From cd28ab6a4e50a7601d22752aa7ce0c8197b10bdf Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 16 Aug 2005 16:36:49 -0700 Subject: [PATCH] sky2: new experimental Marvell Yukon2 driver New driver for the Marvell Yukon2 Gigabit Ethernet chipset. This driver is based on the skge driver, but using the logic from the SysKonnect version of the sk98lin driver. It should support all the Yukon2 chipsets that are available in many current Intel and AMD motherboards. The driver does support ethtool, tx and rx checksum, and tcp segmentation offload. But it has only been tested for a short while and is known to stop receiving under heavy load. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/Kconfig | 20 +- drivers/net/Makefile | 1 + drivers/net/sky2.c | 2686 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/sky2.h | 1935 ++++++++++++++++++++++++++++++++++++ 4 files changed, 4641 insertions(+), 1 deletion(-) create mode 100644 drivers/net/sky2.c create mode 100644 drivers/net/sky2.h diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 8a835eb..4d7489a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -1932,7 +1932,25 @@ config SKGE It does not support the link failover and network management features that "portable" vendor supplied sk98lin driver does. - + + +config SKY2 + tristate "SysKonnect Yukon2 support (EXPERIMENTAL)" + depends on PCI && EXPERIMENTAL + select CRC32 + ---help--- + This driver support the Marvell Yukon 2 Gigabit Ethernet adapter. + + To compile this driver as a module, choose M here: the module + will be called sky2. This is recommended. + +config SKY2_EC_A1 + bool "Support old Yukon-EC A1 chipset" + depends on SKY2 + ---help--- + Include support for early revisions of the Yukon EC chipset + that required extra workarounds. If in doubt, say N. + config SK98LIN tristate "Marvell Yukon Chipset / SysKonnect SK-98xx Support" depends on PCI diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 63c6d1e..7e5c0d4 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_TIGON3) += tg3.o obj-$(CONFIG_BNX2) += bnx2.o obj-$(CONFIG_TC35815) += tc35815.o obj-$(CONFIG_SKGE) += skge.o +obj-$(CONFIG_SKY2) += sky2.o obj-$(CONFIG_SK98LIN) += sk98lin/ obj-$(CONFIG_SKFP) += skfp/ obj-$(CONFIG_VIA_RHINE) += via-rhine.o diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c new file mode 100644 index 0000000..cfb2b41 --- /dev/null +++ b/drivers/net/sky2.c @@ -0,0 +1,2686 @@ +/* + * New driver for Marvell Yukon 2 chipset. + * Based on earlier sk98lin, and skge driver. + * + * This driver intentionally does not support all the features + * of the original driver such as link fail-over and link management because + * those should be done at higher levels. + * + * Copyright (C) 2005 Stephen Hemminger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * TODO + * - coalescing setting? + * - variable ring size? + * + * TOTEST + * - speed setting + * - power management + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "sky2.h" + +#define DRV_NAME "sky2" +#define DRV_VERSION "0.2" +#define PFX DRV_NAME " " + +/* + * The Yukon II chipset takes 64 bit command blocks (called list elements) + * that are organized into three (receive, transmit, status) different rings + * similar to Tigon3. A transmit can require several elements; + * a receive requires one (or two if using 64 bit dma). + */ + +#ifdef CONFIG_SKY2_EC_A1 +#define is_ec_a1(hw) \ + ((hw)->chip_id == CHIP_ID_YUKON_EC && \ + (hw)->chip_rev == CHIP_REV_YU_EC_A1) +#else +#define is_ec_a1(hw) 0 +#endif + +#define RX_LE_SIZE 256 +#define MIN_RX_BUFFERS 8 +#define MAX_RX_BUFFERS 124 +#define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) + +#define TX_RING_SIZE 256 // min 64 max 4096 +#define STATUS_RING_SIZE 1024 // pow2 > (2*Rx + Tx) +#define STATUS_LE_BYTES (STATUS_RING_SIZE*sizeof(struct sky2_status_le)) +#define ETH_JUMBO_MTU 9000 +#define TX_WATCHDOG (5 * HZ) +#define NAPI_WEIGHT 64 +#define PHY_RETRIES 1000 + +static const u32 default_msg = + NETIF_MSG_DRV| NETIF_MSG_PROBE| NETIF_MSG_LINK + | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR + | NETIF_MSG_IFUP| NETIF_MSG_IFDOWN; + +static int debug = -1; /* defaults above */ +module_param(debug, int, 0); +MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); + +static const struct pci_device_id sky2_id_table[] = { + { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, + { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, + { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, + { 0 } +}; +MODULE_DEVICE_TABLE(pci, sky2_id_table); + +/* Avoid conditionals by using array */ +static const unsigned txqaddr[] = { Q_XA1, Q_XA2 }; +static const unsigned rxqaddr[] = { Q_R1, Q_R2 }; + +static inline const char *chip_name(u8 chip_id) +{ + switch (chip_id) { + case CHIP_ID_GENESIS: + return "Genesis"; + case CHIP_ID_YUKON: + return "Yukon"; + case CHIP_ID_YUKON_LITE: + return "Yukon-Lite"; + case CHIP_ID_YUKON_LP: + return "Yukon-LP"; + case CHIP_ID_YUKON_XL: + return "Yukon-XL"; + case CHIP_ID_YUKON_EC: + return "Yukon-EC"; + case CHIP_ID_YUKON_FE: + return "Yukon-FE"; + default: + return "???"; + } +} + +static void gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) +{ + int i; + + gma_write16(hw, port, GM_SMI_DATA, val); + gma_write16(hw, port, GM_SMI_CTRL, + GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg)); + + for (i = 0; i < PHY_RETRIES; i++) { + udelay(1); + + if (!(gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY)) + break; + } +} + +static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) +{ + int i; + + gma_write16(hw, port, GM_SMI_CTRL, + GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) + | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD); + + for (i = 0; i < PHY_RETRIES; i++) { + udelay(1); + if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) + goto ready; + } + + printk(KERN_WARNING PFX "%s: phy read timeout\n", + hw->dev[port]->name); + ready: + return gma_read16(hw, port, GM_SMI_DATA); +} + +static void sky2_phy_reset(struct sky2_hw *hw, unsigned port) +{ + u16 reg; + + /* disable all GMAC IRQ's */ + sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), 0); + /* disable PHY IRQs */ + gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0); + gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */ + gma_write16(hw, port, GM_MC_ADDR_H2, 0); + gma_write16(hw, port, GM_MC_ADDR_H3, 0); + gma_write16(hw, port, GM_MC_ADDR_H4, 0); + + reg = gma_read16(hw, port, GM_RX_CTRL); + reg |= GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA; + gma_write16(hw, port, GM_RX_CTRL, reg); +} + +static void sky2_phy_init(struct sky2_hw *hw, unsigned port) +{ + struct sky2_port *sky2 = netdev_priv(hw->dev[port]); + u16 ctrl, ct1000, adv; + u16 ledctrl, ledover; + + pr_debug("phy reset autoneg=%s advertising=0x%x pause rx=%s tx=%s\n", + sky2->autoneg == AUTONEG_ENABLE ? "enable" : "disable", + sky2->advertising, + sky2->rx_pause ? "on" : "off", + sky2->tx_pause ? "on" : "off"); + + if (sky2->autoneg == AUTONEG_ENABLE && + hw->chip_id != CHIP_ID_YUKON_XL) { + u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); + + ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK | + PHY_M_EC_MAC_S_MSK); + ectrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ); + + if (hw->chip_id == CHIP_ID_YUKON_EC) + ectrl |= PHY_M_EC_DSC_2(2) | PHY_M_EC_DOWN_S_ENA; + else + ectrl |= PHY_M_EC_M_DSC(2) | PHY_M_EC_S_DSC(3); + + gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, ectrl); + } + + ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL); + if (hw->copper) { + if (hw->chip_id == CHIP_ID_YUKON_FE) { + /* enable automatic crossover */ + ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO) >> 1; + } else { + /* disable energy detect */ + ctrl &= ~PHY_M_PC_EN_DET_MSK; + + /* enable automatic crossover */ + ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO); + + if (sky2->autoneg == AUTONEG_ENABLE && + hw->chip_id == CHIP_ID_YUKON_XL) { + ctrl &= ~PHY_M_PC_DSC_MSK; + ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA; + } + } + gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl); + } else { + /* workaround for deviation #4.88 (CRC errors) */ + /* disable Automatic Crossover */ + + ctrl &= ~PHY_M_PC_MDIX_MSK; + gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl); + + if (hw->chip_id == CHIP_ID_YUKON_XL) { + /* Fiber: select 1000BASE-X only mode MAC Specific Ctrl Reg. */ + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 2); + ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL); + ctrl &= ~PHY_M_MAC_MD_MSK; + ctrl |= PHY_M_MAC_MODE_SEL(PHY_M_MAC_MD_1000BX); + gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl); + + /* select page 1 to access Fiber registers */ + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 1); + } + + ctrl &= ~(PHY_M_PC_MDIX_MSK | PHY_M_MAC_MD_MSK); + ctrl |= PHY_M_MAC_MODE_SEL(PHY_M_MAC_MD_1000BX); + } + + ctrl = gm_phy_read(hw, port, PHY_MARV_CTRL); + if (sky2->autoneg == AUTONEG_DISABLE) + ctrl &= ~PHY_CT_ANE; + else + ctrl |= PHY_CT_ANE; + + ctrl |= PHY_CT_RESET; + gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl); + + ctrl = 0; + ct1000 = 0; + adv = PHY_AN_CSMA; + + if (sky2->autoneg == AUTONEG_ENABLE) { + if (hw->copper) { + if (sky2->advertising & ADVERTISED_1000baseT_Full) + ct1000 |= PHY_M_1000C_AFD; + if (sky2->advertising & ADVERTISED_1000baseT_Half) + ct1000 |= PHY_M_1000C_AHD; + if (sky2->advertising & ADVERTISED_100baseT_Full) + adv |= PHY_M_AN_100_FD; + if (sky2->advertising & ADVERTISED_100baseT_Half) + adv |= PHY_M_AN_100_HD; + if (sky2->advertising & ADVERTISED_10baseT_Full) + adv |= PHY_M_AN_10_FD; + if (sky2->advertising & ADVERTISED_10baseT_Half) + adv |= PHY_M_AN_10_HD; + } else /* special defines for FIBER (88E1011S only) */ + adv |= PHY_M_AN_1000X_AHD | PHY_M_AN_1000X_AFD; + + /* Set Flow-control capabilities */ + if (sky2->tx_pause && sky2->rx_pause) + adv |= PHY_AN_PAUSE_CAP; /* symmetric */ + else if (sky2->rx_pause && !sky2->tx_pause) + adv |= PHY_AN_PAUSE_ASYM|PHY_AN_PAUSE_CAP; + else if (!sky2->rx_pause && sky2->tx_pause) + adv |= PHY_AN_PAUSE_ASYM; /* local */ + + /* Restart Auto-negotiation */ + ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG; + } else { + /* forced speed/duplex settings */ + ct1000 = PHY_M_1000C_MSE; + + if (sky2->duplex == DUPLEX_FULL) + ctrl |= PHY_CT_DUP_MD; + + switch (sky2->speed) { + case SPEED_1000: + ctrl |= PHY_CT_SP1000; + break; + case SPEED_100: + ctrl |= PHY_CT_SP100; + break; + } + + ctrl |= PHY_CT_RESET; + } + + if (hw->chip_id != CHIP_ID_YUKON_FE) + gm_phy_write(hw, port, PHY_MARV_1000T_CTRL, ct1000); + + gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, adv); + gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl); + + /* Setup Phy LED's */ + ledctrl = PHY_M_LED_PULS_DUR(PULS_170MS); + ledover = 0; + + switch (hw->chip_id) { + case CHIP_ID_YUKON_FE: + /* on 88E3082 these bits are at 11..9 (shifted left) */ + ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) << 1; + + ctrl = gm_phy_read(hw, port, PHY_MARV_FE_LED_PAR); + + /* delete ACT LED control bits */ + ctrl &= ~PHY_M_FELP_LED1_MSK; + /* change ACT LED control to blink mode */ + ctrl |= PHY_M_FELP_LED1_CTRL(LED_PAR_CTRL_ACT_BL); + gm_phy_write(hw, port, PHY_MARV_FE_LED_PAR, ctrl); + break; + + case CHIP_ID_YUKON_XL: + ctrl = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); + + /* select page 3 to access LED control register */ + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); + + /* set LED Function Control register */ + gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, + (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ + PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */ + PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ + PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */ + + /* set Polarity Control register */ + gm_phy_write(hw, port, PHY_MARV_PHY_STAT, + (PHY_M_POLC_LS1_P_MIX(4) | PHY_M_POLC_IS0_P_MIX(4) | + PHY_M_POLC_LOS_CTRL(2) | PHY_M_POLC_INIT_CTRL(2) | + PHY_M_POLC_STA1_CTRL(2) | PHY_M_POLC_STA0_CTRL(2))); + + /* restore page register */ + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, ctrl); + break; + + default: + /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ + ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL; + /* turn off the Rx LED (LED_RX) */ + ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); + } + + gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); + + if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) { + /* turn on 100 Mbps LED (LED_LINK100) */ + ledover |= PHY_M_LED_MO_100(MO_LED_ON); + } + + if (ledover) + gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); + + /* Enable phy interrupt on autonegotiation complete (or link up) */ + if (sky2->autoneg == AUTONEG_ENABLE) + gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_COMPL); + else + gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); +} + +static void sky2_mac_init(struct sky2_hw *hw, unsigned port) +{ + struct sky2_port *sky2 = netdev_priv(hw->dev[port]); + u16 reg; + int i; + const u8 *addr = hw->dev[port]->dev_addr; + + sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); + sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR); + + sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR); + + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 + && port == 1) { + /* WA DEV_472 -- looks like crossed wires on port 2 */ + /* clear GMAC 1 Control reset */ + sky2_write8(hw, SK_REG(0, GMAC_CTRL), GMC_RST_CLR); + do { + sky2_write8(hw, SK_REG(1, GMAC_CTRL), GMC_RST_SET); + sky2_write8(hw, SK_REG(1, GMAC_CTRL), GMC_RST_CLR); + } while (gm_phy_read(hw, 1, PHY_MARV_ID0) != PHY_MARV_ID0_VAL || + gm_phy_read(hw, 1, PHY_MARV_ID1) != PHY_MARV_ID1_Y2 || + gm_phy_read(hw, 1, PHY_MARV_INT_MASK) != 0); + } + + + if (sky2->autoneg == AUTONEG_DISABLE) { + reg = gma_read16(hw, port, GM_GP_CTRL); + reg |= GM_GPCR_AU_ALL_DIS; + gma_write16(hw, port, GM_GP_CTRL, reg); + gma_read16(hw, port, GM_GP_CTRL); + + + switch (sky2->speed) { + case SPEED_1000: + reg |= GM_GPCR_SPEED_1000; + /* fallthru */ + case SPEED_100: + reg |= GM_GPCR_SPEED_100; + } + + if (sky2->duplex == DUPLEX_FULL) + reg |= GM_GPCR_DUP_FULL; + } else + reg = GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100 | GM_GPCR_DUP_FULL; + + if (!sky2->tx_pause && !sky2->rx_pause) { + sky2_write32(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); + reg |= GM_GPCR_FC_TX_DIS | GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; + } else if (sky2->tx_pause &&!sky2->rx_pause) { + /* disable Rx flow-control */ + reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; + } + + gma_write16(hw, port, GM_GP_CTRL, reg); + + sky2_read16(hw, GMAC_IRQ_SRC); + + spin_lock_bh(&hw->phy_lock); + sky2_phy_init(hw, port); + spin_unlock_bh(&hw->phy_lock); + + /* MIB clear */ + reg = gma_read16(hw, port, GM_PHY_ADDR); + gma_write16(hw, port, GM_PHY_ADDR, reg | GM_PAR_MIB_CLR); + + for (i = 0; i < GM_MIB_CNT_SIZE; i++) + gma_read16(hw, port, GM_MIB_CNT_BASE + 8*i); + gma_write16(hw, port, GM_PHY_ADDR, reg); + + /* transmit control */ + gma_write16(hw, port, GM_TX_CTRL, TX_COL_THR(TX_COL_DEF)); + + /* receive control reg: unicast + multicast + no FCS */ + gma_write16(hw, port, GM_RX_CTRL, + GM_RXCR_UCF_ENA | GM_RXCR_CRC_DIS | GM_RXCR_MCF_ENA); + + /* transmit flow control */ + gma_write16(hw, port, GM_TX_FLOW_CTRL, 0xffff); + + /* transmit parameter */ + gma_write16(hw, port, GM_TX_PARAM, + TX_JAM_LEN_VAL(TX_JAM_LEN_DEF) | + TX_JAM_IPG_VAL(TX_JAM_IPG_DEF) | + TX_IPG_JAM_DATA(TX_IPG_JAM_DEF) | + TX_BACK_OFF_LIM(TX_BOF_LIM_DEF)); + + /* serial mode register */ + reg = DATA_BLIND_VAL(DATA_BLIND_DEF) | + GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); + + if (hw->dev[port]->mtu > 1500) + reg |= GM_SMOD_JUMBO_ENA; + + gma_write16(hw, port, GM_SERIAL_MODE, reg); + + /* physical address: used for pause frames */ + gma_set_addr(hw, port, GM_SRC_ADDR_1L, addr); + /* virtual address for data */ + gma_set_addr(hw, port, GM_SRC_ADDR_2L, addr); + + /* enable interrupt mask for counter overflows */ + gma_write16(hw, port, GM_TX_IRQ_MSK, 0); + gma_write16(hw, port, GM_RX_IRQ_MSK, 0); + gma_write16(hw, port, GM_TR_IRQ_MSK, 0); + + /* Configure Rx MAC FIFO */ + sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR); + sky2_write16(hw, SK_REG(port, RX_GMF_CTRL_T), + GMF_OPER_ON | GMF_RX_F_FL_ON); + + reg = RX_FF_FL_DEF_MSK; + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev <= 1) + reg = 0; /* WA Dev #4115 */ + + sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), reg); + /* Set threshold to 0xa (64 bytes) + * ASF disabled so no need to do WA dev #4.30 + */ + sky2_write16(hw, SK_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF); + + /* Configure Tx MAC FIFO */ + sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR); + sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON); + + /* Turn off Rx fifo flush (per sk98lin) */ + sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RX_F_FL_OFF); +} + +static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) +{ + u32 end; + + start /= 8; + len /= 8; + end = start + len - 1; + pr_debug("ramset q=%d start=0x%x end=0x%x\n", q, start, end); + + sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); + sky2_write32(hw, RB_ADDR(q, RB_START), start); + sky2_write32(hw, RB_ADDR(q, RB_END), end); + sky2_write32(hw, RB_ADDR(q, RB_WP), start); + sky2_write32(hw, RB_ADDR(q, RB_RP), start); + + if (q == Q_R1 || q == Q_R2) { + /* Set thresholds on receive queue's */ + sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), + start + (2*len)/3); + sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), + start + (len/3)); + } else { + /* Enable store & forward on Tx queue's because + * Tx FIFO is only 1K on Yukon + */ + sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_ENA_STFWD); + } + + sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_ENA_OP_MD); +} + + +/* Setup Bus Memory Interface */ +static void sky2_qset(struct sky2_hw *hw, u16 q, u32 wm) +{ + sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_RESET); + sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_OPER_INIT); + sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_FIFO_OP_ON); + sky2_write32(hw, Q_ADDR(q, Q_WM), wm); +} + + +/* Setup prefetch unit registers. This is the interface between + * hardware and driver list elements + */ +static inline void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr, + u64 addr, u32 last) +{ + pr_debug("sky2 prefetch init q=%x addr=%llx last=%x\n", + Y2_QADDR(qaddr, 0), addr, last); + + sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); + sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_RST_CLR); + sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_ADDR_HI), addr >> 32); + sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_ADDR_LO), (u32) addr); + sky2_write16(hw, Y2_QADDR(qaddr, PREF_UNIT_LAST_IDX), last); + sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_OP_ON); +} + + +/* + * This is a workaround code taken from syskonnect sk98lin driver + * to deal with chip bug in the wraparound case. + */ +static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, + u16 idx, u16 *last, u16 size) + +{ + BUG_ON(idx >= size); + + wmb(); + if (is_ec_a1(hw) && idx < *last) { + u16 hwget = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_GET_IDX)); + + if (hwget == 0) { + /* Start prefetching again */ + sky2_write8(hw, Y2_QADDR(q, PREF_UNIT_FIFO_WM), + 0xe0); + goto setnew; + } + + if (hwget == size-1) { + /* set watermark to one list element */ + sky2_write8(hw, Y2_QADDR(q, PREF_UNIT_FIFO_WM), 8); + + /* set put index to first list element */ + sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), 0); + } else /* have hardware go to end of list */ + sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), size-1); + } else { + setnew: + sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx); + *last = idx; + } +} + +static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) +{ + struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put; + sky2->rx_put = (sky2->rx_put + 1) % RX_LE_SIZE; + return le; +} + +static inline void sky2_rx_add(struct sky2_port *sky2, dma_addr_t map, u16 len) +{ + struct sky2_rx_le *le; + + if (sizeof(map) > sizeof(u32)) { + le = sky2_next_rx(sky2); + le->rx.addr = cpu_to_le32((u64) map >> 32); + le->ctrl = 0; + le->opcode = OP_ADDR64 | HW_OWNER; + } + + le = sky2_next_rx(sky2); + le->rx.addr = cpu_to_le32((u32) map); + le->length = cpu_to_le16(len); + le->ctrl = 0; + le->opcode = OP_PACKET | HW_OWNER; +} + +/* Tell chip where to start receive checksum. + * Actually has two checksums, but set both same to avoid possible byte + * order problems. + */ +static void sky2_rx_set_offset(struct sky2_port *sky2) +{ + struct sky2_rx_le *le; + + sky2_write32(sky2->hw, + Q_ADDR(rxqaddr[sky2->port], Q_CSR), + sky2->rx_csum ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); + + le = sky2_next_rx(sky2); + le->rx.csum.start1 = ETH_HLEN; + le->rx.csum.start2 = ETH_HLEN; + le->ctrl = 0; + le->opcode = OP_TCPSTART | HW_OWNER; + wmb(); + sky2_write16(sky2->hw, + Y2_QADDR(rxqaddr[sky2->port], PREF_UNIT_PUT_IDX), + sky2->rx_put); + +} + +/* Cleanout receive buffer area, assumes receiver hardware stopped */ +static void sky2_rx_clean(struct sky2_port *sky2) +{ + unsigned i; + + memset(sky2->rx_le, 0, RX_LE_BYTES); + for (i = 0; i < sky2->rx_ring_size; i++) { + struct ring_info *re = sky2->rx_ring + i; + + if (re->skb) { + pci_unmap_single(sky2->hw->pdev, + pci_unmap_addr(re, mapaddr), + pci_unmap_len(re, maplen), + PCI_DMA_FROMDEVICE); + kfree_skb(re->skb); + re->skb = NULL; + } + } +} + +static inline struct sk_buff *sky2_rx_alloc_skb(struct sky2_port *sky2, + unsigned int size, int gfp_mask) +{ + struct sk_buff *skb; + + skb = alloc_skb(size, gfp_mask); + if (likely(skb)) { + skb->dev = sky2->netdev; + skb_reserve(skb, NET_IP_ALIGN); + } + return skb; +} + +/* + * Allocate and setup receiver buffer pool. + * In case of 64 bit dma, there are 2X as many list elements + * available as ring entries + * and need to reserve one list element so we don't wrap around. + */ +static int sky2_rx_fill(struct sky2_port *sky2) +{ + unsigned i; + unsigned int rx_buf_size = sky2->netdev->mtu + ETH_HLEN + 8; + + pr_debug("sky2_rx_fill %d\n", sky2->rx_ring_size); + for (i = 0; i < sky2->rx_ring_size; i++) { + struct ring_info *re = sky2->rx_ring + i; + dma_addr_t paddr; + + re->skb = sky2_rx_alloc_skb(sky2, rx_buf_size, GFP_KERNEL); + if (!re->skb) + goto nomem; + + paddr = pci_map_single(sky2->hw->pdev, re->skb->data, + rx_buf_size, PCI_DMA_FROMDEVICE); + + pci_unmap_len_set(re, maplen, rx_buf_size); + pci_unmap_addr_set(re, mapaddr, paddr); + sky2_rx_add(sky2, paddr, rx_buf_size); + } + + sky2_write16(sky2->hw, + Y2_QADDR(rxqaddr[sky2->port], PREF_UNIT_PUT_IDX), + sky2->rx_put); + + return 0; +nomem: + sky2_rx_clean(sky2); + return -ENOMEM; +} + +/* Bring up network interface. */ +static int sky2_up(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + u32 ramsize, rxspace; + int err = -ENOMEM; + + if (netif_msg_ifup(sky2)) + printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); + + /* must be power of 2 */ + sky2->tx_le = pci_alloc_consistent(hw->pdev, + TX_RING_SIZE * sizeof(struct sky2_tx_le), + &sky2->tx_le_map); + if (!sky2->tx_le) + goto err_out; + + sky2->tx_ring = kmalloc(TX_RING_SIZE * sizeof(struct ring_info), + GFP_KERNEL); + if (!sky2->tx_ring) + goto err_out; + sky2->tx_prod = sky2->tx_cons = 0; + memset(sky2->tx_ring, 0, TX_RING_SIZE * sizeof(struct ring_info)); + + sky2->rx_le = pci_alloc_consistent(hw->pdev, RX_LE_BYTES, + &sky2->rx_le_map); + if (!sky2->rx_le) + goto err_out; + memset(sky2->rx_le, 0, RX_LE_BYTES); + + sky2->rx_ring = kmalloc(sky2->rx_ring_size * sizeof(struct ring_info), + GFP_KERNEL); + if (!sky2->rx_ring) + goto err_out; + + sky2_mac_init(hw, port); + + /* Configure RAM buffers */ + if (hw->chip_id == CHIP_ID_YUKON_FE || + (hw->chip_id == CHIP_ID_YUKON_EC && hw->chip_rev == 2)) + ramsize = 4096; + else { + u8 e0 = sky2_read8(hw, B2_E_0); + ramsize = (e0 == 0) ? (128*1024) : (e0 * 4096); + } + + /* 2/3 for Rx */ + rxspace = (2 * ramsize) / 3; + sky2_ramset(hw, rxqaddr[port], 0, rxspace); + sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace); + + sky2_qset(hw, rxqaddr[port], is_pciex(hw) ? 0x80 : 0x600); + sky2_qset(hw, txqaddr[port], 0x600); + + sky2->rx_put = sky2->rx_next = 0; + sky2_prefetch_init(hw, rxqaddr[port], sky2->rx_le_map, RX_LE_SIZE-1); + + sky2_rx_set_offset(sky2); + + err = sky2_rx_fill(sky2); + if (err) + goto err_out; + + sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, + TX_RING_SIZE - 1); + + /* Enable interrupts from phy/mac for port */ + hw->intr_mask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2; + sky2_write32(hw, B0_IMSK, hw->intr_mask); + return 0; + +err_out: + if (sky2->rx_le) + pci_free_consistent(hw->pdev, RX_LE_BYTES, + sky2->rx_le, sky2->rx_le_map); + if (sky2->tx_le) + pci_free_consistent(hw->pdev, + TX_RING_SIZE * sizeof(struct sky2_tx_le), + sky2->tx_le, sky2->tx_le_map); + if (sky2->tx_ring) + kfree(sky2->tx_ring); + if (sky2->rx_ring) + kfree(sky2->rx_ring); + + return err; +} + +/* + * Worst case number of list elements is 36 + * TSO + CHKSUM + ADDR64 + BUFFER + (ADDR+BUFFER)*MAXFRAGS + */ +#define MAX_SKB_TX_LE (4 + 2*MAX_SKB_FRAGS) + +static inline int sky2_xmit_avail(const struct sky2_port *sky2) +{ + return (sky2->tx_cons > sky2->tx_prod ? 0 : TX_RING_SIZE) + + sky2->tx_cons - sky2->tx_prod - 1; +} + +static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2) +{ + struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod; + sky2->tx_prod = (sky2->tx_prod + 1) % TX_RING_SIZE; + return le; +} + +/* Put one frame in ring for transmit. */ +static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + struct sky2_tx_le *le; + struct ring_info *re; + unsigned i, len; + dma_addr_t mapping; + u32 addr64; + u16 mss; + u8 ctrl; + + skb = skb_padto(skb, ETH_ZLEN); + if (!skb) + return NETDEV_TX_OK; + + if (!spin_trylock(&sky2->tx_lock)) + return NETDEV_TX_LOCKED; + + if (unlikely(sky2_xmit_avail(sky2) < MAX_SKB_TX_LE)) { + netif_stop_queue(dev); + spin_unlock(&sky2->tx_lock); + + printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", + dev->name); + return NETDEV_TX_BUSY; + } + + if (netif_msg_tx_queued(sky2)) + printk(KERN_DEBUG "%s: tx queued, slot %u, len %d\n", + dev->name, sky2->tx_prod, skb->len); + + + len = skb_headlen(skb); + mapping = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE); + + /* Check for TCP Segmentation Offload */ + mss = skb_shinfo(skb)->tso_size; + if (mss) { + /* just drop the packet if non-linear expansion fails */ + if (skb_header_cloned(skb) && + pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { + dev_kfree_skb(skb); + return NETDEV_TX_OK; + } + + mss += ((skb->h.th->doff - 5) * 4); /* TCP options */ + mss += (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); + mss += ETH_HLEN; + + le = get_tx_le(sky2); + le->tx.tso.size = cpu_to_le16(mss); + le->ctrl = 0; + le->opcode = OP_LRGLEN | HW_OWNER; + } + + /* Handle Hi DMA */ + if (sizeof(mapping) > sizeof(u32)) { + addr64 = (u64)mapping >> 32; + + le = get_tx_le(sky2); + le->tx.addr = cpu_to_le32(addr64); + le->ctrl = 0; + le->opcode = OP_ADDR64 | HW_OWNER; + } + + /* Handle TCP checksum offload */ + ctrl = 0; + if (skb->ip_summed == CHECKSUM_HW) { + ptrdiff_t hdr = skb->h.raw - skb->data; + + ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM; + if (skb->nh.iph->protocol == IPPROTO_UDP) + ctrl |= UDPTCP; + + le = get_tx_le(sky2); + le->tx.csum.start = cpu_to_le16(hdr); + le->tx.csum.offset = cpu_to_le16(hdr + skb->csum); + le->length = 0; + le->ctrl = 1; /* one packet */ + le->opcode = OP_TCPLISW|HW_OWNER; + } + + le = get_tx_le(sky2); + le->tx.addr = cpu_to_le32((u32) mapping); + le->length = cpu_to_le16(len); + le->ctrl = ctrl; + le->opcode = (mss ? OP_LARGESEND : OP_PACKET) |HW_OWNER; + + re = &sky2->tx_ring[le - sky2->tx_le]; + re->skb = skb; + pci_unmap_addr_set(re, mapaddr, mapping); + pci_unmap_len_set(re, maplen, len); + + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; + + mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset, + frag->size, PCI_DMA_TODEVICE); + + if (sizeof(mapping) > sizeof(u32)) { + u32 hi = (u64) mapping >> 32; + if (hi != addr64) { + le = get_tx_le(sky2); + le->tx.addr = cpu_to_le32(hi); + le->ctrl = 0; + le->opcode = OP_ADDR64|HW_OWNER; + addr64 = hi; + } + } + + le = get_tx_le(sky2); + le->tx.addr = cpu_to_le32((u32) mapping); + le->length = cpu_to_le16(frag->size); + le->ctrl = ctrl; + le->opcode = OP_BUFFER|HW_OWNER; + + re = &sky2->tx_ring[le - sky2->tx_le]; + pci_unmap_addr_set(re, mapaddr, mapping); + pci_unmap_len_set(re, maplen, frag->size); + } + + le->ctrl |= EOP; + + sky2_put_idx(sky2->hw, txqaddr[sky2->port], sky2->tx_prod, + &sky2->tx_last_put, TX_RING_SIZE); + + if (sky2_xmit_avail(sky2) < MAX_SKB_TX_LE) { + pr_debug("%s: transmit queue full\n", dev->name); + netif_stop_queue(dev); + } + spin_unlock(&sky2->tx_lock); + + dev->trans_start = jiffies; + return NETDEV_TX_OK; +} + + +/* + * Free ring elements from starting at tx_cons until done + * This unwinds the elements based on the usage assigned + * xmit routine. + */ +static void sky2_tx_complete(struct net_device *dev, u16 done) +{ + struct sky2_port *sky2 = netdev_priv(dev); + unsigned idx = sky2->tx_cons; + struct sk_buff *skb = NULL; + + BUG_ON(done >= TX_RING_SIZE); + + spin_lock(&sky2->tx_lock); + while (idx != done) { + struct ring_info *re = sky2->tx_ring + idx; + struct sky2_tx_le *le = sky2->tx_le + idx; + + BUG_ON(le->opcode == 0); + + switch(le->opcode & ~HW_OWNER) { + case OP_LARGESEND: + case OP_PACKET: + if (skb) + dev_kfree_skb_any(skb); + skb = re->skb; + BUG_ON(!skb); + re->skb = NULL; + + pci_unmap_single(sky2->hw->pdev, + pci_unmap_addr(re, mapaddr), + pci_unmap_len(re, maplen), + PCI_DMA_TODEVICE); + break; + + case OP_BUFFER: + pci_unmap_page(sky2->hw->pdev, + pci_unmap_addr(re, mapaddr), + pci_unmap_len(re, maplen), + PCI_DMA_TODEVICE); + break; + } + + le->opcode = 0; + idx = (idx + 1) % TX_RING_SIZE; + } + + if (skb) + dev_kfree_skb_any(skb); + sky2->tx_cons = idx; + + if (sky2_xmit_avail(sky2) > MAX_SKB_TX_LE) + netif_wake_queue(dev); + spin_unlock(&sky2->tx_lock); +} + +/* Cleanup all untransmitted buffers, assume transmitter not running */ +static inline void sky2_tx_clean(struct sky2_port *sky2) +{ + sky2_tx_complete(sky2->netdev, sky2->tx_prod); +} + +/* Network shutdown */ +static int sky2_down(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + u16 ctrl; + int i; + + if (netif_msg_ifdown(sky2)) + printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); + + netif_stop_queue(dev); + + /* Stop transmitter */ + sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_STOP); + sky2_read32(hw, Q_ADDR(txqaddr[port], Q_CSR)); + + sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), + RB_RST_SET|RB_DIS_OP_MD); + + ctrl = gma_read16(hw, port, GM_GP_CTRL); + ctrl &= ~(GM_GPCR_TX_ENA|GM_GPCR_RX_ENA); + gma_write16(hw, port, GM_GP_CTRL, ctrl); + + sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); + + /* Workaround shared GMAC reset */ + if (! (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 + && port == 0 && hw->dev[1] && netif_running(hw->dev[1]))) + sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_SET); + + /* Disable Force Sync bit and Enable Alloc bit */ + sky2_write8(hw, SK_REG(port, TXA_CTRL), + TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC); + + /* Stop Interval Timer and Limit Counter of Tx Arbiter */ + sky2_write32(hw, SK_REG(port, TXA_ITI_INI), 0L); + sky2_write32(hw, SK_REG(port, TXA_LIM_INI), 0L); + + /* Reset the PCI FIFO of the async Tx queue */ + sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_RST_SET | BMU_FIFO_RST); + + /* Reset the Tx prefetch units */ + sky2_write32(hw, Y2_QADDR(txqaddr[port], PREF_UNIT_CTRL), + PREF_UNIT_RST_SET); + + sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), RB_RST_SET); + + /* + * The RX Stop command will not work for Yukon-2 if the BMU does not + * reach the end of packet and since we can't make sure that we have + * incoming data, we must reset the BMU while it is not doing a DMA + * transfer. Since it is possible that the RX path is still active, + * the RX RAM buffer will be stopped first, so any possible incoming + * data will not trigger a DMA. After the RAM buffer is stopped, the + * BMU is polled until any DMA in progress is ended and only then it + * will be reset. + */ + + /* disable the RAM Buffer receive queue */ + sky2_write8(hw, RB_ADDR(rxqaddr[port], RB_CTRL), RB_DIS_OP_MD); + + for (i = 0; i < 0xffff; i++) + if (sky2_read8(hw, RB_ADDR(rxqaddr[port], Q_RSL)) + == sky2_read8(hw, RB_ADDR(rxqaddr[port], Q_RL))) + break; + + sky2_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), + BMU_RST_SET | BMU_FIFO_RST); + /* reset the Rx prefetch unit */ + sky2_write32(hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_CTRL), + PREF_UNIT_RST_SET); + + sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET); + sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET); + + /* turn off led's */ + sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); + + sky2_tx_clean(sky2); + sky2_rx_clean(sky2); + + pci_free_consistent(hw->pdev, RX_LE_BYTES, + sky2->rx_le, sky2->rx_le_map); + kfree(sky2->rx_ring); + + pci_free_consistent(hw->pdev, + TX_RING_SIZE * sizeof(struct sky2_tx_le), + sky2->tx_le, sky2->tx_le_map); + kfree(sky2->tx_ring); + + return 0; +} + +static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux) +{ + if (hw->chip_id == CHIP_ID_YUKON_FE) + return (aux & PHY_M_PS_SPEED_100) ? SPEED_100 : SPEED_10; + + switch (aux & PHY_M_PS_SPEED_MSK) { + case PHY_M_PS_SPEED_1000: + return SPEED_1000; + case PHY_M_PS_SPEED_100: + return SPEED_100; + default: + return SPEED_10; + } +} + +static void sky2_link_up(struct sky2_port *sky2) +{ + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + u16 reg; + + /* Enable Transmit FIFO Underrun */ + sky2_write8(hw, GMAC_IRQ_MSK, GMAC_DEF_MSK); + + reg = gma_read16(hw, port, GM_GP_CTRL); + if (sky2->duplex == DUPLEX_FULL || sky2->autoneg == AUTONEG_ENABLE) + reg |= GM_GPCR_DUP_FULL; + + + /* enable Rx/Tx */ + reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA; + gma_write16(hw, port, GM_GP_CTRL, reg); + gma_read16(hw, port, GM_GP_CTRL); + + gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); + + netif_carrier_on(sky2->netdev); + netif_wake_queue(sky2->netdev); + + /* Turn on link LED */ + sky2_write8(hw, SK_REG(port, LNK_LED_REG), + LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF); + + if (netif_msg_link(sky2)) + printk(KERN_INFO PFX + "%s: Link is up at %d Mbps, %s duplex, flowcontrol %s\n", + sky2->netdev->name, sky2->speed, + sky2->duplex == DUPLEX_FULL ? "full" : "half", + (sky2->tx_pause && sky2->rx_pause) ? "both" : + sky2->tx_pause ? "tx" : + sky2->rx_pause ? "rx" : "none"); +} + +static void sky2_link_down(struct sky2_port *sky2) +{ + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + u16 reg; + + gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0); + + reg = gma_read16(hw, port, GM_GP_CTRL); + reg &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA); + gma_write16(hw, port, GM_GP_CTRL, reg); + gma_read16(hw, port, GM_GP_CTRL); /* PCI post */ + + if (sky2->rx_pause && !sky2->tx_pause) { + /* restore Asymmetric Pause bit */ + gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, + gm_phy_read(hw, port, + PHY_MARV_AUNE_ADV) + | PHY_M_AN_ASP); + } + + sky2_phy_reset(hw, port); + + netif_carrier_off(sky2->netdev); + netif_stop_queue(sky2->netdev); + + /* Turn on link LED */ + sky2_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF); + + if (netif_msg_link(sky2)) + printk(KERN_INFO PFX "%s: Link is down.\n", sky2->netdev->name); + sky2_phy_init(hw, port); +} + + +/* + * Interrrupt from PHY are handled in tasklet (soft irq) + * because accessing phy registers requires spin wait which might + * cause excess interrupt latency. + */ +static void sky2_phy_task(unsigned long data) +{ + struct sky2_port *sky2 = (struct sky2_port *) data; + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + u16 istatus, phystat; + + istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT); + + phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT); + + if (netif_msg_intr(sky2)) + printk(KERN_INFO PFX "%s: phy interrupt status 0x%x 0x%x\n", + sky2->netdev->name, istatus, phystat); + + if (istatus & PHY_M_IS_AN_COMPL) { + u16 lpa = gm_phy_read(hw, port, PHY_MARV_AUNE_LP); + + if (lpa & PHY_M_AN_RF) { + printk(KERN_ERR PFX "%s: remote fault", + sky2->netdev->name); + } + else if (hw->chip_id != CHIP_ID_YUKON_FE + && gm_phy_read(hw, port, PHY_MARV_1000T_STAT) + & PHY_B_1000S_MSF) { + printk(KERN_ERR PFX "%s: master/slave fault", + sky2->netdev->name); + } + else if (!(phystat & PHY_M_PS_SPDUP_RES)) { + printk(KERN_ERR PFX "%s: speed/duplex mismatch", + sky2->netdev->name); + } + else { + sky2->duplex = (phystat & PHY_M_PS_FULL_DUP) + ? DUPLEX_FULL : DUPLEX_HALF; + + sky2->speed = sky2_phy_speed(hw, phystat); + + sky2->tx_pause = (phystat & PHY_M_PS_TX_P_EN) != 0; + sky2->rx_pause = (phystat & PHY_M_PS_RX_P_EN) != 0; + + if ((!sky2->tx_pause && !sky2->rx_pause) || + (sky2->speed < SPEED_1000 && sky2->duplex == DUPLEX_HALF)) + sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); + else + sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON); + sky2_link_up(sky2); + } + } else { + + if (istatus & PHY_M_IS_LSP_CHANGE) + sky2->speed = sky2_phy_speed(hw, phystat); + + if (istatus & PHY_M_IS_DUP_CHANGE) + sky2->duplex = (phystat & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF; + if (istatus & PHY_M_IS_LST_CHANGE) { + if (phystat & PHY_M_PS_LINK_UP) + sky2_link_up(sky2); + else + sky2_link_down(sky2); + } + } + + local_irq_disable(); + hw->intr_mask |= (port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2; + sky2_write32(hw, B0_IMSK, hw->intr_mask); + local_irq_enable(); +} + +static void sky2_tx_timeout(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + if (netif_msg_timer(sky2)) + printk(KERN_ERR PFX "%s: tx timeout\n", dev->name); + + sky2_write32(sky2->hw, Q_ADDR(txqaddr[sky2->port], Q_CSR), BMU_STOP); + sky2_read32(sky2->hw, Q_ADDR(txqaddr[sky2->port], Q_CSR)); + + sky2_tx_clean(sky2); +} + +static int sky2_change_mtu(struct net_device *dev, int new_mtu) +{ + int err = 0; + + if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) + return -EINVAL; + + if (netif_running(dev)) + sky2_down(dev); + + dev->mtu = new_mtu; + + if (netif_running(dev)) + err = sky2_up(dev); + + return err; +} + +/* + * Receive one packet. + * For small packets or errors, just reuse existing skb. + * For larger pakects, get new buffer. + */ +static struct sk_buff *sky2_receive(struct sky2_hw *hw, unsigned port, + u16 length, u32 status) +{ + struct net_device *dev = hw->dev[port]; + struct sky2_port *sky2 = netdev_priv(dev); + struct ring_info *re = sky2->rx_ring + sky2->rx_next; + struct sk_buff *skb = re->skb; + dma_addr_t mapping; + const unsigned int rx_buf_size = dev->mtu + ETH_HLEN + 8; + + if (unlikely(netif_msg_rx_status(sky2))) + printk(KERN_DEBUG PFX "%s: rx slot %u status 0x%x len %d\n", + dev->name, sky2->rx_next, status, length); + + sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_ring_size; + + pci_unmap_single(sky2->hw->pdev, + pci_unmap_addr(re, mapaddr), + pci_unmap_len(re, maplen), + PCI_DMA_FROMDEVICE); + prefetch(skb->data); + + if (!(status & GMR_FS_RX_OK) + || (status & GMR_FS_ANY_ERR) + || (length << 16) != (status & GMR_FS_LEN) + || length > rx_buf_size) + goto error; + + re->skb = sky2_rx_alloc_skb(sky2, rx_buf_size, GFP_ATOMIC); + if (!re->skb) + goto reuse; + +submit: + mapping = pci_map_single(sky2->hw->pdev, re->skb->data, + rx_buf_size, PCI_DMA_FROMDEVICE); + + pci_unmap_len_set(re, maplen, rx_buf_size); + pci_unmap_addr_set(re, mapaddr, mapping); + + sky2_rx_add(sky2, mapping, rx_buf_size); + sky2_put_idx(sky2->hw, rxqaddr[sky2->port], + sky2->rx_put, &sky2->rx_last_put, RX_LE_SIZE); + + return skb; + +error: + if (netif_msg_rx_err(sky2)) + printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n", + sky2->netdev->name, status, length); + + if (status & (GMR_FS_LONG_ERR|GMR_FS_UN_SIZE)) + sky2->net_stats.rx_length_errors++; + if (status & GMR_FS_FRAGMENT) + sky2->net_stats.rx_frame_errors++; + if (status & GMR_FS_CRC_ERR) + sky2->net_stats.rx_crc_errors++; +reuse: + re->skb = skb; + skb = NULL; + goto submit; +} + +static u16 get_tx_index(u8 port, u32 status, u16 len) +{ + if (port == 0) + return status & 0xfff; + else + return ((status >> 24) & 0xff) | (len & 0xf) << 8; +} + +/* + * NAPI poll routine. + * Both ports share the same status interrupt, therefore there is only + * one poll routine. + * + */ +static int sky2_poll(struct net_device *dev, int *budget) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + unsigned int to_do = min(dev->quota, *budget); + unsigned int work_done = 0; + unsigned char summed[2] = { CHECKSUM_NONE, CHECKSUM_NONE }; + unsigned int csum[2] = { 0 }; + unsigned int rx_handled[2] = { 0, 0}; + u16 last; + + sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); + last = sky2_read16(hw, STAT_PUT_IDX); + + while (hw->st_idx != last && work_done < to_do) { + struct sky2_status_le *le = hw->st_le + hw->st_idx; + struct sk_buff *skb; + u8 port; + u32 status; + u16 length; + + rmb(); + status = le32_to_cpu(le->status); + length = le16_to_cpu(le->length); + port = le->link; + + BUG_ON(port >= hw->ports); + + switch(le->opcode & ~HW_OWNER) { + case OP_RXSTAT: + ++rx_handled[port]; + skb = sky2_receive(hw, port, length, status); + if (likely(skb)) { + __skb_put(skb, length); + skb->protocol = eth_type_trans(skb, dev); + + /* Add hw checksum if available */ + skb->ip_summed = summed[port]; + skb->csum = csum[port]; + + /* Clear for next packet */ + csum[port] = 0; + summed[port] = CHECKSUM_NONE; + + netif_receive_skb(skb); + + dev->last_rx = jiffies; + ++work_done; + } + break; + + case OP_RXCHKS: + /* Save computed checksum for next rx */ + csum[port] = le16_to_cpu(status & 0xffff); + summed[port] = CHECKSUM_HW; + break; + + case OP_TXINDEXLE: + sky2_tx_complete(hw->dev[port], + get_tx_index(port, status, length)); + break; + + case OP_RXTIMESTAMP: + break; + + default: + if (net_ratelimit()) + printk(KERN_WARNING PFX "unknown status opcode 0x%x\n", + le->opcode); + break; + } + + hw->st_idx = (hw->st_idx + 1) & (STATUS_RING_SIZE -1); + } + + *budget -= work_done; + dev->quota -= work_done; + if (work_done < to_do) { + /* + * Another chip workaround, need to restart TX timer if status + * LE was handled. WA_DEV_43_418 + */ + if (is_ec_a1(hw)) { + sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP); + sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START); + } + + hw->intr_mask |= Y2_IS_STAT_BMU; + sky2_write32(hw, B0_IMSK, hw->intr_mask); + netif_rx_complete(dev); + } + + return work_done >= to_do; + +} + +static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status) +{ + struct net_device *dev = hw->dev[port]; + + printk(KERN_INFO PFX "%s: hw error interrupt status 0x%x\n", + dev->name, status); + + if (status & Y2_IS_PAR_RD1) { + printk(KERN_ERR PFX "%s: ram data read parity error\n", + dev->name); + /* Clear IRQ */ + sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_RD_PERR); + } + + if (status & Y2_IS_PAR_WR1) { + printk(KERN_ERR PFX "%s: ram data write parity error\n", + dev->name); + + sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_WR_PERR); + } + + if (status & Y2_IS_PAR_MAC1) { + printk(KERN_ERR PFX "%s: MAC parity error\n", dev->name); + sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_PE); + } + + if (status & Y2_IS_PAR_RX1) { + printk(KERN_ERR PFX "%s: RX parity error\n", dev->name); + sky2_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), BMU_CLR_IRQ_PAR); + } + + if (status & Y2_IS_TCP_TXA1) { + printk(KERN_ERR PFX "%s: TCP segmentation error\n", dev->name); + sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_CLR_IRQ_TCP); + } +} + +static void sky2_hw_intr(struct sky2_hw *hw) +{ + u32 status = sky2_read32(hw, B0_HWE_ISRC); + + if (status & Y2_IS_TIST_OV) { + pr_debug (PFX "%s: unused timer overflow??\n", + pci_name(hw->pdev)); + sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ); + } + + if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) { + u16 pci_err = sky2_read16(hw, PCI_C(PCI_STATUS)); + printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n", + pci_name(hw->pdev), pci_err); + + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); + sky2_write16(hw, PCI_C(PCI_STATUS), + pci_err | PCI_STATUS_ERROR_BITS); + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); + } + + if (status & Y2_IS_PCI_EXP) { + /* PCI-Express uncorrectable Error occured */ + u32 pex_err = sky2_read32(hw, PCI_C(PEX_UNC_ERR_STAT)); + + /* + * On PCI-Express bus bridges are called root complexes. + * PCI-Express errors are recognized by the root complex too, + * which requests the system to handle the problem. After error + * occurence it may be that no access to the adapter may be performed + * any longer. + */ + printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", + pci_name(hw->pdev), pex_err); + + /* clear the interrupt */ + sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); + sky2_write32(hw, PCI_C(PEX_UNC_ERR_STAT), 0xffffffffUL); + sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); + + if (pex_err & PEX_FATAL_ERRORS) { + u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK); + hwmsk &= ~Y2_IS_PCI_EXP; + sky2_write32(hw, B0_HWE_IMSK, hwmsk); + } + } + + if (status & Y2_HWE_L1_MASK) + sky2_hw_error(hw, 0, status); + status >>= 8; + if (status & Y2_HWE_L1_MASK) + sky2_hw_error(hw, 1, status); +} + +static void sky2_mac_intr(struct sky2_hw *hw, unsigned port) +{ + struct net_device *dev = hw->dev[port]; + struct sky2_port *sky2 = netdev_priv(dev); + u8 status = sky2_read8(hw, SK_REG(port, GMAC_IRQ_SRC)); + + if (netif_msg_intr(sky2)) + printk(KERN_INFO PFX "%s: mac interrupt status 0x%x\n", + dev->name, status); + + if (status & GM_IS_RX_FF_OR) { + ++sky2->net_stats.rx_fifo_errors; + sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO); + } + + if (status & GM_IS_TX_FF_UR) { + ++sky2->net_stats.tx_fifo_errors; + sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_FU); + } + +} + +static void sky2_phy_intr(struct sky2_hw *hw, unsigned port) +{ + struct net_device *dev = hw->dev[port]; + struct sky2_port *sky2 = netdev_priv(dev); + + hw->intr_mask &= ~(port == 0 ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2); + sky2_write32(hw, B0_IMSK, hw->intr_mask); + tasklet_schedule(&sky2->phy_task); +} + +static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs) +{ + struct sky2_hw *hw = dev_id; + u32 status; + + status = sky2_read32(hw, B0_Y2_SP_ISRC2); + if (status == 0 || status == ~0) /* hotplug or shared irq */ + return IRQ_NONE; + + if (status & Y2_IS_HW_ERR) + sky2_hw_intr(hw); + + if ((status & Y2_IS_STAT_BMU) && netif_rx_schedule_prep(hw->dev[0])) { + hw->intr_mask &= ~Y2_IS_STAT_BMU; + sky2_write32(hw, B0_IMSK, hw->intr_mask); + __netif_rx_schedule(hw->dev[0]); + } + + if (status & Y2_IS_IRQ_PHY1) + sky2_phy_intr(hw, 0); + + if (status & Y2_IS_IRQ_PHY2) + sky2_phy_intr(hw, 1); + + if (status & Y2_IS_IRQ_MAC1) + sky2_mac_intr(hw, 0); + + if (status & Y2_IS_IRQ_MAC2) + sky2_mac_intr(hw, 1); + + + sky2_write32(hw, B0_Y2_SP_ICR, 2); + return IRQ_HANDLED; +} + +#ifdef CONFIG_NET_POLL_CONTROLLER +static void sky2_netpoll(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + disable_irq(dev->irq); + sky2_intr(dev->irq, sky2->hw, NULL); + enable_irq(dev->irq); +} +#endif + +/* Chip internal frequency for clock calculations */ +static inline u32 sky2_khz(const struct sky2_hw *hw) +{ + switch(hw->chip_id) { + case CHIP_ID_YUKON_EC: + return 125000; /* 125 Mhz */ + case CHIP_ID_YUKON_FE: + return 100000; /* 100 Mhz */ + default: /* YUKON_XL */ + return 156000; /* 156 Mhz */ + } +} + +static inline u32 sky2_ms2clk(const struct sky2_hw *hw, u32 ms) +{ + return sky2_khz(hw) * ms; +} + +static inline u32 sky2_us2clk(const struct sky2_hw *hw, u32 us) +{ + return (sky2_khz(hw) * 75) / 1000; +} + +static int sky2_reset(struct sky2_hw *hw) +{ + u32 ctst, power; + u16 status; + u8 t8, pmd_type; + int i; + + ctst = sky2_read32(hw, B0_CTST); + + sky2_write8(hw, B0_CTST, CS_RST_CLR); + hw->chip_id = sky2_read8(hw, B2_CHIP_ID); + if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) { + printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n", + pci_name(hw->pdev), hw->chip_id); + return -EOPNOTSUPP; + } + + /* disable ASF */ + if (hw->chip_id <= CHIP_ID_YUKON_EC) { + sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); + sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE); + } + + /* do a SW reset */ + sky2_write8(hw, B0_CTST, CS_RST_SET); + sky2_write8(hw, B0_CTST, CS_RST_CLR); + + /* clear PCI errors, if any */ + status = sky2_read16(hw, PCI_C(PCI_STATUS)); + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); + sky2_write16(hw, PCI_C(PCI_STATUS), + status | PCI_STATUS_ERROR_BITS); + + sky2_write8(hw, B0_CTST, CS_MRST_CLR); + + /* clear any PEX errors */ + if (is_pciex(hw)) { + sky2_write32(hw, PCI_C(PEX_UNC_ERR_STAT), 0xffffffffUL); + sky2_read16(hw, PCI_C(PEX_LNK_STAT)); + } + + pmd_type = sky2_read8(hw, B2_PMD_TYP); + hw->copper = !(pmd_type == 'L' || pmd_type == 'S'); + + hw->ports = 1; + t8 = sky2_read8(hw, B2_Y2_HW_RES); + if ((t8 & CFG_DUAL_MAC_MSK) == CFG_DUAL_MAC_MSK) { + if (!(sky2_read8(hw, B2_Y2_CLK_GATE) & Y2_STATUS_LNK2_INAC)) + ++hw->ports; + } + hw->chip_rev = (sky2_read8(hw, B2_MAC_CFG) & CFG_CHIP_R_MSK) >> 4; + + /* switch power to VCC (WA for VAUX problem) */ + sky2_write8(hw, B0_POWER_CTRL, + PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_OFF | PC_VCC_ON); + + /* disable Core Clock Division, */ + sky2_write32(hw, B2_Y2_CLK_CTRL, Y2_CLK_DIV_DIS); + + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) + /* enable bits are inverted */ + sky2_write8(hw, B2_Y2_CLK_GATE, + Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS | + Y2_CLK_GAT_LNK1_DIS | Y2_PCI_CLK_LNK2_DIS | + Y2_COR_CLK_LNK2_DIS | Y2_CLK_GAT_LNK2_DIS); + else + sky2_write8(hw, B2_Y2_CLK_GATE, 0); + + /* Turn off phy power saving */ + power = sky2_read32(hw, PCI_C(PCI_DEV_REG1)); + power &= ~(PCI_Y2_PHY1_POWD|PCI_Y2_PHY2_POWD); + + /* back asswards .. */ + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) { + power |= PCI_Y2_PHY1_COMA; + if (hw->ports > 1) + power |= PCI_Y2_PHY2_COMA; + } + sky2_write32(hw, PCI_C(PCI_DEV_REG1), power); + + for (i = 0; i < hw->ports; i++) { + sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET); + sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_CLR); + } + + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); + + sky2_write32(hw, B2_I2C_IRQ, 1); /* Clear I2C IRQ noise */ + + /* turn off hardware timer (unused) */ + sky2_write8(hw, B2_TI_CTRL, TIM_STOP); + sky2_write8(hw, B2_TI_CTRL, TIM_CLR_IRQ); + + sky2_write8(hw, B0_Y2LED, LED_STAT_ON); + + /* Turn on descriptor polling -- is this necessary? */ + sky2_write32(hw, B28_DPT_INI, sky2_us2clk(hw, 75)); + sky2_write8(hw, B28_DPT_CTRL, DPT_START); + + /* Turn off receive timestamp */ + sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_STOP); + + /* enable the Tx Arbiters */ + for (i = 0; i < hw->ports; i++) + sky2_write8(hw, SK_REG(i, TXA_CTRL), TXA_ENA_ARB); + + /* Initialize ram interface */ + for (i = 0; i < hw->ports; i++) { + sky2_write16(hw, RAM_BUFFER(i, B3_RI_CTRL), RI_RST_CLR); + + sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_R1), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XA1), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XS1), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_R1), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XA1), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS1), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_R2), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XA2), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XS2), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_R2), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XA2), SK_RI_TO_53); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53); + } + + /* Optimize PCI Express access */ + if (is_pciex(hw)) { + u16 ctrl = sky2_read32(hw, PCI_C(PEX_DEV_CTRL)); + ctrl &= ~PEX_DC_MAX_RRS_MSK; + ctrl |= PEX_DC_MAX_RD_RQ_SIZE(4); + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); + sky2_write16(hw, PCI_C(PEX_DEV_CTRL), ctrl); + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); + } + + sky2_write32(hw, B0_HWE_IMSK, Y2_HWE_ALL_MASK); + + hw->intr_mask = Y2_IS_BASE; + sky2_write32(hw, B0_IMSK, hw->intr_mask); + + /* disable all GMAC IRQ's */ + sky2_write8(hw, GMAC_IRQ_MSK, 0); + + spin_lock_bh(&hw->phy_lock); + for (i = 0; i < hw->ports; i++) + sky2_phy_reset(hw, i); + spin_unlock_bh(&hw->phy_lock); + + /* Setup ring for status responses */ + hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES, + &hw->st_dma); + if (!hw->st_le) + return -ENOMEM; + + memset(hw->st_le, 0, STATUS_LE_BYTES); + hw->st_idx = 0; + + sky2_write32(hw, STAT_CTRL, SC_STAT_RST_SET); + sky2_write32(hw, STAT_CTRL, SC_STAT_RST_CLR); + + sky2_write32(hw, STAT_LIST_ADDR_LO, hw->st_dma); + sky2_write32(hw, STAT_LIST_ADDR_HI, (u64)hw->st_dma >> 32); + + /* Set the list last index */ + sky2_write16(hw, STAT_LAST_IDX, STATUS_RING_SIZE-1); + + if (is_ec_a1(hw)) { + /* WA for dev. #4.3 */ + sky2_write16(hw, STAT_TX_IDX_TH, ST_TXTH_IDX_MASK); + + /* set Status-FIFO watermark */ + sky2_write8(hw, STAT_FIFO_WM, 0x21); /* WA for dev. #4.18 */ + + /* set Status-FIFO ISR watermark */ + sky2_write8(hw, STAT_FIFO_ISR_WM, 0x07);/* WA for dev. #4.18 */ + + /* WA for dev. #4.3 and #4.18 */ + /* set Status-FIFO Tx timer init value */ + sky2_write32(hw, STAT_TX_TIMER_INI, sky2_ms2clk(hw, 10)); + } else { + /* + * Theses settings should avoid the + * temporary hanging of the status BMU. + * May be not all required... still under investigation... + */ + sky2_write16(hw, STAT_TX_IDX_TH, 0x000a); + + /* set Status-FIFO watermark */ + sky2_write8(hw, STAT_FIFO_WM, 0x10); + + /* set Status-FIFO ISR watermark */ + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0) + sky2_write8(hw, STAT_FIFO_ISR_WM, 0x10); + + else /* WA 4109 */ + sky2_write8(hw, STAT_FIFO_ISR_WM, 0x04); + + sky2_write32(hw, STAT_ISR_TIMER_INI, 0x0190); + } + + /* enable the prefetch unit */ + /* operational bit not functional for Yukon-EC, but fixed in Yukon-2? */ + sky2_write32(hw, STAT_CTRL, SC_STAT_OP_ON); + + sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START); + sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_START); + sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START); + + return 0; +} + +static inline u32 sky2_supported_modes(const struct sky2_hw *hw) +{ + u32 modes; + if (hw->copper) { + modes = SUPPORTED_10baseT_Half + | SUPPORTED_10baseT_Full + | SUPPORTED_100baseT_Half + | SUPPORTED_100baseT_Full + | SUPPORTED_Autoneg| SUPPORTED_TP; + + if (hw->chip_id != CHIP_ID_YUKON_FE) + modes |= SUPPORTED_1000baseT_Half + | SUPPORTED_1000baseT_Full; + } else + modes = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE + | SUPPORTED_Autoneg; + return modes; +} + +static int sky2_get_settings(struct net_device *dev, + struct ethtool_cmd *ecmd) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + + ecmd->transceiver = XCVR_INTERNAL; + ecmd->supported = sky2_supported_modes(hw); + ecmd->phy_address = PHY_ADDR_MARV; + if (hw->copper) { + ecmd->supported = SUPPORTED_10baseT_Half + + | SUPPORTED_10baseT_Full + | SUPPORTED_100baseT_Half + | SUPPORTED_100baseT_Full + | SUPPORTED_1000baseT_Half + | SUPPORTED_1000baseT_Full + | SUPPORTED_Autoneg| SUPPORTED_TP; + ecmd->port = PORT_TP; + } else + ecmd->port = PORT_FIBRE; + + ecmd->advertising = sky2->advertising; + ecmd->autoneg = sky2->autoneg; + ecmd->speed = sky2->speed; + ecmd->duplex = sky2->duplex; + return 0; +} + +static int sky2_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) +{ + struct sky2_port *sky2 = netdev_priv(dev); + const struct sky2_hw *hw = sky2->hw; + u32 supported = sky2_supported_modes(hw); + + if (ecmd->autoneg == AUTONEG_ENABLE) { + ecmd->advertising = supported; + sky2->duplex = -1; + sky2->speed = -1; + } else { + u32 setting; + + switch(ecmd->speed) { + case SPEED_1000: + if (ecmd->duplex == DUPLEX_FULL) + setting = SUPPORTED_1000baseT_Full; + else if (ecmd->duplex == DUPLEX_HALF) + setting = SUPPORTED_1000baseT_Half; + else + return -EINVAL; + break; + case SPEED_100: + if (ecmd->duplex == DUPLEX_FULL) + setting = SUPPORTED_100baseT_Full; + else if (ecmd->duplex == DUPLEX_HALF) + setting = SUPPORTED_100baseT_Half; + else + return -EINVAL; + break; + + case SPEED_10: + if (ecmd->duplex == DUPLEX_FULL) + setting = SUPPORTED_10baseT_Full; + else if (ecmd->duplex == DUPLEX_HALF) + setting = SUPPORTED_10baseT_Half; + else + return -EINVAL; + break; + default: + return -EINVAL; + } + + if ((setting & supported) == 0) + return -EINVAL; + + sky2->speed = ecmd->speed; + sky2->duplex = ecmd->duplex; + } + + sky2->autoneg = ecmd->autoneg; + sky2->advertising = ecmd->advertising; + + if (netif_running(dev)) { + sky2_down(dev); + sky2_up(dev); + } + + return 0; +} + +static void sky2_get_drvinfo(struct net_device *dev, + struct ethtool_drvinfo *info) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + strcpy(info->driver, DRV_NAME); + strcpy(info->version, DRV_VERSION); + strcpy(info->fw_version, "N/A"); + strcpy(info->bus_info, pci_name(sky2->hw->pdev)); +} + +static const struct sky2_stat { + char name[ETH_GSTRING_LEN]; + u16 offset; +} sky2_stats[] = { + { "tx_bytes", GM_TXO_OK_HI }, + { "rx_bytes", GM_RXO_OK_HI }, + { "tx_broadcast", GM_TXF_BC_OK }, + { "rx_broadcast", GM_RXF_BC_OK }, + { "tx_multicast", GM_TXF_MC_OK }, + { "rx_multicast", GM_RXF_MC_OK }, + { "tx_unicast", GM_TXF_UC_OK }, + { "rx_unicast", GM_RXF_UC_OK }, + { "tx_mac_pause", GM_TXF_MPAUSE }, + { "rx_mac_pause", GM_RXF_MPAUSE }, + { "collisions", GM_TXF_SNG_COL }, + { "late_collision",GM_TXF_LAT_COL }, + { "aborted", GM_TXF_ABO_COL }, + { "multi_collisions", GM_TXF_MUL_COL }, + { "fifo_underrun", GM_TXE_FIFO_UR }, + { "fifo_overflow", GM_RXE_FIFO_OV }, + { "rx_toolong", GM_RXF_LNG_ERR }, + { "rx_jabber", GM_RXF_JAB_PKT }, + { "rx_runt", GM_RXE_FRAG }, + { "rx_too_long", GM_RXF_LNG_ERR }, + { "rx_fcs_error", GM_RXF_FCS_ERR }, +}; + + +static u32 sky2_get_rx_csum(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + return sky2->rx_csum; +} + +static int sky2_set_rx_csum(struct net_device *dev, u32 data) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + sky2->rx_csum = data; + sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), + data ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); + + return 0; +} + +static u32 sky2_get_msglevel(struct net_device *netdev) +{ + struct sky2_port *sky2 = netdev_priv(netdev); + return sky2->msg_enable; +} + +static void sky2_phy_stats(struct sky2_port *sky2, u64 *data) +{ + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + int i; + + data[0] = (u64) gma_read32(hw, port, GM_TXO_OK_HI) << 32 + | (u64) gma_read32(hw, port, GM_TXO_OK_LO); + data[1] = (u64) gma_read32(hw, port, GM_RXO_OK_HI) << 32 + | (u64) gma_read32(hw, port, GM_RXO_OK_LO); + + for (i = 2; i < ARRAY_SIZE(sky2_stats); i++) + data[i] = (u64) gma_read32(hw, port, sky2_stats[i].offset); +} + + +static void sky2_set_msglevel(struct net_device *netdev, u32 value) +{ + struct sky2_port *sky2 = netdev_priv(netdev); + sky2->msg_enable = value; +} + +static int sky2_get_stats_count(struct net_device *dev) +{ + return ARRAY_SIZE(sky2_stats); +} + +static void sky2_get_ethtool_stats(struct net_device *dev, + struct ethtool_stats *stats, u64 *data) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + sky2_phy_stats(sky2, data); +} + +static void sky2_get_strings(struct net_device *dev, u32 stringset, u8 *data) +{ + int i; + + switch (stringset) { + case ETH_SS_STATS: + for (i = 0; i < ARRAY_SIZE(sky2_stats); i++) + memcpy(data + i * ETH_GSTRING_LEN, + sky2_stats[i].name, ETH_GSTRING_LEN); + break; + } +} + +/* Use hardware MIB variables for critical path statistics and + * transmit feedback not reported at interrupt. + * Other errors are accounted for in interrupt handler. + */ +static struct net_device_stats *sky2_get_stats(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + u64 data[ARRAY_SIZE(sky2_stats)]; + + sky2_phy_stats(sky2, data); + + sky2->net_stats.tx_bytes = data[0]; + sky2->net_stats.rx_bytes = data[1]; + sky2->net_stats.tx_packets = data[2] + data[4] + data[6]; + sky2->net_stats.rx_packets = data[3] + data[5] + data[7]; + sky2->net_stats.multicast = data[5] + data[7]; + sky2->net_stats.collisions = data[10]; + sky2->net_stats.tx_aborted_errors = data[12]; + + return &sky2->net_stats; +} + +static int sky2_set_mac_address(struct net_device *dev, void *p) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sockaddr *addr = p; + int err = 0; + + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; + + sky2_down(dev); + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + memcpy_toio(sky2->hw->regs + B2_MAC_1 + sky2->port*8, + dev->dev_addr, ETH_ALEN); + memcpy_toio(sky2->hw->regs + B2_MAC_2 + sky2->port*8, + dev->dev_addr, ETH_ALEN); + if (dev->flags & IFF_UP) + err = sky2_up(dev); + return err; +} + +static void sky2_set_multicast(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + struct dev_mc_list *list = dev->mc_list; + u16 reg; + u8 filter[8]; + + memset(filter, 0, sizeof(filter)); + + reg = gma_read16(hw, port, GM_RX_CTRL); + reg |= GM_RXCR_UCF_ENA; + + if (dev->flags & IFF_PROMISC) /* promiscious */ + reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); + else if (dev->flags & IFF_ALLMULTI) /* all multicast */ + memset(filter, 0xff, sizeof(filter)); + else if (dev->mc_count == 0) /* no multicast */ + reg &= ~GM_RXCR_MCF_ENA; + else { + int i; + reg |= GM_RXCR_MCF_ENA; + + for (i = 0; list && i < dev->mc_count; i++, list = list->next) { + u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f; + filter[bit/8] |= 1 << (bit%8); + } + } + + + gma_write16(hw, port, GM_MC_ADDR_H1, + (u16)filter[0] | ((u16)filter[1] << 8)); + gma_write16(hw, port, GM_MC_ADDR_H2, + (u16)filter[2] | ((u16)filter[3] << 8)); + gma_write16(hw, port, GM_MC_ADDR_H3, + (u16)filter[4] | ((u16)filter[5] << 8)); + gma_write16(hw, port, GM_MC_ADDR_H4, + (u16)filter[6] | ((u16)filter[7] << 8)); + + gma_write16(hw, port, GM_RX_CTRL, reg); +} + +/* Can have one global because blinking is controlled by + * ethtool and that is always under RTNL mutex + */ +static inline void sky2_led(struct sky2_hw *hw, unsigned port, int on) +{ + spin_lock_bh(&hw->phy_lock); + gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); + if (on) + gm_phy_write(hw, port, PHY_MARV_LED_OVER, + PHY_M_LED_MO_DUP(MO_LED_ON) | + PHY_M_LED_MO_10(MO_LED_ON) | + PHY_M_LED_MO_100(MO_LED_ON) | + PHY_M_LED_MO_1000(MO_LED_ON) | + PHY_M_LED_MO_RX(MO_LED_ON)); + else + gm_phy_write(hw, port, PHY_MARV_LED_OVER, + + PHY_M_LED_MO_DUP(MO_LED_OFF) | + PHY_M_LED_MO_10(MO_LED_OFF) | + PHY_M_LED_MO_100(MO_LED_OFF) | + PHY_M_LED_MO_1000(MO_LED_OFF) | + PHY_M_LED_MO_RX(MO_LED_OFF)); + + spin_unlock_bh(&hw->phy_lock); +} + +/* blink LED's for finding board */ +static int sky2_phys_id(struct net_device *dev, u32 data) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + u16 ledctrl, ledover; + long ms; + int onoff = 1; + + if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) + ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT); + else + ms = data * 1000; + + /* save initial values */ + spin_lock_bh(&hw->phy_lock); + ledctrl = gm_phy_read(hw, port, PHY_MARV_LED_CTRL); + ledover = gm_phy_read(hw, port, PHY_MARV_LED_OVER); + spin_unlock_bh(&hw->phy_lock); + + while (ms > 0) { + sky2_led(hw, port, onoff); + onoff = !onoff; + + if (msleep_interruptible(250)) + break; /* interrupted */ + ms -= 250; + } + + /* resume regularly scheduled programming */ + spin_lock_bh(&hw->phy_lock); + gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); + gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); + spin_unlock_bh(&hw->phy_lock); + + return 0; +} + +static void sky2_get_pauseparam(struct net_device *dev, + struct ethtool_pauseparam *ecmd) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + ecmd->tx_pause = sky2->tx_pause; + ecmd->rx_pause = sky2->rx_pause; + ecmd->autoneg = sky2->autoneg; +} + +static int sky2_set_pauseparam(struct net_device *dev, + struct ethtool_pauseparam *ecmd) +{ + struct sky2_port *sky2 = netdev_priv(dev); + int err = 0; + + sky2->autoneg = ecmd->autoneg; + sky2->tx_pause = ecmd->tx_pause != 0; + sky2->rx_pause = ecmd->rx_pause != 0; + + if (netif_running(dev)) { + sky2_down(dev); + err = sky2_up(dev); + } + + return err; +} + +#ifdef CONFIG_PM +static void sky2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + wol->supported = WAKE_MAGIC; + wol->wolopts = sky2->wol ? WAKE_MAGIC : 0; +} + +static int sky2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + + if (wol->wolopts != WAKE_MAGIC && wol->wolopts != 0) + return -EOPNOTSUPP; + + sky2->wol = wol->wolopts == WAKE_MAGIC; + + if (sky2->wol) { + memcpy_toio(hw->regs + WOL_MAC_ADDR, dev->dev_addr, ETH_ALEN); + + sky2_write16(hw, WOL_CTRL_STAT, + WOL_CTL_ENA_PME_ON_MAGIC_PKT | + WOL_CTL_ENA_MAGIC_PKT_UNIT); + } else + sky2_write16(hw, WOL_CTRL_STAT, WOL_CTL_DEFAULT); + + return 0; +} +#endif + + +static struct ethtool_ops sky2_ethtool_ops = { + .get_settings = sky2_get_settings, + .set_settings = sky2_set_settings, + .get_drvinfo = sky2_get_drvinfo, + .get_msglevel = sky2_get_msglevel, + .set_msglevel = sky2_set_msglevel, + .get_link = ethtool_op_get_link, + .get_sg = ethtool_op_get_sg, + .set_sg = ethtool_op_set_sg, + .get_tx_csum = ethtool_op_get_tx_csum, + .set_tx_csum = ethtool_op_set_tx_csum, + .get_tso = ethtool_op_get_tso, + .set_tso = ethtool_op_set_tso, + .get_rx_csum = sky2_get_rx_csum, + .set_rx_csum = sky2_set_rx_csum, + .get_strings = sky2_get_strings, + .get_pauseparam = sky2_get_pauseparam, + .set_pauseparam = sky2_set_pauseparam, +#ifdef CONFIG_PM + .get_wol = sky2_get_wol, + .set_wol = sky2_set_wol, +#endif + .phys_id = sky2_phys_id, + .get_stats_count = sky2_get_stats_count, + .get_ethtool_stats = sky2_get_ethtool_stats, +}; + +/* Initialize network device */ +static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, + unsigned port, int highmem) +{ + struct sky2_port *sky2; + struct net_device *dev = alloc_etherdev(sizeof(*sky2)); + + if (!dev) { + printk(KERN_ERR "sky2 etherdev alloc failed"); + return NULL; + } + + SET_MODULE_OWNER(dev); + SET_NETDEV_DEV(dev, &hw->pdev->dev); + dev->open = sky2_up; + dev->stop = sky2_down; + dev->hard_start_xmit = sky2_xmit_frame; + dev->get_stats = sky2_get_stats; + dev->set_multicast_list = sky2_set_multicast; + dev->set_mac_address = sky2_set_mac_address; + dev->change_mtu = sky2_change_mtu; + SET_ETHTOOL_OPS(dev, &sky2_ethtool_ops); + dev->tx_timeout = sky2_tx_timeout; + dev->watchdog_timeo = TX_WATCHDOG; + if (port == 0) + dev->poll = sky2_poll; + dev->weight = NAPI_WEIGHT; +#ifdef CONFIG_NET_POLL_CONTROLLER + dev->poll_controller = sky2_netpoll; +#endif + dev->irq = hw->pdev->irq; + + sky2 = netdev_priv(dev); + sky2->netdev = dev; + sky2->hw = hw; + sky2->msg_enable = netif_msg_init(debug, default_msg); + + spin_lock_init(&sky2->tx_lock); + /* Auto speed and flow control */ + sky2->autoneg = AUTONEG_ENABLE; + sky2->tx_pause = 0; + sky2->rx_pause = 1; + sky2->duplex = -1; + sky2->speed = -1; + sky2->advertising = sky2_supported_modes(hw); + sky2->rx_csum = 1; + sky2->rx_ring_size = is_ec_a1(hw) ? MIN_RX_BUFFERS : MAX_RX_BUFFERS; + tasklet_init(&sky2->phy_task, sky2_phy_task, (unsigned long) sky2); + + hw->dev[port] = dev; + + sky2->port = port; + + dev->features |= NETIF_F_LLTX; + if (highmem) + dev->features |= NETIF_F_HIGHDMA; + dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO; + + /* read the mac address */ + memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port*8, ETH_ALEN); + + /* device is off until link detection */ + netif_carrier_off(dev); + netif_stop_queue(dev); + + return dev; +} + +static inline void sky2_show_addr(struct net_device *dev) +{ + const struct sky2_port *sky2 = netdev_priv(dev); + + if (netif_msg_probe(sky2)) + printk(KERN_INFO PFX "%s: addr %02x:%02x:%02x:%02x:%02x:%02x\n", + dev->name, + dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], + dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); +} + +static int __devinit sky2_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + struct net_device *dev, *dev1; + struct sky2_hw *hw; + int err, using_dac = 0; + + if ((err = pci_enable_device(pdev))) { + printk(KERN_ERR PFX "%s cannot enable PCI device\n", + pci_name(pdev)); + goto err_out; + } + + if ((err = pci_request_regions(pdev, DRV_NAME))) { + printk(KERN_ERR PFX "%s cannot obtain PCI resources\n", + pci_name(pdev)); + goto err_out_disable_pdev; + } + + pci_set_master(pdev); + + if (sizeof(dma_addr_t) > sizeof(u32)) { + err = pci_set_dma_mask(pdev, DMA_64BIT_MASK); + if (!err) + using_dac = 1; + } + + if (!using_dac) { + err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); + if (err) { + printk(KERN_ERR PFX "%s no usable DMA configuration\n", + pci_name(pdev)); + goto err_out_free_regions; + } + } + +#ifdef __BIG_ENDIAN + /* byte swap decriptors in hardware */ + { + u32 reg; + + pci_read_config_dword(pdev, PCI_DEV_REG2, ®); + reg |= PCI_REV_DESC; + pci_write_config_dword(pdev, PCI_DEV_REG2, reg); + } +#endif + + err = -ENOMEM; + hw = kmalloc(sizeof(*hw), GFP_KERNEL); + if (!hw) { + printk(KERN_ERR PFX "%s: cannot allocate hardware struct\n", + pci_name(pdev)); + goto err_out_free_regions; + } + + memset(hw, 0, sizeof(*hw)); + hw->pdev = pdev; + spin_lock_init(&hw->phy_lock); + + hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); + if (!hw->regs) { + printk(KERN_ERR PFX "%s: cannot map device registers\n", + pci_name(pdev)); + goto err_out_free_hw; + } + + err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ, DRV_NAME, hw); + if (err) { + printk(KERN_ERR PFX "%s: cannot assign irq %d\n", + pci_name(pdev), pdev->irq); + goto err_out_iounmap; + } + pci_set_drvdata(pdev, hw); + + err = sky2_reset(hw); + if (err) + goto err_out_free_irq; + + printk(KERN_INFO PFX "addr 0x%lx irq %d chip 0x%x (%s) rev %d\n", + pci_resource_start(pdev, 0), pdev->irq, + hw->chip_id, chip_name(hw->chip_id), hw->chip_rev); + + if ((dev = sky2_init_netdev(hw, 0, using_dac)) == NULL) + goto err_out_free_pci; + + if ((err = register_netdev(dev))) { + printk(KERN_ERR PFX "%s: cannot register net device\n", + pci_name(pdev)); + goto err_out_free_netdev; + } + + sky2_show_addr(dev); + + if (hw->ports > 1 && (dev1 = sky2_init_netdev(hw, 1, using_dac))) { + if (register_netdev(dev1) == 0) + sky2_show_addr(dev1); + else { + /* Failure to register second port need not be fatal */ + printk(KERN_WARNING PFX "register of second port failed\n"); + hw->dev[1] = NULL; + free_netdev(dev1); + } + } + + return 0; + +err_out_free_netdev: + free_netdev(dev); + +err_out_free_irq: + free_irq(pdev->irq, hw); +err_out_free_pci: + pci_free_consistent(hw->pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma); +err_out_iounmap: + iounmap(hw->regs); +err_out_free_hw: + kfree(hw); +err_out_free_regions: + pci_release_regions(pdev); +err_out_disable_pdev: + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); +err_out: + return err; +} + +static void __devexit sky2_remove(struct pci_dev *pdev) +{ + struct sky2_hw *hw = pci_get_drvdata(pdev); + struct net_device *dev0, *dev1; + + if(!hw) + return; + + if ((dev1 = hw->dev[1])) + unregister_netdev(dev1); + dev0 = hw->dev[0]; + unregister_netdev(dev0); + + sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); + + free_irq(pdev->irq, hw); + pci_free_consistent(pdev, STATUS_LE_BYTES, + hw->st_le, hw->st_dma); + pci_release_regions(pdev); + pci_disable_device(pdev); + if (dev1) + free_netdev(dev1); + free_netdev(dev0); + iounmap(hw->regs); + kfree(hw); + pci_set_drvdata(pdev, NULL); +} + +#ifdef CONFIG_PM +static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) +{ + struct sky2_hw *hw = pci_get_drvdata(pdev); + int i, wol = 0; + + for (i = 0; i < 2; i++) { + struct net_device *dev = hw->dev[i]; + + if (dev) { + struct sky2_port *sky2 = netdev_priv(dev); + if (netif_running(dev)) { + netif_carrier_off(dev); + sky2_down(dev); + } + netif_device_detach(dev); + wol |= sky2->wol; + } + } + + pci_save_state(pdev); + pci_enable_wake(pdev, pci_choose_state(pdev, state), wol); + pci_disable_device(pdev); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); + + return 0; +} + +static int sky2_resume(struct pci_dev *pdev) +{ + struct sky2_hw *hw = pci_get_drvdata(pdev); + int i; + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + pci_enable_wake(pdev, PCI_D0, 0); + + sky2_reset(hw); + + for (i = 0; i < 2; i++) { + struct net_device *dev = hw->dev[i]; + if (dev) { + netif_device_attach(dev); + if (netif_running(dev)) + sky2_up(dev); + } + } + return 0; +} +#endif + +static struct pci_driver sky2_driver = { + .name = DRV_NAME, + .id_table = sky2_id_table, + .probe = sky2_probe, + .remove = __devexit_p(sky2_remove), +#ifdef CONFIG_PM + .suspend = sky2_suspend, + .resume = sky2_resume, +#endif +}; + +static int __init sky2_init_module(void) +{ + + return pci_module_init(&sky2_driver); +} + +static void __exit sky2_cleanup_module(void) +{ + pci_unregister_driver(&sky2_driver); +} + +module_init(sky2_init_module); +module_exit(sky2_cleanup_module); + +MODULE_DESCRIPTION("Marvell Yukon 2 Gigabit Ethernet driver"); +MODULE_AUTHOR("Stephen Hemminger "); +MODULE_LICENSE("GPL"); diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h new file mode 100644 index 0000000..d2a0ac2 --- /dev/null +++ b/drivers/net/sky2.h @@ -0,0 +1,1935 @@ +/* + * Definitions for the new Marvell Yukon 2 driver. + */ +#ifndef _SKY2_H +#define _SKY2_H + +/* PCI config registers */ +#define PCI_DEV_REG1 0x40 +#define PCI_DEV_REG2 0x44 +#define PCI_DEV_STATUS 0x7c +#define PCI_OS_PCI_X (1<<26) + +#define PEX_LNK_STAT 0xf2 +#define PEX_UNC_ERR_STAT 0x104 +#define PEX_DEV_CTRL 0xe8 + +/* Yukon-2 */ +enum pci_dev_reg_1 { + PCI_Y2_PIG_ENA = 1<<31, /* Enable Plug-in-Go (YUKON-2) */ + PCI_Y2_DLL_DIS = 1<<30, /* Disable PCI DLL (YUKON-2) */ + PCI_Y2_PHY2_COMA = 1<<29, /* Set PHY 2 to Coma Mode (YUKON-2) */ + PCI_Y2_PHY1_COMA = 1<<28, /* Set PHY 1 to Coma Mode (YUKON-2) */ + PCI_Y2_PHY2_POWD = 1<<27, /* Set PHY 2 to Power Down (YUKON-2) */ + PCI_Y2_PHY1_POWD = 1<<26, /* Set PHY 1 to Power Down (YUKON-2) */ +}; + +enum pci_dev_reg_2 { + PCI_VPD_WR_THR = 0xffL<<24, /* Bit 31..24: VPD Write Threshold */ + PCI_DEV_SEL = 0x7fL<<17, /* Bit 23..17: EEPROM Device Select */ + PCI_VPD_ROM_SZ = 7L<<14, /* Bit 16..14: VPD ROM Size */ + + PCI_PATCH_DIR = 0xfL<<8, /* Bit 11.. 8: Ext Patches dir 3..0 */ + PCI_EXT_PATCHS = 0xfL<<4, /* Bit 7.. 4: Extended Patches 3..0 */ + PCI_EN_DUMMY_RD = 1<<3, /* Enable Dummy Read */ + PCI_REV_DESC = 1<<2, /* Reverse Desc. Bytes */ + + PCI_USEDATA64 = 1<<0, /* Use 64Bit Data bus ext */ +}; + + +#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \ + PCI_STATUS_SIG_SYSTEM_ERROR | \ + PCI_STATUS_REC_MASTER_ABORT | \ + PCI_STATUS_REC_TARGET_ABORT | \ + PCI_STATUS_PARITY) + +enum pex_dev_ctrl { + PEX_DC_MAX_RRS_MSK = 7<<12, /* Bit 14..12: Max. Read Request Size */ + PEX_DC_EN_NO_SNOOP = 1<<11,/* Enable No Snoop */ + PEX_DC_EN_AUX_POW = 1<<10,/* Enable AUX Power */ + PEX_DC_EN_PHANTOM = 1<<9, /* Enable Phantom Functions */ + PEX_DC_EN_EXT_TAG = 1<<8, /* Enable Extended Tag Field */ + PEX_DC_MAX_PLS_MSK = 7<<5, /* Bit 7.. 5: Max. Payload Size Mask */ + PEX_DC_EN_REL_ORD = 1<<4, /* Enable Relaxed Ordering */ + PEX_DC_EN_UNS_RQ_RP = 1<<3, /* Enable Unsupported Request Reporting */ + PEX_DC_EN_FAT_ER_RP = 1<<2, /* Enable Fatal Error Reporting */ + PEX_DC_EN_NFA_ER_RP = 1<<1, /* Enable Non-Fatal Error Reporting */ + PEX_DC_EN_COR_ER_RP = 1<<0, /* Enable Correctable Error Reporting */ +}; +#define PEX_DC_MAX_RD_RQ_SIZE(x) (((x)<<12) & PEX_DC_MAX_RRS_MSK) + +/* PEX_UNC_ERR_STAT PEX Uncorrectable Errors Status Register (Yukon-2) */ +enum pex_err { + PEX_UNSUP_REQ = 1<<20, /* Unsupported Request Error */ + + PEX_MALFOR_TLP = 1<<18, /* Malformed TLP */ + + PEX_UNEXP_COMP = 1<<16, /* Unexpected Completion */ + + PEX_COMP_TO = 1<<14, /* Completion Timeout */ + PEX_FLOW_CTRL_P = 1<<13, /* Flow Control Protocol Error */ + PEX_POIS_TLP = 1<<12, /* Poisoned TLP */ + + PEX_DATA_LINK_P = 1<<4, /* Data Link Protocol Error */ + PEX_FATAL_ERRORS= (PEX_MALFOR_TLP | PEX_FLOW_CTRL_P | PEX_DATA_LINK_P), +}; + + +enum csr_regs { + B0_RAP = 0x0000, + B0_CTST = 0x0004, + B0_Y2LED = 0x0005, + B0_POWER_CTRL = 0x0007, + B0_ISRC = 0x0008, + B0_IMSK = 0x000c, + B0_HWE_ISRC = 0x0010, + B0_HWE_IMSK = 0x0014, + B0_SP_ISRC = 0x0018, + B0_XM1_IMSK = 0x0020, + B0_XM1_ISRC = 0x0028, + B0_XM1_PHY_ADDR = 0x0030, + B0_XM1_PHY_DATA = 0x0034, + B0_XM2_IMSK = 0x0040, + B0_XM2_ISRC = 0x0048, + B0_XM2_PHY_ADDR = 0x0050, + B0_XM2_PHY_DATA = 0x0054, + B0_R1_CSR = 0x0060, + B0_R2_CSR = 0x0064, + B0_XS1_CSR = 0x0068, + B0_XA1_CSR = 0x006c, + B0_XS2_CSR = 0x0070, + B0_XA2_CSR = 0x0074, + + /* Special ISR registers (Yukon-2 only) */ + B0_Y2_SP_ISRC2 = 0x001c, + B0_Y2_SP_ISRC3 = 0x0020, + B0_Y2_SP_EISR = 0x0024, + B0_Y2_SP_LISR = 0x0028, + B0_Y2_SP_ICR = 0x002c, + + B2_MAC_1 = 0x0100, + B2_MAC_2 = 0x0108, + B2_MAC_3 = 0x0110, + B2_CONN_TYP = 0x0118, + B2_PMD_TYP = 0x0119, + B2_MAC_CFG = 0x011a, + B2_CHIP_ID = 0x011b, + B2_E_0 = 0x011c, + B2_E_1 = 0x011d, + B2_E_2 = 0x011e, + B2_Y2_CLK_GATE = 0x011d, + B2_Y2_HW_RES = 0x011e, + B2_E_3 = 0x011f, + B2_Y2_CLK_CTRL = 0x0120, + B2_LD_CTRL = 0x0128, + B2_LD_TEST = 0x0129, + B2_TI_INI = 0x0130, + B2_TI_VAL = 0x0134, + B2_TI_CTRL = 0x0138, + B2_TI_TEST = 0x0139, + B2_IRQM_INI = 0x0140, + B2_IRQM_VAL = 0x0144, + B2_IRQM_CTRL = 0x0148, + B2_IRQM_TEST = 0x0149, + B2_IRQM_MSK = 0x014c, + B2_IRQM_HWE_MSK = 0x0150, + B2_TST_CTRL1 = 0x0158, + B2_TST_CTRL2 = 0x0159, + B2_GP_IO = 0x015c, + B2_I2C_CTRL = 0x0160, + B2_I2C_DATA = 0x0164, + B2_I2C_IRQ = 0x0168, + B2_I2C_SW = 0x016c, + B2_BSC_INI = 0x0170, + B2_BSC_VAL = 0x0174, + B2_BSC_CTRL = 0x0178, + B2_BSC_STAT = 0x0179, + B2_BSC_TST = 0x017a, + + B3_RAM_ADDR = 0x0180, + B3_RAM_DATA_LO = 0x0184, + B3_RAM_DATA_HI = 0x0188, + +/* RAM Interface Registers */ +/* Yukon-2: use RAM_BUFFER() to access the RAM buffer */ +/* + * The HW-Spec. calls this registers Timeout Value 0..11. But this names are + * not usable in SW. Please notice these are NOT real timeouts, these are + * the number of qWords transferred continuously. + */ +#define RAM_BUFFER(port, reg) (reg | (port <<6)) + + B3_RI_WTO_R1 = 0x0190, + B3_RI_WTO_XA1 = 0x0191, + B3_RI_WTO_XS1 = 0x0192, + B3_RI_RTO_R1 = 0x0193, + B3_RI_RTO_XA1 = 0x0194, + B3_RI_RTO_XS1 = 0x0195, + B3_RI_WTO_R2 = 0x0196, + B3_RI_WTO_XA2 = 0x0197, + B3_RI_WTO_XS2 = 0x0198, + B3_RI_RTO_R2 = 0x0199, + B3_RI_RTO_XA2 = 0x019a, + B3_RI_RTO_XS2 = 0x019b, + B3_RI_TO_VAL = 0x019c, + B3_RI_CTRL = 0x01a0, + B3_RI_TEST = 0x01a2, + B3_MA_TOINI_RX1 = 0x01b0, + B3_MA_TOINI_RX2 = 0x01b1, + B3_MA_TOINI_TX1 = 0x01b2, + B3_MA_TOINI_TX2 = 0x01b3, + B3_MA_TOVAL_RX1 = 0x01b4, + B3_MA_TOVAL_RX2 = 0x01b5, + B3_MA_TOVAL_TX1 = 0x01b6, + B3_MA_TOVAL_TX2 = 0x01b7, + B3_MA_TO_CTRL = 0x01b8, + B3_MA_TO_TEST = 0x01ba, + B3_MA_RCINI_RX1 = 0x01c0, + B3_MA_RCINI_RX2 = 0x01c1, + B3_MA_RCINI_TX1 = 0x01c2, + B3_MA_RCINI_TX2 = 0x01c3, + B3_MA_RCVAL_RX1 = 0x01c4, + B3_MA_RCVAL_RX2 = 0x01c5, + B3_MA_RCVAL_TX1 = 0x01c6, + B3_MA_RCVAL_TX2 = 0x01c7, + B3_MA_RC_CTRL = 0x01c8, + B3_MA_RC_TEST = 0x01ca, + B3_PA_TOINI_RX1 = 0x01d0, + B3_PA_TOINI_RX2 = 0x01d4, + B3_PA_TOINI_TX1 = 0x01d8, + B3_PA_TOINI_TX2 = 0x01dc, + B3_PA_TOVAL_RX1 = 0x01e0, + B3_PA_TOVAL_RX2 = 0x01e4, + B3_PA_TOVAL_TX1 = 0x01e8, + B3_PA_TOVAL_TX2 = 0x01ec, + B3_PA_CTRL = 0x01f0, + B3_PA_TEST = 0x01f2, + + Y2_CFG_SPC = 0x1c00, +}; + +/* Access pci config through board I/O */ +#define PCI_C(x) (Y2_CFG_SPC + (x)) + + +/* B0_CTST 16 bit Control/Status register */ +enum { + Y2_VMAIN_AVAIL = 1<<17, /* VMAIN available (YUKON-2 only) */ + Y2_VAUX_AVAIL = 1<<16,/* VAUX available (YUKON-2 only) */ + Y2_ASF_ENABLE = 1<<13,/* ASF Unit Enable (YUKON-2 only) */ + Y2_ASF_DISABLE = 1<<12,/* ASF Unit Disable (YUKON-2 only) */ + Y2_CLK_RUN_ENA = 1<<11,/* CLK_RUN Enable (YUKON-2 only) */ + Y2_CLK_RUN_DIS = 1<<10,/* CLK_RUN Disable (YUKON-2 only) */ + Y2_LED_STAT_ON = 1<<9, /* Status LED On (YUKON-2 only) */ + Y2_LED_STAT_OFF = 1<<8, /* Status LED Off (YUKON-2 only) */ + + CS_BUS_CLOCK = 1<<9, /* Bus Clock 0/1 = 33/66 MHz */ + CS_BUS_SLOT_SZ = 1<<8, /* Slot Size 0/1 = 32/64 bit slot */ + CS_ST_SW_IRQ = 1<<7, /* Set IRQ SW Request */ + CS_CL_SW_IRQ = 1<<6, /* Clear IRQ SW Request */ + CS_STOP_DONE = 1<<5, /* Stop Master is finished */ + CS_STOP_MAST = 1<<4, /* Command Bit to stop the master */ + CS_MRST_CLR = 1<<3, /* Clear Master reset */ + CS_MRST_SET = 1<<2, /* Set Master reset */ + CS_RST_CLR = 1<<1, /* Clear Software reset */ + CS_RST_SET = 1, /* Set Software reset */ + +/* B0_LED 8 Bit LED register */ +/* Bit 7.. 2: reserved */ + LED_STAT_ON = 1<<1, /* Status LED on */ + LED_STAT_OFF = 1, /* Status LED off */ + +/* B0_POWER_CTRL 8 Bit Power Control reg (YUKON only) */ + PC_VAUX_ENA = 1<<7, /* Switch VAUX Enable */ + PC_VAUX_DIS = 1<<6, /* Switch VAUX Disable */ + PC_VCC_ENA = 1<<5, /* Switch VCC Enable */ + PC_VCC_DIS = 1<<4, /* Switch VCC Disable */ + PC_VAUX_ON = 1<<3, /* Switch VAUX On */ + PC_VAUX_OFF = 1<<2, /* Switch VAUX Off */ + PC_VCC_ON = 1<<1, /* Switch VCC On */ + PC_VCC_OFF = 1<<0, /* Switch VCC Off */ +}; + +/* B2_IRQM_MSK 32 bit IRQ Moderation Mask */ + +/* B0_Y2_SP_ISRC2 32 bit Special Interrupt Source Reg 2 */ +/* B0_Y2_SP_ISRC3 32 bit Special Interrupt Source Reg 3 */ +/* B0_Y2_SP_EISR 32 bit Enter ISR Reg */ +/* B0_Y2_SP_LISR 32 bit Leave ISR Reg */ +enum { + Y2_IS_HW_ERR = 1<<31, /* Interrupt HW Error */ + Y2_IS_STAT_BMU = 1<<30, /* Status BMU Interrupt */ + Y2_IS_ASF = 1<<29, /* ASF subsystem Interrupt */ + + Y2_IS_POLL_CHK = 1<<27, /* Check IRQ from polling unit */ + Y2_IS_TWSI_RDY = 1<<26, /* IRQ on end of TWSI Tx */ + Y2_IS_IRQ_SW = 1<<25, /* SW forced IRQ */ + Y2_IS_TIMINT = 1<<24, /* IRQ from Timer */ + + Y2_IS_IRQ_PHY2 = 1<<12, /* Interrupt from PHY 2 */ + Y2_IS_IRQ_MAC2 = 1<<11, /* Interrupt from MAC 2 */ + Y2_IS_CHK_RX2 = 1<<10, /* Descriptor error Rx 2 */ + Y2_IS_CHK_TXS2 = 1<<9, /* Descriptor error TXS 2 */ + Y2_IS_CHK_TXA2 = 1<<8, /* Descriptor error TXA 2 */ + + Y2_IS_IRQ_PHY1 = 1<<4, /* Interrupt from PHY 1 */ + Y2_IS_IRQ_MAC1 = 1<<3, /* Interrupt from MAC 1 */ + Y2_IS_CHK_RX1 = 1<<2, /* Descriptor error Rx 1 */ + Y2_IS_CHK_TXS1 = 1<<1, /* Descriptor error TXS 1 */ + Y2_IS_CHK_TXA1 = 1<<0, /* Descriptor error TXA 1 */ + + Y2_IS_BASE = Y2_IS_HW_ERR | Y2_IS_STAT_BMU | + Y2_IS_POLL_CHK | Y2_IS_TWSI_RDY | + Y2_IS_IRQ_SW | Y2_IS_TIMINT, + Y2_IS_PORT_1 = Y2_IS_IRQ_PHY1 | Y2_IS_IRQ_MAC1 | + Y2_IS_CHK_RX1 | Y2_IS_CHK_TXA1 | Y2_IS_CHK_TXS1, + Y2_IS_PORT_2 = Y2_IS_IRQ_PHY2 | Y2_IS_IRQ_MAC2 | + Y2_IS_CHK_RX2 | Y2_IS_CHK_TXA2 | Y2_IS_CHK_TXS2, +}; + +/* B2_IRQM_HWE_MSK 32 bit IRQ Moderation HW Error Mask */ +enum { + IS_ERR_MSK = 0x00003fff,/* All Error bits */ + + IS_IRQ_TIST_OV = 1<<13, /* Time Stamp Timer Overflow (YUKON only) */ + IS_IRQ_SENSOR = 1<<12, /* IRQ from Sensor (YUKON only) */ + IS_IRQ_MST_ERR = 1<<11, /* IRQ master error detected */ + IS_IRQ_STAT = 1<<10, /* IRQ status exception */ + IS_NO_STAT_M1 = 1<<9, /* No Rx Status from MAC 1 */ + IS_NO_STAT_M2 = 1<<8, /* No Rx Status from MAC 2 */ + IS_NO_TIST_M1 = 1<<7, /* No Time Stamp from MAC 1 */ + IS_NO_TIST_M2 = 1<<6, /* No Time Stamp from MAC 2 */ + IS_RAM_RD_PAR = 1<<5, /* RAM Read Parity Error */ + IS_RAM_WR_PAR = 1<<4, /* RAM Write Parity Error */ + IS_M1_PAR_ERR = 1<<3, /* MAC 1 Parity Error */ + IS_M2_PAR_ERR = 1<<2, /* MAC 2 Parity Error */ + IS_R1_PAR_ERR = 1<<1, /* Queue R1 Parity Error */ + IS_R2_PAR_ERR = 1<<0, /* Queue R2 Parity Error */ +}; + +/* Hardware error interrupt mask for Yukon 2 */ +enum { + Y2_IS_TIST_OV = 1<<29,/* Time Stamp Timer overflow interrupt */ + Y2_IS_SENSOR = 1<<28, /* Sensor interrupt */ + Y2_IS_MST_ERR = 1<<27, /* Master error interrupt */ + Y2_IS_IRQ_STAT = 1<<26, /* Status exception interrupt */ + Y2_IS_PCI_EXP = 1<<25, /* PCI-Express interrupt */ + Y2_IS_PCI_NEXP = 1<<24, /* PCI-Express error similar to PCI error */ + /* Link 2 */ + Y2_IS_PAR_RD2 = 1<<13, /* Read RAM parity error interrupt */ + Y2_IS_PAR_WR2 = 1<<12, /* Write RAM parity error interrupt */ + Y2_IS_PAR_MAC2 = 1<<11, /* MAC hardware fault interrupt */ + Y2_IS_PAR_RX2 = 1<<10, /* Parity Error Rx Queue 2 */ + Y2_IS_TCP_TXS2 = 1<<9, /* TCP length mismatch sync Tx queue IRQ */ + Y2_IS_TCP_TXA2 = 1<<8, /* TCP length mismatch async Tx queue IRQ */ + /* Link 1 */ + Y2_IS_PAR_RD1 = 1<<5, /* Read RAM parity error interrupt */ + Y2_IS_PAR_WR1 = 1<<4, /* Write RAM parity error interrupt */ + Y2_IS_PAR_MAC1 = 1<<3, /* MAC hardware fault interrupt */ + Y2_IS_PAR_RX1 = 1<<2, /* Parity Error Rx Queue 1 */ + Y2_IS_TCP_TXS1 = 1<<1, /* TCP length mismatch sync Tx queue IRQ */ + Y2_IS_TCP_TXA1 = 1<<0, /* TCP length mismatch async Tx queue IRQ */ + + Y2_HWE_L1_MASK = Y2_IS_PAR_RD1 | Y2_IS_PAR_WR1 | Y2_IS_PAR_MAC1 | + Y2_IS_PAR_RX1 | Y2_IS_TCP_TXS1| Y2_IS_TCP_TXA1, + Y2_HWE_L2_MASK = Y2_IS_PAR_RD2 | Y2_IS_PAR_WR2 | Y2_IS_PAR_MAC2 | + Y2_IS_PAR_RX2 | Y2_IS_TCP_TXS2| Y2_IS_TCP_TXA2, + + Y2_HWE_ALL_MASK = Y2_IS_SENSOR | Y2_IS_MST_ERR | Y2_IS_IRQ_STAT | + Y2_IS_PCI_EXP | Y2_IS_PCI_NEXP | + Y2_HWE_L1_MASK | Y2_HWE_L2_MASK, +}; + +/* B28_DPT_CTRL 8 bit Descriptor Poll Timer Ctrl Reg */ +enum { + DPT_START = 1<<1, + DPT_STOP = 1<<0, +}; + +/* B2_TST_CTRL1 8 bit Test Control Register 1 */ +enum { + TST_FRC_DPERR_MR = 1<<7, /* force DATAPERR on MST RD */ + TST_FRC_DPERR_MW = 1<<6, /* force DATAPERR on MST WR */ + TST_FRC_DPERR_TR = 1<<5, /* force DATAPERR on TRG RD */ + TST_FRC_DPERR_TW = 1<<4, /* force DATAPERR on TRG WR */ + TST_FRC_APERR_M = 1<<3, /* force ADDRPERR on MST */ + TST_FRC_APERR_T = 1<<2, /* force ADDRPERR on TRG */ + TST_CFG_WRITE_ON = 1<<1, /* Enable Config Reg WR */ + TST_CFG_WRITE_OFF= 1<<0, /* Disable Config Reg WR */ +}; + +/* B2_MAC_CFG 8 bit MAC Configuration / Chip Revision */ +enum { + CFG_CHIP_R_MSK = 0xf<<4, /* Bit 7.. 4: Chip Revision */ + /* Bit 3.. 2: reserved */ + CFG_DIS_M2_CLK = 1<<1, /* Disable Clock for 2nd MAC */ + CFG_SNG_MAC = 1<<0, /* MAC Config: 0=2 MACs / 1=1 MAC*/ +}; + +/* B2_CHIP_ID 8 bit Chip Identification Number */ +enum { + CHIP_ID_GENESIS = 0x0a, /* Chip ID for GENESIS */ + CHIP_ID_YUKON = 0xb0, /* Chip ID for YUKON */ + CHIP_ID_YUKON_LITE = 0xb1, /* Chip ID for YUKON-Lite (Rev. A1-A3) */ + CHIP_ID_YUKON_LP = 0xb2, /* Chip ID for YUKON-LP */ + CHIP_ID_YUKON_XL = 0xb3, /* Chip ID for YUKON-2 XL */ + CHIP_ID_YUKON_EC = 0xb6, /* Chip ID for YUKON-2 EC */ + CHIP_ID_YUKON_FE = 0xb7, /* Chip ID for YUKON-2 FE */ + + CHIP_REV_YU_EC_A1 = 0, /* Chip Rev. for Yukon-EC A1/A0 */ + CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */ + CHIP_REV_YU_EC_A3 = 2, /* Chip Rev. for Yukon-EC A3 */ +}; + +/* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ +enum { + Y2_STATUS_LNK2_INAC = 1<<7, /* Status Link 2 inactiv (0 = activ) */ + Y2_CLK_GAT_LNK2_DIS = 1<<6, /* Disable clock gating Link 2 */ + Y2_COR_CLK_LNK2_DIS = 1<<5, /* Disable Core clock Link 2 */ + Y2_PCI_CLK_LNK2_DIS = 1<<4, /* Disable PCI clock Link 2 */ + Y2_STATUS_LNK1_INAC = 1<<3, /* Status Link 1 inactiv (0 = activ) */ + Y2_CLK_GAT_LNK1_DIS = 1<<2, /* Disable clock gating Link 1 */ + Y2_COR_CLK_LNK1_DIS = 1<<1, /* Disable Core clock Link 1 */ + Y2_PCI_CLK_LNK1_DIS = 1<<0, /* Disable PCI clock Link 1 */ +}; + +/* B2_Y2_HW_RES 8 bit HW Resources (Yukon-2 only) */ +enum { + CFG_LED_MODE_MSK = 7<<2, /* Bit 4.. 2: LED Mode Mask */ + CFG_LINK_2_AVAIL = 1<<1, /* Link 2 available */ + CFG_LINK_1_AVAIL = 1<<0, /* Link 1 available */ +}; +#define CFG_LED_MODE(x) (((x) & CFG_LED_MODE_MSK) >> 2) +#define CFG_DUAL_MAC_MSK (CFG_LINK_2_AVAIL | CFG_LINK_1_AVAIL) + + +/* B2_Y2_CLK_CTRL 32 bit Clock Frequency Control Register (Yukon-2/EC) */ +enum { + Y2_CLK_DIV_VAL_MSK = 0xff<<16,/* Bit 23..16: Clock Divisor Value */ +#define Y2_CLK_DIV_VAL(x) (((x)<<16) & Y2_CLK_DIV_VAL_MSK) + Y2_CLK_DIV_VAL2_MSK = 7<<21, /* Bit 23..21: Clock Divisor Value */ + Y2_CLK_SELECT2_MSK = 0x1f<<16,/* Bit 20..16: Clock Select */ +#define Y2_CLK_DIV_VAL_2(x) (((x)<<21) & Y2_CLK_DIV_VAL2_MSK) +#define Y2_CLK_SEL_VAL_2(x) (((x)<<16) & Y2_CLK_SELECT2_MSK) + Y2_CLK_DIV_ENA = 1<<1, /* Enable Core Clock Division */ + Y2_CLK_DIV_DIS = 1<<0, /* Disable Core Clock Division */ +}; + +/* B2_TI_CTRL 8 bit Timer control */ +/* B2_IRQM_CTRL 8 bit IRQ Moderation Timer Control */ +enum { + TIM_START = 1<<2, /* Start Timer */ + TIM_STOP = 1<<1, /* Stop Timer */ + TIM_CLR_IRQ = 1<<0, /* Clear Timer IRQ (!IRQM) */ +}; + +/* B2_TI_TEST 8 Bit Timer Test */ +/* B2_IRQM_TEST 8 bit IRQ Moderation Timer Test */ +/* B28_DPT_TST 8 bit Descriptor Poll Timer Test Reg */ +enum { + TIM_T_ON = 1<<2, /* Test mode on */ + TIM_T_OFF = 1<<1, /* Test mode off */ + TIM_T_STEP = 1<<0, /* Test step */ +}; + +/* B3_RAM_ADDR 32 bit RAM Address, to read or write */ + /* Bit 31..19: reserved */ +#define RAM_ADR_RAN 0x0007ffffL /* Bit 18.. 0: RAM Address Range */ +/* RAM Interface Registers */ + +/* B3_RI_CTRL 16 bit RAM Iface Control Register */ +enum { + RI_CLR_RD_PERR = 1<<9, /* Clear IRQ RAM Read Parity Err */ + RI_CLR_WR_PERR = 1<<8, /* Clear IRQ RAM Write Parity Err*/ + + RI_RST_CLR = 1<<1, /* Clear RAM Interface Reset */ + RI_RST_SET = 1<<0, /* Set RAM Interface Reset */ +}; + +#define SK_RI_TO_53 36 /* RAM interface timeout */ + + +/* Port related registers FIFO, and Arbiter */ +#define SK_REG(port,reg) (((port)<<7)+(reg)) + +/* Transmit Arbiter Registers MAC 1 and 2, use SK_REG() to access */ +/* TXA_ITI_INI 32 bit Tx Arb Interval Timer Init Val */ +/* TXA_ITI_VAL 32 bit Tx Arb Interval Timer Value */ +/* TXA_LIM_INI 32 bit Tx Arb Limit Counter Init Val */ +/* TXA_LIM_VAL 32 bit Tx Arb Limit Counter Value */ + +#define TXA_MAX_VAL 0x00ffffffUL /* Bit 23.. 0: Max TXA Timer/Cnt Val */ + +/* TXA_CTRL 8 bit Tx Arbiter Control Register */ +enum { + TXA_ENA_FSYNC = 1<<7, /* Enable force of sync Tx queue */ + TXA_DIS_FSYNC = 1<<6, /* Disable force of sync Tx queue */ + TXA_ENA_ALLOC = 1<<5, /* Enable alloc of free bandwidth */ + TXA_DIS_ALLOC = 1<<4, /* Disable alloc of free bandwidth */ + TXA_START_RC = 1<<3, /* Start sync Rate Control */ + TXA_STOP_RC = 1<<2, /* Stop sync Rate Control */ + TXA_ENA_ARB = 1<<1, /* Enable Tx Arbiter */ + TXA_DIS_ARB = 1<<0, /* Disable Tx Arbiter */ +}; + +/* + * Bank 4 - 5 + */ +/* Transmit Arbiter Registers MAC 1 and 2, use SK_REG() to access */ +enum { + TXA_ITI_INI = 0x0200,/* 32 bit Tx Arb Interval Timer Init Val*/ + TXA_ITI_VAL = 0x0204,/* 32 bit Tx Arb Interval Timer Value */ + TXA_LIM_INI = 0x0208,/* 32 bit Tx Arb Limit Counter Init Val */ + TXA_LIM_VAL = 0x020c,/* 32 bit Tx Arb Limit Counter Value */ + TXA_CTRL = 0x0210,/* 8 bit Tx Arbiter Control Register */ + TXA_TEST = 0x0211,/* 8 bit Tx Arbiter Test Register */ + TXA_STAT = 0x0212,/* 8 bit Tx Arbiter Status Register */ +}; + + +enum { + B6_EXT_REG = 0x0300,/* External registers (GENESIS only) */ + B7_CFG_SPC = 0x0380,/* copy of the Configuration register */ + B8_RQ1_REGS = 0x0400,/* Receive Queue 1 */ + B8_RQ2_REGS = 0x0480,/* Receive Queue 2 */ + B8_TS1_REGS = 0x0600,/* Transmit sync queue 1 */ + B8_TA1_REGS = 0x0680,/* Transmit async queue 1 */ + B8_TS2_REGS = 0x0700,/* Transmit sync queue 2 */ + B8_TA2_REGS = 0x0780,/* Transmit sync queue 2 */ + B16_RAM_REGS = 0x0800,/* RAM Buffer Registers */ +}; + +/* Queue Register Offsets, use Q_ADDR() to access */ +enum { + B8_Q_REGS = 0x0400, /* base of Queue registers */ + Q_D = 0x00, /* 8*32 bit Current Descriptor */ + Q_DA_L = 0x20, /* 32 bit Current Descriptor Address Low dWord */ + Q_DA_H = 0x24, /* 32 bit Current Descriptor Address High dWord */ + Q_AC_L = 0x28, /* 32 bit Current Address Counter Low dWord */ + Q_AC_H = 0x2c, /* 32 bit Current Address Counter High dWord */ + Q_BC = 0x30, /* 32 bit Current Byte Counter */ + Q_CSR = 0x34, /* 32 bit BMU Control/Status Register */ + Q_F = 0x38, /* 32 bit Flag Register */ + Q_T1 = 0x3c, /* 32 bit Test Register 1 */ + Q_T1_TR = 0x3c, /* 8 bit Test Register 1 Transfer SM */ + Q_T1_WR = 0x3d, /* 8 bit Test Register 1 Write Descriptor SM */ + Q_T1_RD = 0x3e, /* 8 bit Test Register 1 Read Descriptor SM */ + Q_T1_SV = 0x3f, /* 8 bit Test Register 1 Supervisor SM */ + Q_T2 = 0x40, /* 32 bit Test Register 2 */ + Q_T3 = 0x44, /* 32 bit Test Register 3 */ + +/* Yukon-2 */ + Q_DONE = 0x24, /* 16 bit Done Index (Yukon-2 only) */ + Q_WM = 0x40, /* 16 bit FIFO Watermark */ + Q_AL = 0x42, /* 8 bit FIFO Alignment */ + Q_RSP = 0x44, /* 16 bit FIFO Read Shadow Pointer */ + Q_RSL = 0x46, /* 8 bit FIFO Read Shadow Level */ + Q_RP = 0x48, /* 8 bit FIFO Read Pointer */ + Q_RL = 0x4a, /* 8 bit FIFO Read Level */ + Q_WP = 0x4c, /* 8 bit FIFO Write Pointer */ + Q_WSP = 0x4d, /* 8 bit FIFO Write Shadow Pointer */ + Q_WL = 0x4e, /* 8 bit FIFO Write Level */ + Q_WSL = 0x4f, /* 8 bit FIFO Write Shadow Level */ +}; +#define Q_ADDR(reg, offs) (B8_Q_REGS + (reg) + (offs)) + + +/* Queue Prefetch Unit Offsets, use Y2_QADDR() to address (Yukon-2 only)*/ +enum { + Y2_B8_PREF_REGS = 0x0450, + + PREF_UNIT_CTRL = 0x00, /* 32 bit Control register */ + PREF_UNIT_LAST_IDX = 0x04, /* 16 bit Last Index */ + PREF_UNIT_ADDR_LO = 0x08, /* 32 bit List start addr, low part */ + PREF_UNIT_ADDR_HI = 0x0c, /* 32 bit List start addr, high part*/ + PREF_UNIT_GET_IDX = 0x10, /* 16 bit Get Index */ + PREF_UNIT_PUT_IDX = 0x14, /* 16 bit Put Index */ + PREF_UNIT_FIFO_WP = 0x20, /* 8 bit FIFO write pointer */ + PREF_UNIT_FIFO_RP = 0x24, /* 8 bit FIFO read pointer */ + PREF_UNIT_FIFO_WM = 0x28, /* 8 bit FIFO watermark */ + PREF_UNIT_FIFO_LEV = 0x2c, /* 8 bit FIFO level */ + + PREF_UNIT_MASK_IDX = 0x0fff, +}; +#define Y2_QADDR(q,reg) (Y2_B8_PREF_REGS + (q) + (reg)) + +/* RAM Buffer Register Offsets */ +enum { + + RB_START = 0x00,/* 32 bit RAM Buffer Start Address */ + RB_END = 0x04,/* 32 bit RAM Buffer End Address */ + RB_WP = 0x08,/* 32 bit RAM Buffer Write Pointer */ + RB_RP = 0x0c,/* 32 bit RAM Buffer Read Pointer */ + RB_RX_UTPP = 0x10,/* 32 bit Rx Upper Threshold, Pause Packet */ + RB_RX_LTPP = 0x14,/* 32 bit Rx Lower Threshold, Pause Packet */ + RB_RX_UTHP = 0x18,/* 32 bit Rx Upper Threshold, High Prio */ + RB_RX_LTHP = 0x1c,/* 32 bit Rx Lower Threshold, High Prio */ + /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */ + RB_PC = 0x20,/* 32 bit RAM Buffer Packet Counter */ + RB_LEV = 0x24,/* 32 bit RAM Buffer Level Register */ + RB_CTRL = 0x28,/* 32 bit RAM Buffer Control Register */ + RB_TST1 = 0x29,/* 8 bit RAM Buffer Test Register 1 */ + RB_TST2 = 0x2a,/* 8 bit RAM Buffer Test Register 2 */ +}; + +/* Receive and Transmit Queues */ +enum { + Q_R1 = 0x0000, /* Receive Queue 1 */ + Q_R2 = 0x0080, /* Receive Queue 2 */ + Q_XS1 = 0x0200, /* Synchronous Transmit Queue 1 */ + Q_XA1 = 0x0280, /* Asynchronous Transmit Queue 1 */ + Q_XS2 = 0x0300, /* Synchronous Transmit Queue 2 */ + Q_XA2 = 0x0380, /* Asynchronous Transmit Queue 2 */ +}; + +/* Different PHY Types */ +enum { + PHY_ADDR_MARV = 0, +}; + +#define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs)) + + +enum { + LNK_SYNC_INI = 0x0c30,/* 32 bit Link Sync Cnt Init Value */ + LNK_SYNC_VAL = 0x0c34,/* 32 bit Link Sync Cnt Current Value */ + LNK_SYNC_CTRL = 0x0c38,/* 8 bit Link Sync Cnt Control Register */ + LNK_SYNC_TST = 0x0c39,/* 8 bit Link Sync Cnt Test Register */ + + LNK_LED_REG = 0x0c3c,/* 8 bit Link LED Register */ + +/* Receive GMAC FIFO (YUKON and Yukon-2) */ + + RX_GMF_EA = 0x0c40,/* 32 bit Rx GMAC FIFO End Address */ + RX_GMF_AF_THR = 0x0c44,/* 32 bit Rx GMAC FIFO Almost Full Thresh. */ + RX_GMF_CTRL_T = 0x0c48,/* 32 bit Rx GMAC FIFO Control/Test */ + RX_GMF_FL_MSK = 0x0c4c,/* 32 bit Rx GMAC FIFO Flush Mask */ + RX_GMF_FL_THR = 0x0c50,/* 32 bit Rx GMAC FIFO Flush Threshold */ + RX_GMF_TR_THR = 0x0c54,/* 32 bit Rx Truncation Threshold (Yukon-2) */ + + RX_GMF_VLAN = 0x0c5c,/* 32 bit Rx VLAN Type Register (Yukon-2) */ + RX_GMF_WP = 0x0c60,/* 32 bit Rx GMAC FIFO Write Pointer */ + + RX_GMF_WLEV = 0x0c68,/* 32 bit Rx GMAC FIFO Write Level */ + + RX_GMF_RP = 0x0c70,/* 32 bit Rx GMAC FIFO Read Pointer */ + + RX_GMF_RLEV = 0x0c78,/* 32 bit Rx GMAC FIFO Read Level */ +}; + + +/* Q_BC 32 bit Current Byte Counter */ + +/* BMU Control Status Registers */ +/* B0_R1_CSR 32 bit BMU Ctrl/Stat Rx Queue 1 */ +/* B0_R2_CSR 32 bit BMU Ctrl/Stat Rx Queue 2 */ +/* B0_XA1_CSR 32 bit BMU Ctrl/Stat Sync Tx Queue 1 */ +/* B0_XS1_CSR 32 bit BMU Ctrl/Stat Async Tx Queue 1 */ +/* B0_XA2_CSR 32 bit BMU Ctrl/Stat Sync Tx Queue 2 */ +/* B0_XS2_CSR 32 bit BMU Ctrl/Stat Async Tx Queue 2 */ +/* Q_CSR 32 bit BMU Control/Status Register */ + +/* Rx BMU Control / Status Registers (Yukon-2) */ +enum { + BMU_IDLE = 1<<31, /* BMU Idle State */ + BMU_RX_TCP_PKT = 1<<30, /* Rx TCP Packet (when RSS Hash enabled) */ + BMU_RX_IP_PKT = 1<<29, /* Rx IP Packet (when RSS Hash enabled) */ + + BMU_ENA_RX_RSS_HASH = 1<<15, /* Enable Rx RSS Hash */ + BMU_DIS_RX_RSS_HASH = 1<<14, /* Disable Rx RSS Hash */ + BMU_ENA_RX_CHKSUM = 1<<13, /* Enable Rx TCP/IP Checksum Check */ + BMU_DIS_RX_CHKSUM = 1<<12, /* Disable Rx TCP/IP Checksum Check */ + BMU_CLR_IRQ_PAR = 1<<11, /* Clear IRQ on Parity errors (Rx) */ + BMU_CLR_IRQ_TCP = 1<<11, /* Clear IRQ on TCP segmen. error (Tx) */ + BMU_CLR_IRQ_CHK = 1<<10, /* Clear IRQ Check */ + BMU_STOP = 1<<9, /* Stop Rx/Tx Queue */ + BMU_START = 1<<8, /* Start Rx/Tx Queue */ + BMU_FIFO_OP_ON = 1<<7, /* FIFO Operational On */ + BMU_FIFO_OP_OFF = 1<<6, /* FIFO Operational Off */ + BMU_FIFO_ENA = 1<<5, /* Enable FIFO */ + BMU_FIFO_RST = 1<<4, /* Reset FIFO */ + BMU_OP_ON = 1<<3, /* BMU Operational On */ + BMU_OP_OFF = 1<<2, /* BMU Operational Off */ + BMU_RST_CLR = 1<<1, /* Clear BMU Reset (Enable) */ + BMU_RST_SET = 1<<0, /* Set BMU Reset */ + + BMU_CLR_RESET = BMU_FIFO_RST | BMU_OP_OFF | BMU_RST_CLR, + BMU_OPER_INIT = BMU_CLR_IRQ_PAR | BMU_CLR_IRQ_CHK | BMU_START | + BMU_FIFO_ENA | BMU_OP_ON, +}; + +/* Tx BMU Control / Status Registers (Yukon-2) */ + /* Bit 31: same as for Rx */ +enum { + BMU_TX_IPIDINCR_ON = 1<<13, /* Enable IP ID Increment */ + BMU_TX_IPIDINCR_OFF = 1<<12, /* Disable IP ID Increment */ + BMU_TX_CLR_IRQ_TCP = 1<<11, /* Clear IRQ on TCP segm. length mism. */ +}; + +/* Queue Prefetch Unit Offsets, use Y2_QADDR() to address (Yukon-2 only)*/ +/* PREF_UNIT_CTRL 32 bit Prefetch Control register */ +enum { + PREF_UNIT_OP_ON = 1<<3, /* prefetch unit operational */ + PREF_UNIT_OP_OFF = 1<<2, /* prefetch unit not operational */ + PREF_UNIT_RST_CLR = 1<<1, /* Clear Prefetch Unit Reset */ + PREF_UNIT_RST_SET = 1<<0, /* Set Prefetch Unit Reset */ +}; + +/* RAM Buffer Register Offsets, use RB_ADDR(Queue, Offs) to access */ +/* RB_START 32 bit RAM Buffer Start Address */ +/* RB_END 32 bit RAM Buffer End Address */ +/* RB_WP 32 bit RAM Buffer Write Pointer */ +/* RB_RP 32 bit RAM Buffer Read Pointer */ +/* RB_RX_UTPP 32 bit Rx Upper Threshold, Pause Pack */ +/* RB_RX_LTPP 32 bit Rx Lower Threshold, Pause Pack */ +/* RB_RX_UTHP 32 bit Rx Upper Threshold, High Prio */ +/* RB_RX_LTHP 32 bit Rx Lower Threshold, High Prio */ +/* RB_PC 32 bit RAM Buffer Packet Counter */ +/* RB_LEV 32 bit RAM Buffer Level Register */ + +#define RB_MSK 0x0007ffff /* Bit 18.. 0: RAM Buffer Pointer Bits */ +/* RB_TST2 8 bit RAM Buffer Test Register 2 */ +/* RB_TST1 8 bit RAM Buffer Test Register 1 */ + +/* RB_CTRL 8 bit RAM Buffer Control Register */ +enum { + RB_ENA_STFWD = 1<<5, /* Enable Store & Forward */ + RB_DIS_STFWD = 1<<4, /* Disable Store & Forward */ + RB_ENA_OP_MD = 1<<3, /* Enable Operation Mode */ + RB_DIS_OP_MD = 1<<2, /* Disable Operation Mode */ + RB_RST_CLR = 1<<1, /* Clear RAM Buf STM Reset */ + RB_RST_SET = 1<<0, /* Set RAM Buf STM Reset */ +}; + + +/* Transmit GMAC FIFO (YUKON only) */ +enum { + TX_GMF_EA = 0x0d40,/* 32 bit Tx GMAC FIFO End Address */ + TX_GMF_AE_THR = 0x0d44,/* 32 bit Tx GMAC FIFO Almost Empty Thresh.*/ + TX_GMF_CTRL_T = 0x0d48,/* 32 bit Tx GMAC FIFO Control/Test */ + + TX_GMF_WP = 0x0d60,/* 32 bit Tx GMAC FIFO Write Pointer */ + TX_GMF_WSP = 0x0d64,/* 32 bit Tx GMAC FIFO Write Shadow Ptr. */ + TX_GMF_WLEV = 0x0d68,/* 32 bit Tx GMAC FIFO Write Level */ + + TX_GMF_RP = 0x0d70,/* 32 bit Tx GMAC FIFO Read Pointer */ + TX_GMF_RSTP = 0x0d74,/* 32 bit Tx GMAC FIFO Restart Pointer */ + TX_GMF_RLEV = 0x0d78,/* 32 bit Tx GMAC FIFO Read Level */ +}; + +/* Descriptor Poll Timer Registers */ +enum { + B28_DPT_INI = 0x0e00,/* 24 bit Descriptor Poll Timer Init Val */ + B28_DPT_VAL = 0x0e04,/* 24 bit Descriptor Poll Timer Curr Val */ + B28_DPT_CTRL = 0x0e08,/* 8 bit Descriptor Poll Timer Ctrl Reg */ + + B28_DPT_TST = 0x0e0a,/* 8 bit Descriptor Poll Timer Test Reg */ +}; + +/* Time Stamp Timer Registers (YUKON only) */ +enum { + GMAC_TI_ST_VAL = 0x0e14,/* 32 bit Time Stamp Timer Curr Val */ + GMAC_TI_ST_CTRL = 0x0e18,/* 8 bit Time Stamp Timer Ctrl Reg */ + GMAC_TI_ST_TST = 0x0e1a,/* 8 bit Time Stamp Timer Test Reg */ +}; + +/* Polling Unit Registers (Yukon-2 only) */ +enum { + POLL_CTRL = 0x0e20, /* 32 bit Polling Unit Control Reg */ + POLL_LAST_IDX = 0x0e24,/* 16 bit Polling Unit List Last Index */ + + POLL_LIST_ADDR_LO= 0x0e28,/* 32 bit Poll. List Start Addr (low) */ + POLL_LIST_ADDR_HI= 0x0e2c,/* 32 bit Poll. List Start Addr (high) */ +}; + +/* ASF Subsystem Registers (Yukon-2 only) */ +enum { + B28_Y2_SMB_CONFIG = 0x0e40,/* 32 bit ASF SMBus Config Register */ + B28_Y2_SMB_CSD_REG = 0x0e44,/* 32 bit ASF SMB Control/Status/Data */ + B28_Y2_ASF_IRQ_V_BASE=0x0e60,/* 32 bit ASF IRQ Vector Base */ + + B28_Y2_ASF_STAT_CMD= 0x0e68,/* 32 bit ASF Status and Command Reg */ + B28_Y2_ASF_HOST_COM= 0x0e6c,/* 32 bit ASF Host Communication Reg */ + B28_Y2_DATA_REG_1 = 0x0e70,/* 32 bit ASF/Host Data Register 1 */ + B28_Y2_DATA_REG_2 = 0x0e74,/* 32 bit ASF/Host Data Register 2 */ + B28_Y2_DATA_REG_3 = 0x0e78,/* 32 bit ASF/Host Data Register 3 */ + B28_Y2_DATA_REG_4 = 0x0e7c,/* 32 bit ASF/Host Data Register 4 */ +}; + +/* Status BMU Registers (Yukon-2 only)*/ +enum { + STAT_CTRL = 0x0e80,/* 32 bit Status BMU Control Reg */ + STAT_LAST_IDX = 0x0e84,/* 16 bit Status BMU Last Index */ + + STAT_LIST_ADDR_LO= 0x0e88,/* 32 bit Status List Start Addr (low) */ + STAT_LIST_ADDR_HI= 0x0e8c,/* 32 bit Status List Start Addr (high) */ + STAT_TXA1_RIDX = 0x0e90,/* 16 bit Status TxA1 Report Index Reg */ + STAT_TXS1_RIDX = 0x0e92,/* 16 bit Status TxS1 Report Index Reg */ + STAT_TXA2_RIDX = 0x0e94,/* 16 bit Status TxA2 Report Index Reg */ + STAT_TXS2_RIDX = 0x0e96,/* 16 bit Status TxS2 Report Index Reg */ + STAT_TX_IDX_TH = 0x0e98,/* 16 bit Status Tx Index Threshold Reg */ + STAT_PUT_IDX = 0x0e9c,/* 16 bit Status Put Index Reg */ + +/* FIFO Control/Status Registers (Yukon-2 only)*/ + STAT_FIFO_WP = 0x0ea0,/* 8 bit Status FIFO Write Pointer Reg */ + STAT_FIFO_RP = 0x0ea4,/* 8 bit Status FIFO Read Pointer Reg */ + STAT_FIFO_RSP = 0x0ea6,/* 8 bit Status FIFO Read Shadow Ptr */ + STAT_FIFO_LEVEL = 0x0ea8,/* 8 bit Status FIFO Level Reg */ + STAT_FIFO_SHLVL = 0x0eaa,/* 8 bit Status FIFO Shadow Level Reg */ + STAT_FIFO_WM = 0x0eac,/* 8 bit Status FIFO Watermark Reg */ + STAT_FIFO_ISR_WM= 0x0ead,/* 8 bit Status FIFO ISR Watermark Reg */ + +/* Level and ISR Timer Registers (Yukon-2 only)*/ + STAT_LEV_TIMER_INI= 0x0eb0,/* 32 bit Level Timer Init. Value Reg */ + STAT_LEV_TIMER_CNT= 0x0eb4,/* 32 bit Level Timer Counter Reg */ + STAT_LEV_TIMER_CTRL= 0x0eb8,/* 8 bit Level Timer Control Reg */ + STAT_LEV_TIMER_TEST= 0x0eb9,/* 8 bit Level Timer Test Reg */ + STAT_TX_TIMER_INI = 0x0ec0,/* 32 bit Tx Timer Init. Value Reg */ + STAT_TX_TIMER_CNT = 0x0ec4,/* 32 bit Tx Timer Counter Reg */ + STAT_TX_TIMER_CTRL = 0x0ec8,/* 8 bit Tx Timer Control Reg */ + STAT_TX_TIMER_TEST = 0x0ec9,/* 8 bit Tx Timer Test Reg */ + STAT_ISR_TIMER_INI = 0x0ed0,/* 32 bit ISR Timer Init. Value Reg */ + STAT_ISR_TIMER_CNT = 0x0ed4,/* 32 bit ISR Timer Counter Reg */ + STAT_ISR_TIMER_CTRL= 0x0ed8,/* 8 bit ISR Timer Control Reg */ + STAT_ISR_TIMER_TEST= 0x0ed9,/* 8 bit ISR Timer Test Reg */ + + ST_LAST_IDX_MASK = 0x007f,/* Last Index Mask */ + ST_TXRP_IDX_MASK = 0x0fff,/* Tx Report Index Mask */ + ST_TXTH_IDX_MASK = 0x0fff,/* Tx Threshold Index Mask */ + ST_WM_IDX_MASK = 0x3f,/* FIFO Watermark Index Mask */ +}; + +enum { + LINKLED_OFF = 0x01, + LINKLED_ON = 0x02, + LINKLED_LINKSYNC_OFF = 0x04, + LINKLED_LINKSYNC_ON = 0x08, + LINKLED_BLINK_OFF = 0x10, + LINKLED_BLINK_ON = 0x20, +}; + +/* GMAC and GPHY Control Registers (YUKON only) */ +enum { + GMAC_CTRL = 0x0f00,/* 32 bit GMAC Control Reg */ + GPHY_CTRL = 0x0f04,/* 32 bit GPHY Control Reg */ + GMAC_IRQ_SRC = 0x0f08,/* 8 bit GMAC Interrupt Source Reg */ + GMAC_IRQ_MSK = 0x0f0c,/* 8 bit GMAC Interrupt Mask Reg */ + GMAC_LINK_CTRL = 0x0f10,/* 16 bit Link Control Reg */ + +/* Wake-up Frame Pattern Match Control Registers (YUKON only) */ + + WOL_REG_OFFS = 0x20,/* HW-Bug: Address is + 0x20 against spec. */ + + WOL_CTRL_STAT = 0x0f20,/* 16 bit WOL Control/Status Reg */ + WOL_MATCH_CTL = 0x0f22,/* 8 bit WOL Match Control Reg */ + WOL_MATCH_RES = 0x0f23,/* 8 bit WOL Match Result Reg */ + WOL_MAC_ADDR = 0x0f24,/* 32 bit WOL MAC Address */ + WOL_PATT_PME = 0x0f2a,/* 8 bit WOL PME Match Enable (Yukon-2) */ + WOL_PATT_ASFM = 0x0f2b,/* 8 bit WOL ASF Match Enable (Yukon-2) */ + WOL_PATT_RPTR = 0x0f2c,/* 8 bit WOL Pattern Read Pointer */ + +/* WOL Pattern Length Registers (YUKON only) */ + + WOL_PATT_LEN_LO = 0x0f30,/* 32 bit WOL Pattern Length 3..0 */ + WOL_PATT_LEN_HI = 0x0f34,/* 24 bit WOL Pattern Length 6..4 */ + +/* WOL Pattern Counter Registers (YUKON only) */ + + WOL_PATT_CNT_0 = 0x0f38,/* 32 bit WOL Pattern Counter 3..0 */ + WOL_PATT_CNT_4 = 0x0f3c,/* 24 bit WOL Pattern Counter 6..4 */ +}; + +enum { + WOL_PATT_RAM_1 = 0x1000,/* WOL Pattern RAM Link 1 */ + WOL_PATT_RAM_2 = 0x1400,/* WOL Pattern RAM Link 2 */ +}; + +enum { + BASE_GMAC_1 = 0x2800,/* GMAC 1 registers */ + BASE_GMAC_2 = 0x3800,/* GMAC 2 registers */ +}; + +/* + * Marvel-PHY Registers, indirect addressed over GMAC + */ +enum { + PHY_MARV_CTRL = 0x00,/* 16 bit r/w PHY Control Register */ + PHY_MARV_STAT = 0x01,/* 16 bit r/o PHY Status Register */ + PHY_MARV_ID0 = 0x02,/* 16 bit r/o PHY ID0 Register */ + PHY_MARV_ID1 = 0x03,/* 16 bit r/o PHY ID1 Register */ + PHY_MARV_AUNE_ADV = 0x04,/* 16 bit r/w Auto-Neg. Advertisement */ + PHY_MARV_AUNE_LP = 0x05,/* 16 bit r/o Link Part Ability Reg */ + PHY_MARV_AUNE_EXP = 0x06,/* 16 bit r/o Auto-Neg. Expansion Reg */ + PHY_MARV_NEPG = 0x07,/* 16 bit r/w Next Page Register */ + PHY_MARV_NEPG_LP = 0x08,/* 16 bit r/o Next Page Link Partner */ + /* Marvel-specific registers */ + PHY_MARV_1000T_CTRL = 0x09,/* 16 bit r/w 1000Base-T Control Reg */ + PHY_MARV_1000T_STAT = 0x0a,/* 16 bit r/o 1000Base-T Status Reg */ + PHY_MARV_EXT_STAT = 0x0f,/* 16 bit r/o Extended Status Reg */ + PHY_MARV_PHY_CTRL = 0x10,/* 16 bit r/w PHY Specific Ctrl Reg */ + PHY_MARV_PHY_STAT = 0x11,/* 16 bit r/o PHY Specific Stat Reg */ + PHY_MARV_INT_MASK = 0x12,/* 16 bit r/w Interrupt Mask Reg */ + PHY_MARV_INT_STAT = 0x13,/* 16 bit r/o Interrupt Status Reg */ + PHY_MARV_EXT_CTRL = 0x14,/* 16 bit r/w Ext. PHY Specific Ctrl */ + PHY_MARV_RXE_CNT = 0x15,/* 16 bit r/w Receive Error Counter */ + PHY_MARV_EXT_ADR = 0x16,/* 16 bit r/w Ext. Ad. for Cable Diag. */ + PHY_MARV_PORT_IRQ = 0x17,/* 16 bit r/o Port 0 IRQ (88E1111 only) */ + PHY_MARV_LED_CTRL = 0x18,/* 16 bit r/w LED Control Reg */ + PHY_MARV_LED_OVER = 0x19,/* 16 bit r/w Manual LED Override Reg */ + PHY_MARV_EXT_CTRL_2 = 0x1a,/* 16 bit r/w Ext. PHY Specific Ctrl 2 */ + PHY_MARV_EXT_P_STAT = 0x1b,/* 16 bit r/w Ext. PHY Spec. Stat Reg */ + PHY_MARV_CABLE_DIAG = 0x1c,/* 16 bit r/o Cable Diagnostic Reg */ + PHY_MARV_PAGE_ADDR = 0x1d,/* 16 bit r/w Extended Page Address Reg */ + PHY_MARV_PAGE_DATA = 0x1e,/* 16 bit r/w Extended Page Data Reg */ + +/* for 10/100 Fast Ethernet PHY (88E3082 only) */ + PHY_MARV_FE_LED_PAR = 0x16,/* 16 bit r/w LED Parallel Select Reg. */ + PHY_MARV_FE_LED_SER = 0x17,/* 16 bit r/w LED Stream Select S. LED */ + PHY_MARV_FE_VCT_TX = 0x1a,/* 16 bit r/w VCT Reg. for TXP/N Pins */ + PHY_MARV_FE_VCT_RX = 0x1b,/* 16 bit r/o VCT Reg. for RXP/N Pins */ + PHY_MARV_FE_SPEC_2 = 0x1c,/* 16 bit r/w Specific Control Reg. 2 */ +}; + +enum { + PHY_CT_RESET = 1<<15, /* Bit 15: (sc) clear all PHY related regs */ + PHY_CT_LOOP = 1<<14, /* Bit 14: enable Loopback over PHY */ + PHY_CT_SPS_LSB = 1<<13, /* Bit 13: Speed select, lower bit */ + PHY_CT_ANE = 1<<12, /* Bit 12: Auto-Negotiation Enabled */ + PHY_CT_PDOWN = 1<<11, /* Bit 11: Power Down Mode */ + PHY_CT_ISOL = 1<<10, /* Bit 10: Isolate Mode */ + PHY_CT_RE_CFG = 1<<9, /* Bit 9: (sc) Restart Auto-Negotiation */ + PHY_CT_DUP_MD = 1<<8, /* Bit 8: Duplex Mode */ + PHY_CT_COL_TST = 1<<7, /* Bit 7: Collision Test enabled */ + PHY_CT_SPS_MSB = 1<<6, /* Bit 6: Speed select, upper bit */ +}; + +enum { + PHY_CT_SP1000 = PHY_CT_SPS_MSB, /* enable speed of 1000 Mbps */ + PHY_CT_SP100 = PHY_CT_SPS_LSB, /* enable speed of 100 Mbps */ + PHY_CT_SP10 = 0, /* enable speed of 10 Mbps */ +}; + +enum { + PHY_ST_EXT_ST = 1<<8, /* Bit 8: Extended Status Present */ + + PHY_ST_PRE_SUP = 1<<6, /* Bit 6: Preamble Suppression */ + PHY_ST_AN_OVER = 1<<5, /* Bit 5: Auto-Negotiation Over */ + PHY_ST_REM_FLT = 1<<4, /* Bit 4: Remote Fault Condition Occured */ + PHY_ST_AN_CAP = 1<<3, /* Bit 3: Auto-Negotiation Capability */ + PHY_ST_LSYNC = 1<<2, /* Bit 2: Link Synchronized */ + PHY_ST_JAB_DET = 1<<1, /* Bit 1: Jabber Detected */ + PHY_ST_EXT_REG = 1<<0, /* Bit 0: Extended Register available */ +}; + +enum { + PHY_I1_OUI_MSK = 0x3f<<10, /* Bit 15..10: Organization Unique ID */ + PHY_I1_MOD_NUM = 0x3f<<4, /* Bit 9.. 4: Model Number */ + PHY_I1_REV_MSK = 0xf, /* Bit 3.. 0: Revision Number */ +}; + +/* different Marvell PHY Ids */ +enum { + PHY_MARV_ID0_VAL= 0x0141, /* Marvell Unique Identifier */ + + PHY_BCOM_ID1_A1 = 0x6041, + PHY_BCOM_ID1_B2 = 0x6043, + PHY_BCOM_ID1_C0 = 0x6044, + PHY_BCOM_ID1_C5 = 0x6047, + + PHY_MARV_ID1_B0 = 0x0C23, /* Yukon (PHY 88E1011) */ + PHY_MARV_ID1_B2 = 0x0C25, /* Yukon-Plus (PHY 88E1011) */ + PHY_MARV_ID1_C2 = 0x0CC2, /* Yukon-EC (PHY 88E1111) */ + PHY_MARV_ID1_Y2 = 0x0C91, /* Yukon-2 (PHY 88E1112) */ +}; + +/* Advertisement register bits */ +enum { + PHY_AN_NXT_PG = 1<<15, /* Bit 15: Request Next Page */ + PHY_AN_ACK = 1<<14, /* Bit 14: (ro) Acknowledge Received */ + PHY_AN_RF = 1<<13, /* Bit 13: Remote Fault Bits */ + + PHY_AN_PAUSE_ASYM = 1<<11,/* Bit 11: Try for asymmetric */ + PHY_AN_PAUSE_CAP = 1<<10, /* Bit 10: Try for pause */ + PHY_AN_100BASE4 = 1<<9, /* Bit 9: Try for 100mbps 4k packets */ + PHY_AN_100FULL = 1<<8, /* Bit 8: Try for 100mbps full-duplex */ + PHY_AN_100HALF = 1<<7, /* Bit 7: Try for 100mbps half-duplex */ + PHY_AN_10FULL = 1<<6, /* Bit 6: Try for 10mbps full-duplex */ + PHY_AN_10HALF = 1<<5, /* Bit 5: Try for 10mbps half-duplex */ + PHY_AN_CSMA = 1<<0, /* Bit 0: Only selector supported */ + PHY_AN_SEL = 0x1f, /* Bit 4..0: Selector Field, 00001=Ethernet*/ + PHY_AN_FULL = PHY_AN_100FULL | PHY_AN_10FULL | PHY_AN_CSMA, + PHY_AN_ALL = PHY_AN_10HALF | PHY_AN_10FULL | + PHY_AN_100HALF | PHY_AN_100FULL, +}; + +/***** PHY_BCOM_1000T_STAT 16 bit r/o 1000Base-T Status Reg *****/ +/***** PHY_MARV_1000T_STAT 16 bit r/o 1000Base-T Status Reg *****/ +enum { + PHY_B_1000S_MSF = 1<<15, /* Bit 15: Master/Slave Fault */ + PHY_B_1000S_MSR = 1<<14, /* Bit 14: Master/Slave Result */ + PHY_B_1000S_LRS = 1<<13, /* Bit 13: Local Receiver Status */ + PHY_B_1000S_RRS = 1<<12, /* Bit 12: Remote Receiver Status */ + PHY_B_1000S_LP_FD = 1<<11, /* Bit 11: Link Partner can FD */ + PHY_B_1000S_LP_HD = 1<<10, /* Bit 10: Link Partner can HD */ + /* Bit 9..8: reserved */ + PHY_B_1000S_IEC = 0xff, /* Bit 7..0: Idle Error Count */ +}; + +/** Marvell-Specific */ +enum { + PHY_M_AN_NXT_PG = 1<<15, /* Request Next Page */ + PHY_M_AN_ACK = 1<<14, /* (ro) Acknowledge Received */ + PHY_M_AN_RF = 1<<13, /* Remote Fault */ + + PHY_M_AN_ASP = 1<<11, /* Asymmetric Pause */ + PHY_M_AN_PC = 1<<10, /* MAC Pause implemented */ + PHY_M_AN_100_T4 = 1<<9, /* Not cap. 100Base-T4 (always 0) */ + PHY_M_AN_100_FD = 1<<8, /* Advertise 100Base-TX Full Duplex */ + PHY_M_AN_100_HD = 1<<7, /* Advertise 100Base-TX Half Duplex */ + PHY_M_AN_10_FD = 1<<6, /* Advertise 10Base-TX Full Duplex */ + PHY_M_AN_10_HD = 1<<5, /* Advertise 10Base-TX Half Duplex */ + PHY_M_AN_SEL_MSK =0x1f<<4, /* Bit 4.. 0: Selector Field Mask */ +}; + +/* special defines for FIBER (88E1011S only) */ +enum { + PHY_M_AN_ASP_X = 1<<8, /* Asymmetric Pause */ + PHY_M_AN_PC_X = 1<<7, /* MAC Pause implemented */ + PHY_M_AN_1000X_AHD = 1<<6, /* Advertise 10000Base-X Half Duplex */ + PHY_M_AN_1000X_AFD = 1<<5, /* Advertise 10000Base-X Full Duplex */ +}; + +/* Pause Bits (PHY_M_AN_ASP_X and PHY_M_AN_PC_X) encoding */ +enum { + PHY_M_P_NO_PAUSE_X = 0<<7,/* Bit 8.. 7: no Pause Mode */ + PHY_M_P_SYM_MD_X = 1<<7, /* Bit 8.. 7: symmetric Pause Mode */ + PHY_M_P_ASYM_MD_X = 2<<7,/* Bit 8.. 7: asymmetric Pause Mode */ + PHY_M_P_BOTH_MD_X = 3<<7,/* Bit 8.. 7: both Pause Mode */ +}; + +/***** PHY_MARV_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/ +enum { + PHY_M_1000C_TEST = 7<<13,/* Bit 15..13: Test Modes */ + PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */ + PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */ + PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */ + PHY_M_1000C_AFD = 1<<9, /* Advertise Full Duplex */ + PHY_M_1000C_AHD = 1<<8, /* Advertise Half Duplex */ +}; + +/***** PHY_MARV_PHY_CTRL 16 bit r/w PHY Specific Ctrl Reg *****/ +enum { + PHY_M_PC_TX_FFD_MSK = 3<<14,/* Bit 15..14: Tx FIFO Depth Mask */ + PHY_M_PC_RX_FFD_MSK = 3<<12,/* Bit 13..12: Rx FIFO Depth Mask */ + PHY_M_PC_ASS_CRS_TX = 1<<11, /* Assert CRS on Transmit */ + PHY_M_PC_FL_GOOD = 1<<10, /* Force Link Good */ + PHY_M_PC_EN_DET_MSK = 3<<8,/* Bit 9.. 8: Energy Detect Mask */ + PHY_M_PC_ENA_EXT_D = 1<<7, /* Enable Ext. Distance (10BT) */ + PHY_M_PC_MDIX_MSK = 3<<5,/* Bit 6.. 5: MDI/MDIX Config. Mask */ + PHY_M_PC_DIS_125CLK = 1<<4, /* Disable 125 CLK */ + PHY_M_PC_MAC_POW_UP = 1<<3, /* MAC Power up */ + PHY_M_PC_SQE_T_ENA = 1<<2, /* SQE Test Enabled */ + PHY_M_PC_POL_R_DIS = 1<<1, /* Polarity Reversal Disabled */ + PHY_M_PC_DIS_JABBER = 1<<0, /* Disable Jabber */ +}; + +enum { + PHY_M_PC_EN_DET = 2<<8, /* Energy Detect (Mode 1) */ + PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ +}; + +#define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK) + +enum { + PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ + PHY_M_PC_MAN_MDIX = 1, /* 01 = Manual MDIX configuration */ + PHY_M_PC_ENA_AUTO = 3, /* 11 = Enable Automatic Crossover */ +}; + +/* for 10/100 Fast Ethernet PHY (88E3082 only) */ +enum { + PHY_M_PC_ENA_DTE_DT = 1<<15, /* Enable Data Terminal Equ. (DTE) Detect */ + PHY_M_PC_ENA_ENE_DT = 1<<14, /* Enable Energy Detect (sense & pulse) */ + PHY_M_PC_DIS_NLP_CK = 1<<13, /* Disable Normal Link Puls (NLP) Check */ + PHY_M_PC_ENA_LIP_NP = 1<<12, /* Enable Link Partner Next Page Reg. */ + PHY_M_PC_DIS_NLP_GN = 1<<11, /* Disable Normal Link Puls Generation */ + + PHY_M_PC_DIS_SCRAMB = 1<<9, /* Disable Scrambler */ + PHY_M_PC_DIS_FEFI = 1<<8, /* Disable Far End Fault Indic. (FEFI) */ + + PHY_M_PC_SH_TP_SEL = 1<<6, /* Shielded Twisted Pair Select */ + PHY_M_PC_RX_FD_MSK = 3<<2,/* Bit 3.. 2: Rx FIFO Depth Mask */ +}; + +/***** PHY_MARV_PHY_STAT 16 bit r/o PHY Specific Status Reg *****/ +enum { + PHY_M_PS_SPEED_MSK = 3<<14, /* Bit 15..14: Speed Mask */ + PHY_M_PS_SPEED_1000 = 1<<15, /* 10 = 1000 Mbps */ + PHY_M_PS_SPEED_100 = 1<<14, /* 01 = 100 Mbps */ + PHY_M_PS_SPEED_10 = 0, /* 00 = 10 Mbps */ + PHY_M_PS_FULL_DUP = 1<<13, /* Full Duplex */ + PHY_M_PS_PAGE_REC = 1<<12, /* Page Received */ + PHY_M_PS_SPDUP_RES = 1<<11, /* Speed & Duplex Resolved */ + PHY_M_PS_LINK_UP = 1<<10, /* Link Up */ + PHY_M_PS_CABLE_MSK = 7<<7, /* Bit 9.. 7: Cable Length Mask */ + PHY_M_PS_MDI_X_STAT = 1<<6, /* MDI Crossover Stat (1=MDIX) */ + PHY_M_PS_DOWNS_STAT = 1<<5, /* Downshift Status (1=downsh.) */ + PHY_M_PS_ENDET_STAT = 1<<4, /* Energy Detect Status (1=act) */ + PHY_M_PS_TX_P_EN = 1<<3, /* Tx Pause Enabled */ + PHY_M_PS_RX_P_EN = 1<<2, /* Rx Pause Enabled */ + PHY_M_PS_POL_REV = 1<<1, /* Polarity Reversed */ + PHY_M_PS_JABBER = 1<<0, /* Jabber */ +}; + +#define PHY_M_PS_PAUSE_MSK (PHY_M_PS_TX_P_EN | PHY_M_PS_RX_P_EN) + +/* for 10/100 Fast Ethernet PHY (88E3082 only) */ +enum { + PHY_M_PS_DTE_DETECT = 1<<15, /* Data Terminal Equipment (DTE) Detected */ + PHY_M_PS_RES_SPEED = 1<<14, /* Resolved Speed (1=100 Mbps, 0=10 Mbps */ +}; + +enum { + PHY_M_IS_AN_ERROR = 1<<15, /* Auto-Negotiation Error */ + PHY_M_IS_LSP_CHANGE = 1<<14, /* Link Speed Changed */ + PHY_M_IS_DUP_CHANGE = 1<<13, /* Duplex Mode Changed */ + PHY_M_IS_AN_PR = 1<<12, /* Page Received */ + PHY_M_IS_AN_COMPL = 1<<11, /* Auto-Negotiation Completed */ + PHY_M_IS_LST_CHANGE = 1<<10, /* Link Status Changed */ + PHY_M_IS_SYMB_ERROR = 1<<9, /* Symbol Error */ + PHY_M_IS_FALSE_CARR = 1<<8, /* False Carrier */ + PHY_M_IS_FIFO_ERROR = 1<<7, /* FIFO Overflow/Underrun Error */ + PHY_M_IS_MDI_CHANGE = 1<<6, /* MDI Crossover Changed */ + PHY_M_IS_DOWNSH_DET = 1<<5, /* Downshift Detected */ + PHY_M_IS_END_CHANGE = 1<<4, /* Energy Detect Changed */ + + PHY_M_IS_DTE_CHANGE = 1<<2, /* DTE Power Det. Status Changed */ + PHY_M_IS_POL_CHANGE = 1<<1, /* Polarity Changed */ + PHY_M_IS_JABBER = 1<<0, /* Jabber */ + + PHY_M_DEF_MSK = PHY_M_IS_LSP_CHANGE | PHY_M_IS_LST_CHANGE + | PHY_M_IS_FIFO_ERROR, + PHY_M_AN_MSK = PHY_M_IS_AN_ERROR | PHY_M_IS_AN_COMPL, +}; + + +/***** PHY_MARV_EXT_CTRL 16 bit r/w Ext. PHY Specific Ctrl *****/ +enum { + PHY_M_EC_ENA_BC_EXT = 1<<15, /* Enable Block Carr. Ext. (88E1111 only) */ + PHY_M_EC_ENA_LIN_LB = 1<<14, /* Enable Line Loopback (88E1111 only) */ + + PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */ + PHY_M_EC_M_DSC_MSK = 3<<10, /* Bit 11..10: Master Downshift Counter */ + /* (88E1011 only) */ + PHY_M_EC_S_DSC_MSK = 3<<8,/* Bit 9.. 8: Slave Downshift Counter */ + /* (88E1011 only) */ + PHY_M_EC_M_DSC_MSK2 = 7<<9,/* Bit 11.. 9: Master Downshift Counter */ + /* (88E1111 only) */ + PHY_M_EC_DOWN_S_ENA = 1<<8, /* Downshift Enable (88E1111 only) */ + /* !!! Errata in spec. (1 = disable) */ + PHY_M_EC_RX_TIM_CT = 1<<7, /* RGMII Rx Timing Control*/ + PHY_M_EC_MAC_S_MSK = 7<<4,/* Bit 6.. 4: Def. MAC interface speed */ + PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */ + PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */ + PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ + PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; + +#define PHY_M_EC_M_DSC(x) ((x)<<10 & PHY_M_EC_M_DSC_MSK) + /* 00=1x; 01=2x; 10=3x; 11=4x */ +#define PHY_M_EC_S_DSC(x) ((x)<<8 & PHY_M_EC_S_DSC_MSK) + /* 00=dis; 01=1x; 10=2x; 11=3x */ +#define PHY_M_EC_DSC_2(x) ((x)<<9 & PHY_M_EC_M_DSC_MSK2) + /* 000=1x; 001=2x; 010=3x; 011=4x */ +#define PHY_M_EC_MAC_S(x) ((x)<<4 & PHY_M_EC_MAC_S_MSK) + /* 01X=0; 110=2.5; 111=25 (MHz) */ + +/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */ +enum { + PHY_M_PC_DIS_LINK_Pa = 1<<15,/* Disable Link Pulses */ + PHY_M_PC_DSC_MSK = 7<<12,/* Bit 14..12: Downshift Counter */ + PHY_M_PC_DOWN_S_ENA = 1<<11,/* Downshift Enable */ +}; +/* !!! Errata in spec. (1 = disable) */ + +#define PHY_M_PC_DSC(x) (((x)<<12) & PHY_M_PC_DSC_MSK) + /* 100=5x; 101=6x; 110=7x; 111=8x */ +enum { + MAC_TX_CLK_0_MHZ = 2, + MAC_TX_CLK_2_5_MHZ = 6, + MAC_TX_CLK_25_MHZ = 7, +}; + +/***** PHY_MARV_LED_CTRL 16 bit r/w LED Control Reg *****/ +enum { + PHY_M_LEDC_DIS_LED = 1<<15, /* Disable LED */ + PHY_M_LEDC_PULS_MSK = 7<<12,/* Bit 14..12: Pulse Stretch Mask */ + PHY_M_LEDC_F_INT = 1<<11, /* Force Interrupt */ + PHY_M_LEDC_BL_R_MSK = 7<<8,/* Bit 10.. 8: Blink Rate Mask */ + PHY_M_LEDC_DP_C_LSB = 1<<7, /* Duplex Control (LSB, 88E1111 only) */ + PHY_M_LEDC_TX_C_LSB = 1<<6, /* Tx Control (LSB, 88E1111 only) */ + PHY_M_LEDC_LK_C_MSK = 7<<3,/* Bit 5.. 3: Link Control Mask */ + /* (88E1111 only) */ +}; + +enum { + PHY_M_LEDC_LINK_MSK = 3<<3,/* Bit 4.. 3: Link Control Mask */ + /* (88E1011 only) */ + PHY_M_LEDC_DP_CTRL = 1<<2, /* Duplex Control */ + PHY_M_LEDC_DP_C_MSB = 1<<2, /* Duplex Control (MSB, 88E1111 only) */ + PHY_M_LEDC_RX_CTRL = 1<<1, /* Rx Activity / Link */ + PHY_M_LEDC_TX_CTRL = 1<<0, /* Tx Activity / Link */ + PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ +}; + +#define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK) + +/***** PHY_MARV_PHY_STAT (page 3)16 bit r/w Polarity Control Reg. *****/ +enum { + PHY_M_POLC_LS1M_MSK = 0xf<<12, /* Bit 15..12: LOS,STAT1 Mix % Mask */ + PHY_M_POLC_IS0M_MSK = 0xf<<8, /* Bit 11.. 8: INIT,STAT0 Mix % Mask */ + PHY_M_POLC_LOS_MSK = 0x3<<6, /* Bit 7.. 6: LOS Pol. Ctrl. Mask */ + PHY_M_POLC_INIT_MSK = 0x3<<4, /* Bit 5.. 4: INIT Pol. Ctrl. Mask */ + PHY_M_POLC_STA1_MSK = 0x3<<2, /* Bit 3.. 2: STAT1 Pol. Ctrl. Mask */ + PHY_M_POLC_STA0_MSK = 0x3, /* Bit 1.. 0: STAT0 Pol. Ctrl. Mask */ +}; + +#define PHY_M_POLC_LS1_P_MIX(x) (((x)<<12) & PHY_M_POLC_LS1M_MSK) +#define PHY_M_POLC_IS0_P_MIX(x) (((x)<<8) & PHY_M_POLC_IS0M_MSK) +#define PHY_M_POLC_LOS_CTRL(x) (((x)<<6) & PHY_M_POLC_LOS_MSK) +#define PHY_M_POLC_INIT_CTRL(x) (((x)<<4) & PHY_M_POLC_INIT_MSK) +#define PHY_M_POLC_STA1_CTRL(x) (((x)<<2) & PHY_M_POLC_STA1_MSK) +#define PHY_M_POLC_STA0_CTRL(x) (((x)<<0) & PHY_M_POLC_STA0_MSK) + +enum { + PULS_NO_STR = 0,/* no pulse stretching */ + PULS_21MS = 1,/* 21 ms to 42 ms */ + PULS_42MS = 2,/* 42 ms to 84 ms */ + PULS_84MS = 3,/* 84 ms to 170 ms */ + PULS_170MS = 4,/* 170 ms to 340 ms */ + PULS_340MS = 5,/* 340 ms to 670 ms */ + PULS_670MS = 6,/* 670 ms to 1.3 s */ + PULS_1300MS = 7,/* 1.3 s to 2.7 s */ +}; + +#define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK) + +enum { + BLINK_42MS = 0,/* 42 ms */ + BLINK_84MS = 1,/* 84 ms */ + BLINK_170MS = 2,/* 170 ms */ + BLINK_340MS = 3,/* 340 ms */ + BLINK_670MS = 4,/* 670 ms */ +}; + +/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/ +#define PHY_M_LED_MO_SGMII(x) ((x)<<14) /* Bit 15..14: SGMII AN Timer */ + /* Bit 13..12: reserved */ +#define PHY_M_LED_MO_DUP(x) ((x)<<10) /* Bit 11..10: Duplex */ +#define PHY_M_LED_MO_10(x) ((x)<<8) /* Bit 9.. 8: Link 10 */ +#define PHY_M_LED_MO_100(x) ((x)<<6) /* Bit 7.. 6: Link 100 */ +#define PHY_M_LED_MO_1000(x) ((x)<<4) /* Bit 5.. 4: Link 1000 */ +#define PHY_M_LED_MO_RX(x) ((x)<<2) /* Bit 3.. 2: Rx */ +#define PHY_M_LED_MO_TX(x) ((x)<<0) /* Bit 1.. 0: Tx */ + +enum { + MO_LED_NORM = 0, + MO_LED_BLINK = 1, + MO_LED_OFF = 2, + MO_LED_ON = 3, +}; + +/***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/ +enum { + PHY_M_EC2_FI_IMPED = 1<<6, /* Fiber Input Impedance */ + PHY_M_EC2_FO_IMPED = 1<<5, /* Fiber Output Impedance */ + PHY_M_EC2_FO_M_CLK = 1<<4, /* Fiber Mode Clock Enable */ + PHY_M_EC2_FO_BOOST = 1<<3, /* Fiber Output Boost */ + PHY_M_EC2_FO_AM_MSK = 7,/* Bit 2.. 0: Fiber Output Amplitude */ +}; + +/***** PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/ +enum { + PHY_M_FC_AUTO_SEL = 1<<15, /* Fiber/Copper Auto Sel. Dis. */ + PHY_M_FC_AN_REG_ACC = 1<<14, /* Fiber/Copper AN Reg. Access */ + PHY_M_FC_RESOLUTION = 1<<13, /* Fiber/Copper Resolution */ + PHY_M_SER_IF_AN_BP = 1<<12, /* Ser. IF AN Bypass Enable */ + PHY_M_SER_IF_BP_ST = 1<<11, /* Ser. IF AN Bypass Status */ + PHY_M_IRQ_POLARITY = 1<<10, /* IRQ polarity */ + PHY_M_DIS_AUT_MED = 1<<9, /* Disable Aut. Medium Reg. Selection */ + /* (88E1111 only) */ + + PHY_M_UNDOC1 = 1<<7, /* undocumented bit !! */ + PHY_M_DTE_POW_STAT = 1<<4, /* DTE Power Status (88E1111 only) */ + PHY_M_MODE_MASK = 0xf, /* Bit 3.. 0: copy of HWCFG MODE[3:0] */ +}; + +/* for 10/100 Fast Ethernet PHY (88E3082 only) */ +/***** PHY_MARV_FE_LED_PAR 16 bit r/w LED Parallel Select Reg. *****/ + /* Bit 15..12: reserved (used internally) */ +enum { + PHY_M_FELP_LED2_MSK = 0xf<<8, /* Bit 11.. 8: LED2 Mask (LINK) */ + PHY_M_FELP_LED1_MSK = 0xf<<4, /* Bit 7.. 4: LED1 Mask (ACT) */ + PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */ +}; + +#define PHY_M_FELP_LED2_CTRL(x) (((x)<<8) & PHY_M_FELP_LED2_MSK) +#define PHY_M_FELP_LED1_CTRL(x) (((x)<<4) & PHY_M_FELP_LED1_MSK) +#define PHY_M_FELP_LED0_CTRL(x) (((x)<<0) & PHY_M_FELP_LED0_MSK) + +enum { + LED_PAR_CTRL_COLX = 0x00, + LED_PAR_CTRL_ERROR = 0x01, + LED_PAR_CTRL_DUPLEX = 0x02, + LED_PAR_CTRL_DP_COL = 0x03, + LED_PAR_CTRL_SPEED = 0x04, + LED_PAR_CTRL_LINK = 0x05, + LED_PAR_CTRL_TX = 0x06, + LED_PAR_CTRL_RX = 0x07, + LED_PAR_CTRL_ACT = 0x08, + LED_PAR_CTRL_LNK_RX = 0x09, + LED_PAR_CTRL_LNK_AC = 0x0a, + LED_PAR_CTRL_ACT_BL = 0x0b, + LED_PAR_CTRL_TX_BL = 0x0c, + LED_PAR_CTRL_RX_BL = 0x0d, + LED_PAR_CTRL_COL_BL = 0x0e, + LED_PAR_CTRL_INACT = 0x0f +}; + +/*****,PHY_MARV_FE_SPEC_2 16 bit r/w Specific Control Reg. 2 *****/ +enum { + PHY_M_FESC_DIS_WAIT = 1<<2, /* Disable TDR Waiting Period */ + PHY_M_FESC_ENA_MCLK = 1<<1, /* Enable MAC Rx Clock in sleep mode */ + PHY_M_FESC_SEL_CL_A = 1<<0, /* Select Class A driver (100B-TX) */ +}; + +/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */ +/***** PHY_MARV_PHY_CTRL (page 2) 16 bit r/w MAC Specific Ctrl *****/ +enum { + PHY_M_MAC_MD_MSK = 7<<7, /* Bit 9.. 7: Mode Select Mask */ + PHY_M_MAC_MD_AUTO = 3,/* Auto Copper/1000Base-X */ + PHY_M_MAC_MD_COPPER = 5,/* Copper only */ + PHY_M_MAC_MD_1000BX = 7,/* 1000Base-X only */ +}; +#define PHY_M_MAC_MODE_SEL(x) (((x)<<7) & PHY_M_MAC_MD_MSK) + +/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ +enum { + PHY_M_LEDC_LOS_MSK = 0xf<<12,/* Bit 15..12: LOS LED Ctrl. Mask */ + PHY_M_LEDC_INIT_MSK = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */ + PHY_M_LEDC_STA1_MSK = 0xf<<4,/* Bit 7.. 4: STAT1 LED Ctrl. Mask */ + PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */ +}; + +#define PHY_M_LEDC_LOS_CTRL(x) (((x)<<12) & PHY_M_LEDC_LOS_MSK) +#define PHY_M_LEDC_INIT_CTRL(x) (((x)<<8) & PHY_M_LEDC_INIT_MSK) +#define PHY_M_LEDC_STA1_CTRL(x) (((x)<<4) & PHY_M_LEDC_STA1_MSK) +#define PHY_M_LEDC_STA0_CTRL(x) (((x)<<0) & PHY_M_LEDC_STA0_MSK) + +/* GMAC registers */ +/* Port Registers */ +enum { + GM_GP_STAT = 0x0000, /* 16 bit r/o General Purpose Status */ + GM_GP_CTRL = 0x0004, /* 16 bit r/w General Purpose Control */ + GM_TX_CTRL = 0x0008, /* 16 bit r/w Transmit Control Reg. */ + GM_RX_CTRL = 0x000c, /* 16 bit r/w Receive Control Reg. */ + GM_TX_FLOW_CTRL = 0x0010, /* 16 bit r/w Transmit Flow-Control */ + GM_TX_PARAM = 0x0014, /* 16 bit r/w Transmit Parameter Reg. */ + GM_SERIAL_MODE = 0x0018, /* 16 bit r/w Serial Mode Register */ +/* Source Address Registers */ + GM_SRC_ADDR_1L = 0x001c, /* 16 bit r/w Source Address 1 (low) */ + GM_SRC_ADDR_1M = 0x0020, /* 16 bit r/w Source Address 1 (middle) */ + GM_SRC_ADDR_1H = 0x0024, /* 16 bit r/w Source Address 1 (high) */ + GM_SRC_ADDR_2L = 0x0028, /* 16 bit r/w Source Address 2 (low) */ + GM_SRC_ADDR_2M = 0x002c, /* 16 bit r/w Source Address 2 (middle) */ + GM_SRC_ADDR_2H = 0x0030, /* 16 bit r/w Source Address 2 (high) */ + +/* Multicast Address Hash Registers */ + GM_MC_ADDR_H1 = 0x0034, /* 16 bit r/w Multicast Address Hash 1 */ + GM_MC_ADDR_H2 = 0x0038, /* 16 bit r/w Multicast Address Hash 2 */ + GM_MC_ADDR_H3 = 0x003c, /* 16 bit r/w Multicast Address Hash 3 */ + GM_MC_ADDR_H4 = 0x0040, /* 16 bit r/w Multicast Address Hash 4 */ + +/* Interrupt Source Registers */ + GM_TX_IRQ_SRC = 0x0044, /* 16 bit r/o Tx Overflow IRQ Source */ + GM_RX_IRQ_SRC = 0x0048, /* 16 bit r/o Rx Overflow IRQ Source */ + GM_TR_IRQ_SRC = 0x004c, /* 16 bit r/o Tx/Rx Over. IRQ Source */ + +/* Interrupt Mask Registers */ + GM_TX_IRQ_MSK = 0x0050, /* 16 bit r/w Tx Overflow IRQ Mask */ + GM_RX_IRQ_MSK = 0x0054, /* 16 bit r/w Rx Overflow IRQ Mask */ + GM_TR_IRQ_MSK = 0x0058, /* 16 bit r/w Tx/Rx Over. IRQ Mask */ + +/* Serial Management Interface (SMI) Registers */ + GM_SMI_CTRL = 0x0080, /* 16 bit r/w SMI Control Register */ + GM_SMI_DATA = 0x0084, /* 16 bit r/w SMI Data Register */ + GM_PHY_ADDR = 0x0088, /* 16 bit r/w GPHY Address Register */ +}; + +/* MIB Counters */ +#define GM_MIB_CNT_BASE 0x0100 /* Base Address of MIB Counters */ +#define GM_MIB_CNT_SIZE 44 /* Number of MIB Counters */ + +/* + * MIB Counters base address definitions (low word) - + * use offset 4 for access to high word (32 bit r/o) + */ +enum { + GM_RXF_UC_OK = GM_MIB_CNT_BASE + 0, /* Unicast Frames Received OK */ + GM_RXF_BC_OK = GM_MIB_CNT_BASE + 8, /* Broadcast Frames Received OK */ + GM_RXF_MPAUSE = GM_MIB_CNT_BASE + 16, /* Pause MAC Ctrl Frames Received */ + GM_RXF_MC_OK = GM_MIB_CNT_BASE + 24, /* Multicast Frames Received OK */ + GM_RXF_FCS_ERR = GM_MIB_CNT_BASE + 32, /* Rx Frame Check Seq. Error */ + /* GM_MIB_CNT_BASE + 40: reserved */ + GM_RXO_OK_LO = GM_MIB_CNT_BASE + 48, /* Octets Received OK Low */ + GM_RXO_OK_HI = GM_MIB_CNT_BASE + 56, /* Octets Received OK High */ + GM_RXO_ERR_LO = GM_MIB_CNT_BASE + 64, /* Octets Received Invalid Low */ + GM_RXO_ERR_HI = GM_MIB_CNT_BASE + 72, /* Octets Received Invalid High */ + GM_RXF_SHT = GM_MIB_CNT_BASE + 80, /* Frames <64 Byte Received OK */ + GM_RXE_FRAG = GM_MIB_CNT_BASE + 88, /* Frames <64 Byte Received with FCS Err */ + GM_RXF_64B = GM_MIB_CNT_BASE + 96, /* 64 Byte Rx Frame */ + GM_RXF_127B = GM_MIB_CNT_BASE + 104, /* 65-127 Byte Rx Frame */ + GM_RXF_255B = GM_MIB_CNT_BASE + 112, /* 128-255 Byte Rx Frame */ + GM_RXF_511B = GM_MIB_CNT_BASE + 120, /* 256-511 Byte Rx Frame */ + GM_RXF_1023B = GM_MIB_CNT_BASE + 128, /* 512-1023 Byte Rx Frame */ + GM_RXF_1518B = GM_MIB_CNT_BASE + 136, /* 1024-1518 Byte Rx Frame */ + GM_RXF_MAX_SZ = GM_MIB_CNT_BASE + 144, /* 1519-MaxSize Byte Rx Frame */ + GM_RXF_LNG_ERR = GM_MIB_CNT_BASE + 152, /* Rx Frame too Long Error */ + GM_RXF_JAB_PKT = GM_MIB_CNT_BASE + 160, /* Rx Jabber Packet Frame */ + /* GM_MIB_CNT_BASE + 168: reserved */ + GM_RXE_FIFO_OV = GM_MIB_CNT_BASE + 176, /* Rx FIFO overflow Event */ + /* GM_MIB_CNT_BASE + 184: reserved */ + GM_TXF_UC_OK = GM_MIB_CNT_BASE + 192, /* Unicast Frames Xmitted OK */ + GM_TXF_BC_OK = GM_MIB_CNT_BASE + 200, /* Broadcast Frames Xmitted OK */ + GM_TXF_MPAUSE = GM_MIB_CNT_BASE + 208, /* Pause MAC Ctrl Frames Xmitted */ + GM_TXF_MC_OK = GM_MIB_CNT_BASE + 216, /* Multicast Frames Xmitted OK */ + GM_TXO_OK_LO = GM_MIB_CNT_BASE + 224, /* Octets Transmitted OK Low */ + GM_TXO_OK_HI = GM_MIB_CNT_BASE + 232, /* Octets Transmitted OK High */ + GM_TXF_64B = GM_MIB_CNT_BASE + 240, /* 64 Byte Tx Frame */ + GM_TXF_127B = GM_MIB_CNT_BASE + 248, /* 65-127 Byte Tx Frame */ + GM_TXF_255B = GM_MIB_CNT_BASE + 256, /* 128-255 Byte Tx Frame */ + GM_TXF_511B = GM_MIB_CNT_BASE + 264, /* 256-511 Byte Tx Frame */ + GM_TXF_1023B = GM_MIB_CNT_BASE + 272, /* 512-1023 Byte Tx Frame */ + GM_TXF_1518B = GM_MIB_CNT_BASE + 280, /* 1024-1518 Byte Tx Frame */ + GM_TXF_MAX_SZ = GM_MIB_CNT_BASE + 288, /* 1519-MaxSize Byte Tx Frame */ + + GM_TXF_COL = GM_MIB_CNT_BASE + 304, /* Tx Collision */ + GM_TXF_LAT_COL = GM_MIB_CNT_BASE + 312, /* Tx Late Collision */ + GM_TXF_ABO_COL = GM_MIB_CNT_BASE + 320, /* Tx aborted due to Exces. Col. */ + GM_TXF_MUL_COL = GM_MIB_CNT_BASE + 328, /* Tx Multiple Collision */ + GM_TXF_SNG_COL = GM_MIB_CNT_BASE + 336, /* Tx Single Collision */ + GM_TXE_FIFO_UR = GM_MIB_CNT_BASE + 344, /* Tx FIFO Underrun Event */ +}; + +/* GMAC Bit Definitions */ +/* GM_GP_STAT 16 bit r/o General Purpose Status Register */ +enum { + GM_GPSR_SPEED = 1<<15, /* Bit 15: Port Speed (1 = 100 Mbps) */ + GM_GPSR_DUPLEX = 1<<14, /* Bit 14: Duplex Mode (1 = Full) */ + GM_GPSR_FC_TX_DIS = 1<<13, /* Bit 13: Tx Flow-Control Mode Disabled */ + GM_GPSR_LINK_UP = 1<<12, /* Bit 12: Link Up Status */ + GM_GPSR_PAUSE = 1<<11, /* Bit 11: Pause State */ + GM_GPSR_TX_ACTIVE = 1<<10, /* Bit 10: Tx in Progress */ + GM_GPSR_EXC_COL = 1<<9, /* Bit 9: Excessive Collisions Occured */ + GM_GPSR_LAT_COL = 1<<8, /* Bit 8: Late Collisions Occured */ + + GM_GPSR_PHY_ST_CH = 1<<5, /* Bit 5: PHY Status Change */ + GM_GPSR_GIG_SPEED = 1<<4, /* Bit 4: Gigabit Speed (1 = 1000 Mbps) */ + GM_GPSR_PART_MODE = 1<<3, /* Bit 3: Partition mode */ + GM_GPSR_FC_RX_DIS = 1<<2, /* Bit 2: Rx Flow-Control Mode Disabled */ + GM_GPSR_PROM_EN = 1<<1, /* Bit 1: Promiscuous Mode Enabled */ +}; + +/* GM_GP_CTRL 16 bit r/w General Purpose Control Register */ +enum { + GM_GPCR_PROM_ENA = 1<<14, /* Bit 14: Enable Promiscuous Mode */ + GM_GPCR_FC_TX_DIS = 1<<13, /* Bit 13: Disable Tx Flow-Control Mode */ + GM_GPCR_TX_ENA = 1<<12, /* Bit 12: Enable Transmit */ + GM_GPCR_RX_ENA = 1<<11, /* Bit 11: Enable Receive */ + GM_GPCR_BURST_ENA = 1<<10, /* Bit 10: Enable Burst Mode */ + GM_GPCR_LOOP_ENA = 1<<9, /* Bit 9: Enable MAC Loopback Mode */ + GM_GPCR_PART_ENA = 1<<8, /* Bit 8: Enable Partition Mode */ + GM_GPCR_GIGS_ENA = 1<<7, /* Bit 7: Gigabit Speed (1000 Mbps) */ + GM_GPCR_FL_PASS = 1<<6, /* Bit 6: Force Link Pass */ + GM_GPCR_DUP_FULL = 1<<5, /* Bit 5: Full Duplex Mode */ + GM_GPCR_FC_RX_DIS = 1<<4, /* Bit 4: Disable Rx Flow-Control Mode */ + GM_GPCR_SPEED_100 = 1<<3, /* Bit 3: Port Speed 100 Mbps */ + GM_GPCR_AU_DUP_DIS = 1<<2, /* Bit 2: Disable Auto-Update Duplex */ + GM_GPCR_AU_FCT_DIS = 1<<1, /* Bit 1: Disable Auto-Update Flow-C. */ + GM_GPCR_AU_SPD_DIS = 1<<0, /* Bit 0: Disable Auto-Update Speed */ +}; + +#define GM_GPCR_SPEED_1000 (GM_GPCR_GIGS_ENA | GM_GPCR_SPEED_100) +#define GM_GPCR_AU_ALL_DIS (GM_GPCR_AU_DUP_DIS | GM_GPCR_AU_FCT_DIS|GM_GPCR_AU_SPD_DIS) + +/* GM_TX_CTRL 16 bit r/w Transmit Control Register */ +enum { + GM_TXCR_FORCE_JAM = 1<<15, /* Bit 15: Force Jam / Flow-Control */ + GM_TXCR_CRC_DIS = 1<<14, /* Bit 14: Disable insertion of CRC */ + GM_TXCR_PAD_DIS = 1<<13, /* Bit 13: Disable padding of packets */ + GM_TXCR_COL_THR_MSK = 1<<10, /* Bit 12..10: Collision Threshold */ +}; + +#define TX_COL_THR(x) (((x)<<10) & GM_TXCR_COL_THR_MSK) +#define TX_COL_DEF 0x04 + +/* GM_RX_CTRL 16 bit r/w Receive Control Register */ +enum { + GM_RXCR_UCF_ENA = 1<<15, /* Bit 15: Enable Unicast filtering */ + GM_RXCR_MCF_ENA = 1<<14, /* Bit 14: Enable Multicast filtering */ + GM_RXCR_CRC_DIS = 1<<13, /* Bit 13: Remove 4-byte CRC */ + GM_RXCR_PASS_FC = 1<<12, /* Bit 12: Pass FC packets to FIFO */ +}; + +/* GM_TX_PARAM 16 bit r/w Transmit Parameter Register */ +enum { + GM_TXPA_JAMLEN_MSK = 0x03<<14, /* Bit 15..14: Jam Length */ + GM_TXPA_JAMIPG_MSK = 0x1f<<9, /* Bit 13..9: Jam IPG */ + GM_TXPA_JAMDAT_MSK = 0x1f<<4, /* Bit 8..4: IPG Jam to Data */ + GM_TXPA_BO_LIM_MSK = 0x0f, /* Bit 3.. 0: Backoff Limit Mask */ + + TX_JAM_LEN_DEF = 0x03, + TX_JAM_IPG_DEF = 0x0b, + TX_IPG_JAM_DEF = 0x1c, + TX_BOF_LIM_DEF = 0x04, +}; + +#define TX_JAM_LEN_VAL(x) (((x)<<14) & GM_TXPA_JAMLEN_MSK) +#define TX_JAM_IPG_VAL(x) (((x)<<9) & GM_TXPA_JAMIPG_MSK) +#define TX_IPG_JAM_DATA(x) (((x)<<4) & GM_TXPA_JAMDAT_MSK) +#define TX_BACK_OFF_LIM(x) ((x) & GM_TXPA_BO_LIM_MSK) + + +/* GM_SERIAL_MODE 16 bit r/w Serial Mode Register */ +enum { + GM_SMOD_DATABL_MSK = 0x1f<<11, /* Bit 15..11: Data Blinder (r/o) */ + GM_SMOD_LIMIT_4 = 1<<10, /* Bit 10: 4 consecutive Tx trials */ + GM_SMOD_VLAN_ENA = 1<<9, /* Bit 9: Enable VLAN (Max. Frame Len) */ + GM_SMOD_JUMBO_ENA = 1<<8, /* Bit 8: Enable Jumbo (Max. Frame Len) */ + GM_SMOD_IPG_MSK = 0x1f /* Bit 4..0: Inter-Packet Gap (IPG) */ +}; + +#define DATA_BLIND_VAL(x) (((x)<<11) & GM_SMOD_DATABL_MSK) +#define DATA_BLIND_DEF 0x04 + +#define IPG_DATA_VAL(x) (x & GM_SMOD_IPG_MSK) +#define IPG_DATA_DEF 0x1e + +/* GM_SMI_CTRL 16 bit r/w SMI Control Register */ +enum { + GM_SMI_CT_PHY_A_MSK = 0x1f<<11,/* Bit 15..11: PHY Device Address */ + GM_SMI_CT_REG_A_MSK = 0x1f<<6,/* Bit 10.. 6: PHY Register Address */ + GM_SMI_CT_OP_RD = 1<<5, /* Bit 5: OpCode Read (0=Write)*/ + GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */ + GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ +}; + +#define GM_SMI_CT_PHY_AD(x) (((x)<<11) & GM_SMI_CT_PHY_A_MSK) +#define GM_SMI_CT_REG_AD(x) (((x)<<6) & GM_SMI_CT_REG_A_MSK) + +/* GM_PHY_ADDR 16 bit r/w GPHY Address Register */ +enum { + GM_PAR_MIB_CLR = 1<<5, /* Bit 5: Set MIB Clear Counter Mode */ + GM_PAR_MIB_TST = 1<<4, /* Bit 4: MIB Load Counter (Test Mode) */ +}; + +/* Receive Frame Status Encoding */ +enum { + GMR_FS_LEN = 0xffff<<16, /* Bit 31..16: Rx Frame Length */ + GMR_FS_VLAN = 1<<13, /* Bit 13: VLAN Packet */ + GMR_FS_JABBER = 1<<12, /* Bit 12: Jabber Packet */ + GMR_FS_UN_SIZE = 1<<11, /* Bit 11: Undersize Packet */ + GMR_FS_MC = 1<<10, /* Bit 10: Multicast Packet */ + GMR_FS_BC = 1<<9, /* Bit 9: Broadcast Packet */ + GMR_FS_RX_OK = 1<<8, /* Bit 8: Receive OK (Good Packet) */ + GMR_FS_GOOD_FC = 1<<7, /* Bit 7: Good Flow-Control Packet */ + GMR_FS_BAD_FC = 1<<6, /* Bit 6: Bad Flow-Control Packet */ + GMR_FS_MII_ERR = 1<<5, /* Bit 5: MII Error */ + GMR_FS_LONG_ERR = 1<<4, /* Bit 4: Too Long Packet */ + GMR_FS_FRAGMENT = 1<<3, /* Bit 3: Fragment */ + + GMR_FS_CRC_ERR = 1<<1, /* Bit 1: CRC Error */ + GMR_FS_RX_FF_OV = 1<<0, /* Bit 0: Rx FIFO Overflow */ + +/* + * GMR_FS_ANY_ERR (analogous to XMR_FS_ANY_ERR) + */ + GMR_FS_ANY_ERR = GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR | + GMR_FS_FRAGMENT | GMR_FS_LONG_ERR | + GMR_FS_MII_ERR | GMR_FS_BAD_FC | GMR_FS_GOOD_FC | + GMR_FS_UN_SIZE | GMR_FS_JABBER, +/* Rx GMAC FIFO Flush Mask (default) */ + RX_FF_FL_DEF_MSK = GMR_FS_ANY_ERR, +}; + +/* RX_GMF_CTRL_T 32 bit Rx GMAC FIFO Control/Test */ +enum { + GMF_WP_TST_ON = 1<<14, /* Write Pointer Test On */ + GMF_WP_TST_OFF = 1<<13, /* Write Pointer Test Off */ + GMF_WP_STEP = 1<<12, /* Write Pointer Step/Increment */ + + GMF_RP_TST_ON = 1<<10, /* Read Pointer Test On */ + GMF_RP_TST_OFF = 1<<9, /* Read Pointer Test Off */ + GMF_RP_STEP = 1<<8, /* Read Pointer Step/Increment */ + GMF_RX_F_FL_ON = 1<<7, /* Rx FIFO Flush Mode On */ + GMF_RX_F_FL_OFF = 1<<6, /* Rx FIFO Flush Mode Off */ + GMF_CLI_RX_FO = 1<<5, /* Clear IRQ Rx FIFO Overrun */ + GMF_CLI_RX_FC = 1<<4, /* Clear IRQ Rx Frame Complete */ + GMF_OPER_ON = 1<<3, /* Operational Mode On */ + GMF_OPER_OFF = 1<<2, /* Operational Mode Off */ + GMF_RST_CLR = 1<<1, /* Clear GMAC FIFO Reset */ + GMF_RST_SET = 1<<0, /* Set GMAC FIFO Reset */ + + RX_GMF_FL_THR_DEF = 0xa, /* flush threshold (default) */ +}; + + +/* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */ +enum { + GMF_WSP_TST_ON = 1<<18,/* Write Shadow Pointer Test On */ + GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */ + GMF_WSP_STEP = 1<<16,/* Write Shadow Pointer Step/Increment */ + + GMF_CLI_TX_FU = 1<<6, /* Clear IRQ Tx FIFO Underrun */ + GMF_CLI_TX_FC = 1<<5, /* Clear IRQ Tx Frame Complete */ + GMF_CLI_TX_PE = 1<<4, /* Clear IRQ Tx Parity Error */ +}; + +/* GMAC_TI_ST_CTRL 8 bit Time Stamp Timer Ctrl Reg (YUKON only) */ +enum { + GMT_ST_START = 1<<2, /* Start Time Stamp Timer */ + GMT_ST_STOP = 1<<1, /* Stop Time Stamp Timer */ + GMT_ST_CLR_IRQ = 1<<0, /* Clear Time Stamp Timer IRQ */ +}; + +/* B28_Y2_ASF_STAT_CMD 32 bit ASF Status and Command Reg */ +enum { + Y2_ASF_OS_PRES = 1<<4, /* ASF operation system present */ + Y2_ASF_RESET = 1<<3, /* ASF system in reset state */ + Y2_ASF_RUNNING = 1<<2, /* ASF system operational */ + Y2_ASF_CLR_HSTI = 1<<1, /* Clear ASF IRQ */ + Y2_ASF_IRQ = 1<<0, /* Issue an IRQ to ASF system */ + + Y2_ASF_UC_STATE = 3<<2, /* ASF uC State */ + Y2_ASF_CLK_HALT = 0, /* ASF system clock stopped */ +}; + +/* B28_Y2_ASF_HOST_COM 32 bit ASF Host Communication Reg */ +enum { + Y2_ASF_CLR_ASFI = 1<<1, /* Clear host IRQ */ + Y2_ASF_HOST_IRQ = 1<<0, /* Issue an IRQ to HOST system */ +}; + +/* STAT_CTRL 32 bit Status BMU control register (Yukon-2 only) */ +enum { + SC_STAT_CLR_IRQ = 1<<4, /* Status Burst IRQ clear */ + SC_STAT_OP_ON = 1<<3, /* Operational Mode On */ + SC_STAT_OP_OFF = 1<<2, /* Operational Mode Off */ + SC_STAT_RST_CLR = 1<<1, /* Clear Status Unit Reset (Enable) */ + SC_STAT_RST_SET = 1<<0, /* Set Status Unit Reset */ +}; + +/* GMAC_CTRL 32 bit GMAC Control Reg (YUKON only) */ +enum { + GMC_H_BURST_ON = 1<<7, /* Half Duplex Burst Mode On */ + GMC_H_BURST_OFF = 1<<6, /* Half Duplex Burst Mode Off */ + GMC_F_LOOPB_ON = 1<<5, /* FIFO Loopback On */ + GMC_F_LOOPB_OFF = 1<<4, /* FIFO Loopback Off */ + GMC_PAUSE_ON = 1<<3, /* Pause On */ + GMC_PAUSE_OFF = 1<<2, /* Pause Off */ + GMC_RST_CLR = 1<<1, /* Clear GMAC Reset */ + GMC_RST_SET = 1<<0, /* Set GMAC Reset */ +}; + +/* GPHY_CTRL 32 bit GPHY Control Reg (YUKON only) */ +enum { + GPC_SEL_BDT = 1<<28, /* Select Bi-Dir. Transfer for MDC/MDIO */ + GPC_INT_POL_HI = 1<<27, /* IRQ Polarity is Active HIGH */ + GPC_75_OHM = 1<<26, /* Use 75 Ohm Termination instead of 50 */ + GPC_DIS_FC = 1<<25, /* Disable Automatic Fiber/Copper Detection */ + GPC_DIS_SLEEP = 1<<24, /* Disable Energy Detect */ + GPC_HWCFG_M_3 = 1<<23, /* HWCFG_MODE[3] */ + GPC_HWCFG_M_2 = 1<<22, /* HWCFG_MODE[2] */ + GPC_HWCFG_M_1 = 1<<21, /* HWCFG_MODE[1] */ + GPC_HWCFG_M_0 = 1<<20, /* HWCFG_MODE[0] */ + GPC_ANEG_0 = 1<<19, /* ANEG[0] */ + GPC_ENA_XC = 1<<18, /* Enable MDI crossover */ + GPC_DIS_125 = 1<<17, /* Disable 125 MHz clock */ + GPC_ANEG_3 = 1<<16, /* ANEG[3] */ + GPC_ANEG_2 = 1<<15, /* ANEG[2] */ + GPC_ANEG_1 = 1<<14, /* ANEG[1] */ + GPC_ENA_PAUSE = 1<<13, /* Enable Pause (SYM_OR_REM) */ + GPC_PHYADDR_4 = 1<<12, /* Bit 4 of Phy Addr */ + GPC_PHYADDR_3 = 1<<11, /* Bit 3 of Phy Addr */ + GPC_PHYADDR_2 = 1<<10, /* Bit 2 of Phy Addr */ + GPC_PHYADDR_1 = 1<<9, /* Bit 1 of Phy Addr */ + GPC_PHYADDR_0 = 1<<8, /* Bit 0 of Phy Addr */ + /* Bits 7..2: reserved */ + GPC_RST_CLR = 1<<1, /* Clear GPHY Reset */ + GPC_RST_SET = 1<<0, /* Set GPHY Reset */ +}; + +/* GMAC_IRQ_SRC 8 bit GMAC Interrupt Source Reg (YUKON only) */ +/* GMAC_IRQ_MSK 8 bit GMAC Interrupt Mask Reg (YUKON only) */ +enum { + GM_IS_TX_CO_OV = 1<<5, /* Transmit Counter Overflow IRQ */ + GM_IS_RX_CO_OV = 1<<4, /* Receive Counter Overflow IRQ */ + GM_IS_TX_FF_UR = 1<<3, /* Transmit FIFO Underrun */ + GM_IS_TX_COMPL = 1<<2, /* Frame Transmission Complete */ + GM_IS_RX_FF_OR = 1<<1, /* Receive FIFO Overrun */ + GM_IS_RX_COMPL = 1<<0, /* Frame Reception Complete */ + +#define GMAC_DEF_MSK (GM_IS_TX_CO_OV | GM_IS_RX_CO_OV |\ + GM_IS_TX_FF_UR | GM_IS_RX_FF_OR) + +/* GMAC_LINK_CTRL 16 bit GMAC Link Control Reg (YUKON only) */ + /* Bits 15.. 2: reserved */ + GMLC_RST_CLR = 1<<1, /* Clear GMAC Link Reset */ + GMLC_RST_SET = 1<<0, /* Set GMAC Link Reset */ + + +/* WOL_CTRL_STAT 16 bit WOL Control/Status Reg */ + WOL_CTL_LINK_CHG_OCC = 1<<15, + WOL_CTL_MAGIC_PKT_OCC = 1<<14, + WOL_CTL_PATTERN_OCC = 1<<13, + WOL_CTL_CLEAR_RESULT = 1<<12, + WOL_CTL_ENA_PME_ON_LINK_CHG = 1<<11, + WOL_CTL_DIS_PME_ON_LINK_CHG = 1<<10, + WOL_CTL_ENA_PME_ON_MAGIC_PKT = 1<<9, + WOL_CTL_DIS_PME_ON_MAGIC_PKT = 1<<8, + WOL_CTL_ENA_PME_ON_PATTERN = 1<<7, + WOL_CTL_DIS_PME_ON_PATTERN = 1<<6, + WOL_CTL_ENA_LINK_CHG_UNIT = 1<<5, + WOL_CTL_DIS_LINK_CHG_UNIT = 1<<4, + WOL_CTL_ENA_MAGIC_PKT_UNIT = 1<<3, + WOL_CTL_DIS_MAGIC_PKT_UNIT = 1<<2, + WOL_CTL_ENA_PATTERN_UNIT = 1<<1, + WOL_CTL_DIS_PATTERN_UNIT = 1<<0, +}; + +#define WOL_CTL_DEFAULT \ + (WOL_CTL_DIS_PME_ON_LINK_CHG | \ + WOL_CTL_DIS_PME_ON_PATTERN | \ + WOL_CTL_DIS_PME_ON_MAGIC_PKT | \ + WOL_CTL_DIS_LINK_CHG_UNIT | \ + WOL_CTL_DIS_PATTERN_UNIT | \ + WOL_CTL_DIS_MAGIC_PKT_UNIT) + +/* WOL_MATCH_CTL 8 bit WOL Match Control Reg */ +#define WOL_CTL_PATT_ENA(x) (1 << (x)) + + +/* Control flags */ +enum { + UDPTCP = 1<<0, + CALSUM = 1<<1, + WR_SUM = 1<<2, + INIT_SUM= 1<<3, + LOCK_SUM= 1<<4, + INS_VLAN= 1<<5, + FRC_STAT= 1<<6, + EOP = 1<<7, +}; + +enum { + HW_OWNER = 1<<7, + OP_TCPWRITE = 0x11, + OP_TCPSTART = 0x12, + OP_TCPINIT = 0x14, + OP_TCPLCK = 0x18, + OP_TCPCHKSUM = OP_TCPSTART, + OP_TCPIS = OP_TCPINIT | OP_TCPSTART, + OP_TCPLW = OP_TCPLCK | OP_TCPWRITE, + OP_TCPLSW = OP_TCPLCK | OP_TCPSTART | OP_TCPWRITE, + OP_TCPLISW = OP_TCPLCK | OP_TCPINIT | OP_TCPSTART | OP_TCPWRITE, + + OP_ADDR64 = 0x21, + OP_VLAN = 0x22, + OP_ADDR64VLAN = OP_ADDR64 | OP_VLAN, + OP_LRGLEN = 0x24, + OP_LRGLENVLAN = OP_LRGLEN | OP_VLAN, + OP_BUFFER = 0x40, + OP_PACKET = 0x41, + OP_LARGESEND = 0x43, + +/* YUKON-2 STATUS opcodes defines */ + OP_RXSTAT = 0x60, + OP_RXTIMESTAMP = 0x61, + OP_RXVLAN = 0x62, + OP_RXCHKS = 0x64, + OP_RXCHKSVLAN = OP_RXCHKS | OP_RXVLAN, + OP_RXTIMEVLAN = OP_RXTIMESTAMP | OP_RXVLAN, + OP_RSS_HASH = 0x65, + OP_TXINDEXLE = 0x68, + +/* YUKON-2 SPECIAL opcodes defines */ + OP_PUTIDX = 0x70, +}; + +/* Yukon 2 hardware interface + * Not tested on big endian + */ +struct sky2_tx_le { + union { + u32 addr; + struct { + u16 offset; + u16 start; + } csum; + struct { + u16 size; + u16 rsvd; + } tso; + } tx; + u16 length; /* also vlan tag or checksum start */ + u8 ctrl; + u8 opcode; +}; + +struct sky2_rx_le { + union { + u32 addr; + struct { + u16 start1; + u16 start2; + } csum; + } rx; + u16 length; + u8 ctrl; + u8 opcode; +}; + +struct sky2_status_le { + u32 status; /* also checksum */ + u16 length; /* also vlan tag */ + u8 link; + u8 opcode; +}; + + +struct ring_info { + struct sk_buff *skb; + DECLARE_PCI_UNMAP_ADDR(mapaddr); + DECLARE_PCI_UNMAP_LEN(maplen); +}; + +struct sky2_port { + struct sky2_hw *hw ____cacheline_aligned; + struct net_device *netdev; + unsigned port; + u32 msg_enable; + + struct ring_info *tx_ring ____cacheline_aligned; + struct sky2_tx_le *tx_le; + spinlock_t tx_lock; + u16 tx_cons; /* next le to check */ + u16 tx_prod; /* next le to use */ + u16 tx_last_put; + + struct ring_info *rx_ring ____cacheline_aligned; + struct sky2_rx_le *rx_le; + u16 rx_ring_size; + u16 rx_next; /* next re to check */ + u16 rx_put; /* next le index to use */ + u16 rx_last_put; + + dma_addr_t rx_le_map; + dma_addr_t tx_le_map; + u32 advertising; /* ADVERTISED_ bits */ + u16 speed; /* SPEED_1000, SPEED_100, ... */ + u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */ + u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */ + u8 rx_pause; + u8 tx_pause; + u8 rx_csum; + u8 wol; + + struct tasklet_struct phy_task; + struct net_device_stats net_stats; +}; + +struct sky2_hw { + void __iomem *regs; + struct pci_dev *pdev; + u32 intr_mask; + struct net_device *dev[2]; + + u8 chip_id; + u8 chip_rev; + u8 copper; + u8 ports; + + struct sky2_status_le *st_le; + u32 st_idx; + dma_addr_t st_dma; + + spinlock_t phy_lock; +}; + +/* Register accessor for memory mapped device */ +static inline u32 sky2_read32(const struct sky2_hw *hw, unsigned reg) +{ + return readl(hw->regs + reg); +} + +static inline u16 sky2_read16(const struct sky2_hw *hw, unsigned reg) +{ + return readw(hw->regs + reg); +} + +static inline u8 sky2_read8(const struct sky2_hw *hw, unsigned reg) +{ + return readb(hw->regs + reg); +} + +static inline int is_pciex(const struct sky2_hw *hw) +{ + return (sky2_read32(hw, PCI_C(PCI_DEV_STATUS)) & PCI_OS_PCI_X) == 0; +} + + +static inline void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val) +{ + writel(val, hw->regs + reg); +} + +static inline void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val) +{ + writew(val, hw->regs + reg); +} + +static inline void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val) +{ + writeb(val, hw->regs + reg); +} + +/* Yukon PHY related registers */ +#define SK_GMAC_REG(port,reg) \ + (BASE_GMAC_1 + (port) * (BASE_GMAC_2-BASE_GMAC_1) + (reg)) +#define GM_PHY_RETRIES 100 + +static inline u16 gma_read16(const struct sky2_hw *hw, unsigned port, unsigned reg) +{ + return sky2_read16(hw, SK_GMAC_REG(port,reg)); +} + +static inline u32 gma_read32(struct sky2_hw *hw, unsigned port, unsigned reg) +{ + unsigned base = SK_GMAC_REG(port, reg); + return (u32) sky2_read16(hw, base) + | (u32) sky2_read16(hw, base+4) << 16; +} + +static inline void gma_write16(const struct sky2_hw *hw, unsigned port, int r, u16 v) +{ + sky2_write16(hw, SK_GMAC_REG(port,r), v); +} + +static inline void gma_set_addr(struct sky2_hw *hw, unsigned port, unsigned reg, + const u8 *addr) +{ + gma_write16(hw, port, reg, (u16) addr[0] | ((u16) addr[1] << 8)); + gma_write16(hw, port, reg+4,(u16) addr[2] | ((u16) addr[3] << 8)); + gma_write16(hw, port, reg+8,(u16) addr[4] | ((u16) addr[5] << 8)); +} +#endif -- cgit v1.1 From 793b883ed12a6ae6e2901ddb5e038b77d6f0c0ac Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 14 Sep 2005 16:06:14 -0700 Subject: [PATCH] sky2: driver update. Here is revised patch against netdev sky2 branch. It includes whitespace fixes, all the changes from the previous review as well as some optimizations and timing fixes to solve some of the hangs. The stall problem is better but not perfect. It appears that under stress the chip can't keep up with the bus and sends a pause frame, then hangs. This version is for testing, and hopefully other eyes might see the root cause of the problem. I don't want to reinvent the ugly watchdog code in the syskonnect version of sk98lin. If you read it you will see, the original driver writer and the hardware developer obviously didn't understand each other. Dual port support is included, but not tested yet. It did require small change to NAPI since both ports share same IRQ. Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 1311 ++++++++++++++++++++++++++------------------- drivers/net/sky2.h | 112 ++-- include/linux/netdevice.h | 8 +- 3 files changed, 809 insertions(+), 622 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index cfb2b41..bc95aac 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -15,7 +15,7 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License @@ -26,14 +26,17 @@ /* * TODO * - coalescing setting? - * - variable ring size? + * - vlan support * * TOTEST + * - variable ring size * - speed setting * - power management + * - netpoll */ #include +#include #include #include #include @@ -45,14 +48,13 @@ #include #include #include -#include #include #include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "0.2" +#define DRV_VERSION "0.4" #define PFX DRV_NAME " " /* @@ -70,13 +72,18 @@ #define is_ec_a1(hw) 0 #endif -#define RX_LE_SIZE 256 -#define MIN_RX_BUFFERS 8 -#define MAX_RX_BUFFERS 124 +#define RX_LE_SIZE 256 #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) +#define RX_MAX_PENDING (RX_LE_SIZE/2 - 1) +#define RX_DEF_PENDING 128 +#define RX_COPY_THRESHOLD 128 + +#define TX_RING_SIZE 512 +#define TX_DEF_PENDING (TX_RING_SIZE - 1) +#define TX_MIN_PENDING 64 +#define MAX_SKB_TX_LE (4 + 2*MAX_SKB_FRAGS) -#define TX_RING_SIZE 256 // min 64 max 4096 -#define STATUS_RING_SIZE 1024 // pow2 > (2*Rx + Tx) +#define STATUS_RING_SIZE 2048 /* 2 ports * (TX + 2*RX) */ #define STATUS_LE_BYTES (STATUS_RING_SIZE*sizeof(struct sky2_status_le)) #define ETH_JUMBO_MTU 9000 #define TX_WATCHDOG (5 * HZ) @@ -84,15 +91,16 @@ #define PHY_RETRIES 1000 static const u32 default_msg = - NETIF_MSG_DRV| NETIF_MSG_PROBE| NETIF_MSG_LINK - | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR - | NETIF_MSG_IFUP| NETIF_MSG_IFDOWN; + NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK + | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR + | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN | NETIF_MSG_INTR; -static int debug = -1; /* defaults above */ +static int debug = -1; /* defaults above */ module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); static const struct pci_device_id sky2_id_table[] = { + { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) }, @@ -111,34 +119,24 @@ static const struct pci_device_id sky2_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, { 0 } }; + MODULE_DEVICE_TABLE(pci, sky2_id_table); /* Avoid conditionals by using array */ static const unsigned txqaddr[] = { Q_XA1, Q_XA2 }; static const unsigned rxqaddr[] = { Q_R1, Q_R2 }; -static inline const char *chip_name(u8 chip_id) -{ - switch (chip_id) { - case CHIP_ID_GENESIS: - return "Genesis"; - case CHIP_ID_YUKON: - return "Yukon"; - case CHIP_ID_YUKON_LITE: - return "Yukon-Lite"; - case CHIP_ID_YUKON_LP: - return "Yukon-LP"; - case CHIP_ID_YUKON_XL: - return "Yukon-XL"; - case CHIP_ID_YUKON_EC: - return "Yukon-EC"; - case CHIP_ID_YUKON_FE: - return "Yukon-FE"; - default: - return "???"; - } -} +static const char *yukon_name[] = { + [CHIP_ID_YUKON_LITE - CHIP_ID_YUKON] = "Lite", /* 0xb0 */ + [CHIP_ID_YUKON_LP - CHIP_ID_YUKON] = "LP", /* 0xb2 */ + [CHIP_ID_YUKON_XL - CHIP_ID_YUKON] = "XL", /* 0xb3 */ + [CHIP_ID_YUKON_EC - CHIP_ID_YUKON] = "EC", /* 0xb6 */ + [CHIP_ID_YUKON_FE - CHIP_ID_YUKON] = "FE", /* 0xb7 */ +}; + + +/* Access to external PHY */ static void gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) { int i; @@ -148,30 +146,28 @@ static void gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg)); for (i = 0; i < PHY_RETRIES; i++) { - udelay(1); - if (!(gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY)) - break; + return; + udelay(1); } + printk(KERN_WARNING PFX "%s: phy write timeout\n", hw->dev[port]->name); } static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) { int i; - gma_write16(hw, port, GM_SMI_CTRL, - GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) + gma_write16(hw, port, GM_SMI_CTRL, GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD); for (i = 0; i < PHY_RETRIES; i++) { - udelay(1); if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) goto ready; + udelay(1); } - printk(KERN_WARNING PFX "%s: phy read timeout\n", - hw->dev[port]->name); - ready: + printk(KERN_WARNING PFX "%s: phy read timeout\n", hw->dev[port]->name); +ready: return gma_read16(hw, port, GM_SMI_DATA); } @@ -183,6 +179,7 @@ static void sky2_phy_reset(struct sky2_hw *hw, unsigned port) sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), 0); /* disable PHY IRQs */ gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0); + gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */ gma_write16(hw, port, GM_MC_ADDR_H2, 0); gma_write16(hw, port, GM_MC_ADDR_H3, 0); @@ -196,21 +193,13 @@ static void sky2_phy_reset(struct sky2_hw *hw, unsigned port) static void sky2_phy_init(struct sky2_hw *hw, unsigned port) { struct sky2_port *sky2 = netdev_priv(hw->dev[port]); - u16 ctrl, ct1000, adv; - u16 ledctrl, ledover; - - pr_debug("phy reset autoneg=%s advertising=0x%x pause rx=%s tx=%s\n", - sky2->autoneg == AUTONEG_ENABLE ? "enable" : "disable", - sky2->advertising, - sky2->rx_pause ? "on" : "off", - sky2->tx_pause ? "on" : "off"); + u16 ctrl, ct1000, adv, pg, ledctrl, ledover; - if (sky2->autoneg == AUTONEG_ENABLE && - hw->chip_id != CHIP_ID_YUKON_XL) { + if (sky2->autoneg == AUTONEG_ENABLE && hw->chip_id != CHIP_ID_YUKON_XL) { u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL); ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK | - PHY_M_EC_MAC_S_MSK); + PHY_M_EC_MAC_S_MSK); ectrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ); if (hw->chip_id == CHIP_ID_YUKON_EC) @@ -258,9 +247,6 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) /* select page 1 to access Fiber registers */ gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 1); } - - ctrl &= ~(PHY_M_PC_MDIX_MSK | PHY_M_MAC_MD_MSK); - ctrl |= PHY_M_MAC_MODE_SEL(PHY_M_MAC_MD_1000BX); } ctrl = gm_phy_read(hw, port, PHY_MARV_CTRL); @@ -290,14 +276,14 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) adv |= PHY_M_AN_10_FD; if (sky2->advertising & ADVERTISED_10baseT_Half) adv |= PHY_M_AN_10_HD; - } else /* special defines for FIBER (88E1011S only) */ + } else /* special defines for FIBER (88E1011S only) */ adv |= PHY_M_AN_1000X_AHD | PHY_M_AN_1000X_AFD; /* Set Flow-control capabilities */ if (sky2->tx_pause && sky2->rx_pause) - adv |= PHY_AN_PAUSE_CAP; /* symmetric */ + adv |= PHY_AN_PAUSE_CAP; /* symmetric */ else if (sky2->rx_pause && !sky2->tx_pause) - adv |= PHY_AN_PAUSE_ASYM|PHY_AN_PAUSE_CAP; + adv |= PHY_AN_PAUSE_ASYM | PHY_AN_PAUSE_CAP; else if (!sky2->rx_pause && sky2->tx_pause) adv |= PHY_AN_PAUSE_ASYM; /* local */ @@ -347,26 +333,28 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) break; case CHIP_ID_YUKON_XL: - ctrl = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); + pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); /* select page 3 to access LED control register */ gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); /* set LED Function Control register */ - gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, - (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ - PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */ - PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ - PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */ + gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ + PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */ + PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */ + PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */ /* set Polarity Control register */ gm_phy_write(hw, port, PHY_MARV_PHY_STAT, - (PHY_M_POLC_LS1_P_MIX(4) | PHY_M_POLC_IS0_P_MIX(4) | - PHY_M_POLC_LOS_CTRL(2) | PHY_M_POLC_INIT_CTRL(2) | - PHY_M_POLC_STA1_CTRL(2) | PHY_M_POLC_STA0_CTRL(2))); + (PHY_M_POLC_LS1_P_MIX(4) | + PHY_M_POLC_IS0_P_MIX(4) | + PHY_M_POLC_LOS_CTRL(2) | + PHY_M_POLC_INIT_CTRL(2) | + PHY_M_POLC_STA1_CTRL(2) | + PHY_M_POLC_STA0_CTRL(2))); /* restore page register */ - gm_phy_write(hw, port, PHY_MARV_EXT_ADR, ctrl); + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); break; default: @@ -405,8 +393,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR); - if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 - && port == 1) { + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 && port == 1) { /* WA DEV_472 -- looks like crossed wires on port 2 */ /* clear GMAC 1 Control reset */ sky2_write8(hw, SK_REG(0, GMAC_CTRL), GMC_RST_CLR); @@ -418,14 +405,12 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) gm_phy_read(hw, 1, PHY_MARV_INT_MASK) != 0); } - if (sky2->autoneg == AUTONEG_DISABLE) { reg = gma_read16(hw, port, GM_GP_CTRL); reg |= GM_GPCR_AU_ALL_DIS; gma_write16(hw, port, GM_GP_CTRL, reg); gma_read16(hw, port, GM_GP_CTRL); - switch (sky2->speed) { case SPEED_1000: reg |= GM_GPCR_SPEED_1000; @@ -441,15 +426,16 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) if (!sky2->tx_pause && !sky2->rx_pause) { sky2_write32(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); - reg |= GM_GPCR_FC_TX_DIS | GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; - } else if (sky2->tx_pause &&!sky2->rx_pause) { + reg |= + GM_GPCR_FC_TX_DIS | GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; + } else if (sky2->tx_pause && !sky2->rx_pause) { /* disable Rx flow-control */ reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS; } gma_write16(hw, port, GM_GP_CTRL, reg); - sky2_read16(hw, GMAC_IRQ_SRC); + sky2_read16(hw, SK_REG(port, GMAC_IRQ_SRC)); spin_lock_bh(&hw->phy_lock); sky2_phy_init(hw, port); @@ -460,7 +446,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) gma_write16(hw, port, GM_PHY_ADDR, reg | GM_PAR_MIB_CLR); for (i = 0; i < GM_MIB_CNT_SIZE; i++) - gma_read16(hw, port, GM_MIB_CNT_BASE + 8*i); + gma_read16(hw, port, GM_MIB_CNT_BASE + 8 * i); gma_write16(hw, port, GM_PHY_ADDR, reg); /* transmit control */ @@ -468,7 +454,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) /* receive control reg: unicast + multicast + no FCS */ gma_write16(hw, port, GM_RX_CTRL, - GM_RXCR_UCF_ENA | GM_RXCR_CRC_DIS | GM_RXCR_MCF_ENA); + GM_RXCR_UCF_ENA | GM_RXCR_CRC_DIS | GM_RXCR_MCF_ENA); /* transmit flow control */ gma_write16(hw, port, GM_TX_FLOW_CTRL, 0xffff); @@ -482,44 +468,43 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) /* serial mode register */ reg = DATA_BLIND_VAL(DATA_BLIND_DEF) | - GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); + GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); if (hw->dev[port]->mtu > 1500) reg |= GM_SMOD_JUMBO_ENA; gma_write16(hw, port, GM_SERIAL_MODE, reg); - /* physical address: used for pause frames */ - gma_set_addr(hw, port, GM_SRC_ADDR_1L, addr); /* virtual address for data */ gma_set_addr(hw, port, GM_SRC_ADDR_2L, addr); - /* enable interrupt mask for counter overflows */ + /* physical address: used for pause frames */ + gma_set_addr(hw, port, GM_SRC_ADDR_1L, addr); + + /* ignore counter overflows */ gma_write16(hw, port, GM_TX_IRQ_MSK, 0); gma_write16(hw, port, GM_RX_IRQ_MSK, 0); gma_write16(hw, port, GM_TR_IRQ_MSK, 0); /* Configure Rx MAC FIFO */ sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR); - sky2_write16(hw, SK_REG(port, RX_GMF_CTRL_T), + sky2_write16(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_OPER_ON | GMF_RX_F_FL_ON); - reg = RX_FF_FL_DEF_MSK; + /* Flush Rx MAC FIFO on any flowcontrol or error */ + reg = GMR_FS_ANY_ERR; if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev <= 1) reg = 0; /* WA Dev #4115 */ sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), reg); - /* Set threshold to 0xa (64 bytes) - * ASF disabled so no need to do WA dev #4.30 + /* Set threshold to 0xa (64 bytes) + * ASF disabled so no need to do WA dev #4.30 */ sky2_write16(hw, SK_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF); /* Configure Tx MAC FIFO */ sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR); sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON); - - /* Turn off Rx fifo flush (per sk98lin) */ - sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RX_F_FL_OFF); } static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) @@ -529,7 +514,8 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) start /= 8; len /= 8; end = start + len - 1; - pr_debug("ramset q=%d start=0x%x end=0x%x\n", q, start, end); + + pr_debug("sky2_ramset start=%d end=%d\n", start, end); sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); sky2_write32(hw, RB_ADDR(q, RB_START), start); @@ -538,11 +524,15 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) sky2_write32(hw, RB_ADDR(q, RB_RP), start); if (q == Q_R1 || q == Q_R2) { + u32 rxup, rxlo; + + rxlo = len/2; + rxup = rxlo + len/4; + pr_debug(" utpp=%d ltpp=%d\n", rxup, rxlo); + /* Set thresholds on receive queue's */ - sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), - start + (2*len)/3); - sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), - start + (len/3)); + sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), rxup); + sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), rxlo); } else { /* Enable store & forward on Tx queue's because * Tx FIFO is only 1K on Yukon @@ -551,9 +541,9 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) } sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_ENA_OP_MD); + sky2_read8(hw, RB_ADDR(q, RB_CTRL)); } - /* Setup Bus Memory Interface */ static void sky2_qset(struct sky2_hw *hw, u16 q, u32 wm) { @@ -563,61 +553,63 @@ static void sky2_qset(struct sky2_hw *hw, u16 q, u32 wm) sky2_write32(hw, Q_ADDR(q, Q_WM), wm); } - /* Setup prefetch unit registers. This is the interface between * hardware and driver list elements */ static inline void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr, u64 addr, u32 last) { - pr_debug("sky2 prefetch init q=%x addr=%llx last=%x\n", - Y2_QADDR(qaddr, 0), addr, last); - sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_RST_CLR); sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_ADDR_HI), addr >> 32); sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_ADDR_LO), (u32) addr); sky2_write16(hw, Y2_QADDR(qaddr, PREF_UNIT_LAST_IDX), last); sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_OP_ON); + + sky2_read32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL)); } +static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2) +{ + struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod; + + sky2->tx_prod = (sky2->tx_prod + 1) % TX_RING_SIZE; + return le; +} /* * This is a workaround code taken from syskonnect sk98lin driver - * to deal with chip bug in the wraparound case. + * to deal with chip bug on Yukon EC rev 0 in the wraparound case. */ static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx, u16 *last, u16 size) - { - BUG_ON(idx >= size); - - wmb(); if (is_ec_a1(hw) && idx < *last) { u16 hwget = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_GET_IDX)); if (hwget == 0) { /* Start prefetching again */ - sky2_write8(hw, Y2_QADDR(q, PREF_UNIT_FIFO_WM), - 0xe0); + sky2_write8(hw, Y2_QADDR(q, PREF_UNIT_FIFO_WM), 0xe0); goto setnew; } - if (hwget == size-1) { + if (hwget == size - 1) { /* set watermark to one list element */ sky2_write8(hw, Y2_QADDR(q, PREF_UNIT_FIFO_WM), 8); /* set put index to first list element */ sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), 0); - } else /* have hardware go to end of list */ - sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), size-1); + } else /* have hardware go to end of list */ + sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), + size - 1); } else { - setnew: +setnew: sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx); - *last = idx; } + *last = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX)); } + static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) { struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put; @@ -625,61 +617,74 @@ static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) return le; } -static inline void sky2_rx_add(struct sky2_port *sky2, dma_addr_t map, u16 len) +/* Build description to hardware about buffer */ +static inline void sky2_rx_add(struct sky2_port *sky2, struct ring_info *re) { struct sky2_rx_le *le; + u32 hi = (re->mapaddr >> 16) >> 16; - if (sizeof(map) > sizeof(u32)) { + re->idx = sky2->rx_put; + if (sky2->rx_addr64 != hi) { le = sky2_next_rx(sky2); - le->rx.addr = cpu_to_le32((u64) map >> 32); + le->addr = cpu_to_le32(hi); le->ctrl = 0; le->opcode = OP_ADDR64 | HW_OWNER; + sky2->rx_addr64 = hi; } - + le = sky2_next_rx(sky2); - le->rx.addr = cpu_to_le32((u32) map); - le->length = cpu_to_le16(len); + le->addr = cpu_to_le32((u32) re->mapaddr); + le->length = cpu_to_le16(re->maplen); le->ctrl = 0; le->opcode = OP_PACKET | HW_OWNER; } +/* Tell receiver about new buffers. */ +static inline void rx_set_put(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + if (sky2->rx_last_put != sky2->rx_put) + sky2_put_idx(sky2->hw, rxqaddr[sky2->port], sky2->rx_put, + &sky2->rx_last_put, RX_LE_SIZE); +} + /* Tell chip where to start receive checksum. * Actually has two checksums, but set both same to avoid possible byte * order problems. */ -static void sky2_rx_set_offset(struct sky2_port *sky2) +static void rx_set_checksum(struct sky2_port *sky2) { struct sky2_rx_le *le; - sky2_write32(sky2->hw, - Q_ADDR(rxqaddr[sky2->port], Q_CSR), - sky2->rx_csum ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); - le = sky2_next_rx(sky2); - le->rx.csum.start1 = ETH_HLEN; - le->rx.csum.start2 = ETH_HLEN; + le->addr = (ETH_HLEN << 16) | ETH_HLEN; le->ctrl = 0; le->opcode = OP_TCPSTART | HW_OWNER; - wmb(); - sky2_write16(sky2->hw, - Y2_QADDR(rxqaddr[sky2->port], PREF_UNIT_PUT_IDX), - sky2->rx_put); + + sky2_write16(sky2->hw, Y2_QADDR(rxqaddr[sky2->port], + PREF_UNIT_PUT_IDX), sky2->rx_put); + sky2_read16(sky2->hw, Y2_QADDR(rxqaddr[sky2->port], PREF_UNIT_PUT_IDX)); + mdelay(1); + sky2_write32(sky2->hw, + Q_ADDR(rxqaddr[sky2->port], Q_CSR), + sky2->rx_csum ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); } + /* Cleanout receive buffer area, assumes receiver hardware stopped */ static void sky2_rx_clean(struct sky2_port *sky2) { unsigned i; memset(sky2->rx_le, 0, RX_LE_BYTES); - for (i = 0; i < sky2->rx_ring_size; i++) { + for (i = 0; i < sky2->rx_pending; i++) { struct ring_info *re = sky2->rx_ring + i; if (re->skb) { - pci_unmap_single(sky2->hw->pdev, - pci_unmap_addr(re, mapaddr), - pci_unmap_len(re, maplen), + pci_unmap_single(sky2->hw->pdev, + re->mapaddr, re->maplen, PCI_DMA_FROMDEVICE); kfree_skb(re->skb); re->skb = NULL; @@ -687,12 +692,13 @@ static void sky2_rx_clean(struct sky2_port *sky2) } } -static inline struct sk_buff *sky2_rx_alloc_skb(struct sky2_port *sky2, - unsigned int size, int gfp_mask) +static inline struct sk_buff *sky2_rx_alloc(struct sky2_port *sky2, + unsigned int size, + unsigned int gfp_mask) { struct sk_buff *skb; - skb = alloc_skb(size, gfp_mask); + skb = alloc_skb(size + NET_IP_ALIGN, gfp_mask); if (likely(skb)) { skb->dev = sky2->netdev; skb_reserve(skb, NET_IP_ALIGN); @@ -709,29 +715,21 @@ static inline struct sk_buff *sky2_rx_alloc_skb(struct sky2_port *sky2, static int sky2_rx_fill(struct sky2_port *sky2) { unsigned i; - unsigned int rx_buf_size = sky2->netdev->mtu + ETH_HLEN + 8; + const unsigned rx_buf_size = sky2->netdev->mtu + ETH_HLEN + 8; - pr_debug("sky2_rx_fill %d\n", sky2->rx_ring_size); - for (i = 0; i < sky2->rx_ring_size; i++) { + for (i = 0; i < sky2->rx_pending; i++) { struct ring_info *re = sky2->rx_ring + i; - dma_addr_t paddr; - re->skb = sky2_rx_alloc_skb(sky2, rx_buf_size, GFP_KERNEL); + re->skb = sky2_rx_alloc(sky2, rx_buf_size, GFP_KERNEL); if (!re->skb) goto nomem; - paddr = pci_map_single(sky2->hw->pdev, re->skb->data, - rx_buf_size, PCI_DMA_FROMDEVICE); - - pci_unmap_len_set(re, maplen, rx_buf_size); - pci_unmap_addr_set(re, mapaddr, paddr); - sky2_rx_add(sky2, paddr, rx_buf_size); + re->mapaddr = pci_map_single(sky2->hw->pdev, re->skb->data, + rx_buf_size, PCI_DMA_FROMDEVICE); + re->maplen = rx_buf_size; + sky2_rx_add(sky2, re); } - sky2_write16(sky2->hw, - Y2_QADDR(rxqaddr[sky2->port], PREF_UNIT_PUT_IDX), - sky2->rx_put); - return 0; nomem: sky2_rx_clean(sky2); @@ -752,7 +750,8 @@ static int sky2_up(struct net_device *dev) /* must be power of 2 */ sky2->tx_le = pci_alloc_consistent(hw->pdev, - TX_RING_SIZE * sizeof(struct sky2_tx_le), + TX_RING_SIZE * + sizeof(struct sky2_tx_le), &sky2->tx_le_map); if (!sky2->tx_le) goto err_out; @@ -770,7 +769,7 @@ static int sky2_up(struct net_device *dev) goto err_out; memset(sky2->rx_le, 0, RX_LE_BYTES); - sky2->rx_ring = kmalloc(sky2->rx_ring_size * sizeof(struct ring_info), + sky2->rx_ring = kmalloc(sky2->rx_pending * sizeof(struct ring_info), GFP_KERNEL); if (!sky2->rx_ring) goto err_out; @@ -782,8 +781,8 @@ static int sky2_up(struct net_device *dev) (hw->chip_id == CHIP_ID_YUKON_EC && hw->chip_rev == 2)) ramsize = 4096; else { - u8 e0 = sky2_read8(hw, B2_E_0); - ramsize = (e0 == 0) ? (128*1024) : (e0 * 4096); + u8 e0 = sky2_read8(hw, B2_E_0); + ramsize = (e0 == 0) ? (128 * 1024) : (e0 * 4096); } /* 2/3 for Rx */ @@ -791,18 +790,29 @@ static int sky2_up(struct net_device *dev) sky2_ramset(hw, rxqaddr[port], 0, rxspace); sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace); + /* Make sure SyncQ is disabled */ + sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), + RB_RST_SET); + sky2_qset(hw, rxqaddr[port], is_pciex(hw) ? 0x80 : 0x600); sky2_qset(hw, txqaddr[port], 0x600); sky2->rx_put = sky2->rx_next = 0; - sky2_prefetch_init(hw, rxqaddr[port], sky2->rx_le_map, RX_LE_SIZE-1); + sky2_prefetch_init(hw, rxqaddr[port], sky2->rx_le_map, RX_LE_SIZE - 1); - sky2_rx_set_offset(sky2); + rx_set_checksum(sky2); err = sky2_rx_fill(sky2); if (err) goto err_out; + /* Give buffers to receiver */ + sky2_write16(sky2->hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_PUT_IDX), + sky2->rx_put); + sky2->rx_last_put = sky2_read16(sky2->hw, + Y2_QADDR(rxqaddr[port], + PREF_UNIT_PUT_IDX)); + sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, TX_RING_SIZE - 1); @@ -827,96 +837,117 @@ err_out: return err; } -/* - * Worst case number of list elements is 36 - * TSO + CHKSUM + ADDR64 + BUFFER + (ADDR+BUFFER)*MAXFRAGS - */ -#define MAX_SKB_TX_LE (4 + 2*MAX_SKB_FRAGS) +/* Modular subtraction in ring */ +static inline int tx_dist(unsigned tail, unsigned head) +{ + return (head >= tail ? head : head + TX_RING_SIZE) - tail; +} -static inline int sky2_xmit_avail(const struct sky2_port *sky2) +/* Number of list elements available for next tx */ +static inline int tx_avail(const struct sky2_port *sky2) { - return (sky2->tx_cons > sky2->tx_prod ? 0 : TX_RING_SIZE) - + sky2->tx_cons - sky2->tx_prod - 1; + return sky2->tx_pending - tx_dist(sky2->tx_cons, sky2->tx_prod); } -static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2) +/* Estimate of number of transmit list elements required */ +static inline unsigned tx_le_req(const struct sk_buff *skb) { - struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod; - sky2->tx_prod = (sky2->tx_prod + 1) % TX_RING_SIZE; - return le; + unsigned count; + + count = sizeof(dma_addr_t) / sizeof(u32); + count += skb_shinfo(skb)->nr_frags * count; + + if (skb_shinfo(skb)->tso_size) + ++count; + + if (skb->ip_summed) + ++count; + + return count; } -/* Put one frame in ring for transmit. */ +/* + * Put one packet in ring for transmit. + * A single packet can generate multiple list elements, and + * the number of ring elements will probably be less than the number + * of list elements used. + */ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) { struct sky2_port *sky2 = netdev_priv(dev); struct sky2_hw *hw = sky2->hw; struct sky2_tx_le *le; struct ring_info *re; + unsigned long flags; unsigned i, len; dma_addr_t mapping; u32 addr64; u16 mss; u8 ctrl; - skb = skb_padto(skb, ETH_ZLEN); - if (!skb) - return NETDEV_TX_OK; - - if (!spin_trylock(&sky2->tx_lock)) + local_irq_save(flags); + if (!spin_trylock(&sky2->tx_lock)) { + local_irq_restore(flags); return NETDEV_TX_LOCKED; + } - if (unlikely(sky2_xmit_avail(sky2) < MAX_SKB_TX_LE)) { + if (unlikely(tx_avail(sky2) < tx_le_req(skb))) { netif_stop_queue(dev); - spin_unlock(&sky2->tx_lock); + spin_unlock_irqrestore(&sky2->tx_lock, flags); printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", dev->name); return NETDEV_TX_BUSY; } - if (netif_msg_tx_queued(sky2)) + if (unlikely(netif_msg_tx_queued(sky2))) printk(KERN_DEBUG "%s: tx queued, slot %u, len %d\n", dev->name, sky2->tx_prod, skb->len); - len = skb_headlen(skb); mapping = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE); + addr64 = (mapping >> 16) >> 16; + + re = sky2->tx_ring + sky2->tx_prod; + + /* Send high bits if changed */ + if (addr64 != sky2->tx_addr64) { + le = get_tx_le(sky2); + le->tx.addr = cpu_to_le32(addr64); + le->ctrl = 0; + le->opcode = OP_ADDR64 | HW_OWNER; + sky2->tx_addr64 = addr64; + } /* Check for TCP Segmentation Offload */ mss = skb_shinfo(skb)->tso_size; - if (mss) { + if (mss != 0) { /* just drop the packet if non-linear expansion fails */ if (skb_header_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { - dev_kfree_skb(skb); - return NETDEV_TX_OK; + dev_kfree_skb_any(skb); + goto out_unlock; } mss += ((skb->h.th->doff - 5) * 4); /* TCP options */ mss += (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); mss += ETH_HLEN; + } + if (mss != sky2->tx_last_mss) { le = get_tx_le(sky2); le->tx.tso.size = cpu_to_le16(mss); - le->ctrl = 0; + le->tx.tso.rsvd = 0; le->opcode = OP_LRGLEN | HW_OWNER; - } - - /* Handle Hi DMA */ - if (sizeof(mapping) > sizeof(u32)) { - addr64 = (u64)mapping >> 32; - - le = get_tx_le(sky2); - le->tx.addr = cpu_to_le32(addr64); le->ctrl = 0; - le->opcode = OP_ADDR64 | HW_OWNER; + sky2->tx_last_mss = mss; } /* Handle TCP checksum offload */ ctrl = 0; if (skb->ip_summed == CHECKSUM_HW) { - ptrdiff_t hdr = skb->h.raw - skb->data; + u16 hdr = skb->h.raw - skb->data; + u16 offset = hdr + skb->csum; ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM; if (skb->nh.iph->protocol == IPPROTO_UDP) @@ -924,119 +955,112 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) le = get_tx_le(sky2); le->tx.csum.start = cpu_to_le16(hdr); - le->tx.csum.offset = cpu_to_le16(hdr + skb->csum); - le->length = 0; + le->tx.csum.offset = cpu_to_le16(offset); + le->length = 0; /* initial checksum value */ le->ctrl = 1; /* one packet */ - le->opcode = OP_TCPLISW|HW_OWNER; + le->opcode = OP_TCPLISW | HW_OWNER; } le = get_tx_le(sky2); le->tx.addr = cpu_to_le32((u32) mapping); le->length = cpu_to_le16(len); le->ctrl = ctrl; - le->opcode = (mss ? OP_LARGESEND : OP_PACKET) |HW_OWNER; + le->opcode = mss ? (OP_LARGESEND | HW_OWNER) : (OP_PACKET | HW_OWNER); - re = &sky2->tx_ring[le - sky2->tx_le]; + /* Record the transmit mapping info */ re->skb = skb; - pci_unmap_addr_set(re, mapaddr, mapping); - pci_unmap_len_set(re, maplen, len); + re->mapaddr = mapping; + re->maplen = len; for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; + struct ring_info *fre; mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset, frag->size, PCI_DMA_TODEVICE); - - if (sizeof(mapping) > sizeof(u32)) { - u32 hi = (u64) mapping >> 32; - if (hi != addr64) { - le = get_tx_le(sky2); - le->tx.addr = cpu_to_le32(hi); - le->ctrl = 0; - le->opcode = OP_ADDR64|HW_OWNER; - addr64 = hi; - } + addr64 = (mapping >> 16) >> 16; + if (addr64 != sky2->tx_addr64) { + le = get_tx_le(sky2); + le->tx.addr = cpu_to_le32(addr64); + le->ctrl = 0; + le->opcode = OP_ADDR64 | HW_OWNER; + sky2->tx_addr64 = addr64; } le = get_tx_le(sky2); le->tx.addr = cpu_to_le32((u32) mapping); le->length = cpu_to_le16(frag->size); le->ctrl = ctrl; - le->opcode = OP_BUFFER|HW_OWNER; + le->opcode = OP_BUFFER | HW_OWNER; - re = &sky2->tx_ring[le - sky2->tx_le]; - pci_unmap_addr_set(re, mapaddr, mapping); - pci_unmap_len_set(re, maplen, frag->size); + fre = sky2->tx_ring + + ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE; + fre->skb = NULL; + fre->mapaddr = mapping; + fre->maplen = frag->size; } - + re->idx = sky2->tx_prod; le->ctrl |= EOP; sky2_put_idx(sky2->hw, txqaddr[sky2->port], sky2->tx_prod, &sky2->tx_last_put, TX_RING_SIZE); - if (sky2_xmit_avail(sky2) < MAX_SKB_TX_LE) { - pr_debug("%s: transmit queue full\n", dev->name); + if (tx_avail(sky2) < MAX_SKB_TX_LE + 1) netif_stop_queue(dev); - } - spin_unlock(&sky2->tx_lock); + +out_unlock: + mmiowb(); + spin_unlock_irqrestore(&sky2->tx_lock, flags); dev->trans_start = jiffies; return NETDEV_TX_OK; } - /* - * Free ring elements from starting at tx_cons until done - * This unwinds the elements based on the usage assigned - * xmit routine. + * Free ring elements from starting at tx_cons until "done" + * + * NB: the hardware will tell us about partial completion of multi-part + * buffers; these are defered until completion. */ static void sky2_tx_complete(struct net_device *dev, u16 done) { struct sky2_port *sky2 = netdev_priv(dev); - unsigned idx = sky2->tx_cons; - struct sk_buff *skb = NULL; + unsigned i; - BUG_ON(done >= TX_RING_SIZE); + if (netif_msg_tx_done(sky2)) + printk(KERN_DEBUG "%s: tx done, upto %u\n", dev->name, done); spin_lock(&sky2->tx_lock); - while (idx != done) { - struct ring_info *re = sky2->tx_ring + idx; - struct sky2_tx_le *le = sky2->tx_le + idx; - - BUG_ON(le->opcode == 0); - - switch(le->opcode & ~HW_OWNER) { - case OP_LARGESEND: - case OP_PACKET: - if (skb) - dev_kfree_skb_any(skb); - skb = re->skb; - BUG_ON(!skb); - re->skb = NULL; - pci_unmap_single(sky2->hw->pdev, - pci_unmap_addr(re, mapaddr), - pci_unmap_len(re, maplen), - PCI_DMA_TODEVICE); - break; + while (sky2->tx_cons != done) { + struct ring_info *re = sky2->tx_ring + sky2->tx_cons; + struct sk_buff *skb; - case OP_BUFFER: - pci_unmap_page(sky2->hw->pdev, - pci_unmap_addr(re, mapaddr), - pci_unmap_len(re, maplen), - PCI_DMA_TODEVICE); - break; + /* Check for partial status */ + if (tx_dist(sky2->tx_cons, done) + < tx_dist(sky2->tx_cons, re->idx)) + goto out; + + skb = re->skb; + pci_unmap_single(sky2->hw->pdev, + re->mapaddr, re->maplen, PCI_DMA_TODEVICE); + + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + struct ring_info *fre; + fre = + sky2->tx_ring + (sky2->tx_cons + i + + 1) % TX_RING_SIZE; + pci_unmap_page(sky2->hw->pdev, fre->mapaddr, + fre->maplen, PCI_DMA_TODEVICE); } - le->opcode = 0; - idx = (idx + 1) % TX_RING_SIZE; - } - - if (skb) dev_kfree_skb_any(skb); - sky2->tx_cons = idx; - if (sky2_xmit_avail(sky2) > MAX_SKB_TX_LE) + sky2->tx_cons = re->idx; + } +out: + + if (netif_queue_stopped(dev) && tx_avail(sky2) > MAX_SKB_TX_LE) netif_wake_queue(dev); spin_unlock(&sky2->tx_lock); } @@ -1061,22 +1085,24 @@ static int sky2_down(struct net_device *dev) netif_stop_queue(dev); + sky2_phy_reset(hw, port); + /* Stop transmitter */ sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_STOP); sky2_read32(hw, Q_ADDR(txqaddr[port], Q_CSR)); sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), - RB_RST_SET|RB_DIS_OP_MD); + RB_RST_SET | RB_DIS_OP_MD); ctrl = gma_read16(hw, port, GM_GP_CTRL); - ctrl &= ~(GM_GPCR_TX_ENA|GM_GPCR_RX_ENA); + ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA); gma_write16(hw, port, GM_GP_CTRL, ctrl); sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); /* Workaround shared GMAC reset */ - if (! (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 - && port == 0 && hw->dev[1] && netif_running(hw->dev[1]))) + if (!(hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 + && port == 0 && hw->dev[1] && netif_running(hw->dev[1]))) sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_SET); /* Disable Force Sync bit and Enable Alloc bit */ @@ -1088,7 +1114,8 @@ static int sky2_down(struct net_device *dev) sky2_write32(hw, SK_REG(port, TXA_LIM_INI), 0L); /* Reset the PCI FIFO of the async Tx queue */ - sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_RST_SET | BMU_FIFO_RST); + sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), + BMU_RST_SET | BMU_FIFO_RST); /* Reset the Tx prefetch units */ sky2_write32(hw, Y2_QADDR(txqaddr[port], PREF_UNIT_CTRL), @@ -1144,6 +1171,9 @@ static int sky2_down(struct net_device *dev) static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux) { + if (!hw->copper) + return SPEED_1000; + if (hw->chip_id == CHIP_ID_YUKON_FE) return (aux & PHY_M_PS_SPEED_100) ? SPEED_100 : SPEED_10; @@ -1163,14 +1193,16 @@ static void sky2_link_up(struct sky2_port *sky2) unsigned port = sky2->port; u16 reg; + /* disable Rx GMAC FIFO flush mode */ + sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RX_F_FL_OFF); + /* Enable Transmit FIFO Underrun */ - sky2_write8(hw, GMAC_IRQ_MSK, GMAC_DEF_MSK); + sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), GMAC_DEF_MSK); reg = gma_read16(hw, port, GM_GP_CTRL); if (sky2->duplex == DUPLEX_FULL || sky2->autoneg == AUTONEG_ENABLE) reg |= GM_GPCR_DUP_FULL; - /* enable Rx/Tx */ reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA; gma_write16(hw, port, GM_GP_CTRL, reg); @@ -1182,17 +1214,30 @@ static void sky2_link_up(struct sky2_port *sky2) netif_wake_queue(sky2->netdev); /* Turn on link LED */ - sky2_write8(hw, SK_REG(port, LNK_LED_REG), + sky2_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF); + if (hw->chip_id == CHIP_ID_YUKON_XL) { + u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); + + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); + gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */ + PHY_M_LEDC_INIT_CTRL(sky2->speed == + SPEED_10 ? 7 : 0) | + PHY_M_LEDC_STA1_CTRL(sky2->speed == + SPEED_100 ? 7 : 0) | + PHY_M_LEDC_STA0_CTRL(sky2->speed == + SPEED_1000 ? 7 : 0)); + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); + } + if (netif_msg_link(sky2)) printk(KERN_INFO PFX "%s: Link is up at %d Mbps, %s duplex, flowcontrol %s\n", sky2->netdev->name, sky2->speed, sky2->duplex == DUPLEX_FULL ? "full" : "half", (sky2->tx_pause && sky2->rx_pause) ? "both" : - sky2->tx_pause ? "tx" : - sky2->rx_pause ? "rx" : "none"); + sky2->tx_pause ? "tx" : sky2->rx_pause ? "rx" : "none"); } static void sky2_link_down(struct sky2_port *sky2) @@ -1211,9 +1256,8 @@ static void sky2_link_down(struct sky2_port *sky2) if (sky2->rx_pause && !sky2->tx_pause) { /* restore Asymmetric Pause bit */ gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, - gm_phy_read(hw, port, - PHY_MARV_AUNE_ADV) - | PHY_M_AN_ASP); + gm_phy_read(hw, port, PHY_MARV_AUNE_ADV) + | PHY_M_AN_ASP); } sky2_phy_reset(hw, port); @@ -1229,6 +1273,51 @@ static void sky2_link_down(struct sky2_port *sky2) sky2_phy_init(hw, port); } +static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux) +{ + struct sky2_hw *hw = sky2->hw; + unsigned port = sky2->port; + u16 lpa; + + lpa = gm_phy_read(hw, port, PHY_MARV_AUNE_LP); + + if (lpa & PHY_M_AN_RF) { + printk(KERN_ERR PFX "%s: remote fault", sky2->netdev->name); + return -1; + } + + if (hw->chip_id != CHIP_ID_YUKON_FE && + gm_phy_read(hw, port, PHY_MARV_1000T_STAT) & PHY_B_1000S_MSF) { + printk(KERN_ERR PFX "%s: master/slave fault", + sky2->netdev->name); + return -1; + } + + if (!(aux & PHY_M_PS_SPDUP_RES)) { + printk(KERN_ERR PFX "%s: speed/duplex mismatch", + sky2->netdev->name); + return -1; + } + + sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF; + + sky2->speed = sky2_phy_speed(hw, aux); + + /* Pause bits are offset (9..8) */ + if (hw->chip_id == CHIP_ID_YUKON_XL) + aux >>= 6; + + sky2->rx_pause = (aux & PHY_M_PS_RX_P_EN) != 0; + sky2->tx_pause = (aux & PHY_M_PS_TX_P_EN) != 0; + + if ((sky2->tx_pause || sky2->rx_pause) + && !(sky2->speed < SPEED_1000 && sky2->duplex == DUPLEX_HALF)) + sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON); + else + sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); + + return 0; +} /* * Interrrupt from PHY are handled in tasklet (soft irq) @@ -1237,69 +1326,42 @@ static void sky2_link_down(struct sky2_port *sky2) */ static void sky2_phy_task(unsigned long data) { - struct sky2_port *sky2 = (struct sky2_port *) data; + struct sky2_port *sky2 = (struct sky2_port *)data; struct sky2_hw *hw = sky2->hw; - unsigned port = sky2->port; u16 istatus, phystat; - istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT); - - phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT); + spin_lock(&hw->phy_lock); + istatus = gm_phy_read(hw, sky2->port, PHY_MARV_INT_STAT); + phystat = gm_phy_read(hw, sky2->port, PHY_MARV_PHY_STAT); if (netif_msg_intr(sky2)) printk(KERN_INFO PFX "%s: phy interrupt status 0x%x 0x%x\n", sky2->netdev->name, istatus, phystat); if (istatus & PHY_M_IS_AN_COMPL) { - u16 lpa = gm_phy_read(hw, port, PHY_MARV_AUNE_LP); + if (sky2_autoneg_done(sky2, phystat) == 0) + sky2_link_up(sky2); + goto out; + } - if (lpa & PHY_M_AN_RF) { - printk(KERN_ERR PFX "%s: remote fault", - sky2->netdev->name); - } - else if (hw->chip_id != CHIP_ID_YUKON_FE - && gm_phy_read(hw, port, PHY_MARV_1000T_STAT) - & PHY_B_1000S_MSF) { - printk(KERN_ERR PFX "%s: master/slave fault", - sky2->netdev->name); - } - else if (!(phystat & PHY_M_PS_SPDUP_RES)) { - printk(KERN_ERR PFX "%s: speed/duplex mismatch", - sky2->netdev->name); - } - else { - sky2->duplex = (phystat & PHY_M_PS_FULL_DUP) - ? DUPLEX_FULL : DUPLEX_HALF; + if (istatus & PHY_M_IS_LSP_CHANGE) + sky2->speed = sky2_phy_speed(hw, phystat); - sky2->speed = sky2_phy_speed(hw, phystat); - - sky2->tx_pause = (phystat & PHY_M_PS_TX_P_EN) != 0; - sky2->rx_pause = (phystat & PHY_M_PS_RX_P_EN) != 0; + if (istatus & PHY_M_IS_DUP_CHANGE) + sky2->duplex = + (phystat & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF; - if ((!sky2->tx_pause && !sky2->rx_pause) || - (sky2->speed < SPEED_1000 && sky2->duplex == DUPLEX_HALF)) - sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); - else - sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON); + if (istatus & PHY_M_IS_LST_CHANGE) { + if (phystat & PHY_M_PS_LINK_UP) sky2_link_up(sky2); - } - } else { - - if (istatus & PHY_M_IS_LSP_CHANGE) - sky2->speed = sky2_phy_speed(hw, phystat); - - if (istatus & PHY_M_IS_DUP_CHANGE) - sky2->duplex = (phystat & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF; - if (istatus & PHY_M_IS_LST_CHANGE) { - if (phystat & PHY_M_PS_LINK_UP) - sky2_link_up(sky2); - else - sky2_link_down(sky2); - } + else + sky2_link_down(sky2); } +out: + spin_unlock(&hw->phy_lock); local_irq_disable(); - hw->intr_mask |= (port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2; + hw->intr_mask |= (sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2; sky2_write32(hw, B0_IMSK, hw->intr_mask); local_irq_enable(); } @@ -1346,63 +1408,78 @@ static struct sk_buff *sky2_receive(struct sky2_hw *hw, unsigned port, struct net_device *dev = hw->dev[port]; struct sky2_port *sky2 = netdev_priv(dev); struct ring_info *re = sky2->rx_ring + sky2->rx_next; - struct sk_buff *skb = re->skb; - dma_addr_t mapping; + struct sk_buff *skb, *nskb; const unsigned int rx_buf_size = dev->mtu + ETH_HLEN + 8; if (unlikely(netif_msg_rx_status(sky2))) printk(KERN_DEBUG PFX "%s: rx slot %u status 0x%x len %d\n", dev->name, sky2->rx_next, status, length); - sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_ring_size; - - pci_unmap_single(sky2->hw->pdev, - pci_unmap_addr(re, mapaddr), - pci_unmap_len(re, maplen), - PCI_DMA_FROMDEVICE); - prefetch(skb->data); + sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending; - if (!(status & GMR_FS_RX_OK) - || (status & GMR_FS_ANY_ERR) - || (length << 16) != (status & GMR_FS_LEN) - || length > rx_buf_size) + skb = NULL; + if (!(status & GMR_FS_RX_OK) + || (status & GMR_FS_ANY_ERR) + || (length << 16) != (status & GMR_FS_LEN) + || length > rx_buf_size) goto error; - re->skb = sky2_rx_alloc_skb(sky2, rx_buf_size, GFP_ATOMIC); - if (!re->skb) - goto reuse; - -submit: - mapping = pci_map_single(sky2->hw->pdev, re->skb->data, - rx_buf_size, PCI_DMA_FROMDEVICE); + if (length < RX_COPY_THRESHOLD) { + nskb = sky2_rx_alloc(sky2, length, GFP_ATOMIC); + if (!nskb) + goto resubmit; + + pci_dma_sync_single_for_cpu(sky2->hw->pdev, re->mapaddr, + length, PCI_DMA_FROMDEVICE); + memcpy(nskb->data, re->skb->data, length); + pci_dma_sync_single_for_device(sky2->hw->pdev, re->mapaddr, + length, PCI_DMA_FROMDEVICE); + skb = nskb; + } else { + nskb = sky2_rx_alloc(sky2, rx_buf_size, GFP_ATOMIC); + if (!nskb) + goto resubmit; - pci_unmap_len_set(re, maplen, rx_buf_size); - pci_unmap_addr_set(re, mapaddr, mapping); + skb = re->skb; + pci_unmap_single(sky2->hw->pdev, re->mapaddr, + re->maplen, PCI_DMA_FROMDEVICE); + prefetch(skb->data); - sky2_rx_add(sky2, mapping, rx_buf_size); - sky2_put_idx(sky2->hw, rxqaddr[sky2->port], - sky2->rx_put, &sky2->rx_last_put, RX_LE_SIZE); + re->skb = nskb; + re->mapaddr = pci_map_single(sky2->hw->pdev, nskb->data, + rx_buf_size, PCI_DMA_FROMDEVICE); + re->maplen = rx_buf_size; + } +resubmit: + BUG_ON(re->skb == skb); + sky2_rx_add(sky2, re); return skb; error: + if (status & GMR_FS_GOOD_FC) + goto resubmit; + if (netif_msg_rx_err(sky2)) printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n", sky2->netdev->name, status, length); - - if (status & (GMR_FS_LONG_ERR|GMR_FS_UN_SIZE)) + + if (status & (GMR_FS_LONG_ERR | GMR_FS_UN_SIZE)) sky2->net_stats.rx_length_errors++; if (status & GMR_FS_FRAGMENT) sky2->net_stats.rx_frame_errors++; if (status & GMR_FS_CRC_ERR) sky2->net_stats.rx_crc_errors++; -reuse: - re->skb = skb; - skb = NULL; - goto submit; + if (status & GMR_FS_RX_FF_OV) + sky2->net_stats.rx_fifo_errors++; + goto resubmit; } -static u16 get_tx_index(u8 port, u32 status, u16 len) +/* Transmit ring index in reported status block is encoded as: + * + * | TXS2 | TXA2 | TXS1 | TXA1 + */ +static inline u16 tx_index(u8 port, u32 status, u16 len) { if (port == 0) return status & 0xfff; @@ -1411,10 +1488,8 @@ static u16 get_tx_index(u8 port, u32 status, u16 len) } /* - * NAPI poll routine. * Both ports share the same status interrupt, therefore there is only * one poll routine. - * */ static int sky2_poll(struct net_device *dev, int *budget) { @@ -1422,31 +1497,27 @@ static int sky2_poll(struct net_device *dev, int *budget) struct sky2_hw *hw = sky2->hw; unsigned int to_do = min(dev->quota, *budget); unsigned int work_done = 0; + u16 hwidx; unsigned char summed[2] = { CHECKSUM_NONE, CHECKSUM_NONE }; - unsigned int csum[2] = { 0 }; - unsigned int rx_handled[2] = { 0, 0}; - u16 last; - - sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); - last = sky2_read16(hw, STAT_PUT_IDX); + unsigned int csum[2]; - while (hw->st_idx != last && work_done < to_do) { + hwidx = sky2_read16(hw, STAT_PUT_IDX); + rmb(); + while (hw->st_idx != hwidx && work_done < to_do) { struct sky2_status_le *le = hw->st_le + hw->st_idx; struct sk_buff *skb; u8 port; u32 status; u16 length; - rmb(); status = le32_to_cpu(le->status); length = le16_to_cpu(le->length); port = le->link; - BUG_ON(port >= hw->ports); + BUG_ON(port >= hw->ports || hw->dev[port] == NULL); - switch(le->opcode & ~HW_OWNER) { + switch (le->opcode & ~HW_OWNER) { case OP_RXSTAT: - ++rx_handled[port]; skb = sky2_receive(hw, port, length, status); if (likely(skb)) { __skb_put(skb, length); @@ -1475,7 +1546,7 @@ static int sky2_poll(struct net_device *dev, int *budget) case OP_TXINDEXLE: sky2_tx_complete(hw->dev[port], - get_tx_index(port, status, length)); + tx_index(port, status, length)); break; case OP_RXTIMESTAMP: @@ -1483,14 +1554,27 @@ static int sky2_poll(struct net_device *dev, int *budget) default: if (net_ratelimit()) - printk(KERN_WARNING PFX "unknown status opcode 0x%x\n", + printk(KERN_WARNING PFX + "unknown status opcode 0x%x\n", le->opcode); break; } - hw->st_idx = (hw->st_idx + 1) & (STATUS_RING_SIZE -1); + hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; + if (hw->st_idx == hwidx) { + hwidx = sky2_read16(hw, STAT_PUT_IDX); + rmb(); + } } + mmiowb(); + + if (hw->dev[0]) + rx_set_put(hw->dev[0]); + + if (hw->dev[1]) + rx_set_put(hw->dev[1]); + *budget -= work_done; dev->quota -= work_done; if (work_done < to_do) { @@ -1505,6 +1589,7 @@ static int sky2_poll(struct net_device *dev, int *budget) hw->intr_mask |= Y2_IS_STAT_BMU; sky2_write32(hw, B0_IMSK, hw->intr_mask); + sky2_read32(hw, B0_IMSK); netif_rx_complete(dev); } @@ -1553,40 +1638,35 @@ static void sky2_hw_intr(struct sky2_hw *hw) { u32 status = sky2_read32(hw, B0_HWE_ISRC); - if (status & Y2_IS_TIST_OV) { - pr_debug (PFX "%s: unused timer overflow??\n", - pci_name(hw->pdev)); + if (status & Y2_IS_TIST_OV) sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ); - } if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) { - u16 pci_err = sky2_read16(hw, PCI_C(PCI_STATUS)); + u16 pci_err; + + pci_read_config_word(hw->pdev, PCI_STATUS, &pci_err); printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n", pci_name(hw->pdev), pci_err); sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); - sky2_write16(hw, PCI_C(PCI_STATUS), - pci_err | PCI_STATUS_ERROR_BITS); + pci_write_config_word(hw->pdev, PCI_STATUS, + pci_err | PCI_STATUS_ERROR_BITS); sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); } if (status & Y2_IS_PCI_EXP) { /* PCI-Express uncorrectable Error occured */ - u32 pex_err = sky2_read32(hw, PCI_C(PEX_UNC_ERR_STAT)); + u32 pex_err; + + pci_read_config_dword(hw->pdev, PEX_UNC_ERR_STAT, &pex_err); - /* - * On PCI-Express bus bridges are called root complexes. - * PCI-Express errors are recognized by the root complex too, - * which requests the system to handle the problem. After error - * occurence it may be that no access to the adapter may be performed - * any longer. - */ printk(KERN_ERR PFX "%s: pci express error (0x%x)\n", pci_name(hw->pdev), pex_err); /* clear the interrupt */ sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); - sky2_write32(hw, PCI_C(PEX_UNC_ERR_STAT), 0xffffffffUL); + pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT, + 0xffffffffUL); sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); if (pex_err & PEX_FATAL_ERRORS) { @@ -1622,7 +1702,6 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port) ++sky2->net_stats.tx_fifo_errors; sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_FU); } - } static void sky2_phy_intr(struct sky2_hw *hw, unsigned port) @@ -1641,19 +1720,22 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs) u32 status; status = sky2_read32(hw, B0_Y2_SP_ISRC2); - if (status == 0 || status == ~0) /* hotplug or shared irq */ + if (status == 0 || status == ~0) return IRQ_NONE; if (status & Y2_IS_HW_ERR) sky2_hw_intr(hw); - if ((status & Y2_IS_STAT_BMU) && netif_rx_schedule_prep(hw->dev[0])) { + /* Do NAPI for Rx and Tx status */ + if ((status & Y2_IS_STAT_BMU) && netif_rx_schedule_test(hw->dev[0])) { + sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); + hw->intr_mask &= ~Y2_IS_STAT_BMU; sky2_write32(hw, B0_IMSK, hw->intr_mask); __netif_rx_schedule(hw->dev[0]); } - if (status & Y2_IS_IRQ_PHY1) + if (status & Y2_IS_IRQ_PHY1) sky2_phy_intr(hw, 0); if (status & Y2_IS_IRQ_PHY2) @@ -1665,8 +1747,10 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs) if (status & Y2_IS_IRQ_MAC2) sky2_mac_intr(hw, 1); - sky2_write32(hw, B0_Y2_SP_ICR, 2); + + sky2_read32(hw, B0_IMSK); + return IRQ_HANDLED; } @@ -1675,21 +1759,19 @@ static void sky2_netpoll(struct net_device *dev) { struct sky2_port *sky2 = netdev_priv(dev); - disable_irq(dev->irq); - sky2_intr(dev->irq, sky2->hw, NULL); - enable_irq(dev->irq); + sky2_intr(sky2->hw->pdev->irq, sky2->hw, NULL); } #endif /* Chip internal frequency for clock calculations */ static inline u32 sky2_khz(const struct sky2_hw *hw) { - switch(hw->chip_id) { + switch (hw->chip_id) { case CHIP_ID_YUKON_EC: return 125000; /* 125 Mhz */ case CHIP_ID_YUKON_FE: return 100000; /* 100 Mhz */ - default: /* YUKON_XL */ + default: /* YUKON_XL */ return 156000; /* 156 Mhz */ } } @@ -1701,7 +1783,7 @@ static inline u32 sky2_ms2clk(const struct sky2_hw *hw, u32 ms) static inline u32 sky2_us2clk(const struct sky2_hw *hw, u32 us) { - return (sky2_khz(hw) * 75) / 1000; + return (sky2_khz(hw) * us) / 1000; } static int sky2_reset(struct sky2_hw *hw) @@ -1721,6 +1803,12 @@ static int sky2_reset(struct sky2_hw *hw) return -EOPNOTSUPP; } + /* ring for status responses */ + hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES, + &hw->st_dma); + if (!hw->st_le) + return -ENOMEM; + /* disable ASF */ if (hw->chip_id <= CHIP_ID_YUKON_EC) { sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); @@ -1732,17 +1820,19 @@ static int sky2_reset(struct sky2_hw *hw) sky2_write8(hw, B0_CTST, CS_RST_CLR); /* clear PCI errors, if any */ - status = sky2_read16(hw, PCI_C(PCI_STATUS)); + pci_read_config_word(hw->pdev, PCI_STATUS, &status); sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); - sky2_write16(hw, PCI_C(PCI_STATUS), - status | PCI_STATUS_ERROR_BITS); + pci_write_config_word(hw->pdev, PCI_STATUS, + status | PCI_STATUS_ERROR_BITS); sky2_write8(hw, B0_CTST, CS_MRST_CLR); /* clear any PEX errors */ if (is_pciex(hw)) { - sky2_write32(hw, PCI_C(PEX_UNC_ERR_STAT), 0xffffffffUL); - sky2_read16(hw, PCI_C(PEX_LNK_STAT)); + u16 lstat; + pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT, + 0xffffffffUL); + pci_read_config_word(hw->pdev, PEX_LNK_STAT, &lstat); } pmd_type = sky2_read8(hw, B2_PMD_TYP); @@ -1769,20 +1859,20 @@ static int sky2_reset(struct sky2_hw *hw) Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS | Y2_CLK_GAT_LNK1_DIS | Y2_PCI_CLK_LNK2_DIS | Y2_COR_CLK_LNK2_DIS | Y2_CLK_GAT_LNK2_DIS); - else - sky2_write8(hw, B2_Y2_CLK_GATE, 0); + else + sky2_write8(hw, B2_Y2_CLK_GATE, 0); /* Turn off phy power saving */ - power = sky2_read32(hw, PCI_C(PCI_DEV_REG1)); - power &= ~(PCI_Y2_PHY1_POWD|PCI_Y2_PHY2_POWD); + pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &power); + power &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); - /* back asswards .. */ + /* looks like this xl is back asswards .. */ if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) { power |= PCI_Y2_PHY1_COMA; if (hw->ports > 1) power |= PCI_Y2_PHY2_COMA; } - sky2_write32(hw, PCI_C(PCI_DEV_REG1), power); + pci_write_config_dword(hw->pdev, PCI_DEV_REG1, power); for (i = 0; i < hw->ports; i++) { sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET); @@ -1791,20 +1881,22 @@ static int sky2_reset(struct sky2_hw *hw) sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); - sky2_write32(hw, B2_I2C_IRQ, 1); /* Clear I2C IRQ noise */ + /* Clear I2C IRQ noise */ + sky2_write32(hw, B2_I2C_IRQ, 1); /* turn off hardware timer (unused) */ sky2_write8(hw, B2_TI_CTRL, TIM_STOP); sky2_write8(hw, B2_TI_CTRL, TIM_CLR_IRQ); - + sky2_write8(hw, B0_Y2LED, LED_STAT_ON); - /* Turn on descriptor polling -- is this necessary? */ + /* Turn on descriptor polling (every 75us) */ sky2_write32(hw, B28_DPT_INI, sky2_us2clk(hw, 75)); sky2_write8(hw, B28_DPT_CTRL, DPT_START); /* Turn off receive timestamp */ sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_STOP); + sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ); /* enable the Tx Arbiters */ for (i = 0; i < hw->ports; i++) @@ -1812,7 +1904,7 @@ static int sky2_reset(struct sky2_hw *hw) /* Initialize ram interface */ for (i = 0; i < hw->ports; i++) { - sky2_write16(hw, RAM_BUFFER(i, B3_RI_CTRL), RI_RST_CLR); + sky2_write8(hw, RAM_BUFFER(i, B3_RI_CTRL), RI_RST_CLR); sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_R1), SK_RI_TO_53); sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XA1), SK_RI_TO_53); @@ -1828,35 +1920,27 @@ static int sky2_reset(struct sky2_hw *hw) sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53); } - /* Optimize PCI Express access */ if (is_pciex(hw)) { - u16 ctrl = sky2_read32(hw, PCI_C(PEX_DEV_CTRL)); - ctrl &= ~PEX_DC_MAX_RRS_MSK; - ctrl |= PEX_DC_MAX_RD_RQ_SIZE(4); + u16 pctrl; + + /* change Max. Read Request Size to 2048 bytes */ + pci_read_config_word(hw->pdev, PEX_DEV_CTRL, &pctrl); + pctrl &= ~PEX_DC_MAX_RRS_MSK; + pctrl |= PEX_DC_MAX_RD_RQ_SIZE(4); + + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); - sky2_write16(hw, PCI_C(PEX_DEV_CTRL), ctrl); + pci_write_config_word(hw->pdev, PEX_DEV_CTRL, pctrl); sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); } sky2_write32(hw, B0_HWE_IMSK, Y2_HWE_ALL_MASK); - hw->intr_mask = Y2_IS_BASE; - sky2_write32(hw, B0_IMSK, hw->intr_mask); - - /* disable all GMAC IRQ's */ - sky2_write8(hw, GMAC_IRQ_MSK, 0); - spin_lock_bh(&hw->phy_lock); for (i = 0; i < hw->ports; i++) sky2_phy_reset(hw, i); spin_unlock_bh(&hw->phy_lock); - /* Setup ring for status responses */ - hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES, - &hw->st_dma); - if (!hw->st_le) - return -ENOMEM; - memset(hw->st_le, 0, STATUS_LE_BYTES); hw->st_idx = 0; @@ -1864,30 +1948,25 @@ static int sky2_reset(struct sky2_hw *hw) sky2_write32(hw, STAT_CTRL, SC_STAT_RST_CLR); sky2_write32(hw, STAT_LIST_ADDR_LO, hw->st_dma); - sky2_write32(hw, STAT_LIST_ADDR_HI, (u64)hw->st_dma >> 32); + sky2_write32(hw, STAT_LIST_ADDR_HI, (u64) hw->st_dma >> 32); /* Set the list last index */ - sky2_write16(hw, STAT_LAST_IDX, STATUS_RING_SIZE-1); + sky2_write16(hw, STAT_LAST_IDX, STATUS_RING_SIZE - 1); + sky2_write32(hw, STAT_TX_TIMER_INI, sky2_ms2clk(hw, 10)); + + /* These status setup values are copied from SysKonnect's driver */ if (is_ec_a1(hw)) { /* WA for dev. #4.3 */ - sky2_write16(hw, STAT_TX_IDX_TH, ST_TXTH_IDX_MASK); + sky2_write16(hw, STAT_TX_IDX_TH, 0xfff); /* Tx Threshold */ /* set Status-FIFO watermark */ sky2_write8(hw, STAT_FIFO_WM, 0x21); /* WA for dev. #4.18 */ /* set Status-FIFO ISR watermark */ - sky2_write8(hw, STAT_FIFO_ISR_WM, 0x07);/* WA for dev. #4.18 */ + sky2_write8(hw, STAT_FIFO_ISR_WM, 0x07); /* WA for dev. #4.18 */ - /* WA for dev. #4.3 and #4.18 */ - /* set Status-FIFO Tx timer init value */ - sky2_write32(hw, STAT_TX_TIMER_INI, sky2_ms2clk(hw, 10)); } else { - /* - * Theses settings should avoid the - * temporary hanging of the status BMU. - * May be not all required... still under investigation... - */ sky2_write16(hw, STAT_TX_IDX_TH, 0x000a); /* set Status-FIFO watermark */ @@ -1897,14 +1976,13 @@ static int sky2_reset(struct sky2_hw *hw) if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0) sky2_write8(hw, STAT_FIFO_ISR_WM, 0x10); - else /* WA 4109 */ + else /* WA 4109 */ sky2_write8(hw, STAT_FIFO_ISR_WM, 0x04); sky2_write32(hw, STAT_ISR_TIMER_INI, 0x0190); } - /* enable the prefetch unit */ - /* operational bit not functional for Yukon-EC, but fixed in Yukon-2? */ + /* enable status unit */ sky2_write32(hw, STAT_CTRL, SC_STAT_OP_ON); sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START); @@ -1918,23 +1996,22 @@ static inline u32 sky2_supported_modes(const struct sky2_hw *hw) { u32 modes; if (hw->copper) { - modes = SUPPORTED_10baseT_Half - | SUPPORTED_10baseT_Full - | SUPPORTED_100baseT_Half - | SUPPORTED_100baseT_Full - | SUPPORTED_Autoneg| SUPPORTED_TP; + modes = SUPPORTED_10baseT_Half + | SUPPORTED_10baseT_Full + | SUPPORTED_100baseT_Half + | SUPPORTED_100baseT_Full + | SUPPORTED_Autoneg | SUPPORTED_TP; if (hw->chip_id != CHIP_ID_YUKON_FE) modes |= SUPPORTED_1000baseT_Half - | SUPPORTED_1000baseT_Full; + | SUPPORTED_1000baseT_Full; } else modes = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE - | SUPPORTED_Autoneg; + | SUPPORTED_Autoneg; return modes; } -static int sky2_get_settings(struct net_device *dev, - struct ethtool_cmd *ecmd) +static int sky2_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct sky2_port *sky2 = netdev_priv(dev); struct sky2_hw *hw = sky2->hw; @@ -1944,13 +2021,12 @@ static int sky2_get_settings(struct net_device *dev, ecmd->phy_address = PHY_ADDR_MARV; if (hw->copper) { ecmd->supported = SUPPORTED_10baseT_Half - - | SUPPORTED_10baseT_Full - | SUPPORTED_100baseT_Half - | SUPPORTED_100baseT_Full - | SUPPORTED_1000baseT_Half - | SUPPORTED_1000baseT_Full - | SUPPORTED_Autoneg| SUPPORTED_TP; + | SUPPORTED_10baseT_Full + | SUPPORTED_100baseT_Half + | SUPPORTED_100baseT_Full + | SUPPORTED_1000baseT_Half + | SUPPORTED_1000baseT_Full + | SUPPORTED_Autoneg | SUPPORTED_TP; ecmd->port = PORT_TP; } else ecmd->port = PORT_FIBRE; @@ -1975,7 +2051,7 @@ static int sky2_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) } else { u32 setting; - switch(ecmd->speed) { + switch (ecmd->speed) { case SPEED_1000: if (ecmd->duplex == DUPLEX_FULL) setting = SUPPORTED_1000baseT_Full; @@ -2035,8 +2111,8 @@ static void sky2_get_drvinfo(struct net_device *dev, } static const struct sky2_stat { - char name[ETH_GSTRING_LEN]; - u16 offset; + char name[ETH_GSTRING_LEN]; + u16 offset; } sky2_stats[] = { { "tx_bytes", GM_TXO_OK_HI }, { "rx_bytes", GM_RXO_OK_HI }, @@ -2061,7 +2137,6 @@ static const struct sky2_stat { { "rx_fcs_error", GM_RXF_FCS_ERR }, }; - static u32 sky2_get_rx_csum(struct net_device *dev) { struct sky2_port *sky2 = netdev_priv(dev); @@ -2074,6 +2149,7 @@ static int sky2_set_rx_csum(struct net_device *dev, u32 data) struct sky2_port *sky2 = netdev_priv(dev); sky2->rx_csum = data; + sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), data ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); @@ -2086,22 +2162,21 @@ static u32 sky2_get_msglevel(struct net_device *netdev) return sky2->msg_enable; } -static void sky2_phy_stats(struct sky2_port *sky2, u64 *data) +static void sky2_phy_stats(struct sky2_port *sky2, u64 * data, unsigned count) { struct sky2_hw *hw = sky2->hw; unsigned port = sky2->port; int i; data[0] = (u64) gma_read32(hw, port, GM_TXO_OK_HI) << 32 - | (u64) gma_read32(hw, port, GM_TXO_OK_LO); + | (u64) gma_read32(hw, port, GM_TXO_OK_LO); data[1] = (u64) gma_read32(hw, port, GM_RXO_OK_HI) << 32 - | (u64) gma_read32(hw, port, GM_RXO_OK_LO); + | (u64) gma_read32(hw, port, GM_RXO_OK_LO); - for (i = 2; i < ARRAY_SIZE(sky2_stats); i++) + for (i = 2; i < count; i++) data[i] = (u64) gma_read32(hw, port, sky2_stats[i].offset); } - static void sky2_set_msglevel(struct net_device *netdev, u32 value) { struct sky2_port *sky2 = netdev_priv(netdev); @@ -2114,14 +2189,14 @@ static int sky2_get_stats_count(struct net_device *dev) } static void sky2_get_ethtool_stats(struct net_device *dev, - struct ethtool_stats *stats, u64 *data) + struct ethtool_stats *stats, u64 * data) { struct sky2_port *sky2 = netdev_priv(dev); - sky2_phy_stats(sky2, data); + sky2_phy_stats(sky2, data, ARRAY_SIZE(sky2_stats)); } -static void sky2_get_strings(struct net_device *dev, u32 stringset, u8 *data) +static void sky2_get_strings(struct net_device *dev, u32 stringset, u8 * data) { int i; @@ -2141,9 +2216,9 @@ static void sky2_get_strings(struct net_device *dev, u32 stringset, u8 *data) static struct net_device_stats *sky2_get_stats(struct net_device *dev) { struct sky2_port *sky2 = netdev_priv(dev); - u64 data[ARRAY_SIZE(sky2_stats)]; + u64 data[13]; - sky2_phy_stats(sky2, data); + sky2_phy_stats(sky2, data, ARRAY_SIZE(data)); sky2->net_stats.tx_bytes = data[0]; sky2->net_stats.rx_bytes = data[1]; @@ -2167,9 +2242,9 @@ static int sky2_set_mac_address(struct net_device *dev, void *p) sky2_down(dev); memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - memcpy_toio(sky2->hw->regs + B2_MAC_1 + sky2->port*8, + memcpy_toio(sky2->hw->regs + B2_MAC_1 + sky2->port * 8, dev->dev_addr, ETH_ALEN); - memcpy_toio(sky2->hw->regs + B2_MAC_2 + sky2->port*8, + memcpy_toio(sky2->hw->regs + B2_MAC_2 + sky2->port * 8, dev->dev_addr, ETH_ALEN); if (dev->flags & IFF_UP) err = sky2_up(dev); @@ -2190,11 +2265,11 @@ static void sky2_set_multicast(struct net_device *dev) reg = gma_read16(hw, port, GM_RX_CTRL); reg |= GM_RXCR_UCF_ENA; - if (dev->flags & IFF_PROMISC) /* promiscious */ + if (dev->flags & IFF_PROMISC) /* promiscious */ reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); - else if (dev->flags & IFF_ALLMULTI) /* all multicast */ + else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > 16) /* all multicast */ memset(filter, 0xff, sizeof(filter)); - else if (dev->mc_count == 0) /* no multicast */ + else if (dev->mc_count == 0) /* no multicast */ reg &= ~GM_RXCR_MCF_ENA; else { int i; @@ -2202,19 +2277,18 @@ static void sky2_set_multicast(struct net_device *dev) for (i = 0; list && i < dev->mc_count; i++, list = list->next) { u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f; - filter[bit/8] |= 1 << (bit%8); + filter[bit / 8] |= 1 << (bit % 8); } } - gma_write16(hw, port, GM_MC_ADDR_H1, - (u16)filter[0] | ((u16)filter[1] << 8)); + (u16) filter[0] | ((u16) filter[1] << 8)); gma_write16(hw, port, GM_MC_ADDR_H2, - (u16)filter[2] | ((u16)filter[3] << 8)); + (u16) filter[2] | ((u16) filter[3] << 8)); gma_write16(hw, port, GM_MC_ADDR_H3, - (u16)filter[4] | ((u16)filter[5] << 8)); + (u16) filter[4] | ((u16) filter[5] << 8)); gma_write16(hw, port, GM_MC_ADDR_H4, - (u16)filter[6] | ((u16)filter[7] << 8)); + (u16) filter[6] | ((u16) filter[7] << 8)); gma_write16(hw, port, GM_RX_CTRL, reg); } @@ -2224,24 +2298,38 @@ static void sky2_set_multicast(struct net_device *dev) */ static inline void sky2_led(struct sky2_hw *hw, unsigned port, int on) { + u16 pg; + spin_lock_bh(&hw->phy_lock); - gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); - if (on) + switch (hw->chip_id) { + case CHIP_ID_YUKON_XL: + pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); + gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, + on ? (PHY_M_LEDC_LOS_CTRL(1) | + PHY_M_LEDC_INIT_CTRL(7) | + PHY_M_LEDC_STA1_CTRL(7) | + PHY_M_LEDC_STA0_CTRL(7)) + : 0); + + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); + break; + + default: + gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); gm_phy_write(hw, port, PHY_MARV_LED_OVER, - PHY_M_LED_MO_DUP(MO_LED_ON) | - PHY_M_LED_MO_10(MO_LED_ON) | - PHY_M_LED_MO_100(MO_LED_ON) | + on ? PHY_M_LED_MO_DUP(MO_LED_ON) | + PHY_M_LED_MO_10(MO_LED_ON) | + PHY_M_LED_MO_100(MO_LED_ON) | PHY_M_LED_MO_1000(MO_LED_ON) | - PHY_M_LED_MO_RX(MO_LED_ON)); - else - gm_phy_write(hw, port, PHY_MARV_LED_OVER, - - PHY_M_LED_MO_DUP(MO_LED_OFF) | - PHY_M_LED_MO_10(MO_LED_OFF) | - PHY_M_LED_MO_100(MO_LED_OFF) | + PHY_M_LED_MO_RX(MO_LED_ON) + : PHY_M_LED_MO_DUP(MO_LED_OFF) | + PHY_M_LED_MO_10(MO_LED_OFF) | + PHY_M_LED_MO_100(MO_LED_OFF) | PHY_M_LED_MO_1000(MO_LED_OFF) | PHY_M_LED_MO_RX(MO_LED_OFF)); + } spin_unlock_bh(&hw->phy_lock); } @@ -2251,19 +2339,26 @@ static int sky2_phys_id(struct net_device *dev, u32 data) struct sky2_port *sky2 = netdev_priv(dev); struct sky2_hw *hw = sky2->hw; unsigned port = sky2->port; - u16 ledctrl, ledover; + u16 ledctrl, ledover = 0; long ms; int onoff = 1; - if (!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ)) + if (!data || data > (u32) (MAX_SCHEDULE_TIMEOUT / HZ)) ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT); else ms = data * 1000; /* save initial values */ spin_lock_bh(&hw->phy_lock); - ledctrl = gm_phy_read(hw, port, PHY_MARV_LED_CTRL); - ledover = gm_phy_read(hw, port, PHY_MARV_LED_OVER); + if (hw->chip_id == CHIP_ID_YUKON_XL) { + u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); + ledctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL); + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); + } else { + ledctrl = gm_phy_read(hw, port, PHY_MARV_LED_CTRL); + ledover = gm_phy_read(hw, port, PHY_MARV_LED_OVER); + } spin_unlock_bh(&hw->phy_lock); while (ms > 0) { @@ -2277,8 +2372,15 @@ static int sky2_phys_id(struct net_device *dev, u32 data) /* resume regularly scheduled programming */ spin_lock_bh(&hw->phy_lock); - gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); - gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); + if (hw->chip_id == CHIP_ID_YUKON_XL) { + u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); + gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ledctrl); + gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg); + } else { + gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); + gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); + } spin_unlock_bh(&hw->phy_lock); return 0; @@ -2344,30 +2446,102 @@ static int sky2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) } #endif +static void sky2_get_ringparam(struct net_device *dev, + struct ethtool_ringparam *ering) +{ + struct sky2_port *sky2 = netdev_priv(dev); + + ering->rx_max_pending = RX_MAX_PENDING; + ering->rx_mini_max_pending = 0; + ering->rx_jumbo_max_pending = 0; + ering->tx_max_pending = TX_RING_SIZE - 1; + + ering->rx_pending = sky2->rx_pending; + ering->rx_mini_pending = 0; + ering->rx_jumbo_pending = 0; + ering->tx_pending = sky2->tx_pending; +} + +static int sky2_set_ringparam(struct net_device *dev, + struct ethtool_ringparam *ering) +{ + struct sky2_port *sky2 = netdev_priv(dev); + int err = 0; + + if (ering->rx_pending > RX_MAX_PENDING || + ering->rx_pending < 8 || + ering->tx_pending < MAX_SKB_TX_LE || + ering->tx_pending > TX_RING_SIZE - 1) + return -EINVAL; + + if (netif_running(dev)) + sky2_down(dev); + + sky2->rx_pending = ering->rx_pending; + sky2->tx_pending = ering->tx_pending; + + if (netif_running(dev)) + err = sky2_up(dev); + + return err; +} + +#define SKY2_REGS_LEN 0x1000 +static int sky2_get_regs_len(struct net_device *dev) +{ + return SKY2_REGS_LEN; +} + +/* + * Returns copy of control register region + * I/O region is divided into banks and certain regions are unreadable + */ +static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs, + void *p) +{ + const struct sky2_port *sky2 = netdev_priv(dev); + unsigned long offs; + const void __iomem *io = sky2->hw->regs; + static const unsigned long bankmap = 0xfff3f305; + + regs->version = 1; + for (offs = 0; offs < regs->len; offs += 128) { + u32 len = min_t(u32, 128, regs->len - offs); + + if (bankmap & (1 << (offs / 128))) + memcpy_fromio(p + offs, io + offs, len); + else + memset(p + offs, 0, len); + } +} static struct ethtool_ops sky2_ethtool_ops = { - .get_settings = sky2_get_settings, - .set_settings = sky2_set_settings, - .get_drvinfo = sky2_get_drvinfo, - .get_msglevel = sky2_get_msglevel, - .set_msglevel = sky2_set_msglevel, - .get_link = ethtool_op_get_link, - .get_sg = ethtool_op_get_sg, - .set_sg = ethtool_op_set_sg, - .get_tx_csum = ethtool_op_get_tx_csum, - .set_tx_csum = ethtool_op_set_tx_csum, - .get_tso = ethtool_op_get_tso, - .set_tso = ethtool_op_set_tso, - .get_rx_csum = sky2_get_rx_csum, - .set_rx_csum = sky2_set_rx_csum, - .get_strings = sky2_get_strings, + .get_settings = sky2_get_settings, + .set_settings = sky2_set_settings, + .get_drvinfo = sky2_get_drvinfo, + .get_msglevel = sky2_get_msglevel, + .set_msglevel = sky2_set_msglevel, + .get_regs_len = sky2_get_regs_len, + .get_regs = sky2_get_regs, + .get_link = ethtool_op_get_link, + .get_sg = ethtool_op_get_sg, + .set_sg = ethtool_op_set_sg, + .get_tx_csum = ethtool_op_get_tx_csum, + .set_tx_csum = ethtool_op_set_tx_csum, + .get_tso = ethtool_op_get_tso, + .set_tso = ethtool_op_set_tso, + .get_rx_csum = sky2_get_rx_csum, + .set_rx_csum = sky2_set_rx_csum, + .get_strings = sky2_get_strings, + .get_ringparam = sky2_get_ringparam, + .set_ringparam = sky2_set_ringparam, .get_pauseparam = sky2_get_pauseparam, .set_pauseparam = sky2_set_pauseparam, #ifdef CONFIG_PM - .get_wol = sky2_get_wol, - .set_wol = sky2_set_wol, + .get_wol = sky2_get_wol, + .set_wol = sky2_set_wol, #endif - .phys_id = sky2_phys_id, + .phys_id = sky2_phys_id, .get_stats_count = sky2_get_stats_count, .get_ethtool_stats = sky2_get_ethtool_stats, }; @@ -2402,7 +2576,6 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, #ifdef CONFIG_NET_POLL_CONTROLLER dev->poll_controller = sky2_netpoll; #endif - dev->irq = hw->pdev->irq; sky2 = netdev_priv(dev); sky2->netdev = dev; @@ -2418,20 +2591,21 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, sky2->speed = -1; sky2->advertising = sky2_supported_modes(hw); sky2->rx_csum = 1; - sky2->rx_ring_size = is_ec_a1(hw) ? MIN_RX_BUFFERS : MAX_RX_BUFFERS; - tasklet_init(&sky2->phy_task, sky2_phy_task, (unsigned long) sky2); + tasklet_init(&sky2->phy_task, sky2_phy_task, (unsigned long)sky2); + sky2->tx_pending = TX_DEF_PENDING; + sky2->rx_pending = is_ec_a1(hw) ? 8 : RX_DEF_PENDING; hw->dev[port] = dev; sky2->port = port; - dev->features |= NETIF_F_LLTX; + dev->features |= NETIF_F_LLTX | NETIF_F_TSO; if (highmem) dev->features |= NETIF_F_HIGHDMA; - dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO; + dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; /* read the mac address */ - memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port*8, ETH_ALEN); + memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN); /* device is off until link detection */ netif_carrier_off(dev); @@ -2454,20 +2628,22 @@ static inline void sky2_show_addr(struct net_device *dev) static int __devinit sky2_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - struct net_device *dev, *dev1; + struct net_device *dev, *dev1 = NULL; struct sky2_hw *hw; int err, using_dac = 0; - if ((err = pci_enable_device(pdev))) { + err = pci_enable_device(pdev); + if (err) { printk(KERN_ERR PFX "%s cannot enable PCI device\n", pci_name(pdev)); goto err_out; } - if ((err = pci_request_regions(pdev, DRV_NAME))) { + err = pci_request_regions(pdev, DRV_NAME); + if (err) { printk(KERN_ERR PFX "%s cannot obtain PCI resources\n", pci_name(pdev)); - goto err_out_disable_pdev; + goto err_out; } pci_set_master(pdev); @@ -2486,7 +2662,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev, goto err_out_free_regions; } } - #ifdef __BIG_ENDIAN /* byte swap decriptors in hardware */ { @@ -2517,26 +2692,21 @@ static int __devinit sky2_probe(struct pci_dev *pdev, goto err_out_free_hw; } - err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ, DRV_NAME, hw); - if (err) { - printk(KERN_ERR PFX "%s: cannot assign irq %d\n", - pci_name(pdev), pdev->irq); - goto err_out_iounmap; - } - pci_set_drvdata(pdev, hw); - err = sky2_reset(hw); if (err) - goto err_out_free_irq; + goto err_out_iounmap; - printk(KERN_INFO PFX "addr 0x%lx irq %d chip 0x%x (%s) rev %d\n", + printk(KERN_INFO PFX "addr 0x%lx irq %d Yukon-%s (0x%x) rev %d\n", pci_resource_start(pdev, 0), pdev->irq, - hw->chip_id, chip_name(hw->chip_id), hw->chip_rev); + yukon_name[hw->chip_id - CHIP_ID_YUKON], + hw->chip_id, hw->chip_rev); - if ((dev = sky2_init_netdev(hw, 0, using_dac)) == NULL) + dev = sky2_init_netdev(hw, 0, using_dac); + if (!dev) goto err_out_free_pci; - if ((err = register_netdev(dev))) { + err = register_netdev(dev); + if (err) { printk(KERN_ERR PFX "%s: cannot register net device\n", pci_name(pdev)); goto err_out_free_netdev; @@ -2549,20 +2719,37 @@ static int __devinit sky2_probe(struct pci_dev *pdev, sky2_show_addr(dev1); else { /* Failure to register second port need not be fatal */ - printk(KERN_WARNING PFX "register of second port failed\n"); + printk(KERN_WARNING PFX + "register of second port failed\n"); hw->dev[1] = NULL; free_netdev(dev1); } } + err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ, DRV_NAME, hw); + if (err) { + printk(KERN_ERR PFX "%s: cannot assign irq %d\n", + pci_name(pdev), pdev->irq); + goto err_out_unregister; + } + + hw->intr_mask = Y2_IS_BASE; + sky2_write32(hw, B0_IMSK, hw->intr_mask); + + pci_set_drvdata(pdev, hw); + return 0; +err_out_unregister: + if (dev1) { + unregister_netdev(dev1); + free_netdev(dev1); + } + unregister_netdev(dev); err_out_free_netdev: free_netdev(dev); - -err_out_free_irq: - free_irq(pdev->irq, hw); err_out_free_pci: + sky2_write8(hw, B0_CTST, CS_RST_SET); pci_free_consistent(hw->pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma); err_out_iounmap: iounmap(hw->regs); @@ -2570,33 +2757,34 @@ err_out_free_hw: kfree(hw); err_out_free_regions: pci_release_regions(pdev); -err_out_disable_pdev: pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); err_out: return err; } static void __devexit sky2_remove(struct pci_dev *pdev) { - struct sky2_hw *hw = pci_get_drvdata(pdev); + struct sky2_hw *hw = pci_get_drvdata(pdev); struct net_device *dev0, *dev1; - if(!hw) + if (!hw) return; - if ((dev1 = hw->dev[1])) - unregister_netdev(dev1); dev0 = hw->dev[0]; + dev1 = hw->dev[1]; + if (dev1) + unregister_netdev(dev1); unregister_netdev(dev0); + sky2_write32(hw, B0_IMSK, 0); sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); + sky2_write8(hw, B0_CTST, CS_RST_SET); free_irq(pdev->irq, hw); - pci_free_consistent(pdev, STATUS_LE_BYTES, - hw->st_le, hw->st_dma); + pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma); pci_release_regions(pdev); pci_disable_device(pdev); + if (dev1) free_netdev(dev1); free_netdev(dev0); @@ -2608,7 +2796,7 @@ static void __devexit sky2_remove(struct pci_dev *pdev) #ifdef CONFIG_PM static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) { - struct sky2_hw *hw = pci_get_drvdata(pdev); + struct sky2_hw *hw = pci_get_drvdata(pdev); int i, wol = 0; for (i = 0; i < 2; i++) { @@ -2635,7 +2823,7 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) static int sky2_resume(struct pci_dev *pdev) { - struct sky2_hw *hw = pci_get_drvdata(pdev); + struct sky2_hw *hw = pci_get_drvdata(pdev); int i; pci_set_power_state(pdev, PCI_D0); @@ -2657,19 +2845,18 @@ static int sky2_resume(struct pci_dev *pdev) #endif static struct pci_driver sky2_driver = { - .name = DRV_NAME, - .id_table = sky2_id_table, - .probe = sky2_probe, - .remove = __devexit_p(sky2_remove), + .name = DRV_NAME, + .id_table = sky2_id_table, + .probe = sky2_probe, + .remove = __devexit_p(sky2_remove), #ifdef CONFIG_PM - .suspend = sky2_suspend, - .resume = sky2_resume, + .suspend = sky2_suspend, + .resume = sky2_resume, #endif }; static int __init sky2_init_module(void) { - return pci_module_init(&sky2_driver); } diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index d2a0ac2..9256303 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -209,13 +209,9 @@ enum csr_regs { Y2_CFG_SPC = 0x1c00, }; -/* Access pci config through board I/O */ -#define PCI_C(x) (Y2_CFG_SPC + (x)) - - /* B0_CTST 16 bit Control/Status register */ enum { - Y2_VMAIN_AVAIL = 1<<17, /* VMAIN available (YUKON-2 only) */ + Y2_VMAIN_AVAIL = 1<<17,/* VMAIN available (YUKON-2 only) */ Y2_VAUX_AVAIL = 1<<16,/* VAUX available (YUKON-2 only) */ Y2_ASF_ENABLE = 1<<13,/* ASF Unit Enable (YUKON-2 only) */ Y2_ASF_DISABLE = 1<<12,/* ASF Unit Disable (YUKON-2 only) */ @@ -234,13 +230,17 @@ enum { CS_MRST_SET = 1<<2, /* Set Master reset */ CS_RST_CLR = 1<<1, /* Clear Software reset */ CS_RST_SET = 1, /* Set Software reset */ +}; /* B0_LED 8 Bit LED register */ +enum { /* Bit 7.. 2: reserved */ LED_STAT_ON = 1<<1, /* Status LED on */ - LED_STAT_OFF = 1, /* Status LED off */ + LED_STAT_OFF = 1, /* Status LED off */ +}; /* B0_POWER_CTRL 8 Bit Power Control reg (YUKON only) */ +enum { PC_VAUX_ENA = 1<<7, /* Switch VAUX Enable */ PC_VAUX_DIS = 1<<6, /* Switch VAUX Disable */ PC_VCC_ENA = 1<<5, /* Switch VCC Enable */ @@ -336,7 +336,7 @@ enum { Y2_HWE_L2_MASK = Y2_IS_PAR_RD2 | Y2_IS_PAR_WR2 | Y2_IS_PAR_MAC2 | Y2_IS_PAR_RX2 | Y2_IS_TCP_TXS2| Y2_IS_TCP_TXA2, - Y2_HWE_ALL_MASK = Y2_IS_SENSOR | Y2_IS_MST_ERR | Y2_IS_IRQ_STAT | + Y2_HWE_ALL_MASK = Y2_IS_TIST_OV | Y2_IS_MST_ERR | Y2_IS_IRQ_STAT | Y2_IS_PCI_EXP | Y2_IS_PCI_NEXP | Y2_HWE_L1_MASK | Y2_HWE_L2_MASK, }; @@ -793,11 +793,6 @@ enum { STAT_ISR_TIMER_CNT = 0x0ed4,/* 32 bit ISR Timer Counter Reg */ STAT_ISR_TIMER_CTRL= 0x0ed8,/* 8 bit ISR Timer Control Reg */ STAT_ISR_TIMER_TEST= 0x0ed9,/* 8 bit ISR Timer Test Reg */ - - ST_LAST_IDX_MASK = 0x007f,/* Last Index Mask */ - ST_TXRP_IDX_MASK = 0x0fff,/* Tx Report Index Mask */ - ST_TXTH_IDX_MASK = 0x0fff,/* Tx Threshold Index Mask */ - ST_WM_IDX_MASK = 0x3f,/* FIFO Watermark Index Mask */ }; enum { @@ -836,6 +831,7 @@ enum { /* WOL Pattern Counter Registers (YUKON only) */ + WOL_PATT_CNT_0 = 0x0f38,/* 32 bit WOL Pattern Counter 3..0 */ WOL_PATT_CNT_4 = 0x0f3c,/* 24 bit WOL Pattern Counter 6..4 */ }; @@ -1536,34 +1532,34 @@ enum { /* Receive Frame Status Encoding */ enum { GMR_FS_LEN = 0xffff<<16, /* Bit 31..16: Rx Frame Length */ - GMR_FS_VLAN = 1<<13, /* Bit 13: VLAN Packet */ - GMR_FS_JABBER = 1<<12, /* Bit 12: Jabber Packet */ - GMR_FS_UN_SIZE = 1<<11, /* Bit 11: Undersize Packet */ - GMR_FS_MC = 1<<10, /* Bit 10: Multicast Packet */ - GMR_FS_BC = 1<<9, /* Bit 9: Broadcast Packet */ - GMR_FS_RX_OK = 1<<8, /* Bit 8: Receive OK (Good Packet) */ - GMR_FS_GOOD_FC = 1<<7, /* Bit 7: Good Flow-Control Packet */ - GMR_FS_BAD_FC = 1<<6, /* Bit 6: Bad Flow-Control Packet */ - GMR_FS_MII_ERR = 1<<5, /* Bit 5: MII Error */ - GMR_FS_LONG_ERR = 1<<4, /* Bit 4: Too Long Packet */ - GMR_FS_FRAGMENT = 1<<3, /* Bit 3: Fragment */ - - GMR_FS_CRC_ERR = 1<<1, /* Bit 1: CRC Error */ - GMR_FS_RX_FF_OV = 1<<0, /* Bit 0: Rx FIFO Overflow */ + GMR_FS_VLAN = 1<<13, /* VLAN Packet */ + GMR_FS_JABBER = 1<<12, /* Jabber Packet */ + GMR_FS_UN_SIZE = 1<<11, /* Undersize Packet */ + GMR_FS_MC = 1<<10, /* Multicast Packet */ + GMR_FS_BC = 1<<9, /* Broadcast Packet */ + GMR_FS_RX_OK = 1<<8, /* Receive OK (Good Packet) */ + GMR_FS_GOOD_FC = 1<<7, /* Good Flow-Control Packet */ + GMR_FS_BAD_FC = 1<<6, /* Bad Flow-Control Packet */ + GMR_FS_MII_ERR = 1<<5, /* MII Error */ + GMR_FS_LONG_ERR = 1<<4, /* Too Long Packet */ + GMR_FS_FRAGMENT = 1<<3, /* Fragment */ + + GMR_FS_CRC_ERR = 1<<1, /* CRC Error */ + GMR_FS_RX_FF_OV = 1<<0, /* Rx FIFO Overflow */ -/* - * GMR_FS_ANY_ERR (analogous to XMR_FS_ANY_ERR) - */ GMR_FS_ANY_ERR = GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR | GMR_FS_FRAGMENT | GMR_FS_LONG_ERR | GMR_FS_MII_ERR | GMR_FS_BAD_FC | GMR_FS_GOOD_FC | GMR_FS_UN_SIZE | GMR_FS_JABBER, -/* Rx GMAC FIFO Flush Mask (default) */ - RX_FF_FL_DEF_MSK = GMR_FS_ANY_ERR, }; /* RX_GMF_CTRL_T 32 bit Rx GMAC FIFO Control/Test */ enum { + RX_TRUNC_ON = 1<<27, /* enable packet truncation */ + RX_TRUNC_OFF = 1<<26, /* disable packet truncation */ + RX_VLAN_STRIP_ON = 1<<25, /* enable VLAN stripping */ + RX_VLAN_STRIP_OFF = 1<<24, /* disable VLAN stripping */ + GMF_WP_TST_ON = 1<<14, /* Write Pointer Test On */ GMF_WP_TST_OFF = 1<<13, /* Write Pointer Test Off */ GMF_WP_STEP = 1<<12, /* Write Pointer Step/Increment */ @@ -1574,7 +1570,8 @@ enum { GMF_RX_F_FL_ON = 1<<7, /* Rx FIFO Flush Mode On */ GMF_RX_F_FL_OFF = 1<<6, /* Rx FIFO Flush Mode Off */ GMF_CLI_RX_FO = 1<<5, /* Clear IRQ Rx FIFO Overrun */ - GMF_CLI_RX_FC = 1<<4, /* Clear IRQ Rx Frame Complete */ + GMF_CLI_RX_C = 1<<4, /* Clear IRQ Rx Frame Complete */ + GMF_OPER_ON = 1<<3, /* Operational Mode On */ GMF_OPER_OFF = 1<<2, /* Operational Mode Off */ GMF_RST_CLR = 1<<1, /* Clear GMAC FIFO Reset */ @@ -1586,6 +1583,9 @@ enum { /* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */ enum { + TX_VLAN_TAG_ON = 1<<25,/* enable VLAN tagging */ + TX_VLAN_TAG_OFF = 1<<24,/* disable VLAN tagging */ + GMF_WSP_TST_ON = 1<<18,/* Write Shadow Pointer Test On */ GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */ GMF_WSP_STEP = 1<<16,/* Write Shadow Pointer Step/Increment */ @@ -1679,8 +1679,7 @@ enum { GM_IS_RX_FF_OR = 1<<1, /* Receive FIFO Overrun */ GM_IS_RX_COMPL = 1<<0, /* Frame Reception Complete */ -#define GMAC_DEF_MSK (GM_IS_TX_CO_OV | GM_IS_RX_CO_OV |\ - GM_IS_TX_FF_UR | GM_IS_RX_FF_OR) +#define GMAC_DEF_MSK (GM_IS_TX_FF_UR|GM_IS_RX_FF_OR) /* GMAC_LINK_CTRL 16 bit GMAC Link Control Reg (YUKON only) */ /* Bits 15.. 2: reserved */ @@ -1761,9 +1760,6 @@ enum { OP_RXTIMEVLAN = OP_RXTIMESTAMP | OP_RXVLAN, OP_RSS_HASH = 0x65, OP_TXINDEXLE = 0x68, - -/* YUKON-2 SPECIAL opcodes defines */ - OP_PUTIDX = 0x70, }; /* Yukon 2 hardware interface @@ -1775,62 +1771,60 @@ struct sky2_tx_le { struct { u16 offset; u16 start; - } csum; + } csum __attribute((packed)); struct { u16 size; u16 rsvd; - } tso; + } tso __attribute((packed)); } tx; u16 length; /* also vlan tag or checksum start */ u8 ctrl; u8 opcode; -}; +} __attribute((packed)); struct sky2_rx_le { - union { - u32 addr; - struct { - u16 start1; - u16 start2; - } csum; - } rx; + u32 addr; u16 length; u8 ctrl; u8 opcode; -}; +} __attribute((packed));; struct sky2_status_le { u32 status; /* also checksum */ u16 length; /* also vlan tag */ u8 link; u8 opcode; -}; - +} __attribute((packed)); struct ring_info { struct sk_buff *skb; - DECLARE_PCI_UNMAP_ADDR(mapaddr); - DECLARE_PCI_UNMAP_LEN(maplen); + dma_addr_t mapaddr; + u16 maplen; + u16 idx; }; struct sky2_port { - struct sky2_hw *hw ____cacheline_aligned; + struct sky2_hw *hw; struct net_device *netdev; unsigned port; u32 msg_enable; - struct ring_info *tx_ring ____cacheline_aligned; + struct ring_info *tx_ring; struct sky2_tx_le *tx_le; spinlock_t tx_lock; + u32 tx_addr64; u16 tx_cons; /* next le to check */ u16 tx_prod; /* next le to use */ + u16 tx_pending; u16 tx_last_put; + u16 tx_last_mss; - struct ring_info *rx_ring ____cacheline_aligned; + struct ring_info *rx_ring; struct sky2_rx_le *rx_le; - u16 rx_ring_size; + u32 rx_addr64; u16 rx_next; /* next re to check */ u16 rx_put; /* next le index to use */ + u16 rx_pending; u16 rx_last_put; dma_addr_t rx_le_map; @@ -1882,12 +1876,14 @@ static inline u8 sky2_read8(const struct sky2_hw *hw, unsigned reg) return readb(hw->regs + reg); } +/* This should probably go away, bus based tweeks suck */ static inline int is_pciex(const struct sky2_hw *hw) { - return (sky2_read32(hw, PCI_C(PCI_DEV_STATUS)) & PCI_OS_PCI_X) == 0; + u32 status; + pci_read_config_dword(hw->pdev, PCI_DEV_STATUS, &status); + return (status & PCI_OS_PCI_X) == 0; } - static inline void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val) { writel(val, hw->regs + reg); diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7c71790..5e90557 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -780,11 +780,15 @@ static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits) } /* Schedule rx intr now? */ +static inline int netif_rx_schedule_test(struct net_device *dev) +{ + return !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state); +} +/* Schedule only if device is up */ static inline int netif_rx_schedule_prep(struct net_device *dev) { - return netif_running(dev) && - !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state); + return netif_running(dev) && netif_rx_schedule_test(dev); } /* Add interface to tail of rx poll list. This assumes that _prep has -- cgit v1.1 From 79e57d32fe6d2d5bd38378f6dccfdbe6bd1d1dab Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 19 Sep 2005 15:42:33 -0700 Subject: [PATCH] sky2: fix FIFO DMA alignment problems The Yukon2 chip FIFO has a problem recovering from a pause frame if the receive buffer is not aligned. The workaround is to just leave receive buffer at original alignment, which will make IP header unaligned. Rework receive logic for clarity. Need to ignore receive overrun interrupts (or mac hangs). These fixes make the sky2 driver generally usable. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 78 ++++++++++++++++++++++++++++-------------------------- drivers/net/sky2.h | 2 +- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index bc95aac..c057694 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -76,7 +76,7 @@ #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) #define RX_MAX_PENDING (RX_LE_SIZE/2 - 1) #define RX_DEF_PENDING 128 -#define RX_COPY_THRESHOLD 128 +#define RX_COPY_THRESHOLD 256 #define TX_RING_SIZE 512 #define TX_DEF_PENDING (TX_RING_SIZE - 1) @@ -692,18 +692,10 @@ static void sky2_rx_clean(struct sky2_port *sky2) } } -static inline struct sk_buff *sky2_rx_alloc(struct sky2_port *sky2, - unsigned int size, - unsigned int gfp_mask) +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +static inline unsigned sky2_rx_size(const struct sky2_port *sky2) { - struct sk_buff *skb; - - skb = alloc_skb(size + NET_IP_ALIGN, gfp_mask); - if (likely(skb)) { - skb->dev = sky2->netdev; - skb_reserve(skb, NET_IP_ALIGN); - } - return skb; + return roundup(sky2->netdev->mtu + ETH_HLEN + 4, 8); } /* @@ -711,22 +703,28 @@ static inline struct sk_buff *sky2_rx_alloc(struct sky2_port *sky2, * In case of 64 bit dma, there are 2X as many list elements * available as ring entries * and need to reserve one list element so we don't wrap around. + * + * It appears the hardware has a bug in the FIFO logic that + * cause it to hang if the FIFO gets overrun and the receive buffer + * is not aligned. This means we can't use skb_reserve to align + * the IP header. */ static int sky2_rx_fill(struct sky2_port *sky2) { unsigned i; - const unsigned rx_buf_size = sky2->netdev->mtu + ETH_HLEN + 8; + unsigned size = sky2_rx_size(sky2); + pr_debug("rx_fill size=%d\n", size); for (i = 0; i < sky2->rx_pending; i++) { struct ring_info *re = sky2->rx_ring + i; - re->skb = sky2_rx_alloc(sky2, rx_buf_size, GFP_KERNEL); + re->skb = dev_alloc_skb(size); if (!re->skb) goto nomem; re->mapaddr = pci_map_single(sky2->hw->pdev, re->skb->data, - rx_buf_size, PCI_DMA_FROMDEVICE); - re->maplen = rx_buf_size; + size, PCI_DMA_FROMDEVICE); + re->maplen = size; sky2_rx_add(sky2, re); } @@ -1408,8 +1406,8 @@ static struct sk_buff *sky2_receive(struct sky2_hw *hw, unsigned port, struct net_device *dev = hw->dev[port]; struct sky2_port *sky2 = netdev_priv(dev); struct ring_info *re = sky2->rx_ring + sky2->rx_next; - struct sk_buff *skb, *nskb; - const unsigned int rx_buf_size = dev->mtu + ETH_HLEN + 8; + struct sk_buff *skb = NULL; + const unsigned int bufsize = sky2_rx_size(sky2); if (unlikely(netif_msg_rx_status(sky2))) printk(KERN_DEBUG PFX "%s: rx slot %u status 0x%x len %d\n", @@ -1417,43 +1415,49 @@ static struct sk_buff *sky2_receive(struct sky2_hw *hw, unsigned port, sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending; - skb = NULL; if (!(status & GMR_FS_RX_OK) || (status & GMR_FS_ANY_ERR) || (length << 16) != (status & GMR_FS_LEN) - || length > rx_buf_size) + || length > bufsize) goto error; if (length < RX_COPY_THRESHOLD) { - nskb = sky2_rx_alloc(sky2, length, GFP_ATOMIC); - if (!nskb) + skb = alloc_skb(length + 2, GFP_ATOMIC); + if (!skb) goto resubmit; + skb_reserve(skb, 2); pci_dma_sync_single_for_cpu(sky2->hw->pdev, re->mapaddr, length, PCI_DMA_FROMDEVICE); - memcpy(nskb->data, re->skb->data, length); + memcpy(skb->data, re->skb->data, length); pci_dma_sync_single_for_device(sky2->hw->pdev, re->mapaddr, length, PCI_DMA_FROMDEVICE); - skb = nskb; } else { - nskb = sky2_rx_alloc(sky2, rx_buf_size, GFP_ATOMIC); + struct sk_buff *nskb; + + nskb = dev_alloc_skb(bufsize); if (!nskb) goto resubmit; skb = re->skb; + re->skb = nskb; pci_unmap_single(sky2->hw->pdev, re->mapaddr, re->maplen, PCI_DMA_FROMDEVICE); prefetch(skb->data); - re->skb = nskb; re->mapaddr = pci_map_single(sky2->hw->pdev, nskb->data, - rx_buf_size, PCI_DMA_FROMDEVICE); - re->maplen = rx_buf_size; + bufsize, PCI_DMA_FROMDEVICE); + re->maplen = bufsize; } + skb->dev = dev; + skb_put(skb, length); + skb->protocol = eth_type_trans(skb, dev); + dev->last_rx = jiffies; + resubmit: - BUG_ON(re->skb == skb); sky2_rx_add(sky2, re); + return skb; error: @@ -1472,6 +1476,7 @@ error: sky2->net_stats.rx_crc_errors++; if (status & GMR_FS_RX_FF_OV) sky2->net_stats.rx_fifo_errors++; + goto resubmit; } @@ -1502,6 +1507,7 @@ static int sky2_poll(struct net_device *dev, int *budget) unsigned int csum[2]; hwidx = sky2_read16(hw, STAT_PUT_IDX); + BUG_ON(hwidx >= STATUS_RING_SIZE); rmb(); while (hw->st_idx != hwidx && work_done < to_do) { struct sky2_status_le *le = hw->st_le + hw->st_idx; @@ -1520,22 +1526,18 @@ static int sky2_poll(struct net_device *dev, int *budget) case OP_RXSTAT: skb = sky2_receive(hw, port, length, status); if (likely(skb)) { - __skb_put(skb, length); - skb->protocol = eth_type_trans(skb, dev); - /* Add hw checksum if available */ skb->ip_summed = summed[port]; skb->csum = csum[port]; - /* Clear for next packet */ - csum[port] = 0; - summed[port] = CHECKSUM_NONE; - netif_receive_skb(skb); - - dev->last_rx = jiffies; ++work_done; } + + /* Clear for next packet */ + csum[port] = 0; + summed[port] = CHECKSUM_NONE; + break; case OP_RXCHKS: diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 9256303..1a8a004 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -1679,7 +1679,7 @@ enum { GM_IS_RX_FF_OR = 1<<1, /* Receive FIFO Overrun */ GM_IS_RX_COMPL = 1<<0, /* Frame Reception Complete */ -#define GMAC_DEF_MSK (GM_IS_TX_FF_UR|GM_IS_RX_FF_OR) +#define GMAC_DEF_MSK GM_IS_TX_FF_UR /* GMAC_LINK_CTRL 16 bit GMAC Link Control Reg (YUKON only) */ /* Bits 15.. 2: reserved */ -- cgit v1.1 From 6e4cbb34d4cabec48f25f0bbad68935221bd457b Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 19 Sep 2005 15:47:57 -0700 Subject: [PATCH] sky2: allow ethtool debug access to all of PCI space For debugging, it is useful to allow ethtool to dump all of the PCI mapped space. There is one small set of registers for RAM diagnostics that needs to be avoided to prevent hanging, but all the rest is accessible. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index c057694..1acca98 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -2488,33 +2488,30 @@ static int sky2_set_ringparam(struct net_device *dev, return err; } -#define SKY2_REGS_LEN 0x1000 static int sky2_get_regs_len(struct net_device *dev) { - return SKY2_REGS_LEN; + return 0x4000; } /* * Returns copy of control register region - * I/O region is divided into banks and certain regions are unreadable + * Note: access to the RAM address register set will cause timeouts. */ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) { const struct sky2_port *sky2 = netdev_priv(dev); - unsigned long offs; const void __iomem *io = sky2->hw->regs; - static const unsigned long bankmap = 0xfff3f305; + BUG_ON(regs->len < B3_RI_WTO_R1); regs->version = 1; - for (offs = 0; offs < regs->len; offs += 128) { - u32 len = min_t(u32, 128, regs->len - offs); + memset(p, 0, regs->len); - if (bankmap & (1 << (offs / 128))) - memcpy_fromio(p + offs, io + offs, len); - else - memset(p + offs, 0, len); - } + memcpy_fromio(p, io, B3_RAM_ADDR); + + memcpy_fromio(p + B3_RI_WTO_R1, + io + B3_RI_WTO_R1, + regs->len - B3_RI_WTO_R1); } static struct ethtool_ops sky2_ethtool_ops = { -- cgit v1.1 From ecfd7f32aa9e279f3732c2e5049b1a4a13428572 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 19 Sep 2005 15:49:13 -0700 Subject: [PATCH] sky2: version 0.5 Bump version (we are half way to a stable driver??) Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 1acca98..d2c0d04 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -54,7 +54,7 @@ #include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "0.4" +#define DRV_VERSION "0.5" #define PFX DRV_NAME " " /* -- cgit v1.1 From 6b1a3aefd897fd9be410d192f950656ef2b59694 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Tue, 27 Sep 2005 15:02:55 -0700 Subject: [PATCH] sky2: changing mtu doesn't have to reset link Changing the MTU of the network device doesn't mean the whole link has to be brought down and back up again. Just stopping the receive engine is good enough. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 147 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 63 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index d2c0d04..0cc5729 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -468,9 +468,9 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) /* serial mode register */ reg = DATA_BLIND_VAL(DATA_BLIND_DEF) | - GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); + GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); - if (hw->dev[port]->mtu > 1500) + if (hw->dev[port]->mtu > ETH_DATA_LEN) reg |= GM_SMOD_JUMBO_ENA; gma_write16(hw, port, GM_SERIAL_MODE, reg); @@ -515,8 +515,6 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) len /= 8; end = start + len - 1; - pr_debug("sky2_ramset start=%d end=%d\n", start, end); - sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); sky2_write32(hw, RB_ADDR(q, RB_START), start); sky2_write32(hw, RB_ADDR(q, RB_END), end); @@ -528,7 +526,6 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) rxlo = len/2; rxup = rxlo + len/4; - pr_debug(" utpp=%d ltpp=%d\n", rxup, rxlo); /* Set thresholds on receive queue's */ sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), rxup); @@ -662,16 +659,44 @@ static void rx_set_checksum(struct sky2_port *sky2) le->ctrl = 0; le->opcode = OP_TCPSTART | HW_OWNER; - sky2_write16(sky2->hw, Y2_QADDR(rxqaddr[sky2->port], - PREF_UNIT_PUT_IDX), sky2->rx_put); - sky2_read16(sky2->hw, Y2_QADDR(rxqaddr[sky2->port], PREF_UNIT_PUT_IDX)); - mdelay(1); sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR), sky2->rx_csum ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM); } +/* + * The RX Stop command will not work for Yukon-2 if the BMU does not + * reach the end of packet and since we can't make sure that we have + * incoming data, we must reset the BMU while it is not doing a DMA + * transfer. Since it is possible that the RX path is still active, + * the RX RAM buffer will be stopped first, so any possible incoming + * data will not trigger a DMA. After the RAM buffer is stopped, the + * BMU is polled until any DMA in progress is ended and only then it + * will be reset. + */ +static void sky2_rx_stop(struct sky2_port *sky2) +{ + struct sky2_hw *hw = sky2->hw; + unsigned rxq = rxqaddr[sky2->port]; + int i; + + /* disable the RAM Buffer receive queue */ + sky2_write8(hw, RB_ADDR(rxq, RB_CTRL), RB_DIS_OP_MD); + + for (i = 0; i < 0xffff; i++) + if (sky2_read8(hw, RB_ADDR(rxq, Q_RSL)) + == sky2_read8(hw, RB_ADDR(rxq, Q_RL))) + goto stopped; + + printk(KERN_WARNING PFX "%s: receiver stop failed\n", + sky2->netdev->name); +stopped: + sky2_write32(hw, Q_ADDR(rxq, Q_CSR), BMU_RST_SET | BMU_FIFO_RST); + + /* reset the Rx prefetch unit */ + sky2_write32(hw, Y2_QADDR(rxq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); +} /* Cleanout receive buffer area, assumes receiver hardware stopped */ static void sky2_rx_clean(struct sky2_port *sky2) @@ -693,7 +718,7 @@ static void sky2_rx_clean(struct sky2_port *sky2) } #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) -static inline unsigned sky2_rx_size(const struct sky2_port *sky2) +static inline unsigned rx_size(const struct sky2_port *sky2) { return roundup(sky2->netdev->mtu + ETH_HLEN + 4, 8); } @@ -709,12 +734,18 @@ static inline unsigned sky2_rx_size(const struct sky2_port *sky2) * is not aligned. This means we can't use skb_reserve to align * the IP header. */ -static int sky2_rx_fill(struct sky2_port *sky2) +static int sky2_rx_start(struct sky2_port *sky2) { - unsigned i; - unsigned size = sky2_rx_size(sky2); + struct sky2_hw *hw = sky2->hw; + unsigned size = rx_size(sky2); + unsigned rxq = rxqaddr[sky2->port]; + int i; + + sky2->rx_put = sky2->rx_next = 0; + sky2_qset(hw, rxq, is_pciex(hw) ? 0x80 : 0x600); + sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); - pr_debug("rx_fill size=%d\n", size); + rx_set_checksum(sky2); for (i = 0; i < sky2->rx_pending; i++) { struct ring_info *re = sky2->rx_ring + i; @@ -722,12 +753,15 @@ static int sky2_rx_fill(struct sky2_port *sky2) if (!re->skb) goto nomem; - re->mapaddr = pci_map_single(sky2->hw->pdev, re->skb->data, + re->mapaddr = pci_map_single(hw->pdev, re->skb->data, size, PCI_DMA_FROMDEVICE); re->maplen = size; sky2_rx_add(sky2, re); } + /* Tell chip about available buffers */ + sky2_write16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX), sky2->rx_put); + sky2->rx_last_put = sky2_read16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX)); return 0; nomem: sky2_rx_clean(sky2); @@ -792,28 +826,14 @@ static int sky2_up(struct net_device *dev) sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), RB_RST_SET); - sky2_qset(hw, rxqaddr[port], is_pciex(hw) ? 0x80 : 0x600); sky2_qset(hw, txqaddr[port], 0x600); + sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, + TX_RING_SIZE - 1); - sky2->rx_put = sky2->rx_next = 0; - sky2_prefetch_init(hw, rxqaddr[port], sky2->rx_le_map, RX_LE_SIZE - 1); - - rx_set_checksum(sky2); - - err = sky2_rx_fill(sky2); + err = sky2_rx_start(sky2); if (err) goto err_out; - /* Give buffers to receiver */ - sky2_write16(sky2->hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_PUT_IDX), - sky2->rx_put); - sky2->rx_last_put = sky2_read16(sky2->hw, - Y2_QADDR(rxqaddr[port], - PREF_UNIT_PUT_IDX)); - - sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, - TX_RING_SIZE - 1); - /* Enable interrupts from phy/mac for port */ hw->intr_mask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2; sky2_write32(hw, B0_IMSK, hw->intr_mask); @@ -1076,7 +1096,6 @@ static int sky2_down(struct net_device *dev) struct sky2_hw *hw = sky2->hw; unsigned port = sky2->port; u16 ctrl; - int i; if (netif_msg_ifdown(sky2)) printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); @@ -1121,30 +1140,7 @@ static int sky2_down(struct net_device *dev) sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), RB_RST_SET); - /* - * The RX Stop command will not work for Yukon-2 if the BMU does not - * reach the end of packet and since we can't make sure that we have - * incoming data, we must reset the BMU while it is not doing a DMA - * transfer. Since it is possible that the RX path is still active, - * the RX RAM buffer will be stopped first, so any possible incoming - * data will not trigger a DMA. After the RAM buffer is stopped, the - * BMU is polled until any DMA in progress is ended and only then it - * will be reset. - */ - - /* disable the RAM Buffer receive queue */ - sky2_write8(hw, RB_ADDR(rxqaddr[port], RB_CTRL), RB_DIS_OP_MD); - - for (i = 0; i < 0xffff; i++) - if (sky2_read8(hw, RB_ADDR(rxqaddr[port], Q_RSL)) - == sky2_read8(hw, RB_ADDR(rxqaddr[port], Q_RL))) - break; - - sky2_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), - BMU_RST_SET | BMU_FIFO_RST); - /* reset the Rx prefetch unit */ - sky2_write32(hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_CTRL), - PREF_UNIT_RST_SET); + sky2_rx_stop(sky2); sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET); sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET); @@ -1379,19 +1375,44 @@ static void sky2_tx_timeout(struct net_device *dev) static int sky2_change_mtu(struct net_device *dev, int new_mtu) { - int err = 0; + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + int err; + u16 ctl, mode; if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) return -EINVAL; - if (netif_running(dev)) - sky2_down(dev); + if (!netif_running(dev)) { + dev->mtu = new_mtu; + return 0; + } + + local_irq_disable(); + sky2_write32(hw, B0_IMSK, 0); + + ctl = gma_read16(hw, sky2->port, GM_GP_CTRL); + gma_write16(hw, sky2->port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA); + sky2_rx_stop(sky2); + sky2_rx_clean(sky2); dev->mtu = new_mtu; + mode = DATA_BLIND_VAL(DATA_BLIND_DEF) | + GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); - if (netif_running(dev)) - err = sky2_up(dev); + if (dev->mtu > ETH_DATA_LEN) + mode |= GM_SMOD_JUMBO_ENA; + + gma_write16(hw, sky2->port, GM_SERIAL_MODE, mode); + + sky2_write8(hw, RB_ADDR(rxqaddr[sky2->port], RB_CTRL), RB_ENA_OP_MD); + + err = sky2_rx_start(sky2); + gma_write16(hw, sky2->port, GM_GP_CTRL, ctl); + sky2_write32(hw, B0_IMSK, hw->intr_mask); + sky2_read32(hw, B0_IMSK); + local_irq_enable(); return err; } @@ -1407,7 +1428,7 @@ static struct sk_buff *sky2_receive(struct sky2_hw *hw, unsigned port, struct sky2_port *sky2 = netdev_priv(dev); struct ring_info *re = sky2->rx_ring + sky2->rx_next; struct sk_buff *skb = NULL; - const unsigned int bufsize = sky2_rx_size(sky2); + const unsigned int bufsize = rx_size(sky2); if (unlikely(netif_msg_rx_status(sky2))) printk(KERN_DEBUG PFX "%s: rx slot %u status 0x%x len %d\n", -- cgit v1.1 From d11c13e752c4e34777d33579ee0378e0178ef52d Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Tue, 27 Sep 2005 15:02:56 -0700 Subject: [PATCH] sky2: cleanup interrupt processing The receive processing can be cleaned up by not using local variables to store checksum status, instead just put it directly onto the expected skb. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 65 +++++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 0cc5729..8527a49 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1040,13 +1040,14 @@ out_unlock: * NB: the hardware will tell us about partial completion of multi-part * buffers; these are defered until completion. */ -static void sky2_tx_complete(struct net_device *dev, u16 done) +static void sky2_tx_complete(struct sky2_port *sky2, u16 done) { - struct sky2_port *sky2 = netdev_priv(dev); + struct net_device *dev = sky2->netdev; unsigned i; - if (netif_msg_tx_done(sky2)) - printk(KERN_DEBUG "%s: tx done, upto %u\n", dev->name, done); + if (unlikely(netif_msg_tx_done(sky2))) + printk(KERN_DEBUG "%s: tx done, upto %u\n", + dev->name, done); spin_lock(&sky2->tx_lock); @@ -1086,7 +1087,7 @@ out: /* Cleanup all untransmitted buffers, assume transmitter not running */ static inline void sky2_tx_clean(struct sky2_port *sky2) { - sky2_tx_complete(sky2->netdev, sky2->tx_prod); + sky2_tx_complete(sky2, sky2->tx_prod); } /* Network shutdown */ @@ -1421,18 +1422,17 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) * For small packets or errors, just reuse existing skb. * For larger pakects, get new buffer. */ -static struct sk_buff *sky2_receive(struct sky2_hw *hw, unsigned port, +static struct sk_buff *sky2_receive(struct sky2_port *sky2, u16 length, u32 status) { - struct net_device *dev = hw->dev[port]; - struct sky2_port *sky2 = netdev_priv(dev); struct ring_info *re = sky2->rx_ring + sky2->rx_next; struct sk_buff *skb = NULL; + struct net_device *dev; const unsigned int bufsize = rx_size(sky2); if (unlikely(netif_msg_rx_status(sky2))) printk(KERN_DEBUG PFX "%s: rx slot %u status 0x%x len %d\n", - dev->name, sky2->rx_next, status, length); + sky2->netdev->name, sky2->rx_next, status, length); sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending; @@ -1451,6 +1451,8 @@ static struct sk_buff *sky2_receive(struct sky2_hw *hw, unsigned port, pci_dma_sync_single_for_cpu(sky2->hw->pdev, re->mapaddr, length, PCI_DMA_FROMDEVICE); memcpy(skb->data, re->skb->data, length); + skb->ip_summed = re->skb->ip_summed; + skb->csum = re->skb->csum; pci_dma_sync_single_for_device(sky2->hw->pdev, re->mapaddr, length, PCI_DMA_FROMDEVICE); } else { @@ -1471,12 +1473,14 @@ static struct sk_buff *sky2_receive(struct sky2_hw *hw, unsigned port, re->maplen = bufsize; } - skb->dev = dev; skb_put(skb, length); + dev = sky2->netdev; + skb->dev = dev; skb->protocol = eth_type_trans(skb, dev); dev->last_rx = jiffies; resubmit: + re->skb->ip_summed = CHECKSUM_NONE; sky2_rx_add(sky2, re); return skb; @@ -1517,59 +1521,46 @@ static inline u16 tx_index(u8 port, u32 status, u16 len) * Both ports share the same status interrupt, therefore there is only * one poll routine. */ -static int sky2_poll(struct net_device *dev, int *budget) +static int sky2_poll(struct net_device *dev0, int *budget) { - struct sky2_port *sky2 = netdev_priv(dev); - struct sky2_hw *hw = sky2->hw; - unsigned int to_do = min(dev->quota, *budget); + struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw; + unsigned int to_do = min(dev0->quota, *budget); unsigned int work_done = 0; u16 hwidx; - unsigned char summed[2] = { CHECKSUM_NONE, CHECKSUM_NONE }; - unsigned int csum[2]; hwidx = sky2_read16(hw, STAT_PUT_IDX); BUG_ON(hwidx >= STATUS_RING_SIZE); rmb(); while (hw->st_idx != hwidx && work_done < to_do) { struct sky2_status_le *le = hw->st_le + hw->st_idx; + struct sky2_port *sky2; struct sk_buff *skb; - u8 port; u32 status; u16 length; + BUG_ON(le->link >= hw->ports); + sky2 = netdev_priv(hw->dev[le->link]); status = le32_to_cpu(le->status); length = le16_to_cpu(le->length); - port = le->link; - - BUG_ON(port >= hw->ports || hw->dev[port] == NULL); switch (le->opcode & ~HW_OWNER) { case OP_RXSTAT: - skb = sky2_receive(hw, port, length, status); + skb = sky2_receive(sky2, length, status); if (likely(skb)) { - /* Add hw checksum if available */ - skb->ip_summed = summed[port]; - skb->csum = csum[port]; - netif_receive_skb(skb); ++work_done; } - - /* Clear for next packet */ - csum[port] = 0; - summed[port] = CHECKSUM_NONE; - break; case OP_RXCHKS: - /* Save computed checksum for next rx */ - csum[port] = le16_to_cpu(status & 0xffff); - summed[port] = CHECKSUM_HW; + skb = sky2->rx_ring[sky2->rx_next].skb; + skb->ip_summed = CHECKSUM_HW; + skb->csum = le16_to_cpu(status); break; case OP_TXINDEXLE: - sky2_tx_complete(hw->dev[port], - tx_index(port, status, length)); + sky2_tx_complete(sky2, + tx_index(sky2->port, status, length)); break; case OP_RXTIMESTAMP: @@ -1599,7 +1590,7 @@ static int sky2_poll(struct net_device *dev, int *budget) rx_set_put(hw->dev[1]); *budget -= work_done; - dev->quota -= work_done; + dev0->quota -= work_done; if (work_done < to_do) { /* * Another chip workaround, need to restart TX timer if status @@ -1613,7 +1604,7 @@ static int sky2_poll(struct net_device *dev, int *budget) hw->intr_mask |= Y2_IS_STAT_BMU; sky2_write32(hw, B0_IMSK, hw->intr_mask); sky2_read32(hw, B0_IMSK); - netif_rx_complete(dev); + netif_rx_complete(dev0); } return work_done >= to_do; -- cgit v1.1 From d1f1370863f7fa3d76dc7d7779debdda854a5a60 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Tue, 27 Sep 2005 15:02:57 -0700 Subject: [PATCH] sky2: add hardware VLAN acceleration support Use the hardware to do VLAN. Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 101 +++++++++++++++++++++++++++++++++++++++++++++-------- drivers/net/sky2.h | 6 ++++ 2 files changed, 93 insertions(+), 14 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 8527a49..6d9c1db 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -26,7 +26,6 @@ /* * TODO * - coalescing setting? - * - vlan support * * TOTEST * - variable ring size @@ -48,9 +47,14 @@ #include #include #include +#include #include +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) +#define SKY2_VLAN_TAG_USED 1 +#endif + #include "sky2.h" #define DRV_NAME "sky2" @@ -489,7 +493,7 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) /* Configure Rx MAC FIFO */ sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR); sky2_write16(hw, SK_REG(port, RX_GMF_CTRL_T), - GMF_OPER_ON | GMF_RX_F_FL_ON); + GMF_RX_CTRL_DEF); /* Flush Rx MAC FIFO on any flowcontrol or error */ reg = GMR_FS_ANY_ERR; @@ -717,6 +721,41 @@ static void sky2_rx_clean(struct sky2_port *sky2) } } +#ifdef SKY2_VLAN_TAG_USED +static void sky2_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + u16 port = sky2->port; + unsigned long flags; + + spin_lock_irqsave(&sky2->tx_lock, flags); + + sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_ON); + sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_ON); + sky2->vlgrp = grp; + + spin_unlock_irqrestore(&sky2->tx_lock, flags); +} + +static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + u16 port = sky2->port; + unsigned long flags; + + spin_lock_irqsave(&sky2->tx_lock, flags); + + sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_OFF); + sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_OFF); + if (sky2->vlgrp) + sky2->vlgrp->vlan_devices[vid] = NULL; + + spin_unlock_irqrestore(&sky2->tx_lock, flags); +} +#endif + #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) static inline unsigned rx_size(const struct sky2_port *sky2) { @@ -894,7 +933,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) { struct sky2_port *sky2 = netdev_priv(dev); struct sky2_hw *hw = sky2->hw; - struct sky2_tx_le *le; + struct sky2_tx_le *le = NULL; struct ring_info *re; unsigned long flags; unsigned i, len; @@ -961,8 +1000,23 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) sky2->tx_last_mss = mss; } - /* Handle TCP checksum offload */ ctrl = 0; +#ifdef SKY2_VLAN_TAG_USED + /* Add VLAN tag, can piggyback on LRGLEN or ADDR64 */ + if (sky2->vlgrp && vlan_tx_tag_present(skb)) { + if (!le) { + le = get_tx_le(sky2); + le->tx.addr = 0; + le->opcode = OP_VLAN|HW_OWNER; + le->ctrl = 0; + } else + le->opcode |= OP_VLAN; + le->length = cpu_to_be16(vlan_tx_tag_get(skb)); + ctrl |= INS_VLAN; + } +#endif + + /* Handle TCP checksum offload */ if (skb->ip_summed == CHECKSUM_HW) { u16 hdr = skb->h.raw - skb->data; u16 offset = hdr + skb->csum; @@ -1436,10 +1490,7 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending; - if (!(status & GMR_FS_RX_OK) - || (status & GMR_FS_ANY_ERR) - || (length << 16) != (status & GMR_FS_LEN) - || length > bufsize) + if (!(status & GMR_FS_RX_OK) || (status & GMR_FS_ANY_ERR)) goto error; if (length < RX_COPY_THRESHOLD) { @@ -1539,6 +1590,9 @@ static int sky2_poll(struct net_device *dev0, int *budget) u16 length; BUG_ON(le->link >= hw->ports); + if (!hw->dev[le->link]) + goto skip; + sky2 = netdev_priv(hw->dev[le->link]); status = le32_to_cpu(le->status); length = le16_to_cpu(le->length); @@ -1546,12 +1600,27 @@ static int sky2_poll(struct net_device *dev0, int *budget) switch (le->opcode & ~HW_OWNER) { case OP_RXSTAT: skb = sky2_receive(sky2, length, status); - if (likely(skb)) { + if (!skb) + break; +#ifdef SKY2_VLAN_TAG_USED + if (sky2->vlgrp && (status & GMR_FS_VLAN)) { + vlan_hwaccel_receive_skb(skb, + sky2->vlgrp, + be16_to_cpu(sky2->rx_tag)); + } else +#endif netif_receive_skb(skb); - ++work_done; - } break; +#ifdef SKY2_VLAN_TAG_USED + case OP_RXVLAN: + sky2->rx_tag = length; + break; + + case OP_RXCHKSVLAN: + sky2->rx_tag = length; + /* fall through */ +#endif case OP_RXCHKS: skb = sky2->rx_ring[sky2->rx_next].skb; skb->ip_summed = CHECKSUM_HW; @@ -1563,9 +1632,6 @@ static int sky2_poll(struct net_device *dev0, int *budget) tx_index(sky2->port, status, length)); break; - case OP_RXTIMESTAMP: - break; - default: if (net_ratelimit()) printk(KERN_WARNING PFX @@ -1574,6 +1640,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) break; } + skip: hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; if (hw->st_idx == hwidx) { hwidx = sky2_read16(hw, STAT_PUT_IDX); @@ -2615,6 +2682,12 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, dev->features |= NETIF_F_HIGHDMA; dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; +#ifdef SKY2_VLAN_TAG_USED + dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; + dev->vlan_rx_register = sky2_vlan_rx_register; + dev->vlan_rx_kill_vid = sky2_vlan_rx_kill_vid; +#endif + /* read the mac address */ memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN); diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 1a8a004..ac91d91 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -1578,6 +1578,8 @@ enum { GMF_RST_SET = 1<<0, /* Set GMAC FIFO Reset */ RX_GMF_FL_THR_DEF = 0xa, /* flush threshold (default) */ + + GMF_RX_CTRL_DEF = GMF_OPER_ON | GMF_RX_F_FL_ON, }; @@ -1826,6 +1828,10 @@ struct sky2_port { u16 rx_put; /* next le index to use */ u16 rx_pending; u16 rx_last_put; +#ifdef SKY2_VLAN_TAG_USED + u16 rx_tag; + struct vlan_group *vlgrp; +#endif dma_addr_t rx_le_map; dma_addr_t tx_le_map; -- cgit v1.1 From 5afa0a9cfb79556f45c02957e71a2ac48a5bb6a1 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Tue, 27 Sep 2005 15:03:00 -0700 Subject: [PATCH] sky2: explicit set power state Add better power management, and power down the chip on device removal Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 156 +++++++++++++++++++++++++++++++++++++---------------- drivers/net/sky2.h | 1 + 2 files changed, 112 insertions(+), 45 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 6d9c1db..1d00cdc 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -175,6 +175,91 @@ ready: return gma_read16(hw, port, GM_SMI_DATA); } +static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state) +{ + u16 power_control; + u32 reg1; + int vaux; + int ret = 0; + + pr_debug("sky2_set_power_state %d\n", state); + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); + + pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control); + vaux = (sky2_read8(hw, B0_CTST) & Y2_VAUX_AVAIL) && + (power_control & PCI_PM_CAP_PME_D3cold); + + pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control); + + power_control |= PCI_PM_CTRL_PME_STATUS; + power_control &= ~(PCI_PM_CTRL_STATE_MASK); + + switch (state) { + case PCI_D0: + /* switch power to VCC (WA for VAUX problem) */ + sky2_write8(hw, B0_POWER_CTRL, + PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_OFF | PC_VCC_ON); + + /* disable Core Clock Division, */ + sky2_write32(hw, B2_Y2_CLK_CTRL, Y2_CLK_DIV_DIS); + + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) + /* enable bits are inverted */ + sky2_write8(hw, B2_Y2_CLK_GATE, + Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS | + Y2_CLK_GAT_LNK1_DIS | Y2_PCI_CLK_LNK2_DIS | + Y2_COR_CLK_LNK2_DIS | Y2_CLK_GAT_LNK2_DIS); + else + sky2_write8(hw, B2_Y2_CLK_GATE, 0); + + /* Turn off phy power saving */ + pci_read_config_dword(hw->pdev, PCI_DEV_REG1, ®1); + reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); + + /* looks like this xl is back asswards .. */ + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) { + reg1 |= PCI_Y2_PHY1_COMA; + if (hw->ports > 1) + reg1 |= PCI_Y2_PHY2_COMA; + } + pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1); + break; + + case PCI_D3hot: + case PCI_D3cold: + /* Turn on phy power saving */ + pci_read_config_dword(hw->pdev, PCI_DEV_REG1, ®1); + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) + reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); + else + reg1 |= (PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); + pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1); + + if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) + sky2_write8(hw, B2_Y2_CLK_GATE, 0); + else + /* enable bits are inverted */ + sky2_write8(hw, B2_Y2_CLK_GATE, + Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS | + Y2_CLK_GAT_LNK1_DIS | Y2_PCI_CLK_LNK2_DIS | + Y2_COR_CLK_LNK2_DIS | Y2_CLK_GAT_LNK2_DIS); + + /* switch power to VAUX */ + if (vaux && state != PCI_D3cold) + sky2_write8(hw, B0_POWER_CTRL, + (PC_VAUX_ENA | PC_VCC_ENA | + PC_VAUX_ON | PC_VCC_OFF)); + break; + default: + printk(KERN_ERR PFX "Unknown power state %d\n", state); + ret = -1; + } + + pci_write_config_byte(hw->pdev, hw->pm_cap + PCI_PM_CTRL, power_control); + sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); + return ret; +} + static void sky2_phy_reset(struct sky2_hw *hw, unsigned port) { u16 reg; @@ -1869,7 +1954,7 @@ static inline u32 sky2_us2clk(const struct sky2_hw *hw, u32 us) static int sky2_reset(struct sky2_hw *hw) { - u32 ctst, power; + u32 ctst; u16 status; u8 t8, pmd_type; int i; @@ -1927,33 +2012,7 @@ static int sky2_reset(struct sky2_hw *hw) } hw->chip_rev = (sky2_read8(hw, B2_MAC_CFG) & CFG_CHIP_R_MSK) >> 4; - /* switch power to VCC (WA for VAUX problem) */ - sky2_write8(hw, B0_POWER_CTRL, - PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_OFF | PC_VCC_ON); - - /* disable Core Clock Division, */ - sky2_write32(hw, B2_Y2_CLK_CTRL, Y2_CLK_DIV_DIS); - - if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) - /* enable bits are inverted */ - sky2_write8(hw, B2_Y2_CLK_GATE, - Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS | - Y2_CLK_GAT_LNK1_DIS | Y2_PCI_CLK_LNK2_DIS | - Y2_COR_CLK_LNK2_DIS | Y2_CLK_GAT_LNK2_DIS); - else - sky2_write8(hw, B2_Y2_CLK_GATE, 0); - - /* Turn off phy power saving */ - pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &power); - power &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); - - /* looks like this xl is back asswards .. */ - if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) { - power |= PCI_Y2_PHY1_COMA; - if (hw->ports > 1) - power |= PCI_Y2_PHY2_COMA; - } - pci_write_config_dword(hw->pdev, PCI_DEV_REG1, power); + sky2_set_power_state(hw, PCI_D0); for (i = 0; i < hw->ports; i++) { sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET); @@ -2714,7 +2773,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, { struct net_device *dev, *dev1 = NULL; struct sky2_hw *hw; - int err, using_dac = 0; + int err, pm_cap, using_dac = 0; err = pci_enable_device(pdev); if (err) { @@ -2732,6 +2791,15 @@ static int __devinit sky2_probe(struct pci_dev *pdev, pci_set_master(pdev); + /* Find power-management capability. */ + pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); + if (pm_cap == 0) { + printk(KERN_ERR PFX "Cannot find PowerManagement capability, " + "aborting.\n"); + err = -EIO; + goto err_out_free_regions; + } + if (sizeof(dma_addr_t) > sizeof(u32)) { err = pci_set_dma_mask(pdev, DMA_64BIT_MASK); if (!err) @@ -2775,6 +2843,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, pci_name(pdev)); goto err_out_free_hw; } + hw->pm_cap = pm_cap; err = sky2_reset(hw); if (err) @@ -2861,8 +2930,10 @@ static void __devexit sky2_remove(struct pci_dev *pdev) unregister_netdev(dev0); sky2_write32(hw, B0_IMSK, 0); + sky2_set_power_state(hw, PCI_D3hot); sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); sky2_write8(hw, B0_CTST, CS_RST_SET); + sky2_read8(hw, B0_CTST); free_irq(pdev->irq, hw); pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma); @@ -2874,6 +2945,7 @@ static void __devexit sky2_remove(struct pci_dev *pdev) free_netdev(dev0); iounmap(hw->regs); kfree(hw); + pci_set_drvdata(pdev, NULL); } @@ -2881,28 +2953,21 @@ static void __devexit sky2_remove(struct pci_dev *pdev) static int sky2_suspend(struct pci_dev *pdev, pm_message_t state) { struct sky2_hw *hw = pci_get_drvdata(pdev); - int i, wol = 0; + int i; for (i = 0; i < 2; i++) { struct net_device *dev = hw->dev[i]; if (dev) { - struct sky2_port *sky2 = netdev_priv(dev); - if (netif_running(dev)) { - netif_carrier_off(dev); - sky2_down(dev); - } + if (!netif_running(dev)) + continue; + + sky2_down(dev); netif_device_detach(dev); - wol |= sky2->wol; } } - pci_save_state(pdev); - pci_enable_wake(pdev, pci_choose_state(pdev, state), wol); - pci_disable_device(pdev); - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - - return 0; + return sky2_set_power_state(hw, pci_choose_state(pdev, state)); } static int sky2_resume(struct pci_dev *pdev) @@ -2910,18 +2975,19 @@ static int sky2_resume(struct pci_dev *pdev) struct sky2_hw *hw = pci_get_drvdata(pdev); int i; - pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); pci_enable_wake(pdev, PCI_D0, 0); + sky2_set_power_state(hw, PCI_D0); sky2_reset(hw); for (i = 0; i < 2; i++) { struct net_device *dev = hw->dev[i]; if (dev) { - netif_device_attach(dev); - if (netif_running(dev)) + if (netif_running(dev)) { + netif_device_attach(dev); sky2_up(dev); + } } } return 0; diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index ac91d91..b1acdc6 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -1854,6 +1854,7 @@ struct sky2_hw { u32 intr_mask; struct net_device *dev[2]; + int pm_cap; u8 chip_id; u8 chip_rev; u8 copper; -- cgit v1.1 From 724bca3ca4d2126b67dd62e64d3f97805f9672de Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Tue, 27 Sep 2005 15:03:01 -0700 Subject: [PATCH] sky2: version 0.6 Verion number change, comment update and one simple optimization Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 1d00cdc..a6c7bb9 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -28,10 +28,8 @@ * - coalescing setting? * * TOTEST - * - variable ring size * - speed setting - * - power management - * - netpoll + * - suspend/resume */ #include @@ -58,7 +56,7 @@ #include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "0.5" +#define DRV_VERSION "0.6" #define PFX DRV_NAME " " /* @@ -1159,7 +1157,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) re->idx = sky2->tx_prod; le->ctrl |= EOP; - sky2_put_idx(sky2->hw, txqaddr[sky2->port], sky2->tx_prod, + sky2_put_idx(hw, txqaddr[sky2->port], sky2->tx_prod, &sky2->tx_last_put, TX_RING_SIZE); if (tx_avail(sky2) < MAX_SKB_TX_LE + 1) -- cgit v1.1 From 9a7ae0a978263adb7d6b630f0c3c37c0133325e0 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 27 Sep 2005 15:28:42 -0700 Subject: [PATCH] sky2: nway reset (BONUS FEATURE) Here is support for ethtool controlled renegotiation. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index a6c7bb9..57583fa 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -2300,6 +2300,24 @@ static u32 sky2_get_msglevel(struct net_device *netdev) return sky2->msg_enable; } +static int sky2_nway_reset(struct net_device *dev) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + + if (sky2->autoneg != AUTONEG_ENABLE) + return -EINVAL; + + netif_stop_queue(dev); + + spin_lock_irq(&hw->phy_lock); + sky2_phy_reset(hw, sky2->port); + sky2_phy_init(hw, sky2->port); + spin_unlock_irq(&hw->phy_lock); + + return 0; +} + static void sky2_phy_stats(struct sky2_port *sky2, u64 * data, unsigned count) { struct sky2_hw *hw = sky2->hw; @@ -2656,6 +2674,7 @@ static struct ethtool_ops sky2_ethtool_ops = { .get_drvinfo = sky2_get_drvinfo, .get_msglevel = sky2_get_msglevel, .set_msglevel = sky2_set_msglevel, + .nway_reset = sky2_nway_reset, .get_regs_len = sky2_get_regs_len, .get_regs = sky2_get_regs, .get_link = ethtool_op_get_link, -- cgit v1.1 From 2995bfb7855aabd493f840af361f3dd7d221caea Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 28 Sep 2005 10:01:03 -0700 Subject: [PATCH] sky2: add permanent address support. Add permanent address support Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 57583fa..06beb71 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -2698,6 +2698,7 @@ static struct ethtool_ops sky2_ethtool_ops = { .phys_id = sky2_phys_id, .get_stats_count = sky2_get_stats_count, .get_ethtool_stats = sky2_get_ethtool_stats, + .get_perm_addr = ethtool_op_get_perm_addr, }; /* Initialize network device */ @@ -2766,6 +2767,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, /* read the mac address */ memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN); + memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); /* device is off until link detection */ netif_carrier_off(dev); -- cgit v1.1 From 488f84fd901cd3386f5723a3573ea2e1f55af537 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 26 Oct 2005 12:16:07 -0700 Subject: [PATCH] sky2: remove unused definitions The sky2 driver has a lot of register definitions, that were copied over from the skge driver, for areas that don't exist on the Yukon2. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.h | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index b1acdc6..c15d464 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -85,21 +85,6 @@ enum csr_regs { B0_IMSK = 0x000c, B0_HWE_ISRC = 0x0010, B0_HWE_IMSK = 0x0014, - B0_SP_ISRC = 0x0018, - B0_XM1_IMSK = 0x0020, - B0_XM1_ISRC = 0x0028, - B0_XM1_PHY_ADDR = 0x0030, - B0_XM1_PHY_DATA = 0x0034, - B0_XM2_IMSK = 0x0040, - B0_XM2_ISRC = 0x0048, - B0_XM2_PHY_ADDR = 0x0050, - B0_XM2_PHY_DATA = 0x0054, - B0_R1_CSR = 0x0060, - B0_R2_CSR = 0x0064, - B0_XS1_CSR = 0x0068, - B0_XA1_CSR = 0x006c, - B0_XS2_CSR = 0x0070, - B0_XA2_CSR = 0x0074, /* Special ISR registers (Yukon-2 only) */ B0_Y2_SP_ISRC2 = 0x001c, @@ -116,36 +101,25 @@ enum csr_regs { B2_MAC_CFG = 0x011a, B2_CHIP_ID = 0x011b, B2_E_0 = 0x011c, - B2_E_1 = 0x011d, - B2_E_2 = 0x011e, + B2_Y2_CLK_GATE = 0x011d, B2_Y2_HW_RES = 0x011e, B2_E_3 = 0x011f, B2_Y2_CLK_CTRL = 0x0120, - B2_LD_CTRL = 0x0128, - B2_LD_TEST = 0x0129, + B2_TI_INI = 0x0130, B2_TI_VAL = 0x0134, B2_TI_CTRL = 0x0138, B2_TI_TEST = 0x0139, - B2_IRQM_INI = 0x0140, - B2_IRQM_VAL = 0x0144, - B2_IRQM_CTRL = 0x0148, - B2_IRQM_TEST = 0x0149, - B2_IRQM_MSK = 0x014c, - B2_IRQM_HWE_MSK = 0x0150, + B2_TST_CTRL1 = 0x0158, B2_TST_CTRL2 = 0x0159, B2_GP_IO = 0x015c, + B2_I2C_CTRL = 0x0160, B2_I2C_DATA = 0x0164, B2_I2C_IRQ = 0x0168, B2_I2C_SW = 0x016c, - B2_BSC_INI = 0x0170, - B2_BSC_VAL = 0x0174, - B2_BSC_CTRL = 0x0178, - B2_BSC_STAT = 0x0179, - B2_BSC_TST = 0x017a, B3_RAM_ADDR = 0x0180, B3_RAM_DATA_LO = 0x0184, @@ -220,8 +194,6 @@ enum { Y2_LED_STAT_ON = 1<<9, /* Status LED On (YUKON-2 only) */ Y2_LED_STAT_OFF = 1<<8, /* Status LED Off (YUKON-2 only) */ - CS_BUS_CLOCK = 1<<9, /* Bus Clock 0/1 = 33/66 MHz */ - CS_BUS_SLOT_SZ = 1<<8, /* Slot Size 0/1 = 32/64 bit slot */ CS_ST_SW_IRQ = 1<<7, /* Set IRQ SW Request */ CS_CL_SW_IRQ = 1<<6, /* Clear IRQ SW Request */ CS_STOP_DONE = 1<<5, /* Stop Master is finished */ -- cgit v1.1 From b2f5ad4fec76e78103e7fbb4e808587ea8a6d824 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 26 Oct 2005 12:16:08 -0700 Subject: [PATCH] sky2: use kzalloc Can use kzalloc to save a little code. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 06beb71..f5b101bf 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -910,12 +910,11 @@ static int sky2_up(struct net_device *dev) if (!sky2->tx_le) goto err_out; - sky2->tx_ring = kmalloc(TX_RING_SIZE * sizeof(struct ring_info), + sky2->tx_ring = kzalloc(TX_RING_SIZE * sizeof(struct ring_info), GFP_KERNEL); if (!sky2->tx_ring) goto err_out; sky2->tx_prod = sky2->tx_cons = 0; - memset(sky2->tx_ring, 0, TX_RING_SIZE * sizeof(struct ring_info)); sky2->rx_le = pci_alloc_consistent(hw->pdev, RX_LE_BYTES, &sky2->rx_le_map); @@ -923,7 +922,7 @@ static int sky2_up(struct net_device *dev) goto err_out; memset(sky2->rx_le, 0, RX_LE_BYTES); - sky2->rx_ring = kmalloc(sky2->rx_pending * sizeof(struct ring_info), + sky2->rx_ring = kzalloc(sky2->rx_pending * sizeof(struct ring_info), GFP_KERNEL); if (!sky2->rx_ring) goto err_out; -- cgit v1.1 From d571b694df3ebc66f7a4c507f5a32579e43c2294 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 26 Oct 2005 12:16:09 -0700 Subject: [PATCH] sky2: spelling fixes Cosmetic cleanup's: mostly spelling fixes etc. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 32 ++++++++++++++++---------------- drivers/net/sky2.h | 10 +++++----- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index f5b101bf..92d69ff 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -214,7 +214,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state) pci_read_config_dword(hw->pdev, PCI_DEV_REG1, ®1); reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD); - /* looks like this xl is back asswards .. */ + /* looks like this XL is back asswards .. */ if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) { reg1 |= PCI_Y2_PHY1_COMA; if (hw->ports > 1) @@ -461,7 +461,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) if (ledover) gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); - /* Enable phy interrupt on autonegotiation complete (or link up) */ + /* Enable phy interrupt on auto-negotiation complete (or link up) */ if (sky2->autoneg == AUTONEG_ENABLE) gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_COMPL); else @@ -578,10 +578,10 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) sky2_write16(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RX_CTRL_DEF); - /* Flush Rx MAC FIFO on any flowcontrol or error */ + /* Flush Rx MAC FIFO on any flow control or error */ reg = GMR_FS_ANY_ERR; if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev <= 1) - reg = 0; /* WA Dev #4115 */ + reg = 0; /* WA dev #4.115 */ sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), reg); /* Set threshold to 0xa (64 bytes) @@ -662,7 +662,7 @@ static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2) } /* - * This is a workaround code taken from syskonnect sk98lin driver + * This is a workaround code taken from SysKonnect sk98lin driver * to deal with chip bug on Yukon EC rev 0 in the wraparound case. */ static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, @@ -785,7 +785,7 @@ stopped: sky2_write32(hw, Y2_QADDR(rxq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); } -/* Cleanout receive buffer area, assumes receiver hardware stopped */ +/* Clean out receive buffer area, assumes receiver hardware stopped */ static void sky2_rx_clean(struct sky2_port *sky2) { unsigned i; @@ -1174,7 +1174,7 @@ out_unlock: * Free ring elements from starting at tx_cons until "done" * * NB: the hardware will tell us about partial completion of multi-part - * buffers; these are defered until completion. + * buffers; these are deferred until completion. */ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) { @@ -1182,7 +1182,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) unsigned i; if (unlikely(netif_msg_tx_done(sky2))) - printk(KERN_DEBUG "%s: tx done, upto %u\n", + printk(KERN_DEBUG "%s: tx done, up to %u\n", dev->name, done); spin_lock(&sky2->tx_lock); @@ -1282,7 +1282,7 @@ static int sky2_down(struct net_device *dev) sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET); sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET); - /* turn off led's */ + /* turn off LED's */ sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); sky2_tx_clean(sky2); @@ -1364,7 +1364,7 @@ static void sky2_link_up(struct sky2_port *sky2) if (netif_msg_link(sky2)) printk(KERN_INFO PFX - "%s: Link is up at %d Mbps, %s duplex, flowcontrol %s\n", + "%s: Link is up at %d Mbps, %s duplex, flow control %s\n", sky2->netdev->name, sky2->speed, sky2->duplex == DUPLEX_FULL ? "full" : "half", (sky2->tx_pause && sky2->rx_pause) ? "both" : @@ -1451,7 +1451,7 @@ static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux) } /* - * Interrrupt from PHY are handled in tasklet (soft irq) + * Interrupt from PHY are handled in tasklet (soft irq) * because accessing phy registers requires spin wait which might * cause excess interrupt latency. */ @@ -1556,7 +1556,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) /* * Receive one packet. * For small packets or errors, just reuse existing skb. - * For larger pakects, get new buffer. + * For larger packets, get new buffer. */ static struct sk_buff *sky2_receive(struct sky2_port *sky2, u16 length, u32 status) @@ -1818,7 +1818,7 @@ static void sky2_hw_intr(struct sky2_hw *hw) } if (status & Y2_IS_PCI_EXP) { - /* PCI-Express uncorrectable Error occured */ + /* PCI-Express uncorrectable Error occurred */ u32 pex_err; pci_read_config_dword(hw->pdev, PEX_UNC_ERR_STAT, &pex_err); @@ -2113,7 +2113,7 @@ static int sky2_reset(struct sky2_hw *hw) if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0) sky2_write8(hw, STAT_FIFO_ISR_WM, 0x10); - else /* WA 4109 */ + else /* WA dev 4.109 */ sky2_write8(hw, STAT_FIFO_ISR_WM, 0x04); sky2_write32(hw, STAT_ISR_TIMER_INI, 0x0190); @@ -2420,7 +2420,7 @@ static void sky2_set_multicast(struct net_device *dev) reg = gma_read16(hw, port, GM_RX_CTRL); reg |= GM_RXCR_UCF_ENA; - if (dev->flags & IFF_PROMISC) /* promiscious */ + if (dev->flags & IFF_PROMISC) /* promiscuous */ reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA); else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > 16) /* all multicast */ memset(filter, 0xff, sizeof(filter)); @@ -2833,7 +2833,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, } } #ifdef __BIG_ENDIAN - /* byte swap decriptors in hardware */ + /* byte swap descriptors in hardware */ { u32 reg; diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index c15d464..629d08f 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -356,11 +356,11 @@ enum { /* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */ enum { - Y2_STATUS_LNK2_INAC = 1<<7, /* Status Link 2 inactiv (0 = activ) */ + Y2_STATUS_LNK2_INAC = 1<<7, /* Status Link 2 inactive (0 = active) */ Y2_CLK_GAT_LNK2_DIS = 1<<6, /* Disable clock gating Link 2 */ Y2_COR_CLK_LNK2_DIS = 1<<5, /* Disable Core clock Link 2 */ Y2_PCI_CLK_LNK2_DIS = 1<<4, /* Disable PCI clock Link 2 */ - Y2_STATUS_LNK1_INAC = 1<<3, /* Status Link 1 inactiv (0 = activ) */ + Y2_STATUS_LNK1_INAC = 1<<3, /* Status Link 1 inactive (0 = active) */ Y2_CLK_GAT_LNK1_DIS = 1<<2, /* Disable clock gating Link 1 */ Y2_COR_CLK_LNK1_DIS = 1<<1, /* Disable Core clock Link 1 */ Y2_PCI_CLK_LNK1_DIS = 1<<0, /* Disable PCI clock Link 1 */ @@ -410,7 +410,7 @@ enum { #define RAM_ADR_RAN 0x0007ffffL /* Bit 18.. 0: RAM Address Range */ /* RAM Interface Registers */ -/* B3_RI_CTRL 16 bit RAM Iface Control Register */ +/* B3_RI_CTRL 16 bit RAM Interface Control Register */ enum { RI_CLR_RD_PERR = 1<<9, /* Clear IRQ RAM Read Parity Err */ RI_CLR_WR_PERR = 1<<8, /* Clear IRQ RAM Write Parity Err*/ @@ -613,7 +613,7 @@ enum { BMU_ENA_RX_CHKSUM = 1<<13, /* Enable Rx TCP/IP Checksum Check */ BMU_DIS_RX_CHKSUM = 1<<12, /* Disable Rx TCP/IP Checksum Check */ BMU_CLR_IRQ_PAR = 1<<11, /* Clear IRQ on Parity errors (Rx) */ - BMU_CLR_IRQ_TCP = 1<<11, /* Clear IRQ on TCP segmen. error (Tx) */ + BMU_CLR_IRQ_TCP = 1<<11, /* Clear IRQ on TCP segment. error (Tx) */ BMU_CLR_IRQ_CHK = 1<<10, /* Clear IRQ Check */ BMU_STOP = 1<<9, /* Stop Rx/Tx Queue */ BMU_START = 1<<8, /* Start Rx/Tx Queue */ @@ -636,7 +636,7 @@ enum { enum { BMU_TX_IPIDINCR_ON = 1<<13, /* Enable IP ID Increment */ BMU_TX_IPIDINCR_OFF = 1<<12, /* Disable IP ID Increment */ - BMU_TX_CLR_IRQ_TCP = 1<<11, /* Clear IRQ on TCP segm. length mism. */ + BMU_TX_CLR_IRQ_TCP = 1<<11, /* Clear IRQ on TCP segment length mismatch */ }; /* Queue Prefetch Unit Offsets, use Y2_QADDR() to address (Yukon-2 only)*/ -- cgit v1.1 From bea86103313fae2e29f2d6eb9a4bd7cbeabd4d32 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 26 Oct 2005 12:16:10 -0700 Subject: [PATCH] sky2: fix NAPI and receive handling Speed up the receive and interrupt processing and eliminate a couple of race conditions from NAPI code. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 63 ++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 92d69ff..a85a8d1 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -76,7 +76,7 @@ #define RX_LE_SIZE 256 #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) -#define RX_MAX_PENDING (RX_LE_SIZE/2 - 1) +#define RX_MAX_PENDING (RX_LE_SIZE/2 - 2) #define RX_DEF_PENDING 128 #define RX_COPY_THRESHOLD 256 @@ -690,7 +690,7 @@ static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, setnew: sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx); } - *last = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX)); + *last = idx; } @@ -723,15 +723,6 @@ static inline void sky2_rx_add(struct sky2_port *sky2, struct ring_info *re) le->opcode = OP_PACKET | HW_OWNER; } -/* Tell receiver about new buffers. */ -static inline void rx_set_put(struct net_device *dev) -{ - struct sky2_port *sky2 = netdev_priv(dev); - - if (sky2->rx_last_put != sky2->rx_put) - sky2_put_idx(sky2->hw, rxqaddr[sky2->port], sky2->rx_put, - &sky2->rx_last_put, RX_LE_SIZE); -} /* Tell chip where to start receive checksum. * Actually has two checksums, but set both same to avoid possible byte @@ -1616,6 +1607,10 @@ resubmit: re->skb->ip_summed = CHECKSUM_NONE; sky2_rx_add(sky2, re); + /* Tell receiver about new buffers. */ + sky2_put_idx(sky2->hw, rxqaddr[sky2->port], sky2->rx_put, + &sky2->rx_last_put, RX_LE_SIZE); + return skb; error: @@ -1664,16 +1659,26 @@ static int sky2_poll(struct net_device *dev0, int *budget) hwidx = sky2_read16(hw, STAT_PUT_IDX); BUG_ON(hwidx >= STATUS_RING_SIZE); rmb(); - while (hw->st_idx != hwidx && work_done < to_do) { + + do { struct sky2_status_le *le = hw->st_le + hw->st_idx; struct sky2_port *sky2; struct sk_buff *skb; u32 status; u16 length; - BUG_ON(le->link >= hw->ports); - if (!hw->dev[le->link]) - goto skip; + /* Are we done yet? */ + if (hw->st_idx == hwidx) { + sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); + hwidx = sky2_read16(hw, STAT_PUT_IDX); + if (hwidx == hw->st_idx) + break; + } + + hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; + prefetch(&hw->st_le[hw->st_idx]); + + BUG_ON(le->link >= hw->ports || !hw->dev[le->link]); sky2 = netdev_priv(hw->dev[le->link]); status = le32_to_cpu(le->status); @@ -1692,6 +1697,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) } else #endif netif_receive_skb(skb); + ++work_done; break; #ifdef SKY2_VLAN_TAG_USED @@ -1722,22 +1728,11 @@ static int sky2_poll(struct net_device *dev0, int *budget) break; } - skip: - hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; - if (hw->st_idx == hwidx) { - hwidx = sky2_read16(hw, STAT_PUT_IDX); - rmb(); - } - } + le->opcode = 0; /* paranoia */ + } while (work_done < to_do); mmiowb(); - if (hw->dev[0]) - rx_set_put(hw->dev[0]); - - if (hw->dev[1]) - rx_set_put(hw->dev[1]); - *budget -= work_done; dev0->quota -= work_done; if (work_done < to_do) { @@ -1750,10 +1745,10 @@ static int sky2_poll(struct net_device *dev0, int *budget) sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START); } + netif_rx_complete(dev0); hw->intr_mask |= Y2_IS_STAT_BMU; sky2_write32(hw, B0_IMSK, hw->intr_mask); sky2_read32(hw, B0_IMSK); - netif_rx_complete(dev0); } return work_done >= to_do; @@ -1880,6 +1875,7 @@ static void sky2_phy_intr(struct sky2_hw *hw, unsigned port) static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs) { struct sky2_hw *hw = dev_id; + struct net_device *dev0 = hw->dev[0]; u32 status; status = sky2_read32(hw, B0_Y2_SP_ISRC2); @@ -1890,12 +1886,13 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs) sky2_hw_intr(hw); /* Do NAPI for Rx and Tx status */ - if ((status & Y2_IS_STAT_BMU) && netif_rx_schedule_test(hw->dev[0])) { - sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); - + if (status & Y2_IS_STAT_BMU) { hw->intr_mask &= ~Y2_IS_STAT_BMU; sky2_write32(hw, B0_IMSK, hw->intr_mask); - __netif_rx_schedule(hw->dev[0]); + prefetch(&hw->st_le[hw->st_idx]); + + if (netif_rx_schedule_test(dev0)) + __netif_rx_schedule(dev0); } if (status & Y2_IS_IRQ_PHY1) -- cgit v1.1 From f1e691a24955ea987f021f378324fb5003b1b208 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 26 Oct 2005 12:16:11 -0700 Subject: [PATCH] sky2: version 0.7 Change version number Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index a85a8d1..e08695a 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -56,7 +56,7 @@ #include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "0.6" +#define DRV_VERSION "0.7" #define PFX DRV_NAME " " /* -- cgit v1.1 From ea37ccea66e6bdd9f3571418b6461850088c114e Mon Sep 17 00:00:00 2001 From: Daniele Venzano Date: Tue, 11 Oct 2005 09:44:30 +0200 Subject: [PATCH] Add Wake on LAN support to sis900 (2) Sorry, but that day I had smoked somthing too heavy for me, the patch didn't apply. Here's a new one. The patch availble below adds support for Wake on LAN to the sis900 driver. Some register addresses were added to sis900.h and two new functions were implemented in sis900.c. WoL status is controlled by ethtool. Patch is against 2.6.13. Comments are welcome, but also consider for inclusion in the -mm series. Signed-off-by: Daniele Venzano -- Signed-off-by: Jeff Garzik --- drivers/net/sis900.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++-- drivers/net/sis900.h | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c index 1d4d886..3d95fa2 100644 --- a/drivers/net/sis900.c +++ b/drivers/net/sis900.c @@ -1,6 +1,6 @@ /* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux. Copyright 1999 Silicon Integrated System Corporation - Revision: 1.08.08 Jan. 22 2005 + Revision: 1.08.09 Sep. 19 2005 Modified from the driver which is originally written by Donald Becker. @@ -17,6 +17,7 @@ SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution, preliminary Rev. 1.0 Jan. 18, 1998 + Rev 1.08.09 Sep. 19 2005 Daniele Venzano add Wake on LAN support Rev 1.08.08 Jan. 22 2005 Daniele Venzano use netif_msg for debugging messages Rev 1.08.07 Nov. 2 2003 Daniele Venzano add suspend/resume support Rev 1.08.06 Sep. 24 2002 Mufasa Yang bug fix for Tx timeout & add SiS963 support @@ -76,7 +77,7 @@ #include "sis900.h" #define SIS900_MODULE_NAME "sis900" -#define SIS900_DRV_VERSION "v1.08.08 Jan. 22 2005" +#define SIS900_DRV_VERSION "v1.08.09 Sep. 19 2005" static char version[] __devinitdata = KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n"; @@ -538,6 +539,11 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev, printk("%2.2x:", (u8)net_dev->dev_addr[i]); printk("%2.2x.\n", net_dev->dev_addr[i]); + /* Detect Wake on Lan support */ + ret = inl(CFGPMC & PMESP); + if (netif_msg_probe(sis_priv) && (ret & PME_D3C) == 0) + printk(KERN_INFO "%s: Wake on LAN only available from suspend to RAM.", net_dev->name); + return 0; err_unmap_rx: @@ -2015,6 +2021,67 @@ static int sis900_nway_reset(struct net_device *net_dev) return mii_nway_restart(&sis_priv->mii_info); } +/** + * sis900_set_wol - Set up Wake on Lan registers + * @net_dev: the net device to probe + * @wol: container for info passed to the driver + * + * Process ethtool command "wol" to setup wake on lan features. + * SiS900 supports sending WoL events if a correct packet is received, + * but there is no simple way to filter them to only a subset (broadcast, + * multicast, unicast or arp). + */ + +static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol) +{ + struct sis900_private *sis_priv = net_dev->priv; + long pmctrl_addr = net_dev->base_addr + pmctrl; + u32 cfgpmcsr = 0, pmctrl_bits = 0; + + if (wol->wolopts == 0) { + pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr); + cfgpmcsr |= ~PME_EN; + pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr); + outl(pmctrl_bits, pmctrl_addr); + if (netif_msg_wol(sis_priv)) + printk(KERN_DEBUG "%s: Wake on LAN disabled\n", net_dev->name); + return 0; + } + + if (wol->wolopts & (WAKE_MAGICSECURE | WAKE_UCAST | WAKE_MCAST + | WAKE_BCAST | WAKE_ARP)) + return -EINVAL; + + if (wol->wolopts & WAKE_MAGIC) + pmctrl_bits |= MAGICPKT; + if (wol->wolopts & WAKE_PHY) + pmctrl_bits |= LINKON; + + outl(pmctrl_bits, pmctrl_addr); + + pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr); + cfgpmcsr |= PME_EN; + pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr); + if (netif_msg_wol(sis_priv)) + printk(KERN_DEBUG "%s: Wake on LAN enabled\n", net_dev->name); + + return 0; +} + +static void sis900_get_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol) +{ + long pmctrl_addr = net_dev->base_addr + pmctrl; + u32 pmctrl_bits; + + pmctrl_bits = inl(pmctrl_addr); + if (pmctrl_bits & MAGICPKT) + wol->wolopts |= WAKE_MAGIC; + if (pmctrl_bits & LINKON) + wol->wolopts |= WAKE_PHY; + + wol->supported = (WAKE_PHY | WAKE_MAGIC); +} + static struct ethtool_ops sis900_ethtool_ops = { .get_drvinfo = sis900_get_drvinfo, .get_msglevel = sis900_get_msglevel, @@ -2023,6 +2090,8 @@ static struct ethtool_ops sis900_ethtool_ops = { .get_settings = sis900_get_settings, .set_settings = sis900_set_settings, .nway_reset = sis900_nway_reset, + .get_wol = sis900_get_wol, + .set_wol = sis900_set_wol }; /** diff --git a/drivers/net/sis900.h b/drivers/net/sis900.h index de3c067..4233ea5 100644 --- a/drivers/net/sis900.h +++ b/drivers/net/sis900.h @@ -33,6 +33,7 @@ enum sis900_registers { rxcfg=0x34, //Receive Configuration Register flctrl=0x38, //Flow Control Register rxlen=0x3c, //Receive Packet Length Register + cfgpmcsr=0x44, //Configuration Power Management Control/Status Register rfcr=0x48, //Receive Filter Control Register rfdr=0x4C, //Receive Filter Data Register pmctrl=0xB0, //Power Management Control Register @@ -140,6 +141,50 @@ enum sis96x_eeprom_command { EEREQ = 0x00000400, EEDONE = 0x00000200, EEGNT = 0x00000100 }; +/* PCI Registers */ +enum sis900_pci_registers { + CFGPMC = 0x40, + CFGPMCSR = 0x44 +}; + +/* Power management capabilities bits */ +enum sis900_cfgpmc_register_bits { + PMVER = 0x00070000, + DSI = 0x00100000, + PMESP = 0xf8000000 +}; + +enum sis900_pmesp_bits { + PME_D0 = 0x1, + PME_D1 = 0x2, + PME_D2 = 0x4, + PME_D3H = 0x8, + PME_D3C = 0x10 +}; + +/* Power management control/status bits */ +enum sis900_cfgpmcsr_register_bits { + PMESTS = 0x00004000, + PME_EN = 0x00000100, // Power management enable + PWR_STA = 0x00000003 // Current power state +}; + +/* Wake-on-LAN support. */ +enum sis900_power_management_control_register_bits { + LINKLOSS = 0x00000001, + LINKON = 0x00000002, + MAGICPKT = 0x00000400, + ALGORITHM = 0x00000800, + FRM1EN = 0x00100000, + FRM2EN = 0x00200000, + FRM3EN = 0x00400000, + FRM1ACS = 0x01000000, + FRM2ACS = 0x02000000, + FRM3ACS = 0x04000000, + WAKEALL = 0x40000000, + GATECLK = 0x80000000 +}; + /* Management Data I/O (mdio) frame */ #define MIIread 0x6000 #define MIIwrite 0x5002 -- cgit v1.1 From a15e0384dd22ee08f56d62761ce9d770488f6f4e Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 31 Oct 2005 07:59:37 -0500 Subject: [netdrvr 8139too] replace hand-crafted kernel thread with workqueue Gone are the days when 8139too was a shining example of how to use kernel threads. Delayed workqueues are easier, and map precisely to our task: running code from a kernel thread, after a periodic sleep. --- drivers/net/8139too.c | 87 +++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 54 deletions(-) diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 30bee11..9de58e2 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c @@ -590,12 +590,12 @@ struct rtl8139_private { spinlock_t lock; spinlock_t rx_lock; chip_t chipset; - pid_t thr_pid; - wait_queue_head_t thr_wait; - struct completion thr_exited; u32 rx_config; struct rtl_extra_stats xstats; - int time_to_die; + + struct work_struct thread; + long time_to_die; /* -1 no thr, 0 thr active, 1 thr cancel */ + struct mii_if_info mii; unsigned int regs_len; unsigned long fifo_copy_timeout; @@ -620,7 +620,7 @@ static int rtl8139_open (struct net_device *dev); static int mdio_read (struct net_device *dev, int phy_id, int location); static void mdio_write (struct net_device *dev, int phy_id, int location, int val); -static void rtl8139_start_thread(struct net_device *dev); +static void rtl8139_start_thread(struct rtl8139_private *tp); static void rtl8139_tx_timeout (struct net_device *dev); static void rtl8139_init_ring (struct net_device *dev); static int rtl8139_start_xmit (struct sk_buff *skb, @@ -637,6 +637,7 @@ static struct net_device_stats *rtl8139_get_stats (struct net_device *dev); static void rtl8139_set_rx_mode (struct net_device *dev); static void __set_rx_mode (struct net_device *dev); static void rtl8139_hw_start (struct net_device *dev); +static void rtl8139_thread (void *_data); static struct ethtool_ops rtl8139_ethtool_ops; /* write MMIO register, with flush */ @@ -1007,8 +1008,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev, (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1)); spin_lock_init (&tp->lock); spin_lock_init (&tp->rx_lock); - init_waitqueue_head (&tp->thr_wait); - init_completion (&tp->thr_exited); + INIT_WORK(&tp->thread, rtl8139_thread, dev); tp->mii.dev = dev; tp->mii.mdio_read = mdio_read; tp->mii.mdio_write = mdio_write; @@ -1345,7 +1345,7 @@ static int rtl8139_open (struct net_device *dev) dev->irq, RTL_R8 (MediaStatus), tp->mii.full_duplex ? "full" : "half"); - rtl8139_start_thread(dev); + rtl8139_start_thread(tp); return 0; } @@ -1594,56 +1594,45 @@ static inline void rtl8139_thread_iter (struct net_device *dev, RTL_R8 (Config1)); } -static int rtl8139_thread (void *data) +static void rtl8139_thread (void *_data) { - struct net_device *dev = data; + struct net_device *dev = _data; struct rtl8139_private *tp = netdev_priv(dev); - unsigned long timeout; - - daemonize("%s", dev->name); - allow_signal(SIGTERM); - - while (1) { - timeout = next_tick; - do { - timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout); - /* make swsusp happy with our thread */ - try_to_freeze(); - } while (!signal_pending (current) && (timeout > 0)); - if (signal_pending (current)) { - flush_signals(current); - } - - if (tp->time_to_die) - break; - - if (rtnl_lock_interruptible ()) - break; + if ((tp->time_to_die == 0) && + (rtnl_lock_interruptible() == 0)) { rtl8139_thread_iter (dev, tp, tp->mmio_addr); rtnl_unlock (); } - complete_and_exit (&tp->thr_exited, 0); + if (tp->time_to_die == 0) + schedule_delayed_work(&tp->thread, next_tick); } -static void rtl8139_start_thread(struct net_device *dev) +static void rtl8139_start_thread(struct rtl8139_private *tp) { - struct rtl8139_private *tp = netdev_priv(dev); - - tp->thr_pid = -1; tp->twistie = 0; - tp->time_to_die = 0; + tp->time_to_die = -1; if (tp->chipset == CH_8139_K) tp->twistie = 1; else if (tp->drv_flags & HAS_LNK_CHNG) return; - tp->thr_pid = kernel_thread(rtl8139_thread, dev, CLONE_FS|CLONE_FILES); - if (tp->thr_pid < 0) { - printk (KERN_WARNING "%s: unable to start kernel thread\n", - dev->name); - } + tp->time_to_die = 0; + + schedule_delayed_work(&tp->thread, next_tick); +} + +static void rtl8139_stop_thread(struct rtl8139_private *tp) +{ + if (tp->time_to_die < 0) + return; + + tp->time_to_die = 1; + wmb(); + + if (cancel_delayed_work(&tp->thread) == 0) + flush_scheduled_work(); } static inline void rtl8139_tx_clear (struct rtl8139_private *tp) @@ -2224,22 +2213,12 @@ static int rtl8139_close (struct net_device *dev) { struct rtl8139_private *tp = netdev_priv(dev); void __iomem *ioaddr = tp->mmio_addr; - int ret = 0; unsigned long flags; netif_stop_queue (dev); - if (tp->thr_pid >= 0) { - tp->time_to_die = 1; - wmb(); - ret = kill_proc (tp->thr_pid, SIGTERM, 1); - if (ret) { - printk (KERN_ERR "%s: unable to signal thread\n", dev->name); - return ret; - } - wait_for_completion (&tp->thr_exited); - } - + rtl8139_stop_thread(tp); + if (netif_msg_ifdown(tp)) printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n", dev->name, RTL_R16 (IntrStatus)); -- cgit v1.1 From 38b492a21ac1b0f0a5ebed69c9e2ee6f4202f574 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Fri, 4 Nov 2005 22:36:28 -0500 Subject: [netdrvr 8139too] use cancel_rearming_delayed_work() to cancel thread Noted by Herbert Xu. --- drivers/net/8139too.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 9de58e2..bcea9d4 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c @@ -586,7 +586,8 @@ struct rtl8139_private { dma_addr_t tx_bufs_dma; signed char phys[4]; /* MII device addresses. */ char twistie, twist_row, twist_col; /* Twister tune state. */ - unsigned int default_port:4; /* Last dev->if_port value. */ + unsigned int default_port : 4; /* Last dev->if_port value. */ + unsigned int have_thread : 1; spinlock_t lock; spinlock_t rx_lock; chip_t chipset; @@ -594,7 +595,6 @@ struct rtl8139_private { struct rtl_extra_stats xstats; struct work_struct thread; - long time_to_die; /* -1 no thr, 0 thr active, 1 thr cancel */ struct mii_if_info mii; unsigned int regs_len; @@ -1599,40 +1599,33 @@ static void rtl8139_thread (void *_data) struct net_device *dev = _data; struct rtl8139_private *tp = netdev_priv(dev); - if ((tp->time_to_die == 0) && - (rtnl_lock_interruptible() == 0)) { + if (rtnl_lock_interruptible() == 0) { rtl8139_thread_iter (dev, tp, tp->mmio_addr); rtnl_unlock (); } - if (tp->time_to_die == 0) - schedule_delayed_work(&tp->thread, next_tick); + schedule_delayed_work(&tp->thread, next_tick); } static void rtl8139_start_thread(struct rtl8139_private *tp) { tp->twistie = 0; - tp->time_to_die = -1; if (tp->chipset == CH_8139_K) tp->twistie = 1; else if (tp->drv_flags & HAS_LNK_CHNG) return; - tp->time_to_die = 0; + tp->have_thread = 1; schedule_delayed_work(&tp->thread, next_tick); } static void rtl8139_stop_thread(struct rtl8139_private *tp) { - if (tp->time_to_die < 0) - return; - - tp->time_to_die = 1; - wmb(); - - if (cancel_delayed_work(&tp->thread) == 0) - flush_scheduled_work(); + if (tp->have_thread) { + cancel_rearming_delayed_work(&tp->thread); + tp->have_thread = 0; + } } static inline void rtl8139_tx_clear (struct rtl8139_private *tp) -- cgit v1.1 From 96a71d52bb91d9b386a60f904956420f98946dd3 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Fri, 4 Nov 2005 22:46:35 -0500 Subject: [netdrvr 8139too] use rtnl_shlock_nowait() rather than rtnl_lock_interruptible() --- drivers/net/8139too.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index bcea9d4..120baaa 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c @@ -1599,7 +1599,7 @@ static void rtl8139_thread (void *_data) struct net_device *dev = _data; struct rtl8139_private *tp = netdev_priv(dev); - if (rtnl_lock_interruptible() == 0) { + if (rtnl_shlock_nowait() == 0) { rtl8139_thread_iter (dev, tp, tp->mmio_addr); rtnl_unlock (); } -- cgit v1.1 From 7945619794314414a5c44df11fca4d3f2a3389cf Mon Sep 17 00:00:00 2001 From: Jody McIntyre Date: Mon, 7 Nov 2005 06:29:39 -0500 Subject: sbp2_command_orb_lock must be held when accessing the _orb_inuse list. Fixes an oops in sbp2util_find_command_for_SCpnt after sbp2scsi_abort: https://bugzilla.novell.com/show_bug.cgi?id=113734 Signed-off-by: Jody McIntyre Signed-off-by: Stefan Richter --- drivers/ieee1394/sbp2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 12cec7c..f7e18cc 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -2350,6 +2350,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest struct scsi_cmnd *SCpnt = NULL; u32 scsi_status = SBP2_SCSI_STATUS_GOOD; struct sbp2_command_info *command; + unsigned long flags; SBP2_DEBUG("sbp2_handle_status_write"); @@ -2451,9 +2452,11 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest * null out last orb so that next time around we write directly to the orb pointer... * Quick start saves one 1394 bus transaction. */ + spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); if (list_empty(&scsi_id->sbp2_command_orb_inuse)) { scsi_id->last_orb = NULL; } + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); } else { @@ -2563,9 +2566,11 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id struct sbp2scsi_host_info *hi = scsi_id->hi; struct list_head *lh; struct sbp2_command_info *command; + unsigned long flags; SBP2_DEBUG("sbp2scsi_complete_all_commands"); + spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { SBP2_DEBUG("Found pending command to complete"); lh = scsi_id->sbp2_command_orb_inuse.next; @@ -2582,6 +2587,7 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id command->Current_done(command->Current_SCpnt); } } + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return; } -- cgit v1.1 From 365c786f0be44ee92e018773cb0bc4b19080b6aa Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Mon, 7 Nov 2005 06:31:24 -0500 Subject: sbp2: Merge TYPE_RBC and 10byte removal patch from scsi maintainers. Added more cleanups to remove unused code. Signed-off-by: Ben Collins Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/sbp2.c | 151 +----------------------------------------------- drivers/ieee1394/sbp2.h | 1 - 2 files changed, 2 insertions(+), 150 deletions(-) diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index f7e18cc..d53c8cf 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -1089,16 +1089,6 @@ static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_ **************************************/ /* - * This function determines if we should convert scsi commands for a particular sbp2 device type - */ -static __inline__ int sbp2_command_conversion_device_type(u8 device_type) -{ - return (((device_type == TYPE_DISK) || - (device_type == TYPE_RBC) || - (device_type == TYPE_ROM)) ? 1:0); -} - -/* * This function queries the device for the maximum concurrent logins it * supports. */ @@ -2106,11 +2096,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, request_bufflen, SCpnt->request_buffer, SCpnt->sc_data_direction); - /* - * Update our cdb if necessary (to handle sbp2 RBC command set - * differences). This is where the command set hacks go! =) - */ - sbp2_check_sbp2_command(scsi_id, command->command_orb.cdb); sbp2util_packet_dump(&command->command_orb, sizeof(struct sbp2_command_orb), "sbp2 command orb", command->command_orb_dma); @@ -2130,110 +2115,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, /* - * This function deals with command set differences between Linux scsi - * command set and sbp2 RBC command set. - */ -static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd) -{ - unchar new_cmd[16]; - u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun); - - SBP2_DEBUG("sbp2_check_sbp2_command"); - - switch (*cmd) { - - case READ_6: - - if (sbp2_command_conversion_device_type(device_type)) { - - SBP2_DEBUG("Convert READ_6 to READ_10"); - - /* - * Need to turn read_6 into read_10 - */ - new_cmd[0] = 0x28; - new_cmd[1] = (cmd[1] & 0xe0); - new_cmd[2] = 0x0; - new_cmd[3] = (cmd[1] & 0x1f); - new_cmd[4] = cmd[2]; - new_cmd[5] = cmd[3]; - new_cmd[6] = 0x0; - new_cmd[7] = 0x0; - new_cmd[8] = cmd[4]; - new_cmd[9] = cmd[5]; - - memcpy(cmd, new_cmd, 10); - - } - - break; - - case WRITE_6: - - if (sbp2_command_conversion_device_type(device_type)) { - - SBP2_DEBUG("Convert WRITE_6 to WRITE_10"); - - /* - * Need to turn write_6 into write_10 - */ - new_cmd[0] = 0x2a; - new_cmd[1] = (cmd[1] & 0xe0); - new_cmd[2] = 0x0; - new_cmd[3] = (cmd[1] & 0x1f); - new_cmd[4] = cmd[2]; - new_cmd[5] = cmd[3]; - new_cmd[6] = 0x0; - new_cmd[7] = 0x0; - new_cmd[8] = cmd[4]; - new_cmd[9] = cmd[5]; - - memcpy(cmd, new_cmd, 10); - - } - - break; - - case MODE_SENSE: - - if (sbp2_command_conversion_device_type(device_type)) { - - SBP2_DEBUG("Convert MODE_SENSE_6 to MODE_SENSE_10"); - - /* - * Need to turn mode_sense_6 into mode_sense_10 - */ - new_cmd[0] = 0x5a; - new_cmd[1] = cmd[1]; - new_cmd[2] = cmd[2]; - new_cmd[3] = 0x0; - new_cmd[4] = 0x0; - new_cmd[5] = 0x0; - new_cmd[6] = 0x0; - new_cmd[7] = 0x0; - new_cmd[8] = cmd[4]; - new_cmd[9] = cmd[5]; - - memcpy(cmd, new_cmd, 10); - - } - - break; - - case MODE_SELECT: - - /* - * TODO. Probably need to change mode select to 10 byte version - */ - - default: - break; - } - - return; -} - -/* * Translates SBP-2 status into SCSI sense data for check conditions */ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data) @@ -2271,7 +2152,6 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, struct scsi_cmnd *SCpnt) { u8 *scsi_buf = SCpnt->request_buffer; - u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun); SBP2_DEBUG("sbp2_check_sbp2_response"); @@ -2296,14 +2176,6 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, } /* - * Check for Simple Direct Access Device and change it to TYPE_DISK - */ - if ((scsi_buf[0] & 0x1f) == TYPE_RBC) { - SBP2_DEBUG("Changing TYPE_RBC to TYPE_DISK"); - scsi_buf[0] &= 0xe0; - } - - /* * Fix ansi revision and response data format */ scsi_buf[2] |= 2; @@ -2311,27 +2183,6 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, break; - case MODE_SENSE: - - if (sbp2_command_conversion_device_type(device_type)) { - - SBP2_DEBUG("Modify mode sense response (10 byte version)"); - - scsi_buf[0] = scsi_buf[1]; /* Mode data length */ - scsi_buf[1] = scsi_buf[2]; /* Medium type */ - scsi_buf[2] = scsi_buf[3]; /* Device specific parameter */ - scsi_buf[3] = scsi_buf[7]; /* Block descriptor length */ - memcpy(scsi_buf + 4, scsi_buf + 8, scsi_buf[0]); - } - - break; - - case MODE_SELECT: - - /* - * TODO. Probably need to change mode select to 10 byte version - */ - default: break; } @@ -2713,6 +2564,8 @@ static int sbp2scsi_slave_alloc(struct scsi_device *sdev) static int sbp2scsi_slave_configure(struct scsi_device *sdev) { blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); + sdev->use_10_for_rw = 1; + sdev->use_10_for_ms = 1; return 0; } diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index cd425be..cb111d7 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h @@ -469,7 +469,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)); static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data); -static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd); static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, struct scsi_cmnd *SCpnt); static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, -- cgit v1.1 From e309fc6d71d61bb0f049ab6d0da10c845da9513f Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Mon, 7 Nov 2005 06:31:34 -0500 Subject: sbp2: Remove our tracking of device type, since we no longer need to worry about it. Depends on patch "ieee1394: remove sbp2's TYPE_RBC and 10byte handling". Signed-off-by: Ben Collins Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/sbp2.c | 34 ++++++---------------------------- drivers/ieee1394/sbp2.h | 7 +------ 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index d53c8cf..747dbd1 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -735,7 +735,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed); INIT_LIST_HEAD(&scsi_id->scsi_list); spin_lock_init(&scsi_id->sbp2_command_orb_lock); - scsi_id->sbp2_device_type_and_lun = SBP2_DEVICE_TYPE_LUN_UNINITIALIZED; + scsi_id->sbp2_lun = 0; ud->device.driver_data = scsi_id; @@ -1110,11 +1110,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST); scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1); - if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { - scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun); - SBP2_DEBUG("sbp2_query_logins: set lun to %d", - ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun)); - } + scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); SBP2_DEBUG("sbp2_query_logins: lun_misc initialized"); scsi_id->query_logins_orb->reserved_resp_length = @@ -1223,12 +1219,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */ scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */ scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */ - /* Set the lun if we were able to pull it from the device's unit directory */ - if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { - scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun); - SBP2_DEBUG("sbp2_query_logins: set lun to %d", - ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun)); - } + scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); SBP2_DEBUG("sbp2_login_device: lun_misc initialized"); scsi_id->login_orb->passwd_resp_lengths = @@ -1543,7 +1534,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, SBP2_DEBUG("sbp2_management_agent_addr = %x", (unsigned int) management_agent_addr); } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { - scsi_id->sbp2_device_type_and_lun = kv->value.immediate; + scsi_id->sbp2_lun = ORB_SET_LUN(kv->value.immediate); } break; @@ -1636,7 +1627,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, scsi_id->sbp2_firmware_revision = firmware_revision; scsi_id->workarounds = workarounds; if (ud->flags & UNIT_DIRECTORY_HAS_LUN) - scsi_id->sbp2_device_type_and_lun = ud->lun; + scsi_id->sbp2_lun = ORB_SET_LUN(ud->lun); } } @@ -2158,16 +2149,6 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, switch (SCpnt->cmnd[0]) { case INQUIRY: - - /* - * If scsi_id->sbp2_device_type_and_lun is uninitialized, then fill - * this information in from the inquiry response data. Lun is set to zero. - */ - if (scsi_id->sbp2_device_type_and_lun == SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { - SBP2_DEBUG("Creating sbp2_device_type_and_lun from scsi inquiry data"); - scsi_id->sbp2_device_type_and_lun = (scsi_buf[0] & 0x1f) << 16; - } - /* * Make sure data length is ok. Minimum length is 36 bytes */ @@ -2665,10 +2646,7 @@ static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_att if (!(scsi_id = (struct scsi_id_instance_data *)sdev->host->hostdata[0])) return 0; - if (scsi_id->sbp2_device_type_and_lun == SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) - lun = 0; - else - lun = ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun); + lun = ORB_SET_LUN(scsi_id->sbp2_lun); return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid, scsi_id->ud->id, lun); diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index cb111d7..890be13 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h @@ -229,9 +229,6 @@ struct sbp2_status_block { #define SBP2_DEVICE_TYPE_AND_LUN_KEY 0x14 #define SBP2_FIRMWARE_REVISION_KEY 0x3c -#define SBP2_DEVICE_TYPE(q) (((q) >> 16) & 0x1f) -#define SBP2_DEVICE_LUN(q) ((q) & 0xffff) - #define SBP2_AGENT_STATE_OFFSET 0x00ULL #define SBP2_AGENT_RESET_OFFSET 0x04ULL #define SBP2_ORB_POINTER_OFFSET 0x08ULL @@ -256,8 +253,6 @@ struct sbp2_status_block { */ #define SBP2_128KB_BROKEN_FIRMWARE 0xa0b800 -#define SBP2_DEVICE_TYPE_LUN_UNINITIALIZED 0xffffffff - /* * SCSI specific stuff */ @@ -379,7 +374,7 @@ struct scsi_id_instance_data { u32 sbp2_command_set_spec_id; u32 sbp2_command_set; u32 sbp2_unit_characteristics; - u32 sbp2_device_type_and_lun; + u32 sbp2_lun; u32 sbp2_firmware_revision; /* -- cgit v1.1 From a237f35fdd81d85037dccdacd2e94028227b59fb Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 7 Nov 2005 06:31:39 -0500 Subject: sbp2, ohci1394 cleanups: sbp2: various code formatting cleanups ohci1394: remove form feed characters Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/ohci1394.c | 5 - drivers/ieee1394/sbp2.c | 433 ++++++++++++++++++++++---------------------- drivers/ieee1394/sbp2.h | 15 +- 3 files changed, 224 insertions(+), 229 deletions(-) diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 4cf9b8f..dcb5776 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -3201,8 +3201,6 @@ static struct hpsb_host_driver ohci1394_driver = { .hw_csr_reg = ohci_hw_csr_reg, }; - - /*********************************** * PCI Driver Interface functions * ***********************************/ @@ -3606,8 +3604,6 @@ static struct pci_driver ohci1394_pci_driver = { .suspend = ohci1394_pci_suspend, }; - - /*********************************** * OHCI1394 Video Interface * ***********************************/ @@ -3714,7 +3710,6 @@ EXPORT_SYMBOL(ohci1394_init_iso_tasklet); EXPORT_SYMBOL(ohci1394_register_iso_tasklet); EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet); - /*********************************** * General module initialization * ***********************************/ diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 747dbd1..073ede9 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -151,18 +151,15 @@ static int force_inquiry_hack; module_param(force_inquiry_hack, int, 0444); MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); - /* * Export information about protocols/devices supported by this driver. */ static struct ieee1394_device_id sbp2_id_table[] = { { - .match_flags =IEEE1394_MATCH_SPECIFIER_ID | - IEEE1394_MATCH_VERSION, - .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, - .version = SBP2_SW_VERSION_ENTRY & 0xffffff - }, - { } + .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, + .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, + .version = SBP2_SW_VERSION_ENTRY & 0xffffff}, + {} }; MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); @@ -221,7 +218,6 @@ static u32 global_outstanding_dmas = 0; #define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) - /* * Globals */ @@ -254,8 +250,8 @@ static struct hpsb_address_ops sbp2_ops = { #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA static struct hpsb_address_ops sbp2_physdma_ops = { - .read = sbp2_handle_physdma_read, - .write = sbp2_handle_physdma_write, + .read = sbp2_handle_physdma_read, + .write = sbp2_handle_physdma_write, }; #endif @@ -287,7 +283,6 @@ static u32 sbp2_broken_inquiry_list[] = { * General utility functions **************************************/ - #ifndef __BIG_ENDIAN /* * Converts a buffer from be32 to cpu byte ordering. Length is in bytes. @@ -324,7 +319,8 @@ static __inline__ void sbp2util_cpu_to_be32_buffer(void *buffer, int length) /* * Debug packet dump routine. Length is in bytes. */ -static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32 dump_phys_addr) +static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, + u32 dump_phys_addr) { int i; unsigned char *dump = buffer; @@ -345,7 +341,7 @@ static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32 printk(" "); if ((i & 0xf) == 0) printk("\n "); - printk("%02x ", (int) dump[i]); + printk("%02x ", (int)dump[i]); } printk("\n"); @@ -364,9 +360,9 @@ static int sbp2util_down_timeout(atomic_t *done, int timeout) for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) { if (msleep_interruptible(100)) /* 100ms */ - return(1); + return 1; } - return ((i > 0) ? 0:1); + return (i > 0) ? 0 : 1; } /* Free's an allocated packet */ @@ -380,21 +376,22 @@ static void sbp2_free_packet(struct hpsb_packet *packet) * subaction and returns immediately. Can be used from interrupts. */ static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, - quadlet_t *buffer, size_t length) + quadlet_t *buffer, size_t length) { struct hpsb_packet *packet; packet = hpsb_make_writepacket(ne->host, ne->nodeid, addr, buffer, length); - if (!packet) - return -ENOMEM; + if (!packet) + return -ENOMEM; - hpsb_set_packet_complete_task(packet, (void (*)(void*))sbp2_free_packet, + hpsb_set_packet_complete_task(packet, + (void (*)(void *))sbp2_free_packet, packet); hpsb_node_fill_packet(ne, packet); - if (hpsb_send_packet(packet) < 0) { + if (hpsb_send_packet(packet) < 0) { sbp2_free_packet(packet); return -EIO; } @@ -420,19 +417,21 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i command = (struct sbp2_command_info *) kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC); if (!command) { - spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); - return(-ENOMEM); + spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, + flags); + return -ENOMEM; } memset(command, '\0', sizeof(struct sbp2_command_info)); command->command_orb_dma = - pci_map_single (hi->host->pdev, &command->command_orb, - sizeof(struct sbp2_command_orb), - PCI_DMA_BIDIRECTIONAL); + pci_map_single(hi->host->pdev, &command->command_orb, + sizeof(struct sbp2_command_orb), + PCI_DMA_BIDIRECTIONAL); SBP2_DMA_ALLOC("single command orb DMA"); command->sge_dma = - pci_map_single (hi->host->pdev, &command->scatter_gather_element, - sizeof(command->scatter_gather_element), - PCI_DMA_BIDIRECTIONAL); + pci_map_single(hi->host->pdev, + &command->scatter_gather_element, + sizeof(command->scatter_gather_element), + PCI_DMA_BIDIRECTIONAL); SBP2_DMA_ALLOC("scatter_gather_element"); INIT_LIST_HEAD(&command->list); list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); @@ -488,7 +487,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb( list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { if (command->command_orb_dma == orb) { spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); - return (command); + return command; } } } @@ -496,7 +495,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb( SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb); - return(NULL); + return NULL; } /* @@ -513,12 +512,12 @@ static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_ list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { if (command->Current_SCpnt == SCpnt) { spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); - return (command); + return command; } } } spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); - return(NULL); + return NULL; } /* @@ -545,7 +544,7 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb( SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!"); } spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); - return (command); + return command; } /* Free our DMA's */ @@ -587,7 +586,8 @@ static void sbp2util_free_command_dma(struct sbp2_command_info *command) /* * This function moves a command to the completed orb list. */ -static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id, struct sbp2_command_info *command) +static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id, + struct sbp2_command_info *command) { unsigned long flags; @@ -606,8 +606,6 @@ static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_ return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo; } - - /********************************************* * IEEE-1394 core driver stack related section *********************************************/ @@ -627,14 +625,14 @@ static int sbp2_probe(struct device *dev) if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY) return -ENODEV; - scsi_id = sbp2_alloc_device(ud); + scsi_id = sbp2_alloc_device(ud); - if (!scsi_id) - return -ENOMEM; + if (!scsi_id) + return -ENOMEM; - sbp2_parse_unit_directory(scsi_id, ud); + sbp2_parse_unit_directory(scsi_id, ud); - return sbp2_start_device(scsi_id); + return sbp2_start_device(scsi_id); } static int sbp2_remove(struct device *dev) @@ -769,7 +767,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud /* Register our host with the SCSI stack. */ scsi_host = scsi_host_alloc(&scsi_driver_template, - sizeof (unsigned long)); + sizeof(unsigned long)); if (!scsi_host) { SBP2_ERR("failed to register scsi host"); goto failed_alloc; @@ -790,7 +788,6 @@ failed_alloc: return NULL; } - static void sbp2_host_reset(struct hpsb_host *host) { struct sbp2scsi_host_info *hi; @@ -804,7 +801,6 @@ static void sbp2_host_reset(struct hpsb_host *host) } } - /* * This function is where we first pull the node unique ids, and then * allocate memory and register a SBP-2 device. @@ -818,7 +814,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) /* Login FIFO DMA */ scsi_id->login_response = - pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_response), + pci_alloc_consistent(hi->host->pdev, + sizeof(struct sbp2_login_response), &scsi_id->login_response_dma); if (!scsi_id->login_response) goto alloc_fail; @@ -826,7 +823,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) /* Query logins ORB DMA */ scsi_id->query_logins_orb = - pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_orb), + pci_alloc_consistent(hi->host->pdev, + sizeof(struct sbp2_query_logins_orb), &scsi_id->query_logins_orb_dma); if (!scsi_id->query_logins_orb) goto alloc_fail; @@ -834,7 +832,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) /* Query logins response DMA */ scsi_id->query_logins_response = - pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_response), + pci_alloc_consistent(hi->host->pdev, + sizeof(struct sbp2_query_logins_response), &scsi_id->query_logins_response_dma); if (!scsi_id->query_logins_response) goto alloc_fail; @@ -842,7 +841,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) /* Reconnect ORB DMA */ scsi_id->reconnect_orb = - pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_reconnect_orb), + pci_alloc_consistent(hi->host->pdev, + sizeof(struct sbp2_reconnect_orb), &scsi_id->reconnect_orb_dma); if (!scsi_id->reconnect_orb) goto alloc_fail; @@ -850,7 +850,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) /* Logout ORB DMA */ scsi_id->logout_orb = - pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_logout_orb), + pci_alloc_consistent(hi->host->pdev, + sizeof(struct sbp2_logout_orb), &scsi_id->logout_orb_dma); if (!scsi_id->logout_orb) goto alloc_fail; @@ -858,7 +859,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) /* Login ORB DMA */ scsi_id->login_orb = - pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_orb), + pci_alloc_consistent(hi->host->pdev, + sizeof(struct sbp2_login_orb), &scsi_id->login_orb_dma); if (!scsi_id->login_orb) { alloc_fail: @@ -880,25 +882,25 @@ alloc_fail: if (scsi_id->logout_orb) { pci_free_consistent(hi->host->pdev, - sizeof(struct sbp2_logout_orb), - scsi_id->logout_orb, - scsi_id->logout_orb_dma); + sizeof(struct sbp2_logout_orb), + scsi_id->logout_orb, + scsi_id->logout_orb_dma); SBP2_DMA_FREE("logout ORB DMA"); } if (scsi_id->reconnect_orb) { pci_free_consistent(hi->host->pdev, - sizeof(struct sbp2_reconnect_orb), - scsi_id->reconnect_orb, - scsi_id->reconnect_orb_dma); + sizeof(struct sbp2_reconnect_orb), + scsi_id->reconnect_orb, + scsi_id->reconnect_orb_dma); SBP2_DMA_FREE("reconnect ORB DMA"); } if (scsi_id->login_response) { pci_free_consistent(hi->host->pdev, - sizeof(struct sbp2_login_response), - scsi_id->login_response, - scsi_id->login_response_dma); + sizeof(struct sbp2_login_response), + scsi_id->login_response, + scsi_id->login_response_dma); SBP2_DMA_FREE("login FIFO DMA"); } @@ -906,7 +908,7 @@ alloc_fail: kfree(scsi_id); - SBP2_ERR ("Could not allocate memory for scsi_id"); + SBP2_ERR("Could not allocate memory for scsi_id"); return -ENOMEM; } @@ -935,7 +937,7 @@ alloc_fail: sbp2_remove_device(scsi_id); return -EINTR; } - + /* * Login to the sbp-2 device */ @@ -1054,36 +1056,39 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) * This function deals with physical dma write requests (for adapters that do not support * physical dma in hardware). Mostly just here for debugging... */ -static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data, - u64 addr, size_t length, u16 flags) +static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, + int destid, quadlet_t *data, u64 addr, + size_t length, u16 flags) { - /* - * Manually put the data in the right place. - */ - memcpy(bus_to_virt((u32)addr), data, length); - sbp2util_packet_dump(data, length, "sbp2 phys dma write by device", (u32)addr); - return(RCODE_COMPLETE); + /* + * Manually put the data in the right place. + */ + memcpy(bus_to_virt((u32) addr), data, length); + sbp2util_packet_dump(data, length, "sbp2 phys dma write by device", + (u32) addr); + return RCODE_COMPLETE; } /* * This function deals with physical dma read requests (for adapters that do not support * physical dma in hardware). Mostly just here for debugging... */ -static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data, - u64 addr, size_t length, u16 flags) +static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, + quadlet_t *data, u64 addr, size_t length, + u16 flags) { - /* - * Grab data from memory and send a read response. - */ - memcpy(data, bus_to_virt((u32)addr), length); - sbp2util_packet_dump(data, length, "sbp2 phys dma read by device", (u32)addr); - return(RCODE_COMPLETE); + /* + * Grab data from memory and send a read response. + */ + memcpy(data, bus_to_virt((u32) addr), length); + sbp2util_packet_dump(data, length, "sbp2 phys dma read by device", + (u32) addr); + return RCODE_COMPLETE; } #endif - /************************************** * SBP-2 protocol related section **************************************/ @@ -1147,12 +1152,12 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) { SBP2_INFO("Error querying logins to SBP-2 device - timed out"); - return(-EIO); + return -EIO; } if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) { SBP2_INFO("Error querying logins to SBP-2 device - timed out"); - return(-EIO); + return -EIO; } if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) || @@ -1160,7 +1165,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { SBP2_INFO("Error querying logins to SBP-2 device - timed out"); - return(-EIO); + return -EIO; } sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response)); @@ -1177,7 +1182,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) SBP2_DEBUG("Number of active logins: %d", active_logins); if (active_logins >= max_logins) { - return(-EIO); + return -EIO; } return 0; @@ -1196,13 +1201,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) if (!scsi_id->login_orb) { SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!"); - return(-EIO); + return -EIO; } if (!exclusive_login) { if (sbp2_query_logins(scsi_id)) { SBP2_INFO("Device does not support any more concurrent logins"); - return(-EIO); + return -EIO; } } @@ -1269,7 +1274,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) */ if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) { SBP2_ERR("Error logging into SBP-2 device - login timed-out"); - return(-EIO); + return -EIO; } /* @@ -1277,7 +1282,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) */ if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) { SBP2_ERR("Error logging into SBP-2 device - login timed-out"); - return(-EIO); + return -EIO; } /* @@ -1288,7 +1293,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { SBP2_ERR("Error logging into SBP-2 device - login failed"); - return(-EIO); + return -EIO; } /* @@ -1312,7 +1317,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) SBP2_INFO("Logged into SBP-2 device"); - return(0); + return 0; } @@ -1366,8 +1371,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) atomic_set(&scsi_id->sbp2_login_complete, 0); error = hpsb_node_write(scsi_id->ne, - scsi_id->sbp2_management_agent_addr, - data, 8); + scsi_id->sbp2_management_agent_addr, data, 8); if (error) return error; @@ -1377,7 +1381,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) SBP2_INFO("Logged out of SBP-2 device"); - return(0); + return 0; } @@ -1437,8 +1441,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) atomic_set(&scsi_id->sbp2_login_complete, 0); error = hpsb_node_write(scsi_id->ne, - scsi_id->sbp2_management_agent_addr, - data, 8); + scsi_id->sbp2_management_agent_addr, data, 8); if (error) return error; @@ -1447,7 +1450,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) */ if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) { SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); - return(-EIO); + return -EIO; } /* @@ -1455,7 +1458,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) */ if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) { SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); - return(-EIO); + return -EIO; } /* @@ -1466,12 +1469,12 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed"); - return(-EIO); + return -EIO; } HPSB_DEBUG("Reconnected to SBP-2 device"); - return(0); + return 0; } @@ -1494,10 +1497,9 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id) SBP2_ERR("sbp2_set_busy_timeout error"); } - return(0); + return 0; } - /* * This function is called to parse sbp2 device's config rom unit * directory. Used to determine things like sbp2 management agent offset, @@ -1510,7 +1512,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, struct csr1212_dentry *dentry; u64 management_agent_addr; u32 command_set_spec_id, command_set, unit_characteristics, - firmware_revision, workarounds; + firmware_revision, workarounds; int i; SBP2_DEBUG("sbp2_parse_unit_directory"); @@ -1528,13 +1530,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) { /* Save off the management agent address */ management_agent_addr = - CSR1212_REGISTER_SPACE_BASE + - (kv->value.csr_offset << 2); + CSR1212_REGISTER_SPACE_BASE + + (kv->value.csr_offset << 2); SBP2_DEBUG("sbp2_management_agent_addr = %x", - (unsigned int) management_agent_addr); + (unsigned int)management_agent_addr); } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { - scsi_id->sbp2_lun = ORB_SET_LUN(kv->value.immediate); + scsi_id->sbp2_lun = + ORB_SET_LUN(kv->value.immediate); } break; @@ -1542,14 +1545,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, /* Command spec organization */ command_set_spec_id = kv->value.immediate; SBP2_DEBUG("sbp2_command_set_spec_id = %x", - (unsigned int) command_set_spec_id); + (unsigned int)command_set_spec_id); break; case SBP2_COMMAND_SET_KEY: /* Command set used by sbp2 device */ command_set = kv->value.immediate; SBP2_DEBUG("sbp2_command_set = %x", - (unsigned int) command_set); + (unsigned int)command_set); break; case SBP2_UNIT_CHARACTERISTICS_KEY: @@ -1559,7 +1562,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, */ unit_characteristics = kv->value.immediate; SBP2_DEBUG("sbp2_unit_characteristics = %x", - (unsigned int) unit_characteristics); + (unsigned int)unit_characteristics); break; case SBP2_FIRMWARE_REVISION_KEY: @@ -1567,9 +1570,10 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, firmware_revision = kv->value.immediate; if (force_inquiry_hack) SBP2_INFO("sbp2_firmware_revision = %x", - (unsigned int) firmware_revision); - else SBP2_DEBUG("sbp2_firmware_revision = %x", - (unsigned int) firmware_revision); + (unsigned int)firmware_revision); + else + SBP2_DEBUG("sbp2_firmware_revision = %x", + (unsigned int)firmware_revision); break; default: @@ -1647,8 +1651,9 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) SBP2_DEBUG("sbp2_max_speed_and_size"); /* Initial setting comes from the hosts speed map */ - scsi_id->speed_code = hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 - + NODEID_TO_NODE(scsi_id->ne->nodeid)]; + scsi_id->speed_code = + hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 + + NODEID_TO_NODE(scsi_id->ne->nodeid)]; /* Bump down our speed if the user requested it */ if (scsi_id->speed_code > max_speed) { @@ -1659,15 +1664,16 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) /* Payload size is the lesser of what our speed supports and what * our host supports. */ - scsi_id->max_payload_size = min(sbp2_speedto_max_payload[scsi_id->speed_code], - (u8)(hi->host->csr.max_rec - 1)); + scsi_id->max_payload_size = + min(sbp2_speedto_max_payload[scsi_id->speed_code], + (u8) (hi->host->csr.max_rec - 1)); HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]", NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid), hpsb_speedto_str[scsi_id->speed_code], - 1 << ((u32)scsi_id->max_payload_size + 2)); + 1 << ((u32) scsi_id->max_payload_size + 2)); - return(0); + return 0; } /* @@ -1702,7 +1708,7 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait) */ scsi_id->last_orb = NULL; - return(0); + return 0; } /* @@ -1716,10 +1722,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, unsigned int scsi_request_bufflen, void *scsi_request_buffer, enum dma_data_direction dma_dir) - { struct sbp2scsi_host_info *hi = scsi_id->hi; - struct scatterlist *sgpnt = (struct scatterlist *) scsi_request_buffer; + struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer; struct sbp2_command_orb *command_orb = &command->command_orb; struct sbp2_unrestricted_page_table *scatter_gather_element = &command->scatter_gather_element[0]; @@ -1739,30 +1744,30 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, command_orb->next_ORB_lo = 0x0; command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size); command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); - command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ + command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ /* * Get the direction of the transfer. If the direction is unknown, then use our * goofy table as a back-up. */ switch (dma_dir) { - case DMA_NONE: - orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; - break; - case DMA_TO_DEVICE: - orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA; - break; - case DMA_FROM_DEVICE: - orb_direction = ORB_DIRECTION_READ_FROM_MEDIA; - break; - case DMA_BIDIRECTIONAL: - default: - SBP2_ERR("SCSI data transfer direction not specified. " - "Update the SBP2 direction table in sbp2.h if " - "necessary for your application"); - __scsi_print_command(scsi_cmd); - orb_direction = sbp2scsi_direction_table[*scsi_cmd]; - break; + case DMA_NONE: + orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; + break; + case DMA_TO_DEVICE: + orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA; + break; + case DMA_FROM_DEVICE: + orb_direction = ORB_DIRECTION_READ_FROM_MEDIA; + break; + case DMA_BIDIRECTIONAL: + default: + SBP2_ERR("SCSI data transfer direction not specified. " + "Update the SBP2 direction table in sbp2.h if " + "necessary for your application"); + __scsi_print_command(scsi_cmd); + orb_direction = sbp2scsi_direction_table[*scsi_cmd]; + break; } /* @@ -1865,9 +1870,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, command->dma_dir = dma_dir; command->dma_size = scsi_request_bufflen; command->dma_type = CMD_DMA_SINGLE; - command->cmd_dma = pci_map_single (hi->host->pdev, scsi_request_buffer, - command->dma_size, - command->dma_dir); + command->cmd_dma = + pci_map_single(hi->host->pdev, scsi_request_buffer, + command->dma_size, command->dma_dir); SBP2_DMA_ALLOC("single bulk"); /* @@ -1954,7 +1959,7 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, memset(command_orb->cdb, 0, 12); memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); - return(0); + return 0; } /* @@ -1970,7 +1975,7 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, outstanding_orb_incr; SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x", - command_orb, global_outstanding_command_orbs); + command_orb, global_outstanding_command_orbs); pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma, sizeof(struct sbp2_command_orb), @@ -2015,10 +2020,11 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, * both by the sbp2 device and us. */ scsi_id->last_orb->next_ORB_lo = - cpu_to_be32(command->command_orb_dma); + cpu_to_be32(command->command_orb_dma); /* Tells hardware that this pointer is valid */ scsi_id->last_orb->next_ORB_hi = 0x0; - pci_dma_sync_single_for_device(hi->host->pdev, scsi_id->last_orb_dma, + pci_dma_sync_single_for_device(hi->host->pdev, + scsi_id->last_orb_dma, sizeof(struct sbp2_command_orb), PCI_DMA_BIDIRECTIONAL); @@ -2032,14 +2038,14 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) { SBP2_ERR("sbp2util_node_write_no_wait failed"); - return(-EIO); + return -EIO; } scsi_id->last_orb = command_orb; scsi_id->last_orb_dma = command->command_orb_dma; } - return(0); + return 0; } /* @@ -2066,7 +2072,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, */ command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done); if (!command) { - return(-EIO); + return -EIO; } /* @@ -2101,10 +2107,9 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, */ sbp2_link_orb_command(scsi_id, command); - return(0); + return 0; } - /* * Translates SBP-2 status into SCSI sense data for check conditions */ @@ -2132,14 +2137,14 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense sense_data[14] = sbp2_status[20]; sense_data[15] = sbp2_status[21]; - return(sbp2_status[8] & 0x3f); /* return scsi status */ + return sbp2_status[8] & 0x3f; /* return scsi status */ } /* * This function is called after a command is completed, in order to do any necessary SBP-2 * response data translations for the SCSI stack */ -static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, +static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, struct scsi_cmnd *SCpnt) { u8 *scsi_buf = SCpnt->request_buffer; @@ -2148,24 +2153,24 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, switch (SCpnt->cmnd[0]) { - case INQUIRY: - /* - * Make sure data length is ok. Minimum length is 36 bytes - */ - if (scsi_buf[4] == 0) { - scsi_buf[4] = 36 - 5; - } + case INQUIRY: + /* + * Make sure data length is ok. Minimum length is 36 bytes + */ + if (scsi_buf[4] == 0) { + scsi_buf[4] = 36 - 5; + } - /* - * Fix ansi revision and response data format - */ - scsi_buf[2] |= 2; - scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; + /* + * Fix ansi revision and response data format + */ + scsi_buf[2] |= 2; + scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; - break; + break; - default: - break; + default: + break; } return; } @@ -2190,14 +2195,14 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest if (!host) { SBP2_ERR("host is NULL - this is bad!"); - return(RCODE_ADDRESS_ERROR); + return RCODE_ADDRESS_ERROR; } hi = hpsb_get_hostinfo(&sbp2_highlevel, host); if (!hi) { SBP2_ERR("host info is NULL - this is bad!"); - return(RCODE_ADDRESS_ERROR); + return RCODE_ADDRESS_ERROR; } /* @@ -2214,7 +2219,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest if (!scsi_id) { SBP2_ERR("scsi_id is NULL - device is gone?"); - return(RCODE_ADDRESS_ERROR); + return RCODE_ADDRESS_ERROR; } /* @@ -2312,10 +2317,9 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest SBP2_ORB_DEBUG("command orb completed"); } - return(RCODE_COMPLETE); + return RCODE_COMPLETE; } - /************************************** * SCSI interface related section **************************************/ @@ -2448,55 +2452,56 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, * complete the command, just let it get retried at the end of the * bus reset. */ - if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { + if (!hpsb_node_entry_valid(scsi_id->ne) + && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { SBP2_ERR("Bus reset in progress - retry command later"); return; } - + /* * Switch on scsi status */ switch (scsi_status) { - case SBP2_SCSI_STATUS_GOOD: - SCpnt->result = DID_OK; - break; + case SBP2_SCSI_STATUS_GOOD: + SCpnt->result = DID_OK; + break; - case SBP2_SCSI_STATUS_BUSY: - SBP2_ERR("SBP2_SCSI_STATUS_BUSY"); - SCpnt->result = DID_BUS_BUSY << 16; - break; + case SBP2_SCSI_STATUS_BUSY: + SBP2_ERR("SBP2_SCSI_STATUS_BUSY"); + SCpnt->result = DID_BUS_BUSY << 16; + break; - case SBP2_SCSI_STATUS_CHECK_CONDITION: - SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION"); - SCpnt->result = CHECK_CONDITION << 1; + case SBP2_SCSI_STATUS_CHECK_CONDITION: + SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION"); + SCpnt->result = CHECK_CONDITION << 1; - /* - * Debug stuff - */ + /* + * Debug stuff + */ #if CONFIG_IEEE1394_SBP2_DEBUG >= 1 - scsi_print_command(SCpnt); - scsi_print_sense("bh", SCpnt); + scsi_print_command(SCpnt); + scsi_print_sense("bh", SCpnt); #endif - break; + break; - case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: - SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT"); - SCpnt->result = DID_NO_CONNECT << 16; - scsi_print_command(SCpnt); - break; + case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: + SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT"); + SCpnt->result = DID_NO_CONNECT << 16; + scsi_print_command(SCpnt); + break; - case SBP2_SCSI_STATUS_CONDITION_MET: - case SBP2_SCSI_STATUS_RESERVATION_CONFLICT: - case SBP2_SCSI_STATUS_COMMAND_TERMINATED: - SBP2_ERR("Bad SCSI status = %x", scsi_status); - SCpnt->result = DID_ERROR << 16; - scsi_print_command(SCpnt); - break; + case SBP2_SCSI_STATUS_CONDITION_MET: + case SBP2_SCSI_STATUS_RESERVATION_CONFLICT: + case SBP2_SCSI_STATUS_COMMAND_TERMINATED: + SBP2_ERR("Bad SCSI status = %x", scsi_status); + SCpnt->result = DID_ERROR << 16; + scsi_print_command(SCpnt); + break; - default: - SBP2_ERR("Unsupported SCSI status = %x", scsi_status); - SCpnt->result = DID_ERROR << 16; + default: + SBP2_ERR("Unsupported SCSI status = %x", scsi_status); + SCpnt->result = DID_ERROR << 16; } /* @@ -2510,7 +2515,8 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, * If a bus reset is in progress and there was an error, complete * the command as busy so that it will get retried. */ - if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { + if (!hpsb_node_entry_valid(scsi_id->ne) + && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { SBP2_ERR("Completing command with busy (bus reset)"); SCpnt->result = DID_BUS_BUSY << 16; } @@ -2531,17 +2537,15 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, /* * Tell scsi stack that we're done with this command */ - done (SCpnt); + done(SCpnt); } - static int sbp2scsi_slave_alloc(struct scsi_device *sdev) { ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; return 0; } - static int sbp2scsi_slave_configure(struct scsi_device *sdev) { blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); @@ -2550,14 +2554,12 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev) return 0; } - static void sbp2scsi_slave_destroy(struct scsi_device *sdev) { ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL; return; } - /* * Called by scsi stack when something has really gone wrong. Usually * called when a command has timed-out for some reason. @@ -2603,7 +2605,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY); } - return(SUCCESS); + return SUCCESS; } /* @@ -2629,12 +2631,14 @@ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt) return SUCCESS; } -static const char *sbp2scsi_info (struct Scsi_Host *host) +static const char *sbp2scsi_info(struct Scsi_Host *host) { - return "SCSI emulation for IEEE-1394 SBP-2 Devices"; + return "SCSI emulation for IEEE-1394 SBP-2 Devices"; } -static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, + struct device_attribute *attr, + char *buf) { struct scsi_device *sdev; struct scsi_id_instance_data *scsi_id; @@ -2705,7 +2709,6 @@ static int sbp2_module_init(void) /* Set max sectors (module load option). Default is 255 sectors. */ scsi_driver_template.max_sectors = max_sectors; - /* Register our high level driver with 1394 stack */ hpsb_register_highlevel(&sbp2_highlevel); diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index 890be13..abc647b 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h @@ -119,8 +119,8 @@ struct sbp2_query_logins_response { struct sbp2_reconnect_orb { u32 reserved1; u32 reserved2; - u32 reserved3; - u32 reserved4; + u32 reserved3; + u32 reserved4; u32 login_ID_misc; u32 reserved5; u32 status_FIFO_hi; @@ -130,8 +130,8 @@ struct sbp2_reconnect_orb { struct sbp2_logout_orb { u32 reserved1; u32 reserved2; - u32 reserved3; - u32 reserved4; + u32 reserved3; + u32 reserved4; u32 login_ID_misc; u32 reserved5; u32 status_FIFO_hi; @@ -188,7 +188,7 @@ struct sbp2_unrestricted_page_table { struct sbp2_status_block { u32 ORB_offset_hi_misc; u32 ORB_offset_lo; - u8 command_set_dependent[24]; + u8 command_set_dependent[24]; }; /* @@ -211,7 +211,7 @@ struct sbp2_status_block { * specified for write posting, where the ohci controller will * automatically send an ack_complete when the status is written by the * sbp2 device... saving a split transaction. =) - */ + */ #define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL #define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe #define SBP2_STATUS_FIFO_ADDRESS_LO 0x0 @@ -333,10 +333,8 @@ struct sbp2_command_info { #define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1 #define SBP2_BREAKAGE_INQUIRY_HACK 0x2 - struct sbp2scsi_host_info; - /* * Information needed on a per scsi id basis (one for each sbp2 device) */ @@ -406,7 +404,6 @@ struct scsi_id_instance_data { u32 workarounds; }; - /* Sbp2 host data structure (one per IEEE1394 host) */ struct sbp2scsi_host_info { struct hpsb_host *host; /* IEEE1394 host */ -- cgit v1.1 From 7afa1467761f06bd9649efd66a4a6b3ff9f29a1f Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 7 Nov 2005 06:31:42 -0500 Subject: Remove version strings from eth1394, ohci1394, sbp2. Their version information is not trustworthy. Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/eth1394.c | 8 -------- drivers/ieee1394/ohci1394.c | 8 -------- drivers/ieee1394/sbp2.c | 5 ----- 3 files changed, 21 deletions(-) diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index c9e92d8..6984a92 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c @@ -88,9 +88,6 @@ printk(KERN_ERR "%s:%s[%d]: " fmt "\n", driver_name, __FUNCTION__, __LINE__, ## args) #define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__) -static char version[] __devinitdata = - "$Rev: 1312 $ Ben Collins "; - struct fragment_info { struct list_head list; int offset; @@ -566,7 +563,6 @@ static void ether1394_add_host (struct hpsb_host *host) struct eth1394_host_info *hi = NULL; struct net_device *dev = NULL; struct eth1394_priv *priv; - static int version_printed = 0; u64 fifo_addr; if (!(host->config_roms & HPSB_CONFIG_ROM_ENTRY_IP1394)) @@ -581,9 +577,6 @@ static void ether1394_add_host (struct hpsb_host *host) if (fifo_addr == ~0ULL) goto out; - if (version_printed++ == 0) - ETH1394_PRINT_G (KERN_INFO, "%s\n", version); - /* We should really have our own alloc_hpsbdev() function in * net_init.c instead of calling the one for ethernet then hijacking * it for ourselves. That way we'd be a real networking device. */ @@ -1768,7 +1761,6 @@ fail: static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strcpy (info->driver, driver_name); - strcpy (info->version, "$Rev: 1312 $"); /* FIXME XXX provide sane businfo */ strcpy (info->bus_info, "ieee1394"); } diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index dcb5776..8355068 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -161,9 +161,6 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args) #define PRINT(level, fmt, args...) \ printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args) -static char version[] __devinitdata = - "$Rev: 1313 $ Ben Collins "; - /* Module Parameters */ static int phys_dma = 1; module_param(phys_dma, int, 0644); @@ -3215,15 +3212,10 @@ do { \ static int __devinit ohci1394_pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) { - static int version_printed = 0; - struct hpsb_host *host; struct ti_ohci *ohci; /* shortcut to currently handled device */ unsigned long ohci_base; - if (version_printed++ == 0) - PRINT_G(KERN_INFO, "%s", version); - if (pci_enable_device(dev)) FAIL(-ENXIO, "Failed to enable OHCI hardware"); pci_set_master(dev); diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 073ede9..b871116 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -80,9 +80,6 @@ #include "ieee1394_transactions.h" #include "sbp2.h" -static char version[] __devinitdata = - "$Rev: 1306 $ Ben Collins "; - /* * Module load parameter definitions */ @@ -2696,8 +2693,6 @@ static int sbp2_module_init(void) SBP2_DEBUG("sbp2_module_init"); - printk(KERN_INFO "sbp2: %s\n", version); - /* Module load debug option to force one command at a time (serializing I/O) */ if (serialize_io) { SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)"); -- cgit v1.1 From 8551158abc8ef45a7f473a87e69624d05ebfd684 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 7 Nov 2005 06:31:45 -0500 Subject: kmalloc/kzalloc changes: dv1394, eth1394, ieee1394, ohci1394, pcilynx, raw1394, sbp2c, video1394: - use kzalloc - provide safer size arguments to kmalloc and kzalloc - omit some casts Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/csr1212.c | 11 +++--- drivers/ieee1394/csr1212.h | 2 +- drivers/ieee1394/dv1394.c | 4 +-- drivers/ieee1394/eth1394.c | 12 +++---- drivers/ieee1394/highlevel.c | 18 ++++------ drivers/ieee1394/hosts.c | 6 ++-- drivers/ieee1394/nodemgr.c | 27 +++++++-------- drivers/ieee1394/ohci1394.c | 20 ++++------- drivers/ieee1394/pcilynx.c | 2 +- drivers/ieee1394/raw1394.c | 38 +++++++++------------ drivers/ieee1394/sbp2.c | 7 ++-- drivers/ieee1394/video1394.c | 81 ++++++++++++++------------------------------ 12 files changed, 85 insertions(+), 143 deletions(-) diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c index 61ddd5d..c0f8ed6 100644 --- a/drivers/ieee1394/csr1212.c +++ b/drivers/ieee1394/csr1212.c @@ -1261,7 +1261,7 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr) return CSR1212_EINVAL; #endif - cr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); + cr = CSR1212_MALLOC(sizeof(*cr)); if (!cr) return CSR1212_ENOMEM; @@ -1393,8 +1393,7 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv, case CSR1212_KV_TYPE_LEAF: if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) { kv->value.leaf.data = CSR1212_MALLOC(quads_to_bytes(kvi_len)); - if (!kv->value.leaf.data) - { + if (!kv->value.leaf.data) { ret = CSR1212_ENOMEM; goto fail; } @@ -1462,7 +1461,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) cache->next = NULL; csr->cache_tail = cache; cache->filled_head = - CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); + CSR1212_MALLOC(sizeof(*cache->filled_head)); if (!cache->filled_head) { return CSR1212_ENOMEM; } @@ -1484,7 +1483,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) /* Now seach read portions of the cache to see if it is there. */ for (cr = cache->filled_head; cr; cr = cr->next) { if (cache_index < cr->offset_start) { - newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); + newcr = CSR1212_MALLOC(sizeof(*newcr)); if (!newcr) return CSR1212_ENOMEM; @@ -1508,7 +1507,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) if (!cr) { cr = cache->filled_tail; - newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); + newcr = CSR1212_MALLOC(sizeof(*newcr)); if (!newcr) return CSR1212_ENOMEM; diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h index 28c5f4b..cecd587 100644 --- a/drivers/ieee1394/csr1212.h +++ b/drivers/ieee1394/csr1212.h @@ -646,7 +646,7 @@ static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u_int32_t o { struct csr1212_csr_rom_cache *cache; - cache = CSR1212_MALLOC(sizeof(struct csr1212_csr_rom_cache) + size); + cache = CSR1212_MALLOC(sizeof(*cache) + size); if (!cache) return NULL; diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index cbbbe14..d204ec7 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c @@ -2218,14 +2218,12 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes unsigned long flags; int i; - video = kmalloc(sizeof(struct video_card), GFP_KERNEL); + video = kzalloc(sizeof(*video), GFP_KERNEL); if (!video) { printk(KERN_ERR "dv1394: cannot allocate video_card\n"); goto err; } - memset(video, 0, sizeof(struct video_card)); - video->ohci = ohci; /* lower 2 bits of id indicate which of four "plugs" per host */ diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index 6984a92..30fa0d4 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c @@ -352,12 +352,12 @@ static int eth1394_probe(struct device *dev) if (!hi) return -ENOENT; - new_node = kmalloc(sizeof(struct eth1394_node_ref), + new_node = kmalloc(sizeof(*new_node), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); if (!new_node) return -ENOMEM; - node_info = kmalloc(sizeof(struct eth1394_node_info), + node_info = kmalloc(sizeof(*node_info), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); if (!node_info) { kfree(new_node); @@ -433,12 +433,12 @@ static int eth1394_update(struct unit_directory *ud) node = eth1394_find_node(&priv->ip_node_list, ud); if (!node) { - node = kmalloc(sizeof(struct eth1394_node_ref), + node = kmalloc(sizeof(*node), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); if (!node) return -ENOMEM; - node_info = kmalloc(sizeof(struct eth1394_node_info), + node_info = kmalloc(sizeof(*node_info), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); if (!node_info) { kfree(node); @@ -1014,7 +1014,7 @@ static inline int new_fragment(struct list_head *frag_info, int offset, int len) } } - new = kmalloc(sizeof(struct fragment_info), GFP_ATOMIC); + new = kmalloc(sizeof(*new), GFP_ATOMIC); if (!new) return -ENOMEM; @@ -1033,7 +1033,7 @@ static inline int new_partial_datagram(struct net_device *dev, { struct partial_datagram *new; - new = kmalloc(sizeof(struct partial_datagram), GFP_ATOMIC); + new = kmalloc(sizeof(*new), GFP_ATOMIC); if (!new) return -ENOMEM; diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c index 997e1bf..734b121 100644 --- a/drivers/ieee1394/highlevel.c +++ b/drivers/ieee1394/highlevel.c @@ -101,12 +101,10 @@ void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, return NULL; } - hi = kmalloc(sizeof(*hi) + data_size, GFP_ATOMIC); + hi = kzalloc(sizeof(*hi) + data_size, GFP_ATOMIC); if (!hi) return NULL; - memset(hi, 0, sizeof(*hi) + data_size); - if (data_size) { data = hi->data = hi + 1; hi->size = data_size; @@ -326,11 +324,9 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl, return retval; } - as = (struct hpsb_address_serve *) - kmalloc(sizeof(struct hpsb_address_serve), GFP_KERNEL); - if (as == NULL) { + as = kmalloc(sizeof(*as), GFP_KERNEL); + if (!as) return retval; - } INIT_LIST_HEAD(&as->host_list); INIT_LIST_HEAD(&as->hl_list); @@ -383,11 +379,9 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, return 0; } - as = (struct hpsb_address_serve *) - kmalloc(sizeof(struct hpsb_address_serve), GFP_ATOMIC); - if (as == NULL) { - return 0; - } + as = kmalloc(sizeof(*as), GFP_ATOMIC); + if (!as) + return 0; INIT_LIST_HEAD(&as->host_list); INIT_LIST_HEAD(&as->hl_list); diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c index aeeaeb6..d245abe 100644 --- a/drivers/ieee1394/hosts.c +++ b/drivers/ieee1394/hosts.c @@ -114,9 +114,9 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, int i; int hostnum = 0; - h = kmalloc(sizeof(struct hpsb_host) + extra, SLAB_KERNEL); - if (!h) return NULL; - memset(h, 0, sizeof(struct hpsb_host) + extra); + h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); + if (!h) + return NULL; h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); if (!h->csr.rom) { diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 7fff5a1..3f0917b 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -743,21 +743,20 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr unsigned int generation) { struct hpsb_host *host = hi->host; - struct node_entry *ne; - - ne = kmalloc(sizeof(struct node_entry), GFP_KERNEL); - if (!ne) return NULL; + struct node_entry *ne; - memset(ne, 0, sizeof(struct node_entry)); + ne = kzalloc(sizeof(*ne), GFP_KERNEL); + if (!ne) + return NULL; ne->tpool = &host->tpool[nodeid & NODE_MASK]; - ne->host = host; - ne->nodeid = nodeid; + ne->host = host; + ne->nodeid = nodeid; ne->generation = generation; ne->needs_probe = 1; - ne->guid = guid; + ne->guid = guid; ne->guid_vendor_id = (guid >> 40) & 0xffffff; ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id); ne->csr = csr; @@ -787,7 +786,7 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr (host->node_id == nodeid) ? "Host" : "Node", NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid); - return ne; + return ne; } @@ -872,12 +871,10 @@ static struct unit_directory *nodemgr_process_unit_directory struct csr1212_keyval *kv; u8 last_key_id = 0; - ud = kmalloc(sizeof(struct unit_directory), GFP_KERNEL); + ud = kzalloc(sizeof(*ud), GFP_KERNEL); if (!ud) goto unit_directory_error; - memset (ud, 0, sizeof(struct unit_directory)); - ud->ne = ne; ud->ignore_driver = ignore_drivers; ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE; @@ -937,10 +934,10 @@ static struct unit_directory *nodemgr_process_unit_directory /* Logical Unit Number */ if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { if (ud->flags & UNIT_DIRECTORY_HAS_LUN) { - ud_child = kmalloc(sizeof(struct unit_directory), GFP_KERNEL); + ud_child = kmalloc(sizeof(*ud_child), GFP_KERNEL); if (!ud_child) goto unit_directory_error; - memcpy(ud_child, ud, sizeof(struct unit_directory)); + memcpy(ud_child, ud, sizeof(*ud_child)); nodemgr_register_device(ne, ud_child, &ne->device); ud_child = NULL; @@ -1200,7 +1197,7 @@ static void nodemgr_node_scan_one(struct host_info *hi, struct csr1212_csr *csr; struct nodemgr_csr_info *ci; - ci = kmalloc(sizeof(struct nodemgr_csr_info), GFP_KERNEL); + ci = kmalloc(sizeof(*ci), GFP_KERNEL); if (!ci) return; diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 8355068..97b6f48 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -2957,28 +2957,23 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d, d->ctrlClear = 0; d->cmdPtr = 0; - d->buf_cpu = kmalloc(d->num_desc * sizeof(quadlet_t*), GFP_ATOMIC); - d->buf_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC); + d->buf_cpu = kzalloc(d->num_desc * sizeof(*d->buf_cpu), GFP_ATOMIC); + d->buf_bus = kzalloc(d->num_desc * sizeof(*d->buf_bus), GFP_ATOMIC); if (d->buf_cpu == NULL || d->buf_bus == NULL) { PRINT(KERN_ERR, "Failed to allocate dma buffer"); free_dma_rcv_ctx(d); return -ENOMEM; } - memset(d->buf_cpu, 0, d->num_desc * sizeof(quadlet_t*)); - memset(d->buf_bus, 0, d->num_desc * sizeof(dma_addr_t)); - d->prg_cpu = kmalloc(d->num_desc * sizeof(struct dma_cmd*), - GFP_ATOMIC); - d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC); + d->prg_cpu = kzalloc(d->num_desc * sizeof(*d->prg_cpu), GFP_ATOMIC); + d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_ATOMIC); if (d->prg_cpu == NULL || d->prg_bus == NULL) { PRINT(KERN_ERR, "Failed to allocate dma prg"); free_dma_rcv_ctx(d); return -ENOMEM; } - memset(d->prg_cpu, 0, d->num_desc * sizeof(struct dma_cmd*)); - memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t)); d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC); @@ -3090,17 +3085,14 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d, d->ctrlClear = 0; d->cmdPtr = 0; - d->prg_cpu = kmalloc(d->num_desc * sizeof(struct at_dma_prg*), - GFP_KERNEL); - d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL); + d->prg_cpu = kzalloc(d->num_desc * sizeof(*d->prg_cpu), GFP_KERNEL); + d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_KERNEL); if (d->prg_cpu == NULL || d->prg_bus == NULL) { PRINT(KERN_ERR, "Failed to allocate at dma prg"); free_dma_trm_ctx(d); return -ENOMEM; } - memset(d->prg_cpu, 0, d->num_desc * sizeof(struct at_dma_prg*)); - memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t)); len = sprintf(pool_name, "ohci1394_trm_prg"); sprintf(pool_name+len, "%d", num_allocs); diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c index 6b1ab87..e2edc41 100644 --- a/drivers/ieee1394/pcilynx.c +++ b/drivers/ieee1394/pcilynx.c @@ -1435,7 +1435,7 @@ static int __devinit add_card(struct pci_dev *dev, struct i2c_algo_bit_data i2c_adapter_data; error = -ENOMEM; - i2c_ad = kmalloc(sizeof(struct i2c_adapter), SLAB_KERNEL); + i2c_ad = kmalloc(sizeof(*i2c_ad), SLAB_KERNEL); if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter)); diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 24411e6..0278dc5d 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -102,12 +102,9 @@ static struct pending_request *__alloc_pending_request(gfp_t flags) { struct pending_request *req; - req = (struct pending_request *)kmalloc(sizeof(struct pending_request), - flags); - if (req != NULL) { - memset(req, 0, sizeof(struct pending_request)); + req = kzalloc(sizeof(*req), flags); + if (req) INIT_LIST_HEAD(&req->list); - } return req; } @@ -192,9 +189,9 @@ static void add_host(struct hpsb_host *host) struct host_info *hi; unsigned long flags; - hi = (struct host_info *)kmalloc(sizeof(struct host_info), GFP_KERNEL); + hi = kmalloc(sizeof(*hi), GFP_KERNEL); - if (hi != NULL) { + if (hi) { INIT_LIST_HEAD(&hi->list); hi->host = host; INIT_LIST_HEAD(&hi->file_info_list); @@ -315,8 +312,8 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data, break; if (!ibs) { - ibs = kmalloc(sizeof(struct iso_block_store) - + length, SLAB_ATOMIC); + ibs = kmalloc(sizeof(*ibs) + length, + SLAB_ATOMIC); if (!ibs) { kfree(req); break; @@ -376,8 +373,8 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction, break; if (!ibs) { - ibs = kmalloc(sizeof(struct iso_block_store) - + length, SLAB_ATOMIC); + ibs = kmalloc(sizeof(*ibs) + length, + SLAB_ATOMIC); if (!ibs) { kfree(req); break; @@ -502,10 +499,9 @@ static int state_initialized(struct file_info *fi, struct pending_request *req) switch (req->req.type) { case RAW1394_REQ_LIST_CARDS: spin_lock_irqsave(&host_info_lock, flags); - khl = kmalloc(sizeof(struct raw1394_khost_list) * host_count, - SLAB_ATOMIC); + khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC); - if (khl != NULL) { + if (khl) { req->req.misc = host_count; req->data = (quadlet_t *) khl; @@ -517,7 +513,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req) } spin_unlock_irqrestore(&host_info_lock, flags); - if (khl != NULL) { + if (khl) { req->req.error = RAW1394_ERROR_NONE; req->req.length = min(req->req.length, (u32) (sizeof @@ -1647,13 +1643,13 @@ static int arm_register(struct file_info *fi, struct pending_request *req) return (-EINVAL); } /* addr-list-entry for fileinfo */ - addr = (struct arm_addr *)kmalloc(sizeof(struct arm_addr), SLAB_KERNEL); + addr = kmalloc(sizeof(*addr), SLAB_KERNEL); if (!addr) { req->req.length = 0; return (-ENOMEM); } /* allocation of addr_space_buffer */ - addr->addr_space_buffer = (u8 *) vmalloc(req->req.length); + addr->addr_space_buffer = vmalloc(req->req.length); if (!(addr->addr_space_buffer)) { kfree(addr); req->req.length = 0; @@ -2122,8 +2118,7 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req) return -ENOMEM; } - cache->filled_head = - kmalloc(sizeof(struct csr1212_cache_region), GFP_KERNEL); + cache->filled_head = kmalloc(sizeof(*cache->filled_head), GFP_KERNEL); if (!cache->filled_head) { csr1212_release_keyval(fi->csr1212_dirs[dr]); fi->csr1212_dirs[dr] = NULL; @@ -2684,11 +2679,10 @@ static int raw1394_open(struct inode *inode, struct file *file) { struct file_info *fi; - fi = kmalloc(sizeof(struct file_info), SLAB_KERNEL); - if (fi == NULL) + fi = kzalloc(sizeof(*fi), SLAB_KERNEL); + if (!fi) return -ENOMEM; - memset(fi, 0, sizeof(struct file_info)); fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ INIT_LIST_HEAD(&fi->list); diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index b871116..84875cd 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -411,14 +411,12 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); for (i = 0; i < orbs; i++) { - command = (struct sbp2_command_info *) - kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC); + command = kzalloc(sizeof(*command), GFP_ATOMIC); if (!command) { spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); return -ENOMEM; } - memset(command, '\0', sizeof(struct sbp2_command_info)); command->command_orb_dma = pci_map_single(hi->host->pdev, &command->command_orb, sizeof(struct sbp2_command_orb), @@ -714,12 +712,11 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud SBP2_DEBUG("sbp2_alloc_device"); - scsi_id = kmalloc(sizeof(*scsi_id), GFP_KERNEL); + scsi_id = kzalloc(sizeof(*scsi_id), GFP_KERNEL); if (!scsi_id) { SBP2_ERR("failed to create scsi_id"); goto failed_alloc; } - memset(scsi_id, 0, sizeof(*scsi_id)); scsi_id->ne = ud->ne; scsi_id->ud = ud; diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 23911da..2ad30cd 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -206,14 +206,12 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, struct dma_iso_ctx *d; int i; - d = kmalloc(sizeof(struct dma_iso_ctx), GFP_KERNEL); - if (d == NULL) { + d = kzalloc(sizeof(*d), GFP_KERNEL); + if (!d) { PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx"); return NULL; } - memset(d, 0, sizeof *d); - d->ohci = ohci; d->type = type; d->channel = channel; @@ -251,9 +249,8 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, } d->ctx = d->iso_tasklet.context; - d->prg_reg = kmalloc(d->num_desc * sizeof(struct dma_prog_region), - GFP_KERNEL); - if (d->prg_reg == NULL) { + d->prg_reg = kmalloc(d->num_desc * sizeof(*d->prg_reg), GFP_KERNEL); + if (!d->prg_reg) { PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs"); free_dma_iso_ctx(d); return NULL; @@ -268,15 +265,14 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, d->cmdPtr = OHCI1394_IsoRcvCommandPtr+32*d->ctx; d->ctxMatch = OHCI1394_IsoRcvContextMatch+32*d->ctx; - d->ir_prg = kmalloc(d->num_desc * sizeof(struct dma_cmd *), + d->ir_prg = kzalloc(d->num_desc * sizeof(*d->ir_prg), GFP_KERNEL); - if (d->ir_prg == NULL) { + if (!d->ir_prg) { PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg"); free_dma_iso_ctx(d); return NULL; } - memset(d->ir_prg, 0, d->num_desc * sizeof(struct dma_cmd *)); d->nb_cmd = d->buf_size / PAGE_SIZE + 1; d->left_size = (d->frame_size % PAGE_SIZE) ? @@ -297,16 +293,15 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, d->ctrlClear = OHCI1394_IsoXmitContextControlClear+16*d->ctx; d->cmdPtr = OHCI1394_IsoXmitCommandPtr+16*d->ctx; - d->it_prg = kmalloc(d->num_desc * sizeof(struct it_dma_prg *), + d->it_prg = kzalloc(d->num_desc * sizeof(*d->it_prg), GFP_KERNEL); - if (d->it_prg == NULL) { + if (!d->it_prg) { PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma it prg"); free_dma_iso_ctx(d); return NULL; } - memset(d->it_prg, 0, d->num_desc*sizeof(struct it_dma_prg *)); d->packet_size = packet_size; @@ -337,47 +332,24 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, } } - d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int), - GFP_KERNEL); - d->buffer_prg_assignment = kmalloc(d->num_desc * sizeof(unsigned int), - GFP_KERNEL); - d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval), - GFP_KERNEL); - d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int), - GFP_KERNEL); - d->next_buffer = kmalloc(d->num_desc * sizeof(int), - GFP_KERNEL); - - if (d->buffer_status == NULL) { - PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_status"); - free_dma_iso_ctx(d); - return NULL; - } - if (d->buffer_prg_assignment == NULL) { - PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_prg_assignment"); - free_dma_iso_ctx(d); - return NULL; - } - if (d->buffer_time == NULL) { - PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time"); - free_dma_iso_ctx(d); - return NULL; - } - if (d->last_used_cmd == NULL) { - PRINT(KERN_ERR, ohci->host->id, "Failed to allocate last_used_cmd"); - free_dma_iso_ctx(d); - return NULL; - } - if (d->next_buffer == NULL) { - PRINT(KERN_ERR, ohci->host->id, "Failed to allocate next_buffer"); + d->buffer_status = + kzalloc(d->num_desc * sizeof(*d->buffer_status), GFP_KERNEL); + d->buffer_prg_assignment = + kzalloc(d->num_desc * sizeof(*d->buffer_prg_assignment), GFP_KERNEL); + d->buffer_time = + kzalloc(d->num_desc * sizeof(*d->buffer_time), GFP_KERNEL); + d->last_used_cmd = + kzalloc(d->num_desc * sizeof(*d->last_used_cmd), GFP_KERNEL); + d->next_buffer = + kzalloc(d->num_desc * sizeof(*d->next_buffer), GFP_KERNEL); + + if (!d->buffer_status || !d->buffer_prg_assignment || !d->buffer_time || + !d->last_used_cmd || !d->next_buffer) { + PRINT(KERN_ERR, ohci->host->id, + "Failed to allocate dma_iso_ctx member"); free_dma_iso_ctx(d); return NULL; } - memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int)); - memset(d->buffer_prg_assignment, 0, d->num_desc * sizeof(unsigned int)); - memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval)); - memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int)); - memset(d->next_buffer, -1, d->num_desc * sizeof(int)); spin_lock_init(&d->lock); @@ -1085,7 +1057,7 @@ static int __video1394_ioctl(struct file *file, } if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { - int buf_size = d->nb_cmd * sizeof(unsigned int); + int buf_size = d->nb_cmd * sizeof(*psizes); struct video1394_queue_variable __user *p = argp; unsigned int __user *qv; @@ -1251,13 +1223,12 @@ static int video1394_open(struct inode *inode, struct file *file) if (ohci == NULL) return -EIO; - ctx = kmalloc(sizeof(struct file_ctx), GFP_KERNEL); - if (ctx == NULL) { + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + if (!ctx) { PRINT(KERN_ERR, ohci->host->id, "Cannot malloc file_ctx"); return -ENOMEM; } - memset(ctx, 0, sizeof(struct file_ctx)); ctx->ohci = ohci; INIT_LIST_HEAD(&ctx->context_list); ctx->current_ctx = NULL; -- cgit v1.1 From ef797546a93fffa9d8508e7c8539b352b6678568 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 7 Nov 2005 06:31:50 -0500 Subject: Remove definitions of unreferenced macros virt_to_page and vmalloc_32 from dv1394 and video1394. Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/dv1394.c | 9 --------- drivers/ieee1394/video1394.c | 8 -------- 2 files changed, 17 deletions(-) diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index d204ec7..196db74 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c @@ -123,15 +123,6 @@ #include "ohci1394.h" -#ifndef virt_to_page -#define virt_to_page(x) MAP_NR(x) -#endif - -#ifndef vmalloc_32 -#define vmalloc_32(x) vmalloc(x) -#endif - - /* DEBUG LEVELS: 0 - no debugging messages 1 - some debugging messages, but none during DMA frame transmission diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 2ad30cd..07050f0 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -77,14 +77,6 @@ #define ISO_CHANNELS 64 -#ifndef virt_to_page -#define virt_to_page(x) MAP_NR(x) -#endif - -#ifndef vmalloc_32 -#define vmalloc_32(x) vmalloc(x) -#endif - struct it_dma_prg { struct dma_cmd begin; quadlet_t data[4]; -- cgit v1.1 From 760559e1330a58cc5b320154a20e64b8444143c0 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Thu, 10 Nov 2005 04:31:55 -0500 Subject: [netdrvr 8139too] fast poll for thread, if an unlikely race occurs The rtl8139 thread is triggered only on rare 8139 hardware, the race itself is unlikely, and the impact of racing is low. We don't care enough to create a more-complex race-free solution. Rather, if the trylock fails, we now simply poll twice a second until we do get the lock. --- drivers/net/8139too.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 120baaa..d2102a2 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c @@ -1598,13 +1598,19 @@ static void rtl8139_thread (void *_data) { struct net_device *dev = _data; struct rtl8139_private *tp = netdev_priv(dev); + unsigned long thr_delay; if (rtnl_shlock_nowait() == 0) { rtl8139_thread_iter (dev, tp, tp->mmio_addr); rtnl_unlock (); + + thr_delay = next_tick; + } else { + /* unlikely race. mitigate with fast poll. */ + thr_delay = HZ / 2; } - schedule_delayed_work(&tp->thread, next_tick); + schedule_delayed_work(&tp->thread, thr_delay); } static void rtl8139_start_thread(struct rtl8139_private *tp) -- cgit v1.1 From d0bbccfa3297d3ef6ae4691585abde9a6c26b186 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 10 Nov 2005 15:29:27 -0800 Subject: [PATCH] sky2 needs dma_mapping.h On alpha: drivers/net/sky2.c: In function `sky2_probe': drivers/net/sky2.c:2819: error: `DMA_64BIT_MASK' undeclared (first use in this function) drivers/net/sky2.c:2819: error: (Each undeclared identifier is reported only once drivers/net/sky2.c:2819: error: for each function it appears in.) drivers/net/sky2.c:2825: error: `DMA_32BIT_MASK' undeclared (first use in this function) Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index e08695a..9f89000 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include -- cgit v1.1 From 1e2e5659656b8b9bd9fa4714355d91282cb74178 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:34:01 -0800 Subject: [PATCH] net: allow newline terminated IP addresses in in_aton in_aton() gives weird results if it sees a newline at the end of the input. This patch makes it able to handle such input correctly. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- net/core/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/utils.c b/net/core/utils.c index 7b5970f..587eb77 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -175,7 +175,7 @@ __u32 in_aton(const char *str) if (*str != '\0') { val = 0; - while (*str != '\0' && *str != '.') + while (*str != '\0' && *str != '.' && *str != '\n') { val *= 10; val += *str - '0'; -- cgit v1.1 From c2373ee98982a1c842dfb213c398f388d4227e63 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:34:45 -0800 Subject: [PATCH] net: make dev_valid_name public dev_valid_name() is a useful function. Make it public. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- include/linux/netdevice.h | 1 + net/core/dev.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 936f8b7..4fceff0 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -684,6 +684,7 @@ extern int netif_rx(struct sk_buff *skb); extern int netif_rx_ni(struct sk_buff *skb); #define HAVE_NETIF_RECEIVE_SKB 1 extern int netif_receive_skb(struct sk_buff *skb); +extern int dev_valid_name(const char *name); extern int dev_ioctl(unsigned int cmd, void __user *); extern int dev_ethtool(struct ifreq *); extern unsigned dev_get_flags(const struct net_device *); diff --git a/net/core/dev.c b/net/core/dev.c index 0b48e29..94e642e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -626,7 +626,7 @@ struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mas * Network device names need to be valid file names to * to allow sysfs to work */ -static int dev_valid_name(const char *name) +int dev_valid_name(const char *name) { return !(*name == '\0' || !strcmp(name, ".") @@ -3269,6 +3269,7 @@ EXPORT_SYMBOL(__dev_get_by_index); EXPORT_SYMBOL(__dev_get_by_name); EXPORT_SYMBOL(__dev_remove_pack); EXPORT_SYMBOL(__skb_linearize); +EXPORT_SYMBOL(dev_valid_name); EXPORT_SYMBOL(dev_add_pack); EXPORT_SYMBOL(dev_alloc_name); EXPORT_SYMBOL(dev_close); -- cgit v1.1 From 4e0952c74ee450ded86e8946ce58ea8dfd05b007 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:34:57 -0800 Subject: [PATCH] bonding: add bond name to all error messages Add the bond name to all error messages so we can tell which one is complaining. Also reformats some error messages to be more consistent. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_3ad.c | 74 +++++++++++++++++++++------------- drivers/net/bonding/bond_alb.c | 30 ++++++++------ drivers/net/bonding/bond_main.c | 89 ++++++++++++++++++++++------------------- 3 files changed, 112 insertions(+), 81 deletions(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index d2f34d5..0470523 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -1198,10 +1198,10 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) // detect loopback situation if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { // INFO_RECEIVED_LOOPBACK_FRAMES - printk(KERN_ERR DRV_NAME ": An illegal loopback occurred on adapter (%s)\n", - port->slave->dev->name); - printk(KERN_ERR "Check the configuration to verify that all Adapters " - "are connected to 802.3ad compliant switch ports\n"); + printk(KERN_ERR DRV_NAME ": %s: An illegal loopback occurred on " + "adapter (%s). Check the configuration to verify that all " + "Adapters are connected to 802.3ad compliant switch ports\n", + port->slave->dev->master->name, port->slave->dev->name); __release_rx_machine_lock(port); return; } @@ -1378,8 +1378,9 @@ static void ad_port_selection_logic(struct port *port) } } if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list - printk(KERN_WARNING DRV_NAME ": Warning: Port %d (on %s) was " + printk(KERN_WARNING DRV_NAME ": %s: Warning: Port %d (on %s) was " "related to aggregator %d but was not on its port list\n", + port->slave->dev->master->name, port->actor_port_number, port->slave->dev->name, port->aggregator->aggregator_identifier); } @@ -1450,7 +1451,8 @@ static void ad_port_selection_logic(struct port *port) dprintk("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); } else { - printk(KERN_ERR DRV_NAME ": Port %d (on %s) did not find a suitable aggregator\n", + printk(KERN_ERR DRV_NAME ": %s: Port %d (on %s) did not find a suitable aggregator\n", + port->slave->dev->master->name, port->actor_port_number, port->slave->dev->name); } } @@ -1582,8 +1584,9 @@ static void ad_agg_selection_logic(struct aggregator *aggregator) // check if any partner replys if (best_aggregator->is_individual) { - printk(KERN_WARNING DRV_NAME ": Warning: No 802.3ad response from the link partner " - "for any adapters in the bond\n"); + printk(KERN_WARNING DRV_NAME ": %s: Warning: No 802.3ad response from " + "the link partner for any adapters in the bond\n", + best_aggregator->slave->dev->master->name); } // check if there are more than one aggregator @@ -1915,7 +1918,8 @@ int bond_3ad_bind_slave(struct slave *slave) struct aggregator *aggregator; if (bond == NULL) { - printk(KERN_ERR "The slave %s is not attached to its bond\n", slave->dev->name); + printk(KERN_ERR DRV_NAME ": %s: The slave %s is not attached to its bond\n", + slave->dev->master->name, slave->dev->name); return -1; } @@ -1990,7 +1994,9 @@ void bond_3ad_unbind_slave(struct slave *slave) // if slave is null, the whole port is not initialized if (!port->slave) { - printk(KERN_WARNING DRV_NAME ": Trying to unbind an uninitialized port on %s\n", slave->dev->name); + printk(KERN_WARNING DRV_NAME ": Warning: %s: Trying to " + "unbind an uninitialized port on %s\n", + slave->dev->master->name, slave->dev->name); return; } @@ -2021,7 +2027,8 @@ void bond_3ad_unbind_slave(struct slave *slave) dprintk("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier); if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) { - printk(KERN_INFO DRV_NAME ": Removing an active aggregator\n"); + printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", + aggregator->slave->dev->master->name); // select new active aggregator select_new_active_agg = 1; } @@ -2051,15 +2058,17 @@ void bond_3ad_unbind_slave(struct slave *slave) ad_agg_selection_logic(__get_first_agg(port)); } } else { - printk(KERN_WARNING DRV_NAME ": Warning: unbinding aggregator, " - "and could not find a new aggregator for its ports\n"); + printk(KERN_WARNING DRV_NAME ": %s: Warning: unbinding aggregator, " + "and could not find a new aggregator for its ports\n", + slave->dev->master->name); } } else { // in case that the only port related to this aggregator is the one we want to remove select_new_active_agg = aggregator->is_active; // clear the aggregator ad_clear_agg(aggregator); if (select_new_active_agg) { - printk(KERN_INFO "Removing an active aggregator\n"); + printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", + slave->dev->master->name); // select new active aggregator ad_agg_selection_logic(__get_first_agg(port)); } @@ -2085,7 +2094,8 @@ void bond_3ad_unbind_slave(struct slave *slave) // clear the aggregator ad_clear_agg(temp_aggregator); if (select_new_active_agg) { - printk(KERN_INFO "Removing an active aggregator\n"); + printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n", + slave->dev->master->name); // select new active aggregator ad_agg_selection_logic(__get_first_agg(port)); } @@ -2131,7 +2141,8 @@ void bond_3ad_state_machine_handler(struct bonding *bond) // select the active aggregator for the bond if ((port = __get_first_port(bond))) { if (!port->slave) { - printk(KERN_WARNING DRV_NAME ": Warning: bond's first port is uninitialized\n"); + printk(KERN_WARNING DRV_NAME ": %s: Warning: bond's first port is " + "uninitialized\n", bond->dev->name); goto re_arm; } @@ -2143,7 +2154,8 @@ void bond_3ad_state_machine_handler(struct bonding *bond) // for each port run the state machines for (port = __get_first_port(bond); port; port = __get_next_port(port)) { if (!port->slave) { - printk(KERN_WARNING DRV_NAME ": Warning: Found an uninitialized port\n"); + printk(KERN_WARNING DRV_NAME ": %s: Warning: Found an uninitialized " + "port\n", bond->dev->name); goto re_arm; } @@ -2184,7 +2196,8 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u port = &(SLAVE_AD_INFO(slave).port); if (!port->slave) { - printk(KERN_WARNING DRV_NAME ": Warning: port of slave %s is uninitialized\n", slave->dev->name); + printk(KERN_WARNING DRV_NAME ": %s: Warning: port of slave %s is " + "uninitialized\n", slave->dev->name, slave->dev->master->name); return; } @@ -2230,8 +2243,9 @@ void bond_3ad_adapter_speed_changed(struct slave *slave) // if slave is null, the whole port is not initialized if (!port->slave) { - printk(KERN_WARNING DRV_NAME ": Warning: speed changed for uninitialized port on %s\n", - slave->dev->name); + printk(KERN_WARNING DRV_NAME ": Warning: %s: speed " + "changed for uninitialized port on %s\n", + slave->dev->master->name, slave->dev->name); return; } @@ -2257,8 +2271,9 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave) // if slave is null, the whole port is not initialized if (!port->slave) { - printk(KERN_WARNING DRV_NAME ": Warning: duplex changed for uninitialized port on %s\n", - slave->dev->name); + printk(KERN_WARNING DRV_NAME ": %s: Warning: duplex changed " + "for uninitialized port on %s\n", + slave->dev->master->name, slave->dev->name); return; } @@ -2285,8 +2300,9 @@ void bond_3ad_handle_link_change(struct slave *slave, char link) // if slave is null, the whole port is not initialized if (!port->slave) { - printk(KERN_WARNING DRV_NAME ": Warning: link status changed for uninitialized port on %s\n", - slave->dev->name); + printk(KERN_WARNING DRV_NAME ": Warning: %s: link status changed for " + "uninitialized port on %s\n", + slave->dev->master->name, slave->dev->name); return; } @@ -2363,7 +2379,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) } if (bond_3ad_get_active_agg_info(bond, &ad_info)) { - printk(KERN_DEBUG "ERROR: bond_3ad_get_active_agg_info failed\n"); + printk(KERN_DEBUG DRV_NAME ": %s: Error: " + "bond_3ad_get_active_agg_info failed\n", dev->name); goto out; } @@ -2372,7 +2389,9 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) if (slaves_in_agg == 0) { /*the aggregator is empty*/ - printk(KERN_DEBUG "ERROR: active aggregator is empty\n"); + printk(KERN_DEBUG DRV_NAME ": %s: Error: active " + "aggregator is empty\n", + dev->name); goto out; } @@ -2390,7 +2409,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) } if (slave_agg_no >= 0) { - printk(KERN_ERR DRV_NAME ": Error: Couldn't find a slave to tx on for aggregator ID %d\n", agg_id); + printk(KERN_ERR DRV_NAME ": %s: Error: Couldn't find a slave to tx on " + "for aggregator ID %d\n", dev->name, agg_id); goto out; } diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index f8fce39..96dfb90 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -207,7 +207,7 @@ static int tlb_initialize(struct bonding *bond) bond_info->tx_hashtbl = kmalloc(size, GFP_KERNEL); if (!bond_info->tx_hashtbl) { printk(KERN_ERR DRV_NAME - ": Error: %s: Failed to allocate TLB hash table\n", + ": %s: Error: Failed to allocate TLB hash table\n", bond->dev->name); _unlock_tx_hashtbl(bond); return -1; @@ -513,7 +513,8 @@ static void rlb_update_client(struct rlb_client_info *client_info) client_info->mac_dst); if (!skb) { printk(KERN_ERR DRV_NAME - ": Error: failed to create an ARP packet\n"); + ": %s: Error: failed to create an ARP packet\n", + client_info->slave->dev->master->name); continue; } @@ -523,7 +524,8 @@ static void rlb_update_client(struct rlb_client_info *client_info) skb = vlan_put_tag(skb, client_info->vlan_id); if (!skb) { printk(KERN_ERR DRV_NAME - ": Error: failed to insert VLAN tag\n"); + ": %s: Error: failed to insert VLAN tag\n", + client_info->slave->dev->master->name); continue; } } @@ -606,8 +608,9 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, u32 src_ip) if (!client_info->slave) { printk(KERN_ERR DRV_NAME - ": Error: found a client with no channel in " - "the client's hash table\n"); + ": %s: Error: found a client with no channel in " + "the client's hash table\n", + bond->dev->name); continue; } /*update all clients using this src_ip, that are not assigned @@ -807,7 +810,7 @@ static int rlb_initialize(struct bonding *bond) bond_info->rx_hashtbl = kmalloc(size, GFP_KERNEL); if (!bond_info->rx_hashtbl) { printk(KERN_ERR DRV_NAME - ": Error: %s: Failed to allocate RLB hash table\n", + ": %s: Error: Failed to allocate RLB hash table\n", bond->dev->name); _unlock_rx_hashtbl(bond); return -1; @@ -927,7 +930,8 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) skb = vlan_put_tag(skb, vlan->vlan_id); if (!skb) { printk(KERN_ERR DRV_NAME - ": Error: failed to insert VLAN tag\n"); + ": %s: Error: failed to insert VLAN tag\n", + bond->dev->name); continue; } } @@ -956,11 +960,11 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw) s_addr.sa_family = dev->type; if (dev_set_mac_address(dev, &s_addr)) { printk(KERN_ERR DRV_NAME - ": Error: dev_set_mac_address of dev %s failed! ALB " + ": %s: Error: dev_set_mac_address of dev %s failed! ALB " "mode requires that the base driver support setting " "the hw address also when the network device's " "interface is open\n", - dev->name); + dev->master->name, dev->name); return -EOPNOTSUPP; } return 0; @@ -1153,16 +1157,16 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav bond->alb_info.rlb_enabled); printk(KERN_WARNING DRV_NAME - ": Warning: the hw address of slave %s is in use by " + ": %s: Warning: the hw address of slave %s is in use by " "the bond; giving it the hw address of %s\n", - slave->dev->name, free_mac_slave->dev->name); + bond->dev->name, slave->dev->name, free_mac_slave->dev->name); } else if (has_bond_addr) { printk(KERN_ERR DRV_NAME - ": Error: the hw address of slave %s is in use by the " + ": %s: Error: the hw address of slave %s is in use by the " "bond; couldn't find a slave with a free hw address to " "give it (this should not have happened)\n", - slave->dev->name); + bond->dev->name, slave->dev->name); return -EFAULT; } diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 94cec3c..7838522 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -910,7 +910,7 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid) res = bond_add_vlan(bond, vid); if (res) { printk(KERN_ERR DRV_NAME - ": %s: Failed to add vlan id %d\n", + ": %s: Error: Failed to add vlan id %d\n", bond_dev->name, vid); } } @@ -944,7 +944,7 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid) res = bond_del_vlan(bond, vid); if (res) { printk(KERN_ERR DRV_NAME - ": %s: Failed to remove vlan id %d\n", + ": %s: Error: Failed to remove vlan id %d\n", bond_dev->name, vid); } } @@ -1644,8 +1644,8 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL && slave_dev->do_ioctl == NULL) { printk(KERN_WARNING DRV_NAME - ": Warning : no link monitoring support for %s\n", - slave_dev->name); + ": %s: Warning: no link monitoring support for %s\n", + bond_dev->name, slave_dev->name); } /* bond must be initialized by bond_open() before enslaving */ @@ -1666,17 +1666,17 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de dprintk("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name); if (!list_empty(&bond->vlan_list)) { printk(KERN_ERR DRV_NAME - ": Error: cannot enslave VLAN " + ": %s: Error: cannot enslave VLAN " "challenged slave %s on VLAN enabled " - "bond %s\n", slave_dev->name, + "bond %s\n", bond_dev->name, slave_dev->name, bond_dev->name); return -EPERM; } else { printk(KERN_WARNING DRV_NAME - ": Warning: enslaved VLAN challenged " + ": %s: Warning: enslaved VLAN challenged " "slave %s. Adding VLANs will be blocked as " "long as %s is part of bond %s\n", - slave_dev->name, slave_dev->name, + bond_dev->name, slave_dev->name, slave_dev->name, bond_dev->name); bond_dev->features |= NETIF_F_VLAN_CHALLENGED; } @@ -1706,12 +1706,11 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de if (slave_dev->set_mac_address == NULL) { printk(KERN_ERR DRV_NAME - ": Error: The slave device you specified does " - "not support setting the MAC address.\n"); - printk(KERN_ERR - "Your kernel likely does not support slave devices.\n"); - - res = -EOPNOTSUPP; + ": %s: Error: The slave device you specified does " + "not support setting the MAC address. " + "Your kernel likely does not support slave " + "devices.\n", bond_dev->name); + res = -EOPNOTSUPP; goto err_undo_flags; } @@ -1827,21 +1826,21 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de * the messages for netif_carrier. */ printk(KERN_WARNING DRV_NAME - ": Warning: MII and ETHTOOL support not " + ": %s: Warning: MII and ETHTOOL support not " "available for interface %s, and " "arp_interval/arp_ip_target module parameters " "not specified, thus bonding will not detect " "link failures! see bonding.txt for details.\n", - slave_dev->name); + bond_dev->name, slave_dev->name); } else if (link_reporting == -1) { /* unable get link status using mii/ethtool */ printk(KERN_WARNING DRV_NAME - ": Warning: can't get link status from " + ": %s: Warning: can't get link status from " "interface %s; the network driver associated " "with this interface does not support MII or " "ETHTOOL link status reporting, thus miimon " "has no effect on this interface.\n", - slave_dev->name); + bond_dev->name, slave_dev->name); } } @@ -1868,15 +1867,15 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de if (bond_update_speed_duplex(new_slave) && (new_slave->link != BOND_LINK_DOWN)) { printk(KERN_WARNING DRV_NAME - ": Warning: failed to get speed and duplex from %s, " + ": %s: Warning: failed to get speed and duplex from %s, " "assumed to be 100Mb/sec and Full.\n", - new_slave->dev->name); + bond_dev->name, new_slave->dev->name); if (bond->params.mode == BOND_MODE_8023AD) { - printk(KERN_WARNING - "Operation of 802.3ad mode requires ETHTOOL " + printk(KERN_WARNING DRV_NAME + ": %s: Warning: Operation of 802.3ad mode requires ETHTOOL " "support in base driver for proper aggregator " - "selection.\n"); + "selection.\n", bond_dev->name); } } @@ -2010,7 +2009,7 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de if (!(slave_dev->flags & IFF_SLAVE) || (slave_dev->master != bond_dev)) { printk(KERN_ERR DRV_NAME - ": Error: %s: cannot release %s.\n", + ": %s: Error: cannot release %s.\n", bond_dev->name, slave_dev->name); return -EINVAL; } @@ -2031,11 +2030,12 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de ETH_ALEN); if (!mac_addr_differ && (bond->slave_cnt > 1)) { printk(KERN_WARNING DRV_NAME - ": Warning: the permanent HWaddr of %s " + ": %s: Warning: the permanent HWaddr of %s " "- %02X:%02X:%02X:%02X:%02X:%02X - is " "still in use by %s. Set the HWaddr of " "%s to a different address to avoid " "conflicts.\n", + bond_dev->name, slave_dev->name, slave->perm_hwaddr[0], slave->perm_hwaddr[1], @@ -2111,19 +2111,20 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de bond_dev->features |= NETIF_F_VLAN_CHALLENGED; } else { printk(KERN_WARNING DRV_NAME - ": Warning: clearing HW address of %s while it " + ": %s: Warning: clearing HW address of %s while it " "still has VLANs.\n", - bond_dev->name); + bond_dev->name, bond_dev->name); printk(KERN_WARNING DRV_NAME - ": When re-adding slaves, make sure the bond's " - "HW address matches its VLANs'.\n"); + ": %s: When re-adding slaves, make sure the bond's " + "HW address matches its VLANs'.\n", + bond_dev->name); } } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) && !bond_has_challenged_slaves(bond)) { printk(KERN_INFO DRV_NAME - ": last VLAN challenged slave %s " + ": %s: last VLAN challenged slave %s " "left bond %s. VLAN blocking is removed\n", - slave_dev->name, bond_dev->name); + bond_dev->name, slave_dev->name, bond_dev->name); bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED; } @@ -2274,12 +2275,13 @@ static int bond_release_all(struct net_device *bond_dev) bond_dev->features |= NETIF_F_VLAN_CHALLENGED; } else { printk(KERN_WARNING DRV_NAME - ": Warning: clearing HW address of %s while it " + ": %s: Warning: clearing HW address of %s while it " "still has VLANs.\n", - bond_dev->name); + bond_dev->name, bond_dev->name); printk(KERN_WARNING DRV_NAME - ": When re-adding slaves, make sure the bond's " - "HW address matches its VLANs'.\n"); + ": %s: When re-adding slaves, make sure the bond's " + "HW address matches its VLANs'.\n", + bond_dev->name); } printk(KERN_INFO DRV_NAME @@ -2596,8 +2598,11 @@ static void bond_mii_monitor(struct net_device *bond_dev) break; default: /* Should not happen */ - printk(KERN_ERR "bonding: Error: %s Illegal value (link=%d)\n", - slave->dev->name, slave->link); + printk(KERN_ERR DRV_NAME + ": %s: Error: %s Illegal value (link=%d)\n", + bond_dev->name, + slave->dev->name, + slave->link); goto out; } /* end of switch (slave->link) */ @@ -4397,8 +4402,9 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); if (!skb2) { printk(KERN_ERR DRV_NAME - ": Error: bond_xmit_broadcast(): " - "skb_clone() failed\n"); + ": %s: Error: bond_xmit_broadcast(): " + "skb_clone() failed\n", + bond_dev->name); continue; } @@ -4467,7 +4473,8 @@ static inline void bond_set_mode_ops(struct bonding *bond, int mode) default: /* Should never happen, mode already checked */ printk(KERN_ERR DRV_NAME - ": Error: Unknown bonding mode %d\n", + ": %s: Error: Unknown bonding mode %d\n", + bond_dev->name, mode); break; } @@ -4670,7 +4677,7 @@ static int bond_check_params(struct bond_params *params) if (max_bonds < 1 || max_bonds > INT_MAX) { printk(KERN_WARNING DRV_NAME ": Warning: max_bonds (%d) not in range %d-%d, so it " - "was reset to BOND_DEFAULT_MAX_BONDS (%d)", + "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n", max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS); max_bonds = BOND_DEFAULT_MAX_BONDS; } -- cgit v1.1 From 2ac47660f9b4d0ea1a2ab9becba03c14ef5d9b99 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:35:03 -0800 Subject: [PATCH] bonding: expand module param descriptions Expand and correct the parameter descriptions shown by modinfo. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 7838522..9a2d266 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -565,17 +565,24 @@ MODULE_PARM_DESC(miimon, "Link check interval in milliseconds"); module_param(updelay, int, 0); MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds"); module_param(downdelay, int, 0); -MODULE_PARM_DESC(downdelay, "Delay before considering link down, in milliseconds"); +MODULE_PARM_DESC(downdelay, "Delay before considering link down, " + "in milliseconds"); module_param(use_carrier, int, 0); -MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default)"); +MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; " + "0 for off, 1 for on (default)"); module_param(mode, charp, 0); -MODULE_PARM_DESC(mode, "Mode of operation : 0 for round robin, 1 for active-backup, 2 for xor"); +MODULE_PARM_DESC(mode, "Mode of operation : 0 for balance-rr, " + "1 for active-backup, 2 for balance-xor, " + "3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, " + "6 for balance-alb"); module_param(primary, charp, 0); MODULE_PARM_DESC(primary, "Primary network device to use"); module_param(lacp_rate, charp, 0); -MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner (slow/fast)"); +MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner " + "(slow/fast)"); module_param(xmit_hash_policy, charp, 0); -MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method : 0 for layer 2 (default), 1 for layer 3+4"); +MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method: 0 for layer 2 (default)" + ", 1 for layer 3+4"); module_param(arp_interval, int, 0); MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); module_param_array(arp_ip_target, charp, NULL, 0); -- cgit v1.1 From c61b75ad03f3a30ef247cac27406f030c10628b0 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:35:13 -0800 Subject: [PATCH] bonding: Add transmit policy to /proc Adds information about the recently-added transmit policy setting to each bond's /proc file. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 9a2d266..9d9f027 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3269,6 +3269,13 @@ static void bond_info_show_master(struct seq_file *seq) seq_printf(seq, "Bonding Mode: %s\n", bond_mode_name(bond->params.mode)); + if (bond->params.mode == BOND_MODE_XOR || + bond->params.mode == BOND_MODE_8023AD) { + seq_printf(seq, "Transmit Hash Policy: %s (%d)\n", + xmit_hashtype_tbl[bond->params.xmit_policy].modename, + bond->params.xmit_policy); + } + if (USES_PRIMARY(bond->params.mode)) { seq_printf(seq, "Primary Slave: %s\n", (bond->params.primary[0]) ? -- cgit v1.1 From 0f418b2ac49e97b7b763e0473320a201eec15ed3 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:35:21 -0800 Subject: [PATCH] bonding: get slave name from actual slave instead of param list Take the primary slave name shown in /proc from the actual slave dev instead of from the command-line parameter, which won't be present if the bond is created via sysfs. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 9d9f027..3e9b47d 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3278,8 +3278,8 @@ static void bond_info_show_master(struct seq_file *seq) if (USES_PRIMARY(bond->params.mode)) { seq_printf(seq, "Primary Slave: %s\n", - (bond->params.primary[0]) ? - bond->params.primary : "None"); + (bond->primary_slave) ? + bond->primary_slave->dev->name : "None"); seq_printf(seq, "Currently Active Slave: %s\n", (curr) ? curr->dev->name : "None"); -- cgit v1.1 From 0d206a3af4329bd833cfa5fe1cc7fe146e49c131 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:35:30 -0800 Subject: [PATCH] bonding: move kmalloc out of spinlock in ALB init Move memory allocations out of the spinlock during ALB init. This gets rid of a sleeping-inside-spinlock warning and accompanying stack dump. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_alb.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 96dfb90..e8d10f3 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -198,20 +198,21 @@ static int tlb_initialize(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info); + struct tlb_client_info *new_hashtbl; int i; spin_lock_init(&(bond_info->tx_hashtbl_lock)); - _lock_tx_hashtbl(bond); - - bond_info->tx_hashtbl = kmalloc(size, GFP_KERNEL); - if (!bond_info->tx_hashtbl) { + new_hashtbl = kmalloc(size, GFP_KERNEL); + if (!new_hashtbl) { printk(KERN_ERR DRV_NAME ": %s: Error: Failed to allocate TLB hash table\n", bond->dev->name); - _unlock_tx_hashtbl(bond); return -1; } + _lock_tx_hashtbl(bond); + + bond_info->tx_hashtbl = new_hashtbl; memset(bond_info->tx_hashtbl, 0, size); @@ -800,21 +801,22 @@ static int rlb_initialize(struct bonding *bond) { struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); + struct rlb_client_info *new_hashtbl; int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); int i; spin_lock_init(&(bond_info->rx_hashtbl_lock)); - _lock_rx_hashtbl(bond); - - bond_info->rx_hashtbl = kmalloc(size, GFP_KERNEL); - if (!bond_info->rx_hashtbl) { + new_hashtbl = kmalloc(size, GFP_KERNEL); + if (!new_hashtbl) { printk(KERN_ERR DRV_NAME ": %s: Error: Failed to allocate RLB hash table\n", bond->dev->name); - _unlock_rx_hashtbl(bond); return -1; } + _lock_rx_hashtbl(bond); + + bond_info->rx_hashtbl = new_hashtbl; bond_info->rx_hashtbl_head = RLB_NULL_INDEX; -- cgit v1.1 From b76850ab577bb4b929e60894d2025bbfcc043984 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:35:35 -0800 Subject: [PATCH] bonding: explicitly clear RLB flag during ALB init Explicitly clear RLB flag during ALB init. This is needed for sysfs support, since the bond mode can be changed at runtime via sysfs. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_alb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index e8d10f3..24f4a3d 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -1256,6 +1256,8 @@ int bond_alb_initialize(struct bonding *bond, int rlb_enabled) tlb_deinitialize(bond); return res; } + } else { + bond->alb_info.rlb_enabled = 0; } return 0; -- cgit v1.1 From 12479f9a823dc7d791f198af2d3e4efae418a65e Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:35:44 -0800 Subject: [PATCH] bonding: expose some structs The sysfs code needs to know what these structs look like, so make them not static, and move the definition to the header. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 13 +++++-------- drivers/net/bonding/bonding.h | 5 +++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 3e9b47d..7139d6e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -557,6 +557,7 @@ static char *lacp_rate = NULL; static char *xmit_hash_policy = NULL; static int arp_interval = BOND_LINK_ARP_INTERV; static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; +struct bond_params bonding_defaults; module_param(max_bonds, int, 0); MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); @@ -593,7 +594,7 @@ MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form"); static const char *version = DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; -static LIST_HEAD(bond_dev_list); +LIST_HEAD(bond_dev_list); #ifdef CONFIG_PROC_FS static struct proc_dir_entry *bond_proc_dir = NULL; @@ -605,18 +606,14 @@ static int bond_mode = BOND_MODE_ROUNDROBIN; static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2; static int lacp_fast = 0; -struct bond_parm_tbl { - char *modename; - int mode; -}; -static struct bond_parm_tbl bond_lacp_tbl[] = { +struct bond_parm_tbl bond_lacp_tbl[] = { { "slow", AD_LACP_SLOW}, { "fast", AD_LACP_FAST}, { NULL, -1}, }; -static struct bond_parm_tbl bond_mode_tbl[] = { +struct bond_parm_tbl bond_mode_tbl[] = { { "balance-rr", BOND_MODE_ROUNDROBIN}, { "active-backup", BOND_MODE_ACTIVEBACKUP}, { "balance-xor", BOND_MODE_XOR}, @@ -627,7 +624,7 @@ static struct bond_parm_tbl bond_mode_tbl[] = { { NULL, -1}, }; -static struct bond_parm_tbl xmit_hashtype_tbl[] = { +struct bond_parm_tbl xmit_hashtype_tbl[] = { { "layer2", BOND_XMIT_POLICY_LAYER2}, { "layer3+4", BOND_XMIT_POLICY_LAYER34}, { NULL, -1}, diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 1433e91..c8a873f 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -152,6 +152,11 @@ struct bond_params { u32 arp_targets[BOND_MAX_ARP_TARGETS]; }; +struct bond_parm_tbl { + char *modename; + int mode; +}; + struct vlan_entry { struct list_head vlan_list; u32 vlan_ip; -- cgit v1.1 From a77b53258d76513c37e766dc0db1fc9db7c4ac1e Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:35:51 -0800 Subject: [PATCH] bonding: make functions not static The sysfs code needs access these functions, so make them not static, and move the protos to the header file. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 25 ++++++++++++------------- drivers/net/bonding/bonding.h | 12 ++++++++++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 7139d6e..b8d6176 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -632,12 +632,11 @@ struct bond_parm_tbl xmit_hashtype_tbl[] = { /*-------------------------- Forward declarations ---------------------------*/ -static inline void bond_set_mode_ops(struct bonding *bond, int mode); static void bond_send_gratuitous_arp(struct bonding *bond); /*---------------------------- General routines -----------------------------*/ -static const char *bond_mode_name(int mode) +const char *bond_mode_name(int mode) { switch (mode) { case BOND_MODE_ROUNDROBIN : @@ -1453,7 +1452,7 @@ static struct slave *bond_find_best_slave(struct bonding *bond) * * Warning: Caller must hold curr_slave_lock for writing. */ -static void bond_change_active_slave(struct bonding *bond, struct slave *new_active) +void bond_change_active_slave(struct bonding *bond, struct slave *new_active) { struct slave *old_active = bond->curr_active_slave; @@ -1527,7 +1526,7 @@ static void bond_change_active_slave(struct bonding *bond, struct slave *new_act * * Warning: Caller must hold curr_slave_lock for writing. */ -static void bond_select_active_slave(struct bonding *bond) +void bond_select_active_slave(struct bonding *bond) { struct slave *best_slave; @@ -1595,7 +1594,7 @@ static void bond_detach_slave(struct bonding *bond, struct slave *slave) /*---------------------------------- IOCTL ----------------------------------*/ -static int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev) +int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev) { dprintk("bond_dev=%p\n", bond_dev); dprintk("slave_dev=%p\n", slave_dev); @@ -1635,7 +1634,7 @@ static int bond_compute_features(struct bonding *bond) } /* enslave device to bond device */ -static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) +int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) { struct bonding *bond = bond_dev->priv; struct slave *new_slave = NULL; @@ -2002,7 +2001,7 @@ err_undo_flags: * for Bonded connections: * The first up interface should be left on and all others downed. */ -static int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) +int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) { struct bonding *bond = bond_dev->priv; struct slave *slave, *oldcurrent; @@ -2403,7 +2402,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in /*-------------------------------- Monitoring -------------------------------*/ /* this function is called regularly to monitor each slave's link. */ -static void bond_mii_monitor(struct net_device *bond_dev) +void bond_mii_monitor(struct net_device *bond_dev) { struct bonding *bond = bond_dev->priv; struct slave *slave, *oldcurrent; @@ -2834,7 +2833,7 @@ static void bond_send_gratuitous_arp(struct bonding *bond) * arp is transmitted to generate traffic. see activebackup_arp_monitor for * arp monitoring in active backup mode. */ -static void bond_loadbalance_arp_mon(struct net_device *bond_dev) +void bond_loadbalance_arp_mon(struct net_device *bond_dev) { struct bonding *bond = bond_dev->priv; struct slave *slave, *oldcurrent; @@ -2972,7 +2971,7 @@ out: * may have received. * see loadbalance_arp_monitor for arp monitoring in load balancing mode */ -static void bond_activebackup_arp_mon(struct net_device *bond_dev) +void bond_activebackup_arp_mon(struct net_device *bond_dev) { struct bonding *bond = bond_dev->priv; struct slave *slave; @@ -4448,7 +4447,7 @@ out: /* * set bond mode specific net device operations */ -static inline void bond_set_mode_ops(struct bonding *bond, int mode) +void bond_set_mode_ops(struct bonding *bond, int mode) { struct net_device *bond_dev = bond->dev; @@ -4583,7 +4582,7 @@ static int __init bond_init(struct net_device *bond_dev, struct bond_params *par /* De-initialize device specific data. * Caller must hold rtnl_lock. */ -static inline void bond_deinit(struct net_device *bond_dev) +void bond_deinit(struct net_device *bond_dev) { struct bonding *bond = bond_dev->priv; @@ -4619,7 +4618,7 @@ static void bond_free_all(void) * Convert string input module parms. Accept either the * number of the mode or its string name. */ -static inline int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) +int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) { int i; diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index c8a873f..96a733f 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -260,6 +260,18 @@ extern inline void bond_set_slave_active_flags(struct slave *slave) struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); +void bond_deinit(struct net_device *bond_dev); +int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); +int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); +int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev); +void bond_mii_monitor(struct net_device *bond_dev); +void bond_loadbalance_arp_mon(struct net_device *bond_dev); +void bond_activebackup_arp_mon(struct net_device *bond_dev); +void bond_set_mode_ops(struct bonding *bond, int mode); +int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl); +const char *bond_mode_name(int mode); +void bond_select_active_slave(struct bonding *bond); +void bond_change_active_slave(struct bonding *bond, struct slave *new_active); #endif /* _LINUX_BONDING_H */ -- cgit v1.1 From dfe60397a62b1a5ebc7f05fd65463d3e29397677 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:36:04 -0800 Subject: [PATCH] bonding: move bond creation into separate function The sysfs interface can create bonds at runtime, so we need a separate function to do this, instead of just doing it in the module init code. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 113 ++++++++++++++++++++++------------------ drivers/net/bonding/bonding.h | 1 + 2 files changed, 62 insertions(+), 52 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b8d6176..2475b76e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4898,81 +4898,90 @@ static int bond_check_params(struct bond_params *params) return 0; } +/* Create a new bond based on the specified name and bonding parameters. + * Caller must NOT hold rtnl_lock; we need to release it here before we + * set up our sysfs entries. + */ +int bond_create(char *name, struct bond_params *params, struct bonding **newbond) +{ + struct net_device *bond_dev; + int res; + + rtnl_lock(); + bond_dev = alloc_netdev(sizeof(struct bonding), name, ether_setup); + if (!bond_dev) { + printk(KERN_ERR DRV_NAME + ": %s: eek! can't alloc netdev!\n", + name); + res = -ENOMEM; + goto out_rtnl; + } + + /* bond_init() must be called after dev_alloc_name() (for the + * /proc files), but before register_netdevice(), because we + * need to set function pointers. + */ + + res = bond_init(bond_dev, params); + if (res < 0) { + goto out_netdev; + } + + SET_MODULE_OWNER(bond_dev); + + res = register_netdevice(bond_dev); + if (res < 0) { + goto out_bond; + } + if (newbond) + *newbond = bond_dev->priv; + + rtnl_unlock(); /* allows sysfs registration of net device */ + goto done; +out_bond: + bond_deinit(bond_dev); +out_netdev: + free_netdev(bond_dev); +out_rtnl: + rtnl_unlock(); +done: + return res; +} + static int __init bonding_init(void) { - struct bond_params params; int i; int res; + char new_bond_name[8]; /* Enough room for 999 bonds at init. */ printk(KERN_INFO "%s", version); - res = bond_check_params(¶ms); + res = bond_check_params(&bonding_defaults); if (res) { - return res; + goto out; } - rtnl_lock(); - #ifdef CONFIG_PROC_FS bond_create_proc_dir(); #endif - for (i = 0; i < max_bonds; i++) { - struct net_device *bond_dev; - - bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); - if (!bond_dev) { - res = -ENOMEM; - goto out_err; - } - - res = dev_alloc_name(bond_dev, "bond%d"); - if (res < 0) { - free_netdev(bond_dev); - goto out_err; - } - - /* bond_init() must be called after dev_alloc_name() (for the - * /proc files), but before register_netdevice(), because we - * need to set function pointers. - */ - res = bond_init(bond_dev, ¶ms); - if (res < 0) { - free_netdev(bond_dev); - goto out_err; - } - - SET_MODULE_OWNER(bond_dev); - - res = register_netdevice(bond_dev); - if (res < 0) { - bond_deinit(bond_dev); - free_netdev(bond_dev); - goto out_err; - } + sprintf(new_bond_name, "bond%d",i); + res = bond_create(new_bond_name,&bonding_defaults, NULL); + if (res) + goto err; } - rtnl_unlock(); register_netdevice_notifier(&bond_netdev_notifier); register_inetaddr_notifier(&bond_inetaddr_notifier); - return 0; - -out_err: - /* - * rtnl_unlock() will run netdev_run_todo(), putting the - * thus-far-registered bonding devices into a state which - * unregigister_netdevice() will accept - */ - rtnl_unlock(); + goto out; +err: rtnl_lock(); - - /* free and unregister all bonds that were successfully added */ bond_free_all(); - rtnl_unlock(); - +out: return res; + } static void __exit bonding_exit(void) diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 96a733f..863605a 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -260,6 +260,7 @@ extern inline void bond_set_slave_active_flags(struct slave *slave) struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); +int bond_create(char *name, struct bond_params *params, struct bonding **newbond); void bond_deinit(struct net_device *bond_dev); int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); -- cgit v1.1 From 3c535952d86df83f817595068c9fd2b3cfbd3a4d Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:36:11 -0800 Subject: [PATCH] bonding: make bond_init not __init The sysfs interface can create bonds at runtime, and __init code goes away after module init. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 2475b76e..73c9dd6 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4508,7 +4508,7 @@ static struct ethtool_ops bond_ethtool_ops = { * Does not allocate but creates a /proc entry. * Allowed to fail. */ -static int __init bond_init(struct net_device *bond_dev, struct bond_params *params) +static int bond_init(struct net_device *bond_dev, struct bond_params *params) { struct bonding *bond = bond_dev->priv; -- cgit v1.1 From 6b780567223524cac86c745aeac425521cf37490 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:36:19 -0800 Subject: [PATCH] bonding: Allow ARP target table to have empty entries With the sysfs interface, the user can remove entries from the ARP table at runtime. The ARP monitor code now allows for empty entries in the table. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 73c9dd6..b656e53 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -2729,7 +2729,9 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave) struct flowi fl; struct rtable *rt; - for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) { + for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { + if (!targets[i]) + continue; dprintk("basa: target %x\n", targets[i]); if (list_empty(&bond->vlan_list)) { dprintk("basa: empty vlan: arp_send\n"); -- cgit v1.1 From 4756b02f558cbbbef5ae278fd3bbed778458c124 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:36:25 -0800 Subject: [PATCH] bonding: add ARP entries to /proc Make the /proc files show which ARP targets are in use by each bond. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b656e53..d5415ba 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -3259,6 +3259,8 @@ static void bond_info_show_master(struct seq_file *seq) { struct bonding *bond = seq->private; struct slave *curr; + int i; + u32 target; read_lock(&bond->curr_slave_lock); curr = bond->curr_active_slave; @@ -3290,6 +3292,27 @@ static void bond_info_show_master(struct seq_file *seq) seq_printf(seq, "Down Delay (ms): %d\n", bond->params.downdelay * bond->params.miimon); + + /* ARP information */ + if(bond->params.arp_interval > 0) { + int printed=0; + seq_printf(seq, "ARP Polling Interval (ms): %d\n", + bond->params.arp_interval); + + seq_printf(seq, "ARP IP target/s (n.n.n.n form):"); + + for(i = 0; (i < BOND_MAX_ARP_TARGETS) ;i++) { + if (!bond->params.arp_targets[i]) + continue; + if (printed) + seq_printf(seq, ","); + target = ntohl(bond->params.arp_targets[i]); + seq_printf(seq, " %d.%d.%d.%d", HIPQUAD(target)); + printed = 1; + } + seq_printf(seq, "\n"); + } + if (bond->params.mode == BOND_MODE_8023AD) { struct ad_info ad_info; -- cgit v1.1 From b76cdba9cdb29b091cacb4c11534ffb2eac02f64 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:36:41 -0800 Subject: [PATCH] bonding: add sysfs functionality to bonding (large) This large patch adds sysfs functionality to the channel bonding module. Bonds can be added, removed, and reconfigured at runtime without having to reload the module. Multiple bonds with different configurations are easily configured, and ifenslave is no longer required to configure bonds. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/Makefile | 2 +- drivers/net/bonding/bond_main.c | 23 +- drivers/net/bonding/bond_sysfs.c | 1399 ++++++++++++++++++++++++++++++++++++++ drivers/net/bonding/bonding.h | 7 + 4 files changed, 1429 insertions(+), 2 deletions(-) create mode 100644 drivers/net/bonding/bond_sysfs.c diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile index cf50384..5cdae2b 100644 --- a/drivers/net/bonding/Makefile +++ b/drivers/net/bonding/Makefile @@ -4,5 +4,5 @@ obj-$(CONFIG_BONDING) += bonding.o -bonding-objs := bond_main.o bond_3ad.o bond_alb.o +bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index d5415ba..5ac9718 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -600,6 +600,7 @@ LIST_HEAD(bond_dev_list); static struct proc_dir_entry *bond_proc_dir = NULL; #endif +extern struct rw_semaphore bonding_rwsem; static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ; static int arp_ip_count = 0; static int bond_mode = BOND_MODE_ROUNDROBIN; @@ -1960,6 +1961,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) write_unlock_bh(&bond->lock); + res = bond_create_slave_symlinks(bond_dev, slave_dev); + if (res) + goto err_unset_master; + printk(KERN_INFO DRV_NAME ": %s: enslaving %s as a%s interface with a%s link.\n", bond_dev->name, slave_dev->name, @@ -2133,6 +2138,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) write_unlock_bh(&bond->lock); + /* must do this from outside any spinlocks */ + bond_destroy_slave_symlinks(bond_dev, slave_dev); + bond_del_vlans_from_slave(bond, slave_dev); /* If the mode USES_PRIMARY, then we should only remove its @@ -2224,6 +2232,7 @@ static int bond_release_all(struct net_device *bond_dev) */ write_unlock_bh(&bond->lock); + bond_destroy_slave_symlinks(bond_dev, slave_dev); bond_del_vlans_from_slave(bond, slave_dev); /* If the mode USES_PRIMARY, then we should only remove its @@ -3518,7 +3527,10 @@ static int bond_event_changename(struct bonding *bond) bond_remove_proc_entry(bond); bond_create_proc_entry(bond); #endif - + down_write(&(bonding_rwsem)); + bond_destroy_sysfs_entry(bond); + bond_create_sysfs_entry(bond); + up_write(&(bonding_rwsem)); return NOTIFY_DONE; } @@ -3995,6 +4007,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd return -EPERM; } + down_write(&(bonding_rwsem)); slave_dev = dev_get_by_name(ifr->ifr_slave); dprintk("slave_dev=%p: \n", slave_dev); @@ -4027,6 +4040,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd dev_put(slave_dev); } + up_write(&(bonding_rwsem)); return res; } @@ -4962,6 +4976,7 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond *newbond = bond_dev->priv; rtnl_unlock(); /* allows sysfs registration of net device */ + res = bond_create_sysfs_entry(bond_dev->priv); goto done; out_bond: bond_deinit(bond_dev); @@ -4996,6 +5011,10 @@ static int __init bonding_init(void) goto err; } + res = bond_create_sysfs(); + if (res) + goto err; + register_netdevice_notifier(&bond_netdev_notifier); register_inetaddr_notifier(&bond_inetaddr_notifier); @@ -5003,6 +5022,7 @@ static int __init bonding_init(void) err: rtnl_lock(); bond_free_all(); + bond_destroy_sysfs(); rtnl_unlock(); out: return res; @@ -5016,6 +5036,7 @@ static void __exit bonding_exit(void) rtnl_lock(); bond_free_all(); + bond_destroy_sysfs(); rtnl_unlock(); } diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c new file mode 100644 index 0000000..c5f1c52 --- /dev/null +++ b/drivers/net/bonding/bond_sysfs.c @@ -0,0 +1,1399 @@ + +/* + * Copyright(c) 2004-2005 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * + * Changes: + * + * 2004/12/12 - Mitch Williams + * - Initial creation of sysfs interface. + * + * 2005/06/22 - Radheka Godse + * - Added ifenslave -c type functionality to sysfs + * - Added sysfs files for attributes such as MII Status and + * 802.3ad aggregator that are displayed in /proc + * - Added "name value" format to sysfs "mode" and + * "lacp_rate", for e.g., "active-backup 1" or "slow 0" for + * consistency and ease of script parsing + * - Fixed reversal of octets in arp_ip_targets via sysfs + * - sysfs support to handle bond interface re-naming + * - Moved all sysfs entries into /sys/class/net instead of + * of using a standalone subsystem. + * - Added sysfs symlinks between masters and slaves + * - Corrected bugs in sysfs unload path when creating bonds + * with existing interface names. + * - Removed redundant sysfs stat file since it duplicates slave info + * from the proc file + * - Fixed errors in sysfs show/store arp targets. + * - For consistency with ifenslave, instead of exiting + * with an error, updated bonding sysfs to + * close and attempt to enslave an up adapter. + * - Fixed NULL dereference when adding a slave interface + * that does not exist. + * - Added checks in sysfs bonding to reject invalid ip addresses + * - Synch up with post linux-2.6.12 bonding changes + * - Created sysfs bond attrib for xmit_hash_policy + * + * 2005/09/19 - Mitch Williams + * - Changed semantics of multi-item files to be command-based + * instead of list-based. + * - Changed ARP target handler to use in_aton instead of sscanf + * - Style changes. + * 2005/09/27 - Mitch Williams + * - Made line endings consistent. + * - Removed "none" from primary output - just put blank instead + * - Fixed bug with long interface names + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* #define BONDING_DEBUG 1 */ +#include "bonding.h" +#define to_class_dev(obj) container_of(obj,struct class_device,kobj) +#define to_net_dev(class) container_of(class, struct net_device, class_dev) +#define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv)) + +/*---------------------------- Declarations -------------------------------*/ + + +extern struct list_head bond_dev_list; +extern struct bond_params bonding_defaults; +extern struct bond_parm_tbl bond_mode_tbl[]; +extern struct bond_parm_tbl bond_lacp_tbl[]; +extern struct bond_parm_tbl xmit_hashtype_tbl[]; + +static int expected_refcount = -1; +static struct class *netdev_class; +/*--------------------------- Data Structures -----------------------------*/ + +/* Bonding sysfs lock. Why can't we just use the subsytem lock? + * Because kobject_register tries to acquire the subsystem lock. If + * we already hold the lock (which we would if the user was creating + * a new bond through the sysfs interface), we deadlock. + * This lock is only needed when deleting a bond - we need to make sure + * that we don't collide with an ongoing ioctl. + */ + +struct rw_semaphore bonding_rwsem; + + + + +/*------------------------------ Functions --------------------------------*/ + +/* + * "show" function for the bond_masters attribute. + * The class parameter is ignored. + */ +static ssize_t bonding_show_bonds(struct class *cls, char *buffer) +{ + int res = 0; + struct bonding *bond; + + down_read(&(bonding_rwsem)); + + list_for_each_entry(bond, &bond_dev_list, bond_list) { + if (res > (PAGE_SIZE - IFNAMSIZ)) { + /* not enough space for another interface name */ + if ((PAGE_SIZE - res) > 10) + res = PAGE_SIZE - 10; + res += sprintf(buffer + res, "++more++"); + break; + } + res += sprintf(buffer + res, "%s ", + bond->dev->name); + } + res += sprintf(buffer + res, "\n"); + res++; + up_read(&(bonding_rwsem)); + return res; +} + +/* + * "store" function for the bond_masters attribute. This is what + * creates and deletes entire bonds. + * + * The class parameter is ignored. + * + */ + +static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t count) +{ + char command[IFNAMSIZ + 1] = {0, }; + char *ifname; + int res = count; + struct bonding *bond; + struct bonding *nxt; + + down_write(&(bonding_rwsem)); + sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ + ifname = command + 1; + if ((strlen(command) <= 1) || + !dev_valid_name(ifname)) + goto err_no_cmd; + + if (command[0] == '+') { + + /* Check to see if the bond already exists. */ + list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) + if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { + printk(KERN_ERR DRV_NAME + ": cannot add bond %s; it already exists\n", + ifname); + res = -EPERM; + goto out; + } + + printk(KERN_INFO DRV_NAME + ": %s is being created...\n", ifname); + if (bond_create(ifname, &bonding_defaults, &bond)) { + printk(KERN_INFO DRV_NAME + ": %s interface already exists. Bond creation failed.\n", + ifname); + res = -EPERM; + } + goto out; + } + + if (command[0] == '-') { + list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) + if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) { + rtnl_lock(); + /* check the ref count on the bond's kobject. + * If it's > expected, then there's a file open, + * and we have to fail. + */ + if (atomic_read(&bond->dev->class_dev.kobj.kref.refcount) + > expected_refcount){ + rtnl_unlock(); + printk(KERN_INFO DRV_NAME + ": Unable remove bond %s due to open references.\n", + ifname); + res = -EPERM; + goto out; + } + printk(KERN_INFO DRV_NAME + ": %s is being deleted...\n", + bond->dev->name); + unregister_netdevice(bond->dev); + bond_deinit(bond->dev); + bond_destroy_sysfs_entry(bond); + rtnl_unlock(); + goto out; + } + + printk(KERN_ERR DRV_NAME + ": unable to delete non-existent bond %s\n", ifname); + res = -ENODEV; + goto out; + } + +err_no_cmd: + printk(KERN_ERR DRV_NAME + ": no command found in bonding_masters. Use +ifname or -ifname.\n"); + res = -EPERM; + + /* Always return either count or an error. If you return 0, you'll + * get called forever, which is bad. + */ +out: + up_write(&(bonding_rwsem)); + return res; +} +/* class attribute for bond_masters file. This ends up in /sys/class/net */ +static CLASS_ATTR(bonding_masters, S_IWUSR | S_IRUGO, + bonding_show_bonds, bonding_store_bonds); + +int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave) +{ + char linkname[IFNAMSIZ+7]; + int ret = 0; + + /* first, create a link from the slave back to the master */ + ret = sysfs_create_link(&(slave->class_dev.kobj), &(master->class_dev.kobj), + "master"); + if (ret) + return ret; + /* next, create a link from the master to the slave */ + sprintf(linkname,"slave_%s",slave->name); + ret = sysfs_create_link(&(master->class_dev.kobj), &(slave->class_dev.kobj), + linkname); + return ret; + +} + +void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave) +{ + char linkname[IFNAMSIZ+7]; + + sysfs_remove_link(&(slave->class_dev.kobj), "master"); + sprintf(linkname,"slave_%s",slave->name); + sysfs_remove_link(&(master->class_dev.kobj), linkname); +} + + +/* + * Show the slaves in the current bond. + */ +static ssize_t bonding_show_slaves(struct class_device *cd, char *buf) +{ + struct slave *slave; + int i, res = 0; + struct bonding *bond = to_bond(cd); + + read_lock_bh(&bond->lock); + bond_for_each_slave(bond, slave, i) { + if (res > (PAGE_SIZE - IFNAMSIZ)) { + /* not enough space for another interface name */ + if ((PAGE_SIZE - res) > 10) + res = PAGE_SIZE - 10; + res += sprintf(buf + res, "++more++"); + break; + } + res += sprintf(buf + res, "%s ", slave->dev->name); + } + read_unlock_bh(&bond->lock); + res += sprintf(buf + res, "\n"); + res++; + return res; +} + +/* + * Set the slaves in the current bond. The bond interface must be + * up for this to succeed. + * This function is largely the same flow as bonding_update_bonds(). + */ +static ssize_t bonding_store_slaves(struct class_device *cd, const char *buffer, size_t count) +{ + char command[IFNAMSIZ + 1] = { 0, }; + char *ifname; + int i, res, found, ret = count; + struct slave *slave; + struct net_device *dev = 0; + struct bonding *bond = to_bond(cd); + + /* Quick sanity check -- is the bond interface up? */ + if (!(bond->dev->flags & IFF_UP)) { + printk(KERN_ERR DRV_NAME + ": %s: Unable to update slaves because interface is down.\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + + /* Note: We can't hold bond->lock here, as bond_create grabs it. */ + + sscanf(buffer, "%16s", command); /* IFNAMSIZ*/ + ifname = command + 1; + if ((strlen(command) <= 1) || + !dev_valid_name(ifname)) + goto err_no_cmd; + + if (command[0] == '+') { + + /* Got a slave name in ifname. Is it already in the list? */ + found = 0; + read_lock_bh(&bond->lock); + bond_for_each_slave(bond, slave, i) + if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { + printk(KERN_ERR DRV_NAME + ": %s: Interface %s is already enslaved!\n", + bond->dev->name, ifname); + ret = -EPERM; + read_unlock_bh(&bond->lock); + goto out; + } + + read_unlock_bh(&bond->lock); + printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n", + bond->dev->name, ifname); + dev = dev_get_by_name(ifname); + if (!dev) { + printk(KERN_INFO DRV_NAME + ": %s: Interface %s does not exist!\n", + bond->dev->name, ifname); + ret = -EPERM; + goto out; + } + else + dev_put(dev); + + if (dev->flags & IFF_UP) { + printk(KERN_ERR DRV_NAME + ": %s: Error: Unable to enslave %s " + "because it is already up.\n", + bond->dev->name, dev->name); + ret = -EPERM; + goto out; + } + /* If this is the first slave, then we need to set + the master's hardware address to be the same as the + slave's. */ + if (!(*((u32 *) & (bond->dev->dev_addr[0])))) { + memcpy(bond->dev->dev_addr, dev->dev_addr, + dev->addr_len); + } + + /* Set the slave's MTU to match the bond */ + if (dev->mtu != bond->dev->mtu) { + if (dev->change_mtu) { + res = dev->change_mtu(dev, + bond->dev->mtu); + if (res) { + ret = res; + goto out; + } + } else { + dev->mtu = bond->dev->mtu; + } + } + rtnl_lock(); + res = bond_enslave(bond->dev, dev); + rtnl_unlock(); + if (res) { + ret = res; + } + goto out; + } + + if (command[0] == '-') { + dev = NULL; + bond_for_each_slave(bond, slave, i) + if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) { + dev = slave->dev; + break; + } + if (dev) { + printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n", + bond->dev->name, dev->name); + rtnl_lock(); + res = bond_release(bond->dev, dev); + rtnl_unlock(); + if (res) { + ret = res; + goto out; + } + /* set the slave MTU to the default */ + if (dev->change_mtu) { + dev->change_mtu(dev, 1500); + } else { + dev->mtu = 1500; + } + } + else { + printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n", + ifname, bond->dev->name); + ret = -ENODEV; + } + goto out; + } + +err_no_cmd: + printk(KERN_ERR DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name); + ret = -EPERM; + +out: + return ret; +} + +static CLASS_DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves); + +/* + * Show and set the bonding mode. The bond interface must be down to + * change the mode. + */ +static ssize_t bonding_show_mode(struct class_device *cd, char *buf) +{ + struct bonding *bond = to_bond(cd); + + return sprintf(buf, "%s %d\n", + bond_mode_tbl[bond->params.mode].modename, + bond->params.mode) + 1; +} + +static ssize_t bonding_store_mode(struct class_device *cd, const char *buf, size_t count) +{ + int new_value, ret = count; + struct bonding *bond = to_bond(cd); + + if (bond->dev->flags & IFF_UP) { + printk(KERN_ERR DRV_NAME + ": unable to update mode of %s because interface is up.\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + + new_value = bond_parse_parm((char *)buf, bond_mode_tbl); + if (new_value < 0) { + printk(KERN_ERR DRV_NAME + ": %s: Ignoring invalid mode value %.*s.\n", + bond->dev->name, + (int)strlen(buf) - 1, buf); + ret = -EINVAL; + goto out; + } else { + bond->params.mode = new_value; + bond_set_mode_ops(bond, bond->params.mode); + printk(KERN_INFO DRV_NAME ": %s: setting mode to %s (%d).\n", + bond->dev->name, bond_mode_tbl[new_value].modename, new_value); + } +out: + return ret; +} +static CLASS_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode); + +/* + * Show and set the bonding transmit hash method. The bond interface must be down to + * change the xmit hash policy. + */ +static ssize_t bonding_show_xmit_hash(struct class_device *cd, char *buf) +{ + int count; + struct bonding *bond = to_bond(cd); + + if ((bond->params.mode != BOND_MODE_XOR) && + (bond->params.mode != BOND_MODE_8023AD)) { + // Not Applicable + count = sprintf(buf, "NA\n") + 1; + } else { + count = sprintf(buf, "%s %d\n", + xmit_hashtype_tbl[bond->params.xmit_policy].modename, + bond->params.xmit_policy) + 1; + } + + return count; +} + +static ssize_t bonding_store_xmit_hash(struct class_device *cd, const char *buf, size_t count) +{ + int new_value, ret = count; + struct bonding *bond = to_bond(cd); + + if (bond->dev->flags & IFF_UP) { + printk(KERN_ERR DRV_NAME + "%s: Interface is up. Unable to update xmit policy.\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + + if ((bond->params.mode != BOND_MODE_XOR) && + (bond->params.mode != BOND_MODE_8023AD)) { + printk(KERN_ERR DRV_NAME + "%s: Transmit hash policy is irrelevant in this mode.\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + + new_value = bond_parse_parm((char *)buf, xmit_hashtype_tbl); + if (new_value < 0) { + printk(KERN_ERR DRV_NAME + ": %s: Ignoring invalid xmit hash policy value %.*s.\n", + bond->dev->name, + (int)strlen(buf) - 1, buf); + ret = -EINVAL; + goto out; + } else { + bond->params.xmit_policy = new_value; + bond_set_mode_ops(bond, bond->params.mode); + printk(KERN_INFO DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n", + bond->dev->name, xmit_hashtype_tbl[new_value].modename, new_value); + } +out: + return ret; +} +static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); + +/* + * Show and set the arp timer interval. There are two tricky bits + * here. First, if ARP monitoring is activated, then we must disable + * MII monitoring. Second, if the ARP timer isn't running, we must + * start it. + */ +static ssize_t bonding_show_arp_interval(struct class_device *cd, char *buf) +{ + struct bonding *bond = to_bond(cd); + + return sprintf(buf, "%d\n", bond->params.arp_interval) + 1; +} + +static ssize_t bonding_store_arp_interval(struct class_device *cd, const char *buf, size_t count) +{ + int new_value, ret = count; + struct bonding *bond = to_bond(cd); + + if (sscanf(buf, "%d", &new_value) != 1) { + printk(KERN_ERR DRV_NAME + ": %s: no arp_interval value specified.\n", + bond->dev->name); + ret = -EINVAL; + goto out; + } + if (new_value < 0) { + printk(KERN_ERR DRV_NAME + ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", + bond->dev->name, new_value, INT_MAX); + ret = -EINVAL; + goto out; + } + + printk(KERN_INFO DRV_NAME + ": %s: Setting ARP monitoring interval to %d.\n", + bond->dev->name, new_value); + bond->params.arp_interval = new_value; + if (bond->params.miimon) { + printk(KERN_INFO DRV_NAME + ": %s: ARP monitoring cannot be used with MII monitoring. " + "%s Disabling MII monitoring.\n", + bond->dev->name, bond->dev->name); + bond->params.miimon = 0; + /* Kill MII timer, else it brings bond's link down */ + if (bond->arp_timer.function) { + printk(KERN_INFO DRV_NAME + ": %s: Kill MII timer, else it brings bond's link down...\n", + bond->dev->name); + del_timer_sync(&bond->mii_timer); + } + } + if (!bond->params.arp_targets[0]) { + printk(KERN_INFO DRV_NAME + ": %s: ARP monitoring has been set up, " + "but no ARP targets have been specified.\n", + bond->dev->name); + } + if (bond->dev->flags & IFF_UP) { + /* If the interface is up, we may need to fire off + * the ARP timer. If the interface is down, the + * timer will get fired off when the open function + * is called. + */ + if (bond->arp_timer.function) { + /* The timer's already set up, so fire it off */ + mod_timer(&bond->arp_timer, jiffies + 1); + } else { + /* Set up the timer. */ + init_timer(&bond->arp_timer); + bond->arp_timer.expires = jiffies + 1; + bond->arp_timer.data = + (unsigned long) bond->dev; + if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { + bond->arp_timer.function = + (void *) + &bond_activebackup_arp_mon; + } else { + bond->arp_timer.function = + (void *) + &bond_loadbalance_arp_mon; + } + add_timer(&bond->arp_timer); + } + } + +out: + return ret; +} +static CLASS_DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval); + +/* + * Show and set the arp targets. + */ +static ssize_t bonding_show_arp_targets(struct class_device *cd, char *buf) +{ + int i, res = 0; + struct bonding *bond = to_bond(cd); + + for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) { + if (bond->params.arp_targets[i]) + res += sprintf(buf + res, "%u.%u.%u.%u ", + NIPQUAD(bond->params.arp_targets[i])); + } + if (res) + res--; /* eat the leftover space */ + res += sprintf(buf + res, "\n"); + res++; + return res; +} + +static ssize_t bonding_store_arp_targets(struct class_device *cd, const char *buf, size_t count) +{ + u32 newtarget; + int i = 0, done = 0, ret = count; + struct bonding *bond = to_bond(cd); + u32 *targets; + + targets = bond->params.arp_targets; + newtarget = in_aton(buf + 1); + /* look for adds */ + if (buf[0] == '+') { + if ((newtarget == 0) || (newtarget == INADDR_BROADCAST)) { + printk(KERN_ERR DRV_NAME + ": %s: invalid ARP target %u.%u.%u.%u specified for addition\n", + bond->dev->name, NIPQUAD(newtarget)); + ret = -EINVAL; + goto out; + } + /* look for an empty slot to put the target in, and check for dupes */ + for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { + if (targets[i] == newtarget) { /* duplicate */ + printk(KERN_ERR DRV_NAME + ": %s: ARP target %u.%u.%u.%u is already present\n", + bond->dev->name, NIPQUAD(newtarget)); + if (done) + targets[i] = 0; + ret = -EINVAL; + goto out; + } + if (targets[i] == 0 && !done) { + printk(KERN_INFO DRV_NAME + ": %s: adding ARP target %d.%d.%d.%d.\n", + bond->dev->name, NIPQUAD(newtarget)); + done = 1; + targets[i] = newtarget; + } + } + if (!done) { + printk(KERN_ERR DRV_NAME + ": %s: ARP target table is full!\n", + bond->dev->name); + ret = -EINVAL; + goto out; + } + + } + else if (buf[0] == '-') { + if ((newtarget == 0) || (newtarget == INADDR_BROADCAST)) { + printk(KERN_ERR DRV_NAME + ": %s: invalid ARP target %d.%d.%d.%d specified for removal\n", + bond->dev->name, NIPQUAD(newtarget)); + ret = -EINVAL; + goto out; + } + + for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) { + if (targets[i] == newtarget) { + printk(KERN_INFO DRV_NAME + ": %s: removing ARP target %d.%d.%d.%d.\n", + bond->dev->name, NIPQUAD(newtarget)); + targets[i] = 0; + done = 1; + } + } + if (!done) { + printk(KERN_INFO DRV_NAME + ": %s: unable to remove nonexistent ARP target %d.%d.%d.%d.\n", + bond->dev->name, NIPQUAD(newtarget)); + ret = -EINVAL; + goto out; + } + } + else { + printk(KERN_ERR DRV_NAME ": no command found in arp_ip_targets file for bond %s. Use + or -.\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + +out: + return ret; +} +static CLASS_DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); + +/* + * Show and set the up and down delays. These must be multiples of the + * MII monitoring value, and are stored internally as the multiplier. + * Thus, we must translate to MS for the real world. + */ +static ssize_t bonding_show_downdelay(struct class_device *cd, char *buf) +{ + struct bonding *bond = to_bond(cd); + + return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon) + 1; +} + +static ssize_t bonding_store_downdelay(struct class_device *cd, const char *buf, size_t count) +{ + int new_value, ret = count; + struct bonding *bond = to_bond(cd); + + if (!(bond->params.miimon)) { + printk(KERN_ERR DRV_NAME + ": %s: Unable to set down delay as MII monitoring is disabled\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + + if (sscanf(buf, "%d", &new_value) != 1) { + printk(KERN_ERR DRV_NAME + ": %s: no down delay value specified.\n", + bond->dev->name); + ret = -EINVAL; + goto out; + } + if (new_value < 0) { + printk(KERN_ERR DRV_NAME + ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", + bond->dev->name, new_value, 1, INT_MAX); + ret = -EINVAL; + goto out; + } else { + if ((new_value % bond->params.miimon) != 0) { + printk(KERN_WARNING DRV_NAME + ": %s: Warning: down delay (%d) is not a multiple " + "of miimon (%d), delay rounded to %d ms\n", + bond->dev->name, new_value, bond->params.miimon, + (new_value / bond->params.miimon) * + bond->params.miimon); + } + bond->params.downdelay = new_value / bond->params.miimon; + printk(KERN_INFO DRV_NAME ": %s: Setting down delay to %d.\n", + bond->dev->name, bond->params.downdelay * bond->params.miimon); + + } + +out: + return ret; +} +static CLASS_DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay); + +static ssize_t bonding_show_updelay(struct class_device *cd, char *buf) +{ + struct bonding *bond = to_bond(cd); + + return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon) + 1; + +} + +static ssize_t bonding_store_updelay(struct class_device *cd, const char *buf, size_t count) +{ + int new_value, ret = count; + struct bonding *bond = to_bond(cd); + + if (!(bond->params.miimon)) { + printk(KERN_ERR DRV_NAME + ": %s: Unable to set up delay as MII monitoring is disabled\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + + if (sscanf(buf, "%d", &new_value) != 1) { + printk(KERN_ERR DRV_NAME + ": %s: no up delay value specified.\n", + bond->dev->name); + ret = -EINVAL; + goto out; + } + if (new_value < 0) { + printk(KERN_ERR DRV_NAME + ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n", + bond->dev->name, new_value, 1, INT_MAX); + ret = -EINVAL; + goto out; + } else { + if ((new_value % bond->params.miimon) != 0) { + printk(KERN_WARNING DRV_NAME + ": %s: Warning: up delay (%d) is not a multiple " + "of miimon (%d), updelay rounded to %d ms\n", + bond->dev->name, new_value, bond->params.miimon, + (new_value / bond->params.miimon) * + bond->params.miimon); + } + bond->params.updelay = new_value / bond->params.miimon; + printk(KERN_INFO DRV_NAME ": %s: Setting up delay to %d.\n", + bond->dev->name, bond->params.updelay * bond->params.miimon); + + } + +out: + return ret; +} +static CLASS_DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay); + +/* + * Show and set the LACP interval. Interface must be down, and the mode + * must be set to 802.3ad mode. + */ +static ssize_t bonding_show_lacp(struct class_device *cd, char *buf) +{ + struct bonding *bond = to_bond(cd); + + return sprintf(buf, "%s %d\n", + bond_lacp_tbl[bond->params.lacp_fast].modename, + bond->params.lacp_fast) + 1; +} + +static ssize_t bonding_store_lacp(struct class_device *cd, const char *buf, size_t count) +{ + int new_value, ret = count; + struct bonding *bond = to_bond(cd); + + if (bond->dev->flags & IFF_UP) { + printk(KERN_ERR DRV_NAME + ": %s: Unable to update LACP rate because interface is up.\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + + if (bond->params.mode != BOND_MODE_8023AD) { + printk(KERN_ERR DRV_NAME + ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n", + bond->dev->name); + ret = -EPERM; + goto out; + } + + new_value = bond_parse_parm((char *)buf, bond_lacp_tbl); + + if ((new_value == 1) || (new_value == 0)) { + bond->params.lacp_fast = new_value; + printk(KERN_INFO DRV_NAME + ": %s: Setting LACP rate to %s (%d).\n", + bond->dev->name, bond_lacp_tbl[new_value].modename, new_value); + } else { + printk(KERN_ERR DRV_NAME + ": %s: Ignoring invalid LACP rate value %.*s.\n", + bond->dev->name, (int)strlen(buf) - 1, buf); + ret = -EINVAL; + } +out: + return ret; +} +static CLASS_DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp); + +/* + * Show and set the MII monitor interval. There are two tricky bits + * here. First, if MII monitoring is activated, then we must disable + * ARP monitoring. Second, if the timer isn't running, we must + * start it. + */ +static ssize_t bonding_show_miimon(struct class_device *cd, char *buf) +{ + struct bonding *bond = to_bond(cd); + + return sprintf(buf, "%d\n", bond->params.miimon) + 1; +} + +static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, size_t count) +{ + int new_value, ret = count; + struct bonding *bond = to_bond(cd); + + if (sscanf(buf, "%d", &new_value) != 1) { + printk(KERN_ERR DRV_NAME + ": %s: no miimon value specified.\n", + bond->dev->name); + ret = -EINVAL; + goto out; + } + if (new_value < 0) { + printk(KERN_ERR DRV_NAME + ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n", + bond->dev->name, new_value, 1, INT_MAX); + ret = -EINVAL; + goto out; + } else { + printk(KERN_INFO DRV_NAME + ": %s: Setting MII monitoring interval to %d.\n", + bond->dev->name, new_value); + bond->params.miimon = new_value; + if(bond->params.updelay) + printk(KERN_INFO DRV_NAME + ": %s: Note: Updating updelay (to %d) " + "since it is a multiple of the miimon value.\n", + bond->dev->name, + bond->params.updelay * bond->params.miimon); + if(bond->params.downdelay) + printk(KERN_INFO DRV_NAME + ": %s: Note: Updating downdelay (to %d) " + "since it is a multiple of the miimon value.\n", + bond->dev->name, + bond->params.downdelay * bond->params.miimon); + if (bond->params.arp_interval) { + printk(KERN_INFO DRV_NAME + ": %s: MII monitoring cannot be used with " + "ARP monitoring. Disabling ARP monitoring...\n", + bond->dev->name); + bond->params.arp_interval = 0; + /* Kill ARP timer, else it brings bond's link down */ + if (bond->mii_timer.function) { + printk(KERN_INFO DRV_NAME + ": %s: Kill ARP timer, else it brings bond's link down...\n", + bond->dev->name); + del_timer_sync(&bond->arp_timer); + } + } + + if (bond->dev->flags & IFF_UP) { + /* If the interface is up, we may need to fire off + * the MII timer. If the interface is down, the + * timer will get fired off when the open function + * is called. + */ + if (bond->mii_timer.function) { + /* The timer's already set up, so fire it off */ + mod_timer(&bond->mii_timer, jiffies + 1); + } else { + /* Set up the timer. */ + init_timer(&bond->mii_timer); + bond->mii_timer.expires = jiffies + 1; + bond->mii_timer.data = + (unsigned long) bond->dev; + bond->mii_timer.function = + (void *) &bond_mii_monitor; + add_timer(&bond->mii_timer); + } + } + } +out: + return ret; +} +static CLASS_DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon); + +/* + * Show and set the primary slave. The store function is much + * simpler than bonding_store_slaves function because it only needs to + * handle one interface name. + * The bond must be a mode that supports a primary for this be + * set. + */ +static ssize_t bonding_show_primary(struct class_device *cd, char *buf) +{ + int count = 0; + struct bonding *bond = to_bond(cd); + + if (bond->primary_slave) + count = sprintf(buf, "%s\n", bond->primary_slave->dev->name) + 1; + else + count = sprintf(buf, "\n") + 1; + + return count; +} + +static ssize_t bonding_store_primary(struct class_device *cd, const char *buf, size_t count) +{ + int i; + struct slave *slave; + struct bonding *bond = to_bond(cd); + + write_lock_bh(&bond->lock); + if (!USES_PRIMARY(bond->params.mode)) { + printk(KERN_INFO DRV_NAME + ": %s: Unable to set primary slave; %s is in mode %d\n", + bond->dev->name, bond->dev->name, bond->params.mode); + } else { + bond_for_each_slave(bond, slave, i) { + if (strnicmp + (slave->dev->name, buf, + strlen(slave->dev->name)) == 0) { + printk(KERN_INFO DRV_NAME + ": %s: Setting %s as primary slave.\n", + bond->dev->name, slave->dev->name); + bond->primary_slave = slave; + bond_select_active_slave(bond); + goto out; + } + } + + /* if we got here, then we didn't match the name of any slave */ + + if (strlen(buf) == 0 || buf[0] == '\n') { + printk(KERN_INFO DRV_NAME + ": %s: Setting primary slave to None.\n", + bond->dev->name); + bond->primary_slave = 0; + bond_select_active_slave(bond); + } else { + printk(KERN_INFO DRV_NAME + ": %s: Unable to set %.*s as primary slave as it is not a slave.\n", + bond->dev->name, (int)strlen(buf) - 1, buf); + } + } +out: + write_unlock_bh(&bond->lock); + return count; +} +static CLASS_DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary); + +/* + * Show and set the use_carrier flag. + */ +static ssize_t bonding_show_carrier(struct class_device *cd, char *buf) +{ + struct bonding *bond = to_bond(cd); + + return sprintf(buf, "%d\n", bond->params.use_carrier) + 1; +} + +static ssize_t bonding_store_carrier(struct class_device *cd, const char *buf, size_t count) +{ + int new_value, ret = count; + struct bonding *bond = to_bond(cd); + + + if (sscanf(buf, "%d", &new_value) != 1) { + printk(KERN_ERR DRV_NAME + ": %s: no use_carrier value specified.\n", + bond->dev->name); + ret = -EINVAL; + goto out; + } + if ((new_value == 0) || (new_value == 1)) { + bond->params.use_carrier = new_value; + printk(KERN_INFO DRV_NAME ": %s: Setting use_carrier to %d.\n", + bond->dev->name, new_value); + } else { + printk(KERN_INFO DRV_NAME + ": %s: Ignoring invalid use_carrier value %d.\n", + bond->dev->name, new_value); + } +out: + return count; +} +static CLASS_DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier); + + +/* + * Show and set currently active_slave. + */ +static ssize_t bonding_show_active_slave(struct class_device *cd, char *buf) +{ + struct slave *curr; + struct bonding *bond = to_bond(cd); + int count; + + + read_lock(&bond->curr_slave_lock); + curr = bond->curr_active_slave; + read_unlock(&bond->curr_slave_lock); + + if (USES_PRIMARY(bond->params.mode) && curr) + count = sprintf(buf, "%s\n", curr->dev->name) + 1; + else + count = sprintf(buf, "\n") + 1; + return count; +} + +static ssize_t bonding_store_active_slave(struct class_device *cd, const char *buf, size_t count) +{ + int i; + struct slave *slave; + struct slave *old_active = NULL; + struct slave *new_active = NULL; + struct bonding *bond = to_bond(cd); + + write_lock_bh(&bond->lock); + if (!USES_PRIMARY(bond->params.mode)) { + printk(KERN_INFO DRV_NAME + ": %s: Unable to change active slave; %s is in mode %d\n", + bond->dev->name, bond->dev->name, bond->params.mode); + } else { + bond_for_each_slave(bond, slave, i) { + if (strnicmp + (slave->dev->name, buf, + strlen(slave->dev->name)) == 0) { + old_active = bond->curr_active_slave; + new_active = slave; + if (new_active && (new_active == old_active)) { + /* do nothing */ + printk(KERN_INFO DRV_NAME + ": %s: %s is already the current active slave.\n", + bond->dev->name, slave->dev->name); + goto out; + } + else { + if ((new_active) && + (old_active) && + (new_active->link == BOND_LINK_UP) && + IS_UP(new_active->dev)) { + printk(KERN_INFO DRV_NAME + ": %s: Setting %s as active slave.\n", + bond->dev->name, slave->dev->name); + bond_change_active_slave(bond, new_active); + } + else { + printk(KERN_INFO DRV_NAME + ": %s: Could not set %s as active slave; " + "either %s is down or the link is down.\n", + bond->dev->name, slave->dev->name, + slave->dev->name); + } + goto out; + } + } + } + + /* if we got here, then we didn't match the name of any slave */ + + if (strlen(buf) == 0 || buf[0] == '\n') { + printk(KERN_INFO DRV_NAME + ": %s: Setting active slave to None.\n", + bond->dev->name); + bond->primary_slave = 0; + bond_select_active_slave(bond); + } else { + printk(KERN_INFO DRV_NAME + ": %s: Unable to set %.*s as active slave as it is not a slave.\n", + bond->dev->name, (int)strlen(buf) - 1, buf); + } + } +out: + write_unlock_bh(&bond->lock); + return count; + +} +static CLASS_DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave); + + +/* + * Show link status of the bond interface. + */ +static ssize_t bonding_show_mii_status(struct class_device *cd, char *buf) +{ + struct slave *curr; + struct bonding *bond = to_bond(cd); + + read_lock(&bond->curr_slave_lock); + curr = bond->curr_active_slave; + read_unlock(&bond->curr_slave_lock); + + return sprintf(buf, "%s\n", (curr) ? "up" : "down") + 1; +} +static CLASS_DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); + + +/* + * Show current 802.3ad aggregator ID. + */ +static ssize_t bonding_show_ad_aggregator(struct class_device *cd, char *buf) +{ + int count = 0; + struct bonding *bond = to_bond(cd); + + if (bond->params.mode == BOND_MODE_8023AD) { + struct ad_info ad_info; + count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.aggregator_id) + 1; + } + else + count = sprintf(buf, "\n") + 1; + + return count; +} +static CLASS_DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); + + +/* + * Show number of active 802.3ad ports. + */ +static ssize_t bonding_show_ad_num_ports(struct class_device *cd, char *buf) +{ + int count = 0; + struct bonding *bond = to_bond(cd); + + if (bond->params.mode == BOND_MODE_8023AD) { + struct ad_info ad_info; + count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0: ad_info.ports) + 1; + } + else + count = sprintf(buf, "\n") + 1; + + return count; +} +static CLASS_DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); + + +/* + * Show current 802.3ad actor key. + */ +static ssize_t bonding_show_ad_actor_key(struct class_device *cd, char *buf) +{ + int count = 0; + struct bonding *bond = to_bond(cd); + + if (bond->params.mode == BOND_MODE_8023AD) { + struct ad_info ad_info; + count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.actor_key) + 1; + } + else + count = sprintf(buf, "\n") + 1; + + return count; +} +static CLASS_DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); + + +/* + * Show current 802.3ad partner key. + */ +static ssize_t bonding_show_ad_partner_key(struct class_device *cd, char *buf) +{ + int count = 0; + struct bonding *bond = to_bond(cd); + + if (bond->params.mode == BOND_MODE_8023AD) { + struct ad_info ad_info; + count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.partner_key) + 1; + } + else + count = sprintf(buf, "\n") + 1; + + return count; +} +static CLASS_DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); + + +/* + * Show current 802.3ad partner mac. + */ +static ssize_t bonding_show_ad_partner_mac(struct class_device *cd, char *buf) +{ + int count = 0; + struct bonding *bond = to_bond(cd); + + if (bond->params.mode == BOND_MODE_8023AD) { + struct ad_info ad_info; + if (!bond_3ad_get_active_agg_info(bond, &ad_info)) { + count = sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x\n", + ad_info.partner_system[0], + ad_info.partner_system[1], + ad_info.partner_system[2], + ad_info.partner_system[3], + ad_info.partner_system[4], + ad_info.partner_system[5]) + 1; + } + } + else + count = sprintf(buf, "\n") + 1; + + return count; +} +static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); + + + +static struct attribute *per_bond_attrs[] = { + &class_device_attr_slaves.attr, + &class_device_attr_mode.attr, + &class_device_attr_arp_interval.attr, + &class_device_attr_arp_ip_target.attr, + &class_device_attr_downdelay.attr, + &class_device_attr_updelay.attr, + &class_device_attr_lacp_rate.attr, + &class_device_attr_xmit_hash_policy.attr, + &class_device_attr_miimon.attr, + &class_device_attr_primary.attr, + &class_device_attr_use_carrier.attr, + &class_device_attr_active_slave.attr, + &class_device_attr_mii_status.attr, + &class_device_attr_ad_aggregator.attr, + &class_device_attr_ad_num_ports.attr, + &class_device_attr_ad_actor_key.attr, + &class_device_attr_ad_partner_key.attr, + &class_device_attr_ad_partner_mac.attr, + NULL, +}; + +static struct attribute_group bonding_group = { + .name = "bonding", + .attrs = per_bond_attrs, +}; + +/* + * Initialize sysfs. This sets up the bonding_masters file in + * /sys/class/net. + */ +int bond_create_sysfs(void) +{ + int ret = 0; + struct bonding *firstbond; + + init_rwsem(&bonding_rwsem); + + /* get the netdev class pointer */ + firstbond = container_of(bond_dev_list.next, struct bonding, bond_list); + if (!firstbond) + return -ENODEV; + + netdev_class = firstbond->dev->class_dev.class; + if (!netdev_class) + return -ENODEV; + + ret = class_create_file(netdev_class, &class_attr_bonding_masters); + + return ret; + +} + +/* + * Remove /sys/class/net/bonding_masters. + */ +void bond_destroy_sysfs(void) +{ + if (netdev_class) + class_remove_file(netdev_class, &class_attr_bonding_masters); +} + +/* + * Initialize sysfs for each bond. This sets up and registers + * the 'bondctl' directory for each individual bond under /sys/class/net. + */ +int bond_create_sysfs_entry(struct bonding *bond) +{ + struct net_device *dev = bond->dev; + int err; + + err = sysfs_create_group(&(dev->class_dev.kobj), &bonding_group); + if (err) { + printk(KERN_EMERG "eek! didn't create group!\n"); + } + + if (expected_refcount < 1) + expected_refcount = atomic_read(&bond->dev->class_dev.kobj.kref.refcount); + + return err; +} +/* + * Remove sysfs entries for each bond. + */ +void bond_destroy_sysfs_entry(struct bonding *bond) +{ + struct net_device *dev = bond->dev; + + sysfs_remove_group(&(dev->class_dev.kobj), &bonding_group); +} + diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 863605a..903e60a 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "bond_3ad.h" #include "bond_alb.h" @@ -262,6 +263,12 @@ struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr) int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); int bond_create(char *name, struct bond_params *params, struct bonding **newbond); void bond_deinit(struct net_device *bond_dev); +int bond_create_sysfs(void); +void bond_destroy_sysfs(void); +void bond_destroy_sysfs_entry(struct bonding *bond); +int bond_create_sysfs_entry(struct bonding *bond); +int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave); +void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave); int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev); -- cgit v1.1 From 39755cad88f7b26dcb1edf9dcf14bd85f8fc2a3a Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:36:46 -0800 Subject: [PATCH] bonding: version update Update the version number for the bonding module. Since we've just added a significant new feature (sysfs support), bump the major number. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bonding.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 903e60a..88b8981d 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -41,8 +41,8 @@ #include "bond_3ad.h" #include "bond_alb.h" -#define DRV_VERSION "2.6.5" -#define DRV_RELDATE "November 4, 2005" +#define DRV_VERSION "3.0.0" +#define DRV_RELDATE "November 8, 2005" #define DRV_NAME "bonding" #define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" -- cgit v1.1 From e944ef79184ff7f283e7bf79496d2873a0b0410b Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:36:50 -0800 Subject: [PATCH] bonding: spelling and whitespace corrections Minor spelling and whitespace corrections. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_alb.c | 2 +- drivers/net/bonding/bond_main.c | 1 + drivers/net/bonding/bonding.h | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 24f4a3d..9bd1e10 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -1417,7 +1417,7 @@ void bond_alb_monitor(struct bonding *bond) read_lock(&bond->curr_slave_lock); bond_for_each_slave(bond, slave, i) { - alb_send_learning_packets(slave,slave->dev->dev_addr); + alb_send_learning_packets(slave, slave->dev->dev_addr); } read_unlock(&bond->curr_slave_lock); diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 5ac9718..c7cd6b9 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4125,6 +4125,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) bond_for_each_slave(bond, slave, i) { dprintk("s %p s->p %p c_m %p\n", slave, slave->prev, slave->dev->change_mtu); + res = dev_set_mtu(slave->dev, new_mtu); if (res) { diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 88b8981d..ef4b11c 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -165,7 +165,7 @@ struct vlan_entry { }; struct slave { - struct net_device *dev; /* first - usefull for panic debug */ + struct net_device *dev; /* first - useful for panic debug */ struct slave *next; struct slave *prev; s16 delay; @@ -191,7 +191,7 @@ struct slave { * beforehand. */ struct bonding { - struct net_device *dev; /* first - usefull for panic debug */ + struct net_device *dev; /* first - useful for panic debug */ struct slave *first_slave; struct slave *curr_active_slave; struct slave *current_arp_slave; -- cgit v1.1 From 691b73b13220886aefacb7c7f7ace7f528bbf800 Mon Sep 17 00:00:00 2001 From: Mitch Williams Date: Wed, 9 Nov 2005 10:36:57 -0800 Subject: [PATCH] bonding: comments and changelog Bonding source files still have changelogs in the comments. This, then, is an update to that changelog. Signed-off-by: Mitch Williams Acked-by: Jay Vosburgh Signed-off-by: John W. Linville --- drivers/net/bonding/bond_main.c | 22 ++++++++++++++++++++++ drivers/net/bonding/bonding.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index c7cd6b9..40ff791 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -489,6 +489,28 @@ * Set version to 2.6.3. * 2005/09/26 - Jay Vosburgh * - Removed backwards compatibility for old ifenslaves. Version 2.6.4. + * 2005/09/27 - Mitch Williams + * - Radheka Godse + * - Split out bond creation code to allow for sysfs interface. + * - Removed static declaration on some functions and data items. + * - Added sysfs support, including capability to add/remove/change + * any bond at runtime. + * + * - Miscellaneous: + * - Added bonding: : prefix to sysfs log messages + * - Added arp_ip_targets to /proc entry + * - Allow ARP target table to have empty entries + * - trivial fix: added missing modes description to modinfo + * - Corrected bug in ALB init where kmalloc is called inside + * a held lock + * - Corrected behavior to maintain bond link when changing + * from arp monitor to miimon and vice versa + * - Added missing bonding: : prefix to alb, ad log messages + * - Fixed stack dump warnings seen if changing between miimon + * and arp monitoring when the bond interface is down. + * - Fixed stack dump warnings seen when enslaving an e100 + * driver + * - Set version to 3.0.0 */ //#define BONDING_DEBUG 1 diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index ef4b11c..d6d0854 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -29,6 +29,10 @@ * 2005/05/05 - Jason Gabler * - added "xmit_policy" kernel parameter for alternate hashing policy * support for mode 2 + * + * 2005/09/27 - Mitch Williams + * Radheka Godse + * - Added bonding sysfs interface */ #ifndef _LINUX_BONDING_H -- cgit v1.1 From e74ac79956ecb56e71a398c57eb10fab8c58a562 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 14 Nov 2005 18:16:37 -0500 Subject: [libata] remove two unused fields from struct ata_port --- include/linux/libata.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/libata.h b/include/linux/libata.h index f2dbb68..83a83ba 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -330,8 +330,6 @@ struct ata_port { u8 ctl; /* cache of ATA control register */ u8 last_ctl; /* Cache last written value */ - unsigned int bus_state; - unsigned int port_state; unsigned int pio_mask; unsigned int mwdma_mask; unsigned int udma_mask; -- cgit v1.1 From 1c24a412fd8873bcacba7ed8a1780d12b86b6cb5 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 14 Nov 2005 18:20:23 -0500 Subject: [libata ata_piix] cleanup: remove duplicate ata_port_info records --- drivers/scsi/ata_piix.c | 40 +++++++--------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 855428f..7a1ed94 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -78,9 +78,7 @@ enum { ich5_sata = 1, piix4_pata = 2, ich6_sata = 3, - ich6_sata_rm = 4, - ich7_sata = 5, - esb2_sata = 6, + ich6_sata_ahci = 4, PIIX_AHCI_DEVICE = 6, }; @@ -111,11 +109,11 @@ static const struct pci_device_id piix_pci_tbl[] = { { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata }, - { 0x8086, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_rm }, - { 0x8086, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_rm }, - { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7_sata }, - { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7_sata }, - { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb2_sata }, + { 0x8086, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, + { 0x8086, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, + { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, + { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, + { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, { } /* terminate list */ }; @@ -258,31 +256,7 @@ static struct ata_port_info piix_port_info[] = { .port_ops = &piix_sata_ops, }, - /* ich6_sata_rm */ - { - .sht = &piix_sht, - .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | - PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR | - ATA_FLAG_SLAVE_POSS | PIIX_FLAG_AHCI, - .pio_mask = 0x1f, /* pio0-4 */ - .mwdma_mask = 0x07, /* mwdma0-2 */ - .udma_mask = 0x7f, /* udma0-6 */ - .port_ops = &piix_sata_ops, - }, - - /* ich7_sata */ - { - .sht = &piix_sht, - .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | - PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR | - ATA_FLAG_SLAVE_POSS | PIIX_FLAG_AHCI, - .pio_mask = 0x1f, /* pio0-4 */ - .mwdma_mask = 0x07, /* mwdma0-2 */ - .udma_mask = 0x7f, /* udma0-6 */ - .port_ops = &piix_sata_ops, - }, - - /* esb2_sata */ + /* ich6_sata_ahci */ { .sht = &piix_sht, .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | -- cgit v1.1 From c8ebd3a37f0e7a2aae337279d58a50c1a1fcd053 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 11 Nov 2005 20:44:21 +0100 Subject: [PATCH] drivers/net/sk98lin/skge.c: make SkPciWriteCfgDWord() a static inline No external user and that small - such a function should be static inline and not a global function. Signed-off-by: Adrian Bunk Signed-off-by: John W. Linville --- drivers/net/sk98lin/h/skvpd.h | 8 -------- drivers/net/sk98lin/skge.c | 43 +++++++++++++++++++++---------------------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/drivers/net/sk98lin/h/skvpd.h b/drivers/net/sk98lin/h/skvpd.h index bdc1a5e..daa9a8d 100644 --- a/drivers/net/sk98lin/h/skvpd.h +++ b/drivers/net/sk98lin/h/skvpd.h @@ -130,14 +130,12 @@ typedef struct s_vpd_key { #ifndef VPD_DO_IO #define VPD_OUT8(pAC,IoC,Addr,Val) (void)SkPciWriteCfgByte(pAC,Addr,Val) #define VPD_OUT16(pAC,IoC,Addr,Val) (void)SkPciWriteCfgWord(pAC,Addr,Val) -#define VPD_OUT32(pAC,IoC,Addr,Val) (void)SkPciWriteCfgDWord(pAC,Addr,Val) #define VPD_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal) #define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal) #define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal) #else /* VPD_DO_IO */ #define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val) #define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val) -#define VPD_OUT32(pAC,IoC,Addr,Val) SK_OUT32(IoC,PCI_C(Addr),Val) #define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal) #define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal) #define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal) @@ -155,12 +153,6 @@ typedef struct s_vpd_key { else \ SK_OUT16(pAC,PCI_C(Addr),Val); \ } -#define VPD_OUT32(pAC,Ioc,Addr,Val) { \ - if ((pAC)->DgT.DgUseCfgCycle) \ - SkPciWriteCfgDWord(pAC,Addr,Val); \ - else \ - SK_OUT32(pAC,PCI_C(Addr),Val); \ - } #define VPD_IN8(pAC,Ioc,Addr,pVal) { \ if ((pAC)->DgT.DgUseCfgCycle) \ SkPciReadCfgByte(pAC,Addr,pVal); \ diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index b18c92c..08906ef 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c @@ -279,6 +279,27 @@ static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480}; /***************************************************************************** * + * SkPciWriteCfgDWord - write a 32 bit value to pci config space + * + * Description: + * This routine writes a 32 bit value to the pci configuration + * space. + * + * Returns: + * 0 - indicate everything worked ok. + * != 0 - error indication + */ +static inline int SkPciWriteCfgDWord( +SK_AC *pAC, /* Adapter Control structure pointer */ +int PciAddr, /* PCI register address */ +SK_U32 Val) /* pointer to store the read value */ +{ + pci_write_config_dword(pAC->PciDev, PciAddr, Val); + return(0); +} /* SkPciWriteCfgDWord */ + +/***************************************************************************** + * * SkGeInitPCI - Init the PCI resources * * Description: @@ -4085,28 +4106,6 @@ SK_U8 *pVal) /* pointer to store the read value */ /***************************************************************************** * - * SkPciWriteCfgDWord - write a 32 bit value to pci config space - * - * Description: - * This routine writes a 32 bit value to the pci configuration - * space. - * - * Returns: - * 0 - indicate everything worked ok. - * != 0 - error indication - */ -int SkPciWriteCfgDWord( -SK_AC *pAC, /* Adapter Control structure pointer */ -int PciAddr, /* PCI register address */ -SK_U32 Val) /* pointer to store the read value */ -{ - pci_write_config_dword(pAC->PciDev, PciAddr, Val); - return(0); -} /* SkPciWriteCfgDWord */ - - -/***************************************************************************** - * * SkPciWriteCfgWord - write a 16 bit value to pci config space * * Description: -- cgit v1.1 From 9a648f3c535cb6b24a5f0538d032aea9a33ec515 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Sun, 13 Nov 2005 00:33:32 -0500 Subject: [PATCH] skge: fix warning from inlining SkPciWriteCfgDWord() Making SkPciWriteCfgDWord a static inline produces a warning due to a forward declaration in skdrv2nd.h. This patch removes that declaration. Signed-off-by: John W. Linville --- drivers/net/sk98lin/h/skdrv2nd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h index 542cec5..c0bfce5 100644 --- a/drivers/net/sk98lin/h/skdrv2nd.h +++ b/drivers/net/sk98lin/h/skdrv2nd.h @@ -60,7 +60,6 @@ extern SK_U64 SkOsGetTime(SK_AC*); extern int SkPciReadCfgDWord(SK_AC*, int, SK_U32*); extern int SkPciReadCfgWord(SK_AC*, int, SK_U16*); extern int SkPciReadCfgByte(SK_AC*, int, SK_U8*); -extern int SkPciWriteCfgDWord(SK_AC*, int, SK_U32); extern int SkPciWriteCfgWord(SK_AC*, int, SK_U16); extern int SkPciWriteCfgByte(SK_AC*, int, SK_U8); extern int SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA); -- cgit v1.1 From c1120b22499d7e13e5cd2349cb2168b76d0edaca Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sat, 12 Nov 2005 23:46:43 +0300 Subject: [PATCH] Remove drivers/net/wan/lmc/lmc_prot.h "grep "lmc_prot\." -r ." didn't show anything. lmc_proto.h seems to have the correct prototypes, and is actually used. Signed-off-by: Tobias Klauser Signed-off-by: Alexey Dobriyan Signed-off-by: John W. Linville --- drivers/net/wan/lmc/lmc_prot.h | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 drivers/net/wan/lmc/lmc_prot.h diff --git a/drivers/net/wan/lmc/lmc_prot.h b/drivers/net/wan/lmc/lmc_prot.h deleted file mode 100644 index f3b1df9..0000000 --- a/drivers/net/wan/lmc/lmc_prot.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _LMC_PROTO_H_ -#define _LMC_PROTO_H_ - -void lmc_proto_init(lmc_softc_t * const) -void lmc_proto_attach(lmc_softc_t *sc const) -void lmc_proto_detach(lmc_softc *sc const) -void lmc_proto_reopen(lmc_softc_t *sc const) -int lmc_proto_ioctl(lmc_softc_t *sc const, struct ifreq *ifr, int cmd) -void lmc_proto_open(lmc_softc_t *sc const) -void lmc_proto_close(lmc_softc_t *sc const) -unsigned short lmc_proto_type(lmc_softc_t *sc const, struct skbuff *skb) - - -#endif - -- cgit v1.1 From 4d791aadf63c9d605bc9a4144e79d5756fc29fb3 Mon Sep 17 00:00:00 2001 From: Carlo Perassi Date: Sun, 13 Nov 2005 15:02:15 +0300 Subject: [PATCH] atmel: CodingStyle cleanup Reading this driver I noticed some trailing whitespaces and tabs so I removed them with some 80th column fitting and a few more similar things. Signed-off-by: Carlo Perassi Signed-off-by: Alexey Dobriyan Signed-off-by: John W. Linville --- drivers/net/wireless/atmel.c | 1487 +++++++++++++++++++++--------------------- 1 file changed, 759 insertions(+), 728 deletions(-) diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 5e53c52..050aa51 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c @@ -5,9 +5,9 @@ Copyright 2000-2001 ATMEL Corporation. Copyright 2003-2004 Simon Kelley. - This code was developed from version 2.1.1 of the Atmel drivers, - released by Atmel corp. under the GPL in December 2002. It also - includes code from the Linux aironet drivers (C) Benjamin Reed, + This code was developed from version 2.1.1 of the Atmel drivers, + released by Atmel corp. under the GPL in December 2002. It also + includes code from the Linux aironet drivers (C) Benjamin Reed, and the Linux PCMCIA package, (C) David Hinds and the Linux wireless extensions, (C) Jean Tourrilhes. @@ -31,7 +31,7 @@ along with Atmel wireless lan drivers; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - For all queries about this code, please contact the current author, + For all queries about this code, please contact the current author, Simon Kelley and not Atmel Corporation. Credit is due to HP UK and Cambridge Online Systems Ltd for supplying @@ -79,13 +79,13 @@ MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.") MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("Atmel at76c50x wireless cards"); -/* The name of the firmware file to be loaded +/* The name of the firmware file to be loaded over-rides any automatic selection */ static char *firmware = NULL; module_param(firmware, charp, 0); /* table of firmware file names */ -static struct { +static struct { AtmelFWType fw_type; const char *fw_file; const char *fw_file_ext; @@ -104,17 +104,17 @@ static struct { #define MAX_SSID_LENGTH 32 #define MGMT_JIFFIES (256 * HZ / 100) -#define MAX_BSS_ENTRIES 64 +#define MAX_BSS_ENTRIES 64 /* registers */ -#define GCR 0x00 // (SIR0) General Configuration Register -#define BSR 0x02 // (SIR1) Bank Switching Select Register +#define GCR 0x00 // (SIR0) General Configuration Register +#define BSR 0x02 // (SIR1) Bank Switching Select Register #define AR 0x04 #define DR 0x08 -#define MR1 0x12 // Mirror Register 1 -#define MR2 0x14 // Mirror Register 2 -#define MR3 0x16 // Mirror Register 3 -#define MR4 0x18 // Mirror Register 4 +#define MR1 0x12 // Mirror Register 1 +#define MR2 0x14 // Mirror Register 2 +#define MR3 0x16 // Mirror Register 3 +#define MR4 0x18 // Mirror Register 4 #define GPR1 0x0c #define GPR2 0x0e @@ -123,9 +123,9 @@ static struct { // Constants for the GCR register. // #define GCR_REMAP 0x0400 // Remap internal SRAM to 0 -#define GCR_SWRES 0x0080 // BIU reset (ARM and PAI are NOT reset) +#define GCR_SWRES 0x0080 // BIU reset (ARM and PAI are NOT reset) #define GCR_CORES 0x0060 // Core Reset (ARM and PAI are reset) -#define GCR_ENINT 0x0002 // Enable Interrupts +#define GCR_ENINT 0x0002 // Enable Interrupts #define GCR_ACKINT 0x0008 // Acknowledge Interrupts #define BSS_SRAM 0x0200 // AMBA module selection --> SRAM @@ -190,7 +190,7 @@ struct rx_desc { u32 Next; u16 MsduPos; u16 MsduSize; - + u8 State; u8 Status; u8 Rate; @@ -199,7 +199,6 @@ struct rx_desc { u8 PreambleType; u16 Duration; u32 RxTime; - }; #define RX_DESC_FLAG_VALID 0x80 @@ -218,16 +217,15 @@ struct rx_desc { #define RX_DESC_DURATION_OFFSET 14 #define RX_DESC_RX_TIME_OFFSET 16 - struct tx_desc { u32 NextDescriptor; u16 TxStartOfFrame; u16 TxLength; - + u8 TxState; u8 TxStatus; u8 RetryCount; - + u8 TxRate; u8 KeyIndex; @@ -238,10 +236,8 @@ struct tx_desc { u8 Reserved; u8 PacketType; u16 HostTxLength; - }; - #define TX_DESC_NEXT_OFFSET 0 #define TX_DESC_POS_OFFSET 4 #define TX_DESC_SIZE_OFFSET 6 @@ -255,8 +251,6 @@ struct tx_desc { #define TX_DESC_PACKET_TYPE_OFFSET 17 #define TX_DESC_HOST_LENGTH_OFFSET 18 - - /////////////////////////////////////////////////////// // Host-MAC interface /////////////////////////////////////////////////////// @@ -266,7 +260,6 @@ struct tx_desc { #define TX_FIRM_OWN 0x80 #define TX_DONE 0x40 - #define TX_ERROR 0x01 #define TX_PACKET_TYPE_DATA 0x01 @@ -280,8 +273,7 @@ struct tx_desc { #define ISR_COMMAND_COMPLETE 0x10 // command completed #define ISR_OUT_OF_RANGE 0x20 // command completed #define ISR_IBSS_MERGE 0x40 // (4.1.2.30): IBSS merge -#define ISR_GENERIC_IRQ 0x80 - +#define ISR_GENERIC_IRQ 0x80 #define Local_Mib_Type 0x01 #define Mac_Address_Mib_Type 0x02 @@ -317,7 +309,6 @@ struct tx_desc { #define LOCAL_MIB_PREAMBLE_TYPE 9 #define MAC_ADDR_MIB_MAC_ADDR_POS 0 - #define CMD_Set_MIB_Vars 0x01 #define CMD_Get_MIB_Vars 0x02 #define CMD_Scan 0x03 @@ -338,7 +329,6 @@ struct tx_desc { #define CMD_STATUS_HOST_ERROR 0xFF #define CMD_STATUS_BUSY 0xFE - #define CMD_BLOCK_COMMAND_OFFSET 0 #define CMD_BLOCK_STATUS_OFFSET 1 #define CMD_BLOCK_PARAMETERS_OFFSET 4 @@ -347,15 +337,15 @@ struct tx_desc { #define MGMT_FRAME_BODY_OFFSET 24 #define MAX_AUTHENTICATION_RETRIES 3 -#define MAX_ASSOCIATION_RETRIES 3 +#define MAX_ASSOCIATION_RETRIES 3 #define AUTHENTICATION_RESPONSE_TIME_OUT 1000 #define MAX_WIRELESS_BODY 2316 /* mtu is 2312, CRC is 4 */ #define LOOP_RETRY_LIMIT 500000 -#define ACTIVE_MODE 1 -#define PS_MODE 2 +#define ACTIVE_MODE 1 +#define PS_MODE 2 #define MAX_ENCRYPTION_KEYS 4 #define MAX_ENCRYPTION_KEY_SIZE 40 @@ -377,7 +367,7 @@ struct tx_desc { #define REG_DOMAIN_MKK1 0x41 //Channel 1-14 Japan(MKK1) #define REG_DOMAIN_ISRAEL 0x50 //Channel 3-9 ISRAEL -#define BSS_TYPE_AD_HOC 1 +#define BSS_TYPE_AD_HOC 1 #define BSS_TYPE_INFRASTRUCTURE 2 #define SCAN_TYPE_ACTIVE 0 @@ -389,7 +379,7 @@ struct tx_desc { #define DATA_FRAME_WS_HEADER_SIZE 30 -/* promiscuous mode control */ +/* promiscuous mode control */ #define PROM_MODE_OFF 0x0 #define PROM_MODE_UNKNOWN 0x1 #define PROM_MODE_CRC_FAILED 0x2 @@ -398,8 +388,7 @@ struct tx_desc { #define PROM_MODE_CTRL 0x10 #define PROM_MODE_BAD_PROTOCOL 0x20 - -#define IFACE_INT_STATUS_OFFSET 0 +#define IFACE_INT_STATUS_OFFSET 0 #define IFACE_INT_MASK_OFFSET 1 #define IFACE_LOCKOUT_HOST_OFFSET 2 #define IFACE_LOCKOUT_MAC_OFFSET 3 @@ -407,7 +396,7 @@ struct tx_desc { #define IFACE_MAC_STAT_OFFSET 30 #define IFACE_GENERIC_INT_TYPE_OFFSET 32 -#define CIPHER_SUITE_NONE 0 +#define CIPHER_SUITE_NONE 0 #define CIPHER_SUITE_WEP_64 1 #define CIPHER_SUITE_TKIP 2 #define CIPHER_SUITE_AES 3 @@ -419,11 +408,11 @@ struct tx_desc { // // -// FuncCtrl field: +// FuncCtrl field: // #define FUNC_CTRL_TxENABLE 0x10 #define FUNC_CTRL_RxENABLE 0x20 -#define FUNC_CTRL_INIT_COMPLETE 0x01 +#define FUNC_CTRL_INIT_COMPLETE 0x01 /* A stub firmware image which reads the MAC address from NVRAM on the card. For copyright information and source see the end of this file. */ @@ -486,10 +475,10 @@ struct atmel_private { struct net_device_stats stats; // device stats spinlock_t irqlock, timerlock; // spinlocks enum { BUS_TYPE_PCCARD, BUS_TYPE_PCI } bus_type; - enum { - CARD_TYPE_PARALLEL_FLASH, + enum { + CARD_TYPE_PARALLEL_FLASH, CARD_TYPE_SPI_FLASH, - CARD_TYPE_EEPROM + CARD_TYPE_EEPROM } card_type; int do_rx_crc; /* If we need to CRC incoming packets */ int probe_crc; /* set if we don't yet know */ @@ -497,18 +486,18 @@ struct atmel_private { u16 rx_desc_head; u16 tx_desc_free, tx_desc_head, tx_desc_tail, tx_desc_previous; u16 tx_free_mem, tx_buff_head, tx_buff_tail; - + u16 frag_seq, frag_len, frag_no; - u8 frag_source[6]; - + u8 frag_source[6]; + u8 wep_is_on, default_key, exclude_unencrypted, encryption_level; u8 group_cipher_suite, pairwise_cipher_suite; u8 wep_keys[MAX_ENCRYPTION_KEYS][MAX_ENCRYPTION_KEY_SIZE]; - int wep_key_len[MAX_ENCRYPTION_KEYS]; + int wep_key_len[MAX_ENCRYPTION_KEYS]; int use_wpa, radio_on_broken; /* firmware dependent stuff. */ u16 host_info_base; - struct host_info_struct { + struct host_info_struct { /* NB this is matched to the hardware, don't change. */ u8 volatile int_status; u8 volatile int_mask; @@ -524,20 +513,20 @@ struct atmel_private { u16 rx_buff_size; u16 rx_desc_pos; u16 rx_desc_count; - + u16 build_version; - u16 command_pos; - + u16 command_pos; + u16 major_version; u16 minor_version; - + u16 func_ctrl; u16 mac_status; u16 generic_IRQ_type; u8 reserved[2]; } host_info; - enum { + enum { STATION_STATE_SCANNING, STATION_STATE_JOINNING, STATION_STATE_AUTHENTICATING, @@ -547,7 +536,7 @@ struct atmel_private { STATION_STATE_DOWN, STATION_STATE_MGMT_ERROR } station_state; - + int operating_mode, power_mode; time_t last_qual; int beacons_this_sec; @@ -560,18 +549,18 @@ struct atmel_private { int long_retry, short_retry; int preamble; int default_beacon_period, beacon_period, listen_interval; - int CurrentAuthentTransactionSeqNum, ExpectedAuthentTransactionSeqNum; + int CurrentAuthentTransactionSeqNum, ExpectedAuthentTransactionSeqNum; int AuthenticationRequestRetryCnt, AssociationRequestRetryCnt, ReAssociationRequestRetryCnt; enum { SITE_SURVEY_IDLE, SITE_SURVEY_IN_PROGRESS, - SITE_SURVEY_COMPLETED + SITE_SURVEY_COMPLETED } site_survey_state; time_t last_survey; int station_was_associated, station_is_associated; int fast_scan; - + struct bss_info { int channel; int SSIDsize; @@ -584,13 +573,12 @@ struct atmel_private { u8 SSID[MAX_SSID_LENGTH]; } BSSinfo[MAX_BSS_ENTRIES]; int BSS_list_entries, current_BSS; - int connect_to_any_BSS; + int connect_to_any_BSS; int SSID_size, new_SSID_size; u8 CurrentBSSID[6], BSSID[6]; u8 SSID[MAX_SSID_LENGTH], new_SSID[MAX_SSID_LENGTH]; u64 last_beacon_timestamp; u8 rx_buf[MAX_WIRELESS_BODY]; - }; static u8 atmel_basic_rates[4] = {0x82,0x84,0x0b,0x16}; @@ -598,39 +586,49 @@ static u8 atmel_basic_rates[4] = {0x82,0x84,0x0b,0x16}; static const struct { int reg_domain; int min, max; - char *name; + char *name; } channel_table[] = { { REG_DOMAIN_FCC, 1, 11, "USA" }, { REG_DOMAIN_DOC, 1, 11, "Canada" }, { REG_DOMAIN_ETSI, 1, 13, "Europe" }, { REG_DOMAIN_SPAIN, 10, 11, "Spain" }, - { REG_DOMAIN_FRANCE, 10, 13, "France" }, + { REG_DOMAIN_FRANCE, 10, 13, "France" }, { REG_DOMAIN_MKK, 14, 14, "MKK" }, { REG_DOMAIN_MKK1, 1, 14, "MKK1" }, { REG_DOMAIN_ISRAEL, 3, 9, "Israel"} }; static void build_wpa_mib(struct atmel_private *priv); static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); -static void atmel_copy_to_card(struct net_device *dev, u16 dest, unsigned char *src, u16 len); -static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest, u16 src, u16 len); +static void atmel_copy_to_card(struct net_device *dev, u16 dest, + unsigned char *src, u16 len); +static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest, + u16 src, u16 len); static void atmel_set_gcr(struct net_device *dev, u16 mask); static void atmel_clear_gcr(struct net_device *dev, u16 mask); static int atmel_lock_mac(struct atmel_private *priv); static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data); static void atmel_command_irq(struct atmel_private *priv); static int atmel_validate_channel(struct atmel_private *priv, int channel); -static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, +static void atmel_management_frame(struct atmel_private *priv, + struct ieee80211_hdr_4addr *header, u16 frame_len, u8 rssi); static void atmel_management_timer(u_long a); -static void atmel_send_command(struct atmel_private *priv, int command, void *cmd, int cmd_size); -static int atmel_send_command_wait(struct atmel_private *priv, int command, void *cmd, int cmd_size); -static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, +static void atmel_send_command(struct atmel_private *priv, int command, + void *cmd, int cmd_size); +static int atmel_send_command_wait(struct atmel_private *priv, int command, + void *cmd, int cmd_size); +static void atmel_transmit_management_frame(struct atmel_private *priv, + struct ieee80211_hdr_4addr *header, u8 *body, int body_len); static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index); -static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index, u8 data); -static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, u16 data); -static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len); -static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len); +static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index, + u8 data); +static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, + u16 data); +static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, + u8 *data, int data_len); +static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, + u8 *data, int data_len); static void atmel_scan(struct atmel_private *priv, int specific_ssid); static void atmel_join_bss(struct atmel_private *priv, int bss_index); static void atmel_smooth_qual(struct atmel_private *priv); @@ -650,12 +648,12 @@ static inline u16 atmel_co(struct atmel_private *priv, u16 offset) return priv->host_info.command_pos + offset; } -static inline u16 atmel_rx(struct atmel_private *priv, u16 offset, u16 desc) +static inline u16 atmel_rx(struct atmel_private *priv, u16 offset, u16 desc) { return priv->host_info.rx_desc_pos + (sizeof(struct rx_desc) * desc) + offset; } -static inline u16 atmel_tx(struct atmel_private *priv, u16 offset, u16 desc) +static inline u16 atmel_tx(struct atmel_private *priv, u16 offset, u16 desc) { return priv->host_info.tx_desc_pos + (sizeof(struct tx_desc) * desc) + offset; } @@ -682,25 +680,25 @@ static inline void atmel_write16(struct net_device *dev, u16 offset, u16 data) static inline u8 atmel_rmem8(struct atmel_private *priv, u16 pos) { - atmel_writeAR(priv->dev, pos); + atmel_writeAR(priv->dev, pos); return atmel_read8(priv->dev, DR); } static inline void atmel_wmem8(struct atmel_private *priv, u16 pos, u16 data) { - atmel_writeAR(priv->dev, pos); + atmel_writeAR(priv->dev, pos); atmel_write8(priv->dev, DR, data); } static inline u16 atmel_rmem16(struct atmel_private *priv, u16 pos) { - atmel_writeAR(priv->dev, pos); + atmel_writeAR(priv->dev, pos); return atmel_read16(priv->dev, DR); } static inline void atmel_wmem16(struct atmel_private *priv, u16 pos, u16 data) { - atmel_writeAR(priv->dev, pos); + atmel_writeAR(priv->dev, pos); atmel_write16(priv->dev, DR, data); } @@ -710,11 +708,10 @@ static void tx_done_irq(struct atmel_private *priv) { int i; - for (i = 0; + for (i = 0; atmel_rmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, priv->tx_desc_head)) == TX_DONE && i < priv->host_info.tx_desc_count; i++) { - u8 status = atmel_rmem8(priv, atmel_tx(priv, TX_DESC_STATUS_OFFSET, priv->tx_desc_head)); u16 msdu_size = atmel_rmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_head)); u8 type = atmel_rmem8(priv, atmel_tx(priv, TX_DESC_PACKET_TYPE_OFFSET, priv->tx_desc_head)); @@ -728,16 +725,16 @@ static void tx_done_irq(struct atmel_private *priv) priv->tx_buff_head = 0; else priv->tx_buff_head += msdu_size; - + if (priv->tx_desc_head < (priv->host_info.tx_desc_count - 1)) - priv->tx_desc_head++ ; + priv->tx_desc_head++ ; else priv->tx_desc_head = 0; - + if (type == TX_PACKET_TYPE_DATA) { if (status == TX_STATUS_SUCCESS) priv->stats.tx_packets++; - else + else priv->stats.tx_errors++; netif_wake_queue(priv->dev); } @@ -748,21 +745,22 @@ static u16 find_tx_buff(struct atmel_private *priv, u16 len) { u16 bottom_free = priv->host_info.tx_buff_size - priv->tx_buff_tail; - if (priv->tx_desc_free == 3 || priv->tx_free_mem < len) + if (priv->tx_desc_free == 3 || priv->tx_free_mem < len) return 0; - + if (bottom_free >= len) return priv->host_info.tx_buff_pos + priv->tx_buff_tail; - + if (priv->tx_free_mem - bottom_free >= len) { priv->tx_buff_tail = 0; return priv->host_info.tx_buff_pos; } - + return 0; } -static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 len, u16 buff, u8 type) +static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, + u16 len, u16 buff, u8 type) { atmel_wmem16(priv, atmel_tx(priv, TX_DESC_POS_OFFSET, priv->tx_desc_tail), buff); atmel_wmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_tail), len); @@ -775,8 +773,8 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l int cipher_type, cipher_length; if (is_bcast) { cipher_type = priv->group_cipher_suite; - if (cipher_type == CIPHER_SUITE_WEP_64 || - cipher_type == CIPHER_SUITE_WEP_128 ) + if (cipher_type == CIPHER_SUITE_WEP_64 || + cipher_type == CIPHER_SUITE_WEP_128) cipher_length = 8; else if (cipher_type == CIPHER_SUITE_TKIP) cipher_length = 12; @@ -790,8 +788,8 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l } } else { cipher_type = priv->pairwise_cipher_suite; - if (cipher_type == CIPHER_SUITE_WEP_64 || - cipher_type == CIPHER_SUITE_WEP_128 ) + if (cipher_type == CIPHER_SUITE_WEP_64 || + cipher_type == CIPHER_SUITE_WEP_128) cipher_length = 8; else if (cipher_type == CIPHER_SUITE_TKIP) cipher_length = 12; @@ -804,9 +802,9 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l cipher_length = 0; } } - + atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_TYPE_OFFSET, priv->tx_desc_tail), - cipher_type); + cipher_type); atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_LENGTH_OFFSET, priv->tx_desc_tail), cipher_length); } @@ -815,46 +813,46 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l if (priv->tx_desc_previous != priv->tx_desc_tail) atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, priv->tx_desc_previous), 0); priv->tx_desc_previous = priv->tx_desc_tail; - if (priv->tx_desc_tail < (priv->host_info.tx_desc_count -1 )) + if (priv->tx_desc_tail < (priv->host_info.tx_desc_count - 1)) priv->tx_desc_tail++; else priv->tx_desc_tail = 0; priv->tx_desc_free--; priv->tx_free_mem -= len; - } -static int start_tx (struct sk_buff *skb, struct net_device *dev) +static int start_tx(struct sk_buff *skb, struct net_device *dev) { struct atmel_private *priv = netdev_priv(dev); struct ieee80211_hdr_4addr header; unsigned long flags; u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; - - if (priv->card && priv->present_callback && + + if (priv->card && priv->present_callback && !(*priv->present_callback)(priv->card)) { priv->stats.tx_errors++; dev_kfree_skb(skb); return 0; } - + if (priv->station_state != STATION_STATE_READY) { priv->stats.tx_errors++; dev_kfree_skb(skb); return 0; } - + /* first ensure the timer func cannot run */ - spin_lock_bh(&priv->timerlock); + spin_lock_bh(&priv->timerlock); /* then stop the hardware ISR */ - spin_lock_irqsave(&priv->irqlock, flags); + spin_lock_irqsave(&priv->irqlock, flags); /* nb doing the above in the opposite order will deadlock */ - + /* The Wireless Header is 30 bytes. In the Ethernet packet we "cut" the - 12 first bytes (containing DA/SA) and put them in the appropriate fields of - the Wireless Header. Thus the packet length is then the initial + 18 (+30-12) */ - + 12 first bytes (containing DA/SA) and put them in the appropriate + fields of the Wireless Header. Thus the packet length is then the + initial + 18 (+30-12) */ + if (!(buff = find_tx_buff(priv, len + 18))) { priv->stats.tx_dropped++; spin_unlock_irqrestore(&priv->irqlock, flags); @@ -862,7 +860,7 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev) netif_stop_queue(dev); return 1; } - + frame_ctl = IEEE80211_FTYPE_DATA; header.duration_id = 0; header.seq_ctl = 0; @@ -878,7 +876,7 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev) memcpy(&header.addr2, dev->dev_addr, 6); memcpy(&header.addr3, skb->data, 6); } - + if (priv->use_wpa) memcpy(&header.addr4, SNAP_RFC1024, 6); @@ -888,27 +886,27 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev) /* Copy the packet sans its 802.3 header addresses which have been replaced */ atmel_copy_to_card(dev, buff + DATA_FRAME_WS_HEADER_SIZE, skb->data + 12, len - 12); priv->tx_buff_tail += len - 12 + DATA_FRAME_WS_HEADER_SIZE; - + /* low bit of first byte of destination tells us if broadcast */ tx_update_descriptor(priv, *(skb->data) & 0x01, len + 18, buff, TX_PACKET_TYPE_DATA); dev->trans_start = jiffies; priv->stats.tx_bytes += len; - + spin_unlock_irqrestore(&priv->irqlock, flags); spin_unlock_bh(&priv->timerlock); dev_kfree_skb(skb); - - return 0; + + return 0; } -static void atmel_transmit_management_frame(struct atmel_private *priv, +static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, u8 *body, int body_len) { u16 buff; - int len = MGMT_FRAME_BODY_OFFSET + body_len; - - if (!(buff = find_tx_buff(priv, len))) + int len = MGMT_FRAME_BODY_OFFSET + body_len; + + if (!(buff = find_tx_buff(priv, len))) return; atmel_copy_to_card(priv->dev, buff, (u8 *)header, MGMT_FRAME_BODY_OFFSET); @@ -916,24 +914,25 @@ static void atmel_transmit_management_frame(struct atmel_private *priv, priv->tx_buff_tail += len; tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT); } - -static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, + +static void fast_rx_path(struct atmel_private *priv, + struct ieee80211_hdr_4addr *header, u16 msdu_size, u16 rx_packet_loc, u32 crc) { /* fast path: unfragmented packet copy directly into skbuf */ - u8 mac4[6]; - struct sk_buff *skb; + u8 mac4[6]; + struct sk_buff *skb; unsigned char *skbp; - + /* get the final, mac 4 header field, this tells us encapsulation */ atmel_copy_to_host(priv->dev, mac4, rx_packet_loc + 24, 6); msdu_size -= 6; - + if (priv->do_rx_crc) { crc = crc32_le(crc, mac4, 6); msdu_size -= 4; } - + if (!(skb = dev_alloc_skb(msdu_size + 14))) { priv->stats.rx_dropped++; return; @@ -942,7 +941,7 @@ static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr skb_reserve(skb, 2); skbp = skb_put(skb, msdu_size + 12); atmel_copy_to_host(priv->dev, skbp + 12, rx_packet_loc + 30, msdu_size); - + if (priv->do_rx_crc) { u32 netcrc; crc = crc32_le(crc, skbp + 12, msdu_size); @@ -953,24 +952,25 @@ static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr return; } } - + memcpy(skbp, header->addr1, 6); /* destination address */ - if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) + if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) memcpy(&skbp[6], header->addr3, 6); else memcpy(&skbp[6], header->addr2, 6); /* source address */ - - priv->dev->last_rx=jiffies; + + priv->dev->last_rx = jiffies; skb->dev = priv->dev; skb->protocol = eth_type_trans(skb, priv->dev); - skb->ip_summed = CHECKSUM_NONE; + skb->ip_summed = CHECKSUM_NONE; netif_rx(skb); priv->stats.rx_bytes += 12 + msdu_size; priv->stats.rx_packets++; } /* Test to see if the packet in card memory at packet_loc has a valid CRC - It doesn't matter that this is slow: it is only used to proble the first few packets. */ + It doesn't matter that this is slow: it is only used to proble the first few + packets. */ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size) { int i = msdu_size - 4; @@ -980,7 +980,7 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size) return 0; atmel_copy_to_host(priv->dev, (void *)&netcrc, packet_loc + i, 4); - + atmel_writeAR(priv->dev, packet_loc); while (i--) { u8 octet = atmel_read8(priv->dev, DR); @@ -990,20 +990,22 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size) return (crc ^ 0xffffffff) == netcrc; } -static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, - u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no, u8 frag_no, int more_frags) +static void frag_rx_path(struct atmel_private *priv, + struct ieee80211_hdr_4addr *header, + u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no, + u8 frag_no, int more_frags) { - u8 mac4[6]; + u8 mac4[6]; u8 source[6]; struct sk_buff *skb; - if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) + if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) memcpy(source, header->addr3, 6); else - memcpy(source, header->addr2, 6); - + memcpy(source, header->addr2, 6); + rx_packet_loc += 24; /* skip header */ - + if (priv->do_rx_crc) msdu_size -= 4; @@ -1012,16 +1014,16 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr msdu_size -= 6; rx_packet_loc += 6; - if (priv->do_rx_crc) + if (priv->do_rx_crc) crc = crc32_le(crc, mac4, 6); - + priv->frag_seq = seq_no; priv->frag_no = 1; priv->frag_len = msdu_size; - memcpy(priv->frag_source, source, 6); + memcpy(priv->frag_source, source, 6); memcpy(&priv->rx_buf[6], source, 6); memcpy(priv->rx_buf, header->addr1, 6); - + atmel_copy_to_host(priv->dev, &priv->rx_buf[12], rx_packet_loc, msdu_size); if (priv->do_rx_crc) { @@ -1033,17 +1035,17 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr memset(priv->frag_source, 0xff, 6); } } - + } else if (priv->frag_no == frag_no && priv->frag_seq == seq_no && memcmp(priv->frag_source, source, 6) == 0) { - - atmel_copy_to_host(priv->dev, &priv->rx_buf[12 + priv->frag_len], + + atmel_copy_to_host(priv->dev, &priv->rx_buf[12 + priv->frag_len], rx_packet_loc, msdu_size); if (priv->do_rx_crc) { u32 netcrc; - crc = crc32_le(crc, - &priv->rx_buf[12 + priv->frag_len], + crc = crc32_le(crc, + &priv->rx_buf[12 + priv->frag_len], msdu_size); atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4); if ((crc ^ 0xffffffff) != netcrc) { @@ -1052,7 +1054,7 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr more_frags = 1; /* don't send broken assembly */ } } - + priv->frag_len += msdu_size; priv->frag_no++; @@ -1062,60 +1064,60 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr priv->stats.rx_dropped++; } else { skb_reserve(skb, 2); - memcpy(skb_put(skb, priv->frag_len + 12), + memcpy(skb_put(skb, priv->frag_len + 12), priv->rx_buf, priv->frag_len + 12); priv->dev->last_rx = jiffies; skb->dev = priv->dev; skb->protocol = eth_type_trans(skb, priv->dev); - skb->ip_summed = CHECKSUM_NONE; + skb->ip_summed = CHECKSUM_NONE; netif_rx(skb); priv->stats.rx_bytes += priv->frag_len + 12; priv->stats.rx_packets++; } } - } else priv->wstats.discard.fragment++; } - + static void rx_done_irq(struct atmel_private *priv) { int i; struct ieee80211_hdr_4addr header; - - for (i = 0; + + for (i = 0; atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID && i < priv->host_info.rx_desc_count; i++) { - + u16 msdu_size, rx_packet_loc, frame_ctl, seq_control; u8 status = atmel_rmem8(priv, atmel_rx(priv, RX_DESC_STATUS_OFFSET, priv->rx_desc_head)); u32 crc = 0xffffffff; - + if (status != RX_STATUS_SUCCESS) { if (status == 0xc1) /* determined by experiment */ priv->wstats.discard.nwid++; else - priv->stats.rx_errors++; + priv->stats.rx_errors++; goto next; } msdu_size = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_SIZE_OFFSET, priv->rx_desc_head)); rx_packet_loc = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_POS_OFFSET, priv->rx_desc_head)); - + if (msdu_size < 30) { - priv->stats.rx_errors++; + priv->stats.rx_errors++; goto next; } - + /* Get header as far as end of seq_ctl */ atmel_copy_to_host(priv->dev, (char *)&header, rx_packet_loc, 24); frame_ctl = le16_to_cpu(header.frame_ctl); seq_control = le16_to_cpu(header.seq_ctl); - /* probe for CRC use here if needed once five packets have arrived with - the same crc status, we assume we know what's happening and stop probing */ + /* probe for CRC use here if needed once five packets have + arrived with the same crc status, we assume we know what's + happening and stop probing */ if (priv->probe_crc) { if (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED)) { priv->do_rx_crc = probe_crc(priv, rx_packet_loc, msdu_size); @@ -1130,34 +1132,33 @@ static void rx_done_irq(struct atmel_private *priv) priv->probe_crc = 0; } } - + /* don't CRC header when WEP in use */ if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED))) { crc = crc32_le(0xffffffff, (unsigned char *)&header, 24); } msdu_size -= 24; /* header */ - if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) { - + if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) { int more_fragments = frame_ctl & IEEE80211_FCTL_MOREFRAGS; u8 packet_fragment_no = seq_control & IEEE80211_SCTL_FRAG; u16 packet_sequence_no = (seq_control & IEEE80211_SCTL_SEQ) >> 4; - - if (!more_fragments && packet_fragment_no == 0 ) { + + if (!more_fragments && packet_fragment_no == 0) { fast_rx_path(priv, &header, msdu_size, rx_packet_loc, crc); } else { frag_rx_path(priv, &header, msdu_size, rx_packet_loc, crc, packet_sequence_no, packet_fragment_no, more_fragments); } } - + if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { /* copy rest of packet into buffer */ atmel_copy_to_host(priv->dev, (unsigned char *)&priv->rx_buf, rx_packet_loc + 24, msdu_size); - + /* we use the same buffer for frag reassembly and control packets */ memset(priv->frag_source, 0xff, 6); - + if (priv->do_rx_crc) { /* last 4 octets is crc */ msdu_size -= 4; @@ -1170,18 +1171,18 @@ static void rx_done_irq(struct atmel_private *priv) atmel_management_frame(priv, &header, msdu_size, atmel_rmem8(priv, atmel_rx(priv, RX_DESC_RSSI_OFFSET, priv->rx_desc_head))); - } + } - next: +next: /* release descriptor */ - atmel_wmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head), RX_DESC_FLAG_CONSUMED); - + atmel_wmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head), RX_DESC_FLAG_CONSUMED); + if (priv->rx_desc_head < (priv->host_info.rx_desc_count - 1)) - priv->rx_desc_head++; + priv->rx_desc_head++; else priv->rx_desc_head = 0; } -} +} static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs) { @@ -1189,7 +1190,7 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs struct atmel_private *priv = netdev_priv(dev); u8 isr; int i = -1; - static u8 irq_order[] = { + static u8 irq_order[] = { ISR_OUT_OF_RANGE, ISR_RxCOMPLETE, ISR_TxCOMPLETE, @@ -1199,20 +1200,19 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs ISR_IBSS_MERGE, ISR_GENERIC_IRQ }; - - if (priv->card && priv->present_callback && + if (priv->card && priv->present_callback && !(*priv->present_callback)(priv->card)) return IRQ_HANDLED; /* In this state upper-level code assumes it can mess with the card unhampered by interrupts which may change register state. Note that even though the card shouldn't generate interrupts - the inturrupt line may be shared. This allows card setup + the inturrupt line may be shared. This allows card setup to go on without disabling interrupts for a long time. */ if (priv->station_state == STATION_STATE_DOWN) return IRQ_NONE; - + atmel_clear_gcr(dev, GCR_ENINT); /* disable interrupts */ while (1) { @@ -1221,36 +1221,36 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs printk(KERN_ALERT "%s: failed to contact MAC.\n", dev->name); return IRQ_HANDLED; } - + isr = atmel_rmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET)); atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0); - + if (!isr) { atmel_set_gcr(dev, GCR_ENINT); /* enable interrupts */ return i == -1 ? IRQ_NONE : IRQ_HANDLED; } - + atmel_set_gcr(dev, GCR_ACKINT); /* acknowledge interrupt */ - + for (i = 0; i < sizeof(irq_order)/sizeof(u8); i++) if (isr & irq_order[i]) break; - + if (!atmel_lock_mac(priv)) { /* failed to contact card */ printk(KERN_ALERT "%s: failed to contact MAC.\n", dev->name); return IRQ_HANDLED; } - + isr = atmel_rmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET)); isr ^= irq_order[i]; atmel_wmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET), isr); atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0); - + switch (irq_order[i]) { - - case ISR_OUT_OF_RANGE: - if (priv->operating_mode == IW_MODE_INFRA && + + case ISR_OUT_OF_RANGE: + if (priv->operating_mode == IW_MODE_INFRA && priv->station_state == STATION_STATE_READY) { priv->station_is_associated = 0; atmel_scan(priv, 1); @@ -1261,24 +1261,24 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs priv->wstats.discard.misc++; /* fall through */ case ISR_RxCOMPLETE: - rx_done_irq(priv); + rx_done_irq(priv); break; - + case ISR_TxCOMPLETE: - tx_done_irq(priv); + tx_done_irq(priv); break; - + case ISR_FATAL_ERROR: printk(KERN_ALERT "%s: *** FATAL error interrupt ***\n", dev->name); atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); break; - - case ISR_COMMAND_COMPLETE: + + case ISR_COMMAND_COMPLETE: atmel_command_irq(priv); break; case ISR_IBSS_MERGE: - atmel_get_mib(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_BSSID_POS, + atmel_get_mib(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_BSSID_POS, priv->CurrentBSSID, 6); /* The WPA stuff cares about the current AP address */ if (priv->use_wpa) @@ -1288,24 +1288,23 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs printk(KERN_INFO "%s: Generic_irq received.\n", dev->name); break; } - } + } } - -static struct net_device_stats *atmel_get_stats (struct net_device *dev) +static struct net_device_stats *atmel_get_stats(struct net_device *dev) { struct atmel_private *priv = netdev_priv(dev); return &priv->stats; } -static struct iw_statistics *atmel_get_wireless_stats (struct net_device *dev) +static struct iw_statistics *atmel_get_wireless_stats(struct net_device *dev) { struct atmel_private *priv = netdev_priv(dev); - /* update the link quality here in case we are seeing no beacons + /* update the link quality here in case we are seeing no beacons at all to drive the process */ atmel_smooth_qual(priv); - + priv->wstats.status = priv->station_state; if (priv->operating_mode == IW_MODE_INFRA) { @@ -1328,8 +1327,8 @@ static struct iw_statistics *atmel_get_wireless_stats (struct net_device *dev) | IW_QUAL_NOISE_INVALID; priv->wstats.miss.beacon = 0; } - - return (&priv->wstats); + + return &priv->wstats; } static int atmel_change_mtu(struct net_device *dev, int new_mtu) @@ -1343,21 +1342,21 @@ static int atmel_change_mtu(struct net_device *dev, int new_mtu) static int atmel_set_mac_address(struct net_device *dev, void *p) { struct sockaddr *addr = p; - + memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); return atmel_open(dev); } EXPORT_SYMBOL(atmel_open); -int atmel_open (struct net_device *dev) +int atmel_open(struct net_device *dev) { struct atmel_private *priv = netdev_priv(dev); int i, channel; /* any scheduled timer is no longer needed and might screw things up.. */ del_timer_sync(&priv->management_timer); - + /* Interrupts will not touch the card once in this state... */ priv->station_state = STATION_STATE_DOWN; @@ -1377,7 +1376,7 @@ int atmel_open (struct net_device *dev) priv->site_survey_state = SITE_SURVEY_IDLE; priv->station_is_associated = 0; - if (!reset_atmel_card(dev)) + if (!reset_atmel_card(dev)) return -EAGAIN; if (priv->config_reg_domain) { @@ -1391,26 +1390,26 @@ int atmel_open (struct net_device *dev) if (i == sizeof(channel_table)/sizeof(channel_table[0])) { priv->reg_domain = REG_DOMAIN_MKK1; printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name); - } + } } - + if ((channel = atmel_validate_channel(priv, priv->channel))) priv->channel = channel; - /* this moves station_state on.... */ - atmel_scan(priv, 1); + /* this moves station_state on.... */ + atmel_scan(priv, 1); atmel_set_gcr(priv->dev, GCR_ENINT); /* enable interrupts */ return 0; } -static int atmel_close (struct net_device *dev) +static int atmel_close(struct net_device *dev) { struct atmel_private *priv = netdev_priv(dev); - + atmel_enter_state(priv, STATION_STATE_DOWN); - - if (priv->bus_type == BUS_TYPE_PCCARD) + + if (priv->bus_type == BUS_TYPE_PCCARD) atmel_write16(dev, GCR, 0x0060); atmel_write16(dev, GCR, 0x0040); return 0; @@ -1438,43 +1437,46 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv) int i; char *p = buf; char *s, *r, *c; - - p += sprintf(p, "Driver version:\t\t%d.%d\n", DRIVER_MAJOR, DRIVER_MINOR); - + + p += sprintf(p, "Driver version:\t\t%d.%d\n", + DRIVER_MAJOR, DRIVER_MINOR); + if (priv->station_state != STATION_STATE_DOWN) { - p += sprintf(p, "Firmware version:\t%d.%d build %d\nFirmware location:\t", + p += sprintf(p, "Firmware version:\t%d.%d build %d\n" + "Firmware location:\t", priv->host_info.major_version, priv->host_info.minor_version, priv->host_info.build_version); - - if (priv->card_type != CARD_TYPE_EEPROM) + + if (priv->card_type != CARD_TYPE_EEPROM) p += sprintf(p, "on card\n"); - else if (priv->firmware) - p += sprintf(p, "%s loaded by host\n", priv->firmware_id); + else if (priv->firmware) + p += sprintf(p, "%s loaded by host\n", + priv->firmware_id); else - p += sprintf(p, "%s loaded by hotplug\n", priv->firmware_id); - - switch(priv->card_type) { + p += sprintf(p, "%s loaded by hotplug\n", + priv->firmware_id); + + switch (priv->card_type) { case CARD_TYPE_PARALLEL_FLASH: c = "Parallel flash"; break; case CARD_TYPE_SPI_FLASH: c = "SPI flash\n"; break; case CARD_TYPE_EEPROM: c = "EEPROM"; break; default: c = ""; } - r = ""; for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) if (priv->reg_domain == channel_table[i].reg_domain) r = channel_table[i].name; - + p += sprintf(p, "MAC memory type:\t%s\n", c); p += sprintf(p, "Regulatory domain:\t%s\n", r); - p += sprintf(p, "Host CRC checking:\t%s\n", + p += sprintf(p, "Host CRC checking:\t%s\n", priv->do_rx_crc ? "On" : "Off"); p += sprintf(p, "WPA-capable firmware:\t%s\n", priv->use_wpa ? "Yes" : "No"); } - + switch(priv->station_state) { case STATION_STATE_SCANNING: s = "Scanning"; break; case STATION_STATE_JOINNING: s = "Joining"; break; @@ -1486,9 +1488,9 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv) case STATION_STATE_DOWN: s = "Down"; break; default: s = ""; } - + p += sprintf(p, "Current state:\t\t%s\n", s); - return p - buf; + return p - buf; } static int atmel_read_proc(char *page, char **start, off_t off, @@ -1504,8 +1506,10 @@ static int atmel_read_proc(char *page, char **start, off_t off, return len; } -struct net_device *init_atmel_card( unsigned short irq, unsigned long port, const AtmelFWType fw_type, - struct device *sys_dev, int (*card_present)(void *), void *card) +struct net_device *init_atmel_card(unsigned short irq, unsigned long port, + const AtmelFWType fw_type, + struct device *sys_dev, + int (*card_present)(void *), void *card) { struct net_device *dev; struct atmel_private *priv; @@ -1514,11 +1518,11 @@ struct net_device *init_atmel_card( unsigned short irq, unsigned long port, cons /* Create the network device object. */ dev = alloc_etherdev(sizeof(*priv)); if (!dev) { - printk(KERN_ERR "atmel: Couldn't alloc_etherdev\n"); + printk(KERN_ERR "atmel: Couldn't alloc_etherdev\n"); return NULL; } if (dev_alloc_name(dev, dev->name) < 0) { - printk(KERN_ERR "atmel: Couldn't get name!\n"); + printk(KERN_ERR "atmel: Couldn't get name!\n"); goto err_out_free; } @@ -1550,7 +1554,7 @@ struct net_device *init_atmel_card( unsigned short irq, unsigned long port, cons memset(priv->BSSID, 0, 6); priv->CurrentBSSID[0] = 0xFF; /* Initialize to something invalid.... */ priv->station_was_associated = 0; - + priv->last_survey = jiffies; priv->preamble = LONG_PREAMBLE; priv->operating_mode = IW_MODE_INFRA; @@ -1586,7 +1590,7 @@ struct net_device *init_atmel_card( unsigned short irq, unsigned long port, cons spin_lock_init(&priv->timerlock); priv->management_timer.function = atmel_management_timer; priv->management_timer.data = (unsigned long) dev; - + dev->open = atmel_open; dev->stop = atmel_close; dev->change_mtu = atmel_change_mtu; @@ -1597,44 +1601,44 @@ struct net_device *init_atmel_card( unsigned short irq, unsigned long port, cons dev->do_ioctl = atmel_ioctl; dev->irq = irq; dev->base_addr = port; - + SET_NETDEV_DEV(dev, sys_dev); - + if ((rc = request_irq(dev->irq, service_interrupt, SA_SHIRQ, dev->name, dev))) { - printk(KERN_ERR "%s: register interrupt %d failed, rc %d\n", dev->name, irq, rc ); + printk(KERN_ERR "%s: register interrupt %d failed, rc %d\n", dev->name, irq, rc); goto err_out_free; } - if (!request_region(dev->base_addr, 32, + if (!request_region(dev->base_addr, 32, priv->bus_type == BUS_TYPE_PCCARD ? "atmel_cs" : "atmel_pci")) { goto err_out_irq; } - + if (register_netdev(dev)) goto err_out_res; - + if (!probe_atmel_card(dev)){ unregister_netdev(dev); goto err_out_res; } - + netif_carrier_off(dev); - - create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); - + + create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); + printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", dev->name, DRIVER_MAJOR, DRIVER_MINOR, dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] ); - + SET_MODULE_OWNER(dev); return dev; - - err_out_res: + +err_out_res: release_region( dev->base_addr, 32); - err_out_irq: +err_out_irq: free_irq(dev->irq, dev); - err_out_free: +err_out_free: free_netdev(dev); return NULL; } @@ -1644,12 +1648,12 @@ EXPORT_SYMBOL(init_atmel_card); void stop_atmel_card(struct net_device *dev) { struct atmel_private *priv = netdev_priv(dev); - + /* put a brick on it... */ - if (priv->bus_type == BUS_TYPE_PCCARD) + if (priv->bus_type == BUS_TYPE_PCCARD) atmel_write16(dev, GCR, 0x0060); atmel_write16(dev, GCR, 0x0040); - + del_timer_sync(&priv->management_timer); unregister_netdev(dev); remove_proc_entry("driver/atmel", NULL); @@ -1675,13 +1679,13 @@ static int atmel_set_essid(struct net_device *dev, int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; priv->connect_to_any_BSS = 0; - + /* Check the size of the string */ if (dwrq->length > MAX_SSID_LENGTH + 1) - return -E2BIG ; + return -E2BIG; if (index != 0) return -EINVAL; - + memcpy(priv->new_SSID, extra, dwrq->length - 1); priv->new_SSID_size = dwrq->length - 1; } @@ -1706,7 +1710,7 @@ static int atmel_get_essid(struct net_device *dev, extra[priv->SSID_size] = '\0'; dwrq->length = priv->SSID_size + 1; } - + dwrq->flags = !priv->connect_to_any_BSS; /* active */ return 0; @@ -1768,7 +1772,7 @@ static int atmel_set_encode(struct net_device *dev, /* WE specify that if a valid key is set, encryption * should be enabled (user may turn it off later) * This is also how "iwconfig ethX key on" works */ - if (index == current_index && + if (index == current_index && priv->wep_key_len[index] > 0) { priv->wep_is_on = 1; priv->exclude_unencrypted = 1; @@ -1783,18 +1787,18 @@ static int atmel_set_encode(struct net_device *dev, } else { /* Do we want to just set the transmit key index ? */ int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; - if ( index>=0 && index < 4 ) { + if (index >= 0 && index < 4) { priv->default_key = index; } else /* Don't complain if only change the mode */ - if(!dwrq->flags & IW_ENCODE_MODE) { + if (!dwrq->flags & IW_ENCODE_MODE) { return -EINVAL; } } /* Read the flags */ - if(dwrq->flags & IW_ENCODE_DISABLED) { + if (dwrq->flags & IW_ENCODE_DISABLED) { priv->wep_is_on = 0; - priv->encryption_level = 0; + priv->encryption_level = 0; priv->pairwise_cipher_suite = CIPHER_SUITE_NONE; } else { priv->wep_is_on = 1; @@ -1806,15 +1810,14 @@ static int atmel_set_encode(struct net_device *dev, priv->encryption_level = 1; } } - if(dwrq->flags & IW_ENCODE_RESTRICTED) + if (dwrq->flags & IW_ENCODE_RESTRICTED) priv->exclude_unencrypted = 1; - if(dwrq->flags & IW_ENCODE_OPEN) + if(dwrq->flags & IW_ENCODE_OPEN) priv->exclude_unencrypted = 0; - + return -EINPROGRESS; /* Call commit handler */ } - static int atmel_get_encode(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, @@ -1822,7 +1825,7 @@ static int atmel_get_encode(struct net_device *dev, { struct atmel_private *priv = netdev_priv(dev); int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; - + if (!priv->wep_is_on) dwrq->flags = IW_ENCODE_DISABLED; else { @@ -1843,7 +1846,7 @@ static int atmel_get_encode(struct net_device *dev, memset(extra, 0, 16); memcpy(extra, priv->wep_keys[index], dwrq->length); } - + return 0; } @@ -1862,17 +1865,17 @@ static int atmel_set_rate(struct net_device *dev, char *extra) { struct atmel_private *priv = netdev_priv(dev); - + if (vwrq->fixed == 0) { priv->tx_rate = 3; priv->auto_tx_rate = 1; } else { priv->auto_tx_rate = 0; - + /* Which type of value ? */ - if((vwrq->value < 4) && (vwrq->value >= 0)) { + if ((vwrq->value < 4) && (vwrq->value >= 0)) { /* Setting by rate index */ - priv->tx_rate = vwrq->value; + priv->tx_rate = vwrq->value; } else { /* Setting by frequency value */ switch (vwrq->value) { @@ -1899,7 +1902,7 @@ static int atmel_set_mode(struct net_device *dev, return -EINVAL; priv->operating_mode = *uwrq; - return -EINPROGRESS; + return -EINPROGRESS; } static int atmel_get_mode(struct net_device *dev, @@ -1908,7 +1911,7 @@ static int atmel_get_mode(struct net_device *dev, char *extra) { struct atmel_private *priv = netdev_priv(dev); - + *uwrq = priv->operating_mode; return 0; } @@ -1962,9 +1965,9 @@ static int atmel_set_retry(struct net_device *dev, char *extra) { struct atmel_private *priv = netdev_priv(dev); - - if(!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) { - if(vwrq->flags & IW_RETRY_MAX) + + if (!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) { + if (vwrq->flags & IW_RETRY_MAX) priv->long_retry = vwrq->value; else if (vwrq->flags & IW_RETRY_MIN) priv->short_retry = vwrq->value; @@ -1973,9 +1976,9 @@ static int atmel_set_retry(struct net_device *dev, priv->long_retry = vwrq->value; priv->short_retry = vwrq->value; } - return -EINPROGRESS; + return -EINPROGRESS; } - + return -EINVAL; } @@ -1989,13 +1992,13 @@ static int atmel_get_retry(struct net_device *dev, vwrq->disabled = 0; /* Can't be disabled */ /* Note : by default, display the min retry number */ - if((vwrq->flags & IW_RETRY_MAX)) { + if (vwrq->flags & IW_RETRY_MAX) { vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; vwrq->value = priv->long_retry; } else { vwrq->flags = IW_RETRY_LIMIT; vwrq->value = priv->short_retry; - if(priv->long_retry != priv->short_retry) + if (priv->long_retry != priv->short_retry) vwrq->flags |= IW_RETRY_MIN; } @@ -2010,13 +2013,13 @@ static int atmel_set_rts(struct net_device *dev, struct atmel_private *priv = netdev_priv(dev); int rthr = vwrq->value; - if(vwrq->disabled) + if (vwrq->disabled) rthr = 2347; - if((rthr < 0) || (rthr > 2347)) { + if ((rthr < 0) || (rthr > 2347)) { return -EINVAL; } priv->rts_threshold = rthr; - + return -EINPROGRESS; /* Call commit handler */ } @@ -2026,7 +2029,7 @@ static int atmel_get_rts(struct net_device *dev, char *extra) { struct atmel_private *priv = netdev_priv(dev); - + vwrq->value = priv->rts_threshold; vwrq->disabled = (vwrq->value >= 2347); vwrq->fixed = 1; @@ -2042,14 +2045,14 @@ static int atmel_set_frag(struct net_device *dev, struct atmel_private *priv = netdev_priv(dev); int fthr = vwrq->value; - if(vwrq->disabled) + if (vwrq->disabled) fthr = 2346; - if((fthr < 256) || (fthr > 2346)) { + if ((fthr < 256) || (fthr > 2346)) { return -EINVAL; } fthr &= ~0x1; /* Get an even value - is it really needed ??? */ priv->frag_threshold = fthr; - + return -EINPROGRESS; /* Call commit handler */ } @@ -2077,21 +2080,21 @@ static int atmel_set_freq(struct net_device *dev, { struct atmel_private *priv = netdev_priv(dev); int rc = -EINPROGRESS; /* Call commit handler */ - + /* If setting by frequency, convert to a channel */ - if((fwrq->e == 1) && - (fwrq->m >= (int) 241200000) && - (fwrq->m <= (int) 248700000)) { + if ((fwrq->e == 1) && + (fwrq->m >= (int) 241200000) && + (fwrq->m <= (int) 248700000)) { int f = fwrq->m / 100000; int c = 0; - while((c < 14) && (f != frequency_list[c])) + while ((c < 14) && (f != frequency_list[c])) c++; /* Hack to fall through... */ fwrq->e = 0; fwrq->m = c + 1; } /* Setting by channel number */ - if((fwrq->m > 1000) || (fwrq->e > 0)) + if ((fwrq->m > 1000) || (fwrq->e > 0)) rc = -EOPNOTSUPP; else { int channel = fwrq->m; @@ -2099,7 +2102,7 @@ static int atmel_set_freq(struct net_device *dev, priv->channel = channel; } else { rc = -EINVAL; - } + } } return rc; } @@ -2130,7 +2133,7 @@ static int atmel_set_scan(struct net_device *dev, * This is not an error, while the device perform scanning, * traffic doesn't flow, so it's a perfect DoS... * Jean II */ - + if (priv->station_state == STATION_STATE_DOWN) return -EAGAIN; @@ -2142,15 +2145,15 @@ static int atmel_set_scan(struct net_device *dev, /* Initiate a scan command */ if (priv->site_survey_state == SITE_SURVEY_IN_PROGRESS) return -EBUSY; - + del_timer_sync(&priv->management_timer); spin_lock_irqsave(&priv->irqlock, flags); - + priv->site_survey_state = SITE_SURVEY_IN_PROGRESS; priv->fast_scan = 0; atmel_scan(priv, 0); spin_unlock_irqrestore(&priv->irqlock, flags); - + return 0; } @@ -2163,11 +2166,11 @@ static int atmel_get_scan(struct net_device *dev, int i; char *current_ev = extra; struct iw_event iwe; - + if (priv->site_survey_state != SITE_SURVEY_COMPLETED) return -EAGAIN; - - for(i=0; iBSS_list_entries; i++) { + + for (i = 0; i < priv->BSS_list_entries; i++) { iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, priv->BSSinfo[i].BSSID, 6); @@ -2179,16 +2182,16 @@ static int atmel_get_scan(struct net_device *dev, iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, priv->BSSinfo[i].SSID); - + iwe.cmd = SIOCGIWMODE; iwe.u.mode = priv->BSSinfo[i].BSStype; current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_UINT_LEN); - + iwe.cmd = SIOCGIWFREQ; iwe.u.freq.m = priv->BSSinfo[i].channel; iwe.u.freq.e = 0; current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN); - + iwe.cmd = SIOCGIWENCODE; if (priv->BSSinfo[i].UsingWEP) iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; @@ -2196,13 +2199,12 @@ static int atmel_get_scan(struct net_device *dev, iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, NULL); - } /* Length of data */ dwrq->length = (current_ev - extra); - dwrq->flags = 0; - + dwrq->flags = 0; + return 0; } @@ -2213,7 +2215,7 @@ static int atmel_get_range(struct net_device *dev, { struct atmel_private *priv = netdev_priv(dev); struct iw_range *range = (struct iw_range *) extra; - int k,i,j; + int k, i, j; dwrq->length = sizeof(struct iw_range); memset(range, 0, sizeof(struct iw_range)); @@ -2226,14 +2228,14 @@ static int atmel_get_range(struct net_device *dev, break; } if (range->num_channels != 0) { - for(k = 0, i = channel_table[j].min; i <= channel_table[j].max; i++) { + for (k = 0, i = channel_table[j].min; i <= channel_table[j].max; i++) { range->freq[k].i = i; /* List index */ - range->freq[k].m = frequency_list[i-1] * 100000; + range->freq[k].m = frequency_list[i - 1] * 100000; range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ } range->num_frequency = k; } - + range->max_qual.qual = 100; range->max_qual.level = 100; range->max_qual.noise = 0; @@ -2261,11 +2263,11 @@ static int atmel_get_range(struct net_device *dev, range->encoding_size[1] = 13; range->num_encoding_sizes = 2; range->max_encoding_tokens = 4; - + range->pmp_flags = IW_POWER_ON; range->pmt_flags = IW_POWER_ON; range->pm_capa = 0; - + range->we_version_source = WIRELESS_EXT; range->we_version_compiled = WIRELESS_EXT; range->retry_capa = IW_RETRY_LIMIT ; @@ -2289,7 +2291,7 @@ static int atmel_set_wap(struct net_device *dev, if (awrq->sa_family != ARPHRD_ETHER) return -EINVAL; - + if (memcmp(bcast, awrq->sa_data, 6) == 0) { del_timer_sync(&priv->management_timer); spin_lock_irqsave(&priv->irqlock, flags); @@ -2297,8 +2299,8 @@ static int atmel_set_wap(struct net_device *dev, spin_unlock_irqrestore(&priv->irqlock, flags); return 0; } - - for(i=0; iBSS_list_entries; i++) { + + for (i = 0; i < priv->BSS_list_entries; i++) { if (memcmp(priv->BSSinfo[i].BSSID, awrq->sa_data, 6) == 0) { if (!priv->wep_is_on && priv->BSSinfo[i].UsingWEP) { return -EINVAL; @@ -2313,10 +2315,10 @@ static int atmel_set_wap(struct net_device *dev, } } } - + return -EINVAL; } - + static int atmel_config_commit(struct net_device *dev, struct iw_request_info *info, /* NULL */ void *zwrq, /* NULL */ @@ -2325,18 +2327,18 @@ static int atmel_config_commit(struct net_device *dev, return atmel_open(dev); } -static const iw_handler atmel_handler[] = +static const iw_handler atmel_handler[] = { (iw_handler) atmel_config_commit, /* SIOCSIWCOMMIT */ - (iw_handler) atmel_get_name, /* SIOCGIWNAME */ + (iw_handler) atmel_get_name, /* SIOCGIWNAME */ (iw_handler) NULL, /* SIOCSIWNWID */ (iw_handler) NULL, /* SIOCGIWNWID */ (iw_handler) atmel_set_freq, /* SIOCSIWFREQ */ (iw_handler) atmel_get_freq, /* SIOCGIWFREQ */ (iw_handler) atmel_set_mode, /* SIOCSIWMODE */ (iw_handler) atmel_get_mode, /* SIOCGIWMODE */ - (iw_handler) NULL, /* SIOCSIWSENS */ - (iw_handler) NULL, /* SIOCGIWSENS */ + (iw_handler) NULL, /* SIOCSIWSENS */ + (iw_handler) NULL, /* SIOCGIWSENS */ (iw_handler) NULL, /* SIOCSIWRANGE */ (iw_handler) atmel_get_range, /* SIOCGIWRANGE */ (iw_handler) NULL, /* SIOCSIWPRIV */ @@ -2350,13 +2352,13 @@ static const iw_handler atmel_handler[] = (iw_handler) atmel_set_wap, /* SIOCSIWAP */ (iw_handler) atmel_get_wap, /* SIOCGIWAP */ (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCGIWAPLIST */ + (iw_handler) NULL, /* SIOCGIWAPLIST */ (iw_handler) atmel_set_scan, /* SIOCSIWSCAN */ (iw_handler) atmel_get_scan, /* SIOCGIWSCAN */ (iw_handler) atmel_set_essid, /* SIOCSIWESSID */ (iw_handler) atmel_get_essid, /* SIOCGIWESSID */ - (iw_handler) NULL, /* SIOCSIWNICKN */ - (iw_handler) NULL, /* SIOCGIWNICKN */ + (iw_handler) NULL, /* SIOCSIWNICKN */ + (iw_handler) NULL, /* SIOCGIWNICKN */ (iw_handler) NULL, /* -- hole -- */ (iw_handler) NULL, /* -- hole -- */ (iw_handler) atmel_set_rate, /* SIOCSIWRATE */ @@ -2365,8 +2367,8 @@ static const iw_handler atmel_handler[] = (iw_handler) atmel_get_rts, /* SIOCGIWRTS */ (iw_handler) atmel_set_frag, /* SIOCSIWFRAG */ (iw_handler) atmel_get_frag, /* SIOCGIWFRAG */ - (iw_handler) NULL, /* SIOCSIWTXPOW */ - (iw_handler) NULL, /* SIOCGIWTXPOW */ + (iw_handler) NULL, /* SIOCSIWTXPOW */ + (iw_handler) NULL, /* SIOCGIWTXPOW */ (iw_handler) atmel_set_retry, /* SIOCSIWRETRY */ (iw_handler) atmel_get_retry, /* SIOCGIWRETRY */ (iw_handler) atmel_set_encode, /* SIOCSIWENCODE */ @@ -2375,39 +2377,51 @@ static const iw_handler atmel_handler[] = (iw_handler) atmel_get_power, /* SIOCGIWPOWER */ }; - -static const iw_handler atmel_private_handler[] = +static const iw_handler atmel_private_handler[] = { NULL, /* SIOCIWFIRSTPRIV */ }; typedef struct atmel_priv_ioctl { char id[32]; - unsigned char __user *data; - unsigned short len; + unsigned char __user *data; + unsigned short len; } atmel_priv_ioctl; - -#define ATMELFWL SIOCIWFIRSTPRIV -#define ATMELIDIFC ATMELFWL + 1 -#define ATMELRD ATMELFWL + 2 -#define ATMELMAGIC 0x51807 +#define ATMELFWL SIOCIWFIRSTPRIV +#define ATMELIDIFC ATMELFWL + 1 +#define ATMELRD ATMELFWL + 2 +#define ATMELMAGIC 0x51807 #define REGDOMAINSZ 20 static const struct iw_priv_args atmel_private_args[] = { -/*{ cmd, set_args, get_args, name } */ - { ATMELFWL, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof (atmel_priv_ioctl), IW_PRIV_TYPE_NONE, "atmelfwl" }, - { ATMELIDIFC, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "atmelidifc" }, - { ATMELRD, IW_PRIV_TYPE_CHAR | REGDOMAINSZ, IW_PRIV_TYPE_NONE, "regdomain" }, + { + .cmd = ATMELFWL, + .set_args = IW_PRIV_TYPE_BYTE + | IW_PRIV_SIZE_FIXED + | sizeof (atmel_priv_ioctl), + .get_args = IW_PRIV_TYPE_NONE, + .name = "atmelfwl" + }, { + .cmd = ATMELIDIFC, + .set_args = IW_PRIV_TYPE_NONE, + .get_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + .name = "atmelidifc" + }, { + .cmd = ATMELRD, + .set_args = IW_PRIV_TYPE_CHAR | REGDOMAINSZ, + .get_args = IW_PRIV_TYPE_NONE, + .name = "regdomain" + }, }; -static const struct iw_handler_def atmel_handler_def = +static const struct iw_handler_def atmel_handler_def = { .num_standard = sizeof(atmel_handler)/sizeof(iw_handler), - .num_private = sizeof(atmel_private_handler)/sizeof(iw_handler), - .num_private_args = sizeof(atmel_private_args)/sizeof(struct iw_priv_args), + .num_private = sizeof(atmel_private_handler)/sizeof(iw_handler), + .num_private_args = sizeof(atmel_private_args)/sizeof(struct iw_priv_args), .standard = (iw_handler *) atmel_handler, - .private = (iw_handler *) atmel_private_handler, + .private = (iw_handler *) atmel_private_handler, .private_args = (struct iw_priv_args *) atmel_private_args, .get_wireless_stats = atmel_get_wireless_stats }; @@ -2419,13 +2433,13 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) atmel_priv_ioctl com; struct iwreq *wrq = (struct iwreq *) rq; unsigned char *new_firmware; - char domain[REGDOMAINSZ+1]; + char domain[REGDOMAINSZ + 1]; switch (cmd) { case ATMELIDIFC: - wrq->u.param.value = ATMELMAGIC; + wrq->u.param.value = ATMELMAGIC; break; - + case ATMELFWL: if (copy_from_user(&com, rq->ifr_data, sizeof(com))) { rc = -EFAULT; @@ -2449,7 +2463,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } kfree(priv->firmware); - + priv->firmware = new_firmware; priv->firmware_length = com.len; strncpy(priv->firmware_id, com.id, 31); @@ -2461,7 +2475,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) rc = -EFAULT; break; } - + if (!capable(CAP_NET_ADMIN)) { rc = -EPERM; break; @@ -2484,15 +2498,15 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) rc = 0; } } - + if (rc == 0 && priv->station_state != STATION_STATE_DOWN) rc = atmel_open(dev); break; - + default: rc = -EOPNOTSUPP; } - + return rc; } @@ -2503,17 +2517,17 @@ struct auth_body { u8 el_id; u8 chall_text_len; u8 chall_text[253]; -}; +}; static void atmel_enter_state(struct atmel_private *priv, int new_state) { int old_state = priv->station_state; - + if (new_state == old_state) return; - + priv->station_state = new_state; - + if (new_state == STATION_STATE_READY) { netif_start_queue(priv->dev); netif_carrier_on(priv->dev); @@ -2540,7 +2554,7 @@ static void atmel_scan(struct atmel_private *priv, int specific_ssid) u8 options; u8 SSID_size; } cmd; - + memset(cmd.BSSID, 0xff, 6); if (priv->fast_scan) { @@ -2554,17 +2568,17 @@ static void atmel_scan(struct atmel_private *priv, int specific_ssid) cmd.min_channel_time = cpu_to_le16(10); cmd.max_channel_time = cpu_to_le16(120); } - + cmd.options = 0; - + if (!specific_ssid) cmd.options |= SCAN_OPTIONS_SITE_SURVEY; - - cmd.channel = (priv->channel & 0x7f); + + cmd.channel = (priv->channel & 0x7f); cmd.scan_type = SCAN_TYPE_ACTIVE; - cmd.BSS_type = cpu_to_le16(priv->operating_mode == IW_MODE_ADHOC ? + cmd.BSS_type = cpu_to_le16(priv->operating_mode == IW_MODE_ADHOC ? BSS_TYPE_AD_HOC : BSS_TYPE_INFRASTRUCTURE); - + atmel_send_command(priv, CMD_Scan, &cmd, sizeof(cmd)); /* This must come after all hardware access to avoid being messed up @@ -2591,16 +2605,15 @@ static void join(struct atmel_private *priv, int type) cmd.BSS_type = type; cmd.timeout = cpu_to_le16(2000); - atmel_send_command(priv, CMD_Join, &cmd, sizeof(cmd)); + atmel_send_command(priv, CMD_Join, &cmd, sizeof(cmd)); } - static void start(struct atmel_private *priv, int type) { struct { u8 BSSID[6]; u8 SSID[MAX_SSID_LENGTH]; - u8 BSS_type; + u8 BSS_type; u8 channel; u8 SSID_size; u8 reserved[3]; @@ -2612,13 +2625,14 @@ static void start(struct atmel_private *priv, int type) cmd.BSS_type = type; cmd.channel = (priv->channel & 0x7f); - atmel_send_command(priv, CMD_Start, &cmd, sizeof(cmd)); + atmel_send_command(priv, CMD_Start, &cmd, sizeof(cmd)); } -static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 channel) +static void handle_beacon_probe(struct atmel_private *priv, u16 capability, + u8 channel) { int rejoin = 0; - int new = capability & C80211_MGMT_CAPABILITY_ShortPreamble ? + int new = capability & C80211_MGMT_CAPABILITY_ShortPreamble ? SHORT_PREAMBLE : LONG_PREAMBLE; if (priv->preamble != new) { @@ -2626,48 +2640,48 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 c rejoin = 1; atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, new); } - + if (priv->channel != channel) { priv->channel = channel; rejoin = 1; atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_CHANNEL_POS, channel); } - + if (rejoin) { priv->station_is_associated = 0; atmel_enter_state(priv, STATION_STATE_JOINNING); - + if (priv->operating_mode == IW_MODE_INFRA) join(priv, BSS_TYPE_INFRASTRUCTURE); - else + else join(priv, BSS_TYPE_AD_HOC); - } + } } - -static void send_authentication_request(struct atmel_private *priv, u16 system, u8 *challenge, int challenge_len) +static void send_authentication_request(struct atmel_private *priv, u16 system, + u8 *challenge, int challenge_len) { struct ieee80211_hdr_4addr header; struct auth_body auth; - - header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); - header.duration_id = cpu_to_le16(0x8000); + + header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); + header.duration_id = cpu_to_le16(0x8000); header.seq_ctl = 0; memcpy(header.addr1, priv->CurrentBSSID, 6); memcpy(header.addr2, priv->dev->dev_addr, 6); memcpy(header.addr3, priv->CurrentBSSID, 6); - - if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1) + + if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1) /* no WEP for authentication frames with TrSeqNo 1 */ header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); - - auth.alg = cpu_to_le16(system); + + auth.alg = cpu_to_le16(system); auth.status = 0; auth.trans_seq = cpu_to_le16(priv->CurrentAuthentTransactionSeqNum); - priv->ExpectedAuthentTransactionSeqNum = priv->CurrentAuthentTransactionSeqNum+1; + priv->ExpectedAuthentTransactionSeqNum = priv->CurrentAuthentTransactionSeqNum+1; priv->CurrentAuthentTransactionSeqNum += 2; - + if (challenge_len != 0) { auth.el_id = 16; /* challenge_text */ auth.chall_text_len = challenge_len; @@ -2685,7 +2699,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc) struct ieee80211_hdr_4addr header; struct ass_req_format { u16 capability; - u16 listen_interval; + u16 listen_interval; u8 ap[6]; /* nothing after here directly accessible */ u8 ssid_el_id; u8 ssid_len; @@ -2694,15 +2708,15 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc) u8 sup_rates_len; u8 rates[4]; } body; - - header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | + + header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | (is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ)); header.duration_id = cpu_to_le16(0x8000); header.seq_ctl = 0; - memcpy(header.addr1, priv->CurrentBSSID, 6); + memcpy(header.addr1, priv->CurrentBSSID, 6); memcpy(header.addr2, priv->dev->dev_addr, 6); - memcpy(header.addr3, priv->CurrentBSSID, 6); + memcpy(header.addr3, priv->CurrentBSSID, 6); body.capability = cpu_to_le16(C80211_MGMT_CAPABILITY_ESS); if (priv->wep_is_on) @@ -2711,18 +2725,18 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc) body.capability |= cpu_to_le16(C80211_MGMT_CAPABILITY_ShortPreamble); body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period); - + /* current AP address - only in reassoc frame */ if (is_reassoc) { - memcpy(body.ap, priv->CurrentBSSID, 6); + memcpy(body.ap, priv->CurrentBSSID, 6); ssid_el_p = (u8 *)&body.ssid_el_id; bodysize = 18 + priv->SSID_size; } else { ssid_el_p = (u8 *)&body.ap[0]; bodysize = 12 + priv->SSID_size; } - - ssid_el_p[0]= C80211_MGMT_ElementID_SSID; + + ssid_el_p[0] = C80211_MGMT_ElementID_SSID; ssid_el_p[1] = priv->SSID_size; memcpy(ssid_el_p + 2, priv->SSID, priv->SSID_size); ssid_el_p[2 + priv->SSID_size] = C80211_MGMT_ElementID_SupportedRates; @@ -2732,7 +2746,8 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc) atmel_transmit_management_frame(priv, &header, (void *)&body, bodysize); } -static int is_frame_from_current_bss(struct atmel_private *priv, struct ieee80211_hdr_4addr *header) +static int is_frame_from_current_bss(struct atmel_private *priv, + struct ieee80211_hdr_4addr *header) { if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0; @@ -2745,29 +2760,29 @@ static int retrieve_bss(struct atmel_private *priv) int i; int max_rssi = -128; int max_index = -1; - + if (priv->BSS_list_entries == 0) return -1; - + if (priv->connect_to_any_BSS) { - /* Select a BSS with the max-RSSI but of the same type and of the same WEP mode - and that it is not marked as 'bad' (i.e. we had previously failed to connect to - this BSS with the settings that we currently use) */ + /* Select a BSS with the max-RSSI but of the same type and of + the same WEP mode and that it is not marked as 'bad' (i.e. + we had previously failed to connect to this BSS with the + settings that we currently use) */ priv->current_BSS = 0; - for(i=0; iBSS_list_entries; i++) { + for (i = 0; i < priv->BSS_list_entries; i++) { if (priv->operating_mode == priv->BSSinfo[i].BSStype && - ((!priv->wep_is_on && !priv->BSSinfo[i].UsingWEP) || + ((!priv->wep_is_on && !priv->BSSinfo[i].UsingWEP) || (priv->wep_is_on && priv->BSSinfo[i].UsingWEP)) && !(priv->BSSinfo[i].channel & 0x80)) { max_rssi = priv->BSSinfo[i].RSSI; priv->current_BSS = max_index = i; } - } return max_index; } - - for(i=0; iBSS_list_entries; i++) { + + for (i = 0; i < priv->BSS_list_entries; i++) { if (priv->SSID_size == priv->BSSinfo[i].SSIDsize && memcmp(priv->SSID, priv->BSSinfo[i].SSID, priv->SSID_size) == 0 && priv->operating_mode == priv->BSSinfo[i].BSStype && @@ -2781,19 +2796,19 @@ static int retrieve_bss(struct atmel_private *priv) return max_index; } - -static void store_bss_info(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, - u16 capability, u16 beacon_period, u8 channel, u8 rssi, - u8 ssid_len, u8 *ssid, int is_beacon) +static void store_bss_info(struct atmel_private *priv, + struct ieee80211_hdr_4addr *header, u16 capability, + u16 beacon_period, u8 channel, u8 rssi, u8 ssid_len, + u8 *ssid, int is_beacon) { u8 *bss = capability & C80211_MGMT_CAPABILITY_ESS ? header->addr2 : header->addr3; int i, index; - - for (index = -1, i = 0; i < priv->BSS_list_entries; i++) - if (memcmp(bss, priv->BSSinfo[i].BSSID, 6) == 0) + + for (index = -1, i = 0; i < priv->BSS_list_entries; i++) + if (memcmp(bss, priv->BSSinfo[i].BSSID, 6) == 0) index = i; - /* If we process a probe and an entry from this BSS exists + /* If we process a probe and an entry from this BSS exists we will update the BSS entry with the info from this BSS. If we process a beacon we will only update RSSI */ @@ -2820,8 +2835,8 @@ static void store_bss_info(struct atmel_private *priv, struct ieee80211_hdr_4add priv->BSSinfo[index].BSStype = IW_MODE_ADHOC; else if (capability & C80211_MGMT_CAPABILITY_ESS) priv->BSSinfo[index].BSStype =IW_MODE_INFRA; - - priv->BSSinfo[index].preamble = capability & C80211_MGMT_CAPABILITY_ShortPreamble ? + + priv->BSSinfo[index].preamble = capability & C80211_MGMT_CAPABILITY_ShortPreamble ? SHORT_PREAMBLE : LONG_PREAMBLE; } @@ -2831,8 +2846,8 @@ static void authenticate(struct atmel_private *priv, u16 frame_len) u16 status = le16_to_cpu(auth->status); u16 trans_seq_no = le16_to_cpu(auth->trans_seq); u16 system = le16_to_cpu(auth->alg); - - if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) { + + if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) { /* no WEP */ if (priv->station_was_associated) { atmel_enter_state(priv, STATION_STATE_REASSOCIATING); @@ -2842,20 +2857,20 @@ static void authenticate(struct atmel_private *priv, u16 frame_len) atmel_enter_state(priv, STATION_STATE_ASSOCIATING); send_association_request(priv, 0); return; - } + } } - - if (status == C80211_MGMT_SC_Success && priv->wep_is_on) { + + if (status == C80211_MGMT_SC_Success && priv->wep_is_on) { /* WEP */ if (trans_seq_no != priv->ExpectedAuthentTransactionSeqNum) return; - + if (trans_seq_no == 0x0002 && auth->el_id == C80211_MGMT_ElementID_ChallengeText) { send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len); return; } - + if (trans_seq_no == 0x0004) { if(priv->station_was_associated) { atmel_enter_state(priv, STATION_STATE_REASSOCIATING); @@ -2865,10 +2880,10 @@ static void authenticate(struct atmel_private *priv, u16 frame_len) atmel_enter_state(priv, STATION_STATE_ASSOCIATING); send_association_request(priv, 0); return; - } + } } - } - + } + if (status == C80211_MGMT_SC_AuthAlgNotSupported) { /* Do opensystem first, then try sharedkey */ if (system == C80211_MGMT_AAN_OPENSYSTEM) { @@ -2876,17 +2891,16 @@ static void authenticate(struct atmel_private *priv, u16 frame_len) send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0); } else if (priv->connect_to_any_BSS) { int bss_index; - + priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; - + if ((bss_index = retrieve_bss(priv)) != -1) { atmel_join_bss(priv, bss_index); return; } } } - - + priv->AuthenticationRequestRetryCnt = 0; atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); priv->station_is_associated = 0; @@ -2902,38 +2916,44 @@ static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype) u8 length; u8 rates[4]; } *ass_resp = (struct ass_resp_format *)priv->rx_buf; - - u16 status = le16_to_cpu(ass_resp->status); + + u16 status = le16_to_cpu(ass_resp->status); u16 ass_id = le16_to_cpu(ass_resp->ass_id); - u16 rates_len = ass_resp->length > 4 ? 4 : ass_resp->length; - + u16 rates_len = ass_resp->length > 4 ? 4 : ass_resp->length; + if (frame_len < 8 + rates_len) return; - + if (status == C80211_MGMT_SC_Success) { if (subtype == C80211_SUBTYPE_MGMT_ASS_RESPONSE) priv->AssociationRequestRetryCnt = 0; else priv->ReAssociationRequestRetryCnt = 0; - - atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_STATION_ID_POS, ass_id & 0x3fff); - atmel_set_mib(priv, Phy_Mib_Type, PHY_MIB_RATE_SET_POS, ass_resp->rates, rates_len); + + atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, + MAC_MGMT_MIB_STATION_ID_POS, ass_id & 0x3fff); + atmel_set_mib(priv, Phy_Mib_Type, + PHY_MIB_RATE_SET_POS, ass_resp->rates, rates_len); if (priv->power_mode == 0) { priv->listen_interval = 1; - atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE); - atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1); + atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, + MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE); + atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, + MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1); } else { priv->listen_interval = 2; - atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, PS_MODE); - atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 2); + atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, + MAC_MGMT_MIB_PS_MODE_POS, PS_MODE); + atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, + MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 2); } - + priv->station_is_associated = 1; priv->station_was_associated = 1; atmel_enter_state(priv, STATION_STATE_READY); return; } - + if (subtype == C80211_SUBTYPE_MGMT_ASS_RESPONSE && status != C80211_MGMT_SC_AssDeniedBSSRate && status != C80211_MGMT_SC_SupportCapabilities && @@ -2943,7 +2963,7 @@ static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype) send_association_request(priv, 0); return; } - + if (subtype == C80211_SUBTYPE_MGMT_REASS_RESPONSE && status != C80211_MGMT_SC_AssDeniedBSSRate && status != C80211_MGMT_SC_SupportCapabilities && @@ -2953,17 +2973,16 @@ static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype) send_association_request(priv, 1); return; } - + atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); priv->station_is_associated = 0; - - if(priv->connect_to_any_BSS) { + + if (priv->connect_to_any_BSS) { int bss_index; priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; - - if ((bss_index = retrieve_bss(priv)) != -1) + + if ((bss_index = retrieve_bss(priv)) != -1) atmel_join_bss(priv, bss_index); - } } @@ -2977,7 +2996,7 @@ void atmel_join_bss(struct atmel_private *priv, int bss_index) /* The WPA stuff cares about the current AP address */ if (priv->use_wpa) build_wpa_mib(priv); - + /* When switching to AdHoc turn OFF Power Save if needed */ if (bss->BSStype == IW_MODE_ADHOC && @@ -2985,25 +3004,28 @@ void atmel_join_bss(struct atmel_private *priv, int bss_index) priv->power_mode) { priv->power_mode = 0; priv->listen_interval = 1; - atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE); - atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1); + atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, + MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE); + atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, + MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1); } - + priv->operating_mode = bss->BSStype; - priv->channel = bss->channel & 0x7f; + priv->channel = bss->channel & 0x7f; priv->beacon_period = bss->beacon_period; - + if (priv->preamble != bss->preamble) { priv->preamble = bss->preamble; - atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, bss->preamble); + atmel_set_mib8(priv, Local_Mib_Type, + LOCAL_MIB_PREAMBLE_TYPE, bss->preamble); } - + if (!priv->wep_is_on && bss->UsingWEP) { atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); priv->station_is_associated = 0; return; } - + if (priv->wep_is_on && !bss->UsingWEP) { atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); priv->station_is_associated = 0; @@ -3011,30 +3033,28 @@ void atmel_join_bss(struct atmel_private *priv, int bss_index) } atmel_enter_state(priv, STATION_STATE_JOINNING); - + if (priv->operating_mode == IW_MODE_INFRA) join(priv, BSS_TYPE_INFRASTRUCTURE); - else + else join(priv, BSS_TYPE_AD_HOC); } - static void restart_search(struct atmel_private *priv) { int bss_index; - + if (!priv->connect_to_any_BSS) { atmel_scan(priv, 1); } else { priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; - - if ((bss_index = retrieve_bss(priv)) != -1) + + if ((bss_index = retrieve_bss(priv)) != -1) atmel_join_bss(priv, bss_index); else atmel_scan(priv, 0); - - } -} + } +} static void smooth_rssi(struct atmel_private *priv, u8 rssi) { @@ -3050,21 +3070,21 @@ static void smooth_rssi(struct atmel_private *priv, u8 rssi) } rssi = rssi * 100 / max_rssi; - if((rssi + old) % 2) - priv->wstats.qual.level = ((rssi + old)/2) + 1; + if ((rssi + old) % 2) + priv->wstats.qual.level = (rssi + old) / 2 + 1; else - priv->wstats.qual.level = ((rssi + old)/2); + priv->wstats.qual.level = (rssi + old) / 2; priv->wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; priv->wstats.qual.updated &= ~IW_QUAL_LEVEL_INVALID; } static void atmel_smooth_qual(struct atmel_private *priv) { - unsigned long time_diff = (jiffies - priv->last_qual)/HZ; + unsigned long time_diff = (jiffies - priv->last_qual) / HZ; while (time_diff--) { priv->last_qual += HZ; - priv->wstats.qual.qual = priv->wstats.qual.qual/2; - priv->wstats.qual.qual += + priv->wstats.qual.qual = priv->wstats.qual.qual / 2; + priv->wstats.qual.qual += priv->beacons_this_sec * priv->beacon_period * (priv->wstats.qual.level + 100) / 4000; priv->beacons_this_sec = 0; } @@ -3073,15 +3093,17 @@ static void atmel_smooth_qual(struct atmel_private *priv) } /* deals with incoming managment frames. */ -static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, - u16 frame_len, u8 rssi) +static void atmel_management_frame(struct atmel_private *priv, + struct ieee80211_hdr_4addr *header, + u16 frame_len, u8 rssi) { u16 subtype; - - switch (subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE) { - case C80211_SUBTYPE_MGMT_BEACON : + + subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE; + switch (subtype) { + case C80211_SUBTYPE_MGMT_BEACON: case C80211_SUBTYPE_MGMT_ProbeResponse: - + /* beacon frame has multiple variable-length fields - never let an engineer loose with a data structure design. */ { @@ -3099,7 +3121,7 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_ u8 ds_length; /* ds here */ } *beacon = (struct beacon_format *)priv->rx_buf; - + u8 channel, rates_length, ssid_length; u64 timestamp = le64_to_cpu(beacon->timestamp); u16 beacon_interval = le16_to_cpu(beacon->interval); @@ -3107,7 +3129,7 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_ u8 *beaconp = priv->rx_buf; ssid_length = beacon->ssid_length; /* this blows chunks. */ - if (frame_len < 14 || frame_len < ssid_length + 15) + if (frame_len < 14 || frame_len < ssid_length + 15) return; rates_length = beaconp[beacon->ssid_length + 15]; if (frame_len < ssid_length + rates_length + 18) @@ -3115,10 +3137,10 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_ if (ssid_length > MAX_SSID_LENGTH) return; channel = beaconp[ssid_length + rates_length + 18]; - + if (priv->station_state == STATION_STATE_READY) { smooth_rssi(priv, rssi); - if (is_frame_from_current_bss(priv, header)) { + if (is_frame_from_current_bss(priv, header)) { priv->beacons_this_sec++; atmel_smooth_qual(priv); if (priv->last_beacon_timestamp) { @@ -3132,41 +3154,43 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_ handle_beacon_probe(priv, capability, channel); } } - - if (priv->station_state == STATION_STATE_SCANNING ) - store_bss_info(priv, header, capability, beacon_interval, channel, - rssi, ssid_length, &beacon->rates_el_id, - subtype == C80211_SUBTYPE_MGMT_BEACON) ; + + if (priv->station_state == STATION_STATE_SCANNING) + store_bss_info(priv, header, capability, + beacon_interval, channel, rssi, + ssid_length, + &beacon->rates_el_id, + subtype == C80211_SUBTYPE_MGMT_BEACON); } break; - + case C80211_SUBTYPE_MGMT_Authentication: if (priv->station_state == STATION_STATE_AUTHENTICATING) authenticate(priv, frame_len); - + break; - + case C80211_SUBTYPE_MGMT_ASS_RESPONSE: case C80211_SUBTYPE_MGMT_REASS_RESPONSE: - - if (priv->station_state == STATION_STATE_ASSOCIATING || + + if (priv->station_state == STATION_STATE_ASSOCIATING || priv->station_state == STATION_STATE_REASSOCIATING) associate(priv, frame_len, subtype); - + break; case C80211_SUBTYPE_MGMT_DISASSOSIATION: - if (priv->station_is_associated && - priv->operating_mode == IW_MODE_INFRA && + if (priv->station_is_associated && + priv->operating_mode == IW_MODE_INFRA && is_frame_from_current_bss(priv, header)) { priv->station_was_associated = 0; priv->station_is_associated = 0; - + atmel_enter_state(priv, STATION_STATE_JOINNING); join(priv, BSS_TYPE_INFRASTRUCTURE); } - + break; case C80211_SUBTYPE_MGMT_Deauthentication: @@ -3177,7 +3201,7 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_ atmel_enter_state(priv, STATION_STATE_JOINNING); join(priv, BSS_TYPE_INFRASTRUCTURE); } - + break; } } @@ -3185,76 +3209,73 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_ /* run when timer expires */ static void atmel_management_timer(u_long a) { - struct net_device *dev = (struct net_device *) a; - struct atmel_private *priv = netdev_priv(dev); - unsigned long flags; - - /* Check if the card has been yanked. */ - if (priv->card && priv->present_callback && - !(*priv->present_callback)(priv->card)) - return; - - spin_lock_irqsave(&priv->irqlock, flags); - - switch (priv->station_state) { - - case STATION_STATE_AUTHENTICATING: - if (priv->AuthenticationRequestRetryCnt >= MAX_AUTHENTICATION_RETRIES) { - atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); - priv->station_is_associated = 0; - priv->AuthenticationRequestRetryCnt = 0; - restart_search(priv); - } else { - priv->AuthenticationRequestRetryCnt++; - priv->CurrentAuthentTransactionSeqNum = 0x0001; - mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); - send_authentication_request(priv, C80211_MGMT_AAN_OPENSYSTEM, NULL, 0); - } - - break; + struct net_device *dev = (struct net_device *) a; + struct atmel_private *priv = netdev_priv(dev); + unsigned long flags; - case STATION_STATE_ASSOCIATING: - if (priv->AssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) { - atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); - priv->station_is_associated = 0; - priv->AssociationRequestRetryCnt = 0; - restart_search(priv); - } else { - priv->AssociationRequestRetryCnt++; - mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); - send_association_request(priv, 0); - } + /* Check if the card has been yanked. */ + if (priv->card && priv->present_callback && + !(*priv->present_callback)(priv->card)) + return; - break; - - case STATION_STATE_REASSOCIATING: - if (priv->ReAssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) { - atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); - priv->station_is_associated = 0; - priv->ReAssociationRequestRetryCnt = 0; - restart_search(priv); - } else { - priv->ReAssociationRequestRetryCnt++; - mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); - send_association_request(priv, 1); - } + spin_lock_irqsave(&priv->irqlock, flags); + + switch (priv->station_state) { + case STATION_STATE_AUTHENTICATING: + if (priv->AuthenticationRequestRetryCnt >= MAX_AUTHENTICATION_RETRIES) { + atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); + priv->station_is_associated = 0; + priv->AuthenticationRequestRetryCnt = 0; + restart_search(priv); + } else { + priv->AuthenticationRequestRetryCnt++; + priv->CurrentAuthentTransactionSeqNum = 0x0001; + mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); + send_authentication_request(priv, C80211_MGMT_AAN_OPENSYSTEM, NULL, 0); + } break; - - default: + + case STATION_STATE_ASSOCIATING: + if (priv->AssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) { + atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); + priv->station_is_associated = 0; + priv->AssociationRequestRetryCnt = 0; + restart_search(priv); + } else { + priv->AssociationRequestRetryCnt++; + mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); + send_association_request(priv, 0); + } break; - } - - spin_unlock_irqrestore(&priv->irqlock, flags); + + case STATION_STATE_REASSOCIATING: + if (priv->ReAssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) { + atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); + priv->station_is_associated = 0; + priv->ReAssociationRequestRetryCnt = 0; + restart_search(priv); + } else { + priv->ReAssociationRequestRetryCnt++; + mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); + send_association_request(priv, 1); + } + break; + + default: + break; + } + + spin_unlock_irqrestore(&priv->irqlock, flags); } - + static void atmel_command_irq(struct atmel_private *priv) { u8 status = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET)); u8 command = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_COMMAND_OFFSET)); int fast_scan; - - if (status == CMD_STATUS_IDLE || + + if (status == CMD_STATUS_IDLE || status == CMD_STATUS_IN_PROGRESS) return; @@ -3266,20 +3287,20 @@ static void atmel_command_irq(struct atmel_private *priv) atmel_get_mib(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_BSSID_POS, (u8 *)priv->CurrentBSSID, 6); atmel_enter_state(priv, STATION_STATE_READY); - } + } break; - + case CMD_Scan: fast_scan = priv->fast_scan; priv->fast_scan = 0; - + if (status != CMD_STATUS_COMPLETE) { atmel_scan(priv, 1); } else { int bss_index = retrieve_bss(priv); if (bss_index != -1) { atmel_join_bss(priv, bss_index); - } else if (priv->operating_mode == IW_MODE_ADHOC && + } else if (priv->operating_mode == IW_MODE_ADHOC && priv->SSID_size != 0) { start(priv, BSS_TYPE_AD_HOC); } else { @@ -3289,16 +3310,16 @@ static void atmel_command_irq(struct atmel_private *priv) priv->site_survey_state = SITE_SURVEY_COMPLETED; } break; - + case CMD_SiteSurvey: priv->fast_scan = 0; - + if (status != CMD_STATUS_COMPLETE) return; - + priv->site_survey_state = SITE_SURVEY_COMPLETED; if (priv->station_is_associated) { - atmel_enter_state(priv, STATION_STATE_READY); + atmel_enter_state(priv, STATION_STATE_READY); } else { atmel_scan(priv, 1); } @@ -3312,16 +3333,15 @@ static void atmel_command_irq(struct atmel_private *priv) } else { priv->AuthenticationRequestRetryCnt = 0; atmel_enter_state(priv, STATION_STATE_AUTHENTICATING); - + mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); priv->CurrentAuthentTransactionSeqNum = 0x0001; send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0); } return; } - + atmel_scan(priv, 1); - } } @@ -3333,20 +3353,20 @@ static int atmel_wakeup_firmware(struct atmel_private *priv) if (priv->card_type == CARD_TYPE_SPI_FLASH) atmel_set_gcr(priv->dev, GCR_REMAP); - + /* wake up on-board processor */ atmel_clear_gcr(priv->dev, 0x0040); atmel_write16(priv->dev, BSR, BSS_SRAM); - + if (priv->card_type == CARD_TYPE_SPI_FLASH) mdelay(100); /* and wait for it */ - for (i = LOOP_RETRY_LIMIT; i; i--) { + for (i = LOOP_RETRY_LIMIT; i; i--) { mr1 = atmel_read16(priv->dev, MR1); mr3 = atmel_read16(priv->dev, MR3); - - if (mr3 & MAC_BOOT_COMPLETE) + + if (mr3 & MAC_BOOT_COMPLETE) break; if (mr1 & MAC_BOOT_COMPLETE && priv->bus_type == BUS_TYPE_PCCARD) @@ -3357,35 +3377,36 @@ static int atmel_wakeup_firmware(struct atmel_private *priv) printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name); return 0; } - + if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) { printk(KERN_ALERT "%s: card missing.\n", priv->dev->name); return 0; } - - /* now check for completion of MAC initialization through - the FunCtrl field of the IFACE, poll MR1 to detect completion of - MAC initialization, check completion status, set interrupt mask, - enables interrupts and calls Tx and Rx initialization functions */ - + + /* now check for completion of MAC initialization through + the FunCtrl field of the IFACE, poll MR1 to detect completion of + MAC initialization, check completion status, set interrupt mask, + enables interrupts and calls Tx and Rx initialization functions */ + atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), FUNC_CTRL_INIT_COMPLETE); - - for (i = LOOP_RETRY_LIMIT; i; i--) { + + for (i = LOOP_RETRY_LIMIT; i; i--) { mr1 = atmel_read16(priv->dev, MR1); mr3 = atmel_read16(priv->dev, MR3); - - if (mr3 & MAC_INIT_COMPLETE) + + if (mr3 & MAC_INIT_COMPLETE) break; if (mr1 & MAC_INIT_COMPLETE && priv->bus_type == BUS_TYPE_PCCARD) break; } - + if (i == 0) { - printk(KERN_ALERT "%s: MAC failed to initialise.\n", priv->dev->name); + printk(KERN_ALERT "%s: MAC failed to initialise.\n", + priv->dev->name); return 0; } - + /* Check for MAC_INIT_OK only on the register that the MAC_INIT_OK was set */ if ((mr3 & MAC_INIT_COMPLETE) && !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) { @@ -3398,9 +3419,9 @@ static int atmel_wakeup_firmware(struct atmel_private *priv) return 0; } - atmel_copy_to_host(priv->dev, (unsigned char *)iface, + atmel_copy_to_host(priv->dev, (unsigned char *)iface, priv->host_info_base, sizeof(*iface)); - + iface->tx_buff_pos = le16_to_cpu(iface->tx_buff_pos); iface->tx_buff_size = le16_to_cpu(iface->tx_buff_size); iface->tx_desc_pos = le16_to_cpu(iface->tx_desc_pos); @@ -3424,16 +3445,16 @@ static int probe_atmel_card(struct net_device *dev) { int rc = 0; struct atmel_private *priv = netdev_priv(dev); - + /* reset pccard */ - if (priv->bus_type == BUS_TYPE_PCCARD) + if (priv->bus_type == BUS_TYPE_PCCARD) atmel_write16(dev, GCR, 0x0060); - + atmel_write16(dev, GCR, 0x0040); mdelay(500); - + if (atmel_read16(dev, MR2) == 0) { - /* No stored firmware so load a small stub which just + /* No stored firmware so load a small stub which just tells us the MAC address */ int i; priv->card_type = CARD_TYPE_EEPROM; @@ -3442,7 +3463,7 @@ static int probe_atmel_card(struct net_device *dev) atmel_set_gcr(dev, GCR_REMAP); atmel_clear_gcr(priv->dev, 0x0040); atmel_write16(dev, BSR, BSS_SRAM); - for (i = LOOP_RETRY_LIMIT; i; i--) + for (i = LOOP_RETRY_LIMIT; i; i--) if (atmel_read16(dev, MR3) & MAC_BOOT_COMPLETE) break; if (i == 0) { @@ -3451,7 +3472,7 @@ static int probe_atmel_card(struct net_device *dev) atmel_copy_to_host(dev, dev->dev_addr, atmel_read16(dev, MR2), 6); /* got address, now squash it again until the network interface is opened */ - if (priv->bus_type == BUS_TYPE_PCCARD) + if (priv->bus_type == BUS_TYPE_PCCARD) atmel_write16(dev, GCR, 0x0060); atmel_write16(dev, GCR, 0x0040); rc = 1; @@ -3459,7 +3480,7 @@ static int probe_atmel_card(struct net_device *dev) } else if (atmel_read16(dev, MR4) == 0) { /* Mac address easy in this case. */ priv->card_type = CARD_TYPE_PARALLEL_FLASH; - atmel_write16(dev, BSR, 1); + atmel_write16(dev, BSR, 1); atmel_copy_to_host(dev, dev->dev_addr, 0xc000, 6); atmel_write16(dev, BSR, 0x200); rc = 1; @@ -3469,16 +3490,16 @@ static int probe_atmel_card(struct net_device *dev) priv->card_type = CARD_TYPE_SPI_FLASH; if (atmel_wakeup_firmware(priv)) { atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6); - + /* got address, now squash it again until the network interface is opened */ - if (priv->bus_type == BUS_TYPE_PCCARD) + if (priv->bus_type == BUS_TYPE_PCCARD) atmel_write16(dev, GCR, 0x0060); atmel_write16(dev, GCR, 0x0040); rc = 1; } } - + if (rc) { if (dev->dev_addr[0] == 0xFF) { u8 default_mac[] = {0x00,0x04, 0x25, 0x00, 0x00, 0x00}; @@ -3486,27 +3507,27 @@ static int probe_atmel_card(struct net_device *dev) memcpy(dev->dev_addr, default_mac, 6); } } - + return rc; } -static void build_wep_mib(struct atmel_private *priv) /* Move the encyption information on the MIB structure. This routine is for the pre-WPA firmware: later firmware has a different format MIB and a different routine. */ +static void build_wep_mib(struct atmel_private *priv) { struct { /* NB this is matched to the hardware, don't change. */ - u8 wep_is_on; + u8 wep_is_on; u8 default_key; /* 0..3 */ u8 reserved; u8 exclude_unencrypted; - + u32 WEPICV_error_count; u32 WEP_excluded_count; - + u8 wep_keys[MAX_ENCRYPTION_KEYS][13]; - u8 encryption_level; /* 0, 1, 2 */ - u8 reserved2[3]; + u8 encryption_level; /* 0, 1, 2 */ + u8 reserved2[3]; } mib; int i; @@ -3515,54 +3536,55 @@ static void build_wep_mib(struct atmel_private *priv) if (priv->wep_key_len[priv->default_key] > 5) mib.encryption_level = 2; else - mib.encryption_level = 1; + mib.encryption_level = 1; } else { mib.encryption_level = 0; } mib.default_key = priv->default_key; mib.exclude_unencrypted = priv->exclude_unencrypted; - - for(i = 0; i < MAX_ENCRYPTION_KEYS; i++) + + for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) memcpy(mib.wep_keys[i], priv->wep_keys[i], 13); - + atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&mib, sizeof(mib)); } static void build_wpa_mib(struct atmel_private *priv) { - /* This is for the later (WPA enabled) firmware. */ + /* This is for the later (WPA enabled) firmware. */ struct { /* NB this is matched to the hardware, don't change. */ u8 cipher_default_key_value[MAX_ENCRYPTION_KEYS][MAX_ENCRYPTION_KEY_SIZE]; u8 receiver_address[6]; - u8 wep_is_on; + u8 wep_is_on; u8 default_key; /* 0..3 */ u8 group_key; u8 exclude_unencrypted; u8 encryption_type; u8 reserved; - + u32 WEPICV_error_count; u32 WEP_excluded_count; - + u8 key_RSC[4][8]; } mib; - + int i; mib.wep_is_on = priv->wep_is_on; mib.exclude_unencrypted = priv->exclude_unencrypted; memcpy(mib.receiver_address, priv->CurrentBSSID, 6); - + /* zero all the keys before adding in valid ones. */ memset(mib.cipher_default_key_value, 0, sizeof(mib.cipher_default_key_value)); - + if (priv->wep_is_on) { - /* There's a comment in the Atmel code to the effect that this is only valid - when still using WEP, it may need to be set to something to use WPA */ + /* There's a comment in the Atmel code to the effect that this + is only valid when still using WEP, it may need to be set to + something to use WPA */ memset(mib.key_RSC, 0, sizeof(mib.key_RSC)); - + mib.default_key = mib.group_key = 255; for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) { if (priv->wep_key_len[i] > 0) { @@ -3570,12 +3592,12 @@ static void build_wpa_mib(struct atmel_private *priv) if (i == priv->default_key) { mib.default_key = i; mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 7; - mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->pairwise_cipher_suite; + mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->pairwise_cipher_suite; } else { mib.group_key = i; priv->group_cipher_suite = priv->pairwise_cipher_suite; mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 1; - mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->group_cipher_suite; + mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->group_cipher_suite; } } } @@ -3583,47 +3605,47 @@ static void build_wpa_mib(struct atmel_private *priv) mib.default_key = mib.group_key != 255 ? mib.group_key : 0; if (mib.group_key == 255) mib.group_key = mib.default_key; - + } - + atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&mib, sizeof(mib)); } - -static int reset_atmel_card(struct net_device *dev) + +static int reset_atmel_card(struct net_device *dev) { /* do everything necessary to wake up the hardware, including waiting for the lightning strike and throwing the knife switch.... - set all the Mib values which matter in the card to match + set all the Mib values which matter in the card to match their settings in the atmel_private structure. Some of these can be altered on the fly, but many (WEP, infrastucture or ad-hoc) can only be changed by tearing down the world and coming back through here. - This routine is also responsible for initialising some - hardware-specific fields in the atmel_private structure, + This routine is also responsible for initialising some + hardware-specific fields in the atmel_private structure, including a copy of the firmware's hostinfo stucture which is the route into the rest of the firmare datastructures. */ struct atmel_private *priv = netdev_priv(dev); u8 configuration; - + /* data to add to the firmware names, in priority order this implemenents firmware versioning */ - + static char *firmware_modifier[] = { "-wpa", "", NULL }; - + /* reset pccard */ - if (priv->bus_type == BUS_TYPE_PCCARD) + if (priv->bus_type == BUS_TYPE_PCCARD) atmel_write16(priv->dev, GCR, 0x0060); - + /* stop card , disable interrupts */ atmel_write16(priv->dev, GCR, 0x0040); - + if (priv->card_type == CARD_TYPE_EEPROM) { /* copy in firmware if needed */ const struct firmware *fw_entry = NULL; @@ -3636,13 +3658,13 @@ static int reset_atmel_card(struct net_device *dev) "%s: card type is unknown: assuming at76c502 firmware is OK.\n", dev->name); printk(KERN_INFO - "%s: if not, use the firmware= module parameter.\n", + "%s: if not, use the firmware= module parameter.\n", dev->name); strcpy(priv->firmware_id, "atmel_at76c502.bin"); } if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) != 0) { - printk(KERN_ALERT - "%s: firmware %s is missing, cannot continue.\n", + printk(KERN_ALERT + "%s: firmware %s is missing, cannot continue.\n", dev->name, priv->firmware_id); return 0; } @@ -3654,7 +3676,7 @@ static int reset_atmel_card(struct net_device *dev) while (fw_table[fw_index].fw_type != priv->firmware_type && fw_table[fw_index].fw_type != ATMEL_FW_TYPE_NONE) fw_index++; - + /* construct the actual firmware file name */ if (fw_table[fw_index].fw_type != ATMEL_FW_TYPE_NONE) { int i; @@ -3669,24 +3691,24 @@ static int reset_atmel_card(struct net_device *dev) } } if (!success) { - printk(KERN_ALERT - "%s: firmware %s is missing, cannot start.\n", + printk(KERN_ALERT + "%s: firmware %s is missing, cannot start.\n", dev->name, priv->firmware_id); priv->firmware_id[0] = '\0'; - return 0; + return 0; } } - + fw = fw_entry->data; len = fw_entry->size; } - + if (len <= 0x6000) { atmel_write16(priv->dev, BSR, BSS_IRAM); atmel_copy_to_card(priv->dev, 0, fw, len); atmel_set_gcr(priv->dev, GCR_REMAP); } else { - /* Remap */ + /* Remap */ atmel_set_gcr(priv->dev, GCR_REMAP); atmel_write16(priv->dev, BSR, BSS_IRAM); atmel_copy_to_card(priv->dev, 0, fw, 0x6000); @@ -3708,45 +3730,45 @@ static int reset_atmel_card(struct net_device *dev) the 3com broken-ness filter. */ priv->use_wpa = (priv->host_info.major_version == 4); priv->radio_on_broken = (priv->host_info.major_version == 5); - + /* unmask all irq sources */ atmel_wmem8(priv, atmel_hi(priv, IFACE_INT_MASK_OFFSET), 0xff); - + /* int Tx system and enable Tx */ atmel_wmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, 0), 0); atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, 0), 0x80000000L); atmel_wmem16(priv, atmel_tx(priv, TX_DESC_POS_OFFSET, 0), 0); atmel_wmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, 0), 0); - priv->tx_desc_free = priv->host_info.tx_desc_count; - priv->tx_desc_head = 0; - priv->tx_desc_tail = 0; + priv->tx_desc_free = priv->host_info.tx_desc_count; + priv->tx_desc_head = 0; + priv->tx_desc_tail = 0; priv->tx_desc_previous = 0; priv->tx_free_mem = priv->host_info.tx_buff_size; - priv->tx_buff_head = 0; - priv->tx_buff_tail = 0; - - configuration = atmel_rmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET)); - atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), + priv->tx_buff_head = 0; + priv->tx_buff_tail = 0; + + configuration = atmel_rmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET)); + atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), configuration | FUNC_CTRL_TxENABLE); /* init Rx system and enable */ priv->rx_desc_head = 0; - - configuration = atmel_rmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET)); - atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), + + configuration = atmel_rmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET)); + atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), configuration | FUNC_CTRL_RxENABLE); - + if (!priv->radio_on_broken) { - if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) == + if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) == CMD_STATUS_REJECTED_RADIO_OFF) { - printk(KERN_INFO + printk(KERN_INFO "%s: cannot turn the radio on. (Hey radio, you're beautiful!)\n", dev->name); return 0; } } - + /* set up enough MIB values to run. */ atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_AUTO_TX_RATE_POS, priv->auto_tx_rate); atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_TX_PROMISCUOUS_POS, PROM_MODE_OFF); @@ -3755,7 +3777,7 @@ static int reset_atmel_card(struct net_device *dev) atmel_set_mib8(priv, Mac_Mib_Type, MAC_MIB_SHORT_RETRY_POS, priv->short_retry); atmel_set_mib8(priv, Mac_Mib_Type, MAC_MIB_LONG_RETRY_POS, priv->long_retry); atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, priv->preamble); - atmel_set_mib(priv, Mac_Address_Mib_Type, MAC_ADDR_MIB_MAC_ADDR_POS, + atmel_set_mib(priv, Mac_Address_Mib_Type, MAC_ADDR_MIB_MAC_ADDR_POS, priv->dev->dev_addr, 6); atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE); atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1); @@ -3766,42 +3788,44 @@ static int reset_atmel_card(struct net_device *dev) build_wpa_mib(priv); else build_wep_mib(priv); - + return 1; } -static void atmel_send_command(struct atmel_private *priv, int command, void *cmd, int cmd_size) +static void atmel_send_command(struct atmel_private *priv, int command, + void *cmd, int cmd_size) { if (cmd) - atmel_copy_to_card(priv->dev, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET), + atmel_copy_to_card(priv->dev, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET), cmd, cmd_size); - + atmel_wmem8(priv, atmel_co(priv, CMD_BLOCK_COMMAND_OFFSET), command); atmel_wmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET), 0); } - -static int atmel_send_command_wait(struct atmel_private *priv, int command, void *cmd, int cmd_size) + +static int atmel_send_command_wait(struct atmel_private *priv, int command, + void *cmd, int cmd_size) { int i, status; - + atmel_send_command(priv, command, cmd, cmd_size); - + for (i = 5000; i; i--) { status = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET)); - if (status != CMD_STATUS_IDLE && + if (status != CMD_STATUS_IDLE && status != CMD_STATUS_IN_PROGRESS) break; udelay(20); } - + if (i == 0) { printk(KERN_ALERT "%s: failed to contact MAC.\n", priv->dev->name); status = CMD_STATUS_HOST_ERROR; - } else { + } else { if (command != CMD_EnableRadio) status = CMD_STATUS_COMPLETE; } - + return status; } @@ -3827,7 +3851,8 @@ static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index, u8 dat atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + 1); } -static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, u16 data) +static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, + u16 data) { struct get_set_mib m; m.type = type; @@ -3839,7 +3864,8 @@ static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, u16 d atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + 2); } -static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len) +static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, + u8 *data, int data_len) { struct get_set_mib m; m.type = type; @@ -3848,23 +3874,24 @@ static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, u8 *dat if (data_len > MIB_MAX_DATA_BYTES) printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name); - + memcpy(m.data, data, data_len); atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + data_len); } -static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len) +static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, + u8 *data, int data_len) { struct get_set_mib m; m.type = type; m.size = data_len; m.index = index; - + if (data_len > MIB_MAX_DATA_BYTES) printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name); - + atmel_send_command_wait(priv, CMD_Get_MIB_Vars, &m, MIB_HEADER_SIZE + data_len); - atmel_copy_to_host(priv->dev, data, + atmel_copy_to_host(priv->dev, data, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET + MIB_HEADER_SIZE), data_len); } @@ -3873,11 +3900,12 @@ static void atmel_writeAR(struct net_device *dev, u16 data) int i; outw(data, dev->base_addr + AR); /* Address register appears to need some convincing..... */ - for (i = 0; data != inw(dev->base_addr + AR) && i<10; i++) + for (i = 0; data != inw(dev->base_addr + AR) && i < 10; i++) outw(data, dev->base_addr + AR); } -static void atmel_copy_to_card(struct net_device *dev, u16 dest, unsigned char *src, u16 len) +static void atmel_copy_to_card(struct net_device *dev, u16 dest, + unsigned char *src, u16 len) { int i; atmel_writeAR(dev, dest); @@ -3894,7 +3922,8 @@ static void atmel_copy_to_card(struct net_device *dev, u16 dest, unsigned char * atmel_write8(dev, DR, *src); } -static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest, u16 src, u16 len) +static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest, + u16 src, u16 len) { int i; atmel_writeAR(dev, src); @@ -3930,22 +3959,24 @@ static int atmel_lock_mac(struct atmel_private *priv) break; udelay(20); } - - if (!i) return 0; /* timed out */ - + + if (!i) + return 0; /* timed out */ + atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 1); if (atmel_rmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_HOST_OFFSET))) { atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0); - if (!j--) return 0; /* timed out */ + if (!j--) + return 0; /* timed out */ goto retry; } - + return 1; } static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data) { - atmel_writeAR(priv->dev, pos); + atmel_writeAR(priv->dev, pos); atmel_write16(priv->dev, DR, data); /* card is little-endian */ atmel_write16(priv->dev, DR, data >> 16); } @@ -4017,9 +4048,9 @@ static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data) serial output, since SO is normally high. But it does cause 8 clock cycles and thus 8 bits to be clocked in to the chip. See Atmel's SPI - controller (e.g. AT91M55800) timing and 4K + controller (e.g. AT91M55800) timing and 4K SPI EEPROM manuals */ - + .set NVRAM_SCRATCH, 0x02000100 /* arbitrary area for scratchpad memory */ .set NVRAM_IMAGE, 0x02000200 .set NVRAM_LENGTH, 0x0200 @@ -4032,24 +4063,24 @@ static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data) .set MR4, 0xC RESET_VECTOR: b RESET_HANDLER -UNDEF_VECTOR: +UNDEF_VECTOR: b HALT1 -SWI_VECTOR: +SWI_VECTOR: b HALT1 -IABORT_VECTOR: +IABORT_VECTOR: b HALT1 -DABORT_VECTOR: -RESERVED_VECTOR: +DABORT_VECTOR: +RESERVED_VECTOR: b HALT1 -IRQ_VECTOR: +IRQ_VECTOR: b HALT1 -FIQ_VECTOR: +FIQ_VECTOR: b HALT1 HALT1: b HALT1 RESET_HANDLER: mov r0, #CPSR_INITIAL msr CPSR_c, r0 /* This is probably unnecessary */ - + /* I'm guessing this is initializing clock generator electronics for SPI */ ldr r0, =SPI_CGEN_BASE mov r1, #0 @@ -4061,7 +4092,7 @@ RESET_HANDLER: str r1, [r0, #28] mov r1, #1 str r1, [r0, #8] - + ldr r0, =MRBASE mov r1, #0 strh r1, [r0, #MR1] @@ -4094,7 +4125,7 @@ GET_WHOLE_NVRAM: ldmia sp!, {lr} bx lr .endfunc - + .func Get_MAC_Addr, GET_MAC_ADDR GET_MAC_ADDR: stmdb sp!, {lr} @@ -4110,13 +4141,13 @@ GET_MAC_ADDR: .func Delay9, DELAY9 DELAY9: adds r0, r0, r0, LSL #3 /* r0 = r0 * 9 */ -DELAYLOOP: +DELAYLOOP: beq DELAY9_done subs r0, r0, #1 b DELAYLOOP -DELAY9_done: +DELAY9_done: bx lr -.endfunc +.endfunc .func SP_Init, SP_INIT SP_INIT: @@ -4145,26 +4176,26 @@ SP_INIT: ldr r0, [r0, #SP_RDR] bx lr .endfunc -.func NVRAM_Init, NVRAM_INIT +.func NVRAM_Init, NVRAM_INIT NVRAM_INIT: ldr r1, =SP_BASE ldr r0, [r1, #SP_RDR] mov r0, #NVRAM_CMD_RDSR str r0, [r1, #SP_TDR] -SP_loop1: +SP_loop1: ldr r0, [r1, #SP_SR] tst r0, #SP_TDRE beq SP_loop1 mov r0, #SPI_8CLOCKS - str r0, [r1, #SP_TDR] -SP_loop2: + str r0, [r1, #SP_TDR] +SP_loop2: ldr r0, [r1, #SP_SR] tst r0, #SP_TDRE beq SP_loop2 ldr r0, [r1, #SP_RDR] -SP_loop3: +SP_loop3: ldr r0, [r1, #SP_SR] tst r0, #SP_RDRF beq SP_loop3 @@ -4173,7 +4204,7 @@ SP_loop3: and r0, r0, #255 bx lr .endfunc - + .func NVRAM_Xfer, NVRAM_XFER /* r0 = dest address */ /* r1 = not used */ @@ -4185,11 +4216,11 @@ NVRAM_XFER: mov r4, r3 /* save r3 (length) */ mov r0, r2, LSR #5 /* SPI memories put A8 in the command field */ and r0, r0, #8 - add r0, r0, #NVRAM_CMD_READ + add r0, r0, #NVRAM_CMD_READ ldr r1, =NVRAM_SCRATCH strb r0, [r1, #0] /* save command in NVRAM_SCRATCH[0] */ strb r2, [r1, #1] /* save low byte of source address in NVRAM_SCRATCH[1] */ -_local1: +_local1: bl NVRAM_INIT tst r0, #NVRAM_SR_RDY bne _local1 @@ -4211,7 +4242,7 @@ NVRAM_XFER2: cmp r0, #0 bls _local2 ldr r5, =NVRAM_SCRATCH -_local4: +_local4: ldrb r6, [r5, r3] str r6, [r4, #SP_TDR] _local3: @@ -4225,7 +4256,7 @@ _local2: mov r3, #SPI_8CLOCKS str r3, [r4, #SP_TDR] ldr r0, [r4, #SP_RDR] -_local5: +_local5: ldr r0, [r4, #SP_SR] tst r0, #SP_RDRF beq _local5 @@ -4233,12 +4264,12 @@ _local5: mov r0, #0 cmp r2, #0 /* r2 is # of bytes to copy in */ bls _local6 -_local7: +_local7: ldr r5, [r4, #SP_SR] tst r5, #SP_TDRE beq _local7 str r3, [r4, #SP_TDR] /* r3 has SPI_8CLOCKS */ -_local8: +_local8: ldr r5, [r4, #SP_SR] tst r5, #SP_RDRF beq _local8 -- cgit v1.1 From 5bc4c36d7cd9f1605efeade67b3d27845a4affcd Mon Sep 17 00:00:00 2001 From: Christophe Lucas Date: Sat, 12 Nov 2005 21:58:53 +0300 Subject: [PATCH] atmel: audit return code of create_proc_read_entry Signed-off-by: Christophe Lucas Signed-off-by: Alexey Dobriyan Signed-off-by: John W. Linville --- drivers/net/wireless/atmel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 050aa51..e4729dd 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c @@ -1511,6 +1511,7 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port, struct device *sys_dev, int (*card_present)(void *), void *card) { + struct proc_dir_entry *ent; struct net_device *dev; struct atmel_private *priv; int rc; @@ -1624,7 +1625,9 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port, netif_carrier_off(dev); - create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); + ent = create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); + if (!ent) + printk(KERN_WARNING "atmel: unable to create /proc entry.\n"); printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", dev->name, DRIVER_MAJOR, DRIVER_MINOR, -- cgit v1.1 From 7635d345b2c047339b44c85fff486c6b94b67216 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 13 Nov 2005 13:26:25 -0500 Subject: [PATCH] hostap: rename hostap.c to hostap_main.c I wanted to remove the #include "hostap_ioctl.c" from hostap.c and build hostap_ioctl.c separately, but this doesn't work since hostap.c has the same name as the module. After renaming hostap.c this will be possible. Signed-off-by: Adrian Bunk Acked-by: Jouni Malinen Signed-off-by: John W. Linville --- drivers/net/wireless/hostap/Makefile | 1 + drivers/net/wireless/hostap/hostap.c | 1191 ----------------------------- drivers/net/wireless/hostap/hostap_main.c | 1191 +++++++++++++++++++++++++++++ 3 files changed, 1192 insertions(+), 1191 deletions(-) delete mode 100644 drivers/net/wireless/hostap/hostap.c create mode 100644 drivers/net/wireless/hostap/hostap_main.c diff --git a/drivers/net/wireless/hostap/Makefile b/drivers/net/wireless/hostap/Makefile index fc62235..353ccb9 100644 --- a/drivers/net/wireless/hostap/Makefile +++ b/drivers/net/wireless/hostap/Makefile @@ -1,3 +1,4 @@ +hostap-y := hostap_main.o obj-$(CONFIG_HOSTAP) += hostap.o obj-$(CONFIG_HOSTAP_CS) += hostap_cs.o diff --git a/drivers/net/wireless/hostap/hostap.c b/drivers/net/wireless/hostap/hostap.c deleted file mode 100644 index 3d2ea61..0000000 --- a/drivers/net/wireless/hostap/hostap.c +++ /dev/null @@ -1,1191 +0,0 @@ -/* - * Host AP (software wireless LAN access point) driver for - * Intersil Prism2/2.5/3 - hostap.o module, common routines - * - * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen - * - * Copyright (c) 2002-2005, Jouni Malinen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. See README and COPYING for - * more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "hostap_wlan.h" -#include "hostap_80211.h" -#include "hostap_ap.h" -#include "hostap.h" - -MODULE_AUTHOR("Jouni Malinen"); -MODULE_DESCRIPTION("Host AP common routines"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(PRISM2_VERSION); - -#define TX_TIMEOUT (2 * HZ) - -#define PRISM2_MAX_FRAME_SIZE 2304 -#define PRISM2_MIN_MTU 256 -/* FIX: */ -#define PRISM2_MAX_MTU (PRISM2_MAX_FRAME_SIZE - (6 /* LLC */ + 8 /* WEP */)) - - -/* hostap.c */ -static int prism2_wds_add(local_info_t *local, u8 *remote_addr, - int rtnl_locked); -static int prism2_wds_del(local_info_t *local, u8 *remote_addr, - int rtnl_locked, int do_not_remove); - -/* hostap_ap.c */ -static int prism2_ap_get_sta_qual(local_info_t *local, struct sockaddr addr[], - struct iw_quality qual[], int buf_size, - int aplist); -static int prism2_ap_translate_scan(struct net_device *dev, char *buffer); -static int prism2_hostapd(struct ap_data *ap, - struct prism2_hostapd_param *param); -static void * ap_crypt_get_ptrs(struct ap_data *ap, u8 *addr, int permanent, - struct ieee80211_crypt_data ***crypt); -static void ap_control_kickall(struct ap_data *ap); -#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT -static int ap_control_add_mac(struct mac_restrictions *mac_restrictions, - u8 *mac); -static int ap_control_del_mac(struct mac_restrictions *mac_restrictions, - u8 *mac); -static void ap_control_flush_macs(struct mac_restrictions *mac_restrictions); -static int ap_control_kick_mac(struct ap_data *ap, struct net_device *dev, - u8 *mac); -#endif /* !PRISM2_NO_KERNEL_IEEE80211_MGMT */ - - -static const long freq_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, - 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; -#define FREQ_COUNT (sizeof(freq_list) / sizeof(freq_list[0])) - - -/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ -/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ -static unsigned char rfc1042_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; -/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -static unsigned char bridge_tunnel_header[] = -{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; -/* No encapsulation header if EtherType < 0x600 (=length) */ - - -/* FIX: these could be compiled separately and linked together to hostap.o */ -#include "hostap_ap.c" -#include "hostap_info.c" -#include "hostap_ioctl.c" -#include "hostap_proc.c" -#include "hostap_80211_rx.c" -#include "hostap_80211_tx.c" - - -struct net_device * hostap_add_interface(struct local_info *local, - int type, int rtnl_locked, - const char *prefix, - const char *name) -{ - struct net_device *dev, *mdev; - struct hostap_interface *iface; - int ret; - - dev = alloc_etherdev(sizeof(struct hostap_interface)); - if (dev == NULL) - return NULL; - - iface = netdev_priv(dev); - iface->dev = dev; - iface->local = local; - iface->type = type; - list_add(&iface->list, &local->hostap_interfaces); - - mdev = local->dev; - memcpy(dev->dev_addr, mdev->dev_addr, ETH_ALEN); - dev->base_addr = mdev->base_addr; - dev->irq = mdev->irq; - dev->mem_start = mdev->mem_start; - dev->mem_end = mdev->mem_end; - - hostap_setup_dev(dev, local, 0); - dev->destructor = free_netdev; - - sprintf(dev->name, "%s%s", prefix, name); - if (!rtnl_locked) - rtnl_lock(); - - ret = 0; - if (strchr(dev->name, '%')) - ret = dev_alloc_name(dev, dev->name); - - SET_NETDEV_DEV(dev, mdev->class_dev.dev); - if (ret >= 0) - ret = register_netdevice(dev); - - if (!rtnl_locked) - rtnl_unlock(); - - if (ret < 0) { - printk(KERN_WARNING "%s: failed to add new netdevice!\n", - dev->name); - free_netdev(dev); - return NULL; - } - - printk(KERN_DEBUG "%s: registered netdevice %s\n", - mdev->name, dev->name); - - return dev; -} - - -void hostap_remove_interface(struct net_device *dev, int rtnl_locked, - int remove_from_list) -{ - struct hostap_interface *iface; - - if (!dev) - return; - - iface = netdev_priv(dev); - - if (remove_from_list) { - list_del(&iface->list); - } - - if (dev == iface->local->ddev) - iface->local->ddev = NULL; - else if (dev == iface->local->apdev) - iface->local->apdev = NULL; - else if (dev == iface->local->stadev) - iface->local->stadev = NULL; - - if (rtnl_locked) - unregister_netdevice(dev); - else - unregister_netdev(dev); - - /* dev->destructor = free_netdev() will free the device data, including - * private data, when removing the device */ -} - - -static inline int prism2_wds_special_addr(u8 *addr) -{ - if (addr[0] || addr[1] || addr[2] || addr[3] || addr[4] || addr[5]) - return 0; - - return 1; -} - - -static int prism2_wds_add(local_info_t *local, u8 *remote_addr, - int rtnl_locked) -{ - struct net_device *dev; - struct list_head *ptr; - struct hostap_interface *iface, *empty, *match; - - empty = match = NULL; - read_lock_bh(&local->iface_lock); - list_for_each(ptr, &local->hostap_interfaces) { - iface = list_entry(ptr, struct hostap_interface, list); - if (iface->type != HOSTAP_INTERFACE_WDS) - continue; - - if (prism2_wds_special_addr(iface->u.wds.remote_addr)) - empty = iface; - else if (memcmp(iface->u.wds.remote_addr, remote_addr, - ETH_ALEN) == 0) { - match = iface; - break; - } - } - if (!match && empty && !prism2_wds_special_addr(remote_addr)) { - /* take pre-allocated entry into use */ - memcpy(empty->u.wds.remote_addr, remote_addr, ETH_ALEN); - read_unlock_bh(&local->iface_lock); - printk(KERN_DEBUG "%s: using pre-allocated WDS netdevice %s\n", - local->dev->name, empty->dev->name); - return 0; - } - read_unlock_bh(&local->iface_lock); - - if (!prism2_wds_special_addr(remote_addr)) { - if (match) - return -EEXIST; - hostap_add_sta(local->ap, remote_addr); - } - - if (local->wds_connections >= local->wds_max_connections) - return -ENOBUFS; - - /* verify that there is room for wds# postfix in the interface name */ - if (strlen(local->dev->name) > IFNAMSIZ - 5) { - printk(KERN_DEBUG "'%s' too long base device name\n", - local->dev->name); - return -EINVAL; - } - - dev = hostap_add_interface(local, HOSTAP_INTERFACE_WDS, rtnl_locked, - local->ddev->name, "wds%d"); - if (dev == NULL) - return -ENOMEM; - - iface = netdev_priv(dev); - memcpy(iface->u.wds.remote_addr, remote_addr, ETH_ALEN); - - local->wds_connections++; - - return 0; -} - - -static int prism2_wds_del(local_info_t *local, u8 *remote_addr, - int rtnl_locked, int do_not_remove) -{ - unsigned long flags; - struct list_head *ptr; - struct hostap_interface *iface, *selected = NULL; - - write_lock_irqsave(&local->iface_lock, flags); - list_for_each(ptr, &local->hostap_interfaces) { - iface = list_entry(ptr, struct hostap_interface, list); - if (iface->type != HOSTAP_INTERFACE_WDS) - continue; - - if (memcmp(iface->u.wds.remote_addr, remote_addr, - ETH_ALEN) == 0) { - selected = iface; - break; - } - } - if (selected && !do_not_remove) - list_del(&selected->list); - write_unlock_irqrestore(&local->iface_lock, flags); - - if (selected) { - if (do_not_remove) - memset(selected->u.wds.remote_addr, 0, ETH_ALEN); - else { - hostap_remove_interface(selected->dev, rtnl_locked, 0); - local->wds_connections--; - } - } - - return selected ? 0 : -ENODEV; -} - - -u16 hostap_tx_callback_register(local_info_t *local, - void (*func)(struct sk_buff *, int ok, void *), - void *data) -{ - unsigned long flags; - struct hostap_tx_callback_info *entry; - - entry = (struct hostap_tx_callback_info *) kmalloc(sizeof(*entry), - GFP_ATOMIC); - if (entry == NULL) - return 0; - - entry->func = func; - entry->data = data; - - spin_lock_irqsave(&local->lock, flags); - entry->idx = local->tx_callback ? local->tx_callback->idx + 1 : 1; - entry->next = local->tx_callback; - local->tx_callback = entry; - spin_unlock_irqrestore(&local->lock, flags); - - return entry->idx; -} - - -int hostap_tx_callback_unregister(local_info_t *local, u16 idx) -{ - unsigned long flags; - struct hostap_tx_callback_info *cb, *prev = NULL; - - spin_lock_irqsave(&local->lock, flags); - cb = local->tx_callback; - while (cb != NULL && cb->idx != idx) { - prev = cb; - cb = cb->next; - } - if (cb) { - if (prev == NULL) - local->tx_callback = cb->next; - else - prev->next = cb->next; - kfree(cb); - } - spin_unlock_irqrestore(&local->lock, flags); - - return cb ? 0 : -1; -} - - -/* val is in host byte order */ -int hostap_set_word(struct net_device *dev, int rid, u16 val) -{ - struct hostap_interface *iface; - u16 tmp = cpu_to_le16(val); - iface = netdev_priv(dev); - return iface->local->func->set_rid(dev, rid, &tmp, 2); -} - - -int hostap_set_string(struct net_device *dev, int rid, const char *val) -{ - struct hostap_interface *iface; - char buf[MAX_SSID_LEN + 2]; - int len; - - iface = netdev_priv(dev); - len = strlen(val); - if (len > MAX_SSID_LEN) - return -1; - memset(buf, 0, sizeof(buf)); - buf[0] = len; /* little endian 16 bit word */ - memcpy(buf + 2, val, len); - - return iface->local->func->set_rid(dev, rid, &buf, MAX_SSID_LEN + 2); -} - - -u16 hostap_get_porttype(local_info_t *local) -{ - if (local->iw_mode == IW_MODE_ADHOC && local->pseudo_adhoc) - return HFA384X_PORTTYPE_PSEUDO_IBSS; - if (local->iw_mode == IW_MODE_ADHOC) - return HFA384X_PORTTYPE_IBSS; - if (local->iw_mode == IW_MODE_INFRA) - return HFA384X_PORTTYPE_BSS; - if (local->iw_mode == IW_MODE_REPEAT) - return HFA384X_PORTTYPE_WDS; - if (local->iw_mode == IW_MODE_MONITOR) - return HFA384X_PORTTYPE_PSEUDO_IBSS; - return HFA384X_PORTTYPE_HOSTAP; -} - - -int hostap_set_encryption(local_info_t *local) -{ - u16 val, old_val; - int i, keylen, len, idx; - char keybuf[WEP_KEY_LEN + 1]; - enum { NONE, WEP, OTHER } encrypt_type; - - idx = local->tx_keyidx; - if (local->crypt[idx] == NULL || local->crypt[idx]->ops == NULL) - encrypt_type = NONE; - else if (strcmp(local->crypt[idx]->ops->name, "WEP") == 0) - encrypt_type = WEP; - else - encrypt_type = OTHER; - - if (local->func->get_rid(local->dev, HFA384X_RID_CNFWEPFLAGS, &val, 2, - 1) < 0) { - printk(KERN_DEBUG "Could not read current WEP flags.\n"); - goto fail; - } - le16_to_cpus(&val); - old_val = val; - - if (encrypt_type != NONE || local->privacy_invoked) - val |= HFA384X_WEPFLAGS_PRIVACYINVOKED; - else - val &= ~HFA384X_WEPFLAGS_PRIVACYINVOKED; - - if (local->open_wep || encrypt_type == NONE || - ((local->ieee_802_1x || local->wpa) && local->host_decrypt)) - val &= ~HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED; - else - val |= HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED; - - if ((encrypt_type != NONE || local->privacy_invoked) && - (encrypt_type == OTHER || local->host_encrypt)) - val |= HFA384X_WEPFLAGS_HOSTENCRYPT; - else - val &= ~HFA384X_WEPFLAGS_HOSTENCRYPT; - if ((encrypt_type != NONE || local->privacy_invoked) && - (encrypt_type == OTHER || local->host_decrypt)) - val |= HFA384X_WEPFLAGS_HOSTDECRYPT; - else - val &= ~HFA384X_WEPFLAGS_HOSTDECRYPT; - - if (val != old_val && - hostap_set_word(local->dev, HFA384X_RID_CNFWEPFLAGS, val)) { - printk(KERN_DEBUG "Could not write new WEP flags (0x%x)\n", - val); - goto fail; - } - - if (encrypt_type != WEP) - return 0; - - /* 104-bit support seems to require that all the keys are set to the - * same keylen */ - keylen = 6; /* first 5 octets */ - len = local->crypt[idx]->ops->get_key(keybuf, sizeof(keybuf), - NULL, local->crypt[idx]->priv); - if (idx >= 0 && idx < WEP_KEYS && len > 5) - keylen = WEP_KEY_LEN + 1; /* first 13 octets */ - - for (i = 0; i < WEP_KEYS; i++) { - memset(keybuf, 0, sizeof(keybuf)); - if (local->crypt[i]) { - (void) local->crypt[i]->ops->get_key( - keybuf, sizeof(keybuf), - NULL, local->crypt[i]->priv); - } - if (local->func->set_rid(local->dev, - HFA384X_RID_CNFDEFAULTKEY0 + i, - keybuf, keylen)) { - printk(KERN_DEBUG "Could not set key %d (len=%d)\n", - i, keylen); - goto fail; - } - } - if (hostap_set_word(local->dev, HFA384X_RID_CNFWEPDEFAULTKEYID, idx)) { - printk(KERN_DEBUG "Could not set default keyid %d\n", idx); - goto fail; - } - - return 0; - - fail: - printk(KERN_DEBUG "%s: encryption setup failed\n", local->dev->name); - return -1; -} - - -int hostap_set_antsel(local_info_t *local) -{ - u16 val; - int ret = 0; - - if (local->antsel_tx != HOSTAP_ANTSEL_DO_NOT_TOUCH && - local->func->cmd(local->dev, HFA384X_CMDCODE_READMIF, - HFA386X_CR_TX_CONFIGURE, - NULL, &val) == 0) { - val &= ~(BIT(2) | BIT(1)); - switch (local->antsel_tx) { - case HOSTAP_ANTSEL_DIVERSITY: - val |= BIT(1); - break; - case HOSTAP_ANTSEL_LOW: - break; - case HOSTAP_ANTSEL_HIGH: - val |= BIT(2); - break; - } - - if (local->func->cmd(local->dev, HFA384X_CMDCODE_WRITEMIF, - HFA386X_CR_TX_CONFIGURE, &val, NULL)) { - printk(KERN_INFO "%s: setting TX AntSel failed\n", - local->dev->name); - ret = -1; - } - } - - if (local->antsel_rx != HOSTAP_ANTSEL_DO_NOT_TOUCH && - local->func->cmd(local->dev, HFA384X_CMDCODE_READMIF, - HFA386X_CR_RX_CONFIGURE, - NULL, &val) == 0) { - val &= ~(BIT(1) | BIT(0)); - switch (local->antsel_rx) { - case HOSTAP_ANTSEL_DIVERSITY: - break; - case HOSTAP_ANTSEL_LOW: - val |= BIT(0); - break; - case HOSTAP_ANTSEL_HIGH: - val |= BIT(0) | BIT(1); - break; - } - - if (local->func->cmd(local->dev, HFA384X_CMDCODE_WRITEMIF, - HFA386X_CR_RX_CONFIGURE, &val, NULL)) { - printk(KERN_INFO "%s: setting RX AntSel failed\n", - local->dev->name); - ret = -1; - } - } - - return ret; -} - - -int hostap_set_roaming(local_info_t *local) -{ - u16 val; - - switch (local->host_roaming) { - case 1: - val = HFA384X_ROAMING_HOST; - break; - case 2: - val = HFA384X_ROAMING_DISABLED; - break; - case 0: - default: - val = HFA384X_ROAMING_FIRMWARE; - break; - } - - return hostap_set_word(local->dev, HFA384X_RID_CNFROAMINGMODE, val); -} - - -int hostap_set_auth_algs(local_info_t *local) -{ - int val = local->auth_algs; - /* At least STA f/w v0.6.2 seems to have issues with cnfAuthentication - * set to include both Open and Shared Key flags. It tries to use - * Shared Key authentication in that case even if WEP keys are not - * configured.. STA f/w v0.7.6 is able to handle such configuration, - * but it is unknown when this was fixed between 0.6.2 .. 0.7.6. */ - if (local->sta_fw_ver < PRISM2_FW_VER(0,7,0) && - val != PRISM2_AUTH_OPEN && val != PRISM2_AUTH_SHARED_KEY) - val = PRISM2_AUTH_OPEN; - - if (hostap_set_word(local->dev, HFA384X_RID_CNFAUTHENTICATION, val)) { - printk(KERN_INFO "%s: cnfAuthentication setting to 0x%x " - "failed\n", local->dev->name, local->auth_algs); - return -EINVAL; - } - - return 0; -} - - -void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx) -{ - u16 status, fc; - - status = __le16_to_cpu(rx->status); - - printk(KERN_DEBUG "%s: RX status=0x%04x (port=%d, type=%d, " - "fcserr=%d) silence=%d signal=%d rate=%d rxflow=%d; " - "jiffies=%ld\n", - name, status, (status >> 8) & 0x07, status >> 13, status & 1, - rx->silence, rx->signal, rx->rate, rx->rxflow, jiffies); - - fc = __le16_to_cpu(rx->frame_control); - printk(KERN_DEBUG " FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x " - "data_len=%d%s%s\n", - fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4, - __le16_to_cpu(rx->duration_id), __le16_to_cpu(rx->seq_ctrl), - __le16_to_cpu(rx->data_len), - fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", - fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : ""); - - printk(KERN_DEBUG " A1=" MACSTR " A2=" MACSTR " A3=" MACSTR " A4=" - MACSTR "\n", - MAC2STR(rx->addr1), MAC2STR(rx->addr2), MAC2STR(rx->addr3), - MAC2STR(rx->addr4)); - - printk(KERN_DEBUG " dst=" MACSTR " src=" MACSTR " len=%d\n", - MAC2STR(rx->dst_addr), MAC2STR(rx->src_addr), - __be16_to_cpu(rx->len)); -} - - -void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx) -{ - u16 fc; - - printk(KERN_DEBUG "%s: TX status=0x%04x retry_count=%d tx_rate=%d " - "tx_control=0x%04x; jiffies=%ld\n", - name, __le16_to_cpu(tx->status), tx->retry_count, tx->tx_rate, - __le16_to_cpu(tx->tx_control), jiffies); - - fc = __le16_to_cpu(tx->frame_control); - printk(KERN_DEBUG " FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x " - "data_len=%d%s%s\n", - fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4, - __le16_to_cpu(tx->duration_id), __le16_to_cpu(tx->seq_ctrl), - __le16_to_cpu(tx->data_len), - fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", - fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : ""); - - printk(KERN_DEBUG " A1=" MACSTR " A2=" MACSTR " A3=" MACSTR " A4=" - MACSTR "\n", - MAC2STR(tx->addr1), MAC2STR(tx->addr2), MAC2STR(tx->addr3), - MAC2STR(tx->addr4)); - - printk(KERN_DEBUG " dst=" MACSTR " src=" MACSTR " len=%d\n", - MAC2STR(tx->dst_addr), MAC2STR(tx->src_addr), - __be16_to_cpu(tx->len)); -} - - -int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr) -{ - memcpy(haddr, skb->mac.raw + 10, ETH_ALEN); /* addr2 */ - return ETH_ALEN; -} - - -int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr) -{ - if (*(u32 *)skb->mac.raw == LWNG_CAP_DID_BASE) { - memcpy(haddr, skb->mac.raw + - sizeof(struct linux_wlan_ng_prism_hdr) + 10, - ETH_ALEN); /* addr2 */ - } else { /* (*(u32 *)skb->mac.raw == htonl(LWNG_CAPHDR_VERSION)) */ - memcpy(haddr, skb->mac.raw + - sizeof(struct linux_wlan_ng_cap_hdr) + 10, - ETH_ALEN); /* addr2 */ - } - return ETH_ALEN; -} - - -int hostap_80211_get_hdrlen(u16 fc) -{ - int hdrlen = 24; - - switch (WLAN_FC_GET_TYPE(fc)) { - case IEEE80211_FTYPE_DATA: - if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) - hdrlen = 30; /* Addr4 */ - break; - case IEEE80211_FTYPE_CTL: - switch (WLAN_FC_GET_STYPE(fc)) { - case IEEE80211_STYPE_CTS: - case IEEE80211_STYPE_ACK: - hdrlen = 10; - break; - default: - hdrlen = 16; - break; - } - break; - } - - return hdrlen; -} - - -struct net_device_stats *hostap_get_stats(struct net_device *dev) -{ - struct hostap_interface *iface; - iface = netdev_priv(dev); - return &iface->stats; -} - - -static int prism2_close(struct net_device *dev) -{ - struct hostap_interface *iface; - local_info_t *local; - - PDEBUG(DEBUG_FLOW, "%s: prism2_close\n", dev->name); - - iface = netdev_priv(dev); - local = iface->local; - - if (dev == local->ddev) { - prism2_sta_deauth(local, WLAN_REASON_DEAUTH_LEAVING); - } -#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT - if (!local->hostapd && dev == local->dev && - (!local->func->card_present || local->func->card_present(local)) && - local->hw_ready && local->ap && local->iw_mode == IW_MODE_MASTER) - hostap_deauth_all_stas(dev, local->ap, 1); -#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ - - if (dev == local->dev) { - local->func->hw_shutdown(dev, HOSTAP_HW_ENABLE_CMDCOMPL); - } - - if (netif_running(dev)) { - netif_stop_queue(dev); - netif_device_detach(dev); - } - - flush_scheduled_work(); - - module_put(local->hw_module); - - local->num_dev_open--; - - if (dev != local->dev && local->dev->flags & IFF_UP && - local->master_dev_auto_open && local->num_dev_open == 1) { - /* Close master radio interface automatically if it was also - * opened automatically and we are now closing the last - * remaining non-master device. */ - dev_close(local->dev); - } - - return 0; -} - - -static int prism2_open(struct net_device *dev) -{ - struct hostap_interface *iface; - local_info_t *local; - - PDEBUG(DEBUG_FLOW, "%s: prism2_open\n", dev->name); - - iface = netdev_priv(dev); - local = iface->local; - - if (local->no_pri) { - printk(KERN_DEBUG "%s: could not set interface UP - no PRI " - "f/w\n", dev->name); - return 1; - } - - if ((local->func->card_present && !local->func->card_present(local)) || - local->hw_downloading) - return -ENODEV; - - if (!try_module_get(local->hw_module)) - return -ENODEV; - local->num_dev_open++; - - if (!local->dev_enabled && local->func->hw_enable(dev, 1)) { - printk(KERN_WARNING "%s: could not enable MAC port\n", - dev->name); - prism2_close(dev); - return 1; - } - if (!local->dev_enabled) - prism2_callback(local, PRISM2_CALLBACK_ENABLE); - local->dev_enabled = 1; - - if (dev != local->dev && !(local->dev->flags & IFF_UP)) { - /* Master radio interface is needed for all operation, so open - * it automatically when any virtual net_device is opened. */ - local->master_dev_auto_open = 1; - dev_open(local->dev); - } - - netif_device_attach(dev); - netif_start_queue(dev); - - return 0; -} - - -static int prism2_set_mac_address(struct net_device *dev, void *p) -{ - struct hostap_interface *iface; - local_info_t *local; - struct list_head *ptr; - struct sockaddr *addr = p; - - iface = netdev_priv(dev); - local = iface->local; - - if (local->func->set_rid(dev, HFA384X_RID_CNFOWNMACADDR, addr->sa_data, - ETH_ALEN) < 0 || local->func->reset_port(dev)) - return -EINVAL; - - read_lock_bh(&local->iface_lock); - list_for_each(ptr, &local->hostap_interfaces) { - iface = list_entry(ptr, struct hostap_interface, list); - memcpy(iface->dev->dev_addr, addr->sa_data, ETH_ALEN); - } - memcpy(local->dev->dev_addr, addr->sa_data, ETH_ALEN); - read_unlock_bh(&local->iface_lock); - - return 0; -} - - -/* TODO: to be further implemented as soon as Prism2 fully supports - * GroupAddresses and correct documentation is available */ -void hostap_set_multicast_list_queue(void *data) -{ - struct net_device *dev = (struct net_device *) data; - struct hostap_interface *iface; - local_info_t *local; - - iface = netdev_priv(dev); - local = iface->local; - if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, - local->is_promisc)) { - printk(KERN_INFO "%s: %sabling promiscuous mode failed\n", - dev->name, local->is_promisc ? "en" : "dis"); - } -} - - -static void hostap_set_multicast_list(struct net_device *dev) -{ -#if 0 - /* FIX: promiscuous mode seems to be causing a lot of problems with - * some station firmware versions (FCSErr frames, invalid MACPort, etc. - * corrupted incoming frames). This code is now commented out while the - * problems are investigated. */ - struct hostap_interface *iface; - local_info_t *local; - - iface = netdev_priv(dev); - local = iface->local; - if ((dev->flags & IFF_ALLMULTI) || (dev->flags & IFF_PROMISC)) { - local->is_promisc = 1; - } else { - local->is_promisc = 0; - } - - schedule_work(&local->set_multicast_list_queue); -#endif -} - - -static int prism2_change_mtu(struct net_device *dev, int new_mtu) -{ - if (new_mtu < PRISM2_MIN_MTU || new_mtu > PRISM2_MAX_MTU) - return -EINVAL; - - dev->mtu = new_mtu; - return 0; -} - - -static void prism2_tx_timeout(struct net_device *dev) -{ - struct hostap_interface *iface; - local_info_t *local; - struct hfa384x_regs regs; - - iface = netdev_priv(dev); - local = iface->local; - - printk(KERN_WARNING "%s Tx timed out! Resetting card\n", dev->name); - netif_stop_queue(local->dev); - - local->func->read_regs(dev, ®s); - printk(KERN_DEBUG "%s: CMD=%04x EVSTAT=%04x " - "OFFSET0=%04x OFFSET1=%04x SWSUPPORT0=%04x\n", - dev->name, regs.cmd, regs.evstat, regs.offset0, regs.offset1, - regs.swsupport0); - - local->func->schedule_reset(local); -} - - -void hostap_setup_dev(struct net_device *dev, local_info_t *local, - int main_dev) -{ - struct hostap_interface *iface; - - iface = netdev_priv(dev); - ether_setup(dev); - - /* kernel callbacks */ - dev->get_stats = hostap_get_stats; - if (iface) { - /* Currently, we point to the proper spy_data only on - * the main_dev. This could be fixed. Jean II */ - iface->wireless_data.spy_data = &iface->spy_data; - dev->wireless_data = &iface->wireless_data; - } - dev->wireless_handlers = - (struct iw_handler_def *) &hostap_iw_handler_def; - dev->do_ioctl = hostap_ioctl; - dev->open = prism2_open; - dev->stop = prism2_close; - dev->hard_start_xmit = hostap_data_start_xmit; - dev->set_mac_address = prism2_set_mac_address; - dev->set_multicast_list = hostap_set_multicast_list; - dev->change_mtu = prism2_change_mtu; - dev->tx_timeout = prism2_tx_timeout; - dev->watchdog_timeo = TX_TIMEOUT; - - dev->mtu = local->mtu; - if (!main_dev) { - /* use main radio device queue */ - dev->tx_queue_len = 0; - } - - SET_ETHTOOL_OPS(dev, &prism2_ethtool_ops); - - netif_stop_queue(dev); -} - - -static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked) -{ - struct net_device *dev = local->dev; - - if (local->apdev) - return -EEXIST; - - printk(KERN_DEBUG "%s: enabling hostapd mode\n", dev->name); - - local->apdev = hostap_add_interface(local, HOSTAP_INTERFACE_AP, - rtnl_locked, local->ddev->name, - "ap"); - if (local->apdev == NULL) - return -ENOMEM; - - local->apdev->hard_start_xmit = hostap_mgmt_start_xmit; - local->apdev->type = ARPHRD_IEEE80211; - local->apdev->hard_header_parse = hostap_80211_header_parse; - - return 0; -} - - -static int hostap_disable_hostapd(local_info_t *local, int rtnl_locked) -{ - struct net_device *dev = local->dev; - - printk(KERN_DEBUG "%s: disabling hostapd mode\n", dev->name); - - hostap_remove_interface(local->apdev, rtnl_locked, 1); - local->apdev = NULL; - - return 0; -} - - -static int hostap_enable_hostapd_sta(local_info_t *local, int rtnl_locked) -{ - struct net_device *dev = local->dev; - - if (local->stadev) - return -EEXIST; - - printk(KERN_DEBUG "%s: enabling hostapd STA mode\n", dev->name); - - local->stadev = hostap_add_interface(local, HOSTAP_INTERFACE_STA, - rtnl_locked, local->ddev->name, - "sta"); - if (local->stadev == NULL) - return -ENOMEM; - - return 0; -} - - -static int hostap_disable_hostapd_sta(local_info_t *local, int rtnl_locked) -{ - struct net_device *dev = local->dev; - - printk(KERN_DEBUG "%s: disabling hostapd mode\n", dev->name); - - hostap_remove_interface(local->stadev, rtnl_locked, 1); - local->stadev = NULL; - - return 0; -} - - -int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked) -{ - int ret; - - if (val < 0 || val > 1) - return -EINVAL; - - if (local->hostapd == val) - return 0; - - if (val) { - ret = hostap_enable_hostapd(local, rtnl_locked); - if (ret == 0) - local->hostapd = 1; - } else { - local->hostapd = 0; - ret = hostap_disable_hostapd(local, rtnl_locked); - if (ret != 0) - local->hostapd = 1; - } - - return ret; -} - - -int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked) -{ - int ret; - - if (val < 0 || val > 1) - return -EINVAL; - - if (local->hostapd_sta == val) - return 0; - - if (val) { - ret = hostap_enable_hostapd_sta(local, rtnl_locked); - if (ret == 0) - local->hostapd_sta = 1; - } else { - local->hostapd_sta = 0; - ret = hostap_disable_hostapd_sta(local, rtnl_locked); - if (ret != 0) - local->hostapd_sta = 1; - } - - - return ret; -} - - -int prism2_update_comms_qual(struct net_device *dev) -{ - struct hostap_interface *iface; - local_info_t *local; - int ret = 0; - struct hfa384x_comms_quality sq; - - iface = netdev_priv(dev); - local = iface->local; - if (!local->sta_fw_ver) - ret = -1; - else if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1)) { - if (local->func->get_rid(local->dev, - HFA384X_RID_DBMCOMMSQUALITY, - &sq, sizeof(sq), 1) >= 0) { - local->comms_qual = (s16) le16_to_cpu(sq.comm_qual); - local->avg_signal = (s16) le16_to_cpu(sq.signal_level); - local->avg_noise = (s16) le16_to_cpu(sq.noise_level); - local->last_comms_qual_update = jiffies; - } else - ret = -1; - } else { - if (local->func->get_rid(local->dev, HFA384X_RID_COMMSQUALITY, - &sq, sizeof(sq), 1) >= 0) { - local->comms_qual = le16_to_cpu(sq.comm_qual); - local->avg_signal = HFA384X_LEVEL_TO_dBm( - le16_to_cpu(sq.signal_level)); - local->avg_noise = HFA384X_LEVEL_TO_dBm( - le16_to_cpu(sq.noise_level)); - local->last_comms_qual_update = jiffies; - } else - ret = -1; - } - - return ret; -} - - -int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u16 stype, - u8 *body, size_t bodylen) -{ - struct sk_buff *skb; - struct hostap_ieee80211_mgmt *mgmt; - struct hostap_skb_tx_data *meta; - struct net_device *dev = local->dev; - - skb = dev_alloc_skb(IEEE80211_MGMT_HDR_LEN + bodylen); - if (skb == NULL) - return -ENOMEM; - - mgmt = (struct hostap_ieee80211_mgmt *) - skb_put(skb, IEEE80211_MGMT_HDR_LEN); - memset(mgmt, 0, IEEE80211_MGMT_HDR_LEN); - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); - memcpy(mgmt->da, dst, ETH_ALEN); - memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); - memcpy(mgmt->bssid, dst, ETH_ALEN); - if (body) - memcpy(skb_put(skb, bodylen), body, bodylen); - - meta = (struct hostap_skb_tx_data *) skb->cb; - memset(meta, 0, sizeof(*meta)); - meta->magic = HOSTAP_SKB_TX_DATA_MAGIC; - meta->iface = netdev_priv(dev); - - skb->dev = dev; - skb->mac.raw = skb->nh.raw = skb->data; - dev_queue_xmit(skb); - - return 0; -} - - -int prism2_sta_deauth(local_info_t *local, u16 reason) -{ - union iwreq_data wrqu; - int ret; - - if (local->iw_mode != IW_MODE_INFRA || - memcmp(local->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0 || - memcmp(local->bssid, "\x44\x44\x44\x44\x44\x44", ETH_ALEN) == 0) - return 0; - - reason = cpu_to_le16(reason); - ret = prism2_sta_send_mgmt(local, local->bssid, IEEE80211_STYPE_DEAUTH, - (u8 *) &reason, 2); - memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); - wireless_send_event(local->dev, SIOCGIWAP, &wrqu, NULL); - return ret; -} - - -struct proc_dir_entry *hostap_proc; - -static int __init hostap_init(void) -{ - if (proc_net != NULL) { - hostap_proc = proc_mkdir("hostap", proc_net); - if (!hostap_proc) - printk(KERN_WARNING "Failed to mkdir " - "/proc/net/hostap\n"); - } else - hostap_proc = NULL; - - return 0; -} - - -static void __exit hostap_exit(void) -{ - if (hostap_proc != NULL) { - hostap_proc = NULL; - remove_proc_entry("hostap", proc_net); - } -} - - -EXPORT_SYMBOL(hostap_set_word); -EXPORT_SYMBOL(hostap_set_string); -EXPORT_SYMBOL(hostap_get_porttype); -EXPORT_SYMBOL(hostap_set_encryption); -EXPORT_SYMBOL(hostap_set_antsel); -EXPORT_SYMBOL(hostap_set_roaming); -EXPORT_SYMBOL(hostap_set_auth_algs); -EXPORT_SYMBOL(hostap_dump_rx_header); -EXPORT_SYMBOL(hostap_dump_tx_header); -EXPORT_SYMBOL(hostap_80211_header_parse); -EXPORT_SYMBOL(hostap_80211_prism_header_parse); -EXPORT_SYMBOL(hostap_80211_get_hdrlen); -EXPORT_SYMBOL(hostap_get_stats); -EXPORT_SYMBOL(hostap_setup_dev); -EXPORT_SYMBOL(hostap_proc); -EXPORT_SYMBOL(hostap_set_multicast_list_queue); -EXPORT_SYMBOL(hostap_set_hostapd); -EXPORT_SYMBOL(hostap_set_hostapd_sta); -EXPORT_SYMBOL(hostap_add_interface); -EXPORT_SYMBOL(hostap_remove_interface); -EXPORT_SYMBOL(prism2_update_comms_qual); - -module_init(hostap_init); -module_exit(hostap_exit); diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c new file mode 100644 index 0000000..3d2ea61 --- /dev/null +++ b/drivers/net/wireless/hostap/hostap_main.c @@ -0,0 +1,1191 @@ +/* + * Host AP (software wireless LAN access point) driver for + * Intersil Prism2/2.5/3 - hostap.o module, common routines + * + * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen + * + * Copyright (c) 2002-2005, Jouni Malinen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. See README and COPYING for + * more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "hostap_wlan.h" +#include "hostap_80211.h" +#include "hostap_ap.h" +#include "hostap.h" + +MODULE_AUTHOR("Jouni Malinen"); +MODULE_DESCRIPTION("Host AP common routines"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(PRISM2_VERSION); + +#define TX_TIMEOUT (2 * HZ) + +#define PRISM2_MAX_FRAME_SIZE 2304 +#define PRISM2_MIN_MTU 256 +/* FIX: */ +#define PRISM2_MAX_MTU (PRISM2_MAX_FRAME_SIZE - (6 /* LLC */ + 8 /* WEP */)) + + +/* hostap.c */ +static int prism2_wds_add(local_info_t *local, u8 *remote_addr, + int rtnl_locked); +static int prism2_wds_del(local_info_t *local, u8 *remote_addr, + int rtnl_locked, int do_not_remove); + +/* hostap_ap.c */ +static int prism2_ap_get_sta_qual(local_info_t *local, struct sockaddr addr[], + struct iw_quality qual[], int buf_size, + int aplist); +static int prism2_ap_translate_scan(struct net_device *dev, char *buffer); +static int prism2_hostapd(struct ap_data *ap, + struct prism2_hostapd_param *param); +static void * ap_crypt_get_ptrs(struct ap_data *ap, u8 *addr, int permanent, + struct ieee80211_crypt_data ***crypt); +static void ap_control_kickall(struct ap_data *ap); +#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT +static int ap_control_add_mac(struct mac_restrictions *mac_restrictions, + u8 *mac); +static int ap_control_del_mac(struct mac_restrictions *mac_restrictions, + u8 *mac); +static void ap_control_flush_macs(struct mac_restrictions *mac_restrictions); +static int ap_control_kick_mac(struct ap_data *ap, struct net_device *dev, + u8 *mac); +#endif /* !PRISM2_NO_KERNEL_IEEE80211_MGMT */ + + +static const long freq_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, + 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; +#define FREQ_COUNT (sizeof(freq_list) / sizeof(freq_list[0])) + + +/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ +/* Ethernet-II snap header (RFC1042 for most EtherTypes) */ +static unsigned char rfc1042_header[] = +{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; +/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ +static unsigned char bridge_tunnel_header[] = +{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; +/* No encapsulation header if EtherType < 0x600 (=length) */ + + +/* FIX: these could be compiled separately and linked together to hostap.o */ +#include "hostap_ap.c" +#include "hostap_info.c" +#include "hostap_ioctl.c" +#include "hostap_proc.c" +#include "hostap_80211_rx.c" +#include "hostap_80211_tx.c" + + +struct net_device * hostap_add_interface(struct local_info *local, + int type, int rtnl_locked, + const char *prefix, + const char *name) +{ + struct net_device *dev, *mdev; + struct hostap_interface *iface; + int ret; + + dev = alloc_etherdev(sizeof(struct hostap_interface)); + if (dev == NULL) + return NULL; + + iface = netdev_priv(dev); + iface->dev = dev; + iface->local = local; + iface->type = type; + list_add(&iface->list, &local->hostap_interfaces); + + mdev = local->dev; + memcpy(dev->dev_addr, mdev->dev_addr, ETH_ALEN); + dev->base_addr = mdev->base_addr; + dev->irq = mdev->irq; + dev->mem_start = mdev->mem_start; + dev->mem_end = mdev->mem_end; + + hostap_setup_dev(dev, local, 0); + dev->destructor = free_netdev; + + sprintf(dev->name, "%s%s", prefix, name); + if (!rtnl_locked) + rtnl_lock(); + + ret = 0; + if (strchr(dev->name, '%')) + ret = dev_alloc_name(dev, dev->name); + + SET_NETDEV_DEV(dev, mdev->class_dev.dev); + if (ret >= 0) + ret = register_netdevice(dev); + + if (!rtnl_locked) + rtnl_unlock(); + + if (ret < 0) { + printk(KERN_WARNING "%s: failed to add new netdevice!\n", + dev->name); + free_netdev(dev); + return NULL; + } + + printk(KERN_DEBUG "%s: registered netdevice %s\n", + mdev->name, dev->name); + + return dev; +} + + +void hostap_remove_interface(struct net_device *dev, int rtnl_locked, + int remove_from_list) +{ + struct hostap_interface *iface; + + if (!dev) + return; + + iface = netdev_priv(dev); + + if (remove_from_list) { + list_del(&iface->list); + } + + if (dev == iface->local->ddev) + iface->local->ddev = NULL; + else if (dev == iface->local->apdev) + iface->local->apdev = NULL; + else if (dev == iface->local->stadev) + iface->local->stadev = NULL; + + if (rtnl_locked) + unregister_netdevice(dev); + else + unregister_netdev(dev); + + /* dev->destructor = free_netdev() will free the device data, including + * private data, when removing the device */ +} + + +static inline int prism2_wds_special_addr(u8 *addr) +{ + if (addr[0] || addr[1] || addr[2] || addr[3] || addr[4] || addr[5]) + return 0; + + return 1; +} + + +static int prism2_wds_add(local_info_t *local, u8 *remote_addr, + int rtnl_locked) +{ + struct net_device *dev; + struct list_head *ptr; + struct hostap_interface *iface, *empty, *match; + + empty = match = NULL; + read_lock_bh(&local->iface_lock); + list_for_each(ptr, &local->hostap_interfaces) { + iface = list_entry(ptr, struct hostap_interface, list); + if (iface->type != HOSTAP_INTERFACE_WDS) + continue; + + if (prism2_wds_special_addr(iface->u.wds.remote_addr)) + empty = iface; + else if (memcmp(iface->u.wds.remote_addr, remote_addr, + ETH_ALEN) == 0) { + match = iface; + break; + } + } + if (!match && empty && !prism2_wds_special_addr(remote_addr)) { + /* take pre-allocated entry into use */ + memcpy(empty->u.wds.remote_addr, remote_addr, ETH_ALEN); + read_unlock_bh(&local->iface_lock); + printk(KERN_DEBUG "%s: using pre-allocated WDS netdevice %s\n", + local->dev->name, empty->dev->name); + return 0; + } + read_unlock_bh(&local->iface_lock); + + if (!prism2_wds_special_addr(remote_addr)) { + if (match) + return -EEXIST; + hostap_add_sta(local->ap, remote_addr); + } + + if (local->wds_connections >= local->wds_max_connections) + return -ENOBUFS; + + /* verify that there is room for wds# postfix in the interface name */ + if (strlen(local->dev->name) > IFNAMSIZ - 5) { + printk(KERN_DEBUG "'%s' too long base device name\n", + local->dev->name); + return -EINVAL; + } + + dev = hostap_add_interface(local, HOSTAP_INTERFACE_WDS, rtnl_locked, + local->ddev->name, "wds%d"); + if (dev == NULL) + return -ENOMEM; + + iface = netdev_priv(dev); + memcpy(iface->u.wds.remote_addr, remote_addr, ETH_ALEN); + + local->wds_connections++; + + return 0; +} + + +static int prism2_wds_del(local_info_t *local, u8 *remote_addr, + int rtnl_locked, int do_not_remove) +{ + unsigned long flags; + struct list_head *ptr; + struct hostap_interface *iface, *selected = NULL; + + write_lock_irqsave(&local->iface_lock, flags); + list_for_each(ptr, &local->hostap_interfaces) { + iface = list_entry(ptr, struct hostap_interface, list); + if (iface->type != HOSTAP_INTERFACE_WDS) + continue; + + if (memcmp(iface->u.wds.remote_addr, remote_addr, + ETH_ALEN) == 0) { + selected = iface; + break; + } + } + if (selected && !do_not_remove) + list_del(&selected->list); + write_unlock_irqrestore(&local->iface_lock, flags); + + if (selected) { + if (do_not_remove) + memset(selected->u.wds.remote_addr, 0, ETH_ALEN); + else { + hostap_remove_interface(selected->dev, rtnl_locked, 0); + local->wds_connections--; + } + } + + return selected ? 0 : -ENODEV; +} + + +u16 hostap_tx_callback_register(local_info_t *local, + void (*func)(struct sk_buff *, int ok, void *), + void *data) +{ + unsigned long flags; + struct hostap_tx_callback_info *entry; + + entry = (struct hostap_tx_callback_info *) kmalloc(sizeof(*entry), + GFP_ATOMIC); + if (entry == NULL) + return 0; + + entry->func = func; + entry->data = data; + + spin_lock_irqsave(&local->lock, flags); + entry->idx = local->tx_callback ? local->tx_callback->idx + 1 : 1; + entry->next = local->tx_callback; + local->tx_callback = entry; + spin_unlock_irqrestore(&local->lock, flags); + + return entry->idx; +} + + +int hostap_tx_callback_unregister(local_info_t *local, u16 idx) +{ + unsigned long flags; + struct hostap_tx_callback_info *cb, *prev = NULL; + + spin_lock_irqsave(&local->lock, flags); + cb = local->tx_callback; + while (cb != NULL && cb->idx != idx) { + prev = cb; + cb = cb->next; + } + if (cb) { + if (prev == NULL) + local->tx_callback = cb->next; + else + prev->next = cb->next; + kfree(cb); + } + spin_unlock_irqrestore(&local->lock, flags); + + return cb ? 0 : -1; +} + + +/* val is in host byte order */ +int hostap_set_word(struct net_device *dev, int rid, u16 val) +{ + struct hostap_interface *iface; + u16 tmp = cpu_to_le16(val); + iface = netdev_priv(dev); + return iface->local->func->set_rid(dev, rid, &tmp, 2); +} + + +int hostap_set_string(struct net_device *dev, int rid, const char *val) +{ + struct hostap_interface *iface; + char buf[MAX_SSID_LEN + 2]; + int len; + + iface = netdev_priv(dev); + len = strlen(val); + if (len > MAX_SSID_LEN) + return -1; + memset(buf, 0, sizeof(buf)); + buf[0] = len; /* little endian 16 bit word */ + memcpy(buf + 2, val, len); + + return iface->local->func->set_rid(dev, rid, &buf, MAX_SSID_LEN + 2); +} + + +u16 hostap_get_porttype(local_info_t *local) +{ + if (local->iw_mode == IW_MODE_ADHOC && local->pseudo_adhoc) + return HFA384X_PORTTYPE_PSEUDO_IBSS; + if (local->iw_mode == IW_MODE_ADHOC) + return HFA384X_PORTTYPE_IBSS; + if (local->iw_mode == IW_MODE_INFRA) + return HFA384X_PORTTYPE_BSS; + if (local->iw_mode == IW_MODE_REPEAT) + return HFA384X_PORTTYPE_WDS; + if (local->iw_mode == IW_MODE_MONITOR) + return HFA384X_PORTTYPE_PSEUDO_IBSS; + return HFA384X_PORTTYPE_HOSTAP; +} + + +int hostap_set_encryption(local_info_t *local) +{ + u16 val, old_val; + int i, keylen, len, idx; + char keybuf[WEP_KEY_LEN + 1]; + enum { NONE, WEP, OTHER } encrypt_type; + + idx = local->tx_keyidx; + if (local->crypt[idx] == NULL || local->crypt[idx]->ops == NULL) + encrypt_type = NONE; + else if (strcmp(local->crypt[idx]->ops->name, "WEP") == 0) + encrypt_type = WEP; + else + encrypt_type = OTHER; + + if (local->func->get_rid(local->dev, HFA384X_RID_CNFWEPFLAGS, &val, 2, + 1) < 0) { + printk(KERN_DEBUG "Could not read current WEP flags.\n"); + goto fail; + } + le16_to_cpus(&val); + old_val = val; + + if (encrypt_type != NONE || local->privacy_invoked) + val |= HFA384X_WEPFLAGS_PRIVACYINVOKED; + else + val &= ~HFA384X_WEPFLAGS_PRIVACYINVOKED; + + if (local->open_wep || encrypt_type == NONE || + ((local->ieee_802_1x || local->wpa) && local->host_decrypt)) + val &= ~HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED; + else + val |= HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED; + + if ((encrypt_type != NONE || local->privacy_invoked) && + (encrypt_type == OTHER || local->host_encrypt)) + val |= HFA384X_WEPFLAGS_HOSTENCRYPT; + else + val &= ~HFA384X_WEPFLAGS_HOSTENCRYPT; + if ((encrypt_type != NONE || local->privacy_invoked) && + (encrypt_type == OTHER || local->host_decrypt)) + val |= HFA384X_WEPFLAGS_HOSTDECRYPT; + else + val &= ~HFA384X_WEPFLAGS_HOSTDECRYPT; + + if (val != old_val && + hostap_set_word(local->dev, HFA384X_RID_CNFWEPFLAGS, val)) { + printk(KERN_DEBUG "Could not write new WEP flags (0x%x)\n", + val); + goto fail; + } + + if (encrypt_type != WEP) + return 0; + + /* 104-bit support seems to require that all the keys are set to the + * same keylen */ + keylen = 6; /* first 5 octets */ + len = local->crypt[idx]->ops->get_key(keybuf, sizeof(keybuf), + NULL, local->crypt[idx]->priv); + if (idx >= 0 && idx < WEP_KEYS && len > 5) + keylen = WEP_KEY_LEN + 1; /* first 13 octets */ + + for (i = 0; i < WEP_KEYS; i++) { + memset(keybuf, 0, sizeof(keybuf)); + if (local->crypt[i]) { + (void) local->crypt[i]->ops->get_key( + keybuf, sizeof(keybuf), + NULL, local->crypt[i]->priv); + } + if (local->func->set_rid(local->dev, + HFA384X_RID_CNFDEFAULTKEY0 + i, + keybuf, keylen)) { + printk(KERN_DEBUG "Could not set key %d (len=%d)\n", + i, keylen); + goto fail; + } + } + if (hostap_set_word(local->dev, HFA384X_RID_CNFWEPDEFAULTKEYID, idx)) { + printk(KERN_DEBUG "Could not set default keyid %d\n", idx); + goto fail; + } + + return 0; + + fail: + printk(KERN_DEBUG "%s: encryption setup failed\n", local->dev->name); + return -1; +} + + +int hostap_set_antsel(local_info_t *local) +{ + u16 val; + int ret = 0; + + if (local->antsel_tx != HOSTAP_ANTSEL_DO_NOT_TOUCH && + local->func->cmd(local->dev, HFA384X_CMDCODE_READMIF, + HFA386X_CR_TX_CONFIGURE, + NULL, &val) == 0) { + val &= ~(BIT(2) | BIT(1)); + switch (local->antsel_tx) { + case HOSTAP_ANTSEL_DIVERSITY: + val |= BIT(1); + break; + case HOSTAP_ANTSEL_LOW: + break; + case HOSTAP_ANTSEL_HIGH: + val |= BIT(2); + break; + } + + if (local->func->cmd(local->dev, HFA384X_CMDCODE_WRITEMIF, + HFA386X_CR_TX_CONFIGURE, &val, NULL)) { + printk(KERN_INFO "%s: setting TX AntSel failed\n", + local->dev->name); + ret = -1; + } + } + + if (local->antsel_rx != HOSTAP_ANTSEL_DO_NOT_TOUCH && + local->func->cmd(local->dev, HFA384X_CMDCODE_READMIF, + HFA386X_CR_RX_CONFIGURE, + NULL, &val) == 0) { + val &= ~(BIT(1) | BIT(0)); + switch (local->antsel_rx) { + case HOSTAP_ANTSEL_DIVERSITY: + break; + case HOSTAP_ANTSEL_LOW: + val |= BIT(0); + break; + case HOSTAP_ANTSEL_HIGH: + val |= BIT(0) | BIT(1); + break; + } + + if (local->func->cmd(local->dev, HFA384X_CMDCODE_WRITEMIF, + HFA386X_CR_RX_CONFIGURE, &val, NULL)) { + printk(KERN_INFO "%s: setting RX AntSel failed\n", + local->dev->name); + ret = -1; + } + } + + return ret; +} + + +int hostap_set_roaming(local_info_t *local) +{ + u16 val; + + switch (local->host_roaming) { + case 1: + val = HFA384X_ROAMING_HOST; + break; + case 2: + val = HFA384X_ROAMING_DISABLED; + break; + case 0: + default: + val = HFA384X_ROAMING_FIRMWARE; + break; + } + + return hostap_set_word(local->dev, HFA384X_RID_CNFROAMINGMODE, val); +} + + +int hostap_set_auth_algs(local_info_t *local) +{ + int val = local->auth_algs; + /* At least STA f/w v0.6.2 seems to have issues with cnfAuthentication + * set to include both Open and Shared Key flags. It tries to use + * Shared Key authentication in that case even if WEP keys are not + * configured.. STA f/w v0.7.6 is able to handle such configuration, + * but it is unknown when this was fixed between 0.6.2 .. 0.7.6. */ + if (local->sta_fw_ver < PRISM2_FW_VER(0,7,0) && + val != PRISM2_AUTH_OPEN && val != PRISM2_AUTH_SHARED_KEY) + val = PRISM2_AUTH_OPEN; + + if (hostap_set_word(local->dev, HFA384X_RID_CNFAUTHENTICATION, val)) { + printk(KERN_INFO "%s: cnfAuthentication setting to 0x%x " + "failed\n", local->dev->name, local->auth_algs); + return -EINVAL; + } + + return 0; +} + + +void hostap_dump_rx_header(const char *name, const struct hfa384x_rx_frame *rx) +{ + u16 status, fc; + + status = __le16_to_cpu(rx->status); + + printk(KERN_DEBUG "%s: RX status=0x%04x (port=%d, type=%d, " + "fcserr=%d) silence=%d signal=%d rate=%d rxflow=%d; " + "jiffies=%ld\n", + name, status, (status >> 8) & 0x07, status >> 13, status & 1, + rx->silence, rx->signal, rx->rate, rx->rxflow, jiffies); + + fc = __le16_to_cpu(rx->frame_control); + printk(KERN_DEBUG " FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x " + "data_len=%d%s%s\n", + fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4, + __le16_to_cpu(rx->duration_id), __le16_to_cpu(rx->seq_ctrl), + __le16_to_cpu(rx->data_len), + fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", + fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : ""); + + printk(KERN_DEBUG " A1=" MACSTR " A2=" MACSTR " A3=" MACSTR " A4=" + MACSTR "\n", + MAC2STR(rx->addr1), MAC2STR(rx->addr2), MAC2STR(rx->addr3), + MAC2STR(rx->addr4)); + + printk(KERN_DEBUG " dst=" MACSTR " src=" MACSTR " len=%d\n", + MAC2STR(rx->dst_addr), MAC2STR(rx->src_addr), + __be16_to_cpu(rx->len)); +} + + +void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx) +{ + u16 fc; + + printk(KERN_DEBUG "%s: TX status=0x%04x retry_count=%d tx_rate=%d " + "tx_control=0x%04x; jiffies=%ld\n", + name, __le16_to_cpu(tx->status), tx->retry_count, tx->tx_rate, + __le16_to_cpu(tx->tx_control), jiffies); + + fc = __le16_to_cpu(tx->frame_control); + printk(KERN_DEBUG " FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x " + "data_len=%d%s%s\n", + fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4, + __le16_to_cpu(tx->duration_id), __le16_to_cpu(tx->seq_ctrl), + __le16_to_cpu(tx->data_len), + fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", + fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : ""); + + printk(KERN_DEBUG " A1=" MACSTR " A2=" MACSTR " A3=" MACSTR " A4=" + MACSTR "\n", + MAC2STR(tx->addr1), MAC2STR(tx->addr2), MAC2STR(tx->addr3), + MAC2STR(tx->addr4)); + + printk(KERN_DEBUG " dst=" MACSTR " src=" MACSTR " len=%d\n", + MAC2STR(tx->dst_addr), MAC2STR(tx->src_addr), + __be16_to_cpu(tx->len)); +} + + +int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr) +{ + memcpy(haddr, skb->mac.raw + 10, ETH_ALEN); /* addr2 */ + return ETH_ALEN; +} + + +int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr) +{ + if (*(u32 *)skb->mac.raw == LWNG_CAP_DID_BASE) { + memcpy(haddr, skb->mac.raw + + sizeof(struct linux_wlan_ng_prism_hdr) + 10, + ETH_ALEN); /* addr2 */ + } else { /* (*(u32 *)skb->mac.raw == htonl(LWNG_CAPHDR_VERSION)) */ + memcpy(haddr, skb->mac.raw + + sizeof(struct linux_wlan_ng_cap_hdr) + 10, + ETH_ALEN); /* addr2 */ + } + return ETH_ALEN; +} + + +int hostap_80211_get_hdrlen(u16 fc) +{ + int hdrlen = 24; + + switch (WLAN_FC_GET_TYPE(fc)) { + case IEEE80211_FTYPE_DATA: + if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) + hdrlen = 30; /* Addr4 */ + break; + case IEEE80211_FTYPE_CTL: + switch (WLAN_FC_GET_STYPE(fc)) { + case IEEE80211_STYPE_CTS: + case IEEE80211_STYPE_ACK: + hdrlen = 10; + break; + default: + hdrlen = 16; + break; + } + break; + } + + return hdrlen; +} + + +struct net_device_stats *hostap_get_stats(struct net_device *dev) +{ + struct hostap_interface *iface; + iface = netdev_priv(dev); + return &iface->stats; +} + + +static int prism2_close(struct net_device *dev) +{ + struct hostap_interface *iface; + local_info_t *local; + + PDEBUG(DEBUG_FLOW, "%s: prism2_close\n", dev->name); + + iface = netdev_priv(dev); + local = iface->local; + + if (dev == local->ddev) { + prism2_sta_deauth(local, WLAN_REASON_DEAUTH_LEAVING); + } +#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT + if (!local->hostapd && dev == local->dev && + (!local->func->card_present || local->func->card_present(local)) && + local->hw_ready && local->ap && local->iw_mode == IW_MODE_MASTER) + hostap_deauth_all_stas(dev, local->ap, 1); +#endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ + + if (dev == local->dev) { + local->func->hw_shutdown(dev, HOSTAP_HW_ENABLE_CMDCOMPL); + } + + if (netif_running(dev)) { + netif_stop_queue(dev); + netif_device_detach(dev); + } + + flush_scheduled_work(); + + module_put(local->hw_module); + + local->num_dev_open--; + + if (dev != local->dev && local->dev->flags & IFF_UP && + local->master_dev_auto_open && local->num_dev_open == 1) { + /* Close master radio interface automatically if it was also + * opened automatically and we are now closing the last + * remaining non-master device. */ + dev_close(local->dev); + } + + return 0; +} + + +static int prism2_open(struct net_device *dev) +{ + struct hostap_interface *iface; + local_info_t *local; + + PDEBUG(DEBUG_FLOW, "%s: prism2_open\n", dev->name); + + iface = netdev_priv(dev); + local = iface->local; + + if (local->no_pri) { + printk(KERN_DEBUG "%s: could not set interface UP - no PRI " + "f/w\n", dev->name); + return 1; + } + + if ((local->func->card_present && !local->func->card_present(local)) || + local->hw_downloading) + return -ENODEV; + + if (!try_module_get(local->hw_module)) + return -ENODEV; + local->num_dev_open++; + + if (!local->dev_enabled && local->func->hw_enable(dev, 1)) { + printk(KERN_WARNING "%s: could not enable MAC port\n", + dev->name); + prism2_close(dev); + return 1; + } + if (!local->dev_enabled) + prism2_callback(local, PRISM2_CALLBACK_ENABLE); + local->dev_enabled = 1; + + if (dev != local->dev && !(local->dev->flags & IFF_UP)) { + /* Master radio interface is needed for all operation, so open + * it automatically when any virtual net_device is opened. */ + local->master_dev_auto_open = 1; + dev_open(local->dev); + } + + netif_device_attach(dev); + netif_start_queue(dev); + + return 0; +} + + +static int prism2_set_mac_address(struct net_device *dev, void *p) +{ + struct hostap_interface *iface; + local_info_t *local; + struct list_head *ptr; + struct sockaddr *addr = p; + + iface = netdev_priv(dev); + local = iface->local; + + if (local->func->set_rid(dev, HFA384X_RID_CNFOWNMACADDR, addr->sa_data, + ETH_ALEN) < 0 || local->func->reset_port(dev)) + return -EINVAL; + + read_lock_bh(&local->iface_lock); + list_for_each(ptr, &local->hostap_interfaces) { + iface = list_entry(ptr, struct hostap_interface, list); + memcpy(iface->dev->dev_addr, addr->sa_data, ETH_ALEN); + } + memcpy(local->dev->dev_addr, addr->sa_data, ETH_ALEN); + read_unlock_bh(&local->iface_lock); + + return 0; +} + + +/* TODO: to be further implemented as soon as Prism2 fully supports + * GroupAddresses and correct documentation is available */ +void hostap_set_multicast_list_queue(void *data) +{ + struct net_device *dev = (struct net_device *) data; + struct hostap_interface *iface; + local_info_t *local; + + iface = netdev_priv(dev); + local = iface->local; + if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, + local->is_promisc)) { + printk(KERN_INFO "%s: %sabling promiscuous mode failed\n", + dev->name, local->is_promisc ? "en" : "dis"); + } +} + + +static void hostap_set_multicast_list(struct net_device *dev) +{ +#if 0 + /* FIX: promiscuous mode seems to be causing a lot of problems with + * some station firmware versions (FCSErr frames, invalid MACPort, etc. + * corrupted incoming frames). This code is now commented out while the + * problems are investigated. */ + struct hostap_interface *iface; + local_info_t *local; + + iface = netdev_priv(dev); + local = iface->local; + if ((dev->flags & IFF_ALLMULTI) || (dev->flags & IFF_PROMISC)) { + local->is_promisc = 1; + } else { + local->is_promisc = 0; + } + + schedule_work(&local->set_multicast_list_queue); +#endif +} + + +static int prism2_change_mtu(struct net_device *dev, int new_mtu) +{ + if (new_mtu < PRISM2_MIN_MTU || new_mtu > PRISM2_MAX_MTU) + return -EINVAL; + + dev->mtu = new_mtu; + return 0; +} + + +static void prism2_tx_timeout(struct net_device *dev) +{ + struct hostap_interface *iface; + local_info_t *local; + struct hfa384x_regs regs; + + iface = netdev_priv(dev); + local = iface->local; + + printk(KERN_WARNING "%s Tx timed out! Resetting card\n", dev->name); + netif_stop_queue(local->dev); + + local->func->read_regs(dev, ®s); + printk(KERN_DEBUG "%s: CMD=%04x EVSTAT=%04x " + "OFFSET0=%04x OFFSET1=%04x SWSUPPORT0=%04x\n", + dev->name, regs.cmd, regs.evstat, regs.offset0, regs.offset1, + regs.swsupport0); + + local->func->schedule_reset(local); +} + + +void hostap_setup_dev(struct net_device *dev, local_info_t *local, + int main_dev) +{ + struct hostap_interface *iface; + + iface = netdev_priv(dev); + ether_setup(dev); + + /* kernel callbacks */ + dev->get_stats = hostap_get_stats; + if (iface) { + /* Currently, we point to the proper spy_data only on + * the main_dev. This could be fixed. Jean II */ + iface->wireless_data.spy_data = &iface->spy_data; + dev->wireless_data = &iface->wireless_data; + } + dev->wireless_handlers = + (struct iw_handler_def *) &hostap_iw_handler_def; + dev->do_ioctl = hostap_ioctl; + dev->open = prism2_open; + dev->stop = prism2_close; + dev->hard_start_xmit = hostap_data_start_xmit; + dev->set_mac_address = prism2_set_mac_address; + dev->set_multicast_list = hostap_set_multicast_list; + dev->change_mtu = prism2_change_mtu; + dev->tx_timeout = prism2_tx_timeout; + dev->watchdog_timeo = TX_TIMEOUT; + + dev->mtu = local->mtu; + if (!main_dev) { + /* use main radio device queue */ + dev->tx_queue_len = 0; + } + + SET_ETHTOOL_OPS(dev, &prism2_ethtool_ops); + + netif_stop_queue(dev); +} + + +static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked) +{ + struct net_device *dev = local->dev; + + if (local->apdev) + return -EEXIST; + + printk(KERN_DEBUG "%s: enabling hostapd mode\n", dev->name); + + local->apdev = hostap_add_interface(local, HOSTAP_INTERFACE_AP, + rtnl_locked, local->ddev->name, + "ap"); + if (local->apdev == NULL) + return -ENOMEM; + + local->apdev->hard_start_xmit = hostap_mgmt_start_xmit; + local->apdev->type = ARPHRD_IEEE80211; + local->apdev->hard_header_parse = hostap_80211_header_parse; + + return 0; +} + + +static int hostap_disable_hostapd(local_info_t *local, int rtnl_locked) +{ + struct net_device *dev = local->dev; + + printk(KERN_DEBUG "%s: disabling hostapd mode\n", dev->name); + + hostap_remove_interface(local->apdev, rtnl_locked, 1); + local->apdev = NULL; + + return 0; +} + + +static int hostap_enable_hostapd_sta(local_info_t *local, int rtnl_locked) +{ + struct net_device *dev = local->dev; + + if (local->stadev) + return -EEXIST; + + printk(KERN_DEBUG "%s: enabling hostapd STA mode\n", dev->name); + + local->stadev = hostap_add_interface(local, HOSTAP_INTERFACE_STA, + rtnl_locked, local->ddev->name, + "sta"); + if (local->stadev == NULL) + return -ENOMEM; + + return 0; +} + + +static int hostap_disable_hostapd_sta(local_info_t *local, int rtnl_locked) +{ + struct net_device *dev = local->dev; + + printk(KERN_DEBUG "%s: disabling hostapd mode\n", dev->name); + + hostap_remove_interface(local->stadev, rtnl_locked, 1); + local->stadev = NULL; + + return 0; +} + + +int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked) +{ + int ret; + + if (val < 0 || val > 1) + return -EINVAL; + + if (local->hostapd == val) + return 0; + + if (val) { + ret = hostap_enable_hostapd(local, rtnl_locked); + if (ret == 0) + local->hostapd = 1; + } else { + local->hostapd = 0; + ret = hostap_disable_hostapd(local, rtnl_locked); + if (ret != 0) + local->hostapd = 1; + } + + return ret; +} + + +int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked) +{ + int ret; + + if (val < 0 || val > 1) + return -EINVAL; + + if (local->hostapd_sta == val) + return 0; + + if (val) { + ret = hostap_enable_hostapd_sta(local, rtnl_locked); + if (ret == 0) + local->hostapd_sta = 1; + } else { + local->hostapd_sta = 0; + ret = hostap_disable_hostapd_sta(local, rtnl_locked); + if (ret != 0) + local->hostapd_sta = 1; + } + + + return ret; +} + + +int prism2_update_comms_qual(struct net_device *dev) +{ + struct hostap_interface *iface; + local_info_t *local; + int ret = 0; + struct hfa384x_comms_quality sq; + + iface = netdev_priv(dev); + local = iface->local; + if (!local->sta_fw_ver) + ret = -1; + else if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1)) { + if (local->func->get_rid(local->dev, + HFA384X_RID_DBMCOMMSQUALITY, + &sq, sizeof(sq), 1) >= 0) { + local->comms_qual = (s16) le16_to_cpu(sq.comm_qual); + local->avg_signal = (s16) le16_to_cpu(sq.signal_level); + local->avg_noise = (s16) le16_to_cpu(sq.noise_level); + local->last_comms_qual_update = jiffies; + } else + ret = -1; + } else { + if (local->func->get_rid(local->dev, HFA384X_RID_COMMSQUALITY, + &sq, sizeof(sq), 1) >= 0) { + local->comms_qual = le16_to_cpu(sq.comm_qual); + local->avg_signal = HFA384X_LEVEL_TO_dBm( + le16_to_cpu(sq.signal_level)); + local->avg_noise = HFA384X_LEVEL_TO_dBm( + le16_to_cpu(sq.noise_level)); + local->last_comms_qual_update = jiffies; + } else + ret = -1; + } + + return ret; +} + + +int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u16 stype, + u8 *body, size_t bodylen) +{ + struct sk_buff *skb; + struct hostap_ieee80211_mgmt *mgmt; + struct hostap_skb_tx_data *meta; + struct net_device *dev = local->dev; + + skb = dev_alloc_skb(IEEE80211_MGMT_HDR_LEN + bodylen); + if (skb == NULL) + return -ENOMEM; + + mgmt = (struct hostap_ieee80211_mgmt *) + skb_put(skb, IEEE80211_MGMT_HDR_LEN); + memset(mgmt, 0, IEEE80211_MGMT_HDR_LEN); + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); + memcpy(mgmt->da, dst, ETH_ALEN); + memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN); + memcpy(mgmt->bssid, dst, ETH_ALEN); + if (body) + memcpy(skb_put(skb, bodylen), body, bodylen); + + meta = (struct hostap_skb_tx_data *) skb->cb; + memset(meta, 0, sizeof(*meta)); + meta->magic = HOSTAP_SKB_TX_DATA_MAGIC; + meta->iface = netdev_priv(dev); + + skb->dev = dev; + skb->mac.raw = skb->nh.raw = skb->data; + dev_queue_xmit(skb); + + return 0; +} + + +int prism2_sta_deauth(local_info_t *local, u16 reason) +{ + union iwreq_data wrqu; + int ret; + + if (local->iw_mode != IW_MODE_INFRA || + memcmp(local->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0 || + memcmp(local->bssid, "\x44\x44\x44\x44\x44\x44", ETH_ALEN) == 0) + return 0; + + reason = cpu_to_le16(reason); + ret = prism2_sta_send_mgmt(local, local->bssid, IEEE80211_STYPE_DEAUTH, + (u8 *) &reason, 2); + memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); + wireless_send_event(local->dev, SIOCGIWAP, &wrqu, NULL); + return ret; +} + + +struct proc_dir_entry *hostap_proc; + +static int __init hostap_init(void) +{ + if (proc_net != NULL) { + hostap_proc = proc_mkdir("hostap", proc_net); + if (!hostap_proc) + printk(KERN_WARNING "Failed to mkdir " + "/proc/net/hostap\n"); + } else + hostap_proc = NULL; + + return 0; +} + + +static void __exit hostap_exit(void) +{ + if (hostap_proc != NULL) { + hostap_proc = NULL; + remove_proc_entry("hostap", proc_net); + } +} + + +EXPORT_SYMBOL(hostap_set_word); +EXPORT_SYMBOL(hostap_set_string); +EXPORT_SYMBOL(hostap_get_porttype); +EXPORT_SYMBOL(hostap_set_encryption); +EXPORT_SYMBOL(hostap_set_antsel); +EXPORT_SYMBOL(hostap_set_roaming); +EXPORT_SYMBOL(hostap_set_auth_algs); +EXPORT_SYMBOL(hostap_dump_rx_header); +EXPORT_SYMBOL(hostap_dump_tx_header); +EXPORT_SYMBOL(hostap_80211_header_parse); +EXPORT_SYMBOL(hostap_80211_prism_header_parse); +EXPORT_SYMBOL(hostap_80211_get_hdrlen); +EXPORT_SYMBOL(hostap_get_stats); +EXPORT_SYMBOL(hostap_setup_dev); +EXPORT_SYMBOL(hostap_proc); +EXPORT_SYMBOL(hostap_set_multicast_list_queue); +EXPORT_SYMBOL(hostap_set_hostapd); +EXPORT_SYMBOL(hostap_set_hostapd_sta); +EXPORT_SYMBOL(hostap_add_interface); +EXPORT_SYMBOL(hostap_remove_interface); +EXPORT_SYMBOL(prism2_update_comms_qual); + +module_init(hostap_init); +module_exit(hostap_exit); -- cgit v1.1 From 7301c8d3a05dc52d33598364da7c4eb6ab6357eb Mon Sep 17 00:00:00 2001 From: Jody McIntyre Date: Fri, 18 Nov 2005 00:16:26 -0500 Subject: Remove amdtp, cmp drivers. Remove the Audio and Music Data Transmission Protocol driver and the Connection Management Procedures driver. These are incomplete, have never worked, and are better implemented in userland via raw1394 (see http://freebob.sourceforge.net/ for example.) Signed-off-by: Jody McIntyre Cc: Adrian Bunk --- Documentation/feature-removal-schedule.txt | 11 ----------- drivers/ieee1394/Kconfig | 23 ----------------------- drivers/ieee1394/Makefile | 2 -- drivers/ieee1394/ieee1394-ioctl.h | 8 -------- drivers/ieee1394/ohci1394.h | 4 ++-- 5 files changed, 2 insertions(+), 46 deletions(-) diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index b67189a..daaf03e 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt @@ -40,17 +40,6 @@ Who: Paul E. McKenney --------------------------- -What: IEEE1394 Audio and Music Data Transmission Protocol driver, - Connection Management Procedures driver -When: November 2005 -Files: drivers/ieee1394/{amdtp,cmp}* -Why: These are incomplete, have never worked, and are better implemented - in userland via raw1394 (see http://freebob.sourceforge.net/ for - example.) -Who: Jody McIntyre - ---------------------------- - What: raw1394: requests of type RAW1394_REQ_ISO_SEND, RAW1394_REQ_ISO_LISTEN When: November 2005 Why: Deprecated in favour of the new ioctl-based rawiso interface, which is diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig index 25103a0..39142e2 100644 --- a/drivers/ieee1394/Kconfig +++ b/drivers/ieee1394/Kconfig @@ -169,27 +169,4 @@ config IEEE1394_RAWIO To compile this driver as a module, say M here: the module will be called raw1394. -config IEEE1394_CMP - tristate "IEC61883-1 Plug support" - depends on IEEE1394 - help - This option enables the Connection Management Procedures - (IEC61883-1) driver, which implements input and output plugs. - - To compile this driver as a module, say M here: the - module will be called cmp. - -config IEEE1394_AMDTP - tristate "IEC61883-6 (Audio transmission) support" - depends on IEEE1394 && IEEE1394_OHCI1394 && IEEE1394_CMP - help - This option enables the Audio & Music Data Transmission Protocol - (IEC61883-6) driver, which implements audio transmission over - IEEE1394. - - The userspace interface is documented in amdtp.h. - - To compile this driver as a module, say M here: the - module will be called amdtp. - endmenu diff --git a/drivers/ieee1394/Makefile b/drivers/ieee1394/Makefile index e8b4d48..6f53611 100644 --- a/drivers/ieee1394/Makefile +++ b/drivers/ieee1394/Makefile @@ -14,8 +14,6 @@ obj-$(CONFIG_IEEE1394_RAWIO) += raw1394.o obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o -obj-$(CONFIG_IEEE1394_AMDTP) += amdtp.o -obj-$(CONFIG_IEEE1394_CMP) += cmp.o quiet_cmd_oui2c = OUI2C $@ cmd_oui2c = $(CONFIG_SHELL) $(srctree)/$(src)/oui2c.sh < $< > $@ diff --git a/drivers/ieee1394/ieee1394-ioctl.h b/drivers/ieee1394/ieee1394-ioctl.h index f92b566..1567039 100644 --- a/drivers/ieee1394/ieee1394-ioctl.h +++ b/drivers/ieee1394/ieee1394-ioctl.h @@ -7,14 +7,6 @@ #include #include - -/* AMDTP Gets 6 */ -#define AMDTP_IOC_CHANNEL _IOW('#', 0x00, struct amdtp_ioctl) -#define AMDTP_IOC_PLUG _IOW('#', 0x01, struct amdtp_ioctl) -#define AMDTP_IOC_PING _IOW('#', 0x02, struct amdtp_ioctl) -#define AMDTP_IOC_ZAP _IO ('#', 0x03) - - /* DV1394 Gets 10 */ /* Get the driver ready to transmit video. pass a struct dv1394_init* as diff --git a/drivers/ieee1394/ohci1394.h b/drivers/ieee1394/ohci1394.h index cc66c1c..7df0962 100644 --- a/drivers/ieee1394/ohci1394.h +++ b/drivers/ieee1394/ohci1394.h @@ -219,8 +219,8 @@ struct ti_ohci { int self_id_errors; - /* Tasklets for iso receive and transmit, used by video1394, - * amdtp and dv1394 */ + /* Tasklets for iso receive and transmit, used by video1394 + * and dv1394 */ struct list_head iso_tasklet_list; spinlock_t iso_tasklet_list_lock; -- cgit v1.1 From fed5eccdcf542742786701b2514b5cb7ab282b93 Mon Sep 17 00:00:00 2001 From: Ananda Raju Date: Mon, 14 Nov 2005 15:25:08 -0500 Subject: [PATCH] s2io: UFO support This patch implements the UFO support in S2io driver. This patch uses the UFO interface available in linux-2.6.15 kernel. Signed-off-by: Ananda Raju Signed-off-by: Jeff Garzik --- drivers/net/s2io.c | 186 +++++++++++++++++++++++++++++++---------------------- drivers/net/s2io.h | 3 + 2 files changed, 112 insertions(+), 77 deletions(-) diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index e57df8d..5303a96 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c @@ -66,7 +66,7 @@ #include "s2io.h" #include "s2io-regs.h" -#define DRV_VERSION "Version 2.0.9.3" +#define DRV_VERSION "Version 2.0.9.4" /* S2io Driver name & version. */ static char s2io_driver_name[] = "Neterion"; @@ -412,7 +412,7 @@ static int init_shared_mem(struct s2io_nic *nic) config->tx_cfg[i].fifo_len - 1; mac_control->fifos[i].fifo_no = i; mac_control->fifos[i].nic = nic; - mac_control->fifos[i].max_txds = MAX_SKB_FRAGS + 1; + mac_control->fifos[i].max_txds = MAX_SKB_FRAGS + 2; for (j = 0; j < page_num; j++) { int k = 0; @@ -459,6 +459,10 @@ static int init_shared_mem(struct s2io_nic *nic) } } + nic->ufo_in_band_v = kmalloc((sizeof(u64) * size), GFP_KERNEL); + if (!nic->ufo_in_band_v) + return -ENOMEM; + /* Allocation and initialization of RXDs in Rings */ size = 0; for (i = 0; i < config->rx_ring_num; i++) { @@ -731,6 +735,8 @@ static void free_shared_mem(struct s2io_nic *nic) mac_control->stats_mem, mac_control->stats_mem_phy); } + if (nic->ufo_in_band_v) + kfree(nic->ufo_in_band_v); } /** @@ -2003,6 +2009,49 @@ static int start_nic(struct s2io_nic *nic) return SUCCESS; } +/** + * s2io_txdl_getskb - Get the skb from txdl, unmap and return skb + */ +static struct sk_buff *s2io_txdl_getskb(fifo_info_t *fifo_data, TxD_t *txdlp, int get_off) +{ + nic_t *nic = fifo_data->nic; + struct sk_buff *skb; + TxD_t *txds; + u16 j, frg_cnt; + + txds = txdlp; + if (txds->Host_Control == (u64) nic->ufo_in_band_v) { + pci_unmap_single(nic->pdev, (dma_addr_t) + txds->Buffer_Pointer, sizeof(u64), + PCI_DMA_TODEVICE); + txds++; + } + + skb = (struct sk_buff *) ((unsigned long) + txds->Host_Control); + if (!skb) { + memset(txdlp, 0, (sizeof(TxD_t) * fifo_data->max_txds)); + return NULL; + } + pci_unmap_single(nic->pdev, (dma_addr_t) + txds->Buffer_Pointer, + skb->len - skb->data_len, + PCI_DMA_TODEVICE); + frg_cnt = skb_shinfo(skb)->nr_frags; + if (frg_cnt) { + txds++; + for (j = 0; j < frg_cnt; j++, txds++) { + skb_frag_t *frag = &skb_shinfo(skb)->frags[j]; + if (!txds->Buffer_Pointer) + break; + pci_unmap_page(nic->pdev, (dma_addr_t) + txds->Buffer_Pointer, + frag->size, PCI_DMA_TODEVICE); + } + } + txdlp->Host_Control = 0; + return(skb); +} /** * free_tx_buffers - Free all queued Tx buffers @@ -2020,7 +2069,7 @@ static void free_tx_buffers(struct s2io_nic *nic) int i, j; mac_info_t *mac_control; struct config_param *config; - int cnt = 0, frg_cnt; + int cnt = 0; mac_control = &nic->mac_control; config = &nic->config; @@ -2029,38 +2078,11 @@ static void free_tx_buffers(struct s2io_nic *nic) for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { txdp = (TxD_t *) mac_control->fifos[i].list_info[j]. list_virt_addr; - skb = - (struct sk_buff *) ((unsigned long) txdp-> - Host_Control); - if (skb == NULL) { - memset(txdp, 0, sizeof(TxD_t) * - config->max_txds); - continue; - } - frg_cnt = skb_shinfo(skb)->nr_frags; - pci_unmap_single(nic->pdev, (dma_addr_t) - txdp->Buffer_Pointer, - skb->len - skb->data_len, - PCI_DMA_TODEVICE); - if (frg_cnt) { - TxD_t *temp; - temp = txdp; - txdp++; - for (j = 0; j < frg_cnt; j++, txdp++) { - skb_frag_t *frag = - &skb_shinfo(skb)->frags[j]; - pci_unmap_page(nic->pdev, - (dma_addr_t) - txdp-> - Buffer_Pointer, - frag->size, - PCI_DMA_TODEVICE); - } - txdp = temp; + skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j); + if (skb) { + dev_kfree_skb(skb); + cnt++; } - dev_kfree_skb(skb); - memset(txdp, 0, sizeof(TxD_t) * config->max_txds); - cnt++; } DBG_PRINT(INTR_DBG, "%s:forcibly freeing %d skbs on FIFO%d\n", @@ -2661,7 +2683,6 @@ static void tx_intr_handler(fifo_info_t *fifo_data) tx_curr_get_info_t get_info, put_info; struct sk_buff *skb; TxD_t *txdlp; - u16 j, frg_cnt; get_info = fifo_data->tx_curr_get_info; put_info = fifo_data->tx_curr_put_info; @@ -2684,8 +2705,7 @@ to loss of link\n"); } } - skb = (struct sk_buff *) ((unsigned long) - txdlp->Host_Control); + skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset); if (skb == NULL) { DBG_PRINT(ERR_DBG, "%s: Null skb ", __FUNCTION__); @@ -2693,34 +2713,6 @@ to loss of link\n"); return; } - frg_cnt = skb_shinfo(skb)->nr_frags; - nic->tx_pkt_count++; - - pci_unmap_single(nic->pdev, (dma_addr_t) - txdlp->Buffer_Pointer, - skb->len - skb->data_len, - PCI_DMA_TODEVICE); - if (frg_cnt) { - TxD_t *temp; - temp = txdlp; - txdlp++; - for (j = 0; j < frg_cnt; j++, txdlp++) { - skb_frag_t *frag = - &skb_shinfo(skb)->frags[j]; - if (!txdlp->Buffer_Pointer) - break; - pci_unmap_page(nic->pdev, - (dma_addr_t) - txdlp-> - Buffer_Pointer, - frag->size, - PCI_DMA_TODEVICE); - } - txdlp = temp; - } - memset(txdlp, 0, - (sizeof(TxD_t) * fifo_data->max_txds)); - /* Updating the statistics block */ nic->stats.tx_bytes += skb->len; dev_kfree_skb_irq(skb); @@ -3527,6 +3519,8 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) return 0; } + txdp->Control_1 = 0; + txdp->Control_2 = 0; #ifdef NETIF_F_TSO mss = skb_shinfo(skb)->tso_size; if (mss) { @@ -3534,19 +3528,13 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) txdp->Control_1 |= TXD_TCP_LSO_MSS(mss); } #endif - - frg_cnt = skb_shinfo(skb)->nr_frags; - frg_len = skb->len - skb->data_len; - - txdp->Buffer_Pointer = pci_map_single - (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); - txdp->Host_Control = (unsigned long) skb; if (skb->ip_summed == CHECKSUM_HW) { txdp->Control_2 |= (TXD_TX_CKO_IPV4_EN | TXD_TX_CKO_TCP_EN | TXD_TX_CKO_UDP_EN); } - + txdp->Control_1 |= TXD_GATHER_CODE_FIRST; + txdp->Control_1 |= TXD_LIST_OWN_XENA; txdp->Control_2 |= config->tx_intr_type; if (sp->vlgrp && vlan_tx_tag_present(skb)) { @@ -3554,10 +3542,40 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) txdp->Control_2 |= TXD_VLAN_TAG(vlan_tag); } - txdp->Control_1 |= (TXD_BUFFER0_SIZE(frg_len) | - TXD_GATHER_CODE_FIRST); - txdp->Control_1 |= TXD_LIST_OWN_XENA; + frg_len = skb->len - skb->data_len; + if (skb_shinfo(skb)->ufo_size) { + int ufo_size; + + ufo_size = skb_shinfo(skb)->ufo_size; + ufo_size &= ~7; + txdp->Control_1 |= TXD_UFO_EN; + txdp->Control_1 |= TXD_UFO_MSS(ufo_size); + txdp->Control_1 |= TXD_BUFFER0_SIZE(8); +#ifdef __BIG_ENDIAN + sp->ufo_in_band_v[put_off] = + (u64)skb_shinfo(skb)->ip6_frag_id; +#else + sp->ufo_in_band_v[put_off] = + (u64)skb_shinfo(skb)->ip6_frag_id << 32; +#endif + txdp->Host_Control = (unsigned long)sp->ufo_in_band_v; + txdp->Buffer_Pointer = pci_map_single(sp->pdev, + sp->ufo_in_band_v, + sizeof(u64), PCI_DMA_TODEVICE); + txdp++; + txdp->Control_1 = 0; + txdp->Control_2 = 0; + } + + txdp->Buffer_Pointer = pci_map_single + (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE); + txdp->Host_Control = (unsigned long) skb; + txdp->Control_1 |= TXD_BUFFER0_SIZE(frg_len); + if (skb_shinfo(skb)->ufo_size) + txdp->Control_1 |= TXD_UFO_EN; + + frg_cnt = skb_shinfo(skb)->nr_frags; /* For fragmented SKB. */ for (i = 0; i < frg_cnt; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; @@ -3569,9 +3587,14 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) (sp->pdev, frag->page, frag->page_offset, frag->size, PCI_DMA_TODEVICE); txdp->Control_1 |= TXD_BUFFER0_SIZE(frag->size); + if (skb_shinfo(skb)->ufo_size) + txdp->Control_1 |= TXD_UFO_EN; } txdp->Control_1 |= TXD_GATHER_CODE_LAST; + if (skb_shinfo(skb)->ufo_size) + frg_cnt++; /* as Txd0 was used for inband header */ + tx_fifo = mac_control->tx_FIFO_start[queue]; val64 = mac_control->fifos[queue].list_info[put_off].list_phy_addr; writeq(val64, &tx_fifo->TxDL_Pointer); @@ -3583,6 +3606,8 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) if (mss) val64 |= TX_FIFO_SPECIAL_FUNC; #endif + if (skb_shinfo(skb)->ufo_size) + val64 |= TX_FIFO_SPECIAL_FUNC; writeq(val64, &tx_fifo->List_Control); mmiowb(); @@ -5190,6 +5215,8 @@ static struct ethtool_ops netdev_ethtool_ops = { .get_tso = ethtool_op_get_tso, .set_tso = ethtool_op_set_tso, #endif + .get_ufo = ethtool_op_get_ufo, + .set_ufo = ethtool_op_set_ufo, .self_test_count = s2io_ethtool_self_test_count, .self_test = s2io_ethtool_test, .get_strings = s2io_ethtool_get_strings, @@ -5941,7 +5968,8 @@ Defaulting to INTA\n"); break; } } - config->max_txds = MAX_SKB_FRAGS + 1; + /* + 2 because one Txd for skb->data and one Txd for UFO */ + config->max_txds = MAX_SKB_FRAGS + 2; /* Rx side parameters. */ if (rx_ring_sz[0] == 0) @@ -6035,6 +6063,10 @@ Defaulting to INTA\n"); #ifdef NETIF_F_TSO dev->features |= NETIF_F_TSO; #endif + if (sp->device_type & XFRAME_II_DEVICE) { + dev->features |= NETIF_F_UFO; + dev->features |= NETIF_F_HW_CSUM; + } dev->tx_timeout = &s2io_tx_watchdog; dev->watchdog_timeo = WATCH_DOG_TIMEOUT; diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h index 419aad7..852a6a8 100644 --- a/drivers/net/s2io.h +++ b/drivers/net/s2io.h @@ -393,7 +393,9 @@ typedef struct _TxD { #define TXD_GATHER_CODE_LAST BIT(23) #define TXD_TCP_LSO_EN BIT(30) #define TXD_UDP_COF_EN BIT(31) +#define TXD_UFO_EN BIT(31) | BIT(30) #define TXD_TCP_LSO_MSS(val) vBIT(val,34,14) +#define TXD_UFO_MSS(val) vBIT(val,34,14) #define TXD_BUFFER0_SIZE(val) vBIT(val,48,16) u64 Control_2; @@ -789,6 +791,7 @@ struct s2io_nic { spinlock_t rx_lock; atomic_t isr_cnt; + u64 *ufo_in_band_v; }; #define RESET_ERROR 1; -- cgit v1.1 From 7f7f53168dbee6d6a462acea666fddd18aad4f08 Mon Sep 17 00:00:00 2001 From: Andy Fleming Date: Fri, 11 Nov 2005 12:38:59 -0600 Subject: [PATCH] Gianfar update and sysfs support This seems to have gotten lost, so I'll resend. Signed-off-by: Andy Fleming * Added sysfs support to gianfar for modifying FIFO and stashing parameters * Updated driver to support 10 Mbit, full duplex operation * Improved comments throughout * Cleaned up and optimized offloading code * Fixed a bug where rx buffers were being improperly mapped and unmapped * (only manifested if cache-coherency was off) * Added support for using the eTSEC exact-match MAC registers * Bumped the version to 1.3 * Added support for distinguishing between reduced 100 and 10 Mbit modes * Modified default coalescing values to lower latency * Added documentation Signed-off-by: Jeff Garzik --- Documentation/networking/gianfar.txt | 72 ++++++++ drivers/net/Makefile | 5 +- drivers/net/gianfar.c | 231 +++++++++++++++++--------- drivers/net/gianfar.h | 69 ++++---- drivers/net/gianfar_ethtool.c | 2 +- drivers/net/gianfar_mii.h | 1 + drivers/net/gianfar_sysfs.c | 311 +++++++++++++++++++++++++++++++++++ 7 files changed, 579 insertions(+), 112 deletions(-) create mode 100644 Documentation/networking/gianfar.txt create mode 100644 drivers/net/gianfar_sysfs.c diff --git a/Documentation/networking/gianfar.txt b/Documentation/networking/gianfar.txt new file mode 100644 index 0000000..ad474ea --- /dev/null +++ b/Documentation/networking/gianfar.txt @@ -0,0 +1,72 @@ +The Gianfar Ethernet Driver +Sysfs File description + +Author: Andy Fleming +Updated: 2005-07-28 + +SYSFS + +Several of the features of the gianfar driver are controlled +through sysfs files. These are: + +bd_stash: +To stash RX Buffer Descriptors in the L2, echo 'on' or '1' to +bd_stash, echo 'off' or '0' to disable + +rx_stash_len: +To stash the first n bytes of the packet in L2, echo the number +of bytes to buf_stash_len. echo 0 to disable. + +WARNING: You could really screw these up if you set them too low or high! +fifo_threshold: +To change the number of bytes the controller needs in the +fifo before it starts transmission, echo the number of bytes to +fifo_thresh. Range should be 0-511. + +fifo_starve: +When the FIFO has less than this many bytes during a transmit, it +enters starve mode, and increases the priority of TX memory +transactions. To change, echo the number of bytes to +fifo_starve. Range should be 0-511. + +fifo_starve_off: +Once in starve mode, the FIFO remains there until it has this +many bytes. To change, echo the number of bytes to +fifo_starve_off. Range should be 0-511. + +CHECKSUM OFFLOADING + +The eTSEC controller (first included in parts from late 2005 like +the 8548) has the ability to perform TCP, UDP, and IP checksums +in hardware. The Linux kernel only offloads the TCP and UDP +checksums (and always performs the pseudo header checksums), so +the driver only supports checksumming for TCP/IP and UDP/IP +packets. Use ethtool to enable or disable this feature for RX +and TX. + +VLAN + +In order to use VLAN, please consult Linux documentation on +configuring VLANs. The gianfar driver supports hardware insertion and +extraction of VLAN headers, but not filtering. Filtering will be +done by the kernel. + +MULTICASTING + +The gianfar driver supports using the group hash table on the +TSEC (and the extended hash table on the eTSEC) for multicast +filtering. On the eTSEC, the exact-match MAC registers are used +before the hash tables. See Linux documentation on how to join +multicast groups. + +PADDING + +The gianfar driver supports padding received frames with 2 bytes +to align the IP header to a 16-byte boundary, when supported by +hardware. + +ETHTOOL + +The gianfar driver supports the use of ethtool for many +configuration options. You must run ethtool only on currently +open interfaces. See ethtool documentation for details. diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 27822a2..5056814 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -13,7 +13,10 @@ obj-$(CONFIG_CHELSIO_T1) += chelsio/ obj-$(CONFIG_BONDING) += bonding/ obj-$(CONFIG_GIANFAR) += gianfar_driver.o -gianfar_driver-objs := gianfar.o gianfar_ethtool.o gianfar_mii.o +gianfar_driver-objs := gianfar.o \ + gianfar_ethtool.o \ + gianfar_mii.o \ + gianfar_sysfs.o # # link order important here diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 0f030b7..146f951 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c @@ -2,7 +2,8 @@ * drivers/net/gianfar.c * * Gianfar Ethernet Driver - * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560 + * This driver is designed for the non-CPM ethernet controllers + * on the 85xx and 83xx family of integrated processors * Based on 8260_io/fcc_enet.c * * Author: Andy Fleming @@ -22,8 +23,6 @@ * B-V +1.62 * * Theory of operation - * This driver is designed for the non-CPM ethernet controllers - * on the 85xx and 83xx family of integrated processors * * The driver is initialized through platform_device. Structures which * define the configuration needed by the board are defined in a @@ -110,7 +109,7 @@ #endif const char gfar_driver_name[] = "Gianfar Ethernet"; -const char gfar_driver_version[] = "1.2"; +const char gfar_driver_version[] = "1.3"; static int gfar_enet_open(struct net_device *dev); static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev); @@ -139,6 +138,10 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int l static void gfar_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp); static void gfar_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid); +void gfar_halt(struct net_device *dev); +void gfar_start(struct net_device *dev); +static void gfar_clear_exact_match(struct net_device *dev); +static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr); extern struct ethtool_ops gfar_ethtool_ops; @@ -146,12 +149,10 @@ MODULE_AUTHOR("Freescale Semiconductor, Inc"); MODULE_DESCRIPTION("Gianfar Ethernet Driver"); MODULE_LICENSE("GPL"); -int gfar_uses_fcb(struct gfar_private *priv) +/* Returns 1 if incoming frames use an FCB */ +static inline int gfar_uses_fcb(struct gfar_private *priv) { - if (priv->vlan_enable || priv->rx_csum_enable) - return 1; - else - return 0; + return (priv->vlan_enable || priv->rx_csum_enable); } /* Set up the ethernet device structure, private data, @@ -320,15 +321,10 @@ static int gfar_probe(struct platform_device *pdev) else priv->padding = 0; - dev->hard_header_len += priv->padding; - if (dev->features & NETIF_F_IP_CSUM) dev->hard_header_len += GMAC_FCB_LEN; priv->rx_buffer_size = DEFAULT_RX_BUFFER_SIZE; -#ifdef CONFIG_GFAR_BUFSTASH - priv->rx_stash_size = STASH_LENGTH; -#endif priv->tx_ring_size = DEFAULT_TX_RING_SIZE; priv->rx_ring_size = DEFAULT_RX_RING_SIZE; @@ -350,6 +346,9 @@ static int gfar_probe(struct platform_device *pdev) goto register_fail; } + /* Create all the sysfs files */ + gfar_init_sysfs(dev); + /* Print out the device info */ printk(KERN_INFO DEVICE_NAME, dev->name); for (idx = 0; idx < 6; idx++) @@ -357,8 +356,7 @@ static int gfar_probe(struct platform_device *pdev) printk("\n"); /* Even more device info helps when determining which kernel */ - /* provided which set of benchmarks. Since this is global for all */ - /* devices, we only print it once */ + /* provided which set of benchmarks. */ #ifdef CONFIG_GFAR_NAPI printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name); #else @@ -463,19 +461,9 @@ static void init_registers(struct net_device *dev) /* Initialize the max receive buffer length */ gfar_write(&priv->regs->mrblr, priv->rx_buffer_size); -#ifdef CONFIG_GFAR_BUFSTASH - /* If we are stashing buffers, we need to set the - * extraction length to the size of the buffer */ - gfar_write(&priv->regs->attreli, priv->rx_stash_size << 16); -#endif - /* Initialize the Minimum Frame Length Register */ gfar_write(&priv->regs->minflr, MINFLR_INIT_SETTINGS); - /* Setup Attributes so that snooping is on for rx */ - gfar_write(&priv->regs->attr, ATTR_INIT_SETTINGS); - gfar_write(&priv->regs->attreli, ATTRELI_INIT_SETTINGS); - /* Assign the TBI an address which won't conflict with the PHYs */ gfar_write(&priv->regs->tbipa, TBIPA_VALUE); } @@ -577,8 +565,7 @@ static void free_skb_resources(struct gfar_private *priv) for (i = 0; i < priv->rx_ring_size; i++) { if (priv->rx_skbuff[i]) { dma_unmap_single(NULL, rxbdp->bufPtr, - priv->rx_buffer_size - + RXBUF_ALIGNMENT, + priv->rx_buffer_size, DMA_FROM_DEVICE); dev_kfree_skb_any(priv->rx_skbuff[i]); @@ -636,6 +623,7 @@ int startup_gfar(struct net_device *dev) struct gfar *regs = priv->regs; int err = 0; u32 rctrl = 0; + u32 attrs = 0; gfar_write(®s->imask, IMASK_INIT_CLEAR); @@ -795,18 +783,50 @@ int startup_gfar(struct net_device *dev) if (priv->rx_csum_enable) rctrl |= RCTRL_CHECKSUMMING; - if (priv->extended_hash) + if (priv->extended_hash) { rctrl |= RCTRL_EXTHASH; + gfar_clear_exact_match(dev); + rctrl |= RCTRL_EMEN; + } + if (priv->vlan_enable) rctrl |= RCTRL_VLAN; + if (priv->padding) { + rctrl &= ~RCTRL_PAL_MASK; + rctrl |= RCTRL_PADDING(priv->padding); + } + /* Init rctrl based on our settings */ gfar_write(&priv->regs->rctrl, rctrl); if (dev->features & NETIF_F_IP_CSUM) gfar_write(&priv->regs->tctrl, TCTRL_INIT_CSUM); + /* Set the extraction length and index */ + attrs = ATTRELI_EL(priv->rx_stash_size) | + ATTRELI_EI(priv->rx_stash_index); + + gfar_write(&priv->regs->attreli, attrs); + + /* Start with defaults, and add stashing or locking + * depending on the approprate variables */ + attrs = ATTR_INIT_SETTINGS; + + if (priv->bd_stash_en) + attrs |= ATTR_BDSTASH; + + if (priv->rx_stash_size != 0) + attrs |= ATTR_BUFSTASH; + + gfar_write(&priv->regs->attr, attrs); + + gfar_write(&priv->regs->fifo_tx_thr, priv->fifo_threshold); + gfar_write(&priv->regs->fifo_tx_starve, priv->fifo_starve); + gfar_write(&priv->regs->fifo_tx_starve_shutoff, priv->fifo_starve_off); + + /* Start the controller */ gfar_start(dev); return 0; @@ -851,34 +871,32 @@ static int gfar_enet_open(struct net_device *dev) return err; } -static struct txfcb *gfar_add_fcb(struct sk_buff *skb, struct txbd8 *bdp) +static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb, struct txbd8 *bdp) { struct txfcb *fcb = (struct txfcb *)skb_push (skb, GMAC_FCB_LEN); memset(fcb, 0, GMAC_FCB_LEN); - /* Flag the bd so the controller looks for the FCB */ - bdp->status |= TXBD_TOE; - return fcb; } static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb) { - int len; + u8 flags = 0; /* If we're here, it's a IP packet with a TCP or UDP * payload. We set it to checksum, using a pseudo-header * we provide */ - fcb->ip = 1; - fcb->tup = 1; - fcb->ctu = 1; - fcb->nph = 1; + flags = TXFCB_DEFAULT; - /* Notify the controller what the protocol is */ - if (skb->nh.iph->protocol == IPPROTO_UDP) - fcb->udp = 1; + /* Tell the controller what the protocol is */ + /* And provide the already calculated phcs */ + if (skb->nh.iph->protocol == IPPROTO_UDP) { + flags |= TXFCB_UDP; + fcb->phcs = skb->h.uh->check; + } else + fcb->phcs = skb->h.th->check; /* l3os is the distance between the start of the * frame (skb->data) and the start of the IP hdr. @@ -887,17 +905,12 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb) fcb->l3os = (u16)(skb->nh.raw - skb->data - GMAC_FCB_LEN); fcb->l4os = (u16)(skb->h.raw - skb->nh.raw); - len = skb->nh.iph->tot_len - fcb->l4os; - - /* Provide the pseudoheader csum */ - fcb->phcs = ~csum_tcpudp_magic(skb->nh.iph->saddr, - skb->nh.iph->daddr, len, - skb->nh.iph->protocol, 0); + fcb->flags = flags; } -void gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb) +void inline gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb) { - fcb->vln = 1; + fcb->flags |= TXFCB_VLN; fcb->vlctl = vlan_tx_tag_get(skb); } @@ -908,6 +921,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) struct gfar_private *priv = netdev_priv(dev); struct txfcb *fcb = NULL; struct txbd8 *txbdp; + u16 status; /* Update transmit stats */ priv->stats.tx_bytes += skb->len; @@ -919,19 +933,22 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) txbdp = priv->cur_tx; /* Clear all but the WRAP status flags */ - txbdp->status &= TXBD_WRAP; + status = txbdp->status & TXBD_WRAP; /* Set up checksumming */ - if ((dev->features & NETIF_F_IP_CSUM) - && (CHECKSUM_HW == skb->ip_summed)) { + if (likely((dev->features & NETIF_F_IP_CSUM) + && (CHECKSUM_HW == skb->ip_summed))) { fcb = gfar_add_fcb(skb, txbdp); + status |= TXBD_TOE; gfar_tx_checksum(skb, fcb); } if (priv->vlan_enable && unlikely(priv->vlgrp && vlan_tx_tag_present(skb))) { - if (NULL == fcb) + if (unlikely(NULL == fcb)) { fcb = gfar_add_fcb(skb, txbdp); + status |= TXBD_TOE; + } gfar_tx_vlan(skb, fcb); } @@ -949,14 +966,16 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) (priv->skb_curtx + 1) & TX_RING_MOD_MASK(priv->tx_ring_size); /* Flag the BD as interrupt-causing */ - txbdp->status |= TXBD_INTERRUPT; + status |= TXBD_INTERRUPT; /* Flag the BD as ready to go, last in frame, and */ /* in need of CRC */ - txbdp->status |= (TXBD_READY | TXBD_LAST | TXBD_CRC); + status |= (TXBD_READY | TXBD_LAST | TXBD_CRC); dev->trans_start = jiffies; + txbdp->status = status; + /* If this was the last BD in the ring, the next one */ /* is at the beginning of the ring */ if (txbdp->status & TXBD_WRAP) @@ -1010,21 +1029,7 @@ static struct net_device_stats * gfar_get_stats(struct net_device *dev) /* Changes the mac address if the controller is not running. */ int gfar_set_mac_address(struct net_device *dev) { - struct gfar_private *priv = netdev_priv(dev); - int i; - char tmpbuf[MAC_ADDR_LEN]; - u32 tempval; - - /* Now copy it into the mac registers backwards, cuz */ - /* little endian is silly */ - for (i = 0; i < MAC_ADDR_LEN; i++) - tmpbuf[MAC_ADDR_LEN - 1 - i] = dev->dev_addr[i]; - - gfar_write(&priv->regs->macstnaddr1, *((u32 *) (tmpbuf))); - - tempval = *((u32 *) (tmpbuf + 4)); - - gfar_write(&priv->regs->macstnaddr2, tempval); + gfar_set_mac_for_addr(dev, 0, dev->dev_addr); return 0; } @@ -1110,7 +1115,7 @@ static int gfar_change_mtu(struct net_device *dev, int new_mtu) INCREMENTAL_BUFFER_SIZE; /* Only stop and start the controller if it isn't already - * stopped */ + * stopped, and we changed something */ if ((oldsize != tempsize) && (dev->flags & IFF_UP)) stop_gfar(dev); @@ -1220,6 +1225,7 @@ static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs) struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp) { + unsigned int alignamount; struct gfar_private *priv = netdev_priv(dev); struct sk_buff *skb = NULL; unsigned int timeout = SKB_ALLOC_TIMEOUT; @@ -1231,18 +1237,18 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp) if (NULL == skb) return NULL; + alignamount = RXBUF_ALIGNMENT - + (((unsigned) skb->data) & (RXBUF_ALIGNMENT - 1)); + /* We need the data buffer to be aligned properly. We will reserve * as many bytes as needed to align the data properly */ - skb_reserve(skb, - RXBUF_ALIGNMENT - - (((unsigned) skb->data) & (RXBUF_ALIGNMENT - 1))); + skb_reserve(skb, alignamount); skb->dev = dev; bdp->bufPtr = dma_map_single(NULL, skb->data, - priv->rx_buffer_size + RXBUF_ALIGNMENT, - DMA_FROM_DEVICE); + priv->rx_buffer_size, DMA_FROM_DEVICE); bdp->length = 0; @@ -1350,7 +1356,7 @@ static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb) /* If valid headers were found, and valid sums * were verified, then we tell the kernel that no * checksumming is necessary. Otherwise, it is */ - if (fcb->cip && !fcb->eip && fcb->ctu && !fcb->etu) + if ((fcb->flags & RXFCB_CSUM_MASK) == (RXFCB_CIP | RXFCB_CTU)) skb->ip_summed = CHECKSUM_UNNECESSARY; else skb->ip_summed = CHECKSUM_NONE; @@ -1401,7 +1407,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, skb->protocol = eth_type_trans(skb, dev); /* Send the packet up the stack */ - if (unlikely(priv->vlgrp && fcb->vln)) + if (unlikely(priv->vlgrp && (fcb->flags & RXFCB_VLN))) ret = gfar_rx_vlan(skb, priv->vlgrp, fcb->vlctl); else ret = RECEIVE(skb); @@ -1620,6 +1626,7 @@ static void adjust_link(struct net_device *dev) spin_lock_irqsave(&priv->lock, flags); if (phydev->link) { u32 tempval = gfar_read(®s->maccfg2); + u32 ecntrl = gfar_read(®s->ecntrl); /* Now we make sure that we can be in full duplex mode. * If not, we operate in half-duplex mode. */ @@ -1644,6 +1651,13 @@ static void adjust_link(struct net_device *dev) case 10: tempval = ((tempval & ~(MACCFG2_IF)) | MACCFG2_MII); + + /* Reduced mode distinguishes + * between 10 and 100 */ + if (phydev->speed == SPEED_100) + ecntrl |= ECNTRL_R100; + else + ecntrl &= ~(ECNTRL_R100); break; default: if (netif_msg_link(priv)) @@ -1657,6 +1671,7 @@ static void adjust_link(struct net_device *dev) } gfar_write(®s->maccfg2, tempval); + gfar_write(®s->ecntrl, ecntrl); if (!priv->oldlink) { new_state = 1; @@ -1721,6 +1736,9 @@ static void gfar_set_multi(struct net_device *dev) gfar_write(®s->gaddr6, 0xffffffff); gfar_write(®s->gaddr7, 0xffffffff); } else { + int em_num; + int idx; + /* zero out the hash */ gfar_write(®s->igaddr0, 0x0); gfar_write(®s->igaddr1, 0x0); @@ -1739,18 +1757,47 @@ static void gfar_set_multi(struct net_device *dev) gfar_write(®s->gaddr6, 0x0); gfar_write(®s->gaddr7, 0x0); + /* If we have extended hash tables, we need to + * clear the exact match registers to prepare for + * setting them */ + if (priv->extended_hash) { + em_num = GFAR_EM_NUM + 1; + gfar_clear_exact_match(dev); + idx = 1; + } else { + idx = 0; + em_num = 0; + } + if(dev->mc_count == 0) return; /* Parse the list, and set the appropriate bits */ for(mc_ptr = dev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) { - gfar_set_hash_for_addr(dev, mc_ptr->dmi_addr); + if (idx < em_num) { + gfar_set_mac_for_addr(dev, idx, + mc_ptr->dmi_addr); + idx++; + } else + gfar_set_hash_for_addr(dev, mc_ptr->dmi_addr); } } return; } + +/* Clears each of the exact match registers to zero, so they + * don't interfere with normal reception */ +static void gfar_clear_exact_match(struct net_device *dev) +{ + int idx; + u8 zero_arr[MAC_ADDR_LEN] = {0,0,0,0,0,0}; + + for(idx = 1;idx < GFAR_EM_NUM + 1;idx++) + gfar_set_mac_for_addr(dev, idx, (u8 *)zero_arr); +} + /* Set the appropriate hash bit for the given addr */ /* The algorithm works like so: * 1) Take the Destination Address (ie the multicast address), and @@ -1781,6 +1828,32 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr) return; } + +/* There are multiple MAC Address register pairs on some controllers + * This function sets the numth pair to a given address + */ +static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr) +{ + struct gfar_private *priv = netdev_priv(dev); + int idx; + char tmpbuf[MAC_ADDR_LEN]; + u32 tempval; + u32 *macptr = &priv->regs->macstnaddr1; + + macptr += num*2; + + /* Now copy it into the mac registers backwards, cuz */ + /* little endian is silly */ + for (idx = 0; idx < MAC_ADDR_LEN; idx++) + tmpbuf[MAC_ADDR_LEN - 1 - idx] = addr[idx]; + + gfar_write(macptr, *((u32 *) (tmpbuf))); + + tempval = *((u32 *) (tmpbuf + 4)); + + gfar_write(macptr+1, tempval); +} + /* GFAR error interrupt handler */ static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs) { diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h index 5065ba8..94a91da 100644 --- a/drivers/net/gianfar.h +++ b/drivers/net/gianfar.h @@ -90,12 +90,26 @@ extern const char gfar_driver_version[]; #define GFAR_RX_MAX_RING_SIZE 256 #define GFAR_TX_MAX_RING_SIZE 256 +#define GFAR_MAX_FIFO_THRESHOLD 511 +#define GFAR_MAX_FIFO_STARVE 511 +#define GFAR_MAX_FIFO_STARVE_OFF 511 + #define DEFAULT_RX_BUFFER_SIZE 1536 #define TX_RING_MOD_MASK(size) (size-1) #define RX_RING_MOD_MASK(size) (size-1) #define JUMBO_BUFFER_SIZE 9728 #define JUMBO_FRAME_SIZE 9600 +#define DEFAULT_FIFO_TX_THR 0x100 +#define DEFAULT_FIFO_TX_STARVE 0x40 +#define DEFAULT_FIFO_TX_STARVE_OFF 0x80 +#define DEFAULT_BD_STASH 1 +#define DEFAULT_STASH_LENGTH 64 +#define DEFAULT_STASH_INDEX 0 + +/* The number of Exact Match registers */ +#define GFAR_EM_NUM 15 + /* Latency of interface clock in nanoseconds */ /* Interface clock latency , in this case, means the * time described by a value of 1 in the interrupt @@ -112,11 +126,11 @@ extern const char gfar_driver_version[]; #define DEFAULT_TX_COALESCE 1 #define DEFAULT_TXCOUNT 16 -#define DEFAULT_TXTIME 400 +#define DEFAULT_TXTIME 4 #define DEFAULT_RX_COALESCE 1 #define DEFAULT_RXCOUNT 16 -#define DEFAULT_RXTIME 400 +#define DEFAULT_RXTIME 4 #define TBIPA_VALUE 0x1f #define MIIMCFG_INIT_VALUE 0x00000007 @@ -147,6 +161,7 @@ extern const char gfar_driver_version[]; #define ECNTRL_INIT_SETTINGS 0x00001000 #define ECNTRL_TBI_MODE 0x00000020 +#define ECNTRL_R100 0x00000008 #define MRBLR_INIT_SETTINGS DEFAULT_RX_BUFFER_SIZE @@ -181,10 +196,12 @@ extern const char gfar_driver_version[]; #define RCTRL_PRSDEP_MASK 0x000000c0 #define RCTRL_PRSDEP_INIT 0x000000c0 #define RCTRL_PROM 0x00000008 +#define RCTRL_EMEN 0x00000002 #define RCTRL_CHECKSUMMING (RCTRL_IPCSEN \ | RCTRL_TUCSEN | RCTRL_PRSDEP_INIT) #define RCTRL_EXTHASH (RCTRL_GHTX) #define RCTRL_VLAN (RCTRL_PRSDEP_INIT) +#define RCTRL_PADDING(x) ((x << 16) & RCTRL_PAL_MASK) #define RSTAT_CLEAR_RHALT 0x00800000 @@ -251,28 +268,26 @@ extern const char gfar_driver_version[]; IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \ | IMASK_PERR) +/* Fifo management */ +#define FIFO_TX_THR_MASK 0x01ff +#define FIFO_TX_STARVE_MASK 0x01ff +#define FIFO_TX_STARVE_OFF_MASK 0x01ff /* Attribute fields */ /* This enables rx snooping for buffers and descriptors */ -#ifdef CONFIG_GFAR_BDSTASH #define ATTR_BDSTASH 0x00000800 -#else -#define ATTR_BDSTASH 0x00000000 -#endif -#ifdef CONFIG_GFAR_BUFSTASH #define ATTR_BUFSTASH 0x00004000 -#define STASH_LENGTH 64 -#else -#define ATTR_BUFSTASH 0x00000000 -#endif #define ATTR_SNOOPING 0x000000c0 -#define ATTR_INIT_SETTINGS (ATTR_SNOOPING \ - | ATTR_BDSTASH | ATTR_BUFSTASH) +#define ATTR_INIT_SETTINGS ATTR_SNOOPING #define ATTRELI_INIT_SETTINGS 0x0 +#define ATTRELI_EL_MASK 0x3fff0000 +#define ATTRELI_EL(x) (x << 16) +#define ATTRELI_EI_MASK 0x00003fff +#define ATTRELI_EI(x) (x) /* TxBD status field bits */ @@ -328,6 +343,7 @@ extern const char gfar_driver_version[]; #define RXFCB_CTU 0x0400 #define RXFCB_EIP 0x0200 #define RXFCB_ETU 0x0100 +#define RXFCB_CSUM_MASK 0x0f00 #define RXFCB_PERR_MASK 0x000c #define RXFCB_PERR_BADL3 0x0008 @@ -339,14 +355,7 @@ struct txbd8 }; struct txfcb { - u8 vln:1, - ip:1, - ip6:1, - tup:1, - udp:1, - cip:1, - ctu:1, - nph:1; + u8 flags; u8 reserved; u8 l4os; /* Level 4 Header Offset */ u8 l3os; /* Level 3 Header Offset */ @@ -362,14 +371,7 @@ struct rxbd8 }; struct rxfcb { - u16 vln:1, - ip:1, - ip6:1, - tup:1, - cip:1, - ctu:1, - eip:1, - etu:1; + u16 flags; u8 rq; /* Receive Queue index */ u8 pro; /* Layer 4 Protocol */ u16 reserved; @@ -688,12 +690,17 @@ struct gfar_private { spinlock_t lock; unsigned int rx_buffer_size; unsigned int rx_stash_size; + unsigned int rx_stash_index; unsigned int tx_ring_size; unsigned int rx_ring_size; + unsigned int fifo_threshold; + unsigned int fifo_starve; + unsigned int fifo_starve_off; unsigned char vlan_enable:1, rx_csum_enable:1, - extended_hash:1; + extended_hash:1, + bd_stash_en:1; unsigned short padding; struct vlan_group *vlgrp; /* Info structure initialized by board setup code */ @@ -731,6 +738,6 @@ extern void stop_gfar(struct net_device *dev); extern void gfar_halt(struct net_device *dev); extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, int enable, u32 regnum, u32 read); -void gfar_setup_stashing(struct net_device *dev); +void gfar_init_sysfs(struct net_device *dev); #endif /* __GIANFAR_H */ diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c index cfa3cd7..765e810 100644 --- a/drivers/net/gianfar_ethtool.c +++ b/drivers/net/gianfar_ethtool.c @@ -125,7 +125,7 @@ static char stat_gstrings[][ETH_GSTRING_LEN] = { static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf) { struct gfar_private *priv = netdev_priv(dev); - + if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) memcpy(buf, stat_gstrings, GFAR_STATS_LEN * ETH_GSTRING_LEN); else diff --git a/drivers/net/gianfar_mii.h b/drivers/net/gianfar_mii.h index e85eb21..d527cf2 100644 --- a/drivers/net/gianfar_mii.h +++ b/drivers/net/gianfar_mii.h @@ -24,6 +24,7 @@ #define MII_READ_COMMAND 0x00000001 #define GFAR_SUPPORTED (SUPPORTED_10baseT_Half \ + | SUPPORTED_10baseT_Full \ | SUPPORTED_100baseT_Half \ | SUPPORTED_100baseT_Full \ | SUPPORTED_Autoneg \ diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c new file mode 100644 index 0000000..10d34cb --- /dev/null +++ b/drivers/net/gianfar_sysfs.c @@ -0,0 +1,311 @@ +/* + * drivers/net/gianfar_sysfs.c + * + * Gianfar Ethernet Driver + * This driver is designed for the non-CPM ethernet controllers + * on the 85xx and 83xx family of integrated processors + * Based on 8260_io/fcc_enet.c + * + * Author: Andy Fleming + * Maintainer: Kumar Gala (kumar.gala@freescale.com) + * + * Copyright (c) 2002-2005 Freescale Semiconductor, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * Sysfs file creation and management + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "gianfar.h" + +#define GFAR_ATTR(_name) \ +static ssize_t gfar_show_##_name(struct class_device *cdev, char *buf); \ +static ssize_t gfar_set_##_name(struct class_device *cdev, \ + const char *buf, size_t count); \ +static CLASS_DEVICE_ATTR(_name, 0644, gfar_show_##_name, gfar_set_##_name) + +#define GFAR_CREATE_FILE(_dev, _name) \ + class_device_create_file(&_dev->class_dev, &class_device_attr_##_name) + +GFAR_ATTR(bd_stash); +GFAR_ATTR(rx_stash_size); +GFAR_ATTR(rx_stash_index); +GFAR_ATTR(fifo_threshold); +GFAR_ATTR(fifo_starve); +GFAR_ATTR(fifo_starve_off); + +#define to_net_dev(cd) container_of(cd, struct net_device, class_dev) + +static ssize_t gfar_show_bd_stash(struct class_device *cdev, char *buf) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + + return sprintf(buf, "%s\n", priv->bd_stash_en? "on" : "off"); +} + +static ssize_t gfar_set_bd_stash(struct class_device *cdev, + const char *buf, size_t count) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + int new_setting = 0; + u32 temp; + unsigned long flags; + + /* Find out the new setting */ + if (!strncmp("on", buf, count-1) || !strncmp("1", buf, count-1)) + new_setting = 1; + else if (!strncmp("off", buf, count-1) || !strncmp("0", buf, count-1)) + new_setting = 0; + else + return count; + + spin_lock_irqsave(&priv->lock, flags); + + /* Set the new stashing value */ + priv->bd_stash_en = new_setting; + + temp = gfar_read(&priv->regs->attr); + + if (new_setting) + temp |= ATTR_BDSTASH; + else + temp &= ~(ATTR_BDSTASH); + + gfar_write(&priv->regs->attr, temp); + + spin_unlock_irqrestore(&priv->lock, flags); + + return count; +} + +static ssize_t gfar_show_rx_stash_size(struct class_device *cdev, char *buf) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + + return sprintf(buf, "%d\n", priv->rx_stash_size); +} + +static ssize_t gfar_set_rx_stash_size(struct class_device *cdev, + const char *buf, size_t count) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + unsigned int length = simple_strtoul(buf, NULL, 0); + u32 temp; + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + if (length > priv->rx_buffer_size) + return count; + + if (length == priv->rx_stash_size) + return count; + + priv->rx_stash_size = length; + + temp = gfar_read(&priv->regs->attreli); + temp &= ~ATTRELI_EL_MASK; + temp |= ATTRELI_EL(length); + gfar_write(&priv->regs->attreli, temp); + + /* Turn stashing on/off as appropriate */ + temp = gfar_read(&priv->regs->attr); + + if (length) + temp |= ATTR_BUFSTASH; + else + temp &= ~(ATTR_BUFSTASH); + + gfar_write(&priv->regs->attr, temp); + + spin_unlock_irqrestore(&priv->lock, flags); + + return count; +} + + +/* Stashing will only be enabled when rx_stash_size != 0 */ +static ssize_t gfar_show_rx_stash_index(struct class_device *cdev, char *buf) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + + return sprintf(buf, "%d\n", priv->rx_stash_index); +} + +static ssize_t gfar_set_rx_stash_index(struct class_device *cdev, + const char *buf, size_t count) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + unsigned short index = simple_strtoul(buf, NULL, 0); + u32 temp; + unsigned long flags; + + spin_lock_irqsave(&priv->lock, flags); + if (index > priv->rx_stash_size) + return count; + + if (index == priv->rx_stash_index) + return count; + + priv->rx_stash_index = index; + + temp = gfar_read(&priv->regs->attreli); + temp &= ~ATTRELI_EI_MASK; + temp |= ATTRELI_EI(index); + gfar_write(&priv->regs->attreli, flags); + + spin_unlock_irqrestore(&priv->lock, flags); + + return count; +} + +static ssize_t gfar_show_fifo_threshold(struct class_device *cdev, char *buf) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + + return sprintf(buf, "%d\n", priv->fifo_threshold); +} + +static ssize_t gfar_set_fifo_threshold(struct class_device *cdev, + const char *buf, size_t count) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + unsigned int length = simple_strtoul(buf, NULL, 0); + u32 temp; + unsigned long flags; + + if (length > GFAR_MAX_FIFO_THRESHOLD) + return count; + + spin_lock_irqsave(&priv->lock, flags); + + priv->fifo_threshold = length; + + temp = gfar_read(&priv->regs->fifo_tx_thr); + temp &= ~FIFO_TX_THR_MASK; + temp |= length; + gfar_write(&priv->regs->fifo_tx_thr, temp); + + spin_unlock_irqrestore(&priv->lock, flags); + + return count; +} + +static ssize_t gfar_show_fifo_starve(struct class_device *cdev, char *buf) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + + return sprintf(buf, "%d\n", priv->fifo_starve); +} + + +static ssize_t gfar_set_fifo_starve(struct class_device *cdev, + const char *buf, size_t count) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + unsigned int num = simple_strtoul(buf, NULL, 0); + u32 temp; + unsigned long flags; + + if (num > GFAR_MAX_FIFO_STARVE) + return count; + + spin_lock_irqsave(&priv->lock, flags); + + priv->fifo_starve = num; + + temp = gfar_read(&priv->regs->fifo_tx_starve); + temp &= ~FIFO_TX_STARVE_MASK; + temp |= num; + gfar_write(&priv->regs->fifo_tx_starve, temp); + + spin_unlock_irqrestore(&priv->lock, flags); + + return count; +} + +static ssize_t gfar_show_fifo_starve_off(struct class_device *cdev, char *buf) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + + return sprintf(buf, "%d\n", priv->fifo_starve_off); +} + +static ssize_t gfar_set_fifo_starve_off(struct class_device *cdev, + const char *buf, size_t count) +{ + struct net_device *dev = to_net_dev(cdev); + struct gfar_private *priv = netdev_priv(dev); + unsigned int num = simple_strtoul(buf, NULL, 0); + u32 temp; + unsigned long flags; + + if (num > GFAR_MAX_FIFO_STARVE_OFF) + return count; + + spin_lock_irqsave(&priv->lock, flags); + + priv->fifo_starve_off = num; + + temp = gfar_read(&priv->regs->fifo_tx_starve_shutoff); + temp &= ~FIFO_TX_STARVE_OFF_MASK; + temp |= num; + gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp); + + spin_unlock_irqrestore(&priv->lock, flags); + + return count; +} + +void gfar_init_sysfs(struct net_device *dev) +{ + struct gfar_private *priv = netdev_priv(dev); + + /* Initialize the default values */ + priv->rx_stash_size = DEFAULT_STASH_LENGTH; + priv->rx_stash_index = DEFAULT_STASH_INDEX; + priv->fifo_threshold = DEFAULT_FIFO_TX_THR; + priv->fifo_starve = DEFAULT_FIFO_TX_STARVE; + priv->fifo_starve_off = DEFAULT_FIFO_TX_STARVE_OFF; + priv->bd_stash_en = DEFAULT_BD_STASH; + + /* Create our sysfs files */ + GFAR_CREATE_FILE(dev, bd_stash); + GFAR_CREATE_FILE(dev, rx_stash_size); + GFAR_CREATE_FILE(dev, rx_stash_index); + GFAR_CREATE_FILE(dev, fifo_threshold); + GFAR_CREATE_FILE(dev, fifo_starve); + GFAR_CREATE_FILE(dev, fifo_starve_off); + +} -- cgit v1.1 From 15d014d13149aedd76cbff1b5c3bbfe839391457 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Fri, 11 Nov 2005 18:23:13 +0100 Subject: [PATCH] intel ixp2000 network driver The way the hardware and firmware work is that there is one shared RX queue and IRQ for a number of different network interfaces. Due to this, we would like to process received packets for every interface in the same NAPI poll handler, so we need a pseudo-device to schedule polling on. What the driver currently does is that it always schedules polling for the first network interface in the list, and processes packets for every interface in the poll handler for that first interface -- however, this scheme breaks down if the first network interface happens to not be up, since netif_rx_schedule_prep() checks netif_running(). sky2 apparently has the same issue, and Stephen Hemminger suggested a way to work around this: create a variant of netif_rx_schedule_prep() that does not check netif_running(). I implemented this locally and called it netif_rx_schedule_prep_notup(), and it seems to work well, but it's something that probably not everyone would be happy with. The ixp2000 is an ARM CPU with a high-speed network interface in the CPU itself (full duplex 4Gb/s or 10Gb/s depending on the IXP model.) The CPU package also contains 8 or 16 (again depending on the IXP model) 'microengines', which are somewhat primitive but very fast and efficient processor cores which can be used to offload various things from the main CPU. This driver makes the high-speed network interface in the CPU visible and usable as a regular linux network device. Currently, it only supports the Radisys ENP2611 IXP board, but adding support for other board types should be fairly easy. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/Kconfig | 2 + drivers/net/Makefile | 1 + drivers/net/ixp2000/Kconfig | 6 + drivers/net/ixp2000/Makefile | 3 + drivers/net/ixp2000/caleb.c | 136 ++++++++++++ drivers/net/ixp2000/caleb.h | 22 ++ drivers/net/ixp2000/enp2611.c | 238 ++++++++++++++++++++ drivers/net/ixp2000/ixp2400-msf.c | 213 ++++++++++++++++++ drivers/net/ixp2000/ixp2400-msf.h | 115 ++++++++++ drivers/net/ixp2000/ixp2400_rx.uc | 408 +++++++++++++++++++++++++++++++++++ drivers/net/ixp2000/ixp2400_rx.ucode | 130 +++++++++++ drivers/net/ixp2000/ixp2400_tx.uc | 272 +++++++++++++++++++++++ drivers/net/ixp2000/ixp2400_tx.ucode | 98 +++++++++ drivers/net/ixp2000/ixpdev.c | 404 ++++++++++++++++++++++++++++++++++ drivers/net/ixp2000/ixpdev.h | 27 +++ drivers/net/ixp2000/ixpdev_priv.h | 57 +++++ drivers/net/ixp2000/pm3386.c | 304 ++++++++++++++++++++++++++ drivers/net/ixp2000/pm3386.h | 26 +++ 18 files changed, 2462 insertions(+) create mode 100644 drivers/net/ixp2000/Kconfig create mode 100644 drivers/net/ixp2000/Makefile create mode 100644 drivers/net/ixp2000/caleb.c create mode 100644 drivers/net/ixp2000/caleb.h create mode 100644 drivers/net/ixp2000/enp2611.c create mode 100644 drivers/net/ixp2000/ixp2400-msf.c create mode 100644 drivers/net/ixp2000/ixp2400-msf.h create mode 100644 drivers/net/ixp2000/ixp2400_rx.uc create mode 100644 drivers/net/ixp2000/ixp2400_rx.ucode create mode 100644 drivers/net/ixp2000/ixp2400_tx.uc create mode 100644 drivers/net/ixp2000/ixp2400_tx.ucode create mode 100644 drivers/net/ixp2000/ixpdev.c create mode 100644 drivers/net/ixp2000/ixpdev.h create mode 100644 drivers/net/ixp2000/ixpdev_priv.h create mode 100644 drivers/net/ixp2000/pm3386.c create mode 100644 drivers/net/ixp2000/pm3386.h diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 39415b5..fca6000 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -1901,6 +1901,8 @@ config E1000_NAPI If in doubt, say N. +source "drivers/net/ixp2000/Kconfig" + config MYRI_SBUS tristate "MyriCOM Gigabit Ethernet support" depends on SBUS diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 5056814..b74a7cb 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -206,6 +206,7 @@ obj-$(CONFIG_NET_TULIP) += tulip/ obj-$(CONFIG_HAMRADIO) += hamradio/ obj-$(CONFIG_IRDA) += irda/ obj-$(CONFIG_ETRAX_ETHERNET) += cris/ +obj-$(CONFIG_ENP2611_MSF_NET) += ixp2000/ obj-$(CONFIG_NETCONSOLE) += netconsole.o diff --git a/drivers/net/ixp2000/Kconfig b/drivers/net/ixp2000/Kconfig new file mode 100644 index 0000000..2fec241 --- /dev/null +++ b/drivers/net/ixp2000/Kconfig @@ -0,0 +1,6 @@ +config ENP2611_MSF_NET + tristate "Radisys ENP2611 MSF network interface support" + depends on ARCH_ENP2611 + help + This is a driver for the MSF network interface unit in + the IXP2400 on the Radisys ENP2611 platform. diff --git a/drivers/net/ixp2000/Makefile b/drivers/net/ixp2000/Makefile new file mode 100644 index 0000000..fd38351 --- /dev/null +++ b/drivers/net/ixp2000/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_ENP2611_MSF_NET) += enp2611_mod.o + +enp2611_mod-objs := caleb.o enp2611.o ixp2400-msf.o ixpdev.o pm3386.o diff --git a/drivers/net/ixp2000/caleb.c b/drivers/net/ixp2000/caleb.c new file mode 100644 index 0000000..d70530a --- /dev/null +++ b/drivers/net/ixp2000/caleb.c @@ -0,0 +1,136 @@ +/* + * Helper functions for the SPI-3 bridge FPGA on the Radisys ENP2611 + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include + +#define CALEB_IDLO 0x00 +#define CALEB_IDHI 0x01 +#define CALEB_RID 0x02 +#define CALEB_RESET 0x03 +#define CALEB_INTREN0 0x04 +#define CALEB_INTREN1 0x05 +#define CALEB_INTRSTAT0 0x06 +#define CALEB_INTRSTAT1 0x07 +#define CALEB_PORTEN 0x08 +#define CALEB_BURST 0x09 +#define CALEB_PORTPAUS 0x0A +#define CALEB_PORTPAUSD 0x0B +#define CALEB_PHY0RX 0x10 +#define CALEB_PHY1RX 0x11 +#define CALEB_PHY0TX 0x12 +#define CALEB_PHY1TX 0x13 +#define CALEB_IXPRX_HI_CNTR 0x15 +#define CALEB_PHY0RX_HI_CNTR 0x16 +#define CALEB_PHY1RX_HI_CNTR 0x17 +#define CALEB_IXPRX_CNTR 0x18 +#define CALEB_PHY0RX_CNTR 0x19 +#define CALEB_PHY1RX_CNTR 0x1A +#define CALEB_IXPTX_CNTR 0x1B +#define CALEB_PHY0TX_CNTR 0x1C +#define CALEB_PHY1TX_CNTR 0x1D +#define CALEB_DEBUG0 0x1E +#define CALEB_DEBUG1 0x1F + + +static u8 caleb_reg_read(int reg) +{ + u8 value; + + value = *((volatile u8 *)(ENP2611_CALEB_VIRT_BASE + reg)); + +// printk(KERN_INFO "caleb_reg_read(%d) = %.2x\n", reg, value); + + return value; +} + +static void caleb_reg_write(int reg, u8 value) +{ + u8 dummy; + +// printk(KERN_INFO "caleb_reg_write(%d, %.2x)\n", reg, value); + + *((volatile u8 *)(ENP2611_CALEB_VIRT_BASE + reg)) = value; + + dummy = *((volatile u8 *)ENP2611_CALEB_VIRT_BASE); + __asm__ __volatile__("mov %0, %0" : "+r" (dummy)); +} + + +void caleb_reset(void) +{ + /* + * Perform a chip reset. + */ + caleb_reg_write(CALEB_RESET, 0x02); + udelay(1); + + /* + * Enable all interrupt sources. This is needed to get + * meaningful results out of the status bits (register 6 + * and 7.) + */ + caleb_reg_write(CALEB_INTREN0, 0xff); + caleb_reg_write(CALEB_INTREN1, 0x07); + + /* + * Set RX and TX FIFO thresholds to 1.5kb. + */ + caleb_reg_write(CALEB_PHY0RX, 0x11); + caleb_reg_write(CALEB_PHY1RX, 0x11); + caleb_reg_write(CALEB_PHY0TX, 0x11); + caleb_reg_write(CALEB_PHY1TX, 0x11); + + /* + * Program SPI-3 burst size. + */ + caleb_reg_write(CALEB_BURST, 0); // 64-byte RBUF mpackets +// caleb_reg_write(CALEB_BURST, 1); // 128-byte RBUF mpackets +// caleb_reg_write(CALEB_BURST, 2); // 256-byte RBUF mpackets +} + +void caleb_enable_rx(int port) +{ + u8 temp; + + temp = caleb_reg_read(CALEB_PORTEN); + temp |= 1 << port; + caleb_reg_write(CALEB_PORTEN, temp); +} + +void caleb_disable_rx(int port) +{ + u8 temp; + + temp = caleb_reg_read(CALEB_PORTEN); + temp &= ~(1 << port); + caleb_reg_write(CALEB_PORTEN, temp); +} + +void caleb_enable_tx(int port) +{ + u8 temp; + + temp = caleb_reg_read(CALEB_PORTEN); + temp |= 1 << (port + 4); + caleb_reg_write(CALEB_PORTEN, temp); +} + +void caleb_disable_tx(int port) +{ + u8 temp; + + temp = caleb_reg_read(CALEB_PORTEN); + temp &= ~(1 << (port + 4)); + caleb_reg_write(CALEB_PORTEN, temp); +} diff --git a/drivers/net/ixp2000/caleb.h b/drivers/net/ixp2000/caleb.h new file mode 100644 index 0000000..e93a1ef --- /dev/null +++ b/drivers/net/ixp2000/caleb.h @@ -0,0 +1,22 @@ +/* + * Helper functions for the SPI-3 bridge FPGA on the Radisys ENP2611 + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef __CALEB_H +#define __CALEB_H + +void caleb_reset(void); +void caleb_enable_rx(int port); +void caleb_disable_rx(int port); +void caleb_enable_tx(int port); +void caleb_disable_tx(int port); + + +#endif diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c new file mode 100644 index 0000000..3262e70 --- /dev/null +++ b/drivers/net/ixp2000/enp2611.c @@ -0,0 +1,238 @@ +/* + * IXP2400 MSF network device driver for the Radisys ENP2611 + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ixpdev.h" +#include "caleb.h" +#include "ixp2400-msf.h" +#include "pm3386.h" + +/*********************************************************************** + * The Radisys ENP2611 is a PCI form factor board with three SFP GBIC + * slots, connected via two PMC/Sierra 3386s and an SPI-3 bridge FPGA + * to the IXP2400. + * + * +-------------+ + * SFP GBIC #0 ---+ | +---------+ + * | PM3386 #0 +-------+ | + * SFP GBIC #1 ---+ | | "Caleb" | +---------+ + * +-------------+ | | | | + * | SPI-3 +---------+ IXP2400 | + * +-------------+ | bridge | | | + * SFP GBIC #2 ---+ | | FPGA | +---------+ + * | PM3386 #1 +-------+ | + * | | +---------+ + * +-------------+ + * ^ ^ ^ + * | 1.25Gbaud | 104MHz | 104MHz + * | SERDES ea. | SPI-3 ea. | SPI-3 + * + ***********************************************************************/ +static struct ixp2400_msf_parameters enp2611_msf_parameters = +{ + .rx_mode = IXP2400_RX_MODE_UTOPIA_POS | + IXP2400_RX_MODE_1x32 | + IXP2400_RX_MODE_MPHY | + IXP2400_RX_MODE_MPHY_32 | + IXP2400_RX_MODE_MPHY_POLLED_STATUS | + IXP2400_RX_MODE_MPHY_LEVEL3 | + IXP2400_RX_MODE_RBUF_SIZE_64, + + .rxclk01_multiplier = IXP2400_PLL_MULTIPLIER_16, + + .rx_poll_ports = 3, + + .rx_channel_mode = { + IXP2400_PORT_RX_MODE_MASTER | + IXP2400_PORT_RX_MODE_POS_PHY | + IXP2400_PORT_RX_MODE_POS_PHY_L3 | + IXP2400_PORT_RX_MODE_ODD_PARITY | + IXP2400_PORT_RX_MODE_2_CYCLE_DECODE, + + IXP2400_PORT_RX_MODE_MASTER | + IXP2400_PORT_RX_MODE_POS_PHY | + IXP2400_PORT_RX_MODE_POS_PHY_L3 | + IXP2400_PORT_RX_MODE_ODD_PARITY | + IXP2400_PORT_RX_MODE_2_CYCLE_DECODE, + + IXP2400_PORT_RX_MODE_MASTER | + IXP2400_PORT_RX_MODE_POS_PHY | + IXP2400_PORT_RX_MODE_POS_PHY_L3 | + IXP2400_PORT_RX_MODE_ODD_PARITY | + IXP2400_PORT_RX_MODE_2_CYCLE_DECODE, + + IXP2400_PORT_RX_MODE_MASTER | + IXP2400_PORT_RX_MODE_POS_PHY | + IXP2400_PORT_RX_MODE_POS_PHY_L3 | + IXP2400_PORT_RX_MODE_ODD_PARITY | + IXP2400_PORT_RX_MODE_2_CYCLE_DECODE + }, + + .tx_mode = IXP2400_TX_MODE_UTOPIA_POS | + IXP2400_TX_MODE_1x32 | + IXP2400_TX_MODE_MPHY | + IXP2400_TX_MODE_MPHY_32 | + IXP2400_TX_MODE_MPHY_POLLED_STATUS | + IXP2400_TX_MODE_MPHY_LEVEL3 | + IXP2400_TX_MODE_TBUF_SIZE_64, + + .txclk01_multiplier = IXP2400_PLL_MULTIPLIER_16, + + .tx_poll_ports = 3, + + .tx_channel_mode = { + IXP2400_PORT_TX_MODE_MASTER | + IXP2400_PORT_TX_MODE_POS_PHY | + IXP2400_PORT_TX_MODE_ODD_PARITY | + IXP2400_PORT_TX_MODE_2_CYCLE_DECODE, + + IXP2400_PORT_TX_MODE_MASTER | + IXP2400_PORT_TX_MODE_POS_PHY | + IXP2400_PORT_TX_MODE_ODD_PARITY | + IXP2400_PORT_TX_MODE_2_CYCLE_DECODE, + + IXP2400_PORT_TX_MODE_MASTER | + IXP2400_PORT_TX_MODE_POS_PHY | + IXP2400_PORT_TX_MODE_ODD_PARITY | + IXP2400_PORT_TX_MODE_2_CYCLE_DECODE, + + IXP2400_PORT_TX_MODE_MASTER | + IXP2400_PORT_TX_MODE_POS_PHY | + IXP2400_PORT_TX_MODE_ODD_PARITY | + IXP2400_PORT_TX_MODE_2_CYCLE_DECODE + } +}; + +struct enp2611_ixpdev_priv +{ + struct ixpdev_priv ixpdev_priv; + struct net_device_stats stats; +}; + +static struct net_device *nds[3]; +static struct timer_list link_check_timer; + +static struct net_device_stats *enp2611_get_stats(struct net_device *dev) +{ + struct enp2611_ixpdev_priv *ip = netdev_priv(dev); + + pm3386_get_stats(ip->ixpdev_priv.channel, &(ip->stats)); + + return &(ip->stats); +} + +/* @@@ Poll the SFP moddef0 line too. */ +/* @@@ Try to use the pm3386 DOOL interrupt as well. */ +static void enp2611_check_link_status(unsigned long __dummy) +{ + int i; + + for (i = 0; i < 3; i++) { + struct net_device *dev; + int status; + + if (!netif_running(nds[i])) + continue; + + dev = nds[i]; + + status = pm3386_is_link_up(i); + if (status && !netif_carrier_ok(nds[i])) { + pm3386_enable_tx(i); + caleb_enable_tx(i); + netif_carrier_on(nds[i]); + } else if (!status && netif_carrier_ok(nds[i])) { + netif_carrier_off(nds[i]); + caleb_disable_tx(i); + pm3386_disable_tx(i); + } + } + + link_check_timer.expires = jiffies + HZ / 10; + add_timer(&link_check_timer); +} + +static void enp2611_set_port_admin_status(int port, int up) +{ + if (up) { + caleb_enable_rx(port); + pm3386_enable_rx(port); + } else { + caleb_disable_tx(port); + pm3386_disable_tx(port); + pm3386_disable_rx(port); + caleb_disable_rx(port); + } +} + +static int __init enp2611_init_module(void) +{ + int i; + + if (!machine_is_enp2611()) + return -ENODEV; + + caleb_reset(); + pm3386_reset(); + + for (i = 0; i < 3; i++) { + nds[i] = ixpdev_alloc(i, sizeof(struct enp2611_ixpdev_priv)); + if (nds[i] == NULL) { + while (--i >= 0) + free_netdev(nds[i]); + return -ENOMEM; + } + + SET_MODULE_OWNER(nds[i]); + nds[i]->get_stats = enp2611_get_stats; + pm3386_init_port(i); + pm3386_get_mac(i, nds[i]->dev_addr); + } + + ixp2400_msf_init(&enp2611_msf_parameters); + + if (ixpdev_init(3, nds, enp2611_set_port_admin_status)) { + for (i = 0; i < 3; i++) + free_netdev(nds[i]); + return -EINVAL; + } + + init_timer(&link_check_timer); + link_check_timer.function = enp2611_check_link_status; + link_check_timer.expires = jiffies; + add_timer(&link_check_timer); + + return 0; +} + +static void __exit enp2611_cleanup_module(void) +{ + int i; + + del_timer_sync(&link_check_timer); + + ixpdev_deinit(); + for (i = 0; i < 3; i++) + free_netdev(nds[i]); +} + +module_init(enp2611_init_module); +module_exit(enp2611_cleanup_module); +MODULE_LICENSE("GPL"); diff --git a/drivers/net/ixp2000/ixp2400-msf.c b/drivers/net/ixp2000/ixp2400-msf.c new file mode 100644 index 0000000..48a3a89 --- /dev/null +++ b/drivers/net/ixp2000/ixp2400-msf.c @@ -0,0 +1,213 @@ +/* + * Generic library functions for the MSF (Media and Switch Fabric) unit + * found on the Intel IXP2400 network processor. + * + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "ixp2400-msf.h" + +/* + * This is the Intel recommended PLL init procedure as described on + * page 340 of the IXP2400/IXP2800 Programmer's Reference Manual. + */ +static void ixp2400_pll_init(struct ixp2400_msf_parameters *mp) +{ + int rx_dual_clock; + int tx_dual_clock; + u32 value; + + /* + * If the RX mode is not 1x32, we have to enable both RX PLLs + * (#0 and #1.) The same thing for the TX direction. + */ + rx_dual_clock = !!(mp->rx_mode & IXP2400_RX_MODE_WIDTH_MASK); + tx_dual_clock = !!(mp->tx_mode & IXP2400_TX_MODE_WIDTH_MASK); + + /* + * Read initial value. + */ + value = ixp2000_reg_read(IXP2000_MSF_CLK_CNTRL); + + /* + * Put PLLs in powerdown and bypass mode. + */ + value |= 0x0000f0f0; + ixp2000_reg_write(IXP2000_MSF_CLK_CNTRL, value); + + /* + * Set single or dual clock mode bits. + */ + value &= ~0x03000000; + value |= (rx_dual_clock << 24) | (tx_dual_clock << 25); + + /* + * Set multipliers. + */ + value &= ~0x00ff0000; + value |= mp->rxclk01_multiplier << 16; + value |= mp->rxclk23_multiplier << 18; + value |= mp->txclk01_multiplier << 20; + value |= mp->txclk23_multiplier << 22; + + /* + * And write value. + */ + ixp2000_reg_write(IXP2000_MSF_CLK_CNTRL, value); + + /* + * Disable PLL bypass mode. + */ + value &= ~(0x00005000 | rx_dual_clock << 13 | tx_dual_clock << 15); + ixp2000_reg_write(IXP2000_MSF_CLK_CNTRL, value); + + /* + * Turn on PLLs. + */ + value &= ~(0x00000050 | rx_dual_clock << 5 | tx_dual_clock << 7); + ixp2000_reg_write(IXP2000_MSF_CLK_CNTRL, value); + + /* + * Wait for PLLs to lock. There are lock status bits, but IXP2400 + * erratum #65 says that these lock bits should not be relied upon + * as they might not accurately reflect the true state of the PLLs. + */ + udelay(100); +} + +/* + * Needed according to p480 of Programmer's Reference Manual. + */ +static void ixp2400_msf_free_rbuf_entries(struct ixp2400_msf_parameters *mp) +{ + int size_bits; + int i; + + /* + * Work around IXP2400 erratum #69 (silent RBUF-to-DRAM transfer + * corruption) in the Intel-recommended way: do not add the RBUF + * elements susceptible to corruption to the freelist. + */ + size_bits = mp->rx_mode & IXP2400_RX_MODE_RBUF_SIZE_MASK; + if (size_bits == IXP2400_RX_MODE_RBUF_SIZE_64) { + for (i = 1; i < 128; i++) { + if (i == 9 || i == 18 || i == 27) + continue; + ixp2000_reg_write(IXP2000_MSF_RBUF_ELEMENT_DONE, i); + } + } else if (size_bits == IXP2400_RX_MODE_RBUF_SIZE_128) { + for (i = 1; i < 64; i++) { + if (i == 4 || i == 9 || i == 13) + continue; + ixp2000_reg_write(IXP2000_MSF_RBUF_ELEMENT_DONE, i); + } + } else if (size_bits == IXP2400_RX_MODE_RBUF_SIZE_256) { + for (i = 1; i < 32; i++) { + if (i == 2 || i == 4 || i == 6) + continue; + ixp2000_reg_write(IXP2000_MSF_RBUF_ELEMENT_DONE, i); + } + } +} + +static u32 ixp2400_msf_valid_channels(u32 reg) +{ + u32 channels; + + channels = 0; + switch (reg & IXP2400_RX_MODE_WIDTH_MASK) { + case IXP2400_RX_MODE_1x32: + channels = 0x1; + if (reg & IXP2400_RX_MODE_MPHY && + !(reg & IXP2400_RX_MODE_MPHY_32)) + channels = 0xf; + break; + + case IXP2400_RX_MODE_2x16: + channels = 0x5; + break; + + case IXP2400_RX_MODE_4x8: + channels = 0xf; + break; + + case IXP2400_RX_MODE_1x16_2x8: + channels = 0xd; + break; + } + + return channels; +} + +static void ixp2400_msf_enable_rx(struct ixp2400_msf_parameters *mp) +{ + u32 value; + + value = ixp2000_reg_read(IXP2000_MSF_RX_CONTROL) & 0x0fffffff; + value |= ixp2400_msf_valid_channels(mp->rx_mode) << 28; + ixp2000_reg_write(IXP2000_MSF_RX_CONTROL, value); +} + +static void ixp2400_msf_enable_tx(struct ixp2400_msf_parameters *mp) +{ + u32 value; + + value = ixp2000_reg_read(IXP2000_MSF_TX_CONTROL) & 0x0fffffff; + value |= ixp2400_msf_valid_channels(mp->tx_mode) << 28; + ixp2000_reg_write(IXP2000_MSF_TX_CONTROL, value); +} + + +void ixp2400_msf_init(struct ixp2400_msf_parameters *mp) +{ + u32 value; + int i; + + /* + * Init the RX/TX PLLs based on the passed parameter block. + */ + ixp2400_pll_init(mp); + + /* + * Reset MSF. Bit 7 in IXP_RESET_0 resets the MSF. + */ + value = ixp2000_reg_read(IXP2000_RESET0); + ixp2000_reg_write(IXP2000_RESET0, value | 0x80); + ixp2000_reg_write(IXP2000_RESET0, value & ~0x80); + + /* + * Initialise the RX section. + */ + ixp2000_reg_write(IXP2000_MSF_RX_MPHY_POLL_LIMIT, mp->rx_poll_ports - 1); + ixp2000_reg_write(IXP2000_MSF_RX_CONTROL, mp->rx_mode); + for (i = 0; i < 4; i++) { + ixp2000_reg_write(IXP2000_MSF_RX_UP_CONTROL_0 + i, + mp->rx_channel_mode[i]); + } + ixp2400_msf_free_rbuf_entries(mp); + ixp2400_msf_enable_rx(mp); + + /* + * Initialise the TX section. + */ + ixp2000_reg_write(IXP2000_MSF_TX_MPHY_POLL_LIMIT, mp->tx_poll_ports - 1); + ixp2000_reg_write(IXP2000_MSF_TX_CONTROL, mp->tx_mode); + for (i = 0; i < 4; i++) { + ixp2000_reg_write(IXP2000_MSF_TX_UP_CONTROL_0 + i, + mp->tx_channel_mode[i]); + } + ixp2400_msf_enable_tx(mp); +} diff --git a/drivers/net/ixp2000/ixp2400-msf.h b/drivers/net/ixp2000/ixp2400-msf.h new file mode 100644 index 0000000..3ac1af2 --- /dev/null +++ b/drivers/net/ixp2000/ixp2400-msf.h @@ -0,0 +1,115 @@ +/* + * Generic library functions for the MSF (Media and Switch Fabric) unit + * found on the Intel IXP2400 network processor. + * + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + */ + +#ifndef __IXP2400_MSF_H +#define __IXP2400_MSF_H + +struct ixp2400_msf_parameters +{ + u32 rx_mode; + unsigned rxclk01_multiplier:2; + unsigned rxclk23_multiplier:2; + unsigned rx_poll_ports:6; + u32 rx_channel_mode[4]; + + u32 tx_mode; + unsigned txclk01_multiplier:2; + unsigned txclk23_multiplier:2; + unsigned tx_poll_ports:6; + u32 tx_channel_mode[4]; +}; + +void ixp2400_msf_init(struct ixp2400_msf_parameters *mp); + +#define IXP2400_PLL_MULTIPLIER_48 0x00 +#define IXP2400_PLL_MULTIPLIER_24 0x01 +#define IXP2400_PLL_MULTIPLIER_16 0x02 +#define IXP2400_PLL_MULTIPLIER_12 0x03 + +#define IXP2400_RX_MODE_CSIX 0x00400000 +#define IXP2400_RX_MODE_UTOPIA_POS 0x00000000 +#define IXP2400_RX_MODE_WIDTH_MASK 0x00300000 +#define IXP2400_RX_MODE_1x16_2x8 0x00300000 +#define IXP2400_RX_MODE_4x8 0x00200000 +#define IXP2400_RX_MODE_2x16 0x00100000 +#define IXP2400_RX_MODE_1x32 0x00000000 +#define IXP2400_RX_MODE_MPHY 0x00080000 +#define IXP2400_RX_MODE_SPHY 0x00000000 +#define IXP2400_RX_MODE_MPHY_32 0x00040000 +#define IXP2400_RX_MODE_MPHY_4 0x00000000 +#define IXP2400_RX_MODE_MPHY_POLLED_STATUS 0x00020000 +#define IXP2400_RX_MODE_MPHY_DIRECT_STATUS 0x00000000 +#define IXP2400_RX_MODE_CBUS_FULL_DUPLEX 0x00010000 +#define IXP2400_RX_MODE_CBUS_SIMPLEX 0x00000000 +#define IXP2400_RX_MODE_MPHY_LEVEL2 0x00004000 +#define IXP2400_RX_MODE_MPHY_LEVEL3 0x00000000 +#define IXP2400_RX_MODE_CBUS_8BIT 0x00002000 +#define IXP2400_RX_MODE_CBUS_4BIT 0x00000000 +#define IXP2400_RX_MODE_CSIX_SINGLE_FREELIST 0x00000200 +#define IXP2400_RX_MODE_CSIX_SPLIT_FREELISTS 0x00000000 +#define IXP2400_RX_MODE_RBUF_SIZE_MASK 0x0000000c +#define IXP2400_RX_MODE_RBUF_SIZE_256 0x00000008 +#define IXP2400_RX_MODE_RBUF_SIZE_128 0x00000004 +#define IXP2400_RX_MODE_RBUF_SIZE_64 0x00000000 + +#define IXP2400_PORT_RX_MODE_SLAVE 0x00000040 +#define IXP2400_PORT_RX_MODE_MASTER 0x00000000 +#define IXP2400_PORT_RX_MODE_POS_PHY_L3 0x00000020 +#define IXP2400_PORT_RX_MODE_POS_PHY_L2 0x00000000 +#define IXP2400_PORT_RX_MODE_POS_PHY 0x00000010 +#define IXP2400_PORT_RX_MODE_UTOPIA 0x00000000 +#define IXP2400_PORT_RX_MODE_EVEN_PARITY 0x0000000c +#define IXP2400_PORT_RX_MODE_ODD_PARITY 0x00000008 +#define IXP2400_PORT_RX_MODE_NO_PARITY 0x00000000 +#define IXP2400_PORT_RX_MODE_UTOPIA_BIG_CELLS 0x00000002 +#define IXP2400_PORT_RX_MODE_UTOPIA_NORMAL_CELLS 0x00000000 +#define IXP2400_PORT_RX_MODE_2_CYCLE_DECODE 0x00000001 +#define IXP2400_PORT_RX_MODE_1_CYCLE_DECODE 0x00000000 + +#define IXP2400_TX_MODE_CSIX 0x00400000 +#define IXP2400_TX_MODE_UTOPIA_POS 0x00000000 +#define IXP2400_TX_MODE_WIDTH_MASK 0x00300000 +#define IXP2400_TX_MODE_1x16_2x8 0x00300000 +#define IXP2400_TX_MODE_4x8 0x00200000 +#define IXP2400_TX_MODE_2x16 0x00100000 +#define IXP2400_TX_MODE_1x32 0x00000000 +#define IXP2400_TX_MODE_MPHY 0x00080000 +#define IXP2400_TX_MODE_SPHY 0x00000000 +#define IXP2400_TX_MODE_MPHY_32 0x00040000 +#define IXP2400_TX_MODE_MPHY_4 0x00000000 +#define IXP2400_TX_MODE_MPHY_POLLED_STATUS 0x00020000 +#define IXP2400_TX_MODE_MPHY_DIRECT_STATUS 0x00000000 +#define IXP2400_TX_MODE_CBUS_FULL_DUPLEX 0x00010000 +#define IXP2400_TX_MODE_CBUS_SIMPLEX 0x00000000 +#define IXP2400_TX_MODE_MPHY_LEVEL2 0x00004000 +#define IXP2400_TX_MODE_MPHY_LEVEL3 0x00000000 +#define IXP2400_TX_MODE_CBUS_8BIT 0x00002000 +#define IXP2400_TX_MODE_CBUS_4BIT 0x00000000 +#define IXP2400_TX_MODE_TBUF_SIZE_MASK 0x0000000c +#define IXP2400_TX_MODE_TBUF_SIZE_256 0x00000008 +#define IXP2400_TX_MODE_TBUF_SIZE_128 0x00000004 +#define IXP2400_TX_MODE_TBUF_SIZE_64 0x00000000 + +#define IXP2400_PORT_TX_MODE_SLAVE 0x00000040 +#define IXP2400_PORT_TX_MODE_MASTER 0x00000000 +#define IXP2400_PORT_TX_MODE_POS_PHY 0x00000010 +#define IXP2400_PORT_TX_MODE_UTOPIA 0x00000000 +#define IXP2400_PORT_TX_MODE_EVEN_PARITY 0x0000000c +#define IXP2400_PORT_TX_MODE_ODD_PARITY 0x00000008 +#define IXP2400_PORT_TX_MODE_NO_PARITY 0x00000000 +#define IXP2400_PORT_TX_MODE_UTOPIA_BIG_CELLS 0x00000002 +#define IXP2400_PORT_TX_MODE_2_CYCLE_DECODE 0x00000001 +#define IXP2400_PORT_TX_MODE_1_CYCLE_DECODE 0x00000000 + + +#endif diff --git a/drivers/net/ixp2000/ixp2400_rx.uc b/drivers/net/ixp2000/ixp2400_rx.uc new file mode 100644 index 0000000..42a73e35 --- /dev/null +++ b/drivers/net/ixp2000/ixp2400_rx.uc @@ -0,0 +1,408 @@ +/* + * RX ucode for the Intel IXP2400 in POS-PHY mode. + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Assumptions made in this code: + * - The IXP2400 MSF is configured for POS-PHY mode, in a mode where + * only one full element list is used. This includes, for example, + * 1x32 SPHY and 1x32 MPHY32, but not 4x8 SPHY or 1x32 MPHY4. (This + * is not an exhaustive list.) + * - The RBUF uses 64-byte mpackets. + * - RX descriptors reside in SRAM, and have the following format: + * struct rx_desc + * { + * // to uengine + * u32 buf_phys_addr; + * u32 buf_length; + * + * // from uengine + * u32 channel; + * u32 pkt_length; + * }; + * - Packet data resides in DRAM. + * - Packet buffer addresses are 8-byte aligned. + * - Scratch ring 0 is rx_pending. + * - Scratch ring 1 is rx_done, and has status condition 'full'. + * - The host triggers rx_done flush and rx_pending refill on seeing INTA. + * - This code is run on all eight threads of the microengine it runs on. + * + * Local memory is used for per-channel RX state. + */ + +#define RX_THREAD_FREELIST_0 0x0030 +#define RBUF_ELEMENT_DONE 0x0044 + +#define CHANNEL_FLAGS *l$index0[0] +#define CHANNEL_FLAG_RECEIVING 1 +#define PACKET_LENGTH *l$index0[1] +#define PACKET_CHECKSUM *l$index0[2] +#define BUFFER_HANDLE *l$index0[3] +#define BUFFER_START *l$index0[4] +#define BUFFER_LENGTH *l$index0[5] + +#define CHANNEL_STATE_SIZE 24 // in bytes +#define CHANNEL_STATE_SHIFT 5 // ceil(log2(state size)) + + + .sig volatile sig1 + .sig volatile sig2 + .sig volatile sig3 + + .sig mpacket_arrived + .reg add_to_rx_freelist + .reg read $rsw0, $rsw1 + .xfer_order $rsw0 $rsw1 + + .reg zero + + /* + * Initialise add_to_rx_freelist. + */ + .begin + .reg temp + .reg temp2 + + immed[add_to_rx_freelist, RX_THREAD_FREELIST_0] + immed_w1[add_to_rx_freelist, (&$rsw0 | (&mpacket_arrived << 12))] + + local_csr_rd[ACTIVE_CTX_STS] + immed[temp, 0] + alu[temp2, temp, and, 0x1f] + alu_shf[add_to_rx_freelist, add_to_rx_freelist, or, temp2, <<20] + alu[temp2, temp, and, 0x80] + alu_shf[add_to_rx_freelist, add_to_rx_freelist, or, temp2, <<18] + .end + + immed[zero, 0] + + /* + * Skip context 0 initialisation? + */ + .begin + br!=ctx[0, mpacket_receive_loop#] + .end + + /* + * Initialise local memory. + */ + .begin + .reg addr + .reg temp + + immed[temp, 0] + init_local_mem_loop#: + alu_shf[addr, --, b, temp, <>8] + bne[abort_rswerr#] + .end + + /* + * Point local memory pointer to this channel's state area. + */ + .begin + .reg chanaddr + + alu[chanaddr, $rsw0, and, 0x1f] + alu_shf[chanaddr, --, b, chanaddr, < abort) If everything's + * okay, update the RECEIVING flag to reflect our new state. + */ + .begin + .reg temp + .reg eop + + #if CHANNEL_FLAG_RECEIVING != 1 + #error CHANNEL_FLAG_RECEIVING is not 1 + #endif + + alu_shf[temp, 1, and, $rsw0, >>15] + alu[temp, temp, xor, CHANNEL_FLAGS] + alu[--, temp, and, CHANNEL_FLAG_RECEIVING] + beq[abort_proterr#] + + alu_shf[eop, 1, and, $rsw0, >>14] + alu[CHANNEL_FLAGS, temp, xor, eop] + .end + + /* + * Copy the mpacket into the right spot, and in case of EOP, + * write back the descriptor and pass the packet on. + */ + .begin + .reg buffer_offset + .reg _packet_length + .reg _packet_checksum + .reg _buffer_handle + .reg _buffer_start + .reg _buffer_length + + /* + * Determine buffer_offset, _packet_length and + * _packet_checksum. + */ + .begin + .reg temp + + alu[--, 1, and, $rsw0, >>15] + beq[not_sop#] + + immed[PACKET_LENGTH, 0] + immed[PACKET_CHECKSUM, 0] + + not_sop#: + alu[buffer_offset, --, b, PACKET_LENGTH] + alu_shf[temp, 0xff, and, $rsw0, >>16] + alu[_packet_length, buffer_offset, +, temp] + alu[PACKET_LENGTH, --, b, _packet_length] + + immed[temp, 0xffff] + alu[temp, $rsw1, and, temp] + alu[_packet_checksum, PACKET_CHECKSUM, +, temp] + alu[PACKET_CHECKSUM, --, b, _packet_checksum] + .end + + /* + * Allocate buffer in case of SOP. + */ + .begin + .reg temp + + alu[temp, 1, and, $rsw0, >>15] + beq[skip_buffer_alloc#] + + .begin + .sig zzz + .reg read $stemp $stemp2 + .xfer_order $stemp $stemp2 + + rx_nobufs#: + scratch[get, $stemp, zero, 0, 1], ctx_swap[zzz] + alu[_buffer_handle, --, b, $stemp] + beq[rx_nobufs#] + + sram[read, $stemp, _buffer_handle, 0, 2], + ctx_swap[zzz] + alu[_buffer_start, --, b, $stemp] + alu[_buffer_length, --, b, $stemp2] + .end + + skip_buffer_alloc#: + .end + + /* + * Resynchronise. + */ + .begin + ctx_arb[sig2] + local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig2 << 3))] + .end + + /* + * Synchronise buffer state. + */ + .begin + .reg temp + + alu[temp, 1, and, $rsw0, >>15] + beq[copy_from_local_mem#] + + alu[BUFFER_HANDLE, --, b, _buffer_handle] + alu[BUFFER_START, --, b, _buffer_start] + alu[BUFFER_LENGTH, --, b, _buffer_length] + br[sync_state_done#] + + copy_from_local_mem#: + alu[_buffer_handle, --, b, BUFFER_HANDLE] + alu[_buffer_start, --, b, BUFFER_START] + alu[_buffer_length, --, b, BUFFER_LENGTH] + + sync_state_done#: + .end + +#if 0 + /* + * Debug buffer state management. + */ + .begin + .reg temp + + alu[temp, 1, and, $rsw0, >>14] + beq[no_poison#] + immed[BUFFER_HANDLE, 0xdead] + immed[BUFFER_START, 0xdead] + immed[BUFFER_LENGTH, 0xdead] + no_poison#: + + immed[temp, 0xdead] + alu[--, _buffer_handle, -, temp] + beq[state_corrupted#] + alu[--, _buffer_start, -, temp] + beq[state_corrupted#] + alu[--, _buffer_length, -, temp] + beq[state_corrupted#] + .end +#endif + + /* + * Check buffer length. + */ + .begin + alu[--, _buffer_length, -, _packet_length] + blo[buffer_overflow#] + .end + + /* + * Copy the mpacket and give back the RBUF element. + */ + .begin + .reg element + .reg xfer_size + .reg temp + .sig copy_sig + + alu_shf[element, 0x7f, and, $rsw0, >>24] + alu_shf[xfer_size, 0xff, and, $rsw0, >>16] + + alu[xfer_size, xfer_size, -, 1] + alu_shf[xfer_size, 0x10, or, xfer_size, >>3] + alu_shf[temp, 0x10, or, xfer_size, <<21] + alu_shf[temp, temp, or, element, <<11] + alu_shf[--, temp, or, 1, <<18] + + dram[rbuf_rd, --, _buffer_start, buffer_offset, max_8], + indirect_ref, sig_done[copy_sig] + ctx_arb[copy_sig] + + alu[temp, RBUF_ELEMENT_DONE, or, element, <<16] + msf[fast_wr, --, temp, 0] + .end + + /* + * If EOP, write back the packet descriptor. + */ + .begin + .reg write $stemp $stemp2 + .xfer_order $stemp $stemp2 + .sig zzz + + alu_shf[--, 1, and, $rsw0, >>14] + beq[no_writeback#] + + alu[$stemp, $rsw0, and, 0x1f] + alu[$stemp2, --, b, _packet_length] + sram[write, $stemp, _buffer_handle, 8, 2], ctx_swap[zzz] + + no_writeback#: + .end + + /* + * Resynchronise. + */ + .begin + ctx_arb[sig3] + local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig3 << 3))] + .end + + /* + * If EOP, put the buffer back onto the scratch ring. + */ + .begin + .reg write $stemp + .sig zzz + + br_inp_state[SCR_Ring1_Status, rx_done_ring_overflow#] + + alu_shf[--, 1, and, $rsw0, >>14] + beq[mpacket_receive_loop#] + + alu[--, 1, and, $rsw0, >>10] + bne[rxerr#] + + alu[$stemp, --, b, _buffer_handle] + scratch[put, $stemp, zero, 4, 1], ctx_swap[zzz] + cap[fast_wr, 0, XSCALE_INT_A] + br[mpacket_receive_loop#] + + rxerr#: + alu[$stemp, --, b, _buffer_handle] + scratch[put, $stemp, zero, 0, 1], ctx_swap[zzz] + br[mpacket_receive_loop#] + .end + .end + + +abort_rswerr#: + halt + +abort_proterr#: + halt + +state_corrupted#: + halt + +buffer_overflow#: + halt + +rx_done_ring_overflow#: + halt + + diff --git a/drivers/net/ixp2000/ixp2400_rx.ucode b/drivers/net/ixp2000/ixp2400_rx.ucode new file mode 100644 index 0000000..e8aee2f --- /dev/null +++ b/drivers/net/ixp2000/ixp2400_rx.ucode @@ -0,0 +1,130 @@ +static struct ixp2000_uengine_code ixp2400_rx = +{ + .cpu_model_bitmask = 0x000003fe, + .cpu_min_revision = 0, + .cpu_max_revision = 255, + + .uengine_parameters = IXP2000_UENGINE_8_CONTEXTS | + IXP2000_UENGINE_PRN_UPDATE_EVERY | + IXP2000_UENGINE_NN_FROM_PREVIOUS | + IXP2000_UENGINE_ASSERT_EMPTY_AT_0 | + IXP2000_UENGINE_LM_ADDR1_PER_CONTEXT | + IXP2000_UENGINE_LM_ADDR0_PER_CONTEXT, + + .initial_reg_values = (struct ixp2000_reg_value []) { + { -1, -1 } + }, + + .num_insns = 109, + .insns = (u8 []) { + 0xf0, 0x00, 0x0c, 0xc0, 0x05, + 0xf4, 0x44, 0x0c, 0x00, 0x05, + 0xfc, 0x04, 0x4c, 0x00, 0x00, + 0xf0, 0x00, 0x00, 0x3b, 0x00, + 0xb4, 0x40, 0xf0, 0x3b, 0x1f, + 0x8a, 0xc0, 0x50, 0x3e, 0x05, + 0xb4, 0x40, 0xf0, 0x3b, 0x80, + 0x9a, 0xe0, 0x00, 0x3e, 0x05, + 0xf0, 0x00, 0x00, 0x07, 0x00, + 0xd8, 0x05, 0xc0, 0x00, 0x11, + 0xf0, 0x00, 0x00, 0x0f, 0x00, + 0x91, 0xb0, 0x20, 0x0e, 0x00, + 0xfc, 0x06, 0x60, 0x0b, 0x00, + 0xf0, 0x00, 0x0c, 0x03, 0x00, + 0xf0, 0x00, 0x0c, 0x03, 0x00, + 0xf0, 0x00, 0x0c, 0x03, 0x00, + 0xf0, 0x00, 0x0c, 0x02, 0x00, + 0xb0, 0xc0, 0x30, 0x0f, 0x01, + 0xa4, 0x70, 0x00, 0x0f, 0x20, + 0xd8, 0x02, 0xc0, 0x01, 0x00, + 0xfc, 0x10, 0xac, 0x23, 0x08, + 0xfc, 0x10, 0xac, 0x43, 0x10, + 0xfc, 0x10, 0xac, 0x63, 0x18, + 0xe0, 0x00, 0x00, 0x00, 0x02, + 0xfc, 0x10, 0xae, 0x23, 0x88, + 0x3d, 0x00, 0x04, 0x03, 0x20, + 0xe0, 0x00, 0x00, 0x00, 0x10, + 0x84, 0x82, 0x02, 0x01, 0x3b, + 0xd8, 0x1a, 0x00, 0x01, 0x01, + 0xb4, 0x00, 0x8c, 0x7d, 0x80, + 0x91, 0xb0, 0x80, 0x22, 0x00, + 0xfc, 0x06, 0x60, 0x23, 0x00, + 0xf0, 0x00, 0x0c, 0x03, 0x00, + 0xf0, 0x00, 0x0c, 0x03, 0x00, + 0xf0, 0x00, 0x0c, 0x03, 0x00, + 0x94, 0xf0, 0x92, 0x01, 0x21, + 0xac, 0x40, 0x60, 0x26, 0x00, + 0xa4, 0x30, 0x0c, 0x04, 0x06, + 0xd8, 0x1a, 0x40, 0x01, 0x00, + 0x94, 0xe0, 0xa2, 0x01, 0x21, + 0xac, 0x20, 0x00, 0x28, 0x06, + 0x84, 0xf2, 0x02, 0x01, 0x21, + 0xd8, 0x0b, 0x40, 0x01, 0x00, + 0xf0, 0x00, 0x0c, 0x02, 0x01, + 0xf0, 0x00, 0x0c, 0x02, 0x02, + 0xa0, 0x00, 0x08, 0x04, 0x00, + 0x95, 0x00, 0xc6, 0x01, 0xff, + 0xa0, 0x80, 0x10, 0x30, 0x00, + 0xa0, 0x60, 0x1c, 0x00, 0x01, + 0xf0, 0x0f, 0xf0, 0x33, 0xff, + 0xb4, 0x00, 0xc0, 0x31, 0x81, + 0xb0, 0x80, 0xb0, 0x32, 0x02, + 0xa0, 0x20, 0x20, 0x2c, 0x00, + 0x94, 0xf0, 0xd2, 0x01, 0x21, + 0xd8, 0x0f, 0x40, 0x01, 0x00, + 0x19, 0x40, 0x10, 0x04, 0x20, + 0xa0, 0x00, 0x26, 0x04, 0x00, + 0xd8, 0x0d, 0xc0, 0x01, 0x00, + 0x00, 0x42, 0x10, 0x80, 0x02, + 0xb0, 0x00, 0x46, 0x04, 0x00, + 0xb0, 0x00, 0x56, 0x08, 0x00, + 0xe0, 0x00, 0x00, 0x00, 0x04, + 0xfc, 0x10, 0xae, 0x43, 0x90, + 0x84, 0xf0, 0x32, 0x01, 0x21, + 0xd8, 0x11, 0x40, 0x01, 0x00, + 0xa0, 0x60, 0x3c, 0x00, 0x02, + 0xa0, 0x20, 0x40, 0x10, 0x00, + 0xa0, 0x20, 0x50, 0x14, 0x00, + 0xd8, 0x12, 0x00, 0x00, 0x18, + 0xa0, 0x00, 0x28, 0x0c, 0x00, + 0xb0, 0x00, 0x48, 0x10, 0x00, + 0xb0, 0x00, 0x58, 0x14, 0x00, + 0xaa, 0xf0, 0x00, 0x14, 0x01, + 0xd8, 0x1a, 0xc0, 0x01, 0x05, + 0x85, 0x80, 0x42, 0x01, 0xff, + 0x95, 0x00, 0x66, 0x01, 0xff, + 0xba, 0xc0, 0x60, 0x1b, 0x01, + 0x9a, 0x30, 0x60, 0x19, 0x30, + 0x9a, 0xb0, 0x70, 0x1a, 0x30, + 0x9b, 0x50, 0x78, 0x1e, 0x04, + 0x8a, 0xe2, 0x08, 0x1e, 0x21, + 0x6a, 0x4e, 0x00, 0x13, 0x00, + 0xe0, 0x00, 0x00, 0x00, 0x30, + 0x9b, 0x00, 0x7a, 0x92, 0x04, + 0x3d, 0x00, 0x04, 0x1f, 0x20, + 0x84, 0xe2, 0x02, 0x01, 0x21, + 0xd8, 0x16, 0x80, 0x01, 0x00, + 0xa4, 0x18, 0x0c, 0x7d, 0x80, + 0xa0, 0x58, 0x1c, 0x00, 0x01, + 0x01, 0x42, 0x00, 0xa0, 0x02, + 0xe0, 0x00, 0x00, 0x00, 0x08, + 0xfc, 0x10, 0xae, 0x63, 0x98, + 0xd8, 0x1b, 0x00, 0xc2, 0x14, + 0x84, 0xe2, 0x02, 0x01, 0x21, + 0xd8, 0x05, 0xc0, 0x01, 0x00, + 0x84, 0xa2, 0x02, 0x01, 0x21, + 0xd8, 0x19, 0x40, 0x01, 0x01, + 0xa0, 0x58, 0x0c, 0x00, 0x02, + 0x1a, 0x40, 0x00, 0x04, 0x24, + 0x33, 0x00, 0x01, 0x2f, 0x20, + 0xd8, 0x05, 0xc0, 0x00, 0x18, + 0xa0, 0x58, 0x0c, 0x00, 0x02, + 0x1a, 0x40, 0x00, 0x04, 0x20, + 0xd8, 0x05, 0xc0, 0x00, 0x18, + 0xe0, 0x00, 0x02, 0x00, 0x00, + 0xe0, 0x00, 0x02, 0x00, 0x00, + 0xe0, 0x00, 0x02, 0x00, 0x00, + 0xe0, 0x00, 0x02, 0x00, 0x00, + 0xe0, 0x00, 0x02, 0x00, 0x00, + } +}; diff --git a/drivers/net/ixp2000/ixp2400_tx.uc b/drivers/net/ixp2000/ixp2400_tx.uc new file mode 100644 index 0000000..d090d18 --- /dev/null +++ b/drivers/net/ixp2000/ixp2400_tx.uc @@ -0,0 +1,272 @@ +/* + * TX ucode for the Intel IXP2400 in POS-PHY mode. + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Assumptions made in this code: + * - The IXP2400 MSF is configured for POS-PHY mode, in a mode where + * only one TBUF partition is used. This includes, for example, + * 1x32 SPHY and 1x32 MPHY32, but not 4x8 SPHY or 1x32 MPHY4. (This + * is not an exhaustive list.) + * - The TBUF uses 64-byte mpackets. + * - TX descriptors reside in SRAM, and have the following format: + * struct tx_desc + * { + * // to uengine + * u32 buf_phys_addr; + * u32 pkt_length; + * u32 channel; + * }; + * - Packet data resides in DRAM. + * - Packet buffer addresses are 8-byte aligned. + * - Scratch ring 2 is tx_pending. + * - Scratch ring 3 is tx_done, and has status condition 'full'. + * - This code is run on all eight threads of the microengine it runs on. + */ + +#define TX_SEQUENCE_0 0x0060 +#define TBUF_CTRL 0x1800 + +#define PARTITION_SIZE 128 +#define PARTITION_THRESH 96 + + + .sig volatile sig1 + .sig volatile sig2 + .sig volatile sig3 + + .reg @old_tx_seq_0 + .reg @mpkts_in_flight + .reg @next_tbuf_mpacket + + .reg @buffer_handle + .reg @buffer_start + .reg @packet_length + .reg @channel + .reg @packet_offset + + .reg zero + + immed[zero, 0] + + /* + * Skip context 0 initialisation? + */ + .begin + br!=ctx[0, mpacket_tx_loop#] + .end + + /* + * Wait until all pending TBUF elements have been transmitted. + */ + .begin + .reg read $tx + .sig zzz + + loop_empty#: + msf[read, $tx, zero, TX_SEQUENCE_0, 1], ctx_swap[zzz] + alu_shf[--, --, b, $tx, >>31] + beq[loop_empty#] + + alu[@old_tx_seq_0, --, b, $tx] + .end + + immed[@mpkts_in_flight, 0] + alu[@next_tbuf_mpacket, @old_tx_seq_0, and, (PARTITION_SIZE - 1)] + + immed[@buffer_handle, 0] + + /* + * Initialise signal pipeline. + */ + .begin + local_csr_wr[SAME_ME_SIGNAL, (&sig1 << 3)] + .set_sig sig1 + + local_csr_wr[SAME_ME_SIGNAL, (&sig2 << 3)] + .set_sig sig2 + + local_csr_wr[SAME_ME_SIGNAL, (&sig3 << 3)] + .set_sig sig3 + .end + +mpacket_tx_loop#: + .begin + .reg tbuf_element_index + .reg buffer_handle + .reg sop_eop + .reg packet_data + .reg channel + .reg mpacket_size + + /* + * If there is no packet currently being transmitted, + * dequeue the next TX descriptor, and fetch the buffer + * address, packet length and destination channel number. + */ + .begin + .reg read $stemp $stemp2 $stemp3 + .xfer_order $stemp $stemp2 $stemp3 + .sig zzz + + ctx_arb[sig1] + + alu[--, --, b, @buffer_handle] + bne[already_got_packet#] + + tx_nobufs#: + scratch[get, $stemp, zero, 8, 1], ctx_swap[zzz] + alu[@buffer_handle, --, b, $stemp] + beq[tx_nobufs#] + + sram[read, $stemp, $stemp, 0, 3], ctx_swap[zzz] + alu[@buffer_start, --, b, $stemp] + alu[@packet_length, --, b, $stemp2] + beq[zero_byte_packet#] + alu[@channel, --, b, $stemp3] + immed[@packet_offset, 0] + + already_got_packet#: + local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig1 << 3))] + .end + + /* + * Determine tbuf element index, SOP/EOP flags, mpacket + * offset and mpacket size and cache buffer_handle and + * channel number. + */ + .begin + alu[tbuf_element_index, --, b, @next_tbuf_mpacket] + alu[@next_tbuf_mpacket, @next_tbuf_mpacket, +, 1] + alu[@next_tbuf_mpacket, @next_tbuf_mpacket, and, + (PARTITION_SIZE - 1)] + + alu[buffer_handle, --, b, @buffer_handle] + immed[@buffer_handle, 0] + + immed[sop_eop, 1] + + alu[packet_data, --, b, @packet_offset] + bne[no_sop#] + alu[sop_eop, sop_eop, or, 2] + no_sop#: + alu[packet_data, packet_data, +, @buffer_start] + + alu[channel, --, b, @channel] + + alu[mpacket_size, @packet_length, -, @packet_offset] + alu[--, 64, -, mpacket_size] + bhs[eop#] + alu[@buffer_handle, --, b, buffer_handle] + immed[mpacket_size, 64] + alu[sop_eop, sop_eop, and, 2] + eop#: + + alu[@packet_offset, @packet_offset, +, mpacket_size] + .end + + /* + * Wait until there's enough space in the TBUF. + */ + .begin + .reg read $tx + .reg temp + .sig zzz + + ctx_arb[sig2] + + br[test_space#] + + loop_space#: + msf[read, $tx, zero, TX_SEQUENCE_0, 1], ctx_swap[zzz] + + alu[temp, $tx, -, @old_tx_seq_0] + alu[temp, temp, and, 0xff] + alu[@mpkts_in_flight, @mpkts_in_flight, -, temp] + + alu[@old_tx_seq_0, --, b, $tx] + + test_space#: + alu[--, PARTITION_THRESH, -, @mpkts_in_flight] + blo[loop_space#] + + alu[@mpkts_in_flight, @mpkts_in_flight, +, 1] + + local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig2 << 3))] + .end + + /* + * Copy the packet data to the TBUF. + */ + .begin + .reg temp + .sig copy_sig + + alu[temp, mpacket_size, -, 1] + alu_shf[temp, 0x10, or, temp, >>3] + alu_shf[temp, 0x10, or, temp, <<21] + alu_shf[temp, temp, or, tbuf_element_index, <<11] + alu_shf[--, temp, or, 1, <<18] + + dram[tbuf_wr, --, packet_data, 0, max_8], + indirect_ref, sig_done[copy_sig] + ctx_arb[copy_sig] + .end + + /* + * Mark TBUF element as ready-to-be-transmitted. + */ + .begin + .reg write $tsw $tsw2 + .xfer_order $tsw $tsw2 + .reg temp + .sig zzz + + alu_shf[temp, channel, or, mpacket_size, <<24] + alu_shf[$tsw, temp, or, sop_eop, <<8] + immed[$tsw2, 0] + + immed[temp, TBUF_CTRL] + alu_shf[temp, temp, or, tbuf_element_index, <<3] + msf[write, $tsw, temp, 0, 2], ctx_swap[zzz] + .end + + /* + * Resynchronise. + */ + .begin + ctx_arb[sig3] + local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig3 << 3))] + .end + + /* + * If this was an EOP mpacket, recycle the TX buffer + * and signal the host. + */ + .begin + .reg write $stemp + .sig zzz + + alu[--, sop_eop, and, 1] + beq[mpacket_tx_loop#] + + tx_done_ring_full#: + br_inp_state[SCR_Ring3_Status, tx_done_ring_full#] + + alu[$stemp, --, b, buffer_handle] + scratch[put, $stemp, zero, 12, 1], ctx_swap[zzz] + cap[fast_wr, 0, XSCALE_INT_A] + br[mpacket_tx_loop#] + .end + .end + + +zero_byte_packet#: + halt + + diff --git a/drivers/net/ixp2000/ixp2400_tx.ucode b/drivers/net/ixp2000/ixp2400_tx.ucode new file mode 100644 index 0000000..a433e24 --- /dev/null +++ b/drivers/net/ixp2000/ixp2400_tx.ucode @@ -0,0 +1,98 @@ +static struct ixp2000_uengine_code ixp2400_tx = +{ + .cpu_model_bitmask = 0x000003fe, + .cpu_min_revision = 0, + .cpu_max_revision = 255, + + .uengine_parameters = IXP2000_UENGINE_8_CONTEXTS | + IXP2000_UENGINE_PRN_UPDATE_EVERY | + IXP2000_UENGINE_NN_FROM_PREVIOUS | + IXP2000_UENGINE_ASSERT_EMPTY_AT_0 | + IXP2000_UENGINE_LM_ADDR1_PER_CONTEXT | + IXP2000_UENGINE_LM_ADDR0_PER_CONTEXT, + + .initial_reg_values = (struct ixp2000_reg_value []) { + { -1, -1 } + }, + + .num_insns = 77, + .insns = (u8 []) { + 0xf0, 0x00, 0x00, 0x07, 0x00, + 0xd8, 0x03, 0x00, 0x00, 0x11, + 0x3c, 0x40, 0x00, 0x04, 0xe0, + 0x81, 0xf2, 0x02, 0x01, 0x00, + 0xd8, 0x00, 0x80, 0x01, 0x00, + 0xb0, 0x08, 0x06, 0x00, 0x00, + 0xf0, 0x00, 0x0c, 0x00, 0x80, + 0xb4, 0x49, 0x02, 0x03, 0x7f, + 0xf0, 0x00, 0x02, 0x83, 0x00, + 0xfc, 0x10, 0xac, 0x23, 0x08, + 0xfc, 0x10, 0xac, 0x43, 0x10, + 0xfc, 0x10, 0xac, 0x63, 0x18, + 0xe0, 0x00, 0x00, 0x00, 0x02, + 0xa0, 0x30, 0x02, 0x80, 0x00, + 0xd8, 0x06, 0x00, 0x01, 0x01, + 0x19, 0x40, 0x00, 0x04, 0x28, + 0xb0, 0x0a, 0x06, 0x00, 0x00, + 0xd8, 0x03, 0xc0, 0x01, 0x00, + 0x00, 0x44, 0x00, 0x80, 0x80, + 0xa0, 0x09, 0x06, 0x00, 0x00, + 0xb0, 0x0b, 0x06, 0x04, 0x00, + 0xd8, 0x13, 0x00, 0x01, 0x00, + 0xb0, 0x0c, 0x06, 0x08, 0x00, + 0xf0, 0x00, 0x0c, 0x00, 0xa0, + 0xfc, 0x10, 0xae, 0x23, 0x88, + 0xa0, 0x00, 0x12, 0x40, 0x00, + 0xb0, 0xc9, 0x02, 0x43, 0x01, + 0xb4, 0x49, 0x02, 0x43, 0x7f, + 0xb0, 0x00, 0x22, 0x80, 0x00, + 0xf0, 0x00, 0x02, 0x83, 0x00, + 0xf0, 0x00, 0x0c, 0x04, 0x02, + 0xb0, 0x40, 0x6c, 0x00, 0xa0, + 0xd8, 0x08, 0x80, 0x01, 0x01, + 0xaa, 0x00, 0x2c, 0x08, 0x02, + 0xa0, 0xc0, 0x30, 0x18, 0x90, + 0xa0, 0x00, 0x43, 0x00, 0x00, + 0xba, 0xc0, 0x32, 0xc0, 0xa0, + 0xaa, 0xb0, 0x00, 0x0f, 0x40, + 0xd8, 0x0a, 0x80, 0x01, 0x04, + 0xb0, 0x0a, 0x00, 0x08, 0x00, + 0xf0, 0x00, 0x00, 0x0f, 0x40, + 0xa4, 0x00, 0x2c, 0x08, 0x02, + 0xa0, 0x8a, 0x00, 0x0c, 0xa0, + 0xe0, 0x00, 0x00, 0x00, 0x04, + 0xd8, 0x0c, 0x80, 0x00, 0x18, + 0x3c, 0x40, 0x00, 0x04, 0xe0, + 0xba, 0x80, 0x42, 0x01, 0x80, + 0xb4, 0x40, 0x40, 0x13, 0xff, + 0xaa, 0x88, 0x00, 0x10, 0x80, + 0xb0, 0x08, 0x06, 0x00, 0x00, + 0xaa, 0xf0, 0x0d, 0x80, 0x80, + 0xd8, 0x0b, 0x40, 0x01, 0x05, + 0xa0, 0x88, 0x0c, 0x04, 0x80, + 0xfc, 0x10, 0xae, 0x43, 0x90, + 0xba, 0xc0, 0x50, 0x0f, 0x01, + 0x9a, 0x30, 0x50, 0x15, 0x30, + 0x9a, 0xb0, 0x50, 0x16, 0x30, + 0x9b, 0x50, 0x58, 0x16, 0x01, + 0x8a, 0xe2, 0x08, 0x16, 0x21, + 0x6b, 0x4e, 0x00, 0x83, 0x03, + 0xe0, 0x00, 0x00, 0x00, 0x30, + 0x9a, 0x80, 0x70, 0x0e, 0x04, + 0x8b, 0x88, 0x08, 0x1e, 0x02, + 0xf0, 0x00, 0x0c, 0x01, 0x81, + 0xf0, 0x01, 0x80, 0x1f, 0x00, + 0x9b, 0xd0, 0x78, 0x1e, 0x01, + 0x3d, 0x42, 0x00, 0x1c, 0x20, + 0xe0, 0x00, 0x00, 0x00, 0x08, + 0xfc, 0x10, 0xae, 0x63, 0x98, + 0xa4, 0x30, 0x0c, 0x04, 0x02, + 0xd8, 0x03, 0x00, 0x01, 0x00, + 0xd8, 0x11, 0xc1, 0x42, 0x14, + 0xa0, 0x18, 0x00, 0x08, 0x00, + 0x1a, 0x40, 0x00, 0x04, 0x2c, + 0x33, 0x00, 0x01, 0x2f, 0x20, + 0xd8, 0x03, 0x00, 0x00, 0x18, + 0xe0, 0x00, 0x02, 0x00, 0x00, + } +}; diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c new file mode 100644 index 0000000..216aad1 --- /dev/null +++ b/drivers/net/ixp2000/ixpdev.c @@ -0,0 +1,404 @@ +/* + * IXP2000 MSF network device driver + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ixp2400_rx.ucode" +#include "ixp2400_tx.ucode" +#include "ixpdev_priv.h" +#include "ixpdev.h" + +static int nds_count; +static struct net_device **nds; +static int nds_open; +static void (*set_port_admin_status)(int port, int up); + +static struct ixpdev_rx_desc * const rx_desc = + (struct ixpdev_rx_desc *)(IXP2000_SRAM0_VIRT_BASE + RX_BUF_DESC_BASE); +static struct ixpdev_tx_desc * const tx_desc = + (struct ixpdev_tx_desc *)(IXP2000_SRAM0_VIRT_BASE + TX_BUF_DESC_BASE); +static int tx_pointer; + + +static int ixpdev_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct ixpdev_priv *ip = netdev_priv(dev); + struct ixpdev_tx_desc *desc; + int entry; + + if (unlikely(skb->len > PAGE_SIZE)) { + /* @@@ Count drops. */ + dev_kfree_skb(skb); + return 0; + } + + entry = tx_pointer; + tx_pointer = (tx_pointer + 1) % TX_BUF_COUNT; + + desc = tx_desc + entry; + desc->pkt_length = skb->len; + desc->channel = ip->channel; + + skb_copy_and_csum_dev(skb, phys_to_virt(desc->buf_addr)); + dev_kfree_skb(skb); + + ixp2000_reg_write(RING_TX_PENDING, + TX_BUF_DESC_BASE + (entry * sizeof(struct ixpdev_tx_desc))); + + dev->trans_start = jiffies; + + local_irq_disable(); + ip->tx_queue_entries++; + if (ip->tx_queue_entries == TX_BUF_COUNT_PER_CHAN) + netif_stop_queue(dev); + local_irq_enable(); + + return 0; +} + + +static int ixpdev_rx(struct net_device *dev, int *budget) +{ + while (*budget > 0) { + struct ixpdev_rx_desc *desc; + struct sk_buff *skb; + void *buf; + u32 _desc; + + _desc = ixp2000_reg_read(RING_RX_DONE); + if (_desc == 0) + return 0; + + desc = rx_desc + + ((_desc - RX_BUF_DESC_BASE) / sizeof(struct ixpdev_rx_desc)); + buf = phys_to_virt(desc->buf_addr); + + if (desc->pkt_length < 4 || desc->pkt_length > PAGE_SIZE) { + printk(KERN_ERR "ixp2000: rx err, length %d\n", + desc->pkt_length); + goto err; + } + + if (desc->channel < 0 || desc->channel >= nds_count) { + printk(KERN_ERR "ixp2000: rx err, channel %d\n", + desc->channel); + goto err; + } + + /* @@@ Make FCS stripping configurable. */ + desc->pkt_length -= 4; + + if (unlikely(!netif_running(nds[desc->channel]))) + goto err; + + skb = dev_alloc_skb(desc->pkt_length + 2); + if (likely(skb != NULL)) { + skb->dev = nds[desc->channel]; + skb_reserve(skb, 2); + eth_copy_and_sum(skb, buf, desc->pkt_length, 0); + skb_put(skb, desc->pkt_length); + skb->protocol = eth_type_trans(skb, skb->dev); + + skb->dev->last_rx = jiffies; + + netif_receive_skb(skb); + } + +err: + ixp2000_reg_write(RING_RX_PENDING, _desc); + dev->quota--; + (*budget)--; + } + + return 1; +} + +/* dev always points to nds[0]. */ +static int ixpdev_poll(struct net_device *dev, int *budget) +{ + /* @@@ Have to stop polling when nds[0] is administratively + * downed while we are polling. */ + do { + ixp2000_reg_write(IXP2000_IRQ_THD_RAW_STATUS_A_0, 0x00ff); + + if (ixpdev_rx(dev, budget)) + return 1; + } while (ixp2000_reg_read(IXP2000_IRQ_THD_RAW_STATUS_A_0) & 0x00ff); + + netif_rx_complete(dev); + ixp2000_reg_write(IXP2000_IRQ_THD_ENABLE_SET_A_0, 0x00ff); + + return 0; +} + +/* @@@ Ugly hack. */ +static inline int netif_rx_schedule_prep_notup(struct net_device *dev) +{ + return !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state); +} + +static void ixpdev_tx_complete(void) +{ + int channel; + u32 wake; + + wake = 0; + while (1) { + struct ixpdev_priv *ip; + u32 desc; + int entry; + + desc = ixp2000_reg_read(RING_TX_DONE); + if (desc == 0) + break; + + /* @@@ Check whether entries come back in order. */ + entry = (desc - TX_BUF_DESC_BASE) / sizeof(struct ixpdev_tx_desc); + channel = tx_desc[entry].channel; + + if (channel < 0 || channel >= nds_count) { + printk(KERN_ERR "ixp2000: txcomp channel index " + "out of bounds (%d, %.8i, %d)\n", + channel, (unsigned int)desc, entry); + continue; + } + + ip = netdev_priv(nds[channel]); + if (ip->tx_queue_entries == TX_BUF_COUNT_PER_CHAN) + wake |= 1 << channel; + ip->tx_queue_entries--; + } + + for (channel = 0; wake != 0; channel++) { + if (wake & (1 << channel)) { + netif_wake_queue(nds[channel]); + wake &= ~(1 << channel); + } + } +} + +static irqreturn_t ixpdev_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + u32 status; + + status = ixp2000_reg_read(IXP2000_IRQ_THD_STATUS_A_0); + if (status == 0) + return IRQ_NONE; + + /* + * Any of the eight receive units signaled RX? + */ + if (status & 0x00ff) { + ixp2000_reg_wrb(IXP2000_IRQ_THD_ENABLE_CLEAR_A_0, 0x00ff); + if (likely(netif_rx_schedule_prep_notup(nds[0]))) { + __netif_rx_schedule(nds[0]); + } else { + printk(KERN_CRIT "ixp2000: irq while polling!!\n"); + } + } + + /* + * Any of the eight transmit units signaled TXdone? + */ + if (status & 0xff00) { + ixp2000_reg_wrb(IXP2000_IRQ_THD_RAW_STATUS_A_0, 0xff00); + ixpdev_tx_complete(); + } + + return IRQ_HANDLED; +} + +static int ixpdev_open(struct net_device *dev) +{ + struct ixpdev_priv *ip = netdev_priv(dev); + int err; + + if (!nds_open++) { + err = request_irq(IRQ_IXP2000_THDA0, ixpdev_interrupt, + SA_SHIRQ, "ixp2000_eth", nds); + if (err) { + nds_open--; + return err; + } + + ixp2000_reg_write(IXP2000_IRQ_THD_ENABLE_SET_A_0, 0xffff); + } + + set_port_admin_status(ip->channel, 1); + netif_start_queue(dev); + + return 0; +} + +static int ixpdev_close(struct net_device *dev) +{ + struct ixpdev_priv *ip = netdev_priv(dev); + + netif_stop_queue(dev); + set_port_admin_status(ip->channel, 0); + + if (!--nds_open) { + ixp2000_reg_write(IXP2000_IRQ_THD_ENABLE_CLEAR_A_0, 0xffff); + free_irq(IRQ_IXP2000_THDA0, nds); + } + + return 0; +} + +struct net_device *ixpdev_alloc(int channel, int sizeof_priv) +{ + struct net_device *dev; + struct ixpdev_priv *ip; + + dev = alloc_etherdev(sizeof_priv); + if (dev == NULL) + return NULL; + + dev->hard_start_xmit = ixpdev_xmit; + dev->poll = ixpdev_poll; + dev->open = ixpdev_open; + dev->stop = ixpdev_close; + + dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; + dev->weight = 64; + + ip = netdev_priv(dev); + ip->channel = channel; + ip->tx_queue_entries = 0; + + return dev; +} + +int ixpdev_init(int __nds_count, struct net_device **__nds, + void (*__set_port_admin_status)(int port, int up)) +{ + int i; + int err; + + if (RX_BUF_COUNT > 192 || TX_BUF_COUNT > 192) { + static void __too_many_rx_or_tx_buffers(void); + __too_many_rx_or_tx_buffers(); + } + + nds_count = __nds_count; + nds = __nds; + set_port_admin_status = __set_port_admin_status; + + for (i = 0; i < nds_count; i++) { + err = register_netdev(nds[i]); + if (err) { + while (--i >= 0) + unregister_netdev(nds[i]); + goto err_out; + } + } + + for (i = 0; i < RX_BUF_COUNT; i++) { + void *buf; + + buf = (void *)get_zeroed_page(GFP_KERNEL); + if (buf == NULL) { + err = -ENOMEM; + while (--i >= 0) + free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr)); + goto err_unregister; + } + rx_desc[i].buf_addr = virt_to_phys(buf); + rx_desc[i].buf_length = PAGE_SIZE; + } + + /* @@@ Maybe we shouldn't be preallocating TX buffers. */ + for (i = 0; i < TX_BUF_COUNT; i++) { + void *buf; + + buf = (void *)get_zeroed_page(GFP_KERNEL); + if (buf == NULL) { + err = -ENOMEM; + while (--i >= 0) + free_page((unsigned long)phys_to_virt(tx_desc[i].buf_addr)); + goto err_free_rx; + } + tx_desc[i].buf_addr = virt_to_phys(buf); + } + + /* 256 entries, ring status set means 'empty', base address 0x0000. */ + ixp2000_reg_write(RING_RX_PENDING_BASE, 0x44000000); + ixp2000_reg_write(RING_RX_PENDING_HEAD, 0x00000000); + ixp2000_reg_write(RING_RX_PENDING_TAIL, 0x00000000); + + /* 256 entries, ring status set means 'full', base address 0x0400. */ + ixp2000_reg_write(RING_RX_DONE_BASE, 0x40000400); + ixp2000_reg_write(RING_RX_DONE_HEAD, 0x00000000); + ixp2000_reg_write(RING_RX_DONE_TAIL, 0x00000000); + + for (i = 0; i < RX_BUF_COUNT; i++) { + ixp2000_reg_write(RING_RX_PENDING, + RX_BUF_DESC_BASE + (i * sizeof(struct ixpdev_rx_desc))); + } + + ixp2000_uengine_load(0, &ixp2400_rx); + ixp2000_uengine_start_contexts(0, 0xff); + + + /* 256 entries, ring status set means 'empty', base address 0x0800. */ + ixp2000_reg_write(RING_TX_PENDING_BASE, 0x44000800); + ixp2000_reg_write(RING_TX_PENDING_HEAD, 0x00000000); + ixp2000_reg_write(RING_TX_PENDING_TAIL, 0x00000000); + + /* 256 entries, ring status set means 'full', base address 0x0c00. */ + ixp2000_reg_write(RING_TX_DONE_BASE, 0x40000c00); + ixp2000_reg_write(RING_TX_DONE_HEAD, 0x00000000); + ixp2000_reg_write(RING_TX_DONE_TAIL, 0x00000000); + + ixp2000_uengine_load(1, &ixp2400_tx); + ixp2000_uengine_start_contexts(1, 0xff); + + return 0; + +err_free_rx: + for (i = 0; i < RX_BUF_COUNT; i++) + free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr)); + +err_unregister: + for (i = 0; i < nds_count; i++) + unregister_netdev(nds[i]); + +err_out: + return err; +} + +void ixpdev_deinit(void) +{ + int i; + + /* @@@ Flush out pending packets. */ + + ixp2000_uengine_stop_contexts(1, 0xff); + ixp2000_uengine_stop_contexts(0, 0xff); + ixp2000_uengine_reset(0x3); + + for (i = 0; i < TX_BUF_COUNT; i++) + free_page((unsigned long)phys_to_virt(tx_desc[i].buf_addr)); + + for (i = 0; i < RX_BUF_COUNT; i++) + free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr)); + + for (i = 0; i < nds_count; i++) + unregister_netdev(nds[i]); +} diff --git a/drivers/net/ixp2000/ixpdev.h b/drivers/net/ixp2000/ixpdev.h new file mode 100644 index 0000000..bd686cb --- /dev/null +++ b/drivers/net/ixp2000/ixpdev.h @@ -0,0 +1,27 @@ +/* + * IXP2000 MSF network device driver + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef __IXPDEV_H +#define __IXPDEV_H + +struct ixpdev_priv +{ + int channel; + int tx_queue_entries; +}; + +struct net_device *ixpdev_alloc(int channel, int sizeof_priv); +int ixpdev_init(int num_ports, struct net_device **nds, + void (*set_port_admin_status)(int port, int up)); +void ixpdev_deinit(void); + + +#endif diff --git a/drivers/net/ixp2000/ixpdev_priv.h b/drivers/net/ixp2000/ixpdev_priv.h new file mode 100644 index 0000000..86aa08e --- /dev/null +++ b/drivers/net/ixp2000/ixpdev_priv.h @@ -0,0 +1,57 @@ +/* + * IXP2000 MSF network device driver + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef __IXPDEV_PRIV_H +#define __IXPDEV_PRIV_H + +#define RX_BUF_DESC_BASE 0x00001000 +#define RX_BUF_COUNT ((3 * PAGE_SIZE) / (4 * sizeof(struct ixpdev_rx_desc))) +#define TX_BUF_DESC_BASE 0x00002000 +#define TX_BUF_COUNT ((3 * PAGE_SIZE) / (4 * sizeof(struct ixpdev_tx_desc))) +#define TX_BUF_COUNT_PER_CHAN (TX_BUF_COUNT / 4) + +#define RING_RX_PENDING ((u32 *)IXP2000_SCRATCH_RING_VIRT_BASE) +#define RING_RX_DONE ((u32 *)(IXP2000_SCRATCH_RING_VIRT_BASE + 4)) +#define RING_TX_PENDING ((u32 *)(IXP2000_SCRATCH_RING_VIRT_BASE + 8)) +#define RING_TX_DONE ((u32 *)(IXP2000_SCRATCH_RING_VIRT_BASE + 12)) + +#define SCRATCH_REG(x) ((u32 *)(IXP2000_GLOBAL_REG_VIRT_BASE | 0x0800 | (x))) +#define RING_RX_PENDING_BASE SCRATCH_REG(0x00) +#define RING_RX_PENDING_HEAD SCRATCH_REG(0x04) +#define RING_RX_PENDING_TAIL SCRATCH_REG(0x08) +#define RING_RX_DONE_BASE SCRATCH_REG(0x10) +#define RING_RX_DONE_HEAD SCRATCH_REG(0x14) +#define RING_RX_DONE_TAIL SCRATCH_REG(0x18) +#define RING_TX_PENDING_BASE SCRATCH_REG(0x20) +#define RING_TX_PENDING_HEAD SCRATCH_REG(0x24) +#define RING_TX_PENDING_TAIL SCRATCH_REG(0x28) +#define RING_TX_DONE_BASE SCRATCH_REG(0x30) +#define RING_TX_DONE_HEAD SCRATCH_REG(0x34) +#define RING_TX_DONE_TAIL SCRATCH_REG(0x38) + +struct ixpdev_rx_desc +{ + u32 buf_addr; + u32 buf_length; + u32 channel; + u32 pkt_length; +}; + +struct ixpdev_tx_desc +{ + u32 buf_addr; + u32 pkt_length; + u32 channel; + u32 unused; +}; + + +#endif diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c new file mode 100644 index 0000000..cf0681f --- /dev/null +++ b/drivers/net/ixp2000/pm3386.c @@ -0,0 +1,304 @@ +/* + * Helper functions for the PM3386s on the Radisys ENP2611 + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include + +/* + * Read from register 'reg' of PM3386 device 'pm'. + */ +static u16 pm3386_reg_read(int pm, int reg) +{ + void *_reg; + u16 value; + + _reg = (void *)ENP2611_PM3386_0_VIRT_BASE; + if (pm == 1) + _reg = (void *)ENP2611_PM3386_1_VIRT_BASE; + + value = *((volatile u16 *)(_reg + (reg << 1))); + +// printk(KERN_INFO "pm3386_reg_read(%d, %.3x) = %.8x\n", pm, reg, value); + + return value; +} + +/* + * Write to register 'reg' of PM3386 device 'pm', and perform + * a readback from the identification register. + */ +static void pm3386_reg_write(int pm, int reg, u16 value) +{ + void *_reg; + u16 dummy; + +// printk(KERN_INFO "pm3386_reg_write(%d, %.3x, %.8x)\n", pm, reg, value); + + _reg = (void *)ENP2611_PM3386_0_VIRT_BASE; + if (pm == 1) + _reg = (void *)ENP2611_PM3386_1_VIRT_BASE; + + *((volatile u16 *)(_reg + (reg << 1))) = value; + + dummy = *((volatile u16 *)_reg); + __asm__ __volatile__("mov %0, %0" : "+r" (dummy)); +} + +/* + * Read from port 'port' register 'reg', where the registers + * for the different ports are 'spacing' registers apart. + */ +static u16 pm3386_port_reg_read(int port, int _reg, int spacing) +{ + int reg; + + reg = _reg; + if (port & 1) + reg += spacing; + + return pm3386_reg_read(port >> 1, reg); +} + +/* + * Write to port 'port' register 'reg', where the registers + * for the different ports are 'spacing' registers apart. + */ +static void pm3386_port_reg_write(int port, int _reg, int spacing, u16 value) +{ + int reg; + + reg = _reg; + if (port & 1) + reg += spacing; + + pm3386_reg_write(port >> 1, reg, value); +} + + +void pm3386_reset(void) +{ + /* @@@ Implement me. */ +} + +static u16 swaph(u16 x) +{ + return ((x << 8) | (x >> 8)) & 0xffff; +} + +void pm3386_init_port(int port) +{ + int pm = port >> 1; + + /* + * Work around ENP2611 bootloader programming MAC address + * in reverse. + */ + if (pm3386_port_reg_read(port, 0x30a, 0x100) == 0x0000 && + (pm3386_port_reg_read(port, 0x309, 0x100) & 0xff00) == 0x5000) { + u16 temp[3]; + + temp[0] = pm3386_port_reg_read(port, 0x308, 0x100); + temp[1] = pm3386_port_reg_read(port, 0x309, 0x100); + temp[2] = pm3386_port_reg_read(port, 0x30a, 0x100); + pm3386_port_reg_write(port, 0x308, 0x100, swaph(temp[2])); + pm3386_port_reg_write(port, 0x309, 0x100, swaph(temp[1])); + pm3386_port_reg_write(port, 0x30a, 0x100, swaph(temp[0])); + } + + /* + * Initialise narrowbanding mode. See application note 2010486 + * for more information. (@@@ We also need to issue a reset + * when ROOL or DOOL are detected.) + */ + pm3386_port_reg_write(port, 0x708, 0x10, 0xd055); + udelay(500); + pm3386_port_reg_write(port, 0x708, 0x10, 0x5055); + + /* + * SPI-3 ingress block. Set 64 bytes SPI-3 burst size + * towards SPI-3 bridge. + */ + pm3386_port_reg_write(port, 0x122, 0x20, 0x0002); + + /* + * Enable ingress protocol checking, and soft reset the + * SPI-3 ingress block. + */ + pm3386_reg_write(pm, 0x103, 0x0003); + while (!(pm3386_reg_read(pm, 0x103) & 0x80)) + ; + + /* + * SPI-3 egress block. Gather 12288 bytes of the current + * packet in the TX fifo before initiating transmit on the + * SERDES interface. (Prevents TX underflows.) + */ + pm3386_port_reg_write(port, 0x221, 0x20, 0x0007); + + /* + * Enforce odd parity from the SPI-3 bridge, and soft reset + * the SPI-3 egress block. + */ + pm3386_reg_write(pm, 0x203, 0x000d & ~(4 << (port & 1))); + while ((pm3386_reg_read(pm, 0x203) & 0x000c) != 0x000c) + ; + + /* + * EGMAC block. Set this channels to reject long preambles, + * not send or transmit PAUSE frames, enable preamble checking, + * disable frame length checking, enable FCS appending, enable + * TX frame padding. + */ + pm3386_port_reg_write(port, 0x302, 0x100, 0x0113); + + /* + * Soft reset the EGMAC block. + */ + pm3386_port_reg_write(port, 0x301, 0x100, 0x8000); + udelay(10); + pm3386_port_reg_write(port, 0x301, 0x100, 0x0000); + udelay(10); + + /* + * Auto-sense autonegotiation status. + */ + pm3386_port_reg_write(port, 0x306, 0x100, 0x0100); + + /* + * Allow reception of jumbo frames. + */ + pm3386_port_reg_write(port, 0x310, 0x100, 9018); + + /* + * Allow transmission of jumbo frames. + */ + pm3386_port_reg_write(port, 0x336, 0x100, 9018); + + /* @@@ Should set 0x337/0x437 (RX forwarding threshold.) */ + + /* + * Set autonegotiation parameters to 'no PAUSE, full duplex.' + */ + pm3386_port_reg_write(port, 0x31c, 0x100, 0x0020); + udelay(10); + + /* + * Enable and restart autonegotiation. + */ + pm3386_port_reg_write(port, 0x318, 0x100, 0x0003); + udelay(1000); + pm3386_port_reg_write(port, 0x318, 0x100, 0x0002); + udelay(10); +} + +void pm3386_get_mac(int port, u8 *mac) +{ + u16 temp; + + temp = pm3386_port_reg_read(port, 0x308, 0x100); + mac[0] = temp & 0xff; + mac[1] = (temp >> 8) & 0xff; + + temp = pm3386_port_reg_read(port, 0x309, 0x100); + mac[2] = temp & 0xff; + mac[3] = (temp >> 8) & 0xff; + + temp = pm3386_port_reg_read(port, 0x30a, 0x100); + mac[4] = temp & 0xff; + mac[5] = (temp >> 8) & 0xff; +} + +static u32 pm3386_get_stat(int port, u16 base) +{ + u32 value; + + value = pm3386_port_reg_read(port, base, 0x100); + value |= pm3386_port_reg_read(port, base + 1, 0x100) << 16; + + return value; +} + +void pm3386_get_stats(int port, struct net_device_stats *stats) +{ + /* + * Snapshot statistics counters. + */ + pm3386_port_reg_write(port, 0x500, 0x100, 0x0001); + while (pm3386_port_reg_read(port, 0x500, 0x100) & 0x0001) + ; + + memset(stats, 0, sizeof(stats)); + + stats->rx_packets = pm3386_get_stat(port, 0x510); + stats->tx_packets = pm3386_get_stat(port, 0x590); + stats->rx_bytes = pm3386_get_stat(port, 0x514); + stats->tx_bytes = pm3386_get_stat(port, 0x594); + /* @@@ Add other stats. */ +} + +int pm3386_is_link_up(int port) +{ + u16 temp; + + temp = pm3386_port_reg_read(port, 0x31a, 0x100); + temp = pm3386_port_reg_read(port, 0x31a, 0x100); + + return !!(temp & 0x0002); +} + +void pm3386_enable_rx(int port) +{ + u16 temp; + + temp = pm3386_port_reg_read(port, 0x303, 0x100); + temp |= 0x1000; + pm3386_port_reg_write(port, 0x303, 0x100, temp); + + udelay(10); +} + +void pm3386_disable_rx(int port) +{ + u16 temp; + + temp = pm3386_port_reg_read(port, 0x303, 0x100); + temp &= 0xefff; + pm3386_port_reg_write(port, 0x303, 0x100, temp); + + udelay(10); +} + +void pm3386_enable_tx(int port) +{ + u16 temp; + + temp = pm3386_port_reg_read(port, 0x303, 0x100); + temp |= 0x4000; + pm3386_port_reg_write(port, 0x303, 0x100, temp); + + udelay(10); +} + +void pm3386_disable_tx(int port) +{ + u16 temp; + + temp = pm3386_port_reg_read(port, 0x303, 0x100); + temp &= 0xbfff; + pm3386_port_reg_write(port, 0x303, 0x100, temp); + + udelay(10); +} + +MODULE_LICENSE("GPL"); diff --git a/drivers/net/ixp2000/pm3386.h b/drivers/net/ixp2000/pm3386.h new file mode 100644 index 0000000..55ecb18 --- /dev/null +++ b/drivers/net/ixp2000/pm3386.h @@ -0,0 +1,26 @@ +/* + * Helper functions for the PM3386s on the Radisys ENP2611 + * Copyright (C) 2004, 2005 Lennert Buytenhek + * Dedicated to Marija Kulikova. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef __PM3386_H +#define __PM3386_H + +void pm3386_reset(void); +void pm3386_init_port(int port); +void pm3386_get_mac(int port, u8 *mac); +void pm3386_get_stats(int port, struct net_device_stats *stats); +int pm3386_is_link_up(int port); +void pm3386_enable_rx(int port); +void pm3386_disable_rx(int port); +void pm3386_enable_tx(int port); +void pm3386_disable_tx(int port); + + +#endif -- cgit v1.1 From e98fc4aae10b925ad5aa739c483abf78d80b66db Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Tue, 8 Nov 2005 15:45:02 -0500 Subject: [PATCH] e1000: avoid leak when e1000_setup_loopback_test fails In e1000_loopback_test, make sure to call e1000_free_desc_rings if e1000_setup_loopback_test fails. Currently in that case it will not get called, causing a leak. Signed-off-by: John W. Linville --- drivers/net/e1000/e1000_ethtool.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index 8eae8ba..8584e93 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c @@ -1440,9 +1440,11 @@ static int e1000_loopback_test(struct e1000_adapter *adapter, uint64_t *data) { if((*data = e1000_setup_desc_rings(adapter))) goto err_loopback; - if((*data = e1000_setup_loopback_test(adapter))) goto err_loopback; + if((*data = e1000_setup_loopback_test(adapter))) + goto err_loopback_setup; *data = e1000_run_loopback_test(adapter); e1000_loopback_cleanup(adapter); +err_loopback_setup: e1000_free_desc_rings(adapter); err_loopback: return *data; -- cgit v1.1 From 6b27adb607282addcfe2707783dfcc28ba3a753b Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Tue, 8 Nov 2005 15:59:30 -0500 Subject: [PATCH] e1000: zero-out pointers in e1000_free_desc_rings In e1000_free_desc_rings, zero-out pointers after the memory they point to is freed. The test rings are static and get re-used, and failures during subsequent test setups can cause e1000_free_desc_rings to get called with dirty pointers. Dirty pointers can cause oopses or crashes... Signed-off-by: John W. Linville --- drivers/net/e1000/e1000_ethtool.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index 8584e93..8646914 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c @@ -960,13 +960,21 @@ e1000_free_desc_rings(struct e1000_adapter *adapter) } } - if(txdr->desc) + if(txdr->desc) { pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma); - if(rxdr->desc) + txdr->desc = NULL; + } + if(rxdr->desc) { pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma); + rxdr->desc = NULL; + } kfree(txdr->buffer_info); + txdr->buffer_info = NULL; + kfree(rxdr->buffer_info); + rxdr->buffer_info = NULL; + return; } -- cgit v1.1 From b1c5f1c635f4a821f834ed51ccd8a2a1515fffd2 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 19 Nov 2005 19:13:34 +0100 Subject: kconfig: Lindent scripts/lxdialog The lxdialog code was not easy to read. So as first step the code was run through Lindent. Fix-ups will come in next patchset. Signed-off-by: Sam Ravnborg --- scripts/lxdialog/checklist.c | 656 +++++++++++++++-------------- scripts/lxdialog/colors.h | 1 - scripts/lxdialog/dialog.h | 59 ++- scripts/lxdialog/inputbox.c | 408 +++++++++--------- scripts/lxdialog/lxdialog.c | 238 +++++------ scripts/lxdialog/menubox.c | 724 +++++++++++++++++--------------- scripts/lxdialog/msgbox.c | 89 ++-- scripts/lxdialog/textbox.c | 968 ++++++++++++++++++++++--------------------- scripts/lxdialog/util.c | 467 ++++++++++----------- scripts/lxdialog/yesno.c | 158 ++++--- 10 files changed, 1921 insertions(+), 1847 deletions(-) diff --git a/scripts/lxdialog/checklist.c b/scripts/lxdialog/checklist.c index 7aba17c..1857c53 100644 --- a/scripts/lxdialog/checklist.c +++ b/scripts/lxdialog/checklist.c @@ -29,87 +29,83 @@ static int list_width, check_x, item_x, checkflag; * Print list item */ static void -print_item (WINDOW * win, const char *item, int status, - int choice, int selected) +print_item(WINDOW * win, const char *item, int status, int choice, int selected) { - int i; - - /* Clear 'residue' of last item */ - wattrset (win, menubox_attr); - wmove (win, choice, 0); - for (i = 0; i < list_width; i++) - waddch (win, ' '); - - wmove (win, choice, check_x); - wattrset (win, selected ? check_selected_attr : check_attr); - if (checkflag == FLAG_CHECK) - wprintw (win, "[%c]", status ? 'X' : ' '); - else - wprintw (win, "(%c)", status ? 'X' : ' '); - - wattrset (win, selected ? tag_selected_attr : tag_attr); - mvwaddch(win, choice, item_x, item[0]); - wattrset (win, selected ? item_selected_attr : item_attr); - waddstr (win, (char *)item+1); - if (selected) { - wmove (win, choice, check_x+1); - wrefresh (win); - } + int i; + + /* Clear 'residue' of last item */ + wattrset(win, menubox_attr); + wmove(win, choice, 0); + for (i = 0; i < list_width; i++) + waddch(win, ' '); + + wmove(win, choice, check_x); + wattrset(win, selected ? check_selected_attr : check_attr); + if (checkflag == FLAG_CHECK) + wprintw(win, "[%c]", status ? 'X' : ' '); + else + wprintw(win, "(%c)", status ? 'X' : ' '); + + wattrset(win, selected ? tag_selected_attr : tag_attr); + mvwaddch(win, choice, item_x, item[0]); + wattrset(win, selected ? item_selected_attr : item_attr); + waddstr(win, (char *)item + 1); + if (selected) { + wmove(win, choice, check_x + 1); + wrefresh(win); + } } /* * Print the scroll indicators. */ static void -print_arrows (WINDOW * win, int choice, int item_no, int scroll, - int y, int x, int height) +print_arrows(WINDOW * win, int choice, int item_no, int scroll, + int y, int x, int height) { - wmove(win, y, x); - - if (scroll > 0) { - wattrset (win, uarrow_attr); - waddch (win, ACS_UARROW); - waddstr (win, "(-)"); - } - else { - wattrset (win, menubox_attr); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - } - - y = y + height + 1; - wmove(win, y, x); - - if ((height < item_no) && (scroll + choice < item_no - 1)) { - wattrset (win, darrow_attr); - waddch (win, ACS_DARROW); - waddstr (win, "(+)"); - } - else { - wattrset (win, menubox_border_attr); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - } + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, uarrow_attr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, menubox_attr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + choice < item_no - 1)) { + wattrset(win, darrow_attr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, menubox_border_attr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } } /* * Display the termination buttons */ -static void -print_buttons( WINDOW *dialog, int height, int width, int selected) +static void print_buttons(WINDOW * dialog, int height, int width, int selected) { - int x = width / 2 - 11; - int y = height - 2; + int x = width / 2 - 11; + int y = height - 2; - print_button (dialog, "Select", y, x, selected == 0); - print_button (dialog, " Help ", y, x + 14, selected == 1); + print_button(dialog, "Select", y, x, selected == 0); + print_button(dialog, " Help ", y, x + 14, selected == 1); - wmove(dialog, y, x+1 + 14*selected); - wrefresh (dialog); + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); } /* @@ -117,257 +113,293 @@ print_buttons( WINDOW *dialog, int height, int width, int selected) * The `flag' parameter is used to select between radiolist and checklist. */ int -dialog_checklist (const char *title, const char *prompt, int height, int width, - int list_height, int item_no, const char * const * items, int flag) - +dialog_checklist(const char *title, const char *prompt, int height, int width, + int list_height, int item_no, const char *const *items, + int flag) { - int i, x, y, box_x, box_y; - int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; - WINDOW *dialog, *list; - - checkflag = flag; - - /* Allocate space for storing item on/off status */ - if ((status = malloc (sizeof (int) * item_no)) == NULL) { - endwin (); - fprintf (stderr, - "\nCan't allocate memory in dialog_checklist().\n"); - exit (-1); - } - - /* Initializes status */ - for (i = 0; i < item_no; i++) { - status[i] = !strcasecmp (items[i * 3 + 2], "on"); - if ((!choice && status[i]) || !strcasecmp (items[i * 3 + 2], "selected")) - choice = i + 1; - } - if (choice) - choice--; - - max_choice = MIN (list_height, item_no); - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset (dialog, border_attr); - mvwaddch (dialog, height-3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 3); - - list_width = width - 6; - box_y = height - list_height - 5; - box_x = (width - list_width) / 2 - 1; - - /* create new window for the list */ - list = subwin (dialog, list_height, list_width, y+box_y+1, x+box_x+1); - - keypad (list, TRUE); - - /* draw a box around the list items */ - draw_box (dialog, box_y, box_x, list_height + 2, list_width + 2, - menubox_border_attr, menubox_attr); - - /* Find length of longest item in order to center checklist */ - check_x = 0; - for (i = 0; i < item_no; i++) - check_x = MAX (check_x, + strlen (items[i * 3 + 1]) + 4); - - check_x = (list_width - check_x) / 2; - item_x = check_x + 4; - - if (choice >= list_height) { - scroll = choice - list_height + 1; - choice -= scroll; - } - - /* Print the list */ - for (i = 0; i < max_choice; i++) { - print_item (list, items[(scroll+i) * 3 + 1], - status[i+scroll], i, i == choice); - } - - print_arrows(dialog, choice, item_no, scroll, - box_y, box_x + check_x + 5, list_height); - - print_buttons(dialog, height, width, 0); - - wnoutrefresh (list); - wnoutrefresh (dialog); - doupdate (); - - while (key != ESC) { - key = wgetch (dialog); - - for (i = 0; i < max_choice; i++) - if (toupper(key) == toupper(items[(scroll+i)*3+1][0])) - break; - - - if ( i < max_choice || key == KEY_UP || key == KEY_DOWN || - key == '+' || key == '-' ) { - if (key == KEY_UP || key == '-') { - if (!choice) { - if (!scroll) - continue; - /* Scroll list down */ - if (list_height > 1) { - /* De-highlight current first item */ - print_item (list, items[scroll * 3 + 1], - status[scroll], 0, FALSE); - scrollok (list, TRUE); - wscrl (list, -1); - scrollok (list, FALSE); - } - scroll--; - print_item (list, items[scroll * 3 + 1], - status[scroll], 0, TRUE); - wnoutrefresh (list); - - print_arrows(dialog, choice, item_no, scroll, - box_y, box_x + check_x + 5, list_height); - - wrefresh (dialog); - - continue; /* wait for another key press */ - } else - i = choice - 1; - } else if (key == KEY_DOWN || key == '+') { - if (choice == max_choice - 1) { - if (scroll + choice >= item_no - 1) - continue; - /* Scroll list up */ - if (list_height > 1) { - /* De-highlight current last item before scrolling up */ - print_item (list, items[(scroll + max_choice - 1) * 3 + 1], - status[scroll + max_choice - 1], - max_choice - 1, FALSE); - scrollok (list, TRUE); - wscrl (list, 1); - scrollok (list, FALSE); - } - scroll++; - print_item (list, items[(scroll + max_choice - 1) * 3 + 1], - status[scroll + max_choice - 1], - max_choice - 1, TRUE); - wnoutrefresh (list); - - print_arrows(dialog, choice, item_no, scroll, - box_y, box_x + check_x + 5, list_height); - - wrefresh (dialog); - - continue; /* wait for another key press */ - } else - i = choice + 1; - } - if (i != choice) { - /* De-highlight current item */ - print_item (list, items[(scroll + choice) * 3 + 1], - status[scroll + choice], choice, FALSE); - /* Highlight new item */ - choice = i; - print_item (list, items[(scroll + choice) * 3 + 1], - status[scroll + choice], choice, TRUE); - wnoutrefresh (list); - wrefresh (dialog); - } - continue; /* wait for another key press */ + int i, x, y, box_x, box_y; + int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; + WINDOW *dialog, *list; + + checkflag = flag; + + /* Allocate space for storing item on/off status */ + if ((status = malloc(sizeof(int) * item_no)) == NULL) { + endwin(); + fprintf(stderr, + "\nCan't allocate memory in dialog_checklist().\n"); + exit(-1); } - switch (key) { - case 'H': - case 'h': - case '?': - fprintf (stderr, "%s", items[(scroll + choice) * 3]); - delwin (dialog); - free (status); - return 1; - case TAB: - case KEY_LEFT: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 1 : (button > 1 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh (dialog); - break; - case 'S': - case 's': - case ' ': - case '\n': - if (!button) { - if (flag == FLAG_CHECK) { - status[scroll + choice] = !status[scroll + choice]; - wmove (list, choice, check_x); - wattrset (list, check_selected_attr); - wprintw (list, "[%c]", status[scroll + choice] ? 'X' : ' '); - } else { - if (!status[scroll + choice]) { - for (i = 0; i < item_no; i++) - status[i] = 0; - status[scroll + choice] = 1; - for (i = 0; i < max_choice; i++) - print_item (list, items[(scroll + i) * 3 + 1], - status[scroll + i], i, i == choice); - } - } - wnoutrefresh (list); - wrefresh (dialog); - - for (i = 0; i < item_no; i++) { - if (status[i]) { - if (flag == FLAG_CHECK) { - fprintf (stderr, "\"%s\" ", items[i * 3]); - } else { - fprintf (stderr, "%s", items[i * 3]); - } - } - } - } else - fprintf (stderr, "%s", items[(scroll + choice) * 3]); - delwin (dialog); - free (status); - return button; - case 'X': - case 'x': - key = ESC; - case ESC: - break; + /* Initializes status */ + for (i = 0; i < item_no; i++) { + status[i] = !strcasecmp(items[i * 3 + 2], "on"); + if ((!choice && status[i]) + || !strcasecmp(items[i * 3 + 2], "selected")) + choice = i + 1; + } + if (choice) + choice--; + + max_choice = MIN(list_height, item_no); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + waddch(dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width - 2) { + /* truncate long title -- mec */ + char *title2 = malloc(width - 2 + 1); + memcpy(title2, title, width - 2); + title2[width - 2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); + waddstr(dialog, (char *)title); + waddch(dialog, ' '); + } + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + list_width = width - 6; + box_y = height - list_height - 5; + box_x = (width - list_width) / 2 - 1; + + /* create new window for the list */ + list = + subwin(dialog, list_height, list_width, y + box_y + 1, + x + box_x + 1); + + keypad(list, TRUE); + + /* draw a box around the list items */ + draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, + menubox_border_attr, menubox_attr); + + /* Find length of longest item in order to center checklist */ + check_x = 0; + for (i = 0; i < item_no; i++) + check_x = MAX(check_x, +strlen(items[i * 3 + 1]) + 4); + + check_x = (list_width - check_x) / 2; + item_x = check_x + 4; + + if (choice >= list_height) { + scroll = choice - list_height + 1; + choice -= scroll; + } + + /* Print the list */ + for (i = 0; i < max_choice; i++) { + print_item(list, items[(scroll + i) * 3 + 1], + status[i + scroll], i, i == choice); } - /* Now, update everything... */ - doupdate (); - } - + print_arrows(dialog, choice, item_no, scroll, + box_y, box_x + check_x + 5, list_height); + + print_buttons(dialog, height, width, 0); + + wnoutrefresh(list); + wnoutrefresh(dialog); + doupdate(); + + while (key != ESC) { + key = wgetch(dialog); + + for (i = 0; i < max_choice; i++) + if (toupper(key) == + toupper(items[(scroll + i) * 3 + 1][0])) + break; + + if (i < max_choice || key == KEY_UP || key == KEY_DOWN || + key == '+' || key == '-') { + if (key == KEY_UP || key == '-') { + if (!choice) { + if (!scroll) + continue; + /* Scroll list down */ + if (list_height > 1) { + /* De-highlight current first item */ + print_item(list, + items[scroll * 3 + + 1], + status[scroll], 0, + FALSE); + scrollok(list, TRUE); + wscrl(list, -1); + scrollok(list, FALSE); + } + scroll--; + print_item(list, items[scroll * 3 + 1], + status[scroll], 0, TRUE); + wnoutrefresh(list); + + print_arrows(dialog, choice, item_no, + scroll, box_y, + box_x + check_x + 5, + list_height); + + wrefresh(dialog); + + continue; /* wait for another key press */ + } else + i = choice - 1; + } else if (key == KEY_DOWN || key == '+') { + if (choice == max_choice - 1) { + if (scroll + choice >= item_no - 1) + continue; + /* Scroll list up */ + if (list_height > 1) { + /* De-highlight current last item before scrolling up */ + print_item(list, + items[(scroll + + max_choice - + 1) * 3 + 1], + status[scroll + + max_choice - + 1], + max_choice - 1, + FALSE); + scrollok(list, TRUE); + wscrl(list, 1); + scrollok(list, FALSE); + } + scroll++; + print_item(list, + items[(scroll + max_choice - + 1) * 3 + 1], + status[scroll + max_choice - + 1], max_choice - 1, + TRUE); + wnoutrefresh(list); + + print_arrows(dialog, choice, item_no, + scroll, box_y, + box_x + check_x + 5, + list_height); + + wrefresh(dialog); + + continue; /* wait for another key press */ + } else + i = choice + 1; + } + if (i != choice) { + /* De-highlight current item */ + print_item(list, + items[(scroll + choice) * 3 + 1], + status[scroll + choice], choice, + FALSE); + /* Highlight new item */ + choice = i; + print_item(list, + items[(scroll + choice) * 3 + 1], + status[scroll + choice], choice, + TRUE); + wnoutrefresh(list); + wrefresh(dialog); + } + continue; /* wait for another key press */ + } + switch (key) { + case 'H': + case 'h': + case '?': + fprintf(stderr, "%s", items[(scroll + choice) * 3]); + delwin(dialog); + free(status); + return 1; + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case 'S': + case 's': + case ' ': + case '\n': + if (!button) { + if (flag == FLAG_CHECK) { + status[scroll + choice] = + !status[scroll + choice]; + wmove(list, choice, check_x); + wattrset(list, check_selected_attr); + wprintw(list, "[%c]", + status[scroll + + choice] ? 'X' : ' '); + } else { + if (!status[scroll + choice]) { + for (i = 0; i < item_no; i++) + status[i] = 0; + status[scroll + choice] = 1; + for (i = 0; i < max_choice; i++) + print_item(list, + items[(scroll + + + i) * + 3 + 1], + status[scroll + + i], + i, + i == choice); + } + } + wnoutrefresh(list); + wrefresh(dialog); + + for (i = 0; i < item_no; i++) { + if (status[i]) { + if (flag == FLAG_CHECK) { + fprintf(stderr, + "\"%s\" ", + items[i * 3]); + } else { + fprintf(stderr, "%s", + items[i * 3]); + } + + } + } + } else + fprintf(stderr, "%s", + items[(scroll + choice) * 3]); + delwin(dialog); + free(status); + return button; + case 'X': + case 'x': + key = ESC; + case ESC: + break; + } + + /* Now, update everything... */ + doupdate(); + } - delwin (dialog); - free (status); - return -1; /* ESC pressed */ + delwin(dialog); + free(status); + return -1; /* ESC pressed */ } diff --git a/scripts/lxdialog/colors.h b/scripts/lxdialog/colors.h index 25c5952..db071df1 100644 --- a/scripts/lxdialog/colors.h +++ b/scripts/lxdialog/colors.h @@ -18,7 +18,6 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - /* * Default color definitions * diff --git a/scripts/lxdialog/dialog.h b/scripts/lxdialog/dialog.h index eb63e1b..c86801f 100644 --- a/scripts/lxdialog/dialog.h +++ b/scripts/lxdialog/dialog.h @@ -42,7 +42,7 @@ #if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) #define OLD_NCURSES 1 #undef wbkgdset -#define wbkgdset(w,p) /*nothing*/ +#define wbkgdset(w,p) /*nothing */ #else #define OLD_NCURSES 0 #endif @@ -56,7 +56,6 @@ #define MIN(x,y) (x < y ? x : y) #define MAX(x,y) (x > y ? x : y) - #ifndef ACS_ULCORNER #define ACS_ULCORNER '+' #endif @@ -137,35 +136,34 @@ extern const char *backtitle; /* * Function prototypes */ -extern void create_rc (const char *filename); -extern int parse_rc (void); - - -void init_dialog (void); -void end_dialog (void); -void attr_clear (WINDOW * win, int height, int width, chtype attr); -void dialog_clear (void); -void color_setup (void); -void print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x); -void print_button (WINDOW * win, const char *label, int y, int x, int selected); -void draw_box (WINDOW * win, int y, int x, int height, int width, chtype box, - chtype border); -void draw_shadow (WINDOW * win, int y, int x, int height, int width); - -int first_alpha (const char *string, const char *exempt); -int dialog_yesno (const char *title, const char *prompt, int height, int width); -int dialog_msgbox (const char *title, const char *prompt, int height, - int width, int pause); -int dialog_textbox (const char *title, const char *file, int height, int width); -int dialog_menu (const char *title, const char *prompt, int height, int width, - int menu_height, const char *choice, int item_no, - const char * const * items); -int dialog_checklist (const char *title, const char *prompt, int height, - int width, int list_height, int item_no, - const char * const * items, int flag); +extern void create_rc(const char *filename); +extern int parse_rc(void); + +void init_dialog(void); +void end_dialog(void); +void attr_clear(WINDOW * win, int height, int width, chtype attr); +void dialog_clear(void); +void color_setup(void); +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); +void print_button(WINDOW * win, const char *label, int y, int x, int selected); +void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, + chtype border); +void draw_shadow(WINDOW * win, int y, int x, int height, int width); + +int first_alpha(const char *string, const char *exempt); +int dialog_yesno(const char *title, const char *prompt, int height, int width); +int dialog_msgbox(const char *title, const char *prompt, int height, + int width, int pause); +int dialog_textbox(const char *title, const char *file, int height, int width); +int dialog_menu(const char *title, const char *prompt, int height, int width, + int menu_height, const char *choice, int item_no, + const char *const *items); +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height, int item_no, + const char *const *items, int flag); extern char dialog_input_result[]; -int dialog_inputbox (const char *title, const char *prompt, int height, - int width, const char *init); +int dialog_inputbox(const char *title, const char *prompt, int height, + int width, const char *init); /* * This is the base for fictitious keys, which activate @@ -178,7 +176,6 @@ int dialog_inputbox (const char *title, const char *prompt, int height, */ #define M_EVENT (KEY_MAX+1) - /* * The `flag' parameter in checklist is used to select between * radiolist and checklist diff --git a/scripts/lxdialog/inputbox.c b/scripts/lxdialog/inputbox.c index 074d2d6..9e96915 100644 --- a/scripts/lxdialog/inputbox.c +++ b/scripts/lxdialog/inputbox.c @@ -26,215 +26,231 @@ char dialog_input_result[MAX_LEN + 1]; /* * Print the termination buttons */ -static void -print_buttons(WINDOW *dialog, int height, int width, int selected) +static void print_buttons(WINDOW * dialog, int height, int width, int selected) { - int x = width / 2 - 11; - int y = height - 2; + int x = width / 2 - 11; + int y = height - 2; - print_button (dialog, " Ok ", y, x, selected==0); - print_button (dialog, " Help ", y, x + 14, selected==1); + print_button(dialog, " Ok ", y, x, selected == 0); + print_button(dialog, " Help ", y, x + 14, selected == 1); - wmove(dialog, y, x+1+14*selected); - wrefresh(dialog); + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); } /* * Display a dialog box for inputing a string */ int -dialog_inputbox (const char *title, const char *prompt, int height, int width, - const char *init) +dialog_inputbox(const char *title, const char *prompt, int height, int width, + const char *init) { - int i, x, y, box_y, box_x, box_width; - int input_x = 0, scroll = 0, key = 0, button = -1; - char *instr = dialog_input_result; - WINDOW *dialog; - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset (dialog, border_attr); - mvwaddch (dialog, height-3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 3); - - /* Draw the input field box */ - box_width = width - 6; - getyx (dialog, y, x); - box_y = y + 2; - box_x = (width - box_width) / 2; - draw_box (dialog, y + 1, box_x - 1, 3, box_width + 2, - border_attr, dialog_attr); - - print_buttons(dialog, height, width, 0); - - /* Set up the initial value */ - wmove (dialog, box_y, box_x); - wattrset (dialog, inputbox_attr); - - if (!init) - instr[0] = '\0'; - else - strcpy (instr, init); - - input_x = strlen (instr); - - if (input_x >= box_width) { - scroll = input_x - box_width + 1; - input_x = box_width - 1; - for (i = 0; i < box_width - 1; i++) - waddch (dialog, instr[scroll + i]); - } else - waddstr (dialog, instr); - - wmove (dialog, box_y, box_x + input_x); - - wrefresh (dialog); - - while (key != ESC) { - key = wgetch (dialog); - - if (button == -1) { /* Input box selected */ - switch (key) { - case TAB: - case KEY_UP: - case KEY_DOWN: - break; - case KEY_LEFT: - continue; - case KEY_RIGHT: - continue; - case KEY_BACKSPACE: - case 127: - if (input_x || scroll) { - wattrset (dialog, inputbox_attr); - if (!input_x) { - scroll = scroll < box_width - 1 ? - 0 : scroll - (box_width - 1); - wmove (dialog, box_y, box_x); - for (i = 0; i < box_width; i++) - waddch (dialog, instr[scroll + input_x + i] ? - instr[scroll + input_x + i] : ' '); - input_x = strlen (instr) - scroll; - } else - input_x--; - instr[scroll + input_x] = '\0'; - mvwaddch (dialog, box_y, input_x + box_x, ' '); - wmove (dialog, box_y, input_x + box_x); - wrefresh (dialog); + int i, x, y, box_y, box_x, box_width; + int input_x = 0, scroll = 0, key = 0, button = -1; + char *instr = dialog_input_result; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + waddch(dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width - 2) { + /* truncate long title -- mec */ + char *title2 = malloc(width - 2 + 1); + memcpy(title2, title, width - 2); + title2[width - 2] = '\0'; + title = title2; + } + + if (title != NULL) { + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); + waddstr(dialog, (char *)title); + waddch(dialog, ' '); + } + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + /* Draw the input field box */ + box_width = width - 6; + getyx(dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, + border_attr, dialog_attr); + + print_buttons(dialog, height, width, 0); + + /* Set up the initial value */ + wmove(dialog, box_y, box_x); + wattrset(dialog, inputbox_attr); + + if (!init) + instr[0] = '\0'; + else + strcpy(instr, init); + + input_x = strlen(instr); + + if (input_x >= box_width) { + scroll = input_x - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[scroll + i]); + } else + waddstr(dialog, instr); + + wmove(dialog, box_y, box_x + input_x); + + wrefresh(dialog); + + while (key != ESC) { + key = wgetch(dialog); + + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_LEFT: + continue; + case KEY_RIGHT: + continue; + case KEY_BACKSPACE: + case 127: + if (input_x || scroll) { + wattrset(dialog, inputbox_attr); + if (!input_x) { + scroll = + scroll < + box_width - 1 ? 0 : scroll - + (box_width - 1); + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch(dialog, + instr[scroll + + input_x + + i] ? + instr[scroll + + input_x + + i] : ' '); + input_x = + strlen(instr) - scroll; + } else + input_x--; + instr[scroll + input_x] = '\0'; + mvwaddch(dialog, box_y, input_x + box_x, + ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + continue; + default: + if (key < 0x100 && isprint(key)) { + if (scroll + input_x < MAX_LEN) { + wattrset(dialog, inputbox_attr); + instr[scroll + input_x] = key; + instr[scroll + input_x + 1] = + '\0'; + if (input_x == box_width - 1) { + scroll++; + wmove(dialog, box_y, + box_x); + for (i = 0; + i < box_width - 1; + i++) + waddch(dialog, + instr + [scroll + + i]); + } else { + wmove(dialog, box_y, + input_x++ + + box_x); + waddch(dialog, key); + } + wrefresh(dialog); + } else + flash(); /* Alarm user about overflow */ + continue; + } + } } - continue; - default: - if (key < 0x100 && isprint (key)) { - if (scroll + input_x < MAX_LEN) { - wattrset (dialog, inputbox_attr); - instr[scroll + input_x] = key; - instr[scroll + input_x + 1] = '\0'; - if (input_x == box_width - 1) { - scroll++; - wmove (dialog, box_y, box_x); - for (i = 0; i < box_width - 1; i++) - waddch (dialog, instr[scroll + i]); - } else { - wmove (dialog, box_y, input_x++ + box_x); - waddch (dialog, key); + switch (key) { + case 'O': + case 'o': + delwin(dialog); + return 0; + case 'H': + case 'h': + delwin(dialog); + return 1; + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 0: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; } - wrefresh (dialog); - } else - flash (); /* Alarm user about overflow */ - continue; + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + case 0: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 1: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + } + break; + case ' ': + case '\n': + delwin(dialog); + return (button == -1 ? 0 : button); + case 'X': + case 'x': + key = ESC; + case ESC: + break; } - } - } - switch (key) { - case 'O': - case 'o': - delwin (dialog); - return 0; - case 'H': - case 'h': - delwin (dialog); - return 1; - case KEY_UP: - case KEY_LEFT: - switch (button) { - case -1: - button = 1; /* Indicates "Cancel" button is selected */ - print_buttons(dialog, height, width, 1); - break; - case 0: - button = -1; /* Indicates input box is selected */ - print_buttons(dialog, height, width, 0); - wmove (dialog, box_y, box_x + input_x); - wrefresh (dialog); - break; - case 1: - button = 0; /* Indicates "OK" button is selected */ - print_buttons(dialog, height, width, 0); - break; - } - break; - case TAB: - case KEY_DOWN: - case KEY_RIGHT: - switch (button) { - case -1: - button = 0; /* Indicates "OK" button is selected */ - print_buttons(dialog, height, width, 0); - break; - case 0: - button = 1; /* Indicates "Cancel" button is selected */ - print_buttons(dialog, height, width, 1); - break; - case 1: - button = -1; /* Indicates input box is selected */ - print_buttons(dialog, height, width, 0); - wmove (dialog, box_y, box_x + input_x); - wrefresh (dialog); - break; - } - break; - case ' ': - case '\n': - delwin (dialog); - return (button == -1 ? 0 : button); - case 'X': - case 'x': - key = ESC; - case ESC: - break; } - } - delwin (dialog); - return -1; /* ESC pressed */ + delwin(dialog); + return -1; /* ESC pressed */ } diff --git a/scripts/lxdialog/lxdialog.c b/scripts/lxdialog/lxdialog.c index f283a85..2c34ea1 100644 --- a/scripts/lxdialog/lxdialog.c +++ b/scripts/lxdialog/lxdialog.c @@ -21,30 +21,29 @@ #include "dialog.h" -static void Usage (const char *name); +static void Usage(const char *name); -typedef int (jumperFn) (const char *title, int argc, const char * const * argv); +typedef int (jumperFn) (const char *title, int argc, const char *const *argv); struct Mode { - char *name; - int argmin, argmax, argmod; - jumperFn *jumper; + char *name; + int argmin, argmax, argmod; + jumperFn *jumper; }; jumperFn j_menu, j_checklist, j_radiolist, j_yesno, j_textbox, j_inputbox; jumperFn j_msgbox, j_infobox; -static struct Mode modes[] = -{ - {"--menu", 9, 0, 3, j_menu}, - {"--checklist", 9, 0, 3, j_checklist}, - {"--radiolist", 9, 0, 3, j_radiolist}, - {"--yesno", 5,5,1, j_yesno}, - {"--textbox", 5,5,1, j_textbox}, - {"--inputbox", 5, 6, 1, j_inputbox}, - {"--msgbox", 5, 5, 1, j_msgbox}, - {"--infobox", 5, 5, 1, j_infobox}, - {NULL, 0, 0, 0, NULL} +static struct Mode modes[] = { + {"--menu", 9, 0, 3, j_menu}, + {"--checklist", 9, 0, 3, j_checklist}, + {"--radiolist", 9, 0, 3, j_radiolist}, + {"--yesno", 5, 5, 1, j_yesno}, + {"--textbox", 5, 5, 1, j_textbox}, + {"--inputbox", 5, 6, 1, j_inputbox}, + {"--msgbox", 5, 5, 1, j_msgbox}, + {"--infobox", 5, 5, 1, j_infobox}, + {NULL, 0, 0, 0, NULL} }; static struct Mode *modePtr; @@ -53,96 +52,92 @@ static struct Mode *modePtr; #include #endif -int -main (int argc, const char * const * argv) +int main(int argc, const char *const *argv) { - int offset = 0, opt_clear = 0, end_common_opts = 0, retval; - const char *title = NULL; + int offset = 0, opt_clear = 0, end_common_opts = 0, retval; + const char *title = NULL; #ifdef LOCALE - (void) setlocale (LC_ALL, ""); + (void)setlocale(LC_ALL, ""); #endif #ifdef TRACE - trace(TRACE_CALLS|TRACE_UPDATE); + trace(TRACE_CALLS | TRACE_UPDATE); #endif - if (argc < 2) { - Usage (argv[0]); - exit (-1); - } - - while (offset < argc - 1 && !end_common_opts) { /* Common options */ - if (!strcmp (argv[offset + 1], "--title")) { - if (argc - offset < 3 || title != NULL) { - Usage (argv[0]); - exit (-1); - } else { - title = argv[offset + 2]; - offset += 2; - } - } else if (!strcmp (argv[offset + 1], "--backtitle")) { - if (backtitle != NULL) { - Usage (argv[0]); - exit (-1); - } else { - backtitle = argv[offset + 2]; - offset += 2; - } - } else if (!strcmp (argv[offset + 1], "--clear")) { - if (opt_clear) { /* Hey, "--clear" can't appear twice! */ - Usage (argv[0]); - exit (-1); - } else if (argc == 2) { /* we only want to clear the screen */ - init_dialog (); - refresh (); /* init_dialog() will clear the screen for us */ - end_dialog (); - return 0; - } else { - opt_clear = 1; - offset++; - } - } else /* no more common options */ - end_common_opts = 1; - } - - if (argc - 1 == offset) { /* no more options */ - Usage (argv[0]); - exit (-1); - } - /* use a table to look for the requested mode, to avoid code duplication */ - - for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ - if (!strcmp (argv[offset + 1], modePtr->name)) - break; - - if (!modePtr->name) - Usage (argv[0]); - if (argc - offset < modePtr->argmin) - Usage (argv[0]); - if (modePtr->argmax && argc - offset > modePtr->argmax) - Usage (argv[0]); - - - - init_dialog (); - retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); - - if (opt_clear) { /* clear screen before exit */ - attr_clear (stdscr, LINES, COLS, screen_attr); - refresh (); - } - end_dialog(); - - exit (retval); + if (argc < 2) { + Usage(argv[0]); + exit(-1); + } + + while (offset < argc - 1 && !end_common_opts) { /* Common options */ + if (!strcmp(argv[offset + 1], "--title")) { + if (argc - offset < 3 || title != NULL) { + Usage(argv[0]); + exit(-1); + } else { + title = argv[offset + 2]; + offset += 2; + } + } else if (!strcmp(argv[offset + 1], "--backtitle")) { + if (backtitle != NULL) { + Usage(argv[0]); + exit(-1); + } else { + backtitle = argv[offset + 2]; + offset += 2; + } + } else if (!strcmp(argv[offset + 1], "--clear")) { + if (opt_clear) { /* Hey, "--clear" can't appear twice! */ + Usage(argv[0]); + exit(-1); + } else if (argc == 2) { /* we only want to clear the screen */ + init_dialog(); + refresh(); /* init_dialog() will clear the screen for us */ + end_dialog(); + return 0; + } else { + opt_clear = 1; + offset++; + } + } else /* no more common options */ + end_common_opts = 1; + } + + if (argc - 1 == offset) { /* no more options */ + Usage(argv[0]); + exit(-1); + } + /* use a table to look for the requested mode, to avoid code duplication */ + + for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ + if (!strcmp(argv[offset + 1], modePtr->name)) + break; + + if (!modePtr->name) + Usage(argv[0]); + if (argc - offset < modePtr->argmin) + Usage(argv[0]); + if (modePtr->argmax && argc - offset > modePtr->argmax) + Usage(argv[0]); + + init_dialog(); + retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); + + if (opt_clear) { /* clear screen before exit */ + attr_clear(stdscr, LINES, COLS, screen_attr); + refresh(); + } + end_dialog(); + + exit(retval); } /* * Print program usage */ -static void -Usage (const char *name) +static void Usage(const char *name) { - fprintf (stderr, "\ + fprintf(stderr, "\ \ndialog, by Savio Lam (lam836@cs.cuhk.hk).\ \n patched by Stuart Herbert (S.Herbert@shef.ac.uk)\ \n modified/gutted for use as a Linux kernel config tool by \ @@ -162,65 +157,56 @@ Usage (const char *name) \n --inputbox []\ \n --yesno \ \n", name, name); - exit (-1); + exit(-1); } /* * These are the program jumpers */ -int -j_menu (const char *t, int ac, const char * const * av) +int j_menu(const char *t, int ac, const char *const *av) { - return dialog_menu (t, av[2], atoi (av[3]), atoi (av[4]), - atoi (av[5]), av[6], (ac - 6) / 2, av + 7); + return dialog_menu(t, av[2], atoi(av[3]), atoi(av[4]), + atoi(av[5]), av[6], (ac - 6) / 2, av + 7); } -int -j_checklist (const char *t, int ac, const char * const * av) +int j_checklist(const char *t, int ac, const char *const *av) { - return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]), - atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK); + return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), + atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK); } -int -j_radiolist (const char *t, int ac, const char * const * av) +int j_radiolist(const char *t, int ac, const char *const *av) { - return dialog_checklist (t, av[2], atoi (av[3]), atoi (av[4]), - atoi (av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO); + return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), + atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO); } -int -j_textbox (const char *t, int ac, const char * const * av) +int j_textbox(const char *t, int ac, const char *const *av) { - return dialog_textbox (t, av[2], atoi (av[3]), atoi (av[4])); + return dialog_textbox(t, av[2], atoi(av[3]), atoi(av[4])); } -int -j_yesno (const char *t, int ac, const char * const * av) +int j_yesno(const char *t, int ac, const char *const *av) { - return dialog_yesno (t, av[2], atoi (av[3]), atoi (av[4])); + return dialog_yesno(t, av[2], atoi(av[3]), atoi(av[4])); } -int -j_inputbox (const char *t, int ac, const char * const * av) +int j_inputbox(const char *t, int ac, const char *const *av) { - int ret = dialog_inputbox (t, av[2], atoi (av[3]), atoi (av[4]), - ac == 6 ? av[5] : (char *) NULL); - if (ret == 0) - fprintf(stderr, dialog_input_result); - return ret; + int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]), + ac == 6 ? av[5] : (char *)NULL); + if (ret == 0) + fprintf(stderr, dialog_input_result); + return ret; } -int -j_msgbox (const char *t, int ac, const char * const * av) +int j_msgbox(const char *t, int ac, const char *const *av) { - return dialog_msgbox (t, av[2], atoi (av[3]), atoi (av[4]), 1); + return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 1); } -int -j_infobox (const char *t, int ac, const char * const * av) +int j_infobox(const char *t, int ac, const char *const *av) { - return dialog_msgbox (t, av[2], atoi (av[3]), atoi (av[4]), 0); + return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 0); } - diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index 91d82ba..083f13d 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -64,382 +64,420 @@ static int menu_width, item_x; * Print menu item */ static void -print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey) +print_item(WINDOW * win, const char *item, int choice, int selected, int hotkey) { - int j; - char menu_item[menu_width+1]; + int j; + char menu_item[menu_width + 1]; - strncpy(menu_item, item, menu_width); - menu_item[menu_width] = 0; - j = first_alpha(menu_item, "YyNnMmHh"); + strncpy(menu_item, item, menu_width); + menu_item[menu_width] = 0; + j = first_alpha(menu_item, "YyNnMmHh"); - /* Clear 'residue' of last item */ - wattrset (win, menubox_attr); - wmove (win, choice, 0); + /* Clear 'residue' of last item */ + wattrset(win, menubox_attr); + wmove(win, choice, 0); #if OLD_NCURSES - { - int i; - for (i = 0; i < menu_width; i++) - waddch (win, ' '); - } + { + int i; + for (i = 0; i < menu_width; i++) + waddch(win, ' '); + } #else - wclrtoeol(win); + wclrtoeol(win); #endif - wattrset (win, selected ? item_selected_attr : item_attr); - mvwaddstr (win, choice, item_x, menu_item); - if (hotkey) { - wattrset (win, selected ? tag_key_selected_attr : tag_key_attr); - mvwaddch(win, choice, item_x+j, menu_item[j]); - } - if (selected) { - wmove (win, choice, item_x+1); - wrefresh (win); - } + wattrset(win, selected ? item_selected_attr : item_attr); + mvwaddstr(win, choice, item_x, menu_item); + if (hotkey) { + wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); + mvwaddch(win, choice, item_x + j, menu_item[j]); + } + if (selected) { + wmove(win, choice, item_x + 1); + wrefresh(win); + } } /* * Print the scroll indicators. */ static void -print_arrows (WINDOW * win, int item_no, int scroll, - int y, int x, int height) +print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, int height) { - int cur_y, cur_x; - - getyx(win, cur_y, cur_x); - - wmove(win, y, x); - - if (scroll > 0) { - wattrset (win, uarrow_attr); - waddch (win, ACS_UARROW); - waddstr (win, "(-)"); - } - else { - wattrset (win, menubox_attr); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - } - - y = y + height + 1; - wmove(win, y, x); - - if ((height < item_no) && (scroll + height < item_no)) { - wattrset (win, darrow_attr); - waddch (win, ACS_DARROW); - waddstr (win, "(+)"); - } - else { - wattrset (win, menubox_border_attr); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - waddch (win, ACS_HLINE); - } - - wmove(win, cur_y, cur_x); + int cur_y, cur_x; + + getyx(win, cur_y, cur_x); + + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, uarrow_attr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, menubox_attr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + height < item_no)) { + wattrset(win, darrow_attr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, menubox_border_attr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + wmove(win, cur_y, cur_x); } /* * Display the termination buttons. */ -static void -print_buttons (WINDOW *win, int height, int width, int selected) +static void print_buttons(WINDOW * win, int height, int width, int selected) { - int x = width / 2 - 16; - int y = height - 2; + int x = width / 2 - 16; + int y = height - 2; - print_button (win, "Select", y, x, selected == 0); - print_button (win, " Exit ", y, x + 12, selected == 1); - print_button (win, " Help ", y, x + 24, selected == 2); + print_button(win, "Select", y, x, selected == 0); + print_button(win, " Exit ", y, x + 12, selected == 1); + print_button(win, " Help ", y, x + 24, selected == 2); - wmove(win, y, x+1+12*selected); - wrefresh (win); + wmove(win, y, x + 1 + 12 * selected); + wrefresh(win); } /* * Display a menu for choosing among a number of options */ int -dialog_menu (const char *title, const char *prompt, int height, int width, - int menu_height, const char *current, int item_no, - const char * const * items) - +dialog_menu(const char *title, const char *prompt, int height, int width, + int menu_height, const char *current, int item_no, + const char *const *items) { - int i, j, x, y, box_x, box_y; - int key = 0, button = 0, scroll = 0, choice = 0, first_item = 0, max_choice; - WINDOW *dialog, *menu; - FILE *f; - - max_choice = MIN (menu_height, item_no); - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset (dialog, border_attr); - mvwaddch (dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - wbkgdset (dialog, dialog_attr & A_COLOR); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 3); - - menu_width = width - 6; - box_y = height - menu_height - 5; - box_x = (width - menu_width) / 2 - 1; - - /* create new window for the menu */ - menu = subwin (dialog, menu_height, menu_width, - y + box_y + 1, x + box_x + 1); - keypad (menu, TRUE); - - /* draw a box around the menu items */ - draw_box (dialog, box_y, box_x, menu_height + 2, menu_width + 2, - menubox_border_attr, menubox_attr); - - /* - * Find length of longest item in order to center menu. - * Set 'choice' to default item. - */ - item_x = 0; - for (i = 0; i < item_no; i++) { - item_x = MAX (item_x, MIN(menu_width, strlen (items[i * 2 + 1]) + 2)); - if (strcmp(current, items[i*2]) == 0) choice = i; - } - - item_x = (menu_width - item_x) / 2; - - /* get the scroll info from the temp file */ - if ( (f=fopen("lxdialog.scrltmp","r")) != NULL ) { - if ( (fscanf(f,"%d\n",&scroll) == 1) && (scroll <= choice) && - (scroll+max_choice > choice) && (scroll >= 0) && - (scroll+max_choice <= item_no) ) { - first_item = scroll; - choice = choice - scroll; - fclose(f); - } else { - scroll=0; - remove("lxdialog.scrltmp"); - fclose(f); - f=NULL; + int i, j, x, y, box_x, box_y; + int key = 0, button = 0, scroll = 0, choice = 0, first_item = + 0, max_choice; + WINDOW *dialog, *menu; + FILE *f; + + max_choice = MIN(menu_height, item_no); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + wbkgdset(dialog, dialog_attr & A_COLOR); + waddch(dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width - 2) { + /* truncate long title -- mec */ + char *title2 = malloc(width - 2 + 1); + memcpy(title2, title, width - 2); + title2[width - 2] = '\0'; + title = title2; } - } - if ( (choice >= max_choice) || (f==NULL && choice >= max_choice/2) ) { - if (choice >= item_no-max_choice/2) - scroll = first_item = item_no-max_choice; - else - scroll = first_item = choice - max_choice/2; - choice = choice - scroll; - } - - /* Print the menu */ - for (i=0; i < max_choice; i++) { - print_item (menu, items[(first_item + i) * 2 + 1], i, i == choice, - (items[(first_item + i)*2][0] != ':')); - } - - wnoutrefresh (menu); - - print_arrows(dialog, item_no, scroll, - box_y, box_x+item_x+1, menu_height); - - print_buttons (dialog, height, width, 0); - wmove (menu, choice, item_x+1); - wrefresh (menu); - - while (key != ESC) { - key = wgetch(menu); - - if (key < 256 && isalpha(key)) key = tolower(key); - - if (strchr("ynmh", key)) - i = max_choice; - else { - for (i = choice+1; i < max_choice; i++) { - j = first_alpha(items[(scroll+i)*2+1], "YyNnMmHh"); - if (key == tolower(items[(scroll+i)*2+1][j])) - break; + + if (title != NULL) { + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); + waddstr(dialog, (char *)title); + waddch(dialog, ' '); } - if (i == max_choice) - for (i = 0; i < max_choice; i++) { - j = first_alpha(items[(scroll+i)*2+1], "YyNnMmHh"); - if (key == tolower(items[(scroll+i)*2+1][j])) - break; + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + menu_width = width - 6; + box_y = height - menu_height - 5; + box_x = (width - menu_width) / 2 - 1; + + /* create new window for the menu */ + menu = subwin(dialog, menu_height, menu_width, + y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, + menubox_border_attr, menubox_attr); + + /* + * Find length of longest item in order to center menu. + * Set 'choice' to default item. + */ + item_x = 0; + for (i = 0; i < item_no; i++) { + item_x = + MAX(item_x, MIN(menu_width, strlen(items[i * 2 + 1]) + 2)); + if (strcmp(current, items[i * 2]) == 0) + choice = i; + } + + item_x = (menu_width - item_x) / 2; + + /* get the scroll info from the temp file */ + if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) { + if ((fscanf(f, "%d\n", &scroll) == 1) && (scroll <= choice) && + (scroll + max_choice > choice) && (scroll >= 0) && + (scroll + max_choice <= item_no)) { + first_item = scroll; + choice = choice - scroll; + fclose(f); + } else { + scroll = 0; + remove("lxdialog.scrltmp"); + fclose(f); + f = NULL; } } + if ((choice >= max_choice) || (f == NULL && choice >= max_choice / 2)) { + if (choice >= item_no - max_choice / 2) + scroll = first_item = item_no - max_choice; + else + scroll = first_item = choice - max_choice / 2; + choice = choice - scroll; + } - if (i < max_choice || - key == KEY_UP || key == KEY_DOWN || - key == '-' || key == '+' || - key == KEY_PPAGE || key == KEY_NPAGE) { - - print_item (menu, items[(scroll+choice)*2+1], choice, FALSE, - (items[(scroll+choice)*2][0] != ':')); - - if (key == KEY_UP || key == '-') { - if (choice < 2 && scroll) { - /* Scroll menu down */ - scrollok (menu, TRUE); - wscrl (menu, -1); - scrollok (menu, FALSE); - - scroll--; - - print_item (menu, items[scroll * 2 + 1], 0, FALSE, - (items[scroll*2][0] != ':')); - } else - choice = MAX(choice - 1, 0); - - } else if (key == KEY_DOWN || key == '+') { - - print_item (menu, items[(scroll+choice)*2+1], choice, FALSE, - (items[(scroll+choice)*2][0] != ':')); - - if ((choice > max_choice-3) && - (scroll + max_choice < item_no) - ) { - /* Scroll menu up */ - scrollok (menu, TRUE); - wscrl (menu, 1); - scrollok (menu, FALSE); - - scroll++; - - print_item (menu, items[(scroll+max_choice-1)*2+1], - max_choice-1, FALSE, - (items[(scroll+max_choice-1)*2][0] != ':')); - } else - choice = MIN(choice+1, max_choice-1); - - } else if (key == KEY_PPAGE) { - scrollok (menu, TRUE); - for (i=0; (i < max_choice); i++) { - if (scroll > 0) { - wscrl (menu, -1); - scroll--; - print_item (menu, items[scroll * 2 + 1], 0, FALSE, - (items[scroll*2][0] != ':')); - } else { - if (choice > 0) - choice--; - } - } - scrollok (menu, FALSE); - - } else if (key == KEY_NPAGE) { - for (i=0; (i < max_choice); i++) { - if (scroll+max_choice < item_no) { - scrollok (menu, TRUE); - wscrl (menu, 1); - scrollok (menu, FALSE); - scroll++; - print_item (menu, items[(scroll+max_choice-1)*2+1], - max_choice-1, FALSE, - (items[(scroll+max_choice-1)*2][0] != ':')); - } else { - if (choice+1 < max_choice) - choice++; - } - } - - } else - choice = i; - - print_item (menu, items[(scroll+choice)*2+1], choice, TRUE, - (items[(scroll+choice)*2][0] != ':')); - - print_arrows(dialog, item_no, scroll, - box_y, box_x+item_x+1, menu_height); - - wnoutrefresh (dialog); - wrefresh (menu); - - continue; /* wait for another key press */ - } - - switch (key) { - case KEY_LEFT: - case TAB: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 2 : (button > 2 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh (menu); - break; - case ' ': - case 's': - case 'y': - case 'n': - case 'm': - case '/': - /* save scroll info */ - if ( (f=fopen("lxdialog.scrltmp","w")) != NULL ) { - fprintf(f,"%d\n",scroll); - fclose(f); - } - delwin (dialog); - fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); - switch (key) { - case 's': return 3; - case 'y': return 3; - case 'n': return 4; - case 'm': return 5; - case ' ': return 6; - case '/': return 7; - } - return 0; - case 'h': - case '?': - button = 2; - case '\n': - delwin (dialog); - if (button == 2) - fprintf(stderr, "%s \"%s\"\n", - items[(scroll + choice) * 2], - items[(scroll + choice) * 2 + 1] + - first_alpha(items[(scroll + choice) * 2 + 1],"")); - else - fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); - - remove("lxdialog.scrltmp"); - return button; - case 'e': - case 'x': - key = ESC; - case ESC: - break; + /* Print the menu */ + for (i = 0; i < max_choice; i++) { + print_item(menu, items[(first_item + i) * 2 + 1], i, + i == choice, + (items[(first_item + i) * 2][0] != ':')); + } + + wnoutrefresh(menu); + + print_arrows(dialog, item_no, scroll, + box_y, box_x + item_x + 1, menu_height); + + print_buttons(dialog, height, width, 0); + wmove(menu, choice, item_x + 1); + wrefresh(menu); + + while (key != ESC) { + key = wgetch(menu); + + if (key < 256 && isalpha(key)) + key = tolower(key); + + if (strchr("ynmh", key)) + i = max_choice; + else { + for (i = choice + 1; i < max_choice; i++) { + j = first_alpha(items[(scroll + i) * 2 + 1], + "YyNnMmHh"); + if (key == + tolower(items[(scroll + i) * 2 + 1][j])) + break; + } + if (i == max_choice) + for (i = 0; i < max_choice; i++) { + j = first_alpha(items + [(scroll + i) * 2 + 1], + "YyNnMmHh"); + if (key == + tolower(items[(scroll + i) * 2 + 1] + [j])) + break; + } + } + + if (i < max_choice || + key == KEY_UP || key == KEY_DOWN || + key == '-' || key == '+' || + key == KEY_PPAGE || key == KEY_NPAGE) { + + print_item(menu, items[(scroll + choice) * 2 + 1], + choice, FALSE, + (items[(scroll + choice) * 2][0] != ':')); + + if (key == KEY_UP || key == '-') { + if (choice < 2 && scroll) { + /* Scroll menu down */ + scrollok(menu, TRUE); + wscrl(menu, -1); + scrollok(menu, FALSE); + + scroll--; + + print_item(menu, items[scroll * 2 + 1], + 0, FALSE, + (items[scroll * 2][0] != + ':')); + } else + choice = MAX(choice - 1, 0); + + } else if (key == KEY_DOWN || key == '+') { + + print_item(menu, + items[(scroll + choice) * 2 + 1], + choice, FALSE, + (items[(scroll + choice) * 2][0] != + ':')); + + if ((choice > max_choice - 3) && + (scroll + max_choice < item_no) + ) { + /* Scroll menu up */ + scrollok(menu, TRUE); + wscrl(menu, 1); + scrollok(menu, FALSE); + + scroll++; + + print_item(menu, + items[(scroll + max_choice - + 1) * 2 + 1], + max_choice - 1, FALSE, + (items + [(scroll + max_choice - + 1) * 2][0] != ':')); + } else + choice = + MIN(choice + 1, max_choice - 1); + + } else if (key == KEY_PPAGE) { + scrollok(menu, TRUE); + for (i = 0; (i < max_choice); i++) { + if (scroll > 0) { + wscrl(menu, -1); + scroll--; + print_item(menu, + items[scroll * 2 + + 1], 0, FALSE, + (items[scroll * 2][0] + != ':')); + } else { + if (choice > 0) + choice--; + } + } + scrollok(menu, FALSE); + + } else if (key == KEY_NPAGE) { + for (i = 0; (i < max_choice); i++) { + if (scroll + max_choice < item_no) { + scrollok(menu, TRUE); + wscrl(menu, 1); + scrollok(menu, FALSE); + scroll++; + print_item(menu, + items[(scroll + + max_choice - + 1) * 2 + 1], + max_choice - 1, + FALSE, + (items + [(scroll + + max_choice - + 1) * 2][0] != + ':')); + } else { + if (choice + 1 < max_choice) + choice++; + } + } + + } else + choice = i; + + print_item(menu, items[(scroll + choice) * 2 + 1], + choice, TRUE, + (items[(scroll + choice) * 2][0] != ':')); + + print_arrows(dialog, item_no, scroll, + box_y, box_x + item_x + 1, menu_height); + + wnoutrefresh(dialog); + wrefresh(menu); + + continue; /* wait for another key press */ + } + + switch (key) { + case KEY_LEFT: + case TAB: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 2 : (button > 2 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(menu); + break; + case ' ': + case 's': + case 'y': + case 'n': + case 'm': + case '/': + /* save scroll info */ + if ((f = fopen("lxdialog.scrltmp", "w")) != NULL) { + fprintf(f, "%d\n", scroll); + fclose(f); + } + delwin(dialog); + fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); + switch (key) { + case 's': + return 3; + case 'y': + return 3; + case 'n': + return 4; + case 'm': + return 5; + case ' ': + return 6; + case '/': + return 7; + } + return 0; + case 'h': + case '?': + button = 2; + case '\n': + delwin(dialog); + if (button == 2) + fprintf(stderr, "%s \"%s\"\n", + items[(scroll + choice) * 2], + items[(scroll + choice) * 2 + 1] + + first_alpha(items + [(scroll + choice) * 2 + 1], + "")); + else + fprintf(stderr, "%s\n", + items[(scroll + choice) * 2]); + + remove("lxdialog.scrltmp"); + return button; + case 'e': + case 'x': + key = ESC; + case ESC: + break; + } } - } - delwin (dialog); - remove("lxdialog.scrltmp"); - return -1; /* ESC pressed */ + delwin(dialog); + remove("lxdialog.scrltmp"); + return -1; /* ESC pressed */ } diff --git a/scripts/lxdialog/msgbox.c b/scripts/lxdialog/msgbox.c index 93692e1..76f358c 100644 --- a/scripts/lxdialog/msgbox.c +++ b/scripts/lxdialog/msgbox.c @@ -26,60 +26,59 @@ * if the parameter 'pause' is non-zero. */ int -dialog_msgbox (const char *title, const char *prompt, int height, int width, - int pause) +dialog_msgbox(const char *title, const char *prompt, int height, int width, + int pause) { - int i, x, y, key = 0; - WINDOW *dialog; + int i, x, y, key = 0; + WINDOW *dialog; - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; - draw_shadow (stdscr, y, x, height, width); + draw_shadow(stdscr, y, x, height, width); - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } + if (title != NULL && strlen(title) >= width - 2) { + /* truncate long title -- mec */ + char *title2 = malloc(width - 2 + 1); + memcpy(title2, title, width - 2); + title2[width - 2] = '\0'; + title = title2; + } - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 2); + if (title != NULL) { + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); + waddstr(dialog, (char *)title); + waddch(dialog, ' '); + } + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 2); - if (pause) { - wattrset (dialog, border_attr); - mvwaddch (dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - waddch (dialog, ACS_RTEE); + if (pause) { + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + waddch(dialog, ACS_RTEE); - print_button (dialog, " Ok ", - height - 2, width / 2 - 4, TRUE); + print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE); - wrefresh (dialog); - while (key != ESC && key != '\n' && key != ' ' && - key != 'O' && key != 'o' && key != 'X' && key != 'x') - key = wgetch (dialog); - } else { - key = '\n'; - wrefresh (dialog); - } + wrefresh(dialog); + while (key != ESC && key != '\n' && key != ' ' && + key != 'O' && key != 'o' && key != 'X' && key != 'x') + key = wgetch(dialog); + } else { + key = '\n'; + wrefresh(dialog); + } - delwin (dialog); - return key == ESC ? -1 : 0; + delwin(dialog); + return key == ESC ? -1 : 0; } diff --git a/scripts/lxdialog/textbox.c b/scripts/lxdialog/textbox.c index ed23df2..d6e7f2a 100644 --- a/scripts/lxdialog/textbox.c +++ b/scripts/lxdialog/textbox.c @@ -21,11 +21,11 @@ #include "dialog.h" -static void back_lines (int n); -static void print_page (WINDOW * win, int height, int width); -static void print_line (WINDOW * win, int row, int width); -static char *get_line (void); -static void print_position (WINDOW * win, int height, int width); +static void back_lines(int n); +static void print_page(WINDOW * win, int height, int width); +static void print_line(WINDOW * win, int row, int width); +static char *get_line(void); +static void print_position(WINDOW * win, int height, int width); static int hscroll, fd, file_size, bytes_read; static int begin_reached = 1, end_reached, page_length; @@ -34,450 +34,466 @@ static char *buf, *page; /* * Display text from a file in a dialog box. */ -int -dialog_textbox (const char *title, const char *file, int height, int width) +int dialog_textbox(const char *title, const char *file, int height, int width) { - int i, x, y, cur_x, cur_y, fpos, key = 0; - int passed_end; - char search_term[MAX_LEN + 1]; - WINDOW *dialog, *text; - - search_term[0] = '\0'; /* no search term entered yet */ - - /* Open input file for reading */ - if ((fd = open (file, O_RDONLY)) == -1) { - endwin (); - fprintf (stderr, - "\nCan't open input file in dialog_textbox().\n"); - exit (-1); - } - /* Get file size. Actually, 'file_size' is the real file size - 1, - since it's only the last byte offset from the beginning */ - if ((file_size = lseek (fd, 0, SEEK_END)) == -1) { - endwin (); - fprintf (stderr, "\nError getting file size in dialog_textbox().\n"); - exit (-1); - } - /* Restore file pointer to beginning of file after getting file size */ - if (lseek (fd, 0, SEEK_SET) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in dialog_textbox().\n"); - exit (-1); - } - /* Allocate space for read buffer */ - if ((buf = malloc (BUF_SIZE + 1)) == NULL) { - endwin (); - fprintf (stderr, "\nCan't allocate memory in dialog_textbox().\n"); - exit (-1); - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, "\nError reading file in dialog_textbox().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; /* mark end of valid data */ - page = buf; /* page is pointer to start of page to be displayed */ - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - /* Create window for text region, used for scrolling text */ - text = subwin (dialog, height - 4, width - 2, y + 1, x + 1); - wattrset (text, dialog_attr); - wbkgdset (text, dialog_attr & A_COLOR); - - keypad (text, TRUE); - - /* register the new window, along with its borders */ - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - - wattrset (dialog, border_attr); - mvwaddch (dialog, height-3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - wbkgdset (dialog, dialog_attr & A_COLOR); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - print_button (dialog, " Exit ", height - 2, width / 2 - 4, TRUE); - wnoutrefresh (dialog); - getyx (dialog, cur_y, cur_x); /* Save cursor position */ - - /* Print first page of text */ - attr_clear (text, height - 4, width - 2, dialog_attr); - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - - while ((key != ESC) && (key != '\n')) { - key = wgetch (dialog); - switch (key) { - case 'E': /* Exit */ - case 'e': - case 'X': - case 'x': - delwin (dialog); - free (buf); - close (fd); - return 0; - case 'g': /* First page */ - case KEY_HOME: - if (!begin_reached) { - begin_reached = 1; - /* First page not in buffer? */ - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, - "\nError moving file pointer in dialog_textbox().\n"); - exit (-1); - } - if (fpos > bytes_read) { /* Yes, we have to read it in */ - if (lseek (fd, 0, SEEK_SET) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in " - "dialog_textbox().\n"); - exit (-1); - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, - "\nError reading file in dialog_textbox().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; - } - page = buf; - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - } - break; - case 'G': /* Last page */ - case KEY_END: - - end_reached = 1; - /* Last page not in buffer? */ - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, - "\nError moving file pointer in dialog_textbox().\n"); - exit (-1); - } - if (fpos < file_size) { /* Yes, we have to read it in */ - if (lseek (fd, -BUF_SIZE, SEEK_END) == -1) { - endwin (); - fprintf (stderr, - "\nError moving file pointer in dialog_textbox().\n"); - exit (-1); - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, - "\nError reading file in dialog_textbox().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; - } - page = buf + bytes_read; - back_lines (height - 4); - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - break; - case 'K': /* Previous line */ - case 'k': - case KEY_UP: - if (!begin_reached) { - back_lines (page_length + 1); - - /* We don't call print_page() here but use scrolling to ensure - faster screen update. However, 'end_reached' and - 'page_length' should still be updated, and 'page' should - point to start of next page. This is done by calling - get_line() in the following 'for' loop. */ - scrollok (text, TRUE); - wscrl (text, -1); /* Scroll text region down one line */ - scrollok (text, FALSE); - page_length = 0; - passed_end = 0; - for (i = 0; i < height - 4; i++) { - if (!i) { - /* print first line of page */ - print_line (text, 0, width - 2); - wnoutrefresh (text); - } else - /* Called to update 'end_reached' and 'page' */ - get_line (); - if (!passed_end) - page_length++; - if (end_reached && !passed_end) - passed_end = 1; - } + int i, x, y, cur_x, cur_y, fpos, key = 0; + int passed_end; + char search_term[MAX_LEN + 1]; + WINDOW *dialog, *text; + + search_term[0] = '\0'; /* no search term entered yet */ + + /* Open input file for reading */ + if ((fd = open(file, O_RDONLY)) == -1) { + endwin(); + fprintf(stderr, + "\nCan't open input file in dialog_textbox().\n"); + exit(-1); + } + /* Get file size. Actually, 'file_size' is the real file size - 1, + since it's only the last byte offset from the beginning */ + if ((file_size = lseek(fd, 0, SEEK_END)) == -1) { + endwin(); + fprintf(stderr, + "\nError getting file size in dialog_textbox().\n"); + exit(-1); + } + /* Restore file pointer to beginning of file after getting file size */ + if (lseek(fd, 0, SEEK_SET) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit(-1); + } + /* Allocate space for read buffer */ + if ((buf = malloc(BUF_SIZE + 1)) == NULL) { + endwin(); + fprintf(stderr, + "\nCan't allocate memory in dialog_textbox().\n"); + exit(-1); + } + if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, "\nError reading file in dialog_textbox().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; /* mark end of valid data */ + page = buf; /* page is pointer to start of page to be displayed */ + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + /* Create window for text region, used for scrolling text */ + text = subwin(dialog, height - 4, width - 2, y + 1, x + 1); + wattrset(text, dialog_attr); + wbkgdset(text, dialog_attr & A_COLOR); + + keypad(text, TRUE); + + /* register the new window, along with its borders */ + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + wbkgdset(dialog, dialog_attr & A_COLOR); + waddch(dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width - 2) { + /* truncate long title -- mec */ + char *title2 = malloc(width - 2 + 1); + memcpy(title2, title, width - 2); + title2[width - 2] = '\0'; + title = title2; + } - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - } - break; - case 'B': /* Previous page */ - case 'b': - case KEY_PPAGE: - if (begin_reached) - break; - back_lines (page_length + height - 4); - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); - wrefresh (dialog); - break; - case 'J': /* Next line */ - case 'j': - case KEY_DOWN: - if (!end_reached) { - begin_reached = 0; - scrollok (text, TRUE); - scroll (text); /* Scroll text region up one line */ - scrollok (text, FALSE); - print_line (text, height - 5, width - 2); - wnoutrefresh (text); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh (dialog); - } - break; - case KEY_NPAGE: /* Next page */ - case ' ': - if (end_reached) - break; - - begin_reached = 0; - print_page (text, height - 4, width - 2); - print_position (dialog, height, width); - wmove (dialog, cur_y, cur_x); - wrefresh (dialog); - break; - case '0': /* Beginning of line */ - case 'H': /* Scroll left */ - case 'h': - case KEY_LEFT: - if (hscroll <= 0) - break; - - if (key == '0') - hscroll = 0; - else - hscroll--; - /* Reprint current page to scroll horizontally */ - back_lines (page_length); - print_page (text, height - 4, width - 2); - wmove (dialog, cur_y, cur_x); - wrefresh (dialog); - break; - case 'L': /* Scroll right */ - case 'l': - case KEY_RIGHT: - if (hscroll >= MAX_LEN) - break; - hscroll++; - /* Reprint current page to scroll horizontally */ - back_lines (page_length); - print_page (text, height - 4, width - 2); - wmove (dialog, cur_y, cur_x); - wrefresh (dialog); - break; - case ESC: - break; + if (title != NULL) { + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); + waddstr(dialog, (char *)title); + waddch(dialog, ' '); + } + print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE); + wnoutrefresh(dialog); + getyx(dialog, cur_y, cur_x); /* Save cursor position */ + + /* Print first page of text */ + attr_clear(text, height - 4, width - 2, dialog_attr); + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + + while ((key != ESC) && (key != '\n')) { + key = wgetch(dialog); + switch (key) { + case 'E': /* Exit */ + case 'e': + case 'X': + case 'x': + delwin(dialog); + free(buf); + close(fd); + return 0; + case 'g': /* First page */ + case KEY_HOME: + if (!begin_reached) { + begin_reached = 1; + /* First page not in buffer? */ + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit(-1); + } + if (fpos > bytes_read) { /* Yes, we have to read it in */ + if (lseek(fd, 0, SEEK_SET) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in " + "dialog_textbox().\n"); + exit(-1); + } + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, + "\nError reading file in dialog_textbox().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + } + page = buf; + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case 'G': /* Last page */ + case KEY_END: + + end_reached = 1; + /* Last page not in buffer? */ + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit(-1); + } + if (fpos < file_size) { /* Yes, we have to read it in */ + if (lseek(fd, -BUF_SIZE, SEEK_END) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in dialog_textbox().\n"); + exit(-1); + } + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, + "\nError reading file in dialog_textbox().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + } + page = buf + bytes_read; + back_lines(height - 4); + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + break; + case 'K': /* Previous line */ + case 'k': + case KEY_UP: + if (!begin_reached) { + back_lines(page_length + 1); + + /* We don't call print_page() here but use scrolling to ensure + faster screen update. However, 'end_reached' and + 'page_length' should still be updated, and 'page' should + point to start of next page. This is done by calling + get_line() in the following 'for' loop. */ + scrollok(text, TRUE); + wscrl(text, -1); /* Scroll text region down one line */ + scrollok(text, FALSE); + page_length = 0; + passed_end = 0; + for (i = 0; i < height - 4; i++) { + if (!i) { + /* print first line of page */ + print_line(text, 0, width - 2); + wnoutrefresh(text); + } else + /* Called to update 'end_reached' and 'page' */ + get_line(); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case 'B': /* Previous page */ + case 'b': + case KEY_PPAGE: + if (begin_reached) + break; + back_lines(page_length + height - 4); + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + break; + case 'J': /* Next line */ + case 'j': + case KEY_DOWN: + if (!end_reached) { + begin_reached = 0; + scrollok(text, TRUE); + scroll(text); /* Scroll text region up one line */ + scrollok(text, FALSE); + print_line(text, height - 5, width - 2); + wnoutrefresh(text); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case KEY_NPAGE: /* Next page */ + case ' ': + if (end_reached) + break; + + begin_reached = 0; + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + break; + case '0': /* Beginning of line */ + case 'H': /* Scroll left */ + case 'h': + case KEY_LEFT: + if (hscroll <= 0) + break; + + if (key == '0') + hscroll = 0; + else + hscroll--; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + print_page(text, height - 4, width - 2); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + break; + case 'L': /* Scroll right */ + case 'l': + case KEY_RIGHT: + if (hscroll >= MAX_LEN) + break; + hscroll++; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + print_page(text, height - 4, width - 2); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + break; + case ESC: + break; + } } - } - delwin (dialog); - free (buf); - close (fd); - return -1; /* ESC pressed */ + delwin(dialog); + free(buf); + close(fd); + return -1; /* ESC pressed */ } /* * Go back 'n' lines in text file. Called by dialog_textbox(). * 'page' will be updated to point to the desired line in 'buf'. */ -static void -back_lines (int n) +static void back_lines(int n) { - int i, fpos; - - begin_reached = 0; - /* We have to distinguish between end_reached and !end_reached - since at end of file, the line is not ended by a '\n'. - The code inside 'if' basically does a '--page' to move one - character backward so as to skip '\n' of the previous line */ - if (!end_reached) { - /* Either beginning of buffer or beginning of file reached? */ - if (page == buf) { - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in " - "back_lines().\n"); - exit (-1); - } - if (fpos > bytes_read) { /* Not beginning of file yet */ - /* We've reached beginning of buffer, but not beginning of - file yet, so read previous part of file into buffer. - Note that we only move backward for BUF_SIZE/2 bytes, - but not BUF_SIZE bytes to avoid re-reading again in - print_page() later */ - /* Really possible to move backward BUF_SIZE/2 bytes? */ - if (fpos < BUF_SIZE / 2 + bytes_read) { - /* No, move less then */ - if (lseek (fd, 0, SEEK_SET) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in " - "back_lines().\n"); - exit (-1); - } - page = buf + fpos - bytes_read; - } else { /* Move backward BUF_SIZE/2 bytes */ - if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) - == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer " - "in back_lines().\n"); - exit (-1); - } - page = buf + BUF_SIZE / 2; + int i, fpos; + + begin_reached = 0; + /* We have to distinguish between end_reached and !end_reached + since at end of file, the line is not ended by a '\n'. + The code inside 'if' basically does a '--page' to move one + character backward so as to skip '\n' of the previous line */ + if (!end_reached) { + /* Either beginning of buffer or beginning of file reached? */ + if (page == buf) { + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in " + "back_lines().\n"); + exit(-1); + } + if (fpos > bytes_read) { /* Not beginning of file yet */ + /* We've reached beginning of buffer, but not beginning of + file yet, so read previous part of file into buffer. + Note that we only move backward for BUF_SIZE/2 bytes, + but not BUF_SIZE bytes to avoid re-reading again in + print_page() later */ + /* Really possible to move backward BUF_SIZE/2 bytes? */ + if (fpos < BUF_SIZE / 2 + bytes_read) { + /* No, move less then */ + if (lseek(fd, 0, SEEK_SET) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in " + "back_lines().\n"); + exit(-1); + } + page = buf + fpos - bytes_read; + } else { /* Move backward BUF_SIZE/2 bytes */ + if (lseek + (fd, -(BUF_SIZE / 2 + bytes_read), + SEEK_CUR) + == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer " + "in back_lines().\n"); + exit(-1); + } + page = buf + BUF_SIZE / 2; + } + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, + "\nError reading file in back_lines().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + } else { /* Beginning of file reached */ + begin_reached = 1; + return; + } } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, "\nError reading file in back_lines().\n"); - exit (-1); + if (*(--page) != '\n') { /* '--page' here */ + /* Something's wrong... */ + endwin(); + fprintf(stderr, "\nInternal error in back_lines().\n"); + exit(-1); } - buf[bytes_read] = '\0'; - } else { /* Beginning of file reached */ - begin_reached = 1; - return; - } - } - if (*(--page) != '\n') { /* '--page' here */ - /* Something's wrong... */ - endwin (); - fprintf (stderr, "\nInternal error in back_lines().\n"); - exit (-1); } - } - /* Go back 'n' lines */ - for (i = 0; i < n; i++) - do { - if (page == buf) { - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, - "\nError moving file pointer in back_lines().\n"); - exit (-1); - } - if (fpos > bytes_read) { - /* Really possible to move backward BUF_SIZE/2 bytes? */ - if (fpos < BUF_SIZE / 2 + bytes_read) { - /* No, move less then */ - if (lseek (fd, 0, SEEK_SET) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer " - "in back_lines().\n"); - exit (-1); - } - page = buf + fpos - bytes_read; - } else { /* Move backward BUF_SIZE/2 bytes */ - if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), - SEEK_CUR) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer" - " in back_lines().\n"); - exit (-1); + /* Go back 'n' lines */ + for (i = 0; i < n; i++) + do { + if (page == buf) { + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in back_lines().\n"); + exit(-1); + } + if (fpos > bytes_read) { + /* Really possible to move backward BUF_SIZE/2 bytes? */ + if (fpos < BUF_SIZE / 2 + bytes_read) { + /* No, move less then */ + if (lseek(fd, 0, SEEK_SET) == + -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer " + "in back_lines().\n"); + exit(-1); + } + page = buf + fpos - bytes_read; + } else { /* Move backward BUF_SIZE/2 bytes */ + if (lseek + (fd, + -(BUF_SIZE / 2 + + bytes_read), + SEEK_CUR) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer" + " in back_lines().\n"); + exit(-1); + } + page = buf + BUF_SIZE / 2; + } + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, + "\nError reading file in " + "back_lines().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + } else { /* Beginning of file reached */ + begin_reached = 1; + return; + } } - page = buf + BUF_SIZE / 2; - } - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, "\nError reading file in " - "back_lines().\n"); - exit (-1); - } - buf[bytes_read] = '\0'; - } else { /* Beginning of file reached */ - begin_reached = 1; - return; - } - } - } while (*(--page) != '\n'); - page++; + } while (*(--page) != '\n'); + page++; } /* * Print a new page of text. Called by dialog_textbox(). */ -static void -print_page (WINDOW * win, int height, int width) +static void print_page(WINDOW * win, int height, int width) { - int i, passed_end = 0; - - page_length = 0; - for (i = 0; i < height; i++) { - print_line (win, i, width); - if (!passed_end) - page_length++; - if (end_reached && !passed_end) - passed_end = 1; - } - wnoutrefresh (win); + int i, passed_end = 0; + + page_length = 0; + for (i = 0; i < height; i++) { + print_line(win, i, width); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + wnoutrefresh(win); } /* * Print a new line of text. Called by dialog_textbox() and print_page(). */ -static void -print_line (WINDOW * win, int row, int width) +static void print_line(WINDOW * win, int row, int width) { - int y, x; - char *line; + int y, x; + char *line; - line = get_line (); - line += MIN (strlen (line), hscroll); /* Scroll horizontally */ - wmove (win, row, 0); /* move cursor to correct line */ - waddch (win, ' '); - waddnstr (win, line, MIN (strlen (line), width - 2)); + line = get_line(); + line += MIN(strlen(line), hscroll); /* Scroll horizontally */ + wmove(win, row, 0); /* move cursor to correct line */ + waddch(win, ' '); + waddnstr(win, line, MIN(strlen(line), width - 2)); - getyx (win, y, x); - /* Clear 'residue' of previous line */ + getyx(win, y, x); + /* Clear 'residue' of previous line */ #if OLD_NCURSES - { - int i; - for (i = 0; i < width - x; i++) - waddch (win, ' '); - } + { + int i; + for (i = 0; i < width - x; i++) + waddch(win, ' '); + } #else - wclrtoeol(win); + wclrtoeol(win); #endif } @@ -486,71 +502,73 @@ print_line (WINDOW * win, int row, int width) * 'page' should point to start of current line before calling, and will be * updated to point to start of next line. */ -static char * -get_line (void) +static char *get_line(void) { - int i = 0, fpos; - static char line[MAX_LEN + 1]; - - end_reached = 0; - while (*page != '\n') { - if (*page == '\0') { - /* Either end of file or end of buffer reached */ - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in " - "get_line().\n"); - exit (-1); - } - if (fpos < file_size) { /* Not end of file yet */ - /* We've reached end of buffer, but not end of file yet, - so read next part of file into buffer */ - if ((bytes_read = read (fd, buf, BUF_SIZE)) == -1) { - endwin (); - fprintf (stderr, "\nError reading file in get_line().\n"); - exit (-1); + int i = 0, fpos; + static char line[MAX_LEN + 1]; + + end_reached = 0; + while (*page != '\n') { + if (*page == '\0') { + /* Either end of file or end of buffer reached */ + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in " + "get_line().\n"); + exit(-1); + } + if (fpos < file_size) { /* Not end of file yet */ + /* We've reached end of buffer, but not end of file yet, + so read next part of file into buffer */ + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, + "\nError reading file in get_line().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + page = buf; + } else { + if (!end_reached) + end_reached = 1; + break; + } + } else if (i < MAX_LEN) + line[i++] = *(page++); + else { + /* Truncate lines longer than MAX_LEN characters */ + if (i == MAX_LEN) + line[i++] = '\0'; + page++; } - buf[bytes_read] = '\0'; - page = buf; - } else { - if (!end_reached) - end_reached = 1; - break; - } - } else if (i < MAX_LEN) - line[i++] = *(page++); - else { - /* Truncate lines longer than MAX_LEN characters */ - if (i == MAX_LEN) - line[i++] = '\0'; - page++; } - } - if (i <= MAX_LEN) - line[i] = '\0'; - if (!end_reached) - page++; /* move pass '\n' */ + if (i <= MAX_LEN) + line[i] = '\0'; + if (!end_reached) + page++; /* move pass '\n' */ - return line; + return line; } /* * Print current position */ -static void -print_position (WINDOW * win, int height, int width) +static void print_position(WINDOW * win, int height, int width) { - int fpos, percent; - - if ((fpos = lseek (fd, 0, SEEK_CUR)) == -1) { - endwin (); - fprintf (stderr, "\nError moving file pointer in print_position().\n"); - exit (-1); - } - wattrset (win, position_indicator_attr); - wbkgdset (win, position_indicator_attr & A_COLOR); - percent = !file_size ? - 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; - wmove (win, height - 3, width - 9); - wprintw (win, "(%3d%%)", percent); + int fpos, percent; + + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, + "\nError moving file pointer in print_position().\n"); + exit(-1); + } + wattrset(win, position_indicator_attr); + wbkgdset(win, position_indicator_attr & A_COLOR); + percent = !file_size ? + 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; + wmove(win, height - 3, width - 9); + wprintw(win, "(%3d%%)", percent); } diff --git a/scripts/lxdialog/util.c b/scripts/lxdialog/util.c index e7bce9b..232b32c 100644 --- a/scripts/lxdialog/util.c +++ b/scripts/lxdialog/util.c @@ -21,7 +21,6 @@ #include "dialog.h" - /* use colors by default? */ bool use_colors = 1; @@ -32,326 +31,318 @@ const char *dialog_result; /* * Attribute values, default is for mono display */ -chtype attributes[] = -{ - A_NORMAL, /* screen_attr */ - A_NORMAL, /* shadow_attr */ - A_NORMAL, /* dialog_attr */ - A_BOLD, /* title_attr */ - A_NORMAL, /* border_attr */ - A_REVERSE, /* button_active_attr */ - A_DIM, /* button_inactive_attr */ - A_REVERSE, /* button_key_active_attr */ - A_BOLD, /* button_key_inactive_attr */ - A_REVERSE, /* button_label_active_attr */ - A_NORMAL, /* button_label_inactive_attr */ - A_NORMAL, /* inputbox_attr */ - A_NORMAL, /* inputbox_border_attr */ - A_NORMAL, /* searchbox_attr */ - A_BOLD, /* searchbox_title_attr */ - A_NORMAL, /* searchbox_border_attr */ - A_BOLD, /* position_indicator_attr */ - A_NORMAL, /* menubox_attr */ - A_NORMAL, /* menubox_border_attr */ - A_NORMAL, /* item_attr */ - A_REVERSE, /* item_selected_attr */ - A_BOLD, /* tag_attr */ - A_REVERSE, /* tag_selected_attr */ - A_BOLD, /* tag_key_attr */ - A_REVERSE, /* tag_key_selected_attr */ - A_BOLD, /* check_attr */ - A_REVERSE, /* check_selected_attr */ - A_BOLD, /* uarrow_attr */ - A_BOLD /* darrow_attr */ +chtype attributes[] = { + A_NORMAL, /* screen_attr */ + A_NORMAL, /* shadow_attr */ + A_NORMAL, /* dialog_attr */ + A_BOLD, /* title_attr */ + A_NORMAL, /* border_attr */ + A_REVERSE, /* button_active_attr */ + A_DIM, /* button_inactive_attr */ + A_REVERSE, /* button_key_active_attr */ + A_BOLD, /* button_key_inactive_attr */ + A_REVERSE, /* button_label_active_attr */ + A_NORMAL, /* button_label_inactive_attr */ + A_NORMAL, /* inputbox_attr */ + A_NORMAL, /* inputbox_border_attr */ + A_NORMAL, /* searchbox_attr */ + A_BOLD, /* searchbox_title_attr */ + A_NORMAL, /* searchbox_border_attr */ + A_BOLD, /* position_indicator_attr */ + A_NORMAL, /* menubox_attr */ + A_NORMAL, /* menubox_border_attr */ + A_NORMAL, /* item_attr */ + A_REVERSE, /* item_selected_attr */ + A_BOLD, /* tag_attr */ + A_REVERSE, /* tag_selected_attr */ + A_BOLD, /* tag_key_attr */ + A_REVERSE, /* tag_key_selected_attr */ + A_BOLD, /* check_attr */ + A_REVERSE, /* check_selected_attr */ + A_BOLD, /* uarrow_attr */ + A_BOLD /* darrow_attr */ }; - #include "colors.h" /* * Table of color values */ -int color_table[][3] = -{ - {SCREEN_FG, SCREEN_BG, SCREEN_HL}, - {SHADOW_FG, SHADOW_BG, SHADOW_HL}, - {DIALOG_FG, DIALOG_BG, DIALOG_HL}, - {TITLE_FG, TITLE_BG, TITLE_HL}, - {BORDER_FG, BORDER_BG, BORDER_HL}, - {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, - {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, - {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, - {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, BUTTON_KEY_INACTIVE_HL}, - {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, BUTTON_LABEL_ACTIVE_HL}, - {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, - BUTTON_LABEL_INACTIVE_HL}, - {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, - {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, - {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, - {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, - {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, - {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, - {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, - {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, - {ITEM_FG, ITEM_BG, ITEM_HL}, - {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, - {TAG_FG, TAG_BG, TAG_HL}, - {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, - {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, - {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, - {CHECK_FG, CHECK_BG, CHECK_HL}, - {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, - {UARROW_FG, UARROW_BG, UARROW_HL}, - {DARROW_FG, DARROW_BG, DARROW_HL}, +int color_table[][3] = { + {SCREEN_FG, SCREEN_BG, SCREEN_HL}, + {SHADOW_FG, SHADOW_BG, SHADOW_HL}, + {DIALOG_FG, DIALOG_BG, DIALOG_HL}, + {TITLE_FG, TITLE_BG, TITLE_HL}, + {BORDER_FG, BORDER_BG, BORDER_HL}, + {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, + {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, + {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, + {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, + BUTTON_KEY_INACTIVE_HL}, + {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, + BUTTON_LABEL_ACTIVE_HL}, + {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, + BUTTON_LABEL_INACTIVE_HL}, + {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, + {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, + {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, + {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, + {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, + {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, + {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, + {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, + {ITEM_FG, ITEM_BG, ITEM_HL}, + {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, + {TAG_FG, TAG_BG, TAG_HL}, + {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, + {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, + {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, + {CHECK_FG, CHECK_BG, CHECK_HL}, + {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, + {UARROW_FG, UARROW_BG, UARROW_HL}, + {DARROW_FG, DARROW_BG, DARROW_HL}, }; /* color_table */ /* * Set window to attribute 'attr' */ -void -attr_clear (WINDOW * win, int height, int width, chtype attr) +void attr_clear(WINDOW * win, int height, int width, chtype attr) { - int i, j; - - wattrset (win, attr); - for (i = 0; i < height; i++) { - wmove (win, i, 0); - for (j = 0; j < width; j++) - waddch (win, ' '); - } - touchwin (win); + int i, j; + + wattrset(win, attr); + for (i = 0; i < height; i++) { + wmove(win, i, 0); + for (j = 0; j < width; j++) + waddch(win, ' '); + } + touchwin(win); } -void dialog_clear (void) +void dialog_clear(void) { - attr_clear (stdscr, LINES, COLS, screen_attr); - /* Display background title if it exists ... - SLH */ - if (backtitle != NULL) { - int i; - - wattrset (stdscr, screen_attr); - mvwaddstr (stdscr, 0, 1, (char *)backtitle); - wmove (stdscr, 1, 1); - for (i = 1; i < COLS - 1; i++) - waddch (stdscr, ACS_HLINE); - } - wnoutrefresh (stdscr); + attr_clear(stdscr, LINES, COLS, screen_attr); + /* Display background title if it exists ... - SLH */ + if (backtitle != NULL) { + int i; + + wattrset(stdscr, screen_attr); + mvwaddstr(stdscr, 0, 1, (char *)backtitle); + wmove(stdscr, 1, 1); + for (i = 1; i < COLS - 1; i++) + waddch(stdscr, ACS_HLINE); + } + wnoutrefresh(stdscr); } /* * Do some initialization for dialog */ -void -init_dialog (void) +void init_dialog(void) { - initscr (); /* Init curses */ - keypad (stdscr, TRUE); - cbreak (); - noecho (); + initscr(); /* Init curses */ + keypad(stdscr, TRUE); + cbreak(); + noecho(); + if (use_colors) /* Set up colors */ + color_setup(); - if (use_colors) /* Set up colors */ - color_setup (); - - - dialog_clear (); + dialog_clear(); } /* * Setup for color display */ -void -color_setup (void) +void color_setup(void) { - int i; + int i; - if (has_colors ()) { /* Terminal supports color? */ - start_color (); + if (has_colors()) { /* Terminal supports color? */ + start_color(); - /* Initialize color pairs */ - for (i = 0; i < ATTRIBUTE_COUNT; i++) - init_pair (i + 1, color_table[i][0], color_table[i][1]); + /* Initialize color pairs */ + for (i = 0; i < ATTRIBUTE_COUNT; i++) + init_pair(i + 1, color_table[i][0], color_table[i][1]); - /* Setup color attributes */ - for (i = 0; i < ATTRIBUTE_COUNT; i++) - attributes[i] = C_ATTR (color_table[i][2], i + 1); - } + /* Setup color attributes */ + for (i = 0; i < ATTRIBUTE_COUNT; i++) + attributes[i] = C_ATTR(color_table[i][2], i + 1); + } } /* * End using dialog functions. */ -void -end_dialog (void) +void end_dialog(void) { - endwin (); + endwin(); } - /* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline * characters '\n' are replaced by spaces. We start on a new line * if there is no room for at least 4 nonblanks following a double-space. */ -void -print_autowrap (WINDOW * win, const char *prompt, int width, int y, int x) +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) { - int newl, cur_x, cur_y; - int i, prompt_len, room, wlen; - char tempstr[MAX_LEN + 1], *word, *sp, *sp2; - - strcpy (tempstr, prompt); - - prompt_len = strlen(tempstr); - - /* - * Remove newlines - */ - for(i=0; i room || - (newl && wlen < 4 && sp && wlen+1+strlen(sp) > room - && (!(sp2 = index(sp, ' ')) || wlen+1+(sp2-sp) > room))) { - cur_y++; + int newl, cur_x, cur_y; + int i, prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + + strcpy(tempstr, prompt); + + prompt_len = strlen(tempstr); + + /* + * Remove newlines + */ + for (i = 0; i < prompt_len; i++) { + if (tempstr[i] == '\n') + tempstr[i] = ' '; + } + + if (prompt_len <= width - x * 2) { /* If prompt is short */ + wmove(win, y, (width - prompt_len) / 2); + waddstr(win, tempstr); + } else { cur_x = x; - } - wmove (win, cur_y, cur_x); - waddstr (win, word); - getyx (win, cur_y, cur_x); - cur_x++; - if (sp && *sp == ' ') { - cur_x++; /* double space */ - while (*++sp == ' '); + cur_y = y; newl = 1; - } else - newl = 0; - word = sp; + word = tempstr; + while (word && *word) { + sp = index(word, ' '); + if (sp) + *sp++ = 0; + + /* Wrap to next line if either the word does not fit, + or it is the first word of a new sentence, and it is + short, and the next word does not fit. */ + room = width - cur_x; + wlen = strlen(word); + if (wlen > room || + (newl && wlen < 4 && sp + && wlen + 1 + strlen(sp) > room + && (!(sp2 = index(sp, ' ')) + || wlen + 1 + (sp2 - sp) > room))) { + cur_y++; + cur_x = x; + } + wmove(win, cur_y, cur_x); + waddstr(win, word); + getyx(win, cur_y, cur_x); + cur_x++; + if (sp && *sp == ' ') { + cur_x++; /* double space */ + while (*++sp == ' ') ; + newl = 1; + } else + newl = 0; + word = sp; + } } - } } /* * Print a button */ -void -print_button (WINDOW * win, const char *label, int y, int x, int selected) +void print_button(WINDOW * win, const char *label, int y, int x, int selected) { - int i, temp; - - wmove (win, y, x); - wattrset (win, selected ? button_active_attr : button_inactive_attr); - waddstr (win, "<"); - temp = strspn (label, " "); - label += temp; - wattrset (win, selected ? button_label_active_attr - : button_label_inactive_attr); - for (i = 0; i < temp; i++) - waddch (win, ' '); - wattrset (win, selected ? button_key_active_attr - : button_key_inactive_attr); - waddch (win, label[0]); - wattrset (win, selected ? button_label_active_attr - : button_label_inactive_attr); - waddstr (win, (char *)label + 1); - wattrset (win, selected ? button_active_attr : button_inactive_attr); - waddstr (win, ">"); - wmove (win, y, x + temp + 1); + int i, temp; + + wmove(win, y, x); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, "<"); + temp = strspn(label, " "); + label += temp; + wattrset(win, selected ? button_label_active_attr + : button_label_inactive_attr); + for (i = 0; i < temp; i++) + waddch(win, ' '); + wattrset(win, selected ? button_key_active_attr + : button_key_inactive_attr); + waddch(win, label[0]); + wattrset(win, selected ? button_label_active_attr + : button_label_inactive_attr); + waddstr(win, (char *)label + 1); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, ">"); + wmove(win, y, x + temp + 1); } /* * Draw a rectangular box with line drawing characters */ void -draw_box (WINDOW * win, int y, int x, int height, int width, - chtype box, chtype border) +draw_box(WINDOW * win, int y, int x, int height, int width, + chtype box, chtype border) { - int i, j; - - wattrset (win, 0); - for (i = 0; i < height; i++) { - wmove (win, y + i, x); - for (j = 0; j < width; j++) - if (!i && !j) - waddch (win, border | ACS_ULCORNER); - else if (i == height - 1 && !j) - waddch (win, border | ACS_LLCORNER); - else if (!i && j == width - 1) - waddch (win, box | ACS_URCORNER); - else if (i == height - 1 && j == width - 1) - waddch (win, box | ACS_LRCORNER); - else if (!i) - waddch (win, border | ACS_HLINE); - else if (i == height - 1) - waddch (win, box | ACS_HLINE); - else if (!j) - waddch (win, border | ACS_VLINE); - else if (j == width - 1) - waddch (win, box | ACS_VLINE); - else - waddch (win, box | ' '); - } + int i, j; + + wattrset(win, 0); + for (i = 0; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch(win, border | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch(win, border | ACS_LLCORNER); + else if (!i && j == width - 1) + waddch(win, box | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, box | ACS_LRCORNER); + else if (!i) + waddch(win, border | ACS_HLINE); + else if (i == height - 1) + waddch(win, box | ACS_HLINE); + else if (!j) + waddch(win, border | ACS_VLINE); + else if (j == width - 1) + waddch(win, box | ACS_VLINE); + else + waddch(win, box | ' '); + } } /* * Draw shadows along the right and bottom edge to give a more 3D look * to the boxes */ -void -draw_shadow (WINDOW * win, int y, int x, int height, int width) +void draw_shadow(WINDOW * win, int y, int x, int height, int width) { - int i; - - if (has_colors ()) { /* Whether terminal supports color? */ - wattrset (win, shadow_attr); - wmove (win, y + height, x + 2); - for (i = 0; i < width; i++) - waddch (win, winch (win) & A_CHARTEXT); - for (i = y + 1; i < y + height + 1; i++) { - wmove (win, i, x + width); - waddch (win, winch (win) & A_CHARTEXT); - waddch (win, winch (win) & A_CHARTEXT); + int i; + + if (has_colors()) { /* Whether terminal supports color? */ + wattrset(win, shadow_attr); + wmove(win, y + height, x + 2); + for (i = 0; i < width; i++) + waddch(win, winch(win) & A_CHARTEXT); + for (i = y + 1; i < y + height + 1; i++) { + wmove(win, i, x + width); + waddch(win, winch(win) & A_CHARTEXT); + waddch(win, winch(win) & A_CHARTEXT); + } + wnoutrefresh(win); } - wnoutrefresh (win); - } } /* * Return the position of the first alphabetic character in a string. */ -int -first_alpha(const char *string, const char *exempt) +int first_alpha(const char *string, const char *exempt) { - int i, in_paren=0, c; + int i, in_paren = 0, c; for (i = 0; i < strlen(string); i++) { c = tolower(string[i]); - if (strchr("<[(", c)) ++in_paren; - if (strchr(">])", c) && in_paren > 0) --in_paren; + if (strchr("<[(", c)) + ++in_paren; + if (strchr(">])", c) && in_paren > 0) + --in_paren; - if ((! in_paren) && isalpha(c) && - strchr(exempt, c) == 0) + if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) return i; } diff --git a/scripts/lxdialog/yesno.c b/scripts/lxdialog/yesno.c index 11fcc25..dffd5af 100644 --- a/scripts/lxdialog/yesno.c +++ b/scripts/lxdialog/yesno.c @@ -24,95 +24,93 @@ /* * Display termination buttons */ -static void -print_buttons(WINDOW *dialog, int height, int width, int selected) +static void print_buttons(WINDOW * dialog, int height, int width, int selected) { - int x = width / 2 - 10; - int y = height - 2; + int x = width / 2 - 10; + int y = height - 2; - print_button (dialog, " Yes ", y, x, selected == 0); - print_button (dialog, " No ", y, x + 13, selected == 1); + print_button(dialog, " Yes ", y, x, selected == 0); + print_button(dialog, " No ", y, x + 13, selected == 1); - wmove(dialog, y, x+1 + 13*selected ); - wrefresh (dialog); + wmove(dialog, y, x + 1 + 13 * selected); + wrefresh(dialog); } /* * Display a dialog box with two buttons - Yes and No */ -int -dialog_yesno (const char *title, const char *prompt, int height, int width) +int dialog_yesno(const char *title, const char *prompt, int height, int width) { - int i, x, y, key = 0, button = 0; - WINDOW *dialog; - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow (stdscr, y, x, height, width); - - dialog = newwin (height, width, y, x); - keypad (dialog, TRUE); - - draw_box (dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset (dialog, border_attr); - mvwaddch (dialog, height-3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch (dialog, ACS_HLINE); - wattrset (dialog, dialog_attr); - waddch (dialog, ACS_RTEE); - - if (title != NULL && strlen(title) >= width-2 ) { - /* truncate long title -- mec */ - char * title2 = malloc(width-2+1); - memcpy( title2, title, width-2 ); - title2[width-2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset (dialog, title_attr); - mvwaddch (dialog, 0, (width - strlen(title))/2 - 1, ' '); - waddstr (dialog, (char *)title); - waddch (dialog, ' '); - } - - wattrset (dialog, dialog_attr); - print_autowrap (dialog, prompt, width - 2, 1, 3); - - print_buttons(dialog, height, width, 0); - - while (key != ESC) { - key = wgetch (dialog); - switch (key) { - case 'Y': - case 'y': - delwin (dialog); - return 0; - case 'N': - case 'n': - delwin (dialog); - return 1; - - case TAB: - case KEY_LEFT: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 1 : (button > 1 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh (dialog); - break; - case ' ': - case '\n': - delwin (dialog); - return button; - case ESC: - break; + int i, x, y, key = 0, button = 0; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + waddch(dialog, ACS_RTEE); + + if (title != NULL && strlen(title) >= width - 2) { + /* truncate long title -- mec */ + char *title2 = malloc(width - 2 + 1); + memcpy(title2, title, width - 2); + title2[width - 2] = '\0'; + title = title2; } - } - delwin (dialog); - return -1; /* ESC pressed */ + if (title != NULL) { + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); + waddstr(dialog, (char *)title); + waddch(dialog, ' '); + } + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + print_buttons(dialog, height, width, 0); + + while (key != ESC) { + key = wgetch(dialog); + switch (key) { + case 'Y': + case 'y': + delwin(dialog); + return 0; + case 'N': + case 'n': + delwin(dialog); + return 1; + + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case ' ': + case '\n': + delwin(dialog); + return button; + case ESC: + break; + } + } + + delwin(dialog); + return -1; /* ESC pressed */ } -- cgit v1.1 From dec69da856653772d7ee7b2f98dc69da27274a22 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 19 Nov 2005 21:56:20 +0100 Subject: kconfig: fixup after Lindent Readability are more important then the 80 coloumn limit, so fold several lines to greatly improve readability. Also keep return type on same line as function definition. Signed-off-by: Sam Ravnborg --- scripts/lxdialog/checklist.c | 99 ++++++++++++++------------------------------ scripts/lxdialog/dialog.h | 3 +- scripts/lxdialog/inputbox.c | 49 +++++++--------------- scripts/lxdialog/menubox.c | 83 ++++++++++++------------------------- scripts/lxdialog/msgbox.c | 5 +-- scripts/lxdialog/textbox.c | 93 ++++++++++++++--------------------------- scripts/lxdialog/util.c | 2 +- scripts/lxdialog/yesno.c | 3 +- 8 files changed, 108 insertions(+), 229 deletions(-) diff --git a/scripts/lxdialog/checklist.c b/scripts/lxdialog/checklist.c index 1857c53..ae40a2b 100644 --- a/scripts/lxdialog/checklist.c +++ b/scripts/lxdialog/checklist.c @@ -28,8 +28,8 @@ static int list_width, check_x, item_x, checkflag; /* * Print list item */ -static void -print_item(WINDOW * win, const char *item, int status, int choice, int selected) +static void print_item(WINDOW * win, const char *item, int status, int choice, + int selected) { int i; @@ -59,8 +59,7 @@ print_item(WINDOW * win, const char *item, int status, int choice, int selected) /* * Print the scroll indicators. */ -static void -print_arrows(WINDOW * win, int choice, int item_no, int scroll, +static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, int y, int x, int height) { wmove(win, y, x); @@ -112,10 +111,9 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected) * Display a dialog box with a list of options that can be turned on or off * The `flag' parameter is used to select between radiolist and checklist. */ -int -dialog_checklist(const char *title, const char *prompt, int height, int width, - int list_height, int item_no, const char *const *items, - int flag) +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height, int item_no, + const char *const *items, int flag) { int i, x, y, box_x, box_y; int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; @@ -183,15 +181,14 @@ dialog_checklist(const char *title, const char *prompt, int height, int width, box_x = (width - list_width) / 2 - 1; /* create new window for the list */ - list = - subwin(dialog, list_height, list_width, y + box_y + 1, - x + box_x + 1); + list = subwin(dialog, list_height, list_width, y + box_y + 1, + x + box_x + 1); keypad(list, TRUE); /* draw a box around the list items */ draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, - menubox_border_attr, menubox_attr); + menubox_border_attr, menubox_attr); /* Find length of longest item in order to center checklist */ check_x = 0; @@ -238,24 +235,18 @@ dialog_checklist(const char *title, const char *prompt, int height, int width, /* Scroll list down */ if (list_height > 1) { /* De-highlight current first item */ - print_item(list, - items[scroll * 3 + - 1], - status[scroll], 0, - FALSE); + print_item(list, items[scroll * 3 + 1], + status[scroll], 0, FALSE); scrollok(list, TRUE); wscrl(list, -1); scrollok(list, FALSE); } scroll--; - print_item(list, items[scroll * 3 + 1], - status[scroll], 0, TRUE); + print_item(list, items[scroll * 3 + 1], status[scroll], 0, TRUE); wnoutrefresh(list); print_arrows(dialog, choice, item_no, - scroll, box_y, - box_x + check_x + 5, - list_height); + scroll, box_y, box_x + check_x + 5, list_height); wrefresh(dialog); @@ -269,32 +260,20 @@ dialog_checklist(const char *title, const char *prompt, int height, int width, /* Scroll list up */ if (list_height > 1) { /* De-highlight current last item before scrolling up */ - print_item(list, - items[(scroll + - max_choice - - 1) * 3 + 1], - status[scroll + - max_choice - - 1], - max_choice - 1, - FALSE); + print_item(list, items[(scroll + max_choice - 1) * 3 + 1], + status[scroll + max_choice - 1], + max_choice - 1, FALSE); scrollok(list, TRUE); wscrl(list, 1); scrollok(list, FALSE); } scroll++; - print_item(list, - items[(scroll + max_choice - - 1) * 3 + 1], - status[scroll + max_choice - - 1], max_choice - 1, - TRUE); + print_item(list, items[(scroll + max_choice - 1) * 3 + 1], + status[scroll + max_choice - 1], max_choice - 1, TRUE); wnoutrefresh(list); print_arrows(dialog, choice, item_no, - scroll, box_y, - box_x + check_x + 5, - list_height); + scroll, box_y, box_x + check_x + 5, list_height); wrefresh(dialog); @@ -304,16 +283,12 @@ dialog_checklist(const char *title, const char *prompt, int height, int width, } if (i != choice) { /* De-highlight current item */ - print_item(list, - items[(scroll + choice) * 3 + 1], - status[scroll + choice], choice, - FALSE); + print_item(list, items[(scroll + choice) * 3 + 1], + status[scroll + choice], choice, FALSE); /* Highlight new item */ choice = i; - print_item(list, - items[(scroll + choice) * 3 + 1], - status[scroll + choice], choice, - TRUE); + print_item(list, items[(scroll + choice) * 3 + 1], + status[scroll + choice], choice, TRUE); wnoutrefresh(list); wrefresh(dialog); } @@ -342,28 +317,18 @@ dialog_checklist(const char *title, const char *prompt, int height, int width, case '\n': if (!button) { if (flag == FLAG_CHECK) { - status[scroll + choice] = - !status[scroll + choice]; + status[scroll + choice] = !status[scroll + choice]; wmove(list, choice, check_x); wattrset(list, check_selected_attr); - wprintw(list, "[%c]", - status[scroll + - choice] ? 'X' : ' '); + wprintw(list, "[%c]", status[scroll + choice] ? 'X' : ' '); } else { if (!status[scroll + choice]) { for (i = 0; i < item_no; i++) status[i] = 0; status[scroll + choice] = 1; for (i = 0; i < max_choice; i++) - print_item(list, - items[(scroll - + - i) * - 3 + 1], - status[scroll - + i], - i, - i == choice); + print_item(list, items[(scroll + i) * 3 + 1], + status[scroll + i], i, i == choice); } } wnoutrefresh(list); @@ -372,19 +337,15 @@ dialog_checklist(const char *title, const char *prompt, int height, int width, for (i = 0; i < item_no; i++) { if (status[i]) { if (flag == FLAG_CHECK) { - fprintf(stderr, - "\"%s\" ", - items[i * 3]); + fprintf(stderr, "\"%s\" ", items[i * 3]); } else { - fprintf(stderr, "%s", - items[i * 3]); + fprintf(stderr, "%s", items[i * 3]); } } } } else - fprintf(stderr, "%s", - items[(scroll + choice) * 3]); + fprintf(stderr, "%s", items[(scroll + choice) * 3]); delwin(dialog); free(status); return button; diff --git a/scripts/lxdialog/dialog.h b/scripts/lxdialog/dialog.h index c86801f..3cf3d35 100644 --- a/scripts/lxdialog/dialog.h +++ b/scripts/lxdialog/dialog.h @@ -1,4 +1,3 @@ - /* * dialog.h -- common declarations for all dialog modules * @@ -87,7 +86,7 @@ #define ACS_DARROW 'v' #endif -/* +/* * Attribute names */ #define screen_attr attributes[0] diff --git a/scripts/lxdialog/inputbox.c b/scripts/lxdialog/inputbox.c index 9e96915..bc135c7 100644 --- a/scripts/lxdialog/inputbox.c +++ b/scripts/lxdialog/inputbox.c @@ -41,9 +41,8 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected) /* * Display a dialog box for inputing a string */ -int -dialog_inputbox(const char *title, const char *prompt, int height, int width, - const char *init) +int dialog_inputbox(const char *title, const char *prompt, int height, int width, + const char *init) { int i, x, y, box_y, box_x, box_width; int input_x = 0, scroll = 0, key = 0, button = -1; @@ -90,8 +89,7 @@ dialog_inputbox(const char *title, const char *prompt, int height, int width, getyx(dialog, y, x); box_y = y + 2; box_x = (width - box_width) / 2; - draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, - border_attr, dialog_attr); + draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); print_buttons(dialog, height, width, 0); @@ -111,8 +109,9 @@ dialog_inputbox(const char *title, const char *prompt, int height, int width, input_x = box_width - 1; for (i = 0; i < box_width - 1; i++) waddch(dialog, instr[scroll + i]); - } else + } else { waddstr(dialog, instr); + } wmove(dialog, box_y, box_x + input_x); @@ -136,26 +135,17 @@ dialog_inputbox(const char *title, const char *prompt, int height, int width, if (input_x || scroll) { wattrset(dialog, inputbox_attr); if (!input_x) { - scroll = - scroll < - box_width - 1 ? 0 : scroll - - (box_width - 1); + scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); wmove(dialog, box_y, box_x); for (i = 0; i < box_width; i++) waddch(dialog, - instr[scroll + - input_x + - i] ? - instr[scroll + - input_x + - i] : ' '); - input_x = - strlen(instr) - scroll; + instr[scroll + input_x + i] ? + instr[scroll + input_x + i] : ' '); + input_x = strlen(instr) - scroll; } else input_x--; instr[scroll + input_x] = '\0'; - mvwaddch(dialog, box_y, input_x + box_x, - ' '); + mvwaddch(dialog, box_y, input_x + box_x, ' '); wmove(dialog, box_y, input_x + box_x); wrefresh(dialog); } @@ -165,23 +155,14 @@ dialog_inputbox(const char *title, const char *prompt, int height, int width, if (scroll + input_x < MAX_LEN) { wattrset(dialog, inputbox_attr); instr[scroll + input_x] = key; - instr[scroll + input_x + 1] = - '\0'; + instr[scroll + input_x + 1] = '\0'; if (input_x == box_width - 1) { scroll++; - wmove(dialog, box_y, - box_x); - for (i = 0; - i < box_width - 1; - i++) - waddch(dialog, - instr - [scroll + - i]); + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr [scroll + i]); } else { - wmove(dialog, box_y, - input_x++ + - box_x); + wmove(dialog, box_y, input_x++ + box_x); waddch(dialog, key); } wrefresh(dialog); diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index 083f13d..260cc4d 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -63,8 +63,8 @@ static int menu_width, item_x; /* * Print menu item */ -static void -print_item(WINDOW * win, const char *item, int choice, int selected, int hotkey) +static void print_item(WINDOW * win, const char *item, int choice, + int selected, int hotkey) { int j; char menu_item[menu_width + 1]; @@ -100,8 +100,8 @@ print_item(WINDOW * win, const char *item, int choice, int selected, int hotkey) /* * Print the scroll indicators. */ -static void -print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, int height) +static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, + int height) { int cur_y, cur_x; @@ -158,10 +158,9 @@ static void print_buttons(WINDOW * win, int height, int width, int selected) /* * Display a menu for choosing among a number of options */ -int -dialog_menu(const char *title, const char *prompt, int height, int width, - int menu_height, const char *current, int item_no, - const char *const *items) +int dialog_menu(const char *title, const char *prompt, int height, int width, + int menu_height, const char *current, int item_no, + const char *const *items) { int i, j, x, y, box_x, box_y; int key = 0, button = 0, scroll = 0, choice = 0, first_item = @@ -283,20 +282,14 @@ dialog_menu(const char *title, const char *prompt, int height, int width, i = max_choice; else { for (i = choice + 1; i < max_choice; i++) { - j = first_alpha(items[(scroll + i) * 2 + 1], - "YyNnMmHh"); - if (key == - tolower(items[(scroll + i) * 2 + 1][j])) + j = first_alpha(items[(scroll + i) * 2 + 1], "YyNnMmHh"); + if (key == tolower(items[(scroll + i) * 2 + 1][j])) break; } if (i == max_choice) for (i = 0; i < max_choice; i++) { - j = first_alpha(items - [(scroll + i) * 2 + 1], - "YyNnMmHh"); - if (key == - tolower(items[(scroll + i) * 2 + 1] - [j])) + j = first_alpha(items [(scroll + i) * 2 + 1], "YyNnMmHh"); + if (key == tolower(items[(scroll + i) * 2 + 1][j])) break; } } @@ -319,24 +312,19 @@ dialog_menu(const char *title, const char *prompt, int height, int width, scroll--; - print_item(menu, items[scroll * 2 + 1], - 0, FALSE, - (items[scroll * 2][0] != - ':')); + print_item(menu, items[scroll * 2 + 1], 0, FALSE, + (items[scroll * 2][0] != ':')); } else choice = MAX(choice - 1, 0); } else if (key == KEY_DOWN || key == '+') { print_item(menu, - items[(scroll + choice) * 2 + 1], - choice, FALSE, - (items[(scroll + choice) * 2][0] != - ':')); + items[(scroll + choice) * 2 + 1], choice, FALSE, + (items[(scroll + choice) * 2][0] != ':')); if ((choice > max_choice - 3) && - (scroll + max_choice < item_no) - ) { + (scroll + max_choice < item_no)) { /* Scroll menu up */ scrollok(menu, TRUE); wscrl(menu, 1); @@ -344,16 +332,11 @@ dialog_menu(const char *title, const char *prompt, int height, int width, scroll++; - print_item(menu, - items[(scroll + max_choice - - 1) * 2 + 1], + print_item(menu, items[(scroll + max_choice - 1) * 2 + 1], max_choice - 1, FALSE, - (items - [(scroll + max_choice - - 1) * 2][0] != ':')); + (items [(scroll + max_choice - 1) * 2][0] != ':')); } else - choice = - MIN(choice + 1, max_choice - 1); + choice = MIN(choice + 1, max_choice - 1); } else if (key == KEY_PPAGE) { scrollok(menu, TRUE); @@ -361,11 +344,8 @@ dialog_menu(const char *title, const char *prompt, int height, int width, if (scroll > 0) { wscrl(menu, -1); scroll--; - print_item(menu, - items[scroll * 2 + - 1], 0, FALSE, - (items[scroll * 2][0] - != ':')); + print_item(menu, items[scroll * 2 + 1], 0, FALSE, + (items[scroll * 2][0] != ':')); } else { if (choice > 0) choice--; @@ -380,17 +360,9 @@ dialog_menu(const char *title, const char *prompt, int height, int width, wscrl(menu, 1); scrollok(menu, FALSE); scroll++; - print_item(menu, - items[(scroll + - max_choice - - 1) * 2 + 1], - max_choice - 1, - FALSE, - (items - [(scroll + - max_choice - - 1) * 2][0] != - ':')); + print_item(menu, items[(scroll + max_choice - 1) * 2 + 1], + max_choice - 1, FALSE, + (items [(scroll + max_choice - 1) * 2][0] != ':')); } else { if (choice + 1 < max_choice) choice++; @@ -401,8 +373,7 @@ dialog_menu(const char *title, const char *prompt, int height, int width, choice = i; print_item(menu, items[(scroll + choice) * 2 + 1], - choice, TRUE, - (items[(scroll + choice) * 2][0] != ':')); + choice, TRUE, (items[(scroll + choice) * 2][0] != ':')); print_arrows(dialog, item_no, scroll, box_y, box_x + item_x + 1, menu_height); @@ -460,9 +431,7 @@ dialog_menu(const char *title, const char *prompt, int height, int width, fprintf(stderr, "%s \"%s\"\n", items[(scroll + choice) * 2], items[(scroll + choice) * 2 + 1] + - first_alpha(items - [(scroll + choice) * 2 + 1], - "")); + first_alpha(items [(scroll + choice) * 2 + 1], "")); else fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); diff --git a/scripts/lxdialog/msgbox.c b/scripts/lxdialog/msgbox.c index 76f358c..b394057 100644 --- a/scripts/lxdialog/msgbox.c +++ b/scripts/lxdialog/msgbox.c @@ -25,9 +25,8 @@ * Display a message box. Program will pause and display an "OK" button * if the parameter 'pause' is non-zero. */ -int -dialog_msgbox(const char *title, const char *prompt, int height, int width, - int pause) +int dialog_msgbox(const char *title, const char *prompt, int height, int width, + int pause) { int i, x, y, key = 0; WINDOW *dialog; diff --git a/scripts/lxdialog/textbox.c b/scripts/lxdialog/textbox.c index d6e7f2a..fa8d92e 100644 --- a/scripts/lxdialog/textbox.c +++ b/scripts/lxdialog/textbox.c @@ -46,30 +46,26 @@ int dialog_textbox(const char *title, const char *file, int height, int width) /* Open input file for reading */ if ((fd = open(file, O_RDONLY)) == -1) { endwin(); - fprintf(stderr, - "\nCan't open input file in dialog_textbox().\n"); + fprintf(stderr, "\nCan't open input file in dialog_textbox().\n"); exit(-1); } /* Get file size. Actually, 'file_size' is the real file size - 1, since it's only the last byte offset from the beginning */ if ((file_size = lseek(fd, 0, SEEK_END)) == -1) { endwin(); - fprintf(stderr, - "\nError getting file size in dialog_textbox().\n"); + fprintf(stderr, "\nError getting file size in dialog_textbox().\n"); exit(-1); } /* Restore file pointer to beginning of file after getting file size */ if (lseek(fd, 0, SEEK_SET) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in dialog_textbox().\n"); + fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); exit(-1); } /* Allocate space for read buffer */ if ((buf = malloc(BUF_SIZE + 1)) == NULL) { endwin(); - fprintf(stderr, - "\nCan't allocate memory in dialog_textbox().\n"); + fprintf(stderr, "\nCan't allocate memory in dialog_textbox().\n"); exit(-1); } if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { @@ -150,23 +146,20 @@ int dialog_textbox(const char *title, const char *file, int height, int width) /* First page not in buffer? */ if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in dialog_textbox().\n"); + fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); exit(-1); } if (fpos > bytes_read) { /* Yes, we have to read it in */ if (lseek(fd, 0, SEEK_SET) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in " - "dialog_textbox().\n"); + fprintf(stderr, "\nError moving file pointer in " + "dialog_textbox().\n"); exit(-1); } if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { endwin(); - fprintf(stderr, - "\nError reading file in dialog_textbox().\n"); + fprintf(stderr, "\nError reading file in dialog_textbox().\n"); exit(-1); } buf[bytes_read] = '\0'; @@ -185,22 +178,19 @@ int dialog_textbox(const char *title, const char *file, int height, int width) /* Last page not in buffer? */ if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in dialog_textbox().\n"); + fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); exit(-1); } if (fpos < file_size) { /* Yes, we have to read it in */ if (lseek(fd, -BUF_SIZE, SEEK_END) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in dialog_textbox().\n"); + fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); exit(-1); } if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { endwin(); - fprintf(stderr, - "\nError reading file in dialog_textbox().\n"); + fprintf(stderr, "\nError reading file in dialog_textbox().\n"); exit(-1); } buf[bytes_read] = '\0'; @@ -342,9 +332,8 @@ static void back_lines(int n) if (page == buf) { if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in " - "back_lines().\n"); + fprintf(stderr, "\nError moving file pointer in " + "back_lines().\n"); exit(-1); } if (fpos > bytes_read) { /* Not beginning of file yet */ @@ -358,21 +347,16 @@ static void back_lines(int n) /* No, move less then */ if (lseek(fd, 0, SEEK_SET) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in " - "back_lines().\n"); + fprintf(stderr, "\nError moving file pointer in " + "back_lines().\n"); exit(-1); } page = buf + fpos - bytes_read; } else { /* Move backward BUF_SIZE/2 bytes */ - if (lseek - (fd, -(BUF_SIZE / 2 + bytes_read), - SEEK_CUR) - == -1) { + if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer " - "in back_lines().\n"); + fprintf(stderr, "\nError moving file pointer " + "in back_lines().\n"); exit(-1); } page = buf + BUF_SIZE / 2; @@ -380,8 +364,7 @@ static void back_lines(int n) if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { endwin(); - fprintf(stderr, - "\nError reading file in back_lines().\n"); + fprintf(stderr, "\nError reading file in back_lines().\n"); exit(-1); } buf[bytes_read] = '\0'; @@ -403,33 +386,25 @@ static void back_lines(int n) if (page == buf) { if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in back_lines().\n"); + fprintf(stderr, "\nError moving file pointer in back_lines().\n"); exit(-1); } if (fpos > bytes_read) { /* Really possible to move backward BUF_SIZE/2 bytes? */ if (fpos < BUF_SIZE / 2 + bytes_read) { /* No, move less then */ - if (lseek(fd, 0, SEEK_SET) == - -1) { + if (lseek(fd, 0, SEEK_SET) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer " - "in back_lines().\n"); + fprintf(stderr, "\nError moving file pointer " + "in back_lines().\n"); exit(-1); } page = buf + fpos - bytes_read; } else { /* Move backward BUF_SIZE/2 bytes */ - if (lseek - (fd, - -(BUF_SIZE / 2 + - bytes_read), - SEEK_CUR) == -1) { + if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer" - " in back_lines().\n"); + fprintf(stderr, "\nError moving file pointer" + " in back_lines().\n"); exit(-1); } page = buf + BUF_SIZE / 2; @@ -437,9 +412,8 @@ static void back_lines(int n) if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { endwin(); - fprintf(stderr, - "\nError reading file in " - "back_lines().\n"); + fprintf(stderr, "\nError reading file in " + "back_lines().\n"); exit(-1); } buf[bytes_read] = '\0'; @@ -513,9 +487,8 @@ static char *get_line(void) /* Either end of file or end of buffer reached */ if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in " - "get_line().\n"); + fprintf(stderr, "\nError moving file pointer in " + "get_line().\n"); exit(-1); } if (fpos < file_size) { /* Not end of file yet */ @@ -524,8 +497,7 @@ static char *get_line(void) if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { endwin(); - fprintf(stderr, - "\nError reading file in get_line().\n"); + fprintf(stderr, "\nError reading file in get_line().\n"); exit(-1); } buf[bytes_read] = '\0'; @@ -561,8 +533,7 @@ static void print_position(WINDOW * win, int height, int width) if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { endwin(); - fprintf(stderr, - "\nError moving file pointer in print_position().\n"); + fprintf(stderr, "\nError moving file pointer in print_position().\n"); exit(-1); } wattrset(win, position_indicator_attr); diff --git a/scripts/lxdialog/util.c b/scripts/lxdialog/util.c index 232b32c..1f84809 100644 --- a/scripts/lxdialog/util.c +++ b/scripts/lxdialog/util.c @@ -28,7 +28,7 @@ const char *backtitle = NULL; const char *dialog_result; -/* +/* * Attribute values, default is for mono display */ chtype attributes[] = { diff --git a/scripts/lxdialog/yesno.c b/scripts/lxdialog/yesno.c index dffd5af..84f3e8e 100644 --- a/scripts/lxdialog/yesno.c +++ b/scripts/lxdialog/yesno.c @@ -96,8 +96,7 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) case TAB: case KEY_LEFT: case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 1 : (button > 1 ? 0 : button); + button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); print_buttons(dialog, height, width, button); wrefresh(dialog); -- cgit v1.1 From a06104af7dcf2f5bafaf18f373c8b2554cbfe014 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 19 Nov 2005 22:17:55 +0100 Subject: kconfig: lxdialog is now sparse clean Replacing a gcc idiom with malloc and deleting an unused global variable made lxdialog sparse clean. Signed-off-by: Sam Ravnborg --- scripts/lxdialog/menubox.c | 5 +++-- scripts/lxdialog/util.c | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index 260cc4d..ff3a6179 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -67,7 +67,7 @@ static void print_item(WINDOW * win, const char *item, int choice, int selected, int hotkey) { int j; - char menu_item[menu_width + 1]; + char *menu_item = malloc(menu_width + 1); strncpy(menu_item, item, menu_width); menu_item[menu_width] = 0; @@ -95,6 +95,7 @@ static void print_item(WINDOW * win, const char *item, int choice, wmove(win, choice, item_x + 1); wrefresh(win); } + free(menu_item); } /* @@ -221,7 +222,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, /* * Find length of longest item in order to center menu. - * Set 'choice' to default item. + * Set 'choice' to default item. */ item_x = 0; for (i = 0; i < item_no; i++) { diff --git a/scripts/lxdialog/util.c b/scripts/lxdialog/util.c index 1f84809..ce41147 100644 --- a/scripts/lxdialog/util.c +++ b/scripts/lxdialog/util.c @@ -26,8 +26,6 @@ bool use_colors = 1; const char *backtitle = NULL; -const char *dialog_result; - /* * Attribute values, default is for mono display */ -- cgit v1.1 From fa7009d5b59b8acd8071f7b3057d36eeeaf08146 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 19 Nov 2005 23:38:06 +0100 Subject: kconfig: Add print_title helper in lxdialog Simplify check for long title and use a helper function in util.c Signed-off-by: Sam Ravnborg --- scripts/lxdialog/checklist.c | 15 +-------------- scripts/lxdialog/dialog.h | 1 + scripts/lxdialog/inputbox.c | 15 +-------------- scripts/lxdialog/menubox.c | 15 +-------------- scripts/lxdialog/msgbox.c | 14 +------------- scripts/lxdialog/textbox.c | 14 +------------- scripts/lxdialog/util.c | 14 ++++++++++++++ scripts/lxdialog/yesno.c | 15 +-------------- 8 files changed, 21 insertions(+), 82 deletions(-) diff --git a/scripts/lxdialog/checklist.c b/scripts/lxdialog/checklist.c index ae40a2b..3fb681f 100644 --- a/scripts/lxdialog/checklist.c +++ b/scripts/lxdialog/checklist.c @@ -158,20 +158,7 @@ int dialog_checklist(const char *title, const char *prompt, int height, wattrset(dialog, dialog_attr); waddch(dialog, ACS_RTEE); - if (title != NULL && strlen(title) >= width - 2) { - /* truncate long title -- mec */ - char *title2 = malloc(width - 2 + 1); - memcpy(title2, title, width - 2); - title2[width - 2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset(dialog, title_attr); - mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); - waddstr(dialog, (char *)title); - waddch(dialog, ' '); - } + print_title(dialog, title, width); wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, width - 2, 1, 3); diff --git a/scripts/lxdialog/dialog.h b/scripts/lxdialog/dialog.h index 3cf3d35..f882204 100644 --- a/scripts/lxdialog/dialog.h +++ b/scripts/lxdialog/dialog.h @@ -145,6 +145,7 @@ void dialog_clear(void); void color_setup(void); void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); void print_button(WINDOW * win, const char *label, int y, int x, int selected); +void print_title(WINDOW *dialog, const char *title, int width); void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, chtype border); void draw_shadow(WINDOW * win, int y, int x, int height, int width); diff --git a/scripts/lxdialog/inputbox.c b/scripts/lxdialog/inputbox.c index bc135c7..7795037 100644 --- a/scripts/lxdialog/inputbox.c +++ b/scripts/lxdialog/inputbox.c @@ -66,20 +66,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width wattrset(dialog, dialog_attr); waddch(dialog, ACS_RTEE); - if (title != NULL && strlen(title) >= width - 2) { - /* truncate long title -- mec */ - char *title2 = malloc(width - 2 + 1); - memcpy(title2, title, width - 2); - title2[width - 2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset(dialog, title_attr); - mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); - waddstr(dialog, (char *)title); - waddch(dialog, ' '); - } + print_title(dialog, title, width); wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, width - 2, 1, 3); diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index ff3a6179..ebfe6a3 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -189,20 +189,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, wbkgdset(dialog, dialog_attr & A_COLOR); waddch(dialog, ACS_RTEE); - if (title != NULL && strlen(title) >= width - 2) { - /* truncate long title -- mec */ - char *title2 = malloc(width - 2 + 1); - memcpy(title2, title, width - 2); - title2[width - 2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset(dialog, title_attr); - mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); - waddstr(dialog, (char *)title); - waddch(dialog, ' '); - } + print_title(dialog, title, width); wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, width - 2, 1, 3); diff --git a/scripts/lxdialog/msgbox.c b/scripts/lxdialog/msgbox.c index b394057..7323f54 100644 --- a/scripts/lxdialog/msgbox.c +++ b/scripts/lxdialog/msgbox.c @@ -42,20 +42,8 @@ int dialog_msgbox(const char *title, const char *prompt, int height, int width, draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - if (title != NULL && strlen(title) >= width - 2) { - /* truncate long title -- mec */ - char *title2 = malloc(width - 2 + 1); - memcpy(title2, title, width - 2); - title2[width - 2] = '\0'; - title = title2; - } + print_title(dialog, title, width); - if (title != NULL) { - wattrset(dialog, title_attr); - mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); - waddstr(dialog, (char *)title); - waddch(dialog, ' '); - } wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, width - 2, 1, 2); diff --git a/scripts/lxdialog/textbox.c b/scripts/lxdialog/textbox.c index fa8d92e..77848bb 100644 --- a/scripts/lxdialog/textbox.c +++ b/scripts/lxdialog/textbox.c @@ -103,20 +103,8 @@ int dialog_textbox(const char *title, const char *file, int height, int width) wbkgdset(dialog, dialog_attr & A_COLOR); waddch(dialog, ACS_RTEE); - if (title != NULL && strlen(title) >= width - 2) { - /* truncate long title -- mec */ - char *title2 = malloc(width - 2 + 1); - memcpy(title2, title, width - 2); - title2[width - 2] = '\0'; - title = title2; - } + print_title(dialog, title, width); - if (title != NULL) { - wattrset(dialog, title_attr); - mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); - waddstr(dialog, (char *)title); - waddch(dialog, ' '); - } print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE); wnoutrefresh(dialog); getyx(dialog, cur_y, cur_x); /* Save cursor position */ diff --git a/scripts/lxdialog/util.c b/scripts/lxdialog/util.c index ce41147..f82cebb 100644 --- a/scripts/lxdialog/util.c +++ b/scripts/lxdialog/util.c @@ -177,6 +177,20 @@ void end_dialog(void) endwin(); } +/* Print the title of the dialog. Center the title and truncate + * tile if wider than dialog (- 2 chars). + **/ +void print_title(WINDOW *dialog, const char *title, int width) +{ + if (title) { + int tlen = MIN(width - 2, strlen(title)); + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); + mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); + waddch(dialog, ' '); + } +} + /* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline diff --git a/scripts/lxdialog/yesno.c b/scripts/lxdialog/yesno.c index 84f3e8e..cb2568a 100644 --- a/scripts/lxdialog/yesno.c +++ b/scripts/lxdialog/yesno.c @@ -61,20 +61,7 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width) wattrset(dialog, dialog_attr); waddch(dialog, ACS_RTEE); - if (title != NULL && strlen(title) >= width - 2) { - /* truncate long title -- mec */ - char *title2 = malloc(width - 2 + 1); - memcpy(title2, title, width - 2); - title2[width - 2] = '\0'; - title = title2; - } - - if (title != NULL) { - wattrset(dialog, title_attr); - mvwaddch(dialog, 0, (width - strlen(title)) / 2 - 1, ' '); - waddstr(dialog, (char *)title); - waddch(dialog, ' '); - } + print_title(dialog, title, width); wattrset(dialog, dialog_attr); print_autowrap(dialog, prompt, width - 2, 1, 3); -- cgit v1.1 From e27d3014f301e6aee7b65b62ad1da2940e1fd8de Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sat, 19 Nov 2005 21:23:48 -0500 Subject: Every file should #include the headers containing the prototypes for it's global functions. Signed-off-by: Adrian Bunk Signed-off-by: Jody McIntyre --- drivers/ieee1394/ieee1394_transactions.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/ieee1394/ieee1394_transactions.c b/drivers/ieee1394/ieee1394_transactions.c index 0aa8763..81b983c 100644 --- a/drivers/ieee1394/ieee1394_transactions.c +++ b/drivers/ieee1394/ieee1394_transactions.c @@ -22,6 +22,7 @@ #include "ieee1394_core.h" #include "highlevel.h" #include "nodemgr.h" +#include "ieee1394_transactions.h" #define PREP_ASYNC_HEAD_ADDRESS(tc) \ -- cgit v1.1 From e4cda1654e5c0be4b68e29011e8dc04977286df9 Mon Sep 17 00:00:00 2001 From: Damien Douxchamps Date: Sat, 19 Nov 2005 21:32:03 -0500 Subject: Fix incorrect video1394 timestamps. This patch fixes the incoherent timestamps generated by video1394 since the single-buffer patch was applied in 2.6.11. Credits have also been removed from the header and a "//" comment was changed to "/* */". Signed-off-by: Damien Douxchamps Signed-off-by: Jody McIntyre --- drivers/ieee1394/video1394.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 07050f0..608479b 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c @@ -19,12 +19,6 @@ * * NOTES: * - * jds -- add private data to file to keep track of iso contexts associated - * with each open -- so release won't kill all iso transfers. - * - * Damien Douxchamps: Fix failure when the number of DMA pages per frame is - * one. - * * ioctl return codes: * EFAULT is only for invalid address for the argp * EINVAL for out of range values @@ -34,12 +28,6 @@ * ENOTTY for unsupported ioctl request * */ - -/* Markus Tavenrath : - - fixed checks for valid buffer-numbers in video1394_icotl - - changed the ways the dma prg's are used, now it's possible to use - even a single dma buffer -*/ #include #include #include @@ -503,7 +491,7 @@ static void wakeup_dma_ir_ctx(unsigned long l) if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) { reset_ir_status(d, i); d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY; - do_gettimeofday(&d->buffer_time[i]); + do_gettimeofday(&d->buffer_time[d->buffer_prg_assignment[i]]); } } @@ -1010,7 +998,6 @@ static int __video1394_ioctl(struct file *file, /* set time of buffer */ v.filltime = d->buffer_time[v.buffer]; -// printk("Buffer %d time %d\n", v.buffer, (d->buffer_time[v.buffer]).tv_usec); /* * Look ahead to see how many more buffers have been received @@ -1068,7 +1055,7 @@ static int __video1394_ioctl(struct file *file, spin_lock_irqsave(&d->lock,flags); - // last_buffer is last_prg + /* last_buffer is last_prg */ next_prg = (d->last_buffer + 1) % d->num_desc; if (d->buffer_status[v.buffer]!=VIDEO1394_BUFFER_FREE) { PRINT(KERN_ERR, ohci->host->id, -- cgit v1.1 From 977545e35289b13981614a57fd6c9b82d55e3b4a Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Sat, 19 Nov 2005 21:35:22 -0500 Subject: sbp2: slimmer interface to scsi_mod - sbp2scsi_reset does not need to take host_lock - sbp2scsi_reset, as our device reset handler, does not need to stand in as bus reset or host reset handler - let scsi_mod use scsi_host_template.name instead of .info (sbp2 is not an emulation anway) Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/sbp2.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 84875cd..f0763b7 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -2609,27 +2609,17 @@ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt) { struct scsi_id_instance_data *scsi_id = (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0]; - unsigned long flags; SBP2_ERR("reset requested"); - spin_lock_irqsave(SCpnt->device->host->host_lock, flags); - if (sbp2util_node_is_available(scsi_id)) { SBP2_ERR("Generating sbp2 fetch agent reset"); sbp2_agent_reset(scsi_id, 0); } - spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags); - return SUCCESS; } -static const char *sbp2scsi_info(struct Scsi_Host *host) -{ - return "SCSI emulation for IEEE-1394 SBP-2 Devices"; -} - static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -2666,12 +2656,9 @@ static struct scsi_host_template scsi_driver_template = { .module = THIS_MODULE, .name = "SBP-2 IEEE-1394", .proc_name = SBP2_DEVICE_NAME, - .info = sbp2scsi_info, .queuecommand = sbp2scsi_queuecommand, .eh_abort_handler = sbp2scsi_abort, .eh_device_reset_handler = sbp2scsi_reset, - .eh_bus_reset_handler = sbp2scsi_reset, - .eh_host_reset_handler = sbp2scsi_reset, .slave_alloc = sbp2scsi_slave_alloc, .slave_configure = sbp2scsi_slave_configure, .slave_destroy = sbp2scsi_slave_destroy, -- cgit v1.1 From 656563e32c3f1dfdc35b3944305ece1c5dfeade5 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sun, 20 Nov 2005 03:36:45 -0500 Subject: [libata] Print out SATA speed, if link is up Make the SATA phy probe messages a bit more informative. Note this only applies to drivers that use __sata_phy_reset(), which excludes some drivers. --- drivers/scsi/libata-core.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 665ae79..9f27e8d 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1444,11 +1444,23 @@ void __sata_phy_reset(struct ata_port *ap) } while (time_before(jiffies, timeout)); /* TODO: phy layer with polling, timeouts, etc. */ - if (sata_dev_present(ap)) + sstatus = scr_read(ap, SCR_STATUS); + if (sata_dev_present(ap)) { + const char *speed; + u32 tmp; + + tmp = (sstatus >> 4) & 0xf; + if (tmp & (1 << 0)) + speed = "1.5"; + else if (tmp & (1 << 1)) + speed = "3.0"; + else + speed = ""; + printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n", + ap->id, speed, sstatus); ata_port_probe(ap); - else { - sstatus = scr_read(ap, SCR_STATUS); - printk(KERN_INFO "ata%u: no device found (phy stat %08x)\n", + } else { + printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n", ap->id, sstatus); ata_port_disable(ap); } -- cgit v1.1 From 0e175d05a4e72f85918da3ea4bd9f5d3d78face4 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 20 Nov 2005 22:41:21 +0100 Subject: kconfig: Left aling menu items in menuconfig Keeping menu lines on a fixed position creates less visual noise when navigating the menus. Signed-off-by: Sam Ravnborg --- scripts/lxdialog/menubox.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index ebfe6a3..89fcf41 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -58,7 +58,8 @@ #include "dialog.h" -static int menu_width, item_x; +#define ITEM_IDENT 4 /* Indent of menu entries. Fixed for all menus */ +static int menu_width; /* * Print menu item @@ -86,13 +87,13 @@ static void print_item(WINDOW * win, const char *item, int choice, wclrtoeol(win); #endif wattrset(win, selected ? item_selected_attr : item_attr); - mvwaddstr(win, choice, item_x, menu_item); + mvwaddstr(win, choice, ITEM_IDENT, menu_item); if (hotkey) { wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); - mvwaddch(win, choice, item_x + j, menu_item[j]); + mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]); } if (selected) { - wmove(win, choice, item_x + 1); + wmove(win, choice, ITEM_IDENT + 1); wrefresh(win); } free(menu_item); @@ -207,19 +208,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, menubox_border_attr, menubox_attr); - /* - * Find length of longest item in order to center menu. - * Set 'choice' to default item. - */ - item_x = 0; - for (i = 0; i < item_no; i++) { - item_x = - MAX(item_x, MIN(menu_width, strlen(items[i * 2 + 1]) + 2)); + /* Set choice to default item */ + for (i = 0; i < item_no; i++) if (strcmp(current, items[i * 2]) == 0) choice = i; - } - - item_x = (menu_width - item_x) / 2; /* get the scroll info from the temp file */ if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) { @@ -254,10 +246,10 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, wnoutrefresh(menu); print_arrows(dialog, item_no, scroll, - box_y, box_x + item_x + 1, menu_height); + box_y, box_x + ITEM_IDENT + 1, menu_height); print_buttons(dialog, height, width, 0); - wmove(menu, choice, item_x + 1); + wmove(menu, choice, ITEM_IDENT + 1); wrefresh(menu); while (key != ESC) { @@ -286,7 +278,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, key == KEY_UP || key == KEY_DOWN || key == '-' || key == '+' || key == KEY_PPAGE || key == KEY_NPAGE) { - + /* Remove highligt of current item */ print_item(menu, items[(scroll + choice) * 2 + 1], choice, FALSE, (items[(scroll + choice) * 2][0] != ':')); @@ -364,7 +356,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, choice, TRUE, (items[(scroll + choice) * 2][0] != ':')); print_arrows(dialog, item_no, scroll, - box_y, box_x + item_x + 1, menu_height); + box_y, box_x + ITEM_IDENT + 1, menu_height); wnoutrefresh(dialog); wrefresh(menu); -- cgit v1.1 From 7c3badf96e0dc8aa89ebf8919653339a5ee8e035 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 20 Nov 2005 23:03:49 +0100 Subject: kconfig: Fix indention when using menuconfig in text-onle consoles When using menuconfig in a text-only console (no X started) the indention was often two spaces wrong. This proved to be a ncurses issue which are worked around by calling wrefresh more often. Signed-off-by: Sam Ravnborg --- scripts/lxdialog/menubox.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index 89fcf41..461ee08 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -94,9 +94,9 @@ static void print_item(WINDOW * win, const char *item, int choice, } if (selected) { wmove(win, choice, ITEM_IDENT + 1); - wrefresh(win); } free(menu_item); + wrefresh(win); } /* @@ -125,6 +125,7 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, y = y + height + 1; wmove(win, y, x); + wrefresh(win); if ((height < item_no) && (scroll + height < item_no)) { wattrset(win, darrow_attr); @@ -139,6 +140,7 @@ static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, } wmove(win, cur_y, cur_x); + wrefresh(win); } /* @@ -157,6 +159,17 @@ static void print_buttons(WINDOW * win, int height, int width, int selected) wrefresh(win); } +/* scroll up n lines (n may be negative) */ +static void do_scroll(WINDOW *win, int *scroll, int n) +{ + /* Scroll menu up */ + scrollok(win, TRUE); + wscrl(win, n); + scrollok(win, FALSE); + *scroll = *scroll + n; + wrefresh(win); +} + /* * Display a menu for choosing among a number of options */ @@ -286,11 +299,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, if (key == KEY_UP || key == '-') { if (choice < 2 && scroll) { /* Scroll menu down */ - scrollok(menu, TRUE); - wscrl(menu, -1); - scrollok(menu, FALSE); - - scroll--; + do_scroll(menu, &scroll, -1); print_item(menu, items[scroll * 2 + 1], 0, FALSE, (items[scroll * 2][0] != ':')); @@ -306,11 +315,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, if ((choice > max_choice - 3) && (scroll + max_choice < item_no)) { /* Scroll menu up */ - scrollok(menu, TRUE); - wscrl(menu, 1); - scrollok(menu, FALSE); - - scroll++; + do_scroll(menu, &scroll, 1); print_item(menu, items[(scroll + max_choice - 1) * 2 + 1], max_choice - 1, FALSE, @@ -322,8 +327,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, scrollok(menu, TRUE); for (i = 0; (i < max_choice); i++) { if (scroll > 0) { - wscrl(menu, -1); - scroll--; + do_scroll(menu, &scroll, -1); print_item(menu, items[scroll * 2 + 1], 0, FALSE, (items[scroll * 2][0] != ':')); } else { @@ -331,15 +335,11 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, choice--; } } - scrollok(menu, FALSE); } else if (key == KEY_NPAGE) { for (i = 0; (i < max_choice); i++) { if (scroll + max_choice < item_no) { - scrollok(menu, TRUE); - wscrl(menu, 1); - scrollok(menu, FALSE); - scroll++; + do_scroll(menu, &scroll, 1); print_item(menu, items[(scroll + max_choice - 1) * 2 + 1], max_choice - 1, FALSE, (items [(scroll + max_choice - 1) * 2][0] != ':')); @@ -348,7 +348,6 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, choice++; } } - } else choice = i; -- cgit v1.1 From 59d3cf7a40dfdbb8e86758ade172831c19630050 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 20 Nov 2005 23:34:35 +0100 Subject: kconfig: make lxdialog/menubox.c more readable Utilising a small macro for print_item made wonders for readability for this file. Signed-off-by: Sam Ravnborg --- scripts/lxdialog/menubox.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index 461ee08..d0bf32b 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -64,8 +64,8 @@ static int menu_width; /* * Print menu item */ -static void print_item(WINDOW * win, const char *item, int choice, - int selected, int hotkey) +static void do_print_item(WINDOW * win, const char *item, int choice, + int selected, int hotkey) { int j; char *menu_item = malloc(menu_width + 1); @@ -99,6 +99,12 @@ static void print_item(WINDOW * win, const char *item, int choice, wrefresh(win); } +#define print_item(index, choice, selected) \ +do {\ + int hotkey = (items[(index) * 2][0] != ':'); \ + do_print_item(menu, items[(index) * 2 + 1], choice, selected, hotkey); \ +} while (0) + /* * Print the scroll indicators. */ @@ -251,9 +257,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, /* Print the menu */ for (i = 0; i < max_choice; i++) { - print_item(menu, items[(first_item + i) * 2 + 1], i, - i == choice, - (items[(first_item + i) * 2][0] != ':')); + print_item(first_item + i, i, i == choice); } wnoutrefresh(menu); @@ -292,34 +296,27 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, key == '-' || key == '+' || key == KEY_PPAGE || key == KEY_NPAGE) { /* Remove highligt of current item */ - print_item(menu, items[(scroll + choice) * 2 + 1], - choice, FALSE, - (items[(scroll + choice) * 2][0] != ':')); + print_item(scroll + choice, choice, FALSE); if (key == KEY_UP || key == '-') { if (choice < 2 && scroll) { /* Scroll menu down */ do_scroll(menu, &scroll, -1); - print_item(menu, items[scroll * 2 + 1], 0, FALSE, - (items[scroll * 2][0] != ':')); + print_item(scroll, 0, FALSE); } else choice = MAX(choice - 1, 0); } else if (key == KEY_DOWN || key == '+') { - - print_item(menu, - items[(scroll + choice) * 2 + 1], choice, FALSE, - (items[(scroll + choice) * 2][0] != ':')); + print_item(scroll+choice, choice, FALSE); if ((choice > max_choice - 3) && (scroll + max_choice < item_no)) { /* Scroll menu up */ do_scroll(menu, &scroll, 1); - print_item(menu, items[(scroll + max_choice - 1) * 2 + 1], - max_choice - 1, FALSE, - (items [(scroll + max_choice - 1) * 2][0] != ':')); + print_item(scroll+max_choice - 1, + max_choice - 1, FALSE); } else choice = MIN(choice + 1, max_choice - 1); @@ -328,8 +325,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, for (i = 0; (i < max_choice); i++) { if (scroll > 0) { do_scroll(menu, &scroll, -1); - print_item(menu, items[scroll * 2 + 1], 0, FALSE, - (items[scroll * 2][0] != ':')); + print_item(scroll, 0, FALSE); } else { if (choice > 0) choice--; @@ -340,9 +336,8 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, for (i = 0; (i < max_choice); i++) { if (scroll + max_choice < item_no) { do_scroll(menu, &scroll, 1); - print_item(menu, items[(scroll + max_choice - 1) * 2 + 1], - max_choice - 1, FALSE, - (items [(scroll + max_choice - 1) * 2][0] != ':')); + print_item(scroll+max_choice-1, + max_choice - 1, FALSE); } else { if (choice + 1 < max_choice) choice++; @@ -351,8 +346,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, } else choice = i; - print_item(menu, items[(scroll + choice) * 2 + 1], - choice, TRUE, (items[(scroll + choice) * 2][0] != ':')); + print_item(scroll + choice, choice, TRUE); print_arrows(dialog, item_no, scroll, box_y, box_x + ITEM_IDENT + 1, menu_height); -- cgit v1.1 From 8aae8284fece2b8fc404ccd40b7a30aa96f317b5 Mon Sep 17 00:00:00 2001 From: Jacob Shin Date: Mon, 21 Nov 2005 07:23:08 -0800 Subject: [CPUFREQ] Improve Error reporting in powernow-k8 This patch cleans up some error messages in the powernow-k8 driver and makes them more understandable. Signed-off-by: Jacob Shin Signed-off-by: Mark Langsdorf Signed-off-by: Dave Jones --- arch/i386/kernel/cpu/cpufreq/powernow-k8.c | 31 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c index 68a1fc8..3497827 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c @@ -45,7 +45,7 @@ #define PFX "powernow-k8: " #define BFX PFX "BIOS error: " -#define VERSION "version 1.50.4" +#define VERSION "version 1.50.5" #include "powernow-k8.h" /* serialize freq changes */ @@ -464,7 +464,7 @@ static int check_supported_cpu(unsigned int cpu) set_cpus_allowed(current, cpumask_of_cpu(cpu)); if (smp_processor_id() != cpu) { - printk(KERN_ERR "limiting to cpu %u failed\n", cpu); + printk(KERN_ERR PFX "limiting to cpu %u failed\n", cpu); goto out; } @@ -517,22 +517,28 @@ static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 printk(KERN_ERR BFX "maxvid exceeded with pstate %d\n", j); return -ENODEV; } - if ((pst[j].fid > MAX_FID) - || (pst[j].fid & 1) - || (j && (pst[j].fid < HI_FID_TABLE_BOTTOM))) { + if (pst[j].fid > MAX_FID) { + printk(KERN_ERR BFX "maxfid exceeded with pstate %d\n", j); + return -ENODEV; + } + if (pst[j].fid & 1) { + printk(KERN_ERR BFX "fid invalid - %d : 0x%x\n", j, pst[j].fid); + return -EINVAL; + } + if (j && (pst[j].fid < HI_FID_TABLE_BOTTOM)) { /* Only first fid is allowed to be in "low" range */ - printk(KERN_ERR PFX "two low fids - %d : 0x%x\n", j, pst[j].fid); + printk(KERN_ERR BFX "two low fids - %d : 0x%x\n", j, pst[j].fid); return -EINVAL; } if (pst[j].fid < lastfid) lastfid = pst[j].fid; } if (lastfid & 1) { - printk(KERN_ERR PFX "lastfid invalid\n"); + printk(KERN_ERR BFX "lastfid invalid\n"); return -EINVAL; } if (lastfid > LO_FID_TABLE_TOP) - printk(KERN_INFO PFX "first fid not from lo freq table\n"); + printk(KERN_INFO BFX "first fid not from lo freq table\n"); return 0; } @@ -912,7 +918,7 @@ static int powernowk8_target(struct cpufreq_policy *pol, unsigned targfreq, unsi set_cpus_allowed(current, cpumask_of_cpu(pol->cpu)); if (smp_processor_id() != pol->cpu) { - printk(KERN_ERR "limiting to cpu %u failed\n", pol->cpu); + printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); goto err_out; } @@ -982,6 +988,9 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol) cpumask_t oldmask = CPU_MASK_ALL; int rc, i; + if (!cpu_online(pol->cpu)) + return -ENODEV; + if (!check_supported_cpu(pol->cpu)) return -ENODEV; @@ -1021,7 +1030,7 @@ static int __init powernowk8_cpu_init(struct cpufreq_policy *pol) set_cpus_allowed(current, cpumask_of_cpu(pol->cpu)); if (smp_processor_id() != pol->cpu) { - printk(KERN_ERR "limiting to cpu %u failed\n", pol->cpu); + printk(KERN_ERR PFX "limiting to cpu %u failed\n", pol->cpu); goto err_out; } @@ -1162,7 +1171,7 @@ static void __exit powernowk8_exit(void) cpufreq_unregister_driver(&cpufreq_amd64_driver); } -MODULE_AUTHOR("Paul Devriendt and Mark Langsdorf and Mark Langsdorf "); MODULE_DESCRIPTION("AMD Athlon 64 and Opteron processor frequency driver."); MODULE_LICENSE("GPL"); -- cgit v1.1 From e067e1f98d54d62fd598126f95e7684e5b63e67f Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 21 Nov 2005 22:59:32 +0100 Subject: kconfig: truncate too long menu lines in menuconfig menu lines wrapped over too lines when too long - truncate them. Also fixed a coding style issue Signed-off-by: Sam Ravnborg --- scripts/lxdialog/menubox.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c index d0bf32b..2d91880 100644 --- a/scripts/lxdialog/menubox.c +++ b/scripts/lxdialog/menubox.c @@ -70,7 +70,7 @@ static void do_print_item(WINDOW * win, const char *item, int choice, int j; char *menu_item = malloc(menu_width + 1); - strncpy(menu_item, item, menu_width); + strncpy(menu_item, item, menu_width - ITEM_IDENT); menu_item[menu_width] = 0; j = first_alpha(menu_item, "YyNnMmHh"); @@ -184,8 +184,8 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, const char *const *items) { int i, j, x, y, box_x, box_y; - int key = 0, button = 0, scroll = 0, choice = 0, first_item = - 0, max_choice; + int key = 0, button = 0, scroll = 0, choice = 0; + int first_item = 0, max_choice; WINDOW *dialog, *menu; FILE *f; -- cgit v1.1 From d734f92b0dc4c04daa2e0106354972cbbc2e0fbe Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 21 Nov 2005 17:32:14 -0500 Subject: drivers/ieee1394/raw1394.c: fix a NULL pointer The coverity checker spotted that this was a NULL pointer dereference in the "if (copy_from_user(...))" case since the next step is to kfree(cache->filled_head). There's no need to free cache at this point, and it's getting free'd later. Signed-off-by: Adrian Bunk Signed-off-by: Jody McIntyre --- drivers/ieee1394/raw1394.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 0278dc5d..99b2ce1 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -2131,7 +2131,6 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req) req->req.length)) { csr1212_release_keyval(fi->csr1212_dirs[dr]); fi->csr1212_dirs[dr] = NULL; - CSR1212_FREE(cache); ret = -EFAULT; } else { cache->len = req->req.length; -- cgit v1.1 From b12479ddce4aed112e0018fdf8bbb7cfb349ebdc Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 21 Nov 2005 17:32:18 -0500 Subject: raw1394: fix memory deallocation in modify_config_rom raw1394: use correct deallocation macro for CSR cache Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/raw1394.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 99b2ce1..89cac1f 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -2166,7 +2166,7 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req) } } kfree(cache->filled_head); - kfree(cache); + CSR1212_FREE(cache); if (ret >= 0) { /* we have to free the request, because we queue no response, -- cgit v1.1 From 5303a986c33ae6c75d5ffb57d06ccf9246a8725a Mon Sep 17 00:00:00 2001 From: Jody McIntyre Date: Tue, 22 Nov 2005 12:17:11 -0500 Subject: csr1212: check results of keyval reads csr1212_parse_csr() did not properly check return values when reading keyvals. Fix this by using _csr1212_read_keyval() instead of csr1212_get_keyval() and checking the return code. Signed-off-by: Jody McIntyre --- drivers/ieee1394/csr1212.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c index c0f8ed6..4812d59 100644 --- a/drivers/ieee1394/csr1212.c +++ b/drivers/ieee1394/csr1212.c @@ -1610,15 +1610,16 @@ int csr1212_parse_csr(struct csr1212_csr *csr) csr->root_kv->valid = 0; csr->root_kv->next = csr->root_kv; csr->root_kv->prev = csr->root_kv; - csr1212_get_keyval(csr, csr->root_kv); + ret = _csr1212_read_keyval(csr, csr->root_kv); + if (ret != CSR1212_SUCCESS) + return ret; /* Scan through the Root directory finding all extended ROM regions * and make cache regions for them */ for (dentry = csr->root_kv->value.directory.dentries_head; dentry; dentry = dentry->next) { if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) { - csr1212_get_keyval(csr, dentry->kv); - + ret = _csr1212_read_keyval(csr, dentry->kv); if (ret != CSR1212_SUCCESS) return ret; } -- cgit v1.1 From a96074e76f87a4f658af4ecfd95edc89cfd61fc1 Mon Sep 17 00:00:00 2001 From: Jody McIntyre Date: Tue, 22 Nov 2005 12:17:14 -0500 Subject: csr1212: add check for !valid Don't read the keyval if there's already a valid one in place. May not be necessary but shouldn't hurt. Signed-off-by: Jody McIntyre --- drivers/ieee1394/csr1212.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c index 4812d59..1577354 100644 --- a/drivers/ieee1394/csr1212.c +++ b/drivers/ieee1394/csr1212.c @@ -1618,7 +1618,8 @@ int csr1212_parse_csr(struct csr1212_csr *csr) * and make cache regions for them */ for (dentry = csr->root_kv->value.directory.dentries_head; dentry; dentry = dentry->next) { - if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) { + if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM && + !dentry->kv->valid) { ret = _csr1212_read_keyval(csr, dentry->kv); if (ret != CSR1212_SUCCESS) return ret; -- cgit v1.1 From 6649e92d792efa00a823781bcee2dba7f21199ba Mon Sep 17 00:00:00 2001 From: Jens-Michael Hoffmann Date: Tue, 22 Nov 2005 12:18:28 -0500 Subject: ieee1394/dma: LIndent fixes This patch contains fixes by LIndent. Signed-off-by: Jens-Michael Hoffmann Signed-off-by: Jody McIntyre --- drivers/ieee1394/dma.c | 73 +++++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c index b79ddb4..9fb2769 100644 --- a/drivers/ieee1394/dma.c +++ b/drivers/ieee1394/dma.c @@ -23,7 +23,8 @@ void dma_prog_region_init(struct dma_prog_region *prog) prog->bus_addr = 0; } -int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes, struct pci_dev *dev) +int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes, + struct pci_dev *dev) { /* round up to page size */ n_bytes = PAGE_ALIGN(n_bytes); @@ -32,7 +33,8 @@ int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes, prog->kvirt = pci_alloc_consistent(dev, n_bytes, &prog->bus_addr); if (!prog->kvirt) { - printk(KERN_ERR "dma_prog_region_alloc: pci_alloc_consistent() failed\n"); + printk(KERN_ERR + "dma_prog_region_alloc: pci_alloc_consistent() failed\n"); dma_prog_region_free(prog); return -ENOMEM; } @@ -45,7 +47,8 @@ int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes, void dma_prog_region_free(struct dma_prog_region *prog) { if (prog->kvirt) { - pci_free_consistent(prog->dev, prog->n_pages << PAGE_SHIFT, prog->kvirt, prog->bus_addr); + pci_free_consistent(prog->dev, prog->n_pages << PAGE_SHIFT, + prog->kvirt, prog->bus_addr); } prog->kvirt = NULL; @@ -65,7 +68,8 @@ void dma_region_init(struct dma_region *dma) dma->sglist = NULL; } -int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_dev *dev, int direction) +int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, + struct pci_dev *dev, int direction) { unsigned int i; @@ -95,14 +99,16 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d /* fill scatter/gather list with pages */ for (i = 0; i < dma->n_pages; i++) { - unsigned long va = (unsigned long) dma->kvirt + (i << PAGE_SHIFT); + unsigned long va = + (unsigned long)dma->kvirt + (i << PAGE_SHIFT); dma->sglist[i].page = vmalloc_to_page((void *)va); dma->sglist[i].length = PAGE_SIZE; } /* map sglist to the IOMMU */ - dma->n_dma_pages = pci_map_sg(dev, dma->sglist, dma->n_pages, direction); + dma->n_dma_pages = + pci_map_sg(dev, dma->sglist, dma->n_pages, direction); if (dma->n_dma_pages == 0) { printk(KERN_ERR "dma_region_alloc: pci_map_sg() failed\n"); @@ -114,7 +120,7 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d return 0; -err: + err: dma_region_free(dma); return -ENOMEM; } @@ -122,7 +128,8 @@ err: void dma_region_free(struct dma_region *dma) { if (dma->n_dma_pages) { - pci_unmap_sg(dma->dev, dma->sglist, dma->n_pages, dma->direction); + pci_unmap_sg(dma->dev, dma->sglist, dma->n_pages, + dma->direction); dma->n_dma_pages = 0; dma->dev = NULL; } @@ -137,7 +144,8 @@ void dma_region_free(struct dma_region *dma) /* find the scatterlist index and remaining offset corresponding to a given offset from the beginning of the buffer */ -static inline int dma_region_find(struct dma_region *dma, unsigned long offset, unsigned long *rem) +static inline int dma_region_find(struct dma_region *dma, unsigned long offset, + unsigned long *rem) { int i; unsigned long off = offset; @@ -156,15 +164,18 @@ static inline int dma_region_find(struct dma_region *dma, unsigned long offset, return i; } -dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset) +dma_addr_t dma_region_offset_to_bus(struct dma_region * dma, + unsigned long offset) { unsigned long rem = 0; - struct scatterlist *sg = &dma->sglist[dma_region_find(dma, offset, &rem)]; + struct scatterlist *sg = + &dma->sglist[dma_region_find(dma, offset, &rem)]; return sg_dma_address(sg) + rem; } -void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset, unsigned long len) +void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset, + unsigned long len) { int first, last; unsigned long rem; @@ -175,10 +186,12 @@ void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset, unsig first = dma_region_find(dma, offset, &rem); last = dma_region_find(dma, offset + len - 1, &rem); - pci_dma_sync_sg_for_cpu(dma->dev, &dma->sglist[first], last - first + 1, dma->direction); + pci_dma_sync_sg_for_cpu(dma->dev, &dma->sglist[first], last - first + 1, + dma->direction); } -void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, unsigned long len) +void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, + unsigned long len) { int first, last; unsigned long rem; @@ -189,44 +202,47 @@ void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, un first = dma_region_find(dma, offset, &rem); last = dma_region_find(dma, offset + len - 1, &rem); - pci_dma_sync_sg_for_device(dma->dev, &dma->sglist[first], last - first + 1, dma->direction); + pci_dma_sync_sg_for_device(dma->dev, &dma->sglist[first], + last - first + 1, dma->direction); } #ifdef CONFIG_MMU /* nopage() handler for mmap access */ -static struct page* -dma_region_pagefault(struct vm_area_struct *area, unsigned long address, int *type) +static struct page *dma_region_pagefault(struct vm_area_struct *area, + unsigned long address, int *type) { unsigned long offset; unsigned long kernel_virt_addr; struct page *ret = NOPAGE_SIGBUS; - struct dma_region *dma = (struct dma_region*) area->vm_private_data; + struct dma_region *dma = (struct dma_region *)area->vm_private_data; if (!dma->kvirt) goto out; - if ( (address < (unsigned long) area->vm_start) || - (address > (unsigned long) area->vm_start + (dma->n_pages << PAGE_SHIFT)) ) + if ((address < (unsigned long)area->vm_start) || + (address > + (unsigned long)area->vm_start + (dma->n_pages << PAGE_SHIFT))) goto out; if (type) *type = VM_FAULT_MINOR; offset = address - area->vm_start; - kernel_virt_addr = (unsigned long) dma->kvirt + offset; - ret = vmalloc_to_page((void*) kernel_virt_addr); + kernel_virt_addr = (unsigned long)dma->kvirt + offset; + ret = vmalloc_to_page((void *)kernel_virt_addr); get_page(ret); -out: + out: return ret; } static struct vm_operations_struct dma_region_vm_ops = { - .nopage = dma_region_pagefault, + .nopage = dma_region_pagefault, }; -int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_struct *vma) +int dma_region_mmap(struct dma_region *dma, struct file *file, + struct vm_area_struct *vma) { unsigned long size; @@ -250,11 +266,12 @@ int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_st return 0; } -#else /* CONFIG_MMU */ +#else /* CONFIG_MMU */ -int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_struct *vma) +int dma_region_mmap(struct dma_region *dma, struct file *file, + struct vm_area_struct *vma) { return -EINVAL; } -#endif /* CONFIG_MMU */ +#endif /* CONFIG_MMU */ -- cgit v1.1 From 16c333a34a1a0441c54c4fe5cf6052716f95c2fa Mon Sep 17 00:00:00 2001 From: Jens-Michael Hoffmann Date: Tue, 22 Nov 2005 12:34:16 -0500 Subject: ieee1394/ieee1394_transactions: LIndent fixes This patch contains fixes by LIndent. Signed-off-by: Jens-Michael Hoffmann Signed-off-by: Jody McIntyre --- drivers/ieee1394/ieee1394_transactions.c | 388 ++++++++++++++++--------------- 1 file changed, 195 insertions(+), 193 deletions(-) diff --git a/drivers/ieee1394/ieee1394_transactions.c b/drivers/ieee1394/ieee1394_transactions.c index 81b983c..3fe2f6c 100644 --- a/drivers/ieee1394/ieee1394_transactions.c +++ b/drivers/ieee1394/ieee1394_transactions.c @@ -24,7 +24,6 @@ #include "nodemgr.h" #include "ieee1394_transactions.h" - #define PREP_ASYNC_HEAD_ADDRESS(tc) \ packet->tcode = tc; \ packet->header[0] = (packet->node_id << 16) | (packet->tlabel << 10) \ @@ -32,80 +31,82 @@ packet->header[1] = (packet->host->node_id << 16) | (addr >> 32); \ packet->header[2] = addr & 0xffffffff - static void fill_async_readquad(struct hpsb_packet *packet, u64 addr) { - PREP_ASYNC_HEAD_ADDRESS(TCODE_READQ); - packet->header_size = 12; - packet->data_size = 0; - packet->expect_response = 1; + PREP_ASYNC_HEAD_ADDRESS(TCODE_READQ); + packet->header_size = 12; + packet->data_size = 0; + packet->expect_response = 1; } -static void fill_async_readblock(struct hpsb_packet *packet, u64 addr, int length) +static void fill_async_readblock(struct hpsb_packet *packet, u64 addr, + int length) { - PREP_ASYNC_HEAD_ADDRESS(TCODE_READB); - packet->header[3] = length << 16; - packet->header_size = 16; - packet->data_size = 0; - packet->expect_response = 1; + PREP_ASYNC_HEAD_ADDRESS(TCODE_READB); + packet->header[3] = length << 16; + packet->header_size = 16; + packet->data_size = 0; + packet->expect_response = 1; } -static void fill_async_writequad(struct hpsb_packet *packet, u64 addr, quadlet_t data) +static void fill_async_writequad(struct hpsb_packet *packet, u64 addr, + quadlet_t data) { - PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEQ); - packet->header[3] = data; - packet->header_size = 16; - packet->data_size = 0; - packet->expect_response = 1; + PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEQ); + packet->header[3] = data; + packet->header_size = 16; + packet->data_size = 0; + packet->expect_response = 1; } -static void fill_async_writeblock(struct hpsb_packet *packet, u64 addr, int length) +static void fill_async_writeblock(struct hpsb_packet *packet, u64 addr, + int length) { - PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEB); - packet->header[3] = length << 16; - packet->header_size = 16; - packet->expect_response = 1; - packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0); + PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEB); + packet->header[3] = length << 16; + packet->header_size = 16; + packet->expect_response = 1; + packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0); } static void fill_async_lock(struct hpsb_packet *packet, u64 addr, int extcode, - int length) + int length) { - PREP_ASYNC_HEAD_ADDRESS(TCODE_LOCK_REQUEST); - packet->header[3] = (length << 16) | extcode; - packet->header_size = 16; - packet->data_size = length; - packet->expect_response = 1; + PREP_ASYNC_HEAD_ADDRESS(TCODE_LOCK_REQUEST); + packet->header[3] = (length << 16) | extcode; + packet->header_size = 16; + packet->data_size = length; + packet->expect_response = 1; } static void fill_iso_packet(struct hpsb_packet *packet, int length, int channel, - int tag, int sync) + int tag, int sync) { - packet->header[0] = (length << 16) | (tag << 14) | (channel << 8) - | (TCODE_ISO_DATA << 4) | sync; + packet->header[0] = (length << 16) | (tag << 14) | (channel << 8) + | (TCODE_ISO_DATA << 4) | sync; - packet->header_size = 4; - packet->data_size = length; - packet->type = hpsb_iso; - packet->tcode = TCODE_ISO_DATA; + packet->header_size = 4; + packet->data_size = length; + packet->type = hpsb_iso; + packet->tcode = TCODE_ISO_DATA; } static void fill_phy_packet(struct hpsb_packet *packet, quadlet_t data) { - packet->header[0] = data; - packet->header[1] = ~data; - packet->header_size = 8; - packet->data_size = 0; - packet->expect_response = 0; - packet->type = hpsb_raw; /* No CRC added */ - packet->speed_code = IEEE1394_SPEED_100; /* Force speed to be 100Mbps */ + packet->header[0] = data; + packet->header[1] = ~data; + packet->header_size = 8; + packet->data_size = 0; + packet->expect_response = 0; + packet->type = hpsb_raw; /* No CRC added */ + packet->speed_code = IEEE1394_SPEED_100; /* Force speed to be 100Mbps */ } static void fill_async_stream_packet(struct hpsb_packet *packet, int length, int channel, int tag, int sync) { packet->header[0] = (length << 16) | (tag << 14) | (channel << 8) - | (TCODE_STREAM_DATA << 4) | sync; + | (TCODE_STREAM_DATA << 4) | sync; packet->header_size = 4; packet->data_size = length; @@ -172,99 +173,96 @@ int hpsb_get_tlabel(struct hpsb_packet *packet) */ void hpsb_free_tlabel(struct hpsb_packet *packet) { - unsigned long flags; + unsigned long flags; struct hpsb_tlabel_pool *tp; tp = &packet->host->tpool[packet->node_id & NODE_MASK]; BUG_ON(packet->tlabel > 63 || packet->tlabel < 0); - spin_lock_irqsave(&tp->lock, flags); + spin_lock_irqsave(&tp->lock, flags); BUG_ON(!test_and_clear_bit(packet->tlabel, tp->pool)); - spin_unlock_irqrestore(&tp->lock, flags); + spin_unlock_irqrestore(&tp->lock, flags); up(&tp->count); } - - int hpsb_packet_success(struct hpsb_packet *packet) { - switch (packet->ack_code) { - case ACK_PENDING: - switch ((packet->header[1] >> 12) & 0xf) { - case RCODE_COMPLETE: - return 0; - case RCODE_CONFLICT_ERROR: - return -EAGAIN; - case RCODE_DATA_ERROR: - return -EREMOTEIO; - case RCODE_TYPE_ERROR: - return -EACCES; - case RCODE_ADDRESS_ERROR: - return -EINVAL; - default: - HPSB_ERR("received reserved rcode %d from node %d", - (packet->header[1] >> 12) & 0xf, - packet->node_id); - return -EAGAIN; - } - HPSB_PANIC("reached unreachable code 1 in %s", __FUNCTION__); - - case ACK_BUSY_X: - case ACK_BUSY_A: - case ACK_BUSY_B: - return -EBUSY; - - case ACK_TYPE_ERROR: - return -EACCES; - - case ACK_COMPLETE: - if (packet->tcode == TCODE_WRITEQ - || packet->tcode == TCODE_WRITEB) { - return 0; - } else { - HPSB_ERR("impossible ack_complete from node %d " - "(tcode %d)", packet->node_id, packet->tcode); - return -EAGAIN; - } - - - case ACK_DATA_ERROR: - if (packet->tcode == TCODE_WRITEB - || packet->tcode == TCODE_LOCK_REQUEST) { - return -EAGAIN; - } else { - HPSB_ERR("impossible ack_data_error from node %d " - "(tcode %d)", packet->node_id, packet->tcode); - return -EAGAIN; - } - - case ACK_ADDRESS_ERROR: - return -EINVAL; - - case ACK_TARDY: - case ACK_CONFLICT_ERROR: - case ACKX_NONE: - case ACKX_SEND_ERROR: - case ACKX_ABORTED: - case ACKX_TIMEOUT: - /* error while sending */ - return -EAGAIN; - - default: - HPSB_ERR("got invalid ack %d from node %d (tcode %d)", - packet->ack_code, packet->node_id, packet->tcode); - return -EAGAIN; - } - - HPSB_PANIC("reached unreachable code 2 in %s", __FUNCTION__); + switch (packet->ack_code) { + case ACK_PENDING: + switch ((packet->header[1] >> 12) & 0xf) { + case RCODE_COMPLETE: + return 0; + case RCODE_CONFLICT_ERROR: + return -EAGAIN; + case RCODE_DATA_ERROR: + return -EREMOTEIO; + case RCODE_TYPE_ERROR: + return -EACCES; + case RCODE_ADDRESS_ERROR: + return -EINVAL; + default: + HPSB_ERR("received reserved rcode %d from node %d", + (packet->header[1] >> 12) & 0xf, + packet->node_id); + return -EAGAIN; + } + HPSB_PANIC("reached unreachable code 1 in %s", __FUNCTION__); + + case ACK_BUSY_X: + case ACK_BUSY_A: + case ACK_BUSY_B: + return -EBUSY; + + case ACK_TYPE_ERROR: + return -EACCES; + + case ACK_COMPLETE: + if (packet->tcode == TCODE_WRITEQ + || packet->tcode == TCODE_WRITEB) { + return 0; + } else { + HPSB_ERR("impossible ack_complete from node %d " + "(tcode %d)", packet->node_id, packet->tcode); + return -EAGAIN; + } + + case ACK_DATA_ERROR: + if (packet->tcode == TCODE_WRITEB + || packet->tcode == TCODE_LOCK_REQUEST) { + return -EAGAIN; + } else { + HPSB_ERR("impossible ack_data_error from node %d " + "(tcode %d)", packet->node_id, packet->tcode); + return -EAGAIN; + } + + case ACK_ADDRESS_ERROR: + return -EINVAL; + + case ACK_TARDY: + case ACK_CONFLICT_ERROR: + case ACKX_NONE: + case ACKX_SEND_ERROR: + case ACKX_ABORTED: + case ACKX_TIMEOUT: + /* error while sending */ + return -EAGAIN; + + default: + HPSB_ERR("got invalid ack %d from node %d (tcode %d)", + packet->ack_code, packet->node_id, packet->tcode); + return -EAGAIN; + } + + HPSB_PANIC("reached unreachable code 2 in %s", __FUNCTION__); } struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node, u64 addr, size_t length) { - struct hpsb_packet *packet; + struct hpsb_packet *packet; if (length == 0) return NULL; @@ -289,8 +287,9 @@ struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node, return packet; } -struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node, - u64 addr, quadlet_t *buffer, size_t length) +struct hpsb_packet *hpsb_make_writepacket(struct hpsb_host *host, nodeid_t node, + u64 addr, quadlet_t * buffer, + size_t length) { struct hpsb_packet *packet; @@ -301,7 +300,7 @@ struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node if (!packet) return NULL; - if (length % 4) { /* zero padding bytes */ + if (length % 4) { /* zero padding bytes */ packet->data[length >> 2] = 0; } packet->host = host; @@ -323,8 +322,9 @@ struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node return packet; } -struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, int length, - int channel, int tag, int sync) +struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 * buffer, + int length, int channel, int tag, + int sync) { struct hpsb_packet *packet; @@ -335,7 +335,7 @@ struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, i if (!packet) return NULL; - if (length % 4) { /* zero padding bytes */ + if (length % 4) { /* zero padding bytes */ packet->data[length >> 2] = 0; } packet->host = host; @@ -353,14 +353,15 @@ struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, i } struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node, - u64 addr, int extcode, quadlet_t *data, - quadlet_t arg) + u64 addr, int extcode, + quadlet_t * data, quadlet_t arg) { struct hpsb_packet *p; u32 length; p = hpsb_alloc_packet(8); - if (!p) return NULL; + if (!p) + return NULL; p->host = host; p->node_id = node; @@ -389,15 +390,16 @@ struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node, return p; } -struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, nodeid_t node, - u64 addr, int extcode, octlet_t *data, - octlet_t arg) +struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, + nodeid_t node, u64 addr, int extcode, + octlet_t * data, octlet_t arg) { struct hpsb_packet *p; u32 length; p = hpsb_alloc_packet(16); - if (!p) return NULL; + if (!p) + return NULL; p->host = host; p->node_id = node; @@ -430,18 +432,18 @@ struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, nodeid_t node return p; } -struct hpsb_packet *hpsb_make_phypacket(struct hpsb_host *host, - quadlet_t data) +struct hpsb_packet *hpsb_make_phypacket(struct hpsb_host *host, quadlet_t data) { - struct hpsb_packet *p; + struct hpsb_packet *p; - p = hpsb_alloc_packet(0); - if (!p) return NULL; + p = hpsb_alloc_packet(0); + if (!p) + return NULL; - p->host = host; - fill_phy_packet(p, data); + p->host = host; + fill_phy_packet(p, data); - return p; + return p; } struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host, @@ -451,7 +453,8 @@ struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host, struct hpsb_packet *p; p = hpsb_alloc_packet(length); - if (!p) return NULL; + if (!p) + return NULL; p->host = host; fill_iso_packet(p, length, channel, tag, sync); @@ -467,47 +470,46 @@ struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host, */ int hpsb_read(struct hpsb_host *host, nodeid_t node, unsigned int generation, - u64 addr, quadlet_t *buffer, size_t length) + u64 addr, quadlet_t * buffer, size_t length) { - struct hpsb_packet *packet; - int retval = 0; + struct hpsb_packet *packet; + int retval = 0; - if (length == 0) - return -EINVAL; + if (length == 0) + return -EINVAL; - BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet + BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet packet = hpsb_make_readpacket(host, node, addr, length); - if (!packet) { - return -ENOMEM; - } + if (!packet) { + return -ENOMEM; + } packet->generation = generation; - retval = hpsb_send_packet_and_wait(packet); + retval = hpsb_send_packet_and_wait(packet); if (retval < 0) goto hpsb_read_fail; - retval = hpsb_packet_success(packet); + retval = hpsb_packet_success(packet); - if (retval == 0) { - if (length == 4) { - *buffer = packet->header[3]; - } else { - memcpy(buffer, packet->data, length); - } - } + if (retval == 0) { + if (length == 4) { + *buffer = packet->header[3]; + } else { + memcpy(buffer, packet->data, length); + } + } -hpsb_read_fail: - hpsb_free_tlabel(packet); - hpsb_free_packet(packet); + hpsb_read_fail: + hpsb_free_tlabel(packet); + hpsb_free_packet(packet); - return retval; + return retval; } - int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation, - u64 addr, quadlet_t *buffer, size_t length) + u64 addr, quadlet_t * buffer, size_t length) { struct hpsb_packet *packet; int retval; @@ -515,62 +517,61 @@ int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation, if (length == 0) return -EINVAL; - BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet + BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet - packet = hpsb_make_writepacket (host, node, addr, buffer, length); + packet = hpsb_make_writepacket(host, node, addr, buffer, length); if (!packet) return -ENOMEM; packet->generation = generation; - retval = hpsb_send_packet_and_wait(packet); + retval = hpsb_send_packet_and_wait(packet); if (retval < 0) goto hpsb_write_fail; - retval = hpsb_packet_success(packet); + retval = hpsb_packet_success(packet); -hpsb_write_fail: - hpsb_free_tlabel(packet); - hpsb_free_packet(packet); + hpsb_write_fail: + hpsb_free_tlabel(packet); + hpsb_free_packet(packet); - return retval; + return retval; } #if 0 int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation, - u64 addr, int extcode, quadlet_t *data, quadlet_t arg) + u64 addr, int extcode, quadlet_t * data, quadlet_t arg) { - struct hpsb_packet *packet; - int retval = 0; + struct hpsb_packet *packet; + int retval = 0; - BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet + BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg); - if (!packet) - return -ENOMEM; + if (!packet) + return -ENOMEM; packet->generation = generation; - retval = hpsb_send_packet_and_wait(packet); + retval = hpsb_send_packet_and_wait(packet); if (retval < 0) goto hpsb_lock_fail; - retval = hpsb_packet_success(packet); + retval = hpsb_packet_success(packet); - if (retval == 0) { - *data = packet->data[0]; - } + if (retval == 0) { + *data = packet->data[0]; + } -hpsb_lock_fail: - hpsb_free_tlabel(packet); - hpsb_free_packet(packet); + hpsb_lock_fail: + hpsb_free_tlabel(packet); + hpsb_free_packet(packet); - return retval; + return retval; } - int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation, - quadlet_t *buffer, size_t length, u32 specifier_id, + quadlet_t * buffer, size_t length, u32 specifier_id, unsigned int version) { struct hpsb_packet *packet; @@ -587,7 +588,8 @@ int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation, return -ENOMEM; packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi); - packet->data[1] = cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff)); + packet->data[1] = + cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff)); memcpy(&(packet->data[2]), buffer, length - 8); @@ -602,4 +604,4 @@ int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation, return retval; } -#endif /* 0 */ +#endif /* 0 */ -- cgit v1.1 From 066ef9c2fb30a22eca7724326e210f0405c51f29 Mon Sep 17 00:00:00 2001 From: Jens-Michael Hoffmann Date: Tue, 22 Nov 2005 12:35:23 -0500 Subject: ieee1394/iso: LIndent fixes This patch contains fixes by LIndent. Signed-off-by: Jens-Michael Hoffmann Signed-off-by: Jody McIntyre --- drivers/ieee1394/iso.c | 102 +++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/drivers/ieee1394/iso.c b/drivers/ieee1394/iso.c index 615541b..f26680e 100644 --- a/drivers/ieee1394/iso.c +++ b/drivers/ieee1394/iso.c @@ -36,20 +36,22 @@ void hpsb_iso_shutdown(struct hpsb_iso *iso) kfree(iso); } -static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_iso_type type, +static struct hpsb_iso *hpsb_iso_common_init(struct hpsb_host *host, + enum hpsb_iso_type type, unsigned int data_buf_size, unsigned int buf_packets, - int channel, - int dma_mode, + int channel, int dma_mode, int irq_interval, - void (*callback)(struct hpsb_iso*)) + void (*callback) (struct hpsb_iso + *)) { struct hpsb_iso *iso; int dma_direction; /* make sure driver supports the ISO API */ if (!host->driver->isoctl) { - printk(KERN_INFO "ieee1394: host driver '%s' does not support the rawiso API\n", + printk(KERN_INFO + "ieee1394: host driver '%s' does not support the rawiso API\n", host->driver->name); return NULL; } @@ -59,12 +61,13 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i if (buf_packets < 2) buf_packets = 2; - if ((dma_mode < HPSB_ISO_DMA_DEFAULT) || (dma_mode > HPSB_ISO_DMA_PACKET_PER_BUFFER)) - dma_mode=HPSB_ISO_DMA_DEFAULT; + if ((dma_mode < HPSB_ISO_DMA_DEFAULT) + || (dma_mode > HPSB_ISO_DMA_PACKET_PER_BUFFER)) + dma_mode = HPSB_ISO_DMA_DEFAULT; if ((irq_interval < 0) || (irq_interval > buf_packets / 4)) - irq_interval = buf_packets / 4; - if (irq_interval == 0) /* really interrupt for each packet*/ + irq_interval = buf_packets / 4; + if (irq_interval == 0) /* really interrupt for each packet */ irq_interval = 1; if (channel < -1 || channel >= 64) @@ -76,7 +79,10 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i /* allocate and write the struct hpsb_iso */ - iso = kmalloc(sizeof(*iso) + buf_packets * sizeof(struct hpsb_iso_packet_info), GFP_KERNEL); + iso = + kmalloc(sizeof(*iso) + + buf_packets * sizeof(struct hpsb_iso_packet_info), + GFP_KERNEL); if (!iso) return NULL; @@ -111,17 +117,18 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i iso->prebuffer = 0; /* allocate the packet buffer */ - if (dma_region_alloc(&iso->data_buf, iso->buf_size, host->pdev, dma_direction)) + if (dma_region_alloc + (&iso->data_buf, iso->buf_size, host->pdev, dma_direction)) goto err; return iso; -err: + err: hpsb_iso_shutdown(iso); return NULL; } -int hpsb_iso_n_ready(struct hpsb_iso* iso) +int hpsb_iso_n_ready(struct hpsb_iso *iso) { unsigned long flags; int val; @@ -133,18 +140,19 @@ int hpsb_iso_n_ready(struct hpsb_iso* iso) return val; } - -struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host, +struct hpsb_iso *hpsb_iso_xmit_init(struct hpsb_host *host, unsigned int data_buf_size, unsigned int buf_packets, int channel, int speed, int irq_interval, - void (*callback)(struct hpsb_iso*)) + void (*callback) (struct hpsb_iso *)) { struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_XMIT, data_buf_size, buf_packets, - channel, HPSB_ISO_DMA_DEFAULT, irq_interval, callback); + channel, + HPSB_ISO_DMA_DEFAULT, + irq_interval, callback); if (!iso) return NULL; @@ -157,22 +165,23 @@ struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host, iso->flags |= HPSB_ISO_DRIVER_INIT; return iso; -err: + err: hpsb_iso_shutdown(iso); return NULL; } -struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host, +struct hpsb_iso *hpsb_iso_recv_init(struct hpsb_host *host, unsigned int data_buf_size, unsigned int buf_packets, int channel, int dma_mode, int irq_interval, - void (*callback)(struct hpsb_iso*)) + void (*callback) (struct hpsb_iso *)) { struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_RECV, data_buf_size, buf_packets, - channel, dma_mode, irq_interval, callback); + channel, dma_mode, + irq_interval, callback); if (!iso) return NULL; @@ -183,7 +192,7 @@ struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host, iso->flags |= HPSB_ISO_DRIVER_INIT; return iso; -err: + err: hpsb_iso_shutdown(iso); return NULL; } @@ -197,16 +206,17 @@ int hpsb_iso_recv_listen_channel(struct hpsb_iso *iso, unsigned char channel) int hpsb_iso_recv_unlisten_channel(struct hpsb_iso *iso, unsigned char channel) { - if (iso->type != HPSB_ISO_RECV || iso->channel != -1 || channel >= 64) - return -EINVAL; - return iso->host->driver->isoctl(iso, RECV_UNLISTEN_CHANNEL, channel); + if (iso->type != HPSB_ISO_RECV || iso->channel != -1 || channel >= 64) + return -EINVAL; + return iso->host->driver->isoctl(iso, RECV_UNLISTEN_CHANNEL, channel); } int hpsb_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask) { if (iso->type != HPSB_ISO_RECV || iso->channel != -1) return -EINVAL; - return iso->host->driver->isoctl(iso, RECV_SET_CHANNEL_MASK, (unsigned long) &mask); + return iso->host->driver->isoctl(iso, RECV_SET_CHANNEL_MASK, + (unsigned long)&mask); } int hpsb_iso_recv_flush(struct hpsb_iso *iso) @@ -283,7 +293,9 @@ int hpsb_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, int sync) isoctl_args[2] = sync; - retval = iso->host->driver->isoctl(iso, RECV_START, (unsigned long) &isoctl_args[0]); + retval = + iso->host->driver->isoctl(iso, RECV_START, + (unsigned long)&isoctl_args[0]); if (retval) return retval; @@ -296,7 +308,8 @@ int hpsb_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, int sync) static int hpsb_iso_check_offset_len(struct hpsb_iso *iso, unsigned int offset, unsigned short len, - unsigned int *out_offset, unsigned short *out_len) + unsigned int *out_offset, + unsigned short *out_len) { if (offset >= iso->buf_size) return -EFAULT; @@ -316,8 +329,8 @@ static int hpsb_iso_check_offset_len(struct hpsb_iso *iso, return 0; } - -int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag, u8 sy) +int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, + u8 tag, u8 sy) { struct hpsb_iso_packet_info *info; unsigned long flags; @@ -334,7 +347,8 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag info = &iso->infos[iso->first_packet]; /* check for bogus offset/length */ - if (hpsb_iso_check_offset_len(iso, offset, len, &info->offset, &info->len)) + if (hpsb_iso_check_offset_len + (iso, offset, len, &info->offset, &info->len)) return -EFAULT; info->tag = tag; @@ -342,13 +356,13 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag spin_lock_irqsave(&iso->lock, flags); - rv = iso->host->driver->isoctl(iso, XMIT_QUEUE, (unsigned long) info); + rv = iso->host->driver->isoctl(iso, XMIT_QUEUE, (unsigned long)info); if (rv) goto out; /* increment cursors */ - iso->first_packet = (iso->first_packet+1) % iso->buf_packets; - iso->xmit_cycle = (iso->xmit_cycle+1) % 8000; + iso->first_packet = (iso->first_packet + 1) % iso->buf_packets; + iso->xmit_cycle = (iso->xmit_cycle + 1) % 8000; iso->n_ready_packets--; if (iso->prebuffer != 0) { @@ -359,7 +373,7 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag } } -out: + out: spin_unlock_irqrestore(&iso->lock, flags); return rv; } @@ -369,7 +383,9 @@ int hpsb_iso_xmit_sync(struct hpsb_iso *iso) if (iso->type != HPSB_ISO_XMIT) return -EINVAL; - return wait_event_interruptible(iso->waitq, hpsb_iso_n_ready(iso) == iso->buf_packets); + return wait_event_interruptible(iso->waitq, + hpsb_iso_n_ready(iso) == + iso->buf_packets); } void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error) @@ -396,7 +412,8 @@ void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error) } void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len, - u16 total_len, u16 cycle, u8 channel, u8 tag, u8 sy) + u16 total_len, u16 cycle, u8 channel, u8 tag, + u8 sy) { unsigned long flags; spin_lock_irqsave(&iso->lock, flags); @@ -416,7 +433,7 @@ void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len, info->tag = tag; info->sy = sy; - iso->pkt_dma = (iso->pkt_dma+1) % iso->buf_packets; + iso->pkt_dma = (iso->pkt_dma + 1) % iso->buf_packets; iso->n_ready_packets++; } @@ -435,20 +452,21 @@ int hpsb_iso_recv_release_packets(struct hpsb_iso *iso, unsigned int n_packets) spin_lock_irqsave(&iso->lock, flags); for (i = 0; i < n_packets; i++) { rv = iso->host->driver->isoctl(iso, RECV_RELEASE, - (unsigned long) &iso->infos[iso->first_packet]); + (unsigned long)&iso->infos[iso-> + first_packet]); if (rv) break; - iso->first_packet = (iso->first_packet+1) % iso->buf_packets; + iso->first_packet = (iso->first_packet + 1) % iso->buf_packets; iso->n_ready_packets--; /* release memory from packets discarded when queue was full */ - if (iso->n_ready_packets == 0) { /* Release only after all prior packets handled */ + if (iso->n_ready_packets == 0) { /* Release only after all prior packets handled */ if (iso->bytes_discarded != 0) { struct hpsb_iso_packet_info inf; inf.total_len = iso->bytes_discarded; iso->host->driver->isoctl(iso, RECV_RELEASE, - (unsigned long) &inf); + (unsigned long)&inf); iso->bytes_discarded = 0; } } -- cgit v1.1 From c64d472abc68dcad4d34f365545058c3f11973d8 Mon Sep 17 00:00:00 2001 From: Jens-Michael Hoffmann Date: Tue, 22 Nov 2005 12:37:10 -0500 Subject: ieee1394/raw1394: LIndent fixes This patch contains fixes by LIndent. Signed-off-by: Jens-Michael Hoffmann Signed-off-by: Jody McIntyre --- drivers/ieee1394/raw1394.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 89cac1f..b052356 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c @@ -2482,8 +2482,8 @@ static int raw1394_iso_recv_packets(struct file_info *fi, void __user * uaddr) /* ensure user-supplied buffer is accessible and big enough */ if (!access_ok(VERIFY_WRITE, upackets.infos, - upackets.n_packets * - sizeof(struct raw1394_iso_packet_info))) + upackets.n_packets * + sizeof(struct raw1394_iso_packet_info))) return -EFAULT; /* copy the packet_infos out */ @@ -2516,8 +2516,8 @@ static int raw1394_iso_send_packets(struct file_info *fi, void __user * uaddr) /* ensure user-supplied buffer is accessible and big enough */ if (!access_ok(VERIFY_READ, upackets.infos, - upackets.n_packets * - sizeof(struct raw1394_iso_packet_info))) + upackets.n_packets * + sizeof(struct raw1394_iso_packet_info))) return -EFAULT; /* copy the infos structs in and queue the packets */ @@ -2741,8 +2741,7 @@ static int raw1394_release(struct inode *inode, struct file *file) list) { entry = fi_hlp->addr_list.next; while (entry != &(fi_hlp->addr_list)) { - arm_addr = list_entry(entry, - struct + arm_addr = list_entry(entry, struct arm_addr, addr_list); if (arm_addr->start == @@ -2905,16 +2904,17 @@ static int __init init_raw1394(void) hpsb_register_highlevel(&raw1394_highlevel); - if (IS_ERR(class_device_create(hpsb_protocol_class, NULL, MKDEV( - IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), - NULL, RAW1394_DEVICE_NAME))) { + if (IS_ERR + (class_device_create + (hpsb_protocol_class, NULL, + MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), NULL, + RAW1394_DEVICE_NAME))) { ret = -EFAULT; goto out_unreg; } - - devfs_mk_cdev(MKDEV( - IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), - S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME); + + devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), + S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME); cdev_init(&raw1394_cdev, &raw1394_fops); raw1394_cdev.owner = THIS_MODULE; @@ -2936,20 +2936,22 @@ static int __init init_raw1394(void) goto out; -out_dev: + out_dev: devfs_remove(RAW1394_DEVICE_NAME); class_device_destroy(hpsb_protocol_class, - MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)); -out_unreg: + MKDEV(IEEE1394_MAJOR, + IEEE1394_MINOR_BLOCK_RAW1394 * 16)); + out_unreg: hpsb_unregister_highlevel(&raw1394_highlevel); -out: + out: return ret; } static void __exit cleanup_raw1394(void) { class_device_destroy(hpsb_protocol_class, - MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)); + MKDEV(IEEE1394_MAJOR, + IEEE1394_MINOR_BLOCK_RAW1394 * 16)); cdev_del(&raw1394_cdev); devfs_remove(RAW1394_DEVICE_NAME); hpsb_unregister_highlevel(&raw1394_highlevel); -- cgit v1.1 From 2e06cb5859fdaeba0529806eb1bf161ffd0db201 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Mon, 28 Nov 2005 13:54:22 -0500 Subject: [bonding] Remove superfluous changelog. No need to record this information in source code, its all in the git repository, and kernel archives. --- drivers/net/bonding/bond_3ad.c | 32 --- drivers/net/bonding/bond_3ad.h | 13 -- drivers/net/bonding/bond_alb.c | 19 -- drivers/net/bonding/bond_alb.h | 9 - drivers/net/bonding/bond_main.c | 482 --------------------------------------- drivers/net/bonding/bond_sysfs.c | 41 ---- drivers/net/bonding/bonding.h | 23 -- 7 files changed, 619 deletions(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 0470523..f3f5825 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -18,38 +18,6 @@ * The full GNU General Public License is included in this distribution in the * file called LICENSE. * - * - * Changes: - * - * 2003/05/01 - Tsippy Mendelson and - * Amir Noam - * - Added support for lacp_rate module param. - * - * 2003/05/01 - Shmulik Hen - * - Based on discussion on mailing list, changed locking scheme - * to use lock/unlock or lock_bh/unlock_bh appropriately instead - * of lock_irqsave/unlock_irqrestore. The new scheme helps exposing - * hidden bugs and solves system hangs that occurred due to the fact - * that holding lock_irqsave doesn't prevent softirqs from running. - * This also increases total throughput since interrupts are not - * blocked on each transmitted packets or monitor timeout. - * - * 2003/05/01 - Shmulik Hen - * - Renamed bond_3ad_link_status_changed() to - * bond_3ad_handle_link_change() for compatibility with TLB. - * - * 2003/05/20 - Amir Noam - * - Fix long fail over time when releasing last slave of an active - * aggregator - send LACPDU on unbind of slave to tell partner this - * port is no longer aggregatable. - * - * 2003/06/25 - Tsippy Mendelson - * - Send LACPDU as highest priority packet to further fix the above - * problem on very high Tx traffic load where packets may get dropped - * by the slave. - * - * 2003/12/01 - Shmulik Hen - * - Code cleanup and style changes */ //#define BONDING_DEBUG 1 diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h index 673a30a..5ee2cef 100644 --- a/drivers/net/bonding/bond_3ad.h +++ b/drivers/net/bonding/bond_3ad.h @@ -18,19 +18,6 @@ * The full GNU General Public License is included in this distribution in the * file called LICENSE. * - * - * Changes: - * - * 2003/05/01 - Tsippy Mendelson and - * Amir Noam - * - Added support for lacp_rate module param. - * - * 2003/05/01 - Shmulik Hen - * - Renamed bond_3ad_link_status_changed() to - * bond_3ad_handle_link_change() for compatibility with TLB. - * - * 2003/12/01 - Shmulik Hen - * - Code cleanup and style changes */ #ifndef __BOND_3AD_H__ diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 9bd1e10..854ddfb 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -18,25 +18,6 @@ * The full GNU General Public License is included in this distribution in the * file called LICENSE. * - * - * Changes: - * - * 2003/06/25 - Shmulik Hen - * - Fixed signed/unsigned calculation errors that caused load sharing - * to collapse to one slave under very heavy UDP Tx stress. - * - * 2003/08/06 - Amir Noam - * - Add support for setting bond's MAC address with special - * handling required for ALB/TLB. - * - * 2003/12/01 - Shmulik Hen - * - Code cleanup and style changes - * - * 2003/12/30 - Amir Noam - * - Fixed: Cannot remove and re-enslave the original active slave. - * - * 2004/01/14 - Shmulik Hen - * - Add capability to tag self generated packets in ALB/TLB modes. */ //#define BONDING_DEBUG 1 diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h index e4091cd..28f2a2f 100644 --- a/drivers/net/bonding/bond_alb.h +++ b/drivers/net/bonding/bond_alb.h @@ -18,15 +18,6 @@ * The full GNU General Public License is included in this distribution in the * file called LICENSE. * - * - * Changes: - * - * 2003/08/06 - Amir Noam - * - Add support for setting bond's MAC address with special - * handling required for ALB/TLB. - * - * 2003/12/01 - Shmulik Hen - * - Code cleanup and style changes */ #ifndef __BOND_ALB_H__ diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 40ff791..2582d98 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -29,488 +29,6 @@ * b: if a hw mac address already is there, eth0's hw mac address * will then be set from bond0. * - * v0.1 - first working version. - * v0.2 - changed stats to be calculated by summing slaves stats. - * - * Changes: - * Arnaldo Carvalho de Melo - * - fix leaks on failure at bond_init - * - * 2000/09/30 - Willy Tarreau - * - added trivial code to release a slave device. - * - fixed security bug (CAP_NET_ADMIN not checked) - * - implemented MII link monitoring to disable dead links : - * All MII capable slaves are checked every milliseconds - * (100 ms seems good). This value can be changed by passing it to - * insmod. A value of zero disables the monitoring (default). - * - fixed an infinite loop in bond_xmit_roundrobin() when there's no - * good slave. - * - made the code hopefully SMP safe - * - * 2000/10/03 - Willy Tarreau - * - optimized slave lists based on relevant suggestions from Thomas Davis - * - implemented active-backup method to obtain HA with two switches: - * stay as long as possible on the same active interface, while we - * also monitor the backup one (MII link status) because we want to know - * if we are able to switch at any time. ( pass "mode=1" to insmod ) - * - lots of stress testings because we need it to be more robust than the - * wires ! :-> - * - * 2000/10/09 - Willy Tarreau - * - added up and down delays after link state change. - * - optimized the slaves chaining so that when we run forward, we never - * repass through the bond itself, but we can find it by searching - * backwards. Renders the deletion more difficult, but accelerates the - * scan. - * - smarter enslaving and releasing. - * - finer and more robust SMP locking - * - * 2000/10/17 - Willy Tarreau - * - fixed two potential SMP race conditions - * - * 2000/10/18 - Willy Tarreau - * - small fixes to the monitoring FSM in case of zero delays - * 2000/11/01 - Willy Tarreau - * - fixed first slave not automatically used in trunk mode. - * 2000/11/10 : spelling of "EtherChannel" corrected. - * 2000/11/13 : fixed a race condition in case of concurrent accesses to ioctl(). - * 2000/12/16 : fixed improper usage of rtnl_exlock_nowait(). - * - * 2001/1/3 - Chad N. Tindel - * - The bonding driver now simulates MII status monitoring, just like - * a normal network device. It will show that the link is down iff - * every slave in the bond shows that their links are down. If at least - * one slave is up, the bond's MII status will appear as up. - * - * 2001/2/7 - Chad N. Tindel - * - Applications can now query the bond from user space to get - * information which may be useful. They do this by calling - * the BOND_INFO_QUERY ioctl. Once the app knows how many slaves - * are in the bond, it can call the BOND_SLAVE_INFO_QUERY ioctl to - * get slave specific information (# link failures, etc). See - * for more details. The structs of interest - * are ifbond and ifslave. - * - * 2001/4/5 - Chad N. Tindel - * - Ported to 2.4 Kernel - * - * 2001/5/2 - Jeffrey E. Mast - * - When a device is detached from a bond, the slave device is no longer - * left thinking that is has a master. - * - * 2001/5/16 - Jeffrey E. Mast - * - memset did not appropriately initialized the bond rw_locks. Used - * rwlock_init to initialize to unlocked state to prevent deadlock when - * first attempting a lock - * - Called SET_MODULE_OWNER for bond device - * - * 2001/5/17 - Tim Anderson - * - 2 paths for releasing for slave release; 1 through ioctl - * and 2) through close. Both paths need to release the same way. - * - the free slave in bond release is changing slave status before - * the free. The netdev_set_master() is intended to change slave state - * so it should not be done as part of the release process. - * - Simple rule for slave state at release: only the active in A/B and - * only one in the trunked case. - * - * 2001/6/01 - Tim Anderson - * - Now call dev_close when releasing a slave so it doesn't screw up - * out routing table. - * - * 2001/6/01 - Chad N. Tindel - * - Added /proc support for getting bond and slave information. - * Information is in /proc/net//info. - * - Changed the locking when calling bond_close to prevent deadlock. - * - * 2001/8/05 - Janice Girouard - * - correct problem where refcnt of slave is not incremented in bond_ioctl - * so the system hangs when halting. - * - correct locking problem when unable to malloc in bond_enslave. - * - adding bond_xmit_xor logic. - * - adding multiple bond device support. - * - * 2001/8/13 - Erik Habbinga - * - correct locking problem with rtnl_exlock_nowait - * - * 2001/8/23 - Janice Girouard - * - bzero initial dev_bonds, to correct oops - * - convert SIOCDEVPRIVATE to new MII ioctl calls - * - * 2001/9/13 - Takao Indoh - * - Add the BOND_CHANGE_ACTIVE ioctl implementation - * - * 2001/9/14 - Mark Huth - * - Change MII_LINK_READY to not check for end of auto-negotiation, - * but only for an up link. - * - * 2001/9/20 - Chad N. Tindel - * - Add the device field to bonding_t. Previously the net_device - * corresponding to a bond wasn't available from the bonding_t - * structure. - * - * 2001/9/25 - Janice Girouard - * - add arp_monitor for active backup mode - * - * 2001/10/23 - Takao Indoh - * - Various memory leak fixes - * - * 2001/11/5 - Mark Huth - * - Don't take rtnl lock in bond_mii_monitor as it deadlocks under - * certain hotswap conditions. - * Note: this same change may be required in bond_arp_monitor ??? - * - Remove possibility of calling bond_sethwaddr with NULL slave_dev ptr - * - Handle hot swap ethernet interface deregistration events to remove - * kernel oops following hot swap of enslaved interface - * - * 2002/1/2 - Chad N. Tindel - * - Restore original slave flags at release time. - * - * 2002/02/18 - Erik Habbinga - * - bond_release(): calling kfree on our_slave after call to - * bond_restore_slave_flags, not before - * - bond_enslave(): saving slave flags into original_flags before - * call to netdev_set_master, so the IFF_SLAVE flag doesn't end - * up in original_flags - * - * 2002/04/05 - Mark Smith and - * Steve Mead - * - Port Gleb Natapov's multicast support patchs from 2.4.12 - * to 2.4.18 adding support for multicast. - * - * 2002/06/10 - Tony Cureington - * - corrected uninitialized pointer (ifr.ifr_data) in bond_check_dev_link; - * actually changed function to use MIIPHY, then MIIREG, and finally - * ETHTOOL to determine the link status - * - fixed bad ifr_data pointer assignments in bond_ioctl - * - corrected mode 1 being reported as active-backup in bond_get_info; - * also added text to distinguish type of load balancing (rr or xor) - * - change arp_ip_target module param from "1-12s" (array of 12 ptrs) - * to "s" (a single ptr) - * - * 2002/08/30 - Jay Vosburgh - * - Removed acquisition of xmit_lock in set_multicast_list; caused - * deadlock on SMP (lock is held by caller). - * - Revamped SIOCGMIIPHY, SIOCGMIIREG portion of bond_check_dev_link(). - * - * 2002/09/18 - Jay Vosburgh - * - Fixed up bond_check_dev_link() (and callers): removed some magic - * numbers, banished local MII_ defines, wrapped ioctl calls to - * prevent EFAULT errors - * - * 2002/9/30 - Jay Vosburgh - * - make sure the ip target matches the arp_target before saving the - * hw address. - * - * 2002/9/30 - Dan Eisner - * - make sure my_ip is set before taking down the link, since - * not all switches respond if the source ip is not set. - * - * 2002/10/8 - Janice Girouard - * - read in the local ip address when enslaving a device - * - add primary support - * - make sure 2*arp_interval has passed when a new device - * is brought on-line before taking it down. - * - * 2002/09/11 - Philippe De Muyter - * - Added bond_xmit_broadcast logic. - * - Added bond_mode() support function. - * - * 2002/10/26 - Laurent Deniel - * - allow to register multicast addresses only on active slave - * (useful in active-backup mode) - * - add multicast module parameter - * - fix deletion of multicast groups after unloading module - * - * 2002/11/06 - Kameshwara Rayaprolu - * - Changes to prevent panic from closing the device twice; if we close - * the device in bond_release, we must set the original_flags to down - * so it won't be closed again by the network layer. - * - * 2002/11/07 - Tony Cureington - * - Fix arp_target_hw_addr memory leak - * - Created activebackup_arp_monitor function to handle arp monitoring - * in active backup mode - the bond_arp_monitor had several problems... - * such as allowing slaves to tx arps sequentially without any delay - * for a response - * - Renamed bond_arp_monitor to loadbalance_arp_monitor and re-wrote - * this function to just handle arp monitoring in load-balancing mode; - * it is a lot more compact now - * - Changes to ensure one and only one slave transmits in active-backup - * mode - * - Robustesize parameters; warn users about bad combinations of - * parameters; also if miimon is specified and a network driver does - * not support MII or ETHTOOL, inform the user of this - * - Changes to support link_failure_count when in arp monitoring mode - * - Fix up/down delay reported in /proc - * - Added version; log version; make version available from "modinfo -d" - * - Fixed problem in bond_check_dev_link - if the first IOCTL (SIOCGMIIPH) - * failed, the ETHTOOL ioctl never got a chance - * - * 2002/11/16 - Laurent Deniel - * - fix multicast handling in activebackup_arp_monitor - * - remove one unnecessary and confusing curr_active_slave == slave test - * in activebackup_arp_monitor - * - * 2002/11/17 - Laurent Deniel - * - fix bond_slave_info_query when slave_id = num_slaves - * - * 2002/11/19 - Janice Girouard - * - correct ifr_data reference. Update ifr_data reference - * to mii_ioctl_data struct values to avoid confusion. - * - * 2002/11/22 - Bert Barbe - * - Add support for multiple arp_ip_target - * - * 2002/12/13 - Jay Vosburgh - * - Changed to allow text strings for mode and multicast, e.g., - * insmod bonding mode=active-backup. The numbers still work. - * One change: an invalid choice will cause module load failure, - * rather than the previous behavior of just picking one. - * - Minor cleanups; got rid of dup ctype stuff, atoi function - * - * 2003/02/07 - Jay Vosburgh - * - Added use_carrier module parameter that causes miimon to - * use netif_carrier_ok() test instead of MII/ETHTOOL ioctls. - * - Minor cleanups; consolidated ioctl calls to one function. - * - * 2003/02/07 - Tony Cureington - * - Fix bond_mii_monitor() logic error that could result in - * bonding round-robin mode ignoring links after failover/recovery - * - * 2003/03/17 - Jay Vosburgh - * - kmalloc fix (GFP_KERNEL to GFP_ATOMIC) reported by - * Shmulik dot Hen at intel.com. - * - Based on discussion on mailing list, changed use of - * update_slave_cnt(), created wrapper functions for adding/removing - * slaves, changed bond_xmit_xor() to check slave_cnt instead of - * checking slave and slave->dev (which only worked by accident). - * - Misc code cleanup: get arp_send() prototype from header file, - * add max_bonds to bonding.txt. - * - * 2003/03/18 - Tsippy Mendelson and - * Shmulik Hen - * - Make sure only bond_attach_slave() and bond_detach_slave() can - * manipulate the slave list, including slave_cnt, even when in - * bond_release_all(). - * - Fixed hang in bond_release() with traffic running: - * netdev_set_master() must not be called from within the bond lock. - * - * 2003/03/18 - Tsippy Mendelson and - * Shmulik Hen - * - Fixed hang in bond_enslave() with traffic running: - * netdev_set_master() must not be called from within the bond lock. - * - * 2003/03/18 - Amir Noam - * - Added support for getting slave's speed and duplex via ethtool. - * Needed for 802.3ad and other future modes. - * - * 2003/03/18 - Tsippy Mendelson and - * Shmulik Hen - * - Enable support of modes that need to use the unique mac address of - * each slave. - * * bond_enslave(): Moved setting the slave's mac address, and - * openning it, from the application to the driver. This breaks - * backward comaptibility with old versions of ifenslave that open - * the slave before enalsving it !!!. - * * bond_release(): The driver also takes care of closing the slave - * and restoring its original mac address. - * - Removed the code that restores all base driver's flags. - * Flags are automatically restored once all undo stages are done - * properly. - * - Block possibility of enslaving before the master is up. This - * prevents putting the system in an unstable state. - * - * 2003/03/18 - Amir Noam , - * Tsippy Mendelson and - * Shmulik Hen - * - Added support for IEEE 802.3ad Dynamic link aggregation mode. - * - * 2003/05/01 - Amir Noam - * - Added ABI version control to restore compatibility between - * new/old ifenslave and new/old bonding. - * - * 2003/05/01 - Shmulik Hen - * - Fixed bug in bond_release_all(): save old value of curr_active_slave - * before setting it to NULL. - * - Changed driver versioning scheme to include version number instead - * of release date (that is already in another field). There are 3 - * fields X.Y.Z where: - * X - Major version - big behavior changes - * Y - Minor version - addition of features - * Z - Extra version - minor changes and bug fixes - * The current version is 1.0.0 as a base line. - * - * 2003/05/01 - Tsippy Mendelson and - * Amir Noam - * - Added support for lacp_rate module param. - * - Code beautification and style changes (mainly in comments). - * new version - 1.0.1 - * - * 2003/05/01 - Shmulik Hen - * - Based on discussion on mailing list, changed locking scheme - * to use lock/unlock or lock_bh/unlock_bh appropriately instead - * of lock_irqsave/unlock_irqrestore. The new scheme helps exposing - * hidden bugs and solves system hangs that occurred due to the fact - * that holding lock_irqsave doesn't prevent softirqs from running. - * This also increases total throughput since interrupts are not - * blocked on each transmitted packets or monitor timeout. - * new version - 2.0.0 - * - * 2003/05/01 - Shmulik Hen - * - Added support for Transmit load balancing mode. - * - Concentrate all assignments of curr_active_slave to a single point - * so specific modes can take actions when the primary adapter is - * changed. - * - Take the updelay parameter into consideration during bond_enslave - * since some adapters loose their link during setting the device. - * - Renamed bond_3ad_link_status_changed() to - * bond_3ad_handle_link_change() for compatibility with TLB. - * new version - 2.1.0 - * - * 2003/05/01 - Tsippy Mendelson - * - Added support for Adaptive load balancing mode which is - * equivalent to Transmit load balancing + Receive load balancing. - * new version - 2.2.0 - * - * 2003/05/15 - Jay Vosburgh - * - Applied fix to activebackup_arp_monitor posted to bonding-devel - * by Tony Cureington . Fixes ARP - * monitor endless failover bug. Version to 2.2.10 - * - * 2003/05/20 - Amir Noam - * - Fixed bug in ABI version control - Don't commit to a specific - * ABI version if receiving unsupported ioctl commands. - * - * 2003/05/22 - Jay Vosburgh - * - Fix ifenslave -c causing bond to loose existing routes; - * added bond_set_mac_address() that doesn't require the - * bond to be down. - * - In conjunction with fix for ifenslave -c, in - * bond_change_active(), changing to the already active slave - * is no longer an error (it successfully does nothing). - * - * 2003/06/30 - Amir Noam - * - Fixed bond_change_active() for ALB/TLB modes. - * Version to 2.2.14. - * - * 2003/07/29 - Amir Noam - * - Fixed ARP monitoring bug. - * Version to 2.2.15. - * - * 2003/07/31 - Willy Tarreau - * - Fixed kernel panic when using ARP monitoring without - * setting bond's IP address. - * Version to 2.2.16. - * - * 2003/08/06 - Amir Noam - * - Back port from 2.6: use alloc_netdev(); fix /proc handling; - * made stats a part of bond struct so no need to allocate - * and free it separately; use standard list operations instead - * of pre-allocated array of bonds. - * Version to 2.3.0. - * - * 2003/08/07 - Jay Vosburgh , - * Amir Noam and - * Shmulik Hen - * - Propagating master's settings: Distinguish between modes that - * use a primary slave from those that don't, and propagate settings - * accordingly; Consolidate change_active opeartions and add - * reselect_active and find_best opeartions; Decouple promiscuous - * handling from the multicast mode setting; Add support for changing - * HW address and MTU with proper unwind; Consolidate procfs code, - * add CHANGENAME handler; Enhance netdev notification handling. - * Version to 2.4.0. - * - * 2003/09/15 - Stephen Hemminger , - * Amir Noam - * - Convert /proc to seq_file interface. - * Change /proc/net/bondX/info to /proc/net/bonding/bondX. - * Set version to 2.4.1. - * - * 2003/11/20 - Amir Noam - * - Fix /proc creation/destruction. - * - * 2003/12/01 - Shmulik Hen - * - Massive cleanup - Set version to 2.5.0 - * Code changes: - * o Consolidate format of prints and debug prints. - * o Remove bonding_t/slave_t typedefs and consolidate all casts. - * o Remove dead code and unnecessary checks. - * o Consolidate starting/stopping timers. - * o Consolidate handling of primary module param throughout the code. - * o Removed multicast module param support - all settings are done - * according to mode. - * o Slave list iteration - bond is no longer part of the list, - * added cyclic list iteration macros. - * o Consolidate error handling in all xmit functions. - * Style changes: - * o Consolidate function naming and declarations. - * o Consolidate function params and local variables names. - * o Consolidate return values. - * o Consolidate curly braces. - * o Consolidate conditionals format. - * o Change struct member names and types. - * o Chomp trailing spaces, remove empty lines, fix indentations. - * o Re-organize code according to context. - * - * 2003/12/30 - Amir Noam - * - Fixed: Cannot remove and re-enslave the original active slave. - * - Fixed: Releasing the original active slave causes mac address - * duplication. - * - Add support for slaves that use ethtool_ops. - * Set version to 2.5.3. - * - * 2004/01/05 - Amir Noam - * - Save bonding parameters per bond instead of using the global values. - * Set version to 2.5.4. - * - * 2004/01/14 - Shmulik Hen - * - Enhance VLAN support: - * * Add support for VLAN hardware acceleration capable slaves. - * * Add capability to tag self generated packets in ALB/TLB modes. - * Set version to 2.6.0. - * 2004/10/29 - Mitch Williams - * - Fixed bug when unloading module while using 802.3ad. If - * spinlock debugging is turned on, this causes a stack dump. - * Solution is to move call to dev_remove_pack outside of the - * spinlock. - * Set version to 2.6.1. - * 2005/06/05 - Jay Vosburgh - * - Support for generating gratuitous ARPs in active-backup mode. - * Includes support for VLAN tagging all bonding-generated ARPs - * as needed. Set version to 2.6.2. - * 2005/06/08 - Jason Gabler - * - alternate hashing policy support for mode 2 - * * Added kernel parameter "xmit_hash_policy" to allow the selection - * of different hashing policies for mode 2. The original mode 2 - * policy is the default, now found in xmit_hash_policy_layer2(). - * * Added xmit_hash_policy_layer34() - * - Modified by Jay Vosburgh to also support mode 4. - * Set version to 2.6.3. - * 2005/09/26 - Jay Vosburgh - * - Removed backwards compatibility for old ifenslaves. Version 2.6.4. - * 2005/09/27 - Mitch Williams - * - Radheka Godse - * - Split out bond creation code to allow for sysfs interface. - * - Removed static declaration on some functions and data items. - * - Added sysfs support, including capability to add/remove/change - * any bond at runtime. - * - * - Miscellaneous: - * - Added bonding: : prefix to sysfs log messages - * - Added arp_ip_targets to /proc entry - * - Allow ARP target table to have empty entries - * - trivial fix: added missing modes description to modinfo - * - Corrected bug in ALB init where kmalloc is called inside - * a held lock - * - Corrected behavior to maintain bond link when changing - * from arp monitor to miimon and vice versa - * - Added missing bonding: : prefix to alb, ad log messages - * - Fixed stack dump warnings seen if changing between miimon - * and arp monitoring when the bond interface is down. - * - Fixed stack dump warnings seen when enslaving an e100 - * driver - * - Set version to 3.0.0 */ //#define BONDING_DEBUG 1 diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index c5f1c52..32d13da 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -19,47 +19,6 @@ * The full GNU General Public License is included in this distribution in the * file called LICENSE. * - * - * Changes: - * - * 2004/12/12 - Mitch Williams - * - Initial creation of sysfs interface. - * - * 2005/06/22 - Radheka Godse - * - Added ifenslave -c type functionality to sysfs - * - Added sysfs files for attributes such as MII Status and - * 802.3ad aggregator that are displayed in /proc - * - Added "name value" format to sysfs "mode" and - * "lacp_rate", for e.g., "active-backup 1" or "slow 0" for - * consistency and ease of script parsing - * - Fixed reversal of octets in arp_ip_targets via sysfs - * - sysfs support to handle bond interface re-naming - * - Moved all sysfs entries into /sys/class/net instead of - * of using a standalone subsystem. - * - Added sysfs symlinks between masters and slaves - * - Corrected bugs in sysfs unload path when creating bonds - * with existing interface names. - * - Removed redundant sysfs stat file since it duplicates slave info - * from the proc file - * - Fixed errors in sysfs show/store arp targets. - * - For consistency with ifenslave, instead of exiting - * with an error, updated bonding sysfs to - * close and attempt to enslave an up adapter. - * - Fixed NULL dereference when adding a slave interface - * that does not exist. - * - Added checks in sysfs bonding to reject invalid ip addresses - * - Synch up with post linux-2.6.12 bonding changes - * - Created sysfs bond attrib for xmit_hash_policy - * - * 2005/09/19 - Mitch Williams - * - Changed semantics of multi-item files to be command-based - * instead of list-based. - * - Changed ARP target handler to use in_aton instead of sscanf - * - Style changes. - * 2005/09/27 - Mitch Williams - * - Made line endings consistent. - * - Removed "none" from primary output - just put blank instead - * - Fixed bug with long interface names */ #include #include diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index d6d0854..015c7f1 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h @@ -10,29 +10,6 @@ * This software may be used and distributed according to the terms * of the GNU Public License, incorporated herein by reference. * - * - * 2003/03/18 - Amir Noam , - * Tsippy Mendelson and - * Shmulik Hen - * - Added support for IEEE 802.3ad Dynamic link aggregation mode. - * - * 2003/05/01 - Tsippy Mendelson and - * Amir Noam - * - Code beautification and style changes (mainly in comments). - * - * 2003/05/01 - Shmulik Hen - * - Added support for Transmit load balancing mode. - * - * 2003/12/01 - Shmulik Hen - * - Code cleanup and style changes - * - * 2005/05/05 - Jason Gabler - * - added "xmit_policy" kernel parameter for alternate hashing policy - * support for mode 2 - * - * 2005/09/27 - Mitch Williams - * Radheka Godse - * - Added bonding sysfs interface */ #ifndef _LINUX_BONDING_H -- cgit v1.1 From 019a61b99338d0ac05de25317b85da88e7ec4b35 Mon Sep 17 00:00:00 2001 From: "Langsdorf, Mark" Date: Tue, 29 Nov 2005 14:18:03 -0600 Subject: [PATCH] Support 100 MHz frequency transitions Future versions of the Opteron processor may support frequency transitions of 100 MHz, instead of the=20 current 200 MHz. This patch enables the powernow-k8 driver to transition to an odd FID code, indicating a multiple of 100 MHz frequency. Signed-off-by: Jacob Shin Signed-off-by: Mark Langsdorf Signed-off-by: Dave Jones --- arch/i386/kernel/cpu/cpufreq/powernow-k8.c | 17 +++++++---------- arch/i386/kernel/cpu/cpufreq/powernow-k8.h | 9 +++++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c index 3497827..a342b32 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c @@ -45,7 +45,7 @@ #define PFX "powernow-k8: " #define BFX PFX "BIOS error: " -#define VERSION "version 1.50.5" +#define VERSION "version 1.60.0" #include "powernow-k8.h" /* serialize freq changes */ @@ -336,7 +336,7 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data, u32 reqvid /* Phase 2 - core frequency transition */ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) { - u32 vcoreqfid, vcocurrfid, vcofiddiff, savevid = data->currvid; + u32 vcoreqfid, vcocurrfid, vcofiddiff, fid_interval, savevid = data->currvid; if ((reqfid < HI_FID_TABLE_BOTTOM) && (data->currfid < HI_FID_TABLE_BOTTOM)) { printk(KERN_ERR PFX "ph2: illegal lo-lo transition 0x%x 0x%x\n", @@ -359,9 +359,11 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) : vcoreqfid - vcocurrfid; while (vcofiddiff > 2) { + (data->currfid & 1) ? (fid_interval = 1) : (fid_interval = 2); + if (reqfid > data->currfid) { if (data->currfid > LO_FID_TABLE_TOP) { - if (write_new_fid(data, data->currfid + 2)) { + if (write_new_fid(data, data->currfid + fid_interval)) { return 1; } } else { @@ -371,7 +373,7 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid) } } } else { - if (write_new_fid(data, data->currfid - 2)) + if (write_new_fid(data, data->currfid - fid_interval)) return 1; } @@ -474,7 +476,7 @@ static int check_supported_cpu(unsigned int cpu) eax = cpuid_eax(CPUID_PROCESSOR_SIGNATURE); if (((eax & CPUID_USE_XFAM_XMOD) != CPUID_USE_XFAM_XMOD) || ((eax & CPUID_XFAM) != CPUID_XFAM_K8) || - ((eax & CPUID_XMOD) > CPUID_XMOD_REV_F)) { + ((eax & CPUID_XMOD) > CPUID_XMOD_REV_G)) { printk(KERN_INFO PFX "Processor cpuid %x not supported\n", eax); goto out; } @@ -521,10 +523,6 @@ static int check_pst_table(struct powernow_k8_data *data, struct pst_s *pst, u8 printk(KERN_ERR BFX "maxfid exceeded with pstate %d\n", j); return -ENODEV; } - if (pst[j].fid & 1) { - printk(KERN_ERR BFX "fid invalid - %d : 0x%x\n", j, pst[j].fid); - return -EINVAL; - } if (j && (pst[j].fid < HI_FID_TABLE_BOTTOM)) { /* Only first fid is allowed to be in "low" range */ printk(KERN_ERR BFX "two low fids - %d : 0x%x\n", j, pst[j].fid); @@ -1177,4 +1175,3 @@ MODULE_LICENSE("GPL"); late_initcall(powernowk8_init); module_exit(powernowk8_exit); - diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h index b1e85bb..d0de37d 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.h +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.h @@ -42,7 +42,7 @@ struct powernow_k8_data { #define CPUID_XFAM 0x0ff00000 /* extended family */ #define CPUID_XFAM_K8 0 #define CPUID_XMOD 0x000f0000 /* extended model */ -#define CPUID_XMOD_REV_F 0x00040000 +#define CPUID_XMOD_REV_G 0x00060000 #define CPUID_USE_XFAM_XMOD 0x00000f00 #define CPUID_GET_MAX_CAPABILITIES 0x80000000 #define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007 @@ -86,13 +86,14 @@ struct powernow_k8_data { * low fid table * - lowest entry in the high fid table must be a <= 200MHz + 2 * the entry * in the low fid table - * - the parts can only step at 200 MHz intervals, so 1.9 GHz is never valid + * - the parts can only step at <= 200 MHz intervals, odd fid values are + * supported in revision G and later revisions. * - lowest frequency must be >= interprocessor hypertransport link speed * (only applies to MP systems obviously) */ /* fids (frequency identifiers) are arranged in 2 tables - lo and hi */ -#define LO_FID_TABLE_TOP 6 /* fid values marking the boundary */ +#define LO_FID_TABLE_TOP 7 /* fid values marking the boundary */ #define HI_FID_TABLE_BOTTOM 8 /* between the low and high tables */ #define LO_VCOFREQ_TABLE_TOP 1400 /* corresponding vco frequency values */ @@ -106,7 +107,7 @@ struct powernow_k8_data { #define MIN_FREQ 800 /* Min and max freqs, per spec */ #define MAX_FREQ 5000 -#define INVALID_FID_MASK 0xffffffc1 /* not a valid fid if these bits are set */ +#define INVALID_FID_MASK 0xffffffc0 /* not a valid fid if these bits are set */ #define INVALID_VID_MASK 0xffffffc0 /* not a valid vid if these bits are set */ #define VID_OFF 0x3f -- cgit v1.1 From 6df8900676c3f5c133328332fb8ad889fd0cc9e3 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Wed, 30 Nov 2005 13:33:30 -0800 Subject: [CPUFREQ] Fix indentation in powernow-k8 Signed-off-by: Dave Jones --- arch/i386/kernel/cpu/cpufreq/powernow-k8.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c index a342b32..f44c1b1 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c @@ -216,10 +216,10 @@ static int write_new_vid(struct powernow_k8_data *data, u32 vid) do { wrmsr(MSR_FIDVID_CTL, lo, STOP_GRANT_5NS); - if (i++ > 100) { - printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n"); - return 1; - } + if (i++ > 100) { + printk(KERN_ERR PFX "internal error - pending bit very stuck - no further pstate changes possible\n"); + return 1; + } } while (query_current_values_with_pending_wait(data)); if (savefid != data->currfid) { -- cgit v1.1 From 6c9e5eb522bca694a0311898039d2707e9bc7783 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Wed, 30 Nov 2005 16:42:55 -0500 Subject: [libata sata_promise] minor whitespace cleanup --- drivers/scsi/sata_promise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 8a8e3e3..25e56fb 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c @@ -703,7 +703,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e probe_ent->port[3].scr_addr = base + 0x700; break; case board_2037x: - probe_ent->n_ports = 2; + probe_ent->n_ports = 2; break; case board_20619: probe_ent->n_ports = 4; @@ -713,7 +713,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e probe_ent->port[2].scr_addr = base + 0x600; probe_ent->port[3].scr_addr = base + 0x700; - break; + break; default: BUG(); break; -- cgit v1.1 From 214376434863f9ca109a7853fbbd6db284d3fba7 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:11 -0800 Subject: [PATCH] sky2: eliminate special case for EC-A1 Eliminate special case for EC-A1. The overhead isn't so great that having config option is worth it. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/Kconfig | 7 ------- drivers/net/sky2.c | 8 ++------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index fca6000..0f2e4c1 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2022,13 +2022,6 @@ config SKY2 To compile this driver as a module, choose M here: the module will be called sky2. This is recommended. -config SKY2_EC_A1 - bool "Support old Yukon-EC A1 chipset" - depends on SKY2 - ---help--- - Include support for early revisions of the Yukon EC chipset - that required extra workarounds. If in doubt, say N. - config SK98LIN tristate "Marvell Yukon Chipset / SysKonnect SK-98xx Support" depends on PCI diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 9f89000..d7a94d6 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -67,13 +67,9 @@ * a receive requires one (or two if using 64 bit dma). */ -#ifdef CONFIG_SKY2_EC_A1 #define is_ec_a1(hw) \ - ((hw)->chip_id == CHIP_ID_YUKON_EC && \ - (hw)->chip_rev == CHIP_REV_YU_EC_A1) -#else -#define is_ec_a1(hw) 0 -#endif + unlikely((hw)->chip_id == CHIP_ID_YUKON_EC && \ + (hw)->chip_rev == CHIP_REV_YU_EC_A1) #define RX_LE_SIZE 256 #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) -- cgit v1.1 From ef743d3359813795fb38c4308bff2311eb30651f Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:12 -0800 Subject: [PATCH] sky2: add MII support Add MII ioctl interface to sky2. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index d7a94d6..0b9b701 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -47,6 +47,7 @@ #include #include #include +#include #include @@ -136,7 +137,7 @@ static const char *yukon_name[] = { /* Access to external PHY */ -static void gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) +static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) { int i; @@ -146,13 +147,15 @@ static void gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) for (i = 0; i < PHY_RETRIES; i++) { if (!(gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY)) - return; + return 0; udelay(1); } + printk(KERN_WARNING PFX "%s: phy write timeout\n", hw->dev[port]->name); + return -ETIMEDOUT; } -static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) +static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val) { int i; @@ -160,14 +163,24 @@ static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD); for (i = 0; i < PHY_RETRIES; i++) { - if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) - goto ready; + if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) { + *val = gma_read16(hw, port, GM_SMI_DATA); + return 0; + } + udelay(1); } - printk(KERN_WARNING PFX "%s: phy read timeout\n", hw->dev[port]->name); -ready: - return gma_read16(hw, port, GM_SMI_DATA); + return -ETIMEDOUT; +} + +static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg) +{ + u16 v; + + if (__gm_phy_read(hw, port, reg, &v) != 0) + printk(KERN_WARNING PFX "%s: phy read timeout\n", hw->dev[port]->name); + return v; } static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state) @@ -792,6 +805,44 @@ static void sky2_rx_clean(struct sky2_port *sky2) } } +/* Basic MII support */ +static int sky2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +{ + struct mii_ioctl_data *data = if_mii(ifr); + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + int err = -EOPNOTSUPP; + + if (!netif_running(dev)) + return -ENODEV; /* Phy still in reset */ + + switch(cmd) { + case SIOCGMIIPHY: + data->phy_id = PHY_ADDR_MARV; + + /* fallthru */ + case SIOCGMIIREG: { + u16 val = 0; + spin_lock_bh(&hw->phy_lock); + err = __gm_phy_read(hw, sky2->port, data->reg_num & 0x1f, &val); + spin_unlock_bh(&hw->phy_lock); + data->val_out = val; + break; + } + + case SIOCSMIIREG: + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + + spin_lock_bh(&hw->phy_lock); + err = gm_phy_write(hw, sky2->port, data->reg_num & 0x1f, + data->val_in); + spin_unlock_bh(&hw->phy_lock); + break; + } + return err; +} + #ifdef SKY2_VLAN_TAG_USED static void sky2_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) { @@ -2708,8 +2759,10 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, SET_MODULE_OWNER(dev); SET_NETDEV_DEV(dev, &hw->pdev->dev); + dev->irq = hw->pdev->irq; dev->open = sky2_up; dev->stop = sky2_down; + dev->do_ioctl = sky2_ioctl; dev->hard_start_xmit = sky2_xmit_frame; dev->get_stats = sky2_get_stats; dev->set_multicast_list = sky2_set_multicast; -- cgit v1.1 From 42eeea0145a1c7570624ddeaa15d3f357a52edf8 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:13 -0800 Subject: [PATCH] sky2: fix receive flush/pause issues Fix issues with pause and flush. This code works on all chip versions tested. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 0b9b701..83361ae 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -485,8 +485,8 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) int i; const u8 *addr = hw->dev[port]->dev_addr; - sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); - sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR); + sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET); + sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR|GPC_ENA_PAUSE); sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR); @@ -589,11 +589,8 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) GMF_RX_CTRL_DEF); /* Flush Rx MAC FIFO on any flow control or error */ - reg = GMR_FS_ANY_ERR; - if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev <= 1) - reg = 0; /* WA dev #4.115 */ + sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR); - sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), reg); /* Set threshold to 0xa (64 bytes) * ASF disabled so no need to do WA dev #4.30 */ @@ -1363,9 +1360,6 @@ static void sky2_link_up(struct sky2_port *sky2) unsigned port = sky2->port; u16 reg; - /* disable Rx GMAC FIFO flush mode */ - sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RX_F_FL_OFF); - /* Enable Transmit FIFO Underrun */ sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), GMAC_DEF_MSK); @@ -1611,9 +1605,12 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending; - if (!(status & GMR_FS_RX_OK) || (status & GMR_FS_ANY_ERR)) + if (status & GMR_FS_ANY_ERR) goto error; + if (!(status & GMR_FS_RX_OK)) + goto resubmit; + if (length < RX_COPY_THRESHOLD) { skb = alloc_skb(length + 2, GFP_ATOMIC); if (!skb) @@ -1662,9 +1659,6 @@ resubmit: return skb; error: - if (status & GMR_FS_GOOD_FC) - goto resubmit; - if (netif_msg_rx_err(sky2)) printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n", sky2->netdev->name, status, length); -- cgit v1.1 From 13210ce5c06ed9537558b85e9c0df4248b28f1f7 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:14 -0800 Subject: [PATCH] sky2: improve receive performance Changes to receive side processing: * bigger receive ring * clean up polling loop Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 66 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 83361ae..e6f71c1 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -72,10 +72,10 @@ unlikely((hw)->chip_id == CHIP_ID_YUKON_EC && \ (hw)->chip_rev == CHIP_REV_YU_EC_A1) -#define RX_LE_SIZE 256 +#define RX_LE_SIZE 512 #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) #define RX_MAX_PENDING (RX_LE_SIZE/2 - 2) -#define RX_DEF_PENDING 128 +#define RX_DEF_PENDING RX_MAX_PENDING #define RX_COPY_THRESHOLD 256 #define TX_RING_SIZE 512 @@ -1596,7 +1596,6 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, { struct ring_info *re = sky2->rx_ring + sky2->rx_next; struct sk_buff *skb = NULL; - struct net_device *dev; const unsigned int bufsize = rx_size(sky2); if (unlikely(netif_msg_rx_status(sky2))) @@ -1643,11 +1642,6 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, } skb_put(skb, length); - dev = sky2->netdev; - skb->dev = dev; - skb->protocol = eth_type_trans(skb, dev); - dev->last_rx = jiffies; - resubmit: re->skb->ip_summed = CHECKSUM_NONE; sky2_rx_add(sky2, re); @@ -1702,35 +1696,42 @@ static int sky2_poll(struct net_device *dev0, int *budget) BUG_ON(hwidx >= STATUS_RING_SIZE); rmb(); - do { - struct sky2_status_le *le = hw->st_le + hw->st_idx; + while (hwidx != hw->st_idx) { + struct sky2_status_le *le = hw->st_le + hw->st_idx; + struct net_device *dev; struct sky2_port *sky2; struct sk_buff *skb; u32 status; u16 length; + u8 op; - /* Are we done yet? */ - if (hw->st_idx == hwidx) { - sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); - hwidx = sky2_read16(hw, STAT_PUT_IDX); - if (hwidx == hw->st_idx) - break; - } - + le = hw->st_le + hw->st_idx; hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; - prefetch(&hw->st_le[hw->st_idx]); + prefetch(hw->st_le + hw->st_idx); BUG_ON(le->link >= hw->ports || !hw->dev[le->link]); - sky2 = netdev_priv(hw->dev[le->link]); + BUG_ON(le->link >= 2); + dev = hw->dev[le->link]; + if (dev == NULL || !netif_running(dev)) + continue; + + sky2 = netdev_priv(dev); status = le32_to_cpu(le->status); length = le16_to_cpu(le->length); + op = le->opcode & ~HW_OWNER; + le->opcode = 0; - switch (le->opcode & ~HW_OWNER) { + switch (op) { case OP_RXSTAT: skb = sky2_receive(sky2, length, status); if (!skb) break; + + skb->dev = dev; + skb->protocol = eth_type_trans(skb, dev); + dev->last_rx = jiffies; + #ifdef SKY2_VLAN_TAG_USED if (sky2->vlgrp && (status & GMR_FS_VLAN)) { vlan_hwaccel_receive_skb(skb, @@ -1739,7 +1740,9 @@ static int sky2_poll(struct net_device *dev0, int *budget) } else #endif netif_receive_skb(skb); - ++work_done; + + if (++work_done >= to_do) + goto exit_loop; break; #ifdef SKY2_VLAN_TAG_USED @@ -1765,18 +1768,15 @@ static int sky2_poll(struct net_device *dev0, int *budget) default: if (net_ratelimit()) printk(KERN_WARNING PFX - "unknown status opcode 0x%x\n", - le->opcode); + "unknown status opcode 0x%x\n", op); break; } + } - le->opcode = 0; /* paranoia */ - } while (work_done < to_do); +exit_loop: mmiowb(); - *budget -= work_done; - dev0->quota -= work_done; if (work_done < to_do) { /* * Another chip workaround, need to restart TX timer if status @@ -1790,11 +1790,13 @@ static int sky2_poll(struct net_device *dev0, int *budget) netif_rx_complete(dev0); hw->intr_mask |= Y2_IS_STAT_BMU; sky2_write32(hw, B0_IMSK, hw->intr_mask); - sky2_read32(hw, B0_IMSK); + mmiowb(); + return 0; + } else { + *budget -= work_done; + dev0->quota -= work_done; + return 1; } - - return work_done >= to_do; - } static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status) -- cgit v1.1 From 5a5b1ea026572ac0e5e03d7322deb546d60f9e6e Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:15 -0800 Subject: [PATCH] sky2: add Yukon-EC ultra support Add support for Yukon-EC Ultra chip as implemented in SysKonnect's driver version 8.26. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 27 ++++++++++++++++++++++++++- drivers/net/sky2.h | 9 +++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index e6f71c1..aff347f 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -114,9 +114,11 @@ static const struct pci_device_id sky2_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) }, { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, { 0 } }; @@ -130,6 +132,7 @@ static const char *yukon_name[] = { [CHIP_ID_YUKON_LITE - CHIP_ID_YUKON] = "Lite", /* 0xb0 */ [CHIP_ID_YUKON_LP - CHIP_ID_YUKON] = "LP", /* 0xb2 */ [CHIP_ID_YUKON_XL - CHIP_ID_YUKON] = "XL", /* 0xb3 */ + [CHIP_ID_YUKON_EC_U - CHIP_ID_YUKON] = "EC Ultra", /* 0xb4 */ [CHIP_ID_YUKON_EC - CHIP_ID_YUKON] = "EC", /* 0xb6 */ [CHIP_ID_YUKON_FE - CHIP_ID_YUKON] = "FE", /* 0xb7 */ @@ -599,6 +602,18 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) /* Configure Tx MAC FIFO */ sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR); sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON); + + if (hw->chip_id == CHIP_ID_YUKON_EC_U) { + sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8); + sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8); + if (hw->dev[port]->mtu > ETH_DATA_LEN) { + /* set Tx GMAC FIFO Almost Empty Threshold */ + sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR), 0x180); + /* Disable Store & Forward mode for TX */ + sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_DIS); + } + } + } static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) @@ -984,6 +999,10 @@ static int sky2_up(struct net_device *dev) RB_RST_SET); sky2_qset(hw, txqaddr[port], 0x600); + if (hw->chip_id == CHIP_ID_YUKON_EC_U) + sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0); + + sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map, TX_RING_SIZE - 1); @@ -1553,6 +1572,9 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) return -EINVAL; + if (hw->chip_id == CHIP_ID_YUKON_EC_U && new_mtu > ETH_DATA_LEN) + return -EINVAL; + if (!netif_running(dev)) { dev->mtu = new_mtu; return 0; @@ -1972,6 +1994,7 @@ static inline u32 sky2_khz(const struct sky2_hw *hw) { switch (hw->chip_id) { case CHIP_ID_YUKON_EC: + case CHIP_ID_YUKON_EC_U: return 125000; /* 125 Mhz */ case CHIP_ID_YUKON_FE: return 100000; /* 100 Mhz */ @@ -2796,7 +2819,9 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, sky2->port = port; - dev->features |= NETIF_F_LLTX | NETIF_F_TSO; + dev->features |= NETIF_F_LLTX; + if (hw->chip_id != CHIP_ID_YUKON_EC_U) + dev->features |= NETIF_F_TSO; if (highmem) dev->features |= NETIF_F_HIGHDMA; dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 629d08f..f836b03 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -309,7 +309,7 @@ enum { Y2_IS_PAR_RX2 | Y2_IS_TCP_TXS2| Y2_IS_TCP_TXA2, Y2_HWE_ALL_MASK = Y2_IS_TIST_OV | Y2_IS_MST_ERR | Y2_IS_IRQ_STAT | - Y2_IS_PCI_EXP | Y2_IS_PCI_NEXP | + Y2_IS_PCI_EXP | Y2_HWE_L1_MASK | Y2_HWE_L2_MASK, }; @@ -346,6 +346,7 @@ enum { CHIP_ID_YUKON_LITE = 0xb1, /* Chip ID for YUKON-Lite (Rev. A1-A3) */ CHIP_ID_YUKON_LP = 0xb2, /* Chip ID for YUKON-LP */ CHIP_ID_YUKON_XL = 0xb3, /* Chip ID for YUKON-2 XL */ + CHIP_ID_YUKON_EC_U = 0xb4, /* Chip ID for YUKON-2 EC Ultra */ CHIP_ID_YUKON_EC = 0xb6, /* Chip ID for YUKON-2 EC */ CHIP_ID_YUKON_FE = 0xb7, /* Chip ID for YUKON-2 FE */ @@ -579,7 +580,8 @@ enum { RX_GMF_FL_MSK = 0x0c4c,/* 32 bit Rx GMAC FIFO Flush Mask */ RX_GMF_FL_THR = 0x0c50,/* 32 bit Rx GMAC FIFO Flush Threshold */ RX_GMF_TR_THR = 0x0c54,/* 32 bit Rx Truncation Threshold (Yukon-2) */ - + RX_GMF_UP_THR = 0x0c58,/* 8 bit Rx Upper Pause Thr (Yukon-EC_U) */ + RX_GMF_LP_THR = 0x0c5a,/* 8 bit Rx Lower Pause Thr (Yukon-EC_U) */ RX_GMF_VLAN = 0x0c5c,/* 32 bit Rx VLAN Type Register (Yukon-2) */ RX_GMF_WP = 0x0c60,/* 32 bit Rx GMAC FIFO Write Pointer */ @@ -1557,6 +1559,9 @@ enum { /* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */ enum { + TX_STFW_DIS = 1<<31,/* Disable Store & Forward (Yukon-EC Ultra) */ + TX_STFW_ENA = 1<<30,/* Enable Store & Forward (Yukon-EC Ultra) */ + TX_VLAN_TAG_ON = 1<<25,/* enable VLAN tagging */ TX_VLAN_TAG_OFF = 1<<24,/* disable VLAN tagging */ -- cgit v1.1 From a018e3305fe1e500e28830666b1757b75c6b4df5 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:16 -0800 Subject: [PATCH] sky2: handle DMA boundary crossing Handle the case of DMA spanning 32 bit boundary. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index aff347f..2253140 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -723,11 +723,17 @@ static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2) return le; } +/* Return high part of DMA address (could be 32 or 64 bit) */ +static inline u32 high32(dma_addr_t a) +{ + return (a >> 16) >> 16; +} + /* Build description to hardware about buffer */ static inline void sky2_rx_add(struct sky2_port *sky2, struct ring_info *re) { struct sky2_rx_le *le; - u32 hi = (re->mapaddr >> 16) >> 16; + u32 hi = high32(re->mapaddr); re->idx = sky2->rx_put; if (sky2->rx_addr64 != hi) { @@ -735,7 +741,7 @@ static inline void sky2_rx_add(struct sky2_port *sky2, struct ring_info *re) le->addr = cpu_to_le32(hi); le->ctrl = 0; le->opcode = OP_ADDR64 | HW_OWNER; - sky2->rx_addr64 = hi; + sky2->rx_addr64 = high32(re->mapaddr + re->maplen); } le = sky2_next_rx(sky2); @@ -1100,17 +1106,17 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) len = skb_headlen(skb); mapping = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE); - addr64 = (mapping >> 16) >> 16; + addr64 = high32(mapping); re = sky2->tx_ring + sky2->tx_prod; - /* Send high bits if changed */ - if (addr64 != sky2->tx_addr64) { + /* Send high bits if changed or crosses boundary */ + if (addr64 != sky2->tx_addr64 || high32(mapping + len) != sky2->tx_addr64) { le = get_tx_le(sky2); le->tx.addr = cpu_to_le32(addr64); le->ctrl = 0; le->opcode = OP_ADDR64 | HW_OWNER; - sky2->tx_addr64 = addr64; + sky2->tx_addr64 = high32(mapping + len); } /* Check for TCP Segmentation Offload */ -- cgit v1.1 From 0a1225769763779288d759e904c4f5a660844ce4 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:17 -0800 Subject: [PATCH] sky2: change netif_rx_schedule_test to __netif_schedule_prep I didn't like the name netif_rx_schedule_test(), in earlier patches and changed to __netif_rx_schedule_prep to be more consistent. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 5 +++-- include/linux/netdevice.h | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 2253140..f56de98 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1961,10 +1961,11 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs) if (status & Y2_IS_STAT_BMU) { hw->intr_mask &= ~Y2_IS_STAT_BMU; sky2_write32(hw, B0_IMSK, hw->intr_mask); - prefetch(&hw->st_le[hw->st_idx]); - if (netif_rx_schedule_test(dev0)) + if (likely(__netif_rx_schedule_prep(dev0))) { + prefetch(&hw->st_le[hw->st_idx]); __netif_rx_schedule(dev0); + } } if (status & Y2_IS_IRQ_PHY1) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 07e114d..7fda03d 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -802,16 +802,16 @@ static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits) return (1 << debug_value) - 1; } -/* Schedule rx intr now? */ -static inline int netif_rx_schedule_test(struct net_device *dev) +/* Test if receive needs to be scheduled */ +static inline int __netif_rx_schedule_prep(struct net_device *dev) { return !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state); } -/* Schedule only if device is up */ +/* Test if receive needs to be scheduled but only if up */ static inline int netif_rx_schedule_prep(struct net_device *dev) { - return netif_running(dev) && netif_rx_schedule_test(dev); + return netif_running(dev) && __netif_rx_schedule_prep(dev); } /* Add interface to tail of rx poll list. This assumes that _prep has -- cgit v1.1 From 018d1c667ef4dce5299dd79d38447840789c97d6 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:18 -0800 Subject: [PATCH] sky2: race with MTU change Avoid possible race conditions when doing MTU and change and shutdown. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index f56de98..1d5c303 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1298,8 +1298,16 @@ static int sky2_down(struct net_device *dev) if (netif_msg_ifdown(sky2)) printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); + /* Stop more packets from being queued */ netif_stop_queue(dev); + /* Disable port IRQ */ + local_irq_disable(); + hw->intr_mask &= ~((sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2); + sky2_write32(hw, B0_IMSK, hw->intr_mask); + local_irq_enable(); + + sky2_phy_reset(hw, port); /* Stop transmitter */ @@ -1346,6 +1354,8 @@ static int sky2_down(struct net_device *dev) /* turn off LED's */ sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); + synchronize_irq(hw->pdev->irq); + sky2_tx_clean(sky2); sky2_rx_clean(sky2); @@ -1586,9 +1596,12 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) return 0; } - local_irq_disable(); sky2_write32(hw, B0_IMSK, 0); + dev->trans_start = jiffies; /* prevent tx timeout */ + netif_stop_queue(dev); + netif_poll_disable(hw->dev[0]); + ctl = gma_read16(hw, sky2->port, GM_GP_CTRL); gma_write16(hw, sky2->port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA); sky2_rx_stop(sky2); @@ -1608,9 +1621,10 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) err = sky2_rx_start(sky2); gma_write16(hw, sky2->port, GM_GP_CTRL, ctl); + netif_poll_disable(hw->dev[0]); + netif_wake_queue(dev); sky2_write32(hw, B0_IMSK, hw->intr_mask); - sky2_read32(hw, B0_IMSK); - local_irq_enable(); + return err; } -- cgit v1.1 From 2224795d7e4c7f7e44fe21f0fa067d62539308fb Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:19 -0800 Subject: [PATCH] sky2: dual port tx completion Sometimes on dual port cards, one tx complete may cover both ports. To handle that rearrange poll routine to lookup at end. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 1d5c303..52c7b18 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1242,6 +1242,9 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) struct net_device *dev = sky2->netdev; unsigned i; + if (done == sky2->tx_cons) + return; + if (unlikely(netif_msg_tx_done(sky2))) printk(KERN_DEBUG "%s: tx done, up to %u\n", dev->name, done); @@ -1711,16 +1714,18 @@ error: goto resubmit; } -/* Transmit ring index in reported status block is encoded as: - * - * | TXS2 | TXA2 | TXS1 | TXA1 +/* + * Check for transmit complete */ -static inline u16 tx_index(u8 port, u32 status, u16 len) +static inline void sky2_tx_check(struct sky2_hw *hw, int port) { - if (port == 0) - return status & 0xfff; - else - return ((status >> 24) & 0xff) | (len & 0xf) << 8; + struct net_device *dev = hw->dev[port]; + + if (dev && netif_running(dev)) { + sky2_tx_complete(netdev_priv(dev), + sky2_read16(hw, port == 0 + ? STAT_TXA1_RIDX : STAT_TXA2_RIDX)); + } } /* @@ -1803,8 +1808,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) break; case OP_TXINDEXLE: - sky2_tx_complete(sky2, - tx_index(sky2->port, status, length)); + /* pick up transmit status later */ break; default: @@ -1816,6 +1820,8 @@ static int sky2_poll(struct net_device *dev0, int *budget) } exit_loop: + sky2_tx_check(hw, 0); + sky2_tx_check(hw, 1); mmiowb(); -- cgit v1.1 From 65497dacd8104004f5115dcb2dfe1bf697154ce9 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:20 -0800 Subject: [PATCH] sky2: byteorder annotation Use byteorder annotation for hardware structures Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index f836b03..420454a 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -1746,31 +1746,31 @@ enum { */ struct sky2_tx_le { union { - u32 addr; + __le32 addr; struct { - u16 offset; - u16 start; + __le16 offset; + __le16 start; } csum __attribute((packed)); struct { - u16 size; - u16 rsvd; + __le16 size; + __le16 rsvd; } tso __attribute((packed)); } tx; - u16 length; /* also vlan tag or checksum start */ + __le16 length; /* also vlan tag or checksum start */ u8 ctrl; u8 opcode; } __attribute((packed)); struct sky2_rx_le { - u32 addr; - u16 length; + __le32 addr; + __le16 length; u8 ctrl; u8 opcode; } __attribute((packed));; struct sky2_status_le { - u32 status; /* also checksum */ - u16 length; /* also vlan tag */ + __le32 status; /* also checksum */ + __le16 length; /* also vlan tag */ u8 link; u8 opcode; } __attribute((packed)); -- cgit v1.1 From af4ed7e6ba0cba388cf691f3a330089bd46e4d9e Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:21 -0800 Subject: [PATCH] sky2: remove pci-express hacks Eliminate special case tuning for PCI-Express. This code causes receive hangs and doesn't help performance much anyway. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 22 ++++------------------ drivers/net/sky2.h | 2 ++ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 52c7b18..c6c3275 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -651,12 +651,12 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len) } /* Setup Bus Memory Interface */ -static void sky2_qset(struct sky2_hw *hw, u16 q, u32 wm) +static void sky2_qset(struct sky2_hw *hw, u16 q) { sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_RESET); sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_OPER_INIT); sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_FIFO_OP_ON); - sky2_write32(hw, Q_ADDR(q, Q_WM), wm); + sky2_write32(hw, Q_ADDR(q, Q_WM), BMU_WM_DEFAULT); } /* Setup prefetch unit registers. This is the interface between @@ -921,7 +921,7 @@ static int sky2_rx_start(struct sky2_port *sky2) int i; sky2->rx_put = sky2->rx_next = 0; - sky2_qset(hw, rxq, is_pciex(hw) ? 0x80 : 0x600); + sky2_qset(hw, rxq); sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); rx_set_checksum(sky2); @@ -1004,7 +1004,7 @@ static int sky2_up(struct net_device *dev) sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), RB_RST_SET); - sky2_qset(hw, txqaddr[port], 0x600); + sky2_qset(hw, txqaddr[port]); if (hw->chip_id == CHIP_ID_YUKON_EC_U) sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0); @@ -2148,20 +2148,6 @@ static int sky2_reset(struct sky2_hw *hw) sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53); } - if (is_pciex(hw)) { - u16 pctrl; - - /* change Max. Read Request Size to 2048 bytes */ - pci_read_config_word(hw->pdev, PEX_DEV_CTRL, &pctrl); - pctrl &= ~PEX_DC_MAX_RRS_MSK; - pctrl |= PEX_DC_MAX_RD_RQ_SIZE(4); - - - sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); - pci_write_config_word(hw->pdev, PEX_DEV_CTRL, pctrl); - sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF); - } - sky2_write32(hw, B0_HWE_IMSK, Y2_HWE_ALL_MASK); spin_lock_bh(&hw->phy_lock); diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 420454a..930680f 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -631,6 +631,8 @@ enum { BMU_CLR_RESET = BMU_FIFO_RST | BMU_OP_OFF | BMU_RST_CLR, BMU_OPER_INIT = BMU_CLR_IRQ_PAR | BMU_CLR_IRQ_CHK | BMU_START | BMU_FIFO_ENA | BMU_OP_ON, + + BMU_WM_DEFAULT = 0x600, }; /* Tx BMU Control / Status Registers (Yukon-2) */ -- cgit v1.1 From 50241c4c59453fae01555f67daa96d799d85b968 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:22 -0800 Subject: [PATCH] sky2: use pci_register_driver Switch to using pci_register_driver as per current convention. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index c6c3275..aa79ad4 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -3106,7 +3106,7 @@ static struct pci_driver sky2_driver = { static int __init sky2_init_module(void) { - return pci_module_init(&sky2_driver); + return pci_register_driver(&sky2_driver); } static void __exit sky2_cleanup_module(void) -- cgit v1.1 From 5f4f9dc113a7aedca072851f3a51cc563f8e143f Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 30 Nov 2005 11:45:23 -0800 Subject: [PATCH] sky2: update version number Update version number and print version in boot message. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index aa79ad4..a1884b4 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -58,7 +58,7 @@ #include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "0.7" +#define DRV_VERSION "0.9" #define PFX DRV_NAME " " /* @@ -2948,8 +2948,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev, if (err) goto err_out_iounmap; - printk(KERN_INFO PFX "addr 0x%lx irq %d Yukon-%s (0x%x) rev %d\n", - pci_resource_start(pdev, 0), pdev->irq, + printk(KERN_INFO PFX "v%s addr 0x%lx irq %d Yukon-%s (0x%x) rev %d\n", + DRV_VERSION, pci_resource_start(pdev, 0), pdev->irq, yukon_name[hw->chip_id - CHIP_ID_YUKON], hw->chip_id, hw->chip_rev); @@ -3120,3 +3120,4 @@ module_exit(sky2_cleanup_module); MODULE_DESCRIPTION("Marvell Yukon 2 Gigabit Ethernet driver"); MODULE_AUTHOR("Stephen Hemminger "); MODULE_LICENSE("GPL"); +MODULE_VERSION(DRV_VERSION); -- cgit v1.1 From 09f5a214389fe467c2ff15aa2b85349bbde15bce Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 23 Nov 2005 22:00:52 -0800 Subject: [PATCH] sk98lin: allow ethtool checksum on/off per port Allow control of checksumming parameters via ethtool. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sk98lin/h/skdrv2nd.h | 1 + drivers/net/sk98lin/skethtool.c | 48 +++++++++++++++++++++++++++++ drivers/net/sk98lin/skge.c | 66 ++++++++++++++++++---------------------- 3 files changed, 79 insertions(+), 36 deletions(-) diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h index 9bdfde8..0ebafc8 100644 --- a/drivers/net/sk98lin/h/skdrv2nd.h +++ b/drivers/net/sk98lin/h/skdrv2nd.h @@ -297,6 +297,7 @@ struct s_RxPort { RXD *pRxdRingTail; /* Tail of Rx rings */ RXD *pRxdRingPrev; /* descriptor given to BMU previously */ int RxdRingFree; /* # of free entrys */ + int RxCsum; /* use receive checksum hardware */ spinlock_t RxDesRingLock; /* serialize descriptor accesses */ int RxFillLimit; /* limit for buffers in ring */ SK_IOC HwAddr; /* bmu registers address */ diff --git a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c index b71769a..4265ed9 100644 --- a/drivers/net/sk98lin/skethtool.c +++ b/drivers/net/sk98lin/skethtool.c @@ -539,6 +539,48 @@ static int setPauseParams(struct net_device *dev , struct ethtool_pauseparam *ep return ret ? -EIO : 0; } +/* Only Yukon supports checksum offload. */ +static int setScatterGather(struct net_device *dev, u32 data) +{ + DEV_NET *pNet = netdev_priv(dev); + SK_AC *pAC = pNet->pAC; + + if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) + return -EOPNOTSUPP; + return ethtool_op_set_sg(dev, data); +} + +static int setTxCsum(struct net_device *dev, u32 data) +{ + DEV_NET *pNet = netdev_priv(dev); + SK_AC *pAC = pNet->pAC; + + if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) + return -EOPNOTSUPP; + + return ethtool_op_set_tx_csum(dev, data); +} + +static u32 getRxCsum(struct net_device *dev) +{ + DEV_NET *pNet = netdev_priv(dev); + SK_AC *pAC = pNet->pAC; + + return pAC->RxPort[pNet->PortNr].RxCsum; +} + +static int setRxCsum(struct net_device *dev, u32 data) +{ + DEV_NET *pNet = netdev_priv(dev); + SK_AC *pAC = pNet->pAC; + + if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) + return -EOPNOTSUPP; + + pAC->RxPort[pNet->PortNr].RxCsum = data != 0; + return 0; +} + struct ethtool_ops SkGeEthtoolOps = { .get_settings = getSettings, .set_settings = setSettings, @@ -551,4 +593,10 @@ struct ethtool_ops SkGeEthtoolOps = { .set_pauseparam = setPauseParams, .get_link = ethtool_op_get_link, .get_perm_addr = ethtool_op_get_perm_addr, + .get_sg = ethtool_op_get_sg, + .set_sg = setScatterGather, + .get_tx_csum = ethtool_op_get_tx_csum, + .set_tx_csum = setTxCsum, + .get_rx_csum = getRxCsum, + .set_rx_csum = setRxCsum, }; diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index 107c5d9..02143fa 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c @@ -2189,13 +2189,10 @@ rx_start: skb_put(pMsg, FrameLength); } /* frame > SK_COPY_TRESHOLD */ -#ifdef USE_SK_RX_CHECKSUM - pMsg->csum = pRxd->TcpSums; - pMsg->ip_summed = CHECKSUM_HW; -#else - pMsg->ip_summed = CHECKSUM_NONE; -#endif - + if (pRxPort->RxCsum) { + pMsg->csum = pRxd->TcpSums; + pMsg->ip_summed = CHECKSUM_HW; + } SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V")); ForRlmt = SK_RLMT_RX_PROTOCOL; @@ -4149,6 +4146,7 @@ SK_BOOL DualNet; Flags); break; case SK_DRV_NET_UP: /* SK_U32 PortIdx */ + { struct net_device *dev = pAC->dev[Param.Para32[0]]; /* action list 5 */ FromPort = Param.Para32[0]; SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, @@ -4232,22 +4230,12 @@ SK_BOOL DualNet; printk(" irq moderation: disabled\n"); -#ifdef SK_ZEROCOPY - if (pAC->ChipsetType) -#ifdef USE_SK_TX_CHECKSUM - printk(" scatter-gather: enabled\n"); -#else - printk(" tx-checksum: disabled\n"); -#endif - else - printk(" scatter-gather: disabled\n"); -#else - printk(" scatter-gather: disabled\n"); -#endif - -#ifndef USE_SK_RX_CHECKSUM - printk(" rx-checksum: disabled\n"); -#endif + printk(" scatter-gather: %s\n", + (dev->features & NETIF_F_SG) ? "enabled" : "disabled"); + printk(" tx-checksum: %s\n", + (dev->features & NETIF_F_IP_CSUM) ? "enabled" : "disabled"); + printk(" rx-checksum: %s\n", + pAC->RxPort[Param.Para32[0]].RxCsum ? "enabled" : "disabled"); } else { DoPrintInterfaceChange = SK_TRUE; @@ -4262,9 +4250,9 @@ SK_BOOL DualNet; } /* Inform the world that link protocol is up. */ - netif_carrier_on(pAC->dev[Param.Para32[0]]); - + netif_carrier_on(dev); break; + } case SK_DRV_NET_DOWN: /* SK_U32 Reason */ /* action list 7 */ SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, @@ -4871,15 +4859,18 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, SET_NETDEV_DEV(dev, &pdev->dev); SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps); -#ifdef SK_ZEROCOPY -#ifdef USE_SK_TX_CHECKSUM + /* Use only if yukon hardware */ if (pAC->ChipsetType) { - /* Use only if yukon hardware */ - /* SK and ZEROCOPY - fly baby... */ - dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; - } +#ifdef USE_SK_TX_CHECKSUM + dev->features |= NETIF_F_IP_CSUM; #endif +#ifdef SK_ZEROCOPY + dev->features |= NETIF_F_SG; +#endif +#ifdef USE_SK_RX_CHECKSUM + pAC->RxPort[0].RxCsum = 1; #endif + } pAC->Index = boards_found++; @@ -4944,14 +4935,17 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, SET_NETDEV_DEV(dev, &pdev->dev); SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps); -#ifdef SK_ZEROCOPY -#ifdef USE_SK_TX_CHECKSUM if (pAC->ChipsetType) { - /* SG and ZEROCOPY - fly baby... */ - dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; - } +#ifdef USE_SK_TX_CHECKSUM + dev->features |= NETIF_F_IP_CSUM; #endif +#ifdef SK_ZEROCOPY + dev->features |= NETIF_F_SG; +#endif +#ifdef USE_SK_RX_CHECKSUM + pAC->RxPort[1].RxCsum = 1; #endif + } if (register_netdev(dev)) { printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n"); -- cgit v1.1 From 8f7a17d12a8cfd0ab4a50dded8390f6c44f1f205 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 23 Nov 2005 22:00:53 -0800 Subject: [PATCH] sk98lin: remove redundant fields in device info Shrink size of per device data by removing redundant fields or things that are only used at boot up. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sk98lin/h/skdrv2nd.h | 7 +--- drivers/net/sk98lin/skge.c | 71 +++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 44 deletions(-) diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h index 0ebafc8..778d9e6 100644 --- a/drivers/net/sk98lin/h/skdrv2nd.h +++ b/drivers/net/sk98lin/h/skdrv2nd.h @@ -267,8 +267,6 @@ typedef struct s_DevNet DEV_NET; struct s_DevNet { int PortNr; int NetNr; - int Mtu; - int Up; SK_AC *pAC; }; @@ -390,12 +388,10 @@ struct s_AC { SK_IOC IoBase; /* register set of adapter */ int BoardLevel; /* level of active hw init (0-2) */ - char DeviceStr[80]; /* adapter string from vpd */ + SK_U32 AllocFlag; /* flag allocation of resources */ struct pci_dev *PciDev; /* for access to pci config space */ - SK_U32 PciDevId; /* pci device id */ struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */ - char Name[30]; /* driver name */ int RxBufSize; /* length of receive buffers */ struct net_device_stats stats; /* linux 'netstat -i' statistics */ @@ -430,7 +426,6 @@ struct s_AC { DIM_INFO DynIrqModInfo; /* all data related to DIM */ /* Only for tests */ - int PortUp; int PortDown; int ChipsetType; /* Chipset family type * 0 == Genesis family support diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index 02143fa..8338d49 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c @@ -206,7 +206,6 @@ static void SkGeSetRxMode(struct SK_NET_DEVICE *dev); static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev); static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd); static void GetConfiguration(SK_AC*); -static void ProductStr(SK_AC*); static int XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*); static void FreeTxDescriptors(SK_AC*pAC, TX_PORT*); static void FillRxRing(SK_AC*, RX_PORT*); @@ -321,7 +320,7 @@ int SkGeInitPCI(SK_AC *pAC) dev->mem_start = pci_resource_start (pdev, 0); pci_set_master(pdev); - if (pci_request_regions(pdev, pAC->Name) != 0) { + if (pci_request_regions(pdev, "sk98lin") != 0) { retval = 2; goto out_disable; } @@ -599,10 +598,10 @@ SK_BOOL DualNet; spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); if (pAC->GIni.GIMacsFound == 2) { - Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev); + Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev); } else if (pAC->GIni.GIMacsFound == 1) { Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, - pAC->Name, dev); + "sk98lin", dev); } else { printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n", pAC->GIni.GIMacsFound); @@ -1286,7 +1285,6 @@ struct SK_NET_DEVICE *dev) spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); pAC->MaxPorts++; - pNet->Up = 1; SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, @@ -1416,7 +1414,6 @@ struct SK_NET_DEVICE *dev) sizeof(SK_PNMI_STRUCT_DATA)); pAC->MaxPorts--; - pNet->Up = 0; return (0); } /* SkGeClose */ @@ -2568,7 +2565,7 @@ unsigned long Flags; static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu) { DEV_NET *pNet; -DEV_NET *pOtherNet; +struct net_device *pOtherDev; SK_AC *pAC; unsigned long Flags; int i; @@ -2598,11 +2595,11 @@ SK_EVPARA EvPara; } #endif - pNet->Mtu = NewMtu; - pOtherNet = netdev_priv(pAC->dev[1 - pNet->NetNr]); - if ((pOtherNet->Mtu>1500) && (NewMtu<=1500) && (pOtherNet->Up==1)) { - return(0); - } + pOtherDev = pAC->dev[1 - pNet->NetNr]; + + if ( netif_running(pOtherDev) && (pOtherDev->mtu > 1500) + && (NewMtu <= 1500)) + return 0; pAC->RxBufSize = NewMtu + 32; dev->mtu = NewMtu; @@ -2764,7 +2761,8 @@ SK_EVPARA EvPara; EvPara.Para32[1] = -1; SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); - if (pOtherNet->Up) { + if (netif_running(pOtherDev)) { + DEV_NET *pOtherNet = netdev_priv(pOtherDev); EvPara.Para32[0] = pOtherNet->PortNr; SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); } @@ -2838,7 +2836,7 @@ unsigned long Flags; /* for spin lock */ pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts; pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts; - if (pNet->Mtu <= 1500) { + if (dev->mtu <= 1500) { pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF; } else { pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts - @@ -3789,25 +3787,21 @@ int Capabilities[3][3] = * * Returns: N/A */ -static void ProductStr( -SK_AC *pAC /* pointer to adapter context */ +static inline int ProductStr( + SK_AC *pAC, /* pointer to adapter context */ + char *DeviceStr, /* result string */ + int StrLen /* length of the string */ ) { -int StrLen = 80; /* length of the string, defined in SK_AC */ char Keyword[] = VPD_NAME; /* vpd productname identifier */ int ReturnCode; /* return code from vpd_read */ unsigned long Flags; spin_lock_irqsave(&pAC->SlowPathLock, Flags); - ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, pAC->DeviceStr, - &StrLen); + ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, DeviceStr, &StrLen); spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); - if (ReturnCode != 0) { - /* there was an error reading the vpd data */ - SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ERROR, - ("Error reading VPD data: %d\n", ReturnCode)); - pAC->DeviceStr[0] = '\0'; - } + + return ReturnCode; } /* ProductStr */ /***************************************************************************** @@ -4466,7 +4460,7 @@ SK_AC *pAc) /* pointer to adapter context */ pAC->DiagModeActive = DIAG_ACTIVE; if (pAC->BoardLevel > SK_INIT_DATA) { - if (pNet->Up) { + if (netif_running(pAC->dev[0])) { pAC->WasIfUp[0] = SK_TRUE; pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */ DoPrintInterfaceChange = SK_FALSE; @@ -4476,7 +4470,7 @@ SK_AC *pAc) /* pointer to adapter context */ } if (pNet != netdev_priv(pAC->dev[1])) { pNet = netdev_priv(pAC->dev[1]); - if (pNet->Up) { + if (netif_running(pAC->dev[1])) { pAC->WasIfUp[1] = SK_TRUE; pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */ DoPrintInterfaceChange = SK_FALSE; @@ -4802,6 +4796,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, struct net_device *dev = NULL; static int boards_found = 0; int error = -ENODEV; + char DeviceStr[80]; if (pci_enable_device(pdev)) goto out; @@ -4829,14 +4824,11 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, memset(pNet->pAC, 0, sizeof(SK_AC)); pAC = pNet->pAC; pAC->PciDev = pdev; - pAC->PciDevId = pdev->device; + pAC->dev[0] = dev; pAC->dev[1] = dev; - sprintf(pAC->Name, "SysKonnect SK-98xx"); pAC->CheckQueue = SK_FALSE; - pNet->Mtu = 1500; - pNet->Up = 0; dev->irq = pdev->irq; error = SkGeInitPCI(pAC); if (error) { @@ -4877,6 +4869,12 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, if (SkGeBoardInit(dev, pAC)) goto out_free_netdev; + /* Read Adapter name from VPD */ + if (ProductStr(pAC, DeviceStr, sizeof(DeviceStr)) != 0) { + printk(KERN_ERR "sk98lin: Could not read VPD data.\n"); + goto out_free_resources; + } + /* Register net device */ if (register_netdev(dev)) { printk(KERN_ERR "sk98lin: Could not register device.\n"); @@ -4884,8 +4882,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, } /* Print adapter specific string from vpd */ - ProductStr(pAC); - printk("%s: %s\n", dev->name, pAC->DeviceStr); + printk("%s: %s\n", dev->name, DeviceStr); /* Print configuration settings */ printk(" PrefPort:%c RlmtMode:%s\n", @@ -4921,8 +4918,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, pNet->PortNr = 1; pNet->NetNr = 1; pNet->pAC = pAC; - pNet->Mtu = 1500; - pNet->Up = 0; dev->open = &SkGeOpen; dev->stop = &SkGeClose; @@ -4957,7 +4952,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, &pAC->Addr.Net[1].CurrentMacAddress, 6); memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); - printk("%s: %s\n", dev->name, pAC->DeviceStr); + printk("%s: %s\n", dev->name, DeviceStr); printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); } } @@ -5081,9 +5076,9 @@ static int skge_resume(struct pci_dev *pdev) pci_enable_device(pdev); pci_set_master(pdev); if (pAC->GIni.GIMacsFound == 2) - ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev); + ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev); else - ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, pAC->Name, dev); + ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, "sk98lin", dev); if (ret) { printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq); pAC->AllocFlag &= ~SK_ALLOC_IRQ; -- cgit v1.1 From 35b8fcab1b293cadd54cdf9e9636cc576d2cad88 Mon Sep 17 00:00:00 2001 From: "shemminger@osdl.org" Date: Wed, 23 Nov 2005 22:00:54 -0800 Subject: [PATCH] sk98lin: remove /proc interface Remove device specific proc interface. It doesn't handle renames correctly; it ain't worth fixing. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sk98lin/Makefile | 3 +- drivers/net/sk98lin/skge.c | 42 +------ drivers/net/sk98lin/skproc.c | 265 ------------------------------------------- 3 files changed, 2 insertions(+), 308 deletions(-) delete mode 100644 drivers/net/sk98lin/skproc.c diff --git a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile index 7653d6e..afd900d 100644 --- a/drivers/net/sk98lin/Makefile +++ b/drivers/net/sk98lin/Makefile @@ -26,8 +26,7 @@ sk98lin-objs := \ skrlmt.o \ sktimer.o \ skvpd.o \ - skxmac2.o \ - skproc.o + skxmac2.o # DBGDEF = \ # -DDEBUG diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index 8338d49..e3bdb58 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c @@ -110,7 +110,6 @@ #include #include #include -#include #include #include @@ -234,28 +233,6 @@ static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr); * Extern Function Prototypes * ******************************************************************************/ -static const char SKRootName[] = "net/sk98lin"; -static struct proc_dir_entry *pSkRootDir; -extern struct file_operations sk_proc_fops; - -static inline void SkGeProcCreate(struct net_device *dev) -{ - struct proc_dir_entry *pe; - - if (pSkRootDir && - (pe = create_proc_entry(dev->name, S_IRUGO, pSkRootDir))) { - pe->proc_fops = &sk_proc_fops; - pe->data = dev; - pe->owner = THIS_MODULE; - } -} - -static inline void SkGeProcRemove(struct net_device *dev) -{ - if (pSkRootDir) - remove_proc_entry(dev->name, pSkRootDir); -} - extern void SkDimEnableModerationIfNeeded(SK_AC *pAC); extern void SkDimDisplayModerationSettings(SK_AC *pAC); extern void SkDimStartModerationTimer(SK_AC *pAC); @@ -4898,8 +4875,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6); memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); - SkGeProcCreate(dev); - pNet->PortNr = 0; pNet->NetNr = 0; @@ -4947,7 +4922,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev, free_netdev(dev); pAC->dev[1] = pAC->dev[0]; } else { - SkGeProcCreate(dev); memcpy(&dev->dev_addr, &pAC->Addr.Net[1].CurrentMacAddress, 6); memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); @@ -4988,10 +4962,7 @@ static void __devexit skge_remove_one(struct pci_dev *pdev) SK_AC *pAC = pNet->pAC; struct net_device *otherdev = pAC->dev[1]; - SkGeProcRemove(dev); unregister_netdev(dev); - if (otherdev != dev) - SkGeProcRemove(otherdev); SkGeYellowLED(pAC, pAC->IoBase, 0); @@ -5136,23 +5107,12 @@ static struct pci_driver skge_driver = { static int __init skge_init(void) { - int error; - - pSkRootDir = proc_mkdir(SKRootName, NULL); - if (pSkRootDir) - pSkRootDir->owner = THIS_MODULE; - - error = pci_register_driver(&skge_driver); - if (error) - remove_proc_entry(SKRootName, NULL); - return error; + return pci_module_init(&skge_driver); } static void __exit skge_exit(void) { pci_unregister_driver(&skge_driver); - remove_proc_entry(SKRootName, NULL); - } module_init(skge_init); diff --git a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c deleted file mode 100644 index 5cece25..0000000 --- a/drivers/net/sk98lin/skproc.c +++ /dev/null @@ -1,265 +0,0 @@ -/****************************************************************************** - * - * Name: skproc.c - * Project: GEnesis, PCI Gigabit Ethernet Adapter - * Version: $Revision: 1.11 $ - * Date: $Date: 2003/12/11 16:03:57 $ - * Purpose: Funktions to display statictic data - * - ******************************************************************************/ - -/****************************************************************************** - * - * (C)Copyright 1998-2002 SysKonnect GmbH. - * (C)Copyright 2002-2003 Marvell. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Created 22-Nov-2000 - * Author: Mirko Lindner (mlindner@syskonnect.de) - * - * The information in this file is provided "AS IS" without warranty. - * - ******************************************************************************/ -#include -#include - -#include "h/skdrv1st.h" -#include "h/skdrv2nd.h" -#include "h/skversion.h" - -static int sk_seq_show(struct seq_file *seq, void *v); -static int sk_proc_open(struct inode *inode, struct file *file); - -struct file_operations sk_proc_fops = { - .owner = THIS_MODULE, - .open = sk_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - - -/***************************************************************************** - * - * sk_seq_show - show proc information of a particular adapter - * - * Description: - * This function fills the proc entry with statistic data about - * the ethernet device. It invokes the generic sk_gen_browse() to - * print out all items one per one. - * - * Returns: 0 - * - */ -static int sk_seq_show(struct seq_file *seq, void *v) -{ - struct net_device *dev = seq->private; - DEV_NET *pNet = netdev_priv(dev); - SK_AC *pAC = pNet->pAC; - SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct; - unsigned long Flags; - unsigned int Size; - char sens_msg[50]; - int t; - int i; - - /* NetIndex in GetStruct is now required, zero is only dummy */ - for (t=pAC->GIni.GIMacsFound; t > 0; t--) { - if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1) - t--; - - spin_lock_irqsave(&pAC->SlowPathLock, Flags); - Size = SK_PNMI_STRUCT_SIZE; -#ifdef SK_DIAG_SUPPORT - if (pAC->BoardLevel == SK_INIT_DATA) { - SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA)); - if (pAC->DiagModeActive == DIAG_NOTACTIVE) { - pAC->Pnmi.DiagAttached = SK_DIAG_IDLE; - } - } else { - SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1); - } -#else - SkPnmiGetStruct(pAC, pAC->IoBase, - pPnmiStruct, &Size, t-1); -#endif - spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); - - if (pAC->dev[t-1] == dev) { - SK_PNMI_STAT *pPnmiStat = &pPnmiStruct->Stat[0]; - - seq_printf(seq, "\nDetailed statistic for device %s\n", - pAC->dev[t-1]->name); - seq_printf(seq, "=======================================\n"); - - /* Board statistics */ - seq_printf(seq, "\nBoard statistics\n\n"); - seq_printf(seq, "Active Port %c\n", - 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt. - Net[t-1].PrefPort]->PortNumber); - seq_printf(seq, "Preferred Port %c\n", - 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt. - Net[t-1].PrefPort]->PortNumber); - - seq_printf(seq, "Bus speed (MHz) %d\n", - pPnmiStruct->BusSpeed); - - seq_printf(seq, "Bus width (Bit) %d\n", - pPnmiStruct->BusWidth); - seq_printf(seq, "Driver version %s\n", - VER_STRING); - seq_printf(seq, "Hardware revision v%d.%d\n", - (pAC->GIni.GIPciHwRev >> 4) & 0x0F, - pAC->GIni.GIPciHwRev & 0x0F); - - /* Print sensor informations */ - for (i=0; i < pAC->I2c.MaxSens; i ++) { - /* Check type */ - switch (pAC->I2c.SenTable[i].SenType) { - case 1: - strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc); - strcat(sens_msg, " (C)"); - seq_printf(seq, "%-25s %d.%02d\n", - sens_msg, - pAC->I2c.SenTable[i].SenValue / 10, - pAC->I2c.SenTable[i].SenValue % 10); - - strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc); - strcat(sens_msg, " (F)"); - seq_printf(seq, "%-25s %d.%02d\n", - sens_msg, - ((((pAC->I2c.SenTable[i].SenValue) - *10)*9)/5 + 3200)/100, - ((((pAC->I2c.SenTable[i].SenValue) - *10)*9)/5 + 3200) % 10); - break; - case 2: - strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc); - strcat(sens_msg, " (V)"); - seq_printf(seq, "%-25s %d.%03d\n", - sens_msg, - pAC->I2c.SenTable[i].SenValue / 1000, - pAC->I2c.SenTable[i].SenValue % 1000); - break; - case 3: - strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc); - strcat(sens_msg, " (rpm)"); - seq_printf(seq, "%-25s %d\n", - sens_msg, - pAC->I2c.SenTable[i].SenValue); - break; - default: - break; - } - } - - /*Receive statistics */ - seq_printf(seq, "\nReceive statistics\n\n"); - - seq_printf(seq, "Received bytes %Lu\n", - (unsigned long long) pPnmiStat->StatRxOctetsOkCts); - seq_printf(seq, "Received packets %Lu\n", - (unsigned long long) pPnmiStat->StatRxOkCts); -#if 0 - if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && - pAC->HWRevision < 12) { - pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts - - pPnmiStat->StatRxShortsCts; - pPnmiStat->StatRxShortsCts = 0; - } -#endif - if (dev->mtu > 1500) - pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts - - pPnmiStat->StatRxTooLongCts; - - seq_printf(seq, "Receive errors %Lu\n", - (unsigned long long) pPnmiStruct->InErrorsCts); - seq_printf(seq, "Receive dropped %Lu\n", - (unsigned long long) pPnmiStruct->RxNoBufCts); - seq_printf(seq, "Received multicast %Lu\n", - (unsigned long long) pPnmiStat->StatRxMulticastOkCts); - seq_printf(seq, "Receive error types\n"); - seq_printf(seq, " length %Lu\n", - (unsigned long long) pPnmiStat->StatRxRuntCts); - seq_printf(seq, " buffer overflow %Lu\n", - (unsigned long long) pPnmiStat->StatRxFifoOverflowCts); - seq_printf(seq, " bad crc %Lu\n", - (unsigned long long) pPnmiStat->StatRxFcsCts); - seq_printf(seq, " framing %Lu\n", - (unsigned long long) pPnmiStat->StatRxFramingCts); - seq_printf(seq, " missed frames %Lu\n", - (unsigned long long) pPnmiStat->StatRxMissedCts); - - if (dev->mtu > 1500) - pPnmiStat->StatRxTooLongCts = 0; - - seq_printf(seq, " too long %Lu\n", - (unsigned long long) pPnmiStat->StatRxTooLongCts); - seq_printf(seq, " carrier extension %Lu\n", - (unsigned long long) pPnmiStat->StatRxCextCts); - seq_printf(seq, " too short %Lu\n", - (unsigned long long) pPnmiStat->StatRxShortsCts); - seq_printf(seq, " symbol %Lu\n", - (unsigned long long) pPnmiStat->StatRxSymbolCts); - seq_printf(seq, " LLC MAC size %Lu\n", - (unsigned long long) pPnmiStat->StatRxIRLengthCts); - seq_printf(seq, " carrier event %Lu\n", - (unsigned long long) pPnmiStat->StatRxCarrierCts); - seq_printf(seq, " jabber %Lu\n", - (unsigned long long) pPnmiStat->StatRxJabberCts); - - - /*Transmit statistics */ - seq_printf(seq, "\nTransmit statistics\n\n"); - - seq_printf(seq, "Transmited bytes %Lu\n", - (unsigned long long) pPnmiStat->StatTxOctetsOkCts); - seq_printf(seq, "Transmited packets %Lu\n", - (unsigned long long) pPnmiStat->StatTxOkCts); - seq_printf(seq, "Transmit errors %Lu\n", - (unsigned long long) pPnmiStat->StatTxSingleCollisionCts); - seq_printf(seq, "Transmit dropped %Lu\n", - (unsigned long long) pPnmiStruct->TxNoBufCts); - seq_printf(seq, "Transmit collisions %Lu\n", - (unsigned long long) pPnmiStat->StatTxSingleCollisionCts); - seq_printf(seq, "Transmit error types\n"); - seq_printf(seq, " excessive collision %ld\n", - pAC->stats.tx_aborted_errors); - seq_printf(seq, " carrier %Lu\n", - (unsigned long long) pPnmiStat->StatTxCarrierCts); - seq_printf(seq, " fifo underrun %Lu\n", - (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts); - seq_printf(seq, " heartbeat %Lu\n", - (unsigned long long) pPnmiStat->StatTxCarrierCts); - seq_printf(seq, " window %ld\n", - pAC->stats.tx_window_errors); - - } - } - return 0; -} - -/***************************************************************************** - * - * sk_proc_open - register the show function when proc is open'ed - * - * Description: - * This function is called whenever a sk98lin proc file is queried. - * - * Returns: the return value of single_open() - * - */ -static int sk_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, sk_seq_show, PDE(inode)->data); -} - -/******************************************************************************* - * - * End of file - * - ******************************************************************************/ -- cgit v1.1 From 0c49919a4706cc8c72ff381da7f3ae094e6df03a Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:05 +0100 Subject: [PATCH] ixp2000: register netdevices last Do not register our netdevices with the kernel until we've actually finished setting up the hardware and microcode. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/ixpdev.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c index 216aad1..d9fd57d 100644 --- a/drivers/net/ixp2000/ixpdev.c +++ b/drivers/net/ixp2000/ixpdev.c @@ -300,15 +300,6 @@ int ixpdev_init(int __nds_count, struct net_device **__nds, nds = __nds; set_port_admin_status = __set_port_admin_status; - for (i = 0; i < nds_count; i++) { - err = register_netdev(nds[i]); - if (err) { - while (--i >= 0) - unregister_netdev(nds[i]); - goto err_out; - } - } - for (i = 0; i < RX_BUF_COUNT; i++) { void *buf; @@ -317,7 +308,7 @@ int ixpdev_init(int __nds_count, struct net_device **__nds, err = -ENOMEM; while (--i >= 0) free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr)); - goto err_unregister; + goto err_out; } rx_desc[i].buf_addr = virt_to_phys(buf); rx_desc[i].buf_length = PAGE_SIZE; @@ -355,7 +346,6 @@ int ixpdev_init(int __nds_count, struct net_device **__nds, ixp2000_uengine_load(0, &ixp2400_rx); ixp2000_uengine_start_contexts(0, 0xff); - /* 256 entries, ring status set means 'empty', base address 0x0800. */ ixp2000_reg_write(RING_TX_PENDING_BASE, 0x44000800); ixp2000_reg_write(RING_TX_PENDING_HEAD, 0x00000000); @@ -369,16 +359,25 @@ int ixpdev_init(int __nds_count, struct net_device **__nds, ixp2000_uengine_load(1, &ixp2400_tx); ixp2000_uengine_start_contexts(1, 0xff); + for (i = 0; i < nds_count; i++) { + err = register_netdev(nds[i]); + if (err) { + while (--i >= 0) + unregister_netdev(nds[i]); + goto err_free_tx; + } + } + return 0; +err_free_tx: + for (i = 0; i < TX_BUF_COUNT; i++) + free_page((unsigned long)phys_to_virt(tx_desc[i].buf_addr)); + err_free_rx: for (i = 0; i < RX_BUF_COUNT; i++) free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr)); -err_unregister: - for (i = 0; i < nds_count; i++) - unregister_netdev(nds[i]); - err_out: return err; } @@ -389,6 +388,9 @@ void ixpdev_deinit(void) /* @@@ Flush out pending packets. */ + for (i = 0; i < nds_count; i++) + unregister_netdev(nds[i]); + ixp2000_uengine_stop_contexts(1, 0xff); ixp2000_uengine_stop_contexts(0, 0xff); ixp2000_uengine_reset(0x3); @@ -398,7 +400,4 @@ void ixpdev_deinit(void) for (i = 0; i < RX_BUF_COUNT; i++) free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr)); - - for (i = 0; i < nds_count; i++) - unregister_netdev(nds[i]); } -- cgit v1.1 From 178f171da7f0ea5cfc1c45932680c81b3a8a0bd6 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:10 +0100 Subject: [PATCH] pm3386: zero stats properly Zero our stats structure properly. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/pm3386.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c index cf0681f..df960f1 100644 --- a/drivers/net/ixp2000/pm3386.c +++ b/drivers/net/ixp2000/pm3386.c @@ -238,7 +238,7 @@ void pm3386_get_stats(int port, struct net_device_stats *stats) while (pm3386_port_reg_read(port, 0x500, 0x100) & 0x0001) ; - memset(stats, 0, sizeof(stats)); + memset(stats, 0, sizeof(*stats)); stats->rx_packets = pm3386_get_stat(port, 0x510); stats->tx_packets = pm3386_get_stat(port, 0x590); -- cgit v1.1 From f48a8815f8535c62714cb596281d8480ba9e78ea Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:15 +0100 Subject: [PATCH] pm3386: remove unnecessary udelays Remove a number of unnecessary udelay() calls. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/pm3386.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c index df960f1..b8a59b9 100644 --- a/drivers/net/ixp2000/pm3386.c +++ b/drivers/net/ixp2000/pm3386.c @@ -166,9 +166,7 @@ void pm3386_init_port(int port) * Soft reset the EGMAC block. */ pm3386_port_reg_write(port, 0x301, 0x100, 0x8000); - udelay(10); pm3386_port_reg_write(port, 0x301, 0x100, 0x0000); - udelay(10); /* * Auto-sense autonegotiation status. @@ -191,15 +189,12 @@ void pm3386_init_port(int port) * Set autonegotiation parameters to 'no PAUSE, full duplex.' */ pm3386_port_reg_write(port, 0x31c, 0x100, 0x0020); - udelay(10); /* * Enable and restart autonegotiation. */ pm3386_port_reg_write(port, 0x318, 0x100, 0x0003); - udelay(1000); pm3386_port_reg_write(port, 0x318, 0x100, 0x0002); - udelay(10); } void pm3386_get_mac(int port, u8 *mac) @@ -264,8 +259,6 @@ void pm3386_enable_rx(int port) temp = pm3386_port_reg_read(port, 0x303, 0x100); temp |= 0x1000; pm3386_port_reg_write(port, 0x303, 0x100, temp); - - udelay(10); } void pm3386_disable_rx(int port) @@ -275,8 +268,6 @@ void pm3386_disable_rx(int port) temp = pm3386_port_reg_read(port, 0x303, 0x100); temp &= 0xefff; pm3386_port_reg_write(port, 0x303, 0x100, temp); - - udelay(10); } void pm3386_enable_tx(int port) @@ -286,8 +277,6 @@ void pm3386_enable_tx(int port) temp = pm3386_port_reg_read(port, 0x303, 0x100); temp |= 0x4000; pm3386_port_reg_write(port, 0x303, 0x100, temp); - - udelay(10); } void pm3386_disable_tx(int port) @@ -297,8 +286,6 @@ void pm3386_disable_tx(int port) temp = pm3386_port_reg_read(port, 0x303, 0x100); temp &= 0xbfff; pm3386_port_reg_write(port, 0x303, 0x100, temp); - - udelay(10); } MODULE_LICENSE("GPL"); -- cgit v1.1 From 6744a5069bdadd96324290d015103163a0f7a45b Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:21 +0100 Subject: [PATCH] caleb/pm3386: include proper header files Make caleb.c and pm3386.c include their own header files, to catch incorrect prototype definitions. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/caleb.c | 1 + drivers/net/ixp2000/pm3386.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/net/ixp2000/caleb.c b/drivers/net/ixp2000/caleb.c index d70530a..3595e10 100644 --- a/drivers/net/ixp2000/caleb.c +++ b/drivers/net/ixp2000/caleb.c @@ -13,6 +13,7 @@ #include #include #include +#include "caleb.h" #define CALEB_IDLO 0x00 #define CALEB_IDHI 0x01 diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c index b8a59b9..267b6bd 100644 --- a/drivers/net/ixp2000/pm3386.c +++ b/drivers/net/ixp2000/pm3386.c @@ -14,6 +14,7 @@ #include #include #include +#include "pm3386.h" /* * Read from register 'reg' of PM3386 device 'pm'. -- cgit v1.1 From ee61249468ec9bb8d032896ae2e8ba8a8b8c3972 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:25 +0100 Subject: [PATCH] ixp2000: use netif_rx_schedule_test The sky2 driver introduced netif_rx_schedule_test(). This is exactly what we need, so remove our local version of this function (which was called netif_rx_schedule_prep_notup) and use the generic one instead. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/ixpdev.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c index d9fd57d..e9d978a 100644 --- a/drivers/net/ixp2000/ixpdev.c +++ b/drivers/net/ixp2000/ixpdev.c @@ -147,12 +147,6 @@ static int ixpdev_poll(struct net_device *dev, int *budget) return 0; } -/* @@@ Ugly hack. */ -static inline int netif_rx_schedule_prep_notup(struct net_device *dev) -{ - return !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state); -} - static void ixpdev_tx_complete(void) { int channel; @@ -206,7 +200,7 @@ static irqreturn_t ixpdev_interrupt(int irq, void *dev_id, struct pt_regs *regs) */ if (status & 0x00ff) { ixp2000_reg_wrb(IXP2000_IRQ_THD_ENABLE_CLEAR_A_0, 0x00ff); - if (likely(netif_rx_schedule_prep_notup(nds[0]))) { + if (likely(netif_rx_schedule_test(nds[0]))) { __netif_rx_schedule(nds[0]); } else { printk(KERN_CRIT "ixp2000: irq while polling!!\n"); -- cgit v1.1 From de287fd596e2e9ea9a29c397322d0a8b8a470cd1 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:30 +0100 Subject: [PATCH] enp2611: don't check netif_running() in link status timer Even after an interface has gone !netif_running(), we still want to catch the 'carrier went down' event for our internal bookkeeping. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/enp2611.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c index 3262e70..f0cc23d 100644 --- a/drivers/net/ixp2000/enp2611.c +++ b/drivers/net/ixp2000/enp2611.c @@ -148,9 +148,6 @@ static void enp2611_check_link_status(unsigned long __dummy) struct net_device *dev; int status; - if (!netif_running(nds[i])) - continue; - dev = nds[i]; status = pm3386_is_link_up(i); -- cgit v1.1 From c44185d4dcb92384c22e6c01dc09c25adae36a82 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:35 +0100 Subject: [PATCH] enp2611: use 'dev' in link status timer We assign nds[i] to a local variable 'dev', which we never use afterwards. Use the local variable instead. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/enp2611.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c index f0cc23d..bc29dbe 100644 --- a/drivers/net/ixp2000/enp2611.c +++ b/drivers/net/ixp2000/enp2611.c @@ -151,12 +151,12 @@ static void enp2611_check_link_status(unsigned long __dummy) dev = nds[i]; status = pm3386_is_link_up(i); - if (status && !netif_carrier_ok(nds[i])) { + if (status && !netif_carrier_ok(dev)) { pm3386_enable_tx(i); caleb_enable_tx(i); - netif_carrier_on(nds[i]); - } else if (!status && netif_carrier_ok(nds[i])) { - netif_carrier_off(nds[i]); + netif_carrier_on(dev); + } else if (!status && netif_carrier_ok(dev)) { + netif_carrier_off(dev); caleb_disable_tx(i); pm3386_disable_tx(i); } -- cgit v1.1 From 350f19632d18e808aa1f2ca96f2be86c67de67ff Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:40 +0100 Subject: [PATCH] enp2611: report link up/down events Report carrier going up/down. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/enp2611.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c index bc29dbe..2542e3b 100644 --- a/drivers/net/ixp2000/enp2611.c +++ b/drivers/net/ixp2000/enp2611.c @@ -152,10 +152,15 @@ static void enp2611_check_link_status(unsigned long __dummy) status = pm3386_is_link_up(i); if (status && !netif_carrier_ok(dev)) { + /* @@@ Should report autonegotiation status. */ + printk(KERN_INFO "%s: NIC Link is Up\n", dev->name); + pm3386_enable_tx(i); caleb_enable_tx(i); netif_carrier_on(dev); } else if (!status && netif_carrier_ok(dev)) { + printk(KERN_INFO "%s: NIC Link is Down\n", dev->name); + netif_carrier_off(dev); caleb_disable_tx(i); pm3386_disable_tx(i); -- cgit v1.1 From 7ed98bfdea45dbdc66261660357659470935a03a Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:43 +0100 Subject: [PATCH] ixp2000: report MAC addresses for each port on init After initialising, report the MAC address that we're using for each port. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/ixpdev.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c index e9d978a..2ef8f8f 100644 --- a/drivers/net/ixp2000/ixpdev.c +++ b/drivers/net/ixp2000/ixpdev.c @@ -362,6 +362,14 @@ int ixpdev_init(int __nds_count, struct net_device **__nds, } } + for (i = 0; i < nds_count; i++) { + printk(KERN_INFO "%s: IXP2000 MSF ethernet (port %d), " + "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x.\n", nds[i]->name, i, + nds[i]->dev_addr[0], nds[i]->dev_addr[1], + nds[i]->dev_addr[2], nds[i]->dev_addr[3], + nds[i]->dev_addr[4], nds[i]->dev_addr[5]); + } + return 0; err_free_tx: -- cgit v1.1 From 0b85c0ebde63a41d57b6214977ac2752bf5a086f Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:47 +0100 Subject: [PATCH] pm3386: add hook for setting MAC address When we reset the pm3386, it loses its internally stored MAC addresses that were programmed into it by the bootloader (and are used by the hardware for the generation of PAUSE frames.) Add a hook to allow setting these addresses so that we can program them back by hand. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/pm3386.c | 7 +++++++ drivers/net/ixp2000/pm3386.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c index 267b6bd..870b486 100644 --- a/drivers/net/ixp2000/pm3386.c +++ b/drivers/net/ixp2000/pm3386.c @@ -215,6 +215,13 @@ void pm3386_get_mac(int port, u8 *mac) mac[5] = (temp >> 8) & 0xff; } +void pm3386_set_mac(int port, u8 *mac) +{ + pm3386_port_reg_write(port, 0x308, 0x100, (mac[1] << 8) | mac[0]); + pm3386_port_reg_write(port, 0x309, 0x100, (mac[3] << 8) | mac[2]); + pm3386_port_reg_write(port, 0x30a, 0x100, (mac[5] << 8) | mac[4]); +} + static u32 pm3386_get_stat(int port, u16 base) { u32 value; diff --git a/drivers/net/ixp2000/pm3386.h b/drivers/net/ixp2000/pm3386.h index 55ecb18..117f50a 100644 --- a/drivers/net/ixp2000/pm3386.h +++ b/drivers/net/ixp2000/pm3386.h @@ -15,6 +15,7 @@ void pm3386_reset(void); void pm3386_init_port(int port); void pm3386_get_mac(int port, u8 *mac); +void pm3386_set_mac(int port, u8 *mac); void pm3386_get_stats(int port, struct net_device_stats *stats); int pm3386_is_link_up(int port); void pm3386_enable_rx(int port); -- cgit v1.1 From df86550602f320d28fdaeb577c25f9821525bfa0 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:51 +0100 Subject: [PATCH] pm3386: add hook for setting carrier Add a pm3386 hook for disabling/enabling the SERDES carrier, so that we can disable it when the interface is administratively downed, and enable it when it is upped. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/pm3386.c | 5 +++++ drivers/net/ixp2000/pm3386.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c index 870b486..ec70b1d 100644 --- a/drivers/net/ixp2000/pm3386.c +++ b/drivers/net/ixp2000/pm3386.c @@ -250,6 +250,11 @@ void pm3386_get_stats(int port, struct net_device_stats *stats) /* @@@ Add other stats. */ } +void pm3386_set_carrier(int port, int state) +{ + pm3386_port_reg_write(port, 0x703, 0x10, state ? 0x1001 : 0x0000); +} + int pm3386_is_link_up(int port) { u16 temp; diff --git a/drivers/net/ixp2000/pm3386.h b/drivers/net/ixp2000/pm3386.h index 117f50a..fe92bb0 100644 --- a/drivers/net/ixp2000/pm3386.h +++ b/drivers/net/ixp2000/pm3386.h @@ -17,6 +17,7 @@ void pm3386_init_port(int port); void pm3386_get_mac(int port, u8 *mac); void pm3386_set_mac(int port, u8 *mac); void pm3386_get_stats(int port, struct net_device_stats *stats); +void pm3386_set_carrier(int port, int state); int pm3386_is_link_up(int port); void pm3386_enable_rx(int port); void pm3386_disable_rx(int port); -- cgit v1.1 From c6e429bdd6f0142558896e29c21a526c1ffdd1f3 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:55 +0100 Subject: [PATCH] pm3386: implement reset Implement pm3386 reset. A reset zeroes out the internally stored MAC addresses, so we need to save and reload them by hand. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/pm3386.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c index ec70b1d..5c7ab75 100644 --- a/drivers/net/ixp2000/pm3386.c +++ b/drivers/net/ixp2000/pm3386.c @@ -89,7 +89,37 @@ static void pm3386_port_reg_write(int port, int _reg, int spacing, u16 value) void pm3386_reset(void) { - /* @@@ Implement me. */ + u8 mac[3][6]; + + /* Save programmed MAC addresses. */ + pm3386_get_mac(0, mac[0]); + pm3386_get_mac(1, mac[1]); + pm3386_get_mac(2, mac[2]); + + /* Assert analog and digital reset. */ + pm3386_reg_write(0, 0x002, 0x0060); + pm3386_reg_write(1, 0x002, 0x0060); + mdelay(1); + + /* Deassert analog reset. */ + pm3386_reg_write(0, 0x002, 0x0062); + pm3386_reg_write(1, 0x002, 0x0062); + mdelay(10); + + /* Deassert digital reset. */ + pm3386_reg_write(0, 0x002, 0x0063); + pm3386_reg_write(1, 0x002, 0x0063); + mdelay(10); + + /* Restore programmed MAC addresses. */ + pm3386_set_mac(0, mac[0]); + pm3386_set_mac(1, mac[1]); + pm3386_set_mac(2, mac[2]); + + /* Disable carrier on all ports. */ + pm3386_set_carrier(0, 0); + pm3386_set_carrier(1, 0); + pm3386_set_carrier(2, 0); } static u16 swaph(u16 x) -- cgit v1.1 From cffbfcaf00c4a36592fabd54ae9f960b552322b6 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:49:59 +0100 Subject: [PATCH] enp2611: disable/enable SERDES carrier on interface down/up Disable/enable the SERDES carrier when an interface is administratively downed/upped. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/enp2611.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c index 2542e3b..d82651a 100644 --- a/drivers/net/ixp2000/enp2611.c +++ b/drivers/net/ixp2000/enp2611.c @@ -175,10 +175,15 @@ static void enp2611_set_port_admin_status(int port, int up) { if (up) { caleb_enable_rx(port); + + pm3386_set_carrier(port, 1); pm3386_enable_rx(port); } else { caleb_disable_tx(port); pm3386_disable_tx(port); + /* @@@ Flush out pending packets. */ + pm3386_set_carrier(port, 0); + pm3386_disable_rx(port); caleb_disable_rx(port); } -- cgit v1.1 From 8ce51d69b755c39e714826899631629209896b70 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:50:04 +0100 Subject: [PATCH] ixp2000: add netpoll support Add netpoll support to the ixp2000 driver. Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/ixpdev.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c index 2ef8f8f..0f7b8ab 100644 --- a/drivers/net/ixp2000/ixpdev.c +++ b/drivers/net/ixp2000/ixpdev.c @@ -218,6 +218,15 @@ static irqreturn_t ixpdev_interrupt(int irq, void *dev_id, struct pt_regs *regs) return IRQ_HANDLED; } +#ifdef CONFIG_NET_POLL_CONTROLLER +static void ixpdev_poll_controller(struct net_device *dev) +{ + disable_irq(IRQ_IXP2000_THDA0); + ixpdev_interrupt(IRQ_IXP2000_THDA0, dev, NULL); + enable_irq(IRQ_IXP2000_THDA0); +} +#endif + static int ixpdev_open(struct net_device *dev) { struct ixpdev_priv *ip = netdev_priv(dev); @@ -268,6 +277,9 @@ struct net_device *ixpdev_alloc(int channel, int sizeof_priv) dev->poll = ixpdev_poll; dev->open = ixpdev_open; dev->stop = ixpdev_close; +#ifdef CONFIG_NET_POLL_CONTROLLER + dev->poll_controller = ixpdev_poll_controller; +#endif dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; dev->weight = 64; -- cgit v1.1 From 127477840b9fd205958203648b9fa89860d69a43 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 23 Nov 2005 12:50:08 +0100 Subject: [PATCH] ixp2000: add driver version, bump version to 0.2 Signed-off-by: Lennert Buytenhek Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/ixpdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c index 0f7b8ab..52c5a1c 100644 --- a/drivers/net/ixp2000/ixpdev.c +++ b/drivers/net/ixp2000/ixpdev.c @@ -24,6 +24,8 @@ #include "ixpdev_priv.h" #include "ixpdev.h" +#define DRV_MODULE_VERSION "0.2" + static int nds_count; static struct net_device **nds; static int nds_open; @@ -302,6 +304,8 @@ int ixpdev_init(int __nds_count, struct net_device **__nds, __too_many_rx_or_tx_buffers(); } + printk(KERN_INFO "IXP2000 MSF ethernet driver %s\n", DRV_MODULE_VERSION); + nds_count = __nds_count; nds = __nds; set_port_admin_status = __set_port_admin_status; -- cgit v1.1 From 98ac62defe529d04a192688f40d801a2d8fbcf98 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 28 Nov 2005 10:06:23 +0100 Subject: [PATCH] mark several libata datastructures const Hi, the patch below marks several libata (and libata-driver) structures const so that they end up in the .rodata segment and don't false-share cachelines with things that get dirtied often. Signed-off-by: Arjan van de Ven Signed-off-by: Jeff Garzik --- drivers/scsi/ahci.c | 2 +- drivers/scsi/libata-core.c | 4 ++-- drivers/scsi/libata-scsi.c | 6 +++--- drivers/scsi/sata_mv.c | 2 +- drivers/scsi/sata_promise.c | 2 +- drivers/scsi/sata_qstor.c | 2 +- drivers/scsi/sata_sil.c | 2 +- drivers/scsi/sata_sx4.c | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 83467a0..cfbdd3f 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -243,7 +243,7 @@ static const struct ata_port_operations ahci_ops = { .port_stop = ahci_port_stop, }; -static struct ata_port_info ahci_port_info[] = { +static const struct ata_port_info ahci_port_info[] = { /* board_ahci */ { .sht = &ahci_sht, diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 9f27e8d..11ed6fa 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -605,7 +605,7 @@ void ata_rwcmd_protocol(struct ata_queued_cmd *qc) tf->command = ata_rw_cmds[index + lba48 + write]; } -static const char * xfer_mode_str[] = { +static const char * const xfer_mode_str[] = { "UDMA/16", "UDMA/25", "UDMA/33", @@ -2083,7 +2083,7 @@ static void ata_pr_blacklisted(const struct ata_port *ap, ap->id, dev->devno); } -static const char * ata_dma_blacklist [] = { +static const char * const ata_dma_blacklist [] = { "WDC AC11000H", "WDC AC22100H", "WDC AC32500H", diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index 3b4ca55a..b21b885 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c @@ -418,7 +418,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, int i; /* Based on the 3ware driver translation table */ - static unsigned char sense_table[][4] = { + static const unsigned char sense_table[][4] = { /* BBD|ECC|ID|MAR */ {0xd1, ABORTED_COMMAND, 0x00, 0x00}, // Device busy Aborted command /* BBD|ECC|ID */ @@ -449,7 +449,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, {0x80, MEDIUM_ERROR, 0x11, 0x04}, // Block marked bad Medium error, unrecovered read error {0xFF, 0xFF, 0xFF, 0xFF}, // END mark }; - static unsigned char stat_table[][4] = { + static const unsigned char stat_table[][4] = { /* Must be first because BUSY means no other bits valid */ {0x80, ABORTED_COMMAND, 0x47, 0x00}, // Busy, fake parity for now {0x20, HARDWARE_ERROR, 0x00, 0x00}, // Device fault @@ -1532,7 +1532,7 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf, return 0; } -static const char *inq_83_str = "Linux ATA-SCSI simulator"; +static const char * const inq_83_str = "Linux ATA-SCSI simulator"; /** * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index ab7432a..c941766 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c @@ -430,7 +430,7 @@ static const struct ata_port_operations mv6_ops = { .host_stop = mv_host_stop, }; -static struct ata_port_info mv_port_info[] = { +static const struct ata_port_info mv_port_info[] = { { /* chip_504x */ .sht = &mv_sht, .host_flags = MV_COMMON_FLAGS, diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 25e56fb..0208906 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c @@ -158,7 +158,7 @@ static const struct ata_port_operations pdc_pata_ops = { .host_stop = ata_pci_host_stop, }; -static struct ata_port_info pdc_port_info[] = { +static const struct ata_port_info pdc_port_info[] = { /* board_2037x */ { .sht = &pdc_ata_sht, diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index a8987f5..6b9c3ae 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c @@ -170,7 +170,7 @@ static const struct ata_port_operations qs_ata_ops = { .bmdma_status = qs_bmdma_status, }; -static struct ata_port_info qs_port_info[] = { +static const struct ata_port_info qs_port_info[] = { /* board_2068_idx */ { .sht = &qs_ata_sht, diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index 3609186..d205348 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c @@ -176,7 +176,7 @@ static const struct ata_port_operations sil_ops = { .host_stop = ata_pci_host_stop, }; -static struct ata_port_info sil_port_info[] = { +static const struct ata_port_info sil_port_info[] = { /* sil_3112 */ { .sht = &sil_sht, diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index dcc3ad9..7c4b535 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c @@ -215,7 +215,7 @@ static const struct ata_port_operations pdc_20621_ops = { .host_stop = pdc20621_host_stop, }; -static struct ata_port_info pdc_port_info[] = { +static const struct ata_port_info pdc_port_info[] = { /* board_20621 */ { .sht = &pdc_sata_sht, -- cgit v1.1 From f89b23217372ed9bdba8804c1616d445402d1e05 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Fri, 11 Nov 2005 11:41:42 -0500 Subject: [PATCH] airo.c: add support for IW_ENCODE_TEMP (i.e. xsupplicant) Hello Jeff, this patch changes causes the airo driver to not reset the card when a temporary WEP key is set, when the IW_ENCODE_TEMP flag is used. This is needed for xsupplicant as 802.1x, LEAP, etc. change WEP keys frequently after authentication and resetting the card causes infinite reauthentication. Javier and Jean agree with the patch, Javier suggested I send this to you, can you apply this? Thanks. Signed-off-by: Dan Streetman Signed-off-by: Jeff Garzik --- drivers/net/wireless/airo.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 340ab4e..6c4aa7b 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -4037,7 +4037,7 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid, Cmd cmd; Resp rsp; - if (test_bit(FLAG_ENABLED, &ai->flags)) + if (test_bit(FLAG_ENABLED, &ai->flags) && (RID_WEP_TEMP != rid)) printk(KERN_ERR "%s: MAC should be disabled (rid=%04x)\n", __FUNCTION__, rid); @@ -5093,9 +5093,9 @@ static int set_wep_key(struct airo_info *ai, u16 index, printk(KERN_INFO "Setting key %d\n", index); } - disable_MAC(ai, lock); + if (perm) disable_MAC(ai, lock); writeWepKeyRid(ai, &wkr, perm, lock); - enable_MAC(ai, &rsp, lock); + if (perm) enable_MAC(ai, &rsp, lock); return 0; } @@ -6170,6 +6170,8 @@ static int airo_set_encode(struct net_device *dev, { struct airo_info *local = dev->priv; CapabilityRid cap_rid; /* Card capability info */ + int perm = ( dwrq->flags & IW_ENCODE_TEMP ? 0 : 1 ); + u16 currentAuthType = local->config.authType; /* Is WEP supported ? */ readCapabilityRid(local, &cap_rid, 1); @@ -6212,7 +6214,7 @@ static int airo_set_encode(struct net_device *dev, /* Copy the key in the driver */ memcpy(key.key, extra, dwrq->length); /* Send the key to the card */ - set_wep_key(local, index, key.key, key.len, 1, 1); + set_wep_key(local, index, key.key, key.len, perm, 1); } /* WE specify that if a valid key is set, encryption * should be enabled (user may turn it off later) @@ -6220,13 +6222,12 @@ static int airo_set_encode(struct net_device *dev, if((index == current_index) && (key.len > 0) && (local->config.authType == AUTH_OPEN)) { local->config.authType = AUTH_ENCRYPT; - set_bit (FLAG_COMMIT, &local->flags); } } else { /* Do we want to just set the transmit key index ? */ int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; if ((index >= 0) && (index < ((cap_rid.softCap & 0x80)?4:1))) { - set_wep_key(local, index, NULL, 0, 1, 1); + set_wep_key(local, index, NULL, 0, perm, 1); } else /* Don't complain if only change the mode */ if(!dwrq->flags & IW_ENCODE_MODE) { @@ -6241,7 +6242,7 @@ static int airo_set_encode(struct net_device *dev, if(dwrq->flags & IW_ENCODE_OPEN) local->config.authType = AUTH_ENCRYPT; // Only Wep /* Commit the changes to flags if needed */ - if(dwrq->flags & IW_ENCODE_MODE) + if (local->config.authType != currentAuthType) set_bit (FLAG_COMMIT, &local->flags); return -EINPROGRESS; /* Call commit handler */ } -- cgit v1.1 From 001893cda2f280ab882164737a0b608208524809 Mon Sep 17 00:00:00 2001 From: Alexander Clouter Date: Thu, 1 Dec 2005 01:09:25 -0800 Subject: [PATCH] cpufreq_conservative/ondemand: invert meaning of 'ignore nice' The use of the 'ignore_nice' sysfs file is confusing to anyone using it. This removes the sysfs file 'ignore_nice' and in its place creates a 'ignore_nice_load' entry that defaults to '0'; meaning nice'd processes _are_ counted towards the 'business' calculation. WARNING: this obvious breaks any userland tools that expected ignore_nice' to exist, to draw attention to this fact it was concluded on the mailing list that the entry should be removed altogether so the userland app breaks and so the author can build simple to detect workaround. Having said that it seems currently very few tools even make use of this functionality; all I could find was a Gentoo Wiki entry. Signed-off-by: Alexander Clouter Signed-off-by: Andrew Morton Signed-off-by: Dave Jones --- drivers/cpufreq/cpufreq_conservative.c | 10 +++++----- drivers/cpufreq/cpufreq_ondemand.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 2ed5c43..39543a2 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c @@ -93,7 +93,7 @@ static inline unsigned int get_cpu_idle_time(unsigned int cpu) { return kstat_cpu(cpu).cpustat.idle + kstat_cpu(cpu).cpustat.iowait + - ( !dbs_tuners_ins.ignore_nice ? + ( dbs_tuners_ins.ignore_nice ? kstat_cpu(cpu).cpustat.nice : 0); } @@ -127,7 +127,7 @@ show_one(sampling_rate, sampling_rate); show_one(sampling_down_factor, sampling_down_factor); show_one(up_threshold, up_threshold); show_one(down_threshold, down_threshold); -show_one(ignore_nice, ignore_nice); +show_one(ignore_nice_load, ignore_nice); show_one(freq_step, freq_step); static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, @@ -207,7 +207,7 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused, return count; } -static ssize_t store_ignore_nice(struct cpufreq_policy *policy, +static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, const char *buf, size_t count) { unsigned int input; @@ -272,7 +272,7 @@ define_one_rw(sampling_rate); define_one_rw(sampling_down_factor); define_one_rw(up_threshold); define_one_rw(down_threshold); -define_one_rw(ignore_nice); +define_one_rw(ignore_nice_load); define_one_rw(freq_step); static struct attribute * dbs_attributes[] = { @@ -282,7 +282,7 @@ static struct attribute * dbs_attributes[] = { &sampling_down_factor.attr, &up_threshold.attr, &down_threshold.attr, - &ignore_nice.attr, + &ignore_nice_load.attr, &freq_step.attr, NULL }; diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 1774111..e69fd8d 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c @@ -89,7 +89,7 @@ static inline unsigned int get_cpu_idle_time(unsigned int cpu) { return kstat_cpu(cpu).cpustat.idle + kstat_cpu(cpu).cpustat.iowait + - ( !dbs_tuners_ins.ignore_nice ? + ( dbs_tuners_ins.ignore_nice ? kstat_cpu(cpu).cpustat.nice : 0); } @@ -122,7 +122,7 @@ static ssize_t show_##file_name \ show_one(sampling_rate, sampling_rate); show_one(sampling_down_factor, sampling_down_factor); show_one(up_threshold, up_threshold); -show_one(ignore_nice, ignore_nice); +show_one(ignore_nice_load, ignore_nice); static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, const char *buf, size_t count) @@ -182,7 +182,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, return count; } -static ssize_t store_ignore_nice(struct cpufreq_policy *policy, +static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, const char *buf, size_t count) { unsigned int input; @@ -223,7 +223,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name) define_one_rw(sampling_rate); define_one_rw(sampling_down_factor); define_one_rw(up_threshold); -define_one_rw(ignore_nice); +define_one_rw(ignore_nice_load); static struct attribute * dbs_attributes[] = { &sampling_rate_max.attr, @@ -231,7 +231,7 @@ static struct attribute * dbs_attributes[] = { &sampling_rate.attr, &sampling_down_factor.attr, &up_threshold.attr, - &ignore_nice.attr, + &ignore_nice_load.attr, NULL }; -- cgit v1.1 From 537208c8072280ab87916710d5a3f7ef11ab94ff Mon Sep 17 00:00:00 2001 From: Alexander Clouter Date: Thu, 1 Dec 2005 01:09:23 -0800 Subject: [PATCH] cpufreq: documentation for 'ondemand' and 'conservative' Added a more verbose entry for the 'ondemend' governor and an entry for the 'conservative' governor to the documentation. Signed-off-by: Alexander Clouter Signed-off-by: Andrew Morton Signed-off-by: Dave Jones --- Documentation/cpu-freq/governors.txt | 62 ++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/Documentation/cpu-freq/governors.txt b/Documentation/cpu-freq/governors.txt index 933fae7..f4b8dc4 100644 --- a/Documentation/cpu-freq/governors.txt +++ b/Documentation/cpu-freq/governors.txt @@ -27,6 +27,7 @@ Contents: 2.2 Powersave 2.3 Userspace 2.4 Ondemand +2.5 Conservative 3. The Governor Interface in the CPUfreq Core @@ -110,9 +111,64 @@ directory. The CPUfreq govenor "ondemand" sets the CPU depending on the current usage. To do this the CPU must have the capability to -switch the frequency very fast. - - +switch the frequency very quickly. There are a number of sysfs file +accessible parameters: + +sampling_rate: measured in uS (10^-6 seconds), this is how often you +want the kernel to look at the CPU usage and to make decisions on +what to do about the frequency. Typically this is set to values of +around '10000' or more. + +show_sampling_rate_(min|max): the minimum and maximum sampling rates +available that you may set 'sampling_rate' to. + +up_threshold: defines what the average CPU usaged between the samplings +of 'sampling_rate' needs to be for the kernel to make a decision on +whether it should increase the frequency. For example when it is set +to its default value of '80' it means that between the checking +intervals the CPU needs to be on average more than 80% in use to then +decide that the CPU frequency needs to be increased. + +sampling_down_factor: this parameter controls the rate that the CPU +makes a decision on when to decrease the frequency. When set to its +default value of '5' it means that at 1/5 the sampling_rate the kernel +makes a decision to lower the frequency. Five "lower rate" decisions +have to be made in a row before the CPU frequency is actually lower. +If set to '1' then the frequency decreases as quickly as it increases, +if set to '2' it decreases at half the rate of the increase. + +ignore_nice_load: this parameter takes a value of '0' or '1', when set +to '0' (its default) then all processes are counted towards towards the +'cpu utilisation' value. When set to '1' then processes that are +run with a 'nice' value will not count (and thus be ignored) in the +overal usage calculation. This is useful if you are running a CPU +intensive calculation on your laptop that you do not care how long it +takes to complete as you can 'nice' it and prevent it from taking part +in the deciding process of whether to increase your CPU frequency. + + +2.5 Conservative +---------------- + +The CPUfreq governor "conservative", much like the "ondemand" +governor, sets the CPU depending on the current usage. It differs in +behaviour in that it gracefully increases and decreases the CPU speed +rather than jumping to max speed the moment there is any load on the +CPU. This behaviour more suitable in a battery powered environment. +The governor is tweaked in the same manner as the "ondemand" governor +through sysfs with the addition of: + +freq_step: this describes what percentage steps the cpu freq should be +increased and decreased smoothly by. By default the cpu frequency will +increase in 5% chunks of your maximum cpu frequency. You can change this +value to anywhere between 0 and 100 where '0' will effectively lock your +CPU at a speed regardless of its load whilst '100' will, in theory, make +it behave identically to the "ondemand" governor. + +down_threshold: same as the 'up_threshold' found for the "ondemand" +governor but for the opposite direction. For example when set to its +default value of '20' it means that if the CPU usage needs to be below +20% between samples to have the frequency decreased. 3. The Governor Interface in the CPUfreq Core ============================================= -- cgit v1.1 From d4921914de19339d7cd987d2ed6d48754821f41a Mon Sep 17 00:00:00 2001 From: "Gabriel A. Devenyi" Date: Thu, 1 Dec 2005 01:09:22 -0800 Subject: [PATCH] cpufreq-nforce2.c fix u32<0 test Thanks to LinuxICC (http://linuxicc.sf.net), a comparison of a u32 less than 0 was found, this patch changes the variable to a signed int so that comparison is meaningful. Signed-off-by: Gabriel A. Devenyi Signed-off-by: Andrew Morton Signed-off-by: Dave Jones --- arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c b/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c index 04a4053..2b62dee 100644 --- a/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c +++ b/arch/i386/kernel/cpu/cpufreq/cpufreq-nforce2.c @@ -177,9 +177,10 @@ static unsigned int nforce2_fsb_read(int bootfsb) */ static int nforce2_set_fsb(unsigned int fsb) { - u32 pll, temp = 0; + u32 temp = 0; unsigned int tfsb; int diff; + int pll = 0; if ((fsb > max_fsb) || (fsb < NFORCE2_MIN_FSB)) { printk(KERN_ERR "cpufreq: FSB %d is out of range!\n", fsb); -- cgit v1.1 From c75f4742e2306a319baaa556e53209d4e7c47f0d Mon Sep 17 00:00:00 2001 From: Takis Date: Thu, 1 Dec 2005 01:41:45 -0800 Subject: [PATCH] ipw2200: kzalloc conversion and Kconfig dependency fix - Use kzalloc for IPW2200 - Fix config dependency for IPW2200 Signed-off-by: Panagiotis Issaris Cc: James Ketrenos Cc: Yi Zhu Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/net/wireless/Kconfig | 2 +- drivers/net/wireless/ipw2200.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index 00e5516..d94421c 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig @@ -192,7 +192,7 @@ config IPW_DEBUG config IPW2200 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection" - depends on IEEE80211 && PCI + depends on NET_RADIO && IEEE80211 && PCI select FW_LOADER ---help--- A driver for the Intel PRO/Wireless 2200BG and 2915ABG Network diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index 5e7c7e9..0e47b23 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -4944,12 +4944,11 @@ static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *priv) struct ipw_rx_queue *rxq; int i; - rxq = (struct ipw_rx_queue *)kmalloc(sizeof(*rxq), GFP_KERNEL); + rxq = kzalloc(sizeof(*rxq), GFP_KERNEL); if (unlikely(!rxq)) { IPW_ERROR("memory allocation failed\n"); return NULL; } - memset(rxq, 0, sizeof(*rxq)); spin_lock_init(&rxq->lock); INIT_LIST_HEAD(&rxq->rx_free); INIT_LIST_HEAD(&rxq->rx_used); -- cgit v1.1 From 0f52bf905884c6dd7f994c9e2f533b2c02f0bd4b Mon Sep 17 00:00:00 2001 From: Brice Goglin Date: Thu, 1 Dec 2005 01:41:46 -0800 Subject: [PATCH] Duplicate IPW_DEBUG option for ipw2100 and 2200 There are currently two IPW_DEBUG options in drivers/net/wireless/Kconfig (one for ipw2100 and one for ipw2200). The attached patch splits it into IPW2100_DEBUG and IPW2200_DEBUG. Signed-off-by: Brice Goglin Cc: "James P. Ketrenos" Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- drivers/net/wireless/Kconfig | 4 ++-- drivers/net/wireless/ipw2100.c | 40 ++++++++++++++++++++-------------------- drivers/net/wireless/ipw2100.h | 2 +- drivers/net/wireless/ipw2200.c | 18 +++++++++--------- drivers/net/wireless/ipw2200.h | 6 +++--- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index d94421c..24f7967 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig @@ -173,7 +173,7 @@ config IPW2100_MONITOR promiscuous mode via the Wireless Tool's Monitor mode. While in this mode, no packets can be sent. -config IPW_DEBUG +config IPW2100_DEBUG bool "Enable full debugging output in IPW2100 module." depends on IPW2100 ---help--- @@ -217,7 +217,7 @@ config IPW2200 say M here and read . The module will be called ipw2200.ko. -config IPW_DEBUG +config IPW2200_DEBUG bool "Enable full debugging output in IPW2200 module." depends on IPW2200 ---help--- diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index 77d2a21..44cd3fc 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c @@ -175,7 +175,7 @@ that only one external action is invoked at a time. #define DRV_COPYRIGHT "Copyright(c) 2003-2005 Intel Corporation" /* Debugging stuff */ -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG #define CONFIG_IPW2100_RX_DEBUG /* Reception debugging */ #endif @@ -208,7 +208,7 @@ MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])"); static u32 ipw2100_debug_level = IPW_DL_NONE; -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG #define IPW_DEBUG(level, message...) \ do { \ if (ipw2100_debug_level & (level)) { \ @@ -219,9 +219,9 @@ do { \ } while (0) #else #define IPW_DEBUG(level, message...) do {} while (0) -#endif /* CONFIG_IPW_DEBUG */ +#endif /* CONFIG_IPW2100_DEBUG */ -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG static const char *command_types[] = { "undefined", "unused", /* HOST_ATTENTION */ @@ -2081,7 +2081,7 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) priv->status &= ~STATUS_SCANNING; } -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG #define IPW2100_HANDLER(v, f) { v, f, # v } struct ipw2100_status_indicator { int status; @@ -2094,7 +2094,7 @@ struct ipw2100_status_indicator { int status; void (*cb) (struct ipw2100_priv * priv, u32 status); }; -#endif /* CONFIG_IPW_DEBUG */ +#endif /* CONFIG_IPW2100_DEBUG */ static void isr_indicate_scanning(struct ipw2100_priv *priv, u32 status) { @@ -2149,7 +2149,7 @@ static void isr_status_change(struct ipw2100_priv *priv, int status) static void isr_rx_complete_command(struct ipw2100_priv *priv, struct ipw2100_cmd_header *cmd) { -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG if (cmd->host_command_reg < ARRAY_SIZE(command_types)) { IPW_DEBUG_HC("Command completed '%s (%d)'\n", command_types[cmd->host_command_reg], @@ -2167,7 +2167,7 @@ static void isr_rx_complete_command(struct ipw2100_priv *priv, wake_up_interruptible(&priv->wait_command_queue); } -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG static const char *frame_types[] = { "COMMAND_STATUS_VAL", "STATUS_CHANGE_VAL", @@ -2290,7 +2290,7 @@ static u8 packet_data[IPW_RX_NIC_BUFFER_LENGTH]; static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i) { -#ifdef CONFIG_IPW_DEBUG_C3 +#ifdef CONFIG_IPW2100_DEBUG_C3 struct ipw2100_status *status = &priv->status_queue.drv[i]; u32 match, reg; int j; @@ -2312,7 +2312,7 @@ static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i) } #endif -#ifdef CONFIG_IPW_DEBUG_C3 +#ifdef CONFIG_IPW2100_DEBUG_C3 /* Halt the fimrware so we can get a good image */ write_register(priv->net_dev, IPW_REG_RESET_REG, IPW_AUX_HOST_RESET_REG_STOP_MASTER); @@ -2716,7 +2716,7 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) list_del(element); DEC_STAT(&priv->fw_pend_stat); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG { int i = txq->oldest; IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i, @@ -2782,7 +2782,7 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv) "something else: ids %d=%d.\n", priv->net_dev->name, txq->oldest, packet->index); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG if (packet->info.c_struct.cmd->host_command_reg < sizeof(command_types) / sizeof(*command_types)) IPW_DEBUG_TX("Command '%s (%d)' processed: %d.\n", @@ -2975,7 +2975,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) IPW_DEBUG_TX("data header tbd TX%d P=%08x L=%d\n", packet->index, tbd->host_addr, tbd->buf_length); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG if (packet->info.d_struct.txb->nr_frags > 1) IPW_DEBUG_FRAG("fragment Tx: %d frames\n", packet->info.d_struct.txb->nr_frags); @@ -3827,7 +3827,7 @@ static ssize_t show_stats(struct device *d, struct device_attribute *attr, priv->rx_interrupts, priv->inta_other); out += sprintf(out, "firmware resets: %d\n", priv->resets); out += sprintf(out, "firmware hangs: %d\n", priv->hangs); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG out += sprintf(out, "packet mismatch image: %s\n", priv->snapshot[0] ? "YES" : "NO"); #endif @@ -3982,7 +3982,7 @@ static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr, static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG static ssize_t show_debug_level(struct device_driver *d, char *buf) { return sprintf(buf, "0x%08X\n", ipw2100_debug_level); @@ -4011,7 +4011,7 @@ static ssize_t store_debug_level(struct device_driver *d, static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level, store_debug_level); -#endif /* CONFIG_IPW_DEBUG */ +#endif /* CONFIG_IPW2100_DEBUG */ static ssize_t show_fatal_error(struct device *d, struct device_attribute *attr, char *buf) @@ -4937,7 +4937,7 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 * bssid, }; int err; -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG if (bssid != NULL) IPW_DEBUG_HC("MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], @@ -6858,7 +6858,7 @@ static int __init ipw2100_init(void) ret = pci_module_init(&ipw2100_pci_driver); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG ipw2100_debug_level = debug; driver_create_file(&ipw2100_pci_driver.driver, &driver_attr_debug_level); @@ -6873,7 +6873,7 @@ static int __init ipw2100_init(void) static void __exit ipw2100_exit(void) { /* FIXME: IPG: check that we have no instances of the devices open */ -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG driver_remove_file(&ipw2100_pci_driver.driver, &driver_attr_debug_level); #endif @@ -8558,7 +8558,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev) quality = min(beacon_qual, min(tx_qual, rssi_qual)); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2100_DEBUG if (beacon_qual == quality) IPW_DEBUG_WX("Quality clamped by Missed Beacons\n"); else if (tx_qual == quality) diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h index 7c65b10..f6c5144 100644 --- a/drivers/net/wireless/ipw2100.h +++ b/drivers/net/wireless/ipw2100.h @@ -73,7 +73,7 @@ struct ipw2100_rx_packet; * you simply need to add your entry to the ipw2100_debug_levels array. * * If you do not see debug_level in /proc/net/ipw2100 then you do not have - * CONFIG_IPW_DEBUG defined in your kernel configuration + * CONFIG_IPW2100_DEBUG defined in your kernel configuration * */ diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index 0e47b23..cd034b7 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -462,7 +462,7 @@ static inline void ipw_disable_interrupts(struct ipw_priv *priv) ipw_write32(priv, IPW_INTA_MASK_R, ~IPW_INTA_MASK_ALL); } -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG static char *ipw_error_desc(u32 val) { switch (val) { @@ -1235,7 +1235,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { struct ipw_priv *priv = dev_get_drvdata(d); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG struct net_device *dev = priv->net_dev; #endif char buffer[] = "00000000"; @@ -1754,7 +1754,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) IPW_ERROR("Firmware error detected. Restarting.\n"); if (priv->error) { IPW_ERROR("Sysfs 'error' log already exists.\n"); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG if (ipw_debug_level & IPW_DL_FW_ERRORS) { struct ipw_fw_error *error = ipw_alloc_error_log(priv); @@ -1770,7 +1770,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) else IPW_ERROR("Error allocating sysfs 'error' " "log.\n"); -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG if (ipw_debug_level & IPW_DL_FW_ERRORS) ipw_dump_error_log(priv, priv->error); #endif @@ -3778,7 +3778,7 @@ static const struct ipw_status_code ipw_status_codes[] = { {0x2E, "Cipher suite is rejected per security policy"}, }; -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG static const char *ipw_get_status_code(u16 status) { int i; @@ -4250,7 +4250,7 @@ static inline void ipw_rx_notification(struct ipw_priv *priv, if (priv-> status & (STATUS_ASSOCIATED | STATUS_AUTH)) { -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG struct notif_authenticate *auth = ¬if->u.auth; IPW_DEBUG(IPW_DL_NOTIF | @@ -5827,7 +5827,7 @@ static void ipw_bg_adhoc_check(void *data) up(&priv->sem); } -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG static void ipw_debug_config(struct ipw_priv *priv) { IPW_DEBUG_INFO("Scan completed, no valid APs matched " @@ -7814,7 +7814,7 @@ static void ipw_rx(struct ipw_priv *priv) while (i != r) { rxb = priv->rxq->queue[i]; -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG if (unlikely(rxb == NULL)) { printk(KERN_CRIT "Queue not allocated!\n"); break; @@ -10955,7 +10955,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) priv->net_dev = net_dev; priv->pci_dev = pdev; -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG ipw_debug_level = debug; #endif spin_lock_init(&priv->lock); diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h index 1c98db0..e65620a 100644 --- a/drivers/net/wireless/ipw2200.h +++ b/drivers/net/wireless/ipw2200.h @@ -1301,14 +1301,14 @@ struct ipw_priv { /* debug macros */ -#ifdef CONFIG_IPW_DEBUG +#ifdef CONFIG_IPW2200_DEBUG #define IPW_DEBUG(level, fmt, args...) \ do { if (ipw_debug_level & (level)) \ printk(KERN_DEBUG DRV_NAME": %c %s " fmt, \ in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) #else #define IPW_DEBUG(level, fmt, args...) do {} while (0) -#endif /* CONFIG_IPW_DEBUG */ +#endif /* CONFIG_IPW2200_DEBUG */ /* * To use the debug system; @@ -1332,7 +1332,7 @@ do { if (ipw_debug_level & (level)) \ * you simply need to add your entry to the ipw_debug_levels array. * * If you do not see debug_level in /proc/net/ipw then you do not have - * CONFIG_IPW_DEBUG defined in your kernel configuration + * CONFIG_IPW2200_DEBUG defined in your kernel configuration * */ -- cgit v1.1 From 14c0fa243b358c24040ff5f44b60c47aaf6430c3 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Thu, 1 Dec 2005 18:51:52 -0500 Subject: ieee1394: resume remote ports when starting a host (fixes device recognition) After initializing an IEEE 1394 host, broadcast a resume packet. This makes remote nodes visible which suspended their ports while the host was down. Such nodes had to be unplugged and replugged in order to be recognized. Motorola DCT6200 cable reciever was affected, probably other devices too. http://marc.theaimsgroup.com/?t=113202715800001 Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/hosts.h | 1 + drivers/ieee1394/nodemgr.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h index 38f4211..ae9b02c 100644 --- a/drivers/ieee1394/hosts.h +++ b/drivers/ieee1394/hosts.h @@ -41,6 +41,7 @@ struct hpsb_host { /* this nodes state */ unsigned in_bus_reset:1; unsigned is_shutdown:1; + unsigned resume_packet_sent:1; /* this nodes' duties on the bus */ unsigned is_root:1; diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 3f0917b..b56934e 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -1410,6 +1410,24 @@ static void nodemgr_node_probe(struct host_info *hi, int generation) return; } +static int nodemgr_send_resume_packet(struct hpsb_host *host) +{ + struct hpsb_packet *packet; + int ret = 1; + + packet = hpsb_make_phypacket(host, + 0x003c0000 | NODEID_TO_NODE(host->node_id) << 24); + if (packet) { + packet->no_waiter = 1; + packet->generation = get_hpsb_generation(host); + ret = hpsb_send_packet(packet); + } + if (ret) + HPSB_WARN("fw-host%d: Failed to broadcast resume packet", + host->id); + return ret; +} + /* Because we are a 1394a-2000 compliant IRM, we need to inform all the other * nodes of the broadcast channel. (Really we're only setting the validity * bit). Other IRM responsibilities go in here as well. */ @@ -1460,6 +1478,13 @@ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles) } } + /* Some devices suspend their ports while being connected to an inactive + * host adapter, i.e. if connected before the low-level driver is + * loaded. They become visible either when physically unplugged and + * replugged, or when receiving a resume packet. Send one once. */ + if (!host->resume_packet_sent && !nodemgr_send_resume_packet(host)) + host->resume_packet_sent = 1; + return 1; } -- cgit v1.1 From d7758461b9a8253f1c125e5907579e0594d29e3b Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Thu, 1 Dec 2005 18:51:56 -0500 Subject: ieee1394: add definitions for phy packet constants Introduce new macros related to phy packets and use them in ieee1394_core and nodemgr. Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/ieee1394.h | 19 ++++++++++++++++++- drivers/ieee1394/ieee1394_core.c | 38 ++++++++++++++++++++++---------------- drivers/ieee1394/nodemgr.c | 3 ++- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/drivers/ieee1394/ieee1394.h b/drivers/ieee1394/ieee1394.h index b634a9b..936d776 100644 --- a/drivers/ieee1394/ieee1394.h +++ b/drivers/ieee1394/ieee1394.h @@ -62,6 +62,7 @@ extern const char *hpsb_speedto_str[]; +/* 1394a cable PHY packets */ #define SELFID_PWRCL_NO_POWER 0x0 #define SELFID_PWRCL_PROVIDE_15W 0x1 #define SELFID_PWRCL_PROVIDE_30W 0x2 @@ -76,8 +77,24 @@ extern const char *hpsb_speedto_str[]; #define SELFID_PORT_NCONN 0x1 #define SELFID_PORT_NONE 0x0 +#define PHYPACKET_LINKON 0x40000000 +#define PHYPACKET_PHYCONFIG_R 0x00800000 +#define PHYPACKET_PHYCONFIG_T 0x00400000 +#define EXTPHYPACKET_TYPE_PING 0x00000000 +#define EXTPHYPACKET_TYPE_REMOTEACCESS_BASE 0x00040000 +#define EXTPHYPACKET_TYPE_REMOTEACCESS_PAGED 0x00140000 +#define EXTPHYPACKET_TYPE_REMOTEREPLY_BASE 0x000C0000 +#define EXTPHYPACKET_TYPE_REMOTEREPLY_PAGED 0x001C0000 +#define EXTPHYPACKET_TYPE_REMOTECOMMAND 0x00200000 +#define EXTPHYPACKET_TYPE_REMOTECONFIRMATION 0x00280000 +#define EXTPHYPACKET_TYPE_RESUME 0x003C0000 -/* 1394a PHY bitmasks */ +#define EXTPHYPACKET_TYPEMASK 0xC0FC0000 + +#define PHYPACKET_PORT_SHIFT 24 +#define PHYPACKET_GAPCOUNT_SHIFT 16 + +/* 1394a PHY register map bitmasks */ #define PHY_00_PHYSICAL_ID 0xFC #define PHY_00_R 0x02 /* Root */ #define PHY_00_PS 0x01 /* Power Status*/ diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index 32a1e01..f2f5e48 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -256,10 +256,14 @@ static int check_selfids(struct hpsb_host *host) esid = (struct ext_selfid *)(sid - 1); while (esid->extended) { - if ((esid->porta == 0x2) || (esid->portb == 0x2) - || (esid->portc == 0x2) || (esid->portd == 0x2) - || (esid->porte == 0x2) || (esid->portf == 0x2) - || (esid->portg == 0x2) || (esid->porth == 0x2)) { + if ((esid->porta == SELFID_PORT_PARENT) || + (esid->portb == SELFID_PORT_PARENT) || + (esid->portc == SELFID_PORT_PARENT) || + (esid->portd == SELFID_PORT_PARENT) || + (esid->porte == SELFID_PORT_PARENT) || + (esid->portf == SELFID_PORT_PARENT) || + (esid->portg == SELFID_PORT_PARENT) || + (esid->porth == SELFID_PORT_PARENT)) { HPSB_INFO("SelfIDs failed root check on " "extended SelfID"); return 0; @@ -268,7 +272,9 @@ static int check_selfids(struct hpsb_host *host) } sid = (struct selfid *)esid; - if ((sid->port0 == 0x2) || (sid->port1 == 0x2) || (sid->port2 == 0x2)) { + if ((sid->port0 == SELFID_PORT_PARENT) || + (sid->port1 == SELFID_PORT_PARENT) || + (sid->port2 == SELFID_PORT_PARENT)) { HPSB_INFO("SelfIDs failed root check"); return 0; } @@ -303,18 +309,18 @@ static void build_speed_map(struct hpsb_host *host, int nodecount) if (sid->extended) { esid = (struct ext_selfid *)sid; - if (esid->porta == 0x3) cldcnt[n]++; - if (esid->portb == 0x3) cldcnt[n]++; - if (esid->portc == 0x3) cldcnt[n]++; - if (esid->portd == 0x3) cldcnt[n]++; - if (esid->porte == 0x3) cldcnt[n]++; - if (esid->portf == 0x3) cldcnt[n]++; - if (esid->portg == 0x3) cldcnt[n]++; - if (esid->porth == 0x3) cldcnt[n]++; + if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portc == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portd == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->porte == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portf == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->portg == SELFID_PORT_CHILD) cldcnt[n]++; + if (esid->porth == SELFID_PORT_CHILD) cldcnt[n]++; } else { - if (sid->port0 == 0x3) cldcnt[n]++; - if (sid->port1 == 0x3) cldcnt[n]++; - if (sid->port2 == 0x3) cldcnt[n]++; + if (sid->port0 == SELFID_PORT_CHILD) cldcnt[n]++; + if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++; + if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++; speedcap[n] = sid->speed; n--; diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index b56934e..f4b6025 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -1416,7 +1416,8 @@ static int nodemgr_send_resume_packet(struct hpsb_host *host) int ret = 1; packet = hpsb_make_phypacket(host, - 0x003c0000 | NODEID_TO_NODE(host->node_id) << 24); + EXTPHYPACKET_TYPE_RESUME | + NODEID_TO_NODE(host->node_id) << PHYPACKET_PORT_SHIFT); if (packet) { packet->no_waiter = 1; packet->generation = get_hpsb_generation(host); -- cgit v1.1 From 546513f9fd96cba613cc2d025ee03d32d79394b7 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Thu, 1 Dec 2005 18:52:01 -0500 Subject: ieee1394: hpsb_send_phy_config() cleanup Eliminate some code in hpsb_send_phy_config() which is provided by hpsb_make_phypacket(). Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/ieee1394_core.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index f2f5e48..ff8a409 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -463,6 +463,7 @@ void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt) { struct hpsb_packet *packet; + quadlet_t d = 0; int retval = 0; if (rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 || @@ -472,26 +473,16 @@ int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt) return -EINVAL; } - packet = hpsb_alloc_packet(0); - if (!packet) - return -ENOMEM; - - packet->host = host; - packet->header_size = 8; - packet->data_size = 0; - packet->expect_response = 0; - packet->no_waiter = 0; - packet->type = hpsb_raw; - packet->header[0] = 0; if (rootid != -1) - packet->header[0] |= rootid << 24 | 1 << 23; + d |= PHYPACKET_PHYCONFIG_R | rootid << PHYPACKET_PORT_SHIFT; if (gapcnt != -1) - packet->header[0] |= gapcnt << 16 | 1 << 22; + d |= PHYPACKET_PHYCONFIG_T | gapcnt << PHYPACKET_GAPCOUNT_SHIFT; - packet->header[1] = ~packet->header[0]; + packet = hpsb_make_phypacket(host, d); + if (!packet) + return -ENOMEM; packet->generation = get_hpsb_generation(host); - retval = hpsb_send_packet_and_wait(packet); hpsb_free_packet(packet); -- cgit v1.1 From 741854e4f9a23421e194df8d846899172ff393d6 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Thu, 1 Dec 2005 18:52:03 -0500 Subject: ieee1394: whitespace cleanup in hosts.[ch], ieee1394_core.[ch] Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/hosts.c | 28 +- drivers/ieee1394/hosts.h | 162 ++++----- drivers/ieee1394/ieee1394_core.c | 762 +++++++++++++++++++-------------------- drivers/ieee1394/ieee1394_core.h | 100 ++--- 4 files changed, 526 insertions(+), 526 deletions(-) diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c index d245abe..ba09741 100644 --- a/drivers/ieee1394/hosts.c +++ b/drivers/ieee1394/hosts.c @@ -61,12 +61,12 @@ static void delayed_reset_bus(void * __reset_info) static int dummy_transmit_packet(struct hpsb_host *h, struct hpsb_packet *p) { - return 0; + return 0; } static int dummy_devctl(struct hpsb_host *h, enum devctl_cmd c, int arg) { - return -1; + return -1; } static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg) @@ -75,9 +75,9 @@ static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned } static struct hpsb_host_driver dummy_driver = { - .transmit_packet = dummy_transmit_packet, - .devctl = dummy_devctl, - .isoctl = dummy_isoctl + .transmit_packet = dummy_transmit_packet, + .devctl = dummy_devctl, + .isoctl = dummy_isoctl }; static int alloc_hostnum_cb(struct hpsb_host *host, void *__data) @@ -110,12 +110,12 @@ static DECLARE_MUTEX(host_num_alloc); struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, struct device *dev) { - struct hpsb_host *h; + struct hpsb_host *h; int i; int hostnum = 0; - h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); - if (!h) + h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); + if (!h) return NULL; h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); @@ -125,7 +125,7 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, } h->hostdata = h + 1; - h->driver = drv; + h->driver = drv; skb_queue_head_init(&h->pending_packet_queue); INIT_LIST_HEAD(&h->addr_space); @@ -145,8 +145,8 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, h->timeout.function = abort_timedouts; h->timeout_interval = HZ / 20; // 50ms by default - h->topology_map = h->csr.topology_map + 3; - h->speed_map = (u8 *)(h->csr.speed_map + 2); + h->topology_map = h->csr.topology_map + 3; + h->speed_map = (u8 *)(h->csr.speed_map + 2); down(&host_num_alloc); @@ -186,14 +186,14 @@ int hpsb_add_host(struct hpsb_host *host) void hpsb_remove_host(struct hpsb_host *host) { - host->is_shutdown = 1; + host->is_shutdown = 1; cancel_delayed_work(&host->delayed_reset); flush_scheduled_work(); - host->driver = &dummy_driver; + host->driver = &dummy_driver; - highlevel_remove_host(host); + highlevel_remove_host(host); hpsb_remove_extra_config_roms(host); diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h index ae9b02c..07d188c 100644 --- a/drivers/ieee1394/hosts.h +++ b/drivers/ieee1394/hosts.h @@ -17,47 +17,47 @@ struct hpsb_packet; struct hpsb_iso; struct hpsb_host { - struct list_head host_list; + struct list_head host_list; - void *hostdata; + void *hostdata; - atomic_t generation; + atomic_t generation; struct sk_buff_head pending_packet_queue; struct timer_list timeout; unsigned long timeout_interval; - unsigned char iso_listen_count[64]; + unsigned char iso_listen_count[64]; - int node_count; /* number of identified nodes on this bus */ - int selfid_count; /* total number of SelfIDs received */ + int node_count; /* number of identified nodes on this bus */ + int selfid_count; /* total number of SelfIDs received */ int nodes_active; /* number of nodes that are actually active */ - nodeid_t node_id; /* node ID of this host */ - nodeid_t irm_id; /* ID of this bus' isochronous resource manager */ - nodeid_t busmgr_id; /* ID of this bus' bus manager */ + nodeid_t node_id; /* node ID of this host */ + nodeid_t irm_id; /* ID of this bus' isochronous resource manager */ + nodeid_t busmgr_id; /* ID of this bus' bus manager */ - /* this nodes state */ - unsigned in_bus_reset:1; - unsigned is_shutdown:1; + /* this nodes state */ + unsigned in_bus_reset:1; + unsigned is_shutdown:1; unsigned resume_packet_sent:1; - /* this nodes' duties on the bus */ - unsigned is_root:1; - unsigned is_cycmst:1; - unsigned is_irm:1; - unsigned is_busmgr:1; + /* this nodes' duties on the bus */ + unsigned is_root:1; + unsigned is_cycmst:1; + unsigned is_irm:1; + unsigned is_busmgr:1; - int reset_retries; - quadlet_t *topology_map; - u8 *speed_map; - struct csr_control csr; + int reset_retries; + quadlet_t *topology_map; + u8 *speed_map; + struct csr_control csr; /* Per node tlabel pool allocation */ struct hpsb_tlabel_pool tpool[64]; - struct hpsb_host_driver *driver; + struct hpsb_host_driver *driver; struct pci_dev *pdev; @@ -77,34 +77,34 @@ struct hpsb_host { enum devctl_cmd { - /* Host is requested to reset its bus and cancel all outstanding async - * requests. If arg == 1, it shall also attempt to become root on the - * bus. Return void. */ - RESET_BUS, - - /* Arg is void, return value is the hardware cycle counter value. */ - GET_CYCLE_COUNTER, - - /* Set the hardware cycle counter to the value in arg, return void. - * FIXME - setting is probably not required. */ - SET_CYCLE_COUNTER, - - /* Configure hardware for new bus ID in arg, return void. */ - SET_BUS_ID, - - /* If arg true, start sending cycle start packets, stop if arg == 0. - * Return void. */ - ACT_CYCLE_MASTER, - - /* Cancel all outstanding async requests without resetting the bus. - * Return void. */ - CANCEL_REQUESTS, - - /* Start or stop receiving isochronous channel in arg. Return void. - * This acts as an optimization hint, hosts are not required not to - * listen on unrequested channels. */ - ISO_LISTEN_CHANNEL, - ISO_UNLISTEN_CHANNEL + /* Host is requested to reset its bus and cancel all outstanding async + * requests. If arg == 1, it shall also attempt to become root on the + * bus. Return void. */ + RESET_BUS, + + /* Arg is void, return value is the hardware cycle counter value. */ + GET_CYCLE_COUNTER, + + /* Set the hardware cycle counter to the value in arg, return void. + * FIXME - setting is probably not required. */ + SET_CYCLE_COUNTER, + + /* Configure hardware for new bus ID in arg, return void. */ + SET_BUS_ID, + + /* If arg true, start sending cycle start packets, stop if arg == 0. + * Return void. */ + ACT_CYCLE_MASTER, + + /* Cancel all outstanding async requests without resetting the bus. + * Return void. */ + CANCEL_REQUESTS, + + /* Start or stop receiving isochronous channel in arg. Return void. + * This acts as an optimization hint, hosts are not required not to + * listen on unrequested channels. */ + ISO_LISTEN_CHANNEL, + ISO_UNLISTEN_CHANNEL }; enum isoctl_cmd { @@ -135,13 +135,13 @@ enum isoctl_cmd { }; enum reset_types { - /* 166 microsecond reset -- only type of reset available on - non-1394a capable controllers */ - LONG_RESET, + /* 166 microsecond reset -- only type of reset available on + non-1394a capable controllers */ + LONG_RESET, - /* Short (arbitrated) reset -- only available on 1394a capable - controllers */ - SHORT_RESET, + /* Short (arbitrated) reset -- only available on 1394a capable + controllers */ + SHORT_RESET, /* Variants that set force_root before issueing the bus reset */ LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT, @@ -159,22 +159,22 @@ struct hpsb_host_driver { * reads to the ConfigROM on its own. */ void (*set_hw_config_rom) (struct hpsb_host *host, quadlet_t *config_rom); - /* This function shall implement packet transmission based on - * packet->type. It shall CRC both parts of the packet (unless - * packet->type == raw) and do byte-swapping as necessary or instruct - * the hardware to do so. It can return immediately after the packet - * was queued for sending. After sending, hpsb_sent_packet() has to be - * called. Return 0 on success, negative errno on failure. - * NOTE: The function must be callable in interrupt context. - */ - int (*transmit_packet) (struct hpsb_host *host, - struct hpsb_packet *packet); - - /* This function requests miscellanous services from the driver, see - * above for command codes and expected actions. Return -1 for unknown - * command, though that should never happen. - */ - int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg); + /* This function shall implement packet transmission based on + * packet->type. It shall CRC both parts of the packet (unless + * packet->type == raw) and do byte-swapping as necessary or instruct + * the hardware to do so. It can return immediately after the packet + * was queued for sending. After sending, hpsb_sent_packet() has to be + * called. Return 0 on success, negative errno on failure. + * NOTE: The function must be callable in interrupt context. + */ + int (*transmit_packet) (struct hpsb_host *host, + struct hpsb_packet *packet); + + /* This function requests miscellanous services from the driver, see + * above for command codes and expected actions. Return -1 for unknown + * command, though that should never happen. + */ + int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg); /* ISO transmission/reception functions. Return 0 on success, -1 * (or -EXXX errno code) on failure. If the low-level driver does not @@ -182,15 +182,15 @@ struct hpsb_host_driver { */ int (*isoctl) (struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg); - /* This function is mainly to redirect local CSR reads/locks to the iso - * management registers (bus manager id, bandwidth available, channels - * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus - * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids - * as OHCI uses). data and compare are the new data and expected data - * respectively, return value is the old value. - */ - quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg, - quadlet_t data, quadlet_t compare); + /* This function is mainly to redirect local CSR reads/locks to the iso + * management registers (bus manager id, bandwidth available, channels + * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus + * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids + * as OHCI uses). data and compare are the new data and expected data + * respectively, return value is the old value. + */ + quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg, + quadlet_t data, quadlet_t compare); }; diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index ff8a409..64fbbb0 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -179,34 +179,34 @@ void hpsb_free_packet(struct hpsb_packet *packet) int hpsb_reset_bus(struct hpsb_host *host, int type) { - if (!host->in_bus_reset) { - host->driver->devctl(host, RESET_BUS, type); - return 0; - } else { - return 1; - } + if (!host->in_bus_reset) { + host->driver->devctl(host, RESET_BUS, type); + return 0; + } else { + return 1; + } } int hpsb_bus_reset(struct hpsb_host *host) { - if (host->in_bus_reset) { - HPSB_NOTICE("%s called while bus reset already in progress", + if (host->in_bus_reset) { + HPSB_NOTICE("%s called while bus reset already in progress", __FUNCTION__); - return 1; - } + return 1; + } - abort_requests(host); - host->in_bus_reset = 1; - host->irm_id = -1; + abort_requests(host); + host->in_bus_reset = 1; + host->irm_id = -1; host->is_irm = 0; - host->busmgr_id = -1; + host->busmgr_id = -1; host->is_busmgr = 0; host->is_cycmst = 0; - host->node_count = 0; - host->selfid_count = 0; + host->node_count = 0; + host->selfid_count = 0; - return 0; + return 0; } @@ -216,47 +216,47 @@ int hpsb_bus_reset(struct hpsb_host *host) */ static int check_selfids(struct hpsb_host *host) { - int nodeid = -1; - int rest_of_selfids = host->selfid_count; - struct selfid *sid = (struct selfid *)host->topology_map; - struct ext_selfid *esid; - int esid_seq = 23; + int nodeid = -1; + int rest_of_selfids = host->selfid_count; + struct selfid *sid = (struct selfid *)host->topology_map; + struct ext_selfid *esid; + int esid_seq = 23; host->nodes_active = 0; - while (rest_of_selfids--) { - if (!sid->extended) { - nodeid++; - esid_seq = 0; + while (rest_of_selfids--) { + if (!sid->extended) { + nodeid++; + esid_seq = 0; - if (sid->phy_id != nodeid) { - HPSB_INFO("SelfIDs failed monotony check with " - "%d", sid->phy_id); - return 0; - } + if (sid->phy_id != nodeid) { + HPSB_INFO("SelfIDs failed monotony check with " + "%d", sid->phy_id); + return 0; + } if (sid->link_active) { host->nodes_active++; if (sid->contender) host->irm_id = LOCAL_BUS | sid->phy_id; } - } else { - esid = (struct ext_selfid *)sid; - - if ((esid->phy_id != nodeid) - || (esid->seq_nr != esid_seq)) { - HPSB_INFO("SelfIDs failed monotony check with " - "%d/%d", esid->phy_id, esid->seq_nr); - return 0; - } - esid_seq++; - } - sid++; - } - - esid = (struct ext_selfid *)(sid - 1); - while (esid->extended) { - if ((esid->porta == SELFID_PORT_PARENT) || + } else { + esid = (struct ext_selfid *)sid; + + if ((esid->phy_id != nodeid) + || (esid->seq_nr != esid_seq)) { + HPSB_INFO("SelfIDs failed monotony check with " + "%d/%d", esid->phy_id, esid->seq_nr); + return 0; + } + esid_seq++; + } + sid++; + } + + esid = (struct ext_selfid *)(sid - 1); + while (esid->extended) { + if ((esid->porta == SELFID_PORT_PARENT) || (esid->portb == SELFID_PORT_PARENT) || (esid->portc == SELFID_PORT_PARENT) || (esid->portd == SELFID_PORT_PARENT) || @@ -267,47 +267,47 @@ static int check_selfids(struct hpsb_host *host) HPSB_INFO("SelfIDs failed root check on " "extended SelfID"); return 0; - } - esid--; - } + } + esid--; + } - sid = (struct selfid *)esid; + sid = (struct selfid *)esid; if ((sid->port0 == SELFID_PORT_PARENT) || (sid->port1 == SELFID_PORT_PARENT) || (sid->port2 == SELFID_PORT_PARENT)) { HPSB_INFO("SelfIDs failed root check"); return 0; - } + } host->node_count = nodeid + 1; - return 1; + return 1; } static void build_speed_map(struct hpsb_host *host, int nodecount) { u8 speedcap[nodecount]; u8 cldcnt[nodecount]; - u8 *map = host->speed_map; - struct selfid *sid; - struct ext_selfid *esid; - int i, j, n; - - for (i = 0; i < (nodecount * 64); i += 64) { - for (j = 0; j < nodecount; j++) { - map[i+j] = IEEE1394_SPEED_MAX; - } - } - - for (i = 0; i < nodecount; i++) { - cldcnt[i] = 0; - } - - /* find direct children count and speed */ - for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1], - n = nodecount - 1; - (void *)sid >= (void *)host->topology_map; sid--) { - if (sid->extended) { - esid = (struct ext_selfid *)sid; + u8 *map = host->speed_map; + struct selfid *sid; + struct ext_selfid *esid; + int i, j, n; + + for (i = 0; i < (nodecount * 64); i += 64) { + for (j = 0; j < nodecount; j++) { + map[i+j] = IEEE1394_SPEED_MAX; + } + } + + for (i = 0; i < nodecount; i++) { + cldcnt[i] = 0; + } + + /* find direct children count and speed */ + for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1], + n = nodecount - 1; + (void *)sid >= (void *)host->topology_map; sid--) { + if (sid->extended) { + esid = (struct ext_selfid *)sid; if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++; if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++; @@ -322,50 +322,50 @@ static void build_speed_map(struct hpsb_host *host, int nodecount) if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++; if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++; - speedcap[n] = sid->speed; - n--; - } - } - - /* set self mapping */ - for (i = 0; i < nodecount; i++) { - map[64*i + i] = speedcap[i]; - } - - /* fix up direct children count to total children count; - * also fix up speedcaps for sibling and parent communication */ - for (i = 1; i < nodecount; i++) { - for (j = cldcnt[i], n = i - 1; j > 0; j--) { - cldcnt[i] += cldcnt[n]; - speedcap[n] = min(speedcap[n], speedcap[i]); - n -= cldcnt[n] + 1; - } - } - - for (n = 0; n < nodecount; n++) { - for (i = n - cldcnt[n]; i <= n; i++) { - for (j = 0; j < (n - cldcnt[n]); j++) { - map[j*64 + i] = map[i*64 + j] = - min(map[i*64 + j], speedcap[n]); - } - for (j = n + 1; j < nodecount; j++) { - map[j*64 + i] = map[i*64 + j] = - min(map[i*64 + j], speedcap[n]); - } - } - } + speedcap[n] = sid->speed; + n--; + } + } + + /* set self mapping */ + for (i = 0; i < nodecount; i++) { + map[64*i + i] = speedcap[i]; + } + + /* fix up direct children count to total children count; + * also fix up speedcaps for sibling and parent communication */ + for (i = 1; i < nodecount; i++) { + for (j = cldcnt[i], n = i - 1; j > 0; j--) { + cldcnt[i] += cldcnt[n]; + speedcap[n] = min(speedcap[n], speedcap[i]); + n -= cldcnt[n] + 1; + } + } + + for (n = 0; n < nodecount; n++) { + for (i = n - cldcnt[n]; i <= n; i++) { + for (j = 0; j < (n - cldcnt[n]); j++) { + map[j*64 + i] = map[i*64 + j] = + min(map[i*64 + j], speedcap[n]); + } + for (j = n + 1; j < nodecount; j++) { + map[j*64 + i] = map[i*64 + j] = + min(map[i*64 + j], speedcap[n]); + } + } + } } void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid) { - if (host->in_bus_reset) { - HPSB_VERBOSE("Including SelfID 0x%x", sid); - host->topology_map[host->selfid_count++] = sid; - } else { - HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d", + if (host->in_bus_reset) { + HPSB_VERBOSE("Including SelfID 0x%x", sid); + host->topology_map[host->selfid_count++] = sid; + } else { + HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d", sid, NODEID_TO_BUS(host->node_id)); - } + } } void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot) @@ -373,50 +373,50 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot) if (!host->in_bus_reset) HPSB_NOTICE("SelfID completion called outside of bus reset!"); - host->node_id = LOCAL_BUS | phyid; - host->is_root = isroot; + host->node_id = LOCAL_BUS | phyid; + host->is_root = isroot; - if (!check_selfids(host)) { - if (host->reset_retries++ < 20) { - /* selfid stage did not complete without error */ - HPSB_NOTICE("Error in SelfID stage, resetting"); + if (!check_selfids(host)) { + if (host->reset_retries++ < 20) { + /* selfid stage did not complete without error */ + HPSB_NOTICE("Error in SelfID stage, resetting"); host->in_bus_reset = 0; /* this should work from ohci1394 now... */ - hpsb_reset_bus(host, LONG_RESET); - return; - } else { - HPSB_NOTICE("Stopping out-of-control reset loop"); - HPSB_NOTICE("Warning - topology map and speed map will not be valid"); + hpsb_reset_bus(host, LONG_RESET); + return; + } else { + HPSB_NOTICE("Stopping out-of-control reset loop"); + HPSB_NOTICE("Warning - topology map and speed map will not be valid"); host->reset_retries = 0; - } - } else { + } + } else { host->reset_retries = 0; - build_speed_map(host, host->node_count); - } + build_speed_map(host, host->node_count); + } HPSB_VERBOSE("selfid_complete called with successful SelfID stage " "... irm_id: 0x%X node_id: 0x%X",host->irm_id,host->node_id); - /* irm_id is kept up to date by check_selfids() */ - if (host->irm_id == host->node_id) { - host->is_irm = 1; - } else { - host->is_busmgr = 0; - host->is_irm = 0; - } + /* irm_id is kept up to date by check_selfids() */ + if (host->irm_id == host->node_id) { + host->is_irm = 1; + } else { + host->is_busmgr = 0; + host->is_irm = 0; + } - if (isroot) { + if (isroot) { host->driver->devctl(host, ACT_CYCLE_MASTER, 1); host->is_cycmst = 1; } atomic_inc(&host->generation); host->in_bus_reset = 0; - highlevel_host_reset(host); + highlevel_host_reset(host); } void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, - int ackcode) + int ackcode) { unsigned long flags; @@ -507,13 +507,13 @@ int hpsb_send_packet(struct hpsb_packet *packet) { struct hpsb_host *host = packet->host; - if (host->is_shutdown) + if (host->is_shutdown) return -EINVAL; if (host->in_bus_reset || (packet->generation != get_hpsb_generation(host))) - return -EAGAIN; + return -EAGAIN; - packet->state = hpsb_queued; + packet->state = hpsb_queued; /* This just seems silly to me */ WARN_ON(packet->no_waiter && packet->expect_response); @@ -527,42 +527,42 @@ int hpsb_send_packet(struct hpsb_packet *packet) skb_queue_tail(&host->pending_packet_queue, packet->skb); } - if (packet->node_id == host->node_id) { + if (packet->node_id == host->node_id) { /* it is a local request, so handle it locally */ - quadlet_t *data; - size_t size = packet->data_size + packet->header_size; + quadlet_t *data; + size_t size = packet->data_size + packet->header_size; - data = kmalloc(size, GFP_ATOMIC); - if (!data) { - HPSB_ERR("unable to allocate memory for concatenating header and data"); - return -ENOMEM; - } + data = kmalloc(size, GFP_ATOMIC); + if (!data) { + HPSB_ERR("unable to allocate memory for concatenating header and data"); + return -ENOMEM; + } - memcpy(data, packet->header, packet->header_size); + memcpy(data, packet->header, packet->header_size); - if (packet->data_size) + if (packet->data_size) memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size); - dump_packet("send packet local", packet->header, packet->header_size, -1); + dump_packet("send packet local", packet->header, packet->header_size, -1); - hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE); - hpsb_packet_received(host, data, size, 0); + hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE); + hpsb_packet_received(host, data, size, 0); - kfree(data); + kfree(data); - return 0; - } + return 0; + } - if (packet->type == hpsb_async && packet->node_id != ALL_NODES) { - packet->speed_code = - host->speed_map[NODEID_TO_NODE(host->node_id) * 64 - + NODEID_TO_NODE(packet->node_id)]; - } + if (packet->type == hpsb_async && packet->node_id != ALL_NODES) { + packet->speed_code = + host->speed_map[NODEID_TO_NODE(host->node_id) * 64 + + NODEID_TO_NODE(packet->node_id)]; + } - dump_packet("send packet", packet->header, packet->header_size, packet->speed_code); + dump_packet("send packet", packet->header, packet->header_size, packet->speed_code); - return host->driver->transmit_packet(host, packet); + return host->driver->transmit_packet(host, packet); } /* We could just use complete() directly as the packet complete @@ -590,81 +590,81 @@ int hpsb_send_packet_and_wait(struct hpsb_packet *packet) static void send_packet_nocare(struct hpsb_packet *packet) { - if (hpsb_send_packet(packet) < 0) { - hpsb_free_packet(packet); - } + if (hpsb_send_packet(packet) < 0) { + hpsb_free_packet(packet); + } } static void handle_packet_response(struct hpsb_host *host, int tcode, quadlet_t *data, size_t size) { - struct hpsb_packet *packet = NULL; + struct hpsb_packet *packet = NULL; struct sk_buff *skb; - int tcode_match = 0; - int tlabel; - unsigned long flags; + int tcode_match = 0; + int tlabel; + unsigned long flags; - tlabel = (data[0] >> 10) & 0x3f; + tlabel = (data[0] >> 10) & 0x3f; spin_lock_irqsave(&host->pending_packet_queue.lock, flags); skb_queue_walk(&host->pending_packet_queue, skb) { packet = (struct hpsb_packet *)skb->data; - if ((packet->tlabel == tlabel) - && (packet->node_id == (data[1] >> 16))){ - break; - } + if ((packet->tlabel == tlabel) + && (packet->node_id == (data[1] >> 16))){ + break; + } packet = NULL; - } + } if (packet == NULL) { - HPSB_DEBUG("unsolicited response packet received - no tlabel match"); - dump_packet("contents", data, 16, -1); + HPSB_DEBUG("unsolicited response packet received - no tlabel match"); + dump_packet("contents", data, 16, -1); spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags); - return; - } + return; + } - switch (packet->tcode) { - case TCODE_WRITEQ: - case TCODE_WRITEB: - if (tcode != TCODE_WRITE_RESPONSE) + switch (packet->tcode) { + case TCODE_WRITEQ: + case TCODE_WRITEB: + if (tcode != TCODE_WRITE_RESPONSE) break; tcode_match = 1; memcpy(packet->header, data, 12); - break; - case TCODE_READQ: - if (tcode != TCODE_READQ_RESPONSE) + break; + case TCODE_READQ: + if (tcode != TCODE_READQ_RESPONSE) break; tcode_match = 1; memcpy(packet->header, data, 16); - break; - case TCODE_READB: - if (tcode != TCODE_READB_RESPONSE) + break; + case TCODE_READB: + if (tcode != TCODE_READB_RESPONSE) break; tcode_match = 1; BUG_ON(packet->skb->len - sizeof(*packet) < size - 16); memcpy(packet->header, data, 16); memcpy(packet->data, data + 4, size - 16); - break; - case TCODE_LOCK_REQUEST: - if (tcode != TCODE_LOCK_RESPONSE) + break; + case TCODE_LOCK_REQUEST: + if (tcode != TCODE_LOCK_RESPONSE) break; tcode_match = 1; size = min((size - 16), (size_t)8); BUG_ON(packet->skb->len - sizeof(*packet) < size); memcpy(packet->header, data, 16); memcpy(packet->data, data + 4, size); - break; - } + break; + } - if (!tcode_match) { + if (!tcode_match) { spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags); - HPSB_INFO("unsolicited response packet received - tcode mismatch"); - dump_packet("contents", data, 16, -1); - return; - } + HPSB_INFO("unsolicited response packet received - tcode mismatch"); + dump_packet("contents", data, 16, -1); + return; + } __skb_unlink(skb, &host->pending_packet_queue); @@ -683,27 +683,27 @@ static void handle_packet_response(struct hpsb_host *host, int tcode, static struct hpsb_packet *create_reply_packet(struct hpsb_host *host, quadlet_t *data, size_t dsize) { - struct hpsb_packet *p; + struct hpsb_packet *p; - p = hpsb_alloc_packet(dsize); - if (unlikely(p == NULL)) { - /* FIXME - send data_error response */ - return NULL; - } + p = hpsb_alloc_packet(dsize); + if (unlikely(p == NULL)) { + /* FIXME - send data_error response */ + return NULL; + } - p->type = hpsb_async; - p->state = hpsb_unused; - p->host = host; - p->node_id = data[1] >> 16; - p->tlabel = (data[0] >> 10) & 0x3f; - p->no_waiter = 1; + p->type = hpsb_async; + p->state = hpsb_unused; + p->host = host; + p->node_id = data[1] >> 16; + p->tlabel = (data[0] >> 10) & 0x3f; + p->no_waiter = 1; p->generation = get_hpsb_generation(host); if (dsize % 4) p->data[dsize / 4] = 0; - return p; + return p; } #define PREP_ASYNC_HEAD_RCODE(tc) \ @@ -714,7 +714,7 @@ static struct hpsb_packet *create_reply_packet(struct hpsb_host *host, packet->header[2] = 0 static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode, - quadlet_t data) + quadlet_t data) { PREP_ASYNC_HEAD_RCODE(TCODE_READQ_RESPONSE); packet->header[3] = data; @@ -723,7 +723,7 @@ static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode, } static void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode, - int length) + int length) { if (rcode != RCODE_COMPLETE) length = 0; @@ -743,7 +743,7 @@ static void fill_async_write_resp(struct hpsb_packet *packet, int rcode) } static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode, - int length) + int length) { if (rcode != RCODE_COMPLETE) length = 0; @@ -755,184 +755,184 @@ static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extc } #define PREP_REPLY_PACKET(length) \ - packet = create_reply_packet(host, data, length); \ - if (packet == NULL) break + packet = create_reply_packet(host, data, length); \ + if (packet == NULL) break static void handle_incoming_packet(struct hpsb_host *host, int tcode, quadlet_t *data, size_t size, int write_acked) { - struct hpsb_packet *packet; - int length, rcode, extcode; - quadlet_t buffer; - nodeid_t source = data[1] >> 16; - nodeid_t dest = data[0] >> 16; - u16 flags = (u16) data[0]; - u64 addr; - - /* big FIXME - no error checking is done for an out of bounds length */ - - switch (tcode) { - case TCODE_WRITEQ: - addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; - rcode = highlevel_write(host, source, dest, data+3, + struct hpsb_packet *packet; + int length, rcode, extcode; + quadlet_t buffer; + nodeid_t source = data[1] >> 16; + nodeid_t dest = data[0] >> 16; + u16 flags = (u16) data[0]; + u64 addr; + + /* big FIXME - no error checking is done for an out of bounds length */ + + switch (tcode) { + case TCODE_WRITEQ: + addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; + rcode = highlevel_write(host, source, dest, data+3, addr, 4, flags); - if (!write_acked - && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK) - && (rcode >= 0)) { - /* not a broadcast write, reply */ - PREP_REPLY_PACKET(0); - fill_async_write_resp(packet, rcode); - send_packet_nocare(packet); - } - break; - - case TCODE_WRITEB: - addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; - rcode = highlevel_write(host, source, dest, data+4, + if (!write_acked + && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK) + && (rcode >= 0)) { + /* not a broadcast write, reply */ + PREP_REPLY_PACKET(0); + fill_async_write_resp(packet, rcode); + send_packet_nocare(packet); + } + break; + + case TCODE_WRITEB: + addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; + rcode = highlevel_write(host, source, dest, data+4, addr, data[3]>>16, flags); - if (!write_acked - && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK) - && (rcode >= 0)) { - /* not a broadcast write, reply */ - PREP_REPLY_PACKET(0); - fill_async_write_resp(packet, rcode); - send_packet_nocare(packet); - } - break; - - case TCODE_READQ: - addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; - rcode = highlevel_read(host, source, &buffer, addr, 4, flags); - - if (rcode >= 0) { - PREP_REPLY_PACKET(0); - fill_async_readquad_resp(packet, rcode, buffer); - send_packet_nocare(packet); - } - break; - - case TCODE_READB: - length = data[3] >> 16; - PREP_REPLY_PACKET(length); - - addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; - rcode = highlevel_read(host, source, packet->data, addr, - length, flags); - - if (rcode >= 0) { - fill_async_readblock_resp(packet, rcode, length); - send_packet_nocare(packet); - } else { - hpsb_free_packet(packet); - } - break; - - case TCODE_LOCK_REQUEST: - length = data[3] >> 16; - extcode = data[3] & 0xffff; - addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; - - PREP_REPLY_PACKET(8); - - if ((extcode == 0) || (extcode >= 7)) { - /* let switch default handle error */ - length = 0; - } - - switch (length) { - case 4: - rcode = highlevel_lock(host, source, packet->data, addr, - data[4], 0, extcode,flags); - fill_async_lock_resp(packet, rcode, extcode, 4); - break; - case 8: - if ((extcode != EXTCODE_FETCH_ADD) - && (extcode != EXTCODE_LITTLE_ADD)) { - rcode = highlevel_lock(host, source, - packet->data, addr, - data[5], data[4], - extcode, flags); - fill_async_lock_resp(packet, rcode, extcode, 4); - } else { - rcode = highlevel_lock64(host, source, - (octlet_t *)packet->data, addr, - *(octlet_t *)(data + 4), 0ULL, - extcode, flags); - fill_async_lock_resp(packet, rcode, extcode, 8); - } - break; - case 16: - rcode = highlevel_lock64(host, source, - (octlet_t *)packet->data, addr, - *(octlet_t *)(data + 6), - *(octlet_t *)(data + 4), - extcode, flags); - fill_async_lock_resp(packet, rcode, extcode, 8); - break; - default: - rcode = RCODE_TYPE_ERROR; - fill_async_lock_resp(packet, rcode, - extcode, 0); - } - - if (rcode >= 0) { - send_packet_nocare(packet); - } else { - hpsb_free_packet(packet); - } - break; - } + if (!write_acked + && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK) + && (rcode >= 0)) { + /* not a broadcast write, reply */ + PREP_REPLY_PACKET(0); + fill_async_write_resp(packet, rcode); + send_packet_nocare(packet); + } + break; + + case TCODE_READQ: + addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; + rcode = highlevel_read(host, source, &buffer, addr, 4, flags); + + if (rcode >= 0) { + PREP_REPLY_PACKET(0); + fill_async_readquad_resp(packet, rcode, buffer); + send_packet_nocare(packet); + } + break; + + case TCODE_READB: + length = data[3] >> 16; + PREP_REPLY_PACKET(length); + + addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; + rcode = highlevel_read(host, source, packet->data, addr, + length, flags); + + if (rcode >= 0) { + fill_async_readblock_resp(packet, rcode, length); + send_packet_nocare(packet); + } else { + hpsb_free_packet(packet); + } + break; + + case TCODE_LOCK_REQUEST: + length = data[3] >> 16; + extcode = data[3] & 0xffff; + addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; + + PREP_REPLY_PACKET(8); + + if ((extcode == 0) || (extcode >= 7)) { + /* let switch default handle error */ + length = 0; + } + + switch (length) { + case 4: + rcode = highlevel_lock(host, source, packet->data, addr, + data[4], 0, extcode,flags); + fill_async_lock_resp(packet, rcode, extcode, 4); + break; + case 8: + if ((extcode != EXTCODE_FETCH_ADD) + && (extcode != EXTCODE_LITTLE_ADD)) { + rcode = highlevel_lock(host, source, + packet->data, addr, + data[5], data[4], + extcode, flags); + fill_async_lock_resp(packet, rcode, extcode, 4); + } else { + rcode = highlevel_lock64(host, source, + (octlet_t *)packet->data, addr, + *(octlet_t *)(data + 4), 0ULL, + extcode, flags); + fill_async_lock_resp(packet, rcode, extcode, 8); + } + break; + case 16: + rcode = highlevel_lock64(host, source, + (octlet_t *)packet->data, addr, + *(octlet_t *)(data + 6), + *(octlet_t *)(data + 4), + extcode, flags); + fill_async_lock_resp(packet, rcode, extcode, 8); + break; + default: + rcode = RCODE_TYPE_ERROR; + fill_async_lock_resp(packet, rcode, + extcode, 0); + } + + if (rcode >= 0) { + send_packet_nocare(packet); + } else { + hpsb_free_packet(packet); + } + break; + } } #undef PREP_REPLY_PACKET void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, - int write_acked) + int write_acked) { - int tcode; - - if (host->in_bus_reset) { - HPSB_INFO("received packet during reset; ignoring"); - return; - } - - dump_packet("received packet", data, size, -1); - - tcode = (data[0] >> 4) & 0xf; - - switch (tcode) { - case TCODE_WRITE_RESPONSE: - case TCODE_READQ_RESPONSE: - case TCODE_READB_RESPONSE: - case TCODE_LOCK_RESPONSE: - handle_packet_response(host, tcode, data, size); - break; - - case TCODE_WRITEQ: - case TCODE_WRITEB: - case TCODE_READQ: - case TCODE_READB: - case TCODE_LOCK_REQUEST: - handle_incoming_packet(host, tcode, data, size, write_acked); - break; - - - case TCODE_ISO_DATA: - highlevel_iso_receive(host, data, size); - break; - - case TCODE_CYCLE_START: - /* simply ignore this packet if it is passed on */ - break; - - default: - HPSB_NOTICE("received packet with bogus transaction code %d", - tcode); - break; - } + int tcode; + + if (host->in_bus_reset) { + HPSB_INFO("received packet during reset; ignoring"); + return; + } + + dump_packet("received packet", data, size, -1); + + tcode = (data[0] >> 4) & 0xf; + + switch (tcode) { + case TCODE_WRITE_RESPONSE: + case TCODE_READQ_RESPONSE: + case TCODE_READB_RESPONSE: + case TCODE_LOCK_RESPONSE: + handle_packet_response(host, tcode, data, size); + break; + + case TCODE_WRITEQ: + case TCODE_WRITEB: + case TCODE_READQ: + case TCODE_READB: + case TCODE_LOCK_REQUEST: + handle_incoming_packet(host, tcode, data, size, write_acked); + break; + + + case TCODE_ISO_DATA: + highlevel_iso_receive(host, data, size); + break; + + case TCODE_CYCLE_START: + /* simply ignore this packet if it is passed on */ + break; + + default: + HPSB_NOTICE("received packet with bogus transaction code %d", + tcode); + break; + } } @@ -1126,7 +1126,7 @@ static int __init ieee1394_init(void) nodemgr implements functionality required of ieee1394a-2000 IRMs */ hpsb_disable_irm = 1; - + return 0; } diff --git a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h index 0b31429..b354660 100644 --- a/drivers/ieee1394/ieee1394_core.h +++ b/drivers/ieee1394/ieee1394_core.h @@ -10,8 +10,8 @@ struct hpsb_packet { - /* This struct is basically read-only for hosts with the exception of - * the data buffer contents and xnext - see below. */ + /* This struct is basically read-only for hosts with the exception of + * the data buffer contents and xnext - see below. */ /* This can be used for host driver internal linking. * @@ -21,47 +21,47 @@ struct hpsb_packet { * driver_list when free'ing it. */ struct list_head driver_list; - nodeid_t node_id; + nodeid_t node_id; - /* Async and Iso types should be clear, raw means send-as-is, do not - * CRC! Byte swapping shall still be done in this case. */ - enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type; + /* Async and Iso types should be clear, raw means send-as-is, do not + * CRC! Byte swapping shall still be done in this case. */ + enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type; - /* Okay, this is core internal and a no care for hosts. - * queued = queued for sending - * pending = sent, waiting for response - * complete = processing completed, successful or not - */ - enum { - hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete - } __attribute__((packed)) state; + /* Okay, this is core internal and a no care for hosts. + * queued = queued for sending + * pending = sent, waiting for response + * complete = processing completed, successful or not + */ + enum { + hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete + } __attribute__((packed)) state; - /* These are core internal. */ - signed char tlabel; + /* These are core internal. */ + signed char tlabel; signed char ack_code; unsigned char tcode; - unsigned expect_response:1; - unsigned no_waiter:1; + unsigned expect_response:1; + unsigned no_waiter:1; - /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */ - unsigned speed_code:2; + /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */ + unsigned speed_code:2; - /* - * *header and *data are guaranteed to be 32-bit DMAable and may be - * overwritten to allow in-place byte swapping. Neither of these is - * CRCed (the sizes also don't include CRC), but contain space for at - * least one additional quadlet to allow in-place CRCing. The memory is - * also guaranteed to be DMA mappable. - */ - quadlet_t *header; - quadlet_t *data; - size_t header_size; - size_t data_size; + /* + * *header and *data are guaranteed to be 32-bit DMAable and may be + * overwritten to allow in-place byte swapping. Neither of these is + * CRCed (the sizes also don't include CRC), but contain space for at + * least one additional quadlet to allow in-place CRCing. The memory is + * also guaranteed to be DMA mappable. + */ + quadlet_t *header; + quadlet_t *data; + size_t header_size; + size_t data_size; - struct hpsb_host *host; - unsigned int generation; + struct hpsb_host *host; + unsigned int generation; atomic_t refcnt; @@ -73,10 +73,10 @@ struct hpsb_packet { /* XXX This is just a hack at the moment */ struct sk_buff *skb; - /* Store jiffies for implementing bus timeouts. */ - unsigned long sendtime; + /* Store jiffies for implementing bus timeouts. */ + unsigned long sendtime; - quadlet_t embedded_header[5]; + quadlet_t embedded_header[5]; }; /* Set a task for when a packet completes */ @@ -102,7 +102,7 @@ void hpsb_free_packet(struct hpsb_packet *packet); */ static inline unsigned int get_hpsb_generation(struct hpsb_host *host) { - return atomic_read(&host->generation); + return atomic_read(&host->generation); } /* @@ -157,7 +157,7 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot); * from within a transmit packet routine. */ void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, - int ackcode); + int ackcode); /* * Hand over received packet to the core. The contents of data are expected to @@ -171,7 +171,7 @@ void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, * packet type. */ void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, - int write_acked); + int write_acked); /* @@ -197,20 +197,20 @@ void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, * Block 15 (240-255) reserved for drivers under development, etc. */ -#define IEEE1394_MAJOR 171 +#define IEEE1394_MAJOR 171 -#define IEEE1394_MINOR_BLOCK_RAW1394 0 -#define IEEE1394_MINOR_BLOCK_VIDEO1394 1 -#define IEEE1394_MINOR_BLOCK_DV1394 2 -#define IEEE1394_MINOR_BLOCK_AMDTP 3 +#define IEEE1394_MINOR_BLOCK_RAW1394 0 +#define IEEE1394_MINOR_BLOCK_VIDEO1394 1 +#define IEEE1394_MINOR_BLOCK_DV1394 2 +#define IEEE1394_MINOR_BLOCK_AMDTP 3 #define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15 -#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0) -#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16) -#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16) -#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16) -#define IEEE1394_AMDTP_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16) -#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16) +#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0) +#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16) +#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16) +#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16) +#define IEEE1394_AMDTP_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16) +#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16) /* return the index (within a minor number block) of a file */ static inline unsigned char ieee1394_file_to_instance(struct file *file) -- cgit v1.1 From d359b6ff6a79e250422fdfa991b36d37c286eda1 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 1 Dec 2005 11:12:47 -0800 Subject: [PATCH] ixp2000: change netif_schedule_test to __netif_schedule_prep Sky2 update changed name of netif_schedule_test to __netif_schedule_prep Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/ixp2000/ixpdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c index 52c5a1c..09f03f4 100644 --- a/drivers/net/ixp2000/ixpdev.c +++ b/drivers/net/ixp2000/ixpdev.c @@ -202,7 +202,7 @@ static irqreturn_t ixpdev_interrupt(int irq, void *dev_id, struct pt_regs *regs) */ if (status & 0x00ff) { ixp2000_reg_wrb(IXP2000_IRQ_THD_ENABLE_CLEAR_A_0, 0x00ff); - if (likely(netif_rx_schedule_test(nds[0]))) { + if (likely(__netif_rx_schedule_prep(nds[0]))) { __netif_rx_schedule(nds[0]); } else { printk(KERN_CRIT "ixp2000: irq while polling!!\n"); -- cgit v1.1 From f89c2b464558a21fd3be8d578b7d13e810fb6b8a Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 1 Dec 2005 08:41:32 -0800 Subject: [PATCH] sky2: interrupt not cleared. One of the rearrangements dropped this and it means sky2 spins in napi/interrupt. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index a1884b4..7dc5b48 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1739,6 +1739,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) unsigned int work_done = 0; u16 hwidx; + sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); hwidx = sky2_read16(hw, STAT_PUT_IDX); BUG_ON(hwidx >= STATUS_RING_SIZE); rmb(); -- cgit v1.1 From 61c7f775ca25ccfc0e51486103a724fb1a3a08f2 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 5 Dec 2005 16:28:59 -0500 Subject: ieee1394: write broadcast_channel only to select nodes (fixes device recognition) Some old 1394-1995 SBP-2 bridges would hang if they received a broadcast write request to BROADCAST_CHANNEL before the config ROM was read. Affected devices include Datafab MD2-FW2 2.5" HDD and SmartDisk VST FWCDRW-V8 portable CD writer. The write request is now directed to specific nodes instead of being broadcast to all nodes at once, and it is only performed if a previous read request at this register succeeded. Fixes an old interoperability problem which was perceived as a 2.6.14-specific regression: http://marc.theaimsgroup.com/?t=113190586800003 Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/nodemgr.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index f4b6025..01ab2bf 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -1346,6 +1346,33 @@ static void nodemgr_update_pdrv(struct node_entry *ne) } +/* Write the BROADCAST_CHANNEL as per IEEE1394a 8.3.2.3.11 and 8.4.2.3. This + * seems like an optional service but in the end it is practically mandatory + * as a consequence of these clauses. + * + * Note that we cannot do a broadcast write to all nodes at once because some + * pre-1394a devices would hang. */ +static void nodemgr_irm_write_bc(struct node_entry *ne, int generation) +{ + const u64 bc_addr = (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL); + quadlet_t bc_remote, bc_local; + int ret; + + if (!ne->host->is_irm || ne->generation != generation || + ne->nodeid == ne->host->node_id) + return; + + bc_local = cpu_to_be32(ne->host->csr.broadcast_channel); + + /* Check if the register is implemented and 1394a compliant. */ + ret = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote, + sizeof(bc_remote)); + if (!ret && bc_remote & cpu_to_be32(0x80000000) && + bc_remote != bc_local) + hpsb_node_write(ne, bc_addr, &bc_local, sizeof(bc_local)); +} + + static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation) { struct device *dev; @@ -1357,6 +1384,8 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge if (!dev) return; + nodemgr_irm_write_bc(ne, generation); + /* If "needs_probe", then this is either a new or changed node we * rescan totally. If the generation matches for an existing node * (one that existed prior to the bus reset) we send update calls @@ -1429,9 +1458,7 @@ static int nodemgr_send_resume_packet(struct hpsb_host *host) return ret; } -/* Because we are a 1394a-2000 compliant IRM, we need to inform all the other - * nodes of the broadcast channel. (Really we're only setting the validity - * bit). Other IRM responsibilities go in here as well. */ +/* Perform a few high-level IRM responsibilities. */ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles) { quadlet_t bc; @@ -1440,13 +1467,8 @@ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles) if (!host->is_irm || host->irm_id == (nodeid_t)-1) return 1; - host->csr.broadcast_channel |= 0x40000000; /* set validity bit */ - - bc = cpu_to_be32(host->csr.broadcast_channel); - - hpsb_write(host, LOCAL_BUS | ALL_NODES, get_hpsb_generation(host), - (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL), - &bc, sizeof(quadlet_t)); + /* We are a 1394a-2000 compliant IRM. Set the validity bit. */ + host->csr.broadcast_channel |= 0x40000000; /* If there is no bus manager then we should set the root node's * force_root bit to promote bus stability per the 1394 -- cgit v1.1 From e38dc0ae24635a2a8a68d87cd0f4a13e74a52d98 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 5 Dec 2005 16:29:02 -0500 Subject: ieee1394: remove nonexistent functions from nodemgr.h Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/nodemgr.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/ieee1394/nodemgr.h b/drivers/ieee1394/nodemgr.h index 3a2f0c0..0b26616 100644 --- a/drivers/ieee1394/nodemgr.h +++ b/drivers/ieee1394/nodemgr.h @@ -151,24 +151,6 @@ static inline int hpsb_node_entry_valid(struct node_entry *ne) } /* - * Returns a node entry (which has its reference count incremented) or NULL if - * the GUID in question is not known. Getting a valid entry does not mean that - * the node with this GUID is currently accessible (might be powered down). - */ -struct node_entry *hpsb_guid_get_entry(u64 guid); - -/* Same as above, but use the nodeid to get an node entry. This is not - * fool-proof by itself, since the nodeid can change. */ -struct node_entry *hpsb_nodeid_get_entry(struct hpsb_host *host, nodeid_t nodeid); - -/* - * If the entry refers to a local host, this function will return the pointer - * to the hpsb_host structure. It will return NULL otherwise. Once you have - * established it is a local host, you can use that knowledge from then on (the - * GUID won't wander to an external node). */ -struct hpsb_host *hpsb_get_host_by_ne(struct node_entry *ne); - -/* * This will fill in the given, pre-initialised hpsb_packet with the current * information from the node entry (host, node ID, generation number). It will * return false if the node owning the GUID is not accessible (and not modify the -- cgit v1.1 From c14b8331ec4843e4f2b67a4d847a0d812a50e43c Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 5 Dec 2005 15:36:08 +0800 Subject: [PATCH] libata: minor patch before moving err_mask - add qc to ata_pio_poll() - reorder the initialization of qc in ata_pio_complete() Signed-off-by: Albert Lee =================== Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 11ed6fa..0a95956 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -2802,10 +2802,14 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) static unsigned long ata_pio_poll(struct ata_port *ap) { + struct ata_queued_cmd *qc; u8 status; unsigned int poll_state = HSM_ST_UNKNOWN; unsigned int reg_state = HSM_ST_UNKNOWN; + qc = ata_qc_from_tag(ap, ap->active_tag); + assert(qc != NULL); + switch (ap->hsm_task_state) { case HSM_ST: case HSM_ST_POLL: @@ -2870,15 +2874,15 @@ static int ata_pio_complete (struct ata_port *ap) } } + qc = ata_qc_from_tag(ap, ap->active_tag); + assert(qc != NULL); + drv_stat = ata_wait_idle(ap); if (!ata_ok(drv_stat)) { ap->hsm_task_state = HSM_ST_ERR; return 0; } - qc = ata_qc_from_tag(ap, ap->active_tag); - assert(qc != NULL); - ap->hsm_task_state = HSM_ST_IDLE; ata_poll_qc_complete(qc, 0); -- cgit v1.1 From a22e2eb0710798009b8e696ae911aef745089dd6 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 5 Dec 2005 15:38:02 +0800 Subject: [PATCH] libata: move err_mask to ata_queued_cmd - remove err_mask from the parameter list of the complete functions - move err_mask to ata_queued_cmd - initialize qc->err_mask when needed - for each function call to ata_qc_complete(), replace the err_mask parameter with qc->err_mask. Signed-off-by: Albert Lee =============== Signed-off-by: Jeff Garzik --- drivers/scsi/ahci.c | 12 ++++++++---- drivers/scsi/libata-core.c | 32 +++++++++++++++++++------------- drivers/scsi/libata-scsi.c | 18 ++++++++++-------- drivers/scsi/libata.h | 2 +- drivers/scsi/pdc_adma.c | 11 +++++------ drivers/scsi/sata_mv.c | 9 ++++++--- drivers/scsi/sata_promise.c | 14 ++++++++------ drivers/scsi/sata_qstor.c | 7 ++++--- drivers/scsi/sata_sil24.c | 15 ++++++++++----- drivers/scsi/sata_sx4.c | 15 ++++++++++----- include/linux/libata.h | 7 +++++-- 11 files changed, 86 insertions(+), 56 deletions(-) diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index cfbdd3f..887eaa2 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -643,7 +643,8 @@ static void ahci_eng_timeout(struct ata_port *ap) * not being called from the SCSI EH. */ qc->scsidone = scsi_finish_command; - ata_qc_complete(qc, AC_ERR_OTHER); + qc->err_mask |= AC_ERR_OTHER; + ata_qc_complete(qc); } spin_unlock_irqrestore(&host_set->lock, flags); @@ -664,7 +665,8 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) ci = readl(port_mmio + PORT_CMD_ISSUE); if (likely((ci & 0x1) == 0)) { if (qc) { - ata_qc_complete(qc, 0); + assert(qc->err_mask == 0); + ata_qc_complete(qc); qc = NULL; } } @@ -681,8 +683,10 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc) /* command processing has stopped due to error; restart */ ahci_restart_port(ap, status); - if (qc) - ata_qc_complete(qc, err_mask); + if (qc) { + qc->err_mask |= AC_ERR_OTHER; + ata_qc_complete(qc); + } } return 1; diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 0a95956..f56b4da 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1053,9 +1053,9 @@ static int ata_qc_wait_err(struct ata_queued_cmd *qc, if (wait_for_completion_timeout(wait, 30 * HZ) < 1) { /* timeout handling */ - unsigned int err_mask = ac_err_mask(ata_chk_status(qc->ap)); + qc->err_mask |= ac_err_mask(ata_chk_status(qc->ap)); - if (!err_mask) { + if (!qc->err_mask) { printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n", qc->ap->id, qc->tf.command); } else { @@ -1064,7 +1064,7 @@ static int ata_qc_wait_err(struct ata_queued_cmd *qc, rc = -EIO; } - ata_qc_complete(qc, err_mask); + ata_qc_complete(qc); } return rc; @@ -1175,6 +1175,7 @@ retry: qc->cursg_ofs = 0; qc->cursect = 0; qc->nsect = 1; + qc->err_mask = 0; goto retry; } } @@ -2777,7 +2778,7 @@ skip_map: * None. (grabs host lock) */ -void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) +void ata_poll_qc_complete(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; unsigned long flags; @@ -2785,7 +2786,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) spin_lock_irqsave(&ap->host_set->lock, flags); ap->flags &= ~ATA_FLAG_NOINTR; ata_irq_on(ap); - ata_qc_complete(qc, err_mask); + ata_qc_complete(qc); spin_unlock_irqrestore(&ap->host_set->lock, flags); } @@ -2885,7 +2886,8 @@ static int ata_pio_complete (struct ata_port *ap) ap->hsm_task_state = HSM_ST_IDLE; - ata_poll_qc_complete(qc, 0); + assert(qc->err_mask == 0); + ata_poll_qc_complete(qc); /* another command may start at this point */ @@ -3261,7 +3263,8 @@ static void ata_pio_error(struct ata_port *ap) ap->hsm_task_state = HSM_ST_IDLE; - ata_poll_qc_complete(qc, AC_ERR_ATA_BUS); + qc->err_mask |= AC_ERR_ATA_BUS; + ata_poll_qc_complete(qc); } static void ata_pio_task(void *_data) @@ -3363,7 +3366,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) ap->id, qc->tf.command, drv_stat, host_stat); /* complete taskfile transaction */ - ata_qc_complete(qc, ac_err_mask(drv_stat)); + qc->err_mask |= ac_err_mask(drv_stat); + ata_qc_complete(qc); break; } @@ -3462,7 +3466,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, return qc; } -int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask) +int ata_qc_complete_noop(struct ata_queued_cmd *qc) { return 0; } @@ -3521,7 +3525,7 @@ void ata_qc_free(struct ata_queued_cmd *qc) * spin_lock_irqsave(host_set lock) */ -void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) +void ata_qc_complete(struct ata_queued_cmd *qc) { int rc; @@ -3538,7 +3542,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) qc->flags &= ~ATA_QCFLAG_ACTIVE; /* call completion callback */ - rc = qc->complete_fn(qc, err_mask); + rc = qc->complete_fn(qc); /* if callback indicates not to complete command (non-zero), * return immediately @@ -3976,7 +3980,8 @@ inline unsigned int ata_host_intr (struct ata_port *ap, ap->ops->irq_clear(ap); /* complete taskfile transaction */ - ata_qc_complete(qc, ac_err_mask(status)); + qc->err_mask |= ac_err_mask(status); + ata_qc_complete(qc); break; default: @@ -4111,7 +4116,8 @@ static void atapi_packet_task(void *_data) err_out_status: status = ata_chk_status(ap); err_out: - ata_poll_qc_complete(qc, __ac_err_mask(status)); + qc->err_mask |= __ac_err_mask(status); + ata_poll_qc_complete(qc); } diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index ef763ed..2aef411 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c @@ -1203,12 +1203,11 @@ nothing_to_do: return 1; } -static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, - unsigned int err_mask) +static int ata_scsi_qc_complete(struct ata_queued_cmd *qc) { struct scsi_cmnd *cmd = qc->scsicmd; u8 *cdb = cmd->cmnd; - int need_sense = (err_mask != 0); + int need_sense = (qc->err_mask != 0); /* For ATA pass thru (SAT) commands, generate a sense block if * user mandated it or if there's an error. Note that if we @@ -1955,9 +1954,9 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8 done(cmd); } -static int atapi_sense_complete(struct ata_queued_cmd *qc,unsigned int err_mask) +static int atapi_sense_complete(struct ata_queued_cmd *qc) { - if (err_mask && ((err_mask & AC_ERR_DEV) == 0)) + if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0)) /* FIXME: not quite right; we don't want the * translation of taskfile registers into * a sense descriptors, since that's only @@ -2015,15 +2014,18 @@ static void atapi_request_sense(struct ata_queued_cmd *qc) qc->complete_fn = atapi_sense_complete; - if (ata_qc_issue(qc)) - ata_qc_complete(qc, AC_ERR_OTHER); + if (ata_qc_issue(qc)) { + qc->err_mask |= AC_ERR_OTHER; + ata_qc_complete(qc); + } DPRINTK("EXIT\n"); } -static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) +static int atapi_qc_complete(struct ata_queued_cmd *qc) { struct scsi_cmnd *cmd = qc->scsicmd; + unsigned int err_mask = qc->err_mask; VPRINTK("ENTER, err_mask 0x%X\n", err_mask); diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 8ebaa69..686255d 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h @@ -39,7 +39,7 @@ struct ata_scsi_args { /* libata-core.c */ extern int atapi_enabled; -extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask); +extern int ata_qc_complete_noop(struct ata_queued_cmd *qc); extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, struct ata_device *dev); extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index f557f17..e8df0c9 100644 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c @@ -464,14 +464,12 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) continue; qc = ata_qc_from_tag(ap, ap->active_tag); if (qc && (!(qc->tf.ctl & ATA_NIEN))) { - unsigned int err_mask = 0; - if ((status & (aPERR | aPSD | aUIRQ))) - err_mask = AC_ERR_OTHER; + qc->err_mask |= AC_ERR_OTHER; else if (pp->pkt[0] != cDONE) - err_mask = AC_ERR_OTHER; + qc->err_mask |= AC_ERR_OTHER; - ata_qc_complete(qc, err_mask); + ata_qc_complete(qc); } } return handled; @@ -501,7 +499,8 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set) /* complete taskfile transaction */ pp->state = adma_state_idle; - ata_qc_complete(qc, ac_err_mask(status)); + qc->err_mask |= ac_err_mask(status); + ata_qc_complete(qc); handled = 1; } } diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index c941766..3e7866b 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c @@ -1242,8 +1242,10 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, VPRINTK("port %u IRQ found for qc, " "ata_status 0x%x\n", port,ata_status); /* mark qc status appropriately */ - if (!(qc->tf.ctl & ATA_NIEN)) - ata_qc_complete(qc, err_mask); + if (!(qc->tf.ctl & ATA_NIEN)) { + qc->err_mask |= err_mask; + ata_qc_complete(qc); + } } } } @@ -1864,7 +1866,8 @@ static void mv_eng_timeout(struct ata_port *ap) */ spin_lock_irqsave(&ap->host_set->lock, flags); qc->scsidone = scsi_finish_command; - ata_qc_complete(qc, AC_ERR_OTHER); + qc->err_mask |= AC_ERR_OTHER; + ata_qc_complete(qc); spin_unlock_irqrestore(&ap->host_set->lock, flags); } } diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 0208906..e2e146a 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c @@ -401,7 +401,8 @@ static void pdc_eng_timeout(struct ata_port *ap) case ATA_PROT_NODATA: printk(KERN_ERR "ata%u: command timeout\n", ap->id); drv_stat = ata_wait_idle(ap); - ata_qc_complete(qc, __ac_err_mask(drv_stat)); + qc->err_mask |= __ac_err_mask(drv_stat); + ata_qc_complete(qc); break; default: @@ -410,7 +411,8 @@ static void pdc_eng_timeout(struct ata_port *ap) printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", ap->id, qc->tf.command, drv_stat); - ata_qc_complete(qc, ac_err_mask(drv_stat)); + qc->err_mask |= ac_err_mask(drv_stat); + ata_qc_complete(qc); break; } @@ -422,21 +424,21 @@ out: static inline unsigned int pdc_host_intr( struct ata_port *ap, struct ata_queued_cmd *qc) { - unsigned int handled = 0, err_mask = 0; + unsigned int handled = 0; u32 tmp; void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; tmp = readl(mmio); if (tmp & PDC_ERR_MASK) { - err_mask = AC_ERR_DEV; + qc->err_mask |= AC_ERR_DEV; pdc_reset_port(ap); } switch (qc->tf.protocol) { case ATA_PROT_DMA: case ATA_PROT_NODATA: - err_mask |= ac_err_mask(ata_wait_idle(ap)); - ata_qc_complete(qc, err_mask); + qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); + ata_qc_complete(qc); handled = 1; break; diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index 6b9c3ae..de05e28 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c @@ -409,8 +409,8 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set) case 3: /* device error */ pp->state = qs_state_idle; qs_enter_reg_mode(qc->ap); - ata_qc_complete(qc, - ac_err_mask(sDST)); + qc->err_mask |= ac_err_mask(sDST); + ata_qc_complete(qc); break; default: break; @@ -447,7 +447,8 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set) /* complete taskfile transaction */ pp->state = qs_state_idle; - ata_qc_complete(qc, ac_err_mask(status)); + qc->err_mask |= ac_err_mask(status); + ata_qc_complete(qc); handled = 1; } } diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index e0d6f19..a0ad3ed 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c @@ -654,7 +654,8 @@ static void sil24_eng_timeout(struct ata_port *ap) */ printk(KERN_ERR "ata%u: command timeout\n", ap->id); qc->scsidone = scsi_finish_command; - ata_qc_complete(qc, AC_ERR_OTHER); + qc->err_mask |= AC_ERR_OTHER; + ata_qc_complete(qc); sil24_reset_controller(ap); } @@ -711,8 +712,10 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat) sil24_reset_controller(ap); } - if (qc) - ata_qc_complete(qc, err_mask); + if (qc) { + qc->err_mask |= err_mask; + ata_qc_complete(qc); + } } static inline void sil24_host_intr(struct ata_port *ap) @@ -734,8 +737,10 @@ static inline void sil24_host_intr(struct ata_port *ap) */ sil24_update_tf(ap); - if (qc) - ata_qc_complete(qc, ac_err_mask(pp->tf.command)); + if (qc) { + qc->err_mask |= ac_err_mask(pp->tf.command); + ata_qc_complete(qc); + } } else sil24_error_intr(ap, slot_stat); } diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index 7c4b535..58da854 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c @@ -718,7 +718,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); /* get drive status; clear intr; complete txn */ - ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); + qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); + ata_qc_complete(qc); pdc20621_pop_hdma(qc); } @@ -756,7 +757,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); /* get drive status; clear intr; complete txn */ - ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); + qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); + ata_qc_complete(qc); pdc20621_pop_hdma(qc); } handled = 1; @@ -766,7 +768,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap, status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); - ata_qc_complete(qc, ac_err_mask(status)); + qc->err_mask |= ac_err_mask(status); + ata_qc_complete(qc); handled = 1; } else { @@ -881,7 +884,8 @@ static void pdc_eng_timeout(struct ata_port *ap) case ATA_PROT_DMA: case ATA_PROT_NODATA: printk(KERN_ERR "ata%u: command timeout\n", ap->id); - ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap))); + qc->err_mask |= __ac_err_mask(ata_wait_idle(ap)); + ata_qc_complete(qc); break; default: @@ -890,7 +894,8 @@ static void pdc_eng_timeout(struct ata_port *ap) printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", ap->id, qc->tf.command, drv_stat); - ata_qc_complete(qc, ac_err_mask(drv_stat)); + qc->err_mask |= ac_err_mask(drv_stat); + ata_qc_complete(qc); break; } diff --git a/include/linux/libata.h b/include/linux/libata.h index 83a83ba..e18ce03 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -194,7 +194,7 @@ struct ata_port; struct ata_queued_cmd; /* typedefs */ -typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc, unsigned int err_mask); +typedef int (*ata_qc_cb_t) (struct ata_queued_cmd *qc); struct ata_ioports { unsigned long cmd_addr; @@ -279,6 +279,8 @@ struct ata_queued_cmd { /* DO NOT iterate over __sg manually, use ata_for_each_sg() */ struct scatterlist *__sg; + unsigned int err_mask; + ata_qc_cb_t complete_fn; struct completion *waiting; @@ -475,7 +477,7 @@ extern void ata_bmdma_start (struct ata_queued_cmd *qc); extern void ata_bmdma_stop(struct ata_queued_cmd *qc); extern u8 ata_bmdma_status(struct ata_port *ap); extern void ata_bmdma_irq_clear(struct ata_port *ap); -extern void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask); +extern void ata_qc_complete(struct ata_queued_cmd *qc); extern void ata_eng_timeout(struct ata_port *ap); extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); @@ -667,6 +669,7 @@ static inline void ata_qc_reinit(struct ata_queued_cmd *qc) qc->cursect = qc->cursg = qc->cursg_ofs = 0; qc->nsect = 0; qc->nbytes = qc->curbytes = 0; + qc->err_mask = 0; ata_tf_init(qc->ap, &qc->tf, qc->dev->devno); } -- cgit v1.1 From 1c8489840e6b080e810e588423c1b6dd5913cf18 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 5 Dec 2005 15:40:15 +0800 Subject: [PATCH] libata: determine the err_mask when the error is found - move "qc->err_mask |= AC_ERR_ATA_BUS" to where the error is found - add "assert(qc->err_mask)" to ata_pio_error() to make sure qc->err_mask was available when we enter the error state Signed-off-by: Albert Lee ============ Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index f56b4da..cc003f2 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -2830,6 +2830,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap) status = ata_chk_status(ap); if (status & ATA_BUSY) { if (time_after(jiffies, ap->pio_task_timeout)) { + qc->err_mask |= AC_ERR_ATA_BUS; ap->hsm_task_state = HSM_ST_TMOUT; return 0; } @@ -2880,6 +2881,7 @@ static int ata_pio_complete (struct ata_port *ap) drv_stat = ata_wait_idle(ap); if (!ata_ok(drv_stat)) { + qc->err_mask |= __ac_err_mask(drv_stat); ap->hsm_task_state = HSM_ST_ERR; return 0; } @@ -3195,6 +3197,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) err_out: printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", ap->id, dev->devno); + qc->err_mask |= AC_ERR_ATA_BUS; ap->hsm_task_state = HSM_ST_ERR; } @@ -3244,6 +3247,7 @@ static void ata_pio_block(struct ata_port *ap) } else { /* handle BSY=0, DRQ=0 as error */ if ((status & ATA_DRQ) == 0) { + qc->err_mask |= AC_ERR_ATA_BUS; ap->hsm_task_state = HSM_ST_ERR; return; } @@ -3261,9 +3265,13 @@ static void ata_pio_error(struct ata_port *ap) qc = ata_qc_from_tag(ap, ap->active_tag); assert(qc != NULL); + /* make sure qc->err_mask is available to + * know what's wrong and recover + */ + assert(qc->err_mask); + ap->hsm_task_state = HSM_ST_IDLE; - qc->err_mask |= AC_ERR_ATA_BUS; ata_poll_qc_complete(qc); } -- cgit v1.1 From d8fe452b3e8e9ea6d62a3d116a092999fabae407 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Mon, 5 Dec 2005 15:42:17 +0800 Subject: [PATCH] libata: determine the err_mask directly in atapi_packet_task() - set qc->err_mask directly when we found the error - remove the code to determine err_mask from device status Signed-off-by: Albert Lee ============ Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index cc003f2..b3aedb0 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -4083,13 +4083,17 @@ static void atapi_packet_task(void *_data) /* sleep-wait for BSY to clear */ DPRINTK("busy wait\n"); - if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) - goto err_out_status; + if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { + qc->err_mask |= AC_ERR_ATA_BUS; + goto err_out; + } /* make sure DRQ is set */ status = ata_chk_status(ap); - if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) + if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) { + qc->err_mask |= AC_ERR_ATA_BUS; goto err_out; + } /* send SCSI cdb */ DPRINTK("send cdb\n"); @@ -4121,10 +4125,7 @@ static void atapi_packet_task(void *_data) return; -err_out_status: - status = ata_chk_status(ap); err_out: - qc->err_mask |= __ac_err_mask(status); ata_poll_qc_complete(qc); } -- cgit v1.1 From fe79e683ccdb29c13b3e0d18507474b4e2d9aab6 Mon Sep 17 00:00:00 2001 From: Albert Lee Date: Tue, 6 Dec 2005 11:34:59 +0800 Subject: [PATCH] libata: err_mask misc fix 1. ata_pio_complete(): It seems unnecessary to wait for the clearing of the DRQ bit. (Waiting for BSY=0 should be enough. ata_ok() also checks the correctness of the status bits later.) 2. ata_pio_block(): - added error checking, before transfering data. - minor comments fix Signed-off-by: Albert Lee ============ Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index b3aedb0..e4c4007 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -2865,11 +2865,11 @@ static int ata_pio_complete (struct ata_port *ap) * msecs, then chk-status again. If still busy, fall back to * HSM_ST_POLL state. */ - drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); - if (drv_stat & (ATA_BUSY | ATA_DRQ)) { + drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); + if (drv_stat & ATA_BUSY) { msleep(2); - drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); - if (drv_stat & (ATA_BUSY | ATA_DRQ)) { + drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); + if (drv_stat & ATA_BUSY) { ap->hsm_task_state = HSM_ST_LAST_POLL; ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; return 0; @@ -3236,8 +3236,16 @@ static void ata_pio_block(struct ata_port *ap) qc = ata_qc_from_tag(ap, ap->active_tag); assert(qc != NULL); + /* check error */ + if (status & (ATA_ERR | ATA_DF)) { + qc->err_mask |= AC_ERR_DEV; + ap->hsm_task_state = HSM_ST_ERR; + return; + } + + /* transfer data if any */ if (is_atapi_taskfile(&qc->tf)) { - /* no more data to transfer or unsupported ATAPI command */ + /* DRQ=0 means no more data to transfer */ if ((status & ATA_DRQ) == 0) { ap->hsm_task_state = HSM_ST_LAST; return; -- cgit v1.1 From cc6e8de8f0fab61760bb7091fb19eef1406e17be Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Tue, 6 Dec 2005 15:03:55 -0800 Subject: [CPUFREQ] Change loglevels on powernow-k8 bios error printk's. If a user has booted with 'quiet', some important messages don't get displayed which really should. We've seen at least one case where powernow-k8 stopped working, and the user needed a BIOS update that they didn't know about. Signed-off-by: Dave Jones --- arch/i386/kernel/cpu/cpufreq/powernow-k8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c index f44c1b1..0fbbd4c 100644 --- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c +++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c @@ -635,7 +635,7 @@ static int find_psb_table(struct powernow_k8_data *data) dprintk("table vers: 0x%x\n", psb->tableversion); if (psb->tableversion != PSB_VERSION_1_4) { - printk(KERN_INFO BFX "PSB table is not v1.4\n"); + printk(KERN_ERR BFX "PSB table is not v1.4\n"); return -ENODEV; } @@ -693,7 +693,7 @@ static int find_psb_table(struct powernow_k8_data *data) * BIOS and Kernel Developer's Guide, which is available on * www.amd.com */ - printk(KERN_INFO PFX "BIOS error - no PSB or ACPI _PSS objects\n"); + printk(KERN_ERR PFX "BIOS error - no PSB or ACPI _PSS objects\n"); return -ENODEV; } -- cgit v1.1 From 1a10760c91c394dfe4adfefeeaf85cd8098c4894 Mon Sep 17 00:00:00 2001 From: Mattia Dongili Date: Fri, 2 Dec 2005 21:59:41 +0100 Subject: [CPUFREQ] Measure transition latency at driver initialization The attached patch introduces runtime latency measurement for ICH[234] based chipsets instead of using CPUFREQ_ETERNAL. It includes some sanity checks in case the measured value is out of range and assigns a safe value of 500uSec that should still be enough on problematics chipsets (current testing report values ~200uSec). The measurement is currently done in speedstep_get_freqs in order to avoid further unnecessary transitions and in the hope it'll come handy for SMI also. Signed-off-by: Mattia Dongili Acked-by: Dominik Brodowski Signed-off-by: Dave Jones speedstep-ich.c | 4 ++-- speedstep-lib.c | 32 +++++++++++++++++++++++++++++++- speedstep-lib.h | 1 + speedstep-smi.c | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) --- arch/i386/kernel/cpu/cpufreq/speedstep-ich.c | 4 ++-- arch/i386/kernel/cpu/cpufreq/speedstep-lib.c | 32 +++++++++++++++++++++++++++- arch/i386/kernel/cpu/cpufreq/speedstep-lib.h | 1 + arch/i386/kernel/cpu/cpufreq/speedstep-smi.c | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c b/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c index 5b7d18a..862e0b5 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c @@ -315,10 +315,11 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) cpus_allowed = current->cpus_allowed; set_cpus_allowed(current, policy->cpus); - /* detect low and high frequency */ + /* detect low and high frequency and transition latency */ result = speedstep_get_freqs(speedstep_processor, &speedstep_freqs[SPEEDSTEP_LOW].frequency, &speedstep_freqs[SPEEDSTEP_HIGH].frequency, + &policy->cpuinfo.transition_latency, &speedstep_set_state); set_cpus_allowed(current, cpus_allowed); if (result) @@ -335,7 +336,6 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) /* cpuinfo and default policy values */ policy->governor = CPUFREQ_DEFAULT_GOVERNOR; - policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; policy->cur = speed; result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs); diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c index d368b3f..7c47005 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.c @@ -320,11 +320,13 @@ EXPORT_SYMBOL_GPL(speedstep_detect_processor); unsigned int speedstep_get_freqs(unsigned int processor, unsigned int *low_speed, unsigned int *high_speed, + unsigned int *transition_latency, void (*set_state) (unsigned int state)) { unsigned int prev_speed; unsigned int ret = 0; unsigned long flags; + struct timeval tv1, tv2; if ((!processor) || (!low_speed) || (!high_speed) || (!set_state)) return -EINVAL; @@ -337,7 +339,7 @@ unsigned int speedstep_get_freqs(unsigned int processor, return -EIO; dprintk("previous speed is %u\n", prev_speed); - + local_irq_save(flags); /* switch to low state */ @@ -350,8 +352,17 @@ unsigned int speedstep_get_freqs(unsigned int processor, dprintk("low speed is %u\n", *low_speed); + /* start latency measurement */ + if (transition_latency) + do_gettimeofday(&tv1); + /* switch to high state */ set_state(SPEEDSTEP_HIGH); + + /* end latency measurement */ + if (transition_latency) + do_gettimeofday(&tv2); + *high_speed = speedstep_get_processor_frequency(processor); if (!*high_speed) { ret = -EIO; @@ -369,6 +380,25 @@ unsigned int speedstep_get_freqs(unsigned int processor, if (*high_speed != prev_speed) set_state(SPEEDSTEP_LOW); + if (transition_latency) { + *transition_latency = (tv2.tv_sec - tv1.tv_sec) * USEC_PER_SEC + + tv2.tv_usec - tv1.tv_usec; + dprintk("transition latency is %u uSec\n", *transition_latency); + + /* convert uSec to nSec and add 20% for safety reasons */ + *transition_latency *= 1200; + + /* check if the latency measurement is too high or too low + * and set it to a safe value (500uSec) in that case + */ + if (*transition_latency > 10000000 || *transition_latency < 50000) { + printk (KERN_WARNING "speedstep: frequency transition measured seems out of " + "range (%u nSec), falling back to a safe one of %u nSec.\n", + *transition_latency, 500000); + *transition_latency = 500000; + } + } + out: local_irq_restore(flags); return (ret); diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h index 261a2c9..6a727fd 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-lib.h @@ -44,4 +44,5 @@ extern unsigned int speedstep_get_processor_frequency(unsigned int processor); extern unsigned int speedstep_get_freqs(unsigned int processor, unsigned int *low_speed, unsigned int *high_speed, + unsigned int *transition_latency, void (*set_state) (unsigned int state)); diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c index 2718fb6..28cc5d5 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c @@ -269,6 +269,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) result = speedstep_get_freqs(speedstep_processor, &speedstep_freqs[SPEEDSTEP_LOW].frequency, &speedstep_freqs[SPEEDSTEP_HIGH].frequency, + NULL, &speedstep_set_state); if (result) { -- cgit v1.1 From 9a7d82a89a8bf55b112f2a5c3b3f405eb95a4303 Mon Sep 17 00:00:00 2001 From: Mattia Dongili Date: Wed, 30 Nov 2005 22:00:59 +0100 Subject: [CPUFREQ] Move PMBASE reading away and do it only once at initialization time This patch moves away PMBASE reading and only performs it at cpufreq_register_driver time by exiting with -ENODEV if unable to read the value. Signed-off-by: Mattia Dongili Acked-by: Dominik Brodowski Signed-off-by: Dave Jones --- arch/i386/kernel/cpu/cpufreq/speedstep-ich.c | 43 +++++++++++++++++++--------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c b/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c index 862e0b5..b425cd3d1 100644 --- a/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c +++ b/arch/i386/kernel/cpu/cpufreq/speedstep-ich.c @@ -40,6 +40,7 @@ static struct pci_dev *speedstep_chipset_dev; */ static unsigned int speedstep_processor = 0; +static u32 pmbase; /* * There are only two frequency states for each processor. Values @@ -56,34 +57,47 @@ static struct cpufreq_frequency_table speedstep_freqs[] = { /** - * speedstep_set_state - set the SpeedStep state - * @state: new processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH) + * speedstep_find_register - read the PMBASE address * - * Tries to change the SpeedStep state. + * Returns: -ENODEV if no register could be found */ -static void speedstep_set_state (unsigned int state) +static int speedstep_find_register (void) { - u32 pmbase; - u8 pm2_blk; - u8 value; - unsigned long flags; - - if (!speedstep_chipset_dev || (state > 0x1)) - return; + if (!speedstep_chipset_dev) + return -ENODEV; /* get PMBASE */ pci_read_config_dword(speedstep_chipset_dev, 0x40, &pmbase); if (!(pmbase & 0x01)) { printk(KERN_ERR "speedstep-ich: could not find speedstep register\n"); - return; + return -ENODEV; } pmbase &= 0xFFFFFFFE; if (!pmbase) { printk(KERN_ERR "speedstep-ich: could not find speedstep register\n"); - return; + return -ENODEV; } + dprintk("pmbase is 0x%x\n", pmbase); + return 0; +} + +/** + * speedstep_set_state - set the SpeedStep state + * @state: new processor frequency state (SPEEDSTEP_LOW or SPEEDSTEP_HIGH) + * + * Tries to change the SpeedStep state. + */ +static void speedstep_set_state (unsigned int state) +{ + u8 pm2_blk; + u8 value; + unsigned long flags; + + if (state > 0x1) + return; + /* Disable IRQs */ local_irq_save(flags); @@ -400,6 +414,9 @@ static int __init speedstep_init(void) return -EINVAL; } + if (speedstep_find_register()) + return -ENODEV; + return cpufreq_register_driver(&speedstep_driver); } -- cgit v1.1 From 95235ca2c20ac0b31a8eb39e2d599bcc3e9c9a10 Mon Sep 17 00:00:00 2001 From: Venkatesh Pallipadi Date: Fri, 2 Dec 2005 10:43:20 -0800 Subject: [CPUFREQ] CPU frequency display in /proc/cpuinfo What is the value shown in "cpu MHz" of /proc/cpuinfo when CPUs are capable of changing frequency? Today the answer is: It depends. On i386: SMP kernel - It is always the boot frequency UP kernel - Scales with the frequency change and shows that was last set. On x86_64: There is one single variable cpu_khz that gets written by all the CPUs. So, the frequency set by last CPU will be seen on /proc/cpuinfo of all the CPUs in the system. What you see also depends on whether you have constant_tsc capable CPU or not. On ia64: It is always boot time frequency of a particular CPU that gets displayed. The patch below changes this to: Show the last known frequency of the particular CPU, when cpufreq is present. If cpu doesnot support changing of frequency through cpufreq, then boot frequency will be shown. The patch affects i386, x86_64 and ia64 architectures. Signed-off-by: Venkatesh Pallipadi Signed-off-by: Dave Jones --- arch/i386/kernel/cpu/proc.c | 6 +++++- arch/ia64/kernel/setup.c | 8 +++++++- arch/x86_64/kernel/setup.c | 6 +++++- drivers/cpufreq/cpufreq.c | 24 ++++++++++++++++++++++++ include/linux/cpufreq.h | 10 ++++++++++ 5 files changed, 51 insertions(+), 3 deletions(-) diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c index e792131..6d91b27 100644 --- a/arch/i386/kernel/cpu/proc.c +++ b/arch/i386/kernel/cpu/proc.c @@ -3,6 +3,7 @@ #include #include #include +#include /* * Get CPU information for use by the procfs. @@ -86,8 +87,11 @@ static int show_cpuinfo(struct seq_file *m, void *v) seq_printf(m, "stepping\t: unknown\n"); if ( cpu_has(c, X86_FEATURE_TSC) ) { + unsigned int freq = cpufreq_quick_get(n); + if (!freq) + freq = cpu_khz; seq_printf(m, "cpu MHz\t\t: %u.%03u\n", - cpu_khz / 1000, (cpu_khz % 1000)); + freq / 1000, (freq % 1000)); } /* Cache size */ diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 5add0bc..088e5dd 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -517,6 +518,7 @@ show_cpuinfo (struct seq_file *m, void *v) char family[32], features[128], *cp, sep; struct cpuinfo_ia64 *c = v; unsigned long mask; + unsigned int proc_freq; int i; mask = c->features; @@ -549,6 +551,10 @@ show_cpuinfo (struct seq_file *m, void *v) sprintf(cp, " 0x%lx", mask); } + proc_freq = cpufreq_quick_get(cpunum); + if (!proc_freq) + proc_freq = c->proc_freq / 1000; + seq_printf(m, "processor : %d\n" "vendor : %s\n" @@ -565,7 +571,7 @@ show_cpuinfo (struct seq_file *m, void *v) "BogoMIPS : %lu.%02lu\n", cpunum, c->vendor, family, c->model, c->revision, c->archrev, features, c->ppn, c->number, - c->proc_freq / 1000000, c->proc_freq % 1000000, + proc_freq / 1000, proc_freq % 1000, c->itc_freq / 1000000, c->itc_freq % 1000000, lpj*HZ/500000, (lpj*HZ/5000) % 100); #ifdef CONFIG_SMP diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c index 750e01d..64c4534 100644 --- a/arch/x86_64/kernel/setup.c +++ b/arch/x86_64/kernel/setup.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -1256,8 +1257,11 @@ static int show_cpuinfo(struct seq_file *m, void *v) seq_printf(m, "stepping\t: unknown\n"); if (cpu_has(c,X86_FEATURE_TSC)) { + unsigned int freq = cpufreq_quick_get((unsigned)(c-cpu_data)); + if (!freq) + freq = cpu_khz; seq_printf(m, "cpu MHz\t\t: %u.%03u\n", - cpu_khz / 1000, (cpu_khz % 1000)); + freq / 1000, (freq % 1000)); } /* Cache size */ diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 815902c..a9163d0 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -823,6 +823,30 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne /** + * cpufreq_quick_get - get the CPU frequency (in kHz) frpm policy->cur + * @cpu: CPU number + * + * This is the last known freq, without actually getting it from the driver. + * Return value will be same as what is shown in scaling_cur_freq in sysfs. + */ +unsigned int cpufreq_quick_get(unsigned int cpu) +{ + struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + unsigned int ret = 0; + + if (policy) { + down(&policy->lock); + ret = policy->cur; + up(&policy->lock); + cpufreq_cpu_put(policy); + } + + return (ret); +} +EXPORT_SYMBOL(cpufreq_quick_get); + + +/** * cpufreq_get - get the current CPU frequency (in kHz) * @cpu: CPU number * diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index d068176..c31650d 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -256,6 +256,16 @@ int cpufreq_update_policy(unsigned int cpu); /* query the current CPU frequency (in kHz). If zero, cpufreq couldn't detect it */ unsigned int cpufreq_get(unsigned int cpu); +/* query the last known CPU freq (in kHz). If zero, cpufreq couldn't detect it */ +#ifdef CONFIG_CPU_FREQ +unsigned int cpufreq_quick_get(unsigned int cpu); +#else +static inline unsigned int cpufreq_quick_get(unsigned int cpu) +{ + return 0; +} +#endif + /********************************************************************* * CPUFREQ DEFAULT GOVERNOR * -- cgit v1.1 From 92f965e8c5433408d5a3805c6882b657eb6cbdb1 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:34:53 -0800 Subject: [PATCH] sky2: don't die if we see chip rev 0xb5 There maybe new versions of Yukon2 in the future, so make the driver more robust to handle this. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 7dc5b48..0f694a9 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -128,17 +128,15 @@ MODULE_DEVICE_TABLE(pci, sky2_id_table); static const unsigned txqaddr[] = { Q_XA1, Q_XA2 }; static const unsigned rxqaddr[] = { Q_R1, Q_R2 }; -static const char *yukon_name[] = { - [CHIP_ID_YUKON_LITE - CHIP_ID_YUKON] = "Lite", /* 0xb0 */ - [CHIP_ID_YUKON_LP - CHIP_ID_YUKON] = "LP", /* 0xb2 */ - [CHIP_ID_YUKON_XL - CHIP_ID_YUKON] = "XL", /* 0xb3 */ - [CHIP_ID_YUKON_EC_U - CHIP_ID_YUKON] = "EC Ultra", /* 0xb4 */ - - [CHIP_ID_YUKON_EC - CHIP_ID_YUKON] = "EC", /* 0xb6 */ - [CHIP_ID_YUKON_FE - CHIP_ID_YUKON] = "FE", /* 0xb7 */ +/* This driver supports yukon2 chipset only */ +static const char *yukon2_name[] = { + "XL", /* 0xb3 */ + "EC Ultra", /* 0xb4 */ + "UNKNOWN", /* 0xb5 */ + "EC", /* 0xb6 */ + "FE", /* 0xb7 */ }; - /* Access to external PHY */ static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val) { @@ -2951,7 +2949,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev, printk(KERN_INFO PFX "v%s addr 0x%lx irq %d Yukon-%s (0x%x) rev %d\n", DRV_VERSION, pci_resource_start(pdev, 0), pdev->irq, - yukon_name[hw->chip_id - CHIP_ID_YUKON], + yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], hw->chip_id, hw->chip_rev); dev = sky2_init_netdev(hw, 0, using_dac); -- cgit v1.1 From 6e23231b6509f17a251e6dfddb607d300680ac25 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:34:54 -0800 Subject: [PATCH] sky2: device structure alignment It is a useful optimization to rearrange the structure slightly to align receive and transmit portions. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 930680f..7943dd4 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -1790,17 +1790,17 @@ struct sky2_port { unsigned port; u32 msg_enable; - struct ring_info *tx_ring; + spinlock_t tx_lock ____cacheline_aligned_in_smp; + struct ring_info *tx_ring; struct sky2_tx_le *tx_le; - spinlock_t tx_lock; - u32 tx_addr64; u16 tx_cons; /* next le to check */ u16 tx_prod; /* next le to use */ + u32 tx_addr64; u16 tx_pending; u16 tx_last_put; u16 tx_last_mss; - struct ring_info *rx_ring; + struct ring_info *rx_ring ____cacheline_aligned_in_smp; struct sky2_rx_le *rx_le; u32 rx_addr64; u16 rx_next; /* next re to check */ -- cgit v1.1 From bdb5c58ebe4301f9c3470cc35adeff1ef7ee99eb Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:34:55 -0800 Subject: [PATCH] sky2: copy threshold as module parameter Make the copy threshold a module parameter for those who may want to turn it off. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 0f694a9..f2f8f60 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -76,7 +76,6 @@ #define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le)) #define RX_MAX_PENDING (RX_LE_SIZE/2 - 2) #define RX_DEF_PENDING RX_MAX_PENDING -#define RX_COPY_THRESHOLD 256 #define TX_RING_SIZE 512 #define TX_DEF_PENDING (TX_RING_SIZE - 1) @@ -99,6 +98,10 @@ static int debug = -1; /* defaults above */ module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); +static int copybreak __read_mostly = 256; +module_param(copybreak, int, 0); +MODULE_PARM_DESC(copybreak, "Receive copy threshold"); + static const struct pci_device_id sky2_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, @@ -1653,7 +1656,7 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, if (!(status & GMR_FS_RX_OK)) goto resubmit; - if (length < RX_COPY_THRESHOLD) { + if (length < copybreak) { skb = alloc_skb(length + 2, GFP_ATOMIC); if (!skb) goto resubmit; -- cgit v1.1 From fb17358fe31e01baf902a9fd1fce0e29e3493517 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:34:56 -0800 Subject: [PATCH] sky2: ethtool get/set interrupt coalescing Add support for get/set the interrupt coalescing settings. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 103 insertions(+), 12 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index f2f8f60..0ab3768 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -24,9 +24,6 @@ */ /* - * TODO - * - coalescing setting? - * * TOTEST * - speed setting * - suspend/resume @@ -2019,29 +2016,30 @@ static void sky2_netpoll(struct net_device *dev) #endif /* Chip internal frequency for clock calculations */ -static inline u32 sky2_khz(const struct sky2_hw *hw) +static inline u32 sky2_mhz(const struct sky2_hw *hw) { switch (hw->chip_id) { case CHIP_ID_YUKON_EC: case CHIP_ID_YUKON_EC_U: - return 125000; /* 125 Mhz */ + return 125; /* 125 Mhz */ case CHIP_ID_YUKON_FE: - return 100000; /* 100 Mhz */ + return 100; /* 100 Mhz */ default: /* YUKON_XL */ - return 156000; /* 156 Mhz */ + return 156; /* 156 Mhz */ } } -static inline u32 sky2_ms2clk(const struct sky2_hw *hw, u32 ms) +static inline u32 sky2_us2clk(const struct sky2_hw *hw, u32 us) { - return sky2_khz(hw) * ms; + return sky2_mhz(hw) * us; } -static inline u32 sky2_us2clk(const struct sky2_hw *hw, u32 us) +static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk) { - return (sky2_khz(hw) * us) / 1000; + return clk / sky2_mhz(hw); } + static int sky2_reset(struct sky2_hw *hw) { u32 ctst; @@ -2169,7 +2167,7 @@ static int sky2_reset(struct sky2_hw *hw) /* Set the list last index */ sky2_write16(hw, STAT_LAST_IDX, STATUS_RING_SIZE - 1); - sky2_write32(hw, STAT_TX_TIMER_INI, sky2_ms2clk(hw, 10)); + sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 1000)); /* These status setup values are copied from SysKonnect's driver */ if (is_ec_a1(hw)) { @@ -2680,6 +2678,97 @@ static int sky2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) } #endif +static int sky2_get_coalesce(struct net_device *dev, + struct ethtool_coalesce *ecmd) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + + if (sky2_read8(hw, STAT_TX_TIMER_CTRL) == TIM_STOP) + ecmd->tx_coalesce_usecs = 0; + else { + u32 clks = sky2_read32(hw, STAT_TX_TIMER_INI); + ecmd->tx_coalesce_usecs = sky2_clk2us(hw, clks); + } + ecmd->tx_max_coalesced_frames = sky2_read16(hw, STAT_TX_IDX_TH); + + if (sky2_read8(hw, STAT_LEV_TIMER_CTRL) == TIM_STOP) + ecmd->rx_coalesce_usecs = 0; + else { + u32 clks = sky2_read32(hw, STAT_LEV_TIMER_INI); + ecmd->rx_coalesce_usecs = sky2_clk2us(hw, clks); + } + ecmd->rx_max_coalesced_frames = sky2_read8(hw, STAT_FIFO_WM); + + if (sky2_read8(hw, STAT_ISR_TIMER_CTRL) == TIM_STOP) + ecmd->rx_coalesce_usecs_irq = 0; + else { + u32 clks = sky2_read32(hw, STAT_ISR_TIMER_INI); + ecmd->rx_coalesce_usecs_irq = sky2_clk2us(hw, clks); + } + + ecmd->rx_max_coalesced_frames_irq = sky2_read8(hw, STAT_FIFO_ISR_WM); + + return 0; +} + +/* Note: this affect both ports */ +static int sky2_set_coalesce(struct net_device *dev, + struct ethtool_coalesce *ecmd) +{ + struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + const u32 tmin = sky2_clk2us(hw, 1); + const u32 tmax = 5000; + + if (ecmd->tx_coalesce_usecs != 0 && + (ecmd->tx_coalesce_usecs < tmin || ecmd->tx_coalesce_usecs > tmax)) + return -EINVAL; + + if (ecmd->rx_coalesce_usecs != 0 && + (ecmd->rx_coalesce_usecs < tmin || ecmd->rx_coalesce_usecs > tmax)) + return -EINVAL; + + if (ecmd->rx_coalesce_usecs_irq != 0 && + (ecmd->rx_coalesce_usecs_irq < tmin || ecmd->rx_coalesce_usecs_irq > tmax)) + return -EINVAL; + + if (ecmd->tx_max_coalesced_frames > 0xffff) + return -EINVAL; + if (ecmd->rx_max_coalesced_frames > 0xff) + return -EINVAL; + if (ecmd->rx_max_coalesced_frames_irq > 0xff) + return -EINVAL; + + if (ecmd->tx_coalesce_usecs == 0) + sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP); + else { + sky2_write32(hw, STAT_TX_TIMER_INI, + sky2_us2clk(hw, ecmd->tx_coalesce_usecs)); + sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START); + } + sky2_write16(hw, STAT_TX_IDX_TH, ecmd->tx_max_coalesced_frames); + + if (ecmd->rx_coalesce_usecs == 0) + sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_STOP); + else { + sky2_write32(hw, STAT_LEV_TIMER_INI, + sky2_us2clk(hw, ecmd->rx_coalesce_usecs)); + sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_START); + } + sky2_write8(hw, STAT_FIFO_WM, ecmd->rx_max_coalesced_frames); + + if (ecmd->rx_coalesce_usecs_irq == 0) + sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_STOP); + else { + sky2_write32(hw, STAT_TX_TIMER_INI, + sky2_us2clk(hw, ecmd->rx_coalesce_usecs_irq)); + sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START); + } + sky2_write8(hw, STAT_FIFO_ISR_WM, ecmd->rx_max_coalesced_frames_irq); + return 0; +} + static void sky2_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ering) { @@ -2765,6 +2854,8 @@ static struct ethtool_ops sky2_ethtool_ops = { .get_rx_csum = sky2_get_rx_csum, .set_rx_csum = sky2_set_rx_csum, .get_strings = sky2_get_strings, + .get_coalesce = sky2_get_coalesce, + .set_coalesce = sky2_set_coalesce, .get_ringparam = sky2_get_ringparam, .set_ringparam = sky2_set_ringparam, .get_pauseparam = sky2_get_pauseparam, -- cgit v1.1 From 91c86df5a8a44157b456bf1e91fc6d878582e68c Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:34:57 -0800 Subject: [PATCH] sky2: phy processing in workqueue rather than tasklet Do phy processing in a work queue rather than a tasklet. This means we can let bottom halves run. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 58 ++++++++++++++++++++++++++++-------------------------- drivers/net/sky2.h | 6 +++--- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 0ab3768..2cb6406 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -535,9 +536,9 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) sky2_read16(hw, SK_REG(port, GMAC_IRQ_SRC)); - spin_lock_bh(&hw->phy_lock); + down(&sky2->phy_sema); sky2_phy_init(hw, port); - spin_unlock_bh(&hw->phy_lock); + up(&sky2->phy_sema); /* MIB clear */ reg = gma_read16(hw, port, GM_PHY_ADDR); @@ -839,9 +840,11 @@ static int sky2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /* fallthru */ case SIOCGMIIREG: { u16 val = 0; - spin_lock_bh(&hw->phy_lock); + + down(&sky2->phy_sema); err = __gm_phy_read(hw, sky2->port, data->reg_num & 0x1f, &val); - spin_unlock_bh(&hw->phy_lock); + up(&sky2->phy_sema); + data->val_out = val; break; } @@ -850,10 +853,10 @@ static int sky2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) if (!capable(CAP_NET_ADMIN)) return -EPERM; - spin_lock_bh(&hw->phy_lock); + down(&sky2->phy_sema); err = gm_phy_write(hw, sky2->port, data->reg_num & 0x1f, data->val_in); - spin_unlock_bh(&hw->phy_lock); + up(&sky2->phy_sema); break; } return err; @@ -1308,6 +1311,7 @@ static int sky2_down(struct net_device *dev) sky2_write32(hw, B0_IMSK, hw->intr_mask); local_irq_enable(); + flush_scheduled_work(); sky2_phy_reset(hw, port); @@ -1520,17 +1524,17 @@ static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux) } /* - * Interrupt from PHY are handled in tasklet (soft irq) + * Interrupt from PHY are handled outside of interrupt context * because accessing phy registers requires spin wait which might * cause excess interrupt latency. */ -static void sky2_phy_task(unsigned long data) +static void sky2_phy_task(void *arg) { - struct sky2_port *sky2 = (struct sky2_port *)data; + struct sky2_port *sky2 = arg; struct sky2_hw *hw = sky2->hw; u16 istatus, phystat; - spin_lock(&hw->phy_lock); + down(&sky2->phy_sema); istatus = gm_phy_read(hw, sky2->port, PHY_MARV_INT_STAT); phystat = gm_phy_read(hw, sky2->port, PHY_MARV_PHY_STAT); @@ -1558,7 +1562,7 @@ static void sky2_phy_task(unsigned long data) sky2_link_down(sky2); } out: - spin_unlock(&hw->phy_lock); + up(&sky2->phy_sema); local_irq_disable(); hw->intr_mask |= (sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2; @@ -1960,7 +1964,7 @@ static void sky2_phy_intr(struct sky2_hw *hw, unsigned port) hw->intr_mask &= ~(port == 0 ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2); sky2_write32(hw, B0_IMSK, hw->intr_mask); - tasklet_schedule(&sky2->phy_task); + schedule_work(&sky2->phy_task); } static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs) @@ -2150,10 +2154,8 @@ static int sky2_reset(struct sky2_hw *hw) sky2_write32(hw, B0_HWE_IMSK, Y2_HWE_ALL_MASK); - spin_lock_bh(&hw->phy_lock); for (i = 0; i < hw->ports; i++) sky2_phy_reset(hw, i); - spin_unlock_bh(&hw->phy_lock); memset(hw->st_le, 0, STATUS_LE_BYTES); hw->st_idx = 0; @@ -2386,10 +2388,10 @@ static int sky2_nway_reset(struct net_device *dev) netif_stop_queue(dev); - spin_lock_irq(&hw->phy_lock); + down(&sky2->phy_sema); sky2_phy_reset(hw, sky2->port); sky2_phy_init(hw, sky2->port); - spin_unlock_irq(&hw->phy_lock); + up(&sky2->phy_sema); return 0; } @@ -2528,11 +2530,10 @@ static void sky2_set_multicast(struct net_device *dev) /* Can have one global because blinking is controlled by * ethtool and that is always under RTNL mutex */ -static inline void sky2_led(struct sky2_hw *hw, unsigned port, int on) +static void sky2_led(struct sky2_hw *hw, unsigned port, int on) { u16 pg; - spin_lock_bh(&hw->phy_lock); switch (hw->chip_id) { case CHIP_ID_YUKON_XL: pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); @@ -2562,7 +2563,6 @@ static inline void sky2_led(struct sky2_hw *hw, unsigned port, int on) PHY_M_LED_MO_RX(MO_LED_OFF)); } - spin_unlock_bh(&hw->phy_lock); } /* blink LED's for finding board */ @@ -2573,6 +2573,7 @@ static int sky2_phys_id(struct net_device *dev, u32 data) unsigned port = sky2->port; u16 ledctrl, ledover = 0; long ms; + int interrupted; int onoff = 1; if (!data || data > (u32) (MAX_SCHEDULE_TIMEOUT / HZ)) @@ -2581,7 +2582,7 @@ static int sky2_phys_id(struct net_device *dev, u32 data) ms = data * 1000; /* save initial values */ - spin_lock_bh(&hw->phy_lock); + down(&sky2->phy_sema); if (hw->chip_id == CHIP_ID_YUKON_XL) { u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); @@ -2591,19 +2592,20 @@ static int sky2_phys_id(struct net_device *dev, u32 data) ledctrl = gm_phy_read(hw, port, PHY_MARV_LED_CTRL); ledover = gm_phy_read(hw, port, PHY_MARV_LED_OVER); } - spin_unlock_bh(&hw->phy_lock); - while (ms > 0) { + interrupted = 0; + while (!interrupted && ms > 0) { sky2_led(hw, port, onoff); onoff = !onoff; - if (msleep_interruptible(250)) - break; /* interrupted */ + up(&sky2->phy_sema); + interrupted = msleep_interruptible(250); + down(&sky2->phy_sema); + ms -= 250; } /* resume regularly scheduled programming */ - spin_lock_bh(&hw->phy_lock); if (hw->chip_id == CHIP_ID_YUKON_XL) { u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR); gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3); @@ -2613,7 +2615,7 @@ static int sky2_phys_id(struct net_device *dev, u32 data) gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl); gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover); } - spin_unlock_bh(&hw->phy_lock); + up(&sky2->phy_sema); return 0; } @@ -2917,7 +2919,8 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, sky2->speed = -1; sky2->advertising = sky2_supported_modes(hw); sky2->rx_csum = 1; - tasklet_init(&sky2->phy_task, sky2_phy_task, (unsigned long)sky2); + INIT_WORK(&sky2->phy_task, sky2_phy_task, sky2); + init_MUTEX(&sky2->phy_sema); sky2->tx_pending = TX_DEF_PENDING; sky2->rx_pending = is_ec_a1(hw) ? 8 : RX_DEF_PENDING; @@ -3027,7 +3030,6 @@ static int __devinit sky2_probe(struct pci_dev *pdev, memset(hw, 0, sizeof(*hw)); hw->pdev = pdev; - spin_lock_init(&hw->phy_lock); hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); if (!hw->regs) { diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 7943dd4..29ebca0 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -1823,8 +1823,10 @@ struct sky2_port { u8 rx_csum; u8 wol; - struct tasklet_struct phy_task; struct net_device_stats net_stats; + + struct work_struct phy_task; + struct semaphore phy_sema; }; struct sky2_hw { @@ -1842,8 +1844,6 @@ struct sky2_hw { struct sky2_status_le *st_le; u32 st_idx; dma_addr_t st_dma; - - spinlock_t phy_lock; }; /* Register accessor for memory mapped device */ -- cgit v1.1 From f2e46561cc1afa82b18b2fc6efc8510ec57c7d7d Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:34:58 -0800 Subject: [PATCH] sky2: no irq disable needed during tx Don't need to disable interrupts during the transmit routine. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 2cb6406..eae270d 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -868,15 +868,14 @@ static void sky2_vlan_rx_register(struct net_device *dev, struct vlan_group *grp struct sky2_port *sky2 = netdev_priv(dev); struct sky2_hw *hw = sky2->hw; u16 port = sky2->port; - unsigned long flags; - spin_lock_irqsave(&sky2->tx_lock, flags); + spin_lock(&sky2->tx_lock); sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_ON); sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_ON); sky2->vlgrp = grp; - spin_unlock_irqrestore(&sky2->tx_lock, flags); + spin_unlock(&sky2->tx_lock); } static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) @@ -884,16 +883,15 @@ static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) struct sky2_port *sky2 = netdev_priv(dev); struct sky2_hw *hw = sky2->hw; u16 port = sky2->port; - unsigned long flags; - spin_lock_irqsave(&sky2->tx_lock, flags); + spin_lock(&sky2->tx_lock); sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_OFF); sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_OFF); if (sky2->vlgrp) sky2->vlgrp->vlan_devices[vid] = NULL; - spin_unlock_irqrestore(&sky2->tx_lock, flags); + spin_unlock(&sky2->tx_lock); } #endif @@ -1072,6 +1070,8 @@ static inline unsigned tx_le_req(const struct sk_buff *skb) * A single packet can generate multiple list elements, and * the number of ring elements will probably be less than the number * of list elements used. + * + * No BH disabling for tx_lock here (like tg3) */ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) { @@ -1079,22 +1079,18 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) struct sky2_hw *hw = sky2->hw; struct sky2_tx_le *le = NULL; struct ring_info *re; - unsigned long flags; unsigned i, len; dma_addr_t mapping; u32 addr64; u16 mss; u8 ctrl; - local_irq_save(flags); - if (!spin_trylock(&sky2->tx_lock)) { - local_irq_restore(flags); + if (!spin_trylock(&sky2->tx_lock)) return NETDEV_TX_LOCKED; - } if (unlikely(tx_avail(sky2) < tx_le_req(skb))) { netif_stop_queue(dev); - spin_unlock_irqrestore(&sky2->tx_lock, flags); + spin_unlock(&sky2->tx_lock); printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", dev->name); @@ -1226,7 +1222,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) out_unlock: mmiowb(); - spin_unlock_irqrestore(&sky2->tx_lock, flags); + spin_unlock(&sky2->tx_lock); dev->trans_start = jiffies; return NETDEV_TX_OK; -- cgit v1.1 From 129372d0524c9124d5693f63c1d3c1ce2e3714ce Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:34:59 -0800 Subject: [PATCH] sky2: ring distance optimization Faster way to compute ring distance. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index eae270d..2dd46a0 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1039,7 +1039,7 @@ err_out: /* Modular subtraction in ring */ static inline int tx_dist(unsigned tail, unsigned head) { - return (head >= tail ? head : head + TX_RING_SIZE) - tail; + return (head - tail) % TX_RING_SIZE; } /* Number of list elements available for next tx */ -- cgit v1.1 From 734d18684695dd1c6a9527b50e01bba4acab4738 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:00 -0800 Subject: [PATCH] sky2: map length optimization Don't need to keep track of mapping length in ring structure because we can get the same info from other info. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 57 +++++++++++++++++++++++++++--------------------------- drivers/net/sky2.h | 2 +- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 2dd46a0..b1a5886 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -729,23 +729,23 @@ static inline u32 high32(dma_addr_t a) } /* Build description to hardware about buffer */ -static inline void sky2_rx_add(struct sky2_port *sky2, struct ring_info *re) +static inline void sky2_rx_add(struct sky2_port *sky2, dma_addr_t map) { struct sky2_rx_le *le; - u32 hi = high32(re->mapaddr); + u32 hi = high32(map); + u16 len = sky2->rx_bufsize; - re->idx = sky2->rx_put; if (sky2->rx_addr64 != hi) { le = sky2_next_rx(sky2); le->addr = cpu_to_le32(hi); le->ctrl = 0; le->opcode = OP_ADDR64 | HW_OWNER; - sky2->rx_addr64 = high32(re->mapaddr + re->maplen); + sky2->rx_addr64 = high32(map + len); } le = sky2_next_rx(sky2); - le->addr = cpu_to_le32((u32) re->mapaddr); - le->length = cpu_to_le16(re->maplen); + le->addr = cpu_to_le32((u32) map); + le->length = cpu_to_le16(len); le->ctrl = 0; le->opcode = OP_PACKET | HW_OWNER; } @@ -814,7 +814,7 @@ static void sky2_rx_clean(struct sky2_port *sky2) if (re->skb) { pci_unmap_single(sky2->hw->pdev, - re->mapaddr, re->maplen, + re->mapaddr, sky2->rx_bufsize, PCI_DMA_FROMDEVICE); kfree_skb(re->skb); re->skb = NULL; @@ -895,12 +895,6 @@ static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) } #endif -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) -static inline unsigned rx_size(const struct sky2_port *sky2) -{ - return roundup(sky2->netdev->mtu + ETH_HLEN + 4, 8); -} - /* * Allocate and setup receiver buffer pool. * In case of 64 bit dma, there are 2X as many list elements @@ -915,7 +909,6 @@ static inline unsigned rx_size(const struct sky2_port *sky2) static int sky2_rx_start(struct sky2_port *sky2) { struct sky2_hw *hw = sky2->hw; - unsigned size = rx_size(sky2); unsigned rxq = rxqaddr[sky2->port]; int i; @@ -927,14 +920,13 @@ static int sky2_rx_start(struct sky2_port *sky2) for (i = 0; i < sky2->rx_pending; i++) { struct ring_info *re = sky2->rx_ring + i; - re->skb = dev_alloc_skb(size); + re->skb = dev_alloc_skb(sky2->rx_bufsize); if (!re->skb) goto nomem; re->mapaddr = pci_map_single(hw->pdev, re->skb->data, - size, PCI_DMA_FROMDEVICE); - re->maplen = size; - sky2_rx_add(sky2, re); + sky2->rx_bufsize, PCI_DMA_FROMDEVICE); + sky2_rx_add(sky2, re->mapaddr); } /* Tell chip about available buffers */ @@ -1182,7 +1174,6 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) /* Record the transmit mapping info */ re->skb = skb; re->mapaddr = mapping; - re->maplen = len; for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; @@ -1209,7 +1200,6 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) + ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE; fre->skb = NULL; fre->mapaddr = mapping; - fre->maplen = frag->size; } re->idx = sky2->tx_prod; le->ctrl |= EOP; @@ -1258,8 +1248,8 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) goto out; skb = re->skb; - pci_unmap_single(sky2->hw->pdev, - re->mapaddr, re->maplen, PCI_DMA_TODEVICE); + pci_unmap_single(sky2->hw->pdev, re->mapaddr, + skb_headlen(skb), PCI_DMA_TODEVICE); for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { struct ring_info *fre; @@ -1267,7 +1257,8 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) sky2->tx_ring + (sky2->tx_cons + i + 1) % TX_RING_SIZE; pci_unmap_page(sky2->hw->pdev, fre->mapaddr, - fre->maplen, PCI_DMA_TODEVICE); + skb_shinfo(skb)->frags[i].size, + PCI_DMA_TODEVICE); } dev_kfree_skb_any(skb); @@ -1579,6 +1570,14 @@ static void sky2_tx_timeout(struct net_device *dev) sky2_tx_clean(sky2); } + +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +/* Want receive buffer size to be multiple of 64 bits, and incl room for vlan */ +static inline unsigned sky2_buf_size(int mtu) +{ + return roundup(mtu + ETH_HLEN + 4, 8); +} + static int sky2_change_mtu(struct net_device *dev, int new_mtu) { struct sky2_port *sky2 = netdev_priv(dev); @@ -1609,6 +1608,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) sky2_rx_clean(sky2); dev->mtu = new_mtu; + sky2->rx_bufsize = sky2_buf_size(new_mtu); mode = DATA_BLIND_VAL(DATA_BLIND_DEF) | GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF); @@ -1639,7 +1639,6 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, { struct ring_info *re = sky2->rx_ring + sky2->rx_next; struct sk_buff *skb = NULL; - const unsigned int bufsize = rx_size(sky2); if (unlikely(netif_msg_rx_status(sky2))) printk(KERN_DEBUG PFX "%s: rx slot %u status 0x%x len %d\n", @@ -1669,25 +1668,24 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, } else { struct sk_buff *nskb; - nskb = dev_alloc_skb(bufsize); + nskb = dev_alloc_skb(sky2->rx_bufsize); if (!nskb) goto resubmit; skb = re->skb; re->skb = nskb; pci_unmap_single(sky2->hw->pdev, re->mapaddr, - re->maplen, PCI_DMA_FROMDEVICE); + sky2->rx_bufsize, PCI_DMA_FROMDEVICE); prefetch(skb->data); re->mapaddr = pci_map_single(sky2->hw->pdev, nskb->data, - bufsize, PCI_DMA_FROMDEVICE); - re->maplen = bufsize; + sky2->rx_bufsize, PCI_DMA_FROMDEVICE); } skb_put(skb, length); resubmit: re->skb->ip_summed = CHECKSUM_NONE; - sky2_rx_add(sky2, re); + sky2_rx_add(sky2, re->mapaddr); /* Tell receiver about new buffers. */ sky2_put_idx(sky2->hw, rxqaddr[sky2->port], sky2->rx_put, @@ -2919,6 +2917,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, init_MUTEX(&sky2->phy_sema); sky2->tx_pending = TX_DEF_PENDING; sky2->rx_pending = is_ec_a1(hw) ? 8 : RX_DEF_PENDING; + sky2->rx_bufsize = sky2_buf_size(ETH_DATA_LEN); hw->dev[port] = dev; diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 29ebca0..1a91c2d 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -1780,7 +1780,6 @@ struct sky2_status_le { struct ring_info { struct sk_buff *skb; dma_addr_t mapaddr; - u16 maplen; u16 idx; }; @@ -1807,6 +1806,7 @@ struct sky2_port { u16 rx_put; /* next le index to use */ u16 rx_pending; u16 rx_last_put; + u16 rx_bufsize; #ifdef SKY2_VLAN_TAG_USED u16 rx_tag; struct vlan_group *vlgrp; -- cgit v1.1 From 6cdbbdf3055f4657c9d6ccc79257bbcac1a9a1fc Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:01 -0800 Subject: [PATCH] sky2: tx/rx ring data structure split Split Tx and Rx ring into two different data structures. Tx needs the next value (to handle partial status), and Rx always needs the mapaddr (to handle resubmitting same buffer). Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 24 +++++++++++++----------- drivers/net/sky2.h | 9 +++++++-- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index b1a5886..1eefacb 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -958,7 +958,7 @@ static int sky2_up(struct net_device *dev) if (!sky2->tx_le) goto err_out; - sky2->tx_ring = kzalloc(TX_RING_SIZE * sizeof(struct ring_info), + sky2->tx_ring = kcalloc(TX_RING_SIZE, sizeof(struct tx_ring_info), GFP_KERNEL); if (!sky2->tx_ring) goto err_out; @@ -970,7 +970,7 @@ static int sky2_up(struct net_device *dev) goto err_out; memset(sky2->rx_le, 0, RX_LE_BYTES); - sky2->rx_ring = kzalloc(sky2->rx_pending * sizeof(struct ring_info), + sky2->rx_ring = kcalloc(sky2->rx_pending, sizeof(struct ring_info), GFP_KERNEL); if (!sky2->rx_ring) goto err_out; @@ -1070,7 +1070,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) struct sky2_port *sky2 = netdev_priv(dev); struct sky2_hw *hw = sky2->hw; struct sky2_tx_le *le = NULL; - struct ring_info *re; + struct tx_ring_info *re; unsigned i, len; dma_addr_t mapping; u32 addr64; @@ -1173,11 +1173,11 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) /* Record the transmit mapping info */ re->skb = skb; - re->mapaddr = mapping; + pci_unmap_addr_set(re, mapaddr, mapping); for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; - struct ring_info *fre; + struct tx_ring_info *fre; mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset, frag->size, PCI_DMA_TODEVICE); @@ -1198,9 +1198,9 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) fre = sky2->tx_ring + ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE; - fre->skb = NULL; - fre->mapaddr = mapping; + pci_unmap_addr_set(fre, mapaddr, mapping); } + re->idx = sky2->tx_prod; le->ctrl |= EOP; @@ -1239,7 +1239,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) spin_lock(&sky2->tx_lock); while (sky2->tx_cons != done) { - struct ring_info *re = sky2->tx_ring + sky2->tx_cons; + struct tx_ring_info *re = sky2->tx_ring + sky2->tx_cons; struct sk_buff *skb; /* Check for partial status */ @@ -1248,15 +1248,17 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) goto out; skb = re->skb; - pci_unmap_single(sky2->hw->pdev, re->mapaddr, + pci_unmap_single(sky2->hw->pdev, + pci_unmap_addr(re, mapaddr), skb_headlen(skb), PCI_DMA_TODEVICE); for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - struct ring_info *fre; + struct tx_ring_info *fre; fre = sky2->tx_ring + (sky2->tx_cons + i + 1) % TX_RING_SIZE; - pci_unmap_page(sky2->hw->pdev, fre->mapaddr, + pci_unmap_page(sky2->hw->pdev, + pci_unmap_addr(fre, mapaddr), skb_shinfo(skb)->frags[i].size, PCI_DMA_TODEVICE); } diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 1a91c2d..9551892 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h @@ -1777,10 +1777,15 @@ struct sky2_status_le { u8 opcode; } __attribute((packed)); +struct tx_ring_info { + struct sk_buff *skb; + DECLARE_PCI_UNMAP_ADDR(mapaddr); + u16 idx; +}; + struct ring_info { struct sk_buff *skb; dma_addr_t mapaddr; - u16 idx; }; struct sky2_port { @@ -1790,7 +1795,7 @@ struct sky2_port { u32 msg_enable; spinlock_t tx_lock ____cacheline_aligned_in_smp; - struct ring_info *tx_ring; + struct tx_ring_info *tx_ring; struct sky2_tx_le *tx_le; u16 tx_cons; /* next le to check */ u16 tx_prod; /* next le to use */ -- cgit v1.1 From 0e3ff6aab1ff2d093996bd7b8c9c06c3d823855c Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:02 -0800 Subject: [PATCH] sky2: transmit logic fixes Some transmit side small fixes: * When computing number of list elements per transmit, do full comparision to check for checksuming. * Get rid of racy check for tx_complete * Change stop test to match wake condition. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 1eefacb..8dfd27d 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1051,7 +1051,7 @@ static inline unsigned tx_le_req(const struct sk_buff *skb) if (skb_shinfo(skb)->tso_size) ++count; - if (skb->ip_summed) + if (skb->ip_summed == CHECKSUM_HW) ++count; return count; @@ -1207,7 +1207,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) sky2_put_idx(hw, txqaddr[sky2->port], sky2->tx_prod, &sky2->tx_last_put, TX_RING_SIZE); - if (tx_avail(sky2) < MAX_SKB_TX_LE + 1) + if (tx_avail(sky2) <= MAX_SKB_TX_LE) netif_stop_queue(dev); out_unlock: @@ -1229,8 +1229,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) struct net_device *dev = sky2->netdev; unsigned i; - if (done == sky2->tx_cons) - return; + BUG_ON(done >= TX_RING_SIZE); if (unlikely(netif_msg_tx_done(sky2))) printk(KERN_DEBUG "%s: tx done, up to %u\n", -- cgit v1.1 From 13b97b74b964f9da9b5dab6c57708bccd3ada542 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:03 -0800 Subject: [PATCH] sky2: transmit complete index optimization Change transmit complete handling to use the status values in the poll list because they are in-cache, rather than reading non-cached memory for chips status. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 8dfd27d..ff6557d 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1274,7 +1274,7 @@ out: } /* Cleanup all untransmitted buffers, assume transmitter not running */ -static inline void sky2_tx_clean(struct sky2_port *sky2) +static void sky2_tx_clean(struct sky2_port *sky2) { sky2_tx_complete(sky2, sky2->tx_prod); } @@ -1714,14 +1714,16 @@ error: /* * Check for transmit complete */ -static inline void sky2_tx_check(struct sky2_hw *hw, int port) -{ - struct net_device *dev = hw->dev[port]; +#define TX_NO_STATUS 0xffff - if (dev && netif_running(dev)) { - sky2_tx_complete(netdev_priv(dev), - sky2_read16(hw, port == 0 - ? STAT_TXA1_RIDX : STAT_TXA2_RIDX)); +static inline void sky2_tx_check(struct sky2_hw *hw, int port, u16 last) +{ + if (last != TX_NO_STATUS) { + struct net_device *dev = hw->dev[port]; + if (dev && netif_running(dev)) { + struct sky2_port *sky2 = netdev_priv(dev); + sky2_tx_complete(sky2, last); + } } } @@ -1735,6 +1737,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) unsigned int to_do = min(dev0->quota, *budget); unsigned int work_done = 0; u16 hwidx; + u16 tx_done[2] = { TX_NO_STATUS, TX_NO_STATUS }; sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); hwidx = sky2_read16(hw, STAT_PUT_IDX); @@ -1806,7 +1809,10 @@ static int sky2_poll(struct net_device *dev0, int *budget) break; case OP_TXINDEXLE: - /* pick up transmit status later */ + /* TX index reports status for both ports */ + tx_done[0] = status & 0xffff; + tx_done[1] = ((status >> 24) & 0xff) + | (u16)(length & 0xf) << 8; break; default: @@ -1818,16 +1824,13 @@ static int sky2_poll(struct net_device *dev0, int *budget) } exit_loop: - sky2_tx_check(hw, 0); - sky2_tx_check(hw, 1); - mmiowb(); + sky2_tx_check(hw, 0, tx_done[0]); + sky2_tx_check(hw, 1, tx_done[1]); + if (work_done < to_do) { - /* - * Another chip workaround, need to restart TX timer if status - * LE was handled. WA_DEV_43_418 - */ + /* need to restart TX timer */ if (is_ec_a1(hw)) { sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP); sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START); -- cgit v1.1 From af2a58acb12f6b19e6f04b730203e199abedc44a Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:04 -0800 Subject: [PATCH] sky2: transmit complete routine optimization Hand optimize transmit completion routine. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index ff6557d..21aeb0c 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1227,6 +1227,8 @@ out_unlock: static void sky2_tx_complete(struct sky2_port *sky2, u16 done) { struct net_device *dev = sky2->netdev; + struct pci_dev *pdev = sky2->hw->pdev; + u16 nxt, put; unsigned i; BUG_ON(done >= TX_RING_SIZE); @@ -1235,39 +1237,34 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) printk(KERN_DEBUG "%s: tx done, up to %u\n", dev->name, done); - spin_lock(&sky2->tx_lock); + for (put = sky2->tx_cons; put != done; put = nxt) { + struct tx_ring_info *re = sky2->tx_ring + put; + struct sk_buff *skb = re->skb; - while (sky2->tx_cons != done) { - struct tx_ring_info *re = sky2->tx_ring + sky2->tx_cons; - struct sk_buff *skb; + nxt = re->idx; + BUG_ON(nxt >= TX_RING_SIZE); /* Check for partial status */ - if (tx_dist(sky2->tx_cons, done) - < tx_dist(sky2->tx_cons, re->idx)) - goto out; + if (tx_dist(put, done) < tx_dist(put, nxt)) + break; skb = re->skb; - pci_unmap_single(sky2->hw->pdev, - pci_unmap_addr(re, mapaddr), + pci_unmap_single(pdev, pci_unmap_addr(re, mapaddr), skb_headlen(skb), PCI_DMA_TODEVICE); for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { struct tx_ring_info *fre; - fre = - sky2->tx_ring + (sky2->tx_cons + i + - 1) % TX_RING_SIZE; - pci_unmap_page(sky2->hw->pdev, - pci_unmap_addr(fre, mapaddr), - skb_shinfo(skb)->frags[i].size, + fre = sky2->tx_ring + (put + i + 1) % TX_RING_SIZE; + pci_unmap_page(pdev, pci_unmap_addr(fre, mapaddr), + skb_shinfo(skb)->frags[i].size, PCI_DMA_TODEVICE); } dev_kfree_skb_any(skb); - - sky2->tx_cons = re->idx; } -out: + spin_lock(&sky2->tx_lock); + sky2->tx_cons = put; if (netif_queue_stopped(dev) && tx_avail(sky2) > MAX_SKB_TX_LE) netif_wake_queue(dev); spin_unlock(&sky2->tx_lock); @@ -1742,7 +1739,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); hwidx = sky2_read16(hw, STAT_PUT_IDX); BUG_ON(hwidx >= STATUS_RING_SIZE); - rmb(); + rmb(); while (hwidx != hw->st_idx) { struct sky2_status_le *le = hw->st_le + hw->st_idx; -- cgit v1.1 From 3e4b32e11674a40cf50e48a79764f12988641e20 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:05 -0800 Subject: [PATCH] sky2: interrupt/poll optimization Optimize poll routine by not clearing interrupt till after processing, and checking for more work before re-enable. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 21aeb0c..af9739c 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1736,7 +1736,6 @@ static int sky2_poll(struct net_device *dev0, int *budget) u16 hwidx; u16 tx_done[2] = { TX_NO_STATUS, TX_NO_STATUS }; - sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); hwidx = sky2_read16(hw, STAT_PUT_IDX); BUG_ON(hwidx >= STATUS_RING_SIZE); rmb(); @@ -1754,8 +1753,6 @@ static int sky2_poll(struct net_device *dev0, int *budget) hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE; prefetch(hw->st_le + hw->st_idx); - BUG_ON(le->link >= hw->ports || !hw->dev[le->link]); - BUG_ON(le->link >= 2); dev = hw->dev[le->link]; if (dev == NULL || !netif_running(dev)) @@ -1821,12 +1818,13 @@ static int sky2_poll(struct net_device *dev0, int *budget) } exit_loop: + sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); mmiowb(); sky2_tx_check(hw, 0, tx_done[0]); sky2_tx_check(hw, 1, tx_done[1]); - if (work_done < to_do) { + if (sky2_read16(hw, STAT_PUT_IDX) == hw->st_idx) { /* need to restart TX timer */ if (is_ec_a1(hw)) { sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP); -- cgit v1.1 From 69634ee7366d05b26b2650584bed180edf923125 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:06 -0800 Subject: [PATCH] sky2: interrupt coalescing tuning Adjust interrupt deferral values for better performance and avoid starvation issues under stress. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index af9739c..0b82dbb 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -2115,9 +2115,8 @@ static int sky2_reset(struct sky2_hw *hw) sky2_write8(hw, B0_Y2LED, LED_STAT_ON); - /* Turn on descriptor polling (every 75us) */ - sky2_write32(hw, B28_DPT_INI, sky2_us2clk(hw, 75)); - sky2_write8(hw, B28_DPT_CTRL, DPT_START); + /* Turn off descriptor polling */ + sky2_write32(hw, B28_DPT_CTRL, DPT_STOP); /* Turn off receive timestamp */ sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_STOP); @@ -2162,8 +2161,6 @@ static int sky2_reset(struct sky2_hw *hw) /* Set the list last index */ sky2_write16(hw, STAT_LAST_IDX, STATUS_RING_SIZE - 1); - sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 1000)); - /* These status setup values are copied from SysKonnect's driver */ if (is_ec_a1(hw)) { /* WA for dev. #4.3 */ @@ -2174,21 +2171,20 @@ static int sky2_reset(struct sky2_hw *hw) /* set Status-FIFO ISR watermark */ sky2_write8(hw, STAT_FIFO_ISR_WM, 0x07); /* WA for dev. #4.18 */ - + sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 10000)); } else { - sky2_write16(hw, STAT_TX_IDX_TH, 0x000a); - - /* set Status-FIFO watermark */ - sky2_write8(hw, STAT_FIFO_WM, 0x10); + sky2_write16(hw, STAT_TX_IDX_TH, 10); + sky2_write8(hw, STAT_FIFO_WM, 16); /* set Status-FIFO ISR watermark */ if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0) - sky2_write8(hw, STAT_FIFO_ISR_WM, 0x10); - - else /* WA dev 4.109 */ - sky2_write8(hw, STAT_FIFO_ISR_WM, 0x04); + sky2_write8(hw, STAT_FIFO_ISR_WM, 4); + else + sky2_write8(hw, STAT_FIFO_ISR_WM, 16); - sky2_write32(hw, STAT_ISR_TIMER_INI, 0x0190); + sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 1000)); + sky2_write32(hw, STAT_LEV_TIMER_INI, sky2_us2clk(hw, 100)); + sky2_write32(hw, STAT_ISR_TIMER_INI, sky2_us2clk(hw, 20)); } /* enable status unit */ -- cgit v1.1 From 8cc048e338ad4034255f3ff72ef1f631963e1263 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:07 -0800 Subject: [PATCH] sky2: handle tx timeout Put more logic in to try and handle transmit timeout recovery. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 0b82dbb..e1733aa 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -661,7 +661,7 @@ static void sky2_qset(struct sky2_hw *hw, u16 q) /* Setup prefetch unit registers. This is the interface between * hardware and driver list elements */ -static inline void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr, +static void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr, u64 addr, u32 last) { sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); @@ -1558,14 +1558,25 @@ out: static void sky2_tx_timeout(struct net_device *dev) { struct sky2_port *sky2 = netdev_priv(dev); + struct sky2_hw *hw = sky2->hw; + unsigned txq = txqaddr[sky2->port]; if (netif_msg_timer(sky2)) printk(KERN_ERR PFX "%s: tx timeout\n", dev->name); - sky2_write32(sky2->hw, Q_ADDR(txqaddr[sky2->port], Q_CSR), BMU_STOP); - sky2_read32(sky2->hw, Q_ADDR(txqaddr[sky2->port], Q_CSR)); + netif_stop_queue(dev); + + sky2_write32(hw, Q_ADDR(txq, Q_CSR), BMU_STOP); + sky2_read32(hw, Q_ADDR(txq, Q_CSR)); + + sky2_write32(hw, Y2_QADDR(txq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); sky2_tx_clean(sky2); + + sky2_qset(hw, txq); + sky2_prefetch_init(hw, txq, sky2->tx_le_map, TX_RING_SIZE - 1); + + netif_wake_queue(dev); } -- cgit v1.1 From 8c463ef7928d7a42bb9ca410df9b294dc01c1850 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:08 -0800 Subject: [PATCH] sky2: quiet ring full message in case of race Don't print ring full message if we lose race. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index e1733aa..54947ae 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1081,11 +1081,16 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_LOCKED; if (unlikely(tx_avail(sky2) < tx_le_req(skb))) { - netif_stop_queue(dev); + /* There is a known but harmless race with lockless tx + * and netif_stop_queue. + */ + if (!netif_queue_stopped(dev)) { + netif_stop_queue(dev); + printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", + dev->name); + } spin_unlock(&sky2->tx_lock); - printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", - dev->name); return NETDEV_TX_BUSY; } -- cgit v1.1 From d70cd51ac0585a9273abea4c333e8f0dd8385d27 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:09 -0800 Subject: [PATCH] sky2: prefetch tuning Add a couple more prefetches to where we walk the rings. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 54947ae..39916e7 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -1248,6 +1249,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) nxt = re->idx; BUG_ON(nxt >= TX_RING_SIZE); + prefetch(sky2->tx_ring + nxt); /* Check for partial status */ if (tx_dist(put, done) < tx_dist(put, nxt)) @@ -1659,6 +1661,7 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, sky2->netdev->name, sky2->rx_next, status, length); sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending; + prefetch(sky2->rx_ring + sky2->rx_next); if (status & GMR_FS_ANY_ERR) goto error; -- cgit v1.1 From 585b56012f08a6edc598d17b28a6c434134bfaff Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:10 -0800 Subject: [PATCH] sky2: turn on tx flow control Turn symmetric flow control on by default. This was an oversight in the initial versions. Signed-off-by: Stephen HEmminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 39916e7..cdcbf72 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -2921,7 +2921,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, spin_lock_init(&sky2->tx_lock); /* Auto speed and flow control */ sky2->autoneg = AUTONEG_ENABLE; - sky2->tx_pause = 0; + sky2->tx_pause = 1; sky2->rx_pause = 1; sky2->duplex = -1; sky2->speed = -1; -- cgit v1.1 From 75d070c56fa77913b165947f046304efcd38e516 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:11 -0800 Subject: [PATCH] sky2: disable rx checksum on Yukon XL Under load, my SysKonnect SK-9S22 sees duplicate checksums from earlier packets. Doesn't happen on other platforms so just disable receive checksum there. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index cdcbf72..b9c0aaf 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -2926,7 +2926,13 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw, sky2->duplex = -1; sky2->speed = -1; sky2->advertising = sky2_supported_modes(hw); - sky2->rx_csum = 1; + + /* Receive checksum disabled for Yukon XL + * because of observed problems with incorrect + * values when multiple packets are received in one interrupt + */ + sky2->rx_csum = (hw->chip_id != CHIP_ID_YUKON_XL); + INIT_WORK(&sky2->phy_task, sky2_phy_task, sky2); init_MUTEX(&sky2->phy_sema); sky2->tx_pending = TX_DEF_PENDING; -- cgit v1.1 From fed954dafc0ab03e00501862df397e8f8e2211fd Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 9 Dec 2005 11:35:12 -0800 Subject: [PATCH] sky2: version 0.10 Change version number. Still don't have enough history on this to call it 1.0 yet. Signed-off-by: Stephen Hemminger Signed-off-by: Jeff Garzik --- drivers/net/sky2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index b9c0aaf..7af72cd 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -57,7 +57,7 @@ #include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "0.9" +#define DRV_VERSION "0.10" #define PFX DRV_NAME " " /* -- cgit v1.1 From d96212ed87d032d2d830e265aae14038dc1f8ad8 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 8 Dec 2005 19:19:50 +0000 Subject: [PATCH] libata: add ata_piix notes Ok lets start with the 'easy' stuff. This includes my research and summary of chip errata into the new driver so that people can refer to it when updating ata_piix. No code changes Signed-off-by: Jeff Garzik --- drivers/scsi/ata_piix.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 887b2b9..908ff1f 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -37,6 +37,49 @@ * * Hardware documentation available at http://developer.intel.com/ * + * Documentation + * Publically available from Intel web site. Errata documentation + * is also publically available. As an aide to anyone hacking on this + * driver the list of errata that are relevant is below.going back to + * PIIX4. Older device documentation is now a bit tricky to find. + * + * The chipsets all follow very much the same design. The orginal Triton + * series chipsets do _not_ support independant device timings, but this + * is fixed in Triton II. With the odd mobile exception the chips then + * change little except in gaining more modes until SATA arrives. This + * driver supports only the chips with independant timing (that is those + * with SITRE and the 0x44 timing register). See pata_oldpiix and pata_mpiix + * for the early chip drivers. + * + * Errata of note: + * + * Unfixable + * PIIX4 errata #9 - Only on ultra obscure hw + * ICH3 errata #13 - Not observed to affect real hw + * by Intel + * + * Things we must deal with + * PIIX4 errata #10 - BM IDE hang with non UDMA + * (must stop/start dma to recover) + * 440MX errata #15 - As PIIX4 errata #10 + * PIIX4 errata #15 - Must not read control registers + * during a PIO transfer + * 440MX errata #13 - As PIIX4 errata #15 + * ICH2 errata #21 - DMA mode 0 doesn't work right + * ICH0/1 errata #55 - As ICH2 errata #21 + * ICH2 spec c #9 - Extra operations needed to handle + * drive hotswap [NOT YET SUPPORTED] + * ICH2 spec c #20 - IDE PRD must not cross a 64K boundary + * and must be dword aligned + * ICH2 spec c #24 - UDMA mode 4,5 t85/86 should be 6ns not 3.3 + * + * Should have been BIOS fixed: + * 450NX: errata #19 - DMA hangs on old 450NX + * 450NX: errata #20 - DMA hangs on old 450NX + * 450NX: errata #25 - Corruption with DMA on old 450NX + * ICH3 errata #15 - IDE deadlock under high load + * (BIOS must set dev 31 fn 0 bit 23) + * ICH3 errata #18 - Don't use native mode */ #include -- cgit v1.1 From 51c1d80e929bace26d2d795bd77fcc14b02ba3bb Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 12 Dec 2005 23:03:19 -0500 Subject: ieee1394: run high-level updates before high-level probes After a bus reset, let nodemgr call high-level update hooks first for nodes which do not need to be probed. The main benefit is for a bus with more than one SBP-2 device: SBP-2 reconnects will be performed before SBP-2 logins, thus have a much higher chance to succeed, and their SCSI devices will not be blocked much longer than necessary. This was demonstrated for Linux 2.4 by Dave Cinege a while ago. A better approach would be to perform time-consuming probes in parallel by a subthread. I actually plan to implement this for sbp2 but it may take a while to get that done and tested. Until then, this tweak is a huge improvement for users with multiple SBP-2 devices. Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/nodemgr.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 01ab2bf..0ec2987 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -1407,14 +1407,28 @@ static void nodemgr_node_probe(struct host_info *hi, int generation) struct hpsb_host *host = hi->host; struct class *class = &nodemgr_ne_class; struct class_device *cdev; + struct node_entry *ne; /* Do some processing of the nodes we've probed. This pulls them * into the sysfs layer if needed, and can result in processing of * unit-directories, or just updating the node and it's - * unit-directories. */ + * unit-directories. + * + * Run updates before probes. Usually, updates are time-critical + * while probes are time-consuming. (Well, those probes need some + * improvement...) */ + down_read(&class->subsys.rwsem); - list_for_each_entry(cdev, &class->children, node) - nodemgr_probe_ne(hi, container_of(cdev, struct node_entry, class_dev), generation); + list_for_each_entry(cdev, &class->children, node) { + ne = container_of(cdev, struct node_entry, class_dev); + if (!ne->needs_probe) + nodemgr_probe_ne(hi, ne, generation); + } + list_for_each_entry(cdev, &class->children, node) { + ne = container_of(cdev, struct node_entry, class_dev); + if (ne->needs_probe) + nodemgr_probe_ne(hi, ne, generation); + } up_read(&class->subsys.rwsem); -- cgit v1.1 From 43863eba763e0c91e33e342ce5b7650fea594a53 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 12 Dec 2005 23:03:24 -0500 Subject: sbp2: delete sbp2scsi_direction_table DMA_BIDIRECTIONAL data direction may be handled properly by Linux in the future. For now, reject it instead to convert it to another direction. Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/sbp2.c | 45 ++++++++++++++++----------------------------- drivers/ieee1394/sbp2.h | 40 +--------------------------------------- 2 files changed, 17 insertions(+), 68 deletions(-) diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index f0763b7..372a772 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -1740,28 +1740,15 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ - /* - * Get the direction of the transfer. If the direction is unknown, then use our - * goofy table as a back-up. - */ - switch (dma_dir) { - case DMA_NONE: + if (dma_dir == DMA_NONE) orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; - break; - case DMA_TO_DEVICE: + else if (dma_dir == DMA_TO_DEVICE && scsi_request_bufflen) orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA; - break; - case DMA_FROM_DEVICE: + else if (dma_dir == DMA_FROM_DEVICE && scsi_request_bufflen) orb_direction = ORB_DIRECTION_READ_FROM_MEDIA; - break; - case DMA_BIDIRECTIONAL: - default: - SBP2_ERR("SCSI data transfer direction not specified. " - "Update the SBP2 direction table in sbp2.h if " - "necessary for your application"); - __scsi_print_command(scsi_cmd); - orb_direction = sbp2scsi_direction_table[*scsi_cmd]; - break; + else { + SBP2_WARN("Falling back to DMA_NONE"); + orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; } /* @@ -1880,16 +1867,6 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, command_orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen); command_orb->misc |= ORB_SET_DIRECTION(orb_direction); - /* - * Sanity, in case our direction table is not - * up-to-date - */ - if (!scsi_request_bufflen) { - command_orb->data_descriptor_hi = 0x0; - command_orb->data_descriptor_lo = 0x0; - command_orb->misc |= ORB_SET_DIRECTION(1); - } - } else { /* * Need to turn this into page tables, since the @@ -2371,6 +2348,16 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt, } /* + * Bidirectional commands are not yet implemented, + * and unknown transfer direction not handled. + */ + if (SCpnt->sc_data_direction == DMA_BIDIRECTIONAL) { + SBP2_ERR("Cannot handle DMA_BIDIRECTIONAL - rejecting command"); + result = DID_ERROR << 16; + goto done; + } + + /* * Try and send our SCSI command */ if (sbp2_send_command(scsi_id, SCpnt, done)) { diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index abc647b..8e227c5 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h @@ -260,45 +260,7 @@ struct sbp2_status_block { #define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 #define SBP2_MAX_UDS_PER_NODE 16 /* Maximum scsi devices per node */ #define SBP2_MAX_SECTORS 255 /* Max sectors supported */ - -/* - * SCSI direction table... - * (now used as a back-up in case the direction passed down from above is "unknown") - * - * DIN = IN data direction - * DOU = OUT data direction - * DNO = No data transfer - * DUN = Unknown data direction - * - * Opcode 0xec (Teac specific "opc execute") possibly should be DNO, - * but we'll change it when somebody reports a problem with this. - */ -#define DIN ORB_DIRECTION_READ_FROM_MEDIA -#define DOU ORB_DIRECTION_WRITE_TO_MEDIA -#define DNO ORB_DIRECTION_NO_DATA_TRANSFER -#define DUN DIN - -static unchar sbp2scsi_direction_table[0x100] = { - DNO,DNO,DIN,DIN,DOU,DIN,DIN,DOU,DIN,DUN,DOU,DOU,DUN,DUN,DUN,DIN, - DNO,DIN,DIN,DOU,DIN,DOU,DNO,DNO,DOU,DNO,DIN,DNO,DIN,DOU,DNO,DUN, - DIN,DUN,DIN,DIN,DOU,DIN,DUN,DUN,DIN,DIN,DOU,DNO,DUN,DIN,DOU,DOU, - DOU,DOU,DOU,DNO,DIN,DNO,DNO,DIN,DOU,DOU,DOU,DOU,DIN,DOU,DIN,DOU, - DOU,DOU,DIN,DIN,DIN,DNO,DIN,DNO,DNO,DNO,DUN,DNO,DOU,DIN,DNO,DUN, - DUN,DIN,DIN,DNO,DNO,DOU,DUN,DUN,DNO,DIN,DIN,DNO,DIN,DOU,DUN,DUN, - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, - DUN,DNO,DOU,DOU,DIN,DNO,DNO,DNO,DIN,DNO,DOU,DUN,DNO,DIN,DOU,DOU, - DOU,DOU,DOU,DNO,DUN,DIN,DOU,DIN,DIN,DIN,DNO,DNO,DNO,DIN,DIN,DUN, - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN, - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DOU,DUN,DUN,DUN,DUN,DUN, - DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN -}; - -/* This should be safe */ -#define SBP2_MAX_CMDS 8 +#define SBP2_MAX_CMDS 8 /* This should be safe */ /* This is the two dma types we use for cmd_dma below */ enum cmd_dma_types { -- cgit v1.1 From dc3edd5412341b02d84144ddfd5bf6ccaaeeb1ac Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Mon, 12 Dec 2005 23:03:30 -0500 Subject: sbp2: did not clean up after scsi_add_device() failed If scsi_add_device() at the end of sbp2_start_device() fails, e.g. due to transport errors during SCSI inquiry, sbp2 needs to log out of the device and release all associated resources. Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/sbp2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 372a772..5b9d03e 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -960,6 +960,8 @@ alloc_fail: error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0); if (error) { SBP2_ERR("scsi_add_device failed"); + sbp2_logout_device(scsi_id); + sbp2_remove_device(scsi_id); return error; } -- cgit v1.1 From c621b140603dfb4a89809e00f965d42c054871e0 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Thu, 8 Dec 2005 19:22:28 +0000 Subject: [PATCH] libata: ata_piix 450NX errata Signed-off-by: Alan Cox Signed-off-by: Jeff Garzik --- drivers/scsi/ata_piix.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 908ff1f..0ea2787 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -620,6 +620,40 @@ static int piix_disable_ahci(struct pci_dev *pdev) } /** + * piix_check_450nx_errata - Check for problem 450NX setup + * + * Check for the present of 450NX errata #19 and errata #25. If + * they are found return an error code so we can turn off DMA + */ + +static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev) +{ + struct pci_dev *pdev = NULL; + u16 cfg; + u8 rev; + int no_piix_dma = 0; + + while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL) + { + /* Look for 450NX PXB. Check for problem configurations + A PCI quirk checks bit 6 already */ + pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); + pci_read_config_word(pdev, 0x41, &cfg); + /* Only on the original revision: IDE DMA can hang */ + if(rev == 0x00) + no_piix_dma = 1; + /* On all revisions below 5 PXB bus lock must be disabled for IDE */ + else if(cfg & (1<<14) && rev < 5) + no_piix_dma = 2; + } + if(no_piix_dma) + dev_printk(KERN_WARNING, &ata_dev->dev, "450NX errata present, disabling IDE DMA.\n"); + if(no_piix_dma == 2) + dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n"); + return no_piix_dma; +} + +/** * piix_init_one - Register PIIX ATA PCI device with kernel services * @pdev: PCI device to register * @ent: Entry in piix_pci_tbl matching with @pdev @@ -693,7 +727,15 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) "combined mode detected (p=%u, s=%u)\n", pata_chan, sata_chan); } - + if (piix_check_450nx_errata(pdev)) { + /* This writes into the master table but it does not + really matter for this errata as we will apply it to + all the PIIX devices on the board */ + port_info[0]->mwdma_mask = 0; + port_info[0]->udma_mask = 0; + port_info[1]->mwdma_mask = 0; + port_info[1]->udma_mask = 0; + } return ata_pci_init_one(pdev, port_info, 2); } -- cgit v1.1 From fd803241744ad6e4262b6588c6af89e8fb794098 Mon Sep 17 00:00:00 2001 From: Jeff Kirsher Date: Tue, 13 Dec 2005 00:06:22 -0500 Subject: e1000: Fixes for 8357x - TSO workaround - Fixes eeprom version reporting - Fix loopback test - Fix for WOL Signed-off-by: Jeff Kirsher Signed-off-by: John Ronciak Signed-off-by: Jesse Brandeburg --- drivers/net/e1000/e1000.h | 4 +- drivers/net/e1000/e1000_ethtool.c | 95 +++++++++++++++++++++++++++++---------- drivers/net/e1000/e1000_hw.c | 67 +++++++++++++++++++-------- drivers/net/e1000/e1000_hw.h | 4 +- drivers/net/e1000/e1000_main.c | 64 ++++++++++---------------- 5 files changed, 150 insertions(+), 84 deletions(-) diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h index 3f653a9..e02e9ba 100644 --- a/drivers/net/e1000/e1000.h +++ b/drivers/net/e1000/e1000.h @@ -188,11 +188,13 @@ struct e1000_tx_ring { /* array of buffer information structs */ struct e1000_buffer *buffer_info; - struct e1000_buffer previous_buffer_info; spinlock_t tx_lock; uint16_t tdh; uint16_t tdt; uint64_t pkt; + + boolean_t last_tx_tso; + }; struct e1000_rx_ring { diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index 8646914..c88f1a3 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c @@ -562,10 +562,29 @@ e1000_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) { struct e1000_adapter *adapter = netdev_priv(netdev); + char firmware_version[32]; + uint16_t eeprom_data; strncpy(drvinfo->driver, e1000_driver_name, 32); strncpy(drvinfo->version, e1000_driver_version, 32); - strncpy(drvinfo->fw_version, "N/A", 32); + + /* EEPROM image version # is reported as firware version # for + * 8257{1|2|3} controllers */ + e1000_read_eeprom(&adapter->hw, 5, 1, &eeprom_data); + switch (adapter->hw.mac_type) { + case e1000_82571: + case e1000_82572: + case e1000_82573: + sprintf(firmware_version, "%d.%d-%d", + (eeprom_data & 0xF000) >> 12, + (eeprom_data & 0x0FF0) >> 4, + eeprom_data & 0x000F); + break; + default: + sprintf(firmware_version, "n/a"); + } + + strncpy(drvinfo->fw_version, firmware_version, 32); strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); drvinfo->n_stats = E1000_STATS_LEN; drvinfo->testinfo_len = E1000_TEST_LEN; @@ -1309,21 +1328,32 @@ static int e1000_setup_loopback_test(struct e1000_adapter *adapter) { uint32_t rctl; + struct e1000_hw *hw = &adapter->hw; - if(adapter->hw.media_type == e1000_media_type_fiber || - adapter->hw.media_type == e1000_media_type_internal_serdes) { - if(adapter->hw.mac_type == e1000_82545 || - adapter->hw.mac_type == e1000_82546 || - adapter->hw.mac_type == e1000_82545_rev_3 || - adapter->hw.mac_type == e1000_82546_rev_3) + if (hw->media_type == e1000_media_type_fiber || + hw->media_type == e1000_media_type_internal_serdes) { + switch (hw->mac_type) { + case e1000_82545: + case e1000_82546: + case e1000_82545_rev_3: + case e1000_82546_rev_3: return e1000_set_phy_loopback(adapter); - else { - rctl = E1000_READ_REG(&adapter->hw, RCTL); + break; + case e1000_82571: + case e1000_82572: +#define E1000_SERDES_LB_ON 0x410 + e1000_set_phy_loopback(adapter); + E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_ON); + msec_delay(10); + return 0; + break; + default: + rctl = E1000_READ_REG(hw, RCTL); rctl |= E1000_RCTL_LBM_TCVR; - E1000_WRITE_REG(&adapter->hw, RCTL, rctl); + E1000_WRITE_REG(hw, RCTL, rctl); return 0; } - } else if(adapter->hw.media_type == e1000_media_type_copper) + } else if (hw->media_type == e1000_media_type_copper) return e1000_set_phy_loopback(adapter); return 7; @@ -1334,25 +1364,36 @@ e1000_loopback_cleanup(struct e1000_adapter *adapter) { uint32_t rctl; uint16_t phy_reg; + struct e1000_hw *hw = &adapter->hw; rctl = E1000_READ_REG(&adapter->hw, RCTL); rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC); E1000_WRITE_REG(&adapter->hw, RCTL, rctl); - if(adapter->hw.media_type == e1000_media_type_copper || - ((adapter->hw.media_type == e1000_media_type_fiber || - adapter->hw.media_type == e1000_media_type_internal_serdes) && - (adapter->hw.mac_type == e1000_82545 || - adapter->hw.mac_type == e1000_82546 || - adapter->hw.mac_type == e1000_82545_rev_3 || - adapter->hw.mac_type == e1000_82546_rev_3))) { - adapter->hw.autoneg = TRUE; - e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); - if(phy_reg & MII_CR_LOOPBACK) { + switch (hw->mac_type) { + case e1000_82571: + case e1000_82572: + if (hw->media_type == e1000_media_type_fiber || + hw->media_type == e1000_media_type_internal_serdes){ +#define E1000_SERDES_LB_OFF 0x400 + E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_OFF); + msec_delay(10); + break; + } + /* fall thru for Cu adapters */ + case e1000_82545: + case e1000_82546: + case e1000_82545_rev_3: + case e1000_82546_rev_3: + default: + hw->autoneg = TRUE; + e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg); + if (phy_reg & MII_CR_LOOPBACK) { phy_reg &= ~MII_CR_LOOPBACK; - e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg); - e1000_phy_reset(&adapter->hw); + e1000_write_phy_reg(hw, PHY_CTRL, phy_reg); + e1000_phy_reset(hw); } + break; } } @@ -1681,6 +1722,14 @@ e1000_phys_id(struct net_device *netdev, uint32_t data) msleep_interruptible(data * 1000); del_timer_sync(&adapter->blink_timer); } + else if(adapter->hw.mac_type < e1000_82573) { + E1000_WRITE_REG(&adapter->hw, LEDCTL, (E1000_LEDCTL_LED2_BLINK_RATE | + E1000_LEDCTL_LED0_BLINK | E1000_LEDCTL_LED2_BLINK | + (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED2_MODE_SHIFT) | + (E1000_LEDCTL_MODE_LINK_ACTIVITY << E1000_LEDCTL_LED0_MODE_SHIFT) | + (E1000_LEDCTL_MODE_LED_OFF << E1000_LEDCTL_LED1_MODE_SHIFT))); + msleep_interruptible(data * 1000); + } else { E1000_WRITE_REG(&adapter->hw, LEDCTL, (E1000_LEDCTL_LED2_BLINK_RATE | E1000_LEDCTL_LED1_BLINK | E1000_LEDCTL_LED2_BLINK | diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c index a267c52..136fc03 100644 --- a/drivers/net/e1000/e1000_hw.c +++ b/drivers/net/e1000/e1000_hw.c @@ -563,11 +563,13 @@ e1000_reset_hw(struct e1000_hw *hw) msec_delay(20); break; case e1000_82573: - udelay(10); - ctrl_ext = E1000_READ_REG(hw, CTRL_EXT); - ctrl_ext |= E1000_CTRL_EXT_EE_RST; - E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); - E1000_WRITE_FLUSH(hw); + if (e1000_is_onboard_nvm_eeprom(hw) == FALSE) { + udelay(10); + ctrl_ext = E1000_READ_REG(hw, CTRL_EXT); + ctrl_ext |= E1000_CTRL_EXT_EE_RST; + E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); + E1000_WRITE_FLUSH(hw); + } /* fall through */ case e1000_82571: case e1000_82572: @@ -844,19 +846,27 @@ e1000_setup_link(struct e1000_hw *hw) * control setting, then the variable hw->fc will * be initialized based on a value in the EEPROM. */ - if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data)) { - DEBUGOUT("EEPROM Read Error\n"); - return -E1000_ERR_EEPROM; - } - - if(hw->fc == e1000_fc_default) { - if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0) - hw->fc = e1000_fc_none; - else if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == - EEPROM_WORD0F_ASM_DIR) - hw->fc = e1000_fc_tx_pause; - else + if (hw->fc == e1000_fc_default) { + switch (hw->mac_type) { + case e1000_82573: hw->fc = e1000_fc_full; + break; + default: + ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, + 1, &eeprom_data); + if (ret_val) { + DEBUGOUT("EEPROM Read Error\n"); + return -E1000_ERR_EEPROM; + } + if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0) + hw->fc = e1000_fc_none; + else if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == + EEPROM_WORD0F_ASM_DIR) + hw->fc = e1000_fc_tx_pause; + else + hw->fc = e1000_fc_full; + break; + } } /* We want to save off the original Flow Control configuration just @@ -2962,13 +2972,22 @@ e1000_phy_hw_reset(struct e1000_hw *hw) if(hw->mac_type > e1000_82543) { /* Read the device control register and assert the E1000_CTRL_PHY_RST * bit. Then, take it out of reset. + * For pre-e1000_82571 hardware, we delay for 10ms between the assert + * and deassert. For e1000_82571 hardware and later, we instead delay + * for 10ms after the deassertion. */ ctrl = E1000_READ_REG(hw, CTRL); E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST); E1000_WRITE_FLUSH(hw); - msec_delay(10); + + if (hw->mac_type < e1000_82571) + msec_delay(10); + E1000_WRITE_REG(hw, CTRL, ctrl); E1000_WRITE_FLUSH(hw); + + if (hw->mac_type >= e1000_82571) + msec_delay(10); } else { /* Read the Extended Device Control Register, assert the PHY_RESET_DIR * bit to put the PHY into reset. Then, take it out of reset. @@ -5278,11 +5297,15 @@ e1000_get_bus_info(struct e1000_hw *hw) hw->bus_speed = e1000_bus_speed_unknown; hw->bus_width = e1000_bus_width_unknown; break; - case e1000_82571: case e1000_82572: case e1000_82573: hw->bus_type = e1000_bus_type_pci_express; hw->bus_speed = e1000_bus_speed_2500; + hw->bus_width = e1000_bus_width_pciex_1; + break; + case e1000_82571: + hw->bus_type = e1000_bus_type_pci_express; + hw->bus_speed = e1000_bus_speed_2500; hw->bus_width = e1000_bus_width_pciex_4; break; default: @@ -6650,6 +6673,12 @@ e1000_get_auto_rd_done(struct e1000_hw *hw) break; } + /* PHY configuration from NVM just starts after EECD_AUTO_RD sets to high. + * Need to wait for PHY configuration completion before accessing NVM + * and PHY. */ + if (hw->mac_type == e1000_82573) + msec_delay(25); + return E1000_SUCCESS; } diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h index 76ce128..7caa357 100644 --- a/drivers/net/e1000/e1000_hw.h +++ b/drivers/net/e1000/e1000_hw.h @@ -123,6 +123,7 @@ typedef enum { e1000_bus_width_32, e1000_bus_width_64, e1000_bus_width_pciex_1, + e1000_bus_width_pciex_2, e1000_bus_width_pciex_4, e1000_bus_width_reserved } e1000_bus_width; @@ -149,6 +150,7 @@ typedef enum { e1000_igp_cable_length_90 = 90, e1000_igp_cable_length_100 = 100, e1000_igp_cable_length_110 = 110, + e1000_igp_cable_length_115 = 115, e1000_igp_cable_length_120 = 120, e1000_igp_cable_length_130 = 130, e1000_igp_cable_length_140 = 140, @@ -1457,6 +1459,7 @@ struct e1000_hw { #define E1000_EECD_AUPDEN 0x00100000 /* Enable Autonomous FLASH update */ #define E1000_EECD_SHADV 0x00200000 /* Shadow RAM Data Valid */ #define E1000_EECD_SEC1VAL 0x00400000 /* Sector One Valid */ +#define E1000_EECD_SECVAL_SHIFT 22 #define E1000_STM_OPCODE 0xDB00 #define E1000_HICR_FW_RESET 0xC0 @@ -1951,7 +1954,6 @@ struct e1000_host_command_info { #define E1000_MDALIGN 4096 -#define E1000_GCR_BEM32 0x00400000 #define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000 /* Function Active and Power State to MNG */ #define E1000_FACTPS_FUNC0_POWER_STATE_MASK 0x00000003 diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index e0ae248..438a931 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c @@ -711,6 +711,7 @@ e1000_probe(struct pci_dev *pdev, break; case e1000_82546: case e1000_82546_rev_3: + case e1000_82571: if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1) && (adapter->hw.media_type == e1000_media_type_copper)) { e1000_read_eeprom(&adapter->hw, @@ -1158,7 +1159,6 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter, return -ENOMEM; } memset(txdr->buffer_info, 0, size); - memset(&txdr->previous_buffer_info, 0, sizeof(struct e1000_buffer)); /* round up to nearest 4K */ @@ -1813,11 +1813,6 @@ e1000_clean_tx_ring(struct e1000_adapter *adapter, /* Free all the Tx ring sk_buffs */ - if (likely(tx_ring->previous_buffer_info.skb != NULL)) { - e1000_unmap_and_free_tx_resource(adapter, - &tx_ring->previous_buffer_info); - } - for(i = 0; i < tx_ring->count; i++) { buffer_info = &tx_ring->buffer_info[i]; e1000_unmap_and_free_tx_resource(adapter, buffer_info); @@ -1832,6 +1827,7 @@ e1000_clean_tx_ring(struct e1000_adapter *adapter, tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; + tx_ring->last_tx_tso = 0; writel(0, adapter->hw.hw_addr + tx_ring->tdh); writel(0, adapter->hw.hw_addr + tx_ring->tdt); @@ -2437,6 +2433,16 @@ e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, buffer_info = &tx_ring->buffer_info[i]; size = min(len, max_per_txd); #ifdef NETIF_F_TSO + /* Workaround for Controller erratum -- + * descriptor for non-tso packet in a linear SKB that follows a + * tso gets written back prematurely before the data is fully + * DMAd to the controller */ + if (!skb->data_len && tx_ring->last_tx_tso && + !skb_shinfo(skb)->tso_size) { + tx_ring->last_tx_tso = 0; + size -= 4; + } + /* Workaround for premature desc write-backs * in TSO mode. Append 4-byte sentinel desc */ if(unlikely(mss && !nr_frags && size == len && size > 8)) @@ -2693,6 +2699,14 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) if(skb->ip_summed == CHECKSUM_HW) count++; #endif + +#ifdef NETIF_F_TSO + /* Controller Erratum workaround */ + if (!skb->data_len && tx_ring->last_tx_tso && + !skb_shinfo(skb)->tso_size) + count++; +#endif + count += TXD_USE_COUNT(len, max_txd_pwr); if(adapter->pcix_82544) @@ -2774,9 +2788,10 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) return NETDEV_TX_OK; } - if (likely(tso)) + if (likely(tso)) { + tx_ring->last_tx_tso = 1; tx_flags |= E1000_TX_FLAGS_TSO; - else if (likely(e1000_tx_csum(adapter, tx_ring, skb))) + } else if (likely(e1000_tx_csum(adapter, tx_ring, skb))) tx_flags |= E1000_TX_FLAGS_CSUM; /* Old method was to assume IPv4 packet by default if TSO was enabled. @@ -3227,37 +3242,12 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter, eop_desc = E1000_TX_DESC(*tx_ring, eop); while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) { - /* Premature writeback of Tx descriptors clear (free buffers - * and unmap pci_mapping) previous_buffer_info */ - if (likely(tx_ring->previous_buffer_info.skb != NULL)) { - e1000_unmap_and_free_tx_resource(adapter, - &tx_ring->previous_buffer_info); - } - for(cleaned = FALSE; !cleaned; ) { tx_desc = E1000_TX_DESC(*tx_ring, i); buffer_info = &tx_ring->buffer_info[i]; cleaned = (i == eop); -#ifdef NETIF_F_TSO - if (!(netdev->features & NETIF_F_TSO)) { -#endif - e1000_unmap_and_free_tx_resource(adapter, - buffer_info); -#ifdef NETIF_F_TSO - } else { - if (cleaned) { - memcpy(&tx_ring->previous_buffer_info, - buffer_info, - sizeof(struct e1000_buffer)); - memset(buffer_info, 0, - sizeof(struct e1000_buffer)); - } else { - e1000_unmap_and_free_tx_resource( - adapter, buffer_info); - } - } -#endif + e1000_unmap_and_free_tx_resource(adapter, buffer_info); tx_desc->buffer_addr = 0; tx_desc->lower.data = 0; @@ -3318,12 +3308,6 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter, netif_stop_queue(netdev); } } -#ifdef NETIF_F_TSO - if (unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && - time_after(jiffies, tx_ring->previous_buffer_info.time_stamp + HZ))) - e1000_unmap_and_free_tx_resource( - adapter, &tx_ring->previous_buffer_info); -#endif return cleaned; } -- cgit v1.1 From a2a7a662f80d8b7f2295a36de1f9b033ed0b910c Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Dec 2005 14:48:31 +0900 Subject: [PATCH] libata: implement ata_exec_internal() This patch implements ata_exec_internal() function which performs libata internal command execution. Previously, this was done by each user by manually initializing a qc, issueing it, waiting for its completion and handling errors. In addition to obvious code factoring, using ata_exec_internal() fixes the following bugs. * qc not freed on issue failure * ap->qactive clearing could race with the next internal command * race between timeout handling and irq * ignoring error condition not represented in tf->status Also, qc & hardware are not accessed anymore once it's completed, making internal commands more conformant with general semantics. ata_exec_internal() also makes it easy to issue internal commands from multiple threads if that becomes necessary. This patch only implements ata_exec_internal(). A following patch will convert all users. Signed-off-by: Tejun Heo -- Jeff, all patches have been regenerated against upstream branch as of today. (575ab52a218e4ff0667a6cbd972c3af443ee8713) Also, I took out a debug printk from ata_exec_internal (don't know how that one got left there). Other than that, all patches are identical to the previous posting. Thanks. :-) Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/libata.h | 2 + 2 files changed, 101 insertions(+) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index a0060cf..de80abe 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1046,6 +1046,105 @@ static unsigned int ata_pio_modes(const struct ata_device *adev) return modes; } +struct ata_exec_internal_arg { + unsigned int err_mask; + struct ata_taskfile *tf; + struct completion *waiting; +}; + +int ata_qc_complete_internal(struct ata_queued_cmd *qc) +{ + struct ata_exec_internal_arg *arg = qc->private_data; + struct completion *waiting = arg->waiting; + + if (!(qc->err_mask & ~AC_ERR_DEV)) + qc->ap->ops->tf_read(qc->ap, arg->tf); + arg->err_mask = qc->err_mask; + arg->waiting = NULL; + complete(waiting); + + return 0; +} + +/** + * ata_exec_internal - execute libata internal command + * @ap: Port to which the command is sent + * @dev: Device to which the command is sent + * @tf: Taskfile registers for the command and the result + * @dma_dir: Data tranfer direction of the command + * @buf: Data buffer of the command + * @buflen: Length of data buffer + * + * Executes libata internal command with timeout. @tf contains + * command on entry and result on return. Timeout and error + * conditions are reported via return value. No recovery action + * is taken after a command times out. It's caller's duty to + * clean up after timeout. + * + * LOCKING: + * None. Should be called with kernel context, might sleep. + */ + +static unsigned +ata_exec_internal(struct ata_port *ap, struct ata_device *dev, + struct ata_taskfile *tf, + int dma_dir, void *buf, unsigned int buflen) +{ + u8 command = tf->command; + struct ata_queued_cmd *qc; + DECLARE_COMPLETION(wait); + unsigned long flags; + struct ata_exec_internal_arg arg; + + spin_lock_irqsave(&ap->host_set->lock, flags); + + qc = ata_qc_new_init(ap, dev); + BUG_ON(qc == NULL); + + qc->tf = *tf; + qc->dma_dir = dma_dir; + if (dma_dir != DMA_NONE) { + ata_sg_init_one(qc, buf, buflen); + qc->nsect = buflen / ATA_SECT_SIZE; + } + + arg.waiting = &wait; + arg.tf = tf; + qc->private_data = &arg; + qc->complete_fn = ata_qc_complete_internal; + + if (ata_qc_issue(qc)) + goto issue_fail; + + spin_unlock_irqrestore(&ap->host_set->lock, flags); + + if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) { + spin_lock_irqsave(&ap->host_set->lock, flags); + + /* We're racing with irq here. If we lose, the + * following test prevents us from completing the qc + * again. If completion irq occurs after here but + * before the caller cleans up, it will result in a + * spurious interrupt. We can live with that. + */ + if (arg.waiting) { + qc->err_mask = AC_ERR_OTHER; + ata_qc_complete(qc); + printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n", + ap->id, command); + } + + spin_unlock_irqrestore(&ap->host_set->lock, flags); + } + + return arg.err_mask; + + issue_fail: + ata_qc_free(qc); + spin_unlock_irqrestore(&ap->host_set->lock, flags); + return AC_ERR_OTHER; +} + static int ata_qc_wait_err(struct ata_queued_cmd *qc, struct completion *wait) { diff --git a/include/linux/libata.h b/include/linux/libata.h index e18ce03..833e57a 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -135,6 +135,8 @@ enum { ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* hueristic */ ATA_TMOUT_CDB = 30 * HZ, ATA_TMOUT_CDB_QUICK = 5 * HZ, + ATA_TMOUT_INTERNAL = 30 * HZ, + ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, /* ATA bus states */ BUS_UNKNOWN = 0, -- cgit v1.1 From a012370322eafee642369784ff71afe81f5a8592 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Dec 2005 14:49:31 +0900 Subject: [PATCH] libata: use ata_exec_internal() This patch converts all users of libata internal commands to use ata_exec_internal(). Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 145 ++++++++++++++------------------------------- 1 file changed, 44 insertions(+), 101 deletions(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index de80abe..0107036 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1198,9 +1198,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) u16 tmp; unsigned long xfer_modes; unsigned int using_edd; - DECLARE_COMPLETION(wait); - struct ata_queued_cmd *qc; - unsigned long flags; + struct ata_taskfile tf; + unsigned int err_mask; int rc; if (!ata_dev_present(dev)) { @@ -1221,40 +1220,26 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device) ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ - qc = ata_qc_new_init(ap, dev); - BUG_ON(qc == NULL); - - ata_sg_init_one(qc, dev->id, sizeof(dev->id)); - qc->dma_dir = DMA_FROM_DEVICE; - qc->tf.protocol = ATA_PROT_PIO; - qc->nsect = 1; - retry: + ata_tf_init(ap, &tf, device); + if (dev->class == ATA_DEV_ATA) { - qc->tf.command = ATA_CMD_ID_ATA; + tf.command = ATA_CMD_ID_ATA; DPRINTK("do ATA identify\n"); } else { - qc->tf.command = ATA_CMD_ID_ATAPI; + tf.command = ATA_CMD_ID_ATAPI; DPRINTK("do ATAPI identify\n"); } - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - - spin_lock_irqsave(&ap->host_set->lock, flags); - rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + tf.protocol = ATA_PROT_PIO; - if (rc) - goto err_out; - else - ata_qc_wait_err(qc, &wait); + err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, + dev->id, sizeof(dev->id)); - spin_lock_irqsave(&ap->host_set->lock, flags); - ap->ops->tf_read(ap, &qc->tf); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + if (err_mask) { + if (err_mask & ~AC_ERR_DEV) + goto err_out; - if (qc->tf.command & ATA_ERR) { /* * arg! EDD works for all test cases, but seems to return * the ATA signature for some ATAPI devices. Until the @@ -1267,14 +1252,9 @@ retry: * to have this problem. */ if ((using_edd) && (dev->class == ATA_DEV_ATA)) { - u8 err = qc->tf.feature; + u8 err = tf.feature; if (err & ATA_ABORTED) { dev->class = ATA_DEV_ATAPI; - qc->cursg = 0; - qc->cursg_ofs = 0; - qc->cursect = 0; - qc->nsect = 1; - qc->err_mask = 0; goto retry; } } @@ -2378,34 +2358,23 @@ static int ata_choose_xfer_mode(const struct ata_port *ap, static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) { - DECLARE_COMPLETION(wait); - struct ata_queued_cmd *qc; - int rc; - unsigned long flags; + struct ata_taskfile tf; /* set up set-features taskfile */ DPRINTK("set features - xfer mode\n"); - qc = ata_qc_new_init(ap, dev); - BUG_ON(qc == NULL); - - qc->tf.command = ATA_CMD_SET_FEATURES; - qc->tf.feature = SETFEATURES_XFER; - qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; - qc->tf.protocol = ATA_PROT_NODATA; - qc->tf.nsect = dev->xfer_mode; - - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - - spin_lock_irqsave(&ap->host_set->lock, flags); - rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + ata_tf_init(ap, &tf, dev->devno); + tf.command = ATA_CMD_SET_FEATURES; + tf.feature = SETFEATURES_XFER; + tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; + tf.protocol = ATA_PROT_NODATA; + tf.nsect = dev->xfer_mode; - if (rc) + if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) { + printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n", + ap->id); ata_port_disable(ap); - else - ata_qc_wait_err(qc, &wait); + } DPRINTK("EXIT\n"); } @@ -2420,41 +2389,25 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) { - DECLARE_COMPLETION(wait); - struct ata_queued_cmd *qc; - unsigned long flags; - int rc; - - qc = ata_qc_new_init(ap, dev); - BUG_ON(qc == NULL); + struct ata_taskfile tf; - ata_sg_init_one(qc, dev->id, sizeof(dev->id)); - qc->dma_dir = DMA_FROM_DEVICE; + ata_tf_init(ap, &tf, dev->devno); if (dev->class == ATA_DEV_ATA) { - qc->tf.command = ATA_CMD_ID_ATA; + tf.command = ATA_CMD_ID_ATA; DPRINTK("do ATA identify\n"); } else { - qc->tf.command = ATA_CMD_ID_ATAPI; + tf.command = ATA_CMD_ID_ATAPI; DPRINTK("do ATAPI identify\n"); } - qc->tf.flags |= ATA_TFLAG_DEVICE; - qc->tf.protocol = ATA_PROT_PIO; - qc->nsect = 1; - - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - - spin_lock_irqsave(&ap->host_set->lock, flags); - rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + tf.flags |= ATA_TFLAG_DEVICE; + tf.protocol = ATA_PROT_PIO; - if (rc) + if (ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE, + dev->id, sizeof(dev->id))) goto err_out; - ata_qc_wait_err(qc, &wait); - swap_buf_le16(dev->id, ATA_ID_WORDS); ata_dump_id(dev); @@ -2463,6 +2416,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) return; err_out: + printk(KERN_ERR "ata%u: failed to reread ID, disabled\n", ap->id); ata_port_disable(ap); } @@ -2476,10 +2430,7 @@ err_out: static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) { - DECLARE_COMPLETION(wait); - struct ata_queued_cmd *qc; - int rc; - unsigned long flags; + struct ata_taskfile tf; u16 sectors = dev->id[6]; u16 heads = dev->id[3]; @@ -2490,26 +2441,18 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) /* set up init dev params taskfile */ DPRINTK("init dev params \n"); - qc = ata_qc_new_init(ap, dev); - BUG_ON(qc == NULL); - - qc->tf.command = ATA_CMD_INIT_DEV_PARAMS; - qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; - qc->tf.protocol = ATA_PROT_NODATA; - qc->tf.nsect = sectors; - qc->tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ - - qc->waiting = &wait; - qc->complete_fn = ata_qc_complete_noop; - - spin_lock_irqsave(&ap->host_set->lock, flags); - rc = ata_qc_issue(qc); - spin_unlock_irqrestore(&ap->host_set->lock, flags); + ata_tf_init(ap, &tf, dev->devno); + tf.command = ATA_CMD_INIT_DEV_PARAMS; + tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; + tf.protocol = ATA_PROT_NODATA; + tf.nsect = sectors; + tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ - if (rc) + if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) { + printk(KERN_ERR "ata%u: failed to init parameters, disabled\n", + ap->id); ata_port_disable(ap); - else - ata_qc_wait_err(qc, &wait); + } DPRINTK("EXIT\n"); } -- cgit v1.1 From 82033adf0a4b26eb0c0c90e224848431e2a59bc6 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Dec 2005 14:50:38 +0900 Subject: [PATCH] libata: remove unused functions There is no user of ata_qc_wait_err() and ata_qc_complete_noop() after ata_exec_internal() changes. Remove unused functions. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 29 ----------------------------- drivers/scsi/libata.h | 1 - 2 files changed, 30 deletions(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 0107036..1c4dbf3 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -1145,30 +1145,6 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev, return AC_ERR_OTHER; } -static int ata_qc_wait_err(struct ata_queued_cmd *qc, - struct completion *wait) -{ - int rc = 0; - - if (wait_for_completion_timeout(wait, 30 * HZ) < 1) { - /* timeout handling */ - qc->err_mask |= ac_err_mask(ata_chk_status(qc->ap)); - - if (!qc->err_mask) { - printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n", - qc->ap->id, qc->tf.command); - } else { - printk(KERN_WARNING "ata%u: qc timeout (cmd %x)\n", - qc->ap->id, qc->tf.command); - rc = -EIO; - } - - ata_qc_complete(qc); - } - - return rc; -} - /** * ata_dev_identify - obtain IDENTIFY x DEVICE page * @ap: port on which device we wish to probe resides @@ -3524,11 +3500,6 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, return qc; } -int ata_qc_complete_noop(struct ata_queued_cmd *qc) -{ - return 0; -} - static void __ata_qc_complete(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 686255d..251e53b 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h @@ -39,7 +39,6 @@ struct ata_scsi_args { /* libata-core.c */ extern int atapi_enabled; -extern int ata_qc_complete_noop(struct ata_queued_cmd *qc); extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, struct ata_device *dev); extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); -- cgit v1.1 From b5632303401c231bf270ef36f1013e52caf4caf9 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Dec 2005 14:51:25 +0900 Subject: [PATCH] libata: remove unused qc->waiting There is no user of qc->waiting left after ata_exec_internal() changes. Kill the field. Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- drivers/scsi/libata-core.c | 14 ++------------ include/linux/libata.h | 2 -- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 1c4dbf3..9ea1025 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -3503,7 +3503,7 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, static void __ata_qc_complete(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; - unsigned int tag, do_clear = 0; + unsigned int tag; qc->flags = 0; tag = qc->tag; @@ -3511,17 +3511,8 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) if (tag == ap->active_tag) ap->active_tag = ATA_TAG_POISON; qc->tag = ATA_TAG_POISON; - do_clear = 1; - } - - if (qc->waiting) { - struct completion *waiting = qc->waiting; - qc->waiting = NULL; - complete(waiting); - } - - if (likely(do_clear)) clear_bit(tag, &ap->qactive); + } } /** @@ -3537,7 +3528,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc) void ata_qc_free(struct ata_queued_cmd *qc) { assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ - assert(qc->waiting == NULL); /* nothing should be waiting */ __ata_qc_complete(qc); } diff --git a/include/linux/libata.h b/include/linux/libata.h index 833e57a..46337e7 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -285,8 +285,6 @@ struct ata_queued_cmd { ata_qc_cb_t complete_fn; - struct completion *waiting; - void *private_data; }; -- cgit v1.1 From 2bd0fa3b62e8565a80f9535e0f2bd51bba46213f Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Tue, 13 Dec 2005 03:05:03 -0500 Subject: [PATCH] add boot option to control Intel SATA/PATA combined mode Combined mode sucks. Especially when both libata and the legacy IDE drivers try to drive ports on the same device, since that makes DMA rather difficult. This patch addresses the problem by allowing the user to control which driver binds to the ports in a combined mode configuration. In many cases, they'll probably want the libata driver to control both ports since it can use DMA for talking with ATAPI devices (when libata.atapi_enabled=1 of course). It also allows the user to get old school behavior by letting the legacy IDE driver bind to both ports. But neither is forced, the patch doesn't change current behavior unless one of combined_mode=ide or combined_mode=libata is passed on the boot line. Either of those options may require you to access your devices via different device nodes (/dev/hd* in the ide case and /dev/sd* in the libata case), though of course if you have udev installed nicely you may not notice anything. :) Let me know if the documentation is too cryptic, I'd be happy to expand on it if necessary. I think most users will want to boot with 'combined_mode=libata' and add 'options libata atapi_enabled=1' to their modules.conf to get good DVD playing and disk behavior (haven't tested CD or DVD writing though). I'd much rather things behave sanely by default (i.e. DMA for devices on both ports), but apparently that's difficult given the various chip bugs and hardware configs out there (not to mention that people's drives may suddenly change from /dev/hdc to /dev/sdb), so this boot option may be the correct long term fix. Signed-off-by: Jesse Barnes Signed-off-by: Jeff Garzik --- Documentation/kernel-parameters.txt | 8 ++++++++ drivers/pci/quirks.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 5dffcfe..61a56b1 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -633,6 +633,14 @@ running once the system is up. inport.irq= [HW] Inport (ATI XL and Microsoft) busmouse driver Format: + combined_mode= [HW] control which driver uses IDE ports in combined + mode: legacy IDE driver, libata, or both + (in the libata case, libata.atapi_enabled=1 may be + useful as well). Note that using the ide or libata + options may affect your device naming (e.g. by + changing hdc to sdb). + Format: combined (default), ide, or libata + inttest= [IA64] io7= [HW] IO7 for Marvel based alpha systems diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 3a4f49f..f28ebdd 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1098,6 +1098,23 @@ static void __init quirk_alder_ioapic(struct pci_dev *pdev) DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic ); #endif +enum ide_combined_type { COMBINED = 0, IDE = 1, LIBATA = 2 }; +/* Defaults to combined */ +static enum ide_combined_type combined_mode; + +static int __init combined_setup(char *str) +{ + if (!strncmp(str, "ide", 3)) + combined_mode = IDE; + else if (!strncmp(str, "libata", 6)) + combined_mode = LIBATA; + else /* "combined" or anything else defaults to old behavior */ + combined_mode = COMBINED; + + return 1; +} +__setup("combined_mode=", combined_setup); + #ifdef CONFIG_SCSI_SATA_INTEL_COMBINED static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev) { @@ -1164,6 +1181,19 @@ static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev) if (prog & comb) return; + /* Don't reserve any so the IDE driver can get them (but only if + * combined_mode=ide). + */ + if (combined_mode == IDE) + return; + + /* Grab them both for libata if combined_mode=libata. */ + if (combined_mode == LIBATA) { + request_region(0x1f0, 8, "libata"); /* port 0 */ + request_region(0x170, 8, "libata"); /* port 1 */ + return; + } + /* SATA port is in legacy mode. Reserve port so that * IDE driver does not attempt to use it. If request_region * fails, it will be obvious at boot time, so we don't bother -- cgit v1.1 From 209171a17a908605e516d11436371337a5d87f06 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Tue, 13 Dec 2005 11:05:00 -0500 Subject: ohci1394: log number of implemented isochronous contexts Print the number of IR and IT contexts which a hardware implements as an informational log message when ohci1394 initializes. Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/ohci1394.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 97b6f48..b6b96fa 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -584,12 +584,13 @@ static void ohci_initialize(struct ti_ohci *ohci) sprintf (irq_buf, "%s", __irq_itoa(ohci->dev->irq)); #endif PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] " - "MMIO=[%lx-%lx] Max Packet=[%d]", + "MMIO=[%lx-%lx] Max Packet=[%d] IR/IT contexts=[%d/%d]", ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10), ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf, pci_resource_start(ohci->dev, 0), pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1, - ohci->max_packet_size); + ohci->max_packet_size, + ohci->nb_iso_rcv_ctx, ohci->nb_iso_xmit_ctx); /* Check all of our ports to make sure that if anything is * connected, we enable that port. */ @@ -3351,13 +3352,8 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev, /* Determine the number of available IR and IT contexts. */ ohci->nb_iso_rcv_ctx = get_nb_iso_ctx(ohci, OHCI1394_IsoRecvIntMaskSet); - DBGMSG("%d iso receive contexts available", - ohci->nb_iso_rcv_ctx); - ohci->nb_iso_xmit_ctx = get_nb_iso_ctx(ohci, OHCI1394_IsoXmitIntMaskSet); - DBGMSG("%d iso transmit contexts available", - ohci->nb_iso_xmit_ctx); /* Set the usage bits for non-existent contexts so they can't * be allocated */ -- cgit v1.1 From cf8d2c0965b891a5efce8c3a9a07a522e91ddba2 Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Tue, 13 Dec 2005 11:05:03 -0500 Subject: sbp2: split sbp2_create_command_orb() for better readability sbp2_create_command_orb() code cleanup: - add two helper functions to reduce nesting depth - omit the return value which was always ignored - remove unnecessary declaration from sb2.h Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/sbp2.c | 355 ++++++++++++++++++++++++------------------------ drivers/ieee1394/sbp2.h | 7 - 2 files changed, 178 insertions(+), 184 deletions(-) diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 5b9d03e..14b0c35 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -1707,26 +1707,184 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait) return 0; } +static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, + struct sbp2scsi_host_info *hi, + struct sbp2_command_info *command, + unsigned int scsi_use_sg, + struct scatterlist *sgpnt, + u32 orb_direction, + enum dma_data_direction dma_dir) +{ + command->dma_dir = dma_dir; + orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); + orb->misc |= ORB_SET_DIRECTION(orb_direction); + + /* Special case if only one element (and less than 64KB in size) */ + if ((scsi_use_sg == 1) && + (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) { + + SBP2_DEBUG("Only one s/g element"); + command->dma_size = sgpnt[0].length; + command->dma_type = CMD_DMA_PAGE; + command->cmd_dma = pci_map_page(hi->host->pdev, + sgpnt[0].page, + sgpnt[0].offset, + command->dma_size, + command->dma_dir); + SBP2_DMA_ALLOC("single page scatter element"); + + orb->data_descriptor_lo = command->cmd_dma; + orb->misc |= ORB_SET_DATA_SIZE(command->dma_size); + + } else { + struct sbp2_unrestricted_page_table *sg_element = + &command->scatter_gather_element[0]; + u32 sg_count, sg_len; + dma_addr_t sg_addr; + int i, count = pci_map_sg(hi->host->pdev, sgpnt, scsi_use_sg, + dma_dir); + + SBP2_DMA_ALLOC("scatter list"); + + command->dma_size = scsi_use_sg; + command->sge_buffer = sgpnt; + + /* use page tables (s/g) */ + orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); + orb->data_descriptor_lo = command->sge_dma; + + /* + * Loop through and fill out our sbp-2 page tables + * (and split up anything too large) + */ + for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) { + sg_len = sg_dma_len(sgpnt); + sg_addr = sg_dma_address(sgpnt); + while (sg_len) { + sg_element[sg_count].segment_base_lo = sg_addr; + if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) { + sg_element[sg_count].length_segment_base_hi = + PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH); + sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH; + sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH; + } else { + sg_element[sg_count].length_segment_base_hi = + PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len); + sg_len = 0; + } + sg_count++; + } + } + + /* Number of page table (s/g) elements */ + orb->misc |= ORB_SET_DATA_SIZE(sg_count); + + sbp2util_packet_dump(sg_element, + (sizeof(struct sbp2_unrestricted_page_table)) * sg_count, + "sbp2 s/g list", command->sge_dma); + + /* Byte swap page tables if necessary */ + sbp2util_cpu_to_be32_buffer(sg_element, + (sizeof(struct sbp2_unrestricted_page_table)) * + sg_count); + } +} + +static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb, + struct sbp2scsi_host_info *hi, + struct sbp2_command_info *command, + struct scatterlist *sgpnt, + u32 orb_direction, + unsigned int scsi_request_bufflen, + void *scsi_request_buffer, + enum dma_data_direction dma_dir) +{ + command->dma_dir = dma_dir; + command->dma_size = scsi_request_bufflen; + command->dma_type = CMD_DMA_SINGLE; + command->cmd_dma = pci_map_single(hi->host->pdev, scsi_request_buffer, + command->dma_size, command->dma_dir); + orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); + orb->misc |= ORB_SET_DIRECTION(orb_direction); + + SBP2_DMA_ALLOC("single bulk"); + + /* + * Handle case where we get a command w/o s/g enabled (but + * check for transfers larger than 64K) + */ + if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) { + + orb->data_descriptor_lo = command->cmd_dma; + orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen); + + } else { + struct sbp2_unrestricted_page_table *sg_element = + &command->scatter_gather_element[0]; + u32 sg_count, sg_len; + dma_addr_t sg_addr; + + /* + * Need to turn this into page tables, since the + * buffer is too large. + */ + orb->data_descriptor_lo = command->sge_dma; + + /* Use page tables (s/g) */ + orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); + + /* + * fill out our sbp-2 page tables (and split up + * the large buffer) + */ + sg_count = 0; + sg_len = scsi_request_bufflen; + sg_addr = command->cmd_dma; + while (sg_len) { + sg_element[sg_count].segment_base_lo = sg_addr; + if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) { + sg_element[sg_count].length_segment_base_hi = + PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH); + sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH; + sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH; + } else { + sg_element[sg_count].length_segment_base_hi = + PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len); + sg_len = 0; + } + sg_count++; + } + + /* Number of page table (s/g) elements */ + orb->misc |= ORB_SET_DATA_SIZE(sg_count); + + sbp2util_packet_dump(sg_element, + (sizeof(struct sbp2_unrestricted_page_table)) * sg_count, + "sbp2 s/g list", command->sge_dma); + + /* Byte swap page tables if necessary */ + sbp2util_cpu_to_be32_buffer(sg_element, + (sizeof(struct sbp2_unrestricted_page_table)) * + sg_count); + } +} + /* * This function is called to create the actual command orb and s/g list * out of the scsi command itself. */ -static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, - struct sbp2_command_info *command, - unchar *scsi_cmd, - unsigned int scsi_use_sg, - unsigned int scsi_request_bufflen, - void *scsi_request_buffer, - enum dma_data_direction dma_dir) +static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, + struct sbp2_command_info *command, + unchar *scsi_cmd, + unsigned int scsi_use_sg, + unsigned int scsi_request_bufflen, + void *scsi_request_buffer, + enum dma_data_direction dma_dir) { struct sbp2scsi_host_info *hi = scsi_id->hi; struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer; struct sbp2_command_orb *command_orb = &command->command_orb; - struct sbp2_unrestricted_page_table *scatter_gather_element = - &command->scatter_gather_element[0]; - u32 sg_count, sg_len, orb_direction; - dma_addr_t sg_addr; - int i; + u32 orb_direction; /* * Set-up our command ORB.. @@ -1753,186 +1911,29 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; } - /* - * Set-up our pagetable stuff... unfortunately, this has become - * messier than I'd like. Need to clean this up a bit. ;-) - */ + /* Set-up our pagetable stuff */ if (orb_direction == ORB_DIRECTION_NO_DATA_TRANSFER) { - SBP2_DEBUG("No data transfer"); - - /* - * Handle no data transfer - */ command_orb->data_descriptor_hi = 0x0; command_orb->data_descriptor_lo = 0x0; command_orb->misc |= ORB_SET_DIRECTION(1); - } else if (scsi_use_sg) { - SBP2_DEBUG("Use scatter/gather"); - - /* - * Special case if only one element (and less than 64KB in size) - */ - if ((scsi_use_sg == 1) && (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) { - - SBP2_DEBUG("Only one s/g element"); - command->dma_dir = dma_dir; - command->dma_size = sgpnt[0].length; - command->dma_type = CMD_DMA_PAGE; - command->cmd_dma = pci_map_page(hi->host->pdev, - sgpnt[0].page, - sgpnt[0].offset, - command->dma_size, - command->dma_dir); - SBP2_DMA_ALLOC("single page scatter element"); - - command_orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); - command_orb->data_descriptor_lo = command->cmd_dma; - command_orb->misc |= ORB_SET_DATA_SIZE(command->dma_size); - command_orb->misc |= ORB_SET_DIRECTION(orb_direction); - - } else { - int count = pci_map_sg(hi->host->pdev, sgpnt, scsi_use_sg, dma_dir); - SBP2_DMA_ALLOC("scatter list"); - - command->dma_size = scsi_use_sg; - command->dma_dir = dma_dir; - command->sge_buffer = sgpnt; - - /* use page tables (s/g) */ - command_orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); - command_orb->misc |= ORB_SET_DIRECTION(orb_direction); - command_orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); - command_orb->data_descriptor_lo = command->sge_dma; - - /* - * Loop through and fill out our sbp-2 page tables - * (and split up anything too large) - */ - for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) { - sg_len = sg_dma_len(sgpnt); - sg_addr = sg_dma_address(sgpnt); - while (sg_len) { - scatter_gather_element[sg_count].segment_base_lo = sg_addr; - if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) { - scatter_gather_element[sg_count].length_segment_base_hi = - PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH); - sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH; - sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH; - } else { - scatter_gather_element[sg_count].length_segment_base_hi = - PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len); - sg_len = 0; - } - sg_count++; - } - } - - /* Number of page table (s/g) elements */ - command_orb->misc |= ORB_SET_DATA_SIZE(sg_count); - - sbp2util_packet_dump(scatter_gather_element, - (sizeof(struct sbp2_unrestricted_page_table)) * sg_count, - "sbp2 s/g list", command->sge_dma); - - /* - * Byte swap page tables if necessary - */ - sbp2util_cpu_to_be32_buffer(scatter_gather_element, - (sizeof(struct sbp2_unrestricted_page_table)) * - sg_count); - - } - + sbp2_prep_command_orb_sg(command_orb, hi, command, scsi_use_sg, + sgpnt, orb_direction, dma_dir); } else { - SBP2_DEBUG("No scatter/gather"); - - command->dma_dir = dma_dir; - command->dma_size = scsi_request_bufflen; - command->dma_type = CMD_DMA_SINGLE; - command->cmd_dma = - pci_map_single(hi->host->pdev, scsi_request_buffer, - command->dma_size, command->dma_dir); - SBP2_DMA_ALLOC("single bulk"); - - /* - * Handle case where we get a command w/o s/g enabled (but - * check for transfers larger than 64K) - */ - if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) { - - command_orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); - command_orb->data_descriptor_lo = command->cmd_dma; - command_orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen); - command_orb->misc |= ORB_SET_DIRECTION(orb_direction); - - } else { - /* - * Need to turn this into page tables, since the - * buffer is too large. - */ - command_orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id); - command_orb->data_descriptor_lo = command->sge_dma; - - /* Use page tables (s/g) */ - command_orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); - command_orb->misc |= ORB_SET_DIRECTION(orb_direction); - - /* - * fill out our sbp-2 page tables (and split up - * the large buffer) - */ - sg_count = 0; - sg_len = scsi_request_bufflen; - sg_addr = command->cmd_dma; - while (sg_len) { - scatter_gather_element[sg_count].segment_base_lo = sg_addr; - if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) { - scatter_gather_element[sg_count].length_segment_base_hi = - PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH); - sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH; - sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH; - } else { - scatter_gather_element[sg_count].length_segment_base_hi = - PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len); - sg_len = 0; - } - sg_count++; - } - - /* Number of page table (s/g) elements */ - command_orb->misc |= ORB_SET_DATA_SIZE(sg_count); - - sbp2util_packet_dump(scatter_gather_element, - (sizeof(struct sbp2_unrestricted_page_table)) * sg_count, - "sbp2 s/g list", command->sge_dma); - - /* - * Byte swap page tables if necessary - */ - sbp2util_cpu_to_be32_buffer(scatter_gather_element, - (sizeof(struct sbp2_unrestricted_page_table)) * - sg_count); - - } - + sbp2_prep_command_orb_no_sg(command_orb, hi, command, sgpnt, + orb_direction, scsi_request_bufflen, + scsi_request_buffer, dma_dir); } - /* - * Byte swap command ORB if necessary - */ + /* Byte swap command ORB if necessary */ sbp2util_cpu_to_be32_buffer(command_orb, sizeof(struct sbp2_command_orb)); - /* - * Put our scsi command in the command ORB - */ + /* Put our scsi command in the command ORB */ memset(command_orb->cdb, 0, 12); memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); - - return 0; } /* diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index 8e227c5..900ea1d 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h @@ -410,13 +410,6 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id); static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data, u64 addr, size_t length, u16 flags); static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait); -static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, - struct sbp2_command_info *command, - unchar *scsi_cmd, - unsigned int scsi_use_sg, - unsigned int scsi_request_bufflen, - void *scsi_request_buffer, - enum dma_data_direction dma_dir); static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, struct sbp2_command_info *command); static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, -- cgit v1.1 From eaceec7f6cc5223d0f146086884d67746b8aa81d Mon Sep 17 00:00:00 2001 From: Stefan Richter Date: Tue, 13 Dec 2005 11:05:05 -0500 Subject: sbp2: remove duplicate code from sbp2_start_device() Use sbp2_remove_device() to free FIFO and ORB DMAs in a failure case. Signed-off-by: Stefan Richter Signed-off-by: Jody McIntyre --- drivers/ieee1394/sbp2.c | 57 ++++++------------------------------------------- 1 file changed, 7 insertions(+), 50 deletions(-) diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 14b0c35..18d7eda 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -856,56 +856,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_orb), &scsi_id->login_orb_dma); - if (!scsi_id->login_orb) { -alloc_fail: - if (scsi_id->query_logins_response) { - pci_free_consistent(hi->host->pdev, - sizeof(struct sbp2_query_logins_response), - scsi_id->query_logins_response, - scsi_id->query_logins_response_dma); - SBP2_DMA_FREE("query logins response DMA"); - } - - if (scsi_id->query_logins_orb) { - pci_free_consistent(hi->host->pdev, - sizeof(struct sbp2_query_logins_orb), - scsi_id->query_logins_orb, - scsi_id->query_logins_orb_dma); - SBP2_DMA_FREE("query logins ORB DMA"); - } - - if (scsi_id->logout_orb) { - pci_free_consistent(hi->host->pdev, - sizeof(struct sbp2_logout_orb), - scsi_id->logout_orb, - scsi_id->logout_orb_dma); - SBP2_DMA_FREE("logout ORB DMA"); - } - - if (scsi_id->reconnect_orb) { - pci_free_consistent(hi->host->pdev, - sizeof(struct sbp2_reconnect_orb), - scsi_id->reconnect_orb, - scsi_id->reconnect_orb_dma); - SBP2_DMA_FREE("reconnect ORB DMA"); - } - - if (scsi_id->login_response) { - pci_free_consistent(hi->host->pdev, - sizeof(struct sbp2_login_response), - scsi_id->login_response, - scsi_id->login_response_dma); - SBP2_DMA_FREE("login FIFO DMA"); - } - - list_del(&scsi_id->scsi_list); - - kfree(scsi_id); - - SBP2_ERR("Could not allocate memory for scsi_id"); - - return -ENOMEM; - } + if (!scsi_id->login_orb) + goto alloc_fail; SBP2_DMA_ALLOC("consistent DMA region for login ORB"); SBP2_DEBUG("New SBP-2 device inserted, SCSI ID = %x", scsi_id->ud->id); @@ -966,6 +918,11 @@ alloc_fail: } return 0; + +alloc_fail: + SBP2_ERR("Could not allocate memory for scsi_id"); + sbp2_remove_device(scsi_id); + return -ENOMEM; } /* -- cgit v1.1 From 3492b328834319c9503c0a34c50fb3f009556443 Mon Sep 17 00:00:00 2001 From: "Ju, Seokmann" Date: Thu, 17 Nov 2005 13:13:31 -0500 Subject: [SCSI] megaraid_legacy: removed PCI ID overlap from the driv er This patch fixes - PCI ID overlap issue - node name changed to 'megaraid_legacy' I hope this patch addresses concerns brought by Daniel Drake. Signed-off by: Seokmann Ju Signed-off-by: James Bottomley --- drivers/scsi/megaraid.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index f979252..9fa41cc 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -2,7 +2,7 @@ * * Linux MegaRAID device driver * - * Copyright © 2002 LSI Logic Corporation. + * Copyright (c) 2002 LSI Logic Corporation. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -17,7 +17,8 @@ * Copyright (c) 2003 Christoph Hellwig * - new-style, hotplug-aware pci probing and scsi registration * - * Version : v2.00.3 (Feb 19, 2003) - Atul Mukker + * Version : v2.00.4 Mon Nov 14 14:02:43 EST 2005 - Seokmann Ju + * * * Description: Linux device driver for LSI Logic MegaRAID controller * @@ -51,10 +52,10 @@ #include "megaraid.h" -#define MEGARAID_MODULE_VERSION "2.00.3" +#define MEGARAID_MODULE_VERSION "2.00.4" -MODULE_AUTHOR ("LSI Logic Corporation"); -MODULE_DESCRIPTION ("LSI Logic MegaRAID driver"); +MODULE_AUTHOR ("sju@lsil.com"); +MODULE_DESCRIPTION ("LSI Logic MegaRAID legacy driver"); MODULE_LICENSE ("GPL"); MODULE_VERSION(MEGARAID_MODULE_VERSION); @@ -4553,7 +4554,7 @@ mega_internal_done(Scsi_Cmnd *scmd) static struct scsi_host_template megaraid_template = { .module = THIS_MODULE, .name = "MegaRAID", - .proc_name = "megaraid", + .proc_name = "megaraid_legacy", .info = megaraid_info, .queuecommand = megaraid_queue, .bios_param = megaraid_biosparam, @@ -5037,22 +5038,12 @@ megaraid_shutdown(struct pci_dev *pdev) } static struct pci_device_id megaraid_pci_tbl[] = { - {PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DISCOVERY, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_PERC4_DI, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, BOARD_64BIT}, - {PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_PERC4_QC_VERDE, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, BOARD_64BIT}, {PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID3, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_AMI_MEGARAID3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_AMI_MEGARAID3, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, {0,} }; MODULE_DEVICE_TABLE(pci, megaraid_pci_tbl); @@ -5095,7 +5086,7 @@ static int __init megaraid_init(void) * First argument (major) to register_chrdev implies a dynamic * major number allocation. */ - major = register_chrdev(0, "megadev", &megadev_fops); + major = register_chrdev(0, "megadev_legacy", &megadev_fops); if (!major) { printk(KERN_WARNING "megaraid: failed to register char device\n"); @@ -5109,7 +5100,7 @@ static void __exit megaraid_exit(void) /* * Unregister the character device interface to the driver. */ - unregister_chrdev(major, "megadev"); + unregister_chrdev(major, "megadev_legacy"); pci_unregister_driver(&megaraid_pci_driver); -- cgit v1.1 From ed7e8ef7f12f5c3c8bbb85eeb0a1ded91c7c5dbf Mon Sep 17 00:00:00 2001 From: "Ju, Seokmann" Date: Thu, 17 Nov 2005 13:17:25 -0500 Subject: [SCSI] megaraid_{mbox,mm} : remove PCI Id overlaping between megaraid_legacy and megaraid_{mbox,mm} Signed-off-by: James Bottomley --- Documentation/scsi/ChangeLog.megaraid | 35 +++++++++++++++ drivers/scsi/megaraid/Kconfig.megaraid | 2 - drivers/scsi/megaraid/megaraid_mbox.c | 82 ++++------------------------------ drivers/scsi/megaraid/megaraid_mbox.h | 4 +- 4 files changed, 46 insertions(+), 77 deletions(-) diff --git a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid index 5331d91..09f6300 100644 --- a/Documentation/scsi/ChangeLog.megaraid +++ b/Documentation/scsi/ChangeLog.megaraid @@ -1,3 +1,38 @@ +Release Date : Fri Nov 11 12:27:22 EST 2005 - Seokmann Ju +Current Version : 2.20.4.7 (scsi module), 2.20.2.6 (cmm module) +Older Version : 2.20.4.6 (scsi module), 2.20.2.6 (cmm module) + +1. Sorted out PCI IDs to remove megaraid support overlaps. + Based on the patch from Daniel, sorted out PCI IDs along with + charactor node name change from 'megadev' to 'megadev_legacy' to avoid + conflict. + --- + Hopefully we'll be getting the build restriction zapped much sooner, + but we should also be thinking about totally removing the hardware + support overlap in the megaraid drivers. + + This patch pencils in a date of Feb 06 for this, and performs some + printk abuse in hope that existing legacy users might pick up on what's + going on. + + Signed-off-by: Daniel Drake + --- + +2. Fixed a issue: megaraid always fails to reset handler. + --- + I found that the megaraid driver always fails to reset the + adapter with the following message: + megaraid: resetting the host... + megaraid mbox: reset sequence completed successfully + megaraid: fast sync command timed out + megaraid: reservation reset failed + when the "Cluster mode" of the adapter BIOS is enabled. + So, whenever the reset occurs, the adapter goes to + offline and just become unavailable. + + Jun'ichi Nomura [mailto:jnomura@mtc.biglobe.ne.jp] + --- + Release Date : Mon Mar 07 12:27:22 EST 2005 - Seokmann Ju Current Version : 2.20.4.6 (scsi module), 2.20.2.6 (cmm module) Older Version : 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) diff --git a/drivers/scsi/megaraid/Kconfig.megaraid b/drivers/scsi/megaraid/Kconfig.megaraid index 7363e12..17419e3 100644 --- a/drivers/scsi/megaraid/Kconfig.megaraid +++ b/drivers/scsi/megaraid/Kconfig.megaraid @@ -64,7 +64,6 @@ config MEGARAID_MAILBOX To compile this driver as a module, choose M here: the module will be called megaraid_mbox -if MEGARAID_NEWGEN=n config MEGARAID_LEGACY tristate "LSI Logic Legacy MegaRAID Driver" depends on PCI && SCSI @@ -75,7 +74,6 @@ config MEGARAID_LEGACY To compile this driver as a module, choose M here: the module will be called megaraid -endif config MEGARAID_SAS tristate "LSI Logic MegaRAID SAS RAID Module" diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index 4b5d420..d18a4bc 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -10,12 +10,13 @@ * 2 of the License, or (at your option) any later version. * * FILE : megaraid_mbox.c - * Version : v2.20.4.6 (Mar 07 2005) + * Version : v2.20.4.7 (Nov 14 2005) * * Authors: * Atul Mukker * Sreenivas Bagalkote * Manoj Jose + * Seokmann Ju * * List of supported controllers * @@ -136,7 +137,7 @@ static int wait_till_fw_empty(adapter_t *); -MODULE_AUTHOR("LSI Logic Corporation"); +MODULE_AUTHOR("sju@lsil.com"); MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver"); MODULE_LICENSE("GPL"); MODULE_VERSION(MEGARAID_VERSION); @@ -278,68 +279,14 @@ static struct pci_device_id pci_id_table_g[] = { { PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID3, - PCI_VENDOR_ID_DELL, - PCI_SUBSYS_ID_PERC3_QC, - }, - { - PCI_VENDOR_ID_AMI, - PCI_DEVICE_ID_AMI_MEGARAID3, - PCI_VENDOR_ID_DELL, - PCI_SUBSYS_ID_PERC3_DC, - }, - { - PCI_VENDOR_ID_AMI, - PCI_DEVICE_ID_AMI_MEGARAID3, - PCI_VENDOR_ID_DELL, - PCI_SUBSYS_ID_PERC3_SC, - }, - { - PCI_VENDOR_ID_AMI, - PCI_DEVICE_ID_AMI_MEGARAID3, - PCI_VENDOR_ID_AMI, - PCI_SUBSYS_ID_PERC3_SC, - }, - { - PCI_VENDOR_ID_AMI, - PCI_DEVICE_ID_AMI_MEGARAID3, - PCI_VENDOR_ID_AMI, - PCI_SUBSYS_ID_PERC3_DC, - }, - { - PCI_VENDOR_ID_LSI_LOGIC, - PCI_DEVICE_ID_MEGARAID_SCSI_320_0, - PCI_VENDOR_ID_LSI_LOGIC, - PCI_SUBSYS_ID_MEGARAID_SCSI_320_0, - }, - { - PCI_VENDOR_ID_LSI_LOGIC, - PCI_DEVICE_ID_MEGARAID_SCSI_320_1, - PCI_VENDOR_ID_LSI_LOGIC, - PCI_SUBSYS_ID_MEGARAID_SCSI_320_1, - }, - { - PCI_VENDOR_ID_LSI_LOGIC, - PCI_DEVICE_ID_MEGARAID_SCSI_320_2, - PCI_VENDOR_ID_LSI_LOGIC, - PCI_SUBSYS_ID_MEGARAID_SCSI_320_2, - }, - { - PCI_VENDOR_ID_LSI_LOGIC, - PCI_DEVICE_ID_MEGARAID_I4_133_RAID, - PCI_VENDOR_ID_LSI_LOGIC, - PCI_SUBSYS_ID_MEGARAID_I4_133_RAID, - }, - { - PCI_VENDOR_ID_LSI_LOGIC, - PCI_DEVICE_ID_MEGARAID_SATA_150_4, - PCI_VENDOR_ID_LSI_LOGIC, - PCI_SUBSYS_ID_MEGARAID_SATA_150_4, + PCI_ANY_ID, + PCI_ANY_ID, }, { PCI_VENDOR_ID_LSI_LOGIC, - PCI_DEVICE_ID_MEGARAID_SATA_150_6, - PCI_VENDOR_ID_LSI_LOGIC, - PCI_SUBSYS_ID_MEGARAID_SATA_150_6, + PCI_DEVICE_ID_AMI_MEGARAID3, + PCI_ANY_ID, + PCI_ANY_ID, }, { PCI_VENDOR_ID_LSI_LOGIC, @@ -347,18 +294,6 @@ static struct pci_device_id pci_id_table_g[] = { PCI_ANY_ID, PCI_ANY_ID, }, - { - PCI_VENDOR_ID_LSI_LOGIC, - PCI_DEVICE_ID_INTEL_RAID_SRCS16, - PCI_VENDOR_ID_INTEL, - PCI_SUBSYS_ID_INTEL_RAID_SRCS16, - }, - { - PCI_VENDOR_ID_LSI_LOGIC, - PCI_DEVICE_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK, - PCI_VENDOR_ID_INTEL, - PCI_SUBSYS_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK, - }, {0} /* Terminating entry */ }; MODULE_DEVICE_TABLE(pci, pci_id_table_g); @@ -2985,6 +2920,7 @@ mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[]) for (i = 0; i < 0xFFFFF; i++) { if (mbox->numstatus != 0xFF) break; + rmb(); } if (i == 0xFFFFF) { diff --git a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h index 644b91b..882fb1a 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.h +++ b/drivers/scsi/megaraid/megaraid_mbox.h @@ -21,8 +21,8 @@ #include "megaraid_ioctl.h" -#define MEGARAID_VERSION "2.20.4.6" -#define MEGARAID_EXT_VERSION "(Release Date: Mon Mar 07 12:27:22 EST 2005)" +#define MEGARAID_VERSION "2.20.4.7" +#define MEGARAID_EXT_VERSION "(Release Date: Mon Nov 14 12:27:22 EST 2005)" /* -- cgit v1.1 From ce155ccecd4094e7b5e68058d26db691713240fc Mon Sep 17 00:00:00 2001 From: "brking@us.ibm.com" Date: Thu, 17 Nov 2005 09:35:12 -0600 Subject: [SCSI] ipr: Driver initialization fix for kexec/kdump When kexec booting a kernel when the previous kernel did not call ipr's shutdown method, the ipr adapter does not get properly initialized, which can result in the ipr adapter completing commands issued by the previous kernel. Fix ipr to detect this scenario by reading the adapter's interrupt mask register and the microprocessor interrupt register. If the interrupt mask register indicates that interrupts are enabled or the reset alert bit is set when the card is probed, this means the card is in an unknown state and we hard reset the card. Signed-off-by: Brian King Signed-off-by: James Bottomley --- drivers/scsi/ipr.c | 17 ++++++++++++++++- drivers/scsi/ipr.h | 5 +++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index fa2cb358..b6714da 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -5887,7 +5887,12 @@ static int __devinit ipr_probe_ioa_part2(struct ipr_ioa_cfg *ioa_cfg) ENTER; spin_lock_irqsave(ioa_cfg->host->host_lock, host_lock_flags); dev_dbg(&ioa_cfg->pdev->dev, "ioa_cfg adx: 0x%p\n", ioa_cfg); - _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_enable_ioa, IPR_SHUTDOWN_NONE); + if (ioa_cfg->needs_hard_reset) { + ioa_cfg->needs_hard_reset = 0; + ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE); + } else + _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_enable_ioa, + IPR_SHUTDOWN_NONE); spin_unlock_irqrestore(ioa_cfg->host->host_lock, host_lock_flags); wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload); @@ -6264,6 +6269,7 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, unsigned long ipr_regs_pci; void __iomem *ipr_regs; u32 rc = PCIBIOS_SUCCESSFUL; + volatile u32 mask, uproc; ENTER; @@ -6356,6 +6362,15 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev, goto cleanup_nomem; } + /* + * If HRRQ updated interrupt is not masked, or reset alert is set, + * the card is in an unknown state and needs a hard reset + */ + mask = readl(ioa_cfg->regs.sense_interrupt_mask_reg); + uproc = readl(ioa_cfg->regs.sense_uproc_interrupt_reg); + if ((mask & IPR_PCII_HRRQ_UPDATED) == 0 || (uproc & IPR_UPROCI_RESET_ALERT)) + ioa_cfg->needs_hard_reset = 1; + ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER); rc = request_irq(pdev->irq, ipr_isr, SA_SHIRQ, IPR_NAME, ioa_cfg); diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h index 6bec673..b639332 100644 --- a/drivers/scsi/ipr.h +++ b/drivers/scsi/ipr.h @@ -36,8 +36,8 @@ /* * Literals */ -#define IPR_DRIVER_VERSION "2.1.0" -#define IPR_DRIVER_DATE "(October 31, 2005)" +#define IPR_DRIVER_VERSION "2.1.1" +#define IPR_DRIVER_DATE "(November 15, 2005)" /* * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding @@ -922,6 +922,7 @@ struct ipr_ioa_cfg { u8 dump_taken:1; u8 allow_cmds:1; u8 allow_ml_add_del:1; + u8 needs_hard_reset:1; enum ipr_cache_state cache_state; u16 type; /* CCIN of the card */ -- cgit v1.1 From 0ad78200baf1f85a21e6b26c225717ad80980d8f Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Mon, 28 Nov 2005 16:22:25 +0100 Subject: [SCSI] Mark some core scsi data structures const patch below marks a few scsi core datastructures as const, so that they end up in the .rodata section and don't cacheline share with things that get dirtied Signed-off-by: Arjan van de Ven Signed-off-by: James Bottomley --- drivers/scsi/ch.c | 4 ++-- drivers/scsi/constants.c | 16 ++++++++-------- drivers/scsi/raid_class.c | 2 +- drivers/scsi/scsi_scan.c | 2 +- drivers/scsi/scsi_sysfs.c | 4 ++-- drivers/scsi/scsi_transport_fc.c | 8 ++++---- drivers/scsi/sr.c | 2 +- drivers/scsi/st.c | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index ccbbae2..0920220 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c @@ -75,7 +75,7 @@ static int vendor_counts[CH_TYPES-4]; module_param_array(vendor_firsts, int, NULL, 0444); module_param_array(vendor_counts, int, NULL, 0444); -static char *vendor_labels[CH_TYPES-4] = { +static const char * vendor_labels[CH_TYPES-4] = { "v0", "v1", "v2", "v3" }; // module_param_string_array(vendor_labels, NULL, 0444); @@ -140,7 +140,7 @@ static struct file_operations changer_fops = #endif }; -static struct { +static const struct { unsigned char sense; unsigned char asc; unsigned char ascq; diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 09bc815..a972c1e 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1065,7 +1065,7 @@ struct error_info2 { const char * fmt; }; -static struct error_info2 additional2[] = +static const struct error_info2 additional2[] = { {0x40,0x00,0x7f,"Ram failure (%x)"}, {0x40,0x80,0xff,"Diagnostic failure on component (%x)"}, @@ -1077,7 +1077,7 @@ static struct error_info2 additional2[] = }; /* description of the sense key values */ -static const char *snstext[] = { +static const char * const snstext[] = { "No Sense", /* 0: There is no sense information */ "Recovered Error", /* 1: The last command completed successfully but used error correction */ @@ -1279,7 +1279,7 @@ void scsi_print_req_sense(const char *devclass, struct scsi_request *sreq) EXPORT_SYMBOL(scsi_print_req_sense); #ifdef CONFIG_SCSI_CONSTANTS -static const char *one_byte_msgs[] = { +static const char * const one_byte_msgs[] = { /* 0x00 */ "Command Complete", NULL, "Save Pointers", /* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error", /* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error", @@ -1289,13 +1289,13 @@ static const char *one_byte_msgs[] = { }; #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *)) -static const char *two_byte_msgs[] = { +static const char * const two_byte_msgs[] = { /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag" /* 0x23 */ "Ignore Wide Residue" }; #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) -static const char *extended_msgs[] = { +static const char * const extended_msgs[] = { /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" }; @@ -1397,7 +1397,7 @@ EXPORT_SYMBOL(scsi_print_command); #ifdef CONFIG_SCSI_CONSTANTS -static const char * hostbyte_table[]={ +static const char * const hostbyte_table[]={ "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", "DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"}; @@ -1422,12 +1422,12 @@ void scsi_print_hostbyte(int scsiresult) #ifdef CONFIG_SCSI_CONSTANTS -static const char * driverbyte_table[]={ +static const char * const driverbyte_table[]={ "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; #define NUM_DRIVERBYTE_STRS (sizeof(driverbyte_table) / sizeof(const char *)) -static const char * driversuggest_table[]={"SUGGEST_OK", +static const char * const driversuggest_table[]={"SUGGEST_OK", "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE", "SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"}; #define NUM_SUGGEST_STRS (sizeof(driversuggest_table) / sizeof(const char *)) diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c index 5b1c120..5ec5f44 100644 --- a/drivers/scsi/raid_class.c +++ b/drivers/scsi/raid_class.c @@ -115,7 +115,7 @@ static DECLARE_TRANSPORT_CLASS(raid_class, raid_remove, NULL); -static struct { +static const struct { enum raid_state value; char *name; } raid_states[] = { diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 94e5167f..950b087 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -74,7 +74,7 @@ #define SCSI_SCAN_TARGET_PRESENT 1 #define SCSI_SCAN_LUN_PRESENT 2 -static char *scsi_null_device_strs = "nullnullnullnull"; +static const char *scsi_null_device_strs = "nullnullnullnull"; #define MAX_SCSI_LUNS 512 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 4634929..15842b1 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -21,7 +21,7 @@ #include "scsi_priv.h" #include "scsi_logging.h" -static struct { +static const struct { enum scsi_device_state value; char *name; } sdev_states[] = { @@ -48,7 +48,7 @@ const char *scsi_device_state_name(enum scsi_device_state state) return name; } -static struct { +static const struct { enum scsi_host_state value; char *name; } shost_states[] = { diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 6cd5931..cd95d2a 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c @@ -111,7 +111,7 @@ fc_enum_name_search(port_state, fc_port_state, fc_port_state_names) /* Convert fc_tgtid_binding_type values to ascii string name */ -static struct { +static const struct { enum fc_tgtid_binding_type value; char *name; int matchlen; @@ -149,7 +149,7 @@ get_fc_##title##_names(u32 table_key, char *buf) \ /* Convert FC_COS bit values to ascii string name */ -static struct { +static const struct { u32 value; char *name; } fc_cos_names[] = { @@ -163,7 +163,7 @@ fc_bitfield_name_search(cos, fc_cos_names) /* Convert FC_PORTSPEED bit values to ascii string name */ -static struct { +static const struct { u32 value; char *name; } fc_port_speed_names[] = { @@ -189,7 +189,7 @@ show_fc_fc4s (char *buf, u8 *fc4_list) /* Convert FC_RPORT_ROLE bit values to ascii string name */ -static struct { +static const struct { u32 value; char *name; } fc_remote_port_role_names[] = { diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index d68cea7..a3fa64c 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -730,7 +730,7 @@ static void get_capabilities(struct scsi_cd *cd) unsigned int the_result; int retries, rc, n; - static char *loadmech[] = + static const char *loadmech[] = { "caddy", "tray", diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 7ac6ea1..6d90787 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -17,7 +17,7 @@ Last modified: 18-JAN-1998 Richard Gooch Devfs support */ -static char *verstr = "20050830"; +static const char *verstr = "20050830"; #include @@ -134,7 +134,7 @@ static struct st_dev_parm { #endif /* Bit reversed order to get same names for same minors with all mode counts */ -static char *st_formats[] = { +static const char *st_formats[] = { "", "r", "k", "s", "l", "t", "o", "u", "m", "v", "p", "x", "a", "y", "q", "z"}; -- cgit v1.1 From 493ff4ee7f93a2b53ed60197e05aa145eec8f8f5 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 17 Nov 2005 11:13:43 -0700 Subject: [SCSI] Delete trailing full stop None of the other domain validation messages have a trailing full stop, so I don't see why this one should. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/scsi_transport_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 38a53b5..4002a98 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -1041,7 +1041,7 @@ void spi_display_xfer_agreement(struct scsi_target *starget) tp->hold_mcs ? " HMCS" : "", tmp, tp->offset); } else { - dev_info(&starget->dev, "%sasynchronous.\n", + dev_info(&starget->dev, "%sasynchronous\n", tp->width ? "wide " : ""); } } -- cgit v1.1 From 26a68019c86e1d1782984a7a5babff762cde1501 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 29 Nov 2005 21:03:34 +0100 Subject: [SCSI] scsi_lib: stricter checks for clearing use_10_for_rw Check the asc and ascq for being "invalid command opcode" as well. Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index ce9d73a..1f27827 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -884,7 +884,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, * system where READ CAPACITY failed, we may have read * past the end of the disk. */ - if (cmd->device->use_10_for_rw && + if ((cmd->device->use_10_for_rw && + sshdr.asc == 0x20 && sshdr.ascq == 0x00) && (cmd->cmnd[0] == READ_10 || cmd->cmnd[0] == WRITE_10)) { cmd->device->use_10_for_rw = 0; -- cgit v1.1 From 5433383ef33ed40c9c8a86a4355da344234af2a5 Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Wed, 9 Nov 2005 15:49:04 -0800 Subject: [SCSI] qla2xxx: Add full firmware(-request) hotplug support for all ISPs. Transition driver to exclusively use the request_firmware() interfaces to retrieve firmware-blobs from user-space. This will be the default behaviour going forward until the embedded firmware-binary images are removed from the upstream kernel. Upon request, the driver caches the firmware image until the driver is unloaded. NOTE: The option is present to allow the user to continue to use the firmware-loader modules, but, should be considered deprecated. Signed-off-by: Andrew Vasquez Rejections fixed up and Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/Kconfig | 69 +++++++++------ drivers/scsi/qla2xxx/Makefile | 2 + drivers/scsi/qla2xxx/qla_attr.c | 2 +- drivers/scsi/qla2xxx/qla_def.h | 24 ++++- drivers/scsi/qla2xxx/qla_gbl.h | 4 +- drivers/scsi/qla2xxx/qla_init.c | 189 +++++++++++++++++++++++++++++----------- drivers/scsi/qla2xxx/qla_os.c | 156 +++++++++++++++++++++++++++++---- 7 files changed, 348 insertions(+), 98 deletions(-) diff --git a/drivers/scsi/qla2xxx/Kconfig b/drivers/scsi/qla2xxx/Kconfig index c1c1c68..5205c4e 100644 --- a/drivers/scsi/qla2xxx/Kconfig +++ b/drivers/scsi/qla2xxx/Kconfig @@ -1,55 +1,70 @@ config SCSI_QLA2XXX - tristate - default (SCSI && PCI) - depends on SCSI && PCI + tristate "QLogic QLA2XXX Fibre Channel Support" + depends on PCI && SCSI + select SCSI_FC_ATTRS + select FW_LOADER + ---help--- + This qla2xxx driver supports all QLogic Fibre Channel + PCI and PCIe host adapters. -config SCSI_QLA21XX - tristate "QLogic ISP2100 host adapter family support" + By default, firmware for the ISP parts will be loaded + via the Firmware Loader interface. + + ISP Firmware Filename + ---------- ----------------- + 21xx ql2100_fw.bin + 22xx ql2200_fw.bin + 2300, 2312 ql2300_fw.bin + 2322 ql2322_fw.bin + 6312, 6322 ql6312_fw.bin + 24xx ql2400_fw.bin + + Upon request, the driver caches the firmware image until + the driver is unloaded. + + NOTE: The original method of building firmware-loader + modules has been deprecated as the firmware-images will + be removed from the kernel sources. + +config SCSI_QLA2XXX_EMBEDDED_FIRMWARE + bool " Use firmware-loader modules (DEPRECATED)" depends on SCSI_QLA2XXX - select SCSI_FC_ATTRS - select FW_LOADER + +config SCSI_QLA21XX + tristate " Build QLogic ISP2100 firmware-module" + depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE ---help--- This driver supports the QLogic 21xx (ISP2100) host adapter family. config SCSI_QLA22XX - tristate "QLogic ISP2200 host adapter family support" - depends on SCSI_QLA2XXX - select SCSI_FC_ATTRS - select FW_LOADER + tristate " Build QLogic ISP2200 firmware-module" + depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE ---help--- This driver supports the QLogic 22xx (ISP2200) host adapter family. config SCSI_QLA2300 - tristate "QLogic ISP2300 host adapter family support" - depends on SCSI_QLA2XXX - select SCSI_FC_ATTRS - select FW_LOADER + tristate " Build QLogic ISP2300 firmware-module" + depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE ---help--- This driver supports the QLogic 2300 (ISP2300 and ISP2312) host adapter family. config SCSI_QLA2322 - tristate "QLogic ISP2322 host adapter family support" - depends on SCSI_QLA2XXX - select SCSI_FC_ATTRS - select FW_LOADER + tristate " Build QLogic ISP2322 firmware-module" + depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE ---help--- This driver supports the QLogic 2322 (ISP2322) host adapter family. config SCSI_QLA6312 - tristate "QLogic ISP63xx host adapter family support" - depends on SCSI_QLA2XXX - select SCSI_FC_ATTRS - select FW_LOADER + tristate " Build QLogic ISP63xx firmware-module" + depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE ---help--- This driver supports the QLogic 63xx (ISP6312 and ISP6322) host adapter family. config SCSI_QLA24XX - tristate "QLogic ISP24xx host adapter family support" - depends on SCSI_QLA2XXX - select SCSI_FC_ATTRS - select FW_LOADER + tristate " Build QLogic ISP24xx firmware-module" + depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE ---help--- This driver supports the QLogic 24xx (ISP2422 and ISP2432) host adapter family. diff --git a/drivers/scsi/qla2xxx/Makefile b/drivers/scsi/qla2xxx/Makefile index b169687..549dfe4 100644 --- a/drivers/scsi/qla2xxx/Makefile +++ b/drivers/scsi/qla2xxx/Makefile @@ -3,6 +3,8 @@ EXTRA_CFLAGS += -DUNIQUE_FW_NAME qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \ qla_dbg.o qla_sup.o qla_rscn.o qla_attr.o +obj-$(CONFIG_SCSI_QLA2XXX) += qla2xxx.o + qla2100-y := ql2100.o ql2100_fw.o qla2200-y := ql2200.o ql2200_fw.o qla2300-y := ql2300.o ql2300_fw.o diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index 48e460e..2efca52 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -232,7 +232,7 @@ static ssize_t qla2x00_isp_name_show(struct class_device *cdev, char *buf) { scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); - return snprintf(buf, PAGE_SIZE, "%s\n", ha->brd_info->isp_name); + return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device); } static ssize_t diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index 7096945..ce0d88b 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,7 @@ #include #include +#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) #if defined(CONFIG_SCSI_QLA21XX) || defined(CONFIG_SCSI_QLA21XX_MODULE) #define IS_QLA2100(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100) #else @@ -79,9 +81,23 @@ #define IS_QLA2522(ha) 0 #endif +#else /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */ + +#define IS_QLA2100(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100) +#define IS_QLA2200(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2200) +#define IS_QLA2300(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2300) +#define IS_QLA2312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2312) +#define IS_QLA2322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2322) +#define IS_QLA6312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6312) +#define IS_QLA6322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6322) +#define IS_QLA2422(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422) +#define IS_QLA2432(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432) +#define IS_QLA2512(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2512) +#define IS_QLA2522(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2522) +#endif + #define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \ IS_QLA6312(ha) || IS_QLA6322(ha)) - #define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha)) #define IS_QLA25XX(ha) (IS_QLA2512(ha) || IS_QLA2522(ha)) @@ -2124,6 +2140,12 @@ struct qla_board_info { struct scsi_host_template *sht; }; +struct fw_blob { + char *name; + uint32_t segs[4]; + const struct firmware *fw; +}; + /* Return data from MBC_GET_ID_LIST call. */ struct gid_list_info { uint8_t al_pa; diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index fedcb0d..bec81ad 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -33,8 +33,8 @@ extern int qla24xx_nvram_config(struct scsi_qla_host *); extern void qla2x00_update_fw_options(struct scsi_qla_host *); extern void qla24xx_update_fw_options(scsi_qla_host_t *); extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *); +extern int qla24xx_load_risc(scsi_qla_host_t *, uint32_t *); extern int qla24xx_load_risc_flash(scsi_qla_host_t *, uint32_t *); -extern int qla24xx_load_risc_hotplug(scsi_qla_host_t *, uint32_t *); extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, gfp_t); @@ -76,6 +76,8 @@ extern void qla2x00_blink_led(scsi_qla_host_t *); extern int qla2x00_down_timeout(struct semaphore *, unsigned long); +extern struct fw_blob *qla2x00_request_firmware(scsi_qla_host_t *); + /* * Global Function Prototypes in qla_iocb.c source file. */ diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 2d72012..13e2aaf 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -8,7 +8,6 @@ #include #include -#include #include #include "qla_devtbl.h" @@ -3484,17 +3483,16 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) return (rval); } +#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) + int qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) { - int rval; - uint16_t cnt; - uint16_t *risc_code; - unsigned long risc_address; - unsigned long risc_code_size; - int num; - int i; - uint16_t *req_ring; + int rval, num, i; + uint32_t cnt; + uint16_t *risc_code; + uint32_t risc_addr, risc_size; + uint16_t *req_ring; struct qla_fw_info *fw_iter; rval = QLA_SUCCESS; @@ -3504,37 +3502,29 @@ qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) *srisc_addr = *ha->brd_info->fw_info->fwstart; while (fw_iter->addressing != FW_INFO_ADDR_NOMORE) { risc_code = fw_iter->fwcode; - risc_code_size = *fw_iter->fwlen; - - if (fw_iter->addressing == FW_INFO_ADDR_NORMAL) { - risc_address = *fw_iter->fwstart; - } else { - /* Extended address */ - risc_address = *fw_iter->lfwstart; - } + risc_size = *fw_iter->fwlen; + if (fw_iter->addressing == FW_INFO_ADDR_NORMAL) + risc_addr = *fw_iter->fwstart; + else + risc_addr = *fw_iter->lfwstart; num = 0; rval = 0; - while (risc_code_size > 0 && !rval) { + while (risc_size > 0 && !rval) { cnt = (uint16_t)(ha->fw_transfer_size >> 1); - if (cnt > risc_code_size) - cnt = risc_code_size; + if (cnt > risc_size) + cnt = risc_size; DEBUG7(printk("scsi(%ld): Loading risc segment@ " "addr %p, number of bytes 0x%x, offset 0x%lx.\n", - ha->host_no, risc_code, cnt, risc_address)); + ha->host_no, risc_code, cnt, risc_addr)); req_ring = (uint16_t *)ha->request_ring; for (i = 0; i < cnt; i++) req_ring[i] = cpu_to_le16(risc_code[i]); - if (fw_iter->addressing == FW_INFO_ADDR_NORMAL) { - rval = qla2x00_load_ram(ha, ha->request_dma, - risc_address, cnt); - } else { - rval = qla2x00_load_ram_ext(ha, - ha->request_dma, risc_address, cnt); - } + rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, + cnt); if (rval) { DEBUG(printk("scsi(%ld): [ERROR] Failed to " "load segment %d of firmware\n", @@ -3548,16 +3538,15 @@ qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) } risc_code += cnt; - risc_address += cnt; - risc_code_size -= cnt; + risc_addr += cnt; + risc_size -= cnt; num++; } /* Next firmware sequence */ fw_iter++; } - - return (rval); + return rval; } int @@ -3642,8 +3631,108 @@ qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) return rval; } +#else /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */ + int -qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr) +qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) +{ + int rval; + int i, fragment; + uint16_t *wcode, *fwcode; + uint32_t risc_addr, risc_size, fwclen, wlen, *seg; + struct fw_blob *blob; + + /* Load firmware blob. */ + blob = qla2x00_request_firmware(ha); + if (!blob) { + qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n"); + return QLA_FUNCTION_FAILED; + } + + rval = QLA_SUCCESS; + + wcode = (uint16_t *)ha->request_ring; + *srisc_addr = 0; + fwcode = (uint16_t *)blob->fw->data; + fwclen = 0; + + /* Validate firmware image by checking version. */ + if (blob->fw->size < 8 * sizeof(uint16_t)) { + qla_printk(KERN_WARNING, ha, + "Unable to verify integrity of firmware image (%Zd)!\n", + blob->fw->size); + goto fail_fw_integrity; + } + for (i = 0; i < 4; i++) + wcode[i] = be16_to_cpu(fwcode[i + 4]); + if ((wcode[0] == 0xffff && wcode[1] == 0xffff && wcode[2] == 0xffff && + wcode[3] == 0xffff) || (wcode[0] == 0 && wcode[1] == 0 && + wcode[2] == 0 && wcode[3] == 0)) { + qla_printk(KERN_WARNING, ha, + "Unable to verify integrity of firmware image!\n"); + qla_printk(KERN_WARNING, ha, + "Firmware data: %04x %04x %04x %04x!\n", wcode[0], + wcode[1], wcode[2], wcode[3]); + goto fail_fw_integrity; + } + + seg = blob->segs; + while (*seg && rval == QLA_SUCCESS) { + risc_addr = *seg; + *srisc_addr = *srisc_addr == 0 ? *seg : *srisc_addr; + risc_size = be16_to_cpu(fwcode[3]); + + /* Validate firmware image size. */ + fwclen += risc_size * sizeof(uint16_t); + if (blob->fw->size < fwclen) { + qla_printk(KERN_WARNING, ha, + "Unable to verify integrity of firmware image " + "(%Zd)!\n", blob->fw->size); + goto fail_fw_integrity; + } + + fragment = 0; + while (risc_size > 0 && rval == QLA_SUCCESS) { + wlen = (uint16_t)(ha->fw_transfer_size >> 1); + if (wlen > risc_size) + wlen = risc_size; + + DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " + "addr %x, number of words 0x%x.\n", ha->host_no, + risc_addr, wlen)); + + for (i = 0; i < wlen; i++) + wcode[i] = swab16(fwcode[i]); + + rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, + wlen); + if (rval) { + DEBUG(printk("scsi(%ld):[ERROR] Failed to load " + "segment %d of firmware\n", ha->host_no, + fragment)); + qla_printk(KERN_WARNING, ha, + "[ERROR] Failed to load segment %d of " + "firmware\n", fragment); + break; + } + + fwcode += wlen; + risc_addr += wlen; + risc_size -= wlen; + fragment++; + } + + /* Next segment. */ + seg++; + } + return rval; + +fail_fw_integrity: + return QLA_FUNCTION_FAILED; +} + +int +qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) { int rval; int segments, fragment; @@ -3651,14 +3740,13 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr) uint32_t risc_addr; uint32_t risc_size; uint32_t i; - const struct firmware *fw_entry; + struct fw_blob *blob; uint32_t *fwcode, fwclen; - if (request_firmware(&fw_entry, ha->brd_info->fw_fname, - &ha->pdev->dev)) { - qla_printk(KERN_ERR, ha, - "Firmware image file not available: '%s'\n", - ha->brd_info->fw_fname); + /* Load firmware blob. */ + blob = qla2x00_request_firmware(ha); + if (!blob) { + qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n"); return QLA_FUNCTION_FAILED; } @@ -3667,14 +3755,14 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr) segments = FA_RISC_CODE_SEGMENTS; dcode = (uint32_t *)ha->request_ring; *srisc_addr = 0; - fwcode = (uint32_t *)fw_entry->data; + fwcode = (uint32_t *)blob->fw->data; fwclen = 0; /* Validate firmware image by checking version. */ - if (fw_entry->size < 8 * sizeof(uint32_t)) { + if (blob->fw->size < 8 * sizeof(uint32_t)) { qla_printk(KERN_WARNING, ha, - "Unable to verify integrity of flash firmware image " - "(%Zd)!\n", fw_entry->size); + "Unable to verify integrity of firmware image (%Zd)!\n", + blob->fw->size); goto fail_fw_integrity; } for (i = 0; i < 4; i++) @@ -3684,7 +3772,7 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr) (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && dcode[3] == 0)) { qla_printk(KERN_WARNING, ha, - "Unable to verify integrity of flash firmware image!\n"); + "Unable to verify integrity of firmware image!\n"); qla_printk(KERN_WARNING, ha, "Firmware data: %08x %08x %08x %08x!\n", dcode[0], dcode[1], dcode[2], dcode[3]); @@ -3698,10 +3786,11 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr) /* Validate firmware image size. */ fwclen += risc_size * sizeof(uint32_t); - if (fw_entry->size < fwclen) { + if (blob->fw->size < fwclen) { qla_printk(KERN_WARNING, ha, - "Unable to verify integrity of flash firmware " - "image (%Zd)!\n", fw_entry->size); + "Unable to verify integrity of firmware image " + "(%Zd)!\n", blob->fw->size); + goto fail_fw_integrity; } @@ -3739,13 +3828,9 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr) /* Next segment. */ segments--; } - - release_firmware(fw_entry); return rval; fail_fw_integrity: - - release_firmware(fw_entry); return QLA_FUNCTION_FAILED; - } +#endif diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index c58c9d9..47db029 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -54,11 +54,6 @@ module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR); MODULE_PARM_DESC(ql2xloginretrycount, "Specify an alternate value for the NVRAM login retry count."); -int ql2xfwloadbin=1; -module_param(ql2xfwloadbin, int, S_IRUGO|S_IRUSR); -MODULE_PARM_DESC(ql2xfwloadbin, - "Load ISP2xxx firmware image via hotplug."); - static void qla2x00_free_device(scsi_qla_host_t *); static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha); @@ -1261,12 +1256,16 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) char pci_info[20]; char fw_str[30]; fc_port_t *fcport; + struct scsi_host_template *sht; if (pci_enable_device(pdev)) goto probe_out; - host = scsi_host_alloc(brd_info->sht ? brd_info->sht: - &qla2x00_driver_template, sizeof(scsi_qla_host_t)); + sht = &qla2x00_driver_template; + if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || + pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432) + sht = &qla24xx_driver_template; + host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); if (host == NULL) { printk(KERN_WARNING "qla2xxx: Couldn't allocate host from scsi layer!\n"); @@ -1291,8 +1290,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) goto probe_failed; qla_printk(KERN_INFO, ha, - "Found an %s, irq %d, iobase 0x%p\n", ha->brd_info->isp_name, - pdev->irq, ha->iobase); + "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev->device, pdev->irq, + ha->iobase); spin_lock_init(&ha->hardware_lock); @@ -1368,9 +1367,11 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) ha->isp_ops.reset_adapter = qla24xx_reset_adapter; ha->isp_ops.nvram_config = qla24xx_nvram_config; ha->isp_ops.update_fw_options = qla24xx_update_fw_options; +#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) ha->isp_ops.load_risc = qla24xx_load_risc_flash; - if (ql2xfwloadbin) - ha->isp_ops.load_risc = qla24xx_load_risc_hotplug; +#else + ha->isp_ops.load_risc = qla24xx_load_risc; +#endif ha->isp_ops.pci_info_str = qla24xx_pci_info_str; ha->isp_ops.fw_version_str = qla24xx_fw_version_str; ha->isp_ops.intr_handler = qla24xx_intr_handler; @@ -1531,11 +1532,12 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) qla_printk(KERN_INFO, ha, "\n" " QLogic Fibre Channel HBA Driver: %s\n" " QLogic %s - %s\n" - " %s: %s @ %s hdma%c, host#=%ld, fw=%s\n", qla2x00_version_str, - ha->model_number, ha->model_desc ? ha->model_desc: "", - ha->brd_info->isp_name, ha->isp_ops.pci_info_str(ha, pci_info), - pci_name(pdev), ha->flags.enable_64bit_addressing ? '+': '-', - ha->host_no, ha->isp_ops.fw_version_str(ha, fw_str)); + " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n", + qla2x00_version_str, ha->model_number, + ha->model_desc ? ha->model_desc: "", pdev->device, + ha->isp_ops.pci_info_str(ha, pci_info), pci_name(pdev), + ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no, + ha->isp_ops.fw_version_str(ha, fw_str)); /* Go with fc_rport registration. */ list_for_each_entry(fcport, &ha->fcports, list) @@ -2483,6 +2485,10 @@ qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout) return -ETIMEDOUT; } +#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) + +#define qla2x00_release_firmware() do { } while (0) + static struct qla_board_info qla_board_tbl[] = { { .drv_name = "qla2400", @@ -2530,8 +2536,122 @@ qla2xxx_remove_one(struct pci_dev *pdev) qla2x00_remove_one(pdev); } +#else /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */ + +/* Firmware interface routines. */ + +#define FW_BLOBS 6 +#define FW_ISP21XX 0 +#define FW_ISP22XX 1 +#define FW_ISP2300 2 +#define FW_ISP2322 3 +#define FW_ISP63XX 4 +#define FW_ISP24XX 5 + +static DECLARE_MUTEX(qla_fw_lock); + +static struct fw_blob qla_fw_blobs[FW_BLOBS] = { + { .name = "ql2100_fw.bin", .segs = { 0x1000, 0 }, }, + { .name = "ql2200_fw.bin", .segs = { 0x1000, 0 }, }, + { .name = "ql2300_fw.bin", .segs = { 0x800, 0 }, }, + { .name = "ql2322_fw.bin", .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, + { .name = "ql6312_fw.bin", .segs = { 0x800, 0 }, }, + { .name = "ql2400_fw.bin", }, +}; + +struct fw_blob * +qla2x00_request_firmware(scsi_qla_host_t *ha) +{ + struct fw_blob *blob; + + blob = NULL; + if (IS_QLA2100(ha)) { + blob = &qla_fw_blobs[FW_ISP21XX]; + } else if (IS_QLA2200(ha)) { + blob = &qla_fw_blobs[FW_ISP22XX]; + } else if (IS_QLA2300(ha) || IS_QLA2312(ha)) { + blob = &qla_fw_blobs[FW_ISP2300]; + } else if (IS_QLA2322(ha)) { + blob = &qla_fw_blobs[FW_ISP2322]; + } else if (IS_QLA6312(ha) || IS_QLA6322(ha)) { + blob = &qla_fw_blobs[FW_ISP63XX]; + } else if (IS_QLA24XX(ha)) { + blob = &qla_fw_blobs[FW_ISP24XX]; + } + + down(&qla_fw_lock); + if (blob->fw) + goto out; + + if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { + DEBUG2(printk("scsi(%ld): Failed to load firmware image " + "(%s).\n", ha->host_no, blob->name)); + blob->fw = NULL; + blob = NULL; + goto out; + } + +out: + up(&qla_fw_lock); + return blob; +} + +static void +qla2x00_release_firmware(void) +{ + int idx; + + down(&qla_fw_lock); + for (idx = 0; idx < FW_BLOBS; idx++) + if (qla_fw_blobs[idx].fw) + release_firmware(qla_fw_blobs[idx].fw); + up(&qla_fw_lock); +} + +static struct qla_board_info qla_board_tbl = { + .drv_name = "qla2xxx", +}; + +static struct pci_device_id qla2xxx_pci_tbl[] = { + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422, + PCI_ANY_ID, PCI_ANY_ID, }, + { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432, + PCI_ANY_ID, PCI_ANY_ID, }, + { 0 }, +}; +MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); + +static int __devinit +qla2xxx_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) +{ + return qla2x00_probe_one(pdev, &qla_board_tbl); +} + +static void __devexit +qla2xxx_remove_one(struct pci_dev *pdev) +{ + qla2x00_remove_one(pdev); +} + +#endif + static struct pci_driver qla2xxx_pci_driver = { .name = "qla2xxx", + .owner = THIS_MODULE, .id_table = qla2xxx_pci_tbl, .probe = qla2xxx_probe_one, .remove = __devexit_p(qla2xxx_remove_one), @@ -2556,6 +2676,9 @@ qla2x00_module_init(void) /* Derive version string. */ strcpy(qla2x00_version_str, QLA2XXX_VERSION); +#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) + strcat(qla2x00_version_str, "-fw"); +#endif #if DEBUG_QLA2100 strcat(qla2x00_version_str, "-debug"); #endif @@ -2580,6 +2703,7 @@ static void __exit qla2x00_module_exit(void) { pci_unregister_driver(&qla2xxx_pci_driver); + qla2x00_release_firmware(); kmem_cache_destroy(srb_cachep); fc_release_transport(qla2xxx_transport_template); } -- cgit v1.1 From 331e34768657ead5a5b169337351e045305cafcb Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Wed, 9 Nov 2005 15:49:19 -0800 Subject: [SCSI] qla2xxx: Add support for embedded ISP24xx firmware. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/Makefile | 3 +- drivers/scsi/qla2xxx/ql2400.c | 111 ++++++++++++++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_init.c | 61 ++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_os.c | 82 ++++++++++------------------- 4 files changed, 202 insertions(+), 55 deletions(-) create mode 100644 drivers/scsi/qla2xxx/ql2400.c diff --git a/drivers/scsi/qla2xxx/Makefile b/drivers/scsi/qla2xxx/Makefile index 549dfe4..40c0de1 100644 --- a/drivers/scsi/qla2xxx/Makefile +++ b/drivers/scsi/qla2xxx/Makefile @@ -10,10 +10,11 @@ qla2200-y := ql2200.o ql2200_fw.o qla2300-y := ql2300.o ql2300_fw.o qla2322-y := ql2322.o ql2322_fw.o qla6312-y := ql6312.o ql6312_fw.o +qla2400-y := ql2400.o ql2400_fw.o obj-$(CONFIG_SCSI_QLA21XX) += qla2xxx.o qla2100.o obj-$(CONFIG_SCSI_QLA22XX) += qla2xxx.o qla2200.o obj-$(CONFIG_SCSI_QLA2300) += qla2xxx.o qla2300.o obj-$(CONFIG_SCSI_QLA2322) += qla2xxx.o qla2322.o obj-$(CONFIG_SCSI_QLA6312) += qla2xxx.o qla6312.o -obj-$(CONFIG_SCSI_QLA24XX) += qla2xxx.o +obj-$(CONFIG_SCSI_QLA24XX) += qla2xxx.o qla2400.o diff --git a/drivers/scsi/qla2xxx/ql2400.c b/drivers/scsi/qla2xxx/ql2400.c new file mode 100644 index 0000000..6c7165f --- /dev/null +++ b/drivers/scsi/qla2xxx/ql2400.c @@ -0,0 +1,111 @@ +/* + * QLogic Fibre Channel HBA Driver + * Copyright (c) 2003-2005 QLogic Corporation + * + * See LICENSE.qla2xxx for copyright and licensing details. + */ +#include +#include +#include + +#include "qla_def.h" + +static char qla_driver_name[] = "qla2400"; + +extern uint32_t fw2400_version_str[]; +extern uint32_t fw2400_addr01; +extern uint32_t fw2400_code01[]; +extern uint32_t fw2400_length01; +extern uint32_t fw2400_addr02; +extern uint32_t fw2400_code02[]; +extern uint32_t fw2400_length02; + +static struct qla_fw_info qla_fw_tbl[] = { + { + .addressing = FW_INFO_ADDR_EXTENDED, + .fwcode = (unsigned short *)&fw2400_code01[0], + .fwlen = (unsigned short *)&fw2400_length01, + .lfwstart = (unsigned long *)&fw2400_addr01, + }, + { + .addressing = FW_INFO_ADDR_EXTENDED, + .fwcode = (unsigned short *)&fw2400_code02[0], + .fwlen = (unsigned short *)&fw2400_length02, + .lfwstart = (unsigned long *)&fw2400_addr02, + }, + { FW_INFO_ADDR_NOMORE, }, +}; + +static struct qla_board_info qla_board_tbl[] = { + { + .drv_name = qla_driver_name, + .isp_name = "ISP2422", + .fw_info = qla_fw_tbl, + .fw_fname = "ql2400_fw.bin", + }, + { + .drv_name = qla_driver_name, + .isp_name = "ISP2432", + .fw_info = qla_fw_tbl, + .fw_fname = "ql2400_fw.bin", + }, +}; + +static struct pci_device_id qla24xx_pci_tbl[] = { + { + .vendor = PCI_VENDOR_ID_QLOGIC, + .device = PCI_DEVICE_ID_QLOGIC_ISP2422, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = (unsigned long)&qla_board_tbl[0], + }, + { + .vendor = PCI_VENDOR_ID_QLOGIC, + .device = PCI_DEVICE_ID_QLOGIC_ISP2432, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = (unsigned long)&qla_board_tbl[1], + }, + {0, 0}, +}; +MODULE_DEVICE_TABLE(pci, qla24xx_pci_tbl); + +static int __devinit +qla24xx_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) +{ + return qla2x00_probe_one(pdev, + (struct qla_board_info *)id->driver_data); +} + +static void __devexit +qla24xx_remove_one(struct pci_dev *pdev) +{ + qla2x00_remove_one(pdev); +} + +static struct pci_driver qla24xx_pci_driver = { + .name = "qla2400", + .id_table = qla24xx_pci_tbl, + .probe = qla24xx_probe_one, + .remove = __devexit_p(qla24xx_remove_one), +}; + +static int __init +qla24xx_init(void) +{ + return pci_module_init(&qla24xx_pci_driver); +} + +static void __exit +qla24xx_exit(void) +{ + pci_unregister_driver(&qla24xx_pci_driver); +} + +module_init(qla24xx_init); +module_exit(qla24xx_exit); + +MODULE_AUTHOR("QLogic Corporation"); +MODULE_DESCRIPTION("QLogic ISP24xx FC-SCSI Host Bus Adapter driver"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(QLA2XXX_VERSION); diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 13e2aaf..dadc91b 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -3550,6 +3550,67 @@ qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) } int +qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) +{ + int rval, num, i; + uint32_t cnt; + uint32_t *risc_code; + uint32_t risc_addr, risc_size; + uint32_t *req_ring; + struct qla_fw_info *fw_iter; + + rval = QLA_SUCCESS; + + /* Load firmware sequences */ + fw_iter = ha->brd_info->fw_info; + *srisc_addr = *((uint32_t *)fw_iter->lfwstart); + while (fw_iter->addressing != FW_INFO_ADDR_NOMORE) { + risc_code = (uint32_t *)fw_iter->fwcode; + risc_size = *((uint32_t *)fw_iter->fwlen); + risc_addr = *((uint32_t *)fw_iter->lfwstart); + + num = 0; + rval = 0; + while (risc_size > 0 && !rval) { + cnt = (uint32_t)(ha->fw_transfer_size >> 2); + if (cnt > risc_size) + cnt = risc_size; + + DEBUG7(printk("scsi(%ld): Loading risc segment@ " + "addr %p, number of bytes 0x%x, offset 0x%lx.\n", + ha->host_no, risc_code, cnt, risc_addr)); + + req_ring = (uint32_t *)ha->request_ring; + for (i = 0; i < cnt; i++) + req_ring[i] = cpu_to_le32(risc_code[i]); + + rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, + cnt); + if (rval) { + DEBUG(printk("scsi(%ld): [ERROR] Failed to " + "load segment %d of firmware\n", + ha->host_no, num)); + qla_printk(KERN_WARNING, ha, + "[ERROR] Failed to load segment %d of " + "firmware\n", num); + + qla2x00_dump_regs(ha); + break; + } + + risc_code += cnt; + risc_addr += cnt; + risc_size -= cnt; + num++; + } + + /* Next firmware sequence */ + fw_iter++; + } + return rval; +} + +int qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) { int rval; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 47db029..41d2aee 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -54,6 +54,13 @@ module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR); MODULE_PARM_DESC(ql2xloginretrycount, "Specify an alternate value for the NVRAM login retry count."); +#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) +int ql2xfwloadflash; +module_param(ql2xfwloadflash, int, S_IRUGO|S_IRUSR); +MODULE_PARM_DESC(ql2xfwloadflash, + "Load ISP24xx firmware image from FLASH (onboard memory)."); +#endif + static void qla2x00_free_device(scsi_qla_host_t *); static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha); @@ -1367,10 +1374,10 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info) ha->isp_ops.reset_adapter = qla24xx_reset_adapter; ha->isp_ops.nvram_config = qla24xx_nvram_config; ha->isp_ops.update_fw_options = qla24xx_update_fw_options; -#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) - ha->isp_ops.load_risc = qla24xx_load_risc_flash; -#else ha->isp_ops.load_risc = qla24xx_load_risc; +#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) + if (ql2xfwloadflash) + ha->isp_ops.load_risc = qla24xx_load_risc_flash; #endif ha->isp_ops.pci_info_str = qla24xx_pci_info_str; ha->isp_ops.fw_version_str = qla24xx_fw_version_str; @@ -2488,53 +2495,8 @@ qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout) #if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) #define qla2x00_release_firmware() do { } while (0) - -static struct qla_board_info qla_board_tbl[] = { - { - .drv_name = "qla2400", - .isp_name = "ISP2422", - .fw_fname = "ql2400_fw.bin", - .sht = &qla24xx_driver_template, - }, - { - .drv_name = "qla2400", - .isp_name = "ISP2432", - .fw_fname = "ql2400_fw.bin", - .sht = &qla24xx_driver_template, - }, -}; - -static struct pci_device_id qla2xxx_pci_tbl[] = { - { - .vendor = PCI_VENDOR_ID_QLOGIC, - .device = PCI_DEVICE_ID_QLOGIC_ISP2422, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = (unsigned long)&qla_board_tbl[0], - }, - { - .vendor = PCI_VENDOR_ID_QLOGIC, - .device = PCI_DEVICE_ID_QLOGIC_ISP2432, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = (unsigned long)&qla_board_tbl[1], - }, - {0, 0}, -}; -MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); - -static int __devinit -qla2xxx_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) -{ - return qla2x00_probe_one(pdev, - (struct qla_board_info *)id->driver_data); -} - -static void __devexit -qla2xxx_remove_one(struct pci_dev *pdev) -{ - qla2x00_remove_one(pdev); -} +#define qla2x00_pci_module_init() (0) +#define qla2x00_pci_module_exit() do { } while (0) #else /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */ @@ -2647,8 +2609,6 @@ qla2xxx_remove_one(struct pci_dev *pdev) qla2x00_remove_one(pdev); } -#endif - static struct pci_driver qla2xxx_pci_driver = { .name = "qla2xxx", .owner = THIS_MODULE, @@ -2657,6 +2617,20 @@ static struct pci_driver qla2xxx_pci_driver = { .remove = __devexit_p(qla2xxx_remove_one), }; +static inline int +qla2x00_pci_module_init(void) +{ + return pci_module_init(&qla2xxx_pci_driver); +} + +static inline void +qla2x00_pci_module_exit(void) +{ + pci_unregister_driver(&qla2xxx_pci_driver); +} + +#endif + /** * qla2x00_module_init - Module initialization. **/ @@ -2688,7 +2662,7 @@ qla2x00_module_init(void) return -ENODEV; printk(KERN_INFO "QLogic Fibre Channel HBA Driver\n"); - ret = pci_module_init(&qla2xxx_pci_driver); + ret = qla2x00_pci_module_init(); if (ret) { kmem_cache_destroy(srb_cachep); fc_release_transport(qla2xxx_transport_template); @@ -2702,7 +2676,7 @@ qla2x00_module_init(void) static void __exit qla2x00_module_exit(void) { - pci_unregister_driver(&qla2xxx_pci_driver); + qla2x00_pci_module_exit(); qla2x00_release_firmware(); kmem_cache_destroy(srb_cachep); fc_release_transport(qla2xxx_transport_template); -- cgit v1.1 From c6ce15d7cdb3f6cb3ff442ac01eb6c5f0fe321af Mon Sep 17 00:00:00 2001 From: Andrew Vasquez Date: Wed, 9 Nov 2005 15:49:33 -0800 Subject: [SCSI] qla2xxx: Resync with latest released ISP24xx firmware -- 4.00.16. Signed-off-by: Andrew Vasquez Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/ql2400_fw.c | 12376 +++++++++++++++++++++++++++++++++++++ 1 file changed, 12376 insertions(+) create mode 100644 drivers/scsi/qla2xxx/ql2400_fw.c diff --git a/drivers/scsi/qla2xxx/ql2400_fw.c b/drivers/scsi/qla2xxx/ql2400_fw.c new file mode 100644 index 0000000..5977795 --- /dev/null +++ b/drivers/scsi/qla2xxx/ql2400_fw.c @@ -0,0 +1,12376 @@ +/* + * QLogic Fibre Channel HBA Driver + * Copyright (c) 2003-2005 QLogic Corporation + * + * See LICENSE.qla2xxx for copyright and licensing details. + */ +#include + +/* + * Firmware Version 4.00.16 (08:09 Oct 26, 2005) + */ + +#ifdef UNIQUE_FW_NAME +uint32_t fw2400_version = 4*1024+0; +#else +uint32_t risc_code_version = 4*1024+0; +#endif + +#ifdef UNIQUE_FW_NAME +uint32_t fw2400_version_str[] = {4, 0,16}; +#else +uint32_t firmware_version[] = {4, 0,16}; +#endif + +#ifdef UNIQUE_FW_NAME +#define fw2400_VERSION_STRING "4.00.16" +#else +#define FW_VERSION_STRING "4.00.16" +#endif + +#ifdef UNIQUE_FW_NAME +uint32_t fw2400_addr01 = 0x00100000 ; +#else +uint32_t risc_code_addr01 = 0x00100000 ; +#endif + +#ifdef UNIQUE_FW_NAME +uint32_t fw2400_code01[] = { +#else +uint32_t risc_code01[] = { +#endif + 0x0401f17c, 0x0010e000, 0x00100000, 0x0000ab4a, + 0x00000004, 0x00000000, 0x00000010, 0x00000002, + 0x00000003, 0x00000000, 0x20434f50, 0x59524947, + 0x48542032, 0x30303520, 0x514c4f47, 0x49432043, + 0x4f52504f, 0x52415449, 0x4f4e2020, 0x20495350, + 0x32347878, 0x20466972, 0x6d776172, 0x65202020, + 0x56657273, 0x696f6e20, 0x342e302e, 0x31362020, + 0x20202024, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x42001800, 0x0010014f, 0x42002000, 0x0010b8fe, + 0x500c0800, 0x800c1800, 0x500c1000, 0x800c1800, + 0x54042000, 0x80102000, 0x80040800, 0x80081040, + 0x040207fc, 0x500c0800, 0x800409c0, 0x040207f6, + 0x44002000, 0x80102000, 0x40100000, 0x44040000, + 0x80000000, 0x44080000, 0x80000000, 0x440c0000, + 0x80000000, 0x44100000, 0x80000000, 0x44140000, + 0x80000000, 0x44180000, 0x80000000, 0x441c0000, + 0x80000000, 0x44200000, 0x80000000, 0x44240000, + 0x80000000, 0x44280000, 0x80000000, 0x442c0000, + 0x80000000, 0x44300000, 0x80000000, 0x44340000, + 0x80000000, 0x44380000, 0x80000000, 0x443c0000, + 0x80000000, 0x44400000, 0x80000000, 0x44440000, + 0x80000000, 0x44480000, 0x80000000, 0x444c0000, + 0x80000000, 0x44500000, 0x80000000, 0x44540000, + 0x80000000, 0x44580000, 0x80000000, 0x445c0000, + 0x80000000, 0x44600000, 0x80000000, 0x44640000, + 0x80000000, 0x44680000, 0x80000000, 0x446c0000, + 0x80000000, 0x44700000, 0x80000000, 0x44740000, + 0x80000000, 0x44780000, 0x80000000, 0x447c0000, + 0x80000000, 0x44800000, 0x80000000, 0x44840000, + 0x80000000, 0x44880000, 0x80000000, 0x448c0000, + 0x80000000, 0x44900000, 0x80000000, 0x44940000, + 0x80000000, 0x44980000, 0x80000000, 0x449c0000, + 0x80000000, 0x44a00000, 0x80000000, 0x44a40000, + 0x80000000, 0x44a80000, 0x80000000, 0x44ac0000, + 0x80000000, 0x44b00000, 0x80000000, 0x44b40000, + 0x80000000, 0x44b80000, 0x80000000, 0x44bc0000, + 0x80000000, 0x44c00000, 0x80000000, 0x44c40000, + 0x80000000, 0x44c80000, 0x80000000, 0x44cc0000, + 0x80000000, 0x44d00000, 0x80000000, 0x44d80000, + 0x80000000, 0x44d40000, 0x80000000, 0x44dc0000, + 0x80000000, 0x44e00000, 0x80000000, 0x44e40000, + 0x80000000, 0x44e80000, 0x80000000, 0x44ec0000, + 0x80000000, 0x44f00000, 0x80000000, 0x44f40000, + 0x80000000, 0x44f80000, 0x80000000, 0x44fc0000, + 0x80000000, 0x45000000, 0x80000000, 0x45040000, + 0x80000000, 0x45080000, 0x80000000, 0x450c0000, + 0x80000000, 0x45100000, 0x80000000, 0x45140000, + 0x80000000, 0x45180000, 0x80000000, 0x451c0000, + 0x80000000, 0x45200000, 0x80000000, 0x45240000, + 0x80000000, 0x45280000, 0x80000000, 0x452c0000, + 0x80000000, 0x45300000, 0x80000000, 0x45340000, + 0x80000000, 0x45380000, 0x80000000, 0x453c0000, + 0x80000000, 0x45400000, 0x80000000, 0x45440000, + 0x80000000, 0x45480000, 0x80000000, 0x454c0000, + 0x80000000, 0x45500000, 0x80000000, 0x45540000, + 0x80000000, 0x45580000, 0x80000000, 0x455c0000, + 0x80000000, 0x45600000, 0x80000000, 0x45640000, + 0x80000000, 0x45680000, 0x80000000, 0x456c0000, + 0x80000000, 0x45700000, 0x80000000, 0x45740000, + 0x80000000, 0x45780000, 0x80000000, 0x457c0000, + 0x80000000, 0x45800000, 0x80000000, 0x45840000, + 0x80000000, 0x45880000, 0x80000000, 0x458c0000, + 0x80000000, 0x45900000, 0x80000000, 0x45940000, + 0x80000000, 0x45980000, 0x80000000, 0x459c0000, + 0x80000000, 0x45a00000, 0x80000000, 0x45a40000, + 0x80000000, 0x45a80000, 0x80000000, 0x45ac0000, + 0x80000000, 0x45b00000, 0x80000000, 0x45b40000, + 0x80000000, 0x45b80000, 0x80000000, 0x45bc0000, + 0x80000000, 0x45c00000, 0x80000000, 0x45c40000, + 0x80000000, 0x45c80000, 0x80000000, 0x45cc0000, + 0x80000000, 0x45d00000, 0x80000000, 0x45d40000, + 0x80000000, 0x45d80000, 0x80000000, 0x45dc0000, + 0x80000000, 0x45e00000, 0x80000000, 0x45e40000, + 0x80000000, 0x45e80000, 0x80000000, 0x45ec0000, + 0x80000000, 0x45f00000, 0x80000000, 0x45f40000, + 0x80000000, 0x45f80000, 0x80000000, 0x45fc0000, + 0x4a03c020, 0x00004000, 0x4a03c011, 0x40000010, + 0x04006000, 0x4203e000, 0x40000000, 0x59e00017, + 0x8c000508, 0x04000003, 0x4a03c017, 0x00000000, + 0x4203e000, 0x30000001, 0x0401f000, 0x0000bf00, + 0x00000080, 0x0000bfe0, 0x00000020, 0x0000ff00, + 0x00000080, 0x0000ffd0, 0x00000030, 0x00007100, + 0x00000010, 0x00007200, 0x00000008, 0x00007209, + 0x00000007, 0x00007300, 0x00000008, 0x00007309, + 0x00000007, 0x00007400, 0x00000008, 0x00007409, + 0x00000007, 0x00007600, 0x000000b0, 0x00007700, + 0x00000040, 0x00003000, 0x00000070, 0x00004000, + 0x000000c0, 0x00006000, 0x00000050, 0x00006100, + 0x00000010, 0x00006130, 0x00000010, 0x00006150, + 0x00000010, 0x00006170, 0x00000010, 0x00006190, + 0x00000010, 0x000061b0, 0x00000010, 0x00000000, + 0x42000000, 0x00000100, 0x4202f000, 0x00000000, + 0x42000800, 0x00021f00, 0x45780800, 0x80040800, + 0x80000040, 0x040207fd, 0x4203f000, 0x00021fff, + 0x40000000, 0x4203e000, 0x90000100, 0x40000000, + 0x0201f800, 0x001006fd, 0x42000000, 0x00001000, + 0x50000000, 0x82000480, 0x24320002, 0x04020015, + 0x42000800, 0x00000064, 0x80040840, 0x04000007, + 0x4a030000, 0x00000001, 0x40000000, 0x59800000, + 0x8c000500, 0x040007f9, 0x04000008, 0x42000800, + 0x00007a17, 0x50040000, 0x8c00050e, 0x04020003, + 0x8400054e, 0x44000800, 0x4a030000, 0x00000000, + 0x4a03c020, 0x00000004, 0x4203e000, 0x6000000f, + 0x59e00023, 0x8c000500, 0x04020039, 0x42000000, + 0x00100001, 0x50000800, 0x82040c00, 0x00000004, + 0x58042003, 0x42001000, 0xffffffff, 0x0201f800, + 0x001006f4, 0x0402004e, 0x58042003, 0x42001000, + 0xffffffff, 0x0201f800, 0x001006f4, 0x04020048, + 0x58042003, 0x42001000, 0x00ffffff, 0x0201f800, + 0x001006f4, 0x04020042, 0x58042003, 0x42001000, + 0x00ffffff, 0x0201f800, 0x001006f4, 0x0402003c, + 0x42000000, 0x00100001, 0x5000a000, 0x8250a400, + 0x00000004, 0x4200a800, 0x00020000, 0x5850b003, + 0x0201f800, 0x0010ab17, 0x8250a400, 0x00000005, + 0x4a0370e8, 0x00000003, 0x4200a800, 0x0000c000, + 0x5850b003, 0x0201f800, 0x0010ab17, 0x4a0378e8, + 0x00000003, 0x4200a800, 0x00008000, 0x5850b003, + 0x0201f800, 0x0010ab17, 0x0401f02b, 0x42000800, + 0x00020000, 0x58042003, 0x42001000, 0xffffffff, + 0x0201f800, 0x001006f4, 0x04020019, 0x4a0370e8, + 0x00000003, 0x42000800, 0x0000c000, 0x58042003, + 0x82102500, 0x00ffffff, 0x42001000, 0x00ffffff, + 0x0201f800, 0x001006f4, 0x0402000d, 0x4a0378e8, + 0x00000003, 0x42000800, 0x00008000, 0x58042003, + 0x82102500, 0x00ffffff, 0x42001000, 0x00ffffff, + 0x0201f800, 0x001006f4, 0x0400000b, 0x4a03c020, + 0x00004010, 0x4a03c011, 0x40100011, 0x04006000, + 0x4203e000, 0x40000000, 0x4203e000, 0x30000001, + 0x0401f000, 0x0201f800, 0x00100791, 0x42001000, + 0x0010ab4a, 0x40080000, 0x80140480, 0x82001d00, + 0xffffff00, 0x04020003, 0x40001800, 0x0401f003, + 0x42001800, 0x000000ff, 0x480bc840, 0x480fc842, + 0x04011000, 0x400c0000, 0x80081400, 0x40140000, + 0x80080580, 0x040207f0, 0x4817500d, 0x45782800, + 0x59c40000, 0x82000500, 0xffff0000, 0x80000120, + 0x82000580, 0x00002422, 0x04020005, 0x59a80005, + 0x8400054e, 0x48035005, 0x0401f008, 0x59e00003, + 0x82000500, 0x00030000, 0x04000004, 0x59a80005, + 0x84000554, 0x48035005, 0x42000800, 0x00000040, + 0x59a80005, 0x8c000514, 0x0402000e, 0x42000800, + 0x00001000, 0x82141480, 0x0017ffff, 0x04021009, + 0x80040902, 0x82141480, 0x0013ffff, 0x04021005, + 0x80040902, 0x82141480, 0x0011ffff, 0x04001b8d, + 0x4807500e, 0x42001000, 0x00000024, 0x0201f800, + 0x00106681, 0x82040c00, 0x0010d1c0, 0x4807500b, + 0x4a03c810, 0x00100000, 0x4a03c811, 0x0010ab4a, + 0x4a03c829, 0x00000004, 0x59e40001, 0x82000540, + 0x0003001d, 0x4803c801, 0x4a03c014, 0x001c001c, + 0x42001000, 0x0000001c, 0x0201f800, 0x001006e2, + 0x4202c000, 0x0010d1c0, 0x59aab00b, 0x59aaa00b, + 0x59aaa80b, 0x59aac80e, 0x49675069, 0x59a8000b, + 0x4803500c, 0x0401fbf5, 0x0201f800, 0x00107903, + 0x0201f800, 0x001007be, 0x0201f800, 0x00100807, + 0x0201f800, 0x00101a05, 0x0201f800, 0x00101354, + 0x0201f800, 0x00100969, 0x0201f800, 0x00101354, + 0x0201f800, 0x00100f4c, 0x0201f800, 0x001066c1, + 0x0401fb1a, 0x0201f800, 0x0010220e, 0x0201f800, + 0x001053bb, 0x0201f800, 0x00104c90, 0x0201f800, + 0x00106194, 0x0201f800, 0x00105f28, 0x0201f800, + 0x001013ed, 0x0201f800, 0x0010126f, 0x4203e000, + 0xf0000001, 0x42000000, 0x00001000, 0x50000000, + 0x82000480, 0x24220001, 0x04000016, 0x59e00002, + 0x8c00051e, 0x42000000, 0x7ffe00fe, 0x04020003, + 0x42000000, 0x7ffe01fe, 0x50000800, 0x48075058, + 0x80040920, 0x82040580, 0x0000013a, 0x04000004, + 0x82040580, 0x0000013b, 0x04020006, 0x59a80005, + 0x84000552, 0x48035005, 0x4a0378e4, 0x000c0000, + 0x4a03c018, 0x0000000f, 0x4203e000, 0x20000511, + 0x4203e000, 0x50010000, 0x4a03c020, 0x00000000, + 0x04027013, 0x59e00020, 0x82000580, 0x00000002, + 0x0402000f, 0x4a03c020, 0x00004000, 0x4a03c011, + 0x40000010, 0x04006000, 0x4203e000, 0x40000000, + 0x59e00017, 0x8c000508, 0x04000003, 0x4a03c017, + 0x00000000, 0x4203e000, 0x30000001, 0x4202d800, + 0x00000000, 0x4203e000, 0xb0600000, 0x59a80005, + 0x42000800, 0x00000002, 0x8c000512, 0x04020007, + 0x42000800, 0x0000000f, 0x8c000514, 0x04020003, + 0x42000800, 0x00000001, 0x4007f800, 0x59a80005, + 0x8c000514, 0x02020000, 0x00020004, 0x59e00003, + 0x82000500, 0x00030000, 0x82000580, 0x00000000, + 0x04020af8, 0x0201f000, 0x00020004, 0x4df00000, + 0x4203e000, 0x50000000, 0x416c0000, 0x82000c80, + 0x00000008, 0x04021aef, 0x0c01f804, 0x5c03e000, + 0x0201f000, 0x00020008, 0x001002f7, 0x0010030a, + 0x001003d7, 0x001002f6, 0x00100452, 0x001002f6, + 0x001002f6, 0x00100593, 0x0401fae2, 0x42000800, + 0x0010b4a4, 0x5804001d, 0x4803c857, 0x8c000500, + 0x0400000d, 0x84000500, 0x4800081d, 0x4202d800, + 0x00000004, 0x0401fbd3, 0x49f3c857, 0x5c000800, + 0x5c000000, 0x82000540, 0x00003e00, 0x4c000000, + 0x4c040000, 0x1c01f000, 0x0401fbbd, 0x0201f800, + 0x0010513b, 0x04000009, 0x0201f800, 0x00105151, + 0x0402002e, 0x59c40006, 0x82000540, 0x000000c0, + 0x48038806, 0x0401f029, 0x0201f800, 0x001050a2, + 0x836c0580, 0x00000001, 0x040200bc, 0x59a80017, + 0x82000580, 0x00000009, 0x040200b8, 0x497b5010, + 0x4a038893, 0x00000001, 0x42001000, 0x000000f0, + 0x0201f800, 0x0010193d, 0x0201f800, 0x00105149, + 0x59c41006, 0x04020006, 0x82081540, 0x000000f1, + 0x82081500, 0xbbffffff, 0x0401f003, 0x82081540, + 0x440000f1, 0x480b8806, 0x0201f800, 0x0010609e, + 0x4a0378e4, 0x00002000, 0x42000000, 0x0010b83a, + 0x0201f800, 0x0010aa47, 0x42001000, 0x00008030, + 0x497b5013, 0x0401f035, 0x0201f800, 0x00103b38, + 0x59c400a4, 0x82000500, 0x0000000f, 0x82000480, + 0x00000007, 0x04021091, 0x0201f800, 0x0010609e, + 0x59c400a3, 0x82000500, 0xffefffff, 0x480388a3, + 0x59a8004b, 0x800001c0, 0x04020004, 0x0201f800, + 0x00104139, 0x0401f085, 0x59a80015, 0x84000546, + 0x48035015, 0x0201f800, 0x00105141, 0x59c41006, + 0x04020006, 0x82081540, 0x44000001, 0x82081500, + 0xffffff0f, 0x0401f003, 0x82081540, 0x440000f1, + 0x480b8806, 0x497b9005, 0x4a038802, 0x0000ffff, + 0x4a0378e4, 0x00003000, 0x42000000, 0x0010b80c, + 0x0201f800, 0x0010aa47, 0x59a81010, 0x42000800, + 0x00000003, 0x0201f800, 0x00106c78, 0x42001000, + 0x00008010, 0x59a8180a, 0x0201f800, 0x00103a3e, + 0x0201f800, 0x00101815, 0x59a80805, 0x82040d00, + 0xffffffdf, 0x48075005, 0x0201f800, 0x0010483d, + 0x0201f800, 0x0010513b, 0x0400000a, 0x0201f800, + 0x0010413e, 0x04000007, 0x4a035013, 0x00000001, + 0x497b5021, 0x0201f800, 0x00103c80, 0x0401f04f, + 0x0201f800, 0x001048ec, 0x04000005, 0x59c41002, + 0x8408150c, 0x480b8802, 0x0401f012, 0x0201f800, + 0x0010513b, 0x04020006, 0x59a8001d, 0x80000540, + 0x02000800, 0x0010930f, 0x0401f00a, 0x0201f800, + 0x0010930f, 0x59a80026, 0x8c000506, 0x04020005, + 0x59a8001d, 0x80000540, 0x02020800, 0x00104245, + 0x497b5028, 0x497b5027, 0x497b5018, 0x0201f800, + 0x0010513b, 0x59a81026, 0x0402000a, 0x0201f800, + 0x0010162a, 0x80001580, 0x59a8002a, 0x82000500, + 0xffff0000, 0x80040d40, 0x4807502a, 0x0401f005, + 0x59a8002a, 0x82000500, 0xffff0000, 0x4803502a, + 0x599c0017, 0x8c00050a, 0x04000002, 0x84081544, + 0x480b5026, 0x0201f800, 0x0010513b, 0x04000004, + 0x0201f800, 0x0010162a, 0x48078880, 0x42001000, + 0x00000005, 0x0201f800, 0x001070b0, 0x497b5028, + 0x497b501b, 0x4a03501c, 0x0000ffff, 0x4a0378e4, + 0x000000c0, 0x4202d800, 0x00000002, 0x0201f800, + 0x0010513b, 0x04000007, 0x59a80026, 0x82000500, + 0x0000000c, 0x82000580, 0x00000004, 0x04000003, + 0x0201f800, 0x00101e45, 0x1c01f000, 0x59a8001c, + 0x82000580, 0x0000ffff, 0x04000004, 0x0201f800, + 0x00101e45, 0x0401f074, 0x59a80026, 0x8c00050a, + 0x04020003, 0x8c000506, 0x0400001c, 0x8c000500, + 0x0400001a, 0x4a038802, 0x0000ffbf, 0x8c000502, + 0x04000016, 0x599c0018, 0x8c000516, 0x04020010, + 0x59a80027, 0x82000580, 0x0000ffff, 0x0400000c, + 0x0201f800, 0x00101f9a, 0x59a80026, 0x8c000504, + 0x0402005d, 0x42001000, 0x00000003, 0x417a5800, + 0x0201f800, 0x00101fbf, 0x0401f057, 0x59a80028, + 0x80000540, 0x04020054, 0x59a80026, 0x8c000508, + 0x04020005, 0x59a8001b, 0x80000540, 0x0402004e, + 0x0401f003, 0x8c000516, 0x0400004b, 0x0201f800, + 0x001048ec, 0x04020048, 0x599c0018, 0x8c000516, + 0x04020004, 0x0201f800, 0x00104c51, 0x04020042, + 0x599c0017, 0x8c00050a, 0x0400000d, 0x4200b000, + 0x000007f0, 0x417a8800, 0x0201f800, 0x00020245, + 0x04020004, 0x59340200, 0x8c00051a, 0x04020036, + 0x81468800, 0x8058b040, 0x040207f8, 0x4a038802, + 0x0000ffff, 0x42001800, 0x0010b4eb, 0x0401fb8c, + 0x42001800, 0x0010b4f8, 0x0401fb89, 0x59a80005, + 0x84000502, 0x48035005, 0x4a0378e4, 0x00000080, + 0x4202d800, 0x00000003, 0x4a03501c, 0x0000ffff, + 0x0401fa7f, 0x80000580, 0x0201f800, 0x00101590, + 0x599c0018, 0x8c000516, 0x04000004, 0x0201f800, + 0x00103b10, 0x0401f009, 0x42001800, 0x0000ffff, + 0x42002000, 0x00000006, 0x42003000, 0x00000000, + 0x0201f800, 0x00103aae, 0x0201f800, 0x00105151, + 0x0400000b, 0x59c40006, 0x0201f800, 0x0010513b, + 0x04000004, 0x82000500, 0xffffff0f, 0x0401f003, + 0x82000500, 0xfbffffff, 0x48038806, 0x0201f800, + 0x00106f36, 0x1c01f000, 0x4c040000, 0x4c080000, + 0x4c100000, 0x59a8003e, 0x82000c80, 0x00000004, + 0x04021980, 0x0c01f805, 0x5c002000, 0x5c001000, + 0x5c000800, 0x1c01f000, 0x00100462, 0x001004ea, + 0x00100516, 0x00100577, 0x42000000, 0x00000001, + 0x0201f800, 0x00101590, 0x0201f800, 0x0010609e, + 0x59c408a3, 0x82040d00, 0xfffffff7, 0x480788a3, + 0x0201f800, 0x00105141, 0x0400000e, 0x0201f800, + 0x00105151, 0x0400000b, 0x0201f800, 0x00105149, + 0x04020964, 0x59c400a3, 0x84000532, 0x84000570, + 0x480388a3, 0x4a038808, 0x00000008, 0x0401f010, + 0x59c400a3, 0x84000530, 0x82000500, 0xbf7fffff, + 0x480388a3, 0x42000800, 0x000000f8, 0x0201f800, + 0x00104200, 0x59c400a3, 0x82000540, 0x00018000, + 0x8400051c, 0x480388a3, 0x497b8808, 0x59c40006, + 0x82000500, 0xfbffff0e, 0x48038806, 0x497b2822, + 0x497b2823, 0x42000800, 0x000001f4, 0x42001000, + 0x00100591, 0x0201f800, 0x00105f83, 0x59c40805, + 0x42001000, 0x00000001, 0x0201f800, 0x0010193d, + 0x0201f800, 0x0010163b, 0x0402000a, 0x42000000, + 0x00000001, 0x0201f800, 0x0010188c, 0x42000000, + 0x00000001, 0x0201f800, 0x00101821, 0x0401f022, + 0x0201f800, 0x00101642, 0x04020008, 0x41780000, + 0x0201f800, 0x0010188c, 0x41780000, 0x0201f800, + 0x00101821, 0x0401f018, 0x0201f800, 0x00101649, + 0x0402000a, 0x42000000, 0x00000002, 0x0201f800, + 0x0010188c, 0x42000000, 0x00000002, 0x0201f800, + 0x00101821, 0x0401f00c, 0x0201f800, 0x00101650, + 0x04020918, 0x59a80049, 0x800001c0, 0x04000006, + 0x0201f800, 0x00101656, 0x4a03503e, 0x00000001, + 0x0401f021, 0x0201f800, 0x00101927, 0x4a03503e, + 0x00000001, 0x0201f800, 0x00105141, 0x0400000c, + 0x0201f800, 0x00105151, 0x04000009, 0x0201f800, + 0x00105149, 0x04020903, 0x4a035033, 0x00000001, + 0x0201f800, 0x001050a2, 0x0401f00f, 0x59c400a4, + 0x82000500, 0x0000000f, 0x82000580, 0x00000008, + 0x04000003, 0x4a038805, 0x04000000, 0x59c400a3, + 0x82000540, 0x0001c000, 0x480388a3, 0x84000520, + 0x480388a3, 0x1c01f000, 0x0401f8a3, 0x04020004, + 0x4a03503e, 0x00000003, 0x0401f027, 0x0201f800, + 0x00101650, 0x04020011, 0x59a80049, 0x800001c0, + 0x0400000e, 0x0201f800, 0x00101656, 0x59a80048, + 0x8c00051e, 0x0400001c, 0x0201f800, 0x00105149, + 0x04020009, 0x4a035033, 0x00000001, 0x0201f800, + 0x001050a2, 0x0401f004, 0x0201f800, 0x001018d3, + 0x04020011, 0x0201f800, 0x00101815, 0x4a03503e, + 0x00000002, 0x497b5049, 0x59c400a3, 0x84000520, + 0x480388a3, 0x497b2822, 0x497b2823, 0x42000800, + 0x0000002d, 0x42001000, 0x00100591, 0x0201f800, + 0x00105f83, 0x1c01f000, 0x0401f877, 0x04020004, + 0x4a03503e, 0x00000003, 0x0401f05b, 0x4a038805, + 0x000000f0, 0x0201f800, 0x001018d3, 0x04020050, + 0x0201f800, 0x00105149, 0x04000044, 0x59c400a4, + 0x82000500, 0x0000000f, 0x82000580, 0x00000008, + 0x04000020, 0x59c40005, 0x8c000534, 0x0402001d, + 0x59940022, 0x82000580, 0x00000001, 0x04020046, + 0x0201f800, 0x00105151, 0x04020043, 0x4a038805, + 0x000000f0, 0x0201f800, 0x00105196, 0x4a035032, + 0x0000aaaa, 0x4a035033, 0x00000000, 0x59c408a3, + 0x82040d40, 0x00000008, 0x480788a3, 0x4202d800, + 0x00000001, 0x4a03503e, 0x00000000, 0x4a038805, + 0x00000001, 0x497b2822, 0x497b2823, 0x0401f01f, + 0x0201f800, 0x00105151, 0x04020007, 0x59a80032, + 0x82000580, 0x0000aaaa, 0x04020003, 0x4a035010, + 0x00ffffff, 0x497b5032, 0x59c40006, 0x82000540, + 0x04000001, 0x48038806, 0x59a80805, 0x8c040d06, + 0x04020005, 0x59c408a3, 0x82040d40, 0x00000008, + 0x480788a3, 0x4202d800, 0x00000001, 0x4a03503e, + 0x00000000, 0x4a038805, 0x00000001, 0x497b2822, + 0x497b2823, 0x0401f010, 0x59c40005, 0x82000500, + 0x000000c0, 0x0400000c, 0x59c40006, 0x82000540, + 0x000000f1, 0x48038806, 0x0401f7ef, 0x0201f800, + 0x00101650, 0x04020004, 0x59a80049, 0x800001c0, + 0x040207a4, 0x497b8885, 0x1c01f000, 0x4803c856, + 0x42000000, 0x00000001, 0x0201f800, 0x00101590, + 0x4a03503e, 0x00000000, 0x0201f800, 0x00101650, + 0x0402000b, 0x59a80052, 0x800001c0, 0x04000004, + 0x80000040, 0x48035052, 0x04020005, 0x4a035052, + 0x0000000a, 0x4a035049, 0x00000001, 0x497b8885, + 0x0401f0ed, 0x59940022, 0x59940823, 0x80040540, + 0x1c01f000, 0x497b2823, 0x1c01f000, 0x4c080000, + 0x42001000, 0x000000f0, 0x0201f800, 0x0010193d, + 0x5c001000, 0x1c01f000, 0x4a03505c, 0x00000004, + 0x4a03505d, 0x00000000, 0x4a03505e, 0x00000010, + 0x4a03505f, 0x00000002, 0x4a035010, 0x00ffffff, + 0x0201f800, 0x0010930f, 0x4a03502a, 0x20200000, + 0x4a03502b, 0x88000200, 0x4a03502c, 0x00ff001f, + 0x4a03502d, 0x000007d0, 0x4a03502e, 0x80000000, + 0x4a03502f, 0x00000200, 0x4a035030, 0x00ff0000, + 0x4a035031, 0x00010000, 0x4a03503a, 0x514c4f47, + 0x4a03503b, 0x49432020, 0x1c01f000, 0x4d440000, + 0x417a8800, 0x41780800, 0x0201f800, 0x00020245, + 0x04020005, 0x0201f800, 0x001049e7, 0x04020002, + 0x80040800, 0x81468800, 0x83440580, 0x000007f0, + 0x040207f6, 0x5c028800, 0x1c01f000, 0x4803c857, + 0x5c000000, 0x4c000000, 0x4803c857, 0x0401f809, + 0x485fc857, 0x4203e000, 0x50000000, 0x5c000000, + 0x4d780000, 0x4200b800, 0x00008002, 0x0401f006, + 0x485fc857, 0x4203e000, 0x50000000, 0x4200b800, + 0x00008002, 0x04006000, 0x4c000000, 0x4c040000, + 0x59bc00ea, 0x82000500, 0x00000007, 0x82000580, + 0x00000001, 0x04020005, 0x42000800, 0x00000000, + 0x0201f800, 0x00106c6c, 0x5c000800, 0x4807c025, + 0x80040920, 0x4807c026, 0x5c000000, 0x4803c023, + 0x80000120, 0x4803c024, 0x5c000000, 0x4803c857, + 0x4803c021, 0x80000120, 0x4803c022, 0x41f80000, + 0x4803c027, 0x80000120, 0x4803c028, 0x42000000, + 0x00001000, 0x50000000, 0x82000480, 0x24320001, + 0x4803c857, 0x0400104f, 0x42000800, 0x00000064, + 0x80040840, 0x04000007, 0x4a030000, 0x00000001, + 0x40000000, 0x59800000, 0x8c000500, 0x040007f9, + 0x04000042, 0x42000800, 0x0010c1a3, 0x46000800, + 0xfaceface, 0x80040800, 0x42001000, 0x00007a00, + 0x58080013, 0x44000800, 0x80040800, 0x58080019, + 0x44000800, 0x80040800, 0x5808001a, 0x44000800, + 0x80040800, 0x5808001b, 0x44000800, 0x80040800, + 0x5808001c, 0x44000800, 0x80040800, 0x5808001f, + 0x44000800, 0x80040800, 0x42001000, 0x00007a40, + 0x42001800, 0x0000000b, 0x50080000, 0x44000800, + 0x80081000, 0x80040800, 0x800c1840, 0x040207fb, + 0x42001800, 0x00000003, 0x42001000, 0x00007b00, + 0x480c1003, 0x58080005, 0x44000800, 0x80040800, + 0x800c1840, 0x040217fb, 0x42001000, 0x00007c00, + 0x58080002, 0x44000800, 0x80040800, 0x58080003, + 0x44000800, 0x80040800, 0x58080020, 0x44000800, + 0x80040800, 0x58080021, 0x44000800, 0x80040800, + 0x58080022, 0x44000800, 0x80040800, 0x58080023, + 0x44000800, 0x80040800, 0x4a030000, 0x00000000, + 0x485fc020, 0x905cb9c0, 0x825cbd40, 0x00000012, + 0x485fc011, 0x4203e000, 0x40000000, 0x4202d800, + 0x00000005, 0x59e00017, 0x8c000508, 0x04000003, + 0x4a03c017, 0x00000002, 0x4203e000, 0x30000001, + 0x0401f81a, 0x0401f7ff, 0x4a03c850, 0x0010c1bf, + 0x4a03c851, 0x0010d1be, 0x4a03c853, 0x00000800, + 0x4a03c855, 0x0001eb5a, 0x59e40001, 0x82000540, + 0x00003f00, 0x4803c801, 0x4a03b104, 0x70000002, + 0x4a03a804, 0x70000002, 0x4a03b004, 0x70000002, + 0x42000000, 0x0010b8ec, 0x49780001, 0x49780002, + 0x1c01f000, 0x1c01f000, 0x59a8006b, 0x8c000530, + 0x040207fe, 0x4c080000, 0x42001000, 0x00000004, + 0x0401f862, 0x5c001000, 0x4201d000, 0x00028b0a, + 0x0201f800, 0x0010608e, 0x4c080000, 0x42001000, + 0x00000008, 0x0401f859, 0x5c001000, 0x4201d000, + 0x00028b0a, 0x0201f800, 0x0010608e, 0x4c080000, + 0x42001000, 0x00000010, 0x0401f850, 0x5c001000, + 0x4201d000, 0x00028b0a, 0x0201f800, 0x0010608e, + 0x0401f7e2, 0x8c00050c, 0x59a8086b, 0x04020003, + 0x84040d30, 0x0401f006, 0x84040d70, 0x4807506b, + 0x42001000, 0x00000000, 0x0401f040, 0x4807506b, + 0x836c0500, 0x00000007, 0x0c01f001, 0x001006e1, + 0x001006c7, 0x001006c7, 0x001006af, 0x001006d4, + 0x001006c7, 0x001006c7, 0x001006d4, 0x59a80005, + 0x8c000514, 0x04020013, 0x59c40801, 0x82040d00, + 0x00018000, 0x82040580, 0x00010000, 0x0400000a, + 0x82040580, 0x00008000, 0x04000004, 0x42001000, + 0x42004000, 0x0401f006, 0x42001000, 0x22002000, + 0x0401f003, 0x42001000, 0x12001000, 0x0401f025, + 0x42001000, 0x00001004, 0x0401f022, 0x59a80005, + 0x8c000514, 0x04020008, 0x59a8006b, 0x8c000534, + 0x04020004, 0x42001000, 0x74057005, 0x0401f819, + 0x1c01f000, 0x42001000, 0x00002008, 0x0401f7fc, + 0x59a8006b, 0x8c000534, 0x0402000a, 0x59a80005, + 0x8c000514, 0x04000004, 0x42001000, 0x24052005, + 0x0401f00c, 0x42001000, 0x74057005, 0x0401f009, + 0x1c01f000, 0x1c01f000, 0x82081500, 0x0000001c, + 0x82081540, 0x001c0000, 0x480bc013, 0x1c01f000, + 0x59a8006b, 0x8c000530, 0x04000002, 0x84081570, + 0x480b506b, 0x8c000530, 0x04020005, 0x82081500, + 0x00007000, 0x80081114, 0x0401fff0, 0x1c01f000, + 0x41780000, 0x50041800, 0x800c0400, 0x80040800, + 0x80102040, 0x040207fc, 0x80080500, 0x80000540, + 0x1c01f000, 0x4202f000, 0x00000000, 0x41780000, + 0x41780800, 0x41781000, 0x41781800, 0x41782000, + 0x41782800, 0x41783000, 0x41783800, 0x41784000, + 0x41784800, 0x41785000, 0x41785800, 0x41786000, + 0x41786800, 0x41787000, 0x41787800, 0x41788000, + 0x41788800, 0x41789000, 0x41789800, 0x4178a000, + 0x4178a800, 0x4178b000, 0x4178b800, 0x4178c000, + 0x4178c800, 0x4178d000, 0x4178d800, 0x4178e000, + 0x4178e800, 0x4178f000, 0x4178f800, 0x41790000, + 0x41790800, 0x41791000, 0x41791800, 0x41792000, + 0x41792800, 0x41793000, 0x41793800, 0x41794000, + 0x41794800, 0x41795000, 0x41795800, 0x41796000, + 0x41796800, 0x41797000, 0x41797800, 0x41798000, + 0x41798800, 0x42019000, 0x0010b537, 0x42019800, + 0x0010b50e, 0x4179a000, 0x4179b000, 0x4179a800, + 0x4179b800, 0x4179c800, 0x4179c000, 0x4179d000, + 0x4179d800, 0x4179e000, 0x4179e800, 0x4179f000, + 0x4179f800, 0x417a0000, 0x417a0800, 0x417a1000, + 0x417a1800, 0x417a2000, 0x42022800, 0x00006100, + 0x417a3000, 0x417a3800, 0x417a4000, 0x417a4800, + 0x417a5000, 0x417a5800, 0x417a6000, 0x417a6800, + 0x417a7000, 0x417a7800, 0x417a8000, 0x417a8800, + 0x417a9000, 0x417a9800, 0x417ae800, 0x417af800, + 0x42030000, 0x00007c00, 0x42031000, 0x0010b806, + 0x42031800, 0x0000bf1d, 0x42032000, 0x0000bf32, + 0x42032800, 0x0010b7ce, 0x42033000, 0x0010b46e, + 0x42034000, 0x0010b4a4, 0x42033800, 0x0010b4c3, + 0x42034800, 0x0010b544, 0x42035000, 0x0010b400, + 0x42035800, 0x0010ac00, 0x42030800, 0x0010b505, + 0x417b6000, 0x42036800, 0x00006f00, 0x4203c800, + 0x00003000, 0x42037000, 0x0000ff00, 0x42037800, + 0x0000bf00, 0x42038000, 0x00007700, 0x42038800, + 0x00004000, 0x42039000, 0x00006000, 0x42039800, + 0x0010bedb, 0x4203a000, 0x00007600, 0x4203a800, + 0x00007400, 0x4203b000, 0x00007200, 0x4203b800, + 0x00007100, 0x4203c000, 0x00007000, 0x4203d000, + 0x00000000, 0x4203e800, 0x00101b95, 0x417bd800, + 0x1c01f000, 0x42000800, 0x00100000, 0x50040000, + 0x4c000000, 0x42000000, 0x0000aaaa, 0x44000800, + 0x42001800, 0x00005555, 0x41782000, 0x82102400, + 0x00010000, 0x40100000, 0x80042c00, 0x440c2800, + 0x42003000, 0x0000000a, 0x80183040, 0x040207ff, + 0x50140000, 0x800c0580, 0x04020004, 0x50040000, + 0x800c0580, 0x040207f2, 0x5c000000, 0x44000800, + 0x80142840, 0x4817c861, 0x1c01f000, 0x59a8081f, + 0x800409c0, 0x04020009, 0x49781c0c, 0x4a001a0c, + 0x00000200, 0x4a001804, 0x07000000, 0x59a80010, + 0x9c0001c0, 0x48001805, 0x0401fe01, 0x9c0409c0, + 0x48041806, 0x1c01f000, 0x59a8080c, 0x4006d000, + 0x4202b800, 0x00000001, 0x59a8180d, 0x480fc857, + 0x82041400, 0x00000014, 0x82082400, 0x00000014, + 0x40100000, 0x800c0480, 0x04001006, 0x44080800, + 0x40080800, 0x40101000, 0x815eb800, 0x0401f7f7, + 0x45780800, 0x495f5020, 0x1c01f000, 0x835c0480, + 0x00000020, 0x04001009, 0x496bc857, 0x815eb840, + 0x416a5800, 0x592ed000, 0x497a5800, 0x497a5801, + 0x812e59c0, 0x1c01f000, 0x42000000, 0x0010b853, + 0x0201f800, 0x0010aa47, 0x417a5800, 0x0401f7f9, + 0x815eb840, 0x04001008, 0x416a5800, 0x492fc857, + 0x592ed000, 0x497a5800, 0x497a5801, 0x812e59c0, + 0x1c01f000, 0x42000000, 0x0010b853, 0x0201f800, + 0x0010aa47, 0x417ab800, 0x417a5800, 0x0401f7f8, + 0x492fc857, 0x496a5800, 0x412ed000, 0x815eb800, + 0x59c80000, 0x82000540, 0x00001200, 0x48039000, + 0x1c01f000, 0x492fc857, 0x812e59c0, 0x04000007, + 0x592c0001, 0x497a5801, 0x4c000000, 0x0401fff1, + 0x5c025800, 0x0401f7f9, 0x1c01f000, 0x4807c856, + 0x42007000, 0x0010b7f8, 0x4a007001, 0x00000000, + 0x59e00003, 0x82000540, 0x00008080, 0x4803c003, + 0x4a03b805, 0x90000001, 0x59dc0006, 0x4a03b805, + 0x70000000, 0x59dc0006, 0x4a03b805, 0x30000000, + 0x4200b000, 0x00000020, 0x497bb807, 0x8058b040, + 0x040207fe, 0x4a03b805, 0x30000000, 0x59dc0006, + 0x4a03b805, 0x60000001, 0x59dc0006, 0x4a03b805, + 0x70000001, 0x59dc0006, 0x4a03b805, 0x30000002, + 0x4200b000, 0x00000020, 0x497bb807, 0x8058b040, + 0x040207fe, 0x4a03b805, 0x30000000, 0x59dc0006, + 0x4a03b805, 0x60000001, 0x0401ffa1, 0x04000da5, + 0x42001000, 0x0010b7f6, 0x452c1000, 0x4a025801, + 0x00000001, 0x4a025802, 0x00000100, 0x4a025809, + 0x00107149, 0x497a580a, 0x497a580b, 0x497a580c, + 0x0401ff93, 0x04000d97, 0x42001000, 0x0010b7f7, + 0x452c1000, 0x4a025801, 0x00000000, 0x4a025802, + 0x00000100, 0x4a025809, 0x001011bc, 0x497a5803, + 0x497a5807, 0x497a5808, 0x497a580a, 0x59a80005, + 0x8c00050e, 0x04000006, 0x4a03b805, 0xe0000001, + 0x59dc0006, 0x8c000522, 0x040007fc, 0x1c01f000, + 0x4df00000, 0x4203e000, 0x50000000, 0x4c380000, + 0x40087000, 0x480bc857, 0x4a007002, 0x00000000, + 0x42007000, 0x0010b7f8, 0x82080400, 0x00000000, + 0x45780000, 0x58380005, 0x48087005, 0x80000540, + 0x04000005, 0x82000400, 0x00000000, 0x44080000, + 0x0401f003, 0x480bc857, 0x48087006, 0x58380001, + 0x80000540, 0x0400080c, 0x5c007000, 0x5c03e000, + 0x1c01f000, 0x4c380000, 0x42007000, 0x0010b7f8, + 0x58380001, 0x80000540, 0x04000803, 0x5c007000, + 0x1c01f000, 0x42007000, 0x0010b7f8, 0x58380001, + 0x82000580, 0x00000000, 0x04020012, 0x58380000, + 0x0c01f001, 0x0010088e, 0x0010088d, 0x0010088d, + 0x0010088d, 0x0010088d, 0x0010088d, 0x0010088d, + 0x0010088d, 0x0401fd4b, 0x58380808, 0x800409c0, + 0x04020024, 0x58380006, 0x80000540, 0x04020002, + 0x1c01f000, 0x4803c857, 0x48007002, 0x40006800, + 0x58340000, 0x80000540, 0x04020002, 0x48007005, + 0x48007006, 0x4a03b805, 0x20000000, 0x59dc0006, + 0x4a03b805, 0x30000000, 0x58340007, 0x4803b800, + 0x58340008, 0x4803b801, 0x58340004, 0x48007003, + 0x58340003, 0x48007004, 0x4803b803, 0x58340001, + 0x8c000500, 0x04000004, 0x4a007001, 0x00000001, + 0x0401f028, 0x4a007001, 0x00000002, 0x0401f03d, + 0x0201f800, 0x001093ea, 0x0201f800, 0x0010a69d, + 0x04000017, 0x4a03b805, 0x20000000, 0x59dc0006, + 0x4a03b805, 0x30000000, 0x4807b800, 0x480bb801, + 0x4a007003, 0x00000010, 0x480c7009, 0x42001000, + 0x00100875, 0x0201f800, 0x00105f9a, 0x58380008, + 0x82000400, 0x00000004, 0x48007004, 0x4803b803, + 0x4a007001, 0x00000007, 0x0401f022, 0x0201f800, + 0x00109402, 0x42000800, 0x00000001, 0x42001000, + 0x00100875, 0x0201f800, 0x00105f76, 0x0401f7ba, + 0x4c040000, 0x4c080000, 0x58380803, 0x42001000, + 0x00003fff, 0x82040480, 0x00003fff, 0x04021003, + 0x40041000, 0x80000580, 0x48007003, 0x800800c4, + 0x4803b802, 0x4a03b805, 0x30000002, 0x59dc0006, + 0x4a03b805, 0x70000001, 0x59dc0006, 0x4a03b805, + 0x10000000, 0x5c001000, 0x5c000800, 0x1c01f000, + 0x483bc857, 0x4c040000, 0x4c080000, 0x58380803, + 0x42001000, 0x00003fff, 0x82040480, 0x00003fff, + 0x04021003, 0x40041000, 0x80000580, 0x48007003, + 0x800800c4, 0x4803b802, 0x4a03b805, 0x10000002, + 0x5c001000, 0x5c000800, 0x1c01f000, 0x4c040000, + 0x4c380000, 0x42007000, 0x0010b7f8, 0x59dc0806, + 0x4807c857, 0x4a03b805, 0x20000000, 0x8c040d3e, + 0x04000007, 0x8c040d08, 0x04020cca, 0x58380001, + 0x82000500, 0x00000007, 0x0c01f804, 0x5c007000, + 0x5c000800, 0x1c01f000, 0x0010087d, 0x0010091e, + 0x0010092e, 0x001005d8, 0x001005d8, 0x001005d8, + 0x001005d8, 0x001011ea, 0x4807c856, 0x82040d00, + 0x43000f80, 0x04020009, 0x58380003, 0x80000540, + 0x0400001c, 0x59dc0000, 0x4803b800, 0x59dc0001, + 0x4803b801, 0x0401f7af, 0x58380802, 0x4a000802, + 0x00000200, 0x0401f01e, 0x4807c856, 0x82040d00, + 0x43000f80, 0x04020009, 0x58380003, 0x80000540, + 0x0400000c, 0x59dc0000, 0x4803b800, 0x59dc0001, + 0x4803b801, 0x0401f7b7, 0x58380002, 0x82000400, + 0x00000002, 0x46000000, 0x00000200, 0x0401f00c, + 0x4c340000, 0x58386802, 0x59dc0000, 0x4803c857, + 0x48006807, 0x59dc0001, 0x4803c857, 0x48006808, + 0x4a006802, 0x00000100, 0x5c006800, 0x4a007001, + 0x00000000, 0x4c300000, 0x58386002, 0x0401f80c, + 0x04000009, 0x58300009, 0x82000c80, 0x0010ab4a, + 0x04021c84, 0x82000c80, 0x00020000, 0x04001c81, + 0x0801f800, 0x5c006000, 0x0401f723, 0x4833c857, + 0x803061c0, 0x04000009, 0x59a8000c, 0x80300480, + 0x04001007, 0x59a8000d, 0x80300480, 0x04021004, + 0x82000540, 0x00000001, 0x1c01f000, 0x80000580, + 0x1c01f000, 0x4803c856, 0x4dc00000, 0x42007000, + 0x0010b803, 0x4a007400, 0x00000000, 0x49787001, + 0x42038000, 0x00007720, 0x4a038006, 0x60000001, + 0x4a038009, 0xf4f60000, 0x42038000, 0x00007700, + 0x4a038006, 0x60000001, 0x4a038009, 0xf4f60000, + 0x4a03c822, 0x00000010, 0x4a0370e8, 0x00000000, + 0x0401f809, 0x4a0370e9, 0x00003a0f, 0x4a0370e8, + 0x00000000, 0x4a0370e8, 0x00000001, 0x5c038000, + 0x1c01f000, 0x4c5c0000, 0x4178b800, 0x0401f80a, + 0x5c00b800, 0x1c01f000, 0x4803c856, 0x4c5c0000, + 0x825cbd40, 0x00000001, 0x0401f803, 0x5c00b800, + 0x1c01f000, 0x4803c856, 0x4dc00000, 0x4c500000, + 0x4c580000, 0x4c540000, 0x4a0370e8, 0x00000000, + 0x805cb9c0, 0x04000009, 0x4a038807, 0x00000004, + 0x59b800ea, 0x8c000510, 0x04000004, 0x59b800e0, + 0x0401f87b, 0x0401f7fb, 0x42038000, 0x00007720, + 0x0201f800, 0x00100ec1, 0x59c00007, 0x4a038006, + 0x20000000, 0x59c00007, 0x4a038006, 0x8000000a, + 0x59c00007, 0x4a038006, 0x8000000b, 0x59c00007, + 0x4a038006, 0x40000001, 0x83c00580, 0x00007700, + 0x04000004, 0x42038000, 0x00007700, 0x0401f7ed, + 0x42038000, 0x00007720, 0x42000800, 0x00000800, + 0x59c00007, 0x8c00051e, 0x04000006, 0x4a038006, + 0x90000001, 0x80040840, 0x040207fa, 0x0401fc11, + 0x83c00580, 0x00007700, 0x04000004, 0x42038000, + 0x00007700, 0x0401f7f1, 0x805cb9c0, 0x0402001d, + 0x4200b000, 0x00000020, 0x83b8ac00, 0x00000020, + 0x0201f800, 0x0010ab20, 0x4a0370fb, 0x00000001, + 0x4a037020, 0x001010bd, 0x59a80039, 0x82000500, + 0x0000ffff, 0x48037021, 0x4a037035, 0x0010bddb, + 0x4a037030, 0x0010b410, 0x4a037031, 0x0010ac00, + 0x4a037032, 0x0010b519, 0x4a037036, 0x0010b524, + 0x59840002, 0x48037034, 0x4a037038, 0x001010b4, + 0x4a0370fb, 0x00000001, 0x4178a000, 0x4200b000, + 0x00000020, 0x83b8ac00, 0x00000000, 0x0201f800, + 0x0010ab20, 0x4200b000, 0x00000040, 0x83b8ac00, + 0x00000040, 0x0201f800, 0x0010ab20, 0x805cb9c0, + 0x04020004, 0x4a0370e4, 0xaaaaaaaa, 0x0401f003, + 0x4a0370e4, 0xa2aaaa82, 0x4a0370e5, 0xaaaaaaaa, + 0x4a0370e6, 0xaaaaaaaa, 0x4a0370fb, 0x00000000, + 0x4a0370e6, 0xaaaaaaaa, 0x42038000, 0x00007720, + 0x4a038006, 0x90000000, 0x59c00007, 0x8c00051e, + 0x02020800, 0x001005d8, 0x42038000, 0x00007700, + 0x4a038006, 0x90000000, 0x59c00007, 0x8c00051e, + 0x02020800, 0x001005d8, 0x5c00a800, 0x5c00b000, + 0x5c00a000, 0x5c038000, 0x1c01f000, 0x4d300000, + 0x4d380000, 0x40026000, 0x82000500, 0x7f000000, + 0x82000580, 0x00000003, 0x0402000f, 0x83326500, + 0x00ffffff, 0x59300203, 0x82000580, 0x00000004, + 0x04020009, 0x59300c06, 0x82040580, 0x00000009, + 0x04020005, 0x42027000, 0x00000047, 0x0201f800, + 0x000207a1, 0x5c027000, 0x5c026000, 0x1c01f000, + 0x4d300000, 0x4d2c0000, 0x4d340000, 0x4d400000, + 0x4cfc0000, 0x4d380000, 0x4d3c0000, 0x4d440000, + 0x4d4c0000, 0x4d480000, 0x4c5c0000, 0x4c600000, + 0x4c640000, 0x4cc80000, 0x4ccc0000, 0x4cf00000, + 0x4cf40000, 0x4cf80000, 0x4cfc0000, 0x4d000000, + 0x4d040000, 0x0201f800, 0x00020015, 0x5c020800, + 0x5c020000, 0x5c01f800, 0x5c01f000, 0x5c01e800, + 0x5c01e000, 0x5c019800, 0x5c019000, 0x5c00c800, + 0x5c00c000, 0x5c00b800, 0x5c029000, 0x5c029800, + 0x5c028800, 0x5c027800, 0x5c027000, 0x5c01f800, + 0x5c028000, 0x5c026800, 0x5c025800, 0x5c026000, + 0x1c01f000, 0x493bc857, 0x0201f000, 0x00020044, + 0x83300500, 0x1f000000, 0x04000008, 0x81326580, + 0x80000130, 0x82000c80, 0x00000014, 0x02021800, + 0x001005d8, 0x0c01f013, 0x83300500, 0x000000ff, + 0x82000c80, 0x00000007, 0x02021800, 0x001005d8, + 0x0c01f025, 0x1c01f000, 0x82000d00, 0xc0000038, + 0x02020800, 0x001005d0, 0x0201f800, 0x001005d8, + 0x00000000, 0x00000048, 0x00000054, 0x00000053, + 0x00100a9b, 0x00100abf, 0x00100aba, 0x00100adf, + 0x00100aa6, 0x00100ab2, 0x00100a9b, 0x00100ada, + 0x00100b1a, 0x00100a9b, 0x00100a9b, 0x00100a9b, + 0x00100a9b, 0x00100b1d, 0x00100b23, 0x00100b34, + 0x00100b45, 0x00100a9b, 0x00100b4e, 0x00100b5a, + 0x00100a9b, 0x00100a9b, 0x00100a9b, 0x0201f800, + 0x001005d8, 0x00100aa4, 0x00100bff, 0x00100aec, + 0x00100b0f, 0x00100aa4, 0x00100aa4, 0x00100aa4, + 0x0201f800, 0x001005d8, 0x4803c856, 0x59300004, + 0x8c00053e, 0x04020005, 0x42027000, 0x00000055, + 0x0201f000, 0x000207a1, 0x0201f800, 0x00106f60, + 0x040007fa, 0x1c01f000, 0x4803c856, 0x0401f8a9, + 0x40002800, 0x41782000, 0x42027000, 0x00000056, + 0x0201f000, 0x000207a1, 0x4803c856, 0x42027000, + 0x00000057, 0x0201f000, 0x000207a1, 0x4803c856, + 0x59300007, 0x8c00051a, 0x04020010, 0x59325808, + 0x812e59c0, 0x04000014, 0x592c0408, 0x8c00051c, + 0x04020003, 0x4a026011, 0xffffffff, 0x59300004, + 0x8c00053e, 0x04020009, 0x42027000, 0x00000048, + 0x0201f000, 0x000207a1, 0x59325808, 0x4a025a06, + 0x00000007, 0x0401f7f4, 0x0201f800, 0x00106f60, + 0x040007f6, 0x1c01f000, 0x4803c856, 0x83300500, + 0x00ffffff, 0x0201f000, 0x001064d7, 0x1c01f000, + 0x4c040000, 0x59b808ea, 0x82040d00, 0x00000007, + 0x82040580, 0x00000003, 0x04000004, 0x42000000, + 0x60000000, 0x0401f8ab, 0x5c000800, 0x1c01f000, + 0x0401f8f9, 0x59325808, 0x812e59c0, 0x04000018, + 0x592c0204, 0x82000500, 0x000000ff, 0x82000d80, + 0x00000029, 0x04020012, 0x59300203, 0x82000580, + 0x00000003, 0x0400000b, 0x59300807, 0x84040d26, + 0x48066007, 0x0201f800, 0x00020086, 0x4a03900d, + 0x00000040, 0x4a0370e5, 0x00000008, 0x1c01f000, + 0x0201f800, 0x00106f60, 0x040007f4, 0x59880052, + 0x80000000, 0x48031052, 0x4a03900d, 0x00000040, + 0x42000000, 0xc0000000, 0x0401f05a, 0x42007800, + 0x0010bde2, 0x42002000, 0x00003000, 0x42003000, + 0x00000105, 0x0201f800, 0x00105e04, 0x4a0370e4, + 0x02000000, 0x1c01f000, 0x4933c857, 0x0201f000, + 0x0002077d, 0x41300800, 0x800409c0, 0x02020800, + 0x001005d8, 0x0201f800, 0x001005d0, 0x4933c857, + 0x813261c0, 0x02000800, 0x001005d8, 0x0401f835, + 0x40002800, 0x0201f800, 0x0010a99c, 0x0401f8ae, + 0x04000007, 0x59326809, 0x59340200, 0x8c00050e, + 0x59300414, 0x02020800, 0x001092ce, 0x1c01f000, + 0x4933c857, 0x813261c0, 0x02000800, 0x001005d8, + 0x0401f8a1, 0x0400000b, 0x59325808, 0x0201f800, + 0x00109037, 0x04000007, 0x592c0208, 0x8400054e, + 0x48025a08, 0x417a7800, 0x0201f800, 0x00108be3, + 0x1c01f000, 0x485fc857, 0x5c000000, 0x4d780000, + 0x4203e000, 0x50000000, 0x4200b800, 0x00008005, + 0x0201f000, 0x001005dd, 0x4933c857, 0x83300480, + 0x00000020, 0x02021800, 0x001005d8, 0x83300c00, + 0x0010b8cc, 0x50040000, 0x80000000, 0x04001002, + 0x44000800, 0x1c01f000, 0x4933c857, 0x0401f7f4, + 0x4807c856, 0x59b800ea, 0x8c000510, 0x040007fd, + 0x59b800e0, 0x4803c857, 0x1c01f000, 0x4803c856, + 0x42000000, 0x10000000, 0x41300800, 0x0401f02d, + 0x82000500, 0xf0000000, 0x82040d00, 0x0fffffff, + 0x80040d40, 0x4807c857, 0x59b800ea, 0x8c000516, + 0x04020003, 0x480770e1, 0x1c01f000, 0x8c000510, + 0x040007fa, 0x4c040000, 0x0401f809, 0x5c000800, + 0x82100480, 0x00000008, 0x040017f4, 0x4c040000, + 0x0401febc, 0x5c000800, 0x0401f7f0, 0x59b800e2, + 0x59b820e2, 0x80100580, 0x040207fd, 0x80102114, + 0x0401f006, 0x59b800e2, 0x59b820e2, 0x80100580, + 0x040207fd, 0x0401f001, 0x40101800, 0x800c190a, + 0x82100500, 0x0000001f, 0x820c1d00, 0x0000001f, + 0x800c2480, 0x82102500, 0x0000001f, 0x1c01f000, + 0x82000500, 0xf0000000, 0x82040d00, 0x0fffffff, + 0x80040d40, 0x4807c857, 0x42001000, 0x0010b804, + 0x50080000, 0x80000540, 0x04020005, 0x4a0370e5, + 0x00000003, 0x4a0370e4, 0x00000300, 0x80000000, + 0x44001000, 0x42001000, 0x00000400, 0x59b800ea, + 0x8c000510, 0x0400000c, 0x0401ffd5, 0x82100480, + 0x00000008, 0x04001007, 0x4c040000, 0x4c080000, + 0x0401fe88, 0x5c001000, 0x5c000800, 0x0401f020, + 0x59b800ea, 0x8c000516, 0x0402001d, 0x4a0370e4, + 0x00300000, 0x480770e1, 0x42001000, 0x0000ff00, + 0x80081040, 0x04000012, 0x59b808e4, 0x8c040d28, + 0x040207fc, 0x42001000, 0x0010b804, 0x50080000, + 0x80000040, 0x04020005, 0x4a0370e5, 0x00000002, + 0x4a0370e4, 0x00000200, 0x02001800, 0x001005d8, + 0x44001000, 0x8c040d2c, 0x1c01f000, 0x41f80000, + 0x50000000, 0x0201f800, 0x001005d8, 0x80081040, + 0x040207d3, 0x41f80000, 0x50000000, 0x0201f800, + 0x001005d8, 0x4d380000, 0x59300c06, 0x82040580, + 0x00000009, 0x04020006, 0x42027000, 0x00000047, + 0x0201f800, 0x000207a1, 0x80000580, 0x5c027000, + 0x1c01f000, 0x4c500000, 0x4a03900d, 0x00000001, + 0x59c8a020, 0x4a03900d, 0x00000002, 0x59c80820, + 0x8c50a52e, 0x04000002, 0x900409c0, 0x82040d00, + 0x0000ffff, 0x0201f800, 0x00105dd7, 0x02000800, + 0x001005d8, 0x4933c857, 0x8250a500, 0xff000000, + 0x82500580, 0x05000000, 0x04000003, 0x82000540, + 0x00000001, 0x5c00a000, 0x1c01f000, 0x0401ffe6, + 0x4933c857, 0x59300406, 0x82000580, 0x00000000, + 0x04000040, 0x59c82021, 0x4a03900d, 0x00000001, + 0x59c82821, 0x82142d00, 0x0000ffff, 0x59325808, + 0x812e59c0, 0x04000037, 0x59326809, 0x0201f800, + 0x001048d9, 0x02020800, 0x001092b6, 0x599c0019, + 0x8c00050c, 0x04020018, 0x0201f800, 0x001048d9, + 0x04020015, 0x59300811, 0x4807c857, 0x592c0408, + 0x8c00051c, 0x0402000e, 0x8400055c, 0x48025c08, + 0x592c0a04, 0x82040d00, 0x000000ff, 0x82040580, + 0x00000048, 0x04000004, 0x82040580, 0x00000018, + 0x04020003, 0x59300811, 0x48065803, 0x4a026011, + 0x7fffffff, 0x48166013, 0x0201f800, 0x001010dd, + 0x04020014, 0x0401f9fd, 0x40280000, 0x4802600d, + 0x04000005, 0x4832600b, 0x50200000, 0x4802600a, + 0x4822600c, 0x59300414, 0x8c00051c, 0x04020004, + 0x599c0019, 0x8c00050c, 0x0402086e, 0x4a03900d, + 0x00000040, 0x4a0370e5, 0x00000008, 0x1c01f000, + 0x59880052, 0x80000000, 0x48031052, 0x4a03900d, + 0x00000040, 0x42000000, 0xc0000000, 0x0401f71d, + 0x4cf80000, 0x58f40000, 0x8001f540, 0x0401f820, + 0x41781800, 0x0401f8e4, 0x04020014, 0x44140800, + 0x0401f82a, 0x04000011, 0x40043800, 0x42001800, + 0x00000001, 0x40142000, 0x0401f8db, 0x0402000b, + 0x801c3800, 0x501c0000, 0x44000800, 0x0401f810, + 0x801c0580, 0x04000004, 0x44103800, 0x801c3840, + 0x44143800, 0x0401f819, 0x5c01f000, 0x1c01f000, + 0x80f9f1c0, 0x04020003, 0x58f41202, 0x0401f003, + 0x42001000, 0x00000007, 0x1c01f000, 0x80f9f1c0, + 0x04020006, 0x58f40401, 0x82000480, 0x00000002, + 0x80f40400, 0x0401f005, 0x58f80401, 0x82000480, + 0x00000002, 0x80f80400, 0x50002800, 0x80000000, + 0x50002000, 0x1c01f000, 0x80f9f1c0, 0x04020008, + 0x58f40401, 0x82000480, 0x00000002, 0x02001800, + 0x001005d8, 0x4801ec01, 0x0401f00b, 0x58f80401, + 0x82000480, 0x00000002, 0x02001800, 0x001005d8, + 0x4801f401, 0x82000580, 0x00000002, 0x04020002, + 0x0401f809, 0x58f40202, 0x80000040, 0x4801ea02, + 0x02000800, 0x001005d8, 0x82000580, 0x00000001, + 0x1c01f000, 0x4d2c0000, 0x40fa5800, 0x0201f800, + 0x001007f4, 0x4979e800, 0x4179f000, 0x5c025800, + 0x1c01f000, 0x80f5e9c0, 0x04000009, 0x80f9f1c0, + 0x04020ff5, 0x4d2c0000, 0x40f65800, 0x0201f800, + 0x001007f4, 0x4179e800, 0x5c025800, 0x1c01f000, + 0x4cf40000, 0x59300807, 0x82040500, 0x00003100, + 0x04020032, 0x8c040d22, 0x04000032, 0x5930001f, + 0x8001ed40, 0x02000800, 0x001005d8, 0x82000580, + 0xffffffff, 0x04000029, 0x58f40201, 0x82000580, + 0x0000dcb3, 0x02020800, 0x001005d8, 0x58f40a02, + 0x82040500, 0x0000fffe, 0x04000003, 0x0401ff89, + 0x58f40a02, 0x82040480, 0x0000000f, 0x04021059, + 0x80040800, 0x4805ea02, 0x82040580, 0x00000008, + 0x0400005d, 0x82040480, 0x00000008, 0x0400100a, + 0x58f40000, 0x8001ed40, 0x02000800, 0x001005d8, + 0x58f40201, 0x82000580, 0x0000ddb9, 0x02020800, + 0x001005d8, 0x58f40401, 0x82000c00, 0x00000002, + 0x4805ec01, 0x80f40400, 0x59300812, 0x44040000, + 0x80000000, 0x45780000, 0x5c01e800, 0x1c01f000, + 0x42001000, 0x00000400, 0x59b800e4, 0x8c000524, + 0x04020023, 0x4a0370e4, 0x00030000, 0x40000000, + 0x59b800e4, 0x8c000524, 0x0402001b, 0x59300807, + 0x84040d62, 0x48066007, 0x4a0370e4, 0x00020000, + 0x4d2c0000, 0x0201f800, 0x001007d3, 0x04000025, + 0x492e601f, 0x4a025a01, 0x0000dcb3, 0x59300008, + 0x80001d40, 0x02000800, 0x001005d8, 0x580c080f, + 0x48065803, 0x59301811, 0x40040000, 0x800c0580, + 0x0402000d, 0x497a5a02, 0x4a025c01, 0x00000004, + 0x0401f011, 0x4a0370e4, 0x00020000, 0x40000000, + 0x40000000, 0x80081040, 0x02000800, 0x001005d8, + 0x0401f7d6, 0x4a025a02, 0x00000001, 0x4a025c01, + 0x00000006, 0x497a5804, 0x400c0000, 0x80040480, + 0x48025805, 0x412de800, 0x5c025800, 0x0401f7a9, + 0x5c025800, 0x4a02601f, 0xffffffff, 0x0401f7c3, + 0x4d2c0000, 0x58f65800, 0x0201f800, 0x001007f4, + 0x40f65800, 0x0201f800, 0x001007f4, 0x5c025800, + 0x0401f7f5, 0x4d2c0000, 0x0201f800, 0x001007d3, + 0x040007f8, 0x4a025a01, 0x0000ddb9, 0x4a025c01, + 0x00000002, 0x492de800, 0x412de800, 0x5c025800, + 0x0401f7a5, 0x0401ff33, 0x82f40400, 0x00000004, + 0x800c0400, 0x40000800, 0x50040000, 0x80100580, + 0x04000016, 0x82040c00, 0x00000002, 0x80081040, + 0x040207fa, 0x80f9f1c0, 0x04000011, 0x58f41202, + 0x82081480, 0x00000007, 0x82f80400, 0x00000002, + 0x800c0400, 0x40000800, 0x50040000, 0x80100580, + 0x04000006, 0x82040c00, 0x00000002, 0x80081040, + 0x040207fa, 0x0401f002, 0x1c01f000, 0x82000540, + 0x00000001, 0x0401f7fd, 0x4cf40000, 0x4cf80000, + 0x4001e800, 0x592c0a06, 0x800409c0, 0x0402001d, + 0x82f40580, 0xffffffff, 0x04000017, 0x58f40201, + 0x82000580, 0x0000dcb3, 0x02020800, 0x001005d8, + 0x58f40000, 0x8001f540, 0x04000006, 0x58f80201, + 0x82000580, 0x0000ddb9, 0x02020800, 0x001005d8, + 0x41783800, 0x0401f839, 0x04020006, 0x0401ff32, + 0x497a601f, 0x5c01f000, 0x5c01e800, 0x1c01f000, + 0x0401ff2d, 0x4a025a06, 0x00000011, 0x0401f7f9, + 0x82f40580, 0xffffffff, 0x04020f27, 0x0401f7f5, + 0x4cf40000, 0x4cf80000, 0x4001e800, 0x82040580, + 0x00000001, 0x0402001f, 0x82f40580, 0xffffffff, + 0x04000019, 0x58f40201, 0x82000580, 0x0000dcb3, + 0x02020800, 0x001005d8, 0x58f40000, 0x8001f540, + 0x04000006, 0x58f80201, 0x82000580, 0x0000ddb9, + 0x02020800, 0x001005d8, 0x41783800, 0x0401f813, + 0x04020008, 0x0401ff0c, 0x42000800, 0x00000001, + 0x497a601f, 0x5c01f000, 0x5c01e800, 0x1c01f000, + 0x0401ff05, 0x42000800, 0x00000011, 0x0401f7f9, + 0x4c040000, 0x82f40580, 0xffffffff, 0x04020efe, + 0x5c000800, 0x0401f7f3, 0x4803c856, 0x401c2000, + 0x41781800, 0x0401ff8c, 0x0402002c, 0x58f42003, + 0x42001800, 0x00000001, 0x0401ff87, 0x04020027, + 0x0401feb8, 0x40082800, 0x82f40400, 0x00000004, + 0x40003000, 0x50182000, 0x40100000, 0x801c0580, + 0x04000005, 0x42001800, 0x00000001, 0x0401ff7a, + 0x0402001a, 0x82183400, 0x00000002, 0x80142840, + 0x040207f5, 0x80f9f1c0, 0x04000013, 0x58f42a02, + 0x82142c80, 0x00000007, 0x82f80400, 0x00000003, + 0x40003000, 0x50182000, 0x40100000, 0x801c0580, + 0x04000005, 0x42001800, 0x00000001, 0x0401ff66, + 0x04020006, 0x82183400, 0x00000002, 0x80142840, + 0x040207f5, 0x1c01f000, 0x82000540, 0x00000001, + 0x0401f7fd, 0x0201f800, 0x001005d8, 0x58380207, + 0x8c000502, 0x040007fc, 0x50200000, 0x80387c00, + 0x583c2800, 0x583c2001, 0x58380404, 0x80001540, + 0x04020002, 0x58381407, 0x58c83401, 0x58380c08, + 0x59303807, 0x497a6012, 0x497a6013, 0x0201f000, + 0x000200be, 0x592c0408, 0x8c000502, 0x040007ea, + 0x592c0409, 0x80000540, 0x040007e7, 0x82000c80, + 0x00000002, 0x04001011, 0x58380001, 0x80007540, + 0x02000800, 0x001005d8, 0x58380204, 0x82000500, + 0x0000000f, 0x82000400, 0x001010bd, 0x50004000, + 0x40040000, 0x800409c0, 0x04000005, 0x82040c80, + 0x00000005, 0x040217f1, 0x80204400, 0x50200000, + 0x80387c00, 0x583c2800, 0x583c2001, 0x583c1002, + 0x592c0a07, 0x592c4c08, 0x592c300d, 0x59303807, + 0x497a6012, 0x497a6013, 0x4816600e, 0x4812600f, + 0x480a6010, 0x481a6011, 0x80040840, 0x4806600d, + 0x02000000, 0x000200c6, 0x80204000, 0x50201800, + 0x800c19c0, 0x0402000c, 0x58380001, 0x80007540, + 0x02000800, 0x001005d8, 0x58380204, 0x82000500, + 0x0000000f, 0x82000400, 0x001010bd, 0x50004000, + 0x50201800, 0x483a600b, 0x480e600a, 0x4822600c, + 0x0201f000, 0x000200c6, 0x4803c856, 0x592c0208, + 0x8c00051e, 0x04020017, 0x50200000, 0x80306c00, + 0x40240000, 0x0c01f001, 0x00100e46, 0x00100e46, + 0x00100e4f, 0x00100e46, 0x00100e46, 0x00100e46, + 0x00100e46, 0x00100e46, 0x00100e4f, 0x00100e46, + 0x00100e4f, 0x00100e46, 0x00100e46, 0x00100e4f, + 0x00100e46, 0x00100e46, 0x0201f800, 0x001005d8, + 0x8400051e, 0x48025a08, 0x50200000, 0x80306c00, + 0x58343801, 0x481e600f, 0x0401f007, 0x58341802, + 0x58342800, 0x58343801, 0x480e6010, 0x4816600e, + 0x481e600f, 0x0401f246, 0x4933c857, 0x5931f808, + 0x59300a06, 0x800409c0, 0x04000005, 0x80040906, + 0x04020002, 0x80040800, 0x4805fc06, 0x4a026206, + 0x00000002, 0x592c0409, 0x82000500, 0x00000008, + 0x0400000b, 0x0401f834, 0x59300203, 0x82000580, + 0x00000004, 0x04020005, 0x42027000, 0x00000048, + 0x0201f800, 0x000207a1, 0x1c01f000, 0x4cfc0000, + 0x58fc0204, 0x82000500, 0x000000ff, 0x82000580, + 0x00000048, 0x0402000c, 0x58fc000b, 0x800001c0, + 0x04000009, 0x58fc0407, 0x800001c0, 0x04000006, + 0x58fc080b, 0x8c040d16, 0x04000017, 0x58fc0007, + 0x0401f00a, 0x58fc0408, 0x8c000512, 0x04020014, + 0x58fc0c09, 0x8c040d16, 0x04020003, 0x5c01f800, + 0x1c01f000, 0x58fc000a, 0x59300811, 0x80040580, + 0x04020009, 0x59300007, 0x84000500, 0x48026007, + 0x42027000, 0x00000048, 0x5c01f800, 0x0201f000, + 0x000207a1, 0x5c01f800, 0x1c01f000, 0x58fdf809, + 0x0401f7ec, 0x4933c857, 0x59b808ea, 0x82040d00, + 0x00000007, 0x82040580, 0x00000000, 0x0400001e, + 0x82040580, 0x00000003, 0x0400001b, 0x59300406, + 0x4c000000, 0x4a026406, 0x00000000, 0x42003000, + 0x00000041, 0x42000000, 0x50000000, 0x41300800, + 0x4c180000, 0x0401fce7, 0x5c003000, 0x0400000b, + 0x42000000, 0x0000001e, 0x80000040, 0x040207ff, + 0x80183040, 0x040207f4, 0x42000000, 0x40000000, + 0x41300800, 0x0401fcdb, 0x5c000000, 0x48026406, + 0x1c01f000, 0x59300007, 0x84000500, 0x48026007, + 0x0401f7fc, 0x59c00007, 0x4a038006, 0x30000000, + 0x40000000, 0x59c00007, 0x8c00050a, 0x040207fe, + 0x1c01f000, 0x5c000000, 0x4c000000, 0x4803c857, + 0x4dc00000, 0x4a0370e8, 0x00000000, 0x42038000, + 0x00007720, 0x0401fff0, 0x42038000, 0x00007700, + 0x0401ffed, 0x0201f800, 0x0010513b, 0x04020013, + 0x4a038891, 0x0000ffff, 0x497b8880, 0x497b8892, + 0x42001000, 0x00000190, 0x40000000, 0x40000000, + 0x80081040, 0x040207fd, 0x42000000, 0x0010b8a6, + 0x0201f800, 0x0010aa47, 0x0401f80e, 0x5c038000, + 0x0201f000, 0x00105258, 0x0401f82d, 0x42000000, + 0x0010b8a7, 0x0201f800, 0x0010aa47, 0x0401f805, + 0x48178892, 0x480b8880, 0x5c038000, 0x1c01f000, + 0x496fc857, 0x836c0580, 0x00000003, 0x0402000b, + 0x4c080000, 0x4c0c0000, 0x42001000, 0x00008048, + 0x42001800, 0x0000ffff, 0x0201f800, 0x00103a3e, + 0x5c001800, 0x5c001000, 0x42000800, 0x0000003c, + 0x0201f800, 0x00101345, 0x59a8006c, 0x80000540, + 0x04000006, 0x59a8106d, 0x800811c0, 0x04000003, + 0x0201f800, 0x00101aaf, 0x4a038891, 0x0000ffff, + 0x4a03900d, 0x00000040, 0x0201f800, 0x0010098e, + 0x4a0370e8, 0x00000001, 0x1c01f000, 0x5c000000, + 0x4c000000, 0x4803c857, 0x59c41080, 0x497b8880, + 0x59c42892, 0x497b8892, 0x0201f800, 0x0010513b, + 0x04020002, 0x1c01f000, 0x42002000, 0x00000260, + 0x59c418a4, 0x820c1d00, 0x0000000f, 0x820c0580, + 0x00000000, 0x04000010, 0x59c41805, 0x820c1d00, + 0x00000001, 0x0402000e, 0x59c418a4, 0x820c1d00, + 0x0000000f, 0x820c0480, 0x00000007, 0x04001004, + 0x820c0480, 0x0000000c, 0x04001003, 0x80102040, + 0x040207ec, 0x497b8891, 0x1c01f000, 0x4c100000, + 0x42002000, 0x00000019, 0x46000000, 0x00000001, + 0x0201f800, 0x00101937, 0x50001800, 0x820c1d00, + 0x00000001, 0x04000005, 0x80102040, 0x040207f7, + 0x5c002000, 0x0401f7f0, 0x5c002000, 0x0401f7ec, + 0x4803c856, 0x1c01f000, 0x4d2c0000, 0x59325808, + 0x592c0a04, 0x4807c857, 0x82040d00, 0x000000ff, + 0x82040500, 0x0000000f, 0x0c01f001, 0x00100f67, + 0x00100f67, 0x00100f67, 0x00100f7f, 0x00100f67, + 0x00100f67, 0x00100f67, 0x00100f67, 0x00100f67, + 0x00100f7f, 0x00100f67, 0x00100f69, 0x00100f67, + 0x00100f67, 0x00100f67, 0x00100f67, 0x0201f800, + 0x001005d8, 0x82040580, 0x0000003b, 0x02020800, + 0x001005d8, 0x592c020a, 0x8c000500, 0x0400005f, + 0x592c1a07, 0x82040500, 0x0000000f, 0x82000400, + 0x001010bd, 0x50001000, 0x50080000, 0x59302013, + 0x4802600a, 0x492e600b, 0x480a600c, 0x480e600d, + 0x48126012, 0x5c025800, 0x1c01f000, 0x82040500, + 0x0000000f, 0x82000400, 0x001010bd, 0x50001000, + 0x50080000, 0x592c1a07, 0x4802600a, 0x492e600b, + 0x480a600c, 0x480e600d, 0x497a6012, 0x0401f7f2, + 0x8c040d00, 0x04020041, 0x82040d00, 0x00000080, + 0x0400003e, 0x0201f000, 0x000200cf, 0x59300013, + 0x59301012, 0x80080580, 0x0402000c, 0x42007800, + 0x80000005, 0x592c1208, 0x82080500, 0xffff7fff, + 0x48025a08, 0x8c08151e, 0x0402002d, 0x823c7d40, + 0x00000020, 0x0401f02a, 0x480bc857, 0x42000000, + 0x0010b851, 0x0201f800, 0x0010aa47, 0x59300414, + 0x4803c857, 0x8c000514, 0x04020007, 0x599c1819, + 0x8c0c1d12, 0x04020004, 0x820c1d40, 0x00000001, + 0x0401f01d, 0x59302013, 0x0401f92b, 0x0402001a, + 0x42007800, 0x80000005, 0x5930500d, 0x592c0208, + 0x4803c857, 0x8c00051e, 0x04020005, 0x823c7d40, + 0x00000020, 0x5930400c, 0x0401f004, 0x8400051e, + 0x48025a08, 0x0401f8da, 0x50201800, 0x480e600a, + 0x4832600b, 0x4822600c, 0x482a600d, 0x480fc857, + 0x4833c857, 0x4823c857, 0x482bc857, 0x80000580, + 0x483e6004, 0x1c01f000, 0x0201f800, 0x001005d8, + 0x4933c857, 0x4d2c0000, 0x59900004, 0x81300580, + 0x02020800, 0x001005d8, 0x0201f800, 0x00109037, + 0x02000800, 0x001005d8, 0x59325808, 0x4d3c0000, + 0x4d400000, 0x59300004, 0x4803c857, 0x4c000000, + 0x0201f800, 0x00106dc3, 0x0201f800, 0x00106b8a, + 0x5c000000, 0x8c000516, 0x04000010, 0x592c000f, + 0x4803c857, 0x48025807, 0x41780800, 0x42028000, + 0x00000002, 0x0201f800, 0x00104e70, 0x4a025c06, + 0x0000ffff, 0x0201f800, 0x000202da, 0x0201f800, + 0x00107911, 0x0401f015, 0x4a026203, 0x00000002, + 0x592c0208, 0x8400054e, 0x48025a08, 0x59300406, + 0x82000580, 0x00000006, 0x04020009, 0x811800ca, + 0x81c80c00, 0x58040939, 0x592c000d, 0x80040480, + 0x592c080f, 0x80040480, 0x4802580b, 0x417a7800, + 0x0201f800, 0x00108be3, 0x5c028000, 0x5c027800, + 0x5c025800, 0x1c01f000, 0x4933c857, 0x4d2c0000, + 0x59900004, 0x81300580, 0x02020800, 0x001005d8, + 0x0201f800, 0x00109037, 0x02000800, 0x001005d8, + 0x59325808, 0x592c0208, 0x84000540, 0x48025a08, + 0x0401f7bf, 0x491bc857, 0x49d3c857, 0x4dd00000, + 0x41780800, 0x8007a0ca, 0x83d3a400, 0x00007600, + 0x4a03a005, 0x80000002, 0x42000000, 0x00001000, + 0x50000000, 0x82000480, 0x24220001, 0x04020029, + 0x59d01006, 0x82080500, 0x00006000, 0x82000580, + 0x00006000, 0x0400002f, 0x82080500, 0x40008000, + 0x040007f8, 0x800409c0, 0x0402002a, 0x811a31c0, + 0x04000028, 0x42000000, 0x00001002, 0x50001000, + 0x46000000, 0x00000512, 0x42001800, 0x0000000a, + 0x59e00000, 0x8c00051a, 0x040207fc, 0x800c1840, + 0x040207fc, 0x42000000, 0x00001002, 0x46000000, + 0x00000514, 0x42001800, 0x0000000a, 0x59e00000, + 0x8c00053a, 0x040207fc, 0x800c1840, 0x040207fc, + 0x42000000, 0x00001002, 0x44080000, 0x0401f00d, + 0x59d01006, 0x82080500, 0x00006000, 0x82000580, + 0x00006000, 0x04000007, 0x8c08151e, 0x040007f9, + 0x59d01006, 0x82080500, 0x00006000, 0x040207f5, + 0x83d3a400, 0x00000020, 0x80040800, 0x82040480, + 0x00000005, 0x040017bf, 0x5c03a000, 0x1c01f000, + 0x491bc857, 0x49d3c857, 0x4dd00000, 0x41780800, + 0x8007a0ca, 0x83d3a400, 0x00007600, 0x4a03a005, + 0x80000001, 0x59d00006, 0x83d3a400, 0x00000020, + 0x80040800, 0x82040480, 0x00000005, 0x040017f8, + 0x5c03a000, 0x1c01f000, 0x59d00006, 0x8c00053e, + 0x0400001e, 0x59902804, 0x4817c857, 0x801429c0, + 0x04000013, 0x5990000a, 0x5990080b, 0x5990100c, + 0x5990180d, 0x4800280a, 0x4804280b, 0x4808280c, + 0x480c280d, 0x59d00000, 0x59d00801, 0x59d01002, + 0x59d01803, 0x59d02004, 0x4800280e, 0x4804280f, + 0x48082810, 0x480c2811, 0x48102812, 0x59900006, + 0x82000500, 0xffff0000, 0x48032006, 0x4a03a005, + 0x30000000, 0x59d00006, 0x1c01f000, 0x4803c856, + 0x80204000, 0x50200000, 0x80000540, 0x04000003, + 0x80285040, 0x1c01f000, 0x58300001, 0x80000540, + 0x0400000e, 0x4802600b, 0x40006000, 0x58300204, + 0x82000500, 0x0000000f, 0x82000400, 0x001010bd, + 0x50004000, 0x802041c0, 0x02000800, 0x001005d8, + 0x80285040, 0x1c01f000, 0x40005000, 0x1c01f000, + 0x00000005, 0x00000008, 0x0000000b, 0x0000000e, + 0x00000011, 0x00000000, 0x00000000, 0x0000000b, + 0x00000000, 0x00000000, 0x00000000, 0x001010b8, + 0x001010b7, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x001010b8, 0x001010b7, 0x001010b4, + 0x001010b8, 0x001010b7, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x001010b8, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x001010b8, 0x001010b8, 0x001010b8, + 0x00000000, 0x001010b8, 0x00000000, 0x00000000, + 0x00000000, 0x4813c857, 0x492fc857, 0x4933c857, + 0x48126012, 0x592c5207, 0x802851c0, 0x0400004a, + 0x412c6000, 0x0401f84b, 0x04000009, 0x82240580, + 0x00000002, 0x04020003, 0x5830000d, 0x80102480, + 0x50200000, 0x80004540, 0x0400003f, 0x50200000, + 0x80000540, 0x0400000b, 0x80301400, 0x58080002, + 0x80102480, 0x0400101e, 0x801021c0, 0x04000009, + 0x80285040, 0x04000034, 0x80204000, 0x0401f7f4, + 0x58300001, 0x80006540, 0x0400002f, 0x0401f7e6, + 0x80285040, 0x0400002c, 0x80204000, 0x50200000, + 0x80000540, 0x0402000a, 0x58300001, 0x80006540, + 0x04000025, 0x58300204, 0x82004d00, 0x0000000f, + 0x82244400, 0x001010bd, 0x50204000, 0x592c0208, + 0x8400051e, 0x48025a08, 0x0401f013, 0x80102080, + 0x80102000, 0x48126010, 0x4813c857, 0x58080802, + 0x40100000, 0x80042480, 0x02001800, 0x001005d8, + 0x58080000, 0x58081801, 0x80102400, 0x4812600e, + 0x480e600f, 0x4813c857, 0x592c0208, 0x8400055e, + 0x48025a08, 0x4833c857, 0x4823c857, 0x482bc857, + 0x4832600b, 0x4822600c, 0x482a600d, 0x80000580, + 0x0401f003, 0x82000540, 0x00000001, 0x1c01f000, + 0x58300204, 0x82004d00, 0x0000000f, 0x82244400, + 0x001010bd, 0x82000500, 0x000000ff, 0x82000580, + 0x00000029, 0x0402001b, 0x50204000, 0x592c0409, + 0x80000540, 0x02000800, 0x001005d8, 0x82000c80, + 0x00000002, 0x04001011, 0x58300001, 0x80006540, + 0x02000800, 0x001005d8, 0x58300204, 0x82000500, + 0x0000000f, 0x82000400, 0x001010bd, 0x50004000, + 0x40040000, 0x800409c0, 0x04000006, 0x82040c80, + 0x00000005, 0x040217f1, 0x80204400, 0x80000580, + 0x1c01f000, 0x59e00004, 0x8c00050e, 0x02020000, + 0x00100903, 0x1c01f000, 0x4c5c0000, 0x59e4b800, + 0x485fc857, 0x825c0500, 0x0000001f, 0x04000004, + 0x59e40862, 0x0201f800, 0x001005d8, 0x825c0500, + 0x000000e0, 0x02000800, 0x001005d8, 0x8c5cbd0e, + 0x04020807, 0x8c5cbd0c, 0x04020809, 0x8c5cbd0a, + 0x04020878, 0x5c00b800, 0x1c01f000, 0x4803c856, + 0x4a03c800, 0x00000080, 0x1c01f000, 0x4d2c0000, + 0x42007800, 0x0010b8ec, 0x583c0001, 0x583c0802, + 0x80040540, 0x0400003f, 0x42000800, 0x0010b7f7, + 0x50065800, 0x592c0002, 0x82000580, 0x00000000, + 0x0400000e, 0x59e40850, 0x59e41853, 0x400c0000, + 0x80040400, 0x59e40852, 0x4807c857, 0x80041480, + 0x04021008, 0x40001000, 0x480bc857, 0x4a007800, + 0x00000001, 0x0401f006, 0x4803c857, 0x0401f029, + 0x59e41050, 0x480bc857, 0x49787800, 0x480bc857, + 0x480fc857, 0x592c0003, 0x80000540, 0x04000006, + 0x80080580, 0x04020004, 0x592c0003, 0x4803c857, + 0x480bc857, 0x480a5803, 0x592c0007, 0x800001c0, + 0x04000007, 0x592c1007, 0x480bc857, 0x583c0003, + 0x4803c857, 0x80080480, 0x04001003, 0x583c1001, + 0x480bc857, 0x583c0802, 0x480bc857, 0x4807c857, + 0x4a025801, 0x00000000, 0x4a025809, 0x001011bc, + 0x480a5807, 0x48065808, 0x59e40053, 0x48025804, + 0x412c1000, 0x492fc857, 0x0201f800, 0x00100858, + 0x5c025800, 0x4a03c800, 0x00000040, 0x1c01f000, + 0x42007800, 0x0010b7f7, 0x503c7800, 0x4a007802, + 0x00000100, 0x42007800, 0x0010b8ec, 0x583c0000, + 0x4803c857, 0x82000d80, 0x00000001, 0x04000004, + 0x80000000, 0x48007800, 0x0401f019, 0x49787800, + 0x583c1806, 0x583c0005, 0x800c1800, 0x480c7806, + 0x800c0580, 0x04020002, 0x49787806, 0x583c0807, + 0x800409c0, 0x0400000e, 0x583c0008, 0x80000000, + 0x48007808, 0x80040580, 0x04020009, 0x49787808, + 0x583c2006, 0x42001800, 0x00000001, 0x42001000, + 0x00008028, 0x0201f800, 0x00103a3e, 0x1c01f000, + 0x4a03c800, 0x00000020, 0x0201f800, 0x0010aa40, + 0x59e40000, 0x1c01f000, 0x4d2c0000, 0x4a007001, + 0x00000000, 0x82040d00, 0x43000f80, 0x02020800, + 0x001005d8, 0x58380009, 0x4803c00f, 0x0201f800, + 0x00109402, 0x583a5808, 0x592c0000, 0x48007008, + 0x800001c0, 0x04020002, 0x49787007, 0x0201f800, + 0x001007f4, 0x5c025800, 0x0201f000, 0x0010087d, + 0x4803c856, 0x4c3c0000, 0x4d2c0000, 0x4d300000, + 0x5830000a, 0x80025d40, 0x02000800, 0x001005d8, + 0x592e6008, 0x4c300000, 0x0201f800, 0x0010941a, + 0x5c006000, 0x02000800, 0x001005d8, 0x58300002, + 0x82000580, 0x00000100, 0x04020010, 0x5930780b, + 0x583c0001, 0x80000540, 0x0400000e, 0x4802600b, + 0x40007800, 0x82000400, 0x00000002, 0x48006003, + 0x583c0000, 0x48006004, 0x40301000, 0x0201f800, + 0x00100858, 0x0401f00c, 0x4a025a06, 0x00000002, + 0x4c300000, 0x0201f800, 0x000202da, 0x5c006000, + 0x40325800, 0x0201f800, 0x001007f4, 0x0201f800, + 0x0002077d, 0x5c026000, 0x5c025800, 0x5c007800, + 0x1c01f000, 0x4803c856, 0x4d2c0000, 0x4d300000, + 0x42007000, 0x0010b7f8, 0x58380801, 0x82040580, + 0x00000002, 0x04020011, 0x58386002, 0x5830000a, + 0x812c0580, 0x0402000d, 0x59e00004, 0x8c00050e, + 0x040007fe, 0x59dc0006, 0x4803c857, 0x4a03b805, + 0x20000000, 0x8c00053e, 0x040007f8, 0x4a007001, + 0x00000000, 0x0401f019, 0x58386006, 0x40305000, + 0x803061c0, 0x02000800, 0x001005d8, 0x5830000a, + 0x812c0580, 0x04000004, 0x40305000, 0x58306000, + 0x0401f7f8, 0x40280000, 0x80300580, 0x58300000, + 0x04000006, 0x48005000, 0x800001c0, 0x04020007, + 0x48287005, 0x0401f005, 0x800001c0, 0x04020002, + 0x48007005, 0x48007006, 0x40325800, 0x0201f800, + 0x001007f4, 0x42007000, 0x0010b7f8, 0x58380001, + 0x82000580, 0x00000000, 0x02000800, 0x0010087d, + 0x5c026000, 0x5c025800, 0x1c01f000, 0x4803c856, + 0x42000800, 0x0000003c, 0x48079000, 0x59c80000, + 0x80040500, 0x040207fe, 0x497b9005, 0x4a039035, + 0x00880200, 0x59a8000e, 0x800000e0, 0x4803900e, + 0x4a039011, 0x00000024, 0x4a03900f, 0x0010d1c0, + 0x4a039010, 0x0010d1c0, 0x4a039015, 0x0000007f, + 0x4a03900d, 0x00000040, 0x4a039000, 0x00001600, + 0x1c01f000, 0x59c80007, 0x8c000508, 0x040208b7, + 0x59c80800, 0x8c040d16, 0x04020004, 0x82000500, + 0x00000006, 0x0c01f005, 0x4807c857, 0x82000500, + 0x0000000e, 0x0c01f001, 0x001012a8, 0x001012a6, + 0x00105999, 0x001012a6, 0x001012aa, 0x001012a6, + 0x001012aa, 0x001012aa, 0x001012a6, 0x001012a6, + 0x001012a6, 0x001012a6, 0x001012aa, 0x001012a6, + 0x001012aa, 0x001012a6, 0x0201f800, 0x001005d8, + 0x4803c857, 0x1c01f000, 0x59c8080c, 0x4807c857, + 0x82040500, 0x00006000, 0x04000004, 0x0201f800, + 0x0010aa03, 0x0401f006, 0x82040500, 0x007f0000, + 0x04000006, 0x0201f800, 0x0010a9d5, 0x0201f800, + 0x00106eb3, 0x0401f02b, 0x82040500, 0x00000014, + 0x04000014, 0x0201f800, 0x0010aa32, 0x836c0580, + 0x00000003, 0x0400000d, 0x0201f800, 0x0010513b, + 0x04000004, 0x0201f800, 0x0010411d, 0x0401f007, + 0x4a035033, 0x00000001, 0x4202d800, 0x00000001, + 0x0201f800, 0x001050a2, 0x0401f817, 0x0401f015, + 0x82040500, 0x00001c00, 0x04000005, 0x0201f800, + 0x0010aa11, 0x0401f810, 0x0401f00e, 0x82040500, + 0x00000140, 0x04000005, 0x0201f800, 0x0010aa24, + 0x0401f809, 0x0401f007, 0x82040500, 0x00008000, + 0x04000004, 0x0201f800, 0x0010a9fc, 0x0401f802, + 0x1c01f000, 0x4c0c0000, 0x4c100000, 0x4c140000, + 0x0201f800, 0x00100ec9, 0x5c002800, 0x5c002000, + 0x5c001800, 0x1c01f000, 0x4803c856, 0x59a80804, + 0x59a8002b, 0x82000500, 0xfffff000, 0x80040540, + 0x4803502b, 0x59a8002f, 0x82000500, 0xfffff000, + 0x80040540, 0x4803502f, 0x48078882, 0x82041c00, + 0x0000000f, 0x800c1908, 0x820c1c00, 0x00000004, + 0x400c2000, 0x901029c0, 0x82040480, 0x000001e4, + 0x04021005, 0x42001000, 0x00000008, 0x801020c6, + 0x0401f031, 0x82040480, 0x00000230, 0x04021009, + 0x42001000, 0x00000007, 0x801000c2, 0x800000c2, + 0x80100400, 0x80100400, 0x80102400, 0x0401f026, + 0x82040480, 0x00000298, 0x04021008, 0x42001000, + 0x00000006, 0x801000c2, 0x800000c2, 0x80100400, + 0x80102400, 0x0401f01c, 0x82040480, 0x00000328, + 0x04021007, 0x42001000, 0x00000005, 0x801000c2, + 0x800000c2, 0x80102400, 0x0401f013, 0x82040480, + 0x00000404, 0x04021005, 0x42001000, 0x00000004, + 0x801020c4, 0x0401f00c, 0x82040480, 0x0000056c, + 0x04021006, 0x42001000, 0x00000003, 0x801000c2, + 0x80102400, 0x0401f004, 0x42001000, 0x00000002, + 0x801020c2, 0x82100480, 0x00000110, 0x80000080, + 0x80002000, 0x800800d0, 0x80140540, 0x80100540, + 0x48039035, 0x1c01f000, 0x59c80815, 0x0201f800, + 0x001005d0, 0x82040d00, 0x0000007c, 0x48079000, + 0x59c80000, 0x80040500, 0x040207fe, 0x8c040d04, + 0x04000003, 0x59c80035, 0x48039035, 0x59c80000, + 0x82000540, 0x00001200, 0x48039000, 0x1c01f000, + 0x4803c856, 0x497b88a9, 0x4a038807, 0x00000001, + 0x497b8807, 0x59c40005, 0x48038805, 0x0201f800, + 0x00101815, 0x4201d000, 0x000001f4, 0x0201f800, + 0x0010608e, 0x497b880e, 0x4200b000, 0x000001f4, + 0x42000000, 0x00000001, 0x42000800, 0x00000014, + 0x0201f800, 0x00101944, 0x42000800, 0x00000014, + 0x0201f800, 0x0010193f, 0x8c040d00, 0x04000005, + 0x8058b040, 0x040207f3, 0x0201f800, 0x001005d8, + 0x4200b000, 0x00000032, 0x42000000, 0x00000001, + 0x42000800, 0x000000b4, 0x0201f800, 0x00101944, + 0x42000800, 0x000000b4, 0x0201f800, 0x0010193f, + 0x8c040d00, 0x04000005, 0x8058b040, 0x040207f3, + 0x0201f800, 0x001005d8, 0x59c40005, 0x48038805, + 0x42000000, 0x00000089, 0x800008d0, 0x48075054, + 0x48075055, 0x48075056, 0x42000800, 0x000000e0, + 0x0201f800, 0x00101944, 0x42000800, 0x000000f4, + 0x0201f800, 0x0010193f, 0x82040500, 0xffffffd1, + 0x82000540, 0x00000002, 0x42000800, 0x000000f4, + 0x0201f800, 0x00101944, 0x42000800, 0x000000a0, + 0x0201f800, 0x0010193f, 0x82040540, 0x00000001, + 0x42000800, 0x000000a0, 0x0201f800, 0x00101944, + 0x42000800, 0x00000000, 0x0201f800, 0x0010193f, + 0x82040540, 0x00000001, 0x42000800, 0x00000000, + 0x0201f800, 0x00101944, 0x4201d000, 0x0001d4c0, + 0x0201f800, 0x0010608e, 0x0401fa2b, 0x4a0388a7, + 0x0000f7f7, 0x4a0388a3, 0x8000403c, 0x4a0388ae, + 0x000061a8, 0x4a038801, 0x00032063, 0x4a038810, + 0x00410108, 0x4a038811, 0x00520608, 0x4a038812, + 0x00450320, 0x4a038813, 0x00440405, 0x4a03881c, + 0x004132e1, 0x4a038850, 0x80000108, 0x4a038860, + 0x00000008, 0x4a038870, 0x00000008, 0x4a038851, + 0x80000508, 0x4a038861, 0x00800000, 0x4a038871, + 0x00800000, 0x4a038852, 0x80000708, 0x4a038862, + 0x00800000, 0x4a038872, 0x00800000, 0x4a038853, + 0x80000608, 0x497b8863, 0x4a038873, 0x00800000, + 0x4a038882, 0x00000840, 0x4a0388a5, 0x0000001e, + 0x4a0388a6, 0x0000001e, 0x4a0388b0, 0x00007530, + 0x4a038802, 0x0000ffff, 0x4a038806, 0xc0e00800, + 0x1c01f000, 0x497b5022, 0x4a035021, 0x00000001, + 0x42000800, 0x00000040, 0x0201f800, 0x0010193f, + 0x82040500, 0xffffffaf, 0x82000540, 0x00000000, + 0x42000800, 0x00000040, 0x0201f800, 0x00101944, + 0x42000800, 0x000000f4, 0x0201f800, 0x0010193f, + 0x4c040000, 0x40040000, 0x84000548, 0x42000800, + 0x000000f4, 0x0201f800, 0x00101944, 0x42000800, + 0x00000000, 0x0201f800, 0x0010193f, 0x82040500, + 0xffffffc1, 0x82000540, 0x00000038, 0x42000800, + 0x00000000, 0x0201f800, 0x00101944, 0x5c000000, + 0x42000800, 0x000000f4, 0x0201f000, 0x00101944, + 0x59c40805, 0x4807c857, 0x59c40006, 0x80040d00, + 0x02000800, 0x001005d8, 0x82040500, 0x00e00800, + 0x04020004, 0x8c040d3e, 0x040208c4, 0x0401f007, + 0x82040500, 0x00800800, 0x02020800, 0x001005d0, + 0x0201f800, 0x001005d8, 0x4c5c0000, 0x4c600000, + 0x59c4b805, 0x485fc857, 0x59c40006, 0x8c000500, + 0x04000003, 0x8c5cbd00, 0x04020079, 0x0201f800, + 0x0010513b, 0x04000014, 0x59c40005, 0x82000500, + 0x000000c0, 0x04000036, 0x0201f800, 0x00105151, + 0x04020033, 0x4a038805, 0x04000000, 0x59c400a3, + 0x82000500, 0xbf203fff, 0x480388a3, 0x497b5049, + 0x4a038805, 0x000000c0, 0x0201f800, 0x00105065, + 0x0401f063, 0x8c5cbd34, 0x04020025, 0x59c40005, + 0x8c00050c, 0x04020012, 0x8c00050e, 0x04020013, + 0x8c00050a, 0x04020014, 0x8c000508, 0x0400000b, + 0x59a80017, 0x82000580, 0x00000009, 0x04020007, + 0x42000000, 0x0010b844, 0x0201f800, 0x0010aa47, + 0x0201f800, 0x00105318, 0x0401f04b, 0x4a035033, + 0x00000000, 0x0401f00b, 0x4a035033, 0x00000002, + 0x0401f008, 0x42000000, 0x0010b846, 0x0201f800, + 0x0010aa47, 0x0201f800, 0x001052c2, 0x0401f03e, + 0x0201f800, 0x00105378, 0x0401f03b, 0x8c5cbd34, + 0x04000037, 0x59c40005, 0x8c00053a, 0x04020005, + 0x42000000, 0x0010b818, 0x0201f800, 0x0010aa47, + 0x4a038805, 0x02000000, 0x0201f800, 0x0010513b, + 0x04020010, 0x4a038805, 0x04000000, 0x0201f800, + 0x00105149, 0x04020008, 0x4a035033, 0x00000001, + 0x4202d800, 0x00000001, 0x0201f800, 0x001050a2, + 0x0401f05b, 0x41780000, 0x0201f800, 0x00105113, + 0x0201f800, 0x001019fe, 0x4000c000, 0x0201f800, + 0x00101963, 0x836c1580, 0x00000004, 0x0402000d, + 0x8c5cbd00, 0x04020012, 0x59a81005, 0x8c081506, + 0x04020005, 0x59c410a3, 0x82081540, 0x00000008, + 0x480b88a3, 0x59c41006, 0x84081540, 0x480b8806, + 0x4a038805, 0x04000000, 0x4202d800, 0x00000001, + 0x497b5014, 0x0201f800, 0x00103b38, 0x8c5cbd3c, + 0x04020858, 0x8c5cbd00, 0x04000036, 0x42000000, + 0x0010b8ca, 0x0201f800, 0x0010aa47, 0x4a038805, + 0x00000001, 0x4200b000, 0x000003e8, 0x4201d000, + 0x00000064, 0x4c580000, 0x0201f800, 0x0010608e, + 0x0201f800, 0x001018d3, 0x5c00b000, 0x04000004, + 0x8058b040, 0x040207f6, 0x0401f004, 0x4a038805, + 0x00000001, 0x0401f01f, 0x59c40006, 0x84000500, + 0x48038806, 0x0201f800, 0x00106ede, 0x497b8880, + 0x0201f800, 0x0010a9c0, 0x59c4000d, 0x8c000500, + 0x02020800, 0x0010a9ce, 0x59c400a3, 0x82000500, + 0xfcf8ffff, 0x480388a3, 0x4a03504c, 0x00000002, + 0x4202d800, 0x00000004, 0x4a038805, 0x00000001, + 0x0201f800, 0x001006d4, 0x0401fb3b, 0x497b5052, + 0x4a035049, 0x00000001, 0x0201f800, 0x00100452, + 0x825cbd00, 0xbbfffffe, 0x485f8805, 0x5c00c000, + 0x5c00b800, 0x1c01f000, 0x59c41004, 0x480bc857, + 0x8c081500, 0x04000006, 0x4803c856, 0x497b2807, + 0x0201f800, 0x00106fa4, 0x0401f00a, 0x82080500, + 0x000001f0, 0x04000007, 0x4803c856, 0x417a3000, + 0x0201f800, 0x00106062, 0x0201f800, 0x00106fc6, + 0x4a038805, 0x80000000, 0x1c01f000, 0x59c408a3, + 0x4807c857, 0x84040d40, 0x480788a3, 0x1c01f000, + 0x4d900000, 0x4dd00000, 0x4da40000, 0x4d140000, + 0x4a038805, 0x40000000, 0x42000000, 0x0010b8c6, + 0x0201f800, 0x0010aa47, 0x0201f800, 0x00106c55, + 0x59c41004, 0x8c081500, 0x04000054, 0x598e600d, + 0x497b2807, 0x813261c0, 0x04000032, 0x59300403, + 0x82000580, 0x00000032, 0x0402002e, 0x5930001c, + 0x48038833, 0x4a038807, 0x00018000, 0x4201d000, + 0x00000002, 0x0201f800, 0x0010608e, 0x497b8807, + 0x4201d000, 0x00000002, 0x0201f800, 0x0010608e, + 0x0201f800, 0x00106e21, 0x4201d000, 0x00007530, + 0x0201f800, 0x0010608e, 0x59c408a4, 0x82040d00, + 0x0000000f, 0x82040d80, 0x00000000, 0x04000005, + 0x42000000, 0x00200000, 0x0201f800, 0x00101949, + 0x0201f800, 0x00106bbf, 0x59300008, 0x80000540, + 0x02000800, 0x001005d8, 0x40025800, 0x4a025a04, + 0x00000103, 0x5931d821, 0x58ef400b, 0x58ec0009, + 0x0801f800, 0x0201f800, 0x0002077d, 0x0401f047, + 0x598c000f, 0x82001c80, 0x000000c8, 0x0402100f, + 0x80000000, 0x4803180f, 0x59c400a4, 0x82000500, + 0x0000000f, 0x82000580, 0x00000002, 0x04020004, + 0x42000000, 0x00200000, 0x0401fbf7, 0x0201f800, + 0x0010604d, 0x0401f035, 0x4933c857, 0x0201f800, + 0x00106e21, 0x813261c0, 0x04000030, 0x4a026203, + 0x00000001, 0x42027000, 0x00000027, 0x0201f800, + 0x000207a1, 0x0401f029, 0x8c081508, 0x04000027, + 0x417a3000, 0x0201f800, 0x001070d8, 0x42032000, + 0x0000bf32, 0x0201f800, 0x00106062, 0x59926004, + 0x813261c0, 0x04000012, 0x42001800, 0x000000c8, + 0x0201f800, 0x001070a4, 0x0402000d, 0x59c400a4, + 0x82000500, 0x0000000f, 0x82000580, 0x00000002, + 0x04020004, 0x42000000, 0x00200000, 0x0401fbce, + 0x0201f800, 0x00106052, 0x0401f00c, 0x4933c857, + 0x0201f800, 0x00106dc3, 0x813261c0, 0x04000007, + 0x42027000, 0x0000004f, 0x4a026203, 0x00000003, + 0x0201f800, 0x000207a1, 0x5c022800, 0x5c034800, + 0x5c03a000, 0x5c032000, 0x0201f000, 0x00106c4b, + 0x4803c857, 0x59a80821, 0x48035021, 0x80041580, + 0x04000045, 0x800409c0, 0x04000023, 0x497b504c, + 0x42000000, 0x0010b80d, 0x0201f800, 0x0010aa47, + 0x0201f800, 0x0010aaf9, 0x42001000, 0x00008011, + 0x59c40001, 0x82000500, 0x00018000, 0x82001d80, + 0x00000000, 0x04000009, 0x82001d80, 0x00008000, + 0x04000009, 0x82001d80, 0x00010000, 0x04000009, + 0x0201f800, 0x001005d8, 0x42001800, 0x00000000, + 0x0401f006, 0x42001800, 0x00000001, 0x0401f003, + 0x42001800, 0x00000003, 0x0201f800, 0x00103a3e, + 0x0401f021, 0x59a8084c, 0x800409c0, 0x04020007, + 0x59c4000d, 0x8c000520, 0x04000004, 0x42001800, + 0x00000003, 0x0401f002, 0x40041800, 0x0201f800, + 0x0010aadd, 0x42001000, 0x00008012, 0x0201f800, + 0x00103a3e, 0x0201f800, 0x001006d4, 0x0201f800, + 0x0010ab33, 0x0402000c, 0x0401f853, 0x4d400000, + 0x4d3c0000, 0x42028000, 0x00000028, 0x42027800, + 0x00000408, 0x0201f800, 0x00101fe5, 0x5c027800, + 0x5c028000, 0x1c01f000, 0x4803c857, 0x82000400, + 0x0010210e, 0x50000800, 0x82040d00, 0x000000ff, + 0x1c01f000, 0x4803c856, 0x4c580000, 0x4200b000, + 0x00000010, 0x497b88ac, 0x497b88ad, 0x8058b040, + 0x040207fe, 0x5c00b000, 0x1c01f000, 0x4807c857, + 0x48075010, 0x80041108, 0x4200b000, 0x00000010, + 0x497b88ac, 0x80000580, 0x800811c0, 0x04020006, + 0x82040500, 0x0000000f, 0x82000400, 0x0010ab38, + 0x50000000, 0x480388ad, 0x80081040, 0x8058b040, + 0x040207f5, 0x1c01f000, 0x59a80005, 0x04000003, + 0x84000546, 0x0401f002, 0x84000506, 0x48035005, + 0x4803c857, 0x1c01f000, 0x4803c857, 0x4c080000, + 0x4c040000, 0x4c000000, 0x59c40892, 0x4807c857, + 0x80041580, 0x04000010, 0x80041480, 0x04021007, + 0x80081080, 0x80081000, 0x4008b000, 0x42000000, + 0x00000201, 0x0401f004, 0x4008b000, 0x42000000, + 0x00000210, 0x48038886, 0x8058b040, 0x040207fe, + 0x497b8886, 0x5c000000, 0x5c000800, 0x5c001000, + 0x1c01f000, 0x4803c856, 0x0201f800, 0x00103b25, + 0x04000005, 0x42028000, 0x0000002e, 0x0201f000, + 0x0010a449, 0x1c01f000, 0x42000800, 0x00000002, + 0x59a80005, 0x8c000514, 0x0402000b, 0x59c80835, + 0x82040d00, 0x00001f00, 0x80040910, 0x80040800, + 0x59a8006c, 0x80000540, 0x04000003, 0x42000800, + 0x0000025a, 0x4807c857, 0x1c01f000, 0x4c000000, + 0x59a80053, 0x4803c857, 0x82000580, 0x00000000, + 0x5c000000, 0x1c01f000, 0x4c000000, 0x59a80053, + 0x4803c857, 0x82000580, 0x00000001, 0x5c000000, + 0x1c01f000, 0x4c000000, 0x59a80053, 0x4803c857, + 0x82000580, 0x00000003, 0x5c000000, 0x1c01f000, + 0x4c000000, 0x59a80053, 0x82000580, 0x00000002, + 0x5c000000, 0x1c01f000, 0x4c000000, 0x4c040000, + 0x4c080000, 0x4c380000, 0x59a80040, 0x82000c80, + 0x00000007, 0x02021800, 0x001005d8, 0x0c01f806, + 0x5c007000, 0x5c001000, 0x5c000800, 0x5c000000, + 0x1c01f000, 0x0010166c, 0x0010167f, 0x00101693, + 0x00101695, 0x001016bc, 0x001016be, 0x001016c0, + 0x4803c856, 0x4a035042, 0x00000000, 0x42000000, + 0x00000002, 0x0401fa1b, 0x42000000, 0x00000002, + 0x0401f9ad, 0x0401fab2, 0x4803c856, 0x4a035040, + 0x00000006, 0x42000800, 0x0000001e, 0x42001000, + 0x001016c1, 0x0201f000, 0x0010606e, 0x497b5045, + 0x4a035050, 0x00000036, 0x4a03504f, 0x0000002a, + 0x4803c856, 0x4a035042, 0x00000001, 0x42000000, + 0x00000002, 0x0401f998, 0x4803c856, 0x4a035040, + 0x00000006, 0x42000800, 0x0000001e, 0x42001000, + 0x001016c1, 0x0201f000, 0x0010606e, 0x0201f800, + 0x001005d8, 0x4a035050, 0x00000036, 0x4803c856, + 0x4a035042, 0x00000003, 0x42000800, 0x00000000, + 0x0401faa3, 0x82040d00, 0x00000090, 0x82040580, + 0x00000090, 0x04000009, 0x82040580, 0x00000010, + 0x04000009, 0x82040580, 0x00000000, 0x04000008, + 0x0201f800, 0x001005d8, 0x42000000, 0x00000001, + 0x0401f005, 0x41780000, 0x0401f003, 0x42000000, + 0x00000002, 0x0401f970, 0x497b5046, 0x4803c856, + 0x4a035040, 0x00000006, 0x42000800, 0x0000001e, + 0x42001000, 0x001016c1, 0x0201f000, 0x0010606e, + 0x0201f800, 0x001005d8, 0x0201f800, 0x001005d8, + 0x1c01f000, 0x4c000000, 0x4c040000, 0x4c080000, + 0x4c380000, 0x59a80042, 0x82000c80, 0x00000007, + 0x02021800, 0x001005d8, 0x0c01f806, 0x5c007000, + 0x5c001000, 0x5c000800, 0x5c000000, 0x1c01f000, + 0x001016d7, 0x001016f6, 0x0010174a, 0x00101761, + 0x00101778, 0x00101781, 0x00101783, 0x0401f9fc, + 0x0402001b, 0x59a81048, 0x42000800, 0x00000000, + 0x0401fa63, 0x82040d00, 0x00000090, 0x82040580, + 0x00000090, 0x04000009, 0x82040580, 0x00000010, + 0x04000008, 0x82040580, 0x00000000, 0x04000007, + 0x0201f800, 0x001005d8, 0x84081540, 0x0401f004, + 0x84081542, 0x0401f002, 0x84081544, 0x480b5048, + 0x4a035040, 0x00000001, 0x0401f003, 0x0401f8cb, + 0x0401ff82, 0x1c01f000, 0x0401f88f, 0x04000052, + 0x0401f9db, 0x0402002a, 0x42000800, 0x00000000, + 0x0401fa43, 0x82040d00, 0x00000090, 0x82040580, + 0x00000000, 0x04000044, 0x82040580, 0x00000010, + 0x04000006, 0x82040580, 0x00000090, 0x04000009, + 0x0201f800, 0x001005d8, 0x59c40801, 0x82040d00, + 0x00018000, 0x82040580, 0x00000000, 0x04000036, + 0x42000800, 0x00000000, 0x0401fa2d, 0x82040d00, + 0x00000090, 0x82040580, 0x00000010, 0x04000006, + 0x82040580, 0x00000090, 0x04000006, 0x02020800, + 0x001005d8, 0x59a80048, 0x84000542, 0x0401f003, + 0x59a80048, 0x84000540, 0x48035048, 0x59a80045, + 0x80000000, 0x48035045, 0x82000580, 0x00000005, + 0x04000003, 0x0401f861, 0x0401f01e, 0x497b5045, + 0x59c40801, 0x82040d00, 0x00018000, 0x82040580, + 0x00000000, 0x04000009, 0x82040580, 0x00008000, + 0x04000009, 0x82040580, 0x00010000, 0x04000008, + 0x0201f800, 0x001005d8, 0x42000000, 0x00000001, + 0x0401f005, 0x41780000, 0x0401f003, 0x42000000, + 0x00000002, 0x0401f94b, 0x4a035042, 0x00000002, + 0x0401f004, 0x4a035040, 0x00000003, 0x0401f002, + 0x0401ff42, 0x1c01f000, 0x0401f83b, 0x04000015, + 0x59a8004f, 0x80000040, 0x4803504f, 0x0401f984, + 0x04020005, 0x4a035040, 0x00000003, 0x497b5041, + 0x0401f00c, 0x59a8004f, 0x80000540, 0x04020003, + 0x0401f89e, 0x0401f002, 0x0401f84b, 0x0401f82f, + 0x497b5045, 0x4a035042, 0x00000001, 0x0401ff2b, + 0x1c01f000, 0x0401f824, 0x04000015, 0x0401f970, + 0x0402000f, 0x59a80046, 0x80000000, 0x48035046, + 0x82000580, 0x00000007, 0x0402000c, 0x4a035052, + 0x0000000a, 0x497b5049, 0x59a80048, 0x8400055e, + 0x48035048, 0x4803c857, 0x0401f005, 0x0401f817, + 0x4a035042, 0x00000004, 0x0401ff3d, 0x1c01f000, + 0x0401f80d, 0x04000007, 0x0401f959, 0x04020003, + 0x0401ff1b, 0x0401f003, 0x0401f80c, 0x0401ff34, + 0x1c01f000, 0x0201f800, 0x001005d8, 0x0201f800, + 0x001005d8, 0x59a80050, 0x80000040, 0x48035050, + 0x0400088d, 0x1c01f000, 0x4c040000, 0x42000800, + 0x00000000, 0x0401f9b2, 0x82040d00, 0x00000090, + 0x82040580, 0x00000090, 0x04000009, 0x82040580, + 0x00000010, 0x04000009, 0x82040580, 0x00000000, + 0x04000009, 0x0201f800, 0x001005d8, 0x42000000, + 0x00000002, 0x0401f005, 0x42000000, 0x00000001, + 0x0401f002, 0x41780000, 0x0401f8ea, 0x5c000800, + 0x1c01f000, 0x4c040000, 0x59c40801, 0x82040d00, + 0x00018000, 0x82040580, 0x00000000, 0x04000009, + 0x82040580, 0x00008000, 0x04000009, 0x82040580, + 0x00010000, 0x04000009, 0x0201f800, 0x001005d8, + 0x42000000, 0x00000002, 0x0401f005, 0x42000000, + 0x00000001, 0x0401f002, 0x41780000, 0x0401f866, + 0x5c000800, 0x1c01f000, 0x4c040000, 0x59a80045, + 0x80000000, 0x48035045, 0x82000580, 0x00000005, + 0x04020018, 0x497b5045, 0x59c40801, 0x82040d00, + 0x00018000, 0x82040580, 0x00000000, 0x04000009, + 0x82040580, 0x00008000, 0x04000009, 0x82040580, + 0x00010000, 0x04000009, 0x0201f800, 0x001005d8, + 0x42000000, 0x00000002, 0x0401f005, 0x42000000, + 0x00000001, 0x0401f002, 0x41780000, 0x0401f846, + 0x42000800, 0x00000000, 0x0401f961, 0x82040d00, + 0x00000090, 0x82040580, 0x00000090, 0x04000009, + 0x82040580, 0x00000010, 0x04000009, 0x82040580, + 0x00000000, 0x04000009, 0x0201f800, 0x001005d8, + 0x42000000, 0x00000002, 0x0401f005, 0x42000000, + 0x00000001, 0x0401f002, 0x41780000, 0x0401f899, + 0x5c000800, 0x1c01f000, 0x4c200000, 0x59a80048, + 0x82000500, 0x00007fff, 0x02000800, 0x001005d8, + 0x59a84047, 0x80204102, 0x02001800, 0x001005d8, + 0x48235047, 0x80204500, 0x040007fa, 0x8c000504, + 0x04020007, 0x8c000502, 0x04020008, 0x8c000500, + 0x04020008, 0x0201f800, 0x001005d8, 0x42000000, + 0x00000002, 0x0401f005, 0x41780000, 0x0401f003, + 0x42000000, 0x00000001, 0x0401f80f, 0x5c004000, + 0x1c01f000, 0x04011000, 0x4a03c840, 0x0010b440, + 0x4a03c842, 0x00000009, 0x40000000, 0x040117ff, + 0x4a035047, 0x00000004, 0x4a03503e, 0x00000000, + 0x1c01f000, 0x59a80858, 0x82040d80, 0x01391077, + 0x04020008, 0x59e00813, 0x8c040d00, 0x04000005, + 0x82000d80, 0x00000002, 0x04020002, 0x41780000, + 0x4c000000, 0x0401f9b1, 0x5c000000, 0x800001c0, + 0x04000040, 0x82000d80, 0x00000001, 0x0402001d, + 0x42000800, 0x000000a0, 0x0401f909, 0x82040540, + 0x00000004, 0x42000800, 0x000000a0, 0x0401f909, + 0x42000800, 0x000000c0, 0x0401f901, 0x82040540, + 0x00000020, 0x42000800, 0x000000c0, 0x0401f901, + 0x59c40001, 0x82000500, 0xfffe7fff, 0x82000540, + 0x00000000, 0x48038801, 0x59a80054, 0x80000110, + 0x42000800, 0x000000e0, 0x0401f8f6, 0x0401f03c, + 0x82000d80, 0x00000002, 0x02020800, 0x001005d8, + 0x42000800, 0x000000a0, 0x0401f8e9, 0x82040500, + 0xfffffffb, 0x42000800, 0x000000a0, 0x0401f8e9, + 0x42000800, 0x000000c0, 0x0401f8e1, 0x82040500, + 0xffffffdf, 0x42000800, 0x000000c0, 0x0401f8e1, + 0x59c40001, 0x82000500, 0xfffe7fff, 0x82000540, + 0x00010000, 0x48038801, 0x59a80056, 0x80000110, + 0x42000800, 0x000000e0, 0x0401f8d6, 0x0401f01c, + 0x42000800, 0x000000a0, 0x0401f8cd, 0x82040540, + 0x00000004, 0x42000800, 0x000000a0, 0x0401f8cd, + 0x42000800, 0x000000c0, 0x0401f8c5, 0x82040500, + 0xffffffdf, 0x42000800, 0x000000c0, 0x0401f8c5, + 0x59c40001, 0x82000500, 0xfffe7fff, 0x82000540, + 0x00008000, 0x48038801, 0x59a80055, 0x80000110, + 0x42000800, 0x000000e0, 0x0401f8ba, 0x0401f163, + 0x4803c857, 0x59a80858, 0x82040d80, 0x01391077, + 0x04020008, 0x59e00813, 0x8c040d00, 0x04000005, + 0x82000d80, 0x00000002, 0x04020002, 0x41780000, + 0x4c000000, 0x0401f94d, 0x5c000000, 0x800001c0, + 0x04000026, 0x82000d80, 0x00000001, 0x04020010, + 0x59a8006c, 0x80000540, 0x04000004, 0x42001000, + 0x00000000, 0x0401fa0a, 0x42000800, 0x00000000, + 0x0401f897, 0x82040540, 0x00000090, 0x42000800, + 0x00000000, 0x0401f897, 0x0401f024, 0x82000d80, + 0x00000002, 0x02020800, 0x001005d8, 0x59a8006c, + 0x80000540, 0x04000004, 0x42001000, 0x00010000, + 0x0401f9f7, 0x42000800, 0x00000000, 0x0401f884, + 0x82040500, 0xffffff6f, 0x42000800, 0x00000000, + 0x0401f884, 0x0401f011, 0x59a8006c, 0x80000540, + 0x04000004, 0x42001000, 0x00008000, 0x0401f9e8, + 0x42000800, 0x00000000, 0x0401f875, 0x82040500, + 0xffffff6f, 0x82000540, 0x00000010, 0x42000800, + 0x00000000, 0x0401f873, 0x0401f124, 0x4c580000, + 0x4200b000, 0x00000014, 0x8058b040, 0x04000043, + 0x59c4000d, 0x8c000520, 0x040207fc, 0x0401f85c, + 0x59c4000d, 0x8c000520, 0x040207f8, 0x59c40808, + 0x84040d50, 0x48078808, 0x4200b000, 0x000000c8, + 0x8058b040, 0x040207ff, 0x4200b000, 0x00000014, + 0x8058b040, 0x04000031, 0x59c4000d, 0x8c000520, + 0x0402002e, 0x42000800, 0x00001000, 0x50040800, + 0x82040c80, 0x24220001, 0x04020003, 0x8c000504, + 0x040007f4, 0x0401f842, 0x59c4000d, 0x8c000520, + 0x04020022, 0x42000800, 0x00001000, 0x50040800, + 0x82040c80, 0x24220001, 0x04020003, 0x8c000504, + 0x040007e8, 0x4200b000, 0x0000000a, 0x8058b040, + 0x04000003, 0x0401f832, 0x0401f7fd, 0x4200b000, + 0x00000064, 0x59c4000d, 0x8c00051e, 0x0400000f, + 0x8058b040, 0x040207fc, 0x42000000, 0x00001000, + 0x50000000, 0x82000480, 0x24220001, 0x04020004, + 0x59c40808, 0x84040d10, 0x48078808, 0x80000580, + 0x4803c857, 0x0401f00c, 0x42000000, 0x00001000, + 0x50000000, 0x82000480, 0x24220001, 0x04020004, + 0x59c40808, 0x84040d10, 0x48078808, 0x82000540, + 0x00000001, 0x5c00b000, 0x1c01f000, 0x42000800, + 0x000000a0, 0x0401f816, 0x82040500, 0xfffffffe, + 0x42000800, 0x000000a0, 0x0401f816, 0x42000800, + 0x00000000, 0x0401f80e, 0x82040500, 0xfffffffe, + 0x42000800, 0x00000000, 0x0401f00e, 0x40000000, + 0x40000000, 0x40000000, 0x40000000, 0x40000000, + 0x1c01f000, 0x480b8805, 0x1c01f000, 0x4807880e, + 0x59c4080f, 0x82040d00, 0x000000ff, 0x1c01f000, + 0x900001c0, 0x80040d40, 0x84040d40, 0x4807880e, + 0x1c01f000, 0x82000d80, 0x00200000, 0x04000009, + 0x82000d80, 0x02000000, 0x04000006, 0x82000d80, + 0x01000000, 0x04000006, 0x59c408a3, 0x0401f006, + 0x59c408a3, 0x84040d30, 0x0401f003, 0x59c408a3, + 0x84040d32, 0x80040540, 0x480388a3, 0x480788a3, + 0x1c01f000, 0x59c400a3, 0x84000556, 0x480388a3, + 0x84000516, 0x480388a3, 0x1c01f000, 0x485fc857, + 0x4863c857, 0x4c640000, 0x4d3c0000, 0x4d400000, + 0x0201f800, 0x00106ede, 0x4863500a, 0x0201f800, + 0x0010ab33, 0x0402006c, 0x82600d00, 0x0000ff00, + 0x800409c0, 0x0400000c, 0x4200c800, 0x00000001, + 0x59a80010, 0x82000500, 0x000000ff, 0x80041110, + 0x80081580, 0x04000021, 0x82041580, 0x0000ff00, + 0x0400000a, 0x59c410a3, 0x82081500, 0x00008000, + 0x04000009, 0x59c410a7, 0x82081500, 0x0000ff00, + 0x82081580, 0x0000ff00, 0x4200c800, 0x00000000, + 0x04000012, 0x59a80005, 0x8c000502, 0x04020008, + 0x8c000500, 0x0402000d, 0x599c1017, 0x8c08151a, + 0x0400003e, 0x84000542, 0x48035005, 0x4200c800, + 0x00000002, 0x42028000, 0x00000004, 0x42027800, + 0x00000008, 0x0401f008, 0x59a80805, 0x84040d40, + 0x48075005, 0x42028000, 0x00000004, 0x42027800, + 0x00000400, 0x59a80006, 0x8c000502, 0x04020006, + 0x59a80805, 0x8c040d0a, 0x04020033, 0x84040d4a, + 0x48075005, 0x42000000, 0x0010b812, 0x0201f800, + 0x0010aa47, 0x59a8180a, 0x42001000, 0x00008013, + 0x0201f800, 0x00103a3e, 0x0201f800, 0x00103b25, + 0x04000015, 0x4d400000, 0x82600500, 0x000000ff, + 0x42028800, 0x0000ffff, 0x40643000, 0x42028000, + 0x0000000e, 0x0201f800, 0x0010a446, 0x42000800, + 0x00000001, 0x42001000, 0x00000100, 0x0201f800, + 0x0010618b, 0x5c028000, 0x599c0817, 0x8c040d0a, + 0x04020011, 0x493fc857, 0x4943c857, 0x0201f800, + 0x00101fe5, 0x0401f00c, 0x0201f800, 0x00103b25, + 0x04000009, 0x42028000, 0x0000000f, 0x42028800, + 0x0000ffff, 0x42003000, 0x00000000, 0x0201f800, + 0x0010a449, 0x497b8880, 0x5c028000, 0x5c027800, + 0x5c00c800, 0x1c01f000, 0x42000800, 0x000000a0, + 0x0401ff5f, 0x82040540, 0x00000002, 0x42000800, + 0x000000a0, 0x0401f75f, 0x42000800, 0x00000000, + 0x0401ff57, 0x82040540, 0x00000002, 0x42000800, + 0x00000000, 0x0401f757, 0x42000800, 0x000000a0, + 0x0401ff4f, 0x82040500, 0xfffffffd, 0x42000800, + 0x000000a0, 0x0401f74f, 0x42000800, 0x00000000, + 0x0401ff47, 0x82040500, 0xfffffffd, 0x42000800, + 0x00000000, 0x0401f747, 0x59c408a8, 0x0401ff38, + 0x0401ff37, 0x59c400a8, 0x80040d80, 0x040207fb, + 0x1c01f000, 0x4803c856, 0x4a038807, 0x00000001, + 0x497b8807, 0x59c40005, 0x48038805, 0x497b506c, + 0x497b506d, 0x41785800, 0x42006000, 0x00000001, + 0x42006800, 0x00000003, 0x0401f824, 0x0401f82f, + 0x40400000, 0x4803c857, 0x82408580, 0x00000000, + 0x0402001d, 0x41785800, 0x42006000, 0x0000001e, + 0x42006800, 0x00000014, 0x0401f818, 0x0401f823, + 0x40400000, 0x4803c857, 0x82408580, 0x00000800, + 0x04020011, 0x42005800, 0x00000001, 0x42006000, + 0x0000001e, 0x42006800, 0x00000014, 0x0401f80b, + 0x0401f816, 0x40400000, 0x4803c857, 0x82408580, + 0x0000ffff, 0x04020004, 0x4a03506c, 0x00000001, + 0x4803c856, 0x1c01f000, 0x41785000, 0x0401f812, + 0x0401f838, 0x40347000, 0x40340800, 0x0401f03d, + 0x42005000, 0x00000001, 0x0401f80b, 0x0401f831, + 0x40340800, 0x0401f037, 0x42005000, 0x00000002, + 0x0401f805, 0x0401f81d, 0x0401f835, 0x40048000, + 0x1c01f000, 0x0401f808, 0x0401f814, 0x40280800, + 0x0401f826, 0x402c0800, 0x0401f827, 0x40300800, + 0x0401f025, 0x42000800, 0x0000ffff, 0x42001000, + 0x00000001, 0x0401f829, 0x42001000, 0x00000010, + 0x0401f826, 0x42000800, 0x0000ffff, 0x42001000, + 0x00000010, 0x0401f021, 0x41780800, 0x42001000, + 0x00000002, 0x0401f01d, 0x0401f92e, 0x4a03d000, + 0x00050004, 0x0401f92b, 0x4a03d000, 0x00050005, + 0x0401f928, 0x4a03d000, 0x00050004, 0x42000800, + 0x00000001, 0x42001000, 0x00000001, 0x0401f00f, + 0x42000800, 0x00000002, 0x42001000, 0x00000002, + 0x0401f00a, 0x42001000, 0x00000005, 0x0401f007, + 0x42001000, 0x00000010, 0x0401f004, 0x42001000, + 0x00000010, 0x0401f01b, 0x0401f912, 0x82082c00, + 0x0010ab38, 0x50142800, 0x82081500, 0xffffffff, + 0x04000013, 0x0401f90b, 0x80081040, 0x80142902, + 0x40040000, 0x80140500, 0x04000007, 0x4a03d000, + 0x00070006, 0x0401f903, 0x4a03d000, 0x00070007, + 0x0401f006, 0x4a03d000, 0x00070004, 0x0401f8fd, + 0x4a03d000, 0x00070005, 0x0401f7ec, 0x1c01f000, + 0x41780800, 0x82082c00, 0x0010ab38, 0x50142800, + 0x82081500, 0xffffffff, 0x04000010, 0x0401f8f1, + 0x4a03d000, 0x00050001, 0x0401f8ee, 0x59e81800, + 0x80081040, 0x80142902, 0x8c0c1d06, 0x04000004, + 0x40140000, 0x80040d40, 0x0401f8e6, 0x4a03d000, + 0x00070000, 0x0401f7ef, 0x1c01f000, 0x480bc857, + 0x480b506d, 0x59c40001, 0x82000500, 0xffffefff, + 0x48038801, 0x41781800, 0x0401f8c4, 0x41785800, + 0x42006000, 0x0000001e, 0x42006800, 0x00000004, + 0x0401ff7a, 0x42006800, 0x0000003c, 0x0401ff7d, + 0x41785800, 0x42006000, 0x0000001e, 0x42006800, + 0x00000004, 0x0401ff71, 0x41786800, 0x0401ff75, + 0x41785800, 0x42006000, 0x0000001e, 0x41786800, + 0x0401ff6a, 0x42006800, 0x00000002, 0x0401ff6d, + 0x42006800, 0x00000001, 0x0401ff64, 0x42006800, + 0x000000f5, 0x0401ff67, 0x41785800, 0x42006000, + 0x0000001e, 0x42006800, 0x00000004, 0x0401ff5b, + 0x42006800, 0x00000020, 0x0401ff5e, 0x59a8106d, + 0x0401f865, 0x42001800, 0x000200f5, 0x0401f897, + 0x59a8106d, 0x0401f879, 0x41785800, 0x42006000, + 0x0000001e, 0x42006800, 0x00000004, 0x0401ff4b, + 0x41786800, 0x0401ff4f, 0x59c40001, 0x82000540, + 0x00001000, 0x48038801, 0x41785800, 0x42006000, + 0x0000001e, 0x42006800, 0x00000015, 0x0401ff3f, + 0x0401ff4a, 0x40400000, 0x82000540, 0x00000002, + 0x4c000000, 0x41785800, 0x42006000, 0x0000001e, + 0x42006800, 0x00000015, 0x0401ff34, 0x5c000000, + 0x40006800, 0x0401ff37, 0x41785800, 0x42006000, + 0x0000001e, 0x42006800, 0x00000015, 0x0401ff2b, + 0x0401ff36, 0x40400000, 0x82000500, 0x0000fffd, + 0x4c000000, 0x41785800, 0x42006000, 0x0000001e, + 0x42006800, 0x00000015, 0x0401ff20, 0x5c000000, + 0x40006800, 0x0401ff23, 0x41785800, 0x42006000, + 0x0000001e, 0x42006800, 0x00000014, 0x0401ff17, + 0x0401ff22, 0x40400000, 0x82000540, 0x00000040, + 0x4c000000, 0x41785800, 0x42006000, 0x0000001e, + 0x42006800, 0x00000014, 0x0401ff0c, 0x5c000000, + 0x40006800, 0x0401ff0f, 0x41785800, 0x42006000, + 0x0000001e, 0x42006800, 0x00000014, 0x0401ff03, + 0x0401ff0e, 0x40400000, 0x82000500, 0x0000ffbf, + 0x4c000000, 0x41785800, 0x42006000, 0x0000001e, + 0x42006800, 0x00000014, 0x0401fef8, 0x5c000000, + 0x40006800, 0x0401fefb, 0x4a038886, 0x00002020, + 0x0401f04c, 0x480bc857, 0x82080580, 0x00010000, + 0x04020007, 0x82040d40, 0x00010000, 0x42001800, + 0x00000001, 0x0401f82d, 0x0401f00f, 0x82080580, + 0x00008000, 0x04000007, 0x82040d40, 0x00000000, + 0x42001800, 0x00900001, 0x0401f824, 0x0401f006, + 0x82040d40, 0x00008000, 0x42001800, 0x00100001, + 0x0401f81e, 0x1c01f000, 0x480bc857, 0x82080580, + 0x00010000, 0x04020008, 0x42001800, 0x000000a1, + 0x0401f816, 0x42001800, 0x000000c1, 0x0401f813, + 0x0401f011, 0x82080580, 0x00008000, 0x04000008, + 0x42001800, 0x000400a1, 0x0401f80c, 0x42001800, + 0x002000c1, 0x0401f809, 0x0401f007, 0x42001800, + 0x000400a1, 0x0401f805, 0x42001800, 0x000000c1, + 0x0401f802, 0x1c01f000, 0x480fc857, 0x41785800, + 0x42006000, 0x0000001e, 0x41786800, 0x0401feb7, + 0x400c6800, 0x80346960, 0x0401feba, 0x42006800, + 0x00000001, 0x0401feb1, 0x400c6800, 0x0401feb5, + 0x42006800, 0x00000003, 0x0401feac, 0x0401feb7, + 0x40400000, 0x8c000504, 0x040207fc, 0x1c01f000, + 0x42000000, 0x00000064, 0x80000040, 0x040207ff, + 0x1c01f000, 0x00020103, 0x00101bd5, 0x00101bdb, + 0x00101be1, 0x00101be9, 0x00101bef, 0x00101bf7, + 0x00101bff, 0x00101c09, 0x00101c0f, 0x00101c17, + 0x00101c1f, 0x00101c29, 0x00101c31, 0x00101c3b, + 0x00101c45, 0x000200f8, 0x00101c51, 0x00101c59, + 0x00101c61, 0x00101c6b, 0x00101c73, 0x00101c7d, + 0x00101c87, 0x00101c93, 0x00101c9b, 0x00101ca5, + 0x00101caf, 0x00101cbb, 0x00101cc5, 0x00101cd1, + 0x00101cdd, 0x000200fd, 0x00101ceb, 0x00101cf3, + 0x00101cfb, 0x00101d05, 0x00101d0d, 0x00101d17, + 0x00101d21, 0x00101d2d, 0x00101d35, 0x00101d3f, + 0x00101d49, 0x00101d55, 0x00101d5f, 0x00101d6b, + 0x00101d77, 0x00101d85, 0x00101d8d, 0x00101d97, + 0x00101da1, 0x00101dad, 0x00101db7, 0x00101dc3, + 0x00101dcf, 0x00101ddd, 0x00101de7, 0x00101df3, + 0x00101dff, 0x00101e0d, 0x00101e19, 0x00101e27, + 0x00101e35, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00101418, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101289, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101289, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00101289, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00101289, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00101289, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00101289, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00101418, 0x0201f800, 0x00101289, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00101418, 0x0201f800, + 0x00101289, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020729, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020729, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00020729, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020729, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00020729, 0x0201f800, + 0x00101289, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00020729, 0x0201f800, + 0x00101289, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020729, 0x0201f800, + 0x00101289, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00101289, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00020729, 0x0201f800, 0x00101289, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00020729, 0x0201f800, + 0x00101289, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00101289, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00101289, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00020015, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020015, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020015, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00020015, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00020015, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00101155, 0x0201f800, 0x00020015, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101418, 0x0201f800, 0x00101155, 0x0201f800, + 0x00020015, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101289, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f800, + 0x00101155, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101289, 0x0201f800, 0x00101155, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f800, + 0x00101155, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f800, + 0x00101155, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020729, 0x0201f800, + 0x00020015, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101155, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00020729, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101155, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101155, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101155, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101289, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00020729, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101289, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101289, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00020729, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00020729, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f800, + 0x00020104, 0x0201f000, 0x00020101, 0x4c000000, + 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800, + 0x00101418, 0x0201f800, 0x00020729, 0x0201f800, + 0x00020015, 0x0201f800, 0x00101289, 0x0201f000, + 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800, + 0x00101155, 0x0201f800, 0x00101418, 0x0201f800, + 0x00020729, 0x0201f800, 0x00020015, 0x0201f800, + 0x00101289, 0x0201f800, 0x00020104, 0x0201f000, + 0x00020101, 0x4c5c0000, 0x4c600000, 0x4178b800, + 0x0201f800, 0x001048ec, 0x040200fd, 0x59a8c026, + 0x0201f800, 0x0010513b, 0x04000003, 0x8c60c506, + 0x0400000e, 0x8c60c500, 0x04020004, 0x8c60c50e, + 0x040008f6, 0x0401f0f2, 0x0401fab4, 0x040200f0, + 0x0201f800, 0x0010513b, 0x04020004, 0x4a03501c, + 0x0000ffff, 0x0401f0ea, 0x8c60c504, 0x04000004, + 0x4a03501c, 0x0000ffff, 0x0401f0e5, 0x59a8c010, + 0x8260c500, 0x000000ff, 0x59a81013, 0x8c081500, + 0x0400005d, 0x8c081502, 0x0402005b, 0x59a8b81c, + 0x825c0d80, 0x0000ffff, 0x04020003, 0x4200b800, + 0x00000001, 0x805c1104, 0x82086400, 0x0010be21, + 0x50300800, 0x825c0500, 0x00000003, 0x0c01f001, + 0x00101e81, 0x00101e7c, 0x00101e80, 0x00101e7e, + 0x80040910, 0x0401f004, 0x80040930, 0x0401f002, + 0x80040920, 0x82040500, 0x000000ff, 0x82000d80, + 0x000000ff, 0x0400000f, 0x4c000000, 0x82000400, + 0x0010210e, 0x50000800, 0x80040910, 0x82040580, + 0x00000080, 0x5c000000, 0x04000030, 0x80600d80, + 0x0400002e, 0x80000540, 0x0400002c, 0x0401f00b, + 0x59a81005, 0x82081500, 0x00000003, 0x0402002b, + 0x59a81013, 0x84081542, 0x480b5013, 0x4a03501c, + 0x0000ffff, 0x0401f028, 0x4c000000, 0x59a80005, + 0x8c000514, 0x42001000, 0x00000010, 0x02020800, + 0x00104c6d, 0x5c000000, 0x0402001c, 0x417a8800, + 0x0201f800, 0x00105c9a, 0x04020016, 0x0201f800, + 0x001045e5, 0x04000006, 0x0201f800, 0x00104c62, + 0x0401f8b1, 0x0400000f, 0x0401f00c, 0x599c0019, + 0x8c00050e, 0x04020009, 0x0201f800, 0x001045a6, + 0x04020008, 0x0201f800, 0x00104c62, 0x0401f9e1, + 0x0401f8be, 0x04000003, 0x805cb800, 0x0401f7b2, + 0x485f501c, 0x0401f086, 0x4a03501c, 0x0000ffff, + 0x0401f083, 0x42003000, 0x0000007e, 0x59a8001c, + 0x82001580, 0x0000ffff, 0x04020005, 0x80000d80, + 0x4018b000, 0x4803c856, 0x0401f009, 0x8018b480, + 0x04001004, 0x40000800, 0x4803c856, 0x0401f004, + 0x4a03501c, 0x0000ffff, 0x0401f071, 0x4c040000, + 0x4c580000, 0x82040400, 0x0010210e, 0x50000000, + 0x82000500, 0x000000ff, 0x80604580, 0x0400005c, + 0x0201f800, 0x00105c9b, 0x04020061, 0x59a80005, + 0x8c000514, 0x42001000, 0x00000010, 0x02020800, + 0x00104c6d, 0x5c00b000, 0x5c000800, 0x040207d7, + 0x4c040000, 0x4c580000, 0x845cbd00, 0x0201f800, + 0x00020245, 0x04000008, 0x599c0019, 0x8c00050e, + 0x04020047, 0x0201f800, 0x001045ab, 0x0402004c, + 0x0401f002, 0x845cbd40, 0x0201f800, 0x00104c62, + 0x0201f800, 0x001049e7, 0x04020007, 0x59a80005, + 0x8c000502, 0x04000033, 0x59340200, 0x8c00050e, + 0x04020030, 0x59a81013, 0x8c081502, 0x04000025, + 0x0201f800, 0x00104a09, 0x04000031, 0x8c5cbd00, + 0x04020004, 0x0201f800, 0x001045ff, 0x0401f02c, + 0x0401f9cd, 0x0400002a, 0x42026000, 0x0010bde9, + 0x49366009, 0x497a6008, 0x417a7800, 0x0401f925, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x0201f800, 0x00103b25, 0x0400001d, 0x41782800, + 0x42003000, 0x00000008, 0x4d400000, 0x4d440000, + 0x59368c03, 0x42028000, 0x00000029, 0x0201f800, + 0x0010a446, 0x5c028800, 0x5c028000, 0x0401f010, + 0x4937c857, 0x599c0019, 0x8c00050e, 0x0402000c, + 0x0401f96c, 0x0401f849, 0x04000011, 0x0401f008, + 0x59a80013, 0x8c000500, 0x04000003, 0x0401f9a6, + 0x04000003, 0x0401f828, 0x04000009, 0x5c00b000, + 0x5c000800, 0x80040800, 0x8058b040, 0x04020798, + 0x4a03501c, 0x0000ffff, 0x0401f005, 0x4937c857, + 0x5c00b000, 0x5c000800, 0x4807501c, 0x5c00c000, + 0x5c00b800, 0x1c01f000, 0x4803c856, 0x4a03501c, + 0x00000001, 0x42028800, 0x000007fe, 0x42003000, + 0x00fffffe, 0x0201f800, 0x001045a6, 0x0402000c, + 0x0401f948, 0x0401f825, 0x04000009, 0x59a80026, + 0x8400054e, 0x48035026, 0x0201f800, 0x0010930f, + 0x82000540, 0x00000001, 0x1c01f000, 0x80000580, + 0x0401f7fe, 0x4937c857, 0x0201f800, 0x00107942, + 0x04000015, 0x49366009, 0x4a026406, 0x00000001, + 0x417a7800, 0x0201f800, 0x00104567, 0x59a8001b, + 0x80000000, 0x4803501b, 0x42027000, 0x00000004, + 0x599c0019, 0x8c00050e, 0x04000003, 0x42027000, + 0x00000000, 0x0201f800, 0x000207a1, 0x82000540, + 0x00000001, 0x1c01f000, 0x4937c857, 0x0201f800, + 0x00107942, 0x0400001c, 0x49366009, 0x59340403, + 0x82000580, 0x000007fe, 0x04000005, 0x4d3c0000, + 0x417a7800, 0x0401f8b7, 0x5c027800, 0x4a026406, + 0x00000001, 0x417a7800, 0x0201f800, 0x00104567, + 0x42000800, 0x00000003, 0x0201f800, 0x00104571, + 0x59a8001b, 0x80000000, 0x4803501b, 0x42027000, + 0x00000002, 0x0201f800, 0x000207a1, 0x82000540, + 0x00000001, 0x1c01f000, 0x4803c856, 0x42028800, + 0x000007fc, 0x42003000, 0x00fffffc, 0x0201f800, + 0x001045a6, 0x04020005, 0x0401f805, 0x04000003, + 0x4a035027, 0x0000ffff, 0x1c01f000, 0x4937c857, + 0x0201f800, 0x00107942, 0x04000014, 0x49366009, + 0x4a026406, 0x00000001, 0x417a7800, 0x0201f800, + 0x00104567, 0x42000800, 0x00000003, 0x0201f800, + 0x00104571, 0x59a80028, 0x80000000, 0x48035028, + 0x42027000, 0x00000002, 0x0201f800, 0x000207a1, + 0x82000540, 0x00000001, 0x1c01f000, 0x480bc857, + 0x492fc857, 0x4c5c0000, 0x4008b800, 0x42028800, + 0x000007fd, 0x42003000, 0x00fffffd, 0x0201f800, + 0x001045a6, 0x0402001a, 0x0201f800, 0x0002075a, + 0x04000017, 0x49366009, 0x5934000a, 0x84000544, + 0x4802680a, 0x812e59c0, 0x04000005, 0x592c0404, + 0x8c00051e, 0x04000002, 0x48ee6021, 0x492e6008, + 0x4a026406, 0x00000001, 0x485e601c, 0x42027000, + 0x00000022, 0x0201f800, 0x000207a1, 0x82000540, + 0x00000001, 0x5c00b800, 0x1c01f000, 0x80000580, + 0x0401f7fd, 0x5c000000, 0x4c000000, 0x4803c857, + 0x4943c857, 0x493fc857, 0x4d340000, 0x4d440000, + 0x4c580000, 0x4d2c0000, 0x4c5c0000, 0x0201f800, + 0x00106c55, 0x4df00000, 0x0201f800, 0x001069f1, + 0x0201f800, 0x00106aac, 0x0201f800, 0x00106737, + 0x0201f800, 0x0010848a, 0x5c03e000, 0x02000800, + 0x00106c4b, 0x4200b000, 0x000007f0, 0x417a8800, + 0x0201f800, 0x00020245, 0x0402001f, 0x8d3e7d14, + 0x04000005, 0x59340212, 0x82000500, 0x0000ff00, + 0x04000019, 0x8d3e7d06, 0x04000004, 0x59340200, + 0x8c00050e, 0x04020014, 0x8d3e7d18, 0x0400000f, + 0x5934b80f, 0x805cb9c0, 0x04000009, 0x49425a06, + 0x592cb800, 0x0201f800, 0x000202ce, 0x805cb9c0, + 0x040207fb, 0x497a680f, 0x497a6810, 0x4a026c00, + 0x00000707, 0x0401f004, 0x4937c857, 0x0201f800, + 0x001042b4, 0x81468800, 0x8058b040, 0x040207dd, + 0x8d3e7d02, 0x04000011, 0x497b501d, 0x42028800, + 0x000007f0, 0x4200b000, 0x00000010, 0x0201f800, + 0x00020245, 0x04020006, 0x4937c857, 0x4a026c00, + 0x00000707, 0x0201f800, 0x001042b4, 0x81468800, + 0x8058b040, 0x040207f6, 0x5c00b800, 0x5c025800, + 0x5c00b000, 0x5c028800, 0x5c026800, 0x1c01f000, + 0x5c000000, 0x4c000000, 0x4803c857, 0x4933c857, + 0x493fc857, 0x4d340000, 0x4d400000, 0x4d440000, + 0x4d2c0000, 0x4c5c0000, 0x0201f800, 0x00106c55, + 0x4df00000, 0x59326809, 0x813669c0, 0x04000020, + 0x59368c03, 0x42028000, 0x00000029, 0x0201f800, + 0x00106a50, 0x0201f800, 0x00106ab4, 0x0201f800, + 0x001067fd, 0x0201f800, 0x0010a2ff, 0x4937c857, + 0x8d3e7d18, 0x04000010, 0x5934b80f, 0x805cb9c0, + 0x0400000a, 0x405e5800, 0x49425a06, 0x592cb800, + 0x0201f800, 0x000202ce, 0x805cb9c0, 0x040207fa, + 0x497a680f, 0x497a6810, 0x4a026c00, 0x00000707, + 0x0401f003, 0x0201f800, 0x001042b4, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x5c00b800, 0x5c025800, + 0x5c028800, 0x5c028000, 0x5c026800, 0x1c01f000, + 0x4933c857, 0x59a80026, 0x8c000508, 0x04020012, + 0x59305009, 0x482bc857, 0x836c0580, 0x00000002, + 0x0402000d, 0x0401f813, 0x0402000b, 0x58280403, + 0x82000580, 0x000007fc, 0x04000008, 0x59a8001b, + 0x80000040, 0x4803c857, 0x02001800, 0x001005d8, + 0x4803501b, 0x1c01f000, 0x59a80028, 0x80000040, + 0x4803c857, 0x040017fc, 0x48035028, 0x1c01f000, + 0x59300008, 0x800001c0, 0x04020009, 0x59300403, + 0x82000580, 0x00000001, 0x04020004, 0x82000540, + 0x00000001, 0x0401f002, 0x80000580, 0x1c01f000, + 0x4937c857, 0x59340200, 0x84000502, 0x48026a00, + 0x1c01f000, 0x4933c857, 0x493fc857, 0x4947c857, + 0x4d3c0000, 0x4d400000, 0x4d340000, 0x4d440000, + 0x4c580000, 0x0201f800, 0x00106c55, 0x4df00000, + 0x813e79c0, 0x04020004, 0x4200b000, 0x00000001, + 0x0401f004, 0x4200b000, 0x000007f0, 0x417a8800, + 0x41440000, 0x81ac0400, 0x50000000, 0x80026d40, + 0x04000019, 0x42027800, 0x00000001, 0x0201f800, + 0x001048f6, 0x42028000, 0x00000029, 0x417a7800, + 0x0201f800, 0x00106a50, 0x0201f800, 0x00106ab4, + 0x0201f800, 0x001067fd, 0x0201f800, 0x001049e7, + 0x04020005, 0x4937c857, 0x4a026c00, 0x00000404, + 0x0401f003, 0x0201f800, 0x00104a14, 0x0201f800, + 0x0010a2ff, 0x81468800, 0x8058b040, 0x040207e1, + 0x5c03e000, 0x02000800, 0x00106c4b, 0x5c00b000, + 0x5c028800, 0x5c026800, 0x5c028000, 0x5c027800, + 0x1c01f000, 0x4937c857, 0x4947c857, 0x4c5c0000, + 0x4c600000, 0x4c640000, 0x59a80013, 0x8c000500, + 0x0400001f, 0x599c0017, 0x8c00050a, 0x0402001c, + 0x5934ba02, 0x825cbd00, 0x000000ff, 0x485fc857, + 0x4178c000, 0x4178c800, 0x82600400, 0x0010be21, + 0x50002000, 0x8060c1c0, 0x04000008, 0x82100500, + 0x000000ff, 0x82002d80, 0x000000ff, 0x0400000c, + 0x805c0580, 0x0400000d, 0x80102110, 0x8064c800, + 0x82640580, 0x00000004, 0x040207f5, 0x8060c000, + 0x82600580, 0x00000020, 0x040207eb, 0x4813c857, + 0x82000540, 0x00000001, 0x5c00c800, 0x5c00c000, + 0x5c00b800, 0x1c01f000, 0x59a80026, 0x4803c857, + 0x8c000512, 0x1c01f000, 0x00007eef, 0x00007de8, + 0x00007ce4, 0x000080e2, 0x00007be1, 0x000080e0, + 0x000080dc, 0x000080da, 0x00007ad9, 0x000080d6, + 0x000080d5, 0x000080d4, 0x000080d3, 0x000080d2, + 0x000080d1, 0x000079ce, 0x000078cd, 0x000080cc, + 0x000080cb, 0x000080ca, 0x000080c9, 0x000080c7, + 0x000080c6, 0x000077c5, 0x000076c3, 0x000080bc, + 0x000080ba, 0x000075b9, 0x000080b6, 0x000074b5, + 0x000073b4, 0x000072b3, 0x000080b2, 0x000080b1, + 0x000080ae, 0x000071ad, 0x000080ac, 0x000070ab, + 0x00006faa, 0x00006ea9, 0x000080a7, 0x00006da6, + 0x00006ca5, 0x00006ba3, 0x00006a9f, 0x0000699e, + 0x0000689d, 0x0000809b, 0x00008098, 0x00006797, + 0x00006690, 0x0000658f, 0x00006488, 0x00006384, + 0x00006282, 0x00008081, 0x00008080, 0x0000617c, + 0x0000607a, 0x00008079, 0x00005f76, 0x00008075, + 0x00008074, 0x00008073, 0x00008072, 0x00008071, + 0x0000806e, 0x00005e6d, 0x0000806c, 0x00005d6b, + 0x00005c6a, 0x00005b69, 0x00008067, 0x00005a66, + 0x00005965, 0x00005863, 0x0000575c, 0x0000565a, + 0x00005559, 0x00008056, 0x00008055, 0x00005454, + 0x00005353, 0x00005252, 0x00005151, 0x0000504e, + 0x00004f4d, 0x0000804c, 0x0000804b, 0x00004e4a, + 0x00004d49, 0x00008047, 0x00004c46, 0x00008045, + 0x00008043, 0x0000803c, 0x0000803a, 0x00008039, + 0x00008036, 0x00004b35, 0x00008034, 0x00004a33, + 0x00004932, 0x00004831, 0x0000802e, 0x0000472d, + 0x0000462c, 0x0000452b, 0x0000442a, 0x00004329, + 0x00004227, 0x00008026, 0x00008025, 0x00004123, + 0x0000401f, 0x00003f1e, 0x00003e1d, 0x00003d1b, + 0x00003c18, 0x00008017, 0x00008010, 0x00003b0f, + 0x00003a08, 0x00008004, 0x00003902, 0x00008001, + 0x00008000, 0x00008000, 0x00003800, 0x00003700, + 0x00003600, 0x00008000, 0x00003500, 0x00008000, + 0x00008000, 0x00008000, 0x00003400, 0x00008000, + 0x00008000, 0x00008000, 0x00008000, 0x00008000, + 0x00008000, 0x00003300, 0x00003200, 0x00008000, + 0x00008000, 0x00008000, 0x00008000, 0x00008000, + 0x00008000, 0x00003100, 0x00003000, 0x00008000, + 0x00008000, 0x00002f00, 0x00008000, 0x00002e00, + 0x00002d00, 0x00002c00, 0x00008000, 0x00008000, + 0x00008000, 0x00002b00, 0x00008000, 0x00002a00, + 0x00002900, 0x00002800, 0x00008000, 0x00002700, + 0x00002600, 0x00002500, 0x00002400, 0x00002300, + 0x00002200, 0x00008000, 0x00008000, 0x00002100, + 0x00002000, 0x00001f00, 0x00001e00, 0x00001d00, + 0x00001c00, 0x00008000, 0x00008000, 0x00001b00, + 0x00001a00, 0x00008000, 0x00001900, 0x00008000, + 0x00008000, 0x00008000, 0x00008000, 0x00008000, + 0x00008000, 0x00001800, 0x00008000, 0x00001700, + 0x00001600, 0x00001500, 0x00008000, 0x00001400, + 0x00001300, 0x00001200, 0x00001100, 0x00001000, + 0x00000f00, 0x00008000, 0x00008000, 0x00000e00, + 0x00000d00, 0x00000c00, 0x00000b00, 0x00000a00, + 0x00000900, 0x00008000, 0x00008000, 0x00000800, + 0x00000700, 0x00008000, 0x00000600, 0x00008000, + 0x00008000, 0x00008000, 0x00000500, 0x00000400, + 0x00000300, 0x00008000, 0x00000200, 0x00008000, + 0x00008000, 0x00008000, 0x00000100, 0x00008000, + 0x00008000, 0x00008000, 0x00008000, 0x00008000, + 0x00008000, 0x00000000, 0x00008000, 0x00008000, + 0x00008000, 0x00008000, 0x00008000, 0x00008000, + 0x00008000, 0x00008000, 0x00008000, 0x00008000, + 0x00008000, 0x00008000, 0x00008000, 0x00008000, + 0x00008000, 0x00008000, 0x0201f800, 0x001007d3, + 0x02000800, 0x001005d8, 0x492f4016, 0x1c01f000, + 0x83a0ac00, 0x00000006, 0x83a00580, 0x0010b4a4, + 0x0400000c, 0x492fc857, 0x812e59c0, 0x02000800, + 0x001005d8, 0x832ca400, 0x00000006, 0x4200b000, + 0x0000000d, 0x0201f800, 0x0010ab17, 0x0401f00f, + 0x4200b000, 0x00000010, 0x83e0a400, 0x00000020, + 0x50500000, 0x8050a000, 0x50500800, 0x900409c0, + 0x80040540, 0x4400a800, 0x8050a000, 0x8054a800, + 0x8058b040, 0x040207f7, 0x1c01f000, 0x59a00206, + 0x4803c857, 0x82000c80, 0x0000007f, 0x040210c9, + 0x59a80821, 0x0c01f001, 0x001022c0, 0x00102300, + 0x00102300, 0x0010234b, 0x0010236d, 0x00102300, + 0x001022c0, 0x0010238f, 0x001023a0, 0x00102300, + 0x00102300, 0x001023ad, 0x001023c5, 0x001023dd, + 0x00102300, 0x001023e7, 0x001023f4, 0x00102300, + 0x0010241d, 0x00102300, 0x0010247a, 0x00102300, + 0x00102300, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x00102300, 0x00102491, 0x00102300, + 0x001024e3, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x001024e8, 0x00102560, 0x00102300, + 0x00102567, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x00102300, 0x00102569, 0x001025ea, + 0x00102727, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x00102300, 0x00102736, 0x00102300, + 0x00102300, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x00102300, 0x00102753, 0x001027a6, + 0x00102802, 0x00102816, 0x00102835, 0x00102a70, + 0x00102dff, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x00102300, 0x00102300, 0x00102300, + 0x00102300, 0x00102fb4, 0x00103028, 0x00102300, + 0x00102300, 0x00103094, 0x00102300, 0x00103126, + 0x001031d8, 0x00102300, 0x00102300, 0x0010320f, + 0x0010326b, 0x00102300, 0x001032bd, 0x00103419, + 0x00102300, 0x0010342d, 0x001034b8, 0x00102300, + 0x00102300, 0x00102300, 0x00102300, 0x00103522, + 0x00103526, 0x00103545, 0x00102300, 0x001035e7, + 0x00102300, 0x00102300, 0x00103615, 0x00102300, + 0x00103643, 0x00102300, 0x00102300, 0x001036aa, + 0x001037b7, 0x00103814, 0x00102300, 0x0010387a, + 0x00102300, 0x00102300, 0x001038d3, 0x00103936, + 0x00102300, 0x48efc857, 0x4031d800, 0x58ef400b, + 0x58ec0002, 0x82000580, 0x00000200, 0x04000045, + 0x48efc857, 0x4a034206, 0x00004000, 0x0201f800, + 0x00103a15, 0x83a00580, 0x0010b4a4, 0x0400000d, + 0x58ee580a, 0x4d2c0000, 0x0401f856, 0x41a25800, + 0x0201f800, 0x001007f4, 0x40ee5800, 0x0201f800, + 0x001007f4, 0x5c025800, 0x0201f000, 0x000202da, + 0x04026007, 0x59a0001d, 0x84000542, 0x4803401d, + 0x4a01d809, 0x001022d4, 0x1c01f000, 0x59a00206, + 0x82000d80, 0x00004000, 0x04000006, 0x900001c0, + 0x82000540, 0x00000011, 0x4803c011, 0x0401f005, + 0x900001c0, 0x82000540, 0x00000010, 0x4803c011, + 0x0401f845, 0x59e00017, 0x8c000508, 0x0402000c, + 0x4203e000, 0x30000001, 0x4203e000, 0x40000000, + 0x40ee5800, 0x0201f800, 0x001007f4, 0x59a0001d, + 0x84000504, 0x4803401d, 0x1c01f000, 0x4a03c017, + 0x00000000, 0x59a00206, 0x82000d80, 0x00004000, + 0x040007f0, 0x4a03c017, 0x00000001, 0x0401f7ed, + 0x4803c856, 0x4a034206, 0x00004001, 0x0401f7c0, + 0x4803c856, 0x4a034206, 0x00004002, 0x0401f7bc, + 0x4803c856, 0x4a034206, 0x00004003, 0x0401f7b8, + 0x4803c856, 0x4a034206, 0x00004005, 0x0401f7b4, + 0x4803c856, 0x4a034206, 0x00004006, 0x0401f7b0, + 0x4803c856, 0x4a034206, 0x0000400b, 0x0401f7ac, + 0x4803c856, 0x4a034206, 0x0000400c, 0x0401f7a8, + 0x4803c856, 0x4a034206, 0x0000400c, 0x0401f7a4, + 0x48efc857, 0x58eca80a, 0x8054a9c0, 0x02000800, + 0x001005d8, 0x83a0a400, 0x00000006, 0x8254ac00, + 0x00000006, 0x4200b000, 0x0000000d, 0x0201f000, + 0x0010ab17, 0x59a00206, 0x4803c857, 0x59a00406, + 0x4803c857, 0x59a00207, 0x4803c857, 0x59a00407, + 0x4803c857, 0x59a00208, 0x4803c857, 0x59a00408, + 0x4803c857, 0x59a00209, 0x4803c857, 0x83e0ac00, + 0x00000020, 0x83a0a400, 0x00000006, 0x4200b000, + 0x00000010, 0x50500000, 0x4400a800, 0x8054a800, + 0x900001c0, 0x4400a800, 0x8054a800, 0x8050a000, + 0x8058b040, 0x040207f8, 0x1c01f000, 0x59a00406, + 0x800000c2, 0x59a00a07, 0x900409c0, 0x80040540, + 0x84000540, 0x59a00c07, 0x8c040d00, 0x04000018, + 0x59a80805, 0x8c040d0e, 0x040207ba, 0x42000800, + 0x00000064, 0x80040840, 0x04000007, 0x4a030000, + 0x00000001, 0x40000000, 0x59801000, 0x8c081500, + 0x040007f9, 0x04000005, 0x48030004, 0x4a030000, + 0x00000000, 0x0401f75b, 0x4a030000, 0x00000000, + 0x4a034406, 0x00000004, 0x040007a2, 0x4803880e, + 0x0401f754, 0x59a00406, 0x800000c2, 0x59a00c07, + 0x8c040d00, 0x0400001a, 0x59a80805, 0x8c040d0e, + 0x0402079c, 0x42000800, 0x00000064, 0x80040840, + 0x04000007, 0x4a030000, 0x00000001, 0x40000000, + 0x59801000, 0x8c081500, 0x040007f9, 0x04000007, + 0x48030004, 0x59800805, 0x48074406, 0x4a030000, + 0x00000000, 0x0401f73b, 0x4a030000, 0x00000000, + 0x4a034406, 0x00000004, 0x04000782, 0x4803880e, + 0x59c4080f, 0x48074406, 0x0401f732, 0x59a01c06, + 0x59a00207, 0x900c19c0, 0x800c1d40, 0x580c0803, + 0x80000580, 0x500c1000, 0x80080400, 0x800c1800, + 0x80040840, 0x040207fc, 0x48034406, 0x900001c0, + 0x48034207, 0x800001c0, 0x04000722, 0x0401f769, + 0x4a034406, 0x00000004, 0x4a034207, 0x00000000, + 0x4a034407, 0x00000010, 0x59a8000d, 0x48034208, + 0x900001c0, 0x48034408, 0x4a034209, 0x00000002, + 0x0401f714, 0x59a00407, 0x59a01207, 0x900811c0, + 0x80081540, 0x59a00409, 0x59a01a09, 0x900c19c0, + 0x800c1d40, 0x59a00a08, 0x59a00408, 0x900409c0, + 0x80040d40, 0x59a0020a, 0x82002480, 0x00000010, + 0x04001754, 0x59a02406, 0x900001c0, 0x80100540, + 0x59a8280d, 0x80142480, 0x0400174e, 0x0201f000, + 0x00103a25, 0x59a00407, 0x59a01207, 0x900811c0, + 0x80081540, 0x59a00409, 0x59a01a09, 0x900c19c0, + 0x800c1d40, 0x59a00a08, 0x59a00408, 0x900409c0, + 0x80040d40, 0x59a0020a, 0x82002480, 0x00000010, + 0x0400173c, 0x59a02406, 0x900001c0, 0x80100540, + 0x59a8280d, 0x80142480, 0x04001736, 0x0201f000, + 0x00103a28, 0x59a00a0a, 0x59a00406, 0x900409c0, + 0x80040d40, 0x59a01407, 0x59a00207, 0x900811c0, + 0x80081540, 0x44080800, 0x0401f6da, 0x59a00a0a, + 0x59a00406, 0x900409c0, 0x80040d40, 0x50040000, + 0x82000d00, 0x0000ffff, 0x48074207, 0x82000d00, + 0xffff0000, 0x900409c0, 0x48074407, 0x0401f6cd, + 0x59a00406, 0x8c000500, 0x04000020, 0x59a01207, + 0x59a01c07, 0x59a02208, 0x480b5054, 0x480f5055, + 0x48135056, 0x59c40801, 0x82040d00, 0x00018000, + 0x82040580, 0x00000000, 0x04000009, 0x82040580, + 0x00008000, 0x04000008, 0x82040580, 0x00010000, + 0x04000007, 0x0201f800, 0x001005d8, 0x40080000, + 0x0401f004, 0x400c0000, 0x0401f002, 0x40100000, + 0x80000110, 0x42000800, 0x000000e0, 0x0201f800, + 0x00101944, 0x0401f007, 0x59a81054, 0x59a81855, + 0x59a82056, 0x480b4207, 0x480f4407, 0x48134208, + 0x0401f6a4, 0x4d2c0000, 0x4d340000, 0x4d300000, + 0x4d440000, 0x59a28c06, 0x0201f800, 0x00020245, + 0x04000006, 0x5c028800, 0x5c026000, 0x5c026800, + 0x5c025800, 0x0401f6e7, 0x59a04407, 0x59a00207, + 0x900001c0, 0x80204540, 0x0401f81e, 0x04000009, + 0x4a034208, 0x00000001, 0x4a034406, 0x0000ffff, + 0x4a034207, 0x0000ffff, 0x497b4407, 0x0401f00b, + 0x0401f822, 0x0400000e, 0x4a034208, 0x00000002, + 0x59300402, 0x48034406, 0x59300202, 0x48034207, + 0x59300206, 0x48034407, 0x5c028800, 0x5c026000, + 0x5c026800, 0x5c025800, 0x0401f67a, 0x5c028800, + 0x5c026000, 0x5c026800, 0x5c025800, 0x0401f6c1, + 0x4937c856, 0x4823c856, 0x4d2c0000, 0x5934000f, + 0x80025d40, 0x04000007, 0x592c0005, 0x80200580, + 0x592c0000, 0x040207fb, 0x82000540, 0x00000001, + 0x5c025800, 0x1c01f000, 0x4823c857, 0x4d2c0000, + 0x4d300000, 0x42026000, 0x0010d1c0, 0x59300406, + 0x82000d80, 0x00000003, 0x04000004, 0x82000d80, + 0x00000006, 0x04020007, 0x59325808, 0x812e59c0, + 0x04000004, 0x592c0005, 0x80200580, 0x0400000a, + 0x83326400, 0x00000024, 0x41580000, 0x81300480, + 0x040017ef, 0x80000580, 0x5c026000, 0x5c025800, + 0x1c01f000, 0x82000540, 0x00000001, 0x5c026000, + 0x5c025800, 0x1c01f000, 0x83a00580, 0x0010b4a4, + 0x04020684, 0x59a80005, 0x8c00050e, 0x04020003, + 0x4a030000, 0x00000000, 0x4a034206, 0x00004000, + 0x4a03c011, 0x40000010, 0x0401fea7, 0x59e00017, + 0x8c000508, 0x04000003, 0x4a03c017, 0x00000000, + 0x4203e000, 0x30000001, 0x4203e000, 0x40000000, + 0x0401f000, 0x800409c0, 0x04000004, 0x4a034406, + 0x00000001, 0x0401f677, 0x836c0580, 0x00000003, + 0x04020010, 0x59a80010, 0x497b4406, 0x0201f800, + 0x0010513b, 0x0400000f, 0x82000d00, 0x00ffff00, + 0x0402000c, 0x82000c00, 0x0010210e, 0x50040800, + 0x80040910, 0x82041580, 0x00000080, 0x04020004, + 0x4a034406, 0x00000007, 0x0401f662, 0x48074406, + 0x82000d00, 0x0000ffff, 0x48074207, 0x80000120, + 0x48034407, 0x59a80026, 0x82001500, 0x00000100, + 0x480b4409, 0x8c000502, 0x0400001f, 0x8c000506, + 0x04000009, 0x82000d00, 0x0000000a, 0x82040d80, + 0x0000000a, 0x04020004, 0x4a034209, 0x00000001, + 0x0401f022, 0x8c00050a, 0x04000009, 0x82000d00, + 0x00000022, 0x82040d80, 0x00000022, 0x04020004, + 0x4a034209, 0x00000003, 0x0401f018, 0x8c000508, + 0x04000009, 0x82000d00, 0x00000012, 0x82040d80, + 0x00000012, 0x04020004, 0x4a034209, 0x00000002, + 0x0401f00e, 0x0201f800, 0x0010513b, 0x04020004, + 0x4a034209, 0x00000004, 0x0401f5e6, 0x8c000506, + 0x04000004, 0x4a034406, 0x00000005, 0x0401f62d, + 0x4a034209, 0x00000000, 0x0401f5de, 0x59a80037, + 0x48034407, 0x59a80038, 0x48034209, 0x0401f5d9, + 0x42007800, 0x0010b8ec, 0x59a00406, 0x4803c857, + 0x82000c80, 0x00000006, 0x04021622, 0x0c01f001, + 0x001024f6, 0x001024f7, 0x00102505, 0x00102518, + 0x00102539, 0x001024f6, 0x0401f61a, 0x836c0580, + 0x00000000, 0x04000613, 0x59a00a07, 0x59a00407, + 0x900001c0, 0x80040d40, 0x4807c857, 0x59a00a08, + 0x59a00408, 0x900001c0, 0x80040d40, 0x4807c857, + 0x0401f056, 0x836c0580, 0x00000000, 0x04000605, + 0x59a00407, 0x59a01207, 0x900001c0, 0x80081540, + 0x59a00408, 0x59a01a08, 0x900001c0, 0x800c1d40, + 0x42000000, 0x0010c1bf, 0x480fc857, 0x480bc857, + 0x42000800, 0x00001000, 0x0201f000, 0x00103a28, + 0x59a00a07, 0x59a00407, 0x900001c0, 0x80041d40, + 0x820c0c80, 0x0010ab4a, 0x040215f2, 0x820c0c80, + 0x00100000, 0x040015ef, 0x480fc857, 0x823c7c00, + 0x00000009, 0x503c0800, 0x800409c0, 0x04000006, + 0x823c0580, 0x0000000d, 0x040005e6, 0x803c7800, + 0x0401f7f9, 0x59e41001, 0x82080d00, 0xfffeffcf, + 0x4807c801, 0x440c7800, 0x46001800, 0x0201f800, + 0x800c1800, 0x46001800, 0x001005cb, 0x480bc801, + 0x0401f022, 0x59a01a07, 0x59a00407, 0x900001c0, + 0x800c1d40, 0x480c7801, 0x59a02208, 0x59a00408, + 0x900001c0, 0x80102540, 0x48107802, 0x59a00209, + 0x80000040, 0x040015cb, 0x48007806, 0x80000000, + 0x48007805, 0x42000800, 0x00004000, 0x40001000, + 0x0201f800, 0x00106681, 0x80000540, 0x04000003, + 0x49787801, 0x0401f5bf, 0x40040000, 0x800c1c00, + 0x040015bc, 0x480c7803, 0x48107804, 0x49787808, + 0x59a00409, 0x48007807, 0x59e40001, 0x4803c857, + 0x82000540, 0x00040000, 0x4803c801, 0x0401f561, + 0x59a80006, 0x48034406, 0x59a80007, 0x48034207, + 0x59a80008, 0x48034407, 0x0401f55a, 0x0201f800, + 0x001005d8, 0x4803c856, 0x4a03c013, 0x03800300, + 0x4a03c014, 0x03800380, 0x59a00c06, 0x82040580, + 0x000000a0, 0x04000004, 0x82040580, 0x000000a2, + 0x0402002b, 0x59a0140a, 0x82080480, 0x00000100, + 0x04021027, 0x59a0020b, 0x8c000500, 0x0402002e, + 0x59a00a0a, 0x800409c0, 0x04000021, 0x82040480, + 0x00000041, 0x0402101e, 0x82040c00, 0x00000003, + 0x82040d00, 0x000000fc, 0x80040904, 0x59a00407, + 0x59a01207, 0x900811c0, 0x80081540, 0x59a00409, + 0x59a01a09, 0x900c19c0, 0x800c1d40, 0x0201f800, + 0x00103a00, 0x04020006, 0x4a034406, 0x00000002, + 0x4a03c014, 0x03800000, 0x0401f576, 0x832e5c00, + 0x00000004, 0x412c0000, 0x0201f800, 0x00103a25, + 0x4a01d809, 0x001025a2, 0x1c01f000, 0x4a03c014, + 0x03800000, 0x0401f56f, 0x4031d800, 0x58ef400b, + 0x58ee580d, 0x58ec0002, 0x82000580, 0x00000200, + 0x0400055c, 0x59a00c06, 0x59a0140a, 0x59a0020b, + 0x8c000500, 0x04020031, 0x832e5c00, 0x00000004, + 0x41783800, 0x59a04a0a, 0x401c0000, 0x812c0400, + 0x50004000, 0x82201d00, 0x000000ff, 0x4c040000, + 0x0401f8ac, 0x5c000800, 0x0400002d, 0x80244840, + 0x04000028, 0x80081000, 0x82201d00, 0x0000ff00, + 0x800c1910, 0x4c040000, 0x0401f8a2, 0x5c000800, + 0x04000023, 0x80244840, 0x0400001e, 0x80081000, + 0x82201d00, 0x00ff0000, 0x800c1920, 0x4c040000, + 0x0401f898, 0x5c000800, 0x04000019, 0x80244840, + 0x04000014, 0x80081000, 0x82201d00, 0xff000000, + 0x800c1930, 0x4c040000, 0x0401f88e, 0x5c000800, + 0x0400000f, 0x80244840, 0x0400000a, 0x80081000, + 0x801c3800, 0x0401f7d5, 0x59a0020a, 0x82000500, + 0x000000ff, 0x40001800, 0x0401f882, 0x04000004, + 0x4a03c014, 0x03800000, 0x0401f4da, 0x4a03c014, + 0x03800000, 0x0401f523, 0x4803c856, 0x4a03c013, + 0x03800300, 0x4a03c014, 0x03800380, 0x59a00c06, + 0x82040580, 0x000000a0, 0x04000004, 0x82040580, + 0x000000a2, 0x0402006c, 0x59a0140a, 0x82080480, + 0x00000100, 0x04021068, 0x59a0020b, 0x8c000500, + 0x0402005c, 0x59a01a0a, 0x800c19c0, 0x04000062, + 0x820c0480, 0x00000041, 0x0402105f, 0x0201f800, + 0x00103a00, 0x04020006, 0x4a034406, 0x00000002, + 0x4a03c014, 0x03800000, 0x0401f502, 0x832e5c00, + 0x00000004, 0x41783800, 0x59a04a0a, 0x401c0000, + 0x812c0400, 0x40004000, 0x4c040000, 0x4c080000, + 0x0401f874, 0x5c001000, 0x5c000800, 0x04000047, + 0x44144000, 0x80244840, 0x0400002b, 0x80081000, + 0x4c040000, 0x4c080000, 0x0401f86a, 0x5c001000, + 0x5c000800, 0x0400003d, 0x50200000, 0x801428d0, + 0x80140540, 0x44004000, 0x80244840, 0x0400001e, + 0x80081000, 0x4c040000, 0x4c080000, 0x0401f85d, + 0x5c001000, 0x5c000800, 0x04000030, 0x50200000, + 0x801428e0, 0x80140540, 0x44004000, 0x80244840, + 0x04000011, 0x80081000, 0x4c040000, 0x4c080000, + 0x0401f850, 0x5c001000, 0x5c000800, 0x04000023, + 0x50200000, 0x801428f0, 0x80140540, 0x44004000, + 0x80244840, 0x04000004, 0x80081000, 0x801c3800, + 0x0401f7cb, 0x59a00a0a, 0x82040c00, 0x00000003, + 0x82040d00, 0x000000fc, 0x80040904, 0x59a00407, + 0x59a01207, 0x900811c0, 0x80081540, 0x59a00409, + 0x59a01a09, 0x900c19c0, 0x800c1d40, 0x4a03c014, + 0x03800000, 0x412c0000, 0x0201f000, 0x00103a28, + 0x0401f830, 0x04000005, 0x48174406, 0x4a03c014, + 0x03800000, 0x0401f463, 0x4a03c014, 0x03800000, + 0x0401f4ac, 0x4a03c014, 0x03800000, 0x0401f4ad, + 0x0401f836, 0x04000010, 0x0401f862, 0x0402000f, + 0x40080800, 0x0401f85f, 0x0402000c, 0x400c0800, + 0x0401f85c, 0x04020009, 0x0401f84b, 0x42000000, + 0x00030d40, 0x80000040, 0x040207ff, 0x82000540, + 0x00000001, 0x1c01f000, 0x0401f843, 0x80000580, + 0x0401f7fd, 0x0401f821, 0x0400000a, 0x82040d40, + 0x00000001, 0x0401f84b, 0x04020007, 0x0401f87e, + 0x0401f898, 0x0401f838, 0x82000540, 0x00000001, + 0x1c01f000, 0x0401f834, 0x80000580, 0x0401f7fd, + 0x40041800, 0x0401f811, 0x0400000c, 0x0401f83d, + 0x0402000b, 0x40080800, 0x0401f83a, 0x04020008, + 0x400c0800, 0x0401ffe8, 0x04000004, 0x0401f826, + 0x82000540, 0x00000001, 0x1c01f000, 0x0401f822, + 0x80000580, 0x0401f7fd, 0x4c040000, 0x42000800, + 0x00000064, 0x4a03c013, 0x03800300, 0x80040840, + 0x04000016, 0x59e00013, 0x82000500, 0x00000300, + 0x82000580, 0x00000300, 0x040207f7, 0x42000000, + 0x00000064, 0x80000040, 0x040207ff, 0x4a03c013, + 0x01000000, 0x42000000, 0x00000064, 0x80000040, + 0x040207ff, 0x4a03c013, 0x02000000, 0x82000540, + 0x00000001, 0x0401f002, 0x80000580, 0x5c000800, + 0x1c01f000, 0x4a03c013, 0x01000000, 0x42000000, + 0x00000064, 0x80000040, 0x040207ff, 0x4a03c013, + 0x02000200, 0x42000000, 0x00000064, 0x80000040, + 0x040207ff, 0x4a03c013, 0x01000100, 0x1c01f000, + 0x42002000, 0x00000008, 0x82040500, 0x00000080, + 0x800000c2, 0x82000540, 0x01000000, 0x4803c013, + 0x42000000, 0x00000064, 0x80000040, 0x040207ff, + 0x4a03c013, 0x02000200, 0x42000000, 0x00000064, + 0x80000040, 0x040207ff, 0x4a03c013, 0x02000000, + 0x800408c2, 0x80102040, 0x040207ec, 0x4a03c013, + 0x01000100, 0x42000000, 0x00000064, 0x80000040, + 0x040207ff, 0x4a03c013, 0x02000200, 0x42000000, + 0x00000064, 0x80000040, 0x040207ff, 0x59e00013, + 0x82000500, 0x00000100, 0x4a03c013, 0x02000000, + 0x4c040000, 0x42000800, 0x00000064, 0x59e00013, + 0x82000500, 0x00000100, 0x80040840, 0x04000003, + 0x80000540, 0x040207fa, 0x80000540, 0x5c000800, + 0x1c01f000, 0x4a03c013, 0x01000100, 0x42001000, + 0x00000008, 0x80000d80, 0x42000000, 0x00000064, + 0x80000040, 0x040207ff, 0x4a03c013, 0x02000200, + 0x42000000, 0x00000064, 0x80000040, 0x040207ff, + 0x59e00013, 0x82000500, 0x00000100, 0x80000110, + 0x800408c2, 0x80040d40, 0x4a03c013, 0x02000000, + 0x80081040, 0x040207ed, 0x40042800, 0x1c01f000, + 0x4a03c013, 0x01000100, 0x42000000, 0x00000064, + 0x80000040, 0x040207ff, 0x4a03c013, 0x02000200, + 0x42000000, 0x00000064, 0x80000040, 0x040207ff, + 0x4a03c013, 0x02000000, 0x1c01f000, 0x59a00407, + 0x59a80837, 0x48035037, 0x48074407, 0x59a00a09, + 0x82040480, 0x00000014, 0x04021003, 0x42000800, + 0x000007d0, 0x59a80038, 0x48075038, 0x48034209, + 0x0201f000, 0x001022c0, 0x836c0580, 0x00000000, + 0x0400000e, 0x59a80006, 0x59a00c06, 0x80041580, + 0x82081500, 0x00000040, 0x02000000, 0x001022c0, + 0x80080580, 0x48035006, 0x0201f800, 0x00100699, + 0x0201f000, 0x001022c0, 0x59a00406, 0x59a80806, + 0x48035006, 0x80040d80, 0x8c040d0c, 0x02020800, + 0x00100699, 0x59a00207, 0x48035007, 0x59a00407, + 0x48035008, 0x0201f000, 0x001022c0, 0x800409c0, + 0x04000005, 0x4a034406, 0x00000001, 0x0201f000, + 0x0010230c, 0x0201f800, 0x0010513b, 0x04020005, + 0x4a034406, 0x00000016, 0x0201f000, 0x0010230c, + 0x836c0580, 0x00000003, 0x04000005, 0x4a034406, + 0x00000007, 0x0201f000, 0x0010230c, 0x59a00c06, + 0x82040500, 0xffffff00, 0x02020000, 0x00102310, + 0x82041580, 0x000000ff, 0x04020007, 0x59a80010, + 0x82000500, 0x000000ff, 0x82001540, 0x0000ff00, + 0x0401f011, 0x82040400, 0x0010210e, 0x50000000, + 0x80000110, 0x82000580, 0x00000080, 0x02000000, + 0x00102310, 0x59a80010, 0x82000500, 0x000000ff, + 0x80041580, 0x02000000, 0x00102310, 0x840409c0, + 0x80041540, 0x0201f800, 0x0002075a, 0x04020005, + 0x4a034406, 0x00000003, 0x0201f000, 0x0010230c, + 0x48ee6021, 0x480a621c, 0x4a02641c, 0x0000bc09, + 0x4a026406, 0x00000001, 0x0201f800, 0x00103a00, + 0x04020007, 0x0201f800, 0x0002077d, 0x4a034406, + 0x00000002, 0x0201f000, 0x0010230c, 0x497a5a04, + 0x497a5805, 0x4a025c04, 0x00008000, 0x4a01d809, + 0x001027f9, 0x492e6008, 0x42027000, 0x00000032, + 0x0201f000, 0x000207a1, 0x800409c0, 0x04000005, + 0x4a034406, 0x00000001, 0x0201f000, 0x0010230c, + 0x0201f800, 0x0010513b, 0x04020005, 0x4a034406, + 0x00000016, 0x0201f000, 0x0010230c, 0x836c0580, + 0x00000003, 0x04000005, 0x4a034406, 0x00000007, + 0x0201f000, 0x0010230c, 0x59a00c06, 0x82040500, + 0xffffff00, 0x02020000, 0x00102310, 0x82041580, + 0x000000ff, 0x04020007, 0x59a80010, 0x82000500, + 0x000000ff, 0x82001540, 0x0000ff00, 0x0401f011, + 0x82040400, 0x0010210e, 0x50000000, 0x80000110, + 0x82000580, 0x00000080, 0x02000000, 0x00102310, + 0x59a80010, 0x82000500, 0x000000ff, 0x80041580, + 0x02000000, 0x00102310, 0x840409c0, 0x80041540, + 0x0201f800, 0x0002075a, 0x04020005, 0x4a034406, + 0x00000003, 0x0201f000, 0x0010230c, 0x48ee6021, + 0x480a621c, 0x4a02641c, 0x0000bc05, 0x4a026406, + 0x00000001, 0x0201f800, 0x00103a00, 0x04020007, + 0x0201f800, 0x0002077d, 0x4a034406, 0x00000002, + 0x0201f000, 0x0010230c, 0x497a5a04, 0x497a5805, + 0x4a025c04, 0x00008000, 0x4a01d809, 0x001027f9, + 0x492e6008, 0x42027000, 0x00000032, 0x0201f000, + 0x000207a1, 0x592c0005, 0x82000580, 0x01000000, + 0x02020000, 0x001022c0, 0x4a034406, 0x00000004, + 0x0201f000, 0x0010230c, 0x497b4406, 0x497b4207, + 0x0201f800, 0x00103b25, 0x04000008, 0x59a80066, + 0x59a8086a, 0x80040480, 0x59a80867, 0x48074406, + 0x80041480, 0x480b4207, 0x49674407, 0x59a8000e, + 0x48034209, 0x495f4409, 0x59a80020, 0x4803420b, + 0x0201f000, 0x001022c0, 0x800409c0, 0x04000005, + 0x4a034406, 0x00000001, 0x0201f000, 0x0010230c, + 0x59a00406, 0x8c000500, 0x0402000f, 0x59a80069, + 0x81640480, 0x04001008, 0x59a8000b, 0x81500580, + 0x04000009, 0x59a8006a, 0x59a81066, 0x80080580, + 0x04000005, 0x4a034406, 0x00000018, 0x0201f000, + 0x0010230c, 0x82000540, 0x00000001, 0x0201f800, + 0x001015fe, 0x0201f800, 0x00103c80, 0x0201f000, + 0x001022c0, 0x4803c856, 0x800409c0, 0x02020000, + 0x00102314, 0x59a00406, 0x8c00051e, 0x04000008, + 0x4803c856, 0x59a0020b, 0x82000480, 0x00000800, + 0x04001015, 0x0201f000, 0x00102310, 0x4803c856, + 0x59a0020b, 0x599c0a01, 0x80040480, 0x04021003, + 0x0201f000, 0x00102310, 0x59a8000e, 0x81640580, + 0x04000009, 0x4a034406, 0x00000018, 0x0201f000, + 0x0010230c, 0x4a034406, 0x00000005, 0x0201f000, + 0x0010230c, 0x59a80026, 0x8c00050a, 0x040007fa, + 0x59a00406, 0x8c00051e, 0x04000036, 0x0201f800, + 0x0002075a, 0x040007f4, 0x0201f800, 0x00103a00, + 0x040007f1, 0x497a5a04, 0x59a00406, 0x4802620a, + 0x59a00209, 0x4802640a, 0x59a00409, 0x4802620b, + 0x59a0020d, 0x4802620c, 0x59a0040d, 0x4802640c, + 0x59a0020e, 0x4802620d, 0x59a0040e, 0x4802640d, + 0x59a00210, 0x4802620e, 0x59a00410, 0x4802640e, + 0x59a0020b, 0x82000500, 0x0000fffc, 0x80000104, + 0x4802640b, 0x0401f9d9, 0x040007d7, 0x48ee6021, + 0x58ee580d, 0x5930020e, 0x59301c0e, 0x900c19c0, + 0x800c1d40, 0x5930020c, 0x5930140c, 0x900811c0, + 0x80081540, 0x592c0a05, 0x832c0400, 0x00000006, + 0x0201f800, 0x00103a25, 0x4a01d809, 0x001029e5, + 0x4a034000, 0x00000001, 0x49334001, 0x1c01f000, + 0x0201f800, 0x00106c55, 0x0201f800, 0x00100ae0, + 0x0401f86d, 0x497b5057, 0x4201d000, 0x00002710, + 0x0201f800, 0x001060c6, 0x59c40880, 0x4c040000, + 0x59c408a3, 0x4c040000, 0x497b4002, 0x0401f876, + 0x0401f893, 0x4a03a005, 0x10000000, 0x0401f8b4, + 0x0401f901, 0x04000048, 0x59c80001, 0x800001c0, + 0x040007fc, 0x59c80018, 0x82000500, 0xf0000000, + 0x59c00808, 0x82040d00, 0x0fffffff, 0x80040540, + 0x48038008, 0x0201f800, 0x00100ec1, 0x59c00006, + 0x4a038006, 0x10000000, 0x59c00009, 0x82000d00, + 0x00e00000, 0x04020024, 0x4a03900d, 0x00000000, + 0x59c80020, 0x82000500, 0xff000000, 0x82000580, + 0x32000000, 0x0402001c, 0x4a03900d, 0x00000001, + 0x59c80020, 0x82000500, 0xff000000, 0x82000580, + 0xe1000000, 0x04020014, 0x4a03900d, 0x00000000, + 0x59c80020, 0x82000500, 0x00ffffff, 0x4a03900d, + 0x00000000, 0x59c80821, 0x82040d00, 0x00ffffff, + 0x80040580, 0x04020008, 0x59a80010, 0x80040580, + 0x04020005, 0x59c40005, 0x82000500, 0x000000f0, + 0x04000006, 0x4803c856, 0x0401f8d7, 0x4a035057, + 0x00000001, 0x0401f002, 0x0401f8e1, 0x42000000, + 0x00000064, 0x80000040, 0x02000800, 0x001005d8, + 0x59c00807, 0x82040d00, 0x0000000c, 0x040007fa, + 0x0401f003, 0x4a035057, 0x00000001, 0x0401f8da, + 0x0201f800, 0x00106f36, 0x0401f818, 0x4201d000, + 0x000186a0, 0x0201f800, 0x001060c6, 0x5c000800, + 0x480788a3, 0x5c000800, 0x48078880, 0x59a80057, + 0x800001c0, 0x02000000, 0x001022c0, 0x0201f000, + 0x00102318, 0x599c0201, 0x48035059, 0x41780800, + 0x42001000, 0x00003b10, 0x0201f800, 0x001066a0, + 0x480b505a, 0x1c01f000, 0x0201f800, 0x00106c4b, + 0x59b800ea, 0x82000500, 0x00000007, 0x82000580, + 0x00000003, 0x04020003, 0x4a0370e8, 0x00000001, + 0x1c01f000, 0x42038000, 0x00007700, 0x4a038006, + 0x30000000, 0x59c00007, 0x8c00050a, 0x040207fe, + 0x59c00006, 0x59a00209, 0x59a00c09, 0x900409c0, + 0x80040d40, 0x48078001, 0x59a0020e, 0x59a00c0e, + 0x900409c0, 0x80040d40, 0x48078000, 0x59a0020b, + 0x82000500, 0x0000fffc, 0x48038002, 0x48038003, + 0x48038005, 0x497b9009, 0x59e00003, 0x82000540, + 0x00008060, 0x4803c003, 0x1c01f000, 0x41780800, + 0x8007a0ca, 0x83d3a400, 0x00007600, 0x42000800, + 0x00000040, 0x0201f800, 0x00101345, 0x4a03a00a, + 0x00000001, 0x4a03a005, 0x20000000, 0x59d00006, + 0x4a03a005, 0x30000000, 0x59d00006, 0x8c00050a, + 0x040207fe, 0x59d00005, 0x59a00210, 0x59a00c10, + 0x900409c0, 0x80040d40, 0x4807a001, 0x59a0020d, + 0x59a00c0d, 0x900409c0, 0x80040d40, 0x4807a000, + 0x59a0020b, 0x82000500, 0x0000fffc, 0x4803a003, + 0x4803a002, 0x4803a008, 0x1c01f000, 0x59a00002, + 0x4803c857, 0x800001c0, 0x0402004a, 0x59a8005a, + 0x48038880, 0x59c400a3, 0x82000540, 0x00002008, + 0x8400053a, 0x480388a3, 0x59c40008, 0x8400054e, + 0x82000500, 0xffffffe1, 0x48038808, 0x59c80040, + 0x84000534, 0x48039040, 0x0401f902, 0x04020013, + 0x59a80010, 0x800000d0, 0x82000540, 0x00000011, + 0x48039120, 0x59a80010, 0x82000500, 0x00ffffff, + 0x82000540, 0x32000000, 0x48039121, 0x4a039123, + 0xe1290008, 0x59a80010, 0x82000500, 0x00ffffff, + 0x48039122, 0x0401f016, 0x59a80010, 0x82000500, + 0x000000ff, 0x900009c0, 0x840001c0, 0x80040540, + 0x82000540, 0x00000000, 0x48039120, 0x59a80010, + 0x82000500, 0x000000ff, 0x82000540, 0x01000000, + 0x48039121, 0x4a039123, 0x08210008, 0x59a80010, + 0x82000500, 0x000000ff, 0x48039122, 0x497b9124, + 0x59a80c5b, 0x80040800, 0x4807545b, 0x900409c0, + 0x82040540, 0x0000aaaa, 0x48039125, 0x497b9126, + 0x497b9127, 0x0401f8cf, 0x04020004, 0x4a039100, + 0x0000e980, 0x0401f003, 0x4a039100, 0x0000e9a0, + 0x1c01f000, 0x82000540, 0x00000001, 0x0402500d, + 0x4203e000, 0x80000000, 0x40e81000, 0x41780800, + 0x42000000, 0x00000064, 0x0201f800, 0x001066a0, + 0x59940024, 0x80080400, 0x48032824, 0x80000580, + 0x1c01f000, 0x4d900000, 0x4dd00000, 0x4da40000, + 0x4d140000, 0x417a3000, 0x0201f800, 0x001070d8, + 0x0201f800, 0x00106dc3, 0x5c022800, 0x5c034800, + 0x5c03a000, 0x5c032000, 0x1c01f000, 0x59c80007, + 0x8c000500, 0x04000003, 0x4a03900d, 0x00000030, + 0x1c01f000, 0x4a038805, 0x00020000, 0x42000800, + 0x0000003c, 0x0201f800, 0x00101345, 0x4a038891, + 0x0000ffff, 0x59c80035, 0x48039035, 0x4a03900d, + 0x00000040, 0x42038000, 0x00007700, 0x0201f800, + 0x00100ec1, 0x42038000, 0x00007720, 0x0201f800, + 0x00100ec1, 0x4a03a005, 0x20000000, 0x4a03a005, + 0x30000000, 0x59d00806, 0x8c040d0a, 0x040207fe, + 0x1c01f000, 0x4d300000, 0x4031d800, 0x58ef400b, + 0x58ee580d, 0x58ec0002, 0x82000580, 0x00000200, + 0x5c026000, 0x02000000, 0x00102304, 0x4d300000, + 0x59a26001, 0x59a00000, 0x4000b000, 0x80000000, + 0x48034000, 0x592c0001, 0x80000540, 0x0400001e, + 0x40025800, 0x8058b040, 0x040207fb, 0x58ec1007, + 0x58ec1808, 0x592c0a05, 0x4d2c0000, 0x58ec000d, + 0x40025800, 0x592c0204, 0x5c025800, 0x82000580, + 0x00000103, 0x04000008, 0x832c0400, 0x00000006, + 0x0201f800, 0x00103a25, 0x4a01d809, 0x001029e5, + 0x0401f007, 0x832c0400, 0x00000006, 0x0201f800, + 0x00103a28, 0x4a01d809, 0x001029e5, 0x5c026000, + 0x1c01f000, 0x58ec000d, 0x40025800, 0x592c0204, + 0x82000580, 0x00000103, 0x04020006, 0x0201f800, + 0x0002077d, 0x5c026000, 0x0201f000, 0x001022c0, + 0x58ec000d, 0x40025800, 0x592c0404, 0x8400055e, + 0x48025c04, 0x42028800, 0x000007fd, 0x42003000, + 0x00fffffd, 0x0201f800, 0x001045a6, 0x04000003, + 0x80000580, 0x0401f004, 0x59a26001, 0x0201f800, + 0x0010937d, 0x5c026000, 0x02000000, 0x0010230c, + 0x4d300000, 0x4a01d809, 0x00102a38, 0x0401f7dc, + 0x592c0005, 0x82000580, 0x01000000, 0x02000000, + 0x00102318, 0x4d300000, 0x59a26001, 0x5930020b, + 0x59301c0a, 0x900001c0, 0x800c1d40, 0x5930040d, + 0x5930120d, 0x900001c0, 0x80081540, 0x592c0a05, + 0x832c0400, 0x00000006, 0x0201f800, 0x00103a28, + 0x4a01d809, 0x001029e5, 0x4a034000, 0x00000001, + 0x5c026000, 0x1c01f000, 0x4933c857, 0x4c300000, + 0x5930040b, 0x82000c80, 0x0000000e, 0x04001004, + 0x4a025a05, 0x0000000e, 0x0401f003, 0x48025a05, + 0x0401f00c, 0x800409c0, 0x0400000a, 0x4c040000, + 0x0201f800, 0x00103a00, 0x5c000800, 0x04000003, + 0x40040000, 0x0401f7f0, 0x80000580, 0x0401f003, + 0x82000540, 0x00000001, 0x5c006000, 0x1c01f000, + 0x59a00206, 0x82000580, 0x00000044, 0x1c01f000, + 0x4807c857, 0x800409c0, 0x0400000c, 0x0201f800, + 0x00101650, 0x04020009, 0x42000000, 0x00000002, + 0x0201f800, 0x0010188c, 0x42000000, 0x00000002, + 0x0201f800, 0x00101821, 0x59a00406, 0x82000500, + 0x00000007, 0x0c01f001, 0x00102a8c, 0x00102aa1, + 0x00102ab7, 0x00102a8a, 0x00102a8a, 0x00102a8a, + 0x00102a8a, 0x00102a8a, 0x0201f000, 0x00102310, + 0x42000800, 0x000000c0, 0x0201f800, 0x0010193f, + 0x82040540, 0x00000002, 0x42000800, 0x000000c0, + 0x0201f800, 0x00101944, 0x42000800, 0x00000000, + 0x0201f800, 0x0010193f, 0x82040540, 0x00000008, + 0x42000800, 0x00000000, 0x0201f800, 0x00101944, + 0x0401f00b, 0x42000800, 0x000000c0, 0x0201f800, + 0x0010193f, 0x82040540, 0x00000001, 0x42000800, + 0x000000c0, 0x0201f800, 0x00101944, 0x59c80040, + 0x4c000000, 0x59a80010, 0x4c000000, 0x59c400a3, + 0x4c000000, 0x59c40008, 0x4c000000, 0x0401f911, + 0x04000021, 0x0201f800, 0x001005d8, 0x59a80821, + 0x800409c0, 0x02020000, 0x00102314, 0x0201f800, + 0x0010513b, 0x04020005, 0x4a034406, 0x00000016, + 0x0201f000, 0x0010230c, 0x836c0580, 0x00000003, + 0x02020000, 0x00102314, 0x59c408a4, 0x82040d00, + 0x0000000f, 0x82040580, 0x00000000, 0x02020000, + 0x00102314, 0x59c80040, 0x4c000000, 0x59a80010, + 0x4c000000, 0x59c400a3, 0x4c000000, 0x59c40008, + 0x4c000000, 0x59c40080, 0x4c000000, 0x59a0020f, + 0x59a0bc0f, 0x905cb9c0, 0x805cbd40, 0x41784800, + 0x41785000, 0x41785800, 0x41789000, 0x41789800, + 0x0401fe21, 0x0201f800, 0x00106c55, 0x0201f800, + 0x00100ae0, 0x4178c000, 0x497b4002, 0x0401f95c, + 0x0401f9aa, 0x59a0020c, 0x59a00c0c, 0x80040d40, + 0x04000002, 0x0401f9fb, 0x0401f9fa, 0x0401fe68, + 0x8060c1c0, 0x04020014, 0x0401fa98, 0x0401feb2, + 0x0402000e, 0x0201f800, 0x001018d3, 0x04020008, + 0x4a034406, 0x00000017, 0x0201f800, 0x0010230c, + 0x4203e000, 0x50000000, 0x0401f000, 0x42005800, + 0x0000aaaa, 0x0401f058, 0x59c80001, 0x800001c0, + 0x040007ee, 0x59c80801, 0x800409c0, 0x04000006, + 0x0401fa70, 0x40240000, 0x80280540, 0x802c0540, + 0x0402004d, 0x59a00002, 0x82000580, 0xfeedbeef, + 0x04000004, 0x42008800, 0x10000000, 0x0401f003, + 0x42008800, 0x10000004, 0x0401fa19, 0x4a034002, + 0xfeedbeef, 0x0401fa71, 0x0401fa97, 0x0401fea8, + 0x59c40005, 0x8c000534, 0x04000004, 0x42005800, + 0x0000bbbb, 0x0401f038, 0x0401fe83, 0x04020007, + 0x42005800, 0x0000cccc, 0x485f420f, 0x905cb9c0, + 0x485f440f, 0x0401f030, 0x59a0040c, 0x800001c0, + 0x0400000e, 0x59a26000, 0x5930000d, 0x800001c0, + 0x040207be, 0x59a26001, 0x5930080d, 0x800409c0, + 0x040207ba, 0x804891c0, 0x040207b8, 0x804c99c0, + 0x040207b6, 0x0401f87a, 0x805cb840, 0x04000005, + 0x40240000, 0x80280540, 0x802c0540, 0x0402001a, + 0x42000000, 0x00030d40, 0x80000040, 0x04020012, + 0x59c00007, 0x82000500, 0x000501c0, 0x0402000b, + 0x0201f800, 0x001018d3, 0x04020008, 0x4a034406, + 0x00000017, 0x0201f800, 0x0010230c, 0x4203e000, + 0x50000000, 0x0401f000, 0x42005800, 0x0000dddd, + 0x0401f005, 0x59c00807, 0x82040d00, 0x0000000c, + 0x040007ea, 0x0401fe5c, 0x59a0040c, 0x800001c0, + 0x04000002, 0x0401f856, 0x0401fe6b, 0x40240000, + 0x80280540, 0x802c0540, 0x04020003, 0x805cb9c0, + 0x04020781, 0x0201f800, 0x00106f36, 0x0401fda3, + 0x4201d000, 0x000186a0, 0x0201f800, 0x001060c6, + 0x5c000800, 0x48078880, 0x5c000800, 0x48078808, + 0x5c000800, 0x480788a3, 0x5c000800, 0x48075010, + 0x5c000800, 0x48079040, 0x0201f800, 0x00100969, + 0x59a00406, 0x82000500, 0x00000003, 0x82000580, + 0x00000002, 0x0400002c, 0x42000800, 0x000000c0, + 0x0201f800, 0x0010193f, 0x82040500, 0xfffffffc, + 0x42000800, 0x000000c0, 0x0201f800, 0x00101944, + 0x42000800, 0x00000000, 0x0201f800, 0x0010193f, + 0x82040500, 0xfffffff7, 0x42000800, 0x00000000, + 0x0201f800, 0x00101944, 0x42000800, 0x00000000, + 0x0201f800, 0x0010193f, 0x82040500, 0xfffffffb, + 0x42000800, 0x00000000, 0x0201f800, 0x00101944, + 0x4a0388a7, 0x0000f7f7, 0x42006000, 0xbeffffff, + 0x42006800, 0x80018000, 0x0201f800, 0x0010427d, + 0x42006000, 0xfffeffff, 0x41786800, 0x0201f800, + 0x0010427d, 0x402c0000, 0x80280540, 0x80240540, + 0x02000000, 0x001022c0, 0x48274406, 0x482b4207, + 0x482f4407, 0x0201f000, 0x0010231c, 0x59a26000, + 0x813261c0, 0x0400000e, 0x59325808, 0x812e59c0, + 0x0400000b, 0x0201f800, 0x0002077d, 0x0201f800, + 0x001007fd, 0x59a26001, 0x59325808, 0x0201f800, + 0x0002077d, 0x0201f800, 0x001007fd, 0x1c01f000, + 0x42000800, 0x000000ef, 0x0201f800, 0x001015eb, + 0x59c400a3, 0x8400055a, 0x8400053a, 0x480388a3, + 0x0201f800, 0x0010163b, 0x0402000a, 0x42000000, + 0x00000001, 0x0201f800, 0x0010188c, 0x42000000, + 0x00000001, 0x0201f800, 0x00101821, 0x0401f013, + 0x0201f800, 0x00101642, 0x04020008, 0x41780000, + 0x0201f800, 0x0010188c, 0x41780000, 0x0201f800, + 0x00101821, 0x0401f009, 0x42000000, 0x00000002, + 0x0201f800, 0x0010188c, 0x42000000, 0x00000002, + 0x0201f800, 0x00101821, 0x42000800, 0x00000000, + 0x0201f800, 0x0010193f, 0x82040540, 0x00000004, + 0x42000800, 0x00000000, 0x0201f800, 0x00101944, + 0x4201d000, 0x00000014, 0x0201f800, 0x0010608e, + 0x59c40008, 0x8400054e, 0x82000500, 0xffffffe1, + 0x48038808, 0x4a0388a7, 0x0000f7f7, 0x42001000, + 0x04000001, 0x0201f800, 0x0010193d, 0x42006000, + 0xbe20bfff, 0x42006800, 0x80018000, 0x0201f800, + 0x0010427d, 0x42006000, 0xfffeffff, 0x41786800, + 0x0201f800, 0x0010427d, 0x4200b000, 0x00001388, + 0x4201d000, 0x00000014, 0x4c580000, 0x0201f800, + 0x0010608e, 0x0201f800, 0x001018d3, 0x5c00b000, + 0x04000004, 0x8058b040, 0x040207f6, 0x0401f025, + 0x59c40005, 0x8c000534, 0x04020007, 0x59c400a4, + 0x82000500, 0x0000000f, 0x82000580, 0x00000008, + 0x0402001c, 0x42006000, 0x00020000, 0x0201f800, + 0x00104282, 0x4201d000, 0x00000064, 0x0201f800, + 0x0010608e, 0x42006000, 0xfeffffff, 0x42006800, + 0x02000000, 0x0201f800, 0x0010427d, 0x42006000, + 0xfdffffff, 0x41786800, 0x0201f800, 0x0010427d, + 0x4a038805, 0x04000001, 0x59c400a4, 0x82000500, + 0x0000000f, 0x82000580, 0x00000000, 0x04000003, + 0x82000540, 0x00000001, 0x1c01f000, 0x4803c856, + 0x42038000, 0x00007700, 0x0201f800, 0x00100ec1, + 0x59c00006, 0x59a0040c, 0x800001c0, 0x0400003f, + 0x59a03c0c, 0x59a00209, 0x59a01c09, 0x900c19c0, + 0x800c1d40, 0x59a0020e, 0x59a0240e, 0x901021c0, + 0x80102540, 0x59a0020b, 0x82000500, 0x0000fffc, + 0x59a0140b, 0x900811c0, 0x80081540, 0x480b8003, + 0x0201f800, 0x0002075a, 0x02000800, 0x001005d8, + 0x49334000, 0x0201f800, 0x001007e4, 0x4a025a04, + 0x00000018, 0x4a025805, 0x00abcdef, 0x492e6008, + 0x492e600b, 0x481e600d, 0x4a02600c, 0x00000004, + 0x832c0400, 0x00000011, 0x4802600a, 0x42001000, + 0x0000000c, 0x821c0d80, 0x00000001, 0x04000004, + 0x801c3840, 0x0401f963, 0x0401f004, 0x41783800, + 0x0401f960, 0x0401f011, 0x821c0c80, 0x00000005, + 0x04001005, 0x40043800, 0x42001000, 0x0000003c, + 0x0401f006, 0x80001580, 0x82081400, 0x0000000c, + 0x801c3840, 0x040207fd, 0x832c0400, 0x00000005, + 0x0401f950, 0x040207f1, 0x497b9009, 0x59e00003, + 0x82000540, 0x00008060, 0x4803c003, 0x4a038009, + 0x00e00000, 0x1c01f000, 0x4803c856, 0x41780800, + 0x8007a0ca, 0x83d3a400, 0x00007600, 0x42000800, + 0x00000040, 0x0201f800, 0x00101345, 0x4a03a00a, + 0x00000001, 0x4a03a005, 0x20000000, 0x59d00006, + 0x4a03a005, 0x30000000, 0x59d00006, 0x8c00050a, + 0x040207fe, 0x59d00005, 0x59a0020c, 0x800001c0, + 0x0400003f, 0x59a03a0c, 0x59a00210, 0x59a01c10, + 0x900c19c0, 0x800c1d40, 0x59a0020d, 0x59a0240d, + 0x901021c0, 0x80102540, 0x59a0120b, 0x82081500, + 0x0000fffc, 0x59a0040b, 0x900001c0, 0x80081540, + 0x480ba003, 0x0201f800, 0x0002075a, 0x02000800, + 0x001005d8, 0x49334001, 0x0201f800, 0x001007e4, + 0x4a025a04, 0x00000018, 0x4a025805, 0x00abcdef, + 0x492e6008, 0x492e600b, 0x481e600d, 0x4a02600c, + 0x00000004, 0x832c0400, 0x00000011, 0x4802600a, + 0x42001000, 0x0000000c, 0x821c0d80, 0x00000001, + 0x04000004, 0x801c3840, 0x0401f906, 0x0401f004, + 0x41783800, 0x0401f903, 0x0401f011, 0x821c0c80, + 0x00000005, 0x04001005, 0x40043800, 0x42001000, + 0x0000003c, 0x0401f006, 0x80001580, 0x82081400, + 0x0000000c, 0x801c3840, 0x040207fd, 0x832c0400, + 0x00000005, 0x0401f8f3, 0x040207f1, 0x1c01f000, + 0x4803c856, 0x59a0020c, 0x800001c0, 0x04000024, + 0x824c0580, 0x00000002, 0x04000040, 0x59a26001, + 0x5930380d, 0x801c39c0, 0x0400003c, 0x801c3840, + 0x481e600d, 0x5932580b, 0x5930080a, 0x50042000, + 0x58041801, 0x58041002, 0x82081500, 0xfffffffc, + 0x5930000c, 0x80000000, 0x82000d80, 0x00000005, + 0x04020009, 0x497a600c, 0x592e5801, 0x812e59c0, + 0x0400001a, 0x492e600b, 0x832c0c00, 0x00000005, + 0x0401f005, 0x4802600c, 0x5930080a, 0x82040c00, + 0x00000003, 0x4806600a, 0x0401f010, 0x59a0120b, + 0x82081500, 0x0000fffc, 0x59a0040b, 0x900001c0, + 0x80081540, 0x480ba003, 0x59a0020d, 0x59a0240d, + 0x901021c0, 0x80102540, 0x59a00210, 0x59a01c10, + 0x900c19c0, 0x800c1d40, 0x4201d000, 0x00003a98, + 0x0201f800, 0x001060c6, 0x480ba002, 0x59a80059, + 0x4803a008, 0x4813a000, 0x480fa001, 0x4a03a005, + 0x10000000, 0x02005800, 0x001005d8, 0x804c9800, + 0x82000540, 0x00000001, 0x1c01f000, 0x4847c857, + 0x59a0040c, 0x800001c0, 0x04000024, 0x82480580, + 0x00000002, 0x04000042, 0x59a26000, 0x5930380d, + 0x801c39c0, 0x0400003e, 0x801c3840, 0x481e600d, + 0x5932580b, 0x5930080a, 0x50042000, 0x58041801, + 0x58041002, 0x82081500, 0xfffffffc, 0x5930000c, + 0x80000000, 0x82000d80, 0x00000005, 0x04020009, + 0x497a600c, 0x592e5801, 0x812e59c0, 0x0400001d, + 0x492e600b, 0x832c0c00, 0x00000005, 0x0401f005, + 0x4802600c, 0x5930080a, 0x82040c00, 0x00000003, + 0x4806600a, 0x0401f013, 0x82440580, 0x10000000, + 0x0402001f, 0x59a0020e, 0x59a0240e, 0x901021c0, + 0x80102540, 0x59a00209, 0x59a01c09, 0x900c19c0, + 0x800c1d40, 0x59a0020b, 0x82000500, 0x0000fffc, + 0x59a0140b, 0x900811c0, 0x80081540, 0x480b8003, + 0x48138000, 0x480f8001, 0x480b8002, 0x59c80018, + 0x82000500, 0xf0000000, 0x59c02008, 0x82102500, + 0x0fffffff, 0x80100540, 0x48038008, 0x48478006, + 0x80489000, 0x8260c540, 0x00000001, 0x1c01f000, + 0x59c00009, 0x4803c857, 0x82000d00, 0x00e00000, + 0x0400000d, 0x485f420f, 0x905cb9c0, 0x485f440f, + 0x8c00052e, 0x04000002, 0x80285000, 0x8c00052c, + 0x04000002, 0x80244800, 0x8c00052a, 0x04000002, + 0x802c5800, 0x1c01f000, 0x59a0020c, 0x800001c0, + 0x04000024, 0x59d00806, 0x4807c857, 0x8c040d3e, + 0x04000020, 0x4a03a005, 0x20000000, 0x4a03a005, + 0x30000000, 0x59d00806, 0x8c040d0a, 0x040207fe, + 0x824c0480, 0x00000003, 0x02021800, 0x001005d8, + 0x404c0000, 0x0c01f001, 0x00102da1, 0x00102da3, + 0x00102da9, 0x0201f800, 0x001005d8, 0x80000040, + 0x40009800, 0x0401ff43, 0x0400000a, 0x0401ff41, + 0x0401f008, 0x80000040, 0x40009800, 0x59d00806, + 0x4807c857, 0x8c040d3e, 0x040207e3, 0x0401ff39, + 0x1c01f000, 0x59a0040c, 0x800001c0, 0x04000024, + 0x59c00807, 0x4807c857, 0x8c040d3e, 0x04000020, + 0x59c00807, 0x4a038006, 0x20000000, 0x82480480, + 0x00000003, 0x02021800, 0x001005d8, 0x40480000, + 0x0c01f001, 0x00102dc4, 0x00102dc6, 0x00102dce, + 0x0201f800, 0x001005d8, 0x80000040, 0x40009000, + 0x42008800, 0x10000004, 0x0401ff65, 0x0400000c, + 0x0401ff63, 0x0401f00a, 0x80000040, 0x40009000, + 0x59c00807, 0x4807c857, 0x8c040d3e, 0x040207e5, + 0x42008800, 0x10000004, 0x0401ff59, 0x1c01f000, + 0x492fc857, 0x4000a800, 0x4a03b805, 0x20000000, + 0x59dc0006, 0x4a03b805, 0x30000000, 0x4813b800, + 0x480fb801, 0x480bb802, 0x4857b803, 0x4a03b805, + 0x30000002, 0x59dc0006, 0x4a03b805, 0x70000001, + 0x59dc0006, 0x4a03b805, 0x10000000, 0x59dc0006, + 0x8c00053e, 0x040007fe, 0x4a03b805, 0x20000000, + 0x59dc0006, 0x59dc2000, 0x59dc1801, 0x801c39c0, + 0x0400000a, 0x4d2c0000, 0x0201f800, 0x001007e4, + 0x5c000800, 0x02000800, 0x001005d8, 0x4a025a04, + 0x0000000a, 0x492c0801, 0x1c01f000, 0x42006000, + 0x00102fb2, 0x0201f800, 0x00101345, 0x4a03902c, + 0x00200000, 0x4200b000, 0x000001f4, 0x59c8002c, + 0x8c00052c, 0x04000007, 0x8058b040, 0x040207fc, + 0x42000000, 0x00004003, 0x41781000, 0x0401f196, + 0x50301000, 0x41784800, 0x4a03902d, 0x00008000, + 0x4200b000, 0x000001f4, 0x59c8002c, 0x8c000534, + 0x04000007, 0x8058b040, 0x040207fc, 0x42000000, + 0x00004003, 0x41781000, 0x0401f187, 0x0401f8f8, + 0x80244800, 0x40240000, 0x82000580, 0x000003b1, + 0x040207fb, 0x0401f988, 0x41784800, 0x0401f920, + 0x80244800, 0x40240000, 0x82000580, 0x000003b1, + 0x040207fb, 0x80306000, 0x82300580, 0x00102fb4, + 0x040207e0, 0x59a80863, 0x800409c0, 0x04000007, + 0x42000000, 0x00004004, 0x42001000, 0x00000002, + 0x59a81862, 0x0401f16c, 0x42006000, 0x00102fb2, + 0x4a035064, 0x00000004, 0x50301000, 0x41784800, + 0x4a03902d, 0x00004000, 0x4200b000, 0x000001f4, + 0x59c8002c, 0x8c000532, 0x04000007, 0x8058b040, + 0x040207fc, 0x42000000, 0x00004003, 0x41781000, + 0x0401f159, 0x0401f8ca, 0x80244800, 0x40240000, + 0x82000580, 0x00000154, 0x040207fb, 0x0401f95a, + 0x41784800, 0x0401f8f2, 0x80244800, 0x40240000, + 0x82000580, 0x00000154, 0x040207fb, 0x80306000, + 0x82300580, 0x00102fb4, 0x040207e0, 0x59a80863, + 0x800409c0, 0x04000007, 0x42000000, 0x00004004, + 0x42001000, 0x00000004, 0x59a81862, 0x0401f13e, + 0x42006000, 0x00102fb2, 0x497b5064, 0x50301000, + 0x41784800, 0x4a03902d, 0x00001000, 0x4200b000, + 0x000001f4, 0x59c8002c, 0x8c00052e, 0x04000007, + 0x8058b040, 0x040207fc, 0x42000000, 0x00004003, + 0x41781000, 0x0401f12c, 0x0401f89d, 0x80244800, + 0x40240000, 0x82000580, 0x00000088, 0x040207fb, + 0x0401f92d, 0x41784800, 0x0401f8c5, 0x80244800, + 0x40240000, 0x82000580, 0x00000088, 0x040207fb, + 0x80306000, 0x82300580, 0x00102fb4, 0x040207e0, + 0x59a80863, 0x800409c0, 0x04000007, 0x42000000, + 0x00004004, 0x42001000, 0x00000001, 0x59a81862, + 0x0401f111, 0x42006000, 0x00102fb2, 0x50301000, + 0x41784800, 0x4a03902d, 0x00000800, 0x0401f87c, + 0x80244800, 0x40240000, 0x82000580, 0x00000018, + 0x040207fb, 0x0401f90c, 0x41784800, 0x0401f8a4, + 0x80244800, 0x40240000, 0x82000580, 0x00000018, + 0x040207fb, 0x80306000, 0x82300580, 0x00102fb4, + 0x040207eb, 0x59a80863, 0x800409c0, 0x04000007, + 0x42000000, 0x00004004, 0x42001000, 0x00000010, + 0x59a81862, 0x0401f0f0, 0x42006000, 0x00102fb2, + 0x50301000, 0x41784800, 0x4a03902d, 0x00000400, + 0x0401f85b, 0x80244800, 0x40240000, 0x82000580, + 0x00000088, 0x040207fb, 0x0401f8eb, 0x41784800, + 0x0401f883, 0x80244800, 0x40240000, 0x82000580, + 0x00000088, 0x040207fb, 0x80306000, 0x82300580, + 0x00102fb4, 0x040207eb, 0x59a80863, 0x800409c0, + 0x04000007, 0x42000000, 0x00004004, 0x42001000, + 0x00000008, 0x59a81862, 0x0401f0cf, 0x42006000, + 0x00102fb2, 0x50301000, 0x41784800, 0x4a03902d, + 0x00002000, 0x4200b000, 0x000001f4, 0x59c8002c, + 0x8c000530, 0x04000007, 0x8058b040, 0x040207fc, + 0x42000000, 0x00004003, 0x41781000, 0x0401f0be, + 0x59c8002c, 0x82000500, 0xffe0ffff, 0x82080d00, + 0x001f0000, 0x80040540, 0x4803902c, 0x0401f828, + 0x80244800, 0x40240000, 0x82000580, 0x00000110, + 0x040207fb, 0x0401f8b8, 0x41784800, 0x0401f850, + 0x59c80034, 0x82080d00, 0x001f0000, 0x82000500, + 0x001f0000, 0x80040580, 0x04000006, 0x59a80063, + 0x80000000, 0x48035063, 0x40240000, 0x48035062, + 0x80244800, 0x40240000, 0x82000580, 0x00000110, + 0x040207ef, 0x80306000, 0x82300580, 0x00102fb4, + 0x040207cd, 0x59a80863, 0x800409c0, 0x04000006, + 0x42000000, 0x00004004, 0x42001000, 0x00000020, + 0x59a81862, 0x0201f000, 0x001022c0, 0x59c8002c, + 0x82000500, 0xffff0000, 0x82080d00, 0x0000ffff, + 0x80040540, 0x4803902c, 0x40080000, 0x48039028, + 0x48039029, 0x59a80064, 0x82000580, 0x00000004, + 0x04000004, 0x40080000, 0x4803902a, 0x4803902b, + 0x59c8082d, 0x82040d00, 0xfffffc00, 0x40240000, + 0x80040d40, 0x4807902d, 0x4200b000, 0x000001f4, + 0x59c8002c, 0x82000500, 0x18000000, 0x04000007, + 0x8058b040, 0x040207fb, 0x42000000, 0x00004003, + 0x41781000, 0x0401f06c, 0x4a03902e, 0x00000001, + 0x4200b000, 0x000001f4, 0x59c8002e, 0x8c000500, + 0x04000006, 0x8058b040, 0x040207fc, 0x42000000, + 0x00004003, 0x0401f060, 0x1c01f000, 0x41783800, + 0x59c8082d, 0x82040d00, 0xfffffc00, 0x40240000, + 0x80040d40, 0x4807902d, 0x4200b000, 0x000001f4, + 0x59c8002c, 0x82000500, 0x18000000, 0x04000007, + 0x8058b040, 0x040207fb, 0x42000000, 0x00004003, + 0x41781000, 0x0401f04c, 0x59c80030, 0x59c80830, + 0x80040580, 0x040207fd, 0x40041800, 0x59c80031, + 0x59c80831, 0x80040580, 0x040207fd, 0x40042000, + 0x59c80032, 0x59c80832, 0x80040580, 0x040207fd, + 0x40042800, 0x59c80033, 0x59c80833, 0x80040580, + 0x040207fd, 0x40043000, 0x400c0000, 0x80080580, + 0x04000002, 0x801c3800, 0x40100000, 0x80080580, + 0x04000002, 0x801c3800, 0x59a80064, 0x82000580, + 0x00000004, 0x04000009, 0x40140000, 0x80080580, + 0x04000002, 0x801c3800, 0x40180000, 0x80080580, + 0x04000002, 0x801c3800, 0x59a80064, 0x82000580, + 0x00000004, 0x0400000d, 0x59c80034, 0x59c80834, + 0x80040580, 0x040207fd, 0x82040500, 0x0000ffff, + 0x82080d00, 0x0000ffff, 0x80040580, 0x0400000e, + 0x801c3800, 0x0401f00c, 0x59c80034, 0x59c80834, + 0x80040580, 0x040207fd, 0x82040500, 0x000000ff, + 0x82080d00, 0x000000ff, 0x80040580, 0x04000002, + 0x801c3800, 0x801c39c0, 0x04000006, 0x59a80063, + 0x801c0400, 0x48035063, 0x40240000, 0x48035062, + 0x1c01f000, 0x48034206, 0x48074406, 0x480b4207, + 0x480f4407, 0x48134208, 0x48174408, 0x0201f000, + 0x001022c3, 0x42000000, 0x00600000, 0x80000040, + 0x040207ff, 0x1c01f000, 0x5a5a5a5a, 0xa5a5a5a5, + 0x59a00c0a, 0x800409c0, 0x02000000, 0x00102310, + 0x82040480, 0x00000021, 0x02021000, 0x00102310, + 0x82040480, 0x00000011, 0x04001003, 0x42000800, + 0x00000010, 0x59a00208, 0x59a01407, 0x900811c0, + 0x80081540, 0x59a00207, 0x59a01c06, 0x900c19c0, + 0x800c1d40, 0x0201f800, 0x00103a00, 0x04000006, + 0x0201f800, 0x00103a25, 0x4a01d809, 0x00102fd5, + 0x1c01f000, 0x4a034406, 0x00000002, 0x0201f000, + 0x0010230c, 0x4031d800, 0x58ef400b, 0x58ec0002, + 0x82000580, 0x00000200, 0x02000000, 0x00102304, + 0x59a00c0a, 0x82040480, 0x00000011, 0x04001003, + 0x42000800, 0x00000010, 0x59a0040b, 0x59a0120b, + 0x900811c0, 0x80081540, 0x59a00209, 0x59a01c08, + 0x900c19c0, 0x800c1d40, 0x58ec0003, 0x0201f800, + 0x00103a28, 0x4a01d809, 0x00102ff0, 0x1c01f000, + 0x4031d800, 0x58ef400b, 0x58ec0002, 0x82000580, + 0x00000200, 0x02000000, 0x00102304, 0x59a00c0a, + 0x82040480, 0x00000011, 0x02001000, 0x001022c0, + 0x82040c80, 0x00000010, 0x59a00208, 0x59a01407, + 0x900811c0, 0x80081540, 0x59a00207, 0x59a01c06, + 0x900c19c0, 0x800c1d40, 0x82081400, 0x00000040, + 0x58ec0003, 0x0201f800, 0x00103a25, 0x4a01d809, + 0x0010300e, 0x1c01f000, 0x4031d800, 0x58ef400b, + 0x58ec0002, 0x82000580, 0x00000200, 0x02000000, + 0x00102304, 0x59a0040a, 0x82000c80, 0x00000010, + 0x59a0040b, 0x59a0120b, 0x900811c0, 0x80081540, + 0x59a00209, 0x59a01c08, 0x900c19c0, 0x800c1d40, + 0x82081400, 0x00000040, 0x58ec0003, 0x0201f800, + 0x00103a28, 0x4a01d809, 0x001022b9, 0x1c01f000, + 0x48efc857, 0x59a00207, 0x59a01407, 0x900001c0, + 0x80081540, 0x59a00209, 0x59a01c09, 0x900001c0, + 0x800c1d40, 0x59a00406, 0x48034000, 0x480b4001, + 0x480f4002, 0x0201f800, 0x00103a00, 0x04020005, + 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c, + 0x42000800, 0x00000010, 0x0201f800, 0x00103a25, + 0x4a01d809, 0x00103043, 0x1c01f000, 0x4031d800, + 0x58ef400b, 0x58ee580d, 0x58ec0002, 0x82000580, + 0x00000200, 0x02000000, 0x00102304, 0x48efc857, + 0x49a3c857, 0x492fc857, 0x592c0a04, 0x80040910, + 0x04020005, 0x4a034406, 0x00000019, 0x0201f000, + 0x0010230c, 0x4805d80c, 0x0401f00a, 0x4031d800, + 0x58ef400b, 0x58ec0002, 0x82000580, 0x00000200, + 0x02000000, 0x00102304, 0x48efc857, 0x49a3c857, + 0x48efc857, 0x49a3c857, 0x58ec000c, 0x80000040, + 0x04000012, 0x4801d80c, 0x0201f800, 0x00103a00, + 0x04020005, 0x4a034406, 0x00000002, 0x0201f000, + 0x0010230c, 0x42000800, 0x00000010, 0x58ec1007, + 0x58ec1808, 0x0201f800, 0x00103a25, 0x4a01d809, + 0x00103057, 0x1c01f000, 0x58ee580d, 0x48efc857, + 0x49a3c857, 0x492fc857, 0x492f3006, 0x592c0404, + 0x8400055e, 0x48025c04, 0x4a01d809, 0x00103081, + 0x1c01f000, 0x58ee580d, 0x48efc857, 0x49a3c857, + 0x492fc857, 0x592c0404, 0x8400051e, 0x48025c04, + 0x59a00000, 0x59a01001, 0x59a01802, 0x80081400, + 0x820c1c40, 0x00000000, 0x832c0400, 0x00000004, + 0x42000800, 0x00000010, 0x0201f000, 0x00103a28, + 0x800409c0, 0x04000005, 0x4a034406, 0x00000001, + 0x0201f000, 0x0010230c, 0x836c0580, 0x00000003, + 0x04000005, 0x4a034406, 0x00000007, 0x0201f000, + 0x0010230c, 0x59a0320b, 0x82183500, 0x000000ff, + 0x59a28c06, 0x0201f800, 0x00020245, 0x02020000, + 0x00102310, 0x83440580, 0x000007fd, 0x04000008, + 0x0201f800, 0x001049e7, 0x04000005, 0x4a034406, + 0x00000009, 0x0201f000, 0x0010230c, 0x0201f800, + 0x00103a00, 0x04020005, 0x4a034406, 0x00000002, + 0x0201f000, 0x0010230c, 0x801831c0, 0x0400000a, + 0x412c0800, 0x0201f800, 0x00103a00, 0x04020005, + 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c, + 0x40065800, 0x4a025c04, 0x00008000, 0x497a5a04, + 0x0201f800, 0x00109100, 0x04020005, 0x4a034406, + 0x00000003, 0x0201f000, 0x0010230c, 0x4a01d809, + 0x001030d2, 0x1c01f000, 0x592c0005, 0x82000580, + 0x01000000, 0x04020005, 0x4a034406, 0x00000004, + 0x0201f000, 0x0010230c, 0x592c0406, 0x82002d00, + 0x0000ff00, 0x82000500, 0x000000ff, 0x80000904, + 0x80040800, 0x82040480, 0x00000006, 0x04001003, + 0x42000800, 0x00000005, 0x832ca400, 0x00000006, + 0x4050a800, 0x4004b000, 0x0201f800, 0x0010ab28, + 0x59a00407, 0x59a01207, 0x900811c0, 0x80081540, + 0x59a00409, 0x59a01a09, 0x900c19c0, 0x800c1d40, + 0x832c0400, 0x00000006, 0x4c140000, 0x0201f800, + 0x00103a28, 0x5c002800, 0x801429c0, 0x04000003, + 0x4a01d809, 0x001030ff, 0x1c01f000, 0x4031d800, + 0x58ef400b, 0x58ee580d, 0x58ec0002, 0x82000580, + 0x00000200, 0x02000000, 0x00102304, 0x812e59c0, + 0x02000800, 0x001005d8, 0x592c0006, 0x82000500, + 0xff000000, 0x80000904, 0x800409c0, 0x02000000, + 0x00102304, 0x82040480, 0x0000000e, 0x04001003, + 0x42000800, 0x0000000d, 0x592e5801, 0x812e59c0, + 0x02000800, 0x001005d8, 0x832ca400, 0x00000005, + 0x4050a800, 0x4004b000, 0x0201f800, 0x0010ab28, + 0x58ec1007, 0x58ec1808, 0x832c0400, 0x00000005, + 0x0201f000, 0x00103a28, 0x0201f800, 0x00103a00, + 0x04020005, 0x4a034406, 0x00000002, 0x0201f000, + 0x0010230c, 0x59a00c06, 0x82040500, 0x0000ff00, + 0x840001c0, 0x82001480, 0x00000007, 0x02021000, + 0x00102310, 0x0c01f001, 0x0010313d, 0x00103144, + 0x0010314b, 0x0010314b, 0x0010314b, 0x0010314d, + 0x00103152, 0x42000800, 0x0000000d, 0x42003800, + 0x00103166, 0x4a034000, 0x0010b4eb, 0x0401f013, + 0x42000800, 0x0000000d, 0x42003800, 0x00103166, + 0x4a034000, 0x0010b4f8, 0x0401f00c, 0x0201f000, + 0x00102310, 0x42000800, 0x00000008, 0x42003800, + 0x00103179, 0x0401f005, 0x42000800, 0x00000004, + 0x42003800, 0x001031c3, 0x59a00207, 0x59a01407, + 0x900001c0, 0x80081540, 0x59a00209, 0x59a01c09, + 0x900001c0, 0x800c1d40, 0x832c0400, 0x00000005, + 0x4c1c0000, 0x0201f800, 0x00103a25, 0x5c003800, + 0x481dd809, 0x1c01f000, 0x4031d800, 0x58ef400b, + 0x58ee580d, 0x58ec0002, 0x82000580, 0x00000200, + 0x02000000, 0x00102304, 0x4a03501f, 0x00000001, + 0x4200b000, 0x0000000d, 0x59a0a800, 0x832ca400, + 0x00000005, 0x0201f800, 0x0010ab17, 0x0201f000, + 0x001022c0, 0x4031d800, 0x58ef400b, 0x58ee580d, + 0x58ec0002, 0x82000580, 0x00000200, 0x02000000, + 0x00102304, 0x832ca400, 0x00000005, 0x50500000, + 0x82001500, 0x000c0016, 0x02020000, 0x00102310, + 0x82500c00, 0x00000003, 0x50040000, 0x82001500, + 0x00000001, 0x02020000, 0x00102310, 0x50500000, + 0x82001500, 0x00000028, 0x0400001d, 0x82081580, + 0x00000028, 0x02020000, 0x00102310, 0x80500800, + 0x50040000, 0x82001500, 0x00000013, 0x82081580, + 0x00000013, 0x02020000, 0x00102310, 0x80040800, + 0x50040000, 0x82001500, 0x00010000, 0x82081580, + 0x00010000, 0x02020000, 0x00102310, 0x836c0580, + 0x00000000, 0x04000012, 0x599c0019, 0x8c00050e, + 0x0402000f, 0x0201f000, 0x00102310, 0x80500800, + 0x50040000, 0x82001500, 0x00000013, 0x02020000, + 0x00102310, 0x80040800, 0x50040000, 0x82001500, + 0x00010000, 0x02020000, 0x00102310, 0x4200b000, + 0x00000008, 0x4200a800, 0x0010b4e3, 0x0201f800, + 0x0010ab17, 0x0201f000, 0x001022c0, 0x4031d800, + 0x58ef400b, 0x58ee580d, 0x58ec0002, 0x82000580, + 0x00000200, 0x02000000, 0x00102304, 0x4200b000, + 0x00000004, 0x4200a800, 0x0010b8fa, 0x832ca400, + 0x00000005, 0x0201f800, 0x0010ab17, 0x59a80005, + 0x84000550, 0x48035005, 0x0201f000, 0x001022c0, + 0x0201f800, 0x00103a00, 0x04020005, 0x4a034406, + 0x00000002, 0x0201f000, 0x0010230c, 0x59a00c06, + 0x82040500, 0x0000ff00, 0x840001c0, 0x82001480, + 0x00000006, 0x02021000, 0x00102310, 0x0c01f001, + 0x001031ee, 0x001031f3, 0x001031f8, 0x001031f8, + 0x001031f8, 0x001031fa, 0x42000800, 0x0000000d, + 0x4200a000, 0x0010b4eb, 0x0401f00c, 0x42000800, + 0x0000000d, 0x4200a000, 0x0010b4f8, 0x0401f007, + 0x0201f000, 0x00102310, 0x42000800, 0x00000008, + 0x4200a000, 0x0010b4e3, 0x4004b000, 0x832cac00, + 0x00000005, 0x0201f800, 0x0010ab17, 0x59a00207, + 0x59a01407, 0x900001c0, 0x80081540, 0x59a00209, + 0x59a01c09, 0x900001c0, 0x800c1d40, 0x832c0400, + 0x00000005, 0x0201f000, 0x00103a28, 0x836c0580, + 0x00000000, 0x04020005, 0x4a034406, 0x00000007, + 0x0201f000, 0x0010230c, 0x59a00406, 0x800001c0, + 0x0400001a, 0x59a80005, 0x8c000514, 0x04000005, + 0x42000000, 0x00000001, 0x40000800, 0x0401f003, + 0x59a00207, 0x59a80853, 0x48035053, 0x0201f800, + 0x0010163b, 0x04000022, 0x0201f800, 0x00101642, + 0x0400001f, 0x0201f800, 0x00101649, 0x0400001c, + 0x0201f800, 0x00101650, 0x04000019, 0x48075053, + 0x0201f000, 0x00102310, 0x59c40801, 0x82040d00, + 0x00018000, 0x82040580, 0x00000000, 0x04020004, + 0x4a034406, 0x00000000, 0x0401f00d, 0x82040580, + 0x00008000, 0x04020004, 0x4a034406, 0x00000001, + 0x0401f007, 0x82040580, 0x00010000, 0x02020800, + 0x001005d8, 0x4a034406, 0x00000003, 0x59a00406, + 0x82000580, 0x00000002, 0x0402001f, 0x59c40006, + 0x84000500, 0x48038806, 0x0201f800, 0x00106ede, + 0x497b8880, 0x0201f800, 0x0010a9c0, 0x0201f800, + 0x0010a9ce, 0x42000000, 0x0010b8ca, 0x0201f800, + 0x0010aa47, 0x82000540, 0x00000001, 0x0201f800, + 0x0010518c, 0x4a038808, 0x00000000, 0x4202d800, + 0x00000004, 0x42001000, 0x00000001, 0x0201f800, + 0x0010193d, 0x4a035049, 0x00000001, 0x0201f800, + 0x001006d4, 0x0201f000, 0x001022c0, 0x800409c0, + 0x04000005, 0x4a034406, 0x00000001, 0x0201f000, + 0x0010230c, 0x836c0580, 0x00000003, 0x04000005, + 0x4a034406, 0x00000007, 0x0201f000, 0x0010230c, + 0x59a28c06, 0x59a0320b, 0x82183500, 0x000000ff, + 0x0201f800, 0x00020245, 0x02020000, 0x00102310, + 0x83440580, 0x000007fd, 0x04000008, 0x0201f800, + 0x001049e7, 0x04000005, 0x42000800, 0x00000009, + 0x0201f000, 0x0010230c, 0x0201f800, 0x00103a00, + 0x04020005, 0x4a034406, 0x00000002, 0x0201f000, + 0x0010230c, 0x497a5a04, 0x4a025c04, 0x00008000, + 0x0201f800, 0x00109115, 0x04020005, 0x4a034406, + 0x00000003, 0x0201f000, 0x0010230c, 0x4a01d809, + 0x0010329e, 0x1c01f000, 0x592c0005, 0x82000d00, + 0x0000ffff, 0x82000500, 0xffff0000, 0x82000580, + 0x01000000, 0x04020005, 0x4a034406, 0x00000004, + 0x0201f000, 0x0010230c, 0x80040904, 0x832ca400, + 0x00000005, 0x4050a800, 0x4004b000, 0x0201f800, + 0x0010ab28, 0x59a00207, 0x59a01407, 0x900001c0, + 0x80081540, 0x59a00209, 0x59a01c09, 0x900001c0, + 0x800c1d40, 0x832c0400, 0x00000005, 0x0201f000, + 0x00103a28, 0x496fc857, 0x836c0580, 0x00000000, + 0x04000005, 0x4a034406, 0x0000001a, 0x0201f000, + 0x0010230c, 0x0201f800, 0x0010513b, 0x02020800, + 0x00104142, 0x42000800, 0x00000020, 0x59a00407, + 0x59a01207, 0x900811c0, 0x80081540, 0x59a00409, + 0x59a01a09, 0x900c19c0, 0x800c1d40, 0x419c0000, + 0x49a3c857, 0x0201f800, 0x00103a25, 0x4a01d809, + 0x001032da, 0x1c01f000, 0x4833c857, 0x4031d800, + 0x58ef400b, 0x58ec0002, 0x82000580, 0x00000200, + 0x02000000, 0x00102304, 0x599c0200, 0x800001c0, + 0x02000000, 0x00102310, 0x59a80005, 0x8c000512, + 0x04000004, 0x599c0019, 0x8400050c, 0x48033819, + 0x0201f800, 0x001097d7, 0x59a80005, 0x8c000514, + 0x04000004, 0x599c0017, 0x84000508, 0x48033817, + 0x0201f800, 0x00103b25, 0x04020004, 0x8c00050a, + 0x02020000, 0x00102310, 0x4803c857, 0x8c000504, + 0x04020004, 0x59c408a3, 0x84040d7a, 0x480788a3, + 0x8c000502, 0x04020004, 0x59c408a3, 0x84040d08, + 0x480788a3, 0x599c0c02, 0x8c000500, 0x04020004, + 0x8c000516, 0x04000012, 0x0401f001, 0x82041480, + 0x0000007f, 0x02021000, 0x00102310, 0x82041400, + 0x0010210e, 0x50081000, 0x82081500, 0x000000ff, + 0x8c000500, 0x04020006, 0x480b5010, 0x42000800, + 0x00000003, 0x0201f800, 0x00106c78, 0x599c0019, + 0x8c00050e, 0x0402000b, 0x59a80806, 0x8c040d14, + 0x04000008, 0x42000800, 0x0010b4e3, 0x50040800, + 0x82040d00, 0x00000028, 0x02020000, 0x00102310, + 0x82000500, 0x00000030, 0x04000003, 0x80000108, + 0x0401f003, 0x42000000, 0x00000002, 0x48039040, + 0x42000800, 0x00000002, 0x82000400, 0x00103415, + 0x50001000, 0x0201f800, 0x00106c78, 0x599c0201, + 0x82000c80, 0x00000100, 0x02001000, 0x00102310, + 0x82000c80, 0x00000841, 0x02021000, 0x00102310, + 0x82000500, 0x00000007, 0x02020000, 0x00102310, + 0x599c0401, 0x80000540, 0x02000000, 0x00102310, + 0x599c0409, 0x599c0c07, 0x80040c80, 0x02021000, + 0x00102310, 0x80000040, 0x02000000, 0x00102310, + 0x599c0209, 0x599c0a07, 0x80040c80, 0x02021000, + 0x00102310, 0x80000040, 0x02000000, 0x00102310, + 0x0201f800, 0x001053cd, 0x0201f800, 0x00104cb6, + 0x599c0201, 0x48035004, 0x0201f800, 0x001012ee, + 0x599c020a, 0x800001c0, 0x04000003, 0x4803504d, + 0x0401f003, 0x4a03504d, 0x000000c8, 0x0201f800, + 0x00103b25, 0x04000004, 0x0201f800, 0x001060df, + 0x417a5000, 0x836c0580, 0x00000000, 0x04020098, + 0x599c0003, 0x599c0804, 0x9c0001c0, 0x9c0409c0, + 0x48035002, 0x48075003, 0x599c1017, 0x8c08151c, + 0x04000006, 0x599c0005, 0x599c0806, 0x9c0001c0, + 0x9c0409c0, 0x0401f003, 0x82000500, 0xf0ffffff, + 0x48035000, 0x48075001, 0x42001000, 0x0010b4eb, + 0x48001000, 0x48041001, 0x42001000, 0x0010b4f8, + 0x48001000, 0x48041001, 0x59a80005, 0x8c000514, + 0x04020015, 0x599c1019, 0x82081500, 0x0000e000, + 0x82080580, 0x00000000, 0x0402000c, 0x4a035053, + 0x00000000, 0x42000000, 0x00000001, 0x0201f800, + 0x0010188c, 0x42000000, 0x00000001, 0x0201f800, + 0x00101821, 0x0401f02b, 0x82080580, 0x00002000, + 0x0402000a, 0x4a035053, 0x00000001, 0x41780000, + 0x0201f800, 0x0010188c, 0x41780000, 0x0201f800, + 0x00101821, 0x0401f01f, 0x82080580, 0x00004000, + 0x04020006, 0x4a035053, 0x00000002, 0x4a035049, + 0x00000001, 0x0401f017, 0x82080580, 0x00006000, + 0x02020000, 0x00102310, 0x59a80858, 0x82040d80, + 0x01391077, 0x04020005, 0x59e00813, 0x8c040d00, + 0x02020000, 0x00102310, 0x4a035053, 0x00000003, + 0x42000000, 0x00000002, 0x0201f800, 0x0010188c, + 0x42000000, 0x00000002, 0x0201f800, 0x00101821, + 0x599c0019, 0x8c000520, 0x0400000d, 0x42000000, + 0x00000004, 0x42000800, 0x00000040, 0x0201f800, + 0x00101944, 0x42000000, 0x00000010, 0x42000800, + 0x000000c0, 0x0201f800, 0x00101944, 0x4a035032, + 0x0000aaaa, 0x599c1018, 0x82081500, 0x00000030, + 0x59a8006c, 0x80000540, 0x0400000c, 0x82080580, + 0x00000000, 0x02000000, 0x00102310, 0x599c1018, + 0x82081500, 0xffffffcf, 0x82081540, 0x00000010, + 0x480b3818, 0x0401f010, 0x82080d80, 0x00000000, + 0x04000007, 0x82080d80, 0x00000010, 0x0400000a, + 0x82080d80, 0x00000020, 0x04020002, 0x48075032, + 0x0201f800, 0x00103aba, 0x04000008, 0x0201f800, + 0x001015fe, 0x0201f800, 0x0010162a, 0x59a8002a, + 0x80040540, 0x4803502a, 0x49f3c857, 0x42001000, + 0x00105065, 0x0201f800, 0x00105f90, 0x42001000, + 0x00105058, 0x0201f800, 0x00106084, 0x4a038805, + 0xffffffff, 0x4a03c014, 0x00400040, 0x4a03c013, + 0x00400000, 0x0201f800, 0x001048c7, 0x59a0001d, + 0x84000540, 0x4803401d, 0x49f3c857, 0x0201f000, + 0x001022c0, 0x00000018, 0x0000000c, 0x00000018, + 0x00000020, 0x836c0580, 0x00000000, 0x04020005, + 0x42000800, 0x00000007, 0x0201f000, 0x0010230c, + 0x42000800, 0x00000020, 0x59a00407, 0x59a01207, + 0x900811c0, 0x80081540, 0x59a00409, 0x59a01a09, + 0x900c19c0, 0x800c1d40, 0x419c0000, 0x0201f000, + 0x00103a28, 0x800409c0, 0x04000005, 0x4a034406, + 0x00000001, 0x0201f000, 0x0010230c, 0x0201f800, + 0x0010513b, 0x04020005, 0x4a034406, 0x00000016, + 0x0201f000, 0x0010230c, 0x59a80013, 0x8c000500, + 0x04000011, 0x4a034406, 0x00000000, 0x42000800, + 0x00000020, 0x59a00407, 0x59a01207, 0x900811c0, + 0x80081540, 0x59a00409, 0x59a01a09, 0x900c19c0, + 0x800c1d40, 0x42000000, 0x0010be21, 0x0201f000, + 0x00103a28, 0x4a034406, 0x00000001, 0x4200b000, + 0x00000020, 0x4200a800, 0x0010be21, 0x4200a000, + 0xffffffff, 0x4450a800, 0x8054a800, 0x8058b040, + 0x040207fd, 0x4d440000, 0x4d340000, 0x42028800, + 0xffffffff, 0x42002000, 0xffffffff, 0x42003000, + 0x00000001, 0x42003800, 0x00000001, 0x42001800, + 0x0010be21, 0x59a81010, 0x82081500, 0x000000ff, + 0x40180000, 0x0c01f001, 0x0010346e, 0x00103471, + 0x00103475, 0x00103479, 0x82102500, 0xffffff00, + 0x0401f014, 0x82102500, 0xffff00ff, 0x840811c0, + 0x0401f010, 0x82102500, 0xff00ffff, 0x900811c0, + 0x0401f00c, 0x82102500, 0x00ffffff, 0x9c0801c0, + 0x80102540, 0x44101800, 0x42003000, 0xffffffff, + 0x42002000, 0xffffffff, 0x800c1800, 0x0401f003, + 0x40080000, 0x80102540, 0x81468800, 0x83442c80, + 0x0000007f, 0x04021014, 0x4c080000, 0x4c0c0000, + 0x4c180000, 0x4c1c0000, 0x0201f800, 0x00020245, + 0x5c003800, 0x5c003000, 0x5c001800, 0x5c001000, + 0x040207f2, 0x0201f800, 0x001049f3, 0x040207ef, + 0x80183000, 0x801c3800, 0x59341202, 0x40180000, + 0x0c01f7ce, 0x82100580, 0xffffffff, 0x04000002, + 0x44101800, 0x42001800, 0x0010be21, 0x500c0000, + 0x82000500, 0xffffff00, 0x801c0540, 0x44001800, + 0x5c026800, 0x5c028800, 0x42000800, 0x00000020, + 0x59a00407, 0x59a01207, 0x900811c0, 0x80081540, + 0x59a00409, 0x59a01a09, 0x900c19c0, 0x800c1d40, + 0x42000000, 0x0010be21, 0x0201f000, 0x00103a28, + 0x59a28c06, 0x59a0020b, 0x8c000500, 0x0400000e, + 0x59a01208, 0x59a00408, 0x82000500, 0x000000ff, + 0x900001c0, 0x80081540, 0x41784000, 0x0201f800, + 0x00104919, 0x04000008, 0x48034406, 0x0201f000, + 0x00102310, 0x0201f800, 0x00020245, 0x02020000, + 0x00102310, 0x0201f800, 0x00103a00, 0x04020005, + 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c, + 0x59a0020b, 0x8c000500, 0x04000005, 0x0201f800, + 0x001049f3, 0x02020000, 0x00103ac4, 0x59a0020b, + 0x8c000502, 0x04000019, 0x83440480, 0x000007f0, + 0x04021016, 0x0201f800, 0x001049fc, 0x04020013, + 0x497a5a04, 0x4a025c04, 0x00008000, 0x0201f800, + 0x001090e6, 0x04020005, 0x4a034406, 0x00000003, + 0x0201f000, 0x0010230c, 0x4a01d809, 0x001034f1, + 0x1c01f000, 0x59a28c06, 0x0201f800, 0x00020245, + 0x02020000, 0x00102310, 0x4200b000, 0x0000000a, + 0x4134a000, 0x832e5c00, 0x00000002, 0x412ca800, + 0x0201f800, 0x0010ab17, 0x832cac00, 0x00000006, + 0x4054a000, 0x4200b000, 0x00000004, 0x0201f800, + 0x0010ab28, 0x592c0802, 0x82040500, 0x00ff00ff, + 0x900001c0, 0x82041500, 0xff00ff00, 0x80080540, + 0x48025802, 0x592c0801, 0x82040500, 0x00ff00ff, + 0x900001c0, 0x82041500, 0xff00ff00, 0x80080540, + 0x48025801, 0x42000800, 0x0000000a, 0x59a00407, + 0x59a01207, 0x900811c0, 0x80081540, 0x59a00409, + 0x59a01a09, 0x900c19c0, 0x800c1d40, 0x412c0000, + 0x0201f000, 0x00103a28, 0x496fc857, 0x496f4406, + 0x0201f000, 0x001022c0, 0x59a28c06, 0x0201f800, + 0x00020245, 0x02020000, 0x00102310, 0x836c0580, + 0x00000003, 0x04000005, 0x4a034406, 0x00000007, + 0x0201f000, 0x0010230c, 0x83340c00, 0x00000006, + 0x59a0020b, 0x8c000500, 0x04000003, 0x83340c00, + 0x00000008, 0x58040001, 0x48034409, 0x900001c0, + 0x48034209, 0x50040000, 0x48034407, 0x900001c0, + 0x48034207, 0x59340200, 0x48034406, 0x0201f000, + 0x001022c0, 0x800409c0, 0x04000005, 0x4a034406, + 0x00000001, 0x0201f000, 0x0010230c, 0x59a0220b, + 0x8c102500, 0x0402002e, 0x8c102506, 0x04020006, + 0x59a03208, 0x82180480, 0x00000003, 0x02021000, + 0x00102310, 0x59a28c06, 0x0201f800, 0x00020245, + 0x02020000, 0x00102310, 0x0201f800, 0x001049e7, + 0x04000005, 0x4a034406, 0x00000009, 0x0201f000, + 0x0010230c, 0x0201f800, 0x00103a00, 0x04020005, + 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c, + 0x59a0220b, 0x8c102506, 0x04000004, 0x59343002, + 0x82183500, 0x00ffffff, 0x497a5a04, 0x4a025c04, + 0x00008000, 0x0201f800, 0x001090a8, 0x04020005, + 0x4a034406, 0x00000003, 0x0201f000, 0x0010230c, + 0x4a01d809, 0x001035d1, 0x1c01f000, 0x59a28c06, + 0x0201f800, 0x00020245, 0x02020000, 0x00102310, + 0x0201f800, 0x001049e7, 0x04000005, 0x4a034406, + 0x00000009, 0x0201f000, 0x0010230c, 0x0201f800, + 0x00103a00, 0x04020005, 0x4a034406, 0x00000002, + 0x0201f000, 0x0010230c, 0x497a5a04, 0x4a025c04, + 0x00008000, 0x0201f800, 0x00103a00, 0x04020005, + 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c, + 0x592e5800, 0x0201f800, 0x001090bd, 0x04020005, + 0x4a034406, 0x00000003, 0x0201f000, 0x0010230c, + 0x4a01d809, 0x001035a3, 0x1c01f000, 0x592c2805, + 0x82140d80, 0x01000000, 0x04020005, 0x4a034406, + 0x00000004, 0x0201f000, 0x0010230c, 0x42000800, + 0x00000008, 0x59a00207, 0x59a01407, 0x900001c0, + 0x80081540, 0x59a00209, 0x59a01c09, 0x900001c0, + 0x800c1d40, 0x832c0400, 0x00000005, 0x0201f800, + 0x00103a28, 0x8c142d00, 0x04000003, 0x4a01d809, + 0x001035be, 0x1c01f000, 0x4031d800, 0x58ef400b, + 0x58ee580e, 0x58ec0002, 0x82000580, 0x00000200, + 0x02000000, 0x00102304, 0x812e59c0, 0x02000800, + 0x001005d8, 0x42000800, 0x00000008, 0x832c0400, + 0x00000005, 0x58ec1007, 0x58ec1808, 0x0201f000, + 0x00103a28, 0x592c0005, 0x82000580, 0x01000000, + 0x04020005, 0x4a034406, 0x00000004, 0x0201f000, + 0x0010230c, 0x59a00207, 0x59a01407, 0x900001c0, + 0x80081540, 0x59a00209, 0x59a01c09, 0x900001c0, + 0x800c1d40, 0x42000800, 0x00000006, 0x832c0400, + 0x00000006, 0x0201f000, 0x00103a28, 0x59a00a0a, + 0x800409c0, 0x02000000, 0x00102310, 0x82040480, + 0x000000e7, 0x04001003, 0x42000800, 0x000000e6, + 0x59a00207, 0x59a01407, 0x900001c0, 0x80081540, + 0x59a00209, 0x59a01c09, 0x900001c0, 0x800c1d40, + 0x83880400, 0x00000000, 0x0201f800, 0x00103a28, + 0x4a01d809, 0x001035ff, 0x1c01f000, 0x4031d800, + 0x58ef400b, 0x58ec0002, 0x82000580, 0x00000200, + 0x02000000, 0x00102304, 0x58ef400b, 0x59a0020b, + 0x8c000500, 0x04000008, 0x83880400, 0x00000000, + 0x4803c840, 0x4a03c842, 0x00000006, 0x04011000, + 0x497b8885, 0x4a034207, 0x000000e6, 0x0201f000, + 0x001022c0, 0x800409c0, 0x04000005, 0x4a034406, + 0x00000001, 0x0201f000, 0x0010230c, 0x0401fbe5, + 0x04020005, 0x4a034406, 0x00000002, 0x0201f000, + 0x0010230c, 0x497a5a04, 0x4a025c04, 0x00008000, + 0x59a00406, 0x800001c0, 0x02000000, 0x00102310, + 0x82001580, 0x000000ff, 0x04000005, 0x82001480, + 0x00000004, 0x02021000, 0x00102310, 0x40001000, + 0x0201f800, 0x00101fbf, 0x04020005, 0x4a034406, + 0x00000003, 0x0201f000, 0x0010230c, 0x4a01d809, + 0x0010363a, 0x1c01f000, 0x592c0005, 0x82000580, + 0x01000000, 0x02020000, 0x001022c0, 0x4a034406, + 0x00000004, 0x0201f000, 0x0010230c, 0x59a01406, + 0x8c081508, 0x04020007, 0x800409c0, 0x04000005, + 0x4a034406, 0x00000001, 0x0201f000, 0x0010230c, + 0x59a01c07, 0x820c0480, 0x00001000, 0x02021000, + 0x00102310, 0x497b2804, 0x497b2805, 0x497b281c, + 0x497b281d, 0x497b281f, 0x497b2820, 0x497b2822, + 0x497b2823, 0x80000580, 0x0201f800, 0x001015fe, + 0x59a80805, 0x8c081500, 0x04000004, 0x82040d40, + 0x00000011, 0x0401f004, 0x8c081506, 0x04000002, + 0x84040d42, 0x84040d0a, 0x48075005, 0x4202d800, + 0x00000001, 0x82081500, 0x000000e0, 0x8008010a, + 0x0c020036, 0x0201f800, 0x0010513b, 0x04020009, + 0x4a035033, 0x00000001, 0x0201f800, 0x001050a2, + 0x0401f01f, 0x4a035033, 0x00000000, 0x0401f7fb, + 0x497b5032, 0x0201f800, 0x00104142, 0x0201f800, + 0x00106c55, 0x0201f800, 0x00106ede, 0x0201f800, + 0x00106c4b, 0x59a00a07, 0x480788a7, 0x59c400a3, + 0x82000500, 0xfeffffff, 0x82000540, 0x80018000, + 0x40000800, 0x84040d20, 0x480388a3, 0x480788a3, + 0x497b504e, 0x42000800, 0x0000002d, 0x42001000, + 0x001041bc, 0x0201f800, 0x00105f69, 0x59a00407, + 0x800000c2, 0x800008c4, 0x8005d400, 0x42000000, + 0x0000ffff, 0x0201f800, 0x0010513b, 0x04000003, + 0x59a00207, 0x80000110, 0x0201f800, 0x00103afc, + 0x0201f000, 0x001022c0, 0x0010366d, 0x00103670, + 0x00103678, 0x00102310, 0x00103675, 0x00102310, + 0x00102310, 0x00102310, 0x836c0580, 0x00000003, + 0x04000005, 0x4a034406, 0x00000007, 0x0201f000, + 0x0010230c, 0x59a03c06, 0x59a00407, 0x59a04a07, + 0x902449c0, 0x80244d40, 0x59a00409, 0x59a05209, + 0x902851c0, 0x80285540, 0x0401fb46, 0x04020005, + 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c, + 0x417a8800, 0x41783000, 0x497b4001, 0x497b4004, + 0x832c4400, 0x00000005, 0x48234002, 0x8c1c3d04, + 0x04020078, 0x0201f800, 0x00020245, 0x0402002a, + 0x0201f800, 0x001049e7, 0x04000004, 0x0201f800, + 0x001048e3, 0x04020024, 0x8c1c3d00, 0x04000008, + 0x59340009, 0x44004000, 0x59340008, 0x80204000, + 0x44004000, 0x80204000, 0x0401f007, 0x59340007, + 0x44004000, 0x59340006, 0x80204000, 0x44004000, + 0x80204000, 0x83440580, 0x000007fe, 0x0400000d, + 0x83440580, 0x000007fc, 0x0400000a, 0x0201f800, + 0x001049f3, 0x04000003, 0x85468d5e, 0x0401f005, + 0x0201f800, 0x00104838, 0x04020002, 0x85468d5e, + 0x45444000, 0x85468d1e, 0x80204000, 0x82183400, + 0x00000003, 0x81468800, 0x83440480, 0x000007f0, + 0x0400100e, 0x8c1c3d06, 0x04000010, 0x83440580, + 0x000007f0, 0x04020004, 0x42028800, 0x000007fe, + 0x0401f006, 0x83440580, 0x000007ff, 0x04020007, + 0x42028800, 0x000007fc, 0x82180580, 0x0000000f, + 0x0400000b, 0x0401f7c0, 0x801831c0, 0x04020006, + 0x59a00801, 0x800408c4, 0x48074406, 0x0201f000, + 0x001022c0, 0x4a034004, 0x00000001, 0x49474000, + 0x59a00001, 0x80180400, 0x48034001, 0x481f4003, + 0x4a01d801, 0x00000000, 0x4819d804, 0x59a00002, + 0x4801d803, 0x4825d807, 0x4829d808, 0x4000a800, + 0x4000a000, 0x4018b000, 0x0201f800, 0x0010ab17, + 0x40ec1000, 0x0201f800, 0x00100858, 0x4a01d809, + 0x0010372a, 0x1c01f000, 0x4031d800, 0x58ef400b, + 0x58ec0002, 0x82000580, 0x00000200, 0x02000000, + 0x00102304, 0x59a00004, 0x80000540, 0x04020008, + 0x59a28800, 0x59a04002, 0x59a03803, 0x41783000, + 0x58ec4807, 0x58ec5008, 0x0401f78f, 0x59a00801, + 0x800408c4, 0x48074406, 0x0201f000, 0x001022c0, + 0x0201f800, 0x00020245, 0x0402002f, 0x0201f800, + 0x001049e7, 0x04000004, 0x0201f800, 0x001048e3, + 0x04020029, 0x83440580, 0x000007fe, 0x04000011, + 0x83440580, 0x000007fc, 0x0400000e, 0x0201f800, + 0x001049f3, 0x04000005, 0x59340403, 0x8400055e, + 0x48026c03, 0x0401f007, 0x0201f800, 0x00104838, + 0x04020004, 0x59340403, 0x8400055e, 0x48026c03, + 0x4134a000, 0x4020a800, 0x4200b000, 0x00000006, + 0x0201f800, 0x0010ab17, 0x59340007, 0x4400a800, + 0x59340006, 0x4800a801, 0x59340009, 0x4800a802, + 0x59340008, 0x4800a803, 0x59340403, 0x8400051e, + 0x48026c03, 0x82204400, 0x0000000a, 0x82183400, + 0x0000000a, 0x81468800, 0x83440480, 0x000007f0, + 0x0400100e, 0x8c1c3d06, 0x04000010, 0x83440580, + 0x000007f0, 0x04020004, 0x42028800, 0x000007fe, + 0x0401f006, 0x83440580, 0x000007ff, 0x04020007, + 0x42028800, 0x000007fc, 0x82180580, 0x0000000a, + 0x0400000b, 0x0401f7bb, 0x801831c0, 0x04020006, + 0x59a00801, 0x800408c4, 0x48074406, 0x0201f000, + 0x001022c0, 0x4a034004, 0x00000001, 0x49474000, + 0x59a00001, 0x80180400, 0x48034001, 0x481f4003, + 0x4a01d801, 0x00000000, 0x4819d804, 0x59a00002, + 0x4801d803, 0x4825d807, 0x4829d808, 0x40ec1000, + 0x0201f800, 0x00100858, 0x4a01d809, 0x001037a1, + 0x1c01f000, 0x4031d800, 0x58ef400b, 0x58ec0002, + 0x82000580, 0x00000200, 0x02000000, 0x00102304, + 0x59a00004, 0x80000540, 0x04020008, 0x59a28800, + 0x59a04002, 0x59a03803, 0x41783000, 0x58ec4807, + 0x58ec5008, 0x0401f78f, 0x59a00801, 0x800408c4, + 0x48074406, 0x0201f000, 0x001022c0, 0x42002800, + 0x0000007e, 0x59a00c06, 0x59a01207, 0x59a01c07, + 0x59a02209, 0x82040500, 0x0000ff00, 0x840001c0, + 0x82003480, 0x00000020, 0x02001000, 0x00102310, + 0x80140480, 0x02001000, 0x00102310, 0x82040500, + 0x000000ff, 0x82003480, 0x00000020, 0x02001000, + 0x00102310, 0x80140480, 0x02001000, 0x00102310, + 0x82080500, 0x0000ff00, 0x840001c0, 0x82003480, + 0x00000020, 0x02001000, 0x00102310, 0x80140480, + 0x02001000, 0x00102310, 0x82080500, 0x000000ff, + 0x82003480, 0x00000020, 0x02001000, 0x00102310, + 0x80140480, 0x02001000, 0x00102310, 0x820c0500, + 0x0000ff00, 0x840001c0, 0x82003480, 0x00000020, + 0x02001000, 0x00102310, 0x80140480, 0x02001000, + 0x00102310, 0x820c0500, 0x000000ff, 0x82003480, + 0x00000020, 0x02001000, 0x00102310, 0x80140480, + 0x02001000, 0x00102310, 0x82100500, 0x0000ff00, + 0x840001c0, 0x82003480, 0x00000020, 0x02001000, + 0x00102310, 0x80140480, 0x02001000, 0x00102310, + 0x82100500, 0x000000ff, 0x82003480, 0x00000020, + 0x02001000, 0x00102310, 0x80140480, 0x02001000, + 0x00102310, 0x900401c0, 0x80080d40, 0x900c01c0, + 0x80101d40, 0x83a83400, 0x0000003a, 0x44043000, + 0x80183000, 0x440c3000, 0x0201f000, 0x001022c0, + 0x0401f9ec, 0x04020005, 0x4a034406, 0x00000002, + 0x0201f000, 0x0010230c, 0x42000800, 0x0000000c, + 0x0401f853, 0x4a01d809, 0x00103820, 0x1c01f000, + 0x4031d800, 0x58ee580d, 0x58ef400b, 0x58ec0002, + 0x82000580, 0x00000200, 0x02000000, 0x00102304, + 0x832ca400, 0x00000004, 0x4200b000, 0x0000000c, + 0x40c8a800, 0x0201f800, 0x0010ab17, 0x58c80200, + 0x80000540, 0x04000034, 0x58c80400, 0x82000500, + 0xfffffffb, 0x04020030, 0x58c80401, 0x80000540, + 0x0400002d, 0x82000480, 0x0000ff01, 0x0402102a, + 0x58c80202, 0x82000480, 0x0000005c, 0x04001026, + 0x0201f800, 0x001063a3, 0x58c80c08, 0x58c80204, + 0x80040480, 0x04001020, 0x58c80204, 0x82000480, + 0x00000005, 0x0402101c, 0x58c80205, 0x58c80c08, + 0x80040902, 0x80040480, 0x04001017, 0x58c80c08, + 0x0201f800, 0x001062f1, 0x0400001b, 0x0201f800, + 0x001061b9, 0x04020012, 0x4979940b, 0x59c408a3, + 0x82040d40, 0x00000002, 0x480788a3, 0x4a038830, + 0x00000001, 0x4a038832, 0x01ffffff, 0x58c80202, + 0x48030804, 0x0201f800, 0x0010619b, 0x0201f000, + 0x001022c0, 0x0201f000, 0x00102310, 0x0201f800, + 0x001063f5, 0x0201f800, 0x00106402, 0x0201f800, + 0x001062e4, 0x0201f000, 0x0010230c, 0x4c000000, + 0x59a01207, 0x59a00407, 0x900811c0, 0x80081540, + 0x59a01a09, 0x59a00409, 0x900c19c0, 0x800c1d40, + 0x5c000000, 0x0401f1ac, 0x59840000, 0x82000580, + 0x00000000, 0x04000054, 0x59840002, 0x8c000504, + 0x04000051, 0x84000546, 0x48030802, 0x0201f800, + 0x001062e4, 0x59c408a3, 0x82040d00, 0xfffffffd, + 0x480788a3, 0x4c5c0000, 0x4200b800, 0x0010ac00, + 0x505e6800, 0x813669c0, 0x04000008, 0x5936600e, + 0x813261c0, 0x04000005, 0x0201f800, 0x001062d5, + 0x02000800, 0x001064ad, 0x805cb800, 0x825c0580, + 0x0010b3f0, 0x040207f3, 0x59866003, 0x813261c0, + 0x0400000b, 0x59300406, 0x82000580, 0x00000009, + 0x02020800, 0x001005d8, 0x5930b800, 0x0201f800, + 0x001062c1, 0x405e6000, 0x0401f7f5, 0x497b0803, + 0x4200b800, 0x0010b51b, 0x505e6000, 0x813261c0, + 0x04000011, 0x59300406, 0x82000580, 0x00000009, + 0x0402000d, 0x59300203, 0x82000580, 0x00000004, + 0x04020009, 0x59326809, 0x813669c0, 0x02020800, + 0x001005d8, 0x0201f800, 0x00100e99, 0x0201f800, + 0x001062c1, 0x4578b800, 0x805cb800, 0x825c0580, + 0x0010b523, 0x040207e9, 0x42000800, 0x0010b519, + 0x49780801, 0x49780800, 0x59a80069, 0x82000400, + 0x00000007, 0x48035069, 0x0201f800, 0x001063f5, + 0x0201f800, 0x00106402, 0x5c00b800, 0x0201f800, + 0x001061b4, 0x0201f000, 0x001022c0, 0x836c0580, + 0x00000003, 0x04000005, 0x4a034406, 0x00000007, + 0x0201f000, 0x0010230c, 0x59a00407, 0x59a02207, + 0x901021c0, 0x80102540, 0x59a00409, 0x59a02a09, + 0x901429c0, 0x80142d40, 0x0401f91e, 0x04020005, + 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c, + 0x417a8800, 0x41781800, 0x497b4001, 0x497b4003, + 0x832c3400, 0x00000004, 0x481b4002, 0x41440000, + 0x81ac0400, 0x50026800, 0x813669c0, 0x0400000b, + 0x0201f800, 0x001049e7, 0x04020008, 0x59340002, + 0x48003000, 0x49443001, 0x82183400, 0x00000002, + 0x820c1c00, 0x00000002, 0x81468800, 0x83440480, + 0x00000800, 0x04000005, 0x820c0480, 0x00000010, + 0x0402100b, 0x0401f7ea, 0x800c19c0, 0x04020006, + 0x59a00801, 0x80040902, 0x48074406, 0x0201f000, + 0x001022c0, 0x4a034003, 0x00000001, 0x49474000, + 0x59a00001, 0x800c0400, 0x48034001, 0x40ec1000, + 0x4a001001, 0x00000000, 0x480c1004, 0x59a00002, + 0x48001003, 0x48101007, 0x48141008, 0x0201f800, + 0x00100858, 0x4a01d809, 0x00103920, 0x1c01f000, + 0x4031d800, 0x58ef400b, 0x58ec0002, 0x82000580, + 0x00000200, 0x02000000, 0x00102304, 0x59a00003, + 0x80000540, 0x04020008, 0x59a28800, 0x59a03002, + 0x41781800, 0x40ec1000, 0x58082007, 0x58082808, + 0x0401f7bf, 0x59a00801, 0x80040902, 0x48074406, + 0x0201f000, 0x001022c0, 0x800409c0, 0x04000005, + 0x4a034406, 0x00000001, 0x0201f000, 0x0010230c, + 0x59a80026, 0x8c00050a, 0x04020007, 0x8c000506, + 0x04020005, 0x4a034406, 0x00000016, 0x0201f000, + 0x0010230c, 0x0401f8bb, 0x04020005, 0x4a034406, + 0x00000002, 0x0201f000, 0x0010230c, 0x59a00c06, + 0x80040902, 0x59a00407, 0x59a01207, 0x900811c0, + 0x80081540, 0x59a00409, 0x59a01a09, 0x900c19c0, + 0x800c1d40, 0x832c0400, 0x00000005, 0x0401f8ce, + 0x4a01d809, 0x0010395b, 0x1c01f000, 0x4031d800, + 0x58ef400b, 0x58ee580d, 0x58ec0002, 0x82000580, + 0x00000200, 0x02000000, 0x00102304, 0x592c0009, + 0x0201f800, 0x00105c9a, 0x02000800, 0x001045a6, + 0x02020000, 0x00102310, 0x49474001, 0x481a6802, + 0x592c000a, 0x82001d80, 0x70000000, 0x04020007, + 0x0401f890, 0x04020011, 0x4a034406, 0x00000002, + 0x0201f000, 0x0010230c, 0x82001d80, 0x72000000, + 0x02020000, 0x00102310, 0x0401f886, 0x04020885, + 0x04020884, 0x04020005, 0x4a034406, 0x00000002, + 0x0201f000, 0x0010230c, 0x58ee580d, 0x4a025c04, + 0x00008000, 0x497a5a04, 0x592c3208, 0x80183102, + 0x592c1801, 0x4a001805, 0x01000000, 0x0201f800, + 0x001090d1, 0x04020005, 0x4a034406, 0x00000003, + 0x0201f000, 0x0010230c, 0x4a01d809, 0x00103995, + 0x1c01f000, 0x592c4000, 0x592c0005, 0x82000580, + 0x01000000, 0x04020005, 0x4a034406, 0x00000004, + 0x0201f000, 0x0010230c, 0x832c3c00, 0x00000005, + 0x401ca000, 0x401ca800, 0x5820280a, 0x4200b000, + 0x00000002, 0x82143580, 0x70000000, 0x04000003, + 0x4200b000, 0x0000000f, 0x0201f800, 0x0010ab28, + 0x401c0000, 0x58201006, 0x58201807, 0x58202205, + 0x80102102, 0x82143580, 0x70000000, 0x04020008, + 0x82103480, 0x00000002, 0x02001000, 0x00102310, + 0x42000800, 0x00000002, 0x0401f06e, 0x82143580, + 0x72000000, 0x02020000, 0x00102310, 0x82103480, + 0x0000002a, 0x02001000, 0x00102310, 0x42000800, + 0x0000000f, 0x0401f863, 0x4a01d809, 0x001039c9, + 0x1c01f000, 0x4031d800, 0x58ef400b, 0x58ee580e, + 0x58ec0002, 0x82000580, 0x00000200, 0x02000000, + 0x00102304, 0x592e5800, 0x832c0c00, 0x00000005, + 0x4004a000, 0x4004a800, 0x4200b000, 0x0000000f, + 0x0201f800, 0x0010ab28, 0x40ec1000, 0x4a001001, + 0x00000000, 0x4a001004, 0x0000000f, 0x48041003, + 0x0201f800, 0x00100858, 0x4a01d809, 0x001039e5, + 0x1c01f000, 0x4031d800, 0x58ef400b, 0x58ee580e, + 0x58ec0002, 0x82000580, 0x00000200, 0x02000000, + 0x00102304, 0x832c0c00, 0x00000005, 0x4004a000, + 0x4004a800, 0x4200b000, 0x0000000c, 0x0201f800, + 0x0010ab28, 0x40ec1000, 0x4a001001, 0x00000000, + 0x4a001004, 0x0000000c, 0x48041003, 0x0201f800, + 0x00100858, 0x4a01d809, 0x001022b9, 0x1c01f000, + 0x0201f800, 0x001007e4, 0x04000010, 0x497a5800, + 0x58ec000d, 0x80000540, 0x04020004, 0x492dd80d, + 0x492dd80e, 0x0401f007, 0x58ec000e, 0x48025800, + 0x82000400, 0x00000001, 0x452c0000, 0x492dd80e, + 0x832c0400, 0x00000004, 0x492fc857, 0x4803c857, + 0x1c01f000, 0x4d2c0000, 0x48efc857, 0x58ec400d, + 0x4823c857, 0x802041c0, 0x04000007, 0x40225800, + 0x592c4001, 0x497a5801, 0x0201f800, 0x001007f4, + 0x0401f7f8, 0x4979d80d, 0x4979d80e, 0x5c025800, + 0x1c01f000, 0x42003000, 0x00000001, 0x0401f003, + 0x42003000, 0x00000000, 0x4803c857, 0x4807c857, + 0x480bc857, 0x480fc857, 0x481bc857, 0x48efc857, + 0x4819d801, 0x800409c0, 0x02000800, 0x001005d8, + 0x4805d804, 0x4801d803, 0x4809d807, 0x480dd808, + 0x40ec1000, 0x0201f800, 0x00100858, 0x4a01d809, + 0x001022b9, 0x1c01f000, 0x80002d80, 0x480bc857, + 0x480fc857, 0x4813c857, 0x4817c857, 0x4d2c0000, + 0x4da00000, 0x42034000, 0x0010b4a4, 0x59a00017, + 0x800001c0, 0x04020013, 0x04006012, 0x480bc020, + 0x480fc021, 0x4813c022, 0x4817c023, 0x900811c0, + 0x82081540, 0x00000012, 0x480bc011, 0x59e00017, + 0x8c000508, 0x04020004, 0x4203e000, 0x30000001, + 0x0401f053, 0x4a03c017, 0x00000002, 0x0401f7fb, + 0x4c040000, 0x4c1c0000, 0x80000800, 0x48074017, + 0x59a0381a, 0x481fc857, 0x801c39c0, 0x04020027, + 0x82000480, 0x0000000a, 0x04021010, 0x59a00018, + 0x80000000, 0x48034018, 0x59a00219, 0x82000400, + 0x00000002, 0x82000c80, 0x00000013, 0x48034219, + 0x04001003, 0x497b4219, 0x41780000, 0x59a03816, + 0x801c3c00, 0x0401f030, 0x4803c856, 0x0201f800, + 0x001007e4, 0x04000007, 0x492f401a, 0x492f401b, + 0x412c3800, 0x497b421c, 0x497a5813, 0x0401f026, + 0x59880051, 0x80000000, 0x48031051, 0x59a00017, + 0x80000040, 0x48034017, 0x59a00219, 0x59a03816, + 0x801c3c00, 0x0401f01c, 0x59a0021c, 0x82000400, + 0x00000002, 0x82000c80, 0x00000012, 0x04021004, + 0x4803421c, 0x801c3c00, 0x0401f013, 0x0201f800, + 0x001007e4, 0x0402000b, 0x59880051, 0x80000000, + 0x48031051, 0x59a00017, 0x80000040, 0x48034017, + 0x4803c856, 0x59a0021c, 0x801c3c00, 0x0401f006, + 0x492f401a, 0x492c3813, 0x412c3800, 0x497b421c, + 0x497a5813, 0x48083c00, 0x480c3a00, 0x48103c01, + 0x48143a01, 0x5c003800, 0x5c000800, 0x5c034000, + 0x5c025800, 0x1c01f000, 0x480fc857, 0x4813c857, + 0x481bc857, 0x42000000, 0x0010b813, 0x0201f800, + 0x0010aa47, 0x801800d0, 0x40002800, 0x42001000, + 0x00008014, 0x0401f786, 0x4c000000, 0x599c0017, + 0x8c000512, 0x5c000000, 0x1c01f000, 0x4c000000, + 0x599c0018, 0x8c00050e, 0x5c000000, 0x1c01f000, + 0x59a80821, 0x800409c0, 0x04000005, 0x4a034406, + 0x00000001, 0x0201f000, 0x0010230c, 0x836c0580, + 0x00000003, 0x04000005, 0x4a034406, 0x00000007, + 0x0201f000, 0x0010230c, 0x599c0017, 0x8c00050a, + 0x04000005, 0x4a034406, 0x00000008, 0x0201f000, + 0x0010230c, 0x59340405, 0x8c000508, 0x04020004, + 0x8c00050a, 0x02020000, 0x001034db, 0x497a5a04, + 0x497a5805, 0x4a025c04, 0x00008000, 0x0201f800, + 0x00109176, 0x04020005, 0x4a034406, 0x00000003, + 0x0201f000, 0x0010230c, 0x4a01d809, 0x00103aed, + 0x1c01f000, 0x592c0005, 0x82000580, 0x01000000, + 0x04020005, 0x4a034406, 0x00000004, 0x0201f000, + 0x0010230c, 0x59a28c06, 0x0201f800, 0x00020245, + 0x02020000, 0x00102310, 0x0201f000, 0x001034db, + 0x82001580, 0x0000ffff, 0x04000009, 0x0201f800, + 0x00105c9a, 0x02000800, 0x00020245, 0x0402000c, + 0x0201f800, 0x00105fae, 0x0401f009, 0x42028800, + 0x000007ef, 0x0201f800, 0x00020245, 0x02000800, + 0x00105fae, 0x81468840, 0x040217fb, 0x1c01f000, + 0x4803c856, 0x4c0c0000, 0x4d340000, 0x4d440000, + 0x42028800, 0x000007fe, 0x0201f800, 0x00020245, + 0x04020009, 0x5934180a, 0x820c1d00, 0x00000001, + 0x820c1d80, 0x00000001, 0x42001000, 0x0000801b, + 0x0401ff1e, 0x5c028800, 0x5c026800, 0x5c001800, + 0x1c01f000, 0x599c0017, 0x8c000508, 0x1c01f000, + 0x48efc857, 0x04011000, 0x48efc840, 0x4a03c842, + 0x00000011, 0x40000000, 0x040117ff, 0x4a01d80f, + 0xbeefbeef, 0x1c01f000, 0x497b4000, 0x497b4001, + 0x497b4002, 0x497b4003, 0x497b4004, 0x1c01f000, + 0x59c400a4, 0x4c580000, 0x4c500000, 0x4c540000, + 0x82000500, 0x0000000f, 0x82000480, 0x00000007, + 0x0400100a, 0x82006c80, 0x00000006, 0x02021800, + 0x001005d8, 0x0c01f807, 0x5c00a800, 0x5c00a000, + 0x5c00b000, 0x1c01f000, 0x0401f906, 0x0401f7fb, + 0x00103b51, 0x00103b57, 0x00103b7c, 0x00103b9e, + 0x00103c59, 0x59c40806, 0x8c040d00, 0x04020003, + 0x84040d40, 0x48078806, 0x1c01f000, 0x59c40005, + 0x8c000534, 0x02020000, 0x0010429e, 0x4a038805, + 0xffffffff, 0x42006000, 0x00020000, 0x0201f800, + 0x00104282, 0x59a80015, 0x82000500, 0xfffffffa, + 0x84000542, 0x48035015, 0x497b5026, 0x42000800, + 0x0010be21, 0x45780800, 0x497b5013, 0x42006000, + 0xffefffff, 0x42006800, 0x40000000, 0x0201f800, + 0x0010427d, 0x59c40006, 0x82000500, 0xffffff0f, + 0x48038806, 0x42000800, 0x00000010, 0x42001000, + 0x001041f3, 0x0201f800, 0x00105f83, 0x0401f001, + 0x42006000, 0xffffffff, 0x42006800, 0x00800000, + 0x0201f800, 0x0010427d, 0x4200b000, 0x000000c8, + 0x59c400a4, 0x82000500, 0x0000000f, 0x82000580, + 0x0000000a, 0x0400000f, 0x8058b040, 0x040207f9, + 0x497b5014, 0x42006000, 0xbf7fffff, 0x42006800, + 0x00018000, 0x0201f800, 0x0010427d, 0x42006000, + 0xfffeffff, 0x41786800, 0x0201f000, 0x0010427d, + 0x497b5014, 0x4a035012, 0x00000000, 0x80000580, + 0x0201f000, 0x00104289, 0x4a038805, 0xffffffff, + 0x59a80012, 0x82000c80, 0x00000004, 0x02021800, + 0x001005d8, 0x0c01f001, 0x00103ba9, 0x00103bd6, + 0x00103c4f, 0x4803c856, 0x59c400a3, 0x8400051e, + 0x480388a3, 0x4a035012, 0x00000001, 0x59c40008, + 0x8400054e, 0x48038808, 0x0201f800, 0x00104263, + 0x42007800, 0x0010b54c, 0x4a007806, 0x11010000, + 0x4200a000, 0x0010b402, 0x4200a800, 0x0010b553, + 0x4200b000, 0x00000002, 0x0201f800, 0x0010ab17, + 0x497b8802, 0x42000800, 0x00000003, 0x497b504a, + 0x0201f800, 0x0010416e, 0x4a03504a, 0x00000001, + 0x497b5016, 0x0201f800, 0x00104290, 0x42006000, + 0xffffffff, 0x42006800, 0x00080000, 0x0201f800, + 0x0010427d, 0x42006000, 0xfff7ffff, 0x41786800, + 0x0201f000, 0x0010427d, 0x59a80016, 0x497b5016, + 0x80002540, 0x04000066, 0x59c40004, 0x82000500, + 0x00000003, 0x04020071, 0x59a80815, 0x8c040d02, + 0x0400004b, 0x82100580, 0x0000000c, 0x0402004f, + 0x82100400, 0x00000018, 0x8000b104, 0x41cc1000, + 0x42001800, 0x0010b54c, 0x50080800, 0x500c0000, + 0x80040580, 0x0402001a, 0x80081000, 0x800c1800, + 0x8058b040, 0x040207f9, 0x0201f800, 0x00104290, + 0x42006000, 0xffffffff, 0x42006800, 0x00500000, + 0x0201f800, 0x0010427d, 0x4a035012, 0x00000002, + 0x4a035014, 0x00000002, 0x42000800, 0x000007d0, + 0x42001000, 0x00104148, 0x0201f800, 0x0010606e, + 0x0201f800, 0x00104263, 0x0401f048, 0x59cc0806, + 0x82040d80, 0x11010000, 0x04020028, 0x59cc0800, + 0x82040500, 0x00ffffff, 0x0400001a, 0x82000580, + 0x000000ef, 0x04020017, 0x59cc0801, 0x82040500, + 0x00ffffff, 0x82000580, 0x000000ef, 0x04020011, + 0x83cca400, 0x00000007, 0x4200a800, 0x0010b402, + 0x4200b000, 0x00000002, 0x50500800, 0x50540000, + 0x80040480, 0x04001007, 0x04020010, 0x8050a000, + 0x8054a800, 0x8058b040, 0x040207f8, 0x0401f00b, + 0x59a80015, 0x84000502, 0x48035015, 0x41cca000, + 0x4200a800, 0x0010b54c, 0x4200b000, 0x00000009, + 0x0201f800, 0x0010ab17, 0x0201f800, 0x00104290, + 0x42006000, 0xffffffff, 0x42006800, 0x00080000, + 0x0201f800, 0x0010427d, 0x42006000, 0xfff7ffff, + 0x41786800, 0x0201f800, 0x0010427d, 0x42006000, + 0xffffffff, 0x42006800, 0x00004000, 0x0201f800, + 0x0010427d, 0x59c40004, 0x82000500, 0x00000003, + 0x04020006, 0x497b5016, 0x42000800, 0x00000003, + 0x0201f000, 0x0010416e, 0x1c01f000, 0x1c01f000, + 0x59a80014, 0x82006d80, 0x0000000f, 0x04000005, + 0x82000580, 0x0000001b, 0x02020800, 0x00104139, + 0x1c01f000, 0x59a80015, 0x84000506, 0x48035015, + 0x497b504a, 0x59a80014, 0x82000c80, 0x0000001e, + 0x02021800, 0x001005d8, 0x0c01f001, 0x00103c97, + 0x00103cac, 0x00103cd5, 0x00103cf0, 0x00103d14, + 0x00103d45, 0x00103d68, 0x00103d9b, 0x00103dbe, + 0x00103de4, 0x00103e21, 0x00103e48, 0x00103e5f, + 0x00103e71, 0x00103e8a, 0x00103ea0, 0x00103ea5, + 0x00103ecd, 0x00103ef0, 0x00103f16, 0x00103f39, + 0x00103f6c, 0x00103fae, 0x00103fd8, 0x00103ff0, + 0x00104030, 0x00104049, 0x0010405c, 0x0010405d, + 0x4803c856, 0x4202d800, 0x00000007, 0x0201f800, + 0x0010513b, 0x04000007, 0x42006000, 0xffffffd7, + 0x41786800, 0x0201f800, 0x0010427d, 0x0401f00b, + 0x59c40006, 0x82000500, 0xffffff0f, 0x48038806, + 0x42001000, 0x000000f0, 0x0201f800, 0x0010193d, + 0x0201f800, 0x00105098, 0x1c01f000, 0x4803c856, + 0x42006000, 0xbf7fffff, 0x42006800, 0x00400000, + 0x0201f800, 0x0010427d, 0x4a035014, 0x00000001, + 0x42001000, 0x001041f3, 0x0201f800, 0x00105fa4, + 0x0201f800, 0x001041f8, 0x42000800, 0x000007d0, + 0x42001000, 0x00104148, 0x0201f000, 0x0010606e, + 0x59a80016, 0x82000580, 0x00000014, 0x04020025, + 0x4803c857, 0x42006000, 0xffbfffff, 0x41786800, + 0x0201f800, 0x0010427d, 0x59c40004, 0x82000500, + 0x00000003, 0x0402001b, 0x59cc1006, 0x82081580, + 0x11020000, 0x04020016, 0x59cc1007, 0x8c08153e, + 0x0400000b, 0x59a80015, 0x8c000504, 0x04020008, + 0x42000000, 0x0010b83f, 0x0201f800, 0x0010aa47, + 0x59a80015, 0x84000544, 0x48035015, 0x42001000, + 0x00104148, 0x0201f800, 0x00105f90, 0x4a035014, + 0x00000010, 0x0401f9d4, 0x0401f002, 0x497b5016, + 0x1c01f000, 0x4803c856, 0x4a035014, 0x00000003, + 0x42006000, 0xbf3fffff, 0x42006800, 0x00100000, + 0x0201f800, 0x0010427d, 0x42001000, 0x001041f3, + 0x0201f800, 0x00105fa4, 0x0201f800, 0x001041f8, + 0x42001000, 0x00104148, 0x0201f800, 0x00105f90, + 0x42007800, 0x0010b552, 0x46007800, 0x11020000, + 0x42000800, 0x00000005, 0x0201f000, 0x0010416e, + 0x59a80016, 0x80000540, 0x04000021, 0x4803c857, + 0x42001000, 0x00104148, 0x0201f800, 0x00105f90, + 0x59a80016, 0x82000580, 0x00000014, 0x04020016, + 0x59cc1006, 0x82081580, 0x11020000, 0x04020012, + 0x59cc1007, 0x8c08153e, 0x0400000b, 0x59a80015, + 0x8c000504, 0x04020008, 0x42000000, 0x0010b83f, + 0x0201f800, 0x0010aa47, 0x59a80015, 0x84000544, + 0x48035015, 0x4a035014, 0x00000004, 0x0401f805, + 0x0401f003, 0x0201f800, 0x00104139, 0x1c01f000, + 0x4803c856, 0x4a035014, 0x00000005, 0x83cca400, + 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000, + 0x00000005, 0x0201f800, 0x0010ab17, 0x42007800, + 0x0010b552, 0x46007800, 0x11030000, 0x0201f800, + 0x0010413e, 0x04020014, 0x59a80015, 0x8c000500, + 0x04020011, 0x59a80810, 0x82040580, 0x00ffffff, + 0x0400000d, 0x82040d00, 0x000000ff, 0x82040400, + 0x0010210e, 0x50000800, 0x80040910, 0x42001000, + 0x00000004, 0x0401fb9b, 0x0400000b, 0x0201f800, + 0x0010420d, 0x4200b000, 0x00000004, 0x83cca400, + 0x00000007, 0x4200a800, 0x0010b553, 0x0201f800, + 0x0010ab17, 0x42000800, 0x00000005, 0x0201f000, + 0x0010416e, 0x59a80016, 0x80000540, 0x04000020, + 0x4803c857, 0x42001000, 0x00104148, 0x0201f800, + 0x00105f90, 0x59a80016, 0x82000580, 0x00000014, + 0x04020016, 0x59cc1006, 0x82081580, 0x11030000, + 0x04020012, 0x59cc1007, 0x8c08153e, 0x0400000b, + 0x59a80015, 0x8c000504, 0x04020008, 0x42000000, + 0x0010b83f, 0x0201f800, 0x0010aa47, 0x59a80015, + 0x84000544, 0x48035015, 0x4a035014, 0x00000006, + 0x0401f804, 0x0401f002, 0x0401fbd3, 0x1c01f000, + 0x4803c856, 0x4a035014, 0x00000007, 0x83cca400, + 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000, + 0x00000005, 0x0201f800, 0x0010ab17, 0x42007800, + 0x0010b552, 0x46007800, 0x11040000, 0x0401fbc7, + 0x04020020, 0x59a80015, 0x8c000500, 0x0402001d, + 0x599c0017, 0x8c000500, 0x0400001a, 0x599c1402, + 0x82080480, 0x0000007f, 0x02021800, 0x001005d8, + 0x4c080000, 0x82081400, 0x0010210e, 0x50081000, + 0x82081500, 0x000000ff, 0x480b5010, 0x42000800, + 0x00000003, 0x0201f800, 0x00106c78, 0x5c000800, + 0x42001000, 0x00000004, 0x0401fb3e, 0x04000005, + 0x0401fd2b, 0x04000003, 0x0201f800, 0x001015fe, + 0x42000800, 0x00000005, 0x0401f3d4, 0x59a80016, + 0x80000540, 0x04000020, 0x4803c857, 0x42001000, + 0x00104148, 0x0201f800, 0x00105f90, 0x59a80016, + 0x82000580, 0x00000014, 0x04020016, 0x59cc1006, + 0x82081580, 0x11040000, 0x04020012, 0x59cc1007, + 0x8c08153e, 0x0400000b, 0x59a80015, 0x8c000504, + 0x04020008, 0x42000000, 0x0010b83f, 0x0201f800, + 0x0010aa47, 0x59a80015, 0x84000544, 0x48035015, + 0x4a035014, 0x00000008, 0x0401f804, 0x0401f002, + 0x0401fb7d, 0x1c01f000, 0x4803c856, 0x4a035014, + 0x00000009, 0x83cca400, 0x00000006, 0x4200a800, + 0x0010b552, 0x4200b000, 0x00000005, 0x0201f800, + 0x0010ab17, 0x42007800, 0x0010b552, 0x46007800, + 0x11050100, 0x0401fb71, 0x0402000a, 0x59a80015, + 0x8c000500, 0x04020007, 0x0401fa8c, 0x04020005, + 0x82000540, 0x00000001, 0x0201f800, 0x001015fe, + 0x42000800, 0x00000005, 0x0401fb94, 0x0401fb63, + 0x04020ea4, 0x4d3c0000, 0x42027800, 0x00000001, + 0x0201f800, 0x00109874, 0x5c027800, 0x1c01f000, + 0x59a80016, 0x80000540, 0x0400003a, 0x4803c857, + 0x42001000, 0x00104148, 0x0201f800, 0x00105f90, + 0x59a80016, 0x82000580, 0x00000014, 0x04020030, + 0x59cc1006, 0x82080500, 0x11050000, 0x82000580, + 0x11050000, 0x0402002a, 0x8c081510, 0x04000014, + 0x59cc1007, 0x8c08153e, 0x0400000b, 0x59a80015, + 0x8c000504, 0x04020008, 0x42000000, 0x0010b83f, + 0x0201f800, 0x0010aa47, 0x59a80015, 0x84000544, + 0x48035015, 0x4a035013, 0x00000001, 0x4a035014, + 0x0000000a, 0x0401f818, 0x0401f016, 0x80000540, + 0x04020013, 0x59cc1007, 0x8c08153e, 0x0400000b, + 0x59a80015, 0x8c000504, 0x04020008, 0x42000000, + 0x0010b83f, 0x0201f800, 0x0010aa47, 0x59a80015, + 0x84000544, 0x48035015, 0x497b5013, 0x4a035014, + 0x0000000e, 0x0401f86d, 0x0401f002, 0x0401fb1a, + 0x1c01f000, 0x4803c856, 0x4a035014, 0x0000000b, + 0x42001000, 0x0010b553, 0x4008a800, 0x4200b000, + 0x00000020, 0x4600a800, 0xffffffff, 0x8054a800, + 0x8058b040, 0x040207fc, 0x42007800, 0x0010b552, + 0x46007800, 0x11060000, 0x42001000, 0x0010b553, + 0x0401fb0a, 0x04000005, 0x50080000, 0x46001000, + 0x00ffffff, 0x0401f00c, 0x50080800, 0x82040d00, + 0x0000ffff, 0x59a80010, 0x82000500, 0x000000ff, + 0x82000540, 0x00000100, 0x800000e0, 0x80040d40, + 0x44041000, 0x42000800, 0x00000021, 0x0401f327, + 0x59a80016, 0x80000540, 0x04000014, 0x4803c857, + 0x59a80016, 0x42001000, 0x00104148, 0x0201f800, + 0x00105f90, 0x59a80016, 0x82000580, 0x00000084, + 0x04020009, 0x59cc1006, 0x82081580, 0x11060000, + 0x04020005, 0x4a035014, 0x0000000c, 0x0401f804, + 0x0401f002, 0x0401fadc, 0x1c01f000, 0x4803c856, + 0x4a035014, 0x0000000d, 0x83cca400, 0x00000006, + 0x4200a800, 0x0010b552, 0x4200b000, 0x00000021, + 0x0201f800, 0x0010ab17, 0x42007800, 0x0010b552, + 0x46007800, 0x11070000, 0x42000800, 0x00000021, + 0x0401f2fe, 0x59a80016, 0x80000540, 0x04000016, + 0x4803c857, 0x59a80016, 0x42001000, 0x00104148, + 0x0201f800, 0x00105f90, 0x82000580, 0x00000084, + 0x0402000c, 0x59cc1006, 0x82081580, 0x11070000, + 0x04020008, 0x4a035013, 0x00000001, 0x0401fa91, + 0x4a035014, 0x0000000e, 0x0401f804, 0x0401f002, + 0x0401fab1, 0x1c01f000, 0x4803c856, 0x82040d40, + 0x00000001, 0x0401fbfc, 0x4a035014, 0x0000000f, + 0x497b5016, 0x42006000, 0xffffffff, 0x42006800, + 0x00300000, 0x0401fbe8, 0x42006000, 0xffdfffff, + 0x41786800, 0x0401fbe4, 0x42000800, 0x000007d0, + 0x42001000, 0x00104148, 0x0201f000, 0x00105f69, + 0x4803c856, 0x59a80016, 0x80000540, 0x04020296, + 0x1c01f000, 0x4803c856, 0x4a035014, 0x00000011, + 0x83cca400, 0x00000006, 0x4200a800, 0x0010b552, + 0x4200b000, 0x00000005, 0x0201f800, 0x0010ab17, + 0x4200a800, 0x0010b552, 0x4600a800, 0x11020000, + 0x0401fa8a, 0x04020015, 0x59a80010, 0x82000d00, + 0xffff0000, 0x04000011, 0x82000500, 0x000000ff, + 0x0400000e, 0x82000c00, 0x0010210e, 0x50040800, + 0x80040910, 0x82040580, 0x0000007e, 0x04000007, + 0x82040580, 0x00000080, 0x04000004, 0x42001000, + 0x00000004, 0x0401fa07, 0x42000800, 0x00000005, + 0x0401f2a2, 0x59a80016, 0x80000540, 0x04000020, + 0x4803c857, 0x42001000, 0x00104148, 0x0201f800, + 0x00105f90, 0x59a80016, 0x82000580, 0x00000014, + 0x04020016, 0x59cc1006, 0x82081580, 0x11030000, + 0x04020012, 0x59cc1007, 0x8c08153e, 0x0400000b, + 0x59a80015, 0x8c000504, 0x04020008, 0x42000000, + 0x0010b83f, 0x0201f800, 0x0010aa47, 0x59a80015, + 0x84000544, 0x48035015, 0x4a035014, 0x00000012, + 0x0401f804, 0x0401f002, 0x0401fa4b, 0x1c01f000, + 0x4803c856, 0x4a035014, 0x00000013, 0x83cca400, + 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000, + 0x00000005, 0x0201f800, 0x0010ab17, 0x4200a800, + 0x0010b552, 0x4600a800, 0x11030000, 0x0401fa3f, + 0x04020013, 0x59a80015, 0x8c000500, 0x04020010, + 0x59a80810, 0x82040580, 0x00ffffff, 0x0400000c, + 0x82040d00, 0x000000ff, 0x82040400, 0x0010210e, + 0x50000800, 0x80040910, 0x42001000, 0x00000004, + 0x0401f9c0, 0x04000002, 0x0401fafb, 0x42000800, + 0x00000005, 0x0401f259, 0x59a80016, 0x80000540, + 0x04000020, 0x4803c857, 0x42001000, 0x00104148, + 0x0201f800, 0x00105f90, 0x59a80016, 0x82000580, + 0x00000014, 0x04020016, 0x59cc1006, 0x82081580, + 0x11040000, 0x04020012, 0x59cc1007, 0x8c08153e, + 0x0400000b, 0x59a80015, 0x8c000504, 0x04020008, + 0x42000000, 0x0010b83f, 0x0201f800, 0x0010aa47, + 0x59a80015, 0x84000544, 0x48035015, 0x4a035014, + 0x00000014, 0x0401f804, 0x0401f002, 0x0401fa02, + 0x1c01f000, 0x4803c856, 0x4a035014, 0x00000015, + 0x83cca400, 0x00000006, 0x4200a800, 0x0010b552, + 0x4200b000, 0x00000005, 0x0201f800, 0x0010ab17, + 0x4200a800, 0x0010b552, 0x4600a800, 0x11040000, + 0x0401f9f6, 0x04020020, 0x59a80015, 0x8c000500, + 0x0402001d, 0x599c0017, 0x8c000500, 0x0400001a, + 0x599c1402, 0x82080480, 0x0000007f, 0x02021800, + 0x001005d8, 0x4c080000, 0x82081400, 0x0010210e, + 0x50081000, 0x82081500, 0x000000ff, 0x480b5010, + 0x42000800, 0x00000003, 0x0201f800, 0x00106c78, + 0x5c000800, 0x42001000, 0x00000004, 0x0401f96d, + 0x04000005, 0x0201f800, 0x00103abf, 0x02020800, + 0x001015fe, 0x42000800, 0x00000005, 0x0401f203, + 0x59a80016, 0x80000540, 0x0400003f, 0x4803c857, + 0x42001000, 0x00104148, 0x0201f800, 0x00105f90, + 0x59a80016, 0x82000580, 0x00000014, 0x04020035, + 0x59cc1006, 0x82080500, 0x11050000, 0x82000580, + 0x11050000, 0x0402002f, 0x8c081510, 0x04000010, + 0x0401fb09, 0x59cc1007, 0x8c08153e, 0x0400000b, + 0x59a80015, 0x8c000504, 0x04020008, 0x42000000, + 0x0010b83f, 0x0201f800, 0x0010aa47, 0x59a80015, + 0x84000544, 0x48035015, 0x0401f013, 0x59cc1007, + 0x8c08153e, 0x0400000b, 0x59a80015, 0x8c000504, + 0x04020008, 0x42000000, 0x0010b83f, 0x0201f800, + 0x0010aa47, 0x59a80015, 0x84000544, 0x48035015, + 0x82000540, 0x00000001, 0x0401faeb, 0x497b5013, + 0x0401f003, 0x4a035013, 0x00000001, 0x59cc1007, + 0x8c08153c, 0x04000003, 0x4a035026, 0x00000008, + 0x4a035014, 0x00000016, 0x0401f804, 0x0401f002, + 0x0401f98d, 0x1c01f000, 0x4803c856, 0x83cca400, + 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000, + 0x00000005, 0x0201f800, 0x0010ab17, 0x4a035014, + 0x00000017, 0x59a80013, 0x8c000500, 0x04000006, + 0x42001000, 0x0010b552, 0x46001000, 0x11050100, + 0x0401f003, 0x4a035014, 0x0000001b, 0x0401f97b, + 0x0402000a, 0x59a80015, 0x8c000500, 0x04020007, + 0x0401f896, 0x04020005, 0x82000540, 0x00000001, + 0x0201f800, 0x001015fe, 0x42000800, 0x00000005, + 0x0401f99e, 0x4d3c0000, 0x42027800, 0x00000001, + 0x0201f800, 0x00109874, 0x5c027800, 0x1c01f000, + 0x59a80016, 0x80000540, 0x04000015, 0x4803c857, + 0x42001000, 0x00104148, 0x0201f800, 0x00105f90, + 0x59a80016, 0x82000580, 0x00000084, 0x0402000b, + 0x59cc1006, 0x82081580, 0x11060000, 0x04020007, + 0x80000580, 0x0401faa0, 0x4a035014, 0x00000018, + 0x0401f804, 0x0401f002, 0x0401f94b, 0x1c01f000, + 0x4803c856, 0x4a035014, 0x00000019, 0x83cca400, + 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000, + 0x00000021, 0x0201f800, 0x0010ab17, 0x42003800, + 0x0010b553, 0x0401f941, 0x04020018, 0x401c2800, + 0x50141000, 0x80080130, 0x80000000, 0x40001800, + 0x82081500, 0x00ffffff, 0x800000f0, 0x80080540, + 0x44002800, 0x59a80810, 0x82040d00, 0x000000ff, + 0x400c1000, 0x80081104, 0x82082400, 0x0010b553, + 0x50101000, 0x820c0500, 0x00000003, 0x0c01f806, + 0x80081540, 0x44082000, 0x42000800, 0x00000021, + 0x0401f156, 0x0010401d, 0x00104022, 0x00104027, + 0x0010402c, 0x800408f0, 0x40040000, 0x82081500, + 0x00ffffff, 0x1c01f000, 0x800408e0, 0x40040000, + 0x82081500, 0xff00ffff, 0x1c01f000, 0x800408d0, + 0x40040000, 0x82081500, 0xffff00ff, 0x1c01f000, + 0x40040000, 0x82081500, 0xffffff00, 0x1c01f000, + 0x59a80016, 0x80000540, 0x04000016, 0x4803c857, + 0x42001000, 0x00104148, 0x0201f800, 0x00105f90, + 0x59a80016, 0x82000580, 0x00000084, 0x0402000c, + 0x59cc1006, 0x82081580, 0x11070000, 0x04020008, + 0x4a035013, 0x00000001, 0x0401f8d2, 0x4a035014, + 0x0000001a, 0x0401f804, 0x0401f002, 0x0401f8f2, + 0x1c01f000, 0x82000540, 0x00000001, 0x0401fa3e, + 0x4a035014, 0x0000001b, 0x83cca400, 0x00000006, + 0x4200a800, 0x0010b552, 0x59a82016, 0x40100000, + 0x8000b104, 0x40580800, 0x5450a800, 0x8050a000, + 0x8054a800, 0x8058b040, 0x040207fc, 0x0401f113, + 0x1c01f000, 0x1c01f000, 0x4803c856, 0x42003000, + 0x00000004, 0x42004000, 0x0010b553, 0x599c2817, + 0x8c142d14, 0x0402001f, 0x42001000, 0x00000003, + 0x40200000, 0x80080400, 0x50000800, 0x82042580, + 0xffffffff, 0x04020005, 0x80081040, 0x80183040, + 0x040207f8, 0x0401f05e, 0x800811c0, 0x04020006, + 0x82042580, 0x3fffffff, 0x04000058, 0x82040d40, + 0xc0000000, 0x4200b000, 0x00000020, 0x42001800, + 0x00000001, 0x40042000, 0x80102102, 0x04021021, + 0x800c18c2, 0x8058b040, 0x040207fc, 0x0401f04b, + 0x41781000, 0x40200000, 0x80080400, 0x50000800, + 0x82042580, 0xffffffff, 0x04020005, 0x80081000, + 0x80183040, 0x040207f8, 0x0401f040, 0x800811c0, + 0x04020003, 0x82040d40, 0xc0000000, 0x4200b000, + 0x00000001, 0x42001800, 0x80000000, 0x40042000, + 0x801020c2, 0x04021007, 0x800c1902, 0x8058b000, + 0x82580480, 0x00000021, 0x040017fa, 0x0401f02f, + 0x40200000, 0x80082400, 0x50100000, 0x800c0540, + 0x44002000, 0x59a80015, 0x84000540, 0x48035015, + 0x40580000, 0x42002800, 0x00000020, 0x80142c80, + 0x40080000, 0x42003800, 0x00000003, 0x801c0480, + 0x800000ca, 0x80142d40, 0x82144c00, 0x0010210e, + 0x50242800, 0x82142d00, 0x000000ff, 0x48175010, + 0x4c040000, 0x40140800, 0x0201f800, 0x001015eb, + 0x5c000800, 0x40001800, 0x500c0000, 0x80100540, + 0x44001800, 0x59a80015, 0x84000540, 0x48035015, + 0x4200a800, 0x0010b553, 0x4020a000, 0x4200b000, + 0x00000004, 0x0201f800, 0x0010ab17, 0x82000540, + 0x00000001, 0x0401f002, 0x80000580, 0x1c01f000, + 0x4807c857, 0x480bc857, 0x4008b000, 0x83cca400, + 0x00000007, 0x4200a800, 0x0010b553, 0x40541000, + 0x0201f800, 0x0010ab17, 0x40041800, 0x41782000, + 0x42000000, 0x00000003, 0x820c1c80, 0x00000020, + 0x04001004, 0x80102000, 0x80000040, 0x0401f7fb, + 0x40041800, 0x801021c0, 0x04000005, 0x820c1c80, + 0x00000020, 0x80102040, 0x040207fd, 0x42002000, + 0x00000001, 0x800c19c0, 0x04000004, 0x801020c2, + 0x800c1840, 0x040207fe, 0x80083c00, 0x83cc2c00, + 0x00000007, 0x80142c00, 0x50140000, 0x80102d00, + 0x04020012, 0x80100540, 0x44003800, 0x82042400, + 0x0010210e, 0x50102800, 0x82142d00, 0x000000ff, + 0x48175010, 0x4c040000, 0x40140800, 0x0201f800, + 0x001015eb, 0x5c000800, 0x59a80015, 0x84000540, + 0x48035015, 0x80000580, 0x1c01f000, 0x4807c856, + 0x42001000, 0x00008017, 0x59a8184e, 0x0201f800, + 0x0010aa4f, 0x0201f800, 0x00103a3e, 0x1c01f000, + 0x4807c856, 0x4200b000, 0x00000020, 0x83cca400, + 0x00000007, 0x4200a800, 0x0010be21, 0x0201f000, + 0x0010ab28, 0x4807c856, 0x0201f800, 0x00106ede, + 0x42000800, 0x000000f7, 0x0401f8de, 0x497b2804, + 0x497b2805, 0x497b281c, 0x497b281d, 0x4202d800, + 0x00000001, 0x42006000, 0xbf7fffff, 0x42006800, + 0x00018000, 0x0401f950, 0x42006000, 0xfffeffff, + 0x41786800, 0x0401f94c, 0x497b504e, 0x42000800, + 0x0000002d, 0x42001000, 0x001041bc, 0x0201f000, + 0x00105f69, 0x4807c856, 0x0401ffe3, 0x497b5014, + 0x497b5016, 0x1c01f000, 0x4807c856, 0x59a80005, + 0x8c000506, 0x1c01f000, 0x4807c856, 0x42006000, + 0xffffffff, 0x42006800, 0x00000028, 0x0401f136, + 0x4807c856, 0x0401ffc2, 0x0201f800, 0x00106c55, + 0x4df00000, 0x0201f800, 0x00106e21, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x59c400a4, 0x82000500, + 0x0000000f, 0x82000580, 0x00000002, 0x0402000a, + 0x42006000, 0xffffffff, 0x42006800, 0x00200000, + 0x0401f921, 0x42006000, 0xffdfffff, 0x41786800, + 0x0401f91d, 0x497b5014, 0x42000800, 0x000000f7, + 0x0401f89c, 0x59c400a3, 0x82000500, 0xbf20bfff, + 0x82000540, 0x0001c000, 0x480388a3, 0x84000520, + 0x480388a3, 0x1c01f000, 0x497b5016, 0x59b400f5, + 0x8c000500, 0x04020004, 0x82000540, 0x00000001, + 0x480368f5, 0x800400c4, 0x82000400, 0x00002000, + 0x4803910a, 0x59b400f6, 0x82000500, 0x00000018, + 0x040207fd, 0x4a0368f0, 0x0010b54b, 0x42000000, + 0x0010b552, 0x480368f1, 0x82040400, 0x0000dc00, + 0x480368f3, 0x59c400a4, 0x82000500, 0x0000000f, + 0x82000580, 0x00000008, 0x04020017, 0x4c5c0000, + 0x4c600000, 0x59c4b805, 0x8c5cbd3a, 0x04020005, + 0x42000000, 0x0010b818, 0x0201f800, 0x0010aa47, + 0x4a038805, 0x02000000, 0x0201f800, 0x001019fe, + 0x4000c000, 0x0201f800, 0x00101963, 0x4202d800, + 0x00000001, 0x497b5014, 0x5c00c000, 0x5c00b800, + 0x1c01f000, 0x59c8010b, 0x8c000502, 0x040007e2, + 0x59c408a4, 0x82040d00, 0x0000000f, 0x82040d80, + 0x0000000b, 0x04020005, 0x59a80814, 0x82040d40, + 0x00002000, 0x0401f004, 0x59a80812, 0x82040d40, + 0x00001000, 0x4807504e, 0x59a8084a, 0x800409c0, + 0x04020007, 0x42000800, 0x000007d0, 0x42001000, + 0x00104148, 0x0201f800, 0x0010606e, 0x1c01f000, + 0x4807c856, 0x0401ff4e, 0x0201f800, 0x00106c55, + 0x4df00000, 0x0201f800, 0x00106e21, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x59c400a4, 0x82000500, + 0x0000000f, 0x82000580, 0x00000002, 0x0402000a, + 0x42006000, 0xffffffff, 0x42006800, 0x00200000, + 0x0401f8ad, 0x42006000, 0xffdfffff, 0x41786800, + 0x0401f8a9, 0x0201f800, 0x00105141, 0x04000014, + 0x0201f800, 0x00105151, 0x04020011, 0x4a035032, + 0x0000aaaa, 0x4c040000, 0x0201f800, 0x0010162a, + 0x59a8002a, 0x82000500, 0xffff0000, 0x80040540, + 0x4803502a, 0x5c000800, 0x4a035033, 0x00000000, + 0x0201f800, 0x001050a2, 0x0401f008, 0x4a03504c, + 0x00000005, 0x42000000, 0x00000001, 0x0201f800, + 0x00101590, 0x0401ff2c, 0x1c01f000, 0x0401f805, + 0x42006000, 0xbf7f7fff, 0x41786800, 0x0401f086, + 0x0201f800, 0x00105151, 0x04020005, 0x59c40006, + 0x82000540, 0x000000f0, 0x48038806, 0x1c01f000, + 0x800408d0, 0x59a80015, 0x8c000506, 0x04000006, + 0x59a80010, 0x82000500, 0x000000ff, 0x80040540, + 0x0401f003, 0x82040540, 0x000000f7, 0x480388a7, + 0x1c01f000, 0x4807c856, 0x42000000, 0x0010b83b, + 0x0201f800, 0x0010aa47, 0x42003000, 0x00000005, + 0x4d3c0000, 0x4c180000, 0x42003000, 0x0000000d, + 0x42027800, 0x00000002, 0x0401f038, 0x4807c856, + 0x42000000, 0x0010b86b, 0x0201f800, 0x0010aa47, + 0x42003000, 0x00000000, 0x4d3c0000, 0x4c180000, + 0x42003000, 0x0000000f, 0x42027800, 0x00000002, + 0x0401f02a, 0x4807c856, 0x42000000, 0x0010b86a, + 0x0201f800, 0x0010aa47, 0x42003000, 0x00000003, + 0x4d3c0000, 0x4c180000, 0x42003000, 0x0000000e, + 0x42027800, 0x00000202, 0x0401f01c, 0x4807c856, + 0x42000000, 0x0010b869, 0x0201f800, 0x0010aa47, + 0x42003000, 0x00000004, 0x4d3c0000, 0x4c180000, + 0x42003000, 0x00000010, 0x42027800, 0x00000202, + 0x0401f00e, 0x4807c856, 0x42000000, 0x0010b83e, + 0x0201f800, 0x0010aa47, 0x42003000, 0x00000001, + 0x4d3c0000, 0x4c180000, 0x42003000, 0x0000000c, + 0x42027800, 0x00000202, 0x42001800, 0x0000ffff, + 0x42002000, 0x00000007, 0x0201f800, 0x00103aae, + 0x5c003000, 0x4d400000, 0x0201f800, 0x0010a95d, + 0x42028000, 0x0000002a, 0x0201f800, 0x00101fe5, + 0x5c028000, 0x5c027800, 0x1c01f000, 0x4807c856, + 0x04011000, 0x4a03c840, 0x0010b54b, 0x4a03c842, + 0x00000040, 0x40000000, 0x040117ff, 0x42007800, + 0x0010b54b, 0x46007800, 0x00000011, 0x803c7800, + 0x4a007800, 0x220000ef, 0x4a007801, 0x000000ef, + 0x4a007802, 0x01380000, 0x4a007803, 0x00000000, + 0x4a007804, 0xffffffff, 0x4a007805, 0x00000000, + 0x1c01f000, 0x59c400a3, 0x80300500, 0x80340540, + 0x480388a3, 0x1c01f000, 0x4833c857, 0x59c400a3, + 0x80300540, 0x480388a3, 0x80300580, 0x480388a3, + 0x1c01f000, 0x4803c856, 0x04000004, 0x4a03504b, + 0x00000001, 0x0401f002, 0x497b504b, 0x1c01f000, + 0x4803c856, 0x59c80002, 0x80000540, 0x0400000a, + 0x80000040, 0x04000008, 0x4a039005, 0x00000140, + 0x42000000, 0x00000006, 0x80000040, 0x040207ff, + 0x0401f7f4, 0x1c01f000, 0x4c5c0000, 0x4c600000, + 0x59c4b805, 0x485fc856, 0x8c5cbd3a, 0x04020005, + 0x42000000, 0x0010b818, 0x0201f800, 0x0010aa47, + 0x4a038805, 0x02000000, 0x0201f800, 0x001019fe, + 0x4000c000, 0x0201f800, 0x00101963, 0x4a038805, + 0x04000000, 0x5c00c000, 0x5c00b800, 0x1c01f000, + 0x497a6a00, 0x4937c857, 0x4a026c00, 0x00000707, + 0x497a6801, 0x497a6808, 0x497a6809, 0x497a6806, + 0x497a6807, 0x497a6c0b, 0x497a680c, 0x0201f800, + 0x00103b25, 0x04020006, 0x5934080f, 0x59340010, + 0x80040540, 0x02020800, 0x001005d8, 0x4a026a04, + 0x00000100, 0x497a6a03, 0x59340402, 0x82000500, + 0x000000ff, 0x48026c02, 0x497a6c04, 0x497a6a05, + 0x497a6c05, 0x497a6811, 0x4d2c0000, 0x5934000d, + 0x49466c03, 0x80025d40, 0x04000004, 0x0201f800, + 0x001007fd, 0x497a680d, 0x5c025800, 0x599c0401, + 0x48026a0b, 0x599c0208, 0x48026c12, 0x497a680a, + 0x0201f000, 0x00104c62, 0x42000000, 0x00000005, + 0x80000d80, 0x0401f02d, 0x0201f800, 0x00104a09, + 0x04020017, 0x59a80026, 0x8c00050a, 0x04020010, + 0x59340212, 0x82000500, 0x0000ff00, 0x4803c857, + 0x0400000b, 0x59340a00, 0x8c040d1e, 0x02000000, + 0x000201c4, 0x42000000, 0x00000029, 0x42000800, + 0x00001000, 0x492fc857, 0x0401f018, 0x492fc857, + 0x42000000, 0x00000028, 0x0401f012, 0x59a80805, + 0x8c040d02, 0x04020003, 0x8c040d00, 0x04000004, + 0x42000000, 0x00000004, 0x0401f00a, 0x42000000, + 0x00000029, 0x59340a00, 0x8c040d1e, 0x04000005, + 0x492fc857, 0x42000800, 0x00001000, 0x0401f003, + 0x492fc857, 0x80000d80, 0x4803c857, 0x80028540, + 0x1c01f000, 0x4803c857, 0x59a80005, 0x8c000500, + 0x040207ec, 0x0201f800, 0x001049e7, 0x040207e4, + 0x59340200, 0x8c00050e, 0x040007e1, 0x0201f000, + 0x000201c4, 0x0201f800, 0x001047eb, 0x040007bf, + 0x0201f000, 0x000201c8, 0x592c0206, 0x492fc857, + 0x82000d80, 0x000007ff, 0x04020006, 0x4a025c0a, + 0x00000030, 0x42026800, 0x0010b524, 0x0401f021, + 0x82000c80, 0x000007f0, 0x04021046, 0x81ac0400, + 0x50000000, 0x80026d40, 0x04000038, 0x0201f800, + 0x001048e3, 0x04020038, 0x592c040a, 0x8c00050a, + 0x04020014, 0x592e6009, 0x83300480, 0x0010d1c0, + 0x0400103b, 0x41580000, 0x81300480, 0x04021038, + 0x59300c06, 0x82040580, 0x00000009, 0x04020037, + 0x4a025a06, 0x00000000, 0x497a5800, 0x59300008, + 0x80000540, 0x04020018, 0x492e6008, 0x0401f010, + 0x0201f800, 0x0002075a, 0x04000019, 0x592c0206, + 0x49366009, 0x492e6008, 0x4a026406, 0x00000009, + 0x497a6015, 0x49325809, 0x82000d80, 0x000007ff, + 0x04020003, 0x4a026015, 0x00008000, 0x42027000, + 0x00000043, 0x0201f800, 0x000207a1, 0x80000580, + 0x0401f020, 0x40000800, 0x58040000, 0x80000d40, + 0x040207fd, 0x492c0800, 0x0401f01a, 0x42000000, + 0x0000002c, 0x0401f016, 0x42000000, 0x00000028, + 0x0401f013, 0x59a80805, 0x82040500, 0x00000003, + 0x04000004, 0x42000000, 0x00000004, 0x0401f00c, + 0x42000000, 0x00000029, 0x0401f009, 0x42000000, + 0x00000008, 0x0401f006, 0x82040580, 0x00000007, + 0x040207fb, 0x42000000, 0x00000005, 0x80000540, + 0x1c01f000, 0x492fc857, 0x592e8c06, 0x83440d80, + 0x000007fc, 0x04000004, 0x83440480, 0x000007f0, + 0x04021014, 0x0201f800, 0x00020245, 0x04020011, + 0x0201f800, 0x001049f3, 0x04020011, 0x0201f800, + 0x0002075a, 0x0400001c, 0x49366009, 0x492e6008, + 0x4a026406, 0x0000000a, 0x42027000, 0x00000040, + 0x0201f800, 0x000207a1, 0x80000580, 0x0401f011, + 0x42000000, 0x00000028, 0x0401f00d, 0x0201f800, + 0x00104a09, 0x040007fb, 0x59a80805, 0x82040d00, + 0x00000003, 0x04000004, 0x42000000, 0x00000004, + 0x0401f003, 0x42000000, 0x00000029, 0x80000540, + 0x1c01f000, 0x42000000, 0x0000002c, 0x0401f7fc, + 0x492fc857, 0x592e8c06, 0x4947c857, 0x83440c80, + 0x00000800, 0x42000000, 0x0000000a, 0x04021176, + 0x592c4207, 0x4823c857, 0x82200500, 0x0000000f, + 0x0c01f001, 0x001043d5, 0x0010445d, 0x001044a9, + 0x001044b4, 0x001044bf, 0x001043d1, 0x001043d1, + 0x001043d1, 0x001044cf, 0x00104513, 0x00104530, + 0x001043d1, 0x001043d1, 0x001043d1, 0x001043d1, + 0x001043d1, 0x4803c857, 0x42000000, 0x0000000c, + 0x0401f15d, 0x592c1008, 0x82081500, 0x00ffffff, + 0x59a80010, 0x80084d80, 0x42000000, 0x00000010, + 0x04000155, 0x0201f800, 0x00104919, 0x04000036, + 0x4803c857, 0x82004d80, 0x0000001d, 0x0402001a, + 0x0201f800, 0x00105755, 0x59340405, 0x4c000000, + 0x0201f800, 0x001049e7, 0x5c000000, 0x04000004, + 0x8c20450a, 0x04000028, 0x80000580, 0x44002800, + 0x59340008, 0x48002802, 0x59340009, 0x48002801, + 0x59340006, 0x48002804, 0x59340007, 0x48002803, + 0x4200b000, 0x00000005, 0x0201f800, 0x0010955f, + 0x0401f166, 0x4803c857, 0x82004d80, 0x0000001a, + 0x04020003, 0x40101000, 0x0401f136, 0x4803c857, + 0x82004d80, 0x0000001b, 0x04020003, 0x40181000, + 0x0401f130, 0x4803c857, 0x82004d80, 0x0000001c, + 0x04000131, 0x82004d80, 0x00000019, 0x42000000, + 0x0000000a, 0x04000120, 0x42000000, 0x0000000a, + 0x04020137, 0x59a80005, 0x8c000514, 0x0400001b, + 0x0201f800, 0x001049e7, 0x04000018, 0x59340212, + 0x82000500, 0x0000ff00, 0x42001000, 0x00000010, + 0x0402000c, 0x42001000, 0x00000008, 0x59a80026, + 0x8c000506, 0x04020009, 0x59340002, 0x82000500, + 0x00ff0000, 0x82000580, 0x00ff0000, 0x04000007, + 0x0201f800, 0x00104c6d, 0x42000000, 0x0000001c, + 0x40181000, 0x04020107, 0x0201f800, 0x0002075a, + 0x04000111, 0x49366009, 0x492e6008, 0x4a026406, + 0x00000001, 0x8c20450a, 0x04000004, 0x592c0404, + 0x8400055c, 0x48025c04, 0x4c200000, 0x4d3c0000, + 0x42027800, 0x00001000, 0x0201f800, 0x0010203c, + 0x5c027800, 0x5c004000, 0x8c204512, 0x0400000b, + 0x599c0018, 0x8c000518, 0x04000008, 0x592c0009, + 0x82000500, 0x00000380, 0x5934080a, 0x80040d40, + 0x84040d54, 0x4806680a, 0x417a7800, 0x0401f914, + 0x42000800, 0x00000003, 0x0401f91b, 0x42027000, + 0x00000002, 0x0201f800, 0x000207a1, 0x80000580, + 0x0401f10a, 0x0201f800, 0x00020245, 0x040200ec, + 0x0201f800, 0x001049ed, 0x04000008, 0x0201f800, + 0x001049e7, 0x040200ec, 0x417a7800, 0x417a6000, + 0x0201f800, 0x001020a1, 0x59a80005, 0x8c000514, + 0x0400001b, 0x0201f800, 0x001049e7, 0x04000018, + 0x59340212, 0x82000500, 0x0000ff00, 0x42001000, + 0x00000010, 0x0402000c, 0x42001000, 0x00000008, + 0x59a80026, 0x8c000506, 0x04020009, 0x59340002, + 0x82000500, 0x00ff0000, 0x82000580, 0x00ff0000, + 0x04000007, 0x0201f800, 0x00104c6d, 0x42000000, + 0x0000001c, 0x40181000, 0x040200b2, 0x0201f800, + 0x0002075a, 0x040000bc, 0x5934080a, 0x8c204512, + 0x0400000c, 0x599c0018, 0x8c000518, 0x04000009, + 0x592c0009, 0x82000500, 0x00000380, 0x82041500, + 0xfffffc7f, 0x80080d40, 0x84040d54, 0x0401f002, + 0x84040d14, 0x4806680a, 0x49366009, 0x492e6008, + 0x4a026406, 0x00000001, 0x417a7800, 0x0401f8c8, + 0x42000800, 0x00000005, 0x0401f8cf, 0x42027000, + 0x00000003, 0x0201f800, 0x000207a1, 0x80000580, + 0x0401f0be, 0x0201f800, 0x00020245, 0x040200a0, + 0x0201f800, 0x001049fc, 0x040200a3, 0x0201f800, + 0x00109517, 0x04000094, 0x80000580, 0x0401f0b3, + 0x0201f800, 0x00020245, 0x04020095, 0x0201f800, + 0x001049fc, 0x04020098, 0x0201f800, 0x001090e6, + 0x04000089, 0x80000580, 0x0401f0a8, 0x0201f800, + 0x00020245, 0x0402008a, 0x83444d80, 0x000007fe, + 0x42000000, 0x0000000a, 0x0402006b, 0x0201f800, + 0x001049e7, 0x04020088, 0x0201f800, 0x0010952f, + 0x04000079, 0x80000580, 0x0401f098, 0x82200500, + 0x00000070, 0x04020005, 0x8c20450e, 0x42000000, + 0x0000000c, 0x0402005c, 0x8c20450a, 0x0400000d, + 0x4d3c0000, 0x42027800, 0x00001000, 0x8c20450e, + 0x04020002, 0x853e7d56, 0x82200500, 0x000000a0, + 0x0201f800, 0x001049d3, 0x5c027800, 0x0401f07f, + 0x0201f800, 0x00020245, 0x04020065, 0x8c204508, + 0x04000010, 0x4d3c0000, 0x42027800, 0x00001000, + 0x8c20450e, 0x04020002, 0x853e7d56, 0x82200500, + 0x00000090, 0x0201f800, 0x001049bb, 0x5c027800, + 0x42000000, 0x0000000a, 0x0402003b, 0x0401f06b, + 0x836c0580, 0x00000003, 0x42000800, 0x00000007, + 0x0402000f, 0x0201f800, 0x001049f3, 0x04000007, + 0x4c000000, 0x0201f800, 0x00104a1f, 0x5c000000, + 0x0400004d, 0x0401f05d, 0x0201f800, 0x001094c5, + 0x04000007, 0x80000580, 0x0401f05c, 0x0201f800, + 0x00104a1f, 0x04000051, 0x0401f054, 0x0201f800, + 0x00104a1f, 0x04000034, 0x0401f050, 0x0201f800, + 0x00020245, 0x04020036, 0x836c0580, 0x00000003, + 0x04020040, 0x8c204508, 0x04000006, 0x417a7800, + 0x417a6000, 0x0201f800, 0x001020a1, 0x0401f043, + 0x0201f800, 0x001049ed, 0x04000008, 0x0201f800, + 0x001049e7, 0x0402002c, 0x417a7800, 0x417a6000, + 0x0201f800, 0x001020a1, 0x480bc856, 0x0201f800, + 0x00109332, 0x04000018, 0x80000580, 0x0401f037, + 0x0401f7e3, 0x480bc857, 0x42000800, 0x00000019, + 0x40001000, 0x4200b000, 0x00000002, 0x0401f00a, + 0x480bc857, 0x40000800, 0x4200b000, 0x00000002, + 0x0401f005, 0x480bc857, 0x40000800, 0x4200b000, + 0x00000001, 0x480bc857, 0x42028000, 0x00000031, + 0x0401f020, 0x480bc857, 0x42000800, 0x00000003, + 0x4200b000, 0x00000001, 0x0401f7f7, 0x480bc857, + 0x42000800, 0x0000000a, 0x4200b000, 0x00000001, + 0x0401f7f1, 0x480bc857, 0x42000800, 0x00000009, + 0x40001000, 0x4200b000, 0x00000002, 0x0401f7ea, + 0x480bc857, 0x42000800, 0x00000007, 0x4200b000, + 0x00000001, 0x0401f7e4, 0x480bc857, 0x4200b000, + 0x00000001, 0x0401f7e0, 0x80028580, 0x4178b000, + 0x82000540, 0x00000001, 0x1c01f000, 0x4937c857, + 0x59326809, 0x59341200, 0x813e79c0, 0x04000003, + 0x84081540, 0x0401f002, 0x84081500, 0x480a6a00, + 0x1c01f000, 0x59326809, 0x5c000000, 0x4c000000, + 0x4803c857, 0x4937c857, 0x82040580, 0x00000006, + 0x04020004, 0x42000000, 0x00000606, 0x0401f021, + 0x82040580, 0x00000004, 0x04020004, 0x42000000, + 0x00000404, 0x0401f01b, 0x82040580, 0x00000007, + 0x42000000, 0x00000707, 0x04000016, 0x82040580, + 0x00000003, 0x42000000, 0x00000703, 0x04000011, + 0x82040580, 0x00000005, 0x42000000, 0x00000405, + 0x0400000c, 0x82040580, 0x00000009, 0x42000000, + 0x00000409, 0x04000007, 0x82040580, 0x0000000b, + 0x42000000, 0x0000070b, 0x02020800, 0x001005d8, + 0x4803c857, 0x48026c00, 0x82040d80, 0x00000006, + 0x04020005, 0x59341404, 0x800811c0, 0x02000800, + 0x001005d8, 0x1c01f000, 0x5c000000, 0x4c000000, + 0x4803c857, 0x4947c857, 0x481bc857, 0x83440480, + 0x00000800, 0x04021034, 0x83441400, 0x0010ac00, + 0x50080000, 0x80026d40, 0x04020011, 0x4c180000, + 0x4d2c0000, 0x0201f800, 0x001007d3, 0x412e6800, + 0x5c025800, 0x5c003000, 0x04000027, 0x45341000, + 0x497a680d, 0x497a6810, 0x497a680f, 0x497a680e, + 0x4c180000, 0x0401fcf3, 0x5c003000, 0x59340a12, + 0x4c040000, 0x0201f800, 0x0010513b, 0x5c000800, + 0x04000009, 0x82180500, 0x00ffff00, 0x04000008, + 0x59a81010, 0x82081500, 0x00ffff00, 0x80080580, + 0x04000003, 0x80000580, 0x0401f004, 0x82180500, + 0x000000ff, 0x800000d0, 0x80040d80, 0x04000003, + 0x4803c857, 0x48026a12, 0x59340002, 0x80180580, + 0x04000003, 0x481bc857, 0x481a6802, 0x80000580, + 0x1c01f000, 0x4803c856, 0x82000540, 0x00000001, + 0x0401f7fc, 0x4947c857, 0x83440480, 0x00000800, + 0x04021011, 0x83441400, 0x0010ac00, 0x50080000, + 0x80026d40, 0x0400000b, 0x0401fbf9, 0x0402000a, + 0x59a80005, 0x8c000502, 0x04000004, 0x59340200, + 0x8c00050e, 0x04000004, 0x82000540, 0x00000001, + 0x1c01f000, 0x80000580, 0x0401f7fe, 0x5c000000, + 0x4c000000, 0x4803c857, 0x4947c857, 0x4d2c0000, + 0x4d300000, 0x83440480, 0x00000800, 0x04021024, + 0x83441400, 0x0010ac00, 0x50080000, 0x80026d40, + 0x0400001b, 0x45781000, 0x5934000d, 0x80025d40, + 0x02020800, 0x001007fd, 0x59366011, 0x813261c0, + 0x0400000e, 0x4c640000, 0x5930c800, 0x59325808, + 0x0201f800, 0x00109037, 0x02020800, 0x001007fd, + 0x0201f800, 0x0002077d, 0x82666540, 0x00000000, + 0x040207f6, 0x5c00c800, 0x0201f800, 0x00104c62, + 0x41365800, 0x0201f800, 0x001007f5, 0x80000580, + 0x5c026000, 0x5c025800, 0x1c01f000, 0x82000540, + 0x00000001, 0x0401f7fb, 0x4937c857, 0x4c580000, + 0x59cc0001, 0x82000500, 0x00ffffff, 0x48026802, + 0x497a6c01, 0x497a6a01, 0x59340200, 0x84000502, + 0x48026a00, 0x0201f800, 0x0010513b, 0x04020017, + 0x59340403, 0x82000580, 0x000007fe, 0x04000005, + 0x59a80026, 0x8c00050a, 0x04020010, 0x0401f008, + 0x59cc0408, 0x8c000518, 0x0400000c, 0x59cc0009, + 0x48035035, 0x59cc000a, 0x48035036, 0x59cc0207, + 0x80000540, 0x04020003, 0x42000000, 0x00000001, + 0x48038893, 0x4803501e, 0x59cc0a09, 0x82040d00, + 0x00000010, 0x59cc0408, 0x82000500, 0x00000020, + 0x04000002, 0x84040d40, 0x5934000a, 0x82000500, + 0xffffffee, 0x80040540, 0x4802680a, 0x83cca400, + 0x0000000b, 0x8334ac00, 0x00000006, 0x4200b000, + 0x00000002, 0x0201f800, 0x0010ab17, 0x83cca400, + 0x0000000d, 0x8334ac00, 0x00000008, 0x4200b000, + 0x00000002, 0x0201f800, 0x0010ab17, 0x59cc0a18, + 0x82040480, 0x00000800, 0x0402100c, 0x82040480, + 0x00000400, 0x04001004, 0x42000800, 0x00000400, + 0x0401f006, 0x82040480, 0x00000200, 0x04001003, + 0x42000800, 0x00000200, 0x48066a04, 0x59340403, + 0x82000580, 0x000007fe, 0x04020003, 0x59cc0a08, + 0x48066a04, 0x42000800, 0x00000004, 0x59cc1207, + 0x800811c0, 0x04000005, 0x82080480, 0x00000004, + 0x04021002, 0x40080800, 0x48066c04, 0x5c00b000, + 0x1c01f000, 0x4937c857, 0x59a80026, 0x8c000508, + 0x04000004, 0x84000556, 0x4803c857, 0x48035026, + 0x59cc0207, 0x4803c857, 0x48026a05, 0x59cc020a, + 0x4803c857, 0x48026c05, 0x59341200, 0x599c0818, + 0x5934180a, 0x4807c857, 0x480bc857, 0x480fc857, + 0x59cc2006, 0x82102500, 0xff000000, 0x82102580, + 0x02000000, 0x04000007, 0x8c00050e, 0x04000009, + 0x8c0c1d14, 0x04000003, 0x8c0c1d0e, 0x04000005, + 0x8c040d18, 0x04000003, 0x8408154a, 0x0401f002, + 0x8408150a, 0x8c000510, 0x04000009, 0x8c0c1d14, + 0x04000003, 0x8c0c1d10, 0x04000005, 0x8c040d18, + 0x04000003, 0x8408154e, 0x0401f002, 0x8408150e, + 0x8c000512, 0x04000009, 0x8c0c1d14, 0x04000003, + 0x8c0c1d12, 0x04000005, 0x8c040d18, 0x04000003, + 0x8408155c, 0x0401f002, 0x8408151c, 0x480a6a00, + 0x1c01f000, 0x4803c856, 0x4c5c0000, 0x4d2c0000, + 0x4c580000, 0x5934000d, 0x80025d40, 0x04000029, + 0x592c0003, 0x82000480, 0x00000008, 0x0400100b, + 0x412cb800, 0x592c0001, 0x80025d40, 0x040207f9, + 0x0201f800, 0x001007e4, 0x04000037, 0x492fc857, + 0x492cb801, 0x0401f020, 0x832c0c00, 0x00000004, + 0x4200b000, 0x00000008, 0x50040000, 0x82000580, + 0xffffffff, 0x04020006, 0x80041000, 0x50080000, + 0x82000580, 0xffffffff, 0x04000007, 0x82040c00, + 0x00000002, 0x8058b040, 0x040207f4, 0x0201f800, + 0x001005d8, 0x45480800, 0x454c1000, 0x592c1803, + 0x800c1800, 0x480e5803, 0x480fc857, 0x0401f014, + 0x0201f800, 0x001007e4, 0x04000017, 0x492fc857, + 0x492e680d, 0x497a5802, 0x4a025803, 0x00000001, + 0x494a5804, 0x494e5805, 0x832c0c00, 0x00000006, + 0x4200b000, 0x0000000e, 0x46000800, 0xffffffff, + 0x80040800, 0x8058b040, 0x040207fc, 0x82000540, + 0x00000001, 0x5c00b000, 0x5c025800, 0x5c00b800, + 0x1c01f000, 0x80000580, 0x0401f7fb, 0x4803c856, + 0x4d3c0000, 0x4d2c0000, 0x5934000d, 0x80025d40, + 0x0400001f, 0x592c0002, 0x80000540, 0x0402001f, + 0x412e7800, 0x0401f8ce, 0x0402001c, 0x46000800, + 0xffffffff, 0x46001000, 0xffffffff, 0x4813c857, + 0x480fc857, 0x580c0003, 0x82000c80, 0x00000002, + 0x04021014, 0x480fc857, 0x400c0000, 0x812c0580, + 0x04020004, 0x580c0001, 0x4802680d, 0x0401f003, + 0x580c0001, 0x48002001, 0x400e5800, 0x0201f800, + 0x001007f4, 0x82000540, 0x00000001, 0x5c025800, + 0x5c027800, 0x1c01f000, 0x80000580, 0x0401f7fc, + 0x80000040, 0x48001803, 0x4803c857, 0x0401f7f6, + 0x0201f800, 0x00020086, 0x59300007, 0x8400054e, + 0x48026007, 0x592c1a04, 0x820c1d00, 0x000000ff, + 0x820c0580, 0x00000048, 0x04000013, 0x0201f000, + 0x0002028e, 0x8c000500, 0x02020800, 0x000200e5, + 0x4a026203, 0x00000002, 0x592c1a04, 0x820c1d00, + 0x000000ff, 0x820c0580, 0x00000018, 0x02000000, + 0x0002028e, 0x820c0580, 0x00000048, 0x02020000, + 0x0002028e, 0x42000800, 0x80000804, 0x0201f800, + 0x00106721, 0x0201f000, 0x00020297, 0x4a025a06, + 0x00000008, 0x0201f000, 0x000202da, 0x4a025a06, + 0x00000029, 0x0201f000, 0x000202da, 0x4a025a06, + 0x0000002a, 0x0201f000, 0x000202da, 0x4a025a06, + 0x00000028, 0x0201f000, 0x000202da, 0x4943c857, + 0x4d440000, 0x4d340000, 0x4d2c0000, 0x4c580000, + 0x4200b000, 0x000007f0, 0x417a8800, 0x0201f800, + 0x00020245, 0x0402000d, 0x8d3e7d14, 0x04000005, + 0x59340212, 0x82000500, 0x0000ff00, 0x04000007, + 0x8d3e7d06, 0x04000004, 0x59340200, 0x8c00050e, + 0x04020002, 0x0401f813, 0x81468800, 0x8058b040, + 0x040207ef, 0x83440480, 0x00000800, 0x04021008, + 0x8d3e7d02, 0x04000006, 0x42028800, 0x000007f0, + 0x4200b000, 0x00000010, 0x0401f7e5, 0x5c00b000, + 0x5c025800, 0x5c026800, 0x5c028800, 0x1c01f000, + 0x4d2c0000, 0x41783000, 0x5936580f, 0x812e59c0, + 0x04000029, 0x592c0204, 0x82000500, 0x000000ff, + 0x82000580, 0x00000012, 0x04000020, 0x8d3e7d00, + 0x04000003, 0x0401f83c, 0x0402001c, 0x592c2000, + 0x497a5800, 0x801831c0, 0x04020009, 0x59340010, + 0x812c0580, 0x04020004, 0x497a680f, 0x497a6810, + 0x0401f008, 0x4812680f, 0x0401f006, 0x48103000, + 0x59340010, 0x812c0580, 0x04020002, 0x481a6810, + 0x4a025a04, 0x00000103, 0x49425a06, 0x497a5c09, + 0x0201f800, 0x001091c6, 0x0201f800, 0x000202da, + 0x40125800, 0x0401f7da, 0x412c3000, 0x592e5800, + 0x0401f7d7, 0x5c025800, 0x1c01f000, 0x4803c856, + 0x41781800, 0x5934000f, 0x80025d40, 0x04000010, + 0x592c0005, 0x80200580, 0x592c0000, 0x04000003, + 0x412c1800, 0x0401f7f9, 0x497a5800, 0x800c19c0, + 0x04000008, 0x48001800, 0x80000540, 0x04020004, + 0x480e6810, 0x82000540, 0x00000001, 0x1c01f000, + 0x4802680f, 0x80000540, 0x040207fd, 0x497a6810, + 0x0401f7f9, 0x592c0008, 0x81480580, 0x04020003, + 0x592c0009, 0x814c0580, 0x1c01f000, 0x4803c856, + 0x4c580000, 0x413c1800, 0x400c2000, 0x593c0002, + 0x80000540, 0x04020018, 0x4200b000, 0x00000008, + 0x820c0c00, 0x00000004, 0x50040000, 0x81480580, + 0x04020005, 0x80041000, 0x50080000, 0x814c0580, + 0x0400000d, 0x82040c00, 0x00000002, 0x8058b040, + 0x040207f6, 0x400c2000, 0x580c0001, 0x80001d40, + 0x040207ee, 0x82000540, 0x00000001, 0x5c00b000, + 0x1c01f000, 0x80000580, 0x0401f7fd, 0x4937c857, + 0x4c580000, 0x4d2c0000, 0x5934000d, 0x80025d40, + 0x04020016, 0x0201f800, 0x001007e4, 0x04000010, + 0x492e680d, 0x4a025802, 0x00000001, 0x497a5803, + 0x832c0c00, 0x00000004, 0x4200b000, 0x00000010, + 0x46000800, 0xffffffff, 0x80040800, 0x8058b040, + 0x040207fc, 0x82000540, 0x00000001, 0x5c025800, + 0x5c00b000, 0x1c01f000, 0x4d2c0000, 0x592e5801, + 0x0201f800, 0x001007fd, 0x5c025800, 0x0401f7ea, + 0x4d2c0000, 0x5936580d, 0x812e59c0, 0x04000007, + 0x4937c857, 0x497a680d, 0x0201f800, 0x001007fd, + 0x82000540, 0x00000001, 0x5c025800, 0x1c01f000, + 0x59340405, 0x4937c857, 0x4803c857, 0x8c000508, + 0x1c01f000, 0x4803c856, 0x0201f800, 0x0010513b, + 0x04000011, 0x59a80815, 0x8c040d04, 0x0402000e, + 0x59a80826, 0x8c040d06, 0x0400000b, 0x83ac0400, + 0x000007fe, 0x50000000, 0x80026d40, 0x04000006, + 0x0401f9a7, 0x04020004, 0x59340200, 0x8400055a, + 0x48026a00, 0x599c0017, 0x8c000508, 0x04000015, + 0x4200b000, 0x000007f0, 0x417a8800, 0x0201f800, + 0x00020245, 0x0402000c, 0x0401f999, 0x0402000a, + 0x59a80010, 0x59340802, 0x80040580, 0x82000500, + 0x00ffff00, 0x04020004, 0x59340200, 0x8400055a, + 0x48026a00, 0x81468800, 0x8058b040, 0x040207f0, + 0x0401f884, 0x04000003, 0x59a80836, 0x0401f006, + 0x599c0017, 0x8c000508, 0x04000007, 0x42000800, + 0x000007d0, 0x42001000, 0x00104876, 0x0201f800, + 0x0010606e, 0x1c01f000, 0x4803c856, 0x4d340000, + 0x4d440000, 0x4d3c0000, 0x4c580000, 0x42001000, + 0x00104876, 0x0201f800, 0x00105f90, 0x59a80826, + 0x8c040d06, 0x04000015, 0x0401f86a, 0x04000013, + 0x83ae6c00, 0x000007fe, 0x51366800, 0x59340200, + 0x8400051a, 0x48026a00, 0x599c0017, 0x8c000508, + 0x04000007, 0x42000800, 0x000007d0, 0x42001000, + 0x00104876, 0x0201f800, 0x0010606e, 0x0201f800, + 0x00101e45, 0x0401f027, 0x4200b000, 0x000007f0, + 0x80028d80, 0x0201f800, 0x00020245, 0x0402001e, + 0x59340200, 0x8c00051a, 0x0400001b, 0x59368c03, + 0x417a7800, 0x42028000, 0x00000029, 0x41783000, + 0x0201f800, 0x0010a446, 0x59340200, 0x84000558, + 0x8400051a, 0x48026a00, 0x4937c857, 0x4a026c00, + 0x00000707, 0x42028000, 0x00000029, 0x0201f800, + 0x00106ab4, 0x417a7800, 0x0201f800, 0x001067fd, + 0x80000d80, 0x0201f800, 0x0010a2ff, 0x0201f800, + 0x00106c4b, 0x81468800, 0x8058b040, 0x040207de, + 0x5c00b000, 0x5c027800, 0x5c028800, 0x5c026800, + 0x1c01f000, 0x4933c857, 0x59303809, 0x581c0200, + 0x8400051a, 0x48003a00, 0x1c01f000, 0x4803c856, + 0x42026800, 0x0010b524, 0x497a680e, 0x42028800, + 0x000007ff, 0x0201f800, 0x001042b4, 0x4937c857, + 0x4a026c00, 0x00000606, 0x4a026802, 0x00ffffff, + 0x4a026a04, 0x00000200, 0x4a026c04, 0x00000002, + 0x1c01f000, 0x59300009, 0x50000000, 0x4933c857, + 0x4803c857, 0x8c00050e, 0x1c01f000, 0x59300009, + 0x50000000, 0x8c00050a, 0x1c01f000, 0x4933c856, + 0x0401f90f, 0x04000006, 0x59340400, 0x82000d00, + 0x000000ff, 0x82041580, 0x00000005, 0x1c01f000, + 0x4d340000, 0x83ac0400, 0x000007fe, 0x50000000, + 0x80026d40, 0x04000003, 0x59340200, 0x8c00051a, + 0x5c026800, 0x1c01f000, 0x4937c857, 0x493fc857, + 0x59340403, 0x81ac0400, 0x50000000, 0x81340580, + 0x02020800, 0x001005d8, 0x59341200, 0x813e79c0, + 0x04000003, 0x8408155e, 0x0401f002, 0x8408151e, + 0x480a6a00, 0x1c01f000, 0x4937c857, 0x0201f800, + 0x0010210a, 0x04000006, 0x59a80835, 0x42001000, + 0x00104910, 0x0201f800, 0x0010606e, 0x1c01f000, + 0x4937c857, 0x42001000, 0x00104910, 0x0201f800, + 0x00105f90, 0x59a81026, 0x84081512, 0x480b5026, + 0x1c01f000, 0x4c380000, 0x4c340000, 0x4c240000, + 0x4c600000, 0x4008c000, 0x83440480, 0x00000800, + 0x04021045, 0x80002d80, 0x41442000, 0x83447400, + 0x0010ac00, 0x4200b000, 0x000007f0, 0x83444c80, + 0x000007f0, 0x04001003, 0x4200b000, 0x00000010, + 0x50380000, 0x80000540, 0x0402001e, 0x41440000, + 0x80100580, 0x04020043, 0x40102800, 0x82104c80, + 0x000007f0, 0x04001015, 0x82104d80, 0x000007fc, + 0x04020005, 0x82604d80, 0x00fffffc, 0x0402002a, + 0x0401f00e, 0x82104d80, 0x000007fd, 0x04020005, + 0x82604d80, 0x00fffffd, 0x04020023, 0x0401f007, + 0x82104d80, 0x000007ff, 0x0402001f, 0x82604d80, + 0x00ffffff, 0x0402001c, 0x84142d5e, 0x0401f029, + 0x40006800, 0x58343002, 0x82183500, 0x00ffffff, + 0x40180000, 0x80600580, 0x04020019, 0x40100000, + 0x81440580, 0x0402000a, 0x40366800, 0x8c204508, + 0x04000053, 0x0401ff8a, 0x04020051, 0x4947c857, + 0x42000000, 0x0000001d, 0x0401f04e, 0x4947c857, + 0x480bc857, 0x4823c857, 0x42000000, 0x0000001a, + 0x0401f048, 0x4947c857, 0x4863c857, 0x4813c857, + 0x42000000, 0x00000019, 0x0401f042, 0x40100000, + 0x81440580, 0x04020007, 0x58343002, 0x4947c857, + 0x481bc857, 0x42000000, 0x0000001b, 0x0401f039, + 0x80102000, 0x80387000, 0x83444c80, 0x000007f0, + 0x04001009, 0x82104d80, 0x00000800, 0x0402000c, + 0x42002000, 0x000007f0, 0x42007000, 0x0010b3f0, + 0x0401f007, 0x82104d80, 0x000007f0, 0x04020004, + 0x41782000, 0x42007000, 0x0010ac00, 0x8058b040, + 0x040207a4, 0x801429c0, 0x04020007, 0x0201f800, + 0x001005d8, 0x4947c857, 0x42000000, 0x0000000a, + 0x0401f01c, 0x4d2c0000, 0x4c180000, 0x40603000, + 0x0401fc12, 0x4947c857, 0x4937c857, 0x5c003000, + 0x5c025800, 0x040207f4, 0x497a6a12, 0x59a80026, + 0x8c00050a, 0x0402000d, 0x82600500, 0x00ffff00, + 0x04000006, 0x59a84810, 0x82244d00, 0x00ffff00, + 0x80240580, 0x04020005, 0x82600500, 0x000000ff, + 0x800000d0, 0x48026a12, 0x48626802, 0x80000580, + 0x80000540, 0x5c00c000, 0x5c004800, 0x5c006800, + 0x5c007000, 0x1c01f000, 0x5934000f, 0x5934140b, + 0x80081040, 0x04001002, 0x480a6c0b, 0x80000540, + 0x02020800, 0x00020253, 0x1c01f000, 0x4803c857, + 0x4947c857, 0x4c300000, 0x82006500, 0x00000030, + 0x04000006, 0x4c000000, 0x0201f800, 0x0010942a, + 0x5c000000, 0x0402000b, 0x8c00050e, 0x04000006, + 0x0201f800, 0x00020245, 0x04020006, 0x4937c857, + 0x0401fc2f, 0x80000580, 0x5c006000, 0x1c01f000, + 0x82000540, 0x00000001, 0x0401f7fc, 0x4803c857, + 0x4c580000, 0x4d440000, 0x40001000, 0x80000d80, + 0x4200b000, 0x000007f0, 0x4c040000, 0x40068800, + 0x4c080000, 0x40080000, 0x0401ffdd, 0x5c001000, + 0x5c000800, 0x80040800, 0x8058b040, 0x040207f7, + 0x5c028800, 0x5c00b000, 0x1c01f000, 0x4c5c0000, + 0x59340400, 0x8200bd80, 0x00000606, 0x5c00b800, + 0x1c01f000, 0x4c5c0000, 0x59340400, 0x8200bd80, + 0x00000404, 0x5c00b800, 0x1c01f000, 0x4c5c0000, + 0x59340400, 0x8200bd80, 0x00000404, 0x04000003, + 0x8200bd80, 0x00000606, 0x5c00b800, 0x1c01f000, + 0x4c5c0000, 0x4c600000, 0x59340400, 0x8200bd00, + 0x0000ff00, 0x825cc580, 0x00000400, 0x04000003, + 0x825cc580, 0x00000600, 0x5c00c000, 0x5c00b800, + 0x1c01f000, 0x4c5c0000, 0x59340400, 0x82000500, + 0x000000ff, 0x8200bd80, 0x00000003, 0x04000003, + 0x8200bd80, 0x00000005, 0x5c00b800, 0x1c01f000, + 0x4c5c0000, 0x59340400, 0x82000500, 0x0000ff00, + 0x8400b9c0, 0x805c0580, 0x4937c857, 0x4803c857, + 0x48026c00, 0x5c00b800, 0x1c01f000, 0x4c040000, + 0x4c080000, 0x592c0207, 0x8c00050c, 0x0400000f, + 0x592e8c06, 0x82000500, 0x00000080, 0x84000548, + 0x4d3c0000, 0x42027800, 0x00001000, 0x0401ff90, + 0x5c027800, 0x82000540, 0x00000001, 0x5c001000, + 0x5c000800, 0x1c01f000, 0x80000580, 0x0401f7fc, + 0x592c040b, 0x82000500, 0x0000e000, 0x82000580, + 0x00006000, 0x04000019, 0x836c0580, 0x00000003, + 0x04000016, 0x836c0580, 0x00000002, 0x040200ff, + 0x59a80026, 0x82000d00, 0x00000038, 0x04020005, + 0x59a80832, 0x800409c0, 0x0400000c, 0x0401f0f7, + 0x82000d00, 0x00000003, 0x82040d80, 0x00000003, + 0x040200f2, 0x82000d00, 0x00000028, 0x04020003, + 0x8c00050c, 0x040000ed, 0x592c100a, 0x82080500, + 0xff000000, 0x040200ce, 0x59a80010, 0x80080580, + 0x040000c8, 0x592c0c0b, 0x82040d00, 0x0000e000, + 0x82040480, 0x00008000, 0x040210c8, 0x592e8c06, + 0x83440480, 0x00000800, 0x04001007, 0x83440580, + 0x0000ffff, 0x040200af, 0x800409c0, 0x040200f7, + 0x0401f0ac, 0x800409c0, 0x040200f4, 0x41784000, + 0x0401fead, 0x040200db, 0x42027000, 0x00000053, + 0x592c2409, 0x82100500, 0xffffff00, 0x040200aa, + 0x4813c857, 0x592c000c, 0x800001c0, 0x04000083, + 0x82100580, 0x00000004, 0x040000a0, 0x82100580, + 0x00000051, 0x0400009d, 0x82100580, 0x00000003, + 0x04000016, 0x82100580, 0x00000020, 0x0400004b, + 0x82100580, 0x00000024, 0x04000042, 0x82100580, + 0x00000021, 0x04000042, 0x82100580, 0x00000050, + 0x04000037, 0x82100580, 0x00000052, 0x04000031, + 0x82100580, 0x00000005, 0x0402006b, 0x42027000, + 0x00000001, 0x0401f01b, 0x42027000, 0x00000002, + 0x59a80005, 0x8c000514, 0x04000016, 0x0401ff4c, + 0x04000014, 0x59340212, 0x82000500, 0x0000ff00, + 0x42001000, 0x00000010, 0x0402000c, 0x59a80026, + 0x8c000506, 0x0402006f, 0x42001000, 0x00000008, + 0x59340002, 0x82000500, 0x00ff0000, 0x82000580, + 0x00ff0000, 0x04000003, 0x0401f9bf, 0x04020065, + 0x0201f800, 0x0002075a, 0x0400007e, 0x4a026406, + 0x00000010, 0x49366009, 0x42000800, 0x00000003, + 0x83380580, 0x00000002, 0x04000003, 0x42000800, + 0x0000000b, 0x0201f800, 0x00104571, 0x0401f044, + 0x42027000, 0x00000000, 0x0401f003, 0x42027000, + 0x00000004, 0x0401ff37, 0x04020071, 0x0401f036, + 0x42027000, 0x00000033, 0x0401f006, 0x42027000, + 0x00000005, 0x0401f003, 0x42027000, 0x00000003, + 0x0401ff23, 0x04020066, 0x59a80005, 0x8c000514, + 0x04000016, 0x0401ff12, 0x04000014, 0x59340212, + 0x82000500, 0x0000ff00, 0x42001000, 0x00000010, + 0x0402000c, 0x59a80026, 0x8c000506, 0x04020035, + 0x42001000, 0x00000008, 0x59340002, 0x82000500, + 0x00ff0000, 0x82000580, 0x00ff0000, 0x04000003, + 0x0401f985, 0x0402002b, 0x0201f800, 0x0002075a, + 0x04000044, 0x4a026406, 0x00000010, 0x49366009, + 0x42000800, 0x00000005, 0x83380580, 0x00000003, + 0x04000003, 0x42000800, 0x00000009, 0x0201f800, + 0x00104571, 0x0401f00a, 0x82102580, 0x00000011, + 0x0402002d, 0x0201f800, 0x0002075a, 0x04000031, + 0x4a026406, 0x00000010, 0x49366009, 0x492e6008, + 0x49325808, 0x813669c0, 0x04000007, 0x592c0c0b, + 0x8c040d18, 0x04000004, 0x59340200, 0x84000514, + 0x48026a00, 0x0201f800, 0x000207a1, 0x80000580, + 0x1c01f000, 0x82000540, 0x00000001, 0x0401f7fd, + 0x42001000, 0x0000000a, 0x0401f015, 0x42001000, + 0x00000010, 0x0401f012, 0x42001000, 0x00000016, + 0x0401f00f, 0x42001000, 0x00000017, 0x0401f00c, + 0x42001000, 0x00000018, 0x0401f009, 0x42001000, + 0x0000001b, 0x0401f006, 0x42001000, 0x0000001e, + 0x0401f003, 0x42001000, 0x00000020, 0x42000800, + 0x00000019, 0x42028000, 0x00000031, 0x0401f7e2, + 0x42000800, 0x00000003, 0x0401f003, 0x42000800, + 0x0000000a, 0x41781000, 0x0401f7f7, 0x42000800, + 0x00000009, 0x59341400, 0x0401f7f3, 0x42028000, + 0x00000008, 0x0401f005, 0x42000800, 0x00000007, + 0x416c1000, 0x0401f7ec, 0x41780800, 0x41781000, + 0x0401f7cd, 0x42028000, 0x00000000, 0x0401f7fb, + 0x82004d80, 0x0000001d, 0x02000800, 0x001005d8, + 0x82004d80, 0x0000001a, 0x04020004, 0x40101000, + 0x40000800, 0x0401f7dc, 0x82004d80, 0x0000001b, + 0x04020003, 0x40181000, 0x0401f7fa, 0x82004d80, + 0x0000001c, 0x040007f7, 0x82004d80, 0x00000019, + 0x040007b8, 0x0401f7d6, 0x592e6008, 0x0201f800, + 0x0010941a, 0x040007b6, 0x59300c06, 0x82040580, + 0x00000011, 0x040207d6, 0x83440580, 0x0000ffff, + 0x04020005, 0x59326809, 0x813669c0, 0x0400000e, + 0x0401f7cf, 0x592c100a, 0x82081500, 0x00ffffff, + 0x41784000, 0x0401fda8, 0x040207d6, 0x59300009, + 0x800001c0, 0x04000003, 0x81340580, 0x040207c4, + 0x49366009, 0x592c0c0b, 0x82041500, 0x0000e000, + 0x82080580, 0x00006000, 0x04000009, 0x59300a03, + 0x82040580, 0x00000007, 0x040207b9, 0x492e6008, + 0x42027000, 0x00000054, 0x0401f77f, 0x0201f800, + 0x0010a8d4, 0x040007bc, 0x0401f7b1, 0x492fc857, + 0x59a80021, 0x800001c0, 0x04020073, 0x592e6008, + 0x4933c857, 0x0201f800, 0x0010941a, 0x04000041, + 0x59301406, 0x82080580, 0x00000005, 0x0402005b, + 0x59301203, 0x82080580, 0x00000007, 0x04020057, + 0x592e8c06, 0x83440480, 0x00000800, 0x04021032, + 0x41784000, 0x592c1009, 0x82081500, 0x00ffffff, + 0x0401fd75, 0x0402005f, 0x59300009, 0x800001c0, + 0x04000003, 0x81340580, 0x04020048, 0x4d300000, + 0x592e6013, 0x4933c857, 0x83300580, 0xffffffff, + 0x0400000d, 0x0201f800, 0x0010941a, 0x5c026000, + 0x04000029, 0x591c1406, 0x82080580, 0x00000006, + 0x04000046, 0x82080580, 0x00000011, 0x04000043, + 0x0401f002, 0x5c026000, 0x59a80010, 0x592c100a, + 0x82081500, 0x00ffffff, 0x80081580, 0x04020017, + 0x592c1009, 0x82081500, 0x00ffffff, 0x80081580, + 0x0400000f, 0x49366009, 0x492e6008, 0x42027000, + 0x00000092, 0x0201f800, 0x000207a1, 0x80000580, + 0x1c01f000, 0x42001000, 0x0000000a, 0x0401f00c, + 0x42001000, 0x00000010, 0x0401f009, 0x42001000, + 0x00000014, 0x0401f006, 0x42001000, 0x00000018, + 0x0401f003, 0x42001000, 0x0000003c, 0x492fc857, + 0x480bc857, 0x42000800, 0x00000019, 0x42028000, + 0x00000031, 0x82000540, 0x00000001, 0x0401f7e9, + 0x492fc857, 0x4803c857, 0x480bc857, 0x40000800, + 0x0401f7f7, 0x492fc857, 0x42000800, 0x0000000a, + 0x41781000, 0x0401f7f2, 0x4933c857, 0x59300406, + 0x4803c857, 0x59300203, 0x4803c857, 0x59300009, + 0x4803c857, 0x42028000, 0x00000008, 0x41780800, + 0x41781000, 0x0401f7e8, 0x42000800, 0x0000001e, + 0x0401f7f0, 0x42000800, 0x00000001, 0x0401f7ed, + 0x82004d80, 0x0000001d, 0x02000800, 0x001005d8, + 0x82004d80, 0x0000001a, 0x04020003, 0x40101000, + 0x0401f7dc, 0x82004d80, 0x0000001b, 0x04020003, + 0x40181000, 0x0401f7d7, 0x82004d80, 0x0000001c, + 0x040007d4, 0x82004d80, 0x00000019, 0x040007d1, + 0x0401f7d5, 0x59302009, 0x801021c0, 0x04000035, + 0x58101400, 0x82081d00, 0x000000ff, 0x59300c03, + 0x82040580, 0x00000008, 0x04000022, 0x82040580, + 0x0000000a, 0x04000017, 0x82040580, 0x0000000c, + 0x04000010, 0x82040580, 0x00000002, 0x04000019, + 0x82040580, 0x00000001, 0x04000012, 0x82040580, + 0x00000003, 0x0400000b, 0x82040580, 0x00000005, + 0x04000004, 0x82040580, 0x00000033, 0x04020019, + 0x820c0580, 0x00000009, 0x0400000d, 0x0401f015, + 0x820c0580, 0x00000005, 0x04000009, 0x0401f011, + 0x820c0580, 0x0000000b, 0x04000005, 0x0401f00d, + 0x820c0580, 0x00000003, 0x0402000a, 0x82081d00, + 0xffffff00, 0x840c01c0, 0x800c0540, 0x4813c857, + 0x480bc857, 0x4807c857, 0x4803c857, 0x48002400, + 0x1c01f000, 0x599c0017, 0x8c00050a, 0x04000003, + 0x80000580, 0x1c01f000, 0x59a80026, 0x82000500, + 0x00000028, 0x04000008, 0x42028800, 0x000007fd, + 0x0201f800, 0x00020245, 0x04020003, 0x5934000a, + 0x8c000504, 0x1c01f000, 0x4d300000, 0x5934000e, + 0x80026540, 0x04000006, 0x0201f800, 0x001062d5, + 0x02000800, 0x001064ad, 0x497a680e, 0x5c026000, + 0x1c01f000, 0x4d440000, 0x4d340000, 0x80000580, + 0x40001800, 0x40028800, 0x82080580, 0x00000008, + 0x04020003, 0x42001800, 0x00000001, 0x0201f800, + 0x00020245, 0x0402000a, 0x0401fd6d, 0x04020008, + 0x800c19c0, 0x04000004, 0x59340405, 0x8c000508, + 0x04000003, 0x80081040, 0x04000009, 0x81468800, + 0x83440480, 0x00000800, 0x040017f1, 0x80000580, + 0x5c026800, 0x5c028800, 0x1c01f000, 0x82000540, + 0x00000001, 0x5c026800, 0x5c028800, 0x1c01f000, + 0x4a033020, 0x00000000, 0x497b3026, 0x497b3027, + 0x497b3028, 0x497b3029, 0x497b302b, 0x497b3021, + 0x4a03b104, 0x60000001, 0x1c01f000, 0x4803c856, + 0x599c0018, 0x497b3024, 0x497b3025, 0x82000500, + 0x0000000f, 0x82000d80, 0x00000005, 0x04000006, + 0x82000580, 0x00000006, 0x0400000d, 0x497b3022, + 0x1c01f000, 0x4a033022, 0x00000005, 0x599c0216, + 0x82000500, 0x0000ffff, 0x04020003, 0x42000000, + 0x00000002, 0x48033023, 0x1c01f000, 0x4a033022, + 0x00000006, 0x0401f7f6, 0x0401ffe5, 0x4a03c826, + 0x00000004, 0x599c0209, 0x80000540, 0x0400001f, + 0x599c0207, 0x80000540, 0x04000007, 0x800000cc, + 0x599c080d, 0x80040400, 0x4803b100, 0x497bb102, + 0x59d80101, 0x599c000d, 0x4803b100, 0x599c000e, + 0x4803b101, 0x599c0207, 0x80000540, 0x04020002, + 0x497bb102, 0x599c0a09, 0x82040540, 0x00400000, + 0x59980822, 0x4803b103, 0x4a03b109, 0x00000004, + 0x4a03b104, 0x10000001, 0x800409c0, 0x04020004, + 0x4a033020, 0x00000001, 0x1c01f000, 0x4a033020, + 0x00000002, 0x0401f7fd, 0x59980022, 0x4803c856, + 0x80000540, 0x02000000, 0x000202de, 0x0401f017, + 0x42034000, 0x0010b4a4, 0x59a1d81e, 0x80edd9c0, + 0x02000800, 0x001005d8, 0x58ec0009, 0x48efc857, + 0x49a3c857, 0x492fc857, 0x4803c857, 0x800001c0, + 0x08020000, 0x0201f800, 0x001005d8, 0x5931d821, + 0x58ef400b, 0x58ec0009, 0x800001c0, 0x08020000, + 0x0201f800, 0x001005d8, 0x497a5800, 0x59980026, + 0x80000540, 0x0402008c, 0x59d80105, 0x82000d00, + 0x00018780, 0x040201da, 0x80000106, 0x82000500, + 0x00000003, 0x0c01f001, 0x00104d0a, 0x00104d89, + 0x00104d22, 0x00104d50, 0x592c0001, 0x492fc857, + 0x492fb107, 0x80000d40, 0x04020007, 0x59940019, + 0x80000540, 0x04022003, 0x59980023, 0x48032819, + 0x1c01f000, 0x497a5801, 0x40065800, 0x592c0001, + 0x496a5800, 0x815eb800, 0x412ed000, 0x80000d40, + 0x040207f9, 0x59c80000, 0x82000540, 0x00001200, + 0x48039000, 0x0401f7ee, 0x492fc857, 0x492fb107, + 0x592c0001, 0x80000d40, 0x04020012, 0x59da5908, + 0x835c0480, 0x00000020, 0x0400101c, 0x0402b01a, + 0x492fb007, 0x0400e7fa, 0x59d80105, 0x82000500, + 0x00018780, 0x040201aa, 0x59940019, 0x80000540, + 0x04022003, 0x59980023, 0x48032819, 0x1c01f000, + 0x497a5801, 0x40065800, 0x592c0001, 0x496a5800, + 0x815eb800, 0x412ed000, 0x80000d40, 0x040207f9, + 0x59c80000, 0x82000540, 0x00001200, 0x48039000, + 0x0401f7e3, 0x0400f009, 0x496a5800, 0x412ed000, + 0x815eb800, 0x59c80000, 0x82000540, 0x00001200, + 0x48039000, 0x0401f7e0, 0x492fa807, 0x0401f7de, + 0x492fc857, 0x59d81108, 0x45681000, 0x400ad000, + 0x815eb800, 0x0400e7fc, 0x59c80000, 0x82000540, + 0x00001200, 0x48039000, 0x0402d00c, 0x592c0001, + 0x492fc857, 0x492fb107, 0x80000d40, 0x0402001d, + 0x59940019, 0x80000540, 0x04022003, 0x59980023, + 0x48032819, 0x1c01f000, 0x59d80105, 0x82000500, + 0x00018780, 0x04020172, 0x42000000, 0x0010b855, + 0x0201f800, 0x0010aa47, 0x59980026, 0x59980828, + 0x80000000, 0x48033026, 0x492fc857, 0x800409c0, + 0x492f3028, 0x04000003, 0x492c0800, 0x0401f002, + 0x492f3029, 0x592c0001, 0x80000d40, 0x040007e5, + 0x497a5801, 0x40065800, 0x592c0001, 0x496a5800, + 0x815eb800, 0x412ed000, 0x80000d40, 0x040207f9, + 0x59c80000, 0x82000540, 0x00001200, 0x48039000, + 0x0401f7d8, 0x59980026, 0x59980828, 0x80000000, + 0x48033026, 0x492fc857, 0x800409c0, 0x492f3028, + 0x04000003, 0x492c0800, 0x0401f002, 0x492f3029, + 0x592c0001, 0x80000d40, 0x04020027, 0x0402d00e, + 0x59980029, 0x80025d40, 0x0400000f, 0x59980026, + 0x80000040, 0x48033026, 0x04020002, 0x48033028, + 0x592c0000, 0x48033029, 0x492fc857, 0x492fb107, + 0x0400d7f4, 0x42000000, 0x0010b855, 0x0201f800, + 0x0010aa47, 0x0402e00a, 0x59da5908, 0x496a5800, + 0x412ed000, 0x815eb800, 0x0400e7fc, 0x59c80000, + 0x82000540, 0x00001200, 0x48039000, 0x59d80105, + 0x82000500, 0x00018780, 0x04020125, 0x59940019, + 0x80000540, 0x04022003, 0x59980023, 0x48032819, + 0x1c01f000, 0x497a5801, 0x40065800, 0x592c0001, + 0x496a5800, 0x815eb800, 0x412ed000, 0x80000d40, + 0x040207f9, 0x59c80000, 0x82000540, 0x00001200, + 0x48039000, 0x0401f7ce, 0x592c0204, 0x4803c856, + 0x04000008, 0x42034000, 0x0010b4a4, 0x59a1d81e, + 0x80edd9c0, 0x02000800, 0x001005d8, 0x0401f003, + 0x5931d821, 0x58ef400b, 0x58ec0009, 0x800001c0, + 0x08020000, 0x0201f800, 0x001005d8, 0x497a5801, + 0x40065800, 0x592c0001, 0x496a5800, 0x412ed000, + 0x815eb800, 0x80000d40, 0x040207f9, 0x59c80000, + 0x82000540, 0x00001200, 0x48039000, 0x1c01f000, + 0x497a5801, 0x40065800, 0x592c0001, 0x496a5800, + 0x412ed000, 0x815eb800, 0x80000d40, 0x040207f9, + 0x59c80000, 0x82000540, 0x00001200, 0x48039000, + 0x0200e000, 0x000202fb, 0x0201f000, 0x00020302, + 0x5998002b, 0x84000540, 0x4803302b, 0x0201f000, + 0x0002035e, 0x42000000, 0x0010b855, 0x0201f800, + 0x0010aa47, 0x492fc857, 0x59980026, 0x59980828, + 0x80000000, 0x48033026, 0x800409c0, 0x492f3028, + 0x04000003, 0x492c0800, 0x0401f002, 0x492f3029, + 0x592c0001, 0x80000d40, 0x04020002, 0x1c01f000, + 0x497a5801, 0x40065800, 0x592c0001, 0x496a5800, + 0x412ed000, 0x815eb800, 0x80000d40, 0x040207f9, + 0x59c80000, 0x82000540, 0x00001200, 0x48039000, + 0x1c01f000, 0x59980026, 0x59980828, 0x80000000, + 0x48033026, 0x492fc857, 0x800409c0, 0x492f3028, + 0x04000003, 0x492c0800, 0x0401f002, 0x492f3029, + 0x592c0001, 0x80000d40, 0x04020039, 0x0402d00e, + 0x59980029, 0x80025d40, 0x0400000f, 0x59980026, + 0x80000040, 0x48033026, 0x04020002, 0x48033028, + 0x592c0000, 0x48033029, 0x492fc857, 0x492fb107, + 0x0400d7f4, 0x42000000, 0x0010b855, 0x0201f800, + 0x0010aa47, 0x0402e01d, 0x59da5908, 0x496a5800, + 0x412ed000, 0x815eb800, 0x0400e7fc, 0x59c80000, + 0x82000540, 0x00001200, 0x48039000, 0x04006018, + 0x59d8010a, 0x59d8090a, 0x80040d80, 0x040207fd, + 0x900001c0, 0x82000540, 0x00000013, 0x4803c011, + 0x5998002b, 0x84000500, 0x4803302b, 0x59e00017, + 0x8c000508, 0x04000003, 0x4a03c017, 0x00000003, + 0x4203e000, 0x30000001, 0x59d80105, 0x82000500, + 0x00018780, 0x0402007e, 0x1c01f000, 0x5998002b, + 0x84000540, 0x4803302b, 0x0401f7f8, 0x497a5801, + 0x40065800, 0x592c0001, 0x496a5800, 0x412ed000, + 0x815eb800, 0x80000d40, 0x040207f9, 0x59c80000, + 0x82000540, 0x00001200, 0x48039000, 0x0401f7bc, + 0x5c000000, 0x4c000000, 0x4803c857, 0x492fc857, + 0x4943c857, 0x4807c857, 0x4a025a04, 0x00000103, + 0x49425a06, 0x48065a08, 0x4a025c06, 0x0000ffff, + 0x813261c0, 0x04000003, 0x59300402, 0x48025c06, + 0x832c0400, 0x00000009, 0x04011000, 0x4803c840, + 0x4a03c842, 0x0000000b, 0x04011000, 0x1c01f000, + 0x4df00000, 0x4203e000, 0x50000000, 0x599cb817, + 0x59940019, 0x80000540, 0x04002023, 0x0400000e, + 0x59980022, 0x82000580, 0x00000005, 0x0400001e, + 0x59a80069, 0x81640580, 0x0402001b, 0x8c5cbd08, + 0x04000005, 0x59a8006a, 0x59a80866, 0x80040580, + 0x04020015, 0x8c5cbd08, 0x04020030, 0x59d8090b, + 0x59d8010a, 0x80040580, 0x0400000d, 0x0400600e, + 0x4a03c011, 0x80400012, 0x4a03c020, 0x00008040, + 0x59e00017, 0x8c000508, 0x04000003, 0x4a03c017, + 0x00000002, 0x4203e000, 0x30000001, 0x4a032819, + 0xffff0000, 0x04026835, 0x04006003, 0x8c5cbd08, + 0x04020860, 0x59980029, 0x80025d40, 0x04000010, + 0x59d80105, 0x82000500, 0x00018780, 0x04020020, + 0x0402d00d, 0x59980026, 0x492fc857, 0x80000040, + 0x48033026, 0x592c0000, 0x492fb107, 0x48033029, + 0x04020003, 0x4803c856, 0x48033028, 0x5c03e000, + 0x1c01f000, 0x42000000, 0x0010b855, 0x0201f800, + 0x0010aa47, 0x0401f7fa, 0x59e0000f, 0x59e0080f, + 0x80040580, 0x040207fd, 0x59e00010, 0x59e01010, + 0x80081580, 0x040207fd, 0x40065000, 0x80041580, + 0x040007c7, 0x040067dc, 0x0401f7ca, 0x4803c857, + 0x485fc857, 0x8c00050e, 0x02020800, 0x001005d0, + 0x4203e000, 0x50000000, 0x4200b800, 0x00008004, + 0x0201f000, 0x001005dd, 0x5998002b, 0x8c000500, + 0x04000013, 0x84000500, 0x4803302b, 0x59d8010a, + 0x59d8090a, 0x80040580, 0x040207fd, 0x800408e0, + 0x82040d40, 0x00000013, 0x4807c011, 0x59e00017, + 0x8c000508, 0x04000003, 0x4a03c017, 0x00000003, + 0x4203e000, 0x30000001, 0x1c01f000, 0x0402e014, + 0x59da5908, 0x496a5800, 0x412ed000, 0x815eb800, + 0x0400e7fc, 0x59c80000, 0x82000540, 0x00001200, + 0x48039000, 0x59d8090b, 0x59980024, 0x48073024, + 0x80040480, 0x04020004, 0x59940019, 0x80000540, + 0x04022003, 0x59980823, 0x48072819, 0x59d80105, + 0x82000500, 0x00018780, 0x040207c9, 0x1c01f000, + 0x59981025, 0x59e00010, 0x59e00810, 0x80041d80, + 0x040207fd, 0x80080580, 0x04000013, 0x48073025, + 0x59e0000f, 0x59e0100f, 0x80081d80, 0x040207fd, + 0x81280580, 0x04000008, 0x400a5000, 0x40080000, + 0x80040580, 0x04000003, 0x59980823, 0x48072819, + 0x1c01f000, 0x59940019, 0x80000540, 0x040227f8, + 0x0401f7fc, 0x59e0000f, 0x59e0100f, 0x80081d80, + 0x040207fd, 0x81280580, 0x040007f6, 0x400a5000, + 0x59940019, 0x80000540, 0x040027ed, 0x0401f7f1, + 0x59a80017, 0x82000c80, 0x0000000a, 0x02021800, + 0x001005d8, 0x0c01f809, 0x4a038805, 0x000000f0, + 0x59c400a3, 0x82000500, 0x02870000, 0x02020800, + 0x001005d8, 0x1c01f000, 0x00104fc5, 0x00104f51, + 0x00104f6c, 0x00104f95, 0x00104fb8, 0x00104ff2, + 0x00105004, 0x00104f6c, 0x00104fd6, 0x00104f50, + 0x1c01f000, 0x4a038808, 0x00000004, 0x0401f8f9, + 0x0201f800, 0x001053ab, 0x59c40805, 0x8c040d0e, + 0x04020013, 0x8c040d0a, 0x0402000b, 0x8c040d0c, + 0x04020006, 0x8c040d08, 0x0400000d, 0x4a035017, + 0x00000003, 0x0401f00a, 0x4a035017, 0x00000000, + 0x0401f007, 0x42000000, 0x0010b844, 0x0201f800, + 0x0010aa47, 0x4a035017, 0x00000002, 0x1c01f000, + 0x4a038808, 0x00000002, 0x0401f8de, 0x59c40805, + 0x8c040d08, 0x04020021, 0x8c040d0c, 0x0402001c, + 0x8c040d0e, 0x04020017, 0x82040500, 0x000000f0, + 0x0402001c, 0x0201f800, 0x001053ab, 0x4a038808, + 0x00000080, 0x59c40002, 0x8400050c, 0x48038802, + 0x0401f9d9, 0x4d3c0000, 0x42027800, 0x00000001, + 0x0201f800, 0x00109874, 0x5c027800, 0x4a038808, + 0x00000080, 0x4a035017, 0x00000009, 0x0401f009, + 0x4a035017, 0x00000001, 0x0401f006, 0x4a035017, + 0x00000000, 0x0401f003, 0x4a035017, 0x00000003, + 0x1c01f000, 0x0401f8b7, 0x4a038808, 0x00000080, + 0x59c40805, 0x8c040d0a, 0x0402001b, 0x8c040d0c, + 0x04020016, 0x8c040d0e, 0x04020011, 0x82040500, + 0x000000f0, 0x04020016, 0x59c40002, 0x8400050c, + 0x48038802, 0x0401f9b4, 0x4d3c0000, 0x42027800, + 0x00000001, 0x0201f800, 0x00109874, 0x5c027800, + 0x4a035017, 0x00000009, 0x0401f009, 0x4a035017, + 0x00000001, 0x0401f006, 0x4a035017, 0x00000000, + 0x0401f003, 0x4a035017, 0x00000002, 0x1c01f000, + 0x4a038808, 0x00000008, 0x59c40805, 0x8c040d0c, + 0x04020006, 0x8c040d0e, 0x04000006, 0x4a035017, + 0x00000001, 0x0401f003, 0x4a035017, 0x00000000, + 0x1c01f000, 0x0401f8d3, 0x59c40805, 0x8c040d0c, + 0x0402000d, 0x4c040000, 0x0401f882, 0x5c000800, + 0x8c040d0a, 0x04020006, 0x8c040d0e, 0x04000006, + 0x4a035017, 0x00000001, 0x0401f003, 0x4a035017, + 0x00000002, 0x1c01f000, 0x4a038808, 0x00000008, + 0x42001000, 0x00105058, 0x0201f800, 0x00106084, + 0x59c40805, 0x8c040d0a, 0x0402000d, 0x8c040d08, + 0x0402000b, 0x8c040d0c, 0x04020006, 0x8c040d0e, + 0x0400000d, 0x4a035017, 0x00000001, 0x0401f00a, + 0x4a035017, 0x00000000, 0x0401f007, 0x42000000, + 0x0010b844, 0x0201f800, 0x0010aa47, 0x4a035017, + 0x00000004, 0x1c01f000, 0x0401f8a6, 0x0401f859, + 0x59c40805, 0x8c040d0a, 0x0402000b, 0x8c040d0c, + 0x04020006, 0x8c040d0e, 0x04000009, 0x4a035017, + 0x00000001, 0x0401f006, 0x4a035017, 0x00000000, + 0x0401f003, 0x4a035017, 0x00000002, 0x1c01f000, + 0x4a038808, 0x00000004, 0x0401f846, 0x59c40805, + 0x8c040d0a, 0x04020010, 0x8c040d08, 0x0402000b, + 0x8c040d0c, 0x04020006, 0x8c040d0e, 0x0400000c, + 0x4a035017, 0x00000001, 0x0401f009, 0x4a035017, + 0x00000000, 0x0401f006, 0x4a035017, 0x00000003, + 0x0401f003, 0x4a035017, 0x00000002, 0x1c01f000, + 0x0401f91f, 0x02020800, 0x001005d8, 0x59a80805, + 0x8c040d0c, 0x04000015, 0x84040d0c, 0x48075005, + 0x4a038805, 0x00000010, 0x0201f800, 0x00101937, + 0x59c40005, 0x8c000508, 0x04000008, 0x4a038808, + 0x00000008, 0x4a035033, 0x00000001, 0x4202d800, + 0x00000001, 0x0401f01a, 0x59c40006, 0x84000548, + 0x48038806, 0x0401f016, 0x59a80017, 0x82000580, + 0x00000001, 0x0400000c, 0x59a80017, 0x82000580, + 0x00000005, 0x0402000c, 0x42000000, 0x0010b844, + 0x0201f800, 0x0010aa47, 0x4a035017, 0x00000008, + 0x0401f007, 0x42000000, 0x0010b844, 0x0201f800, + 0x0010aa47, 0x4a035017, 0x00000004, 0x1c01f000, + 0x4803c856, 0x4c040000, 0x4c080000, 0x42000800, + 0x00000064, 0x42001000, 0x00105058, 0x0201f800, + 0x00106079, 0x5c001000, 0x5c000800, 0x1c01f000, + 0x4803c856, 0x4c040000, 0x0201f800, 0x00106c55, + 0x4df00000, 0x0201f800, 0x00106e21, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x0401ffba, 0x5c000800, + 0x1c01f000, 0x4803c856, 0x4c040000, 0x4c080000, + 0x0201f800, 0x00106c55, 0x4df00000, 0x0201f800, + 0x00106e21, 0x5c03e000, 0x02000800, 0x00106c4b, + 0x59c40006, 0x84000500, 0x48038806, 0x0201f800, + 0x00106ede, 0x497b8880, 0x0201f800, 0x0010a9c0, + 0x0201f800, 0x0010a9ce, 0x0201f800, 0x00101815, + 0x4a03504c, 0x00000004, 0x4202d800, 0x00000004, + 0x4a038805, 0x00000001, 0x42001000, 0x00105058, + 0x0201f800, 0x00106084, 0x0201f800, 0x001006d4, + 0x0401f8c1, 0x04000006, 0x42006000, 0xfeffffff, + 0x41786800, 0x0201f800, 0x0010427d, 0x0201f800, + 0x00100452, 0x42000000, 0x00000001, 0x0201f800, + 0x00101590, 0x5c001000, 0x5c000800, 0x1c01f000, + 0x59c40008, 0x8c000508, 0x04020007, 0x4a038808, + 0x00000010, 0x4201d000, 0x00001388, 0x0201f800, + 0x0010608e, 0x1c01f000, 0x4c040000, 0x59a80833, + 0x82040580, 0x00000000, 0x0400000b, 0x82040580, + 0x00000001, 0x0400000b, 0x82040580, 0x00000002, + 0x0400000b, 0x82040580, 0x00000003, 0x0400000b, + 0x0401f057, 0x4a035017, 0x00000000, 0x0401f009, + 0x4a035017, 0x00000004, 0x0401f006, 0x4a035017, + 0x00000001, 0x0401f003, 0x4a035017, 0x00000007, + 0x497b8880, 0x4a038893, 0x00000001, 0x41780000, + 0x0201f800, 0x00101606, 0x0201f800, 0x00106ede, + 0x836c0d80, 0x00000004, 0x04000008, 0x59c40006, + 0x82000500, 0xffffff0f, 0x82000540, 0x04000001, + 0x48038806, 0x0401f007, 0x59c40006, 0x82000500, + 0xffffff0f, 0x82000540, 0x04000000, 0x48038806, + 0x0401f875, 0x04020005, 0x59c40806, 0x82040d00, + 0xfbffff0f, 0x48078806, 0x4200b000, 0x00000005, + 0x59c40005, 0x8c000534, 0x04020033, 0x42006000, + 0xfc18ffff, 0x42006800, 0x01000000, 0x0201f800, + 0x0010427d, 0x0201f800, 0x00101937, 0x59c408a4, + 0x82040d00, 0x0000000f, 0x82040d80, 0x0000000c, + 0x0400000a, 0x42006000, 0xfeffffff, 0x42006800, + 0x02000000, 0x0201f800, 0x0010427d, 0x8058b040, + 0x040207e8, 0x0401f8a1, 0x0401f853, 0x04000006, + 0x42006000, 0xfeffffff, 0x41786800, 0x0201f800, + 0x0010427d, 0x836c0d80, 0x00000004, 0x04000006, + 0x59a8084d, 0x42001000, 0x00105065, 0x0201f800, + 0x0010606e, 0x4a035033, 0x00000004, 0x0401fe31, + 0x0401f841, 0x04020008, 0x59c408a4, 0x82040d00, + 0x0000000f, 0x82040580, 0x0000000c, 0x02020800, + 0x001005d8, 0x5c000800, 0x1c01f000, 0x4803c856, + 0x4c000000, 0x0201f800, 0x0010609e, 0x4a035010, + 0x00ffffff, 0x497b5032, 0x59a8002a, 0x82000500, + 0xffff0000, 0x4803502a, 0x497b8880, 0x497b8893, + 0x41780000, 0x0201f800, 0x00101606, 0x59c40001, + 0x82000500, 0xfffffcff, 0x48038801, 0x42006000, + 0xfc18ffff, 0x41786800, 0x0201f800, 0x0010427d, + 0x4a038808, 0x00000000, 0x5c000000, 0x800001c0, + 0x02020800, 0x0010411d, 0x4a038805, 0x040000f0, + 0x59c40006, 0x82000500, 0xffffffcf, 0x82000540, + 0x440000c1, 0x48038806, 0x1c01f000, 0x4c5c0000, + 0x59a8b832, 0x825cbd80, 0x0000aaaa, 0x5c00b800, + 0x1c01f000, 0x4c5c0000, 0x599cb818, 0x825cbd00, + 0x00000030, 0x825cbd80, 0x00000000, 0x5c00b800, + 0x1c01f000, 0x4c5c0000, 0x599cb818, 0x825cbd00, + 0x00000030, 0x825cbd80, 0x00000010, 0x5c00b800, + 0x1c01f000, 0x4c5c0000, 0x599cb818, 0x825cbd00, + 0x00000030, 0x825cbd80, 0x00000020, 0x5c00b800, + 0x1c01f000, 0x59a80005, 0x4803c857, 0x82000d00, + 0x00000013, 0x04000025, 0x599c1017, 0x4d3c0000, + 0x82000500, 0x00000011, 0x04000007, 0x42027800, + 0x00000400, 0x0201f800, 0x00103b25, 0x0402000a, + 0x0401f012, 0x42027800, 0x00000408, 0x0201f800, + 0x00103b25, 0x0400000d, 0x42003000, 0x00000003, + 0x0401f003, 0x42003000, 0x00000004, 0x42028000, + 0x0000000e, 0x0201f800, 0x0010a449, 0x599c1017, + 0x8c08150a, 0x04020007, 0x42028000, 0x00000004, + 0x0201f800, 0x00101fe5, 0x80000580, 0x0401f80d, + 0x5c027800, 0x0401f00a, 0x0201f800, 0x00103b25, + 0x04000007, 0x42028000, 0x0000000f, 0x42003000, + 0x00000001, 0x0201f800, 0x0010a449, 0x1c01f000, + 0x59a80005, 0x04000004, 0x82000540, 0x00000010, + 0x0401f003, 0x82000500, 0xffffffef, 0x48035005, + 0x4803c857, 0x1c01f000, 0x4803c856, 0x4c580000, + 0x42000000, 0x0010b8cb, 0x0201f800, 0x0010aa47, + 0x42000800, 0x0010c0f1, 0x59c40003, 0x44000800, + 0x59c40004, 0x48000801, 0x59c4000b, 0x48000802, + 0x59c4008e, 0x48000803, 0x59c4008f, 0x48000804, + 0x59c40090, 0x48000805, 0x59c40091, 0x48000806, + 0x59c40092, 0x48000807, 0x59c40093, 0x48000808, + 0x59c40099, 0x48000809, 0x59c4009e, 0x4800080a, + 0x59c400aa, 0x4800080b, 0x59c400af, 0x4800080c, + 0x59c400b2, 0x4800080d, 0x59c400b1, 0x4800080e, + 0x82040c00, 0x0000000f, 0x41c41800, 0x4200b000, + 0x00000030, 0x580c0050, 0x44000800, 0x80040800, + 0x800c1800, 0x8058b040, 0x040207fb, 0x41c41800, + 0x4200b000, 0x00000020, 0x580c0010, 0x44000800, + 0x80040800, 0x800c1800, 0x8058b040, 0x040207fb, + 0x497b8830, 0x4200b000, 0x00000040, 0x59c40031, + 0x44000800, 0x80040800, 0x8058b040, 0x040207fc, + 0x497b88ac, 0x4200b000, 0x00000010, 0x59c400ad, + 0x44000800, 0x80040800, 0x8058b040, 0x040207fc, + 0x59c41001, 0x4c080000, 0x8408150c, 0x480b8801, + 0x4a0370e4, 0x00000300, 0x4a0370e5, 0xb0000000, + 0x42000800, 0x00000800, 0x80040840, 0x02000800, + 0x001005d8, 0x59b800e5, 0x8c000538, 0x040207fb, + 0x4a0370e4, 0x00000200, 0x42006000, 0xffffffff, + 0x42006800, 0x80000000, 0x0201f800, 0x0010427d, + 0x4a038807, 0x00000001, 0x497b8807, 0x4a038808, + 0x00000010, 0x42006000, 0xfcf8ffff, 0x42006800, + 0x01000000, 0x0201f800, 0x0010427d, 0x5c001000, + 0x480b8801, 0x42000800, 0x0010c0f1, 0x50040000, + 0x48038803, 0x58040001, 0x48038804, 0x58040002, + 0x4803880b, 0x58040003, 0x4803888e, 0x58040004, + 0x4803888f, 0x58040005, 0x48038890, 0x58040006, + 0x48038891, 0x58040007, 0x48038892, 0x58040008, + 0x48038893, 0x58040009, 0x48038899, 0x5804000a, + 0x4803889e, 0x5804000b, 0x480388aa, 0x5804000c, + 0x480388af, 0x5804000d, 0x480388b2, 0x5804000e, + 0x480388b1, 0x82040c00, 0x0000000f, 0x41c41800, + 0x4200b000, 0x00000030, 0x50040000, 0x48001850, + 0x80040800, 0x800c1800, 0x8058b040, 0x040207fb, + 0x41c41800, 0x4200b000, 0x00000020, 0x50040000, + 0x48001810, 0x80040800, 0x800c1800, 0x8058b040, + 0x040207fb, 0x497b8830, 0x4200b000, 0x00000040, + 0x50040000, 0x48038831, 0x80040800, 0x8058b040, + 0x040207fc, 0x497b88ac, 0x4200b000, 0x00000010, + 0x50040000, 0x480388ad, 0x80040800, 0x8058b040, + 0x040207fc, 0x497b8880, 0x41780000, 0x0201f800, + 0x00101606, 0x59c408a4, 0x82040d00, 0x0000000f, + 0x82040580, 0x0000000c, 0x02020800, 0x001005d8, + 0x4a038805, 0x04000000, 0x5c00b000, 0x1c01f000, + 0x4803c856, 0x4c580000, 0x4ce80000, 0x42000000, + 0x0010b845, 0x0201f800, 0x0010aa47, 0x59c41008, + 0x4c080000, 0x82080500, 0xffffff7f, 0x48038808, + 0x59c40004, 0x82000500, 0x00003e02, 0x04000005, + 0x4201d000, 0x00000014, 0x0201f800, 0x0010608e, + 0x59c40006, 0x82000500, 0xffffff0f, 0x48038806, + 0x4a038805, 0x00000010, 0x4a038808, 0x00000004, + 0x4200b000, 0x00000065, 0x59c40005, 0x8c000508, + 0x04020012, 0x4201d000, 0x000003e8, 0x0201f800, + 0x0010608e, 0x8058b040, 0x040207f8, 0x0201f800, + 0x00106ede, 0x4a038808, 0x00000008, 0x4a035033, + 0x00000001, 0x4202d800, 0x00000001, 0x82000540, + 0x00000001, 0x0401f030, 0x0201f800, 0x00100ae0, + 0x42000000, 0x0010b8a8, 0x0201f800, 0x0010aa47, + 0x0201f800, 0x00100ef4, 0x497b8880, 0x59a8002a, + 0x82000500, 0x0000ffff, 0x4c000000, 0x0201f800, + 0x00101606, 0x5c000000, 0x48038880, 0x4a038808, + 0x00000000, 0x4200b000, 0x00000065, 0x4a038805, + 0x000000f0, 0x0201f800, 0x00101937, 0x42000800, + 0x000000f0, 0x59c40005, 0x80040d00, 0x04000008, + 0x4201d000, 0x000003e8, 0x0201f800, 0x0010608e, + 0x8058b040, 0x040207f2, 0x0401f7d1, 0x59c40006, + 0x82000540, 0x000000f0, 0x48038806, 0x59a8001e, + 0x80000540, 0x04020002, 0x80000000, 0x48038893, + 0x80000580, 0x5c001000, 0x4df00000, 0x0201f800, + 0x0010195d, 0x5c03e000, 0x480b8808, 0x5c01d000, + 0x5c00b000, 0x1c01f000, 0x4803c856, 0x4c580000, + 0x4ce80000, 0x59c41008, 0x82080500, 0xffffff7f, + 0x48038808, 0x4c080000, 0x59c40004, 0x82000500, + 0x00003e02, 0x04000005, 0x4201d000, 0x00000014, + 0x0201f800, 0x0010608e, 0x0201f800, 0x00100ae0, + 0x42000000, 0x0010b8a9, 0x0201f800, 0x0010aa47, + 0x0201f800, 0x00100ef4, 0x4a038808, 0x00000002, + 0x80000580, 0x48038880, 0x48038893, 0x0201f800, + 0x00101606, 0x4200b000, 0x00000384, 0x4a038805, + 0x000000f0, 0x0201f800, 0x00101937, 0x42000800, + 0x000000f0, 0x59c40005, 0x80040d00, 0x04000015, + 0x82000500, 0x000000d0, 0x04020012, 0x4201d000, + 0x00000067, 0x0201f800, 0x0010608e, 0x8058b040, + 0x040207ef, 0x0201f800, 0x00106ede, 0x4a038808, + 0x00000008, 0x4a035033, 0x00000001, 0x4202d800, + 0x00000001, 0x82000540, 0x00000001, 0x0401f010, + 0x497b8880, 0x59a8001e, 0x80000540, 0x04020002, + 0x80000000, 0x48038893, 0x59a8002a, 0x82000500, + 0x0000ffff, 0x4c000000, 0x0201f800, 0x00101606, + 0x5c000000, 0x48038880, 0x80000580, 0x5c001000, + 0x4df00000, 0x0201f800, 0x0010195d, 0x5c03e000, + 0x480b8808, 0x5c01d000, 0x5c00b000, 0x1c01f000, + 0x4803c856, 0x59c40004, 0x82000500, 0x00003e02, + 0x0400000a, 0x0201f800, 0x00106ede, 0x4a038808, + 0x00000008, 0x4a035033, 0x00000001, 0x4202d800, + 0x00000001, 0x0401f052, 0x0201f800, 0x00100ae0, + 0x42000000, 0x0010b8aa, 0x0201f800, 0x0010aa47, + 0x0201f800, 0x00100ef4, 0x59c40006, 0x84000508, + 0x48038806, 0x4a038805, 0x00000010, 0x59a80805, + 0x84040d4c, 0x48075005, 0x42000800, 0x00000064, + 0x42001000, 0x00105058, 0x0201f800, 0x0010606e, + 0x4a038808, 0x00000000, 0x497b8880, 0x4a038805, + 0x000000f0, 0x0201f800, 0x00101937, 0x42000800, + 0x000000f0, 0x59c40005, 0x80040d00, 0x0400000e, + 0x82000500, 0x000000e0, 0x0402000b, 0x4201d000, + 0x000003e8, 0x0201f800, 0x0010608e, 0x0201f800, + 0x00105f48, 0x59940004, 0x80000540, 0x040207ec, + 0x0401f023, 0x4c080000, 0x42001000, 0x00105065, + 0x0201f800, 0x00105f90, 0x42001000, 0x00105058, + 0x0201f800, 0x00106084, 0x5c001000, 0x497b8880, + 0x59a8001e, 0x80000540, 0x04020002, 0x80000000, + 0x48038893, 0x59a8002a, 0x82000500, 0x0000ffff, + 0x4c000000, 0x0201f800, 0x00101606, 0x5c000000, + 0x48038880, 0x59a80805, 0x84040d0c, 0x48075005, + 0x59c40006, 0x84000548, 0x48038806, 0x0201f800, + 0x0010195d, 0x4a038808, 0x00000080, 0x1c01f000, + 0x4803c856, 0x4d400000, 0x4d3c0000, 0x0201f800, + 0x00106ede, 0x0201f800, 0x0010ab33, 0x04020025, + 0x599c1017, 0x59a80805, 0x8c040d00, 0x0402000c, + 0x8c08151a, 0x0400001f, 0x84040d42, 0x48075005, + 0x42028000, 0x00000004, 0x42027800, 0x0000000c, + 0x8c081508, 0x04020008, 0x0401f012, 0x42028000, + 0x00000004, 0x42027800, 0x00000004, 0x8c081508, + 0x0400000c, 0x4d400000, 0x42028000, 0x0000000e, + 0x42028800, 0x0000ffff, 0x0201f800, 0x0010a446, + 0x5c028000, 0x599c0817, 0x8c040d0a, 0x04020005, + 0x4943c857, 0x493fc857, 0x0201f800, 0x00101fe5, + 0x497b8880, 0x4202d800, 0x00000001, 0x0401fcfb, + 0x5c027800, 0x5c028000, 0x1c01f000, 0x0201f800, + 0x00100ae0, 0x42000000, 0x0010b8ab, 0x0201f800, + 0x0010aa47, 0x0201f800, 0x00100ef4, 0x42000000, + 0x00000001, 0x0201f800, 0x00101606, 0x4a038880, + 0x00000001, 0x0201f000, 0x0010195d, 0x4202e000, + 0x00000000, 0x4a033015, 0x00000001, 0x497b301d, + 0x497b3006, 0x4a03b004, 0x60000001, 0x59d80005, + 0x4a03b004, 0x90000001, 0x4a03a804, 0x60000001, + 0x59d40005, 0x4a03a804, 0x90000001, 0x0201f000, + 0x00105983, 0x4a03c825, 0x00000004, 0x4a03c827, + 0x00000004, 0x599c0409, 0x80000d40, 0x04000020, + 0x599c0407, 0x80000540, 0x04000007, 0x800000cc, + 0x599c100b, 0x80080400, 0x4803b000, 0x497bb002, + 0x59d80001, 0x599c000b, 0x4803b000, 0x599c000c, + 0x4803b001, 0x599c0407, 0x80000540, 0x04020002, + 0x497bb002, 0x599c0c09, 0x82040540, 0x00400000, + 0x4803b003, 0x4a03b009, 0x00000004, 0x4a03b004, + 0x10000001, 0x59e00803, 0x82040d00, 0xfffffeff, + 0x82040d40, 0x00008000, 0x4807c003, 0x599c040a, + 0x80000540, 0x04000020, 0x599c0408, 0x80000540, + 0x04000007, 0x800000cc, 0x599c100f, 0x80080400, + 0x4803a800, 0x497ba802, 0x59d40001, 0x599c000f, + 0x4803a800, 0x599c0010, 0x4803a801, 0x599c0408, + 0x80000540, 0x04020002, 0x497ba802, 0x599c0c0a, + 0x82040540, 0x00400000, 0x4803a803, 0x4a03a809, + 0x00000004, 0x4a03a804, 0x10000001, 0x59e00803, + 0x82040d00, 0xfffffbff, 0x82040d40, 0x00008000, + 0x4807c003, 0x800409c0, 0x04000007, 0x4202e000, + 0x00000001, 0x0200b800, 0x00020551, 0x0200f000, + 0x00020566, 0x1c01f000, 0x0201f800, 0x001005d8, + 0x1c01f000, 0x4df00000, 0x4203e000, 0x50000000, + 0x59981005, 0x800811c0, 0x0400001e, 0x58080005, + 0x82000d00, 0x43018780, 0x02020000, 0x00105846, + 0x8c000508, 0x04000015, 0x580a5808, 0x592c0204, + 0x497a5800, 0x497a5801, 0x82000500, 0x000000ff, + 0x82000c80, 0x0000004b, 0x0402100b, 0x0c01f80f, + 0x5c03e000, 0x83700580, 0x00000003, 0x040007e6, + 0x0200f800, 0x00020566, 0x0200b000, 0x00020551, + 0x1c01f000, 0x0401f850, 0x5c03e000, 0x0401f7f9, + 0x0401f8de, 0x0401f7fd, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x001054a1, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105519, 0x00105491, 0x00105491, 0x001054a1, + 0x001054a1, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x492fc857, 0x42000000, 0x0010b85e, + 0x0201f800, 0x0010aa47, 0x42000000, 0x00000400, + 0x0401f019, 0x492fc857, 0x42000000, 0x0010b85d, + 0x0201f800, 0x0010aa47, 0x42000000, 0x00001000, + 0x0401f011, 0x492fc857, 0x42000000, 0x0010b85c, + 0x0201f800, 0x0010aa47, 0x42000000, 0x00002000, + 0x0401f009, 0x492fc857, 0x42000000, 0x0010b85f, + 0x0201f800, 0x0010aa47, 0x42000000, 0x00000800, + 0x0401f001, 0x4803c857, 0x4202e000, 0x00000001, + 0x592c0c04, 0x82040d00, 0xffff80ff, 0x80040540, + 0x48025c04, 0x0201f000, 0x000202da, 0x592c0204, + 0x492fc857, 0x80000110, 0x040007db, 0x80000040, + 0x04000025, 0x48033002, 0x492f3003, 0x492f3004, + 0x4a033008, 0x001054e5, 0x4202e000, 0x00000003, + 0x1c01f000, 0x592c0204, 0x492fc857, 0x80000110, + 0x040007cd, 0x80000040, 0x04000033, 0x48033002, + 0x492f3003, 0x492f3004, 0x4a033008, 0x00105501, + 0x4202e000, 0x00000003, 0x1c01f000, 0x0201f800, + 0x0010ab33, 0x02020000, 0x000204d9, 0x42028000, + 0x00000028, 0x41780800, 0x417a6000, 0x0201f800, + 0x00104e70, 0x0201f800, 0x001091c6, 0x0201f000, + 0x000202da, 0x592c0a0a, 0x8c040d02, 0x04020016, + 0x59a80021, 0x492fc857, 0x80000540, 0x0402000f, + 0x592c0207, 0x80000540, 0x04000005, 0x0201f800, + 0x00104326, 0x04020004, 0x1c01f000, 0x42000000, + 0x00000000, 0x592c0a06, 0x48065c06, 0x48025a06, + 0x0201f000, 0x000202da, 0x42000000, 0x00000028, + 0x0401f7f9, 0x42000800, 0x00000009, 0x0201f000, + 0x0010665b, 0x592c0208, 0x492fc857, 0x82000c80, + 0x0000199a, 0x040217a4, 0x592c0408, 0x80000540, + 0x040207a1, 0x59a80821, 0x800409c0, 0x04020009, + 0x592c0207, 0x80000540, 0x0400079b, 0x497a5a06, + 0x0201f800, 0x00104385, 0x04020004, 0x1c01f000, + 0x42000000, 0x00000028, 0x48025a06, 0x0201f000, + 0x000202da, 0x59980804, 0x59980002, 0x48065800, + 0x492c0801, 0x492f3004, 0x80000040, 0x48033002, + 0x04000002, 0x1c01f000, 0x599a5803, 0x59980008, + 0x4202e000, 0x00000001, 0x0801f000, 0x592e8a06, + 0x592c0406, 0x4803c856, 0x82000500, 0x000000ff, + 0x4200b800, 0x00000001, 0x82000d80, 0x00000001, + 0x04000015, 0x417a8800, 0x4200b800, 0x000007f0, + 0x82000d80, 0x00000002, 0x0400000f, 0x80000540, + 0x02020000, 0x000202da, 0x592e8a06, 0x0201f800, + 0x00020245, 0x02020000, 0x000202da, 0x592e9008, + 0x592e9809, 0x0201f800, 0x00104713, 0x0201f000, + 0x000202da, 0x59a80805, 0x84040d00, 0x48075005, + 0x0201f800, 0x00020245, 0x02000800, 0x0010482c, + 0x81468800, 0x805cb840, 0x040207fa, 0x0201f000, + 0x000202da, 0x592c0a08, 0x4807c857, 0x82040580, + 0x0000000e, 0x04000045, 0x82040580, 0x00000046, + 0x04000046, 0x82040580, 0x00000045, 0x04000020, + 0x82040580, 0x00000029, 0x04000010, 0x82040580, + 0x0000002a, 0x04000009, 0x82040580, 0x0000000f, + 0x040001fc, 0x82040580, 0x0000002e, 0x040001f9, + 0x4807c856, 0x0401f1f2, 0x59a80805, 0x84040d04, + 0x48075005, 0x0401f1f3, 0x592e8a06, 0x0201f800, + 0x00020245, 0x040201ef, 0x59340200, 0x84000518, + 0x48026a00, 0x592e6009, 0x4933c857, 0x83300580, + 0xffffffff, 0x0402002a, 0x0401f1e6, 0x592c1407, + 0x480bc857, 0x0201f800, 0x00109410, 0x411e6000, + 0x04020003, 0x4803c856, 0x0401f1d9, 0x592e3809, + 0x591c1414, 0x84081516, 0x84081554, 0x480a3c14, + 0x4a026403, 0x0000003a, 0x592c040b, 0x80000540, + 0x04000007, 0x4a026403, 0x0000003b, 0x592c020c, + 0x4802641a, 0x592c040c, 0x4802621a, 0x4a026203, + 0x00000001, 0x42000800, 0x80000040, 0x0201f800, + 0x00020721, 0x0401f1c7, 0x59a80068, 0x84000510, + 0x48035068, 0x0401f1c3, 0x592c1207, 0x8c081500, + 0x040201c0, 0x592e8a06, 0x592e6009, 0x0201f800, + 0x0010941a, 0x04020003, 0x4803c856, 0x0401f1b4, + 0x59300c06, 0x82040580, 0x00000004, 0x04000003, + 0x4803c856, 0x0401f1ae, 0x59300a03, 0x82040580, + 0x00000007, 0x04000003, 0x4803c856, 0x0401f1a8, + 0x59300c03, 0x82040580, 0x00000001, 0x04000021, + 0x82040580, 0x00000003, 0x04000016, 0x82040580, + 0x00000006, 0x04000020, 0x82040580, 0x00000008, + 0x04000015, 0x82040580, 0x0000000a, 0x0400000a, + 0x82040580, 0x0000000c, 0x04000004, 0x82040580, + 0x0000002e, 0x04020018, 0x42000800, 0x00000009, + 0x0401f013, 0x42000800, 0x00000005, 0x0401f010, + 0x417a7800, 0x0201f800, 0x0010203c, 0x4a026406, + 0x00000001, 0x42000800, 0x00000003, 0x0401f008, + 0x417a7800, 0x0201f800, 0x0010203c, 0x4a026406, + 0x00000001, 0x42000800, 0x0000000b, 0x0201f800, + 0x00104571, 0x4a026203, 0x00000001, 0x0201f800, + 0x0010672b, 0x0401f17b, 0x40000800, 0x58040000, + 0x80000540, 0x040207fd, 0x492c0800, 0x1c01f000, + 0x492fc857, 0x59300c06, 0x82040580, 0x00000006, + 0x04020094, 0x0201f800, 0x001049e7, 0x04020005, + 0x59340200, 0x8c00051a, 0x02000000, 0x00020533, + 0x59340200, 0x8c00050e, 0x0400008a, 0x59300203, + 0x42027800, 0x00000001, 0x82000580, 0x00000007, + 0x02020000, 0x00020533, 0x4a026203, 0x00000002, + 0x0201f000, 0x00020533, 0x42028000, 0x00000002, + 0x4a026206, 0x00000014, 0x4d2c0000, 0x0201f800, + 0x0010a1d1, 0x5c025800, 0x59300c06, 0x4807c857, + 0x82040580, 0x00000007, 0x04020063, 0x492fc857, + 0x4a025a06, 0x00000001, 0x0201f000, 0x000202da, + 0x592c240a, 0x492fc857, 0x4813c857, 0x8c10251c, + 0x04020016, 0x8c10251a, 0x04000003, 0x8c10250a, + 0x04000069, 0x59340a00, 0x8c040d0e, 0x04000003, + 0x8c10251e, 0x04000064, 0x0201f800, 0x0002075a, + 0x0400006b, 0x592c240a, 0x49366009, 0x49325809, + 0x4a026406, 0x00000006, 0x4a026203, 0x00000007, + 0x0201f000, 0x0002052f, 0x592c0a0c, 0x5934000f, + 0x41784000, 0x80001540, 0x0400006d, 0x58080204, + 0x82000500, 0x000000ff, 0x82000580, 0x00000012, + 0x04020004, 0x5808020c, 0x80040580, 0x04000004, + 0x58080000, 0x40084000, 0x0401f7f3, 0x58080000, + 0x49781000, 0x802041c0, 0x04000006, 0x48004000, + 0x80000540, 0x04020007, 0x48226810, 0x0401f005, + 0x4802680f, 0x80000540, 0x04020002, 0x497a6810, + 0x4d2c0000, 0x400a5800, 0x4a025a06, 0x00000002, + 0x0201f800, 0x000202da, 0x5c025800, 0x0401f7bc, + 0x592c040a, 0x8c00051c, 0x04000016, 0x592c0206, + 0x82000580, 0x0000ffff, 0x04020012, 0x592e6009, + 0x83300580, 0xffffffff, 0x040007b1, 0x83300480, + 0x0010d1c0, 0x04001010, 0x59a8000b, 0x81300480, + 0x0402100d, 0x59300008, 0x800001c0, 0x04020005, + 0x59300203, 0x82000580, 0x00000007, 0x04000797, + 0x492fc857, 0x4a025a06, 0x00000029, 0x0201f000, + 0x000202da, 0x492fc857, 0x4a025a06, 0x00000008, + 0x0201f000, 0x000202da, 0x492fc857, 0x4a025a06, + 0x00000045, 0x0201f000, 0x000202da, 0x492fc857, + 0x4a025a06, 0x0000002a, 0x0201f000, 0x000202da, + 0x492fc857, 0x4a025a06, 0x00000028, 0x0201f000, + 0x000202da, 0x492fc857, 0x4a025a06, 0x00000006, + 0x0201f000, 0x000202da, 0x492fc857, 0x4a025a06, + 0x0000000e, 0x0201f000, 0x000202da, 0x59340010, + 0x492e6810, 0x492fc857, 0x80000d40, 0x04000003, + 0x492c0800, 0x1c01f000, 0x5934040b, 0x492e680f, + 0x492fc857, 0x4803c857, 0x80000540, 0x04020003, + 0x4a026a03, 0x00000001, 0x1c01f000, 0x59a8000e, + 0x81640480, 0x0402176e, 0x42026000, 0x0010d1c0, + 0x59300009, 0x81340580, 0x04020004, 0x59300202, + 0x80040580, 0x04000759, 0x83326400, 0x00000024, + 0x41580000, 0x81300480, 0x040017f6, 0x0401f760, + 0x492fc857, 0x592c0407, 0x82000c80, 0x0000199a, + 0x040215f1, 0x592c0204, 0x80000112, 0x040205de, + 0x592e8a06, 0x0201f800, 0x00020245, 0x04020059, + 0x0201f800, 0x001049e7, 0x04020059, 0x592e780a, + 0x493fc857, 0x8d3e7d3e, 0x04020007, 0x59a80021, + 0x80000540, 0x0402004f, 0x0201f800, 0x00104838, + 0x040005dd, 0x833c1d00, 0x0000001f, 0x040005da, + 0x592c0207, 0x82000c80, 0x00001000, 0x040215d6, + 0x800000c2, 0x800008c4, 0x8005d400, 0x592e9008, + 0x592e9809, 0x5934080d, 0x800409c0, 0x0402002e, + 0x833c1d00, 0x0000001f, 0x81780040, 0x80000000, + 0x800c1902, 0x040217fe, 0x040205c7, 0x0c01f001, + 0x001056e9, 0x001056ec, 0x001056f9, 0x001056fc, + 0x001056ff, 0x0201f800, 0x0010903e, 0x0401f01a, + 0x0201f800, 0x0010480b, 0x04000027, 0x80e9d1c0, + 0x02020800, 0x00105fae, 0x42028000, 0x00000005, + 0x417a9000, 0x417a9800, 0x0201f800, 0x0010904e, + 0x0401f00d, 0x42027000, 0x0000004d, 0x0401f006, + 0x42027000, 0x0000004e, 0x0401f003, 0x42027000, + 0x00000052, 0x0201f800, 0x001046c9, 0x02020800, + 0x0010907e, 0x04000010, 0x8d3e7d3e, 0x04020017, + 0x1c01f000, 0x58040002, 0x80000540, 0x04020007, + 0x4d3c0000, 0x40067800, 0x0201f800, 0x001047eb, + 0x5c027800, 0x040207cb, 0x4a025a06, 0x00000030, + 0x0401f00d, 0x4a025a06, 0x0000002c, 0x0401f00a, + 0x4a025a06, 0x00000028, 0x0401f007, 0x4a025a06, + 0x00000029, 0x0401f004, 0x497a5c09, 0x4a025a06, + 0x00000000, 0x4a025a04, 0x00000103, 0x0201f000, + 0x000202da, 0x492fc857, 0x592c0204, 0x80000110, + 0x80000040, 0x04000002, 0x0401f56f, 0x592c0207, + 0x82000500, 0x000003ff, 0x48025a07, 0x8c000506, + 0x04000004, 0x82000500, 0x00000070, 0x04020004, + 0x59a80821, 0x800409c0, 0x04020018, 0x4a025a06, + 0x0000dead, 0x592c0408, 0x82000500, 0x0000f0ff, + 0x48025c08, 0x0201f800, 0x001043b4, 0x04020002, + 0x1c01f000, 0x49425a06, 0x8058b1c0, 0x04000009, + 0x0201f800, 0x0010955f, 0x0401f80f, 0x44042800, + 0x82580580, 0x00000002, 0x04020002, 0x48082801, + 0x0201f000, 0x000202da, 0x42028000, 0x00000031, + 0x42000800, 0x00000001, 0x4200b000, 0x00000001, + 0x0401f7ed, 0x592c0408, 0x80000118, 0x832c2c00, + 0x00000009, 0x80142c00, 0x1c01f000, 0x492fc857, + 0x4a025a08, 0x00000006, 0x0201f000, 0x000202da, + 0x492fc857, 0x4a025a08, 0x00000001, 0x0201f000, + 0x000202da, 0x492fc857, 0x592c040a, 0x82000500, + 0x00000003, 0x04000020, 0x0201f800, 0x0002075a, + 0x04000021, 0x592c0204, 0x492e6008, 0x82000500, + 0x000000ff, 0x82000580, 0x00000045, 0x0400000e, + 0x592c000b, 0x0201f800, 0x00105c9a, 0x02000800, + 0x00020245, 0x04020018, 0x42027000, 0x00000041, + 0x49366009, 0x4a026406, 0x00000001, 0x0201f000, + 0x000207a1, 0x59300015, 0x8400055e, 0x48026015, + 0x42026800, 0x0010b524, 0x42027000, 0x00000040, + 0x0401f7f4, 0x4a025a06, 0x00000101, 0x0201f000, + 0x000202da, 0x4a025a06, 0x0000002c, 0x0201f000, + 0x000202da, 0x4a025a06, 0x00000028, 0x0201f800, + 0x000202da, 0x0201f000, 0x0002077d, 0x492fc857, + 0x0201f800, 0x001062e1, 0x0400000b, 0x592c0204, + 0x80000110, 0x80000040, 0x040204fb, 0x592c0c06, + 0x800409c0, 0x04000009, 0x42000000, 0x00000102, + 0x0401f003, 0x42000000, 0x00000104, 0x48025a06, + 0x0201f000, 0x000202da, 0x592c0c07, 0x800409c0, + 0x04000024, 0x82040480, 0x00000005, 0x04021021, + 0x4c040000, 0x80040800, 0x0201f800, 0x00106306, + 0x5c001000, 0x04020018, 0x832c0400, 0x00000008, + 0x4000a000, 0x0201f800, 0x0010632f, 0x04020012, + 0x592c1207, 0x82cc0580, 0x0010b50e, 0x04020009, + 0x58c80c0b, 0x84040d00, 0x84040d02, 0x8c081500, + 0x04000002, 0x84040d5e, 0x4805940b, 0x0401f001, + 0x42000000, 0x00000000, 0x48025a06, 0x0201f000, + 0x000202da, 0x42000000, 0x00000103, 0x0401f7fb, + 0x42000000, 0x00000102, 0x0401f7f8, 0x492fc857, + 0x592e7c06, 0x833c0500, 0xfffffffe, 0x04020043, + 0x592c4007, 0x42026000, 0x0010d1c0, 0x41581800, + 0x400c0000, 0x81300480, 0x04021023, 0x59300203, + 0x82000580, 0x00000000, 0x04000007, 0x59300008, + 0x80000d40, 0x04000004, 0x58040005, 0x80200580, + 0x04000004, 0x83326400, 0x00000024, 0x0401f7f1, + 0x58040204, 0x82000500, 0x000000ff, 0x82000d80, + 0x00000053, 0x04000007, 0x82000d80, 0x00000048, + 0x04000004, 0x82000580, 0x00000018, 0x04020023, + 0x4d2c0000, 0x0201f800, 0x00108be3, 0x5c025800, + 0x0400001e, 0x4a025a06, 0x00000000, 0x0201f000, + 0x000202da, 0x592e8a06, 0x83440480, 0x000007f0, + 0x04021016, 0x83440400, 0x0010ac00, 0x50000000, + 0x80026d40, 0x04000011, 0x4d2c0000, 0x0201f800, + 0x001047cb, 0x0400000c, 0x42028000, 0x00000005, + 0x592c0a08, 0x0201f800, 0x00104e70, 0x0201f800, + 0x001091cc, 0x0201f800, 0x000202da, 0x5c025800, + 0x0401f7e5, 0x5c025800, 0x4a025a06, 0x00000031, + 0x0201f000, 0x000202da, 0x492fc857, 0x4d2c0000, + 0x0201f800, 0x001007e4, 0x04000016, 0x492fc857, + 0x412f4000, 0x0201f800, 0x001007e4, 0x0400000e, + 0x492fc857, 0x412dd800, 0x0201f800, 0x00103b28, + 0x0201f800, 0x00103b32, 0x49a1d80b, 0x5c025800, + 0x492dd80a, 0x0201f800, 0x00102214, 0x0201f000, + 0x00102233, 0x41a25800, 0x0201f800, 0x001007f4, + 0x5c025800, 0x4a025a06, 0x00004005, 0x4a025c06, + 0x00000002, 0x0201f000, 0x000202da, 0x4807c857, + 0x485fc857, 0x4200b800, 0x00000001, 0x5c000800, + 0x4c5c0000, 0x0401f005, 0x4807c857, 0x485fc857, + 0x5c000800, 0x4d780000, 0x4803c857, 0x492fc857, + 0x8c00050e, 0x02020800, 0x001005d0, 0x4203e000, + 0x50000000, 0x4200b800, 0x00008003, 0x0201f000, + 0x001005dd, 0x592c0204, 0x80000110, 0x80000040, + 0x04020441, 0x0201f800, 0x00104a34, 0x04020002, + 0x1c01f000, 0x49425a06, 0x4806580d, 0x480a580e, + 0x4943c857, 0x4807c857, 0x480bc857, 0x0201f000, + 0x000202da, 0x592c0204, 0x80000110, 0x80000040, + 0x04020431, 0x0201f800, 0x00104b8b, 0x04020002, + 0x1c01f000, 0x49425a06, 0x48065811, 0x480a5812, + 0x0201f000, 0x000202da, 0x592c0204, 0x80000110, + 0x04000425, 0x80000040, 0x0402000c, 0x4202e000, + 0x00000001, 0x592c020a, 0x8c000504, 0x02000000, + 0x000204d0, 0x592c0207, 0x82000c80, 0x00001001, + 0x04021429, 0x0401f009, 0x4202e000, 0x00000003, + 0x48033002, 0x492f3003, 0x492f3004, 0x4a033008, + 0x000204d0, 0x1c01f000, 0x4202e000, 0x00000002, + 0x42000000, 0x0010beda, 0x50007000, 0x492c700b, + 0x4978700e, 0x4978700c, 0x592c0011, 0x592c0812, + 0x48007007, 0x48047008, 0x592c1013, 0x82080500, + 0xffff0000, 0x04000003, 0x0201f800, 0x001005d8, + 0x4978700d, 0x82080480, 0x00000180, 0x4803c857, + 0x04001007, 0x4800700f, 0x4a007005, 0x00000180, + 0x4a007004, 0x00000060, 0x0401f005, 0x4978700f, + 0x48087005, 0x80081104, 0x48087004, 0x5838000a, + 0x48007003, 0x40381000, 0x0201f000, 0x00100858, + 0x0201f800, 0x001007d3, 0x04000003, 0x59980007, + 0x0801f000, 0x1c01f000, 0x40307000, 0x5838000b, + 0x80025d40, 0x0400001b, 0x58380002, 0x82000580, + 0x00000100, 0x0400001d, 0x4c380000, 0x592c0204, + 0x82000500, 0x000000ff, 0x82000580, 0x00000012, + 0x0400000b, 0x592c0208, 0x8400054e, 0x48025a08, + 0x4a025a06, 0x00000002, 0x4a025a04, 0x00000103, + 0x0201f800, 0x000202c1, 0x0401f005, 0x4a025a06, + 0x00000010, 0x0201f800, 0x000202da, 0x5c007000, + 0x4202e000, 0x00000001, 0x4a007002, 0x00000100, + 0x49787010, 0x1c01f000, 0x58380004, 0x82000480, + 0x00000003, 0x04000087, 0x58380010, 0x8c000500, + 0x04020019, 0x4200b000, 0x00000003, 0x832cac00, + 0x00000011, 0x5838000a, 0x5838100d, 0x8008a400, + 0x4c380000, 0x0201f800, 0x0010ab17, 0x5c007000, + 0x5838000d, 0x82000400, 0x00000003, 0x4800700d, + 0x4a007010, 0x00000001, 0x58380004, 0x82000480, + 0x00000003, 0x48007004, 0x82000580, 0x00000003, + 0x0400006c, 0x5838000e, 0x80001d40, 0x04020020, + 0x4c380000, 0x0201f800, 0x001007d3, 0x5c007000, + 0x04000010, 0x4a025a04, 0x0000010a, 0x42001800, + 0x00000005, 0x480c700e, 0x5838000c, 0x80000540, + 0x04020002, 0x5838000b, 0x40000800, 0x492c0801, + 0x492c700c, 0x42000800, 0x0000000f, 0x0401f011, + 0x4202e000, 0x00000008, 0x4a033007, 0x00105915, + 0x1c01f000, 0x4202e000, 0x00000002, 0x42000000, + 0x0010beda, 0x50007000, 0x0401f7e7, 0x583a580c, + 0x400c0000, 0x42000800, 0x00000014, 0x80040c80, + 0x58381004, 0x5838000f, 0x41783000, 0x80000540, + 0x04020005, 0x84183540, 0x82081480, 0x00000003, + 0x0400003c, 0x40080000, 0x80040480, 0x04001002, + 0x40080800, 0x4004b000, 0x412c0000, 0x800c0400, + 0x4000a800, 0x5838000a, 0x5838100d, 0x8008a400, + 0x4c080000, 0x4c040000, 0x4c0c0000, 0x4c380000, + 0x0201f800, 0x0010ab17, 0x5c007000, 0x5c001800, + 0x5c000800, 0x40040000, 0x58381004, 0x80080480, + 0x48007004, 0x82000580, 0x00000003, 0x04000002, + 0x84183500, 0x5c000000, 0x80041400, 0x82080480, + 0x00000060, 0x04020003, 0x84183542, 0x41781000, + 0x400c0000, 0x80041c00, 0x820c0480, 0x00000014, + 0x04020003, 0x84183544, 0x40001800, 0x40080800, + 0x4804700d, 0x480c700e, 0x40180000, 0x0c01f001, + 0x00105960, 0x00105964, 0x00105962, 0x00105960, + 0x001058fc, 0x00105964, 0x00105962, 0x00105960, + 0x0201f800, 0x001005d8, 0x5838100f, 0x0401f739, + 0x5838080d, 0x82040400, 0x00000002, 0x5838100a, + 0x80080400, 0x50001000, 0x800811c0, 0x0402000f, + 0x4202e000, 0x00000001, 0x583a580b, 0x4978700b, + 0x49787010, 0x592c0204, 0x82000500, 0x000000ff, + 0x82000580, 0x00000012, 0x02000000, 0x00020507, + 0x0201f000, 0x000204d0, 0x5838000a, 0x80040c00, + 0x82381c00, 0x00000007, 0x54041800, 0x80040800, + 0x800c1800, 0x54041800, 0x0401f71a, 0x0201f800, + 0x001007d3, 0x02000800, 0x001005d8, 0x4a02580a, + 0x0010be79, 0x42000800, 0x0010beda, 0x452c0800, + 0x497a580b, 0x497a580c, 0x497a580d, 0x497a580e, + 0x497a580f, 0x4a025809, 0x001058b6, 0x497a5810, + 0x4a025802, 0x00000100, 0x4a025801, 0x00000001, + 0x1c01f000, 0x59c80007, 0x8c000502, 0x04000070, + 0x835c2c80, 0x00000005, 0x02001000, 0x00105f23, + 0x59c82817, 0x497b9005, 0x82140500, 0x00e00000, + 0x0402004f, 0x82140500, 0x000003ff, 0x82001c00, + 0x00000006, 0x41cc2000, 0x42003000, 0x00006080, + 0x820c0480, 0x00000040, 0x04001006, 0x42001000, + 0x00000040, 0x820c1c80, 0x00000040, 0x0401f003, + 0x400c1000, 0x41781800, 0x54182000, 0x80102000, + 0x80183000, 0x80081040, 0x040207fc, 0x800c19c0, + 0x04000005, 0x59c80005, 0x80000000, 0x48039005, + 0x0401f7ea, 0x82140500, 0x01f60000, 0x04020029, + 0x82140500, 0x0000f000, 0x0400000b, 0x82000c80, + 0x00002000, 0x0402100f, 0x82140500, 0x0e000000, + 0x80000132, 0x0c01f840, 0x4a039005, 0x00000140, + 0x1c01f000, 0x59cc0400, 0x82000500, 0x0000ff00, + 0x82000580, 0x00008100, 0x040007f4, 0x0401f01c, + 0x4817c857, 0x82140500, 0x000003ff, 0x04020007, + 0x59cc0400, 0x82000500, 0x0000ff00, 0x82000580, + 0x00008100, 0x04020012, 0x42000000, 0x0010b8bd, + 0x0201f800, 0x0010aa47, 0x0201f800, 0x00105dfa, + 0x4803c856, 0x4a039005, 0x00000140, 0x0401f020, + 0x4817c857, 0x82140500, 0x00f60000, 0x04020004, + 0x0201f800, 0x00105e35, 0x040207d2, 0x0201f800, + 0x0010513b, 0x04000010, 0x59c400a4, 0x4803c857, + 0x82000500, 0x0000000f, 0x82000580, 0x0000000a, + 0x04020009, 0x497b5016, 0x59c400a3, 0x82000540, + 0x00080000, 0x480388a3, 0x82000500, 0xfff7ffff, + 0x480388a3, 0x4817c856, 0x0201f800, 0x0010a978, + 0x4a039005, 0x00000140, 0x0401f842, 0x4803c856, + 0x1c01f000, 0x00105a1d, 0x00105cf4, 0x00105a15, + 0x00105a15, 0x00105a15, 0x00105a15, 0x00105a15, + 0x00105a15, 0x4803c857, 0x42000000, 0x0010b85a, + 0x0201f800, 0x0010aa47, 0x4a039005, 0x00000140, + 0x1c01f000, 0x4817c857, 0x59cc0400, 0x4803c857, + 0x82000d00, 0x0000ff00, 0x82041500, 0x0000f000, + 0x840409c0, 0x82140500, 0x000003ff, 0x800018c4, + 0x8c142d14, 0x04000005, 0x59cc0002, 0x82000500, + 0x00000003, 0x800c1c80, 0x480f5016, 0x82080580, + 0x00002000, 0x04020011, 0x836c0580, 0x00000001, + 0x0402000c, 0x59cc0006, 0x82000500, 0xff000000, + 0x82000580, 0x11000000, 0x04020011, 0x0201f800, + 0x00103b38, 0x0201f800, 0x00105f48, 0x0401f00c, + 0x0401f81f, 0x0401f00a, 0x82080580, 0x00003000, + 0x04020003, 0x0401fa06, 0x0401f005, 0x82080580, + 0x00008000, 0x04020002, 0x0401fafc, 0x1c01f000, + 0x4817c857, 0x42000000, 0x0010b859, 0x0201f800, + 0x0010aa47, 0x836c0580, 0x00000003, 0x0402000b, + 0x4c080000, 0x4c0c0000, 0x42001000, 0x00008048, + 0x40141800, 0x80142120, 0x0201f800, 0x00103a3e, + 0x5c001800, 0x5c001000, 0x1c01f000, 0x4807c857, + 0x59cc0002, 0x82000500, 0xff000000, 0x82001580, + 0x01000000, 0x04000004, 0x82001580, 0x23000000, + 0x04020192, 0x82040580, 0x00000023, 0x0402003f, + 0x0401fb6a, 0x0400018d, 0x59300c06, 0x82040580, + 0x00000010, 0x04000013, 0x82040580, 0x00000011, + 0x04000010, 0x82040580, 0x00000001, 0x0400000d, + 0x82040580, 0x00000004, 0x0400000a, 0x82040580, + 0x00000008, 0x04000007, 0x82040580, 0x0000000a, + 0x04000004, 0x4933c857, 0x4807c857, 0x0401f177, + 0x59300004, 0x82000500, 0x80010000, 0x04000004, + 0x0201f800, 0x00106f60, 0x04020170, 0x59cc0a04, + 0x48066202, 0x59cc0006, 0x82000500, 0xffff0000, + 0x82000d80, 0x02000000, 0x04020005, 0x42027000, + 0x00000015, 0x0201f000, 0x000207a1, 0x82000d80, + 0x02140000, 0x040007fa, 0x82000d80, 0x02100000, + 0x040007f7, 0x82000d80, 0x02100000, 0x040007f4, + 0x82000d80, 0x01000000, 0x04020158, 0x59cc0006, + 0x82000500, 0x0000ffff, 0x04020154, 0x42027000, + 0x00000016, 0x0401f7ec, 0x82040580, 0x00000022, + 0x0402014e, 0x59a80806, 0x8c040d14, 0x04000011, + 0x0401f967, 0x0402000f, 0x0401f97d, 0x0400000d, + 0x42027000, 0x0000004c, 0x59cc0001, 0x82000500, + 0x00ffffff, 0x0201f800, 0x00105eec, 0x0400012a, + 0x42028800, 0x0000ffff, 0x417a6800, 0x0401f126, + 0x59cc0006, 0x82000500, 0xffff0000, 0x82000d80, + 0x03000000, 0x04020021, 0x59a80026, 0x8c000508, + 0x04000017, 0x8400054c, 0x48035026, 0x59cc0800, + 0x82040d00, 0x00ffffff, 0x48075010, 0x497b8830, + 0x84040d70, 0x48078832, 0x59c40802, 0x84040d4c, + 0x48078802, 0x59cc0007, 0x82000500, 0x0000ffff, + 0x48038893, 0x4803501e, 0x42000800, 0x00000003, + 0x59a81010, 0x0201f800, 0x00106c78, 0x59cc0006, + 0x82000500, 0x0000ffff, 0x04020118, 0x42027000, + 0x00000017, 0x0401f0d9, 0x82000d80, 0x04000000, + 0x04020011, 0x59cc0006, 0x82000500, 0x0000ffff, + 0x0402010e, 0x0201f800, 0x0010513b, 0x04000004, + 0x42027000, 0x0000001d, 0x0401f0cc, 0x59a80026, + 0x84000548, 0x48035026, 0x42027000, 0x00000030, + 0x0401f0c6, 0x82000d80, 0x05000000, 0x04020008, + 0x59cc0006, 0x82000500, 0x0000ffff, 0x040200fb, + 0x42027000, 0x00000018, 0x0401f0bc, 0x82000d80, + 0x20100000, 0x04020004, 0x42027000, 0x00000019, + 0x0401f0b6, 0x82000d80, 0x21100000, 0x04020004, + 0x42027000, 0x0000001a, 0x0401f0b0, 0x82000d80, + 0x52000000, 0x04020008, 0x59cc0006, 0x82000500, + 0x0000ffff, 0x040200e5, 0x42027000, 0x0000001b, + 0x0401f0a6, 0x82000d80, 0x50000000, 0x04020008, + 0x59cc0006, 0x82000500, 0x0000ffff, 0x040200db, + 0x42027000, 0x0000001c, 0x0401f09c, 0x82000d80, + 0x13000000, 0x04020004, 0x42027000, 0x00000034, + 0x0401f096, 0x82000d80, 0x12000000, 0x04020008, + 0x59cc0006, 0x82000500, 0x0000ffff, 0x040200cb, + 0x42027000, 0x00000024, 0x0401f08c, 0x82000d00, + 0xff000000, 0x82040d80, 0x24000000, 0x04020004, + 0x42027000, 0x0000002d, 0x0401f084, 0x82000d00, + 0xff000000, 0x82040d80, 0x53000000, 0x04020004, + 0x42027000, 0x0000002a, 0x0401f07c, 0x82000d80, + 0x0f000000, 0x04020004, 0x42027000, 0x00000020, + 0x0401f076, 0x82000d80, 0x61040000, 0x04020036, + 0x83cc1400, 0x00000006, 0x80080800, 0x50080000, + 0x82000500, 0x0000ffff, 0x82000480, 0x00000004, + 0x4c580000, 0x8000b104, 0x8058b1c0, 0x04000026, + 0x4c100000, 0x50041800, 0x820c1500, 0x03000000, + 0x80081130, 0x42000000, 0x0010b817, 0x82082580, + 0x00000000, 0x04020004, 0x42000000, 0x0010b814, + 0x0401f00c, 0x82082580, 0x00000001, 0x04020004, + 0x42000000, 0x0010b815, 0x0401f006, 0x82082580, + 0x00000002, 0x04020003, 0x42000000, 0x0010b816, + 0x0201f800, 0x0010aa47, 0x42001000, 0x00008015, + 0x820c2500, 0x0000ffff, 0x800c1920, 0x0201f800, + 0x00103a3e, 0x5c002000, 0x80040800, 0x8058b040, + 0x040207da, 0x5c00b000, 0x42027000, 0x00000023, + 0x0401f03e, 0x82000d80, 0x60000000, 0x04020004, + 0x42027000, 0x0000003f, 0x0401f038, 0x82000d80, + 0x54000000, 0x04020006, 0x0401fb12, 0x0402006f, + 0x42027000, 0x00000046, 0x0401f030, 0x82000d80, + 0x55000000, 0x04020009, 0x0401fb32, 0x04020004, + 0x42027000, 0x00000041, 0x0401f028, 0x42027000, + 0x00000042, 0x0401f025, 0x82000d80, 0x78000000, + 0x04020004, 0x42027000, 0x00000045, 0x0401f01f, + 0x82000d80, 0x10000000, 0x04020004, 0x42027000, + 0x0000004e, 0x0401f019, 0x82000d80, 0x63000000, + 0x04020004, 0x42027000, 0x0000004a, 0x0401f013, + 0x82000d00, 0xff000000, 0x82040d80, 0x56000000, + 0x04020004, 0x42027000, 0x0000004f, 0x0401f00b, + 0x82000d00, 0xff000000, 0x82040d80, 0x57000000, + 0x04020004, 0x42027000, 0x00000050, 0x0401f003, + 0x42027000, 0x0000001d, 0x59cc3800, 0x821c3d00, + 0x00ffffff, 0x821c0580, 0x00fffffe, 0x59cc0001, + 0x04020005, 0x40003000, 0x42028800, 0x000007fe, + 0x0401f003, 0x0401f8d1, 0x04020030, 0x0201f800, + 0x001045a6, 0x0402002d, 0x83380580, 0x00000046, + 0x04020004, 0x59a80010, 0x80180580, 0x04000027, + 0x59340200, 0x8c000514, 0x0400000f, 0x83380580, + 0x00000030, 0x0400000c, 0x83380580, 0x0000003f, + 0x04000009, 0x83380580, 0x00000034, 0x04000006, + 0x83380580, 0x00000024, 0x04000003, 0x42027000, + 0x0000004c, 0x0201f800, 0x0002075a, 0x04000018, + 0x49366009, 0x4a026406, 0x00000004, 0x59cc0c04, + 0x48066202, 0x83380580, 0x0000004c, 0x04020009, + 0x4a026406, 0x00000011, 0x813669c0, 0x04020005, + 0x59cc0001, 0x82000500, 0x00ffffff, 0x4802601e, + 0x0201f000, 0x000207a1, 0x59880052, 0x4803c857, + 0x80000000, 0x48031052, 0x1c01f000, 0x42001000, + 0x00008049, 0x59cc1806, 0x800c1930, 0x0201f800, + 0x00103a3e, 0x0201f800, 0x00107942, 0x040007f3, + 0x49366009, 0x4a026406, 0x00000004, 0x59cc0c04, + 0x48066202, 0x4a026403, 0x00000009, 0x4a02641a, + 0x00000009, 0x4a02621a, 0x00002900, 0x4a026203, + 0x00000001, 0x0201f000, 0x0010672b, 0x59a80026, + 0x4803c857, 0x8c000508, 0x04000010, 0x59cc0006, + 0x82000500, 0xff000000, 0x82000d80, 0x03000000, + 0x0400000c, 0x82000d80, 0x20000000, 0x04000009, + 0x82000d80, 0x05000000, 0x04000006, 0x82000d80, + 0x21000000, 0x04000003, 0x80000580, 0x1c01f000, + 0x82000540, 0x00000001, 0x0401f7fd, 0x59cc2006, + 0x82102500, 0xff000000, 0x9c1021c0, 0x0401f807, + 0x820c1c00, 0x0010b4e3, 0x500c1800, 0x800c0500, + 0x4803c857, 0x1c01f000, 0x40100800, 0x41781800, + 0x82040480, 0x00000020, 0x04001004, 0x800c1800, + 0x40000800, 0x0401f7fb, 0x82040500, 0x0000000f, + 0x82000400, 0x0010ab38, 0x50000000, 0x8c040d08, + 0x04000002, 0x900001c0, 0x1c01f000, 0x4803c856, + 0x0401fac3, 0x0402000a, 0x0201f800, 0x0010210a, + 0x04020007, 0x59cc0002, 0x82000500, 0xff000000, + 0x82000d80, 0x08000000, 0x04000802, 0x1c01f000, + 0x4803c856, 0x59cc0400, 0x82000d00, 0x0000ff00, + 0x840409c0, 0x82040580, 0x00000033, 0x0402001f, + 0x0401f976, 0x04000038, 0x59cc0a04, 0x48066202, + 0x59cc0006, 0x4803c857, 0x82000500, 0xffff0000, + 0x82000d80, 0x02000000, 0x04020009, 0x59cc0006, + 0x82000500, 0x0000ffff, 0x0402002b, 0x42027000, + 0x00000015, 0x0201f000, 0x000207a1, 0x82000d80, + 0x01000000, 0x04020024, 0x59cc0006, 0x82000500, + 0x0000ffff, 0x04020020, 0x42027000, 0x00000016, + 0x0201f000, 0x000207a1, 0x82040580, 0x00000032, + 0x04020019, 0x59cc0006, 0x82000500, 0xffff0000, + 0x82000d80, 0x14000000, 0x04020013, 0x42027000, + 0x00000038, 0x59cc0001, 0x0401f810, 0x0402000e, + 0x0201f800, 0x001045a6, 0x0402000b, 0x0201f800, + 0x0002075a, 0x04000008, 0x49366009, 0x4a026406, + 0x00000004, 0x59cc0c04, 0x48066202, 0x0201f000, + 0x000207a1, 0x1c01f000, 0x4803c857, 0x4c580000, + 0x4c100000, 0x4c380000, 0x4c340000, 0x82003500, + 0x00ffffff, 0x82181500, 0x00ff0000, 0x82081580, + 0x00ff0000, 0x04020016, 0x82181480, 0x00fffffc, + 0x04001013, 0x82181580, 0x00fffffd, 0x04020004, + 0x42028800, 0x000007fd, 0x0401f040, 0x82181580, + 0x00fffffe, 0x04020004, 0x42028800, 0x000007fe, + 0x0401f03a, 0x82181580, 0x00fffffc, 0x04020004, + 0x42028800, 0x000007fc, 0x0401f034, 0x41781000, + 0x42002000, 0x00000000, 0x4200b000, 0x000007f0, + 0x41ac7000, 0x50380000, 0x80006d40, 0x04020005, + 0x800811c0, 0x0402001e, 0x8410155e, 0x0401f01c, + 0x58340212, 0x82000500, 0x0000ff00, 0x04000011, + 0x59a84010, 0x82204500, 0x00ffff00, 0x82180500, + 0x00ffff00, 0x04000002, 0x80200580, 0x58340002, + 0x0402000f, 0x82000500, 0x000000ff, 0x82184500, + 0x000000ff, 0x80204580, 0x04020009, 0x0401f006, + 0x58340002, 0x82000500, 0x00ffffff, 0x80184580, + 0x04020003, 0x40128800, 0x0401f00c, 0x80102000, + 0x80387000, 0x8058b040, 0x040207db, 0x800811c0, + 0x04020005, 0x481bc857, 0x82000540, 0x00000001, + 0x0401f003, 0x840a8d1e, 0x80000580, 0x5c006800, + 0x5c007000, 0x5c002000, 0x5c00b000, 0x1c01f000, + 0x59a80026, 0x8c00050e, 0x04000003, 0x8c000502, + 0x04000006, 0x59cc0c00, 0x80040910, 0x82040500, + 0x0000000f, 0x0c01f002, 0x1c01f000, 0x00105d0f, + 0x00105d0f, 0x00105d0f, 0x00105de5, 0x00105d0f, + 0x00105d11, 0x00105d29, 0x00105d2c, 0x00105d0f, + 0x00105d0f, 0x00105d0f, 0x00105d0f, 0x00105d0f, + 0x00105d0f, 0x00105d0f, 0x00105d0f, 0x4803c856, + 0x1c01f000, 0x0401f8c5, 0x04000014, 0x82140500, + 0x000003ff, 0x800000c4, 0x82000480, 0x00000008, + 0x0400100e, 0x59cc0001, 0x59326809, 0x59340802, + 0x80040580, 0x82000500, 0x00ffffff, 0x04020007, + 0x59cc0a04, 0x48066202, 0x42027000, 0x00000046, + 0x0201f000, 0x000207a1, 0x59cc0004, 0x4803c857, + 0x1c01f000, 0x59cc0004, 0x4803c857, 0x1c01f000, + 0x0401f8aa, 0x04000016, 0x82140500, 0x000003ff, + 0x800000c4, 0x82000480, 0x0000000c, 0x04001010, + 0x59cc0001, 0x82000500, 0x00ffffff, 0x59326809, + 0x59340802, 0x82040d00, 0x00ffffff, 0x80040580, + 0x04020007, 0x59cc0a04, 0x48066202, 0x42027000, + 0x00000045, 0x0201f000, 0x000207a1, 0x59cc0004, + 0x4803c857, 0x1c01f000, 0x4817c857, 0x0401f9c8, + 0x04020011, 0x0201f800, 0x0010210a, 0x0402000e, + 0x59cc0002, 0x82000500, 0xff000000, 0x82000580, + 0x00000000, 0x04020008, 0x82040500, 0x0000000f, + 0x82000c80, 0x00000006, 0x04021003, 0x4803c857, + 0x0c01f002, 0x1c01f000, 0x00105d60, 0x00105d64, + 0x00105d60, 0x00105d60, 0x00105db2, 0x00105dc3, + 0x4803c857, 0x59cc0004, 0x4803c857, 0x1c01f000, + 0x59cc0004, 0x4803c857, 0x59a80016, 0x800001c0, + 0x040207f8, 0x59cc0802, 0x8c040d2e, 0x0402001d, + 0x0201f800, 0x00107942, 0x02000800, 0x001005d8, + 0x59cc0001, 0x4803c857, 0x0401ff28, 0x0402000d, + 0x0201f800, 0x00020245, 0x0402000a, 0x4a026406, + 0x00000005, 0x49366009, 0x59cc0c04, 0x48066202, + 0x42027000, 0x00000088, 0x0201f000, 0x000207a1, + 0x42028800, 0x0000ffff, 0x417a6800, 0x59cc0001, + 0x82000500, 0x00ffffff, 0x4802601e, 0x0401f7f0, + 0x59cc0001, 0x4803c857, 0x0401ff10, 0x040207d5, + 0x0201f800, 0x001045a6, 0x040207d2, 0x59cc0005, + 0x8c000500, 0x04020004, 0x59340200, 0x8c00050e, + 0x040207cc, 0x0201f800, 0x001049f3, 0x0402000f, + 0x0401f83e, 0x040007c7, 0x0201f800, 0x0002075a, + 0x040007c4, 0x49366009, 0x4a026406, 0x00000002, + 0x59cc0c04, 0x48066202, 0x42027000, 0x00000088, + 0x0201f000, 0x000207a1, 0x0201f800, 0x0002075a, + 0x040007b8, 0x49366009, 0x4a026406, 0x00000004, + 0x59cc0c04, 0x48066202, 0x42027000, 0x00000001, + 0x0201f000, 0x000207a1, 0x59cc0004, 0x4803c857, + 0x59cc0802, 0x8c040d2e, 0x0400000b, 0x0401f81f, + 0x04000009, 0x0401f960, 0x04020007, 0x59cc0a04, + 0x48066202, 0x42027000, 0x00000089, 0x0201f000, + 0x000207a1, 0x4933c857, 0x1c01f000, 0x59cc0004, + 0x4803c857, 0x59cc0802, 0x8c040d2e, 0x0400000b, + 0x0401f80e, 0x04000009, 0x0401f94f, 0x04020007, + 0x59cc0a04, 0x48066202, 0x42027000, 0x0000008a, + 0x0201f000, 0x000207a1, 0x4933c857, 0x1c01f000, + 0x59cc0a04, 0x0401f002, 0x59cc0c04, 0x59a8000e, + 0x59a81067, 0x80080400, 0x80040480, 0x04021008, + 0x40040000, 0x800000c4, 0x800408ca, 0x80040c00, + 0x82066400, 0x0010d1c0, 0x1c01f000, 0x80000580, + 0x0401f7fe, 0x59cc0802, 0x8c040d2e, 0x04020010, + 0x0401ffec, 0x0400000e, 0x59cc0001, 0x82000500, + 0x00ffffff, 0x59326809, 0x59340802, 0x82040d00, + 0x00ffffff, 0x80040580, 0x04020005, 0x42027000, + 0x00000051, 0x0201f000, 0x000207a1, 0x59cc0004, + 0x4803c857, 0x1c01f000, 0x4803c856, 0x42003000, + 0x00000105, 0x0401f001, 0x4803c856, 0x4c3c0000, + 0x41cc7800, 0x0401f803, 0x5c007800, 0x1c01f000, + 0x4803c856, 0x4c580000, 0x583c0400, 0x82000500, + 0x0000f000, 0x82000580, 0x0000c000, 0x04000024, + 0x0201f800, 0x0002075a, 0x04000021, 0x4c180000, + 0x583c0001, 0x0401fe89, 0x0402001f, 0x0201f800, + 0x001045a6, 0x0402001c, 0x49366009, 0x0201f800, + 0x001007e4, 0x04000018, 0x492e6017, 0x497a5800, + 0x497a5a04, 0x48125c04, 0x832cac00, 0x00000005, + 0x4200b000, 0x00000007, 0x403ca000, 0x0201f800, + 0x0010ab17, 0x5c003000, 0x481a641a, 0x4a026403, + 0x0000003e, 0x4a026406, 0x00000001, 0x4a026203, + 0x00000001, 0x0201f800, 0x0010672b, 0x5c00b000, + 0x1c01f000, 0x0201f800, 0x0002077d, 0x5c003000, + 0x0401f7fb, 0x4803c856, 0x59cc0400, 0x82000d00, + 0x0000ff00, 0x82040500, 0x0000f000, 0x840409c0, + 0x82000580, 0x00002000, 0x04020049, 0x82040580, + 0x00000022, 0x0402003a, 0x59c400a4, 0x82000500, + 0x0000000f, 0x82000c80, 0x00000007, 0x04001004, + 0x82000480, 0x0000000c, 0x0400103f, 0x59cc0006, + 0x82000500, 0xffff0000, 0x82000d80, 0x04000000, + 0x04000039, 0x82000d80, 0x60000000, 0x04000036, + 0x82000d80, 0x54000000, 0x04000033, 0x82000d80, + 0x03000000, 0x04020015, 0x59a80826, 0x8c040d02, + 0x0402002d, 0x8c040d08, 0x0402002b, 0x0201f800, + 0x001048ec, 0x0400002b, 0x59a8001d, 0x800000d0, + 0x59a80810, 0x82040d00, 0x000000ff, 0x80040540, + 0x59cc0800, 0x82040d00, 0x00ffffff, 0x80040580, + 0x0402001b, 0x0401f01c, 0x59c40802, 0x8c040d0c, + 0x04020017, 0x82000d80, 0x52000000, 0x040007ec, + 0x82000d80, 0x05000000, 0x040007e9, 0x82000d80, + 0x50000000, 0x040007e6, 0x0401f00d, 0x82040580, + 0x00000023, 0x0402000a, 0x0401ff58, 0x04000008, + 0x59300c03, 0x82040580, 0x00000002, 0x04000006, + 0x82040580, 0x00000051, 0x04000003, 0x80000580, + 0x0401f003, 0x82000540, 0x00000001, 0x1c01f000, + 0x59cc0006, 0x82000500, 0xffff0000, 0x82000d80, + 0x03000000, 0x04000004, 0x82000d80, 0x52000000, + 0x040207f3, 0x59a80026, 0x82000500, 0x00000009, + 0x82000580, 0x00000008, 0x040007ef, 0x0401f7ec, + 0x4803c856, 0x4c5c0000, 0x4c580000, 0x59a80016, + 0x82000580, 0x0000004c, 0x0402001f, 0x59ccb807, + 0x9c5cb9c0, 0x825cbd00, 0x00000007, 0x8c5cbd00, + 0x0400000a, 0x4200b000, 0x00000002, 0x83a81c00, + 0x00000002, 0x83cc1400, 0x0000000d, 0x0201f800, + 0x0010855a, 0x04020010, 0x8c5cbd02, 0x0400000a, + 0x4200b000, 0x00000002, 0x83a81c00, 0x00000000, + 0x83cc1400, 0x0000000f, 0x0201f800, 0x0010855a, + 0x04020005, 0x8c5cbd04, 0x04000003, 0x82000540, + 0x00000001, 0x5c00b000, 0x5c00b800, 0x1c01f000, + 0x4803c856, 0x4c5c0000, 0x4c580000, 0x59a80016, + 0x82000580, 0x0000004c, 0x0402001f, 0x59ccb807, + 0x9c5cb9c0, 0x825cbd00, 0x00000007, 0x8c5cbd00, + 0x0400000a, 0x4200b000, 0x00000002, 0x83a81c00, + 0x00000002, 0x83cc1400, 0x00000009, 0x0201f800, + 0x0010855a, 0x04020010, 0x8c5cbd02, 0x0400000a, + 0x4200b000, 0x00000002, 0x83a81c00, 0x00000000, + 0x83cc1400, 0x0000000b, 0x0201f800, 0x0010855a, + 0x04020005, 0x8c5cbd04, 0x04000003, 0x82000540, + 0x00000001, 0x5c00b000, 0x5c00b800, 0x1c01f000, + 0x4803c857, 0x4c580000, 0x40003000, 0x42002000, + 0x000007f0, 0x4200b000, 0x00000010, 0x83ac7400, + 0x000007f0, 0x50380000, 0x80026d40, 0x04000006, + 0x59340002, 0x82000500, 0x00ffffff, 0x80180580, + 0x04000010, 0x80102000, 0x80387000, 0x8058b040, + 0x040207f5, 0x82100480, 0x00000800, 0x42002000, + 0x00000000, 0x4200b000, 0x000007f0, 0x41ac7000, + 0x040217ed, 0x82000540, 0x00000001, 0x0401f002, + 0x40128800, 0x5c00b000, 0x1c01f000, 0x59a80026, + 0x8c00050e, 0x04000004, 0x8c000502, 0x04000003, + 0x80000580, 0x1c01f000, 0x82000540, 0x00000001, + 0x0401f7fd, 0x59300c06, 0x82040580, 0x00000002, + 0x04000006, 0x82040580, 0x00000005, 0x04000003, + 0x82000540, 0x00000001, 0x1c01f000, 0x59c80000, + 0x84000558, 0x84000512, 0x48039000, 0x1c01f000, + 0x4a03281a, 0x000003e8, 0x4a032802, 0x0010d1c0, + 0x4a032800, 0x00000000, 0x4a032808, 0x00107049, + 0x42000000, 0x00000005, 0x83947c00, 0x00000009, + 0x49787801, 0x4a007802, 0x00106fff, 0x823c7c00, + 0x00000003, 0x80000040, 0x040207fa, 0x4a032819, + 0xffff0000, 0x4201d000, 0x00000064, 0x0401f96e, + 0x4201d000, 0x000186a0, 0x0401f184, 0x00000000, + 0x00000003, 0x00000006, 0x00000009, 0x0000000c, + 0x4d300000, 0x4d2c0000, 0x4d340000, 0x4d400000, + 0x4cfc0000, 0x4d380000, 0x4d3c0000, 0x4d440000, + 0x4d4c0000, 0x4d480000, 0x4c5c0000, 0x4c600000, + 0x4c640000, 0x4cc80000, 0x4ccc0000, 0x0201f800, + 0x0002057b, 0x5c019800, 0x5c019000, 0x5c00c800, + 0x5c00c000, 0x5c00b800, 0x5c029000, 0x5c029800, + 0x5c028800, 0x5c027800, 0x5c027000, 0x5c01f800, + 0x5c028000, 0x5c026800, 0x5c025800, 0x5c026000, + 0x1c01f000, 0x59940004, 0x80000540, 0x0402000a, + 0x59940025, 0x80040400, 0x02001800, 0x001005d8, + 0x48032804, 0x480b2805, 0x4a032803, 0x0000000a, + 0x80000580, 0x1c01f000, 0x5994001f, 0x80000540, + 0x0402000a, 0x59940025, 0x80040400, 0x02001800, + 0x001005d8, 0x4803281f, 0x480b2820, 0x4a03281e, + 0x00000001, 0x80000580, 0x1c01f000, 0x59940022, + 0x80000540, 0x0402000a, 0x59940025, 0x80040400, + 0x02001800, 0x001005d8, 0x48032822, 0x480b2823, + 0x4a032821, 0x0000000a, 0x80000580, 0x1c01f000, + 0x4c000000, 0x59940005, 0x4803c857, 0x480bc857, + 0x80080580, 0x04020003, 0x497b2804, 0x497b2805, + 0x5c000000, 0x1c01f000, 0x4c000000, 0x59940020, + 0x4803c857, 0x480bc857, 0x80080580, 0x04020003, + 0x497b281f, 0x497b2820, 0x5c000000, 0x1c01f000, + 0x4c000000, 0x59940023, 0x4803c857, 0x480bc857, + 0x80080580, 0x04020003, 0x497b2822, 0x497b2823, + 0x5c000000, 0x1c01f000, 0x4937c857, 0x48ebc857, + 0x59340203, 0x80e80480, 0x04001002, 0x48ea6a03, + 0x1c01f000, 0x5c03e000, 0x1c01f000, 0x4d440000, + 0x42007800, 0x00000010, 0x59968801, 0x0201f800, + 0x00020245, 0x04020012, 0x59341a03, 0x800c1840, + 0x0400100f, 0x59940027, 0x800c0480, 0x04000003, + 0x48026a03, 0x0402100a, 0x5934000f, 0x497a6a03, + 0x80000540, 0x04000006, 0x4c3c0000, 0x5934140b, + 0x0201f800, 0x00020253, 0x5c007800, 0x81468800, + 0x83440480, 0x00000800, 0x04021007, 0x803c7840, + 0x040207e7, 0x49472801, 0x5c028800, 0x5c03e000, + 0x1c01f000, 0x4a032800, 0x00000002, 0x497b2801, + 0x0401f7fa, 0x42007800, 0x00000010, 0x59966002, + 0x59300205, 0x80000d40, 0x04000006, 0x59940027, + 0x80040480, 0x48026205, 0x0400102d, 0x0400002c, + 0x59300206, 0x80000d40, 0x04000014, 0x59b800e4, + 0x8c000524, 0x04020011, 0x4a0370e4, 0x00030000, + 0x40000000, 0x59b800e4, 0x8c000524, 0x04000004, + 0x4a0370e4, 0x00020000, 0x0401f008, 0x59940027, + 0x80040480, 0x48026206, 0x4a0370e4, 0x00020000, + 0x0400101c, 0x0400001b, 0x83326400, 0x00000024, + 0x49332802, 0x41540000, 0x81300480, 0x04021005, + 0x803c7840, 0x040207db, 0x5c03e000, 0x1c01f000, + 0x59940026, 0x48032827, 0x4a032802, 0x0010d1c0, + 0x497b2826, 0x80000540, 0x0400000f, 0x4a032800, + 0x00000001, 0x5c03e000, 0x1c01f000, 0x4c3c0000, + 0x0201f800, 0x001091db, 0x5c007800, 0x0401f7d1, + 0x4c3c0000, 0x0201f800, 0x00108d5d, 0x5c007800, + 0x0401f7e2, 0x4a032800, 0x00000000, 0x5c03e000, + 0x1c01f000, 0x59a8086b, 0x8c040d30, 0x04020029, + 0x8c040d32, 0x0400000f, 0x59a80069, 0x81640480, + 0x04001019, 0x59a8000b, 0x81500580, 0x04000005, + 0x59a8006a, 0x59a81066, 0x80080580, 0x04020012, + 0x900411c0, 0x82081500, 0x00007000, 0x0401f012, + 0x82040500, 0x0000001f, 0x04000016, 0x80040840, + 0x82040500, 0x0000001f, 0x04000003, 0x4807506b, + 0x0401f010, 0x900401c0, 0x82000500, 0x0000001f, + 0x80040d40, 0x900401c0, 0x80040580, 0x82001500, + 0x00007000, 0x82040500, 0xffff8fff, 0x80080540, + 0x4803506b, 0x80081114, 0x0201f800, 0x001006e2, + 0x1c01f000, 0x4a032807, 0x000007d0, 0x4a032806, + 0x0000000a, 0x1c01f000, 0x42000800, 0x000007d0, + 0x83180480, 0x00000005, 0x02021800, 0x001005d8, + 0x83947c00, 0x00000009, 0x83180400, 0x00105f43, + 0x50000000, 0x803c7c00, 0x48047801, 0x4a007800, + 0x0000000a, 0x1c01f000, 0x83180480, 0x00000005, + 0x02021800, 0x001005d8, 0x83947c00, 0x00000009, + 0x83180400, 0x00105f43, 0x50000000, 0x803c7c00, + 0x49787801, 0x1c01f000, 0x4807c857, 0x480bc857, + 0x59940025, 0x80040400, 0x02001800, 0x001005d8, + 0x48032804, 0x480b2805, 0x4a032803, 0x0000000a, + 0x1c01f000, 0x4807c857, 0x480bc857, 0x59940025, + 0x80040400, 0x02001800, 0x001005d8, 0x4803281c, + 0x480b281d, 0x4a03281b, 0x0000000a, 0x1c01f000, + 0x4c000000, 0x5994001d, 0x4803c857, 0x480bc857, + 0x80080580, 0x04020003, 0x4803281c, 0x4803281d, + 0x5c000000, 0x1c01f000, 0x80e9d1c0, 0x0400000e, + 0x0401f836, 0x04025000, 0x4203e000, 0x80000000, + 0x40e81000, 0x41780800, 0x42000000, 0x00000064, + 0x0201f800, 0x001066a0, 0x59940024, 0x80080400, + 0x48032824, 0x1c01f000, 0x42001000, 0x00105065, + 0x0401fef0, 0x42001000, 0x00105058, 0x0401ffe1, + 0x42001000, 0x00104148, 0x0401feea, 0x42001000, + 0x001041bc, 0x0401fee7, 0x42001000, 0x001041f3, + 0x0401f6f8, 0x4203e000, 0x70000000, 0x4203e000, + 0xb0300000, 0x41fc0000, 0x40ebf800, 0x80e80480, + 0x04001011, 0x04000004, 0x82000480, 0x00000003, + 0x0402100d, 0x42000000, 0x0000000f, 0x04004004, + 0x80000040, 0x040207fe, 0x0401f007, 0x4203e000, + 0x70000000, 0x42000000, 0x0010b87e, 0x0201f800, + 0x0010aa47, 0x1c01f000, 0x4203e000, 0x80000000, + 0x4203e000, 0xb0400000, 0x41fc0000, 0x40ebf800, + 0x80e80480, 0x04001011, 0x04000004, 0x82000480, + 0x00000003, 0x0402100d, 0x42000000, 0x0000000f, + 0x04005004, 0x80000040, 0x040207fe, 0x0401f007, + 0x4203e000, 0x80000000, 0x42000000, 0x0010b87f, + 0x0201f800, 0x0010aa47, 0x1c01f000, 0x59a8000e, + 0x82000480, 0x00000100, 0x599c0a02, 0x800409c0, + 0x04020002, 0x80040800, 0x80041480, 0x04001002, + 0x40000800, 0x48075067, 0x59a8100e, 0x40040000, + 0x800acc80, 0x4967500e, 0x49675069, 0x59aaa80b, + 0x41640800, 0x42001000, 0x00000024, 0x0201f800, + 0x00106681, 0x8206a400, 0x0010d1c0, 0x49535065, + 0x4152b000, 0x42006000, 0x0010be65, 0x4a006004, + 0x0000012c, 0x4a006005, 0xda10da10, 0x4a006008, + 0x00000011, 0x4a006009, 0x0010be65, 0x4a00600a, + 0x001010b8, 0x599c0014, 0x48006011, 0x599c0015, + 0x48006012, 0x42006000, 0x0010be41, 0x4a006203, + 0x00000008, 0x4a006406, 0x00000006, 0x4a006002, + 0xffff0000, 0x4a006008, 0x0010be65, 0x4a006014, + 0x0010be65, 0x599c0014, 0x48006015, 0x599c0015, + 0x48006016, 0x599c0413, 0x48006017, 0x49506018, + 0x49546019, 0x59a80067, 0x4800601a, 0x4a00601b, + 0x0010b465, 0x4a00601c, 0x0010b466, 0x4a00601d, + 0x0010b46a, 0x42000000, 0xb0000000, 0x42000800, + 0x0010be41, 0x0201f800, 0x00100b68, 0x1c01f000, + 0x82000d00, 0x000000c0, 0x04000004, 0x82040d80, + 0x000000c0, 0x04020055, 0x82000d00, 0x00002020, + 0x59300414, 0x84000512, 0x82040d80, 0x00002020, + 0x0400000b, 0x8c000514, 0x0402000f, 0x48026414, + 0x813e79c0, 0x02020000, 0x000206d0, 0x42027000, + 0x00000043, 0x0201f000, 0x000207a1, 0x59326809, + 0x59340a00, 0x8c040d0a, 0x040007f3, 0x84000552, + 0x0401f7f1, 0x84000514, 0x592c080d, 0x48066015, + 0x0401f7ef, 0x59326809, 0x59340a00, 0x8c040d0a, + 0x02000000, 0x000206e3, 0x59300c14, 0x84040d52, + 0x48066414, 0x0201f000, 0x000206e3, 0x0201f800, + 0x00020086, 0x813e79c0, 0x02020000, 0x000206d0, + 0x0201f000, 0x000206f1, 0x8c00051e, 0x02000000, + 0x000206fd, 0x82000d00, 0x00002020, 0x82040d80, + 0x00002020, 0x04000014, 0x82000500, 0x000000c0, + 0x82000d80, 0x00000080, 0x04000008, 0x813e79c0, + 0x02020000, 0x000206d0, 0x42027000, 0x00000041, + 0x0201f000, 0x000207a1, 0x813e79c0, 0x02020000, + 0x000206d0, 0x42027000, 0x00000043, 0x0201f000, + 0x000207a1, 0x59326809, 0x59340a00, 0x8c040d0a, + 0x040007ea, 0x59300c14, 0x84040d52, 0x48066414, + 0x0401f7e6, 0x492fc857, 0x42000800, 0x00000006, + 0x0201f000, 0x000206f8, 0x492fc857, 0x42000800, + 0x00000004, 0x0201f000, 0x000206f8, 0x4807c856, + 0x59a80068, 0x800409c0, 0x04000003, 0x80080540, + 0x0401f002, 0x80080500, 0x48035068, 0x1c01f000, + 0x4a030800, 0x00000000, 0x4a030802, 0x00000001, + 0x497b0803, 0x497b0804, 0x1c01f000, 0x59840002, + 0x8c000500, 0x04000004, 0x84000500, 0x4a030800, + 0x00000001, 0x84000544, 0x84000506, 0x48030802, + 0x82000d00, 0x0fffffff, 0x42000000, 0x90000000, + 0x0201f800, 0x00100b94, 0x59a80069, 0x82000480, + 0x00000007, 0x48035069, 0x80000580, 0x42000800, + 0x0010b519, 0x48000800, 0x48000801, 0x1c01f000, + 0x59a80069, 0x82000480, 0x00000007, 0x48035069, + 0x1c01f000, 0x83640480, 0x00000008, 0x0400101b, + 0x58c80a03, 0x80000580, 0x82000400, 0x00000008, + 0x80040840, 0x040207fd, 0x815c0480, 0x04001013, + 0x4200b000, 0x00000007, 0x0201f800, 0x0002075a, + 0x4a026203, 0x00000004, 0x4a026406, 0x00000009, + 0x4a026203, 0x00000004, 0x4a026007, 0x00000101, + 0x0401f809, 0x0401f880, 0x8058b040, 0x040207f3, + 0x80000580, 0x1c01f000, 0x82000540, 0x00000001, + 0x0401f7fd, 0x0201f800, 0x001007e4, 0x492e6008, + 0x58c80a03, 0x4a025a04, 0x0000002c, 0x497a5800, + 0x497a5801, 0x497a5c04, 0x497a5c06, 0x497a5805, + 0x4a025a08, 0x00000005, 0x4a025a07, 0x00000002, + 0x58c80201, 0x48025c04, 0x58c80202, 0x48025c07, + 0x58c80204, 0x48025c08, 0x4a02580d, 0x0000ffff, + 0x80040840, 0x0400000c, 0x412c2000, 0x0201f800, + 0x001007e4, 0x4a025a04, 0x0000000a, 0x497a5c04, + 0x48125800, 0x492c2001, 0x412c2000, 0x80040840, + 0x040207f7, 0x1c01f000, 0x4d7c0000, 0x4202f800, + 0x00000010, 0x4df00000, 0x4203e000, 0x50000000, + 0x59847803, 0x803c79c0, 0x0400001e, 0x4c5c0000, + 0x583cb808, 0x585c3408, 0x801831c0, 0x0400000b, + 0x0401f84a, 0x04000016, 0x42001000, 0x0010b519, + 0x0401f87f, 0x04000012, 0x0201f800, 0x001007d3, + 0x0400000f, 0x492cb805, 0x585c0005, 0x80000540, + 0x02000800, 0x001005d8, 0x0401f830, 0x585c5408, + 0x0401f80b, 0x5c00b800, 0x5c03e000, 0x817ef840, + 0x040207e1, 0x5c02f800, 0x1c01f000, 0x5c00b800, + 0x5c03e000, 0x5c02f800, 0x1c01f000, 0x4803c856, + 0x405c6000, 0x802851c0, 0x04000018, 0x585c0204, + 0x82000d00, 0x0000000f, 0x82040c00, 0x001010bd, + 0x50044000, 0x4cf00000, 0x4d000000, 0x4d040000, + 0x4021e000, 0x40320800, 0x59860004, 0x4c280000, + 0x0401f934, 0x5c005000, 0x40f04000, 0x41046000, + 0x0201f800, 0x0010109b, 0x040207f6, 0x5c020800, + 0x5c020000, 0x5c01e000, 0x58c80204, 0x4800bc08, + 0x0201f800, 0x00020086, 0x4a026007, 0x00000101, + 0x497a6009, 0x0401f055, 0x4803c856, 0x59840003, + 0x80026540, 0x04000003, 0x59300000, 0x48030803, + 0x1c01f000, 0x4803c856, 0x59840003, 0x48026000, + 0x49330803, 0x1c01f000, 0x58cc0805, 0x40180000, + 0x80040480, 0x0400100d, 0x82cc0580, 0x0010b50e, + 0x02020800, 0x001005d8, 0x58c80205, 0x80040480, + 0x0400101d, 0x82000540, 0x00000001, 0x1c01f000, + 0x80003580, 0x0401f7fe, 0x82cc0580, 0x0010b50e, + 0x02020800, 0x001005d8, 0x58c80400, 0x8c000504, + 0x040007f8, 0x58c8040b, 0x8c00051e, 0x040007f5, + 0x8c000500, 0x040207f3, 0x84000540, 0x4801940b, + 0x42000000, 0x0010b839, 0x0201f800, 0x0010aa47, + 0x42001000, 0x00008026, 0x0201f800, 0x00103a3e, + 0x0401f7e8, 0x58c8040b, 0x8c00051e, 0x040007e2, + 0x8c000502, 0x040207e0, 0x84000542, 0x4801940b, + 0x42000000, 0x0010b838, 0x0201f800, 0x0010aa47, + 0x42001000, 0x00008025, 0x42001800, 0x00000000, + 0x0201f800, 0x00103a3e, 0x0401f7d3, 0x4803c856, + 0x58080000, 0x42001800, 0x00000007, 0x58080801, + 0x80040480, 0x04020004, 0x400c0000, 0x80000540, + 0x0401f005, 0x04001003, 0x800c0480, 0x0401f002, + 0x80000080, 0x1c01f000, 0x4803c856, 0x59300008, + 0x80000d40, 0x02000800, 0x001005d8, 0x58040005, + 0x80000540, 0x02000800, 0x001005d8, 0x59300007, + 0x82000500, 0x00000101, 0x82000580, 0x00000101, + 0x02020800, 0x001005d8, 0x42001000, 0x0010b519, + 0x58080801, 0x82040400, 0x0010b51b, 0x497a6414, + 0x4a026015, 0x0000ffff, 0x45300000, 0x80040800, + 0x82040480, 0x00000008, 0x04001002, 0x80000d80, + 0x48041001, 0x82040400, 0x0010b51b, 0x45780000, + 0x1c01f000, 0x4933c857, 0x59300808, 0x800409c0, + 0x02000800, 0x001005d8, 0x4d2c0000, 0x58065805, + 0x812e59c0, 0x02020800, 0x001007f4, 0x49780805, + 0x40065800, 0x0201f800, 0x001007fd, 0x5c025800, + 0x4d300000, 0x0201f800, 0x0002077d, 0x5c026000, + 0x1c01f000, 0x59300406, 0x82000580, 0x00000009, + 0x04020006, 0x59300007, 0x8c000510, 0x04000003, + 0x80000580, 0x1c01f000, 0x82000540, 0x00000001, + 0x1c01f000, 0x59840802, 0x8c040d04, 0x1c01f000, + 0x4803c856, 0x59840802, 0x84040d04, 0x84040d40, + 0x4a030800, 0x00000000, 0x48070802, 0x82040d00, + 0x0fffffff, 0x42000000, 0x90000000, 0x0201f000, + 0x00100b94, 0x4807c857, 0x4805980a, 0x49799801, + 0x49799803, 0x49799806, 0x49799807, 0x49799808, + 0x49799805, 0x49799809, 0x0401f8c9, 0x0400000a, + 0x0401f8eb, 0x04000008, 0x48359800, 0x48359802, + 0x48359806, 0x4a019804, 0x00000001, 0x4a019807, + 0x00000005, 0x1c01f000, 0x4807c857, 0x58cc1007, + 0x40040000, 0x80080480, 0x04021020, 0x4c040000, + 0x4c080000, 0x0401f8da, 0x5c001000, 0x5c000800, + 0x0400001c, 0x58cc0006, 0x80006540, 0x0402000b, + 0x48359800, 0x48359802, 0x48359806, 0x49799801, + 0x49799803, 0x49786801, 0x49786800, 0x49799804, + 0x49799807, 0x0401f005, 0x48306801, 0x48346000, + 0x48359806, 0x49786800, 0x58cc0004, 0x58cc1007, + 0x80000000, 0x82081400, 0x00000005, 0x48019804, + 0x48099807, 0x0401f7df, 0x80000580, 0x1c01f000, + 0x82000540, 0x00000001, 0x1c01f000, 0x480bc857, + 0x4c500000, 0x4c540000, 0x4c580000, 0x40083000, + 0x58cc0801, 0x82040480, 0x00000005, 0x02021800, + 0x001005d8, 0x82040400, 0x00106418, 0x50000000, + 0x58cca800, 0x8054ac00, 0x42001800, 0x00000005, + 0x40040000, 0x800c0480, 0x80082480, 0x04021002, + 0x40080000, 0x8000b0c2, 0x8058b400, 0x5450a800, + 0x8050a000, 0x8054a800, 0x8058b040, 0x040207fc, + 0x40001000, 0x58cc2805, 0x58cc0807, 0x58cc2001, + 0x80142c00, 0x80040c80, 0x80102400, 0x48159805, + 0x48059807, 0x48119801, 0x82100580, 0x00000005, + 0x0400000c, 0x48119801, 0x40080000, 0x80181480, + 0x40083000, 0x04000003, 0x040217d6, 0x80000580, + 0x5c00b000, 0x5c00a800, 0x5c00a000, 0x1c01f000, + 0x58cc0800, 0x800409c0, 0x02000800, 0x001005d8, + 0x58040800, 0x48059800, 0x41782000, 0x0401f7ee, + 0x0401f813, 0x50f00000, 0x81040400, 0x40001800, + 0x585c0204, 0x4803c857, 0x82000580, 0x0000002c, + 0x02020800, 0x001005d8, 0x58040202, 0x800000e0, + 0x81000540, 0x48001802, 0x58040000, 0x48001800, + 0x58040001, 0x48001801, 0x1c01f000, 0x4807c856, + 0x58cc0005, 0x80000040, 0x02001800, 0x001005d8, + 0x48019805, 0x58cc1003, 0x82080480, 0x00000005, + 0x02021800, 0x001005d8, 0x82080400, 0x00106418, + 0x50000000, 0x58cc0802, 0x80040c00, 0x80081000, + 0x82080480, 0x00000005, 0x0402000f, 0x58cc2002, + 0x58100000, 0x80006d40, 0x04000009, 0x4c340000, + 0x0401f858, 0x5c006800, 0x49786801, 0x48359802, + 0x58cc0004, 0x80000040, 0x48019804, 0x49799803, + 0x0401f002, 0x48099803, 0x1c01f000, 0x4807c856, + 0x41781800, 0x58c80201, 0x80000540, 0x04000002, + 0x800c1800, 0x58c80c01, 0x80040c80, 0x0400100a, + 0x04000009, 0x800c1800, 0x58c80202, 0x80041480, + 0x04001005, 0x04000004, 0x800c1800, 0x40080800, + 0x0401f7fb, 0x480d9204, 0x400c0000, 0x42002000, + 0x00000001, 0x80000040, 0x04000007, 0x04001006, + 0x80102000, 0x82000480, 0x00000005, 0x04000002, + 0x040217fc, 0x48119203, 0x1c01f000, 0x4807c856, + 0x4d2c0000, 0x58cc000a, 0x80000540, 0x02000800, + 0x001005d8, 0x82002400, 0x00000005, 0x0201f800, + 0x001007d3, 0x04000012, 0x492d9809, 0x497a5800, + 0x497a5801, 0x0201f800, 0x001007d3, 0x0400000c, + 0x58cc0009, 0x48025800, 0x497a5801, 0x492d9809, + 0x82102480, 0x00000005, 0x040217f7, 0x82000540, + 0x00000001, 0x5c025800, 0x1c01f000, 0x58cc0009, + 0x80025d40, 0x040007fc, 0x592c2000, 0x0201f800, + 0x001007f4, 0x40100000, 0x0401f7fa, 0x58cc0009, + 0x48cfc857, 0x80006d40, 0x04000005, 0x50340000, + 0x48019809, 0x49786800, 0x49786801, 0x1c01f000, + 0x4813c857, 0x58cc0009, 0x48002000, 0x48119809, + 0x1c01f000, 0x4807c856, 0x4d2c0000, 0x58cc0009, + 0x80025d40, 0x04000007, 0x592c0000, 0x4c000000, + 0x0201f800, 0x001007f4, 0x5c000000, 0x0401f7f9, + 0x5c025800, 0x1c01f000, 0x4807c856, 0x4d2c0000, + 0x58cc0002, 0x80025d40, 0x04000007, 0x592c0000, + 0x4c000000, 0x0201f800, 0x001007f4, 0x5c000000, + 0x0401f7f9, 0x49799800, 0x49799802, 0x49799801, + 0x49799803, 0x49799806, 0x49799807, 0x49799808, + 0x49799809, 0x4979980a, 0x5c025800, 0x1c01f000, + 0x00000003, 0x00000006, 0x00000009, 0x0000000c, + 0x0000000f, 0x00000012, 0x4803c856, 0x0401f857, + 0x4a00c204, 0x0000003c, 0x59301009, 0x82080580, + 0x0010b524, 0x04000013, 0x58080802, 0x82040d00, + 0x00ffffff, 0x58080403, 0x4804c005, 0x4800c406, + 0x4a00c207, 0x00000003, 0x59300811, 0x585c0404, + 0x4978c206, 0x4804c407, 0x80000540, 0x0400000d, + 0x58600206, 0x84000540, 0x4800c206, 0x0401f009, + 0x585c080a, 0x82040d00, 0x00ffffff, 0x4804c005, + 0x4a00c406, 0x000007ff, 0x4978c207, 0x0401f7ef, + 0x82603c00, 0x00000008, 0x58605404, 0x40282000, + 0x405c6000, 0x585c0a04, 0x82040d00, 0x0000000f, + 0x82040c00, 0x001010bd, 0x50044000, 0x80004d80, + 0x50200000, 0x80307400, 0x58380402, 0x8c244d00, + 0x04020003, 0x48003a00, 0x0401f003, 0x48003c00, + 0x801c3800, 0x80244800, 0x80102040, 0x04000006, + 0x0201f800, 0x0010109b, 0x02000800, 0x001005d8, + 0x0401f7f0, 0x1c01f000, 0x4803c856, 0x4d340000, + 0x59300009, 0x80026d40, 0x02000800, 0x001005d8, + 0x59340401, 0x80000540, 0x0400000e, 0x59840000, + 0x80000540, 0x0400000b, 0x836c0580, 0x00000003, + 0x04020008, 0x59341c03, 0x42002000, 0x00000004, + 0x42003000, 0x00000004, 0x0201f800, 0x00103aae, + 0x5c026800, 0x1c01f000, 0x4803c856, 0x80001580, + 0x58c80c01, 0x59300011, 0x80040c80, 0x48066011, + 0x58c80201, 0x80000540, 0x04000005, 0x80081000, + 0x80040c80, 0x04001007, 0x04000006, 0x58c80202, + 0x80081000, 0x80040c80, 0x04001002, 0x040207fd, + 0x4808bc08, 0x4808c404, 0x1c01f000, 0x4803c856, + 0x4a0370e5, 0x00020000, 0x59b800e5, 0x8c000524, + 0x040207fc, 0x4a0370e5, 0x00030000, 0x40000000, + 0x40000000, 0x59b800e5, 0x8c000524, 0x040207f5, + 0x5934000e, 0x80006d40, 0x04000010, 0x81300580, + 0x04020004, 0x58340000, 0x4802680e, 0x0401f00a, + 0x40347800, 0x58340000, 0x80006d40, 0x02000800, + 0x001005d8, 0x81300580, 0x040207fa, 0x58340000, + 0x48007800, 0x497a6000, 0x4a0370e5, 0x00020000, + 0x1c01f000, 0x4803c856, 0x4d300000, 0x4d2c0000, + 0x42000800, 0x000003ff, 0x4a0370e5, 0x00020000, + 0x59b800e5, 0x8c000524, 0x04000005, 0x80040840, + 0x040207fa, 0x0201f800, 0x001005d8, 0x4a0370e5, + 0x00030000, 0x40000000, 0x40000000, 0x59b800e5, + 0x8c000524, 0x040207f1, 0x5934000e, 0x80026540, + 0x0400000e, 0x4933c857, 0x59300000, 0x4802680e, + 0x4a026203, 0x00000004, 0x497a6206, 0x497a6009, + 0x4a026007, 0x00000101, 0x59325808, 0x497a5c08, + 0x0401fd81, 0x0401f7f1, 0x4a0370e5, 0x00020000, + 0x5c025800, 0x5c026000, 0x1c01f000, 0x4803c856, + 0x4c000000, 0x0201f800, 0x00105c9a, 0x04020011, + 0x0201f800, 0x001045a6, 0x02020800, 0x001005d8, + 0x5c000000, 0x48026802, 0x0201f800, 0x0002075a, + 0x04000009, 0x49366009, 0x4a026406, 0x00000001, + 0x42027000, 0x00000001, 0x0201f000, 0x000207a1, + 0x5c000000, 0x1c01f000, 0x59300203, 0x82000c80, + 0x0000000e, 0x02021800, 0x001005d8, 0x4803c857, + 0x0c01f001, 0x00106503, 0x00106503, 0x00106503, + 0x00106505, 0x00106565, 0x00106503, 0x00106503, + 0x001065b7, 0x001065b8, 0x00106503, 0x00106503, + 0x00106503, 0x00106503, 0x00106503, 0x0201f800, + 0x001005d8, 0x493bc857, 0x83380480, 0x00000050, + 0x02021800, 0x001005d8, 0x83380480, 0x00000049, + 0x02001800, 0x001005d8, 0x0c01f001, 0x00106518, + 0x0010653a, 0x00106516, 0x00106516, 0x00106516, + 0x00106516, 0x00106549, 0x0201f800, 0x001005d8, + 0x4d2c0000, 0x59325808, 0x592c0206, 0x48025c06, + 0x4a025a06, 0x00000000, 0x4c5c0000, 0x592cbc0a, + 0x592c0000, 0x48026008, 0x0201f800, 0x00104cde, + 0x59300008, 0x80000540, 0x04000008, 0x4a026203, + 0x00000007, 0x42027000, 0x00000043, 0x5c00b800, + 0x5c025800, 0x0401f08a, 0x8c5cbd08, 0x04020006, + 0x4a026203, 0x00000007, 0x497a6206, 0x497a6008, + 0x0401f003, 0x0201f800, 0x0002077d, 0x5c00b800, + 0x5c025800, 0x1c01f000, 0x0201f800, 0x00106b8a, + 0x4d2c0000, 0x59325808, 0x0201f800, 0x00109037, + 0x04000006, 0x4d400000, 0x42028000, 0x00000001, + 0x0401f8f8, 0x5c028000, 0x5c025800, 0x0201f000, + 0x0002077d, 0x0201f800, 0x00106b8a, 0x4d3c0000, + 0x417a7800, 0x0201f800, 0x0010203c, 0x5c027800, + 0x42003000, 0x00000014, 0x0201f800, 0x0010a942, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x4d2c0000, 0x59325808, 0x0201f800, 0x00109037, + 0x04000006, 0x4d400000, 0x42028000, 0x00000029, + 0x0401f8dc, 0x5c028000, 0x5c025800, 0x0201f000, + 0x0002077d, 0x493bc857, 0x497a6206, 0x83380480, + 0x00000054, 0x02021800, 0x001005d8, 0x83380480, + 0x00000047, 0x02001800, 0x001005d8, 0x0c01f001, + 0x001065b6, 0x0010657f, 0x0010657d, 0x0010657d, + 0x0010657d, 0x0010657d, 0x0010657d, 0x0010657d, + 0x0010657d, 0x0010657d, 0x0010657d, 0x0010657d, + 0x00106583, 0x0201f800, 0x001005d8, 0x59300011, + 0x82000500, 0xffff0000, 0x04020034, 0x59840802, + 0x8c040d04, 0x04000025, 0x59300009, 0x80026d40, + 0x0400001f, 0x4c5c0000, 0x4c600000, 0x497a6206, + 0x5930b808, 0x585c0005, 0x8000c540, 0x02000800, + 0x001005d8, 0x0401fe8d, 0x40625800, 0x0201f800, + 0x00104cde, 0x4978b805, 0x0401fef5, 0x497a6009, + 0x585c3408, 0x0401fcbd, 0x0400000e, 0x42001000, + 0x0010b519, 0x0401fcf2, 0x0400000a, 0x0201f800, + 0x001007e4, 0x04000007, 0x492cb805, 0x585c5408, + 0x0401fc83, 0x5c00c000, 0x5c00b800, 0x1c01f000, + 0x0401fca9, 0x0401f7fc, 0x8c040d06, 0x040207fc, + 0x59300009, 0x80026d40, 0x04000006, 0x5934000e, + 0x80000540, 0x02020800, 0x001005d8, 0x497a6009, + 0x0401fd0d, 0x0401f7f2, 0x0401f06f, 0x4803c856, + 0x4803c856, 0x83380580, 0x00000043, 0x02020800, + 0x001005d8, 0x4a026203, 0x00000003, 0x493a6403, + 0x59325808, 0x592c000f, 0x48026011, 0x497a6013, + 0x592c0406, 0x800000c2, 0x800010c4, 0x80081400, + 0x480a6206, 0x0201f800, 0x00100f4e, 0x42000800, + 0x80000060, 0x0401f154, 0x42000000, 0x0010b875, + 0x0201f800, 0x0010aa47, 0x59300203, 0x82000c80, + 0x0000000e, 0x02021800, 0x001005d8, 0x4803c857, + 0x82000d80, 0x00000003, 0x04000006, 0x82000d80, + 0x00000004, 0x04000045, 0x0201f800, 0x001005d8, + 0x0201f800, 0x00106c55, 0x59300004, 0x8c00053e, + 0x04020007, 0x0201f800, 0x00106b6c, 0x02020800, + 0x001005d8, 0x0201f000, 0x00106c4b, 0x0401f9c3, + 0x0201f800, 0x00106c4b, 0x59325808, 0x42028000, + 0x00000006, 0x0401f84b, 0x0201f000, 0x0002077d, + 0x4803c856, 0x59300203, 0x82000c80, 0x0000000e, + 0x02021800, 0x001005d8, 0x82000d80, 0x00000003, + 0x04000006, 0x82000d80, 0x00000004, 0x04000023, + 0x0201f800, 0x001005d8, 0x4803c856, 0x0201f800, + 0x00106c55, 0x4df00000, 0x59300004, 0x8c00053e, + 0x04020006, 0x0201f800, 0x00106f60, 0x02020800, + 0x001005d8, 0x0401f010, 0x0201f800, 0x00108cd6, + 0x04020004, 0x0201f800, 0x00106e62, 0x0402000a, + 0x0401f99a, 0x02020800, 0x001005d8, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x82000540, 0x00000001, + 0x1c01f000, 0x5c03e000, 0x02000800, 0x00106c4b, + 0x80000580, 0x1c01f000, 0x4933c857, 0x0201f800, + 0x00100e99, 0x4933c857, 0x4c5c0000, 0x4d340000, + 0x497a6206, 0x5930b808, 0x59300009, 0x80026d40, + 0x04020e5f, 0x42001000, 0x0010b519, 0x0401fc60, + 0x04000009, 0x58c80204, 0x4800bc08, 0x41785000, + 0x0201f800, 0x00106227, 0x5c026800, 0x5c00b800, + 0x1c01f000, 0x4978bc08, 0x0401fc17, 0x0401f7fb, + 0x4803c856, 0x0201f800, 0x00109037, 0x0400000f, + 0x592c0000, 0x80000d40, 0x04000009, 0x497a5800, + 0x49425a06, 0x4c040000, 0x0201f800, 0x000202da, + 0x5c000800, 0x40065800, 0x0401f7f6, 0x49425a06, + 0x0201f800, 0x000202da, 0x1c01f000, 0x4933c857, + 0x59300c06, 0x82040580, 0x0000000e, 0x04000004, + 0x82040580, 0x00000009, 0x04020004, 0x0401ffe5, + 0x497a6008, 0x80000580, 0x1c01f000, 0x592e6009, + 0x83300480, 0x0010d1c0, 0x04001016, 0x41580000, + 0x81300480, 0x04021013, 0x40040000, 0x59300c06, + 0x80040580, 0x04020012, 0x59300a03, 0x82040580, + 0x00000007, 0x02020800, 0x001005d8, 0x59300008, + 0x80000540, 0x02020800, 0x001005d8, 0x0201f800, + 0x0002077d, 0x42000000, 0x00000000, 0x0401f009, + 0x42000000, 0x00000008, 0x0401f006, 0x82040580, + 0x00000007, 0x040207fb, 0x42000000, 0x00000005, + 0x592c0a06, 0x48065c06, 0x48025a06, 0x0201f000, + 0x000202da, 0x4c0c0000, 0x4c100000, 0x4c140000, + 0x4c180000, 0x80001d80, 0x80002580, 0x42003000, + 0x00000020, 0x82040500, 0x00000001, 0x04000003, + 0x40080000, 0x800c1c00, 0x400c2800, 0x800c1902, + 0x80102102, 0x82140500, 0x00000001, 0x04000003, + 0x82102540, 0x80000000, 0x80040902, 0x80183040, + 0x040207f1, 0x40100800, 0x400c0000, 0x5c003000, + 0x5c002800, 0x5c002000, 0x5c001800, 0x1c01f000, + 0x4c580000, 0x4200b000, 0x00000020, 0x80000540, + 0x04000018, 0x80041c80, 0x04021016, 0x800810c2, + 0x80040982, 0x04001006, 0x80041c80, 0x04021005, + 0x8058b040, 0x040207fa, 0x0401f006, 0x80041c80, + 0x400c0800, 0x80081000, 0x8058b040, 0x040207f4, + 0x4c000000, 0x41f00000, 0x82000500, 0xf7ffffff, + 0x4003e000, 0x5c000000, 0x5c00b000, 0x1c01f000, + 0x4c000000, 0x41f00000, 0x82000540, 0x08000000, + 0x0401f7f8, 0x4a0378e8, 0x00000000, 0x4a03c821, + 0x00000010, 0x4a03c823, 0x00000004, 0x0401f82c, + 0x4a0378e9, 0x00003a0d, 0x4a0378e8, 0x00000001, + 0x42000000, 0x00001000, 0x50000000, 0x82000480, + 0x24220001, 0x04000004, 0x59e00002, 0x84000548, + 0x4803c002, 0x42000800, 0x00000005, 0x4203a000, + 0x00007600, 0x42000000, 0x00001000, 0x50000000, + 0x82000480, 0x24320001, 0x04021003, 0x4a03a005, + 0xd0000001, 0x59d00006, 0x4a03a005, 0x90000001, + 0x83d3a400, 0x00000020, 0x80040840, 0x040207fa, + 0x59e00003, 0x82000500, 0xffffffe0, 0x82000540, + 0x00008000, 0x4803c003, 0x59c40006, 0x82000500, + 0xfffcffff, 0x48038806, 0x1c01f000, 0x4d900000, + 0x4d180000, 0x4a0378e7, 0xaaaaaaaa, 0x4a0378e6, + 0xaaaaaaaa, 0x4a0378e5, 0xaaaaaaaa, 0x4a0378e4, + 0xaaaaaaaa, 0x42000800, 0x0000bf00, 0x4a00081a, + 0x0010b7d4, 0x4a00081b, 0x001010bd, 0x4a00081c, + 0x001010cd, 0x4a031800, 0x00000000, 0x4a031801, + 0x0010b544, 0x4a031802, 0x0010b54b, 0x42000800, + 0x0010b7d7, 0x417a3000, 0x811b20c8, 0x83932400, + 0x0000bf32, 0x48072000, 0x4a032001, 0x00000000, + 0x83180400, 0x001070ea, 0x50000000, 0x48032002, + 0x82040c00, 0x00000003, 0x811a3000, 0x83180480, + 0x00000005, 0x040017f1, 0x5c023000, 0x5c032000, + 0x1c01f000, 0x48066004, 0x497a6000, 0x497a6001, + 0x59bc00ea, 0x8c000516, 0x040207fe, 0x83300400, + 0xa0000000, 0x480378e1, 0x1c01f000, 0x4933c857, + 0x42000800, 0x80000040, 0x48066004, 0x497a6000, + 0x59bc00ea, 0x8c000516, 0x040207fe, 0x83300400, + 0x60000000, 0x480378e1, 0x1c01f000, 0x0201f800, + 0x00106c55, 0x4df00000, 0x4d300000, 0x4d340000, + 0x4d2c0000, 0x4d180000, 0x4c5c0000, 0x4c600000, + 0x4d900000, 0x4dd00000, 0x4da40000, 0x4d140000, + 0x42003000, 0x0000bf2e, 0x581a6001, 0x813261c0, + 0x0400002c, 0x41302800, 0x4178c000, 0x59300000, + 0x4c000000, 0x59326809, 0x5930b801, 0x59300406, + 0x82000d80, 0x00000006, 0x04020003, 0x8d3e7d18, + 0x04000010, 0x8d3e7d06, 0x04000007, 0x82000580, + 0x00000003, 0x04020004, 0x59340200, 0x8c00050e, + 0x04020008, 0x0401f92f, 0x4c0c0000, 0x4c140000, + 0x0401fb5f, 0x5c002800, 0x5c001800, 0x0401f005, + 0x41301800, 0x8060c1c0, 0x04020002, 0x400cc000, + 0x805cb9c0, 0x04000003, 0x405e6000, 0x0401f7e3, + 0x5c026000, 0x813261c0, 0x04000006, 0x8060c1c0, + 0x04000002, 0x40602800, 0x4178c000, 0x0401f7d8, + 0x417a3000, 0x0201f800, 0x001070d8, 0x59926004, + 0x813261c0, 0x04000023, 0x59326809, 0x4130c000, + 0x59300001, 0x8000bd40, 0x04000016, 0x40026000, + 0x40602800, 0x5930b801, 0x59300406, 0x82000d80, + 0x00000006, 0x0400000e, 0x8d3e7d06, 0x04000007, + 0x82000580, 0x00000003, 0x04020004, 0x59340200, + 0x8c00050e, 0x04020006, 0x0401f8dc, 0x4c140000, + 0x0401fb2f, 0x5c002800, 0x0401f002, 0x41302800, + 0x405e6000, 0x813261c0, 0x040207eb, 0x8060c1c0, + 0x04000004, 0x40626000, 0x4178c000, 0x0401f7e7, + 0x811a3000, 0x83180480, 0x00000005, 0x040017d6, + 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000, + 0x5c00c000, 0x5c00b800, 0x5c023000, 0x5c025800, + 0x5c026800, 0x5c026000, 0x5c03e000, 0x02000800, + 0x00106c4b, 0x1c01f000, 0x4933c857, 0x0201f800, + 0x00106c55, 0x4df00000, 0x4d340000, 0x4d180000, + 0x4d900000, 0x42003000, 0x0000bf2e, 0x59326809, + 0x58182001, 0x40102800, 0x801021c0, 0x04000016, + 0x41300000, 0x80100580, 0x04000011, 0x58100009, + 0x81340580, 0x0402000b, 0x40101800, 0x58102001, + 0x41300000, 0x801021c0, 0x0400000b, 0x80100d80, + 0x04000007, 0x40101800, 0x58102001, 0x0401f7fa, + 0x40102800, 0x58102000, 0x0401f7ec, 0x0401f8bd, + 0x0401f01a, 0x42032000, 0x0000bf32, 0x417a3000, + 0x59902004, 0x40102800, 0x801021c0, 0x0400000b, + 0x58100009, 0x81340580, 0x04020008, 0x41300000, + 0x80100580, 0x0400000c, 0x40102800, 0x58102001, + 0x801021c0, 0x040207fa, 0x811a3000, 0x83180480, + 0x00000005, 0x0402100d, 0x83932400, 0x00000010, + 0x0401f7ec, 0x0401f881, 0x5c032000, 0x5c023000, + 0x5c026800, 0x5c03e000, 0x02000800, 0x00106c4b, + 0x80000580, 0x1c01f000, 0x0401fb6f, 0x040007f7, + 0x5c032000, 0x5c023000, 0x5c026800, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x82000540, 0x00000001, + 0x1c01f000, 0x0201f800, 0x00106c55, 0x4df00000, + 0x4d300000, 0x4d340000, 0x4d180000, 0x4d2c0000, + 0x4c5c0000, 0x4c600000, 0x4d900000, 0x4dd00000, + 0x4da40000, 0x4d140000, 0x42003000, 0x0000bf2e, + 0x581a6001, 0x813261c0, 0x04000023, 0x41302800, + 0x5930b800, 0x59326809, 0x59340403, 0x81440580, + 0x04000006, 0x805cb9c0, 0x0400001b, 0x41302800, + 0x405e6000, 0x0401f7f7, 0x5930b801, 0x8d3e7d00, + 0x04000003, 0x0401fb67, 0x0402000e, 0x59300406, + 0x82000580, 0x00000006, 0x04020003, 0x8d3e7d18, + 0x04000008, 0x0401f867, 0x4c0c0000, 0x4c140000, + 0x0401fa97, 0x5c002800, 0x5c001800, 0x0401f002, + 0x41301800, 0x405e6000, 0x813261c0, 0x040207eb, + 0x0401f02d, 0x417a3000, 0x0201f800, 0x001070d8, + 0x59926004, 0x813261c0, 0x04000005, 0x59326809, + 0x59340403, 0x81440580, 0x04000006, 0x811a3000, + 0x83180480, 0x00000005, 0x040017f4, 0x0401f01e, + 0x4130c000, 0x59300001, 0x8000bd40, 0x04000012, + 0x40026000, 0x40602800, 0x5930b801, 0x8d3e7d00, + 0x04000003, 0x0401fb3b, 0x0402000a, 0x59300406, + 0x82000580, 0x00000006, 0x04000006, 0x0401f81b, + 0x4c140000, 0x0401fa6e, 0x5c002800, 0x0401f002, + 0x41302800, 0x405e6000, 0x813261c0, 0x040207ef, + 0x8060c1c0, 0x04000004, 0x40626000, 0x4178c000, + 0x0401f7eb, 0x5c022800, 0x5c034800, 0x5c03a000, + 0x5c032000, 0x5c00c000, 0x5c00b800, 0x5c025800, + 0x5c023000, 0x5c026800, 0x5c026000, 0x5c03e000, + 0x04000be3, 0x1c01f000, 0x0401fbc8, 0x59900004, + 0x81300580, 0x04020018, 0x4c140000, 0x0201f800, + 0x00106dc3, 0x0401fbb8, 0x5c002800, 0x59300001, + 0x800001c0, 0x04020003, 0x497a680c, 0x1c01f000, + 0x42003000, 0x0000bf2e, 0x497a6001, 0x58180801, + 0x800409c0, 0x04020004, 0x48003000, 0x48003001, + 0x1c01f000, 0x58180800, 0x48000800, 0x48003000, + 0x1c01f000, 0x59300001, 0x48002801, 0x800001c0, + 0x04020002, 0x4816680c, 0x497a6001, 0x1c01f000, + 0x0401fba6, 0x42003000, 0x0000bf2e, 0x58180001, + 0x81300580, 0x0402001c, 0x59300801, 0x800409c0, + 0x0400000e, 0x59300000, 0x800001c0, 0x04020005, + 0x48043001, 0x48043000, 0x497a6001, 0x1c01f000, + 0x59300000, 0x48000800, 0x48043001, 0x497a6000, + 0x497a6001, 0x1c01f000, 0x59300800, 0x800409c0, + 0x04020005, 0x49783001, 0x49783000, 0x497a680c, + 0x1c01f000, 0x48043001, 0x497a6000, 0x497a680c, + 0x1c01f000, 0x58180000, 0x81300580, 0x0402000c, + 0x59300001, 0x800001c0, 0x04020005, 0x48143000, + 0x49782800, 0x497a680c, 0x1c01f000, 0x48003000, + 0x48002800, 0x497a6001, 0x1c01f000, 0x59300000, + 0x800001c0, 0x04020008, 0x59300001, 0x48001801, + 0x800001c0, 0x04020002, 0x480e680c, 0x497a6001, + 0x1c01f000, 0x59300801, 0x800409c0, 0x04020006, + 0x59300800, 0x48042800, 0x497a6000, 0x497a680c, + 0x1c01f000, 0x59300000, 0x48000800, 0x48042800, + 0x497a6000, 0x497a6001, 0x1c01f000, 0x0401fb82, + 0x4df00000, 0x0401f839, 0x040208c4, 0x04020945, + 0x04020a89, 0x04020005, 0x5c03e000, 0x04000b70, + 0x80000580, 0x1c01f000, 0x5c03e000, 0x04000b6c, + 0x82000540, 0x00000001, 0x1c01f000, 0x4d2c0000, + 0x4d340000, 0x4d300000, 0x41783000, 0x598e6009, + 0x813261c0, 0x04000021, 0x59300406, 0x82000580, + 0x00000006, 0x04020004, 0x8d3e7d18, 0x0402000a, + 0x0401f017, 0x82040580, 0x00000005, 0x04020006, + 0x8d3e7d16, 0x04000004, 0x59300420, 0x8c000500, + 0x0402000f, 0x0401fa4e, 0x59300000, 0x4c000000, + 0x8d3e7d06, 0x04000004, 0x0201f800, 0x001092d7, + 0x04000005, 0x0401f867, 0x4c180000, 0x0401f9bc, + 0x5c003000, 0x5c026000, 0x0401f7e2, 0x41303000, + 0x59326000, 0x0401f7df, 0x5c026000, 0x5c026800, + 0x5c025800, 0x1c01f000, 0x4933c857, 0x4c5c0000, + 0x813261c0, 0x02000800, 0x001005d8, 0x41300000, + 0x598cb809, 0x41783000, 0x805cb9c0, 0x04000013, + 0x805c0d80, 0x04000004, 0x405c3000, 0x5818b800, + 0x0401f7fa, 0x0401f84b, 0x598c000d, 0x81300580, + 0x02000800, 0x001070b9, 0x59300403, 0x82000580, + 0x00000042, 0x04020002, 0x497a6007, 0x80000580, + 0x5c00b800, 0x1c01f000, 0x82000540, 0x00000001, + 0x5c00b800, 0x1c01f000, 0x0401fb27, 0x4df00000, + 0x4d2c0000, 0x4d340000, 0x4d300000, 0x41783000, + 0x598e6009, 0x813261c0, 0x0400002c, 0x59300c06, + 0x82040580, 0x00000006, 0x04020004, 0x8d3e7d18, + 0x0402000a, 0x0401f022, 0x82040580, 0x00000005, + 0x04020006, 0x8d3e7d18, 0x04000004, 0x59300420, + 0x8c000500, 0x0402001a, 0x59326809, 0x59340403, + 0x81440580, 0x04020016, 0x8d3e7d00, 0x04000006, + 0x82040580, 0x00000003, 0x04020011, 0x0401fa35, + 0x0402000f, 0x0401f9f6, 0x59300000, 0x4c000000, + 0x8d3e7d06, 0x04000004, 0x0201f800, 0x001092d7, + 0x04000005, 0x0401f80f, 0x4c180000, 0x0401f964, + 0x5c003000, 0x5c026000, 0x0401f7d7, 0x41303000, + 0x59326000, 0x0401f7d4, 0x5c026000, 0x5c026800, + 0x5c025800, 0x5c03e000, 0x04000ae5, 0x1c01f000, + 0x59300800, 0x497a6000, 0x0401fac8, 0x801831c0, + 0x04020009, 0x598c0008, 0x81300580, 0x04020004, + 0x48031808, 0x48031809, 0x0401f008, 0x48071809, + 0x0401f006, 0x48043000, 0x598c0008, 0x81300580, + 0x04020002, 0x481b1808, 0x0401f2ca, 0x4d2c0000, + 0x4d300000, 0x4d340000, 0x41783000, 0x598e600b, + 0x813261c0, 0x04000013, 0x8d3e7d06, 0x04000005, + 0x59326809, 0x59340200, 0x8c00050e, 0x0402000a, + 0x0401f9bf, 0x59300000, 0x4c000000, 0x0401f853, + 0x4c180000, 0x0401f932, 0x5c003000, 0x5c026000, + 0x0401f7f0, 0x41303000, 0x59326000, 0x0401f7ed, + 0x0201f800, 0x00104773, 0x5c026800, 0x5c026000, + 0x5c025800, 0x1c01f000, 0x4933c857, 0x4c5c0000, + 0x813261c0, 0x02000800, 0x001005d8, 0x41300000, + 0x598cb80b, 0x41783000, 0x805cb9c0, 0x0400000f, + 0x805c0d80, 0x04000004, 0x405c3000, 0x5818b800, + 0x0401f7fa, 0x0401f835, 0x598c000d, 0x81300580, + 0x02000800, 0x001070b9, 0x497a6007, 0x80000580, + 0x5c00b800, 0x1c01f000, 0x82000540, 0x00000001, + 0x5c00b800, 0x1c01f000, 0x0401fa9f, 0x4df00000, + 0x4d340000, 0x4d300000, 0x4d2c0000, 0x0201f800, + 0x00020245, 0x02020800, 0x001005d8, 0x41783000, + 0x598e600b, 0x813261c0, 0x04000014, 0x59300009, + 0x81340580, 0x0402000e, 0x8d3e7d00, 0x04000003, + 0x0401f9bc, 0x0402000a, 0x0401f97d, 0x59300000, + 0x4c000000, 0x0401f811, 0x4c180000, 0x0401f8f0, + 0x5c003000, 0x5c026000, 0x0401f7ef, 0x41303000, + 0x59326000, 0x0401f7ec, 0x0201f800, 0x0010479c, + 0x5c025800, 0x5c026000, 0x5c026800, 0x5c03e000, + 0x04000a6f, 0x1c01f000, 0x59300800, 0x497a6000, + 0x0401fa52, 0x801831c0, 0x04020009, 0x598c000a, + 0x81300580, 0x04020004, 0x4803180a, 0x4803180b, + 0x0401f008, 0x4807180b, 0x0401f006, 0x48043000, + 0x598c000a, 0x81300580, 0x04020002, 0x481b180a, + 0x0401f254, 0x0401fa64, 0x4df00000, 0x4d300000, + 0x598e6005, 0x813261c0, 0x04000020, 0x59300000, + 0x4c000000, 0x59300c06, 0x82040580, 0x00000011, + 0x04020007, 0x833c0500, 0x00001800, 0x04000015, + 0x8d3e7d16, 0x04020013, 0x0401f009, 0x82040580, + 0x00000004, 0x04020006, 0x8d3e7d16, 0x04000004, + 0x59300420, 0x8c000500, 0x0402000a, 0x0201f800, + 0x0010914e, 0x02000800, 0x0010801c, 0x0201f800, + 0x00109326, 0x0201f800, 0x0002077d, 0x0401fa31, + 0x5c026000, 0x0401f7e0, 0x497b1805, 0x497b1804, + 0x5c026000, 0x5c03e000, 0x04000a31, 0x1c01f000, + 0x4933c857, 0x4c5c0000, 0x4c600000, 0x813261c0, + 0x02000800, 0x001005d8, 0x41300000, 0x598cb805, + 0x405cc000, 0x805cb9c0, 0x04000025, 0x805c0d80, + 0x04000004, 0x405cc000, 0x5860b800, 0x0401f7fa, + 0x598c000d, 0x81300580, 0x02000800, 0x001070b9, + 0x0401fa02, 0x598c0005, 0x805c0580, 0x04020009, + 0x585c0000, 0x48031805, 0x4978b800, 0x598c0004, + 0x805c0580, 0x0402000d, 0x497b1804, 0x0401f00b, + 0x598c0004, 0x805c0580, 0x04020005, 0x48631804, + 0x4978b800, 0x4978c000, 0x0401f004, 0x585c0000, + 0x4800c000, 0x4978b800, 0x0401f9fe, 0x80000580, + 0x5c00c000, 0x5c00b800, 0x1c01f000, 0x82000540, + 0x00000001, 0x5c00c000, 0x5c00b800, 0x1c01f000, + 0x4933c857, 0x0401fa04, 0x4df00000, 0x4d2c0000, + 0x4d340000, 0x4d300000, 0x4c5c0000, 0x4178b800, + 0x8d3e7d18, 0x0400000d, 0x8d3e7d16, 0x0402000b, + 0x0201f800, 0x00109037, 0x04000008, 0x0201f800, + 0x00109597, 0x04020005, 0x592c0207, 0x492fc857, + 0x8200bd00, 0x0000000f, 0x41783000, 0x598e6005, + 0x813261c0, 0x04000029, 0x59326809, 0x813669c0, + 0x04000023, 0x59340403, 0x81440580, 0x04020020, + 0x59300c06, 0x82040580, 0x00000011, 0x0400001a, + 0x82040580, 0x00000004, 0x04020004, 0x59300420, + 0x8c000500, 0x04020016, 0x0201f800, 0x00109037, + 0x04000008, 0x0201f800, 0x00109597, 0x04020005, + 0x59300403, 0x82000580, 0x00000043, 0x0400000c, + 0x0401f8c3, 0x59300000, 0x4c000000, 0x0401f812, + 0x4c180000, 0x0401f836, 0x5c003000, 0x5c026000, + 0x0401f7dc, 0x805cb9c0, 0x040207ec, 0x41303000, + 0x59326000, 0x0401f7d7, 0x5c00b800, 0x5c026000, + 0x5c026800, 0x5c025800, 0x5c03e000, 0x040009b4, + 0x1c01f000, 0x59300800, 0x497a6000, 0x0401f997, + 0x801831c0, 0x04020009, 0x598c0004, 0x81300580, + 0x04020004, 0x48031804, 0x48031805, 0x0401f008, + 0x48071805, 0x0401f006, 0x48043000, 0x598c0004, + 0x81300580, 0x04020002, 0x481b1804, 0x0401f199, + 0x4943c857, 0x0401f9a8, 0x4df00000, 0x0401fe34, + 0x0401fecb, 0x5c03e000, 0x04000999, 0x1c01f000, + 0x4947c857, 0x0401f9a0, 0x4df00000, 0x4d3c0000, + 0x853e7d00, 0x0401fe75, 0x0401fefc, 0x5c027800, + 0x5c03e000, 0x0400098e, 0x1c01f000, 0x5c000000, + 0x4c000000, 0x4803c857, 0x4d340000, 0x4d2c0000, + 0x59326809, 0x59325808, 0x59300406, 0x82000c80, + 0x00000012, 0x02021800, 0x001005d8, 0x4933c857, + 0x4943c857, 0x493fc857, 0x4803c857, 0x0c01f804, + 0x5c025800, 0x5c026800, 0x1c01f000, 0x00106ae5, + 0x00106ae7, 0x00106af1, 0x00106b0b, 0x00106ae7, + 0x00106afb, 0x00106b23, 0x00106ae5, 0x00106ae5, + 0x00106b36, 0x00106b2d, 0x00106ae5, 0x00106ae5, + 0x00106ae5, 0x00106ae5, 0x00106ae5, 0x00106b3c, + 0x00106b3c, 0x0201f800, 0x001005d8, 0x0201f800, + 0x00109134, 0x02000800, 0x00102074, 0x0201f800, + 0x00109326, 0x0201f800, 0x0010801c, 0x0201f000, + 0x00107911, 0x812e59c0, 0x02020800, 0x001005d8, + 0x5930021d, 0x82000580, 0x00000003, 0x02000800, + 0x0010912a, 0x0201f000, 0x00107911, 0x0201f800, + 0x00109037, 0x02000000, 0x00107911, 0x592c1204, + 0x82081500, 0x000000ff, 0x82080580, 0x00000055, + 0x02020800, 0x001005d8, 0x49425a06, 0x0201f800, + 0x000202da, 0x0201f000, 0x00107911, 0x59300004, + 0x8400055c, 0x48026004, 0x59300007, 0x8c000500, + 0x02020800, 0x00100e99, 0x0201f800, 0x00109037, + 0x0400000d, 0x4a025a04, 0x00000103, 0x49425a06, + 0x497a5c09, 0x0201f800, 0x001091c6, 0x0201f800, + 0x0010a693, 0x0201f800, 0x000202da, 0x0201f800, + 0x0010912a, 0x0201f000, 0x00107911, 0x59300007, + 0x8c000500, 0x02020800, 0x00100e99, 0x0201f800, + 0x00109037, 0x02020800, 0x0010a3ef, 0x0201f000, + 0x00107911, 0x0201f800, 0x00109037, 0x04000005, + 0x49425a06, 0x497a5c09, 0x0201f800, 0x000202da, + 0x0201f000, 0x00107911, 0x0201f800, 0x00109037, + 0x02020800, 0x0010664f, 0x0201f000, 0x00107911, + 0x0201f800, 0x00109037, 0x04000004, 0x49425a06, + 0x0201f800, 0x000202da, 0x59325817, 0x0201f800, + 0x001007fd, 0x0201f000, 0x00107911, 0x598c000d, + 0x81300580, 0x04000003, 0x497a6007, 0x1c01f000, + 0x59c40004, 0x82000500, 0x0000000c, 0x04000005, + 0x4a038804, 0x0000000c, 0x497b2807, 0x0401f00a, + 0x0401facd, 0x59300403, 0x82000d80, 0x00000040, + 0x04000004, 0x82000580, 0x00000042, 0x04020002, + 0x497a6007, 0x0201f800, 0x001070b9, 0x80000580, + 0x1c01f000, 0x59300804, 0x8c040d3e, 0x04020004, + 0x82000540, 0x00000001, 0x0401f005, 0x4933c857, + 0x84040d3e, 0x48066004, 0x80000580, 0x1c01f000, + 0x59300804, 0x8c040d20, 0x04020004, 0x82000540, + 0x00000001, 0x1c01f000, 0x4933c857, 0x4d380000, + 0x59300804, 0x84040d20, 0x48066004, 0x42027000, + 0x00000049, 0x59300203, 0x82000580, 0x00000003, + 0x04000003, 0x42027000, 0x00000013, 0x0201f800, + 0x000207a1, 0x80000580, 0x5c027000, 0x1c01f000, + 0x59300017, 0x81480580, 0x04020003, 0x59300018, + 0x814c0580, 0x1c01f000, 0x4d2c0000, 0x4d300000, + 0x0401f8c9, 0x4df00000, 0x0201f800, 0x00106062, + 0x59900001, 0x82000500, 0x00000003, 0x0c01f001, + 0x00106bba, 0x00106b9a, 0x00106b98, 0x00106b98, + 0x0201f800, 0x001005d8, 0x59926004, 0x0401f88e, + 0x813261c0, 0x0400001d, 0x59300004, 0x8c000516, + 0x04000004, 0x59325808, 0x497a5808, 0x497a5809, + 0x0401f88e, 0x59300001, 0x800001c0, 0x0400000e, + 0x497a6001, 0x42003000, 0x0000bf2e, 0x58180801, + 0x800409c0, 0x04020004, 0x48003001, 0x48003000, + 0x0401f00a, 0x58180800, 0x48000800, 0x48003000, + 0x0401f006, 0x59300809, 0x800409c0, 0x02000800, + 0x001005d8, 0x4978080c, 0x5c03e000, 0x04000890, + 0x5c026000, 0x5c025800, 0x1c01f000, 0x4d300000, + 0x497b2807, 0x0401f894, 0x4df00000, 0x598c0000, + 0x82000500, 0x00000007, 0x4803c857, 0x0c01f001, + 0x00106bef, 0x00106bd2, 0x00106bdb, 0x00106bdf, + 0x00106bea, 0x00106bef, 0x00106bd0, 0x00106bd0, + 0x0201f800, 0x001005d8, 0x598c000d, 0x80026540, + 0x04000004, 0x0401f81e, 0x02020800, 0x001005d8, + 0x0201f800, 0x001070b9, 0x0401f015, 0x0401f827, + 0x0201f800, 0x001070b9, 0x0401f011, 0x598c000d, + 0x80026540, 0x0400000e, 0x0401f838, 0x04000004, + 0x0401f80f, 0x04000002, 0x0401f81c, 0x0201f800, + 0x001070b9, 0x0401f006, 0x0401f830, 0x02020800, + 0x001005d8, 0x0201f800, 0x001070b9, 0x5c03e000, + 0x0400085b, 0x5c026000, 0x1c01f000, 0x598c0009, + 0x81300580, 0x0402000c, 0x0401f84e, 0x0401f83b, + 0x59300000, 0x800001c0, 0x04000004, 0x48031809, + 0x497a6000, 0x0401f003, 0x497b1809, 0x497b1808, + 0x80000580, 0x1c01f000, 0x4d2c0000, 0x59300406, + 0x82000580, 0x00000003, 0x04020012, 0x598c000b, + 0x81300580, 0x0402000f, 0x0401f83a, 0x59325808, + 0x497a5808, 0x497a5809, 0x0401f824, 0x59300000, + 0x800001c0, 0x04000004, 0x4803180b, 0x497a6000, + 0x0401f003, 0x497b180a, 0x497b180b, 0x80000580, + 0x5c025800, 0x1c01f000, 0x598c0005, 0x81300580, + 0x0402000c, 0x0401f827, 0x0401f814, 0x59300000, + 0x800001c0, 0x04000004, 0x48031805, 0x497a6000, + 0x0401f003, 0x497b1805, 0x497b1804, 0x80000580, + 0x1c01f000, 0x4a032001, 0x00000000, 0x497b2004, + 0x497b2005, 0x59900006, 0x82000500, 0x0000ffff, + 0x48032006, 0x1c01f000, 0x4c040000, 0x59300004, + 0x82000500, 0x7ffeffff, 0x48026004, 0x59bc00e4, + 0x8c000514, 0x04000009, 0x42000800, 0x0000bf00, + 0x58040012, 0x81300580, 0x04020004, 0x49780812, + 0x4a0378e4, 0x00000800, 0x5c000800, 0x1c01f000, + 0x4803c856, 0x598c000c, 0x80000540, 0x04000003, + 0x80000040, 0x4803180c, 0x1c01f000, 0x59bc00ea, + 0x82000500, 0x00000007, 0x82000580, 0x00000003, + 0x04020004, 0x4803c856, 0x4a0378e8, 0x00000001, + 0x1c01f000, 0x59bc00ea, 0x82000500, 0x00000007, + 0x82000580, 0x00000001, 0x04020011, 0x4803c856, + 0x42000800, 0x00000000, 0x0401f80e, 0x42000800, + 0x00001000, 0x59bc00ea, 0x82000500, 0x00000007, + 0x82000580, 0x00000003, 0x04000005, 0x80040840, + 0x040207f9, 0x0201f800, 0x001005d8, 0x1c01f000, + 0x59bc00ea, 0x82000500, 0x00000007, 0x82000580, + 0x00000001, 0x02020800, 0x001005d8, 0x59bc00ea, + 0x8c000516, 0x040207fe, 0x480778e1, 0x1c01f000, + 0x59bc00ea, 0x8c000516, 0x040207fe, 0x480778e1, + 0x59bc00ea, 0x8c000516, 0x040207fe, 0x480b78e1, + 0x1c01f000, 0x82000d00, 0x80000018, 0x02020800, + 0x001005d0, 0x0201f800, 0x001005d8, 0x00106c97, + 0x00106d3b, 0x00106d55, 0x00106c97, 0x00106c99, + 0x00106cba, 0x00106cd9, 0x00106d0d, 0x00106c97, + 0x00106d39, 0x00106c97, 0x00106c97, 0x00106c97, + 0x00106c97, 0x00106c97, 0x00106c97, 0x0201f800, + 0x001005d8, 0x4d300000, 0x4d900000, 0x4dd00000, + 0x4da40000, 0x4d140000, 0x0201f800, 0x001070d8, + 0x59bc00ea, 0x8c000510, 0x040007fe, 0x59be60e0, + 0x59300004, 0x8c000520, 0x04000011, 0x82000500, + 0xfffefeff, 0x48026004, 0x4a026203, 0x00000003, + 0x0401ffa9, 0x0201f800, 0x00100fd0, 0x5c022800, + 0x5c034800, 0x5c03a000, 0x5c032000, 0x5c026000, + 0x4a0378e4, 0x00000008, 0x0401f795, 0x84000510, + 0x48026004, 0x0401f7f6, 0x4d300000, 0x4d900000, + 0x4dd00000, 0x4da40000, 0x4d140000, 0x0201f800, + 0x001070d8, 0x59bc00ea, 0x8c000510, 0x040007fe, + 0x59be60e0, 0x59300004, 0x8c000520, 0x0400000f, + 0x82000500, 0xfffefeff, 0x48026004, 0x0401ff8a, + 0x0201f800, 0x0010100e, 0x5c022800, 0x5c034800, + 0x5c03a000, 0x5c032000, 0x5c026000, 0x4a0378e4, + 0x00000008, 0x0401f776, 0x84000510, 0x48026004, + 0x0401f7f6, 0x4d300000, 0x4d2c0000, 0x4d340000, + 0x4da40000, 0x4cd00000, 0x59bc00ea, 0x8c000510, + 0x040007fe, 0x59be60e0, 0x813261c0, 0x02000800, + 0x001005d8, 0x59300004, 0x8c000520, 0x0400001d, + 0x82000500, 0xfffefeff, 0x48026004, 0x59326809, + 0x42034800, 0x0010b544, 0x04011000, 0x4a03c840, + 0x0010b54b, 0x4a03c842, 0x00000012, 0x04011000, + 0x4a03c840, 0x0010b55d, 0x4a03c842, 0x000000ff, + 0x04011000, 0x4a03c840, 0x0010b65c, 0x4a03c842, + 0x000000ff, 0x0401fbf2, 0x5c01a000, 0x5c034800, + 0x5c026800, 0x5c025800, 0x5c026000, 0x1c01f000, + 0x84000510, 0x48026004, 0x5c01a000, 0x5c034800, + 0x5c026800, 0x5c025800, 0x5c026000, 0x1c01f000, + 0x1c01f000, 0x4d300000, 0x4d2c0000, 0x4d340000, + 0x4cd00000, 0x4d900000, 0x4dd00000, 0x4da40000, + 0x4d140000, 0x0401fbc3, 0x59bc00ea, 0x8c000510, + 0x040007fe, 0x59be60e0, 0x813261c0, 0x02000800, + 0x001005d8, 0x59300004, 0x8c000520, 0x0400000f, + 0x82000500, 0xfffefeff, 0x48026004, 0x0201f800, + 0x0010783a, 0x5c022800, 0x5c034800, 0x5c03a000, + 0x5c032000, 0x5c01a000, 0x5c026800, 0x5c025800, + 0x5c026000, 0x1c01f000, 0x84000510, 0x48026004, + 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000, + 0x5c01a000, 0x5c026800, 0x5c025800, 0x5c026000, + 0x1c01f000, 0x0201f800, 0x001005d8, 0x4d300000, + 0x4d380000, 0x42000000, 0x0010b8c4, 0x0201f800, + 0x0010aa47, 0x0401ff14, 0x598e600d, 0x59c40004, + 0x8c000506, 0x04000004, 0x0401f8db, 0x4a038804, + 0x00000008, 0x813261c0, 0x04000006, 0x0401fb87, + 0x42027000, 0x00000014, 0x0201f800, 0x000207a1, + 0x4a0378e4, 0x00000002, 0x5c027000, 0x5c026000, + 0x0401f6f7, 0x4d180000, 0x4d300000, 0x4d380000, + 0x4d900000, 0x4dd00000, 0x4da40000, 0x4d140000, + 0x0401fef9, 0x417a3000, 0x59c40804, 0x83180400, + 0x0010709f, 0x50000000, 0x80040500, 0x0400001b, + 0x42000000, 0x0010b8c5, 0x0201f800, 0x0010aa47, + 0x0401fb70, 0x59926004, 0x0401f859, 0x83180400, + 0x0010709f, 0x50000000, 0x48038804, 0x813261c0, + 0x0400000a, 0x59300004, 0x8c00050c, 0x04020003, + 0x4a026203, 0x00000003, 0x42027000, 0x0000004a, + 0x0201f800, 0x000207a1, 0x59c40004, 0x82000500, + 0x00f80000, 0x04000005, 0x811a3000, 0x83180480, + 0x00000005, 0x040017dd, 0x4a0378e4, 0x00000008, + 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000, + 0x5c027000, 0x5c026000, 0x5c023000, 0x0401f6c0, + 0x4d2c0000, 0x4d340000, 0x59326809, 0x598c0800, + 0x82040580, 0x00000004, 0x04020004, 0x838c1400, + 0x00000005, 0x0401f00c, 0x82040580, 0x00000001, + 0x04020004, 0x838c1400, 0x00000009, 0x0401f006, + 0x82040580, 0x00000002, 0x04020022, 0x838c1400, + 0x0000000b, 0x41306800, 0x58340000, 0x80007d40, + 0x0400001c, 0x583c0009, 0x81340580, 0x04020006, + 0x403c6800, 0x583c0000, 0x80007d40, 0x040207fa, + 0x0401f014, 0x4933c857, 0x483fc857, 0x583c0000, + 0x48006800, 0x49307800, 0x443c1000, 0x80000580, + 0x4803180d, 0x4803180f, 0x598c0000, 0x82000580, + 0x00000003, 0x04000003, 0x4a031800, 0x00000000, + 0x80000580, 0x5c026800, 0x5c025800, 0x1c01f000, + 0x82000540, 0x00000001, 0x0401f7fb, 0x491bc857, + 0x59c80840, 0x82040540, 0x00000010, 0x48039040, + 0x59c41008, 0x82080500, 0xffffff7f, 0x48038808, + 0x4c040000, 0x4c080000, 0x0401fabb, 0x04020007, + 0x0401fabf, 0x04000022, 0x48038804, 0x0201f800, + 0x0010107a, 0x0401f042, 0x4a038803, 0x00000008, + 0x59c40003, 0x82000500, 0x00000003, 0x040007fd, + 0x8c000502, 0x04020007, 0x0401fab1, 0x04000014, + 0x48038804, 0x0201f800, 0x0010107a, 0x0401f034, + 0x59c80040, 0x8400056a, 0x48039040, 0x59c80040, + 0x8c00052a, 0x040207fe, 0x59c40005, 0x82000500, + 0xc0000000, 0x04000006, 0x59c400a3, 0x84000540, + 0x480388a3, 0x4a038805, 0xc0000000, 0x0201f800, + 0x0010101d, 0x4a03a005, 0x30000000, 0x59d00006, + 0x4a03a005, 0x30000000, 0x59900006, 0x82000500, + 0xffff0000, 0x48032006, 0x59d00005, 0x8c000504, + 0x040207fe, 0x42000800, 0x00007600, 0x83180540, + 0x60000000, 0x480008a1, 0x811800dc, 0x59c80840, + 0x80040540, 0x48039040, 0x82000540, 0x00003000, + 0x48039040, 0x59c80040, 0x82000500, 0x00003000, + 0x040207fd, 0x0201f800, 0x00101068, 0x83180400, + 0x0010709f, 0x50000000, 0x48038804, 0x80000580, + 0x4df00000, 0x0201f800, 0x00106062, 0x5c03e000, + 0x5c001000, 0x5c000800, 0x480b8808, 0x48079040, + 0x1c01f000, 0x4803c856, 0x59c80840, 0x82040540, + 0x00000010, 0x48039040, 0x59c41008, 0x82080500, + 0xffffff7f, 0x48038808, 0x4c040000, 0x4c080000, + 0x59c40004, 0x82000500, 0x00000003, 0x04020010, + 0x59c40004, 0x82000500, 0x0000000c, 0x04000005, + 0x4a038804, 0x0000000c, 0x8c000504, 0x0401f025, + 0x59c80040, 0x8400056e, 0x48039040, 0x59c80040, + 0x8c00052e, 0x040207fe, 0x0401f01e, 0x4a038803, + 0x00000008, 0x59c40003, 0x82000500, 0x00000003, + 0x040007fd, 0x8c000502, 0x04020006, 0x59c40004, + 0x4a038804, 0x0000000c, 0x8c000504, 0x0401f011, + 0x59c80040, 0x8400056a, 0x48039040, 0x59c80040, + 0x8c00052a, 0x040207fe, 0x59c40005, 0x82000500, + 0xc0000000, 0x04000007, 0x59c400a3, 0x84000540, + 0x480388a3, 0x4a038805, 0xc0000000, 0x80000580, + 0x497b2807, 0x5c001000, 0x5c000800, 0x480b8808, + 0x48079040, 0x1c01f000, 0x4933c857, 0x4d900000, + 0x4dd00000, 0x4da40000, 0x4d140000, 0x0401fdee, + 0x4df00000, 0x0401fa6f, 0x59900004, 0x800001c0, + 0x04000011, 0x81300580, 0x0402000f, 0x59300004, + 0x84000520, 0x48026004, 0x0401ff51, 0x04020009, + 0x5c03e000, 0x04000dd6, 0x80000580, 0x5c022800, + 0x5c034800, 0x5c03a000, 0x5c032000, 0x1c01f000, + 0x0401fd0e, 0x42027000, 0x00000049, 0x59300004, + 0x84000520, 0x48026004, 0x8c00050c, 0x02020800, + 0x000207a1, 0x5c03e000, 0x04000dc5, 0x82000540, + 0x00000001, 0x5c022800, 0x5c034800, 0x5c03a000, + 0x5c032000, 0x1c01f000, 0x4933c857, 0x0401fdc6, + 0x4df00000, 0x598c000d, 0x80026540, 0x04000012, + 0x59300004, 0x84000520, 0x48026004, 0x0401ff8a, + 0x04000017, 0x0401fd26, 0x42027000, 0x00000013, + 0x59300004, 0x8c00050c, 0x02020800, 0x000207a1, + 0x5c03e000, 0x04000daa, 0x82000540, 0x00000001, + 0x1c01f000, 0x836c1580, 0x00000001, 0x040007f9, + 0x836c1580, 0x00000004, 0x040007f6, 0x42001000, + 0x00104148, 0x0201f800, 0x00105f90, 0x5c03e000, + 0x04000d9b, 0x80000580, 0x1c01f000, 0x4d300000, + 0x4d180000, 0x4d3c0000, 0x0401fd9f, 0x4df00000, + 0x4a0378e4, 0x0000000f, 0x0401f9ff, 0x417a3000, + 0x59926004, 0x813261c0, 0x04000010, 0x417a7800, + 0x0201f800, 0x001048d9, 0x0400000a, 0x59300c06, + 0x82040580, 0x00000003, 0x04000004, 0x82040580, + 0x00000006, 0x04020003, 0x42027800, 0x00000002, + 0x0201f800, 0x00108be3, 0x811a3000, 0x83180480, + 0x00000005, 0x040017eb, 0x42000800, 0x00000040, + 0x0201f800, 0x00101345, 0x4a0378e4, 0x0000000a, + 0x5c03e000, 0x04000d72, 0x5c027800, 0x5c023000, + 0x5c026000, 0x1c01f000, 0x4803c856, 0x4d300000, + 0x0401fd75, 0x4df00000, 0x59c80840, 0x82040540, + 0x00000010, 0x48039040, 0x59c41008, 0x82080500, + 0xffffff7f, 0x48038808, 0x4c040000, 0x4c080000, + 0x42001000, 0x00000003, 0x0401f9c2, 0x598e600d, + 0x813261c0, 0x04020f9d, 0x040009c7, 0x497b2807, + 0x0401f80a, 0x5c001000, 0x5c000800, 0x480b8808, + 0x84040d74, 0x48079040, 0x5c03e000, 0x04000d50, + 0x5c026000, 0x1c01f000, 0x4d380000, 0x4d180000, + 0x4d300000, 0x4d900000, 0x4dd00000, 0x4da40000, + 0x4d140000, 0x59c41004, 0x480bc857, 0x82080500, + 0x00003ff0, 0x04000025, 0x417a3000, 0x4c080000, + 0x0201f800, 0x00106062, 0x5c001000, 0x82080500, + 0x00000210, 0x04020004, 0x811a3000, 0x80081102, + 0x0401f7f7, 0x0401f9c3, 0x59926004, 0x4933c857, + 0x813261c0, 0x04020005, 0x59c400a3, 0x8c00051a, + 0x02000800, 0x001005d8, 0x0401fea5, 0x04000009, + 0x0401fc6a, 0x42027000, 0x00000049, 0x59300004, + 0x8c00050c, 0x02020800, 0x000207a1, 0x0401f007, + 0x42027000, 0x0000004a, 0x4a026203, 0x00000003, + 0x0201f800, 0x000207a1, 0x5c022800, 0x5c034800, + 0x5c03a000, 0x5c032000, 0x5c026000, 0x5c023000, + 0x5c027000, 0x1c01f000, 0x4d300000, 0x4d180000, + 0x4d900000, 0x0401fd1c, 0x42001000, 0x00000000, + 0x598c0000, 0x82000580, 0x00000005, 0x04000971, + 0x417a3000, 0x811b20c8, 0x83932400, 0x0000bf32, + 0x59900001, 0x82000580, 0x00000001, 0x0402000d, + 0x42000800, 0x000007d0, 0x59926004, 0x59300011, + 0x82000500, 0xfff00000, 0x80000540, 0x04000003, + 0x42000800, 0x00001b58, 0x0201f800, 0x00106054, + 0x811a3000, 0x83180480, 0x00000005, 0x040017ea, + 0x59c81040, 0x84081534, 0x480b9040, 0x0401fcf0, + 0x5c032000, 0x5c023000, 0x5c026000, 0x1c01f000, + 0x4933c857, 0x4d900000, 0x4dd00000, 0x4da40000, + 0x4d140000, 0x4d380000, 0x0401fcef, 0x4df00000, + 0x59300004, 0x8c00053e, 0x04020007, 0x8c000520, + 0x04000025, 0x0201f800, 0x00106b6c, 0x04000022, + 0x0401f02a, 0x598c000d, 0x81300580, 0x04000011, + 0x0201f800, 0x00108cd6, 0x04020024, 0x0401f918, + 0x04000022, 0x48038804, 0x0401f95e, 0x0201f800, + 0x0010107a, 0x0401fc0d, 0x42027000, 0x00000049, + 0x59300004, 0x8c00050c, 0x0402000d, 0x0401f00e, + 0x59c40004, 0x8c000504, 0x04000014, 0x4a038804, + 0x00000004, 0x0401fc36, 0x42027000, 0x00000013, + 0x59300004, 0x8c00050c, 0x04000003, 0x0201f800, + 0x000207a1, 0x5c03e000, 0x04000cb9, 0x5c027000, + 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000, + 0x80000580, 0x1c01f000, 0x5c03e000, 0x04000cb0, + 0x5c027000, 0x5c022800, 0x5c034800, 0x5c03a000, + 0x5c032000, 0x82000540, 0x00000001, 0x1c01f000, + 0x497b2807, 0x0401fcb0, 0x59c400af, 0x800001c0, + 0x04020004, 0x0401fca2, 0x0201f000, 0x001014fb, + 0x598c000f, 0x82001480, 0x00000002, 0x04021007, + 0x80000000, 0x4803180f, 0x80000580, 0x0201f800, + 0x0010604d, 0x0400000e, 0x0401fed8, 0x0402000c, + 0x0401fdd4, 0x0400000a, 0x0201f800, 0x0010a9c7, + 0x0401f916, 0x4d380000, 0x42027000, 0x00000014, + 0x0201f800, 0x000207a1, 0x5c027000, 0x0401fc88, + 0x0201f000, 0x001014fb, 0x4d900000, 0x4dd00000, + 0x4da40000, 0x4d140000, 0x4d300000, 0x0201f800, + 0x00106062, 0x0401fc88, 0x59c400af, 0x800001c0, + 0x04000027, 0x0401f907, 0x59926004, 0x4933c857, + 0x59300004, 0x8c000516, 0x0400000b, 0x0401fe8b, + 0x0402001f, 0x0201f800, 0x00106b8a, 0x0401fc70, + 0x42000800, 0x80000804, 0x0201f800, 0x00106721, + 0x0401f017, 0x42001800, 0x00007530, 0x0401f8c1, + 0x04020004, 0x0201f800, 0x00106052, 0x0401f010, + 0x0401fe7a, 0x0402000e, 0x0201f800, 0x0010a9c7, + 0x59300004, 0x8c00050c, 0x04020003, 0x4a026203, + 0x00000003, 0x4d380000, 0x42027000, 0x0000004a, + 0x0201f800, 0x000207a1, 0x5c027000, 0x0401fc54, + 0x5c026000, 0x5c022800, 0x5c034800, 0x5c03a000, + 0x5c032000, 0x0201f000, 0x001014fb, 0x4d900000, + 0x4dd00000, 0x4da40000, 0x4d140000, 0x4d300000, + 0x4d2c0000, 0x0401fc50, 0x0401f8d2, 0x59926004, + 0x4933c857, 0x0401f880, 0x04000016, 0x0201f800, + 0x00106062, 0x813261c0, 0x04000034, 0x59325808, + 0x812e59c0, 0x02000800, 0x001005d8, 0x0201f800, + 0x0010513b, 0x0402001d, 0x592c0208, 0x84000550, + 0x48025a08, 0x0201f800, 0x00105258, 0x04020027, + 0x592c0208, 0x84000510, 0x48025a08, 0x0401f023, + 0x0201f800, 0x00106052, 0x0401f020, 0x0201f800, + 0x0010a9c7, 0x0401fd9e, 0x592c0208, 0x84000550, + 0x48025a08, 0x4d380000, 0x42027000, 0x0000004a, + 0x4a026203, 0x00000003, 0x0201f800, 0x000207a1, + 0x5c027000, 0x0401f011, 0x59900006, 0x82000500, + 0xffff0000, 0x040207ee, 0x59c408af, 0x82040480, + 0x000003e8, 0x040217ea, 0x59900006, 0x82000400, + 0x00010000, 0x48032006, 0x0201f800, 0x00106052, + 0x0201f800, 0x0010411d, 0x5c025800, 0x5c026000, + 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000, + 0x0401f403, 0x4d300000, 0x4d2c0000, 0x0401fc0a, + 0x598e600d, 0x4933c857, 0x59c41004, 0x8c081500, + 0x04000007, 0x0201f800, 0x0010513b, 0x04020007, + 0x0201f800, 0x00105258, 0x0402002f, 0x0201f800, + 0x0010604d, 0x0401f02c, 0x598c000f, 0x80000540, + 0x04020011, 0x59c408af, 0x82040480, 0x000003e8, + 0x0402100d, 0x598c080f, 0x80040800, 0x4807180f, + 0x0201f800, 0x0010604d, 0x42000000, 0x0010b852, + 0x0201f800, 0x0010aa47, 0x0201f800, 0x0010411d, + 0x0401f019, 0x0401fdb4, 0x813261c0, 0x04020003, + 0x0401f849, 0x0401f014, 0x0201f800, 0x0010a9c7, + 0x59300406, 0x82000580, 0x00000003, 0x04020007, + 0x59325808, 0x812e59c0, 0x04000004, 0x592c0208, + 0x84000550, 0x48025a08, 0x0401f854, 0x4d380000, + 0x42027000, 0x00000014, 0x0201f800, 0x000207a1, + 0x5c027000, 0x5c025800, 0x5c026000, 0x0201f000, + 0x00106c4b, 0x59c40804, 0x83180400, 0x00107095, + 0x50000000, 0x80040500, 0x1c01f000, 0x59c40804, + 0x83180400, 0x0010709a, 0x50000000, 0x80040500, + 0x1c01f000, 0x00000210, 0x00000420, 0x00000840, + 0x00001080, 0x00002100, 0x00004000, 0x00008000, + 0x00010000, 0x00020000, 0x00040000, 0x00080000, + 0x00100000, 0x00200000, 0x00400000, 0x00800000, + 0x59900806, 0x80040120, 0x800c0480, 0x04021004, + 0x82000540, 0x00000001, 0x0401f005, 0x82040c00, + 0x00010000, 0x48072006, 0x80000580, 0x1c01f000, + 0x480bc857, 0x0201f800, 0x00106c55, 0x4df00000, + 0x480b1800, 0x5c03e000, 0x02000800, 0x00106c4b, + 0x1c01f000, 0x4803c856, 0x0201f800, 0x00106c55, + 0x4df00000, 0x497b180d, 0x497b1803, 0x497b180e, + 0x497b180f, 0x497b1810, 0x598c0000, 0x82000580, + 0x00000003, 0x04000009, 0x836c0580, 0x00000002, + 0x04020004, 0x4a031800, 0x00000005, 0x0401f003, + 0x4a031800, 0x00000000, 0x5c03e000, 0x02000800, + 0x00106c4b, 0x1c01f000, 0x59300004, 0x8c00050c, + 0x04020003, 0x4a026203, 0x00000001, 0x1c01f000, + 0x83180480, 0x00000005, 0x02021800, 0x001005d8, + 0x491bc857, 0x811b20c8, 0x83932400, 0x0000bf32, + 0x811ba0ca, 0x83d3a400, 0x00007600, 0x83180400, + 0x001070ea, 0x50034800, 0x811a28c2, 0x83162c00, + 0x00006100, 0x1c01f000, 0x0010b75b, 0x0010b772, + 0x0010b789, 0x0010b7a0, 0x0010b7b7, 0x4933c857, + 0x59300406, 0x82000c80, 0x00000012, 0x04021016, + 0x4803c857, 0x04011000, 0x0c01f001, 0x00107109, + 0x00107198, 0x001074d1, 0x00107556, 0x00107198, + 0x001074d1, 0x00107556, 0x00107109, 0x00107198, + 0x00107109, 0x00107109, 0x00107109, 0x00107109, + 0x00107109, 0x00107109, 0x00107109, 0x0010710f, + 0x0010710f, 0x0201f800, 0x00106c55, 0x0201f800, + 0x00106bbf, 0x0201f000, 0x00106c4b, 0x42001000, + 0x0010b7f6, 0x50081000, 0x4930100c, 0x58080002, + 0x82000580, 0x00000100, 0x04020032, 0x59325808, + 0x812e59c0, 0x02000800, 0x001005d8, 0x59326809, + 0x813669c0, 0x04000019, 0x592c040b, 0x82000500, + 0x0000e000, 0x04000003, 0x0401fba8, 0x0401f002, + 0x0401fb98, 0x42001000, 0x0010b7f6, 0x50081000, + 0x4930100b, 0x492c100a, 0x82d00400, 0x00000006, + 0x48001003, 0x592c000d, 0x80000104, 0x48001004, + 0x592c000e, 0x48001007, 0x592c000f, 0x48001008, + 0x0201f000, 0x00100858, 0x42026800, 0x0010be0d, + 0x592c080a, 0x48066802, 0x82040500, 0x00ffff00, + 0x04000007, 0x497a6a12, 0x59a81010, 0x82081500, + 0x00ffff00, 0x80080580, 0x040207dc, 0x82040d00, + 0x000000ff, 0x800408d0, 0x48066a12, 0x0401f7d7, + 0x1c01f000, 0x4d2c0000, 0x4d300000, 0x4c580000, + 0x4c540000, 0x4c500000, 0x5832580a, 0x812e59c0, + 0x02000800, 0x001005d8, 0x58300002, 0x4a006002, + 0x00000100, 0x82000580, 0x00000100, 0x0402001c, + 0x5830000b, 0x5832600c, 0x81300580, 0x04020010, + 0x0401f828, 0x04020010, 0x592c080d, 0x80040904, + 0x4004b000, 0x4200a000, 0x0010b54b, 0x4050a800, + 0x0201f800, 0x0010ab28, 0x42001000, 0x0000dc00, + 0x0201f800, 0x001078bc, 0x0401f003, 0x0401f819, + 0x04000fa3, 0x5c00a000, 0x5c00a800, 0x5c00b000, + 0x5c026000, 0x5c025800, 0x1c01f000, 0x5830000b, + 0x5832600c, 0x81300580, 0x040207f5, 0x0401f80d, + 0x040207f5, 0x0201f800, 0x001068d3, 0x02020800, + 0x001005d8, 0x4a025a06, 0x00000002, 0x0201f800, + 0x000202da, 0x0201f800, 0x00107911, 0x0401f7ea, + 0x0201f800, 0x00106c55, 0x4df00000, 0x598c000d, + 0x81300580, 0x04020009, 0x598c0005, 0x81300580, + 0x04020006, 0x5c03e000, 0x02000800, 0x00106c4b, + 0x80000580, 0x1c01f000, 0x5c03e000, 0x02000800, + 0x00106c4b, 0x82000540, 0x00000001, 0x1c01f000, + 0x59300403, 0x82000c80, 0x00000056, 0x02021800, + 0x001005d8, 0x4803c857, 0x0c01f001, 0x00107302, + 0x0010731d, 0x0010732e, 0x00107431, 0x001073f1, + 0x001073f5, 0x00107406, 0x0010741a, 0x0010740f, + 0x0010741a, 0x00107455, 0x0010741a, 0x00107497, + 0x0010741a, 0x001074a5, 0x0010741a, 0x0010740f, + 0x0010741a, 0x001074a9, 0x001071f5, 0x001071f5, + 0x001071f5, 0x001071f5, 0x001071f5, 0x001071f5, + 0x001071f5, 0x001071f5, 0x001071f5, 0x001071f5, + 0x001071f5, 0x00107574, 0x00107593, 0x0010759d, + 0x001071f5, 0x001075b3, 0x00107406, 0x001071f5, + 0x00107406, 0x0010741a, 0x001071f5, 0x0010732e, + 0x00107431, 0x001071f5, 0x00107603, 0x0010741a, + 0x001071f5, 0x00107613, 0x0010741a, 0x001071f5, + 0x0010740f, 0x001072f3, 0x001071f7, 0x001071f5, + 0x0010762a, 0x0010765d, 0x001076d7, 0x001071f5, + 0x001076e7, 0x00107404, 0x001076da, 0x001071f5, + 0x001075bf, 0x00107700, 0x001071f5, 0x00107735, + 0x00107788, 0x001071f5, 0x0010720c, 0x00107265, + 0x00107272, 0x001071f5, 0x00107406, 0x001071f5, + 0x001072b9, 0x001072c4, 0x001071f5, 0x001071f5, + 0x00107220, 0x00107245, 0x001077c7, 0x00107808, + 0x0010782e, 0x001071f5, 0x001071f5, 0x001071f5, + 0x001077fc, 0x0201f800, 0x001005d8, 0x0401fac5, + 0x59325808, 0x592c0009, 0x4801a006, 0x592c000a, + 0x4801a007, 0x592c000b, 0x4801a008, 0x592c000c, + 0x4801a009, 0x592c000d, 0x4801a00a, 0x4979a00b, + 0x592c0809, 0x82040d00, 0x00000fff, 0x80040904, + 0x42001000, 0x0000dc00, 0x0201f000, 0x001078bc, + 0x4a026202, 0x0000ffff, 0x0401faae, 0x4d2c0000, + 0x4a01a006, 0x05000000, 0x59325808, 0x592c0009, + 0x4801a007, 0x592c000a, 0x4801a008, 0x592c000b, + 0x4801a009, 0x42000800, 0x00000004, 0x42001000, + 0x0000dc00, 0x5c025800, 0x0201f000, 0x001078bc, + 0x4c580000, 0x4c500000, 0x4c540000, 0x4d2c0000, + 0x0401fa98, 0x59325808, 0x5930040b, 0x800000c2, + 0x4200a800, 0x0010b54b, 0x592cb205, 0x832ca400, + 0x00000006, 0x0201f800, 0x0010ab17, 0x40580000, + 0x8054ac00, 0x592c0001, 0x80000540, 0x04000003, + 0x40025800, 0x0401f7f5, 0x4200a000, 0x0010b54b, + 0x4050a800, 0x5930b40b, 0x0201f800, 0x0010ab28, + 0x59300c0b, 0x42001000, 0x0000dc00, 0x5c025800, + 0x5c00a800, 0x5c00b000, 0x5c00a000, 0x0201f000, + 0x001078bc, 0x4c580000, 0x4c500000, 0x4c540000, + 0x4d2c0000, 0x42034800, 0x0010b544, 0x0401fa7f, + 0x59325808, 0x4a025805, 0x02000000, 0x592c0802, + 0x82d0ac00, 0x00000006, 0x592cb011, 0x832ca400, + 0x00000005, 0x0201f800, 0x0010ab17, 0x40580000, + 0x8054ac00, 0x592e5801, 0x41780000, 0x812e5d40, + 0x040207f6, 0x42001000, 0x0000dc00, 0x5c025800, + 0x5c00a800, 0x5c00b000, 0x5c00a000, 0x0201f000, + 0x001078bc, 0x0401fa57, 0x4a01a006, 0x78000000, + 0x5930001c, 0x840001c0, 0x4801a407, 0x4979a207, + 0x42000800, 0x00000002, 0x42001000, 0x0000dc00, + 0x0201f000, 0x001078bc, 0x4c580000, 0x4c540000, + 0x4c500000, 0x0401fa55, 0x4a01a006, 0x02000000, + 0x59a80002, 0x4801a008, 0x59a80003, 0x4801a009, + 0x59a80000, 0x4801a00a, 0x59a80001, 0x4801a00b, + 0x5930001c, 0x82000d80, 0x0000e000, 0x04000016, + 0x82000d80, 0x0000df00, 0x04000006, 0x4a01a407, + 0x00000010, 0x42000800, 0x00000006, 0x0401f027, + 0x4a03c840, 0x0010b4eb, 0x4a03c842, 0x0000000d, + 0x42001800, 0x0010b4eb, 0x0201f800, 0x001007af, + 0x42000000, 0x0000df00, 0x4200a000, 0x0010b4eb, + 0x0401f00d, 0x4a03c840, 0x0010b4f8, 0x4a03c842, + 0x0000000d, 0x42001800, 0x0010b4f8, 0x0201f800, + 0x001007af, 0x42000000, 0x0000e000, 0x4200a000, + 0x0010b4f8, 0x82000540, 0x00000010, 0x4801a407, + 0x4a01a207, 0x00000034, 0x4200b000, 0x0000000d, + 0x82d0ac00, 0x0000000c, 0x0201f800, 0x0010ab17, + 0x42000800, 0x00000013, 0x42001000, 0x0000dc00, + 0x5c00a000, 0x5c00a800, 0x5c00b000, 0x0201f000, + 0x001078bc, 0x0401fa03, 0x4a01a006, 0x63000028, + 0x5930001c, 0x4801a007, 0x42000800, 0x00000002, + 0x42001000, 0x0000dc00, 0x0201f000, 0x001078bc, + 0x0401fa06, 0x41780000, 0x41780800, 0x42002000, + 0x00080000, 0x0c01f81b, 0x80000000, 0x80040800, + 0x42001000, 0x0000000c, 0x59841802, 0x8c0c1d00, + 0x04020008, 0x42002000, 0x00050000, 0x0c01f811, + 0x80000000, 0x80040800, 0x82081400, 0x00000004, + 0x82080540, 0x02000000, 0x4801a006, 0x800408e0, + 0x5930001c, 0x80040540, 0x4801a007, 0x80080904, + 0x42001000, 0x0000dc00, 0x0201f000, 0x001078bc, + 0x001072e9, 0x001072eb, 0x001072ed, 0x001072ef, + 0x001072f1, 0x4811a008, 0x1c01f000, 0x4811a009, + 0x1c01f000, 0x4811a00a, 0x1c01f000, 0x4811a00b, + 0x1c01f000, 0x4811a00c, 0x1c01f000, 0x4a026009, + 0x0010be0d, 0x59a80010, 0x82000500, 0x000000ff, + 0x800000d0, 0x42026800, 0x0010be0d, 0x48026a12, + 0x0401fa3b, 0x41780800, 0x42001000, 0x00005c00, + 0x0201f000, 0x001078bc, 0x0401f9ba, 0x4a01a006, + 0x52000000, 0x4979a007, 0x599c0017, 0x8c000500, + 0x04000005, 0x599c0402, 0x0201f800, 0x001015da, + 0x4805a007, 0x59a80002, 0x4801a008, 0x59a80003, + 0x4801a009, 0x59a80000, 0x4801a00a, 0x59a80001, + 0x4801a00b, 0x59a80010, 0x4801a00c, 0x42000800, + 0x00000007, 0x42001000, 0x0000dc00, 0x0201f000, + 0x001078bc, 0x4a026202, 0x0000ffff, 0x0401f99d, + 0x4a01a006, 0x05000000, 0x59a80010, 0x4801a007, + 0x59a80002, 0x59a80803, 0x4801a008, 0x4805a009, + 0x42000800, 0x00000004, 0x42001000, 0x0000dc00, + 0x0201f000, 0x001078bc, 0x4a026202, 0x0000ffff, + 0x0401f98c, 0x4d3c0000, 0x417a7800, 0x0201f800, + 0x001048f6, 0x5c027800, 0x4a01a006, 0x03000000, + 0x59340403, 0x82000580, 0x000007fe, 0x0402006e, + 0x4a01a006, 0x04000000, 0x81a40800, 0x4a000800, + 0x22fffffe, 0x5934000a, 0x84000500, 0x4802680a, + 0x59c41002, 0x8408150c, 0x480b8802, 0x59a80026, + 0x8c000508, 0x04000010, 0x59a8002a, 0x4801a007, + 0x59a8002b, 0x82000500, 0xffff2000, 0x599c0818, + 0x8c040d16, 0x04000002, 0x8400056a, 0x4801a008, + 0x4a01a009, 0x00002710, 0x59a8002d, 0x4801a00a, + 0x0401f039, 0x59a8002a, 0x4801a007, 0x0201f800, + 0x0010513b, 0x04020009, 0x497b8880, 0x82000500, + 0x0000ffff, 0x4c000000, 0x0201f800, 0x00101606, + 0x5c000000, 0x48038880, 0x59a8002b, 0x0201f800, + 0x0010513b, 0x04020004, 0x82000500, 0x37ffffff, + 0x0401f003, 0x82000500, 0x3fffffff, 0x599c0818, + 0x8c040d16, 0x04000002, 0x8400056a, 0x59a80805, + 0x8c040d10, 0x04000019, 0x59300c03, 0x82041580, + 0x00000051, 0x04000015, 0x82041580, 0x00000031, + 0x04000012, 0x4c580000, 0x4c500000, 0x4c540000, + 0x4200b000, 0x00000004, 0x4200a000, 0x0010b8fa, + 0x82d0ac00, 0x0000001f, 0x4c000000, 0x0201f800, + 0x0010ab17, 0x5c000000, 0x5c00a800, 0x5c00a000, + 0x5c00b000, 0x8400057a, 0x4801a008, 0x4979a009, + 0x4979a00a, 0x59a80002, 0x59a80803, 0x4801a00b, + 0x4805a00c, 0x59a80000, 0x59a80801, 0x4801a00d, + 0x4805a00e, 0x4979a00f, 0x4979a010, 0x4979a011, + 0x4979a012, 0x4979a013, 0x4979a014, 0x4979a015, + 0x4979a016, 0x59a8002e, 0x84000576, 0x4801a017, + 0x59a8002f, 0x4801a018, 0x4979a019, 0x4979a01a, + 0x0401f043, 0x59a80026, 0x8c000508, 0x0400000d, + 0x59a8002a, 0x82000500, 0x0000ffff, 0x59c40880, + 0x80040d80, 0x04000007, 0x497b8880, 0x4c000000, + 0x0201f800, 0x00101606, 0x5c000000, 0x48038880, + 0x59a8002a, 0x4801a007, 0x4c640000, 0x4d2c0000, + 0x59a8c82b, 0x0201f800, 0x00109037, 0x0400000d, + 0x0201f800, 0x00109597, 0x0402000a, 0x592c0207, + 0x8c00050e, 0x04000007, 0x8264cd00, 0x0000ffff, + 0x592c0009, 0x82000500, 0xffff0000, 0x8064cd40, + 0x4865a008, 0x5c025800, 0x5c00c800, 0x59a8002c, + 0x4801a009, 0x59a8002d, 0x4801a00a, 0x59a80002, + 0x59a80803, 0x4801a00b, 0x4805a00c, 0x59a80000, + 0x59a80801, 0x4801a00d, 0x4805a00e, 0x4979a00f, + 0x4979a010, 0x4979a011, 0x4979a012, 0x4979a013, + 0x4979a014, 0x4979a015, 0x4979a016, 0x59a8002e, + 0x4801a017, 0x59a8002f, 0x4801a018, 0x59a80030, + 0x4801a019, 0x59a80031, 0x4801a01a, 0x42000800, + 0x0000001d, 0x42001000, 0x0000dc00, 0x0201f000, + 0x001078bc, 0x0401f8cb, 0x4a01a006, 0x50000000, + 0x0401f7b5, 0x0401f8c7, 0x4a01a406, 0x21000010, + 0x4a01a206, 0x00000014, 0x4979a007, 0x4979a008, + 0x4979a009, 0x4979a00a, 0x42000800, 0x00000005, + 0x42001000, 0x0000dc00, 0x0201f000, 0x001078bc, + 0x0401f8bf, 0x0401f002, 0x0401f8c4, 0x4a01a006, + 0x02000000, 0x42000800, 0x00000001, 0x42001000, + 0x0000dc00, 0x0201f000, 0x001078bc, 0x0401f8bb, + 0x4a01a006, 0x02000000, 0x59300403, 0x82000580, + 0x00000031, 0x04020794, 0x81a40800, 0x4a000801, + 0x00fffffe, 0x0401f72b, 0x0401f8b0, 0x4a01a006, + 0x01000000, 0x5930041a, 0x80000540, 0x04000003, + 0x4801a407, 0x0401f003, 0x4a01a407, 0x00000003, + 0x5930021a, 0x80000540, 0x04000003, 0x4801a207, + 0x0401f003, 0x4a01a207, 0x00002a00, 0x42000800, + 0x00000002, 0x42001000, 0x0000dc00, 0x0201f000, + 0x001078bc, 0x4a026202, 0x0000ffff, 0x0401f889, + 0x4a01a406, 0x00002010, 0x4a01a206, 0x00000014, + 0x4a01a407, 0x00000800, 0x4a01a207, 0x00002000, + 0x80000580, 0x599c0817, 0x8c040d0a, 0x04020003, + 0x82000540, 0x00000020, 0x8c040d08, 0x04000003, + 0x82000540, 0x00000010, 0x82000540, 0x00000002, + 0x5934080a, 0x8c040d14, 0x04000005, 0x82040d00, + 0x00000380, 0x80040540, 0x0401f006, 0x599c0818, + 0x8c040d18, 0x04000003, 0x82000540, 0x00000380, + 0x0401f03c, 0x0401f875, 0x4a01a406, 0x00000210, + 0x4a01a206, 0x00000014, 0x4a01a407, 0x00000800, + 0x5934000a, 0x8c000516, 0x04000014, 0x59340c05, + 0x82040500, 0x00000030, 0x04000013, 0x59340a05, + 0x82040500, 0x0000c000, 0x04020009, 0x8c040d1a, + 0x04000004, 0x4a01a207, 0x00002100, 0x0401f00c, + 0x4a01a207, 0x00000100, 0x0401f009, 0x4a01a207, + 0x00000400, 0x0401f006, 0x4a01a207, 0x00000700, + 0x0401f003, 0x4a01a207, 0x00000800, 0x80000580, + 0x599c0817, 0x8c040d0a, 0x04020003, 0x82000540, + 0x00000020, 0x8c040d08, 0x04000003, 0x82000540, + 0x00000010, 0x82000540, 0x00000002, 0x59340a00, + 0x8c040d0e, 0x0400000b, 0x84000550, 0x599c1017, + 0x8c08150a, 0x04020004, 0x8c040d0a, 0x04000002, + 0x8400054e, 0x8c040d1c, 0x04000002, 0x84000552, + 0x4801a20a, 0x42000800, 0x00000005, 0x42001000, + 0x0000dc00, 0x0201f000, 0x001078bc, 0x0401f833, + 0x4a01a006, 0x02100014, 0x4a01a007, 0x01000000, + 0x4979a008, 0x4979a009, 0x4979a00a, 0x42000800, + 0x00000005, 0x42001000, 0x0000dc00, 0x0201f000, + 0x001078bc, 0x0401f825, 0x4a01a006, 0x02000000, + 0x0401f65d, 0x4933c857, 0x0401f820, 0x4a01a006, + 0x01000000, 0x4a01a407, 0x0000000b, 0x42000800, + 0x00000002, 0x42001000, 0x0000dc00, 0x0201f000, + 0x001078bc, 0x42005000, 0x32000000, 0x42006000, + 0x08290000, 0x41786800, 0x41787800, 0x0401f3df, + 0x42005000, 0x22000000, 0x42006000, 0x01290000, + 0x41786800, 0x41787800, 0x0401f3d8, 0x42005000, + 0x33000000, 0x42006000, 0x08980000, 0x41786800, + 0x41787800, 0x0401f3d1, 0x42005000, 0x23000000, + 0x42006000, 0x01980000, 0x41786800, 0x41787800, + 0x0401f3ca, 0x59300403, 0x82000c80, 0x00000085, + 0x02001800, 0x001005d8, 0x82000c80, 0x00000093, + 0x02021800, 0x001005d8, 0x82000480, 0x00000085, + 0x0c01f001, 0x001074eb, 0x001074ed, 0x001074fb, + 0x001074eb, 0x001074eb, 0x001074eb, 0x001074eb, + 0x001074eb, 0x001074eb, 0x001074eb, 0x001074eb, + 0x001074eb, 0x001074eb, 0x00107506, 0x0201f800, + 0x001005d8, 0x4933c857, 0x0401f850, 0x59300402, + 0x4801a407, 0x5930001c, 0x4801a207, 0x4979a408, + 0x4a01a208, 0x0000ffff, 0x42000800, 0x00000003, + 0x42001000, 0x0000dc00, 0x0401f3c2, 0x4933c857, + 0x0401f84e, 0x4a01a406, 0x00000003, 0x4a01a206, + 0x00000300, 0x42000800, 0x00000001, 0x42001000, + 0x0000dc00, 0x0401f3b7, 0x4d2c0000, 0x59325808, + 0x4933c857, 0x492fc857, 0x812e59c0, 0x02000800, + 0x001005d8, 0x59340a12, 0x82040d00, 0x0000ff00, + 0x592c000a, 0x82000500, 0x000000ff, 0x900001c0, + 0x80040540, 0x82000540, 0x00000011, 0x44034800, + 0x81a5a000, 0x42001000, 0x00000009, 0x42000800, + 0x00000003, 0x592c0009, 0x82000500, 0xff000000, + 0x82001d80, 0x84000000, 0x04000009, 0x82001d80, + 0x85000000, 0x02020800, 0x001005d8, 0x42001000, + 0x00000007, 0x42000800, 0x00000001, 0x832c1c00, + 0x00000009, 0x500c0000, 0x4401a000, 0x800c1800, + 0x80d1a000, 0x80081040, 0x040207fb, 0x42001000, + 0x0000dc00, 0x5c025800, 0x0401f386, 0x42005000, + 0x81000000, 0x42006000, 0x00090000, 0x41786800, + 0x41787800, 0x0401f35d, 0x42005000, 0x84000000, + 0x42006000, 0x00990000, 0x59300406, 0x82000580, + 0x00000005, 0x04000002, 0x8430652e, 0x41786800, + 0x41787800, 0x0401f351, 0x42005000, 0x85000000, + 0x42006000, 0x00990000, 0x59300406, 0x82000580, + 0x00000005, 0x04000002, 0x8430652e, 0x41786800, + 0x41787800, 0x0401f345, 0x59300403, 0x82000c80, + 0x00000053, 0x02021800, 0x001005d8, 0x82000480, + 0x0000004b, 0x02001800, 0x001005d8, 0x59326809, + 0x59368c03, 0x4803c857, 0x0c01f001, 0x001075da, + 0x001075e2, 0x001075ea, 0x001075f2, 0x0010756b, + 0x0010756b, 0x0010756b, 0x001075d2, 0x0201f800, + 0x001005d8, 0x42005000, 0x06000000, 0x42006000, + 0x08290000, 0x41786800, 0x41787800, 0x0401f327, + 0x4933c857, 0x0401ff47, 0x4a01a006, 0x12000000, + 0x59300406, 0x82000580, 0x00000004, 0x04020003, + 0x59340002, 0x0401f002, 0x59a80010, 0x82000500, + 0x00ffffff, 0x4801a007, 0x59300419, 0x4801a408, + 0x59300219, 0x4801a208, 0x4979a009, 0x4979a00a, + 0x4979a00b, 0x4979a00c, 0x4979a00d, 0x4979a00e, + 0x4979a00f, 0x4979a010, 0x42000800, 0x0000000b, + 0x42001000, 0x0000dc00, 0x0401f32a, 0x0401ff29, + 0x4a01a006, 0x0f000000, 0x5930001c, 0x4801a007, + 0x42000800, 0x00000002, 0x42001000, 0x0000dc00, + 0x0401f320, 0x0401ff2d, 0x4a01a006, 0x02000000, + 0x59c40085, 0x48031004, 0x59880000, 0x4801a007, + 0x59880001, 0x4801a008, 0x59880002, 0x4801a009, + 0x59880003, 0x4801a00a, 0x59880004, 0x4801a00b, + 0x59880005, 0x4801a00c, 0x42000800, 0x00000007, + 0x42001000, 0x0000dc00, 0x0401f30a, 0x4a026202, + 0x0000ffff, 0x0401ff07, 0x4a01a006, 0x62000000, + 0x5930001c, 0x4801a007, 0x42000800, 0x00000002, + 0x42001000, 0x0000dc00, 0x0401f2fe, 0x0401fefd, + 0x59300808, 0x4c500000, 0x4c540000, 0x4c580000, + 0x8204a400, 0x0000000a, 0x5930b01c, 0x82d0ac00, + 0x00000006, 0x0201f800, 0x0010ab17, 0x5930081c, + 0x42001000, 0x0000dc00, 0x5c00b000, 0x5c00a800, + 0x5c00a000, 0x0401f2eb, 0x0401ff9b, 0x59300017, + 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008, + 0x00001000, 0x0401f020, 0x0401ff93, 0x59300017, + 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008, + 0x00004000, 0x0401f018, 0x0401ff8b, 0x59300017, + 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008, + 0x00002000, 0x0401f010, 0x0401ff83, 0x59300017, + 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008, + 0x00000400, 0x0401f008, 0x0401ff7b, 0x59300017, + 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008, + 0x00000200, 0x4979a009, 0x4979a00a, 0x4979a00b, + 0x4979a00c, 0x4979a00d, 0x42000800, 0x00000008, + 0x42001000, 0x0000dc00, 0x0401f2ba, 0x0401fec7, + 0x4a01a006, 0x02000014, 0x4979a407, 0x4979a207, + 0x59a8003a, 0x4801a008, 0x59a8003b, 0x4801a009, + 0x4a01a00a, 0x00047878, 0x42000800, 0x00000005, + 0x42001000, 0x0000dc00, 0x0401f2aa, 0x0401feb7, + 0x4a01a006, 0x02140018, 0x4a01a407, 0x00000800, + 0x5930001c, 0x82000d00, 0xff000000, 0x900409c0, + 0x4805a207, 0x82000500, 0x00ffffff, 0x4801a00a, + 0x4979a408, 0x4979a208, 0x4979a409, 0x4979a209, + 0x4979a00b, 0x42000800, 0x00000006, 0x42001000, + 0x0000dc00, 0x0401f293, 0x4803c856, 0x4d380000, + 0x4d1c0000, 0x42027000, 0x00000035, 0x0201f800, + 0x001093ba, 0x0402001e, 0x0401fe8a, 0x4a01a006, + 0x13000000, 0x5932381e, 0x591c0019, 0x4801a005, + 0x591c0406, 0x82000580, 0x00000003, 0x04000007, + 0x59300809, 0x58040002, 0x82000500, 0x00ffffff, + 0x4801a007, 0x0401f003, 0x59a80010, 0x4801a007, + 0x59300419, 0x4801a408, 0x59300219, 0x4801a208, + 0x42000800, 0x00000003, 0x42001000, 0x0000dc00, + 0x5c023800, 0x5c027000, 0x0401f26e, 0x0201f800, + 0x00106c55, 0x598c000d, 0x81300580, 0x02020800, + 0x001005d8, 0x0201f800, 0x00106bbf, 0x0201f800, + 0x0002077d, 0x5c023800, 0x5c027000, 0x0201f000, + 0x00106c4b, 0x4803c856, 0x4d2c0000, 0x4d1c0000, + 0x5932381e, 0x811e39c0, 0x02000800, 0x001005d8, + 0x591c0c06, 0x82040580, 0x00000006, 0x0400000d, + 0x82040580, 0x00000003, 0x04000036, 0x4a026403, + 0x00000037, 0x4a02641a, 0x00000003, 0x4a02621a, + 0x00001700, 0x5c023800, 0x5c025800, 0x0401f064, + 0x0401f84b, 0x42001000, 0x40000000, 0x591c0203, + 0x591c0804, 0x8c040d3e, 0x04020023, 0x82000c80, + 0x0000000e, 0x0c001003, 0x0201f800, 0x001005d8, + 0x00107691, 0x0010769d, 0x00107693, 0x0010769d, + 0x00107699, 0x00107691, 0x00107691, 0x0010769d, + 0x0010769d, 0x00107691, 0x00107691, 0x00107691, + 0x00107691, 0x00107691, 0x0010769d, 0x00107691, + 0x0010769d, 0x0201f800, 0x001005d8, 0x591c0414, + 0x4803c857, 0x8c000518, 0x04000003, 0x8c000512, + 0x04000003, 0x80001580, 0x0401f003, 0x42001000, + 0x20000000, 0x591c0015, 0x4801a00a, 0x0401f018, + 0x0401f81f, 0x591e5808, 0x812e59c0, 0x02000800, + 0x001005d8, 0x592c100f, 0x591c0011, 0x80080480, + 0x4801a00a, 0x591c0203, 0x591c0804, 0x8c040d3e, + 0x04020007, 0x82000d80, 0x00000002, 0x04000007, + 0x82000d80, 0x00000004, 0x04000004, 0x42001000, + 0x40000000, 0x0401f002, 0x80001580, 0x4809a00b, + 0x42000800, 0x00000006, 0x42001000, 0x0000dc00, + 0x5c023800, 0x5c025800, 0x0401f1fe, 0x4803c856, + 0x0401fe0a, 0x4a01a006, 0x02000000, 0x59300c19, + 0x4805a407, 0x59300a19, 0x4805a207, 0x59a81010, + 0x59300809, 0x58041802, 0x820c1d00, 0x00ffffff, + 0x5930081e, 0x58040406, 0x82000580, 0x00000003, + 0x04020004, 0x4809a008, 0x480da009, 0x0401f003, + 0x480da008, 0x4809a009, 0x1c01f000, 0x4803c856, + 0x0401fdf2, 0x0401f003, 0x4803c856, 0x0401fde8, + 0x4a01a006, 0x01000000, 0x5930041a, 0x4801a407, + 0x5930021a, 0x4801a207, 0x42000800, 0x00000002, + 0x42001000, 0x0000dc00, 0x0401f1d6, 0x4803c856, + 0x4d1c0000, 0x0401fdcc, 0x4a01a006, 0x14000000, + 0x5932381e, 0x591c0019, 0x4801a005, 0x59300419, + 0x4801a407, 0x59300219, 0x4801a207, 0x59300015, + 0x4801a008, 0x59300216, 0x82000500, 0x000000ff, + 0x840001c0, 0x4801a409, 0x42000800, 0x00000004, + 0x42001000, 0x0000dc00, 0x5c023800, 0x0401f1bd, + 0x4803c856, 0x0401f80b, 0x5930041a, 0x900001c0, + 0x4801a005, 0x0401f9ec, 0x41780800, 0x42001000, + 0x00005c00, 0x0401f9b3, 0x0201f000, 0x0010604d, + 0x4803c856, 0x59300817, 0x82041c00, 0x00000005, + 0x46034800, 0x00000021, 0x58040404, 0x82000500, + 0x0000f000, 0x82000580, 0x00003000, 0x04000003, + 0x46034800, 0x00000041, 0x81a5a000, 0x580c0001, + 0x82000d00, 0x00ffffff, 0x82040d40, 0xc2000000, + 0x4805a000, 0x580c0800, 0x82041500, 0x00ffffff, + 0x82000500, 0xff000000, 0x80080540, 0x4801a001, + 0x580c0002, 0x82000580, 0x00c00000, 0x82000500, + 0x00fd0300, 0x4801a002, 0x580c0003, 0x4801a003, + 0x580c0404, 0x4801a404, 0x580c0204, 0x4801a204, + 0x1c01f000, 0x4803c856, 0x59a80026, 0x82000500, + 0x00000028, 0x04020009, 0x59a80026, 0x82000500, + 0x00000028, 0x04000003, 0x497a6a12, 0x0401f003, + 0x4a026a12, 0x0000ff00, 0x42005000, 0x22000000, + 0x42006000, 0x01380000, 0x41786800, 0x41787800, + 0x0401f952, 0x59301008, 0x4a01a006, 0x54000000, + 0x59a80010, 0x82000500, 0x00ffffff, 0x58080c0a, + 0x800408f0, 0x80040540, 0x4801a007, 0x5808000a, + 0x82000500, 0xff000000, 0x4801a008, 0x59a80002, + 0x4801a009, 0x59a80003, 0x4801a00a, 0x59a80000, + 0x4801a00b, 0x59a80001, 0x4801a00c, 0x5808000c, + 0x9c0001c0, 0x4801a00d, 0x5808000d, 0x9c0001c0, + 0x4801a00e, 0x5808000e, 0x9c0001c0, 0x4801a00f, + 0x5808000f, 0x9c0001c0, 0x4801a010, 0x58080010, + 0x9c0001c0, 0x4801a011, 0x58080011, 0x9c0001c0, + 0x4801a012, 0x58080012, 0x9c0001c0, 0x4801a013, + 0x58080013, 0x9c0001c0, 0x4801a014, 0x58080010, + 0x9c0001c0, 0x4801a015, 0x58080011, 0x9c0001c0, + 0x4801a016, 0x58080012, 0x9c0001c0, 0x4801a017, + 0x58080013, 0x9c0001c0, 0x4801a018, 0x42000800, + 0x00000013, 0x42001000, 0x0000dc00, 0x0401f135, + 0x4803c856, 0x42005000, 0x22000000, 0x42006000, + 0x01290000, 0x41786800, 0x41787800, 0x0401f90b, + 0x59301008, 0x4a01a006, 0x55000000, 0x5808000b, + 0x82000500, 0x00ffffff, 0x58080c0a, 0x800408f0, + 0x80040540, 0x4801a007, 0x5808080a, 0x82040d00, + 0xff000000, 0x59a80010, 0x82000500, 0x00ffffff, + 0x80040540, 0x4801a008, 0x5808000c, 0x9c0001c0, + 0x4801a009, 0x5808000d, 0x9c0001c0, 0x4801a00a, + 0x5808000e, 0x9c0001c0, 0x4801a00b, 0x5808000f, + 0x9c0001c0, 0x4801a00c, 0x59a80002, 0x4801a00d, + 0x59a80003, 0x4801a00e, 0x59a80000, 0x4801a00f, + 0x59a80001, 0x4801a010, 0x58080010, 0x4801a011, + 0x58080011, 0x4801a012, 0x58080012, 0x4801a013, + 0x58080013, 0x4801a014, 0x4979a015, 0x4979a016, + 0x4979a017, 0x4979a018, 0x42000800, 0x00000013, + 0x42001000, 0x0000dc00, 0x0401f0f6, 0x0401fd03, + 0x5930001c, 0x800001c0, 0x04000008, 0x4a01a006, + 0x01000000, 0x4a01a407, 0x00000003, 0x42000800, + 0x00000002, 0x0401f028, 0x4a01a006, 0x02000000, + 0x41780800, 0x836c0580, 0x00000004, 0x04020003, + 0x84040d42, 0x0401f00d, 0x0201f800, 0x0010513b, + 0x04020003, 0x84040d4a, 0x0401f002, 0x84040d48, + 0x59a80026, 0x8c000506, 0x04020003, 0x8c00050a, + 0x04000002, 0x84040d46, 0x4805a207, 0x59c40085, + 0x48031004, 0x4c580000, 0x4c500000, 0x4c540000, + 0x4200b000, 0x00000006, 0x8388a400, 0x00000000, + 0x82d0ac00, 0x00000008, 0x0201f800, 0x0010ab17, + 0x5c00a800, 0x5c00a000, 0x5c00b000, 0x42000800, + 0x00000008, 0x42001000, 0x0000dc00, 0x0401f0c1, + 0x0401fcc0, 0x4a01a006, 0x56000000, 0x59340006, + 0x4801a007, 0x59340007, 0x4801a008, 0x42000800, + 0x00000003, 0x42001000, 0x0000dc00, 0x0401f0b5, + 0x4803c856, 0x0401fcc1, 0x5930081c, 0x800409c0, + 0x0400000e, 0x82040580, 0x0000ffff, 0x04000004, + 0x82040480, 0x00000007, 0x04021008, 0x4a01a006, + 0x01000000, 0x4a01a407, 0x00000003, 0x42000800, + 0x00000002, 0x0401f012, 0x4a01a006, 0x0200001c, + 0x4a01a007, 0x00000001, 0x42001000, 0x0010b4f0, + 0x50080000, 0x9c0001c0, 0x4801a009, 0x59a80010, + 0x4801a00a, 0x59a80002, 0x59a80803, 0x4801a00b, + 0x4805a00c, 0x42000800, 0x00000007, 0x42001000, + 0x0000dc00, 0x0401f08f, 0x4d2c0000, 0x0401fc8d, + 0x59325808, 0x592c0008, 0x82000500, 0x00ffffff, + 0x4801a001, 0x4a01a006, 0x51000000, 0x5c025800, + 0x0201f000, 0x00107344, 0x4803c856, 0x59a80810, + 0x82040d00, 0x000000ff, 0x59325808, 0x59326809, + 0x59a83026, 0x8c18350a, 0x04020008, 0x8c00050e, + 0x04020006, 0x80001d80, 0x59a82010, 0x82102500, + 0x000000ff, 0x0401f001, 0x59300406, 0x4803c857, + 0x82000d80, 0x00000009, 0x04000006, 0x82000d80, + 0x0000000a, 0x0400002e, 0x0201f800, 0x001005d8, + 0x59300015, 0x8c00051e, 0x04020020, 0x42005000, + 0x04000000, 0x42006000, 0x05000000, 0x592c040a, + 0x82000500, 0x00000030, 0x800000e0, 0x80306540, + 0x5934000a, 0x8c000508, 0x04000002, 0x84306546, + 0x41786800, 0x41787800, 0x0401f831, 0x59300c14, + 0x80040000, 0x48026414, 0x40040000, 0x800000d0, + 0x82000540, 0x00000020, 0x4801a403, 0x83180d40, + 0x00000038, 0x42001000, 0x0000c920, 0x0401f860, + 0x0201f000, 0x00106052, 0x59a80026, 0x82000500, + 0x00000028, 0x04000003, 0x497a6a12, 0x0401f7dc, + 0x4a026a12, 0x0000ff00, 0x0401f7d9, 0x42005000, + 0x02000000, 0x42006000, 0x20290000, 0x41786800, + 0x41787800, 0x0401f812, 0x83180d40, 0x00000038, + 0x42001000, 0x0000c9a0, 0x0401f849, 0x42000800, + 0x000007d0, 0x59300011, 0x82000500, 0xfff00000, + 0x80000540, 0x04000003, 0x42000800, 0x00001b58, + 0x41781000, 0x0201f000, 0x00106054, 0x4201a000, + 0x00000000, 0x0401f003, 0x4201a000, 0x00000011, + 0x59340a12, 0x82040d00, 0x0000ff00, 0x59a80010, + 0x82000500, 0x000000ff, 0x900001c0, 0x80040540, + 0x80d00540, 0x44034800, 0x81a5a000, 0x59340002, + 0x82000500, 0x00ffffff, 0x80280540, 0x4801a000, + 0x59a80010, 0x4801a001, 0x4831a002, 0x82340540, + 0x00000000, 0x4801a003, 0x59300402, 0x4801a404, + 0x59300a02, 0x4805a204, 0x8c30652e, 0x04000003, + 0x4805a404, 0x4801a204, 0x483da005, 0x1c01f000, + 0x4803c856, 0x4c040000, 0x0401f822, 0x5c000800, + 0x40040000, 0x80081540, 0x800000c4, 0x82000540, + 0x00002000, 0x4803910a, 0x59b400f6, 0x82000500, + 0x00000018, 0x040207fd, 0x4a0368f0, 0x0010b544, + 0x4a0368f1, 0x0010b54b, 0x480b68f3, 0x4a0378e4, + 0x00008000, 0x0201f000, 0x0010604d, 0x4807c857, + 0x480a2800, 0x4c040000, 0x0401f80a, 0x5c000800, + 0x59b400f6, 0x8c00050a, 0x040207fe, 0x49a768f2, + 0x480768f4, 0x4a0378e4, 0x00008000, 0x1c01f000, + 0x4a0378e4, 0x0000c000, 0x59bc00e4, 0x8c000520, + 0x0400000c, 0x4a0378e4, 0x00008000, 0x42007000, + 0x000003e8, 0x59bc00e4, 0x8c000520, 0x040007f5, + 0x80387040, 0x02000800, 0x001005d8, 0x0401f7fa, + 0x1c01f000, 0x82000500, 0xffff0000, 0x82000580, + 0x01050000, 0x0402000d, 0x599c0818, 0x8c040d10, + 0x0400000a, 0x59a80807, 0x8c040d0a, 0x04000007, + 0x42001000, 0x0000804f, 0x41781800, 0x41782000, + 0x0201f800, 0x00103a3e, 0x1c01f000, 0x41781000, + 0x42026000, 0x0010d1c0, 0x59a8180e, 0x480a6402, + 0x4a026202, 0x0000ffff, 0x80081000, 0x800c1840, + 0x04000004, 0x83326400, 0x00000024, 0x0401f7f8, + 0x1c01f000, 0x4933c857, 0x59300203, 0x82000580, + 0x00000000, 0x0400002c, 0x59300406, 0x4803c857, + 0x82000d80, 0x00000004, 0x04000011, 0x82000d80, + 0x00000001, 0x0400000e, 0x82000d80, 0x00000003, + 0x04000006, 0x82000d80, 0x00000006, 0x04020011, + 0x0201f800, 0x0010a5df, 0x5930001c, 0x800001c0, + 0x02020800, 0x0010984e, 0x0401f00a, 0x5930081e, + 0x4807c857, 0x800409c0, 0x04000006, 0x5804001c, + 0x4803c857, 0x81300580, 0x04020002, 0x4978081c, + 0x497a6008, 0x4a026004, 0x00004000, 0x59a80037, + 0x82000c80, 0x00000051, 0x04001002, 0x80000102, + 0x48026206, 0x497a6205, 0x497a6009, 0x4a026406, + 0x00000007, 0x1c01f000, 0x8166c9c0, 0x0400001c, + 0x41626000, 0x41580000, 0x59300a03, 0x82040d80, + 0x00000000, 0x04000008, 0x83326400, 0x00000024, + 0x81300c80, 0x040017f9, 0x42026000, 0x0010d1c0, + 0x0401f7f6, 0x4933c857, 0x8166c840, 0x83300c00, + 0x00000024, 0x80040480, 0x04021006, 0x4006c000, + 0x4a026203, 0x00000008, 0x813261c0, 0x1c01f000, + 0x4202c000, 0x0010d1c0, 0x0401f7fa, 0x42000000, + 0x0010b854, 0x0201f800, 0x0010aa47, 0x4933c856, + 0x417a6000, 0x0401f7f5, 0x4933c857, 0x83380580, + 0x00000013, 0x0402000b, 0x59300004, 0x8c00053e, + 0x04000007, 0x0201f800, 0x00106c55, 0x0201f800, + 0x00106bbf, 0x0201f800, 0x00106c4b, 0x1c01f000, + 0x4933c857, 0x59880052, 0x80000000, 0x48031052, + 0x1c01f000, 0x4933c857, 0x59300203, 0x82003480, + 0x0000000e, 0x02021800, 0x001005d8, 0x4d2c0000, + 0x0c01f803, 0x5c025800, 0x1c01f000, 0x00107991, + 0x00107efd, 0x0010804a, 0x00107991, 0x001080b0, + 0x00107af5, 0x00107991, 0x00107991, 0x00107e93, + 0x00107991, 0x00107991, 0x00107991, 0x00107991, + 0x00107991, 0x0201f800, 0x001005d8, 0x4933c857, + 0x59300203, 0x82003480, 0x0000000e, 0x02021800, + 0x001005d8, 0x0c01f001, 0x001079a8, 0x00108a3d, + 0x001079a8, 0x001079a8, 0x001079a8, 0x001079a8, + 0x001079a8, 0x001079a8, 0x001089e5, 0x00108a58, + 0x00108ac6, 0x00108a58, 0x00108ac6, 0x001079a8, + 0x0201f800, 0x001005d8, 0x0201f800, 0x001005d8, + 0x4933c857, 0x4d2c0000, 0x59325808, 0x59300203, + 0x82003480, 0x0000000e, 0x02021800, 0x001005d8, + 0x0c01f803, 0x5c025800, 0x1c01f000, 0x001079c5, + 0x001079c5, 0x001079c5, 0x001079e1, 0x00107a2d, + 0x001079c5, 0x001079c5, 0x001079c5, 0x001079c7, + 0x001079c5, 0x001079c5, 0x001079c5, 0x001079c5, + 0x001079c5, 0x0201f800, 0x001005d8, 0x4933c857, + 0x83380580, 0x00000040, 0x02020800, 0x001005d8, + 0x4a026007, 0x00082000, 0x4a026203, 0x00000003, + 0x493a6403, 0x4a025c08, 0x00000001, 0x592c000d, + 0x48026011, 0x497a6013, 0x592c0208, 0x800000c2, + 0x800010c4, 0x80081400, 0x480a6206, 0x0201f800, + 0x00100f4e, 0x42000800, 0x80000060, 0x0201f000, + 0x00106721, 0x4933c857, 0x83380480, 0x00000050, + 0x02021800, 0x001005d8, 0x83380480, 0x00000049, + 0x02001800, 0x001005d8, 0x0c01f001, 0x001079f4, + 0x001079ff, 0x001079f2, 0x001079f2, 0x001079f2, + 0x001079f2, 0x00107a0a, 0x0201f800, 0x001005d8, + 0x4a026203, 0x00000004, 0x4a025c08, 0x00000002, + 0x592c0207, 0x48025c09, 0x592c0209, 0x48025a07, + 0x592c000c, 0x4802580d, 0x1c01f000, 0x0201f800, + 0x00106b8a, 0x0201f800, 0x00109037, 0x04000005, + 0x4a025a06, 0x00000006, 0x0201f800, 0x000202da, + 0x0201f000, 0x0002077d, 0x0201f800, 0x00106b8a, + 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c, + 0x5c027800, 0x42003000, 0x00000014, 0x41782800, + 0x42002000, 0x00000002, 0x4d400000, 0x4d440000, + 0x59368c03, 0x42028000, 0x00000029, 0x0201f800, + 0x0010985e, 0x5c028800, 0x5c028000, 0x42000000, + 0x0010b864, 0x0201f800, 0x0010aa47, 0x0201f800, + 0x00109037, 0x02000000, 0x0002077d, 0x4a025a06, + 0x00000029, 0x0201f800, 0x000202da, 0x0201f000, + 0x0002077d, 0x4933c857, 0x83380580, 0x00000048, + 0x04000005, 0x83380580, 0x00000053, 0x02020800, + 0x001005d8, 0x592c0206, 0x82000580, 0x00000007, + 0x04000009, 0x59300011, 0x80000540, 0x04000006, + 0x592c080c, 0x80040480, 0x4802580c, 0x4a025a06, + 0x00000015, 0x592c0206, 0x80000540, 0x04020003, + 0x4a025a06, 0x00000000, 0x0201f800, 0x000202da, + 0x0201f000, 0x0002077d, 0x4933c857, 0x4d2c0000, + 0x4c500000, 0x4c540000, 0x4c580000, 0x0201f800, + 0x001007e4, 0x02000800, 0x001005d8, 0x497a5a06, + 0x59c80017, 0x82000500, 0x0000f000, 0x48025c07, + 0x59a80816, 0x82040c00, 0x00000018, 0x48065a07, + 0x412c7800, 0x4d2c0000, 0x41cca000, 0x42002800, + 0x00000001, 0x42001000, 0x0000002c, 0x82040480, + 0x0000002d, 0x04021006, 0x832cac00, 0x00000009, + 0x0201f800, 0x00108b96, 0x0401f02e, 0x40043000, + 0x42000800, 0x0000002c, 0x832cac00, 0x00000009, + 0x0201f800, 0x00108b96, 0x82183480, 0x0000002c, + 0x0201f800, 0x001007e4, 0x0400001a, 0x80142800, + 0x4a025804, 0x00000110, 0x492c7801, 0x82180c80, + 0x0000003d, 0x04021007, 0x40180800, 0x832cac00, + 0x00000005, 0x0201f800, 0x00108b96, 0x0401f015, + 0x82081400, 0x0000003c, 0x82183480, 0x0000003c, + 0x42000800, 0x0000003c, 0x412c7800, 0x832cac00, + 0x00000005, 0x0201f800, 0x00108b96, 0x0401f7e5, + 0x5c025800, 0x592c0206, 0x8400055e, 0x48025a06, + 0x592c0407, 0x80080540, 0x48025c07, 0x0401f002, + 0x5c025800, 0x813669c0, 0x04000003, 0x59343403, + 0x0401f003, 0x42003000, 0x0000ffff, 0x49325808, + 0x481a5c06, 0x82100580, 0x00000054, 0x04020002, + 0x491e5813, 0x841401c0, 0x80100540, 0x48025804, + 0x592c0001, 0x497a5801, 0x4c000000, 0x0201f800, + 0x000202da, 0x5c025800, 0x812e59c0, 0x040207f9, + 0x5c00b000, 0x5c00a800, 0x5c00a000, 0x5c025800, + 0x1c01f000, 0x4803c856, 0x4c5c0000, 0x4d2c0000, + 0x4c500000, 0x4c540000, 0x4c580000, 0x412cb800, + 0x592c040b, 0x8c000516, 0x04000003, 0x41cca000, + 0x0401f003, 0x83cca400, 0x00000006, 0x4008b000, + 0x41781000, 0x82580480, 0x00000012, 0x04001004, + 0x4200b000, 0x00000012, 0x40001000, 0x4c080000, + 0x4d2c0000, 0x0201f800, 0x001007e4, 0x04000023, + 0x5c001800, 0x492c1801, 0x485a5800, 0x832cac00, + 0x00000002, 0x0201f800, 0x0010ab28, 0x585c040b, + 0x8c000500, 0x0400000e, 0x832c1400, 0x00000002, + 0x8c000516, 0x04000003, 0x82081400, 0x00000006, + 0x46001000, 0x00000001, 0x80081000, 0x46001000, + 0x00000900, 0x84000500, 0x4800bc0b, 0x5c001000, + 0x800811c0, 0x040207da, 0x82000540, 0x00000001, + 0x5c00b000, 0x5c00a800, 0x5c00a000, 0x5c025800, + 0x5c00b800, 0x1c01f000, 0x5c025800, 0x5c001000, + 0x0401f7f8, 0x4933c857, 0x83380d80, 0x00000015, + 0x04020003, 0x0201f000, 0x0002077d, 0x83380d80, + 0x00000016, 0x02020800, 0x001005d8, 0x0201f000, + 0x0002077d, 0x4933c857, 0x4d2c0000, 0x4c500000, + 0x4c540000, 0x4c580000, 0x59325808, 0x83cca400, + 0x00000006, 0x59cc1806, 0x820c0580, 0x01000000, + 0x04020004, 0x4200b000, 0x00000002, 0x0401f00f, + 0x4200b000, 0x00000008, 0x832cac00, 0x00000005, + 0x0201f800, 0x0010ab17, 0x8c0c1d00, 0x0400000b, + 0x4200b000, 0x00000008, 0x592e5801, 0x812e59c0, + 0x02000800, 0x001005d8, 0x832cac00, 0x00000005, + 0x0201f800, 0x0010ab17, 0x0401f816, 0x5c00b000, + 0x5c00a800, 0x5c00a000, 0x5c025800, 0x1c01f000, + 0x4933c857, 0x4c500000, 0x4c540000, 0x4c580000, + 0x83cca400, 0x00000006, 0x5930a808, 0x8254ac00, + 0x00000005, 0x4200b000, 0x00000007, 0x0201f800, + 0x0010ab17, 0x5c00b000, 0x5c00a800, 0x5c00a000, + 0x4933c857, 0x0201f800, 0x00109037, 0x02000000, + 0x0002077d, 0x4d2c0000, 0x0201f800, 0x00109597, + 0x0402000b, 0x41780800, 0x4d400000, 0x42028000, + 0x00000000, 0x0201f800, 0x0010943b, 0x5c028000, + 0x5c025800, 0x0201f000, 0x0002077d, 0x5931d821, + 0x58ef400b, 0x58ee580d, 0x4a025a04, 0x00000103, + 0x58ec0009, 0x0801f800, 0x5c025800, 0x0201f000, + 0x0002077d, 0x4933c857, 0x59cc1806, 0x820c0580, + 0x02000000, 0x04020014, 0x4a026802, 0x00fffffd, + 0x5934000a, 0x84000504, 0x4802680a, 0x59300808, + 0x800409c0, 0x02000000, 0x0002077d, 0x4a000a04, + 0x00000103, 0x480c0805, 0x5931d821, 0x58ef400b, + 0x58ee580d, 0x58ec0009, 0x0801f800, 0x0201f000, + 0x0002077d, 0x42000000, 0x0010b86c, 0x0201f800, + 0x0010aa47, 0x4c0c0000, 0x0401f804, 0x5c001800, + 0x040207eb, 0x1c01f000, 0x4933c857, 0x4d2c0000, + 0x59325808, 0x812e59c0, 0x04020009, 0x497a6206, + 0x497a6205, 0x4d380000, 0x42027000, 0x00000022, + 0x0401fb77, 0x5c027000, 0x80000580, 0x5c025800, + 0x1c01f000, 0x4933c857, 0x4d2c0000, 0x4c500000, + 0x4c540000, 0x4c580000, 0x59325808, 0x592e5801, + 0x832cac00, 0x00000005, 0x83cca400, 0x00000006, + 0x59c80817, 0x82040d00, 0x000003ff, 0x82041480, + 0x0000000f, 0x0400101b, 0x4200b000, 0x0000000f, + 0x0201f800, 0x0010ab17, 0x592e5801, 0x832cac00, + 0x00000005, 0x82080c80, 0x0000000f, 0x0400100d, + 0x4200b000, 0x0000000f, 0x0201f800, 0x0010ab17, + 0x592e5801, 0x832cac00, 0x00000005, 0x82041480, + 0x0000000f, 0x04001007, 0x42001000, 0x0000000f, + 0x4008b000, 0x0201f800, 0x0010ab17, 0x0401f004, + 0x4004b000, 0x0201f800, 0x0010ab17, 0x5931d821, + 0x58ef400b, 0x58ee580d, 0x4a025a04, 0x00000103, + 0x592e5801, 0x58ec0009, 0x0801f800, 0x0201f800, + 0x0002077d, 0x5c00b000, 0x5c00a800, 0x5c00a000, + 0x5c025800, 0x1c01f000, 0x4933c857, 0x4d2c0000, + 0x4c500000, 0x4c540000, 0x4c580000, 0x59cc0006, + 0x82000d80, 0x01000000, 0x0400002c, 0x59cc0007, + 0x9000b1c0, 0x8258b500, 0x000000ff, 0x8058b104, + 0x8258b400, 0x00000002, 0x82580c80, 0x00000007, + 0x04001003, 0x4200b000, 0x00000006, 0x83cca400, + 0x00000006, 0x59301008, 0x800811c0, 0x02000800, + 0x001005d8, 0x8208ac00, 0x00000005, 0x0201f800, + 0x0010ab17, 0x82000d00, 0xff000000, 0x800409c0, + 0x04000019, 0x8200b500, 0x000000ff, 0x8058b104, + 0x82580c80, 0x0000000e, 0x04001003, 0x4200b000, + 0x0000000d, 0x58081001, 0x800811c0, 0x02000800, + 0x001005d8, 0x8208ac00, 0x00000005, 0x0201f800, + 0x0010ab17, 0x0401f008, 0x59301008, 0x800811c0, + 0x02000800, 0x001005d8, 0x48001005, 0x59cc0007, + 0x48001006, 0x0401ff3b, 0x5c00b000, 0x5c00a800, + 0x5c00a000, 0x5c025800, 0x1c01f000, 0x4933c857, + 0x42000800, 0x00000000, 0x59cc0006, 0x82000580, + 0x02000000, 0x04000003, 0x42000800, 0x00000001, + 0x4d2c0000, 0x59325808, 0x812e59c0, 0x02000800, + 0x001005d8, 0x48065a06, 0x0201f800, 0x000202da, + 0x5c025800, 0x0201f000, 0x0002077d, 0x4933c857, + 0x4d2c0000, 0x4c500000, 0x4c540000, 0x4c580000, + 0x4200b000, 0x00000002, 0x59cc0806, 0x82040580, + 0x01000000, 0x04000004, 0x8204b500, 0x0000ffff, + 0x8058b104, 0x83cca400, 0x00000006, 0x59300008, + 0x8200ac00, 0x00000005, 0x0201f800, 0x0010ab17, + 0x0401ff0c, 0x5c00b000, 0x5c00a800, 0x5c00a000, + 0x5c025800, 0x1c01f000, 0x4933c857, 0x4803c857, + 0x4807c857, 0x480bc857, 0x480fc857, 0x4813c857, + 0x481bc857, 0x492fc857, 0x4d2c0000, 0x4c000000, + 0x0201f800, 0x001007d3, 0x5c000000, 0x0400000f, + 0x48025803, 0x5c000000, 0x4802580a, 0x4c000000, + 0x481a5801, 0x48125809, 0x48065804, 0x480a5807, + 0x480e5808, 0x412c1000, 0x0201f800, 0x00100858, + 0x82000540, 0x00000001, 0x5c025800, 0x1c01f000, + 0x4933c857, 0x4d1c0000, 0x59cc0001, 0x82000500, + 0x00ffffff, 0x59341002, 0x82081500, 0x00ffffff, + 0x80080580, 0x0402001f, 0x497a6205, 0x4d380000, + 0x42027000, 0x00000035, 0x0201f800, 0x001093ba, + 0x5c027000, 0x04020012, 0x591c001c, 0x800001c0, + 0x0400000f, 0x497a381c, 0x591c0414, 0x8c000502, + 0x02000800, 0x001005d8, 0x84000502, 0x48023c14, + 0x591c1406, 0x82080580, 0x00000003, 0x04000006, + 0x82080580, 0x00000006, 0x04000005, 0x0401fc9e, + 0x0401f004, 0x0401f805, 0x0401f002, 0x0401f8c0, + 0x5c023800, 0x1c01f000, 0x4d2c0000, 0x591e5808, + 0x4933c857, 0x491fc857, 0x493bc857, 0x492fc857, + 0x83380580, 0x00000015, 0x040000b3, 0x83380580, + 0x00000016, 0x040200ae, 0x4d300000, 0x411e6000, + 0x59cc0207, 0x4803c857, 0x82000d00, 0x0000ff00, + 0x82040580, 0x00001700, 0x04000004, 0x82040580, + 0x00000300, 0x0402005b, 0x591c0203, 0x4803c857, + 0x82000580, 0x0000000d, 0x0400003f, 0x812e59c0, + 0x0400009a, 0x591c0202, 0x4803c857, 0x82000580, + 0x0000ffff, 0x0402007e, 0x592c020a, 0x4803c857, + 0x82000500, 0x00000003, 0x82000580, 0x00000002, + 0x04020007, 0x592c080f, 0x591c0011, 0x4803c857, + 0x4807c857, 0x80040580, 0x04020071, 0x591c0414, + 0x4803c857, 0x8c000500, 0x0402006d, 0x41780800, + 0x591c1206, 0x42000000, 0x0000000a, 0x0201f800, + 0x001066a0, 0x592c0406, 0x4803c857, 0x800001c0, + 0x0400000c, 0x80080c80, 0x04001004, 0x02020800, + 0x001005d8, 0x80001040, 0x480a5c06, 0x800811c0, + 0x04020004, 0x0201f800, 0x00108d88, 0x0401f06b, + 0x0201f800, 0x0010912a, 0x591c0817, 0x591c0018, + 0x48065808, 0x48025809, 0x59300007, 0x8c000500, + 0x02020800, 0x00100e99, 0x497a3808, 0x0201f800, + 0x000201ba, 0x0402004a, 0x411e6000, 0x0401fc3e, + 0x0401f05a, 0x0401fc6d, 0x04000013, 0x49366009, + 0x4a026406, 0x00000003, 0x492e6008, 0x591c0817, + 0x591c1018, 0x48066017, 0x480a6018, 0x4d380000, + 0x591e7403, 0x4d300000, 0x411e6000, 0x0401fc2e, + 0x5c026000, 0x0201f800, 0x000207a1, 0x5c027000, + 0x0401f046, 0x59a80039, 0x48023a05, 0x0401f043, + 0x59cc0407, 0x82000580, 0x0000000b, 0x04020025, + 0x59340a00, 0x84040d0e, 0x48066a00, 0x592c0a04, + 0x82040d00, 0x000000ff, 0x82040d80, 0x00000014, + 0x04000003, 0x4a02621d, 0x00000003, 0x59300007, + 0x8c000500, 0x02020800, 0x00100e99, 0x4d400000, + 0x42028000, 0x00000003, 0x592c0a08, 0x0201f800, + 0x00104e70, 0x0201f800, 0x000202da, 0x5c028000, + 0x497a6008, 0x4a026403, 0x00000085, 0x4a026203, + 0x00000009, 0x4a026406, 0x00000002, 0x42000800, + 0x8000404b, 0x0201f800, 0x00020721, 0x0401f01b, + 0x59cc0207, 0x82000580, 0x00002a00, 0x04020004, + 0x59a80039, 0x48023a05, 0x0401f014, 0x812e59c0, + 0x02000800, 0x001005d8, 0x4a025a04, 0x00000103, + 0x591c0007, 0x8c000500, 0x02020800, 0x00100e99, + 0x591c0402, 0x48025c06, 0x4a025a06, 0x00000003, + 0x0201f800, 0x000202c1, 0x0201f800, 0x00107911, + 0x0201f800, 0x001049b2, 0x5c026000, 0x0201f800, + 0x0002077d, 0x0401f002, 0x5c026000, 0x5c025800, + 0x1c01f000, 0x0401f819, 0x0401f7fd, 0x4933c857, + 0x83380580, 0x00000015, 0x04020004, 0x59a80039, + 0x48023a05, 0x0401f00d, 0x83380580, 0x00000016, + 0x0402000d, 0x4d300000, 0x411e6000, 0x0201f800, + 0x0010a5df, 0x0201f800, 0x000206fd, 0x0201f800, + 0x0002077d, 0x5c026000, 0x497a381c, 0x0201f800, + 0x0002077d, 0x1c01f000, 0x591c0414, 0x84000540, + 0x48023c14, 0x59cc100b, 0x4933c857, 0x491fc857, + 0x492fc857, 0x4803c857, 0x480bc857, 0x8c08153c, + 0x04000006, 0x59a80039, 0x48023a05, 0x497a381c, + 0x0201f000, 0x0002077d, 0x4d300000, 0x411e6000, + 0x0201f800, 0x00108bd7, 0x5c026000, 0x591c0406, + 0x82000580, 0x00000000, 0x02000000, 0x0002077d, + 0x591c0403, 0x82000580, 0x00000050, 0x0402000d, + 0x4d300000, 0x411e6000, 0x4a026203, 0x00000001, + 0x42000800, 0x80000043, 0x0201f800, 0x00020721, + 0x5c026000, 0x497a381c, 0x0201f000, 0x0002077d, + 0x591c0203, 0x82000580, 0x0000000d, 0x04000014, + 0x812e59c0, 0x02000800, 0x001005d8, 0x591c0203, + 0x82000580, 0x00000004, 0x04020011, 0x592c020a, + 0x8c000502, 0x0400000e, 0x4a023812, 0x0fffffff, + 0x592c0208, 0x8400051e, 0x48025a08, 0x42000000, + 0x00000001, 0x48023a14, 0x0401f021, 0x42000000, + 0x00000007, 0x48023a14, 0x0401f01d, 0x592c020a, + 0x4803c857, 0x8c000500, 0x0402000b, 0x8c000502, + 0x040007f7, 0x591c0414, 0x8c00051c, 0x040207eb, + 0x591c0011, 0x4803c857, 0x800001c0, 0x040007f0, + 0x0401f7e6, 0x8c08153a, 0x040207ed, 0x59cc000a, + 0x592c180f, 0x4803c857, 0x480fc857, 0x800c0580, + 0x040007e7, 0x59cc000a, 0x4803c857, 0x48023816, + 0x42000000, 0x00000005, 0x48023a14, 0x0201f000, + 0x00109259, 0x4933c857, 0x4d1c0000, 0x59cc0001, + 0x59341002, 0x80080580, 0x82000500, 0x00ffffff, + 0x04020041, 0x59301419, 0x0201f800, 0x00109410, + 0x02000800, 0x001005d8, 0x591c1406, 0x82080580, + 0x00000007, 0x04000038, 0x82080580, 0x00000002, + 0x04000035, 0x82080580, 0x00000000, 0x04000032, + 0x591c0202, 0x82000d80, 0x0000ffff, 0x04000004, + 0x59301a19, 0x800c0580, 0x0402002b, 0x83380580, + 0x00000015, 0x04000026, 0x4d300000, 0x4d2c0000, + 0x411e6000, 0x59325808, 0x0201f800, 0x00109037, + 0x02000800, 0x001005d8, 0x592c0204, 0x82000500, + 0x000000ff, 0x82000580, 0x00000014, 0x04000003, + 0x4a02621d, 0x00000003, 0x42028000, 0x00000003, + 0x592c0a08, 0x0201f800, 0x00104e70, 0x0201f800, + 0x000202da, 0x5c025800, 0x497a6008, 0x4a026403, + 0x00000085, 0x4a026203, 0x00000009, 0x4a026406, + 0x00000002, 0x42000800, 0x8000404b, 0x0201f800, + 0x00020721, 0x5c026000, 0x0401f003, 0x59a80039, + 0x48023a05, 0x497a381c, 0x0201f800, 0x0002077d, + 0x5c023800, 0x1c01f000, 0x4933c857, 0x4c580000, + 0x4d2c0000, 0x59325808, 0x83383580, 0x00000015, + 0x04000010, 0x59342200, 0x84102502, 0x48126a00, + 0x0201f800, 0x00109037, 0x04000066, 0x0201f800, + 0x00109597, 0x04020005, 0x4200b000, 0x00000002, + 0x0201f800, 0x0010957d, 0x0401fa0a, 0x0401f079, + 0x83cc1400, 0x00000008, 0x4200b000, 0x00000002, + 0x83341c00, 0x00000006, 0x0201f800, 0x0010855a, + 0x04020015, 0x83cc1400, 0x0000000a, 0x4200b000, + 0x00000002, 0x83341c00, 0x00000008, 0x0201f800, + 0x0010855a, 0x0402000c, 0x0201f800, 0x00102074, + 0x59342200, 0x59cc1007, 0x800811c0, 0x04000003, + 0x480a6801, 0x84102542, 0x8410251a, 0x48126a00, + 0x0401f05f, 0x4d3c0000, 0x417a7800, 0x0201f800, + 0x0010203c, 0x5c027800, 0x42000000, 0x0010b864, + 0x0201f800, 0x0010aa47, 0x59340200, 0x84000558, + 0x48026a00, 0x4d300000, 0x0201f800, 0x0002075a, + 0x02000800, 0x001005d8, 0x49366009, 0x497a6008, + 0x4a026406, 0x00000001, 0x4a026403, 0x00000001, + 0x42003000, 0x00000003, 0x0201f800, 0x0010a942, + 0x0201f800, 0x00103b25, 0x04000011, 0x41782800, + 0x42003000, 0x00000001, 0x4d400000, 0x42028000, + 0x00000029, 0x0201f800, 0x0010a43e, 0x5c028000, + 0x4a026406, 0x00000004, 0x4a026203, 0x00000007, + 0x4a026420, 0x00000001, 0x0401f009, 0x4a026203, + 0x00000001, 0x42000800, 0x0000000b, 0x0201f800, + 0x00104571, 0x0201f800, 0x0010672b, 0x5c026000, + 0x0201f800, 0x00109037, 0x04000022, 0x0201f800, + 0x00109597, 0x04020022, 0x0401f9ae, 0x0401f01d, + 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x59340200, 0x84000558, 0x48026a00, 0x42003000, + 0x00000003, 0x41782800, 0x42002000, 0x00000005, + 0x4d400000, 0x4d440000, 0x59368c03, 0x42028000, + 0x00000029, 0x0201f800, 0x0010985e, 0x5c028800, + 0x5c028000, 0x5c027800, 0x0201f800, 0x00102074, + 0x0201f800, 0x0002077d, 0x0401f002, 0x0401fca9, + 0x5c025800, 0x5c00b000, 0x1c01f000, 0x4933c857, + 0x41380000, 0x83383480, 0x00000056, 0x02021800, + 0x001005d8, 0x0c01f001, 0x00107ef7, 0x00107ef2, + 0x00107ef7, 0x00107ef7, 0x00107ef7, 0x00107ef7, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef7, 0x00107ef0, 0x00107ef7, + 0x00107ef7, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef7, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef7, 0x00107ef7, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7, + 0x00107ef0, 0x00107ef0, 0x00107ef7, 0x00107ef7, + 0x00107ef0, 0x00107ef7, 0x00107ef7, 0x00107ef0, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7, + 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7, + 0x0201f800, 0x001005d8, 0x4a026203, 0x00000001, + 0x493a6403, 0x0201f000, 0x0010672b, 0x4933c857, + 0x4a026203, 0x00000001, 0x493a6403, 0x0201f000, + 0x0010672b, 0x4933c857, 0x59300403, 0x82003480, + 0x00000056, 0x02021800, 0x001005d8, 0x83383580, + 0x00000013, 0x04000093, 0x83383580, 0x00000027, + 0x0402004b, 0x0201f800, 0x00106bbf, 0x0201f800, + 0x00109134, 0x0400000b, 0x0201f800, 0x0010914e, + 0x04000041, 0x59300403, 0x82000d80, 0x00000022, + 0x04020038, 0x0401fc61, 0x0400003a, 0x0401f03a, + 0x0201f800, 0x00102074, 0x42000800, 0x00000007, + 0x0201f800, 0x00104571, 0x0401f8fe, 0x4d440000, + 0x59368c03, 0x83440580, 0x000007fe, 0x04020008, + 0x59a81026, 0x84081540, 0x0201f800, 0x0010513b, + 0x04020002, 0x8408154a, 0x480b5026, 0x42028000, + 0x00000029, 0x4d3c0000, 0x417a7800, 0x0201f800, + 0x0010203c, 0x5c027800, 0x836c0580, 0x00000003, + 0x0400000c, 0x59326809, 0x59340008, 0x800001c0, + 0x04020008, 0x59368c03, 0x4933c857, 0x4937c857, + 0x4947c857, 0x0201f800, 0x001045fb, 0x0401f00c, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x42003000, 0x00000015, 0x41782800, 0x42002000, + 0x00000003, 0x0201f800, 0x0010985e, 0x5c028800, + 0x0201f800, 0x00109326, 0x0201f000, 0x0002077d, + 0x1c01f000, 0x0401f8cb, 0x0401f7fa, 0x83380580, + 0x00000014, 0x0400000b, 0x0201f800, 0x00106f60, + 0x02020000, 0x00107974, 0x59300203, 0x82000580, + 0x00000002, 0x040000ed, 0x0201f800, 0x001005d8, + 0x0201f800, 0x00106bbf, 0x4d3c0000, 0x417a7800, + 0x0201f800, 0x0010203c, 0x5c027800, 0x42003000, + 0x00000016, 0x41782800, 0x4d400000, 0x4d440000, + 0x59368c03, 0x42002000, 0x00000009, 0x42028000, + 0x00000029, 0x0201f800, 0x0010985e, 0x5c028800, + 0x5c028000, 0x42000000, 0x0010b864, 0x0201f800, + 0x0010aa47, 0x0201f800, 0x00109134, 0x0402000c, + 0x0201f800, 0x00102074, 0x0401f89e, 0x59340c03, + 0x82040580, 0x000007fe, 0x040207ca, 0x59a80826, + 0x84040d40, 0x48075026, 0x0401f7c6, 0x0201f800, + 0x0010914e, 0x04020003, 0x0401f892, 0x0401f7c1, + 0x59300403, 0x82000d80, 0x00000032, 0x04020004, + 0x0201f800, 0x0010230c, 0x0401f7ba, 0x59300403, + 0x82000d80, 0x00000022, 0x04000886, 0x0401f7b5, + 0x4803c857, 0x0c01f001, 0x00108016, 0x00108016, + 0x00108016, 0x00108016, 0x00108016, 0x00108016, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00107ff9, 0x00108016, 0x00107ff0, 0x00108016, + 0x00108016, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00107ff0, 0x00107ff0, 0x00108016, 0x00108016, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0, + 0x00108007, 0x00108016, 0x00107ff0, 0x00108000, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108000, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016, + 0x00108003, 0x00107ff0, 0x00107ff2, 0x00108016, + 0x00107ff0, 0x00108016, 0x00108016, 0x00107ff0, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016, + 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016, + 0x0201f800, 0x001005d8, 0x4d2c0000, 0x59325808, + 0x0201f800, 0x000202da, 0x5c025800, 0x0201f000, + 0x0002077d, 0x4a026203, 0x00000005, 0x59a80039, + 0x48026205, 0x59a80037, 0x48026206, 0x1c01f000, + 0x5930081e, 0x49780a05, 0x0401f014, 0x0201f800, + 0x00109326, 0x0201f000, 0x0002077d, 0x0201f800, + 0x0010230c, 0x0201f800, 0x00106c55, 0x04000005, + 0x0201f800, 0x00106bbf, 0x0201f000, 0x0002077d, + 0x0201f800, 0x00106bbf, 0x0201f800, 0x0002077d, + 0x0201f000, 0x00106c4b, 0x4933c857, 0x4a026203, + 0x00000002, 0x59a80037, 0x48026206, 0x1c01f000, + 0x4933c857, 0x0201f800, 0x00109037, 0x0400002a, + 0x4d2c0000, 0x0201f800, 0x00109597, 0x0402000a, + 0x4d400000, 0x42028000, 0x00000031, 0x42000800, + 0x00000004, 0x0201f800, 0x0010943b, 0x5c028000, + 0x0401f01c, 0x59300c06, 0x82040580, 0x00000010, + 0x04000004, 0x82040580, 0x00000011, 0x0402000a, + 0x4a025a06, 0x00000031, 0x4a02580d, 0x00000004, + 0x4a02580e, 0x000000ff, 0x0201f800, 0x000202da, + 0x0401f00c, 0x592c0404, 0x8c00051e, 0x04000009, + 0x4a025a04, 0x00000103, 0x4a025805, 0x01000000, + 0x5931d821, 0x58ef400b, 0x58ec0009, 0x0801f800, + 0x5c025800, 0x1c01f000, 0x4933c857, 0x59340400, + 0x82000500, 0x000000ff, 0x82003480, 0x0000000c, + 0x02021800, 0x001005d8, 0x59303403, 0x82180d80, + 0x0000004d, 0x02000000, 0x0010938b, 0x82180d80, + 0x00000033, 0x02000000, 0x00109349, 0x82180d80, + 0x00000028, 0x02000000, 0x0010918f, 0x82180d80, + 0x00000029, 0x02000000, 0x001091a3, 0x82180d80, + 0x0000001f, 0x02000000, 0x00107b28, 0x82180d80, + 0x00000055, 0x02000000, 0x00107b01, 0x82180d80, + 0x00000000, 0x04000591, 0x82180d80, 0x00000022, + 0x02000000, 0x00107b55, 0x82180d80, 0x00000035, + 0x02000000, 0x00107c50, 0x82180d80, 0x00000039, + 0x04000539, 0x82180d80, 0x0000003d, 0x02000000, + 0x00107b85, 0x82180d80, 0x00000044, 0x02000000, + 0x00107bc2, 0x82180d80, 0x00000049, 0x02000000, + 0x00107c17, 0x82180d80, 0x00000041, 0x02000000, + 0x00107c03, 0x82180d80, 0x00000043, 0x02000000, + 0x001094dc, 0x82180d80, 0x00000051, 0x02000000, + 0x00109542, 0x82180d80, 0x00000004, 0x04020003, + 0x42000000, 0x00000001, 0x83380d80, 0x00000015, + 0x04000006, 0x83380d80, 0x00000016, 0x02020000, + 0x00107974, 0x0401f20f, 0x4d2c0000, 0x4d3c0000, + 0x0c01f804, 0x5c027800, 0x5c025800, 0x1c01f000, + 0x001080b8, 0x001080bc, 0x001080b8, 0x00108131, + 0x001080b8, 0x00108226, 0x001082bf, 0x001080b8, + 0x001080b8, 0x00108288, 0x001080b8, 0x0010829a, + 0x4933c857, 0x497a6007, 0x59300808, 0x58040000, + 0x4a000a04, 0x00000103, 0x0201f000, 0x0002077d, + 0x4933c857, 0x40000000, 0x40000000, 0x1c01f000, + 0x4933c857, 0x59a80016, 0x82000580, 0x00000074, + 0x0402005c, 0x0201f800, 0x0010a2c8, 0x04020016, + 0x0401f85c, 0x0201f800, 0x00109037, 0x0400000c, + 0x0201f800, 0x00109597, 0x04020009, 0x41780800, + 0x4d400000, 0x42028000, 0x00000000, 0x0201f800, + 0x0010943b, 0x5c028000, 0x0401f003, 0x0201f800, + 0x00102074, 0x0201f800, 0x001048c1, 0x0201f000, + 0x0002077d, 0x0201f800, 0x00109037, 0x04000007, + 0x0201f800, 0x00109597, 0x04020004, 0x0401ff3d, + 0x0201f000, 0x0002077d, 0x417a7800, 0x0201f800, + 0x0010203c, 0x42000000, 0x0010b864, 0x0201f800, + 0x0010aa47, 0x59340200, 0x84000558, 0x48026a00, + 0x42003000, 0x00000003, 0x0201f800, 0x0010a942, + 0x4d300000, 0x0201f800, 0x0002075a, 0x02000800, + 0x001005d8, 0x49366009, 0x497a6008, 0x4a026406, + 0x00000001, 0x4a026403, 0x00000001, 0x0201f800, + 0x00103b25, 0x04000011, 0x4a026406, 0x00000004, + 0x4a026203, 0x00000007, 0x4a026420, 0x00000001, + 0x42003000, 0x00000001, 0x4d400000, 0x42028000, + 0x00000029, 0x41782800, 0x0201f800, 0x0010a43e, + 0x5c028000, 0x0401f009, 0x42000800, 0x0000000b, + 0x0201f800, 0x00104571, 0x4a026203, 0x00000001, + 0x0201f800, 0x0010672b, 0x5c026000, 0x0401ff05, + 0x0201f800, 0x00102074, 0x0201f000, 0x0002077d, + 0x0401ff00, 0x42000000, 0x00000001, 0x0401f0c7, + 0x4933c857, 0x59340200, 0x8c000500, 0x0400000d, + 0x4d3c0000, 0x417a7800, 0x0201f800, 0x00104567, + 0x5c027800, 0x0201f800, 0x00103b25, 0x04000005, + 0x42000800, 0x00000006, 0x0201f800, 0x00104571, + 0x1c01f000, 0x4933c857, 0x59a80816, 0x82040580, + 0x00000074, 0x0400000e, 0x4807c857, 0x82040580, + 0x00000100, 0x040200a0, 0x59cc0408, 0x4803c857, + 0x8c000500, 0x0400009c, 0x59341403, 0x82080580, + 0x000007fe, 0x04000006, 0x0401f097, 0x59341403, + 0x82080580, 0x000007fe, 0x04020003, 0x0401fa9c, + 0x0401f04c, 0x0201f800, 0x0010462a, 0x59341403, + 0x82080580, 0x000007fc, 0x0402001f, 0x4a026802, + 0x00fffffc, 0x0201f800, 0x00109037, 0x04000012, + 0x0201f800, 0x00109597, 0x0402000f, 0x0401f8a9, + 0x41780800, 0x4d400000, 0x42028000, 0x00000000, + 0x0201f800, 0x0010943b, 0x5c028000, 0x42000800, + 0x00000004, 0x0201f800, 0x00104571, 0x0201f000, + 0x0002077d, 0x42000800, 0x00000004, 0x0201f800, + 0x00104571, 0x0201f800, 0x00102074, 0x0201f000, + 0x0002077d, 0x59a80005, 0x8c000514, 0x04000011, + 0x0201f800, 0x0010513b, 0x42001000, 0x00000010, + 0x04020009, 0x59340002, 0x82000500, 0x00ff0000, + 0x82000580, 0x00ff0000, 0x04000006, 0x42001000, + 0x00000008, 0x0201f800, 0x00104c6d, 0x0402005a, + 0x0201f800, 0x00109037, 0x0400005b, 0x0201f800, + 0x00109597, 0x04020005, 0x592c0404, 0x8c00051c, + 0x040207c9, 0x0401f877, 0x42000800, 0x00000005, + 0x0201f800, 0x00104571, 0x4a026203, 0x00000001, + 0x4a026403, 0x00000003, 0x0201f000, 0x0010672b, + 0x59cc0408, 0x8c000518, 0x04000010, 0x0201f800, + 0x001092e5, 0x0201f800, 0x0010513b, 0x04000004, + 0x59cc0408, 0x8c000516, 0x040207b3, 0x59a80026, + 0x8400054a, 0x48035026, 0x59a80010, 0x84000570, + 0x48038832, 0x0401f7ac, 0x42001000, 0x000000ef, + 0x480b5010, 0x497b8830, 0x84081570, 0x480b8832, + 0x59c40802, 0x84040d4c, 0x48078802, 0x0201f800, + 0x0010930f, 0x59a80026, 0x84000548, 0x48035026, + 0x0201f800, 0x0010a3da, 0x0402079b, 0x59a80026, + 0x8400054c, 0x48035026, 0x42000800, 0x00000006, + 0x0201f800, 0x00104571, 0x417a7800, 0x0201f800, + 0x00104567, 0x42000000, 0x000000e8, 0x0201f800, + 0x00105c9a, 0x02000800, 0x001045a6, 0x02020800, + 0x001005d8, 0x49366009, 0x59340200, 0x8400051a, + 0x48026a00, 0x42000800, 0x00000003, 0x0201f800, + 0x00104571, 0x4a026406, 0x00000001, 0x4a026203, + 0x00000001, 0x4a026403, 0x00000002, 0x0201f000, + 0x0010672b, 0x0401fe43, 0x42000000, 0x00000001, + 0x0401f00a, 0x599c0017, 0x8c00050a, 0x040007ab, + 0x42000800, 0x00000004, 0x0201f800, 0x00104571, + 0x0201f000, 0x0002077d, 0x4933c857, 0x80003540, + 0x04000005, 0x42000800, 0x00000007, 0x0201f800, + 0x00104571, 0x801831c0, 0x0402000e, 0x59302008, + 0x801021c0, 0x04000004, 0x58100404, 0x8c00051e, + 0x04020008, 0x59341c03, 0x42002000, 0x00000004, + 0x42003000, 0x00000012, 0x0201f800, 0x00103aae, + 0x0201f800, 0x00102074, 0x0201f000, 0x0002077d, + 0x4c5c0000, 0x4d2c0000, 0x59325808, 0x0201f800, + 0x00105755, 0x5c025800, 0x59cc0008, 0x48002805, + 0x59cc0009, 0x48002806, 0x49782807, 0x49782808, + 0x49782809, 0x4978280a, 0x59cc0013, 0x8c00053e, + 0x04000009, 0x59cc0414, 0x900001c0, 0x59ccbc15, + 0x805c0540, 0x48002807, 0x59cc0416, 0x900001c0, + 0x48002808, 0x59cc0017, 0x8c00053e, 0x04000009, + 0x59cc0418, 0x900001c0, 0x59ccbc19, 0x805c0540, + 0x48002809, 0x59cc041a, 0x900001c0, 0x4800280a, + 0x5c00b800, 0x1c01f000, 0x4933c857, 0x59a80016, + 0x82000580, 0x00000014, 0x04020048, 0x59a80005, + 0x8c000514, 0x04000015, 0x0201f800, 0x0010513b, + 0x42001000, 0x00000010, 0x04020009, 0x59340002, + 0x82000500, 0x00ff0000, 0x82000580, 0x00ff0000, + 0x0400000a, 0x42001000, 0x00000008, 0x0201f800, + 0x00104c6d, 0x04000005, 0x59a80005, 0x84000556, + 0x48035005, 0x0401f031, 0x836c0580, 0x00000003, + 0x0402000b, 0x59300008, 0x80000540, 0x04020008, + 0x59341c03, 0x42002000, 0x00000006, 0x42003000, + 0x00000013, 0x0201f800, 0x00103aae, 0x0201f800, + 0x0010468d, 0x0401fecf, 0x0401fa1d, 0x0402001f, + 0x59340404, 0x80000540, 0x0400001c, 0x42000800, + 0x00000006, 0x0201f800, 0x00104571, 0x0201f800, + 0x00109037, 0x04000011, 0x0201f800, 0x00109597, + 0x0402000a, 0x41780800, 0x4d400000, 0x42028000, + 0x00000000, 0x0201f800, 0x0010943b, 0x5c028000, + 0x0201f000, 0x0002077d, 0x4a025a04, 0x00000103, + 0x4a025805, 0x02000000, 0x0201f800, 0x00102074, + 0x0201f000, 0x0002077d, 0x0201f800, 0x00104c19, + 0x0201f800, 0x00109037, 0x04000007, 0x0201f800, + 0x00109597, 0x04020004, 0x0401fda2, 0x0201f000, + 0x0002077d, 0x0401fd9f, 0x80000580, 0x59a80005, + 0x8c000516, 0x04000005, 0x84000516, 0x48035005, + 0x82000540, 0x00000001, 0x0401ff60, 0x1c01f000, + 0x4933c857, 0x59a80016, 0x82000580, 0x00000014, + 0x0402000b, 0x42000800, 0x0000000b, 0x0201f800, + 0x00104571, 0x4a026203, 0x00000001, 0x4a026403, + 0x00000001, 0x0201f000, 0x0010672b, 0x42000000, + 0x00000001, 0x0401f74d, 0x4933c857, 0x40003000, + 0x59a80016, 0x82000580, 0x00000004, 0x0402000a, + 0x82183580, 0x0000000b, 0x04020005, 0x42000800, + 0x00000007, 0x0201f800, 0x00104571, 0x0201f000, + 0x0002077d, 0x42000000, 0x00000001, 0x0401f73b, + 0x4803c857, 0x4d2c0000, 0x4d3c0000, 0x0c01f804, + 0x5c027800, 0x5c025800, 0x1c01f000, 0x001080b8, + 0x001082ce, 0x001080b8, 0x00108323, 0x001080b8, + 0x00108391, 0x001082bf, 0x001080b8, 0x001080b8, + 0x001083b1, 0x001080b8, 0x001083c1, 0x4933c857, + 0x4d1c0000, 0x59301403, 0x82080580, 0x00000003, + 0x04000008, 0x82081580, 0x0000001e, 0x04020003, + 0x0201f800, 0x0002077d, 0x5c023800, 0x1c01f000, + 0x0401ff5a, 0x0401f7fd, 0x4933c857, 0x0201f800, + 0x00109037, 0x0400000b, 0x0201f800, 0x00109597, + 0x04020008, 0x4200b000, 0x00000002, 0x0201f800, + 0x0010957d, 0x0401fd43, 0x0201f000, 0x0002077d, + 0x0401f8f5, 0x04020030, 0x417a7800, 0x0201f800, + 0x00104567, 0x417a7800, 0x0201f800, 0x0010203c, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x59340200, 0x84000558, 0x48026a00, 0x4a026403, + 0x00000002, 0x42003000, 0x00000003, 0x0201f800, + 0x0010a942, 0x0201f800, 0x00103b25, 0x04000011, + 0x4d400000, 0x41782800, 0x42003000, 0x00000005, + 0x42028000, 0x00000029, 0x0201f800, 0x0010a43e, + 0x5c028000, 0x4a026203, 0x00000007, 0x4a026406, + 0x00000004, 0x4a026420, 0x00000001, 0x1c01f000, + 0x42000800, 0x00000003, 0x0201f800, 0x00104571, + 0x4a026203, 0x00000001, 0x0201f800, 0x0010672b, + 0x0401f7f7, 0x59cc0407, 0x82000580, 0x00000009, + 0x0402000a, 0x59340412, 0x82000500, 0x000000ff, + 0x0400000c, 0x80000040, 0x48026c12, 0x4a026206, + 0x0000000a, 0x0401f7ea, 0x59cc0207, 0x82000500, + 0x0000ff00, 0x82000580, 0x00001900, 0x040007c2, + 0x0401fcfc, 0x80000580, 0x0401f6c4, 0x4933c857, + 0x59a80032, 0x80000540, 0x04000015, 0x59340403, + 0x82000580, 0x000007fe, 0x04020011, 0x59a80010, + 0x80000000, 0x48035010, 0x417a7800, 0x0201f800, + 0x00104567, 0x42000800, 0x00000003, 0x0201f800, + 0x00104571, 0x4a026203, 0x00000001, 0x4a026403, + 0x00000002, 0x0201f000, 0x0010672b, 0x0201f800, + 0x00109037, 0x04000011, 0x0201f800, 0x00109597, + 0x0402000e, 0x4c580000, 0x4200b000, 0x00000002, + 0x0201f800, 0x0010957d, 0x5c00b000, 0x0401fcd5, + 0x42000800, 0x00000007, 0x0201f800, 0x00104571, + 0x0201f000, 0x0002077d, 0x0401fcce, 0x59cc3407, + 0x82183500, 0x000000ff, 0x82180580, 0x00000005, + 0x0400001c, 0x82180580, 0x0000000b, 0x04000016, + 0x59cc0207, 0x82000500, 0x0000ff00, 0x04020004, + 0x82180580, 0x00000009, 0x04000012, 0x82000580, + 0x00001900, 0x0402000c, 0x82180580, 0x00000009, + 0x0400000c, 0x42000800, 0x00000004, 0x0201f800, + 0x00104571, 0x0201f800, 0x00102074, 0x0201f000, + 0x0002077d, 0x42000000, 0x00000001, 0x0401f677, + 0x0201f800, 0x00109037, 0x59325808, 0x04000008, + 0x592c0204, 0x82000580, 0x00000139, 0x040007f6, + 0x592c0404, 0x8c00051e, 0x040207f3, 0x59340403, + 0x82000580, 0x000007fe, 0x04020007, 0x59a80026, + 0x84000540, 0x48035026, 0x0201f800, 0x00104229, + 0x0401f7e9, 0x417a7800, 0x0201f800, 0x0010203c, + 0x42003000, 0x00000005, 0x0201f800, 0x0010a942, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x0401f7dd, 0x4933c857, 0x0401f84d, 0x0402000b, + 0x42000800, 0x00000005, 0x0201f800, 0x00104571, + 0x4a026203, 0x00000001, 0x4a026403, 0x00000003, + 0x0201f000, 0x0010672b, 0x42000800, 0x00000004, + 0x0201f800, 0x00104571, 0x0201f800, 0x00109597, + 0x0402000a, 0x4c580000, 0x4200b000, 0x00000002, + 0x0201f800, 0x0010957d, 0x5c00b000, 0x0401fc71, + 0x0201f000, 0x0002077d, 0x0401fc6e, 0x80000580, + 0x0401f636, 0x4933c857, 0x0401f82d, 0x0402000b, + 0x42000800, 0x00000009, 0x0201f800, 0x00104571, + 0x4a026203, 0x00000001, 0x4a026403, 0x00000005, + 0x0201f000, 0x0010672b, 0x42000000, 0x00000001, + 0x0401f626, 0x4933c857, 0x0401f81d, 0x0402000b, + 0x42000800, 0x0000000b, 0x0201f800, 0x00104571, + 0x4a026203, 0x00000001, 0x4a026403, 0x00000001, + 0x0201f000, 0x0010672b, 0x42000000, 0x00000001, + 0x0401f616, 0x4933c857, 0x59cc0407, 0x82000580, + 0x00000003, 0x04020009, 0x59cc0207, 0x82000500, + 0x0000ff00, 0x82000d80, 0x00002a00, 0x04000003, + 0x82000d80, 0x00001e00, 0x1c01f000, 0x4933c857, + 0x82000540, 0x00000001, 0x1c01f000, 0x4933c857, + 0x4d400000, 0x4c580000, 0x59a80026, 0x82000540, + 0x00000003, 0x48035026, 0x0401f85c, 0x04000038, + 0x4d340000, 0x4d440000, 0x59a80026, 0x84000552, + 0x48035026, 0x0201f800, 0x00103b25, 0x0400000c, + 0x42028000, 0x0000002a, 0x42028800, 0x0000ffff, + 0x42003000, 0x00000002, 0x0201f800, 0x0010a446, + 0x59a80805, 0x84040d44, 0x48075005, 0x42028000, + 0x0000002a, 0x4d3c0000, 0x42027800, 0x00000204, + 0x0201f800, 0x00101fe5, 0x5c027800, 0x42000000, + 0x0010b864, 0x0201f800, 0x0010aa47, 0x0201f800, + 0x00101e45, 0x4200b000, 0x00000010, 0x42028800, + 0x000007f0, 0x4d2c0000, 0x83440580, 0x000007fe, + 0x04000003, 0x0201f800, 0x001045fb, 0x81468800, + 0x8058b040, 0x040207f9, 0x5c025800, 0x59cc0408, + 0x8c00051e, 0x04000004, 0x59a80026, 0x84000512, + 0x48035026, 0x5c028800, 0x5c026800, 0x0201f800, + 0x0010462a, 0x4a026802, 0x00fffffe, 0x59a80826, + 0x84040d50, 0x59cc0013, 0x8c00053e, 0x04000003, + 0x8c000536, 0x04000004, 0x59cc0017, 0x8c000536, + 0x04020002, 0x84040d10, 0x48075026, 0x59cc0800, + 0x82040d00, 0x00ffffff, 0x48075010, 0x80040110, + 0x4803501d, 0x48038881, 0x0201f800, 0x0010513b, + 0x04000007, 0x59cc0009, 0x48035035, 0x59cc000a, + 0x48035036, 0x0201f800, 0x001092e5, 0x5c00b000, + 0x5c028000, 0x1c01f000, 0x4933c857, 0x4c580000, + 0x59a80010, 0x82000500, 0x00ffff00, 0x04000022, + 0x59cc1000, 0x82081500, 0x00ffff00, 0x80080580, + 0x04000004, 0x42000000, 0x0010b83b, 0x0401f016, + 0x83cc1400, 0x0000000b, 0x4200b000, 0x00000002, + 0x83341c00, 0x00000006, 0x0401f900, 0x04000004, + 0x42000000, 0x0010b83c, 0x0401f00b, 0x83cc1400, + 0x0000000d, 0x4200b000, 0x00000002, 0x83341c00, + 0x00000008, 0x0401f8f5, 0x04000007, 0x42000000, + 0x0010b83d, 0x0201f800, 0x0010aa47, 0x82000540, + 0x00000001, 0x5c00b000, 0x1c01f000, 0x4933c857, + 0x59cc0206, 0x82000580, 0x00000014, 0x04020016, + 0x59cc0407, 0x82000580, 0x00000800, 0x04020012, + 0x59cc0207, 0x8c00051a, 0x0400000d, 0x82000500, + 0x00000f00, 0x82000580, 0x00000100, 0x04020008, + 0x59cc020a, 0x8c000508, 0x04020003, 0x8c00050a, + 0x04000003, 0x80000580, 0x1c01f000, 0x82000540, + 0x00000001, 0x1c01f000, 0x4933c857, 0x4943c857, + 0x493fc857, 0x4c5c0000, 0x4d300000, 0x4d340000, + 0x4d2c0000, 0x4d380000, 0x4130b800, 0x42026000, + 0x0010d1c0, 0x59a8000e, 0x81640480, 0x040210bd, + 0x8d3e7d12, 0x04000004, 0x405c0000, 0x81300580, + 0x040000b3, 0x59300406, 0x82000c80, 0x00000012, + 0x04021015, 0x59326809, 0x0c01f001, 0x0010854f, + 0x001084bc, 0x001084d3, 0x001084de, 0x001084b7, + 0x001084ce, 0x00108507, 0x0010854f, 0x001084b5, + 0x0010851b, 0x0010852a, 0x001084b5, 0x001084b5, + 0x001084b5, 0x001084b5, 0x0010854f, 0x00108540, + 0x00108538, 0x0201f800, 0x001005d8, 0x8d3e7d18, + 0x04000004, 0x59300420, 0x8c000500, 0x04020094, + 0x59300403, 0x82000580, 0x00000043, 0x04000090, + 0x0201f800, 0x00109134, 0x02000800, 0x00102074, + 0x0201f800, 0x0010914e, 0x02000800, 0x0010801c, + 0x8d3e7d06, 0x04000084, 0x0201f800, 0x001092d7, + 0x04000083, 0x0401f080, 0x8d3e7d16, 0x04000004, + 0x59300420, 0x8c000500, 0x0402007d, 0x59325808, + 0x0201f800, 0x00109037, 0x04000077, 0x49425a06, + 0x497a5c09, 0x0201f800, 0x000202da, 0x0201f800, + 0x0010912a, 0x0401f070, 0x813669c0, 0x02000800, + 0x001005d8, 0x8d3e7d06, 0x04000004, 0x59340200, + 0x8c00050e, 0x0402006a, 0x59300004, 0x8400055c, + 0x48026004, 0x59300203, 0x82000580, 0x00000004, + 0x02000800, 0x00100e99, 0x59325808, 0x0201f800, + 0x00109037, 0x0400005c, 0x4a025a04, 0x00000103, + 0x59300402, 0x48025c06, 0x592c0408, 0x8c000512, + 0x04000006, 0x4d2c0000, 0x592e5809, 0x0201f800, + 0x001007fd, 0x5c025800, 0x49425a06, 0x497a5c09, + 0x0201f800, 0x0010959c, 0x0201f800, 0x000202da, + 0x0201f800, 0x0010912a, 0x0401f047, 0x8c000518, + 0x04000047, 0x59300203, 0x82000580, 0x00000004, + 0x02000800, 0x00100e99, 0x59325808, 0x0201f800, + 0x00109037, 0x0400003c, 0x49425a06, 0x497a5c09, + 0x0201f800, 0x0010a693, 0x0201f800, 0x0010959c, + 0x0201f800, 0x000202da, 0x0401f033, 0x0201f800, + 0x001062d5, 0x04000032, 0x59300203, 0x82000580, + 0x00000004, 0x04020004, 0x0201f800, 0x00100e99, + 0x0401f02b, 0x42027000, 0x00000047, 0x0201f800, + 0x000207a1, 0x0401f026, 0x59300203, 0x82000580, + 0x00000004, 0x02000800, 0x00100e99, 0x59325808, + 0x0201f800, 0x00109037, 0x0400001b, 0x49425a06, + 0x497a5c09, 0x0201f800, 0x000202da, 0x0401f016, + 0x833c0500, 0x00001800, 0x04000015, 0x8d3e7d16, + 0x04020013, 0x59325817, 0x0201f800, 0x001007fd, + 0x59300203, 0x82000580, 0x00000004, 0x02000800, + 0x00100e99, 0x59325808, 0x0201f800, 0x00109037, + 0x04000005, 0x49425a06, 0x497a5c09, 0x0201f800, + 0x000202da, 0x0201f800, 0x00107911, 0x83326400, + 0x00000024, 0x41580000, 0x81300480, 0x04001742, + 0x5c027000, 0x5c025800, 0x5c026800, 0x5c026000, + 0x5c00b800, 0x1c01f000, 0x5c000000, 0x4c000000, + 0x4803c857, 0x480bc857, 0x480fc857, 0x485bc857, + 0x50080800, 0x500c0000, 0x80042580, 0x04020007, + 0x80081000, 0x800c1800, 0x8058b040, 0x040207f9, + 0x80000580, 0x1c01f000, 0x4803c857, 0x4807c857, + 0x480bc857, 0x480fc857, 0x80040480, 0x04001006, + 0x42000000, 0x00000001, 0x82040d40, 0x00000001, + 0x1c01f000, 0x41780000, 0x0401f7fc, 0x83380480, + 0x00000053, 0x02021800, 0x001005d8, 0x83380480, + 0x0000004b, 0x02001800, 0x001005d8, 0x0c01f001, + 0x0010858a, 0x0010858a, 0x0010858a, 0x0010858a, + 0x00108588, 0x00108588, 0x00108588, 0x0010858a, + 0x0201f800, 0x001005d8, 0x493bc857, 0x4a026203, + 0x0000000d, 0x493a6403, 0x42000800, 0x80000000, + 0x0201f000, 0x00020721, 0x83380580, 0x00000013, + 0x04020008, 0x59300403, 0x82000580, 0x00000050, + 0x02020800, 0x001005d8, 0x0201f000, 0x0002077d, + 0x4933c857, 0x83380580, 0x00000027, 0x04020030, + 0x4933c857, 0x0201f800, 0x00106bbf, 0x4d3c0000, + 0x417a7800, 0x0201f800, 0x0010203c, 0x5c027800, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x4d2c0000, 0x59325808, 0x0201f800, 0x00109037, + 0x492fc857, 0x0400000d, 0x4a025a04, 0x00000103, + 0x59300c02, 0x48065c06, 0x4a025a06, 0x00000029, + 0x497a5c09, 0x592c0c08, 0x84040d50, 0x48065c08, + 0x0201f800, 0x000202da, 0x5c025800, 0x42003000, + 0x00000015, 0x41782800, 0x42002000, 0x00000003, + 0x4d400000, 0x4d440000, 0x59368c03, 0x42028000, + 0x00000029, 0x0201f800, 0x0010985e, 0x5c028800, + 0x5c028000, 0x0201f000, 0x0002077d, 0x83380580, + 0x00000014, 0x0402000c, 0x59300403, 0x82000c80, + 0x00000053, 0x02021800, 0x001005d8, 0x82000480, + 0x00000040, 0x02001800, 0x001005d8, 0x4803c857, + 0x0c01f00e, 0x83380580, 0x00000053, 0x0400000a, + 0x83380580, 0x00000048, 0x02020800, 0x001005d8, + 0x59300403, 0x82000580, 0x00000050, 0x02020800, + 0x001005d8, 0x1c01f000, 0x001085ff, 0x001085fd, + 0x001085fd, 0x001085fd, 0x001085fd, 0x001085fd, + 0x001085fd, 0x001085fd, 0x001085fd, 0x001085fd, + 0x001085fd, 0x00108616, 0x00108616, 0x00108616, + 0x00108616, 0x001085fd, 0x00108616, 0x001085fd, + 0x00108616, 0x0201f800, 0x001005d8, 0x4933c857, + 0x0201f800, 0x00106bbf, 0x0201f800, 0x00109037, + 0x02000000, 0x0002077d, 0x4d2c0000, 0x59325808, + 0x4a025a04, 0x00000103, 0x59300402, 0x48025c06, + 0x4a025a06, 0x00000006, 0x497a5c09, 0x0201f800, + 0x000202da, 0x5c025800, 0x0201f800, 0x0010912a, + 0x0201f000, 0x0002077d, 0x4933c857, 0x0201f800, + 0x00106bbf, 0x0201f000, 0x0002077d, 0x0201f800, + 0x001005d8, 0x5930001c, 0x800001c0, 0x02020800, + 0x0010984e, 0x59300004, 0x8c00053e, 0x04020029, + 0x59325808, 0x592c0c08, 0x59cc2a08, 0x82141d00, + 0x00000c00, 0x04000002, 0x59cc1809, 0x84040d58, + 0x48065c08, 0x82143500, 0x00000fff, 0x04020027, + 0x59340200, 0x8c00050e, 0x04020080, 0x0201f800, + 0x0002082b, 0x04020006, 0x4a025a06, 0x00000000, + 0x59300811, 0x800409c0, 0x0402094b, 0x4a025a04, + 0x00000103, 0x48065807, 0x480e580a, 0x48165c09, + 0x59300c02, 0x48065c06, 0x0201f800, 0x000202c1, + 0x0201f800, 0x001049b2, 0x59cc0208, 0x8c000518, + 0x02020000, 0x001091d1, 0x0201f000, 0x0002077d, + 0x0201f800, 0x00106f60, 0x040007d6, 0x4d3c0000, + 0x42027800, 0x00000002, 0x0201f800, 0x00108be3, + 0x5c027800, 0x0401f7cf, 0x4817c857, 0x480fc857, + 0x82180500, 0x000000ff, 0x0400000e, 0x592c0204, + 0x82000500, 0x000000ff, 0x82000580, 0x00000048, + 0x04020008, 0x592c0407, 0x800001c0, 0x04000005, + 0x0201f800, 0x0010973f, 0x0201f000, 0x00109787, + 0x82180d00, 0x00000c00, 0x04000004, 0x59340200, + 0x8c00050e, 0x04020032, 0x4a025a06, 0x00000000, + 0x41782000, 0x8c183510, 0x04000007, 0x59cc000c, + 0x82000500, 0x000000ff, 0x04000002, 0x4803c857, + 0x59cc200b, 0x4812580c, 0x41780000, 0x8c183512, + 0x04000002, 0x59cc000a, 0x4802580b, 0x80100c00, + 0x040007b8, 0x82041480, 0x0000001d, 0x04001006, + 0x592c0404, 0x8c00051e, 0x0400000e, 0x42000800, + 0x0000001c, 0x4c500000, 0x4c540000, 0x83cca400, + 0x0000000c, 0x832cac00, 0x0000000d, 0x0201f800, + 0x00108b9f, 0x5c00a800, 0x5c00a000, 0x0401f7a5, + 0x59300011, 0x59301402, 0x480a5c06, 0x48025807, + 0x480e580a, 0x48165c09, 0x0201f800, 0x00108b48, + 0x0201f800, 0x00108b84, 0x0401f7a6, 0x592c020a, + 0x8c000502, 0x040007cd, 0x592c0208, 0x8c00050e, + 0x040207ca, 0x59300011, 0x800c0d80, 0x040007c7, + 0x4803c857, 0x480fc857, 0x8c183514, 0x02000000, + 0x0010920f, 0x80000540, 0x040007c0, 0x4807c856, + 0x0201f000, 0x0010920f, 0x592c020a, 0x8c000502, + 0x04000782, 0x59300011, 0x800001c0, 0x0400077f, + 0x592c0208, 0x8c00050e, 0x0402077c, 0x0201f000, + 0x0010920f, 0x59cc2006, 0x59cc2807, 0x0401f035, + 0x0401f034, 0x1c01f000, 0x4933c857, 0x5930001c, + 0x800001c0, 0x02020800, 0x0010984e, 0x59325808, + 0x592c0c08, 0x41782800, 0x41781800, 0x84040d58, + 0x48065c08, 0x41783000, 0x59340200, 0x8c00050e, + 0x04020018, 0x0201f800, 0x0002082b, 0x04020007, + 0x4a025a06, 0x00000000, 0x59300811, 0x4807c857, + 0x800409c0, 0x040208ac, 0x4a025a04, 0x00000103, + 0x48065807, 0x480e580a, 0x48165c09, 0x4933c857, + 0x59300c02, 0x48065c06, 0x0201f800, 0x000202c1, + 0x0201f800, 0x001049b2, 0x0201f000, 0x0002077d, + 0x592c020a, 0x8c000502, 0x040007ea, 0x59300011, + 0x4803c857, 0x800001c0, 0x040007e6, 0x592c0208, + 0x8c00050e, 0x040207e3, 0x0201f000, 0x0010920f, + 0x5930001c, 0x800001c0, 0x4c100000, 0x4c140000, + 0x02020800, 0x0010984e, 0x5c002800, 0x5c002000, + 0x4a026203, 0x00000002, 0x4a026403, 0x00000043, + 0x59325808, 0x592c020a, 0x8c000502, 0x04020018, + 0x40100000, 0x592c080f, 0x80040c80, 0x40140000, + 0x80040480, 0x04001014, 0x48126013, 0x48166011, + 0x59300004, 0x8c00053e, 0x04020008, 0x497a6205, + 0x0201f800, 0x00100f93, 0x04020009, 0x59300804, + 0x0201f000, 0x00106721, 0x0201f800, 0x00106f60, + 0x040007f7, 0x0201f000, 0x00107974, 0x4933c857, + 0x1c01f000, 0x4807c857, 0x40042800, 0x0401f7eb, + 0x83380480, 0x00000058, 0x04021005, 0x83380480, + 0x00000040, 0x04001002, 0x0c01f002, 0x1c01f000, + 0x00108740, 0x00108740, 0x00108740, 0x00108740, + 0x00108740, 0x00108740, 0x00108740, 0x00108740, + 0x00108740, 0x00108740, 0x00108742, 0x00108740, + 0x00108740, 0x00108740, 0x00108740, 0x0010874f, + 0x00108740, 0x00108740, 0x00108740, 0x00108740, + 0x0010877d, 0x00108740, 0x00108740, 0x00108740, + 0x0201f800, 0x001005d8, 0x4933c857, 0x0201f800, + 0x00106dc3, 0x4a026203, 0x00000002, 0x59a80039, + 0x48026205, 0x59300011, 0x59300815, 0x80040c80, + 0x48066015, 0x0201f000, 0x00106b8a, 0x4933c857, + 0x0201f800, 0x00106b8a, 0x4d3c0000, 0x417a7800, + 0x0201f800, 0x0010203c, 0x5c027800, 0x42000000, + 0x0010b864, 0x0201f800, 0x0010aa47, 0x0201f800, + 0x00109037, 0x04000010, 0x4d2c0000, 0x59325808, + 0x4a025a04, 0x00000103, 0x59300402, 0x48025c06, + 0x4a025a06, 0x00000029, 0x497a5c09, 0x592c0c08, + 0x84040d50, 0x48065c08, 0x0201f800, 0x000202da, + 0x5c025800, 0x42003000, 0x00000014, 0x41782800, + 0x4d400000, 0x4d440000, 0x59368c03, 0x42002000, + 0x00000002, 0x42028000, 0x00000029, 0x0201f800, + 0x0010985e, 0x5c028800, 0x5c028000, 0x0201f000, + 0x0002077d, 0x4933c857, 0x59300808, 0x49780c09, + 0x4978080a, 0x58041408, 0x84081558, 0x48080c08, + 0x1c01f000, 0x4807c857, 0x8c040d3e, 0x04020023, + 0x497a5a06, 0x5930001f, 0x80000540, 0x04000017, + 0x497a5a06, 0x4c040000, 0x4c080000, 0x4c0c0000, + 0x4c100000, 0x4c140000, 0x58f41003, 0x40040000, + 0x80081480, 0x5930001f, 0x4809e803, 0x0201f800, + 0x00100d56, 0x5c002800, 0x5c002000, 0x5c001800, + 0x5c001000, 0x5c000800, 0x592c0206, 0x80000540, + 0x04020009, 0x0401f005, 0x592c0408, 0x8c00051c, + 0x04000002, 0x592c0803, 0x4807c857, 0x4a025a06, + 0x00000015, 0x1c01f000, 0x5930001f, 0x80000540, + 0x04000009, 0x4a025a06, 0x00000011, 0x5930001f, + 0x4c040000, 0x0201f800, 0x00100d56, 0x5c000800, + 0x0401f7f5, 0x4807c856, 0x4a025a06, 0x00000007, + 0x1c01f000, 0x83380480, 0x00000058, 0x04021007, + 0x83380480, 0x00000040, 0x04001004, 0x4d2c0000, + 0x0c01f803, 0x5c025800, 0x1c01f000, 0x001087db, + 0x001087db, 0x001087db, 0x001087db, 0x001087db, + 0x001087dd, 0x001087db, 0x001087db, 0x00108860, + 0x001087db, 0x001087db, 0x001087db, 0x001087db, + 0x001087db, 0x001087db, 0x001087db, 0x001087db, + 0x001087db, 0x001087db, 0x00108910, 0x00108939, + 0x00108918, 0x001087db, 0x00108945, 0x0201f800, + 0x001005d8, 0x5930001c, 0x800001c0, 0x02020800, + 0x0010984e, 0x59300007, 0x8c00050e, 0x0400007c, + 0x8c000500, 0x0400006e, 0x8c00051c, 0x04000009, + 0x84000500, 0x48026007, 0x59325808, 0x592c3c08, + 0x841c3d58, 0x481e5c08, 0x0201f000, 0x000207dd, + 0x59325808, 0x592c3c08, 0x841c3d58, 0x59300007, + 0x8c00051c, 0x040207f3, 0x481e5c08, 0x42000000, + 0x00000005, 0x40000000, 0x80000040, 0x040207fe, + 0x59300007, 0x8c00051c, 0x040207ea, 0x59cc0a08, + 0x592c0204, 0x82000500, 0x000000ff, 0x82000580, + 0x00000048, 0x0402000c, 0x497a580b, 0x82040500, + 0x000000ff, 0x04000008, 0x592c0407, 0x800001c0, + 0x04000005, 0x0201f800, 0x0010973f, 0x0201f000, + 0x00100e56, 0x48065c09, 0x41782000, 0x82040500, + 0x00000c00, 0x04000002, 0x59cc2009, 0x82043500, + 0x00000fff, 0x04020027, 0x481e5c08, 0x4a025a06, + 0x00000000, 0x801831c0, 0x02000000, 0x00100e56, + 0x41782000, 0x8c183510, 0x04000002, 0x59cc200b, + 0x4812580c, 0x41780000, 0x8c183512, 0x04000002, + 0x59cc000a, 0x4802580b, 0x80100c00, 0x02001800, + 0x001005d8, 0x02000000, 0x00100e56, 0x82041480, + 0x0000001d, 0x0402100c, 0x4c500000, 0x4c540000, + 0x83cca400, 0x0000000c, 0x832cac00, 0x0000000d, + 0x0401fb67, 0x5c00a800, 0x5c00a000, 0x0201f000, + 0x00100e56, 0x0401fb0b, 0x0201f000, 0x00100e56, + 0x412c7800, 0x0201f800, 0x001007e4, 0x02000800, + 0x001005d8, 0x492c7809, 0x841c3d52, 0x481c7c08, + 0x4a025a04, 0x00000103, 0x4812580a, 0x48065c09, + 0x583c0404, 0x583c1005, 0x583c2208, 0x48025c04, + 0x480a5805, 0x48125a08, 0x0401f7c8, 0x8c000524, + 0x04000794, 0x59325808, 0x4c000000, 0x592c0408, + 0x8c00051c, 0x5c000000, 0x04020003, 0x4a026011, + 0xffffffff, 0x84000524, 0x0401f78a, 0x1c01f000, + 0x59a80039, 0x48026205, 0x59325808, 0x4a026203, + 0x00000002, 0x592c2408, 0x59300807, 0x4933c857, + 0x4807c857, 0x592c0204, 0x82000500, 0x000000ff, + 0x82000580, 0x00000048, 0x04020004, 0x8c102500, + 0x02020000, 0x00109787, 0x4a025a06, 0x00000000, + 0x8c040d1e, 0x04000027, 0x41780800, 0x497a5c09, + 0x592c1c09, 0x59300011, 0x59341200, 0x497a6205, + 0x8c08150e, 0x0402006e, 0x4807c857, 0x4806580a, + 0x80000d40, 0x04020f04, 0x59300402, 0x48025c06, + 0x48065807, 0x4a025a04, 0x00000103, 0x4c040000, + 0x4c0c0000, 0x4c100000, 0x0201f800, 0x0010959c, + 0x5c002000, 0x5c001800, 0x5c000800, 0x8c102512, + 0x0402001a, 0x4c0c0000, 0x0201f800, 0x000202c1, + 0x0201f800, 0x001049b2, 0x5c001800, 0x8c0c1d18, + 0x02000000, 0x0002077d, 0x0201f000, 0x001091d1, + 0x4813c857, 0x8c102518, 0x0400004b, 0x41780800, + 0x592c1c09, 0x820c0580, 0x00001000, 0x040007d6, + 0x8c102512, 0x040007d4, 0x592c7809, 0x583c080a, + 0x583c1c09, 0x0401f7d0, 0x4807c857, 0x592c7809, + 0x59300402, 0x592c1404, 0x8c08151e, 0x0402000d, + 0x592c1206, 0x48007c06, 0x48047807, 0x48087a06, + 0x84102512, 0x48107c08, 0x4c0c0000, 0x0201f800, + 0x001007fd, 0x403e5800, 0x0401faca, 0x0401f7d9, + 0x48025c06, 0x48065807, 0x583c080c, 0x583c000b, + 0x80040c00, 0x82041480, 0x0000001d, 0x04001006, + 0x583c1001, 0x480a5801, 0x49787801, 0x42000800, + 0x0000001c, 0x82040c00, 0x00000014, 0x4c0c0000, + 0x4c500000, 0x4c540000, 0x823ca400, 0x00000008, + 0x832cac00, 0x00000008, 0x4c100000, 0x4c3c0000, + 0x0401facb, 0x5c007800, 0x5c002000, 0x5c00a800, + 0x5c00a000, 0x84102512, 0x48125c08, 0x403e5800, + 0x0201f800, 0x001007fd, 0x42034000, 0x0010b4a4, + 0x59a1d81e, 0x80edd9c0, 0x02000800, 0x001005d8, + 0x48efc857, 0x58ec0009, 0x4803c857, 0x0801f800, + 0x0401f7ac, 0x4933c857, 0x1c01f000, 0x59301414, + 0x480bc857, 0x8c08151c, 0x0402000e, 0x80000540, + 0x4803c857, 0x0400078d, 0x80042c80, 0x0402178b, + 0x8c081514, 0x04020005, 0x592c080f, 0x4807c857, + 0x80040480, 0x48026016, 0x8408155c, 0x480a6414, + 0x59301007, 0x8408151e, 0x480a6007, 0x4a025c09, + 0x00000001, 0x0201f800, 0x0010959c, 0x497a5c09, + 0x8c102512, 0x04000006, 0x4d2c0000, 0x403e5800, + 0x0201f800, 0x001007fd, 0x5c025800, 0x82102500, + 0xffffedff, 0x48125c08, 0x0201f000, 0x0010920f, + 0x59325808, 0x592c0408, 0x8c000518, 0x04000004, + 0x412df800, 0x0201f000, 0x00100e6f, 0x1c01f000, + 0x4933c857, 0x59325808, 0x497a5c09, 0x4a025a06, + 0x00000000, 0x4a025a04, 0x00000103, 0x59300811, + 0x4807c857, 0x800409c0, 0x0402000a, 0x48065807, + 0x59300c02, 0x48065c06, 0x0201f800, 0x000202c1, + 0x0201f800, 0x001049b2, 0x0201f000, 0x0002077d, + 0x59340200, 0x8c00050e, 0x04020005, 0x59300811, + 0x0401fe55, 0x48065807, 0x0401f7f2, 0x592c0208, + 0x8c00050e, 0x040207fa, 0x4933c857, 0x0201f000, + 0x0010920f, 0x4933c857, 0x59325808, 0x812e59c0, + 0x02000800, 0x001005d8, 0x592c020a, 0x8c000502, + 0x02000800, 0x001005d8, 0x4a026206, 0x00000002, + 0x1c01f000, 0x5930001c, 0x800001c0, 0x02020800, + 0x0010984e, 0x59300007, 0x4933c857, 0x4803c857, + 0x8c00050e, 0x04000037, 0x8c000500, 0x04000029, + 0x8c00051c, 0x0400000a, 0x84000500, 0x48026007, + 0x59325808, 0x592c3c08, 0x481fc857, 0x841c3d58, + 0x481e5c08, 0x0201f000, 0x000207dd, 0x59325808, + 0x592c3c08, 0x841c3d58, 0x59300007, 0x8c00051c, + 0x040207f2, 0x481e5c08, 0x42000000, 0x00000005, + 0x40000000, 0x80000040, 0x040207fe, 0x59300007, + 0x8c00051c, 0x040207e9, 0x592c0204, 0x82000500, + 0x000000ff, 0x82000580, 0x00000048, 0x04020003, + 0x497a580b, 0x0401f002, 0x497a5c09, 0x481e5c08, + 0x4a025a06, 0x00000000, 0x0201f000, 0x00100e56, + 0x8c000524, 0x040007d9, 0x59325808, 0x4c000000, + 0x592c0408, 0x8c00051c, 0x5c000000, 0x04020003, + 0x4a026011, 0xffffffff, 0x84000524, 0x0401f7cf, + 0x1c01f000, 0x4933c857, 0x41780800, 0x83380480, + 0x00000058, 0x0402100b, 0x83380480, 0x00000040, + 0x04001008, 0x4d2c0000, 0x59325808, 0x812e59c0, + 0x0c020806, 0x5c025800, 0x0201f000, 0x0002077d, + 0x493bc857, 0x1c01f000, 0x001089ae, 0x001089ae, + 0x001089ae, 0x001089ae, 0x001089ae, 0x001089b0, + 0x001089ae, 0x001089ae, 0x001089ae, 0x001089ae, + 0x001089ae, 0x001089ae, 0x001089ae, 0x001089ae, + 0x001089ae, 0x001089ae, 0x001089ae, 0x001089ae, + 0x001089ae, 0x001089ae, 0x001089b5, 0x001089ae, + 0x001089ae, 0x001089ae, 0x0201f800, 0x001005d8, + 0x59cc0a08, 0x497a5807, 0x4807c857, 0x82040d00, + 0x00000fff, 0x59300402, 0x48025c06, 0x4a025a04, + 0x00000103, 0x48065c09, 0x4a025a06, 0x00000000, + 0x800409c0, 0x02000000, 0x000202c1, 0x59cc0009, + 0x4802580a, 0x82042500, 0x00000100, 0x04000002, + 0x59cc200b, 0x4812580c, 0x82040500, 0x00000200, + 0x04000002, 0x59cc000a, 0x4802580b, 0x80100c00, + 0x02001800, 0x001005d8, 0x02000000, 0x000202da, + 0x82041480, 0x0000001d, 0x04001006, 0x592c0404, + 0x8c00051e, 0x0400000e, 0x42000800, 0x0000001c, + 0x4c500000, 0x4c540000, 0x83cca400, 0x0000000c, + 0x832cac00, 0x0000000d, 0x0401f9c1, 0x5c00a800, + 0x5c00a000, 0x0201f000, 0x000202da, 0x0401f965, + 0x0401f1a0, 0x83380480, 0x00000093, 0x02021800, + 0x001005d8, 0x83380480, 0x00000085, 0x02001800, + 0x001005d8, 0x0c01f001, 0x001089fd, 0x001089fb, + 0x001089fb, 0x00108a04, 0x001089fb, 0x001089fb, + 0x001089fb, 0x001089fb, 0x001089fb, 0x001089fb, + 0x001089fb, 0x001089fb, 0x001089fb, 0x0201f800, + 0x001005d8, 0x4a026203, 0x00000001, 0x493a6403, + 0x42000800, 0x80000040, 0x0201f000, 0x00020721, + 0x4933c857, 0x59cc1204, 0x480a601c, 0x59cc1404, + 0x0201f800, 0x00109410, 0x0400001b, 0x591c0203, + 0x82000580, 0x00000000, 0x04000017, 0x591c0009, + 0x81340580, 0x04020014, 0x4d300000, 0x4d1c0000, + 0x411e6000, 0x0401f9c2, 0x5c023800, 0x5c026000, + 0x0400000b, 0x59cc0005, 0x8c000500, 0x04020003, + 0x0401f98c, 0x0401f003, 0x4a023a03, 0x00000002, + 0x4a026403, 0x00000086, 0x0401f005, 0x0401f9a6, + 0x040007f5, 0x4a026403, 0x00000087, 0x4a026203, + 0x00000001, 0x42000800, 0x80000040, 0x0201f800, + 0x00020721, 0x59340200, 0x8c00050e, 0x0400000d, + 0x59cc1404, 0x0201f800, 0x00109410, 0x04000009, + 0x591c0414, 0x8c00051a, 0x04000006, 0x4d300000, + 0x411e6000, 0x0201f800, 0x0010921e, 0x5c026000, + 0x1c01f000, 0x83380580, 0x00000013, 0x0402000a, + 0x59300403, 0x82000d80, 0x00000086, 0x04000012, + 0x82000d80, 0x00000087, 0x02020800, 0x001005d8, + 0x0401f00d, 0x83380580, 0x00000027, 0x04000005, + 0x83380580, 0x00000014, 0x02020800, 0x001005d8, + 0x493bc857, 0x0201f800, 0x00106bbf, 0x0201f000, + 0x00107911, 0x4933c857, 0x0201f000, 0x00107911, + 0x83380580, 0x00000013, 0x04020005, 0x59300403, + 0x82000480, 0x00000085, 0x0c01f04d, 0x83380580, + 0x00000027, 0x04020041, 0x4933c857, 0x0201f800, + 0x00106bbf, 0x4d3c0000, 0x417a7800, 0x0201f800, + 0x0010203c, 0x5c027800, 0x42003000, 0x00000015, + 0x41782800, 0x42002000, 0x00000003, 0x42028000, + 0x00000029, 0x4d400000, 0x4d440000, 0x59368c03, + 0x0201f800, 0x0010985e, 0x5c028800, 0x5c028000, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x0201f800, 0x00109037, 0x0400000c, 0x4d2c0000, + 0x59325808, 0x4a025a04, 0x00000103, 0x59300402, + 0x48025c06, 0x497a5c09, 0x49425a06, 0x0201f800, + 0x000202da, 0x5c025800, 0x0201f800, 0x0010912a, + 0x0201f000, 0x0002077d, 0x83380580, 0x00000089, + 0x04000005, 0x83380580, 0x0000008a, 0x02020000, + 0x00107974, 0x0201f800, 0x00106f60, 0x02020000, + 0x00107974, 0x59300a03, 0x82040580, 0x0000000a, + 0x0400002a, 0x82040580, 0x0000000c, 0x04000027, + 0x0201f800, 0x001005d8, 0x83380580, 0x00000014, + 0x040207ea, 0x4933c857, 0x0201f800, 0x00106bbf, + 0x42028000, 0x00000006, 0x0401f7d2, 0x00108aba, + 0x00108ab8, 0x00108ab8, 0x00108ab8, 0x00108ab8, + 0x00108ab8, 0x00108ac0, 0x00108ab8, 0x00108ab8, + 0x00108ab8, 0x00108ab8, 0x00108ab8, 0x00108ab8, + 0x0201f800, 0x001005d8, 0x4933c857, 0x59a80037, + 0x48026206, 0x4a026203, 0x0000000a, 0x1c01f000, + 0x4933c857, 0x59a80037, 0x48026206, 0x4a026203, + 0x0000000c, 0x1c01f000, 0x83380580, 0x00000089, + 0x04000008, 0x83380580, 0x0000008a, 0x04000032, + 0x4933c857, 0x493bc857, 0x0201f000, 0x00107974, + 0x4933c857, 0x59325808, 0x59300a1d, 0x82040580, + 0x00000003, 0x04020004, 0x0201f800, 0x001049b2, + 0x0401f00c, 0x5930021d, 0x82000580, 0x00000001, + 0x04020008, 0x59300c16, 0x82040580, 0x00000039, + 0x0400002c, 0x82040580, 0x00000035, 0x04000029, + 0x4c340000, 0x41306800, 0x0201f800, 0x0002075a, + 0x04000010, 0x4a026203, 0x00000001, 0x4a026403, + 0x0000001e, 0x59cc0c07, 0x48066419, 0x59cc0a07, + 0x48066219, 0x49366009, 0x4a026406, 0x00000001, + 0x42000800, 0x80000040, 0x0201f800, 0x00020721, + 0x40366000, 0x0201f800, 0x0002077d, 0x5c006800, + 0x1c01f000, 0x4933c857, 0x5930021d, 0x82000580, + 0x00000001, 0x04020040, 0x59300c16, 0x82040580, + 0x00000035, 0x04000007, 0x82040580, 0x0000001e, + 0x04000004, 0x82040580, 0x00000039, 0x04020036, + 0x4933c857, 0x4c500000, 0x4d1c0000, 0x4130a000, + 0x40067000, 0x0201f800, 0x001093ba, 0x04020029, + 0x0201f800, 0x0002075a, 0x04000026, 0x491fc857, + 0x4933c857, 0x83380580, 0x00000035, 0x04000004, + 0x83380580, 0x00000039, 0x04020002, 0x4932381c, + 0x493a6403, 0x4a026203, 0x00000001, 0x4a026406, + 0x00000001, 0x58500809, 0x4807c857, 0x48066009, + 0x58500c15, 0x4807c857, 0x48066415, 0x58500a15, + 0x4807c857, 0x48066215, 0x58500a16, 0x4807c857, + 0x48066216, 0x58500c19, 0x4807c857, 0x48066419, + 0x58500a19, 0x4807c857, 0x48066219, 0x491e601e, + 0x42000800, 0x80000040, 0x0201f800, 0x00020721, + 0x40526000, 0x5c023800, 0x5c00a000, 0x0201f000, + 0x0002077d, 0x5930021d, 0x82000580, 0x00000003, + 0x02000800, 0x001049b2, 0x0201f000, 0x0002077d, + 0x4803c856, 0x4c500000, 0x4c540000, 0x412c7800, + 0x4c3c0000, 0x42002800, 0x00000001, 0x82040480, + 0x00000101, 0x04001003, 0x42000800, 0x00000100, + 0x40043000, 0x42000800, 0x0000001c, 0x83cca400, + 0x0000000c, 0x832cac00, 0x0000000d, 0x0401f844, + 0x82183480, 0x0000001c, 0x592e5801, 0x812e59c0, + 0x02020800, 0x001007fd, 0x0201f800, 0x001007e4, + 0x04000017, 0x80142800, 0x4a025a04, 0x00000110, + 0x497a5c04, 0x492c7801, 0x82180c80, 0x0000003d, + 0x04021006, 0x40180800, 0x832cac00, 0x00000005, + 0x0401f82f, 0x0401f00a, 0x82183480, 0x0000003c, + 0x42000800, 0x0000003c, 0x412c7800, 0x832cac00, + 0x00000005, 0x0401f826, 0x0401f7e8, 0x5c007800, + 0x841429c0, 0x82142d40, 0x00000003, 0x48147a04, + 0x403e5800, 0x5c00a800, 0x5c00a000, 0x1c01f000, + 0x492fc857, 0x812e59c0, 0x0400000f, 0x4d2c0000, + 0x4c3c0000, 0x592c7801, 0x803c79c0, 0x04000006, + 0x497a5801, 0x0201f800, 0x000202da, 0x403e5800, + 0x0401f7f9, 0x5c007800, 0x0201f800, 0x000202da, + 0x5c025800, 0x1c01f000, 0x4803c856, 0x4c580000, + 0x82040c00, 0x00000003, 0x8004b104, 0x0201f800, + 0x0010ab17, 0x5c00b000, 0x1c01f000, 0x4803c856, + 0x4c580000, 0x82040c00, 0x00000003, 0x8004b104, + 0x0201f800, 0x0010ab17, 0x5c00b000, 0x1c01f000, + 0x591c0c06, 0x82040580, 0x00000003, 0x04000004, + 0x82040580, 0x00000002, 0x0402001a, 0x4d300000, + 0x4d2c0000, 0x411e6000, 0x59325808, 0x0201f800, + 0x00109037, 0x0400000f, 0x4d400000, 0x42028000, + 0x00000013, 0x592c0a08, 0x84040d54, 0x0201f800, + 0x00104e70, 0x5c028000, 0x0201f800, 0x0010959c, + 0x0201f800, 0x000202da, 0x0201f800, 0x0010912a, + 0x0201f800, 0x00107911, 0x5c025800, 0x5c026000, + 0x1c01f000, 0x59cc0005, 0x8c000500, 0x0402000b, + 0x591c0406, 0x82000580, 0x00000002, 0x04020007, + 0x591c0c03, 0x82040580, 0x00000085, 0x04000003, + 0x82040580, 0x0000008b, 0x1c01f000, 0x4933c857, + 0x4d3c0000, 0x42027800, 0x00000002, 0x59300406, + 0x82000c80, 0x00000012, 0x02021800, 0x001005d8, + 0x0c01f80a, 0x5c027800, 0x1c01f000, 0x4933c857, + 0x59300406, 0x82000c80, 0x00000012, 0x02021800, + 0x001005d8, 0x0c01f001, 0x00108c01, 0x00108bfe, + 0x00108bfe, 0x00108c29, 0x00108bfc, 0x00108bfe, + 0x00108c1a, 0x00108bfe, 0x00108bfc, 0x001065f4, + 0x00108bfe, 0x00108bfe, 0x00108bfe, 0x00108bfc, + 0x00108bfc, 0x00108bfc, 0x00108cf9, 0x00108bfe, + 0x0201f800, 0x001005d8, 0x4803c856, 0x80000580, + 0x1c01f000, 0x4803c856, 0x8d3e7d02, 0x04020016, + 0x0201f800, 0x00109037, 0x0400000f, 0x59325808, + 0x41780800, 0x4d400000, 0x42028000, 0x00000005, + 0x0201f800, 0x00104e70, 0x5c028000, 0x0201f800, + 0x0010959c, 0x0201f800, 0x001091cc, 0x0201f800, + 0x000202da, 0x0201f800, 0x00107911, 0x82000540, + 0x00000001, 0x1c01f000, 0x4933c857, 0x0201f800, + 0x001048d9, 0x0402000c, 0x4d400000, 0x42028000, + 0x00000010, 0x0201f800, 0x0010a1d1, 0x4a026406, + 0x00000006, 0x4a026203, 0x00000007, 0x5c028000, + 0x1c01f000, 0x4933c857, 0x0201f800, 0x00106c55, + 0x4df00000, 0x0401f8b8, 0x82000c80, 0x0000000e, + 0x02021800, 0x001005d8, 0x0c01f001, 0x00108c43, + 0x00108cb0, 0x00108c5a, 0x00108cc3, 0x00108cab, + 0x00108c41, 0x00108c43, 0x00108c43, 0x00108c47, + 0x00108c43, 0x00108c43, 0x00108c43, 0x00108c43, + 0x00108c5a, 0x0201f800, 0x001005d8, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x0401f7b8, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x59300406, 0x82000580, + 0x00000003, 0x040207b4, 0x59300203, 0x82000580, + 0x0000000d, 0x040007b0, 0x8d3e7d02, 0x040207ae, + 0x4d340000, 0x59326809, 0x0201f800, 0x001049b2, + 0x5c026800, 0x0401f7a8, 0x59300004, 0x8400055c, + 0x48026004, 0x0201f800, 0x00106c4b, 0x59300406, + 0x82000580, 0x00000006, 0x04000043, 0x8d3e7d02, + 0x04020041, 0x497a621d, 0x59300203, 0x82000580, + 0x0000000d, 0x04000003, 0x4a02621d, 0x00000003, + 0x0401fbcb, 0x04000024, 0x4d2c0000, 0x4d400000, + 0x59325808, 0x0201f800, 0x001091cc, 0x592c0408, + 0x8c000512, 0x04000009, 0x4d2c0000, 0x84000512, + 0x48025c08, 0x592c0809, 0x40065800, 0x0201f800, + 0x001007fd, 0x5c025800, 0x4d400000, 0x42028000, + 0x00000005, 0x592c0a08, 0x8c040d0e, 0x04000004, + 0x42028000, 0x00000002, 0x0401f001, 0x0201f800, + 0x00104e70, 0x5c028000, 0x0201f800, 0x0010959c, + 0x0201f800, 0x000202da, 0x497a6008, 0x5c028000, + 0x5c025800, 0x8d3e7d00, 0x04000009, 0x4d340000, + 0x59326809, 0x0201f800, 0x001049b2, 0x5c026800, + 0x0201f800, 0x00107911, 0x0401f00b, 0x4a026403, + 0x00000085, 0x4a026203, 0x00000009, 0x4a026406, + 0x00000002, 0x42000800, 0x8000404b, 0x0201f800, + 0x00020721, 0x5c03e000, 0x02020800, 0x00106c55, + 0x82000540, 0x00000001, 0x1c01f000, 0x0201f800, + 0x00106c4b, 0x0201f800, 0x00100e99, 0x0401f7ab, + 0x598c000d, 0x81300580, 0x04020004, 0x0201f800, + 0x00106e8e, 0x0402001b, 0x0201f800, 0x001068d3, + 0x04020006, 0x59300c03, 0x82040580, 0x00000040, + 0x0400078b, 0x0401f79d, 0x0201f800, 0x00106b6c, + 0x04000010, 0x0201f800, 0x001005d8, 0x0401f813, + 0x04020004, 0x0201f800, 0x00106e62, 0x04020009, + 0x0201f800, 0x001067ae, 0x040207f4, 0x59300c03, + 0x82040580, 0x00000040, 0x04000779, 0x0401f78b, + 0x59300203, 0x82000c80, 0x0000000e, 0x02021800, + 0x001005d8, 0x0c01f75e, 0x417a3000, 0x42032000, + 0x0000bf32, 0x59900004, 0x81300580, 0x04000009, + 0x83932400, 0x00000010, 0x811a3000, 0x83180480, + 0x00000005, 0x040017f8, 0x82000540, 0x00000001, + 0x1c01f000, 0x59300004, 0x8c00053e, 0x04000010, + 0x8c00050c, 0x0402000e, 0x8c000516, 0x04020006, + 0x82000d00, 0x0000001f, 0x82040580, 0x00000005, + 0x04020004, 0x42000000, 0x00000003, 0x0401f005, + 0x42000000, 0x00000001, 0x0401f002, 0x59300203, + 0x1c01f000, 0x4933c857, 0x0201f800, 0x00106c55, + 0x4df00000, 0x59300203, 0x82000c80, 0x0000000e, + 0x02021800, 0x001005d8, 0x0c01f001, 0x00108d13, + 0x00108d30, 0x00108d17, 0x00108d11, 0x00108d11, + 0x00108d11, 0x00108d11, 0x00108d11, 0x00108d11, + 0x00108d11, 0x00108d11, 0x00108d11, 0x00108d11, + 0x00108d11, 0x0201f800, 0x001005d8, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x0401f6e8, 0x5c03e000, + 0x02000800, 0x00106c4b, 0x4d2c0000, 0x59325808, + 0x59300403, 0x82000580, 0x00000052, 0x02000800, + 0x00101231, 0x0401fb16, 0x02000800, 0x001005d8, + 0x4a025a06, 0x00000005, 0x0201f800, 0x000202da, + 0x0201f800, 0x00104c19, 0x0201f800, 0x00107911, + 0x5c025800, 0x82000540, 0x00000001, 0x1c01f000, + 0x598c000d, 0x81300580, 0x0402001a, 0x59300004, + 0x8c000520, 0x04000004, 0x84000520, 0x48026004, + 0x0401f01a, 0x42001000, 0x0010b7f6, 0x50081000, + 0x58080002, 0x82000580, 0x00000100, 0x0400000a, + 0x5808000c, 0x81300580, 0x02020800, 0x001005d8, + 0x0201f800, 0x001068d3, 0x02020800, 0x001005d8, + 0x0401f7cf, 0x0201f800, 0x00106e8e, 0x0402000c, + 0x59300004, 0x8c000520, 0x04000004, 0x84000520, + 0x48026004, 0x0401f7c6, 0x0201f800, 0x001068d3, + 0x040007c3, 0x0201f800, 0x001005d8, 0x59300203, + 0x82000c80, 0x0000000e, 0x02021800, 0x001005d8, + 0x0c01f7a7, 0x59300406, 0x4933c857, 0x4803c857, + 0x82000c80, 0x00000012, 0x02021800, 0x001005d8, + 0x0c01f001, 0x00108d7c, 0x00108e41, 0x00108f79, + 0x00108d88, 0x00107911, 0x00108d7c, 0x0010a1c0, + 0x0002077d, 0x00108e41, 0x001065ce, 0x00108fda, + 0x00108d77, 0x00108d77, 0x00108d77, 0x00108d77, + 0x00108d77, 0x001096eb, 0x001096eb, 0x0201f800, + 0x001005d8, 0x0401fbd5, 0x02000000, 0x0010801c, + 0x1c01f000, 0x0201f800, 0x00106c55, 0x0201f800, + 0x00106bbf, 0x0201f800, 0x00106c4b, 0x0201f000, + 0x0002077d, 0x4a026206, 0x00000001, 0x1c01f000, + 0x42000000, 0x0010b872, 0x0201f800, 0x0010aa47, + 0x4d2c0000, 0x4d400000, 0x417a5800, 0x0401faa8, + 0x04000007, 0x59325808, 0x592c0208, 0x8400054c, + 0x48025a08, 0x42028000, 0x00000006, 0x0201f800, + 0x00106c55, 0x0401ff4c, 0x4803c857, 0x82000c80, + 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f806, + 0x0201f800, 0x00106c4b, 0x5c028000, 0x5c025800, + 0x1c01f000, 0x00108e40, 0x00108db5, 0x00108dc3, + 0x00108de5, 0x00108e11, 0x00108db3, 0x00108d7c, + 0x00108d7c, 0x00108d7c, 0x00108db3, 0x00108db3, + 0x00108db3, 0x00108db3, 0x00108dc3, 0x0201f800, + 0x001005d8, 0x598c000d, 0x81300580, 0x04020004, + 0x0201f800, 0x00106e8e, 0x04020038, 0x0201f800, + 0x001068d3, 0x0400003b, 0x0201f800, 0x00106b6c, + 0x04000032, 0x0201f800, 0x001005d8, 0x497a621d, + 0x812e59c0, 0x02000800, 0x001005d8, 0x592c0204, + 0x82000500, 0x000000ff, 0x82000580, 0x00000014, + 0x04000003, 0x4a02621d, 0x00000003, 0x592c0a08, + 0x0201f800, 0x00104e70, 0x0201f800, 0x0010959c, + 0x0201f800, 0x000202da, 0x497a6008, 0x4a026403, + 0x00000085, 0x4a026203, 0x00000009, 0x4a026406, + 0x00000002, 0x4a026004, 0x8000404b, 0x0201f800, + 0x00106c4b, 0x42000800, 0x8000404b, 0x0201f000, + 0x00020721, 0x0401fef1, 0x04020004, 0x0201f800, + 0x00106e62, 0x04020009, 0x0201f800, 0x001067ae, + 0x040207d2, 0x59300c03, 0x82040580, 0x00000040, + 0x04000008, 0x0401f7d2, 0x59300203, 0x82000c80, + 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f7ae, + 0x0201f800, 0x00106c4b, 0x812e59c0, 0x04000013, + 0x592c0a08, 0x0201f800, 0x00104e70, 0x0201f800, + 0x0010959c, 0x0201f800, 0x000202da, 0x59300203, + 0x82000580, 0x0000000d, 0x04000008, 0x0201f800, + 0x00106c4b, 0x4d340000, 0x59326809, 0x0201f800, + 0x001049b2, 0x5c026800, 0x0201f800, 0x00107911, + 0x0401f030, 0x812e59c0, 0x02000800, 0x001005d8, + 0x0201f800, 0x0010940a, 0x04020004, 0x0201f800, + 0x00100e99, 0x0401f7aa, 0x0201f800, 0x00106c4b, + 0x592c0208, 0x8400050c, 0x48025a08, 0x592c0406, + 0x800000c2, 0x800008c4, 0x80040c00, 0x48066206, + 0x42000000, 0x10000000, 0x41300800, 0x0201f800, + 0x00100b94, 0x0400000d, 0x592c0208, 0x8c00051c, + 0x04020006, 0x8400055c, 0x48025a08, 0x4a026206, + 0x00000002, 0x0401f00f, 0x4d300000, 0x0201f800, + 0x001012e5, 0x5c026000, 0x59300203, 0x82000580, + 0x00000004, 0x04020007, 0x4d380000, 0x42027000, + 0x00000048, 0x0201f800, 0x000207a1, 0x5c027000, + 0x1c01f000, 0x42000000, 0x0010b86e, 0x0201f800, + 0x0010aa47, 0x59300203, 0x82000c80, 0x0000000e, + 0x02021800, 0x001005d8, 0x4803c857, 0x0c01f001, + 0x00108e5a, 0x00108d85, 0x00108e5c, 0x00108e5a, + 0x00108e5c, 0x00108e5c, 0x00108d7d, 0x00108e5a, + 0x00108d79, 0x00108e5a, 0x00108e5a, 0x00108e5a, + 0x00108e5a, 0x00108e5a, 0x0201f800, 0x001005d8, + 0x4d340000, 0x4d2c0000, 0x59326809, 0x59340400, + 0x82000500, 0x000000ff, 0x82000c80, 0x0000000c, + 0x02021800, 0x001005d8, 0x59303403, 0x82180d80, + 0x00000004, 0x04020004, 0x42000000, 0x00000001, + 0x0401f006, 0x82180d80, 0x00000000, 0x04020003, + 0x42000000, 0x00000001, 0x4803c857, 0x0c01f804, + 0x5c025800, 0x5c026800, 0x1c01f000, 0x00108e83, + 0x00108f22, 0x00108e85, 0x00108eba, 0x00108e85, + 0x00108f3f, 0x00108e85, 0x00108e8f, 0x00108e83, + 0x00108f3f, 0x00108e83, 0x00108e9e, 0x0201f800, + 0x001005d8, 0x59300403, 0x82000d80, 0x00000016, + 0x0400002e, 0x82000d80, 0x00000004, 0x0400002b, + 0x82000d80, 0x00000002, 0x04000028, 0x0401fabf, + 0x04000079, 0x59300403, 0x82000d80, 0x00000022, + 0x040000ae, 0x82000d80, 0x00000039, 0x040000b3, + 0x82000d80, 0x00000035, 0x040000b0, 0x82000d80, + 0x0000001e, 0x0400001b, 0x0401f999, 0x04000007, + 0x0201f800, 0x00109597, 0x04020004, 0x0201f800, + 0x00104a14, 0x0401f011, 0x59300403, 0x82000d80, + 0x00000001, 0x04020004, 0x0201f800, 0x001049e7, + 0x0400000a, 0x4d3c0000, 0x417a7800, 0x0201f800, + 0x0010203c, 0x5c027800, 0x42000000, 0x0010b864, + 0x0201f800, 0x0010aa47, 0x0201f800, 0x0010801c, + 0x0201f000, 0x00107911, 0x0401f97d, 0x04000004, + 0x0201f800, 0x00109597, 0x040000a9, 0x59300c03, + 0x82040580, 0x00000016, 0x04000056, 0x82040580, + 0x00000002, 0x04020034, 0x59a80026, 0x8c000502, + 0x04020013, 0x0201f800, 0x0010513b, 0x04020010, + 0x0201f800, 0x00105151, 0x04020006, 0x42000000, + 0x00000001, 0x0201f800, 0x00105113, 0x0401f094, + 0x4a035033, 0x00000001, 0x4202d800, 0x00000001, + 0x0201f800, 0x001050a2, 0x0401f08d, 0x59340403, + 0x82000580, 0x000007fc, 0x04000008, 0x59a80026, + 0x8c00050a, 0x04020084, 0x59340212, 0x82000500, + 0x0000ff00, 0x04000082, 0x59340412, 0x82000500, + 0x000000ff, 0x04000010, 0x80000040, 0x48026c12, + 0x497a6008, 0x4a026406, 0x00000007, 0x4a026206, + 0x00000398, 0x497a6205, 0x0201f800, 0x0002075a, + 0x04000005, 0x49366009, 0x4a026406, 0x00000001, + 0x0401f020, 0x59300403, 0x82000d80, 0x00000002, + 0x0402000d, 0x59340403, 0x82000580, 0x000007fe, + 0x04020009, 0x59a80026, 0x84000540, 0x48035026, + 0x0201f800, 0x00104237, 0x0201f800, 0x0010801c, + 0x0401f00c, 0x0201f800, 0x0010801c, 0x4d3c0000, + 0x417a7800, 0x0201f800, 0x0010203c, 0x5c027800, + 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47, + 0x0201f800, 0x00102074, 0x0201f000, 0x00107911, + 0x42000800, 0x00000003, 0x0201f800, 0x00104571, + 0x4a026203, 0x00000001, 0x4a026403, 0x00000002, + 0x0201f000, 0x0010672b, 0x0401f915, 0x04020793, + 0x0201f800, 0x00102074, 0x4d3c0000, 0x417a7800, + 0x0201f800, 0x0010203c, 0x5c027800, 0x42000000, + 0x0010b864, 0x0201f800, 0x0010aa47, 0x42003000, + 0x00000018, 0x41782800, 0x42002000, 0x00000000, + 0x4d400000, 0x4d440000, 0x59368c03, 0x42028000, + 0x00000029, 0x0201f800, 0x0010985e, 0x5c028800, + 0x5c028000, 0x0201f000, 0x00107911, 0x0201f800, + 0x00104a14, 0x0401f7c8, 0x42000000, 0x0010b86d, + 0x0201f800, 0x0010aa47, 0x0201f800, 0x00107b76, + 0x040207c1, 0x1c01f000, 0x4d380000, 0x59327403, + 0x0201f800, 0x001093ba, 0x5c027000, 0x02020000, + 0x0002077d, 0x836c0580, 0x00000003, 0x04000004, + 0x4a026206, 0x00000002, 0x1c01f000, 0x59300403, + 0x48026416, 0x4a02621d, 0x00000001, 0x4a026403, + 0x00000085, 0x4a026203, 0x00000009, 0x4a026406, + 0x00000002, 0x42000800, 0x8000004b, 0x0201f000, + 0x00020721, 0x0201f800, 0x00102074, 0x0201f800, + 0x0010801c, 0x4d3c0000, 0x417a7800, 0x0201f800, + 0x0010203c, 0x5c027800, 0x42000000, 0x0010b864, + 0x0201f800, 0x0010aa47, 0x497a6008, 0x4a026406, + 0x00000007, 0x4a026206, 0x00000398, 0x497a6205, + 0x1c01f000, 0x42000000, 0x0010b870, 0x0201f800, + 0x0010aa47, 0x4d340000, 0x59326809, 0x59300203, + 0x82000c80, 0x0000000e, 0x02021800, 0x001005d8, + 0x4803c857, 0x0c01f803, 0x5c026800, 0x1c01f000, + 0x00108f96, 0x00108d85, 0x00108f96, 0x00108f96, + 0x00108f96, 0x00108f96, 0x00108f96, 0x00108f96, + 0x00108f96, 0x00108d85, 0x00108f98, 0x00108d85, + 0x00108fa0, 0x00108f96, 0x0201f800, 0x001005d8, + 0x4a026403, 0x0000008b, 0x4a026203, 0x0000000b, + 0x42000800, 0x8000404b, 0x0201f000, 0x00020721, + 0x59300a1d, 0x4d3c0000, 0x417a7800, 0x0201f800, + 0x0010203c, 0x5c027800, 0x42003000, 0x00000011, + 0x0201f800, 0x0010a942, 0x42000000, 0x0010b864, + 0x0201f800, 0x0010aa47, 0x41306800, 0x0201f800, + 0x0002075a, 0x04000008, 0x49366009, 0x4d300000, + 0x40366000, 0x0201f800, 0x00107911, 0x5c026000, + 0x0401f002, 0x40366000, 0x497a6008, 0x4a026406, + 0x00000001, 0x4a026403, 0x00000001, 0x0201f800, + 0x00103b25, 0x04000011, 0x4a026406, 0x00000004, + 0x4a026203, 0x00000007, 0x4a026420, 0x00000001, + 0x42003000, 0x00000004, 0x4d400000, 0x42028000, + 0x00000029, 0x41782800, 0x0201f800, 0x0010a43e, + 0x5c028000, 0x1c01f000, 0x42000800, 0x0000000b, + 0x0201f800, 0x00104571, 0x4a026203, 0x00000001, + 0x0201f000, 0x0010672b, 0x42000000, 0x0010b876, + 0x0201f800, 0x0010aa47, 0x59300203, 0x82000c80, + 0x0000000e, 0x02021800, 0x001005d8, 0x4803c857, + 0x0c01f001, 0x0010900b, 0x00108ff3, 0x00108ff7, + 0x0010900c, 0x00108ff5, 0x00108ff3, 0x00108ff3, + 0x00108ff3, 0x00108ff3, 0x00108ff3, 0x00108ff3, + 0x00108ff3, 0x00108ff3, 0x00108ff3, 0x0201f800, + 0x001005d8, 0x0201f800, 0x00100e99, 0x4d2c0000, + 0x59325808, 0x4a025a06, 0x00000006, 0x0201f800, + 0x000202da, 0x5c025800, 0x497a6008, 0x4a02621d, + 0x0000000a, 0x4a026403, 0x00000085, 0x4a026203, + 0x00000009, 0x4a026406, 0x00000002, 0x42000800, + 0x8000404b, 0x0201f000, 0x00020721, 0x1c01f000, + 0x0201f800, 0x00106c55, 0x4df00000, 0x0401fcc7, + 0x04020004, 0x0201f800, 0x00106e62, 0x0402000c, + 0x0201f800, 0x001067ae, 0x04020005, 0x5c03e000, + 0x0201f800, 0x00106c4b, 0x0401f7dd, 0x0201f800, + 0x00106b6c, 0x02020800, 0x001005d8, 0x5c03e000, + 0x0201f800, 0x00106c4b, 0x59300203, 0x82000d80, + 0x00000003, 0x02000800, 0x001005d8, 0x82000c80, + 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f7ba, + 0x4803c856, 0x59a8000e, 0x59a80867, 0x80040400, + 0x80080480, 0x04021004, 0x82000540, 0x00000001, + 0x1c01f000, 0x80000580, 0x1c01f000, 0x4803c856, + 0x4c080000, 0x59301008, 0x82081500, 0xfff00000, + 0x5c001000, 0x1c01f000, 0x4803c856, 0x4d300000, + 0x0201f800, 0x0002075a, 0x0400000a, 0x0401f82f, + 0x4d380000, 0x42027000, 0x0000004b, 0x0201f800, + 0x000207a1, 0x5c027000, 0x82000540, 0x00000001, + 0x5c026000, 0x1c01f000, 0x4803c856, 0x4d300000, + 0x0201f800, 0x00107942, 0x0400001b, 0x0401f81f, + 0x4d300000, 0x0201f800, 0x00106c55, 0x4d3c0000, + 0x417a7800, 0x0201f800, 0x00106ab4, 0x0201f800, + 0x001067fd, 0x5c027800, 0x0201f800, 0x0010a2ff, + 0x0201f800, 0x00106c4b, 0x5c026000, 0x8d3e7d3e, + 0x0402000b, 0x4d380000, 0x42027000, 0x0000004c, + 0x0201f800, 0x000207a1, 0x5c027000, 0x82000540, + 0x00000001, 0x5c026000, 0x1c01f000, 0x0201f800, + 0x0002077d, 0x0401f7fa, 0x592c0407, 0x494a6017, + 0x494e6018, 0x49366009, 0x492e6008, 0x4a026406, + 0x00000003, 0x800000c2, 0x800008c4, 0x80040400, + 0x48026206, 0x1c01f000, 0x493bc857, 0x4d300000, + 0x0201f800, 0x0002075a, 0x0400000d, 0x0401ffef, + 0x4d400000, 0x42028000, 0x00000005, 0x0401f80d, + 0x5c028000, 0x8d3e7d3e, 0x04020007, 0x0201f800, + 0x000207a1, 0x82000540, 0x00000001, 0x5c026000, + 0x1c01f000, 0x0201f800, 0x0002077d, 0x0401f7fa, + 0x4803c856, 0x0201f800, 0x00106c55, 0x4d3c0000, + 0x4d440000, 0x59368c03, 0x42027800, 0x00000001, + 0x0201f800, 0x001069b6, 0x0201f800, 0x0010692e, + 0x0201f800, 0x001067fd, 0x0201f800, 0x0010a2ff, + 0x5c028800, 0x5c027800, 0x0201f000, 0x00106c4b, + 0x4803c856, 0x4d300000, 0x0201f800, 0x0002075a, + 0x0400000f, 0x481a601c, 0x48ee6021, 0x49366009, + 0x4a026406, 0x00000001, 0x492e6008, 0x4d380000, + 0x42027000, 0x0000001f, 0x0201f800, 0x000207a1, + 0x5c027000, 0x82000540, 0x00000001, 0x5c026000, + 0x1c01f000, 0x4803c856, 0x4d300000, 0x0201f800, + 0x0002075a, 0x0400000e, 0x48ee6021, 0x49366009, + 0x4a026406, 0x00000001, 0x492e6008, 0x4d380000, + 0x42027000, 0x00000055, 0x0201f800, 0x000207a1, + 0x5c027000, 0x82000540, 0x00000001, 0x5c026000, + 0x1c01f000, 0x4803c856, 0x4d300000, 0x0201f800, + 0x0002075a, 0x0400000f, 0x481a601c, 0x48ee6021, + 0x49366009, 0x4a026406, 0x00000001, 0x492e6008, + 0x4d380000, 0x42027000, 0x0000003d, 0x0201f800, + 0x000207a1, 0x5c027000, 0x82000540, 0x00000001, + 0x5c026000, 0x1c01f000, 0x4803c856, 0x4d300000, + 0x0201f800, 0x00107942, 0x04000014, 0x49366009, + 0x492fc857, 0x4933c857, 0x592c0404, 0x8c00051e, + 0x04000003, 0x48efc857, 0x48ee6021, 0x4a026406, + 0x00000001, 0x492e6008, 0x4d380000, 0x42027000, + 0x00000000, 0x0201f800, 0x000207a1, 0x5c027000, + 0x82000540, 0x00000001, 0x5c026000, 0x1c01f000, + 0x4803c856, 0x4d300000, 0x0201f800, 0x0002075a, + 0x0400000f, 0x48ee6021, 0x481a601c, 0x49366009, + 0x4a026406, 0x00000001, 0x492e6008, 0x4d380000, + 0x42027000, 0x00000044, 0x0201f800, 0x000207a1, + 0x5c027000, 0x82000540, 0x00000001, 0x5c026000, + 0x1c01f000, 0x4803c856, 0x4d300000, 0x0201f800, + 0x0002075a, 0x0400000f, 0x481a601c, 0x48ee6021, + 0x49366009, 0x4a026406, 0x00000001, 0x492e6008, + 0x4d380000, 0x42027000, 0x00000049, 0x0201f800, + 0x000207a1, 0x5c027000, 0x82000540, 0x00000001, + 0x5c026000, 0x1c01f000, 0x59300009, 0x80001540, + 0x02000800, 0x001005d8, 0x5808040b, 0x4803c856, + 0x80000040, 0x04001002, 0x4800140b, 0x1c01f000, + 0x4803c856, 0x59300403, 0x82000d80, 0x00000002, + 0x04000015, 0x82000d80, 0x00000003, 0x04000012, + 0x82000d80, 0x00000004, 0x0400000f, 0x82000d80, + 0x00000008, 0x0400000c, 0x82000d80, 0x0000000a, + 0x04000009, 0x599c0819, 0x8c040d0e, 0x04000004, + 0x82000d80, 0x00000000, 0x04000003, 0x82000540, + 0x00000001, 0x1c01f000, 0x4803c856, 0x4c000000, + 0x4d2c0000, 0x59300406, 0x82000580, 0x00000004, + 0x0400001d, 0x59300008, 0x80025d40, 0x800001c0, + 0x04000019, 0x0201f800, 0x00109597, 0x04000014, + 0x59300406, 0x82004580, 0x00000010, 0x04000010, + 0x82004580, 0x00000011, 0x0400000d, 0x82004580, + 0x00000003, 0x0400000c, 0x82004580, 0x00000002, + 0x04000009, 0x82004580, 0x0000000a, 0x04000006, + 0x592c0404, 0x8c00051e, 0x04000003, 0x80000580, + 0x0401f003, 0x82000540, 0x00000001, 0x5c025800, + 0x5c000000, 0x1c01f000, 0x4803c856, 0x4d300000, + 0x0201f800, 0x00107942, 0x04000013, 0x49366009, + 0x48ee6021, 0x4a026406, 0x00000001, 0x492e6008, + 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c, + 0x5c027800, 0x4d380000, 0x42027000, 0x00000028, + 0x0201f800, 0x000207a1, 0x5c027000, 0x82000540, + 0x00000001, 0x5c026000, 0x1c01f000, 0x4803c856, + 0x83380580, 0x00000015, 0x0402000d, 0x59a80016, + 0x82000580, 0x00000074, 0x04020009, 0x0201f800, + 0x0010462a, 0x4a026203, 0x00000001, 0x4a026403, + 0x00000029, 0x0201f000, 0x0010672b, 0x0201f800, + 0x0010801c, 0x0201f000, 0x0002077d, 0x4803c856, + 0x83380580, 0x00000016, 0x04020007, 0x42000800, + 0x00000004, 0x0201f800, 0x00104571, 0x0201f000, + 0x00107b38, 0x83380580, 0x00000015, 0x04020013, + 0x59a80016, 0x82000580, 0x00000014, 0x0402000f, + 0x0201f800, 0x0010468d, 0x0201f800, 0x0010846f, + 0x0402000a, 0x59340404, 0x80000540, 0x04000007, + 0x42000800, 0x00000006, 0x0201f800, 0x00104571, + 0x0201f000, 0x00107b38, 0x0201f800, 0x0010801c, + 0x0201f000, 0x0002077d, 0x4803c856, 0x592c0206, + 0x82000580, 0x00000005, 0x04000002, 0x1c01f000, + 0x4803c856, 0x592c0208, 0x8400054a, 0x48025a08, + 0x1c01f000, 0x497a6205, 0x497a6008, 0x4a026203, + 0x00000001, 0x4a026403, 0x00000050, 0x42000800, + 0x80000043, 0x0201f000, 0x00020721, 0x4933c857, + 0x4d340000, 0x59326809, 0x59340200, 0x8c00050e, + 0x04000006, 0x59300406, 0x82000c80, 0x00000012, + 0x04021004, 0x0c01f806, 0x5c026800, 0x1c01f000, + 0x0201f800, 0x00108d7c, 0x0401f7fc, 0x00108d7c, + 0x001091fd, 0x00109201, 0x00109204, 0x0010a49b, + 0x0010a4b8, 0x0010a4bc, 0x00108d7c, 0x00108d7c, + 0x00108d7c, 0x00108d7c, 0x00108d7c, 0x00108d7c, + 0x00108d7c, 0x00108d7c, 0x00108d7c, 0x00108d7c, + 0x00108d7c, 0x4803c856, 0x40000000, 0x40000000, + 0x1c01f000, 0x40000000, 0x40000000, 0x1c01f000, + 0x5930001c, 0x4803c857, 0x59300414, 0x4933c857, + 0x4803c857, 0x8c000502, 0x04000005, 0x84000502, + 0x84000540, 0x48026414, 0x1c01f000, 0x42000000, + 0xd0000000, 0x41300800, 0x0201f800, 0x00100b94, + 0x0401f80a, 0x04020008, 0x59a80037, 0x82000400, + 0x0000000a, 0x48026205, 0x59300414, 0x84000542, + 0x48026414, 0x1c01f000, 0x4933c857, 0x4d340000, + 0x59326809, 0x59340200, 0x8c00050e, 0x02000800, + 0x001005d8, 0x5930001c, 0x80000540, 0x0402002f, + 0x59a80021, 0x80000540, 0x0402002a, 0x4d1c0000, + 0x41323800, 0x0201f800, 0x0002075a, 0x04000023, + 0x4932381c, 0x591c0414, 0x84000542, 0x48023c14, + 0x49366009, 0x591c0406, 0x82000580, 0x00000003, + 0x04000006, 0x591c0202, 0x48026419, 0x591c0402, + 0x48026219, 0x0401f005, 0x591c0202, 0x48026219, + 0x591c0402, 0x48026419, 0x491e601e, 0x4a026406, + 0x00000001, 0x4a026403, 0x00000035, 0x4a026203, + 0x00000001, 0x42000800, 0x80000040, 0x0201f800, + 0x00020721, 0x411e6000, 0x5c023800, 0x80000580, + 0x5c026800, 0x1c01f000, 0x411e6000, 0x5c023800, + 0x59a80039, 0x48026205, 0x82000540, 0x00000001, + 0x0401f7f8, 0x4933c857, 0x4d2c0000, 0x4932381c, + 0x4a026202, 0x0000ffff, 0x591e5808, 0x591c0007, + 0x8c00051e, 0x04000005, 0x8400051e, 0x48023807, + 0x497a5c09, 0x0401f014, 0x592c0408, 0x8c000518, + 0x04000011, 0x84000518, 0x48025c08, 0x4a025c09, + 0x00000001, 0x0401fb2f, 0x497a5c09, 0x592c0408, + 0x8c000512, 0x04000008, 0x4d2c0000, 0x84000512, + 0x48025c08, 0x592e5809, 0x0201f800, 0x001007fd, + 0x5c025800, 0x59a80039, 0x48026205, 0x591c0214, + 0x48026216, 0x82000d80, 0x00000001, 0x04000008, + 0x4a023a03, 0x00000002, 0x82000580, 0x00000005, + 0x04000008, 0x497a6015, 0x0401f01e, 0x591c0007, + 0x84000540, 0x48023807, 0x4a023a03, 0x00000004, + 0x591c0414, 0x4803c857, 0x8400051c, 0x84000554, + 0x48023c14, 0x592c000f, 0x40001000, 0x591c0816, + 0x80040480, 0x040217f0, 0x591c0016, 0x82000500, + 0xfffffffc, 0x48026015, 0x48023816, 0x591c0a14, + 0x4807c857, 0x82040d80, 0x00000005, 0x04020005, + 0x480bc857, 0x4803c857, 0x4a023812, 0xffffffff, + 0x591c0402, 0x48026419, 0x591c0202, 0x48026219, + 0x591e6809, 0x49366009, 0x4a026406, 0x00000001, + 0x4a026403, 0x00000039, 0x4a026203, 0x00000001, + 0x42000800, 0x80000040, 0x0201f800, 0x00020721, + 0x5c025800, 0x1c01f000, 0x4933c857, 0x59300414, + 0x8c000514, 0x04000015, 0x8c00051c, 0x04020012, + 0x59300016, 0x80100480, 0x04001006, 0x04000005, + 0x59300414, 0x84000514, 0x8400055c, 0x0401f009, + 0x48126016, 0x48126012, 0x40100000, 0x592c180f, + 0x800c0480, 0x48026011, 0x59300414, 0x84000514, + 0x48026414, 0x1c01f000, 0x4933c857, 0x8c00051c, + 0x04020006, 0x59300012, 0x48026016, 0x59300414, + 0x8400055c, 0x48026414, 0x1c01f000, 0x59300c03, + 0x4933c857, 0x4807c857, 0x82040480, 0x00000034, + 0x04001006, 0x82040480, 0x0000003c, 0x04021003, + 0x80000580, 0x1c01f000, 0x82000540, 0x00000001, + 0x0401f7fd, 0x41780800, 0x59a81035, 0x42000000, + 0x00000032, 0x0201f800, 0x001066a0, 0x800811c0, + 0x04020003, 0x42001000, 0x00000014, 0x480b5037, + 0x59a81036, 0x480b502d, 0x41780800, 0x42000000, + 0x00000064, 0x0201f800, 0x001066a0, 0x800811c0, + 0x04020003, 0x42001000, 0x00000014, 0x480b5038, + 0x82081400, 0x0000000a, 0x480b5039, 0x42000800, + 0x00000001, 0x0201f800, 0x00106c78, 0x42000000, + 0x30000000, 0x40080800, 0x0201f800, 0x00100b68, + 0x42000800, 0x00000003, 0x59a81010, 0x0201f800, + 0x00106c78, 0x0201f000, 0x00104906, 0x4a035037, + 0x00000028, 0x4a035038, 0x00000014, 0x4a03502d, + 0x000007d0, 0x42001000, 0x0000001e, 0x480b5039, + 0x42000800, 0x00000001, 0x0201f800, 0x00106c78, + 0x42000000, 0x30000000, 0x40080800, 0x0201f800, + 0x00100b68, 0x42000800, 0x00000003, 0x59a81010, + 0x0201f000, 0x00106c78, 0x4933c857, 0x4d2c0000, + 0x59300403, 0x82000580, 0x0000003e, 0x04020005, + 0x59325817, 0x812e59c0, 0x02020800, 0x001007f4, + 0x5c025800, 0x1c01f000, 0x4937c857, 0x4d300000, + 0x0201f800, 0x0002075a, 0x04000011, 0x49366009, + 0x4a026406, 0x00000001, 0x492e6008, 0x42000800, + 0x00000009, 0x0201f800, 0x00104571, 0x4d380000, + 0x42027000, 0x00000033, 0x0201f800, 0x000207a1, + 0x5c027000, 0x82000540, 0x00000001, 0x5c026000, + 0x1c01f000, 0x4933c857, 0x4d2c0000, 0x4c580000, + 0x4d3c0000, 0x59325808, 0x83380580, 0x00000015, + 0x04020022, 0x59a8b016, 0x82580c80, 0x00000019, + 0x04001003, 0x4200b000, 0x00000018, 0x8058b104, + 0x0401fa07, 0x80000580, 0x0401fa17, 0x832cac00, + 0x00000009, 0x83cca400, 0x00000006, 0x0201f800, + 0x0010ab17, 0x42027800, 0x00000001, 0x592c100a, + 0x8c081518, 0x04020006, 0x59a80010, 0x592c100d, + 0x80080580, 0x04020006, 0x417a7800, 0x59301009, + 0x58081403, 0x0201f800, 0x001020a1, 0x0201f800, + 0x00107b38, 0x0401f008, 0x4200b000, 0x00000002, + 0x0401fa09, 0x0201f800, 0x0010801c, 0x0201f800, + 0x0002077d, 0x5c027800, 0x5c00b000, 0x5c025800, + 0x1c01f000, 0x4933c856, 0x49366009, 0x4a026406, + 0x00000001, 0x492e6008, 0x4d380000, 0x42027000, + 0x0000004d, 0x0201f800, 0x000207a1, 0x5c027000, + 0x82000540, 0x00000001, 0x1c01f000, 0x4803c856, + 0x4d2c0000, 0x83380580, 0x00000015, 0x04020027, + 0x59a80816, 0x59325808, 0x5930040b, 0x800000c4, + 0x80040580, 0x04020021, 0x4c500000, 0x4c540000, + 0x4c580000, 0x83cca400, 0x00000006, 0x4050a800, + 0x5930b40b, 0x0201f800, 0x0010ab28, 0x83cca400, + 0x00000006, 0x592cb205, 0x832cac00, 0x00000006, + 0x0201f800, 0x0010ab17, 0x592e5801, 0x812e59c0, + 0x040207f9, 0x5931d821, 0x58ef400b, 0x58ee580d, + 0x4a025a04, 0x00000103, 0x58ec0009, 0x0801f800, + 0x59300402, 0x5c00b000, 0x5c00a800, 0x5c00a000, + 0x5c025800, 0x1c01f000, 0x0201f800, 0x0010801c, + 0x5c025800, 0x1c01f000, 0x4933c857, 0x83380580, + 0x00000035, 0x04000005, 0x59301419, 0x0401f851, + 0x04000027, 0x0401f006, 0x4d300000, 0x5932601e, + 0x0401f856, 0x5c026000, 0x04000020, 0x591c0c06, + 0x82040580, 0x00000003, 0x04000004, 0x82040580, + 0x00000006, 0x0402001c, 0x591c0c02, 0x59300419, + 0x80040580, 0x04000009, 0x59300219, 0x80040580, + 0x04020015, 0x591c0a02, 0x59300419, 0x80040580, + 0x04020011, 0x0401f009, 0x59300a19, 0x82040580, + 0x0000ffff, 0x04000005, 0x591c0202, 0x59300a19, + 0x80040580, 0x04020008, 0x591c0009, 0x59300809, + 0x80040580, 0x1c01f000, 0x417a3800, 0x82000540, + 0x00000001, 0x1c01f000, 0x4803c856, 0x59b800e4, + 0x8c000538, 0x02020800, 0x001005d8, 0x42000800, + 0x0000012c, 0x4a0370e4, 0x20000000, 0x59b800e4, + 0x80040840, 0x02000800, 0x001005d8, 0x8c00053c, + 0x040207f9, 0x4a0370e4, 0x30000000, 0x40000000, + 0x40000000, 0x40000000, 0x59b800e4, 0x8c00053c, + 0x040207f1, 0x1c01f000, 0x4803c856, 0x4a0370e4, + 0x20000000, 0x40000000, 0x59b800e4, 0x8c000538, + 0x040207fb, 0x1c01f000, 0x59300807, 0x8c040d1e, + 0x592c0c08, 0x04020002, 0x8c040d18, 0x1c01f000, + 0x0401fc1c, 0x04000008, 0x42000800, 0x00000024, + 0x0201f800, 0x00106681, 0x82063c00, 0x0010d1c0, + 0x491fc857, 0x1c01f000, 0x83300480, 0x0010d1c0, + 0x0400100a, 0x59a8000b, 0x81300480, 0x04021007, + 0x59301402, 0x0401ffef, 0x04000007, 0x411c0000, + 0x81300580, 0x04000003, 0x81780500, 0x0401f002, + 0x81300540, 0x1c01f000, 0x4947c857, 0x4d300000, + 0x0201f800, 0x00020245, 0x0402000a, 0x42026000, + 0x0010bde9, 0x49366009, 0x492e6008, 0x0201f800, + 0x0010203c, 0x80000580, 0x5c026000, 0x1c01f000, + 0x82000540, 0x00000001, 0x0401f7fc, 0x4933c857, + 0x0201f800, 0x00109037, 0x02000800, 0x001005d8, + 0x4d2c0000, 0x4d340000, 0x4d440000, 0x4c580000, + 0x59325808, 0x59326809, 0x49425a06, 0x0201f800, + 0x00105755, 0x592e8c06, 0x592c4207, 0x82200500, + 0x0000000f, 0x0c01f806, 0x5c00b000, 0x5c028800, + 0x5c026800, 0x5c025800, 0x1c01f000, 0x00109466, + 0x00109488, 0x0010948f, 0x00109493, 0x0010949c, + 0x00109463, 0x00109463, 0x00109463, 0x001094a0, + 0x001094ac, 0x001094ac, 0x00109463, 0x00109463, + 0x00109463, 0x00109463, 0x00109463, 0x4803c857, + 0x0201f800, 0x001005d8, 0x814281c0, 0x04020012, + 0x41785800, 0x592c0404, 0x8c00051c, 0x04020002, + 0x59345c05, 0x442c2800, 0x59340008, 0x48002802, + 0x59340009, 0x48002801, 0x59340006, 0x48002804, + 0x59340007, 0x48002803, 0x4200b000, 0x0000000b, + 0x0401f037, 0x592c0207, 0x8c00051e, 0x4200b000, + 0x00000002, 0x04020032, 0x8204b540, 0x00000000, + 0x0400002f, 0x44042800, 0x59326809, 0x59340400, + 0x48002801, 0x4200b000, 0x00000002, 0x0401f028, + 0x814281c0, 0x04020030, 0x59345c05, 0x442c2800, + 0x4200b000, 0x00000001, 0x0401f021, 0x8340b540, + 0x00000000, 0x0400001e, 0x0401f027, 0x814281c0, + 0x04020025, 0x59340200, 0x44002800, 0x59340001, + 0x48002801, 0x4200b000, 0x00000002, 0x0401f014, + 0x8340b540, 0x00000000, 0x0402001b, 0x0401f010, + 0x8340b540, 0x00000000, 0x0400000d, 0x0201f800, + 0x00104a1f, 0x04000014, 0x8c20450e, 0x04000002, + 0x497a6009, 0x4178b000, 0x497a5a06, 0x0401f004, + 0x8340b540, 0x00000000, 0x0402000b, 0x592c0404, + 0x8400051c, 0x48025c04, 0x592c0207, 0x8400051e, + 0x48025a07, 0x0401f8aa, 0x497a6008, 0x0201f000, + 0x000202da, 0x592c0207, 0x8c00051e, 0x4200b000, + 0x00000002, 0x040207f2, 0x8204b540, 0x00000000, + 0x040007ef, 0x44042800, 0x4200b000, 0x00000001, + 0x0401f7eb, 0x4937c857, 0x4d300000, 0x0201f800, + 0x0002075a, 0x04000011, 0x49366009, 0x4a026406, + 0x00000001, 0x492e6008, 0x42000800, 0x0000000b, + 0x0201f800, 0x00104571, 0x4d380000, 0x42027000, + 0x00000043, 0x0201f800, 0x000207a1, 0x5c027000, + 0x82000540, 0x00000001, 0x5c026000, 0x1c01f000, + 0x4937c857, 0x4d2c0000, 0x59325808, 0x83380580, + 0x00000015, 0x04020025, 0x59a80016, 0x82000580, + 0x00000004, 0x04020021, 0x59a80010, 0x592c1009, + 0x80080580, 0x04020010, 0x4d440000, 0x592e8c06, + 0x592c0207, 0x4803c856, 0x82000500, 0x00000080, + 0x84000548, 0x4d3c0000, 0x42027800, 0x00001000, + 0x0201f800, 0x001049bb, 0x5c027800, 0x5c028800, + 0x0401f004, 0x4803c856, 0x0201f800, 0x00104a1f, + 0x0201f800, 0x00109037, 0x04000017, 0x4d400000, + 0x42028000, 0x00000000, 0x41780800, 0x0401ff38, + 0x5c028000, 0x0401f00e, 0x0201f800, 0x00104a1f, + 0x040207f4, 0x0201f800, 0x00109037, 0x0400000a, + 0x4c580000, 0x4200b000, 0x00000002, 0x0401f86e, + 0x5c00b000, 0x0201f800, 0x0010801c, 0x0201f800, + 0x0002077d, 0x5c025800, 0x1c01f000, 0x4937c857, + 0x4d300000, 0x0201f800, 0x0002075a, 0x04000012, + 0x49366009, 0x4a026406, 0x00000001, 0x4d3c0000, + 0x4d380000, 0x417a7800, 0x0201f800, 0x00104567, + 0x492e6008, 0x42027000, 0x00000004, 0x0201f800, + 0x000207a1, 0x5c027000, 0x5c027800, 0x82000540, + 0x00000001, 0x5c026000, 0x1c01f000, 0x4937c857, + 0x4d300000, 0x0201f800, 0x00107942, 0x0400000d, + 0x49366009, 0x4a026406, 0x00000001, 0x492e6008, + 0x4d380000, 0x42027000, 0x00000051, 0x0201f800, + 0x000207a1, 0x5c027000, 0x82000540, 0x00000001, + 0x5c026000, 0x1c01f000, 0x4933c857, 0x4c580000, + 0x59325808, 0x83383580, 0x00000015, 0x04020011, + 0x592c0008, 0x82000500, 0x00ffffff, 0x0402000a, + 0x0201f800, 0x00105755, 0x59cc0000, 0x82000500, + 0x00ffffff, 0x44002800, 0x4200b000, 0x00000001, + 0x0401f80b, 0x0201f800, 0x00107b38, 0x0401f006, + 0x4200b000, 0x00000002, 0x0401f823, 0x0201f800, + 0x0010801c, 0x5c00b000, 0x1c01f000, 0x492fc857, + 0x4c580000, 0x4c000000, 0x8058b1c0, 0x0400000b, + 0x82580500, 0xfffffff0, 0x02020800, 0x001005d8, + 0x8058b0d0, 0x592c0408, 0x82000500, 0xfffff0ff, + 0x80580540, 0x48025c08, 0x5c000000, 0x5c00b000, + 0x1c01f000, 0x492fc857, 0x4c000000, 0x4c040000, + 0x800000d8, 0x592c0c08, 0x82040d00, 0xffff0fff, + 0x80040540, 0x48025c08, 0x5c000800, 0x5c000000, + 0x1c01f000, 0x4933c857, 0x4d2c0000, 0x59325808, + 0x592c0207, 0x8400055e, 0x48025a07, 0x4c500000, + 0x4c540000, 0x4c580000, 0x0401ffd9, 0x0201f800, + 0x00105755, 0x46002800, 0x00000018, 0x80142800, + 0x8058b040, 0x83cca400, 0x00000007, 0x4014a800, + 0x0201f800, 0x0010ab17, 0x5c00b000, 0x5c00a800, + 0x5c00a000, 0x5c025800, 0x1c01f000, 0x59325808, + 0x592c0204, 0x82000580, 0x00000152, 0x1c01f000, + 0x5930001f, 0x80000540, 0x02020800, 0x00100d56, + 0x1c01f000, 0x4d2c0000, 0x59325808, 0x59300203, + 0x4933c857, 0x492fc857, 0x493bc857, 0x4803c857, + 0x82003480, 0x0000000e, 0x02021800, 0x001005d8, + 0x0c01f803, 0x5c025800, 0x1c01f000, 0x001095bd, + 0x001095c8, 0x00109603, 0x001095bd, 0x001095bd, + 0x001095bd, 0x001095bd, 0x001095bd, 0x001095bf, + 0x001095bd, 0x001095bd, 0x001095bd, 0x001095bd, + 0x001095bd, 0x0201f800, 0x001005d8, 0x83383480, + 0x00000056, 0x02021800, 0x001005d8, 0x493a6403, + 0x4a026203, 0x00000001, 0x0201f000, 0x0010672b, + 0x83380580, 0x00000013, 0x0402000f, 0x592c000c, + 0x800001c0, 0x04000006, 0x4a026203, 0x00000002, + 0x59a80037, 0x48026206, 0x1c01f000, 0x4a025a06, + 0x00000000, 0x0201f800, 0x000202da, 0x0201f000, + 0x0002077d, 0x83380580, 0x00000027, 0x0400001a, + 0x83380580, 0x00000014, 0x04000012, 0x83380580, + 0x00000015, 0x04000005, 0x83380580, 0x00000016, + 0x02020800, 0x001005d8, 0x0201f800, 0x00106f60, + 0x02020000, 0x00107974, 0x59300203, 0x82000580, + 0x00000002, 0x02020800, 0x001005d8, 0x0401f014, + 0x0201f800, 0x00106bbf, 0x4a02580e, 0x00000011, + 0x0401f005, 0x0201f800, 0x00106bbf, 0x4a02580e, + 0x00000010, 0x4a025a06, 0x00000031, 0x4a02580d, + 0x00000004, 0x0201f800, 0x000202da, 0x0201f800, + 0x00104c19, 0x0201f000, 0x00107911, 0x59341400, + 0x82081d00, 0x000000ff, 0x59300c03, 0x480bc857, + 0x4807c857, 0x82040580, 0x00000053, 0x0400002e, + 0x82040580, 0x00000002, 0x04000016, 0x82040580, + 0x00000001, 0x04000017, 0x82040580, 0x00000003, + 0x0400001c, 0x82040580, 0x00000005, 0x0400001d, + 0x82040580, 0x00000033, 0x0400001a, 0x82040580, + 0x00000000, 0x0400001b, 0x82040580, 0x00000004, + 0x02020800, 0x001005d8, 0x0401f8a1, 0x0401f016, + 0x820c0580, 0x00000003, 0x0400084c, 0x0401f012, + 0x820c0580, 0x0000000b, 0x0402000f, 0x42000800, + 0x00000007, 0x0201f800, 0x00104571, 0x0401f00a, + 0x820c0580, 0x00000005, 0x04000864, 0x0401f006, + 0x820c0580, 0x00000009, 0x04000889, 0x0401f002, + 0x0401f893, 0x4a026403, 0x00000052, 0x59a81016, + 0x592c040b, 0x8c000500, 0x04000003, 0x42001000, + 0x00000008, 0x592c040b, 0x8c000516, 0x04000003, + 0x82081400, 0x00000018, 0x592c000c, 0x497a580d, + 0x497a580e, 0x80080c80, 0x04000009, 0x04001005, + 0x4a025a06, 0x00000007, 0x40001000, 0x0401f006, + 0x4a025a06, 0x00000015, 0x0401f003, 0x4a025a06, + 0x00000000, 0x480a580c, 0x82081400, 0x00000003, + 0x80081104, 0x0201f800, 0x00107ab5, 0x04000010, + 0x592c1001, 0x480a600b, 0x58080800, 0x82080400, + 0x00000002, 0x592c1011, 0x592c1812, 0x42003000, + 0x00000000, 0x42002000, 0x00101200, 0x0201f800, + 0x00107c32, 0x04000002, 0x1c01f000, 0x4a025a06, + 0x0000002c, 0x497a580c, 0x0201f800, 0x000202da, + 0x0201f000, 0x0002077d, 0x83380580, 0x00000015, + 0x0402000a, 0x59a80005, 0x8c000514, 0x0402000b, + 0x0201f800, 0x0010462a, 0x42000800, 0x00000004, + 0x0201f000, 0x00104571, 0x42000800, 0x00000007, + 0x0201f000, 0x00104571, 0x0201f800, 0x0010513b, + 0x42001000, 0x00000010, 0x04020009, 0x59340002, + 0x82000500, 0x00ff0000, 0x82000580, 0x00ff0000, + 0x040007ec, 0x42001000, 0x00000008, 0x0201f800, + 0x00104c6d, 0x040007e7, 0x592c040b, 0x84000540, + 0x48025c0b, 0x0401f7e9, 0x83380580, 0x00000015, + 0x0402000f, 0x59a80005, 0x8c000514, 0x04020010, + 0x0201f800, 0x0010468d, 0x4d3c0000, 0x417a7800, + 0x0201f800, 0x00104567, 0x5c027800, 0x42000800, + 0x00000006, 0x0201f000, 0x00104571, 0x42000800, + 0x00000004, 0x0201f000, 0x00104571, 0x0201f800, + 0x0010513b, 0x42001000, 0x00000010, 0x04020009, + 0x59340002, 0x82000500, 0x00ff0000, 0x82000580, + 0x00ff0000, 0x040007e7, 0x42001000, 0x00000008, + 0x0201f800, 0x00104c6d, 0x040007e2, 0x592c040b, + 0x84000540, 0x48025c0b, 0x0401f7e9, 0x42000800, + 0x00000004, 0x0201f000, 0x00104571, 0x83380580, + 0x00000015, 0x04020005, 0x0201f800, 0x0010a2c8, + 0x02000800, 0x001048c1, 0x1c01f000, 0x83380580, + 0x00000015, 0x0402001d, 0x4c580000, 0x83cc1400, + 0x00000008, 0x4200b000, 0x00000002, 0x83341c00, + 0x00000006, 0x0201f800, 0x0010855a, 0x04020012, + 0x83cc1400, 0x0000000a, 0x4200b000, 0x00000002, + 0x83341c00, 0x00000008, 0x0201f800, 0x0010855a, + 0x04020009, 0x59342200, 0x59cc1007, 0x800811c0, + 0x04000003, 0x480a6801, 0x84102542, 0x8410251a, + 0x48126a00, 0x5c00b000, 0x1c01f000, 0x42000000, + 0x0010b87b, 0x0201f800, 0x0010aa47, 0x0201f800, + 0x00106c55, 0x59300203, 0x4933c857, 0x4803c857, + 0x82000c80, 0x0000000e, 0x02021800, 0x001005d8, + 0x0c01f803, 0x0201f000, 0x00106c4b, 0x0010970b, + 0x0010971a, 0x0010970c, 0x00109709, 0x00109709, + 0x00109709, 0x00109709, 0x00109709, 0x00109709, + 0x00109709, 0x00109709, 0x00109709, 0x00109709, + 0x00109709, 0x0201f800, 0x001005d8, 0x1c01f000, + 0x59300403, 0x82000580, 0x00000052, 0x02000000, + 0x00108d85, 0x0201f800, 0x00104c19, 0x59325808, + 0x4a025a06, 0x00000006, 0x0201f800, 0x000202da, + 0x0201f000, 0x00107911, 0x59301804, 0x840c0520, + 0x48026004, 0x598c000d, 0x81300580, 0x04020010, + 0x8c0c1d20, 0x04020010, 0x42001000, 0x0010b7f6, + 0x50081000, 0x58080002, 0x82000580, 0x00000100, + 0x0400000e, 0x5808000c, 0x81300580, 0x02020800, + 0x001005d8, 0x4978100c, 0x0401f003, 0x8c0c1d20, + 0x040207dc, 0x0201f800, 0x001068d3, 0x040007d9, + 0x0201f800, 0x001005d8, 0x0201f800, 0x00106e8e, + 0x040007f9, 0x59300203, 0x82000c80, 0x0000000e, + 0x02021800, 0x001005d8, 0x0c01f7bd, 0x4933c857, + 0x4c500000, 0x4c540000, 0x4c580000, 0x592c0c07, + 0x4806580a, 0x59cc0809, 0x48065807, 0x59cc0a08, + 0x4806580b, 0x59c80817, 0x82040500, 0x000003ff, + 0x800010c4, 0x8c040d14, 0x04000005, 0x59cc0002, + 0x82000500, 0x00000003, 0x80081480, 0x82080480, + 0x000000f1, 0x02021800, 0x001005d8, 0x480a621a, + 0x412c0800, 0x0201f800, 0x001007d3, 0x02000800, + 0x001005d8, 0x492c0809, 0x58040408, 0x84000552, + 0x84000540, 0x48000c08, 0x82081400, 0x00000003, + 0x80081104, 0x83cca400, 0x00000006, 0x832cac00, + 0x00000004, 0x42000800, 0x00000010, 0x82080480, + 0x00000010, 0x04021003, 0x40080800, 0x80000580, + 0x4004b000, 0x4c000000, 0x0201f800, 0x0010ab28, + 0x5c000000, 0x800001c0, 0x0400000d, 0x412c1000, + 0x4c000000, 0x0201f800, 0x001007d3, 0x02000800, + 0x001005d8, 0x492c1001, 0x832cac00, 0x00000004, + 0x5c000000, 0x40001000, 0x0401f7e9, 0x5c00b000, + 0x5c00a800, 0x5c00a000, 0x1c01f000, 0x4933c857, + 0x4d2c0000, 0x4c380000, 0x59325808, 0x5930021a, + 0x48025a08, 0x59301011, 0x800811c0, 0x04020008, + 0x4a025a06, 0x00000000, 0x592c000b, 0x82000500, + 0x00000c00, 0x0400000b, 0x0401f00b, 0x8c08153e, + 0x04000006, 0x4a025a06, 0x00000007, 0x80081080, + 0x80081000, 0x0401f003, 0x4a025a06, 0x00000015, + 0x480a5807, 0x42000000, 0x0010bed9, 0x50007000, + 0x5838000b, 0x80000540, 0x04020008, 0x4930700c, + 0x4930700b, 0x58380002, 0x82000580, 0x00000000, + 0x04020809, 0x0401f005, 0x82001400, 0x00000000, + 0x45301000, 0x4930700b, 0x5c007000, 0x5c025800, + 0x1c01f000, 0x4933c857, 0x592c0009, 0x40001000, + 0x4800700a, 0x82080400, 0x00000004, 0x48007003, + 0x592c000d, 0x592c100e, 0x48007007, 0x48087008, + 0x592c000a, 0x592c1208, 0x80080c80, 0x04001002, + 0x40001000, 0x82081400, 0x00000003, 0x80081104, + 0x82080480, 0x00000010, 0x04021003, 0x80000580, + 0x0401f003, 0x42001000, 0x00000010, 0x4800700d, + 0x48087004, 0x800810c4, 0x48087005, 0x40381000, + 0x0201f800, 0x00100858, 0x1c01f000, 0x4d2c0000, + 0x0201f800, 0x001007d3, 0x02000800, 0x001005d8, + 0x42000800, 0x0010bed9, 0x452c0800, 0x497a580b, + 0x497a580c, 0x497a580d, 0x4a025809, 0x001097ea, + 0x4a025802, 0x00000100, 0x4a025801, 0x00000000, + 0x5c025800, 0x1c01f000, 0x4833c857, 0x4d300000, + 0x4d2c0000, 0x4c5c0000, 0x4030b800, 0x585c000a, + 0x80025d40, 0x04020004, 0x585c000c, 0x4c000000, + 0x0401f044, 0x585c0002, 0x82000580, 0x00000100, + 0x04020022, 0x592c0801, 0x4c040000, 0x0201f800, + 0x001007f4, 0x5c000800, 0x800409c0, 0x0400001c, + 0x4804b80a, 0x585c100d, 0x800811c0, 0x04020005, + 0x40065800, 0x0201f800, 0x001007fd, 0x0401f014, + 0x82080480, 0x00000010, 0x04021003, 0x80000580, + 0x0401f003, 0x42001000, 0x00000010, 0x4800b80d, + 0x4808b804, 0x800810c4, 0x4808b805, 0x82040400, + 0x00000004, 0x4800b803, 0x405c1000, 0x0201f800, + 0x00100858, 0x0401f025, 0x0401f828, 0x585c000c, + 0x80026540, 0x59300000, 0x80000d40, 0x04020002, + 0x4800b80b, 0x4800b80c, 0x497a6000, 0x4c000000, + 0x4978b80a, 0x59325808, 0x4a025a04, 0x00000103, + 0x59300402, 0x48025c06, 0x592c100b, 0x4c080000, + 0x0201f800, 0x000202c1, 0x0201f800, 0x0010912a, + 0x5c001000, 0x8c081518, 0x04000004, 0x0201f800, + 0x001091d1, 0x0401f003, 0x0201f800, 0x0002077d, + 0x405c7000, 0x5c000000, 0x80026540, 0x04000003, + 0x59325808, 0x0401ff78, 0x5c00b800, 0x5c025800, + 0x5c026000, 0x1c01f000, 0x483bc857, 0x5838000a, + 0x40025800, 0x0201f800, 0x001007fd, 0x5838000c, + 0x80026540, 0x59300008, 0x80025d40, 0x4a025a06, + 0x00000002, 0x1c01f000, 0x4803c857, 0x4d1c0000, + 0x497a601c, 0x41323800, 0x40026000, 0x4d3c0000, + 0x42027800, 0x00000005, 0x0401f83c, 0x5c027800, + 0x411e6000, 0x59300414, 0x84000502, 0x48026414, + 0x5c023800, 0x1c01f000, 0x481bc857, 0x4933c857, + 0x4c5c0000, 0x4c600000, 0x4010b800, 0x4014c000, + 0x0201f800, 0x0010a942, 0x0201f800, 0x00103b25, + 0x04000008, 0x40602800, 0x405c3000, 0x0201f800, + 0x0010a446, 0x82000540, 0x00000001, 0x0401f002, + 0x80000580, 0x5c00c000, 0x5c00b800, 0x1c01f000, + 0x4803c856, 0x4d300000, 0x42026000, 0x0010d1c0, + 0x59a8000e, 0x81640580, 0x04000016, 0x59300c06, + 0x82040580, 0x00000001, 0x04000009, 0x82040580, + 0x00000004, 0x04000006, 0x82040580, 0x00000010, + 0x02000800, 0x00108cf9, 0x0401f005, 0x4807c857, + 0x0201f800, 0x001092d7, 0x04020808, 0x83326400, + 0x00000024, 0x41580000, 0x81300480, 0x040017e9, + 0x5c026000, 0x1c01f000, 0x4933c857, 0x59300403, + 0x4803c857, 0x0201f800, 0x00106c55, 0x4df00000, + 0x59300406, 0x4803c857, 0x82000d80, 0x00000002, + 0x04000018, 0x82000d80, 0x00000001, 0x04000009, + 0x82000d80, 0x00000004, 0x04000006, 0x4933c856, + 0x5c03e000, 0x02000800, 0x00106c4b, 0x0401f03c, + 0x59300203, 0x82000d80, 0x00000001, 0x04000018, + 0x82000d80, 0x00000002, 0x04000026, 0x82000d80, + 0x00000005, 0x04000023, 0x0201f800, 0x001005d8, + 0x59300203, 0x82000d80, 0x00000009, 0x0400000c, + 0x82000d80, 0x0000000b, 0x04000009, 0x82000d80, + 0x0000000a, 0x04000017, 0x82000d80, 0x0000000c, + 0x04000014, 0x0201f800, 0x001005d8, 0x598c000d, + 0x81300580, 0x04020004, 0x0201f800, 0x00106e8e, + 0x0402000c, 0x59300004, 0x4803c857, 0x8c000520, + 0x04000004, 0x84000520, 0x48026004, 0x0401f005, + 0x0201f800, 0x001068d3, 0x02020800, 0x001005d8, + 0x5c03e000, 0x02000800, 0x00106c4b, 0x59300406, + 0x82000d80, 0x00000002, 0x04000009, 0x0201f800, + 0x00104c19, 0x0201f800, 0x0010914e, 0x02000800, + 0x0010801c, 0x8d3e7d00, 0x04000003, 0x0201f000, + 0x00107911, 0x4a02621d, 0x00000001, 0x4a026403, + 0x00000085, 0x4a026203, 0x00000009, 0x4a026406, + 0x00000002, 0x42000800, 0x8000004b, 0x0201f000, + 0x00020721, 0x4933c857, 0x59368c03, 0x4c180000, + 0x59300203, 0x82003480, 0x0000000e, 0x02021800, + 0x001005d8, 0x0c01f803, 0x5c003000, 0x1c01f000, + 0x0010990a, 0x00109dcf, 0x00109edb, 0x0010990a, + 0x0010990a, 0x0010990a, 0x0010990a, 0x0010990a, + 0x0010992d, 0x0010990a, 0x0010990a, 0x0010990a, + 0x0010990a, 0x0010990a, 0x0201f800, 0x001005d8, + 0x4933c857, 0x42028800, 0x0000ffff, 0x813669c0, + 0x04000002, 0x59368c03, 0x4c180000, 0x59300203, + 0x82003480, 0x0000000e, 0x02021800, 0x001005d8, + 0x0c01f803, 0x5c003000, 0x1c01f000, 0x00109929, + 0x0010a180, 0x00109929, 0x00109929, 0x00109929, + 0x00109929, 0x00109929, 0x0010a952, 0x0010a0ed, + 0x0010a52c, 0x0010a562, 0x0010a52c, 0x0010a562, + 0x00109929, 0x0201f800, 0x001005d8, 0x0201f800, + 0x001005d8, 0x83383480, 0x00000051, 0x02021800, + 0x001005d8, 0x41380000, 0x493bc857, 0x4d1c0000, + 0x4d400000, 0x0c01f804, 0x5c028000, 0x5c023800, + 0x1c01f000, 0x0010998a, 0x00109b69, 0x0010998a, + 0x0010998a, 0x0010998a, 0x00109b74, 0x0010998a, + 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a, + 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a, + 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a, + 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a, + 0x001099ac, 0x001099f5, 0x00109a0c, 0x00109a62, + 0x00109ac6, 0x00109b04, 0x00109b34, 0x0010998a, + 0x0010998a, 0x00109b7c, 0x0010998a, 0x0010998a, + 0x00109b8a, 0x00109b93, 0x0010998a, 0x0010998a, + 0x0010998a, 0x0010998a, 0x0010998a, 0x00109c15, + 0x0010998a, 0x0010998a, 0x00109a9a, 0x0010998a, + 0x0010998a, 0x00109bec, 0x0010998a, 0x0010998a, + 0x0010998a, 0x00109c23, 0x0010998a, 0x0010998a, + 0x0010998a, 0x00109c6c, 0x0010998a, 0x0010998a, + 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a, + 0x00109cb9, 0x0010998a, 0x00109ce5, 0x00109cf0, + 0x0010998a, 0x0010998a, 0x0010998c, 0x00109cfb, + 0x0010998a, 0x0010998a, 0x0010998a, 0x0010999b, + 0x0010998a, 0x0010998a, 0x0010998a, 0x00109d02, + 0x00109d0a, 0x00109d28, 0x0201f800, 0x001005d8, + 0x4933c857, 0x0201f800, 0x0010a592, 0x040203a4, + 0x0201f800, 0x0010210a, 0x040203a1, 0x59cc0407, + 0x4802601c, 0x4a026403, 0x00000045, 0x4a026203, + 0x00000001, 0x0201f000, 0x0010672b, 0x4933c857, + 0x0201f800, 0x0010a592, 0x04020395, 0x0201f800, + 0x0010210a, 0x04020392, 0x0401fbce, 0x040201a0, + 0x59cc0007, 0x4802601c, 0x4a026403, 0x0000004a, + 0x4a026203, 0x00000001, 0x0201f000, 0x0010672b, + 0x4933c857, 0x0201f800, 0x0010210a, 0x04020009, + 0x0201f800, 0x001048ec, 0x04020006, 0x82000500, + 0x00000009, 0x82000580, 0x00000008, 0x04020008, + 0x4a026403, 0x00000009, 0x4a02641a, 0x00000009, + 0x4a02621a, 0x00000000, 0x0401f1b2, 0x0201f800, + 0x001048c1, 0x0201f800, 0x00104a09, 0x04000021, + 0x0201f800, 0x001049ed, 0x0400001e, 0x0201f800, + 0x0010a252, 0x04020025, 0x42028000, 0x00000029, + 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c, + 0x5c027800, 0x0201f800, 0x0010462a, 0x836c0580, + 0x00000002, 0x04020004, 0x59a8001b, 0x80000000, + 0x4803501b, 0x4a026403, 0x00000008, 0x42003000, + 0x00000003, 0x0201f800, 0x00103b25, 0x04000191, + 0x4a026203, 0x00000007, 0x41782800, 0x0401f180, + 0x0201f800, 0x0010a3da, 0x040207e1, 0x4a026403, + 0x00000009, 0x4a02641a, 0x0000000e, 0x4a02621a, + 0x00001900, 0x0401f183, 0x4a026403, 0x00000009, + 0x4a02641a, 0x00000003, 0x4a02621a, 0x00000f00, + 0x0401f17c, 0x4933c857, 0x0201f800, 0x0010210a, + 0x0402033b, 0x0201f800, 0x001048ec, 0x04020338, + 0x493a6403, 0x0201f800, 0x0010a22d, 0x04020006, + 0x42003000, 0x00000005, 0x4a026403, 0x00000006, + 0x0401f7d9, 0x4a026403, 0x00000007, 0x4a02641a, + 0x00000009, 0x4a02621a, 0x00000000, 0x0401f165, + 0x4933c857, 0x0201f800, 0x001048ec, 0x04020324, + 0x0201f800, 0x0010a592, 0x02000800, 0x0010210a, + 0x0402031f, 0x0201f800, 0x00104a09, 0x04020005, + 0x42027800, 0x00000001, 0x0201f800, 0x00104567, + 0x0201f800, 0x001049fc, 0x0402002b, 0x59cc0206, + 0x82003500, 0x00000003, 0x0402002e, 0x82003480, + 0x00000014, 0x0400102b, 0x5934300a, 0x84183516, + 0x82000580, 0x00000014, 0x04020002, 0x84183556, + 0x481a680a, 0x59cc0406, 0x82000500, 0x00000003, + 0x04020020, 0x0201f800, 0x0010a29f, 0x04020028, + 0x0201f800, 0x001049e7, 0x0402000c, 0x417a7800, + 0x0201f800, 0x001020a1, 0x42003000, 0x00000006, + 0x0201f800, 0x0010a93a, 0x42000000, 0x0010b865, + 0x0201f800, 0x0010aa47, 0x0201f800, 0x0010468d, + 0x4a026403, 0x0000000a, 0x42003000, 0x00000020, + 0x0401f795, 0x4a026403, 0x0000000b, 0x4a02641a, + 0x00000009, 0x4a02621a, 0x00001e00, 0x0401f121, + 0x42000000, 0x0010b860, 0x0201f800, 0x0010aa47, + 0x4a026403, 0x0000000b, 0x4a02641a, 0x00000007, + 0x4a02621a, 0x00000000, 0x0401f116, 0x4a026403, + 0x0000000b, 0x4a02641a, 0x00000003, 0x4a02621a, + 0x00000000, 0x0401f10f, 0x4933c857, 0x0201f800, + 0x001048ec, 0x040202ce, 0x0201f800, 0x0010a592, + 0x040202cb, 0x0201f800, 0x0010210a, 0x040202c8, + 0x59cc0206, 0x82003500, 0x00000003, 0x0402001d, + 0x82003480, 0x00000014, 0x0400101a, 0x59cc0406, + 0x82000500, 0x00000003, 0x04020016, 0x59340400, + 0x82000580, 0x00000707, 0x04000019, 0x417a7800, + 0x0201f800, 0x001020a1, 0x42003000, 0x0000000a, + 0x0201f800, 0x0010a93a, 0x42000000, 0x0010b862, + 0x0201f800, 0x0010aa47, 0x4a026403, 0x0000000c, + 0x41782800, 0x42003000, 0x00000021, 0x0401f752, + 0x4a026403, 0x0000000d, 0x4a02641a, 0x00000007, + 0x4a02621a, 0x00000000, 0x0401f0de, 0x4a026403, + 0x0000000d, 0x4a02641a, 0x00000009, 0x4a02621a, + 0x00001e00, 0x0401f0d7, 0x4933c857, 0x0201f800, + 0x001048ec, 0x04020296, 0x0201f800, 0x0010a592, + 0x04020293, 0x0201f800, 0x0010210a, 0x04020290, + 0x0401facc, 0x0402001a, 0x493a6403, 0x4c5c0000, + 0x0401fad2, 0x0402000e, 0x4a026403, 0x0000002e, + 0x405c2800, 0x42003000, 0x00000024, 0x0201f800, + 0x00103b25, 0x0400000c, 0x4a026203, 0x00000007, + 0x405c2800, 0x5c00b800, 0x0401f0ad, 0x4a026403, + 0x0000000d, 0x4a02641a, 0x00000007, 0x4a02621a, + 0x00000000, 0x5c00b800, 0x0401f0b2, 0x4a026403, + 0x0000000d, 0x4a02641a, 0x00000009, 0x4a02621a, + 0x00001e00, 0x0401f0ab, 0x4933c857, 0x0201f800, + 0x001048ec, 0x040206ef, 0x59a80026, 0x82000500, + 0x00000009, 0x82000580, 0x00000008, 0x040006e9, + 0x0201f800, 0x001049fc, 0x0402002d, 0x0201f800, + 0x0010a2a7, 0x04020007, 0x4a026403, 0x0000000e, + 0x41782800, 0x42003000, 0x00000052, 0x0401f702, + 0x4933c857, 0x42003000, 0x00000003, 0x0201f800, + 0x0010a942, 0x4d3c0000, 0x417a7800, 0x0201f800, + 0x0010203c, 0x5c027800, 0x42000000, 0x0010b864, + 0x0201f800, 0x0010aa47, 0x59340200, 0x84000558, + 0x48026a00, 0x42000800, 0x0000000b, 0x0201f800, + 0x00104571, 0x0201f800, 0x00103b25, 0x04000076, + 0x42003000, 0x00000007, 0x0401f062, 0x4933c857, + 0x4a026403, 0x0000000f, 0x4a02641a, 0x00000003, + 0x4a02621a, 0x00001e00, 0x0401f072, 0x59340400, + 0x82000580, 0x00000703, 0x040007f5, 0x0401f040, + 0x4933c857, 0x0201f800, 0x001048ec, 0x0402022c, + 0x59a80026, 0x82000500, 0x00000009, 0x82000580, + 0x00000008, 0x04000226, 0x0201f800, 0x001049f3, + 0x0402002f, 0x0201f800, 0x0010a2c8, 0x02000800, + 0x0010a252, 0x04020007, 0x4a026403, 0x00000010, + 0x41782800, 0x42003000, 0x00000050, 0x0401f6c2, + 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c, + 0x5c027800, 0x42003000, 0x00000003, 0x0201f800, + 0x0010a942, 0x42000000, 0x0010b864, 0x0201f800, + 0x0010aa47, 0x59340200, 0x84000558, 0x48026a00, + 0x0401f7c5, 0x4a026403, 0x00000011, 0x4a02641a, + 0x00000003, 0x4a02621a, 0x00001e00, 0x0401f03d, + 0x4933c857, 0x0201f800, 0x0010210a, 0x02000800, + 0x0010a592, 0x040201fa, 0x0401fa36, 0x04020008, + 0x4a026403, 0x00000012, 0x0401f032, 0x59340400, + 0x82000580, 0x00000703, 0x040007eb, 0x4d3c0000, + 0x417a7800, 0x42028000, 0x00000029, 0x0201f800, + 0x0010203c, 0x5c027800, 0x42003000, 0x00000017, + 0x0201f800, 0x0010a942, 0x42000000, 0x0010b864, + 0x0201f800, 0x0010aa47, 0x0201f800, 0x00103b25, + 0x04000015, 0x42003000, 0x00000006, 0x41782800, + 0x42028000, 0x00000029, 0x4933c857, 0x4a026403, + 0x00000001, 0x4a026203, 0x00000007, 0x0201f800, + 0x0010a974, 0x0201f000, 0x0010a43e, 0x42028000, + 0x00000046, 0x0201f800, 0x0010a974, 0x0201f000, + 0x0010a43e, 0x4933c857, 0x4a026403, 0x00000001, + 0x42000800, 0x0000000b, 0x0201f800, 0x00104571, + 0x4a026203, 0x00000001, 0x0201f000, 0x0010672b, + 0x4933c857, 0x42000800, 0x00000009, 0x0201f800, + 0x00104571, 0x4a026403, 0x00000005, 0x0401f7f5, + 0x0201f800, 0x0010a592, 0x040201b5, 0x0201f800, + 0x0010210a, 0x040201b2, 0x0401f9ee, 0x040207c0, + 0x4a026403, 0x00000020, 0x4a026203, 0x00000001, + 0x0201f000, 0x0010672b, 0x0201f800, 0x0010210a, + 0x040201a7, 0x4a026403, 0x00000023, 0x4a026203, + 0x00000001, 0x0201f000, 0x0010672b, 0x0201f800, + 0x0010a592, 0x02000800, 0x0010210a, 0x0402019c, + 0x0401f9d8, 0x040207aa, 0x40300800, 0x59a81010, + 0x59cc0007, 0x82000500, 0x00ffffff, 0x80080580, + 0x04000019, 0x59cc1408, 0x0201f800, 0x0010902c, + 0x0400002d, 0x59cc0c08, 0x4d300000, 0x0201f800, + 0x00105dd7, 0x41323800, 0x5c026000, 0x04000026, + 0x591c0202, 0x82000580, 0x0000ffff, 0x04000005, + 0x59cc1208, 0x591c0202, 0x80080580, 0x0402001e, + 0x591c0406, 0x82000580, 0x00000007, 0x0402001a, + 0x0401f02c, 0x59cc1208, 0x82080580, 0x0000ffff, + 0x0400000c, 0x0201f800, 0x00109410, 0x04000012, + 0x59cc1408, 0x591c0202, 0x80080580, 0x0402000e, + 0x591c0009, 0x81340580, 0x04000016, 0x0401f00a, + 0x59cc1408, 0x417a7800, 0x0201f800, 0x0010a405, + 0x04020010, 0x59cc1208, 0x82080580, 0x0000ffff, + 0x04000019, 0x4a026403, 0x00000026, 0x4a02621a, + 0x00001700, 0x59cc1204, 0x82081580, 0x0000ffff, + 0x04020798, 0x4a026403, 0x00000025, 0x0401f795, + 0x591c0406, 0x82000580, 0x00000007, 0x040207f2, + 0x591c0403, 0x82000580, 0x00000024, 0x04020006, + 0x4d300000, 0x411e6000, 0x0201f800, 0x0002077d, + 0x5c026000, 0x4a026403, 0x00000025, 0x0401f785, + 0x4933c857, 0x4d3c0000, 0x42027800, 0x00000001, + 0x0201f800, 0x00104567, 0x5c027800, 0x4c580000, + 0x4200b000, 0x00000002, 0x83a81c00, 0x00000002, + 0x83cc1400, 0x0000000b, 0x0201f800, 0x0010855a, + 0x5c00b000, 0x04000004, 0x4a026403, 0x00000031, + 0x0401f770, 0x0201f800, 0x00107911, 0x0201f800, + 0x0010513b, 0x0402000f, 0x0201f800, 0x00105149, + 0x04020008, 0x4a035033, 0x00000001, 0x4202d800, + 0x00000001, 0x0201f800, 0x001050a2, 0x0401f005, + 0x42000000, 0x00000001, 0x0201f800, 0x00105113, + 0x1c01f000, 0x0201f800, 0x0010210a, 0x0402011c, + 0x0401f958, 0x0402072a, 0x493a6403, 0x0401f996, + 0x04020004, 0x4a026403, 0x0000002b, 0x0401f751, + 0x4a026403, 0x0000002c, 0x0401f74e, 0x4933c857, + 0x0201f800, 0x0010210a, 0x0402010d, 0x0201f800, + 0x001049e7, 0x04020740, 0x0201f800, 0x001048d9, + 0x0400003c, 0x59cc0408, 0x48026419, 0x59cc0208, + 0x48026219, 0x59cc0807, 0x59340002, 0x82000500, + 0x00ffffff, 0x80040580, 0x04000012, 0x59a80010, + 0x80040580, 0x04020021, 0x59cc1408, 0x0201f800, + 0x00109410, 0x04000023, 0x0201f800, 0x0010a4ca, + 0x04000020, 0x0201f800, 0x0010a921, 0x0400001d, + 0x491e601e, 0x4a026403, 0x00000036, 0x0401f0e6, + 0x59cc1208, 0x82080580, 0x0000ffff, 0x04000009, + 0x0201f800, 0x00109410, 0x04000012, 0x591c0202, + 0x59cc0c08, 0x80040580, 0x0402000e, 0x0401f7eb, + 0x59cc1408, 0x41327800, 0x0201f800, 0x0010a405, + 0x04000008, 0x0401f7e5, 0x4803c856, 0x4a02641a, + 0x00000009, 0x4a02621a, 0x00001500, 0x0401f006, + 0x4803c856, 0x4a02641a, 0x00000003, 0x4a02621a, + 0x00001700, 0x4a026403, 0x00000037, 0x0401f0c6, + 0x4803c856, 0x4a026403, 0x00000012, 0x0401f0c2, + 0x4933c857, 0x0201f800, 0x0010210a, 0x040200c4, + 0x0201f800, 0x001049e7, 0x040206f7, 0x0201f800, + 0x001048d9, 0x0400003e, 0x59cc0407, 0x48026419, + 0x59cc1207, 0x480a6219, 0x82080580, 0x0000ffff, + 0x04000005, 0x0201f800, 0x00109410, 0x0400002c, + 0x0401f006, 0x59cc1407, 0x41327800, 0x0201f800, + 0x0010a405, 0x04000026, 0x59cc0c07, 0x591c0202, + 0x80040580, 0x04020022, 0x4d300000, 0x411e6000, + 0x0201f800, 0x00108bd7, 0x5c026000, 0x59cc0c09, + 0x82040d00, 0x0000ff00, 0x840409c0, 0x0201f800, + 0x0010a921, 0x04000016, 0x82040580, 0x00000001, + 0x0400000a, 0x82040580, 0x00000005, 0x04000004, + 0x82040580, 0x00000007, 0x04020007, 0x591c0008, + 0x80000540, 0x04000004, 0x59cc2808, 0x0201f000, + 0x0010a4de, 0x4803c856, 0x4a02641a, 0x00000009, + 0x4a02621a, 0x00002a00, 0x0401f006, 0x4803c856, + 0x4a02641a, 0x00000003, 0x4a02621a, 0x00000300, + 0x4a026403, 0x0000003b, 0x0401f07b, 0x4803c856, + 0x4a02641a, 0x0000000b, 0x4a02621a, 0x00000000, + 0x0401f7f8, 0x4c080000, 0x0201f800, 0x001048ec, + 0x04000026, 0x0201f800, 0x001048c1, 0x0201f800, + 0x0010a601, 0x0402001e, 0x59a80026, 0x82000540, + 0x00000003, 0x48035026, 0x59a8001d, 0x800000d0, + 0x59a80810, 0x82040d00, 0x000000ff, 0x80041540, + 0x480b5010, 0x42000800, 0x00000003, 0x0201f800, + 0x00106c78, 0x497b5028, 0x0201f800, 0x00103b25, + 0x04000003, 0x4a032804, 0x000007d0, 0x8c00050a, + 0x0402000a, 0x0201f800, 0x0002077d, 0x0201f800, + 0x00101e45, 0x5c001000, 0x1c01f000, 0x0201f800, + 0x0010a623, 0x0401f7fc, 0x5c001000, 0x0201f000, + 0x0002077d, 0x0201f800, 0x0010210a, 0x0402004c, + 0x0201f800, 0x0010a628, 0x4a026403, 0x00000047, + 0x4a026203, 0x00000001, 0x0201f000, 0x0010672b, + 0x0201f800, 0x0010210a, 0x04020041, 0x0201f800, + 0x0010a628, 0x4a026403, 0x00000047, 0x4a026203, + 0x00000001, 0x0201f000, 0x0010672b, 0x0201f800, + 0x0010210a, 0x04020036, 0x0201f800, 0x0010a628, + 0x0201f000, 0x0002077d, 0x0401f834, 0x04000030, + 0x4a026403, 0x0000004e, 0x4a026203, 0x00000001, + 0x0201f000, 0x0010672b, 0x4a026403, 0x0000004f, + 0x497a601c, 0x59cc0a06, 0x82040d00, 0x000000ff, + 0x800409c0, 0x0400065f, 0x82040580, 0x00000001, + 0x04020005, 0x59cc0808, 0x59a80005, 0x80040580, + 0x04000658, 0x82040580, 0x00000002, 0x0402000a, + 0x83cc1400, 0x0000000b, 0x4200b000, 0x00000002, + 0x83341c00, 0x00000006, 0x0201f800, 0x0010855a, + 0x0400064c, 0x4a02601c, 0x00000001, 0x0401f649, + 0x4a026403, 0x00000050, 0x59cc0207, 0x4802601c, + 0x0401f644, 0x4a026203, 0x00000001, 0x42000800, + 0x80000040, 0x0201f000, 0x00020721, 0x4803c857, + 0x0201f000, 0x0002077d, 0x4d2c0000, 0x4c500000, + 0x4c580000, 0x4c540000, 0x59a80016, 0x82000c80, + 0x00000829, 0x04021029, 0x0201f800, 0x001007d3, + 0x04000026, 0x492e6008, 0x59a80016, 0x80000104, + 0x48025802, 0x83cca400, 0x00000006, 0x82000c80, + 0x0000000b, 0x04001013, 0x4a025811, 0x0000000b, + 0x4200b000, 0x0000000b, 0x832c0400, 0x00000005, + 0x4000a800, 0x0201f800, 0x0010ab17, 0x412c7000, + 0x0201f800, 0x001007d3, 0x04000010, 0x492c7001, + 0x40040000, 0x800409c0, 0x04000009, 0x0401f7ec, + 0x48025811, 0x4000b000, 0x832c0400, 0x00000005, + 0x4000a800, 0x0201f800, 0x0010ab17, 0x82000540, + 0x00000001, 0x0401f006, 0x497b5016, 0x59325808, + 0x0201f800, 0x001007fd, 0x80000580, 0x5c00a800, + 0x5c00b000, 0x5c00a000, 0x5c025800, 0x1c01f000, + 0x4d340000, 0x59326809, 0x59343400, 0x4933c857, + 0x4937c857, 0x481bc857, 0x0201f800, 0x001049f3, + 0x5c026800, 0x1c01f000, 0x4933c857, 0x4c5c0000, + 0x4d3c0000, 0x0401f840, 0x0402002c, 0x59cc0207, + 0x82000d00, 0x0000ff00, 0x900411c0, 0x59cc000a, + 0x82000500, 0x00ffffff, 0x80081540, 0x480a601c, + 0x8c040d18, 0x0400000e, 0x42003000, 0x00000008, + 0x0201f800, 0x0010a932, 0x42000000, 0x0010b863, + 0x0201f800, 0x0010aa47, 0x4200b800, 0x00000002, + 0x42027800, 0x00000001, 0x0401f011, 0x4178b800, + 0x8c040d1a, 0x04000011, 0x59cc000a, 0x0201f800, + 0x00105c9a, 0x0402000d, 0x42003000, 0x00000009, + 0x0201f800, 0x0010a93a, 0x42000000, 0x0010b863, + 0x0201f800, 0x0010aa47, 0x417a7800, 0x0201f800, + 0x001020a1, 0x0401f004, 0x82000540, 0x00000001, + 0x0401f002, 0x80000580, 0x5c027800, 0x5c00b800, + 0x1c01f000, 0x4933c857, 0x59cc0206, 0x82000480, + 0x00000010, 0x04021006, 0x4a02621a, 0x00000000, + 0x82000540, 0x00000001, 0x0401f002, 0x80000580, + 0x1c01f000, 0x4933c857, 0x4a02621a, 0x00000000, + 0x59cc0407, 0x82000500, 0x0000ff00, 0x82000580, + 0x00000800, 0x04020009, 0x59cc0006, 0x82000500, + 0x00ff0000, 0x82000d80, 0x00140000, 0x04000003, + 0x82000d80, 0x00100000, 0x1c01f000, 0x4933c857, + 0x59300403, 0x82003480, 0x00000051, 0x02021800, + 0x001005d8, 0x83383580, 0x00000013, 0x04020003, + 0x4803c857, 0x0c01f012, 0x83383580, 0x00000027, + 0x04000005, 0x83383580, 0x00000014, 0x02020800, + 0x001005d8, 0x0201f800, 0x001048c1, 0x42000800, + 0x00000007, 0x0201f800, 0x00104571, 0x0201f800, + 0x00106bbf, 0x0201f000, 0x00107911, 0x00109e3c, + 0x00109e45, 0x00109e3c, 0x00109e3c, 0x00109e3c, + 0x00109e45, 0x00109e50, 0x00109ecd, 0x00109e95, + 0x00109ecd, 0x00109ead, 0x00109ecd, 0x00109ebe, + 0x00109ecd, 0x00109ec6, 0x00109ecd, 0x00109ec6, + 0x00109ecd, 0x00109ecd, 0x00109e3c, 0x00109e3c, + 0x00109e3c, 0x00109e3c, 0x00109e3c, 0x00109e3c, + 0x00109e3c, 0x00109e3c, 0x00109e3c, 0x00109e3c, + 0x00109e3c, 0x00109e45, 0x00109e3c, 0x00109ecd, + 0x00109e3c, 0x00109e3c, 0x00109ecd, 0x00109e3c, + 0x00109eca, 0x00109ecd, 0x00109e3c, 0x00109e3c, + 0x00109e3c, 0x00109e3c, 0x00109ecd, 0x00109ecd, + 0x00109e3c, 0x00109ec3, 0x00109ecd, 0x00109e3c, + 0x00109e4a, 0x00109e3c, 0x00109e3c, 0x00109e3c, + 0x00109e3c, 0x00109ec9, 0x00109ecd, 0x00109e3c, + 0x00109e3c, 0x00109ecd, 0x00109ecd, 0x00109e3c, + 0x00109e3c, 0x00109e3c, 0x00109e3c, 0x00109e3c, + 0x00109e3c, 0x00109e3c, 0x00109e3c, 0x00109e3c, + 0x00109e3e, 0x00109e3c, 0x00109e3e, 0x00109e3c, + 0x00109e3c, 0x00109e3e, 0x00109e3c, 0x00109e3c, + 0x00109e3c, 0x00109e3e, 0x00109e3e, 0x00109e3e, + 0x0201f800, 0x001005d8, 0x4d2c0000, 0x59325808, + 0x0201f800, 0x001007fd, 0x5c025800, 0x0201f000, + 0x0002077d, 0x59a80037, 0x48026206, 0x4a026203, + 0x00000002, 0x1c01f000, 0x4d3c0000, 0x417a7800, + 0x0201f800, 0x00104567, 0x5c027800, 0x0401f07e, + 0x42000800, 0x00000007, 0x0201f800, 0x00104571, + 0x59a80026, 0x8c000508, 0x04000012, 0x59326809, + 0x4c580000, 0x4200b000, 0x00000002, 0x83a81c00, + 0x00000002, 0x83341400, 0x00000006, 0x0201f800, + 0x0010855a, 0x80000540, 0x5c00b000, 0x0402006a, + 0x59340200, 0x8400051a, 0x48026a00, 0x0401f01b, + 0x599c0017, 0x8c00050a, 0x04020063, 0x4d3c0000, + 0x417a7800, 0x0201f800, 0x00104567, 0x5c027800, + 0x42000800, 0x00000007, 0x0201f800, 0x00104571, + 0x59340212, 0x82000500, 0x0000ff00, 0x04000056, + 0x599c0019, 0x8c00050e, 0x04020053, 0x416c0000, + 0x82000580, 0x00000002, 0x04020004, 0x59a8001b, + 0x80000000, 0x4803501b, 0x42000800, 0x00000003, + 0x0201f800, 0x00104571, 0x4a026406, 0x00000001, + 0x4a026203, 0x00000001, 0x4a026403, 0x00000002, + 0x0201f800, 0x0010672b, 0x4ce80000, 0x4201d000, + 0x00000001, 0x0201f800, 0x00105fae, 0x5c01d000, + 0x1c01f000, 0x0201f800, 0x001049f3, 0x04000036, + 0x0201f800, 0x0010645e, 0x42000800, 0x00000004, + 0x0201f800, 0x00104571, 0x0201f800, 0x0010a96a, + 0x0402002d, 0x42000800, 0x00000005, 0x0201f800, + 0x00104571, 0x4a026406, 0x00000001, 0x4a026203, + 0x00000001, 0x4a026403, 0x00000003, 0x0201f000, + 0x0010672b, 0x42000800, 0x00000006, 0x0401f820, + 0x59303009, 0x599c0017, 0x8c00050a, 0x0402001a, + 0x59a80026, 0x8c000508, 0x04000017, 0x0201f800, + 0x001049e7, 0x04000014, 0x59a8001b, 0x80000000, + 0x4803501b, 0x0401f7c5, 0x42000800, 0x00000004, + 0x0201f800, 0x00104571, 0x0401f792, 0x42000800, + 0x00000004, 0x0401f006, 0x0201f800, 0x001048c1, + 0x0401f005, 0x0401f004, 0x0401f003, 0x0201f800, + 0x00104571, 0x0201f000, 0x0002077d, 0x4933c857, + 0x4807c857, 0x0201f800, 0x00104571, 0x4d3c0000, + 0x417a7800, 0x0201f800, 0x00104567, 0x5c027800, + 0x0201f800, 0x00102074, 0x1c01f000, 0x4933c857, + 0x59340400, 0x80000110, 0x82003480, 0x0000000c, + 0x02021800, 0x001005d8, 0x83383580, 0x00000015, + 0x04020002, 0x0c01f006, 0x83383580, 0x00000016, + 0x02020800, 0x001005d8, 0x0c01f00d, 0x001080b8, + 0x001080b8, 0x001080b8, 0x001080b8, 0x001080b8, + 0x001080b8, 0x00109f30, 0x00109f03, 0x001080b8, + 0x001080b8, 0x001080b8, 0x001080b8, 0x001080b8, + 0x001080b8, 0x001080b8, 0x001080b8, 0x001080b8, + 0x001080b8, 0x00109f30, 0x00109f37, 0x001080b8, + 0x001080b8, 0x001080b8, 0x001080b8, 0x4933c857, + 0x599c0017, 0x8c00050a, 0x0402001b, 0x813669c0, + 0x04000019, 0x59340212, 0x82000500, 0x0000ff00, + 0x04000015, 0x599c0019, 0x8c00050e, 0x04020012, + 0x4d3c0000, 0x417a7800, 0x0201f800, 0x00104567, + 0x5c027800, 0x42000800, 0x00000003, 0x0201f800, + 0x00104571, 0x4a026406, 0x00000001, 0x4a026203, + 0x00000001, 0x4a026403, 0x00000002, 0x0201f000, + 0x0010672b, 0x59cc0001, 0x0201f800, 0x00105c9a, + 0x0402000b, 0x0201f800, 0x00020245, 0x02020000, + 0x0002077d, 0x59345002, 0x0201f800, 0x001042b4, + 0x482a6802, 0x0201f000, 0x0002077d, 0x1c01f000, + 0x4933c857, 0x59303403, 0x82183580, 0x0000001e, + 0x02000000, 0x0002077d, 0x1c01f000, 0x4933c857, + 0x0201f800, 0x001083df, 0x02020000, 0x0002077d, + 0x4a026203, 0x00000001, 0x4a026403, 0x00000001, + 0x0201f000, 0x0010672b, 0x493bc857, 0x83380580, + 0x00000051, 0x0402000b, 0x0201f800, 0x00106f60, + 0x02020000, 0x00107974, 0x59300203, 0x82000580, + 0x00000002, 0x0400006d, 0x0201f800, 0x001005d8, + 0x83380580, 0x00000027, 0x04000014, 0x83380580, + 0x00000048, 0x04000006, 0x83380580, 0x00000014, + 0x0400000e, 0x02020800, 0x001005d8, 0x0201f800, + 0x00106f60, 0x02020000, 0x00107974, 0x59300203, + 0x82000580, 0x00000004, 0x02000000, 0x0002086e, + 0x0201f800, 0x001005d8, 0x59300403, 0x82000c80, + 0x00000044, 0x02021800, 0x001005d8, 0x82000480, + 0x00000040, 0x02001800, 0x001005d8, 0x40027000, + 0x4803c857, 0x0c01f001, 0x00109f76, 0x00109f78, + 0x00109f78, 0x00109f93, 0x0201f800, 0x001005d8, + 0x0201f800, 0x00106bbf, 0x59325808, 0x812e59c0, + 0x04000016, 0x832c0500, 0x00ff0000, 0x04000013, + 0x4a026203, 0x00000002, 0x59326809, 0x59340200, + 0x8c00050e, 0x0402000d, 0x42028000, 0x00000004, + 0x0201f800, 0x0010a3ef, 0x497a6008, 0x59300206, + 0x80000540, 0x04020003, 0x59a80038, 0x48026206, + 0x4a026203, 0x00000007, 0x1c01f000, 0x0201f800, + 0x00106bbf, 0x0201f800, 0x00109037, 0x02000000, + 0x00107911, 0x59325808, 0x0201f800, 0x001007f4, + 0x0201f000, 0x00107911, 0x0201f800, 0x001005d8, + 0x59325808, 0x592c040a, 0x8c000502, 0x04000007, + 0x4a026203, 0x00000007, 0x42027000, 0x00000043, + 0x0201f000, 0x000207a1, 0x4a026203, 0x00000004, + 0x1c01f000, 0x0201f800, 0x0010a597, 0x02000000, + 0x0002086c, 0x1c01f000, 0x4a026203, 0x00000001, + 0x4a026403, 0x00000041, 0x42027800, 0x80002042, + 0x0201f000, 0x00020721, 0x83380580, 0x00000051, + 0x04000006, 0x83380580, 0x00000041, 0x02020800, + 0x001005d8, 0x1c01f000, 0x0201f800, 0x000206fd, + 0x0201f800, 0x0010a5df, 0x0201f000, 0x0002077d, + 0x83380480, 0x00000050, 0x02021800, 0x001005d8, + 0x83380480, 0x00000049, 0x02001800, 0x001005d8, + 0x0c01f001, 0x00109fda, 0x00109ffb, 0x00109fd8, + 0x00109fd8, 0x00109fd8, 0x00109fd8, 0x00109ffb, + 0x0201f800, 0x001005d8, 0x59325808, 0x592c040a, + 0x8c00051e, 0x0400000d, 0x82000d00, 0x000000c0, + 0x82040d80, 0x00000080, 0x0400000d, 0x59300804, + 0x8c040d18, 0x0402000a, 0x42027000, 0x00000041, + 0x0201f000, 0x0002088d, 0x4a026203, 0x00000007, + 0x497a6206, 0x0201f000, 0x000206fd, 0x59325808, + 0x592c0c0a, 0x8c040d1a, 0x04020005, 0x0201f800, + 0x000206fd, 0x0201f000, 0x0002077d, 0x0201f800, + 0x0010a597, 0x040007fa, 0x1c01f000, 0x0201f800, + 0x00106b8a, 0x59325808, 0x59326809, 0x59340200, + 0x8c00050e, 0x0400000e, 0x592c040a, 0x82000500, + 0x000000c0, 0x82000580, 0x00000080, 0x04000005, + 0x592c000f, 0x59301815, 0x800c1c80, 0x480e6015, + 0x4a026203, 0x00000002, 0x0401f00d, 0x42028000, + 0x00000004, 0x0401fbde, 0x59300206, 0x80000540, + 0x04020004, 0x59a80038, 0x800000c2, 0x48026206, + 0x497a6008, 0x4a026203, 0x00000007, 0x1c01f000, + 0x4a026203, 0x00000007, 0x497a6206, 0x0201f000, + 0x000206fd, 0x4a026203, 0x00000007, 0x497a6206, + 0x0201f000, 0x000206f8, 0x59300414, 0x8c00051c, + 0x02020000, 0x0002087e, 0x59325808, 0x592c200f, + 0x40080000, 0x80102480, 0x59300015, 0x80102400, + 0x48126015, 0x0201f000, 0x0002087e, 0x8c040d0e, + 0x0402000a, 0x4a026203, 0x00000006, 0x0401f823, + 0x5930001f, 0x80000540, 0x02020800, 0x00100d7c, + 0x0201f000, 0x000206f8, 0x4a026203, 0x00000002, + 0x1c01f000, 0x42000800, 0x00000001, 0x0201f800, + 0x00100d7c, 0x82040580, 0x00000001, 0x02000000, + 0x00020885, 0x0401f7d8, 0x59300414, 0x8c00051c, + 0x04000006, 0x0201f800, 0x00100b63, 0x02000000, + 0x00020877, 0x1c01f000, 0x59300011, 0x80000540, + 0x04020005, 0x0201f800, 0x00100b63, 0x02000000, + 0x00020877, 0x1c01f000, 0x492fc857, 0x480bc857, + 0x8c08153e, 0x04000006, 0x80081080, 0x80081000, + 0x42000800, 0x00000009, 0x0401f003, 0x42000800, + 0x00000015, 0x480a580b, 0x1c01f000, 0x83380580, + 0x00000013, 0x04000005, 0x83380580, 0x00000014, + 0x02020800, 0x001005d8, 0x59300414, 0x8c000516, + 0x02000800, 0x001005d8, 0x1c01f000, 0x0201f800, + 0x001005d8, 0x59300008, 0x80000540, 0x02020800, + 0x001005d8, 0x1c01f000, 0x59300414, 0x8c000516, + 0x02000800, 0x001005d8, 0x1c01f000, 0x4a026203, + 0x00000004, 0x493a6403, 0x42000800, 0x80002001, + 0x0201f000, 0x00020721, 0x4a026203, 0x00000003, + 0x493a6403, 0x0201f800, 0x000200c9, 0x59325808, + 0x592c040a, 0x8c00051e, 0x04000012, 0x82000500, + 0x000000c0, 0x82000580, 0x00000080, 0x04000011, + 0x59300414, 0x8c000512, 0x0402000a, 0x8c000510, + 0x04020008, 0x592c040c, 0x80000540, 0x04020005, + 0x82080d40, 0x80003065, 0x0201f000, 0x00106721, + 0x82080d40, 0x80002065, 0x0201f000, 0x00106721, + 0x82080d40, 0x80002042, 0x0201f000, 0x00106721, + 0x4933c857, 0x493bc857, 0x83380480, 0x00000044, + 0x02021800, 0x001005d8, 0x83380480, 0x00000041, + 0x02001800, 0x001005d8, 0x0c01f001, 0x0010a0b6, + 0x0010a0c6, 0x0010a0db, 0x59325808, 0x592c040a, + 0x8c00051e, 0x0400001d, 0x82001d00, 0x000000c0, + 0x820c1d80, 0x000000c0, 0x04000018, 0x4a026203, + 0x00000001, 0x493a6403, 0x42000800, 0x80002042, + 0x0201f000, 0x00020721, 0x59325808, 0x592c040a, + 0x8c00051e, 0x0400000d, 0x82001d00, 0x000000c0, + 0x820c1d80, 0x000000c0, 0x04000008, 0x4a026203, + 0x00000001, 0x493a6403, 0x42000800, 0x80002001, + 0x0201f000, 0x00020721, 0x497a6008, 0x497a6206, + 0x42028000, 0x00000004, 0x0401f315, 0x59325808, + 0x592c040a, 0x8c00051e, 0x040007f8, 0x82001d00, + 0x000000c0, 0x820c1d80, 0x000000c0, 0x040007f3, + 0x4a026203, 0x00000003, 0x493a6403, 0x0201f800, + 0x000200c9, 0x82080d40, 0x80002065, 0x0201f000, + 0x00106721, 0x4933c857, 0x493bc857, 0x83380580, + 0x00000085, 0x04000006, 0x83380580, 0x00000088, + 0x0400000a, 0x0201f800, 0x001005d8, 0x4a026203, + 0x00000009, 0x493a6403, 0x42000800, 0x8000004b, + 0x0201f000, 0x00020721, 0x4d1c0000, 0x813669c0, + 0x04000004, 0x0201f800, 0x0010a592, 0x04020044, + 0x59cc1404, 0x0401f846, 0x04000018, 0x591c0406, + 0x82000500, 0x0000001f, 0x82002580, 0x00000006, + 0x04000007, 0x82002580, 0x00000004, 0x0400002e, + 0x82002580, 0x00000011, 0x0402000c, 0x497a3a05, + 0x42002000, 0x00000054, 0x0201f800, 0x00107a4a, + 0x4a026203, 0x00000007, 0x493a6403, 0x0201f800, + 0x0010a974, 0x0401f02c, 0x0201f800, 0x00103b25, + 0x04000004, 0x42023800, 0xffffffff, 0x0401f7f1, + 0x813669c0, 0x04020009, 0x59cc0001, 0x0201f800, + 0x00105c9a, 0x0402001e, 0x0201f800, 0x001045a6, + 0x0402001b, 0x49366009, 0x4a026403, 0x00000087, + 0x59cc1204, 0x82081580, 0x0000ffff, 0x04020003, + 0x4a026403, 0x00000086, 0x4a026203, 0x00000001, + 0x42000800, 0x80000040, 0x0201f800, 0x00020721, + 0x0401f00d, 0x591c0203, 0x82000580, 0x00000007, + 0x040207de, 0x4d300000, 0x411e6000, 0x0201f800, + 0x00107911, 0x5c026000, 0x0401f7d8, 0x0201f800, + 0x00107911, 0x5c023800, 0x1c01f000, 0x4933c857, + 0x480bc857, 0x42002800, 0x0010d1c0, 0x41300000, + 0x80140580, 0x04000017, 0x58140203, 0x82000580, + 0x00000000, 0x04000013, 0x58140202, 0x80080580, + 0x04020010, 0x58141c06, 0x820c0580, 0x00000005, + 0x0400000c, 0x820c0580, 0x00000009, 0x0400001d, + 0x59302009, 0x58140009, 0x800001c0, 0x0400000b, + 0x801021c0, 0x04000003, 0x80100580, 0x04000010, + 0x82142c00, 0x00000024, 0x41540000, 0x80140480, + 0x0402100e, 0x0401f7e2, 0x5814001e, 0x801021c0, + 0x04000005, 0x58102002, 0x82102500, 0x00ffffff, + 0x0401f7f2, 0x5810201e, 0x0401f7f0, 0x40163800, + 0x81300540, 0x0401f002, 0x80000580, 0x1c01f000, + 0x58141807, 0x8c0c1d10, 0x040207ea, 0x0401f7e1, + 0x4933c857, 0x493bc857, 0x83380580, 0x00000013, + 0x0402000e, 0x59300403, 0x82000c80, 0x00000085, + 0x02001800, 0x001005d8, 0x82000c80, 0x00000093, + 0x02021800, 0x001005d8, 0x82000480, 0x00000085, + 0x4803c857, 0x0c01f018, 0x83380580, 0x00000027, + 0x04000005, 0x83380580, 0x00000014, 0x02020000, + 0x00107974, 0x0201f800, 0x00106bbf, 0x59325808, + 0x812e59c0, 0x02000000, 0x00107911, 0x4a025a06, + 0x00000031, 0x4a025811, 0x00000004, 0x4a025812, + 0x000000ff, 0x0201f800, 0x000202da, 0x0201f000, + 0x00107911, 0x0010a1b7, 0x0010a1be, 0x0010a1be, + 0x0010a1b7, 0x0010a1b7, 0x0010a1b7, 0x0010a1b7, + 0x0010a1b7, 0x0010a1b7, 0x0010a1b7, 0x0010a1b7, + 0x0010a1b7, 0x0010a1b7, 0x0010a1b9, 0x0201f800, + 0x001005d8, 0x59325808, 0x4a025a06, 0x00000000, + 0x0201f800, 0x000202da, 0x0201f000, 0x00107911, + 0x4933c857, 0x42000000, 0x0010b873, 0x0201f800, + 0x0010aa47, 0x0201f800, 0x0010a5df, 0x497a6205, + 0x42028000, 0x0000000b, 0x0401f807, 0x4a026406, + 0x00000006, 0x4a026203, 0x00000007, 0x497a6206, + 0x1c01f000, 0x4933c857, 0x4943c857, 0x59300406, + 0x82000580, 0x00000007, 0x04020002, 0x1c01f000, + 0x0201f800, 0x00106c55, 0x4df00000, 0x0201f800, + 0x00108ce5, 0x82000c80, 0x0000000e, 0x02021800, + 0x001005d8, 0x0c01f001, 0x0010a205, 0x0010a209, + 0x0010a1f0, 0x0010a217, 0x0010a22a, 0x0010a1f0, + 0x0010a1f0, 0x0010a1f0, 0x0010a1f0, 0x0010a1f0, + 0x0010a1f0, 0x0010a1f0, 0x0010a1f0, 0x0010a1f0, + 0x4d400000, 0x5930001f, 0x80000540, 0x04000005, + 0x41400800, 0x0201f800, 0x00100d7c, 0x40068000, + 0x4d2c0000, 0x59325808, 0x0201f800, 0x00109037, + 0x040209f3, 0x4c5c0000, 0x5930b809, 0x0201f800, + 0x00107911, 0x485e6009, 0x5c00b800, 0x5c025800, + 0x5c028000, 0x5c03e000, 0x02000000, 0x00106c4b, + 0x1c01f000, 0x598c000d, 0x81300580, 0x04020004, + 0x0201f800, 0x00106e8e, 0x04020016, 0x0201f800, + 0x001068d3, 0x040007df, 0x0201f800, 0x00106b6c, + 0x04000010, 0x0201f800, 0x001005d8, 0x0201f800, + 0x00108cd6, 0x04020004, 0x0201f800, 0x00106e62, + 0x04020008, 0x0201f800, 0x001067ae, 0x040007d1, + 0x0201f800, 0x00106b6c, 0x02020800, 0x001005d8, + 0x59300203, 0x82000c80, 0x0000000e, 0x02021800, + 0x001005d8, 0x0c01f7b9, 0x0201f800, 0x00100e99, + 0x0401f7c4, 0x4933c857, 0x4d440000, 0x4d340000, + 0x59cc0007, 0x0201f800, 0x00105c9a, 0x02000800, + 0x00020245, 0x0402001a, 0x59300009, 0x4c000000, + 0x49366009, 0x42003000, 0x0000000b, 0x0201f800, + 0x0010a942, 0x42000000, 0x0010b861, 0x0201f800, + 0x0010aa47, 0x4d3c0000, 0x4d400000, 0x42028000, + 0x00000029, 0x417a7800, 0x0201f800, 0x0010203c, + 0x5c028000, 0x5c027800, 0x5c000000, 0x48026009, + 0x59cc0007, 0x48026802, 0x80000580, 0x5c026800, + 0x5c028800, 0x1c01f000, 0x4933c857, 0x4c040000, + 0x59a80016, 0x82000580, 0x00000074, 0x04020040, + 0x59cc0a08, 0x82040480, 0x00000100, 0x04001033, + 0x59cc0c08, 0x82040500, 0x00008000, 0x04000035, + 0x59a80032, 0x80000540, 0x04020009, 0x59301009, + 0x58080212, 0x82000500, 0x0000ff00, 0x04000004, + 0x82040500, 0x00000800, 0x0400002a, 0x59cc0c09, + 0x80040840, 0x04001024, 0x59a80826, 0x8c040d06, + 0x04000004, 0x59cc0c0f, 0x8c040d1e, 0x04020012, + 0x59cc0a17, 0x800409c0, 0x04020012, 0x59cc0a18, + 0x82040480, 0x00000100, 0x04001014, 0x59cc0c18, + 0x800409c0, 0x0402000e, 0x59cc0c19, 0x80040840, + 0x04001011, 0x59cc0c1a, 0x80040840, 0x04001011, + 0x0401f018, 0x4a02621a, 0x00000100, 0x0401f012, + 0x4a02621a, 0x00000300, 0x0401f00f, 0x4a02621a, + 0x00000500, 0x0401f00c, 0x4a02621a, 0x00000700, + 0x0401f009, 0x4a02621a, 0x00000900, 0x0401f006, + 0x4a02621a, 0x00000f00, 0x0401f003, 0x4a02621a, + 0x00002d00, 0x82000540, 0x00000001, 0x0401f002, + 0x80000580, 0x5c000800, 0x1c01f000, 0x59cc0407, + 0x4803c857, 0x82000580, 0x00000800, 0x04000003, + 0x4a02621a, 0x00000000, 0x1c01f000, 0x4933c857, + 0x4c040000, 0x4c080000, 0x4c0c0000, 0x4c580000, + 0x59cc000c, 0x0201f800, 0x00105c9a, 0x02000800, + 0x00020245, 0x04020012, 0x83cc1400, 0x00000008, + 0x4200b000, 0x00000002, 0x83341c00, 0x00000006, + 0x0201f800, 0x0010855a, 0x04020009, 0x83cc1400, + 0x0000000a, 0x4200b000, 0x00000002, 0x83341c00, + 0x00000008, 0x0201f800, 0x0010855a, 0x5c00b000, + 0x5c001800, 0x5c001000, 0x5c000800, 0x1c01f000, + 0x4933c857, 0x4c000000, 0x4c040000, 0x4c080000, + 0x4c0c0000, 0x4c580000, 0x59cc0001, 0x0201f800, + 0x00105c9a, 0x02000800, 0x00020245, 0x04020014, + 0x83cc1400, 0x0000000b, 0x4200b000, 0x00000002, + 0x83341c00, 0x00000006, 0x0201f800, 0x0010855a, + 0x0402000c, 0x83cc1400, 0x0000000d, 0x4200b000, + 0x00000002, 0x83341c00, 0x00000008, 0x0201f800, + 0x0010855a, 0x04000014, 0x4933c856, 0x4933c856, + 0x4933c857, 0x59340009, 0x4803c857, 0x5934000e, + 0x4803c857, 0x59340008, 0x4803c857, 0x5934000d, + 0x4803c857, 0x59340007, 0x4803c857, 0x5934000c, + 0x4803c857, 0x59340006, 0x4803c857, 0x5934000b, + 0x4803c857, 0x5c00b000, 0x5c001800, 0x5c001000, + 0x5c000800, 0x5c000000, 0x1c01f000, 0x4933c857, + 0x4947c857, 0x4943c857, 0x4c600000, 0x0201f800, + 0x00106c55, 0x4df00000, 0x4d2c0000, 0x4d300000, + 0x4d340000, 0x4130c000, 0x42026000, 0x0010d1c0, + 0x59a8000e, 0x8060c1c0, 0x04000005, 0x82601580, + 0x0010bde9, 0x04000002, 0x80000040, 0x81640480, + 0x040210be, 0x40600000, 0x81300580, 0x040000b6, + 0x0401f97a, 0x040200b4, 0x59326809, 0x59300406, + 0x82000c80, 0x00000012, 0x02021800, 0x001005d8, + 0x0c01f001, 0x0010a3cd, 0x0010a338, 0x0010a351, + 0x0010a35c, 0x0010a335, 0x0010a34c, 0x0010a387, + 0x0010a3cd, 0x0010a333, 0x0010a39a, 0x0010a3ae, + 0x0010a333, 0x0010a333, 0x0010a333, 0x0010a333, + 0x0010a3cd, 0x0010a3c4, 0x0010a3bc, 0x0201f800, + 0x001005d8, 0x59300420, 0x8c000500, 0x04020096, + 0x59300403, 0x82000580, 0x00000043, 0x04000092, + 0x0201f800, 0x00109134, 0x04000007, 0x0201f800, + 0x0010914e, 0x0402008a, 0x0201f800, 0x0010801c, + 0x0401f087, 0x0201f800, 0x00102074, 0x0201f800, + 0x0010914e, 0x02000800, 0x0010801c, 0x0401f080, + 0x8d3e7d18, 0x04000004, 0x59300420, 0x8c000500, + 0x0402007d, 0x59325808, 0x0201f800, 0x00109037, + 0x04000077, 0x49425a06, 0x497a5c09, 0x0201f800, + 0x000202da, 0x0201f800, 0x0010912a, 0x0401f070, + 0x8d3e7d00, 0x04000007, 0x59300017, 0x81480580, + 0x0402006d, 0x59300018, 0x814c0580, 0x0402006a, + 0x59300203, 0x82000580, 0x00000004, 0x02000800, + 0x00100e99, 0x59325808, 0x0201f800, 0x00109037, + 0x0400005f, 0x4a025a04, 0x00000103, 0x59300004, + 0x8400055c, 0x48026004, 0x592c0408, 0x8c000512, + 0x04000007, 0x4d2c0000, 0x592c0009, 0x40025800, + 0x0201f800, 0x001007fd, 0x5c025800, 0x49425a06, + 0x497a5c09, 0x0401fb16, 0x0201f800, 0x0010959c, + 0x0201f800, 0x001091c6, 0x0201f800, 0x000202da, + 0x0201f800, 0x0010912a, 0x0401f045, 0x8d3e7d18, + 0x04000045, 0x59300203, 0x82000580, 0x00000004, + 0x02000800, 0x00100e99, 0x59325808, 0x0201f800, + 0x00109037, 0x0400003a, 0x49425a06, 0x497a5c09, + 0x0401faff, 0x0201f800, 0x0010959c, 0x0201f800, + 0x000202da, 0x0401f032, 0x0201f800, 0x001062d5, + 0x04000031, 0x59300203, 0x82000580, 0x00000004, + 0x0400002d, 0x59300203, 0x82000580, 0x00000003, + 0x04020029, 0x0201f800, 0x00106b8a, 0x59325808, + 0x0201f800, 0x00109037, 0x04000021, 0x0201f800, + 0x000202da, 0x0401f01e, 0x59300203, 0x82000580, + 0x00000004, 0x02000800, 0x00100e99, 0x59325808, + 0x0201f800, 0x00109037, 0x04000015, 0x49425a06, + 0x497a5c09, 0x0201f800, 0x000202da, 0x0401f010, + 0x833c0500, 0x00001800, 0x0400000f, 0x8d3e7d16, + 0x0402000d, 0x59325817, 0x0201f800, 0x001007fd, + 0x59325808, 0x0201f800, 0x00109037, 0x04000004, + 0x49425a06, 0x0201f800, 0x000202da, 0x0201f800, + 0x00107911, 0x83326400, 0x00000024, 0x41580000, + 0x81300480, 0x0400173b, 0x5c026800, 0x5c026000, + 0x5c025800, 0x5c03e000, 0x02000800, 0x00106c4b, + 0x5c00c000, 0x1c01f000, 0x5c000000, 0x4c000000, + 0x4803c857, 0x4d3c0000, 0x42027800, 0x00000001, + 0x0201f800, 0x00104567, 0x5c027800, 0x4c580000, + 0x4200b000, 0x00000002, 0x83a81c00, 0x00000002, + 0x83cc1400, 0x0000000b, 0x0201f800, 0x0010855a, + 0x5c00b000, 0x80000540, 0x1c01f000, 0x492fc857, + 0x4943c857, 0x59a8000c, 0x812c0480, 0x04001011, + 0x59a8000d, 0x812c0480, 0x0402100e, 0x592c0000, + 0x80005d40, 0x04000008, 0x497a5800, 0x49425a06, + 0x4c2c0000, 0x0201f800, 0x000202da, 0x5c025800, + 0x0401f7f7, 0x49425a06, 0x0201f000, 0x000202da, + 0x1c01f000, 0x493fc857, 0x4933c857, 0x480bc857, + 0x0201f800, 0x00103b25, 0x0400002e, 0x41502800, + 0x813e79c0, 0x04020006, 0x59a80066, 0x80000000, + 0x59a8086a, 0x80040580, 0x04000026, 0x41300000, + 0x80140580, 0x0400001a, 0x58140203, 0x82000580, + 0x00000000, 0x04000016, 0x58140202, 0x80080580, + 0x04020013, 0x58141c06, 0x820c0580, 0x00000005, + 0x0400000f, 0x820c0580, 0x00000009, 0x04000017, + 0x59300009, 0x58142009, 0x801021c0, 0x04020006, + 0x5814201e, 0x59301809, 0x580c0002, 0x82000500, + 0x00ffffff, 0x80100580, 0x04000007, 0x82142c00, + 0x00000024, 0x41540000, 0x80140480, 0x04021005, + 0x0401f7df, 0x40163800, 0x81300540, 0x0401f002, + 0x80000580, 0x1c01f000, 0x58141807, 0x8c0c1d10, + 0x040207f3, 0x0401f7e7, 0x42002000, 0x0000ffff, + 0x59301009, 0x800811c0, 0x04000002, 0x58082403, + 0x41301000, 0x0401f007, 0x41781000, 0x41442000, + 0x0401f004, 0x41781000, 0x42002000, 0x0000ffff, + 0x5c000000, 0x4c000000, 0x4803c857, 0x480bc857, + 0x4813c857, 0x492fc857, 0x4943c857, 0x4d2c0000, + 0x0201f800, 0x001007e4, 0x02000800, 0x001005d8, + 0x4a025a04, 0x0000010d, 0x800811c0, 0x04000017, + 0x83400580, 0x00000029, 0x04020010, 0x82180580, + 0x00000002, 0x0400000a, 0x82180580, 0x00000003, + 0x04000007, 0x82180580, 0x00000008, 0x04000004, + 0x82180580, 0x00000009, 0x04020004, 0x4a025809, + 0xffffffff, 0x0401f002, 0x480a5809, 0x58080202, + 0x48025c13, 0x0401f005, 0x4a025809, 0xffffffff, + 0x4a025c13, 0x0000ffff, 0x49425a08, 0x48125a06, + 0x82100580, 0x0000ffff, 0x0400000e, 0x4d440000, + 0x4d340000, 0x40128800, 0x0201f800, 0x00020245, + 0x02020800, 0x001005d8, 0x59340002, 0x82000500, + 0x00ffffff, 0x48025812, 0x5c026800, 0x5c028800, + 0x497a5800, 0x497a5c04, 0x83400580, 0x00000046, + 0x04020002, 0x48165a07, 0x481a5c08, 0x0401fbed, + 0x5c025800, 0x1c01f000, 0x59300809, 0x800409c0, + 0x04000004, 0x58040403, 0x81440580, 0x1c01f000, + 0x82000540, 0x00000001, 0x0401f7fd, 0x4933c857, + 0x4c040000, 0x59300403, 0x82000d80, 0x0000001e, + 0x04020016, 0x800000d0, 0x59300a16, 0x82040d00, + 0x000000ff, 0x80040540, 0x4803c857, 0x48026416, + 0x4a026403, 0x00000085, 0x4a026203, 0x00000009, + 0x4a026406, 0x00000005, 0x4a02621d, 0x00000004, + 0x59a80038, 0x48026206, 0x42000800, 0x8000004b, + 0x0201f800, 0x00020721, 0x5c000800, 0x1c01f000, + 0x4933c857, 0x40000000, 0x40000000, 0x1c01f000, + 0x59300414, 0x4933c857, 0x4803c857, 0x8c000518, + 0x04000009, 0x8c000512, 0x02020000, 0x0010921e, + 0x0401f91b, 0x0201f800, 0x000206fd, 0x0201f800, + 0x0002077d, 0x1c01f000, 0x591c0406, 0x4803c857, + 0x82000c80, 0x00000009, 0x0402100b, 0x0c01f001, + 0x0010a4d9, 0x0010a4d9, 0x0010a4d9, 0x0010a4db, + 0x0010a4d9, 0x0010a4db, 0x0010a4db, 0x0010a4d9, + 0x0010a4db, 0x80000580, 0x1c01f000, 0x82000540, + 0x00000001, 0x1c01f000, 0x591c0406, 0x82000500, + 0x0000001f, 0x82000580, 0x00000006, 0x0400000e, + 0x4803c857, 0x4a026403, 0x0000003b, 0x4a02641a, + 0x00000009, 0x4a02621a, 0x00002a00, 0x4a026203, + 0x00000001, 0x42000800, 0x80000040, 0x0201f000, + 0x00020721, 0x4803c856, 0x4c040000, 0x4c140000, + 0x4d300000, 0x411e6000, 0x0401f8e9, 0x497a6205, + 0x59300414, 0x4803c857, 0x82000500, 0xffffadff, + 0x48026414, 0x497a6405, 0x5c026000, 0x0201f800, + 0x001007e4, 0x02000800, 0x001005d8, 0x5c002800, + 0x5c000800, 0x4a025a04, 0x0000010d, 0x497a5800, + 0x497a5c04, 0x4a025a08, 0x00000045, 0x491e5809, + 0x59300402, 0x48025c07, 0x59300419, 0x48025c0b, + 0x591c0414, 0x84000556, 0x48023c14, 0x591c1809, + 0x580c0403, 0x48025a06, 0x4816580a, 0x48065a0b, + 0x0401f99d, 0x4d400000, 0x42028000, 0x00000045, + 0x591c0202, 0x4c000000, 0x4d300000, 0x411e6000, + 0x0401fcb1, 0x5c026000, 0x5c000000, 0x48023a02, + 0x5c028000, 0x4a023c06, 0x00000006, 0x4a023a03, + 0x00000007, 0x497a3a06, 0x497a3a05, 0x1c01f000, + 0x4933c857, 0x83380580, 0x00000013, 0x0402000b, + 0x59300403, 0x4803c857, 0x82000d80, 0x00000085, + 0x0400002b, 0x82000d80, 0x0000008b, 0x04000028, + 0x0201f800, 0x001005d8, 0x83380580, 0x00000027, + 0x0402000c, 0x0201f800, 0x00106bbf, 0x4d2c0000, + 0x4d400000, 0x59325808, 0x42028000, 0x00000004, + 0x0401feab, 0x5c028000, 0x5c025800, 0x1c01f000, + 0x83380580, 0x00000014, 0x040007f3, 0x83380580, + 0x00000089, 0x04000005, 0x83380580, 0x0000008a, + 0x02020000, 0x00107974, 0x0201f800, 0x00106f60, + 0x02020000, 0x00107974, 0x59300a03, 0x82040580, + 0x0000000a, 0x04000009, 0x82040580, 0x0000000c, + 0x04000006, 0x0201f800, 0x001005d8, 0x4a026203, + 0x0000000a, 0x1c01f000, 0x83380480, 0x00000093, + 0x0402100c, 0x83380480, 0x00000085, 0x04001009, + 0x83380580, 0x00000089, 0x0400000a, 0x83380580, + 0x0000008a, 0x04000022, 0x0201f800, 0x001005d8, + 0x493bc857, 0x4933c857, 0x0201f000, 0x00107974, + 0x4933c857, 0x4c340000, 0x41306800, 0x0201f800, + 0x0002075a, 0x04000011, 0x4a026203, 0x00000001, + 0x4a026403, 0x0000001e, 0x59cc0c07, 0x48066419, + 0x59cc0a07, 0x48066219, 0x58340809, 0x48066009, + 0x4a026406, 0x00000004, 0x42000800, 0x80000040, + 0x0201f800, 0x00020721, 0x40366000, 0x0201f800, + 0x0002077d, 0x5c006800, 0x1c01f000, 0x4933c857, + 0x0201f000, 0x0002077d, 0x4933c857, 0x59300809, + 0x58040200, 0x8c00051a, 0x1c01f000, 0x0201f800, + 0x001048df, 0x0400001e, 0x4a026203, 0x00000002, + 0x59300414, 0x84000558, 0x48026414, 0x8c000512, + 0x04000004, 0x59a80039, 0x48026205, 0x0401f007, + 0x59a80839, 0x59a80037, 0x80040400, 0x82000400, + 0x0000000a, 0x48026205, 0x59300009, 0x82000c00, + 0x00000011, 0x50040000, 0x80000540, 0x04000004, + 0x82000c00, 0x00000000, 0x0401f7fb, 0x45300800, + 0x497a6000, 0x82000540, 0x00000001, 0x1c01f000, + 0x82100500, 0xfffffeef, 0x04020020, 0x4d2c0000, + 0x4937c857, 0x59340811, 0x83341400, 0x00000011, + 0x800409c0, 0x0400000e, 0x40040000, 0x81300580, + 0x04000005, 0x58040800, 0x82041400, 0x00000000, + 0x0401f7f8, 0x59300800, 0x497a6000, 0x44041000, + 0x0201f800, 0x000206fd, 0x0401f002, 0x4933c857, + 0x592c0000, 0x80000540, 0x02020800, 0x001005d8, + 0x5c025800, 0x492e6008, 0x0201f800, 0x000206fd, + 0x0201f000, 0x0002077d, 0x492fc857, 0x4a025a06, + 0x00000006, 0x0201f000, 0x000202da, 0x4c340000, + 0x59300009, 0x800001c0, 0x04000010, 0x82006c00, + 0x00000011, 0x50340000, 0x80000540, 0x04000009, + 0x81300580, 0x04000005, 0x50340000, 0x82006c00, + 0x00000000, 0x0401f7f8, 0x59300000, 0x44006800, + 0x5c006800, 0x1c01f000, 0x59300c06, 0x82040580, + 0x00000005, 0x040007fb, 0x82040580, 0x00000011, + 0x040007f8, 0x82040580, 0x00000006, 0x040007f5, + 0x82040580, 0x00000001, 0x040007f2, 0x0201f800, + 0x001005d8, 0x4933c857, 0x4c080000, 0x4c0c0000, + 0x4c580000, 0x59a8101d, 0x59cc1807, 0x820c1d00, + 0x00ffffff, 0x800c0110, 0x80083580, 0x04020014, + 0x83cc1400, 0x00000008, 0x4200b000, 0x00000002, + 0x59300009, 0x82001c00, 0x00000006, 0x0201f800, + 0x0010855a, 0x0402000a, 0x83cc1400, 0x0000000a, + 0x4200b000, 0x00000002, 0x59300009, 0x82001c00, + 0x00000008, 0x0201f800, 0x0010855a, 0x5c00b000, + 0x5c001800, 0x5c001000, 0x1c01f000, 0x4933c856, + 0x0201f800, 0x0010421b, 0x0201f000, 0x00101e45, + 0x493bc857, 0x4d2c0000, 0x0201f800, 0x001007e4, + 0x02000800, 0x001005d8, 0x832cac00, 0x00000005, + 0x4c580000, 0x4c540000, 0x4200b000, 0x00000006, + 0x4578a800, 0x8054a800, 0x8058b040, 0x040207fd, + 0x83380580, 0x00000046, 0x04020004, 0x4a025a04, + 0x00000144, 0x0401f008, 0x4a025a04, 0x00000146, + 0x83380580, 0x00000041, 0x04000003, 0x4a025a06, + 0x00000001, 0x59cc0007, 0x82000500, 0xff000000, + 0x80000110, 0x59cc1008, 0x82081500, 0xff000000, + 0x80081540, 0x480a580a, 0x83380580, 0x00000046, + 0x04020006, 0x59cc0007, 0x82000500, 0x00ffffff, + 0x4802580b, 0x0401f005, 0x59cc0008, 0x82000500, + 0x00ffffff, 0x4802580b, 0x83380580, 0x00000046, + 0x04020004, 0x83cc1400, 0x00000009, 0x0401f003, + 0x83cc1400, 0x0000000d, 0x50080000, 0x9c0001c0, + 0x4802580c, 0x80081000, 0x50080000, 0x9c0001c0, + 0x4802580d, 0x83380580, 0x00000046, 0x04020008, + 0x59cc000b, 0x9c0001c0, 0x4802580e, 0x59cc000c, + 0x9c0001c0, 0x4802580f, 0x0401f007, 0x59cc000f, + 0x9c0001c0, 0x4802580e, 0x59cc0010, 0x9c0001c0, + 0x4802580f, 0x83380580, 0x00000046, 0x04020004, + 0x83cc1400, 0x00000011, 0x0401f003, 0x83cc1400, + 0x00000015, 0x412c3000, 0x82183400, 0x00000010, + 0x4200b000, 0x00000004, 0x50080000, 0x9c0001c0, + 0x44003000, 0x80081000, 0x80183000, 0x8058b040, + 0x040207fa, 0x5c00a800, 0x5c00b000, 0x0201f800, + 0x000202da, 0x5c025800, 0x1c01f000, 0x4933c857, + 0x492fc857, 0x59300809, 0x58040200, 0x8c00051e, + 0x04000004, 0x592c0208, 0x84000558, 0x48025a08, + 0x1c01f000, 0x59e0180f, 0x599c0413, 0x800c1000, + 0x80080580, 0x04020002, 0x41781000, 0x59e00010, + 0x59e00810, 0x80040d80, 0x040207fd, 0x80080580, + 0x0400000b, 0x4c080000, 0x599c0814, 0x599c1015, + 0x800c00cc, 0x80040c00, 0x82081440, 0x00000000, + 0x5c001800, 0x82000540, 0x00000001, 0x4803c857, + 0x1c01f000, 0x492fc857, 0x42007000, 0x0010b7f8, + 0x58380807, 0x800409c0, 0x04020005, 0x492c7008, + 0x492c7007, 0x0201f000, 0x00100875, 0x492c0800, + 0x492c7007, 0x1c01f000, 0x59300203, 0x4933c857, + 0x4937c857, 0x493bc857, 0x4803c857, 0x82003480, + 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f001, + 0x0010a6da, 0x0010a82c, 0x0010a6da, 0x0010a6da, + 0x0010a6da, 0x0010a6da, 0x0010a6da, 0x0010a791, + 0x0010a6dc, 0x0010a6da, 0x0010a6da, 0x0010a6da, + 0x0010a6da, 0x0010a6da, 0x0201f800, 0x001005d8, + 0x83380580, 0x0000004c, 0x02020800, 0x001005d8, + 0x0201f800, 0x001048ec, 0x04020020, 0x59a80826, + 0x82040500, 0x00000009, 0x82000580, 0x00000008, + 0x0400001a, 0x8c040d12, 0x0400003d, 0x59cc0806, + 0x82040d00, 0xff000000, 0x82040580, 0x03000000, + 0x0400001f, 0x82040580, 0x50000000, 0x04000005, + 0x82040580, 0x52000000, 0x02020000, 0x0002077d, + 0x813669c0, 0x04000006, 0x4d3c0000, 0x417a7800, + 0x0201f800, 0x0010203c, 0x5c027800, 0x4a026403, + 0x00000001, 0x0401f014, 0x59cc0806, 0x82040d00, + 0xff000000, 0x82040580, 0x03000000, 0x04000008, + 0x82040580, 0x50000000, 0x04000005, 0x82040580, + 0x52000000, 0x02020000, 0x0002077d, 0x4a026403, + 0x00000009, 0x4a02641a, 0x00000009, 0x4a02621a, + 0x00000000, 0x813669c0, 0x0402000b, 0x59cc0001, + 0x0201f800, 0x00105c9a, 0x02020000, 0x0002077d, + 0x0201f800, 0x001045a6, 0x02020000, 0x0002077d, + 0x49366009, 0x4a026406, 0x00000004, 0x4a026203, + 0x00000001, 0x0201f000, 0x0010672b, 0x0201f800, + 0x00103b25, 0x04000023, 0x59cc0806, 0x4807c857, + 0x82040d00, 0xff000000, 0x82040580, 0x03000000, + 0x04000033, 0x82040580, 0x20000000, 0x04000041, + 0x82040580, 0x21000000, 0x04000052, 0x82040580, + 0x24000000, 0x0400004f, 0x82040580, 0x50000000, + 0x0400004c, 0x82040580, 0x52000000, 0x04000049, + 0x82040580, 0x05000000, 0x0402000d, 0x59cc0806, + 0x82040d00, 0xff000000, 0x9c0431c0, 0x42028000, + 0x00000046, 0x42002800, 0x00000001, 0x0401fcf3, + 0x0401f93c, 0x02000800, 0x001005d8, 0x42002000, + 0x00000051, 0x0201f800, 0x00107a4a, 0x59cc0000, + 0x82000500, 0x00ffffff, 0x82000580, 0x00ffffff, + 0x04000005, 0x4a026203, 0x00000007, 0x493a6403, + 0x1c01f000, 0x59325817, 0x812e59c0, 0x02020800, + 0x001007fd, 0x0201f000, 0x0002077d, 0x813669c0, + 0x040007df, 0x59340400, 0x82000500, 0x000000ff, + 0x82000580, 0x00000003, 0x040207d9, 0x0401fc6f, + 0x040207d7, 0x4a026403, 0x00000009, 0x4a02641a, + 0x0000000e, 0x4a02621a, 0x00001900, 0x0401f7a2, + 0x813669c0, 0x0400000c, 0x59340c00, 0x82040500, + 0x000000ff, 0x82000580, 0x00000009, 0x04000794, + 0x82040500, 0x0000ff00, 0x82000580, 0x00000700, + 0x040207c3, 0x4a026403, 0x00000009, 0x4a02641a, + 0x00000009, 0x4a02621a, 0x00001e00, 0x0401f78e, + 0x813669c0, 0x040007f8, 0x59340c00, 0x82040500, + 0x0000ff00, 0x82000580, 0x00000700, 0x040007f2, + 0x0401f7b3, 0x4d2c0000, 0x4c580000, 0x4c500000, + 0x4c540000, 0x41385000, 0x83380580, 0x00000054, + 0x02020800, 0x001005d8, 0x59325808, 0x592c0c0b, + 0x82040d00, 0x0000e000, 0x82040580, 0x00002000, + 0x04020076, 0x59300817, 0x800409c0, 0x04000014, + 0x58041404, 0x41cca800, 0x8204a400, 0x00000005, + 0x82080480, 0x00000010, 0x04021004, 0x4008b000, + 0x0401fb6b, 0x0401f00a, 0x40001000, 0x4200b000, + 0x0000000f, 0x0401fb66, 0x58040801, 0x800409c0, + 0x040207f2, 0x0201f800, 0x001005d8, 0x813669c0, + 0x0400005e, 0x59344c00, 0x592c0c09, 0x4807c857, + 0x4827c857, 0x82040d00, 0x000000ff, 0x82040580, + 0x00000003, 0x0400002a, 0x82040580, 0x00000005, + 0x04000032, 0x82040580, 0x00000020, 0x04000036, + 0x82040580, 0x00000052, 0x04000042, 0x82040580, + 0x00000050, 0x04000042, 0x82040580, 0x00000021, + 0x04000004, 0x82040580, 0x00000024, 0x04020043, + 0x82240500, 0x0000ff00, 0x82000580, 0x00000007, + 0x04000008, 0x42000800, 0x00000009, 0x0201f800, + 0x00104571, 0x42005000, 0x0000000c, 0x0401f037, + 0x4a025a06, 0x00000031, 0x4a02580d, 0x00000009, + 0x59340400, 0x4802580e, 0x0201f800, 0x000202da, + 0x0201f800, 0x00107911, 0x0401f03d, 0x0201f800, + 0x001042b4, 0x0201f800, 0x0010462a, 0x42000800, + 0x00000003, 0x0201f800, 0x00104571, 0x42005000, + 0x00000008, 0x0401f021, 0x59cc0007, 0x0201f800, + 0x00105eec, 0x0402001d, 0x0201f800, 0x001042b4, + 0x0401f01a, 0x82240500, 0x0000ff00, 0x82000580, + 0x00000007, 0x040007df, 0x82240500, 0x000000ff, + 0x82000580, 0x00000009, 0x040007da, 0x0201f800, + 0x0010468d, 0x42005000, 0x0000000a, 0x0401f00b, + 0x42005000, 0x0000000e, 0x0401f003, 0x42005000, + 0x00000010, 0x82240500, 0x0000ff00, 0x82000580, + 0x00000007, 0x040007cb, 0x482a6403, 0x4a026203, + 0x00000001, 0x592c000d, 0x48026011, 0x497a6013, + 0x59a80038, 0x48026206, 0x417a7800, 0x0201f800, + 0x0010672b, 0x59325817, 0x812e59c0, 0x04000004, + 0x0201f800, 0x001007fd, 0x497a6017, 0x5c00a800, + 0x5c00a000, 0x5c00b000, 0x5c025800, 0x1c01f000, + 0x4d2c0000, 0x59325808, 0x83380580, 0x00000013, + 0x04020029, 0x59300c03, 0x82040580, 0x00000054, + 0x0400001e, 0x82040580, 0x00000010, 0x04000018, + 0x82040580, 0x0000000e, 0x04000015, 0x82040580, + 0x00000008, 0x0400000d, 0x82040580, 0x0000000c, + 0x0400000a, 0x82040580, 0x0000000a, 0x02020800, + 0x001005d8, 0x42000800, 0x00000006, 0x0201f800, + 0x00104571, 0x0401f009, 0x42000800, 0x00000004, + 0x0201f800, 0x00104571, 0x0401f004, 0x59340200, + 0x8400051a, 0x48026a00, 0x4a025a06, 0x00000000, + 0x0201f800, 0x000202da, 0x0201f800, 0x0002077d, + 0x0401f022, 0x83380580, 0x00000027, 0x0400000e, + 0x83380580, 0x00000014, 0x02020800, 0x001005d8, + 0x0201f800, 0x00106bbf, 0x42028000, 0x00000031, + 0x42000800, 0x00000004, 0x42001000, 0x000000ff, + 0x0401f009, 0x0201f800, 0x00106bbf, 0x42028000, + 0x00000031, 0x42000800, 0x00000004, 0x42001000, + 0x00000010, 0x49425a06, 0x4806580d, 0x480a580e, + 0x0201f800, 0x000202da, 0x0201f800, 0x00104c19, + 0x0201f800, 0x00107911, 0x5c025800, 0x1c01f000, + 0x42007000, 0x0010b7f8, 0x58380807, 0x800409c0, + 0x04020005, 0x492c7008, 0x492c7007, 0x0201f000, + 0x00100875, 0x492c0800, 0x492c7007, 0x1c01f000, + 0x4d2c0000, 0x4c580000, 0x4c500000, 0x4c540000, + 0x4933c857, 0x4937c857, 0x59cc0806, 0x4807c857, + 0x82040d00, 0xff000000, 0x82040580, 0x03000000, + 0x0400000d, 0x82040580, 0x05000000, 0x0400000a, + 0x82040580, 0x21000000, 0x04000030, 0x82040580, + 0x24000000, 0x0400002d, 0x82040580, 0x20000000, + 0x0402002f, 0x0201f800, 0x001007e4, 0x0400002c, + 0x492fc857, 0x492e6017, 0x59a8b016, 0x8258b400, + 0x0000001b, 0x8258b500, 0xfffffffc, 0x8058b104, + 0x485a5c04, 0x412c7800, 0x41cca000, 0x82580480, + 0x00000010, 0x04021005, 0x832cac00, 0x00000005, + 0x0401fa63, 0x0401f015, 0x40580800, 0x4200b000, + 0x0000000f, 0x832cac00, 0x00000005, 0x0401fa5c, + 0x8204b480, 0x0000000f, 0x0201f800, 0x001007e4, + 0x04000004, 0x492c7801, 0x412c7800, 0x0401f7ec, + 0x59325817, 0x0201f800, 0x001007fd, 0x497a6017, + 0x80000580, 0x0401f006, 0x59340200, 0x84000554, + 0x48026a00, 0x82000540, 0x00000001, 0x5c00a800, + 0x5c00a000, 0x5c00b000, 0x5c025800, 0x1c01f000, + 0x4933c857, 0x492fc857, 0x4d2c0000, 0x59300a03, + 0x82040580, 0x00000007, 0x04000036, 0x82040580, + 0x00000001, 0x02020800, 0x001005d8, 0x0201f800, + 0x00106c55, 0x4df00000, 0x598c000d, 0x81300580, + 0x04020016, 0x59300004, 0x8c000520, 0x04000004, + 0x84000520, 0x48026004, 0x0401f016, 0x42001000, + 0x0010b7f6, 0x50081000, 0x58080002, 0x82000580, + 0x00000100, 0x04000006, 0x5808000c, 0x81300580, + 0x02020800, 0x001005d8, 0x0401f00a, 0x0201f800, + 0x00106e8e, 0x04020020, 0x59300004, 0x8c000520, + 0x04000004, 0x84000520, 0x48026004, 0x0401f003, + 0x0201f800, 0x001068d3, 0x5c03e000, 0x02000800, + 0x00106c4b, 0x0201f800, 0x00109037, 0x02000800, + 0x001005d8, 0x59325808, 0x4a025a06, 0x00000005, + 0x0201f800, 0x000202da, 0x0201f800, 0x00104c19, + 0x59325817, 0x812e59c0, 0x02020800, 0x001007fd, + 0x0201f800, 0x00107911, 0x80000580, 0x5c025800, + 0x1c01f000, 0x5c03e000, 0x02000800, 0x00106c4b, + 0x59300406, 0x82000580, 0x00000011, 0x040007b8, + 0x0401f7f7, 0x4c040000, 0x59340200, 0x4803c857, + 0x8c00051c, 0x04000009, 0x59cc0805, 0x591c0019, + 0x4803c857, 0x80040580, 0x04000004, 0x80000580, + 0x4803c856, 0x0401f003, 0x82000540, 0x00000001, + 0x5c000800, 0x1c01f000, 0x4c000000, 0x4c0c0000, + 0x4c100000, 0x42001800, 0x0000ffff, 0x42002000, + 0x00000004, 0x0401f010, 0x4c000000, 0x4c0c0000, + 0x4c100000, 0x59302009, 0x58101c03, 0x42002000, + 0x00000004, 0x0401f008, 0x4c000000, 0x4c0c0000, + 0x4c100000, 0x59302009, 0x58101c03, 0x42002000, + 0x00000007, 0x480fc857, 0x4813c857, 0x481bc857, + 0x0201f800, 0x00103aae, 0x5c002000, 0x5c001800, + 0x5c000000, 0x1c01f000, 0x83380580, 0x00000092, + 0x02020800, 0x001005d8, 0x42000800, 0x80000040, + 0x4a026203, 0x00000001, 0x493a6403, 0x0201f000, + 0x00020721, 0x4d400000, 0x0201f800, 0x00103b25, + 0x04000008, 0x59a80005, 0x84000544, 0x48035005, + 0x42028000, 0x0000002a, 0x0201f800, 0x0010a449, + 0x5c028000, 0x1c01f000, 0x59a80026, 0x8c000508, + 0x04000005, 0x599c0017, 0x8c00050a, 0x04020002, + 0x1c01f000, 0x82000540, 0x00000001, 0x1c01f000, + 0x59300420, 0x84000540, 0x48026420, 0x1c01f000, + 0x4817c857, 0x4c000000, 0x4c040000, 0x8c142d2a, + 0x04000004, 0x598800b8, 0x80000000, 0x480310b8, + 0x8c142d2e, 0x04000004, 0x598800b9, 0x80000000, + 0x480310b9, 0x8c142d2c, 0x04000013, 0x40140000, + 0x82000500, 0x00070000, 0x82000d80, 0x00030000, + 0x0400000d, 0x82000d80, 0x00040000, 0x0400000a, + 0x82000d80, 0x00050000, 0x04000007, 0x59880005, + 0x80000000, 0x48031005, 0x598800ba, 0x80000000, + 0x480310ba, 0x5c000800, 0x5c000000, 0x1c01f000, + 0x4817c857, 0x4c000000, 0x4c040000, 0x8c142d2a, + 0x04000004, 0x598800bb, 0x80000000, 0x480310bb, + 0x8c142d2e, 0x04000004, 0x598800bc, 0x80000000, + 0x480310bc, 0x8c142d2c, 0x04000013, 0x40140000, + 0x82000500, 0x00070000, 0x82000d80, 0x00030000, + 0x0400000d, 0x82000d80, 0x00040000, 0x0400000a, + 0x82000d80, 0x00050000, 0x04000007, 0x59880005, + 0x80000000, 0x48031005, 0x598800bd, 0x80000000, + 0x480310bd, 0x5c000800, 0x5c000000, 0x1c01f000, + 0x4c000000, 0x59880001, 0x80000000, 0x4803c857, + 0x48031001, 0x5c000000, 0x1c01f000, 0x4c000000, + 0x59880000, 0x80000000, 0x4803c857, 0x48031000, + 0x5c000000, 0x1c01f000, 0x4c000000, 0x59880002, + 0x80000000, 0x4803c857, 0x48031002, 0x5c000000, + 0x1c01f000, 0x4807c857, 0x4c000000, 0x8c040d2c, + 0x04000004, 0x598800a6, 0x80000000, 0x480310a6, + 0x8c040d2a, 0x04000004, 0x598800a7, 0x80000000, + 0x480310a7, 0x8c040d28, 0x04000004, 0x598800a8, + 0x80000000, 0x480310a8, 0x8c040d26, 0x04000004, + 0x598800a9, 0x80000000, 0x480310a9, 0x8c040d24, + 0x04000004, 0x598800aa, 0x80000000, 0x480310aa, + 0x8c040d22, 0x04000004, 0x598800ab, 0x80000000, + 0x480310ab, 0x8c040d20, 0x04000004, 0x598800ac, + 0x80000000, 0x480310ac, 0x5c000000, 0x1c01f000, + 0x4807c857, 0x4c000000, 0x598800ad, 0x80000000, + 0x480310ad, 0x5c000000, 0x1c01f000, 0x4807c857, + 0x4c000000, 0x8c040d1c, 0x04000004, 0x598800ae, + 0x80000000, 0x480310ae, 0x8c040d1a, 0x04000004, + 0x598800af, 0x80000000, 0x480310af, 0x5c000000, + 0x1c01f000, 0x4807c857, 0x4c000000, 0x8c040d18, + 0x04000004, 0x598800b0, 0x80000000, 0x480310b0, + 0x8c040d16, 0x04000004, 0x598800b1, 0x80000000, + 0x480310b1, 0x8c040d14, 0x04000004, 0x598800b2, + 0x80000000, 0x480310b2, 0x5c000000, 0x1c01f000, + 0x4807c857, 0x4c000000, 0x8c040d10, 0x04000004, + 0x598800b3, 0x80000000, 0x480310b3, 0x8c040d0c, + 0x04000004, 0x598800b4, 0x80000000, 0x480310b4, + 0x5c000000, 0x1c01f000, 0x4807c857, 0x4c000000, + 0x8c040d08, 0x04000004, 0x598800b5, 0x80000000, + 0x480310b5, 0x8c040d04, 0x04000004, 0x598800b6, + 0x80000000, 0x480310b6, 0x5c000000, 0x1c01f000, + 0x4807c856, 0x4c000000, 0x5988007f, 0x80000000, + 0x4803107f, 0x5c000000, 0x1c01f000, 0x4803c857, + 0x4c040000, 0x50000800, 0x80040800, 0x4807c857, + 0x44040000, 0x5c000800, 0x1c01f000, 0x480fc857, + 0x4c000000, 0x820c0580, 0x00000000, 0x04020004, + 0x42000000, 0x0010b819, 0x0401f014, 0x820c0580, + 0x00001001, 0x04020004, 0x42000000, 0x0010b81a, + 0x0401f00e, 0x820c0580, 0x00001002, 0x04020004, + 0x42000000, 0x0010b81b, 0x0401f008, 0x820c0c80, + 0x0000201c, 0x02021800, 0x001005d8, 0x820c0500, + 0x0000001f, 0x0c01f804, 0x0401ffdd, 0x5c000000, + 0x1c01f000, 0x0010aa89, 0x0010aa8c, 0x0010aa8f, + 0x0010aa92, 0x0010aa95, 0x0010aa98, 0x0010aa9b, + 0x0010aa9e, 0x0010aaa1, 0x0010aaa4, 0x0010aaa7, + 0x0010aaaa, 0x0010aaad, 0x0010aab0, 0x0010aab3, + 0x0010aab6, 0x0010aab9, 0x0010aabc, 0x0010aabf, + 0x0010aac2, 0x0010aac5, 0x0010aac8, 0x0010aacb, + 0x0010aace, 0x0010aad1, 0x0010aad4, 0x0010aad7, + 0x0010aada, 0x42000000, 0x0010b81c, 0x1c01f000, + 0x42000000, 0x0010b81d, 0x1c01f000, 0x42000000, + 0x0010b81e, 0x1c01f000, 0x42000000, 0x0010b81f, + 0x1c01f000, 0x42000000, 0x0010b820, 0x1c01f000, + 0x42000000, 0x0010b821, 0x1c01f000, 0x42000000, + 0x0010b822, 0x1c01f000, 0x42000000, 0x0010b823, + 0x1c01f000, 0x42000000, 0x0010b824, 0x1c01f000, + 0x42000000, 0x0010b825, 0x1c01f000, 0x42000000, + 0x0010b826, 0x1c01f000, 0x42000000, 0x0010b827, + 0x1c01f000, 0x42000000, 0x0010b828, 0x1c01f000, + 0x42000000, 0x0010b829, 0x1c01f000, 0x42000000, + 0x0010b82a, 0x1c01f000, 0x42000000, 0x0010b82b, + 0x1c01f000, 0x42000000, 0x0010b82c, 0x1c01f000, + 0x42000000, 0x0010b82d, 0x1c01f000, 0x42000000, + 0x0010b82e, 0x1c01f000, 0x42000000, 0x0010b82f, + 0x1c01f000, 0x42000000, 0x0010b830, 0x1c01f000, + 0x42000000, 0x0010b831, 0x1c01f000, 0x42000000, + 0x0010b832, 0x1c01f000, 0x42000000, 0x0010b833, + 0x1c01f000, 0x42000000, 0x0010b834, 0x1c01f000, + 0x42000000, 0x0010b835, 0x1c01f000, 0x42000000, + 0x0010b836, 0x1c01f000, 0x42000000, 0x0010b837, + 0x1c01f000, 0x480fc857, 0x4c000000, 0x820c0580, + 0x00000001, 0x04020004, 0x42000000, 0x0010b80e, + 0x0401f012, 0x820c0580, 0x00000002, 0x04020004, + 0x42000000, 0x0010b80f, 0x0401f00c, 0x820c0580, + 0x00000003, 0x04020004, 0x42000000, 0x0010b810, + 0x0401f006, 0x820c0580, 0x00000004, 0x04020004, + 0x42000000, 0x0010b811, 0x0401ff51, 0x5c000000, + 0x1c01f000, 0x4c000000, 0x59a80026, 0x4803c857, + 0x8c000502, 0x04000010, 0x8c000506, 0x04000004, + 0x42000000, 0x0010b841, 0x0401f012, 0x8c00050a, + 0x04000004, 0x42000000, 0x0010b840, 0x0401f00d, + 0x8c000508, 0x04000004, 0x42000000, 0x0010b843, + 0x0401f008, 0x0201f800, 0x0010513b, 0x04000006, + 0x8c000506, 0x04020004, 0x42000000, 0x0010b842, + 0x0401ff33, 0x5c000000, 0x1c01f000, 0x8058b1c0, + 0x02000800, 0x001005d8, 0x5450a800, 0x8050a000, + 0x8054a800, 0x8058b040, 0x040207fc, 0x1c01f000, + 0x8058b1c0, 0x02000800, 0x001005d8, 0x4450a800, + 0x8054a800, 0x8058b040, 0x040207fd, 0x1c01f000, + 0x8058b1c0, 0x02000800, 0x001005d8, 0x50500000, + 0x9c0001c0, 0x4400a800, 0x8050a000, 0x8054a800, + 0x8058b040, 0x040207fa, 0x1c01f000, 0x4c000000, + 0x59a80008, 0x8c00051c, 0x5c000000, 0x1c01f000, + 0x00000001, 0x00000002, 0x00000004, 0x00000008, + 0x00000010, 0x00000020, 0x00000040, 0x00000080, + 0x00000100, 0x00000200, 0x00000400, 0x00000800, + 0x00001000, 0x00002000, 0x00004000, 0x00008000, + 0x00010000, 0xa5f2b3ac +}; + +#ifdef UNIQUE_FW_NAME +uint32_t fw2400_length01 = 0x0000ab4a ; +#else +uint32_t risc_code_length01 = 0x0000ab4a ; +#endif + + +#ifdef UNIQUE_FW_NAME +uint32_t fw2400_addr02 = 0x0010e000 ; +#else +uint32_t risc_code_addr02 = 0x0010e000 ; +#endif + +#ifdef UNIQUE_FW_NAME +uint32_t fw2400_code02[] = { +#else +uint32_t risc_code02[] = { +#endif + 0x00000000, 0x00000000, 0x0010e000, 0x000014ff, + 0x00000000, 0x00000000, 0x00020000, 0x000008c0, + 0x836c0580, 0x00000003, 0x02020000, 0x001002e3, + 0x42000000, 0x0010b4bb, 0x50000000, 0x800001c0, + 0x04020956, 0x0401f923, 0x0401fbe3, 0x0401fb5c, + 0x0201f800, 0x00020718, 0x0201f800, 0x0002057b, + 0x0401f7f0, 0x59b800ea, 0x82000d00, 0xf0000038, + 0x02020000, 0x00100a7a, 0x8c000510, 0x02000000, + 0x00100a79, 0x59ba60e0, 0x81300182, 0x0402104e, + 0x04002030, 0x8532653e, 0x59300406, 0x82000580, + 0x00000003, 0x04020028, 0x59300203, 0x82000580, + 0x00000004, 0x04020024, 0x59325808, 0x59300402, + 0x4a025a04, 0x00000103, 0x900001c0, 0x48025806, + 0x497a5807, 0x497a5c09, 0x5930001f, 0x80000540, + 0x02020800, 0x00100d56, 0x59300004, 0x8c00053e, + 0x04020010, 0x0401fa88, 0x59326809, 0x0201f800, + 0x0002077d, 0x5934000f, 0x5934140b, 0x80081040, + 0x04001002, 0x480a6c0b, 0x80000540, 0x04020a10, + 0x59b800ea, 0x8c000510, 0x040207d7, 0x1c01f000, + 0x0201f800, 0x00106f60, 0x040007ef, 0x0201f000, + 0x00100a65, 0x42027000, 0x00000055, 0x0401f027, + 0x83326500, 0x3fffffff, 0x59300406, 0x82000580, + 0x00000003, 0x04020015, 0x59325808, 0x59326809, + 0x59301402, 0x4a025a04, 0x00000103, 0x900811c0, + 0x480a5806, 0x497a5c09, 0x497a5807, 0x0401fa62, + 0x0201f800, 0x0002077d, 0x5934000f, 0x5934140b, + 0x80081040, 0x04001002, 0x480a6c0b, 0x80000540, + 0x040209eb, 0x0401f7db, 0x42027000, 0x00000054, + 0x0401f00a, 0x83300500, 0x60000000, 0x02000000, + 0x00100a68, 0x81326580, 0x8000013a, 0x82000400, + 0x00100a80, 0x50027000, 0x59300c06, 0x82040580, + 0x00000002, 0x02000000, 0x00100a65, 0x59300004, + 0x8c00053e, 0x04020004, 0x0201f800, 0x000207a1, + 0x0401f7c4, 0x0201f800, 0x00106f60, 0x040007fb, + 0x0201f000, 0x00100a65, 0x59325808, 0x412c7000, + 0x58380a04, 0x82040500, 0x0000000f, 0x82000c00, + 0x001010bd, 0x50044000, 0x0c01f001, 0x00100dd9, + 0x00100dd9, 0x0002009f, 0x00100dd9, 0x00100dd9, + 0x00100dd9, 0x00100dd9, 0x00100dd9, 0x000200af, + 0x00100ded, 0x00100dd9, 0x00100dd9, 0x00100ddb, + 0x00100dd9, 0x00100dd9, 0x00100dd9, 0x5838040a, + 0x8c000500, 0x02000800, 0x001005d8, 0x50200000, + 0x80387c00, 0x583c1002, 0x583c2800, 0x583c2001, + 0x58380a07, 0x5838300f, 0x59303807, 0x58384c08, + 0x5838000d, 0x48026012, 0x0401f010, 0x5838020a, + 0x8c000502, 0x02000000, 0x00100dd9, 0x50200000, + 0x80387c00, 0x583c2800, 0x583c2001, 0x583c1002, + 0x592c0a07, 0x592c4c08, 0x592c300f, 0x59303807, + 0x497a6012, 0x497a6013, 0x4816600e, 0x4812600f, + 0x480a6010, 0x481a6011, 0x80040840, 0x4806600d, + 0x02020000, 0x00100e1a, 0x841c3d40, 0x481e6007, + 0x1c01f000, 0x41787800, 0x59325808, 0x592c0c0a, + 0x8c040d02, 0x02000000, 0x00100f8c, 0x592c000d, + 0x592c100f, 0x592c0a04, 0x480a6011, 0x48026012, + 0x48026013, 0x412c3000, 0x82040500, 0x0000000f, + 0x82000400, 0x001010bd, 0x50003800, 0x501c0000, + 0x401c1000, 0x592c1a07, 0x4802600a, 0x481a600b, + 0x480a600c, 0x480e600d, 0x843c7d4a, 0x403c1000, + 0x1c01f000, 0x41787800, 0x497a6012, 0x592c0a04, + 0x412c3000, 0x592c1a07, 0x82040500, 0x0000000f, + 0x82000400, 0x001010bd, 0x50004000, 0x50200000, + 0x40201000, 0x4802600a, 0x481a600b, 0x480a600c, + 0x480e600d, 0x80000580, 0x483e6004, 0x1c01f000, + 0x4c000000, 0x4df00000, 0x0201f800, 0x00020729, + 0x0401f005, 0x4c000000, 0x4df00000, 0x0401ff16, + 0x0401f001, 0x5c03e000, 0x5c000000, 0x1801f000, + 0x4203e000, 0xb0100000, 0x41fc0000, 0x82000500, + 0x00000011, 0x0c01f001, 0x0002012a, 0x00020697, + 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a, + 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a, + 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a, + 0x0002012a, 0x0002012a, 0x0010115a, 0x0002012c, + 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a, + 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a, + 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a, + 0x0002012a, 0x0002012a, 0x0201f800, 0x001005d8, + 0x0201f800, 0x00020697, 0x0201f000, 0x0010115a, + 0x42000000, 0x0010b4c1, 0x50000000, 0x8c000504, + 0x04000014, 0x42000000, 0x0010b4c1, 0x50000000, + 0x8c000502, 0x04020002, 0x1c01f000, 0x4df00000, + 0x4203e000, 0x50000000, 0x42034000, 0x0010b4a4, + 0x59a0001d, 0x59a1d81e, 0x84000502, 0x4803401d, + 0x58ec0009, 0x0801f800, 0x5c03e000, 0x1c01f000, + 0x04027002, 0x04026002, 0x1c01f000, 0x4df00000, + 0x4203e000, 0x50000000, 0x0201f800, 0x001007e4, + 0x04000010, 0x412dd800, 0x48efc857, 0x0201f800, + 0x00103b28, 0x42034000, 0x0010b4a4, 0x49a1d80b, + 0x48ef401e, 0x59a0001d, 0x84000544, 0x4803401d, + 0x0201f800, 0x00102214, 0x0201f800, 0x00102233, + 0x5c03e000, 0x1c01f000, 0x4da00000, 0x4df00000, + 0x4203e000, 0x50000000, 0x04006051, 0x40001000, + 0x42034000, 0x0010b4a4, 0x59a01818, 0x800c19c0, + 0x04020008, 0x59a0381b, 0x801c39c0, 0x02000800, + 0x001005d8, 0x59a0041c, 0x801c3c00, 0x0401f00c, + 0x59a00419, 0x82000400, 0x00000002, 0x48034419, + 0x82000c80, 0x00000013, 0x04001003, 0x497b4419, + 0x41780000, 0x59a03816, 0x801c3c00, 0x80081040, + 0x480b4017, 0x581c0200, 0x4803c021, 0x581c0401, + 0x4803c022, 0x581c0201, 0x4803c023, 0x581c0400, + 0x4803c020, 0x900001c0, 0x82000540, 0x00000012, + 0x4803c011, 0x59e00017, 0x8c000508, 0x04000003, + 0x4a03c017, 0x00000002, 0x4203e000, 0x30000001, + 0x800c19c0, 0x04000007, 0x800c1840, 0x480f4018, + 0x0402001f, 0x497b4419, 0x497b4219, 0x0401f01c, + 0x800811c0, 0x0402000b, 0x4d2c0000, 0x59a2581b, + 0x0201f800, 0x001007f4, 0x5c025800, 0x497b401b, + 0x497b401a, 0x497b441c, 0x497b421c, 0x0401f010, + 0x59a0041c, 0x82000400, 0x00000002, 0x82000c80, + 0x00000012, 0x4803441c, 0x04001009, 0x4d2c0000, + 0x59a2581b, 0x592c3813, 0x481f401b, 0x497b441c, + 0x0201f800, 0x001007f4, 0x5c025800, 0x5c03e000, + 0x5c034000, 0x1c01f000, 0x59a80005, 0x82000500, + 0x00000003, 0x02020000, 0x00104315, 0x59340400, + 0x82000580, 0x00000606, 0x02020000, 0x001042e6, + 0x5934000d, 0x80027d40, 0x02020000, 0x00104321, + 0x0401f803, 0x80000580, 0x1c01f000, 0x5934000f, + 0x59341203, 0x80080540, 0x0402006f, 0x5934020b, + 0x5934140b, 0x80080480, 0x0402106b, 0x0201f800, + 0x0002075a, 0x04000064, 0x80081000, 0x592c0406, + 0x480a6c0b, 0x49366009, 0x492e6008, 0x4a026406, + 0x00000003, 0x4a026403, 0x00000040, 0x800000c2, + 0x800018c4, 0x800c0400, 0x48026206, 0x592c0808, + 0x592c1809, 0x592c020a, 0x48066017, 0x480e6018, + 0x8c000502, 0x04000030, 0x4a026203, 0x00000004, + 0x592c0207, 0x80000040, 0x04020020, 0x59a80005, + 0x8c000514, 0x42000000, 0x00000055, 0x04020003, + 0x42000000, 0x00000033, 0x80000040, 0x040207ff, + 0x592c0204, 0x82000500, 0x000000ff, 0x82000580, + 0x00000018, 0x04020011, 0x592c180f, 0x59300007, + 0x82000540, 0x00000091, 0x480e6011, 0x48026007, + 0x42000000, 0x80000004, 0x48026004, 0x59bc00ea, + 0x8c000516, 0x040207fe, 0x83300400, 0x20000000, + 0x480378e1, 0x1c01f000, 0x0401fe78, 0x59300007, + 0x8400054e, 0x48026007, 0x592c1a04, 0x820c1d00, + 0x000000ff, 0x820c0580, 0x00000048, 0x04000017, + 0x0401f7ec, 0x8c000500, 0x04020ecb, 0x4a026203, + 0x00000002, 0x59a80805, 0x82040500, 0x00000600, + 0x04020012, 0x42000000, 0x00000030, 0x80000040, + 0x040207ff, 0x592c1a04, 0x820c1d00, 0x000000ff, + 0x820c0580, 0x00000018, 0x040007da, 0x820c0580, + 0x00000048, 0x040207d7, 0x42000800, 0x80000804, + 0x0201f000, 0x00106721, 0x8c040d12, 0x42000000, + 0x00000010, 0x040207ee, 0x42000000, 0x00000051, + 0x0401f7eb, 0x800811c0, 0x04020003, 0x4a026a03, + 0x00000001, 0x59340010, 0x492e6810, 0x80000d40, + 0x04020003, 0x492e680f, 0x1c01f000, 0x492c0800, + 0x1c01f000, 0x83440c80, 0x00000800, 0x04021009, + 0x83440400, 0x0010ac00, 0x50000000, 0x80000540, + 0x04000004, 0x40026800, 0x80000580, 0x1c01f000, + 0x82000540, 0x00000001, 0x1c01f000, 0x59340203, + 0x80000540, 0x0402004b, 0x4d300000, 0x4d2c0000, + 0x5934000f, 0x80025d40, 0x04000044, 0x0201f800, + 0x0002075a, 0x0400003f, 0x592c0000, 0x4802680f, + 0x80000540, 0x04020002, 0x48026810, 0x592c2a04, + 0x80081000, 0x480a6c0b, 0x49366009, 0x492e6008, + 0x82142d00, 0x000000ff, 0x82140580, 0x00000012, + 0x04000035, 0x4a026406, 0x00000003, 0x4a026403, + 0x00000040, 0x592c0406, 0x800000c2, 0x800018c4, + 0x800c0400, 0x48026206, 0x592c0808, 0x592c1809, + 0x592c020a, 0x48066017, 0x480e6018, 0x8c000502, + 0x02000000, 0x0010474d, 0x4a026203, 0x00000004, + 0x592c0207, 0x80000040, 0x02020000, 0x00104740, + 0x82140580, 0x00000018, 0x02020000, 0x00104740, + 0x592c180f, 0x59300007, 0x82000540, 0x00000091, + 0x480e6011, 0x48026007, 0x42000000, 0x80000004, + 0x48026004, 0x59bc00ea, 0x8c000516, 0x040207fe, + 0x83300400, 0x20000000, 0x480378e1, 0x5934020b, + 0x5934140b, 0x80080480, 0x040017be, 0x0401f003, + 0x4a026a03, 0x00000001, 0x5c025800, 0x5c026000, + 0x1c01f000, 0x497a5800, 0x49325809, 0x4a026406, + 0x00000006, 0x4a026203, 0x00000007, 0x0401f802, + 0x0401f7ef, 0x59a80021, 0x800001c0, 0x02020000, + 0x0010476f, 0x59a80005, 0x8c000504, 0x02020000, + 0x0010476b, 0x59340200, 0x8c000518, 0x02020000, + 0x00104767, 0x592c0a0c, 0x48066202, 0x4a025a06, + 0x00000000, 0x8c000508, 0x02020000, 0x00104763, + 0x4d3c0000, 0x417a7800, 0x0401fbdf, 0x5c027800, + 0x1c01f000, 0x592c0404, 0x8c00051e, 0x02020000, + 0x00104ce4, 0x59980022, 0x80000540, 0x04000017, + 0x592c0a06, 0x592c0409, 0x80040540, 0x04020013, + 0x0201f000, 0x00104cfa, 0x592c0404, 0x8c00051e, + 0x02020000, 0x00104cf3, 0x59980022, 0x80000540, + 0x0400000a, 0x82040580, 0x00000001, 0x04020007, + 0x0201f000, 0x00104cfa, 0x592c0404, 0x8c00051e, + 0x02020000, 0x00104dca, 0x59980026, 0x497a5800, + 0x80000540, 0x02020000, 0x00104e1d, 0x59d80105, + 0x82000d00, 0x00018780, 0x02020000, 0x00104edb, + 0x80000106, 0x82000500, 0x00000003, 0x0c01f001, + 0x000202f0, 0x00104e1d, 0x000202f6, 0x00020341, + 0x592c0001, 0x492fb107, 0x80000d40, 0x02020000, + 0x00104ddb, 0x1c01f000, 0x592c0001, 0x492fb107, + 0x80000d40, 0x02020000, 0x00104de8, 0x59da5908, + 0x835c0480, 0x00000020, 0x0400102c, 0x0402b034, + 0x492fb007, 0x0400e7fa, 0x59d80105, 0x82000500, + 0x00018780, 0x02020000, 0x00104edb, 0x0400601f, + 0x59d8010a, 0x59d8090a, 0x80040580, 0x040207fd, + 0x800408e0, 0x599c1017, 0x8c081508, 0x04020028, + 0x82040d40, 0x00000013, 0x5998002b, 0x4807c011, + 0x84000500, 0x4803302b, 0x59e00017, 0x8c000508, + 0x04020004, 0x4203e000, 0x30000001, 0x1c01f000, + 0x4a03c017, 0x00000003, 0x82040500, 0x000000ff, + 0x82000580, 0x0000001d, 0x040207f7, 0x4a03c017, + 0x0000000d, 0x0401f7f4, 0x5998082b, 0x84040d40, + 0x4807302b, 0x1c01f000, 0x496a5800, 0x412ed000, + 0x815eb800, 0x59c80000, 0x82000540, 0x00001200, + 0x48039000, 0x0400e7ca, 0x0401f7d0, 0x0402f7f7, + 0x492fa807, 0x0400e7c6, 0x0401f7cc, 0x59e0000f, + 0x59e0100f, 0x80081580, 0x040207fd, 0x81281580, + 0x040007d4, 0x40025000, 0x82040d40, 0x0000001d, + 0x0401f7d2, 0x59d80908, 0x45680800, 0x4006d000, + 0x815eb800, 0x0400e7fc, 0x59c80000, 0x82000540, + 0x00001200, 0x48039000, 0x02006000, 0x00104df8, + 0x59d8010a, 0x59d8090a, 0x80040d80, 0x040207fd, + 0x900001c0, 0x82000540, 0x00000013, 0x4803c011, + 0x5998002b, 0x84000500, 0x4803302b, 0x59e00017, + 0x8c000508, 0x04000003, 0x4a03c017, 0x00000003, + 0x4203e000, 0x30000001, 0x59d80105, 0x82000500, + 0x00018780, 0x02020000, 0x00104edb, 0x0202d000, + 0x00104dfd, 0x592c0001, 0x492fb107, 0x80000d40, + 0x02020000, 0x00104e10, 0x1c01f000, 0x59980020, + 0x0c01f001, 0x00020370, 0x00020371, 0x00104e88, + 0x1c01f000, 0x4df00000, 0x4203e000, 0x50000000, + 0x0402681e, 0x04006004, 0x599c0017, 0x8c000508, + 0x04020865, 0x59980029, 0x80025d40, 0x0400000a, + 0x0402d00b, 0x59980026, 0x80000040, 0x48033026, + 0x592c0000, 0x492fb107, 0x48033029, 0x04020002, + 0x48033028, 0x5c03e000, 0x1c01f000, 0x59d80105, + 0x82000500, 0x00018780, 0x02020000, 0x00104edb, + 0x42000000, 0x0010b855, 0x0201f800, 0x0010aa47, + 0x5c03e000, 0x1c01f000, 0x5998002b, 0x8c000500, + 0x0402003b, 0x0400e007, 0x59d80105, 0x82000500, + 0x00018780, 0x02020000, 0x00104edb, 0x1c01f000, + 0x59da5908, 0x835c0c80, 0x00000020, 0x04001003, + 0x0400b029, 0x0400f02b, 0x496a5800, 0x412ed000, + 0x815eb800, 0x59c80000, 0x82000540, 0x00001200, + 0x48039000, 0x0400e7f3, 0x59d8010a, 0x59d8090a, + 0x80040580, 0x040207fd, 0x800408e0, 0x599c1017, + 0x8c081508, 0x04020022, 0x82040d40, 0x00000013, + 0x4807c011, 0x59e00017, 0x8c000508, 0x0400000a, + 0x4a03c017, 0x00000003, 0x82040500, 0x000000ff, + 0x82000580, 0x0000001d, 0x04020003, 0x4a03c017, + 0x0000000d, 0x4203e000, 0x30000001, 0x59d80105, + 0x82000500, 0x00018780, 0x02020000, 0x00104edb, + 0x1c01f000, 0x492fb007, 0x0400e7d2, 0x0401f7df, + 0x492fa807, 0x0400e7cf, 0x0401f7dc, 0x84000500, + 0x4803302b, 0x0400e7cb, 0x0401f7d8, 0x59e0000f, + 0x59e0100f, 0x80081580, 0x040207fd, 0x81281580, + 0x040007da, 0x40025000, 0x82040d40, 0x0000001d, + 0x0401f7d8, 0x59e0000f, 0x59e0100f, 0x80080d80, + 0x040207fd, 0x81280580, 0x04020002, 0x1c01f000, + 0x400a5000, 0x900811c0, 0x82081540, 0x0000001c, + 0x480bc011, 0x59e00017, 0x8c000508, 0x04000003, + 0x4a03c017, 0x0000000c, 0x4203e000, 0x30000001, + 0x1c01f000, 0x41700000, 0x0c01f001, 0x00105420, + 0x000203fc, 0x00105420, 0x00105421, 0x0010541e, + 0x0010541e, 0x0010541e, 0x0010541e, 0x001058b0, + 0x04010037, 0x59980006, 0x80000540, 0x0402003c, + 0x0402c01c, 0x4202f800, 0x00000010, 0x4df00000, + 0x4203e000, 0x50000000, 0x49db3005, 0x59da5808, + 0x592c0204, 0x497a5800, 0x497a5801, 0x82000500, + 0x000000ff, 0x82000c80, 0x00000079, 0x04021036, + 0x0c01f839, 0x5c03e000, 0x817ef840, 0x04000009, + 0x836c0580, 0x00000003, 0x04020006, 0x83700580, + 0x00000001, 0x04020010, 0x0401001b, 0x0400c7e8, + 0x0400f94a, 0x0400b134, 0x59d40005, 0x82000500, + 0x43018780, 0x02020000, 0x0010583f, 0x59d80005, + 0x82000500, 0x43018780, 0x02020000, 0x00105846, + 0x1c01f000, 0x83700580, 0x00000003, 0x02000800, + 0x00105421, 0x83700580, 0x00000001, 0x040207ed, + 0x04010005, 0x0400c7d2, 0x0401f7ea, 0x4202f800, + 0x00000010, 0x4df00000, 0x4203e000, 0x50000000, + 0x49d73005, 0x59d65808, 0x0401f7ce, 0x4df00000, + 0x4203e000, 0x50000000, 0x40025800, 0x592c0204, + 0x497b3005, 0x497b3006, 0x4202f800, 0x00000010, + 0x0401f7c7, 0x0201f800, 0x00105491, 0x5c03e000, + 0x0401f7d4, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105527, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x001054a1, + 0x00105491, 0x00105491, 0x00105491, 0x00105551, + 0x00105491, 0x00105491, 0x00105491, 0x000204ef, + 0x00105491, 0x001056b4, 0x00105491, 0x00105491, + 0x00105491, 0x000204c2, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x001054c9, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x001057d3, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x0010581e, 0x00105491, + 0x001054bb, 0x00105491, 0x00105797, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105765, 0x00105491, + 0x00105765, 0x00105872, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105725, + 0x00105855, 0x00105491, 0x00105865, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x00105491, 0x00105491, + 0x00105491, 0x00105491, 0x592c0204, 0x80000110, + 0x02000000, 0x00105499, 0x80000040, 0x04000009, + 0x48033002, 0x492f3003, 0x492f3004, 0x4a033008, + 0x000204d0, 0x4202e000, 0x00000003, 0x1c01f000, + 0x592c0406, 0x82000c80, 0x0000199a, 0x02021000, + 0x001054a9, 0x59a80021, 0x80000540, 0x02020000, + 0x001054d7, 0x592e8a06, 0x83440c80, 0x000007f0, + 0x02021000, 0x001054a9, 0x83440400, 0x0010ac00, + 0x50000000, 0x80026d40, 0x02000000, 0x001054db, + 0x59340002, 0x592c0810, 0x80040580, 0x82000500, + 0x00ffffff, 0x02020000, 0x001054a9, 0x0401fccf, + 0x02020000, 0x001054de, 0x1c01f000, 0x592c0204, + 0x80000110, 0x02000000, 0x00105499, 0x80000040, + 0x0402000b, 0x592c040a, 0x8c000504, 0x04000010, + 0x592c0207, 0x82000c80, 0x00001001, 0x02021000, + 0x001054a9, 0x0201f000, 0x0010588a, 0x48033002, + 0x492f3003, 0x492f3004, 0x4a033008, 0x00020507, + 0x4202e000, 0x00000003, 0x1c01f000, 0x592c0406, + 0x82000c80, 0x0000199a, 0x02021000, 0x001054a9, + 0x592e8a06, 0x417a7800, 0x0401fd37, 0x02020000, + 0x00105658, 0x59340002, 0x592c0808, 0x80040580, + 0x82000500, 0x00ffffff, 0x02020000, 0x001054a9, + 0x497a5808, 0x592e6009, 0x83300580, 0xffffffff, + 0x02000000, 0x00105618, 0x83300480, 0x0010d1c0, + 0x02001000, 0x00105675, 0x59a8000b, 0x81300480, + 0x02021000, 0x00105675, 0x592c240a, 0x49366009, + 0x8c10251c, 0x02020000, 0x00105606, 0x59a80068, + 0x8c000510, 0x02020000, 0x0010568e, 0x59a80821, + 0x800409c0, 0x02020000, 0x001055ec, 0x59a80805, + 0x8c040d04, 0x02020000, 0x0010567f, 0x59340200, + 0x8c000518, 0x02020000, 0x00105670, 0x59300c06, + 0x82040580, 0x00000006, 0x02020000, 0x00105610, + 0x59300414, 0x8c000516, 0x02020000, 0x0010567a, + 0x8c102508, 0x02020000, 0x0010a5b8, 0x59300808, + 0x4a025a06, 0x00000000, 0x800409c0, 0x02020000, + 0x001055e7, 0x592c0a0c, 0x48066202, 0x492e6008, + 0x0401f14d, 0x4df00000, 0x4203e000, 0x50000000, + 0x0402b00b, 0x835c0480, 0x00000020, 0x0400100d, + 0x815eb840, 0x416a5800, 0x592ed000, 0x492fb007, + 0x497a5800, 0x497a5801, 0x0400b7f7, 0x59d80005, + 0x82000500, 0x43018780, 0x02020000, 0x00105846, + 0x5c03e000, 0x1c01f000, 0x4df00000, 0x4203e000, + 0x50000000, 0x0402f00b, 0x835c0480, 0x00000020, + 0x0400100d, 0x815eb840, 0x416a5800, 0x592ed000, + 0x492fa807, 0x497a5800, 0x497a5801, 0x0400f7f7, + 0x59d40005, 0x82000500, 0x43018780, 0x02020000, + 0x0010583f, 0x5c03e000, 0x1c01f000, 0x4df00000, + 0x4203e000, 0x50000000, 0x59940024, 0x80000540, + 0x04000112, 0x4c000000, 0x42000000, 0x00001000, + 0x50000000, 0x82000480, 0x24320001, 0x04020015, + 0x42000800, 0x00000064, 0x80040840, 0x04000007, + 0x4a030000, 0x00000001, 0x40000000, 0x59800000, + 0x8c000500, 0x040007f9, 0x04000008, 0x42000800, + 0x00007a01, 0x50040000, 0x8c000510, 0x04000003, + 0x84000510, 0x44000800, 0x4a030000, 0x00000000, + 0x59e00002, 0x8c00051e, 0x0402001b, 0x42000000, + 0x00001000, 0x50000000, 0x82000480, 0x24320002, + 0x04020015, 0x42000800, 0x00000064, 0x80040840, + 0x04000007, 0x4a030000, 0x00000001, 0x40000000, + 0x59800000, 0x8c000500, 0x040007f9, 0x04000008, + 0x42000800, 0x00007a17, 0x50040000, 0x8c00050e, + 0x04020003, 0x8400054e, 0x44000800, 0x4a030000, + 0x00000000, 0x5c000000, 0x5994781a, 0x48032825, + 0x803c0480, 0x04001004, 0x04000003, 0x4803281a, + 0x0401f022, 0x41787800, 0x803c7800, 0x82000400, + 0x000003e8, 0x040027fd, 0x4803281a, 0x59a80024, + 0x803c1400, 0x480b5024, 0x803c0040, 0x04000002, + 0x483fc857, 0x59e40852, 0x59a80025, 0x80040580, + 0x04000004, 0x480bc857, 0x59e40052, 0x48035025, + 0x59940026, 0x803c0400, 0x48032826, 0x0201f800, + 0x00106021, 0x59940000, 0x82000580, 0x00000000, + 0x04020006, 0x59940026, 0x48032827, 0x497b2826, + 0x4a032800, 0x00000001, 0x4c0c0000, 0x59940007, + 0x80000d40, 0x0400001d, 0x59941006, 0x59940025, + 0x80081c80, 0x04001004, 0x04000003, 0x480f2806, + 0x0401f016, 0x80040840, 0x48072807, 0x82040580, + 0x000003e8, 0x04020007, 0x4c040000, 0x4c0c0000, + 0x59940008, 0x0801f800, 0x5c001800, 0x5c000800, + 0x800409c0, 0x04020004, 0x59940008, 0x0801f800, + 0x0401f006, 0x400c0000, 0x820c1c00, 0x0000000a, + 0x040027ed, 0x480f2806, 0x5c001800, 0x4d180000, + 0x59c40008, 0x8c000534, 0x04020025, 0x417a3000, + 0x83947c00, 0x00000009, 0x583c0001, 0x80000d40, + 0x04020008, 0x823c7c00, 0x00000003, 0x811a3000, + 0x83180580, 0x00000005, 0x040207f8, 0x0401f018, + 0x583c1000, 0x59940025, 0x80080480, 0x04001005, + 0x04000004, 0x48007800, 0x80000040, 0x04021010, + 0x80040840, 0x48047801, 0x04000008, 0x82000400, + 0x0000000a, 0x48007800, 0x040027fa, 0x82040500, + 0x0000007f, 0x0401f7e8, 0x583c0002, 0x4c3c0000, + 0x0801f800, 0x5c007800, 0x0401f7e3, 0x5c023000, + 0x59940019, 0x80001540, 0x04000008, 0x04002007, + 0x59940025, 0x80080480, 0x497b2819, 0x04001003, + 0x04000002, 0x48032819, 0x59940004, 0x80000d40, + 0x0400002a, 0x4c040000, 0x5994001c, 0x80000d40, + 0x04000013, 0x5994101b, 0x59940025, 0x80080480, + 0x04001005, 0x04000004, 0x4803281b, 0x80000040, + 0x0402100b, 0x80040840, 0x4807281c, 0x04020004, + 0x5994001d, 0x0801f800, 0x0401f005, 0x82000400, + 0x0000000a, 0x4803281b, 0x040027f7, 0x5c000800, + 0x59941003, 0x59940025, 0x80080480, 0x04001005, + 0x04000004, 0x48032803, 0x80000040, 0x0402100b, + 0x80040840, 0x48072804, 0x04020004, 0x59940005, + 0x0801f800, 0x0401f005, 0x82000400, 0x0000000a, + 0x48032803, 0x040027f7, 0x5994001f, 0x80000d40, + 0x04000013, 0x5994101e, 0x59940025, 0x80080480, + 0x04001005, 0x04000004, 0x4803281e, 0x80000040, + 0x0402100b, 0x80040840, 0x4807281f, 0x04020004, + 0x59940020, 0x0801f800, 0x0401f005, 0x82000400, + 0x00000001, 0x4803281e, 0x040027f7, 0x59940022, + 0x80000d40, 0x04000013, 0x59941021, 0x59940025, + 0x80080480, 0x04001005, 0x04000004, 0x48032821, + 0x80000040, 0x0402100b, 0x80040840, 0x48072822, + 0x04020004, 0x59940023, 0x0801f800, 0x0401f005, + 0x82000400, 0x0000000a, 0x48032821, 0x040027f7, + 0x59940824, 0x59940025, 0x80040480, 0x02001800, + 0x001005d8, 0x48032824, 0x59940000, 0x0c01f001, + 0x00105fb5, 0x00105fb7, 0x00105fdd, 0x59940024, + 0x80000000, 0x48032824, 0x4203e000, 0x70000000, + 0x1c01f000, 0x592c0406, 0x800000c2, 0x800008c4, + 0x80040c00, 0x592c040a, 0x48066206, 0x82000d00, + 0x00000003, 0x02000000, 0x0010615e, 0x8c000500, + 0x04020029, 0x8c00051e, 0x02000000, 0x00106139, + 0x82000d00, 0x000000c0, 0x02020000, 0x0010612f, + 0x82000d00, 0x00002020, 0x02020000, 0x0010612c, + 0x813e79c0, 0x02020000, 0x0010612c, 0x592c0c0c, + 0x800409c0, 0x02020000, 0x0010612c, 0x59300a03, + 0x82040d80, 0x00000007, 0x02020000, 0x0010612c, + 0x4a026203, 0x00000003, 0x4a026403, 0x00000043, + 0x0201f800, 0x000200c9, 0x82080d40, 0x80003465, + 0x48066004, 0x497a6000, 0x59bc00ea, 0x8c000516, + 0x040207fe, 0x83300400, 0xa0000000, 0x480378e1, + 0x1c01f000, 0x8c000502, 0x02020000, 0x00106181, + 0x8c00051e, 0x0400000e, 0x82000d00, 0x000000c0, + 0x04000005, 0x82040d80, 0x000000c0, 0x02020000, + 0x00106186, 0x82000d00, 0x00002020, 0x82040d80, + 0x00002020, 0x02000000, 0x0010614d, 0x592c0207, + 0x80000040, 0x02020000, 0x00106157, 0x592c180d, + 0x800c19c0, 0x02020000, 0x00106157, 0x592c180f, + 0x59300007, 0x82000540, 0x00000011, 0x480e6011, + 0x48026007, 0x4a026203, 0x00000004, 0x4a026403, + 0x00000042, 0x42000800, 0x80002001, 0x0401f02a, + 0x5c000000, 0x4c000000, 0x4803c857, 0x4807c857, + 0x0401f003, 0x42000800, 0x00000001, 0x59325808, + 0x832c0500, 0x00ff0000, 0x0400000d, 0x592c0000, + 0x48065a06, 0x48026008, 0x592c040a, 0x8c000510, + 0x04020008, 0x0201f800, 0x000202ce, 0x417a7800, + 0x59300008, 0x80025d40, 0x0402078f, 0x1c01f000, + 0x456a5800, 0x412ed000, 0x815eb800, 0x59c80000, + 0x82000540, 0x00001200, 0x48039000, 0x0401f7f4, + 0x59840000, 0x80000540, 0x04020002, 0x1c01f000, + 0x59840003, 0x80000540, 0x02020000, 0x001061fe, + 0x1c01f000, 0x48066004, 0x59bc00ea, 0x8c000516, + 0x040207fe, 0x83300400, 0x40000000, 0x480378e1, + 0x1c01f000, 0x59bc00ea, 0x82001500, 0xb0000018, + 0x02020000, 0x00106c81, 0x8c000510, 0x0400002a, + 0x59bc10e0, 0x82080500, 0xfffff000, 0x0402000a, + 0x80080108, 0x820a3500, 0x0000000f, 0x4803c857, + 0x1201f000, 0x00106c87, 0x84000510, 0x48026004, + 0x0401f016, 0x840a653e, 0x59300004, 0x8c000520, + 0x040007fa, 0x82000500, 0xfffefeff, 0x48026004, + 0x8c08153e, 0x04020005, 0x42027000, 0x00000013, + 0x0401f859, 0x0401f009, 0x59300004, 0x8c000514, + 0x04000003, 0x0401ffb0, 0x0401f02f, 0x42027000, + 0x00000049, 0x0401f850, 0x59bc00ea, 0x82001500, + 0xb0000018, 0x02020000, 0x00106c81, 0x8c000510, + 0x040207d8, 0x1c01f000, 0x83640480, 0x00000010, + 0x0400101a, 0x41626000, 0x41580000, 0x59300a03, + 0x82040d80, 0x00000000, 0x04000008, 0x83326400, + 0x00000024, 0x81300c80, 0x040017f9, 0x42026000, + 0x0010d1c0, 0x0401f7f6, 0x8166c840, 0x83300c00, + 0x00000024, 0x80040480, 0x04021005, 0x4006c000, + 0x4a026203, 0x00000008, 0x1c01f000, 0x837ac540, + 0x0010d1c0, 0x0401f7fb, 0x42000000, 0x0010b854, + 0x0201f800, 0x0010aa47, 0x4967c857, 0x80026580, + 0x1c01f000, 0x83300480, 0x0010d1c0, 0x02001800, + 0x001005d8, 0x41580000, 0x81300480, 0x0402100c, + 0x04011000, 0x457a6000, 0x4a026202, 0x0000ffff, + 0x83300400, 0x00000003, 0x4803c840, 0x4a03c842, + 0x00000021, 0x8166c800, 0x1c01f000, 0x41540000, + 0x81300480, 0x02021800, 0x001005d8, 0x04011000, + 0x457a6000, 0x4a026202, 0x0000ffff, 0x83300400, + 0x00000003, 0x4803c840, 0x4a03c842, 0x00000021, + 0x59a80066, 0x49335065, 0x80000000, 0x48035066, + 0x1c01f000, 0x4d340000, 0x59326809, 0x59300406, + 0x82000500, 0x0000001f, 0x0c01f803, 0x5c026800, + 0x1c01f000, 0x00107966, 0x00107979, 0x00107993, + 0x000207c9, 0x001098f1, 0x0010990c, 0x0002083e, + 0x00107966, 0x00107979, 0x001064ee, 0x001079ac, + 0x00107966, 0x00107966, 0x00107966, 0x00107966, + 0x00107966, 0x001095a1, 0x0010a6c2, 0x00107966, + 0x00107966, 0x00107966, 0x00107966, 0x00107966, + 0x00107966, 0x00107966, 0x00107966, 0x00107966, + 0x00107966, 0x00107966, 0x00107966, 0x00107966, + 0x00107966, 0x59300203, 0x82000c80, 0x0000000e, + 0x02021800, 0x001005d8, 0x0c01f001, 0x001079aa, + 0x00108592, 0x000207dd, 0x00108720, 0x001087b9, + 0x001079aa, 0x001079aa, 0x001079aa, 0x00108577, + 0x001079aa, 0x001079aa, 0x001079aa, 0x001079aa, + 0x00108985, 0x83380480, 0x00000058, 0x04021007, + 0x83380480, 0x00000040, 0x04001004, 0x4d2c0000, + 0x0c01f803, 0x5c025800, 0x1c01f000, 0x0010861b, + 0x0010861b, 0x0010861b, 0x0010861b, 0x0010861b, + 0x0010861d, 0x001086bd, 0x0010861b, 0x0010861b, + 0x0010861b, 0x0010861b, 0x0010861b, 0x0010861b, + 0x0010861b, 0x0010861b, 0x0010861b, 0x0010861b, + 0x0010861b, 0x0010861b, 0x001086c1, 0x000207ff, + 0x0010861b, 0x001086c0, 0x001086c2, 0x59325808, + 0x59300811, 0x59301402, 0x59340200, 0x8c00050e, + 0x0402001c, 0x0401f826, 0x04000005, 0x4a025a04, + 0x00000103, 0x497a5c09, 0x0401f009, 0x4a025a04, + 0x00000103, 0x4a025a06, 0x00000000, 0x497a5c09, + 0x800409c0, 0x02020800, 0x00108785, 0x48065807, + 0x480a5c06, 0x0201f800, 0x000202c1, 0x5934000f, + 0x5934140b, 0x80081040, 0x04001002, 0x480a6c0b, + 0x80000540, 0x02020800, 0x00020253, 0x0401f75e, + 0x592c020a, 0x8c000502, 0x040007e9, 0x800409c0, + 0x040007e7, 0x592c0208, 0x8c00050e, 0x040207e4, + 0x4933c857, 0x0201f000, 0x0010920f, 0x592c020a, + 0x8c000500, 0x04000010, 0x59300015, 0x592c380f, + 0x801c3c80, 0x0400000c, 0x4a025a06, 0x00000015, + 0x8c1c3d3e, 0x04000005, 0x4a025a06, 0x00000007, + 0x801c3880, 0x801c3800, 0x481fc857, 0x821c0d40, + 0x00000000, 0x1c01f000, 0x59300203, 0x82003480, + 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f001, + 0x0010992b, 0x00020852, 0x00109fba, 0x00109fc8, + 0x0002086e, 0x0010992b, 0x0010a0a8, 0x0002088d, + 0x0010992b, 0x0010992b, 0x0010992b, 0x0010992b, + 0x0010992b, 0x0010992b, 0x83380580, 0x00000013, + 0x02020000, 0x00109f42, 0x59300403, 0x82027480, + 0x00000044, 0x02021800, 0x001005d8, 0x82000480, + 0x00000040, 0x02001800, 0x001005d8, 0x0c01f001, + 0x00109f9e, 0x00020864, 0x00109fa0, 0x00109fb2, + 0x59325808, 0x832c0500, 0x00ff0000, 0x04000005, + 0x592c0c0a, 0x8c040d1a, 0x02020000, 0x00109fad, + 0x0401fe91, 0x0401f710, 0x83380580, 0x00000048, + 0x04000007, 0x83380580, 0x00000053, 0x02000000, + 0x0010a04a, 0x0201f800, 0x001005d8, 0x5930001f, + 0x59301011, 0x59300809, 0x58040a00, 0x8c040d0e, + 0x02020000, 0x0010a026, 0x800811c0, 0x02020000, + 0x0010a033, 0x5930001f, 0x80000540, 0x02020000, + 0x0010a041, 0x59325808, 0x592c040a, 0x8c00051e, + 0x02000000, 0x0010a01c, 0x42027000, 0x00000041, + 0x0401f001, 0x83380480, 0x00000054, 0x02021800, + 0x001005d8, 0x83380480, 0x00000040, 0x02001000, + 0x0010a067, 0x0c01f001, 0x0010a073, 0x000208aa, + 0x0010a07f, 0x0010a086, 0x0010a073, 0x0010a073, + 0x0010a073, 0x0010a073, 0x0010a075, 0x0010a07a, + 0x0010a07a, 0x0010a073, 0x0010a073, 0x0010a073, + 0x0010a073, 0x0010a07a, 0x0010a073, 0x0010a07a, + 0x0010a073, 0x0010a075, 0x4a026203, 0x00000001, + 0x493a6403, 0x42000800, 0x80002042, 0x0401f672, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x14aa62b1, + 0x00000000, 0x00000000, 0x00000000, 0x00000005, + 0xfffffffb, 0x02800004, 0x00000000, 0x0000c000, + 0x0000071d, 0x073fca5a, 0x0705a5a5, 0x01928009, + 0x070ff0e1, 0x03800006, 0x04958010, 0x05308000, + 0x05008000, 0x0600902f, 0x04a004dc, 0x0202f051, + 0x042e4020, 0x018f021b, 0x033e5000, 0x03020000, + 0x078d0018, 0x0493041a, 0x0092041c, 0x038a0305, + 0x078b0303, 0x048e8010, 0x0678aae5, 0x06000001, + 0x07818174, 0x040010e6, 0x0448e0e6, 0x04818010, + 0x002fb008, 0x0448e0e6, 0x04818010, 0x060ff0e6, + 0x00580401, 0x054880ff, 0x04818010, 0x022a5001, + 0x030430d4, 0x06780043, 0x030e0000, 0x030450ff, + 0x06780043, 0x03019000, 0x058185c6, 0x027c0045, + 0x03020000, 0x06810037, 0x027c0045, 0x03040000, + 0x068100c7, 0x027c0045, 0x03080000, 0x0781061e, + 0x04908037, 0x029105c4, 0x010410a6, 0x0379ff41, + 0x037fffff, 0x072d6000, 0x07601241, 0x050f80ff, + 0x032fa009, 0x05600400, 0x050f80ff, 0x056c04ff, + 0x068105dc, 0x073fa009, 0x06000001, 0x0279ff02, + 0x0700ffff, 0x070ff0d1, 0x0179feff, 0x0700ffff, + 0x045c0402, 0x048185dc, 0x060ff0d0, 0x0179feff, + 0x0700ffff, 0x057dfeff, 0x0700ffff, 0x078105be, + 0x05600e41, 0x050f80ff, 0x032fa069, 0x07480000, + 0x068105d0, 0x06780043, 0x070000f0, 0x0781005f, + 0x037c00ff, 0x06000010, 0x0781005f, 0x038005cc, + 0x0379ff00, 0x070fffff, 0x06780043, 0x07f00000, + 0x075a0000, 0x020ef001, 0x028605ce, 0x05484000, + 0x02a1819e, 0x062d6001, 0x002fb001, 0x070ff069, + 0x01868072, 0x060ff079, 0x055c0441, 0x06810010, + 0x012fb000, 0x060560fb, 0x03800078, 0x060ff079, + 0x02868198, 0x070ff069, 0x055c0441, 0x06810010, + 0x060560fb, 0x0400d0d0, 0x062d6002, 0x0648300d, + 0x06810086, 0x070ff0d1, 0x062d6001, 0x045c040b, + 0x06810089, 0x05488000, 0x04818086, 0x072e500c, + 0x00208001, 0x05a004e1, 0x02800010, 0x062d6001, + 0x07f00000, 0x07f00000, 0x070ff0d1, 0x0179feff, + 0x070000ff, 0x055c040c, 0x058180bb, 0x0007b001, + 0x03079041, 0x0307a000, 0x06600a79, 0x050f80ff, + 0x053fa80a, 0x06000010, 0x072d5003, 0x078d0096, + 0x0307c003, 0x0007d004, 0x0107e005, 0x0307f006, + 0x02080007, 0x00081008, 0x01082009, 0x0308300a, + 0x0008400b, 0x0308500c, 0x068d00a1, 0x0678007a, + 0x07f00000, 0x010880ff, 0x03386000, 0x03010000, + 0x072e6300, 0x020ef07f, 0x02860010, 0x070ff07d, + 0x0450047c, 0x050f80ff, 0x002fa819, 0x068d00ae, + 0x02080001, 0x00081002, 0x0448807a, 0x068100b5, + 0x0379ff03, 0x070000ff, 0x01082003, 0x068d00b6, + 0x02386004, 0x03010000, 0x072e6c00, 0x02800010, + 0x06780043, 0x070000f0, 0x078105d7, 0x050020ff, + 0x027c0002, 0x06000010, 0x078100c3, 0x038005d7, + 0x0700c0d1, 0x0379ff0c, 0x070000ff, 0x0380008e, + 0x0204a051, 0x06780043, 0x070000f0, 0x037c00ff, + 0x06000010, 0x0781816a, 0x072d6000, 0x019485c0, + 0x050fb056, 0x044880e6, 0x04818010, 0x060ff0d0, + 0x0179feff, 0x0700ffff, 0x057dfeff, 0x0700ffff, + 0x078105be, 0x05a00212, 0x0349c0e4, 0x0781811d, + 0x070ff093, 0x050010ff, 0x070ff093, 0x045c0401, + 0x058180db, 0x02046092, 0x04002046, 0x04600202, + 0x00540401, 0x048280e6, 0x04500425, 0x070060ff, + 0x0730ffff, 0x0700000f, 0x0742000f, 0x05810190, + 0x07a005a6, 0x0648a002, 0x048180e9, 0x00047089, + 0x070ff047, 0x045c0443, 0x077800ff, 0x07f00000, + 0x0781818e, 0x07780047, 0x0500e000, 0x048185ad, + 0x070ff006, 0x01860117, 0x0179fe47, 0x0700000f, + 0x010480ff, 0x056c7048, 0x06818102, 0x007a0d4a, + 0x04003801, 0x0220f001, 0x0180010f, 0x07608e48, + 0x034a60ff, 0x0700f0ff, 0x074b88ff, 0x037000ff, + 0x07000600, 0x05500448, 0x074d00ff, 0x045a044a, + 0x0304a0ff, 0x070ff00f, 0x01540406, 0x05820117, + 0x04950120, 0x05a001bd, 0x02868123, 0x0134bfff, + 0x070fffff, 0x0104102e, 0x050fd041, 0x00800126, + 0x0595011d, 0x05a001bd, 0x0186011d, 0x0202f00e, + 0x052e4030, 0x040fd02f, 0x070fc0ff, 0x05a00218, + 0x02800010, 0x0400e02f, 0x042e4020, 0x0202f051, + 0x0004100e, 0x0004b00e, 0x050fd041, 0x024a6c46, + 0x04500423, 0x050070ff, 0x03620024, 0x050080ff, + 0x04004046, 0x0700500f, 0x03206000, 0x05601048, + 0x0700a0ff, 0x0700900a, 0x070ff005, 0x04500446, + 0x00540425, 0x04820157, 0x05601622, 0x050f80ff, + 0x063fa032, 0x06000002, 0x03203000, 0x01204000, + 0x03205000, 0x0120b000, 0x0320c000, 0x07601441, + 0x050f80ff, 0x043fa852, 0x06000001, 0x070ff056, + 0x056c02ff, 0x050fb0ff, 0x070560ff, 0x03079041, + 0x05600e41, 0x050f80ff, 0x073fa011, 0x0600003d, + 0x06780043, 0x07f00000, 0x065a007a, 0x010880ff, + 0x04a001b6, 0x058d0150, 0x0208a04a, 0x0108b04b, + 0x02386001, 0x03010000, 0x072e6300, 0x028000a8, + 0x0500d00a, 0x05500405, 0x014a68ff, 0x070090ff, + 0x0154040a, 0x0700c0ff, 0x0600a023, 0x0500b024, + 0x02206001, 0x05601622, 0x050f80ff, 0x063fa04a, + 0x06000002, 0x05601022, 0x050f80ff, 0x043fa819, + 0x06000001, 0x0600a00d, 0x0180013c, 0x06780043, + 0x070000f0, 0x050010ff, 0x027c0001, 0x07000030, + 0x078105b4, 0x027c0001, 0x06000020, 0x078105b4, + 0x038005cc, 0x054880ff, 0x06810010, 0x070ff056, + 0x050fb0ff, 0x044880e5, 0x0581017d, 0x044880e6, + 0x04818010, 0x00800183, 0x056c02ff, 0x050fb0ff, + 0x070560ff, 0x072e5300, 0x044880e6, 0x04818010, + 0x072d5003, 0x06780043, 0x07f00000, 0x010880ff, + 0x058d0187, 0x03386005, 0x03010000, 0x033e6000, + 0x0700000c, 0x052e5200, 0x02800010, 0x0120918e, + 0x018004e4, 0x01209190, 0x018004e4, 0x00209192, + 0x018004e4, 0x03209000, 0x018004e4, 0x01209196, + 0x018004e4, 0x00209198, 0x018004e4, 0x02493075, + 0x06810510, 0x0120919a, 0x018004e4, 0x06601e01, + 0x050f80ff, 0x063fa029, 0x06000008, 0x02015010, + 0x02016051, 0x00017051, 0x00011051, 0x05601a41, + 0x050f80ff, 0x053fa83a, 0x06000008, 0x05600e41, + 0x050f80ff, 0x01464000, 0x032fa00a, 0x07006011, + 0x05007012, 0x04008013, 0x07009014, 0x0600a015, + 0x0400b016, 0x0700c017, 0x07c00000, 0x072d5003, + 0x06601479, 0x050f80ff, 0x048d01b9, 0x063fa051, + 0x0600003e, 0x07c00000, 0x06005051, 0x0400e02c, + 0x0660060e, 0x050f80ff, 0x032fa009, 0x0379ff00, + 0x070000ff, 0x076c0000, 0x058101dd, 0x0660480e, + 0x0500e0ff, 0x034000ff, 0x01540427, 0x0582020a, + 0x03400005, 0x070ff005, 0x055c0428, 0x0481020e, + 0x01680e05, 0x056c0405, 0x068181bf, 0x040f8029, + 0x053fa809, 0x07000024, 0x06600649, 0x050f80ff, + 0x032fa009, 0x0379ff00, 0x070000ff, 0x076c0000, + 0x068181bf, 0x0400e049, 0x0340002d, 0x050f802b, + 0x053fa80a, 0x06000016, 0x0660480e, 0x0302c0ff, + 0x034000ff, 0x01540427, 0x0582020c, 0x072d6000, + 0x0460040e, 0x050f80ff, 0x0104e0d1, 0x0379ff4e, + 0x0700ffff, 0x062d6002, 0x032fa009, 0x0004d0d0, + 0x074b004d, 0x07780000, 0x07ffff00, 0x055a044d, + 0x070000ff, 0x00201008, 0x04002051, 0x06003051, + 0x05304000, 0x07000060, 0x03205009, 0x07006022, + 0x0460040e, 0x050f80ff, 0x032fa03a, 0x06603c0e, + 0x050f80ff, 0x073fa00a, 0x07000027, 0x050010d1, + 0x0460320e, 0x050f80ff, 0x012fa80a, 0x060ff00e, + 0x055c042e, 0x04810210, 0x07c00000, 0x0400e026, + 0x008001cb, 0x0202c026, 0x008001e6, 0x0500e02e, + 0x008001e6, 0x0400e051, 0x01800209, 0x0349c0e4, + 0x04810215, 0x07c00000, 0x013e4000, 0x070c0000, + 0x07c00000, 0x013e4000, 0x03080000, 0x07c00000, + 0x009702f4, 0x022a5002, 0x0790821d, 0x00910291, + 0x030400a6, 0x0678aae5, 0x06000001, 0x00a1860e, + 0x06600c40, 0x050f80ff, 0x032fa021, 0x074b0000, + 0x076c0600, 0x07818293, 0x05600403, 0x050f80ff, + 0x073fa009, 0x06000002, 0x0279ff04, 0x0700ffff, + 0x010440d7, 0x0179fe44, 0x0700ffff, 0x045c0404, + 0x07818295, 0x0349f044, 0x0681829e, 0x02495001, + 0x06818297, 0x060ff079, 0x045c0440, 0x0781823c, + 0x0644f07a, 0x002fb008, 0x060ff079, 0x045c0440, + 0x07818241, 0x0644f07a, 0x002fb008, 0x0648f001, + 0x07818288, 0x04600e40, 0x050f80ff, 0x06480001, + 0x04810257, 0x0448e001, 0x04810273, 0x02460001, + 0x0644f001, 0x012fa80a, 0x04008040, 0x05a004ee, + 0x0286828c, 0x05a004d8, 0x062da001, 0x013e4000, + 0x06000080, 0x06930013, 0x02920013, 0x02800010, + 0x0644f001, 0x012fa80a, 0x020ef002, 0x00860275, + 0x04600840, 0x050f80ff, 0x053fa809, 0x06000002, + 0x05780105, 0x00800440, 0x017c0105, 0x05000400, + 0x06818275, 0x06601e02, 0x050f80ff, 0x053fa809, + 0x06000002, 0x04602a40, 0x050f80ff, 0x070ff005, + 0x053fa809, 0x06000002, 0x055c0405, 0x06818275, + 0x04008040, 0x0045e008, 0x05a004d8, 0x00800251, + 0x0644f001, 0x012fa80a, 0x050020d8, 0x04600440, + 0x050f80ff, 0x073fa00a, 0x06000001, 0x06480001, + 0x07818281, 0x05308000, 0x03040000, 0x06009040, + 0x04a004dc, 0x00800251, 0x06a0060e, 0x054b0800, + 0x056a0700, 0x06600c40, 0x050f80ff, 0x032fa00a, + 0x00800251, 0x013e4000, 0x06000080, 0x01209288, + 0x018004e4, 0x06009008, 0x05308000, 0x05004000, + 0x04a004dc, 0x00800251, 0x02209002, 0x008002e5, + 0x03209000, 0x008002e5, 0x02209004, 0x008002e5, + 0x04a002fd, 0x062da001, 0x05308000, 0x05002000, + 0x06009040, 0x04a004dc, 0x02800013, 0x013e4000, + 0x06000080, 0x02495001, 0x078182db, 0x04600840, + 0x050f80ff, 0x053fa809, 0x06000001, 0x0721f000, + 0x0349f003, 0x058102aa, 0x0245f01f, 0x06000002, + 0x018602db, 0x07601400, 0x050f80ff, 0x012fa809, + 0x06480001, 0x058102db, 0x06602440, 0x050f80ff, + 0x012fa809, 0x020ef001, 0x038682db, 0x019b02db, + 0x050020d8, 0x062da001, 0x06303002, 0x05000430, + 0x04600440, 0x050f80ff, 0x073fa012, 0x06000001, + 0x028f82bf, 0x050040d8, 0x062da001, 0x07601e00, + 0x050f80ff, 0x073fa009, 0x06000001, 0x060ff004, + 0x00540402, 0x048202d9, 0x06005051, 0x06006051, + 0x06602240, 0x050f80ff, 0x063fa01a, 0x06000002, + 0x06600a40, 0x050f80ff, 0x073fa00a, 0x07000003, + 0x060ff040, 0x045a041f, 0x010eb0ff, 0x06930013, + 0x02920013, 0x02800010, 0x04004002, 0x018002c9, + 0x04a002fd, 0x062da001, 0x05308000, 0x07005000, + 0x06009040, 0x04a004dc, 0x050080d8, 0x05a004e1, + 0x062da001, 0x02800013, 0x050fd009, 0x050fd041, + 0x013e4000, 0x06000080, 0x05308000, 0x03013000, + 0x04a004dc, 0x010440d7, 0x0349f044, 0x048102f2, + 0x062da001, 0x008f02f2, 0x03e00000, 0x062da001, + 0x02800013, 0x0249c0e5, 0x06810013, 0x062da001, + 0x07f00000, 0x07f00000, 0x033e5000, 0x070c0000, + 0x018f02f6, 0x03800011, 0x050020d8, 0x04600440, + 0x050f80ff, 0x073fa00a, 0x06000001, 0x07c00000, + 0x002fb001, 0x03800306, 0x012fb000, 0x03075087, + 0x068d0307, 0x03386000, 0x03020000, 0x04482075, + 0x06810352, 0x0648a0e6, 0x07810347, 0x0642007f, + 0x06810345, 0x0340007e, 0x060ff038, 0x0154047e, + 0x02d00334, 0x0560027d, 0x050f80ff, 0x032fa009, + 0x030ef000, 0x02860504, 0x0107d000, 0x05600800, + 0x050f80ff, 0x032fa009, 0x03681e00, 0x04500420, + 0x050f80ff, 0x073fa009, 0x0700003f, 0x03800311, + 0x070ff07d, 0x0450047c, 0x050f80ff, 0x002fa819, + 0x078d0327, 0x02080001, 0x00081002, 0x0448807a, + 0x0781032e, 0x0379ff03, 0x070000ff, 0x01082003, + 0x068d032f, 0x02386004, 0x03010000, 0x072e6c00, + 0x02800352, 0x0380033a, 0x0380033c, 0x0280033e, + 0x02800340, 0x03800342, 0x03800344, 0x0727c005, + 0x02800323, 0x0627c008, 0x02800323, 0x0627c00b, + 0x02800323, 0x0627c00e, 0x02800323, 0x0727c011, + 0x02800323, 0x03800314, 0x052e6800, 0x02800352, + 0x044880e6, 0x07810533, 0x052e6200, 0x070ff088, + 0x0179feff, 0x070fffff, 0x04818501, 0x060ff083, + 0x0086836d, 0x033e6000, 0x07000003, 0x068d0352, + 0x07286000, 0x07f00000, 0x078d0355, 0x038c0306, + 0x0648c0e6, 0x05818372, 0x0448e0e6, 0x0781036a, + 0x004920e6, 0x07810365, 0x07a0056f, 0x05001088, + 0x00700101, 0x03100000, 0x00088001, 0x033e6000, + 0x07000088, 0x03800560, 0x02386001, 0x07030000, + 0x033e6000, 0x06000008, 0x028003f1, 0x02799075, + 0x0500040f, 0x06810010, 0x06601479, 0x050080ff, + 0x06309052, 0x0600003e, 0x02800376, 0x06602279, + 0x050080ff, 0x05309812, 0x07000041, 0x0648007a, + 0x0781037e, 0x04488075, 0x0581837e, 0x040f8008, + 0x070fa009, 0x0049107a, 0x01a183f3, 0x00798075, + 0x06000507, 0x05818521, 0x0448b075, 0x06810385, + 0x02493075, 0x0681050e, 0x0249c0e6, 0x048183e0, + 0x0648c0e6, 0x0581839a, 0x068d0389, 0x02386001, + 0x07030000, 0x0049107a, 0x07810390, 0x020ef083, + 0x0386039a, 0x06483075, 0x068103ef, 0x0678007a, + 0x07000035, 0x03a184cf, 0x05308000, 0x07060000, + 0x06009079, 0x04a004dc, 0x028003ef, 0x0448807a, + 0x0681039e, 0x06483075, 0x058104f9, 0x0448d07a, + 0x068103a2, 0x06483075, 0x058104f9, 0x068d03a2, + 0x02386001, 0x07030000, 0x0444e07a, 0x0648307a, + 0x048183c7, 0x0448707a, 0x068103ea, 0x0648f07a, + 0x078103b2, 0x05a004cf, 0x04008079, 0x05a004ee, + 0x008683c2, 0x05a004d8, 0x028003ef, 0x0560107b, + 0x050f80ff, 0x032fa009, 0x0349c000, 0x058183c0, + 0x04600e79, 0x050f80ff, 0x073fa00a, 0x0600003d, + 0x06600a79, 0x050f80ff, 0x053fa80a, 0x06000010, + 0x028003ef, 0x0046e07a, 0x028003ea, 0x06009008, + 0x05308000, 0x05004000, 0x04a004dc, 0x028003ef, + 0x0560167b, 0x050f80ff, 0x032fa011, 0x070ff000, + 0x04500401, 0x030460ff, 0x060ff025, 0x00540446, + 0x078203d1, 0x030460ff, 0x04092046, 0x05a00218, + 0x06600679, 0x050f80ff, 0x00201007, 0x012fa80a, + 0x0046047a, 0x034630ff, 0x050020ff, 0x06003051, + 0x04600e79, 0x050f80ff, 0x073fa012, 0x06000001, + 0x028003ef, 0x033e6a00, 0x0202000e, 0x02079051, + 0x07000088, 0x078d03e4, 0x0744c000, 0x01088000, + 0x03386006, 0x03010000, 0x02800010, 0x05a004cf, + 0x05308000, 0x03020000, 0x06009079, 0x04a004dc, + 0x033e6a00, 0x0302000a, 0x02079051, 0x02800010, + 0x04603e79, 0x050f80ff, 0x032fa009, 0x070ff000, + 0x0186040c, 0x057dfeff, 0x07ffffff, 0x0581040c, + 0x050f8000, 0x012fa811, 0x0079fe02, 0x070000ff, + 0x077d66ff, 0x060000dc, 0x0781840c, 0x060ff001, + 0x0286840d, 0x064b0002, 0x06420002, 0x060ff002, + 0x05500400, 0x050f80ff, 0x05004084, 0x073fa00a, + 0x06000002, 0x07c00000, 0x04600201, 0x050f80ff, + 0x073fa009, 0x06000001, 0x0079fe02, 0x070000ff, + 0x077d72ff, 0x070000dd, 0x0781840c, 0x064b0002, + 0x06420002, 0x06000001, 0x01800406, 0x0605004c, + 0x0180041e, 0x0493041a, 0x04a004d5, 0x054bc450, + 0x05810421, 0x01d00422, 0x01800421, 0x00800432, + 0x00800434, 0x00800432, 0x008004a7, 0x0180043f, + 0x00800434, 0x01800471, 0x00800432, 0x00800432, + 0x008004ab, 0x00800432, 0x018004af, 0x008004c4, + 0x01800488, 0x00800432, 0x00800432, 0x00209432, + 0x018004e4, 0x0379ff50, 0x070fffff, 0x060ff079, + 0x055c0450, 0x048104a4, 0x002fb008, 0x060ff079, + 0x055c0450, 0x058104a3, 0x04a004c7, 0x0180049c, + 0x0179fe50, 0x070fffff, 0x070050ff, 0x060ff079, + 0x055c0405, 0x04810449, 0x002fb008, 0x060ff079, + 0x055c0405, 0x078184a0, 0x070ff087, 0x017980ff, + 0x06000507, 0x06818451, 0x02203040, 0x05002087, + 0x0049d002, 0x0481046b, 0x04930458, 0x01257000, + 0x073c3fff, 0x0700000f, 0x052e4003, 0x072e5030, + 0x0304c050, 0x02400057, 0x06740057, 0x06000002, + 0x06820016, 0x04002083, 0x07003084, 0x04004085, + 0x06602279, 0x050f80ff, 0x063fa01a, 0x06000001, + 0x05a004cf, 0x07a00578, 0x033e6a00, 0x0302000a, + 0x062e5020, 0x003e4002, 0x07000a00, 0x028003f1, + 0x07420003, 0x0781844e, 0x00798002, 0x06000507, + 0x06818451, 0x0180045c, 0x05930478, 0x01257000, + 0x073c3fff, 0x0700000f, 0x052e4003, 0x072e5030, + 0x0304c050, 0x067800e6, 0x07000041, 0x0581047d, + 0x07a00581, 0x04818016, 0x002fb008, 0x067800e6, + 0x07000041, 0x04810483, 0x07a00581, 0x04818016, + 0x062e5020, 0x003e4002, 0x07000a00, 0x03e00000, + 0x02800010, 0x0379ff50, 0x070fffff, 0x060ff079, + 0x055c0450, 0x0781848e, 0x0245507a, 0x002fb008, + 0x060ff079, 0x055c0450, 0x07818493, 0x0245507a, + 0x002fb008, 0x05600e50, 0x050f80ff, 0x012fa809, + 0x02455001, 0x05600e50, 0x050f80ff, 0x012fa80a, + 0x0080049d, 0x002fb008, 0x003e4002, 0x07000a00, + 0x02800016, 0x079384a3, 0x062e5020, 0x042e4002, + 0x002fb008, 0x013e4000, 0x05000e00, 0x02800016, + 0x0179fe50, 0x070fffff, 0x010210ff, 0x02800016, + 0x0179fe50, 0x070fffff, 0x050340ff, 0x0080049d, + 0x0179fe50, 0x070fffff, 0x0102e0ff, 0x0760282e, + 0x050f80ff, 0x05222000, 0x07223000, 0x05224000, + 0x07225000, 0x07226000, 0x05227000, 0x05228000, + 0x07229000, 0x0722a000, 0x0522b000, 0x063fa051, + 0x07000011, 0x0202c026, 0x0522d000, 0x052e400c, + 0x02800016, 0x030430d4, 0x062e5008, 0x00800176, + 0x05600e50, 0x050f80ff, 0x032fa009, 0x03460000, + 0x018004d2, 0x0246007a, 0x0045207a, 0x008004d0, + 0x0246007a, 0x0600007a, 0x04600e79, 0x050f80ff, + 0x032fa00a, 0x07c00000, 0x029284d5, 0x070500e1, + 0x07c00000, 0x0245f008, 0x048404d9, 0x020e0008, + 0x07c00000, 0x070ff009, 0x065a0008, 0x058404de, + 0x020e0008, 0x07c00000, 0x058404e1, 0x020e0008, + 0x07c00000, 0x05308000, 0x0500d000, 0x04a004dc, + 0x04a004e9, 0x02800010, 0x052e4300, 0x072e500c, + 0x073c3fff, 0x0700000f, 0x07c00000, 0x06602208, + 0x050f80ff, 0x032fa011, 0x076a0000, 0x068184f7, + 0x066a0001, 0x048104f7, 0x04002051, 0x07c00000, + 0x00202001, 0x07c00000, 0x0648307a, 0x00a18608, + 0x05a004cc, 0x05308000, 0x05001000, 0x06009079, + 0x04a004dc, 0x03800560, 0x0249c0e6, 0x058104f9, + 0x0280036d, 0x0648307a, 0x07818196, 0x05a004cf, + 0x05308000, 0x03013000, 0x03209006, 0x04a004dc, + 0x033e6000, 0x07030000, 0x02800345, 0x02490075, + 0x0781051e, 0x04002089, 0x04780102, 0x07f00000, + 0x05001088, 0x07a0056f, 0x04740101, 0x03100000, + 0x060ff002, 0x045c0401, 0x0481851f, 0x00088001, + 0x033e6000, 0x070000c0, 0x0380055c, 0x07f00000, + 0x0220951f, 0x018004e4, 0x0648307a, 0x07810527, + 0x06780075, 0x06000007, 0x0581852e, 0x06a00608, + 0x06486075, 0x06818194, 0x02490075, 0x0781819a, + 0x04487075, 0x05818536, 0x0280053d, 0x05308000, + 0x03010000, 0x06009079, 0x04a004dc, 0x02800010, + 0x0448e0e6, 0x04818352, 0x00800192, 0x05308000, + 0x0500e000, 0x06009079, 0x04a004dc, 0x04008089, + 0x05a004e1, 0x0380055c, 0x05a004cc, 0x05308000, + 0x0700f000, 0x06009079, 0x07000088, 0x06a00545, + 0x04a004dc, 0x02800010, 0x03386000, 0x07030000, + 0x07f00000, 0x078d0548, 0x033e6a00, 0x0202000e, + 0x02079051, 0x0448b075, 0x07810553, 0x02493075, + 0x07810553, 0x05301005, 0x03010000, 0x03800555, + 0x05301006, 0x03010000, 0x05002087, 0x06485002, + 0x05818555, 0x0744c000, 0x01088000, 0x02086001, + 0x07c00000, 0x05001088, 0x07a0056f, 0x0644c001, + 0x00088001, 0x033e6a00, 0x0202000e, 0x004920e6, + 0x05818565, 0x02079051, 0x078d0565, 0x060ff089, + 0x034990ff, 0x0781056c, 0x03386005, 0x03010000, + 0x02800010, 0x03386006, 0x03010000, 0x02800010, + 0x078d056f, 0x03386000, 0x07030000, 0x07f00000, + 0x068d0573, 0x070ff087, 0x074850ff, 0x05818574, + 0x07c00000, 0x078d0578, 0x02386001, 0x07030000, + 0x07f00000, 0x068d057c, 0x070ff087, 0x074850ff, + 0x0581857d, 0x07c00000, 0x05002087, 0x0049d002, + 0x05818590, 0x002fb008, 0x067800e6, 0x07000041, + 0x002fb008, 0x05818590, 0x07a005a6, 0x0448e002, + 0x07810593, 0x0648a002, 0x0481859d, 0x06486002, + 0x06810597, 0x02400057, 0x056a02ff, 0x07c00000, + 0x07a005a6, 0x06788102, 0x06000004, 0x05818590, + 0x04002089, 0x070ff0d4, 0x045c0402, 0x077800ff, + 0x07f00000, 0x05818590, 0x00202010, 0x038c0590, + 0x07f00000, 0x06420002, 0x0481859e, 0x07a00578, + 0x033e6a00, 0x0302000a, 0x07c00000, 0x07f00000, + 0x060ff0a2, 0x050020ff, 0x060ff0a2, 0x045c0402, + 0x048185a7, 0x07c00000, 0x05a00218, 0x03495047, + 0x078105b2, 0x0320901d, 0x02800604, 0x0220901f, + 0x02800604, 0x014980e4, 0x04818010, 0x013e4000, + 0x07003000, 0x05600e35, 0x050f80ff, 0x07a006fc, + 0x01208003, 0x05a004e1, 0x038005cc, 0x03209009, + 0x02800604, 0x03209011, 0x02800604, 0x02209007, + 0x02800604, 0x03209003, 0x02800604, 0x00498043, + 0x058185be, 0x00497043, 0x048185c2, 0x02209001, + 0x02800604, 0x0220900d, 0x02800604, 0x0320900f, + 0x02800604, 0x03493000, 0x068105d5, 0x027c0045, + 0x070a0000, 0x078105de, 0x0220900b, 0x02800604, + 0x02209013, 0x05308000, 0x01012000, 0x04a004dc, + 0x00800183, 0x03209005, 0x02800604, 0x072e500c, + 0x00208002, 0x05a004e1, 0x02800010, 0x02209015, + 0x02800604, 0x072d6000, 0x05308000, 0x05007000, + 0x07f00000, 0x070090d1, 0x0379ff09, 0x0700ffff, + 0x04a004dc, 0x03209017, 0x02800604, 0x033e5000, + 0x06000080, 0x02209019, 0x02800604, 0x072d6000, + 0x033e5000, 0x06000080, 0x07f00000, 0x060ff0d0, + 0x0179feff, 0x0700ffff, 0x057dfeff, 0x0700ffff, + 0x04818010, 0x02400058, 0x00642058, 0x06820010, + 0x033e5000, 0x06000080, 0x04058051, 0x0320901b, + 0x02800604, 0x05308000, 0x01012000, 0x04a004dc, + 0x00800176, 0x05a00218, 0x05308000, 0x05008000, + 0x06009079, 0x04a004dc, 0x07c00000, 0x034900e4, + 0x05818618, 0x013e4000, 0x070000c0, 0x07f00000, + 0x034900e4, 0x04818616, 0x07c00000, 0x013e4000, + 0x06000080, 0x07f00000, 0x07f00000, 0x07f00000, + 0x034900e4, 0x06810610, 0x03800618, 0x072d6000, + 0x00498043, 0x06810632, 0x060ff0d0, 0x0179feff, + 0x0700ffff, 0x057dfeff, 0x0700ffff, 0x058185e2, + 0x050f8030, 0x032fa009, 0x0379ff00, 0x0700ffff, + 0x070ff0d1, 0x0179feff, 0x0700ffff, 0x055c0400, + 0x078105e2, 0x04004051, 0x0280067a, 0x06a006dc, + 0x062d6001, 0x020ef004, 0x038605e4, 0x06600004, + 0x050f80ff, 0x032fa009, 0x074b0000, 0x05002000, + 0x0769ff00, 0x01640800, 0x078205e4, 0x01640e00, + 0x058285e4, 0x070ff036, 0x045c0404, 0x0581864d, + 0x072d6000, 0x050f8030, 0x032fa009, 0x0379ff00, + 0x0700ffff, 0x070ff0d1, 0x0179feff, 0x0700ffff, + 0x055c0400, 0x078105e2, 0x04482034, 0x078105ff, + 0x06483034, 0x058185ff, 0x070ff0d4, 0x077800ff, + 0x070000f0, 0x037c00ff, 0x06000010, 0x0681067a, + 0x06a006d6, 0x024900e5, 0x0681065d, 0x033e5000, + 0x06000080, 0x02800010, 0x04601c04, 0x050f80ff, + 0x053fa809, 0x06000020, 0x030ef041, 0x038605ee, + 0x062d6002, 0x05602a41, 0x050f80ff, 0x012fa809, + 0x060ff0d0, 0x074b00ff, 0x045c0401, 0x05818678, + 0x062d6001, 0x07602841, 0x050f80ff, 0x053fa809, + 0x06000001, 0x070ff0d1, 0x054b80ff, 0x074b0003, + 0x055c0403, 0x05818678, 0x033e5000, 0x06000080, + 0x0080070e, 0x07600041, 0x0280065e, 0x06a006d6, + 0x024900e5, 0x06810680, 0x033e5000, 0x06000080, + 0x02800010, 0x06a006c2, 0x030ef041, 0x028605f2, + 0x04058051, 0x072d6000, 0x05601041, 0x050f80ff, + 0x012fa809, 0x0600a0d0, 0x0500b0d1, 0x062d6001, + 0x07f00000, 0x07f00000, 0x0600c0d0, 0x0500d0d1, + 0x062d6002, 0x0279ff0d, 0x07ff0000, 0x044d800d, + 0x060ff0d0, 0x074b00ff, 0x065a000d, 0x06601201, + 0x050f80ff, 0x073fa022, 0x07000005, 0x0079fe0d, + 0x070000ff, 0x050020ff, 0x05602a41, 0x050f80ff, + 0x073fa00a, 0x06000001, 0x020ef004, 0x028606bf, + 0x04601c04, 0x050f80ff, 0x053fa809, 0x06000001, + 0x050f80ff, 0x053fa80a, 0x06000020, 0x07602841, + 0x050f80ff, 0x073fa009, 0x06000001, 0x0279ff02, + 0x070000ff, 0x0678000d, 0x0700ff00, 0x065a0002, + 0x07602841, 0x050f80ff, 0x073fa00a, 0x06000001, + 0x07600041, 0x050f80ff, 0x053fa80a, 0x06000001, + 0x07601241, 0x050f80ff, 0x073fa00a, 0x06000002, + 0x033e5000, 0x06000080, 0x0080070e, 0x040f8032, + 0x073fa011, 0x06000001, 0x060ff002, 0x055c0403, + 0x058186ca, 0x00041051, 0x07c00000, 0x04600402, + 0x04500432, 0x050f80ff, 0x053fa809, 0x06000020, + 0x00400402, 0x01680eff, 0x070030ff, 0x040f8032, + 0x053fa80a, 0x06000001, 0x07c00000, 0x024900e5, + 0x068106d9, 0x07c00000, 0x033e5000, 0x070000c0, + 0x07c00000, 0x05004036, 0x060000d0, 0x0179fe00, + 0x0700ffff, 0x057dfeff, 0x0700ffff, 0x068106fb, + 0x070000d1, 0x0379ff00, 0x0700ffff, 0x06005051, + 0x060ff031, 0x05500405, 0x050f80ff, 0x073fa009, + 0x06000002, 0x020ef004, 0x038606f5, 0x04600404, + 0x050f80ff, 0x012fa809, 0x0079fe01, 0x0700ffff, + 0x055c0400, 0x068106fb, 0x01400405, 0x070050ff, + 0x057de0ff, 0x06000007, 0x058186e7, 0x04004051, + 0x07c00000, 0x072d6000, 0x07f00000, 0x07f00000, + 0x000110d0, 0x010120d1, 0x062d6001, 0x07f00000, + 0x07f00000, 0x020130d0, 0x010140d1, 0x062d6002, + 0x010170d4, 0x07f00000, 0x020150d0, 0x030160d1, + 0x053fa83a, 0x06000008, 0x07c00000, 0x07600c41, + 0x050f80ff, 0x073fa009, 0x06000001, 0x04780102, + 0x07ffff00, 0x046a0702, 0x050f80ff, 0x073fa00a, + 0x06000001, 0x05600e41, 0x050f80ff, 0x032fa069, + 0x03800053, 0xba6b4e34, 0x02800004, 0x00000000, + 0x00008000, 0x00000518, 0x040f801f, 0x012fa8c9, + 0x040f801f, 0x073fa081, 0x06000010, 0x03200005, + 0x07420000, 0x050fb000, 0x040f801f, 0x073fa011, + 0x06000038, 0x040f801f, 0x053fa859, 0x0700003a, + 0x050fe000, 0x0581800a, 0x0684003d, 0x04958019, + 0x030e0011, 0x072e4200, 0x03800014, 0x0291001f, + 0x050010c0, 0x04482001, 0x058180e8, 0x06483001, + 0x0781814b, 0x02920029, 0x068b0029, 0x018a0150, + 0x050010c0, 0x06780001, 0x050007c0, 0x06818223, + 0x06780001, 0x0500f800, 0x07818263, 0x03910030, + 0x040fe029, 0x03860030, 0x076c001d, 0x04810294, + 0x076c0a1d, 0x048102b9, 0x0292003d, 0x040fe02f, + 0x0286003d, 0x06000013, 0x050fb000, 0x066c0073, + 0x068103c2, 0x0297003d, 0x014920e4, 0x0481803d, + 0x03400000, 0x076c0a00, 0x04818034, 0x0796003f, + 0x03b900b8, 0x05908014, 0x010170e1, 0x07780017, + 0x03e00000, 0x06810092, 0x050010ff, 0x0179fe17, + 0x031fffff, 0x070000ff, 0x05600800, 0x050f80ff, + 0x073fa009, 0x06000001, 0x06780002, 0x02800040, + 0x037c00ff, 0x03800000, 0x0681005e, 0x0249f002, + 0x068100ab, 0x0448e002, 0x0681005e, 0x07600c00, + 0x050f80ff, 0x073fa009, 0x06000001, 0x06780002, + 0x07ffff00, 0x037c00ff, 0x05000200, 0x048180ab, + 0x064bd401, 0x03d00060, 0x038000a9, 0x02800068, + 0x03800072, 0x0280007c, 0x02800086, 0x03800090, + 0x038000a9, 0x038000a9, 0x050fe027, 0x0186806c, + 0x01028000, 0x0380006f, 0x07600027, 0x050f80ff, + 0x032fa00a, 0x01027000, 0x02400029, 0x028000ab, + 0x040fe025, 0x00868076, 0x03026000, 0x02800079, + 0x06600025, 0x050f80ff, 0x032fa00a, 0x03025000, + 0x02400029, 0x028000ab, 0x050fe021, 0x00868080, + 0x01022000, 0x02800083, 0x07600021, 0x050f80ff, + 0x032fa00a, 0x01021000, 0x02400029, 0x028000ab, + 0x040fe023, 0x0086808a, 0x01024000, 0x0380008d, + 0x06600023, 0x050f80ff, 0x032fa00a, 0x03023000, + 0x02400029, 0x028000ab, 0x06a000c8, 0x028000ab, + 0x01640817, 0x058280a9, 0x070ff017, 0x03d00096, + 0x0280009e, 0x038000a0, 0x038000a3, 0x038000a6, + 0x038000a9, 0x038000a9, 0x038000a9, 0x038000a9, + 0x03e00000, 0x03800014, 0x059080a0, 0x030160e1, + 0x028000ab, 0x059080a3, 0x030150e1, 0x028000ab, + 0x059080a6, 0x010140e1, 0x028000ab, 0x060fc013, + 0x06a00510, 0x03800014, 0x072e4800, 0x07000012, + 0x038000bb, 0x0747f000, 0x05600800, 0x050f80ff, + 0x012fa809, 0x0249f001, 0x078100bb, 0x01012000, + 0x052e4c00, 0x07c00000, 0x070000eb, 0x0349f000, + 0x058180af, 0x05600800, 0x050f80ff, 0x012fa809, + 0x0448e001, 0x068100c1, 0x07c00000, 0x0079c101, + 0x07ffffff, 0x027a4b01, 0x03800000, 0x05600800, + 0x050f80ff, 0x012fa80a, 0x07600c00, 0x050f80ff, + 0x012fa821, 0x06780001, 0x07ffff00, 0x037c00ff, + 0x05000700, 0x078100dd, 0x06601804, 0x070030ff, + 0x050f80ff, 0x012fa809, 0x05002000, 0x050f8003, + 0x073fa00a, 0x06000001, 0x040fe001, 0x038600de, + 0x04600201, 0x050f80ff, 0x032fa00a, 0x07c00000, + 0x050fe02e, 0x008680e3, 0x0102e000, 0x0302f000, + 0x038000e7, 0x0760002e, 0x050f80ff, 0x032fa00a, + 0x0102e000, 0x07c00000, 0x022c0004, 0x056c041d, + 0x078100fc, 0x056c021d, 0x04810113, 0x056c081d, + 0x04810125, 0x076c061d, 0x0581013f, 0x0521d000, + 0x0202c013, 0x0202a013, 0x02020013, 0x0460021a, + 0x050f80ff, 0x053fa80a, 0x07000009, 0x03b600ac, + 0x0484801f, 0x0280003d, 0x040fe02a, 0x028600f2, + 0x06000013, 0x04001013, 0x0560102b, 0x050f80ff, + 0x032fa012, 0x06420029, 0x0660002a, 0x050f80ff, + 0x053fa809, 0x06000001, 0x050fe003, 0x00860110, + 0x01028003, 0x0660002a, 0x050f80ff, 0x053fa80a, + 0x07000009, 0x00800140, 0x00028013, 0x00027013, + 0x00800140, 0x040fe02a, 0x028600f1, 0x06420029, + 0x0660002a, 0x050f80ff, 0x053fa809, 0x06000001, + 0x050fe003, 0x01860122, 0x03026003, 0x0660002a, + 0x050f80ff, 0x053fa80a, 0x07000009, 0x00800140, + 0x02026013, 0x02025013, 0x00800140, 0x040fe02a, + 0x028600f1, 0x06420029, 0x0660002a, 0x050f80ff, + 0x053fa809, 0x06000001, 0x050fe003, 0x00860134, + 0x01022003, 0x0660002a, 0x050f80ff, 0x053fa80a, + 0x07000009, 0x01800136, 0x00022013, 0x00021013, + 0x0647f020, 0x007a0120, 0x04000101, 0x04a00285, + 0x0400802a, 0x05a004f5, 0x009480f1, 0x0521d005, + 0x028000f2, 0x038000fa, 0x0647f020, 0x06486020, + 0x06818145, 0x04a00285, 0x028000f1, 0x007a0120, + 0x04000101, 0x04a00285, 0x0400802a, 0x05a004f5, + 0x028000f1, 0x040fd02a, 0x052e4003, 0x00208010, + 0x05a004f5, 0x038000fa, 0x00018098, 0x07480018, + 0x06818161, 0x05481018, 0x0781815f, 0x05482018, + 0x0681815d, 0x07483018, 0x0681815b, 0x002fb004, + 0x00800162, 0x012fb003, 0x00800162, 0x002fb002, + 0x00800162, 0x002fb001, 0x00800162, 0x012fb000, + 0x0179fe78, 0x070000ff, 0x030190ff, 0x00017086, + 0x058b0166, 0x03385000, 0x03020000, 0x07780017, + 0x00430407, 0x078181ee, 0x046c0419, 0x048101a2, + 0x046c0219, 0x05810172, 0x07219000, 0x00800186, + 0x07219000, 0x07483017, 0x0481018c, 0x05482017, + 0x05810193, 0x0448b075, 0x06818186, 0x06601476, + 0x050f80ff, 0x073fa022, 0x0600003e, 0x06000080, + 0x05001081, 0x05002082, 0x06003083, 0x05004084, + 0x04601c76, 0x050f80ff, 0x022fa02a, 0x07219000, + 0x07780078, 0x07ffff00, 0x045a0419, 0x010780ff, + 0x0484801f, 0x0280003d, 0x040fe07f, 0x0086019b, + 0x05a001bb, 0x00920186, 0x040fe07f, 0x07a681bb, + 0x00800186, 0x0560107b, 0x050f80ff, 0x032fa009, + 0x0744f000, 0x0560107b, 0x050f80ff, 0x032fa00a, + 0x00800179, 0x052e400c, 0x040080fb, 0x046aa108, + 0x06009076, 0x04002075, 0x05a004fc, 0x00800186, + 0x06219001, 0x05482017, 0x058101af, 0x058b01a5, + 0x060ff086, 0x0349f0ff, 0x07818165, 0x07483017, + 0x058101ac, 0x050fd0ff, 0x040fe07f, 0x07a681bb, + 0x00800186, 0x05004084, 0x05a00205, 0x00920186, + 0x070ff07d, 0x0450047c, 0x056004ff, 0x050f80ff, + 0x032fa009, 0x070ff000, 0x00540479, 0x030790ff, + 0x01800193, 0x060ff079, 0x0054047a, 0x058201e7, + 0x058101e7, 0x070ff07d, 0x0450047c, 0x050f80ff, + 0x002fa819, 0x058b01c3, 0x02080001, 0x00081002, + 0x01082003, 0x048b01c7, 0x03385000, 0x03010000, + 0x02400019, 0x070ff003, 0x04500479, 0x030790ff, + 0x0340007e, 0x0642007f, 0x058101e7, 0x070ff07e, + 0x050f80ff, 0x032fa009, 0x050fe000, 0x028681e6, + 0x070ff07d, 0x056002ff, 0x050f80ff, 0x032fa009, + 0x0107d000, 0x018601e8, 0x0560087d, 0x050f80ff, + 0x032fa009, 0x0569fe00, 0x0550041b, 0x050f80ff, + 0x032fa009, 0x0107e000, 0x070ff07e, 0x018001d2, + 0x0307c000, 0x07c00000, 0x052e400c, 0x040080fb, + 0x046aa108, 0x06009076, 0x04002075, 0x018004fc, + 0x040fd076, 0x050fd017, 0x060ff086, 0x077800ff, + 0x07000060, 0x037c00ff, 0x07000060, 0x078181f0, + 0x07780078, 0x07ffff00, 0x045a0419, 0x010780ff, + 0x06601476, 0x050f80ff, 0x073fa022, 0x0600003e, + 0x052e400c, 0x040080fb, 0x066a8108, 0x06009076, + 0x04002075, 0x05a004fc, 0x02800029, 0x0240007f, + 0x0742007e, 0x050f807e, 0x032fa009, 0x050fe000, + 0x0286821f, 0x070ff07d, 0x055c047b, 0x05810214, + 0x0760007d, 0x050f80ff, 0x032fa009, 0x050fe000, + 0x03868214, 0x070ff07b, 0x0107d0ff, 0x0560087d, + 0x050f80ff, 0x032fa009, 0x03681e00, 0x0450041c, + 0x0107e0ff, 0x050f80ff, 0x032fa009, 0x050fe000, + 0x01860221, 0x0307c000, 0x07c00000, 0x040fd076, + 0x02800510, 0x010180c0, 0x0548e018, 0x0781823c, + 0x0748f018, 0x06818238, 0x03490018, 0x06818234, + 0x01491018, 0x07818230, 0x073c0000, 0x06000040, + 0x02200004, 0x0180023f, 0x073c0000, 0x06000020, + 0x03200003, 0x0180023f, 0x073c0000, 0x06000010, + 0x02200002, 0x0180023f, 0x073c0000, 0x06000008, + 0x02200001, 0x0180023f, 0x073c0000, 0x06000004, + 0x06000013, 0x050fb000, 0x040fe076, 0x00860258, + 0x046c0273, 0x04810268, 0x066c0073, 0x04810249, + 0x040fd076, 0x06a00510, 0x03800014, 0x040fd076, + 0x0080024c, 0x00452075, 0x00077013, 0x0647f075, + 0x06486075, 0x06818252, 0x05a0028b, 0x00800258, + 0x007a0175, 0x04000101, 0x05a0028b, 0x04008076, + 0x0245f008, 0x05a004f5, 0x07273000, 0x05600272, + 0x050f80ff, 0x053fa80a, 0x07000009, 0x0379ff78, + 0x070000ff, 0x02076013, 0x02075013, 0x0484801f, + 0x0280003d, 0x070fc0ff, 0x052e400c, 0x00208020, + 0x05a004f5, 0x00800261, 0x04600276, 0x050010ff, + 0x040f8001, 0x032fa009, 0x040f8001, 0x053fa80a, + 0x07000009, 0x070ff000, 0x0286827a, 0x06601276, + 0x050f80ff, 0x073fa009, 0x0700000c, 0x07601818, + 0x050f80ff, 0x053fa80a, 0x07000009, 0x0180027b, + 0x07a000de, 0x0448b075, 0x0581024b, 0x06000013, + 0x04001013, 0x0560107b, 0x050f80ff, 0x032fa012, + 0x0046b075, 0x03b600ac, 0x0080024c, 0x06000020, + 0x04001016, 0x0460082a, 0x050f80ff, 0x032fa012, + 0x07c00000, 0x06000075, 0x040010a2, 0x044b0801, + 0x060ff016, 0x065a0001, 0x04600876, 0x050f80ff, + 0x032fa012, 0x07c00000, 0x050fe022, 0x0186029a, + 0x0421d004, 0x0302a022, 0x04a002c1, 0x018002b1, + 0x040fe026, 0x008602b3, 0x0421d001, 0x0202a026, + 0x04a002c1, 0x0202c013, 0x00683e20, 0x070060ff, + 0x056c0206, 0x048102f4, 0x056c0406, 0x0781030a, + 0x076c0606, 0x06810379, 0x056c1606, 0x078182b1, + 0x04488020, 0x07810387, 0x040fd02a, 0x0521d000, + 0x0202a013, 0x02020013, 0x008002b3, 0x04a004ec, + 0x008002bf, 0x050fe028, 0x008602bf, 0x0302a028, + 0x0421d002, 0x04a002c1, 0x008002c8, 0x050fe022, + 0x008602bf, 0x0421d004, 0x0302a022, 0x04a002c1, + 0x04a004ec, 0x05848030, 0x0280003d, 0x0460082a, + 0x050f80ff, 0x022fa031, 0x03020000, 0x0002b004, + 0x01018005, 0x07c00000, 0x0400702a, 0x06a003ba, + 0x007a0101, 0x07060000, 0x07303000, 0x07008290, + 0x07600018, 0x050f80ff, 0x053fa809, 0x07000003, + 0x0448e007, 0x068182d6, 0x06006013, 0x018002dd, + 0x02400010, 0x048102d6, 0x06006010, 0x0460322a, + 0x050f80ff, 0x073fa00a, 0x07000003, 0x050f801e, + 0x032fa03a, 0x063aa020, 0x06000002, 0x013e4000, + 0x07000030, 0x009802e3, 0x070ff0f6, 0x036830ff, + 0x078182e4, 0x070f001e, 0x0560102b, 0x050f10ff, + 0x063f3c08, 0x0600000d, 0x013e4000, 0x06000020, + 0x040f801a, 0x0320000a, 0x022017d0, 0x032fa012, + 0x0202c013, 0x008002bf, 0x04007013, 0x06a003ba, + 0x007a0101, 0x07050000, 0x07303000, 0x07008890, + 0x074d0005, 0x06006013, 0x050f801e, 0x032fa03a, + 0x05601a2b, 0x050f80ff, 0x022fa019, 0x04001002, + 0x04002013, 0x040f801f, 0x022fa01a, 0x073aa00c, + 0x06000002, 0x07300c03, 0x0600000d, 0x028003a7, + 0x04007013, 0x06a003ba, 0x007a0101, 0x03070000, + 0x0660282a, 0x050f80ff, 0x073fa009, 0x06000004, + 0x02499008, 0x07810317, 0x07303000, 0x07008890, + 0x02800319, 0x07303000, 0x04008980, 0x05007003, + 0x074d0005, 0x06006013, 0x050f801e, 0x032fa03a, + 0x0760142b, 0x050f80ff, 0x032fa021, 0x064b0002, + 0x02499008, 0x06810325, 0x0644c002, 0x054b0400, + 0x050040ff, 0x06698104, 0x0581833a, 0x06000013, + 0x04001013, 0x04780102, 0x06000010, 0x06003013, + 0x04004013, 0x06005013, 0x06006013, 0x04007013, + 0x00644015, 0x07820336, 0x04448002, 0x02205008, + 0x040f801f, 0x032fa042, 0x04008015, 0x03800371, + 0x046c8004, 0x05818348, 0x01208018, 0x06780002, + 0x07000003, 0x0581834b, 0x06003001, 0x06000013, + 0x04001013, 0x04004013, 0x06005013, 0x040f801f, + 0x022fa032, 0x03800371, 0x040fd02a, 0x06a00510, + 0x03800014, 0x04488002, 0x07810350, 0x070ff003, + 0x04500408, 0x050080ff, 0x06489002, 0x06810357, + 0x0379ff00, 0x070000ff, 0x070ff000, 0x04500408, + 0x050080ff, 0x07005003, 0x05004000, 0x06003001, + 0x06000013, 0x04001013, 0x040f801f, 0x022fa032, + 0x05601c2b, 0x050f80ff, 0x022fa031, 0x06600c1f, + 0x050f80ff, 0x022fa032, 0x02680608, 0x07810371, + 0x016408ff, 0x057dfeff, 0x07ffffff, 0x034000ff, + 0x045a0407, 0x070000ff, 0x0760061e, 0x050f80ff, + 0x032fa00a, 0x06600908, 0x0669f908, 0x027a0008, + 0x06000020, 0x070aa0ff, 0x014a20ff, 0x037a00ff, + 0x060000dc, 0x070000ff, 0x028003a7, 0x04007013, + 0x06a003ba, 0x007a0101, 0x07030000, 0x07303000, + 0x07008190, 0x06006013, 0x050f801e, 0x032fa03a, + 0x073aa000, 0x06000002, 0x07300c00, 0x07000005, + 0x028003a7, 0x04007013, 0x06a003ba, 0x007a0101, + 0x07810000, 0x07303000, 0x07000090, 0x06006013, + 0x06600c2a, 0x050f80ff, 0x053fa809, 0x07000003, + 0x04780107, 0x07ffff00, 0x007c0107, 0x07000500, + 0x0581839a, 0x07303000, 0x05000890, 0x074d0005, + 0x0660282a, 0x050f80ff, 0x053fa809, 0x07000003, + 0x0049d007, 0x068103a1, 0x02206001, 0x050f801e, + 0x032fa03a, 0x073aa000, 0x06000002, 0x07300c00, + 0x07000005, 0x013e4000, 0x07000030, 0x039803a9, + 0x070ff0f6, 0x036830ff, 0x058183aa, 0x070f001e, + 0x040f101f, 0x070f3000, 0x013e4000, 0x06000020, + 0x040f801a, 0x0320000a, 0x022017d0, 0x032fa012, + 0x008002bf, 0x03200000, 0x06006076, 0x028003bc, + 0x03200011, 0x0600602a, 0x05a00441, 0x05600406, + 0x050f80ff, 0x053fa809, 0x06000002, 0x07c00000, + 0x0207602f, 0x04600876, 0x050f80ff, 0x022fa031, + 0x03075000, 0x0007b004, 0x01018005, 0x06600076, + 0x050020ff, 0x050f80ff, 0x012fa809, 0x0202f001, + 0x008683d0, 0x0002e013, 0x040f8002, 0x053fa80a, + 0x07000009, 0x06273001, 0x0448b075, 0x048183da, + 0x04602076, 0x050f80ff, 0x053fa811, 0x0700003c, + 0x0179fe78, 0x070000ff, 0x030190ff, 0x018683e2, + 0x07a003f6, 0x00078019, 0x039203f5, 0x0180043a, + 0x040fd076, 0x040fd019, 0x04600276, 0x050020ff, + 0x050f80ff, 0x032fa009, 0x040f8002, 0x053fa80a, + 0x07000009, 0x050fe000, 0x008683f2, 0x07601818, + 0x050f80ff, 0x053fa80a, 0x07000009, 0x038003f3, + 0x07a000de, 0x07273000, 0x02076013, 0x0280003d, + 0x078b03f6, 0x03385000, 0x07030000, 0x05600818, + 0x050f80ff, 0x032fa009, 0x054b0400, 0x0308a0ff, + 0x0179fe00, 0x070000ff, 0x010880ff, 0x0448b075, + 0x04810410, 0x0760147b, 0x050f80ff, 0x002fa819, + 0x064b0001, 0x02080002, 0x01081003, 0x00082001, + 0x02083001, 0x02079001, 0x0207a001, 0x00084013, + 0x0207f013, 0x00800432, 0x06485075, 0x05810428, + 0x02465075, 0x06601476, 0x050f80ff, 0x073fa021, + 0x0600003e, 0x070ff07d, 0x0450047c, 0x050f80ff, + 0x002fa819, 0x058b041b, 0x02080001, 0x00081002, + 0x01082003, 0x03079003, 0x0208307a, 0x0340007e, + 0x0642007f, 0x0581042d, 0x070ff07e, 0x05a001d2, + 0x0392842d, 0x01800439, 0x058b0428, 0x06601476, + 0x050f80ff, 0x073fa041, 0x0600003e, 0x06602476, + 0x050f80ff, 0x073fa009, 0x06000007, 0x0008400e, + 0x048b0432, 0x03385000, 0x03010000, 0x06219001, + 0x040fe07f, 0x01860439, 0x018001bb, 0x07c00000, + 0x00683e75, 0x0581043f, 0x0448d075, 0x05810465, + 0x01800493, 0x05a004f0, 0x038003f5, 0x0297844c, + 0x07602418, 0x050f80ff, 0x012fa809, 0x06780001, + 0x070000ff, 0x075a0000, 0x070ff014, 0x0569feff, + 0x054b08ff, 0x075a0000, 0x05600418, 0x050f80ff, + 0x012fa809, 0x040fe007, 0x03868453, 0x01204000, + 0x00800461, 0x00700101, 0x03010000, 0x06780001, + 0x07ff0000, 0x076c00ff, 0x0681845b, 0x00700101, + 0x03010000, 0x05600418, 0x050f80ff, 0x012fa80a, + 0x06780001, 0x07ff0000, 0x050040ff, 0x0279ff01, + 0x0700ffff, 0x05002014, 0x07c00000, 0x04007076, + 0x0448b075, 0x0481047f, 0x03200011, 0x06006076, + 0x06a003bc, 0x007a0101, 0x07060000, 0x07303000, + 0x07008290, 0x07600018, 0x050f80ff, 0x053fa809, + 0x07000003, 0x0448e007, 0x07818477, 0x06006013, + 0x0180048e, 0x02400010, 0x05810477, 0x06006010, + 0x04603276, 0x050f80ff, 0x073fa00a, 0x07000003, + 0x0180048e, 0x04602a76, 0x050f80ff, 0x032fa009, + 0x060ff07a, 0x05500400, 0x070000ff, 0x04602a76, + 0x050f80ff, 0x032fa00a, 0x07a003b7, 0x007a0101, + 0x03010000, 0x06303008, 0x05008000, 0x0600600e, + 0x050f8074, 0x032fa03a, 0x053079a0, 0x0700000c, + 0x008004d3, 0x00683e75, 0x076c0aff, 0x058104b2, + 0x04007013, 0x03200011, 0x06006076, 0x06a003bc, + 0x007a0101, 0x03070000, 0x06602876, 0x050f80ff, + 0x053fa809, 0x06000001, 0x03499003, 0x048104a7, + 0x07303000, 0x07008890, 0x053079a0, 0x0700000c, + 0x008004ab, 0x07303000, 0x04008980, 0x04307920, + 0x0700000c, 0x074d0005, 0x06006013, 0x050f8074, + 0x032fa03a, 0x04307920, 0x0700000c, 0x008004d3, + 0x04602a76, 0x050f80ff, 0x032fa009, 0x060ff07a, + 0x05500400, 0x070000ff, 0x04602a76, 0x050f80ff, + 0x032fa00a, 0x04007076, 0x07a003b7, 0x007a0101, + 0x03010000, 0x06303008, 0x07008800, 0x074d0005, + 0x06600a76, 0x050f80ff, 0x073fa009, 0x07000003, + 0x054b0406, 0x045a0404, 0x050040ff, 0x0600600e, + 0x050f8074, 0x032fa03a, 0x0648c075, 0x058104d1, + 0x06307d20, 0x0700000c, 0x008004d3, 0x04307920, + 0x0700000c, 0x013e4000, 0x07000030, 0x009804d5, + 0x070ff0f6, 0x074850ff, 0x068184d6, 0x050f2074, + 0x060a0007, 0x040070fb, 0x046a7007, 0x050f40ff, + 0x013e4000, 0x06000020, 0x0678007a, 0x07fff000, + 0x068184e6, 0x0320000a, 0x022017d0, 0x008004e9, + 0x0320000a, 0x06301b58, 0x06000001, 0x050f8072, + 0x032fa012, 0x038003f5, 0x01208060, 0x0600902a, + 0x04002020, 0x018004fc, 0x040080fb, 0x066ae108, + 0x06009076, 0x04002075, 0x018004fc, 0x03201100, + 0x078484fa, 0x06420001, 0x078184f6, 0x02800513, + 0x020e0008, 0x07c00000, 0x050fd009, 0x040fd008, + 0x03201100, 0x05848503, 0x06420001, 0x078184ff, + 0x02800513, 0x007a0102, 0x04000101, 0x05600809, + 0x050f80ff, 0x073fa00a, 0x06000001, 0x020e0008, + 0x0684050d, 0x030e0009, 0x07c00000, 0x01011009, + 0x052e4300, 0x07c00000, 0x052e400f, 0x01208090, + 0x018004f5, 0x070fc0ff, 0x040f8013, 0x032fa009, + 0x02800516, 0x15416ea9, 0xffef0b01 +}; + +#ifdef UNIQUE_FW_NAME +uint32_t fw2400_length02 = 0x000014ff ; +#else +uint32_t risc_code_length02 = 0x000014ff ; +#endif + -- cgit v1.1 From dc25fcfbba513f8de8d1531b47fc9daa33d84f5a Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 10 Nov 2005 07:45:55 -0700 Subject: [SCSI] Mention scsi_scan_host() in scsi_mid_low_api.txt Update to mention scsi_scan_host() Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- Documentation/scsi/scsi_mid_low_api.txt | 37 +++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt index 66565d4..c4af92b 100644 --- a/Documentation/scsi/scsi_mid_low_api.txt +++ b/Documentation/scsi/scsi_mid_low_api.txt @@ -150,7 +150,8 @@ scsi devices of which only the first 2 respond: LLD mid level LLD ===-------------------=========--------------------===------ scsi_host_alloc() --> -scsi_add_host() --------+ +scsi_add_host() ----> +scsi_scan_host() -------+ | slave_alloc() slave_configure() --> scsi_adjust_queue_depth() @@ -196,7 +197,7 @@ of the issues involved. See the section on reference counting below. The hotplug concept may be extended to SCSI devices. Currently, when an -HBA is added, the scsi_add_host() function causes a scan for SCSI devices +HBA is added, the scsi_scan_host() function causes a scan for SCSI devices attached to the HBA's SCSI transport. On newer SCSI transports the HBA may become aware of a new SCSI device _after_ the scan has completed. An LLD can use this sequence to make the mid level aware of a SCSI device: @@ -372,7 +373,7 @@ names all start with "scsi_". Summary: scsi_activate_tcq - turn on tag command queueing scsi_add_device - creates new scsi device (lu) instance - scsi_add_host - perform sysfs registration and SCSI bus scan. + scsi_add_host - perform sysfs registration and set up transport class scsi_adjust_queue_depth - change the queue depth on a SCSI device scsi_assign_lock - replace default host_lock with given lock scsi_bios_ptable - return copy of block device's partition table @@ -386,6 +387,7 @@ Summary: scsi_remove_device - detach and remove a SCSI device scsi_remove_host - detach and remove all SCSI devices owned by host scsi_report_bus_reset - report scsi _bus_ reset observed + scsi_scan_host - scan SCSI bus scsi_track_queue_full - track successive QUEUE_FULL events scsi_unblock_requests - allow further commands to be queued to given host scsi_unregister - [calls scsi_host_put()] @@ -425,10 +427,10 @@ void scsi_activate_tcq(struct scsi_device *sdev, int depth) * Might block: yes * * Notes: This call is usually performed internally during a scsi - * bus scan when an HBA is added (i.e. scsi_add_host()). So it + * bus scan when an HBA is added (i.e. scsi_scan_host()). So it * should only be called if the HBA becomes aware of a new scsi - * device (lu) after scsi_add_host() has completed. If successful - * this call we lead to slave_alloc() and slave_configure() callbacks + * device (lu) after scsi_scan_host() has completed. If successful + * this call can lead to slave_alloc() and slave_configure() callbacks * into the LLD. * * Defined in: drivers/scsi/scsi_scan.c @@ -439,7 +441,7 @@ struct scsi_device * scsi_add_device(struct Scsi_Host *shost, /** - * scsi_add_host - perform sysfs registration and SCSI bus scan. + * scsi_add_host - perform sysfs registration and set up transport class * @shost: pointer to scsi host instance * @dev: pointer to struct device of type scsi class * @@ -448,7 +450,11 @@ struct scsi_device * scsi_add_device(struct Scsi_Host *shost, * Might block: no * * Notes: Only required in "hotplug initialization model" after a - * successful call to scsi_host_alloc(). + * successful call to scsi_host_alloc(). This function does not + * scan the bus; this can be done by calling scsi_scan_host() or + * in some other transport-specific way. The LLD must set up + * the transport template before calling this function and may only + * access the transport class data after this function has been called. * * Defined in: drivers/scsi/hosts.c **/ @@ -559,7 +565,7 @@ void scsi_deactivate_tcq(struct scsi_device *sdev, int depth) * area for the LLD's exclusive use. * Both associated refcounting objects have their refcount set to 1. * Full registration (in sysfs) and a bus scan are performed later when - * scsi_add_host() is called. + * scsi_add_host() and scsi_scan_host() are called. * * Defined in: drivers/scsi/hosts.c . **/ @@ -699,6 +705,19 @@ void scsi_report_bus_reset(struct Scsi_Host * shost, int channel) /** + * scsi_scan_host - scan SCSI bus + * @shost: a pointer to a scsi host instance + * + * Might block: yes + * + * Notes: Should be called after scsi_add_host() + * + * Defined in: drivers/scsi/scsi_scan.c + **/ +void scsi_scan_host(struct Scsi_Host *shost) + + +/** * scsi_track_queue_full - track successive QUEUE_FULL events on given * device to determine if and when there is a need * to adjust the queue depth on the device. -- cgit v1.1 From 47be1e0ee1f484c8127f306e06ed3be91add07ee Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:27 -0500 Subject: [SCSI] sym2: Remove FreeBSD ifdefs Remove FreeBSD ifdefs from sym2 driver Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_fw.c | 12 ------------ drivers/scsi/sym53c8xx_2/sym_malloc.c | 4 ---- 2 files changed, 16 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c index fd36cf9..a7528a8 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw.c +++ b/drivers/scsi/sym53c8xx_2/sym_fw.c @@ -37,11 +37,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __FreeBSD__ -#include -#else #include "sym_glue.h" -#endif /* * Macros used for all firmwares. @@ -60,11 +56,7 @@ #define SYM_FWA_SCR sym_fw1a_scr #define SYM_FWB_SCR sym_fw1b_scr #define SYM_FWZ_SCR sym_fw1z_scr -#ifdef __FreeBSD__ -#include -#else #include "sym_fw1.h" -#endif static struct sym_fwa_ofs sym_fw1a_ofs = { SYM_GEN_FW_A(struct SYM_FWA_SCR) }; @@ -88,11 +80,7 @@ static struct sym_fwz_ofs sym_fw1z_ofs = { #define SYM_FWA_SCR sym_fw2a_scr #define SYM_FWB_SCR sym_fw2b_scr #define SYM_FWZ_SCR sym_fw2z_scr -#ifdef __FreeBSD__ -#include -#else #include "sym_fw2.h" -#endif static struct sym_fwa_ofs sym_fw2a_ofs = { SYM_GEN_FW_A(struct SYM_FWA_SCR) }; diff --git a/drivers/scsi/sym53c8xx_2/sym_malloc.c b/drivers/scsi/sym53c8xx_2/sym_malloc.c index a34d403..92bf9b1 100644 --- a/drivers/scsi/sym53c8xx_2/sym_malloc.c +++ b/drivers/scsi/sym53c8xx_2/sym_malloc.c @@ -37,11 +37,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __FreeBSD__ -#include -#else #include "sym_glue.h" -#endif /* * Simple power of two buddy-like generic allocator. -- cgit v1.1 From 760c9de589175f5285668d17825c259aec08370c Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:29 -0500 Subject: [SCSI] sym2: Remove last vestiges of sym_sniff_inquiry The SYM_OPT_SNIFF_INQUIRY define is never set any more, and the sym_sniff_inquiry() function doesn't exist From: Christoph Hellwig Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.h | 1 - drivers/scsi/sym53c8xx_2/sym_hipd.c | 9 --------- 2 files changed, 10 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index d3d52f1..c61c23f 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -268,6 +268,5 @@ void sym_xpt_async_bus_reset(struct sym_hcb *np); void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target); int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp); void sym_log_bus_error(struct sym_hcb *np); -void sym_sniff_inquiry(struct sym_hcb *np, struct scsi_cmnd *cmd, int resid); #endif /* SYM_GLUE_H */ diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index a7420ca..113e3b3 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -5551,15 +5551,6 @@ if (resid) */ sym_set_cam_result_ok(cp, cmd, resid); -#ifdef SYM_OPT_SNIFF_INQUIRY - /* - * On standard INQUIRY response (EVPD and CmDt - * not set), sniff out device capabilities. - */ - if (cp->cdb_buf[0] == INQUIRY && !(cp->cdb_buf[1] & 0x3)) - sym_sniff_inquiry(np, cmd, resid); -#endif - #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING /* * If max number of started ccbs had been reduced, -- cgit v1.1 From 84e203a279d3de1c8a41a73ab45e55a89bc19345 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:31 -0500 Subject: [SCSI] sym2: Manage sym_lcb properly Allocate the lcb in slave_alloc and free it in slave_destroy. This allows us to remove all the code that checks to see if it's already been allocated. From: Christoph Hellwig Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 59 +++++++++++++------------ drivers/scsi/sym53c8xx_2/sym_hipd.c | 86 +++---------------------------------- drivers/scsi/sym53c8xx_2/sym_hipd.h | 14 ------ 3 files changed, 38 insertions(+), 121 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index 7fc0b97..a2bfdf8 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -563,10 +563,7 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s /* * activate this job. */ - if (lp) - sym_start_next_ccbs(np, lp, 2); - else - sym_put_start_queue(np, cp); + sym_start_next_ccbs(np, lp, 2); return 0; out_abort: @@ -981,15 +978,13 @@ static int device_queue_depth(struct sym_hcb *np, int target, int lun) static int sym53c8xx_slave_alloc(struct scsi_device *sdev) { - struct sym_hcb *np; - struct sym_tcb *tp; + struct sym_hcb *np = sym_get_hcb(sdev->host); + struct sym_tcb *tp = &np->target[sdev->id]; + struct sym_lcb *lp; if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN) return -ENXIO; - np = sym_get_hcb(sdev->host); - tp = &np->target[sdev->id]; - /* * Fail the device init if the device is flagged NOSCAN at BOOT in * the NVRAM. This may speed up boot and maintain coherency with @@ -1005,6 +1000,10 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev) return -ENXIO; } + lp = sym_alloc_lcb(np, sdev->id, sdev->lun); + if (!lp) + return -ENOMEM; + tp->starget = sdev->sdev_target; return 0; } @@ -1012,22 +1011,14 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev) /* * Linux entry point for device queue sizing. */ -static int sym53c8xx_slave_configure(struct scsi_device *device) +static int sym53c8xx_slave_configure(struct scsi_device *sdev) { - struct sym_hcb *np = sym_get_hcb(device->host); - struct sym_tcb *tp = &np->target[device->id]; - struct sym_lcb *lp; + struct sym_hcb *np = sym_get_hcb(sdev->host); + struct sym_tcb *tp = &np->target[sdev->id]; + struct sym_lcb *lp = sym_lp(tp, sdev->lun); int reqtags, depth_to_use; /* - * Allocate the LCB if not yet. - * If it fail, we may well be in the sh*t. :) - */ - lp = sym_alloc_lcb(np, device->id, device->lun); - if (!lp) - return -ENOMEM; - - /* * Get user flags. */ lp->curr_flags = lp->user_flags; @@ -1038,10 +1029,10 @@ static int sym53c8xx_slave_configure(struct scsi_device *device) * Use at least 2. * Donnot use more than our maximum. */ - reqtags = device_queue_depth(np, device->id, device->lun); + reqtags = device_queue_depth(np, sdev->id, sdev->lun); if (reqtags > tp->usrtags) reqtags = tp->usrtags; - if (!device->tagged_supported) + if (!sdev->tagged_supported) reqtags = 0; #if 1 /* Avoid to locally queue commands for no good reasons */ if (reqtags > SYM_CONF_MAX_TAG) @@ -1050,19 +1041,30 @@ static int sym53c8xx_slave_configure(struct scsi_device *device) #else depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2); #endif - scsi_adjust_queue_depth(device, - (device->tagged_supported ? + scsi_adjust_queue_depth(sdev, + (sdev->tagged_supported ? MSG_SIMPLE_TAG : 0), depth_to_use); lp->s.scdev_depth = depth_to_use; - sym_tune_dev_queuing(tp, device->lun, reqtags); + sym_tune_dev_queuing(tp, sdev->lun, reqtags); - if (!spi_initial_dv(device->sdev_target)) - spi_dv_device(device); + if (!spi_initial_dv(sdev->sdev_target)) + spi_dv_device(sdev); return 0; } +static void sym53c8xx_slave_destroy(struct scsi_device *sdev) +{ + struct sym_hcb *np = sym_get_hcb(sdev->host); + struct sym_lcb *lp = sym_lp(&np->target[sdev->id], sdev->lun); + + if (lp->itlq_tbl) + sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK * 4, "ITLQ_TBL"); + kfree(lp->cb_tags); + sym_mfree_dma(lp, sizeof(*lp), "LCB"); +} + /* * Linux entry point for info() function */ @@ -1926,6 +1928,7 @@ static struct scsi_host_template sym2_template = { .queuecommand = sym53c8xx_queue_command, .slave_alloc = sym53c8xx_slave_alloc, .slave_configure = sym53c8xx_slave_configure, + .slave_destroy = sym53c8xx_slave_destroy, .eh_abort_handler = sym53c8xx_eh_abort_handler, .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler, .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler, diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 113e3b3..bec6448 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -1523,7 +1523,7 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp /* * Insert a job into the start queue. */ -void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) +static void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) { u_short qidx; @@ -4664,30 +4664,7 @@ struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char t goto out; cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); -#ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING - /* - * If the LCB is not yet available and the LUN - * has been probed ok, try to allocate the LCB. - */ - if (!lp && sym_is_bit(tp->lun_map, ln)) { - lp = sym_alloc_lcb(np, tn, ln); - if (!lp) - goto out_free; - } -#endif - - /* - * If the LCB is not available here, then the - * logical unit is not yet discovered. For those - * ones only accept 1 SCSI IO per logical unit, - * since we cannot allow disconnections. - */ - if (!lp) { - if (!sym_is_bit(tp->busy0_map, ln)) - sym_set_bit(tp->busy0_map, ln); - else - goto out_free; - } else { + { /* * If we have been asked for a tagged command. */ @@ -4840,12 +4817,6 @@ void sym_free_ccb (struct sym_hcb *np, struct sym_ccb *cp) lp->head.resel_sa = cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun)); } - /* - * Otherwise, we only accept 1 IO per LUN. - * Clear the bit that keeps track of this IO. - */ - else - sym_clr_bit(tp->busy0_map, cp->lun); /* * We donnot queue more than 1 ccb per target @@ -4997,20 +4968,7 @@ static void sym_init_tcb (struct sym_hcb *np, u_char tn) struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) { struct sym_tcb *tp = &np->target[tn]; - struct sym_lcb *lp = sym_lp(tp, ln); - - /* - * Already done, just return. - */ - if (lp) - return lp; - - /* - * Donnot allow LUN control block - * allocation for not probed LUNs. - */ - if (!sym_is_bit(tp->lun_map, ln)) - return NULL; + struct sym_lcb *lp = NULL; /* * Initialize the target control block if not yet. @@ -5082,13 +5040,7 @@ struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) lp->started_max = SYM_CONF_MAX_TASK; lp->started_limit = SYM_CONF_MAX_TASK; #endif - /* - * If we are busy, count the IO. - */ - if (sym_is_bit(tp->busy0_map, ln)) { - lp->busy_itl = 1; - sym_clr_bit(tp->busy0_map, ln); - } + fail: return lp; } @@ -5103,12 +5055,6 @@ static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln) int i; /* - * If LCB not available, try to allocate it. - */ - if (!lp && !(lp = sym_alloc_lcb(np, tn, ln))) - goto fail; - - /* * Allocate the task table and and the tag allocation * circular buffer. We want both or none. */ @@ -5481,8 +5427,7 @@ finish: /* * Donnot start more than 1 command after an error. */ - if (lp) - sym_start_next_ccbs(np, lp, 1); + sym_start_next_ccbs(np, lp, 1); #endif } @@ -5521,12 +5466,6 @@ void sym_complete_ok (struct sym_hcb *np, struct sym_ccb *cp) lp = sym_lp(tp, cp->lun); /* - * Assume device discovered on first success. - */ - if (!lp) - sym_set_bit(tp->lun_map, cp->lun); - - /* * If all data have been transferred, given than no * extended error did occur, there is no residual. */ @@ -5578,7 +5517,7 @@ if (resid) /* * Requeue a couple of awaiting scsi commands. */ - if (lp && !sym_que_empty(&lp->waiting_ccbq)) + if (!sym_que_empty(&lp->waiting_ccbq)) sym_start_next_ccbs(np, lp, 2); #endif /* @@ -5821,8 +5760,7 @@ void sym_hcb_free(struct sym_hcb *np) SYM_QUEHEAD *qp; struct sym_ccb *cp; struct sym_tcb *tp; - struct sym_lcb *lp; - int target, lun; + int target; if (np->scriptz0) sym_mfree_dma(np->scriptz0, np->scriptz_sz, "SCRIPTZ0"); @@ -5848,16 +5786,6 @@ void sym_hcb_free(struct sym_hcb *np) for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) { tp = &np->target[target]; - for (lun = 0 ; lun < SYM_CONF_MAX_LUN ; lun++) { - lp = sym_lp(tp, lun); - if (!lp) - continue; - if (lp->itlq_tbl) - sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4, - "ITLQ_TBL"); - kfree(lp->cb_tags); - sym_mfree_dma(lp, sizeof(*lp), "LCB"); - } #if SYM_CONF_MAX_LUN > 1 kfree(tp->lunmp); #endif diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index 3a264a4..7560088 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -416,19 +416,6 @@ struct sym_tcb { struct sym_lcb **lunmp; /* Other LCBs [1..MAX_LUN] */ #endif - /* - * Bitmap that tells about LUNs that succeeded at least - * 1 IO and therefore assumed to be a real device. - * Avoid useless allocation of the LCB structure. - */ - u32 lun_map[(SYM_CONF_MAX_LUN+31)/32]; - - /* - * Bitmap that tells about LUNs that haven't yet an LCB - * allocated (not discovered or LCB allocation failed). - */ - u32 busy0_map[(SYM_CONF_MAX_LUN+31)/32]; - #ifdef SYM_HAVE_STCB /* * O/S specific data structure. @@ -1077,7 +1064,6 @@ char *sym_driver_name(void); void sym_print_xerr(struct scsi_cmnd *cmd, int x_status); int sym_reset_scsi_bus(struct sym_hcb *np, int enab_int); struct sym_chip *sym_lookup_chip_table(u_short device_id, u_char revision); -void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp); #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn); #endif -- cgit v1.1 From 44f30b0f59d628eb6f57cfa9d8ab06da670e5306 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:33 -0500 Subject: [SCSI] sym2: Remove code to handle DMA_BIDIRECTION requests The upper layer doesn't send these down since 2.4.x (or 2.6 in practice), so no need to handle it. Inline sym_setup_data_pointers into its only caller so we can fail gracefully in the case we'd get one neverless. Signed-off-by: Christoph Hellwig Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_fw.c | 6 --- drivers/scsi/sym53c8xx_2/sym_fw.h | 6 --- drivers/scsi/sym53c8xx_2/sym_fw1.h | 48 --------------------- drivers/scsi/sym53c8xx_2/sym_fw2.h | 52 ----------------------- drivers/scsi/sym53c8xx_2/sym_glue.c | 39 +++++++++++++++-- drivers/scsi/sym53c8xx_2/sym_glue.h | 1 - drivers/scsi/sym53c8xx_2/sym_hipd.c | 8 ++-- drivers/scsi/sym53c8xx_2/sym_hipd.h | 84 ------------------------------------- 8 files changed, 40 insertions(+), 204 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c index a7528a8..9916a2a 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw.c +++ b/drivers/scsi/sym53c8xx_2/sym_fw.c @@ -62,9 +62,6 @@ static struct sym_fwa_ofs sym_fw1a_ofs = { }; static struct sym_fwb_ofs sym_fw1b_ofs = { SYM_GEN_FW_B(struct SYM_FWB_SCR) -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - SYM_GEN_B(struct SYM_FWB_SCR, data_io) -#endif }; static struct sym_fwz_ofs sym_fw1z_ofs = { SYM_GEN_FW_Z(struct SYM_FWZ_SCR) @@ -86,9 +83,6 @@ static struct sym_fwa_ofs sym_fw2a_ofs = { }; static struct sym_fwb_ofs sym_fw2b_ofs = { SYM_GEN_FW_B(struct SYM_FWB_SCR) -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - SYM_GEN_B(struct SYM_FWB_SCR, data_io) -#endif SYM_GEN_B(struct SYM_FWB_SCR, start64) SYM_GEN_B(struct SYM_FWB_SCR, pm_handle) }; diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.h b/drivers/scsi/sym53c8xx_2/sym_fw.h index 43f6810..66ec35b 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw.h +++ b/drivers/scsi/sym53c8xx_2/sym_fw.h @@ -92,9 +92,6 @@ struct sym_fwa_ofs { }; struct sym_fwb_ofs { SYM_GEN_FW_B(u_short) -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - SYM_GEN_B(u_short, data_io) -#endif SYM_GEN_B(u_short, start64) SYM_GEN_B(u_short, pm_handle) }; @@ -111,9 +108,6 @@ struct sym_fwa_ba { }; struct sym_fwb_ba { SYM_GEN_FW_B(u32) -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - SYM_GEN_B(u32, data_io) -#endif SYM_GEN_B(u32, start64); SYM_GEN_B(u32, pm_handle); }; diff --git a/drivers/scsi/sym53c8xx_2/sym_fw1.h b/drivers/scsi/sym53c8xx_2/sym_fw1.h index cdd92d8..7b39f4a 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw1.h +++ b/drivers/scsi/sym53c8xx_2/sym_fw1.h @@ -197,12 +197,6 @@ struct SYM_FWB_SCR { u32 bad_status [ 7]; u32 wsr_ma_helper [ 4]; -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - /* Unknown direction handling */ - u32 data_io [ 2]; - u32 data_io_com [ 8]; - u32 data_io_out [ 7]; -#endif /* Data area */ u32 zero [ 1]; u32 scratch [ 1]; @@ -1747,48 +1741,6 @@ static struct SYM_FWB_SCR SYM_FWB_SCR = { SCR_JUMP, PADDR_A (dispatch), -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN -}/*-------------------------< DATA_IO >--------------------------*/,{ - /* - * We jump here if the data direction was unknown at the - * time we had to queue the command to the scripts processor. - * Pointers had been set as follow in this situation: - * savep --> DATA_IO - * lastp --> start pointer when DATA_IN - * wlastp --> start pointer when DATA_OUT - * This script sets savep and lastp according to the - * direction chosen by the target. - */ - SCR_JUMP ^ IFTRUE (WHEN (SCR_DATA_OUT)), - PADDR_B (data_io_out), -}/*-------------------------< DATA_IO_COM >----------------------*/,{ - /* - * Direction is DATA IN. - */ - SCR_COPY (4), - HADDR_1 (ccb_head.lastp), - HADDR_1 (ccb_head.savep), - /* - * Jump to the SCRIPTS according to actual direction. - */ - SCR_COPY (4), - HADDR_1 (ccb_head.savep), - RADDR_1 (temp), - SCR_RETURN, - 0, -}/*-------------------------< DATA_IO_OUT >----------------------*/,{ - /* - * Direction is DATA OUT. - */ - SCR_REG_REG (HF_REG, SCR_AND, (~HF_DATA_IN)), - 0, - SCR_COPY (4), - HADDR_1 (ccb_head.wlastp), - HADDR_1 (ccb_head.lastp), - SCR_JUMP, - PADDR_B(data_io_com), -#endif /* SYM_OPT_HANDLE_DIR_UNKNOWN */ - }/*-------------------------< ZERO >-----------------------------*/,{ SCR_DATA_ZERO, }/*-------------------------< SCRATCH >--------------------------*/,{ diff --git a/drivers/scsi/sym53c8xx_2/sym_fw2.h b/drivers/scsi/sym53c8xx_2/sym_fw2.h index 7ea7151..851f270 100644 --- a/drivers/scsi/sym53c8xx_2/sym_fw2.h +++ b/drivers/scsi/sym53c8xx_2/sym_fw2.h @@ -191,13 +191,6 @@ struct SYM_FWB_SCR { u32 pm_wsr_handle [ 38]; u32 wsr_ma_helper [ 4]; -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - /* Unknown direction handling */ - u32 data_io [ 2]; - u32 data_io_in [ 2]; - u32 data_io_com [ 6]; - u32 data_io_out [ 8]; -#endif /* Data area */ u32 zero [ 1]; u32 scratch [ 1]; @@ -1838,51 +1831,6 @@ static struct SYM_FWB_SCR SYM_FWB_SCR = { SCR_JUMP, PADDR_A (dispatch), -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN -}/*-------------------------< DATA_IO >--------------------------*/,{ - /* - * We jump here if the data direction was unknown at the - * time we had to queue the command to the scripts processor. - * Pointers had been set as follow in this situation: - * savep --> DATA_IO - * lastp --> start pointer when DATA_IN - * wlastp --> start pointer when DATA_OUT - * This script sets savep and lastp according to the - * direction chosen by the target. - */ - SCR_JUMP ^ IFTRUE (WHEN (SCR_DATA_OUT)), - PADDR_B (data_io_out), -}/*-------------------------< DATA_IO_IN >-----------------------*/,{ - /* - * Direction is DATA IN. - */ - SCR_LOAD_REL (scratcha, 4), - offsetof (struct sym_ccb, phys.head.lastp), -}/*-------------------------< DATA_IO_COM >----------------------*/,{ - SCR_STORE_REL (scratcha, 4), - offsetof (struct sym_ccb, phys.head.savep), - - /* - * Jump to the SCRIPTS according to actual direction. - */ - SCR_LOAD_REL (temp, 4), - offsetof (struct sym_ccb, phys.head.savep), - SCR_RETURN, - 0, -}/*-------------------------< DATA_IO_OUT >----------------------*/,{ - /* - * Direction is DATA OUT. - */ - SCR_REG_REG (HF_REG, SCR_AND, (~HF_DATA_IN)), - 0, - SCR_LOAD_REL (scratcha, 4), - offsetof (struct sym_ccb, phys.head.wlastp), - SCR_STORE_REL (scratcha, 4), - offsetof (struct sym_ccb, phys.head.lastp), - SCR_JUMP, - PADDR_B(data_io_com), -#endif /* SYM_OPT_HANDLE_DIR_UNKNOWN */ - }/*-------------------------< ZERO >-----------------------------*/,{ SCR_DATA_ZERO, }/*-------------------------< SCRATCH >--------------------------*/,{ diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index a2bfdf8..d924997 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -514,9 +514,10 @@ static inline int sym_setup_cdb(struct sym_hcb *np, struct scsi_cmnd *cmd, struc */ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp) { - int dir; struct sym_tcb *tp = &np->target[cp->target]; struct sym_lcb *lp = sym_lp(tp, cp->lun); + u32 lastp, goalp; + int dir; /* * Build the CDB. @@ -534,15 +535,47 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s sym_set_cam_status(cmd, DID_ERROR); goto out_abort; } + + /* + * No segments means no data. + */ + if (!cp->segments) + dir = DMA_NONE; } else { cp->data_len = 0; cp->segments = 0; } /* - * Set data pointers. + * Set the data pointer. + */ + switch (dir) { + case DMA_BIDIRECTIONAL: + printk("%s: got DMA_BIDIRECTIONAL command", sym_name(np)); + sym_set_cam_status(cmd, DID_ERROR); + goto out_abort; + case DMA_TO_DEVICE: + goalp = SCRIPTA_BA(np, data_out2) + 8; + lastp = goalp - 8 - (cp->segments * (2*4)); + break; + case DMA_FROM_DEVICE: + cp->host_flags |= HF_DATA_IN; + goalp = SCRIPTA_BA(np, data_in2) + 8; + lastp = goalp - 8 - (cp->segments * (2*4)); + break; + case DMA_NONE: + default: + lastp = goalp = SCRIPTB_BA(np, no_data); + break; + } + + /* + * Set all pointers values needed by SCRIPTS. */ - sym_setup_data_pointers(np, cp, dir); + cp->phys.head.lastp = cpu_to_scr(lastp); + cp->phys.head.savep = cpu_to_scr(lastp); + cp->startp = cp->phys.head.savep; + cp->goalp = cpu_to_scr(goalp); /* * When `#ifed 1', the code below makes the driver diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h index c61c23f..cc92d0c 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.h +++ b/drivers/scsi/sym53c8xx_2/sym_glue.h @@ -68,7 +68,6 @@ */ #define SYM_CONF_TIMER_INTERVAL ((HZ+1)/2) -#define SYM_OPT_HANDLE_DIR_UNKNOWN #define SYM_OPT_HANDLE_DEVICE_QUEUEING #define SYM_OPT_LIMIT_COMMAND_REORDERING diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index bec6448..b4f0d9a 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -3654,7 +3654,7 @@ static int sym_evaluate_dp(struct sym_hcb *np, struct sym_ccb *cp, u32 scr, int * If result is dp_sg = SYM_CONF_MAX_SG, then we are at the * end of the data. */ - tmp = scr_to_cpu(sym_goalp(cp)); + tmp = scr_to_cpu(cp->goalp); dp_sg = SYM_CONF_MAX_SG; if (dp_scr != tmp) dp_sg -= (tmp - 8 - (int)dp_scr) / (2*4); @@ -3761,7 +3761,7 @@ static void sym_modify_dp(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb * And our alchemy:) allows to easily calculate the data * script address we want to return for the next data phase. */ - dp_ret = cpu_to_scr(sym_goalp(cp)); + dp_ret = cpu_to_scr(cp->goalp); dp_ret = dp_ret - 8 - (SYM_CONF_MAX_SG - dp_sg) * (2*4); /* @@ -3857,7 +3857,7 @@ int sym_compute_residual(struct sym_hcb *np, struct sym_ccb *cp) * If all data has been transferred, * there is no residual. */ - if (cp->phys.head.lastp == sym_goalp(cp)) + if (cp->phys.head.lastp == cp->goalp) return resid; /* @@ -5470,7 +5470,7 @@ void sym_complete_ok (struct sym_hcb *np, struct sym_ccb *cp) * extended error did occur, there is no residual. */ resid = 0; - if (cp->phys.head.lastp != sym_goalp(cp)) + if (cp->phys.head.lastp != cp->goalp) resid = sym_compute_residual(np, cp); /* diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index 7560088..1718110 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -48,12 +48,6 @@ * They may be defined in platform specific headers, if they * are useful. * - * SYM_OPT_HANDLE_DIR_UNKNOWN - * When this option is set, the SCRIPTS used by the driver - * are able to handle SCSI transfers with direction not - * supplied by user. - * (set for Linux-2.0.X) - * * SYM_OPT_HANDLE_DEVICE_QUEUEING * When this option is set, the driver will use a queue per * device and handle QUEUE FULL status requeuing internally. @@ -64,7 +58,6 @@ * (set for Linux) */ #if 0 -#define SYM_OPT_HANDLE_DIR_UNKNOWN #define SYM_OPT_HANDLE_DEVICE_QUEUEING #define SYM_OPT_LIMIT_COMMAND_REORDERING #endif @@ -659,9 +652,6 @@ struct sym_ccbh { */ u32 savep; /* Jump address to saved data pointer */ u32 lastp; /* SCRIPTS address at end of data */ -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - u32 wlastp; -#endif /* * Status fields. @@ -791,9 +781,6 @@ struct sym_ccb { SYM_QUEHEAD link_ccbq; /* Link to free/busy CCB queue */ u32 startp; /* Initial data pointer */ u32 goalp; /* Expected last data pointer */ -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - u32 wgoalp; -#endif int ext_sg; /* Extreme data pointer, used */ int ext_ofs; /* to calculate the residual. */ #ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING @@ -808,12 +795,6 @@ struct sym_ccb { #define CCB_BA(cp,lbl) cpu_to_scr(cp->ccb_ba + offsetof(struct sym_ccb, lbl)) -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN -#define sym_goalp(cp) ((cp->host_flags & HF_DATA_IN) ? cp->goalp : cp->wgoalp) -#else -#define sym_goalp(cp) (cp->goalp) -#endif - typedef struct device *m_pool_ident_t; /* @@ -1122,71 +1103,6 @@ bad: #endif /* - * Set up data pointers used by SCRIPTS. - * Called from O/S specific code. - */ -static inline void sym_setup_data_pointers(struct sym_hcb *np, - struct sym_ccb *cp, int dir) -{ - u32 lastp, goalp; - - /* - * No segments means no data. - */ - if (!cp->segments) - dir = DMA_NONE; - - /* - * Set the data pointer. - */ - switch(dir) { -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - case DMA_BIDIRECTIONAL: -#endif - case DMA_TO_DEVICE: - goalp = SCRIPTA_BA(np, data_out2) + 8; - lastp = goalp - 8 - (cp->segments * (2*4)); -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - cp->wgoalp = cpu_to_scr(goalp); - if (dir != DMA_BIDIRECTIONAL) - break; - cp->phys.head.wlastp = cpu_to_scr(lastp); - /* fall through */ -#else - break; -#endif - case DMA_FROM_DEVICE: - cp->host_flags |= HF_DATA_IN; - goalp = SCRIPTA_BA(np, data_in2) + 8; - lastp = goalp - 8 - (cp->segments * (2*4)); - break; - case DMA_NONE: - default: -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - cp->host_flags |= HF_DATA_IN; -#endif - lastp = goalp = SCRIPTB_BA(np, no_data); - break; - } - - /* - * Set all pointers values needed by SCRIPTS. - */ - cp->phys.head.lastp = cpu_to_scr(lastp); - cp->phys.head.savep = cpu_to_scr(lastp); - cp->startp = cp->phys.head.savep; - cp->goalp = cpu_to_scr(goalp); - -#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN - /* - * If direction is unknown, start at data_io. - */ - if (dir == DMA_BIDIRECTIONAL) - cp->phys.head.savep = cpu_to_scr(SCRIPTB_BA(np, data_io)); -#endif -} - -/* * MEMORY ALLOCATOR. */ -- cgit v1.1 From 1e8eb21ea7b5c318d881eab878f3e545e55fa273 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:36 -0500 Subject: [SCSI] sym2: Use DMA_40BIT_MASK constant Now that this constant has been added to dma-mapping.h, we don't need our own definition Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index d924997..bb90ef9 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1532,7 +1532,7 @@ static int sym_setup_bus_dma_mask(struct sym_hcb *np) { #if SYM_CONF_DMA_ADDRESSING_MODE > 0 #if SYM_CONF_DMA_ADDRESSING_MODE == 1 -#define DMA_DAC_MASK 0x000000ffffffffffULL /* 40-bit */ +#define DMA_DAC_MASK DMA_40BIT_MASK #elif SYM_CONF_DMA_ADDRESSING_MODE == 2 #define DMA_DAC_MASK DMA_64BIT_MASK #endif -- cgit v1.1 From 33333bacf523bb4bb903058fec6041a5952c93c6 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:42 -0500 Subject: [SCSI] sym2: Use scsi_print_msg sym_show_msg was almost a duplicate of scsi_print_msg, except not as featureful. So use the common code instead. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_hipd.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index b4f0d9a..c36e43b 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -40,6 +40,7 @@ #include #include /* for timeouts in units of HZ */ +#include #include "sym_glue.h" #include "sym_nvram.h" @@ -70,32 +71,12 @@ static void sym_printl_hex(u_char *p, int n) printf (".\n"); } -/* - * Print out the content of a SCSI message. - */ -static int sym_show_msg (u_char * msg) -{ - u_char i; - printf ("%x",*msg); - if (*msg==M_EXTENDED) { - for (i=1;i<8;i++) { - if (i-1>msg[1]) break; - printf ("-%x",msg[i]); - } - return (i+1); - } else if ((*msg & 0xf0) == 0x20) { - printf ("-%x",msg[1]); - return (2); - } - return (1); -} - static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg) { sym_print_addr(cp->cmd, "%s: ", label); - sym_show_msg(msg); - printf(".\n"); + scsi_print_msg(msg); + printf("\n"); } static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg) @@ -103,8 +84,8 @@ static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_ch struct sym_tcb *tp = &np->target[target]; dev_info(&tp->starget->dev, "%s: ", label); - sym_show_msg(msg); - printf(".\n"); + scsi_print_msg(msg); + printf("\n"); } /* -- cgit v1.1 From b37df48923b76155de2a728e1155ed263dba5f53 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:44 -0500 Subject: [SCSI] sym2: Allow NVRAM settings to limit speed and width The NVRAM for both Tekram and Symbios boards allows the user to set the speed and width for individual targets. I took that code out in March 2004 when we introduced Domain Validation, but it seems there's still a legitimate need for it in some configurations. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 3 +++ drivers/scsi/sym53c8xx_2/sym_hipd.c | 2 +- drivers/scsi/sym53c8xx_2/sym_hipd.h | 6 ++++-- drivers/scsi/sym53c8xx_2/sym_nvram.c | 29 ++++++++++++++++------------- drivers/scsi/sym53c8xx_2/sym_nvram.h | 4 ++-- 5 files changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index bb90ef9..cb3d195 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1038,6 +1038,9 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev) return -ENOMEM; tp->starget = sdev->sdev_target; + spi_min_period(tp->starget) = tp->usr_period; + spi_max_width(tp->starget) = tp->usr_width; + return 0; } diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index c36e43b..0b0cba0 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -943,7 +943,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru tp->usrflags |= (SYM_DISC_ENABLED | SYM_TAGS_ENABLED); tp->usrtags = SYM_SETUP_MAX_TAG; - sym_nvram_setup_target(np, i, nvram); + sym_nvram_setup_target(tp, i, nvram); if (!tp->usrtags) tp->usrflags &= ~SYM_TAGS_ENABLED; diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h index 1718110..2456090 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.h +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h @@ -434,8 +434,10 @@ struct sym_tcb { * Other user settable limits and options. * These limits are read from the NVRAM if present. */ - u_char usrflags; - u_short usrtags; + unsigned char usrflags; + unsigned char usr_period; + unsigned char usr_width; + unsigned short usrtags; struct scsi_target *starget; }; diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.c b/drivers/scsi/sym53c8xx_2/sym_nvram.c index 994b756..15d6929 100644 --- a/drivers/scsi/sym53c8xx_2/sym_nvram.c +++ b/drivers/scsi/sym53c8xx_2/sym_nvram.c @@ -92,29 +92,32 @@ void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sy * Get target set-up from Symbios format NVRAM. */ static void -sym_Symbios_setup_target(struct sym_hcb *np, int target, Symbios_nvram *nvram) +sym_Symbios_setup_target(struct sym_tcb *tp, int target, Symbios_nvram *nvram) { - struct sym_tcb *tp = &np->target[target]; Symbios_target *tn = &nvram->target[target]; - tp->usrtags = - (tn->flags & SYMBIOS_QUEUE_TAGS_ENABLED)? SYM_SETUP_MAX_TAG : 0; - + if (!(tn->flags & SYMBIOS_QUEUE_TAGS_ENABLED)) + tp->usrtags = 0; if (!(tn->flags & SYMBIOS_DISCONNECT_ENABLE)) tp->usrflags &= ~SYM_DISC_ENABLED; if (!(tn->flags & SYMBIOS_SCAN_AT_BOOT_TIME)) tp->usrflags |= SYM_SCAN_BOOT_DISABLED; if (!(tn->flags & SYMBIOS_SCAN_LUNS)) tp->usrflags |= SYM_SCAN_LUNS_DISABLED; + tp->usr_period = (tn->sync_period + 3) / 4; + tp->usr_width = (tn->bus_width == 0x8) ? 0 : 1; } +static const unsigned char Tekram_sync[16] = { + 25, 31, 37, 43, 50, 62, 75, 125, 12, 15, 18, 21, 6, 7, 9, 10 +}; + /* * Get target set-up from Tekram format NVRAM. */ static void -sym_Tekram_setup_target(struct sym_hcb *np, int target, Tekram_nvram *nvram) +sym_Tekram_setup_target(struct sym_tcb *tp, int target, Tekram_nvram *nvram) { - struct sym_tcb *tp = &np->target[target]; struct Tekram_target *tn = &nvram->target[target]; if (tn->flags & TEKRAM_TAGGED_COMMANDS) { @@ -124,22 +127,22 @@ sym_Tekram_setup_target(struct sym_hcb *np, int target, Tekram_nvram *nvram) if (tn->flags & TEKRAM_DISCONNECT_ENABLE) tp->usrflags |= SYM_DISC_ENABLED; - /* If any device does not support parity, we will not use this option */ - if (!(tn->flags & TEKRAM_PARITY_CHECK)) - np->rv_scntl0 &= ~0x0a; /* SCSI parity checking disabled */ + if (tn->flags & TEKRAM_SYNC_NEGO) + tp->usr_period = Tekram_sync[tn->sync_index & 0xf]; + tp->usr_width = (tn->flags & TEKRAM_WIDE_NEGO) ? 1 : 0; } /* * Get target setup from NVRAM. */ -void sym_nvram_setup_target(struct sym_hcb *np, int target, struct sym_nvram *nvp) +void sym_nvram_setup_target(struct sym_tcb *tp, int target, struct sym_nvram *nvp) { switch (nvp->type) { case SYM_SYMBIOS_NVRAM: - sym_Symbios_setup_target(np, target, &nvp->data.Symbios); + sym_Symbios_setup_target(tp, target, &nvp->data.Symbios); break; case SYM_TEKRAM_NVRAM: - sym_Tekram_setup_target(np, target, &nvp->data.Tekram); + sym_Tekram_setup_target(tp, target, &nvp->data.Tekram); break; default: break; diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.h b/drivers/scsi/sym53c8xx_2/sym_nvram.h index 1538bed..bdfbbb0 100644 --- a/drivers/scsi/sym53c8xx_2/sym_nvram.h +++ b/drivers/scsi/sym53c8xx_2/sym_nvram.h @@ -194,12 +194,12 @@ struct sym_nvram { #if SYM_CONF_NVRAM_SUPPORT void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram); -void sym_nvram_setup_target (struct sym_hcb *np, int target, struct sym_nvram *nvp); +void sym_nvram_setup_target (struct sym_tcb *tp, int target, struct sym_nvram *nvp); int sym_read_nvram (struct sym_device *np, struct sym_nvram *nvp); char *sym_nvram_type(struct sym_nvram *nvp); #else static inline void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { } -static inline void sym_nvram_setup_target(struct sym_hcb *np, struct sym_nvram *nvram) { } +static inline void sym_nvram_setup_target(struct sym_tcb *tp, struct sym_nvram *nvram) { } static inline int sym_read_nvram(struct sym_device *np, struct sym_nvram *nvp) { nvp->type = 0; -- cgit v1.1 From 66e8d1cc64e95be78e6138cc88635f7e3108ef58 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:46 -0500 Subject: [SCSI] sym2: Report disabled devices and LUNs more attractively Rather than print a list of targets at driver init time, print each disabled target as we attempt to scan it. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_glue.c | 14 +++++++++++--- drivers/scsi/sym53c8xx_2/sym_hipd.c | 30 ------------------------------ 2 files changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index cb3d195..1fffd2b 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -1018,6 +1018,7 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev) if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN) return -ENXIO; + tp->starget = sdev->sdev_target; /* * Fail the device init if the device is flagged NOSCAN at BOOT in * the NVRAM. This may speed up boot and maintain coherency with @@ -1027,17 +1028,24 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev) * lun devices behave badly when asked for a non zero LUN. */ - if ((tp->usrflags & SYM_SCAN_BOOT_DISABLED) || - ((tp->usrflags & SYM_SCAN_LUNS_DISABLED) && sdev->lun != 0)) { + if (tp->usrflags & SYM_SCAN_BOOT_DISABLED) { tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED; + starget_printk(KERN_INFO, tp->starget, + "Scan at boot disabled in NVRAM\n"); return -ENXIO; } + if (tp->usrflags & SYM_SCAN_LUNS_DISABLED) { + if (sdev->lun != 0) + return -ENXIO; + starget_printk(KERN_INFO, tp->starget, + "Multiple LUNs disabled in NVRAM\n"); + } + lp = sym_alloc_lcb(np, sdev->id, sdev->lun); if (!lp) return -ENOMEM; - tp->starget = sdev->sdev_target; spi_min_period(tp->starget) = tp->usr_period; spi_max_width(tp->starget) = tp->usr_width; diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 0b0cba0..7a3c807 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -616,29 +616,6 @@ static __inline void sym_init_burst(struct sym_hcb *np, u_char bc) } } - -/* - * Print out the list of targets that have some flag disabled by user. - */ -static void sym_print_targets_flag(struct sym_hcb *np, int mask, char *msg) -{ - int cnt; - int i; - - for (cnt = 0, i = 0 ; i < SYM_CONF_MAX_TARGET ; i++) { - if (i == np->myaddr) - continue; - if (np->target[i].usrflags & mask) { - if (!cnt++) - printf("%s: %s disabled for targets", - sym_name(np), msg); - printf(" %d", i); - } - } - if (cnt) - printf(".\n"); -} - /* * Save initial settings of some IO registers. * Assumed to have been set by BIOS. @@ -986,13 +963,6 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru sym_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); } - /* - * Let user be aware of targets that have some disable flags set. - */ - sym_print_targets_flag(np, SYM_SCAN_BOOT_DISABLED, "SCAN AT BOOT"); - if (sym_verbose) - sym_print_targets_flag(np, SYM_SCAN_LUNS_DISABLED, - "SCAN FOR LUNS"); return 0; } -- cgit v1.1 From ad94c9340a76db187166f2342ba0ff568dc7801f Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 29 Nov 2005 23:08:48 -0500 Subject: [SCSI] sym2: Version 2.2.2 Update version number to 2.2.2 Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/sym53c8xx_2/sym_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sym53c8xx_2/sym_defs.h b/drivers/scsi/sym53c8xx_2/sym_defs.h index 2d9437d..3659dd7b 100644 --- a/drivers/scsi/sym53c8xx_2/sym_defs.h +++ b/drivers/scsi/sym53c8xx_2/sym_defs.h @@ -40,7 +40,7 @@ #ifndef SYM_DEFS_H #define SYM_DEFS_H -#define SYM_VERSION "2.2.1" +#define SYM_VERSION "2.2.2" #define SYM_DRIVER_NAME "sym-" SYM_VERSION /* -- cgit v1.1 From 0d2f16559a9015c4daa8babfc443bf2b8740fbd9 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Tue, 29 Nov 2005 23:12:46 -0600 Subject: [SCSI] iscsi: opcode check fix Must check only valid opcode bits. Signed-off-by: Mike Christie Signed-off-by: Alex Aizman Signed-off-by: Dmitry Yusupov Signed-off-by: James Bottomley --- drivers/scsi/iscsi_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 4fea3e4..0769e94 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -584,7 +584,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn) } /* save opcode for later */ - conn->in.opcode = hdr->opcode; + conn->in.opcode = hdr->opcode & ISCSI_OPCODE_MASK; /* verify itt (itt encoding: age+cid+itt) */ if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG)) { -- cgit v1.1 From e6273993dbcb8d805dd868e2128c3503a3bb1964 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Tue, 29 Nov 2005 23:12:49 -0600 Subject: [SCSI] iscsi: redirect fix From tomof@acm.org: There is one more issue about Equallogic systems. They send re-direction info with FIN. I think that the kernel module needs to let iscsid to read data from the socket before killing it. Signed-off-by: Mike Christie Signed-off-by: Alex Aizman Signed-off-by: Dmitry Yusupov Signed-off-by: James Bottomley --- drivers/scsi/iscsi_tcp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 0769e94..f12d605 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -1237,8 +1237,9 @@ iscsi_tcp_state_change(struct sock *sk) conn = (struct iscsi_conn*)sk->sk_user_data; session = conn->session; - if (sk->sk_state == TCP_CLOSE_WAIT || - sk->sk_state == TCP_CLOSE) { + if ((sk->sk_state == TCP_CLOSE_WAIT || + sk->sk_state == TCP_CLOSE) && + !atomic_read(&sk->sk_rmem_alloc)) { debug_tcp("iscsi_tcp_state_change: TCP_CLOSE|TCP_CLOSE_WAIT\n"); iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); } -- cgit v1.1 From 733bb6a70cb351786f3c2290ab22f71b612e6893 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Tue, 29 Nov 2005 23:12:54 -0600 Subject: [SCSI] iscsi: iscsi response fix from Wang Zhenyu: Must check SCSI CMD and R2T response according to the spec Signed-off-by: Mike Christie Signed-off-by: Alex Aizman Signed-off-by: Dmitry Yusupov Signed-off-by: James Bottomley --- drivers/scsi/iscsi_tcp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index f12d605..e699151 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -642,9 +642,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn) switch(conn->in.opcode) { case ISCSI_OP_SCSI_CMD_RSP: BUG_ON((void*)ctask != ctask->sc->SCp.ptr); - if (ctask->hdr.flags & ISCSI_FLAG_CMD_WRITE) - rc = iscsi_cmd_rsp(conn, ctask); - else if (!conn->in.datalen) + if (!conn->in.datalen) rc = iscsi_cmd_rsp(conn, ctask); else /* @@ -666,8 +664,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn) break; case ISCSI_OP_R2T: BUG_ON((void*)ctask != ctask->sc->SCp.ptr); - if (ctask->hdr.flags & ISCSI_FLAG_CMD_WRITE && - ctask->sc->sc_data_direction == DMA_TO_DEVICE) + if (ctask->sc->sc_data_direction == DMA_TO_DEVICE) rc = iscsi_r2t_rsp(conn, ctask); else rc = ISCSI_ERR_PROTO; -- cgit v1.1 From f6cfba1d21e9e4afd80e2274aa4df3dc1bd0aab7 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Tue, 29 Nov 2005 23:12:57 -0600 Subject: [SCSI] iscsi: data digest calculation fix From Wang Zhenyu: data digest fix (the bug caused data corruption w/Wasabi StorageBuilder target) Signed-off-by: Mike Christie Signed-off-by: Alex Aizman Signed-off-by: Dmitry Yusupov Signed-off-by: James Bottomley --- drivers/scsi/iscsi_tcp.c | 65 +++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index e699151..83e2f8c 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -903,11 +903,20 @@ partial_sg_digest_update(struct iscsi_conn *conn, struct scatterlist *sg, crypto_digest_update(conn->data_rx_tfm, &temp, 1); } +static void +iscsi_recv_digest_update(struct iscsi_conn *conn, char* buf, int len) +{ + struct scatterlist tmp; + + sg_init_one(&tmp, buf, len); + crypto_digest_update(conn->data_rx_tfm, &tmp, 1); +} + static int iscsi_scsi_data_in(struct iscsi_conn *conn) { struct iscsi_cmd_task *ctask = conn->in.ctask; struct scsi_cmnd *sc = ctask->sc; - struct scatterlist tmp, *sg; + struct scatterlist *sg; int i, offset, rc = 0; BUG_ON((void*)ctask != sc->SCp.ptr); @@ -921,10 +930,8 @@ static int iscsi_scsi_data_in(struct iscsi_conn *conn) sc->request_bufflen, ctask->data_offset); if (rc == -EAGAIN) return rc; - if (conn->datadgst_en) { - sg_init_one(&tmp, sc->request_buffer, i); - crypto_digest_update(conn->data_rx_tfm, &tmp, 1); - } + if (conn->datadgst_en) + iscsi_recv_digest_update(conn, sc->request_buffer, i); rc = 0; goto done; } @@ -1018,6 +1025,9 @@ iscsi_data_recv(struct iscsi_conn *conn) conn->in.hdr = &conn->hdr; conn->senselen = (conn->data[0] << 8) | conn->data[1]; rc = iscsi_cmd_rsp(conn, conn->in.ctask); + if (!rc && conn->datadgst_en) + iscsi_recv_digest_update(conn, conn->data, + conn->in.datalen); } break; case ISCSI_OP_TEXT_RSP: @@ -1042,6 +1052,11 @@ iscsi_data_recv(struct iscsi_conn *conn) rc = iscsi_recv_pdu(iscsi_handle(conn), conn->in.hdr, conn->data, conn->in.datalen); + if (!rc && conn->datadgst_en && + conn->in.opcode != ISCSI_OP_LOGIN_RSP) + iscsi_recv_digest_update(conn, conn->data, + conn->in.datalen); + if (mtask && conn->login_mtask != mtask) { spin_lock(&session->lock); __kfifo_put(session->mgmtpool.queue, (void*)&mtask, @@ -1050,6 +1065,8 @@ iscsi_data_recv(struct iscsi_conn *conn) } } break; + case ISCSI_OP_ASYNC_EVENT: + case ISCSI_OP_REJECT: default: BUG_ON(1); } @@ -1112,7 +1129,7 @@ more: rc = iscsi_hdr_recv(conn); if (!rc && conn->in.datalen) { if (conn->datadgst_en && - conn->in.opcode == ISCSI_OP_SCSI_DATA_IN) { + conn->in.opcode != ISCSI_OP_LOGIN_RSP) { BUG_ON(!conn->data_rx_tfm); crypto_digest_init(conn->data_rx_tfm); } @@ -1124,26 +1141,24 @@ more: } if (conn->in_progress == IN_PROGRESS_DDIGEST_RECV) { + uint32_t recv_digest; debug_tcp("extra data_recv offset %d copy %d\n", conn->in.offset, conn->in.copy); - if (conn->in.opcode == ISCSI_OP_SCSI_DATA_IN) { - uint32_t recv_digest; - skb_copy_bits(conn->in.skb, conn->in.offset, - &recv_digest, 4); - conn->in.offset += 4; - conn->in.copy -= 4; - if (recv_digest != conn->in.datadgst) { - debug_tcp("iscsi_tcp: data digest error!" - "0x%x != 0x%x\n", recv_digest, - conn->in.datadgst); - iscsi_conn_failure(conn, ISCSI_ERR_DATA_DGST); - return 0; - } else { - debug_tcp("iscsi_tcp: data digest match!" - "0x%x == 0x%x\n", recv_digest, - conn->in.datadgst); - conn->in_progress = IN_PROGRESS_WAIT_HEADER; - } + skb_copy_bits(conn->in.skb, conn->in.offset, + &recv_digest, 4); + conn->in.offset += 4; + conn->in.copy -= 4; + if (recv_digest != conn->in.datadgst) { + debug_tcp("iscsi_tcp: data digest error!" + "0x%x != 0x%x\n", recv_digest, + conn->in.datadgst); + iscsi_conn_failure(conn, ISCSI_ERR_DATA_DGST); + return 0; + } else { + debug_tcp("iscsi_tcp: data digest match!" + "0x%x == 0x%x\n", recv_digest, + conn->in.datadgst); + conn->in_progress = IN_PROGRESS_WAIT_HEADER; } } @@ -1165,7 +1180,7 @@ more: conn->in.copy -= conn->in.padding; conn->in.offset += conn->in.padding; if (conn->datadgst_en && - conn->in.opcode == ISCSI_OP_SCSI_DATA_IN) { + conn->in.opcode != ISCSI_OP_LOGIN_RSP) { if (conn->in.padding) { debug_tcp("padding -> %d\n", conn->in.padding); memset(pad, 0, conn->in.padding); -- cgit v1.1 From 9e3961ba2be51a88c6223143568c80e0616d93ce Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Tue, 29 Nov 2005 23:12:59 -0600 Subject: [SCSI] iscsi: lower queue depth From Wang Zhenyu: High queue depth was a problem for some targets so make queue_depth adjustable From Mike Christie Make default queue_depth a little lower Signed-off-by: Mike Christie Signed-off-by: Alex Aizman Signed-off-by: Dmitry Yusupov Signed-off-by: James Bottomley --- drivers/scsi/iscsi_tcp.c | 20 +++++++++++++++----- drivers/scsi/iscsi_tcp.h | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 83e2f8c..5b14c40 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -2402,6 +2402,15 @@ fault: } static int +iscsi_change_queue_depth(struct scsi_device *sdev, int depth) +{ + if (depth > ISCSI_MAX_CMD_PER_LUN) + depth = ISCSI_MAX_CMD_PER_LUN; + scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth); + return sdev->queue_depth; +} + +static int iscsi_pool_init(struct iscsi_queue *q, int max, void ***items, int item_size) { int i; @@ -3260,13 +3269,14 @@ iscsi_r2tpool_free(struct iscsi_session *session) static struct scsi_host_template iscsi_sht = { .name = "iSCSI Initiator over TCP/IP, v." ISCSI_VERSION_STR, - .queuecommand = iscsi_queuecommand, + .queuecommand = iscsi_queuecommand, + .change_queue_depth = iscsi_change_queue_depth, .can_queue = ISCSI_XMIT_CMDS_MAX - 1, .sg_tablesize = ISCSI_SG_TABLESIZE, - .cmd_per_lun = ISCSI_CMD_PER_LUN, - .eh_abort_handler = iscsi_eh_abort, - .eh_host_reset_handler = iscsi_eh_host_reset, - .use_clustering = DISABLE_CLUSTERING, + .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN, + .eh_abort_handler = iscsi_eh_abort, + .eh_host_reset_handler = iscsi_eh_host_reset, + .use_clustering = DISABLE_CLUSTERING, .proc_name = "iscsi_tcp", .this_id = -1, }; diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h index d23ae68..855f2df 100644 --- a/drivers/scsi/iscsi_tcp.h +++ b/drivers/scsi/iscsi_tcp.h @@ -71,7 +71,8 @@ #define ISCSI_MGMT_CMDS_MAX 32 /* must be power of 2 */ #define ISCSI_MGMT_ITT_OFFSET 0xa00 #define ISCSI_SG_TABLESIZE SG_ALL -#define ISCSI_CMD_PER_LUN 128 +#define ISCSI_DEF_CMD_PER_LUN 32 +#define ISCSI_MAX_CMD_PER_LUN 128 #define ISCSI_TCP_MAX_CMD_LEN 16 #define ITT_MASK (0xfff) -- cgit v1.1 From 4d841d6bd94d55642f8dbb11d6b672b3b50ff82e Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Tue, 29 Nov 2005 23:13:01 -0600 Subject: [SCSI] iscsi: update version Signed-off-by: Mike Christie Signed-off-by: Alex Aizman Signed-off-by: Dmitry Yusupov Signed-off-by: James Bottomley --- drivers/scsi/iscsi_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 5b14c40..feb8731 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -49,7 +49,7 @@ MODULE_AUTHOR("Dmitry Yusupov , " "Alex Aizman "); MODULE_DESCRIPTION("iSCSI/TCP data-path"); MODULE_LICENSE("GPL"); -MODULE_VERSION("0:4.409"); +MODULE_VERSION("0:4.445"); /* #define DEBUG_TCP */ /* #define DEBUG_SCSI */ #define DEBUG_ASSERT -- cgit v1.1 From 8a47cd340b4a299087f926ff2780d1eb08513f04 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Wed, 30 Nov 2005 02:27:19 -0600 Subject: [SCSI] iscsi: check header digests for mgmt tasks From Wang Zhenyu: check header digest for cmd and mgmt tasks Signed-off-by: Wang Zhenyu Signed-off-by: Mike Christie Signed-off-by: Alex Aizman Signed-off-by: Dmitry Yusupov Signed-off-by: James Bottomley --- drivers/scsi/iscsi_tcp.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index feb8731..2d12355 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -581,6 +581,12 @@ iscsi_hdr_recv(struct iscsi_conn *conn) crypto_digest_digest(conn->rx_tfm, &sg, 1, (u8 *)&cdgst); rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) + conn->in.ahslen); + if (cdgst != rdgst) { + printk(KERN_ERR "iscsi_tcp: itt %x: hdrdgst error " + "recv 0x%x calc 0x%x\n", conn->in.itt, rdgst, + cdgst); + return ISCSI_ERR_HDR_DGST; + } } /* save opcode for later */ @@ -610,13 +616,6 @@ iscsi_hdr_recv(struct iscsi_conn *conn) conn->in.ahslen, conn->in.datalen); if (conn->in.itt < session->cmds_max) { - if (conn->hdrdgst_en && cdgst != rdgst) { - printk(KERN_ERR "iscsi_tcp: itt %x: hdrdgst error " - "recv 0x%x calc 0x%x\n", conn->in.itt, rdgst, - cdgst); - return ISCSI_ERR_HDR_DGST; - } - ctask = (struct iscsi_cmd_task *)session->cmds[conn->in.itt]; if (!ctask->sc) { @@ -1128,8 +1127,7 @@ more: */ rc = iscsi_hdr_recv(conn); if (!rc && conn->in.datalen) { - if (conn->datadgst_en && - conn->in.opcode != ISCSI_OP_LOGIN_RSP) { + if (conn->datadgst_en) { BUG_ON(!conn->data_rx_tfm); crypto_digest_init(conn->data_rx_tfm); } @@ -1179,8 +1177,7 @@ more: } conn->in.copy -= conn->in.padding; conn->in.offset += conn->in.padding; - if (conn->datadgst_en && - conn->in.opcode != ISCSI_OP_LOGIN_RSP) { + if (conn->datadgst_en) { if (conn->in.padding) { debug_tcp("padding -> %d\n", conn->in.padding); memset(pad, 0, conn->in.padding); @@ -2875,8 +2872,11 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag) * in hdr_extract() and will be re-negotiated at * set_param() time. */ - if (flag == STOP_CONN_RECOVER) + if (flag == STOP_CONN_RECOVER) { conn->hdr_size = sizeof(struct iscsi_hdr); + conn->hdrdgst_en = 0; + conn->datadgst_en = 0; + } } up(&conn->xmitsema); } -- cgit v1.1 From 7f23e146a122966bd58e5da9c16a0e12385f09fc Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 1 Dec 2005 12:50:13 -0600 Subject: [SCSI] correct some dropped const compiler warnings Make the vendor, model and rev fields in scsi_device pointers to const and update a few prototypes of functions using them. Signed-off-by: James Bottomley --- drivers/scsi/scsi_devinfo.c | 5 +++-- drivers/scsi/scsi_priv.h | 3 ++- include/scsi/scsi_device.h | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c index e69477d..f01ec0a 100644 --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@ -354,8 +354,9 @@ static int scsi_dev_info_list_add_str(char *dev_list) * @model, if found, return the matching flags value, else return * the host or global default settings. **/ -int scsi_get_device_flags(struct scsi_device *sdev, unsigned char *vendor, - unsigned char *model) +int scsi_get_device_flags(struct scsi_device *sdev, + const unsigned char *vendor, + const unsigned char *model) { struct scsi_dev_info_list *devinfo; unsigned int bflags; diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index d632d9e..a8d121c 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -57,7 +57,8 @@ static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) /* scsi_devinfo.c */ extern int scsi_get_device_flags(struct scsi_device *sdev, - unsigned char *vendor, unsigned char *model); + const unsigned char *vendor, + const unsigned char *model); extern int __init scsi_init_devinfo(void); extern void scsi_exit_devinfo(void); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 85cfd88..063e32f 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -79,9 +79,9 @@ struct scsi_device { char inq_periph_qual; /* PQ from INQUIRY data */ unsigned char inquiry_len; /* valid bytes in 'inquiry' */ unsigned char * inquiry; /* INQUIRY response data */ - char * vendor; /* [back_compat] point into 'inquiry' ... */ - char * model; /* ... after scan; point to static string */ - char * rev; /* ... "nullnullnullnull" before scan */ + const char * vendor; /* [back_compat] point into 'inquiry' ... */ + const char * model; /* ... after scan; point to static string */ + const char * rev; /* ... "nullnullnullnull" before scan */ unsigned char current_tag; /* current tag */ struct scsi_target *sdev_target; /* used only for single_lun */ -- cgit v1.1 From 0a21ef1e603096a8f57fcd7fa0b8b53e7147d3b9 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 1 Dec 2005 12:51:50 -0600 Subject: [SCSI] qla2xxx: fix compile error caused by pci_dev.owner move Signed-off-by: James Bottomley --- drivers/scsi/qla2xxx/qla_os.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 41d2aee..2430430 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2611,7 +2611,9 @@ qla2xxx_remove_one(struct pci_dev *pdev) static struct pci_driver qla2xxx_pci_driver = { .name = "qla2xxx", - .owner = THIS_MODULE, + .driver = { + .owner = THIS_MODULE, + }, .id_table = qla2xxx_pci_tbl, .probe = qla2xxx_probe_one, .remove = __devexit_p(qla2xxx_remove_one), -- cgit v1.1 From 1de933f35b17622f977eff1630eb1f2c92e9450c Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:41:15 -0500 Subject: [SCSI] lpfc 8.1.1: Miscellaneous Cleanups Miscellaneous Cleanups: - Remove ProgType READ_REV mailbox command value check in lpfc_config_port_prep. - Convert simple printk to an lpfc_printf_log in queuecommand. - Modify lpfc_abort_handler message 0749 to display more accurate text and data. - Minor style cleanup: fix 3 long lines in lpfc_hw.h Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_hw.h | 9 ++++++--- drivers/scsi/lpfc/lpfc_init.c | 34 +++++++++++++--------------------- drivers/scsi/lpfc/lpfc_scsi.c | 9 +++++---- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index 86c4198..bf0c25f 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -266,9 +266,11 @@ struct lpfc_name { struct { #ifdef __BIG_ENDIAN_BITFIELD uint8_t nameType:4; /* FC Word 0, bit 28:31 */ - uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit 8:11 of IEEE ext */ + uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit + 8:11 of IEEE ext */ #else /* __LITTLE_ENDIAN_BITFIELD */ - uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit 8:11 of IEEE ext */ + uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit + 8:11 of IEEE ext */ uint8_t nameType:4; /* FC Word 0, bit 28:31 */ #endif @@ -278,7 +280,8 @@ struct lpfc_name { #define NAME_IP_TYPE 0x4 /* IP address */ #define NAME_CCITT_TYPE 0xC #define NAME_CCITT_GR_TYPE 0xE - uint8_t IEEEextLsb; /* FC Word 0, bit 16:23, IEEE extended Lsb */ + uint8_t IEEEextLsb; /* FC Word 0, bit 16:23, IEEE + extended Lsb */ uint8_t IEEE[6]; /* FC IEEE address */ } s; uint8_t wwn[8]; diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 0749811..3eebe66 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -126,34 +126,26 @@ lpfc_config_port_prep(struct lpfc_hba * phba) return -ERESTART; } - /* The HBA's current state is provided by the ProgType and rr fields. - * Read and check the value of these fields before continuing to config - * this port. + /* + * The value of rr must be 1 since the driver set the cv field to 1. + * This setting requires the FW to set all revision fields. */ - if (mb->un.varRdRev.rr == 0 || mb->un.varRdRev.un.b.ProgType != 2) { - /* Old firmware */ + if (mb->un.varRdRev.rr == 0) { vp->rev.rBit = 0; - lpfc_printf_log(phba, - KERN_ERR, - LOG_INIT, - "%d:0440 Adapter failed to init, mbxCmd x%x " - "READ_REV detected outdated firmware" - "Data: x%x\n", - phba->brd_no, - mb->mbxCommand, 0); + lpfc_printf_log(phba, KERN_ERR, LOG_INIT, + "%d:0440 Adapter failed to init, READ_REV has " + "missing revision information.\n", + phba->brd_no); mempool_free(pmb, phba->mbox_mem_pool); return -ERESTART; - } else { - vp->rev.rBit = 1; - vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev; - memcpy(vp->rev.sli1FwName, - (char*)mb->un.varRdRev.sli1FwName, 16); - vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev; - memcpy(vp->rev.sli2FwName, - (char *)mb->un.varRdRev.sli2FwName, 16); } /* Save information as VPD data */ + vp->rev.rBit = 1; + vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev; + memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16); + vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev; + memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16); vp->rev.biuRev = mb->un.varRdRev.biuRev; vp->rev.smRev = mb->un.varRdRev.smRev; vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev; diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index c63275e..0aa5ca6 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -721,8 +721,9 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) } lpfc_cmd = lpfc_sli_get_scsi_buf (phba); if (lpfc_cmd == NULL) { - printk(KERN_WARNING "%s: No buffer available - list empty, " - "total count %d\n", __FUNCTION__, phba->total_scsi_bufs); + lpfc_printf_log(phba, KERN_INFO, LOG_FCP, + "%d:0707 driver's buffer pool is empty, " + "IO busied\n", phba->brd_no); goto out_host_busy; } @@ -844,8 +845,8 @@ __lpfc_abort_handler(struct scsi_cmnd *cmnd) out: lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, - "%d:0749 SCSI layer issued abort device: ret %#x, " - "ID %d, LUN %d, snum %#lx\n", + "%d:0749 SCSI Layer I/O Abort Request " + "Status x%x ID %d LUN %d snum %#lx\n", phba->brd_no, ret, cmnd->device->id, cmnd->device->lun, cmnd->serial_number); -- cgit v1.1 From 2fb70f79936e7180e8b0287a4053b8ba89182717 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:41:24 -0500 Subject: [SCSI] lpfc 8.1.1 : Correct some 8bit to 16bit field conversions/comparisons Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_nportdisc.c | 69 +++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index 507a6af..fbead78 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -55,55 +55,76 @@ lpfc_check_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, return (1); } - int lpfc_check_sparm(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, struct serv_parm * sp, uint32_t class) { volatile struct serv_parm *hsp = &phba->fc_sparam; - /* First check for supported version */ - - /* Next check for class validity */ + uint16_t hsp_value, ssp_value = 0; + + /* + * The receive data field size and buffer-to-buffer receive data field + * size entries are 16 bits but are represented as two 8-bit fields in + * the driver data structure to account for rsvd bits and other control + * bits. Reconstruct and compare the fields as a 16-bit values before + * correcting the byte values. + */ if (sp->cls1.classValid) { - - if (sp->cls1.rcvDataSizeMsb > hsp->cls1.rcvDataSizeMsb) - sp->cls1.rcvDataSizeMsb = hsp->cls1.rcvDataSizeMsb; - if (sp->cls1.rcvDataSizeLsb > hsp->cls1.rcvDataSizeLsb) + hsp_value = (hsp->cls1.rcvDataSizeMsb << 8) | + hsp->cls1.rcvDataSizeLsb; + ssp_value = (sp->cls1.rcvDataSizeMsb << 8) | + sp->cls1.rcvDataSizeLsb; + if (ssp_value > hsp_value) { sp->cls1.rcvDataSizeLsb = hsp->cls1.rcvDataSizeLsb; + sp->cls1.rcvDataSizeMsb = hsp->cls1.rcvDataSizeMsb; + } } else if (class == CLASS1) { - return (0); + return 0; } if (sp->cls2.classValid) { - - if (sp->cls2.rcvDataSizeMsb > hsp->cls2.rcvDataSizeMsb) - sp->cls2.rcvDataSizeMsb = hsp->cls2.rcvDataSizeMsb; - if (sp->cls2.rcvDataSizeLsb > hsp->cls2.rcvDataSizeLsb) + hsp_value = (hsp->cls2.rcvDataSizeMsb << 8) | + hsp->cls2.rcvDataSizeLsb; + ssp_value = (sp->cls2.rcvDataSizeMsb << 8) | + sp->cls2.rcvDataSizeLsb; + if (ssp_value > hsp_value) { sp->cls2.rcvDataSizeLsb = hsp->cls2.rcvDataSizeLsb; + sp->cls2.rcvDataSizeMsb = hsp->cls2.rcvDataSizeMsb; + } } else if (class == CLASS2) { - return (0); + return 0; } if (sp->cls3.classValid) { - - if (sp->cls3.rcvDataSizeMsb > hsp->cls3.rcvDataSizeMsb) - sp->cls3.rcvDataSizeMsb = hsp->cls3.rcvDataSizeMsb; - if (sp->cls3.rcvDataSizeLsb > hsp->cls3.rcvDataSizeLsb) + hsp_value = (hsp->cls3.rcvDataSizeMsb << 8) | + hsp->cls3.rcvDataSizeLsb; + ssp_value = (sp->cls3.rcvDataSizeMsb << 8) | + sp->cls3.rcvDataSizeLsb; + if (ssp_value > hsp_value) { sp->cls3.rcvDataSizeLsb = hsp->cls3.rcvDataSizeLsb; + sp->cls3.rcvDataSizeMsb = hsp->cls3.rcvDataSizeMsb; + } } else if (class == CLASS3) { - return (0); + return 0; } - if (sp->cmn.bbRcvSizeMsb > hsp->cmn.bbRcvSizeMsb) - sp->cmn.bbRcvSizeMsb = hsp->cmn.bbRcvSizeMsb; - if (sp->cmn.bbRcvSizeLsb > hsp->cmn.bbRcvSizeLsb) + /* + * Preserve the upper four bits of the MSB from the PLOGI response. + * These bits contain the Buffer-to-Buffer State Change Number + * from the target and need to be passed to the FW. + */ + hsp_value = (hsp->cmn.bbRcvSizeMsb << 8) | hsp->cmn.bbRcvSizeLsb; + ssp_value = (sp->cmn.bbRcvSizeMsb << 8) | sp->cmn.bbRcvSizeLsb; + if (ssp_value > hsp_value) { sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb; + sp->cmn.bbRcvSizeMsb = (sp->cmn.bbRcvSizeMsb & 0xF0) | + (hsp->cmn.bbRcvSizeMsb & 0x0F); + } - /* If check is good, copy wwpn wwnn into ndlp */ memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name)); memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name)); - return (1); + return 1; } static void * -- cgit v1.1 From 6281bfe0002acd7765cb4afe0304c36962ad6b15 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:41:33 -0500 Subject: [SCSI] lpfc 8.1.1 : Fixes for short cable pulls Cause: Link bounces were causing discovery ELS's to be killed. Driver was not properly flushing ELS commands upon the subsequent link bounces. Thus, processing of ELS post link bounce erroneously assumed discovery failure and device loss. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_els.c | 4 ++++ drivers/scsi/lpfc/lpfc_init.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index bcc29ec..20f1a07 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -720,6 +720,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || + (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); } @@ -869,6 +870,7 @@ lpfc_cmpl_els_prli(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || + (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { goto out; } @@ -1054,6 +1056,7 @@ lpfc_cmpl_els_adisc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || + (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); } @@ -1205,6 +1208,7 @@ lpfc_cmpl_els_logo(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb, /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || + (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) || (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { goto out; } diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 3eebe66..4d4e217 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -563,6 +563,8 @@ lpfc_handle_latt(struct lpfc_hba * phba) rc = -EIO; + /* Cleanup any outstanding ELS commands */ + lpfc_els_flush_cmd(phba); psli->slistat.link_event++; lpfc_read_la(phba, pmb, mp); -- cgit v1.1 From 23dc04f1ec0d2f8fdda82ad1f9aa87b6ed74cd4a Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:41:44 -0500 Subject: [SCSI] lpfc 8.1.1 : Adjust use of scsi_block_requests and interaction w/ FC transport - Remove unnecessary scsi_block_requests calls on rport deletes. This was deadlocking the sdev removals as they wanted to flush commands. - No longer block requests when adding the remote port (to block discovery). Instead, register, then change port role. Maps to Qlogic behavior, and closer to the register-node-upon-first-ELS behavior. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_hbadisc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 259eeb1..a1f751e 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -1017,12 +1017,7 @@ lpfc_register_remote_port(struct lpfc_hba * phba, rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn); rport_ids.port_id = ndlp->nlp_DID; rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; - if (ndlp->nlp_type & NLP_FCP_TARGET) - rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; - if (ndlp->nlp_type & NLP_FCP_INITIATOR) - rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; - scsi_block_requests(phba->host); ndlp->rport = rport = fc_remote_port_add(phba->host, 0, &rport_ids); if (!rport) { dev_printk(KERN_WARNING, &phba->pcidev->dev, @@ -1039,7 +1034,16 @@ lpfc_register_remote_port(struct lpfc_hba * phba, } rdata = rport->dd_data; rdata->pnode = ndlp; - scsi_unblock_requests(phba->host); + + if (ndlp->nlp_type & NLP_FCP_TARGET) + rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; + if (ndlp->nlp_type & NLP_FCP_INITIATOR) + rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; + + + if (rport_ids.roles != FC_RPORT_ROLE_UNKNOWN) + fc_remote_port_rolechg(rport, rport_ids.roles); + return; } @@ -1053,9 +1057,7 @@ lpfc_unregister_remote_port(struct lpfc_hba * phba, ndlp->rport = NULL; rdata->pnode = NULL; - scsi_block_requests(phba->host); fc_remote_port_delete(rport); - scsi_unblock_requests(phba->host); return; } -- cgit v1.1 From 63c59c3b8ff444b771a245f59935c0202ece963b Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:41:53 -0500 Subject: [SCSI] lpfc 8.1.1 : Remove locking wrappers around error handlers Remove locking wrappers around error handlers. Wrappers were added in early 2.6.13 api change Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_scsi.c | 52 ++++++++++++------------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 0aa5ca6..a4d8455 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -760,11 +760,12 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) return 0; } + static int -__lpfc_abort_handler(struct scsi_cmnd *cmnd) +lpfc_abort_handler(struct scsi_cmnd *cmnd) { - struct lpfc_hba *phba = - (struct lpfc_hba *)cmnd->device->host->hostdata[0]; + struct Scsi_Host *shost = cmnd->device->host; + struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0]; struct lpfc_sli_ring *pring = &phba->sli.ring[phba->sli.fcp_ring]; struct lpfc_iocbq *iocb; struct lpfc_iocbq *abtsiocb; @@ -773,6 +774,7 @@ __lpfc_abort_handler(struct scsi_cmnd *cmnd) unsigned int loop_count = 0; int ret = SUCCESS; + spin_lock_irq(shost->host_lock); lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; BUG_ON(!lpfc_cmd); @@ -850,21 +852,13 @@ __lpfc_abort_handler(struct scsi_cmnd *cmnd) phba->brd_no, ret, cmnd->device->id, cmnd->device->lun, cmnd->serial_number); - return ret; -} + spin_unlock_irq(shost->host_lock); -static int -lpfc_abort_handler(struct scsi_cmnd *cmnd) -{ - int rc; - spin_lock_irq(cmnd->device->host->host_lock); - rc = __lpfc_abort_handler(cmnd); - spin_unlock_irq(cmnd->device->host->host_lock); - return rc; + return ret; } static int -__lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) +lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) { struct Scsi_Host *shost = cmnd->device->host; struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0]; @@ -875,6 +869,7 @@ __lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) int ret = FAILED; int cnt, loopcnt; + spin_lock_irq(shost->host_lock); /* * If target is not in a MAPPED state, delay the reset until * target is rediscovered or nodev timeout expires. @@ -964,24 +959,12 @@ out_free_scsi_buf: lpfc_cmd->result); lpfc_release_scsi_buf(phba, lpfc_cmd); out: + spin_unlock_irq(shost->host_lock); return ret; } static int -lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) -{ - int rc; - spin_lock_irq(cmnd->device->host->host_lock); - rc = __lpfc_reset_lun_handler(cmnd); - spin_unlock_irq(cmnd->device->host->host_lock); - return rc; -} - -/* - * Note: midlayer calls this function with the host_lock held - */ -static int -__lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) +lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) { struct Scsi_Host *shost = cmnd->device->host; struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0]; @@ -992,6 +975,8 @@ __lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) unsigned int midlayer_id = 0; struct lpfc_scsi_buf * lpfc_cmd; + spin_lock_irq(shost->host_lock); + lpfc_cmd = lpfc_sli_get_scsi_buf (phba); if (lpfc_cmd == NULL) goto out; @@ -1067,20 +1052,11 @@ __lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) "%d:0714 SCSI layer issued Bus Reset Data: x%x\n", phba->brd_no, ret); out: + spin_unlock_irq(shost->host_lock); return ret; } static int -lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) -{ - int rc; - spin_lock_irq(cmnd->device->host->host_lock); - rc = __lpfc_reset_bus_handler(cmnd); - spin_unlock_irq(cmnd->device->host->host_lock); - return rc; -} - -static int lpfc_slave_alloc(struct scsi_device *sdev) { struct lpfc_hba *phba = (struct lpfc_hba *)sdev->host->hostdata[0]; -- cgit v1.1 From 6175c02a0b12f92c03b56c756c4f1e131ae1456c Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:42:05 -0500 Subject: [SCSI] lpfc 8.1.1 : Fixes to error handlers - Release task management command before counting outstanding commands. TMF was being erroneously counted as an active outstanding command. - Serialize EH calls and block requests when EH function is running. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc.h | 1 + drivers/scsi/lpfc/lpfc_init.c | 2 +- drivers/scsi/lpfc/lpfc_scsi.c | 104 +++++++++++++++++++++++++++--------------- 3 files changed, 70 insertions(+), 37 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 3062b39..dc73a2f 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -167,6 +167,7 @@ struct lpfc_hba { dma_addr_t slim2p_mapping; uint16_t pci_cfg_value; + struct semaphore hba_can_block; uint32_t hba_state; #define LPFC_INIT_START 1 /* Initial state after board reset */ diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 4d4e217..dfd59d2 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -1345,7 +1345,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) goto out_put_host; host->unique_id = phba->brd_no; - + init_MUTEX(&phba->hba_can_block); INIT_LIST_HEAD(&phba->ctrspbuflist); INIT_LIST_HEAD(&phba->rnidrspbuflist); INIT_LIST_HEAD(&phba->freebufList); diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index a4d8455..7dc7810 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -41,6 +41,20 @@ #define LPFC_ABORT_WAIT 2 +static inline void +lpfc_block_requests(struct lpfc_hba * phba) +{ + down(&phba->hba_can_block); + scsi_block_requests(phba->host); +} + +static inline void +lpfc_unblock_requests(struct lpfc_hba * phba) +{ + scsi_unblock_requests(phba->host); + up(&phba->hba_can_block); +} + /* * This routine allocates a scsi buffer, which contains all the necessary * information needed to initiate a SCSI I/O. The non-DMAable buffer region @@ -774,6 +788,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) unsigned int loop_count = 0; int ret = SUCCESS; + lpfc_block_requests(phba); spin_lock_irq(shost->host_lock); lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; @@ -853,6 +868,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) cmnd->device->lun, cmnd->serial_number); spin_unlock_irq(shost->host_lock); + lpfc_unblock_requests(phba); return ret; } @@ -866,9 +882,11 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) struct lpfc_iocbq *iocbq, *iocbqrsp; struct lpfc_rport_data *rdata = cmnd->device->hostdata; struct lpfc_nodelist *pnode = rdata->pnode; + uint32_t cmd_result = 0, cmd_status = 0; int ret = FAILED; int cnt, loopcnt; + lpfc_block_requests(phba); spin_lock_irq(shost->host_lock); /* * If target is not in a MAPPED state, delay the reset until @@ -912,26 +930,28 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) if (ret == IOCB_SUCCESS) ret = SUCCESS; - lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4]; - lpfc_cmd->status = iocbqrsp->iocb.ulpStatus; - if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT) - if (lpfc_cmd->result & IOERR_DRVR_MASK) - lpfc_cmd->status = IOSTAT_DRIVER_REJECT; + + cmd_result = iocbqrsp->iocb.un.ulpWord[4]; + cmd_status = iocbqrsp->iocb.ulpStatus; + + lpfc_sli_release_iocbq(phba, iocbqrsp); + lpfc_release_scsi_buf(phba, lpfc_cmd); /* - * All outstanding txcmplq I/Os should have been aborted by the target. + * All outstanding txcmplq I/Os should have been aborted by the device. * Unfortunately, some targets do not abide by this forcing the driver * to double check. */ - lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], - cmnd->device->id, cmnd->device->lun, 0, - LPFC_CTX_LUN); - + cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], + cmnd->device->id, cmnd->device->lun, + LPFC_CTX_LUN); + if (cnt) + lpfc_sli_abort_iocb(phba, + &phba->sli.ring[phba->sli.fcp_ring], + cmnd->device->id, cmnd->device->lun, + 0, LPFC_CTX_LUN); loopcnt = 0; - while((cnt = lpfc_sli_sum_iocb(phba, - &phba->sli.ring[phba->sli.fcp_ring], - cmnd->device->id, cmnd->device->lun, - LPFC_CTX_LUN))) { + while(cnt) { spin_unlock_irq(phba->host->host_lock); schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); spin_lock_irq(phba->host->host_lock); @@ -939,6 +959,11 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) if (++loopcnt > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT) break; + + cnt = lpfc_sli_sum_iocb(phba, + &phba->sli.ring[phba->sli.fcp_ring], + cmnd->device->id, cmnd->device->lun, + LPFC_CTX_LUN); } if (cnt) { @@ -948,18 +973,16 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) ret = FAILED; } - lpfc_sli_release_iocbq(phba, iocbqrsp); - out_free_scsi_buf: lpfc_printf_log(phba, KERN_ERR, LOG_FCP, "%d:0713 SCSI layer issued LUN reset (%d, %d) " "Data: x%x x%x x%x\n", - phba->brd_no, lpfc_cmd->pCmd->device->id, - lpfc_cmd->pCmd->device->lun, ret, lpfc_cmd->status, - lpfc_cmd->result); - lpfc_release_scsi_buf(phba, lpfc_cmd); + phba->brd_no, cmnd->device->id,cmnd->device->lun, + ret, cmd_status, cmd_result); + out: spin_unlock_irq(shost->host_lock); + lpfc_unblock_requests(phba); return ret; } @@ -975,6 +998,7 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) unsigned int midlayer_id = 0; struct lpfc_scsi_buf * lpfc_cmd; + lpfc_block_requests(phba); spin_lock_irq(shost->host_lock); lpfc_cmd = lpfc_sli_get_scsi_buf (phba); @@ -1008,18 +1032,31 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) lpfc_cmd->pCmd->device->hostdata = ndlp->rport->dd_data; ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba); if (ret != SUCCESS) { - lpfc_printf_log(phba, KERN_INFO, LOG_FCP, + lpfc_printf_log(phba, KERN_ERR, LOG_FCP, "%d:0713 Bus Reset on target %d failed\n", phba->brd_no, i); err_count++; } } + if (err_count == 0) + ret = SUCCESS; + + lpfc_release_scsi_buf(phba, lpfc_cmd); + + /* + * All outstanding txcmplq I/Os should have been aborted by + * the targets. Unfortunately, some targets do not abide by + * this forcing the driver to double check. + */ cmnd->device->id = midlayer_id; + cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], + 0, 0, LPFC_CTX_HOST); + if (cnt) + lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], + 0, 0, 0, LPFC_CTX_HOST); loopcnt = 0; - while((cnt = lpfc_sli_sum_iocb(phba, - &phba->sli.ring[phba->sli.fcp_ring], - 0, 0, LPFC_CTX_HOST))) { + while(cnt) { spin_unlock_irq(phba->host->host_lock); schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); spin_lock_irq(phba->host->host_lock); @@ -1027,25 +1064,19 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) if (++loopcnt > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT) break; + + cnt = lpfc_sli_sum_iocb(phba, + &phba->sli.ring[phba->sli.fcp_ring], + 0, 0, LPFC_CTX_HOST); } if (cnt) { - /* flush all outstanding commands on the host */ - i = lpfc_sli_abort_iocb(phba, - &phba->sli.ring[phba->sli.fcp_ring], 0, 0, 0, - LPFC_CTX_HOST); - - lpfc_printf_log(phba, KERN_INFO, LOG_FCP, + lpfc_printf_log(phba, KERN_ERR, LOG_FCP, "%d:0715 Bus Reset I/O flush failure: cnt x%x left x%x\n", phba->brd_no, cnt, i); - } - - if (cnt == 0) - ret = SUCCESS; - else ret = FAILED; + } - lpfc_release_scsi_buf(phba, lpfc_cmd); lpfc_printf_log(phba, KERN_ERR, LOG_FCP, @@ -1053,6 +1084,7 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) phba->brd_no, ret); out: spin_unlock_irq(shost->host_lock); + lpfc_unblock_requests(phba); return ret; } -- cgit v1.1 From e4adb20406385d1cc8fdb15e92ed7ac3d0ae41f6 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:42:12 -0500 Subject: [SCSI] lpfc 8.1.1 : Add support for more members of the Light Pulse 11xxx (4Gb) family Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_hw.h | 25 ++++++++++++------ drivers/scsi/lpfc/lpfc_init.c | 60 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 74 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index bf0c25f..4f00293 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -1027,23 +1027,32 @@ typedef struct { /* Start FireFly Register definitions */ #define PCI_VENDOR_ID_EMULEX 0x10df #define PCI_DEVICE_ID_FIREFLY 0x1ae5 -#define PCI_DEVICE_ID_SUPERFLY 0xf700 -#define PCI_DEVICE_ID_DRAGONFLY 0xf800 #define PCI_DEVICE_ID_RFLY 0xf095 #define PCI_DEVICE_ID_PFLY 0xf098 +#define PCI_DEVICE_ID_LP101 0xf0a1 #define PCI_DEVICE_ID_TFLY 0xf0a5 +#define PCI_DEVICE_ID_BSMB 0xf0d1 +#define PCI_DEVICE_ID_BMID 0xf0d5 +#define PCI_DEVICE_ID_ZSMB 0xf0e1 +#define PCI_DEVICE_ID_ZMID 0xf0e5 +#define PCI_DEVICE_ID_NEPTUNE 0xf0f5 +#define PCI_DEVICE_ID_NEPTUNE_SCSP 0xf0f6 +#define PCI_DEVICE_ID_NEPTUNE_DCSP 0xf0f7 +#define PCI_DEVICE_ID_SUPERFLY 0xf700 +#define PCI_DEVICE_ID_DRAGONFLY 0xf800 #define PCI_DEVICE_ID_CENTAUR 0xf900 #define PCI_DEVICE_ID_PEGASUS 0xf980 #define PCI_DEVICE_ID_THOR 0xfa00 #define PCI_DEVICE_ID_VIPER 0xfb00 +#define PCI_DEVICE_ID_LP10000S 0xfc00 +#define PCI_DEVICE_ID_LP11000S 0xfc10 +#define PCI_DEVICE_ID_LPE11000S 0xfc20 #define PCI_DEVICE_ID_HELIOS 0xfd00 -#define PCI_DEVICE_ID_BMID 0xf0d5 -#define PCI_DEVICE_ID_BSMB 0xf0d1 +#define PCI_DEVICE_ID_HELIOS_SCSP 0xfd11 +#define PCI_DEVICE_ID_HELIOS_DCSP 0xfd12 #define PCI_DEVICE_ID_ZEPHYR 0xfe00 -#define PCI_DEVICE_ID_ZMID 0xf0e5 -#define PCI_DEVICE_ID_ZSMB 0xf0e1 -#define PCI_DEVICE_ID_LP101 0xf0a1 -#define PCI_DEVICE_ID_LP10000S 0xfc00 +#define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11 +#define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12 #define JEDEC_ID_ADDRESS 0x0080001c #define FIREFLY_JEDEC_ID 0x1ACC diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index dfd59d2..1ab3dac 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -759,15 +759,15 @@ static void lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) { lpfc_vpd_t *vp; - uint32_t id; + uint16_t dev_id; uint8_t hdrtype; char str[16]; vp = &phba->vpd; - pci_read_config_dword(phba->pcidev, PCI_VENDOR_ID, &id); + pci_read_config_word(phba->pcidev, PCI_DEVICE_ID, &dev_id); pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); - switch ((id >> 16) & 0xffff) { + switch (dev_id) { case PCI_DEVICE_ID_FIREFLY: strcpy(str, "LP6000 1"); break; @@ -816,6 +816,24 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) else strcpy(str, "LP11000 4"); break; + case PCI_DEVICE_ID_HELIOS_SCSP: + strcpy(str, "LP11000-SP 4"); + break; + case PCI_DEVICE_ID_HELIOS_DCSP: + strcpy(str, "LP11002-SP 4"); + break; + case PCI_DEVICE_ID_NEPTUNE: + if (hdrtype == 0x80) + strcpy(str, "LPe1002 4"); + else + strcpy(str, "LPe1000 4"); + break; + case PCI_DEVICE_ID_NEPTUNE_SCSP: + strcpy(str, "LPe1000-SP 4"); + break; + case PCI_DEVICE_ID_NEPTUNE_DCSP: + strcpy(str, "LPe1002-SP 4"); + break; case PCI_DEVICE_ID_BMID: strcpy(str, "LP1150 4"); break; @@ -828,6 +846,12 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) else strcpy(str, "LPe11000 4"); break; + case PCI_DEVICE_ID_ZEPHYR_SCSP: + strcpy(str, "LPe11000-SP 4"); + break; + case PCI_DEVICE_ID_ZEPHYR_DCSP: + strcpy(str, "LPe11002-SP 4"); + break; case PCI_DEVICE_ID_ZMID: strcpy(str, "LPe1150 4"); break; @@ -843,6 +867,18 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) default: memset(str, 0, 16); break; + case PCI_DEVICE_ID_LP11000S: + if (hdrtype == 0x80) + strcpy(str, "LP11002-S 4"); + else + strcpy(str, "LP11000-S 4"); + break; + case PCI_DEVICE_ID_LPE11000S: + if (hdrtype == 0x80) + strcpy(str, "LPe11002-S 4"); + else + strcpy(str, "LPe11000-S 4"); + break; } if (mdp) sscanf(str, "%s", mdp); @@ -1673,14 +1709,28 @@ static struct pci_device_id lpfc_id_table[] = { PCI_ANY_ID, PCI_ANY_ID, }, {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY, PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE, + PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_SCSP, + PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_DCSP, + PCI_ANY_ID, PCI_ANY_ID, }, {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS, PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_SCSP, + PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_DCSP, + PCI_ANY_ID, PCI_ANY_ID, }, {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID, PCI_ANY_ID, PCI_ANY_ID, }, {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB, PCI_ANY_ID, PCI_ANY_ID, }, {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR, PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_SCSP, + PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_DCSP, + PCI_ANY_ID, PCI_ANY_ID, }, {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID, PCI_ANY_ID, PCI_ANY_ID, }, {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB, @@ -1691,6 +1741,10 @@ static struct pci_device_id lpfc_id_table[] = { PCI_ANY_ID, PCI_ANY_ID, }, {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S, PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP11000S, + PCI_ANY_ID, PCI_ANY_ID, }, + {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S, + PCI_ANY_ID, PCI_ANY_ID, }, { 0 } }; -- cgit v1.1 From 5cc36b3cd0e3610ad7c7e2514160998276798fc0 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:42:19 -0500 Subject: [SCSI] lpfc 8.1.1 : Bring model descriptions in sync with Emulex standard generic names Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_hw.h | 6 +++ drivers/scsi/lpfc/lpfc_init.c | 107 +++++++++++++++++++++++------------------- 2 files changed, 65 insertions(+), 48 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h index 4f00293..1ea565e 100644 --- a/drivers/scsi/lpfc/lpfc_hw.h +++ b/drivers/scsi/lpfc/lpfc_hw.h @@ -1054,6 +1054,12 @@ typedef struct { #define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11 #define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12 +#define PCI_SUBSYSTEM_ID_LP11000S 0xfc11 +#define PCI_SUBSYSTEM_ID_LP11002S 0xfc12 +#define PCI_SUBSYSTEM_ID_LPE11000S 0xfc21 +#define PCI_SUBSYSTEM_ID_LPE11002S 0xfc22 +#define PCI_SUBSYSTEM_ID_LPE11010S 0xfc2A + #define JEDEC_ID_ADDRESS 0x0080001c #define FIREFLY_JEDEC_ID 0x1ACC #define SUPERFLY_JEDEC_ID 0x0020 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 1ab3dac..766dac2 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -760,8 +760,9 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) { lpfc_vpd_t *vp; uint16_t dev_id; + uint16_t dev_subid; uint8_t hdrtype; - char str[16]; + char *model_str = ""; vp = &phba->vpd; pci_read_config_word(phba->pcidev, PCI_DEVICE_ID, &dev_id); @@ -769,122 +770,132 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) switch (dev_id) { case PCI_DEVICE_ID_FIREFLY: - strcpy(str, "LP6000 1"); + model_str = "LP6000 1Gb PCI"; break; case PCI_DEVICE_ID_SUPERFLY: if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) - strcpy(str, "LP7000 1"); + model_str = "LP7000 1Gb PCI"; else - strcpy(str, "LP7000E 1"); + model_str = "LP7000E 1Gb PCI"; break; case PCI_DEVICE_ID_DRAGONFLY: - strcpy(str, "LP8000 1"); + model_str = "LP8000 1Gb PCI"; break; case PCI_DEVICE_ID_CENTAUR: if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) - strcpy(str, "LP9002 2"); + model_str = "LP9002 2Gb PCI"; else - strcpy(str, "LP9000 1"); + model_str = "LP9000 1Gb PCI"; break; case PCI_DEVICE_ID_RFLY: - strcpy(str, "LP952 2"); + model_str = "LP952 2Gb PCI"; break; case PCI_DEVICE_ID_PEGASUS: - strcpy(str, "LP9802 2"); + model_str = "LP9802 2Gb PCI-X"; break; case PCI_DEVICE_ID_THOR: if (hdrtype == 0x80) - strcpy(str, "LP10000DC 2"); + model_str = "LP10000DC 2Gb 2-port PCI-X"; else - strcpy(str, "LP10000 2"); + model_str = "LP10000 2Gb PCI-X"; break; case PCI_DEVICE_ID_VIPER: - strcpy(str, "LPX1000 10"); + model_str = "LPX1000 10Gb PCI-X"; break; case PCI_DEVICE_ID_PFLY: - strcpy(str, "LP982 2"); + model_str = "LP982 2Gb PCI-X"; break; case PCI_DEVICE_ID_TFLY: if (hdrtype == 0x80) - strcpy(str, "LP1050DC 2"); + model_str = "LP1050DC 2Gb 2-port PCI-X"; else - strcpy(str, "LP1050 2"); + model_str = "LP1050 2Gb PCI-X"; break; case PCI_DEVICE_ID_HELIOS: if (hdrtype == 0x80) - strcpy(str, "LP11002 4"); + model_str = "LP11002 4Gb 2-port PCI-X2"; else - strcpy(str, "LP11000 4"); + model_str = "LP11000 4Gb PCI-X2"; break; case PCI_DEVICE_ID_HELIOS_SCSP: - strcpy(str, "LP11000-SP 4"); + model_str = "LP11000-SP 4Gb PCI-X2"; break; case PCI_DEVICE_ID_HELIOS_DCSP: - strcpy(str, "LP11002-SP 4"); + model_str = "LP11002-SP 4Gb 2-port PCI-X2"; break; case PCI_DEVICE_ID_NEPTUNE: if (hdrtype == 0x80) - strcpy(str, "LPe1002 4"); + model_str = "LPe1002 4Gb 2-port"; else - strcpy(str, "LPe1000 4"); + model_str = "LPe1000 4Gb PCIe"; break; case PCI_DEVICE_ID_NEPTUNE_SCSP: - strcpy(str, "LPe1000-SP 4"); + model_str = "LPe1000-SP 4Gb PCIe"; break; case PCI_DEVICE_ID_NEPTUNE_DCSP: - strcpy(str, "LPe1002-SP 4"); + model_str = "LPe1002-SP 4Gb 2-port PCIe"; break; case PCI_DEVICE_ID_BMID: - strcpy(str, "LP1150 4"); + model_str = "LP1150 4Gb PCI-X2"; break; case PCI_DEVICE_ID_BSMB: - strcpy(str, "LP111 4"); + model_str = "LP111 4Gb PCI-X2"; break; case PCI_DEVICE_ID_ZEPHYR: if (hdrtype == 0x80) - strcpy(str, "LPe11002 4"); + model_str = "LPe11002 4Gb 2-port PCIe"; else - strcpy(str, "LPe11000 4"); + model_str = "LPe11000 4Gb PCIe"; break; case PCI_DEVICE_ID_ZEPHYR_SCSP: - strcpy(str, "LPe11000-SP 4"); + model_str = "LPe11000-SP 4Gb PCIe"; break; case PCI_DEVICE_ID_ZEPHYR_DCSP: - strcpy(str, "LPe11002-SP 4"); + model_str = "LPe11002-SP 4Gb 2-port PCIe"; break; case PCI_DEVICE_ID_ZMID: - strcpy(str, "LPe1150 4"); + model_str = "LPe1150 4Gb PCIe"; break; case PCI_DEVICE_ID_ZSMB: - strcpy(str, "LPe111 4"); + model_str = "LPe111 4Gb PCIe"; break; case PCI_DEVICE_ID_LP101: - strcpy(str, "LP101 2"); + model_str = "LP101 2Gb PCI-X"; break; case PCI_DEVICE_ID_LP10000S: - strcpy(str, "LP10000-S 2"); - break; - default: - memset(str, 0, 16); + model_str = "LP10000-S 2Gb PCI"; break; case PCI_DEVICE_ID_LP11000S: - if (hdrtype == 0x80) - strcpy(str, "LP11002-S 4"); - else - strcpy(str, "LP11000-S 4"); - break; case PCI_DEVICE_ID_LPE11000S: - if (hdrtype == 0x80) - strcpy(str, "LPe11002-S 4"); - else - strcpy(str, "LPe11000-S 4"); + pci_read_config_word(phba->pcidev, PCI_SUBSYSTEM_ID, + &dev_subid); + switch (dev_subid) { + case PCI_SUBSYSTEM_ID_LP11000S: + model_str = "LP11002-S 4Gb PCI-X2"; + break; + case PCI_SUBSYSTEM_ID_LP11002S: + model_str = "LP11000-S 4Gb 2-port PCI-X2"; + break; + case PCI_SUBSYSTEM_ID_LPE11000S: + model_str = "LPe11002-S 4Gb PCIe"; + break; + case PCI_SUBSYSTEM_ID_LPE11002S: + model_str = "LPe11002-S 4Gb 2-port PCIe"; + break; + case PCI_SUBSYSTEM_ID_LPE11010S: + model_str = "LPe11010-S 4Gb 10-port PCIe"; + break; + default: + break; + } + break; + default: break; } if (mdp) - sscanf(str, "%s", mdp); + sscanf(model_str, "%s", mdp); if (descp) - sprintf(descp, "Emulex LightPulse %s Gigabit PCI Fibre " - "Channel Adapter", str); + sprintf(descp, "Emulex %s Fibre Channel Adapter", model_str); } /**************************************************/ -- cgit v1.1 From 875fbdfe9b1b4c8f12622a8d8d81428ff0984875 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Tue, 29 Nov 2005 16:32:13 -0500 Subject: [SCSI] lpfc 8.1.1 : Add polled-mode support - Add functionality to run in polled mode only. Includes run time attribute to enable mode. - Enable runtime writable hba settings for coallescing and delay parameters Customers have requested a mode in the driver to run strictly polled. This is generally to support an environment where the server is extremely loaded and is looking to reclaim some cpu cycles from adapter interrupt handling. This patch adds a new "poll" attribute, and the following behavior: if value is 0 (default): The driver uses the normal method for i/o completion. It uses the firmware feature of interrupt coalesing. The firmware allows a minimum number of i/o completions before an interrupt, or a maximum time delay between interrupts. By default, the driver sets these to no delay (disabled) or 1 i/o - meaning coalescing is disabled. Attributes were provided to change the coalescing values, but it was a module-load time only and global across all adapters. This patch allows them to be writable on a per-adapter basis. if value is 1 : Interrupts are left enabled, expecting that the user has tuned the interrupt coalescing values. When this setting is enabled, the driver will attempt to service completed i/o whenever new i/o is submitted to the adapter. If the coalescing values are large, and the i/o generation rate steady, an interrupt will be avoided by servicing completed i/o prior to the coalescing thresholds kicking in. However, if the i/o completion load is high enough or i/o generation slow, the coalescion values will ensure that completed i/o is serviced in a timely fashion. if value is 3 : Turns off FCP i/o interrupts altogether. The coalescing values now have no effect. A new attribute "poll_tmo" (default 10ms) exists to set the polling interval for i/o completion. When this setting is enabled, the driver will attempt to service completed i/o and restart the interval timer whenever new i/o is submitted. This behavior allows for servicing of completed i/o sooner than the interval timer, but ensures that if no i/o is being issued, then the interval timer will kick in to service the outstanding i/o. Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc.h | 10 ++ drivers/scsi/lpfc/lpfc_attr.c | 92 +++++++++++++++++- drivers/scsi/lpfc/lpfc_crtn.h | 3 + drivers/scsi/lpfc/lpfc_init.c | 16 ++++ drivers/scsi/lpfc/lpfc_scsi.c | 72 ++++++++++++-- drivers/scsi/lpfc/lpfc_sli.c | 217 ++++++++++++++++++++++++++++++++++++++---- 6 files changed, 377 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index dc73a2f..1f3873a 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -45,6 +45,11 @@ struct lpfc_sli2_slim; #define MAX_HBAEVT 32 +enum lpfc_polling_flags { + ENABLE_FCP_RING_POLLING = 0x1, + DISABLE_FCP_RING_INT = 0x2 +}; + /* Provide DMA memory definitions the driver uses per port instance. */ struct lpfc_dmabuf { struct list_head list; @@ -287,6 +292,8 @@ struct lpfc_hba { uint32_t cfg_fcp_bind_method; uint32_t cfg_discovery_threads; uint32_t cfg_max_luns; + uint32_t cfg_poll; + uint32_t cfg_poll_tmo; uint32_t cfg_sg_seg_cnt; uint32_t cfg_sg_dma_buf_size; @@ -338,7 +345,9 @@ struct lpfc_hba { #define VPD_PORT 0x8 /* valid vpd port data */ #define VPD_MASK 0xf /* mask for any vpd data */ + struct timer_list fcp_poll_timer; struct timer_list els_tmofunc; + /* * stat counters */ @@ -349,6 +358,7 @@ struct lpfc_hba { struct lpfc_sysfs_mbox sysfs_mbox; /* fastpath list. */ + spinlock_t scsi_buf_list_lock; struct list_head lpfc_scsi_buf_list; uint32_t total_scsi_bufs; struct list_head lpfc_iocb_list; diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 89e8222..5625a8c 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -278,6 +278,71 @@ lpfc_board_online_store(struct class_device *cdev, const char *buf, return -EIO; } +static ssize_t +lpfc_poll_show(struct class_device *cdev, char *buf) +{ + struct Scsi_Host *host = class_to_shost(cdev); + struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0]; + + return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); +} + +static ssize_t +lpfc_poll_store(struct class_device *cdev, const char *buf, + size_t count) +{ + struct Scsi_Host *host = class_to_shost(cdev); + struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0]; + uint32_t creg_val; + uint32_t old_val; + int val=0; + + if (!isdigit(buf[0])) + return -EINVAL; + + if (sscanf(buf, "%i", &val) != 1) + return -EINVAL; + + if ((val & 0x3) != val) + return -EINVAL; + + spin_lock_irq(phba->host->host_lock); + + old_val = phba->cfg_poll; + + if (val & ENABLE_FCP_RING_POLLING) { + if ((val & DISABLE_FCP_RING_INT) && + !(old_val & DISABLE_FCP_RING_INT)) { + creg_val = readl(phba->HCregaddr); + creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); + writel(creg_val, phba->HCregaddr); + readl(phba->HCregaddr); /* flush */ + + lpfc_poll_start_timer(phba); + } + } else if (val != 0x0) { + spin_unlock_irq(phba->host->host_lock); + return -EINVAL; + } + + if (!(val & DISABLE_FCP_RING_INT) && + (old_val & DISABLE_FCP_RING_INT)) + { + spin_unlock_irq(phba->host->host_lock); + del_timer(&phba->fcp_poll_timer); + spin_lock_irq(phba->host->host_lock); + creg_val = readl(phba->HCregaddr); + creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); + writel(creg_val, phba->HCregaddr); + readl(phba->HCregaddr); /* flush */ + } + + phba->cfg_poll = val; + + spin_unlock_irq(phba->host->host_lock); + + return strlen(buf); +} #define lpfc_param_show(attr) \ static ssize_t \ @@ -416,6 +481,15 @@ static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show, static CLASS_DEVICE_ATTR(board_online, S_IRUGO | S_IWUSR, lpfc_board_online_show, lpfc_board_online_store); +static int lpfc_poll = 0; +module_param(lpfc_poll, int, 0); +MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:" + " 0 - none," + " 1 - poll with interrupts enabled" + " 3 - poll and disable FCP ring interrupts"); + +static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, + lpfc_poll_show, lpfc_poll_store); /* # lpfc_log_verbose: Only turn this flag on if you are willing to risk being @@ -523,10 +597,10 @@ LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support"); # is 0. Default value of cr_count is 1. The cr_count feature is disabled if # cr_delay is set to 0. */ -LPFC_ATTR(cr_delay, 0, 0, 63, "A count of milliseconds after which an" +LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an" "interrupt response is generated"); -LPFC_ATTR(cr_count, 1, 1, 255, "A count of I/O completions after which an" +LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an" "interrupt response is generated"); /* @@ -553,6 +627,13 @@ LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands" LPFC_ATTR_R(max_luns, 256, 1, 32768, "Maximum number of LUNs per target driver will support"); +/* +# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring. +# Value range is [1,255], default value is 10. +*/ +LPFC_ATTR_RW(poll_tmo, 10, 1, 255, + "Milliseconds driver will wait between polling FCP ring"); + struct class_device_attribute *lpfc_host_attrs[] = { &class_device_attr_info, &class_device_attr_serialnum, @@ -575,11 +656,15 @@ struct class_device_attribute *lpfc_host_attrs[] = { &class_device_attr_lpfc_topology, &class_device_attr_lpfc_scan_down, &class_device_attr_lpfc_link_speed, + &class_device_attr_lpfc_cr_delay, + &class_device_attr_lpfc_cr_count, &class_device_attr_lpfc_fdmi_on, &class_device_attr_lpfc_max_luns, &class_device_attr_nport_evt_cnt, &class_device_attr_management_version, &class_device_attr_board_online, + &class_device_attr_lpfc_poll, + &class_device_attr_lpfc_poll_tmo, NULL, }; @@ -1292,6 +1377,9 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) lpfc_fdmi_on_init(phba, lpfc_fdmi_on); lpfc_discovery_threads_init(phba, lpfc_discovery_threads); lpfc_max_luns_init(phba, lpfc_max_luns); + lpfc_poll_tmo_init(phba, lpfc_poll_tmo); + + phba->cfg_poll = lpfc_poll; /* * The total number of segments is the configuration value plus 2 diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h index d527d05..f1e7089 100644 --- a/drivers/scsi/lpfc/lpfc_crtn.h +++ b/drivers/scsi/lpfc/lpfc_crtn.h @@ -143,6 +143,9 @@ LPFC_MBOXQ_t *lpfc_mbox_get(struct lpfc_hba *); int lpfc_mem_alloc(struct lpfc_hba *); void lpfc_mem_free(struct lpfc_hba *); +void lpfc_poll_timeout(unsigned long ptr); +void lpfc_poll_start_timer(struct lpfc_hba * phba); +void lpfc_sli_poll_fcp_ring(struct lpfc_hba * hba); struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *); void lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb); uint16_t lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocb); diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 766dac2..db3c2ad 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -370,6 +370,10 @@ lpfc_config_port_post(struct lpfc_hba * phba) if (psli->num_rings > 3) status |= HC_R3INT_ENA; + if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) && + (phba->cfg_poll & DISABLE_FCP_RING_INT)) + status &= ~(HC_R0INT_ENA << LPFC_FCP_RING); + writel(status, phba->HCregaddr); readl(phba->HCregaddr); /* flush */ spin_unlock_irq(phba->host->host_lock); @@ -1237,6 +1241,7 @@ lpfc_stop_timer(struct lpfc_hba * phba) } } + del_timer_sync(&phba->fcp_poll_timer); del_timer_sync(&phba->fc_estabtmo); del_timer_sync(&phba->fc_disctmo); del_timer_sync(&phba->fc_fdmitmo); @@ -1416,6 +1421,10 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) psli->mbox_tmo.function = lpfc_mbox_timeout; psli->mbox_tmo.data = (unsigned long)phba; + init_timer(&phba->fcp_poll_timer); + phba->fcp_poll_timer.function = lpfc_poll_timeout; + phba->fcp_poll_timer.data = (unsigned long)phba; + /* * Get all the module params for configuring this host and then * establish the host parameters. @@ -1530,6 +1539,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) host->max_cmd_len = 16; /* Initialize the list of scsi buffers used by driver for scsi IO. */ + spin_lock_init(&phba->scsi_buf_list_lock); INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list); host->transportt = lpfc_transport_template; @@ -1561,6 +1571,12 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid) if (error) goto out_free_irq; + if (phba->cfg_poll & DISABLE_FCP_RING_INT) { + spin_lock_irq(phba->host->host_lock); + lpfc_poll_start_timer(phba); + spin_unlock_irq(phba->host->host_lock); + } + /* * set fixed host attributes * Must done after lpfc_sli_hba_setup() diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index 7dc7810..c422220 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -151,18 +151,22 @@ lpfc_new_scsi_buf(struct lpfc_hba * phba) } struct lpfc_scsi_buf* -lpfc_sli_get_scsi_buf(struct lpfc_hba * phba) +lpfc_get_scsi_buf(struct lpfc_hba * phba) { struct lpfc_scsi_buf * lpfc_cmd = NULL; struct list_head *scsi_buf_list = &phba->lpfc_scsi_buf_list; + unsigned long iflag = 0; + spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list); + spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag); return lpfc_cmd; } static void lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) { + unsigned long iflag = 0; /* * There are only two special cases to consider. (1) the scsi command * requested scatter-gather usage or (2) the scsi command allocated @@ -180,8 +184,10 @@ lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) } } + spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag); psb->pCmd = NULL; list_add_tail(&psb->list, &phba->lpfc_scsi_buf_list); + spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag); } static int @@ -403,7 +409,6 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, struct lpfc_rport_data *rdata = lpfc_cmd->rdata; struct lpfc_nodelist *pnode = rdata->pnode; struct scsi_cmnd *cmd = lpfc_cmd->pCmd; - unsigned long iflag; lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; lpfc_cmd->status = pIocbOut->iocb.ulpStatus; @@ -457,9 +462,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, cmd->scsi_done(cmd); - spin_lock_irqsave(phba->host->host_lock, iflag); lpfc_release_scsi_buf(phba, lpfc_cmd); - spin_unlock_irqrestore(phba->host->host_lock, iflag); } static void @@ -707,6 +710,37 @@ lpfc_info(struct Scsi_Host *host) return lpfcinfobuf; } +static __inline__ void lpfc_poll_rearm_timer(struct lpfc_hba * phba) +{ + unsigned long poll_tmo_expires = + (jiffies + msecs_to_jiffies(phba->cfg_poll_tmo)); + + if (phba->sli.ring[LPFC_FCP_RING].txcmplq_cnt) + mod_timer(&phba->fcp_poll_timer, + poll_tmo_expires); +} + +void lpfc_poll_start_timer(struct lpfc_hba * phba) +{ + lpfc_poll_rearm_timer(phba); +} + +void lpfc_poll_timeout(unsigned long ptr) +{ + struct lpfc_hba *phba = (struct lpfc_hba *)ptr; + unsigned long iflag; + + spin_lock_irqsave(phba->host->host_lock, iflag); + + if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { + lpfc_sli_poll_fcp_ring (phba); + if (phba->cfg_poll & DISABLE_FCP_RING_INT) + lpfc_poll_rearm_timer(phba); + } + + spin_unlock_irqrestore(phba->host->host_lock, iflag); +} + static int lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) { @@ -733,7 +767,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) cmnd->result = ScsiResult(DID_BUS_BUSY, 0); goto out_fail_command; } - lpfc_cmd = lpfc_sli_get_scsi_buf (phba); + lpfc_cmd = lpfc_get_scsi_buf (phba); if (lpfc_cmd == NULL) { lpfc_printf_log(phba, KERN_INFO, LOG_FCP, "%d:0707 driver's buffer pool is empty, " @@ -761,11 +795,17 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB); if (err) goto out_host_busy_free_buf; + + if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { + lpfc_sli_poll_fcp_ring(phba); + if (phba->cfg_poll & DISABLE_FCP_RING_INT) + lpfc_poll_rearm_timer(phba); + } + return 0; out_host_busy_free_buf: lpfc_release_scsi_buf(phba, lpfc_cmd); - cmnd->host_scribble = NULL; out_host_busy: return SCSI_MLQUEUE_HOST_BUSY; @@ -839,9 +879,15 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) goto out; } + if (phba->cfg_poll & DISABLE_FCP_RING_INT) + lpfc_sli_poll_fcp_ring (phba); + /* Wait for abort to complete */ while (lpfc_cmd->pCmd == cmnd) { + if (phba->cfg_poll & DISABLE_FCP_RING_INT) + lpfc_sli_poll_fcp_ring (phba); + spin_unlock_irq(phba->host->host_lock); schedule_timeout_uninterruptible(LPFC_ABORT_WAIT*HZ); spin_lock_irq(phba->host->host_lock); @@ -905,7 +951,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) break; } - lpfc_cmd = lpfc_sli_get_scsi_buf (phba); + lpfc_cmd = lpfc_get_scsi_buf (phba); if (lpfc_cmd == NULL) goto out; @@ -1001,7 +1047,7 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd) lpfc_block_requests(phba); spin_lock_irq(shost->host_lock); - lpfc_cmd = lpfc_sli_get_scsi_buf (phba); + lpfc_cmd = lpfc_get_scsi_buf(phba); if (lpfc_cmd == NULL) goto out; @@ -1136,10 +1182,10 @@ lpfc_slave_alloc(struct scsi_device *sdev) break; } - spin_lock_irqsave(phba->host->host_lock, flags); + spin_lock_irqsave(&phba->scsi_buf_list_lock, flags); phba->total_scsi_bufs++; list_add_tail(&scsi_buf->list, &phba->lpfc_scsi_buf_list); - spin_unlock_irqrestore(phba->host->host_lock, flags); + spin_unlock_irqrestore(&phba->scsi_buf_list_lock, flags); } return 0; } @@ -1163,6 +1209,12 @@ lpfc_slave_configure(struct scsi_device *sdev) */ rport->dev_loss_tmo = phba->cfg_nodev_tmo + 5; + if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { + lpfc_sli_poll_fcp_ring(phba); + if (phba->cfg_poll & DISABLE_FCP_RING_INT) + lpfc_poll_rearm_timer(phba); + } + return 0; } diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index e2c08c5..7b785ad 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c @@ -886,6 +886,182 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring, return rc; } +static void lpfc_sli_rsp_pointers_error(struct lpfc_hba * phba, + struct lpfc_sli_ring * pring) +{ + struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno]; + /* + * Ring handler: portRspPut is bigger then + * rsp ring + */ + lpfc_printf_log(phba, KERN_ERR, LOG_SLI, + "%d:0312 Ring %d handler: portRspPut %d " + "is bigger then rsp ring %d\n", + phba->brd_no, pring->ringno, + le32_to_cpu(pgp->rspPutInx), + pring->numRiocb); + + phba->hba_state = LPFC_HBA_ERROR; + + /* + * All error attention handlers are posted to + * worker thread + */ + phba->work_ha |= HA_ERATT; + phba->work_hs = HS_FFER3; + if (phba->work_wait) + wake_up(phba->work_wait); + + return; +} + +void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba) +{ + struct lpfc_sli * psli = &phba->sli; + struct lpfc_sli_ring * pring = &psli->ring[LPFC_FCP_RING]; + IOCB_t *irsp = NULL; + IOCB_t *entry = NULL; + struct lpfc_iocbq *cmdiocbq = NULL; + struct lpfc_iocbq rspiocbq; + struct lpfc_pgp *pgp; + uint32_t status; + uint32_t portRspPut, portRspMax; + int type; + uint32_t rsp_cmpl = 0; + void __iomem *to_slim; + uint32_t ha_copy; + + pring->stats.iocb_event++; + + /* The driver assumes SLI-2 mode */ + pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno]; + + /* + * The next available response entry should never exceed the maximum + * entries. If it does, treat it as an adapter hardware error. + */ + portRspMax = pring->numRiocb; + portRspPut = le32_to_cpu(pgp->rspPutInx); + if (unlikely(portRspPut >= portRspMax)) { + lpfc_sli_rsp_pointers_error(phba, pring); + return; + } + + rmb(); + while (pring->rspidx != portRspPut) { + + entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx); + + if (++pring->rspidx >= portRspMax) + pring->rspidx = 0; + + lpfc_sli_pcimem_bcopy((uint32_t *) entry, + (uint32_t *) &rspiocbq.iocb, + sizeof (IOCB_t)); + irsp = &rspiocbq.iocb; + type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); + pring->stats.iocb_rsp++; + rsp_cmpl++; + + if (unlikely(irsp->ulpStatus)) { + /* Rsp ring error: IOCB */ + lpfc_printf_log(phba, KERN_WARNING, LOG_SLI, + "%d:0326 Rsp Ring %d error: IOCB Data: " + "x%x x%x x%x x%x x%x x%x x%x x%x\n", + phba->brd_no, pring->ringno, + irsp->un.ulpWord[0], + irsp->un.ulpWord[1], + irsp->un.ulpWord[2], + irsp->un.ulpWord[3], + irsp->un.ulpWord[4], + irsp->un.ulpWord[5], + *(((uint32_t *) irsp) + 6), + *(((uint32_t *) irsp) + 7)); + } + + switch (type) { + case LPFC_ABORT_IOCB: + case LPFC_SOL_IOCB: + /* + * Idle exchange closed via ABTS from port. No iocb + * resources need to be recovered. + */ + if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) { + printk(KERN_INFO "%s: IOCB cmd 0x%x processed." + " Skipping completion\n", __FUNCTION__, + irsp->ulpCommand); + break; + } + + cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring, + &rspiocbq); + if ((cmdiocbq) && (cmdiocbq->iocb_cmpl)) { + (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, + &rspiocbq); + } + break; + default: + if (irsp->ulpCommand == CMD_ADAPTER_MSG) { + char adaptermsg[LPFC_MAX_ADPTMSG]; + memset(adaptermsg, 0, LPFC_MAX_ADPTMSG); + memcpy(&adaptermsg[0], (uint8_t *) irsp, + MAX_MSG_DATA); + dev_warn(&((phba->pcidev)->dev), "lpfc%d: %s", + phba->brd_no, adaptermsg); + } else { + /* Unknown IOCB command */ + lpfc_printf_log(phba, KERN_ERR, LOG_SLI, + "%d:0321 Unknown IOCB command " + "Data: x%x, x%x x%x x%x x%x\n", + phba->brd_no, type, + irsp->ulpCommand, + irsp->ulpStatus, + irsp->ulpIoTag, + irsp->ulpContext); + } + break; + } + + /* + * The response IOCB has been processed. Update the ring + * pointer in SLIM. If the port response put pointer has not + * been updated, sync the pgp->rspPutInx and fetch the new port + * response put pointer. + */ + to_slim = phba->MBslimaddr + + (SLIMOFF + (pring->ringno * 2) + 1) * 4; + writeb(pring->rspidx, to_slim); + + if (pring->rspidx == portRspPut) + portRspPut = le32_to_cpu(pgp->rspPutInx); + } + + ha_copy = readl(phba->HAregaddr); + ha_copy >>= (LPFC_FCP_RING * 4); + + if ((rsp_cmpl > 0) && (ha_copy & HA_R0RE_REQ)) { + pring->stats.iocb_rsp_full++; + status = ((CA_R0ATT | CA_R0RE_RSP) << (LPFC_FCP_RING * 4)); + writel(status, phba->CAregaddr); + readl(phba->CAregaddr); + } + if ((ha_copy & HA_R0CE_RSP) && + (pring->flag & LPFC_CALL_RING_AVAILABLE)) { + pring->flag &= ~LPFC_CALL_RING_AVAILABLE; + pring->stats.iocb_cmd_empty++; + + /* Force update of the local copy of cmdGetInx */ + pring->local_getidx = le32_to_cpu(pgp->cmdGetInx); + lpfc_sli_resume_iocb(phba, pring); + + if ((pring->lpfc_sli_cmd_available)) + (pring->lpfc_sli_cmd_available) (phba, pring); + + } + + return; +} + /* * This routine presumes LPFC_FCP_RING handling and doesn't bother * to check it explicitly. @@ -917,24 +1093,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, portRspMax = pring->numRiocb; portRspPut = le32_to_cpu(pgp->rspPutInx); if (unlikely(portRspPut >= portRspMax)) { - /* - * Ring handler: portRspPut is bigger then - * rsp ring - */ - lpfc_printf_log(phba, KERN_ERR, LOG_SLI, - "%d:0312 Ring %d handler: portRspPut %d " - "is bigger then rsp ring %d\n", - phba->brd_no, pring->ringno, portRspPut, - portRspMax); - - phba->hba_state = LPFC_HBA_ERROR; - - /* All error attention handlers are posted to worker thread */ - phba->work_ha |= HA_ERATT; - phba->work_hs = HS_FFER3; - if (phba->work_wait) - wake_up(phba->work_wait); - + lpfc_sli_rsp_pointers_error(phba, pring); spin_unlock_irqrestore(phba->host->host_lock, iflag); return 1; } @@ -947,6 +1106,10 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, * network byte order and pci byte orders are different. */ entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx); + + if (++pring->rspidx >= portRspMax) + pring->rspidx = 0; + lpfc_sli_pcimem_bcopy((uint32_t *) entry, (uint32_t *) &rspiocbq.iocb, sizeof (IOCB_t)); @@ -1020,9 +1183,6 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba, * been updated, sync the pgp->rspPutInx and fetch the new port * response put pointer. */ - if (++pring->rspidx >= portRspMax) - pring->rspidx = 0; - to_slim = phba->MBslimaddr + (SLIMOFF + (pring->ringno * 2) + 1) * 4; writel(pring->rspidx, to_slim); @@ -2615,6 +2775,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba, DECLARE_WAIT_QUEUE_HEAD(done_q); long timeleft, timeout_req = 0; int retval = IOCB_SUCCESS; + uint32_t creg_val; /* * If the caller has provided a response iocbq buffer, then context2 @@ -2630,6 +2791,13 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba, piocb->context_un.wait_queue = &done_q; piocb->iocb_flag &= ~LPFC_IO_WAKE; + if (phba->cfg_poll & DISABLE_FCP_RING_INT) { + creg_val = readl(phba->HCregaddr); + creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING); + writel(creg_val, phba->HCregaddr); + readl(phba->HCregaddr); /* flush */ + } + retval = lpfc_sli_issue_iocb(phba, pring, piocb, 0); if (retval == IOCB_SUCCESS) { timeout_req = timeout * HZ; @@ -2663,6 +2831,13 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba, retval = IOCB_ERROR; } + if (phba->cfg_poll & DISABLE_FCP_RING_INT) { + creg_val = readl(phba->HCregaddr); + creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING); + writel(creg_val, phba->HCregaddr); + readl(phba->HCregaddr); /* flush */ + } + if (prspiocbq) piocb->context2 = NULL; -- cgit v1.1 From 445cf4f4d2aa28f6ddd1d7a5f0986341ad61ec91 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:42:38 -0500 Subject: [SCSI] lpfc 8.1.1 : Added code to adjust lun queue depth to avoid target overloading Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc.h | 3 ++- drivers/scsi/lpfc/lpfc_disc.h | 2 ++ drivers/scsi/lpfc/lpfc_scsi.c | 58 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h index 1f3873a..38ffa8d 100644 --- a/drivers/scsi/lpfc/lpfc.h +++ b/drivers/scsi/lpfc/lpfc.h @@ -29,9 +29,10 @@ struct lpfc_sli2_slim; #define LPFC_LC_HBA_Q_DEPTH 1024 /* max cmds per low cost hba */ #define LPFC_LP101_HBA_Q_DEPTH 128 /* max cmds per low cost hba */ -#define LPFC_CMD_PER_LUN 30 /* max outstanding cmds per lun */ +#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */ #define LPFC_SG_SEG_CNT 64 /* sg element count per scsi cmnd */ #define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */ +#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */ /* Define macros for 64 bit support */ #define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr))) diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h index 084e762..ed6c816 100644 --- a/drivers/scsi/lpfc/lpfc_disc.h +++ b/drivers/scsi/lpfc/lpfc_disc.h @@ -73,6 +73,8 @@ struct lpfc_nodelist { struct lpfc_hba *nlp_phba; struct lpfc_work_evt nodev_timeout_evt; struct lpfc_work_evt els_retry_evt; + unsigned long last_ramp_up_time; /* jiffy of last ramp up */ + unsigned long last_q_full_time; /* jiffy of last queue full */ }; /* Defines for nlp_flag (uint32) */ diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index c422220..9ee8218 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -409,6 +409,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, struct lpfc_rport_data *rdata = lpfc_cmd->rdata; struct lpfc_nodelist *pnode = rdata->pnode; struct scsi_cmnd *cmd = lpfc_cmd->pCmd; + int result; + struct scsi_device *sdev, *tmp_sdev; + int depth = 0; lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; lpfc_cmd->status = pIocbOut->iocb.ulpStatus; @@ -460,8 +463,63 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, *lp, *(lp + 3), cmd->retries, cmd->resid); } + result = cmd->result; + sdev = cmd->device; cmd->scsi_done(cmd); + if (!result && + ((jiffies - pnode->last_ramp_up_time) > + LPFC_Q_RAMP_UP_INTERVAL * HZ) && + ((jiffies - pnode->last_q_full_time) > + LPFC_Q_RAMP_UP_INTERVAL * HZ) && + (phba->cfg_lun_queue_depth > sdev->queue_depth)) { + shost_for_each_device(tmp_sdev, sdev->host) { + if (phba->cfg_lun_queue_depth > tmp_sdev->queue_depth) { + if (tmp_sdev->id != sdev->id) + continue; + if (tmp_sdev->ordered_tags) + scsi_adjust_queue_depth(tmp_sdev, + MSG_ORDERED_TAG, + tmp_sdev->queue_depth+1); + else + scsi_adjust_queue_depth(tmp_sdev, + MSG_SIMPLE_TAG, + tmp_sdev->queue_depth+1); + + pnode->last_ramp_up_time = jiffies; + } + } + } + + /* + * Check for queue full. If the lun is reporting queue full, then + * back off the lun queue depth to prevent target overloads. + */ + if (result == SAM_STAT_TASK_SET_FULL) { + pnode->last_q_full_time = jiffies; + + shost_for_each_device(tmp_sdev, sdev->host) { + if (tmp_sdev->id != sdev->id) + continue; + depth = scsi_track_queue_full(tmp_sdev, + tmp_sdev->queue_depth - 1); + } + /* + * The queue depth cannot be lowered any more. + * Modify the returned error code to store + * the final depth value set by + * scsi_track_queue_full. + */ + if (depth == -1) + depth = sdev->host->cmd_per_lun; + + if (depth) { + lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, + "%d:0711 detected queue full - lun queue depth " + " adjusted to %d.\n", phba->brd_no, depth); + } + } + lpfc_release_scsi_buf(phba, lpfc_cmd); } -- cgit v1.1 From fefcb2b677fbfce894133e59a34395f8988d4610 Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 15:08:56 -0500 Subject: [SCSI] lpfc 8.1.1 : kill use of pci_read_config_xxx Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_init.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index db3c2ad..b7a603a 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c @@ -763,14 +763,12 @@ static void lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) { lpfc_vpd_t *vp; - uint16_t dev_id; - uint16_t dev_subid; - uint8_t hdrtype; + uint16_t dev_id = phba->pcidev->device; + uint16_t dev_subid = phba->pcidev->subsystem_device; + uint8_t hdrtype = phba->pcidev->hdr_type; char *model_str = ""; vp = &phba->vpd; - pci_read_config_word(phba->pcidev, PCI_DEVICE_ID, &dev_id); - pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); switch (dev_id) { case PCI_DEVICE_ID_FIREFLY: @@ -871,8 +869,6 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) break; case PCI_DEVICE_ID_LP11000S: case PCI_DEVICE_ID_LPE11000S: - pci_read_config_word(phba->pcidev, PCI_SUBSYSTEM_ID, - &dev_subid); switch (dev_subid) { case PCI_SUBSYSTEM_ID_LP11000S: model_str = "LP11002-S 4Gb PCI-X2"; -- cgit v1.1 From 1cb25a27d0a3f8296e67e5cc915048db10910d4f Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Mon, 28 Nov 2005 11:42:49 -0500 Subject: [SCSI] lpfc 8.1.1 : Change version number to 8.1.1 Signed-off-by: James Smart Signed-off-by: James Bottomley --- drivers/scsi/lpfc/lpfc_version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h index 4f0466f..fa681a9 100644 --- a/drivers/scsi/lpfc/lpfc_version.h +++ b/drivers/scsi/lpfc/lpfc_version.h @@ -18,7 +18,7 @@ * included with this package. * *******************************************************************/ -#define LPFC_DRIVER_VERSION "8.1.0" +#define LPFC_DRIVER_VERSION "8.1.1" #define LPFC_DRIVER_NAME "lpfc" -- cgit v1.1 From f78496da6a85f4b5f4532d7bf85b05fa655146a8 Mon Sep 17 00:00:00 2001 From: "Moore, Eric Dean" Date: Wed, 16 Nov 2005 18:54:14 -0700 Subject: [SCSI] mptfusion - adding = THIS_MODULE Signed-off-by: Eric Moore Signed-off-by: James Bottomley --- drivers/message/fusion/mptfc.c | 1 + drivers/message/fusion/mptsas.c | 1 + drivers/message/fusion/mptspi.c | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index a628be9..101993f 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -84,6 +84,7 @@ static int mptfcTaskCtx = -1; static int mptfcInternalCtx = -1; /* Used only for internal commands */ static struct scsi_host_template mptfc_driver_template = { + .module = THIS_MODULE, .proc_name = "mptfc", .proc_info = mptscsih_proc_info, .name = "MPT FC Host", diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index e0a8bb8..0e557a3a 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -277,6 +277,7 @@ mptsas_slave_alloc(struct scsi_device *device) } static struct scsi_host_template mptsas_driver_template = { + .module = THIS_MODULE, .proc_name = "mptsas", .proc_info = mptscsih_proc_info, .name = "MPT SPI Host", diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 5c0e307..9431d38 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -103,6 +103,7 @@ static int mptspiTaskCtx = -1; static int mptspiInternalCtx = -1; /* Used only for internal commands */ static struct scsi_host_template mptspi_driver_template = { + .module = THIS_MODULE, .proc_name = "mptspi", .proc_info = mptscsih_proc_info, .name = "MPT SPI Host", -- cgit v1.1 From 7acec1e7556a861416bb6b10f3e3cbb6e82fc01d Mon Sep 17 00:00:00 2001 From: "Moore, Eric Dean" Date: Wed, 16 Nov 2005 18:54:17 -0700 Subject: [SCSI] mptfusion - cleaning up xxx_probe error handling This cleans the returning failure conditions of the mptsas/mptfc/mptspi probe routines. Signed-off-by: Eric Moore Signed-off-by: James Bottomley --- drivers/message/fusion/mptfc.c | 17 ++++++++++------- drivers/message/fusion/mptsas.c | 17 ++++++++++------- drivers/message/fusion/mptspi.c | 17 ++++++++++------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 101993f..531664f 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -168,13 +168,15 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) printk(MYIOC_s_WARN_FMT "Skipping because it's not operational!\n", ioc->name); - return -ENODEV; + error = -ENODEV; + goto out_mptfc_probe; } if (!ioc->active) { printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", ioc->name); - return -ENODEV; + error = -ENODEV; + goto out_mptfc_probe; } /* Sanity check - ensure at least 1 port is INITIATOR capable @@ -199,7 +201,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) printk(MYIOC_s_WARN_FMT "Unable to register controller with SCSI subsystem\n", ioc->name); - return -1; + error = -1; + goto out_mptfc_probe; } spin_lock_irqsave(&ioc->FreeQlock, flags); @@ -267,7 +270,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) mem = kmalloc(sz, GFP_ATOMIC); if (mem == NULL) { error = -ENOMEM; - goto mptfc_probe_failed; + goto out_mptfc_probe; } memset(mem, 0, sz); @@ -285,7 +288,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) mem = kmalloc(sz, GFP_ATOMIC); if (mem == NULL) { error = -ENOMEM; - goto mptfc_probe_failed; + goto out_mptfc_probe; } memset(mem, 0, sz); @@ -331,13 +334,13 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) if(error) { dprintk((KERN_ERR MYNAM "scsi_add_host failed\n")); - goto mptfc_probe_failed; + goto out_mptfc_probe; } scsi_scan_host(sh); return 0; -mptfc_probe_failed: +out_mptfc_probe: mptscsih_remove(pdev); return error; diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 0e557a3a..282fb5e 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -1134,13 +1134,15 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) printk(MYIOC_s_WARN_FMT "Skipping because it's not operational!\n", ioc->name); - return -ENODEV; + error = -ENODEV; + goto out_mptsas_probe; } if (!ioc->active) { printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", ioc->name); - return -ENODEV; + error = -ENODEV; + goto out_mptsas_probe; } /* Sanity check - ensure at least 1 port is INITIATOR capable @@ -1164,7 +1166,8 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) printk(MYIOC_s_WARN_FMT "Unable to register controller with SCSI subsystem\n", ioc->name); - return -1; + error = -1; + goto out_mptsas_probe; } spin_lock_irqsave(&ioc->FreeQlock, flags); @@ -1238,7 +1241,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) mem = kmalloc(sz, GFP_ATOMIC); if (mem == NULL) { error = -ENOMEM; - goto mptsas_probe_failed; + goto out_mptsas_probe; } memset(mem, 0, sz); @@ -1256,7 +1259,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) mem = kmalloc(sz, GFP_ATOMIC); if (mem == NULL) { error = -ENOMEM; - goto mptsas_probe_failed; + goto out_mptsas_probe; } memset(mem, 0, sz); @@ -1309,14 +1312,14 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) { dprintk((KERN_ERR MYNAM "scsi_add_host failed\n")); - goto mptsas_probe_failed; + goto out_mptsas_probe; } mptsas_scan_sas_topology(ioc); return 0; -mptsas_probe_failed: +out_mptsas_probe: mptscsih_remove(pdev); return error; diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 9431d38..91bc467 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -178,13 +178,15 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) printk(MYIOC_s_WARN_FMT "Skipping because it's not operational!\n", ioc->name); - return -ENODEV; + error = -ENODEV; + goto out_mptspi_probe; } if (!ioc->active) { printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", ioc->name); - return -ENODEV; + error = -ENODEV; + goto out_mptspi_probe; } /* Sanity check - ensure at least 1 port is INITIATOR capable @@ -209,7 +211,8 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) printk(MYIOC_s_WARN_FMT "Unable to register controller with SCSI subsystem\n", ioc->name); - return -1; + error = -1; + goto out_mptspi_probe; } spin_lock_irqsave(&ioc->FreeQlock, flags); @@ -287,7 +290,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) mem = kmalloc(sz, GFP_ATOMIC); if (mem == NULL) { error = -ENOMEM; - goto mptspi_probe_failed; + goto out_mptspi_probe; } memset(mem, 0, sz); @@ -305,7 +308,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) mem = kmalloc(sz, GFP_ATOMIC); if (mem == NULL) { error = -ENOMEM; - goto mptspi_probe_failed; + goto out_mptspi_probe; } memset(mem, 0, sz); @@ -386,13 +389,13 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) if(error) { dprintk((KERN_ERR MYNAM "scsi_add_host failed\n")); - goto mptspi_probe_failed; + goto out_mptspi_probe; } scsi_scan_host(sh); return 0; -mptspi_probe_failed: +out_mptspi_probe: mptscsih_remove(pdev); return error; -- cgit v1.1 From a9b2937a1eab2939d0eed3830ead88664ed7445d Mon Sep 17 00:00:00 2001 From: "Moore, Eric Dean" Date: Wed, 16 Nov 2005 18:54:20 -0700 Subject: [SCSI] mptfusion - bus_type, change SCSI to SPI This changes to SPI for the bus_type enumeration. Signed-off-by: Eric Moore Signed-off-by: James Bottomley --- drivers/message/fusion/mptbase.c | 14 +++++++------- drivers/message/fusion/mptbase.h | 2 +- drivers/message/fusion/mptscsih.c | 30 +++++++++++++++--------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c index 4262a22..5378360 100644 --- a/drivers/message/fusion/mptbase.c +++ b/drivers/message/fusion/mptbase.c @@ -313,13 +313,13 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa) u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo); if (ioc->bus_type == FC) mpt_fc_log_info(ioc, log_info); - else if (ioc->bus_type == SCSI) + else if (ioc->bus_type == SPI) mpt_sp_log_info(ioc, log_info); else if (ioc->bus_type == SAS) mpt_sas_log_info(ioc, log_info); } if (ioc_stat & MPI_IOCSTATUS_MASK) { - if (ioc->bus_type == SCSI && + if (ioc->bus_type == SPI && cb_idx != mpt_stm_index && cb_idx != mpt_lan_index) mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf); @@ -1376,7 +1376,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) } else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) { ioc->prod_name = "LSI53C1030"; - ioc->bus_type = SCSI; + ioc->bus_type = SPI; /* 1030 Chip Fix. Disable Split transactions * for PCIX. Set MOST bits to zero if Rev < C0( = 8). */ @@ -1389,7 +1389,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id) } else if (pdev->device == MPI_MANUFACTPAGE_DEVID_1030_53C1035) { ioc->prod_name = "LSI53C1035"; - ioc->bus_type = SCSI; + ioc->bus_type = SPI; } else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064) { ioc->prod_name = "LSISAS1064"; @@ -3042,7 +3042,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag) /* Clear the internal flash bad bit - autoincrementing register, * so must do two writes. */ - if (ioc->bus_type == SCSI) { + if (ioc->bus_type == SPI) { /* * 1030 and 1035 H/W errata, workaround to access * the ClearFlashBadSignatureBit @@ -3152,7 +3152,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag) int cnt,cntdn; dinitprintk((KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name)); - if (ioc->bus_type == SCSI) { + if (ioc->bus_type == SPI) { /* Always issue a Msg Unit Reset first. This will clear some * SCSI bus hang conditions. */ @@ -3580,7 +3580,7 @@ initChainBuffers(MPT_ADAPTER *ioc) dinitprintk((KERN_INFO MYNAM ": %s Now numSGE=%d num_sge=%d num_chain=%d\n", ioc->name, numSGE, num_sge, num_chain)); - if (ioc->bus_type == SCSI) + if (ioc->bus_type == SPI) num_chain *= MPT_SCSI_CAN_QUEUE; else num_chain *= MPT_FC_CAN_QUEUE; diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index bac8eb4..7a6c114 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h @@ -903,7 +903,7 @@ typedef struct _MPT_LOCAL_REPLY { typedef enum { FC, - SCSI, + SPI, SAS } BUS_TYPE; diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index b7b9846..2d01424 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -677,7 +677,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) sc->result = DID_RESET << 16; /* GEM Workaround. */ - if (ioc->bus_type == SCSI) + if (ioc->bus_type == SPI) mptscsih_no_negotiate(hd, sc->device->id); break; @@ -1403,7 +1403,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) SCpnt->host_scribble = NULL; #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION - if (hd->ioc->bus_type == SCSI) { + if (hd->ioc->bus_type == SPI) { int dvStatus = hd->ioc->spi_data.dvStatus[pTarget->target_id]; int issueCmd = 1; @@ -2183,7 +2183,7 @@ mptscsih_slave_alloc(struct scsi_device *device) vdev->bus_id = device->channel; vdev->raidVolume = 0; hd->Targets[device->id] = vdev; - if (hd->ioc->bus_type == SCSI) { + if (hd->ioc->bus_type == SPI) { if (hd->ioc->raid_data.isRaid & (1 << device->id)) { vdev->raidVolume = 1; ddvtprintk((KERN_INFO @@ -2225,7 +2225,7 @@ mptscsih_slave_destroy(struct scsi_device *device) kfree(hd->Targets[target]); hd->Targets[target] = NULL; - if (hd->ioc->bus_type == SCSI) { + if (hd->ioc->bus_type == SPI) { if (mptscsih_is_phys_disk(hd->ioc, target)) { hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; } else { @@ -2261,7 +2261,7 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) if (!(pTarget = hd->Targets[sdev->id])) return 0; - if (hd->ioc->bus_type == SCSI) { + if (hd->ioc->bus_type == SPI) { if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) { if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)) max_depth = 1; @@ -2503,9 +2503,9 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) /* 2. Chain Buffer initialization */ - /* 4. Renegotiate to all devices, if SCSI + /* 4. Renegotiate to all devices, if SPI */ - if (ioc->bus_type == SCSI) { + if (ioc->bus_type == SPI) { dnegoprintk(("writeSDP1: ALL_IDS USE_NVRAM\n")); mptscsih_writeSDP1(hd, 0, 0, MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM); } @@ -2534,7 +2534,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) /* 7. Set flag to force DV and re-read IOC Page 3 */ - if (ioc->bus_type == SCSI) { + if (ioc->bus_type == SPI) { ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3; ddvtprintk(("Set reload IOC Pg3 Flag\n")); } @@ -2576,7 +2576,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) break; case MPI_EVENT_IOC_BUS_RESET: /* 04 */ case MPI_EVENT_EXT_BUS_RESET: /* 05 */ - if (hd && (ioc->bus_type == SCSI) && (hd->soft_resets < -1)) + if (hd && (ioc->bus_type == SPI) && (hd->soft_resets < -1)) hd->soft_resets++; break; case MPI_EVENT_LOGOUT: /* 09 */ @@ -2601,7 +2601,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) (pMpiEventDataRaid_t) pEvReply->Data; #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION /* Domain Validation Needed */ - if (ioc->bus_type == SCSI && + if (ioc->bus_type == SPI && pRaidEventData->ReasonCode == MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) mptscsih_set_dvflags_raid(hd, pRaidEventData->PhysDiskNum); @@ -2682,7 +2682,7 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char * indexed_lun = (lun % 32); vdev->luns[lun_index] |= (1 << indexed_lun); - if (hd->ioc->bus_type == SCSI) { + if (hd->ioc->bus_type == SPI) { if ((data[0] == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) { /* Treat all Processors as SAF-TE if * command line option is set */ @@ -3956,10 +3956,10 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum) if (id == hostId) id++; - /* Write SDP1 for all SCSI devices + /* Write SDP1 for all SPI devices * Alloc memory and set up config buffer */ - if (ioc->bus_type == SCSI) { + if (ioc->bus_type == SPI) { if (ioc->spi_data.sdp1length > 0) { pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev, ioc->spi_data.sdp1length * 4, &cfg1_dma_addr); @@ -4101,8 +4101,8 @@ mptscsih_domainValidation(void *arg) msleep(250); - /* DV only to SCSI adapters */ - if (ioc->bus_type != SCSI) + /* DV only to SPI adapters */ + if (ioc->bus_type != SPI) continue; /* Make sure everything looks ok */ -- cgit v1.1 From f2ea8671a8376e09cf759aa8cb3de8b8d3bced9e Mon Sep 17 00:00:00 2001 From: "Moore, Eric Dean" Date: Wed, 16 Nov 2005 18:54:23 -0700 Subject: [SCSI] mptfusion - prep for removing domain validation This moves some functions around from within the #define MPTSCSIH_ENABLE_DOMAIN_VALIDATION area, in preperation for generic domain validation. Signed-off-by: Eric Moore Signed-off-by: James Bottomley --- drivers/message/fusion/mptscsih.c | 225 +++++++++++++++++++------------------- 1 file changed, 114 insertions(+), 111 deletions(-) diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 2d01424..a5ca749 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -152,7 +152,6 @@ int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply static void mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen); static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56); -static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq); static void mptscsih_setDevicePage1Flags (u8 width, u8 factor, u8 offset, int *requestedPtr, int *configurationPtr, u8 flags); static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id); static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags); @@ -160,18 +159,19 @@ static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus); int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); +static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id); static struct work_struct mptscsih_persistTask; #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io); static void mptscsih_domainValidation(void *hd); -static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id); static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id); static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target); static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); static void mptscsih_fillbuf(char *buffer, int size, int index, int width); static void mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id); +static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq); #endif void mptscsih_remove(struct pci_dev *); @@ -993,8 +993,10 @@ mptscsih_remove(struct pci_dev *pdev) MPT_ADAPTER *ioc = pci_get_drvdata(pdev); struct Scsi_Host *host = ioc->sh; MPT_SCSI_HOST *hd; +#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION int count; unsigned long flags; +#endif int sz1; if(!host) { @@ -2597,9 +2599,9 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) case MPI_EVENT_INTEGRATED_RAID: /* 0B */ { +#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION pMpiEventDataRaid_t pRaidEventData = (pMpiEventDataRaid_t) pEvReply->Data; -#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION /* Domain Validation Needed */ if (ioc->bus_type == SPI && pRaidEventData->ReasonCode == @@ -2926,94 +2928,6 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) } /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ -/* If DV disabled (negoNvram set to USE_NVARM) or if not LUN 0, return. - * Else set the NEED_DV flag after Read Capacity Issued (disks) - * or Mode Sense (cdroms). - * - * Tapes, initTarget will set this flag on completion of Inquiry command. - * Called only if DV_NOT_DONE flag is set - */ -static void -mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) -{ - MPT_ADAPTER *ioc = hd->ioc; - u8 cmd; - SpiCfgData *pSpi; - - ddvtprintk((MYIOC_s_NOTE_FMT - " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", - hd->ioc->name, pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); - - if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) - return; - - cmd = pReq->CDB[0]; - - if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) { - pSpi = &ioc->spi_data; - if ((ioc->raid_data.isRaid & (1 << pReq->TargetID)) && ioc->raid_data.pIocPg3) { - /* Set NEED_DV for all hidden disks - */ - Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk; - int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks; - - while (numPDisk) { - pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV; - ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID)); - pPDisk++; - numPDisk--; - } - } - pSpi->dvStatus[pReq->TargetID] |= MPT_SCSICFG_NEED_DV; - ddvtprintk(("NEED_DV set for visible disk id %d\n", pReq->TargetID)); - } -} - -/* mptscsih_raid_set_dv_flags() - * - * New or replaced disk. Set DV flag and schedule DV. - */ -static void -mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id) -{ - MPT_ADAPTER *ioc = hd->ioc; - SpiCfgData *pSpi = &ioc->spi_data; - Ioc3PhysDisk_t *pPDisk; - int numPDisk; - - if (hd->negoNvram != 0) - return; - - ddvtprintk(("DV requested for phys disk id %d\n", id)); - if (ioc->raid_data.pIocPg3) { - pPDisk = ioc->raid_data.pIocPg3->PhysDisk; - numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks; - while (numPDisk) { - if (id == pPDisk->PhysDiskNum) { - pSpi->dvStatus[pPDisk->PhysDiskID] = - (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE); - pSpi->forceDv = MPT_SCSICFG_NEED_DV; - ddvtprintk(("NEED_DV set for phys disk id %d\n", - pPDisk->PhysDiskID)); - break; - } - pPDisk++; - numPDisk--; - } - - if (numPDisk == 0) { - /* The physical disk that needs DV was not found - * in the stored IOC Page 3. The driver must reload - * this page. DV routine will set the NEED_DV flag for - * all phys disks that have DV_NOT_DONE set. - */ - pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3; - ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n",id)); - } - } -} - -/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* * If no Target, bus reset on 1st I/O. Set the flag to * prevent any future negotiations to this device. @@ -4052,6 +3966,26 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum) return 0; } +/* Search IOC page 3 to determine if this is hidden physical disk + */ +/* Search IOC page 3 to determine if this is hidden physical disk + */ +static int +mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) +{ + int i; + + if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3) + return 0; + + for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { + if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) + return 1; + } + + return 0; +} + #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /** @@ -4205,26 +4139,6 @@ mptscsih_domainValidation(void *arg) return; } -/* Search IOC page 3 to determine if this is hidden physical disk - */ -/* Search IOC page 3 to determine if this is hidden physical disk - */ -static int -mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id) -{ - int i; - - if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3) - return 0; - - for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { - if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID) - return 1; - } - - return 0; -} - /* Write SDP1 if no QAS has been enabled */ static void @@ -5588,6 +5502,95 @@ mptscsih_fillbuf(char *buffer, int size, int index, int width) break; } } + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +/* If DV disabled (negoNvram set to USE_NVARM) or if not LUN 0, return. + * Else set the NEED_DV flag after Read Capacity Issued (disks) + * or Mode Sense (cdroms). + * + * Tapes, initTarget will set this flag on completion of Inquiry command. + * Called only if DV_NOT_DONE flag is set + */ +static void +mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) +{ + MPT_ADAPTER *ioc = hd->ioc; + u8 cmd; + SpiCfgData *pSpi; + + ddvtprintk((MYIOC_s_NOTE_FMT + " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", + hd->ioc->name, pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); + + if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) + return; + + cmd = pReq->CDB[0]; + + if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) { + pSpi = &ioc->spi_data; + if ((ioc->raid_data.isRaid & (1 << pReq->TargetID)) && ioc->raid_data.pIocPg3) { + /* Set NEED_DV for all hidden disks + */ + Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk; + int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks; + + while (numPDisk) { + pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV; + ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID)); + pPDisk++; + numPDisk--; + } + } + pSpi->dvStatus[pReq->TargetID] |= MPT_SCSICFG_NEED_DV; + ddvtprintk(("NEED_DV set for visible disk id %d\n", pReq->TargetID)); + } +} + +/* mptscsih_raid_set_dv_flags() + * + * New or replaced disk. Set DV flag and schedule DV. + */ +static void +mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id) +{ + MPT_ADAPTER *ioc = hd->ioc; + SpiCfgData *pSpi = &ioc->spi_data; + Ioc3PhysDisk_t *pPDisk; + int numPDisk; + + if (hd->negoNvram != 0) + return; + + ddvtprintk(("DV requested for phys disk id %d\n", id)); + if (ioc->raid_data.pIocPg3) { + pPDisk = ioc->raid_data.pIocPg3->PhysDisk; + numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks; + while (numPDisk) { + if (id == pPDisk->PhysDiskNum) { + pSpi->dvStatus[pPDisk->PhysDiskID] = + (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE); + pSpi->forceDv = MPT_SCSICFG_NEED_DV; + ddvtprintk(("NEED_DV set for phys disk id %d\n", + pPDisk->PhysDiskID)); + break; + } + pPDisk++; + numPDisk--; + } + + if (numPDisk == 0) { + /* The physical disk that needs DV was not found + * in the stored IOC Page 3. The driver must reload + * this page. DV routine will set the NEED_DV flag for + * all phys disks that have DV_NOT_DONE set. + */ + pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3; + ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n",id)); + } + } +} + #endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */ EXPORT_SYMBOL(mptscsih_remove); -- cgit v1.1 From c7c82987b4844f555d309ccbd42abe95d46822ff Mon Sep 17 00:00:00 2001 From: "Moore, Eric Dean" Date: Wed, 16 Nov 2005 18:54:25 -0700 Subject: [SCSI] mptfusion - mapping fixs required support for transport layers. This utilizes the hostdata area that is hung off of scsi_target and scsi_device for saving unique firmware mapping. This will be required for supporting new Fibre and SPI transport support. This also fixs problems in error handling error code for SAS controllers, in which the incorrect mapping was passed to the firmware. Signed-off-by: Eric Moore Signed-off-by: James Bottomley --- drivers/message/fusion/mptbase.h | 28 +- drivers/message/fusion/mptctl.c | 4 +- drivers/message/fusion/mptfc.c | 6 +- drivers/message/fusion/mptsas.c | 37 +- drivers/message/fusion/mptscsih.c | 745 +++++++++++++++++++------------------- drivers/message/fusion/mptscsih.h | 2 + drivers/message/fusion/mptspi.c | 6 +- 7 files changed, 411 insertions(+), 417 deletions(-) diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index 7a6c114..2a46b33 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h @@ -321,7 +321,7 @@ typedef struct _SYSIF_REGS * Dynamic Multi-Pathing specific stuff... */ -/* VirtDevice negoFlags field */ +/* VirtTarget negoFlags field */ #define MPT_TARGET_NO_NEGO_WIDE 0x01 #define MPT_TARGET_NO_NEGO_SYNC 0x02 #define MPT_TARGET_NO_NEGO_QAS 0x04 @@ -330,8 +330,7 @@ typedef struct _SYSIF_REGS /* * VirtDevice - FC LUN device or SCSI target device */ -typedef struct _VirtDevice { - struct scsi_device *device; +typedef struct _VirtTarget { u8 tflags; u8 ioc_id; u8 target_id; @@ -342,21 +341,18 @@ typedef struct _VirtDevice { u8 negoFlags; /* bit field, see above */ u8 raidVolume; /* set, if RAID Volume */ u8 type; /* byte 0 of Inquiry data */ - u8 cflags; /* controller flags */ - u8 rsvd1raid; - u16 fc_phys_lun; - u16 fc_xlat_lun; u32 num_luns; u32 luns[8]; /* Max LUNs is 256 */ - u8 pad[4]; u8 inq_data[8]; - /* IEEE Registered Extended Identifier - obtained via INQUIRY VPD page 0x83 */ - /* NOTE: Do not separate uniq_prepad and uniq_data - as they are treateed as a single entity in the code */ - u8 uniq_prepad[8]; - u8 uniq_data[20]; - u8 pad2[4]; +} VirtTarget; + +typedef struct _VirtDevice { + VirtTarget *vtarget; + u8 ioc_id; + u8 bus_id; + u8 target_id; + u8 configured_lun; + u32 lun; } VirtDevice; /* @@ -912,7 +908,7 @@ typedef struct _MPT_SCSI_HOST { int port; u32 pad0; struct scsi_cmnd **ScsiLookup; - VirtDevice **Targets; + VirtTarget **Targets; MPT_LOCAL_REPLY *pLocal; /* used for internal commands */ struct timer_list timer; /* Pool of memory for holding SCpnts before doing diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index 602138f..959d2c59 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c @@ -1245,7 +1245,7 @@ mptctl_gettargetinfo (unsigned long arg) MPT_ADAPTER *ioc; struct Scsi_Host *sh; MPT_SCSI_HOST *hd; - VirtDevice *vdev; + VirtTarget *vdev; char *pmem; int *pdata; IOCPage2_t *pIoc2; @@ -1822,7 +1822,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr) case MPI_FUNCTION_SCSI_IO_REQUEST: if (ioc->sh) { SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; - VirtDevice *pTarget = NULL; + VirtTarget *pTarget = NULL; MPT_SCSI_HOST *hd = NULL; int qtag = MPI_SCSIIO_CONTROL_UNTAGGED; int scsidir = 0; diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c index 531664f..ba61e18 100644 --- a/drivers/message/fusion/mptfc.c +++ b/drivers/message/fusion/mptfc.c @@ -90,8 +90,10 @@ static struct scsi_host_template mptfc_driver_template = { .name = "MPT FC Host", .info = mptscsih_info, .queuecommand = mptscsih_qcmd, + .target_alloc = mptscsih_target_alloc, .slave_alloc = mptscsih_slave_alloc, .slave_configure = mptscsih_slave_configure, + .target_destroy = mptscsih_target_destroy, .slave_destroy = mptscsih_slave_destroy, .change_queue_depth = mptscsih_change_queue_depth, .eh_abort_handler = mptscsih_abort, @@ -292,10 +294,10 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id) } memset(mem, 0, sz); - hd->Targets = (VirtDevice **) mem; + hd->Targets = (VirtTarget **) mem; dprintk((KERN_INFO - " Targets @ %p, sz=%d\n", hd->Targets, sz)); + " vdev @ %p, sz=%d\n", hd->Targets, sz)); /* Clear the TM flags */ diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c index 282fb5e..17e9757e 100644 --- a/drivers/message/fusion/mptsas.c +++ b/drivers/message/fusion/mptsas.c @@ -228,31 +228,35 @@ static void mptsas_print_expander_pg1(SasExpanderPage1_t *pg1) * implement ->target_alloc. */ static int -mptsas_slave_alloc(struct scsi_device *device) +mptsas_slave_alloc(struct scsi_device *sdev) { - struct Scsi_Host *host = device->host; + struct Scsi_Host *host = sdev->host; MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; struct sas_rphy *rphy; struct mptsas_portinfo *p; + VirtTarget *vtarget; VirtDevice *vdev; - uint target = device->id; + struct scsi_target *starget; int i; - if ((vdev = hd->Targets[target]) != NULL) - goto out; - vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); if (!vdev) { printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", hd->ioc->name, sizeof(VirtDevice)); return -ENOMEM; } - memset(vdev, 0, sizeof(VirtDevice)); - vdev->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY; vdev->ioc_id = hd->ioc->id; + sdev->hostdata = vdev; + starget = scsi_target(sdev); + vtarget = starget->hostdata; + vdev->vtarget = vtarget; + if (vtarget->num_luns == 0) { + vtarget->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY; + hd->Targets[sdev->id] = vtarget; + } - rphy = dev_to_rphy(device->sdev_target->dev.parent); + rphy = dev_to_rphy(sdev->sdev_target->dev.parent); list_for_each_entry(p, &hd->ioc->sas_topology, list) { for (i = 0; i < p->num_phys; i++) { if (p->phy_info[i].attached.sas_address == @@ -260,7 +264,7 @@ mptsas_slave_alloc(struct scsi_device *device) vdev->target_id = p->phy_info[i].attached.target; vdev->bus_id = p->phy_info[i].attached.bus; - hd->Targets[device->id] = vdev; + vdev->lun = sdev->lun; goto out; } } @@ -271,8 +275,10 @@ mptsas_slave_alloc(struct scsi_device *device) return -ENODEV; out: - vdev->num_luns++; - device->hostdata = vdev; + vtarget->ioc_id = vdev->ioc_id; + vtarget->target_id = vdev->target_id; + vtarget->bus_id = vdev->bus_id; + vtarget->num_luns++; return 0; } @@ -283,8 +289,10 @@ static struct scsi_host_template mptsas_driver_template = { .name = "MPT SPI Host", .info = mptscsih_info, .queuecommand = mptscsih_qcmd, + .target_alloc = mptscsih_target_alloc, .slave_alloc = mptsas_slave_alloc, .slave_configure = mptscsih_slave_configure, + .target_destroy = mptscsih_target_destroy, .slave_destroy = mptscsih_slave_destroy, .change_queue_depth = mptscsih_change_queue_depth, .eh_abort_handler = mptscsih_abort, @@ -987,7 +995,6 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index) goto out_free_port_info; list_add_tail(&port_info->list, &ioc->sas_topology); - for (i = 0; i < port_info->num_phys; i++) { mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER << @@ -1263,10 +1270,10 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id) } memset(mem, 0, sz); - hd->Targets = (VirtDevice **) mem; + hd->Targets = (VirtTarget **) mem; dprintk((KERN_INFO - " Targets @ %p, sz=%d\n", hd->Targets, sz)); + " vtarget @ %p, sz=%d\n", hd->Targets, sz)); /* Clear the TM flags */ diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index a5ca749..93a16fa 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -150,15 +150,16 @@ static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 tar int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply); -static void mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen); -static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56); +static void mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, u8 lun, char *data, int dlen); +static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *vtarget, char byte56); static void mptscsih_setDevicePage1Flags (u8 width, u8 factor, u8 offset, int *requestedPtr, int *configurationPtr, u8 flags); -static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id); +static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc); static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags); static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus); int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); -static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); +static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice); +static void mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget); static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id); static struct work_struct mptscsih_persistTask; @@ -171,7 +172,7 @@ static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target); static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); static void mptscsih_fillbuf(char *buffer, int size, int index, int width); static void mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id); -static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq); +static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc); #endif void mptscsih_remove(struct pci_dev *); @@ -627,7 +628,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n" "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n" "resid=%d bufflen=%d xfer_cnt=%d\n", - ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], + ioc->id, sc->device->id, sc->device->lun, status, scsi_state, scsi_status, sc->resid, sc->request_bufflen, xfer_cnt)); @@ -641,7 +642,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) pScsiReply->ResponseInfo) { printk(KERN_NOTICE "ha=%d id=%d lun=%d: " "FCP_ResponseInfo=%08xh\n", - ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], + ioc->id, sc->device->id, sc->device->lun, le32_to_cpu(pScsiReply->ResponseInfo)); } @@ -678,7 +679,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr) /* GEM Workaround. */ if (ioc->bus_type == SPI) - mptscsih_no_negotiate(hd, sc->device->id); + mptscsih_no_negotiate(hd, sc); break; case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ @@ -892,16 +893,15 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd) * when a lun is disable by mid-layer. * Do NOT access the referenced scsi_cmnd structure or * members. Will cause either a paging or NULL ptr error. - * @hd: Pointer to a SCSI HOST structure - * @target: target id - * @lun: lun + * @hd: Pointer to a SCSI HOST structure + * @vdevice: per device private data * * Returns: None. * * Called from slave_destroy. */ static void -mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun) +mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice) { SCSIIORequest_t *mf = NULL; int ii; @@ -909,7 +909,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun) struct scsi_cmnd *sc; dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", - target, lun, max)); + vdevice->target_id, vdevice->lun, max)); for (ii=0; ii < max; ii++) { if ((sc = hd->ScsiLookup[ii]) != NULL) { @@ -919,7 +919,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun) dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n", hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1])); - if ((mf->TargetID != ((u8)target)) || (mf->LUN[1] != ((u8) lun))) + if ((mf->TargetID != ((u8)vdevice->target_id)) || (mf->LUN[1] != ((u8) vdevice->lun))) continue; /* Cleanup @@ -996,7 +996,7 @@ mptscsih_remove(struct pci_dev *pdev) #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION int count; unsigned long flags; -#endif +#endif int sz1; if(!host) { @@ -1077,11 +1077,6 @@ mptscsih_shutdown(struct pci_dev *pdev) hd = (MPT_SCSI_HOST *)host->hostdata; - /* Flush the cache of this adapter - */ - if(hd != NULL) - mptscsih_synchronize_cache(hd, 0); - } #ifdef CONFIG_PM @@ -1288,7 +1283,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) MPT_SCSI_HOST *hd; MPT_FRAME_HDR *mf; SCSIIORequest_t *pScsiReq; - VirtDevice *pTarget = SCpnt->device->hostdata; + VirtDevice *vdev = SCpnt->device->hostdata; int lun; u32 datalen; u32 scsictl; @@ -1343,8 +1338,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) /* Default to untagged. Once a target structure has been allocated, * use the Inquiry data to determine if device supports tagged. */ - if (pTarget - && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) + if (vdev + && (vdev->vtarget->tflags & MPT_TARGET_FLAGS_Q_YES) && (SCpnt->device->tagged_supported)) { scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; } else { @@ -1353,8 +1348,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) /* Use the above information to set up the message frame */ - pScsiReq->TargetID = (u8) pTarget->target_id; - pScsiReq->Bus = pTarget->bus_id; + pScsiReq->TargetID = (u8) vdev->target_id; + pScsiReq->Bus = vdev->bus_id; pScsiReq->ChainOffset = 0; pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; pScsiReq->CDBLength = SCpnt->cmd_len; @@ -1406,7 +1401,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION if (hd->ioc->bus_type == SPI) { - int dvStatus = hd->ioc->spi_data.dvStatus[pTarget->target_id]; + int dvStatus = hd->ioc->spi_data.dvStatus[vdev->target_id]; int issueCmd = 1; if (dvStatus || hd->ioc->spi_data.forceDv) { @@ -1439,7 +1434,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) /* Set the DV flags. */ if (dvStatus & MPT_SCSICFG_DV_NOT_DONE) - mptscsih_set_dvflags(hd, pScsiReq); + mptscsih_set_dvflags(hd, SCpnt); if (!issueCmd) goto fail; @@ -1743,6 +1738,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) u32 ctx2abort; int scpnt_idx; int retval; + VirtDevice *vdev; /* If we can't locate our host adapter structure, return FAILED status. */ @@ -1792,8 +1788,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt) hd->abortSCpnt = SCpnt; + vdev = SCpnt->device->hostdata; retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, - SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, + vdev->bus_id, vdev->target_id, vdev->lun, ctx2abort, 2 /* 2 second timeout */); printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n", @@ -1824,6 +1821,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) { MPT_SCSI_HOST *hd; int retval; + VirtDevice *vdev; /* If we can't locate our host adapter structure, return FAILED status. */ @@ -1841,8 +1839,9 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) hd->ioc->name, SCpnt); scsi_print_command(SCpnt); + vdev = SCpnt->device->hostdata; retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, - SCpnt->device->channel, SCpnt->device->id, + vdev->bus_id, vdev->target_id, 0, 0, 5 /* 5 second timeout */); printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n", @@ -1873,6 +1872,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) { MPT_SCSI_HOST *hd; int retval; + VirtDevice *vdev; /* If we can't locate our host adapter structure, return FAILED status. */ @@ -1890,8 +1890,9 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt) if (hd->timeouts < -1) hd->timeouts++; + vdev = SCpnt->device->hostdata; retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, - SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */); + vdev->bus_id, 0, 0, 0, 5 /* 5 second timeout */); printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n", hd->ioc->name, @@ -2153,23 +2154,36 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* * OS entry point to allow host driver to alloc memory + * for each scsi target. Called once per device the bus scan. + * Return non-zero if allocation fails. + */ +int +mptscsih_target_alloc(struct scsi_target *starget) +{ + VirtTarget *vtarget; + + vtarget = kmalloc(sizeof(VirtTarget), GFP_KERNEL); + if (!vtarget) + return -ENOMEM; + memset(vtarget, 0, sizeof(VirtTarget)); + starget->hostdata = vtarget; + return 0; +} + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +/* + * OS entry point to allow host driver to alloc memory * for each scsi device. Called once per device the bus scan. * Return non-zero if allocation fails. - * Init memory once per id (not LUN). */ int -mptscsih_slave_alloc(struct scsi_device *device) +mptscsih_slave_alloc(struct scsi_device *sdev) { - struct Scsi_Host *host = device->host; + struct Scsi_Host *host = sdev->host; MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; + VirtTarget *vtarget; VirtDevice *vdev; - uint target = device->id; - - if (hd == NULL) - return -ENODEV; - - if ((vdev = hd->Targets[target]) != NULL) - goto out; + struct scsi_target *starget; vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); if (!vdev) { @@ -2179,25 +2193,33 @@ mptscsih_slave_alloc(struct scsi_device *device) } memset(vdev, 0, sizeof(VirtDevice)); - vdev->tflags = MPT_TARGET_FLAGS_Q_YES; vdev->ioc_id = hd->ioc->id; - vdev->target_id = device->id; - vdev->bus_id = device->channel; - vdev->raidVolume = 0; - hd->Targets[device->id] = vdev; - if (hd->ioc->bus_type == SPI) { - if (hd->ioc->raid_data.isRaid & (1 << device->id)) { - vdev->raidVolume = 1; - ddvtprintk((KERN_INFO - "RAID Volume @ id %d\n", device->id)); + vdev->target_id = sdev->id; + vdev->bus_id = sdev->channel; + vdev->lun = sdev->lun; + sdev->hostdata = vdev; + + starget = scsi_target(sdev); + vtarget = starget->hostdata; + vdev->vtarget = vtarget; + + if (vtarget->num_luns == 0) { + hd->Targets[sdev->id] = vtarget; + vtarget->ioc_id = hd->ioc->id; + vtarget->tflags = MPT_TARGET_FLAGS_Q_YES; + vtarget->target_id = sdev->id; + vtarget->bus_id = sdev->channel; + if (hd->ioc->bus_type == SPI) { + if (hd->ioc->raid_data.isRaid & (1 << sdev->id)) { + vtarget->raidVolume = 1; + ddvtprintk((KERN_INFO + "RAID Volume @ id %d\n", sdev->id)); + } + } else { + vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY; } - } else { - vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY; } - - out: - vdev->num_luns++; - device->hostdata = vdev; + vtarget->num_luns++; return 0; } @@ -2206,40 +2228,52 @@ mptscsih_slave_alloc(struct scsi_device *device) * Called if no device present or device being unloaded */ void -mptscsih_slave_destroy(struct scsi_device *device) +mptscsih_target_destroy(struct scsi_target *starget) { - struct Scsi_Host *host = device->host; - MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; - VirtDevice *vdev; - uint target = device->id; - uint lun = device->lun; - - if (hd == NULL) - return; - - mptscsih_search_running_cmds(hd, target, lun); - - vdev = hd->Targets[target]; - vdev->luns[0] &= ~(1 << lun); - if (--vdev->num_luns) - return; - - kfree(hd->Targets[target]); - hd->Targets[target] = NULL; - - if (hd->ioc->bus_type == SPI) { - if (mptscsih_is_phys_disk(hd->ioc, target)) { - hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; - } else { - hd->ioc->spi_data.dvStatus[target] = - MPT_SCSICFG_NEGOTIATE; + if (starget->hostdata) + kfree(starget->hostdata); + starget->hostdata = NULL; +} - if (!hd->negoNvram) { - hd->ioc->spi_data.dvStatus[target] |= - MPT_SCSICFG_DV_NOT_DONE; +/* + * OS entry point to allow for host driver to free allocated memory + * Called if no device present or device being unloaded + */ +void +mptscsih_slave_destroy(struct scsi_device *sdev) +{ + struct Scsi_Host *host = sdev->host; + MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; + VirtTarget *vtarget; + VirtDevice *vdevice; + struct scsi_target *starget; + + starget = scsi_target(sdev); + vtarget = starget->hostdata; + vdevice = sdev->hostdata; + + mptscsih_search_running_cmds(hd, vdevice); + vtarget->luns[0] &= ~(1 << vdevice->lun); + vtarget->num_luns--; + if (vtarget->num_luns == 0) { + mptscsih_negotiate_to_asyn_narrow(hd, vtarget); + if (hd->ioc->bus_type == SPI) { + if (mptscsih_is_phys_disk(hd->ioc, vtarget->target_id)) { + hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3; + } else { + hd->ioc->spi_data.dvStatus[vtarget->target_id] = + MPT_SCSICFG_NEGOTIATE; + if (!hd->negoNvram) { + hd->ioc->spi_data.dvStatus[vtarget->target_id] |= + MPT_SCSICFG_DV_NOT_DONE; + } } } + hd->Targets[sdev->id] = NULL; } + mptscsih_synchronize_cache(hd, vdevice); + kfree(vdevice); + sdev->hostdata = NULL; } /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ @@ -2253,22 +2287,21 @@ mptscsih_slave_destroy(struct scsi_device *device) int mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) { - MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; - VirtDevice *pTarget; - int max_depth; - int tagged; + MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; + VirtTarget *vtarget; + struct scsi_target *starget; + int max_depth; + int tagged; - if (hd == NULL) - return 0; - if (!(pTarget = hd->Targets[sdev->id])) - return 0; + starget = scsi_target(sdev); + vtarget = starget->hostdata; if (hd->ioc->bus_type == SPI) { - if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) { - if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES)) + if (vtarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) { + if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)) max_depth = 1; - else if (((pTarget->inq_data[0] & 0x1f) == 0x00) && - (pTarget->minSyncFactor <= MPT_ULTRA160 )) + else if (((vtarget->inq_data[0] & 0x1f) == 0x00) && + (vtarget->minSyncFactor <= MPT_ULTRA160 )) max_depth = MPT_SCSI_CMD_PER_DEV_HIGH; else max_depth = MPT_SCSI_CMD_PER_DEV_LOW; @@ -2297,64 +2330,58 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) * Return non-zero if fails. */ int -mptscsih_slave_configure(struct scsi_device *device) +mptscsih_slave_configure(struct scsi_device *sdev) { - struct Scsi_Host *sh = device->host; - VirtDevice *pTarget; + struct Scsi_Host *sh = sdev->host; + VirtTarget *vtarget; + VirtDevice *vdevice; + struct scsi_target *starget; MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; + int indexed_lun, lun_index; - if ((hd == NULL) || (hd->Targets == NULL)) { - return 0; - } + starget = scsi_target(sdev); + vtarget = starget->hostdata; + vdevice = sdev->hostdata; dsprintk((MYIOC_s_INFO_FMT "device @ %p, id=%d, LUN=%d, channel=%d\n", - hd->ioc->name, device, device->id, device->lun, device->channel)); - dsprintk((MYIOC_s_INFO_FMT - "sdtr %d wdtr %d ppr %d inq length=%d\n", - hd->ioc->name, device->sdtr, device->wdtr, - device->ppr, device->inquiry_len)); - - if (device->id > sh->max_id) { + hd->ioc->name, sdev, sdev->id, sdev->lun, sdev->channel)); + if (hd->ioc->bus_type == SPI) + dsprintk((MYIOC_s_INFO_FMT + "sdtr %d wdtr %d ppr %d inq length=%d\n", + hd->ioc->name, sdev->sdtr, sdev->wdtr, + sdev->ppr, sdev->inquiry_len)); + + if (sdev->id > sh->max_id) { /* error case, should never happen */ - scsi_adjust_queue_depth(device, 0, 1); - goto slave_configure_exit; - } - - pTarget = hd->Targets[device->id]; - - if (pTarget == NULL) { - /* Driver doesn't know about this device. - * Kernel may generate a "Dummy Lun 0" which - * may become a real Lun if a - * "scsi add-single-device" command is executed - * while the driver is active (hot-plug a - * device). LSI Raid controllers need - * queue_depth set to DEV_HIGH for this reason. - */ - scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG, - MPT_SCSI_CMD_PER_DEV_HIGH); + scsi_adjust_queue_depth(sdev, 0, 1); goto slave_configure_exit; } - mptscsih_initTarget(hd, device->channel, device->id, device->lun, - device->inquiry, device->inquiry_len ); - mptscsih_change_queue_depth(device, MPT_SCSI_CMD_PER_DEV_HIGH); + vdevice->configured_lun=1; + lun_index = (vdevice->lun >> 5); /* 32 luns per lun_index */ + indexed_lun = (vdevice->lun % 32); + vtarget->luns[lun_index] |= (1 << indexed_lun); + mptscsih_initTarget(hd, vtarget, sdev->lun, sdev->inquiry, + sdev->inquiry_len ); + mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH); dsprintk((MYIOC_s_INFO_FMT "Queue depth=%d, tflags=%x\n", - hd->ioc->name, device->queue_depth, pTarget->tflags)); + hd->ioc->name, sdev->queue_depth, vtarget->tflags)); - dsprintk((MYIOC_s_INFO_FMT - "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", - hd->ioc->name, pTarget->negoFlags, pTarget->maxOffset, pTarget->minSyncFactor)); + if (hd->ioc->bus_type == SPI) + dsprintk((MYIOC_s_INFO_FMT + "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", + hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset, + vtarget->minSyncFactor)); slave_configure_exit: dsprintk((MYIOC_s_INFO_FMT "tagged %d, simple %d, ordered %d\n", - hd->ioc->name,device->tagged_supported, device->simple_tags, - device->ordered_tags)); + hd->ioc->name,sdev->tagged_supported, sdev->simple_tags, + sdev->ordered_tags)); return 0; } @@ -2372,16 +2399,14 @@ slave_configure_exit: static void mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) { - VirtDevice *target; + VirtDevice *vdev; SCSIIORequest_t *pReq; u32 sense_count = le32_to_cpu(pScsiReply->SenseCount); - int index; /* Get target structure */ pReq = (SCSIIORequest_t *) mf; - index = (int) pReq->TargetID; - target = hd->Targets[index]; + vdev = sc->device->hostdata; if (sense_count) { u8 *sense_data; @@ -2395,7 +2420,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR /* Log SMART data (asc = 0x5D, non-IM case only) if required. */ if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) { - if ((sense_data[12] == 0x5D) && (target->raidVolume == 0)) { + if ((sense_data[12] == 0x5D) && (vdev->vtarget->raidVolume == 0)) { int idx; MPT_ADAPTER *ioc = hd->ioc; @@ -2405,7 +2430,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR ioc->events[idx].data[0] = (pReq->LUN[1] << 24) || (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) || - (pReq->Bus << 8) || pReq->TargetID; + (sc->device->channel << 8) || sc->device->id; ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12]; @@ -2634,8 +2659,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) /* * mptscsih_initTarget - Target, LUN alloc/free functionality. * @hd: Pointer to MPT_SCSI_HOST structure - * @bus_id: Bus number (?) - * @target_id: SCSI target id + * @vtarget: per target private data * @lun: SCSI LUN id * @data: Pointer to data * @dlen: Number of INQUIRY bytes @@ -2648,15 +2672,14 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply) * */ static void -mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen) +mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, u8 lun, char *data, int dlen) { - int indexed_lun, lun_index; - VirtDevice *vdev; SpiCfgData *pSpi; char data_56; + int inq_len; dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n", - hd->ioc->name, bus_id, target_id, lun, hd)); + hd->ioc->name, vtarget->bus_id, vtarget->target_id, lun, hd)); /* * If the peripheral qualifier filter is enabled then if the target reports a 0x1 @@ -2676,75 +2699,68 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char * if (data[0] & 0xe0) return; - if ((vdev = hd->Targets[target_id]) == NULL) { + if (vtarget == NULL) return; - } - lun_index = (lun >> 5); /* 32 luns per lun_index */ - indexed_lun = (lun % 32); - vdev->luns[lun_index] |= (1 << indexed_lun); + if (data) + vtarget->type = data[0]; - if (hd->ioc->bus_type == SPI) { - if ((data[0] == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) { - /* Treat all Processors as SAF-TE if - * command line option is set */ - vdev->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; - mptscsih_writeIOCPage4(hd, target_id, bus_id); - }else if ((data[0] == TYPE_PROCESSOR) && - !(vdev->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) { - if ( dlen > 49 ) { - vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY; - if ( data[44] == 'S' && - data[45] == 'A' && - data[46] == 'F' && - data[47] == '-' && - data[48] == 'T' && - data[49] == 'E' ) { - vdev->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; - mptscsih_writeIOCPage4(hd, target_id, bus_id); - } + if (hd->ioc->bus_type != SPI) + return; + + if ((data[0] == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) { + /* Treat all Processors as SAF-TE if + * command line option is set */ + vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; + mptscsih_writeIOCPage4(hd, vtarget->target_id, vtarget->bus_id); + }else if ((data[0] == TYPE_PROCESSOR) && + !(vtarget->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) { + if ( dlen > 49 ) { + vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY; + if ( data[44] == 'S' && + data[45] == 'A' && + data[46] == 'F' && + data[47] == '-' && + data[48] == 'T' && + data[49] == 'E' ) { + vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; + mptscsih_writeIOCPage4(hd, vtarget->target_id, vtarget->bus_id); } } - if (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) { - if ( dlen > 8 ) { - memcpy (vdev->inq_data, data, 8); - } else { - memcpy (vdev->inq_data, data, dlen); - } + } + if (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) { + inq_len = dlen < 8 ? dlen : 8; + memcpy (vtarget->inq_data, data, inq_len); + /* If have not done DV, set the DV flag. + */ + pSpi = &hd->ioc->spi_data; + if ((data[0] == TYPE_TAPE) || (data[0] == TYPE_PROCESSOR)) { + if (pSpi->dvStatus[vtarget->target_id] & MPT_SCSICFG_DV_NOT_DONE) + pSpi->dvStatus[vtarget->target_id] |= MPT_SCSICFG_NEED_DV; + } + vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY; - /* If have not done DV, set the DV flag. + data_56 = 0x0F; /* Default to full capabilities if Inq data length is < 57 */ + if (dlen > 56) { + if ( (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_56))) { + /* Update the target capabilities */ - pSpi = &hd->ioc->spi_data; - if ((data[0] == TYPE_TAPE) || (data[0] == TYPE_PROCESSOR)) { - if (pSpi->dvStatus[target_id] & MPT_SCSICFG_DV_NOT_DONE) - pSpi->dvStatus[target_id] |= MPT_SCSICFG_NEED_DV; - } - - vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY; - - - data_56 = 0x0F; /* Default to full capabilities if Inq data length is < 57 */ - if (dlen > 56) { - if ( (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_56))) { - /* Update the target capabilities - */ - data_56 = data[56]; - vdev->tflags |= MPT_TARGET_FLAGS_VALID_56; - } + data_56 = data[56]; + vtarget->tflags |= MPT_TARGET_FLAGS_VALID_56; } - mptscsih_setTargetNegoParms(hd, vdev, data_56); - } else { - /* Initial Inquiry may not request enough data bytes to - * obtain byte 57. DV will; if target doesn't return - * at least 57 bytes, data[56] will be zero. */ - if (dlen > 56) { - if ( (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_56))) { - /* Update the target capabilities - */ - data_56 = data[56]; - vdev->tflags |= MPT_TARGET_FLAGS_VALID_56; - mptscsih_setTargetNegoParms(hd, vdev, data_56); - } + } + mptscsih_setTargetNegoParms(hd, vtarget, data_56); + } else { + /* Initial Inquiry may not request enough data bytes to + * obtain byte 57. DV will; if target doesn't return + * at least 57 bytes, data[56] will be zero. */ + if (dlen > 56) { + if ( (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_56))) { + /* Update the target capabilities + */ + data_56 = data[56]; + vtarget->tflags |= MPT_TARGET_FLAGS_VALID_56; + mptscsih_setTargetNegoParms(hd, vtarget, data_56); } } } @@ -2757,12 +2773,12 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char * * */ static void -mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) +mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, char byte56) { SpiCfgData *pspi_data = &hd->ioc->spi_data; int id = (int) target->target_id; int nvram; - VirtDevice *vdev; + VirtTarget *vtarget; int ii; u8 width = MPT_NARROW; u8 factor = MPT_ASYNC; @@ -2907,9 +2923,9 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) ddvtprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id)); for (ii = 0; ii < id; ii++) { - if ( (vdev = hd->Targets[ii]) ) { - vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS; - mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags); + if ( (vtarget = hd->Targets[ii]) ) { + vtarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS; + mptscsih_writeSDP1(hd, 0, ii, vtarget->negoFlags); } } } @@ -2933,12 +2949,12 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) * prevent any future negotiations to this device. */ static void -mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id) +mptscsih_no_negotiate(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc) { + VirtDevice *vdev; - if ((hd->Targets) && (hd->Targets[target_id] == NULL)) - hd->ioc->spi_data.dvStatus[target_id] |= MPT_SCSICFG_BLK_NEGO; - + if ((vdev = sc->device->hostdata) != NULL) + hd->ioc->spi_data.dvStatus[vdev->target_id] |= MPT_SCSICFG_BLK_NEGO; return; } @@ -3014,7 +3030,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags) MPT_ADAPTER *ioc = hd->ioc; Config_t *pReq; SCSIDevicePage1_t *pData; - VirtDevice *pTarget=NULL; + VirtTarget *vtarget=NULL; MPT_FRAME_HDR *mf; dma_addr_t dataDma; u16 req_idx; @@ -3094,11 +3110,11 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags) /* If id is not a raid volume, get the updated * transmission settings from the target structure. */ - if (hd->Targets && (pTarget = hd->Targets[id]) && !pTarget->raidVolume) { - width = pTarget->maxWidth; - factor = pTarget->minSyncFactor; - offset = pTarget->maxOffset; - negoFlags = pTarget->negoFlags; + if (hd->Targets && (vtarget = hd->Targets[id]) && !vtarget->raidVolume) { + width = vtarget->maxWidth; + factor = vtarget->minSyncFactor; + offset = vtarget->maxOffset; + negoFlags = vtarget->negoFlags; } #ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION @@ -3818,152 +3834,122 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io) /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /** - * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks. - * @hd: Pointer to MPT_SCSI_HOST structure - * @portnum: IOC port number + * mptscsih_negotiate_to_asyn_narrow - Restore devices to default state + * @hd: Pointer to a SCSI HOST structure + * @vtarget: per device private data * * Uses the ISR, but with special processing. * MUST be single-threaded. * - * Return: 0 on completion */ -static int -mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum) +static void +mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget) { MPT_ADAPTER *ioc= hd->ioc; - VirtDevice *pTarget; - SCSIDevicePage1_t *pcfg1Data = NULL; - INTERNAL_CMD iocmd; + SCSIDevicePage1_t *pcfg1Data; CONFIGPARMS cfg; - dma_addr_t cfg1_dma_addr = -1; - ConfigPageHeader_t header1; - int bus = 0; - int id = 0; - int lun; - int indexed_lun, lun_index; - int hostId = ioc->pfacts[portnum].PortSCSIID; - int max_id; - int requested, configuration, data; - int doConfig = 0; + dma_addr_t cfg1_dma_addr; + ConfigPageHeader_t header; + int id; + int requested, configuration, data,i; u8 flags, factor; - max_id = ioc->sh->max_id - 1; - - /* Following parameters will not change - * in this routine. - */ - iocmd.cmd = SYNCHRONIZE_CACHE; - iocmd.flags = 0; - iocmd.physDiskNum = -1; - iocmd.data = NULL; - iocmd.data_dma = -1; - iocmd.size = 0; - iocmd.rsvd = iocmd.rsvd2 = 0; - - /* No SCSI hosts - */ - if (hd->Targets == NULL) - return 0; - - /* Skip the host - */ - if (id == hostId) - id++; - - /* Write SDP1 for all SPI devices - * Alloc memory and set up config buffer - */ - if (ioc->bus_type == SPI) { - if (ioc->spi_data.sdp1length > 0) { - pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev, - ioc->spi_data.sdp1length * 4, &cfg1_dma_addr); - - if (pcfg1Data != NULL) { - doConfig = 1; - header1.PageVersion = ioc->spi_data.sdp1version; - header1.PageLength = ioc->spi_data.sdp1length; - header1.PageNumber = 1; - header1.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; - cfg.cfghdr.hdr = &header1; - cfg.physAddr = cfg1_dma_addr; - cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT; - cfg.dir = 1; - cfg.timeout = 0; - } - } - } + if (ioc->bus_type != SPI) + return; - /* loop through all devices on this port - */ - while (bus < MPT_MAX_BUS) { - iocmd.bus = bus; - iocmd.id = id; - pTarget = hd->Targets[(int)id]; + if (!ioc->spi_data.sdp1length) + return; - if (doConfig) { + pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev, + ioc->spi_data.sdp1length * 4, &cfg1_dma_addr); - /* Set the negotiation flags */ - if (pTarget && (pTarget = hd->Targets[id]) && !pTarget->raidVolume) { - flags = pTarget->negoFlags; - } else { - flags = hd->ioc->spi_data.noQas; - if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) { - data = hd->ioc->spi_data.nvram[id]; + if (pcfg1Data == NULL) + return; - if (data & MPT_NVRAM_WIDE_DISABLE) - flags |= MPT_TARGET_NO_NEGO_WIDE; + header.PageVersion = ioc->spi_data.sdp1version; + header.PageLength = ioc->spi_data.sdp1length; + header.PageNumber = 1; + header.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE; + cfg.cfghdr.hdr = &header; + cfg.physAddr = cfg1_dma_addr; + cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT; + cfg.dir = 1; + cfg.timeout = 0; - factor = (data & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT; - if ((factor == 0) || (factor == MPT_ASYNC)) - flags |= MPT_TARGET_NO_NEGO_SYNC; - } + if (vtarget->raidVolume && ioc->raid_data.pIocPg3) { + for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) { + id = ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID; + flags = hd->ioc->spi_data.noQas; + if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) { + data = hd->ioc->spi_data.nvram[id]; + if (data & MPT_NVRAM_WIDE_DISABLE) + flags |= MPT_TARGET_NO_NEGO_WIDE; + factor = (data & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT; + if ((factor == 0) || (factor == MPT_ASYNC)) + flags |= MPT_TARGET_NO_NEGO_SYNC; } - - /* Force to async, narrow */ mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested, - &configuration, flags); + &configuration, flags); dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC " "offset=0 negoFlags=%x request=%x config=%x\n", id, flags, requested, configuration)); pcfg1Data->RequestedParameters = cpu_to_le32(requested); pcfg1Data->Reserved = 0; pcfg1Data->Configuration = cpu_to_le32(configuration); - cfg.pageAddr = (bus<<8) | id; + cfg.pageAddr = (vtarget->bus_id<<8) | id; mpt_config(hd->ioc, &cfg); } + } else { + flags = vtarget->negoFlags; + mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested, + &configuration, flags); + dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC " + "offset=0 negoFlags=%x request=%x config=%x\n", + vtarget->target_id, flags, requested, configuration)); + pcfg1Data->RequestedParameters = cpu_to_le32(requested); + pcfg1Data->Reserved = 0; + pcfg1Data->Configuration = cpu_to_le32(configuration); + cfg.pageAddr = (vtarget->bus_id<<8) | vtarget->target_id; + mpt_config(hd->ioc, &cfg); + } - /* If target Ptr NULL or if this target is NOT a disk, skip. - */ - if ((pTarget) && (pTarget->inq_data[0] == TYPE_DISK)){ - for (lun=0; lun <= MPT_LAST_LUN; lun++) { - /* If LUN present, issue the command - */ - lun_index = (lun >> 5); /* 32 luns per lun_index */ - indexed_lun = (lun % 32); - if (pTarget->luns[lun_index] & (1<pcidev, header.PageLength * 4, pcfg1Data, cfg1_dma_addr); +} - if (id > max_id) { - id = 0; - bus++; - } - } +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +/** + * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks. + * @hd: Pointer to a SCSI HOST structure + * @vtarget: per device private data + * @lun: lun + * + * Uses the ISR, but with special processing. + * MUST be single-threaded. + * + */ +static void +mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice) +{ + INTERNAL_CMD iocmd; - if (pcfg1Data) { - pci_free_consistent(ioc->pcidev, header1.PageLength * 4, pcfg1Data, cfg1_dma_addr); - } + /* Following parameters will not change + * in this routine. + */ + iocmd.cmd = SYNCHRONIZE_CACHE; + iocmd.flags = 0; + iocmd.physDiskNum = -1; + iocmd.data = NULL; + iocmd.data_dma = -1; + iocmd.size = 0; + iocmd.rsvd = iocmd.rsvd2 = 0; + iocmd.bus = vdevice->bus_id; + iocmd.id = vdevice->target_id; + iocmd.lun = (u8)vdevice->lun; - return 0; + if ((vdevice->vtarget->type & TYPE_DISK) && + (vdevice->configured_lun)) + mptscsih_do_cmd(hd, &iocmd); } /* Search IOC page 3 to determine if this is hidden physical disk @@ -4144,7 +4130,7 @@ mptscsih_domainValidation(void *arg) static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id) { - VirtDevice *pTarget; + VirtTarget *vtarget; int ii; if (hd->Targets == NULL) @@ -4157,11 +4143,11 @@ mptscsih_qas_check(MPT_SCSI_HOST *hd, int id) if ((hd->ioc->spi_data.dvStatus[ii] & MPT_SCSICFG_DV_NOT_DONE) != 0) continue; - pTarget = hd->Targets[ii]; + vtarget = hd->Targets[ii]; - if ((pTarget != NULL) && (!pTarget->raidVolume)) { - if ((pTarget->negoFlags & hd->ioc->spi_data.noQas) == 0) { - pTarget->negoFlags |= hd->ioc->spi_data.noQas; + if ((vtarget != NULL) && (!vtarget->raidVolume)) { + if ((vtarget->negoFlags & hd->ioc->spi_data.noQas) == 0) { + vtarget->negoFlags |= hd->ioc->spi_data.noQas; dnegoprintk(("writeSDP1: id=%d flags=0\n", id)); mptscsih_writeSDP1(hd, 0, ii, 0); } @@ -4201,7 +4187,7 @@ static int mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) { MPT_ADAPTER *ioc = hd->ioc; - VirtDevice *pTarget; + VirtTarget *vtarget; SCSIDevicePage1_t *pcfg1Data; SCSIDevicePage0_t *pcfg0Data; u8 *pbuf1; @@ -4272,12 +4258,12 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) iocmd.physDiskNum = -1; iocmd.rsvd = iocmd.rsvd2 = 0; - pTarget = hd->Targets[id]; + vtarget = hd->Targets[id]; /* Use tagged commands if possible. */ - if (pTarget) { - if (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) + if (vtarget) { + if (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES) iocmd.flags |= MPT_ICFLAG_TAGGED_CMD; else { if (hd->ioc->facts.FWVersion.Word < 0x01000600) @@ -4493,7 +4479,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) /* Reset the size for disks */ inq0 = (*pbuf1) & 0x1F; - if ((inq0 == 0) && pTarget && !pTarget->raidVolume) { + if ((inq0 == 0) && vtarget && !vtarget->raidVolume) { sz = 0x40; iocmd.size = sz; } @@ -4503,8 +4489,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) */ if (inq0 == TYPE_PROCESSOR) { mptscsih_initTarget(hd, - bus, - id, + vtarget, lun, pbuf1, sz); @@ -4518,22 +4503,22 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) goto target_done; if (sz == 0x40) { - if ((pTarget->maxWidth == 1) && (pTarget->maxOffset) && (nfactor < 0x0A) - && (pTarget->minSyncFactor > 0x09)) { + if ((vtarget->maxWidth == 1) && (vtarget->maxOffset) && (nfactor < 0x0A) + && (vtarget->minSyncFactor > 0x09)) { if ((pbuf1[56] & 0x04) == 0) ; else if ((pbuf1[56] & 0x01) == 1) { - pTarget->minSyncFactor = + vtarget->minSyncFactor = nfactor > MPT_ULTRA320 ? nfactor : MPT_ULTRA320; } else { - pTarget->minSyncFactor = + vtarget->minSyncFactor = nfactor > MPT_ULTRA160 ? nfactor : MPT_ULTRA160; } - dv.max.factor = pTarget->minSyncFactor; + dv.max.factor = vtarget->minSyncFactor; if ((pbuf1[56] & 0x02) == 0) { - pTarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS; + vtarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS; hd->ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS; ddvprintk((MYIOC_s_NOTE_FMT "DV: Start Basic noQas on id=%d due to pbuf1[56]=%x\n", @@ -4616,8 +4601,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) "DV:Inquiry compared id=%d, calling initTarget\n", ioc->name, id)); hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_NOT_DONE; mptscsih_initTarget(hd, - bus, - id, + vtarget, lun, pbuf1, sz); @@ -5118,7 +5102,7 @@ target_done: static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) { - VirtDevice *pTarget; + VirtTarget *vtarget; SCSIDevicePage0_t *pPage0; SCSIDevicePage1_t *pPage1; int val = 0, data, configuration; @@ -5138,11 +5122,11 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) * already throttled back. */ negoFlags = hd->ioc->spi_data.noQas; - if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume) { - width = pTarget->maxWidth; - offset = pTarget->maxOffset; - factor = pTarget->minSyncFactor; - negoFlags |= pTarget->negoFlags; + if ((hd->Targets)&&((vtarget = hd->Targets[(int)id]) != NULL) && !vtarget->raidVolume) { + width = vtarget->maxWidth; + offset = vtarget->maxOffset; + factor = vtarget->minSyncFactor; + negoFlags |= vtarget->negoFlags; } else { if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) { data = hd->ioc->spi_data.nvram[id]; @@ -5344,11 +5328,11 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) * or overwrite nvram (phys disks only). */ - if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume ) { - pTarget->maxWidth = dv->now.width; - pTarget->maxOffset = dv->now.offset; - pTarget->minSyncFactor = dv->now.factor; - pTarget->negoFlags = dv->now.flags; + if ((hd->Targets)&&((vtarget = hd->Targets[(int)id]) != NULL) && !vtarget->raidVolume ) { + vtarget->maxWidth = dv->now.width; + vtarget->maxOffset = dv->now.offset; + vtarget->minSyncFactor = dv->now.factor; + vtarget->negoFlags = dv->now.flags; } else { /* Preserv all flags, use * read-modify-write algorithm @@ -5512,7 +5496,7 @@ mptscsih_fillbuf(char *buffer, int size, int index, int width) * Called only if DV_NOT_DONE flag is set */ static void -mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) +mptscsih_set_dvflags(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc) { MPT_ADAPTER *ioc = hd->ioc; u8 cmd; @@ -5520,16 +5504,16 @@ mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) ddvtprintk((MYIOC_s_NOTE_FMT " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n", - hd->ioc->name, pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0])); + hd->ioc->name, sc->device->id, sc->device->lun , hd->negoNvram, sc->cmnd[0])); - if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0)) + if ((sc->device->lun != 0) || (hd->negoNvram != 0)) return; - cmd = pReq->CDB[0]; + cmd = sc->cmnd[0]; if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) { pSpi = &ioc->spi_data; - if ((ioc->raid_data.isRaid & (1 << pReq->TargetID)) && ioc->raid_data.pIocPg3) { + if ((ioc->raid_data.isRaid & (1 << sc->device->id)) && ioc->raid_data.pIocPg3) { /* Set NEED_DV for all hidden disks */ Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk; @@ -5542,8 +5526,8 @@ mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq) numPDisk--; } } - pSpi->dvStatus[pReq->TargetID] |= MPT_SCSICFG_NEED_DV; - ddvtprintk(("NEED_DV set for visible disk id %d\n", pReq->TargetID)); + pSpi->dvStatus[sc->device->id] |= MPT_SCSICFG_NEED_DV; + ddvtprintk(("NEED_DV set for visible disk id %d\n", sc->device->id)); } } @@ -5590,7 +5574,6 @@ mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id) } } } - #endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */ EXPORT_SYMBOL(mptscsih_remove); @@ -5602,7 +5585,9 @@ EXPORT_SYMBOL(mptscsih_resume); EXPORT_SYMBOL(mptscsih_proc_info); EXPORT_SYMBOL(mptscsih_info); EXPORT_SYMBOL(mptscsih_qcmd); +EXPORT_SYMBOL(mptscsih_target_alloc); EXPORT_SYMBOL(mptscsih_slave_alloc); +EXPORT_SYMBOL(mptscsih_target_destroy); EXPORT_SYMBOL(mptscsih_slave_destroy); EXPORT_SYMBOL(mptscsih_slave_configure); EXPORT_SYMBOL(mptscsih_abort); diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h index 971fda4..d3cba12 100644 --- a/drivers/message/fusion/mptscsih.h +++ b/drivers/message/fusion/mptscsih.h @@ -91,7 +91,9 @@ extern int mptscsih_resume(struct pci_dev *pdev); extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func); extern const char * mptscsih_info(struct Scsi_Host *SChost); extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)); +extern int mptscsih_target_alloc(struct scsi_target *starget); extern int mptscsih_slave_alloc(struct scsi_device *device); +extern void mptscsih_target_destroy(struct scsi_target *starget); extern void mptscsih_slave_destroy(struct scsi_device *device); extern int mptscsih_slave_configure(struct scsi_device *device); extern int mptscsih_abort(struct scsi_cmnd * SCpnt); diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c index 91bc467..ce332a6 100644 --- a/drivers/message/fusion/mptspi.c +++ b/drivers/message/fusion/mptspi.c @@ -109,8 +109,10 @@ static struct scsi_host_template mptspi_driver_template = { .name = "MPT SPI Host", .info = mptscsih_info, .queuecommand = mptscsih_qcmd, + .target_alloc = mptscsih_target_alloc, .slave_alloc = mptscsih_slave_alloc, .slave_configure = mptscsih_slave_configure, + .target_destroy = mptscsih_target_destroy, .slave_destroy = mptscsih_slave_destroy, .change_queue_depth = mptscsih_change_queue_depth, .eh_abort_handler = mptscsih_abort, @@ -312,10 +314,10 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id) } memset(mem, 0, sz); - hd->Targets = (VirtDevice **) mem; + hd->Targets = (VirtTarget **) mem; dprintk((KERN_INFO - " Targets @ %p, sz=%d\n", hd->Targets, sz)); + " vdev @ %p, sz=%d\n", hd->Targets, sz)); /* Clear the TM flags */ -- cgit v1.1 From f61c1c41b6b959d08d87eee876406bdbcac77b7c Mon Sep 17 00:00:00 2001 From: "Moore, Eric Dean" Date: Wed, 16 Nov 2005 18:54:27 -0700 Subject: [SCSI] mptfusion - bump version Signed-off-by: Eric Moore Signed-off-by: James Bottomley --- drivers/message/fusion/mptbase.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h index 2a46b33..6c48d1f 100644 --- a/drivers/message/fusion/mptbase.h +++ b/drivers/message/fusion/mptbase.h @@ -76,8 +76,8 @@ #define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR #endif -#define MPT_LINUX_VERSION_COMMON "3.03.04" -#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.04" +#define MPT_LINUX_VERSION_COMMON "3.03.05" +#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.05" #define WHAT_MAGIC_STRING "@" "(" "#" ")" #define show_mptmod_ver(s,ver) \ -- cgit v1.1 From 4e06cbd42c41f9e49fcfe5ee45c749eefaae9cf4 Mon Sep 17 00:00:00 2001 From: "Moore, Eric Dean" Date: Thu, 1 Dec 2005 16:51:02 -0700 Subject: [SCSI] pci_ids.h: add subclass code for SAS Controllers Signed-off-by: Eric Moore Signed-off-by: James Bottomley --- include/linux/pci_ids.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 1e737e2..aa76fc4 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -15,6 +15,7 @@ #define PCI_CLASS_STORAGE_FLOPPY 0x0102 #define PCI_CLASS_STORAGE_IPI 0x0103 #define PCI_CLASS_STORAGE_RAID 0x0104 +#define PCI_CLASS_STORAGE_SAS 0x0107 #define PCI_CLASS_STORAGE_OTHER 0x0180 #define PCI_BASE_CLASS_NETWORK 0x02 -- cgit v1.1 From 38d76df2f5483478dee803cb6e39da5e506a6643 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Fri, 9 Dec 2005 11:34:45 -0500 Subject: [SCSI] sd: Always do write-protect check Since nobody has offered an explanation for why the sd driver makes a write-protect check only for devices with removable media, I'm submitting this patch to get rid of the removable-media test. Signed-off-by: Alan Stern Signed-off-by: James Bottomley --- drivers/scsi/sd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8613a13..d827954 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1509,9 +1509,7 @@ static int sd_revalidate_disk(struct gendisk *disk) */ if (sdkp->media_present) { sd_read_capacity(sdkp, disk->disk_name, buffer); - if (sdp->removable) - sd_read_write_protect_flag(sdkp, disk->disk_name, - buffer); + sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); sd_read_cache_type(sdkp, disk->disk_name, buffer); } -- cgit v1.1 From 829b84675edbe05f11c289946216da4f5c6b8e94 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Tue, 13 Dec 2005 10:29:31 -0700 Subject: [SCSI] Make scsi_transport_spi.h includable by itself Add forward declarations to allow scsi_transport_spi.h to be compiled by itself. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- include/scsi/scsi_transport_spi.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h index 6bdc4af..5c9b2e5 100644 --- a/include/scsi/scsi_transport_spi.h +++ b/include/scsi/scsi_transport_spi.h @@ -24,6 +24,9 @@ #include struct scsi_transport_template; +struct scsi_target; +struct scsi_device; +struct Scsi_Host; struct spi_transport_attrs { int period; /* value in the PPR/SDTR command */ -- cgit v1.1 From e7a1ca1d27e20ea2c0ba161c57e3c1d4112b60f7 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Wed, 14 Dec 2005 19:27:28 +0100 Subject: [SCSI] handle scsi_add_host failure for aic79xx and fix compiler warning Add scsi_add_host() failure handling for aic79xx Also silence a compiler warning : drivers/scsi/aic7xxx/aic79xx_osm.c: In function `ahd_linux_register_host': drivers/scsi/aic7xxx/aic79xx_osm.c:1099: warning: ignoring return value of `scsi_add_host', declared with attribute warn_unused_result Signed-off-by: Jesper Juhl Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic79xx_osm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 6aab9da..1c8f872 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1064,6 +1064,7 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa struct Scsi_Host *host; char *new_name; u_long s; + int retval; template->name = ahd->description; host = scsi_host_alloc(template, sizeof(struct ahd_softc *)); @@ -1096,9 +1097,15 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa host->transportt = ahd_linux_transport_template; - scsi_add_host(host, &ahd->dev_softc->dev); /* XXX handle failure */ + retval = scsi_add_host(host, &ahd->dev_softc->dev); + if (retval) { + printk(KERN_WARNING "aic79xx: scsi_add_host failed\n"); + scsi_host_put(host); + return retval; + } + scsi_scan_host(host); - return (0); + return 0; } uint64_t -- cgit v1.1 From 9e1fe9314cb5649b2dc73690f2cd8d0068e633d9 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Wed, 14 Dec 2005 19:27:20 +0100 Subject: [SCSI] handle scsi_add_host failure for aic7xxx and fix compiler warning Add scsi_add_host() failure handling for aic7xxx Also silence a compiler warning : drivers/scsi/aic7xxx/aic7xxx_osm.c: In function `ahc_linux_register_host': drivers/scsi/aic7xxx/aic7xxx_osm.c:1100: warning: ignoring return value of `scsi_add_host', declared with attribute warn_unused_result Signed-off-by: Jesper Juhl Signed-off-by: James Bottomley --- drivers/scsi/aic7xxx/aic7xxx_osm.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c index d866213..fd389e9 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c @@ -1061,10 +1061,11 @@ uint32_t aic7xxx_verbose; int ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template) { - char buf[80]; - struct Scsi_Host *host; + char buf[80]; + struct Scsi_Host *host; char *new_name; - u_long s; + u_long s; + int retval; template->name = ahc->description; host = scsi_host_alloc(template, sizeof(struct ahc_softc *)); @@ -1097,9 +1098,16 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa host->transportt = ahc_linux_transport_template; - scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */ + retval = scsi_add_host(host, + (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); + if (retval) { + printk(KERN_WARNING "aic7xxx: scsi_add_host failed\n"); + scsi_host_put(host); + return retval; + } + scsi_scan_host(host); - return (0); + return 0; } /* -- cgit v1.1 From 6e39b69e7ea9205c5f80aeac3ef999ab8fb1a4cc Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Fri, 11 Nov 2005 05:30:24 -0600 Subject: [SCSI] export blk layer functions needed for blk_execute_rq_nowait To send async requests we need these two functions exported. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- block/ll_rw_blk.c | 6 +++++- include/linux/blkdev.h | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 99c9ca6..c525b5a 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -2306,6 +2306,8 @@ void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk, generic_unplug_device(q); } +EXPORT_SYMBOL_GPL(blk_execute_rq_nowait); + /** * blk_execute_rq - insert a request into queue for execution * @q: queue to insert the request in @@ -2444,7 +2446,7 @@ void disk_round_stats(struct gendisk *disk) /* * queue lock must be held */ -static void __blk_put_request(request_queue_t *q, struct request *req) +void __blk_put_request(request_queue_t *q, struct request *req) { struct request_list *rl = req->rl; @@ -2473,6 +2475,8 @@ static void __blk_put_request(request_queue_t *q, struct request *req) } } +EXPORT_SYMBOL_GPL(__blk_put_request); + void blk_put_request(struct request *req) { unsigned long flags; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a33a31e..9a68716 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -558,6 +558,7 @@ extern void blk_unregister_queue(struct gendisk *disk); extern void register_disk(struct gendisk *dev); extern void generic_make_request(struct bio *bio); extern void blk_put_request(struct request *); +extern void __blk_put_request(request_queue_t *, struct request *); extern void blk_end_sync_rq(struct request *rq); extern void blk_attempt_remerge(request_queue_t *, struct request *); extern struct request *blk_get_request(request_queue_t *, int, gfp_t); @@ -579,6 +580,10 @@ extern int blk_rq_map_kern(request_queue_t *, struct request *, void *, unsigned extern int blk_rq_map_user_iov(request_queue_t *, struct request *, struct sg_iovec *, int); extern int blk_execute_rq(request_queue_t *, struct gendisk *, struct request *, int); +extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *, + struct request *, int, + void (*done)(struct request *)); + static inline request_queue_t *bdev_get_queue(struct block_device *bdev) { return bdev->bd_disk->queue; -- cgit v1.1 From 6e68af666f5336254b5715dca591026b7324499a Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Fri, 11 Nov 2005 05:30:27 -0600 Subject: [SCSI] Convert SCSI mid-layer to scsi_execute_async Add scsi helpers to create really-large-requests and convert scsi-ml to scsi_execute_async(). Per Jens's previous comments, I placed this function in scsi_lib.c. I made it follow all the queue's limits - I think I did at least :), so I removed the warning on the function header. I think the scsi_execute_* functions should eventually take a request_queue and be placed some place where the dm-multipath hw_handler can use them if that failover code is going to stay in the kernel. That conversion patch will be sent in another mail though. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/scsi_error.c | 47 ++------- drivers/scsi/scsi_lib.c | 230 ++++++++++++++++++++++++++++++++++++++------- drivers/scsi/scsi_priv.h | 1 - fs/bio.c | 20 ++++ include/linux/bio.h | 2 + include/scsi/scsi_device.h | 6 ++ 6 files changed, 233 insertions(+), 73 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 18c5d25..53ea62d 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1315,23 +1315,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd) } /** - * scsi_eh_lock_done - done function for eh door lock request - * @scmd: SCSI command block for the door lock request - * - * Notes: - * We completed the asynchronous door lock request, and it has either - * locked the door or failed. We must free the command structures - * associated with this request. - **/ -static void scsi_eh_lock_done(struct scsi_cmnd *scmd) -{ - struct scsi_request *sreq = scmd->sc_request; - - scsi_release_request(sreq); -} - - -/** * scsi_eh_lock_door - Prevent medium removal for the specified device * @sdev: SCSI device to prevent medium removal * @@ -1353,29 +1336,17 @@ static void scsi_eh_lock_done(struct scsi_cmnd *scmd) **/ static void scsi_eh_lock_door(struct scsi_device *sdev) { - struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL); + unsigned char cmnd[MAX_COMMAND_SIZE]; - if (unlikely(!sreq)) { - printk(KERN_ERR "%s: request allocate failed," - "prevent media removal cmd not sent\n", __FUNCTION__); - return; - } + cmnd[0] = ALLOW_MEDIUM_REMOVAL; + cmnd[1] = 0; + cmnd[2] = 0; + cmnd[3] = 0; + cmnd[4] = SCSI_REMOVAL_PREVENT; + cmnd[5] = 0; - sreq->sr_cmnd[0] = ALLOW_MEDIUM_REMOVAL; - sreq->sr_cmnd[1] = 0; - sreq->sr_cmnd[2] = 0; - sreq->sr_cmnd[3] = 0; - sreq->sr_cmnd[4] = SCSI_REMOVAL_PREVENT; - sreq->sr_cmnd[5] = 0; - sreq->sr_data_direction = DMA_NONE; - sreq->sr_bufflen = 0; - sreq->sr_buffer = NULL; - sreq->sr_allowed = 5; - sreq->sr_done = scsi_eh_lock_done; - sreq->sr_timeout_per_command = 10 * HZ; - sreq->sr_cmd_len = COMMAND_SIZE(sreq->sr_cmnd[0]); - - scsi_insert_special_req(sreq, 1); + scsi_execute_async(sdev, cmnd, DMA_NONE, NULL, 0, 0, 10 * HZ, + 5, NULL, NULL, GFP_KERNEL); } diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 1f27827..eb0cfbf 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -63,39 +63,6 @@ static struct scsi_host_sg_pool scsi_sg_pools[] = { }; #undef SP - -/* - * Function: scsi_insert_special_req() - * - * Purpose: Insert pre-formed request into request queue. - * - * Arguments: sreq - request that is ready to be queued. - * at_head - boolean. True if we should insert at head - * of queue, false if we should insert at tail. - * - * Lock status: Assumed that lock is not held upon entry. - * - * Returns: Nothing - * - * Notes: This function is called from character device and from - * ioctl types of functions where the caller knows exactly - * what SCSI command needs to be issued. The idea is that - * we merely inject the command into the queue (at the head - * for now), and then call the queue request function to actually - * process it. - */ -int scsi_insert_special_req(struct scsi_request *sreq, int at_head) -{ - /* - * Because users of this function are apt to reuse requests with no - * modification, we have to sanitise the request flags here - */ - sreq->sr_request->flags &= ~REQ_DONTPREP; - blk_insert_request(sreq->sr_device->request_queue, sreq->sr_request, - at_head, sreq); - return 0; -} - static void scsi_run_queue(struct request_queue *q); /* @@ -249,8 +216,13 @@ void scsi_do_req(struct scsi_request *sreq, const void *cmnd, /* * head injection *required* here otherwise quiesce won't work + * + * Because users of this function are apt to reuse requests with no + * modification, we have to sanitise the request flags here */ - scsi_insert_special_req(sreq, 1); + sreq->sr_request->flags &= ~REQ_DONTPREP; + blk_insert_request(sreq->sr_device->request_queue, sreq->sr_request, + 1, sreq); } EXPORT_SYMBOL(scsi_do_req); @@ -327,6 +299,196 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, } EXPORT_SYMBOL(scsi_execute_req); +struct scsi_io_context { + void *data; + void (*done)(void *data, char *sense, int result, int resid); + char sense[SCSI_SENSE_BUFFERSIZE]; +}; + +static void scsi_end_async(struct request *req) +{ + struct scsi_io_context *sioc = req->end_io_data; + + if (sioc->done) + sioc->done(sioc->data, sioc->sense, req->errors, req->data_len); + + kfree(sioc); + __blk_put_request(req->q, req); +} + +static int scsi_merge_bio(struct request *rq, struct bio *bio) +{ + struct request_queue *q = rq->q; + + bio->bi_flags &= ~(1 << BIO_SEG_VALID); + if (rq_data_dir(rq) == WRITE) + bio->bi_rw |= (1 << BIO_RW); + blk_queue_bounce(q, &bio); + + if (!rq->bio) + blk_rq_bio_prep(q, rq, bio); + else if (!q->back_merge_fn(q, rq, bio)) + return -EINVAL; + else { + rq->biotail->bi_next = bio; + rq->biotail = bio; + rq->hard_nr_sectors += bio_sectors(bio); + rq->nr_sectors = rq->hard_nr_sectors; + } + + return 0; +} + +static int scsi_bi_endio(struct bio *bio, unsigned int bytes_done, int error) +{ + if (bio->bi_size) + return 1; + + bio_put(bio); + return 0; +} + +/** + * scsi_req_map_sg - map a scatterlist into a request + * @rq: request to fill + * @sg: scatterlist + * @nsegs: number of elements + * @bufflen: len of buffer + * @gfp: memory allocation flags + * + * scsi_req_map_sg maps a scatterlist into a request so that the + * request can be sent to the block layer. We do not trust the scatterlist + * sent to use, as some ULDs use that struct to only organize the pages. + */ +static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl, + int nsegs, unsigned bufflen, gfp_t gfp) +{ + struct request_queue *q = rq->q; + int nr_pages = (bufflen + PAGE_SIZE - 1) >> PAGE_SHIFT; + unsigned int data_len = 0, len, bytes, off; + struct page *page; + struct bio *bio = NULL; + int i, err, nr_vecs = 0; + + for (i = 0; i < nsegs; i++) { + page = sgl[i].page; + off = sgl[i].offset; + len = sgl[i].length; + data_len += len; + + while (len > 0) { + bytes = min_t(unsigned int, len, PAGE_SIZE - off); + + if (!bio) { + nr_vecs = min_t(int, BIO_MAX_PAGES, nr_pages); + nr_pages -= nr_vecs; + + bio = bio_alloc(gfp, nr_vecs); + if (!bio) { + err = -ENOMEM; + goto free_bios; + } + bio->bi_end_io = scsi_bi_endio; + } + + if (bio_add_pc_page(q, bio, page, bytes, off) != + bytes) { + bio_put(bio); + err = -EINVAL; + goto free_bios; + } + + if (bio->bi_vcnt >= nr_vecs) { + err = scsi_merge_bio(rq, bio); + if (err) { + bio_endio(bio, bio->bi_size, 0); + goto free_bios; + } + bio = NULL; + } + + page++; + len -= bytes; + off = 0; + } + } + + rq->buffer = rq->data = NULL; + rq->data_len = data_len; + return 0; + +free_bios: + while ((bio = rq->bio) != NULL) { + rq->bio = bio->bi_next; + /* + * call endio instead of bio_put incase it was bounced + */ + bio_endio(bio, bio->bi_size, 0); + } + + return err; +} + +/** + * scsi_execute_async - insert request + * @sdev: scsi device + * @cmd: scsi command + * @data_direction: data direction + * @buffer: data buffer (this can be a kernel buffer or scatterlist) + * @bufflen: len of buffer + * @use_sg: if buffer is a scatterlist this is the number of elements + * @timeout: request timeout in seconds + * @retries: number of times to retry request + * @flags: or into request flags + **/ +int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, + int data_direction, void *buffer, unsigned bufflen, + int use_sg, int timeout, int retries, void *privdata, + void (*done)(void *, char *, int, int), gfp_t gfp) +{ + struct request *req; + struct scsi_io_context *sioc; + int err = 0; + int write = (data_direction == DMA_TO_DEVICE); + + sioc = kzalloc(sizeof(*sioc), gfp); + if (!sioc) + return DRIVER_ERROR << 24; + + req = blk_get_request(sdev->request_queue, write, gfp); + if (!req) + goto free_sense; + + if (use_sg) + err = scsi_req_map_sg(req, buffer, use_sg, bufflen, gfp); + else if (bufflen) + err = blk_rq_map_kern(req->q, req, buffer, bufflen, gfp); + + if (err) + goto free_req; + + req->cmd_len = COMMAND_SIZE(cmd[0]); + memcpy(req->cmd, cmd, req->cmd_len); + req->sense = sioc->sense; + req->sense_len = 0; + req->timeout = timeout; + req->flags |= REQ_BLOCK_PC | REQ_QUIET; + req->end_io_data = sioc; + + sioc->data = privdata; + sioc->done = done; + + blk_execute_rq_nowait(req->q, NULL, req, 1, scsi_end_async); + return 0; + +free_req: + blk_put_request(req); +free_sense: + kfree(sioc); + return DRIVER_ERROR << 24; +} +EXPORT_SYMBOL_GPL(scsi_execute_async); + /* * Function: scsi_init_cmd_errh() * diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index a8d121c..f04e7e1 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h @@ -40,7 +40,6 @@ extern void scsi_exit_hosts(void); extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd); extern int scsi_setup_command_freelist(struct Scsi_Host *shost); extern void scsi_destroy_command_freelist(struct Scsi_Host *shost); -extern int scsi_insert_special_req(struct scsi_request *sreq, int); extern void scsi_init_cmd_from_req(struct scsi_cmnd *cmd, struct scsi_request *sreq); extern void __scsi_release_request(struct scsi_request *sreq); diff --git a/fs/bio.c b/fs/bio.c index 460554b..4d21ee3 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -386,6 +386,25 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page } /** + * bio_add_pc_page - attempt to add page to bio + * @bio: destination bio + * @page: page to add + * @len: vec entry length + * @offset: vec entry offset + * + * Attempt to add a page to the bio_vec maplist. This can fail for a + * number of reasons, such as the bio being full or target block + * device limitations. The target block device must allow bio's + * smaller than PAGE_SIZE, so it is always possible to add a single + * page to an empty bio. This should only be used by REQ_PC bios. + */ +int bio_add_pc_page(request_queue_t *q, struct bio *bio, struct page *page, + unsigned int len, unsigned int offset) +{ + return __bio_add_page(q, bio, page, len, offset); +} + +/** * bio_add_page - attempt to add page to bio * @bio: destination bio * @page: page to add @@ -1228,6 +1247,7 @@ EXPORT_SYMBOL(bio_clone); EXPORT_SYMBOL(bio_phys_segments); EXPORT_SYMBOL(bio_hw_segments); EXPORT_SYMBOL(bio_add_page); +EXPORT_SYMBOL(bio_add_pc_page); EXPORT_SYMBOL(bio_get_nr_vecs); EXPORT_SYMBOL(bio_map_user); EXPORT_SYMBOL(bio_unmap_user); diff --git a/include/linux/bio.h b/include/linux/bio.h index 685fd37..b60ffe3 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -292,6 +292,8 @@ extern struct bio *bio_clone(struct bio *, gfp_t); extern void bio_init(struct bio *); extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); +extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, + unsigned int, unsigned int); extern int bio_get_nr_vecs(struct block_device *); extern struct bio *bio_map_user(struct request_queue *, struct block_device *, unsigned long, unsigned int, int); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 063e32f..e94ca4d 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -274,6 +274,12 @@ extern int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd, int data_direction, void *buffer, unsigned bufflen, struct scsi_sense_hdr *, int timeout, int retries); +extern int scsi_execute_async(struct scsi_device *sdev, + const unsigned char *cmd, int data_direction, + void *buffer, unsigned bufflen, int use_sg, + int timeout, int retries, void *privdata, + void (*done)(void *, char *, int, int), + gfp_t gfp); static inline unsigned int sdev_channel(struct scsi_device *sdev) { -- cgit v1.1 From 17e01f216b611fc46956dcd9063aec4de75991e3 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Fri, 11 Nov 2005 05:31:37 -0600 Subject: [SCSI] add retries field to request for REQ_BLOCK_PC use For tape we need to control the retries. This patch adds a retries counter on the request for REQ_BLOCK_PC commands originating from scsi_execute* to use. REQ_BLOCK_PC commands comming from the block layer SG_IO path continue to use the retires set in the ULD init_command. (scsi_execute* does not set the gendisk so we do not execute the init_command in that path). Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 4 +++- include/linux/blkdev.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index eb0cfbf..365843a 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -259,6 +259,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, memcpy(req->cmd, cmd, req->cmd_len); req->sense = sense; req->sense_len = 0; + req->retries = retries; req->timeout = timeout; req->flags |= flags | REQ_BLOCK_PC | REQ_SPECIAL | REQ_QUIET; @@ -472,6 +473,7 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, req->sense = sioc->sense; req->sense_len = 0; req->timeout = timeout; + req->retries = retries; req->flags |= REQ_BLOCK_PC | REQ_QUIET; req->end_io_data = sioc; @@ -1393,7 +1395,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) cmd->sc_data_direction = DMA_NONE; cmd->transfersize = req->data_len; - cmd->allowed = 3; + cmd->allowed = req->retries; cmd->timeout_per_command = req->timeout; cmd->done = scsi_generic_done; } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 9a68716..509e9a0 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -184,6 +184,7 @@ struct request { void *sense; unsigned int timeout; + int retries; /* * For Power Management requests -- cgit v1.1 From 0d95716d6a1308c465d8c17ed1a217628936bb0c Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Fri, 11 Nov 2005 05:31:40 -0600 Subject: [SCSI] complete the whole command when it is REQ_BLOCK_PC sd does not allow scsi_io_completion to retry commands for SG_IO requests, and it make sense that it should not happen for st SG_IO commands too. If for st we hit the bottom of scsi_io_completion we will probably screw things up pretty bad. This patch returns to the block layer that the whole command completed and relies on the caller to check the request errors field. For initialization commands like in sd, this adds the previous behavior where scsi_io_completion did not process the error. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 8 +++++++- drivers/scsi/st.c | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 365843a..3e136bf 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1247,7 +1247,13 @@ static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, static void scsi_generic_done(struct scsi_cmnd *cmd) { BUG_ON(!blk_pc_request(cmd->request)); - scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0); + /* + * This will complete the whole command with uptodate=1 so + * as far as the block layer is concerned the command completed + * successfully. Since this is a REQ_BLOCK_PC command the + * caller should check the request's errors value + */ + scsi_io_completion(cmd, cmd->bufflen, 0); } static int scsi_prep_fn(struct request_queue *q, struct request *req) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 6d90787..053444b 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -4185,7 +4185,11 @@ static void scsi_tape_release(struct kref *kref) static void st_intr(struct scsi_cmnd *SCpnt) { - scsi_io_completion(SCpnt, (SCpnt->result ? 0: SCpnt->bufflen), 1); + /* + * The caller should be checking the request's errors + * value. + */ + scsi_io_completion(SCpnt, SCpnt->bufflen, 0); } /* -- cgit v1.1 From aa7b5cd750c766f66a92c9f78ba176bc77512b7e Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Fri, 11 Nov 2005 05:31:41 -0600 Subject: [SCSI] add kmemcache for scsi_io_context Add kmemcache of scsi io contexts. In the future when we finalize on where these functions will live we can add a mempool for it and do a bioset for out REQ_BLOCK_PC bios. This is needed becuase the dm-multipath handlers will want to use the scsi_exectute* functions for failover and we cannot have them and the bio device allocating from the same mempool. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/scsi_lib.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3e136bf..54a72f1 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -306,6 +306,8 @@ struct scsi_io_context { char sense[SCSI_SENSE_BUFFERSIZE]; }; +static kmem_cache_t *scsi_io_context_cache; + static void scsi_end_async(struct request *req) { struct scsi_io_context *sioc = req->end_io_data; @@ -313,7 +315,7 @@ static void scsi_end_async(struct request *req) if (sioc->done) sioc->done(sioc->data, sioc->sense, req->errors, req->data_len); - kfree(sioc); + kmem_cache_free(scsi_io_context_cache, sioc); __blk_put_request(req->q, req); } @@ -452,9 +454,10 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, int err = 0; int write = (data_direction == DMA_TO_DEVICE); - sioc = kzalloc(sizeof(*sioc), gfp); + sioc = kmem_cache_alloc(scsi_io_context_cache, gfp); if (!sioc) return DRIVER_ERROR << 24; + memset(sioc, 0, sizeof(*sioc)); req = blk_get_request(sdev->request_queue, write, gfp); if (!req) @@ -1765,6 +1768,14 @@ int __init scsi_init_queue(void) { int i; + scsi_io_context_cache = kmem_cache_create("scsi_io_context", + sizeof(struct scsi_io_context), + 0, 0, NULL, NULL); + if (!scsi_io_context_cache) { + printk(KERN_ERR "SCSI: can't init scsi io context cache\n"); + return -ENOMEM; + } + for (i = 0; i < SG_MEMPOOL_NR; i++) { struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; int size = sgp->size * sizeof(struct scatterlist); @@ -1792,6 +1803,8 @@ void scsi_exit_queue(void) { int i; + kmem_cache_destroy(scsi_io_context_cache); + for (i = 0; i < SG_MEMPOOL_NR; i++) { struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; mempool_destroy(sgp->pool); -- cgit v1.1 From d6b10348f9397943eb968419a2b7f08895e38472 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Tue, 8 Nov 2005 04:06:41 -0600 Subject: [SCSI] convert sg to scsi_execute_async Convert sg to always send scatterlists, and kill scsi_request usage. TODO: - move DIO code to common place or make block layers usable for ULDs. - move buffer allocation code to common place for all ULDs to use. And make buffer allocation code obey all queue limits so we can find out about problems before calling scsi_execute_async. Currently, sg.c could allocate a buffer that is too large, and send the request to scsi_execute_async. scsi_execute_async will then check it against all the queue limits and return a failure in this case. It would nicer to know about the queue limit violation right away. - move indirect (copy_to/from_user) paths commone place or make block layers usable for ULDs. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/sg.c | 686 +++++++++++++++++++++--------------------------------- 1 file changed, 259 insertions(+), 427 deletions(-) diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index b55c2a8..221e96e 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -104,8 +104,6 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF; static int sg_add(struct class_device *, struct class_interface *); static void sg_remove(struct class_device *, struct class_interface *); -static Scsi_Request *dummy_cmdp; /* only used for sizeof */ - static DEFINE_RWLOCK(sg_dev_arr_lock); /* Also used to lock file descriptor list for device */ @@ -119,7 +117,7 @@ typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */ unsigned short sglist_len; /* size of malloc'd scatter-gather list ++ */ unsigned bufflen; /* Size of (aggregate) data buffer */ unsigned b_malloc_len; /* actual len malloc'ed in buffer */ - void *buffer; /* Data buffer or scatter list (k_use_sg>0) */ + struct scatterlist *buffer;/* scatter list */ char dio_in_use; /* 0->indirect IO (or mmap), 1->dio */ unsigned char cmd_opcode; /* first byte of command */ } Sg_scatter_hold; @@ -128,12 +126,11 @@ struct sg_device; /* forward declarations */ struct sg_fd; typedef struct sg_request { /* SG_MAX_QUEUE requests outstanding per file */ - Scsi_Request *my_cmdp; /* != 0 when request with lower levels */ struct sg_request *nextrp; /* NULL -> tail request (slist) */ struct sg_fd *parentfp; /* NULL -> not in use */ Sg_scatter_hold data; /* hold buffer, perhaps scatter list */ sg_io_hdr_t header; /* scsi command+info, see */ - unsigned char sense_b[sizeof (dummy_cmdp->sr_sense_buffer)]; + unsigned char sense_b[SCSI_SENSE_BUFFERSIZE]; char res_used; /* 1 -> using reserve buffer, 0 -> not ... */ char orphan; /* 1 -> drop on sight, 0 -> normal */ char sg_io_owned; /* 1 -> packet belongs to SG_IO */ @@ -174,7 +171,8 @@ typedef struct sg_device { /* holds the state of each scsi generic device */ } Sg_device; static int sg_fasync(int fd, struct file *filp, int mode); -static void sg_cmd_done(Scsi_Cmnd * SCpnt); /* tasklet or soft irq callback */ +/* tasklet or soft irq callback */ +static void sg_cmd_done(void *data, char *sense, int result, int resid); static int sg_start_req(Sg_request * srp); static void sg_finish_rem_req(Sg_request * srp); static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size); @@ -195,8 +193,8 @@ static void sg_remove_scat(Sg_scatter_hold * schp); static void sg_build_reserve(Sg_fd * sfp, int req_size); static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size); static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp); -static char *sg_page_malloc(int rqSz, int lowDma, int *retSzp); -static void sg_page_free(char *buff, int size); +static struct page *sg_page_malloc(int rqSz, int lowDma, int *retSzp); +static void sg_page_free(struct page *page, int size); static Sg_fd *sg_add_sfp(Sg_device * sdp, int dev); static int sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); static void __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); @@ -207,7 +205,6 @@ static int sg_res_in_use(Sg_fd * sfp); static int sg_allow_access(unsigned char opcode, char dev_type); static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len); static Sg_device *sg_get_dev(int dev); -static inline unsigned char *sg_scatg2virt(const struct scatterlist *sclp); #ifdef CONFIG_SCSI_PROC_FS static int sg_last_dev(void); #endif @@ -226,6 +223,7 @@ sg_open(struct inode *inode, struct file *filp) { int dev = iminor(inode); int flags = filp->f_flags; + struct request_queue *q; Sg_device *sdp; Sg_fd *sfp; int res; @@ -287,7 +285,9 @@ sg_open(struct inode *inode, struct file *filp) } if (!sdp->headfp) { /* no existing opens on this device */ sdp->sgdebug = 0; - sdp->sg_tablesize = sdp->device->host->sg_tablesize; + q = sdp->device->request_queue; + sdp->sg_tablesize = min(q->max_hw_segments, + q->max_phys_segments); } if ((sfp = sg_add_sfp(sdp, dev))) filp->private_data = sfp; @@ -340,6 +340,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) return -ENXIO; SCSI_LOG_TIMEOUT(3, printk("sg_read: %s, count=%d\n", sdp->disk->disk_name, (int) count)); + if (!access_ok(VERIFY_WRITE, buf, count)) return -EFAULT; if (sfp->force_packid && (count >= SZ_SG_HEADER)) { @@ -491,7 +492,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) if ((hp->mx_sb_len > 0) && hp->sbp) { if ((CHECK_CONDITION & hp->masked_status) || (DRIVER_SENSE & hp->driver_status)) { - int sb_len = sizeof (dummy_cmdp->sr_sense_buffer); + int sb_len = SCSI_SENSE_BUFFERSIZE; sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len; len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */ len = (len > sb_len) ? sb_len : len; @@ -525,7 +526,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) Sg_request *srp; struct sg_header old_hdr; sg_io_hdr_t *hp; - unsigned char cmnd[sizeof (dummy_cmdp->sr_cmnd)]; + unsigned char cmnd[MAX_COMMAND_SIZE]; if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) return -ENXIO; @@ -624,7 +625,7 @@ sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count, int k; Sg_request *srp; sg_io_hdr_t *hp; - unsigned char cmnd[sizeof (dummy_cmdp->sr_cmnd)]; + unsigned char cmnd[MAX_COMMAND_SIZE]; int timeout; unsigned long ul_timeout; @@ -692,11 +693,9 @@ static int sg_common_write(Sg_fd * sfp, Sg_request * srp, unsigned char *cmnd, int timeout, int blocking) { - int k; - Scsi_Request *SRpnt; + int k, data_dir; Sg_device *sdp = sfp->parentdp; sg_io_hdr_t *hp = &srp->header; - request_queue_t *q; srp->data.cmd_opcode = cmnd[0]; /* hold opcode of command */ hp->status = 0; @@ -723,51 +722,36 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp, sg_finish_rem_req(srp); return -ENODEV; } - SRpnt = scsi_allocate_request(sdp->device, GFP_ATOMIC); - if (SRpnt == NULL) { - SCSI_LOG_TIMEOUT(1, printk("sg_write: no mem\n")); - sg_finish_rem_req(srp); - return -ENOMEM; - } - srp->my_cmdp = SRpnt; - q = SRpnt->sr_device->request_queue; - SRpnt->sr_request->rq_disk = sdp->disk; - SRpnt->sr_sense_buffer[0] = 0; - SRpnt->sr_cmd_len = hp->cmd_len; - SRpnt->sr_use_sg = srp->data.k_use_sg; - SRpnt->sr_sglist_len = srp->data.sglist_len; - SRpnt->sr_bufflen = srp->data.bufflen; - SRpnt->sr_underflow = 0; - SRpnt->sr_buffer = srp->data.buffer; switch (hp->dxfer_direction) { case SG_DXFER_TO_FROM_DEV: case SG_DXFER_FROM_DEV: - SRpnt->sr_data_direction = DMA_FROM_DEVICE; + data_dir = DMA_FROM_DEVICE; break; case SG_DXFER_TO_DEV: - SRpnt->sr_data_direction = DMA_TO_DEVICE; + data_dir = DMA_TO_DEVICE; break; case SG_DXFER_UNKNOWN: - SRpnt->sr_data_direction = DMA_BIDIRECTIONAL; + data_dir = DMA_BIDIRECTIONAL; break; default: - SRpnt->sr_data_direction = DMA_NONE; + data_dir = DMA_NONE; break; } - SRpnt->upper_private_data = srp; - srp->data.k_use_sg = 0; - srp->data.sglist_len = 0; - srp->data.bufflen = 0; - srp->data.buffer = NULL; hp->duration = jiffies_to_msecs(jiffies); /* Now send everything of to mid-level. The next time we hear about this packet is when sg_cmd_done() is called (i.e. a callback). */ - scsi_do_req(SRpnt, (void *) cmnd, - (void *) SRpnt->sr_buffer, hp->dxfer_len, - sg_cmd_done, timeout, SG_DEFAULT_RETRIES); - /* dxfer_len overwrites SRpnt->sr_bufflen, hence need for b_malloc_len */ - return 0; + if (scsi_execute_async(sdp->device, cmnd, data_dir, srp->data.buffer, + hp->dxfer_len, srp->data.k_use_sg, timeout, + SG_DEFAULT_RETRIES, srp, sg_cmd_done, + GFP_ATOMIC)) { + SCSI_LOG_TIMEOUT(1, printk("sg_write: scsi_execute_async failed\n")); + /* + * most likely out of mem, but could also be a bad map + */ + return -ENOMEM; + } else + return 0; } static int @@ -1156,45 +1140,22 @@ sg_fasync(int fd, struct file *filp, int mode) return (retval < 0) ? retval : 0; } -static inline unsigned char * -sg_scatg2virt(const struct scatterlist *sclp) -{ - return (sclp && sclp->page) ? - (unsigned char *) page_address(sclp->page) + sclp->offset : NULL; -} - /* When startFinish==1 increments page counts for pages other than the - first of scatter gather elements obtained from __get_free_pages(). + first of scatter gather elements obtained from alloc_pages(). When startFinish==0 decrements ... */ static void sg_rb_correct4mmap(Sg_scatter_hold * rsv_schp, int startFinish) { - void *page_ptr; + struct scatterlist *sg = rsv_schp->buffer; struct page *page; int k, m; SCSI_LOG_TIMEOUT(3, printk("sg_rb_correct4mmap: startFinish=%d, scatg=%d\n", startFinish, rsv_schp->k_use_sg)); /* N.B. correction _not_ applied to base page of each allocation */ - if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ - struct scatterlist *sclp = rsv_schp->buffer; - - for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sclp) { - for (m = PAGE_SIZE; m < sclp->length; m += PAGE_SIZE) { - page_ptr = sg_scatg2virt(sclp) + m; - page = virt_to_page(page_ptr); - if (startFinish) - get_page(page); - else { - if (page_count(page) > 0) - __put_page(page); - } - } - } - } else { /* reserve buffer is just a single allocation */ - for (m = PAGE_SIZE; m < rsv_schp->bufflen; m += PAGE_SIZE) { - page_ptr = (unsigned char *) rsv_schp->buffer + m; - page = virt_to_page(page_ptr); + for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) { + for (m = PAGE_SIZE; m < sg->length; m += PAGE_SIZE) { + page = sg->page; if (startFinish) get_page(page); else { @@ -1210,9 +1171,10 @@ sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type) { Sg_fd *sfp; struct page *page = NOPAGE_SIGBUS; - void *page_ptr = NULL; - unsigned long offset; + unsigned long offset, len, sa; Sg_scatter_hold *rsv_schp; + struct scatterlist *sg; + int k; if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data))) return page; @@ -1222,30 +1184,21 @@ sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type) return page; SCSI_LOG_TIMEOUT(3, printk("sg_vma_nopage: offset=%lu, scatg=%d\n", offset, rsv_schp->k_use_sg)); - if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ - int k; - unsigned long sa = vma->vm_start; - unsigned long len; - struct scatterlist *sclp = rsv_schp->buffer; - - for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); - ++k, ++sclp) { - len = vma->vm_end - sa; - len = (len < sclp->length) ? len : sclp->length; - if (offset < len) { - page_ptr = sg_scatg2virt(sclp) + offset; - page = virt_to_page(page_ptr); - get_page(page); /* increment page count */ - break; - } - sa += len; - offset -= len; + sg = rsv_schp->buffer; + sa = vma->vm_start; + for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); + ++k, ++sg) { + len = vma->vm_end - sa; + len = (len < sg->length) ? len : sg->length; + if (offset < len) { + page = sg->page; + get_page(page); /* increment page count */ + break; } - } else { /* reserve buffer is just a single allocation */ - page_ptr = (unsigned char *) rsv_schp->buffer + offset; - page = virt_to_page(page_ptr); - get_page(page); /* increment page count */ + sa += len; + offset -= len; } + if (type) *type = VM_FAULT_MINOR; return page; @@ -1259,8 +1212,10 @@ static int sg_mmap(struct file *filp, struct vm_area_struct *vma) { Sg_fd *sfp; - unsigned long req_sz; + unsigned long req_sz, len, sa; Sg_scatter_hold *rsv_schp; + int k; + struct scatterlist *sg; if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) return -ENXIO; @@ -1273,24 +1228,15 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) if (req_sz > rsv_schp->bufflen) return -ENOMEM; /* cannot map more than reserved buffer */ - if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ - int k; - unsigned long sa = vma->vm_start; - unsigned long len; - struct scatterlist *sclp = rsv_schp->buffer; - - for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); - ++k, ++sclp) { - if (0 != sclp->offset) - return -EFAULT; /* non page aligned memory ?? */ - len = vma->vm_end - sa; - len = (len < sclp->length) ? len : sclp->length; - sa += len; - } - } else { /* reserve buffer is just a single allocation */ - if ((unsigned long) rsv_schp->buffer & (PAGE_SIZE - 1)) - return -EFAULT; /* non page aligned memory ?? */ + sa = vma->vm_start; + sg = rsv_schp->buffer; + for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); + ++k, ++sg) { + len = vma->vm_end - sa; + len = (len < sg->length) ? len : sg->length; + sa += len; } + if (0 == sfp->mmap_called) { sg_rb_correct4mmap(rsv_schp, 1); /* do only once per fd lifetime */ sfp->mmap_called = 1; @@ -1304,21 +1250,16 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) /* This function is a "bottom half" handler that is called by the * mid level when a command is completed (or has failed). */ static void -sg_cmd_done(Scsi_Cmnd * SCpnt) +sg_cmd_done(void *data, char *sense, int result, int resid) { - Scsi_Request *SRpnt = NULL; + Sg_request *srp = data; Sg_device *sdp = NULL; Sg_fd *sfp; - Sg_request *srp = NULL; unsigned long iflags; unsigned int ms; - if (SCpnt && (SRpnt = SCpnt->sc_request)) - srp = (Sg_request *) SRpnt->upper_private_data; if (NULL == srp) { printk(KERN_ERR "sg_cmd_done: NULL request\n"); - if (SRpnt) - scsi_release_request(SRpnt); return; } sfp = srp->parentfp; @@ -1326,49 +1267,34 @@ sg_cmd_done(Scsi_Cmnd * SCpnt) sdp = sfp->parentdp; if ((NULL == sdp) || sdp->detached) { printk(KERN_INFO "sg_cmd_done: device detached\n"); - scsi_release_request(SRpnt); return; } - /* First transfer ownership of data buffers to sg_device object. */ - srp->data.k_use_sg = SRpnt->sr_use_sg; - srp->data.sglist_len = SRpnt->sr_sglist_len; - srp->data.bufflen = SRpnt->sr_bufflen; - srp->data.buffer = SRpnt->sr_buffer; - /* now clear out request structure */ - SRpnt->sr_use_sg = 0; - SRpnt->sr_sglist_len = 0; - SRpnt->sr_bufflen = 0; - SRpnt->sr_buffer = NULL; - SRpnt->sr_underflow = 0; - SRpnt->sr_request->rq_disk = NULL; /* "sg" _disowns_ request blk */ - - srp->my_cmdp = NULL; SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n", - sdp->disk->disk_name, srp->header.pack_id, (int) SRpnt->sr_result)); - srp->header.resid = SCpnt->resid; + sdp->disk->disk_name, srp->header.pack_id, result)); + srp->header.resid = resid; ms = jiffies_to_msecs(jiffies); srp->header.duration = (ms > srp->header.duration) ? (ms - srp->header.duration) : 0; - if (0 != SRpnt->sr_result) { + if (0 != result) { struct scsi_sense_hdr sshdr; - memcpy(srp->sense_b, SRpnt->sr_sense_buffer, - sizeof (srp->sense_b)); - srp->header.status = 0xff & SRpnt->sr_result; - srp->header.masked_status = status_byte(SRpnt->sr_result); - srp->header.msg_status = msg_byte(SRpnt->sr_result); - srp->header.host_status = host_byte(SRpnt->sr_result); - srp->header.driver_status = driver_byte(SRpnt->sr_result); + memcpy(srp->sense_b, sense, sizeof (srp->sense_b)); + srp->header.status = 0xff & result; + srp->header.masked_status = status_byte(result); + srp->header.msg_status = msg_byte(result); + srp->header.host_status = host_byte(result); + srp->header.driver_status = driver_byte(result); if ((sdp->sgdebug > 0) && ((CHECK_CONDITION == srp->header.masked_status) || (COMMAND_TERMINATED == srp->header.masked_status))) - scsi_print_req_sense("sg_cmd_done", SRpnt); + __scsi_print_sense("sg_cmd_done", sense, + SCSI_SENSE_BUFFERSIZE); /* Following if statement is a patch supplied by Eric Youngdale */ - if (driver_byte(SRpnt->sr_result) != 0 - && scsi_command_normalize_sense(SCpnt, &sshdr) + if (driver_byte(result) != 0 + && scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr) && !scsi_sense_is_deferred(&sshdr) && sshdr.sense_key == UNIT_ATTENTION && sdp->device->removable) { @@ -1379,8 +1305,6 @@ sg_cmd_done(Scsi_Cmnd * SCpnt) } /* Rely on write phase to clean out srp status values, so no "else" */ - scsi_release_request(SRpnt); - SRpnt = NULL; if (sfp->closed) { /* whoops this fd already released, cleanup */ SCSI_LOG_TIMEOUT(1, printk("sg_cmd_done: already closed, freeing ...\n")); sg_finish_rem_req(srp); @@ -1431,6 +1355,7 @@ static int sg_sysfs_valid = 0; static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) { + struct request_queue *q = scsidp->request_queue; Sg_device *sdp; unsigned long iflags; void *old_sg_dev_arr = NULL; @@ -1473,7 +1398,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) sdp->disk = disk; sdp->device = scsidp; init_waitqueue_head(&sdp->o_excl_wait); - sdp->sg_tablesize = scsidp->host ? scsidp->host->sg_tablesize : 0; + sdp->sg_tablesize = min(q->max_hw_segments, q->max_phys_segments); sg_nr_dev++; sg_dev_arr[k] = sdp; @@ -1753,36 +1678,35 @@ sg_finish_rem_req(Sg_request * srp) static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) { - int ret_sz; - int elem_sz = sizeof (struct scatterlist); - int sg_bufflen = tablesize * elem_sz; - int mx_sc_elems = tablesize; + int sg_bufflen = tablesize * sizeof(struct scatterlist); + unsigned int gfp_flags = GFP_ATOMIC | __GFP_NOWARN; - schp->buffer = sg_page_malloc(sg_bufflen, sfp->low_dma, &ret_sz); + /* + * TODO: test without low_dma, we should not need it since + * the block layer will bounce the buffer for us + * + * XXX(hch): we shouldn't need GFP_DMA for the actual S/G list. + */ + if (sfp->low_dma) + gfp_flags |= GFP_DMA; + schp->buffer = kzalloc(sg_bufflen, gfp_flags); if (!schp->buffer) return -ENOMEM; - else if (ret_sz != sg_bufflen) { - sg_bufflen = ret_sz; - mx_sc_elems = sg_bufflen / elem_sz; - } schp->sglist_len = sg_bufflen; - memset(schp->buffer, 0, sg_bufflen); - return mx_sc_elems; /* number of scat_gath elements allocated */ + return tablesize; /* number of scat_gath elements allocated */ } #ifdef SG_ALLOW_DIO_CODE /* vvvvvvvv following code borrowed from st driver's direct IO vvvvvvvvv */ - /* hopefully this generic code will moved to a library */ + /* TODO: hopefully we can use the generic block layer code */ /* Pin down user pages and put them into a scatter gather list. Returns <= 0 if - mapping of all pages not successful - - any page is above max_pfn (i.e., either completely successful or fails) */ static int st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, - unsigned long uaddr, size_t count, int rw, - unsigned long max_pfn) + unsigned long uaddr, size_t count, int rw) { unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT; unsigned long start = uaddr >> PAGE_SHIFT; @@ -1828,21 +1752,17 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, * probably wrong function for rw==WRITE */ flush_dcache_page(pages[i]); - if (page_to_pfn(pages[i]) > max_pfn) - goto out_unlock; /* ?? Is locking needed? I don't think so */ /* if (TestSetPageLocked(pages[i])) goto out_unlock; */ } - /* Populate the scatter/gather list */ - sgl[0].page = pages[0]; + sgl[0].page = pages[0]; sgl[0].offset = uaddr & ~PAGE_MASK; if (nr_pages > 1) { sgl[0].length = PAGE_SIZE - sgl[0].offset; count -= sgl[0].length; for (i=1; i < nr_pages ; i++) { - sgl[i].offset = 0; sgl[i].page = pages[i]; sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; count -= PAGE_SIZE; @@ -1855,10 +1775,6 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, kfree(pages); return nr_pages; - out_unlock: - /* for (j=0; j < i; j++) - unlock_page(pages[j]); */ - res = 0; out_unmap: if (res > 0) { for (j=0; j < res; j++) @@ -1904,20 +1820,20 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len) sg_io_hdr_t *hp = &srp->header; Sg_scatter_hold *schp = &srp->data; int sg_tablesize = sfp->parentdp->sg_tablesize; - struct scatterlist *sgl; int mx_sc_elems, res; struct scsi_device *sdev = sfp->parentdp->device; if (((unsigned long)hp->dxferp & queue_dma_alignment(sdev->request_queue)) != 0) return 1; + mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); if (mx_sc_elems <= 0) { return 1; } - sgl = (struct scatterlist *)schp->buffer; - res = st_map_user_pages(sgl, mx_sc_elems, (unsigned long)hp->dxferp, dxfer_len, - (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0, ULONG_MAX); + res = st_map_user_pages(schp->buffer, mx_sc_elems, + (unsigned long)hp->dxferp, dxfer_len, + (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0); if (res <= 0) return 1; schp->k_use_sg = res; @@ -1932,9 +1848,11 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len) static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) { - int ret_sz; + struct scatterlist *sg; + int ret_sz = 0, k, rem_sz, num, mx_sc_elems; + int sg_tablesize = sfp->parentdp->sg_tablesize; int blk_size = buff_size; - unsigned char *p = NULL; + struct page *p = NULL; if ((blk_size < 0) || (!sfp)) return -EFAULT; @@ -1944,59 +1862,35 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) blk_size = (blk_size + SG_SECTOR_MSK) & (~SG_SECTOR_MSK); SCSI_LOG_TIMEOUT(4, printk("sg_build_indirect: buff_size=%d, blk_size=%d\n", buff_size, blk_size)); - if (blk_size <= SG_SCATTER_SZ) { - p = sg_page_malloc(blk_size, sfp->low_dma, &ret_sz); - if (!p) - return -ENOMEM; - if (blk_size == ret_sz) { /* got it on the first attempt */ - schp->k_use_sg = 0; - schp->buffer = p; - schp->bufflen = blk_size; - schp->b_malloc_len = blk_size; - return 0; - } - } else { - p = sg_page_malloc(SG_SCATTER_SZ, sfp->low_dma, &ret_sz); + + /* N.B. ret_sz carried into this block ... */ + mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); + if (mx_sc_elems < 0) + return mx_sc_elems; /* most likely -ENOMEM */ + + for (k = 0, sg = schp->buffer, rem_sz = blk_size; + (rem_sz > 0) && (k < mx_sc_elems); + ++k, rem_sz -= ret_sz, ++sg) { + + num = (rem_sz > SG_SCATTER_SZ) ? SG_SCATTER_SZ : rem_sz; + p = sg_page_malloc(num, sfp->low_dma, &ret_sz); if (!p) return -ENOMEM; - } -/* Want some local declarations, so start new block ... */ - { /* lets try and build a scatter gather list */ - struct scatterlist *sclp; - int k, rem_sz, num; - int mx_sc_elems; - int sg_tablesize = sfp->parentdp->sg_tablesize; - int first = 1; - - /* N.B. ret_sz carried into this block ... */ - mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); - if (mx_sc_elems < 0) - return mx_sc_elems; /* most likely -ENOMEM */ - - for (k = 0, sclp = schp->buffer, rem_sz = blk_size; - (rem_sz > 0) && (k < mx_sc_elems); - ++k, rem_sz -= ret_sz, ++sclp) { - if (first) - first = 0; - else { - num = - (rem_sz > - SG_SCATTER_SZ) ? SG_SCATTER_SZ : rem_sz; - p = sg_page_malloc(num, sfp->low_dma, &ret_sz); - if (!p) - break; - } - sg_set_buf(sclp, p, ret_sz); - - SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", - k, sg_scatg2virt(sclp), ret_sz)); - } /* end of for loop */ - schp->k_use_sg = k; - SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, rem_sz=%d\n", k, rem_sz)); - schp->bufflen = blk_size; - if (rem_sz > 0) /* must have failed */ - return -ENOMEM; - } + + sg->page = p; + sg->length = ret_sz; + + SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n", + k, p, ret_sz)); + } /* end of for loop */ + + schp->k_use_sg = k; + SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, rem_sz=%d\n", k, rem_sz)); + + schp->bufflen = blk_size; + if (rem_sz > 0) /* must have failed */ + return -ENOMEM; + return 0; } @@ -2005,6 +1899,7 @@ sg_write_xfer(Sg_request * srp) { sg_io_hdr_t *hp = &srp->header; Sg_scatter_hold *schp = &srp->data; + struct scatterlist *sg = schp->buffer; int num_xfer = 0; int j, k, onum, usglen, ksglen, res; int iovec_count = (int) hp->iovec_count; @@ -2033,63 +1928,45 @@ sg_write_xfer(Sg_request * srp) } else onum = 1; - if (0 == schp->k_use_sg) { /* kernel has single buffer */ - for (j = 0, p = schp->buffer; j < onum; ++j) { - res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up); - if (res) - return res; - usglen = (num_xfer > usglen) ? usglen : num_xfer; - if (__copy_from_user(p, up, usglen)) - return -EFAULT; - p += usglen; - num_xfer -= usglen; - if (num_xfer <= 0) - return 0; - } - } else { /* kernel using scatter gather list */ - struct scatterlist *sclp = (struct scatterlist *) schp->buffer; - - ksglen = (int) sclp->length; - p = sg_scatg2virt(sclp); - for (j = 0, k = 0; j < onum; ++j) { - res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up); - if (res) - return res; - - for (; p; ++sclp, ksglen = (int) sclp->length, - p = sg_scatg2virt(sclp)) { - if (usglen <= 0) - break; - if (ksglen > usglen) { - if (usglen >= num_xfer) { - if (__copy_from_user - (p, up, num_xfer)) - return -EFAULT; - return 0; - } - if (__copy_from_user(p, up, usglen)) - return -EFAULT; - p += usglen; - ksglen -= usglen; - break; - } else { - if (ksglen >= num_xfer) { - if (__copy_from_user - (p, up, num_xfer)) - return -EFAULT; - return 0; - } - if (__copy_from_user(p, up, ksglen)) + ksglen = sg->length; + p = page_address(sg->page); + for (j = 0, k = 0; j < onum; ++j) { + res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up); + if (res) + return res; + + for (; p; ++sg, ksglen = sg->length, + p = page_address(sg->page)) { + if (usglen <= 0) + break; + if (ksglen > usglen) { + if (usglen >= num_xfer) { + if (__copy_from_user(p, up, num_xfer)) return -EFAULT; - up += ksglen; - usglen -= ksglen; + return 0; } - ++k; - if (k >= schp->k_use_sg) + if (__copy_from_user(p, up, usglen)) + return -EFAULT; + p += usglen; + ksglen -= usglen; + break; + } else { + if (ksglen >= num_xfer) { + if (__copy_from_user(p, up, num_xfer)) + return -EFAULT; return 0; + } + if (__copy_from_user(p, up, ksglen)) + return -EFAULT; + up += ksglen; + usglen -= ksglen; } + ++k; + if (k >= schp->k_use_sg) + return 0; } } + return 0; } @@ -2127,29 +2004,25 @@ sg_remove_scat(Sg_scatter_hold * schp) { SCSI_LOG_TIMEOUT(4, printk("sg_remove_scat: k_use_sg=%d\n", schp->k_use_sg)); if (schp->buffer && (schp->sglist_len > 0)) { - struct scatterlist *sclp = (struct scatterlist *) schp->buffer; + struct scatterlist *sg = schp->buffer; if (schp->dio_in_use) { #ifdef SG_ALLOW_DIO_CODE - st_unmap_user_pages(sclp, schp->k_use_sg, TRUE); + st_unmap_user_pages(sg, schp->k_use_sg, TRUE); #endif } else { int k; - for (k = 0; (k < schp->k_use_sg) && sg_scatg2virt(sclp); - ++k, ++sclp) { + for (k = 0; (k < schp->k_use_sg) && sg->page; + ++k, ++sg) { SCSI_LOG_TIMEOUT(5, printk( "sg_remove_scat: k=%d, a=0x%p, len=%d\n", - k, sg_scatg2virt(sclp), sclp->length)); - sg_page_free(sg_scatg2virt(sclp), sclp->length); - sclp->page = NULL; - sclp->offset = 0; - sclp->length = 0; + k, sg->page, sg->length)); + sg_page_free(sg->page, sg->length); } } - sg_page_free(schp->buffer, schp->sglist_len); - } else if (schp->buffer) - sg_page_free(schp->buffer, schp->b_malloc_len); + kfree(schp->buffer); + } memset(schp, 0, sizeof (*schp)); } @@ -2158,6 +2031,7 @@ sg_read_xfer(Sg_request * srp) { sg_io_hdr_t *hp = &srp->header; Sg_scatter_hold *schp = &srp->data; + struct scatterlist *sg = schp->buffer; int num_xfer = 0; int j, k, onum, usglen, ksglen, res; int iovec_count = (int) hp->iovec_count; @@ -2186,63 +2060,45 @@ sg_read_xfer(Sg_request * srp) } else onum = 1; - if (0 == schp->k_use_sg) { /* kernel has single buffer */ - for (j = 0, p = schp->buffer; j < onum; ++j) { - res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up); - if (res) - return res; - usglen = (num_xfer > usglen) ? usglen : num_xfer; - if (__copy_to_user(up, p, usglen)) - return -EFAULT; - p += usglen; - num_xfer -= usglen; - if (num_xfer <= 0) - return 0; - } - } else { /* kernel using scatter gather list */ - struct scatterlist *sclp = (struct scatterlist *) schp->buffer; - - ksglen = (int) sclp->length; - p = sg_scatg2virt(sclp); - for (j = 0, k = 0; j < onum; ++j) { - res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up); - if (res) - return res; - - for (; p; ++sclp, ksglen = (int) sclp->length, - p = sg_scatg2virt(sclp)) { - if (usglen <= 0) - break; - if (ksglen > usglen) { - if (usglen >= num_xfer) { - if (__copy_to_user - (up, p, num_xfer)) - return -EFAULT; - return 0; - } - if (__copy_to_user(up, p, usglen)) - return -EFAULT; - p += usglen; - ksglen -= usglen; - break; - } else { - if (ksglen >= num_xfer) { - if (__copy_to_user - (up, p, num_xfer)) - return -EFAULT; - return 0; - } - if (__copy_to_user(up, p, ksglen)) + p = page_address(sg->page); + ksglen = sg->length; + for (j = 0, k = 0; j < onum; ++j) { + res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up); + if (res) + return res; + + for (; p; ++sg, ksglen = sg->length, + p = page_address(sg->page)) { + if (usglen <= 0) + break; + if (ksglen > usglen) { + if (usglen >= num_xfer) { + if (__copy_to_user(up, p, num_xfer)) return -EFAULT; - up += ksglen; - usglen -= ksglen; + return 0; } - ++k; - if (k >= schp->k_use_sg) + if (__copy_to_user(up, p, usglen)) + return -EFAULT; + p += usglen; + ksglen -= usglen; + break; + } else { + if (ksglen >= num_xfer) { + if (__copy_to_user(up, p, num_xfer)) + return -EFAULT; return 0; + } + if (__copy_to_user(up, p, ksglen)) + return -EFAULT; + up += ksglen; + usglen -= ksglen; } + ++k; + if (k >= schp->k_use_sg) + return 0; } } + return 0; } @@ -2250,37 +2106,32 @@ static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) { Sg_scatter_hold *schp = &srp->data; + struct scatterlist *sg = schp->buffer; + int k, num; SCSI_LOG_TIMEOUT(4, printk("sg_read_oxfer: num_read_xfer=%d\n", num_read_xfer)); if ((!outp) || (num_read_xfer <= 0)) return 0; - if (schp->k_use_sg > 0) { - int k, num; - struct scatterlist *sclp = (struct scatterlist *) schp->buffer; - - for (k = 0; (k < schp->k_use_sg) && sg_scatg2virt(sclp); - ++k, ++sclp) { - num = (int) sclp->length; - if (num > num_read_xfer) { - if (__copy_to_user - (outp, sg_scatg2virt(sclp), num_read_xfer)) - return -EFAULT; + + for (k = 0; (k < schp->k_use_sg) && sg->page; ++k, ++sg) { + num = sg->length; + if (num > num_read_xfer) { + if (__copy_to_user(outp, page_address(sg->page), + num_read_xfer)) + return -EFAULT; + break; + } else { + if (__copy_to_user(outp, page_address(sg->page), + num)) + return -EFAULT; + num_read_xfer -= num; + if (num_read_xfer <= 0) break; - } else { - if (__copy_to_user - (outp, sg_scatg2virt(sclp), num)) - return -EFAULT; - num_read_xfer -= num; - if (num_read_xfer <= 0) - break; - outp += num; - } + outp += num; } - } else { - if (__copy_to_user(outp, schp->buffer, num_read_xfer)) - return -EFAULT; } + return 0; } @@ -2306,44 +2157,31 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) { Sg_scatter_hold *req_schp = &srp->data; Sg_scatter_hold *rsv_schp = &sfp->reserve; + struct scatterlist *sg = rsv_schp->buffer; + int k, num, rem; srp->res_used = 1; SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size)); - size = (size + 1) & (~1); /* round to even for aha1542 */ - if (rsv_schp->k_use_sg > 0) { - int k, num; - int rem = size; - struct scatterlist *sclp = - (struct scatterlist *) rsv_schp->buffer; - - for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sclp) { - num = (int) sclp->length; - if (rem <= num) { - if (0 == k) { - req_schp->k_use_sg = 0; - req_schp->buffer = sg_scatg2virt(sclp); - } else { - sfp->save_scat_len = num; - sclp->length = (unsigned) rem; - req_schp->k_use_sg = k + 1; - req_schp->sglist_len = - rsv_schp->sglist_len; - req_schp->buffer = rsv_schp->buffer; - } - req_schp->bufflen = size; - req_schp->b_malloc_len = rsv_schp->b_malloc_len; - break; - } else - rem -= num; - } - if (k >= rsv_schp->k_use_sg) - SCSI_LOG_TIMEOUT(1, printk("sg_link_reserve: BAD size\n")); - } else { - req_schp->k_use_sg = 0; - req_schp->bufflen = size; - req_schp->buffer = rsv_schp->buffer; - req_schp->b_malloc_len = rsv_schp->b_malloc_len; + rem = size = (size + 1) & (~1); /* round to even for aha1542 */ + + for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) { + num = sg->length; + if (rem <= num) { + sfp->save_scat_len = num; + sg->length = rem; + req_schp->k_use_sg = k + 1; + req_schp->sglist_len = rsv_schp->sglist_len; + req_schp->buffer = rsv_schp->buffer; + + req_schp->bufflen = size; + req_schp->b_malloc_len = rsv_schp->b_malloc_len; + break; + } else + rem -= num; } + + if (k >= rsv_schp->k_use_sg) + SCSI_LOG_TIMEOUT(1, printk("sg_link_reserve: BAD size\n")); } static void @@ -2355,11 +2193,10 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) SCSI_LOG_TIMEOUT(4, printk("sg_unlink_reserve: req->k_use_sg=%d\n", (int) req_schp->k_use_sg)); if ((rsv_schp->k_use_sg > 0) && (req_schp->k_use_sg > 0)) { - struct scatterlist *sclp = - (struct scatterlist *) rsv_schp->buffer; + struct scatterlist *sg = rsv_schp->buffer; if (sfp->save_scat_len > 0) - (sclp + (req_schp->k_use_sg - 1))->length = + (sg + (req_schp->k_use_sg - 1))->length = (unsigned) sfp->save_scat_len; else SCSI_LOG_TIMEOUT(1, printk ("sg_unlink_reserve: BAD save_scat_len\n")); @@ -2445,7 +2282,6 @@ sg_add_request(Sg_fd * sfp) if (resp) { resp->nextrp = NULL; resp->header.duration = jiffies_to_msecs(jiffies); - resp->my_cmdp = NULL; } write_unlock_irqrestore(&sfp->rq_list_lock, iflags); return resp; @@ -2463,8 +2299,6 @@ sg_remove_request(Sg_fd * sfp, Sg_request * srp) if ((!sfp) || (!srp) || (!sfp->headrp)) return res; write_lock_irqsave(&sfp->rq_list_lock, iflags); - if (srp->my_cmdp) - srp->my_cmdp->upper_private_data = NULL; prev_rp = sfp->headrp; if (srp == prev_rp) { sfp->headrp = prev_rp->nextrp; @@ -2507,10 +2341,10 @@ sg_add_sfp(Sg_device * sdp, int dev) Sg_fd *sfp; unsigned long iflags; - sfp = (Sg_fd *) sg_page_malloc(sizeof (Sg_fd), 0, NULL); + sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); if (!sfp) return NULL; - memset(sfp, 0, sizeof (Sg_fd)); + init_waitqueue_head(&sfp->read_wait); rwlock_init(&sfp->rq_list_lock); @@ -2567,7 +2401,7 @@ __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp) } sfp->parentdp = NULL; SCSI_LOG_TIMEOUT(6, printk("__sg_remove_sfp: sfp=0x%p\n", sfp)); - sg_page_free((char *) sfp, sizeof (Sg_fd)); + kfree(sfp); } /* Returns 0 in normal case, 1 when detached and sdp object removed */ @@ -2632,10 +2466,10 @@ sg_res_in_use(Sg_fd * sfp) } /* If retSzp==NULL want exact size or fail */ -static char * +static struct page * sg_page_malloc(int rqSz, int lowDma, int *retSzp) { - char *resp = NULL; + struct page *resp = NULL; gfp_t page_mask; int order, a_size; int resSz = rqSz; @@ -2650,11 +2484,11 @@ sg_page_malloc(int rqSz, int lowDma, int *retSzp) for (order = 0, a_size = PAGE_SIZE; a_size < rqSz; order++, a_size <<= 1) ; - resp = (char *) __get_free_pages(page_mask, order); + resp = alloc_pages(page_mask, order); while ((!resp) && order && retSzp) { --order; a_size >>= 1; /* divide by 2, until PAGE_SIZE */ - resp = (char *) __get_free_pages(page_mask, order); /* try half */ + resp = alloc_pages(page_mask, order); /* try half */ resSz = a_size; } if (resp) { @@ -2667,15 +2501,15 @@ sg_page_malloc(int rqSz, int lowDma, int *retSzp) } static void -sg_page_free(char *buff, int size) +sg_page_free(struct page *page, int size) { int order, a_size; - if (!buff) + if (!page) return; for (order = 0, a_size = PAGE_SIZE; a_size < size; order++, a_size <<= 1) ; - free_pages((unsigned long) buff, order); + __free_pages(page, order); } #ifndef MAINTENANCE_IN_CMD @@ -3067,13 +2901,11 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp) cp = " "; } seq_printf(s, cp); - blen = srp->my_cmdp ? - srp->my_cmdp->sr_bufflen : srp->data.bufflen; - usg = srp->my_cmdp ? - srp->my_cmdp->sr_use_sg : srp->data.k_use_sg; + blen = srp->data.bufflen; + usg = srp->data.k_use_sg; seq_printf(s, srp->done ? ((1 == srp->done) ? "rcv:" : "fin:") - : (srp->my_cmdp ? "act:" : "prior:")); + : "act:"); seq_printf(s, " id=%d blen=%d", srp->header.pack_id, blen); if (srp->done) -- cgit v1.1 From 8b05b773b6030de5b1bab1cbb0bf1ff8c34cdbe0 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Tue, 8 Nov 2005 04:06:44 -0600 Subject: [SCSI] convert st to use scsi_execute_async convert st to always send scatterlists and kill scsi_request usage. This is the same as last time as it was posted, but with Kai's patches merged and we now pass the bytes value to scsi_execute_async. TODO: - move DIO code to common place or make block layers usable for ULDs. - move buffer allocation code to common place for all ULDs to use. And make buffer allocation code handle all queue limits so we can find out about problems before calling scsi_execute_async. - move indirect (copy_to/from_user) paths commone place or make block layers usable for ULDs. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/st.c | 254 +++++++++++++++++++++++------------------------------- drivers/scsi/st.h | 14 ++- 2 files changed, 123 insertions(+), 145 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 053444b..26e13dc 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -50,7 +50,6 @@ static const char *verstr = "20050830"; #include #include #include -#include #include @@ -188,8 +187,6 @@ static int from_buffer(struct st_buffer *, char __user *, int); static void move_buffer_data(struct st_buffer *, int); static void buf_to_sg(struct st_buffer *, unsigned int); -static int st_map_user_pages(struct scatterlist *, const unsigned int, - unsigned long, size_t, int, unsigned long); static int sgl_map_user_pages(struct scatterlist *, const unsigned int, unsigned long, size_t, int); static int sgl_unmap_user_pages(struct scatterlist *, const unsigned int, int); @@ -313,12 +310,13 @@ static inline char *tape_name(struct scsi_tape *tape) } -static void st_analyze_sense(struct scsi_request *SRpnt, struct st_cmdstatus *s) +static void st_analyze_sense(struct st_request *SRpnt, struct st_cmdstatus *s) { const u8 *ucp; - const u8 *sense = SRpnt->sr_sense_buffer; + const u8 *sense = SRpnt->sense; - s->have_sense = scsi_request_normalize_sense(SRpnt, &s->sense_hdr); + s->have_sense = scsi_normalize_sense(SRpnt->sense, + SCSI_SENSE_BUFFERSIZE, &s->sense_hdr); s->flags = 0; if (s->have_sense) { @@ -345,9 +343,9 @@ static void st_analyze_sense(struct scsi_request *SRpnt, struct st_cmdstatus *s) /* Convert the result to success code */ -static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt) +static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) { - int result = SRpnt->sr_result; + int result = SRpnt->result; u8 scode; DEB(const char *stp;) char *name = tape_name(STp); @@ -366,13 +364,12 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt) DEB( if (debugging) { - printk(ST_DEB_MSG "%s: Error: %x, cmd: %x %x %x %x %x %x Len: %d\n", + printk(ST_DEB_MSG "%s: Error: %x, cmd: %x %x %x %x %x %x\n", name, result, - SRpnt->sr_cmnd[0], SRpnt->sr_cmnd[1], SRpnt->sr_cmnd[2], - SRpnt->sr_cmnd[3], SRpnt->sr_cmnd[4], SRpnt->sr_cmnd[5], - SRpnt->sr_bufflen); + SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2], + SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]); if (cmdstatp->have_sense) - scsi_print_req_sense("st", SRpnt); + __scsi_print_sense("st", SRpnt->sense, SCSI_SENSE_BUFFERSIZE); } ) /* end DEB */ if (!debugging) { /* Abnormal conditions for tape */ if (!cmdstatp->have_sense) @@ -386,20 +383,21 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt) /* scode != UNIT_ATTENTION && */ scode != BLANK_CHECK && scode != VOLUME_OVERFLOW && - SRpnt->sr_cmnd[0] != MODE_SENSE && - SRpnt->sr_cmnd[0] != TEST_UNIT_READY) { + SRpnt->cmd[0] != MODE_SENSE && + SRpnt->cmd[0] != TEST_UNIT_READY) { printk(KERN_WARNING "%s: Error with sense data: ", name); - scsi_print_req_sense("st", SRpnt); + __scsi_print_sense("st", SRpnt->sense, + SCSI_SENSE_BUFFERSIZE); } } if (cmdstatp->fixed_format && STp->cln_mode >= EXTENDED_SENSE_START) { /* Only fixed format sense */ if (STp->cln_sense_value) - STp->cleaning_req |= ((SRpnt->sr_sense_buffer[STp->cln_mode] & + STp->cleaning_req |= ((SRpnt->sense[STp->cln_mode] & STp->cln_sense_mask) == STp->cln_sense_value); else - STp->cleaning_req |= ((SRpnt->sr_sense_buffer[STp->cln_mode] & + STp->cleaning_req |= ((SRpnt->sense[STp->cln_mode] & STp->cln_sense_mask) != 0); } if (cmdstatp->have_sense && @@ -411,8 +409,8 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt) if (cmdstatp->have_sense && scode == RECOVERED_ERROR #if ST_RECOVERED_WRITE_FATAL - && SRpnt->sr_cmnd[0] != WRITE_6 - && SRpnt->sr_cmnd[0] != WRITE_FILEMARKS + && SRpnt->cmd[0] != WRITE_6 + && SRpnt->cmd[0] != WRITE_FILEMARKS #endif ) { STp->recover_count++; @@ -420,9 +418,9 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt) DEB( if (debugging) { - if (SRpnt->sr_cmnd[0] == READ_6) + if (SRpnt->cmd[0] == READ_6) stp = "read"; - else if (SRpnt->sr_cmnd[0] == WRITE_6) + else if (SRpnt->cmd[0] == WRITE_6) stp = "write"; else stp = "ioctl"; @@ -438,28 +436,37 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt) /* Wakeup from interrupt */ -static void st_sleep_done(struct scsi_cmnd * SCpnt) +static void st_sleep_done(void *data, char *sense, int result, int resid) { - struct scsi_tape *STp = container_of(SCpnt->request->rq_disk->private_data, - struct scsi_tape, driver); + struct st_request *SRpnt = data; + struct scsi_tape *STp = SRpnt->stp; - (STp->buffer)->cmdstat.midlevel_result = SCpnt->result; - SCpnt->request->rq_status = RQ_SCSI_DONE; + memcpy(SRpnt->sense, sense, SCSI_SENSE_BUFFERSIZE); + (STp->buffer)->cmdstat.midlevel_result = SRpnt->result = result; DEB( STp->write_pending = 0; ) - if (SCpnt->request->waiting) - complete(SCpnt->request->waiting); + if (SRpnt->waiting) + complete(SRpnt->waiting); +} + +static struct st_request *st_allocate_request(void) +{ + return kzalloc(sizeof(struct st_request), GFP_KERNEL); +} + +static void st_release_request(struct st_request *streq) +{ + kfree(streq); } /* Do the scsi command. Waits until command performed if do_wait is true. Otherwise write_behind_check() is used to check that the command has finished. */ -static struct scsi_request * -st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd, +static struct st_request * +st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd, int bytes, int direction, int timeout, int retries, int do_wait) { struct completion *waiting; - unsigned char *bp; /* if async, make sure there's no command outstanding */ if (!do_wait && ((STp->buffer)->last_SRpnt)) { @@ -473,7 +480,7 @@ st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *c } if (SRpnt == NULL) { - SRpnt = scsi_allocate_request(STp->device, GFP_ATOMIC); + SRpnt = st_allocate_request(); if (SRpnt == NULL) { DEBC( printk(KERN_ERR "%s: Can't get SCSI request.\n", tape_name(STp)); ); @@ -483,6 +490,7 @@ st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *c (STp->buffer)->syscall_result = (-EBUSY); return NULL; } + SRpnt->stp = STp; } /* If async IO, set last_SRpnt. This ptr tells write_behind_check @@ -492,32 +500,26 @@ st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *c waiting = &STp->wait; init_completion(waiting); - SRpnt->sr_use_sg = STp->buffer->do_dio || (bytes > (STp->buffer)->frp[0].length); - if (SRpnt->sr_use_sg) { - if (!STp->buffer->do_dio) - buf_to_sg(STp->buffer, bytes); - SRpnt->sr_use_sg = (STp->buffer)->sg_segs; - bp = (char *) &((STp->buffer)->sg[0]); - } else - bp = (STp->buffer)->b_data; - SRpnt->sr_data_direction = direction; - SRpnt->sr_cmd_len = 0; - SRpnt->sr_request->waiting = waiting; - SRpnt->sr_request->rq_status = RQ_SCSI_BUSY; - SRpnt->sr_request->rq_disk = STp->disk; - SRpnt->sr_request->end_io = blk_end_sync_rq; - STp->buffer->cmdstat.have_sense = 0; + SRpnt->waiting = waiting; - scsi_do_req(SRpnt, (void *) cmd, bp, bytes, - st_sleep_done, timeout, retries); + if (!STp->buffer->do_dio) + buf_to_sg(STp->buffer, bytes); - if (do_wait) { + memcpy(SRpnt->cmd, cmd, sizeof(SRpnt->cmd)); + STp->buffer->cmdstat.have_sense = 0; + STp->buffer->syscall_result = 0; + + if (scsi_execute_async(STp->device, cmd, direction, + &((STp->buffer)->sg[0]), bytes, (STp->buffer)->sg_segs, + timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) + /* could not allocate the buffer or request was too large */ + (STp->buffer)->syscall_result = (-EBUSY); + else if (do_wait) { wait_for_completion(waiting); - SRpnt->sr_request->waiting = NULL; - if (SRpnt->sr_request->rq_status != RQ_SCSI_DONE) - SRpnt->sr_result |= (DRIVER_ERROR << 24); + SRpnt->waiting = NULL; (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); } + return SRpnt; } @@ -532,7 +534,7 @@ static int write_behind_check(struct scsi_tape * STp) struct st_buffer *STbuffer; struct st_partstat *STps; struct st_cmdstatus *cmdstatp; - struct scsi_request *SRpnt; + struct st_request *SRpnt; STbuffer = STp->buffer; if (!STbuffer->writing) @@ -548,12 +550,10 @@ static int write_behind_check(struct scsi_tape * STp) wait_for_completion(&(STp->wait)); SRpnt = STbuffer->last_SRpnt; STbuffer->last_SRpnt = NULL; - SRpnt->sr_request->waiting = NULL; - if (SRpnt->sr_request->rq_status != RQ_SCSI_DONE) - SRpnt->sr_result |= (DRIVER_ERROR << 24); + SRpnt->waiting = NULL; (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); - scsi_release_request(SRpnt); + st_release_request(SRpnt); STbuffer->buffer_bytes -= STbuffer->writing; STps = &(STp->ps[STp->partition]); @@ -593,7 +593,7 @@ static int write_behind_check(struct scsi_tape * STp) it messes up the block number). */ static int cross_eof(struct scsi_tape * STp, int forward) { - struct scsi_request *SRpnt; + struct st_request *SRpnt; unsigned char cmd[MAX_COMMAND_SIZE]; cmd[0] = SPACE; @@ -613,7 +613,7 @@ static int cross_eof(struct scsi_tape * STp, int forward) if (!SRpnt) return (STp->buffer)->syscall_result; - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; if ((STp->buffer)->cmdstat.midlevel_result != 0) @@ -630,7 +630,7 @@ static int flush_write_buffer(struct scsi_tape * STp) int offset, transfer, blks; int result; unsigned char cmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt; + struct st_request *SRpnt; struct st_partstat *STps; result = write_behind_check(STp); @@ -688,7 +688,7 @@ static int flush_write_buffer(struct scsi_tape * STp) STp->dirty = 0; (STp->buffer)->buffer_bytes = 0; } - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; } return result; @@ -785,7 +785,7 @@ static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm) } -/* Lock or unlock the drive door. Don't use when scsi_request allocated. */ +/* Lock or unlock the drive door. Don't use when st_request allocated. */ static int do_door_lock(struct scsi_tape * STp, int do_lock) { int retval, cmd; @@ -844,7 +844,7 @@ static int test_ready(struct scsi_tape *STp, int do_wait) int attentions, waits, max_wait, scode; int retval = CHKRES_READY, new_session = 0; unsigned char cmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt = NULL; + struct st_request *SRpnt = NULL; struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; max_wait = do_wait ? ST_BLOCK_SECONDS : 0; @@ -903,7 +903,7 @@ static int test_ready(struct scsi_tape *STp, int do_wait) } if (SRpnt != NULL) - scsi_release_request(SRpnt); + st_release_request(SRpnt); return retval; } @@ -918,7 +918,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp) int i, retval, new_session = 0, do_wait; unsigned char cmd[MAX_COMMAND_SIZE], saved_cleaning; unsigned short st_flags = filp->f_flags; - struct scsi_request *SRpnt = NULL; + struct st_request *SRpnt = NULL; struct st_modedef *STm; struct st_partstat *STps; char *name = tape_name(STp); @@ -993,7 +993,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp) goto err_out; } - if (!SRpnt->sr_result && !STp->buffer->cmdstat.have_sense) { + if (!SRpnt->result && !STp->buffer->cmdstat.have_sense) { STp->max_block = ((STp->buffer)->b_data[1] << 16) | ((STp->buffer)->b_data[2] << 8) | (STp->buffer)->b_data[3]; STp->min_block = ((STp->buffer)->b_data[4] << 8) | @@ -1045,7 +1045,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp) } STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0; } - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; STp->inited = 1; @@ -1196,7 +1196,7 @@ static int st_flush(struct file *filp) { int result = 0, result2; unsigned char cmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt; + struct st_request *SRpnt; struct scsi_tape *STp = filp->private_data; struct st_modedef *STm = &(STp->modes[STp->current_mode]); struct st_partstat *STps = &(STp->ps[STp->partition]); @@ -1249,7 +1249,7 @@ static int st_flush(struct file *filp) cmdstatp->sense_hdr.sense_key == RECOVERED_ERROR) && (!cmdstatp->remainder_valid || cmdstatp->uremainder64 == 0))) { /* Write successful at EOM */ - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; if (STps->drv_file >= 0) STps->drv_file++; @@ -1259,7 +1259,7 @@ static int st_flush(struct file *filp) STps->eof = ST_FM; } else { /* Write error */ - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; printk(KERN_ERR "%s: Error on write filemark.\n", name); if (result == 0) @@ -1400,11 +1400,11 @@ static int setup_buffering(struct scsi_tape *STp, const char __user *buf, i = STp->try_dio && try_rdio; else i = STp->try_dio && try_wdio; + if (i && ((unsigned long)buf & queue_dma_alignment( STp->device->request_queue)) == 0) { - i = st_map_user_pages(&(STbp->sg[0]), STbp->use_sg, - (unsigned long)buf, count, (is_read ? READ : WRITE), - STp->max_pfn); + i = sgl_map_user_pages(&(STbp->sg[0]), STbp->use_sg, + (unsigned long)buf, count, (is_read ? READ : WRITE)); if (i > 0) { STbp->do_dio = i; STbp->buffer_bytes = 0; /* can be used as transfer counter */ @@ -1472,7 +1472,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) int async_write; unsigned char cmd[MAX_COMMAND_SIZE]; const char __user *b_point; - struct scsi_request *SRpnt = NULL; + struct st_request *SRpnt = NULL; struct scsi_tape *STp = filp->private_data; struct st_modedef *STm; struct st_partstat *STps; @@ -1624,7 +1624,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) retval = STbp->syscall_result; goto out; } - if (async_write) { + if (async_write && !STbp->syscall_result) { STbp->writing = transfer; STp->dirty = !(STbp->writing == STbp->buffer_bytes); @@ -1698,7 +1698,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) } else { count += do_count; STps->drv_block = (-1); /* Too cautious? */ - retval = (-EIO); + retval = STbp->syscall_result; } } @@ -1728,7 +1728,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) out: if (SRpnt != NULL) - scsi_release_request(SRpnt); + st_release_request(SRpnt); release_buffering(STp); up(&STp->lock); @@ -1742,11 +1742,11 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) Does release user buffer mapping if it is set. */ static long read_tape(struct scsi_tape *STp, long count, - struct scsi_request ** aSRpnt) + struct st_request ** aSRpnt) { int transfer, blks, bytes; unsigned char cmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt; + struct st_request *SRpnt; struct st_modedef *STm; struct st_partstat *STps; struct st_buffer *STbp; @@ -1802,10 +1802,10 @@ static long read_tape(struct scsi_tape *STp, long count, retval = 1; DEBC(printk(ST_DEB_MSG "%s: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n", name, - SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[1], - SRpnt->sr_sense_buffer[2], SRpnt->sr_sense_buffer[3], - SRpnt->sr_sense_buffer[4], SRpnt->sr_sense_buffer[5], - SRpnt->sr_sense_buffer[6], SRpnt->sr_sense_buffer[7])); + SRpnt->sense[0], SRpnt->sense[1], + SRpnt->sense[2], SRpnt->sense[3], + SRpnt->sense[4], SRpnt->sense[5], + SRpnt->sense[6], SRpnt->sense[7])); if (cmdstatp->have_sense) { if (cmdstatp->sense_hdr.sense_key == BLANK_CHECK) @@ -1835,7 +1835,7 @@ static long read_tape(struct scsi_tape *STp, long count, } STbp->buffer_bytes = bytes - transfer; } else { - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = *aSRpnt = NULL; if (transfer == blks) { /* We did not get anything, error */ printk(KERN_NOTICE "%s: Incorrect block size.\n", name); @@ -1929,7 +1929,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) ssize_t retval = 0; ssize_t i, transfer; int special, do_dio = 0; - struct scsi_request *SRpnt = NULL; + struct st_request *SRpnt = NULL; struct scsi_tape *STp = filp->private_data; struct st_modedef *STm; struct st_partstat *STps; @@ -2054,7 +2054,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) out: if (SRpnt != NULL) { - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; } if (do_dio) { @@ -2284,7 +2284,7 @@ static int st_set_options(struct scsi_tape *STp, long options) static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) { unsigned char cmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt = NULL; + struct st_request *SRpnt = NULL; memset(cmd, 0, MAX_COMMAND_SIZE); cmd[0] = MODE_SENSE; @@ -2298,7 +2298,7 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) if (SRpnt == NULL) return (STp->buffer)->syscall_result; - scsi_release_request(SRpnt); + st_release_request(SRpnt); return (STp->buffer)->syscall_result; } @@ -2310,7 +2310,7 @@ static int write_mode_page(struct scsi_tape *STp, int page, int slow) { int pgo; unsigned char cmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt = NULL; + struct st_request *SRpnt = NULL; memset(cmd, 0, MAX_COMMAND_SIZE); cmd[0] = MODE_SELECT; @@ -2329,7 +2329,7 @@ static int write_mode_page(struct scsi_tape *STp, int page, int slow) if (SRpnt == NULL) return (STp->buffer)->syscall_result; - scsi_release_request(SRpnt); + st_release_request(SRpnt); return (STp->buffer)->syscall_result; } @@ -2412,7 +2412,7 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod DEB( char *name = tape_name(STp); ) unsigned char cmd[MAX_COMMAND_SIZE]; struct st_partstat *STps; - struct scsi_request *SRpnt; + struct st_request *SRpnt; if (STp->ready != ST_READY && !load_code) { if (STp->ready == ST_NO_TAPE) @@ -2455,7 +2455,7 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod return (STp->buffer)->syscall_result; retval = (STp->buffer)->syscall_result; - scsi_release_request(SRpnt); + st_release_request(SRpnt); if (!retval) { /* SCSI command successful */ @@ -2503,7 +2503,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon int ioctl_result; int chg_eof = 1; unsigned char cmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt; + struct st_request *SRpnt; struct st_partstat *STps; int fileno, blkno, at_sm, undone; int datalen = 0, direction = DMA_NONE; @@ -2757,7 +2757,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon ioctl_result = (STp->buffer)->syscall_result; if (!ioctl_result) { /* SCSI command successful */ - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; STps->drv_block = blkno; STps->drv_file = fileno; @@ -2872,7 +2872,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon /* Try the other possible state of Page Format if not already tried */ STp->use_pf = !STp->use_pf | PF_TESTED; - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; return st_int_ioctl(STp, cmd_in, arg); } @@ -2882,7 +2882,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon if (cmdstatp->sense_hdr.sense_key == BLANK_CHECK) STps->eof = ST_EOD; - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; } @@ -2898,7 +2898,7 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti { int result; unsigned char scmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt; + struct st_request *SRpnt; DEB( char *name = tape_name(STp); ) if (STp->ready != ST_READY) @@ -2944,7 +2944,7 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name, *block, *partition)); } - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; return result; @@ -2961,7 +2961,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition unsigned int blk; int timeout; unsigned char scmd[MAX_COMMAND_SIZE]; - struct scsi_request *SRpnt; + struct st_request *SRpnt; DEB( char *name = tape_name(STp); ) if (STp->ready != ST_READY) @@ -3047,7 +3047,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition result = 0; } - scsi_release_request(SRpnt); + st_release_request(SRpnt); SRpnt = NULL; return result; @@ -3577,7 +3577,7 @@ static long st_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a static struct st_buffer * new_tape_buffer(int from_initialization, int need_dma, int max_sg) { - int i, got = 0, segs = 0; + int i, got = 0; gfp_t priority; struct st_buffer *tb; @@ -3594,10 +3594,8 @@ static struct st_buffer * return NULL; } memset(tb, 0, i); - tb->frp_segs = tb->orig_frp_segs = segs; + tb->frp_segs = tb->orig_frp_segs = 0; tb->use_sg = max_sg; - if (segs > 0) - tb->b_data = page_address(tb->sg[0].page); tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg); tb->in_use = 1; @@ -3628,7 +3626,7 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm priority = GFP_KERNEL | __GFP_NOWARN; if (need_dma) priority |= GFP_DMA; - for (b_size = PAGE_SIZE, order=0; + for (b_size = PAGE_SIZE, order=0; order <= 6 && b_size < new_size - STbuffer->buffer_size; order++, b_size *= 2) ; /* empty */ @@ -3670,6 +3668,7 @@ static void normalize_buffer(struct st_buffer * STbuffer) } STbuffer->frp_segs = STbuffer->orig_frp_segs; STbuffer->frp_sg_current = 0; + STbuffer->sg_segs = 0; } @@ -3882,7 +3881,6 @@ static int st_probe(struct device *dev) struct st_buffer *buffer; int i, j, mode, dev_num, error; char *stp; - u64 bounce_limit; if (SDp->type != TYPE_TAPE) return -ENODEV; @@ -3892,7 +3890,8 @@ static int st_probe(struct device *dev) return -ENODEV; } - i = SDp->host->sg_tablesize; + i = min(SDp->request_queue->max_hw_segments, + SDp->request_queue->max_phys_segments); if (st_max_sg_segs < i) i = st_max_sg_segs; buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i); @@ -3994,11 +3993,6 @@ static int st_probe(struct device *dev) tpnt->long_timeout = ST_LONG_TIMEOUT; tpnt->try_dio = try_direct_io && !SDp->host->unchecked_isa_dma; - bounce_limit = scsi_calculate_bounce_limit(SDp->host) >> PAGE_SHIFT; - if (bounce_limit > ULONG_MAX) - bounce_limit = ULONG_MAX; - tpnt->max_pfn = bounce_limit; - for (i = 0; i < ST_NBR_MODES; i++) { STm = &(tpnt->modes[i]); STm->defined = 0; @@ -4077,9 +4071,9 @@ static int st_probe(struct device *dev) sdev_printk(KERN_WARNING, SDp, "Attached scsi tape %s", tape_name(tpnt)); - printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B), max page reachable by HBA %lu\n", + printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n", tape_name(tpnt), tpnt->try_dio ? "yes" : "no", - queue_dma_alignment(SDp->request_queue) + 1, tpnt->max_pfn); + queue_dma_alignment(SDp->request_queue) + 1); return 0; @@ -4411,34 +4405,6 @@ static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) return; } - -/* Pin down user pages and put them into a scatter gather list. Returns <= 0 if - - mapping of all pages not successful - - any page is above max_pfn - (i.e., either completely successful or fails) -*/ -static int st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, - unsigned long uaddr, size_t count, int rw, - unsigned long max_pfn) -{ - int i, nr_pages; - - nr_pages = sgl_map_user_pages(sgl, max_pages, uaddr, count, rw); - if (nr_pages <= 0) - return nr_pages; - - for (i=0; i < nr_pages; i++) { - if (page_to_pfn(sgl[i].page) > max_pfn) - goto out_unmap; - } - return nr_pages; - - out_unmap: - sgl_unmap_user_pages(sgl, nr_pages, 0); - return 0; -} - - /* The following functions may be useful for a larger audience. */ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, unsigned long uaddr, size_t count, int rw) diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h index 790acac..4112090 100644 --- a/drivers/scsi/st.h +++ b/drivers/scsi/st.h @@ -4,6 +4,7 @@ #include #include +#include /* Descriptor for analyzed sense data */ struct st_cmdstatus { @@ -17,6 +18,17 @@ struct st_cmdstatus { u8 deferred; }; +struct scsi_tape; + +/* scsi tape command */ +struct st_request { + unsigned char cmd[MAX_COMMAND_SIZE]; + unsigned char sense[SCSI_SENSE_BUFFERSIZE]; + int result; + struct scsi_tape *stp; + struct completion *waiting; +}; + /* The tape buffer descriptor. */ struct st_buffer { unsigned char in_use; @@ -28,7 +40,7 @@ struct st_buffer { int read_pointer; int writing; int syscall_result; - struct scsi_request *last_SRpnt; + struct st_request *last_SRpnt; struct st_cmdstatus cmdstat; unsigned char *b_data; unsigned short use_sg; /* zero or max number of s/g segments for this adapter */ -- cgit v1.1 From defd94b75409b983f94548ea2f52ff5787ddb848 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Mon, 5 Dec 2005 02:37:06 -0600 Subject: [SCSI] seperate max_sectors from max_hw_sectors - export __blk_put_request and blk_execute_rq_nowait needed for async REQ_BLOCK_PC requests - seperate max_hw_sectors and max_sectors for block/scsi_ioctl.c and SG_IO bio.c helpers per Jens's last comments. Since block/scsi_ioctl.c SG_IO was already testing against max_sectors and SCSI-ml was setting max_sectors and max_hw_sectors to the same value this does not change any scsi SG_IO behavior. It only prepares ll_rw_blk.c, scsi_ioctl.c and bio.c for when SCSI-ml begins to set a valid max_hw_sectors for all LLDs. Today if a LLD does not set it SCSI-ml sets it to a safe default and some LLDs set it to a artificial low value to overcome memory and feedback issues. Note: Since we now cap max_sectors to BLK_DEF_MAX_SECTORS, which is 1024, drivers that used to call blk_queue_max_sectors with a large value of max_sectors will now see the fs requests capped to BLK_DEF_MAX_SECTORS. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- block/ll_rw_blk.c | 34 ++++++++++++++++++++++++++-------- block/scsi_ioctl.c | 2 +- drivers/md/dm-table.c | 2 +- drivers/scsi/scsi_lib.c | 2 +- fs/bio.c | 20 +++++++++++--------- include/linux/blkdev.h | 3 ++- 6 files changed, 42 insertions(+), 21 deletions(-) diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index c525b5a..d4beb9a 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -239,7 +239,7 @@ void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn) q->backing_dev_info.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; q->backing_dev_info.state = 0; q->backing_dev_info.capabilities = BDI_CAP_MAP_COPY; - blk_queue_max_sectors(q, MAX_SECTORS); + blk_queue_max_sectors(q, SAFE_MAX_SECTORS); blk_queue_hardsect_size(q, 512); blk_queue_dma_alignment(q, 511); blk_queue_congestion_threshold(q); @@ -555,7 +555,12 @@ void blk_queue_max_sectors(request_queue_t *q, unsigned short max_sectors) printk("%s: set to minimum %d\n", __FUNCTION__, max_sectors); } - q->max_sectors = q->max_hw_sectors = max_sectors; + if (BLK_DEF_MAX_SECTORS > max_sectors) + q->max_hw_sectors = q->max_sectors = max_sectors; + else { + q->max_sectors = BLK_DEF_MAX_SECTORS; + q->max_hw_sectors = max_sectors; + } } EXPORT_SYMBOL(blk_queue_max_sectors); @@ -657,8 +662,8 @@ EXPORT_SYMBOL(blk_queue_hardsect_size); void blk_queue_stack_limits(request_queue_t *t, request_queue_t *b) { /* zero is "infinity" */ - t->max_sectors = t->max_hw_sectors = - min_not_zero(t->max_sectors,b->max_sectors); + t->max_sectors = min_not_zero(t->max_sectors,b->max_sectors); + t->max_hw_sectors = min_not_zero(t->max_hw_sectors,b->max_hw_sectors); t->max_phys_segments = min(t->max_phys_segments,b->max_phys_segments); t->max_hw_segments = min(t->max_hw_segments,b->max_hw_segments); @@ -1293,9 +1298,15 @@ static inline int ll_new_hw_segment(request_queue_t *q, static int ll_back_merge_fn(request_queue_t *q, struct request *req, struct bio *bio) { + unsigned short max_sectors; int len; - if (req->nr_sectors + bio_sectors(bio) > q->max_sectors) { + if (unlikely(blk_pc_request(req))) + max_sectors = q->max_hw_sectors; + else + max_sectors = q->max_sectors; + + if (req->nr_sectors + bio_sectors(bio) > max_sectors) { req->flags |= REQ_NOMERGE; if (req == q->last_merge) q->last_merge = NULL; @@ -1325,9 +1336,16 @@ static int ll_back_merge_fn(request_queue_t *q, struct request *req, static int ll_front_merge_fn(request_queue_t *q, struct request *req, struct bio *bio) { + unsigned short max_sectors; int len; - if (req->nr_sectors + bio_sectors(bio) > q->max_sectors) { + if (unlikely(blk_pc_request(req))) + max_sectors = q->max_hw_sectors; + else + max_sectors = q->max_sectors; + + + if (req->nr_sectors + bio_sectors(bio) > max_sectors) { req->flags |= REQ_NOMERGE; if (req == q->last_merge) q->last_merge = NULL; @@ -2144,7 +2162,7 @@ int blk_rq_map_user(request_queue_t *q, struct request *rq, void __user *ubuf, struct bio *bio; int reading; - if (len > (q->max_sectors << 9)) + if (len > (q->max_hw_sectors << 9)) return -EINVAL; if (!len || !ubuf) return -EINVAL; @@ -2259,7 +2277,7 @@ int blk_rq_map_kern(request_queue_t *q, struct request *rq, void *kbuf, { struct bio *bio; - if (len > (q->max_sectors << 9)) + if (len > (q->max_hw_sectors << 9)) return -EINVAL; if (!len || !kbuf) return -EINVAL; diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 382dea7..4e390df 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -233,7 +233,7 @@ static int sg_io(struct file *file, request_queue_t *q, if (verify_command(file, cmd)) return -EPERM; - if (hdr->dxfer_len > (q->max_sectors << 9)) + if (hdr->dxfer_len > (q->max_hw_sectors << 9)) return -EIO; if (hdr->dxfer_len) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index a6d3baa..a6f2dc6 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -638,7 +638,7 @@ int dm_split_args(int *argc, char ***argvp, char *input) static void check_for_valid_limits(struct io_restrictions *rs) { if (!rs->max_sectors) - rs->max_sectors = MAX_SECTORS; + rs->max_sectors = SAFE_MAX_SECTORS; if (!rs->max_phys_segments) rs->max_phys_segments = MAX_PHYS_SEGMENTS; if (!rs->max_hw_segments) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 54a72f1..14ad2a7 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -462,6 +462,7 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, req = blk_get_request(sdev->request_queue, write, gfp); if (!req) goto free_sense; + req->flags |= REQ_BLOCK_PC | REQ_QUIET; if (use_sg) err = scsi_req_map_sg(req, buffer, use_sg, bufflen, gfp); @@ -477,7 +478,6 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd, req->sense_len = 0; req->timeout = timeout; req->retries = retries; - req->flags |= REQ_BLOCK_PC | REQ_QUIET; req->end_io_data = sioc; sioc->data = privdata; diff --git a/fs/bio.c b/fs/bio.c index 4d21ee3..38d3e80 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -313,7 +313,8 @@ int bio_get_nr_vecs(struct block_device *bdev) } static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page - *page, unsigned int len, unsigned int offset) + *page, unsigned int len, unsigned int offset, + unsigned short max_sectors) { int retried_segments = 0; struct bio_vec *bvec; @@ -327,7 +328,7 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page if (bio->bi_vcnt >= bio->bi_max_vecs) return 0; - if (((bio->bi_size + len) >> 9) > q->max_sectors) + if (((bio->bi_size + len) >> 9) > max_sectors) return 0; /* @@ -401,7 +402,7 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page int bio_add_pc_page(request_queue_t *q, struct bio *bio, struct page *page, unsigned int len, unsigned int offset) { - return __bio_add_page(q, bio, page, len, offset); + return __bio_add_page(q, bio, page, len, offset, q->max_hw_sectors); } /** @@ -420,8 +421,8 @@ int bio_add_pc_page(request_queue_t *q, struct bio *bio, struct page *page, int bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) { - return __bio_add_page(bdev_get_queue(bio->bi_bdev), bio, page, - len, offset); + struct request_queue *q = bdev_get_queue(bio->bi_bdev); + return __bio_add_page(q, bio, page, len, offset, q->max_sectors); } struct bio_map_data { @@ -533,7 +534,7 @@ struct bio *bio_copy_user(request_queue_t *q, unsigned long uaddr, break; } - if (__bio_add_page(q, bio, page, bytes, 0) < bytes) { + if (bio_add_pc_page(q, bio, page, bytes, 0) < bytes) { ret = -EINVAL; break; } @@ -647,7 +648,8 @@ static struct bio *__bio_map_user_iov(request_queue_t *q, /* * sorry... */ - if (__bio_add_page(q, bio, pages[j], bytes, offset) < bytes) + if (bio_add_pc_page(q, bio, pages[j], bytes, offset) < + bytes) break; len -= bytes; @@ -820,8 +822,8 @@ static struct bio *__bio_map_kern(request_queue_t *q, void *data, if (bytes > len) bytes = len; - if (__bio_add_page(q, bio, virt_to_page(data), bytes, - offset) < bytes) + if (bio_add_pc_page(q, bio, virt_to_page(data), bytes, + offset) < bytes) break; data += bytes; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 509e9a0..a18500d 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -702,7 +702,8 @@ extern int blkdev_issue_flush(struct block_device *, sector_t *); #define MAX_PHYS_SEGMENTS 128 #define MAX_HW_SEGMENTS 128 -#define MAX_SECTORS 255 +#define SAFE_MAX_SECTORS 255 +#define BLK_DEF_MAX_SECTORS 1024 #define MAX_SEGMENT_SIZE 65536 -- cgit v1.1 From 787926b1b2d21d42ca462dc736b77f1a4a30c503 Mon Sep 17 00:00:00 2001 From: Kai Makisara Date: Sun, 13 Nov 2005 10:04:44 +0200 Subject: [SCSI] Fix st oops with new scsi_execute infrastructure Patch from Kai minus last sg_segs clearing which was merged already. > > Was there a oops or lockup or any debug output you can send me? I will try > > some more large request tests with scsi_debug. You also have to compile your > > kernel with SCSI_MAX_PHYS_SEGMENTS == 255 to get larger requests now. > It was an oops in sgl_unmap_user_pages(). The reason is this: /* XXX: just for debug. Remove when PageReserved is removed */ BUG_ON(PageReserved(page)); I was using /dev/zero as input and it triggers this. When I used a file as input, this did not trigger. Should this BUG_ON be removed? In the same log I noticed that there was another ->sg_segs inconsistency. Also, the field ->last_SRpnt was not reset when scsi_execute_async() failed. This caused the error message "Async command already active" later and prevented proper close. While doing the changes, I noticed that the current code (since 2.6.0-test4) does not set the pages dirty when reading with direct i/o. All of these st problems (including the one I sent earlier) are fixed in the patch at the end of this message. These fixes should probably be included already in 2.6.15. After these fixes, the tape seems to operate as expected. Without other changes, the largest block size with sym53c896 SCSI adapter is 384 kB. The maximum number of sg segments is set to 96 and clustering is disabled in the driver. 96 x 4 kB = 384 kB. OK. I enabled clustering and set max_sectors to 10000 in the SCSI HBA driver. Now the block size limit is 5000 kB as expected. Signed-off-by: James Bottomley --- drivers/scsi/st.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 26e13dc..2096d13 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -511,9 +511,11 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd if (scsi_execute_async(STp->device, cmd, direction, &((STp->buffer)->sg[0]), bytes, (STp->buffer)->sg_segs, - timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) + timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) { /* could not allocate the buffer or request was too large */ (STp->buffer)->syscall_result = (-EBUSY); + (STp->buffer)->last_SRpnt = NULL; + } else if (do_wait) { wait_for_completion(waiting); SRpnt->waiting = NULL; @@ -1449,14 +1451,15 @@ static int setup_buffering(struct scsi_tape *STp, const char __user *buf, /* Can be called more than once after each setup_buffer() */ -static void release_buffering(struct scsi_tape *STp) +static void release_buffering(struct scsi_tape *STp, int is_read) { struct st_buffer *STbp; STbp = STp->buffer; if (STbp->do_dio) { - sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, 0); + sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, is_read); STbp->do_dio = 0; + STbp->sg_segs = 0; } } @@ -1729,7 +1732,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) out: if (SRpnt != NULL) st_release_request(SRpnt); - release_buffering(STp); + release_buffering(STp, 0); up(&STp->lock); return retval; @@ -1787,7 +1790,7 @@ static long read_tape(struct scsi_tape *STp, long count, SRpnt = *aSRpnt; SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE, STp->device->timeout, MAX_RETRIES, 1); - release_buffering(STp); + release_buffering(STp, 1); *aSRpnt = SRpnt; if (!SRpnt) return STbp->syscall_result; @@ -2058,7 +2061,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) SRpnt = NULL; } if (do_dio) { - release_buffering(STp); + release_buffering(STp, 1); STbp->buffer_bytes = 0; } up(&STp->lock); -- cgit v1.1 From 7b16318dea8d9840dac567a2ae8c50ecdea36aea Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 15 Dec 2005 20:17:02 -0600 Subject: Fix up SCSI mismerge I forgot to do a git-update-cache on the merged files ... --- drivers/scsi/scsi_lib.c | 33 +++++++++++++++++++++------------ drivers/scsi/sd.c | 2 +- drivers/scsi/sr.c | 2 +- drivers/scsi/st.c | 2 +- include/scsi/scsi_cmnd.h | 2 +- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 14ad2a7..a7f3f0c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1259,6 +1259,26 @@ static void scsi_generic_done(struct scsi_cmnd *cmd) scsi_io_completion(cmd, cmd->bufflen, 0); } +void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd) +{ + struct request *req = cmd->request; + + BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); + memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); + cmd->cmd_len = req->cmd_len; + if (!req->data_len) + cmd->sc_data_direction = DMA_NONE; + else if (rq_data_dir(req) == WRITE) + cmd->sc_data_direction = DMA_TO_DEVICE; + else + cmd->sc_data_direction = DMA_FROM_DEVICE; + + cmd->transfersize = req->data_len; + cmd->allowed = req->retries; + cmd->timeout_per_command = req->timeout; +} +EXPORT_SYMBOL_GPL(scsi_setup_blk_pc_cmnd); + static int scsi_prep_fn(struct request_queue *q, struct request *req) { struct scsi_device *sdev = q->queuedata; @@ -1394,18 +1414,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) goto kill; } } else { - memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); - cmd->cmd_len = req->cmd_len; - if (rq_data_dir(req) == WRITE) - cmd->sc_data_direction = DMA_TO_DEVICE; - else if (req->data_len) - cmd->sc_data_direction = DMA_FROM_DEVICE; - else - cmd->sc_data_direction = DMA_NONE; - - cmd->transfersize = req->data_len; - cmd->allowed = req->retries; - cmd->timeout_per_command = req->timeout; + scsi_setup_blk_pc_cmnd(cmd); cmd->done = scsi_generic_done; } } diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 9d893f0..3d3ad7d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -245,7 +245,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) * SG_IO from block layer already setup, just copy cdb basically */ if (blk_pc_request(rq)) { - scsi_setup_blk_pc_cmnd(SCpnt, SD_PASSTHROUGH_RETRIES); + scsi_setup_blk_pc_cmnd(SCpnt); if (rq->timeout) timeout = rq->timeout; diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 7e7398d..a4d9be7 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -320,7 +320,7 @@ static int sr_init_command(struct scsi_cmnd * SCpnt) * these are already setup, just copy cdb basically */ if (SCpnt->request->flags & REQ_BLOCK_PC) { - scsi_setup_blk_pc_cmnd(SCpnt, MAX_RETRIES); + scsi_setup_blk_pc_cmnd(SCpnt); if (SCpnt->timeout_per_command) timeout = SCpnt->timeout_per_command; diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 894ad53..c4aade8 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -4198,7 +4198,7 @@ static int st_init_command(struct scsi_cmnd *SCpnt) if (!(SCpnt->request->flags & REQ_BLOCK_PC)) return 0; - scsi_setup_blk_pc_cmnd(SCpnt, 0); + scsi_setup_blk_pc_cmnd(SCpnt); SCpnt->done = st_intr; return 1; } diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index 20da282..41cfc29 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -151,6 +151,6 @@ extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); extern void scsi_put_command(struct scsi_cmnd *); extern void scsi_io_completion(struct scsi_cmnd *, unsigned int, unsigned int); extern void scsi_finish_command(struct scsi_cmnd *cmd); -extern void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd, int retries); +extern void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd); #endif /* _SCSI_SCSI_CMND_H */ -- cgit v1.1 From 410ca5c7c6ed08bda165e8137bff26c3fbee5a1b Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 15 Dec 2005 16:22:01 -0500 Subject: [SCSI] Move scsi_print_msg to SPI class scsi_print_msg() is an SPI-specific concept. This patch moves it from constants.c to scsi_transport_spi.c and updates the Kconfig to link in the SPI class for the drivers which use scsi_print_msg(). Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/Kconfig | 13 +++++ drivers/scsi/arm/Kconfig | 1 + drivers/scsi/constants.c | 108 ------------------------------------- drivers/scsi/scsi_transport_spi.c | 109 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 108 deletions(-) diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 20dd85a..4c42065 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -336,6 +336,7 @@ config SCSI_ACARD config SCSI_AHA152X tristate "Adaptec AHA152X/2825 support" depends on ISA && SCSI && !64BIT + select SCSI_SPI_ATTRS ---help--- This is a driver for the AHA-1510, AHA-1520, AHA-1522, and AHA-2825 SCSI host adapters. It also works for the AVA-1505, but the IRQ etc. @@ -623,6 +624,7 @@ config SCSI_OMIT_FLASHPOINT config SCSI_DMX3191D tristate "DMX3191D SCSI support" depends on PCI && SCSI + select SCSI_SPI_ATTRS help This is support for Domex DMX3191D SCSI Host Adapters. @@ -632,6 +634,7 @@ config SCSI_DMX3191D config SCSI_DTC3280 tristate "DTC3180/3280 SCSI support" depends on ISA && SCSI + select SCSI_SPI_ATTRS help This is support for DTC 3180/3280 SCSI Host Adapters. Please read the SCSI-HOWTO, available from @@ -752,6 +755,7 @@ config SCSI_GDTH config SCSI_GENERIC_NCR5380 tristate "Generic NCR5380/53c400 SCSI PIO support" depends on ISA && SCSI + select SCSI_SPI_ATTRS ---help--- This is a driver for the old NCR 53c80 series of SCSI controllers on boards using PIO. Most boards such as the Trantor T130 fit this @@ -771,6 +775,7 @@ config SCSI_GENERIC_NCR5380 config SCSI_GENERIC_NCR5380_MMIO tristate "Generic NCR5380/53c400 SCSI MMIO support" depends on ISA && SCSI + select SCSI_SPI_ATTRS ---help--- This is a driver for the old NCR 53c80 series of SCSI controllers on boards using memory mapped I/O. @@ -1254,6 +1259,7 @@ config SCSI_MCA_53C9X config SCSI_PAS16 tristate "PAS16 SCSI support" depends on ISA && SCSI + select SCSI_SPI_ATTRS ---help--- This is support for a SCSI host adapter. It is explained in section 3.10 of the SCSI-HOWTO, available from @@ -1423,6 +1429,7 @@ config SCSI_DC390T config SCSI_T128 tristate "Trantor T128/T128F/T228 SCSI support" depends on ISA && SCSI + select SCSI_SPI_ATTRS ---help--- This is support for a SCSI host adapter. It is explained in section 3.11 of the SCSI-HOWTO, available from @@ -1681,6 +1688,7 @@ config OKTAGON_SCSI config ATARI_SCSI tristate "Atari native SCSI support" depends on ATARI && SCSI && BROKEN + select SCSI_SPI_ATTRS ---help--- If you have an Atari with built-in NCR5380 SCSI controller (TT, Falcon, ...) say Y to get it supported. Of course also, if you have @@ -1722,6 +1730,7 @@ config TT_DMA_EMUL config MAC_SCSI bool "Macintosh NCR5380 SCSI" depends on MAC && SCSI=y + select SCSI_SPI_ATTRS help This is the NCR 5380 SCSI controller included on most of the 68030 based Macintoshes. If you have one of these say Y and read the @@ -1743,6 +1752,7 @@ config SCSI_MAC_ESP config MVME147_SCSI bool "WD33C93 SCSI driver for MVME147" depends on MVME147 && SCSI=y + select SCSI_SPI_ATTRS help Support for the on-board SCSI controller on the Motorola MVME147 single-board computer. @@ -1750,6 +1760,7 @@ config MVME147_SCSI config MVME16x_SCSI bool "NCR53C710 SCSI driver for MVME16x" depends on MVME16x && SCSI && BROKEN + select SCSI_SPI_ATTRS help The Motorola MVME162, 166, 167, 172 and 177 boards use the NCR53C710 SCSI controller chip. Almost everyone using one of these boards @@ -1758,6 +1769,7 @@ config MVME16x_SCSI config BVME6000_SCSI bool "NCR53C710 SCSI driver for BVME6000" depends on BVME6000 && SCSI && BROKEN + select SCSI_SPI_ATTRS help The BVME4000 and BVME6000 boards from BVM Ltd use the NCR53C710 SCSI controller chip. Almost everyone using one of these boards @@ -1774,6 +1786,7 @@ config SCSI_NCR53C7xx_FAST config SUN3_SCSI tristate "Sun3 NCR5380 SCSI" depends on SUN3 && SCSI && BROKEN + select SCSI_SPI_ATTRS help This option will enable support for the OBIO (onboard io) NCR5380 SCSI controller found in the Sun 3/50 and 3/60, as well as for diff --git a/drivers/scsi/arm/Kconfig b/drivers/scsi/arm/Kconfig index 13f2304..06d7601 100644 --- a/drivers/scsi/arm/Kconfig +++ b/drivers/scsi/arm/Kconfig @@ -4,6 +4,7 @@ config SCSI_ACORNSCSI_3 tristate "Acorn SCSI card (aka30) support" depends on ARCH_ACORN && SCSI && BROKEN + select SCSI_SPI_ATTRS help This enables support for the Acorn SCSI card (aka30). If you have an Acorn system with one of these, say Y. If unsure, say N. diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index a972c1e..30a3353 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c @@ -1278,114 +1278,6 @@ void scsi_print_req_sense(const char *devclass, struct scsi_request *sreq) } EXPORT_SYMBOL(scsi_print_req_sense); -#ifdef CONFIG_SCSI_CONSTANTS -static const char * const one_byte_msgs[] = { -/* 0x00 */ "Command Complete", NULL, "Save Pointers", -/* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error", -/* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error", -/* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag", -/* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", -/* 0x0f */ "Initiate Recovery", "Release Recovery" -}; -#define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *)) - -static const char * const two_byte_msgs[] = { -/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag" -/* 0x23 */ "Ignore Wide Residue" -}; -#define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) - -static const char * const extended_msgs[] = { -/* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", -/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" -}; -#define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) - - -int scsi_print_msg (const unsigned char *msg) -{ - int len = 0, i; - if (msg[0] == EXTENDED_MESSAGE) { - len = 3 + msg[1]; - if (msg[2] < NO_EXTENDED_MSGS) - printk ("%s ", extended_msgs[msg[2]]); - else - printk ("Extended Message, reserved code (0x%02x) ", - (int) msg[2]); - switch (msg[2]) { - case EXTENDED_MODIFY_DATA_POINTER: - printk("pointer = %d", (int) (msg[3] << 24) | - (msg[4] << 16) | (msg[5] << 8) | msg[6]); - break; - case EXTENDED_SDTR: - printk("period = %d ns, offset = %d", - (int) msg[3] * 4, (int) msg[4]); - break; - case EXTENDED_WDTR: - printk("width = 2^%d bytes", msg[3]); - break; - default: - for (i = 2; i < len; ++i) - printk("%02x ", msg[i]); - } - /* Identify */ - } else if (msg[0] & 0x80) { - printk("Identify disconnect %sallowed %s %d ", - (msg[0] & 0x40) ? "" : "not ", - (msg[0] & 0x20) ? "target routine" : "lun", - msg[0] & 0x7); - len = 1; - /* Normal One byte */ - } else if (msg[0] < 0x1f) { - if (msg[0] < NO_ONE_BYTE_MSGS) - printk(one_byte_msgs[msg[0]]); - else - printk("reserved (%02x) ", msg[0]); - len = 1; - /* Two byte */ - } else if (msg[0] <= 0x2f) { - if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS) - printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], - msg[1]); - else - printk("reserved two byte (%02x %02x) ", - msg[0], msg[1]); - len = 2; - } else - printk("reserved"); - return len; -} -EXPORT_SYMBOL(scsi_print_msg); - -#else /* ifndef CONFIG_SCSI_CONSTANTS */ - -int scsi_print_msg (const unsigned char *msg) -{ - int len = 0, i; - - if (msg[0] == EXTENDED_MESSAGE) { - len = 3 + msg[1]; - for (i = 0; i < len; ++i) - printk("%02x ", msg[i]); - /* Identify */ - } else if (msg[0] & 0x80) { - printk("%02x ", msg[0]); - len = 1; - /* Normal One byte */ - } else if (msg[0] < 0x1f) { - printk("%02x ", msg[0]); - len = 1; - /* Two byte */ - } else if (msg[0] <= 0x2f) { - printk("%02x %02x", msg[0], msg[1]); - len = 2; - } else - printk("%02x ", msg[0]); - return len; -} -EXPORT_SYMBOL(scsi_print_msg); -#endif /* ! CONFIG_SCSI_CONSTANTS */ - void scsi_print_command(struct scsi_cmnd *cmd) { /* Assume appended output (i.e. not at start of line) */ diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 4002a98..00a73fc 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -18,6 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include @@ -1047,6 +1048,114 @@ void spi_display_xfer_agreement(struct scsi_target *starget) } EXPORT_SYMBOL(spi_display_xfer_agreement); +#ifdef CONFIG_SCSI_CONSTANTS +static const char * const one_byte_msgs[] = { +/* 0x00 */ "Command Complete", NULL, "Save Pointers", +/* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error", +/* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error", +/* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag", +/* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", +/* 0x0f */ "Initiate Recovery", "Release Recovery" +}; +#define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *)) + +static const char * const two_byte_msgs[] = { +/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag" +/* 0x23 */ "Ignore Wide Residue" +}; +#define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) + +static const char * const extended_msgs[] = { +/* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", +/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" +}; +#define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) + + +int scsi_print_msg (const unsigned char *msg) +{ + int len = 0, i; + if (msg[0] == EXTENDED_MESSAGE) { + len = 3 + msg[1]; + if (msg[2] < NO_EXTENDED_MSGS) + printk ("%s ", extended_msgs[msg[2]]); + else + printk ("Extended Message, reserved code (0x%02x) ", + (int) msg[2]); + switch (msg[2]) { + case EXTENDED_MODIFY_DATA_POINTER: + printk("pointer = %d", (int) (msg[3] << 24) | + (msg[4] << 16) | (msg[5] << 8) | msg[6]); + break; + case EXTENDED_SDTR: + printk("period = %d ns, offset = %d", + (int) msg[3] * 4, (int) msg[4]); + break; + case EXTENDED_WDTR: + printk("width = 2^%d bytes", msg[3]); + break; + default: + for (i = 2; i < len; ++i) + printk("%02x ", msg[i]); + } + /* Identify */ + } else if (msg[0] & 0x80) { + printk("Identify disconnect %sallowed %s %d ", + (msg[0] & 0x40) ? "" : "not ", + (msg[0] & 0x20) ? "target routine" : "lun", + msg[0] & 0x7); + len = 1; + /* Normal One byte */ + } else if (msg[0] < 0x1f) { + if (msg[0] < NO_ONE_BYTE_MSGS) + printk(one_byte_msgs[msg[0]]); + else + printk("reserved (%02x) ", msg[0]); + len = 1; + /* Two byte */ + } else if (msg[0] <= 0x2f) { + if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS) + printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], + msg[1]); + else + printk("reserved two byte (%02x %02x) ", + msg[0], msg[1]); + len = 2; + } else + printk("reserved"); + return len; +} +EXPORT_SYMBOL(scsi_print_msg); + +#else /* ifndef CONFIG_SCSI_CONSTANTS */ + +int scsi_print_msg (const unsigned char *msg) +{ + int len = 0, i; + + if (msg[0] == EXTENDED_MESSAGE) { + len = 3 + msg[1]; + for (i = 0; i < len; ++i) + printk("%02x ", msg[i]); + /* Identify */ + } else if (msg[0] & 0x80) { + printk("%02x ", msg[0]); + len = 1; + /* Normal One byte */ + } else if (msg[0] < 0x1f) { + printk("%02x ", msg[0]); + len = 1; + /* Two byte */ + } else if (msg[0] <= 0x2f) { + printk("%02x %02x", msg[0], msg[1]); + len = 2; + } else + printk("%02x ", msg[0]); + return len; +} +EXPORT_SYMBOL(scsi_print_msg); +#endif /* ! CONFIG_SCSI_CONSTANTS */ + #define SETUP_ATTRIBUTE(field) \ i->private_attrs[count] = class_device_attr_##field; \ if (!i->f->set_##field) { \ -- cgit v1.1 From 1abfd370134553f3b47e3e40a0526e05001409c2 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 15 Dec 2005 16:22:01 -0500 Subject: [SCSI] Rename scsi_print_msg to spi_print_msg Rename scsi_print_msg to spi_print_msg and move its prototype from scsi_dbg.h to scsi_transport_spi.h Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/53c700.c | 6 +++--- drivers/scsi/53c7xx.c | 7 ++++--- drivers/scsi/NCR5380.c | 7 ++++--- drivers/scsi/aha152x.c | 7 ++++--- drivers/scsi/arm/acornscsi.c | 7 ++++--- drivers/scsi/atari_NCR5380.c | 7 ++++--- drivers/scsi/scsi_transport_spi.c | 8 ++++---- drivers/scsi/sun3_NCR5380.c | 7 ++++--- drivers/scsi/sym53c8xx_2/sym_hipd.c | 4 ++-- include/scsi/scsi_dbg.h | 1 - include/scsi/scsi_transport_spi.h | 1 + 11 files changed, 34 insertions(+), 28 deletions(-) diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index e7ad269..4ce7438 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -857,7 +857,7 @@ process_extended_message(struct Scsi_Host *host, printk(KERN_INFO "scsi%d (%d:%d): Unexpected message %s: ", host->host_no, pun, lun, NCR_700_phase[(dsps & 0xf00) >> 8]); - scsi_print_msg(hostdata->msgin); + spi_print_msg(hostdata->msgin); printk("\n"); /* just reject it */ hostdata->msgout[0] = A_REJECT_MSG; @@ -887,7 +887,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata #ifdef NCR_700_DEBUG printk("scsi%d (%d:%d): message %s: ", host->host_no, pun, lun, NCR_700_phase[(dsps & 0xf00) >> 8]); - scsi_print_msg(hostdata->msgin); + spi_print_msg(hostdata->msgin); printk("\n"); #endif @@ -939,7 +939,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata host->host_no, pun, lun, NCR_700_phase[(dsps & 0xf00) >> 8]); - scsi_print_msg(hostdata->msgin); + spi_print_msg(hostdata->msgin); printk("\n"); /* just reject it */ hostdata->msgout[0] = A_REJECT_MSG; diff --git a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c index 9cb5dd4..7894b8e 100644 --- a/drivers/scsi/53c7xx.c +++ b/drivers/scsi/53c7xx.c @@ -282,6 +282,7 @@ #include "scsi.h" #include #include +#include #include "53c7xx.h" #include #include @@ -1724,7 +1725,7 @@ NCR53c7xx_run_tests (struct Scsi_Host *host) { printk ("scsi%d : status ", host->host_no); scsi_print_status (status); printk ("\nscsi%d : message ", host->host_no); - scsi_print_msg (&msg); + spi_print_msg(&msg); printk ("\n"); } else if (hostdata->test_completed == 3) { printk("scsi%d : test 2 no connection with target %d\n", @@ -2313,7 +2314,7 @@ NCR53c7x0_dstat_sir_intr (struct Scsi_Host *host, struct printk ("scsi%d : received message", host->host_no); if (c) printk (" from target %d lun %d ", c->device->id, c->device->lun); - scsi_print_msg ((unsigned char *) hostdata->msg_buf); + spi_print_msg((unsigned char *) hostdata->msg_buf); printk("\n"); } @@ -5540,7 +5541,7 @@ print_dsa (struct Scsi_Host *host, u32 *dsa, const char *prefix) { i > 0 && !check_address ((unsigned long) ptr, 1); ptr += len, i -= len) { printk(" "); - len = scsi_print_msg (ptr); + len = spi_print_msg(ptr); printk("\n"); if (!len) break; diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index cba9655..9f0ddbe 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -87,6 +87,7 @@ * the high level code. */ #include +#include #ifndef NDEBUG #define NDEBUG 0 @@ -2377,7 +2378,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { * 3..length+1 arguments * * Start the extended message buffer with the EXTENDED_MESSAGE - * byte, since scsi_print_msg() wants the whole thing. + * byte, since spi_print_msg() wants the whole thing. */ extended_msg[0] = EXTENDED_MESSAGE; /* Accept first byte by clearing ACK */ @@ -2424,7 +2425,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { default: if (!tmp) { printk("scsi%d: rejecting message ", instance->host_no); - scsi_print_msg(extended_msg); + spi_print_msg(extended_msg); printk("\n"); } else if (tmp != EXTENDED_MESSAGE) scmd_printk(KERN_INFO, cmd, @@ -2560,7 +2561,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) { if (!(msg[0] & 0x80)) { printk(KERN_ERR "scsi%d : expecting IDENTIFY message, got ", instance->host_no); - scsi_print_msg(msg); + spi_print_msg(msg); abort = 1; } else { /* Accept message by clearing ACK */ diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 9df23b6..cb2ee25 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -259,6 +259,7 @@ #include "scsi.h" #include #include +#include #include "aha152x.h" @@ -1845,7 +1846,7 @@ static void msgi_run(struct Scsi_Host *shpnt) #if defined(AHA152X_DEBUG) if (HOSTDATA(shpnt)->debug & debug_msgi) { printk(INFO_LEAD "inbound message %02x ", CMDINFO(CURRENT_SC), MSGI(0)); - scsi_print_msg(&MSGI(0)); + spi_print_msg(&MSGI(0)); printk("\n"); } #endif @@ -1933,7 +1934,7 @@ static void msgi_run(struct Scsi_Host *shpnt) break; printk(INFO_LEAD, CMDINFO(CURRENT_SC)); - scsi_print_msg(&MSGI(0)); + spi_print_msg(&MSGI(0)); printk("\n"); ticks = (MSGI(3) * 4 + 49) / 50; @@ -2031,7 +2032,7 @@ static void msgo_init(struct Scsi_Host *shpnt) int i; printk(DEBUG_LEAD "messages( ", CMDINFO(CURRENT_SC)); - for (i=0; i #include +#include #include "acornscsi.h" #include "msgqueue.h" #include "scsi.h" @@ -1370,7 +1371,7 @@ void acornscsi_sendmessage(AS_Host *host) host->scsi.last_message = msg->msg[0]; #if (DEBUG & DEBUG_MESSAGES) - scsi_print_msg(msg->msg); + spi_print_msg(msg->msg); #endif break; @@ -1392,7 +1393,7 @@ void acornscsi_sendmessage(AS_Host *host) while ((msg = msgqueue_getmsg(&host->scsi.msgs, msgnr++)) != NULL) { unsigned int i; #if (DEBUG & DEBUG_MESSAGES) - scsi_print_msg(msg); + spi_print_msg(msg); #endif i = 0; if (acornscsi_write_pio(host, msg->msg, &i, msg->length, 1000000)) @@ -1488,7 +1489,7 @@ void acornscsi_message(AS_Host *host) #if (DEBUG & DEBUG_MESSAGES) printk("scsi%d.%c: message in: ", host->host->host_no, acornscsi_target(host)); - scsi_print_msg(message); + spi_print_msg(message); printk("\n"); #endif diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 2ae31ce..57295bce 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -74,6 +74,7 @@ * the high level code. */ #include +#include #if (NDEBUG & NDEBUG_LISTS) #define LIST(x,y) \ @@ -2355,7 +2356,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance) * 3..length+1 arguments * * Start the extended message buffer with the EXTENDED_MESSAGE - * byte, since scsi_print_msg() wants the whole thing. + * byte, since spi_print_msg() wants the whole thing. */ extended_msg[0] = EXTENDED_MESSAGE; /* Accept first byte by clearing ACK */ @@ -2408,7 +2409,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance) default: if (!tmp) { printk(KERN_DEBUG "scsi%d: rejecting message ", HOSTNO); - scsi_print_msg (extended_msg); + spi_print_msg(extended_msg); printk("\n"); } else if (tmp != EXTENDED_MESSAGE) printk(KERN_DEBUG "scsi%d: rejecting unknown " @@ -2541,7 +2542,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance) if (!(msg[0] & 0x80)) { printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO); - scsi_print_msg(msg); + spi_print_msg(msg); do_abort(instance); return; } diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 00a73fc..59fb69b 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -1072,7 +1072,7 @@ static const char * const extended_msgs[] = { #define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) -int scsi_print_msg (const unsigned char *msg) +int spi_print_msg(const unsigned char *msg) { int len = 0, i; if (msg[0] == EXTENDED_MESSAGE) { @@ -1125,11 +1125,11 @@ int scsi_print_msg (const unsigned char *msg) printk("reserved"); return len; } -EXPORT_SYMBOL(scsi_print_msg); +EXPORT_SYMBOL(spi_print_msg); #else /* ifndef CONFIG_SCSI_CONSTANTS */ -int scsi_print_msg (const unsigned char *msg) +int spi_print_msg(const unsigned char *msg) { int len = 0, i; @@ -1153,7 +1153,7 @@ int scsi_print_msg (const unsigned char *msg) printk("%02x ", msg[0]); return len; } -EXPORT_SYMBOL(scsi_print_msg); +EXPORT_SYMBOL(spi_print_msg); #endif /* ! CONFIG_SCSI_CONSTANTS */ #define SETUP_ATTRIBUTE(field) \ diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index c041bfd..25cced9 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -70,6 +70,7 @@ * */ #include +#include /* * Further development / testing that should be done : @@ -2378,7 +2379,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance) * 3..length+1 arguments * * Start the extended message buffer with the EXTENDED_MESSAGE - * byte, since scsi_print_msg() wants the whole thing. + * byte, since spi_print_msg() wants the whole thing. */ extended_msg[0] = EXTENDED_MESSAGE; /* Accept first byte by clearing ACK */ @@ -2431,7 +2432,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance) default: if (!tmp) { printk(KERN_DEBUG "scsi%d: rejecting message ", HOSTNO); - scsi_print_msg (extended_msg); + spi_print_msg(extended_msg); printk("\n"); } else if (tmp != EXTENDED_MESSAGE) printk(KERN_DEBUG "scsi%d: rejecting unknown " @@ -2566,7 +2567,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance) if (!(msg[0] & 0x80)) { printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO); - scsi_print_msg(msg); + spi_print_msg(msg); do_abort(instance); return; } diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c index 1010e71..8260f04 100644 --- a/drivers/scsi/sym53c8xx_2/sym_hipd.c +++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c @@ -75,7 +75,7 @@ static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg) { sym_print_addr(cp->cmd, "%s: ", label); - scsi_print_msg(msg); + spi_print_msg(msg); printf("\n"); } @@ -84,7 +84,7 @@ static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_ch struct sym_tcb *tp = &np->target[target]; dev_info(&tp->starget->dev, "%s: ", label); - scsi_print_msg(msg); + spi_print_msg(msg); printf("\n"); } diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h index b090a11..4d69dee 100644 --- a/include/scsi/scsi_dbg.h +++ b/include/scsi/scsi_dbg.h @@ -16,7 +16,6 @@ extern void __scsi_print_sense(const char *name, extern void scsi_print_driverbyte(int); extern void scsi_print_hostbyte(int); extern void scsi_print_status(unsigned char); -extern int scsi_print_msg(const unsigned char *); extern const char *scsi_sense_key_string(unsigned char); extern const char *scsi_extd_sense_format(unsigned char, unsigned char); diff --git a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h index 5c9b2e5..54a8961 100644 --- a/include/scsi/scsi_transport_spi.h +++ b/include/scsi/scsi_transport_spi.h @@ -146,5 +146,6 @@ void spi_release_transport(struct scsi_transport_template *); void spi_schedule_dv_device(struct scsi_device *); void spi_dv_device(struct scsi_device *); void spi_display_xfer_agreement(struct scsi_target *); +int spi_print_msg(const unsigned char *); #endif /* SCSI_TRANSPORT_SPI_H */ -- cgit v1.1 From 479721538957d514df6dcb29f66e5edd26393bb1 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 15 Dec 2005 16:22:01 -0500 Subject: [SCSI] Fix printing of two-byte messages A missing comma meant that "Ordered Queue Tag" and "Ignore Wide Residue" were being concatenated together. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/scsi_transport_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 59fb69b..8cc5dff 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -1060,7 +1060,7 @@ static const char * const one_byte_msgs[] = { #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *)) static const char * const two_byte_msgs[] = { -/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag" +/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag", /* 0x23 */ "Ignore Wide Residue" }; #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) -- cgit v1.1 From b32aaffcdc694650d299a59501c5b3e267fca343 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 15 Dec 2005 16:22:01 -0500 Subject: [SCSI] Use ARRAY_SIZE in spi_print_msg Replace the custom NO_*_MSGS definitions with uses of ARRAY_SIZE. This fixes a bug in the definition of NO_EXTENDED_MSGS. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/scsi_transport_spi.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 8cc5dff..380e167 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -1057,19 +1057,16 @@ static const char * const one_byte_msgs[] = { /* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", /* 0x0f */ "Initiate Recovery", "Release Recovery" }; -#define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *)) static const char * const two_byte_msgs[] = { /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag", /* 0x23 */ "Ignore Wide Residue" }; -#define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) static const char * const extended_msgs[] = { /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" }; -#define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) int spi_print_msg(const unsigned char *msg) @@ -1077,7 +1074,7 @@ int spi_print_msg(const unsigned char *msg) int len = 0, i; if (msg[0] == EXTENDED_MESSAGE) { len = 3 + msg[1]; - if (msg[2] < NO_EXTENDED_MSGS) + if (msg[2] < ARRAY_SIZE(extended_msgs)) printk ("%s ", extended_msgs[msg[2]]); else printk ("Extended Message, reserved code (0x%02x) ", @@ -1107,14 +1104,14 @@ int spi_print_msg(const unsigned char *msg) len = 1; /* Normal One byte */ } else if (msg[0] < 0x1f) { - if (msg[0] < NO_ONE_BYTE_MSGS) + if (msg[0] < ARRAY_SIZE(one_byte_msgs)) printk(one_byte_msgs[msg[0]]); else printk("reserved (%02x) ", msg[0]); len = 1; /* Two byte */ } else if (msg[0] <= 0x2f) { - if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS) + if ((msg[0] - 0x20) < ARRAY_SIZE(two_byte_msgs)) printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], msg[1]); else -- cgit v1.1 From ef72582e7a02e1069c6e6bf5eecf6f388b1467c6 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 15 Dec 2005 16:22:01 -0500 Subject: [SCSI] Add PPR support to spi_print_msg Introduce a new helper, print_nego() to handle SDTR/WDTR/PPR. Split out the guts of show_spi_transport_period_helper() into period_to_str() and use it in print_nego to get the period factor conversion right. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/scsi_transport_spi.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 380e167..46da6fe 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -379,9 +379,7 @@ static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate); /* Translate the period into ns according to the current spec * for SDTR/PPR messages */ -static ssize_t -show_spi_transport_period_helper(struct class_device *cdev, char *buf, - int period) +static int period_to_str(char *buf, int period) { int len, picosec; @@ -399,6 +397,14 @@ show_spi_transport_period_helper(struct class_device *cdev, char *buf, len = sprint_frac(buf, picosec, 1000); } + return len; +} + +static ssize_t +show_spi_transport_period_helper(struct class_device *cdev, char *buf, + int period) +{ + int len = period_to_str(buf, period); buf[len++] = '\n'; buf[len] = '\0'; return len; @@ -1065,9 +1071,23 @@ static const char * const two_byte_msgs[] = { static const char * const extended_msgs[] = { /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request", -/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request" +/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request", +/* 0x04 */ "Parallel Protocol Request" }; +void print_nego(const unsigned char *msg, int per, int off, int width) +{ + if (per) { + char buf[20]; + period_to_str(buf, msg[per]); + printk("period = %s ns ", buf); + } + + if (off) + printk("offset = %d ", msg[off]); + if (width) + printk("width = %d ", 8 << msg[width]); +} int spi_print_msg(const unsigned char *msg) { @@ -1085,11 +1105,13 @@ int spi_print_msg(const unsigned char *msg) (msg[4] << 16) | (msg[5] << 8) | msg[6]); break; case EXTENDED_SDTR: - printk("period = %d ns, offset = %d", - (int) msg[3] * 4, (int) msg[4]); + print_nego(msg, 3, 4, 0); break; case EXTENDED_WDTR: - printk("width = 2^%d bytes", msg[3]); + print_nego(msg, 0, 0, 3); + break; + case EXTENDED_PPR: + print_nego(msg, 3, 5, 6); break; default: for (i = 2; i < len; ++i) -- cgit v1.1 From 8f23d475581adac949315e3339421e12554932c9 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Tue, 29 Nov 2005 16:24:52 -0600 Subject: [SCSI] 53c700: update endian processing macros This update now allows this driver to be used on big endian bus machines that aren't parisc. To do that, the driver must set a CONFIG_53C700_BE_BUS in Kconfig to compile the right macro versions. Signed-off-by: James Bottomley --- drivers/scsi/53c700.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h index 362d784..a8c83bb 100644 --- a/drivers/scsi/53c700.h +++ b/drivers/scsi/53c700.h @@ -238,21 +238,23 @@ struct NCR_700_Host_Parameters { #ifdef CONFIG_53C700_LE_ON_BE #define bE (hostdata->force_le_on_be ? 0 : 3) #define bSWAP (hostdata->force_le_on_be) -/* This is terrible, but there's no raw version of ioread32. That means - * that on a be board we swap twice (once in ioread32 and once again to - * get the value correct) */ -#define bS_to_io(x) ((hostdata->force_le_on_be) ? (x) : cpu_to_le32(x)) +#define bEBus (!hostdata->force_le_on_be) #elif defined(__BIG_ENDIAN) #define bE 3 #define bSWAP 0 -#define bS_to_io(x) (x) #elif defined(__LITTLE_ENDIAN) #define bE 0 #define bSWAP 0 -#define bS_to_io(x) (x) #else #error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined, did you include byteorder.h?" #endif +#ifndef bEBus +#ifdef CONFIG_53C700_BE_BUS +#define bEBus 1 +#else +#define bEBus 0 +#endif +#endif #define bS_to_cpu(x) (bSWAP ? le32_to_cpu(x) : (x)) #define bS_to_host(x) (bSWAP ? cpu_to_le32(x) : (x)) @@ -466,14 +468,15 @@ NCR_700_readl(struct Scsi_Host *host, __u32 reg) { const struct NCR_700_Host_Parameters *hostdata = (struct NCR_700_Host_Parameters *)host->hostdata[0]; - __u32 value = ioread32(hostdata->base + reg); + __u32 value = bEBus ? ioread32be(hostdata->base + reg) : + ioread32(hostdata->base + reg); #if 1 /* sanity check the register */ if((reg & 0x3) != 0) BUG(); #endif - return bS_to_io(value); + return value; } static inline void @@ -497,7 +500,8 @@ NCR_700_writel(__u32 value, struct Scsi_Host *host, __u32 reg) BUG(); #endif - iowrite32(bS_to_io(value), hostdata->base + reg); + bEBus ? iowrite32be(value, hostdata->base + reg): + iowrite32(value, hostdata->base + reg); } #endif -- cgit v1.1 From cd453c6353ea30171d966fd1dd87c37b05bccee1 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 16 Dec 2005 12:50:53 -0500 Subject: [SCSI] Use spi_print_msg in ncr53c8xx driver The ncr53c8xx driver had its own loop to print scsi messages. Use the SPI one instead. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/ncr53c8xx.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 2434709..8e1c77c 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -2971,21 +2971,10 @@ struct host_data { static void ncr_print_msg(struct ccb *cp, char *label, u_char *msg) { - int i; PRINT_ADDR(cp->cmd, "%s: ", label); - printk ("%x",*msg); - if (*msg == M_EXTENDED) { - for (i = 1; i < 8; i++) { - if (i - 1 > msg[1]) - break; - printk ("-%x",msg[i]); - } - } else if ((*msg & 0xf0) == 0x20) { - printk ("-%x",msg[1]); - } - - printk(".\n"); + spi_print_msg(msg); + printk("\n"); } /*========================================================== -- cgit v1.1 From 19c65091c133a98b20d867c94b1b1380a79e4b81 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 16 Dec 2005 12:50:53 -0500 Subject: [SCSI] Merge sym53c8xx_comm.h and sym53c8xx_defs.h into ncr driver When the sym1 driver was in the tree, it used to share various parts of its infrastructure with the ncr driver. Now it's gone, these files are just an annoyance, so merge sym53c8xx_comm.h into ncr53c8xx.c and merge sym53c8xx_defs.h into ncr53c8xx.h. Signed-off-by: Matthew Wilcox Signed-off-by: James Bottomley --- drivers/scsi/ncr53c8xx.c | 734 ++++++++++++++++++++++- drivers/scsi/ncr53c8xx.h | 1263 ++++++++++++++++++++++++++++++++++++++- drivers/scsi/sym53c8xx_comm.h | 792 ------------------------- drivers/scsi/sym53c8xx_defs.h | 1320 ----------------------------------------- 4 files changed, 1995 insertions(+), 2114 deletions(-) delete mode 100644 drivers/scsi/sym53c8xx_comm.h delete mode 100644 drivers/scsi/sym53c8xx_defs.h diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index 8e1c77c..3235070 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c @@ -131,7 +131,739 @@ #define NAME53C "ncr53c" #define NAME53C8XX "ncr53c8xx" -#include "sym53c8xx_comm.h" + +/*========================================================== +** +** Debugging tags +** +**========================================================== +*/ + +#define DEBUG_ALLOC (0x0001) +#define DEBUG_PHASE (0x0002) +#define DEBUG_QUEUE (0x0008) +#define DEBUG_RESULT (0x0010) +#define DEBUG_POINTER (0x0020) +#define DEBUG_SCRIPT (0x0040) +#define DEBUG_TINY (0x0080) +#define DEBUG_TIMING (0x0100) +#define DEBUG_NEGO (0x0200) +#define DEBUG_TAGS (0x0400) +#define DEBUG_SCATTER (0x0800) +#define DEBUG_IC (0x1000) + +/* +** Enable/Disable debug messages. +** Can be changed at runtime too. +*/ + +#ifdef SCSI_NCR_DEBUG_INFO_SUPPORT +static int ncr_debug = SCSI_NCR_DEBUG_FLAGS; + #define DEBUG_FLAGS ncr_debug +#else + #define DEBUG_FLAGS SCSI_NCR_DEBUG_FLAGS +#endif + +static inline struct list_head *ncr_list_pop(struct list_head *head) +{ + if (!list_empty(head)) { + struct list_head *elem = head->next; + + list_del(elem); + return elem; + } + + return NULL; +} + +/*========================================================== +** +** Simple power of two buddy-like allocator. +** +** This simple code is not intended to be fast, but to +** provide power of 2 aligned memory allocations. +** Since the SCRIPTS processor only supplies 8 bit +** arithmetic, this allocator allows simple and fast +** address calculations from the SCRIPTS code. +** In addition, cache line alignment is guaranteed for +** power of 2 cache line size. +** Enhanced in linux-2.3.44 to provide a memory pool +** per pcidev to support dynamic dma mapping. (I would +** have preferred a real bus astraction, btw). +** +**========================================================== +*/ + +#define MEMO_SHIFT 4 /* 16 bytes minimum memory chunk */ +#if PAGE_SIZE >= 8192 +#define MEMO_PAGE_ORDER 0 /* 1 PAGE maximum */ +#else +#define MEMO_PAGE_ORDER 1 /* 2 PAGES maximum */ +#endif +#define MEMO_FREE_UNUSED /* Free unused pages immediately */ +#define MEMO_WARN 1 +#define MEMO_GFP_FLAGS GFP_ATOMIC +#define MEMO_CLUSTER_SHIFT (PAGE_SHIFT+MEMO_PAGE_ORDER) +#define MEMO_CLUSTER_SIZE (1UL << MEMO_CLUSTER_SHIFT) +#define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1) + +typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */ +typedef struct device *m_bush_t; /* Something that addresses DMAable */ + +typedef struct m_link { /* Link between free memory chunks */ + struct m_link *next; +} m_link_s; + +typedef struct m_vtob { /* Virtual to Bus address translation */ + struct m_vtob *next; + m_addr_t vaddr; + m_addr_t baddr; +} m_vtob_s; +#define VTOB_HASH_SHIFT 5 +#define VTOB_HASH_SIZE (1UL << VTOB_HASH_SHIFT) +#define VTOB_HASH_MASK (VTOB_HASH_SIZE-1) +#define VTOB_HASH_CODE(m) \ + ((((m_addr_t) (m)) >> MEMO_CLUSTER_SHIFT) & VTOB_HASH_MASK) + +typedef struct m_pool { /* Memory pool of a given kind */ + m_bush_t bush; + m_addr_t (*getp)(struct m_pool *); + void (*freep)(struct m_pool *, m_addr_t); + int nump; + m_vtob_s *(vtob[VTOB_HASH_SIZE]); + struct m_pool *next; + struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1]; +} m_pool_s; + +static void *___m_alloc(m_pool_s *mp, int size) +{ + int i = 0; + int s = (1 << MEMO_SHIFT); + int j; + m_addr_t a; + m_link_s *h = mp->h; + + if (size > (PAGE_SIZE << MEMO_PAGE_ORDER)) + return NULL; + + while (size > s) { + s <<= 1; + ++i; + } + + j = i; + while (!h[j].next) { + if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) { + h[j].next = (m_link_s *)mp->getp(mp); + if (h[j].next) + h[j].next->next = NULL; + break; + } + ++j; + s <<= 1; + } + a = (m_addr_t) h[j].next; + if (a) { + h[j].next = h[j].next->next; + while (j > i) { + j -= 1; + s >>= 1; + h[j].next = (m_link_s *) (a+s); + h[j].next->next = NULL; + } + } +#ifdef DEBUG + printk("___m_alloc(%d) = %p\n", size, (void *) a); +#endif + return (void *) a; +} + +static void ___m_free(m_pool_s *mp, void *ptr, int size) +{ + int i = 0; + int s = (1 << MEMO_SHIFT); + m_link_s *q; + m_addr_t a, b; + m_link_s *h = mp->h; + +#ifdef DEBUG + printk("___m_free(%p, %d)\n", ptr, size); +#endif + + if (size > (PAGE_SIZE << MEMO_PAGE_ORDER)) + return; + + while (size > s) { + s <<= 1; + ++i; + } + + a = (m_addr_t) ptr; + + while (1) { +#ifdef MEMO_FREE_UNUSED + if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) { + mp->freep(mp, a); + break; + } +#endif + b = a ^ s; + q = &h[i]; + while (q->next && q->next != (m_link_s *) b) { + q = q->next; + } + if (!q->next) { + ((m_link_s *) a)->next = h[i].next; + h[i].next = (m_link_s *) a; + break; + } + q->next = q->next->next; + a = a & b; + s <<= 1; + ++i; + } +} + +static DEFINE_SPINLOCK(ncr53c8xx_lock); + +static void *__m_calloc2(m_pool_s *mp, int size, char *name, int uflags) +{ + void *p; + + p = ___m_alloc(mp, size); + + if (DEBUG_FLAGS & DEBUG_ALLOC) + printk ("new %-10s[%4d] @%p.\n", name, size, p); + + if (p) + memset(p, 0, size); + else if (uflags & MEMO_WARN) + printk (NAME53C8XX ": failed to allocate %s[%d]\n", name, size); + + return p; +} + +#define __m_calloc(mp, s, n) __m_calloc2(mp, s, n, MEMO_WARN) + +static void __m_free(m_pool_s *mp, void *ptr, int size, char *name) +{ + if (DEBUG_FLAGS & DEBUG_ALLOC) + printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr); + + ___m_free(mp, ptr, size); + +} + +/* + * With pci bus iommu support, we use a default pool of unmapped memory + * for memory we donnot need to DMA from/to and one pool per pcidev for + * memory accessed by the PCI chip. `mp0' is the default not DMAable pool. + */ + +static m_addr_t ___mp0_getp(m_pool_s *mp) +{ + m_addr_t m = __get_free_pages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER); + if (m) + ++mp->nump; + return m; +} + +static void ___mp0_freep(m_pool_s *mp, m_addr_t m) +{ + free_pages(m, MEMO_PAGE_ORDER); + --mp->nump; +} + +static m_pool_s mp0 = {NULL, ___mp0_getp, ___mp0_freep}; + +/* + * DMAable pools. + */ + +/* + * With pci bus iommu support, we maintain one pool per pcidev and a + * hashed reverse table for virtual to bus physical address translations. + */ +static m_addr_t ___dma_getp(m_pool_s *mp) +{ + m_addr_t vp; + m_vtob_s *vbp; + + vbp = __m_calloc(&mp0, sizeof(*vbp), "VTOB"); + if (vbp) { + dma_addr_t daddr; + vp = (m_addr_t) dma_alloc_coherent(mp->bush, + PAGE_SIZE<vaddr = vp; + vbp->baddr = daddr; + vbp->next = mp->vtob[hc]; + mp->vtob[hc] = vbp; + ++mp->nump; + return vp; + } + } + if (vbp) + __m_free(&mp0, vbp, sizeof(*vbp), "VTOB"); + return 0; +} + +static void ___dma_freep(m_pool_s *mp, m_addr_t m) +{ + m_vtob_s **vbpp, *vbp; + int hc = VTOB_HASH_CODE(m); + + vbpp = &mp->vtob[hc]; + while (*vbpp && (*vbpp)->vaddr != m) + vbpp = &(*vbpp)->next; + if (*vbpp) { + vbp = *vbpp; + *vbpp = (*vbpp)->next; + dma_free_coherent(mp->bush, PAGE_SIZE<vaddr, (dma_addr_t)vbp->baddr); + __m_free(&mp0, vbp, sizeof(*vbp), "VTOB"); + --mp->nump; + } +} + +static inline m_pool_s *___get_dma_pool(m_bush_t bush) +{ + m_pool_s *mp; + for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next); + return mp; +} + +static m_pool_s *___cre_dma_pool(m_bush_t bush) +{ + m_pool_s *mp; + mp = __m_calloc(&mp0, sizeof(*mp), "MPOOL"); + if (mp) { + memset(mp, 0, sizeof(*mp)); + mp->bush = bush; + mp->getp = ___dma_getp; + mp->freep = ___dma_freep; + mp->next = mp0.next; + mp0.next = mp; + } + return mp; +} + +static void ___del_dma_pool(m_pool_s *p) +{ + struct m_pool **pp = &mp0.next; + + while (*pp && *pp != p) + pp = &(*pp)->next; + if (*pp) { + *pp = (*pp)->next; + __m_free(&mp0, p, sizeof(*p), "MPOOL"); + } +} + +static void *__m_calloc_dma(m_bush_t bush, int size, char *name) +{ + u_long flags; + struct m_pool *mp; + void *m = NULL; + + spin_lock_irqsave(&ncr53c8xx_lock, flags); + mp = ___get_dma_pool(bush); + if (!mp) + mp = ___cre_dma_pool(bush); + if (mp) + m = __m_calloc(mp, size, name); + if (mp && !mp->nump) + ___del_dma_pool(mp); + spin_unlock_irqrestore(&ncr53c8xx_lock, flags); + + return m; +} + +static void __m_free_dma(m_bush_t bush, void *m, int size, char *name) +{ + u_long flags; + struct m_pool *mp; + + spin_lock_irqsave(&ncr53c8xx_lock, flags); + mp = ___get_dma_pool(bush); + if (mp) + __m_free(mp, m, size, name); + if (mp && !mp->nump) + ___del_dma_pool(mp); + spin_unlock_irqrestore(&ncr53c8xx_lock, flags); +} + +static m_addr_t __vtobus(m_bush_t bush, void *m) +{ + u_long flags; + m_pool_s *mp; + int hc = VTOB_HASH_CODE(m); + m_vtob_s *vp = NULL; + m_addr_t a = ((m_addr_t) m) & ~MEMO_CLUSTER_MASK; + + spin_lock_irqsave(&ncr53c8xx_lock, flags); + mp = ___get_dma_pool(bush); + if (mp) { + vp = mp->vtob[hc]; + while (vp && (m_addr_t) vp->vaddr != a) + vp = vp->next; + } + spin_unlock_irqrestore(&ncr53c8xx_lock, flags); + return vp ? vp->baddr + (((m_addr_t) m) - a) : 0; +} + +#define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n) +#define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n) +#define m_calloc_dma(s, n) _m_calloc_dma(np, s, n) +#define m_free_dma(p, s, n) _m_free_dma(np, p, s, n) +#define _vtobus(np, p) __vtobus(np->dev, p) +#define vtobus(p) _vtobus(np, p) + +/* + * Deal with DMA mapping/unmapping. + */ + +/* To keep track of the dma mapping (sg/single) that has been set */ +#define __data_mapped SCp.phase +#define __data_mapping SCp.have_data_in + +static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd) +{ + switch(cmd->__data_mapped) { + case 2: + dma_unmap_sg(dev, cmd->buffer, cmd->use_sg, + cmd->sc_data_direction); + break; + case 1: + dma_unmap_single(dev, cmd->__data_mapping, + cmd->request_bufflen, + cmd->sc_data_direction); + break; + } + cmd->__data_mapped = 0; +} + +static u_long __map_scsi_single_data(struct device *dev, struct scsi_cmnd *cmd) +{ + dma_addr_t mapping; + + if (cmd->request_bufflen == 0) + return 0; + + mapping = dma_map_single(dev, cmd->request_buffer, + cmd->request_bufflen, + cmd->sc_data_direction); + cmd->__data_mapped = 1; + cmd->__data_mapping = mapping; + + return mapping; +} + +static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd) +{ + int use_sg; + + if (cmd->use_sg == 0) + return 0; + + use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg, + cmd->sc_data_direction); + cmd->__data_mapped = 2; + cmd->__data_mapping = use_sg; + + return use_sg; +} + +#define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd) +#define map_scsi_single_data(np, cmd) __map_scsi_single_data(np->dev, cmd) +#define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd) + +/*========================================================== +** +** Driver setup. +** +** This structure is initialized from linux config +** options. It can be overridden at boot-up by the boot +** command line. +** +**========================================================== +*/ +static struct ncr_driver_setup + driver_setup = SCSI_NCR_DRIVER_SETUP; + +#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT +static struct ncr_driver_setup + driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP; +#endif + +#define initverbose (driver_setup.verbose) +#define bootverbose (np->verbose) + + +/*=================================================================== +** +** Driver setup from the boot command line +** +**=================================================================== +*/ + +#ifdef MODULE +#define ARG_SEP ' ' +#else +#define ARG_SEP ',' +#endif + +#define OPT_TAGS 1 +#define OPT_MASTER_PARITY 2 +#define OPT_SCSI_PARITY 3 +#define OPT_DISCONNECTION 4 +#define OPT_SPECIAL_FEATURES 5 +#define OPT_UNUSED_1 6 +#define OPT_FORCE_SYNC_NEGO 7 +#define OPT_REVERSE_PROBE 8 +#define OPT_DEFAULT_SYNC 9 +#define OPT_VERBOSE 10 +#define OPT_DEBUG 11 +#define OPT_BURST_MAX 12 +#define OPT_LED_PIN 13 +#define OPT_MAX_WIDE 14 +#define OPT_SETTLE_DELAY 15 +#define OPT_DIFF_SUPPORT 16 +#define OPT_IRQM 17 +#define OPT_PCI_FIX_UP 18 +#define OPT_BUS_CHECK 19 +#define OPT_OPTIMIZE 20 +#define OPT_RECOVERY 21 +#define OPT_SAFE_SETUP 22 +#define OPT_USE_NVRAM 23 +#define OPT_EXCLUDE 24 +#define OPT_HOST_ID 25 + +#ifdef SCSI_NCR_IARB_SUPPORT +#define OPT_IARB 26 +#endif + +static char setup_token[] __initdata = + "tags:" "mpar:" + "spar:" "disc:" + "specf:" "ultra:" + "fsn:" "revprob:" + "sync:" "verb:" + "debug:" "burst:" + "led:" "wide:" + "settle:" "diff:" + "irqm:" "pcifix:" + "buschk:" "optim:" + "recovery:" + "safe:" "nvram:" + "excl:" "hostid:" +#ifdef SCSI_NCR_IARB_SUPPORT + "iarb:" +#endif + ; /* DONNOT REMOVE THIS ';' */ + +#ifdef MODULE +#define ARG_SEP ' ' +#else +#define ARG_SEP ',' +#endif + +static int __init get_setup_token(char *p) +{ + char *cur = setup_token; + char *pc; + int i = 0; + + while (cur != NULL && (pc = strchr(cur, ':')) != NULL) { + ++pc; + ++i; + if (!strncmp(p, cur, pc - cur)) + return i; + cur = pc; + } + return 0; +} + + +static int __init sym53c8xx__setup(char *str) +{ +#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT + char *cur = str; + char *pc, *pv; + int i, val, c; + int xi = 0; + + while (cur != NULL && (pc = strchr(cur, ':')) != NULL) { + char *pe; + + val = 0; + pv = pc; + c = *++pv; + + if (c == 'n') + val = 0; + else if (c == 'y') + val = 1; + else + val = (int) simple_strtoul(pv, &pe, 0); + + switch (get_setup_token(cur)) { + case OPT_TAGS: + driver_setup.default_tags = val; + if (pe && *pe == '/') { + i = 0; + while (*pe && *pe != ARG_SEP && + i < sizeof(driver_setup.tag_ctrl)-1) { + driver_setup.tag_ctrl[i++] = *pe++; + } + driver_setup.tag_ctrl[i] = '\0'; + } + break; + case OPT_MASTER_PARITY: + driver_setup.master_parity = val; + break; + case OPT_SCSI_PARITY: + driver_setup.scsi_parity = val; + break; + case OPT_DISCONNECTION: + driver_setup.disconnection = val; + break; + case OPT_SPECIAL_FEATURES: + driver_setup.special_features = val; + break; + case OPT_FORCE_SYNC_NEGO: + driver_setup.force_sync_nego = val; + break; + case OPT_REVERSE_PROBE: + driver_setup.reverse_probe = val; + break; + case OPT_DEFAULT_SYNC: + driver_setup.default_sync = val; + break; + case OPT_VERBOSE: + driver_setup.verbose = val; + break; + case OPT_DEBUG: + driver_setup.debug = val; + break; + case OPT_BURST_MAX: + driver_setup.burst_max = val; + break; + case OPT_LED_PIN: + driver_setup.led_pin = val; + break; + case OPT_MAX_WIDE: + driver_setup.max_wide = val? 1:0; + break; + case OPT_SETTLE_DELAY: + driver_setup.settle_delay = val; + break; + case OPT_DIFF_SUPPORT: + driver_setup.diff_support = val; + break; + case OPT_IRQM: + driver_setup.irqm = val; + break; + case OPT_PCI_FIX_UP: + driver_setup.pci_fix_up = val; + break; + case OPT_BUS_CHECK: + driver_setup.bus_check = val; + break; + case OPT_OPTIMIZE: + driver_setup.optimize = val; + break; + case OPT_RECOVERY: + driver_setup.recovery = val; + break; + case OPT_USE_NVRAM: + driver_setup.use_nvram = val; + break; + case OPT_SAFE_SETUP: + memcpy(&driver_setup, &driver_safe_setup, + sizeof(driver_setup)); + break; + case OPT_EXCLUDE: + if (xi < SCSI_NCR_MAX_EXCLUDES) + driver_setup.excludes[xi++] = val; + break; + case OPT_HOST_ID: + driver_setup.host_id = val; + break; +#ifdef SCSI_NCR_IARB_SUPPORT + case OPT_IARB: + driver_setup.iarb = val; + break; +#endif + default: + printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur); + break; + } + + if ((cur = strchr(cur, ARG_SEP)) != NULL) + ++cur; + } +#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */ + return 1; +} + +/*=================================================================== +** +** Get device queue depth from boot command line. +** +**=================================================================== +*/ +#define DEF_DEPTH (driver_setup.default_tags) +#define ALL_TARGETS -2 +#define NO_TARGET -1 +#define ALL_LUNS -2 +#define NO_LUN -1 + +static int device_queue_depth(int unit, int target, int lun) +{ + int c, h, t, u, v; + char *p = driver_setup.tag_ctrl; + char *ep; + + h = -1; + t = NO_TARGET; + u = NO_LUN; + while ((c = *p++) != 0) { + v = simple_strtoul(p, &ep, 0); + switch(c) { + case '/': + ++h; + t = ALL_TARGETS; + u = ALL_LUNS; + break; + case 't': + if (t != target) + t = (target == v) ? v : NO_TARGET; + u = ALL_LUNS; + break; + case 'u': + if (u != lun) + u = (lun == v) ? v : NO_LUN; + break; + case 'q': + if (h == unit && + (t == ALL_TARGETS || t == target) && + (u == ALL_LUNS || u == lun)) + return v; + break; + case '-': + t = ALL_TARGETS; + u = ALL_LUNS; + break; + default: + break; + } + p = ep; + } + return DEF_DEPTH; +} /*========================================================== diff --git a/drivers/scsi/ncr53c8xx.h b/drivers/scsi/ncr53c8xx.h index 05c7b83..6a7bef2 100644 --- a/drivers/scsi/ncr53c8xx.h +++ b/drivers/scsi/ncr53c8xx.h @@ -2,6 +2,7 @@ ** Device driver for the PCI-SCSI NCR538XX controller family. ** ** Copyright (C) 1994 Wolfgang Stanglmeier +** Copyright (C) 1998-2001 Gerard Roudier ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -36,15 +37,1275 @@ ** And has been ported to NetBSD by ** Charles M. Hannum ** +** NVRAM detection and reading. +** Copyright (C) 1997 Richard Waltham +** +** Added support for MIPS big endian systems. +** Carsten Langgaard, carstenl@mips.com +** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. +** +** Added support for HP PARISC big endian systems. +** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. +** ******************************************************************************* */ #ifndef NCR53C8XX_H #define NCR53C8XX_H +#include #include -#include "sym53c8xx_defs.h" +/* +** If you want a driver as small as possible, do not define the +** following options. +*/ +#define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT +#define SCSI_NCR_DEBUG_INFO_SUPPORT + +/* +** To disable integrity checking, do not define the +** following option. +*/ +#ifdef CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK +# define SCSI_NCR_ENABLE_INTEGRITY_CHECK +#endif + +/* --------------------------------------------------------------------- +** Take into account kernel configured parameters. +** Most of these options can be overridden at startup by a command line. +** --------------------------------------------------------------------- +*/ + +/* + * For Ultra2 and Ultra3 SCSI support option, use special features. + * + * Value (default) means: + * bit 0 : all features enabled, except: + * bit 1 : PCI Write And Invalidate. + * bit 2 : Data Phase Mismatch handling from SCRIPTS. + * + * Use boot options ncr53c8xx=specf:1 if you want all chip features to be + * enabled by the driver. + */ +#define SCSI_NCR_SETUP_SPECIAL_FEATURES (3) + +#define SCSI_NCR_MAX_SYNC (80) + +/* + * Allow tags from 2 to 256, default 8 + */ +#ifdef CONFIG_SCSI_NCR53C8XX_MAX_TAGS +#if CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2 +#define SCSI_NCR_MAX_TAGS (2) +#elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256 +#define SCSI_NCR_MAX_TAGS (256) +#else +#define SCSI_NCR_MAX_TAGS CONFIG_SCSI_NCR53C8XX_MAX_TAGS +#endif +#else +#define SCSI_NCR_MAX_TAGS (8) +#endif + +/* + * Allow tagged command queuing support if configured with default number + * of tags set to max (see above). + */ +#ifdef CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS +#define SCSI_NCR_SETUP_DEFAULT_TAGS CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS +#elif defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE +#define SCSI_NCR_SETUP_DEFAULT_TAGS SCSI_NCR_MAX_TAGS +#else +#define SCSI_NCR_SETUP_DEFAULT_TAGS (0) +#endif + +/* + * Immediate arbitration + */ +#if defined(CONFIG_SCSI_NCR53C8XX_IARB) +#define SCSI_NCR_IARB_SUPPORT +#endif + +/* + * Sync transfer frequency at startup. + * Allow from 5Mhz to 80Mhz default 20 Mhz. + */ +#ifndef CONFIG_SCSI_NCR53C8XX_SYNC +#define CONFIG_SCSI_NCR53C8XX_SYNC (20) +#elif CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC +#undef CONFIG_SCSI_NCR53C8XX_SYNC +#define CONFIG_SCSI_NCR53C8XX_SYNC SCSI_NCR_MAX_SYNC +#endif + +#if CONFIG_SCSI_NCR53C8XX_SYNC == 0 +#define SCSI_NCR_SETUP_DEFAULT_SYNC (255) +#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 5 +#define SCSI_NCR_SETUP_DEFAULT_SYNC (50) +#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 20 +#define SCSI_NCR_SETUP_DEFAULT_SYNC (250/(CONFIG_SCSI_NCR53C8XX_SYNC)) +#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 33 +#define SCSI_NCR_SETUP_DEFAULT_SYNC (11) +#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 40 +#define SCSI_NCR_SETUP_DEFAULT_SYNC (10) +#else +#define SCSI_NCR_SETUP_DEFAULT_SYNC (9) +#endif + +/* + * Disallow disconnections at boot-up + */ +#ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT +#define SCSI_NCR_SETUP_DISCONNECTION (0) +#else +#define SCSI_NCR_SETUP_DISCONNECTION (1) +#endif + +/* + * Force synchronous negotiation for all targets + */ +#ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO +#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (1) +#else +#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (0) +#endif + +/* + * Disable master parity checking (flawed hardwares need that) + */ +#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK +#define SCSI_NCR_SETUP_MASTER_PARITY (0) +#else +#define SCSI_NCR_SETUP_MASTER_PARITY (1) +#endif + +/* + * Disable scsi parity checking (flawed devices may need that) + */ +#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK +#define SCSI_NCR_SETUP_SCSI_PARITY (0) +#else +#define SCSI_NCR_SETUP_SCSI_PARITY (1) +#endif + +/* + * Settle time after reset at boot-up + */ +#define SCSI_NCR_SETUP_SETTLE_TIME (2) + +/* +** Bridge quirks work-around option defaulted to 1. +*/ +#ifndef SCSI_NCR_PCIQ_WORK_AROUND_OPT +#define SCSI_NCR_PCIQ_WORK_AROUND_OPT 1 +#endif + +/* +** Work-around common bridge misbehaviour. +** +** - Do not flush posted writes in the opposite +** direction on read. +** - May reorder DMA writes to memory. +** +** This option should not affect performances +** significantly, so it is the default. +*/ +#if SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1 +#define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM +#define SCSI_NCR_PCIQ_MAY_REORDER_WRITES +#define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS + +/* +** Same as option 1, but also deal with +** misconfigured interrupts. +** +** - Edge triggerred instead of level sensitive. +** - No interrupt line connected. +** - IRQ number misconfigured. +** +** If no interrupt is delivered, the driver will +** catch the interrupt conditions 10 times per +** second. No need to say that this option is +** not recommended. +*/ +#elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2 +#define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM +#define SCSI_NCR_PCIQ_MAY_REORDER_WRITES +#define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS +#define SCSI_NCR_PCIQ_BROKEN_INTR + +/* +** Some bridge designers decided to flush +** everything prior to deliver the interrupt. +** This option tries to deal with such a +** behaviour. +*/ +#elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3 +#define SCSI_NCR_PCIQ_SYNC_ON_INTR +#endif + +/* +** Other parameters not configurable with "make config" +** Avoid to change these constants, unless you know what you are doing. +*/ + +#define SCSI_NCR_ALWAYS_SIMPLE_TAG +#define SCSI_NCR_MAX_SCATTER (127) +#define SCSI_NCR_MAX_TARGET (16) + +/* +** Compute some desirable value for CAN_QUEUE +** and CMD_PER_LUN. +** The driver will use lower values if these +** ones appear to be too large. +*/ +#define SCSI_NCR_CAN_QUEUE (8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET) +#define SCSI_NCR_CMD_PER_LUN (SCSI_NCR_MAX_TAGS) + +#define SCSI_NCR_SG_TABLESIZE (SCSI_NCR_MAX_SCATTER) +#define SCSI_NCR_TIMER_INTERVAL (HZ) + +#if 1 /* defined CONFIG_SCSI_MULTI_LUN */ +#define SCSI_NCR_MAX_LUN (16) +#else +#define SCSI_NCR_MAX_LUN (1) +#endif + +/* + * IO functions definition for big/little endian CPU support. + * For now, the NCR is only supported in little endian addressing mode, + */ + +#ifdef __BIG_ENDIAN + +#define inw_l2b inw +#define inl_l2b inl +#define outw_b2l outw +#define outl_b2l outl + +#define readb_raw readb +#define writeb_raw writeb + +#if defined(SCSI_NCR_BIG_ENDIAN) +#define readw_l2b __raw_readw +#define readl_l2b __raw_readl +#define writew_b2l __raw_writew +#define writel_b2l __raw_writel +#define readw_raw __raw_readw +#define readl_raw __raw_readl +#define writew_raw __raw_writew +#define writel_raw __raw_writel +#else /* Other big-endian */ +#define readw_l2b readw +#define readl_l2b readl +#define writew_b2l writew +#define writel_b2l writel +#define readw_raw readw +#define readl_raw readl +#define writew_raw writew +#define writel_raw writel +#endif + +#else /* little endian */ + +#define inw_raw inw +#define inl_raw inl +#define outw_raw outw +#define outl_raw outl + +#define readb_raw readb +#define readw_raw readw +#define readl_raw readl +#define writeb_raw writeb +#define writew_raw writew +#define writel_raw writel + +#endif + +#if !defined(__hppa__) && !defined(__mips__) +#ifdef SCSI_NCR_BIG_ENDIAN +#error "The NCR in BIG ENDIAN addressing mode is not (yet) supported" +#endif +#endif + +#define MEMORY_BARRIER() mb() + + +/* + * If the NCR uses big endian addressing mode over the + * PCI, actual io register addresses for byte and word + * accesses must be changed according to lane routing. + * Btw, ncr_offb() and ncr_offw() macros only apply to + * constants and so donnot generate bloated code. + */ + +#if defined(SCSI_NCR_BIG_ENDIAN) + +#define ncr_offb(o) (((o)&~3)+((~((o)&3))&3)) +#define ncr_offw(o) (((o)&~3)+((~((o)&3))&2)) + +#else + +#define ncr_offb(o) (o) +#define ncr_offw(o) (o) + +#endif + +/* + * If the CPU and the NCR use same endian-ness addressing, + * no byte reordering is needed for script patching. + * Macro cpu_to_scr() is to be used for script patching. + * Macro scr_to_cpu() is to be used for getting a DWORD + * from the script. + */ + +#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN) + +#define cpu_to_scr(dw) cpu_to_le32(dw) +#define scr_to_cpu(dw) le32_to_cpu(dw) + +#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN) + +#define cpu_to_scr(dw) cpu_to_be32(dw) +#define scr_to_cpu(dw) be32_to_cpu(dw) + +#else + +#define cpu_to_scr(dw) (dw) +#define scr_to_cpu(dw) (dw) + +#endif + +/* + * Access to the controller chip. + * + * If the CPU and the NCR use same endian-ness addressing, + * no byte reordering is needed for accessing chip io + * registers. Functions suffixed by '_raw' are assumed + * to access the chip over the PCI without doing byte + * reordering. Functions suffixed by '_l2b' are + * assumed to perform little-endian to big-endian byte + * reordering, those suffixed by '_b2l' blah, blah, + * blah, ... + */ + +/* + * MEMORY mapped IO input / output + */ + +#define INB_OFF(o) readb_raw((char __iomem *)np->reg + ncr_offb(o)) +#define OUTB_OFF(o, val) writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o)) + +#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN) + +#define INW_OFF(o) readw_l2b((char __iomem *)np->reg + ncr_offw(o)) +#define INL_OFF(o) readl_l2b((char __iomem *)np->reg + (o)) + +#define OUTW_OFF(o, val) writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o)) +#define OUTL_OFF(o, val) writel_b2l((val), (char __iomem *)np->reg + (o)) + +#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN) + +#define INW_OFF(o) readw_b2l((char __iomem *)np->reg + ncr_offw(o)) +#define INL_OFF(o) readl_b2l((char __iomem *)np->reg + (o)) + +#define OUTW_OFF(o, val) writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o)) +#define OUTL_OFF(o, val) writel_l2b((val), (char __iomem *)np->reg + (o)) + +#else + +#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS +/* Only 8 or 32 bit transfers allowed */ +#define INW_OFF(o) (readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1)) +#else +#define INW_OFF(o) readw_raw((char __iomem *)np->reg + ncr_offw(o)) +#endif +#define INL_OFF(o) readl_raw((char __iomem *)np->reg + (o)) + +#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS +/* Only 8 or 32 bit transfers allowed */ +#define OUTW_OFF(o, val) do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0) +#else +#define OUTW_OFF(o, val) writew_raw((val), (char __iomem *)np->reg + ncr_offw(o)) +#endif +#define OUTL_OFF(o, val) writel_raw((val), (char __iomem *)np->reg + (o)) + +#endif + +#define INB(r) INB_OFF (offsetof(struct ncr_reg,r)) +#define INW(r) INW_OFF (offsetof(struct ncr_reg,r)) +#define INL(r) INL_OFF (offsetof(struct ncr_reg,r)) + +#define OUTB(r, val) OUTB_OFF (offsetof(struct ncr_reg,r), (val)) +#define OUTW(r, val) OUTW_OFF (offsetof(struct ncr_reg,r), (val)) +#define OUTL(r, val) OUTL_OFF (offsetof(struct ncr_reg,r), (val)) + +/* + * Set bit field ON, OFF + */ + +#define OUTONB(r, m) OUTB(r, INB(r) | (m)) +#define OUTOFFB(r, m) OUTB(r, INB(r) & ~(m)) +#define OUTONW(r, m) OUTW(r, INW(r) | (m)) +#define OUTOFFW(r, m) OUTW(r, INW(r) & ~(m)) +#define OUTONL(r, m) OUTL(r, INL(r) | (m)) +#define OUTOFFL(r, m) OUTL(r, INL(r) & ~(m)) + +/* + * We normally want the chip to have a consistent view + * of driver internal data structures when we restart it. + * Thus these macros. + */ +#define OUTL_DSP(v) \ + do { \ + MEMORY_BARRIER(); \ + OUTL (nc_dsp, (v)); \ + } while (0) + +#define OUTONB_STD() \ + do { \ + MEMORY_BARRIER(); \ + OUTONB (nc_dcntl, (STD|NOCOM)); \ + } while (0) + + +/* +** NCR53C8XX devices features table. +*/ +struct ncr_chip { + unsigned short revision_id; + unsigned char burst_max; /* log-base-2 of max burst */ + unsigned char offset_max; + unsigned char nr_divisor; + unsigned int features; +#define FE_LED0 (1<<0) +#define FE_WIDE (1<<1) /* Wide data transfers */ +#define FE_ULTRA (1<<2) /* Ultra speed 20Mtrans/sec */ +#define FE_DBLR (1<<4) /* Clock doubler present */ +#define FE_QUAD (1<<5) /* Clock quadrupler present */ +#define FE_ERL (1<<6) /* Enable read line */ +#define FE_CLSE (1<<7) /* Cache line size enable */ +#define FE_WRIE (1<<8) /* Write & Invalidate enable */ +#define FE_ERMP (1<<9) /* Enable read multiple */ +#define FE_BOF (1<<10) /* Burst opcode fetch */ +#define FE_DFS (1<<11) /* DMA fifo size */ +#define FE_PFEN (1<<12) /* Prefetch enable */ +#define FE_LDSTR (1<<13) /* Load/Store supported */ +#define FE_RAM (1<<14) /* On chip RAM present */ +#define FE_VARCLK (1<<15) /* SCSI clock may vary */ +#define FE_RAM8K (1<<16) /* On chip RAM sized 8Kb */ +#define FE_64BIT (1<<17) /* Have a 64-bit PCI interface */ +#define FE_IO256 (1<<18) /* Requires full 256 bytes in PCI space */ +#define FE_NOPM (1<<19) /* Scripts handles phase mismatch */ +#define FE_LEDC (1<<20) /* Hardware control of LED */ +#define FE_DIFF (1<<21) /* Support Differential SCSI */ +#define FE_66MHZ (1<<23) /* 66MHz PCI Support */ +#define FE_DAC (1<<24) /* Support DAC cycles (64 bit addressing) */ +#define FE_ISTAT1 (1<<25) /* Have ISTAT1, MBOX0, MBOX1 registers */ +#define FE_DAC_IN_USE (1<<26) /* Platform does DAC cycles */ +#define FE_EHP (1<<27) /* 720: Even host parity */ +#define FE_MUX (1<<28) /* 720: Multiplexed bus */ +#define FE_EA (1<<29) /* 720: Enable Ack */ + +#define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP) +#define FE_SCSI_SET (FE_WIDE|FE_ULTRA|FE_DBLR|FE_QUAD|F_CLK80) +#define FE_SPECIAL_SET (FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM) +}; + + +/* +** Driver setup structure. +** +** This structure is initialized from linux config options. +** It can be overridden at boot-up by the boot command line. +*/ +#define SCSI_NCR_MAX_EXCLUDES 8 +struct ncr_driver_setup { + u8 master_parity; + u8 scsi_parity; + u8 disconnection; + u8 special_features; + u8 force_sync_nego; + u8 reverse_probe; + u8 pci_fix_up; + u8 use_nvram; + u8 verbose; + u8 default_tags; + u16 default_sync; + u16 debug; + u8 burst_max; + u8 led_pin; + u8 max_wide; + u8 settle_delay; + u8 diff_support; + u8 irqm; + u8 bus_check; + u8 optimize; + u8 recovery; + u8 host_id; + u16 iarb; + u32 excludes[SCSI_NCR_MAX_EXCLUDES]; + char tag_ctrl[100]; +}; + +/* +** Initial setup. +** Can be overriden at startup by a command line. +*/ +#define SCSI_NCR_DRIVER_SETUP \ +{ \ + SCSI_NCR_SETUP_MASTER_PARITY, \ + SCSI_NCR_SETUP_SCSI_PARITY, \ + SCSI_NCR_SETUP_DISCONNECTION, \ + SCSI_NCR_SETUP_SPECIAL_FEATURES, \ + SCSI_NCR_SETUP_FORCE_SYNC_NEGO, \ + 0, \ + 0, \ + 1, \ + 0, \ + SCSI_NCR_SETUP_DEFAULT_TAGS, \ + SCSI_NCR_SETUP_DEFAULT_SYNC, \ + 0x00, \ + 7, \ + 0, \ + 1, \ + SCSI_NCR_SETUP_SETTLE_TIME, \ + 0, \ + 0, \ + 1, \ + 0, \ + 0, \ + 255, \ + 0x00 \ +} + +/* +** Boot fail safe setup. +** Override initial setup from boot command line: +** ncr53c8xx=safe:y +*/ +#define SCSI_NCR_DRIVER_SAFE_SETUP \ +{ \ + 0, \ + 1, \ + 0, \ + 0, \ + 0, \ + 0, \ + 0, \ + 1, \ + 2, \ + 0, \ + 255, \ + 0x00, \ + 255, \ + 0, \ + 0, \ + 10, \ + 1, \ + 1, \ + 1, \ + 0, \ + 0, \ + 255 \ +} + +/**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/ + +/*----------------------------------------------------------------- +** +** The ncr 53c810 register structure. +** +**----------------------------------------------------------------- +*/ + +struct ncr_reg { +/*00*/ u8 nc_scntl0; /* full arb., ena parity, par->ATN */ + +/*01*/ u8 nc_scntl1; /* no reset */ + #define ISCON 0x10 /* connected to scsi */ + #define CRST 0x08 /* force reset */ + #define IARB 0x02 /* immediate arbitration */ + +/*02*/ u8 nc_scntl2; /* no disconnect expected */ + #define SDU 0x80 /* cmd: disconnect will raise error */ + #define CHM 0x40 /* sta: chained mode */ + #define WSS 0x08 /* sta: wide scsi send [W]*/ + #define WSR 0x01 /* sta: wide scsi received [W]*/ + +/*03*/ u8 nc_scntl3; /* cnf system clock dependent */ + #define EWS 0x08 /* cmd: enable wide scsi [W]*/ + #define ULTRA 0x80 /* cmd: ULTRA enable */ + /* bits 0-2, 7 rsvd for C1010 */ + +/*04*/ u8 nc_scid; /* cnf host adapter scsi address */ + #define RRE 0x40 /* r/w:e enable response to resel. */ + #define SRE 0x20 /* r/w:e enable response to select */ + +/*05*/ u8 nc_sxfer; /* ### Sync speed and count */ + /* bits 6-7 rsvd for C1010 */ + +/*06*/ u8 nc_sdid; /* ### Destination-ID */ + +/*07*/ u8 nc_gpreg; /* ??? IO-Pins */ + +/*08*/ u8 nc_sfbr; /* ### First byte in phase */ + +/*09*/ u8 nc_socl; + #define CREQ 0x80 /* r/w: SCSI-REQ */ + #define CACK 0x40 /* r/w: SCSI-ACK */ + #define CBSY 0x20 /* r/w: SCSI-BSY */ + #define CSEL 0x10 /* r/w: SCSI-SEL */ + #define CATN 0x08 /* r/w: SCSI-ATN */ + #define CMSG 0x04 /* r/w: SCSI-MSG */ + #define CC_D 0x02 /* r/w: SCSI-C_D */ + #define CI_O 0x01 /* r/w: SCSI-I_O */ + +/*0a*/ u8 nc_ssid; + +/*0b*/ u8 nc_sbcl; + +/*0c*/ u8 nc_dstat; + #define DFE 0x80 /* sta: dma fifo empty */ + #define MDPE 0x40 /* int: master data parity error */ + #define BF 0x20 /* int: script: bus fault */ + #define ABRT 0x10 /* int: script: command aborted */ + #define SSI 0x08 /* int: script: single step */ + #define SIR 0x04 /* int: script: interrupt instruct. */ + #define IID 0x01 /* int: script: illegal instruct. */ + +/*0d*/ u8 nc_sstat0; + #define ILF 0x80 /* sta: data in SIDL register lsb */ + #define ORF 0x40 /* sta: data in SODR register lsb */ + #define OLF 0x20 /* sta: data in SODL register lsb */ + #define AIP 0x10 /* sta: arbitration in progress */ + #define LOA 0x08 /* sta: arbitration lost */ + #define WOA 0x04 /* sta: arbitration won */ + #define IRST 0x02 /* sta: scsi reset signal */ + #define SDP 0x01 /* sta: scsi parity signal */ + +/*0e*/ u8 nc_sstat1; + #define FF3210 0xf0 /* sta: bytes in the scsi fifo */ + +/*0f*/ u8 nc_sstat2; + #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/ + #define ORF1 0x40 /* sta: data in SODR register msb[W]*/ + #define OLF1 0x20 /* sta: data in SODL register msb[W]*/ + #define DM 0x04 /* sta: DIFFSENS mismatch (895/6 only) */ + #define LDSC 0x02 /* sta: disconnect & reconnect */ + +/*10*/ u8 nc_dsa; /* --> Base page */ +/*11*/ u8 nc_dsa1; +/*12*/ u8 nc_dsa2; +/*13*/ u8 nc_dsa3; + +/*14*/ u8 nc_istat; /* --> Main Command and status */ + #define CABRT 0x80 /* cmd: abort current operation */ + #define SRST 0x40 /* mod: reset chip */ + #define SIGP 0x20 /* r/w: message from host to ncr */ + #define SEM 0x10 /* r/w: message between host + ncr */ + #define CON 0x08 /* sta: connected to scsi */ + #define INTF 0x04 /* sta: int on the fly (reset by wr)*/ + #define SIP 0x02 /* sta: scsi-interrupt */ + #define DIP 0x01 /* sta: host/script interrupt */ + +/*15*/ u8 nc_istat1; /* 896 and later cores only */ + #define FLSH 0x04 /* sta: chip is flushing */ + #define SRUN 0x02 /* sta: scripts are running */ + #define SIRQD 0x01 /* r/w: disable INT pin */ + +/*16*/ u8 nc_mbox0; /* 896 and later cores only */ +/*17*/ u8 nc_mbox1; /* 896 and later cores only */ + +/*18*/ u8 nc_ctest0; + #define EHP 0x04 /* 720 even host parity */ +/*19*/ u8 nc_ctest1; + +/*1a*/ u8 nc_ctest2; + #define CSIGP 0x40 + /* bits 0-2,7 rsvd for C1010 */ + +/*1b*/ u8 nc_ctest3; + #define FLF 0x08 /* cmd: flush dma fifo */ + #define CLF 0x04 /* cmd: clear dma fifo */ + #define FM 0x02 /* mod: fetch pin mode */ + #define WRIE 0x01 /* mod: write and invalidate enable */ + /* bits 4-7 rsvd for C1010 */ + +/*1c*/ u32 nc_temp; /* ### Temporary stack */ + +/*20*/ u8 nc_dfifo; +/*21*/ u8 nc_ctest4; + #define MUX 0x80 /* 720 host bus multiplex mode */ + #define BDIS 0x80 /* mod: burst disable */ + #define MPEE 0x08 /* mod: master parity error enable */ + +/*22*/ u8 nc_ctest5; + #define DFS 0x20 /* mod: dma fifo size */ + /* bits 0-1, 3-7 rsvd for C1010 */ +/*23*/ u8 nc_ctest6; + +/*24*/ u32 nc_dbc; /* ### Byte count and command */ +/*28*/ u32 nc_dnad; /* ### Next command register */ +/*2c*/ u32 nc_dsp; /* --> Script Pointer */ +/*30*/ u32 nc_dsps; /* --> Script pointer save/opcode#2 */ + +/*34*/ u8 nc_scratcha; /* Temporary register a */ +/*35*/ u8 nc_scratcha1; +/*36*/ u8 nc_scratcha2; +/*37*/ u8 nc_scratcha3; + +/*38*/ u8 nc_dmode; + #define BL_2 0x80 /* mod: burst length shift value +2 */ + #define BL_1 0x40 /* mod: burst length shift value +1 */ + #define ERL 0x08 /* mod: enable read line */ + #define ERMP 0x04 /* mod: enable read multiple */ + #define BOF 0x02 /* mod: burst op code fetch */ + +/*39*/ u8 nc_dien; +/*3a*/ u8 nc_sbr; + +/*3b*/ u8 nc_dcntl; /* --> Script execution control */ + #define CLSE 0x80 /* mod: cache line size enable */ + #define PFF 0x40 /* cmd: pre-fetch flush */ + #define PFEN 0x20 /* mod: pre-fetch enable */ + #define EA 0x20 /* mod: 720 enable-ack */ + #define SSM 0x10 /* mod: single step mode */ + #define IRQM 0x08 /* mod: irq mode (1 = totem pole !) */ + #define STD 0x04 /* cmd: start dma mode */ + #define IRQD 0x02 /* mod: irq disable */ + #define NOCOM 0x01 /* cmd: protect sfbr while reselect */ + /* bits 0-1 rsvd for C1010 */ + +/*3c*/ u32 nc_adder; + +/*40*/ u16 nc_sien; /* -->: interrupt enable */ +/*42*/ u16 nc_sist; /* <--: interrupt status */ + #define SBMC 0x1000/* sta: SCSI Bus Mode Change (895/6 only) */ + #define STO 0x0400/* sta: timeout (select) */ + #define GEN 0x0200/* sta: timeout (general) */ + #define HTH 0x0100/* sta: timeout (handshake) */ + #define MA 0x80 /* sta: phase mismatch */ + #define CMP 0x40 /* sta: arbitration complete */ + #define SEL 0x20 /* sta: selected by another device */ + #define RSL 0x10 /* sta: reselected by another device*/ + #define SGE 0x08 /* sta: gross error (over/underflow)*/ + #define UDC 0x04 /* sta: unexpected disconnect */ + #define RST 0x02 /* sta: scsi bus reset detected */ + #define PAR 0x01 /* sta: scsi parity error */ + +/*44*/ u8 nc_slpar; +/*45*/ u8 nc_swide; +/*46*/ u8 nc_macntl; +/*47*/ u8 nc_gpcntl; +/*48*/ u8 nc_stime0; /* cmd: timeout for select&handshake*/ +/*49*/ u8 nc_stime1; /* cmd: timeout user defined */ +/*4a*/ u16 nc_respid; /* sta: Reselect-IDs */ + +/*4c*/ u8 nc_stest0; + +/*4d*/ u8 nc_stest1; + #define SCLK 0x80 /* Use the PCI clock as SCSI clock */ + #define DBLEN 0x08 /* clock doubler running */ + #define DBLSEL 0x04 /* clock doubler selected */ + + +/*4e*/ u8 nc_stest2; + #define ROF 0x40 /* reset scsi offset (after gross error!) */ + #define DIF 0x20 /* 720 SCSI differential mode */ + #define EXT 0x02 /* extended filtering */ + +/*4f*/ u8 nc_stest3; + #define TE 0x80 /* c: tolerAnt enable */ + #define HSC 0x20 /* c: Halt SCSI Clock */ + #define CSF 0x02 /* c: clear scsi fifo */ + +/*50*/ u16 nc_sidl; /* Lowlevel: latched from scsi data */ +/*52*/ u8 nc_stest4; + #define SMODE 0xc0 /* SCSI bus mode (895/6 only) */ + #define SMODE_HVD 0x40 /* High Voltage Differential */ + #define SMODE_SE 0x80 /* Single Ended */ + #define SMODE_LVD 0xc0 /* Low Voltage Differential */ + #define LCKFRQ 0x20 /* Frequency Lock (895/6 only) */ + /* bits 0-5 rsvd for C1010 */ + +/*53*/ u8 nc_53_; +/*54*/ u16 nc_sodl; /* Lowlevel: data out to scsi data */ +/*56*/ u8 nc_ccntl0; /* Chip Control 0 (896) */ + #define ENPMJ 0x80 /* Enable Phase Mismatch Jump */ + #define PMJCTL 0x40 /* Phase Mismatch Jump Control */ + #define ENNDJ 0x20 /* Enable Non Data PM Jump */ + #define DISFC 0x10 /* Disable Auto FIFO Clear */ + #define DILS 0x02 /* Disable Internal Load/Store */ + #define DPR 0x01 /* Disable Pipe Req */ + +/*57*/ u8 nc_ccntl1; /* Chip Control 1 (896) */ + #define ZMOD 0x80 /* High Impedance Mode */ + #define DIC 0x10 /* Disable Internal Cycles */ + #define DDAC 0x08 /* Disable Dual Address Cycle */ + #define XTIMOD 0x04 /* 64-bit Table Ind. Indexing Mode */ + #define EXTIBMV 0x02 /* Enable 64-bit Table Ind. BMOV */ + #define EXDBMV 0x01 /* Enable 64-bit Direct BMOV */ + +/*58*/ u16 nc_sbdl; /* Lowlevel: data from scsi data */ +/*5a*/ u16 nc_5a_; + +/*5c*/ u8 nc_scr0; /* Working register B */ +/*5d*/ u8 nc_scr1; /* */ +/*5e*/ u8 nc_scr2; /* */ +/*5f*/ u8 nc_scr3; /* */ + +/*60*/ u8 nc_scrx[64]; /* Working register C-R */ +/*a0*/ u32 nc_mmrs; /* Memory Move Read Selector */ +/*a4*/ u32 nc_mmws; /* Memory Move Write Selector */ +/*a8*/ u32 nc_sfs; /* Script Fetch Selector */ +/*ac*/ u32 nc_drs; /* DSA Relative Selector */ +/*b0*/ u32 nc_sbms; /* Static Block Move Selector */ +/*b4*/ u32 nc_dbms; /* Dynamic Block Move Selector */ +/*b8*/ u32 nc_dnad64; /* DMA Next Address 64 */ +/*bc*/ u16 nc_scntl4; /* C1010 only */ + #define U3EN 0x80 /* Enable Ultra 3 */ + #define AIPEN 0x40 /* Allow check upper byte lanes */ + #define XCLKH_DT 0x08 /* Extra clock of data hold on DT + transfer edge */ + #define XCLKH_ST 0x04 /* Extra clock of data hold on ST + transfer edge */ + +/*be*/ u8 nc_aipcntl0; /* Epat Control 1 C1010 only */ +/*bf*/ u8 nc_aipcntl1; /* AIP Control C1010_66 Only */ + +/*c0*/ u32 nc_pmjad1; /* Phase Mismatch Jump Address 1 */ +/*c4*/ u32 nc_pmjad2; /* Phase Mismatch Jump Address 2 */ +/*c8*/ u8 nc_rbc; /* Remaining Byte Count */ +/*c9*/ u8 nc_rbc1; /* */ +/*ca*/ u8 nc_rbc2; /* */ +/*cb*/ u8 nc_rbc3; /* */ + +/*cc*/ u8 nc_ua; /* Updated Address */ +/*cd*/ u8 nc_ua1; /* */ +/*ce*/ u8 nc_ua2; /* */ +/*cf*/ u8 nc_ua3; /* */ +/*d0*/ u32 nc_esa; /* Entry Storage Address */ +/*d4*/ u8 nc_ia; /* Instruction Address */ +/*d5*/ u8 nc_ia1; +/*d6*/ u8 nc_ia2; +/*d7*/ u8 nc_ia3; +/*d8*/ u32 nc_sbc; /* SCSI Byte Count (3 bytes only) */ +/*dc*/ u32 nc_csbc; /* Cumulative SCSI Byte Count */ + + /* Following for C1010 only */ +/*e0*/ u16 nc_crcpad; /* CRC Value */ +/*e2*/ u8 nc_crccntl0; /* CRC control register */ + #define SNDCRC 0x10 /* Send CRC Request */ +/*e3*/ u8 nc_crccntl1; /* CRC control register */ +/*e4*/ u32 nc_crcdata; /* CRC data register */ +/*e8*/ u32 nc_e8_; /* rsvd */ +/*ec*/ u32 nc_ec_; /* rsvd */ +/*f0*/ u16 nc_dfbc; /* DMA FIFO byte count */ + +}; + +/*----------------------------------------------------------- +** +** Utility macros for the script. +** +**----------------------------------------------------------- +*/ + +#define REGJ(p,r) (offsetof(struct ncr_reg, p ## r)) +#define REG(r) REGJ (nc_, r) + +typedef u32 ncrcmd; + +/*----------------------------------------------------------- +** +** SCSI phases +** +** DT phases illegal for ncr driver. +** +**----------------------------------------------------------- +*/ + +#define SCR_DATA_OUT 0x00000000 +#define SCR_DATA_IN 0x01000000 +#define SCR_COMMAND 0x02000000 +#define SCR_STATUS 0x03000000 +#define SCR_DT_DATA_OUT 0x04000000 +#define SCR_DT_DATA_IN 0x05000000 +#define SCR_MSG_OUT 0x06000000 +#define SCR_MSG_IN 0x07000000 + +#define SCR_ILG_OUT 0x04000000 +#define SCR_ILG_IN 0x05000000 + +/*----------------------------------------------------------- +** +** Data transfer via SCSI. +** +**----------------------------------------------------------- +** +** MOVE_ABS (LEN) +** <> +** +** MOVE_IND (LEN) +** <> +** +** MOVE_TBL +** <> +** +**----------------------------------------------------------- +*/ + +#define OPC_MOVE 0x08000000 + +#define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l)) +#define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l)) +#define SCR_MOVE_TBL (0x10000000 | OPC_MOVE) + +#define SCR_CHMOV_ABS(l) ((0x00000000) | (l)) +#define SCR_CHMOV_IND(l) ((0x20000000) | (l)) +#define SCR_CHMOV_TBL (0x10000000) + +struct scr_tblmove { + u32 size; + u32 addr; +}; + +/*----------------------------------------------------------- +** +** Selection +** +**----------------------------------------------------------- +** +** SEL_ABS | SCR_ID (0..15) [ | REL_JMP] +** <> +** +** SEL_TBL | << dnad_offset>> [ | REL_JMP] +** <> +** +**----------------------------------------------------------- +*/ + +#define SCR_SEL_ABS 0x40000000 +#define SCR_SEL_ABS_ATN 0x41000000 +#define SCR_SEL_TBL 0x42000000 +#define SCR_SEL_TBL_ATN 0x43000000 + + +#ifdef SCSI_NCR_BIG_ENDIAN +struct scr_tblsel { + u8 sel_scntl3; + u8 sel_id; + u8 sel_sxfer; + u8 sel_scntl4; +}; +#else +struct scr_tblsel { + u8 sel_scntl4; + u8 sel_sxfer; + u8 sel_id; + u8 sel_scntl3; +}; +#endif + +#define SCR_JMP_REL 0x04000000 +#define SCR_ID(id) (((u32)(id)) << 16) + +/*----------------------------------------------------------- +** +** Waiting for Disconnect or Reselect +** +**----------------------------------------------------------- +** +** WAIT_DISC +** dummy: <> +** +** WAIT_RESEL +** <> +** +**----------------------------------------------------------- +*/ + +#define SCR_WAIT_DISC 0x48000000 +#define SCR_WAIT_RESEL 0x50000000 + +/*----------------------------------------------------------- +** +** Bit Set / Reset +** +**----------------------------------------------------------- +** +** SET (flags {|.. }) +** +** CLR (flags {|.. }) +** +**----------------------------------------------------------- +*/ + +#define SCR_SET(f) (0x58000000 | (f)) +#define SCR_CLR(f) (0x60000000 | (f)) + +#define SCR_CARRY 0x00000400 +#define SCR_TRG 0x00000200 +#define SCR_ACK 0x00000040 +#define SCR_ATN 0x00000008 + + + + +/*----------------------------------------------------------- +** +** Memory to memory move +** +**----------------------------------------------------------- +** +** COPY (bytecount) +** << source_address >> +** << destination_address >> +** +** SCR_COPY sets the NO FLUSH option by default. +** SCR_COPY_F does not set this option. +** +** For chips which do not support this option, +** ncr_copy_and_bind() will remove this bit. +**----------------------------------------------------------- +*/ + +#define SCR_NO_FLUSH 0x01000000 + +#define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n)) +#define SCR_COPY_F(n) (0xc0000000 | (n)) + +/*----------------------------------------------------------- +** +** Register move and binary operations +** +**----------------------------------------------------------- +** +** SFBR_REG (reg, op, data) reg = SFBR op data +** << 0 >> +** +** REG_SFBR (reg, op, data) SFBR = reg op data +** << 0 >> +** +** REG_REG (reg, op, data) reg = reg op data +** << 0 >> +** +**----------------------------------------------------------- +** On 810A, 860, 825A, 875, 895 and 896 chips the content +** of SFBR register can be used as data (SCR_SFBR_DATA). +** The 896 has additionnal IO registers starting at +** offset 0x80. Bit 7 of register offset is stored in +** bit 7 of the SCRIPTS instruction first DWORD. +**----------------------------------------------------------- +*/ + +#define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80)) + +#define SCR_SFBR_REG(reg,op,data) \ + (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul)) + +#define SCR_REG_SFBR(reg,op,data) \ + (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul)) + +#define SCR_REG_REG(reg,op,data) \ + (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul)) + + +#define SCR_LOAD 0x00000000 +#define SCR_SHL 0x01000000 +#define SCR_OR 0x02000000 +#define SCR_XOR 0x03000000 +#define SCR_AND 0x04000000 +#define SCR_SHR 0x05000000 +#define SCR_ADD 0x06000000 +#define SCR_ADDC 0x07000000 + +#define SCR_SFBR_DATA (0x00800000>>8ul) /* Use SFBR as data */ + +/*----------------------------------------------------------- +** +** FROM_REG (reg) SFBR = reg +** << 0 >> +** +** TO_REG (reg) reg = SFBR +** << 0 >> +** +** LOAD_REG (reg, data) reg = +** << 0 >> +** +** LOAD_SFBR(data) SFBR = +** << 0 >> +** +**----------------------------------------------------------- +*/ + +#define SCR_FROM_REG(reg) \ + SCR_REG_SFBR(reg,SCR_OR,0) + +#define SCR_TO_REG(reg) \ + SCR_SFBR_REG(reg,SCR_OR,0) + +#define SCR_LOAD_REG(reg,data) \ + SCR_REG_REG(reg,SCR_LOAD,data) + +#define SCR_LOAD_SFBR(data) \ + (SCR_REG_SFBR (gpreg, SCR_LOAD, data)) + +/*----------------------------------------------------------- +** +** LOAD from memory to register. +** STORE from register to memory. +** +** Only supported by 810A, 860, 825A, 875, 895 and 896. +** +**----------------------------------------------------------- +** +** LOAD_ABS (LEN) +** <> +** +** LOAD_REL (LEN) (DSA relative) +** <> +** +**----------------------------------------------------------- +*/ + +#define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul) +#define SCR_NO_FLUSH2 0x02000000 +#define SCR_DSA_REL2 0x10000000 + +#define SCR_LOAD_R(reg, how, n) \ + (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n)) + +#define SCR_STORE_R(reg, how, n) \ + (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n)) + +#define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n) +#define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n) +#define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n) +#define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n) + +#define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n) +#define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n) +#define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n) +#define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n) + + +/*----------------------------------------------------------- +** +** Waiting for Disconnect or Reselect +** +**----------------------------------------------------------- +** +** JUMP [ | IFTRUE/IFFALSE ( ... ) ] +** <
> +** +** JUMPR [ | IFTRUE/IFFALSE ( ... ) ] +** <> +** +** CALL [ | IFTRUE/IFFALSE ( ... ) ] +** <
> +** +** CALLR [ | IFTRUE/IFFALSE ( ... ) ] +** <> +** +** RETURN [ | IFTRUE/IFFALSE ( ... ) ] +** <> +** +** INT [ | IFTRUE/IFFALSE ( ... ) ] +** <> +** +** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ] +** <> +** +** Conditions: +** WHEN (phase) +** IF (phase) +** CARRYSET +** DATA (data, mask) +** +**----------------------------------------------------------- +*/ + +#define SCR_NO_OP 0x80000000 +#define SCR_JUMP 0x80080000 +#define SCR_JUMP64 0x80480000 +#define SCR_JUMPR 0x80880000 +#define SCR_CALL 0x88080000 +#define SCR_CALLR 0x88880000 +#define SCR_RETURN 0x90080000 +#define SCR_INT 0x98080000 +#define SCR_INT_FLY 0x98180000 + +#define IFFALSE(arg) (0x00080000 | (arg)) +#define IFTRUE(arg) (0x00000000 | (arg)) + +#define WHEN(phase) (0x00030000 | (phase)) +#define IF(phase) (0x00020000 | (phase)) + +#define DATA(D) (0x00040000 | ((D) & 0xff)) +#define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff)) + +#define CARRYSET (0x00200000) + +/*----------------------------------------------------------- +** +** SCSI constants. +** +**----------------------------------------------------------- +*/ + +/* +** Messages +*/ + +#define M_COMPLETE COMMAND_COMPLETE +#define M_EXTENDED EXTENDED_MESSAGE +#define M_SAVE_DP SAVE_POINTERS +#define M_RESTORE_DP RESTORE_POINTERS +#define M_DISCONNECT DISCONNECT +#define M_ID_ERROR INITIATOR_ERROR +#define M_ABORT ABORT_TASK_SET +#define M_REJECT MESSAGE_REJECT +#define M_NOOP NOP +#define M_PARITY MSG_PARITY_ERROR +#define M_LCOMPLETE LINKED_CMD_COMPLETE +#define M_FCOMPLETE LINKED_FLG_CMD_COMPLETE +#define M_RESET TARGET_RESET +#define M_ABORT_TAG ABORT_TASK +#define M_CLEAR_QUEUE CLEAR_TASK_SET +#define M_INIT_REC INITIATE_RECOVERY +#define M_REL_REC RELEASE_RECOVERY +#define M_TERMINATE (0x11) +#define M_SIMPLE_TAG SIMPLE_QUEUE_TAG +#define M_HEAD_TAG HEAD_OF_QUEUE_TAG +#define M_ORDERED_TAG ORDERED_QUEUE_TAG +#define M_IGN_RESIDUE IGNORE_WIDE_RESIDUE +#define M_IDENTIFY (0x80) + +#define M_X_MODIFY_DP EXTENDED_MODIFY_DATA_POINTER +#define M_X_SYNC_REQ EXTENDED_SDTR +#define M_X_WIDE_REQ EXTENDED_WDTR +#define M_X_PPR_REQ EXTENDED_PPR + +/* +** Status +*/ + +#define S_GOOD (0x00) +#define S_CHECK_COND (0x02) +#define S_COND_MET (0x04) +#define S_BUSY (0x08) +#define S_INT (0x10) +#define S_INT_COND_MET (0x14) +#define S_CONFLICT (0x18) +#define S_TERMINATED (0x20) +#define S_QUEUE_FULL (0x28) +#define S_ILLEGAL (0xff) +#define S_SENSE (0x80) + +/* + * End of ncrreg from FreeBSD + */ /* Build a scatter/gather entry. diff --git a/drivers/scsi/sym53c8xx_comm.h b/drivers/scsi/sym53c8xx_comm.h deleted file mode 100644 index 20ae2b1..0000000 --- a/drivers/scsi/sym53c8xx_comm.h +++ /dev/null @@ -1,792 +0,0 @@ -/****************************************************************************** -** High Performance device driver for the Symbios 53C896 controller. -** -** Copyright (C) 1998-2001 Gerard Roudier -** -** This driver also supports all the Symbios 53C8XX controller family, -** except 53C810 revisions < 16, 53C825 revisions < 16 and all -** revisions of 53C815 controllers. -** -** This driver is based on the Linux port of the FreeBSD ncr driver. -** -** Copyright (C) 1994 Wolfgang Stanglmeier -** -**----------------------------------------------------------------------------- -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -** -**----------------------------------------------------------------------------- -** -** The Linux port of the FreeBSD ncr driver has been achieved in -** november 1995 by: -** -** Gerard Roudier -** -** Being given that this driver originates from the FreeBSD version, and -** in order to keep synergy on both, any suggested enhancements and corrections -** received on Linux are automatically a potential candidate for the FreeBSD -** version. -** -** The original driver has been written for 386bsd and FreeBSD by -** Wolfgang Stanglmeier -** Stefan Esser -** -**----------------------------------------------------------------------------- -** -** Major contributions: -** -------------------- -** -** NVRAM detection and reading. -** Copyright (C) 1997 Richard Waltham -** -******************************************************************************* -*/ - -/*========================================================== -** -** Debugging tags -** -**========================================================== -*/ - -#define DEBUG_ALLOC (0x0001) -#define DEBUG_PHASE (0x0002) -#define DEBUG_QUEUE (0x0008) -#define DEBUG_RESULT (0x0010) -#define DEBUG_POINTER (0x0020) -#define DEBUG_SCRIPT (0x0040) -#define DEBUG_TINY (0x0080) -#define DEBUG_TIMING (0x0100) -#define DEBUG_NEGO (0x0200) -#define DEBUG_TAGS (0x0400) -#define DEBUG_SCATTER (0x0800) -#define DEBUG_IC (0x1000) - -/* -** Enable/Disable debug messages. -** Can be changed at runtime too. -*/ - -#ifdef SCSI_NCR_DEBUG_INFO_SUPPORT -static int ncr_debug = SCSI_NCR_DEBUG_FLAGS; - #define DEBUG_FLAGS ncr_debug -#else - #define DEBUG_FLAGS SCSI_NCR_DEBUG_FLAGS -#endif - -static inline struct list_head *ncr_list_pop(struct list_head *head) -{ - if (!list_empty(head)) { - struct list_head *elem = head->next; - - list_del(elem); - return elem; - } - - return NULL; -} - -#ifdef __sparc__ -#include -#endif - -/*========================================================== -** -** Simple power of two buddy-like allocator. -** -** This simple code is not intended to be fast, but to -** provide power of 2 aligned memory allocations. -** Since the SCRIPTS processor only supplies 8 bit -** arithmetic, this allocator allows simple and fast -** address calculations from the SCRIPTS code. -** In addition, cache line alignment is guaranteed for -** power of 2 cache line size. -** Enhanced in linux-2.3.44 to provide a memory pool -** per pcidev to support dynamic dma mapping. (I would -** have preferred a real bus astraction, btw). -** -**========================================================== -*/ - -#define MEMO_SHIFT 4 /* 16 bytes minimum memory chunk */ -#if PAGE_SIZE >= 8192 -#define MEMO_PAGE_ORDER 0 /* 1 PAGE maximum */ -#else -#define MEMO_PAGE_ORDER 1 /* 2 PAGES maximum */ -#endif -#define MEMO_FREE_UNUSED /* Free unused pages immediately */ -#define MEMO_WARN 1 -#define MEMO_GFP_FLAGS GFP_ATOMIC -#define MEMO_CLUSTER_SHIFT (PAGE_SHIFT+MEMO_PAGE_ORDER) -#define MEMO_CLUSTER_SIZE (1UL << MEMO_CLUSTER_SHIFT) -#define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1) - -typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */ -typedef struct device *m_bush_t; /* Something that addresses DMAable */ - -typedef struct m_link { /* Link between free memory chunks */ - struct m_link *next; -} m_link_s; - -typedef struct m_vtob { /* Virtual to Bus address translation */ - struct m_vtob *next; - m_addr_t vaddr; - m_addr_t baddr; -} m_vtob_s; -#define VTOB_HASH_SHIFT 5 -#define VTOB_HASH_SIZE (1UL << VTOB_HASH_SHIFT) -#define VTOB_HASH_MASK (VTOB_HASH_SIZE-1) -#define VTOB_HASH_CODE(m) \ - ((((m_addr_t) (m)) >> MEMO_CLUSTER_SHIFT) & VTOB_HASH_MASK) - -typedef struct m_pool { /* Memory pool of a given kind */ - m_bush_t bush; - m_addr_t (*getp)(struct m_pool *); - void (*freep)(struct m_pool *, m_addr_t); - int nump; - m_vtob_s *(vtob[VTOB_HASH_SIZE]); - struct m_pool *next; - struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1]; -} m_pool_s; - -static void *___m_alloc(m_pool_s *mp, int size) -{ - int i = 0; - int s = (1 << MEMO_SHIFT); - int j; - m_addr_t a; - m_link_s *h = mp->h; - - if (size > (PAGE_SIZE << MEMO_PAGE_ORDER)) - return NULL; - - while (size > s) { - s <<= 1; - ++i; - } - - j = i; - while (!h[j].next) { - if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) { - h[j].next = (m_link_s *)mp->getp(mp); - if (h[j].next) - h[j].next->next = NULL; - break; - } - ++j; - s <<= 1; - } - a = (m_addr_t) h[j].next; - if (a) { - h[j].next = h[j].next->next; - while (j > i) { - j -= 1; - s >>= 1; - h[j].next = (m_link_s *) (a+s); - h[j].next->next = NULL; - } - } -#ifdef DEBUG - printk("___m_alloc(%d) = %p\n", size, (void *) a); -#endif - return (void *) a; -} - -static void ___m_free(m_pool_s *mp, void *ptr, int size) -{ - int i = 0; - int s = (1 << MEMO_SHIFT); - m_link_s *q; - m_addr_t a, b; - m_link_s *h = mp->h; - -#ifdef DEBUG - printk("___m_free(%p, %d)\n", ptr, size); -#endif - - if (size > (PAGE_SIZE << MEMO_PAGE_ORDER)) - return; - - while (size > s) { - s <<= 1; - ++i; - } - - a = (m_addr_t) ptr; - - while (1) { -#ifdef MEMO_FREE_UNUSED - if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) { - mp->freep(mp, a); - break; - } -#endif - b = a ^ s; - q = &h[i]; - while (q->next && q->next != (m_link_s *) b) { - q = q->next; - } - if (!q->next) { - ((m_link_s *) a)->next = h[i].next; - h[i].next = (m_link_s *) a; - break; - } - q->next = q->next->next; - a = a & b; - s <<= 1; - ++i; - } -} - -static DEFINE_SPINLOCK(ncr53c8xx_lock); - -static void *__m_calloc2(m_pool_s *mp, int size, char *name, int uflags) -{ - void *p; - - p = ___m_alloc(mp, size); - - if (DEBUG_FLAGS & DEBUG_ALLOC) - printk ("new %-10s[%4d] @%p.\n", name, size, p); - - if (p) - memset(p, 0, size); - else if (uflags & MEMO_WARN) - printk (NAME53C8XX ": failed to allocate %s[%d]\n", name, size); - - return p; -} - -#define __m_calloc(mp, s, n) __m_calloc2(mp, s, n, MEMO_WARN) - -static void __m_free(m_pool_s *mp, void *ptr, int size, char *name) -{ - if (DEBUG_FLAGS & DEBUG_ALLOC) - printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr); - - ___m_free(mp, ptr, size); - -} - -/* - * With pci bus iommu support, we use a default pool of unmapped memory - * for memory we donnot need to DMA from/to and one pool per pcidev for - * memory accessed by the PCI chip. `mp0' is the default not DMAable pool. - */ - -static m_addr_t ___mp0_getp(m_pool_s *mp) -{ - m_addr_t m = __get_free_pages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER); - if (m) - ++mp->nump; - return m; -} - -static void ___mp0_freep(m_pool_s *mp, m_addr_t m) -{ - free_pages(m, MEMO_PAGE_ORDER); - --mp->nump; -} - -static m_pool_s mp0 = {NULL, ___mp0_getp, ___mp0_freep}; - -/* - * DMAable pools. - */ - -/* - * With pci bus iommu support, we maintain one pool per pcidev and a - * hashed reverse table for virtual to bus physical address translations. - */ -static m_addr_t ___dma_getp(m_pool_s *mp) -{ - m_addr_t vp; - m_vtob_s *vbp; - - vbp = __m_calloc(&mp0, sizeof(*vbp), "VTOB"); - if (vbp) { - dma_addr_t daddr; - vp = (m_addr_t) dma_alloc_coherent(mp->bush, - PAGE_SIZE<vaddr = vp; - vbp->baddr = daddr; - vbp->next = mp->vtob[hc]; - mp->vtob[hc] = vbp; - ++mp->nump; - return vp; - } - } - if (vbp) - __m_free(&mp0, vbp, sizeof(*vbp), "VTOB"); - return 0; -} - -static void ___dma_freep(m_pool_s *mp, m_addr_t m) -{ - m_vtob_s **vbpp, *vbp; - int hc = VTOB_HASH_CODE(m); - - vbpp = &mp->vtob[hc]; - while (*vbpp && (*vbpp)->vaddr != m) - vbpp = &(*vbpp)->next; - if (*vbpp) { - vbp = *vbpp; - *vbpp = (*vbpp)->next; - dma_free_coherent(mp->bush, PAGE_SIZE<vaddr, (dma_addr_t)vbp->baddr); - __m_free(&mp0, vbp, sizeof(*vbp), "VTOB"); - --mp->nump; - } -} - -static inline m_pool_s *___get_dma_pool(m_bush_t bush) -{ - m_pool_s *mp; - for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next); - return mp; -} - -static m_pool_s *___cre_dma_pool(m_bush_t bush) -{ - m_pool_s *mp; - mp = __m_calloc(&mp0, sizeof(*mp), "MPOOL"); - if (mp) { - memset(mp, 0, sizeof(*mp)); - mp->bush = bush; - mp->getp = ___dma_getp; - mp->freep = ___dma_freep; - mp->next = mp0.next; - mp0.next = mp; - } - return mp; -} - -static void ___del_dma_pool(m_pool_s *p) -{ - struct m_pool **pp = &mp0.next; - - while (*pp && *pp != p) - pp = &(*pp)->next; - if (*pp) { - *pp = (*pp)->next; - __m_free(&mp0, p, sizeof(*p), "MPOOL"); - } -} - -static void *__m_calloc_dma(m_bush_t bush, int size, char *name) -{ - u_long flags; - struct m_pool *mp; - void *m = NULL; - - spin_lock_irqsave(&ncr53c8xx_lock, flags); - mp = ___get_dma_pool(bush); - if (!mp) - mp = ___cre_dma_pool(bush); - if (mp) - m = __m_calloc(mp, size, name); - if (mp && !mp->nump) - ___del_dma_pool(mp); - spin_unlock_irqrestore(&ncr53c8xx_lock, flags); - - return m; -} - -static void __m_free_dma(m_bush_t bush, void *m, int size, char *name) -{ - u_long flags; - struct m_pool *mp; - - spin_lock_irqsave(&ncr53c8xx_lock, flags); - mp = ___get_dma_pool(bush); - if (mp) - __m_free(mp, m, size, name); - if (mp && !mp->nump) - ___del_dma_pool(mp); - spin_unlock_irqrestore(&ncr53c8xx_lock, flags); -} - -static m_addr_t __vtobus(m_bush_t bush, void *m) -{ - u_long flags; - m_pool_s *mp; - int hc = VTOB_HASH_CODE(m); - m_vtob_s *vp = NULL; - m_addr_t a = ((m_addr_t) m) & ~MEMO_CLUSTER_MASK; - - spin_lock_irqsave(&ncr53c8xx_lock, flags); - mp = ___get_dma_pool(bush); - if (mp) { - vp = mp->vtob[hc]; - while (vp && (m_addr_t) vp->vaddr != a) - vp = vp->next; - } - spin_unlock_irqrestore(&ncr53c8xx_lock, flags); - return vp ? vp->baddr + (((m_addr_t) m) - a) : 0; -} - -#define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n) -#define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n) -#define m_calloc_dma(s, n) _m_calloc_dma(np, s, n) -#define m_free_dma(p, s, n) _m_free_dma(np, p, s, n) -#define _vtobus(np, p) __vtobus(np->dev, p) -#define vtobus(p) _vtobus(np, p) - -/* - * Deal with DMA mapping/unmapping. - */ - -/* To keep track of the dma mapping (sg/single) that has been set */ -#define __data_mapped SCp.phase -#define __data_mapping SCp.have_data_in - -static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd) -{ - switch(cmd->__data_mapped) { - case 2: - dma_unmap_sg(dev, cmd->buffer, cmd->use_sg, - cmd->sc_data_direction); - break; - case 1: - dma_unmap_single(dev, cmd->__data_mapping, - cmd->request_bufflen, - cmd->sc_data_direction); - break; - } - cmd->__data_mapped = 0; -} - -static u_long __map_scsi_single_data(struct device *dev, struct scsi_cmnd *cmd) -{ - dma_addr_t mapping; - - if (cmd->request_bufflen == 0) - return 0; - - mapping = dma_map_single(dev, cmd->request_buffer, - cmd->request_bufflen, - cmd->sc_data_direction); - cmd->__data_mapped = 1; - cmd->__data_mapping = mapping; - - return mapping; -} - -static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd) -{ - int use_sg; - - if (cmd->use_sg == 0) - return 0; - - use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg, - cmd->sc_data_direction); - cmd->__data_mapped = 2; - cmd->__data_mapping = use_sg; - - return use_sg; -} - -#define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd) -#define map_scsi_single_data(np, cmd) __map_scsi_single_data(np->dev, cmd) -#define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd) - -/*========================================================== -** -** Driver setup. -** -** This structure is initialized from linux config -** options. It can be overridden at boot-up by the boot -** command line. -** -**========================================================== -*/ -static struct ncr_driver_setup - driver_setup = SCSI_NCR_DRIVER_SETUP; - -#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT -static struct ncr_driver_setup - driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP; -#endif - -#define initverbose (driver_setup.verbose) -#define bootverbose (np->verbose) - - -/*=================================================================== -** -** Driver setup from the boot command line -** -**=================================================================== -*/ - -#ifdef MODULE -#define ARG_SEP ' ' -#else -#define ARG_SEP ',' -#endif - -#define OPT_TAGS 1 -#define OPT_MASTER_PARITY 2 -#define OPT_SCSI_PARITY 3 -#define OPT_DISCONNECTION 4 -#define OPT_SPECIAL_FEATURES 5 -#define OPT_UNUSED_1 6 -#define OPT_FORCE_SYNC_NEGO 7 -#define OPT_REVERSE_PROBE 8 -#define OPT_DEFAULT_SYNC 9 -#define OPT_VERBOSE 10 -#define OPT_DEBUG 11 -#define OPT_BURST_MAX 12 -#define OPT_LED_PIN 13 -#define OPT_MAX_WIDE 14 -#define OPT_SETTLE_DELAY 15 -#define OPT_DIFF_SUPPORT 16 -#define OPT_IRQM 17 -#define OPT_PCI_FIX_UP 18 -#define OPT_BUS_CHECK 19 -#define OPT_OPTIMIZE 20 -#define OPT_RECOVERY 21 -#define OPT_SAFE_SETUP 22 -#define OPT_USE_NVRAM 23 -#define OPT_EXCLUDE 24 -#define OPT_HOST_ID 25 - -#ifdef SCSI_NCR_IARB_SUPPORT -#define OPT_IARB 26 -#endif - -static char setup_token[] __initdata = - "tags:" "mpar:" - "spar:" "disc:" - "specf:" "ultra:" - "fsn:" "revprob:" - "sync:" "verb:" - "debug:" "burst:" - "led:" "wide:" - "settle:" "diff:" - "irqm:" "pcifix:" - "buschk:" "optim:" - "recovery:" - "safe:" "nvram:" - "excl:" "hostid:" -#ifdef SCSI_NCR_IARB_SUPPORT - "iarb:" -#endif - ; /* DONNOT REMOVE THIS ';' */ - -#ifdef MODULE -#define ARG_SEP ' ' -#else -#define ARG_SEP ',' -#endif - -static int __init get_setup_token(char *p) -{ - char *cur = setup_token; - char *pc; - int i = 0; - - while (cur != NULL && (pc = strchr(cur, ':')) != NULL) { - ++pc; - ++i; - if (!strncmp(p, cur, pc - cur)) - return i; - cur = pc; - } - return 0; -} - - -static int __init sym53c8xx__setup(char *str) -{ -#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT - char *cur = str; - char *pc, *pv; - int i, val, c; - int xi = 0; - - while (cur != NULL && (pc = strchr(cur, ':')) != NULL) { - char *pe; - - val = 0; - pv = pc; - c = *++pv; - - if (c == 'n') - val = 0; - else if (c == 'y') - val = 1; - else - val = (int) simple_strtoul(pv, &pe, 0); - - switch (get_setup_token(cur)) { - case OPT_TAGS: - driver_setup.default_tags = val; - if (pe && *pe == '/') { - i = 0; - while (*pe && *pe != ARG_SEP && - i < sizeof(driver_setup.tag_ctrl)-1) { - driver_setup.tag_ctrl[i++] = *pe++; - } - driver_setup.tag_ctrl[i] = '\0'; - } - break; - case OPT_MASTER_PARITY: - driver_setup.master_parity = val; - break; - case OPT_SCSI_PARITY: - driver_setup.scsi_parity = val; - break; - case OPT_DISCONNECTION: - driver_setup.disconnection = val; - break; - case OPT_SPECIAL_FEATURES: - driver_setup.special_features = val; - break; - case OPT_FORCE_SYNC_NEGO: - driver_setup.force_sync_nego = val; - break; - case OPT_REVERSE_PROBE: - driver_setup.reverse_probe = val; - break; - case OPT_DEFAULT_SYNC: - driver_setup.default_sync = val; - break; - case OPT_VERBOSE: - driver_setup.verbose = val; - break; - case OPT_DEBUG: - driver_setup.debug = val; - break; - case OPT_BURST_MAX: - driver_setup.burst_max = val; - break; - case OPT_LED_PIN: - driver_setup.led_pin = val; - break; - case OPT_MAX_WIDE: - driver_setup.max_wide = val? 1:0; - break; - case OPT_SETTLE_DELAY: - driver_setup.settle_delay = val; - break; - case OPT_DIFF_SUPPORT: - driver_setup.diff_support = val; - break; - case OPT_IRQM: - driver_setup.irqm = val; - break; - case OPT_PCI_FIX_UP: - driver_setup.pci_fix_up = val; - break; - case OPT_BUS_CHECK: - driver_setup.bus_check = val; - break; - case OPT_OPTIMIZE: - driver_setup.optimize = val; - break; - case OPT_RECOVERY: - driver_setup.recovery = val; - break; - case OPT_USE_NVRAM: - driver_setup.use_nvram = val; - break; - case OPT_SAFE_SETUP: - memcpy(&driver_setup, &driver_safe_setup, - sizeof(driver_setup)); - break; - case OPT_EXCLUDE: - if (xi < SCSI_NCR_MAX_EXCLUDES) - driver_setup.excludes[xi++] = val; - break; - case OPT_HOST_ID: - driver_setup.host_id = val; - break; -#ifdef SCSI_NCR_IARB_SUPPORT - case OPT_IARB: - driver_setup.iarb = val; - break; -#endif - default: - printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur); - break; - } - - if ((cur = strchr(cur, ARG_SEP)) != NULL) - ++cur; - } -#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */ - return 1; -} - -/*=================================================================== -** -** Get device queue depth from boot command line. -** -**=================================================================== -*/ -#define DEF_DEPTH (driver_setup.default_tags) -#define ALL_TARGETS -2 -#define NO_TARGET -1 -#define ALL_LUNS -2 -#define NO_LUN -1 - -static int device_queue_depth(int unit, int target, int lun) -{ - int c, h, t, u, v; - char *p = driver_setup.tag_ctrl; - char *ep; - - h = -1; - t = NO_TARGET; - u = NO_LUN; - while ((c = *p++) != 0) { - v = simple_strtoul(p, &ep, 0); - switch(c) { - case '/': - ++h; - t = ALL_TARGETS; - u = ALL_LUNS; - break; - case 't': - if (t != target) - t = (target == v) ? v : NO_TARGET; - u = ALL_LUNS; - break; - case 'u': - if (u != lun) - u = (lun == v) ? v : NO_LUN; - break; - case 'q': - if (h == unit && - (t == ALL_TARGETS || t == target) && - (u == ALL_LUNS || u == lun)) - return v; - break; - case '-': - t = ALL_TARGETS; - u = ALL_LUNS; - break; - default: - break; - } - p = ep; - } - return DEF_DEPTH; -} diff --git a/drivers/scsi/sym53c8xx_defs.h b/drivers/scsi/sym53c8xx_defs.h deleted file mode 100644 index 139cd0e..0000000 --- a/drivers/scsi/sym53c8xx_defs.h +++ /dev/null @@ -1,1320 +0,0 @@ -/****************************************************************************** -** High Performance device driver for the Symbios 53C896 controller. -** -** Copyright (C) 1998-2001 Gerard Roudier -** -** This driver also supports all the Symbios 53C8XX controller family, -** except 53C810 revisions < 16, 53C825 revisions < 16 and all -** revisions of 53C815 controllers. -** -** This driver is based on the Linux port of the FreeBSD ncr driver. -** -** Copyright (C) 1994 Wolfgang Stanglmeier -** -**----------------------------------------------------------------------------- -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -** -**----------------------------------------------------------------------------- -** -** The Linux port of the FreeBSD ncr driver has been achieved in -** november 1995 by: -** -** Gerard Roudier -** -** Being given that this driver originates from the FreeBSD version, and -** in order to keep synergy on both, any suggested enhancements and corrections -** received on Linux are automatically a potential candidate for the FreeBSD -** version. -** -** The original driver has been written for 386bsd and FreeBSD by -** Wolfgang Stanglmeier -** Stefan Esser -** -**----------------------------------------------------------------------------- -** -** Major contributions: -** -------------------- -** -** NVRAM detection and reading. -** Copyright (C) 1997 Richard Waltham -** -** Added support for MIPS big endian systems. -** Carsten Langgaard, carstenl@mips.com -** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. -** -** Added support for HP PARISC big endian systems. -** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. -** -******************************************************************************* -*/ - -#ifndef SYM53C8XX_DEFS_H -#define SYM53C8XX_DEFS_H - -#include - -/* -** If you want a driver as small as possible, donnot define the -** following options. -*/ -#define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT -#define SCSI_NCR_DEBUG_INFO_SUPPORT - -/* -** To disable integrity checking, do not define the -** following option. -*/ -#ifdef CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK -# define SCSI_NCR_ENABLE_INTEGRITY_CHECK -#endif - -/* --------------------------------------------------------------------- -** Take into account kernel configured parameters. -** Most of these options can be overridden at startup by a command line. -** --------------------------------------------------------------------- -*/ - -/* - * For Ultra2 and Ultra3 SCSI support option, use special features. - * - * Value (default) means: - * bit 0 : all features enabled, except: - * bit 1 : PCI Write And Invalidate. - * bit 2 : Data Phase Mismatch handling from SCRIPTS. - * - * Use boot options ncr53c8xx=specf:1 if you want all chip features to be - * enabled by the driver. - */ -#define SCSI_NCR_SETUP_SPECIAL_FEATURES (3) - -#define SCSI_NCR_MAX_SYNC (80) - -/* - * Allow tags from 2 to 256, default 8 - */ -#ifdef CONFIG_SCSI_NCR53C8XX_MAX_TAGS -#if CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2 -#define SCSI_NCR_MAX_TAGS (2) -#elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256 -#define SCSI_NCR_MAX_TAGS (256) -#else -#define SCSI_NCR_MAX_TAGS CONFIG_SCSI_NCR53C8XX_MAX_TAGS -#endif -#else -#define SCSI_NCR_MAX_TAGS (8) -#endif - -/* - * Allow tagged command queuing support if configured with default number - * of tags set to max (see above). - */ -#ifdef CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS -#define SCSI_NCR_SETUP_DEFAULT_TAGS CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS -#elif defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE -#define SCSI_NCR_SETUP_DEFAULT_TAGS SCSI_NCR_MAX_TAGS -#else -#define SCSI_NCR_SETUP_DEFAULT_TAGS (0) -#endif - -/* - * Immediate arbitration - */ -#if defined(CONFIG_SCSI_NCR53C8XX_IARB) -#define SCSI_NCR_IARB_SUPPORT -#endif - -/* - * Sync transfer frequency at startup. - * Allow from 5Mhz to 80Mhz default 20 Mhz. - */ -#ifndef CONFIG_SCSI_NCR53C8XX_SYNC -#define CONFIG_SCSI_NCR53C8XX_SYNC (20) -#elif CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC -#undef CONFIG_SCSI_NCR53C8XX_SYNC -#define CONFIG_SCSI_NCR53C8XX_SYNC SCSI_NCR_MAX_SYNC -#endif - -#if CONFIG_SCSI_NCR53C8XX_SYNC == 0 -#define SCSI_NCR_SETUP_DEFAULT_SYNC (255) -#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 5 -#define SCSI_NCR_SETUP_DEFAULT_SYNC (50) -#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 20 -#define SCSI_NCR_SETUP_DEFAULT_SYNC (250/(CONFIG_SCSI_NCR53C8XX_SYNC)) -#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 33 -#define SCSI_NCR_SETUP_DEFAULT_SYNC (11) -#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 40 -#define SCSI_NCR_SETUP_DEFAULT_SYNC (10) -#else -#define SCSI_NCR_SETUP_DEFAULT_SYNC (9) -#endif - -/* - * Disallow disconnections at boot-up - */ -#ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT -#define SCSI_NCR_SETUP_DISCONNECTION (0) -#else -#define SCSI_NCR_SETUP_DISCONNECTION (1) -#endif - -/* - * Force synchronous negotiation for all targets - */ -#ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO -#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (1) -#else -#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (0) -#endif - -/* - * Disable master parity checking (flawed hardwares need that) - */ -#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK -#define SCSI_NCR_SETUP_MASTER_PARITY (0) -#else -#define SCSI_NCR_SETUP_MASTER_PARITY (1) -#endif - -/* - * Disable scsi parity checking (flawed devices may need that) - */ -#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK -#define SCSI_NCR_SETUP_SCSI_PARITY (0) -#else -#define SCSI_NCR_SETUP_SCSI_PARITY (1) -#endif - -/* - * Settle time after reset at boot-up - */ -#define SCSI_NCR_SETUP_SETTLE_TIME (2) - -/* -** Bridge quirks work-around option defaulted to 1. -*/ -#ifndef SCSI_NCR_PCIQ_WORK_AROUND_OPT -#define SCSI_NCR_PCIQ_WORK_AROUND_OPT 1 -#endif - -/* -** Work-around common bridge misbehaviour. -** -** - Do not flush posted writes in the opposite -** direction on read. -** - May reorder DMA writes to memory. -** -** This option should not affect performances -** significantly, so it is the default. -*/ -#if SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1 -#define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM -#define SCSI_NCR_PCIQ_MAY_REORDER_WRITES -#define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS - -/* -** Same as option 1, but also deal with -** misconfigured interrupts. -** -** - Edge triggerred instead of level sensitive. -** - No interrupt line connected. -** - IRQ number misconfigured. -** -** If no interrupt is delivered, the driver will -** catch the interrupt conditions 10 times per -** second. No need to say that this option is -** not recommended. -*/ -#elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2 -#define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM -#define SCSI_NCR_PCIQ_MAY_REORDER_WRITES -#define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS -#define SCSI_NCR_PCIQ_BROKEN_INTR - -/* -** Some bridge designers decided to flush -** everything prior to deliver the interrupt. -** This option tries to deal with such a -** behaviour. -*/ -#elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3 -#define SCSI_NCR_PCIQ_SYNC_ON_INTR -#endif - -/* -** Other parameters not configurable with "make config" -** Avoid to change these constants, unless you know what you are doing. -*/ - -#define SCSI_NCR_ALWAYS_SIMPLE_TAG -#define SCSI_NCR_MAX_SCATTER (127) -#define SCSI_NCR_MAX_TARGET (16) - -/* -** Compute some desirable value for CAN_QUEUE -** and CMD_PER_LUN. -** The driver will use lower values if these -** ones appear to be too large. -*/ -#define SCSI_NCR_CAN_QUEUE (8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET) -#define SCSI_NCR_CMD_PER_LUN (SCSI_NCR_MAX_TAGS) - -#define SCSI_NCR_SG_TABLESIZE (SCSI_NCR_MAX_SCATTER) -#define SCSI_NCR_TIMER_INTERVAL (HZ) - -#if 1 /* defined CONFIG_SCSI_MULTI_LUN */ -#define SCSI_NCR_MAX_LUN (16) -#else -#define SCSI_NCR_MAX_LUN (1) -#endif - -/* - * IO functions definition for big/little endian CPU support. - * For now, the NCR is only supported in little endian addressing mode, - */ - -#ifdef __BIG_ENDIAN - -#define inw_l2b inw -#define inl_l2b inl -#define outw_b2l outw -#define outl_b2l outl - -#define readb_raw readb -#define writeb_raw writeb - -#if defined(SCSI_NCR_BIG_ENDIAN) -#define readw_l2b __raw_readw -#define readl_l2b __raw_readl -#define writew_b2l __raw_writew -#define writel_b2l __raw_writel -#define readw_raw __raw_readw -#define readl_raw __raw_readl -#define writew_raw __raw_writew -#define writel_raw __raw_writel -#else /* Other big-endian */ -#define readw_l2b readw -#define readl_l2b readl -#define writew_b2l writew -#define writel_b2l writel -#define readw_raw readw -#define readl_raw readl -#define writew_raw writew -#define writel_raw writel -#endif - -#else /* little endian */ - -#define inw_raw inw -#define inl_raw inl -#define outw_raw outw -#define outl_raw outl - -#define readb_raw readb -#define readw_raw readw -#define readl_raw readl -#define writeb_raw writeb -#define writew_raw writew -#define writel_raw writel - -#endif - -#if !defined(__hppa__) && !defined(__mips__) -#ifdef SCSI_NCR_BIG_ENDIAN -#error "The NCR in BIG ENDIAN addressing mode is not (yet) supported" -#endif -#endif - -#define MEMORY_BARRIER() mb() - - -/* - * If the NCR uses big endian addressing mode over the - * PCI, actual io register addresses for byte and word - * accesses must be changed according to lane routing. - * Btw, ncr_offb() and ncr_offw() macros only apply to - * constants and so donnot generate bloated code. - */ - -#if defined(SCSI_NCR_BIG_ENDIAN) - -#define ncr_offb(o) (((o)&~3)+((~((o)&3))&3)) -#define ncr_offw(o) (((o)&~3)+((~((o)&3))&2)) - -#else - -#define ncr_offb(o) (o) -#define ncr_offw(o) (o) - -#endif - -/* - * If the CPU and the NCR use same endian-ness addressing, - * no byte reordering is needed for script patching. - * Macro cpu_to_scr() is to be used for script patching. - * Macro scr_to_cpu() is to be used for getting a DWORD - * from the script. - */ - -#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN) - -#define cpu_to_scr(dw) cpu_to_le32(dw) -#define scr_to_cpu(dw) le32_to_cpu(dw) - -#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN) - -#define cpu_to_scr(dw) cpu_to_be32(dw) -#define scr_to_cpu(dw) be32_to_cpu(dw) - -#else - -#define cpu_to_scr(dw) (dw) -#define scr_to_cpu(dw) (dw) - -#endif - -/* - * Access to the controller chip. - * - * If the CPU and the NCR use same endian-ness addressing, - * no byte reordering is needed for accessing chip io - * registers. Functions suffixed by '_raw' are assumed - * to access the chip over the PCI without doing byte - * reordering. Functions suffixed by '_l2b' are - * assumed to perform little-endian to big-endian byte - * reordering, those suffixed by '_b2l' blah, blah, - * blah, ... - */ - -/* - * MEMORY mapped IO input / output - */ - -#define INB_OFF(o) readb_raw((char __iomem *)np->reg + ncr_offb(o)) -#define OUTB_OFF(o, val) writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o)) - -#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN) - -#define INW_OFF(o) readw_l2b((char __iomem *)np->reg + ncr_offw(o)) -#define INL_OFF(o) readl_l2b((char __iomem *)np->reg + (o)) - -#define OUTW_OFF(o, val) writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o)) -#define OUTL_OFF(o, val) writel_b2l((val), (char __iomem *)np->reg + (o)) - -#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN) - -#define INW_OFF(o) readw_b2l((char __iomem *)np->reg + ncr_offw(o)) -#define INL_OFF(o) readl_b2l((char __iomem *)np->reg + (o)) - -#define OUTW_OFF(o, val) writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o)) -#define OUTL_OFF(o, val) writel_l2b((val), (char __iomem *)np->reg + (o)) - -#else - -#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS -/* Only 8 or 32 bit transfers allowed */ -#define INW_OFF(o) (readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1)) -#else -#define INW_OFF(o) readw_raw((char __iomem *)np->reg + ncr_offw(o)) -#endif -#define INL_OFF(o) readl_raw((char __iomem *)np->reg + (o)) - -#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS -/* Only 8 or 32 bit transfers allowed */ -#define OUTW_OFF(o, val) do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0) -#else -#define OUTW_OFF(o, val) writew_raw((val), (char __iomem *)np->reg + ncr_offw(o)) -#endif -#define OUTL_OFF(o, val) writel_raw((val), (char __iomem *)np->reg + (o)) - -#endif - -#define INB(r) INB_OFF (offsetof(struct ncr_reg,r)) -#define INW(r) INW_OFF (offsetof(struct ncr_reg,r)) -#define INL(r) INL_OFF (offsetof(struct ncr_reg,r)) - -#define OUTB(r, val) OUTB_OFF (offsetof(struct ncr_reg,r), (val)) -#define OUTW(r, val) OUTW_OFF (offsetof(struct ncr_reg,r), (val)) -#define OUTL(r, val) OUTL_OFF (offsetof(struct ncr_reg,r), (val)) - -/* - * Set bit field ON, OFF - */ - -#define OUTONB(r, m) OUTB(r, INB(r) | (m)) -#define OUTOFFB(r, m) OUTB(r, INB(r) & ~(m)) -#define OUTONW(r, m) OUTW(r, INW(r) | (m)) -#define OUTOFFW(r, m) OUTW(r, INW(r) & ~(m)) -#define OUTONL(r, m) OUTL(r, INL(r) | (m)) -#define OUTOFFL(r, m) OUTL(r, INL(r) & ~(m)) - -/* - * We normally want the chip to have a consistent view - * of driver internal data structures when we restart it. - * Thus these macros. - */ -#define OUTL_DSP(v) \ - do { \ - MEMORY_BARRIER(); \ - OUTL (nc_dsp, (v)); \ - } while (0) - -#define OUTONB_STD() \ - do { \ - MEMORY_BARRIER(); \ - OUTONB (nc_dcntl, (STD|NOCOM)); \ - } while (0) - - -/* -** NCR53C8XX devices features table. -*/ -struct ncr_chip { - unsigned short revision_id; - unsigned char burst_max; /* log-base-2 of max burst */ - unsigned char offset_max; - unsigned char nr_divisor; - unsigned int features; -#define FE_LED0 (1<<0) -#define FE_WIDE (1<<1) /* Wide data transfers */ -#define FE_ULTRA (1<<2) /* Ultra speed 20Mtrans/sec */ -#define FE_DBLR (1<<4) /* Clock doubler present */ -#define FE_QUAD (1<<5) /* Clock quadrupler present */ -#define FE_ERL (1<<6) /* Enable read line */ -#define FE_CLSE (1<<7) /* Cache line size enable */ -#define FE_WRIE (1<<8) /* Write & Invalidate enable */ -#define FE_ERMP (1<<9) /* Enable read multiple */ -#define FE_BOF (1<<10) /* Burst opcode fetch */ -#define FE_DFS (1<<11) /* DMA fifo size */ -#define FE_PFEN (1<<12) /* Prefetch enable */ -#define FE_LDSTR (1<<13) /* Load/Store supported */ -#define FE_RAM (1<<14) /* On chip RAM present */ -#define FE_VARCLK (1<<15) /* SCSI clock may vary */ -#define FE_RAM8K (1<<16) /* On chip RAM sized 8Kb */ -#define FE_64BIT (1<<17) /* Have a 64-bit PCI interface */ -#define FE_IO256 (1<<18) /* Requires full 256 bytes in PCI space */ -#define FE_NOPM (1<<19) /* Scripts handles phase mismatch */ -#define FE_LEDC (1<<20) /* Hardware control of LED */ -#define FE_DIFF (1<<21) /* Support Differential SCSI */ -#define FE_66MHZ (1<<23) /* 66MHz PCI Support */ -#define FE_DAC (1<<24) /* Support DAC cycles (64 bit addressing) */ -#define FE_ISTAT1 (1<<25) /* Have ISTAT1, MBOX0, MBOX1 registers */ -#define FE_DAC_IN_USE (1<<26) /* Platform does DAC cycles */ -#define FE_EHP (1<<27) /* 720: Even host parity */ -#define FE_MUX (1<<28) /* 720: Multiplexed bus */ -#define FE_EA (1<<29) /* 720: Enable Ack */ - -#define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP) -#define FE_SCSI_SET (FE_WIDE|FE_ULTRA|FE_DBLR|FE_QUAD|F_CLK80) -#define FE_SPECIAL_SET (FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM) -}; - - -/* -** Driver setup structure. -** -** This structure is initialized from linux config options. -** It can be overridden at boot-up by the boot command line. -*/ -#define SCSI_NCR_MAX_EXCLUDES 8 -struct ncr_driver_setup { - u8 master_parity; - u8 scsi_parity; - u8 disconnection; - u8 special_features; - u8 force_sync_nego; - u8 reverse_probe; - u8 pci_fix_up; - u8 use_nvram; - u8 verbose; - u8 default_tags; - u16 default_sync; - u16 debug; - u8 burst_max; - u8 led_pin; - u8 max_wide; - u8 settle_delay; - u8 diff_support; - u8 irqm; - u8 bus_check; - u8 optimize; - u8 recovery; - u8 host_id; - u16 iarb; - u32 excludes[SCSI_NCR_MAX_EXCLUDES]; - char tag_ctrl[100]; -}; - -/* -** Initial setup. -** Can be overriden at startup by a command line. -*/ -#define SCSI_NCR_DRIVER_SETUP \ -{ \ - SCSI_NCR_SETUP_MASTER_PARITY, \ - SCSI_NCR_SETUP_SCSI_PARITY, \ - SCSI_NCR_SETUP_DISCONNECTION, \ - SCSI_NCR_SETUP_SPECIAL_FEATURES, \ - SCSI_NCR_SETUP_FORCE_SYNC_NEGO, \ - 0, \ - 0, \ - 1, \ - 0, \ - SCSI_NCR_SETUP_DEFAULT_TAGS, \ - SCSI_NCR_SETUP_DEFAULT_SYNC, \ - 0x00, \ - 7, \ - 0, \ - 1, \ - SCSI_NCR_SETUP_SETTLE_TIME, \ - 0, \ - 0, \ - 1, \ - 0, \ - 0, \ - 255, \ - 0x00 \ -} - -/* -** Boot fail safe setup. -** Override initial setup from boot command line: -** ncr53c8xx=safe:y -*/ -#define SCSI_NCR_DRIVER_SAFE_SETUP \ -{ \ - 0, \ - 1, \ - 0, \ - 0, \ - 0, \ - 0, \ - 0, \ - 1, \ - 2, \ - 0, \ - 255, \ - 0x00, \ - 255, \ - 0, \ - 0, \ - 10, \ - 1, \ - 1, \ - 1, \ - 0, \ - 0, \ - 255 \ -} - -/**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/ - -/*----------------------------------------------------------------- -** -** The ncr 53c810 register structure. -** -**----------------------------------------------------------------- -*/ - -struct ncr_reg { -/*00*/ u8 nc_scntl0; /* full arb., ena parity, par->ATN */ - -/*01*/ u8 nc_scntl1; /* no reset */ - #define ISCON 0x10 /* connected to scsi */ - #define CRST 0x08 /* force reset */ - #define IARB 0x02 /* immediate arbitration */ - -/*02*/ u8 nc_scntl2; /* no disconnect expected */ - #define SDU 0x80 /* cmd: disconnect will raise error */ - #define CHM 0x40 /* sta: chained mode */ - #define WSS 0x08 /* sta: wide scsi send [W]*/ - #define WSR 0x01 /* sta: wide scsi received [W]*/ - -/*03*/ u8 nc_scntl3; /* cnf system clock dependent */ - #define EWS 0x08 /* cmd: enable wide scsi [W]*/ - #define ULTRA 0x80 /* cmd: ULTRA enable */ - /* bits 0-2, 7 rsvd for C1010 */ - -/*04*/ u8 nc_scid; /* cnf host adapter scsi address */ - #define RRE 0x40 /* r/w:e enable response to resel. */ - #define SRE 0x20 /* r/w:e enable response to select */ - -/*05*/ u8 nc_sxfer; /* ### Sync speed and count */ - /* bits 6-7 rsvd for C1010 */ - -/*06*/ u8 nc_sdid; /* ### Destination-ID */ - -/*07*/ u8 nc_gpreg; /* ??? IO-Pins */ - -/*08*/ u8 nc_sfbr; /* ### First byte in phase */ - -/*09*/ u8 nc_socl; - #define CREQ 0x80 /* r/w: SCSI-REQ */ - #define CACK 0x40 /* r/w: SCSI-ACK */ - #define CBSY 0x20 /* r/w: SCSI-BSY */ - #define CSEL 0x10 /* r/w: SCSI-SEL */ - #define CATN 0x08 /* r/w: SCSI-ATN */ - #define CMSG 0x04 /* r/w: SCSI-MSG */ - #define CC_D 0x02 /* r/w: SCSI-C_D */ - #define CI_O 0x01 /* r/w: SCSI-I_O */ - -/*0a*/ u8 nc_ssid; - -/*0b*/ u8 nc_sbcl; - -/*0c*/ u8 nc_dstat; - #define DFE 0x80 /* sta: dma fifo empty */ - #define MDPE 0x40 /* int: master data parity error */ - #define BF 0x20 /* int: script: bus fault */ - #define ABRT 0x10 /* int: script: command aborted */ - #define SSI 0x08 /* int: script: single step */ - #define SIR 0x04 /* int: script: interrupt instruct. */ - #define IID 0x01 /* int: script: illegal instruct. */ - -/*0d*/ u8 nc_sstat0; - #define ILF 0x80 /* sta: data in SIDL register lsb */ - #define ORF 0x40 /* sta: data in SODR register lsb */ - #define OLF 0x20 /* sta: data in SODL register lsb */ - #define AIP 0x10 /* sta: arbitration in progress */ - #define LOA 0x08 /* sta: arbitration lost */ - #define WOA 0x04 /* sta: arbitration won */ - #define IRST 0x02 /* sta: scsi reset signal */ - #define SDP 0x01 /* sta: scsi parity signal */ - -/*0e*/ u8 nc_sstat1; - #define FF3210 0xf0 /* sta: bytes in the scsi fifo */ - -/*0f*/ u8 nc_sstat2; - #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/ - #define ORF1 0x40 /* sta: data in SODR register msb[W]*/ - #define OLF1 0x20 /* sta: data in SODL register msb[W]*/ - #define DM 0x04 /* sta: DIFFSENS mismatch (895/6 only) */ - #define LDSC 0x02 /* sta: disconnect & reconnect */ - -/*10*/ u8 nc_dsa; /* --> Base page */ -/*11*/ u8 nc_dsa1; -/*12*/ u8 nc_dsa2; -/*13*/ u8 nc_dsa3; - -/*14*/ u8 nc_istat; /* --> Main Command and status */ - #define CABRT 0x80 /* cmd: abort current operation */ - #define SRST 0x40 /* mod: reset chip */ - #define SIGP 0x20 /* r/w: message from host to ncr */ - #define SEM 0x10 /* r/w: message between host + ncr */ - #define CON 0x08 /* sta: connected to scsi */ - #define INTF 0x04 /* sta: int on the fly (reset by wr)*/ - #define SIP 0x02 /* sta: scsi-interrupt */ - #define DIP 0x01 /* sta: host/script interrupt */ - -/*15*/ u8 nc_istat1; /* 896 and later cores only */ - #define FLSH 0x04 /* sta: chip is flushing */ - #define SRUN 0x02 /* sta: scripts are running */ - #define SIRQD 0x01 /* r/w: disable INT pin */ - -/*16*/ u8 nc_mbox0; /* 896 and later cores only */ -/*17*/ u8 nc_mbox1; /* 896 and later cores only */ - -/*18*/ u8 nc_ctest0; - #define EHP 0x04 /* 720 even host parity */ -/*19*/ u8 nc_ctest1; - -/*1a*/ u8 nc_ctest2; - #define CSIGP 0x40 - /* bits 0-2,7 rsvd for C1010 */ - -/*1b*/ u8 nc_ctest3; - #define FLF 0x08 /* cmd: flush dma fifo */ - #define CLF 0x04 /* cmd: clear dma fifo */ - #define FM 0x02 /* mod: fetch pin mode */ - #define WRIE 0x01 /* mod: write and invalidate enable */ - /* bits 4-7 rsvd for C1010 */ - -/*1c*/ u32 nc_temp; /* ### Temporary stack */ - -/*20*/ u8 nc_dfifo; -/*21*/ u8 nc_ctest4; - #define MUX 0x80 /* 720 host bus multiplex mode */ - #define BDIS 0x80 /* mod: burst disable */ - #define MPEE 0x08 /* mod: master parity error enable */ - -/*22*/ u8 nc_ctest5; - #define DFS 0x20 /* mod: dma fifo size */ - /* bits 0-1, 3-7 rsvd for C1010 */ -/*23*/ u8 nc_ctest6; - -/*24*/ u32 nc_dbc; /* ### Byte count and command */ -/*28*/ u32 nc_dnad; /* ### Next command register */ -/*2c*/ u32 nc_dsp; /* --> Script Pointer */ -/*30*/ u32 nc_dsps; /* --> Script pointer save/opcode#2 */ - -/*34*/ u8 nc_scratcha; /* Temporary register a */ -/*35*/ u8 nc_scratcha1; -/*36*/ u8 nc_scratcha2; -/*37*/ u8 nc_scratcha3; - -/*38*/ u8 nc_dmode; - #define BL_2 0x80 /* mod: burst length shift value +2 */ - #define BL_1 0x40 /* mod: burst length shift value +1 */ - #define ERL 0x08 /* mod: enable read line */ - #define ERMP 0x04 /* mod: enable read multiple */ - #define BOF 0x02 /* mod: burst op code fetch */ - -/*39*/ u8 nc_dien; -/*3a*/ u8 nc_sbr; - -/*3b*/ u8 nc_dcntl; /* --> Script execution control */ - #define CLSE 0x80 /* mod: cache line size enable */ - #define PFF 0x40 /* cmd: pre-fetch flush */ - #define PFEN 0x20 /* mod: pre-fetch enable */ - #define EA 0x20 /* mod: 720 enable-ack */ - #define SSM 0x10 /* mod: single step mode */ - #define IRQM 0x08 /* mod: irq mode (1 = totem pole !) */ - #define STD 0x04 /* cmd: start dma mode */ - #define IRQD 0x02 /* mod: irq disable */ - #define NOCOM 0x01 /* cmd: protect sfbr while reselect */ - /* bits 0-1 rsvd for C1010 */ - -/*3c*/ u32 nc_adder; - -/*40*/ u16 nc_sien; /* -->: interrupt enable */ -/*42*/ u16 nc_sist; /* <--: interrupt status */ - #define SBMC 0x1000/* sta: SCSI Bus Mode Change (895/6 only) */ - #define STO 0x0400/* sta: timeout (select) */ - #define GEN 0x0200/* sta: timeout (general) */ - #define HTH 0x0100/* sta: timeout (handshake) */ - #define MA 0x80 /* sta: phase mismatch */ - #define CMP 0x40 /* sta: arbitration complete */ - #define SEL 0x20 /* sta: selected by another device */ - #define RSL 0x10 /* sta: reselected by another device*/ - #define SGE 0x08 /* sta: gross error (over/underflow)*/ - #define UDC 0x04 /* sta: unexpected disconnect */ - #define RST 0x02 /* sta: scsi bus reset detected */ - #define PAR 0x01 /* sta: scsi parity error */ - -/*44*/ u8 nc_slpar; -/*45*/ u8 nc_swide; -/*46*/ u8 nc_macntl; -/*47*/ u8 nc_gpcntl; -/*48*/ u8 nc_stime0; /* cmd: timeout for select&handshake*/ -/*49*/ u8 nc_stime1; /* cmd: timeout user defined */ -/*4a*/ u16 nc_respid; /* sta: Reselect-IDs */ - -/*4c*/ u8 nc_stest0; - -/*4d*/ u8 nc_stest1; - #define SCLK 0x80 /* Use the PCI clock as SCSI clock */ - #define DBLEN 0x08 /* clock doubler running */ - #define DBLSEL 0x04 /* clock doubler selected */ - - -/*4e*/ u8 nc_stest2; - #define ROF 0x40 /* reset scsi offset (after gross error!) */ - #define DIF 0x20 /* 720 SCSI differential mode */ - #define EXT 0x02 /* extended filtering */ - -/*4f*/ u8 nc_stest3; - #define TE 0x80 /* c: tolerAnt enable */ - #define HSC 0x20 /* c: Halt SCSI Clock */ - #define CSF 0x02 /* c: clear scsi fifo */ - -/*50*/ u16 nc_sidl; /* Lowlevel: latched from scsi data */ -/*52*/ u8 nc_stest4; - #define SMODE 0xc0 /* SCSI bus mode (895/6 only) */ - #define SMODE_HVD 0x40 /* High Voltage Differential */ - #define SMODE_SE 0x80 /* Single Ended */ - #define SMODE_LVD 0xc0 /* Low Voltage Differential */ - #define LCKFRQ 0x20 /* Frequency Lock (895/6 only) */ - /* bits 0-5 rsvd for C1010 */ - -/*53*/ u8 nc_53_; -/*54*/ u16 nc_sodl; /* Lowlevel: data out to scsi data */ -/*56*/ u8 nc_ccntl0; /* Chip Control 0 (896) */ - #define ENPMJ 0x80 /* Enable Phase Mismatch Jump */ - #define PMJCTL 0x40 /* Phase Mismatch Jump Control */ - #define ENNDJ 0x20 /* Enable Non Data PM Jump */ - #define DISFC 0x10 /* Disable Auto FIFO Clear */ - #define DILS 0x02 /* Disable Internal Load/Store */ - #define DPR 0x01 /* Disable Pipe Req */ - -/*57*/ u8 nc_ccntl1; /* Chip Control 1 (896) */ - #define ZMOD 0x80 /* High Impedance Mode */ - #define DIC 0x10 /* Disable Internal Cycles */ - #define DDAC 0x08 /* Disable Dual Address Cycle */ - #define XTIMOD 0x04 /* 64-bit Table Ind. Indexing Mode */ - #define EXTIBMV 0x02 /* Enable 64-bit Table Ind. BMOV */ - #define EXDBMV 0x01 /* Enable 64-bit Direct BMOV */ - -/*58*/ u16 nc_sbdl; /* Lowlevel: data from scsi data */ -/*5a*/ u16 nc_5a_; - -/*5c*/ u8 nc_scr0; /* Working register B */ -/*5d*/ u8 nc_scr1; /* */ -/*5e*/ u8 nc_scr2; /* */ -/*5f*/ u8 nc_scr3; /* */ - -/*60*/ u8 nc_scrx[64]; /* Working register C-R */ -/*a0*/ u32 nc_mmrs; /* Memory Move Read Selector */ -/*a4*/ u32 nc_mmws; /* Memory Move Write Selector */ -/*a8*/ u32 nc_sfs; /* Script Fetch Selector */ -/*ac*/ u32 nc_drs; /* DSA Relative Selector */ -/*b0*/ u32 nc_sbms; /* Static Block Move Selector */ -/*b4*/ u32 nc_dbms; /* Dynamic Block Move Selector */ -/*b8*/ u32 nc_dnad64; /* DMA Next Address 64 */ -/*bc*/ u16 nc_scntl4; /* C1010 only */ - #define U3EN 0x80 /* Enable Ultra 3 */ - #define AIPEN 0x40 /* Allow check upper byte lanes */ - #define XCLKH_DT 0x08 /* Extra clock of data hold on DT - transfer edge */ - #define XCLKH_ST 0x04 /* Extra clock of data hold on ST - transfer edge */ - -/*be*/ u8 nc_aipcntl0; /* Epat Control 1 C1010 only */ -/*bf*/ u8 nc_aipcntl1; /* AIP Control C1010_66 Only */ - -/*c0*/ u32 nc_pmjad1; /* Phase Mismatch Jump Address 1 */ -/*c4*/ u32 nc_pmjad2; /* Phase Mismatch Jump Address 2 */ -/*c8*/ u8 nc_rbc; /* Remaining Byte Count */ -/*c9*/ u8 nc_rbc1; /* */ -/*ca*/ u8 nc_rbc2; /* */ -/*cb*/ u8 nc_rbc3; /* */ - -/*cc*/ u8 nc_ua; /* Updated Address */ -/*cd*/ u8 nc_ua1; /* */ -/*ce*/ u8 nc_ua2; /* */ -/*cf*/ u8 nc_ua3; /* */ -/*d0*/ u32 nc_esa; /* Entry Storage Address */ -/*d4*/ u8 nc_ia; /* Instruction Address */ -/*d5*/ u8 nc_ia1; -/*d6*/ u8 nc_ia2; -/*d7*/ u8 nc_ia3; -/*d8*/ u32 nc_sbc; /* SCSI Byte Count (3 bytes only) */ -/*dc*/ u32 nc_csbc; /* Cumulative SCSI Byte Count */ - - /* Following for C1010 only */ -/*e0*/ u16 nc_crcpad; /* CRC Value */ -/*e2*/ u8 nc_crccntl0; /* CRC control register */ - #define SNDCRC 0x10 /* Send CRC Request */ -/*e3*/ u8 nc_crccntl1; /* CRC control register */ -/*e4*/ u32 nc_crcdata; /* CRC data register */ -/*e8*/ u32 nc_e8_; /* rsvd */ -/*ec*/ u32 nc_ec_; /* rsvd */ -/*f0*/ u16 nc_dfbc; /* DMA FIFO byte count */ - -}; - -/*----------------------------------------------------------- -** -** Utility macros for the script. -** -**----------------------------------------------------------- -*/ - -#define REGJ(p,r) (offsetof(struct ncr_reg, p ## r)) -#define REG(r) REGJ (nc_, r) - -typedef u32 ncrcmd; - -/*----------------------------------------------------------- -** -** SCSI phases -** -** DT phases illegal for ncr driver. -** -**----------------------------------------------------------- -*/ - -#define SCR_DATA_OUT 0x00000000 -#define SCR_DATA_IN 0x01000000 -#define SCR_COMMAND 0x02000000 -#define SCR_STATUS 0x03000000 -#define SCR_DT_DATA_OUT 0x04000000 -#define SCR_DT_DATA_IN 0x05000000 -#define SCR_MSG_OUT 0x06000000 -#define SCR_MSG_IN 0x07000000 - -#define SCR_ILG_OUT 0x04000000 -#define SCR_ILG_IN 0x05000000 - -/*----------------------------------------------------------- -** -** Data transfer via SCSI. -** -**----------------------------------------------------------- -** -** MOVE_ABS (LEN) -** <> -** -** MOVE_IND (LEN) -** <> -** -** MOVE_TBL -** <> -** -**----------------------------------------------------------- -*/ - -#define OPC_MOVE 0x08000000 - -#define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l)) -#define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l)) -#define SCR_MOVE_TBL (0x10000000 | OPC_MOVE) - -#define SCR_CHMOV_ABS(l) ((0x00000000) | (l)) -#define SCR_CHMOV_IND(l) ((0x20000000) | (l)) -#define SCR_CHMOV_TBL (0x10000000) - -struct scr_tblmove { - u32 size; - u32 addr; -}; - -/*----------------------------------------------------------- -** -** Selection -** -**----------------------------------------------------------- -** -** SEL_ABS | SCR_ID (0..15) [ | REL_JMP] -** <> -** -** SEL_TBL | << dnad_offset>> [ | REL_JMP] -** <> -** -**----------------------------------------------------------- -*/ - -#define SCR_SEL_ABS 0x40000000 -#define SCR_SEL_ABS_ATN 0x41000000 -#define SCR_SEL_TBL 0x42000000 -#define SCR_SEL_TBL_ATN 0x43000000 - - -#ifdef SCSI_NCR_BIG_ENDIAN -struct scr_tblsel { - u8 sel_scntl3; - u8 sel_id; - u8 sel_sxfer; - u8 sel_scntl4; -}; -#else -struct scr_tblsel { - u8 sel_scntl4; - u8 sel_sxfer; - u8 sel_id; - u8 sel_scntl3; -}; -#endif - -#define SCR_JMP_REL 0x04000000 -#define SCR_ID(id) (((u32)(id)) << 16) - -/*----------------------------------------------------------- -** -** Waiting for Disconnect or Reselect -** -**----------------------------------------------------------- -** -** WAIT_DISC -** dummy: <> -** -** WAIT_RESEL -** <> -** -**----------------------------------------------------------- -*/ - -#define SCR_WAIT_DISC 0x48000000 -#define SCR_WAIT_RESEL 0x50000000 - -/*----------------------------------------------------------- -** -** Bit Set / Reset -** -**----------------------------------------------------------- -** -** SET (flags {|.. }) -** -** CLR (flags {|.. }) -** -**----------------------------------------------------------- -*/ - -#define SCR_SET(f) (0x58000000 | (f)) -#define SCR_CLR(f) (0x60000000 | (f)) - -#define SCR_CARRY 0x00000400 -#define SCR_TRG 0x00000200 -#define SCR_ACK 0x00000040 -#define SCR_ATN 0x00000008 - - - - -/*----------------------------------------------------------- -** -** Memory to memory move -** -**----------------------------------------------------------- -** -** COPY (bytecount) -** << source_address >> -** << destination_address >> -** -** SCR_COPY sets the NO FLUSH option by default. -** SCR_COPY_F does not set this option. -** -** For chips which do not support this option, -** ncr_copy_and_bind() will remove this bit. -**----------------------------------------------------------- -*/ - -#define SCR_NO_FLUSH 0x01000000 - -#define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n)) -#define SCR_COPY_F(n) (0xc0000000 | (n)) - -/*----------------------------------------------------------- -** -** Register move and binary operations -** -**----------------------------------------------------------- -** -** SFBR_REG (reg, op, data) reg = SFBR op data -** << 0 >> -** -** REG_SFBR (reg, op, data) SFBR = reg op data -** << 0 >> -** -** REG_REG (reg, op, data) reg = reg op data -** << 0 >> -** -**----------------------------------------------------------- -** On 810A, 860, 825A, 875, 895 and 896 chips the content -** of SFBR register can be used as data (SCR_SFBR_DATA). -** The 896 has additionnal IO registers starting at -** offset 0x80. Bit 7 of register offset is stored in -** bit 7 of the SCRIPTS instruction first DWORD. -**----------------------------------------------------------- -*/ - -#define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80)) - -#define SCR_SFBR_REG(reg,op,data) \ - (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul)) - -#define SCR_REG_SFBR(reg,op,data) \ - (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul)) - -#define SCR_REG_REG(reg,op,data) \ - (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul)) - - -#define SCR_LOAD 0x00000000 -#define SCR_SHL 0x01000000 -#define SCR_OR 0x02000000 -#define SCR_XOR 0x03000000 -#define SCR_AND 0x04000000 -#define SCR_SHR 0x05000000 -#define SCR_ADD 0x06000000 -#define SCR_ADDC 0x07000000 - -#define SCR_SFBR_DATA (0x00800000>>8ul) /* Use SFBR as data */ - -/*----------------------------------------------------------- -** -** FROM_REG (reg) SFBR = reg -** << 0 >> -** -** TO_REG (reg) reg = SFBR -** << 0 >> -** -** LOAD_REG (reg, data) reg = -** << 0 >> -** -** LOAD_SFBR(data) SFBR = -** << 0 >> -** -**----------------------------------------------------------- -*/ - -#define SCR_FROM_REG(reg) \ - SCR_REG_SFBR(reg,SCR_OR,0) - -#define SCR_TO_REG(reg) \ - SCR_SFBR_REG(reg,SCR_OR,0) - -#define SCR_LOAD_REG(reg,data) \ - SCR_REG_REG(reg,SCR_LOAD,data) - -#define SCR_LOAD_SFBR(data) \ - (SCR_REG_SFBR (gpreg, SCR_LOAD, data)) - -/*----------------------------------------------------------- -** -** LOAD from memory to register. -** STORE from register to memory. -** -** Only supported by 810A, 860, 825A, 875, 895 and 896. -** -**----------------------------------------------------------- -** -** LOAD_ABS (LEN) -** <> -** -** LOAD_REL (LEN) (DSA relative) -** <> -** -**----------------------------------------------------------- -*/ - -#define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul) -#define SCR_NO_FLUSH2 0x02000000 -#define SCR_DSA_REL2 0x10000000 - -#define SCR_LOAD_R(reg, how, n) \ - (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n)) - -#define SCR_STORE_R(reg, how, n) \ - (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n)) - -#define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n) -#define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n) -#define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n) -#define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n) - -#define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n) -#define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n) -#define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n) -#define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n) - - -/*----------------------------------------------------------- -** -** Waiting for Disconnect or Reselect -** -**----------------------------------------------------------- -** -** JUMP [ | IFTRUE/IFFALSE ( ... ) ] -** <
> -** -** JUMPR [ | IFTRUE/IFFALSE ( ... ) ] -** <> -** -** CALL [ | IFTRUE/IFFALSE ( ... ) ] -** <
> -** -** CALLR [ | IFTRUE/IFFALSE ( ... ) ] -** <> -** -** RETURN [ | IFTRUE/IFFALSE ( ... ) ] -** <> -** -** INT [ | IFTRUE/IFFALSE ( ... ) ] -** <> -** -** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ] -** <> -** -** Conditions: -** WHEN (phase) -** IF (phase) -** CARRYSET -** DATA (data, mask) -** -**----------------------------------------------------------- -*/ - -#define SCR_NO_OP 0x80000000 -#define SCR_JUMP 0x80080000 -#define SCR_JUMP64 0x80480000 -#define SCR_JUMPR 0x80880000 -#define SCR_CALL 0x88080000 -#define SCR_CALLR 0x88880000 -#define SCR_RETURN 0x90080000 -#define SCR_INT 0x98080000 -#define SCR_INT_FLY 0x98180000 - -#define IFFALSE(arg) (0x00080000 | (arg)) -#define IFTRUE(arg) (0x00000000 | (arg)) - -#define WHEN(phase) (0x00030000 | (phase)) -#define IF(phase) (0x00020000 | (phase)) - -#define DATA(D) (0x00040000 | ((D) & 0xff)) -#define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff)) - -#define CARRYSET (0x00200000) - -/*----------------------------------------------------------- -** -** SCSI constants. -** -**----------------------------------------------------------- -*/ - -/* -** Messages -*/ - -#define M_COMPLETE COMMAND_COMPLETE -#define M_EXTENDED EXTENDED_MESSAGE -#define M_SAVE_DP SAVE_POINTERS -#define M_RESTORE_DP RESTORE_POINTERS -#define M_DISCONNECT DISCONNECT -#define M_ID_ERROR INITIATOR_ERROR -#define M_ABORT ABORT_TASK_SET -#define M_REJECT MESSAGE_REJECT -#define M_NOOP NOP -#define M_PARITY MSG_PARITY_ERROR -#define M_LCOMPLETE LINKED_CMD_COMPLETE -#define M_FCOMPLETE LINKED_FLG_CMD_COMPLETE -#define M_RESET TARGET_RESET -#define M_ABORT_TAG ABORT_TASK -#define M_CLEAR_QUEUE CLEAR_TASK_SET -#define M_INIT_REC INITIATE_RECOVERY -#define M_REL_REC RELEASE_RECOVERY -#define M_TERMINATE (0x11) -#define M_SIMPLE_TAG SIMPLE_QUEUE_TAG -#define M_HEAD_TAG HEAD_OF_QUEUE_TAG -#define M_ORDERED_TAG ORDERED_QUEUE_TAG -#define M_IGN_RESIDUE IGNORE_WIDE_RESIDUE -#define M_IDENTIFY (0x80) - -#define M_X_MODIFY_DP EXTENDED_MODIFY_DATA_POINTER -#define M_X_SYNC_REQ EXTENDED_SDTR -#define M_X_WIDE_REQ EXTENDED_WDTR -#define M_X_PPR_REQ EXTENDED_PPR - -/* -** Status -*/ - -#define S_GOOD (0x00) -#define S_CHECK_COND (0x02) -#define S_COND_MET (0x04) -#define S_BUSY (0x08) -#define S_INT (0x10) -#define S_INT_COND_MET (0x14) -#define S_CONFLICT (0x18) -#define S_TERMINATED (0x20) -#define S_QUEUE_FULL (0x28) -#define S_ILLEGAL (0xff) -#define S_SENSE (0x80) - -/* - * End of ncrreg from FreeBSD - */ - -#endif /* defined SYM53C8XX_DEFS_H */ -- cgit v1.1 From 6f6046cff2e8f04d6b916b10ebaa7b40d7e7967a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 16 Dec 2005 21:35:19 +0100 Subject: kconfig: move lxdialog to scripts/kconfig/lxdialog The only lxdialog user i kconfig - for menuconfig. So move it to reflect this. Signed-off-by: Sam Ravnborg --- scripts/Makefile | 2 +- scripts/kconfig/Makefile | 3 +- scripts/kconfig/lxdialog/BIG.FAT.WARNING | 4 + scripts/kconfig/lxdialog/Makefile | 42 +++ scripts/kconfig/lxdialog/checklist.c | 353 ++++++++++++++++++++ scripts/kconfig/lxdialog/colors.h | 154 +++++++++ scripts/kconfig/lxdialog/dialog.h | 184 +++++++++++ scripts/kconfig/lxdialog/inputbox.c | 224 +++++++++++++ scripts/kconfig/lxdialog/lxdialog.c | 212 ++++++++++++ scripts/kconfig/lxdialog/menubox.c | 425 ++++++++++++++++++++++++ scripts/kconfig/lxdialog/msgbox.c | 71 ++++ scripts/kconfig/lxdialog/textbox.c | 533 +++++++++++++++++++++++++++++++ scripts/kconfig/lxdialog/util.c | 362 +++++++++++++++++++++ scripts/kconfig/lxdialog/yesno.c | 102 ++++++ scripts/kconfig/mconf.c | 2 +- scripts/lxdialog/BIG.FAT.WARNING | 4 - scripts/lxdialog/Makefile | 42 --- scripts/lxdialog/checklist.c | 353 -------------------- scripts/lxdialog/colors.h | 154 --------- scripts/lxdialog/dialog.h | 184 ----------- scripts/lxdialog/inputbox.c | 224 ------------- scripts/lxdialog/lxdialog.c | 212 ------------ scripts/lxdialog/menubox.c | 425 ------------------------ scripts/lxdialog/msgbox.c | 71 ---- scripts/lxdialog/textbox.c | 533 ------------------------------- scripts/lxdialog/util.c | 362 --------------------- scripts/lxdialog/yesno.c | 102 ------ 27 files changed, 2670 insertions(+), 2669 deletions(-) create mode 100644 scripts/kconfig/lxdialog/BIG.FAT.WARNING create mode 100644 scripts/kconfig/lxdialog/Makefile create mode 100644 scripts/kconfig/lxdialog/checklist.c create mode 100644 scripts/kconfig/lxdialog/colors.h create mode 100644 scripts/kconfig/lxdialog/dialog.h create mode 100644 scripts/kconfig/lxdialog/inputbox.c create mode 100644 scripts/kconfig/lxdialog/lxdialog.c create mode 100644 scripts/kconfig/lxdialog/menubox.c create mode 100644 scripts/kconfig/lxdialog/msgbox.c create mode 100644 scripts/kconfig/lxdialog/textbox.c create mode 100644 scripts/kconfig/lxdialog/util.c create mode 100644 scripts/kconfig/lxdialog/yesno.c delete mode 100644 scripts/lxdialog/BIG.FAT.WARNING delete mode 100644 scripts/lxdialog/Makefile delete mode 100644 scripts/lxdialog/checklist.c delete mode 100644 scripts/lxdialog/colors.h delete mode 100644 scripts/lxdialog/dialog.h delete mode 100644 scripts/lxdialog/inputbox.c delete mode 100644 scripts/lxdialog/lxdialog.c delete mode 100644 scripts/lxdialog/menubox.c delete mode 100644 scripts/lxdialog/msgbox.c delete mode 100644 scripts/lxdialog/textbox.c delete mode 100644 scripts/lxdialog/util.c delete mode 100644 scripts/lxdialog/yesno.c diff --git a/scripts/Makefile b/scripts/Makefile index 67763ee..6f6b48f 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -19,4 +19,4 @@ subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-$(CONFIG_MODULES) += mod # Let clean descend into subdirs -subdir- += basic lxdialog kconfig package +subdir- += basic kconfig package diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 9d67782..55bf955 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -11,7 +11,7 @@ gconfig: $(obj)/gconf $< arch/$(ARCH)/Kconfig menuconfig: $(obj)/mconf - $(Q)$(MAKE) $(build)=scripts/lxdialog + $(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog $< arch/$(ARCH)/Kconfig config: $(obj)/conf @@ -115,6 +115,7 @@ endif clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c +subdir- += lxdialog # Needed for systems without gettext KBUILD_HAVE_NLS := $(shell \ diff --git a/scripts/kconfig/lxdialog/BIG.FAT.WARNING b/scripts/kconfig/lxdialog/BIG.FAT.WARNING new file mode 100644 index 0000000..a8999d8 --- /dev/null +++ b/scripts/kconfig/lxdialog/BIG.FAT.WARNING @@ -0,0 +1,4 @@ +This is NOT the official version of dialog. This version has been +significantly modified from the original. It is for use by the Linux +kernel configuration script. Please do not bother Savio Lam with +questions about this program. diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile new file mode 100644 index 0000000..a45a13f --- /dev/null +++ b/scripts/kconfig/lxdialog/Makefile @@ -0,0 +1,42 @@ +HOST_EXTRACFLAGS := -DLOCALE +ifeq ($(shell uname),SunOS) +HOST_LOADLIBES := -lcurses +else +HOST_LOADLIBES := -lncurses +endif + +ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) + HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h)) + HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC="" +else +ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h)) + HOST_EXTRACFLAGS += -DCURSES_LOC="" +else + HOST_EXTRACFLAGS += -DCURSES_LOC="" +endif +endif +endif + +hostprogs-y := lxdialog +always := ncurses $(hostprogs-y) + +lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ + util.o lxdialog.o msgbox.o + +.PHONY: $(obj)/ncurses +$(obj)/ncurses: + @echo "main() {}" > lxtemp.c + @if $(HOSTCC) lxtemp.c $(HOST_LOADLIBES); then \ + rm -f lxtemp.c a.out; \ + else \ + rm -f lxtemp.c; \ + echo -e "\007" ;\ + echo ">> Unable to find the Ncurses libraries." ;\ + echo ">>" ;\ + echo ">> You must install ncurses-devel in order" ;\ + echo ">> to use 'make menuconfig'" ;\ + echo ;\ + exit 1 ;\ + fi diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c new file mode 100644 index 0000000..3fb681f --- /dev/null +++ b/scripts/kconfig/lxdialog/checklist.c @@ -0,0 +1,353 @@ +/* + * checklist.c -- implements the checklist box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension + * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static int list_width, check_x, item_x, checkflag; + +/* + * Print list item + */ +static void print_item(WINDOW * win, const char *item, int status, int choice, + int selected) +{ + int i; + + /* Clear 'residue' of last item */ + wattrset(win, menubox_attr); + wmove(win, choice, 0); + for (i = 0; i < list_width; i++) + waddch(win, ' '); + + wmove(win, choice, check_x); + wattrset(win, selected ? check_selected_attr : check_attr); + if (checkflag == FLAG_CHECK) + wprintw(win, "[%c]", status ? 'X' : ' '); + else + wprintw(win, "(%c)", status ? 'X' : ' '); + + wattrset(win, selected ? tag_selected_attr : tag_attr); + mvwaddch(win, choice, item_x, item[0]); + wattrset(win, selected ? item_selected_attr : item_attr); + waddstr(win, (char *)item + 1); + if (selected) { + wmove(win, choice, check_x + 1); + wrefresh(win); + } +} + +/* + * Print the scroll indicators. + */ +static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, + int y, int x, int height) +{ + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, uarrow_attr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, menubox_attr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + + if ((height < item_no) && (scroll + choice < item_no - 1)) { + wattrset(win, darrow_attr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, menubox_border_attr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } +} + +/* + * Display the termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button(dialog, "Select", y, x, selected == 0); + print_button(dialog, " Help ", y, x + 14, selected == 1); + + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box with a list of options that can be turned on or off + * The `flag' parameter is used to select between radiolist and checklist. + */ +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height, int item_no, + const char *const *items, int flag) +{ + int i, x, y, box_x, box_y; + int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; + WINDOW *dialog, *list; + + checkflag = flag; + + /* Allocate space for storing item on/off status */ + if ((status = malloc(sizeof(int) * item_no)) == NULL) { + endwin(); + fprintf(stderr, + "\nCan't allocate memory in dialog_checklist().\n"); + exit(-1); + } + + /* Initializes status */ + for (i = 0; i < item_no; i++) { + status[i] = !strcasecmp(items[i * 3 + 2], "on"); + if ((!choice && status[i]) + || !strcasecmp(items[i * 3 + 2], "selected")) + choice = i + 1; + } + if (choice) + choice--; + + max_choice = MIN(list_height, item_no); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + list_width = width - 6; + box_y = height - list_height - 5; + box_x = (width - list_width) / 2 - 1; + + /* create new window for the list */ + list = subwin(dialog, list_height, list_width, y + box_y + 1, + x + box_x + 1); + + keypad(list, TRUE); + + /* draw a box around the list items */ + draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, + menubox_border_attr, menubox_attr); + + /* Find length of longest item in order to center checklist */ + check_x = 0; + for (i = 0; i < item_no; i++) + check_x = MAX(check_x, +strlen(items[i * 3 + 1]) + 4); + + check_x = (list_width - check_x) / 2; + item_x = check_x + 4; + + if (choice >= list_height) { + scroll = choice - list_height + 1; + choice -= scroll; + } + + /* Print the list */ + for (i = 0; i < max_choice; i++) { + print_item(list, items[(scroll + i) * 3 + 1], + status[i + scroll], i, i == choice); + } + + print_arrows(dialog, choice, item_no, scroll, + box_y, box_x + check_x + 5, list_height); + + print_buttons(dialog, height, width, 0); + + wnoutrefresh(list); + wnoutrefresh(dialog); + doupdate(); + + while (key != ESC) { + key = wgetch(dialog); + + for (i = 0; i < max_choice; i++) + if (toupper(key) == + toupper(items[(scroll + i) * 3 + 1][0])) + break; + + if (i < max_choice || key == KEY_UP || key == KEY_DOWN || + key == '+' || key == '-') { + if (key == KEY_UP || key == '-') { + if (!choice) { + if (!scroll) + continue; + /* Scroll list down */ + if (list_height > 1) { + /* De-highlight current first item */ + print_item(list, items[scroll * 3 + 1], + status[scroll], 0, FALSE); + scrollok(list, TRUE); + wscrl(list, -1); + scrollok(list, FALSE); + } + scroll--; + print_item(list, items[scroll * 3 + 1], status[scroll], 0, TRUE); + wnoutrefresh(list); + + print_arrows(dialog, choice, item_no, + scroll, box_y, box_x + check_x + 5, list_height); + + wrefresh(dialog); + + continue; /* wait for another key press */ + } else + i = choice - 1; + } else if (key == KEY_DOWN || key == '+') { + if (choice == max_choice - 1) { + if (scroll + choice >= item_no - 1) + continue; + /* Scroll list up */ + if (list_height > 1) { + /* De-highlight current last item before scrolling up */ + print_item(list, items[(scroll + max_choice - 1) * 3 + 1], + status[scroll + max_choice - 1], + max_choice - 1, FALSE); + scrollok(list, TRUE); + wscrl(list, 1); + scrollok(list, FALSE); + } + scroll++; + print_item(list, items[(scroll + max_choice - 1) * 3 + 1], + status[scroll + max_choice - 1], max_choice - 1, TRUE); + wnoutrefresh(list); + + print_arrows(dialog, choice, item_no, + scroll, box_y, box_x + check_x + 5, list_height); + + wrefresh(dialog); + + continue; /* wait for another key press */ + } else + i = choice + 1; + } + if (i != choice) { + /* De-highlight current item */ + print_item(list, items[(scroll + choice) * 3 + 1], + status[scroll + choice], choice, FALSE); + /* Highlight new item */ + choice = i; + print_item(list, items[(scroll + choice) * 3 + 1], + status[scroll + choice], choice, TRUE); + wnoutrefresh(list); + wrefresh(dialog); + } + continue; /* wait for another key press */ + } + switch (key) { + case 'H': + case 'h': + case '?': + fprintf(stderr, "%s", items[(scroll + choice) * 3]); + delwin(dialog); + free(status); + return 1; + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case 'S': + case 's': + case ' ': + case '\n': + if (!button) { + if (flag == FLAG_CHECK) { + status[scroll + choice] = !status[scroll + choice]; + wmove(list, choice, check_x); + wattrset(list, check_selected_attr); + wprintw(list, "[%c]", status[scroll + choice] ? 'X' : ' '); + } else { + if (!status[scroll + choice]) { + for (i = 0; i < item_no; i++) + status[i] = 0; + status[scroll + choice] = 1; + for (i = 0; i < max_choice; i++) + print_item(list, items[(scroll + i) * 3 + 1], + status[scroll + i], i, i == choice); + } + } + wnoutrefresh(list); + wrefresh(dialog); + + for (i = 0; i < item_no; i++) { + if (status[i]) { + if (flag == FLAG_CHECK) { + fprintf(stderr, "\"%s\" ", items[i * 3]); + } else { + fprintf(stderr, "%s", items[i * 3]); + } + + } + } + } else + fprintf(stderr, "%s", items[(scroll + choice) * 3]); + delwin(dialog); + free(status); + return button; + case 'X': + case 'x': + key = ESC; + case ESC: + break; + } + + /* Now, update everything... */ + doupdate(); + } + + delwin(dialog); + free(status); + return -1; /* ESC pressed */ +} diff --git a/scripts/kconfig/lxdialog/colors.h b/scripts/kconfig/lxdialog/colors.h new file mode 100644 index 0000000..db071df1 --- /dev/null +++ b/scripts/kconfig/lxdialog/colors.h @@ -0,0 +1,154 @@ +/* + * colors.h -- color attribute definitions + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Default color definitions + * + * *_FG = foreground + * *_BG = background + * *_HL = highlight? + */ +#define SCREEN_FG COLOR_CYAN +#define SCREEN_BG COLOR_BLUE +#define SCREEN_HL TRUE + +#define SHADOW_FG COLOR_BLACK +#define SHADOW_BG COLOR_BLACK +#define SHADOW_HL TRUE + +#define DIALOG_FG COLOR_BLACK +#define DIALOG_BG COLOR_WHITE +#define DIALOG_HL FALSE + +#define TITLE_FG COLOR_YELLOW +#define TITLE_BG COLOR_WHITE +#define TITLE_HL TRUE + +#define BORDER_FG COLOR_WHITE +#define BORDER_BG COLOR_WHITE +#define BORDER_HL TRUE + +#define BUTTON_ACTIVE_FG COLOR_WHITE +#define BUTTON_ACTIVE_BG COLOR_BLUE +#define BUTTON_ACTIVE_HL TRUE + +#define BUTTON_INACTIVE_FG COLOR_BLACK +#define BUTTON_INACTIVE_BG COLOR_WHITE +#define BUTTON_INACTIVE_HL FALSE + +#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE +#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE +#define BUTTON_KEY_ACTIVE_HL TRUE + +#define BUTTON_KEY_INACTIVE_FG COLOR_RED +#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE +#define BUTTON_KEY_INACTIVE_HL FALSE + +#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW +#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE +#define BUTTON_LABEL_ACTIVE_HL TRUE + +#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK +#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE +#define BUTTON_LABEL_INACTIVE_HL TRUE + +#define INPUTBOX_FG COLOR_BLACK +#define INPUTBOX_BG COLOR_WHITE +#define INPUTBOX_HL FALSE + +#define INPUTBOX_BORDER_FG COLOR_BLACK +#define INPUTBOX_BORDER_BG COLOR_WHITE +#define INPUTBOX_BORDER_HL FALSE + +#define SEARCHBOX_FG COLOR_BLACK +#define SEARCHBOX_BG COLOR_WHITE +#define SEARCHBOX_HL FALSE + +#define SEARCHBOX_TITLE_FG COLOR_YELLOW +#define SEARCHBOX_TITLE_BG COLOR_WHITE +#define SEARCHBOX_TITLE_HL TRUE + +#define SEARCHBOX_BORDER_FG COLOR_WHITE +#define SEARCHBOX_BORDER_BG COLOR_WHITE +#define SEARCHBOX_BORDER_HL TRUE + +#define POSITION_INDICATOR_FG COLOR_YELLOW +#define POSITION_INDICATOR_BG COLOR_WHITE +#define POSITION_INDICATOR_HL TRUE + +#define MENUBOX_FG COLOR_BLACK +#define MENUBOX_BG COLOR_WHITE +#define MENUBOX_HL FALSE + +#define MENUBOX_BORDER_FG COLOR_WHITE +#define MENUBOX_BORDER_BG COLOR_WHITE +#define MENUBOX_BORDER_HL TRUE + +#define ITEM_FG COLOR_BLACK +#define ITEM_BG COLOR_WHITE +#define ITEM_HL FALSE + +#define ITEM_SELECTED_FG COLOR_WHITE +#define ITEM_SELECTED_BG COLOR_BLUE +#define ITEM_SELECTED_HL TRUE + +#define TAG_FG COLOR_YELLOW +#define TAG_BG COLOR_WHITE +#define TAG_HL TRUE + +#define TAG_SELECTED_FG COLOR_YELLOW +#define TAG_SELECTED_BG COLOR_BLUE +#define TAG_SELECTED_HL TRUE + +#define TAG_KEY_FG COLOR_YELLOW +#define TAG_KEY_BG COLOR_WHITE +#define TAG_KEY_HL TRUE + +#define TAG_KEY_SELECTED_FG COLOR_YELLOW +#define TAG_KEY_SELECTED_BG COLOR_BLUE +#define TAG_KEY_SELECTED_HL TRUE + +#define CHECK_FG COLOR_BLACK +#define CHECK_BG COLOR_WHITE +#define CHECK_HL FALSE + +#define CHECK_SELECTED_FG COLOR_WHITE +#define CHECK_SELECTED_BG COLOR_BLUE +#define CHECK_SELECTED_HL TRUE + +#define UARROW_FG COLOR_GREEN +#define UARROW_BG COLOR_WHITE +#define UARROW_HL TRUE + +#define DARROW_FG COLOR_GREEN +#define DARROW_BG COLOR_WHITE +#define DARROW_HL TRUE + +/* End of default color definitions */ + +#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y))) +#define COLOR_NAME_LEN 10 +#define COLOR_COUNT 8 + +/* + * Global variables + */ + +extern int color_table[][3]; diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h new file mode 100644 index 0000000..f882204 --- /dev/null +++ b/scripts/kconfig/lxdialog/dialog.h @@ -0,0 +1,184 @@ +/* + * dialog.h -- common declarations for all dialog modules + * + * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef __sun__ +#define CURS_MACROS +#endif +#include CURSES_LOC + +/* + * Colors in ncurses 1.9.9e do not work properly since foreground and + * background colors are OR'd rather than separately masked. This version + * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible + * with standard curses. The simplest fix (to make this work with standard + * curses) uses the wbkgdset() function, not used in the original hack. + * Turn it off if we're building with 1.9.9e, since it just confuses things. + */ +#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) +#define OLD_NCURSES 1 +#undef wbkgdset +#define wbkgdset(w,p) /*nothing */ +#else +#define OLD_NCURSES 0 +#endif + +#define TR(params) _tracef params + +#define ESC 27 +#define TAB 9 +#define MAX_LEN 2048 +#define BUF_SIZE (10*1024) +#define MIN(x,y) (x < y ? x : y) +#define MAX(x,y) (x > y ? x : y) + +#ifndef ACS_ULCORNER +#define ACS_ULCORNER '+' +#endif +#ifndef ACS_LLCORNER +#define ACS_LLCORNER '+' +#endif +#ifndef ACS_URCORNER +#define ACS_URCORNER '+' +#endif +#ifndef ACS_LRCORNER +#define ACS_LRCORNER '+' +#endif +#ifndef ACS_HLINE +#define ACS_HLINE '-' +#endif +#ifndef ACS_VLINE +#define ACS_VLINE '|' +#endif +#ifndef ACS_LTEE +#define ACS_LTEE '+' +#endif +#ifndef ACS_RTEE +#define ACS_RTEE '+' +#endif +#ifndef ACS_UARROW +#define ACS_UARROW '^' +#endif +#ifndef ACS_DARROW +#define ACS_DARROW 'v' +#endif + +/* + * Attribute names + */ +#define screen_attr attributes[0] +#define shadow_attr attributes[1] +#define dialog_attr attributes[2] +#define title_attr attributes[3] +#define border_attr attributes[4] +#define button_active_attr attributes[5] +#define button_inactive_attr attributes[6] +#define button_key_active_attr attributes[7] +#define button_key_inactive_attr attributes[8] +#define button_label_active_attr attributes[9] +#define button_label_inactive_attr attributes[10] +#define inputbox_attr attributes[11] +#define inputbox_border_attr attributes[12] +#define searchbox_attr attributes[13] +#define searchbox_title_attr attributes[14] +#define searchbox_border_attr attributes[15] +#define position_indicator_attr attributes[16] +#define menubox_attr attributes[17] +#define menubox_border_attr attributes[18] +#define item_attr attributes[19] +#define item_selected_attr attributes[20] +#define tag_attr attributes[21] +#define tag_selected_attr attributes[22] +#define tag_key_attr attributes[23] +#define tag_key_selected_attr attributes[24] +#define check_attr attributes[25] +#define check_selected_attr attributes[26] +#define uarrow_attr attributes[27] +#define darrow_attr attributes[28] + +/* number of attributes */ +#define ATTRIBUTE_COUNT 29 + +/* + * Global variables + */ +extern bool use_colors; +extern bool use_shadow; + +extern chtype attributes[]; + +extern const char *backtitle; + +/* + * Function prototypes + */ +extern void create_rc(const char *filename); +extern int parse_rc(void); + +void init_dialog(void); +void end_dialog(void); +void attr_clear(WINDOW * win, int height, int width, chtype attr); +void dialog_clear(void); +void color_setup(void); +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); +void print_button(WINDOW * win, const char *label, int y, int x, int selected); +void print_title(WINDOW *dialog, const char *title, int width); +void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, + chtype border); +void draw_shadow(WINDOW * win, int y, int x, int height, int width); + +int first_alpha(const char *string, const char *exempt); +int dialog_yesno(const char *title, const char *prompt, int height, int width); +int dialog_msgbox(const char *title, const char *prompt, int height, + int width, int pause); +int dialog_textbox(const char *title, const char *file, int height, int width); +int dialog_menu(const char *title, const char *prompt, int height, int width, + int menu_height, const char *choice, int item_no, + const char *const *items); +int dialog_checklist(const char *title, const char *prompt, int height, + int width, int list_height, int item_no, + const char *const *items, int flag); +extern char dialog_input_result[]; +int dialog_inputbox(const char *title, const char *prompt, int height, + int width, const char *init); + +/* + * This is the base for fictitious keys, which activate + * the buttons. + * + * Mouse-generated keys are the following: + * -- the first 32 are used as numbers, in addition to '0'-'9' + * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') + * -- uppercase chars are used to invoke the button (M_EVENT + 'O') + */ +#define M_EVENT (KEY_MAX+1) + +/* + * The `flag' parameter in checklist is used to select between + * radiolist and checklist + */ +#define FLAG_CHECK 1 +#define FLAG_RADIO 0 diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c new file mode 100644 index 0000000..7795037 --- /dev/null +++ b/scripts/kconfig/lxdialog/inputbox.c @@ -0,0 +1,224 @@ +/* + * inputbox.c -- implements the input box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +char dialog_input_result[MAX_LEN + 1]; + +/* + * Print the termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 11; + int y = height - 2; + + print_button(dialog, " Ok ", y, x, selected == 0); + print_button(dialog, " Help ", y, x + 14, selected == 1); + + wmove(dialog, y, x + 1 + 14 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box for inputing a string + */ +int dialog_inputbox(const char *title, const char *prompt, int height, int width, + const char *init) +{ + int i, x, y, box_y, box_x, box_width; + int input_x = 0, scroll = 0, key = 0, button = -1; + char *instr = dialog_input_result; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + /* Draw the input field box */ + box_width = width - 6; + getyx(dialog, y, x); + box_y = y + 2; + box_x = (width - box_width) / 2; + draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); + + print_buttons(dialog, height, width, 0); + + /* Set up the initial value */ + wmove(dialog, box_y, box_x); + wattrset(dialog, inputbox_attr); + + if (!init) + instr[0] = '\0'; + else + strcpy(instr, init); + + input_x = strlen(instr); + + if (input_x >= box_width) { + scroll = input_x - box_width + 1; + input_x = box_width - 1; + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr[scroll + i]); + } else { + waddstr(dialog, instr); + } + + wmove(dialog, box_y, box_x + input_x); + + wrefresh(dialog); + + while (key != ESC) { + key = wgetch(dialog); + + if (button == -1) { /* Input box selected */ + switch (key) { + case TAB: + case KEY_UP: + case KEY_DOWN: + break; + case KEY_LEFT: + continue; + case KEY_RIGHT: + continue; + case KEY_BACKSPACE: + case 127: + if (input_x || scroll) { + wattrset(dialog, inputbox_attr); + if (!input_x) { + scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width; i++) + waddch(dialog, + instr[scroll + input_x + i] ? + instr[scroll + input_x + i] : ' '); + input_x = strlen(instr) - scroll; + } else + input_x--; + instr[scroll + input_x] = '\0'; + mvwaddch(dialog, box_y, input_x + box_x, ' '); + wmove(dialog, box_y, input_x + box_x); + wrefresh(dialog); + } + continue; + default: + if (key < 0x100 && isprint(key)) { + if (scroll + input_x < MAX_LEN) { + wattrset(dialog, inputbox_attr); + instr[scroll + input_x] = key; + instr[scroll + input_x + 1] = '\0'; + if (input_x == box_width - 1) { + scroll++; + wmove(dialog, box_y, box_x); + for (i = 0; i < box_width - 1; i++) + waddch(dialog, instr [scroll + i]); + } else { + wmove(dialog, box_y, input_x++ + box_x); + waddch(dialog, key); + } + wrefresh(dialog); + } else + flash(); /* Alarm user about overflow */ + continue; + } + } + } + switch (key) { + case 'O': + case 'o': + delwin(dialog); + return 0; + case 'H': + case 'h': + delwin(dialog); + return 1; + case KEY_UP: + case KEY_LEFT: + switch (button) { + case -1: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 0: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + case 1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + } + break; + case TAB: + case KEY_DOWN: + case KEY_RIGHT: + switch (button) { + case -1: + button = 0; /* Indicates "OK" button is selected */ + print_buttons(dialog, height, width, 0); + break; + case 0: + button = 1; /* Indicates "Cancel" button is selected */ + print_buttons(dialog, height, width, 1); + break; + case 1: + button = -1; /* Indicates input box is selected */ + print_buttons(dialog, height, width, 0); + wmove(dialog, box_y, box_x + input_x); + wrefresh(dialog); + break; + } + break; + case ' ': + case '\n': + delwin(dialog); + return (button == -1 ? 0 : button); + case 'X': + case 'x': + key = ESC; + case ESC: + break; + } + } + + delwin(dialog); + return -1; /* ESC pressed */ +} diff --git a/scripts/kconfig/lxdialog/lxdialog.c b/scripts/kconfig/lxdialog/lxdialog.c new file mode 100644 index 0000000..2c34ea1 --- /dev/null +++ b/scripts/kconfig/lxdialog/lxdialog.c @@ -0,0 +1,212 @@ +/* + * dialog - Display simple dialog boxes from shell scripts + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static void Usage(const char *name); + +typedef int (jumperFn) (const char *title, int argc, const char *const *argv); + +struct Mode { + char *name; + int argmin, argmax, argmod; + jumperFn *jumper; +}; + +jumperFn j_menu, j_checklist, j_radiolist, j_yesno, j_textbox, j_inputbox; +jumperFn j_msgbox, j_infobox; + +static struct Mode modes[] = { + {"--menu", 9, 0, 3, j_menu}, + {"--checklist", 9, 0, 3, j_checklist}, + {"--radiolist", 9, 0, 3, j_radiolist}, + {"--yesno", 5, 5, 1, j_yesno}, + {"--textbox", 5, 5, 1, j_textbox}, + {"--inputbox", 5, 6, 1, j_inputbox}, + {"--msgbox", 5, 5, 1, j_msgbox}, + {"--infobox", 5, 5, 1, j_infobox}, + {NULL, 0, 0, 0, NULL} +}; + +static struct Mode *modePtr; + +#ifdef LOCALE +#include +#endif + +int main(int argc, const char *const *argv) +{ + int offset = 0, opt_clear = 0, end_common_opts = 0, retval; + const char *title = NULL; + +#ifdef LOCALE + (void)setlocale(LC_ALL, ""); +#endif + +#ifdef TRACE + trace(TRACE_CALLS | TRACE_UPDATE); +#endif + if (argc < 2) { + Usage(argv[0]); + exit(-1); + } + + while (offset < argc - 1 && !end_common_opts) { /* Common options */ + if (!strcmp(argv[offset + 1], "--title")) { + if (argc - offset < 3 || title != NULL) { + Usage(argv[0]); + exit(-1); + } else { + title = argv[offset + 2]; + offset += 2; + } + } else if (!strcmp(argv[offset + 1], "--backtitle")) { + if (backtitle != NULL) { + Usage(argv[0]); + exit(-1); + } else { + backtitle = argv[offset + 2]; + offset += 2; + } + } else if (!strcmp(argv[offset + 1], "--clear")) { + if (opt_clear) { /* Hey, "--clear" can't appear twice! */ + Usage(argv[0]); + exit(-1); + } else if (argc == 2) { /* we only want to clear the screen */ + init_dialog(); + refresh(); /* init_dialog() will clear the screen for us */ + end_dialog(); + return 0; + } else { + opt_clear = 1; + offset++; + } + } else /* no more common options */ + end_common_opts = 1; + } + + if (argc - 1 == offset) { /* no more options */ + Usage(argv[0]); + exit(-1); + } + /* use a table to look for the requested mode, to avoid code duplication */ + + for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ + if (!strcmp(argv[offset + 1], modePtr->name)) + break; + + if (!modePtr->name) + Usage(argv[0]); + if (argc - offset < modePtr->argmin) + Usage(argv[0]); + if (modePtr->argmax && argc - offset > modePtr->argmax) + Usage(argv[0]); + + init_dialog(); + retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); + + if (opt_clear) { /* clear screen before exit */ + attr_clear(stdscr, LINES, COLS, screen_attr); + refresh(); + } + end_dialog(); + + exit(retval); +} + +/* + * Print program usage + */ +static void Usage(const char *name) +{ + fprintf(stderr, "\ +\ndialog, by Savio Lam (lam836@cs.cuhk.hk).\ +\n patched by Stuart Herbert (S.Herbert@shef.ac.uk)\ +\n modified/gutted for use as a Linux kernel config tool by \ +\n William Roadcap (roadcapw@cfw.com)\ +\n\ +\n* Display dialog boxes from shell scripts *\ +\n\ +\nUsage: %s --clear\ +\n %s [--title ] [--backtitle <backtitle>] --clear <Box options>\ +\n\ +\nBox options:\ +\n\ +\n --menu <text> <height> <width> <menu height> <tag1> <item1>...\ +\n --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ +\n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ +\n --textbox <file> <height> <width>\ +\n --inputbox <text> <height> <width> [<init>]\ +\n --yesno <text> <height> <width>\ +\n", name, name); + exit(-1); +} + +/* + * These are the program jumpers + */ + +int j_menu(const char *t, int ac, const char *const *av) +{ + return dialog_menu(t, av[2], atoi(av[3]), atoi(av[4]), + atoi(av[5]), av[6], (ac - 6) / 2, av + 7); +} + +int j_checklist(const char *t, int ac, const char *const *av) +{ + return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), + atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK); +} + +int j_radiolist(const char *t, int ac, const char *const *av) +{ + return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), + atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO); +} + +int j_textbox(const char *t, int ac, const char *const *av) +{ + return dialog_textbox(t, av[2], atoi(av[3]), atoi(av[4])); +} + +int j_yesno(const char *t, int ac, const char *const *av) +{ + return dialog_yesno(t, av[2], atoi(av[3]), atoi(av[4])); +} + +int j_inputbox(const char *t, int ac, const char *const *av) +{ + int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]), + ac == 6 ? av[5] : (char *)NULL); + if (ret == 0) + fprintf(stderr, dialog_input_result); + return ret; +} + +int j_msgbox(const char *t, int ac, const char *const *av) +{ + return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 1); +} + +int j_infobox(const char *t, int ac, const char *const *av) +{ + return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 0); +} diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c new file mode 100644 index 0000000..09512b5 --- /dev/null +++ b/scripts/kconfig/lxdialog/menubox.c @@ -0,0 +1,425 @@ +/* + * menubox.c -- implements the menu box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* + * Changes by Clifford Wolf (god@clifford.at) + * + * [ 1998-06-13 ] + * + * *) A bugfix for the Page-Down problem + * + * *) Formerly when I used Page Down and Page Up, the cursor would be set + * to the first position in the menu box. Now lxdialog is a bit + * smarter and works more like other menu systems (just have a look at + * it). + * + * *) Formerly if I selected something my scrolling would be broken because + * lxdialog is re-invoked by the Menuconfig shell script, can't + * remember the last scrolling position, and just sets it so that the + * cursor is at the bottom of the box. Now it writes the temporary file + * lxdialog.scrltmp which contains this information. The file is + * deleted by lxdialog if the user leaves a submenu or enters a new + * one, but it would be nice if Menuconfig could make another "rm -f" + * just to be sure. Just try it out - you will recognise a difference! + * + * [ 1998-06-14 ] + * + * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files + * and menus change their size on the fly. + * + * *) If for some reason the last scrolling position is not saved by + * lxdialog, it sets the scrolling so that the selected item is in the + * middle of the menu box, not at the bottom. + * + * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) + * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. + * This fixes a bug in Menuconfig where using ' ' to descend into menus + * would leave mis-synchronized lxdialog.scrltmp files lying around, + * fscanf would read in 'scroll', and eventually that value would get used. + */ + +#include "dialog.h" + +#define ITEM_IDENT 1 /* Indent of menu entries. Fixed for all menus */ +static int menu_width; + +/* + * Print menu item + */ +static void do_print_item(WINDOW * win, const char *item, int choice, + int selected, int hotkey) +{ + int j; + char *menu_item = malloc(menu_width + 1); + + strncpy(menu_item, item, menu_width - ITEM_IDENT); + menu_item[menu_width] = 0; + j = first_alpha(menu_item, "YyNnMmHh"); + + /* Clear 'residue' of last item */ + wattrset(win, menubox_attr); + wmove(win, choice, 0); +#if OLD_NCURSES + { + int i; + for (i = 0; i < menu_width; i++) + waddch(win, ' '); + } +#else + wclrtoeol(win); +#endif + wattrset(win, selected ? item_selected_attr : item_attr); + mvwaddstr(win, choice, ITEM_IDENT, menu_item); + if (hotkey) { + wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); + mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]); + } + if (selected) { + wmove(win, choice, ITEM_IDENT + 1); + } + free(menu_item); + wrefresh(win); +} + +#define print_item(index, choice, selected) \ +do {\ + int hotkey = (items[(index) * 2][0] != ':'); \ + do_print_item(menu, items[(index) * 2 + 1], choice, selected, hotkey); \ +} while (0) + +/* + * Print the scroll indicators. + */ +static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, + int height) +{ + int cur_y, cur_x; + + getyx(win, cur_y, cur_x); + + wmove(win, y, x); + + if (scroll > 0) { + wattrset(win, uarrow_attr); + waddch(win, ACS_UARROW); + waddstr(win, "(-)"); + } else { + wattrset(win, menubox_attr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + y = y + height + 1; + wmove(win, y, x); + wrefresh(win); + + if ((height < item_no) && (scroll + height < item_no)) { + wattrset(win, darrow_attr); + waddch(win, ACS_DARROW); + waddstr(win, "(+)"); + } else { + wattrset(win, menubox_border_attr); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + waddch(win, ACS_HLINE); + } + + wmove(win, cur_y, cur_x); + wrefresh(win); +} + +/* + * Display the termination buttons. + */ +static void print_buttons(WINDOW * win, int height, int width, int selected) +{ + int x = width / 2 - 16; + int y = height - 2; + + print_button(win, "Select", y, x, selected == 0); + print_button(win, " Exit ", y, x + 12, selected == 1); + print_button(win, " Help ", y, x + 24, selected == 2); + + wmove(win, y, x + 1 + 12 * selected); + wrefresh(win); +} + +/* scroll up n lines (n may be negative) */ +static void do_scroll(WINDOW *win, int *scroll, int n) +{ + /* Scroll menu up */ + scrollok(win, TRUE); + wscrl(win, n); + scrollok(win, FALSE); + *scroll = *scroll + n; + wrefresh(win); +} + +/* + * Display a menu for choosing among a number of options + */ +int dialog_menu(const char *title, const char *prompt, int height, int width, + int menu_height, const char *current, int item_no, + const char *const *items) +{ + int i, j, x, y, box_x, box_y; + int key = 0, button = 0, scroll = 0, choice = 0; + int first_item = 0, max_choice; + WINDOW *dialog, *menu; + FILE *f; + + max_choice = MIN(menu_height, item_no); + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + wbkgdset(dialog, dialog_attr & A_COLOR); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + menu_width = width - 6; + box_y = height - menu_height - 5; + box_x = (width - menu_width) / 2 - 1; + + /* create new window for the menu */ + menu = subwin(dialog, menu_height, menu_width, + y + box_y + 1, x + box_x + 1); + keypad(menu, TRUE); + + /* draw a box around the menu items */ + draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, + menubox_border_attr, menubox_attr); + + /* Set choice to default item */ + for (i = 0; i < item_no; i++) + if (strcmp(current, items[i * 2]) == 0) + choice = i; + + /* get the scroll info from the temp file */ + if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) { + if ((fscanf(f, "%d\n", &scroll) == 1) && (scroll <= choice) && + (scroll + max_choice > choice) && (scroll >= 0) && + (scroll + max_choice <= item_no)) { + first_item = scroll; + choice = choice - scroll; + fclose(f); + } else { + scroll = 0; + remove("lxdialog.scrltmp"); + fclose(f); + f = NULL; + } + } + if ((choice >= max_choice) || (f == NULL && choice >= max_choice / 2)) { + if (choice >= item_no - max_choice / 2) + scroll = first_item = item_no - max_choice; + else + scroll = first_item = choice - max_choice / 2; + choice = choice - scroll; + } + + /* Print the menu */ + for (i = 0; i < max_choice; i++) { + print_item(first_item + i, i, i == choice); + } + + wnoutrefresh(menu); + + print_arrows(dialog, item_no, scroll, + box_y, box_x + ITEM_IDENT + 1, menu_height); + + print_buttons(dialog, height, width, 0); + wmove(menu, choice, ITEM_IDENT + 1); + wrefresh(menu); + + while (key != ESC) { + key = wgetch(menu); + + if (key < 256 && isalpha(key)) + key = tolower(key); + + if (strchr("ynmh", key)) + i = max_choice; + else { + for (i = choice + 1; i < max_choice; i++) { + j = first_alpha(items[(scroll + i) * 2 + 1], "YyNnMmHh"); + if (key == tolower(items[(scroll + i) * 2 + 1][j])) + break; + } + if (i == max_choice) + for (i = 0; i < max_choice; i++) { + j = first_alpha(items [(scroll + i) * 2 + 1], "YyNnMmHh"); + if (key == tolower(items[(scroll + i) * 2 + 1][j])) + break; + } + } + + if (i < max_choice || + key == KEY_UP || key == KEY_DOWN || + key == '-' || key == '+' || + key == KEY_PPAGE || key == KEY_NPAGE) { + /* Remove highligt of current item */ + print_item(scroll + choice, choice, FALSE); + + if (key == KEY_UP || key == '-') { + if (choice < 2 && scroll) { + /* Scroll menu down */ + do_scroll(menu, &scroll, -1); + + print_item(scroll, 0, FALSE); + } else + choice = MAX(choice - 1, 0); + + } else if (key == KEY_DOWN || key == '+') { + print_item(scroll+choice, choice, FALSE); + + if ((choice > max_choice - 3) && + (scroll + max_choice < item_no)) { + /* Scroll menu up */ + do_scroll(menu, &scroll, 1); + + print_item(scroll+max_choice - 1, + max_choice - 1, FALSE); + } else + choice = MIN(choice + 1, max_choice - 1); + + } else if (key == KEY_PPAGE) { + scrollok(menu, TRUE); + for (i = 0; (i < max_choice); i++) { + if (scroll > 0) { + do_scroll(menu, &scroll, -1); + print_item(scroll, 0, FALSE); + } else { + if (choice > 0) + choice--; + } + } + + } else if (key == KEY_NPAGE) { + for (i = 0; (i < max_choice); i++) { + if (scroll + max_choice < item_no) { + do_scroll(menu, &scroll, 1); + print_item(scroll+max_choice-1, + max_choice - 1, FALSE); + } else { + if (choice + 1 < max_choice) + choice++; + } + } + } else + choice = i; + + print_item(scroll + choice, choice, TRUE); + + print_arrows(dialog, item_no, scroll, + box_y, box_x + ITEM_IDENT + 1, menu_height); + + wnoutrefresh(dialog); + wrefresh(menu); + + continue; /* wait for another key press */ + } + + switch (key) { + case KEY_LEFT: + case TAB: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) + ? 2 : (button > 2 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(menu); + break; + case ' ': + case 's': + case 'y': + case 'n': + case 'm': + case '/': + /* save scroll info */ + if ((f = fopen("lxdialog.scrltmp", "w")) != NULL) { + fprintf(f, "%d\n", scroll); + fclose(f); + } + delwin(dialog); + fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); + switch (key) { + case 's': + return 3; + case 'y': + return 3; + case 'n': + return 4; + case 'm': + return 5; + case ' ': + return 6; + case '/': + return 7; + } + return 0; + case 'h': + case '?': + button = 2; + case '\n': + delwin(dialog); + if (button == 2) + fprintf(stderr, "%s \"%s\"\n", + items[(scroll + choice) * 2], + items[(scroll + choice) * 2 + 1] + + first_alpha(items [(scroll + choice) * 2 + 1], "")); + else + fprintf(stderr, "%s\n", + items[(scroll + choice) * 2]); + + remove("lxdialog.scrltmp"); + return button; + case 'e': + case 'x': + key = ESC; + case ESC: + break; + } + } + + delwin(dialog); + remove("lxdialog.scrltmp"); + return -1; /* ESC pressed */ +} diff --git a/scripts/kconfig/lxdialog/msgbox.c b/scripts/kconfig/lxdialog/msgbox.c new file mode 100644 index 0000000..7323f54 --- /dev/null +++ b/scripts/kconfig/lxdialog/msgbox.c @@ -0,0 +1,71 @@ +/* + * msgbox.c -- implements the message box and info box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display a message box. Program will pause and display an "OK" button + * if the parameter 'pause' is non-zero. + */ +int dialog_msgbox(const char *title, const char *prompt, int height, int width, + int pause) +{ + int i, x, y, key = 0; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + + print_title(dialog, title, width); + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 2); + + if (pause) { + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + waddch(dialog, ACS_RTEE); + + print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE); + + wrefresh(dialog); + while (key != ESC && key != '\n' && key != ' ' && + key != 'O' && key != 'o' && key != 'X' && key != 'x') + key = wgetch(dialog); + } else { + key = '\n'; + wrefresh(dialog); + } + + delwin(dialog); + return key == ESC ? -1 : 0; +} diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c new file mode 100644 index 0000000..77848bb --- /dev/null +++ b/scripts/kconfig/lxdialog/textbox.c @@ -0,0 +1,533 @@ +/* + * textbox.c -- implements the text box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +static void back_lines(int n); +static void print_page(WINDOW * win, int height, int width); +static void print_line(WINDOW * win, int row, int width); +static char *get_line(void); +static void print_position(WINDOW * win, int height, int width); + +static int hscroll, fd, file_size, bytes_read; +static int begin_reached = 1, end_reached, page_length; +static char *buf, *page; + +/* + * Display text from a file in a dialog box. + */ +int dialog_textbox(const char *title, const char *file, int height, int width) +{ + int i, x, y, cur_x, cur_y, fpos, key = 0; + int passed_end; + char search_term[MAX_LEN + 1]; + WINDOW *dialog, *text; + + search_term[0] = '\0'; /* no search term entered yet */ + + /* Open input file for reading */ + if ((fd = open(file, O_RDONLY)) == -1) { + endwin(); + fprintf(stderr, "\nCan't open input file in dialog_textbox().\n"); + exit(-1); + } + /* Get file size. Actually, 'file_size' is the real file size - 1, + since it's only the last byte offset from the beginning */ + if ((file_size = lseek(fd, 0, SEEK_END)) == -1) { + endwin(); + fprintf(stderr, "\nError getting file size in dialog_textbox().\n"); + exit(-1); + } + /* Restore file pointer to beginning of file after getting file size */ + if (lseek(fd, 0, SEEK_SET) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); + exit(-1); + } + /* Allocate space for read buffer */ + if ((buf = malloc(BUF_SIZE + 1)) == NULL) { + endwin(); + fprintf(stderr, "\nCan't allocate memory in dialog_textbox().\n"); + exit(-1); + } + if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, "\nError reading file in dialog_textbox().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; /* mark end of valid data */ + page = buf; /* page is pointer to start of page to be displayed */ + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + /* Create window for text region, used for scrolling text */ + text = subwin(dialog, height - 4, width - 2, y + 1, x + 1); + wattrset(text, dialog_attr); + wbkgdset(text, dialog_attr & A_COLOR); + + keypad(text, TRUE); + + /* register the new window, along with its borders */ + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + wbkgdset(dialog, dialog_attr & A_COLOR); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE); + wnoutrefresh(dialog); + getyx(dialog, cur_y, cur_x); /* Save cursor position */ + + /* Print first page of text */ + attr_clear(text, height - 4, width - 2, dialog_attr); + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + + while ((key != ESC) && (key != '\n')) { + key = wgetch(dialog); + switch (key) { + case 'E': /* Exit */ + case 'e': + case 'X': + case 'x': + delwin(dialog); + free(buf); + close(fd); + return 0; + case 'g': /* First page */ + case KEY_HOME: + if (!begin_reached) { + begin_reached = 1; + /* First page not in buffer? */ + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); + exit(-1); + } + if (fpos > bytes_read) { /* Yes, we have to read it in */ + if (lseek(fd, 0, SEEK_SET) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in " + "dialog_textbox().\n"); + exit(-1); + } + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, "\nError reading file in dialog_textbox().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + } + page = buf; + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case 'G': /* Last page */ + case KEY_END: + + end_reached = 1; + /* Last page not in buffer? */ + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); + exit(-1); + } + if (fpos < file_size) { /* Yes, we have to read it in */ + if (lseek(fd, -BUF_SIZE, SEEK_END) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); + exit(-1); + } + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, "\nError reading file in dialog_textbox().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + } + page = buf + bytes_read; + back_lines(height - 4); + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + break; + case 'K': /* Previous line */ + case 'k': + case KEY_UP: + if (!begin_reached) { + back_lines(page_length + 1); + + /* We don't call print_page() here but use scrolling to ensure + faster screen update. However, 'end_reached' and + 'page_length' should still be updated, and 'page' should + point to start of next page. This is done by calling + get_line() in the following 'for' loop. */ + scrollok(text, TRUE); + wscrl(text, -1); /* Scroll text region down one line */ + scrollok(text, FALSE); + page_length = 0; + passed_end = 0; + for (i = 0; i < height - 4; i++) { + if (!i) { + /* print first line of page */ + print_line(text, 0, width - 2); + wnoutrefresh(text); + } else + /* Called to update 'end_reached' and 'page' */ + get_line(); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case 'B': /* Previous page */ + case 'b': + case KEY_PPAGE: + if (begin_reached) + break; + back_lines(page_length + height - 4); + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + break; + case 'J': /* Next line */ + case 'j': + case KEY_DOWN: + if (!end_reached) { + begin_reached = 0; + scrollok(text, TRUE); + scroll(text); /* Scroll text region up one line */ + scrollok(text, FALSE); + print_line(text, height - 5, width - 2); + wnoutrefresh(text); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); /* Restore cursor position */ + wrefresh(dialog); + } + break; + case KEY_NPAGE: /* Next page */ + case ' ': + if (end_reached) + break; + + begin_reached = 0; + print_page(text, height - 4, width - 2); + print_position(dialog, height, width); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + break; + case '0': /* Beginning of line */ + case 'H': /* Scroll left */ + case 'h': + case KEY_LEFT: + if (hscroll <= 0) + break; + + if (key == '0') + hscroll = 0; + else + hscroll--; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + print_page(text, height - 4, width - 2); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + break; + case 'L': /* Scroll right */ + case 'l': + case KEY_RIGHT: + if (hscroll >= MAX_LEN) + break; + hscroll++; + /* Reprint current page to scroll horizontally */ + back_lines(page_length); + print_page(text, height - 4, width - 2); + wmove(dialog, cur_y, cur_x); + wrefresh(dialog); + break; + case ESC: + break; + } + } + + delwin(dialog); + free(buf); + close(fd); + return -1; /* ESC pressed */ +} + +/* + * Go back 'n' lines in text file. Called by dialog_textbox(). + * 'page' will be updated to point to the desired line in 'buf'. + */ +static void back_lines(int n) +{ + int i, fpos; + + begin_reached = 0; + /* We have to distinguish between end_reached and !end_reached + since at end of file, the line is not ended by a '\n'. + The code inside 'if' basically does a '--page' to move one + character backward so as to skip '\n' of the previous line */ + if (!end_reached) { + /* Either beginning of buffer or beginning of file reached? */ + if (page == buf) { + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in " + "back_lines().\n"); + exit(-1); + } + if (fpos > bytes_read) { /* Not beginning of file yet */ + /* We've reached beginning of buffer, but not beginning of + file yet, so read previous part of file into buffer. + Note that we only move backward for BUF_SIZE/2 bytes, + but not BUF_SIZE bytes to avoid re-reading again in + print_page() later */ + /* Really possible to move backward BUF_SIZE/2 bytes? */ + if (fpos < BUF_SIZE / 2 + bytes_read) { + /* No, move less then */ + if (lseek(fd, 0, SEEK_SET) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in " + "back_lines().\n"); + exit(-1); + } + page = buf + fpos - bytes_read; + } else { /* Move backward BUF_SIZE/2 bytes */ + if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer " + "in back_lines().\n"); + exit(-1); + } + page = buf + BUF_SIZE / 2; + } + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, "\nError reading file in back_lines().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + } else { /* Beginning of file reached */ + begin_reached = 1; + return; + } + } + if (*(--page) != '\n') { /* '--page' here */ + /* Something's wrong... */ + endwin(); + fprintf(stderr, "\nInternal error in back_lines().\n"); + exit(-1); + } + } + /* Go back 'n' lines */ + for (i = 0; i < n; i++) + do { + if (page == buf) { + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in back_lines().\n"); + exit(-1); + } + if (fpos > bytes_read) { + /* Really possible to move backward BUF_SIZE/2 bytes? */ + if (fpos < BUF_SIZE / 2 + bytes_read) { + /* No, move less then */ + if (lseek(fd, 0, SEEK_SET) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer " + "in back_lines().\n"); + exit(-1); + } + page = buf + fpos - bytes_read; + } else { /* Move backward BUF_SIZE/2 bytes */ + if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer" + " in back_lines().\n"); + exit(-1); + } + page = buf + BUF_SIZE / 2; + } + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, "\nError reading file in " + "back_lines().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + } else { /* Beginning of file reached */ + begin_reached = 1; + return; + } + } + } while (*(--page) != '\n'); + page++; +} + +/* + * Print a new page of text. Called by dialog_textbox(). + */ +static void print_page(WINDOW * win, int height, int width) +{ + int i, passed_end = 0; + + page_length = 0; + for (i = 0; i < height; i++) { + print_line(win, i, width); + if (!passed_end) + page_length++; + if (end_reached && !passed_end) + passed_end = 1; + } + wnoutrefresh(win); +} + +/* + * Print a new line of text. Called by dialog_textbox() and print_page(). + */ +static void print_line(WINDOW * win, int row, int width) +{ + int y, x; + char *line; + + line = get_line(); + line += MIN(strlen(line), hscroll); /* Scroll horizontally */ + wmove(win, row, 0); /* move cursor to correct line */ + waddch(win, ' '); + waddnstr(win, line, MIN(strlen(line), width - 2)); + + getyx(win, y, x); + /* Clear 'residue' of previous line */ +#if OLD_NCURSES + { + int i; + for (i = 0; i < width - x; i++) + waddch(win, ' '); + } +#else + wclrtoeol(win); +#endif +} + +/* + * Return current line of text. Called by dialog_textbox() and print_line(). + * 'page' should point to start of current line before calling, and will be + * updated to point to start of next line. + */ +static char *get_line(void) +{ + int i = 0, fpos; + static char line[MAX_LEN + 1]; + + end_reached = 0; + while (*page != '\n') { + if (*page == '\0') { + /* Either end of file or end of buffer reached */ + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in " + "get_line().\n"); + exit(-1); + } + if (fpos < file_size) { /* Not end of file yet */ + /* We've reached end of buffer, but not end of file yet, + so read next part of file into buffer */ + if ((bytes_read = + read(fd, buf, BUF_SIZE)) == -1) { + endwin(); + fprintf(stderr, "\nError reading file in get_line().\n"); + exit(-1); + } + buf[bytes_read] = '\0'; + page = buf; + } else { + if (!end_reached) + end_reached = 1; + break; + } + } else if (i < MAX_LEN) + line[i++] = *(page++); + else { + /* Truncate lines longer than MAX_LEN characters */ + if (i == MAX_LEN) + line[i++] = '\0'; + page++; + } + } + if (i <= MAX_LEN) + line[i] = '\0'; + if (!end_reached) + page++; /* move pass '\n' */ + + return line; +} + +/* + * Print current position + */ +static void print_position(WINDOW * win, int height, int width) +{ + int fpos, percent; + + if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { + endwin(); + fprintf(stderr, "\nError moving file pointer in print_position().\n"); + exit(-1); + } + wattrset(win, position_indicator_attr); + wbkgdset(win, position_indicator_attr & A_COLOR); + percent = !file_size ? + 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; + wmove(win, height - 3, width - 9); + wprintw(win, "(%3d%%)", percent); +} diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c new file mode 100644 index 0000000..f82cebb --- /dev/null +++ b/scripts/kconfig/lxdialog/util.c @@ -0,0 +1,362 @@ +/* + * util.c + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* use colors by default? */ +bool use_colors = 1; + +const char *backtitle = NULL; + +/* + * Attribute values, default is for mono display + */ +chtype attributes[] = { + A_NORMAL, /* screen_attr */ + A_NORMAL, /* shadow_attr */ + A_NORMAL, /* dialog_attr */ + A_BOLD, /* title_attr */ + A_NORMAL, /* border_attr */ + A_REVERSE, /* button_active_attr */ + A_DIM, /* button_inactive_attr */ + A_REVERSE, /* button_key_active_attr */ + A_BOLD, /* button_key_inactive_attr */ + A_REVERSE, /* button_label_active_attr */ + A_NORMAL, /* button_label_inactive_attr */ + A_NORMAL, /* inputbox_attr */ + A_NORMAL, /* inputbox_border_attr */ + A_NORMAL, /* searchbox_attr */ + A_BOLD, /* searchbox_title_attr */ + A_NORMAL, /* searchbox_border_attr */ + A_BOLD, /* position_indicator_attr */ + A_NORMAL, /* menubox_attr */ + A_NORMAL, /* menubox_border_attr */ + A_NORMAL, /* item_attr */ + A_REVERSE, /* item_selected_attr */ + A_BOLD, /* tag_attr */ + A_REVERSE, /* tag_selected_attr */ + A_BOLD, /* tag_key_attr */ + A_REVERSE, /* tag_key_selected_attr */ + A_BOLD, /* check_attr */ + A_REVERSE, /* check_selected_attr */ + A_BOLD, /* uarrow_attr */ + A_BOLD /* darrow_attr */ +}; + +#include "colors.h" + +/* + * Table of color values + */ +int color_table[][3] = { + {SCREEN_FG, SCREEN_BG, SCREEN_HL}, + {SHADOW_FG, SHADOW_BG, SHADOW_HL}, + {DIALOG_FG, DIALOG_BG, DIALOG_HL}, + {TITLE_FG, TITLE_BG, TITLE_HL}, + {BORDER_FG, BORDER_BG, BORDER_HL}, + {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, + {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, + {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, + {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, + BUTTON_KEY_INACTIVE_HL}, + {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, + BUTTON_LABEL_ACTIVE_HL}, + {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, + BUTTON_LABEL_INACTIVE_HL}, + {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, + {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, + {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, + {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, + {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, + {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, + {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, + {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, + {ITEM_FG, ITEM_BG, ITEM_HL}, + {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, + {TAG_FG, TAG_BG, TAG_HL}, + {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, + {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, + {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, + {CHECK_FG, CHECK_BG, CHECK_HL}, + {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, + {UARROW_FG, UARROW_BG, UARROW_HL}, + {DARROW_FG, DARROW_BG, DARROW_HL}, +}; /* color_table */ + +/* + * Set window to attribute 'attr' + */ +void attr_clear(WINDOW * win, int height, int width, chtype attr) +{ + int i, j; + + wattrset(win, attr); + for (i = 0; i < height; i++) { + wmove(win, i, 0); + for (j = 0; j < width; j++) + waddch(win, ' '); + } + touchwin(win); +} + +void dialog_clear(void) +{ + attr_clear(stdscr, LINES, COLS, screen_attr); + /* Display background title if it exists ... - SLH */ + if (backtitle != NULL) { + int i; + + wattrset(stdscr, screen_attr); + mvwaddstr(stdscr, 0, 1, (char *)backtitle); + wmove(stdscr, 1, 1); + for (i = 1; i < COLS - 1; i++) + waddch(stdscr, ACS_HLINE); + } + wnoutrefresh(stdscr); +} + +/* + * Do some initialization for dialog + */ +void init_dialog(void) +{ + initscr(); /* Init curses */ + keypad(stdscr, TRUE); + cbreak(); + noecho(); + + if (use_colors) /* Set up colors */ + color_setup(); + + dialog_clear(); +} + +/* + * Setup for color display + */ +void color_setup(void) +{ + int i; + + if (has_colors()) { /* Terminal supports color? */ + start_color(); + + /* Initialize color pairs */ + for (i = 0; i < ATTRIBUTE_COUNT; i++) + init_pair(i + 1, color_table[i][0], color_table[i][1]); + + /* Setup color attributes */ + for (i = 0; i < ATTRIBUTE_COUNT; i++) + attributes[i] = C_ATTR(color_table[i][2], i + 1); + } +} + +/* + * End using dialog functions. + */ +void end_dialog(void) +{ + endwin(); +} + +/* Print the title of the dialog. Center the title and truncate + * tile if wider than dialog (- 2 chars). + **/ +void print_title(WINDOW *dialog, const char *title, int width) +{ + if (title) { + int tlen = MIN(width - 2, strlen(title)); + wattrset(dialog, title_attr); + mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); + mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); + waddch(dialog, ' '); + } +} + +/* + * Print a string of text in a window, automatically wrap around to the + * next line if the string is too long to fit on one line. Newline + * characters '\n' are replaced by spaces. We start on a new line + * if there is no room for at least 4 nonblanks following a double-space. + */ +void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) +{ + int newl, cur_x, cur_y; + int i, prompt_len, room, wlen; + char tempstr[MAX_LEN + 1], *word, *sp, *sp2; + + strcpy(tempstr, prompt); + + prompt_len = strlen(tempstr); + + /* + * Remove newlines + */ + for (i = 0; i < prompt_len; i++) { + if (tempstr[i] == '\n') + tempstr[i] = ' '; + } + + if (prompt_len <= width - x * 2) { /* If prompt is short */ + wmove(win, y, (width - prompt_len) / 2); + waddstr(win, tempstr); + } else { + cur_x = x; + cur_y = y; + newl = 1; + word = tempstr; + while (word && *word) { + sp = index(word, ' '); + if (sp) + *sp++ = 0; + + /* Wrap to next line if either the word does not fit, + or it is the first word of a new sentence, and it is + short, and the next word does not fit. */ + room = width - cur_x; + wlen = strlen(word); + if (wlen > room || + (newl && wlen < 4 && sp + && wlen + 1 + strlen(sp) > room + && (!(sp2 = index(sp, ' ')) + || wlen + 1 + (sp2 - sp) > room))) { + cur_y++; + cur_x = x; + } + wmove(win, cur_y, cur_x); + waddstr(win, word); + getyx(win, cur_y, cur_x); + cur_x++; + if (sp && *sp == ' ') { + cur_x++; /* double space */ + while (*++sp == ' ') ; + newl = 1; + } else + newl = 0; + word = sp; + } + } +} + +/* + * Print a button + */ +void print_button(WINDOW * win, const char *label, int y, int x, int selected) +{ + int i, temp; + + wmove(win, y, x); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, "<"); + temp = strspn(label, " "); + label += temp; + wattrset(win, selected ? button_label_active_attr + : button_label_inactive_attr); + for (i = 0; i < temp; i++) + waddch(win, ' '); + wattrset(win, selected ? button_key_active_attr + : button_key_inactive_attr); + waddch(win, label[0]); + wattrset(win, selected ? button_label_active_attr + : button_label_inactive_attr); + waddstr(win, (char *)label + 1); + wattrset(win, selected ? button_active_attr : button_inactive_attr); + waddstr(win, ">"); + wmove(win, y, x + temp + 1); +} + +/* + * Draw a rectangular box with line drawing characters + */ +void +draw_box(WINDOW * win, int y, int x, int height, int width, + chtype box, chtype border) +{ + int i, j; + + wattrset(win, 0); + for (i = 0; i < height; i++) { + wmove(win, y + i, x); + for (j = 0; j < width; j++) + if (!i && !j) + waddch(win, border | ACS_ULCORNER); + else if (i == height - 1 && !j) + waddch(win, border | ACS_LLCORNER); + else if (!i && j == width - 1) + waddch(win, box | ACS_URCORNER); + else if (i == height - 1 && j == width - 1) + waddch(win, box | ACS_LRCORNER); + else if (!i) + waddch(win, border | ACS_HLINE); + else if (i == height - 1) + waddch(win, box | ACS_HLINE); + else if (!j) + waddch(win, border | ACS_VLINE); + else if (j == width - 1) + waddch(win, box | ACS_VLINE); + else + waddch(win, box | ' '); + } +} + +/* + * Draw shadows along the right and bottom edge to give a more 3D look + * to the boxes + */ +void draw_shadow(WINDOW * win, int y, int x, int height, int width) +{ + int i; + + if (has_colors()) { /* Whether terminal supports color? */ + wattrset(win, shadow_attr); + wmove(win, y + height, x + 2); + for (i = 0; i < width; i++) + waddch(win, winch(win) & A_CHARTEXT); + for (i = y + 1; i < y + height + 1; i++) { + wmove(win, i, x + width); + waddch(win, winch(win) & A_CHARTEXT); + waddch(win, winch(win) & A_CHARTEXT); + } + wnoutrefresh(win); + } +} + +/* + * Return the position of the first alphabetic character in a string. + */ +int first_alpha(const char *string, const char *exempt) +{ + int i, in_paren = 0, c; + + for (i = 0; i < strlen(string); i++) { + c = tolower(string[i]); + + if (strchr("<[(", c)) + ++in_paren; + if (strchr(">])", c) && in_paren > 0) + --in_paren; + + if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) + return i; + } + + return 0; +} diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c new file mode 100644 index 0000000..cb2568a --- /dev/null +++ b/scripts/kconfig/lxdialog/yesno.c @@ -0,0 +1,102 @@ +/* + * yesno.c -- implements the yes/no box + * + * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) + * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "dialog.h" + +/* + * Display termination buttons + */ +static void print_buttons(WINDOW * dialog, int height, int width, int selected) +{ + int x = width / 2 - 10; + int y = height - 2; + + print_button(dialog, " Yes ", y, x, selected == 0); + print_button(dialog, " No ", y, x + 13, selected == 1); + + wmove(dialog, y, x + 1 + 13 * selected); + wrefresh(dialog); +} + +/* + * Display a dialog box with two buttons - Yes and No + */ +int dialog_yesno(const char *title, const char *prompt, int height, int width) +{ + int i, x, y, key = 0, button = 0; + WINDOW *dialog; + + /* center dialog box on screen */ + x = (COLS - width) / 2; + y = (LINES - height) / 2; + + draw_shadow(stdscr, y, x, height, width); + + dialog = newwin(height, width, y, x); + keypad(dialog, TRUE); + + draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); + wattrset(dialog, border_attr); + mvwaddch(dialog, height - 3, 0, ACS_LTEE); + for (i = 0; i < width - 2; i++) + waddch(dialog, ACS_HLINE); + wattrset(dialog, dialog_attr); + waddch(dialog, ACS_RTEE); + + print_title(dialog, title, width); + + wattrset(dialog, dialog_attr); + print_autowrap(dialog, prompt, width - 2, 1, 3); + + print_buttons(dialog, height, width, 0); + + while (key != ESC) { + key = wgetch(dialog); + switch (key) { + case 'Y': + case 'y': + delwin(dialog); + return 0; + case 'N': + case 'n': + delwin(dialog); + return 1; + + case TAB: + case KEY_LEFT: + case KEY_RIGHT: + button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); + + print_buttons(dialog, height, width, button); + wrefresh(dialog); + break; + case ' ': + case '\n': + delwin(dialog); + return button; + case ESC: + break; + } + } + + delwin(dialog); + return -1; /* ESC pressed */ +} diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index d1ad405..d63d7fb 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -325,7 +325,7 @@ static void cprint_init(void) memset(args, 0, sizeof(args)); indent = 0; child_count = 0; - cprint("./scripts/lxdialog/lxdialog"); + cprint("./scripts/kconfig/lxdialog/lxdialog"); cprint("--backtitle"); cprint(menu_backtitle); } diff --git a/scripts/lxdialog/BIG.FAT.WARNING b/scripts/lxdialog/BIG.FAT.WARNING deleted file mode 100644 index a8999d8..0000000 --- a/scripts/lxdialog/BIG.FAT.WARNING +++ /dev/null @@ -1,4 +0,0 @@ -This is NOT the official version of dialog. This version has been -significantly modified from the original. It is for use by the Linux -kernel configuration script. Please do not bother Savio Lam with -questions about this program. diff --git a/scripts/lxdialog/Makefile b/scripts/lxdialog/Makefile deleted file mode 100644 index a45a13f..0000000 --- a/scripts/lxdialog/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -HOST_EXTRACFLAGS := -DLOCALE -ifeq ($(shell uname),SunOS) -HOST_LOADLIBES := -lcurses -else -HOST_LOADLIBES := -lncurses -endif - -ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h)) - HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>" -else -ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h)) - HOST_EXTRACFLAGS += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>" -else -ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h)) - HOST_EXTRACFLAGS += -DCURSES_LOC="<ncurses.h>" -else - HOST_EXTRACFLAGS += -DCURSES_LOC="<curses.h>" -endif -endif -endif - -hostprogs-y := lxdialog -always := ncurses $(hostprogs-y) - -lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \ - util.o lxdialog.o msgbox.o - -.PHONY: $(obj)/ncurses -$(obj)/ncurses: - @echo "main() {}" > lxtemp.c - @if $(HOSTCC) lxtemp.c $(HOST_LOADLIBES); then \ - rm -f lxtemp.c a.out; \ - else \ - rm -f lxtemp.c; \ - echo -e "\007" ;\ - echo ">> Unable to find the Ncurses libraries." ;\ - echo ">>" ;\ - echo ">> You must install ncurses-devel in order" ;\ - echo ">> to use 'make menuconfig'" ;\ - echo ;\ - exit 1 ;\ - fi diff --git a/scripts/lxdialog/checklist.c b/scripts/lxdialog/checklist.c deleted file mode 100644 index 3fb681f..0000000 --- a/scripts/lxdialog/checklist.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * checklist.c -- implements the checklist box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension - * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -static int list_width, check_x, item_x, checkflag; - -/* - * Print list item - */ -static void print_item(WINDOW * win, const char *item, int status, int choice, - int selected) -{ - int i; - - /* Clear 'residue' of last item */ - wattrset(win, menubox_attr); - wmove(win, choice, 0); - for (i = 0; i < list_width; i++) - waddch(win, ' '); - - wmove(win, choice, check_x); - wattrset(win, selected ? check_selected_attr : check_attr); - if (checkflag == FLAG_CHECK) - wprintw(win, "[%c]", status ? 'X' : ' '); - else - wprintw(win, "(%c)", status ? 'X' : ' '); - - wattrset(win, selected ? tag_selected_attr : tag_attr); - mvwaddch(win, choice, item_x, item[0]); - wattrset(win, selected ? item_selected_attr : item_attr); - waddstr(win, (char *)item + 1); - if (selected) { - wmove(win, choice, check_x + 1); - wrefresh(win); - } -} - -/* - * Print the scroll indicators. - */ -static void print_arrows(WINDOW * win, int choice, int item_no, int scroll, - int y, int x, int height) -{ - wmove(win, y, x); - - if (scroll > 0) { - wattrset(win, uarrow_attr); - waddch(win, ACS_UARROW); - waddstr(win, "(-)"); - } else { - wattrset(win, menubox_attr); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - } - - y = y + height + 1; - wmove(win, y, x); - - if ((height < item_no) && (scroll + choice < item_no - 1)) { - wattrset(win, darrow_attr); - waddch(win, ACS_DARROW); - waddstr(win, "(+)"); - } else { - wattrset(win, menubox_border_attr); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - } -} - -/* - * Display the termination buttons - */ -static void print_buttons(WINDOW * dialog, int height, int width, int selected) -{ - int x = width / 2 - 11; - int y = height - 2; - - print_button(dialog, "Select", y, x, selected == 0); - print_button(dialog, " Help ", y, x + 14, selected == 1); - - wmove(dialog, y, x + 1 + 14 * selected); - wrefresh(dialog); -} - -/* - * Display a dialog box with a list of options that can be turned on or off - * The `flag' parameter is used to select between radiolist and checklist. - */ -int dialog_checklist(const char *title, const char *prompt, int height, - int width, int list_height, int item_no, - const char *const *items, int flag) -{ - int i, x, y, box_x, box_y; - int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; - WINDOW *dialog, *list; - - checkflag = flag; - - /* Allocate space for storing item on/off status */ - if ((status = malloc(sizeof(int) * item_no)) == NULL) { - endwin(); - fprintf(stderr, - "\nCan't allocate memory in dialog_checklist().\n"); - exit(-1); - } - - /* Initializes status */ - for (i = 0; i < item_no; i++) { - status[i] = !strcasecmp(items[i * 3 + 2], "on"); - if ((!choice && status[i]) - || !strcasecmp(items[i * 3 + 2], "selected")) - choice = i + 1; - } - if (choice) - choice--; - - max_choice = MIN(list_height, item_no); - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow(stdscr, y, x, height, width); - - dialog = newwin(height, width, y, x); - keypad(dialog, TRUE); - - draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset(dialog, border_attr); - mvwaddch(dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch(dialog, ACS_HLINE); - wattrset(dialog, dialog_attr); - waddch(dialog, ACS_RTEE); - - print_title(dialog, title, width); - - wattrset(dialog, dialog_attr); - print_autowrap(dialog, prompt, width - 2, 1, 3); - - list_width = width - 6; - box_y = height - list_height - 5; - box_x = (width - list_width) / 2 - 1; - - /* create new window for the list */ - list = subwin(dialog, list_height, list_width, y + box_y + 1, - x + box_x + 1); - - keypad(list, TRUE); - - /* draw a box around the list items */ - draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2, - menubox_border_attr, menubox_attr); - - /* Find length of longest item in order to center checklist */ - check_x = 0; - for (i = 0; i < item_no; i++) - check_x = MAX(check_x, +strlen(items[i * 3 + 1]) + 4); - - check_x = (list_width - check_x) / 2; - item_x = check_x + 4; - - if (choice >= list_height) { - scroll = choice - list_height + 1; - choice -= scroll; - } - - /* Print the list */ - for (i = 0; i < max_choice; i++) { - print_item(list, items[(scroll + i) * 3 + 1], - status[i + scroll], i, i == choice); - } - - print_arrows(dialog, choice, item_no, scroll, - box_y, box_x + check_x + 5, list_height); - - print_buttons(dialog, height, width, 0); - - wnoutrefresh(list); - wnoutrefresh(dialog); - doupdate(); - - while (key != ESC) { - key = wgetch(dialog); - - for (i = 0; i < max_choice; i++) - if (toupper(key) == - toupper(items[(scroll + i) * 3 + 1][0])) - break; - - if (i < max_choice || key == KEY_UP || key == KEY_DOWN || - key == '+' || key == '-') { - if (key == KEY_UP || key == '-') { - if (!choice) { - if (!scroll) - continue; - /* Scroll list down */ - if (list_height > 1) { - /* De-highlight current first item */ - print_item(list, items[scroll * 3 + 1], - status[scroll], 0, FALSE); - scrollok(list, TRUE); - wscrl(list, -1); - scrollok(list, FALSE); - } - scroll--; - print_item(list, items[scroll * 3 + 1], status[scroll], 0, TRUE); - wnoutrefresh(list); - - print_arrows(dialog, choice, item_no, - scroll, box_y, box_x + check_x + 5, list_height); - - wrefresh(dialog); - - continue; /* wait for another key press */ - } else - i = choice - 1; - } else if (key == KEY_DOWN || key == '+') { - if (choice == max_choice - 1) { - if (scroll + choice >= item_no - 1) - continue; - /* Scroll list up */ - if (list_height > 1) { - /* De-highlight current last item before scrolling up */ - print_item(list, items[(scroll + max_choice - 1) * 3 + 1], - status[scroll + max_choice - 1], - max_choice - 1, FALSE); - scrollok(list, TRUE); - wscrl(list, 1); - scrollok(list, FALSE); - } - scroll++; - print_item(list, items[(scroll + max_choice - 1) * 3 + 1], - status[scroll + max_choice - 1], max_choice - 1, TRUE); - wnoutrefresh(list); - - print_arrows(dialog, choice, item_no, - scroll, box_y, box_x + check_x + 5, list_height); - - wrefresh(dialog); - - continue; /* wait for another key press */ - } else - i = choice + 1; - } - if (i != choice) { - /* De-highlight current item */ - print_item(list, items[(scroll + choice) * 3 + 1], - status[scroll + choice], choice, FALSE); - /* Highlight new item */ - choice = i; - print_item(list, items[(scroll + choice) * 3 + 1], - status[scroll + choice], choice, TRUE); - wnoutrefresh(list); - wrefresh(dialog); - } - continue; /* wait for another key press */ - } - switch (key) { - case 'H': - case 'h': - case '?': - fprintf(stderr, "%s", items[(scroll + choice) * 3]); - delwin(dialog); - free(status); - return 1; - case TAB: - case KEY_LEFT: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 1 : (button > 1 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh(dialog); - break; - case 'S': - case 's': - case ' ': - case '\n': - if (!button) { - if (flag == FLAG_CHECK) { - status[scroll + choice] = !status[scroll + choice]; - wmove(list, choice, check_x); - wattrset(list, check_selected_attr); - wprintw(list, "[%c]", status[scroll + choice] ? 'X' : ' '); - } else { - if (!status[scroll + choice]) { - for (i = 0; i < item_no; i++) - status[i] = 0; - status[scroll + choice] = 1; - for (i = 0; i < max_choice; i++) - print_item(list, items[(scroll + i) * 3 + 1], - status[scroll + i], i, i == choice); - } - } - wnoutrefresh(list); - wrefresh(dialog); - - for (i = 0; i < item_no; i++) { - if (status[i]) { - if (flag == FLAG_CHECK) { - fprintf(stderr, "\"%s\" ", items[i * 3]); - } else { - fprintf(stderr, "%s", items[i * 3]); - } - - } - } - } else - fprintf(stderr, "%s", items[(scroll + choice) * 3]); - delwin(dialog); - free(status); - return button; - case 'X': - case 'x': - key = ESC; - case ESC: - break; - } - - /* Now, update everything... */ - doupdate(); - } - - delwin(dialog); - free(status); - return -1; /* ESC pressed */ -} diff --git a/scripts/lxdialog/colors.h b/scripts/lxdialog/colors.h deleted file mode 100644 index db071df1..0000000 --- a/scripts/lxdialog/colors.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * colors.h -- color attribute definitions - * - * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* - * Default color definitions - * - * *_FG = foreground - * *_BG = background - * *_HL = highlight? - */ -#define SCREEN_FG COLOR_CYAN -#define SCREEN_BG COLOR_BLUE -#define SCREEN_HL TRUE - -#define SHADOW_FG COLOR_BLACK -#define SHADOW_BG COLOR_BLACK -#define SHADOW_HL TRUE - -#define DIALOG_FG COLOR_BLACK -#define DIALOG_BG COLOR_WHITE -#define DIALOG_HL FALSE - -#define TITLE_FG COLOR_YELLOW -#define TITLE_BG COLOR_WHITE -#define TITLE_HL TRUE - -#define BORDER_FG COLOR_WHITE -#define BORDER_BG COLOR_WHITE -#define BORDER_HL TRUE - -#define BUTTON_ACTIVE_FG COLOR_WHITE -#define BUTTON_ACTIVE_BG COLOR_BLUE -#define BUTTON_ACTIVE_HL TRUE - -#define BUTTON_INACTIVE_FG COLOR_BLACK -#define BUTTON_INACTIVE_BG COLOR_WHITE -#define BUTTON_INACTIVE_HL FALSE - -#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE -#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE -#define BUTTON_KEY_ACTIVE_HL TRUE - -#define BUTTON_KEY_INACTIVE_FG COLOR_RED -#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE -#define BUTTON_KEY_INACTIVE_HL FALSE - -#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW -#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE -#define BUTTON_LABEL_ACTIVE_HL TRUE - -#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK -#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE -#define BUTTON_LABEL_INACTIVE_HL TRUE - -#define INPUTBOX_FG COLOR_BLACK -#define INPUTBOX_BG COLOR_WHITE -#define INPUTBOX_HL FALSE - -#define INPUTBOX_BORDER_FG COLOR_BLACK -#define INPUTBOX_BORDER_BG COLOR_WHITE -#define INPUTBOX_BORDER_HL FALSE - -#define SEARCHBOX_FG COLOR_BLACK -#define SEARCHBOX_BG COLOR_WHITE -#define SEARCHBOX_HL FALSE - -#define SEARCHBOX_TITLE_FG COLOR_YELLOW -#define SEARCHBOX_TITLE_BG COLOR_WHITE -#define SEARCHBOX_TITLE_HL TRUE - -#define SEARCHBOX_BORDER_FG COLOR_WHITE -#define SEARCHBOX_BORDER_BG COLOR_WHITE -#define SEARCHBOX_BORDER_HL TRUE - -#define POSITION_INDICATOR_FG COLOR_YELLOW -#define POSITION_INDICATOR_BG COLOR_WHITE -#define POSITION_INDICATOR_HL TRUE - -#define MENUBOX_FG COLOR_BLACK -#define MENUBOX_BG COLOR_WHITE -#define MENUBOX_HL FALSE - -#define MENUBOX_BORDER_FG COLOR_WHITE -#define MENUBOX_BORDER_BG COLOR_WHITE -#define MENUBOX_BORDER_HL TRUE - -#define ITEM_FG COLOR_BLACK -#define ITEM_BG COLOR_WHITE -#define ITEM_HL FALSE - -#define ITEM_SELECTED_FG COLOR_WHITE -#define ITEM_SELECTED_BG COLOR_BLUE -#define ITEM_SELECTED_HL TRUE - -#define TAG_FG COLOR_YELLOW -#define TAG_BG COLOR_WHITE -#define TAG_HL TRUE - -#define TAG_SELECTED_FG COLOR_YELLOW -#define TAG_SELECTED_BG COLOR_BLUE -#define TAG_SELECTED_HL TRUE - -#define TAG_KEY_FG COLOR_YELLOW -#define TAG_KEY_BG COLOR_WHITE -#define TAG_KEY_HL TRUE - -#define TAG_KEY_SELECTED_FG COLOR_YELLOW -#define TAG_KEY_SELECTED_BG COLOR_BLUE -#define TAG_KEY_SELECTED_HL TRUE - -#define CHECK_FG COLOR_BLACK -#define CHECK_BG COLOR_WHITE -#define CHECK_HL FALSE - -#define CHECK_SELECTED_FG COLOR_WHITE -#define CHECK_SELECTED_BG COLOR_BLUE -#define CHECK_SELECTED_HL TRUE - -#define UARROW_FG COLOR_GREEN -#define UARROW_BG COLOR_WHITE -#define UARROW_HL TRUE - -#define DARROW_FG COLOR_GREEN -#define DARROW_BG COLOR_WHITE -#define DARROW_HL TRUE - -/* End of default color definitions */ - -#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y))) -#define COLOR_NAME_LEN 10 -#define COLOR_COUNT 8 - -/* - * Global variables - */ - -extern int color_table[][3]; diff --git a/scripts/lxdialog/dialog.h b/scripts/lxdialog/dialog.h deleted file mode 100644 index f882204..0000000 --- a/scripts/lxdialog/dialog.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * dialog.h -- common declarations for all dialog modules - * - * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#include <ctype.h> -#include <stdlib.h> -#include <string.h> - -#ifdef __sun__ -#define CURS_MACROS -#endif -#include CURSES_LOC - -/* - * Colors in ncurses 1.9.9e do not work properly since foreground and - * background colors are OR'd rather than separately masked. This version - * of dialog was hacked to work with ncurses 1.9.9e, making it incompatible - * with standard curses. The simplest fix (to make this work with standard - * curses) uses the wbkgdset() function, not used in the original hack. - * Turn it off if we're building with 1.9.9e, since it just confuses things. - */ -#if defined(NCURSES_VERSION) && defined(_NEED_WRAP) && !defined(GCC_PRINTFLIKE) -#define OLD_NCURSES 1 -#undef wbkgdset -#define wbkgdset(w,p) /*nothing */ -#else -#define OLD_NCURSES 0 -#endif - -#define TR(params) _tracef params - -#define ESC 27 -#define TAB 9 -#define MAX_LEN 2048 -#define BUF_SIZE (10*1024) -#define MIN(x,y) (x < y ? x : y) -#define MAX(x,y) (x > y ? x : y) - -#ifndef ACS_ULCORNER -#define ACS_ULCORNER '+' -#endif -#ifndef ACS_LLCORNER -#define ACS_LLCORNER '+' -#endif -#ifndef ACS_URCORNER -#define ACS_URCORNER '+' -#endif -#ifndef ACS_LRCORNER -#define ACS_LRCORNER '+' -#endif -#ifndef ACS_HLINE -#define ACS_HLINE '-' -#endif -#ifndef ACS_VLINE -#define ACS_VLINE '|' -#endif -#ifndef ACS_LTEE -#define ACS_LTEE '+' -#endif -#ifndef ACS_RTEE -#define ACS_RTEE '+' -#endif -#ifndef ACS_UARROW -#define ACS_UARROW '^' -#endif -#ifndef ACS_DARROW -#define ACS_DARROW 'v' -#endif - -/* - * Attribute names - */ -#define screen_attr attributes[0] -#define shadow_attr attributes[1] -#define dialog_attr attributes[2] -#define title_attr attributes[3] -#define border_attr attributes[4] -#define button_active_attr attributes[5] -#define button_inactive_attr attributes[6] -#define button_key_active_attr attributes[7] -#define button_key_inactive_attr attributes[8] -#define button_label_active_attr attributes[9] -#define button_label_inactive_attr attributes[10] -#define inputbox_attr attributes[11] -#define inputbox_border_attr attributes[12] -#define searchbox_attr attributes[13] -#define searchbox_title_attr attributes[14] -#define searchbox_border_attr attributes[15] -#define position_indicator_attr attributes[16] -#define menubox_attr attributes[17] -#define menubox_border_attr attributes[18] -#define item_attr attributes[19] -#define item_selected_attr attributes[20] -#define tag_attr attributes[21] -#define tag_selected_attr attributes[22] -#define tag_key_attr attributes[23] -#define tag_key_selected_attr attributes[24] -#define check_attr attributes[25] -#define check_selected_attr attributes[26] -#define uarrow_attr attributes[27] -#define darrow_attr attributes[28] - -/* number of attributes */ -#define ATTRIBUTE_COUNT 29 - -/* - * Global variables - */ -extern bool use_colors; -extern bool use_shadow; - -extern chtype attributes[]; - -extern const char *backtitle; - -/* - * Function prototypes - */ -extern void create_rc(const char *filename); -extern int parse_rc(void); - -void init_dialog(void); -void end_dialog(void); -void attr_clear(WINDOW * win, int height, int width, chtype attr); -void dialog_clear(void); -void color_setup(void); -void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); -void print_button(WINDOW * win, const char *label, int y, int x, int selected); -void print_title(WINDOW *dialog, const char *title, int width); -void draw_box(WINDOW * win, int y, int x, int height, int width, chtype box, - chtype border); -void draw_shadow(WINDOW * win, int y, int x, int height, int width); - -int first_alpha(const char *string, const char *exempt); -int dialog_yesno(const char *title, const char *prompt, int height, int width); -int dialog_msgbox(const char *title, const char *prompt, int height, - int width, int pause); -int dialog_textbox(const char *title, const char *file, int height, int width); -int dialog_menu(const char *title, const char *prompt, int height, int width, - int menu_height, const char *choice, int item_no, - const char *const *items); -int dialog_checklist(const char *title, const char *prompt, int height, - int width, int list_height, int item_no, - const char *const *items, int flag); -extern char dialog_input_result[]; -int dialog_inputbox(const char *title, const char *prompt, int height, - int width, const char *init); - -/* - * This is the base for fictitious keys, which activate - * the buttons. - * - * Mouse-generated keys are the following: - * -- the first 32 are used as numbers, in addition to '0'-'9' - * -- the lowercase are used to signal mouse-enter events (M_EVENT + 'o') - * -- uppercase chars are used to invoke the button (M_EVENT + 'O') - */ -#define M_EVENT (KEY_MAX+1) - -/* - * The `flag' parameter in checklist is used to select between - * radiolist and checklist - */ -#define FLAG_CHECK 1 -#define FLAG_RADIO 0 diff --git a/scripts/lxdialog/inputbox.c b/scripts/lxdialog/inputbox.c deleted file mode 100644 index 7795037..0000000 --- a/scripts/lxdialog/inputbox.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * inputbox.c -- implements the input box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -char dialog_input_result[MAX_LEN + 1]; - -/* - * Print the termination buttons - */ -static void print_buttons(WINDOW * dialog, int height, int width, int selected) -{ - int x = width / 2 - 11; - int y = height - 2; - - print_button(dialog, " Ok ", y, x, selected == 0); - print_button(dialog, " Help ", y, x + 14, selected == 1); - - wmove(dialog, y, x + 1 + 14 * selected); - wrefresh(dialog); -} - -/* - * Display a dialog box for inputing a string - */ -int dialog_inputbox(const char *title, const char *prompt, int height, int width, - const char *init) -{ - int i, x, y, box_y, box_x, box_width; - int input_x = 0, scroll = 0, key = 0, button = -1; - char *instr = dialog_input_result; - WINDOW *dialog; - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow(stdscr, y, x, height, width); - - dialog = newwin(height, width, y, x); - keypad(dialog, TRUE); - - draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset(dialog, border_attr); - mvwaddch(dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch(dialog, ACS_HLINE); - wattrset(dialog, dialog_attr); - waddch(dialog, ACS_RTEE); - - print_title(dialog, title, width); - - wattrset(dialog, dialog_attr); - print_autowrap(dialog, prompt, width - 2, 1, 3); - - /* Draw the input field box */ - box_width = width - 6; - getyx(dialog, y, x); - box_y = y + 2; - box_x = (width - box_width) / 2; - draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); - - print_buttons(dialog, height, width, 0); - - /* Set up the initial value */ - wmove(dialog, box_y, box_x); - wattrset(dialog, inputbox_attr); - - if (!init) - instr[0] = '\0'; - else - strcpy(instr, init); - - input_x = strlen(instr); - - if (input_x >= box_width) { - scroll = input_x - box_width + 1; - input_x = box_width - 1; - for (i = 0; i < box_width - 1; i++) - waddch(dialog, instr[scroll + i]); - } else { - waddstr(dialog, instr); - } - - wmove(dialog, box_y, box_x + input_x); - - wrefresh(dialog); - - while (key != ESC) { - key = wgetch(dialog); - - if (button == -1) { /* Input box selected */ - switch (key) { - case TAB: - case KEY_UP: - case KEY_DOWN: - break; - case KEY_LEFT: - continue; - case KEY_RIGHT: - continue; - case KEY_BACKSPACE: - case 127: - if (input_x || scroll) { - wattrset(dialog, inputbox_attr); - if (!input_x) { - scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); - wmove(dialog, box_y, box_x); - for (i = 0; i < box_width; i++) - waddch(dialog, - instr[scroll + input_x + i] ? - instr[scroll + input_x + i] : ' '); - input_x = strlen(instr) - scroll; - } else - input_x--; - instr[scroll + input_x] = '\0'; - mvwaddch(dialog, box_y, input_x + box_x, ' '); - wmove(dialog, box_y, input_x + box_x); - wrefresh(dialog); - } - continue; - default: - if (key < 0x100 && isprint(key)) { - if (scroll + input_x < MAX_LEN) { - wattrset(dialog, inputbox_attr); - instr[scroll + input_x] = key; - instr[scroll + input_x + 1] = '\0'; - if (input_x == box_width - 1) { - scroll++; - wmove(dialog, box_y, box_x); - for (i = 0; i < box_width - 1; i++) - waddch(dialog, instr [scroll + i]); - } else { - wmove(dialog, box_y, input_x++ + box_x); - waddch(dialog, key); - } - wrefresh(dialog); - } else - flash(); /* Alarm user about overflow */ - continue; - } - } - } - switch (key) { - case 'O': - case 'o': - delwin(dialog); - return 0; - case 'H': - case 'h': - delwin(dialog); - return 1; - case KEY_UP: - case KEY_LEFT: - switch (button) { - case -1: - button = 1; /* Indicates "Cancel" button is selected */ - print_buttons(dialog, height, width, 1); - break; - case 0: - button = -1; /* Indicates input box is selected */ - print_buttons(dialog, height, width, 0); - wmove(dialog, box_y, box_x + input_x); - wrefresh(dialog); - break; - case 1: - button = 0; /* Indicates "OK" button is selected */ - print_buttons(dialog, height, width, 0); - break; - } - break; - case TAB: - case KEY_DOWN: - case KEY_RIGHT: - switch (button) { - case -1: - button = 0; /* Indicates "OK" button is selected */ - print_buttons(dialog, height, width, 0); - break; - case 0: - button = 1; /* Indicates "Cancel" button is selected */ - print_buttons(dialog, height, width, 1); - break; - case 1: - button = -1; /* Indicates input box is selected */ - print_buttons(dialog, height, width, 0); - wmove(dialog, box_y, box_x + input_x); - wrefresh(dialog); - break; - } - break; - case ' ': - case '\n': - delwin(dialog); - return (button == -1 ? 0 : button); - case 'X': - case 'x': - key = ESC; - case ESC: - break; - } - } - - delwin(dialog); - return -1; /* ESC pressed */ -} diff --git a/scripts/lxdialog/lxdialog.c b/scripts/lxdialog/lxdialog.c deleted file mode 100644 index 2c34ea1..0000000 --- a/scripts/lxdialog/lxdialog.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * dialog - Display simple dialog boxes from shell scripts - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -static void Usage(const char *name); - -typedef int (jumperFn) (const char *title, int argc, const char *const *argv); - -struct Mode { - char *name; - int argmin, argmax, argmod; - jumperFn *jumper; -}; - -jumperFn j_menu, j_checklist, j_radiolist, j_yesno, j_textbox, j_inputbox; -jumperFn j_msgbox, j_infobox; - -static struct Mode modes[] = { - {"--menu", 9, 0, 3, j_menu}, - {"--checklist", 9, 0, 3, j_checklist}, - {"--radiolist", 9, 0, 3, j_radiolist}, - {"--yesno", 5, 5, 1, j_yesno}, - {"--textbox", 5, 5, 1, j_textbox}, - {"--inputbox", 5, 6, 1, j_inputbox}, - {"--msgbox", 5, 5, 1, j_msgbox}, - {"--infobox", 5, 5, 1, j_infobox}, - {NULL, 0, 0, 0, NULL} -}; - -static struct Mode *modePtr; - -#ifdef LOCALE -#include <locale.h> -#endif - -int main(int argc, const char *const *argv) -{ - int offset = 0, opt_clear = 0, end_common_opts = 0, retval; - const char *title = NULL; - -#ifdef LOCALE - (void)setlocale(LC_ALL, ""); -#endif - -#ifdef TRACE - trace(TRACE_CALLS | TRACE_UPDATE); -#endif - if (argc < 2) { - Usage(argv[0]); - exit(-1); - } - - while (offset < argc - 1 && !end_common_opts) { /* Common options */ - if (!strcmp(argv[offset + 1], "--title")) { - if (argc - offset < 3 || title != NULL) { - Usage(argv[0]); - exit(-1); - } else { - title = argv[offset + 2]; - offset += 2; - } - } else if (!strcmp(argv[offset + 1], "--backtitle")) { - if (backtitle != NULL) { - Usage(argv[0]); - exit(-1); - } else { - backtitle = argv[offset + 2]; - offset += 2; - } - } else if (!strcmp(argv[offset + 1], "--clear")) { - if (opt_clear) { /* Hey, "--clear" can't appear twice! */ - Usage(argv[0]); - exit(-1); - } else if (argc == 2) { /* we only want to clear the screen */ - init_dialog(); - refresh(); /* init_dialog() will clear the screen for us */ - end_dialog(); - return 0; - } else { - opt_clear = 1; - offset++; - } - } else /* no more common options */ - end_common_opts = 1; - } - - if (argc - 1 == offset) { /* no more options */ - Usage(argv[0]); - exit(-1); - } - /* use a table to look for the requested mode, to avoid code duplication */ - - for (modePtr = modes; modePtr->name; modePtr++) /* look for the mode */ - if (!strcmp(argv[offset + 1], modePtr->name)) - break; - - if (!modePtr->name) - Usage(argv[0]); - if (argc - offset < modePtr->argmin) - Usage(argv[0]); - if (modePtr->argmax && argc - offset > modePtr->argmax) - Usage(argv[0]); - - init_dialog(); - retval = (*(modePtr->jumper)) (title, argc - offset, argv + offset); - - if (opt_clear) { /* clear screen before exit */ - attr_clear(stdscr, LINES, COLS, screen_attr); - refresh(); - } - end_dialog(); - - exit(retval); -} - -/* - * Print program usage - */ -static void Usage(const char *name) -{ - fprintf(stderr, "\ -\ndialog, by Savio Lam (lam836@cs.cuhk.hk).\ -\n patched by Stuart Herbert (S.Herbert@shef.ac.uk)\ -\n modified/gutted for use as a Linux kernel config tool by \ -\n William Roadcap (roadcapw@cfw.com)\ -\n\ -\n* Display dialog boxes from shell scripts *\ -\n\ -\nUsage: %s --clear\ -\n %s [--title <title>] [--backtitle <backtitle>] --clear <Box options>\ -\n\ -\nBox options:\ -\n\ -\n --menu <text> <height> <width> <menu height> <tag1> <item1>...\ -\n --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ -\n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ -\n --textbox <file> <height> <width>\ -\n --inputbox <text> <height> <width> [<init>]\ -\n --yesno <text> <height> <width>\ -\n", name, name); - exit(-1); -} - -/* - * These are the program jumpers - */ - -int j_menu(const char *t, int ac, const char *const *av) -{ - return dialog_menu(t, av[2], atoi(av[3]), atoi(av[4]), - atoi(av[5]), av[6], (ac - 6) / 2, av + 7); -} - -int j_checklist(const char *t, int ac, const char *const *av) -{ - return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), - atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK); -} - -int j_radiolist(const char *t, int ac, const char *const *av) -{ - return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), - atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO); -} - -int j_textbox(const char *t, int ac, const char *const *av) -{ - return dialog_textbox(t, av[2], atoi(av[3]), atoi(av[4])); -} - -int j_yesno(const char *t, int ac, const char *const *av) -{ - return dialog_yesno(t, av[2], atoi(av[3]), atoi(av[4])); -} - -int j_inputbox(const char *t, int ac, const char *const *av) -{ - int ret = dialog_inputbox(t, av[2], atoi(av[3]), atoi(av[4]), - ac == 6 ? av[5] : (char *)NULL); - if (ret == 0) - fprintf(stderr, dialog_input_result); - return ret; -} - -int j_msgbox(const char *t, int ac, const char *const *av) -{ - return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 1); -} - -int j_infobox(const char *t, int ac, const char *const *av) -{ - return dialog_msgbox(t, av[2], atoi(av[3]), atoi(av[4]), 0); -} diff --git a/scripts/lxdialog/menubox.c b/scripts/lxdialog/menubox.c deleted file mode 100644 index 2d91880..0000000 --- a/scripts/lxdialog/menubox.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * menubox.c -- implements the menu box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* - * Changes by Clifford Wolf (god@clifford.at) - * - * [ 1998-06-13 ] - * - * *) A bugfix for the Page-Down problem - * - * *) Formerly when I used Page Down and Page Up, the cursor would be set - * to the first position in the menu box. Now lxdialog is a bit - * smarter and works more like other menu systems (just have a look at - * it). - * - * *) Formerly if I selected something my scrolling would be broken because - * lxdialog is re-invoked by the Menuconfig shell script, can't - * remember the last scrolling position, and just sets it so that the - * cursor is at the bottom of the box. Now it writes the temporary file - * lxdialog.scrltmp which contains this information. The file is - * deleted by lxdialog if the user leaves a submenu or enters a new - * one, but it would be nice if Menuconfig could make another "rm -f" - * just to be sure. Just try it out - you will recognise a difference! - * - * [ 1998-06-14 ] - * - * *) Now lxdialog is crash-safe against broken "lxdialog.scrltmp" files - * and menus change their size on the fly. - * - * *) If for some reason the last scrolling position is not saved by - * lxdialog, it sets the scrolling so that the selected item is in the - * middle of the menu box, not at the bottom. - * - * 02 January 1999, Michael Elizabeth Chastain (mec@shout.net) - * Reset 'scroll' to 0 if the value from lxdialog.scrltmp is bogus. - * This fixes a bug in Menuconfig where using ' ' to descend into menus - * would leave mis-synchronized lxdialog.scrltmp files lying around, - * fscanf would read in 'scroll', and eventually that value would get used. - */ - -#include "dialog.h" - -#define ITEM_IDENT 4 /* Indent of menu entries. Fixed for all menus */ -static int menu_width; - -/* - * Print menu item - */ -static void do_print_item(WINDOW * win, const char *item, int choice, - int selected, int hotkey) -{ - int j; - char *menu_item = malloc(menu_width + 1); - - strncpy(menu_item, item, menu_width - ITEM_IDENT); - menu_item[menu_width] = 0; - j = first_alpha(menu_item, "YyNnMmHh"); - - /* Clear 'residue' of last item */ - wattrset(win, menubox_attr); - wmove(win, choice, 0); -#if OLD_NCURSES - { - int i; - for (i = 0; i < menu_width; i++) - waddch(win, ' '); - } -#else - wclrtoeol(win); -#endif - wattrset(win, selected ? item_selected_attr : item_attr); - mvwaddstr(win, choice, ITEM_IDENT, menu_item); - if (hotkey) { - wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); - mvwaddch(win, choice, ITEM_IDENT + j, menu_item[j]); - } - if (selected) { - wmove(win, choice, ITEM_IDENT + 1); - } - free(menu_item); - wrefresh(win); -} - -#define print_item(index, choice, selected) \ -do {\ - int hotkey = (items[(index) * 2][0] != ':'); \ - do_print_item(menu, items[(index) * 2 + 1], choice, selected, hotkey); \ -} while (0) - -/* - * Print the scroll indicators. - */ -static void print_arrows(WINDOW * win, int item_no, int scroll, int y, int x, - int height) -{ - int cur_y, cur_x; - - getyx(win, cur_y, cur_x); - - wmove(win, y, x); - - if (scroll > 0) { - wattrset(win, uarrow_attr); - waddch(win, ACS_UARROW); - waddstr(win, "(-)"); - } else { - wattrset(win, menubox_attr); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - } - - y = y + height + 1; - wmove(win, y, x); - wrefresh(win); - - if ((height < item_no) && (scroll + height < item_no)) { - wattrset(win, darrow_attr); - waddch(win, ACS_DARROW); - waddstr(win, "(+)"); - } else { - wattrset(win, menubox_border_attr); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - waddch(win, ACS_HLINE); - } - - wmove(win, cur_y, cur_x); - wrefresh(win); -} - -/* - * Display the termination buttons. - */ -static void print_buttons(WINDOW * win, int height, int width, int selected) -{ - int x = width / 2 - 16; - int y = height - 2; - - print_button(win, "Select", y, x, selected == 0); - print_button(win, " Exit ", y, x + 12, selected == 1); - print_button(win, " Help ", y, x + 24, selected == 2); - - wmove(win, y, x + 1 + 12 * selected); - wrefresh(win); -} - -/* scroll up n lines (n may be negative) */ -static void do_scroll(WINDOW *win, int *scroll, int n) -{ - /* Scroll menu up */ - scrollok(win, TRUE); - wscrl(win, n); - scrollok(win, FALSE); - *scroll = *scroll + n; - wrefresh(win); -} - -/* - * Display a menu for choosing among a number of options - */ -int dialog_menu(const char *title, const char *prompt, int height, int width, - int menu_height, const char *current, int item_no, - const char *const *items) -{ - int i, j, x, y, box_x, box_y; - int key = 0, button = 0, scroll = 0, choice = 0; - int first_item = 0, max_choice; - WINDOW *dialog, *menu; - FILE *f; - - max_choice = MIN(menu_height, item_no); - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow(stdscr, y, x, height, width); - - dialog = newwin(height, width, y, x); - keypad(dialog, TRUE); - - draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset(dialog, border_attr); - mvwaddch(dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch(dialog, ACS_HLINE); - wattrset(dialog, dialog_attr); - wbkgdset(dialog, dialog_attr & A_COLOR); - waddch(dialog, ACS_RTEE); - - print_title(dialog, title, width); - - wattrset(dialog, dialog_attr); - print_autowrap(dialog, prompt, width - 2, 1, 3); - - menu_width = width - 6; - box_y = height - menu_height - 5; - box_x = (width - menu_width) / 2 - 1; - - /* create new window for the menu */ - menu = subwin(dialog, menu_height, menu_width, - y + box_y + 1, x + box_x + 1); - keypad(menu, TRUE); - - /* draw a box around the menu items */ - draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2, - menubox_border_attr, menubox_attr); - - /* Set choice to default item */ - for (i = 0; i < item_no; i++) - if (strcmp(current, items[i * 2]) == 0) - choice = i; - - /* get the scroll info from the temp file */ - if ((f = fopen("lxdialog.scrltmp", "r")) != NULL) { - if ((fscanf(f, "%d\n", &scroll) == 1) && (scroll <= choice) && - (scroll + max_choice > choice) && (scroll >= 0) && - (scroll + max_choice <= item_no)) { - first_item = scroll; - choice = choice - scroll; - fclose(f); - } else { - scroll = 0; - remove("lxdialog.scrltmp"); - fclose(f); - f = NULL; - } - } - if ((choice >= max_choice) || (f == NULL && choice >= max_choice / 2)) { - if (choice >= item_no - max_choice / 2) - scroll = first_item = item_no - max_choice; - else - scroll = first_item = choice - max_choice / 2; - choice = choice - scroll; - } - - /* Print the menu */ - for (i = 0; i < max_choice; i++) { - print_item(first_item + i, i, i == choice); - } - - wnoutrefresh(menu); - - print_arrows(dialog, item_no, scroll, - box_y, box_x + ITEM_IDENT + 1, menu_height); - - print_buttons(dialog, height, width, 0); - wmove(menu, choice, ITEM_IDENT + 1); - wrefresh(menu); - - while (key != ESC) { - key = wgetch(menu); - - if (key < 256 && isalpha(key)) - key = tolower(key); - - if (strchr("ynmh", key)) - i = max_choice; - else { - for (i = choice + 1; i < max_choice; i++) { - j = first_alpha(items[(scroll + i) * 2 + 1], "YyNnMmHh"); - if (key == tolower(items[(scroll + i) * 2 + 1][j])) - break; - } - if (i == max_choice) - for (i = 0; i < max_choice; i++) { - j = first_alpha(items [(scroll + i) * 2 + 1], "YyNnMmHh"); - if (key == tolower(items[(scroll + i) * 2 + 1][j])) - break; - } - } - - if (i < max_choice || - key == KEY_UP || key == KEY_DOWN || - key == '-' || key == '+' || - key == KEY_PPAGE || key == KEY_NPAGE) { - /* Remove highligt of current item */ - print_item(scroll + choice, choice, FALSE); - - if (key == KEY_UP || key == '-') { - if (choice < 2 && scroll) { - /* Scroll menu down */ - do_scroll(menu, &scroll, -1); - - print_item(scroll, 0, FALSE); - } else - choice = MAX(choice - 1, 0); - - } else if (key == KEY_DOWN || key == '+') { - print_item(scroll+choice, choice, FALSE); - - if ((choice > max_choice - 3) && - (scroll + max_choice < item_no)) { - /* Scroll menu up */ - do_scroll(menu, &scroll, 1); - - print_item(scroll+max_choice - 1, - max_choice - 1, FALSE); - } else - choice = MIN(choice + 1, max_choice - 1); - - } else if (key == KEY_PPAGE) { - scrollok(menu, TRUE); - for (i = 0; (i < max_choice); i++) { - if (scroll > 0) { - do_scroll(menu, &scroll, -1); - print_item(scroll, 0, FALSE); - } else { - if (choice > 0) - choice--; - } - } - - } else if (key == KEY_NPAGE) { - for (i = 0; (i < max_choice); i++) { - if (scroll + max_choice < item_no) { - do_scroll(menu, &scroll, 1); - print_item(scroll+max_choice-1, - max_choice - 1, FALSE); - } else { - if (choice + 1 < max_choice) - choice++; - } - } - } else - choice = i; - - print_item(scroll + choice, choice, TRUE); - - print_arrows(dialog, item_no, scroll, - box_y, box_x + ITEM_IDENT + 1, menu_height); - - wnoutrefresh(dialog); - wrefresh(menu); - - continue; /* wait for another key press */ - } - - switch (key) { - case KEY_LEFT: - case TAB: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) - ? 2 : (button > 2 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh(menu); - break; - case ' ': - case 's': - case 'y': - case 'n': - case 'm': - case '/': - /* save scroll info */ - if ((f = fopen("lxdialog.scrltmp", "w")) != NULL) { - fprintf(f, "%d\n", scroll); - fclose(f); - } - delwin(dialog); - fprintf(stderr, "%s\n", items[(scroll + choice) * 2]); - switch (key) { - case 's': - return 3; - case 'y': - return 3; - case 'n': - return 4; - case 'm': - return 5; - case ' ': - return 6; - case '/': - return 7; - } - return 0; - case 'h': - case '?': - button = 2; - case '\n': - delwin(dialog); - if (button == 2) - fprintf(stderr, "%s \"%s\"\n", - items[(scroll + choice) * 2], - items[(scroll + choice) * 2 + 1] + - first_alpha(items [(scroll + choice) * 2 + 1], "")); - else - fprintf(stderr, "%s\n", - items[(scroll + choice) * 2]); - - remove("lxdialog.scrltmp"); - return button; - case 'e': - case 'x': - key = ESC; - case ESC: - break; - } - } - - delwin(dialog); - remove("lxdialog.scrltmp"); - return -1; /* ESC pressed */ -} diff --git a/scripts/lxdialog/msgbox.c b/scripts/lxdialog/msgbox.c deleted file mode 100644 index 7323f54..0000000 --- a/scripts/lxdialog/msgbox.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * msgbox.c -- implements the message box and info box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -/* - * Display a message box. Program will pause and display an "OK" button - * if the parameter 'pause' is non-zero. - */ -int dialog_msgbox(const char *title, const char *prompt, int height, int width, - int pause) -{ - int i, x, y, key = 0; - WINDOW *dialog; - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow(stdscr, y, x, height, width); - - dialog = newwin(height, width, y, x); - keypad(dialog, TRUE); - - draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - - print_title(dialog, title, width); - - wattrset(dialog, dialog_attr); - print_autowrap(dialog, prompt, width - 2, 1, 2); - - if (pause) { - wattrset(dialog, border_attr); - mvwaddch(dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch(dialog, ACS_HLINE); - wattrset(dialog, dialog_attr); - waddch(dialog, ACS_RTEE); - - print_button(dialog, " Ok ", height - 2, width / 2 - 4, TRUE); - - wrefresh(dialog); - while (key != ESC && key != '\n' && key != ' ' && - key != 'O' && key != 'o' && key != 'X' && key != 'x') - key = wgetch(dialog); - } else { - key = '\n'; - wrefresh(dialog); - } - - delwin(dialog); - return key == ESC ? -1 : 0; -} diff --git a/scripts/lxdialog/textbox.c b/scripts/lxdialog/textbox.c deleted file mode 100644 index 77848bb..0000000 --- a/scripts/lxdialog/textbox.c +++ /dev/null @@ -1,533 +0,0 @@ -/* - * textbox.c -- implements the text box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -static void back_lines(int n); -static void print_page(WINDOW * win, int height, int width); -static void print_line(WINDOW * win, int row, int width); -static char *get_line(void); -static void print_position(WINDOW * win, int height, int width); - -static int hscroll, fd, file_size, bytes_read; -static int begin_reached = 1, end_reached, page_length; -static char *buf, *page; - -/* - * Display text from a file in a dialog box. - */ -int dialog_textbox(const char *title, const char *file, int height, int width) -{ - int i, x, y, cur_x, cur_y, fpos, key = 0; - int passed_end; - char search_term[MAX_LEN + 1]; - WINDOW *dialog, *text; - - search_term[0] = '\0'; /* no search term entered yet */ - - /* Open input file for reading */ - if ((fd = open(file, O_RDONLY)) == -1) { - endwin(); - fprintf(stderr, "\nCan't open input file in dialog_textbox().\n"); - exit(-1); - } - /* Get file size. Actually, 'file_size' is the real file size - 1, - since it's only the last byte offset from the beginning */ - if ((file_size = lseek(fd, 0, SEEK_END)) == -1) { - endwin(); - fprintf(stderr, "\nError getting file size in dialog_textbox().\n"); - exit(-1); - } - /* Restore file pointer to beginning of file after getting file size */ - if (lseek(fd, 0, SEEK_SET) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); - exit(-1); - } - /* Allocate space for read buffer */ - if ((buf = malloc(BUF_SIZE + 1)) == NULL) { - endwin(); - fprintf(stderr, "\nCan't allocate memory in dialog_textbox().\n"); - exit(-1); - } - if ((bytes_read = read(fd, buf, BUF_SIZE)) == -1) { - endwin(); - fprintf(stderr, "\nError reading file in dialog_textbox().\n"); - exit(-1); - } - buf[bytes_read] = '\0'; /* mark end of valid data */ - page = buf; /* page is pointer to start of page to be displayed */ - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow(stdscr, y, x, height, width); - - dialog = newwin(height, width, y, x); - keypad(dialog, TRUE); - - /* Create window for text region, used for scrolling text */ - text = subwin(dialog, height - 4, width - 2, y + 1, x + 1); - wattrset(text, dialog_attr); - wbkgdset(text, dialog_attr & A_COLOR); - - keypad(text, TRUE); - - /* register the new window, along with its borders */ - draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - - wattrset(dialog, border_attr); - mvwaddch(dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch(dialog, ACS_HLINE); - wattrset(dialog, dialog_attr); - wbkgdset(dialog, dialog_attr & A_COLOR); - waddch(dialog, ACS_RTEE); - - print_title(dialog, title, width); - - print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE); - wnoutrefresh(dialog); - getyx(dialog, cur_y, cur_x); /* Save cursor position */ - - /* Print first page of text */ - attr_clear(text, height - 4, width - 2, dialog_attr); - print_page(text, height - 4, width - 2); - print_position(dialog, height, width); - wmove(dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh(dialog); - - while ((key != ESC) && (key != '\n')) { - key = wgetch(dialog); - switch (key) { - case 'E': /* Exit */ - case 'e': - case 'X': - case 'x': - delwin(dialog); - free(buf); - close(fd); - return 0; - case 'g': /* First page */ - case KEY_HOME: - if (!begin_reached) { - begin_reached = 1; - /* First page not in buffer? */ - if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); - exit(-1); - } - if (fpos > bytes_read) { /* Yes, we have to read it in */ - if (lseek(fd, 0, SEEK_SET) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in " - "dialog_textbox().\n"); - exit(-1); - } - if ((bytes_read = - read(fd, buf, BUF_SIZE)) == -1) { - endwin(); - fprintf(stderr, "\nError reading file in dialog_textbox().\n"); - exit(-1); - } - buf[bytes_read] = '\0'; - } - page = buf; - print_page(text, height - 4, width - 2); - print_position(dialog, height, width); - wmove(dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh(dialog); - } - break; - case 'G': /* Last page */ - case KEY_END: - - end_reached = 1; - /* Last page not in buffer? */ - if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); - exit(-1); - } - if (fpos < file_size) { /* Yes, we have to read it in */ - if (lseek(fd, -BUF_SIZE, SEEK_END) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in dialog_textbox().\n"); - exit(-1); - } - if ((bytes_read = - read(fd, buf, BUF_SIZE)) == -1) { - endwin(); - fprintf(stderr, "\nError reading file in dialog_textbox().\n"); - exit(-1); - } - buf[bytes_read] = '\0'; - } - page = buf + bytes_read; - back_lines(height - 4); - print_page(text, height - 4, width - 2); - print_position(dialog, height, width); - wmove(dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh(dialog); - break; - case 'K': /* Previous line */ - case 'k': - case KEY_UP: - if (!begin_reached) { - back_lines(page_length + 1); - - /* We don't call print_page() here but use scrolling to ensure - faster screen update. However, 'end_reached' and - 'page_length' should still be updated, and 'page' should - point to start of next page. This is done by calling - get_line() in the following 'for' loop. */ - scrollok(text, TRUE); - wscrl(text, -1); /* Scroll text region down one line */ - scrollok(text, FALSE); - page_length = 0; - passed_end = 0; - for (i = 0; i < height - 4; i++) { - if (!i) { - /* print first line of page */ - print_line(text, 0, width - 2); - wnoutrefresh(text); - } else - /* Called to update 'end_reached' and 'page' */ - get_line(); - if (!passed_end) - page_length++; - if (end_reached && !passed_end) - passed_end = 1; - } - - print_position(dialog, height, width); - wmove(dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh(dialog); - } - break; - case 'B': /* Previous page */ - case 'b': - case KEY_PPAGE: - if (begin_reached) - break; - back_lines(page_length + height - 4); - print_page(text, height - 4, width - 2); - print_position(dialog, height, width); - wmove(dialog, cur_y, cur_x); - wrefresh(dialog); - break; - case 'J': /* Next line */ - case 'j': - case KEY_DOWN: - if (!end_reached) { - begin_reached = 0; - scrollok(text, TRUE); - scroll(text); /* Scroll text region up one line */ - scrollok(text, FALSE); - print_line(text, height - 5, width - 2); - wnoutrefresh(text); - print_position(dialog, height, width); - wmove(dialog, cur_y, cur_x); /* Restore cursor position */ - wrefresh(dialog); - } - break; - case KEY_NPAGE: /* Next page */ - case ' ': - if (end_reached) - break; - - begin_reached = 0; - print_page(text, height - 4, width - 2); - print_position(dialog, height, width); - wmove(dialog, cur_y, cur_x); - wrefresh(dialog); - break; - case '0': /* Beginning of line */ - case 'H': /* Scroll left */ - case 'h': - case KEY_LEFT: - if (hscroll <= 0) - break; - - if (key == '0') - hscroll = 0; - else - hscroll--; - /* Reprint current page to scroll horizontally */ - back_lines(page_length); - print_page(text, height - 4, width - 2); - wmove(dialog, cur_y, cur_x); - wrefresh(dialog); - break; - case 'L': /* Scroll right */ - case 'l': - case KEY_RIGHT: - if (hscroll >= MAX_LEN) - break; - hscroll++; - /* Reprint current page to scroll horizontally */ - back_lines(page_length); - print_page(text, height - 4, width - 2); - wmove(dialog, cur_y, cur_x); - wrefresh(dialog); - break; - case ESC: - break; - } - } - - delwin(dialog); - free(buf); - close(fd); - return -1; /* ESC pressed */ -} - -/* - * Go back 'n' lines in text file. Called by dialog_textbox(). - * 'page' will be updated to point to the desired line in 'buf'. - */ -static void back_lines(int n) -{ - int i, fpos; - - begin_reached = 0; - /* We have to distinguish between end_reached and !end_reached - since at end of file, the line is not ended by a '\n'. - The code inside 'if' basically does a '--page' to move one - character backward so as to skip '\n' of the previous line */ - if (!end_reached) { - /* Either beginning of buffer or beginning of file reached? */ - if (page == buf) { - if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in " - "back_lines().\n"); - exit(-1); - } - if (fpos > bytes_read) { /* Not beginning of file yet */ - /* We've reached beginning of buffer, but not beginning of - file yet, so read previous part of file into buffer. - Note that we only move backward for BUF_SIZE/2 bytes, - but not BUF_SIZE bytes to avoid re-reading again in - print_page() later */ - /* Really possible to move backward BUF_SIZE/2 bytes? */ - if (fpos < BUF_SIZE / 2 + bytes_read) { - /* No, move less then */ - if (lseek(fd, 0, SEEK_SET) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in " - "back_lines().\n"); - exit(-1); - } - page = buf + fpos - bytes_read; - } else { /* Move backward BUF_SIZE/2 bytes */ - if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer " - "in back_lines().\n"); - exit(-1); - } - page = buf + BUF_SIZE / 2; - } - if ((bytes_read = - read(fd, buf, BUF_SIZE)) == -1) { - endwin(); - fprintf(stderr, "\nError reading file in back_lines().\n"); - exit(-1); - } - buf[bytes_read] = '\0'; - } else { /* Beginning of file reached */ - begin_reached = 1; - return; - } - } - if (*(--page) != '\n') { /* '--page' here */ - /* Something's wrong... */ - endwin(); - fprintf(stderr, "\nInternal error in back_lines().\n"); - exit(-1); - } - } - /* Go back 'n' lines */ - for (i = 0; i < n; i++) - do { - if (page == buf) { - if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in back_lines().\n"); - exit(-1); - } - if (fpos > bytes_read) { - /* Really possible to move backward BUF_SIZE/2 bytes? */ - if (fpos < BUF_SIZE / 2 + bytes_read) { - /* No, move less then */ - if (lseek(fd, 0, SEEK_SET) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer " - "in back_lines().\n"); - exit(-1); - } - page = buf + fpos - bytes_read; - } else { /* Move backward BUF_SIZE/2 bytes */ - if (lseek (fd, -(BUF_SIZE / 2 + bytes_read), SEEK_CUR) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer" - " in back_lines().\n"); - exit(-1); - } - page = buf + BUF_SIZE / 2; - } - if ((bytes_read = - read(fd, buf, BUF_SIZE)) == -1) { - endwin(); - fprintf(stderr, "\nError reading file in " - "back_lines().\n"); - exit(-1); - } - buf[bytes_read] = '\0'; - } else { /* Beginning of file reached */ - begin_reached = 1; - return; - } - } - } while (*(--page) != '\n'); - page++; -} - -/* - * Print a new page of text. Called by dialog_textbox(). - */ -static void print_page(WINDOW * win, int height, int width) -{ - int i, passed_end = 0; - - page_length = 0; - for (i = 0; i < height; i++) { - print_line(win, i, width); - if (!passed_end) - page_length++; - if (end_reached && !passed_end) - passed_end = 1; - } - wnoutrefresh(win); -} - -/* - * Print a new line of text. Called by dialog_textbox() and print_page(). - */ -static void print_line(WINDOW * win, int row, int width) -{ - int y, x; - char *line; - - line = get_line(); - line += MIN(strlen(line), hscroll); /* Scroll horizontally */ - wmove(win, row, 0); /* move cursor to correct line */ - waddch(win, ' '); - waddnstr(win, line, MIN(strlen(line), width - 2)); - - getyx(win, y, x); - /* Clear 'residue' of previous line */ -#if OLD_NCURSES - { - int i; - for (i = 0; i < width - x; i++) - waddch(win, ' '); - } -#else - wclrtoeol(win); -#endif -} - -/* - * Return current line of text. Called by dialog_textbox() and print_line(). - * 'page' should point to start of current line before calling, and will be - * updated to point to start of next line. - */ -static char *get_line(void) -{ - int i = 0, fpos; - static char line[MAX_LEN + 1]; - - end_reached = 0; - while (*page != '\n') { - if (*page == '\0') { - /* Either end of file or end of buffer reached */ - if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in " - "get_line().\n"); - exit(-1); - } - if (fpos < file_size) { /* Not end of file yet */ - /* We've reached end of buffer, but not end of file yet, - so read next part of file into buffer */ - if ((bytes_read = - read(fd, buf, BUF_SIZE)) == -1) { - endwin(); - fprintf(stderr, "\nError reading file in get_line().\n"); - exit(-1); - } - buf[bytes_read] = '\0'; - page = buf; - } else { - if (!end_reached) - end_reached = 1; - break; - } - } else if (i < MAX_LEN) - line[i++] = *(page++); - else { - /* Truncate lines longer than MAX_LEN characters */ - if (i == MAX_LEN) - line[i++] = '\0'; - page++; - } - } - if (i <= MAX_LEN) - line[i] = '\0'; - if (!end_reached) - page++; /* move pass '\n' */ - - return line; -} - -/* - * Print current position - */ -static void print_position(WINDOW * win, int height, int width) -{ - int fpos, percent; - - if ((fpos = lseek(fd, 0, SEEK_CUR)) == -1) { - endwin(); - fprintf(stderr, "\nError moving file pointer in print_position().\n"); - exit(-1); - } - wattrset(win, position_indicator_attr); - wbkgdset(win, position_indicator_attr & A_COLOR); - percent = !file_size ? - 100 : ((fpos - bytes_read + page - buf) * 100) / file_size; - wmove(win, height - 3, width - 9); - wprintw(win, "(%3d%%)", percent); -} diff --git a/scripts/lxdialog/util.c b/scripts/lxdialog/util.c deleted file mode 100644 index f82cebb..0000000 --- a/scripts/lxdialog/util.c +++ /dev/null @@ -1,362 +0,0 @@ -/* - * util.c - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -/* use colors by default? */ -bool use_colors = 1; - -const char *backtitle = NULL; - -/* - * Attribute values, default is for mono display - */ -chtype attributes[] = { - A_NORMAL, /* screen_attr */ - A_NORMAL, /* shadow_attr */ - A_NORMAL, /* dialog_attr */ - A_BOLD, /* title_attr */ - A_NORMAL, /* border_attr */ - A_REVERSE, /* button_active_attr */ - A_DIM, /* button_inactive_attr */ - A_REVERSE, /* button_key_active_attr */ - A_BOLD, /* button_key_inactive_attr */ - A_REVERSE, /* button_label_active_attr */ - A_NORMAL, /* button_label_inactive_attr */ - A_NORMAL, /* inputbox_attr */ - A_NORMAL, /* inputbox_border_attr */ - A_NORMAL, /* searchbox_attr */ - A_BOLD, /* searchbox_title_attr */ - A_NORMAL, /* searchbox_border_attr */ - A_BOLD, /* position_indicator_attr */ - A_NORMAL, /* menubox_attr */ - A_NORMAL, /* menubox_border_attr */ - A_NORMAL, /* item_attr */ - A_REVERSE, /* item_selected_attr */ - A_BOLD, /* tag_attr */ - A_REVERSE, /* tag_selected_attr */ - A_BOLD, /* tag_key_attr */ - A_REVERSE, /* tag_key_selected_attr */ - A_BOLD, /* check_attr */ - A_REVERSE, /* check_selected_attr */ - A_BOLD, /* uarrow_attr */ - A_BOLD /* darrow_attr */ -}; - -#include "colors.h" - -/* - * Table of color values - */ -int color_table[][3] = { - {SCREEN_FG, SCREEN_BG, SCREEN_HL}, - {SHADOW_FG, SHADOW_BG, SHADOW_HL}, - {DIALOG_FG, DIALOG_BG, DIALOG_HL}, - {TITLE_FG, TITLE_BG, TITLE_HL}, - {BORDER_FG, BORDER_BG, BORDER_HL}, - {BUTTON_ACTIVE_FG, BUTTON_ACTIVE_BG, BUTTON_ACTIVE_HL}, - {BUTTON_INACTIVE_FG, BUTTON_INACTIVE_BG, BUTTON_INACTIVE_HL}, - {BUTTON_KEY_ACTIVE_FG, BUTTON_KEY_ACTIVE_BG, BUTTON_KEY_ACTIVE_HL}, - {BUTTON_KEY_INACTIVE_FG, BUTTON_KEY_INACTIVE_BG, - BUTTON_KEY_INACTIVE_HL}, - {BUTTON_LABEL_ACTIVE_FG, BUTTON_LABEL_ACTIVE_BG, - BUTTON_LABEL_ACTIVE_HL}, - {BUTTON_LABEL_INACTIVE_FG, BUTTON_LABEL_INACTIVE_BG, - BUTTON_LABEL_INACTIVE_HL}, - {INPUTBOX_FG, INPUTBOX_BG, INPUTBOX_HL}, - {INPUTBOX_BORDER_FG, INPUTBOX_BORDER_BG, INPUTBOX_BORDER_HL}, - {SEARCHBOX_FG, SEARCHBOX_BG, SEARCHBOX_HL}, - {SEARCHBOX_TITLE_FG, SEARCHBOX_TITLE_BG, SEARCHBOX_TITLE_HL}, - {SEARCHBOX_BORDER_FG, SEARCHBOX_BORDER_BG, SEARCHBOX_BORDER_HL}, - {POSITION_INDICATOR_FG, POSITION_INDICATOR_BG, POSITION_INDICATOR_HL}, - {MENUBOX_FG, MENUBOX_BG, MENUBOX_HL}, - {MENUBOX_BORDER_FG, MENUBOX_BORDER_BG, MENUBOX_BORDER_HL}, - {ITEM_FG, ITEM_BG, ITEM_HL}, - {ITEM_SELECTED_FG, ITEM_SELECTED_BG, ITEM_SELECTED_HL}, - {TAG_FG, TAG_BG, TAG_HL}, - {TAG_SELECTED_FG, TAG_SELECTED_BG, TAG_SELECTED_HL}, - {TAG_KEY_FG, TAG_KEY_BG, TAG_KEY_HL}, - {TAG_KEY_SELECTED_FG, TAG_KEY_SELECTED_BG, TAG_KEY_SELECTED_HL}, - {CHECK_FG, CHECK_BG, CHECK_HL}, - {CHECK_SELECTED_FG, CHECK_SELECTED_BG, CHECK_SELECTED_HL}, - {UARROW_FG, UARROW_BG, UARROW_HL}, - {DARROW_FG, DARROW_BG, DARROW_HL}, -}; /* color_table */ - -/* - * Set window to attribute 'attr' - */ -void attr_clear(WINDOW * win, int height, int width, chtype attr) -{ - int i, j; - - wattrset(win, attr); - for (i = 0; i < height; i++) { - wmove(win, i, 0); - for (j = 0; j < width; j++) - waddch(win, ' '); - } - touchwin(win); -} - -void dialog_clear(void) -{ - attr_clear(stdscr, LINES, COLS, screen_attr); - /* Display background title if it exists ... - SLH */ - if (backtitle != NULL) { - int i; - - wattrset(stdscr, screen_attr); - mvwaddstr(stdscr, 0, 1, (char *)backtitle); - wmove(stdscr, 1, 1); - for (i = 1; i < COLS - 1; i++) - waddch(stdscr, ACS_HLINE); - } - wnoutrefresh(stdscr); -} - -/* - * Do some initialization for dialog - */ -void init_dialog(void) -{ - initscr(); /* Init curses */ - keypad(stdscr, TRUE); - cbreak(); - noecho(); - - if (use_colors) /* Set up colors */ - color_setup(); - - dialog_clear(); -} - -/* - * Setup for color display - */ -void color_setup(void) -{ - int i; - - if (has_colors()) { /* Terminal supports color? */ - start_color(); - - /* Initialize color pairs */ - for (i = 0; i < ATTRIBUTE_COUNT; i++) - init_pair(i + 1, color_table[i][0], color_table[i][1]); - - /* Setup color attributes */ - for (i = 0; i < ATTRIBUTE_COUNT; i++) - attributes[i] = C_ATTR(color_table[i][2], i + 1); - } -} - -/* - * End using dialog functions. - */ -void end_dialog(void) -{ - endwin(); -} - -/* Print the title of the dialog. Center the title and truncate - * tile if wider than dialog (- 2 chars). - **/ -void print_title(WINDOW *dialog, const char *title, int width) -{ - if (title) { - int tlen = MIN(width - 2, strlen(title)); - wattrset(dialog, title_attr); - mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); - mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); - waddch(dialog, ' '); - } -} - -/* - * Print a string of text in a window, automatically wrap around to the - * next line if the string is too long to fit on one line. Newline - * characters '\n' are replaced by spaces. We start on a new line - * if there is no room for at least 4 nonblanks following a double-space. - */ -void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) -{ - int newl, cur_x, cur_y; - int i, prompt_len, room, wlen; - char tempstr[MAX_LEN + 1], *word, *sp, *sp2; - - strcpy(tempstr, prompt); - - prompt_len = strlen(tempstr); - - /* - * Remove newlines - */ - for (i = 0; i < prompt_len; i++) { - if (tempstr[i] == '\n') - tempstr[i] = ' '; - } - - if (prompt_len <= width - x * 2) { /* If prompt is short */ - wmove(win, y, (width - prompt_len) / 2); - waddstr(win, tempstr); - } else { - cur_x = x; - cur_y = y; - newl = 1; - word = tempstr; - while (word && *word) { - sp = index(word, ' '); - if (sp) - *sp++ = 0; - - /* Wrap to next line if either the word does not fit, - or it is the first word of a new sentence, and it is - short, and the next word does not fit. */ - room = width - cur_x; - wlen = strlen(word); - if (wlen > room || - (newl && wlen < 4 && sp - && wlen + 1 + strlen(sp) > room - && (!(sp2 = index(sp, ' ')) - || wlen + 1 + (sp2 - sp) > room))) { - cur_y++; - cur_x = x; - } - wmove(win, cur_y, cur_x); - waddstr(win, word); - getyx(win, cur_y, cur_x); - cur_x++; - if (sp && *sp == ' ') { - cur_x++; /* double space */ - while (*++sp == ' ') ; - newl = 1; - } else - newl = 0; - word = sp; - } - } -} - -/* - * Print a button - */ -void print_button(WINDOW * win, const char *label, int y, int x, int selected) -{ - int i, temp; - - wmove(win, y, x); - wattrset(win, selected ? button_active_attr : button_inactive_attr); - waddstr(win, "<"); - temp = strspn(label, " "); - label += temp; - wattrset(win, selected ? button_label_active_attr - : button_label_inactive_attr); - for (i = 0; i < temp; i++) - waddch(win, ' '); - wattrset(win, selected ? button_key_active_attr - : button_key_inactive_attr); - waddch(win, label[0]); - wattrset(win, selected ? button_label_active_attr - : button_label_inactive_attr); - waddstr(win, (char *)label + 1); - wattrset(win, selected ? button_active_attr : button_inactive_attr); - waddstr(win, ">"); - wmove(win, y, x + temp + 1); -} - -/* - * Draw a rectangular box with line drawing characters - */ -void -draw_box(WINDOW * win, int y, int x, int height, int width, - chtype box, chtype border) -{ - int i, j; - - wattrset(win, 0); - for (i = 0; i < height; i++) { - wmove(win, y + i, x); - for (j = 0; j < width; j++) - if (!i && !j) - waddch(win, border | ACS_ULCORNER); - else if (i == height - 1 && !j) - waddch(win, border | ACS_LLCORNER); - else if (!i && j == width - 1) - waddch(win, box | ACS_URCORNER); - else if (i == height - 1 && j == width - 1) - waddch(win, box | ACS_LRCORNER); - else if (!i) - waddch(win, border | ACS_HLINE); - else if (i == height - 1) - waddch(win, box | ACS_HLINE); - else if (!j) - waddch(win, border | ACS_VLINE); - else if (j == width - 1) - waddch(win, box | ACS_VLINE); - else - waddch(win, box | ' '); - } -} - -/* - * Draw shadows along the right and bottom edge to give a more 3D look - * to the boxes - */ -void draw_shadow(WINDOW * win, int y, int x, int height, int width) -{ - int i; - - if (has_colors()) { /* Whether terminal supports color? */ - wattrset(win, shadow_attr); - wmove(win, y + height, x + 2); - for (i = 0; i < width; i++) - waddch(win, winch(win) & A_CHARTEXT); - for (i = y + 1; i < y + height + 1; i++) { - wmove(win, i, x + width); - waddch(win, winch(win) & A_CHARTEXT); - waddch(win, winch(win) & A_CHARTEXT); - } - wnoutrefresh(win); - } -} - -/* - * Return the position of the first alphabetic character in a string. - */ -int first_alpha(const char *string, const char *exempt) -{ - int i, in_paren = 0, c; - - for (i = 0; i < strlen(string); i++) { - c = tolower(string[i]); - - if (strchr("<[(", c)) - ++in_paren; - if (strchr(">])", c) && in_paren > 0) - --in_paren; - - if ((!in_paren) && isalpha(c) && strchr(exempt, c) == 0) - return i; - } - - return 0; -} diff --git a/scripts/lxdialog/yesno.c b/scripts/lxdialog/yesno.c deleted file mode 100644 index cb2568a..0000000 --- a/scripts/lxdialog/yesno.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * yesno.c -- implements the yes/no box - * - * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "dialog.h" - -/* - * Display termination buttons - */ -static void print_buttons(WINDOW * dialog, int height, int width, int selected) -{ - int x = width / 2 - 10; - int y = height - 2; - - print_button(dialog, " Yes ", y, x, selected == 0); - print_button(dialog, " No ", y, x + 13, selected == 1); - - wmove(dialog, y, x + 1 + 13 * selected); - wrefresh(dialog); -} - -/* - * Display a dialog box with two buttons - Yes and No - */ -int dialog_yesno(const char *title, const char *prompt, int height, int width) -{ - int i, x, y, key = 0, button = 0; - WINDOW *dialog; - - /* center dialog box on screen */ - x = (COLS - width) / 2; - y = (LINES - height) / 2; - - draw_shadow(stdscr, y, x, height, width); - - dialog = newwin(height, width, y, x); - keypad(dialog, TRUE); - - draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); - wattrset(dialog, border_attr); - mvwaddch(dialog, height - 3, 0, ACS_LTEE); - for (i = 0; i < width - 2; i++) - waddch(dialog, ACS_HLINE); - wattrset(dialog, dialog_attr); - waddch(dialog, ACS_RTEE); - - print_title(dialog, title, width); - - wattrset(dialog, dialog_attr); - print_autowrap(dialog, prompt, width - 2, 1, 3); - - print_buttons(dialog, height, width, 0); - - while (key != ESC) { - key = wgetch(dialog); - switch (key) { - case 'Y': - case 'y': - delwin(dialog); - return 0; - case 'N': - case 'n': - delwin(dialog); - return 1; - - case TAB: - case KEY_LEFT: - case KEY_RIGHT: - button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button); - - print_buttons(dialog, height, width, button); - wrefresh(dialog); - break; - case ' ': - case '\n': - delwin(dialog); - return button; - case ESC: - break; - } - } - - delwin(dialog); - return -1; /* ESC pressed */ -} -- cgit v1.1 From cb1a7b4df7e2ffc7c97891e8f350ce5db50df3b9 Mon Sep 17 00:00:00 2001 From: Adrian Bunk <bunk@stusta.de> Date: Wed, 14 Dec 2005 00:26:07 +0100 Subject: [PATCH] kbuild: remove the deprecated check_gcc check_gcc has been deprecated for quite some time. Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index c319144..b7856d3 100644 --- a/Makefile +++ b/Makefile @@ -286,10 +286,6 @@ export quiet Q KBUILD_VERBOSE cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) -# For backward compatibility -check_gcc = $(warning check_gcc is deprecated - use cc-option) \ - $(call cc-option, $(1),$(2)) - # cc-option-yn # Usage: flag := $(call cc-option-yn, -march=winchip-c6) cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ -- cgit v1.1 From 98a1e444111c9fd3f7a2b55225f7febf4209c020 Mon Sep 17 00:00:00 2001 From: Brian Strand <bstrand@switchmanagement.com> Date: Tue, 22 Nov 2005 01:23:08 +0000 Subject: kbuild: patch to Documentation/kbuild/modules.txt First off, thanks for the kbuild docs, they are very useful! Second, I've attached a patch to modules.txt (from 2.6.14.2) with a "compile" fix to a Makefile example, and some trivial spelling/grammar nits. Please let me know if you want the patch in some other format (eg not MIME), or if I should go bother someone else about it. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- Documentation/kbuild/modules.txt | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index c91caf7..1c0db65 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt @@ -38,7 +38,7 @@ included in the kernel tree. What is covered within this file is mainly information to authors of modules. The author of an external modules should supply a makefile that hides most of the complexity so one only has to type -'make' to buld the module. A complete example will be present in +'make' to build the module. A complete example will be present in chapter ¤. Creating a kbuild file for an external module". @@ -69,7 +69,7 @@ when building an external module. --- 2.2 Available targets - $KDIR refers to path to kernel source top-level directory + $KDIR refers to the path to the kernel source top-level directory make -C $KDIR M=`pwd` Will build the module(s) located in current directory. @@ -87,11 +87,11 @@ when building an external module. make -C $KDIR M=$PWD modules_install Install the external module(s). Installation default is in /lib/modules/<kernel-version>/extra, - but may be prefixed with INSTALL_MOD_PATH - see separate chater. + but may be prefixed with INSTALL_MOD_PATH - see separate chapter. make -C $KDIR M=$PWD clean Remove all generated files for the module - the kernel - source directory is not moddified. + source directory is not modified. make -C $KDIR M=`pwd` help help will list the available target when building external @@ -99,7 +99,7 @@ when building an external module. --- 2.3 Available options: - $KDIR refer to path to kernel src + $KDIR refers to the path to the kernel source top-level directory make -C $KDIR Used to specify where to find the kernel source. @@ -206,11 +206,11 @@ following files: KERNELDIR := /lib/modules/`uname -r`/build all:: - $(MAKE) -C $KERNELDIR M=`pwd` $@ + $(MAKE) -C $(KERNELDIR) M=`pwd` $@ # Module specific targets genbin: - echo "X" > 8123_bini.o_shipped + echo "X" > 8123_bin.o_shipped endif @@ -341,13 +341,13 @@ directory and therefore needs to deal with this in their kbuild file. EXTRA_CFLAGS := -Iinclude 8123-y := 8123_if.o 8123_pci.o 8123_bin.o - Note that in the assingment there is no space between -I and the path. - This is a kbuild limitation and no space must be present. + Note that in the assignment there is no space between -I and the path. + This is a kbuild limitation: there must be no space present. === 6. Module installation -Modules which are included in the kernel is installed in the directory: +Modules which are included in the kernel are installed in the directory: /lib/modules/$(KERNELRELEASE)/kernel @@ -365,7 +365,7 @@ External modules are installed in the directory: => Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel INSTALL_MOD_PATH may be set as an ordinary shell variable or as in the - example above be specified on the commandline when calling make. + example above be specified on the command line when calling make. INSTALL_MOD_PATH has effect both when installing modules included in the kernel as well as when installing external modules. @@ -384,7 +384,7 @@ External modules are installed in the directory: === 7. Module versioning -Module versioning are enabled by the CONFIG_MODVERSIONS tag. +Module versioning is enabled by the CONFIG_MODVERSIONS tag. Module versioning is used as a simple ABI consistency check. The Module versioning creates a CRC value of the full prototype for an exported symbol and -- cgit v1.1 From 9cc5d74c847dd3a9ea121b5bbca07bd5791c54ee Mon Sep 17 00:00:00 2001 From: Bodo Eggert <7eggert@gmx.de> Date: Wed, 23 Nov 2005 20:11:34 +0100 Subject: kbuild: document INSTALL_MOD_PATH in 'make help' Signed-Off-By: Bodo Eggert <7eggert@gmx.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b7856d3..5f685b9 100644 --- a/Makefile +++ b/Makefile @@ -1062,7 +1062,7 @@ help: @echo ' all - Build all targets marked with [*]' @echo '* vmlinux - Build the bare kernel' @echo '* modules - Build all modules' - @echo ' modules_install - Install all modules' + @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[ois] - Build specified target only' @echo ' dir/file.ko - Build module including final link' -- cgit v1.1 From 7b32b8e018d8f8cc94c808a5fa84a3f889441b91 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox <matthew@wil.cx> Date: Fri, 16 Dec 2005 21:11:37 -0700 Subject: [SCSI] Missing const in sr_vendor Fix compile warnings with current scsi-misc git tree Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com> --- drivers/scsi/sr_vendor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sr_vendor.c b/drivers/scsi/sr_vendor.c index 78274dc..9dde8df 100644 --- a/drivers/scsi/sr_vendor.c +++ b/drivers/scsi/sr_vendor.c @@ -68,8 +68,8 @@ void sr_vendor_init(Scsi_CD *cd) #ifndef CONFIG_BLK_DEV_SR_VENDOR cd->vendor = VENDOR_SCSI3; #else - char *vendor = cd->device->vendor; - char *model = cd->device->model; + const char *vendor = cd->device->vendor; + const char *model = cd->device->model; /* default */ cd->vendor = VENDOR_SCSI3; -- cgit v1.1 From aa84505fb0fb9504c61d77e8e6930a417fc404d6 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Wed, 14 Dec 2005 14:38:44 -0800 Subject: [PATCH] chelsio: transmit routine return values The Chelsio driver does not return the correct values from the transmit routine. It works because the values don't conflict, but it is using the wrong defines. And -ENOMEM is not a legal return value. Since t1_sge_tx is only called in one place, making it static allows compiler to be potentially inline it. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/chelsio/sge.c | 19 ++++++++++--------- drivers/net/chelsio/sge.h | 2 -- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c index 53b41d9..2c5b849 100644 --- a/drivers/net/chelsio/sge.c +++ b/drivers/net/chelsio/sge.c @@ -1332,8 +1332,8 @@ intr_handler_t t1_select_intr_handler(adapter_t *adapter) * * This runs with softirqs disabled. */ -unsigned int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter, - unsigned int qid, struct net_device *dev) +static int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter, + unsigned int qid, struct net_device *dev) { struct sge *sge = adapter->sge; struct cmdQ *q = &sge->cmdQ[qid]; @@ -1352,9 +1352,10 @@ unsigned int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter, set_bit(dev->if_port, &sge->stopped_tx_queues); sge->stats.cmdQ_full[3]++; spin_unlock(&q->lock); - CH_ERR("%s: Tx ring full while queue awake!\n", - adapter->name); - return 1; + if (!netif_queue_stopped(dev)) + CH_ERR("%s: Tx ring full while queue awake!\n", + adapter->name); + return NETDEV_TX_BUSY; } if (unlikely(credits - count < q->stop_thres)) { sge->stats.cmdQ_full[3]++; @@ -1389,7 +1390,7 @@ unsigned int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter, writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL); } } - return 0; + return NETDEV_TX_OK; } #define MK_ETH_TYPE_MSS(type, mss) (((mss) & 0x3FFF) | ((type) << 14)) @@ -1449,7 +1450,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev) if (unlikely(skb->len < ETH_HLEN || skb->len > dev->mtu + eth_hdr_len(skb->data))) { dev_kfree_skb_any(skb); - return NET_XMIT_SUCCESS; + return NETDEV_TX_OK; } /* @@ -1467,7 +1468,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev) skb = skb_realloc_headroom(skb, sizeof(*cpl)); dev_kfree_skb_any(orig_skb); if (!skb) - return -ENOMEM; + return NETDEV_TX_OK; } if (!(adapter->flags & UDP_CSUM_CAPABLE) && @@ -1475,7 +1476,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev) skb->nh.iph->protocol == IPPROTO_UDP) if (unlikely(skb_checksum_help(skb, 0))) { dev_kfree_skb_any(skb); - return -ENOMEM; + return NETDEV_TX_OK; } /* Hmmm, assuming to catch the gratious arp... and we'll use diff --git a/drivers/net/chelsio/sge.h b/drivers/net/chelsio/sge.h index 434b255..6d0d24a 100644 --- a/drivers/net/chelsio/sge.h +++ b/drivers/net/chelsio/sge.h @@ -89,8 +89,6 @@ int t1_sge_configure(struct sge *, struct sge_params *); int t1_sge_set_coalesce_params(struct sge *, struct sge_params *); void t1_sge_destroy(struct sge *); intr_handler_t t1_select_intr_handler(adapter_t *adapter); -unsigned int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter, - unsigned int qid, struct net_device *netdev); int t1_start_xmit(struct sk_buff *skb, struct net_device *dev); void t1_set_vlan_accel(struct adapter *adapter, int on_off); void t1_sge_start(struct sge *); -- cgit v1.1 From ee294dcda1d5dea5b909164cdc459a8483ee2983 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Wed, 14 Dec 2005 15:47:44 -0800 Subject: [PATCH] skge: avoid up/down on speed changes Change the speed settings doesn't need to cause link to go down/up. It can be handled by doing the same logic as nway_reset. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/skge.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 00d6830..f776581 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -88,15 +88,14 @@ MODULE_DEVICE_TABLE(pci, skge_id_table); static int skge_up(struct net_device *dev); static int skge_down(struct net_device *dev); +static void skge_phy_reset(struct skge_port *skge); static void skge_tx_clean(struct skge_port *skge); static int xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val); static int gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val); static void genesis_get_stats(struct skge_port *skge, u64 *data); static void yukon_get_stats(struct skge_port *skge, u64 *data); static void yukon_init(struct skge_hw *hw, int port); -static void yukon_reset(struct skge_hw *hw, int port); static void genesis_mac_init(struct skge_hw *hw, int port); -static void genesis_reset(struct skge_hw *hw, int port); static void genesis_link_up(struct skge_port *skge); /* Avoid conditionals by using array */ @@ -276,10 +275,9 @@ static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) skge->autoneg = ecmd->autoneg; skge->advertising = ecmd->advertising; - if (netif_running(dev)) { - skge_down(dev); - skge_up(dev); - } + if (netif_running(dev)) + skge_phy_reset(skge); + return (0); } @@ -430,21 +428,11 @@ static void skge_set_msglevel(struct net_device *netdev, u32 value) static int skge_nway_reset(struct net_device *dev) { struct skge_port *skge = netdev_priv(dev); - struct skge_hw *hw = skge->hw; - int port = skge->port; if (skge->autoneg != AUTONEG_ENABLE || !netif_running(dev)) return -EINVAL; - spin_lock_bh(&hw->phy_lock); - if (hw->chip_id == CHIP_ID_GENESIS) { - genesis_reset(hw, port); - genesis_mac_init(hw, port); - } else { - yukon_reset(hw, port); - yukon_init(hw, port); - } - spin_unlock_bh(&hw->phy_lock); + skge_phy_reset(skge); return 0; } @@ -2019,6 +2007,25 @@ static void yukon_phy_intr(struct skge_port *skge) /* XXX restart autonegotiation? */ } +static void skge_phy_reset(struct skge_port *skge) +{ + struct skge_hw *hw = skge->hw; + int port = skge->port; + + netif_stop_queue(skge->netdev); + netif_carrier_off(skge->netdev); + + spin_lock_bh(&hw->phy_lock); + if (hw->chip_id == CHIP_ID_GENESIS) { + genesis_reset(hw, port); + genesis_mac_init(hw, port); + } else { + yukon_reset(hw, port); + yukon_init(hw, port); + } + spin_unlock_bh(&hw->phy_lock); +} + /* Basic MII support */ static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { -- cgit v1.1 From e8df8554605f014765732605667145c0824a12b7 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Wed, 14 Dec 2005 15:47:45 -0800 Subject: [PATCH] skge: avoid up/down on pause param changes Change the pause settings doesn't need to cause link to go down/up. It can be handled by the phy_reset code. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/skge.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/skge.c b/drivers/net/skge.c index f776581..14bf4cc 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -504,10 +504,8 @@ static int skge_set_pauseparam(struct net_device *dev, else skge->flow_control = FLOW_MODE_NONE; - if (netif_running(dev)) { - skge_down(dev); - skge_up(dev); - } + if (netif_running(dev)) + skge_phy_reset(skge); return 0; } -- cgit v1.1 From 7731a4ea1bbb7c9336bcdec8ef4050cf08a35268 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Wed, 14 Dec 2005 15:47:46 -0800 Subject: [PATCH] skge: handle out of memory on MTU size changes Changing the MTU size causes the receiver to have to reallocate buffers. If this allocation fails, then we need to return an error, and take the device offline. It can then be brought back up or reconfigured for a smaller MTU. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/skge.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 14bf4cc..96b661b 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -2192,6 +2192,7 @@ static int skge_up(struct net_device *dev) kfree(skge->rx_ring.start); free_pci_mem: pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma); + skge->mem = NULL; return err; } @@ -2202,6 +2203,9 @@ static int skge_down(struct net_device *dev) struct skge_hw *hw = skge->hw; int port = skge->port; + if (skge->mem == NULL) + return 0; + if (netif_msg_ifdown(skge)) printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); @@ -2258,6 +2262,7 @@ static int skge_down(struct net_device *dev) kfree(skge->rx_ring.start); kfree(skge->tx_ring.start); pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma); + skge->mem = NULL; return 0; } @@ -2418,18 +2423,23 @@ static void skge_tx_timeout(struct net_device *dev) static int skge_change_mtu(struct net_device *dev, int new_mtu) { - int err = 0; - int running = netif_running(dev); + int err; if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) return -EINVAL; + if (!netif_running(dev)) { + dev->mtu = new_mtu; + return 0; + } + + skge_down(dev); - if (running) - skge_down(dev); dev->mtu = new_mtu; - if (running) - skge_up(dev); + + err = skge_up(dev); + if (err) + dev_close(dev); return err; } -- cgit v1.1 From 2770b5172e9b3d135b16d1e5d8344919ac09319d Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Wed, 14 Dec 2005 15:47:47 -0800 Subject: [PATCH] skge: get rid of Yukon2 defines Don't need to keep Yukon-2 related definitions around for Skge driver that is only for Yukon-1 and Genesis. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/skge.h | 73 +----------------------------------------------------- 1 file changed, 1 insertion(+), 72 deletions(-) diff --git a/drivers/net/skge.h b/drivers/net/skge.h index ee123c1..2efdacc 100644 --- a/drivers/net/skge.h +++ b/drivers/net/skge.h @@ -475,18 +475,6 @@ enum { Q_T2 = 0x40, /* 32 bit Test Register 2 */ Q_T3 = 0x44, /* 32 bit Test Register 3 */ -/* Yukon-2 */ - Q_DONE = 0x24, /* 16 bit Done Index (Yukon-2 only) */ - Q_WM = 0x40, /* 16 bit FIFO Watermark */ - Q_AL = 0x42, /* 8 bit FIFO Alignment */ - Q_RSP = 0x44, /* 16 bit FIFO Read Shadow Pointer */ - Q_RSL = 0x46, /* 8 bit FIFO Read Shadow Level */ - Q_RP = 0x48, /* 8 bit FIFO Read Pointer */ - Q_RL = 0x4a, /* 8 bit FIFO Read Level */ - Q_WP = 0x4c, /* 8 bit FIFO Write Pointer */ - Q_WSP = 0x4d, /* 8 bit FIFO Write Shadow Pointer */ - Q_WL = 0x4e, /* 8 bit FIFO Write Level */ - Q_WSL = 0x4f, /* 8 bit FIFO Write Shadow Level */ }; #define Q_ADDR(reg, offs) (B8_Q_REGS + (reg) + (offs)) @@ -675,22 +663,16 @@ enum { LED_OFF = 1<<0, /* switch LED off */ }; -/* Receive GMAC FIFO (YUKON and Yukon-2) */ +/* Receive GMAC FIFO (YUKON) */ enum { RX_GMF_EA = 0x0c40,/* 32 bit Rx GMAC FIFO End Address */ RX_GMF_AF_THR = 0x0c44,/* 32 bit Rx GMAC FIFO Almost Full Thresh. */ RX_GMF_CTRL_T = 0x0c48,/* 32 bit Rx GMAC FIFO Control/Test */ RX_GMF_FL_MSK = 0x0c4c,/* 32 bit Rx GMAC FIFO Flush Mask */ RX_GMF_FL_THR = 0x0c50,/* 32 bit Rx GMAC FIFO Flush Threshold */ - RX_GMF_TR_THR = 0x0c54,/* 32 bit Rx Truncation Threshold (Yukon-2) */ - - RX_GMF_VLAN = 0x0c5c,/* 32 bit Rx VLAN Type Register (Yukon-2) */ RX_GMF_WP = 0x0c60,/* 32 bit Rx GMAC FIFO Write Pointer */ - RX_GMF_WLEV = 0x0c68,/* 32 bit Rx GMAC FIFO Write Level */ - RX_GMF_RP = 0x0c70,/* 32 bit Rx GMAC FIFO Read Pointer */ - RX_GMF_RLEV = 0x0c78,/* 32 bit Rx GMAC FIFO Read Level */ }; @@ -855,48 +837,6 @@ enum { GMAC_TI_ST_TST = 0x0e1a,/* 8 bit Time Stamp Timer Test Reg */ }; -/* Status BMU Registers (Yukon-2 only)*/ -enum { - STAT_CTRL = 0x0e80,/* 32 bit Status BMU Control Reg */ - STAT_LAST_IDX = 0x0e84,/* 16 bit Status BMU Last Index */ - /* 0x0e85 - 0x0e86: reserved */ - STAT_LIST_ADDR_LO = 0x0e88,/* 32 bit Status List Start Addr (low) */ - STAT_LIST_ADDR_HI = 0x0e8c,/* 32 bit Status List Start Addr (high) */ - STAT_TXA1_RIDX = 0x0e90,/* 16 bit Status TxA1 Report Index Reg */ - STAT_TXS1_RIDX = 0x0e92,/* 16 bit Status TxS1 Report Index Reg */ - STAT_TXA2_RIDX = 0x0e94,/* 16 bit Status TxA2 Report Index Reg */ - STAT_TXS2_RIDX = 0x0e96,/* 16 bit Status TxS2 Report Index Reg */ - STAT_TX_IDX_TH = 0x0e98,/* 16 bit Status Tx Index Threshold Reg */ - STAT_PUT_IDX = 0x0e9c,/* 16 bit Status Put Index Reg */ - -/* FIFO Control/Status Registers (Yukon-2 only)*/ - STAT_FIFO_WP = 0x0ea0,/* 8 bit Status FIFO Write Pointer Reg */ - STAT_FIFO_RP = 0x0ea4,/* 8 bit Status FIFO Read Pointer Reg */ - STAT_FIFO_RSP = 0x0ea6,/* 8 bit Status FIFO Read Shadow Ptr */ - STAT_FIFO_LEVEL = 0x0ea8,/* 8 bit Status FIFO Level Reg */ - STAT_FIFO_SHLVL = 0x0eaa,/* 8 bit Status FIFO Shadow Level Reg */ - STAT_FIFO_WM = 0x0eac,/* 8 bit Status FIFO Watermark Reg */ - STAT_FIFO_ISR_WM = 0x0ead,/* 8 bit Status FIFO ISR Watermark Reg */ - -/* Level and ISR Timer Registers (Yukon-2 only)*/ - STAT_LEV_TIMER_INI = 0x0eb0,/* 32 bit Level Timer Init. Value Reg */ - STAT_LEV_TIMER_CNT = 0x0eb4,/* 32 bit Level Timer Counter Reg */ - STAT_LEV_TIMER_CTRL = 0x0eb8,/* 8 bit Level Timer Control Reg */ - STAT_LEV_TIMER_TEST = 0x0eb9,/* 8 bit Level Timer Test Reg */ - STAT_TX_TIMER_INI = 0x0ec0,/* 32 bit Tx Timer Init. Value Reg */ - STAT_TX_TIMER_CNT = 0x0ec4,/* 32 bit Tx Timer Counter Reg */ - STAT_TX_TIMER_CTRL = 0x0ec8,/* 8 bit Tx Timer Control Reg */ - STAT_TX_TIMER_TEST = 0x0ec9,/* 8 bit Tx Timer Test Reg */ - STAT_ISR_TIMER_INI = 0x0ed0,/* 32 bit ISR Timer Init. Value Reg */ - STAT_ISR_TIMER_CNT = 0x0ed4,/* 32 bit ISR Timer Counter Reg */ - STAT_ISR_TIMER_CTRL = 0x0ed8,/* 8 bit ISR Timer Control Reg */ - STAT_ISR_TIMER_TEST = 0x0ed9,/* 8 bit ISR Timer Test Reg */ - - ST_LAST_IDX_MASK = 0x007f,/* Last Index Mask */ - ST_TXRP_IDX_MASK = 0x0fff,/* Tx Report Index Mask */ - ST_TXTH_IDX_MASK = 0x0fff,/* Tx Threshold Index Mask */ - ST_WM_IDX_MASK = 0x3f,/* FIFO Watermark Index Mask */ -}; enum { LINKLED_OFF = 0x01, @@ -923,8 +863,6 @@ enum { WOL_MATCH_CTL = 0x0f22,/* 8 bit WOL Match Control Reg */ WOL_MATCH_RES = 0x0f23,/* 8 bit WOL Match Result Reg */ WOL_MAC_ADDR = 0x0f24,/* 32 bit WOL MAC Address */ - WOL_PATT_PME = 0x0f2a,/* 8 bit WOL PME Match Enable (Yukon-2) */ - WOL_PATT_ASFM = 0x0f2b,/* 8 bit WOL ASF Match Enable (Yukon-2) */ WOL_PATT_RPTR = 0x0f2c,/* 8 bit WOL Pattern Read Pointer */ /* WOL Pattern Length Registers (YUKON only) */ @@ -1641,15 +1579,6 @@ enum { PHY_M_FESC_SEL_CL_A = 1<<0, /* Select Class A driver (100B-TX) */ }; -/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */ -/***** PHY_MARV_PHY_CTRL (page 2) 16 bit r/w MAC Specific Ctrl *****/ -enum { - PHY_M_MAC_MD_MSK = 7<<7, /* Bit 9.. 7: Mode Select Mask */ - PHY_M_MAC_MD_AUTO = 3,/* Auto Copper/1000Base-X */ - PHY_M_MAC_MD_COPPER = 5,/* Copper only */ - PHY_M_MAC_MD_1000BX = 7,/* 1000Base-X only */ -}; -#define PHY_M_MAC_MODE_SEL(x) (((x)<<7) & PHY_M_MAC_MD_MSK) /***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ enum { -- cgit v1.1 From 3b8bb472ad8eee6f42bc82647ff5d6d9bfe49e20 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Wed, 14 Dec 2005 15:47:48 -0800 Subject: [PATCH] skge: handle out of memory on ring parameter change If changing ring parameters is unable to allocate memory, we need to return an error and take the device down. Fixes-bug: http://bugzilla.kernel.org/show_bug.cgi?id=5715 Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/skge.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 96b661b..9ff54ea 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -397,6 +397,7 @@ static int skge_set_ring_param(struct net_device *dev, struct ethtool_ringparam *p) { struct skge_port *skge = netdev_priv(dev); + int err; if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE || p->tx_pending == 0 || p->tx_pending > MAX_TX_RING_SIZE) @@ -407,7 +408,9 @@ static int skge_set_ring_param(struct net_device *dev, if (netif_running(dev)) { skge_down(dev); - skge_up(dev); + err = skge_up(dev); + if (err) + dev_close(dev); } return 0; -- cgit v1.1 From f15943f500c2d3edaee6b4c23dfd738715e74618 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Wed, 14 Dec 2005 15:47:49 -0800 Subject: [PATCH] skge: version number (1.3) Enough changes for one version. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/skge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 9ff54ea..e812dbb 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -43,7 +43,7 @@ #include "skge.h" #define DRV_NAME "skge" -#define DRV_VERSION "1.2" +#define DRV_VERSION "1.3" #define PFX DRV_NAME " " #define DEFAULT_TX_RING_SIZE 128 -- cgit v1.1 From 26b7625c46d5d72570252d30fec6814682476684 Mon Sep 17 00:00:00 2001 From: Andrew Morton <akpm@osdl.org> Date: Wed, 14 Dec 2005 19:25:23 -0800 Subject: [PATCH] git-netdev-all: s2io warning fix drivers/net/s2io.c: In function `s2io_txdl_getskb': drivers/net/s2io.c:2023: warning: cast from pointer to integer of different size drivers/net/s2io.c: In function `s2io_open': drivers/net/s2io.c:3325: warning: long long unsigned int format, u64 arg (arg 3) drivers/net/s2io.c:3333: warning: long long unsigned int format, u64 arg (arg 3) drivers/net/s2io.c: In function `s2io_eeprom_test': drivers/net/s2io.c:4749: warning: long long unsigned int format, long unsigned int arg (arg 3) drivers/net/s2io.c:4749: warning: long long unsigned int format, u64 arg (arg 4) drivers/net/s2io.c:4768: warning: long long unsigned int format, long unsigned int arg (arg 3) drivers/net/s2io.c:4768: warning: long long unsigned int format, u64 arg (arg 4) I had to update this patch because more warnings have just appeared. You cannot print a u64 with %l or %ll. You do not know what type the architecture is using. It must be cast to a type which matches the printf control string - unsigned long long. The patch also fixes some overly-long strings. Please try to keep the code looking neat in an 80-col window. Cc: Jeff Garzik <jgarzik@pobox.com> Cc: Ananda Raju <Ananda.Raju@neterion.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/s2io.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 258128a..89c4678 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c @@ -2020,7 +2020,7 @@ static struct sk_buff *s2io_txdl_getskb(fifo_info_t *fifo_data, TxD_t *txdlp, in u16 j, frg_cnt; txds = txdlp; - if (txds->Host_Control == (u64) nic->ufo_in_band_v) { + if (txds->Host_Control == (u64)(long)nic->ufo_in_band_v) { pci_unmap_single(nic->pdev, (dma_addr_t) txds->Buffer_Pointer, sizeof(u64), PCI_DMA_TODEVICE); @@ -3323,7 +3323,7 @@ failed\n", dev->name); s2io_msix_fifo_handle, 0, sp->desc1, sp->s2io_entries[i].arg); DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc1, - sp->msix_info[i].addr); + (unsigned long long)sp->msix_info[i].addr); } else { sprintf(sp->desc2, "%s:MSI-X-%d-RX", dev->name, i); @@ -3331,7 +3331,7 @@ failed\n", dev->name); s2io_msix_ring_handle, 0, sp->desc2, sp->s2io_entries[i].arg); DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc2, - sp->msix_info[i].addr); + (unsigned long long)sp->msix_info[i].addr); } if (err) { DBG_PRINT(ERR_DBG, "%s: MSI-X-%d registration \ @@ -4746,7 +4746,10 @@ static int s2io_eeprom_test(nic_t * sp, uint64_t * data) fail = 1; if (ret_data != 0x012345) { - DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x4F0. Data written %llx Data read %llx\n", dev->name, (u64)0x12345, ret_data); + DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x4F0. " + "Data written %llx Data read %llx\n", + dev->name, (unsigned long long)0x12345, + (unsigned long long)ret_data); fail = 1; } @@ -4765,7 +4768,10 @@ static int s2io_eeprom_test(nic_t * sp, uint64_t * data) fail = 1; if (ret_data != 0x012345) { - DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x7F0. Data written %llx Data read %llx\n", dev->name, (u64)0x12345, ret_data); + DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x7F0. " + "Data written %llx Data read %llx\n", + dev->name, (unsigned long long)0x12345, + (unsigned long long)ret_data); fail = 1; } -- cgit v1.1 From b35de2eb389aa1889941ec3d02fff6d7a2569825 Mon Sep 17 00:00:00 2001 From: Jens Osterkamp <Jens.Osterkamp@de.ibm.com> Date: Thu, 15 Dec 2005 13:42:21 +0100 Subject: [PATCH] spidernet: fix Kconfig after BPA->CELL rename We changed the name of the Kconfig symbols along with the move to arch/powerpc. This one hunk got lost during the conversion. From: Jens.Osterkamp@de.ibm.com Cc: netdev@vger.kernel.org Signed-off-by: Arnd Bergmann <arndb@de.ibm.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 0f2e4c1..e2fa29b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2133,7 +2133,7 @@ config BNX2 config SPIDER_NET tristate "Spider Gigabit Ethernet driver" - depends on PCI && PPC_BPA + depends on PCI && PPC_CELL help This driver supports the Gigabit Ethernet chips present on the Cell Processor-Based Blades from IBM. -- cgit v1.1 From edd702e847fb8a9774a2ed8d50d2b8299b8c7f89 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Thu, 15 Dec 2005 12:18:00 -0800 Subject: [PATCH] skge: error handling on resume Also have to handle out of memory condition on resume. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/skge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/skge.c b/drivers/net/skge.c index e812dbb..b8dfe33 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -3416,8 +3416,8 @@ static int skge_resume(struct pci_dev *pdev) struct net_device *dev = hw->dev[i]; if (dev) { netif_device_attach(dev); - if (netif_running(dev)) - skge_up(dev); + if (netif_running(dev) && skge_up(dev)) + dev_close(dev); } } return 0; -- cgit v1.1 From 1b537565a85cbe5cc9d5174d348a9014381af718 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Tue, 20 Dec 2005 15:08:07 -0800 Subject: [PATCH] sky2: handle out of memory on admin changes Don't die if we run out of memory on mtu or ring parameter change. For other admin operations, don't rebuild Rx ring, just restart the PHY. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/sky2.c | 84 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 7af72cd..1d183d5 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -481,6 +481,14 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK); } +/* Force a renegotiation */ +static void sky2_phy_reinit(struct sky2_port *sky2) +{ + down(&sky2->phy_sema); + sky2_phy_init(sky2->hw, sky2->port); + up(&sky2->phy_sema); +} + static void sky2_mac_init(struct sky2_hw *hw, unsigned port) { struct sky2_port *sky2 = netdev_priv(hw->dev[port]); @@ -1014,18 +1022,22 @@ static int sky2_up(struct net_device *dev) return 0; err_out: - if (sky2->rx_le) + if (sky2->rx_le) { pci_free_consistent(hw->pdev, RX_LE_BYTES, sky2->rx_le, sky2->rx_le_map); - if (sky2->tx_le) + sky2->rx_le = NULL; + } + if (sky2->tx_le) { pci_free_consistent(hw->pdev, TX_RING_SIZE * sizeof(struct sky2_tx_le), sky2->tx_le, sky2->tx_le_map); - if (sky2->tx_ring) - kfree(sky2->tx_ring); - if (sky2->rx_ring) - kfree(sky2->rx_ring); + sky2->tx_le = NULL; + } + kfree(sky2->tx_ring); + kfree(sky2->rx_ring); + sky2->tx_ring = NULL; + sky2->rx_ring = NULL; return err; } @@ -1291,6 +1303,10 @@ static int sky2_down(struct net_device *dev) unsigned port = sky2->port; u16 ctrl; + /* Never really got started! */ + if (!sky2->tx_le) + return 0; + if (netif_msg_ifdown(sky2)) printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); @@ -1365,6 +1381,12 @@ static int sky2_down(struct net_device *dev) sky2->tx_le, sky2->tx_le_map); kfree(sky2->tx_ring); + sky2->tx_le = NULL; + sky2->rx_le = NULL; + + sky2->rx_ring = NULL; + sky2->tx_ring = NULL; + return 0; } @@ -1636,12 +1658,17 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu) sky2_write8(hw, RB_ADDR(rxqaddr[sky2->port], RB_CTRL), RB_ENA_OP_MD); err = sky2_rx_start(sky2); - gma_write16(hw, sky2->port, GM_GP_CTRL, ctl); - - netif_poll_disable(hw->dev[0]); - netif_wake_queue(dev); sky2_write32(hw, B0_IMSK, hw->intr_mask); + if (err) + dev_close(dev); + else { + gma_write16(hw, sky2->port, GM_GP_CTRL, ctl); + + netif_poll_enable(hw->dev[0]); + netif_wake_queue(dev); + } + return err; } @@ -2315,10 +2342,8 @@ static int sky2_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) sky2->autoneg = ecmd->autoneg; sky2->advertising = ecmd->advertising; - if (netif_running(dev)) { - sky2_down(dev); - sky2_up(dev); - } + if (netif_running(dev)) + sky2_phy_reinit(sky2); return 0; } @@ -2389,17 +2414,11 @@ static u32 sky2_get_msglevel(struct net_device *netdev) static int sky2_nway_reset(struct net_device *dev) { struct sky2_port *sky2 = netdev_priv(dev); - struct sky2_hw *hw = sky2->hw; if (sky2->autoneg != AUTONEG_ENABLE) return -EINVAL; - netif_stop_queue(dev); - - down(&sky2->phy_sema); - sky2_phy_reset(hw, sky2->port); - sky2_phy_init(hw, sky2->port); - up(&sky2->phy_sema); + sky2_phy_reinit(sky2); return 0; } @@ -2477,20 +2496,20 @@ static int sky2_set_mac_address(struct net_device *dev, void *p) { struct sky2_port *sky2 = netdev_priv(dev); struct sockaddr *addr = p; - int err = 0; if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; - sky2_down(dev); memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); memcpy_toio(sky2->hw->regs + B2_MAC_1 + sky2->port * 8, dev->dev_addr, ETH_ALEN); memcpy_toio(sky2->hw->regs + B2_MAC_2 + sky2->port * 8, dev->dev_addr, ETH_ALEN); - if (dev->flags & IFF_UP) - err = sky2_up(dev); - return err; + + if (netif_running(dev)) + sky2_phy_reinit(sky2); + + return 0; } static void sky2_set_multicast(struct net_device *dev) @@ -2648,10 +2667,7 @@ static int sky2_set_pauseparam(struct net_device *dev, sky2->tx_pause = ecmd->tx_pause != 0; sky2->rx_pause = ecmd->rx_pause != 0; - if (netif_running(dev)) { - sky2_down(dev); - err = sky2_up(dev); - } + sky2_phy_reinit(sky2); return err; } @@ -2813,8 +2829,11 @@ static int sky2_set_ringparam(struct net_device *dev, sky2->rx_pending = ering->rx_pending; sky2->tx_pending = ering->tx_pending; - if (netif_running(dev)) + if (netif_running(dev)) { err = sky2_up(dev); + if (err) + dev_close(dev); + } return err; } @@ -3195,7 +3214,8 @@ static int sky2_resume(struct pci_dev *pdev) if (dev) { if (netif_running(dev)) { netif_device_attach(dev); - sky2_up(dev); + if (sky2_up(dev)) + dev_close(dev); } } } -- cgit v1.1 From 6ed995bb29f042eece8392d9bae0b83f84bcdb23 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Tue, 20 Dec 2005 15:08:08 -0800 Subject: [PATCH] sky2: don't lose multicast addresses Don't lose multicast addresses when link goes down or ring parameters change. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/sky2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 1d183d5..c7b4da1 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1478,8 +1478,6 @@ static void sky2_link_down(struct sky2_port *sky2) | PHY_M_AN_ASP); } - sky2_phy_reset(hw, port); - netif_carrier_off(sky2->netdev); netif_stop_queue(sky2->netdev); @@ -2833,6 +2831,8 @@ static int sky2_set_ringparam(struct net_device *dev, err = sky2_up(dev); if (err) dev_close(dev); + else + sky2_set_multicast(dev); } return err; -- cgit v1.1 From 6e15b7124990e4b91645601e7a90d3fe72873336 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Tue, 20 Dec 2005 15:08:09 -0800 Subject: [PATCH] sky2: handle hardware packet overrun It is possible for hardware to get confused when an oversized frame is received. In that case, just drop the packet and increment a counter. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/sky2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index c7b4da1..9b428e4 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -1694,6 +1694,9 @@ static struct sk_buff *sky2_receive(struct sky2_port *sky2, if (!(status & GMR_FS_RX_OK)) goto resubmit; + if ((status >> 16) != length || length > sky2->rx_bufsize) + goto oversize; + if (length < copybreak) { skb = alloc_skb(length + 2, GFP_ATOMIC); if (!skb) @@ -1735,7 +1738,13 @@ resubmit: return skb; +oversize: + ++sky2->net_stats.rx_over_errors; + goto resubmit; + error: + ++sky2->net_stats.rx_errors; + if (netif_msg_rx_err(sky2)) printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n", sky2->netdev->name, status, length); -- cgit v1.1 From c4c48d83e9ffb1c25cccd59d5ea9dda6ded01faf Mon Sep 17 00:00:00 2001 From: Stephen Hemminger <shemminger@osdl.org> Date: Tue, 20 Dec 2005 15:08:10 -0800 Subject: [PATCH] sky2: version 0.11 Version number change. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com> --- drivers/net/sky2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 9b428e4..f5d697c 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c @@ -57,7 +57,7 @@ #include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "0.10" +#define DRV_VERSION "0.11" #define PFX DRV_NAME " " /* -- cgit v1.1 From 9572b28faf72859c6b91891c627870cfa282d19d Mon Sep 17 00:00:00 2001 From: Luke Yang <luke.adi@gmail.com> Date: Wed, 21 Dec 2005 10:27:23 +0800 Subject: kbuild: Fix crc-error warning on modules This is the patch for the following issue: In include/linux/module.h, "__crc_" and "__ksymtab_" are hard coded to be the prefix for some kinds of symbols (CRC symbol and ksymtab section). But in script /mod/modpost.c, MODULE_SYMBOL_PREFIX##"__crc_" is used as the prefix to search CRC symbols. So if an architecture (such as h8300 or Blackfin) defines MODULE_SYMBOL_PREFIX as not NULL ("_"), modpost will always warn about "no invalid crc". And it is the same with KSYMTAB_PFX. Signed-off-by: Luke Yang <luke.adi@gmail.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- scripts/mod/modpost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3bed09e..8ce5a63 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -326,8 +326,8 @@ parse_elf_finish(struct elf_info *info) release_file(info->hdr, info->size); } -#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" -#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" +#define CRC_PFX "__crc_" +#define KSYMTAB_PFX "__ksymtab_" void handle_modversions(struct module *mod, struct elf_info *info, -- cgit v1.1 From f6333eb4e788bf70d6455c9004b6b676df62c500 Mon Sep 17 00:00:00 2001 From: John Kacur <jkacur@rogers.com> Date: Sat, 29 Oct 2005 00:25:13 -0400 Subject: kbuild: Add ctags support for function prototypes and external variable declarations This patch adds function prototypes and external variable declarations to the set of tag kinds when running ctags. I find this useful when perusing the kernel. Please apply. Signed-off-by: John Kacur <jkacur@rogers.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5f685b9..ced0346 100644 --- a/Makefile +++ b/Makefile @@ -1236,8 +1236,10 @@ cscope: FORCE quiet_cmd_TAGS = MAKE $@ define cmd_TAGS rm -f $@; \ - ETAGSF=`etags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL --extra=+f"`; \ - $(all-sources) | xargs etags $$ETAGSF -a + ETAGSF=`etags --version | grep -i exuberant >/dev/null && \ + echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px"`; \ + $(all-sources) | xargs etags $$ETAGSF -a endef TAGS: FORCE @@ -1247,8 +1249,10 @@ TAGS: FORCE quiet_cmd_tags = MAKE $@ define cmd_tags rm -f $@; \ - CTAGSF=`ctags --version | grep -i exuberant >/dev/null && echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL --extra=+f"`; \ - $(all-sources) | xargs ctags $$CTAGSF -a + CTAGSF=`ctags --version | grep -i exuberant >/dev/null && \ + echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px"`; \ + $(all-sources) | xargs ctags $$CTAGSF -a endef tags: FORCE -- cgit v1.1 From 4d99f93bdaa1ab49188cac67b4aae9180f8e3960 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg <sam@mars.ravnborg.org> Date: Sun, 25 Dec 2005 23:21:14 +0100 Subject: kbuild: escape '#' in .target.cmd files Commandlines are contained in the .<target>.cmd files and in case they contain a '#' char make see this as start of comment. Teach fixdep to escape the '#' char so make will assing the full commandline. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- scripts/basic/fixdep.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 0b61bea..679124b 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -130,9 +130,22 @@ void usage(void) exit(1); } +/* + * Print out the commandline prefixed with cmd_<target filename> := + * If commandline contains '#' escape with '\' so make to not see + * the '#' as a start-of-comment symbol + **/ void print_cmdline(void) { - printf("cmd_%s := %s\n\n", target, cmdline); + char *p = cmdline; + + printf("cmd_%s := ", target); + for (; *p; p++) { + if (*p == '#') + printf("\\"); + printf("%c", *p); + } + printf("\n\n"); } char * str_config = NULL; -- cgit v1.1 From f83b5e323f57d6e1f35a839d663e91cebe985e54 Mon Sep 17 00:00:00 2001 From: Ustyugov Roman <dr_unique@ymg.ru> Date: Fri, 23 Sep 2005 08:42:11 +0400 Subject: kbuild: set correct KBUILD_MODNAME when using well known kernel symbols as module names This patch fixes a problem when we use well known kernel symbols as module names. For example, if module source name is current.c, idle_stack.c or etc., we have a bad KBUILD_MODNAME value. For example, KBUILD_MODNAME will be "get_current()" instead of "current", or "(init_thread_union.stack)" instead of "idle_task". The trick is to define a stringify macro on the commandline - named KBUILD_STR for namespace reasons - and then to stringify the module name. There are a few uses of KBUILD_MODNAME throughout the tree but the usage is for debug and will not be harmed by this change so left untouched for now. While at it KBUILD_BASENAME was changed too. Any spinlock usage in the unix module would have created wrong section names without it. Usage in spinlock.h fixed so it no longer stringify KBUILD_BASENAME. Original patch from Ustyogov Roman - all bugs introduced by me. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- include/linux/spinlock.h | 3 +-- scripts/Makefile.lib | 8 +++++--- scripts/mod/modpost.c | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 0e9682c..799be67 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -59,8 +59,7 @@ /* * Must define these before including other files, inline functions need them */ -#define LOCK_SECTION_NAME \ - ".text.lock." __stringify(KBUILD_BASENAME) +#define LOCK_SECTION_NAME ".text.lock."KBUILD_BASENAME #define LOCK_SECTION_START(extra) \ ".subsection 1\n\t" \ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 0f81dcf..550798f 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -81,8 +81,10 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs)) # Note: It's possible that one object gets potentially linked into more # than one module. In that case KBUILD_MODNAME will be set to foo_bar, # where foo and bar are the name of the modules. -basename_flags = -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) -modname_flags = $(if $(filter 1,$(words $(modname))),-DKBUILD_MODNAME=$(subst $(comma),_,$(subst -,_,$(modname)))) +name-fix = $(subst $(comma),_,$(subst -,_,$1)) +basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(*F)))" +modname_flags = $(if $(filter 1,$(words $(modname))),\ + -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") _c_flags = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(*F).o) _a_flags = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(*F).o) @@ -113,7 +115,7 @@ endif c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ $(__c_flags) $(modkern_cflags) \ - $(basename_flags) $(modname_flags) + -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \ $(__a_flags) $(modkern_aflags) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 8ce5a63..f70ff13 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -539,10 +539,9 @@ add_header(struct buffer *b, struct module *mod) buf_printf(b, "\n"); buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n"); buf_printf(b, "\n"); - buf_printf(b, "#undef unix\n"); /* We have a module called "unix" */ buf_printf(b, "struct module __this_module\n"); buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); - buf_printf(b, " .name = __stringify(KBUILD_MODNAME),\n"); + buf_printf(b, " .name = KBUILD_MODNAME,\n"); if (mod->has_init) buf_printf(b, " .init = init_module,\n"); if (mod->has_cleanup) -- cgit v1.1 From a89a0a2354ae666612968e254d650bfd04f11eb6 Mon Sep 17 00:00:00 2001 From: Robin Holt <holt@sgi.com> Date: Tue, 20 Dec 2005 19:45:50 -0600 Subject: kbuild: Fix genksyms handling of DEFINE_PER_CPU(struct foo_s *, bar); This is a one-line change to parse.y. To take advantage of this the scripts/genksyms/*_shipped files needs to be rebuild - this is the next patch. When a .c file contains: DEFINE_PER_CPU(struct foo_s *, bar); the .cpp output looks like: __attribute__((__section__(".data.percpu"))) __typeof__(struct foo_s *) per_cpu__bar; With the existing parse.y, the value inside the paranthesis of __typeof__() does not evaluate as a type_specifier and therefore per_cpu__bar does not get assigned a type for genksyms which results in the EXPORT_PER_CPU_SYMBOL() not generating a CRC value. I have compared the Modules.symvers with and without this patch and for ia64's defconfig, the only change is: Before 0x00000000 per_cpu____sn_nodepda vmlinux After 0x9d3f3faa per_cpu____sn_nodepda vmlinux per_cpu____sn_nodepda was the original source of my problems. Signed-off-by: Robin Holt <holt@sgi.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- scripts/genksyms/parse.y | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y index 0990437..ca04c944 100644 --- a/scripts/genksyms/parse.y +++ b/scripts/genksyms/parse.y @@ -197,6 +197,7 @@ storage_class_specifier: type_specifier: simple_type_specifier | cvar_qualifier + | TYPEOF_KEYW '(' decl_specifier_seq '*' ')' | TYPEOF_KEYW '(' decl_specifier_seq ')' /* References to s/u/e's defined elsewhere. Rearrange things -- cgit v1.1 From c40f56409d01f6f1ea80ed4c229096749c2335df Mon Sep 17 00:00:00 2001 From: Sam Ravnborg <sam@mars.ravnborg.org> Date: Mon, 26 Dec 2005 22:53:25 +0100 Subject: kbuild: Create _shipped files for genksyms Generate _shipped files so the genksyms change in previous commit is enabled. The files are generated with latest versions of the tools: bison (GNU Bison) 2.0 flex version 2.5.4 GNU gperf 3.0.1 Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- scripts/genksyms/keywords.c_shipped | 210 ++- scripts/genksyms/lex.c_shipped | 168 +- scripts/genksyms/parse.c_shipped | 2924 ++++++++++++++++++++--------------- scripts/genksyms/parse.h_shipped | 166 +- 4 files changed, 2086 insertions(+), 1382 deletions(-) diff --git a/scripts/genksyms/keywords.c_shipped b/scripts/genksyms/keywords.c_shipped index eabaf74..ee46478 100644 --- a/scripts/genksyms/keywords.c_shipped +++ b/scripts/genksyms/keywords.c_shipped @@ -1,7 +1,38 @@ -/* ANSI-C code produced by gperf version 2.7.2 */ +/* ANSI-C code produced by gperf version 3.0.1 */ /* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." +#endif + +#line 1 "scripts/genksyms/keywords.gperf" + +#line 3 "scripts/genksyms/keywords.gperf" struct resword { const char *name; int token; }; -/* maximum key range = 109, duplicates = 0 */ +/* maximum key range = 68, duplicates = 0 */ #ifdef __GNUC__ __inline @@ -15,32 +46,32 @@ is_reserved_hash (register const char *str, register unsigned int len) { static const unsigned char asso_values[] = { - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 5, - 113, 113, 113, 113, 113, 113, 0, 113, 113, 113, - 0, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 0, 113, 0, 113, 20, - 25, 0, 35, 30, 113, 20, 113, 113, 40, 30, - 30, 0, 0, 113, 0, 51, 0, 15, 5, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, - 113, 113, 113, 113, 113, 113 + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 15, + 71, 71, 71, 71, 71, 71, 15, 71, 71, 71, + 10, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 0, 71, 0, 71, 5, + 5, 0, 10, 20, 71, 25, 71, 71, 20, 0, + 20, 30, 25, 71, 10, 5, 0, 20, 15, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71 }; return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]]; } @@ -56,77 +87,112 @@ is_reserved_word (register const char *str, register unsigned int len) TOTAL_KEYWORDS = 41, MIN_WORD_LENGTH = 3, MAX_WORD_LENGTH = 17, - MIN_HASH_VALUE = 4, - MAX_HASH_VALUE = 112 + MIN_HASH_VALUE = 3, + MAX_HASH_VALUE = 70 }; static const struct resword wordlist[] = { - {""}, {""}, {""}, {""}, - {"auto", AUTO_KEYW}, - {""}, {""}, + {""}, {""}, {""}, +#line 24 "scripts/genksyms/keywords.gperf" + {"asm", ASM_KEYW}, + {""}, +#line 7 "scripts/genksyms/keywords.gperf" + {"__asm", ASM_KEYW}, + {""}, +#line 8 "scripts/genksyms/keywords.gperf" {"__asm__", ASM_KEYW}, {""}, +#line 21 "scripts/genksyms/keywords.gperf" {"_restrict", RESTRICT_KEYW}, +#line 50 "scripts/genksyms/keywords.gperf" {"__typeof__", TYPEOF_KEYW}, +#line 9 "scripts/genksyms/keywords.gperf" {"__attribute", ATTRIBUTE_KEYW}, - {"__restrict__", RESTRICT_KEYW}, +#line 11 "scripts/genksyms/keywords.gperf" + {"__const", CONST_KEYW}, +#line 10 "scripts/genksyms/keywords.gperf" {"__attribute__", ATTRIBUTE_KEYW}, +#line 12 "scripts/genksyms/keywords.gperf" + {"__const__", CONST_KEYW}, +#line 16 "scripts/genksyms/keywords.gperf" + {"__signed__", SIGNED_KEYW}, +#line 42 "scripts/genksyms/keywords.gperf" + {"static", STATIC_KEYW}, {""}, - {"__volatile", VOLATILE_KEYW}, +#line 15 "scripts/genksyms/keywords.gperf" + {"__signed", SIGNED_KEYW}, +#line 30 "scripts/genksyms/keywords.gperf" + {"char", CHAR_KEYW}, {""}, +#line 43 "scripts/genksyms/keywords.gperf" + {"struct", STRUCT_KEYW}, +#line 22 "scripts/genksyms/keywords.gperf" + {"__restrict__", RESTRICT_KEYW}, +#line 23 "scripts/genksyms/keywords.gperf" + {"restrict", RESTRICT_KEYW}, +#line 33 "scripts/genksyms/keywords.gperf" + {"enum", ENUM_KEYW}, +#line 17 "scripts/genksyms/keywords.gperf" + {"__volatile", VOLATILE_KEYW}, +#line 34 "scripts/genksyms/keywords.gperf" + {"extern", EXTERN_KEYW}, +#line 18 "scripts/genksyms/keywords.gperf" {"__volatile__", VOLATILE_KEYW}, - {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW}, - {""}, {""}, {""}, - {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, +#line 37 "scripts/genksyms/keywords.gperf" {"int", INT_KEYW}, - {"char", CHAR_KEYW}, - {""}, {""}, - {"__const", CONST_KEYW}, + {""}, +#line 31 "scripts/genksyms/keywords.gperf" + {"const", CONST_KEYW}, +#line 32 "scripts/genksyms/keywords.gperf" + {"double", DOUBLE_KEYW}, + {""}, +#line 13 "scripts/genksyms/keywords.gperf" {"__inline", INLINE_KEYW}, - {"__const__", CONST_KEYW}, +#line 29 "scripts/genksyms/keywords.gperf" + {"auto", AUTO_KEYW}, +#line 14 "scripts/genksyms/keywords.gperf" {"__inline__", INLINE_KEYW}, - {""}, {""}, {""}, {""}, - {"__asm", ASM_KEYW}, - {"extern", EXTERN_KEYW}, +#line 41 "scripts/genksyms/keywords.gperf" + {"signed", SIGNED_KEYW}, {""}, - {"register", REGISTER_KEYW}, +#line 46 "scripts/genksyms/keywords.gperf" + {"unsigned", UNSIGNED_KEYW}, {""}, - {"float", FLOAT_KEYW}, +#line 40 "scripts/genksyms/keywords.gperf" + {"short", SHORT_KEYW}, +#line 49 "scripts/genksyms/keywords.gperf" {"typeof", TYPEOF_KEYW}, +#line 44 "scripts/genksyms/keywords.gperf" {"typedef", TYPEDEF_KEYW}, - {""}, {""}, - {"_Bool", BOOL_KEYW}, - {"double", DOUBLE_KEYW}, - {""}, {""}, - {"enum", ENUM_KEYW}, - {""}, {""}, {""}, +#line 48 "scripts/genksyms/keywords.gperf" {"volatile", VOLATILE_KEYW}, + {""}, +#line 35 "scripts/genksyms/keywords.gperf" + {"float", FLOAT_KEYW}, + {""}, {""}, +#line 39 "scripts/genksyms/keywords.gperf" + {"register", REGISTER_KEYW}, +#line 47 "scripts/genksyms/keywords.gperf" {"void", VOID_KEYW}, - {"const", CONST_KEYW}, - {"short", SHORT_KEYW}, - {"struct", STRUCT_KEYW}, {""}, - {"restrict", RESTRICT_KEYW}, +#line 36 "scripts/genksyms/keywords.gperf" + {"inline", INLINE_KEYW}, {""}, - {"__signed__", SIGNED_KEYW}, +#line 5 "scripts/genksyms/keywords.gperf" + {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW}, {""}, - {"asm", ASM_KEYW}, - {""}, {""}, - {"inline", INLINE_KEYW}, - {""}, {""}, {""}, - {"union", UNION_KEYW}, - {""}, {""}, {""}, {""}, {""}, {""}, - {"static", STATIC_KEYW}, +#line 20 "scripts/genksyms/keywords.gperf" + {"_Bool", BOOL_KEYW}, + {""}, +#line 6 "scripts/genksyms/keywords.gperf" + {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, {""}, {""}, {""}, {""}, {""}, {""}, - {"__signed", SIGNED_KEYW}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {""}, {""}, {""}, {""}, {""}, - {"unsigned", UNSIGNED_KEYW}, - {""}, {""}, {""}, {""}, +#line 38 "scripts/genksyms/keywords.gperf" {"long", LONG_KEYW}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, - {"signed", SIGNED_KEYW} + {""}, {""}, {""}, {""}, {""}, +#line 45 "scripts/genksyms/keywords.gperf" + {"union", UNION_KEYW} }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) diff --git a/scripts/genksyms/lex.c_shipped b/scripts/genksyms/lex.c_shipped index d9bfbb5..1218053 100644 --- a/scripts/genksyms/lex.c_shipped +++ b/scripts/genksyms/lex.c_shipped @@ -2036,49 +2036,131 @@ fini: return token; } -#ifndef YYSTYPE -#define YYSTYPE int -#endif -#define ASM_KEYW 257 -#define ATTRIBUTE_KEYW 258 -#define AUTO_KEYW 259 -#define BOOL_KEYW 260 -#define CHAR_KEYW 261 -#define CONST_KEYW 262 -#define DOUBLE_KEYW 263 -#define ENUM_KEYW 264 -#define EXTERN_KEYW 265 -#define FLOAT_KEYW 266 -#define INLINE_KEYW 267 -#define INT_KEYW 268 -#define LONG_KEYW 269 -#define REGISTER_KEYW 270 -#define RESTRICT_KEYW 271 -#define SHORT_KEYW 272 -#define SIGNED_KEYW 273 -#define STATIC_KEYW 274 -#define STRUCT_KEYW 275 -#define TYPEDEF_KEYW 276 -#define UNION_KEYW 277 -#define UNSIGNED_KEYW 278 -#define VOID_KEYW 279 -#define VOLATILE_KEYW 280 -#define TYPEOF_KEYW 281 -#define EXPORT_SYMBOL_KEYW 282 -#define ASM_PHRASE 283 -#define ATTRIBUTE_PHRASE 284 -#define BRACE_PHRASE 285 -#define BRACKET_PHRASE 286 -#define EXPRESSION_PHRASE 287 -#define CHAR 288 -#define DOTS 289 -#define IDENT 290 -#define INT 291 -#define REAL 292 -#define STRING 293 -#define TYPE 294 -#define OTHER 295 -#define FILENAME 296 +/* A Bison parser, made by GNU Bison 2.0. */ +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ASM_KEYW = 258, + ATTRIBUTE_KEYW = 259, + AUTO_KEYW = 260, + BOOL_KEYW = 261, + CHAR_KEYW = 262, + CONST_KEYW = 263, + DOUBLE_KEYW = 264, + ENUM_KEYW = 265, + EXTERN_KEYW = 266, + FLOAT_KEYW = 267, + INLINE_KEYW = 268, + INT_KEYW = 269, + LONG_KEYW = 270, + REGISTER_KEYW = 271, + RESTRICT_KEYW = 272, + SHORT_KEYW = 273, + SIGNED_KEYW = 274, + STATIC_KEYW = 275, + STRUCT_KEYW = 276, + TYPEDEF_KEYW = 277, + UNION_KEYW = 278, + UNSIGNED_KEYW = 279, + VOID_KEYW = 280, + VOLATILE_KEYW = 281, + TYPEOF_KEYW = 282, + EXPORT_SYMBOL_KEYW = 283, + ASM_PHRASE = 284, + ATTRIBUTE_PHRASE = 285, + BRACE_PHRASE = 286, + BRACKET_PHRASE = 287, + EXPRESSION_PHRASE = 288, + CHAR = 289, + DOTS = 290, + IDENT = 291, + INT = 292, + REAL = 293, + STRING = 294, + TYPE = 295, + OTHER = 296, + FILENAME = 297 + }; +#endif +#define ASM_KEYW 258 +#define ATTRIBUTE_KEYW 259 +#define AUTO_KEYW 260 +#define BOOL_KEYW 261 +#define CHAR_KEYW 262 +#define CONST_KEYW 263 +#define DOUBLE_KEYW 264 +#define ENUM_KEYW 265 +#define EXTERN_KEYW 266 +#define FLOAT_KEYW 267 +#define INLINE_KEYW 268 +#define INT_KEYW 269 +#define LONG_KEYW 270 +#define REGISTER_KEYW 271 +#define RESTRICT_KEYW 272 +#define SHORT_KEYW 273 +#define SIGNED_KEYW 274 +#define STATIC_KEYW 275 +#define STRUCT_KEYW 276 +#define TYPEDEF_KEYW 277 +#define UNION_KEYW 278 +#define UNSIGNED_KEYW 279 +#define VOID_KEYW 280 +#define VOLATILE_KEYW 281 +#define TYPEOF_KEYW 282 +#define EXPORT_SYMBOL_KEYW 283 +#define ASM_PHRASE 284 +#define ATTRIBUTE_PHRASE 285 +#define BRACE_PHRASE 286 +#define BRACKET_PHRASE 287 +#define EXPRESSION_PHRASE 288 +#define CHAR 289 +#define DOTS 290 +#define IDENT 291 +#define INT 292 +#define REAL 293 +#define STRING 294 +#define TYPE 295 +#define OTHER 296 +#define FILENAME 297 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif extern YYSTYPE yylval; + + + diff --git a/scripts/genksyms/parse.c_shipped b/scripts/genksyms/parse.c_shipped index 2c6b128..99d7c25 100644 --- a/scripts/genksyms/parse.c_shipped +++ b/scripts/genksyms/parse.c_shipped @@ -1,50 +1,145 @@ +/* A Bison parser, made by GNU Bison 2.0. */ -/* A Bison parser, made from scripts/genksyms/parse.y - by GNU Bison version 1.28 */ - -#define YYBISON 1 /* Identify Bison output. */ - -#define ASM_KEYW 257 -#define ATTRIBUTE_KEYW 258 -#define AUTO_KEYW 259 -#define BOOL_KEYW 260 -#define CHAR_KEYW 261 -#define CONST_KEYW 262 -#define DOUBLE_KEYW 263 -#define ENUM_KEYW 264 -#define EXTERN_KEYW 265 -#define FLOAT_KEYW 266 -#define INLINE_KEYW 267 -#define INT_KEYW 268 -#define LONG_KEYW 269 -#define REGISTER_KEYW 270 -#define RESTRICT_KEYW 271 -#define SHORT_KEYW 272 -#define SIGNED_KEYW 273 -#define STATIC_KEYW 274 -#define STRUCT_KEYW 275 -#define TYPEDEF_KEYW 276 -#define UNION_KEYW 277 -#define UNSIGNED_KEYW 278 -#define VOID_KEYW 279 -#define VOLATILE_KEYW 280 -#define TYPEOF_KEYW 281 -#define EXPORT_SYMBOL_KEYW 282 -#define ASM_PHRASE 283 -#define ATTRIBUTE_PHRASE 284 -#define BRACE_PHRASE 285 -#define BRACKET_PHRASE 286 -#define EXPRESSION_PHRASE 287 -#define CHAR 288 -#define DOTS 289 -#define IDENT 290 -#define INT 291 -#define REAL 292 -#define STRING 293 -#define TYPE 294 -#define OTHER 295 -#define FILENAME 296 +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ASM_KEYW = 258, + ATTRIBUTE_KEYW = 259, + AUTO_KEYW = 260, + BOOL_KEYW = 261, + CHAR_KEYW = 262, + CONST_KEYW = 263, + DOUBLE_KEYW = 264, + ENUM_KEYW = 265, + EXTERN_KEYW = 266, + FLOAT_KEYW = 267, + INLINE_KEYW = 268, + INT_KEYW = 269, + LONG_KEYW = 270, + REGISTER_KEYW = 271, + RESTRICT_KEYW = 272, + SHORT_KEYW = 273, + SIGNED_KEYW = 274, + STATIC_KEYW = 275, + STRUCT_KEYW = 276, + TYPEDEF_KEYW = 277, + UNION_KEYW = 278, + UNSIGNED_KEYW = 279, + VOID_KEYW = 280, + VOLATILE_KEYW = 281, + TYPEOF_KEYW = 282, + EXPORT_SYMBOL_KEYW = 283, + ASM_PHRASE = 284, + ATTRIBUTE_PHRASE = 285, + BRACE_PHRASE = 286, + BRACKET_PHRASE = 287, + EXPRESSION_PHRASE = 288, + CHAR = 289, + DOTS = 290, + IDENT = 291, + INT = 292, + REAL = 293, + STRING = 294, + TYPE = 295, + OTHER = 296, + FILENAME = 297 + }; +#endif +#define ASM_KEYW 258 +#define ATTRIBUTE_KEYW 259 +#define AUTO_KEYW 260 +#define BOOL_KEYW 261 +#define CHAR_KEYW 262 +#define CONST_KEYW 263 +#define DOUBLE_KEYW 264 +#define ENUM_KEYW 265 +#define EXTERN_KEYW 266 +#define FLOAT_KEYW 267 +#define INLINE_KEYW 268 +#define INT_KEYW 269 +#define LONG_KEYW 270 +#define REGISTER_KEYW 271 +#define RESTRICT_KEYW 272 +#define SHORT_KEYW 273 +#define SIGNED_KEYW 274 +#define STATIC_KEYW 275 +#define STRUCT_KEYW 276 +#define TYPEDEF_KEYW 277 +#define UNION_KEYW 278 +#define UNSIGNED_KEYW 279 +#define VOID_KEYW 280 +#define VOLATILE_KEYW 281 +#define TYPEOF_KEYW 282 +#define EXPORT_SYMBOL_KEYW 283 +#define ASM_PHRASE 284 +#define ATTRIBUTE_PHRASE 285 +#define BRACE_PHRASE 286 +#define BRACKET_PHRASE 287 +#define EXPRESSION_PHRASE 288 +#define CHAR 289 +#define DOTS 290 +#define IDENT 291 +#define INT 292 +#define REAL 293 +#define STRING 294 +#define TYPE 295 +#define OTHER 296 +#define FILENAME 297 + + + + +/* Copy the first part of user declarations. */ #line 24 "scripts/genksyms/parse.y" @@ -75,661 +170,1000 @@ remove_list(struct string_list **pb, struct string_list **pe) free_list(b, e); } -#ifndef YYSTYPE -#define YYSTYPE int -#endif + + +/* Enabling traces. */ #ifndef YYDEBUG -#define YYDEBUG 1 +# define YYDEBUG 1 #endif -#include <stdio.h> - -#ifndef __cplusplus -#ifndef __STDC__ -#define const +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 #endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif -#define YYFINAL 172 -#define YYFLAG -32768 -#define YYNTBASE 52 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 96) - -static const char yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 46, - 47, 48, 2, 45, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 51, 43, 2, - 49, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 50, 2, 44, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42 -}; +/* Copy the second part of user declarations. */ -#if YYDEBUG != 0 -static const short yyprhs[] = { 0, - 0, 2, 5, 6, 9, 10, 14, 16, 18, 20, - 22, 25, 28, 32, 33, 35, 37, 41, 46, 47, - 49, 51, 54, 56, 58, 60, 62, 64, 66, 68, - 70, 72, 77, 80, 83, 86, 90, 94, 98, 101, - 104, 107, 109, 111, 113, 115, 117, 119, 121, 123, - 125, 127, 129, 132, 133, 135, 137, 140, 142, 144, - 146, 148, 151, 153, 155, 160, 165, 168, 172, 176, - 179, 181, 183, 185, 190, 195, 198, 202, 206, 209, - 211, 215, 216, 218, 220, 224, 227, 230, 232, 233, - 235, 237, 242, 247, 250, 254, 258, 262, 263, 265, - 268, 272, 276, 277, 279, 281, 284, 288, 291, 292, - 294, 296, 300, 303, 306, 308, 311, 312, 314, 317, - 318, 320 -}; -static const short yyrhs[] = { 53, - 0, 52, 53, 0, 0, 54, 55, 0, 0, 22, - 56, 57, 0, 57, 0, 81, 0, 93, 0, 95, - 0, 1, 43, 0, 1, 44, 0, 61, 58, 43, - 0, 0, 59, 0, 60, 0, 59, 45, 60, 0, - 71, 94, 92, 82, 0, 0, 62, 0, 63, 0, - 62, 63, 0, 64, 0, 65, 0, 5, 0, 16, - 0, 20, 0, 11, 0, 13, 0, 66, 0, 70, - 0, 27, 46, 62, 47, 0, 21, 36, 0, 23, - 36, 0, 10, 36, 0, 21, 36, 84, 0, 23, - 36, 84, 0, 10, 36, 31, 0, 10, 31, 0, - 21, 84, 0, 23, 84, 0, 7, 0, 18, 0, - 14, 0, 15, 0, 19, 0, 24, 0, 12, 0, - 9, 0, 25, 0, 6, 0, 40, 0, 48, 68, - 0, 0, 69, 0, 70, 0, 69, 70, 0, 8, - 0, 26, 0, 30, 0, 17, 0, 67, 71, 0, - 72, 0, 36, 0, 72, 46, 75, 47, 0, 72, - 46, 1, 47, 0, 72, 32, 0, 46, 71, 47, - 0, 46, 1, 47, 0, 67, 73, 0, 74, 0, - 36, 0, 40, 0, 74, 46, 75, 47, 0, 74, - 46, 1, 47, 0, 74, 32, 0, 46, 73, 47, - 0, 46, 1, 47, 0, 76, 35, 0, 76, 0, - 77, 45, 35, 0, 0, 77, 0, 78, 0, 77, - 45, 78, 0, 62, 79, 0, 67, 79, 0, 80, - 0, 0, 36, 0, 40, 0, 80, 46, 75, 47, - 0, 80, 46, 1, 47, 0, 80, 32, 0, 46, - 79, 47, 0, 46, 1, 47, 0, 61, 71, 31, - 0, 0, 83, 0, 49, 33, 0, 50, 85, 44, - 0, 50, 1, 44, 0, 0, 86, 0, 87, 0, - 86, 87, 0, 61, 88, 43, 0, 1, 43, 0, - 0, 89, 0, 90, 0, 89, 45, 90, 0, 73, - 92, 0, 36, 91, 0, 91, 0, 51, 33, 0, - 0, 30, 0, 29, 43, 0, 0, 29, 0, 28, - 46, 36, 47, 43, 0 -}; +/* Line 213 of yacc.c. */ +#line 202 "scripts/genksyms/parse.c" -#endif +#if ! defined (yyoverflow) || YYERROR_VERBOSE -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 101, 103, 106, 109, 112, 114, 115, 116, 117, 118, - 119, 120, 123, 137, 139, 142, 151, 163, 169, 171, - 174, 176, 179, 186, 189, 191, 192, 193, 194, 197, - 199, 200, 204, 206, 208, 212, 219, 226, 235, 236, - 237, 240, 242, 243, 244, 245, 246, 247, 248, 249, - 250, 251, 254, 259, 261, 264, 266, 269, 270, 270, - 271, 278, 280, 283, 293, 295, 297, 299, 301, 307, - 309, 312, 314, 315, 317, 319, 321, 323, 327, 329, - 330, 333, 335, 338, 340, 344, 349, 352, 355, 357, - 365, 369, 371, 373, 375, 377, 381, 390, 392, 396, - 401, 403, 406, 408, 411, 413, 416, 419, 423, 425, - 428, 430, 433, 435, 436, 439, 443, 445, 448, 452, - 454, 457 -}; -#endif +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# else +# define YYSTACK_ALLOC alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short int yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) -#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) - -static const char * const yytname[] = { "$","error","$undefined.","ASM_KEYW", -"ATTRIBUTE_KEYW","AUTO_KEYW","BOOL_KEYW","CHAR_KEYW","CONST_KEYW","DOUBLE_KEYW", -"ENUM_KEYW","EXTERN_KEYW","FLOAT_KEYW","INLINE_KEYW","INT_KEYW","LONG_KEYW", -"REGISTER_KEYW","RESTRICT_KEYW","SHORT_KEYW","SIGNED_KEYW","STATIC_KEYW","STRUCT_KEYW", -"TYPEDEF_KEYW","UNION_KEYW","UNSIGNED_KEYW","VOID_KEYW","VOLATILE_KEYW","TYPEOF_KEYW", -"EXPORT_SYMBOL_KEYW","ASM_PHRASE","ATTRIBUTE_PHRASE","BRACE_PHRASE","BRACKET_PHRASE", -"EXPRESSION_PHRASE","CHAR","DOTS","IDENT","INT","REAL","STRING","TYPE","OTHER", -"FILENAME","';'","'}'","','","'('","')'","'*'","'='","'{'","':'","declaration_seq", -"declaration","@1","declaration1","@2","simple_declaration","init_declarator_list_opt", -"init_declarator_list","init_declarator","decl_specifier_seq_opt","decl_specifier_seq", -"decl_specifier","storage_class_specifier","type_specifier","simple_type_specifier", -"ptr_operator","cvar_qualifier_seq_opt","cvar_qualifier_seq","cvar_qualifier", -"declarator","direct_declarator","nested_declarator","direct_nested_declarator", -"parameter_declaration_clause","parameter_declaration_list_opt","parameter_declaration_list", -"parameter_declaration","m_abstract_declarator","direct_m_abstract_declarator", -"function_definition","initializer_opt","initializer","class_body","member_specification_opt", -"member_specification","member_declaration","member_declarator_list_opt","member_declarator_list", -"member_declarator","member_bitfield_declarator","attribute_opt","asm_definition", -"asm_phrase_opt","export_definition", NULL -}; #endif -static const short yyr1[] = { 0, - 52, 52, 54, 53, 56, 55, 55, 55, 55, 55, - 55, 55, 57, 58, 58, 59, 59, 60, 61, 61, - 62, 62, 63, 63, 64, 64, 64, 64, 64, 65, - 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, - 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, - 66, 66, 67, 68, 68, 69, 69, 70, 70, 70, - 70, 71, 71, 72, 72, 72, 72, 72, 72, 73, - 73, 74, 74, 74, 74, 74, 74, 74, 75, 75, - 75, 76, 76, 77, 77, 78, 79, 79, 80, 80, - 80, 80, 80, 80, 80, 80, 81, 82, 82, 83, - 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, - 89, 89, 90, 90, 90, 91, 92, 92, 93, 94, - 94, 95 +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short int yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 4 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 535 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 52 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 45 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 124 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 174 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 297 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 46, 48, 47, 2, 45, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 51, 43, + 2, 49, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 50, 2, 44, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42 }; -static const short yyr2[] = { 0, - 1, 2, 0, 2, 0, 3, 1, 1, 1, 1, - 2, 2, 3, 0, 1, 1, 3, 4, 0, 1, - 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 2, 2, 2, 3, 3, 3, 2, 2, - 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 0, 1, 1, 2, 1, 1, 1, - 1, 2, 1, 1, 4, 4, 2, 3, 3, 2, - 1, 1, 1, 4, 4, 2, 3, 3, 2, 1, - 3, 0, 1, 1, 3, 2, 2, 1, 0, 1, - 1, 4, 4, 2, 3, 3, 3, 0, 1, 2, - 3, 3, 0, 1, 1, 2, 3, 2, 0, 1, - 1, 3, 2, 2, 1, 2, 0, 1, 2, 0, - 1, 5 +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short int yyprhs[] = +{ + 0, 0, 3, 5, 8, 9, 12, 13, 17, 19, + 21, 23, 25, 28, 31, 35, 36, 38, 40, 44, + 49, 50, 52, 54, 57, 59, 61, 63, 65, 67, + 69, 71, 73, 75, 81, 86, 89, 92, 95, 99, + 103, 107, 110, 113, 116, 118, 120, 122, 124, 126, + 128, 130, 132, 134, 136, 138, 141, 142, 144, 146, + 149, 151, 153, 155, 157, 160, 162, 164, 169, 174, + 177, 181, 185, 188, 190, 192, 194, 199, 204, 207, + 211, 215, 218, 220, 224, 225, 227, 229, 233, 236, + 239, 241, 242, 244, 246, 251, 256, 259, 263, 267, + 271, 272, 274, 277, 281, 285, 286, 288, 290, 293, + 297, 300, 301, 303, 305, 309, 312, 315, 317, 320, + 321, 323, 326, 327, 329 }; -static const short yydefact[] = { 3, - 3, 1, 0, 2, 0, 25, 51, 42, 58, 49, - 0, 28, 48, 29, 44, 45, 26, 61, 43, 46, - 27, 0, 5, 0, 47, 50, 59, 0, 0, 0, - 60, 52, 4, 7, 14, 20, 21, 23, 24, 30, - 31, 8, 9, 10, 11, 12, 39, 35, 33, 0, - 40, 19, 34, 41, 0, 0, 119, 64, 0, 54, - 0, 15, 16, 0, 120, 63, 22, 38, 36, 0, - 109, 0, 0, 105, 6, 14, 37, 0, 0, 0, - 0, 53, 55, 56, 13, 0, 62, 121, 97, 117, - 67, 0, 108, 102, 72, 73, 0, 0, 0, 117, - 71, 0, 110, 111, 115, 101, 0, 106, 120, 32, - 0, 69, 68, 57, 17, 118, 98, 0, 89, 0, - 80, 83, 84, 114, 0, 72, 0, 116, 70, 113, - 76, 0, 107, 0, 122, 0, 18, 99, 66, 90, - 52, 0, 89, 86, 88, 65, 79, 0, 78, 77, - 0, 0, 112, 100, 0, 91, 0, 87, 94, 0, - 81, 85, 75, 74, 96, 95, 0, 0, 93, 92, - 0, 0 +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 53, 0, -1, 54, -1, 53, 54, -1, -1, 55, + 56, -1, -1, 22, 57, 58, -1, 58, -1, 82, + -1, 94, -1, 96, -1, 1, 43, -1, 1, 44, + -1, 62, 59, 43, -1, -1, 60, -1, 61, -1, + 60, 45, 61, -1, 72, 95, 93, 83, -1, -1, + 63, -1, 64, -1, 63, 64, -1, 65, -1, 66, + -1, 5, -1, 16, -1, 20, -1, 11, -1, 13, + -1, 67, -1, 71, -1, 27, 46, 63, 47, 48, + -1, 27, 46, 63, 48, -1, 21, 36, -1, 23, + 36, -1, 10, 36, -1, 21, 36, 85, -1, 23, + 36, 85, -1, 10, 36, 31, -1, 10, 31, -1, + 21, 85, -1, 23, 85, -1, 7, -1, 18, -1, + 14, -1, 15, -1, 19, -1, 24, -1, 12, -1, + 9, -1, 25, -1, 6, -1, 40, -1, 47, 69, + -1, -1, 70, -1, 71, -1, 70, 71, -1, 8, + -1, 26, -1, 30, -1, 17, -1, 68, 72, -1, + 73, -1, 36, -1, 73, 46, 76, 48, -1, 73, + 46, 1, 48, -1, 73, 32, -1, 46, 72, 48, + -1, 46, 1, 48, -1, 68, 74, -1, 75, -1, + 36, -1, 40, -1, 75, 46, 76, 48, -1, 75, + 46, 1, 48, -1, 75, 32, -1, 46, 74, 48, + -1, 46, 1, 48, -1, 77, 35, -1, 77, -1, + 78, 45, 35, -1, -1, 78, -1, 79, -1, 78, + 45, 79, -1, 63, 80, -1, 68, 80, -1, 81, + -1, -1, 36, -1, 40, -1, 81, 46, 76, 48, + -1, 81, 46, 1, 48, -1, 81, 32, -1, 46, + 80, 48, -1, 46, 1, 48, -1, 62, 72, 31, + -1, -1, 84, -1, 49, 33, -1, 50, 86, 44, + -1, 50, 1, 44, -1, -1, 87, -1, 88, -1, + 87, 88, -1, 62, 89, 43, -1, 1, 43, -1, + -1, 90, -1, 91, -1, 90, 45, 91, -1, 74, + 93, -1, 36, 92, -1, 92, -1, 51, 33, -1, + -1, 30, -1, 29, 43, -1, -1, 29, -1, 28, + 46, 36, 48, 43, -1 }; -static const short yydefgoto[] = { 1, - 2, 3, 33, 52, 34, 61, 62, 63, 71, 36, - 37, 38, 39, 40, 64, 82, 83, 41, 109, 66, - 100, 101, 120, 121, 122, 123, 144, 145, 42, 137, - 138, 51, 72, 73, 74, 102, 103, 104, 105, 117, - 43, 90, 44 +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short int yyrline[] = +{ + 0, 102, 102, 103, 107, 107, 113, 113, 115, 116, + 117, 118, 119, 120, 124, 138, 139, 143, 151, 164, + 170, 171, 175, 176, 180, 186, 190, 191, 192, 193, + 194, 198, 199, 200, 201, 205, 207, 209, 213, 220, + 227, 236, 237, 238, 242, 243, 244, 245, 246, 247, + 248, 249, 250, 251, 252, 256, 261, 262, 266, 267, + 271, 271, 271, 272, 280, 281, 285, 294, 296, 298, + 300, 302, 309, 310, 314, 315, 316, 318, 320, 322, + 324, 329, 330, 331, 335, 336, 340, 341, 346, 351, + 353, 357, 358, 366, 370, 372, 374, 376, 378, 383, + 392, 393, 398, 403, 404, 408, 409, 413, 414, 418, + 420, 425, 426, 430, 431, 435, 436, 437, 441, 445, + 446, 450, 454, 455, 459 }; +#endif -static const short yypact[] = {-32768, - 15,-32768, 197,-32768, 23,-32768,-32768,-32768,-32768,-32768, - -18,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, --32768, -28,-32768, -25,-32768,-32768,-32768, -26, -22, -12, --32768,-32768,-32768,-32768, 49, 493,-32768,-32768,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768, 27, -8, 101, --32768, 493, -8,-32768, 493, 10,-32768,-32768, 11, 9, - 18, 26,-32768, 49, -15, -13,-32768,-32768,-32768, 25, - 24, 48, 149,-32768,-32768, 49,-32768, 414, 39, 40, - 47,-32768, 9,-32768,-32768, 49,-32768,-32768,-32768, 66, --32768, 241,-32768,-32768, 50,-32768, 5, 65, 42, 66, - 17, 56, 55,-32768,-32768,-32768, 60,-32768, 75,-32768, - 80,-32768,-32768,-32768,-32768,-32768, 81, 82, 370, 85, - 98, 89,-32768,-32768, 88,-32768, 91,-32768,-32768,-32768, --32768, 284,-32768, 24,-32768, 103,-32768,-32768,-32768,-32768, --32768, 8, 43,-32768, 30,-32768,-32768, 457,-32768,-32768, - 92, 93,-32768,-32768, 95,-32768, 96,-32768,-32768, 327, --32768,-32768,-32768,-32768,-32768,-32768, 99, 104,-32768,-32768, - 148,-32768 +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "ASM_KEYW", "ATTRIBUTE_KEYW", + "AUTO_KEYW", "BOOL_KEYW", "CHAR_KEYW", "CONST_KEYW", "DOUBLE_KEYW", + "ENUM_KEYW", "EXTERN_KEYW", "FLOAT_KEYW", "INLINE_KEYW", "INT_KEYW", + "LONG_KEYW", "REGISTER_KEYW", "RESTRICT_KEYW", "SHORT_KEYW", + "SIGNED_KEYW", "STATIC_KEYW", "STRUCT_KEYW", "TYPEDEF_KEYW", + "UNION_KEYW", "UNSIGNED_KEYW", "VOID_KEYW", "VOLATILE_KEYW", + "TYPEOF_KEYW", "EXPORT_SYMBOL_KEYW", "ASM_PHRASE", "ATTRIBUTE_PHRASE", + "BRACE_PHRASE", "BRACKET_PHRASE", "EXPRESSION_PHRASE", "CHAR", "DOTS", + "IDENT", "INT", "REAL", "STRING", "TYPE", "OTHER", "FILENAME", "';'", + "'}'", "','", "'('", "'*'", "')'", "'='", "'{'", "':'", "$accept", + "declaration_seq", "declaration", "@1", "declaration1", "@2", + "simple_declaration", "init_declarator_list_opt", "init_declarator_list", + "init_declarator", "decl_specifier_seq_opt", "decl_specifier_seq", + "decl_specifier", "storage_class_specifier", "type_specifier", + "simple_type_specifier", "ptr_operator", "cvar_qualifier_seq_opt", + "cvar_qualifier_seq", "cvar_qualifier", "declarator", + "direct_declarator", "nested_declarator", "direct_nested_declarator", + "parameter_declaration_clause", "parameter_declaration_list_opt", + "parameter_declaration_list", "parameter_declaration", + "m_abstract_declarator", "direct_m_abstract_declarator", + "function_definition", "initializer_opt", "initializer", "class_body", + "member_specification_opt", "member_specification", "member_declaration", + "member_declarator_list_opt", "member_declarator_list", + "member_declarator", "member_bitfield_declarator", "attribute_opt", + "asm_definition", "asm_phrase_opt", "export_definition", 0 }; +#endif -static const short yypgoto[] = {-32768, - 152,-32768,-32768,-32768, 119,-32768,-32768, 94, 0, -55, - -35,-32768,-32768,-32768, -69,-32768,-32768, -56, -30,-32768, - -76,-32768, -122,-32768,-32768, 29, -62,-32768,-32768,-32768, --32768, -17,-32768,-32768, 105,-32768,-32768, 52, 86, 83, --32768,-32768,-32768 +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short int yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 59, 125, 44, 40, 42, 41, 61, + 123, 58 }; +# endif +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 52, 53, 53, 55, 54, 57, 56, 56, 56, + 56, 56, 56, 56, 58, 59, 59, 60, 60, 61, + 62, 62, 63, 63, 64, 64, 65, 65, 65, 65, + 65, 66, 66, 66, 66, 66, 66, 66, 66, 66, + 66, 66, 66, 66, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 68, 69, 69, 70, 70, + 71, 71, 71, 71, 72, 72, 73, 73, 73, 73, + 73, 73, 74, 74, 75, 75, 75, 75, 75, 75, + 75, 76, 76, 76, 77, 77, 78, 78, 79, 80, + 80, 81, 81, 81, 81, 81, 81, 81, 81, 82, + 83, 83, 84, 85, 85, 86, 86, 87, 87, 88, + 88, 89, 89, 90, 90, 91, 91, 91, 92, 93, + 93, 94, 95, 95, 96 +}; -#define YYLAST 533 - - -static const short yytable[] = { 78, - 67, 99, 35, 84, 65, 125, 54, 49, 155, 152, - 53, 80, 47, 88, 171, 89, 9, 48, 91, 55, - 127, 50, 129, 56, 50, 18, 114, 99, 81, 99, - 57, 69, 92, 87, 27, 77, 119, 168, 31, -89, - 126, 50, 67, 140, 96, 79, 58, 156, 131, 143, - 97, 76, 60, 142, -89, 60, 59, 68, 60, 95, - 85, 159, 132, 96, 99, 45, 46, 93, 94, 97, - 86, 60, 143, 143, 98, 160, 119, 126, 140, 157, - 158, 96, 156, 67, 58, 111, 112, 97, 142, 60, - 60, 106, 119, 113, 59, 116, 60, 128, 133, 134, - 98, 70, 93, 88, 119, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 135, 24, 25, 26, 27, 28, 139, 136, - 31, 146, 147, 148, 149, 154, -19, 150, 163, 164, - 32, 165, 166, -19, -103, 169, -19, 172, -19, 107, - 170, -19, 4, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 75, 24, 25, 26, 27, 28, 162, 108, 31, 115, - 124, 0, 130, 0, -19, 153, 0, 0, 32, 0, - 0, -19, -104, 0, -19, 0, -19, 5, 0, -19, - 0, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 0, 0, 0, - 0, 0, -19, 0, 0, 0, 32, 0, 0, -19, - 0, 118, -19, 0, -19, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 0, 24, 25, 26, 27, 28, 0, 0, - 31, 0, 0, 0, 0, -82, 0, 0, 0, 0, - 32, 0, 0, 0, 151, 0, 0, -82, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 0, 24, 25, 26, 27, - 28, 0, 0, 31, 0, 0, 0, 0, -82, 0, - 0, 0, 0, 32, 0, 0, 0, 167, 0, 0, - -82, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 0, 24, - 25, 26, 27, 28, 0, 0, 31, 0, 0, 0, - 0, -82, 0, 0, 0, 0, 32, 0, 0, 0, - 0, 0, 0, -82, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 0, 24, 25, 26, 27, 28, 0, 0, 31, - 0, 0, 0, 0, 0, 140, 0, 0, 0, 141, - 0, 0, 0, 0, 0, 142, 0, 60, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 0, 24, 25, 26, 27, - 28, 0, 0, 31, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, - 110, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 0, 24, - 25, 26, 27, 28, 0, 0, 31, 0, 0, 0, - 0, 161, 0, 0, 0, 0, 32, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 0, 24, 25, 26, 27, 28, - 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 32 +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 2, 0, 2, 0, 3, 1, 1, + 1, 1, 2, 2, 3, 0, 1, 1, 3, 4, + 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 5, 4, 2, 2, 2, 3, 3, + 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, + 1, 1, 1, 1, 2, 1, 1, 4, 4, 2, + 3, 3, 2, 1, 1, 1, 4, 4, 2, 3, + 3, 2, 1, 3, 0, 1, 1, 3, 2, 2, + 1, 0, 1, 1, 4, 4, 2, 3, 3, 3, + 0, 1, 2, 3, 3, 0, 1, 1, 2, 3, + 2, 0, 1, 1, 3, 2, 2, 1, 2, 0, + 1, 2, 0, 1, 5 }; -static const short yycheck[] = { 55, - 36, 71, 3, 60, 35, 1, 24, 36, 1, 132, - 36, 1, 31, 29, 0, 31, 8, 36, 32, 46, - 97, 50, 99, 46, 50, 17, 83, 97, 59, 99, - 43, 49, 46, 64, 26, 53, 92, 160, 30, 32, - 36, 50, 78, 36, 40, 36, 36, 40, 32, 119, - 46, 52, 48, 46, 47, 48, 46, 31, 48, 36, - 43, 32, 46, 40, 134, 43, 44, 43, 44, 46, - 45, 48, 142, 143, 51, 46, 132, 36, 36, 142, - 143, 40, 40, 119, 36, 47, 47, 46, 46, 48, - 48, 44, 148, 47, 46, 30, 48, 33, 43, 45, - 51, 1, 43, 29, 160, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 43, 23, 24, 25, 26, 27, 47, 49, - 30, 47, 35, 45, 47, 33, 36, 47, 47, 47, - 40, 47, 47, 43, 44, 47, 46, 0, 48, 1, - 47, 51, 1, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 52, 23, 24, 25, 26, 27, 148, 73, 30, 86, - 95, -1, 100, -1, 36, 134, -1, -1, 40, -1, - -1, 43, 44, -1, 46, -1, 48, 1, -1, 51, - -1, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, -1, -1, -1, - -1, -1, 36, -1, -1, -1, 40, -1, -1, 43, - -1, 1, 46, -1, 48, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, -1, 23, 24, 25, 26, 27, -1, -1, - 30, -1, -1, -1, -1, 35, -1, -1, -1, -1, - 40, -1, -1, -1, 1, -1, -1, 47, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, -1, 23, 24, 25, 26, - 27, -1, -1, 30, -1, -1, -1, -1, 35, -1, - -1, -1, -1, 40, -1, -1, -1, 1, -1, -1, - 47, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, -1, 23, - 24, 25, 26, 27, -1, -1, 30, -1, -1, -1, - -1, 35, -1, -1, -1, -1, 40, -1, -1, -1, - -1, -1, -1, 47, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, -1, 23, 24, 25, 26, 27, -1, -1, 30, - -1, -1, -1, -1, -1, 36, -1, -1, -1, 40, - -1, -1, -1, -1, -1, 46, -1, 48, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, -1, 23, 24, 25, 26, - 27, -1, -1, 30, -1, -1, -1, -1, -1, -1, - -1, -1, -1, 40, -1, -1, -1, -1, -1, -1, - 47, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, -1, 23, - 24, 25, 26, 27, -1, -1, 30, -1, -1, -1, - -1, 35, -1, -1, -1, -1, 40, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, -1, 23, 24, 25, 26, 27, - -1, -1, 30, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 40 +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 4, 4, 2, 0, 1, 3, 0, 26, 53, 44, + 60, 51, 0, 29, 50, 30, 46, 47, 27, 63, + 45, 48, 28, 0, 6, 0, 49, 52, 61, 0, + 0, 0, 62, 54, 5, 8, 15, 21, 22, 24, + 25, 31, 32, 9, 10, 11, 12, 13, 41, 37, + 35, 0, 42, 20, 36, 43, 0, 0, 121, 66, + 0, 56, 0, 16, 17, 0, 122, 65, 23, 40, + 38, 0, 111, 0, 0, 107, 7, 15, 39, 0, + 0, 0, 0, 55, 57, 58, 14, 0, 64, 123, + 99, 119, 69, 0, 110, 104, 74, 75, 0, 0, + 0, 119, 73, 0, 112, 113, 117, 103, 0, 108, + 122, 0, 34, 0, 71, 70, 59, 18, 120, 100, + 0, 91, 0, 82, 85, 86, 116, 0, 74, 0, + 118, 72, 115, 78, 0, 109, 0, 33, 124, 0, + 19, 101, 68, 92, 54, 0, 91, 88, 90, 67, + 81, 0, 80, 79, 0, 0, 114, 102, 0, 93, + 0, 89, 96, 0, 83, 87, 77, 76, 98, 97, + 0, 0, 95, 94 }; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/lib/bison.simple" -/* This file comes from bison-1.28. */ -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. +/* YYDEFGOTO[NTERM-NUM]. */ +static const short int yydefgoto[] = +{ + -1, 1, 2, 3, 34, 53, 35, 62, 63, 64, + 72, 37, 38, 39, 40, 41, 65, 83, 84, 42, + 110, 67, 101, 102, 122, 123, 124, 125, 147, 148, + 43, 140, 141, 52, 73, 74, 75, 103, 104, 105, + 106, 119, 44, 91, 45 +}; - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -128 +static const short int yypact[] = +{ + -128, 13, -128, 329, -128, -128, 36, -128, -128, -128, + -128, -128, -16, -128, -128, -128, -128, -128, -128, -128, + -128, -128, -128, -25, -128, -24, -128, -128, -128, -29, + -4, -22, -128, -128, -128, -128, -28, 495, -128, -128, + -128, -128, -128, -128, -128, -128, -128, -128, -128, 16, + -23, 103, -128, 495, -23, -128, 495, 35, -128, -128, + 3, 15, 9, 17, -128, -28, -15, -8, -128, -128, + -128, 47, 23, 44, 150, -128, -128, -28, -128, 372, + 33, 48, 49, -128, 15, -128, -128, -28, -128, -128, + -128, 64, -128, 197, -128, -128, 50, -128, 21, 65, + 37, 64, 14, 56, 55, -128, -128, -128, 59, -128, + 74, 57, -128, 63, -128, -128, -128, -128, -128, 76, + 83, 416, 84, 99, 90, -128, -128, 88, -128, 89, + -128, -128, -128, -128, 241, -128, 23, -128, -128, 105, + -128, -128, -128, -128, -128, 8, 46, -128, 26, -128, + -128, 459, -128, -128, 92, 93, -128, -128, 94, -128, + 96, -128, -128, 285, -128, -128, -128, -128, -128, -128, + 97, 100, -128, -128 +}; - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +/* YYPGOTO[NTERM-NUM]. */ +static const short int yypgoto[] = +{ + -128, -128, 151, -128, -128, -128, 119, -128, -128, 66, + 0, -56, -36, -128, -128, -128, -70, -128, -128, -51, + -31, -128, -11, -128, -127, -128, -128, 27, -81, -128, + -128, -128, -128, -19, -128, -128, 107, -128, -128, 43, + 86, 82, -128, -128, -128 +}; - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -107 +static const short int yytable[] = +{ + 79, 68, 100, 36, 81, 66, 55, 155, 59, 158, + 85, 50, 54, 4, 89, 48, 90, 56, 60, 61, + 49, 58, 127, 10, 92, 51, 51, 51, 100, 82, + 100, 70, 19, 116, 88, 78, 171, 121, 93, 59, + -91, 28, 57, 68, 143, 32, 133, 69, 159, 60, + 61, 146, 86, 77, 145, 61, -91, 128, 162, 96, + 134, 97, 87, 97, 160, 161, 100, 98, 61, 98, + 61, 80, 163, 128, 99, 146, 146, 97, 121, 46, + 47, 113, 143, 98, 61, 68, 159, 129, 107, 131, + 94, 95, 145, 61, 118, 121, 114, 115, 130, 135, + 136, 99, 94, 89, 71, 137, 138, 121, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 139, 25, 26, 27, 28, + 29, 142, 149, 32, 150, 151, 152, 153, 157, -20, + 166, 167, 168, 33, 169, 172, -20, -105, 173, -20, + -20, 108, 5, 117, -20, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 76, 25, 26, 27, 28, 29, 165, 156, + 32, 109, 126, 132, 0, 0, -20, 0, 0, 0, + 33, 0, 0, -20, -106, 0, -20, -20, 120, 0, + 0, -20, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, + 25, 26, 27, 28, 29, 0, 0, 32, 0, 0, + 0, 0, -84, 0, 0, 0, 0, 33, 0, 0, + 0, 0, 154, 0, 0, -84, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 0, 25, 26, 27, 28, 29, 0, + 0, 32, 0, 0, 0, 0, -84, 0, 0, 0, + 0, 33, 0, 0, 0, 0, 170, 0, 0, -84, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 0, 25, 26, + 27, 28, 29, 0, 0, 32, 0, 0, 0, 0, + -84, 0, 0, 0, 0, 33, 0, 0, 0, 0, + 6, 0, 0, -84, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 0, 0, 0, 0, 0, -20, 0, 0, 0, 33, + 0, 0, -20, 0, 0, -20, -20, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 0, 25, 26, 27, 28, 29, + 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 33, 0, 0, 0, 0, 0, 0, 111, + 112, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 0, 25, + 26, 27, 28, 29, 0, 0, 32, 0, 0, 0, + 0, 0, 143, 0, 0, 0, 144, 0, 0, 0, + 0, 0, 145, 61, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 0, 25, 26, 27, 28, 29, 0, 0, 32, + 0, 0, 0, 0, 164, 0, 0, 0, 0, 33, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 0, 25, 26, + 27, 28, 29, 0, 0, 32, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 33 +}; -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ +static const short int yycheck[] = +{ + 56, 37, 72, 3, 1, 36, 25, 134, 36, 1, + 61, 36, 36, 0, 29, 31, 31, 46, 46, 47, + 36, 43, 1, 8, 32, 50, 50, 50, 98, 60, + 100, 50, 17, 84, 65, 54, 163, 93, 46, 36, + 32, 26, 46, 79, 36, 30, 32, 31, 40, 46, + 47, 121, 43, 53, 46, 47, 48, 36, 32, 36, + 46, 40, 45, 40, 145, 146, 136, 46, 47, 46, + 47, 36, 46, 36, 51, 145, 146, 40, 134, 43, + 44, 48, 36, 46, 47, 121, 40, 98, 44, 100, + 43, 44, 46, 47, 30, 151, 48, 48, 33, 43, + 45, 51, 43, 29, 1, 48, 43, 163, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 49, 23, 24, 25, 26, + 27, 48, 48, 30, 35, 45, 48, 48, 33, 36, + 48, 48, 48, 40, 48, 48, 43, 44, 48, 46, + 47, 1, 1, 87, 51, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 53, 23, 24, 25, 26, 27, 151, 136, + 30, 74, 96, 101, -1, -1, 36, -1, -1, -1, + 40, -1, -1, 43, 44, -1, 46, 47, 1, -1, + -1, 51, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, + 23, 24, 25, 26, 27, -1, -1, 30, -1, -1, + -1, -1, 35, -1, -1, -1, -1, 40, -1, -1, + -1, -1, 1, -1, -1, 48, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, -1, 23, 24, 25, 26, 27, -1, + -1, 30, -1, -1, -1, -1, 35, -1, -1, -1, + -1, 40, -1, -1, -1, -1, 1, -1, -1, 48, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, -1, 23, 24, + 25, 26, 27, -1, -1, 30, -1, -1, -1, -1, + 35, -1, -1, -1, -1, 40, -1, -1, -1, -1, + 1, -1, -1, 48, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + -1, -1, -1, -1, -1, 36, -1, -1, -1, 40, + -1, -1, 43, -1, -1, 46, 47, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, -1, 23, 24, 25, 26, 27, + -1, -1, 30, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 40, -1, -1, -1, -1, -1, -1, 47, + 48, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, -1, 23, + 24, 25, 26, 27, -1, -1, 30, -1, -1, -1, + -1, -1, 36, -1, -1, -1, 40, -1, -1, -1, + -1, -1, 46, 47, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, -1, 23, 24, 25, 26, 27, -1, -1, 30, + -1, -1, -1, -1, 35, -1, -1, -1, -1, 40, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, -1, 23, 24, + 25, 26, 27, -1, -1, 30, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 40 +}; -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 53, 54, 55, 0, 54, 1, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 40, 56, 58, 62, 63, 64, 65, + 66, 67, 71, 82, 94, 96, 43, 44, 31, 36, + 36, 50, 85, 57, 36, 85, 46, 46, 43, 36, + 46, 47, 59, 60, 61, 68, 72, 73, 64, 31, + 85, 1, 62, 86, 87, 88, 58, 62, 85, 63, + 36, 1, 72, 69, 70, 71, 43, 45, 72, 29, + 31, 95, 32, 46, 43, 44, 36, 40, 46, 51, + 68, 74, 75, 89, 90, 91, 92, 44, 1, 88, + 72, 47, 48, 48, 48, 48, 71, 61, 30, 93, + 1, 63, 76, 77, 78, 79, 92, 1, 36, 74, + 33, 74, 93, 32, 46, 43, 45, 48, 43, 49, + 83, 84, 48, 36, 40, 46, 68, 80, 81, 48, + 35, 45, 48, 48, 1, 76, 91, 33, 1, 40, + 80, 80, 32, 46, 35, 79, 48, 48, 48, 48, + 1, 76, 48, 48 +}; -#ifndef YYSTACK_USE_ALLOCA -#ifdef alloca -#define YYSTACK_USE_ALLOCA -#else /* alloca not defined */ -#ifdef __GNUC__ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) -#define YYSTACK_USE_ALLOCA -#include <alloca.h> -#else /* not sparc */ -/* We think this test detects Watcom and Microsoft C. */ -/* This used to test MSDOS, but that is a bad idea - since that symbol is in the user namespace. */ -#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) -#if 0 /* No need for malloc.h, which pollutes the namespace; - instead, just don't use alloca. */ -#include <malloc.h> +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ #endif -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -/* I don't know what this was needed for, but it pollutes the namespace. - So I turned it off. rms, 2 May 1997. */ -/* #include <malloc.h> */ - #pragma alloca -#define YYSTACK_USE_ALLOCA -#else /* not MSDOS, or __TURBOC__, or _AIX */ -#if 0 -#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, - and on HPUX 10. Eventually we can turn this on. */ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#endif /* __hpux */ +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t #endif -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc */ -#endif /* not GNU C */ -#endif /* alloca not defined */ -#endif /* YYSTACK_USE_ALLOCA not defined */ - -#ifdef YYSTACK_USE_ALLOCA -#define YYSTACK_ALLOC alloca -#else -#define YYSTACK_ALLOC malloc +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int #endif - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 +#define YYEMPTY (-2) #define YYEOF 0 + #define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ + #define YYFAIL goto yyerrlab + #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ + +#define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ while (0) + #define YYTERROR 1 #define YYERRCODE 256 -#ifndef YYPURE -#define YYLEX yylex() + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (N) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (0) #endif -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif #endif -#else /* not YYLSP_NEEDED */ + + +/* YYLEX -- calling `yylex' with the right arguments. */ + #ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) +# define YYLEX yylex (YYLEX_PARAM) #else -#define YYLEX yylex(&yylval) +# define YYLEX yylex () #endif -#endif /* not YYLSP_NEEDED */ + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short int *bottom, short int *top) +#else +static void +yy_stack_print (bottom, top) + short int *bottom; + short int *top; #endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} -/* If nonreentrant, generate the variables here */ +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) -#ifndef YYPURE -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; #endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ -/* YYINITDEPTH indicates the initial size of the parser's stacks */ +/* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH -#define YYINITDEPTH 200 +# define YYINITDEPTH 200 #endif -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 +# define YYMAXDEPTH 10000 #endif + -/* Define __yy_memcpy. Note that the size argument - should be passed with type unsigned int, because that is what the non-GCC - definitions require. With GCC, __builtin_memcpy takes an arg - of type size_t, but it can handle unsigned int. */ - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - unsigned int count; + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif { - register char *f = from; - register char *t = to; - register int i = count; + register char *yyd = yydest; + register const char *yys = yysrc; - while (i-- > 0) - *t++ = *f++; + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; } +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ -#else /* __cplusplus */ + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ +#if defined (__STDC__) || defined (__cplusplus) static void -__yy_memcpy (char *to, char *from, unsigned int count) +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif { - register char *t = to; - register char *f = from; - register int i = count; + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; - while (i-- > 0) - *t++ = *f++; + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); } +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; #endif -#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} -#line 217 "/usr/lib/bison.simple" -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ +/* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -#ifdef YYPARSE_PARAM -int yyparse (void *); -#else +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) int yyparse (void); +#else +int yyparse (); #endif -#endif +#endif /* ! YYPARSE_PARAM */ + + + +/* The look-ahead symbol. */ +int yychar; +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL +yyparse () + +#endif +#endif { + register int yystate; register int yyn; - register short *yyssp; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short int yyssa[YYINITDEPTH]; + short int *yyss = yyssa; + register short int *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else #define YYPOPSTACK (yyvsp--, yyssp--) -#endif - int yystacksize = YYINITDEPTH; - int yyfree_stacks = 0; + YYSIZE_T yystacksize = YYINITDEPTH; -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ int yylen; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; @@ -741,833 +1175,872 @@ yyparse(YYPARSE_PARAM_ARG) so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss - 1; + yyssp = yyss; yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - *++yyssp = yystate; + yyvsp[0] = yylval; - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif + goto yysetstate; +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; + YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short int *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } #else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 2; - } + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) + if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; -#ifndef YYSTACK_USE_ALLOCA - yyfree_stacks = 1; -#endif - yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, - size * (unsigned int) sizeof (*yyssp)); - yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, - size * (unsigned int) sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, - size * (unsigned int) sizeof (*yylsp)); -#endif + + { + short int *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif #endif /* no yyoverflow */ - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - if (yyssp >= yyss + yystacksize - 1) + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) YYABORT; } -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; - yybackup: + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: /* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ +/* Read a look-ahead token if we need one and don't already have one. */ /* yyresume: */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yyn == YYFLAG) + if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ + /* Not known => get a look-ahead token if don't already have one. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif + YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ + if (yychar <= YYEOF) { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); } else { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) + if (yyn <= 0) { - if (yyn == YYFLAG) + if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } - else if (yyn == 0) - goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; yystate = yyn; goto yynewstate; -/* Do the default action for the current state. */ -yydefault: +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; + goto yyreduce; -/* Do a reduction. yyn is the number of a rule to reduce with. */ + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ yyreduce: + /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; - switch (yyn) { -case 3: + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 4: #line 107 "scripts/genksyms/parse.y" -{ is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ; - break;} -case 4: + { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ;} + break; + + case 5: #line 109 "scripts/genksyms/parse.y" -{ free_list(*yyvsp[0], NULL); *yyvsp[0] = NULL; ; - break;} -case 5: + { free_list(*(yyvsp[0]), NULL); *(yyvsp[0]) = NULL; ;} + break; + + case 6: #line 113 "scripts/genksyms/parse.y" -{ is_typedef = 1; ; - break;} -case 6: + { is_typedef = 1; ;} + break; + + case 7: #line 114 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 11: + { (yyval) = (yyvsp[0]); ;} + break; + + case 12: #line 119 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 12: + { (yyval) = (yyvsp[0]); ;} + break; + + case 13: #line 120 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 13: + { (yyval) = (yyvsp[0]); ;} + break; + + case 14: #line 125 "scripts/genksyms/parse.y" -{ if (current_name) { - struct string_list *decl = (*yyvsp[0])->next; - (*yyvsp[0])->next = NULL; + { if (current_name) { + struct string_list *decl = (*(yyvsp[0]))->next; + (*(yyvsp[0]))->next = NULL; add_symbol(current_name, is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); current_name = NULL; } - yyval = yyvsp[0]; - ; - break;} -case 14: + (yyval) = (yyvsp[0]); + ;} + break; + + case 15: #line 138 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 16: + { (yyval) = NULL; ;} + break; + + case 17: #line 144 "scripts/genksyms/parse.y" -{ struct string_list *decl = *yyvsp[0]; - *yyvsp[0] = NULL; + { struct string_list *decl = *(yyvsp[0]); + *(yyvsp[0]) = NULL; add_symbol(current_name, is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); current_name = NULL; - yyval = yyvsp[0]; - ; - break;} -case 17: + (yyval) = (yyvsp[0]); + ;} + break; + + case 18: #line 152 "scripts/genksyms/parse.y" -{ struct string_list *decl = *yyvsp[0]; - *yyvsp[0] = NULL; - free_list(*yyvsp[-1], NULL); - *yyvsp[-1] = decl_spec; + { struct string_list *decl = *(yyvsp[0]); + *(yyvsp[0]) = NULL; + free_list(*(yyvsp[-1]), NULL); + *(yyvsp[-1]) = decl_spec; add_symbol(current_name, is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); current_name = NULL; - yyval = yyvsp[0]; - ; - break;} -case 18: + (yyval) = (yyvsp[0]); + ;} + break; + + case 19: #line 165 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1] ? yyvsp[-1] : yyvsp[-2] ? yyvsp[-2] : yyvsp[-3]; ; - break;} -case 19: + { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]) ? (yyvsp[-1]) : (yyvsp[-2]) ? (yyvsp[-2]) : (yyvsp[-3]); ;} + break; + + case 20: #line 170 "scripts/genksyms/parse.y" -{ decl_spec = NULL; ; - break;} -case 21: + { decl_spec = NULL; ;} + break; + + case 22: #line 175 "scripts/genksyms/parse.y" -{ decl_spec = *yyvsp[0]; ; - break;} -case 22: + { decl_spec = *(yyvsp[0]); ;} + break; + + case 23: #line 176 "scripts/genksyms/parse.y" -{ decl_spec = *yyvsp[0]; ; - break;} -case 23: + { decl_spec = *(yyvsp[0]); ;} + break; + + case 24: #line 181 "scripts/genksyms/parse.y" -{ /* Version 2 checksumming ignores storage class, as that + { /* Version 2 checksumming ignores storage class, as that is really irrelevant to the linkage. */ - remove_node(yyvsp[0]); - yyval = yyvsp[0]; - ; - break;} -case 28: + remove_node((yyvsp[0])); + (yyval) = (yyvsp[0]); + ;} + break; + + case 29: #line 193 "scripts/genksyms/parse.y" -{ is_extern = 1; yyval = yyvsp[0]; ; - break;} -case 29: + { is_extern = 1; (yyval) = (yyvsp[0]); ;} + break; + + case 30: #line 194 "scripts/genksyms/parse.y" -{ is_extern = 0; yyval = yyvsp[0]; ; - break;} -case 33: -#line 205 "scripts/genksyms/parse.y" -{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_STRUCT; yyval = yyvsp[0]; ; - break;} -case 34: -#line 207 "scripts/genksyms/parse.y" -{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_UNION; yyval = yyvsp[0]; ; - break;} -case 35: -#line 209 "scripts/genksyms/parse.y" -{ remove_node(yyvsp[-1]); (*yyvsp[0])->tag = SYM_ENUM; yyval = yyvsp[0]; ; - break;} -case 36: -#line 213 "scripts/genksyms/parse.y" -{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r; + { is_extern = 0; (yyval) = (yyvsp[0]); ;} + break; + + case 35: +#line 206 "scripts/genksyms/parse.y" + { remove_node((yyvsp[-1])); (*(yyvsp[0]))->tag = SYM_STRUCT; (yyval) = (yyvsp[0]); ;} + break; + + case 36: +#line 208 "scripts/genksyms/parse.y" + { remove_node((yyvsp[-1])); (*(yyvsp[0]))->tag = SYM_UNION; (yyval) = (yyvsp[0]); ;} + break; + + case 37: +#line 210 "scripts/genksyms/parse.y" + { remove_node((yyvsp[-1])); (*(yyvsp[0]))->tag = SYM_ENUM; (yyval) = (yyvsp[0]); ;} + break; + + case 38: +#line 214 "scripts/genksyms/parse.y" + { struct string_list *s = *(yyvsp[0]), *i = *(yyvsp[-1]), *r; r = copy_node(i); r->tag = SYM_STRUCT; - r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL; + r->next = (*(yyvsp[-2]))->next; *(yyvsp[0]) = r; (*(yyvsp[-2]))->next = NULL; add_symbol(i->string, SYM_STRUCT, s, is_extern); - yyval = yyvsp[0]; - ; - break;} -case 37: -#line 220 "scripts/genksyms/parse.y" -{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r; + (yyval) = (yyvsp[0]); + ;} + break; + + case 39: +#line 221 "scripts/genksyms/parse.y" + { struct string_list *s = *(yyvsp[0]), *i = *(yyvsp[-1]), *r; r = copy_node(i); r->tag = SYM_UNION; - r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL; + r->next = (*(yyvsp[-2]))->next; *(yyvsp[0]) = r; (*(yyvsp[-2]))->next = NULL; add_symbol(i->string, SYM_UNION, s, is_extern); - yyval = yyvsp[0]; - ; - break;} -case 38: -#line 227 "scripts/genksyms/parse.y" -{ struct string_list *s = *yyvsp[0], *i = *yyvsp[-1], *r; + (yyval) = (yyvsp[0]); + ;} + break; + + case 40: +#line 228 "scripts/genksyms/parse.y" + { struct string_list *s = *(yyvsp[0]), *i = *(yyvsp[-1]), *r; r = copy_node(i); r->tag = SYM_ENUM; - r->next = (*yyvsp[-2])->next; *yyvsp[0] = r; (*yyvsp[-2])->next = NULL; + r->next = (*(yyvsp[-2]))->next; *(yyvsp[0]) = r; (*(yyvsp[-2]))->next = NULL; add_symbol(i->string, SYM_ENUM, s, is_extern); - yyval = yyvsp[0]; - ; - break;} -case 39: -#line 235 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 40: + (yyval) = (yyvsp[0]); + ;} + break; + + case 41: #line 236 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 41: + { (yyval) = (yyvsp[0]); ;} + break; + + case 42: #line 237 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 52: -#line 251 "scripts/genksyms/parse.y" -{ (*yyvsp[0])->tag = SYM_TYPEDEF; yyval = yyvsp[0]; ; - break;} -case 53: -#line 256 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ; - break;} -case 54: -#line 260 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 57: -#line 266 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 61: -#line 272 "scripts/genksyms/parse.y" -{ /* restrict has no effect in prototypes so ignore it */ - remove_node(yyvsp[0]); - yyval = yyvsp[0]; - ; - break;} -case 62: -#line 279 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 64: -#line 285 "scripts/genksyms/parse.y" -{ if (current_name != NULL) { + { (yyval) = (yyvsp[0]); ;} + break; + + case 43: +#line 238 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 54: +#line 252 "scripts/genksyms/parse.y" + { (*(yyvsp[0]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[0]); ;} + break; + + case 55: +#line 257 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]); ;} + break; + + case 56: +#line 261 "scripts/genksyms/parse.y" + { (yyval) = NULL; ;} + break; + + case 59: +#line 267 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 63: +#line 273 "scripts/genksyms/parse.y" + { /* restrict has no effect in prototypes so ignore it */ + remove_node((yyvsp[0])); + (yyval) = (yyvsp[0]); + ;} + break; + + case 64: +#line 280 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 66: +#line 286 "scripts/genksyms/parse.y" + { if (current_name != NULL) { error_with_pos("unexpected second declaration name"); YYERROR; } else { - current_name = (*yyvsp[0])->string; - yyval = yyvsp[0]; + current_name = (*(yyvsp[0]))->string; + (yyval) = (yyvsp[0]); } - ; - break;} -case 65: -#line 294 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 66: -#line 296 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 67: -#line 298 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 68: -#line 300 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 69: -#line 302 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 70: -#line 308 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 74: -#line 316 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 75: -#line 318 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 76: -#line 320 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 77: -#line 322 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 78: -#line 324 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 79: -#line 328 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 81: -#line 330 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 82: -#line 334 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 85: -#line 341 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 86: -#line 346 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ; - break;} -case 87: -#line 351 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ; - break;} -case 89: -#line 356 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 90: -#line 358 "scripts/genksyms/parse.y" -{ /* For version 2 checksums, we don't want to remember + ;} + break; + + case 67: +#line 295 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 68: +#line 297 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 69: +#line 299 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 70: +#line 301 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 71: +#line 303 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 72: +#line 309 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 76: +#line 317 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 77: +#line 319 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 78: +#line 321 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 79: +#line 323 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 80: +#line 325 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 81: +#line 329 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 83: +#line 331 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 84: +#line 335 "scripts/genksyms/parse.y" + { (yyval) = NULL; ;} + break; + + case 87: +#line 342 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 88: +#line 347 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]); ;} + break; + + case 89: +#line 352 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]); ;} + break; + + case 91: +#line 357 "scripts/genksyms/parse.y" + { (yyval) = NULL; ;} + break; + + case 92: +#line 359 "scripts/genksyms/parse.y" + { /* For version 2 checksums, we don't want to remember private parameter names. */ - remove_node(yyvsp[0]); - yyval = yyvsp[0]; - ; - break;} -case 91: -#line 366 "scripts/genksyms/parse.y" -{ remove_node(yyvsp[0]); - yyval = yyvsp[0]; - ; - break;} -case 92: -#line 370 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 93: -#line 372 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 94: -#line 374 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 95: -#line 376 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 96: -#line 378 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 97: -#line 383 "scripts/genksyms/parse.y" -{ struct string_list *decl = *yyvsp[-1]; - *yyvsp[-1] = NULL; + remove_node((yyvsp[0])); + (yyval) = (yyvsp[0]); + ;} + break; + + case 93: +#line 367 "scripts/genksyms/parse.y" + { remove_node((yyvsp[0])); + (yyval) = (yyvsp[0]); + ;} + break; + + case 94: +#line 371 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 95: +#line 373 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 96: +#line 375 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 97: +#line 377 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 98: +#line 379 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 99: +#line 384 "scripts/genksyms/parse.y" + { struct string_list *decl = *(yyvsp[-1]); + *(yyvsp[-1]) = NULL; add_symbol(current_name, SYM_NORMAL, decl, is_extern); - yyval = yyvsp[0]; - ; - break;} -case 98: -#line 391 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 100: -#line 398 "scripts/genksyms/parse.y" -{ remove_list(yyvsp[0], &(*yyvsp[-1])->next); yyval = yyvsp[0]; ; - break;} -case 101: -#line 402 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 102: + (yyval) = (yyvsp[0]); + ;} + break; + + case 100: +#line 392 "scripts/genksyms/parse.y" + { (yyval) = NULL; ;} + break; + + case 102: +#line 399 "scripts/genksyms/parse.y" + { remove_list((yyvsp[0]), &(*(yyvsp[-1]))->next); (yyval) = (yyvsp[0]); ;} + break; + + case 103: #line 403 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 103: -#line 407 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 106: -#line 413 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 107: -#line 418 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 108: -#line 420 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 109: -#line 424 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 112: -#line 430 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 113: -#line 434 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0] ? yyvsp[0] : yyvsp[-1]; ; - break;} -case 114: + { (yyval) = (yyvsp[0]); ;} + break; + + case 104: +#line 404 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 105: +#line 408 "scripts/genksyms/parse.y" + { (yyval) = NULL; ;} + break; + + case 108: +#line 414 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 109: +#line 419 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 110: +#line 421 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 111: +#line 425 "scripts/genksyms/parse.y" + { (yyval) = NULL; ;} + break; + + case 114: +#line 431 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 115: #line 435 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 116: -#line 440 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 117: -#line 444 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 119: -#line 449 "scripts/genksyms/parse.y" -{ yyval = yyvsp[0]; ; - break;} -case 120: -#line 453 "scripts/genksyms/parse.y" -{ yyval = NULL; ; - break;} -case 122: -#line 459 "scripts/genksyms/parse.y" -{ export_symbol((*yyvsp[-2])->string); yyval = yyvsp[0]; ; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 543 "/usr/lib/bison.simple" + { (yyval) = (yyvsp[0]) ? (yyvsp[0]) : (yyvsp[-1]); ;} + break; + + case 116: +#line 436 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 118: +#line 441 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 119: +#line 445 "scripts/genksyms/parse.y" + { (yyval) = NULL; ;} + break; + + case 121: +#line 450 "scripts/genksyms/parse.y" + { (yyval) = (yyvsp[0]); ;} + break; + + case 122: +#line 454 "scripts/genksyms/parse.y" + { (yyval) = NULL; ;} + break; + + case 124: +#line 460 "scripts/genksyms/parse.y" + { export_symbol((*(yyvsp[-2]))->string); (yyval) = (yyvsp[0]); ;} + break; + + + } + +/* Line 1037 of yacc.c. */ +#line 1816 "scripts/genksyms/parse.c" yyvsp -= yylen; yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif + + YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ yyn = yyr1[yyn]; - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else - yystate = yydefgoto[yyn - YYNTBASE]; + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; -yyerrlab: /* here on detecting error */ - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) { ++yynerrs; - -#ifdef YYERROR_VERBOSE +#if YYERROR_VERBOSE yyn = yypact[yystate]; - if (yyn > YYFLAG && yyn < YYLAST) + if (YYPACT_NINF < yyn && yyn < YYLAST) { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) { - strcpy(msg, "parse error"); + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); - if (count < 5) + if (yycount < 5) { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; } } - yyerror(msg); - free(msg); + yyerror (yymsg); + YYSTACK_FREE (yymsg); } else - yyerror ("parse error; also virtual memory exceeded"); + yyerror ("syntax error; also virtual memory exhausted"); } else #endif /* YYERROR_VERBOSE */ - yyerror("parse error"); + yyerror ("syntax error"); } - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ + if (yyerrstatus == 3) { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + yydestruct ("Error: popping", + yystos[*yyssp], yyvsp); + } + } + else + { + yydestruct ("Error: discarding", yytoken, &yylval); + yychar = YYEMPTY; + } } - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; - goto yyerrhandle; -yyerrdefault: /* current state does not do anything special for the error token. */ +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; #endif -yyerrpop: /* pop the current state because it cannot handle the error token */ +yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + goto yyerrlab1; + - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ -#if YYDEBUG != 0 - if (yydebug) + for (;;) { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; + yydestruct ("Error: popping", yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); } - else if (yyn == 0) - goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; - yyacceptlab: - /* YYACCEPT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yydestruct ("Error: discarding lookahead", + yytoken, &yylval); + yychar = YYEMPTY; + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ #endif - } - return 0; - yyabortlab: - /* YYABORT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); #endif - } - return 1; + return yyresult; } -#line 463 "scripts/genksyms/parse.y" + + +#line 464 "scripts/genksyms/parse.y" static void @@ -1575,3 +2048,4 @@ yyerror(const char *e) { error_with_pos("%s", e); } + diff --git a/scripts/genksyms/parse.h_shipped b/scripts/genksyms/parse.h_shipped index d5b27e3..f3fb2bb 100644 --- a/scripts/genksyms/parse.h_shipped +++ b/scripts/genksyms/parse.h_shipped @@ -1,46 +1,128 @@ -#ifndef YYSTYPE -#define YYSTYPE int +/* A Bison parser, made by GNU Bison 2.0. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ASM_KEYW = 258, + ATTRIBUTE_KEYW = 259, + AUTO_KEYW = 260, + BOOL_KEYW = 261, + CHAR_KEYW = 262, + CONST_KEYW = 263, + DOUBLE_KEYW = 264, + ENUM_KEYW = 265, + EXTERN_KEYW = 266, + FLOAT_KEYW = 267, + INLINE_KEYW = 268, + INT_KEYW = 269, + LONG_KEYW = 270, + REGISTER_KEYW = 271, + RESTRICT_KEYW = 272, + SHORT_KEYW = 273, + SIGNED_KEYW = 274, + STATIC_KEYW = 275, + STRUCT_KEYW = 276, + TYPEDEF_KEYW = 277, + UNION_KEYW = 278, + UNSIGNED_KEYW = 279, + VOID_KEYW = 280, + VOLATILE_KEYW = 281, + TYPEOF_KEYW = 282, + EXPORT_SYMBOL_KEYW = 283, + ASM_PHRASE = 284, + ATTRIBUTE_PHRASE = 285, + BRACE_PHRASE = 286, + BRACKET_PHRASE = 287, + EXPRESSION_PHRASE = 288, + CHAR = 289, + DOTS = 290, + IDENT = 291, + INT = 292, + REAL = 293, + STRING = 294, + TYPE = 295, + OTHER = 296, + FILENAME = 297 + }; #endif -#define ASM_KEYW 257 -#define ATTRIBUTE_KEYW 258 -#define AUTO_KEYW 259 -#define BOOL_KEYW 260 -#define CHAR_KEYW 261 -#define CONST_KEYW 262 -#define DOUBLE_KEYW 263 -#define ENUM_KEYW 264 -#define EXTERN_KEYW 265 -#define FLOAT_KEYW 266 -#define INLINE_KEYW 267 -#define INT_KEYW 268 -#define LONG_KEYW 269 -#define REGISTER_KEYW 270 -#define RESTRICT_KEYW 271 -#define SHORT_KEYW 272 -#define SIGNED_KEYW 273 -#define STATIC_KEYW 274 -#define STRUCT_KEYW 275 -#define TYPEDEF_KEYW 276 -#define UNION_KEYW 277 -#define UNSIGNED_KEYW 278 -#define VOID_KEYW 279 -#define VOLATILE_KEYW 280 -#define TYPEOF_KEYW 281 -#define EXPORT_SYMBOL_KEYW 282 -#define ASM_PHRASE 283 -#define ATTRIBUTE_PHRASE 284 -#define BRACE_PHRASE 285 -#define BRACKET_PHRASE 286 -#define EXPRESSION_PHRASE 287 -#define CHAR 288 -#define DOTS 289 -#define IDENT 290 -#define INT 291 -#define REAL 292 -#define STRING 293 -#define TYPE 294 -#define OTHER 295 -#define FILENAME 296 +#define ASM_KEYW 258 +#define ATTRIBUTE_KEYW 259 +#define AUTO_KEYW 260 +#define BOOL_KEYW 261 +#define CHAR_KEYW 262 +#define CONST_KEYW 263 +#define DOUBLE_KEYW 264 +#define ENUM_KEYW 265 +#define EXTERN_KEYW 266 +#define FLOAT_KEYW 267 +#define INLINE_KEYW 268 +#define INT_KEYW 269 +#define LONG_KEYW 270 +#define REGISTER_KEYW 271 +#define RESTRICT_KEYW 272 +#define SHORT_KEYW 273 +#define SIGNED_KEYW 274 +#define STATIC_KEYW 275 +#define STRUCT_KEYW 276 +#define TYPEDEF_KEYW 277 +#define UNION_KEYW 278 +#define UNSIGNED_KEYW 279 +#define VOID_KEYW 280 +#define VOLATILE_KEYW 281 +#define TYPEOF_KEYW 282 +#define EXPORT_SYMBOL_KEYW 283 +#define ASM_PHRASE 284 +#define ATTRIBUTE_PHRASE 285 +#define BRACE_PHRASE 286 +#define BRACKET_PHRASE 287 +#define EXPRESSION_PHRASE 288 +#define CHAR 289 +#define DOTS 290 +#define IDENT 291 +#define INT 292 +#define REAL 293 +#define STRING 294 +#define TYPE 295 +#define OTHER 296 +#define FILENAME 297 + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + extern YYSTYPE yylval; + + + -- cgit v1.1 From 0d5416433190ee80a8146137dd84613bb9c7ae92 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg <sam@mars.ravnborg.org> Date: Mon, 26 Dec 2005 23:04:02 +0100 Subject: kbuild: remove EXPERIMENTAL tag from Module versioning Module versioning support has been stable for a loong time so let's get rid of the EXPERIMENTAL tag. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- init/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index ea097e0..11930fb 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -460,8 +460,8 @@ config OBSOLETE_MODPARM If unsure, say Y. config MODVERSIONS - bool "Module versioning support (EXPERIMENTAL)" - depends on MODULES && EXPERIMENTAL + bool "Module versioning support" + depends on MODULES help Usually, you have to use modules compiled with your kernel. Saying Y here makes it sometimes possible to use modules -- cgit v1.1 From 54e08a2392e99ba9e48ce1060e0b52a39118419c Mon Sep 17 00:00:00 2001 From: Samuel Thibault <samuel.thibault@ens-lyon.org> Date: Mon, 26 Dec 2005 02:47:18 +0100 Subject: kbuild: tags file generation fixup Here is a fixup for tags file generation, for proper tags of __releases/__acquires functions. Signed-off-by: samuel.thibault@ens-lyon.org Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ced0346..922c763 100644 --- a/Makefile +++ b/Makefile @@ -1236,9 +1236,10 @@ cscope: FORCE quiet_cmd_TAGS = MAKE $@ define cmd_TAGS rm -f $@; \ - ETAGSF=`etags --version | grep -i exuberant >/dev/null && \ - echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ - --extra=+f --c-kinds=+px"`; \ + ETAGSF=`etags --version | grep -i exuberant >/dev/null && \ + echo "-I __initdata,__exitdata,__acquires,__releases \ + -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px"`; \ $(all-sources) | xargs etags $$ETAGSF -a endef @@ -1249,9 +1250,10 @@ TAGS: FORCE quiet_cmd_tags = MAKE $@ define cmd_tags rm -f $@; \ - CTAGSF=`ctags --version | grep -i exuberant >/dev/null && \ - echo "-I __initdata,__exitdata,EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ - --extra=+f --c-kinds=+px"`; \ + CTAGSF=`ctags --version | grep -i exuberant >/dev/null && \ + echo "-I __initdata,__exitdata,__acquires,__releases \ + -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ + --extra=+f --c-kinds=+px"`; \ $(all-sources) | xargs ctags $$CTAGSF -a endef -- cgit v1.1 From 752625cff3eba81cbc886988d5b420064c033948 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg <sam@mars.ravnborg.org> Date: Mon, 26 Dec 2005 23:34:03 +0100 Subject: kbuild: always run 'make silentoldconfig' when tree is cleaned If the file .kconfig.d is missing then make sure to run 'make silentoldconfig', since we have no way to detect if a Kconfig file has been updated. -kconfig.d is created by kconfig and is removed as part of 'make clean' so the situation is likely to occur in reality. Jan Beulich <JBeulich@novell.com> reported this bug. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- Makefile | 10 ++++++---- scripts/kconfig/util.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 922c763..d3598ef 100644 --- a/Makefile +++ b/Makefile @@ -477,18 +477,20 @@ ifeq ($(dot-config),1) # Read in dependencies to all Kconfig* files, make sure to run # oldconfig if changes are detected. --include .config.cmd +-include .kconfig.d include .config # If .config needs to be updated, it will be done via the dependency # that autoconf has on .config. # To avoid any implicit rule to kick in, define an empty command -.config: ; +.config .kconfig.d: ; # If .config is newer than include/linux/autoconf.h, someone tinkered -# with it and forgot to run make oldconfig -include/linux/autoconf.h: .config +# with it and forgot to run make oldconfig. +# If kconfig.d is missing then we are probarly in a cleaned tree so +# we execute the config step to be sure to catch updated Kconfig files +include/linux/autoconf.h: .kconfig.d .config $(Q)mkdir -p include/linux $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig else diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 1fa4c0b..a711007 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -33,7 +33,7 @@ int file_write_dep(const char *name) FILE *out; if (!name) - name = ".config.cmd"; + name = ".kconfig.d"; out = fopen("..config.tmp", "w"); if (!out) return 1; -- cgit v1.1 From 6073aa643f52fd12b02f0532dc96287f4c3293b5 Mon Sep 17 00:00:00 2001 From: Jan-Benedict Glaw <jbglaw@lug-owl.de> Date: Sun, 1 Jan 2006 14:23:47 +0100 Subject: kbuild: tar-pkg with out-out-tree building Fix out-of-tree builds for the tar-pkg targets When I wrote the buildtar script, I didn't even think about out-of-tree builds because I didn't use these back then. This patch throughoutly uses ${objtree} instead of `pwd`. Also, the kernel version is no longer manually built. Instead, it will properly use $KERNELRELEASE . Installing modules is only done if CONFIG_MODULES is set. Signed-off-by: Jan-Benedict Glaw <jbglaw@lug-owl.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- scripts/package/Makefile | 2 +- scripts/package/buildtar | 31 +++++++++++++------------------ 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/scripts/package/Makefile b/scripts/package/Makefile index f3e7e8e..c201ef00 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -84,7 +84,7 @@ clean-dirs += $(objtree)/debian/ # --------------------------------------------------------------------------- .PHONY: tar%pkg tar%pkg: - $(MAKE) + $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ clean-dirs += $(objtree)/tar-install/ diff --git a/scripts/package/buildtar b/scripts/package/buildtar index d8fffe6..88b5281 100644 --- a/scripts/package/buildtar +++ b/scripts/package/buildtar @@ -1,9 +1,9 @@ #!/bin/sh # -# buildtar 0.0.3 +# buildtar 0.0.4 # -# (C) 2004-2005 by Jan-Benedict Glaw <jbglaw@lug-owl.de> +# (C) 2004-2006 by Jan-Benedict Glaw <jbglaw@lug-owl.de> # # This script is used to compile a tarball from the currently # prepared kernel. Based upon the builddeb script from @@ -15,9 +15,8 @@ set -e # # Some variables and settings used throughout the script # -version="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}${EXTRANAME}" tmpdir="${objtree}/tar-install" -tarball="${objtree}/linux-${version}.tar" +tarball="${objtree}/linux-${KERNELRELEASE}.tar" # @@ -53,21 +52,17 @@ mkdir -p -- "${tmpdir}/boot" # # Try to install modules # -if ! make INSTALL_MOD_PATH="${tmpdir}" modules_install; then - echo "" >&2 - echo "Ignoring error at module_install time, since that could be" >&2 - echo "a result of missing local modutils/module-init-tools," >&2 - echo "or you just didn't compile in module support at all..." >&2 - echo "" >&2 +if grep -q '^CONFIG_MODULES=y' "${objtree}/.config"; then + make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install fi # # Install basic kernel files # -cp -v -- System.map "${tmpdir}/boot/System.map-${version}" -cp -v -- .config "${tmpdir}/boot/config-${version}" -cp -v -- vmlinux "${tmpdir}/boot/vmlinux-${version}" +cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}" +cp -v -- "${objtree}/.config" "${tmpdir}/boot/config-${KERNELRELEASE}" +cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" # @@ -75,17 +70,17 @@ cp -v -- vmlinux "${tmpdir}/boot/vmlinux-${version}" # case "${ARCH}" in i386) - [ -f arch/i386/boot/bzImage ] && cp -v -- arch/i386/boot/bzImage "${tmpdir}/boot/vmlinuz-${version}" + [ -f "${objtree}/arch/i386/boot/bzImage" ] && cp -v -- "${objtree}/arch/i386/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" ;; alpha) - [ -f arch/alpha/boot/vmlinux.gz ] && cp -v -- arch/alpha/boot/vmlinux.gz "${tmpdir}/boot/vmlinuz-${version}" + [ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}" ;; vax) - [ -f vmlinux.SYS ] && cp -v -- vmlinux.SYS "${tmpdir}/boot/vmlinux-${version}.SYS" - [ -f vmlinux.dsk ] && cp -v -- vmlinux.dsk "${tmpdir}/boot/vmlinux-${version}.dsk" + [ -f "${objtree}/vmlinux.SYS" ] && cp -v -- "${objtree}/vmlinux.SYS" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.SYS" + [ -f "${objtree}/vmlinux.dsk" ] && cp -v -- "${objtree}/vmlinux.dsk" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.dsk" ;; *) - [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${version}" + [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}" echo "" >&2 echo '** ** ** WARNING ** ** **' >&2 echo "" >&2 -- cgit v1.1 From 42f122c8f7e7134c824907358a5df94cfa38946d Mon Sep 17 00:00:00 2001 From: Brian Gerst <bgerst@didntduck.org> Date: Tue, 27 Dec 2005 23:19:04 -0500 Subject: gitignore: asm-offsets.h Ignore asm-offsets.h for all arches. Signed-off-by: Brian Gerst <bgerst@didntduck.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- .gitignore | 1 + include/asm-mips/.gitignore | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 include/asm-mips/.gitignore diff --git a/.gitignore b/.gitignore index 5014bfa..a4b576e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ Module.symvers # Generated include files # include/asm +include/asm-*/asm-offsets.h include/config include/linux/autoconf.h include/linux/compile.h diff --git a/include/asm-mips/.gitignore b/include/asm-mips/.gitignore deleted file mode 100644 index 4ec57ad..0000000 --- a/include/asm-mips/.gitignore +++ /dev/null @@ -1 +0,0 @@ -asm_offsets.h -- cgit v1.1 From 02959a875caec8cabd36111046ad537251ef405f Mon Sep 17 00:00:00 2001 From: Brian Gerst <bgerst@didntduck.org> Date: Tue, 27 Dec 2005 23:39:51 -0500 Subject: gitignore: x86_64 files Add filters for x86_64 generated files. Signed-off-by: Brian Gerst <bgerst@didntduck.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- arch/x86_64/boot/.gitignore | 3 +++ arch/x86_64/boot/tools/.gitignore | 1 + arch/x86_64/ia32/.gitignore | 1 + 3 files changed, 5 insertions(+) create mode 100644 arch/x86_64/boot/.gitignore create mode 100644 arch/x86_64/boot/tools/.gitignore create mode 100644 arch/x86_64/ia32/.gitignore diff --git a/arch/x86_64/boot/.gitignore b/arch/x86_64/boot/.gitignore new file mode 100644 index 0000000..495f20c --- /dev/null +++ b/arch/x86_64/boot/.gitignore @@ -0,0 +1,3 @@ +bootsect +bzImage +setup diff --git a/arch/x86_64/boot/tools/.gitignore b/arch/x86_64/boot/tools/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/arch/x86_64/boot/tools/.gitignore @@ -0,0 +1 @@ +build diff --git a/arch/x86_64/ia32/.gitignore b/arch/x86_64/ia32/.gitignore new file mode 100644 index 0000000..48ab174 --- /dev/null +++ b/arch/x86_64/ia32/.gitignore @@ -0,0 +1 @@ +vsyscall*.so -- cgit v1.1 From 352dd1df32e672be4cff71132eb9c06a257872fe Mon Sep 17 00:00:00 2001 From: Brian Gerst <bgerst@didntduck.org> Date: Tue, 27 Dec 2005 23:43:31 -0500 Subject: gitignore: misc files Ignore all files generated from *_shipped files, plus a few others. Signed-off-by: Brian Gerst <bgerst@didntduck.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- drivers/char/.gitignore | 2 +- drivers/ieee1394/.gitignore | 1 + drivers/md/.gitignore | 4 ++++ drivers/net/wan/.gitignore | 1 + drivers/scsi/.gitignore | 3 +++ drivers/scsi/aic7xxx/.gitignore | 6 ++++++ scripts/genksyms/.gitignore | 4 ++++ scripts/kconfig/.gitignore | 1 + 8 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 drivers/ieee1394/.gitignore create mode 100644 drivers/md/.gitignore create mode 100644 drivers/net/wan/.gitignore create mode 100644 drivers/scsi/.gitignore create mode 100644 drivers/scsi/aic7xxx/.gitignore create mode 100644 scripts/genksyms/.gitignore diff --git a/drivers/char/.gitignore b/drivers/char/.gitignore index 2b6b1d7..73dfdce 100644 --- a/drivers/char/.gitignore +++ b/drivers/char/.gitignore @@ -1,3 +1,3 @@ consolemap_deftbl.c defkeymap.c - +qtronixmap.c diff --git a/drivers/ieee1394/.gitignore b/drivers/ieee1394/.gitignore new file mode 100644 index 0000000..33da10a --- /dev/null +++ b/drivers/ieee1394/.gitignore @@ -0,0 +1 @@ +oui.c diff --git a/drivers/md/.gitignore b/drivers/md/.gitignore new file mode 100644 index 0000000..a7afec6 --- /dev/null +++ b/drivers/md/.gitignore @@ -0,0 +1,4 @@ +mktables +raid6altivec*.c +raid6int*.c +raid6tables.c diff --git a/drivers/net/wan/.gitignore b/drivers/net/wan/.gitignore new file mode 100644 index 0000000..dae3ea6 --- /dev/null +++ b/drivers/net/wan/.gitignore @@ -0,0 +1 @@ +wanxlfw.inc diff --git a/drivers/scsi/.gitignore b/drivers/scsi/.gitignore new file mode 100644 index 0000000..b385af3 --- /dev/null +++ b/drivers/scsi/.gitignore @@ -0,0 +1,3 @@ +53c700_d.h +53c7xx_d.h +53c7xx_u.h diff --git a/drivers/scsi/aic7xxx/.gitignore b/drivers/scsi/aic7xxx/.gitignore new file mode 100644 index 0000000..b8ee24d --- /dev/null +++ b/drivers/scsi/aic7xxx/.gitignore @@ -0,0 +1,6 @@ +aic79xx_reg.h +aic79xx_reg_print.c +aic79xx_seq.h +aic7xxx_reg.h +aic7xxx_reg_print.c +aic7xxx_seq.h diff --git a/scripts/genksyms/.gitignore b/scripts/genksyms/.gitignore new file mode 100644 index 0000000..be5cadb --- /dev/null +++ b/scripts/genksyms/.gitignore @@ -0,0 +1,4 @@ +keywords.c +lex.c +parse.[ch] +genksyms diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore index 2dac344..e8ad1f6 100644 --- a/scripts/kconfig/.gitignore +++ b/scripts/kconfig/.gitignore @@ -5,6 +5,7 @@ config* lex.*.c *.tab.c *.tab.h +zconf.hash.c # # configuration programs -- cgit v1.1 From 00213b17cec87d2cd4df75bcc79aea7a91d8532d Mon Sep 17 00:00:00 2001 From: Petr Baudis <pasky@ucw.cz> Date: Thu, 22 Dec 2005 04:44:04 +0100 Subject: kconfig: Remove support for lxdialog --checklist Remove support for lxdialog --checklist The checklist lxdialog functionality is not used by menuconfig (only the radiolist variant is used) and supporting it would significantly complicate the forthcoming liblxdialog API. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- scripts/kconfig/lxdialog/checklist.c | 47 +++++++++++------------------------- scripts/kconfig/lxdialog/dialog.h | 9 +------ scripts/kconfig/lxdialog/lxdialog.c | 12 ++------- 3 files changed, 17 insertions(+), 51 deletions(-) diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index 3fb681f..db07ae7 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c @@ -23,7 +23,7 @@ #include "dialog.h" -static int list_width, check_x, item_x, checkflag; +static int list_width, check_x, item_x; /* * Print list item @@ -41,10 +41,7 @@ static void print_item(WINDOW * win, const char *item, int status, int choice, wmove(win, choice, check_x); wattrset(win, selected ? check_selected_attr : check_attr); - if (checkflag == FLAG_CHECK) - wprintw(win, "[%c]", status ? 'X' : ' '); - else - wprintw(win, "(%c)", status ? 'X' : ' '); + wprintw(win, "(%c)", status ? 'X' : ' '); wattrset(win, selected ? tag_selected_attr : tag_attr); mvwaddch(win, choice, item_x, item[0]); @@ -109,18 +106,16 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected) /* * Display a dialog box with a list of options that can be turned on or off - * The `flag' parameter is used to select between radiolist and checklist. + * in the style of radiolist (only one option turned on at a time). */ int dialog_checklist(const char *title, const char *prompt, int height, int width, int list_height, int item_no, - const char *const *items, int flag) + const char *const *items) { int i, x, y, box_x, box_y; int key = 0, button = 0, choice = 0, scroll = 0, max_choice, *status; WINDOW *dialog, *list; - checkflag = flag; - /* Allocate space for storing item on/off status */ if ((status = malloc(sizeof(int) * item_no)) == NULL) { endwin(); @@ -303,34 +298,20 @@ int dialog_checklist(const char *title, const char *prompt, int height, case ' ': case '\n': if (!button) { - if (flag == FLAG_CHECK) { - status[scroll + choice] = !status[scroll + choice]; - wmove(list, choice, check_x); - wattrset(list, check_selected_attr); - wprintw(list, "[%c]", status[scroll + choice] ? 'X' : ' '); - } else { - if (!status[scroll + choice]) { - for (i = 0; i < item_no; i++) - status[i] = 0; - status[scroll + choice] = 1; - for (i = 0; i < max_choice; i++) - print_item(list, items[(scroll + i) * 3 + 1], - status[scroll + i], i, i == choice); - } + if (!status[scroll + choice]) { + for (i = 0; i < item_no; i++) + status[i] = 0; + status[scroll + choice] = 1; + for (i = 0; i < max_choice; i++) + print_item(list, items[(scroll + i) * 3 + 1], + status[scroll + i], i, i == choice); } wnoutrefresh(list); wrefresh(dialog); - for (i = 0; i < item_no; i++) { - if (status[i]) { - if (flag == FLAG_CHECK) { - fprintf(stderr, "\"%s\" ", items[i * 3]); - } else { - fprintf(stderr, "%s", items[i * 3]); - } - - } - } + for (i = 0; i < item_no; i++) + if (status[i]) + fprintf(stderr, "%s", items[i * 3]); } else fprintf(stderr, "%s", items[(scroll + choice) * 3]); delwin(dialog); diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index f882204..af3cf71 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -160,7 +160,7 @@ int dialog_menu(const char *title, const char *prompt, int height, int width, const char *const *items); int dialog_checklist(const char *title, const char *prompt, int height, int width, int list_height, int item_no, - const char *const *items, int flag); + const char *const *items); extern char dialog_input_result[]; int dialog_inputbox(const char *title, const char *prompt, int height, int width, const char *init); @@ -175,10 +175,3 @@ int dialog_inputbox(const char *title, const char *prompt, int height, * -- uppercase chars are used to invoke the button (M_EVENT + 'O') */ #define M_EVENT (KEY_MAX+1) - -/* - * The `flag' parameter in checklist is used to select between - * radiolist and checklist - */ -#define FLAG_CHECK 1 -#define FLAG_RADIO 0 diff --git a/scripts/kconfig/lxdialog/lxdialog.c b/scripts/kconfig/lxdialog/lxdialog.c index 2c34ea1..79f6c5f 100644 --- a/scripts/kconfig/lxdialog/lxdialog.c +++ b/scripts/kconfig/lxdialog/lxdialog.c @@ -31,12 +31,11 @@ struct Mode { jumperFn *jumper; }; -jumperFn j_menu, j_checklist, j_radiolist, j_yesno, j_textbox, j_inputbox; +jumperFn j_menu, j_radiolist, j_yesno, j_textbox, j_inputbox; jumperFn j_msgbox, j_infobox; static struct Mode modes[] = { {"--menu", 9, 0, 3, j_menu}, - {"--checklist", 9, 0, 3, j_checklist}, {"--radiolist", 9, 0, 3, j_radiolist}, {"--yesno", 5, 5, 1, j_yesno}, {"--textbox", 5, 5, 1, j_textbox}, @@ -151,7 +150,6 @@ static void Usage(const char *name) \nBox options:\ \n\ \n --menu <text> <height> <width> <menu height> <tag1> <item1>...\ -\n --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ \n --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...\ \n --textbox <file> <height> <width>\ \n --inputbox <text> <height> <width> [<init>]\ @@ -170,16 +168,10 @@ int j_menu(const char *t, int ac, const char *const *av) atoi(av[5]), av[6], (ac - 6) / 2, av + 7); } -int j_checklist(const char *t, int ac, const char *const *av) -{ - return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), - atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_CHECK); -} - int j_radiolist(const char *t, int ac, const char *const *av) { return dialog_checklist(t, av[2], atoi(av[3]), atoi(av[4]), - atoi(av[5]), (ac - 6) / 3, av + 6, FLAG_RADIO); + atoi(av[5]), (ac - 6) / 3, av + 6); } int j_textbox(const char *t, int ac, const char *const *av) -- cgit v1.1 From febf7ea4bedcd36fba0843db726bba28d22bf89a Mon Sep 17 00:00:00 2001 From: <sam@mars.ravnborg.org> Date: Tue, 3 Jan 2006 11:35:26 +0100 Subject: gitignore: ignore more generated files Signed-off-by: Sam Ravnborg <sam@ravnborg.org> --- kernel/.gitignore | 5 +++++ scripts/.gitignore | 5 ++++- scripts/kconfig/lxdialog/.gitignore | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 kernel/.gitignore create mode 100644 scripts/kconfig/lxdialog/.gitignore diff --git a/kernel/.gitignore b/kernel/.gitignore new file mode 100644 index 0000000..f2ab700 --- /dev/null +++ b/kernel/.gitignore @@ -0,0 +1,5 @@ +# +# Generated files +# +config_data.h +config_data.gz diff --git a/scripts/.gitignore b/scripts/.gitignore index b46d68b..a234e52 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -1,4 +1,7 @@ +# +# Generated files +# conmakehash kallsyms pnmtologo - +bin2c diff --git a/scripts/kconfig/lxdialog/.gitignore b/scripts/kconfig/lxdialog/.gitignore new file mode 100644 index 0000000..90b08ff --- /dev/null +++ b/scripts/kconfig/lxdialog/.gitignore @@ -0,0 +1,4 @@ +# +# Generated files +# +lxdialog -- cgit v1.1 From d031166fecac97fc6b5c35636deace8a3c9ec5f6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Mon, 7 Nov 2005 14:38:44 +0100 Subject: [ALSA] hda-codec - Allocate amp hash array dynamically Modules: HDA Codec driver Allocate amp hash array dynamically instead of static array. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/hda_codec.c | 22 +++++++++++++++++++--- sound/pci/hda/hda_codec.h | 3 ++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 0dbeeaf..e7fb182 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -465,6 +465,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) codec->bus->caddr_tbl[codec->addr] = NULL; if (codec->patch_ops.free) codec->patch_ops.free(codec); + kfree(codec->amp_info); kfree(codec); } @@ -586,6 +587,8 @@ static void init_amp_hash(struct hda_codec *codec) { memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash)); codec->num_amp_entries = 0; + codec->amp_info_size = 0; + codec->amp_info = NULL; } /* query the hash. allocate an entry if not found. */ @@ -603,9 +606,22 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key) } /* add a new hash entry */ - if (codec->num_amp_entries >= ARRAY_SIZE(codec->amp_info)) { - snd_printk(KERN_ERR "hda_codec: Tooooo many amps!\n"); - return NULL; + if (codec->num_amp_entries >= codec->amp_info_size) { + /* reallocate the array */ + int new_size = codec->amp_info_size + 64; + struct hda_amp_info *new_info = kcalloc(new_size, sizeof(struct hda_amp_info), + GFP_KERNEL); + if (! new_info) { + snd_printk(KERN_ERR "hda_codec: can't malloc amp_info\n"); + return NULL; + } + if (codec->amp_info) { + memcpy(new_info, codec->amp_info, + codec->amp_info_size * sizeof(struct hda_amp_info)); + kfree(codec->amp_info); + } + codec->amp_info_size = new_size; + codec->amp_info = new_info; } cur = codec->num_amp_entries++; info = &codec->amp_info[cur]; diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 1179d6c..b0123ad 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -545,7 +545,8 @@ struct hda_codec { /* hash for amp access */ u16 amp_hash[32]; int num_amp_entries; - struct hda_amp_info amp_info[128]; /* big enough? */ + int amp_info_size; + struct hda_amp_info *amp_info; struct semaphore spdif_mutex; unsigned int spdif_status; /* IEC958 status bits */ -- cgit v1.1 From 362775e2125b74cd04f83fd4ef5b72ef1ee6d3a1 Mon Sep 17 00:00:00 2001 From: Randy Dunlap <randy_d_dunlap@linux.intel.com> Date: Mon, 7 Nov 2005 14:43:23 +0100 Subject: [ALSA] sound/hda: rate-limit timeout message Modules: HDA Intel driver Rate-limit the azx_get_response timeout message. A continuous 2 per second is too much. Signed-off-by: Randy Dunlap <randy_d_dunlap@linux.intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/hda_intel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index ed525c0..429ef38 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -37,6 +37,7 @@ #include <asm/io.h> #include <linux/delay.h> #include <linux/interrupt.h> +#include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/init.h> @@ -514,7 +515,9 @@ static unsigned int azx_get_response(struct hda_codec *codec) while (chip->rirb.cmds) { if (! --timeout) { - snd_printk(KERN_ERR "azx_get_response timeout\n"); + if (printk_ratelimit()) + snd_printk(KERN_ERR + "azx_get_response timeout\n"); chip->rirb.rp = azx_readb(chip, RIRBWP); chip->rirb.cmds = 0; return -1; -- cgit v1.1 From 2f020aa71197eddef749ad6202ca5a66c0c6e382 Mon Sep 17 00:00:00 2001 From: Lee Revell <rlrevell@joe-job.com> Date: Mon, 7 Nov 2005 14:54:24 +0100 Subject: [ALSA] emu10k1 - Enable side surround channels for Audigy2 EX Modules: EMU10K1/EMU10K2 driver Enable side surround channels for Audigy2 EX. Tested by Rick Wright <riwright@vt.edu>. Signed-off-by: Lee Revell <rlrevell@joe-job.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/emu10k1/emu10k1_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 53aeff0..0a22f40 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -714,6 +714,7 @@ static emu_chip_details_t emu_chip_details[] = { .emu10k2_chip = 1, .ca0102_chip = 1, .ca0151_chip = 1, + .spk71 = 1, .spdif_bug = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", -- cgit v1.1 From f6f8bb642350dafc21676ccd4fab333282064b8d Mon Sep 17 00:00:00 2001 From: Lee Revell <rlrevell@joe-job.com> Date: Mon, 7 Nov 2005 14:59:19 +0100 Subject: [ALSA] Add support for Audigy 2 subsystem 2006 Modules: EMU10K1/EMU10K2 driver Add support for Audigy 2 subsystem 2006. Signed-off-by: Lee Revell <rlrevell@joe-job.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/emu10k1/emu10k1_main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 0a22f40..541aad6 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -681,6 +681,16 @@ static emu_chip_details_t emu_chip_details[] = { .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} , + /* Tested by shane-alsa@cm.nu 5th Nov 2005 */ + {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102, + .driver = "Audigy2", .name = "Audigy 2 [2006]", + .id = "Audigy2", + .emu10k2_chip = 1, + .ca0102_chip = 1, + .ca0151_chip = 1, + .spk71 = 1, + .spdif_bug = 1, + .ac97_chip = 1} , {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", .id = "Audigy2", -- cgit v1.1 From c1b8f5f0e4aabd4b47648dd9465fb750e07da9fb Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Tue, 8 Nov 2005 17:44:37 +0100 Subject: [ALSA] via82xx - Add dxs entry for MSI KT800 Delta-FSR Modules: VIA82xx driver Added the dxs entry for MSI KT800 Delta-FSR. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/via82xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index fad2a24..f0d8c7f 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2307,6 +2307,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci) { .subvendor = 0x1458, .subdevice = 0xa002, .action = VIA_DXS_ENABLE }, /* Gigabyte GA-7VAXP */ { .subvendor = 0x1462, .subdevice = 0x0080, .action = VIA_DXS_SRC }, /* MSI K8T Neo-FIS2R */ { .subvendor = 0x1462, .subdevice = 0x0430, .action = VIA_DXS_SRC }, /* MSI 7142 (K8MM-V) */ + { .subvendor = 0x1462, .subdevice = 0x0470, .action = VIA_DXS_SRC }, /* MSI KT880 Delta-FSR */ { .subvendor = 0x1462, .subdevice = 0x3800, .action = VIA_DXS_ENABLE }, /* MSI KT266 */ { .subvendor = 0x1462, .subdevice = 0x5901, .action = VIA_DXS_NO_VRA }, /* MSI KT6 Delta-SR */ { .subvendor = 0x1462, .subdevice = 0x7023, .action = VIA_DXS_NO_VRA }, /* MSI K8T Neo2-FI */ -- cgit v1.1 From fd6715e564a53bc3fca22e4f0a9d76b6b72afdb5 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela <perex@suse.cz> Date: Thu, 10 Nov 2005 07:51:31 +0100 Subject: [ALSA] ice1724 (juli) - forced analog doughter board detection Modules: ICE1712 driver Signed-off-by: Jaroslav Kysela <perex@suse.cz> --- sound/pci/ice1712/juli.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index 2437876..a5e04a3 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -175,7 +175,14 @@ static int __devinit juli_init(ice1712_t *ice) if (err < 0) return err; - ice->spec.juli.analog = ice->gpio.get_data(ice) & GPIO_ANALOG_PRESENT; +#if 0 + /* it seems that the analog doughter board detection does not work + reliably, so force the analog flag; it should be very rare + to use Juli@ without the analog doughter board */ + ice->spec.juli.analog = (ice->gpio.get_data(ice) & GPIO_ANALOG_PRESENT) ? 0 : 1; +#else + ice->spec.juli.analog = 1; +#endif if (ice->spec.juli.analog) { printk(KERN_INFO "juli@: analog I/O detected\n"); -- cgit v1.1 From 755e137138007200c3e2549fbd8390a4e7708ed9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Fri, 11 Nov 2005 21:05:27 +0100 Subject: [ALSA] ali5451 - Fix and clean up codec accessor Modules: ALI5451 driver Fix the codec accessors to avoid soft lockup. Spin locks are revised, too. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ali5451/ali5451.c | 89 ++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index feffbe7..21be4c2 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -387,26 +387,24 @@ static inline void snd_ali_5451_poke( ali_t *codec, } static int snd_ali_codec_ready( ali_t *codec, - unsigned int port, - int sched ) + unsigned int port ) { unsigned long end_time; unsigned int res; - end_time = jiffies + 10 * msecs_to_jiffies(250); + end_time = jiffies + msecs_to_jiffies(250); do { res = snd_ali_5451_peek(codec,port); if (! (res & 0x8000)) return 0; - if (sched) - schedule_timeout_uninterruptible(1); + schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); snd_ali_5451_poke(codec, port, res & ~0x8000); snd_printdd("ali_codec_ready: codec is not ready.\n "); return -EIO; } -static int snd_ali_stimer_ready(ali_t *codec, int sched) +static int snd_ali_stimer_ready(ali_t *codec) { unsigned long end_time; unsigned long dwChk1,dwChk2; @@ -414,13 +412,12 @@ static int snd_ali_stimer_ready(ali_t *codec, int sched) dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER); dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); - end_time = jiffies + 10 * msecs_to_jiffies(250); + end_time = jiffies + msecs_to_jiffies(250); do { dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); if (dwChk2 != dwChk1) return 0; - if (sched) - schedule_timeout_uninterruptible(1); + schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n"); return -EIO; @@ -440,9 +437,9 @@ static void snd_ali_codec_poke(ali_t *codec,int secondary, port = codec->chregs.regs.ac97write; - if (snd_ali_codec_ready(codec, port, 0) < 0) + if (snd_ali_codec_ready(codec, port) < 0) return; - if (snd_ali_stimer_ready(codec, 0) < 0) + if (snd_ali_stimer_ready(codec) < 0) return; dwVal = (unsigned int) (reg & 0xff); @@ -469,9 +466,9 @@ static unsigned short snd_ali_codec_peek( ali_t *codec, port = codec->chregs.regs.ac97read; - if (snd_ali_codec_ready(codec, port, 0) < 0) + if (snd_ali_codec_ready(codec, port) < 0) return ~0; - if (snd_ali_stimer_ready(codec, 0) < 0) + if (snd_ali_stimer_ready(codec) < 0) return ~0; dwVal = (unsigned int) (reg & 0xff); @@ -480,9 +477,9 @@ static unsigned short snd_ali_codec_peek( ali_t *codec, snd_ali_5451_poke(codec, port, dwVal); - if (snd_ali_stimer_ready(codec, 0) < 0) + if (snd_ali_stimer_ready(codec) < 0) return ~0; - if (snd_ali_codec_ready(codec, port, 0) < 0) + if (snd_ali_codec_ready(codec, port) < 0) return ~0; return (snd_ali_5451_peek(codec, port) & 0xffff0000)>>16; @@ -770,7 +767,7 @@ static void snd_ali_delay(ali_t *codec,int interval) currenttimer = inl(ALI_REG(codec, ALI_STIMER)); while (currenttimer < begintimer + interval) { - if(snd_ali_stimer_ready(codec, 1) < 0) + if(snd_ali_stimer_ready(codec) < 0) break; currenttimer = inl(ALI_REG(codec, ALI_STIMER)); } @@ -1065,35 +1062,34 @@ static irqreturn_t snd_ali_card_interrupt(int irq, static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec, int channel) { snd_ali_voice_t *pvoice = NULL; - unsigned long flags; int idx; snd_ali_printk("alloc_voice: type=%d rec=%d\n",type,rec); - spin_lock_irqsave(&codec->voice_alloc, flags); + spin_lock_irq(&codec->voice_alloc); if (type == SNDRV_ALI_VOICE_TYPE_PCM) { idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) : snd_ali_find_free_channel(codec,rec); if(idx < 0) { snd_printk(KERN_ERR "ali_alloc_voice: err.\n"); - spin_unlock_irqrestore(&codec->voice_alloc, flags); + spin_unlock_irq(&codec->voice_alloc); return NULL; } pvoice = &(codec->synth.voices[idx]); + pvoice->codec = codec; pvoice->use = 1; pvoice->pcm = 1; pvoice->mode = rec; - spin_unlock_irqrestore(&codec->voice_alloc, flags); + spin_unlock_irq(&codec->voice_alloc); return pvoice; } - spin_unlock_irqrestore(&codec->voice_alloc, flags); + spin_unlock_irq(&codec->voice_alloc); return NULL; } static void snd_ali_free_voice(ali_t * codec, snd_ali_voice_t *pvoice) { - unsigned long flags; void (*private_free)(void *); void *private_data; @@ -1101,7 +1097,7 @@ static void snd_ali_free_voice(ali_t * codec, snd_ali_voice_t *pvoice) if (pvoice == NULL || !pvoice->use) return; snd_ali_clear_voices(codec, pvoice->number, pvoice->number); - spin_lock_irqsave(&codec->voice_alloc, flags); + spin_lock_irq(&codec->voice_alloc); private_free = pvoice->private_free; private_data = pvoice->private_data; pvoice->private_free = NULL; @@ -1111,7 +1107,7 @@ static void snd_ali_free_voice(ali_t * codec, snd_ali_voice_t *pvoice) } pvoice->use = pvoice->pcm = pvoice->synth = 0; pvoice->substream = NULL; - spin_unlock_irqrestore(&codec->voice_alloc, flags); + spin_unlock_irq(&codec->voice_alloc); if (private_free) private_free(private_data); } @@ -1357,7 +1353,6 @@ static int snd_ali_playback_prepare(snd_pcm_substream_t * substream) snd_pcm_runtime_t *runtime = substream->runtime; snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; snd_ali_voice_t *evoice = pvoice->extra; - unsigned long flags; unsigned int LBA; unsigned int Delta; @@ -1370,7 +1365,7 @@ static int snd_ali_playback_prepare(snd_pcm_substream_t * substream) snd_ali_printk("playback_prepare ...\n"); - spin_lock_irqsave(&codec->reg_lock, flags); + spin_lock_irq(&codec->reg_lock); /* set Delta (rate) value */ Delta = snd_ali_convert_rate(runtime->rate, 0); @@ -1435,7 +1430,7 @@ static int snd_ali_playback_prepare(snd_pcm_substream_t * substream) CTRL, EC); } - spin_unlock_irqrestore(&codec->reg_lock, flags); + spin_unlock_irq(&codec->reg_lock); return 0; } @@ -1445,7 +1440,6 @@ static int snd_ali_prepare(snd_pcm_substream_t * substream) ali_t *codec = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; - unsigned long flags; unsigned int LBA; unsigned int Delta; unsigned int ESO; @@ -1456,7 +1450,7 @@ static int snd_ali_prepare(snd_pcm_substream_t * substream) unsigned int EC; u8 bValue; - spin_lock_irqsave(&codec->reg_lock, flags); + spin_lock_irq(&codec->reg_lock); snd_ali_printk("ali_prepare...\n"); @@ -1471,15 +1465,16 @@ static int snd_ali_prepare(snd_pcm_substream_t * substream) unsigned int rate; - if (codec->revision != ALI_5451_V02) { - spin_unlock_irqrestore(&codec->reg_lock, flags); + spin_unlock_irq(&codec->reg_lock); + if (codec->revision != ALI_5451_V02) return -1; - } + rate = snd_ali_get_spdif_in_rate(codec); if (rate == 0) { snd_printk(KERN_WARNING "ali_capture_preapre: spdif rate detect err!\n"); rate = 48000; } + spin_lock_irq(&codec->reg_lock); bValue = inb(ALI_REG(codec,ALI_SPDIF_CTRL)); if (bValue & 0x10) { outb(bValue,ALI_REG(codec,ALI_SPDIF_CTRL)); @@ -1521,7 +1516,7 @@ static int snd_ali_prepare(snd_pcm_substream_t * substream) EC); - spin_unlock_irqrestore(&codec->reg_lock, flags); + spin_unlock_irq(&codec->reg_lock); return 0; } @@ -1554,16 +1549,15 @@ static snd_pcm_uframes_t snd_ali_pointer(snd_pcm_substream_t *substream) snd_pcm_runtime_t *runtime = substream->runtime; snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; unsigned int cso; - unsigned long flags; - spin_lock_irqsave(&codec->reg_lock, flags); + spin_lock(&codec->reg_lock); if (!pvoice->running) { - spin_unlock_irqrestore(&codec->reg_lock, flags); + spin_unlock_irq(&codec->reg_lock); return 0; } outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR)); cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2)); - spin_unlock_irqrestore(&codec->reg_lock, flags); + spin_unlock(&codec->reg_lock); return cso; } @@ -1618,15 +1612,12 @@ static snd_pcm_hardware_t snd_ali_capture = static void snd_ali_pcm_free_substream(snd_pcm_runtime_t *runtime) { - unsigned long flags; snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; ali_t *codec; if (pvoice) { codec = pvoice->codec; - spin_lock_irqsave(&codec->reg_lock, flags); snd_ali_free_voice(pvoice->codec, pvoice); - spin_unlock_irqrestore(&codec->reg_lock, flags); } } @@ -1636,16 +1627,10 @@ static int snd_ali_open(snd_pcm_substream_t * substream, int rec, int channel, ali_t *codec = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; snd_ali_voice_t *pvoice; - unsigned long flags = 0; - spin_lock_irqsave(&codec->reg_lock, flags); pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, channel); - if (pvoice == NULL) { - spin_unlock_irqrestore(&codec->reg_lock, flags); + if (pvoice == NULL) return -EAGAIN; - } - pvoice->codec = codec; - spin_unlock_irqrestore(&codec->reg_lock, flags); pvoice->substream = substream; runtime->private_data = pvoice; @@ -1864,13 +1849,12 @@ static int snd_ali5451_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t static int snd_ali5451_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { - unsigned long flags; ali_t *codec = kcontrol->private_data; unsigned int enable; enable = ucontrol->value.integer.value[0] ? 1 : 0; - spin_lock_irqsave(&codec->reg_lock, flags); + spin_lock_irq(&codec->reg_lock); switch(kcontrol->private_value) { case 0: enable = (codec->spdif_mask & 0x02) ? 1 : 0; @@ -1885,19 +1869,18 @@ static int snd_ali5451_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t break; } ucontrol->value.integer.value[0] = enable; - spin_unlock_irqrestore(&codec->reg_lock, flags); + spin_unlock_irq(&codec->reg_lock); return 0; } static int snd_ali5451_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { - unsigned long flags; ali_t *codec = kcontrol->private_data; unsigned int change = 0, enable = 0; enable = ucontrol->value.integer.value[0] ? 1 : 0; - spin_lock_irqsave(&codec->reg_lock, flags); + spin_lock_irq(&codec->reg_lock); switch (kcontrol->private_value) { case 0: change = (codec->spdif_mask & 0x02) ? 1 : 0; @@ -1942,7 +1925,7 @@ static int snd_ali5451_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t default: break; } - spin_unlock_irqrestore(&codec->reg_lock, flags); + spin_unlock_irq(&codec->reg_lock); return change; } -- cgit v1.1 From e2b15f8f7dfc7a60ab89162502732120792a644f Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton <James@superbug.co.uk> Date: Fri, 11 Nov 2005 23:39:05 +0100 Subject: [ALSA] snd-emu10k1: Attenuate output volume to reduce distortion Modules: EMU10K1/EMU10K2 driver on Audigy 2 ZS Notebook. Set the master volume to about 6 or 8% in alsamixer. This will attenuate the output enough for better sound quality. Note: Only stereo enabled at present. The distortion is caused by the output path after the DSP adding 12dB gain to the output while still in digital mode, resulting in wrap around distortion. Signed-off-by: James Courtier-Dutton <James@superbug.co.uk> --- sound/pci/emu10k1/emu10k1_main.c | 2 ++ sound/pci/emu10k1/tina2.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 sound/pci/emu10k1/tina2.h diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 541aad6..2d1ebe8 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -40,6 +40,7 @@ #include <sound/core.h> #include <sound/emu10k1.h> #include "p16v.h" +#include "tina2.h" #if 0 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Creative Labs, Inc."); @@ -600,6 +601,7 @@ static int __devinit snd_emu10k1_cardbus_init(emu10k1_t * emu) outl(0x0090007f, special_port); value = inl(special_port); + snd_emu10k1_ptr20_write(emu, TINA2_VOLUME, 0, 0xfefefefe); /* Defaults to 0x30303030 */ return 0; } diff --git a/sound/pci/emu10k1/tina2.h b/sound/pci/emu10k1/tina2.h new file mode 100644 index 0000000..5c43abf --- /dev/null +++ b/sound/pci/emu10k1/tina2.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) by James Courtier-Dutton <James@superbug.demon.co.uk> + * Driver p16v chips + * Version: 0.21 + * + * + * This code was initally based on code from ALSA's emu10k1x.c which is: + * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +/********************************************************************************************************/ +/* Audigy2 Tina2 (notebook) pointer-offset register set, accessed through the PTR2 and DATA2 registers */ +/********************************************************************************************************/ + +#define TINA2_VOLUME 0x71 /* Attenuate playback volume to prevent distortion. */ + /* The windows driver does not use this register, + * so it must use some other attenuation method. + * Without this, the output is 12dB too loud, + * resulting in distortion. + */ + -- cgit v1.1 From 6ef7e8614c03f90ecb924938f5cc074af2723d35 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton <James@superbug.co.uk> Date: Fri, 11 Nov 2005 23:45:23 +0100 Subject: [ALSA] snd-emu10k1: Found some new registers to display in debug mode. Modules: EMU10K1/EMU10K2 driver Signed-off-by: James Courtier-Dutton <James@superbug.co.uk> --- sound/pci/emu10k1/emuproc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index cc22707..6cdee58 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c @@ -445,7 +445,7 @@ static void snd_emu_proc_ptr_reg_read(snd_info_entry_t *entry, emu10k1_t *emu = entry->private_data; unsigned long value; int i,j; - if (offset+length > 0x80) { + if (offset+length > 0xa0) { snd_iprintf(buffer, "Input values out of range\n"); return; } @@ -472,7 +472,7 @@ static void snd_emu_proc_ptr_reg_write(snd_info_entry_t *entry, while (!snd_info_get_line(buffer, line, sizeof(line))) { if (sscanf(line, "%x %x %x", ®, &channel_id, &val) != 3) continue; - if ((reg < 0x80) && (reg >=0) && (val <= 0xffffffff) && (channel_id >=0) && (channel_id <= 3) ) + if ((reg < 0xa0) && (reg >=0) && (val <= 0xffffffff) && (channel_id >=0) && (channel_id <= 3) ) snd_ptr_write(emu, iobase, reg, channel_id, val); } } @@ -513,6 +513,12 @@ static void snd_emu_proc_ptr_reg_read20b(snd_info_entry_t *entry, { snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4); } + +static void snd_emu_proc_ptr_reg_read20c(snd_info_entry_t *entry, + snd_info_buffer_t * buffer) +{ + snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4); +} #endif static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = { @@ -553,6 +559,12 @@ int __devinit snd_emu10k1_proc_init(emu10k1_t * emu) entry->c.text.write = snd_emu_proc_ptr_reg_write20; entry->mode |= S_IWUSR; } + if (! snd_card_proc_new(emu->card, "ptr_regs20c", &entry)) { + snd_info_set_text_ops(entry, emu, 65536, snd_emu_proc_ptr_reg_read20c); + entry->c.text.write_size = 64; + entry->c.text.write = snd_emu_proc_ptr_reg_write20; + entry->mode |= S_IWUSR; + } #endif if (! snd_card_proc_new(emu->card, "emu10k1", &entry)) -- cgit v1.1 From b4a621f547ce78d6a415b3be2febd29b55e3235c Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela <perex@suse.cz> Date: Mon, 14 Nov 2005 08:48:59 +0100 Subject: [ALSA] ac97 - procfs - print PCI subsystem vendor/device values Modules: AC97 Codec For debugging and problem finding purposes, show also the PCI subsystem vendor/device values in the ac97#X proc file. Signed-off-by: Jaroslav Kysela <perex@suse.cz> --- sound/pci/ac97/ac97_proc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/pci/ac97/ac97_proc.c b/sound/pci/ac97/ac97_proc.c index a040b26..f4333b8 100644 --- a/sound/pci/ac97/ac97_proc.c +++ b/sound/pci/ac97/ac97_proc.c @@ -79,9 +79,16 @@ static void snd_ac97_proc_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, in snd_ac97_get_name(NULL, ac97->id, name, 0); snd_iprintf(buffer, "%d-%d/%d: %s\n\n", ac97->addr, ac97->num, subidx, name); + + if ((ac97->scaps & AC97_SCAP_AUDIO) == 0) goto __modem; + snd_iprintf(buffer, "PCI Subsys Vendor: 0x%04x\n", + ac97->subsystem_vendor); + snd_iprintf(buffer, "PCI Subsys Device: 0x%04x\n\n", + ac97->subsystem_device); + if ((ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_23) { val = snd_ac97_read(ac97, AC97_INT_PAGING); snd_ac97_update_bits(ac97, AC97_INT_PAGING, -- cgit v1.1 From 26741b5512a99ee35f398ef018d23a38e8dc6e8a Mon Sep 17 00:00:00 2001 From: Daniel Mueller <daniel.mueller@siemens.com> Date: Mon, 14 Nov 2005 17:40:44 +0100 Subject: [ALSA] hda-codec - Fix HDA sound and V.92 modem for notebook Siemens FieldPG-M Modules: HDA Codec driver The patch fixes the problem of mute onboard HDA sound output, buildin V.92 modem idendification and functionality. Signed-off-by: Daniel Mueller <daniel.mueller@siemens.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/patch_si3054.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c index 9c7fe0b..12b5de2 100644 --- a/sound/pci/hda/patch_si3054.c +++ b/sound/pci/hda/patch_si3054.c @@ -295,6 +295,7 @@ static int patch_si3054(struct hda_codec *codec) * patch entries */ struct hda_codec_preset snd_hda_preset_si3054[] = { + { .id = 0x163c3055, .name = "Si3054", .patch = patch_si3054 }, { .id = 0x163c3155, .name = "Si3054", .patch = patch_si3054 }, {} }; -- cgit v1.1 From f31a31b9024f21b2ad8f5a7c30e265a652e2e211 Mon Sep 17 00:00:00 2001 From: "Kurt J. Bosch" <kjb-temp-2005@gmx.de> Date: Wed, 16 Nov 2005 18:41:21 +0100 Subject: [ALSA] Fix missing suspend/resume-code for ens1371 Modules: ENS1370/1+ driver This patch fixes missing suspend/resume-code for snd-ens1371 (but not for snd-ens1370) Signed-off-by: Kurt J. Bosch <kjb-temp-2005@gmx.de> Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ens1370.c | 174 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 123 insertions(+), 51 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 2daa575..fa619a9 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -19,6 +19,13 @@ * */ +/* Power-Management-Code ( CONFIG_PM ) + * for ens1371 only ( FIXME ) + * derived from cs4281.c, atiixp.c and via82xx.c + * using http://www.alsa-project.org/~iwai/writing-an-alsa-driver/c1540.htm + * by Kurt J. Bosch + */ + #include <sound/driver.h> #include <asm/io.h> #include <linux/delay.h> @@ -1924,6 +1931,117 @@ static struct { }; #endif +static void snd_ensoniq_chip_init(ensoniq_t * ensoniq) +{ +#ifdef CHIP1371 + int idx; + struct pci_dev *pci = ensoniq->pci; +#endif +// this code was part of snd_ensoniq_create before intruduction of suspend/resume +#ifdef CHIP1370 + outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); + outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); + outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); + outl(ensoniq->dma_bug.addr, ES_REG(ensoniq, PHANTOM_FRAME)); + outl(0, ES_REG(ensoniq, PHANTOM_COUNT)); +#else + outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); + outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); + outl(0, ES_REG(ensoniq, 1371_LEGACY)); + for (idx = 0; es1371_ac97_reset_hack[idx].vid != (unsigned short)PCI_ANY_ID; idx++) + if (pci->vendor == es1371_ac97_reset_hack[idx].vid && + pci->device == es1371_ac97_reset_hack[idx].did && + ensoniq->rev == es1371_ac97_reset_hack[idx].rev) { + outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); + /* need to delay around 20ms(bleech) to give + some CODECs enough time to wakeup */ + msleep(20); + break; + } + /* AC'97 warm reset to start the bitclk */ + outl(ensoniq->ctrl | ES_1371_SYNC_RES, ES_REG(ensoniq, CONTROL)); + inl(ES_REG(ensoniq, CONTROL)); + udelay(20); + outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); + /* Init the sample rate converter */ + snd_es1371_wait_src_ready(ensoniq); + outl(ES_1371_SRC_DISABLE, ES_REG(ensoniq, 1371_SMPRATE)); + for (idx = 0; idx < 0x80; idx++) + snd_es1371_src_write(ensoniq, idx, 0); + snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_TRUNC_N, 16 << 4); + snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_INT_REGS, 16 << 10); + snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_TRUNC_N, 16 << 4); + snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_INT_REGS, 16 << 10); + snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, 1 << 12); + snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, 1 << 12); + snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC1, 1 << 12); + snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC1 + 1, 1 << 12); + snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC2, 1 << 12); + snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC2 + 1, 1 << 12); + snd_es1371_adc_rate(ensoniq, 22050); + snd_es1371_dac1_rate(ensoniq, 22050); + snd_es1371_dac2_rate(ensoniq, 22050); + /* WARNING: + * enabling the sample rate converter without properly programming + * its parameters causes the chip to lock up (the SRC busy bit will + * be stuck high, and I've found no way to rectify this other than + * power cycle) - Thomas Sailer + */ + snd_es1371_wait_src_ready(ensoniq); + outl(0, ES_REG(ensoniq, 1371_SMPRATE)); + /* try reset codec directly */ + outl(ES_1371_CODEC_WRITE(0, 0), ES_REG(ensoniq, 1371_CODEC)); +#endif + outb(ensoniq->uartc = 0x00, ES_REG(ensoniq, UART_CONTROL)); + outb(0x00, ES_REG(ensoniq, UART_RES)); + outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); + synchronize_irq(ensoniq->irq); +} + +#ifdef CONFIG_PM +static int snd_ensoniq_suspend (snd_card_t * card, + pm_message_t state) +{ + ensoniq_t *ensoniq = card->pm_private_data; + + snd_pcm_suspend_all(ensoniq->pcm1); + snd_pcm_suspend_all(ensoniq->pcm2); + +#ifdef CHIP1371 + if (ensoniq->u.es1371.ac97) + snd_ac97_suspend(ensoniq->u.es1371.ac97); +#else + /* FIXME */ +#endif + pci_set_power_state(ensoniq->pci, 3); + pci_disable_device(ensoniq->pci); + // snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); // only 2.6.10 + return 0; +} + +static int snd_ensoniq_resume (snd_card_t * card + ) +{ + ensoniq_t *ensoniq = card->pm_private_data; + + pci_enable_device(ensoniq->pci); + pci_set_power_state(ensoniq->pci, 0); + pci_set_master(ensoniq->pci); + + snd_ensoniq_chip_init(ensoniq); + +#ifdef CHIP1371 + if (ensoniq->u.es1371.ac97) + snd_ac97_resume(ensoniq->u.es1371.ac97); +#else + /* FIXME */ +#endif + // snd_power_change_state(card, SNDRV_CTL_POWER_D0); // only 2.6.10 + return 0; +} +#endif /* CONFIG_PM */ + + static int __devinit snd_ensoniq_create(snd_card_t * card, struct pci_dev *pci, ensoniq_t ** rensoniq) @@ -1986,12 +2104,6 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); #endif ensoniq->sctrl = 0; - /* initialize the chips */ - outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); - outl(ES_MEM_PAGEO(ES_PAGE_ADC), ES_REG(ensoniq, MEM_PAGE)); - outl(ensoniq->dma_bug.addr, ES_REG(ensoniq, PHANTOM_FRAME)); - outl(0, ES_REG(ensoniq, PHANTOM_COUNT)); #else ensoniq->ctrl = 0; ensoniq->sctrl = 0; @@ -2002,59 +2114,16 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, ensoniq->ctrl |= ES_1371_GPIO_OUT(1); /* turn amplifier on */ break; } - /* initialize the chips */ - outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); - outl(0, ES_REG(ensoniq, 1371_LEGACY)); for (idx = 0; es1371_ac97_reset_hack[idx].vid != (unsigned short)PCI_ANY_ID; idx++) if (pci->vendor == es1371_ac97_reset_hack[idx].vid && pci->device == es1371_ac97_reset_hack[idx].did && ensoniq->rev == es1371_ac97_reset_hack[idx].rev) { ensoniq->cssr |= ES_1371_ST_AC97_RST; - outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); - /* need to delay around 20ms(bleech) to give - some CODECs enough time to wakeup */ - msleep(20); break; } - /* AC'97 warm reset to start the bitclk */ - outl(ensoniq->ctrl | ES_1371_SYNC_RES, ES_REG(ensoniq, CONTROL)); - inl(ES_REG(ensoniq, CONTROL)); - udelay(20); - outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); - /* Init the sample rate converter */ - snd_es1371_wait_src_ready(ensoniq); - outl(ES_1371_SRC_DISABLE, ES_REG(ensoniq, 1371_SMPRATE)); - for (idx = 0; idx < 0x80; idx++) - snd_es1371_src_write(ensoniq, idx, 0); - snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_TRUNC_N, 16 << 4); - snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_INT_REGS, 16 << 10); - snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_TRUNC_N, 16 << 4); - snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_INT_REGS, 16 << 10); - snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, 1 << 12); - snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, 1 << 12); - snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC1, 1 << 12); - snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC1 + 1, 1 << 12); - snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC2, 1 << 12); - snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_DAC2 + 1, 1 << 12); - snd_es1371_adc_rate(ensoniq, 22050); - snd_es1371_dac1_rate(ensoniq, 22050); - snd_es1371_dac2_rate(ensoniq, 22050); - /* WARNING: - * enabling the sample rate converter without properly programming - * its parameters causes the chip to lock up (the SRC busy bit will - * be stuck high, and I've found no way to rectify this other than - * power cycle) - Thomas Sailer - */ - snd_es1371_wait_src_ready(ensoniq); - outl(0, ES_REG(ensoniq, 1371_SMPRATE)); - /* try reset codec directly */ - outl(ES_1371_CODEC_WRITE(0, 0), ES_REG(ensoniq, 1371_CODEC)); #endif - outb(ensoniq->uartc = 0x00, ES_REG(ensoniq, UART_CONTROL)); - outb(0x00, ES_REG(ensoniq, UART_RES)); - outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); - synchronize_irq(ensoniq->irq); + + snd_ensoniq_chip_init(ensoniq); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ensoniq, &ops)) < 0) { snd_ensoniq_free(ensoniq); @@ -2063,6 +2132,8 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, snd_ensoniq_proc_init(ensoniq); + snd_card_set_pm_callback(card, snd_ensoniq_suspend, snd_ensoniq_resume, ensoniq); + snd_card_set_dev(card, &pci->dev); *rensoniq = ensoniq; @@ -2389,6 +2460,7 @@ static struct pci_driver driver = { .id_table = snd_audiopci_ids, .probe = snd_audiopci_probe, .remove = __devexit_p(snd_audiopci_remove), + SND_PCI_PM_CALLBACKS }; static int __init alsa_card_ens137x_init(void) -- cgit v1.1 From c3e6f7d8763fa0400d28c57633eb323515ba05fc Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Wed, 16 Nov 2005 18:43:35 +0100 Subject: [ALSA] Remove superfluous pcm_free callbacks Remove superflous pcm_free callbacks. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/ad1816a/ad1816a_lib.c | 8 -------- sound/isa/ad1848/ad1848_lib.c | 8 -------- sound/isa/cmi8330.c | 6 ------ sound/isa/cs423x/cs4231_lib.c | 8 -------- sound/isa/es1688/es1688_lib.c | 8 -------- sound/isa/es18xx.c | 8 -------- sound/isa/gus/gus_pcm.c | 8 -------- sound/isa/opti9xx/opti92x-ad1848.c | 8 -------- sound/isa/sb/sb16_main.c | 6 ------ sound/isa/sb/sb8_main.c | 6 ------ sound/pci/ad1889.c | 9 --------- sound/pci/als4000.c | 8 -------- sound/pci/azt3328.c | 9 --------- sound/pci/ca0106/ca0106_main.c | 8 -------- sound/pci/cmipci.c | 8 -------- sound/pci/cs4281.c | 8 -------- sound/pci/cs46xx/cs46xx_lib.c | 32 -------------------------------- sound/pci/emu10k1/emu10k1x.c | 8 -------- sound/pci/emu10k1/emupcm.c | 25 ------------------------- sound/pci/emu10k1/p16v.c | 9 --------- sound/pci/ens1370.c | 16 ---------------- sound/pci/es1938.c | 6 ------ sound/pci/fm801.c | 8 -------- sound/pci/ice1712/ice1712.c | 24 ------------------------ sound/pci/rme9652/hdspm.c | 11 ----------- sound/pci/sonicvibes.c | 8 -------- sound/pci/trident/trident_main.c | 34 ---------------------------------- sound/pci/ymfpci/ymfpci_main.c | 32 -------------------------------- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 10 ---------- sound/ppc/pmac.c | 6 ------ sound/sparc/amd7930.c | 9 --------- sound/sparc/cs4231.c | 8 -------- sound/usb/usx2y/usbusx2yaudio.c | 4 +--- sound/usb/usx2y/usx2yhwdeppcm.c | 8 -------- 34 files changed, 1 insertion(+), 381 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 7ae0239..170409e 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -662,13 +662,6 @@ static snd_pcm_ops_t snd_ad1816a_capture_ops = { .pointer = snd_ad1816a_capture_pointer, }; -static void snd_ad1816a_pcm_free(snd_pcm_t *pcm) -{ - ad1816a_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm) { int error; @@ -681,7 +674,6 @@ int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1816a_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_ad1816a_pcm_free; pcm->info_flags = (chip->dma1 == chip->dma2 ) ? SNDRV_PCM_INFO_JOINT_DUPLEX : 0; strcpy(pcm->name, snd_ad1816a_chip_id(chip)); diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c index 891bacc..84a3c55 100644 --- a/sound/isa/ad1848/ad1848_lib.c +++ b/sound/isa/ad1848/ad1848_lib.c @@ -959,13 +959,6 @@ static snd_pcm_ops_t snd_ad1848_capture_ops = { .pointer = snd_ad1848_capture_pointer, }; -static void snd_ad1848_pcm_free(snd_pcm_t *pcm) -{ - ad1848_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm) { snd_pcm_t *pcm; @@ -977,7 +970,6 @@ int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ad1848_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ad1848_capture_ops); - pcm->private_free = snd_ad1848_pcm_free; pcm->private_data = chip; pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; strcpy(pcm->name, snd_ad1848_chip_id(chip)); diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index 5252206..6038529 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -388,11 +388,6 @@ static int snd_cmi8330_capture_open(snd_pcm_substream_t * substream) return chip->streams[SNDRV_PCM_STREAM_CAPTURE].open(substream); } -static void snd_cmi8330_pcm_free(snd_pcm_t *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) { snd_pcm_t *pcm; @@ -407,7 +402,6 @@ static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) return err; strcpy(pcm->name, "CMI8330"); pcm->private_data = chip; - pcm->private_free = snd_cmi8330_pcm_free; /* SB16 */ ops = snd_sb16dsp_get_pcm_ops(CMI_SB_STREAM); diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 4af7690..4c9fb16 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -1605,13 +1605,6 @@ static snd_pcm_ops_t snd_cs4231_capture_ops = { .pointer = snd_cs4231_capture_pointer, }; -static void snd_cs4231_pcm_free(snd_pcm_t *pcm) -{ - cs4231_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) { snd_pcm_t *pcm; @@ -1629,7 +1622,6 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) /* global setup */ pcm->private_data = chip; - pcm->private_free = snd_cs4231_pcm_free; pcm->info_flags = 0; if (chip->single_dma) pcm->info_flags |= SNDRV_PCM_INFO_HALF_DUPLEX; diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 2edc9c9..841e9ac 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -724,13 +724,6 @@ static snd_pcm_ops_t snd_es1688_capture_ops = { .pointer = snd_es1688_capture_pointer, }; -static void snd_es1688_pcm_free(snd_pcm_t *pcm) -{ - es1688_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -743,7 +736,6 @@ int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_es1688_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_es1688_pcm_free; pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; sprintf(pcm->name, snd_es1688_chip_id(chip)); chip->pcm = pcm; diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 970e2aa..7191ff9 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1566,13 +1566,6 @@ static snd_pcm_ops_t snd_es18xx_capture_ops = { .pointer = snd_es18xx_capture_pointer, }; -static void snd_es18xx_pcm_free(snd_pcm_t *pcm) -{ - es18xx_t *codec = pcm->private_data; - codec->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1595,7 +1588,6 @@ static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpc /* global setup */ pcm->private_data = chip; - pcm->private_free = snd_es18xx_pcm_free; pcm->info_flags = 0; if (chip->caps & ES18XX_DUPLEX_SAME) pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index 1cc89fb..bae0fee 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -727,13 +727,6 @@ static int snd_gf1_pcm_capture_close(snd_pcm_substream_t * substream) return 0; } -static void snd_gf1_pcm_free(snd_pcm_t *pcm) -{ - snd_gus_card_t *gus = pcm->private_data; - gus->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int snd_gf1_pcm_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -860,7 +853,6 @@ int snd_gf1_pcm_new(snd_gus_card_t * gus, int pcm_dev, int control_index, snd_pc if (err < 0) return err; pcm->private_data = gus; - pcm->private_free = snd_gf1_pcm_free; /* playback setup */ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_gf1_pcm_playback_ops); diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index b94339f..1be3299 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -1346,13 +1346,6 @@ static snd_pcm_ops_t snd_opti93x_capture_ops = { .pointer = snd_opti93x_capture_pointer, }; -static void snd_opti93x_pcm_free(snd_pcm_t *pcm) -{ - opti93x_t *codec = pcm->private_data; - codec->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm) { int error; @@ -1365,7 +1358,6 @@ static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_opti93x_capture_ops); pcm->private_data = codec; - pcm->private_free = snd_opti93x_pcm_free; pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, snd_opti93x_chip_id(codec)); diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 556b95e..17312e0 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -851,11 +851,6 @@ static snd_pcm_ops_t snd_sb16_capture_ops = { .pointer = snd_sb16_capture_pointer, }; -static void snd_sb16dsp_pcm_free(snd_pcm_t *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm) { snd_card_t *card = chip->card; @@ -869,7 +864,6 @@ int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm) sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff); pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; pcm->private_data = chip; - pcm->private_free = snd_sb16dsp_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops); diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 5ddc6e4..28d8afd 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -507,11 +507,6 @@ static snd_pcm_ops_t snd_sb8_capture_ops = { .pointer = snd_sb8_capture_pointer, }; -static void snd_sb8dsp_pcm_free(snd_pcm_t *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm) { snd_card_t *card = chip->card; @@ -525,7 +520,6 @@ int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm) sprintf(pcm->name, "DSP v%i.%i", chip->version >> 8, chip->version & 0xff); pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX; pcm->private_data = chip; - pcm->private_free = snd_sb8dsp_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb8_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb8_capture_ops); diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 1fdae67..999aaea 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -623,14 +623,6 @@ snd_ad1889_interrupt(int irq, return IRQ_HANDLED; } -static void -snd_ad1889_pcm_free(snd_pcm_t *pcm) -{ - struct snd_ad1889 *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, snd_pcm_t **rpcm) { @@ -650,7 +642,6 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, snd_pcm_t **rpcm) &snd_ad1889_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_ad1889_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, chip->card->shortname); diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 1904df6..d496cc5a 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -490,13 +490,6 @@ static snd_pcm_ops_t snd_als4000_capture_ops = { .pointer = snd_als4000_capture_pointer }; -static void snd_als4000_pcm_free(snd_pcm_t *pcm) -{ - sb_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_als4000_pcm(sb_t *chip, int device) { snd_pcm_t *pcm; @@ -504,7 +497,6 @@ static int __devinit snd_als4000_pcm(sb_t *chip, int device) if ((err = snd_pcm_new(chip->card, "ALS4000 DSP", device, 1, 1, &pcm)) < 0) return err; - pcm->private_free = snd_als4000_pcm_free; pcm->private_data = chip; pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_als4000_playback_ops); diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index ab737d6..96d1ba0 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1365,14 +1365,6 @@ static snd_pcm_ops_t snd_azf3328_capture_ops = { .pointer = snd_azf3328_capture_pointer }; -static void -snd_azf3328_pcm_free(snd_pcm_t *pcm) -{ - azf3328_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_azf3328_pcm(azf3328_t *chip, int device) { @@ -1386,7 +1378,6 @@ snd_azf3328_pcm(azf3328_t *chip, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_azf3328_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_azf3328_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, chip->card->shortname); chip->pcm = pcm; diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 389d967..a89eed2 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1069,13 +1069,6 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, return IRQ_HANDLED; } -static void snd_ca0106_pcm_free(snd_pcm_t *pcm) -{ - ca0106_t *emu = pcm->private_data; - emu->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) { snd_pcm_t *pcm; @@ -1088,7 +1081,6 @@ static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) return err; pcm->private_data = emu; - pcm->private_free = snd_ca0106_pcm_free; switch (device) { case 0: diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index db60537..0309689 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -1693,11 +1693,6 @@ static snd_pcm_ops_t snd_cmipci_capture_spdif_ops = { /* */ -static void snd_cmipci_pcm_free(snd_pcm_t *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_cmipci_pcm_new(cmipci_t *cm, int device) { snd_pcm_t *pcm; @@ -1711,7 +1706,6 @@ static int __devinit snd_cmipci_pcm_new(cmipci_t *cm, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cmipci_capture_ops); pcm->private_data = cm; - pcm->private_free = snd_cmipci_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, "C-Media PCI DAC/ADC"); cm->pcm = pcm; @@ -1734,7 +1728,6 @@ static int __devinit snd_cmipci_pcm2_new(cmipci_t *cm, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cmipci_playback2_ops); pcm->private_data = cm; - pcm->private_free = snd_cmipci_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, "C-Media PCI 2nd DAC"); cm->pcm2 = pcm; @@ -1758,7 +1751,6 @@ static int __devinit snd_cmipci_pcm_spdif_new(cmipci_t *cm, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cmipci_capture_spdif_ops); pcm->private_data = cm; - pcm->private_free = snd_cmipci_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, "C-Media PCI IEC958"); cm->pcm_spdif = pcm; diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 034ff37..a4b4608 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -990,13 +990,6 @@ static snd_pcm_ops_t snd_cs4281_capture_ops = { .pointer = snd_cs4281_pointer, }; -static void snd_cs4281_pcm_free(snd_pcm_t *pcm) -{ - cs4281_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_cs4281_pcm(cs4281_t * chip, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1012,7 +1005,6 @@ static int __devinit snd_cs4281_pcm(cs4281_t * chip, int device, snd_pcm_t ** rp snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cs4281_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_cs4281_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, "CS4281"); chip->pcm = pcm; diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 9b8af5b..9a86148 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -1574,35 +1574,7 @@ static snd_pcm_ops_t snd_cs46xx_capture_indirect_ops = { .ack = snd_cs46xx_capture_transfer, }; -static void snd_cs46xx_pcm_free(snd_pcm_t *pcm) -{ - cs46xx_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - #ifdef CONFIG_SND_CS46XX_NEW_DSP -static void snd_cs46xx_pcm_rear_free(snd_pcm_t *pcm) -{ - cs46xx_t *chip = pcm->private_data; - chip->pcm_rear = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static void snd_cs46xx_pcm_center_lfe_free(snd_pcm_t *pcm) -{ - cs46xx_t *chip = pcm->private_data; - chip->pcm_center_lfe = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static void snd_cs46xx_pcm_iec958_free(snd_pcm_t *pcm) -{ - cs46xx_t *chip = pcm->private_data; - chip->pcm_iec958 = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - #define MAX_PLAYBACK_CHANNELS (DSP_MAX_PCM_CHANNELS - 1) #else #define MAX_PLAYBACK_CHANNELS 1 @@ -1619,7 +1591,6 @@ int __devinit snd_cs46xx_pcm(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) return err; pcm->private_data = chip; - pcm->private_free = snd_cs46xx_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs46xx_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_cs46xx_capture_ops); @@ -1652,7 +1623,6 @@ int __devinit snd_cs46xx_pcm_rear(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) return err; pcm->private_data = chip; - pcm->private_free = snd_cs46xx_pcm_rear_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs46xx_playback_rear_ops); @@ -1682,7 +1652,6 @@ int __devinit snd_cs46xx_pcm_center_lfe(cs46xx_t *chip, int device, snd_pcm_t ** return err; pcm->private_data = chip; - pcm->private_free = snd_cs46xx_pcm_center_lfe_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs46xx_playback_clfe_ops); @@ -1712,7 +1681,6 @@ int __devinit snd_cs46xx_pcm_iec958(cs46xx_t *chip, int device, snd_pcm_t ** rpc return err; pcm->private_data = chip; - pcm->private_free = snd_cs46xx_pcm_iec958_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_cs46xx_playback_iec958_ops); diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 7955777..ca402e9 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -836,13 +836,6 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id, return IRQ_HANDLED; } -static void snd_emu10k1x_pcm_free(snd_pcm_t *pcm) -{ - emu10k1x_t *emu = pcm->private_data; - emu->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **rpcm) { snd_pcm_t *pcm; @@ -858,7 +851,6 @@ static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **r return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1x_pcm_free; switch(device) { case 0: diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index bf7490d..90d3a0b 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -1249,13 +1249,6 @@ static snd_pcm_ops_t snd_emu10k1_efx_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static void snd_emu10k1_pcm_free(snd_pcm_t *pcm) -{ - emu10k1_t *emu = pcm->private_data; - emu->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int __devinit snd_emu10k1_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1269,7 +1262,6 @@ int __devinit snd_emu10k1_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_ops); @@ -1305,7 +1297,6 @@ int __devinit snd_emu10k1_pcm_multi(emu10k1_t * emu, int device, snd_pcm_t ** rp return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_efx_playback_ops); @@ -1336,13 +1327,6 @@ static snd_pcm_ops_t snd_emu10k1_capture_mic_ops = { .pointer = snd_emu10k1_capture_pointer, }; -static void snd_emu10k1_pcm_mic_free(snd_pcm_t *pcm) -{ - emu10k1_t *emu = pcm->private_data; - emu->pcm_mic = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int __devinit snd_emu10k1_pcm_mic(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1355,7 +1339,6 @@ int __devinit snd_emu10k1_pcm_mic(emu10k1_t * emu, int device, snd_pcm_t ** rpcm return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1_pcm_mic_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_mic_ops); @@ -1673,13 +1656,6 @@ static snd_pcm_ops_t snd_emu10k1_fx8010_playback_ops = { .ack = snd_emu10k1_fx8010_playback_transfer, }; -static void snd_emu10k1_pcm_efx_free(snd_pcm_t *pcm) -{ - emu10k1_t *emu = pcm->private_data; - emu->pcm_efx = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int __devinit snd_emu10k1_pcm_efx(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1693,7 +1669,6 @@ int __devinit snd_emu10k1_pcm_efx(emu10k1_t * emu, int device, snd_pcm_t ** rpcm return err; pcm->private_data = emu; - pcm->private_free = snd_emu10k1_pcm_efx_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_emu10k1_fx8010_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_emu10k1_capture_efx_ops); diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index e27ebb9..3b45600 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -587,14 +587,6 @@ int snd_p16v_free(emu10k1_t *chip) return 0; } -static void snd_p16v_pcm_free(snd_pcm_t *pcm) -{ - emu10k1_t *emu = pcm->private_data; - //snd_printk("snd_p16v_pcm_free pcm: called\n"); - snd_pcm_lib_preallocate_free_for_all(pcm); - emu->pcm = NULL; -} - int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) { snd_pcm_t *pcm; @@ -611,7 +603,6 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) return err; pcm->private_data = emu; - pcm->private_free = snd_p16v_pcm_free; // Single playback 8 channel device. // Single capture 2 channel device. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_p16v_playback_front_ops); diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index fa619a9..180c49e 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -1214,13 +1214,6 @@ static snd_pcm_ops_t snd_ensoniq_capture_ops = { .pointer = snd_ensoniq_capture_pointer, }; -static void snd_ensoniq_pcm_free(snd_pcm_t *pcm) -{ - ensoniq_t *ensoniq = pcm->private_data; - ensoniq->pcm1 = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_ensoniq_pcm(ensoniq_t * ensoniq, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1244,7 +1237,6 @@ static int __devinit snd_ensoniq_pcm(ensoniq_t * ensoniq, int device, snd_pcm_t snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ensoniq_capture_ops); pcm->private_data = ensoniq; - pcm->private_free = snd_ensoniq_pcm_free; pcm->info_flags = 0; #ifdef CHIP1370 strcpy(pcm->name, "ES1370 DAC2/ADC"); @@ -1261,13 +1253,6 @@ static int __devinit snd_ensoniq_pcm(ensoniq_t * ensoniq, int device, snd_pcm_t return 0; } -static void snd_ensoniq_pcm_free2(snd_pcm_t *pcm) -{ - ensoniq_t *ensoniq = pcm->private_data; - ensoniq->pcm2 = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_ensoniq_pcm2(ensoniq_t * ensoniq, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1289,7 +1274,6 @@ static int __devinit snd_ensoniq_pcm2(ensoniq_t * ensoniq, int device, snd_pcm_t snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ensoniq_playback2_ops); #endif pcm->private_data = ensoniq; - pcm->private_free = snd_ensoniq_pcm_free2; pcm->info_flags = 0; #ifdef CHIP1370 strcpy(pcm->name, "ES1370 DAC1"); diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index c134f48..d05c3d2b 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1000,11 +1000,6 @@ static snd_pcm_ops_t snd_es1938_capture_ops = { .copy = snd_es1938_capture_copy, }; -static void snd_es1938_free_pcm(snd_pcm_t *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_es1938_new_pcm(es1938_t *chip, int device) { snd_pcm_t *pcm; @@ -1016,7 +1011,6 @@ static int __devinit snd_es1938_new_pcm(es1938_t *chip, int device) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_es1938_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_es1938_free_pcm; pcm->info_flags = 0; strcpy(pcm->name, "ESS Solo-1"); diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 4e1d343..261061b 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -665,13 +665,6 @@ static snd_pcm_ops_t snd_fm801_capture_ops = { .pointer = snd_fm801_capture_pointer, }; -static void snd_fm801_pcm_free(snd_pcm_t *pcm) -{ - fm801_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_fm801_pcm(fm801_t *chip, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -686,7 +679,6 @@ static int __devinit snd_fm801_pcm(fm801_t *chip, int device, snd_pcm_t ** rpcm) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_fm801_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_fm801_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, "FM801"); chip->pcm = pcm; diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index bd71bf4..b16c9c1 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -859,13 +859,6 @@ static snd_pcm_ops_t snd_ice1712_capture_ops = { .pointer = snd_ice1712_capture_pointer, }; -static void snd_ice1712_pcm_free(snd_pcm_t *pcm) -{ - ice1712_t *ice = pcm->private_data; - ice->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_ice1712_pcm(ice1712_t * ice, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -881,7 +874,6 @@ static int __devinit snd_ice1712_pcm(ice1712_t * ice, int device, snd_pcm_t ** r snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ice1712_capture_ops); pcm->private_data = ice; - pcm->private_free = snd_ice1712_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, "ICE1712 consumer"); ice->pcm = pcm; @@ -897,13 +889,6 @@ static int __devinit snd_ice1712_pcm(ice1712_t * ice, int device, snd_pcm_t ** r return 0; } -static void snd_ice1712_pcm_free_ds(snd_pcm_t *pcm) -{ - ice1712_t *ice = pcm->private_data; - ice->pcm_ds = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_ice1712_pcm_ds(ice1712_t * ice, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -918,7 +903,6 @@ static int __devinit snd_ice1712_pcm_ds(ice1712_t * ice, int device, snd_pcm_t * snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ice1712_playback_ds_ops); pcm->private_data = ice; - pcm->private_free = snd_ice1712_pcm_free_ds; pcm->info_flags = 0; strcpy(pcm->name, "ICE1712 consumer (DS)"); ice->pcm_ds = pcm; @@ -1223,13 +1207,6 @@ static int snd_ice1712_capture_pro_close(snd_pcm_substream_t * substream) return 0; } -static void snd_ice1712_pcm_profi_free(snd_pcm_t *pcm) -{ - ice1712_t *ice = pcm->private_data; - ice->pcm_pro = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static snd_pcm_ops_t snd_ice1712_playback_pro_ops = { .open = snd_ice1712_playback_pro_open, .close = snd_ice1712_playback_pro_close, @@ -1267,7 +1244,6 @@ static int __devinit snd_ice1712_pcm_profi(ice1712_t * ice, int device, snd_pcm_ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ice1712_capture_pro_ops); pcm->private_data = ice; - pcm->private_free = snd_ice1712_pcm_profi_free; pcm->info_flags = 0; strcpy(pcm->name, "ICE1712 multi"); diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index a1aef6f..ae2013a 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -3336,15 +3336,6 @@ static int __devinit snd_hdspm_preallocate_memory(hdspm_t * hdspm) return 0; } -static int snd_hdspm_memory_free(hdspm_t * hdspm) -{ - snd_printdd("memory_free_for_all %p\n", hdspm->pcm); - - snd_pcm_lib_preallocate_free_for_all(hdspm->pcm); - return 0; -} - - static void hdspm_set_sgbuf(hdspm_t * hdspm, struct snd_sg_buf *sgbuf, unsigned int reg, int channels) { @@ -3568,8 +3559,6 @@ static int snd_hdspm_free(hdspm_t * hdspm) if (hdspm->iobase) iounmap(hdspm->iobase); - snd_hdspm_memory_free(hdspm); - if (hdspm->port) pci_release_regions(hdspm->pci); diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index e92ef3a..b66459f 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -844,13 +844,6 @@ static snd_pcm_ops_t snd_sonicvibes_capture_ops = { .pointer = snd_sonicvibes_capture_pointer, }; -static void snd_sonicvibes_pcm_free(snd_pcm_t *pcm) -{ - sonicvibes_t *sonic = pcm->private_data; - sonic->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __devinit snd_sonicvibes_pcm(sonicvibes_t * sonic, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -864,7 +857,6 @@ static int __devinit snd_sonicvibes_pcm(sonicvibes_t * sonic, int device, snd_pc snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sonicvibes_capture_ops); pcm->private_data = sonic; - pcm->private_free = snd_sonicvibes_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, "S3 SonicVibes"); sonic->pcm = pcm; diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index b9b93c7..62f109f 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -2118,37 +2118,6 @@ static snd_pcm_ops_t snd_trident_spdif_7018_ops = { }; /*--------------------------------------------------------------------------- - snd_trident_pcm_free - - Description: This routine release the 4DWave private data. - - Paramters: private_data - pointer to 4DWave device info. - - Returns: None - - ---------------------------------------------------------------------------*/ -static void snd_trident_pcm_free(snd_pcm_t *pcm) -{ - trident_t *trident = pcm->private_data; - trident->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static void snd_trident_foldback_pcm_free(snd_pcm_t *pcm) -{ - trident_t *trident = pcm->private_data; - trident->foldback = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -static void snd_trident_spdif_pcm_free(snd_pcm_t *pcm) -{ - trident_t *trident = pcm->private_data; - trident->spdif = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - -/*--------------------------------------------------------------------------- snd_trident_pcm Description: This routine registers the 4DWave device for PCM support. @@ -2170,7 +2139,6 @@ int __devinit snd_trident_pcm(trident_t * trident, int device, snd_pcm_t ** rpcm return err; pcm->private_data = trident; - pcm->private_free = snd_trident_pcm_free; if (trident->tlb.entries) { snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_trident_nx_playback_ops); @@ -2232,7 +2200,6 @@ int __devinit snd_trident_foldback_pcm(trident_t * trident, int device, snd_pcm_ return err; foldback->private_data = trident; - foldback->private_free = snd_trident_foldback_pcm_free; if (trident->tlb.entries) snd_pcm_set_ops(foldback, SNDRV_PCM_STREAM_CAPTURE, &snd_trident_nx_foldback_ops); else @@ -2285,7 +2252,6 @@ int __devinit snd_trident_spdif_pcm(trident_t * trident, int device, snd_pcm_t * return err; spdif->private_data = trident; - spdif->private_free = snd_trident_spdif_pcm_free; if (trident->device != TRIDENT_DEVICE_ID_SI7018) { snd_pcm_set_ops(spdif, SNDRV_PCM_STREAM_PLAYBACK, &snd_trident_spdif_ops); } else { diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 88a43e0..8229703 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -1071,13 +1071,6 @@ static snd_pcm_ops_t snd_ymfpci_capture_rec_ops = { .pointer = snd_ymfpci_capture_pointer, }; -static void snd_ymfpci_pcm_free(snd_pcm_t *pcm) -{ - ymfpci_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int __devinit snd_ymfpci_pcm(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1088,7 +1081,6 @@ int __devinit snd_ymfpci_pcm(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) if ((err = snd_pcm_new(chip->card, "YMFPCI", device, 32, 1, &pcm)) < 0) return err; pcm->private_data = chip; - pcm->private_free = snd_ymfpci_pcm_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ymfpci_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ymfpci_capture_rec_ops); @@ -1117,13 +1109,6 @@ static snd_pcm_ops_t snd_ymfpci_capture_ac97_ops = { .pointer = snd_ymfpci_capture_pointer, }; -static void snd_ymfpci_pcm2_free(snd_pcm_t *pcm) -{ - ymfpci_t *chip = pcm->private_data; - chip->pcm2 = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int __devinit snd_ymfpci_pcm2(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1134,7 +1119,6 @@ int __devinit snd_ymfpci_pcm2(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) if ((err = snd_pcm_new(chip->card, "YMFPCI - PCM2", device, 0, 1, &pcm)) < 0) return err; pcm->private_data = chip; - pcm->private_free = snd_ymfpci_pcm2_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ymfpci_capture_ac97_ops); @@ -1163,13 +1147,6 @@ static snd_pcm_ops_t snd_ymfpci_playback_spdif_ops = { .pointer = snd_ymfpci_playback_pointer, }; -static void snd_ymfpci_pcm_spdif_free(snd_pcm_t *pcm) -{ - ymfpci_t *chip = pcm->private_data; - chip->pcm_spdif = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int __devinit snd_ymfpci_pcm_spdif(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1180,7 +1157,6 @@ int __devinit snd_ymfpci_pcm_spdif(ymfpci_t *chip, int device, snd_pcm_t ** rpcm if ((err = snd_pcm_new(chip->card, "YMFPCI - IEC958", device, 1, 0, &pcm)) < 0) return err; pcm->private_data = chip; - pcm->private_free = snd_ymfpci_pcm_spdif_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ymfpci_playback_spdif_ops); @@ -1208,13 +1184,6 @@ static snd_pcm_ops_t snd_ymfpci_playback_4ch_ops = { .pointer = snd_ymfpci_playback_pointer, }; -static void snd_ymfpci_pcm_4ch_free(snd_pcm_t *pcm) -{ - ymfpci_t *chip = pcm->private_data; - chip->pcm_4ch = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int __devinit snd_ymfpci_pcm_4ch(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) { snd_pcm_t *pcm; @@ -1225,7 +1194,6 @@ int __devinit snd_ymfpci_pcm_4ch(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) if ((err = snd_pcm_new(chip->card, "YMFPCI - Rear", device, 1, 0, &pcm)) < 0) return err; pcm->private_data = chip; - pcm->private_free = snd_ymfpci_pcm_4ch_free; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ymfpci_playback_4ch_ops); diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index 20b86d8..d54033e 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c @@ -325,15 +325,6 @@ static snd_pcm_ops_t pdacf_pcm_capture_ops = { /* - * free callback for pcm - */ -static void snd_pdacf_pcm_free(snd_pcm_t *pcm) -{ - pdacf_t *chip = pcm->private_data; - chip->pcm = NULL; -} - -/* * snd_pdacf_pcm_new - create and initialize a pcm */ int snd_pdacf_pcm_new(pdacf_t *chip) @@ -348,7 +339,6 @@ int snd_pdacf_pcm_new(pdacf_t *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pdacf_pcm_capture_ops); pcm->private_data = chip; - pcm->private_free = snd_pdacf_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, chip->card->shortname); chip->pcm = pcm; diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index db2f1815..dd28187 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -637,11 +637,6 @@ static snd_pcm_ops_t snd_pmac_capture_ops = { .pointer = snd_pmac_capture_pointer, }; -static void pmac_pcm_free(snd_pcm_t *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int __init snd_pmac_pcm_new(pmac_t *chip) { snd_pcm_t *pcm; @@ -659,7 +654,6 @@ int __init snd_pmac_pcm_new(pmac_t *chip) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_pmac_capture_ops); pcm->private_data = chip; - pcm->private_free = pmac_pcm_free; pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, chip->card->shortname); chip->pcm = pcm; diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 46d504b..7d4b685 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -755,14 +755,6 @@ static snd_pcm_ops_t snd_amd7930_capture_ops = { .pointer = snd_amd7930_capture_pointer, }; -static void snd_amd7930_pcm_free(snd_pcm_t *pcm) -{ - amd7930_t *amd = pcm->private_data; - - amd->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static int __init snd_amd7930_pcm(amd7930_t *amd) { snd_pcm_t *pcm; @@ -780,7 +772,6 @@ static int __init snd_amd7930_pcm(amd7930_t *amd) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_amd7930_capture_ops); pcm->private_data = amd; - pcm->private_free = snd_amd7930_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, amd->card->shortname); amd->pcm = pcm; diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 1f8d27a..0fa482c 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1385,13 +1385,6 @@ static snd_pcm_ops_t snd_cs4231_capture_ops = { .pointer = snd_cs4231_capture_pointer, }; -static void snd_cs4231_pcm_free(snd_pcm_t *pcm) -{ - cs4231_t *chip = pcm->private_data; - chip->pcm = NULL; - snd_pcm_lib_preallocate_free_for_all(pcm); -} - int snd_cs4231_pcm(cs4231_t *chip) { snd_pcm_t *pcm; @@ -1405,7 +1398,6 @@ int snd_cs4231_pcm(cs4231_t *chip) /* global setup */ pcm->private_data = chip; - pcm->private_free = snd_cs4231_pcm_free; pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, "CS4231"); diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index affda97..c5989cb 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -941,10 +941,8 @@ static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream) static void snd_usX2Y_pcm_private_free(snd_pcm_t *pcm) { snd_usX2Y_substream_t **usX2Y_stream = pcm->private_data; - if (usX2Y_stream) { - snd_pcm_lib_preallocate_free_for_all(pcm); + if (usX2Y_stream) usX2Y_audio_stream_free(usX2Y_stream); - } } static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int capture_endpoint) diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index c9136a9..4bbf52b 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -740,12 +740,6 @@ static void snd_usX2Y_hwdep_pcm_private_free(snd_hwdep_t *hwdep) } -static void snd_usX2Y_usbpcm_private_free(snd_pcm_t *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - - int usX2Y_hwdep_pcm_new(snd_card_t* card) { int err; @@ -776,7 +770,6 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card) snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_usX2Y_usbpcm_ops); pcm->private_data = usX2Y(card)->subs; - pcm->private_free = snd_usX2Y_usbpcm_private_free; pcm->info_flags = 0; sprintf(pcm->name, NAME_ALLCAPS" hwdep Audio"); @@ -788,7 +781,6 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card) SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_KERNEL), 64*1024, 128*1024))) { - snd_usX2Y_usbpcm_private_free(pcm); return err; } -- cgit v1.1 From 9b4ffa48ae855c8657a36014c5b0243ff69f4722 Mon Sep 17 00:00:00 2001 From: Jaya Kumar <jayakumar.alsa@gmail.com> Date: Thu, 17 Nov 2005 10:12:23 +0100 Subject: [ALSA] Add support for the CS5535 Audio device Add support for the CS5535 Audio device. I've fixed up some errors as per Takashi's advice from the thread: http://lkml.org/lkml/2005/9/15/119 From: Alan Cox <alan@lxorguk.ukuu.org.uk> cs5535 is a 32bit x86 only device using weird CPU features Signed-off-by: Jaya Kumar <jayakumar.alsa@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> --- CREDITS | 1 + MAINTAINERS | 5 + include/linux/pci_ids.h | 4 + sound/pci/Kconfig | 13 + sound/pci/Makefile | 1 + sound/pci/cs5535audio/Makefile | 8 + sound/pci/cs5535audio/cs5535audio.c | 410 ++++++++++++++++++++++++++++++ sound/pci/cs5535audio/cs5535audio.h | 123 +++++++++ sound/pci/cs5535audio/cs5535audio_pcm.c | 430 ++++++++++++++++++++++++++++++++ 9 files changed, 995 insertions(+) create mode 100644 sound/pci/cs5535audio/Makefile create mode 100644 sound/pci/cs5535audio/cs5535audio.c create mode 100644 sound/pci/cs5535audio/cs5535audio.h create mode 100644 sound/pci/cs5535audio/cs5535audio_pcm.c diff --git a/CREDITS b/CREDITS index 1b4f869..521f00d 100644 --- a/CREDITS +++ b/CREDITS @@ -1883,6 +1883,7 @@ N: Jaya Kumar E: jayalk@intworks.biz W: http://www.intworks.biz D: Arc monochrome LCD framebuffer driver, x86 reboot fixups +D: pirq addr, CS5535 alsa audio driver S: Gurgaon, India S: Kuala Lumpur, Malaysia diff --git a/MAINTAINERS b/MAINTAINERS index 6af6830..93f97b3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -650,6 +650,11 @@ L: linux-crypto@vger.kernel.org T: git kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6.git S: Maintained +CS5535 Audio ALSA driver +P: Jaya Kumar +M: jayakumar.alsa@gmail.com +S: Maintained + CYBERPRO FB DRIVER P: Russell King M: rmk@arm.linux.org.uk diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 4db67b3..9093f11 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -376,6 +376,10 @@ #define PCI_DEVICE_ID_NS_87560_USB 0x0012 #define PCI_DEVICE_ID_NS_83815 0x0020 #define PCI_DEVICE_ID_NS_83820 0x0022 +#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d +#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e +#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f +#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 #define PCI_DEVICE_ID_NS_SATURN 0x0035 #define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500 #define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501 diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 0fb16cf..920305c 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -359,6 +359,19 @@ config SND_ENS1370 To compile this driver as a module, choose M here: the module will be called snd-ens1370. +config SND_CS5535AUDIO + tristate "CS5535 Audio" + depends on SND && X86 && !X86_64 + select SND_PCM + select SND_AC97_CODEC + help + Say Y here to include support for audio on CS5535 chips. It is + referred to as NS CS5535 IO or AMD CS5535 IO companion in + various literature. + + To compile this driver as a module, choose M here: the module + will be called snd-cs5535audio. + config SND_ENS1371 tristate "(Creative) Ensoniq AudioPCI 1371/1373" depends on SND diff --git a/sound/pci/Makefile b/sound/pci/Makefile index 42fabfc..82a9c73 100644 --- a/sound/pci/Makefile +++ b/sound/pci/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_SND) += \ au88x0/ \ ca0106/ \ cs46xx/ \ + cs5535audio/ \ emu10k1/ \ hda/ \ ice1712/ \ diff --git a/sound/pci/cs5535audio/Makefile b/sound/pci/cs5535audio/Makefile new file mode 100644 index 0000000..08d8ee6 --- /dev/null +++ b/sound/pci/cs5535audio/Makefile @@ -0,0 +1,8 @@ +# +# Makefile for cs5535audio +# + +snd-cs5535audio-objs := cs5535audio.o cs5535audio_pcm.o + +# Toplevel Module Dependency +obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c new file mode 100644 index 0000000..920c857 --- /dev/null +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -0,0 +1,410 @@ +/* + * Driver for audio on multifunction CS5535 companion device + * Copyright (C) Jaya Kumar + * + * Based on Jaroslav Kysela and Takashi Iwai's examples. + * This work was sponsored by CIS(M) Sdn Bhd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <linux/delay.h> +#include <linux/interrupt.h> +#include <linux/init.h> +#include <linux/pci.h> +#include <linux/slab.h> +#include <linux/moduleparam.h> +#include <asm/io.h> +#include <sound/driver.h> +#include <sound/core.h> +#include <sound/control.h> +#include <sound/pcm.h> +#include <sound/rawmidi.h> +#include <sound/ac97_codec.h> +#include <sound/initval.h> +#include <sound/asoundef.h> +#include "cs5535audio.h" + +#define DRIVER_NAME "cs5535audio" + + +static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; +static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; +static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; + +static struct pci_device_id snd_cs5535audio_ids[] = { + { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_AUDIO, PCI_ANY_ID, + PCI_ANY_ID, 0, 0, 0, }, + {} +}; + +MODULE_DEVICE_TABLE(pci, snd_cs5535audio_ids); + +static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout) +{ + unsigned long tmp; + do { + tmp = cs_readl(cs5535au, ACC_CODEC_CNTL); + if (!(tmp & CMD_NEW)) + break; + msleep(10); + } while (--timeout); + if (!timeout) + snd_printk(KERN_ERR "Failure writing to cs5535 codec\n"); +} + +static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au, + unsigned short reg) +{ + unsigned long regdata; + unsigned long timeout; + unsigned long val; + + regdata = ((unsigned long) reg) << 24; + regdata |= ACC_CODEC_CNTL_RD_CMD; + regdata |= CMD_NEW; + + cs_writel(cs5535au, ACC_CODEC_CNTL, regdata); + wait_till_cmd_acked(cs5535au, 500); + + timeout = 50; + do { + val = cs_readl(cs5535au, ACC_CODEC_STATUS); + if ( (val & STS_NEW) && + ((unsigned long) reg == ((0xFF000000 & val)>>24)) ) + break; + msleep(10); + } while (--timeout); + if (!timeout) + snd_printk(KERN_ERR "Failure reading cs5535 codec\n"); + + return ((unsigned short) val); +} + +static void snd_cs5535audio_codec_write(cs5535audio_t *cs5535au, + unsigned short reg, unsigned short val) +{ + unsigned long regdata; + + regdata = ((unsigned long) reg) << 24; + regdata |= (unsigned long) val; + regdata &= CMD_MASK; + regdata |= CMD_NEW; + regdata &= ACC_CODEC_CNTL_WR_CMD; + + cs_writel(cs5535au, ACC_CODEC_CNTL, regdata); + wait_till_cmd_acked(cs5535au, 50); +} + +static void snd_cs5535audio_ac97_codec_write(ac97_t *ac97, + unsigned short reg, unsigned short val) +{ + cs5535audio_t *cs5535au = ac97->private_data; + snd_cs5535audio_codec_write(cs5535au, reg, val); +} + +static unsigned short snd_cs5535audio_ac97_codec_read(ac97_t *ac97, + unsigned short reg) +{ + cs5535audio_t *cs5535au = ac97->private_data; + return snd_cs5535audio_codec_read(cs5535au, reg); +} + +static void snd_cs5535audio_mixer_free_ac97(ac97_t *ac97) +{ + cs5535audio_t *cs5535audio = ac97->private_data; + cs5535audio->ac97 = NULL; +} + +static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au) +{ + snd_card_t *card = cs5535au->card; + ac97_bus_t *pbus; + ac97_template_t ac97; + int err; + static ac97_bus_ops_t ops = { + .write = snd_cs5535audio_ac97_codec_write, + .read = snd_cs5535audio_ac97_codec_read, + }; + + if ((err = snd_ac97_bus(card, 0, &ops, NULL, &pbus)) < 0) + return err; + + memset(&ac97, 0, sizeof(ac97)); + ac97.scaps = AC97_SCAP_AUDIO|AC97_SCAP_SKIP_MODEM; + ac97.private_data = cs5535au; + ac97.pci = cs5535au->pci; + ac97.private_free = snd_cs5535audio_mixer_free_ac97; + + if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { + snd_printk("mixer failed\n"); + return err; + } + + return 0; +} + +static void process_bm0_irq(cs5535audio_t *cs5535au) +{ + u8 bm_stat; + spin_lock(&cs5535au->reg_lock); + bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS); + spin_unlock(&cs5535au->reg_lock); + if (bm_stat & EOP) { + cs5535audio_dma_t *dma; + dma = cs5535au->playback_substream->runtime->private_data; + snd_pcm_period_elapsed(cs5535au->playback_substream); + } else { + snd_printk(KERN_ERR "unexpected bm0 irq src, bm_stat=%x\n", + bm_stat); + } +} + +static void process_bm1_irq(cs5535audio_t *cs5535au) +{ + u8 bm_stat; + spin_lock(&cs5535au->reg_lock); + bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS); + spin_unlock(&cs5535au->reg_lock); + if (bm_stat & EOP) { + cs5535audio_dma_t *dma; + dma = cs5535au->capture_substream->runtime->private_data; + snd_pcm_period_elapsed(cs5535au->capture_substream); + } +} + +static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id, + struct pt_regs *regs) +{ + u16 acc_irq_stat; + u8 bm_stat; + unsigned char count; + cs5535audio_t *cs5535au = dev_id; + + if (cs5535au == NULL) + return IRQ_NONE; + + acc_irq_stat = cs_readw(cs5535au, ACC_IRQ_STATUS); + + if (!acc_irq_stat) + return IRQ_NONE; + for (count=0; count < 10; count++) { + if (acc_irq_stat & (1<<count)) { + switch (count) { + case IRQ_STS: + cs_readl(cs5535au, ACC_GPIO_STATUS); + break; + case WU_IRQ_STS: + cs_readl(cs5535au, ACC_GPIO_STATUS); + break; + case BM0_IRQ_STS: + process_bm0_irq(cs5535au); + break; + case BM1_IRQ_STS: + process_bm1_irq(cs5535au); + break; + case BM2_IRQ_STS: + bm_stat = cs_readb(cs5535au, ACC_BM2_STATUS); + break; + case BM3_IRQ_STS: + bm_stat = cs_readb(cs5535au, ACC_BM3_STATUS); + break; + case BM4_IRQ_STS: + bm_stat = cs_readb(cs5535au, ACC_BM4_STATUS); + break; + case BM5_IRQ_STS: + bm_stat = cs_readb(cs5535au, ACC_BM5_STATUS); + break; + case BM6_IRQ_STS: + bm_stat = cs_readb(cs5535au, ACC_BM6_STATUS); + break; + case BM7_IRQ_STS: + bm_stat = cs_readb(cs5535au, ACC_BM7_STATUS); + break; + default: + snd_printk(KERN_ERR "Unexpected irq src\n"); + break; + } + } + } + return IRQ_HANDLED; +} + +static int snd_cs5535audio_free(cs5535audio_t *cs5535au) +{ + synchronize_irq(cs5535au->irq); + pci_set_power_state(cs5535au->pci, 3); + + if (cs5535au->irq >= 0) + free_irq(cs5535au->irq, cs5535au); + + pci_release_regions(cs5535au->pci); + pci_disable_device(cs5535au->pci); + kfree(cs5535au); + return 0; +} + +static int snd_cs5535audio_dev_free(snd_device_t *device) +{ + cs5535audio_t *cs5535au = device->device_data; + return snd_cs5535audio_free(cs5535au); +} + +static int __devinit snd_cs5535audio_create(snd_card_t *card, + struct pci_dev *pci, + cs5535audio_t **rcs5535au) +{ + cs5535audio_t *cs5535au; + + int err; + static snd_device_ops_t ops = { + .dev_free = snd_cs5535audio_dev_free, + }; + + *rcs5535au = NULL; + if ((err = pci_enable_device(pci)) < 0) + return err; + + if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 || + pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { + printk(KERN_WARNING "unable to get 32bit dma\n"); + err = -ENXIO; + goto pcifail; + } + + cs5535au = kzalloc(sizeof(*cs5535au), GFP_KERNEL); + if (cs5535au == NULL) { + err = -ENOMEM; + goto pcifail; + } + + spin_lock_init(&cs5535au->reg_lock); + cs5535au->card = card; + cs5535au->pci = pci; + cs5535au->irq = -1; + + if ((err = pci_request_regions(pci, "CS5535 Audio")) < 0) { + kfree(cs5535au); + goto pcifail; + } + + cs5535au->port = pci_resource_start(pci, 0); + + if (request_irq(pci->irq, snd_cs5535audio_interrupt, + SA_INTERRUPT|SA_SHIRQ, "CS5535 Audio", cs5535au)) { + snd_printk("unable to grab IRQ %d\n", pci->irq); + err = -EBUSY; + goto sndfail; + } + + cs5535au->irq = pci->irq; + pci_set_master(pci); + + if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, + cs5535au, &ops)) < 0) + goto sndfail; + + snd_card_set_dev(card, &pci->dev); + + *rcs5535au = cs5535au; + return 0; + +sndfail: /* leave the device alive, just kill the snd */ + snd_cs5535audio_free(cs5535au); + return err; + +pcifail: + pci_disable_device(pci); + return err; +} + +static int __devinit snd_cs5535audio_probe(struct pci_dev *pci, + const struct pci_device_id *pci_id) +{ + static int dev; + snd_card_t *card; + cs5535audio_t *cs5535au; + int err; + + if (dev >= SNDRV_CARDS) + return -ENODEV; + if (!enable[dev]) { + dev++; + return -ENOENT; + } + + card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + if (card == NULL) + return -ENOMEM; + + if ((err = snd_cs5535audio_create(card, pci, &cs5535au)) < 0) + goto probefail_out; + + if ((err = snd_cs5535audio_mixer(cs5535au)) < 0) + goto probefail_out; + + if ((err = snd_cs5535audio_pcm(cs5535au)) < 0) + goto probefail_out; + + strcpy(card->driver, DRIVER_NAME); + + strcpy(card->shortname, "CS5535 Audio"); + sprintf(card->longname, "%s %s at 0x%lx, irq %i", + card->shortname, card->driver, + cs5535au->port, cs5535au->irq); + + if ((err = snd_card_register(card)) < 0) + goto probefail_out; + + pci_set_drvdata(pci, card); + dev++; + return 0; + +probefail_out: + snd_card_free(card); + return err; +} + +static void __devexit snd_cs5535audio_remove(struct pci_dev *pci) +{ + snd_card_free(pci_get_drvdata(pci)); + pci_set_drvdata(pci, NULL); +} + +static struct pci_driver driver = { + .name = DRIVER_NAME, + .id_table = snd_cs5535audio_ids, + .probe = snd_cs5535audio_probe, + .remove = __devexit_p(snd_cs5535audio_remove), +}; + +static int __init alsa_card_cs5535audio_init(void) +{ + return pci_module_init(&driver); +} + +static void __exit alsa_card_cs5535audio_exit(void) +{ + pci_unregister_driver(&driver); +} + +module_init(alsa_card_cs5535audio_init) +module_exit(alsa_card_cs5535audio_exit) + +MODULE_AUTHOR("Jaya Kumar"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("CS5535 Audio"); +MODULE_SUPPORTED_DEVICE("CS5535 Audio"); diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h new file mode 100644 index 0000000..e28177f --- /dev/null +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -0,0 +1,123 @@ +#ifndef __SOUND_CS5535AUDIO_H +#define __SOUND_CS5535AUDIO_H + +#define cs_writel(cs5535au, reg, val) outl(val, (int) cs5535au->port + reg) +#define cs_writeb(cs5535au, reg, val) outb(val, (int) cs5535au->port + reg) +#define cs_readl(cs5535au, reg) inl((unsigned short) (cs5535au->port + reg)) +#define cs_readw(cs5535au, reg) inw((unsigned short) (cs5535au->port + reg)) +#define cs_readb(cs5535au, reg) inb((unsigned short) (cs5535au->port + reg)) + +#define CS5535AUDIO_MAX_DESCRIPTORS 128 + +/* acc_codec bar0 reg addrs */ +#define ACC_GPIO_STATUS 0x00 +#define ACC_CODEC_STATUS 0x08 +#define ACC_CODEC_CNTL 0x0C +#define ACC_IRQ_STATUS 0x12 +#define ACC_BM0_CMD 0x20 +#define ACC_BM1_CMD 0x28 +#define ACC_BM2_CMD 0x30 +#define ACC_BM3_CMD 0x38 +#define ACC_BM4_CMD 0x40 +#define ACC_BM5_CMD 0x48 +#define ACC_BM6_CMD 0x50 +#define ACC_BM7_CMD 0x58 +#define ACC_BM0_PRD 0x24 +#define ACC_BM1_PRD 0x2C +#define ACC_BM2_PRD 0x34 +#define ACC_BM3_PRD 0x3C +#define ACC_BM4_PRD 0x44 +#define ACC_BM5_PRD 0x4C +#define ACC_BM6_PRD 0x54 +#define ACC_BM7_PRD 0x5C +#define ACC_BM0_STATUS 0x21 +#define ACC_BM1_STATUS 0x29 +#define ACC_BM2_STATUS 0x31 +#define ACC_BM3_STATUS 0x39 +#define ACC_BM4_STATUS 0x41 +#define ACC_BM5_STATUS 0x49 +#define ACC_BM6_STATUS 0x51 +#define ACC_BM7_STATUS 0x59 +#define ACC_BM0_PNTR 0x60 +#define ACC_BM1_PNTR 0x64 +#define ACC_BM2_PNTR 0x68 +#define ACC_BM3_PNTR 0x6C +#define ACC_BM4_PNTR 0x70 +#define ACC_BM5_PNTR 0x74 +#define ACC_BM6_PNTR 0x78 +#define ACC_BM7_PNTR 0x7C +/* acc_codec bar0 reg bits */ +/* ACC_IRQ_STATUS */ +#define IRQ_STS 0 +#define WU_IRQ_STS 1 +#define BM0_IRQ_STS 2 +#define BM1_IRQ_STS 3 +#define BM2_IRQ_STS 4 +#define BM3_IRQ_STS 5 +#define BM4_IRQ_STS 6 +#define BM5_IRQ_STS 7 +#define BM6_IRQ_STS 8 +#define BM7_IRQ_STS 9 +/* ACC_BMX_STATUS */ +#define EOP (1<<0) +#define BM_EOP_ERR (1<<1) +/* ACC_BMX_CTL */ +#define BM_CTL_EN 0x00000001 +#define BM_CTL_PAUSE 0x00000011 +#define BM_CTL_DIS 0x00000000 +#define BM_CTL_BYTE_ORD_LE 0x00000000 +#define BM_CTL_BYTE_ORD_BE 0x00000100 +/* cs5535 specific ac97 codec register defines */ +#define CMD_MASK 0xFF00FFFF +#define CMD_NEW 0x00010000 +#define STS_NEW 0x00020000 +#define PRM_RDY_STS 0x00800000 +#define ACC_CODEC_CNTL_WR_CMD (~0x80000000) +#define ACC_CODEC_CNTL_RD_CMD 0x80000000 +#define PRD_JMP 0x2000 +#define PRD_EOP 0x4000 +#define PRD_EOT 0x8000 + +typedef struct _snd_cs5535audio cs5535audio_t; +typedef struct snd_cs5535audio_dma cs5535audio_dma_t; +typedef struct snd_cs5535audio_dma_ops cs5535audio_dma_ops_t; + +enum { CS5535AUDIO_DMA_PLAYBACK, CS5535AUDIO_DMA_CAPTURE, NUM_CS5535AUDIO_DMAS }; +struct snd_cs5535audio_dma_ops { + int type; + void (*enable_dma)(cs5535audio_t *cs5535au); + void (*disable_dma)(cs5535audio_t *cs5535au); + void (*pause_dma)(cs5535audio_t *cs5535au); + void (*setup_prd)(cs5535audio_t *cs5535au, u32 prd_addr); + u32 (*read_dma_pntr)(cs5535audio_t *cs5535au); +}; + +typedef struct cs5535audio_dma_desc { + u32 addr; + u16 size; + u16 ctlreserved; +} cs5535audio_dma_desc_t; + +struct snd_cs5535audio_dma { + const cs5535audio_dma_ops_t *ops; + struct snd_dma_buffer desc_buf; + snd_pcm_substream_t *substream; + unsigned int buf_addr, buf_bytes; + unsigned int period_bytes, periods; +}; + +struct _snd_cs5535audio { + snd_card_t *card; + ac97_t *ac97; + int irq; + struct pci_dev *pci; + unsigned long port; + spinlock_t reg_lock; + snd_pcm_substream_t *playback_substream; + snd_pcm_substream_t *capture_substream; + cs5535audio_dma_t dmas[NUM_CS5535AUDIO_DMAS]; +}; + +int __devinit snd_cs5535audio_pcm(cs5535audio_t *cs5535audio); +#endif /* __SOUND_CS5535AUDIO_H */ + diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c new file mode 100644 index 0000000..5802ed9 --- /dev/null +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -0,0 +1,430 @@ +/* + * Driver for audio on multifunction CS5535 companion device + * Copyright (C) Jaya Kumar + * + * Based on Jaroslav Kysela and Takashi Iwai's examples. + * This work was sponsored by CIS(M) Sdn Bhd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * todo: add be fmt support, spdif, pm + */ + +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/pci.h> +#include <sound/driver.h> +#include <sound/core.h> +#include <sound/control.h> +#include <sound/initval.h> +#include <sound/asoundef.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <sound/ac97_codec.h> +#include "cs5535audio.h" + +static snd_pcm_hardware_t snd_cs5535audio_playback = +{ + .info = ( + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_PAUSE | + SNDRV_PCM_INFO_SYNC_START + ), + .formats = ( + SNDRV_PCM_FMTBIT_S16_LE + ), + .rates = ( + SNDRV_PCM_RATE_CONTINUOUS | + SNDRV_PCM_RATE_8000_48000 + ), + .rate_min = 4000, + .rate_max = 48000, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = (128*1024), + .period_bytes_min = 64, + .period_bytes_max = (64*1024 - 16), + .periods_min = 1, + .periods_max = CS5535AUDIO_MAX_DESCRIPTORS, + .fifo_size = 0, +}; + +static snd_pcm_hardware_t snd_cs5535audio_capture = +{ + .info = ( + SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_SYNC_START + ), + .formats = ( + SNDRV_PCM_FMTBIT_S16_LE + ), + .rates = ( + SNDRV_PCM_RATE_CONTINUOUS | + SNDRV_PCM_RATE_8000_48000 + ), + .rate_min = 4000, + .rate_max = 48000, + .channels_min = 2, + .channels_max = 2, + .buffer_bytes_max = (128*1024), + .period_bytes_min = 64, + .period_bytes_max = (64*1024 - 16), + .periods_min = 1, + .periods_max = CS5535AUDIO_MAX_DESCRIPTORS, + .fifo_size = 0, +}; + +static int snd_cs5535audio_playback_open(snd_pcm_substream_t *substream) +{ + int err; + cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + snd_pcm_runtime_t *runtime = substream->runtime; + + runtime->hw = snd_cs5535audio_playback; + cs5535au->playback_substream = substream; + runtime->private_data = &(cs5535au->dmas[CS5535AUDIO_DMA_PLAYBACK]); + snd_pcm_set_sync(substream); + if ((err = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS)) < 0) + return err; + + return 0; +} + +static int snd_cs5535audio_playback_close(snd_pcm_substream_t *substream) +{ + return 0; +} + +#define CS5535AUDIO_DESC_LIST_SIZE \ + PAGE_ALIGN(CS5535AUDIO_MAX_DESCRIPTORS * sizeof(cs5535audio_dma_desc_t)) + +static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au, + cs5535audio_dma_t *dma, + snd_pcm_substream_t *substream, + unsigned int periods, + unsigned int period_bytes) +{ + unsigned int i; + u32 addr, desc_addr, jmpprd_addr; + cs5535audio_dma_desc_t *lastdesc; + + if (periods > CS5535AUDIO_MAX_DESCRIPTORS) + return -ENOMEM; + + if (dma->desc_buf.area == NULL) { + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, + snd_dma_pci_data(cs5535au->pci), + CS5535AUDIO_DESC_LIST_SIZE+1, + &dma->desc_buf) < 0) + return -ENOMEM; + dma->period_bytes = dma->periods = 0; + } + + if (dma->periods == periods && dma->period_bytes == period_bytes) + return 0; + + /* the u32 cast is okay because in snd*create we succesfully told + pci alloc that we're only 32 bit capable so the uppper will be 0 */ + addr = (u32) substream->runtime->dma_addr; + desc_addr = (u32) dma->desc_buf.addr; + for (i = 0; i < periods; i++) { + cs5535audio_dma_desc_t *desc = + &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[i]; + desc->addr = cpu_to_le32(addr); + desc->size = period_bytes; + desc->ctlreserved = PRD_EOP; + desc_addr += sizeof(cs5535audio_dma_desc_t); + addr += period_bytes; + } + /* we reserved one dummy descriptor at the end to do the PRD jump */ + lastdesc = &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[periods]; + lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr); + lastdesc->size = 0; + lastdesc->ctlreserved = PRD_JMP; + jmpprd_addr = cpu_to_le32(lastdesc->addr + + (sizeof(cs5535audio_dma_desc_t)*periods)); + + dma->period_bytes = period_bytes; + dma->periods = periods; + spin_lock_irq(&cs5535au->reg_lock); + dma->ops->disable_dma(cs5535au); + dma->ops->setup_prd(cs5535au, jmpprd_addr); + spin_unlock_irq(&cs5535au->reg_lock); + return 0; +} + +static void cs5535audio_playback_enable_dma(cs5535audio_t *cs5535au) +{ + cs_writeb(cs5535au, ACC_BM0_CMD, BM_CTL_EN); +} + +static void cs5535audio_playback_disable_dma(cs5535audio_t *cs5535au) +{ + cs_writeb(cs5535au, ACC_BM0_CMD, 0); +} + +static void cs5535audio_playback_pause_dma(cs5535audio_t *cs5535au) +{ + cs_writeb(cs5535au, ACC_BM0_CMD, BM_CTL_PAUSE); +} + +static void cs5535audio_playback_setup_prd(cs5535audio_t *cs5535au, + u32 prd_addr) +{ + cs_writel(cs5535au, ACC_BM0_PRD, prd_addr); +} + +static u32 cs5535audio_playback_read_dma_pntr(cs5535audio_t *cs5535au) +{ + return cs_readl(cs5535au, ACC_BM0_PNTR); +} + +static void cs5535audio_capture_enable_dma(cs5535audio_t *cs5535au) +{ + cs_writeb(cs5535au, ACC_BM1_CMD, BM_CTL_EN); +} + +static void cs5535audio_capture_disable_dma(cs5535audio_t *cs5535au) +{ + cs_writeb(cs5535au, ACC_BM1_CMD, 0); +} + +static void cs5535audio_capture_pause_dma(cs5535audio_t *cs5535au) +{ + cs_writeb(cs5535au, ACC_BM1_CMD, BM_CTL_PAUSE); +} + +static void cs5535audio_capture_setup_prd(cs5535audio_t *cs5535au, + u32 prd_addr) +{ + cs_writel(cs5535au, ACC_BM1_PRD, prd_addr); +} + +static u32 cs5535audio_capture_read_dma_pntr(cs5535audio_t *cs5535au) +{ + return cs_readl(cs5535au, ACC_BM1_PNTR); +} + +static void cs5535audio_clear_dma_packets(cs5535audio_t *cs5535au, + cs5535audio_dma_t *dma, + snd_pcm_substream_t *substream) +{ + snd_dma_free_pages(&dma->desc_buf); + dma->desc_buf.area = NULL; +} + +static int snd_cs5535audio_hw_params(snd_pcm_substream_t *substream, + snd_pcm_hw_params_t *hw_params) +{ + cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + cs5535audio_dma_t *dma = substream->runtime->private_data; + int err; + + err = snd_pcm_lib_malloc_pages(substream, + params_buffer_bytes(hw_params)); + if (err < 0) + return err; + dma->buf_addr = substream->runtime->dma_addr; + dma->buf_bytes = params_buffer_bytes(hw_params); + + err = cs5535audio_build_dma_packets(cs5535au, dma, substream, + params_periods(hw_params), + params_period_bytes(hw_params)); + return err; +} + +static int snd_cs5535audio_hw_free(snd_pcm_substream_t *substream) +{ + cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + cs5535audio_dma_t *dma = substream->runtime->private_data; + + cs5535audio_clear_dma_packets(cs5535au, dma, substream); + return snd_pcm_lib_free_pages(substream); +} + +static int snd_cs5535audio_playback_prepare(snd_pcm_substream_t *substream) +{ + cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + return snd_ac97_set_rate(cs5535au->ac97, AC97_PCM_FRONT_DAC_RATE, + substream->runtime->rate); +} + +static int snd_cs5535audio_trigger(snd_pcm_substream_t *substream, int cmd) +{ + cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + cs5535audio_dma_t *dma = substream->runtime->private_data; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + spin_lock_irq(&cs5535au->reg_lock); + dma->ops->pause_dma(cs5535au); + spin_unlock_irq(&cs5535au->reg_lock); + break; + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + spin_lock_irq(&cs5535au->reg_lock); + dma->ops->enable_dma(cs5535au); + spin_unlock_irq(&cs5535au->reg_lock); + break; + case SNDRV_PCM_TRIGGER_START: + spin_lock_irq(&cs5535au->reg_lock); + dma->ops->enable_dma(cs5535au); + spin_unlock_irq(&cs5535au->reg_lock); + break; + case SNDRV_PCM_TRIGGER_STOP: + spin_lock_irq(&cs5535au->reg_lock); + dma->ops->disable_dma(cs5535au); + spin_unlock_irq(&cs5535au->reg_lock); + break; + default: + snd_printk(KERN_ERR "unhandled trigger\n"); + return -EINVAL; + break; + } + return 0; +} + +static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t + *substream) +{ + cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + u32 curdma; + cs5535audio_dma_t *dma; + + dma = substream->runtime->private_data; + curdma = dma->ops->read_dma_pntr(cs5535au); + if (curdma < dma->buf_addr) { + snd_printk(KERN_ERR "curdma=%x < %x bufaddr.\n", + curdma, dma->buf_addr); + return 0; + } + curdma -= dma->buf_addr; + if (curdma >= dma->buf_bytes) { + snd_printk(KERN_ERR "diff=%x >= %x buf_bytes.\n", + curdma, dma->buf_bytes); + return 0; + } + return bytes_to_frames(substream->runtime, curdma); +} + +static int snd_cs5535audio_capture_open(snd_pcm_substream_t *substream) +{ + int err; + cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + snd_pcm_runtime_t *runtime = substream->runtime; + + runtime->hw = snd_cs5535audio_capture; + cs5535au->capture_substream = substream; + runtime->private_data = &(cs5535au->dmas[CS5535AUDIO_DMA_CAPTURE]); + snd_pcm_set_sync(substream); + if ((err = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS)) < 0) + return err; + return 0; +} + +static int snd_cs5535audio_capture_close(snd_pcm_substream_t *substream) +{ + return 0; +} + +static int snd_cs5535audio_capture_prepare(snd_pcm_substream_t *substream) +{ + cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + return snd_ac97_set_rate(cs5535au->ac97, AC97_PCM_LR_ADC_RATE, + substream->runtime->rate); +} + +static snd_pcm_ops_t snd_cs5535audio_playback_ops = { + .open = snd_cs5535audio_playback_open, + .close = snd_cs5535audio_playback_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = snd_cs5535audio_hw_params, + .hw_free = snd_cs5535audio_hw_free, + .prepare = snd_cs5535audio_playback_prepare, + .trigger = snd_cs5535audio_trigger, + .pointer = snd_cs5535audio_pcm_pointer, +}; + +static snd_pcm_ops_t snd_cs5535audio_capture_ops = { + .open = snd_cs5535audio_capture_open, + .close = snd_cs5535audio_capture_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = snd_cs5535audio_hw_params, + .hw_free = snd_cs5535audio_hw_free, + .prepare = snd_cs5535audio_capture_prepare, + .trigger = snd_cs5535audio_trigger, + .pointer = snd_cs5535audio_pcm_pointer, +}; + +static void snd_cs5535audio_pcm_free(snd_pcm_t *pcm) +{ + snd_pcm_lib_preallocate_free_for_all(pcm); +} + +static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = { + .type = CS5535AUDIO_DMA_PLAYBACK, + .enable_dma = cs5535audio_playback_enable_dma, + .disable_dma = cs5535audio_playback_disable_dma, + .setup_prd = cs5535audio_playback_setup_prd, + .pause_dma = cs5535audio_playback_pause_dma, + .read_dma_pntr = cs5535audio_playback_read_dma_pntr, +}; + +static cs5535audio_dma_ops_t snd_cs5535audio_capture_dma_ops = { + .type = CS5535AUDIO_DMA_CAPTURE, + .enable_dma = cs5535audio_capture_enable_dma, + .disable_dma = cs5535audio_capture_disable_dma, + .setup_prd = cs5535audio_capture_setup_prd, + .pause_dma = cs5535audio_capture_pause_dma, + .read_dma_pntr = cs5535audio_capture_read_dma_pntr, +}; + +int __devinit snd_cs5535audio_pcm(cs5535audio_t *cs5535au) +{ + snd_pcm_t *pcm; + int err; + + err = snd_pcm_new(cs5535au->card, "CS5535 Audio", 0, 1, 1, &pcm); + if (err < 0) + return err; + + cs5535au->dmas[CS5535AUDIO_DMA_PLAYBACK].ops = + &snd_cs5535audio_playback_dma_ops; + cs5535au->dmas[CS5535AUDIO_DMA_CAPTURE].ops = + &snd_cs5535audio_capture_dma_ops; + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, + &snd_cs5535audio_playback_ops); + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, + &snd_cs5535audio_capture_ops); + + pcm->private_data = cs5535au; + pcm->private_free = snd_cs5535audio_pcm_free; + pcm->info_flags = 0; + strcpy(pcm->name, "CS5535 Audio"); + + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_dma_pci_data(cs5535au->pci), + 64*1024, 128*1024); + + return 0; +} + -- cgit v1.1 From 3e8731740e17f01ec1ecce556ccdc4c42279ce1b Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:15:37 +0100 Subject: [ALSA] Minor clean up and fixes for CS5535 audio driver Modules: Documentation,CS5535 driver Minor clean up and fixes for CS5535 audio driver. Added an entry in ALSA-Configuration.txt, too. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- Documentation/sound/alsa/ALSA-Configuration.txt | 7 +++ sound/pci/cs5535audio/cs5535audio.c | 34 ++++++--------- sound/pci/cs5535audio/cs5535audio.h | 10 ++--- sound/pci/cs5535audio/cs5535audio_pcm.c | 57 ++++++++++--------------- 4 files changed, 48 insertions(+), 60 deletions(-) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 2f27f39..23d1870 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -410,6 +410,13 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. The power-management is supported. + Module snd-cs5535audio + ---------------------- + + Module for multifunction CS5535 companion PCI device + + Module supports up to 8 cards. + Module snd-dt019x ----------------- diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 920c857..3f4379d 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -55,7 +55,7 @@ MODULE_DEVICE_TABLE(pci, snd_cs5535audio_ids); static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout) { - unsigned long tmp; + unsigned int tmp; do { tmp = cs_readl(cs5535au, ACC_CODEC_CNTL); if (!(tmp & CMD_NEW)) @@ -69,11 +69,11 @@ static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout) static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au, unsigned short reg) { - unsigned long regdata; - unsigned long timeout; - unsigned long val; + unsigned int regdata; + int timeout; + unsigned int val; - regdata = ((unsigned long) reg) << 24; + regdata = ((unsigned int) reg) << 24; regdata |= ACC_CODEC_CNTL_RD_CMD; regdata |= CMD_NEW; @@ -83,24 +83,23 @@ static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au, timeout = 50; do { val = cs_readl(cs5535au, ACC_CODEC_STATUS); - if ( (val & STS_NEW) && - ((unsigned long) reg == ((0xFF000000 & val)>>24)) ) + if ((val & STS_NEW) && reg == (val >> 24)) break; msleep(10); } while (--timeout); if (!timeout) snd_printk(KERN_ERR "Failure reading cs5535 codec\n"); - return ((unsigned short) val); + return (unsigned short) val; } static void snd_cs5535audio_codec_write(cs5535audio_t *cs5535au, unsigned short reg, unsigned short val) { - unsigned long regdata; + unsigned int regdata; - regdata = ((unsigned long) reg) << 24; - regdata |= (unsigned long) val; + regdata = ((unsigned int) reg) << 24; + regdata |= val; regdata &= CMD_MASK; regdata |= CMD_NEW; regdata &= ACC_CODEC_CNTL_WR_CMD; @@ -123,12 +122,6 @@ static unsigned short snd_cs5535audio_ac97_codec_read(ac97_t *ac97, return snd_cs5535audio_codec_read(cs5535au, reg); } -static void snd_cs5535audio_mixer_free_ac97(ac97_t *ac97) -{ - cs5535audio_t *cs5535audio = ac97->private_data; - cs5535audio->ac97 = NULL; -} - static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au) { snd_card_t *card = cs5535au->card; @@ -147,10 +140,9 @@ static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au) ac97.scaps = AC97_SCAP_AUDIO|AC97_SCAP_SKIP_MODEM; ac97.private_data = cs5535au; ac97.pci = cs5535au->pci; - ac97.private_free = snd_cs5535audio_mixer_free_ac97; if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { - snd_printk("mixer failed\n"); + snd_printk(KERN_ERR "mixer failed\n"); return err; } @@ -201,8 +193,8 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id, if (!acc_irq_stat) return IRQ_NONE; - for (count=0; count < 10; count++) { - if (acc_irq_stat & (1<<count)) { + for (count = 0; count < 10; count++) { + if (acc_irq_stat & (1 << count)) { switch (count) { case IRQ_STS: cs_readl(cs5535au, ACC_GPIO_STATUS); diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index e28177f..774185e 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -1,11 +1,11 @@ #ifndef __SOUND_CS5535AUDIO_H #define __SOUND_CS5535AUDIO_H -#define cs_writel(cs5535au, reg, val) outl(val, (int) cs5535au->port + reg) -#define cs_writeb(cs5535au, reg, val) outb(val, (int) cs5535au->port + reg) -#define cs_readl(cs5535au, reg) inl((unsigned short) (cs5535au->port + reg)) -#define cs_readw(cs5535au, reg) inw((unsigned short) (cs5535au->port + reg)) -#define cs_readb(cs5535au, reg) inb((unsigned short) (cs5535au->port + reg)) +#define cs_writel(cs5535au, reg, val) outl(val, (cs5535au)->port + reg) +#define cs_writeb(cs5535au, reg, val) outb(val, (cs5535au)->port + reg) +#define cs_readl(cs5535au, reg) inl((cs5535au)->port + reg) +#define cs_readw(cs5535au, reg) inw((cs5535au)->port + reg) +#define cs_readb(cs5535au, reg) inb((cs5535au)->port + reg) #define CS5535AUDIO_MAX_DESCRIPTORS 128 diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index 5802ed9..d32b23f2 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -150,8 +150,8 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au, cs5535audio_dma_desc_t *desc = &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[i]; desc->addr = cpu_to_le32(addr); - desc->size = period_bytes; - desc->ctlreserved = PRD_EOP; + desc->size = cpu_to_le32(period_bytes); + desc->ctlreserved = cpu_to_le32(PRD_EOP); desc_addr += sizeof(cs5535audio_dma_desc_t); addr += period_bytes; } @@ -159,7 +159,7 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au, lastdesc = &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[periods]; lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr); lastdesc->size = 0; - lastdesc->ctlreserved = PRD_JMP; + lastdesc->ctlreserved = cpu_to_le32(PRD_JMP); jmpprd_addr = cpu_to_le32(lastdesc->addr + (sizeof(cs5535audio_dma_desc_t)*periods)); @@ -272,34 +272,29 @@ static int snd_cs5535audio_trigger(snd_pcm_substream_t *substream, int cmd) { cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); cs5535audio_dma_t *dma = substream->runtime->private_data; + int err = 0; + spin_lock(&cs5535au->reg_lock); switch (cmd) { - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - spin_lock_irq(&cs5535au->reg_lock); - dma->ops->pause_dma(cs5535au); - spin_unlock_irq(&cs5535au->reg_lock); - break; - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - spin_lock_irq(&cs5535au->reg_lock); - dma->ops->enable_dma(cs5535au); - spin_unlock_irq(&cs5535au->reg_lock); - break; - case SNDRV_PCM_TRIGGER_START: - spin_lock_irq(&cs5535au->reg_lock); - dma->ops->enable_dma(cs5535au); - spin_unlock_irq(&cs5535au->reg_lock); - break; - case SNDRV_PCM_TRIGGER_STOP: - spin_lock_irq(&cs5535au->reg_lock); - dma->ops->disable_dma(cs5535au); - spin_unlock_irq(&cs5535au->reg_lock); - break; - default: - snd_printk(KERN_ERR "unhandled trigger\n"); - return -EINVAL; - break; + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + dma->ops->pause_dma(cs5535au); + break; + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + dma->ops->enable_dma(cs5535au); + break; + case SNDRV_PCM_TRIGGER_START: + dma->ops->enable_dma(cs5535au); + break; + case SNDRV_PCM_TRIGGER_STOP: + dma->ops->disable_dma(cs5535au); + break; + default: + snd_printk(KERN_ERR "unhandled trigger\n"); + err = -EINVAL; + break; } - return 0; + spin_unlock(&cs5535au->reg_lock); + return err; } static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t @@ -375,11 +370,6 @@ static snd_pcm_ops_t snd_cs5535audio_capture_ops = { .pointer = snd_cs5535audio_pcm_pointer, }; -static void snd_cs5535audio_pcm_free(snd_pcm_t *pcm) -{ - snd_pcm_lib_preallocate_free_for_all(pcm); -} - static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = { .type = CS5535AUDIO_DMA_PLAYBACK, .enable_dma = cs5535audio_playback_enable_dma, @@ -417,7 +407,6 @@ int __devinit snd_cs5535audio_pcm(cs5535audio_t *cs5535au) &snd_cs5535audio_capture_ops); pcm->private_data = cs5535au; - pcm->private_free = snd_cs5535audio_pcm_free; pcm->info_flags = 0; strcpy(pcm->name, "CS5535 Audio"); -- cgit v1.1 From 230b5c1a612ae903c560b55a15df287b0ff437ea Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:17:05 +0100 Subject: [ALSA] Sort Kconfig entries Modules: ISA,PCI drivers Sort Kconfig entries in alphabetical order. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/Kconfig | 158 ++++++++++----------- sound/pci/Kconfig | 410 +++++++++++++++++++++++++++--------------------------- 2 files changed, 284 insertions(+), 284 deletions(-) diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 5d6c300a..04cafd2 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig @@ -41,6 +41,45 @@ config SND_AD1848 To compile this driver as a module, choose M here: the module will be called snd-ad1848. +config SND_ALS100 + tristate "Avance Logic ALS100/ALS120" + depends on SND && PNP && ISA + select ISAPNP + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_PCM + help + Say Y here to include support for soundcards based on Avance + Logic ALS100, ALS110, ALS120 and ALS200 chips. + + To compile this driver as a module, choose M here: the module + will be called snd-als100. + +config SND_AZT2320 + tristate "Aztech Systems AZT2320" + depends on SND && PNP && ISA + select ISAPNP + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_CS4231_LIB + help + Say Y here to include support for soundcards based on the + Aztech Systems AZT2320 chip. + + To compile this driver as a module, choose M here: the module + will be called snd-azt2320. + +config SND_CMI8330 + tristate "C-Media CMI8330" + depends on SND + select SND_AD1848_LIB + help + Say Y here to include support for soundcards based on the + C-Media CMI8330 chip. + + To compile this driver as a module, choose M here: the module + will be called snd-cmi8330. + config SND_CS4231 tristate "Generic Cirrus Logic CS4231 driver" depends on SND @@ -79,6 +118,20 @@ config SND_CS4236 To compile this driver as a module, choose M here: the module will be called snd-cs4236. +config SND_DT019X + tristate "Diamond Technologies DT-019X, Avance Logic ALS-007" + depends on SND && PNP && ISA + select ISAPNP + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_PCM + help + Say Y here to include support for soundcards based on the + Diamond Technologies DT-019X or Avance Logic ALS-007 chips. + + To compile this driver as a module, choose M here: the module + will be called snd-dt019x. + config SND_ES968 tristate "Generic ESS ES968 driver" depends on SND && PNP && ISA @@ -194,6 +247,19 @@ config SND_INTERWAVE_STB To compile this driver as a module, choose M here: the module will be called snd-interwave-stb. +config SND_OPL3SA2 + tristate "Yamaha OPL3-SA2/SA3" + depends on SND + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_CS4231_LIB + help + Say Y here to include support for Yamaha OPL3-SA2 and OPL3-SA3 + chips. + + To compile this driver as a module, choose M here: the module + will be called snd-opl3sa2. + config SND_OPTI92X_AD1848 tristate "OPTi 82C92x - AD1848" depends on SND @@ -286,85 +352,6 @@ config SND_SB16_CSP coprocessor can do variable tasks like various compression and decompression algorithms. -config SND_WAVEFRONT - tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" - depends on SND - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_CS4231_LIB - help - Say Y here to include support for Turtle Beach Maui, Tropez - and Tropez+ soundcards based on the Wavefront chip. - - To compile this driver as a module, choose M here: the module - will be called snd-wavefront. - -config SND_ALS100 - tristate "Avance Logic ALS100/ALS120" - depends on SND && PNP && ISA - select ISAPNP - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_PCM - help - Say Y here to include support for soundcards based on Avance - Logic ALS100, ALS110, ALS120 and ALS200 chips. - - To compile this driver as a module, choose M here: the module - will be called snd-als100. - -config SND_AZT2320 - tristate "Aztech Systems AZT2320" - depends on SND && PNP && ISA - select ISAPNP - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_CS4231_LIB - help - Say Y here to include support for soundcards based on the - Aztech Systems AZT2320 chip. - - To compile this driver as a module, choose M here: the module - will be called snd-azt2320. - -config SND_CMI8330 - tristate "C-Media CMI8330" - depends on SND - select SND_AD1848_LIB - help - Say Y here to include support for soundcards based on the - C-Media CMI8330 chip. - - To compile this driver as a module, choose M here: the module - will be called snd-cmi8330. - -config SND_DT019X - tristate "Diamond Technologies DT-019X, Avance Logic ALS-007" - depends on SND && PNP && ISA - select ISAPNP - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_PCM - help - Say Y here to include support for soundcards based on the - Diamond Technologies DT-019X or Avance Logic ALS-007 chips. - - To compile this driver as a module, choose M here: the module - will be called snd-dt019x. - -config SND_OPL3SA2 - tristate "Yamaha OPL3-SA2/SA3" - depends on SND - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_CS4231_LIB - help - Say Y here to include support for Yamaha OPL3-SA2 and OPL3-SA3 - chips. - - To compile this driver as a module, choose M here: the module - will be called snd-opl3sa2. - config SND_SGALAXY tristate "Aztech Sound Galaxy" depends on SND @@ -389,4 +376,17 @@ config SND_SSCAPE To compile this driver as a module, choose M here: the module will be called snd-sscape. +config SND_WAVEFRONT + tristate "Turtle Beach Maui,Tropez,Tropez+ (Wavefront)" + depends on SND + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_CS4231_LIB + help + Say Y here to include support for Turtle Beach Maui, Tropez + and Tropez+ soundcards based on the Wavefront chip. + + To compile this driver as a module, choose M here: the module + will be called snd-wavefront. + endmenu diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 920305c..ef7bdc5 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -3,6 +3,31 @@ menu "PCI devices" depends on SND!=n && PCI +config SND_AD1889 + tristate "Analog Devices AD1889" + depends on SND + select SND_AC97_CODEC + help + Say Y here to include support for the integrated AC97 sound + device found in particular on the Hewlett-Packard [BCJ]-xxx0 + class PA-RISC workstations, using the AD1819 codec. + + To compile this as a module, choose M here: the module + will be called snd-ad1889. + +config SND_ALS4000 + tristate "Avance Logic ALS4000" + depends on SND && ISA_DMA_API + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_PCM + help + Say Y here to include support for soundcards based on Avance Logic + ALS4000 chips. + + To compile this driver as a module, choose M here: the module + will be called snd-als4000. + config SND_ALI5451 tristate "ALi M5451 PCI Audio Controller" depends on SND @@ -119,6 +144,44 @@ config SND_BT87X_OVERCLOCK Higher sample rates won't hurt your hardware, but audio quality may suffer. +config SND_CA0106 + tristate "SB Audigy LS / Live 24bit" + depends on SND + select SND_AC97_CODEC + select SND_RAWMIDI + help + Say Y here to include support for the Sound Blaster Audigy LS + and Live 24bit. + + To compile this driver as a module, choose M here: the module + will be called snd-ca0106. + +config SND_CMIPCI + tristate "C-Media 8738, 8338" + depends on SND + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_PCM + help + If you want to use soundcards based on C-Media CMI8338 or CMI8738 + chips, say Y here and read + <file:Documentation/sound/alsa/CMIPCI.txt>. + + To compile this driver as a module, choose M here: the module + will be called snd-cmipci. + +config SND_CS4281 + tristate "Cirrus Logic (Sound Fusion) CS4281" + depends on SND + select SND_OPL3_LIB + select SND_RAWMIDI + select SND_AC97_CODEC + help + Say Y here to include support for Cirrus Logic CS4281 chips. + + To compile this driver as a module, choose M here: the module + will be called snd-cs4281. + config SND_CS46XX tristate "Cirrus Logic (Sound Fusion) CS4280/CS461x/CS462x/CS463x" depends on SND @@ -139,17 +202,18 @@ config SND_CS46XX_NEW_DSP This works better than the old code, so say Y. -config SND_CS4281 - tristate "Cirrus Logic (Sound Fusion) CS4281" - depends on SND - select SND_OPL3_LIB - select SND_RAWMIDI +config SND_CS5535AUDIO + tristate "CS5535 Audio" + depends on SND && X86 && !X86_64 + select SND_PCM select SND_AC97_CODEC help - Say Y here to include support for Cirrus Logic CS4281 chips. + Say Y here to include support for audio on CS5535 chips. It is + referred to as NS CS5535 IO or AMD CS5535 IO companion in + various literature. To compile this driver as a module, choose M here: the module - will be called snd-cs4281. + will be called snd-cs5535audio. config SND_EMU10K1 tristate "Emu10k1 (SB Live!, Audigy, E-mu APS)" @@ -180,174 +244,6 @@ config SND_EMU10K1X To compile this driver as a module, choose M here: the module will be called snd-emu10k1x. -config SND_CA0106 - tristate "SB Audigy LS / Live 24bit" - depends on SND - select SND_AC97_CODEC - select SND_RAWMIDI - help - Say Y here to include support for the Sound Blaster Audigy LS - and Live 24bit. - - To compile this driver as a module, choose M here: the module - will be called snd-ca0106. - -config SND_KORG1212 - tristate "Korg 1212 IO" - depends on SND - select SND_PCM - help - Say Y here to include support for Korg 1212IO soundcards. - - To compile this driver as a module, choose M here: the module - will be called snd-korg1212. - -config SND_MIXART - tristate "Digigram miXart" - depends on SND - select SND_HWDEP - select SND_PCM - help - If you want to use Digigram miXart soundcards, say Y here and - read <file:Documentation/sound/alsa/MIXART.txt>. - - To compile this driver as a module, choose M here: the module - will be called snd-mixart. - -config SND_NM256 - tristate "NeoMagic NM256AV/ZX" - depends on SND - select SND_AC97_CODEC - help - Say Y here to include support for NeoMagic NM256AV/ZX chips. - - To compile this driver as a module, choose M here: the module - will be called snd-nm256. - -config SND_RME32 - tristate "RME Digi32, 32/8, 32 PRO" - depends on SND - select SND_PCM - help - Say Y to include support for RME Digi32, Digi32 PRO and - Digi32/8 (Sek'd Prodif32, Prodif96 and Prodif Gold) audio - devices. - - To compile this driver as a module, choose M here: the module - will be called snd-rme32. - -config SND_RME96 - tristate "RME Digi96, 96/8, 96/8 PRO" - depends on SND - select SND_PCM - help - Say Y here to include support for RME Digi96, Digi96/8 and - Digi96/8 PRO/PAD/PST soundcards. - - To compile this driver as a module, choose M here: the module - will be called snd-rme96. - -config SND_RME9652 - tristate "RME Digi9652 (Hammerfall)" - depends on SND - select SND_PCM - help - Say Y here to include support for RME Hammerfall (RME - Digi9652/Digi9636) soundcards. - - To compile this driver as a module, choose M here: the module - will be called snd-rme9652. - -config SND_HDSP - tristate "RME Hammerfall DSP Audio" - depends on SND - select SND_HWDEP - select SND_RAWMIDI - select SND_PCM - help - Say Y here to include support for RME Hammerfall DSP Audio - soundcards. - - To compile this driver as a module, choose M here: the module - will be called snd-hdsp. - -config SND_HDSPM - tristate "RME Hammerfall DSP MADI" - depends on SND - select SND_HWDEP - select SND_RAWMIDI - select SND_PCM - help - Say Y here to include support for RME Hammerfall DSP MADI - soundcards. - - To compile this driver as a module, choose M here: the module - will be called snd-hdspm. - -config SND_TRIDENT - tristate "Trident 4D-Wave DX/NX; SiS 7018" - depends on SND - select SND_MPU401_UART - select SND_AC97_CODEC - help - Say Y here to include support for soundcards based on Trident - 4D-Wave DX/NX or SiS 7018 chips. - - To compile this driver as a module, choose M here: the module - will be called snd-trident. - -config SND_YMFPCI - tristate "Yamaha YMF724/740/744/754" - depends on SND - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_AC97_CODEC - help - Say Y here to include support for Yamaha PCI audio chips - - YMF724, YMF724F, YMF740, YMF740C, YMF744, YMF754. - - To compile this driver as a module, choose M here: the module - will be called snd-ymfpci. - -config SND_AD1889 - tristate "Analog Devices AD1889" - depends on SND - select SND_AC97_CODEC - help - Say Y here to include support for the integrated AC97 sound - device found in particular on the Hewlett-Packard [BCJ]-xxx0 - class PA-RISC workstations, using the AD1819 codec. - - To compile this as a module, choose M here: the module - will be called snd-ad1889. - -config SND_ALS4000 - tristate "Avance Logic ALS4000" - depends on SND && ISA_DMA_API - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_PCM - help - Say Y here to include support for soundcards based on Avance Logic - ALS4000 chips. - - To compile this driver as a module, choose M here: the module - will be called snd-als4000. - -config SND_CMIPCI - tristate "C-Media 8738, 8338" - depends on SND - select SND_OPL3_LIB - select SND_MPU401_UART - select SND_PCM - help - If you want to use soundcards based on C-Media CMI8338 or CMI8738 - chips, say Y here and read - <file:Documentation/sound/alsa/CMIPCI.txt>. - - To compile this driver as a module, choose M here: the module - will be called snd-cmipci. - config SND_ENS1370 tristate "(Creative) Ensoniq AudioPCI 1370" depends on SND @@ -359,19 +255,6 @@ config SND_ENS1370 To compile this driver as a module, choose M here: the module will be called snd-ens1370. -config SND_CS5535AUDIO - tristate "CS5535 Audio" - depends on SND && X86 && !X86_64 - select SND_PCM - select SND_AC97_CODEC - help - Say Y here to include support for audio on CS5535 chips. It is - referred to as NS CS5535 IO or AMD CS5535 IO companion in - various literature. - - To compile this driver as a module, choose M here: the module - will be called snd-cs5535audio. - config SND_ENS1371 tristate "(Creative) Ensoniq AudioPCI 1371/1373" depends on SND @@ -409,17 +292,6 @@ config SND_ES1968 To compile this driver as a module, choose M here: the module will be called snd-es1968. -config SND_MAESTRO3 - tristate "ESS Allegro/Maestro3" - depends on SND - select SND_AC97_CODEC - help - Say Y here to include support for soundcards based on ESS Maestro 3 - (Allegro) chips. - - To compile this driver as a module, choose M here: the module - will be called snd-maestro3. - config SND_FM801 tristate "ForteMedia FM801" depends on SND @@ -445,6 +317,43 @@ config SND_FM801_TEA575X To compile this driver as a module, choose M here: the module will be called snd-fm801-tea575x. +config SND_HDA_INTEL + tristate "Intel HD Audio" + depends on SND + select SND_PCM + help + Say Y here to include support for Intel "High Definition + Audio" (Azalia) motherboard devices. + + To compile this driver as a module, choose M here: the module + will be called snd-hda-intel. + +config SND_HDSP + tristate "RME Hammerfall DSP Audio" + depends on SND + select SND_HWDEP + select SND_RAWMIDI + select SND_PCM + help + Say Y here to include support for RME Hammerfall DSP Audio + soundcards. + + To compile this driver as a module, choose M here: the module + will be called snd-hdsp. + +config SND_HDSPM + tristate "RME Hammerfall DSP MADI" + depends on SND + select SND_HWDEP + select SND_RAWMIDI + select SND_PCM + help + Say Y here to include support for RME Hammerfall DSP MADI + soundcards. + + To compile this driver as a module, choose M here: the module + will be called snd-hdspm. + config SND_ICE1712 tristate "ICEnsemble ICE1712 (Envy24)" depends on SND @@ -503,6 +412,83 @@ config SND_INTEL8X0M To compile this driver as a module, choose M here: the module will be called snd-intel8x0m. +config SND_KORG1212 + tristate "Korg 1212 IO" + depends on SND + select SND_PCM + help + Say Y here to include support for Korg 1212IO soundcards. + + To compile this driver as a module, choose M here: the module + will be called snd-korg1212. + +config SND_MAESTRO3 + tristate "ESS Allegro/Maestro3" + depends on SND + select SND_AC97_CODEC + help + Say Y here to include support for soundcards based on ESS Maestro 3 + (Allegro) chips. + + To compile this driver as a module, choose M here: the module + will be called snd-maestro3. + +config SND_MIXART + tristate "Digigram miXart" + depends on SND + select SND_HWDEP + select SND_PCM + help + If you want to use Digigram miXart soundcards, say Y here and + read <file:Documentation/sound/alsa/MIXART.txt>. + + To compile this driver as a module, choose M here: the module + will be called snd-mixart. + +config SND_NM256 + tristate "NeoMagic NM256AV/ZX" + depends on SND + select SND_AC97_CODEC + help + Say Y here to include support for NeoMagic NM256AV/ZX chips. + + To compile this driver as a module, choose M here: the module + will be called snd-nm256. + +config SND_RME32 + tristate "RME Digi32, 32/8, 32 PRO" + depends on SND + select SND_PCM + help + Say Y to include support for RME Digi32, Digi32 PRO and + Digi32/8 (Sek'd Prodif32, Prodif96 and Prodif Gold) audio + devices. + + To compile this driver as a module, choose M here: the module + will be called snd-rme32. + +config SND_RME96 + tristate "RME Digi96, 96/8, 96/8 PRO" + depends on SND + select SND_PCM + help + Say Y here to include support for RME Digi96, Digi96/8 and + Digi96/8 PRO/PAD/PST soundcards. + + To compile this driver as a module, choose M here: the module + will be called snd-rme96. + +config SND_RME9652 + tristate "RME Digi9652 (Hammerfall)" + depends on SND + select SND_PCM + help + Say Y here to include support for RME Hammerfall (RME + Digi9652/Digi9636) soundcards. + + To compile this driver as a module, choose M here: the module + will be called snd-rme9652. + config SND_SONICVIBES tristate "S3 SonicVibes" depends on SND @@ -516,6 +502,18 @@ config SND_SONICVIBES To compile this driver as a module, choose M here: the module will be called snd-sonicvibes. +config SND_TRIDENT + tristate "Trident 4D-Wave DX/NX; SiS 7018" + depends on SND + select SND_MPU401_UART + select SND_AC97_CODEC + help + Say Y here to include support for soundcards based on Trident + 4D-Wave DX/NX or SiS 7018 chips. + + To compile this driver as a module, choose M here: the module + will be called snd-trident. + config SND_VIA82XX tristate "VIA 82C686A/B, 8233/8235 AC97 Controller" depends on SND @@ -549,15 +547,17 @@ config SND_VX222 To compile this driver as a module, choose M here: the module will be called snd-vx222. -config SND_HDA_INTEL - tristate "Intel HD Audio" +config SND_YMFPCI + tristate "Yamaha YMF724/740/744/754" depends on SND - select SND_PCM + select SND_OPL3_LIB + select SND_MPU401_UART + select SND_AC97_CODEC help - Say Y here to include support for Intel "High Definition - Audio" (Azalia) motherboard devices. + Say Y here to include support for Yamaha PCI audio chips - + YMF724, YMF724F, YMF740, YMF740C, YMF744, YMF754. To compile this driver as a module, choose M here: the module - will be called snd-hda-intel. + will be called snd-ymfpci. endmenu -- cgit v1.1 From 47eaebfd31610d2a55fbaccd1e7c37690d42ce30 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:18:00 +0100 Subject: [ALSA] Use standard bitmap functions Modules: ALSA<-OSS emulation Use standard bitmap functions instead of in-house ones. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/core/oss/io.c | 4 +-- sound/core/oss/pcm_plugin.c | 54 +++++++++++++++---------------- sound/core/oss/pcm_plugin.h | 78 ++++++--------------------------------------- sound/core/oss/rate.c | 2 +- sound/core/oss/route.c | 28 ++++++++-------- 5 files changed, 53 insertions(+), 113 deletions(-) diff --git a/sound/core/oss/io.c b/sound/core/oss/io.c index bb1c99a..63eca9a 100644 --- a/sound/core/oss/io.c +++ b/sound/core/oss/io.c @@ -37,7 +37,7 @@ static snd_pcm_sframes_t io_playback_transfer(snd_pcm_plugin_t *plugin, const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels ATTRIBUTE_UNUSED, + snd_pcm_plugin_channel_t *dst_channels, snd_pcm_uframes_t frames) { snd_assert(plugin != NULL, return -ENXIO); @@ -59,7 +59,7 @@ static snd_pcm_sframes_t io_playback_transfer(snd_pcm_plugin_t *plugin, } static snd_pcm_sframes_t io_capture_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels ATTRIBUTE_UNUSED, + const snd_pcm_plugin_channel_t *src_channels, snd_pcm_plugin_channel_t *dst_channels, snd_pcm_uframes_t frames) { diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index fc23373..312ae1f 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c @@ -37,21 +37,21 @@ #define snd_pcm_plug_last(plug) ((plug)->runtime->oss.plugin_last) static int snd_pcm_plugin_src_channels_mask(snd_pcm_plugin_t *plugin, - bitset_t *dst_vmask, - bitset_t **src_vmask) + unsigned long *dst_vmask, + unsigned long **src_vmask) { - bitset_t *vmask = plugin->src_vmask; - bitset_copy(vmask, dst_vmask, plugin->src_format.channels); + unsigned long *vmask = plugin->src_vmask; + bitmap_copy(vmask, dst_vmask, plugin->src_format.channels); *src_vmask = vmask; return 0; } static int snd_pcm_plugin_dst_channels_mask(snd_pcm_plugin_t *plugin, - bitset_t *src_vmask, - bitset_t **dst_vmask) + unsigned long *src_vmask, + unsigned long **dst_vmask) { - bitset_t *vmask = plugin->dst_vmask; - bitset_copy(vmask, src_vmask, plugin->dst_format.channels); + unsigned long *vmask = plugin->dst_vmask; + bitmap_copy(vmask, src_vmask, plugin->dst_format.channels); *dst_vmask = vmask; return 0; } @@ -193,12 +193,12 @@ int snd_pcm_plugin_build(snd_pcm_plug_t *plug, snd_pcm_plugin_free(plugin); return -ENOMEM; } - plugin->src_vmask = bitset_alloc(src_format->channels); + plugin->src_vmask = bitmap_alloc(src_format->channels); if (plugin->src_vmask == NULL) { snd_pcm_plugin_free(plugin); return -ENOMEM; } - plugin->dst_vmask = bitset_alloc(dst_format->channels); + plugin->dst_vmask = bitmap_alloc(dst_format->channels); if (plugin->dst_vmask == NULL) { snd_pcm_plugin_free(plugin); return -ENOMEM; @@ -651,18 +651,18 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(snd_pcm_plug_t *plug, } static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug, - bitset_t *client_vmask) + unsigned long *client_vmask) { snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug); if (plugin == NULL) { return 0; } else { int schannels = plugin->dst_format.channels; - bitset_t bs[bitset_size(schannels)]; - bitset_t *srcmask; - bitset_t *dstmask = bs; + DECLARE_BITMAP(bs, schannels); + unsigned long *srcmask; + unsigned long *dstmask = bs; int err; - bitset_one(dstmask, schannels); + bitmap_fill(dstmask, schannels); while (1) { err = plugin->src_channels_mask(plugin, dstmask, &srcmask); @@ -673,7 +673,7 @@ static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug, break; plugin = plugin->prev; } - bitset_and(client_vmask, dstmask, plugin->src_format.channels); + bitmap_and(client_vmask, client_vmask, dstmask, plugin->src_format.channels); return 0; } } @@ -683,21 +683,21 @@ static int snd_pcm_plug_playback_disable_useless_channels(snd_pcm_plug_t *plug, { snd_pcm_plugin_t *plugin = snd_pcm_plug_first(plug); unsigned int nchannels = plugin->src_format.channels; - bitset_t bs[bitset_size(nchannels)]; - bitset_t *srcmask = bs; + DECLARE_BITMAP(bs, nchannels); + unsigned long *srcmask = bs; int err; unsigned int channel; for (channel = 0; channel < nchannels; channel++) { if (src_channels[channel].enabled) - bitset_set(srcmask, channel); + set_bit(channel, srcmask); else - bitset_reset(srcmask, channel); + clear_bit(channel, srcmask); } err = snd_pcm_plug_playback_channels_mask(plug, srcmask); if (err < 0) return err; for (channel = 0; channel < nchannels; channel++) { - if (!bitset_get(srcmask, channel)) + if (!test_bit(channel, srcmask)) src_channels[channel].enabled = 0; } return 0; @@ -709,16 +709,16 @@ static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug, { snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug); unsigned int nchannels = plugin->dst_format.channels; - bitset_t bs[bitset_size(nchannels)]; - bitset_t *dstmask = bs; - bitset_t *srcmask; + DECLARE_BITMAP(bs, nchannels); + unsigned long *dstmask = bs; + unsigned long *srcmask; int err; unsigned int channel; for (channel = 0; channel < nchannels; channel++) { if (client_channels[channel].enabled) - bitset_set(dstmask, channel); + set_bit(channel, dstmask); else - bitset_reset(dstmask, channel); + clear_bit(channel, dstmask); } while (plugin) { err = plugin->src_channels_mask(plugin, dstmask, &srcmask); @@ -730,7 +730,7 @@ static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug, plugin = snd_pcm_plug_first(plug); nchannels = plugin->src_format.channels; for (channel = 0; channel < nchannels; channel++) { - if (!bitset_get(dstmask, channel)) + if (!test_bit(channel, dstmask)) src_channels[channel].enabled = 0; } return 0; diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h index 0f86ce4..69a4317 100644 --- a/sound/core/oss/pcm_plugin.h +++ b/sound/core/oss/pcm_plugin.h @@ -22,71 +22,11 @@ * */ -#ifndef ATTRIBUTE_UNUSED -#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) -#endif - -typedef unsigned int bitset_t; - -static inline size_t bitset_size(int nbits) -{ - return (nbits + sizeof(bitset_t) * 8 - 1) / (sizeof(bitset_t) * 8); -} - -static inline bitset_t *bitset_alloc(int nbits) -{ - return kcalloc(bitset_size(nbits), sizeof(bitset_t), GFP_KERNEL); -} - -static inline void bitset_set(bitset_t *bitmap, unsigned int pos) -{ - size_t bits = sizeof(*bitmap) * 8; - bitmap[pos / bits] |= 1 << (pos % bits); -} - -static inline void bitset_reset(bitset_t *bitmap, unsigned int pos) -{ - size_t bits = sizeof(*bitmap) * 8; - bitmap[pos / bits] &= ~(1 << (pos % bits)); -} - -static inline int bitset_get(bitset_t *bitmap, unsigned int pos) -{ - size_t bits = sizeof(*bitmap) * 8; - return !!(bitmap[pos / bits] & (1 << (pos % bits))); -} - -static inline void bitset_copy(bitset_t *dst, bitset_t *src, unsigned int nbits) -{ - memcpy(dst, src, bitset_size(nbits) * sizeof(bitset_t)); -} - -static inline void bitset_and(bitset_t *dst, bitset_t *bs, unsigned int nbits) -{ - bitset_t *end = dst + bitset_size(nbits); - while (dst < end) - *dst++ &= *bs++; -} - -static inline void bitset_or(bitset_t *dst, bitset_t *bs, unsigned int nbits) -{ - bitset_t *end = dst + bitset_size(nbits); - while (dst < end) - *dst++ |= *bs++; -} - -static inline void bitset_zero(bitset_t *dst, unsigned int nbits) -{ - bitset_t *end = dst + bitset_size(nbits); - while (dst < end) - *dst++ = 0; -} +#include <linux/bitmap.h> -static inline void bitset_one(bitset_t *dst, unsigned int nbits) +static inline unsigned long *bitmap_alloc(unsigned int nbits) { - bitset_t *end = dst + bitset_size(nbits); - while (dst < end) - *dst++ = ~(bitset_t)0; + return kmalloc(BITS_TO_LONGS(nbits), GFP_KERNEL); } #define snd_pcm_plug_t snd_pcm_substream_t @@ -131,11 +71,11 @@ struct _snd_pcm_plugin { snd_pcm_uframes_t frames, snd_pcm_plugin_channel_t **channels); int (*src_channels_mask)(snd_pcm_plugin_t *plugin, - bitset_t *dst_vmask, - bitset_t **src_vmask); + unsigned long *dst_vmask, + unsigned long **src_vmask); int (*dst_channels_mask)(snd_pcm_plugin_t *plugin, - bitset_t *src_vmask, - bitset_t **dst_vmask); + unsigned long *src_vmask, + unsigned long **dst_vmask); snd_pcm_sframes_t (*transfer)(snd_pcm_plugin_t *plugin, const snd_pcm_plugin_channel_t *src_channels, snd_pcm_plugin_channel_t *dst_channels, @@ -151,8 +91,8 @@ struct _snd_pcm_plugin { char *buf; snd_pcm_uframes_t buf_frames; snd_pcm_plugin_channel_t *buf_channels; - bitset_t *src_vmask; - bitset_t *dst_vmask; + unsigned long *src_vmask; + unsigned long *dst_vmask; char extra_data[0]; }; diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c index 1096ec1..7e325ca 100644 --- a/sound/core/oss/rate.c +++ b/sound/core/oss/rate.c @@ -315,7 +315,7 @@ static snd_pcm_sframes_t rate_transfer(snd_pcm_plugin_t *plugin, static int rate_action(snd_pcm_plugin_t *plugin, snd_pcm_plugin_action_t action, - unsigned long udata ATTRIBUTE_UNUSED) + unsigned long udata) { snd_assert(plugin != NULL, return -ENXIO); switch (action) { diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c index c955b7d..7519aed 100644 --- a/sound/core/oss/route.c +++ b/sound/core/oss/route.c @@ -70,9 +70,9 @@ typedef union { static void route_to_channel_from_zero(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels ATTRIBUTE_UNUSED, + const snd_pcm_plugin_channel_t *src_channels, snd_pcm_plugin_channel_t *dst_channel, - ttable_dst_t* ttable ATTRIBUTE_UNUSED, snd_pcm_uframes_t frames) + ttable_dst_t* ttable, snd_pcm_uframes_t frames) { if (dst_channel->wanted) snd_pcm_area_silence(&dst_channel->area, 0, frames, plugin->dst_format.format); @@ -298,46 +298,46 @@ static void route_to_channel(snd_pcm_plugin_t *plugin, } static int route_src_channels_mask(snd_pcm_plugin_t *plugin, - bitset_t *dst_vmask, - bitset_t **src_vmask) + unsigned long *dst_vmask, + unsigned long **src_vmask) { route_t *data = (route_t *)plugin->extra_data; int schannels = plugin->src_format.channels; int dchannels = plugin->dst_format.channels; - bitset_t *vmask = plugin->src_vmask; + unsigned long *vmask = plugin->src_vmask; int channel; ttable_dst_t *dp = data->ttable; - bitset_zero(vmask, schannels); + bitmap_zero(vmask, schannels); for (channel = 0; channel < dchannels; channel++, dp++) { unsigned int src; ttable_src_t *sp; - if (!bitset_get(dst_vmask, channel)) + if (!test_bit(channel, dst_vmask)) continue; sp = dp->srcs; for (src = 0; src < dp->nsrcs; src++, sp++) - bitset_set(vmask, sp->channel); + set_bit(sp->channel, vmask); } *src_vmask = vmask; return 0; } static int route_dst_channels_mask(snd_pcm_plugin_t *plugin, - bitset_t *src_vmask, - bitset_t **dst_vmask) + unsigned long *src_vmask, + unsigned long **dst_vmask) { route_t *data = (route_t *)plugin->extra_data; int dchannels = plugin->dst_format.channels; - bitset_t *vmask = plugin->dst_vmask; + unsigned long *vmask = plugin->dst_vmask; int channel; ttable_dst_t *dp = data->ttable; - bitset_zero(vmask, dchannels); + bitmap_zero(vmask, dchannels); for (channel = 0; channel < dchannels; channel++, dp++) { unsigned int src; ttable_src_t *sp; sp = dp->srcs; for (src = 0; src < dp->nsrcs; src++, sp++) { - if (bitset_get(src_vmask, sp->channel)) { - bitset_set(vmask, channel); + if (test_bit(sp->channel, src_vmask)) { + set_bit(channel, vmask); break; } } -- cgit v1.1 From c8eb6ba16a5803fab9cc0d1d0dd04a75bf91b6d5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:20:23 +0100 Subject: [ALSA] snd-dummy - Code clean-up Modules: Generic drivers Clean up snd-dummy driver code. - Make common PCM callbacks - Simplify open callback - Remove unnecessary irqsave in control callbacks Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/drivers/dummy.c | 126 +++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 79 deletions(-) diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 64ef7f6..8dfe5d4 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -172,47 +172,33 @@ typedef struct snd_card_dummy_pcm { static snd_card_t *snd_dummy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; -static void snd_card_dummy_pcm_timer_start(snd_pcm_substream_t * substream) +static inline void snd_card_dummy_pcm_timer_start(snd_card_dummy_pcm_t *dpcm) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_card_dummy_pcm_t *dpcm = runtime->private_data; - dpcm->timer.expires = 1 + jiffies; add_timer(&dpcm->timer); } -static void snd_card_dummy_pcm_timer_stop(snd_pcm_substream_t * substream) +static inline void snd_card_dummy_pcm_timer_stop(snd_card_dummy_pcm_t *dpcm) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_card_dummy_pcm_t *dpcm = runtime->private_data; - del_timer(&dpcm->timer); } -static int snd_card_dummy_playback_trigger(snd_pcm_substream_t * substream, - int cmd) +static int snd_card_dummy_pcm_trigger(snd_pcm_substream_t *substream, int cmd) { - if (cmd == SNDRV_PCM_TRIGGER_START) { - snd_card_dummy_pcm_timer_start(substream); - } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { - snd_card_dummy_pcm_timer_stop(substream); - } else { - return -EINVAL; - } - return 0; -} + snd_pcm_runtime_t *runtime = substream->runtime; + snd_dummy_card_pcm_t *dpcm = runtime->private_data; + int err = 0; -static int snd_card_dummy_capture_trigger(snd_pcm_substream_t * substream, - int cmd) -{ + spin_lock(&dpcm->lock); if (cmd == SNDRV_PCM_TRIGGER_START) { - snd_card_dummy_pcm_timer_start(substream); + snd_card_dummy_pcm_timer_start(dpcm); } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { - snd_card_dummy_pcm_timer_stop(substream); + snd_card_dummy_pcm_timer_stop(dpcm); } else { - return -EINVAL; + err = -EINVAL; } - return 0; + spin_unlock(&dpcm->lock); + return err; } static int snd_card_dummy_pcm_prepare(snd_pcm_substream_t * substream) @@ -235,42 +221,26 @@ static int snd_card_dummy_pcm_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_card_dummy_playback_prepare(snd_pcm_substream_t * substream) -{ - return snd_card_dummy_pcm_prepare(substream); -} - -static int snd_card_dummy_capture_prepare(snd_pcm_substream_t * substream) -{ - return snd_card_dummy_pcm_prepare(substream); -} - static void snd_card_dummy_pcm_timer_function(unsigned long data) { snd_card_dummy_pcm_t *dpcm = (snd_card_dummy_pcm_t *)data; + spin_lock(&dpcm->lock); dpcm->timer.expires = 1 + jiffies; add_timer(&dpcm->timer); - spin_lock_irq(&dpcm->lock); dpcm->pcm_irq_pos += dpcm->pcm_jiffie; dpcm->pcm_buf_pos += dpcm->pcm_jiffie; dpcm->pcm_buf_pos %= dpcm->pcm_size; if (dpcm->pcm_irq_pos >= dpcm->pcm_count) { dpcm->pcm_irq_pos %= dpcm->pcm_count; + spin_unlock(&dpcm->lock); snd_pcm_period_elapsed(dpcm->substream); + spin_lock(&dpcm->lock); } - spin_unlock_irq(&dpcm->lock); + spin_unlock(&dpcm->lock); } -static snd_pcm_uframes_t snd_card_dummy_playback_pointer(snd_pcm_substream_t * substream) -{ - snd_pcm_runtime_t *runtime = substream->runtime; - snd_card_dummy_pcm_t *dpcm = runtime->private_data; - - return bytes_to_frames(runtime, dpcm->pcm_buf_pos); -} - -static snd_pcm_uframes_t snd_card_dummy_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(snd_pcm_substream_t * substream) { snd_pcm_runtime_t *runtime = substream->runtime; snd_card_dummy_pcm_t *dpcm = runtime->private_data; @@ -316,8 +286,7 @@ static snd_pcm_hardware_t snd_card_dummy_capture = static void snd_card_dummy_runtime_free(snd_pcm_runtime_t *runtime) { - snd_card_dummy_pcm_t *dpcm = runtime->private_data; - kfree(dpcm); + kfree(runtime->private_data); } static int snd_card_dummy_hw_params(snd_pcm_substream_t * substream, @@ -331,20 +300,29 @@ static int snd_card_dummy_hw_free(snd_pcm_substream_t * substream) return snd_pcm_lib_free_pages(substream); } -static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream) +static snd_card_dummy_pcm_t *new_pcm_stream(snd_pcm_substream_t *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; snd_card_dummy_pcm_t *dpcm; - int err; dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); - if (dpcm == NULL) - return -ENOMEM; + if (! dpcm) + return dpcm; init_timer(&dpcm->timer); dpcm->timer.data = (unsigned long) dpcm; dpcm->timer.function = snd_card_dummy_pcm_timer_function; spin_lock_init(&dpcm->lock); dpcm->substream = substream; + return dpcm; +} + +static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream) +{ + snd_pcm_runtime_t *runtime = substream->runtime; + snd_card_dummy_pcm_t *dpcm; + int err; + + if ((dpcm = new_pcm_stream(substream)) == NULL) + return -ENOMEM; runtime->private_data = dpcm; runtime->private_free = snd_card_dummy_runtime_free; runtime->hw = snd_card_dummy_playback; @@ -368,14 +346,8 @@ static int snd_card_dummy_capture_open(snd_pcm_substream_t * substream) snd_card_dummy_pcm_t *dpcm; int err; - dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); - if (dpcm == NULL) + if ((dpcm = new_pcm_stream(substream)) == NULL) return -ENOMEM; - init_timer(&dpcm->timer); - dpcm->timer.data = (unsigned long) dpcm; - dpcm->timer.function = snd_card_dummy_pcm_timer_function; - spin_lock_init(&dpcm->lock); - dpcm->substream = substream; runtime->private_data = dpcm; runtime->private_free = snd_card_dummy_runtime_free; runtime->hw = snd_card_dummy_capture; @@ -409,9 +381,9 @@ static snd_pcm_ops_t snd_card_dummy_playback_ops = { .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_card_dummy_hw_params, .hw_free = snd_card_dummy_hw_free, - .prepare = snd_card_dummy_playback_prepare, - .trigger = snd_card_dummy_playback_trigger, - .pointer = snd_card_dummy_playback_pointer, + .prepare = snd_card_dummy_pcm_prepare, + .trigger = snd_card_dummy_pcm_trigger, + .pointer = snd_card_dummy_pcm_pointer, }; static snd_pcm_ops_t snd_card_dummy_capture_ops = { @@ -420,9 +392,9 @@ static snd_pcm_ops_t snd_card_dummy_capture_ops = { .ioctl = snd_pcm_lib_ioctl, .hw_params = snd_card_dummy_hw_params, .hw_free = snd_card_dummy_hw_free, - .prepare = snd_card_dummy_capture_prepare, - .trigger = snd_card_dummy_capture_trigger, - .pointer = snd_card_dummy_capture_pointer, + .prepare = snd_card_dummy_pcm_prepare, + .trigger = snd_card_dummy_pcm_trigger, + .pointer = snd_card_dummy_pcm_pointer, }; static int __init snd_card_dummy_pcm(snd_card_dummy_t *dummy, int device, int substreams) @@ -461,20 +433,18 @@ static int snd_dummy_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t static int snd_dummy_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { snd_card_dummy_t *dummy = snd_kcontrol_chip(kcontrol); - unsigned long flags; int addr = kcontrol->private_value; - spin_lock_irqsave(&dummy->mixer_lock, flags); + spin_lock_irq(&dummy->mixer_lock); ucontrol->value.integer.value[0] = dummy->mixer_volume[addr][0]; ucontrol->value.integer.value[1] = dummy->mixer_volume[addr][1]; - spin_unlock_irqrestore(&dummy->mixer_lock, flags); + spin_unlock_irq(&dummy->mixer_lock); return 0; } static int snd_dummy_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { snd_card_dummy_t *dummy = snd_kcontrol_chip(kcontrol); - unsigned long flags; int change, addr = kcontrol->private_value; int left, right; @@ -488,12 +458,12 @@ static int snd_dummy_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t right = -50; if (right > 100) right = 100; - spin_lock_irqsave(&dummy->mixer_lock, flags); + spin_lock_irq(&dummy->mixer_lock); change = dummy->mixer_volume[addr][0] != left || dummy->mixer_volume[addr][1] != right; dummy->mixer_volume[addr][0] = left; dummy->mixer_volume[addr][1] = right; - spin_unlock_irqrestore(&dummy->mixer_lock, flags); + spin_unlock_irq(&dummy->mixer_lock); return change; } @@ -515,31 +485,29 @@ static int snd_dummy_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t static int snd_dummy_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { snd_card_dummy_t *dummy = snd_kcontrol_chip(kcontrol); - unsigned long flags; int addr = kcontrol->private_value; - spin_lock_irqsave(&dummy->mixer_lock, flags); + spin_lock_irq(&dummy->mixer_lock); ucontrol->value.integer.value[0] = dummy->capture_source[addr][0]; ucontrol->value.integer.value[1] = dummy->capture_source[addr][1]; - spin_unlock_irqrestore(&dummy->mixer_lock, flags); + spin_unlock_irq(&dummy->mixer_lock); return 0; } static int snd_dummy_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { snd_card_dummy_t *dummy = snd_kcontrol_chip(kcontrol); - unsigned long flags; int change, addr = kcontrol->private_value; int left, right; left = ucontrol->value.integer.value[0] & 1; right = ucontrol->value.integer.value[1] & 1; - spin_lock_irqsave(&dummy->mixer_lock, flags); + spin_lock_irq(&dummy->mixer_lock); change = dummy->capture_source[addr][0] != left && dummy->capture_source[addr][1] != right; dummy->capture_source[addr][0] = left; dummy->capture_source[addr][1] = right; - spin_unlock_irqrestore(&dummy->mixer_lock, flags); + spin_unlock_irq(&dummy->mixer_lock); return change; } -- cgit v1.1 From bdbae7e62837c22c5399df0789a24e9d8a1d675f Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:21:19 +0100 Subject: [ALSA] Remove snd_vx_delay() function Replace snd_vx_delay() with appropriate delay/sleep functions. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/vx_core.h | 2 -- sound/drivers/vx/vx_core.c | 19 +++---------------- sound/pci/vx222/vx222_ops.c | 14 +++++++------- sound/pcmcia/vx/vxp_ops.c | 10 +++++----- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/include/sound/vx_core.h b/include/sound/vx_core.h index 7a60a38..43c901b 100644 --- a/include/sound/vx_core.h +++ b/include/sound/vx_core.h @@ -274,8 +274,6 @@ static inline void snd_vx_outl(vx_core_t *chip, int reg, unsigned int val) #define vx_inl(chip,reg) snd_vx_inl(chip, VX_##reg) #define vx_outl(chip,reg,val) snd_vx_outl(chip, VX_##reg,val) -void snd_vx_delay(vx_core_t *chip, int msec); - static inline void vx_reset_dsp(vx_core_t *chip) { snd_assert(chip->ops->reset_dsp, return); diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index 4697b1d..e6e4cf9 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -41,18 +41,6 @@ MODULE_LICENSE("GPL"); /* - * snd_vx_delay - delay for the specified time - * @xmsec: the time to delay in msec - */ -void snd_vx_delay(vx_core_t *chip, int xmsec) -{ - if (! in_interrupt() && xmsec >= 1000 / HZ) - msleep(xmsec); - else - mdelay(xmsec); -} - -/* * vx_check_reg_bit - wait for the specified bit is set/reset on a register * @reg: register to check * @mask: bit mask @@ -76,7 +64,7 @@ int snd_vx_check_reg_bit(vx_core_t *chip, int reg, int mask, int bit, int time) do { if ((snd_vx_inb(chip, reg) & mask) == bit) return 0; - //snd_vx_delay(chip, 10); + //msleep(10); } while (time_after_eq(end_time, jiffies)); snd_printd(KERN_DEBUG "vx_check_reg_bit: timeout, reg=%s, mask=0x%x, val=0x%x\n", reg_names[reg], mask, snd_vx_inb(chip, reg)); return -EIO; @@ -664,7 +652,7 @@ int snd_vx_dsp_boot(vx_core_t *chip, const struct firmware *boot) if ((err = snd_vx_load_boot_image(chip, boot)) < 0) return err; - snd_vx_delay(chip, 10); + msleep(10); return 0; } @@ -704,7 +692,7 @@ int snd_vx_dsp_load(vx_core_t *chip, const struct firmware *dsp) } snd_printdd(KERN_DEBUG "checksum = 0x%08x\n", csum); - snd_vx_delay(chip, 200); + msleep(200); if ((err = vx_wait_isr_bit(chip, ISR_CHK)) < 0) return err; @@ -831,7 +819,6 @@ EXPORT_SYMBOL(snd_vx_create); EXPORT_SYMBOL(snd_vx_setup_firmware); EXPORT_SYMBOL(snd_vx_free_firmware); EXPORT_SYMBOL(snd_vx_irq_handler); -EXPORT_SYMBOL(snd_vx_delay); EXPORT_SYMBOL(snd_vx_dsp_boot); EXPORT_SYMBOL(snd_vx_dsp_load); EXPORT_SYMBOL(snd_vx_load_boot_image); diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c index 967bd5e..2d4d0c2 100644 --- a/sound/pci/vx222/vx222_ops.c +++ b/sound/pci/vx222/vx222_ops.c @@ -154,7 +154,7 @@ static void vx2_reset_dsp(vx_core_t *_chip) /* set the reset dsp bit to 0 */ vx_outl(chip, CDSP, chip->regCDSP & ~VX_CDSP_DSP_RESET_MASK); - snd_vx_delay(_chip, XX_DSP_RESET_WAIT_TIME); + mdelay(XX_DSP_RESET_WAIT_TIME); chip->regCDSP |= VX_CDSP_DSP_RESET_MASK; /* set the reset dsp bit to 1 */ @@ -362,10 +362,10 @@ static int vx2_load_xilinx_binary(vx_core_t *chip, const struct firmware *xilinx /* XILINX reset (wait at least 1 milisecond between reset on and off). */ vx_outl(chip, CNTRL, VX_CNTRL_REGISTER_VALUE | VX_XILINX_RESET_MASK); vx_inl(chip, CNTRL); - snd_vx_delay(chip, 10); + msleep(10); vx_outl(chip, CNTRL, VX_CNTRL_REGISTER_VALUE); vx_inl(chip, CNTRL); - snd_vx_delay(chip, 10); + msleep(10); if (chip->type == VX_TYPE_BOARD) port = VX_CNTRL; @@ -381,7 +381,7 @@ static int vx2_load_xilinx_binary(vx_core_t *chip, const struct firmware *xilinx } put_xilinx_data(chip, port, 4, 0xff); /* end signature */ - snd_vx_delay(chip, 200); + msleep(200); /* test after loading (is buggy with VX222) */ if (chip->type != VX_TYPE_BOARD) { @@ -720,17 +720,17 @@ static void vx2_reset_codec(vx_core_t *_chip) /* Set the reset CODEC bit to 0. */ vx_outl(chip, CDSP, chip->regCDSP &~ VX_CDSP_CODEC_RESET_MASK); vx_inl(chip, CDSP); - snd_vx_delay(_chip, 10); + msleep(10); /* Set the reset CODEC bit to 1. */ chip->regCDSP |= VX_CDSP_CODEC_RESET_MASK; vx_outl(chip, CDSP, chip->regCDSP); vx_inl(chip, CDSP); if (_chip->type == VX_TYPE_BOARD) { - snd_vx_delay(_chip, 1); + msleep(1); return; } - snd_vx_delay(_chip, 5); /* additionnel wait time for AKM's */ + msleep(5); /* additionnel wait time for AKM's */ vx2_write_codec_reg(_chip, AKM_CODEC_POWER_CONTROL_CMD); /* DAC power up, ADC power up, Vref power down */ diff --git a/sound/pcmcia/vx/vxp_ops.c b/sound/pcmcia/vx/vxp_ops.c index 6f15c3d..2754d657 100644 --- a/sound/pcmcia/vx/vxp_ops.c +++ b/sound/pcmcia/vx/vxp_ops.c @@ -96,7 +96,7 @@ static int vx_check_magic(vx_core_t *chip) c = vx_inb(chip, CDSP); if (c == CDSP_MAGIC) return 0; - snd_vx_delay(chip, 10); + msleep(10); } while (time_after_eq(end_time, jiffies)); snd_printk(KERN_ERR "cannot find xilinx magic word (%x)\n", c); return -EIO; @@ -134,12 +134,12 @@ static void vxp_reset_codec(vx_core_t *_chip) /* Set the reset CODEC bit to 1. */ vx_outb(chip, CDSP, chip->regCDSP | VXP_CDSP_CODEC_RESET_MASK); vx_inb(chip, CDSP); - snd_vx_delay(_chip, 10); + msleep(10); /* Set the reset CODEC bit to 0. */ chip->regCDSP &= ~VXP_CDSP_CODEC_RESET_MASK; vx_outb(chip, CDSP, chip->regCDSP); vx_inb(chip, CDSP); - snd_vx_delay(_chip, 1); + msleep(1); } /* @@ -207,7 +207,7 @@ static int vxp_load_xilinx_binary(vx_core_t *_chip, const struct firmware *fw) vx_outb(chip, ICR, ICR_HF0); /* TEMPO 250ms : wait until Xilinx is downloaded */ - snd_vx_delay(_chip, 300); + msleep(300); /* test magical word */ if (vx_check_magic(_chip) < 0) @@ -221,7 +221,7 @@ static int vxp_load_xilinx_binary(vx_core_t *_chip, const struct firmware *fw) chip->regDIALOG |= VXP_DLG_XILINX_REPROG_MASK; vx_outb(chip, DIALOG, chip->regDIALOG); vx_inb(chip, DIALOG); - snd_vx_delay(_chip, 10); + msleep(10); chip->regDIALOG &= ~VXP_DLG_XILINX_REPROG_MASK; vx_outb(chip, DIALOG, chip->regDIALOG); vx_inb(chip, DIALOG); -- cgit v1.1 From c8714ba160a498e249dbd32c637b85a1efa1013b Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:22:32 +0100 Subject: [ALSA] Remove tea6330t struct definition from public header Modules: I2C tea6330t Remove tea6330t struct definition from public header. It's anyway unaccessible from outside. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/tea6330t.h | 16 ++-------------- sound/i2c/tea6330t.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/sound/tea6330t.h b/include/sound/tea6330t.h index 3896c0a..1b265bf 100644 --- a/include/sound/tea6330t.h +++ b/include/sound/tea6330t.h @@ -22,21 +22,9 @@ * */ -#include "control.h" #include "i2c.h" /* generic i2c support */ -typedef struct { - snd_i2c_device_t *device; - snd_i2c_bus_t *bus; - int equalizer; - int fader; - unsigned char regs[8]; - unsigned char mleft, mright; - unsigned char bass, treble; - unsigned char max_bass, max_treble; -} tea6330t_t; - -extern int snd_tea6330t_detect(snd_i2c_bus_t *bus, int equalizer); -extern int snd_tea6330t_update_mixer(snd_card_t * card, snd_i2c_bus_t * bus, int equalizer, int fader); +int snd_tea6330t_detect(snd_i2c_bus_t *bus, int equalizer); +int snd_tea6330t_update_mixer(snd_card_t * card, snd_i2c_bus_t * bus, int equalizer, int fader); #endif /* __SOUND_TEA6330T_H */ diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index 4fdd1fb..7bd4948 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c @@ -24,6 +24,7 @@ #include <linux/init.h> #include <linux/slab.h> #include <sound/core.h> +#include <sound/control.h> #include <sound/tea6330t.h> MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); @@ -43,6 +44,17 @@ MODULE_LICENSE("GPL"); #define TEA6330T_GMU 0x80 /* mute control, general mute */ #define TEA6330T_EQN 0x40 /* equalizer switchover (0=equalizer-on) */ +typedef struct { + snd_i2c_device_t *device; + snd_i2c_bus_t *bus; + int equalizer; + int fader; + unsigned char regs[8]; + unsigned char mleft, mright; + unsigned char bass, treble; + unsigned char max_bass, max_treble; +} tea6330t_t; + int snd_tea6330t_detect(snd_i2c_bus_t *bus, int equalizer) { int res; -- cgit v1.1 From 0948e3c8bb187b3dea38be1e1ffd1797866014f1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:25:22 +0100 Subject: [ALSA] Clean up sa11xx-uda1341 driver Modules: SA11xx UDA1341 driver,L3 drivers,UDA1341 Clean up sa11xx-uda1341 driver: - Fix buggy destructor - Remove the global variable - Move array definitions from uda1341.h - Make functions in uda1341.c static Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/uda1341.h | 107 +--------------------------- sound/arm/sa11xx-uda1341.c | 38 +++++----- sound/i2c/l3/uda1341.c | 170 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 154 insertions(+), 161 deletions(-) diff --git a/include/sound/uda1341.h b/include/sound/uda1341.h index 61ff65a..54a048a 100644 --- a/include/sound/uda1341.h +++ b/include/sound/uda1341.h @@ -15,7 +15,7 @@ * features support */ -/* $Id: uda1341.h,v 1.6 2004/05/03 17:36:50 tiwai Exp $ */ +/* $Id: uda1341.h,v 1.7 2005/11/17 10:25:22 tiwai Exp $ */ #define UDA1341_ALSA_NAME "snd-uda1341" @@ -37,11 +37,6 @@ enum uda1341_onoff { ON, }; -const char *onoff_names[] = { - "Off", - "On", -}; - enum uda1341_format { I2S=0, LSB16, @@ -53,17 +48,6 @@ enum uda1341_format { LSB20MSB, }; -const char *format_names[] = { - "I2S-bus", - "LSB 16bits", - "LSB 18bits", - "LSB 20bits", - "MSB", - "in LSB 16bits/out MSB", - "in LSB 18bits/out MSB", - "in LSB 20bits/out MSB", -}; - enum uda1341_fs { F512=0, F384, @@ -71,23 +55,11 @@ enum uda1341_fs { Funused, }; -const char *fs_names[] = { - "512*fs", - "384*fs", - "256*fs", - "Unused - bad value!", -}; - enum uda1341_peak { BEFORE=0, AFTER, }; -const char *peak_names[] = { - "before", - "after", -}; - enum uda1341_filter { FLAT=0, MIN, @@ -95,24 +67,6 @@ enum uda1341_filter { MAX, }; -const char *filter_names[] = { - "flat", - "min", - "min", - "max", -}; - -const char*bass_values[][16] = { - {"0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", - "0 dB", "0 dB", "0 dB", "0 dB", "undefined", }, //flat - {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", - "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min - {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", - "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min - {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "20 dB", - "22 dB", "24 dB", "24 dB", "24 dB", "undefined",}, // max -}; - enum uda1341_mixer { DOUBLE, LINE, @@ -120,13 +74,6 @@ enum uda1341_mixer { MIXER, }; -const char *mixer_names[] = { - "double differential", - "input channel 1 (line in)", - "input channel 2 (microphone)", - "digital mixer", -}; - enum uda1341_deemp { NONE, D32, @@ -134,58 +81,6 @@ enum uda1341_deemp { D48, }; -const char *deemp_names[] = { - "none", - "32 kHz", - "44.1 kHz", - "48 kHz", -}; - -const char *mic_sens_value[] = { - "-3 dB", "0 dB", "3 dB", "9 dB", "15 dB", "21 dB", "27 dB", "not used", -}; - -const unsigned short AGC_atime[] = { - 11, 16, 11, 16, 21, 11, 16, 21, -}; - -const unsigned short AGC_dtime[] = { - 100, 100, 200, 200, 200, 400, 400, 400, -}; - -const char *AGC_level[] = { - "-9.0", "-11.5", "-15.0", "-17.5", -}; - -const char *ig_small_value[] = { - "-3.0", "-2.5", "-2.0", "-1.5", "-1.0", "-0.5", -}; - -/* - * this was computed as peak_value[i] = pow((63-i)*1.42,1.013) - * - * UDA1341 datasheet on page 21: Peak value (dB) = (Peak level - 63.5)*5*log2 - * There is an table with these values [level]=value: [3]=-90.31, [7]=-84.29 - * [61]=-2.78, [62] = -1.48, [63] = 0.0 - * I tried to compute it, but using but even using logarithm with base either 10 or 2 - * i was'n able to get values in the table from the formula. So I constructed another - * formula (see above) to interpolate the values as good as possible. If there is some - * mistake, please contact me on tomas.kasparek@seznam.cz. Thanks. - * UDA1341TS datasheet is available at: - * http://www-us9.semiconductors.com/acrobat/datasheets/UDA1341TS_3.pdf - */ -const char *peak_value[] = { - "-INF dB", "N.A.", "N.A", "90.31 dB", "N.A.", "N.A.", "N.A.", "-84.29 dB", - "-82.65 dB", "-81.13 dB", "-79.61 dB", "-78.09 dB", "-76.57 dB", "-75.05 dB", "-73.53 dB", - "-72.01 dB", "-70.49 dB", "-68.97 dB", "-67.45 dB", "-65.93 dB", "-64.41 dB", "-62.90 dB", - "-61.38 dB", "-59.86 dB", "-58.35 dB", "-56.83 dB", "-55.32 dB", "-53.80 dB", "-52.29 dB", - "-50.78 dB", "-49.26 dB", "-47.75 dB", "-46.24 dB", "-44.73 dB", "-43.22 dB", "-41.71 dB", - "-40.20 dB", "-38.69 dB", "-37.19 dB", "-35.68 dB", "-34.17 dB", "-32.67 dB", "-31.17 dB", - "-29.66 dB", "-28.16 dB", "-26.66 dB", "-25.16 dB", "-23.66 dB", "-22.16 dB", "-20.67 dB", - "-19.17 dB", "-17.68 dB", "-16.19 dB", "-14.70 dB", "-13.21 dB", "-11.72 dB", "-10.24 dB", - "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB", -}; - enum uda1341_config { CMD_READ_REG = 0, CMD_RESET, diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 6ee9122..97dffcc 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -21,7 +21,7 @@ * merged HAL layer (patches from Brian) */ -/* $Id: sa11xx-uda1341.c,v 1.23 2005/09/09 13:22:34 tiwai Exp $ */ +/* $Id: sa11xx-uda1341.c,v 1.24 2005/11/17 10:25:22 tiwai Exp $ */ /*************************************************************************************************** * @@ -141,8 +141,6 @@ typedef struct snd_card_sa11xx_uda1341 { audio_stream_t s[2]; /* playback & capture */ } sa11xx_uda1341_t; -static struct snd_card_sa11xx_uda1341 *sa11xx_uda1341 = NULL; - static unsigned int rates[] = { 8000, 10666, 10985, 14647, 16000, 21970, 22050, 24000, @@ -411,8 +409,8 @@ static int audio_dma_request(audio_stream_t *s, void (*callback)(void *)) static void audio_dma_free(audio_stream_t *s) { - sa1100_free_dma((s)->dma_regs); - (s)->dma_regs = 0; + sa1100_free_dma(s->dma_regs); + s->dma_regs = 0; } #endif @@ -835,8 +833,8 @@ static int __init snd_card_sa11xx_uda1341_pcm(sa11xx_uda1341_t *sa11xx_uda1341, * isa works but I'm not sure why (or if) it's the right choice * this may be too large, trying it for now */ - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_ISA, - snd_pcm_dma_flags(0), + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_dma_isa_data(), 64*1024, 64*1024); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_sa11xx_uda1341_playback_ops); @@ -900,15 +898,15 @@ void snd_sa11xx_uda1341_free(snd_card_t *card) audio_dma_free(&chip->s[SNDRV_PCM_STREAM_PLAYBACK]); audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]); - sa11xx_uda1341 = NULL; - card->private_data = NULL; - kfree(chip); } +static snd_card_t *sa11xx_uda1341_card; + static int __init sa11xx_uda1341_init(void) { int err; snd_card_t *card; + sa11xx_uda1341_t *chip; if (!machine_is_h3xxx()) return -ENODEV; @@ -921,26 +919,25 @@ static int __init sa11xx_uda1341_init(void) sa11xx_uda1341 = kzalloc(sizeof(*sa11xx_uda1341), GFP_KERNEL); if (sa11xx_uda1341 == NULL) return -ENOMEM; + card->private_free = snd_sa11xx_uda1341_free; + chip = card->private_data; spin_lock_init(&chip->s[0].dma_lock); spin_lock_init(&chip->s[1].dma_lock); - card->private_data = (void *)sa11xx_uda1341; - card->private_free = snd_sa11xx_uda1341_free; - - sa11xx_uda1341->card = card; - sa11xx_uda1341->samplerate = AUDIO_RATE_DEFAULT; + chip->card = card; + chip->samplerate = AUDIO_RATE_DEFAULT; // mixer - if ((err = snd_chip_uda1341_mixer_new(sa11xx_uda1341->card, &sa11xx_uda1341->uda1341))) + if ((err = snd_chip_uda1341_mixer_new(chip->card, &sa11xx_uda1341->uda1341))) goto nodev; // PCM - if ((err = snd_card_sa11xx_uda1341_pcm(sa11xx_uda1341, 0)) < 0) + if ((err = snd_card_sa11xx_uda1341_pcm(chip, 0)) < 0) goto nodev; snd_card_set_generic_pm_callback(card, - snd_sa11xx_uda1341_suspend, snd_sa11_uda1341_resume, - sa11xx_uda1341); + snd_sa11xx_uda1341_suspend, snd_sa11_uda1341_resume, + chip); strcpy(card->driver, "UDA1341"); strcpy(card->shortname, "H3600 UDA1341TS"); @@ -951,6 +948,7 @@ static int __init sa11xx_uda1341_init(void) if ((err = snd_card_register(card)) == 0) { printk( KERN_INFO "iPAQ audio support initialized\n" ); + sa11xx_uda1341_card = card; return 0; } @@ -961,7 +959,7 @@ static int __init sa11xx_uda1341_init(void) static void __exit sa11xx_uda1341_exit(void) { - snd_card_free(sa11xx_uda1341->card); + snd_card_free(sa11xx_uda1341_card); } module_init(sa11xx_uda1341_init); diff --git a/sound/i2c/l3/uda1341.c b/sound/i2c/l3/uda1341.c index 103a7dc..bc7eb23 100644 --- a/sound/i2c/l3/uda1341.c +++ b/sound/i2c/l3/uda1341.c @@ -17,7 +17,7 @@ * 2002-05-12 Tomas Kasparek another code cleanup */ -/* $Id: uda1341.c,v 1.16 2005/09/09 13:22:34 tiwai Exp $ */ +/* $Id: uda1341.c,v 1.17 2005/11/17 10:25:22 tiwai Exp $ */ #include <sound/driver.h> #include <linux/module.h> @@ -56,6 +56,33 @@ /* }}} */ + +static const char *peak_names[] = { + "before", + "after", +}; + +static const char *filter_names[] = { + "flat", + "min", + "min", + "max", +}; + +static const char *mixer_names[] = { + "double differential", + "input channel 1 (line in)", + "input channel 2 (microphone)", + "digital mixer", +}; + +static const char *deemp_names[] = { + "none", + "32 kHz", + "44.1 kHz", + "48 kHz", +}; + enum uda1341_regs_names { stat0, stat1, @@ -73,7 +100,7 @@ enum uda1341_regs_names { uda1341_reg_last, }; -const char *uda1341_reg_names[] = { +static const char *uda1341_reg_names[] = { "stat 0 ", "stat 1 ", "data 00", @@ -89,7 +116,7 @@ const char *uda1341_reg_names[] = { "ext 6", }; -const int uda1341_enum_items[] = { +static const int uda1341_enum_items[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, //peak - before/after 4, //deemp - none/32/44.1/48 @@ -100,7 +127,7 @@ const int uda1341_enum_items[] = { 0, 0, 0, 0, 0, }; -const char ** uda1341_enum_names[] = { +static const char ** uda1341_enum_names[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, peak_names, //peak - before/after deemp_names, //deemp - none/32/44.1/48 @@ -129,11 +156,9 @@ struct uda1341 { #endif }; -//hack for ALSA magic casting -typedef struct l3_client l3_client_t; - /* transfer 8bit integer into string with binary representation */ -void int2str_bin8(uint8_t val, char *buf){ +static void int2str_bin8(uint8_t val, char *buf) +{ const int size = sizeof(val) * 8; int i; @@ -146,7 +171,7 @@ void int2str_bin8(uint8_t val, char *buf){ /* {{{ HW manipulation routines */ -int snd_uda1341_codec_write(struct l3_client *clnt, unsigned short reg, unsigned short val) +static int snd_uda1341_codec_write(struct l3_client *clnt, unsigned short reg, unsigned short val) { struct uda1341 *uda = clnt->driver_data; unsigned char buf[2] = { 0xc0, 0xe0 }; // for EXT addressing @@ -171,7 +196,7 @@ int snd_uda1341_codec_write(struct l3_client *clnt, unsigned short reg, unsigned return err; } -int snd_uda1341_codec_read(struct l3_client *clnt, unsigned short reg) +static int snd_uda1341_codec_read(struct l3_client *clnt, unsigned short reg) { unsigned char val; int err; @@ -188,8 +213,9 @@ static inline int snd_uda1341_valid_reg(struct l3_client *clnt, unsigned short r return reg < uda1341_reg_last; } -int snd_uda1341_update_bits(struct l3_client *clnt, unsigned short reg, unsigned short mask, - unsigned short shift, unsigned short value, int flush) +static int snd_uda1341_update_bits(struct l3_client *clnt, unsigned short reg, + unsigned short mask, unsigned short shift, + unsigned short value, int flush) { int change; unsigned short old, new; @@ -214,8 +240,8 @@ int snd_uda1341_update_bits(struct l3_client *clnt, unsigned short reg, unsigned return change; } -int snd_uda1341_cfg_write(struct l3_client *clnt, unsigned short what, - unsigned short value, int flush) +static int snd_uda1341_cfg_write(struct l3_client *clnt, unsigned short what, + unsigned short value, int flush) { struct uda1341 *uda = clnt->driver_data; int ret = 0; @@ -327,6 +353,81 @@ int snd_uda1341_cfg_write(struct l3_client *clnt, unsigned short what, /* }}} */ /* {{{ Proc interface */ +#ifdef CONFIG_PROC_FS + +static const char *format_names[] = { + "I2S-bus", + "LSB 16bits", + "LSB 18bits", + "LSB 20bits", + "MSB", + "in LSB 16bits/out MSB", + "in LSB 18bits/out MSB", + "in LSB 20bits/out MSB", +}; + +static const char *fs_names[] = { + "512*fs", + "384*fs", + "256*fs", + "Unused - bad value!", +}; + +static const char* bass_values[][16] = { + {"0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", "0 dB", + "0 dB", "0 dB", "0 dB", "0 dB", "undefined", }, //flat + {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", + "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min + {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "18 dB", + "18 dB", "18 dB", "18 dB", "18 dB", "undefined",}, // min + {"0 dB", "2 dB", "4 dB", "6 dB", "8 dB", "10 dB", "12 dB", "14 dB", "16 dB", "18 dB", "20 dB", + "22 dB", "24 dB", "24 dB", "24 dB", "undefined",}, // max +}; + +static const char *mic_sens_value[] = { + "-3 dB", "0 dB", "3 dB", "9 dB", "15 dB", "21 dB", "27 dB", "not used", +}; + +static const unsigned short AGC_atime[] = { + 11, 16, 11, 16, 21, 11, 16, 21, +}; + +static const unsigned short AGC_dtime[] = { + 100, 100, 200, 200, 200, 400, 400, 400, +}; + +static const char *AGC_level[] = { + "-9.0", "-11.5", "-15.0", "-17.5", +}; + +static const char *ig_small_value[] = { + "-3.0", "-2.5", "-2.0", "-1.5", "-1.0", "-0.5", +}; + +/* + * this was computed as peak_value[i] = pow((63-i)*1.42,1.013) + * + * UDA1341 datasheet on page 21: Peak value (dB) = (Peak level - 63.5)*5*log2 + * There is an table with these values [level]=value: [3]=-90.31, [7]=-84.29 + * [61]=-2.78, [62] = -1.48, [63] = 0.0 + * I tried to compute it, but using but even using logarithm with base either 10 or 2 + * i was'n able to get values in the table from the formula. So I constructed another + * formula (see above) to interpolate the values as good as possible. If there is some + * mistake, please contact me on tomas.kasparek@seznam.cz. Thanks. + * UDA1341TS datasheet is available at: + * http://www-us9.semiconductors.com/acrobat/datasheets/UDA1341TS_3.pdf + */ +static const char *peak_value[] = { + "-INF dB", "N.A.", "N.A", "90.31 dB", "N.A.", "N.A.", "N.A.", "-84.29 dB", + "-82.65 dB", "-81.13 dB", "-79.61 dB", "-78.09 dB", "-76.57 dB", "-75.05 dB", "-73.53 dB", + "-72.01 dB", "-70.49 dB", "-68.97 dB", "-67.45 dB", "-65.93 dB", "-64.41 dB", "-62.90 dB", + "-61.38 dB", "-59.86 dB", "-58.35 dB", "-56.83 dB", "-55.32 dB", "-53.80 dB", "-52.29 dB", + "-50.78 dB", "-49.26 dB", "-47.75 dB", "-46.24 dB", "-44.73 dB", "-43.22 dB", "-41.71 dB", + "-40.20 dB", "-38.69 dB", "-37.19 dB", "-35.68 dB", "-34.17 dB", "-32.67 dB", "-31.17 dB", + "-29.66 dB", "-28.16 dB", "-26.66 dB", "-25.16 dB", "-23.66 dB", "-22.16 dB", "-20.67 dB", + "-19.17 dB", "-17.68 dB", "-16.19 dB", "-14.70 dB", "-13.21 dB", "-11.72 dB", "-10.24 dB", + "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB", +}; static void snd_uda1341_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) @@ -401,7 +502,6 @@ static void snd_uda1341_proc_regs_read(snd_info_entry_t *entry, int reg; char buf[12]; - spin_lock(&uda->reg_lock); for (reg = 0; reg < uda1341_reg_last; reg ++) { if (reg == empty) continue; @@ -411,9 +511,8 @@ static void snd_uda1341_proc_regs_read(snd_info_entry_t *entry, int2str_bin8(snd_uda1341_codec_read(clnt, UDA1341_DATA1), buf); snd_iprintf(buffer, "DATA1 = %s\n", buf); - - spin_unlock(&uda->reg_lock); } +#endif /* CONFIG_PROC_FS */ static void __devinit snd_uda1341_proc_init(snd_card_t *card, struct l3_client *clnt) { @@ -647,10 +746,10 @@ static snd_kcontrol_new_t snd_uda1341_controls[] = { UDA1341_2REGS("Gain Input Amplifier Gain (channel 2)", CMD_IG, ext4, ext5, 0, 0, 3, 31, 0), }; -static void uda1341_free(struct l3_client *uda1341) +static void uda1341_free(struct l3_client *clnt) { - l3_detach_client(uda1341); // calls kfree for driver_data (uda1341_t) - kfree(uda1341); + l3_detach_client(clnt); // calls kfree for driver_data (uda1341_t) + kfree(clnt); } static int uda1341_dev_free(snd_device_t *device) @@ -660,41 +759,42 @@ static int uda1341_dev_free(snd_device_t *device) return 0; } -int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clnt) +int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clntp) { static snd_device_ops_t ops = { .dev_free = uda1341_dev_free, }; - struct l3_client *uda1341; + struct l3_client *clnt; int idx, err; snd_assert(card != NULL, return -EINVAL); - uda1341 = kzalloc(sizeof(*uda1341), GFP_KERNEL); - if (uda1341 == NULL) + clnt = kzalloc(sizeof(*clnt), GFP_KERNEL); + if (clnt == NULL) return -ENOMEM; - if ((err = l3_attach_client(uda1341, "l3-bit-sa1100-gpio", "snd-uda1341"))) { - kfree(uda1341); - return err; - } - - if ((err = snd_device_new(card, SNDRV_DEV_CODEC, uda1341, &ops)) < 0) { - l3_detach_client(uda1341); - kfree(uda1341); + if ((err = l3_attach_client(clnt, "l3-bit-sa1100-gpio", UDA1341_ALSA_NAME))) { + kfree(clnt); return err; } for (idx = 0; idx < ARRAY_SIZE(snd_uda1341_controls); idx++) { - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_uda1341_controls[idx], uda1341))) < 0) + if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_uda1341_controls[idx], clnt))) < 0) { + uda1341_free(clnt); return err; + } + } + + if ((err = snd_device_new(card, SNDRV_DEV_CODEC, clnt, &ops)) < 0) { + uda1341_free(clnt); + return err; } - *clnt = uda1341; + *clntp = clnt; strcpy(card->mixername, "UDA1341TS Mixer"); ((uda1341_t *)uda1341->driver_data)->card = card; - snd_uda1341_proc_init(card, uda1341); + snd_uda1341_proc_init(card, clnt); return 0; } -- cgit v1.1 From f739aeccedc7681a249bdae435e9af3e5476ad1d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:27:08 +0100 Subject: [ALSA] Clean up ISA cs4231 code Modules: CS4231 driver Clean up ISA cs4231 code, removing experimental EBUS/SBUS merge, to improve readability. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/cs4231.h | 39 -------------------- sound/isa/cs423x/cs4231_lib.c | 82 ++----------------------------------------- 2 files changed, 2 insertions(+), 119 deletions(-) diff --git a/include/sound/cs4231.h b/include/sound/cs4231.h index d7f9082..d956de9 100644 --- a/include/sound/cs4231.h +++ b/include/sound/cs4231.h @@ -26,21 +26,6 @@ #include "pcm.h" #include "timer.h" -#ifdef CONFIG_SBUS -#define SBUS_SUPPORT -#include <asm/sbus.h> -#endif - -#if defined(CONFIG_PCI) && defined(CONFIG_SPARC64) -#define EBUS_SUPPORT -#include <linux/pci.h> -#include <asm/ebus.h> -#endif - -#if !defined(SBUS_SUPPORT) && !defined(EBUS_SUPPORT) -#define LEGACY_SUPPORT -#endif - /* IO ports */ #define CS4231P(x) (c_d_c_CS4231##x) @@ -236,14 +221,12 @@ typedef struct _snd_cs4231 cs4231_t; struct _snd_cs4231 { unsigned long port; /* base i/o port */ -#ifdef LEGACY_SUPPORT struct resource *res_port; unsigned long cport; /* control base i/o port (CS4236) */ struct resource *res_cport; int irq; /* IRQ line */ int dma1; /* playback DMA */ int dma2; /* record DMA */ -#endif unsigned short version; /* version of CODEC chip */ unsigned short mode; /* see to CS4231_MODE_XXXX */ unsigned short hardware; /* see to CS4231_HW_XXXX */ @@ -251,24 +234,6 @@ struct _snd_cs4231 { unsigned short single_dma:1, /* forced single DMA mode (GUS 16-bit daughter board) or dma1 == dma2 */ ebus_flag:1; /* SPARC: EBUS present */ -#ifdef EBUS_SUPPORT - struct ebus_dma_info eb2c; - struct ebus_dma_info eb2p; -#endif - -#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT) - union { -#ifdef SBUS_SUPPORT - struct sbus_dev *sdev; -#endif -#ifdef EBUS_SUPPORT - struct pci_dev *pdev; -#endif - } dev_u; - unsigned int p_periods_sent; - unsigned int c_periods_sent; -#endif - snd_card_t *card; snd_pcm_t *pcm; snd_pcm_substream_t *playback_substream; @@ -281,10 +246,8 @@ struct _snd_cs4231 { int mce_bit; int calibrate_mute; int sw_3d_bit; -#ifdef LEGACY_SUPPORT unsigned int p_dma_size; unsigned int c_dma_size; -#endif spinlock_t reg_lock; struct semaphore mce_mutex; @@ -299,10 +262,8 @@ struct _snd_cs4231 { void (*resume) (cs4231_t *chip); #endif void *dma_private_data; -#ifdef LEGACY_SUPPORT int (*claim_dma) (cs4231_t *chip, void *dma_private_data, int dma); int (*release_dma) (cs4231_t *chip, void *dma_private_data, int dma); -#endif }; /* exported functions */ diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 4c9fb16..94e07a7c 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -124,46 +124,14 @@ static unsigned char snd_cs4231_original_image[32] = * Basic I/O functions */ -#if !defined(EBUS_SUPPORT) && !defined(SBUS_SUPPORT) -#define __CS4231_INLINE__ inline -#else -#define __CS4231_INLINE__ /* nothing */ -#endif - -static __CS4231_INLINE__ void cs4231_outb(cs4231_t *chip, u8 offset, u8 val) +static inline void cs4231_outb(cs4231_t *chip, u8 offset, u8 val) { -#ifdef EBUS_SUPPORT - if (chip->ebus->flag) { - writeb(val, chip->port + (offset << 2)); - } else { -#endif -#ifdef SBUS_SUPPORT - sbus_writeb(val, chip->port + (offset << 2)); -#endif -#ifdef EBUS_SUPPORT - } -#endif -#ifdef LEGACY_SUPPORT outb(val, chip->port + offset); -#endif } -static __CS4231_INLINE__ u8 cs4231_inb(cs4231_t *chip, u8 offset) +static inline u8 cs4231_inb(cs4231_t *chip, u8 offset) { -#ifdef EBUS_SUPPORT - if (chip->ebus_flag) { - return readb(chip->port + (offset << 2)); - } else { -#endif -#ifdef SBUS_SUPPORT - return sbus_readb(chip->port + (offset << 2)); -#endif -#ifdef EBUS_SUPPORT - } -#endif -#ifdef LEGACY_SUPPORT return inb(chip->port + offset); -#endif } static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, @@ -874,7 +842,6 @@ static int snd_cs4231_playback_hw_free(snd_pcm_substream_t * substream) return snd_pcm_lib_free_pages(substream); } -#ifdef LEGACY_SUPPORT static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) { cs4231_t *chip = snd_pcm_substream_chip(substream); @@ -896,7 +863,6 @@ static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) #endif return 0; } -#endif /* LEGACY_SUPPORT */ static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, snd_pcm_hw_params_t * hw_params) @@ -918,7 +884,6 @@ static int snd_cs4231_capture_hw_free(snd_pcm_substream_t * substream) return snd_pcm_lib_free_pages(substream); } -#ifdef LEGACY_SUPPORT static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) { cs4231_t *chip = snd_pcm_substream_chip(substream); @@ -942,7 +907,6 @@ static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) spin_unlock_irqrestore(&chip->reg_lock, flags); return 0; } -#endif static void snd_cs4231_overrange(cs4231_t *chip) { @@ -998,7 +962,6 @@ irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) return IRQ_HANDLED; } -#ifdef LEGACY_SUPPORT static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream) { cs4231_t *chip = snd_pcm_substream_chip(substream); @@ -1020,7 +983,6 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr ptr = snd_dma_pointer(chip->dma2, chip->c_dma_size); return bytes_to_frames(substream->runtime, ptr); } -#endif /* LEGACY_SUPPORT */ /* @@ -1253,7 +1215,6 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) chip->hardware == CS4231_HW_CS4239) runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; -#ifdef LEGACY_SUPPORT snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.buffer_bytes_max); snd_pcm_limit_isa_dma_size(chip->dma1, &runtime->hw.period_bytes_max); @@ -1261,20 +1222,14 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma1)) < 0) return err; } -#endif if ((err = snd_cs4231_open(chip, CS4231_MODE_PLAY)) < 0) { -#ifdef LEGACY_SUPPORT if (chip->release_dma) chip->release_dma(chip, chip->dma_private_data, chip->dma1); -#endif snd_free_pages(runtime->dma_area, runtime->dma_bytes); return err; } chip->playback_substream = substream; -#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT) - chip->p_periods_sent = 0; -#endif snd_pcm_set_sync(substream); chip->rate_constraint(runtime); return 0; @@ -1293,7 +1248,6 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) chip->hardware == CS4231_HW_CS4239) runtime->hw.formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE; -#ifdef LEGACY_SUPPORT snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.buffer_bytes_max); snd_pcm_limit_isa_dma_size(chip->dma2, &runtime->hw.period_bytes_max); @@ -1301,20 +1255,14 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) if ((err = chip->claim_dma(chip, chip->dma_private_data, chip->dma2)) < 0) return err; } -#endif if ((err = snd_cs4231_open(chip, CS4231_MODE_RECORD)) < 0) { -#ifdef LEGACY_SUPPORT if (chip->release_dma) chip->release_dma(chip, chip->dma_private_data, chip->dma2); -#endif snd_free_pages(runtime->dma_area, runtime->dma_bytes); return err; } chip->capture_substream = substream; -#if defined(SBUS_SUPPORT) || defined(EBUS_SUPPORT) - chip->c_periods_sent = 0; -#endif snd_pcm_set_sync(substream); chip->rate_constraint(runtime); return 0; @@ -1413,8 +1361,6 @@ static int snd_cs4231_pm_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -#ifdef LEGACY_SUPPORT - static int snd_cs4231_free(cs4231_t *chip) { release_and_free_resource(chip->res_port); @@ -1444,8 +1390,6 @@ static int snd_cs4231_dev_free(snd_device_t *device) return snd_cs4231_free(chip); } -#endif /* LEGACY_SUPPORT */ - const char *snd_cs4231_chip_id(cs4231_t *chip) { switch (chip->hardware) { @@ -1493,8 +1437,6 @@ static int snd_cs4231_new(snd_card_t * card, return 0; } -#ifdef LEGACY_SUPPORT - int snd_cs4231_create(snd_card_t * card, unsigned long port, unsigned long cport, @@ -1581,8 +1523,6 @@ int snd_cs4231_create(snd_card_t * card, return 0; } -#endif /* LEGACY_SUPPORT */ - static snd_pcm_ops_t snd_cs4231_playback_ops = { .open = snd_cs4231_playback_open, .close = snd_cs4231_playback_close, @@ -1629,27 +1569,9 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) pcm->info_flags |= SNDRV_PCM_INFO_JOINT_DUPLEX; strcpy(pcm->name, snd_cs4231_chip_id(chip)); -#ifdef LEGACY_SUPPORT snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(), 64*1024, chip->dma1 > 3 || chip->dma2 > 3 ? 128*1024 : 64*1024); -#else -# ifdef EBUS_SUPPORT - if (chip->ebus_flag) { - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - chip->dev_u.pdev, - 64*1024, 128*1024); - } else { -# endif -# ifdef SBUS_SUPPORT - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_SBUS, - chip->dev_u.sdev, - 64*1024, 128*1024); -# endif -# ifdef EBUS_SUPPORT - } -# endif -#endif chip->pcm = pcm; if (rpcm) -- cgit v1.1 From bc1ff7fc0ae6ec2d7f2202d9126901aeb3f596cd Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:28:15 +0100 Subject: [ALSA] [Trivial] Fix spaces in gus.h Modules: GUS Library Fix spaces in gus.h. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/gus.h | 62 ++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/include/sound/gus.h b/include/sound/gus.h index 7000d9d..bb12e9f 100644 --- a/include/sound/gus.h +++ b/include/sound/gus.h @@ -49,32 +49,32 @@ #define SNDRV_g_u_s_IRQSTAT (0x226-0x220) #define SNDRV_g_u_s_TIMERCNTRL (0x228-0x220) #define SNDRV_g_u_s_TIMERDATA (0x229-0x220) -#define SNDRV_g_u_s_DRAM (0x327-0x220) +#define SNDRV_g_u_s_DRAM (0x327-0x220) #define SNDRV_g_u_s_MIXCNTRLREG (0x220-0x220) #define SNDRV_g_u_s_IRQDMACNTRLREG (0x22b-0x220) #define SNDRV_g_u_s_REGCNTRLS (0x22f-0x220) -#define SNDRV_g_u_s_BOARDVERSION (0x726-0x220) -#define SNDRV_g_u_s_MIXCNTRLPORT (0x726-0x220) -#define SNDRV_g_u_s_IVER (0x325-0x220) +#define SNDRV_g_u_s_BOARDVERSION (0x726-0x220) +#define SNDRV_g_u_s_MIXCNTRLPORT (0x726-0x220) +#define SNDRV_g_u_s_IVER (0x325-0x220) #define SNDRV_g_u_s_MIXDATAPORT (0x326-0x220) -#define SNDRV_g_u_s_MAXCNTRLPORT (0x326-0x220) +#define SNDRV_g_u_s_MAXCNTRLPORT (0x326-0x220) /* GF1 registers */ /* global registers */ #define SNDRV_GF1_GB_ACTIVE_VOICES 0x0e #define SNDRV_GF1_GB_VOICES_IRQ 0x0f -#define SNDRV_GF1_GB_GLOBAL_MODE 0x19 +#define SNDRV_GF1_GB_GLOBAL_MODE 0x19 #define SNDRV_GF1_GW_LFO_BASE 0x1a #define SNDRV_GF1_GB_VOICES_IRQ_READ 0x1f #define SNDRV_GF1_GB_DRAM_DMA_CONTROL 0x41 -#define SNDRV_GF1_GW_DRAM_DMA_LOW 0x42 -#define SNDRV_GF1_GW_DRAM_IO_LOW 0x43 -#define SNDRV_GF1_GB_DRAM_IO_HIGH 0x44 +#define SNDRV_GF1_GW_DRAM_DMA_LOW 0x42 +#define SNDRV_GF1_GW_DRAM_IO_LOW 0x43 +#define SNDRV_GF1_GB_DRAM_IO_HIGH 0x44 #define SNDRV_GF1_GB_SOUND_BLASTER_CONTROL 0x45 #define SNDRV_GF1_GB_ADLIB_TIMER_1 0x46 #define SNDRV_GF1_GB_ADLIB_TIMER_2 0x47 -#define SNDRV_GF1_GB_RECORD_RATE 0x48 +#define SNDRV_GF1_GB_RECORD_RATE 0x48 #define SNDRV_GF1_GB_REC_DMA_CONTROL 0x49 #define SNDRV_GF1_GB_JOYSTICK_DAC_LEVEL 0x4b #define SNDRV_GF1_GB_RESET 0x4c @@ -83,7 +83,7 @@ #define SNDRV_GF1_GW_MEMORY_CONFIG 0x52 #define SNDRV_GF1_GB_MEMORY_CONTROL 0x53 #define SNDRV_GF1_GW_FIFO_RECORD_BASE_ADDR 0x54 -#define SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR 0x55 +#define SNDRV_GF1_GW_FIFO_PLAY_BASE_ADDR 0x55 #define SNDRV_GF1_GW_FIFO_SIZE 0x56 #define SNDRV_GF1_GW_INTERLEAVE 0x57 #define SNDRV_GF1_GB_COMPATIBILITY 0x59 @@ -100,39 +100,39 @@ #define SNDRV_GF1_VA_START SNDRV_GF1_VW_START_HIGH #define SNDRV_GF1_VW_END_HIGH 0x04 #define SNDRV_GF1_VW_END_LOW 0x05 -#define SNDRV_GF1_VA_END SNDRV_GF1_VW_END_HIGH -#define SNDRV_GF1_VB_VOLUME_RATE 0x06 -#define SNDRV_GF1_VB_VOLUME_START 0x07 +#define SNDRV_GF1_VA_END SNDRV_GF1_VW_END_HIGH +#define SNDRV_GF1_VB_VOLUME_RATE 0x06 +#define SNDRV_GF1_VB_VOLUME_START 0x07 #define SNDRV_GF1_VB_VOLUME_END 0x08 #define SNDRV_GF1_VW_VOLUME 0x09 -#define SNDRV_GF1_VW_CURRENT_HIGH 0x0a -#define SNDRV_GF1_VW_CURRENT_LOW 0x0b +#define SNDRV_GF1_VW_CURRENT_HIGH 0x0a +#define SNDRV_GF1_VW_CURRENT_LOW 0x0b #define SNDRV_GF1_VA_CURRENT SNDRV_GF1_VW_CURRENT_HIGH -#define SNDRV_GF1_VB_PAN 0x0c -#define SNDRV_GF1_VW_OFFSET_RIGHT 0x0c +#define SNDRV_GF1_VB_PAN 0x0c +#define SNDRV_GF1_VW_OFFSET_RIGHT 0x0c #define SNDRV_GF1_VB_VOLUME_CONTROL 0x0d #define SNDRV_GF1_VB_UPPER_ADDRESS 0x10 -#define SNDRV_GF1_VW_EFFECT_HIGH 0x11 +#define SNDRV_GF1_VW_EFFECT_HIGH 0x11 #define SNDRV_GF1_VW_EFFECT_LOW 0x12 #define SNDRV_GF1_VA_EFFECT SNDRV_GF1_VW_EFFECT_HIGH -#define SNDRV_GF1_VW_OFFSET_LEFT 0x13 -#define SNDRV_GF1_VB_ACCUMULATOR 0x14 -#define SNDRV_GF1_VB_MODE 0x15 +#define SNDRV_GF1_VW_OFFSET_LEFT 0x13 +#define SNDRV_GF1_VB_ACCUMULATOR 0x14 +#define SNDRV_GF1_VB_MODE 0x15 #define SNDRV_GF1_VW_EFFECT_VOLUME 0x16 #define SNDRV_GF1_VB_FREQUENCY_LFO 0x17 #define SNDRV_GF1_VB_VOLUME_LFO 0x18 #define SNDRV_GF1_VW_OFFSET_RIGHT_FINAL 0x1b #define SNDRV_GF1_VW_OFFSET_LEFT_FINAL 0x1c -#define SNDRV_GF1_VW_EFFECT_VOLUME_FINAL 0x1d +#define SNDRV_GF1_VW_EFFECT_VOLUME_FINAL 0x1d /* ICS registers */ #define SNDRV_ICS_MIC_DEV 0 -#define SNDRV_ICS_LINE_DEV 1 +#define SNDRV_ICS_LINE_DEV 1 #define SNDRV_ICS_CD_DEV 2 #define SNDRV_ICS_GF1_DEV 3 -#define SNDRV_ICS_NONE_DEV 4 -#define SNDRV_ICS_MASTER_DEV 5 +#define SNDRV_ICS_NONE_DEV 4 +#define SNDRV_ICS_MASTER_DEV 5 /* LFO */ @@ -143,7 +143,7 @@ #define SNDRV_GF1_DMA_UNSIGNED 0x80 #define SNDRV_GF1_DMA_16BIT 0x40 -#define SNDRV_GF1_DMA_IRQ 0x20 +#define SNDRV_GF1_DMA_IRQ 0x20 #define SNDRV_GF1_DMA_WIDTH16 0x04 #define SNDRV_GF1_DMA_READ 0x02 /* read from GUS's DRAM */ #define SNDRV_GF1_DMA_ENABLE 0x01 @@ -159,7 +159,7 @@ /* defines for memory manager */ -#define SNDRV_GF1_MEM_BLOCK_16BIT 0x0001 +#define SNDRV_GF1_MEM_BLOCK_16BIT 0x0001 #define SNDRV_GF1_MEM_OWNER_DRIVER 0x0001 #define SNDRV_GF1_MEM_OWNER_WAVE_SIMPLE 0x0002 @@ -169,9 +169,9 @@ /* constants for interrupt handlers */ #define SNDRV_GF1_HANDLER_MIDI_OUT 0x00010000 -#define SNDRV_GF1_HANDLER_MIDI_IN 0x00020000 -#define SNDRV_GF1_HANDLER_TIMER1 0x00040000 -#define SNDRV_GF1_HANDLER_TIMER2 0x00080000 +#define SNDRV_GF1_HANDLER_MIDI_IN 0x00020000 +#define SNDRV_GF1_HANDLER_TIMER1 0x00040000 +#define SNDRV_GF1_HANDLER_TIMER2 0x00080000 #define SNDRV_GF1_HANDLER_VOICE 0x00100000 #define SNDRV_GF1_HANDLER_DMA_WRITE 0x00200000 #define SNDRV_GF1_HANDLER_DMA_READ 0x00400000 -- cgit v1.1 From 6560c349c501388a1f3030d02fb49e7067e6597e Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:29:33 +0100 Subject: [ALSA] Clean up includes in asound.h & asequencer.h Modules: ALSA sequencer,ALSA Core Clean up includes in asound.h and asequencer.h. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/asequencer.h | 5 ++--- include/sound/asound.h | 26 ++------------------------ 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/include/sound/asequencer.h b/include/sound/asequencer.h index 728efd5..562637b 100644 --- a/include/sound/asequencer.h +++ b/include/sound/asequencer.h @@ -22,11 +22,10 @@ #ifndef __SOUND_ASEQUENCER_H #define __SOUND_ASEQUENCER_H -#ifndef __KERNEL__ +#ifdef __KERNEL__ #include <linux/ioctl.h> -#endif - #include <sound/asound.h> +#endif /** version of the sequencer */ #define SNDRV_SEQ_VERSION SNDRV_PROTOCOL_VERSION (1, 0, 1) diff --git a/include/sound/asound.h b/include/sound/asound.h index 8e552d6..1389704 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -23,12 +23,8 @@ #ifndef __SOUND_ASOUND_H #define __SOUND_ASOUND_H -#if defined(LINUX) || defined(__LINUX__) || defined(__linux__) - -#include <linux/ioctl.h> - #ifdef __KERNEL__ - +#include <linux/ioctl.h> #include <linux/types.h> #include <linux/time.h> #include <asm/byteorder.h> @@ -43,25 +39,7 @@ #endif #endif -#else /* !__KERNEL__ */ - -#include <endian.h> -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define SNDRV_LITTLE_ENDIAN -#elif __BYTE_ORDER == __BIG_ENDIAN -#define SNDRV_BIG_ENDIAN -#else -#error "Unsupported endian..." -#endif - -#endif /* __KERNEL **/ - -#endif /* LINUX */ - -#ifndef __KERNEL__ -#include <sys/time.h> -#include <sys/types.h> -#endif +#endif /* __KERNEL__ **/ /* * protocol version -- cgit v1.1 From 33ea25c113a7d63645b10ed89851e08f7c984d1a Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:32:43 +0100 Subject: [ALSA] au1x00 - Code clean up Modules: MIPS AU1x00 driver Clean up snd-au1x00 driver code: - Remove global variables - Remove old compatibility codes - Fix DMA-link allocation/release functions in hw_params and hw_free callbacks (they may be called multiple times) - Fix spinlocks Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/mips/au1x00.c | 300 ++++++++++++++++++++++++++-------------------------- 1 file changed, 150 insertions(+), 150 deletions(-) diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index d08a42b..a8f9a3b 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -50,12 +50,7 @@ MODULE_AUTHOR("Charles Eidsness <charles@cooper-street.com>"); MODULE_DESCRIPTION("Au1000 AC'97 ALSA Driver"); MODULE_LICENSE("GPL"); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) MODULE_SUPPORTED_DEVICE("{{AMD,Au1000 AC'97}}"); -#else -MODULE_CLASSES("{sound}"); -MODULE_DEVICES("{{AMD,Au1000 AC'97}}"); -#endif #define PLAYBACK 0 #define CAPTURE 1 @@ -68,8 +63,6 @@ MODULE_DEVICES("{{AMD,Au1000 AC'97}}"); #define READ_WAIT 2 #define RW_DONE 3 -DECLARE_WAIT_QUEUE_HEAD(ac97_command_wq); - typedef struct au1000_period au1000_period_t; struct au1000_period { @@ -94,7 +87,8 @@ struct audio_stream { int dma; spinlock_t dma_lock; au1000_period_t * buffer; - unsigned long period_size; + unsigned int period_size; + unsigned int periods; }; typedef struct snd_card_au1000 { @@ -109,11 +103,9 @@ typedef struct snd_card_au1000 { audio_stream_t *stream[2]; /* playback & capture */ } au1000_t; -static au1000_t *au1000 = NULL; - /*--------------------------- Local Functions --------------------------------*/ static void -au1000_set_ac97_xmit_slots(long xmit_slots) +au1000_set_ac97_xmit_slots(au1000_t *au1000, long xmit_slots) { u32 volatile ac97_config; @@ -126,7 +118,7 @@ au1000_set_ac97_xmit_slots(long xmit_slots) } static void -au1000_set_ac97_recv_slots(long recv_slots) +au1000_set_ac97_recv_slots(au1000_t *au1000, long recv_slots) { u32 volatile ac97_config; @@ -140,79 +132,92 @@ au1000_set_ac97_recv_slots(long recv_slots) static void -au1000_dma_stop(audio_stream_t *stream) +au1000_release_dma_link(audio_stream_t *stream) { - unsigned long flags; au1000_period_t * pointer; au1000_period_t * pointer_next; - if (stream->buffer != NULL) { - spin_lock_irqsave(&stream->dma_lock, flags); - disable_dma(stream->dma); - spin_unlock_irqrestore(&stream->dma_lock, flags); + stream->period_size = 0; + stream->periods = 0; + pointer = stream->buffer; + if (! pointer) + return; + do { + pointer_next = pointer->next; + kfree(pointer); + pointer = pointer_next; + } while (pointer != stream->buffer); + stream->buffer = NULL; +} + +static int +au1000_setup_dma_link(audio_stream_t *stream, unsigned int period_bytes, + unsigned int periods) +{ + snd_pcm_substream_t *substream = stream->substream; + snd_pcm_runtime_t *runtime = substream->runtime; + unsigned long dma_start; + int i; + + dma_start = virt_to_phys(runtime->dma_area); - pointer = stream->buffer; - pointer_next = stream->buffer->next; + if (stream->period_size == period_bytes && + stream->periods == periods) + return 0; /* not changed */ - do { - kfree(pointer); - pointer = pointer_next; - pointer_next = pointer->next; - } while (pointer != stream->buffer); + au1000_release_dma_link(stream); - stream->buffer = NULL; + stream->period_size = period_bytes; + stream->periods = periods; + + stream->buffer = kmalloc(sizeof(au1000_period_t), GFP_KERNEL); + if (! stream->buffer) + return -ENOMEM; + pointer = stream->buffer; + for (i = 0; i < periods; i++) { + pointer->start = (u32)(dma_start + (i * period_bytes)); + pointer->relative_end = (u32) (((i+1) * period_bytes) - 0x1); + if (i < periods - 1) { + pointer->next = kmalloc(sizeof(struct au1000_period), GFP_KERNEL); + if (! pointer->next) { + au1000_release_dma_link(stream); + return -ENOMEM; + } + pointer = pointer->next; + } } + pointer->next = stream->buffer; + return 0; } static void -au1000_dma_start(audio_stream_t *stream) +au1000_dma_stop(audio_stream_t *stream) { - snd_pcm_substream_t *substream = stream->substream; - snd_pcm_runtime_t *runtime = substream->runtime; + snd_assert(stream->buffer, return); + disable_dma(stream->dma); +} - unsigned long flags, dma_start; - int i; - au1000_period_t * pointer; +static void +au1000_dma_start(audio_stream_t *stream) +{ + snd_assert(stream->buffer, return); - if (stream->buffer == NULL) { - dma_start = virt_to_phys(runtime->dma_area); - - stream->period_size = frames_to_bytes(runtime, - runtime->period_size); - stream->buffer = kmalloc(sizeof(au1000_period_t), GFP_KERNEL); - pointer = stream->buffer; - for (i = 0 ; i < runtime->periods ; i++) { - pointer->start = (u32)(dma_start + - (i * stream->period_size)); - pointer->relative_end = (u32) - (((i+1) * stream->period_size) - 0x1); - if ( i < runtime->periods - 1) { - pointer->next = kmalloc(sizeof(au1000_period_t) - , GFP_KERNEL); - pointer = pointer->next; - } - } - pointer->next = stream->buffer; - - spin_lock_irqsave(&stream->dma_lock, flags); - init_dma(stream->dma); - if (get_dma_active_buffer(stream->dma) == 0) { - clear_dma_done0(stream->dma); - set_dma_addr0(stream->dma, stream->buffer->start); - set_dma_count0(stream->dma, stream->period_size >> 1); - set_dma_addr1(stream->dma, stream->buffer->next->start); - set_dma_count1(stream->dma, stream->period_size >> 1); - } else { - clear_dma_done1(stream->dma); - set_dma_addr1(stream->dma, stream->buffer->start); - set_dma_count1(stream->dma, stream->period_size >> 1); - set_dma_addr0(stream->dma, stream->buffer->next->start); - set_dma_count0(stream->dma, stream->period_size >> 1); - } - enable_dma_buffers(stream->dma); - start_dma(stream->dma); - spin_unlock_irqrestore(&stream->dma_lock, flags); + init_dma(stream->dma); + if (get_dma_active_buffer(stream->dma) == 0) { + clear_dma_done0(stream->dma); + set_dma_addr0(stream->dma, stream->buffer->start); + set_dma_count0(stream->dma, stream->period_size >> 1); + set_dma_addr1(stream->dma, stream->buffer->next->start); + set_dma_count1(stream->dma, stream->period_size >> 1); + } else { + clear_dma_done1(stream->dma); + set_dma_addr1(stream->dma, stream->buffer->start); + set_dma_count1(stream->dma, stream->period_size >> 1); + set_dma_addr0(stream->dma, stream->buffer->next->start); + set_dma_count0(stream->dma, stream->period_size >> 1); } + enable_dma_buffers(stream->dma); + start_dma(stream->dma); } static irqreturn_t @@ -238,11 +243,9 @@ au1000_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) enable_dma_buffer1(stream->dma); break; case (DMA_D0 | DMA_D1): - spin_unlock(&stream->dma_lock); printk(KERN_ERR "DMA %d missed interrupt.\n",stream->dma); au1000_dma_stop(stream); au1000_dma_start(stream); - spin_lock(&stream->dma_lock); break; case (~DMA_D0 & ~DMA_D1): printk(KERN_ERR "DMA %d empty irq.\n",stream->dma); @@ -261,7 +264,7 @@ static snd_pcm_hw_constraint_list_t hw_constraints_rates = { .mask = 0, }; -static snd_pcm_hardware_t snd_au1000 = +static snd_pcm_hardware_t snd_au1000_hw = { .info = (SNDRV_PCM_INFO_INTERLEAVED | \ SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID), @@ -283,10 +286,12 @@ static snd_pcm_hardware_t snd_au1000 = static int snd_au1000_playback_open(snd_pcm_substream_t * substream) { + au1000_t *au1000 = substream->pcm->private_data; + au1000->stream[PLAYBACK]->substream = substream; au1000->stream[PLAYBACK]->buffer = NULL; substream->private_data = au1000->stream[PLAYBACK]; - substream->runtime->hw = snd_au1000; + substream->runtime->hw = snd_au1000_hw; return (snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates) < 0); } @@ -294,10 +299,12 @@ snd_au1000_playback_open(snd_pcm_substream_t * substream) static int snd_au1000_capture_open(snd_pcm_substream_t * substream) { + au1000_t *au1000 = substream->pcm->private_data; + au1000->stream[CAPTURE]->substream = substream; au1000->stream[CAPTURE]->buffer = NULL; substream->private_data = au1000->stream[CAPTURE]; - substream->runtime->hw = snd_au1000; + substream->runtime->hw = snd_au1000_hw; return (snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates) < 0); @@ -306,6 +313,8 @@ snd_au1000_capture_open(snd_pcm_substream_t * substream) static int snd_au1000_playback_close(snd_pcm_substream_t * substream) { + au1000_t *au1000 = substream->pcm->private_data; + au1000->stream[PLAYBACK]->substream = NULL; return 0; } @@ -313,6 +322,8 @@ snd_au1000_playback_close(snd_pcm_substream_t * substream) static int snd_au1000_capture_close(snd_pcm_substream_t * substream) { + au1000_t *au1000 = substream->pcm->private_data; + au1000->stream[CAPTURE]->substream = NULL; return 0; } @@ -321,25 +332,36 @@ static int snd_au1000_hw_params(snd_pcm_substream_t * substream, snd_pcm_hw_params_t * hw_params) { - return snd_pcm_lib_malloc_pages(substream, - params_buffer_bytes(hw_params)); + audio_stream_t *stream = substream->private_data; + int err; + + err = snd_pcm_lib_malloc_pages(substream, + params_buffer_bytes(hw_params)); + if (err < 0) + return err; + return au1000_setup_dma_link(stream, + params_period_bytes(hw_params), + params_periods(hw_params)); } static int snd_au1000_hw_free(snd_pcm_substream_t * substream) { + audio_stream_t *stream = substream->private_data; + au1000_release_dma_link(stream); return snd_pcm_lib_free_pages(substream); } static int snd_au1000_playback_prepare(snd_pcm_substream_t * substream) { + au1000_t *au1000 = substream->pcm->private_data; snd_pcm_runtime_t *runtime = substream->runtime; - if (runtime->channels == 1 ) - au1000_set_ac97_xmit_slots(AC97_SLOT_4); + if (runtime->channels == 1) + au1000_set_ac97_xmit_slots(au1000, AC97_SLOT_4); else - au1000_set_ac97_xmit_slots(AC97_SLOT_3 | AC97_SLOT_4); + au1000_set_ac97_xmit_slots(au1000, AC97_SLOT_3 | AC97_SLOT_4); snd_ac97_set_rate(au1000->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); return 0; } @@ -347,12 +369,13 @@ snd_au1000_playback_prepare(snd_pcm_substream_t * substream) static int snd_au1000_capture_prepare(snd_pcm_substream_t * substream) { + au1000_t *au1000 = substream->pcm->private_data; snd_pcm_runtime_t *runtime = substream->runtime; - if (runtime->channels == 1 ) - au1000_set_ac97_recv_slots(AC97_SLOT_4); + if (runtime->channels == 1) + au1000_set_ac97_recv_slots(au1000, AC97_SLOT_4); else - au1000_set_ac97_recv_slots(AC97_SLOT_3 | AC97_SLOT_4); + au1000_set_ac97_recv_slots(au1000, AC97_SLOT_3 | AC97_SLOT_4); snd_ac97_set_rate(au1000->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); return 0; } @@ -363,6 +386,7 @@ snd_au1000_trigger(snd_pcm_substream_t * substream, int cmd) audio_stream_t *stream = substream->private_data; int err = 0; + spin_lock(&stream->dma_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: au1000_dma_start(stream); @@ -374,6 +398,7 @@ snd_au1000_trigger(snd_pcm_substream_t * substream, int cmd) err = -EINVAL; break; } + spin_unlock(&stream->dma_lock); return err; } @@ -382,12 +407,11 @@ snd_au1000_pointer(snd_pcm_substream_t * substream) { audio_stream_t *stream = substream->private_data; snd_pcm_runtime_t *runtime = substream->runtime; - unsigned long flags; long location; - spin_lock_irqsave(&stream->dma_lock, flags); + spin_lock(&stream->dma_lock); location = get_dma_residue(stream->dma); - spin_unlock_irqrestore(&stream->dma_lock, flags); + spin_unlock(&stream->dma_lock); location = stream->buffer->relative_end - location; if (location == -1) location = 0; @@ -438,6 +462,9 @@ snd_au1000_pcm_new(void) pcm->info_flags = 0; strcpy(pcm->name, "Au1000 AC97 PCM"); + spin_lock_init(&au1000->stream[PLAYBACK]->dma_lock); + spin_lock_init(&au1000->stream[CAPTURE]->dma_lock); + flags = claim_dma_lock(); if ((au1000->stream[PLAYBACK]->dma = request_au1000_dma(DMA_ID_AC97C_TX, "AC97 TX", au1000_dma_interrupt, SA_INTERRUPT, @@ -457,8 +484,6 @@ snd_au1000_pcm_new(void) set_dma_mode(au1000->stream[CAPTURE]->dma, get_dma_mode(au1000->stream[CAPTURE]->dma) & ~DMA_NC); release_dma_lock(flags); - spin_lock_init(&au1000->stream[PLAYBACK]->dma_lock); - spin_lock_init(&au1000->stream[CAPTURE]->dma_lock); au1000->pcm = pcm; return 0; } @@ -469,9 +494,11 @@ snd_au1000_pcm_new(void) static unsigned short snd_au1000_ac97_read(ac97_t *ac97, unsigned short reg) { + au1000_t *au1000 = ac97->private_data; u32 volatile cmd; u16 volatile data; int i; + spin_lock(&au1000->ac97_lock); /* would rather use the interupt than this polling but it works and I can't get the interupt driven case to work efficiently */ @@ -505,8 +532,10 @@ get the interupt driven case to work efficiently */ static void snd_au1000_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) { + au1000_t *au1000 = ac97->private_data; u32 cmd; int i; + spin_lock(&au1000->ac97_lock); /* would rather use the interupt than this polling but it works and I can't get the interupt driven case to work efficiently */ @@ -522,28 +551,13 @@ get the interupt driven case to work efficiently */ au1000->ac97_ioport->cmd = cmd; spin_unlock(&au1000->ac97_lock); } -static void -snd_au1000_ac97_free(ac97_t *ac97) -{ - au1000->ac97 = NULL; -} static int __devinit -snd_au1000_ac97_new(void) +snd_au1000_ac97_new(au1000_t *au1000) { int err; - -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) - ac97_bus_t *pbus; - ac97_template_t ac97; - static ac97_bus_ops_t ops = { - .write = snd_au1000_ac97_write, - .read = snd_au1000_ac97_read, - }; -#else ac97_bus_t bus, *pbus; ac97_t ac97; -#endif if ((au1000->ac97_res_port = request_region(AC97C_CONFIG, sizeof(au1000_ac97_reg_t), "Au1x00 AC97")) == NULL) { @@ -554,8 +568,6 @@ snd_au1000_ac97_new(void) spin_lock_init(&au1000->ac97_lock); - spin_lock(&au1000->ac97_lock); - /* configure pins for AC'97 TODO: move to board_setup.c */ au_writel(au_readl(SYS_PINFUNC) & ~0x02, SYS_PINFUNC); @@ -572,26 +584,16 @@ snd_au1000_ac97_new(void) au1000->ac97_ioport->config = 0x0; mdelay(5); - spin_unlock(&au1000->ac97_lock); - /* Initialise AC97 middle-layer */ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8) if ((err = snd_ac97_bus(au1000->card, 0, &ops, au1000, &pbus)) < 0) return err; -#else - memset(&bus, 0, sizeof(bus)); - bus.write = snd_au1000_ac97_write; - bus.read = snd_au1000_ac97_read; - if ((err = snd_ac97_bus(au1000->card, &bus, &pbus)) < 0) - return err; -#endif + memset(&ac97, 0, sizeof(ac97)); ac97.private_data = au1000; - ac97.private_free = snd_au1000_ac97_free; if ((err = snd_ac97_mixer(pbus, &ac97, &au1000->ac97)) < 0) return err; - return 0; + return 0; } /*------------------------------ Setup / Destroy ----------------------------*/ @@ -599,6 +601,7 @@ snd_au1000_ac97_new(void) void snd_au1000_free(snd_card_t *card) { + au1000_t *au1000 = card->private_data; if (au1000->ac97_res_port) { /* put internal AC97 block into reset */ @@ -614,73 +617,70 @@ snd_au1000_free(snd_card_t *card) free_au1000_dma(au1000->stream[CAPTURE]->dma); kfree(au1000->stream[PLAYBACK]); - au1000->stream[PLAYBACK] = NULL; kfree(au1000->stream[CAPTURE]); - au1000->stream[CAPTURE] = NULL; - kfree(au1000); - au1000 = NULL; - } + +static snd_card_t *au1000_card; + static int __init au1000_init(void) { int err; + snd_card_t *card; + au1000_t *au1000; - au1000 = kmalloc(sizeof(au1000_t), GFP_KERNEL); - if (au1000 == NULL) - return -ENOMEM; - au1000->stream[PLAYBACK] = kmalloc(sizeof(audio_stream_t), GFP_KERNEL); - if (au1000->stream[PLAYBACK] == NULL) - return -ENOMEM; - au1000->stream[CAPTURE] = kmalloc(sizeof(audio_stream_t), GFP_KERNEL); - if (au1000->stream[CAPTURE] == NULL) + card = snd_card_new(-1, "AC97", THIS_MODULE, sizeof(au1000_t)); + if (card == NULL) return -ENOMEM; + + card->private_free = snd_au1000_free; + au1000 = card->private_data; /* so that snd_au1000_free will work as intended */ + au1000->card = card; au1000->stream[PLAYBACK]->dma = -1; au1000->stream[CAPTURE]->dma = -1; au1000->ac97_res_port = NULL; - - au1000->card = snd_card_new(-1, "AC97", THIS_MODULE, sizeof(au1000_t)); - if (au1000->card == NULL) { - snd_au1000_free(au1000->card); + au1000->stream[PLAYBACK] = kmalloc(sizeof(audio_stream_t), GFP_KERNEL); + au1000->stream[CAPTURE] = kmalloc(sizeof(audio_stream_t), GFP_KERNEL); + if (au1000->stream[PLAYBACK] == NULL || + au1000->stream[CAPTURE] == NULL) { + snd_card_free(card); return -ENOMEM; } - au1000->card->private_data = (au1000_t *)au1000; - au1000->card->private_free = snd_au1000_free; - - if ((err = snd_au1000_ac97_new()) < 0 ) { - snd_card_free(au1000->card); + if ((err = snd_au1000_ac97_new(au1000)) < 0 ) { + snd_card_free(card); return err; } - if ((err = snd_au1000_pcm_new()) < 0) { - snd_card_free(au1000->card); + if ((err = snd_au1000_pcm_new(au1000)) < 0) { + snd_card_free(card); return err; } - strcpy(au1000->card->driver, "AMD-Au1000-AC97"); - strcpy(au1000->card->shortname, "Au1000-AC97"); - sprintf(au1000->card->longname, "AMD Au1000--AC97 ALSA Driver"); + strcpy(card->driver, "Au1000-AC97"); + strcpy(card->shortname, "AMD Au1000-AC97"); + sprintf(card->longname, "AMD Au1000--AC97 ALSA Driver"); - if ((err = snd_card_set_generic_dev(au1000->card)) < 0) { - snd_card_free(au1000->card); + if ((err = snd_card_set_generic_dev(card)) < 0) { + snd_card_free(card); return err; } - if ((err = snd_card_register(au1000->card)) < 0) { - snd_card_free(au1000->card); + if ((err = snd_card_register(card)) < 0) { + snd_card_free(card); return err; } printk( KERN_INFO "ALSA AC97: Driver Initialized\n" ); + au1000_card = card; return 0; } static void __exit au1000_exit(void) { - snd_card_free(au1000->card); + snd_card_free(au1000_card); } module_init(au1000_init); -- cgit v1.1 From 03f9ae2505cf2f5d56c197b4045ed9dba5ce8912 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:34:40 +0100 Subject: [ALSA] harmony - Code clean up Modules: PARISC Harmony driver Clean up snd-harmony driver code: - Give standard module options - Fix spinlocks - Fix the error path of request_irq() - Clean up redundant codes Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/parisc/harmony.c | 103 +++++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 67 deletions(-) diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index d833349..0513137 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -59,6 +59,14 @@ #include "harmony.h" +static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +module_param(index, int, 0444); +MODULE_PARM_DESC(index, "Index value for Harmony driver."); +module_param(id, charp, 0444); +MODULE_PARM_DESC(id, "ID string for Harmony driver."); + + static struct parisc_device_id snd_harmony_devtable[] = { /* bushmaster / flounder */ { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0007A }, @@ -299,12 +307,11 @@ static int snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd) { harmony_t *h = snd_pcm_substream_chip(ss); - unsigned long flags; if (h->st.capturing) return -EBUSY; - spin_lock_irqsave(&h->lock, flags); + spin_lock(&h->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: h->st.playing = 1; @@ -323,11 +330,11 @@ snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd) case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_SUSPEND: default: - spin_unlock_irqrestore(&h->lock, flags); + spin_unlock(&h->lock); snd_BUG(); return -EINVAL; } - spin_unlock_irqrestore(&h->lock, flags); + spin_unlock(&h->lock); return 0; } @@ -336,12 +343,11 @@ static int snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd) { harmony_t *h = snd_pcm_substream_chip(ss); - unsigned long flags; if (h->st.playing) return -EBUSY; - spin_lock_irqsave(&h->lock, flags); + spin_lock(&h->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: h->st.capturing = 1; @@ -360,11 +366,11 @@ snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd) case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: case SNDRV_PCM_TRIGGER_SUSPEND: default: - spin_unlock_irqrestore(&h->lock, flags); + spin_unlock(&h->lock); snd_BUG(); return -EINVAL; } - spin_unlock_irqrestore(&h->lock, flags); + spin_unlock(&h->lock); return 0; } @@ -710,9 +716,8 @@ snd_harmony_volume_get(snd_kcontrol_t *kc, int mask = (kc->private_value >> 16) & 0xff; int invert = (kc->private_value >> 24) & 0xff; int left, right; - unsigned long flags; - spin_lock_irqsave(&h->mixer_lock, flags); + spin_lock_irq(&h->mixer_lock); left = (h->st.gain >> shift_left) & mask; right = (h->st.gain >> shift_right) & mask; @@ -725,7 +730,7 @@ snd_harmony_volume_get(snd_kcontrol_t *kc, if (shift_left != shift_right) ucontrol->value.integer.value[1] = right; - spin_unlock_irqrestore(&h->mixer_lock, flags); + spin_unlock_irq(&h->mixer_lock); return 0; } @@ -741,9 +746,8 @@ snd_harmony_volume_put(snd_kcontrol_t *kc, int invert = (kc->private_value >> 24) & 0xff; int left, right; int old_gain = h->st.gain; - unsigned long flags; - spin_lock_irqsave(&h->mixer_lock, flags); + spin_lock_irq(&h->mixer_lock); left = ucontrol->value.integer.value[0] & mask; if (invert) @@ -761,7 +765,7 @@ snd_harmony_volume_put(snd_kcontrol_t *kc, snd_harmony_set_new_gain(h); - spin_unlock_irqrestore(&h->mixer_lock, flags); + spin_unlock_irq(&h->mixer_lock); return h->st.gain != old_gain; } @@ -787,14 +791,13 @@ snd_harmony_captureroute_get(snd_kcontrol_t *kc, { harmony_t *h = snd_kcontrol_chip(kc); int value; - unsigned long flags; - spin_lock_irqsave(&h->mixer_lock, flags); + spin_lock_irq(&h->mixer_lock); value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1; ucontrol->value.enumerated.item[0] = value; - spin_unlock_irqrestore(&h->mixer_lock, flags); + spin_unlock_irq(&h->mixer_lock); return 0; } @@ -806,9 +809,8 @@ snd_harmony_captureroute_put(snd_kcontrol_t *kc, harmony_t *h = snd_kcontrol_chip(kc); int value; int old_gain = h->st.gain; - unsigned long flags; - spin_lock_irqsave(&h->mixer_lock, flags); + spin_lock_irq(&h->mixer_lock); value = ucontrol->value.enumerated.item[0] & 1; h->st.gain &= ~HARMONY_GAIN_IS_MASK; @@ -816,7 +818,7 @@ snd_harmony_captureroute_put(snd_kcontrol_t *kc, snd_harmony_set_new_gain(h); - spin_unlock_irqrestore(&h->mixer_lock, flags); + spin_unlock_irq(&h->mixer_lock); return h->st.gain != old_gain; } @@ -923,19 +925,14 @@ snd_harmony_create(snd_card_t *card, *rchip = NULL; - h = kmalloc(sizeof(*h), GFP_KERNEL); + h = kzalloc(sizeof(*h), GFP_KERNEL); if (h == NULL) return -ENOMEM; - memset(&h->st, 0, sizeof(h->st)); - memset(&h->stats, 0, sizeof(h->stats)); - memset(&h->pbuf, 0, sizeof(h->pbuf)); - memset(&h->cbuf, 0, sizeof(h->cbuf)); - h->hpa = padev->hpa.start; h->card = card; h->dev = padev; - h->irq = padev->irq; + h->irq = -1; h->iobase = ioremap_nocache(padev->hpa.start, HARMONY_SIZE); if (h->iobase == NULL) { printk(KERN_ERR PFX "unable to remap hpa 0x%lx\n", @@ -944,13 +941,14 @@ snd_harmony_create(snd_card_t *card, goto free_and_ret; } - err = request_irq(h->irq, snd_harmony_interrupt, 0, + err = request_irq(padev->irq, snd_harmony_interrupt, 0, "harmony", h); if (err) { printk(KERN_ERR PFX "could not obtain interrupt %d", - h->irq); + padev->irq); goto free_and_ret; } + h->irq = padev->irq; spin_lock_init(&h->mixer_lock); spin_lock_init(&h->lock); @@ -975,35 +973,24 @@ static int __devinit snd_harmony_probe(struct parisc_device *padev) { int err; - static int dev; snd_card_t *card; harmony_t *h; - static int index = SNDRV_DEFAULT_IDX1; - static char *id = SNDRV_DEFAULT_STR1; - - h = parisc_get_drvdata(padev); - if (h != NULL) { - return -ENODEV; - } card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; err = snd_harmony_create(card, padev, &h); - if (err < 0) { + if (err < 0) goto free_and_ret; - } err = snd_harmony_pcm_init(h); - if (err < 0) { + if (err < 0) goto free_and_ret; - } err = snd_harmony_mixer_init(h); - if (err < 0) { + if (err < 0) goto free_and_ret; - } strcpy(card->driver, "harmony"); strcpy(card->shortname, "Harmony"); @@ -1011,13 +998,10 @@ snd_harmony_probe(struct parisc_device *padev) card->shortname, h->hpa, h->irq); err = snd_card_register(card); - if (err < 0) { + if (err < 0) goto free_and_ret; - } - - dev++; - parisc_set_drvdata(padev, h); + parisc_set_drvdata(padev, card); return 0; free_and_ret: @@ -1028,8 +1012,8 @@ free_and_ret: static int __devexit snd_harmony_remove(struct parisc_device *padev) { - harmony_t *h = parisc_get_drvdata(padev); - snd_card_free(h->card); + snd_card_free(parisc_get_drvdata(padev)); + parisc_set_drvdata(padev, NULL); return 0; } @@ -1043,28 +1027,13 @@ static struct parisc_driver snd_harmony_driver = { static int __init alsa_harmony_init(void) { - int err; - - err = register_parisc_driver(&snd_harmony_driver); - if (err < 0) { - printk(KERN_ERR PFX "device not found\n"); - return err; - } - - return 0; + return register_parisc_driver(&snd_harmony_driver); } static void __exit alsa_harmony_fini(void) { - int err; - - err = unregister_parisc_driver(&snd_harmony_driver); - if (err < 0) { - printk(KERN_ERR PFX "failed to unregister\n"); - } - - return; + return unregister_parisc_driver(&snd_harmony_driver); } MODULE_LICENSE("GPL"); -- cgit v1.1 From bfdcbace6c76cab54f1651349816dc35cc8f12b8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:35:53 +0100 Subject: [ALSA] Remove superfluous macros Modules: ATIIXP driver,ATIIXP-modem driver Remove superfluous macros for delay. Call appropriate functions directly. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/atiixp.c | 12 +++--------- sound/pci/atiixp_modem.c | 12 +++--------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 8bae10d..36395d0 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -328,12 +328,6 @@ static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg, #define atiixp_update(chip,reg,mask,val) \ snd_atiixp_update_bits(chip, ATI_REG_##reg, mask, val) -/* delay for one tick */ -#define do_delay() do { \ - schedule_timeout_uninterruptible(1); \ -} while (0) - - /* * handling DMA packets * @@ -513,7 +507,7 @@ static int snd_atiixp_aclink_reset(atiixp_t *chip) atiixp_update(chip, CMD, ATI_REG_CMD_AC_SYNC|ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_SYNC); atiixp_read(chip, CMD); - do_delay(); + msleep(1); atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET); if (--timeout) { snd_printk(KERN_ERR "atiixp: codec reset timeout\n"); @@ -561,9 +555,9 @@ static int snd_atiixp_codec_detect(atiixp_t *chip) chip->codec_not_ready_bits = 0; atiixp_write(chip, IER, CODEC_CHECK_BITS); /* wait for the interrupts */ - timeout = HZ / 10; + timeout = 50; while (timeout-- > 0) { - do_delay(); + msleep(1); if (chip->codec_not_ready_bits) break; } diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 3174b66..649a999 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -305,12 +305,6 @@ static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg, #define atiixp_update(chip,reg,mask,val) \ snd_atiixp_update_bits(chip, ATI_REG_##reg, mask, val) -/* delay for one tick */ -#define do_delay() do { \ - schedule_timeout_uninterruptible(1); \ -} while (0) - - /* * handling DMA packets * @@ -495,7 +489,7 @@ static int snd_atiixp_aclink_reset(atiixp_t *chip) atiixp_update(chip, CMD, ATI_REG_CMD_AC_SYNC|ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_SYNC); atiixp_read(chip, CMD); - do_delay(); + msleep(1); atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET); if (--timeout) { snd_printk(KERN_ERR "atiixp-modem: codec reset timeout\n"); @@ -543,9 +537,9 @@ static int snd_atiixp_codec_detect(atiixp_t *chip) chip->codec_not_ready_bits = 0; atiixp_write(chip, IER, CODEC_CHECK_BITS); /* wait for the interrupts */ - timeout = HZ / 10; + timeout = 50; while (timeout-- > 0) { - do_delay(); + msleep(1); if (chip->codec_not_ready_bits) break; } -- cgit v1.1 From c9a49bb1957f45e0146c17a865f1444fd06c0f97 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:36:57 +0100 Subject: [ALSA] cs4281 - Clean up delay function Modules: CS4281 driver Remove the own delay function. Call appropriate functions directly. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/cs4281.c | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index a4b4608..c99bb1f 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -514,27 +514,6 @@ MODULE_DEVICE_TABLE(pci, snd_cs4281_ids); * common I/O routines */ -static void snd_cs4281_delay(unsigned int delay) -{ - if (delay > 999) { - unsigned long end_time; - delay = (delay * HZ) / 1000000; - if (delay < 1) - delay = 1; - end_time = jiffies + delay; - do { - schedule_timeout_uninterruptible(1); - } while (time_after_eq(end_time, jiffies)); - } else { - udelay(delay); - } -} - -static inline void snd_cs4281_delay_long(void) -{ - schedule_timeout_uninterruptible(1); -} - static inline void snd_cs4281_pokeBA0(cs4281_t *chip, unsigned long offset, unsigned int val) { writel(val, chip->ba0 + offset); @@ -1493,7 +1472,7 @@ static int snd_cs4281_chip_init(cs4281_t *chip) snd_cs4281_pokeBA0(chip, BA0_SPMC, 0); udelay(50); snd_cs4281_pokeBA0(chip, BA0_SPMC, BA0_SPMC_RSTN); - snd_cs4281_delay(50000); + msleep(50); if (chip->dual_codec) snd_cs4281_pokeBA0(chip, BA0_SPMC, BA0_SPMC_RSTN | BA0_SPMC_ASDI2E); @@ -1509,13 +1488,13 @@ static int snd_cs4281_chip_init(cs4281_t *chip) * Start the DLL Clock logic. */ snd_cs4281_pokeBA0(chip, BA0_CLKCR1, BA0_CLKCR1_DLLP); - snd_cs4281_delay(50000); + msleep(50); snd_cs4281_pokeBA0(chip, BA0_CLKCR1, BA0_CLKCR1_SWCE | BA0_CLKCR1_DLLP); /* * Wait for the DLL ready signal from the clock logic. */ - timeout = HZ; + timeout = 100; do { /* * Read the AC97 status register to see if we've seen a CODEC @@ -1523,7 +1502,7 @@ static int snd_cs4281_chip_init(cs4281_t *chip) */ if (snd_cs4281_peekBA0(chip, BA0_CLKCR1) & BA0_CLKCR1_DLLRDY) goto __ok0; - snd_cs4281_delay_long(); + msleep(1); } while (timeout-- > 0); snd_printk(KERN_ERR "DLLRDY not seen\n"); @@ -1541,7 +1520,7 @@ static int snd_cs4281_chip_init(cs4281_t *chip) /* * Wait for the codec ready signal from the AC97 codec. */ - timeout = HZ; + timeout = 100; do { /* * Read the AC97 status register to see if we've seen a CODEC @@ -1549,7 +1528,7 @@ static int snd_cs4281_chip_init(cs4281_t *chip) */ if (snd_cs4281_peekBA0(chip, BA0_ACSTS) & BA0_ACSTS_CRDY) goto __ok1; - snd_cs4281_delay_long(); + msleep(1); } while (timeout-- > 0); snd_printk(KERN_ERR "never read codec ready from AC'97 (0x%x)\n", snd_cs4281_peekBA0(chip, BA0_ACSTS)); @@ -1557,11 +1536,11 @@ static int snd_cs4281_chip_init(cs4281_t *chip) __ok1: if (chip->dual_codec) { - timeout = HZ; + timeout = 100; do { if (snd_cs4281_peekBA0(chip, BA0_ACSTS2) & BA0_ACSTS_CRDY) goto __codec2_ok; - snd_cs4281_delay_long(); + msleep(1); } while (timeout-- > 0); snd_printk(KERN_INFO "secondary codec doesn't respond. disable it...\n"); chip->dual_codec = 0; @@ -1580,7 +1559,7 @@ static int snd_cs4281_chip_init(cs4281_t *chip) * the codec is pumping ADC data across the AC-link. */ - timeout = HZ; + timeout = 100; do { /* * Read the input slot valid register and see if input slots 3 @@ -1588,7 +1567,7 @@ static int snd_cs4281_chip_init(cs4281_t *chip) */ if ((snd_cs4281_peekBA0(chip, BA0_ACISV) & (BA0_ACISV_SLV(3) | BA0_ACISV_SLV(4))) == (BA0_ACISV_SLV(3) | BA0_ACISV_SLV(4))) goto __ok2; - snd_cs4281_delay_long(); + msleep(1); } while (timeout-- > 0); if (--retry_count > 0) -- cgit v1.1 From 954bea35571461b083390a82b03f077f901fe678 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:37:40 +0100 Subject: [ALSA] intel8x0 - Clean up delay function Modules: Intel8x0 driver,Intel8x0-modem driver Remove superfluous delay macro. Call appropriate functions directly. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/intel8x0.c | 16 ++++++---------- sound/pci/intel8x0m.c | 12 ++++-------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index cf7801d..af2b143 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2149,10 +2149,6 @@ static void do_ali_reset(intel8x0_t *chip) iputdword(chip, ICHREG(ALI_INTERRUPTSR), 0x00000000); } -#define do_delay(chip) do {\ - schedule_timeout_uninterruptible(1);\ -} while (0) - static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) { unsigned long end_time; @@ -2176,7 +2172,7 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) do { if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0) goto __ok; - do_delay(chip); + schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", igetdword(chip, ICHREG(GLOB_CNT))); return -EIO; @@ -2192,7 +2188,7 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) status = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR); if (status) break; - do_delay(chip); + schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); if (! status) { /* no codec is found */ @@ -2210,7 +2206,7 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) /* wait for other codecs ready status. */ end_time = jiffies + HZ / 4; while (status != nstatus && time_after_eq(end_time, jiffies)) { - do_delay(chip); + schedule_timeout_uninterruptible(1); status |= igetdword(chip, ICHREG(GLOB_STA)) & nstatus; } @@ -2227,7 +2223,7 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) nstatus = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR); if (status == nstatus) break; - do_delay(chip); + schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); } @@ -2261,7 +2257,7 @@ static int snd_intel8x0_ali_chip_init(intel8x0_t *chip, int probing) for (i = 0; i < HZ / 2; i++) { if (! (igetdword(chip, ICHREG(ALI_INTERRUPTSR)) & ALI_INT_GPIO)) goto __ok; - do_delay(chip); + schedule_timeout_uninterruptible(1); } snd_printk(KERN_ERR "AC'97 reset failed.\n"); if (probing) @@ -2273,7 +2269,7 @@ static int snd_intel8x0_ali_chip_init(intel8x0_t *chip, int probing) if (reg & 0x80) /* primary codec */ break; iputdword(chip, ICHREG(ALI_RTSR), reg | 0x80); - do_delay(chip); + schedule_timeout_uninterruptible(1); } do_ali_reset(chip); diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index a420918..3244df9 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -889,10 +889,6 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock) * */ -#define do_delay(chip) do {\ - schedule_timeout_uninterruptible(1);\ -} while (0) - static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) { unsigned long end_time; @@ -914,7 +910,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) do { if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0) goto __ok; - do_delay(chip); + schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", igetdword(chip, ICHREG(GLOB_CNT))); return -EIO; @@ -930,7 +926,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) status = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR); if (status) break; - do_delay(chip); + schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); if (! status) { /* no codec is found */ @@ -944,7 +940,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) /* wait for other codecs ready status. */ end_time = jiffies + HZ / 4; while (status != nstatus && time_after_eq(end_time, jiffies)) { - do_delay(chip); + schedule_timeout_uninterruptible(1); status |= igetdword(chip, ICHREG(GLOB_STA)) & nstatus; } @@ -959,7 +955,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) nstatus = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR); if (status == nstatus) break; - do_delay(chip); + schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); } -- cgit v1.1 From 95a98265eb7b112b3268761053d643635171e219 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:40:18 +0100 Subject: [ALSA] ca0106 - Code clean up Modules: CA0106 driver Clean up snd-ca0106 driver code: - Fix spaces and indents - Remove unnecessary spinlocks - Clean up the mixer callbacks using private_value - Clean up mixer constructors using an array Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ca0106/ca0106_main.c | 74 +++---- sound/pci/ca0106/ca0106_mixer.c | 417 ++++++++++------------------------------ 2 files changed, 131 insertions(+), 360 deletions(-) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index a89eed2..0120c46 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -207,7 +207,8 @@ static snd_pcm_hardware_t snd_ca0106_playback_hw = { SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, - .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, + .rates = (SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | + SNDRV_PCM_RATE_192000), .rate_min = 48000, .rate_max = 192000, .channels_min = 2, //1, @@ -226,7 +227,8 @@ static snd_pcm_hardware_t snd_ca0106_capture_hw = { SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, - .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, + .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000), .rate_min = 44100, .rate_max = 192000, .channels_min = 2, @@ -276,11 +278,10 @@ int snd_ca0106_i2c_write(ca0106_t *emu, u32 value) { u32 tmp; - int timeout=0; + int timeout = 0; int status; int retry; - if ((reg > 0x7f) || (value > 0x1ff)) - { + if ((reg > 0x7f) || (value > 0x1ff)) { snd_printk(KERN_ERR "i2c_write: invalid values.\n"); return -EINVAL; } @@ -292,8 +293,7 @@ int snd_ca0106_i2c_write(ca0106_t *emu, /* This controls the I2C connected to the WM8775 ADC Codec */ snd_ca0106_ptr_write(emu, I2C_D1, 0, tmp); - for(retry=0;retry<10;retry++) - { + for (retry = 0; retry < 10; retry++) { /* Send the data to i2c */ tmp = snd_ca0106_ptr_read(emu, I2C_A, 0); tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); @@ -301,24 +301,22 @@ int snd_ca0106_i2c_write(ca0106_t *emu, snd_ca0106_ptr_write(emu, I2C_A, 0, tmp); /* Wait till the transaction ends */ - while(1) - { + while (1) { status = snd_ca0106_ptr_read(emu, I2C_A, 0); //snd_printk("I2C:status=0x%x\n", status); timeout++; - if((status & I2C_A_ADC_START)==0) + if ((status & I2C_A_ADC_START) == 0) break; - if(timeout>1000) + if (timeout > 1000) break; } //Read back and see if the transaction is successful - if((status & I2C_A_ADC_ABORT)==0) + if ((status & I2C_A_ADC_ABORT) == 0) break; } - if(retry==10) - { + if (retry == 10) { snd_printk(KERN_ERR "Writing to ADC failed!\n"); return -EINVAL; } @@ -380,10 +378,10 @@ static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, channel->emu = chip; channel->number = channel_id; - channel->use=1; + channel->use = 1; //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); //channel->interrupt = snd_ca0106_pcm_channel_interrupt; - channel->epcm=epcm; + channel->epcm = epcm; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) @@ -448,10 +446,10 @@ static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, i channel->emu = chip; channel->number = channel_id; - channel->use=1; + channel->use = 1; //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); //channel->interrupt = snd_ca0106_pcm_channel_interrupt; - channel->epcm=epcm; + channel->epcm = epcm; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; //snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hw_constraints_capture_period_sizes); @@ -593,8 +591,8 @@ static int snd_ca0106_pcm_prepare_playback(snd_pcm_substream_t *substream) /* FIXME: Check emu->buffer.size before actually writing to it. */ for(i=0; i < runtime->periods; i++) { - table_base[i*2]=runtime->dma_addr+(i*period_size_bytes); - table_base[(i*2)+1]=period_size_bytes<<16; + table_base[i*2] = runtime->dma_addr + (i * period_size_bytes); + table_base[i*2+1] = period_size_bytes << 16; } snd_ca0106_ptr_write(emu, PLAYBACK_LIST_ADDR, channel, emu->buffer.addr+(8*16*channel)); @@ -1008,13 +1006,8 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, unsigned int stat76; ca0106_channel_t *pchannel; - spin_lock(&chip->emu_lock); - status = inl(chip->port + IPR); - // call updater, unlock before it - spin_unlock(&chip->emu_lock); - if (! status) return IRQ_NONE; @@ -1024,11 +1017,11 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, mask = 0x11; /* 0x1 for one half, 0x10 for the other half period. */ for(i = 0; i < 4; i++) { pchannel = &(chip->playback_channels[i]); - if(stat76 & mask) { + if (stat76 & mask) { /* FIXME: Select the correct substream for period elapsed */ if(pchannel->use) { - snd_pcm_period_elapsed(pchannel->epcm->substream); - //printk(KERN_INFO "interrupt [%d] used\n", i); + snd_pcm_period_elapsed(pchannel->epcm->substream); + //printk(KERN_INFO "interrupt [%d] used\n", i); } } //printk(KERN_INFO "channel=%p\n",pchannel); @@ -1038,11 +1031,11 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, mask = 0x110000; /* 0x1 for one half, 0x10 for the other half period. */ for(i = 0; i < 4; i++) { pchannel = &(chip->capture_channels[i]); - if(stat76 & mask) { + if (stat76 & mask) { /* FIXME: Select the correct substream for period elapsed */ if(pchannel->use) { - snd_pcm_period_elapsed(pchannel->epcm->substream); - //printk(KERN_INFO "interrupt [%d] used\n", i); + snd_pcm_period_elapsed(pchannel->epcm->substream); + //printk(KERN_INFO "interrupt [%d] used\n", i); } } //printk(KERN_INFO "channel=%p\n",pchannel); @@ -1051,10 +1044,9 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, } snd_ca0106_ptr_write(chip, EXTENDED_INT, 0, stat76); - spin_lock(&chip->emu_lock); if (chip->midi.dev_id && - (status & (chip->midi.ipr_tx|chip->midi.ipr_rx))) { + (status & (chip->midi.ipr_tx|chip->midi.ipr_rx))) { if (chip->midi.interrupt) chip->midi.interrupt(&chip->midi, status); else @@ -1064,8 +1056,6 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, // acknowledge the interrupt if necessary outl(status, chip->port+IPR); - spin_unlock(&chip->emu_lock); - return IRQ_HANDLED; } @@ -1202,8 +1192,9 @@ static int __devinit snd_ca0106_create(snd_card_t *card, strcpy(card->driver, "CA0106"); strcpy(card->shortname, "CA0106"); - for (c=ca0106_chip_details; c->serial; c++) { - if (c->serial == chip->serial) break; + for (c = ca0106_chip_details; c->serial; c++) { + if (c->serial == chip->serial) + break; } chip->details = c; sprintf(card->longname, "%s at 0x%lx irq %i", @@ -1359,7 +1350,7 @@ static int __devinit snd_ca0106_midi(ca0106_t *chip, unsigned int channel) char *name; int err; - if(channel==CA0106_MIDI_CHAN_B) { + if (channel == CA0106_MIDI_CHAN_B) { name = "CA0106 MPU-401 (UART) B"; midi = &chip->midi2; midi->tx_enable = INTE_MIDI_TX_B; @@ -1499,12 +1490,7 @@ static struct pci_driver driver = { // initialization of the module static int __init alsa_card_ca0106_init(void) { - int err; - - if ((err = pci_register_driver(&driver)) > 0) - return err; - - return 0; + return pci_register_driver(&driver); } // clean up the module diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index c10e4a5..0730dc7 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -125,18 +125,11 @@ static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_ca0106_shared_spdif __devinitdata = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Out", - .info = snd_ca0106_shared_spdif_info, - .get = snd_ca0106_shared_spdif_get, - .put = snd_ca0106_shared_spdif_put -}; - static int snd_ca0106_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) { - static char *texts[6] = { "SPDIF out", "i2s mixer out", "SPDIF in", "i2s in", "AC97 in", "SRC out" }; + static char *texts[6] = { + "SPDIF out", "i2s mixer out", "SPDIF in", "i2s in", "AC97 in", "SRC out" + }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -176,15 +169,6 @@ static int snd_ca0106_capture_source_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Capture Source", - .info = snd_ca0106_capture_source_info, - .get = snd_ca0106_capture_source_get, - .put = snd_ca0106_capture_source_put -}; - static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) { static char *texts[2] = { "Line in", "Mic in" }; @@ -294,26 +278,6 @@ static int snd_ca0106_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_ca0106_spdif_mask_control = -{ - .access = SNDRV_CTL_ELEM_ACCESS_READ, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), - .count = 4, - .info = snd_ca0106_spdif_info, - .get = snd_ca0106_spdif_get_mask -}; - -static snd_kcontrol_new_t snd_ca0106_spdif_control = -{ - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), - .count = 4, - .info = snd_ca0106_spdif_info, - .get = snd_ca0106_spdif_get, - .put = snd_ca0106_spdif_put -}; - static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -324,10 +288,14 @@ static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t } static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol, int reg, int channel_id) + snd_ctl_elem_value_t * ucontrol) { ca0106_t *emu = snd_kcontrol_chip(kcontrol); unsigned int value; + int channel_id, reg; + + channel_id = (kcontrol->private_value >> 8) & 0xff; + reg = kcontrol->private_value & 0xff; value = snd_ca0106_ptr_read(emu, reg, channel_id); ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ @@ -335,226 +303,92 @@ static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ca0106_volume_get_spdif_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_FRONT_CHANNEL; - int reg = PLAYBACK_VOLUME1; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} - -static int snd_ca0106_volume_get_spdif_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_CENTER_LFE_CHANNEL; - int reg = PLAYBACK_VOLUME1; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_get_spdif_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_UNKNOWN_CHANNEL; - int reg = PLAYBACK_VOLUME1; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_get_spdif_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_REAR_CHANNEL; - int reg = PLAYBACK_VOLUME1; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_get_analog_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_FRONT_CHANNEL; - int reg = PLAYBACK_VOLUME2; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} - -static int snd_ca0106_volume_get_analog_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_CENTER_LFE_CHANNEL; - int reg = PLAYBACK_VOLUME2; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_get_analog_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_UNKNOWN_CHANNEL; - int reg = PLAYBACK_VOLUME2; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_get_analog_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_REAR_CHANNEL; - int reg = PLAYBACK_VOLUME2; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} - -static int snd_ca0106_volume_get_feedback(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = 1; - int reg = CAPTURE_CONTROL; - return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); -} - static int snd_ca0106_volume_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol, int reg, int channel_id) + snd_ctl_elem_value_t * ucontrol) { ca0106_t *emu = snd_kcontrol_chip(kcontrol); - unsigned int value; - //value = snd_ca0106_ptr_read(emu, reg, channel_id); - //value = value & 0xffff; - value = ((0xff - ucontrol->value.integer.value[0]) << 24) | ((0xff - ucontrol->value.integer.value[1]) << 16); - value = value | ((0xff - ucontrol->value.integer.value[0]) << 8) | ((0xff - ucontrol->value.integer.value[1]) ); - snd_ca0106_ptr_write(emu, reg, channel_id, value); - return 1; -} -static int snd_ca0106_volume_put_spdif_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_FRONT_CHANNEL; - int reg = PLAYBACK_VOLUME1; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_put_spdif_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_CENTER_LFE_CHANNEL; - int reg = PLAYBACK_VOLUME1; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_put_spdif_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_UNKNOWN_CHANNEL; - int reg = PLAYBACK_VOLUME1; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_put_spdif_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_REAR_CHANNEL; - int reg = PLAYBACK_VOLUME1; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_put_analog_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_FRONT_CHANNEL; - int reg = PLAYBACK_VOLUME2; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_put_analog_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_CENTER_LFE_CHANNEL; - int reg = PLAYBACK_VOLUME2; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_put_analog_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_UNKNOWN_CHANNEL; - int reg = PLAYBACK_VOLUME2; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} -static int snd_ca0106_volume_put_analog_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = CONTROL_REAR_CHANNEL; - int reg = PLAYBACK_VOLUME2; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} - -static int snd_ca0106_volume_put_feedback(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) -{ - int channel_id = 1; - int reg = CAPTURE_CONTROL; - return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); -} - -static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Front Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_analog_front, - .put = snd_ca0106_volume_put_analog_front -}; -static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Center/LFE Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_analog_center_lfe, - .put = snd_ca0106_volume_put_analog_center_lfe -}; -static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Side Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_analog_unknown, - .put = snd_ca0106_volume_put_analog_unknown -}; -static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Analog Rear Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_analog_rear, - .put = snd_ca0106_volume_put_analog_rear -}; -static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Front Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_spdif_front, - .put = snd_ca0106_volume_put_spdif_front -}; -static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Center/LFE Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_spdif_center_lfe, - .put = snd_ca0106_volume_put_spdif_center_lfe -}; -static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Unknown Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_spdif_unknown, - .put = snd_ca0106_volume_put_spdif_unknown -}; -static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Rear Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_spdif_rear, - .put = snd_ca0106_volume_put_spdif_rear -}; - -static snd_kcontrol_new_t snd_ca0106_volume_control_feedback = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "CAPTURE feedback Playback Volume", - .info = snd_ca0106_volume_info, - .get = snd_ca0106_volume_get_feedback, - .put = snd_ca0106_volume_put_feedback + unsigned int oval, nval; + int channel_id, reg; + + channel_id = (kcontrol->private_value >> 8) & 0xff; + reg = kcontrol->private_value & 0xff; + + oval = snd_ca0106_ptr_read(emu, reg, channel_id); + nval = ((0xff - ucontrol->value.integer.value[0]) << 24) | + ((0xff - ucontrol->value.integer.value[1]) << 16); + nval |= ((0xff - ucontrol->value.integer.value[0]) << 8) | + ((0xff - ucontrol->value.integer.value[1]) ); + if (oval == nval) + return 0; + snd_ca0106_ptr_write(emu, reg, channel_id, nval); + return 1; +} + +#define CA_VOLUME(xname,chid,reg) \ +{ \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_ca0106_volume_info, \ + .get = snd_ca0106_volume_get, \ + .put = snd_ca0106_volume_put, \ + .private_value = ((chid) << 8) | (reg) \ +} + + +static snd_kcontrol_new_t snd_ca0106_volume_ctls[] __devinitdata = { + CA_VOLUME("Analog Front Playback Volume", + CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2), + CA_VOLUME("Analog Rear Playback Volume", + CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME2), + CA_VOLUME("Analog Center/LFE Playback Volume", + CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME2), + CA_VOLUME("Analog Side Playback Volume", + CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME2), + + CA_VOLUME("SPDIF Front Playback Volume", + CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME1), + CA_VOLUME("SPDIF Rear Playback Volume", + CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME1), + CA_VOLUME("SPDIF Center/LFE Playback Volume", + CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME1), + CA_VOLUME("SPDIF Unknown Playback Volume", + CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME1), + + CA_VOLUME("CAPTURE feedback Playback Volume", + 1, CAPTURE_CONTROL), + + { + .access = SNDRV_CTL_ELEM_ACCESS_READ, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), + .count = 4, + .info = snd_ca0106_spdif_info, + .get = snd_ca0106_spdif_get_mask + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "SPDIF Out", + .info = snd_ca0106_shared_spdif_info, + .get = snd_ca0106_shared_spdif_get, + .put = snd_ca0106_shared_spdif_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .info = snd_ca0106_capture_source_info, + .get = snd_ca0106_capture_source_get, + .put = snd_ca0106_capture_source_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), + .count = 4, + .info = snd_ca0106_spdif_info, + .get = snd_ca0106_spdif_get, + .put = snd_ca0106_spdif_put + }, }; - -static int remove_ctl(snd_card_t *card, const char *name) +static int __devinit remove_ctl(snd_card_t *card, const char *name) { snd_ctl_elem_id_t id; memset(&id, 0, sizeof(id)); @@ -563,7 +397,7 @@ static int remove_ctl(snd_card_t *card, const char *name) return snd_ctl_remove_id(card, &id); } -static snd_kcontrol_t *ctl_find(snd_card_t *card, const char *name) +static snd_kcontrol_t __devinit *ctl_find(snd_card_t *card, const char *name) { snd_ctl_elem_id_t sid; memset(&sid, 0, sizeof(sid)); @@ -573,7 +407,7 @@ static snd_kcontrol_t *ctl_find(snd_card_t *card, const char *name) return snd_ctl_find_id(card, &sid); } -static int rename_ctl(snd_card_t *card, const char *src, const char *dst) +static int __devinit rename_ctl(snd_card_t *card, const char *src, const char *dst) { snd_kcontrol_t *kctl = ctl_find(card, src); if (kctl) { @@ -585,8 +419,7 @@ static int rename_ctl(snd_card_t *card, const char *src, const char *dst) int __devinit snd_ca0106_mixer(ca0106_t *emu) { - int err; - snd_kcontrol_t *kctl; + int i, err; snd_card_t *card = emu->card; char **c; static char *ca0106_remove_ctls[] = { @@ -627,70 +460,22 @@ int __devinit snd_ca0106_mixer(ca0106_t *emu) NULL }; #if 1 - for (c=ca0106_remove_ctls; *c; c++) + for (c = ca0106_remove_ctls; *c; c++) remove_ctl(card, *c); - for (c=ca0106_rename_ctls; *c; c += 2) + for (c = ca0106_rename_ctls; *c; c += 2) rename_ctl(card, c[0], c[1]); #endif - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_front, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_rear, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_center_lfe, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_unknown, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_front, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_rear, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_center_lfe, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_unknown, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_feedback, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_mask_control, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_shared_spdif, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_ca0106_capture_source, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; + for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_ctls); i++) { + err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_ctls[i], emu)); + if (err < 0) + return err; + } if (emu->details->i2c_adc == 1) { - if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) + err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)); + if (err < 0) return err; } - if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; return 0; } -- cgit v1.1 From b9b4bdd9f1c98388f13591608d574650a9873717 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:42:40 +0100 Subject: [ALSA] ac97 - Remove ac9_enum definition from public header Modules: AC97 Codec Remove the definition of ac97_enum struct from the public ac97_codec.h. It's used only in the module. The location of struct ac97_pcm is moved closer to its accessor to improve readability. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/ac97_codec.h | 65 +++++++++++++++++++++------------------------ sound/pci/ac97/ac97_local.h | 9 +++++++ 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h index 7f0ca79..6f1e6ba 100644 --- a/include/sound/ac97_codec.h +++ b/include/sound/ac97_codec.h @@ -396,33 +396,6 @@ typedef struct _snd_ac97_bus_ops ac97_bus_ops_t; typedef struct _snd_ac97_template ac97_template_t; typedef struct _snd_ac97 ac97_t; -enum ac97_pcm_cfg { - AC97_PCM_CFG_FRONT = 2, - AC97_PCM_CFG_REAR = 10, /* alias surround */ - AC97_PCM_CFG_LFE = 11, /* center + lfe */ - AC97_PCM_CFG_40 = 4, /* front + rear */ - AC97_PCM_CFG_51 = 6, /* front + rear + center/lfe */ - AC97_PCM_CFG_SPDIF = 20 -}; - -/* PCM allocation */ -struct ac97_pcm { - ac97_bus_t *bus; - unsigned int stream: 1, /* stream type: 1 = capture */ - exclusive: 1, /* exclusive mode, don't override with other pcms */ - copy_flag: 1, /* lowlevel driver must fill all entries */ - spdif: 1; /* spdif pcm */ - unsigned short aslots; /* active slots */ - unsigned int rates; /* available rates */ - struct { - unsigned short slots; /* driver input: requested AC97 slot numbers */ - unsigned short rslots[4]; /* allocated slots per codecs */ - unsigned char rate_table[4]; - ac97_t *codec[4]; /* allocated codecs */ - } r[2]; /* 0 = standard rates, 1 = double rates */ - unsigned long private_value; /* used by the hardware driver */ -}; - struct snd_ac97_build_ops { int (*build_3d) (ac97_t *ac97); int (*build_specific) (ac97_t *ac97); @@ -581,6 +554,36 @@ struct ac97_quirk { int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, const char *override); int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned int rate); +/* + * PCM allocation + */ + +enum ac97_pcm_cfg { + AC97_PCM_CFG_FRONT = 2, + AC97_PCM_CFG_REAR = 10, /* alias surround */ + AC97_PCM_CFG_LFE = 11, /* center + lfe */ + AC97_PCM_CFG_40 = 4, /* front + rear */ + AC97_PCM_CFG_51 = 6, /* front + rear + center/lfe */ + AC97_PCM_CFG_SPDIF = 20 +}; + +struct ac97_pcm { + ac97_bus_t *bus; + unsigned int stream: 1, /* stream type: 1 = capture */ + exclusive: 1, /* exclusive mode, don't override with other pcms */ + copy_flag: 1, /* lowlevel driver must fill all entries */ + spdif: 1; /* spdif pcm */ + unsigned short aslots; /* active slots */ + unsigned int rates; /* available rates */ + struct { + unsigned short slots; /* driver input: requested AC97 slot numbers */ + unsigned short rslots[4]; /* allocated slots per codecs */ + unsigned char rate_table[4]; + ac97_t *codec[4]; /* allocated codecs */ + } r[2]; /* 0 = standard rates, 1 = double rates */ + unsigned long private_value; /* used by the hardware driver */ +}; + int snd_ac97_pcm_assign(ac97_bus_t *ac97, unsigned short pcms_count, const struct ac97_pcm *pcms); @@ -589,14 +592,6 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate, int snd_ac97_pcm_close(struct ac97_pcm *pcm); int snd_ac97_pcm_double_rate_rules(snd_pcm_runtime_t *runtime); -struct ac97_enum { - unsigned char reg; - unsigned char shift_l; - unsigned char shift_r; - unsigned short mask; - const char **texts; -}; - /* ad hoc AC97 device driver access */ extern struct bus_type ac97_bus_type; diff --git a/sound/pci/ac97/ac97_local.h b/sound/pci/ac97/ac97_local.h index 536a4d4..5ff3ef2 100644 --- a/sound/pci/ac97/ac97_local.h +++ b/sound/pci/ac97/ac97_local.h @@ -36,6 +36,15 @@ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), .info = snd_ac97_info_volsw, \ .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \ .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) } + +struct ac97_enum { + unsigned char reg; + unsigned char shift_l; + unsigned char shift_r; + unsigned short mask; + const char **texts; +}; + #define AC97_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \ { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ .mask = xmask, .texts = xtexts } -- cgit v1.1 From 89173bd41439bc6304e3e20f742e52266208ccad Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:43:53 +0100 Subject: [ALSA] emu10k1x - Minor clean up Modules: EMU10K1/EMU10K2 driver Minor clean up of the emu10k1x interrupt handler code. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/emu10k1/emu10k1x.c | 65 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index ca402e9..6c61ac60 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -795,44 +795,43 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id, status = inl(chip->port + IPR); - if(status) { - // capture interrupt - if(status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { - emu10k1x_voice_t *pvoice = &chip->capture_voice; - if(pvoice->use) - snd_emu10k1x_pcm_interrupt(chip, pvoice); - else - snd_emu10k1x_intr_disable(chip, - INTE_CAP_0_LOOP | - INTE_CAP_0_HALF_LOOP); - } - - mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; - for(i = 0; i < 3; i++) { - if(status & mask) { - if(pvoice->use) - snd_emu10k1x_pcm_interrupt(chip, pvoice); - else - snd_emu10k1x_intr_disable(chip, mask); - } - pvoice++; - mask <<= 1; - } + if (! status) + return IRQ_NONE; + + // capture interrupt + if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { + emu10k1x_voice_t *pvoice = &chip->capture_voice; + if(pvoice->use) + snd_emu10k1x_pcm_interrupt(chip, pvoice); + else + snd_emu10k1x_intr_disable(chip, + INTE_CAP_0_LOOP | + INTE_CAP_0_HALF_LOOP); + } - if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { - if (chip->midi.interrupt) - chip->midi.interrupt(chip, status); - else - snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); + mask = IPR_CH_0_LOOP|IPR_CH_0_HALF_LOOP; + for (i = 0; i < 3; i++) { + if (status & mask) { + if (pvoice->use) + snd_emu10k1x_pcm_interrupt(chip, pvoice); + else + snd_emu10k1x_intr_disable(chip, mask); } + pvoice++; + mask <<= 1; + } - // acknowledge the interrupt if necessary - if(status) - outl(status, chip->port+IPR); - -// snd_printk(KERN_INFO "interrupt %08x\n", status); + if (status & (IPR_MIDITRANSBUFEMPTY|IPR_MIDIRECVBUFEMPTY)) { + if (chip->midi.interrupt) + chip->midi.interrupt(chip, status); + else + snd_emu10k1x_intr_disable(chip, INTE_MIDITXENABLE|INTE_MIDIRXENABLE); } + + // acknowledge the interrupt if necessary + outl(status, chip->port + IPR); + // snd_printk(KERN_INFO "interrupt %08x\n", status); return IRQ_HANDLED; } -- cgit v1.1 From e017fa5772cd2536b2b2fb210f5a6e86cceaa633 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:44:51 +0100 Subject: [ALSA] emu10k1 - Minor clean up of memory block handling Modules: EMU10K1/EMU10K2 driver Minor clean up of emu10k1 memory block allocation. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/emu10k1/emupcm.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 90d3a0b..166f7c4 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -405,15 +405,17 @@ static int snd_emu10k1_playback_hw_params(snd_pcm_substream_t * substream, if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) return err; if (err > 0) { /* change */ - snd_util_memblk_t *memblk; + int mapped; if (epcm->memblk != NULL) snd_emu10k1_free_pages(emu, epcm->memblk); - memblk = snd_emu10k1_alloc_pages(emu, substream); - if ((epcm->memblk = memblk) == NULL || ((emu10k1_memblk_t *)memblk)->mapped_page < 0) { - epcm->start_addr = 0; + epcm->memblk = snd_emu10k1_alloc_pages(emu, substream); + epcm->start_addr = 0; + if (! epcm->memblk) return -ENOMEM; - } - epcm->start_addr = ((emu10k1_memblk_t *)memblk)->mapped_page << PAGE_SHIFT; + mapped = ((emu10k1_memblk_t *)epcm->memblk)->mapped_page; + if (mapped < 0) + return -ENOMEM; + epcm->start_addr = mapped << PAGE_SHIFT; } return 0; } -- cgit v1.1 From 9fd9156c6b0dfb8630f68d11dc48a3e824aa64e6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:45:48 +0100 Subject: [ALSA] korg1212 - Clean up debug prints Modules: KORG1212 driver Clean up debug prints in korg1212 driver. Also, clean up spaces/indents in some places. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/korg1212/korg1212.c | 574 ++++++++++++++++++------------------------ 1 file changed, 247 insertions(+), 327 deletions(-) diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index a110d66..ec71613 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -41,8 +41,16 @@ // Debug Stuff // ---------------------------------------------------------------------------- #define K1212_DEBUG_LEVEL 0 -#define K1212_DEBUG_PRINTK printk -//#define K1212_DEBUG_PRINTK(x...) printk("<0>" x) +#if K1212_DEBUG_LEVEL > 0 +#define K1212_DEBUG_PRINTK(fmt,args...) printk(KERN_DEBUG fmt,##args) +#else +#define K1212_DEBUG_PRINTK(fmt,...) +#endif +#if K1212_DEBUG_LEVEL > 1 +#define K1212_DEBUG_PRINTK_VERBOSE(fmt,args...) printk(KERN_DEBUG fmt,##args) +#else +#define K1212_DEBUG_PRINTK_VERBOSE(fmt,...) +#endif // ---------------------------------------------------------------------------- // Record/Play Buffer Allocation Method. If K1212_LARGEALLOC is defined all @@ -432,54 +440,54 @@ static struct pci_device_id snd_korg1212_ids[] = { { 0, }, }; -static char* stateName[] = { - "Non-existent", - "Uninitialized", - "DSP download in process", - "DSP download complete", - "Ready", - "Open", - "Setup for play", - "Playing", - "Monitor mode on", - "Calibrating", - "Invalid" +static char *stateName[] = { + "Non-existent", + "Uninitialized", + "DSP download in process", + "DSP download complete", + "Ready", + "Open", + "Setup for play", + "Playing", + "Monitor mode on", + "Calibrating", + "Invalid" }; -static char* clockSourceTypeName[] = { "ADAT", "S/PDIF", "local" }; +static char *clockSourceTypeName[] = { "ADAT", "S/PDIF", "local" }; -static char* clockSourceName[] = { - "ADAT at 44.1 kHz", - "ADAT at 48 kHz", - "S/PDIF at 44.1 kHz", - "S/PDIF at 48 kHz", - "local clock at 44.1 kHz", - "local clock at 48 kHz" +static char *clockSourceName[] = { + "ADAT at 44.1 kHz", + "ADAT at 48 kHz", + "S/PDIF at 44.1 kHz", + "S/PDIF at 48 kHz", + "local clock at 44.1 kHz", + "local clock at 48 kHz" }; -static char* channelName[] = { - "ADAT-1", - "ADAT-2", - "ADAT-3", - "ADAT-4", - "ADAT-5", - "ADAT-6", - "ADAT-7", - "ADAT-8", - "Analog-L", - "Analog-R", - "SPDIF-L", - "SPDIF-R", +static char *channelName[] = { + "ADAT-1", + "ADAT-2", + "ADAT-3", + "ADAT-4", + "ADAT-5", + "ADAT-6", + "ADAT-7", + "ADAT-8", + "Analog-L", + "Analog-R", + "SPDIF-L", + "SPDIF-R", }; -static u16 ClockSourceSelector[] = - {0x8000, // selects source as ADAT at 44.1 kHz - 0x0000, // selects source as ADAT at 48 kHz - 0x8001, // selects source as S/PDIF at 44.1 kHz - 0x0001, // selects source as S/PDIF at 48 kHz - 0x8002, // selects source as local clock at 44.1 kHz - 0x0002 // selects source as local clock at 48 kHz - }; +static u16 ClockSourceSelector[] = { + 0x8000, // selects source as ADAT at 44.1 kHz + 0x0000, // selects source as ADAT at 48 kHz + 0x8001, // selects source as S/PDIF at 44.1 kHz + 0x0001, // selects source as S/PDIF at 48 kHz + 0x8002, // selects source as local clock at 44.1 kHz + 0x0002 // selects source as local clock at 48 kHz +}; static snd_korg1212rc rc; @@ -521,23 +529,6 @@ static u32 LowerWordSwap(u32 swappee) return retVal.i; } -#if 0 /* not used */ - -static u32 EndianSwap(u32 swappee) -{ - swap_u32 retVal, swapper; - - swapper.i = swappee; - retVal.c[0] = swapper.c[3]; - retVal.c[1] = swapper.c[2]; - retVal.c[2] = swapper.c[1]; - retVal.c[3] = swapper.c[0]; - - return retVal.i; -} - -#endif /* not used */ - #define SetBitInWord(theWord,bitPosition) (*theWord) |= (0x0001 << bitPosition) #define SetBitInDWord(theWord,bitPosition) (*theWord) |= (0x00000001 << bitPosition) #define ClearBitInWord(theWord,bitPosition) (*theWord) &= ~(0x0001 << bitPosition) @@ -551,15 +542,12 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121 snd_korg1212rc rc = K1212_CMDRET_Success; if (!korg1212->outDoorbellPtr) { -#if K1212_DEBUG_LEVEL > 1 - K1212_DEBUG_PRINTK("K1212_DEBUG: CardUninitialized\n"); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: CardUninitialized\n"); return K1212_CMDRET_CardUninitialized; } -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n", doorbellVal, mailBox0Val, stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- 0x%08x 0x%08x [%s]\n", + doorbellVal, mailBox0Val, stateName[korg1212->cardState]); for (retryCount = 0; retryCount < MAX_COMMAND_RETRIES; retryCount++) { writel(mailBox3Val, korg1212->mailbox3Ptr); writel(mailBox2Val, korg1212->mailbox2Ptr); @@ -586,9 +574,7 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121 mailBox3Lo = readl(korg1212->mailbox3Ptr); if (mailBox3Lo & COMMAND_ACK_MASK) { if ((mailBox3Lo & DOORBELL_VAL_MASK) == (doorbellVal & DOORBELL_VAL_MASK)) { -#if K1212_DEBUG_LEVEL > 1 - K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- Success\n"); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- Success\n"); rc = K1212_CMDRET_Success; break; } @@ -597,9 +583,7 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121 korg1212->cmdRetryCount += retryCount; if (retryCount >= MAX_COMMAND_RETRIES) { -#if K1212_DEBUG_LEVEL > 1 - K1212_DEBUG_PRINTK("K1212_DEBUG: Card <- NoAckFromCard\n"); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Card <- NoAckFromCard\n"); rc = K1212_CMDRET_NoAckFromCard; } @@ -639,9 +623,8 @@ static void snd_korg1212_timer_func(unsigned long data) korg1212->stop_pending_cnt = 0; korg1212->dsp_stop_is_processed = 1; wake_up(&korg1212->wait); -#if K1212_DEBUG_LEVEL > 1 - K1212_DEBUG_PRINTK("K1212_DEBUG: Stop ack'ed [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: Stop ack'ed [%s]\n", + stateName[korg1212->cardState]); } else { if (--korg1212->stop_pending_cnt > 0) { /* reprogram timer */ @@ -652,17 +635,17 @@ static void snd_korg1212_timer_func(unsigned long data) korg1212->sharedBufferPtr->cardCommand = 0; korg1212->dsp_stop_is_processed = 1; wake_up(&korg1212->wait); -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: Stop timeout [%s]\n", + stateName[korg1212->cardState]); } } spin_unlock(&korg1212->lock); } -static void snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) +static int snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) { unsigned long flags; + int rc; udelay(INTERCOMMAND_DELAY); spin_lock_irqsave(&korg1212->lock, flags); @@ -670,6 +653,7 @@ static void snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_MonitorOn, 0, 0, 0); spin_unlock_irqrestore(&korg1212->lock, flags); + return rc; } static void snd_korg1212_TurnOffIdleMonitor(korg1212_t *korg1212) @@ -687,9 +671,8 @@ static inline void snd_korg1212_setCardState(korg1212_t * korg1212, CardState cs static int snd_korg1212_OpenCard(korg1212_t * korg1212) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", + stateName[korg1212->cardState], korg1212->opencnt); down(&korg1212->open_mutex); if (korg1212->opencnt++ == 0) { snd_korg1212_TurnOffIdleMonitor(korg1212); @@ -702,9 +685,8 @@ static int snd_korg1212_OpenCard(korg1212_t * korg1212) static int snd_korg1212_CloseCard(korg1212_t * korg1212) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", + stateName[korg1212->cardState], korg1212->opencnt); down(&korg1212->open_mutex); if (--(korg1212->opencnt)) { @@ -713,12 +695,11 @@ static int snd_korg1212_CloseCard(korg1212_t * korg1212) } if (korg1212->cardState == K1212_STATE_SETUP) { - rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, + int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_StopPlay, 0, 0, 0); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif - + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { up(&korg1212->open_mutex); return 0; @@ -739,9 +720,10 @@ static int snd_korg1212_CloseCard(korg1212_t * korg1212) /* spinlock already held */ static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->setcnt); -#endif + int rc; + + K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->setcnt); if (korg1212->setcnt++) return 0; @@ -749,10 +731,9 @@ static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) snd_korg1212_setCardState(korg1212, K1212_STATE_SETUP); rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_SetupPlay, 0, 0, 0); - -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: SetupForPlay - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { return 1; } @@ -762,20 +743,19 @@ static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) /* spinlock already held */ static int snd_korg1212_TriggerPlay(korg1212_t * korg1212) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->playcnt); -#endif + int rc; + + K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->playcnt); if (korg1212->playcnt++) return 0; snd_korg1212_setCardState(korg1212, K1212_STATE_PLAYING); rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_TriggerPlay, 0, 0, 0, 0); - -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif - + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: TriggerPlay - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); if (rc != K1212_CMDRET_Success) { return 1; } @@ -785,9 +765,8 @@ static int snd_korg1212_TriggerPlay(korg1212_t * korg1212) /* spinlock already held */ static int snd_korg1212_StopPlay(korg1212_t * korg1212) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->playcnt); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n", + stateName[korg1212->cardState], korg1212->playcnt); if (--(korg1212->playcnt)) return 0; @@ -815,35 +794,34 @@ static void snd_korg1212_EnableCardInterrupts(korg1212_t * korg1212) static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector mode) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n", + stateName[korg1212->cardState]); switch (mode) { - case K1212_MONMODE_Off: - if (korg1212->cardState != K1212_STATE_MONITOR) { - return 0; - } else { - snd_korg1212_SendStopAndWait(korg1212); - snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); - } - break; - - case K1212_MONMODE_On: - if (korg1212->cardState != K1212_STATE_OPEN) { - return 0; - } else { - snd_korg1212_setCardState(korg1212, K1212_STATE_MONITOR); - rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, - K1212_MODE_MonitorOn, 0, 0, 0); - if (rc != K1212_CMDRET_Success) { - return 0; - } - } - break; + case K1212_MONMODE_Off: + if (korg1212->cardState != K1212_STATE_MONITOR) + return 0; + else { + snd_korg1212_SendStopAndWait(korg1212); + snd_korg1212_setCardState(korg1212, K1212_STATE_OPEN); + } + break; + + case K1212_MONMODE_On: + if (korg1212->cardState != K1212_STATE_OPEN) + return 0; + else { + int rc; + snd_korg1212_setCardState(korg1212, K1212_STATE_MONITOR); + rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, + K1212_MODE_MonitorOn, 0, 0, 0); + if (rc != K1212_CMDRET_Success) + return 0; + } + break; - default: - return 0; + default: + return 0; } return 1; @@ -853,42 +831,42 @@ static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector static inline int snd_korg1212_use_is_exclusive(korg1212_t *korg1212) { - int ret = 1; + if (korg1212->playback_pid != korg1212->capture_pid && + korg1212->playback_pid >= 0 && korg1212->capture_pid >= 0) + return 0; - if ((korg1212->playback_pid != korg1212->capture_pid) && - (korg1212->playback_pid >= 0) && (korg1212->capture_pid >= 0)) { - ret = 0; - } - return ret; + return 1; } static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) { - static ClockSourceIndex s44[] = { K1212_CLKIDX_AdatAt44_1K, - K1212_CLKIDX_WordAt44_1K, - K1212_CLKIDX_LocalAt44_1K }; + static ClockSourceIndex s44[] = { + K1212_CLKIDX_AdatAt44_1K, + K1212_CLKIDX_WordAt44_1K, + K1212_CLKIDX_LocalAt44_1K + }; static ClockSourceIndex s48[] = { - K1212_CLKIDX_AdatAt48K, - K1212_CLKIDX_WordAt48K, - K1212_CLKIDX_LocalAt48K }; - int parm; + K1212_CLKIDX_AdatAt48K, + K1212_CLKIDX_WordAt48K, + K1212_CLKIDX_LocalAt48K + }; + int parm, rc; - if (!snd_korg1212_use_is_exclusive (korg1212)) { - return -EBUSY; - } + if (!snd_korg1212_use_is_exclusive (korg1212)) + return -EBUSY; switch(rate) { - case 44100: - parm = s44[korg1212->clkSource]; - break; + case 44100: + parm = s44[korg1212->clkSource]; + break; - case 48000: - parm = s48[korg1212->clkSource]; - break; + case 48000: + parm = s48[korg1212->clkSource]; + break; - default: - return -EINVAL; - } + default: + return -EINVAL; + } korg1212->clkSrcRate = parm; korg1212->clkRate = rate; @@ -898,9 +876,9 @@ static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); return 0; } @@ -908,8 +886,8 @@ static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) static int snd_korg1212_SetClockSource(korg1212_t *korg1212, int source) { - if (source<0 || source >2) - return -EINVAL; + if (source < 0 || source > 2) + return -EINVAL; korg1212->clkSource = source; @@ -935,9 +913,8 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) u16 count; unsigned long flags; -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity [%s]\n", + stateName[korg1212->cardState]); // ---------------------------------------------------------------------------- // initialize things. The local init bit is always set when writing to the @@ -1006,19 +983,17 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) udelay(LOADSHIFT_DELAY); for (bitPosition = 15; bitPosition >= 0; bitPosition--) { // for all the bits - if (channel == 0) { - if (sensVals.l.leftSensBits & (0x0001 << bitPosition)) { - SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high - } else { - ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low - } - } else { - if (sensVals.r.rightSensBits & (0x0001 << bitPosition)) { - SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high - } else { - ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low - } - } + if (channel == 0) { + if (sensVals.l.leftSensBits & (0x0001 << bitPosition)) + SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high + else + ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low + } else { + if (sensVals.r.rightSensBits & (0x0001 << bitPosition)) + SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high + else + ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low + } ClearBitInWord(&controlValue, SET_SENS_CLOCK_BITPOS); writew(controlValue, korg1212->sensRegPtr); // clock goes low @@ -1061,10 +1036,9 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) if (monModeSet) { rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_MonitorOn, 0, 0, 0); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif - + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); } spin_unlock_irqrestore(&korg1212->lock, flags); @@ -1076,19 +1050,18 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) { int channel; -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n", + stateName[korg1212->cardState]); // ---------------------------------------------------- // tell the card to boot // ---------------------------------------------------- rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_BootFromDSPPage4, 0, 0, 0, 0); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif - mdelay(DSP_BOOT_DELAY_IN_MS); + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: Boot from Page 4 - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); + msleep(DSP_BOOT_DELAY_IN_MS); // -------------------------------------------------------------------------------- // Let the card know where all the buffers are. @@ -1102,9 +1075,9 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) 0 ); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Buffer Memory - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); udelay(INTERCOMMAND_DELAY); @@ -1116,10 +1089,9 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) 0 ); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif - + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: Configure Misc Memory - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); // -------------------------------------------------------------------------------- // Initialize the routing and volume tables, then update the card's state. @@ -1138,16 +1110,16 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate, ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); - snd_korg1212_TurnOnIdleMonitor(korg1212); + rc = snd_korg1212_TurnOnIdleMonitor(korg1212); snd_korg1212_setCardState(korg1212, K1212_STATE_READY); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: Set Monitor On - RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_COMPLETE); } @@ -1176,9 +1148,9 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs switch (doorbellValue) { case K1212_DB_DSPDownloadDone: -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DNLD count - %ld, %x, [%s].\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); if (korg1212->cardState == K1212_STATE_DSP_IN_PROCESS) { korg1212->dsp_is_loaded = 1; wake_up(&korg1212->wait); @@ -1189,10 +1161,10 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs // an error occurred - stop the card // ------------------------------------------------------------------------ case K1212_DB_DMAERROR: -#if K1212_DEBUG_LEVEL > 1 - K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]); -#endif - snd_printk(KERN_ERR "korg1212: DMA Error\n"); + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DMAE count - %ld, %x, [%s].\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); + snd_printk(KERN_ERR "korg1212: DMA Error\n"); korg1212->errorcnt++; korg1212->totalerrorcnt++; korg1212->sharedBufferPtr->cardCommand = 0; @@ -1204,17 +1176,17 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs // the semaphore in case someone is waiting for this. // ------------------------------------------------------------------------ case K1212_DB_CARDSTOPPED: -#if K1212_DEBUG_LEVEL > 1 - K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK_VEROBSE("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", + korg1212->irqcount, doorbellValue, + stateName[korg1212->cardState]); korg1212->sharedBufferPtr->cardCommand = 0; break; default: -#if K1212_DEBUG_LEVEL > 3 - K1212_DEBUG_PRINTK("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", korg1212->irqcount, doorbellValue, - korg1212->currentBuffer, stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", + korg1212->irqcount, doorbellValue, + korg1212->currentBuffer, + stateName[korg1212->cardState]); if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) { korg1212->currentBuffer++; @@ -1249,16 +1221,14 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n", + stateName[korg1212->cardState]); // --------------------------------------------------------------- // verify the state of the card before proceeding. // --------------------------------------------------------------- - if (korg1212->cardState >= K1212_STATE_DSP_IN_PROCESS) { + if (korg1212->cardState >= K1212_STATE_DSP_IN_PROCESS) return 1; - } snd_korg1212_setCardState(korg1212, K1212_STATE_DSP_IN_PROCESS); @@ -1267,10 +1237,9 @@ static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_StartDSPDownload, UpperWordSwap(korg1212->dma_dsp.addr), 0, 0, 0); - -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: Start DSP Download RC = %d [%s]\n", + rc, stateName[korg1212->cardState]); korg1212->dsp_is_loaded = 0; wait_event_timeout(korg1212->wait, korg1212->dsp_is_loaded, HZ * CARD_BOOT_TIMEOUT); @@ -1327,16 +1296,16 @@ static int snd_korg1212_silence(korg1212_t *korg1212, int pos, int count, int of KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i; -#if K1212_DEBUG_LEVEL > 2 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", pos, offset, size, count); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", + pos, offset, size, count); snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); for (i=0; i < count; i++) { #if K1212_DEBUG_LEVEL > 0 if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", dst, i); + printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_silence KERNEL EFAULT dst=%p iter=%d\n", + dst, i); return -EFAULT; } #endif @@ -1352,24 +1321,21 @@ static int snd_korg1212_copy_to(korg1212_t *korg1212, void __user *dst, int pos, KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos; int i, rc; -#if K1212_DEBUG_LEVEL > 2 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", pos, offset, size); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", + pos, offset, size); snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); for (i=0; i < count; i++) { #if K1212_DEBUG_LEVEL > 0 if ( (void *) src < (void *) korg1212->recordDataBufsPtr || (void *) src > (void *) korg1212->recordDataBufsPtr[8].bufferData ) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); + printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_to KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); return -EFAULT; } #endif rc = copy_to_user(dst + offset, src, size); if (rc) { -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_to USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); -#endif return -EFAULT; } src++; @@ -1384,9 +1350,8 @@ static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int po KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i, rc; -#if K1212_DEBUG_LEVEL > 2 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", pos, offset, size, count); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", + pos, offset, size, count); snd_assert(pos + count <= K1212_MAX_SAMPLES, return -EINVAL); @@ -1394,15 +1359,15 @@ static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int po #if K1212_DEBUG_LEVEL > 0 if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); + printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } #endif rc = copy_from_user((void*) dst + offset, src, size); if (rc) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", + src, dst, i); return -EFAULT; } dst++; @@ -1416,9 +1381,8 @@ static void snd_korg1212_free_pcm(snd_pcm_t *pcm) { korg1212_t *korg1212 = (korg1212_t *) pcm->private_data; -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n", + stateName[korg1212->cardState]); korg1212->pcm = NULL; } @@ -1429,9 +1393,8 @@ static int snd_korg1212_playback_open(snd_pcm_substream_t *substream) korg1212_t *korg1212 = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n", + stateName[korg1212->cardState]); snd_pcm_set_sync(substream); // ??? @@ -1461,9 +1424,8 @@ static int snd_korg1212_capture_open(snd_pcm_substream_t *substream) korg1212_t *korg1212 = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n", + stateName[korg1212->cardState]); snd_pcm_set_sync(substream); @@ -1490,9 +1452,8 @@ static int snd_korg1212_playback_close(snd_pcm_substream_t *substream) unsigned long flags; korg1212_t *korg1212 = snd_pcm_substream_chip(substream); -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", + stateName[korg1212->cardState]); snd_korg1212_silence(korg1212, 0, K1212_MAX_SAMPLES, 0, korg1212->channels * 2); @@ -1513,9 +1474,8 @@ static int snd_korg1212_capture_close(snd_pcm_substream_t *substream) unsigned long flags; korg1212_t *korg1212 = snd_pcm_substream_chip(substream); -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", + stateName[korg1212->cardState]); spin_lock_irqsave(&korg1212->lock, flags); @@ -1532,18 +1492,14 @@ static int snd_korg1212_capture_close(snd_pcm_substream_t *substream) static int snd_korg1212_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd); if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO ) { snd_pcm_channel_info_t *info = arg; info->offset = 0; info->first = info->channel * 16; info->step = 256; -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: channel_info %d:, offset=%ld, first=%d, step=%d\n", info->channel, info->offset, info->first, info->step); -#endif return 0; } @@ -1559,9 +1515,8 @@ static int snd_korg1212_hw_params(snd_pcm_substream_t *substream, pid_t this_pid; pid_t other_pid; -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_hw_params [%s]\n", + stateName[korg1212->cardState]); spin_lock_irqsave(&korg1212->lock, flags); @@ -1608,17 +1563,15 @@ static int snd_korg1212_prepare(snd_pcm_substream_t *substream) korg1212_t *korg1212 = snd_pcm_substream_chip(substream); int rc; -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", + stateName[korg1212->cardState]); spin_lock_irq(&korg1212->lock); /* FIXME: we should wait for ack! */ if (korg1212->stop_pending_cnt > 0) { -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare - Stop is pending... [%s]\n", + stateName[korg1212->cardState]); spin_unlock_irq(&korg1212->lock); return -EAGAIN; /* @@ -1643,18 +1596,15 @@ static int snd_korg1212_trigger(snd_pcm_substream_t *substream, korg1212_t *korg1212 = snd_pcm_substream_chip(substream); int rc; -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n", stateName[korg1212->cardState], cmd); -#endif + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n", + stateName[korg1212->cardState], cmd); spin_lock(&korg1212->lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: /* if (korg1212->running) { -#if K1212_DEBUG_LEVEL > 1 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger: Already running?\n"); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already running?\n"); break; } */ @@ -1665,9 +1615,7 @@ static int snd_korg1212_trigger(snd_pcm_substream_t *substream, case SNDRV_PCM_TRIGGER_STOP: /* if (!korg1212->running) { -#if K1212_DEBUG_LEVEL > 1 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger: Already stopped?\n"); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_trigger: Already stopped?\n"); break; } */ @@ -1690,10 +1638,8 @@ static snd_pcm_uframes_t snd_korg1212_playback_pointer(snd_pcm_substream_t *subs pos = korg1212->currentBuffer * kPlayBufferFrames; -#if K1212_DEBUG_LEVEL > 2 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n", - stateName[korg1212->cardState], pos); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_pointer [%s] %ld\n", + stateName[korg1212->cardState], pos); return pos; } @@ -1705,10 +1651,8 @@ static snd_pcm_uframes_t snd_korg1212_capture_pointer(snd_pcm_substream_t *subst pos = korg1212->currentBuffer * kPlayBufferFrames; -#if K1212_DEBUG_LEVEL > 2 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n", - stateName[korg1212->cardState], pos); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_pointer [%s] %ld\n", + stateName[korg1212->cardState], pos); return pos; } @@ -1721,9 +1665,8 @@ static int snd_korg1212_playback_copy(snd_pcm_substream_t *substream, { korg1212_t *korg1212 = snd_pcm_substream_chip(substream); -#if K1212_DEBUG_LEVEL > 2 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", + stateName[korg1212->cardState], pos, count); return snd_korg1212_copy_from(korg1212, src, pos, count, 0, korg1212->channels * 2); @@ -1736,9 +1679,8 @@ static int snd_korg1212_playback_silence(snd_pcm_substream_t *substream, { korg1212_t *korg1212 = snd_pcm_substream_chip(substream); -#if K1212_DEBUG_LEVEL > 0 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", stateName[korg1212->cardState]); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", + stateName[korg1212->cardState]); return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2); } @@ -1751,9 +1693,8 @@ static int snd_korg1212_capture_copy(snd_pcm_substream_t *substream, { korg1212_t *korg1212 = snd_pcm_substream_chip(substream); -#if K1212_DEBUG_LEVEL > 2 - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count); -#endif + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", + stateName[korg1212->cardState], pos, count); return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2); } @@ -2145,7 +2086,7 @@ snd_korg1212_free(korg1212_t *korg1212) if (korg1212->irq >= 0) { synchronize_irq(korg1212->irq); snd_korg1212_DisableCardInterrupts(korg1212); - free_irq(korg1212->irq, (void *)korg1212); + free_irq(korg1212->irq, korg1212); korg1212->irq = -1; } @@ -2197,9 +2138,7 @@ snd_korg1212_free(korg1212_t *korg1212) static int snd_korg1212_dev_free(snd_device_t *device) { korg1212_t *korg1212 = device->device_data; -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n"); -#endif return snd_korg1212_free(korg1212); } @@ -2207,7 +2146,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212_t ** rchip) { - int err; + int err, rc; unsigned int i; unsigned ioport_size, iomem_size, iomem2_size; korg1212_t * korg1212; @@ -2270,7 +2209,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, ioport_size = pci_resource_len(korg1212->pci, 1); iomem2_size = pci_resource_len(korg1212->pci, 2); -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: resources:\n" " iomem = 0x%lx (%d)\n" " ioport = 0x%lx (%d)\n" @@ -2280,7 +2218,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->ioport, ioport_size, korg1212->iomem2, iomem2_size, stateName[korg1212->cardState]); -#endif if ((korg1212->iobase = ioremap(korg1212->iomem, iomem_size)) == NULL) { snd_printk(KERN_ERR "korg1212: unable to remap memory region 0x%lx-0x%lx\n", korg1212->iomem, @@ -2291,7 +2228,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, err = request_irq(pci->irq, snd_korg1212_interrupt, SA_INTERRUPT|SA_SHIRQ, - "korg1212", (void *) korg1212); + "korg1212", korg1212); if (err) { snd_printk(KERN_ERR "korg1212: unable to grab IRQ %d\n", pci->irq); @@ -2314,7 +2251,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->sensRegPtr = (u16 __iomem *) (korg1212->iobase + SENS_CONTROL_OFFSET); korg1212->idRegPtr = (u32 __iomem *) (korg1212->iobase + DEV_VEND_ID_OFFSET); -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: card registers:\n" " Status register = 0x%p\n" " OutDoorbell = 0x%p\n" @@ -2338,7 +2274,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->sensRegPtr, korg1212->idRegPtr, stateName[korg1212->cardState]); -#endif if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) { @@ -2349,9 +2284,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->sharedBufferPtr = (KorgSharedBuffer *)korg1212->dma_shared.area; korg1212->sharedBufferPhy = korg1212->dma_shared.addr; -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(KorgSharedBuffer)); -#endif #ifndef K1212_LARGEALLOC @@ -2366,10 +2299,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->playDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_play.area; korg1212->PlayDataPhy = korg1212->dma_play.addr; -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n", korg1212->playDataBufsPtr, korg1212->PlayDataPhy, korg1212->DataBufsSize); -#endif if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->DataBufsSize, &korg1212->dma_rec) < 0) { @@ -2380,10 +2311,8 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->recordDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_rec.area; korg1212->RecDataPhy = korg1212->dma_rec.addr; -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n", korg1212->recordDataBufsPtr, korg1212->RecDataPhy, korg1212->DataBufsSize); -#endif #else // K1212_LARGEALLOC @@ -2410,17 +2339,14 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, return -ENOMEM; } -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: DSP Code area = 0x%p (0x%08x) %d bytes [%s]\n", korg1212->dma_dsp.area, korg1212->dma_dsp.addr, korg1212->dspCodeSize, stateName[korg1212->cardState]); -#endif rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_RebootCard, 0, 0, 0, 0); -#if K1212_DEBUG_LEVEL > 0 - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); -#endif + if (rc) + K1212_DEBUG_PRINTK("K1212_DEBUG: Reboot Card - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, korg1212, &ops)) < 0) { snd_korg1212_free(korg1212); @@ -2434,8 +2360,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if (snd_korg1212_downloadDSPCode(korg1212)) return -EBUSY; - snd_printk(KERN_ERR - "korg1212: dspMemPhy = %08x U[%08x], " + K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], " "PlayDataPhy = %08x L[%08x]\n" "korg1212: RecDataPhy = %08x L[%08x], " "VolumeTablePhy = %08x L[%08x]\n" @@ -2461,9 +2386,6 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->pcm->info_flags = SNDRV_PCM_INFO_JOINT_DUPLEX; - //snd_pcm_lib_preallocate_pages_for_all(korg1212->pcm, - // K1212_MAX_BUF_SIZE, K1212_MAX_BUF_SIZE, GFP_KERNEL); - for (i = 0; i < ARRAY_SIZE(snd_korg1212_controls); i++) { err = snd_ctl_add(korg1212->card, snd_ctl_new1(&snd_korg1212_controls[i], korg1212)); if (err < 0) @@ -2513,9 +2435,7 @@ snd_korg1212_probe(struct pci_dev *pci, sprintf(card->longname, "%s at 0x%lx, irq %d", card->shortname, korg1212->iomem, korg1212->irq); -#if K1212_DEBUG_LEVEL > 0 K1212_DEBUG_PRINTK("K1212_DEBUG: %s\n", card->longname); -#endif if ((err = snd_card_register(card)) < 0) { snd_card_free(card); -- cgit v1.1 From cb432379eff40d5656ca9f24afc435b4df353d13 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:48:52 +0100 Subject: [ALSA] usx2y - Code clean up Modules: USB USX2Y Clean up snd-usb-usx2y driver code: - Avoid unnecessary cast - Fix spaces/indents - Use kzalloc() - Remove weird debug prints Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/usb/usx2y/usX2Yhwdep.c | 13 +-- sound/usb/usx2y/usbusx2y.c | 13 ++- sound/usb/usx2y/usbusx2yaudio.c | 184 +++++++++++++++++++--------------------- sound/usb/usx2y/usx2yhwdeppcm.c | 31 +++---- 4 files changed, 112 insertions(+), 129 deletions(-) diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index 8abe086..fc0d534 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -67,15 +67,15 @@ static struct vm_operations_struct us428ctls_vm_ops = { static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) { unsigned long size = (unsigned long)(area->vm_end - area->vm_start); - usX2Ydev_t *us428 = (usX2Ydev_t*)hw->private_data; + usX2Ydev_t *us428 = hw->private_data; // FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs? // so as long as the device isn't fully initialised yet we return -EBUSY here. - if (!(((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT)) + if (!(us428->chip_status & USX2Y_STAT_CHIP_INIT)) return -EBUSY; /* if userspace tries to mmap beyond end of our buffer, fail */ - if (size > ((PAGE_SIZE - 1 + sizeof(us428ctls_sharedmem_t)) / PAGE_SIZE) * PAGE_SIZE) { + if (size > PAGE_ALIGN(sizeof(us428ctls_sharedmem_t))) { snd_printd( "%lu > %lu\n", size, (unsigned long)sizeof(us428ctls_sharedmem_t)); return -EINVAL; } @@ -96,7 +96,7 @@ static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_are static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_table *wait) { unsigned int mask = 0; - usX2Ydev_t *us428 = (usX2Ydev_t*)hw->private_data; + usX2Ydev_t *us428 = hw->private_data; us428ctls_sharedmem_t *shm = us428->us428ctls_sharedmem; if (us428->chip_status & USX2Y_STAT_CHIP_HUP) return POLLHUP; @@ -127,9 +127,10 @@ static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *i [USX2Y_TYPE_224] = "us224", [USX2Y_TYPE_428] = "us428", }; + usX2Ydev_t *us428 = hw->private_data; int id = -1; - switch (le16_to_cpu(((usX2Ydev_t*)hw->private_data)->chip.dev->descriptor.idProduct)) { + switch (le16_to_cpu(us428->chip.dev->descriptor.idProduct)) { case USB_ID_US122: id = USX2Y_TYPE_122; break; @@ -144,7 +145,7 @@ static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *i return -ENODEV; strcpy(info->id, type_ids[id]); info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code - if (((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT) + if (us428->chip_status & USX2Y_STAT_CHIP_INIT) info->chip_ready = 1; info->version = USX2Y_DRIVER_VERSION; return 0; diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index cf77313..412c2e5 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -285,7 +285,6 @@ int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y) int usX2Y_In04_init(usX2Ydev_t* usX2Y) { - int err = 0; if (! (usX2Y->In04urb = usb_alloc_urb(0, GFP_KERNEL))) return -ENOMEM; @@ -299,8 +298,7 @@ int usX2Y_In04_init(usX2Ydev_t* usX2Y) usX2Y->In04Buf, 21, i_usX2Y_In04Int, usX2Y, 10); - err = usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); - return err; + return usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); } static void usX2Y_unlinkSeq(snd_usX2Y_AsyncSeq_t* S) @@ -432,20 +430,21 @@ static void snd_usX2Y_card_private_free(snd_card_t *card) static void usX2Y_usb_disconnect(struct usb_device* device, void* ptr) { if (ptr) { - usX2Ydev_t* usX2Y = usX2Y((snd_card_t*)ptr); - struct list_head* p; + snd_card_t *card = ptr; + usX2Ydev_t* usX2Y = usX2Y(card); + struct list_head *p; usX2Y->chip.shutdown = 1; usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; usX2Y_unlinkSeq(&usX2Y->AS04); usb_kill_urb(usX2Y->In04urb); - snd_card_disconnect((snd_card_t*)ptr); + snd_card_disconnect(card); /* release the midi resources */ list_for_each(p, &usX2Y->chip.midi_list) { snd_usbmidi_disconnect(p); } if (usX2Y->us428ctls_sharedmem) wake_up(&usX2Y->us428ctls_wait_queue_head); - snd_card_free((snd_card_t*)ptr); + snd_card_free(card); } } diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index c5989cb..e1dbfbb 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -205,47 +205,42 @@ static int usX2Y_urb_submit(snd_usX2Y_substream_t *subs, struct urb *urb, int fr static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_usX2Y_substream_t *playbacksubs, int frame) { int err, state; - { - struct urb *urb = playbacksubs->completed_urb; - - state = atomic_read(&playbacksubs->state); - if (NULL != urb) { - if (state == state_RUNNING) - usX2Y_urb_play_retire(playbacksubs, urb); - else - if (state >= state_PRERUNNING) { - atomic_inc(&playbacksubs->state); - } - } else { - switch (state) { - case state_STARTING1: - urb = playbacksubs->urb[0]; + struct urb *urb = playbacksubs->completed_urb; + + state = atomic_read(&playbacksubs->state); + if (NULL != urb) { + if (state == state_RUNNING) + usX2Y_urb_play_retire(playbacksubs, urb); + else + if (state >= state_PRERUNNING) atomic_inc(&playbacksubs->state); - break; - case state_STARTING2: - urb = playbacksubs->urb[1]; - atomic_inc(&playbacksubs->state); - break; - } - } - if (urb) { - if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) || - (err = usX2Y_urb_submit(playbacksubs, urb, frame))) { - return err; - } + } else { + switch (state) { + case state_STARTING1: + urb = playbacksubs->urb[0]; + atomic_inc(&playbacksubs->state); + break; + case state_STARTING2: + urb = playbacksubs->urb[1]; + atomic_inc(&playbacksubs->state); + break; } - - playbacksubs->completed_urb = NULL; } + if (urb) { + if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) || + (err = usX2Y_urb_submit(playbacksubs, urb, frame))) + return err; + } + + playbacksubs->completed_urb = NULL; + state = atomic_read(&capsubs->state); if (state >= state_PREPARED) { if (state == state_RUNNING) { if ((err = usX2Y_urb_capt_retire(capsubs))) return err; - } else - if (state >= state_PRERUNNING) { - atomic_inc(&capsubs->state); - } + } else if (state >= state_PRERUNNING) + atomic_inc(&capsubs->state); if ((err = usX2Y_urb_submit(capsubs, capsubs->completed_urb, frame))) return err; } @@ -429,7 +424,7 @@ static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) } /* allocate and initialize data urbs */ for (i = 0; i < NRURBS; i++) { - struct urb** purb = subs->urb + i; + struct urb **purb = subs->urb + i; if (*purb) { usb_kill_urb(*purb); continue; @@ -480,47 +475,45 @@ static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs) goto start; } usX2Y->wait_iso_frame = -1; + start: - { - usX2Y_subs_startup(subs); - for (i = 0; i < NRURBS; i++) { - struct urb *urb = subs->urb[i]; - if (usb_pipein(urb->pipe)) { - unsigned long pack; - if (0 == i) - atomic_set(&subs->state, state_STARTING3); - urb->dev = usX2Y->chip.dev; - urb->transfer_flags = URB_ISO_ASAP; - for (pack = 0; pack < nr_of_packs(); pack++) { - urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack; - urb->iso_frame_desc[pack].length = subs->maxpacksize; - } - urb->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); - if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { - snd_printk (KERN_ERR "cannot submit datapipe for urb %d, err = %d\n", i, err); - err = -EPIPE; - goto cleanup; - } else { - if (0 > usX2Y->wait_iso_frame) - usX2Y->wait_iso_frame = urb->start_frame; - } - urb->transfer_flags = 0; + usX2Y_subs_startup(subs); + for (i = 0; i < NRURBS; i++) { + struct urb *urb = subs->urb[i]; + if (usb_pipein(urb->pipe)) { + unsigned long pack; + if (0 == i) + atomic_set(&subs->state, state_STARTING3); + urb->dev = usX2Y->chip.dev; + urb->transfer_flags = URB_ISO_ASAP; + for (pack = 0; pack < nr_of_packs(); pack++) { + urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack; + urb->iso_frame_desc[pack].length = subs->maxpacksize; + } + urb->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); + if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { + snd_printk (KERN_ERR "cannot submit datapipe for urb %d, err = %d\n", i, err); + err = -EPIPE; + goto cleanup; } else { - atomic_set(&subs->state, state_STARTING1); - break; + if (0 > usX2Y->wait_iso_frame) + usX2Y->wait_iso_frame = urb->start_frame; } + urb->transfer_flags = 0; + } else { + atomic_set(&subs->state, state_STARTING1); + break; } - err = 0; - wait_event(usX2Y->prepare_wait_queue, NULL == usX2Y->prepare_subs); - if (atomic_read(&subs->state) != state_PREPARED) { - err = -EPIPE; - } + } + err = 0; + wait_event(usX2Y->prepare_wait_queue, NULL == usX2Y->prepare_subs); + if (atomic_read(&subs->state) != state_PREPARED) + err = -EPIPE; - cleanup: - if (err) { - usX2Y_subs_startup_finish(usX2Y); - usX2Y_clients_stop(usX2Y); // something is completely wroong > stop evrything - } + cleanup: + if (err) { + usX2Y_subs_startup_finish(usX2Y); + usX2Y_clients_stop(usX2Y); // something is completely wroong > stop evrything } return err; } @@ -667,13 +660,12 @@ static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; if (usX2Y->rate != rate) { - us = kmalloc(sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS, GFP_KERNEL); + us = kzalloc(sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS, GFP_KERNEL); if (NULL == us) { err = -ENOMEM; goto cleanup; } - memset(us, 0, sizeof(*us) + sizeof(struct urb*) * NOOF_SETRATE_URBS); - usbdata = kmalloc(sizeof(int)*NOOF_SETRATE_URBS, GFP_KERNEL); + usbdata = kmalloc(sizeof(int) * NOOF_SETRATE_URBS, GFP_KERNEL); if (NULL == usbdata) { err = -ENOMEM; goto cleanup; @@ -713,9 +705,8 @@ static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) usX2Y->US04 = NULL; kfree(usbdata); kfree(us); - if (!err) { + if (!err) usX2Y->rate = rate; - } } } @@ -759,30 +750,29 @@ static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, int err = 0; unsigned int rate = params_rate(hw_params); snd_pcm_format_t format = params_format(hw_params); - snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params); - - { // all pcm substreams off one usX2Y have to operate at the same rate & format snd_card_t *card = substream->pstr->pcm->card; struct list_head *list; - list_for_each(list, &card->devices) { - snd_device_t *dev; - snd_pcm_t *pcm; - int s; - dev = snd_device(list); - if (dev->type != SNDRV_DEV_PCM) - continue; - pcm = dev->device_data; - for (s = 0; s < 2; ++s) { - snd_pcm_substream_t *test_substream; - test_substream = pcm->streams[s].substream; - if (test_substream && test_substream != substream && - test_substream->runtime && - ((test_substream->runtime->format && - test_substream->runtime->format != format) || - (test_substream->runtime->rate && - test_substream->runtime->rate != rate))) - return -EINVAL; - } + + snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params); + // all pcm substreams off one usX2Y have to operate at the same rate & format + list_for_each(list, &card->devices) { + snd_device_t *dev; + snd_pcm_t *pcm; + int s; + dev = snd_device(list); + if (dev->type != SNDRV_DEV_PCM) + continue; + pcm = dev->device_data; + for (s = 0; s < 2; ++s) { + snd_pcm_substream_t *test_substream; + test_substream = pcm->streams[s].substream; + if (test_substream && test_substream != substream && + test_substream->runtime && + ((test_substream->runtime->format && + test_substream->runtime->format != format) || + (test_substream->runtime->rate && + test_substream->runtime->rate != rate))) + return -EINVAL; } } if (0 > (err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)))) { diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index 4bbf52b..c5379280 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -177,10 +177,8 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, if (NULL != urb) { if (state == state_RUNNING) usX2Y_urb_play_retire(playbacksubs, urb); - else - if (state >= state_PRERUNNING) { - atomic_inc(&playbacksubs->state); - } + else if (state >= state_PRERUNNING) + atomic_inc(&playbacksubs->state); } else { switch (state) { case state_STARTING1: @@ -207,10 +205,8 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, if (state == state_RUNNING) { if ((err = usX2Y_usbpcm_urb_capt_retire(capsubs))) return err; - } else { - if (state >= state_PRERUNNING) - atomic_inc(&capsubs->state); - } + } else if (state >= state_PRERUNNING) + atomic_inc(&capsubs->state); usX2Y_usbpcm_urb_capt_iso_advance(capsubs, capsubs->completed_urb); if (NULL != capsubs2) usX2Y_usbpcm_urb_capt_iso_advance(NULL, capsubs2->completed_urb); @@ -330,7 +326,7 @@ static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs) /* allocate and initialize data urbs */ for (i = 0; i < NRURBS; i++) { - struct urb** purb = subs->urb + i; + struct urb **purb = subs->urb + i; if (*purb) { usb_kill_urb(*purb); continue; @@ -582,10 +578,9 @@ static int snd_usX2Y_usbpcm_close(snd_pcm_substream_t *substream) { snd_pcm_runtime_t *runtime = substream->runtime; snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; - int err = 0; - snd_printd("\n"); + subs->pcm_substream = NULL; - return err; + return 0; } @@ -710,9 +705,9 @@ static struct vm_operations_struct snd_usX2Y_hwdep_pcm_vm_ops = { static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) { unsigned long size = (unsigned long)(area->vm_end - area->vm_start); - usX2Ydev_t *usX2Y = (usX2Ydev_t*)hw->private_data; + usX2Ydev_t *usX2Y = hw->private_data; - if (!(((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT)) + if (!(usX2Y->chip_status & USX2Y_STAT_CHIP_INIT)) return -EBUSY; /* if userspace tries to mmap beyond end of our buffer, fail */ @@ -726,7 +721,6 @@ static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct } area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; area->vm_flags |= VM_RESERVED; - snd_printd("vm_flags=0x%lX\n", area->vm_flags); area->vm_private_data = hw->private_data; return 0; } @@ -734,7 +728,7 @@ static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct static void snd_usX2Y_hwdep_pcm_private_free(snd_hwdep_t *hwdep) { - usX2Ydev_t *usX2Y = (usX2Ydev_t *)hwdep->private_data; + usX2Ydev_t *usX2Y = hwdep->private_data; if (NULL != usX2Y->hwdep_pcm_shm) snd_free_pages(usX2Y->hwdep_pcm_shm, sizeof(snd_usX2Y_hwdep_pcm_shm_t)); } @@ -749,10 +743,9 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card) if (1 != nr_of_packs()) return 0; - if ((err = snd_hwdep_new(card, SND_USX2Y_USBPCM_ID, 1, &hw)) < 0) { - snd_printd("\n"); + if ((err = snd_hwdep_new(card, SND_USX2Y_USBPCM_ID, 1, &hw)) < 0) return err; - } + hw->iface = SNDRV_HWDEP_IFACE_USX2Y_PCM; hw->private_data = usX2Y(card); hw->private_free = snd_usX2Y_hwdep_pcm_private_free; -- cgit v1.1 From a57d15158113cb7f10e662e6df07f445c986a12d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 10:50:13 +0100 Subject: [ALSA] emux - Avoid cast of function pointers Modules: Common EMU synth Pass the proper functions instead of cast of function pointers, which can be dangerous with compiler optimizations. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/synth/emux/emux.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index 9e2b4c0..2aacd8a 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -66,6 +66,29 @@ int snd_emux_new(snd_emux_t **remu) /* */ +static int sf_sample_new(void *private_data, snd_sf_sample_t *sp, + snd_util_memhdr_t *hdr, + const void __user *buf, long count) +{ + snd_emux_t *emu = private_data; + return emu->ops.sample_new(emu, sp, hdr, buf, count); + +} + +static int sf_sample_free(void *private_data, snd_sf_sample_t *sp, + snd_util_memhdr_t *hdr) +{ + snd_emux_t *emu = private_data; + return emu->ops.sample_free(emu, sp, hdr); + +} + +static void sf_sample_reset(void *private_data) +{ + snd_emux_t *emu = private_data; + emu->ops.sample_reset(emu); +} + int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name) { int err; @@ -85,9 +108,12 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name) /* create soundfont list */ memset(&sf_cb, 0, sizeof(sf_cb)); sf_cb.private_data = emu; - sf_cb.sample_new = (snd_sf_sample_new_t)emu->ops.sample_new; - sf_cb.sample_free = (snd_sf_sample_free_t)emu->ops.sample_free; - sf_cb.sample_reset = (snd_sf_sample_reset_t)emu->ops.sample_reset; + if (emu->ops.sample_new) + sf_cb.sample_new = sf_sample_new; + if (emu->ops.sample_free) + sf_cb.sample_free = sf_sample_free; + if (emu->ops.sample_reset) + sf_cb.sample_reset = sf_sample_reset; emu->sflist = snd_sf_new(&sf_cb, emu->memhdr); if (emu->sflist == NULL) return -ENOMEM; -- cgit v1.1 From ba7301c7d985d206a5688c69d0a74de3988f6d6c Mon Sep 17 00:00:00 2001 From: Andreas Mohr <andi@lisas.de> Date: Thu, 17 Nov 2005 11:03:31 +0100 Subject: [ALSA] ALS4000 update Modules: SB drivers,ALS4000 driver some update for the ALS4000 driver (tested with hardware in my PC): - use common control names according to ControlNames.txt - add some controls (Master Mono, 3D control) - optimize struct snd_card_als4000_t layout (performance/size) - save some bytes via unified error path - constify some read-only data - add ToDo list - move GPL license text to top - add comments Signed-off-by: Andreas Mohr <andi@lisas.de> Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/sb/sb_mixer.c | 57 ++++++++++++++++++------------- sound/pci/als4000.c | 89 ++++++++++++++++++++++++++++++------------------- 2 files changed, 88 insertions(+), 58 deletions(-) diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 5a926a4..23cfa6a 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c @@ -669,25 +669,34 @@ static unsigned char snd_dt019x_init_values[][2] = { /* * ALS4000 specific mixer elements */ -/* FIXME: SB_ALS4000_MONO_IO_CTRL needs output select ctrl ! */ -static struct sbmix_elem snd_als4000_ctl_mono_output_switch = - SB_SINGLE("Mono Output Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); -/* FIXME: mono input switch also available on DT019X ? */ -static struct sbmix_elem snd_als4000_ctl_mono_input_switch = - SB_SINGLE("Mono Input Switch", SB_DT019X_OUTPUT_SW2, 0, 1); +/* FIXME: SB_ALS4000_MONO_IO_CTRL needs output select ctrl! */ +static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch = + SB_SINGLE("Master Mono Playback Switch", SB_ALS4000_MONO_IO_CTRL, 5, 1); +static struct sbmix_elem snd_als4000_ctl_master_mono_capture_route = + SB_SINGLE("Master Mono Capture Route", SB_ALS4000_MONO_IO_CTRL, 6, 0x03); +/* FIXME: mono playback switch also available on DT019X? */ +static struct sbmix_elem snd_als4000_ctl_mono_playback_switch = + SB_SINGLE("Mono Playback Switch", SB_DT019X_OUTPUT_SW2, 0, 1); static struct sbmix_elem snd_als4000_ctl_mic_20db_boost = SB_SINGLE("Mic Boost (+20dB)", SB_ALS4000_MIC_IN_GAIN, 0, 0x03); -static struct sbmix_elem snd_als4000_ctl_mixer_out_to_in = - SB_SINGLE("Mixer Out To In", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); -/* FIXME: 3D needs much more sophisticated controls, many more features ! */ -static struct sbmix_elem snd_als4000_ctl_3d_output_switch = - SB_SINGLE("3D Output Switch", SB_ALS4000_3D_SND_FX, 6, 0x01); -static struct sbmix_elem snd_als4000_ctl_3d_output_ratio = - SB_SINGLE("3D Output Ratio", SB_ALS4000_3D_SND_FX, 0, 0x07); -static struct sbmix_elem snd_als4000_ctl_3d_poweroff_switch = +static struct sbmix_elem snd_als4000_ctl_mixer_loopback = + SB_SINGLE("Analog Loopback", SB_ALS4000_MIC_IN_GAIN, 7, 0x01); +/* FIXME: functionality of 3D controls might be swapped, I didn't find + * a description of how to identify what is supposed to be what */ +static struct sbmix_elem snd_als4000_3d_control_switch = + SB_SINGLE("3D Control - Switch", SB_ALS4000_3D_SND_FX, 6, 0x01); +static struct sbmix_elem snd_als4000_3d_control_ratio = + SB_SINGLE("3D Control - Level", SB_ALS4000_3D_SND_FX, 0, 0x07); +static struct sbmix_elem snd_als4000_3d_control_freq = + /* FIXME: maybe there's actually some standard 3D ctrl name for it?? */ + SB_SINGLE("3D Control - Freq", SB_ALS4000_3D_SND_FX, 4, 0x03); +static struct sbmix_elem snd_als4000_3d_control_delay = + /* FIXME: ALS4000a.pdf mentions BBD (Bucket Brigade Device) time delay, + * but what ALSA 3D attribute is that actually? "Center", "Depth", + * "Wide" or "Space" or even "Level"? Assuming "Wide" for now... */ + SB_SINGLE("3D Control - Wide", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); +static struct sbmix_elem snd_als4000_3d_control_poweroff_switch = SB_SINGLE("3D PowerOff Switch", SB_ALS4000_3D_TIME_DELAY, 4, 0x01); -static struct sbmix_elem snd_als4000_ctl_3d_delay = - SB_SINGLE("3D Delay", SB_ALS4000_3D_TIME_DELAY, 0, 0x0f); #ifdef NOT_AVAILABLE static struct sbmix_elem snd_als4000_ctl_fmdac = SB_SINGLE("FMDAC Switch (Option ?)", SB_ALS4000_FMDAC, 0, 0x01); @@ -716,13 +725,15 @@ static struct sbmix_elem *snd_als4000_controls[] = { &snd_sb16_ctl_pc_speaker_vol, &snd_sb16_ctl_capture_vol, &snd_sb16_ctl_play_vol, - &snd_als4000_ctl_mono_output_switch, - &snd_als4000_ctl_mono_input_switch, - &snd_als4000_ctl_mixer_out_to_in, - &snd_als4000_ctl_3d_output_switch, - &snd_als4000_ctl_3d_output_ratio, - &snd_als4000_ctl_3d_delay, - &snd_als4000_ctl_3d_poweroff_switch, + &snd_als4000_ctl_master_mono_playback_switch, + &snd_als4000_ctl_master_mono_capture_route, + &snd_als4000_ctl_mono_playback_switch, + &snd_als4000_ctl_mixer_loopback, + &snd_als4000_3d_control_switch, + &snd_als4000_3d_control_ratio, + &snd_als4000_3d_control_freq, + &snd_als4000_3d_control_delay, + &snd_als4000_3d_control_poweroff_switch, #ifdef NOT_AVAILABLE &snd_als4000_ctl_fmdac, &snd_als4000_ctl_qsound, diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index d496cc5a..48b5175 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -6,6 +6,21 @@ * * Framework borrowed from Massimo Piccioni's card-als100.c. * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * * NOTES * * Since Avance does not provide any meaningful documentation, and I @@ -43,19 +58,9 @@ * Set KSound: * - value -> some port 0x0c0d * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * ToDo: + * - Proper shared IRQ handling? + * - power management? (card can do voice wakeup according to datasheet!!) */ #include <sound/driver.h> @@ -101,8 +106,9 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address for ALS4000 soundcard. (0 #endif typedef struct { - struct pci_dev *pci; + /* most frequent access first */ unsigned long gcr; + struct pci_dev *pci; #ifdef SUPPORT_JOYSTICK struct gameport *gameport; #endif @@ -146,13 +152,13 @@ static void snd_als4000_set_rate(sb_t *chip, unsigned int rate) } } -static void snd_als4000_set_capture_dma(sb_t *chip, dma_addr_t addr, unsigned size) +static inline void snd_als4000_set_capture_dma(sb_t *chip, dma_addr_t addr, unsigned size) { snd_als4000_gcr_write(chip, 0xa2, addr); snd_als4000_gcr_write(chip, 0xa3, (size-1)); } -static void snd_als4000_set_playback_dma(sb_t *chip, dma_addr_t addr, unsigned size) +static inline void snd_als4000_set_playback_dma(sb_t *chip, dma_addr_t addr, unsigned size) { snd_als4000_gcr_write(chip, 0x91, addr); snd_als4000_gcr_write(chip, 0x92, (size-1)|0x180000); @@ -177,7 +183,7 @@ static int snd_als4000_get_format(snd_pcm_runtime_t *runtime) } /* structure for setting up playback */ -static struct { +static const struct { unsigned char dsp_cmd, dma_on, dma_off, format; } playback_cmd_vals[]={ /* ALS4000_FORMAT_U8_MONO */ @@ -201,7 +207,7 @@ static struct { /* structure for setting up capture */ enum { CMD_WIDTH8=0x04, CMD_SIGNED=0x10, CMD_MONO=0x80, CMD_STEREO=0xA0 }; -static unsigned char capture_cmd_vals[]= +static const unsigned char capture_cmd_vals[]= { CMD_WIDTH8|CMD_MONO, /* ALS4000_FORMAT_U8_MONO */ CMD_WIDTH8|CMD_SIGNED|CMD_MONO, /* ALS4000_FORMAT_S8_MONO */ @@ -228,9 +234,9 @@ static int snd_als4000_hw_free(snd_pcm_substream_t * substream) static int snd_als4000_capture_prepare(snd_pcm_substream_t * substream) { - unsigned long flags; sb_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; + unsigned long flags; unsigned long size; unsigned count; @@ -256,9 +262,9 @@ static int snd_als4000_capture_prepare(snd_pcm_substream_t * substream) static int snd_als4000_playback_prepare(snd_pcm_substream_t *substream) { - unsigned long flags; sb_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; + unsigned long flags; unsigned long size; unsigned count; @@ -353,6 +359,18 @@ static snd_pcm_uframes_t snd_als4000_playback_pointer(snd_pcm_substream_t * subs return bytes_to_frames( substream->runtime, result ); } +/* FIXME: this IRQ routine doesn't really support IRQ sharing (we always + * return IRQ_HANDLED no matter whether we actually had an IRQ flag or not). + * ALS4000a.PDF writes that while ACKing IRQ in PCI block will *not* ACK + * the IRQ in the SB core, ACKing IRQ in SB block *will* ACK the PCI IRQ + * register (alt_port + 0x0e). Probably something could be optimized here to + * query/write one register only... + * And even if both registers need to be queried, then there's still the + * question of whether it's actually correct to ACK PCI IRQ before reading + * SB IRQ like we do now, since ALS4000a.PDF mentions that PCI IRQ will *clear* + * SB IRQ status. + * And do we *really* need the lock here for *reading* SB_DSP4_IRQSTATUS?? + * */ static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id, struct pt_regs *regs) { sb_t *chip = dev_id; @@ -698,8 +716,7 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci, -1, SB_HW_ALS4000, &chip)) < 0) { - snd_card_free(card); - return err; + goto out_err; } chip->pci = pci; @@ -716,40 +733,42 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci, if ((err = snd_mpu401_uart_new( card, 0, MPU401_HW_ALS4000, gcr+0x30, 1, pci->irq, 0, &chip->rmidi)) < 0) { - snd_card_free(card); - printk(KERN_ERR "als4000: no MPU-401device at 0x%lx ?\n", gcr+0x30); - return err; + printk(KERN_ERR "als4000: no MPU-401 device at 0x%lx?\n", gcr+0x30); + goto out_err; } if ((err = snd_als4000_pcm(chip, 0)) < 0) { - snd_card_free(card); - return err; + goto out_err; } if ((err = snd_sbmixer_new(chip)) < 0) { - snd_card_free(card); - return err; + goto out_err; } if (snd_opl3_create(card, gcr+0x10, gcr+0x12, OPL3_HW_AUTO, 1, &opl3) < 0) { - printk(KERN_ERR "als4000: no OPL device at 0x%lx-0x%lx ?\n", + printk(KERN_ERR "als4000: no OPL device at 0x%lx-0x%lx?\n", gcr+0x10, gcr+0x12 ); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) { - snd_card_free(card); - return err; + goto out_err; } } snd_als4000_create_gameport(acard, dev); if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; + goto out_err; } pci_set_drvdata(pci, card); dev++; - return 0; + err = 0; + goto out; + +out_err: + snd_card_free(card); + +out: + return err; } static void __devexit snd_card_als4000_remove(struct pci_dev *pci) -- cgit v1.1 From 10e4097fb47b57d095204d3fad10b25e3b4d42a3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 11:04:55 +0100 Subject: [ALSA] [Trivial] Fix ac97_quirk option in document Modules: Documentation Fix a wrong option value for ac97_quirk option in the document. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- Documentation/sound/alsa/ALSA-Configuration.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 23d1870..84068ba 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -1481,7 +1481,7 @@ the proper value with this option. The following strings are accepted: - default Don't override the default setting - - disable Disable the quirk + - none Disable the quirk - hp_only Bind Master and Headphone controls as a single control - swap_hp Swap headphone and master controls - swap_surround Swap master and surround controls -- cgit v1.1 From 59de641ca37b88dd34d0e1d853800b488f642624 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 11:05:34 +0100 Subject: [ALSA] Small update of Procfile.txt Modules: Documentation Small update of Procfile.txt for hda and usb proc files. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- Documentation/sound/alsa/Procfile.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/sound/alsa/Procfile.txt b/Documentation/sound/alsa/Procfile.txt index 25c5d64..1fe4884 100644 --- a/Documentation/sound/alsa/Procfile.txt +++ b/Documentation/sound/alsa/Procfile.txt @@ -138,6 +138,22 @@ card*/codec97#0/ac97#?-?+regs # echo 02 9f1f > /proc/asound/card0/codec97#0/ac97#0-0+regs +USB Audio Streams +----------------- + +card*/stream* + Shows the assignment and the current status of each audio stream + of the given card. This information is very useful for debugging. + + +HD-Audio Codecs +--------------- + +card*/codec#* + Shows the general codec information and the attribute of each + widget node. + + Sequencer Information --------------------- -- cgit v1.1 From d2a6d7dc757da6b57d77bd8b460cf4faa9fd152d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 11:06:29 +0100 Subject: [ALSA] hda-codec - Add channel-mode helper Modules: HDA Codec driver,HDA generic driver Add common channel-mode helper functions for all codec patches. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/hda_codec.c | 48 +++++++++++++++++++++++++++++++ sound/pci/hda/hda_local.h | 17 +++++++++++ sound/pci/hda/patch_analog.c | 2 +- sound/pci/hda/patch_cmedia.c | 62 +++++++++++---------------------------- sound/pci/hda/patch_realtek.c | 67 +++++++++++-------------------------------- 5 files changed, 99 insertions(+), 97 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index e7fb182..14a6f54 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1662,6 +1662,54 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew) } + /* + * Channel mode helper + */ +int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo, + const struct hda_channel_mode *chmode, int num_chmodes) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = num_chmodes; + if (uinfo->value.enumerated.item >= num_chmodes) + uinfo->value.enumerated.item = num_chmodes - 1; + sprintf(uinfo->value.enumerated.name, "%dch", + chmode[uinfo->value.enumerated.item].channels); + return 0; +} + +int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, + const struct hda_channel_mode *chmode, int num_chmodes, + int max_channels) +{ + int i; + + for (i = 0; i < num_chmodes; i++) { + if (max_channels == chmode[i].channels) { + ucontrol->value.enumerated.item[0] = i; + break; + } + } + return 0; +} + +int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, + const struct hda_channel_mode *chmode, int num_chmodes, + int *max_channelsp) +{ + unsigned int mode; + + mode = ucontrol->value.enumerated.item[0]; + snd_assert(mode < num_chmodes, return -EINVAL); + if (*max_channelsp && ! codec->in_resume) + return 0; + /* change the current channel setting */ + *max_channelsp = chmode[mode].channels; + if (chmode[mode].sequence) + snd_hda_sequence_write(codec, chmode[mode].sequence); + return 1; +} + /* * input MUX helper */ diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index f51a56f..05a88fb 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -102,6 +102,23 @@ int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *i snd_ctl_elem_value_t *ucontrol, hda_nid_t nid, unsigned int *cur_val); + /* + * Channel mode helper + */ +struct hda_channel_mode { + int channels; + const struct hda_verb *sequence; +}; + +int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo, + const struct hda_channel_mode *chmode, int num_chmodes); +int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, + const struct hda_channel_mode *chmode, int num_chmodes, + int max_channels); +int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, + const struct hda_channel_mode *chmode, int num_chmodes, + int *max_channelsp); + /* * Multi-channel / digital-out PCM helper */ diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index d7d636d..4687736 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -52,7 +52,7 @@ struct ad198x_spec { unsigned int cur_mux[3]; /* channel model */ - const struct alc_channel_mode *channel_mode; + const struct hda_channel_mode *channel_mode; int num_channel_mode; /* PCM information */ diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index 523c362..6e0fd92 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c @@ -44,7 +44,6 @@ enum { struct cmi_spec { int board_config; - unsigned int surr_switch: 1; /* switchable line,mic */ unsigned int no_line_in: 1; /* no line-in (5-jack) */ unsigned int front_panel: 1; /* has front-panel 2-jack */ @@ -62,9 +61,8 @@ struct cmi_spec { unsigned int cur_mux[2]; /* channel mode */ - unsigned int num_ch_modes; - unsigned int cur_ch_mode; - const struct cmi_channel_mode *channel_modes; + int num_channel_modes; + const struct hda_channel_mode *channel_modes; struct hda_pcm pcm_rec[2]; /* PCM information */ @@ -158,12 +156,7 @@ static struct hda_verb cmi9880_ch8_init[] = { {} }; -struct cmi_channel_mode { - unsigned int channels; - const struct hda_verb *sequence; -}; - -static struct cmi_channel_mode cmi9880_channel_modes[3] = { +static struct hda_channel_mode cmi9880_channel_modes[3] = { { 2, cmi9880_ch2_init }, { 6, cmi9880_ch6_init }, { 8, cmi9880_ch8_init }, @@ -173,43 +166,24 @@ static int cmi_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; - - snd_assert(spec->channel_modes, return -EINVAL); - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; - uinfo->value.enumerated.items = spec->num_ch_modes; - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) - uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; - sprintf(uinfo->value.enumerated.name, "%dch", - spec->channel_modes[uinfo->value.enumerated.item].channels); - return 0; + return snd_hda_ch_mode_info(codec, uinfo, spec->channel_modes, + spec->num_channel_modes); } static int cmi_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; - - ucontrol->value.enumerated.item[0] = spec->cur_ch_mode; - return 0; + return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_modes, + spec->num_channel_modes, spec->multiout.max_channels); } static int cmi_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; - - snd_assert(spec->channel_modes, return -EINVAL); - if (ucontrol->value.enumerated.item[0] >= spec->num_ch_modes) - ucontrol->value.enumerated.item[0] = spec->num_ch_modes; - if (ucontrol->value.enumerated.item[0] == spec->cur_ch_mode && - ! codec->in_resume) - return 0; - - spec->cur_ch_mode = ucontrol->value.enumerated.item[0]; - snd_hda_sequence_write(codec, spec->channel_modes[spec->cur_ch_mode].sequence); - spec->multiout.max_channels = spec->channel_modes[spec->cur_ch_mode].channels; - return 1; + return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_modes, + spec->num_channel_modes, &spec->multiout.max_channels); } /* @@ -361,7 +335,7 @@ static int cmi9880_build_controls(struct hda_codec *codec) err = snd_hda_add_new_ctls(codec, cmi9880_basic_mixer); if (err < 0) return err; - if (spec->surr_switch) { + if (spec->channel_modes) { err = snd_hda_add_new_ctls(codec, cmi9880_ch_mode_mixer); if (err < 0) return err; @@ -475,7 +449,7 @@ static int cmi9880_resume(struct hda_codec *codec) cmi9880_init(codec); snd_hda_resume_ctls(codec, cmi9880_basic_mixer); - if (spec->surr_switch) + if (spec->channel_modes) snd_hda_resume_ctls(codec, cmi9880_ch_mode_mixer); if (spec->multiout.dig_out_nid) snd_hda_resume_spdif_out(codec); @@ -685,14 +659,13 @@ static int patch_cmi9880(struct hda_codec *codec) switch (spec->board_config) { case CMI_MINIMAL: case CMI_MIN_FP: - spec->surr_switch = 1; + spec->channel_modes = cmi9880_channel_modes; if (spec->board_config == CMI_MINIMAL) - spec->num_ch_modes = 2; + spec->num_channel_modes = 2; else { spec->front_panel = 1; - spec->num_ch_modes = 3; + spec->num_channel_modes = 3; } - spec->channel_modes = cmi9880_channel_modes; spec->multiout.max_channels = cmi9880_channel_modes[0].channels; spec->input_mux = &cmi9880_basic_mux; break; @@ -727,19 +700,18 @@ static int patch_cmi9880(struct hda_codec *codec) get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) { port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); - spec->surr_switch = 1; + spec->channel_modes = cmi9880_channel_modes; /* no front panel */ if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE || get_defcfg_connect(port_h) == AC_JACK_PORT_NONE) { /* no optional rear panel */ spec->board_config = CMI_MINIMAL; spec->front_panel = 0; - spec->num_ch_modes = 2; + spec->num_channel_modes = 2; } else { spec->board_config = CMI_MIN_FP; - spec->num_ch_modes = 3; + spec->num_channel_modes = 3; } - spec->channel_modes = cmi9880_channel_modes; spec->input_mux = &cmi9880_basic_mux; spec->multiout.max_channels = cmi9880_channel_modes[0].channels; } else { diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cffb83f..a213c19 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -109,7 +109,7 @@ struct alc_spec { unsigned int cur_mux[3]; /* channel model */ - const struct alc_channel_mode *channel_mode; + const struct hda_channel_mode *channel_mode; int num_channel_mode; /* PCM information */ @@ -157,63 +157,28 @@ static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon /* * channel mode setting */ -struct alc_channel_mode { - int channels; - const struct hda_verb *sequence; -}; - static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; - int items = kcontrol->private_value ? (int)kcontrol->private_value : 2; - - snd_assert(spec->channel_mode, return -ENXIO); - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; - uinfo->value.enumerated.items = items; - if (uinfo->value.enumerated.item >= items) - uinfo->value.enumerated.item = items - 1; - sprintf(uinfo->value.enumerated.name, "%dch", - spec->channel_mode[uinfo->value.enumerated.item].channels); - return 0; + return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, + spec->num_channel_mode); } static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; - int items = kcontrol->private_value ? (int)kcontrol->private_value : 2; - int i; - - snd_assert(spec->channel_mode, return -ENXIO); - for (i = 0; i < items; i++) { - if (spec->multiout.max_channels == spec->channel_mode[i].channels) { - ucontrol->value.enumerated.item[0] = i; - break; - } - } - return 0; + return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, + spec->num_channel_mode, spec->multiout.max_channels); } static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; - int mode; - - snd_assert(spec->channel_mode, return -ENXIO); - mode = ucontrol->value.enumerated.item[0] ? 1 : 0; - if (spec->multiout.max_channels == spec->channel_mode[mode].channels && - ! codec->in_resume) - return 0; - - /* change the current channel setting */ - spec->multiout.max_channels = spec->channel_mode[mode].channels; - if (spec->channel_mode[mode].sequence) - snd_hda_sequence_write(codec, spec->channel_mode[mode].sequence); - - return 1; + return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, + spec->num_channel_mode, &spec->multiout.max_channels); } @@ -328,7 +293,7 @@ static struct hda_verb alc880_threestack_ch6_init[] = { { } /* end */ }; -static struct alc_channel_mode alc880_threestack_modes[2] = { +static struct hda_channel_mode alc880_threestack_modes[2] = { { 2, alc880_threestack_ch2_init }, { 6, alc880_threestack_ch6_init }, }; @@ -443,7 +408,7 @@ static struct hda_verb alc880_fivestack_ch8_init[] = { { } /* end */ }; -static struct alc_channel_mode alc880_fivestack_modes[2] = { +static struct hda_channel_mode alc880_fivestack_modes[2] = { { 6, alc880_fivestack_ch6_init }, { 8, alc880_fivestack_ch8_init }, }; @@ -473,7 +438,7 @@ static struct hda_input_mux alc880_6stack_capture_source = { }; /* fixed 8-channels */ -static struct alc_channel_mode alc880_sixstack_modes[1] = { +static struct hda_channel_mode alc880_sixstack_modes[1] = { { 8, NULL }, }; @@ -540,7 +505,7 @@ static hda_nid_t alc880_w810_dac_nids[3] = { }; /* fixed 6 channels */ -static struct alc_channel_mode alc880_w810_modes[1] = { +static struct hda_channel_mode alc880_w810_modes[1] = { { 6, NULL } }; @@ -572,7 +537,7 @@ static hda_nid_t alc880_z71v_dac_nids[1] = { #define ALC880_Z71V_HP_DAC 0x03 /* fixed 2 channels */ -static struct alc_channel_mode alc880_2_jack_modes[1] = { +static struct hda_channel_mode alc880_2_jack_modes[1] = { { 2, NULL } }; @@ -1227,7 +1192,7 @@ static struct hda_input_mux alc880_test_capture_source = { }, }; -static struct alc_channel_mode alc880_test_modes[4] = { +static struct hda_channel_mode alc880_test_modes[4] = { { 2, NULL }, { 4, NULL }, { 6, NULL }, @@ -1585,7 +1550,7 @@ struct alc_config_preset { unsigned int num_adc_nids; hda_nid_t *adc_nids; unsigned int num_channel_mode; - const struct alc_channel_mode *channel_mode; + const struct hda_channel_mode *channel_mode; const struct hda_input_mux *input_mux; }; @@ -2202,7 +2167,7 @@ static struct hda_input_mux alc260_fujitsu_capture_source = { * element which allows changing the channel mode, so the verb list is * never used. */ -static struct alc_channel_mode alc260_modes[1] = { +static struct hda_channel_mode alc260_modes[1] = { { 2, NULL }, }; @@ -2506,7 +2471,7 @@ static int patch_alc260(struct hda_codec *codec) * driver yet). */ -static struct alc_channel_mode alc882_ch_modes[1] = { +static struct hda_channel_mode alc882_ch_modes[1] = { { 8, NULL } }; -- cgit v1.1 From 9f146bb6e68610ab2b62c76e7485900545515613 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 11:07:49 +0100 Subject: [ALSA] hda-codec - Prepare unsol workqueue on demand Modules: HDA Codec driver Prepare unsol workqueue only when a codec really supports. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/hda_codec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 14a6f54..cfd50b5 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -288,6 +288,9 @@ static int init_unsol_queue(struct hda_bus *bus) { struct hda_bus_unsolicited *unsol; + if (bus->unsol) /* already initialized */ + return 0; + unsol = kzalloc(sizeof(*unsol), GFP_KERNEL); if (! unsol) { snd_printk(KERN_ERR "hda_codec: can't allocate unsolicited queue\n"); @@ -373,8 +376,6 @@ int snd_hda_bus_new(snd_card_t *card, const struct hda_bus_template *temp, init_MUTEX(&bus->cmd_mutex); INIT_LIST_HEAD(&bus->codec_list); - init_unsol_queue(bus); - if ((err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops)) < 0) { snd_hda_bus_free(bus); return err; @@ -540,6 +541,9 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, return err; } + if (codec->patch_ops.unsol_event) + init_unsol_queue(bus); + snd_hda_codec_proc_new(codec); sprintf(component, "HDA:%08x", codec->vendor_id); -- cgit v1.1 From a2a20939b1cc82222eb67a4631009338791f1acd Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 11:08:23 +0100 Subject: [ALSA] hda-codec - Fix a typo Modules: HDA Codec driver Fix a typo in hda_codec.h. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/hda_codec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index b0123ad..58b9949 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -98,7 +98,7 @@ enum { #define AC_VERB_SET_UNSOLICITED_ENABLE 0x708 #define AC_VERB_SET_PIN_SENSE 0x709 #define AC_VERB_SET_BEEP_CONTROL 0x70a -#define AC_VERB_SET_EAPD_BTLENALBE 0x70c +#define AC_VERB_SET_EAPD_BTLENABLE 0x70c #define AC_VERB_SET_DIGI_CONVERT_1 0x70d #define AC_VERB_SET_DIGI_CONVERT_2 0x70e #define AC_VERB_SET_VOLUME_KNOB_CONTROL 0x70f -- cgit v1.1 From 8d88bc3d361bdd81a214eb9c5d06b291d06c603a Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 11:09:23 +0100 Subject: [ALSA] hda-codec - Fix assignment of speaker pin Modules: HDA Codec driver,HDA generic driver Fix the auto-assignment of speaker pin. Handle it independently from line-out pins. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/hda_codec.c | 4 +++- sound/pci/hda/hda_local.h | 15 ++++++++++++++ sound/pci/hda/patch_cmedia.c | 13 ------------ sound/pci/hda/patch_realtek.c | 47 ++++++++++++++++++++----------------------- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index cfd50b5..2e9f587 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1889,7 +1889,6 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c loc = get_defcfg_location(def_conf); switch (get_defcfg_device(def_conf)) { case AC_JACK_LINE_OUT: - case AC_JACK_SPEAKER: seq = get_defcfg_sequence(def_conf); assoc = get_defcfg_association(def_conf); if (! assoc) @@ -1904,6 +1903,9 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c sequences[cfg->line_outs] = seq; cfg->line_outs++; break; + case AC_JACK_SPEAKER: + cfg->speaker_pin = nid; + break; case AC_JACK_HP_OUT: cfg->hp_pin = nid; break; diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 05a88fb..31d3c7e 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -214,6 +214,7 @@ enum { struct auto_pin_cfg { int line_outs; hda_nid_t line_out_pins[4]; /* sorted in the order of Front/Surr/CLFE/Side */ + hda_nid_t speaker_pin; hda_nid_t hp_pin; hda_nid_t input_pins[AUTO_PIN_LAST]; hda_nid_t dig_out_pin; @@ -228,4 +229,18 @@ struct auto_pin_cfg { int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg); +/* amp values */ +#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) +#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) +#define AMP_OUT_MUTE 0xb080 +#define AMP_OUT_UNMUTE 0xb000 +#define AMP_OUT_ZERO 0xb000 +/* pinctl values */ +#define PIN_IN 0x20 +#define PIN_VREF80 0x24 +#define PIN_VREF50 0x21 +#define PIN_OUT 0x40 +#define PIN_HP 0xc0 +#define PIN_HP_AMP 0x80 + #endif /* __SOUND_HDA_LOCAL_H */ diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index 6e0fd92..37ee124 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c @@ -76,19 +76,6 @@ struct cmi_spec { struct hda_verb multi_init[9]; /* 2 verbs for each pin + terminator */ }; -/* amp values */ -#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) -#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) -#define AMP_OUT_MUTE 0xb080 -#define AMP_OUT_UNMUTE 0xb000 -#define AMP_OUT_ZERO 0xb000 -/* pinctl values */ -#define PIN_IN 0x20 -#define PIN_VREF80 0x24 -#define PIN_VREF50 0x21 -#define PIN_OUT 0x40 -#define PIN_HP 0xc0 - /* * input MUX */ diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index a213c19..3ff72c4 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -61,20 +61,6 @@ enum { ALC260_MODEL_LAST /* last tag */ }; -/* amp values */ -#define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) -#define AMP_IN_UNMUTE(idx) (0x7000 | ((idx)<<8)) -#define AMP_OUT_MUTE 0xb080 -#define AMP_OUT_UNMUTE 0xb000 -#define AMP_OUT_ZERO 0xb000 -/* pinctl values */ -#define PIN_IN 0x20 -#define PIN_VREF80 0x24 -#define PIN_VREF50 0x21 -#define PIN_OUT 0x40 -#define PIN_HP 0xc0 -#define PIN_HP_AMP 0x80 - struct alc_spec { /* codec parameterization */ snd_kcontrol_new_t *mixers[3]; /* mixer arrays */ @@ -1833,15 +1819,16 @@ static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct return err; } } - return 0; } -/* add playback controls for HP output */ -static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) +/* add playback controls for speaker and HP outputs */ +static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, + const char *pfx) { hda_nid_t nid; int err; + char name[32]; if (! pin) return 0; @@ -1854,14 +1841,16 @@ static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) if (! spec->multiout.num_dacs) spec->multiout.num_dacs = 1; } else - /* specify the DAC as the extra HP output */ + /* specify the DAC as the extra output */ spec->multiout.hp_nid = nid; /* control HP volume/switch on the output mixer amp */ nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin)); - if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", + sprintf(name, "%s Playback Volume", pfx); + if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) return err; - if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Headphone Playback Switch", + sprintf(name, "%s Playback Switch", pfx); + if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) return err; } else if (alc880_is_multi_pin(pin)) { @@ -1873,7 +1862,8 @@ static int alc880_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) spec->multiout.num_dacs = 1; } /* we have only a switch on HP-out PIN */ - if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", + sprintf(name, "%s Playback Switch", pfx); + if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0) return err; } @@ -1947,11 +1937,14 @@ static void alc880_auto_init_multi_out(struct hda_codec *codec) } } -static void alc880_auto_init_hp_out(struct hda_codec *codec) +static void alc880_auto_init_extra_out(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; hda_nid_t pin; + pin = spec->autocfg.speaker_pin; + if (pin) /* connect to front */ + alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); pin = spec->autocfg.hp_pin; if (pin) /* connect to front */ alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); @@ -1985,10 +1978,14 @@ static int alc880_parse_auto_config(struct hda_codec *codec) return err; if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0) return err; - if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin) + if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && + ! spec->autocfg.hp_pin) return 0; /* can't find valid BIOS pin config */ if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || - (err = alc880_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 || + (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, + "Speaker")) < 0 || + (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, + "Headphone")) < 0 || (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) return err; @@ -2014,7 +2011,7 @@ static int alc880_auto_init(struct hda_codec *codec) { alc_init(codec); alc880_auto_init_multi_out(codec); - alc880_auto_init_hp_out(codec); + alc880_auto_init_extra_out(codec); alc880_auto_init_analog_input(codec); return 0; } -- cgit v1.1 From 3f05f868f1112b970e7fb9c0aa42cc99370098fe Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 11:12:06 +0100 Subject: [ALSA] nm256 - Code clean up Modules: NM256 driver Clean up snd-nm256 driver code: - Simplify chip constructor function Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/nm256/nm256.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 089d23b..a01b3e5 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1375,10 +1375,6 @@ static int snd_nm256_dev_free(snd_device_t *device) static int __devinit snd_nm256_create(snd_card_t *card, struct pci_dev *pci, - int play_bufsize, int capt_bufsize, - int force_load, - u32 buffertop, - int usecache, nm256_t **chip_ret) { nm256_t *chip; @@ -1401,13 +1397,14 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci, chip->card = card; chip->pci = pci; - chip->use_cache = usecache; + chip->use_cache = use_cache; spin_lock_init(&chip->reg_lock); chip->irq = -1; init_MUTEX(&chip->irq_mutex); - chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize = play_bufsize; - chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize = capt_bufsize; + /* store buffer sizes in bytes */ + chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize = playback_bufsize * 1024; + chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize = capture_bufsize * 1024; /* * The NM256 has two memory ports. The first port is nothing @@ -1440,7 +1437,7 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci, /* Ok, try to see if this is a non-AC97 version of the hardware. */ pval = snd_nm256_readw(chip, NM_MIXER_PRESENCE); if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { - if (! force_load) { + if (! force_ac97) { printk(KERN_ERR "nm256: no ac97 is found!\n"); printk(KERN_ERR " force the driver to load by passing in the module parameter\n"); printk(KERN_ERR " force_ac97=1\n"); @@ -1471,8 +1468,8 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci, else chip->buffer_size += NM_MAX_PLAYBACK_COEF_SIZE + NM_MAX_RECORD_COEF_SIZE; - if (buffertop >= chip->buffer_size && buffertop < chip->buffer_end) - chip->buffer_end = buffertop; + if (buffer_top >= chip->buffer_size && buffer_top < chip->buffer_end) + chip->buffer_end = buffer_top; else { /* get buffer end pointer from signature */ if ((err = snd_nm256_peek_for_sig(chip)) < 0) @@ -1567,7 +1564,6 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, snd_card_t *card; nm256_t *chip; int err; - unsigned int xbuffer_top; struct nm256_quirk *q; u16 subsystem_vendor, subsystem_device; @@ -1611,9 +1607,7 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, } if (vaio_hack) - xbuffer_top = 0x25a800; /* this avoids conflicts with XFree86 server */ - else - xbuffer_top = buffer_top; + buffer_top = 0x25a800; /* this avoids conflicts with XFree86 server */ if (playback_bufsize < 4) playback_bufsize = 4; @@ -1623,13 +1617,7 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, capture_bufsize = 4; if (capture_bufsize > 128) capture_bufsize = 128; - if ((err = snd_nm256_create(card, pci, - playback_bufsize * 1024, /* in bytes */ - capture_bufsize * 1024, /* in bytes */ - force_ac97, - xbuffer_top, - use_cache, - &chip)) < 0) { + if ((err = snd_nm256_create(card, pci, &chip)) < 0) { snd_card_free(card); return err; } -- cgit v1.1 From 512bbd6a85230f16389f0dd51925472e72fc8a91 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 13:51:18 +0100 Subject: [ALSA] Remove xxx_t typedefs: Core component Modules: ALSA Core Remove xxx_t typedefs from the core component. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/asound.h | 540 ++++++++++++++++++++++++------------------------- include/sound/core.h | 199 ++++++++---------- sound/core/device.c | 42 ++-- sound/core/init.c | 86 ++++---- sound/core/sound.c | 32 +-- 5 files changed, 432 insertions(+), 467 deletions(-) diff --git a/include/sound/asound.h b/include/sound/asound.h index 1389704..9cc021c 100644 --- a/include/sound/asound.h +++ b/include/sound/asound.h @@ -60,7 +60,7 @@ * * ****************************************************************************/ -struct sndrv_aes_iec958 { +struct snd_aes_iec958 { unsigned char status[24]; /* AES/IEC958 channel status bits */ unsigned char subcode[147]; /* AES/IEC958 subcode bits */ unsigned char pad; /* nothing */ @@ -75,7 +75,7 @@ struct sndrv_aes_iec958 { #define SNDRV_HWDEP_VERSION SNDRV_PROTOCOL_VERSION(1, 0, 1) -enum sndrv_hwdep_iface { +enum { SNDRV_HWDEP_IFACE_OPL2 = 0, SNDRV_HWDEP_IFACE_OPL3, SNDRV_HWDEP_IFACE_OPL4, @@ -97,17 +97,17 @@ enum sndrv_hwdep_iface { SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_SB_RC }; -struct sndrv_hwdep_info { +struct snd_hwdep_info { unsigned int device; /* WR: device number */ int card; /* R: card number */ unsigned char id[64]; /* ID (user selectable) */ unsigned char name[80]; /* hwdep name */ - enum sndrv_hwdep_iface iface; /* hwdep interface */ + int iface; /* hwdep interface */ unsigned char reserved[64]; /* reserved for future */ }; /* generic DSP loader */ -struct sndrv_hwdep_dsp_status { +struct snd_hwdep_dsp_status { unsigned int version; /* R: driver-specific version */ unsigned char id[32]; /* R: driver-specific ID string */ unsigned int num_dsps; /* R: number of DSP images to transfer */ @@ -116,7 +116,7 @@ struct sndrv_hwdep_dsp_status { unsigned char reserved[16]; /* reserved for future use */ }; -struct sndrv_hwdep_dsp_image { +struct snd_hwdep_dsp_image { unsigned int index; /* W: DSP index */ unsigned char name[64]; /* W: ID (e.g. file name) */ unsigned char __user *image; /* W: binary image */ @@ -126,9 +126,9 @@ struct sndrv_hwdep_dsp_image { enum { SNDRV_HWDEP_IOCTL_PVERSION = _IOR ('H', 0x00, int), - SNDRV_HWDEP_IOCTL_INFO = _IOR ('H', 0x01, struct sndrv_hwdep_info), - SNDRV_HWDEP_IOCTL_DSP_STATUS = _IOR('H', 0x02, struct sndrv_hwdep_dsp_status), - SNDRV_HWDEP_IOCTL_DSP_LOAD = _IOW('H', 0x03, struct sndrv_hwdep_dsp_image) + SNDRV_HWDEP_IOCTL_INFO = _IOR ('H', 0x01, struct snd_hwdep_info), + SNDRV_HWDEP_IOCTL_DSP_STATUS = _IOR('H', 0x02, struct snd_hwdep_dsp_status), + SNDRV_HWDEP_IOCTL_DSP_LOAD = _IOW('H', 0x03, struct snd_hwdep_dsp_image) }; /***************************************************************************** @@ -139,10 +139,10 @@ enum { #define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7) -typedef unsigned long sndrv_pcm_uframes_t; -typedef long sndrv_pcm_sframes_t; +typedef unsigned long snd_pcm_uframes_t; +typedef signed long snd_pcm_sframes_t; -enum sndrv_pcm_class { +enum { SNDRV_PCM_CLASS_GENERIC = 0, /* standard mono or stereo device */ SNDRV_PCM_CLASS_MULTI, /* multichannel device */ SNDRV_PCM_CLASS_MODEM, /* software modem class */ @@ -151,97 +151,94 @@ enum sndrv_pcm_class { SNDRV_PCM_CLASS_LAST = SNDRV_PCM_CLASS_DIGITIZER, }; -enum sndrv_pcm_subclass { +enum { SNDRV_PCM_SUBCLASS_GENERIC_MIX = 0, /* mono or stereo subdevices are mixed together */ SNDRV_PCM_SUBCLASS_MULTI_MIX, /* multichannel subdevices are mixed together */ /* Don't forget to change the following: */ SNDRV_PCM_SUBCLASS_LAST = SNDRV_PCM_SUBCLASS_MULTI_MIX, }; -enum sndrv_pcm_stream { +enum { SNDRV_PCM_STREAM_PLAYBACK = 0, SNDRV_PCM_STREAM_CAPTURE, SNDRV_PCM_STREAM_LAST = SNDRV_PCM_STREAM_CAPTURE, }; -enum sndrv_pcm_access { - SNDRV_PCM_ACCESS_MMAP_INTERLEAVED = 0, /* interleaved mmap */ - SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED, /* noninterleaved mmap */ - SNDRV_PCM_ACCESS_MMAP_COMPLEX, /* complex mmap */ - SNDRV_PCM_ACCESS_RW_INTERLEAVED, /* readi/writei */ - SNDRV_PCM_ACCESS_RW_NONINTERLEAVED, /* readn/writen */ - SNDRV_PCM_ACCESS_LAST = SNDRV_PCM_ACCESS_RW_NONINTERLEAVED, -}; - -enum sndrv_pcm_format { - SNDRV_PCM_FORMAT_S8 = 0, - SNDRV_PCM_FORMAT_U8, - SNDRV_PCM_FORMAT_S16_LE, - SNDRV_PCM_FORMAT_S16_BE, - SNDRV_PCM_FORMAT_U16_LE, - SNDRV_PCM_FORMAT_U16_BE, - SNDRV_PCM_FORMAT_S24_LE, /* low three bytes */ - SNDRV_PCM_FORMAT_S24_BE, /* low three bytes */ - SNDRV_PCM_FORMAT_U24_LE, /* low three bytes */ - SNDRV_PCM_FORMAT_U24_BE, /* low three bytes */ - SNDRV_PCM_FORMAT_S32_LE, - SNDRV_PCM_FORMAT_S32_BE, - SNDRV_PCM_FORMAT_U32_LE, - SNDRV_PCM_FORMAT_U32_BE, - SNDRV_PCM_FORMAT_FLOAT_LE, /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */ - SNDRV_PCM_FORMAT_FLOAT_BE, /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */ - SNDRV_PCM_FORMAT_FLOAT64_LE, /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */ - SNDRV_PCM_FORMAT_FLOAT64_BE, /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */ - SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE, /* IEC-958 subframe, Little Endian */ - SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE, /* IEC-958 subframe, Big Endian */ - SNDRV_PCM_FORMAT_MU_LAW, - SNDRV_PCM_FORMAT_A_LAW, - SNDRV_PCM_FORMAT_IMA_ADPCM, - SNDRV_PCM_FORMAT_MPEG, - SNDRV_PCM_FORMAT_GSM, - SNDRV_PCM_FORMAT_SPECIAL = 31, - SNDRV_PCM_FORMAT_S24_3LE = 32, /* in three bytes */ - SNDRV_PCM_FORMAT_S24_3BE, /* in three bytes */ - SNDRV_PCM_FORMAT_U24_3LE, /* in three bytes */ - SNDRV_PCM_FORMAT_U24_3BE, /* in three bytes */ - SNDRV_PCM_FORMAT_S20_3LE, /* in three bytes */ - SNDRV_PCM_FORMAT_S20_3BE, /* in three bytes */ - SNDRV_PCM_FORMAT_U20_3LE, /* in three bytes */ - SNDRV_PCM_FORMAT_U20_3BE, /* in three bytes */ - SNDRV_PCM_FORMAT_S18_3LE, /* in three bytes */ - SNDRV_PCM_FORMAT_S18_3BE, /* in three bytes */ - SNDRV_PCM_FORMAT_U18_3LE, /* in three bytes */ - SNDRV_PCM_FORMAT_U18_3BE, /* in three bytes */ - SNDRV_PCM_FORMAT_LAST = SNDRV_PCM_FORMAT_U18_3BE, +typedef int __bitwise snd_pcm_access_t; +#define SNDRV_PCM_ACCESS_MMAP_INTERLEAVED ((__force snd_pcm_access_t) 0) /* interleaved mmap */ +#define SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED ((__force snd_pcm_access_t) 1) /* noninterleaved mmap */ +#define SNDRV_PCM_ACCESS_MMAP_COMPLEX ((__force snd_pcm_access_t) 2) /* complex mmap */ +#define SNDRV_PCM_ACCESS_RW_INTERLEAVED ((__force snd_pcm_access_t) 3) /* readi/writei */ +#define SNDRV_PCM_ACCESS_RW_NONINTERLEAVED ((__force snd_pcm_access_t) 4) /* readn/writen */ +#define SNDRV_PCM_ACCESS_LAST SNDRV_PCM_ACCESS_RW_NONINTERLEAVED + +typedef int __bitwise snd_pcm_format_t; +#define SNDRV_PCM_FORMAT_S8 ((__force snd_pcm_format_t) 0) +#define SNDRV_PCM_FORMAT_U8 ((__force snd_pcm_format_t) 1) +#define SNDRV_PCM_FORMAT_S16_LE ((__force snd_pcm_format_t) 2) +#define SNDRV_PCM_FORMAT_S16_BE ((__force snd_pcm_format_t) 3) +#define SNDRV_PCM_FORMAT_U16_LE ((__force snd_pcm_format_t) 4) +#define SNDRV_PCM_FORMAT_U16_BE ((__force snd_pcm_format_t) 5) +#define SNDRV_PCM_FORMAT_S24_LE ((__force snd_pcm_format_t) 6) /* low three bytes */ +#define SNDRV_PCM_FORMAT_S24_BE ((__force snd_pcm_format_t) 7) /* low three bytes */ +#define SNDRV_PCM_FORMAT_U24_LE ((__force snd_pcm_format_t) 8) /* low three bytes */ +#define SNDRV_PCM_FORMAT_U24_BE ((__force snd_pcm_format_t) 9) /* low three bytes */ +#define SNDRV_PCM_FORMAT_S32_LE ((__force snd_pcm_format_t) 10) +#define SNDRV_PCM_FORMAT_S32_BE ((__force snd_pcm_format_t) 11) +#define SNDRV_PCM_FORMAT_U32_LE ((__force snd_pcm_format_t) 12) +#define SNDRV_PCM_FORMAT_U32_BE ((__force snd_pcm_format_t) 13) +#define SNDRV_PCM_FORMAT_FLOAT_LE ((__force snd_pcm_format_t) 14) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */ +#define SNDRV_PCM_FORMAT_FLOAT_BE ((__force snd_pcm_format_t) 15) /* 4-byte float, IEEE-754 32-bit, range -1.0 to 1.0 */ +#define SNDRV_PCM_FORMAT_FLOAT64_LE ((__force snd_pcm_format_t) 16) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */ +#define SNDRV_PCM_FORMAT_FLOAT64_BE ((__force snd_pcm_format_t) 17) /* 8-byte float, IEEE-754 64-bit, range -1.0 to 1.0 */ +#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE ((__force snd_pcm_format_t) 18) /* IEC-958 subframe, Little Endian */ +#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE ((__force snd_pcm_format_t) 19) /* IEC-958 subframe, Big Endian */ +#define SNDRV_PCM_FORMAT_MU_LAW ((__force snd_pcm_format_t) 20) +#define SNDRV_PCM_FORMAT_A_LAW ((__force snd_pcm_format_t) 21) +#define SNDRV_PCM_FORMAT_IMA_ADPCM ((__force snd_pcm_format_t) 22) +#define SNDRV_PCM_FORMAT_MPEG ((__force snd_pcm_format_t) 23) +#define SNDRV_PCM_FORMAT_GSM ((__force snd_pcm_format_t) 24) +#define SNDRV_PCM_FORMAT_SPECIAL ((__force snd_pcm_format_t) 31) +#define SNDRV_PCM_FORMAT_S24_3LE ((__force snd_pcm_format_t) 32) /* in three bytes */ +#define SNDRV_PCM_FORMAT_S24_3BE ((__force snd_pcm_format_t) 33) /* in three bytes */ +#define SNDRV_PCM_FORMAT_U24_3LE ((__force snd_pcm_format_t) 34) /* in three bytes */ +#define SNDRV_PCM_FORMAT_U24_3BE ((__force snd_pcm_format_t) 35) /* in three bytes */ +#define SNDRV_PCM_FORMAT_S20_3LE ((__force snd_pcm_format_t) 36) /* in three bytes */ +#define SNDRV_PCM_FORMAT_S20_3BE ((__force snd_pcm_format_t) 37) /* in three bytes */ +#define SNDRV_PCM_FORMAT_U20_3LE ((__force snd_pcm_format_t) 38) /* in three bytes */ +#define SNDRV_PCM_FORMAT_U20_3BE ((__force snd_pcm_format_t) 39) /* in three bytes */ +#define SNDRV_PCM_FORMAT_S18_3LE ((__force snd_pcm_format_t) 40) /* in three bytes */ +#define SNDRV_PCM_FORMAT_S18_3BE ((__force snd_pcm_format_t) 41) /* in three bytes */ +#define SNDRV_PCM_FORMAT_U18_3LE ((__force snd_pcm_format_t) 42) /* in three bytes */ +#define SNDRV_PCM_FORMAT_U18_3BE ((__force snd_pcm_format_t) 43) /* in three bytes */ +#define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_U18_3BE #ifdef SNDRV_LITTLE_ENDIAN - SNDRV_PCM_FORMAT_S16 = SNDRV_PCM_FORMAT_S16_LE, - SNDRV_PCM_FORMAT_U16 = SNDRV_PCM_FORMAT_U16_LE, - SNDRV_PCM_FORMAT_S24 = SNDRV_PCM_FORMAT_S24_LE, - SNDRV_PCM_FORMAT_U24 = SNDRV_PCM_FORMAT_U24_LE, - SNDRV_PCM_FORMAT_S32 = SNDRV_PCM_FORMAT_S32_LE, - SNDRV_PCM_FORMAT_U32 = SNDRV_PCM_FORMAT_U32_LE, - SNDRV_PCM_FORMAT_FLOAT = SNDRV_PCM_FORMAT_FLOAT_LE, - SNDRV_PCM_FORMAT_FLOAT64 = SNDRV_PCM_FORMAT_FLOAT64_LE, - SNDRV_PCM_FORMAT_IEC958_SUBFRAME = SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE, +#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE +#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_LE +#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_LE +#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_LE +#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_LE +#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_LE +#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_LE +#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_LE +#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE #endif #ifdef SNDRV_BIG_ENDIAN - SNDRV_PCM_FORMAT_S16 = SNDRV_PCM_FORMAT_S16_BE, - SNDRV_PCM_FORMAT_U16 = SNDRV_PCM_FORMAT_U16_BE, - SNDRV_PCM_FORMAT_S24 = SNDRV_PCM_FORMAT_S24_BE, - SNDRV_PCM_FORMAT_U24 = SNDRV_PCM_FORMAT_U24_BE, - SNDRV_PCM_FORMAT_S32 = SNDRV_PCM_FORMAT_S32_BE, - SNDRV_PCM_FORMAT_U32 = SNDRV_PCM_FORMAT_U32_BE, - SNDRV_PCM_FORMAT_FLOAT = SNDRV_PCM_FORMAT_FLOAT_BE, - SNDRV_PCM_FORMAT_FLOAT64 = SNDRV_PCM_FORMAT_FLOAT64_BE, - SNDRV_PCM_FORMAT_IEC958_SUBFRAME = SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE, +#define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_BE +#define SNDRV_PCM_FORMAT_U16 SNDRV_PCM_FORMAT_U16_BE +#define SNDRV_PCM_FORMAT_S24 SNDRV_PCM_FORMAT_S24_BE +#define SNDRV_PCM_FORMAT_U24 SNDRV_PCM_FORMAT_U24_BE +#define SNDRV_PCM_FORMAT_S32 SNDRV_PCM_FORMAT_S32_BE +#define SNDRV_PCM_FORMAT_U32 SNDRV_PCM_FORMAT_U32_BE +#define SNDRV_PCM_FORMAT_FLOAT SNDRV_PCM_FORMAT_FLOAT_BE +#define SNDRV_PCM_FORMAT_FLOAT64 SNDRV_PCM_FORMAT_FLOAT64_BE +#define SNDRV_PCM_FORMAT_IEC958_SUBFRAME SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE #endif -}; -enum sndrv_pcm_subformat { - SNDRV_PCM_SUBFORMAT_STD = 0, - SNDRV_PCM_SUBFORMAT_LAST = SNDRV_PCM_SUBFORMAT_STD, -}; +typedef int __bitwise snd_pcm_subformat_t; +#define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0) +#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD #define SNDRV_PCM_INFO_MMAP 0x00000001 /* hardware supports mmap */ #define SNDRV_PCM_INFO_MMAP_VALID 0x00000002 /* period data are valid during transfer */ @@ -258,18 +255,17 @@ enum sndrv_pcm_subformat { #define SNDRV_PCM_INFO_JOINT_DUPLEX 0x00200000 /* playback and capture stream are somewhat correlated */ #define SNDRV_PCM_INFO_SYNC_START 0x00400000 /* pcm support some kind of sync go */ -enum sndrv_pcm_state { - SNDRV_PCM_STATE_OPEN = 0, /* stream is open */ - SNDRV_PCM_STATE_SETUP, /* stream has a setup */ - SNDRV_PCM_STATE_PREPARED, /* stream is ready to start */ - SNDRV_PCM_STATE_RUNNING, /* stream is running */ - SNDRV_PCM_STATE_XRUN, /* stream reached an xrun */ - SNDRV_PCM_STATE_DRAINING, /* stream is draining */ - SNDRV_PCM_STATE_PAUSED, /* stream is paused */ - SNDRV_PCM_STATE_SUSPENDED, /* hardware is suspended */ - SNDRV_PCM_STATE_DISCONNECTED, /* hardware is disconnected */ - SNDRV_PCM_STATE_LAST = SNDRV_PCM_STATE_DISCONNECTED, -}; +typedef int __bitwise snd_pcm_state_t; +#define SNDRV_PCM_STATE_OPEN ((__force snd_pcm_state_t) 0) /* stream is open */ +#define SNDRV_PCM_STATE_SETUP ((__force snd_pcm_state_t) 1) /* stream has a setup */ +#define SNDRV_PCM_STATE_PREPARED ((__force snd_pcm_state_t) 2) /* stream is ready to start */ +#define SNDRV_PCM_STATE_RUNNING ((__force snd_pcm_state_t) 3) /* stream is running */ +#define SNDRV_PCM_STATE_XRUN ((__force snd_pcm_state_t) 4) /* stream reached an xrun */ +#define SNDRV_PCM_STATE_DRAINING ((__force snd_pcm_state_t) 5) /* stream is draining */ +#define SNDRV_PCM_STATE_PAUSED ((__force snd_pcm_state_t) 6) /* stream is paused */ +#define SNDRV_PCM_STATE_SUSPENDED ((__force snd_pcm_state_t) 7) /* hardware is suspended */ +#define SNDRV_PCM_STATE_DISCONNECTED ((__force snd_pcm_state_t) 8) /* hardware is disconnected */ +#define SNDRV_PCM_STATE_LAST SNDRV_PCM_STATE_DISCONNECTED enum { SNDRV_PCM_MMAP_OFFSET_DATA = 0x00000000, @@ -277,55 +273,53 @@ enum { SNDRV_PCM_MMAP_OFFSET_CONTROL = 0x81000000, }; -union sndrv_pcm_sync_id { +union snd_pcm_sync_id { unsigned char id[16]; unsigned short id16[8]; unsigned int id32[4]; }; -struct sndrv_pcm_info { +struct snd_pcm_info { unsigned int device; /* RO/WR (control): device number */ unsigned int subdevice; /* RO/WR (control): subdevice number */ - enum sndrv_pcm_stream stream; /* RO/WR (control): stream number */ + int stream; /* RO/WR (control): stream direction */ int card; /* R: card number */ unsigned char id[64]; /* ID (user selectable) */ unsigned char name[80]; /* name of this device */ unsigned char subname[32]; /* subdevice name */ - enum sndrv_pcm_class dev_class; /* SNDRV_PCM_CLASS_* */ - enum sndrv_pcm_subclass dev_subclass; /* SNDRV_PCM_SUBCLASS_* */ + int dev_class; /* SNDRV_PCM_CLASS_* */ + int dev_subclass; /* SNDRV_PCM_SUBCLASS_* */ unsigned int subdevices_count; unsigned int subdevices_avail; - union sndrv_pcm_sync_id sync; /* hardware synchronization ID */ + union snd_pcm_sync_id sync; /* hardware synchronization ID */ unsigned char reserved[64]; /* reserved for future... */ }; -enum sndrv_pcm_hw_param { - SNDRV_PCM_HW_PARAM_ACCESS = 0, /* Access type */ - SNDRV_PCM_HW_PARAM_FIRST_MASK = SNDRV_PCM_HW_PARAM_ACCESS, - SNDRV_PCM_HW_PARAM_FORMAT, /* Format */ - SNDRV_PCM_HW_PARAM_SUBFORMAT, /* Subformat */ - SNDRV_PCM_HW_PARAM_LAST_MASK = SNDRV_PCM_HW_PARAM_SUBFORMAT, - - SNDRV_PCM_HW_PARAM_SAMPLE_BITS = 8, /* Bits per sample */ - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL = SNDRV_PCM_HW_PARAM_SAMPLE_BITS, - SNDRV_PCM_HW_PARAM_FRAME_BITS, /* Bits per frame */ - SNDRV_PCM_HW_PARAM_CHANNELS, /* Channels */ - SNDRV_PCM_HW_PARAM_RATE, /* Approx rate */ - SNDRV_PCM_HW_PARAM_PERIOD_TIME, /* Approx distance between interrupts - in us */ - SNDRV_PCM_HW_PARAM_PERIOD_SIZE, /* Approx frames between interrupts */ - SNDRV_PCM_HW_PARAM_PERIOD_BYTES, /* Approx bytes between interrupts */ - SNDRV_PCM_HW_PARAM_PERIODS, /* Approx interrupts per buffer */ - SNDRV_PCM_HW_PARAM_BUFFER_TIME, /* Approx duration of buffer in us */ - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, /* Size of buffer in frames */ - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, /* Size of buffer in bytes */ - SNDRV_PCM_HW_PARAM_TICK_TIME, /* Approx tick duration in us */ - SNDRV_PCM_HW_PARAM_LAST_INTERVAL = SNDRV_PCM_HW_PARAM_TICK_TIME -}; +typedef int __bitwise snd_pcm_hw_param_t; +#define SNDRV_PCM_HW_PARAM_ACCESS ((__force snd_pcm_hw_param_t) 0) /* Access type */ +#define SNDRV_PCM_HW_PARAM_FORMAT ((__force snd_pcm_hw_param_t) 1) /* Format */ +#define SNDRV_PCM_HW_PARAM_SUBFORMAT ((__force snd_pcm_hw_param_t) 2) /* Subformat */ +#define SNDRV_PCM_HW_PARAM_FIRST_MASK SNDRV_PCM_HW_PARAM_ACCESS +#define SNDRV_PCM_HW_PARAM_LAST_MASK SNDRV_PCM_HW_PARAM_SUBFORMAT + +#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS ((__force snd_pcm_hw_param_t) 8) /* Bits per sample */ +#define SNDRV_PCM_HW_PARAM_FRAME_BITS ((__force snd_pcm_hw_param_t) 9) /* Bits per frame */ +#define SNDRV_PCM_HW_PARAM_CHANNELS ((__force snd_pcm_hw_param_t) 10) /* Channels */ +#define SNDRV_PCM_HW_PARAM_RATE ((__force snd_pcm_hw_param_t) 11) /* Approx rate */ +#define SNDRV_PCM_HW_PARAM_PERIOD_TIME ((__force snd_pcm_hw_param_t) 12) /* Approx distance between interrupts in us */ +#define SNDRV_PCM_HW_PARAM_PERIOD_SIZE ((__force snd_pcm_hw_param_t) 13) /* Approx frames between interrupts */ +#define SNDRV_PCM_HW_PARAM_PERIOD_BYTES ((__force snd_pcm_hw_param_t) 14) /* Approx bytes between interrupts */ +#define SNDRV_PCM_HW_PARAM_PERIODS ((__force snd_pcm_hw_param_t) 15) /* Approx interrupts per buffer */ +#define SNDRV_PCM_HW_PARAM_BUFFER_TIME ((__force snd_pcm_hw_param_t) 16) /* Approx duration of buffer in us */ +#define SNDRV_PCM_HW_PARAM_BUFFER_SIZE ((__force snd_pcm_hw_param_t) 17) /* Size of buffer in frames */ +#define SNDRV_PCM_HW_PARAM_BUFFER_BYTES ((__force snd_pcm_hw_param_t) 18) /* Size of buffer in bytes */ +#define SNDRV_PCM_HW_PARAM_TICK_TIME ((__force snd_pcm_hw_param_t) 19) /* Approx tick duration in us */ +#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL SNDRV_PCM_HW_PARAM_SAMPLE_BITS +#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL SNDRV_PCM_HW_PARAM_TICK_TIME #define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */ -struct sndrv_interval { +struct snd_interval { unsigned int min, max; unsigned int openmin:1, openmax:1, @@ -335,137 +329,137 @@ struct sndrv_interval { #define SNDRV_MASK_MAX 256 -struct sndrv_mask { +struct snd_mask { u_int32_t bits[(SNDRV_MASK_MAX+31)/32]; }; -struct sndrv_pcm_hw_params { +struct snd_pcm_hw_params { unsigned int flags; - struct sndrv_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - + struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; - struct sndrv_mask mres[5]; /* reserved masks */ - struct sndrv_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - + struct snd_mask mres[5]; /* reserved masks */ + struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; - struct sndrv_interval ires[9]; /* reserved intervals */ + struct snd_interval ires[9]; /* reserved intervals */ unsigned int rmask; /* W: requested masks */ unsigned int cmask; /* R: changed masks */ unsigned int info; /* R: Info flags for returned setup */ unsigned int msbits; /* R: used most significant bits */ unsigned int rate_num; /* R: rate numerator */ unsigned int rate_den; /* R: rate denominator */ - sndrv_pcm_uframes_t fifo_size; /* R: chip FIFO size in frames */ + snd_pcm_uframes_t fifo_size; /* R: chip FIFO size in frames */ unsigned char reserved[64]; /* reserved for future */ }; -enum sndrv_pcm_tstamp { +enum { SNDRV_PCM_TSTAMP_NONE = 0, SNDRV_PCM_TSTAMP_MMAP, SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_MMAP, }; -struct sndrv_pcm_sw_params { - enum sndrv_pcm_tstamp tstamp_mode; /* timestamp mode */ +struct snd_pcm_sw_params { + int tstamp_mode; /* timestamp mode */ unsigned int period_step; unsigned int sleep_min; /* min ticks to sleep */ - sndrv_pcm_uframes_t avail_min; /* min avail frames for wakeup */ - sndrv_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */ - sndrv_pcm_uframes_t start_threshold; /* min hw_avail frames for automatic start */ - sndrv_pcm_uframes_t stop_threshold; /* min avail frames for automatic stop */ - sndrv_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */ - sndrv_pcm_uframes_t silence_size; /* silence block size */ - sndrv_pcm_uframes_t boundary; /* pointers wrap point */ + snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */ + snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */ + snd_pcm_uframes_t start_threshold; /* min hw_avail frames for automatic start */ + snd_pcm_uframes_t stop_threshold; /* min avail frames for automatic stop */ + snd_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */ + snd_pcm_uframes_t silence_size; /* silence block size */ + snd_pcm_uframes_t boundary; /* pointers wrap point */ unsigned char reserved[64]; /* reserved for future */ }; -struct sndrv_pcm_channel_info { +struct snd_pcm_channel_info { unsigned int channel; off_t offset; /* mmap offset */ unsigned int first; /* offset to first sample in bits */ unsigned int step; /* samples distance in bits */ }; -struct sndrv_pcm_status { - enum sndrv_pcm_state state; /* stream state */ +struct snd_pcm_status { + snd_pcm_state_t state; /* stream state */ struct timespec trigger_tstamp; /* time when stream was started/stopped/paused */ struct timespec tstamp; /* reference timestamp */ - sndrv_pcm_uframes_t appl_ptr; /* appl ptr */ - sndrv_pcm_uframes_t hw_ptr; /* hw ptr */ - sndrv_pcm_sframes_t delay; /* current delay in frames */ - sndrv_pcm_uframes_t avail; /* number of frames available */ - sndrv_pcm_uframes_t avail_max; /* max frames available on hw since last status */ - sndrv_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */ - enum sndrv_pcm_state suspended_state; /* suspended stream state */ + snd_pcm_uframes_t appl_ptr; /* appl ptr */ + snd_pcm_uframes_t hw_ptr; /* hw ptr */ + snd_pcm_sframes_t delay; /* current delay in frames */ + snd_pcm_uframes_t avail; /* number of frames available */ + snd_pcm_uframes_t avail_max; /* max frames available on hw since last status */ + snd_pcm_uframes_t overrange; /* count of ADC (capture) overrange detections from last status */ + snd_pcm_state_t suspended_state; /* suspended stream state */ unsigned char reserved[60]; /* must be filled with zero */ }; -struct sndrv_pcm_mmap_status { - enum sndrv_pcm_state state; /* RO: state - SNDRV_PCM_STATE_XXXX */ +struct snd_pcm_mmap_status { + snd_pcm_state_t state; /* RO: state - SNDRV_PCM_STATE_XXXX */ int pad1; /* Needed for 64 bit alignment */ - sndrv_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */ + snd_pcm_uframes_t hw_ptr; /* RO: hw ptr (0...boundary-1) */ struct timespec tstamp; /* Timestamp */ - enum sndrv_pcm_state suspended_state; /* RO: suspended stream state */ + snd_pcm_state_t suspended_state; /* RO: suspended stream state */ }; -struct sndrv_pcm_mmap_control { - sndrv_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */ - sndrv_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */ +struct snd_pcm_mmap_control { + snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */ + snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */ }; #define SNDRV_PCM_SYNC_PTR_HWSYNC (1<<0) /* execute hwsync */ #define SNDRV_PCM_SYNC_PTR_APPL (1<<1) /* get appl_ptr from driver (r/w op) */ #define SNDRV_PCM_SYNC_PTR_AVAIL_MIN (1<<2) /* get avail_min from driver */ -struct sndrv_pcm_sync_ptr { +struct snd_pcm_sync_ptr { unsigned int flags; union { - struct sndrv_pcm_mmap_status status; + struct snd_pcm_mmap_status status; unsigned char reserved[64]; } s; union { - struct sndrv_pcm_mmap_control control; + struct snd_pcm_mmap_control control; unsigned char reserved[64]; } c; }; -struct sndrv_xferi { - sndrv_pcm_sframes_t result; +struct snd_xferi { + snd_pcm_sframes_t result; void __user *buf; - sndrv_pcm_uframes_t frames; + snd_pcm_uframes_t frames; }; -struct sndrv_xfern { - sndrv_pcm_sframes_t result; +struct snd_xfern { + snd_pcm_sframes_t result; void __user * __user *bufs; - sndrv_pcm_uframes_t frames; + snd_pcm_uframes_t frames; }; enum { SNDRV_PCM_IOCTL_PVERSION = _IOR('A', 0x00, int), - SNDRV_PCM_IOCTL_INFO = _IOR('A', 0x01, struct sndrv_pcm_info), + SNDRV_PCM_IOCTL_INFO = _IOR('A', 0x01, struct snd_pcm_info), SNDRV_PCM_IOCTL_TSTAMP = _IOW('A', 0x02, int), - SNDRV_PCM_IOCTL_HW_REFINE = _IOWR('A', 0x10, struct sndrv_pcm_hw_params), - SNDRV_PCM_IOCTL_HW_PARAMS = _IOWR('A', 0x11, struct sndrv_pcm_hw_params), + SNDRV_PCM_IOCTL_HW_REFINE = _IOWR('A', 0x10, struct snd_pcm_hw_params), + SNDRV_PCM_IOCTL_HW_PARAMS = _IOWR('A', 0x11, struct snd_pcm_hw_params), SNDRV_PCM_IOCTL_HW_FREE = _IO('A', 0x12), - SNDRV_PCM_IOCTL_SW_PARAMS = _IOWR('A', 0x13, struct sndrv_pcm_sw_params), - SNDRV_PCM_IOCTL_STATUS = _IOR('A', 0x20, struct sndrv_pcm_status), - SNDRV_PCM_IOCTL_DELAY = _IOR('A', 0x21, sndrv_pcm_sframes_t), + SNDRV_PCM_IOCTL_SW_PARAMS = _IOWR('A', 0x13, struct snd_pcm_sw_params), + SNDRV_PCM_IOCTL_STATUS = _IOR('A', 0x20, struct snd_pcm_status), + SNDRV_PCM_IOCTL_DELAY = _IOR('A', 0x21, snd_pcm_sframes_t), SNDRV_PCM_IOCTL_HWSYNC = _IO('A', 0x22), - SNDRV_PCM_IOCTL_SYNC_PTR = _IOWR('A', 0x23, struct sndrv_pcm_sync_ptr), - SNDRV_PCM_IOCTL_CHANNEL_INFO = _IOR('A', 0x32, struct sndrv_pcm_channel_info), + SNDRV_PCM_IOCTL_SYNC_PTR = _IOWR('A', 0x23, struct snd_pcm_sync_ptr), + SNDRV_PCM_IOCTL_CHANNEL_INFO = _IOR('A', 0x32, struct snd_pcm_channel_info), SNDRV_PCM_IOCTL_PREPARE = _IO('A', 0x40), SNDRV_PCM_IOCTL_RESET = _IO('A', 0x41), SNDRV_PCM_IOCTL_START = _IO('A', 0x42), SNDRV_PCM_IOCTL_DROP = _IO('A', 0x43), SNDRV_PCM_IOCTL_DRAIN = _IO('A', 0x44), SNDRV_PCM_IOCTL_PAUSE = _IOW('A', 0x45, int), - SNDRV_PCM_IOCTL_REWIND = _IOW('A', 0x46, sndrv_pcm_uframes_t), + SNDRV_PCM_IOCTL_REWIND = _IOW('A', 0x46, snd_pcm_uframes_t), SNDRV_PCM_IOCTL_RESUME = _IO('A', 0x47), SNDRV_PCM_IOCTL_XRUN = _IO('A', 0x48), - SNDRV_PCM_IOCTL_FORWARD = _IOW('A', 0x49, sndrv_pcm_uframes_t), - SNDRV_PCM_IOCTL_WRITEI_FRAMES = _IOW('A', 0x50, struct sndrv_xferi), - SNDRV_PCM_IOCTL_READI_FRAMES = _IOR('A', 0x51, struct sndrv_xferi), - SNDRV_PCM_IOCTL_WRITEN_FRAMES = _IOW('A', 0x52, struct sndrv_xfern), - SNDRV_PCM_IOCTL_READN_FRAMES = _IOR('A', 0x53, struct sndrv_xfern), + SNDRV_PCM_IOCTL_FORWARD = _IOW('A', 0x49, snd_pcm_uframes_t), + SNDRV_PCM_IOCTL_WRITEI_FRAMES = _IOW('A', 0x50, struct snd_xferi), + SNDRV_PCM_IOCTL_READI_FRAMES = _IOR('A', 0x51, struct snd_xferi), + SNDRV_PCM_IOCTL_WRITEN_FRAMES = _IOW('A', 0x52, struct snd_xfern), + SNDRV_PCM_IOCTL_READN_FRAMES = _IOR('A', 0x53, struct snd_xfern), SNDRV_PCM_IOCTL_LINK = _IOW('A', 0x60, int), SNDRV_PCM_IOCTL_UNLINK = _IO('A', 0x61), }; @@ -485,7 +479,7 @@ enum { #define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 0) -enum sndrv_rawmidi_stream { +enum { SNDRV_RAWMIDI_STREAM_OUTPUT = 0, SNDRV_RAWMIDI_STREAM_INPUT, SNDRV_RAWMIDI_STREAM_LAST = SNDRV_RAWMIDI_STREAM_INPUT, @@ -495,10 +489,10 @@ enum sndrv_rawmidi_stream { #define SNDRV_RAWMIDI_INFO_INPUT 0x00000002 #define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004 -struct sndrv_rawmidi_info { +struct snd_rawmidi_info { unsigned int device; /* RO/WR (control): device number */ unsigned int subdevice; /* RO/WR (control): subdevice number */ - enum sndrv_rawmidi_stream stream; /* WR: stream */ + int stream; /* WR: stream */ int card; /* R: card number */ unsigned int flags; /* SNDRV_RAWMIDI_INFO_XXXX */ unsigned char id[64]; /* ID (user selectable) */ @@ -509,16 +503,16 @@ struct sndrv_rawmidi_info { unsigned char reserved[64]; /* reserved for future use */ }; -struct sndrv_rawmidi_params { - enum sndrv_rawmidi_stream stream; +struct snd_rawmidi_params { + int stream; size_t buffer_size; /* queue size in bytes */ size_t avail_min; /* minimum avail bytes for wakeup */ unsigned int no_active_sensing: 1; /* do not send active sensing byte in close() */ unsigned char reserved[16]; /* reserved for future use */ }; -struct sndrv_rawmidi_status { - enum sndrv_rawmidi_stream stream; +struct snd_rawmidi_status { + int stream; struct timespec tstamp; /* Timestamp */ size_t avail; /* available bytes */ size_t xruns; /* count of overruns since last status (in bytes) */ @@ -527,9 +521,9 @@ struct sndrv_rawmidi_status { enum { SNDRV_RAWMIDI_IOCTL_PVERSION = _IOR('W', 0x00, int), - SNDRV_RAWMIDI_IOCTL_INFO = _IOR('W', 0x01, struct sndrv_rawmidi_info), - SNDRV_RAWMIDI_IOCTL_PARAMS = _IOWR('W', 0x10, struct sndrv_rawmidi_params), - SNDRV_RAWMIDI_IOCTL_STATUS = _IOWR('W', 0x20, struct sndrv_rawmidi_status), + SNDRV_RAWMIDI_IOCTL_INFO = _IOR('W', 0x01, struct snd_rawmidi_info), + SNDRV_RAWMIDI_IOCTL_PARAMS = _IOWR('W', 0x10, struct snd_rawmidi_params), + SNDRV_RAWMIDI_IOCTL_STATUS = _IOWR('W', 0x20, struct snd_rawmidi_status), SNDRV_RAWMIDI_IOCTL_DROP = _IOW('W', 0x30, int), SNDRV_RAWMIDI_IOCTL_DRAIN = _IOW('W', 0x31, int), }; @@ -540,7 +534,7 @@ enum { #define SNDRV_TIMER_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 5) -enum sndrv_timer_class { +enum { SNDRV_TIMER_CLASS_NONE = -1, SNDRV_TIMER_CLASS_SLAVE = 0, SNDRV_TIMER_CLASS_GLOBAL, @@ -550,7 +544,7 @@ enum sndrv_timer_class { }; /* slave timer classes */ -enum sndrv_timer_slave_class { +enum { SNDRV_TIMER_SCLASS_NONE = 0, SNDRV_TIMER_SCLASS_APPLICATION, SNDRV_TIMER_SCLASS_SEQUENCER, /* alias */ @@ -566,16 +560,16 @@ enum sndrv_timer_slave_class { /* info flags */ #define SNDRV_TIMER_FLG_SLAVE (1<<0) /* cannot be controlled */ -struct sndrv_timer_id { - enum sndrv_timer_class dev_class; - enum sndrv_timer_slave_class dev_sclass; +struct snd_timer_id { + int dev_class; + int dev_sclass; int card; int device; int subdevice; }; -struct sndrv_timer_ginfo { - struct sndrv_timer_id tid; /* requested timer ID */ +struct snd_timer_ginfo { + struct snd_timer_id tid; /* requested timer ID */ unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */ int card; /* card number */ unsigned char id[64]; /* timer identification */ @@ -588,27 +582,27 @@ struct sndrv_timer_ginfo { unsigned char reserved[32]; }; -struct sndrv_timer_gparams { - struct sndrv_timer_id tid; /* requested timer ID */ +struct snd_timer_gparams { + struct snd_timer_id tid; /* requested timer ID */ unsigned long period_num; /* requested precise period duration (in seconds) - numerator */ unsigned long period_den; /* requested precise period duration (in seconds) - denominator */ unsigned char reserved[32]; }; -struct sndrv_timer_gstatus { - struct sndrv_timer_id tid; /* requested timer ID */ +struct snd_timer_gstatus { + struct snd_timer_id tid; /* requested timer ID */ unsigned long resolution; /* current period resolution in ns */ unsigned long resolution_num; /* precise current period resolution (in seconds) - numerator */ unsigned long resolution_den; /* precise current period resolution (in seconds) - denominator */ unsigned char reserved[32]; }; -struct sndrv_timer_select { - struct sndrv_timer_id id; /* bind to timer ID */ +struct snd_timer_select { + struct snd_timer_id id; /* bind to timer ID */ unsigned char reserved[32]; /* reserved */ }; -struct sndrv_timer_info { +struct snd_timer_info { unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */ int card; /* card number */ unsigned char id[64]; /* timer identificator */ @@ -622,7 +616,7 @@ struct sndrv_timer_info { #define SNDRV_TIMER_PSFLG_EXCLUSIVE (1<<1) /* exclusive use, precise start/stop/pause/continue */ #define SNDRV_TIMER_PSFLG_EARLY_EVENT (1<<2) /* write early event to the poll queue */ -struct sndrv_timer_params { +struct snd_timer_params { unsigned int flags; /* flags - SNDRV_MIXER_PSFLG_* */ unsigned int ticks; /* requested resolution in ticks */ unsigned int queue_size; /* total size of queue (32-1024) */ @@ -631,7 +625,7 @@ struct sndrv_timer_params { unsigned char reserved[60]; /* reserved */ }; -struct sndrv_timer_status { +struct snd_timer_status { struct timespec tstamp; /* Timestamp - last update */ unsigned int resolution; /* current period resolution in ns */ unsigned int lost; /* counter of master tick lost */ @@ -642,15 +636,15 @@ struct sndrv_timer_status { enum { SNDRV_TIMER_IOCTL_PVERSION = _IOR('T', 0x00, int), - SNDRV_TIMER_IOCTL_NEXT_DEVICE = _IOWR('T', 0x01, struct sndrv_timer_id), + SNDRV_TIMER_IOCTL_NEXT_DEVICE = _IOWR('T', 0x01, struct snd_timer_id), SNDRV_TIMER_IOCTL_TREAD = _IOW('T', 0x02, int), - SNDRV_TIMER_IOCTL_GINFO = _IOWR('T', 0x03, struct sndrv_timer_ginfo), - SNDRV_TIMER_IOCTL_GPARAMS = _IOW('T', 0x04, struct sndrv_timer_gparams), - SNDRV_TIMER_IOCTL_GSTATUS = _IOWR('T', 0x05, struct sndrv_timer_gstatus), - SNDRV_TIMER_IOCTL_SELECT = _IOW('T', 0x10, struct sndrv_timer_select), - SNDRV_TIMER_IOCTL_INFO = _IOR('T', 0x11, struct sndrv_timer_info), - SNDRV_TIMER_IOCTL_PARAMS = _IOW('T', 0x12, struct sndrv_timer_params), - SNDRV_TIMER_IOCTL_STATUS = _IOR('T', 0x14, struct sndrv_timer_status), + SNDRV_TIMER_IOCTL_GINFO = _IOWR('T', 0x03, struct snd_timer_ginfo), + SNDRV_TIMER_IOCTL_GPARAMS = _IOW('T', 0x04, struct snd_timer_gparams), + SNDRV_TIMER_IOCTL_GSTATUS = _IOWR('T', 0x05, struct snd_timer_gstatus), + SNDRV_TIMER_IOCTL_SELECT = _IOW('T', 0x10, struct snd_timer_select), + SNDRV_TIMER_IOCTL_INFO = _IOR('T', 0x11, struct snd_timer_info), + SNDRV_TIMER_IOCTL_PARAMS = _IOW('T', 0x12, struct snd_timer_params), + SNDRV_TIMER_IOCTL_STATUS = _IOR('T', 0x14, struct snd_timer_status), /* The following four ioctls are changed since 1.0.9 due to confliction */ SNDRV_TIMER_IOCTL_START = _IO('T', 0xa0), SNDRV_TIMER_IOCTL_STOP = _IO('T', 0xa1), @@ -658,12 +652,12 @@ enum { SNDRV_TIMER_IOCTL_PAUSE = _IO('T', 0xa3), }; -struct sndrv_timer_read { +struct snd_timer_read { unsigned int resolution; unsigned int ticks; }; -enum sndrv_timer_event { +enum { SNDRV_TIMER_EVENT_RESOLUTION = 0, /* val = resolution in ns */ SNDRV_TIMER_EVENT_TICK, /* val = ticks */ SNDRV_TIMER_EVENT_START, /* val = resolution in ns */ @@ -682,8 +676,8 @@ enum sndrv_timer_event { SNDRV_TIMER_EVENT_MRESUME = SNDRV_TIMER_EVENT_RESUME + 10, }; -struct sndrv_timer_tread { - enum sndrv_timer_event event; +struct snd_timer_tread { + int event; struct timespec tstamp; unsigned int val; }; @@ -696,7 +690,7 @@ struct sndrv_timer_tread { #define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 3) -struct sndrv_ctl_card_info { +struct snd_ctl_card_info { int card; /* card number */ int pad; /* reserved for future (was type) */ unsigned char id[16]; /* ID of card (user selectable) */ @@ -709,27 +703,25 @@ struct sndrv_ctl_card_info { unsigned char reserved[48]; /* reserved for future */ }; -enum sndrv_ctl_elem_type { - SNDRV_CTL_ELEM_TYPE_NONE = 0, /* invalid */ - SNDRV_CTL_ELEM_TYPE_BOOLEAN, /* boolean type */ - SNDRV_CTL_ELEM_TYPE_INTEGER, /* integer type */ - SNDRV_CTL_ELEM_TYPE_ENUMERATED, /* enumerated type */ - SNDRV_CTL_ELEM_TYPE_BYTES, /* byte array */ - SNDRV_CTL_ELEM_TYPE_IEC958, /* IEC958 (S/PDIF) setup */ - SNDRV_CTL_ELEM_TYPE_INTEGER64, /* 64-bit integer type */ - SNDRV_CTL_ELEM_TYPE_LAST = SNDRV_CTL_ELEM_TYPE_INTEGER64, -}; - -enum sndrv_ctl_elem_iface { - SNDRV_CTL_ELEM_IFACE_CARD = 0, /* global control */ - SNDRV_CTL_ELEM_IFACE_HWDEP, /* hardware dependent device */ - SNDRV_CTL_ELEM_IFACE_MIXER, /* virtual mixer device */ - SNDRV_CTL_ELEM_IFACE_PCM, /* PCM device */ - SNDRV_CTL_ELEM_IFACE_RAWMIDI, /* RawMidi device */ - SNDRV_CTL_ELEM_IFACE_TIMER, /* timer device */ - SNDRV_CTL_ELEM_IFACE_SEQUENCER, /* sequencer client */ - SNDRV_CTL_ELEM_IFACE_LAST = SNDRV_CTL_ELEM_IFACE_SEQUENCER, -}; +typedef int __bitwise snd_ctl_elem_type_t; +#define SNDRV_CTL_ELEM_TYPE_NONE ((__force snd_ctl_elem_type_t) 0) /* invalid */ +#define SNDRV_CTL_ELEM_TYPE_BOOLEAN ((__force snd_ctl_elem_type_t) 1) /* boolean type */ +#define SNDRV_CTL_ELEM_TYPE_INTEGER ((__force snd_ctl_elem_type_t) 2) /* integer type */ +#define SNDRV_CTL_ELEM_TYPE_ENUMERATED ((__force snd_ctl_elem_type_t) 3) /* enumerated type */ +#define SNDRV_CTL_ELEM_TYPE_BYTES ((__force snd_ctl_elem_type_t) 4) /* byte array */ +#define SNDRV_CTL_ELEM_TYPE_IEC958 ((__force snd_ctl_elem_type_t) 5) /* IEC958 (S/PDIF) setup */ +#define SNDRV_CTL_ELEM_TYPE_INTEGER64 ((__force snd_ctl_elem_type_t) 6) /* 64-bit integer type */ +#define SNDRV_CTL_ELEM_TYPE_LAST SNDRV_CTL_ELEM_TYPE_INTEGER64 + +typedef int __bitwise snd_ctl_elem_iface_t; +#define SNDRV_CTL_ELEM_IFACE_CARD ((__force snd_ctl_elem_iface_t) 0) /* global control */ +#define SNDRV_CTL_ELEM_IFACE_HWDEP ((__force snd_ctl_elem_iface_t) 1) /* hardware dependent device */ +#define SNDRV_CTL_ELEM_IFACE_MIXER ((__force snd_ctl_elem_iface_t) 2) /* virtual mixer device */ +#define SNDRV_CTL_ELEM_IFACE_PCM ((__force snd_ctl_elem_iface_t) 3) /* PCM device */ +#define SNDRV_CTL_ELEM_IFACE_RAWMIDI ((__force snd_ctl_elem_iface_t) 4) /* RawMidi device */ +#define SNDRV_CTL_ELEM_IFACE_TIMER ((__force snd_ctl_elem_iface_t) 5) /* timer device */ +#define SNDRV_CTL_ELEM_IFACE_SEQUENCER ((__force snd_ctl_elem_iface_t) 6) /* sequencer client */ +#define SNDRV_CTL_ELEM_IFACE_LAST SNDRV_CTL_ELEM_IFACE_SEQUENCER #define SNDRV_CTL_ELEM_ACCESS_READ (1<<0) #define SNDRV_CTL_ELEM_ACCESS_WRITE (1<<1) @@ -751,27 +743,27 @@ enum sndrv_ctl_elem_iface { #define SNDRV_CTL_POWER_D3hot (SNDRV_CTL_POWER_D3|0x0000) /* Off, with power */ #define SNDRV_CTL_POWER_D3cold (SNDRV_CTL_POWER_D3|0x0001) /* Off, without power */ -struct sndrv_ctl_elem_id { +struct snd_ctl_elem_id { unsigned int numid; /* numeric identifier, zero = invalid */ - enum sndrv_ctl_elem_iface iface; /* interface identifier */ + snd_ctl_elem_iface_t iface; /* interface identifier */ unsigned int device; /* device/client number */ unsigned int subdevice; /* subdevice (substream) number */ unsigned char name[44]; /* ASCII name of item */ unsigned int index; /* index of item */ }; -struct sndrv_ctl_elem_list { +struct snd_ctl_elem_list { unsigned int offset; /* W: first element ID to get */ unsigned int space; /* W: count of element IDs to get */ unsigned int used; /* R: count of element IDs set */ unsigned int count; /* R: count of all elements */ - struct sndrv_ctl_elem_id __user *pids; /* R: IDs */ + struct snd_ctl_elem_id __user *pids; /* R: IDs */ unsigned char reserved[50]; }; -struct sndrv_ctl_elem_info { - struct sndrv_ctl_elem_id id; /* W: element ID */ - enum sndrv_ctl_elem_type type; /* R: value type - SNDRV_CTL_ELEM_TYPE_* */ +struct snd_ctl_elem_info { + struct snd_ctl_elem_id id; /* W: element ID */ + snd_ctl_elem_type_t type; /* R: value type - SNDRV_CTL_ELEM_TYPE_* */ unsigned int access; /* R: value access (bitmask) - SNDRV_CTL_ELEM_ACCESS_* */ unsigned int count; /* count of values */ pid_t owner; /* owner's PID of this control */ @@ -800,8 +792,8 @@ struct sndrv_ctl_elem_info { unsigned char reserved[64-4*sizeof(unsigned short)]; }; -struct sndrv_ctl_elem_value { - struct sndrv_ctl_elem_id id; /* W: element ID */ +struct snd_ctl_elem_value { + struct snd_ctl_elem_id id; /* W: element ID */ unsigned int indirect: 1; /* W: use indirect pointer (xxx_ptr member) */ union { union { @@ -820,7 +812,7 @@ struct sndrv_ctl_elem_value { unsigned char data[512]; unsigned char *data_ptr; } bytes; - struct sndrv_aes_iec958 iec958; + struct snd_aes_iec958 iec958; } value; /* RO */ struct timespec tstamp; unsigned char reserved[128-sizeof(struct timespec)]; @@ -828,24 +820,24 @@ struct sndrv_ctl_elem_value { enum { SNDRV_CTL_IOCTL_PVERSION = _IOR('U', 0x00, int), - SNDRV_CTL_IOCTL_CARD_INFO = _IOR('U', 0x01, struct sndrv_ctl_card_info), - SNDRV_CTL_IOCTL_ELEM_LIST = _IOWR('U', 0x10, struct sndrv_ctl_elem_list), - SNDRV_CTL_IOCTL_ELEM_INFO = _IOWR('U', 0x11, struct sndrv_ctl_elem_info), - SNDRV_CTL_IOCTL_ELEM_READ = _IOWR('U', 0x12, struct sndrv_ctl_elem_value), - SNDRV_CTL_IOCTL_ELEM_WRITE = _IOWR('U', 0x13, struct sndrv_ctl_elem_value), - SNDRV_CTL_IOCTL_ELEM_LOCK = _IOW('U', 0x14, struct sndrv_ctl_elem_id), - SNDRV_CTL_IOCTL_ELEM_UNLOCK = _IOW('U', 0x15, struct sndrv_ctl_elem_id), + SNDRV_CTL_IOCTL_CARD_INFO = _IOR('U', 0x01, struct snd_ctl_card_info), + SNDRV_CTL_IOCTL_ELEM_LIST = _IOWR('U', 0x10, struct snd_ctl_elem_list), + SNDRV_CTL_IOCTL_ELEM_INFO = _IOWR('U', 0x11, struct snd_ctl_elem_info), + SNDRV_CTL_IOCTL_ELEM_READ = _IOWR('U', 0x12, struct snd_ctl_elem_value), + SNDRV_CTL_IOCTL_ELEM_WRITE = _IOWR('U', 0x13, struct snd_ctl_elem_value), + SNDRV_CTL_IOCTL_ELEM_LOCK = _IOW('U', 0x14, struct snd_ctl_elem_id), + SNDRV_CTL_IOCTL_ELEM_UNLOCK = _IOW('U', 0x15, struct snd_ctl_elem_id), SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS = _IOWR('U', 0x16, int), - SNDRV_CTL_IOCTL_ELEM_ADD = _IOWR('U', 0x17, struct sndrv_ctl_elem_info), - SNDRV_CTL_IOCTL_ELEM_REPLACE = _IOWR('U', 0x18, struct sndrv_ctl_elem_info), - SNDRV_CTL_IOCTL_ELEM_REMOVE = _IOWR('U', 0x19, struct sndrv_ctl_elem_id), + SNDRV_CTL_IOCTL_ELEM_ADD = _IOWR('U', 0x17, struct snd_ctl_elem_info), + SNDRV_CTL_IOCTL_ELEM_REPLACE = _IOWR('U', 0x18, struct snd_ctl_elem_info), + SNDRV_CTL_IOCTL_ELEM_REMOVE = _IOWR('U', 0x19, struct snd_ctl_elem_id), SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE = _IOWR('U', 0x20, int), - SNDRV_CTL_IOCTL_HWDEP_INFO = _IOR('U', 0x21, struct sndrv_hwdep_info), + SNDRV_CTL_IOCTL_HWDEP_INFO = _IOR('U', 0x21, struct snd_hwdep_info), SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE = _IOR('U', 0x30, int), - SNDRV_CTL_IOCTL_PCM_INFO = _IOWR('U', 0x31, struct sndrv_pcm_info), + SNDRV_CTL_IOCTL_PCM_INFO = _IOWR('U', 0x31, struct snd_pcm_info), SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE = _IOW('U', 0x32, int), SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE = _IOWR('U', 0x40, int), - SNDRV_CTL_IOCTL_RAWMIDI_INFO = _IOWR('U', 0x41, struct sndrv_rawmidi_info), + SNDRV_CTL_IOCTL_RAWMIDI_INFO = _IOWR('U', 0x41, struct snd_rawmidi_info), SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE = _IOW('U', 0x42, int), SNDRV_CTL_IOCTL_POWER = _IOWR('U', 0xd0, int), SNDRV_CTL_IOCTL_POWER_STATE = _IOR('U', 0xd1, int), @@ -865,12 +857,12 @@ enum sndrv_ctl_event_type { #define SNDRV_CTL_EVENT_MASK_ADD (1<<2) /* element was added */ #define SNDRV_CTL_EVENT_MASK_REMOVE (~0U) /* element was removed */ -struct sndrv_ctl_event { - enum sndrv_ctl_event_type type; /* event type - SNDRV_CTL_EVENT_* */ +struct snd_ctl_event { + int type; /* event type - SNDRV_CTL_EVENT_* */ union { struct { unsigned int mask; - struct sndrv_ctl_elem_id id; + struct snd_ctl_elem_id id; } elem; unsigned char data8[60]; } data; @@ -898,14 +890,14 @@ struct sndrv_ctl_event { * */ -struct sndrv_xferv { +struct snd_xferv { const struct iovec *vector; unsigned long count; }; enum { - SNDRV_IOCTL_READV = _IOW('K', 0x00, struct sndrv_xferv), - SNDRV_IOCTL_WRITEV = _IOW('K', 0x01, struct sndrv_xferv), + SNDRV_IOCTL_READV = _IOW('K', 0x00, struct snd_xferv), + SNDRV_IOCTL_WRITEV = _IOW('K', 0x01, struct snd_xferv), }; #endif /* __SOUND_ASOUND_H */ diff --git a/include/sound/core.h b/include/sound/core.h index 2be65ad..f867433 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -28,13 +28,6 @@ #include <linux/workqueue.h> /* struct workqueue_struct */ #include <linux/pm.h> /* pm_message_t */ -/* Typedef's */ -typedef struct sndrv_interval snd_interval_t; -typedef enum sndrv_card_type snd_card_type; -typedef struct sndrv_xferi snd_xferi_t; -typedef struct sndrv_xfern snd_xfern_t; -typedef struct sndrv_xferv snd_xferv_t; - /* forward declarations */ #ifdef CONFIG_PCI struct pci_dev; @@ -47,76 +40,50 @@ struct sbus_dev; #define SNDRV_DEV_TYPE_RANGE_SIZE 0x1000 -typedef enum { - SNDRV_DEV_TOPLEVEL = (0*SNDRV_DEV_TYPE_RANGE_SIZE), - SNDRV_DEV_CONTROL, - SNDRV_DEV_LOWLEVEL_PRE, - SNDRV_DEV_LOWLEVEL_NORMAL = (1*SNDRV_DEV_TYPE_RANGE_SIZE), - SNDRV_DEV_PCM, - SNDRV_DEV_RAWMIDI, - SNDRV_DEV_TIMER, - SNDRV_DEV_SEQUENCER, - SNDRV_DEV_HWDEP, - SNDRV_DEV_INFO, - SNDRV_DEV_BUS, - SNDRV_DEV_CODEC, - SNDRV_DEV_LOWLEVEL = (2*SNDRV_DEV_TYPE_RANGE_SIZE) -} snd_device_type_t; - -typedef enum { - SNDRV_DEV_BUILD, - SNDRV_DEV_REGISTERED, - SNDRV_DEV_DISCONNECTED -} snd_device_state_t; - -typedef enum { - SNDRV_DEV_CMD_PRE = 0, - SNDRV_DEV_CMD_NORMAL = 1, - SNDRV_DEV_CMD_POST = 2 -} snd_device_cmd_t; - -typedef struct _snd_card snd_card_t; -typedef struct _snd_device snd_device_t; - -typedef int (snd_dev_free_t)(snd_device_t *device); -typedef int (snd_dev_register_t)(snd_device_t *device); -typedef int (snd_dev_disconnect_t)(snd_device_t *device); -typedef int (snd_dev_unregister_t)(snd_device_t *device); - -typedef struct { - snd_dev_free_t *dev_free; - snd_dev_register_t *dev_register; - snd_dev_disconnect_t *dev_disconnect; - snd_dev_unregister_t *dev_unregister; -} snd_device_ops_t; - -struct _snd_device { +typedef int __bitwise snd_device_type_t; +#define SNDRV_DEV_TOPLEVEL ((__force snd_device_type_t) 0) +#define SNDRV_DEV_CONTROL ((__force snd_device_type_t) 1) +#define SNDRV_DEV_LOWLEVEL_PRE ((__force snd_device_type_t) 2) +#define SNDRV_DEV_LOWLEVEL_NORMAL ((__force snd_device_type_t) 0x1000) +#define SNDRV_DEV_PCM ((__force snd_device_type_t) 0x1001) +#define SNDRV_DEV_RAWMIDI ((__force snd_device_type_t) 0x1002) +#define SNDRV_DEV_TIMER ((__force snd_device_type_t) 0x1003) +#define SNDRV_DEV_SEQUENCER ((__force snd_device_type_t) 0x1004) +#define SNDRV_DEV_HWDEP ((__force snd_device_type_t) 0x1005) +#define SNDRV_DEV_INFO ((__force snd_device_type_t) 0x1006) +#define SNDRV_DEV_BUS ((__force snd_device_type_t) 0x1007) +#define SNDRV_DEV_CODEC ((__force snd_device_type_t) 0x1008) +#define SNDRV_DEV_LOWLEVEL ((__force snd_device_type_t) 0x2000) + +typedef int __bitwise snd_device_state_t; +#define SNDRV_DEV_BUILD ((__force snd_device_state_t) 0) +#define SNDRV_DEV_REGISTERED ((__force snd_device_state_t) 1) +#define SNDRV_DEV_DISCONNECTED ((__force snd_device_state_t) 2) + +typedef int __bitwise snd_device_cmd_t; +#define SNDRV_DEV_CMD_PRE ((__force snd_device_cmd_t) 0) +#define SNDRV_DEV_CMD_NORMAL ((__force snd_device_cmd_t) 1) +#define SNDRV_DEV_CMD_POST ((__force snd_device_cmd_t) 2) + +struct snd_device; + +struct snd_device_ops { + int (*dev_free)(struct snd_device *dev); + int (*dev_register)(struct snd_device *dev); + int (*dev_disconnect)(struct snd_device *dev); + int (*dev_unregister)(struct snd_device *dev); +}; + +struct snd_device { struct list_head list; /* list of registered devices */ - snd_card_t *card; /* card which holds this device */ + struct snd_card *card; /* card which holds this device */ snd_device_state_t state; /* state of the device */ snd_device_type_t type; /* device type */ void *device_data; /* device structure */ - snd_device_ops_t *ops; /* operations */ + struct snd_device_ops *ops; /* operations */ }; -#define snd_device(n) list_entry(n, snd_device_t, list) - -/* various typedefs */ - -typedef struct snd_info_entry snd_info_entry_t; -typedef struct _snd_pcm snd_pcm_t; -typedef struct _snd_pcm_str snd_pcm_str_t; -typedef struct _snd_pcm_substream snd_pcm_substream_t; -typedef struct _snd_mixer snd_kmixer_t; -typedef struct _snd_rawmidi snd_rawmidi_t; -typedef struct _snd_ctl_file snd_ctl_file_t; -typedef struct _snd_kcontrol snd_kcontrol_t; -typedef struct _snd_timer snd_timer_t; -typedef struct _snd_timer_instance snd_timer_instance_t; -typedef struct _snd_hwdep snd_hwdep_t; -#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) -typedef struct _snd_oss_mixer snd_mixer_oss_t; -#endif +#define snd_device(n) list_entry(n, struct snd_device, list) /* monitor files for graceful shutdown (hotplug) */ @@ -129,7 +96,7 @@ struct snd_shutdown_f_ops; /* define it later in init.c */ /* main structure for soundcard */ -struct _snd_card { +struct snd_card { int number; /* number of soundcard (index to snd_cards) */ @@ -143,7 +110,7 @@ struct _snd_card { struct module *module; /* top-level module */ void *private_data; /* private data for soundcard */ - void (*private_free) (snd_card_t *card); /* callback for freeing of + void (*private_free) (struct snd_card *card); /* callback for freeing of private data */ struct list_head devices; /* devices */ @@ -155,8 +122,8 @@ struct _snd_card { struct list_head controls; /* all controls for this card */ struct list_head ctl_files; /* active control files */ - snd_info_entry_t *proc_root; /* root for soundcard specific files */ - snd_info_entry_t *proc_id; /* the card id */ + struct snd_info_entry *proc_root; /* root for soundcard specific files */ + struct snd_info_entry *proc_id; /* the card id */ struct proc_dir_entry *proc_root_link; /* number link to real id */ struct snd_monitor_file *files; /* all files associated to this card */ @@ -172,8 +139,8 @@ struct _snd_card { #endif #ifdef CONFIG_PM - int (*pm_suspend)(snd_card_t *card, pm_message_t state); - int (*pm_resume)(snd_card_t *card); + int (*pm_suspend)(struct snd_card *card, pm_message_t state); + int (*pm_resume)(struct snd_card *card); void *pm_private_data; unsigned int power_state; /* power state */ struct semaphore power_lock; /* power lock */ @@ -181,43 +148,43 @@ struct _snd_card { #endif #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) - snd_mixer_oss_t *mixer_oss; + struct snd_mixer_oss *mixer_oss; int mixer_oss_change_count; #endif }; #ifdef CONFIG_PM -static inline void snd_power_lock(snd_card_t *card) +static inline void snd_power_lock(struct snd_card *card) { down(&card->power_lock); } -static inline void snd_power_unlock(snd_card_t *card) +static inline void snd_power_unlock(struct snd_card *card) { up(&card->power_lock); } -static inline unsigned int snd_power_get_state(snd_card_t *card) +static inline unsigned int snd_power_get_state(struct snd_card *card) { return card->power_state; } -static inline void snd_power_change_state(snd_card_t *card, unsigned int state) +static inline void snd_power_change_state(struct snd_card *card, unsigned int state) { card->power_state = state; wake_up(&card->power_sleep); } /* init.c */ -int snd_power_wait(snd_card_t *card, unsigned int power_state, struct file *file); +int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file *file); -int snd_card_set_pm_callback(snd_card_t *card, - int (*suspend)(snd_card_t *, pm_message_t), - int (*resume)(snd_card_t *), +int snd_card_set_pm_callback(struct snd_card *card, + int (*suspend)(struct snd_card *, pm_message_t), + int (*resume)(struct snd_card *), void *private_data); -int snd_card_set_generic_pm_callback(snd_card_t *card, - int (*suspend)(snd_card_t *, pm_message_t), - int (*resume)(snd_card_t *), +int snd_card_set_generic_pm_callback(struct snd_card *card, + int (*suspend)(struct snd_card *, pm_message_t), + int (*resume)(struct snd_card *), void *private_data); #define snd_card_set_isa_pm_callback(card,suspend,resume,data) \ snd_card_set_generic_pm_callback(card, suspend, resume, data) @@ -231,7 +198,7 @@ int snd_card_pci_resume(struct pci_dev *dev); #define snd_power_lock(card) do { (void)(card); } while (0) #define snd_power_unlock(card) do { (void)(card); } while (0) -static inline int snd_power_wait(snd_card_t *card, unsigned int state, struct file *file) { return 0; } +static inline int snd_power_wait(struct snd_card *card, unsigned int state, struct file *file) { return 0; } #define snd_power_get_state(card) SNDRV_CTL_POWER_D0 #define snd_power_change_state(card, state) do { (void)(card); } while (0) #define snd_card_set_pm_callback(card,suspend,resume,data) @@ -241,7 +208,7 @@ static inline int snd_power_wait(snd_card_t *card, unsigned int state, struct fi #endif /* CONFIG_PM */ -struct _snd_minor { +struct snd_minor { struct list_head list; /* list of all minors per card */ int number; /* minor number */ int device; /* device number */ @@ -251,8 +218,6 @@ struct _snd_minor { structure) */ }; -typedef struct _snd_minor snd_minor_t; - /* sound.c */ extern int snd_major; @@ -260,12 +225,12 @@ extern int snd_ecards_limit; void snd_request_card(int card); -int snd_register_device(int type, snd_card_t *card, int dev, snd_minor_t *reg, const char *name); -int snd_unregister_device(int type, snd_card_t *card, int dev); +int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name); +int snd_unregister_device(int type, struct snd_card *card, int dev); #ifdef CONFIG_SND_OSSEMUL -int snd_register_oss_device(int type, snd_card_t *card, int dev, snd_minor_t *reg, const char *name); -int snd_unregister_oss_device(int type, snd_card_t *card, int dev); +int snd_register_oss_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name); +int snd_unregister_oss_device(int type, struct snd_card *card, int dev); #endif int snd_minor_info_init(void); @@ -291,43 +256,43 @@ int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size /* init.c */ extern unsigned int snd_cards_lock; -extern snd_card_t *snd_cards[SNDRV_CARDS]; +extern struct snd_card *snd_cards[SNDRV_CARDS]; extern rwlock_t snd_card_rwlock; #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) #define SND_MIXER_OSS_NOTIFY_REGISTER 0 #define SND_MIXER_OSS_NOTIFY_DISCONNECT 1 #define SND_MIXER_OSS_NOTIFY_FREE 2 -extern int (*snd_mixer_oss_notify_callback)(snd_card_t *card, int cmd); +extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd); #endif -snd_card_t *snd_card_new(int idx, const char *id, +struct snd_card *snd_card_new(int idx, const char *id, struct module *module, int extra_size); -int snd_card_disconnect(snd_card_t *card); -int snd_card_free(snd_card_t *card); -int snd_card_free_in_thread(snd_card_t *card); -int snd_card_register(snd_card_t *card); +int snd_card_disconnect(struct snd_card *card); +int snd_card_free(struct snd_card *card); +int snd_card_free_in_thread(struct snd_card *card); +int snd_card_register(struct snd_card *card); int snd_card_info_init(void); int snd_card_info_done(void); -int snd_component_add(snd_card_t *card, const char *component); -int snd_card_file_add(snd_card_t *card, struct file *file); -int snd_card_file_remove(snd_card_t *card, struct file *file); +int snd_component_add(struct snd_card *card, const char *component); +int snd_card_file_add(struct snd_card *card, struct file *file); +int snd_card_file_remove(struct snd_card *card, struct file *file); #ifndef snd_card_set_dev #define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) #endif /* register a generic device (for ISA, etc) */ -int snd_card_set_generic_dev(snd_card_t *card); +int snd_card_set_generic_dev(struct snd_card *card); /* device.c */ -int snd_device_new(snd_card_t *card, snd_device_type_t type, - void *device_data, snd_device_ops_t *ops); -int snd_device_register(snd_card_t *card, void *device_data); -int snd_device_register_all(snd_card_t *card); -int snd_device_disconnect(snd_card_t *card, void *device_data); -int snd_device_disconnect_all(snd_card_t *card); -int snd_device_free(snd_card_t *card, void *device_data); -int snd_device_free_all(snd_card_t *card, snd_device_cmd_t cmd); +int snd_device_new(struct snd_card *card, snd_device_type_t type, + void *device_data, struct snd_device_ops *ops); +int snd_device_register(struct snd_card *card, void *device_data); +int snd_device_register_all(struct snd_card *card); +int snd_device_disconnect(struct snd_card *card, void *device_data); +int snd_device_disconnect_all(struct snd_card *card); +int snd_device_free(struct snd_card *card, void *device_data); +int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd); /* isadma.c */ @@ -443,4 +408,6 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) #endif #endif +#include "typedefs.h" + #endif /* __SOUND_CORE_H */ diff --git a/sound/core/device.c b/sound/core/device.c index 1f509f5..afa8cc7 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -41,10 +41,10 @@ * * Returns zero if successful, or a negative error code on failure. */ -int snd_device_new(snd_card_t *card, snd_device_type_t type, - void *device_data, snd_device_ops_t *ops) +int snd_device_new(struct snd_card *card, snd_device_type_t type, + void *device_data, struct snd_device_ops *ops) { - snd_device_t *dev; + struct snd_device *dev; snd_assert(card != NULL, return -ENXIO); snd_assert(device_data != NULL, return -ENXIO); @@ -73,10 +73,10 @@ int snd_device_new(snd_card_t *card, snd_device_type_t type, * Returns zero if successful, or a negative error code on failure or if the * device not found. */ -int snd_device_free(snd_card_t *card, void *device_data) +int snd_device_free(struct snd_card *card, void *device_data) { struct list_head *list; - snd_device_t *dev; + struct snd_device *dev; snd_assert(card != NULL, return -ENXIO); snd_assert(device_data != NULL, return -ENXIO); @@ -86,7 +86,8 @@ int snd_device_free(snd_card_t *card, void *device_data) continue; /* unlink */ list_del(&dev->list); - if ((dev->state == SNDRV_DEV_REGISTERED || dev->state == SNDRV_DEV_DISCONNECTED) && + if ((dev->state == SNDRV_DEV_REGISTERED || + dev->state == SNDRV_DEV_DISCONNECTED) && dev->ops->dev_unregister) { if (dev->ops->dev_unregister(dev)) snd_printk(KERN_ERR "device unregister failure\n"); @@ -99,7 +100,8 @@ int snd_device_free(snd_card_t *card, void *device_data) kfree(dev); return 0; } - snd_printd("device free %p (from %p), not found\n", device_data, __builtin_return_address(0)); + snd_printd("device free %p (from %p), not found\n", device_data, + __builtin_return_address(0)); return -ENXIO; } @@ -116,10 +118,10 @@ int snd_device_free(snd_card_t *card, void *device_data) * Returns zero if successful, or a negative error code on failure or if the * device not found. */ -int snd_device_disconnect(snd_card_t *card, void *device_data) +int snd_device_disconnect(struct snd_card *card, void *device_data) { struct list_head *list; - snd_device_t *dev; + struct snd_device *dev; snd_assert(card != NULL, return -ENXIO); snd_assert(device_data != NULL, return -ENXIO); @@ -127,14 +129,16 @@ int snd_device_disconnect(snd_card_t *card, void *device_data) dev = snd_device(list); if (dev->device_data != device_data) continue; - if (dev->state == SNDRV_DEV_REGISTERED && dev->ops->dev_disconnect) { + if (dev->state == SNDRV_DEV_REGISTERED && + dev->ops->dev_disconnect) { if (dev->ops->dev_disconnect(dev)) snd_printk(KERN_ERR "device disconnect failure\n"); dev->state = SNDRV_DEV_DISCONNECTED; } return 0; } - snd_printd("device disconnect %p (from %p), not found\n", device_data, __builtin_return_address(0)); + snd_printd("device disconnect %p (from %p), not found\n", device_data, + __builtin_return_address(0)); return -ENXIO; } @@ -151,10 +155,10 @@ int snd_device_disconnect(snd_card_t *card, void *device_data) * Returns zero if successful, or a negative error code on failure or if the * device not found. */ -int snd_device_register(snd_card_t *card, void *device_data) +int snd_device_register(struct snd_card *card, void *device_data) { struct list_head *list; - snd_device_t *dev; + struct snd_device *dev; int err; snd_assert(card != NULL, return -ENXIO); @@ -179,10 +183,10 @@ int snd_device_register(snd_card_t *card, void *device_data) * register all the devices on the card. * called from init.c */ -int snd_device_register_all(snd_card_t *card) +int snd_device_register_all(struct snd_card *card) { struct list_head *list; - snd_device_t *dev; + struct snd_device *dev; int err; snd_assert(card != NULL, return -ENXIO); @@ -201,9 +205,9 @@ int snd_device_register_all(snd_card_t *card) * disconnect all the devices on the card. * called from init.c */ -int snd_device_disconnect_all(snd_card_t *card) +int snd_device_disconnect_all(struct snd_card *card) { - snd_device_t *dev; + struct snd_device *dev; struct list_head *list; int err = 0; @@ -220,9 +224,9 @@ int snd_device_disconnect_all(snd_card_t *card) * release all the devices on the card. * called from init.c */ -int snd_device_free_all(snd_card_t *card, snd_device_cmd_t cmd) +int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd) { - snd_device_t *dev; + struct snd_device *dev; struct list_head *list; int err; unsigned int range_low, range_high; diff --git a/sound/core/init.c b/sound/core/init.c index 33813f9..dca64d1 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -40,14 +40,15 @@ struct snd_shutdown_f_ops { }; unsigned int snd_cards_lock = 0; /* locked for registering/using */ -snd_card_t *snd_cards[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = NULL}; +struct snd_card *snd_cards[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = NULL}; DEFINE_RWLOCK(snd_card_rwlock); #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) -int (*snd_mixer_oss_notify_callback)(snd_card_t *card, int free_flag); +int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); #endif -static void snd_card_id_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_card_id_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_iprintf(buffer, "%s\n", entry->card->id); } @@ -63,13 +64,13 @@ static void snd_card_free_thread(void * __card); * * Creates and initializes a soundcard structure. * - * Returns kmallocated snd_card_t structure. Creates the ALSA control interface + * Returns kmallocated snd_card structure. Creates the ALSA control interface * (which is blocked until snd_card_register function is called). */ -snd_card_t *snd_card_new(int idx, const char *xid, +struct snd_card *snd_card_new(int idx, const char *xid, struct module *module, int extra_size) { - snd_card_t *card; + struct snd_card *card; int err; if (extra_size < 0) @@ -132,7 +133,7 @@ snd_card_t *snd_card_new(int idx, const char *xid, goto __error_ctl; } if (extra_size > 0) - card->private_data = (char *)card + sizeof(snd_card_t); + card->private_data = (char *)card + sizeof(struct snd_card); return card; __error_ctl: @@ -158,7 +159,7 @@ static unsigned int snd_disconnect_poll(struct file * file, poll_table * wait) * Note: The current implementation replaces all active file->f_op with special * dummy file operations (they do nothing except release). */ -int snd_card_disconnect(snd_card_t * card) +int snd_card_disconnect(struct snd_card *card) { struct snd_monitor_file *mfile; struct file *file; @@ -229,7 +230,7 @@ int snd_card_disconnect(snd_card_t * card) } #ifdef CONFIG_SND_GENERIC_DRIVER -static void snd_generic_device_unregister(snd_card_t *card); +static void snd_generic_device_unregister(struct snd_card *card); #else #define snd_generic_device_unregister(x) /*NOP*/ #endif @@ -245,7 +246,7 @@ static void snd_generic_device_unregister(snd_card_t *card); * Returns zero. Frees all associated devices and frees the control * interface associated to given soundcard. */ -int snd_card_free(snd_card_t * card) +int snd_card_free(struct snd_card *card) { struct snd_shutdown_f_ops *s_f_ops; @@ -300,7 +301,7 @@ int snd_card_free(snd_card_t * card) static void snd_card_free_thread(void * __card) { - snd_card_t *card = __card; + struct snd_card *card = __card; struct module * module = card->module; if (!try_module_get(module)) { @@ -327,7 +328,7 @@ static void snd_card_free_thread(void * __card) * * Returns - zero otherwise a negative error code if the start of thread failed. */ -int snd_card_free_in_thread(snd_card_t * card) +int snd_card_free_in_thread(struct snd_card *card) { if (card->files == NULL) { snd_card_free(card); @@ -343,7 +344,7 @@ int snd_card_free_in_thread(snd_card_t * card) return -EFAULT; } -static void choose_default_id(snd_card_t * card) +static void choose_default_id(struct snd_card *card) { int i, len, idx_flag = 0, loops = 8; char *id, *spos; @@ -415,10 +416,10 @@ static void choose_default_id(snd_card_t * card) * * Returns zero otherwise a negative error code if the registrain failed. */ -int snd_card_register(snd_card_t * card) +int snd_card_register(struct snd_card *card) { int err; - snd_info_entry_t *entry; + struct snd_info_entry *entry; snd_assert(card != NULL, return -EINVAL); if ((err = snd_device_register_all(card)) < 0) @@ -456,12 +457,12 @@ int snd_card_register(snd_card_t * card) return 0; } -static snd_info_entry_t *snd_card_info_entry = NULL; +static struct snd_info_entry *snd_card_info_entry = NULL; -static void snd_card_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_card_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { int idx, count; - snd_card_t *card; + struct snd_card *card; for (idx = count = 0; idx < SNDRV_CARDS; idx++) { read_lock(&snd_card_rwlock); @@ -483,10 +484,10 @@ static void snd_card_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buff #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) -void snd_card_info_read_oss(snd_info_buffer_t * buffer) +void snd_card_info_read_oss(struct snd_info_buffer *buffer) { int idx, count; - snd_card_t *card; + struct snd_card *card; for (idx = count = 0; idx < SNDRV_CARDS; idx++) { read_lock(&snd_card_rwlock); @@ -504,11 +505,12 @@ void snd_card_info_read_oss(snd_info_buffer_t * buffer) #endif #ifdef MODULE -static snd_info_entry_t *snd_card_module_info_entry; -static void snd_card_module_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static struct snd_info_entry *snd_card_module_info_entry; +static void snd_card_module_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int idx; - snd_card_t *card; + struct snd_card *card; for (idx = 0; idx < SNDRV_CARDS; idx++) { read_lock(&snd_card_rwlock); @@ -521,7 +523,7 @@ static void snd_card_module_info_read(snd_info_entry_t *entry, snd_info_buffer_t int __init snd_card_info_init(void) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = snd_info_create_module_entry(THIS_MODULE, "cards", NULL); if (! entry) @@ -571,7 +573,7 @@ int __exit snd_card_info_done(void) * Returns zero otherwise a negative error code. */ -int snd_component_add(snd_card_t *card, const char *component) +int snd_component_add(struct snd_card *card, const char *component) { char *ptr; int len = strlen(component); @@ -602,7 +604,7 @@ int snd_component_add(snd_card_t *card, const char *component) * * Returns zero or a negative error code. */ -int snd_card_file_add(snd_card_t *card, struct file *file) +int snd_card_file_add(struct snd_card *card, struct file *file) { struct snd_monitor_file *mfile; @@ -636,7 +638,7 @@ int snd_card_file_add(snd_card_t *card, struct file *file) * * Returns zero or a negative error code. */ -int snd_card_file_remove(snd_card_t *card, struct file *file) +int snd_card_file_remove(struct snd_card *card, struct file *file) { struct snd_monitor_file *mfile, *pfile = NULL; @@ -671,7 +673,7 @@ int snd_card_file_remove(snd_card_t *card, struct file *file) */ struct snd_generic_device { struct platform_device pdev; - snd_card_t *card; + struct snd_card *card; }; #define get_snd_generic_card(dev) container_of(dev, struct snd_generic_device, pdev)->card @@ -698,7 +700,7 @@ void snd_generic_device_release(struct device *dev) { } -static int snd_generic_device_register(snd_card_t *card) +static int snd_generic_device_register(struct snd_card *card) { struct snd_generic_device *dev; int err; @@ -724,7 +726,7 @@ static int snd_generic_device_register(snd_card_t *card) return 0; } -static void snd_generic_device_unregister(snd_card_t *card) +static void snd_generic_device_unregister(struct snd_card *card) { struct snd_generic_device *dev = card->generic_dev; if (dev) { @@ -744,7 +746,7 @@ static void snd_generic_device_unregister(snd_card_t *card) * * Returns zero if successful, or a negative error code. */ -int snd_card_set_generic_dev(snd_card_t *card) +int snd_card_set_generic_dev(struct snd_card *card) { int err; if ((err = snd_generic_device_register(card)) < 0) @@ -766,7 +768,7 @@ int snd_card_set_generic_dev(snd_card_t *card) * * Note: the power lock must be active before call. */ -int snd_power_wait(snd_card_t *card, unsigned int power_state, struct file *file) +int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file *file) { wait_queue_t wait; int result = 0; @@ -809,9 +811,9 @@ int snd_power_wait(snd_card_t *card, unsigned int power_state, struct file *file * These callbacks are called from ALSA's common PCI suspend/resume * handler and from the control API. */ -int snd_card_set_pm_callback(snd_card_t *card, - int (*suspend)(snd_card_t *, pm_message_t), - int (*resume)(snd_card_t *), +int snd_card_set_pm_callback(struct snd_card *card, + int (*suspend)(struct snd_card *, pm_message_t), + int (*resume)(struct snd_card *), void *private_data) { card->pm_suspend = suspend; @@ -824,7 +826,7 @@ int snd_card_set_pm_callback(snd_card_t *card, /* suspend/resume callbacks for snd_generic platform device */ static int snd_generic_suspend(struct platform_device *dev, pm_message_t state) { - snd_card_t *card; + struct snd_card *card; card = get_snd_generic_card(dev); if (card->power_state == SNDRV_CTL_POWER_D3hot) @@ -837,7 +839,7 @@ static int snd_generic_suspend(struct platform_device *dev, pm_message_t state) static int snd_generic_resume(struct platform_device *dev) { - snd_card_t *card; + struct snd_card *card; card = get_snd_generic_card(dev); if (card->power_state == SNDRV_CTL_POWER_D0) @@ -859,9 +861,9 @@ static int snd_generic_resume(struct platform_device *dev) * the given card. These callbacks are called from the ALSA's common * PM handler and from the control API. */ -int snd_card_set_generic_pm_callback(snd_card_t *card, - int (*suspend)(snd_card_t *, pm_message_t), - int (*resume)(snd_card_t *), +int snd_card_set_generic_pm_callback(struct snd_card *card, + int (*suspend)(struct snd_card *, pm_message_t), + int (*resume)(struct snd_card *), void *private_data) { int err; @@ -874,7 +876,7 @@ int snd_card_set_generic_pm_callback(snd_card_t *card, #ifdef CONFIG_PCI int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state) { - snd_card_t *card = pci_get_drvdata(dev); + struct snd_card *card = pci_get_drvdata(dev); int err; if (! card || ! card->pm_suspend) return 0; @@ -888,7 +890,7 @@ int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state) int snd_card_pci_resume(struct pci_dev *dev) { - snd_card_t *card = pci_get_drvdata(dev); + struct snd_card *card = pci_get_drvdata(dev); if (! card || ! card->pm_resume) return 0; if (card->power_state == SNDRV_CTL_POWER_D0) diff --git a/sound/core/sound.c b/sound/core/sound.c index 6e7cad1e..04de008 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -108,13 +108,13 @@ static void snd_request_other(int minor) #endif /* request_module support */ -static snd_minor_t *snd_minor_search(int minor) +static struct snd_minor *snd_minor_search(int minor) { struct list_head *list; - snd_minor_t *mptr; + struct snd_minor *mptr; list_for_each(list, &snd_minors_hash[SNDRV_MINOR_CARD(minor)]) { - mptr = list_entry(list, snd_minor_t, list); + mptr = list_entry(list, struct snd_minor, list); if (mptr->number == minor) return mptr; } @@ -126,7 +126,7 @@ static int snd_open(struct inode *inode, struct file *file) int minor = iminor(inode); int card = SNDRV_MINOR_CARD(minor); int dev = SNDRV_MINOR_DEVICE(minor); - snd_minor_t *mptr = NULL; + struct snd_minor *mptr = NULL; struct file_operations *old_fops; int err = 0; @@ -164,7 +164,7 @@ static struct file_operations snd_fops = .open = snd_open }; -static int snd_kernel_minor(int type, snd_card_t * card, int dev) +static int snd_kernel_minor(int type, struct snd_card *card, int dev) { int minor; @@ -196,7 +196,7 @@ static int snd_kernel_minor(int type, snd_card_t * card, int dev) * @type: the device type, SNDRV_DEVICE_TYPE_XXX * @card: the card instance * @dev: the device index - * @reg: the snd_minor_t record + * @reg: the struct snd_minor record * @name: the device file name * * Registers an ALSA device file for the given card. @@ -204,16 +204,16 @@ static int snd_kernel_minor(int type, snd_card_t * card, int dev) * * Retrurns zero if successful, or a negative error code on failure. */ -int snd_register_device(int type, snd_card_t * card, int dev, snd_minor_t * reg, const char *name) +int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor * reg, const char *name) { int minor = snd_kernel_minor(type, card, dev); - snd_minor_t *preg; + struct snd_minor *preg; struct device *device = NULL; if (minor < 0) return minor; snd_assert(name, return -EINVAL); - preg = (snd_minor_t *)kmalloc(sizeof(snd_minor_t) + strlen(name) + 1, GFP_KERNEL); + preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); if (preg == NULL) return -ENOMEM; *preg = *reg; @@ -248,10 +248,10 @@ int snd_register_device(int type, snd_card_t * card, int dev, snd_minor_t * reg, * * Returns zero if sucecessful, or a negative error code on failure */ -int snd_unregister_device(int type, snd_card_t * card, int dev) +int snd_unregister_device(int type, struct snd_card *card, int dev) { int minor = snd_kernel_minor(type, card, dev); - snd_minor_t *mptr; + struct snd_minor *mptr; if (minor < 0) return minor; @@ -275,18 +275,18 @@ int snd_unregister_device(int type, snd_card_t * card, int dev) * INFO PART */ -static snd_info_entry_t *snd_minor_info_entry = NULL; +static struct snd_info_entry *snd_minor_info_entry = NULL; -static void snd_minor_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { int card, device; struct list_head *list; - snd_minor_t *mptr; + struct snd_minor *mptr; down(&sound_mutex); for (card = 0; card < SNDRV_CARDS; card++) { list_for_each(list, &snd_minors_hash[card]) { - mptr = list_entry(list, snd_minor_t, list); + mptr = list_entry(list, struct snd_minor, list); if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) { if ((device = mptr->device) >= 0) snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, mptr->comment); @@ -302,7 +302,7 @@ static void snd_minor_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buf int __init snd_minor_info_init(void) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = snd_info_create_module_entry(THIS_MODULE, "devices", NULL); if (entry) { -- cgit v1.1 From 82e9bae6fd253af4aea9c690223c7800313632ad Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 13:53:23 +0100 Subject: [ALSA] Remove xxx_t typedefs: Controls Modules: Control Midlevel Remove xxx_t typedefs from the core controls. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/control.h | 94 +++++++-------- sound/core/control.c | 274 ++++++++++++++++++++++++-------------------- sound/core/control_compat.c | 73 ++++++------ 3 files changed, 228 insertions(+), 213 deletions(-) diff --git a/include/sound/control.h b/include/sound/control.h index ef7903c..2489b1e 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -24,24 +24,14 @@ #include <sound/asound.h> -typedef struct sndrv_aes_iec958 snd_aes_iec958_t; -typedef struct sndrv_ctl_card_info snd_ctl_card_info_t; -typedef enum sndrv_ctl_elem_type snd_ctl_elem_type_t; -typedef enum sndrv_ctl_elem_iface snd_ctl_elem_iface_t; -typedef struct sndrv_ctl_elem_id snd_ctl_elem_id_t; -typedef struct sndrv_ctl_elem_list snd_ctl_elem_list_t; -typedef struct sndrv_ctl_elem_info snd_ctl_elem_info_t; -typedef struct sndrv_ctl_elem_value snd_ctl_elem_value_t; -typedef enum sndrv_ctl_event_type snd_ctl_event_type_t; -typedef struct sndrv_ctl_event snd_ctl_event_t; - #define snd_kcontrol_chip(kcontrol) ((kcontrol)->private_data) -typedef int (snd_kcontrol_info_t) (snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo); -typedef int (snd_kcontrol_get_t) (snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); -typedef int (snd_kcontrol_put_t) (snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); +struct snd_kcontrol; +typedef int (snd_kcontrol_info_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_info * uinfo); +typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); +typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); -typedef struct _snd_kcontrol_new { +struct snd_kcontrol_new { snd_ctl_elem_iface_t iface; /* interface identifier */ unsigned int device; /* device/client number */ unsigned int subdevice; /* subdevice (substream) number */ @@ -53,40 +43,40 @@ typedef struct _snd_kcontrol_new { snd_kcontrol_get_t *get; snd_kcontrol_put_t *put; unsigned long private_value; -} snd_kcontrol_new_t; +}; -typedef struct _snd_kcontrol_volatile { - snd_ctl_file_t *owner; /* locked */ +struct snd_kcontrol_volatile { + struct snd_ctl_file *owner; /* locked */ pid_t owner_pid; unsigned int access; /* access rights */ -} snd_kcontrol_volatile_t; +}; -struct _snd_kcontrol { +struct snd_kcontrol { struct list_head list; /* list of controls */ - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; unsigned int count; /* count of same elements */ snd_kcontrol_info_t *info; snd_kcontrol_get_t *get; snd_kcontrol_put_t *put; unsigned long private_value; void *private_data; - void (*private_free)(snd_kcontrol_t *kcontrol); - snd_kcontrol_volatile_t vd[0]; /* volatile data */ + void (*private_free)(struct snd_kcontrol *kcontrol); + struct snd_kcontrol_volatile vd[0]; /* volatile data */ }; -#define snd_kcontrol(n) list_entry(n, snd_kcontrol_t, list) +#define snd_kcontrol(n) list_entry(n, struct snd_kcontrol, list) -typedef struct _snd_kctl_event { +struct snd_kctl_event { struct list_head list; /* list of events */ - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; unsigned int mask; -} snd_kctl_event_t; +}; -#define snd_kctl_event(n) list_entry(n, snd_kctl_event_t, list) +#define snd_kctl_event(n) list_entry(n, struct snd_kctl_event, list) -struct _snd_ctl_file { +struct snd_ctl_file { struct list_head list; /* list of all control files */ - snd_card_t *card; + struct snd_card *card; pid_t pid; int prefer_pcm_subdevice; int prefer_rawmidi_subdevice; @@ -97,25 +87,25 @@ struct _snd_ctl_file { struct list_head events; /* waiting events for read */ }; -#define snd_ctl_file(n) list_entry(n, snd_ctl_file_t, list) +#define snd_ctl_file(n) list_entry(n, struct snd_ctl_file, list) -typedef int (*snd_kctl_ioctl_func_t) (snd_card_t * card, - snd_ctl_file_t * control, - unsigned int cmd, unsigned long arg); +typedef int (*snd_kctl_ioctl_func_t) (struct snd_card * card, + struct snd_ctl_file * control, + unsigned int cmd, unsigned long arg); -void snd_ctl_notify(snd_card_t * card, unsigned int mask, snd_ctl_elem_id_t * id); +void snd_ctl_notify(struct snd_card * card, unsigned int mask, struct snd_ctl_elem_id * id); -snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * kcontrol, unsigned int access); -snd_kcontrol_t *snd_ctl_new1(const snd_kcontrol_new_t * kcontrolnew, void * private_data); -void snd_ctl_free_one(snd_kcontrol_t * kcontrol); -int snd_ctl_add(snd_card_t * card, snd_kcontrol_t * kcontrol); -int snd_ctl_remove(snd_card_t * card, snd_kcontrol_t * kcontrol); -int snd_ctl_remove_id(snd_card_t * card, snd_ctl_elem_id_t *id); -int snd_ctl_rename_id(snd_card_t * card, snd_ctl_elem_id_t *src_id, snd_ctl_elem_id_t *dst_id); -snd_kcontrol_t *snd_ctl_find_numid(snd_card_t * card, unsigned int numid); -snd_kcontrol_t *snd_ctl_find_id(snd_card_t * card, snd_ctl_elem_id_t *id); +struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol * kcontrol, unsigned int access); +struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new * kcontrolnew, void * private_data); +void snd_ctl_free_one(struct snd_kcontrol * kcontrol); +int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol); +int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol); +int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id); +int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id); +struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid); +struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id); -int snd_ctl_create(snd_card_t *card); +int snd_ctl_create(struct snd_card *card); int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn); int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn); @@ -127,20 +117,20 @@ int snd_ctl_unregister_ioctl_compat(snd_kctl_ioctl_func_t fcn); #define snd_ctl_unregister_ioctl_compat(fcn) #endif -int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t *control); -int snd_ctl_elem_write(snd_card_t *card, snd_ctl_file_t *file, snd_ctl_elem_value_t *control); +int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control); +int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, struct snd_ctl_elem_value *control); -static inline unsigned int snd_ctl_get_ioffnum(snd_kcontrol_t *kctl, snd_ctl_elem_id_t *id) +static inline unsigned int snd_ctl_get_ioffnum(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id) { return id->numid - kctl->id.numid; } -static inline unsigned int snd_ctl_get_ioffidx(snd_kcontrol_t *kctl, snd_ctl_elem_id_t *id) +static inline unsigned int snd_ctl_get_ioffidx(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id) { return id->index - kctl->id.index; } -static inline unsigned int snd_ctl_get_ioff(snd_kcontrol_t *kctl, snd_ctl_elem_id_t *id) +static inline unsigned int snd_ctl_get_ioff(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id) { if (id->numid) { return snd_ctl_get_ioffnum(kctl, id); @@ -149,8 +139,8 @@ static inline unsigned int snd_ctl_get_ioff(snd_kcontrol_t *kctl, snd_ctl_elem_i } } -static inline snd_ctl_elem_id_t *snd_ctl_build_ioff(snd_ctl_elem_id_t *dst_id, - snd_kcontrol_t *src_kctl, +static inline struct snd_ctl_elem_id *snd_ctl_build_ioff(struct snd_ctl_elem_id *dst_id, + struct snd_kcontrol *src_kctl, unsigned int offset) { *dst_id = src_kctl->id; diff --git a/sound/core/control.c b/sound/core/control.c index 212c46a..1a14338 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -34,12 +34,10 @@ /* max number of user-defined controls */ #define MAX_USER_CONTROLS 32 -typedef struct _snd_kctl_ioctl { +struct snd_kctl_ioctl { struct list_head list; /* list of all ioctls */ snd_kctl_ioctl_func_t fioctl; -} snd_kctl_ioctl_t; - -#define snd_kctl_ioctl(n) list_entry(n, snd_kctl_ioctl_t, list) +}; static DECLARE_RWSEM(snd_ioctl_rwsem); static LIST_HEAD(snd_control_ioctls); @@ -51,8 +49,8 @@ static int snd_ctl_open(struct inode *inode, struct file *file) { int cardnum = SNDRV_MINOR_CARD(iminor(inode)); unsigned long flags; - snd_card_t *card; - snd_ctl_file_t *ctl; + struct snd_card *card; + struct snd_ctl_file *ctl; int err; card = snd_cards[cardnum]; @@ -93,9 +91,9 @@ static int snd_ctl_open(struct inode *inode, struct file *file) return err; } -static void snd_ctl_empty_read_queue(snd_ctl_file_t * ctl) +static void snd_ctl_empty_read_queue(struct snd_ctl_file * ctl) { - snd_kctl_event_t *cread; + struct snd_kctl_event *cread; spin_lock(&ctl->read_lock); while (!list_empty(&ctl->events)) { @@ -110,9 +108,9 @@ static int snd_ctl_release(struct inode *inode, struct file *file) { unsigned long flags; struct list_head *list; - snd_card_t *card; - snd_ctl_file_t *ctl; - snd_kcontrol_t *control; + struct snd_card *card; + struct snd_ctl_file *ctl; + struct snd_kcontrol *control; unsigned int idx; ctl = file->private_data; @@ -137,12 +135,13 @@ static int snd_ctl_release(struct inode *inode, struct file *file) return 0; } -void snd_ctl_notify(snd_card_t *card, unsigned int mask, snd_ctl_elem_id_t *id) +void snd_ctl_notify(struct snd_card *card, unsigned int mask, + struct snd_ctl_elem_id *id) { unsigned long flags; struct list_head *flist; - snd_ctl_file_t *ctl; - snd_kctl_event_t *ev; + struct snd_ctl_file *ctl; + struct snd_kctl_event *ev; snd_assert(card != NULL && id != NULL, return); read_lock(&card->ctl_files_rwlock); @@ -183,19 +182,19 @@ void snd_ctl_notify(snd_card_t *card, unsigned int mask, snd_ctl_elem_id_t *id) * @control: the control template * @access: the default control access * - * Allocates a new snd_kcontrol_t instance and copies the given template + * Allocates a new struct snd_kcontrol instance and copies the given template * to the new instance. It does not copy volatile data (access). * * Returns the pointer of the new instance, or NULL on failure. */ -snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access) +struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, unsigned int access) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; unsigned int idx; snd_assert(control != NULL, return NULL); snd_assert(control->count > 0, return NULL); - kctl = kzalloc(sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL); + kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL); if (kctl == NULL) return NULL; *kctl = *control; @@ -209,15 +208,16 @@ snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access) * @ncontrol: the initialization record * @private_data: the private data to set * - * Allocates a new snd_kcontrol_t instance and initialize from the given + * Allocates a new struct snd_kcontrol instance and initialize from the given * template. When the access field of ncontrol is 0, it's assumed as * READWRITE access. When the count field is 0, it's assumes as one. * * Returns the pointer of the newly generated instance, or NULL on failure. */ -snd_kcontrol_t *snd_ctl_new1(const snd_kcontrol_new_t * ncontrol, void *private_data) +struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, + void *private_data) { - snd_kcontrol_t kctl; + struct snd_kcontrol kctl; unsigned int access; snd_assert(ncontrol != NULL, return NULL); @@ -249,7 +249,7 @@ snd_kcontrol_t *snd_ctl_new1(const snd_kcontrol_new_t * ncontrol, void *private_ * or snd_ctl_new1(). * Don't call this after the control was added to the card. */ -void snd_ctl_free_one(snd_kcontrol_t * kcontrol) +void snd_ctl_free_one(struct snd_kcontrol *kcontrol) { if (kcontrol) { if (kcontrol->private_free) @@ -258,11 +258,11 @@ void snd_ctl_free_one(snd_kcontrol_t * kcontrol) } } -static unsigned int snd_ctl_hole_check(snd_card_t * card, +static unsigned int snd_ctl_hole_check(struct snd_card *card, unsigned int count) { struct list_head *list; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; list_for_each(list, &card->controls) { kctl = snd_kcontrol(list); @@ -275,7 +275,7 @@ static unsigned int snd_ctl_hole_check(snd_card_t * card, return card->last_numid; } -static int snd_ctl_find_hole(snd_card_t * card, unsigned int count) +static int snd_ctl_find_hole(struct snd_card *card, unsigned int count) { unsigned int last_numid, iter = 100000; @@ -304,9 +304,9 @@ static int snd_ctl_find_hole(snd_card_t * card, unsigned int count) * * It frees automatically the control which cannot be added. */ -int snd_ctl_add(snd_card_t * card, snd_kcontrol_t * kcontrol) +int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; unsigned int idx; snd_assert(card != NULL && kcontrol != NULL, return -EINVAL); @@ -350,9 +350,9 @@ int snd_ctl_add(snd_card_t * card, snd_kcontrol_t * kcontrol) * * Returns 0 if successful, or a negative error code on failure. */ -int snd_ctl_remove(snd_card_t * card, snd_kcontrol_t * kcontrol) +int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; unsigned int idx; snd_assert(card != NULL && kcontrol != NULL, return -EINVAL); @@ -375,9 +375,9 @@ int snd_ctl_remove(snd_card_t * card, snd_kcontrol_t * kcontrol) * * Returns 0 if successful, or a negative error code on failure. */ -int snd_ctl_remove_id(snd_card_t * card, snd_ctl_elem_id_t *id) +int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; int ret; down_write(&card->controls_rwsem); @@ -401,10 +401,11 @@ int snd_ctl_remove_id(snd_card_t * card, snd_ctl_elem_id_t *id) * * Returns 0 if successful, or a negative error code on failure. */ -static int snd_ctl_remove_unlocked_id(snd_ctl_file_t * file, snd_ctl_elem_id_t *id) +static int snd_ctl_remove_unlocked_id(struct snd_ctl_file * file, + struct snd_ctl_elem_id *id) { - snd_card_t *card = file->card; - snd_kcontrol_t *kctl; + struct snd_card *card = file->card; + struct snd_kcontrol *kctl; int idx, ret; down_write(&card->controls_rwsem); @@ -434,9 +435,10 @@ static int snd_ctl_remove_unlocked_id(snd_ctl_file_t * file, snd_ctl_elem_id_t * * * Returns zero if successful, or a negative error code on failure. */ -int snd_ctl_rename_id(snd_card_t * card, snd_ctl_elem_id_t *src_id, snd_ctl_elem_id_t *dst_id) +int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id, + struct snd_ctl_elem_id *dst_id) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; down_write(&card->controls_rwsem); kctl = snd_ctl_find_id(card, src_id); @@ -463,10 +465,10 @@ int snd_ctl_rename_id(snd_card_t * card, snd_ctl_elem_id_t *src_id, snd_ctl_elem * The caller must down card->controls_rwsem before calling this function * (if the race condition can happen). */ -snd_kcontrol_t *snd_ctl_find_numid(snd_card_t * card, unsigned int numid) +struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) { struct list_head *list; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; snd_assert(card != NULL && numid != 0, return NULL); list_for_each(list, &card->controls) { @@ -489,10 +491,11 @@ snd_kcontrol_t *snd_ctl_find_numid(snd_card_t * card, unsigned int numid) * The caller must down card->controls_rwsem before calling this function * (if the race condition can happen). */ -snd_kcontrol_t *snd_ctl_find_id(snd_card_t * card, snd_ctl_elem_id_t *id) +struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, + struct snd_ctl_elem_id *id) { struct list_head *list; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; snd_assert(card != NULL && id != NULL, return NULL); if (id->numid != 0) @@ -516,10 +519,10 @@ snd_kcontrol_t *snd_ctl_find_id(snd_card_t * card, snd_ctl_elem_id_t *id) return NULL; } -static int snd_ctl_card_info(snd_card_t * card, snd_ctl_file_t * ctl, +static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl, unsigned int cmd, void __user *arg) { - snd_ctl_card_info_t *info; + struct snd_ctl_card_info *info; info = kzalloc(sizeof(*info), GFP_KERNEL); if (! info) @@ -533,7 +536,7 @@ static int snd_ctl_card_info(snd_card_t * card, snd_ctl_file_t * ctl, strlcpy(info->mixername, card->mixername, sizeof(info->mixername)); strlcpy(info->components, card->components, sizeof(info->components)); up_read(&snd_ioctl_rwsem); - if (copy_to_user(arg, info, sizeof(snd_ctl_card_info_t))) { + if (copy_to_user(arg, info, sizeof(struct snd_ctl_card_info))) { kfree(info); return -EFAULT; } @@ -541,12 +544,13 @@ static int snd_ctl_card_info(snd_card_t * card, snd_ctl_file_t * ctl, return 0; } -static int snd_ctl_elem_list(snd_card_t *card, snd_ctl_elem_list_t __user *_list) +static int snd_ctl_elem_list(struct snd_card *card, + struct snd_ctl_elem_list __user *_list) { struct list_head *plist; - snd_ctl_elem_list_t list; - snd_kcontrol_t *kctl; - snd_ctl_elem_id_t *dst, *id; + struct snd_ctl_elem_list list; + struct snd_kcontrol *kctl; + struct snd_ctl_elem_id *dst, *id; unsigned int offset, space, first, jidx; if (copy_from_user(&list, _list, sizeof(list))) @@ -559,7 +563,7 @@ static int snd_ctl_elem_list(snd_card_t *card, snd_ctl_elem_list_t __user *_list return -ENOMEM; if (space > 0) { /* allocate temporary buffer for atomic operation */ - dst = vmalloc(space * sizeof(snd_ctl_elem_id_t)); + dst = vmalloc(space * sizeof(struct snd_ctl_elem_id)); if (dst == NULL) return -ENOMEM; down_read(&card->controls_rwsem); @@ -588,7 +592,9 @@ static int snd_ctl_elem_list(snd_card_t *card, snd_ctl_elem_list_t __user *_list offset = 0; } up_read(&card->controls_rwsem); - if (list.used > 0 && copy_to_user(list.pids, dst, list.used * sizeof(snd_ctl_elem_id_t))) { + if (list.used > 0 && + copy_to_user(list.pids, dst, + list.used * sizeof(struct snd_ctl_elem_id))) { vfree(dst); return -EFAULT; } @@ -603,11 +609,12 @@ static int snd_ctl_elem_list(snd_card_t *card, snd_ctl_elem_list_t __user *_list return 0; } -static int snd_ctl_elem_info(snd_ctl_file_t *ctl, snd_ctl_elem_info_t *info) +static int snd_ctl_elem_info(struct snd_ctl_file *ctl, + struct snd_ctl_elem_info *info) { - snd_card_t *card = ctl->card; - snd_kcontrol_t *kctl; - snd_kcontrol_volatile_t *vd; + struct snd_card *card = ctl->card; + struct snd_kcontrol *kctl; + struct snd_kcontrol_volatile *vd; unsigned int index_offset; int result; @@ -640,9 +647,10 @@ static int snd_ctl_elem_info(snd_ctl_file_t *ctl, snd_ctl_elem_info_t *info) return result; } -static int snd_ctl_elem_info_user(snd_ctl_file_t *ctl, snd_ctl_elem_info_t __user *_info) +static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl, + struct snd_ctl_elem_info __user *_info) { - snd_ctl_elem_info_t info; + struct snd_ctl_elem_info info; int result; if (copy_from_user(&info, _info, sizeof(info))) @@ -654,10 +662,10 @@ static int snd_ctl_elem_info_user(snd_ctl_file_t *ctl, snd_ctl_elem_info_t __use return result; } -int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t *control) +int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control) { - snd_kcontrol_t *kctl; - snd_kcontrol_volatile_t *vd; + struct snd_kcontrol *kctl; + struct snd_kcontrol_volatile *vd; unsigned int index_offset; int result, indirect; @@ -684,9 +692,10 @@ int snd_ctl_elem_read(snd_card_t *card, snd_ctl_elem_value_t *control) return result; } -static int snd_ctl_elem_read_user(snd_card_t *card, snd_ctl_elem_value_t __user *_control) +static int snd_ctl_elem_read_user(struct snd_card *card, + struct snd_ctl_elem_value __user *_control) { - snd_ctl_elem_value_t *control; + struct snd_ctl_elem_value *control; int result; control = kmalloc(sizeof(*control), GFP_KERNEL); @@ -704,10 +713,11 @@ static int snd_ctl_elem_read_user(snd_card_t *card, snd_ctl_elem_value_t __user return result; } -int snd_ctl_elem_write(snd_card_t *card, snd_ctl_file_t *file, snd_ctl_elem_value_t *control) +int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, + struct snd_ctl_elem_value *control) { - snd_kcontrol_t *kctl; - snd_kcontrol_volatile_t *vd; + struct snd_kcontrol *kctl; + struct snd_kcontrol_volatile *vd; unsigned int index_offset; int result, indirect; @@ -741,9 +751,10 @@ int snd_ctl_elem_write(snd_card_t *card, snd_ctl_file_t *file, snd_ctl_elem_valu return result; } -static int snd_ctl_elem_write_user(snd_ctl_file_t *file, snd_ctl_elem_value_t __user *_control) +static int snd_ctl_elem_write_user(struct snd_ctl_file *file, + struct snd_ctl_elem_value __user *_control) { - snd_ctl_elem_value_t *control; + struct snd_ctl_elem_value *control; int result; control = kmalloc(sizeof(*control), GFP_KERNEL); @@ -761,12 +772,13 @@ static int snd_ctl_elem_write_user(snd_ctl_file_t *file, snd_ctl_elem_value_t __ return result; } -static int snd_ctl_elem_lock(snd_ctl_file_t *file, snd_ctl_elem_id_t __user *_id) +static int snd_ctl_elem_lock(struct snd_ctl_file *file, + struct snd_ctl_elem_id __user *_id) { - snd_card_t *card = file->card; - snd_ctl_elem_id_t id; - snd_kcontrol_t *kctl; - snd_kcontrol_volatile_t *vd; + struct snd_card *card = file->card; + struct snd_ctl_elem_id id; + struct snd_kcontrol *kctl; + struct snd_kcontrol_volatile *vd; int result; if (copy_from_user(&id, _id, sizeof(id))) @@ -789,12 +801,13 @@ static int snd_ctl_elem_lock(snd_ctl_file_t *file, snd_ctl_elem_id_t __user *_id return result; } -static int snd_ctl_elem_unlock(snd_ctl_file_t *file, snd_ctl_elem_id_t __user *_id) +static int snd_ctl_elem_unlock(struct snd_ctl_file *file, + struct snd_ctl_elem_id __user *_id) { - snd_card_t *card = file->card; - snd_ctl_elem_id_t id; - snd_kcontrol_t *kctl; - snd_kcontrol_volatile_t *vd; + struct snd_card *card = file->card; + struct snd_ctl_elem_id id; + struct snd_kcontrol *kctl; + struct snd_kcontrol_volatile *vd; int result; if (copy_from_user(&id, _id, sizeof(id))) @@ -820,14 +833,15 @@ static int snd_ctl_elem_unlock(snd_ctl_file_t *file, snd_ctl_elem_id_t __user *_ } struct user_element { - snd_ctl_elem_info_t info; + struct snd_ctl_elem_info info; void *elem_data; /* element data */ unsigned long elem_data_size; /* size of element data in bytes */ void *priv_data; /* private data (like strings for enumerated type) */ unsigned long priv_data_size; /* size of private data in bytes */ }; -static int snd_ctl_elem_user_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ctl_elem_user_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { struct user_element *ue = kcontrol->private_data; @@ -835,7 +849,8 @@ static int snd_ctl_elem_user_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ctl_elem_user_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct user_element *ue = kcontrol->private_data; @@ -843,7 +858,8 @@ static int snd_ctl_elem_user_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ctl_elem_user_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int change; struct user_element *ue = kcontrol->private_data; @@ -854,15 +870,16 @@ static int snd_ctl_elem_user_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static void snd_ctl_elem_user_free(snd_kcontrol_t * kcontrol) +static void snd_ctl_elem_user_free(struct snd_kcontrol *kcontrol) { kfree(kcontrol->private_data); } -static int snd_ctl_elem_add(snd_ctl_file_t *file, snd_ctl_elem_info_t *info, int replace) +static int snd_ctl_elem_add(struct snd_ctl_file *file, + struct snd_ctl_elem_info *info, int replace) { - snd_card_t *card = file->card; - snd_kcontrol_t kctl, *_kctl; + struct snd_card *card = file->card; + struct snd_kcontrol kctl, *_kctl; unsigned int access; long private_size; struct user_element *ue; @@ -873,7 +890,8 @@ static int snd_ctl_elem_add(snd_ctl_file_t *file, snd_ctl_elem_info_t *info, int if (info->count > 1024) return -EINVAL; access = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : - (info->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE|SNDRV_CTL_ELEM_ACCESS_INACTIVE)); + (info->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE| + SNDRV_CTL_ELEM_ACCESS_INACTIVE)); info->id.numid = 0; memset(&kctl, 0, sizeof(kctl)); down_write(&card->controls_rwsem); @@ -921,7 +939,7 @@ static int snd_ctl_elem_add(snd_ctl_file_t *file, snd_ctl_elem_info_t *info, int return -EINVAL; break; case SNDRV_CTL_ELEM_TYPE_IEC958: - private_size = sizeof(struct sndrv_aes_iec958); + private_size = sizeof(struct snd_aes_iec958); if (info->count != 1) return -EINVAL; break; @@ -957,24 +975,26 @@ static int snd_ctl_elem_add(snd_ctl_file_t *file, snd_ctl_elem_info_t *info, int return 0; } -static int snd_ctl_elem_add_user(snd_ctl_file_t *file, snd_ctl_elem_info_t __user *_info, int replace) +static int snd_ctl_elem_add_user(struct snd_ctl_file *file, + struct snd_ctl_elem_info __user *_info, int replace) { - snd_ctl_elem_info_t info; + struct snd_ctl_elem_info info; if (copy_from_user(&info, _info, sizeof(info))) return -EFAULT; return snd_ctl_elem_add(file, &info, replace); } -static int snd_ctl_elem_remove(snd_ctl_file_t *file, snd_ctl_elem_id_t __user *_id) +static int snd_ctl_elem_remove(struct snd_ctl_file *file, + struct snd_ctl_elem_id __user *_id) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; int err; if (copy_from_user(&id, _id, sizeof(id))) return -EFAULT; err = snd_ctl_remove_unlocked_id(file, &id); if (! err) { - snd_card_t *card = file->card; + struct snd_card *card = file->card; down_write(&card->controls_rwsem); card->user_ctl_count--; up_write(&card->controls_rwsem); @@ -982,7 +1002,7 @@ static int snd_ctl_elem_remove(snd_ctl_file_t *file, snd_ctl_elem_id_t __user *_ return err; } -static int snd_ctl_subscribe_events(snd_ctl_file_t *file, int __user *ptr) +static int snd_ctl_subscribe_events(struct snd_ctl_file *file, int __user *ptr) { int subscribe; if (get_user(subscribe, ptr)) @@ -1007,7 +1027,7 @@ static int snd_ctl_subscribe_events(snd_ctl_file_t *file, int __user *ptr) /* * change the power state */ -static int snd_ctl_set_power_state(snd_card_t *card, unsigned int power_state) +static int snd_ctl_set_power_state(struct snd_card *card, unsigned int power_state) { switch (power_state) { case SNDRV_CTL_POWER_D0: @@ -1035,10 +1055,10 @@ static int snd_ctl_set_power_state(snd_card_t *card, unsigned int power_state) static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - snd_ctl_file_t *ctl; - snd_card_t *card; + struct snd_ctl_file *ctl; + struct snd_card *card; struct list_head *list; - snd_kctl_ioctl_t *p; + struct snd_kctl_ioctl *p; void __user *argp = (void __user *)arg; int __user *ip = argp; int err; @@ -1094,7 +1114,7 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg } down_read(&snd_ioctl_rwsem); list_for_each(list, &snd_control_ioctls) { - p = list_entry(list, snd_kctl_ioctl_t, list); + p = list_entry(list, struct snd_kctl_ioctl, list); err = p->fioctl(card, ctl, cmd, arg); if (err != -ENOIOCTLCMD) { up_read(&snd_ioctl_rwsem); @@ -1106,9 +1126,10 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg return -ENOTTY; } -static ssize_t snd_ctl_read(struct file *file, char __user *buffer, size_t count, loff_t * offset) +static ssize_t snd_ctl_read(struct file *file, char __user *buffer, + size_t count, loff_t * offset) { - snd_ctl_file_t *ctl; + struct snd_ctl_file *ctl; int err = 0; ssize_t result = 0; @@ -1116,12 +1137,12 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer, size_t count snd_assert(ctl != NULL && ctl->card != NULL, return -ENXIO); if (!ctl->subscribed) return -EBADFD; - if (count < sizeof(snd_ctl_event_t)) + if (count < sizeof(struct snd_ctl_event)) return -EINVAL; spin_lock_irq(&ctl->read_lock); - while (count >= sizeof(snd_ctl_event_t)) { - snd_ctl_event_t ev; - snd_kctl_event_t *kev; + while (count >= sizeof(struct snd_ctl_event)) { + struct snd_ctl_event ev; + struct snd_kctl_event *kev; while (list_empty(&ctl->events)) { wait_queue_t wait; if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) { @@ -1145,14 +1166,14 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer, size_t count list_del(&kev->list); spin_unlock_irq(&ctl->read_lock); kfree(kev); - if (copy_to_user(buffer, &ev, sizeof(snd_ctl_event_t))) { + if (copy_to_user(buffer, &ev, sizeof(struct snd_ctl_event))) { err = -EFAULT; goto __end; } spin_lock_irq(&ctl->read_lock); - buffer += sizeof(snd_ctl_event_t); - count -= sizeof(snd_ctl_event_t); - result += sizeof(snd_ctl_event_t); + buffer += sizeof(struct snd_ctl_event); + count -= sizeof(struct snd_ctl_event); + result += sizeof(struct snd_ctl_event); } __end_lock: spin_unlock_irq(&ctl->read_lock); @@ -1163,7 +1184,7 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer, size_t count static unsigned int snd_ctl_poll(struct file *file, poll_table * wait) { unsigned int mask; - snd_ctl_file_t *ctl; + struct snd_ctl_file *ctl; ctl = file->private_data; if (!ctl->subscribed) @@ -1183,9 +1204,9 @@ static unsigned int snd_ctl_poll(struct file *file, poll_table * wait) */ static int _snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head *lists) { - snd_kctl_ioctl_t *pn; + struct snd_kctl_ioctl *pn; - pn = kzalloc(sizeof(snd_kctl_ioctl_t), GFP_KERNEL); + pn = kzalloc(sizeof(struct snd_kctl_ioctl), GFP_KERNEL); if (pn == NULL) return -ENOMEM; pn->fioctl = fcn; @@ -1210,15 +1231,16 @@ int snd_ctl_register_ioctl_compat(snd_kctl_ioctl_func_t fcn) /* * de-register the device-specific control-ioctls. */ -static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head *lists) +static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn, + struct list_head *lists) { struct list_head *list; - snd_kctl_ioctl_t *p; + struct snd_kctl_ioctl *p; snd_assert(fcn != NULL, return -EINVAL); down_write(&snd_ioctl_rwsem); list_for_each(list, lists) { - p = list_entry(list, snd_kctl_ioctl_t, list); + p = list_entry(list, struct snd_kctl_ioctl, list); if (p->fioctl == fcn) { list_del(&p->list); up_write(&snd_ioctl_rwsem); @@ -1246,7 +1268,7 @@ int snd_ctl_unregister_ioctl_compat(snd_kctl_ioctl_func_t fcn) static int snd_ctl_fasync(int fd, struct file * file, int on) { - snd_ctl_file_t *ctl; + struct snd_ctl_file *ctl; int err; ctl = file->private_data; err = fasync_helper(fd, file, on, &ctl->fasync); @@ -1280,7 +1302,7 @@ static struct file_operations snd_ctl_f_ops = .fasync = snd_ctl_fasync, }; -static snd_minor_t snd_ctl_reg = +static struct snd_minor snd_ctl_reg = { .comment = "ctl", .f_ops = &snd_ctl_f_ops, @@ -1289,9 +1311,9 @@ static snd_minor_t snd_ctl_reg = /* * registration of the control device */ -static int snd_ctl_dev_register(snd_device_t *device) +static int snd_ctl_dev_register(struct snd_device *device) { - snd_card_t *card = device->device_data; + struct snd_card *card = device->device_data; int err, cardnum; char name[16]; @@ -1308,11 +1330,11 @@ static int snd_ctl_dev_register(snd_device_t *device) /* * disconnection of the control device */ -static int snd_ctl_dev_disconnect(snd_device_t *device) +static int snd_ctl_dev_disconnect(struct snd_device *device) { - snd_card_t *card = device->device_data; + struct snd_card *card = device->device_data; struct list_head *flist; - snd_ctl_file_t *ctl; + struct snd_ctl_file *ctl; down_read(&card->controls_rwsem); list_for_each(flist, &card->ctl_files) { @@ -1327,10 +1349,10 @@ static int snd_ctl_dev_disconnect(snd_device_t *device) /* * free all controls */ -static int snd_ctl_dev_free(snd_device_t *device) +static int snd_ctl_dev_free(struct snd_device *device) { - snd_card_t *card = device->device_data; - snd_kcontrol_t *control; + struct snd_card *card = device->device_data; + struct snd_kcontrol *control; down_write(&card->controls_rwsem); while (!list_empty(&card->controls)) { @@ -1344,9 +1366,9 @@ static int snd_ctl_dev_free(snd_device_t *device) /* * de-registration of the control device */ -static int snd_ctl_dev_unregister(snd_device_t *device) +static int snd_ctl_dev_unregister(struct snd_device *device) { - snd_card_t *card = device->device_data; + struct snd_card *card = device->device_data; int err, cardnum; snd_assert(card != NULL, return -ENXIO); @@ -1361,9 +1383,9 @@ static int snd_ctl_dev_unregister(snd_device_t *device) * create control core: * called from init.c */ -int snd_ctl_create(snd_card_t *card) +int snd_ctl_create(struct snd_card *card) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ctl_dev_free, .dev_register = snd_ctl_dev_register, .dev_disconnect = snd_ctl_dev_disconnect, diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c index 207c7de..418c6d4 100644 --- a/sound/core/control_compat.c +++ b/sound/core/control_compat.c @@ -22,7 +22,7 @@ #include <linux/compat.h> -struct sndrv_ctl_elem_list32 { +struct snd_ctl_elem_list32 { u32 offset; u32 space; u32 used; @@ -31,9 +31,10 @@ struct sndrv_ctl_elem_list32 { unsigned char reserved[50]; } /* don't set packed attribute here */; -static int snd_ctl_elem_list_compat(snd_card_t *card, struct sndrv_ctl_elem_list32 __user *data32) +static int snd_ctl_elem_list_compat(struct snd_card *card, + struct snd_ctl_elem_list32 __user *data32) { - struct sndrv_ctl_elem_list __user *data; + struct snd_ctl_elem_list __user *data; compat_caddr_t ptr; int err; @@ -60,8 +61,8 @@ static int snd_ctl_elem_list_compat(snd_card_t *card, struct sndrv_ctl_elem_list * it uses union, so the things are not easy.. */ -struct sndrv_ctl_elem_info32 { - struct sndrv_ctl_elem_id id; // the size of struct is same +struct snd_ctl_elem_info32 { + struct snd_ctl_elem_id id; // the size of struct is same s32 type; u32 access; u32 count; @@ -87,9 +88,10 @@ struct sndrv_ctl_elem_info32 { unsigned char reserved[64]; } __attribute__((packed)); -static int snd_ctl_elem_info_compat(snd_ctl_file_t *ctl, struct sndrv_ctl_elem_info32 __user *data32) +static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl, + struct snd_ctl_elem_info32 __user *data32) { - struct sndrv_ctl_elem_info *data; + struct snd_ctl_elem_info *data; int err; data = kzalloc(sizeof(*data), GFP_KERNEL); @@ -146,8 +148,8 @@ static int snd_ctl_elem_info_compat(snd_ctl_file_t *ctl, struct sndrv_ctl_elem_i } /* read / write */ -struct sndrv_ctl_elem_value32 { - struct sndrv_ctl_elem_id id; +struct snd_ctl_elem_value32 { + struct snd_ctl_elem_id id; unsigned int indirect; /* bit-field causes misalignment */ union { s32 integer[128]; @@ -161,10 +163,11 @@ struct sndrv_ctl_elem_value32 { /* get the value type and count of the control */ -static int get_ctl_type(snd_card_t *card, snd_ctl_elem_id_t *id, int *countp) +static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id, + int *countp) { - snd_kcontrol_t *kctl; - snd_ctl_elem_info_t info; + struct snd_kcontrol *kctl; + struct snd_ctl_elem_info info; int err; down_read(&card->controls_rwsem); @@ -193,15 +196,15 @@ static int get_elem_size(int type, int count) case SNDRV_CTL_ELEM_TYPE_BYTES: return 512; case SNDRV_CTL_ELEM_TYPE_IEC958: - return sizeof(struct sndrv_aes_iec958); + return sizeof(struct snd_aes_iec958); default: return -1; } } -static int copy_ctl_value_from_user(snd_card_t *card, - struct sndrv_ctl_elem_value *data, - struct sndrv_ctl_elem_value32 __user *data32, +static int copy_ctl_value_from_user(struct snd_card *card, + struct snd_ctl_elem_value *data, + struct snd_ctl_elem_value32 __user *data32, int *typep, int *countp) { int i, type, count, size; @@ -242,8 +245,8 @@ static int copy_ctl_value_from_user(snd_card_t *card, } /* restore the value to 32bit */ -static int copy_ctl_value_to_user(struct sndrv_ctl_elem_value32 __user *data32, - struct sndrv_ctl_elem_value *data, +static int copy_ctl_value_to_user(struct snd_ctl_elem_value32 __user *data32, + struct snd_ctl_elem_value *data, int type, int count) { int i, size; @@ -265,10 +268,10 @@ static int copy_ctl_value_to_user(struct sndrv_ctl_elem_value32 __user *data32, return 0; } -static int snd_ctl_elem_read_user_compat(snd_card_t *card, - struct sndrv_ctl_elem_value32 __user *data32) +static int snd_ctl_elem_read_user_compat(struct snd_card *card, + struct snd_ctl_elem_value32 __user *data32) { - struct sndrv_ctl_elem_value *data; + struct snd_ctl_elem_value *data; int err, type, count; data = kzalloc(sizeof(*data), GFP_KERNEL); @@ -285,10 +288,10 @@ static int snd_ctl_elem_read_user_compat(snd_card_t *card, return err; } -static int snd_ctl_elem_write_user_compat(snd_ctl_file_t *file, - struct sndrv_ctl_elem_value32 __user *data32) +static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file, + struct snd_ctl_elem_value32 __user *data32) { - struct sndrv_ctl_elem_value *data; + struct snd_ctl_elem_value *data; int err, type, count; data = kzalloc(sizeof(*data), GFP_KERNEL); @@ -306,11 +309,11 @@ static int snd_ctl_elem_write_user_compat(snd_ctl_file_t *file, } /* add or replace a user control */ -static int snd_ctl_elem_add_compat(snd_ctl_file_t *file, - struct sndrv_ctl_elem_info32 __user *data32, +static int snd_ctl_elem_add_compat(struct snd_ctl_file *file, + struct snd_ctl_elem_info32 __user *data32, int replace) { - struct sndrv_ctl_elem_info *data; + struct snd_ctl_elem_info *data; int err; data = kzalloc(sizeof(*data), GFP_KERNEL); @@ -355,17 +358,17 @@ static int snd_ctl_elem_add_compat(snd_ctl_file_t *file, } enum { - SNDRV_CTL_IOCTL_ELEM_LIST32 = _IOWR('U', 0x10, struct sndrv_ctl_elem_list32), - SNDRV_CTL_IOCTL_ELEM_INFO32 = _IOWR('U', 0x11, struct sndrv_ctl_elem_info32), - SNDRV_CTL_IOCTL_ELEM_READ32 = _IOWR('U', 0x12, struct sndrv_ctl_elem_value32), - SNDRV_CTL_IOCTL_ELEM_WRITE32 = _IOWR('U', 0x13, struct sndrv_ctl_elem_value32), - SNDRV_CTL_IOCTL_ELEM_ADD32 = _IOWR('U', 0x17, struct sndrv_ctl_elem_info32), - SNDRV_CTL_IOCTL_ELEM_REPLACE32 = _IOWR('U', 0x18, struct sndrv_ctl_elem_info32), + SNDRV_CTL_IOCTL_ELEM_LIST32 = _IOWR('U', 0x10, struct snd_ctl_elem_list32), + SNDRV_CTL_IOCTL_ELEM_INFO32 = _IOWR('U', 0x11, struct snd_ctl_elem_info32), + SNDRV_CTL_IOCTL_ELEM_READ32 = _IOWR('U', 0x12, struct snd_ctl_elem_value32), + SNDRV_CTL_IOCTL_ELEM_WRITE32 = _IOWR('U', 0x13, struct snd_ctl_elem_value32), + SNDRV_CTL_IOCTL_ELEM_ADD32 = _IOWR('U', 0x17, struct snd_ctl_elem_info32), + SNDRV_CTL_IOCTL_ELEM_REPLACE32 = _IOWR('U', 0x18, struct snd_ctl_elem_info32), }; static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) { - snd_ctl_file_t *ctl; + struct snd_ctl_file *ctl; struct list_head *list; void __user *argp = compat_ptr(arg); int err; @@ -398,7 +401,7 @@ static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, uns down_read(&snd_ioctl_rwsem); list_for_each(list, &snd_control_compat_ioctls) { - snd_kctl_ioctl_t *p = list_entry(list, snd_kctl_ioctl_t, list); + struct snd_kctl_ioctl *p = list_entry(list, struct snd_kctl_ioctl, list); if (p->fioctl) { err = p->fioctl(ctl->card, ctl, cmd, arg); if (err != -ENOIOCTLCMD) { -- cgit v1.1 From 53d2f744afc1fcb4fb68975a443fb66eb6c44da4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 13:56:05 +0100 Subject: [ALSA] Remove xxx_t typedefs: Timer Modules: RTC timer driver,Timer Midlevel Remove xxx_t typedefs from the core timer. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/timer.h | 94 ++++++------- sound/core/rtctimer.c | 22 +-- sound/core/timer.c | 346 +++++++++++++++++++++++----------------------- sound/core/timer_compat.c | 22 +-- 4 files changed, 235 insertions(+), 249 deletions(-) diff --git a/include/sound/timer.h b/include/sound/timer.h index b55f38a..5ece2bf 100644 --- a/include/sound/timer.h +++ b/include/sound/timer.h @@ -26,20 +26,6 @@ #include <sound/asound.h> #include <linux/interrupt.h> -typedef enum sndrv_timer_class snd_timer_class_t; -typedef enum sndrv_timer_slave_class snd_timer_slave_class_t; -typedef enum sndrv_timer_global snd_timer_global_t; -typedef struct sndrv_timer_id snd_timer_id_t; -typedef struct sndrv_timer_ginfo snd_timer_ginfo_t; -typedef struct sndrv_timer_gparams snd_timer_gparams_t; -typedef struct sndrv_timer_gstatus snd_timer_gstatus_t; -typedef struct sndrv_timer_select snd_timer_select_t; -typedef struct sndrv_timer_info snd_timer_info_t; -typedef struct sndrv_timer_params snd_timer_params_t; -typedef struct sndrv_timer_status snd_timer_status_t; -typedef struct sndrv_timer_read snd_timer_read_t; -typedef struct sndrv_timer_tread snd_timer_tread_t; - #define snd_timer_chip(timer) ((timer)->private_data) #define SNDRV_TIMER_DEVICES 16 @@ -64,11 +50,9 @@ typedef struct sndrv_timer_tread snd_timer_tread_t; #define SNDRV_TIMER_FLG_CHANGE 0x00000001 #define SNDRV_TIMER_FLG_RESCHED 0x00000002 /* need reschedule */ -typedef void (*snd_timer_callback_t) (snd_timer_instance_t * timeri, unsigned long ticks, unsigned long resolution); -typedef void (*snd_timer_ccallback_t) (snd_timer_instance_t * timeri, enum sndrv_timer_event event, - struct timespec * tstamp, unsigned long resolution); +struct snd_timer; -struct _snd_timer_hardware { +struct snd_timer_hardware { /* -- must be filled with low-level driver */ unsigned int flags; /* various flags */ unsigned long resolution; /* average timer resolution for one tick in nsec */ @@ -76,18 +60,18 @@ struct _snd_timer_hardware { unsigned long resolution_max; /* maximal resolution */ unsigned long ticks; /* max timer ticks per interrupt */ /* -- low-level functions -- */ - int (*open) (snd_timer_t * timer); - int (*close) (snd_timer_t * timer); - unsigned long (*c_resolution) (snd_timer_t * timer); - int (*start) (snd_timer_t * timer); - int (*stop) (snd_timer_t * timer); - int (*set_period) (snd_timer_t * timer, unsigned long period_num, unsigned long period_den); - int (*precise_resolution) (snd_timer_t * timer, unsigned long *num, unsigned long *den); + int (*open) (struct snd_timer * timer); + int (*close) (struct snd_timer * timer); + unsigned long (*c_resolution) (struct snd_timer * timer); + int (*start) (struct snd_timer * timer); + int (*stop) (struct snd_timer * timer); + int (*set_period) (struct snd_timer * timer, unsigned long period_num, unsigned long period_den); + int (*precise_resolution) (struct snd_timer * timer, unsigned long *num, unsigned long *den); }; -struct _snd_timer { - snd_timer_class_t tmr_class; - snd_card_t *card; +struct snd_timer { + int tmr_class; + struct snd_card *card; struct module *module; int tmr_device; int tmr_subdevice; @@ -97,8 +81,8 @@ struct _snd_timer { int running; /* running instances */ unsigned long sticks; /* schedule ticks */ void *private_data; - void (*private_free) (snd_timer_t *timer); - struct _snd_timer_hardware hw; + void (*private_free) (struct snd_timer *timer); + struct snd_timer_hardware hw; spinlock_t lock; struct list_head device_list; struct list_head open_list_head; @@ -108,49 +92,53 @@ struct _snd_timer { struct tasklet_struct task_queue; }; -struct _snd_timer_instance { - snd_timer_t * timer; +struct snd_timer_instance { + struct snd_timer *timer; char *owner; unsigned int flags; void *private_data; - void (*private_free) (snd_timer_instance_t *ti); - snd_timer_callback_t callback; - snd_timer_ccallback_t ccallback; + void (*private_free) (struct snd_timer_instance *ti); + void (*callback) (struct snd_timer_instance *timeri, + unsigned long ticks, unsigned long resolution); + void (*ccallback) (struct snd_timer_instance * timeri, + int event, + struct timespec * tstamp, + unsigned long resolution); void *callback_data; unsigned long ticks; /* auto-load ticks when expired */ unsigned long cticks; /* current ticks */ unsigned long pticks; /* accumulated ticks for callback */ unsigned long resolution; /* current resolution for tasklet */ unsigned long lost; /* lost ticks */ - snd_timer_slave_class_t slave_class; + int slave_class; unsigned int slave_id; struct list_head open_list; struct list_head active_list; struct list_head ack_list; struct list_head slave_list_head; struct list_head slave_active_head; - snd_timer_instance_t *master; + struct snd_timer_instance *master; }; /* * Registering */ -extern int snd_timer_new(snd_card_t *card, char *id, snd_timer_id_t *tid, snd_timer_t ** rtimer); -extern void snd_timer_notify(snd_timer_t *timer, enum sndrv_timer_event event, struct timespec *tstamp); -extern int snd_timer_global_new(char *id, int device, snd_timer_t **rtimer); -extern int snd_timer_global_free(snd_timer_t *timer); -extern int snd_timer_global_register(snd_timer_t *timer); -extern int snd_timer_global_unregister(snd_timer_t *timer); - -extern int snd_timer_open(snd_timer_instance_t ** ti, char *owner, snd_timer_id_t *tid, unsigned int slave_id); -extern int snd_timer_close(snd_timer_instance_t * timeri); -extern unsigned long snd_timer_resolution(snd_timer_instance_t * timeri); -extern int snd_timer_start(snd_timer_instance_t * timeri, unsigned int ticks); -extern int snd_timer_stop(snd_timer_instance_t * timeri); -extern int snd_timer_continue(snd_timer_instance_t * timeri); -extern int snd_timer_pause(snd_timer_instance_t * timeri); - -extern void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left); +int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, struct snd_timer **rtimer); +void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp); +int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer); +int snd_timer_global_free(struct snd_timer *timer); +int snd_timer_global_register(struct snd_timer *timer); +int snd_timer_global_unregister(struct snd_timer *timer); + +int snd_timer_open(struct snd_timer_instance **ti, char *owner, struct snd_timer_id *tid, unsigned int slave_id); +int snd_timer_close(struct snd_timer_instance *timeri); +unsigned long snd_timer_resolution(struct snd_timer_instance *timeri); +int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks); +int snd_timer_stop(struct snd_timer_instance *timeri); +int snd_timer_continue(struct snd_timer_instance *timeri); +int snd_timer_pause(struct snd_timer_instance *timeri); + +void snd_timer_interrupt(struct snd_timer *timer, unsigned long ticks_left); #endif /* __SOUND_TIMER_H */ diff --git a/sound/core/rtctimer.c b/sound/core/rtctimer.c index c3c1856..84704cc 100644 --- a/sound/core/rtctimer.c +++ b/sound/core/rtctimer.c @@ -40,16 +40,16 @@ /* * prototypes */ -static int rtctimer_open(snd_timer_t *t); -static int rtctimer_close(snd_timer_t *t); -static int rtctimer_start(snd_timer_t *t); -static int rtctimer_stop(snd_timer_t *t); +static int rtctimer_open(struct snd_timer *t); +static int rtctimer_close(struct snd_timer *t); +static int rtctimer_start(struct snd_timer *t); +static int rtctimer_stop(struct snd_timer *t); /* * The hardware dependent description for this timer. */ -static struct _snd_timer_hardware rtc_hw = { +static struct snd_timer_hardware rtc_hw = { .flags = SNDRV_TIMER_HW_FIRST|SNDRV_TIMER_HW_AUTO, .ticks = 100000000L, /* FIXME: XXX */ .open = rtctimer_open, @@ -59,12 +59,12 @@ static struct _snd_timer_hardware rtc_hw = { }; static int rtctimer_freq = RTC_FREQ; /* frequency */ -static snd_timer_t *rtctimer; +static struct snd_timer *rtctimer; static rtc_task_t rtc_task; static int -rtctimer_open(snd_timer_t *t) +rtctimer_open(struct snd_timer *t) { int err; @@ -76,7 +76,7 @@ rtctimer_open(snd_timer_t *t) } static int -rtctimer_close(snd_timer_t *t) +rtctimer_close(struct snd_timer *t) { rtc_task_t *rtc = t->private_data; if (rtc) { @@ -87,7 +87,7 @@ rtctimer_close(snd_timer_t *t) } static int -rtctimer_start(snd_timer_t *timer) +rtctimer_start(struct snd_timer *timer) { rtc_task_t *rtc = timer->private_data; snd_assert(rtc != NULL, return -EINVAL); @@ -97,7 +97,7 @@ rtctimer_start(snd_timer_t *timer) } static int -rtctimer_stop(snd_timer_t *timer) +rtctimer_stop(struct snd_timer *timer) { rtc_task_t *rtc = timer->private_data; snd_assert(rtc != NULL, return -EINVAL); @@ -120,7 +120,7 @@ static void rtctimer_interrupt(void *private_data) static int __init rtctimer_init(void) { int err; - snd_timer_t *timer; + struct snd_timer *timer; if (rtctimer_freq < 2 || rtctimer_freq > 8192 || (rtctimer_freq & (rtctimer_freq - 1)) != 0) { diff --git a/sound/core/timer.c b/sound/core/timer.c index 1b90a38..18d43a0 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -53,8 +53,8 @@ MODULE_LICENSE("GPL"); module_param(timer_limit, int, 0444); MODULE_PARM_DESC(timer_limit, "Maximum global timers in system."); -typedef struct { - snd_timer_instance_t *timeri; +struct snd_timer_user { + struct snd_timer_instance *timeri; int tread; /* enhanced read with timestamps and events */ unsigned long ticks; unsigned long overrun; @@ -62,8 +62,8 @@ typedef struct { int qtail; int qused; int queue_size; - snd_timer_read_t *queue; - snd_timer_tread_t *tqueue; + struct snd_timer_read *queue; + struct snd_timer_tread *tqueue; spinlock_t qlock; unsigned long last_resolution; unsigned int filter; @@ -71,7 +71,7 @@ typedef struct { wait_queue_head_t qchange_sleep; struct fasync_struct *fasync; struct semaphore tread_sem; -} snd_timer_user_t; +}; /* list of timers */ static LIST_HEAD(snd_timer_list); @@ -84,21 +84,21 @@ static DEFINE_SPINLOCK(slave_active_lock); static DECLARE_MUTEX(register_mutex); -static int snd_timer_free(snd_timer_t *timer); -static int snd_timer_dev_free(snd_device_t *device); -static int snd_timer_dev_register(snd_device_t *device); -static int snd_timer_dev_unregister(snd_device_t *device); +static int snd_timer_free(struct snd_timer *timer); +static int snd_timer_dev_free(struct snd_device *device); +static int snd_timer_dev_register(struct snd_device *device); +static int snd_timer_dev_unregister(struct snd_device *device); -static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left); +static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_left); /* * create a timer instance with the given owner string. * when timer is not NULL, increments the module counter */ -static snd_timer_instance_t *snd_timer_instance_new(char *owner, - snd_timer_t *timer) +static struct snd_timer_instance *snd_timer_instance_new(char *owner, + struct snd_timer *timer) { - snd_timer_instance_t *timeri; + struct snd_timer_instance *timeri; timeri = kzalloc(sizeof(*timeri), GFP_KERNEL); if (timeri == NULL) return NULL; @@ -126,13 +126,13 @@ static snd_timer_instance_t *snd_timer_instance_new(char *owner, /* * find a timer instance from the given timer id */ -static snd_timer_t *snd_timer_find(snd_timer_id_t *tid) +static struct snd_timer *snd_timer_find(struct snd_timer_id *tid) { - snd_timer_t *timer = NULL; + struct snd_timer *timer = NULL; struct list_head *p; list_for_each(p, &snd_timer_list) { - timer = list_entry(p, snd_timer_t, device_list); + timer = list_entry(p, struct snd_timer, device_list); if (timer->tmr_class != tid->dev_class) continue; @@ -152,7 +152,7 @@ static snd_timer_t *snd_timer_find(snd_timer_id_t *tid) #ifdef CONFIG_KMOD -static void snd_timer_request(snd_timer_id_t *tid) +static void snd_timer_request(struct snd_timer_id *tid) { if (! current->fs->root) return; @@ -179,17 +179,17 @@ static void snd_timer_request(snd_timer_id_t *tid) * * call this with register_mutex down. */ -static void snd_timer_check_slave(snd_timer_instance_t *slave) +static void snd_timer_check_slave(struct snd_timer_instance *slave) { - snd_timer_t *timer; - snd_timer_instance_t *master; + struct snd_timer *timer; + struct snd_timer_instance *master; struct list_head *p, *q; /* FIXME: it's really dumb to look up all entries.. */ list_for_each(p, &snd_timer_list) { - timer = list_entry(p, snd_timer_t, device_list); + timer = list_entry(p, struct snd_timer, device_list); list_for_each(q, &timer->open_list_head) { - master = list_entry(q, snd_timer_instance_t, open_list); + master = list_entry(q, struct snd_timer_instance, open_list); if (slave->slave_class == master->slave_class && slave->slave_id == master->slave_id) { list_del(&slave->open_list); @@ -211,14 +211,14 @@ static void snd_timer_check_slave(snd_timer_instance_t *slave) * * call this with register_mutex down. */ -static void snd_timer_check_master(snd_timer_instance_t *master) +static void snd_timer_check_master(struct snd_timer_instance *master) { - snd_timer_instance_t *slave; + struct snd_timer_instance *slave; struct list_head *p, *n; /* check all pending slaves */ list_for_each_safe(p, n, &snd_timer_slave_list) { - slave = list_entry(p, snd_timer_instance_t, open_list); + slave = list_entry(p, struct snd_timer_instance, open_list); if (slave->slave_class == master->slave_class && slave->slave_id == master->slave_id) { list_del(p); @@ -238,12 +238,12 @@ static void snd_timer_check_master(snd_timer_instance_t *master) * open a timer instance * when opening a master, the slave id must be here given. */ -int snd_timer_open(snd_timer_instance_t **ti, - char *owner, snd_timer_id_t *tid, +int snd_timer_open(struct snd_timer_instance **ti, + char *owner, struct snd_timer_id *tid, unsigned int slave_id) { - snd_timer_t *timer; - snd_timer_instance_t *timeri = NULL; + struct snd_timer *timer; + struct snd_timer_instance *timeri = NULL; if (tid->dev_class == SNDRV_TIMER_CLASS_SLAVE) { /* open a slave instance */ @@ -285,7 +285,7 @@ int snd_timer_open(snd_timer_instance_t **ti, } if (!list_empty(&timer->open_list_head)) { timeri = list_entry(timer->open_list_head.next, - snd_timer_instance_t, open_list); + struct snd_timer_instance, open_list); if (timeri->flags & SNDRV_TIMER_IFLG_EXCLUSIVE) { up(®ister_mutex); return -EBUSY; @@ -307,17 +307,17 @@ int snd_timer_open(snd_timer_instance_t **ti, return 0; } -static int _snd_timer_stop(snd_timer_instance_t * timeri, - int keep_flag, enum sndrv_timer_event event); +static int _snd_timer_stop(struct snd_timer_instance *timeri, + int keep_flag, int event); /* * close a timer instance */ -int snd_timer_close(snd_timer_instance_t * timeri) +int snd_timer_close(struct snd_timer_instance *timeri) { - snd_timer_t *timer = NULL; + struct snd_timer *timer = NULL; struct list_head *p, *n; - snd_timer_instance_t *slave; + struct snd_timer_instance *slave; snd_assert(timeri != NULL, return -ENXIO); @@ -353,7 +353,7 @@ int snd_timer_close(snd_timer_instance_t * timeri) timer->hw.close(timer); /* remove slave links */ list_for_each_safe(p, n, &timeri->slave_list_head) { - slave = list_entry(p, snd_timer_instance_t, open_list); + slave = list_entry(p, struct snd_timer_instance, open_list); spin_lock_irq(&slave_active_lock); _snd_timer_stop(slave, 1, SNDRV_TIMER_EVENT_RESOLUTION); list_del(p); @@ -373,9 +373,9 @@ int snd_timer_close(snd_timer_instance_t * timeri) return 0; } -unsigned long snd_timer_resolution(snd_timer_instance_t * timeri) +unsigned long snd_timer_resolution(struct snd_timer_instance *timeri) { - snd_timer_t * timer; + struct snd_timer * timer; if (timeri == NULL) return 0; @@ -387,13 +387,12 @@ unsigned long snd_timer_resolution(snd_timer_instance_t * timeri) return 0; } -static void snd_timer_notify1(snd_timer_instance_t *ti, - enum sndrv_timer_event event) +static void snd_timer_notify1(struct snd_timer_instance *ti, int event) { - snd_timer_t *timer; + struct snd_timer *timer; unsigned long flags; unsigned long resolution = 0; - snd_timer_instance_t *ts; + struct snd_timer_instance *ts; struct list_head *n; struct timespec tstamp; @@ -414,14 +413,14 @@ static void snd_timer_notify1(snd_timer_instance_t *ti, return; spin_lock_irqsave(&timer->lock, flags); list_for_each(n, &ti->slave_active_head) { - ts = list_entry(n, snd_timer_instance_t, active_list); + ts = list_entry(n, struct snd_timer_instance, active_list); if (ts->ccallback) ts->ccallback(ti, event + 100, &tstamp, resolution); } spin_unlock_irqrestore(&timer->lock, flags); } -static int snd_timer_start1(snd_timer_t *timer, snd_timer_instance_t *timeri, +static int snd_timer_start1(struct snd_timer *timer, struct snd_timer_instance *timeri, unsigned long sticks) { list_del(&timeri->active_list); @@ -442,7 +441,7 @@ static int snd_timer_start1(snd_timer_t *timer, snd_timer_instance_t *timeri, } } -static int snd_timer_start_slave(snd_timer_instance_t *timeri) +static int snd_timer_start_slave(struct snd_timer_instance *timeri) { unsigned long flags; @@ -458,9 +457,9 @@ static int snd_timer_start_slave(snd_timer_instance_t *timeri) /* * start the timer instance */ -int snd_timer_start(snd_timer_instance_t * timeri, unsigned int ticks) +int snd_timer_start(struct snd_timer_instance *timeri, unsigned int ticks) { - snd_timer_t *timer; + struct snd_timer *timer; int result = -EINVAL; unsigned long flags; @@ -483,10 +482,10 @@ int snd_timer_start(snd_timer_instance_t * timeri, unsigned int ticks) return result; } -static int _snd_timer_stop(snd_timer_instance_t * timeri, - int keep_flag, enum sndrv_timer_event event) +static int _snd_timer_stop(struct snd_timer_instance * timeri, + int keep_flag, int event) { - snd_timer_t *timer; + struct snd_timer *timer; unsigned long flags; snd_assert(timeri != NULL, return -ENXIO); @@ -532,9 +531,9 @@ static int _snd_timer_stop(snd_timer_instance_t * timeri, * * do not call this from the timer callback! */ -int snd_timer_stop(snd_timer_instance_t * timeri) +int snd_timer_stop(struct snd_timer_instance *timeri) { - snd_timer_t *timer; + struct snd_timer *timer; unsigned long flags; int err; @@ -552,9 +551,9 @@ int snd_timer_stop(snd_timer_instance_t * timeri) /* * start again.. the tick is kept. */ -int snd_timer_continue(snd_timer_instance_t * timeri) +int snd_timer_continue(struct snd_timer_instance *timeri) { - snd_timer_t *timer; + struct snd_timer *timer; int result = -EINVAL; unsigned long flags; @@ -578,7 +577,7 @@ int snd_timer_continue(snd_timer_instance_t * timeri) /* * pause.. remember the ticks left */ -int snd_timer_pause(snd_timer_instance_t * timeri) +int snd_timer_pause(struct snd_timer_instance * timeri) { return _snd_timer_stop(timeri, 0, SNDRV_TIMER_EVENT_PAUSE); } @@ -589,14 +588,14 @@ int snd_timer_pause(snd_timer_instance_t * timeri) * start pending instances and check the scheduling ticks. * when the scheduling ticks is changed set CHANGE flag to reprogram the timer. */ -static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left) +static void snd_timer_reschedule(struct snd_timer * timer, unsigned long ticks_left) { - snd_timer_instance_t *ti; + struct snd_timer_instance *ti; unsigned long ticks = ~0UL; struct list_head *p; list_for_each(p, &timer->active_list_head) { - ti = list_entry(p, snd_timer_instance_t, active_list); + ti = list_entry(p, struct snd_timer_instance, active_list); if (ti->flags & SNDRV_TIMER_IFLG_START) { ti->flags &= ~SNDRV_TIMER_IFLG_START; ti->flags |= SNDRV_TIMER_IFLG_RUNNING; @@ -624,8 +623,8 @@ static void snd_timer_reschedule(snd_timer_t * timer, unsigned long ticks_left) */ static void snd_timer_tasklet(unsigned long arg) { - snd_timer_t *timer = (snd_timer_t *) arg; - snd_timer_instance_t *ti; + struct snd_timer *timer = (struct snd_timer *) arg; + struct snd_timer_instance *ti; struct list_head *p; unsigned long resolution, ticks; @@ -633,7 +632,7 @@ static void snd_timer_tasklet(unsigned long arg) /* now process all callbacks */ while (!list_empty(&timer->sack_list_head)) { p = timer->sack_list_head.next; /* get first item */ - ti = list_entry(p, snd_timer_instance_t, ack_list); + ti = list_entry(p, struct snd_timer_instance, ack_list); /* remove from ack_list and make empty */ list_del_init(p); @@ -658,9 +657,9 @@ static void snd_timer_tasklet(unsigned long arg) * ticks_left is usually equal to timer->sticks. * */ -void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left) +void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) { - snd_timer_instance_t *ti, *ts; + struct snd_timer_instance *ti, *ts; unsigned long resolution, ticks; struct list_head *p, *q, *n, *ack_list_head; int use_tasklet = 0; @@ -682,7 +681,7 @@ void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left) * is called. */ list_for_each_safe(p, n, &timer->active_list_head) { - ti = list_entry(p, snd_timer_instance_t, active_list); + ti = list_entry(p, struct snd_timer_instance, active_list); if (!(ti->flags & SNDRV_TIMER_IFLG_RUNNING)) continue; ti->pticks += ticks_left; @@ -708,7 +707,7 @@ void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left) if (list_empty(&ti->ack_list)) list_add_tail(&ti->ack_list, ack_list_head); list_for_each(q, &ti->slave_active_head) { - ts = list_entry(q, snd_timer_instance_t, active_list); + ts = list_entry(q, struct snd_timer_instance, active_list); ts->pticks = ti->pticks; ts->resolution = resolution; if (list_empty(&ts->ack_list)) @@ -735,7 +734,7 @@ void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left) /* now process all fast callbacks */ while (!list_empty(&timer->ack_list_head)) { p = timer->ack_list_head.next; /* get first item */ - ti = list_entry(p, snd_timer_instance_t, ack_list); + ti = list_entry(p, struct snd_timer_instance, ack_list); /* remove from ack_list and make empty */ list_del_init(p); @@ -763,12 +762,12 @@ void snd_timer_interrupt(snd_timer_t * timer, unsigned long ticks_left) */ -int snd_timer_new(snd_card_t *card, char *id, snd_timer_id_t *tid, - snd_timer_t **rtimer) +int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, + struct snd_timer **rtimer) { - snd_timer_t *timer; + struct snd_timer *timer; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_timer_dev_free, .dev_register = snd_timer_dev_register, .dev_unregister = snd_timer_dev_unregister @@ -806,7 +805,7 @@ int snd_timer_new(snd_card_t *card, char *id, snd_timer_id_t *tid, return 0; } -static int snd_timer_free(snd_timer_t *timer) +static int snd_timer_free(struct snd_timer *timer) { snd_assert(timer != NULL, return -ENXIO); if (timer->private_free) @@ -815,16 +814,16 @@ static int snd_timer_free(snd_timer_t *timer) return 0; } -static int snd_timer_dev_free(snd_device_t *device) +static int snd_timer_dev_free(struct snd_device *device) { - snd_timer_t *timer = device->device_data; + struct snd_timer *timer = device->device_data; return snd_timer_free(timer); } -static int snd_timer_dev_register(snd_device_t *dev) +static int snd_timer_dev_register(struct snd_device *dev) { - snd_timer_t *timer = dev->device_data; - snd_timer_t *timer1; + struct snd_timer *timer = dev->device_data; + struct snd_timer *timer1; struct list_head *p; snd_assert(timer != NULL && timer->hw.start != NULL && @@ -835,7 +834,7 @@ static int snd_timer_dev_register(snd_device_t *dev) down(®ister_mutex); list_for_each(p, &snd_timer_list) { - timer1 = list_entry(p, snd_timer_t, device_list); + timer1 = list_entry(p, struct snd_timer, device_list); if (timer1->tmr_class > timer->tmr_class) break; if (timer1->tmr_class < timer->tmr_class) @@ -863,10 +862,10 @@ static int snd_timer_dev_register(snd_device_t *dev) return 0; } -static int snd_timer_unregister(snd_timer_t *timer) +static int snd_timer_unregister(struct snd_timer *timer) { struct list_head *p, *n; - snd_timer_instance_t *ti; + struct snd_timer_instance *ti; snd_assert(timer != NULL, return -ENXIO); down(®ister_mutex); @@ -874,7 +873,7 @@ static int snd_timer_unregister(snd_timer_t *timer) snd_printk(KERN_WARNING "timer 0x%lx is busy?\n", (long)timer); list_for_each_safe(p, n, &timer->open_list_head) { list_del_init(p); - ti = list_entry(p, snd_timer_instance_t, open_list); + ti = list_entry(p, struct snd_timer_instance, open_list); ti->timer = NULL; } } @@ -883,18 +882,17 @@ static int snd_timer_unregister(snd_timer_t *timer) return snd_timer_free(timer); } -static int snd_timer_dev_unregister(snd_device_t *device) +static int snd_timer_dev_unregister(struct snd_device *device) { - snd_timer_t *timer = device->device_data; + struct snd_timer *timer = device->device_data; return snd_timer_unregister(timer); } -void snd_timer_notify(snd_timer_t *timer, enum sndrv_timer_event event, - struct timespec *tstamp) +void snd_timer_notify(struct snd_timer *timer, int event, struct timespec *tstamp) { unsigned long flags; unsigned long resolution = 0; - snd_timer_instance_t *ti, *ts; + struct snd_timer_instance *ti, *ts; struct list_head *p, *n; if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) @@ -911,11 +909,11 @@ void snd_timer_notify(snd_timer_t *timer, enum sndrv_timer_event event, resolution = timer->hw.resolution; } list_for_each(p, &timer->active_list_head) { - ti = list_entry(p, snd_timer_instance_t, active_list); + ti = list_entry(p, struct snd_timer_instance, active_list); if (ti->ccallback) ti->ccallback(ti, event, tstamp, resolution); list_for_each(n, &ti->slave_active_head) { - ts = list_entry(n, snd_timer_instance_t, active_list); + ts = list_entry(n, struct snd_timer_instance, active_list); if (ts->ccallback) ts->ccallback(ts, event, tstamp, resolution); } @@ -926,9 +924,9 @@ void snd_timer_notify(snd_timer_t *timer, enum sndrv_timer_event event, /* * exported functions for global timers */ -int snd_timer_global_new(char *id, int device, snd_timer_t **rtimer) +int snd_timer_global_new(char *id, int device, struct snd_timer **rtimer) { - snd_timer_id_t tid; + struct snd_timer_id tid; tid.dev_class = SNDRV_TIMER_CLASS_GLOBAL; tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE; @@ -938,21 +936,21 @@ int snd_timer_global_new(char *id, int device, snd_timer_t **rtimer) return snd_timer_new(NULL, id, &tid, rtimer); } -int snd_timer_global_free(snd_timer_t *timer) +int snd_timer_global_free(struct snd_timer *timer) { return snd_timer_free(timer); } -int snd_timer_global_register(snd_timer_t *timer) +int snd_timer_global_register(struct snd_timer *timer) { - snd_device_t dev; + struct snd_device dev; memset(&dev, 0, sizeof(dev)); dev.device_data = timer; return snd_timer_dev_register(&dev); } -int snd_timer_global_unregister(snd_timer_t *timer) +int snd_timer_global_unregister(struct snd_timer *timer) { return snd_timer_unregister(timer); } @@ -971,7 +969,7 @@ struct snd_timer_system_private { static void snd_timer_s_function(unsigned long data) { - snd_timer_t *timer = (snd_timer_t *)data; + struct snd_timer *timer = (struct snd_timer *)data; struct snd_timer_system_private *priv = timer->private_data; unsigned long jiff = jiffies; if (time_after(jiff, priv->last_expires)) @@ -979,7 +977,7 @@ static void snd_timer_s_function(unsigned long data) snd_timer_interrupt(timer, (long)jiff - (long)priv->last_jiffies); } -static int snd_timer_s_start(snd_timer_t * timer) +static int snd_timer_s_start(struct snd_timer * timer) { struct snd_timer_system_private *priv; unsigned long njiff; @@ -998,7 +996,7 @@ static int snd_timer_s_start(snd_timer_t * timer) return 0; } -static int snd_timer_s_stop(snd_timer_t * timer) +static int snd_timer_s_stop(struct snd_timer * timer) { struct snd_timer_system_private *priv; unsigned long jiff; @@ -1013,7 +1011,7 @@ static int snd_timer_s_stop(snd_timer_t * timer) return 0; } -static struct _snd_timer_hardware snd_timer_system = +static struct snd_timer_hardware snd_timer_system = { .flags = SNDRV_TIMER_HW_FIRST | SNDRV_TIMER_HW_TASKLET, .resolution = 1000000000L / HZ, @@ -1022,14 +1020,14 @@ static struct _snd_timer_hardware snd_timer_system = .stop = snd_timer_s_stop }; -static void snd_timer_free_system(snd_timer_t *timer) +static void snd_timer_free_system(struct snd_timer *timer) { kfree(timer->private_data); } static int snd_timer_register_system(void) { - snd_timer_t *timer; + struct snd_timer *timer; struct snd_timer_system_private *priv; int err; @@ -1055,17 +1053,17 @@ static int snd_timer_register_system(void) * Info interface */ -static void snd_timer_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_timer_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { unsigned long flags; - snd_timer_t *timer; - snd_timer_instance_t *ti; + struct snd_timer *timer; + struct snd_timer_instance *ti; struct list_head *p, *q; down(®ister_mutex); list_for_each(p, &snd_timer_list) { - timer = list_entry(p, snd_timer_t, device_list); + timer = list_entry(p, struct snd_timer, device_list); switch (timer->tmr_class) { case SNDRV_TIMER_CLASS_GLOBAL: snd_iprintf(buffer, "G%i: ", timer->tmr_device); @@ -1094,7 +1092,7 @@ static void snd_timer_proc_read(snd_info_entry_t *entry, snd_iprintf(buffer, "\n"); spin_lock_irqsave(&timer->lock, flags); list_for_each(q, &timer->open_list_head) { - ti = list_entry(q, snd_timer_instance_t, open_list); + ti = list_entry(q, struct snd_timer_instance, open_list); snd_iprintf(buffer, " Client %s : %s\n", ti->owner ? ti->owner : "unknown", ti->flags & (SNDRV_TIMER_IFLG_START | @@ -1110,12 +1108,12 @@ static void snd_timer_proc_read(snd_info_entry_t *entry, * USER SPACE interface */ -static void snd_timer_user_interrupt(snd_timer_instance_t *timeri, +static void snd_timer_user_interrupt(struct snd_timer_instance *timeri, unsigned long resolution, unsigned long ticks) { - snd_timer_user_t *tu = timeri->callback_data; - snd_timer_read_t *r; + struct snd_timer_user *tu = timeri->callback_data; + struct snd_timer_read *r; int prev; spin_lock(&tu->qlock); @@ -1142,8 +1140,8 @@ static void snd_timer_user_interrupt(snd_timer_instance_t *timeri, wake_up(&tu->qchange_sleep); } -static void snd_timer_user_append_to_tqueue(snd_timer_user_t *tu, - snd_timer_tread_t *tread) +static void snd_timer_user_append_to_tqueue(struct snd_timer_user *tu, + struct snd_timer_tread *tread) { if (tu->qused >= tu->queue_size) { tu->overrun++; @@ -1154,13 +1152,13 @@ static void snd_timer_user_append_to_tqueue(snd_timer_user_t *tu, } } -static void snd_timer_user_ccallback(snd_timer_instance_t *timeri, - enum sndrv_timer_event event, +static void snd_timer_user_ccallback(struct snd_timer_instance *timeri, + int event, struct timespec *tstamp, unsigned long resolution) { - snd_timer_user_t *tu = timeri->callback_data; - snd_timer_tread_t r1; + struct snd_timer_user *tu = timeri->callback_data; + struct snd_timer_tread r1; if (event >= SNDRV_TIMER_EVENT_START && event <= SNDRV_TIMER_EVENT_PAUSE) @@ -1177,12 +1175,12 @@ static void snd_timer_user_ccallback(snd_timer_instance_t *timeri, wake_up(&tu->qchange_sleep); } -static void snd_timer_user_tinterrupt(snd_timer_instance_t *timeri, +static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri, unsigned long resolution, unsigned long ticks) { - snd_timer_user_t *tu = timeri->callback_data; - snd_timer_tread_t *r, r1; + struct snd_timer_user *tu = timeri->callback_data; + struct snd_timer_tread *r, r1; struct timespec tstamp; int prev, append = 0; @@ -1233,7 +1231,7 @@ static void snd_timer_user_tinterrupt(snd_timer_instance_t *timeri, static int snd_timer_user_open(struct inode *inode, struct file *file) { - snd_timer_user_t *tu; + struct snd_timer_user *tu; tu = kzalloc(sizeof(*tu), GFP_KERNEL); if (tu == NULL) @@ -1243,7 +1241,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file) init_MUTEX(&tu->tread_sem); tu->ticks = 1; tu->queue_size = 128; - tu->queue = kmalloc(tu->queue_size * sizeof(snd_timer_read_t), + tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read), GFP_KERNEL); if (tu->queue == NULL) { kfree(tu); @@ -1255,7 +1253,7 @@ static int snd_timer_user_open(struct inode *inode, struct file *file) static int snd_timer_user_release(struct inode *inode, struct file *file) { - snd_timer_user_t *tu; + struct snd_timer_user *tu; if (file->private_data) { tu = file->private_data; @@ -1270,7 +1268,7 @@ static int snd_timer_user_release(struct inode *inode, struct file *file) return 0; } -static void snd_timer_user_zero_id(snd_timer_id_t *id) +static void snd_timer_user_zero_id(struct snd_timer_id *id) { id->dev_class = SNDRV_TIMER_CLASS_NONE; id->dev_sclass = SNDRV_TIMER_SCLASS_NONE; @@ -1279,7 +1277,7 @@ static void snd_timer_user_zero_id(snd_timer_id_t *id) id->subdevice = -1; } -static void snd_timer_user_copy_id(snd_timer_id_t *id, snd_timer_t *timer) +static void snd_timer_user_copy_id(struct snd_timer_id *id, struct snd_timer *timer) { id->dev_class = timer->tmr_class; id->dev_sclass = SNDRV_TIMER_SCLASS_NONE; @@ -1288,10 +1286,10 @@ static void snd_timer_user_copy_id(snd_timer_id_t *id, snd_timer_t *timer) id->subdevice = timer->tmr_subdevice; } -static int snd_timer_user_next_device(snd_timer_id_t __user *_tid) +static int snd_timer_user_next_device(struct snd_timer_id __user *_tid) { - snd_timer_id_t id; - snd_timer_t *timer; + struct snd_timer_id id; + struct snd_timer *timer; struct list_head *p; if (copy_from_user(&id, _tid, sizeof(id))) @@ -1302,7 +1300,7 @@ static int snd_timer_user_next_device(snd_timer_id_t __user *_tid) snd_timer_user_zero_id(&id); else { timer = list_entry(snd_timer_list.next, - snd_timer_t, device_list); + struct snd_timer, device_list); snd_timer_user_copy_id(&id, timer); } } else { @@ -1310,7 +1308,7 @@ static int snd_timer_user_next_device(snd_timer_id_t __user *_tid) case SNDRV_TIMER_CLASS_GLOBAL: id.device = id.device < 0 ? 0 : id.device + 1; list_for_each(p, &snd_timer_list) { - timer = list_entry(p, snd_timer_t, device_list); + timer = list_entry(p, struct snd_timer, device_list); if (timer->tmr_class > SNDRV_TIMER_CLASS_GLOBAL) { snd_timer_user_copy_id(&id, timer); break; @@ -1343,7 +1341,7 @@ static int snd_timer_user_next_device(snd_timer_id_t __user *_tid) } } list_for_each(p, &snd_timer_list) { - timer = list_entry(p, snd_timer_t, device_list); + timer = list_entry(p, struct snd_timer, device_list); if (timer->tmr_class > id.dev_class) { snd_timer_user_copy_id(&id, timer); break; @@ -1385,11 +1383,11 @@ static int snd_timer_user_next_device(snd_timer_id_t __user *_tid) } static int snd_timer_user_ginfo(struct file *file, - snd_timer_ginfo_t __user *_ginfo) + struct snd_timer_ginfo __user *_ginfo) { - snd_timer_ginfo_t *ginfo; - snd_timer_id_t tid; - snd_timer_t *t; + struct snd_timer_ginfo *ginfo; + struct snd_timer_id tid; + struct snd_timer *t; struct list_head *p; int err = 0; @@ -1430,10 +1428,10 @@ static int snd_timer_user_ginfo(struct file *file, } static int snd_timer_user_gparams(struct file *file, - snd_timer_gparams_t __user *_gparams) + struct snd_timer_gparams __user *_gparams) { - snd_timer_gparams_t gparams; - snd_timer_t *t; + struct snd_timer_gparams gparams; + struct snd_timer *t; int err; if (copy_from_user(&gparams, _gparams, sizeof(gparams))) @@ -1459,11 +1457,11 @@ _error: } static int snd_timer_user_gstatus(struct file *file, - snd_timer_gstatus_t __user *_gstatus) + struct snd_timer_gstatus __user *_gstatus) { - snd_timer_gstatus_t gstatus; - snd_timer_id_t tid; - snd_timer_t *t; + struct snd_timer_gstatus gstatus; + struct snd_timer_id tid; + struct snd_timer *t; int err = 0; if (copy_from_user(&gstatus, _gstatus, sizeof(gstatus))) @@ -1495,10 +1493,10 @@ static int snd_timer_user_gstatus(struct file *file, } static int snd_timer_user_tselect(struct file *file, - snd_timer_select_t __user *_tselect) + struct snd_timer_select __user *_tselect) { - snd_timer_user_t *tu; - snd_timer_select_t tselect; + struct snd_timer_user *tu; + struct snd_timer_select tselect; char str[32]; int err = 0; @@ -1524,12 +1522,12 @@ static int snd_timer_user_tselect(struct file *file, kfree(tu->tqueue); tu->tqueue = NULL; if (tu->tread) { - tu->tqueue = kmalloc(tu->queue_size * sizeof(snd_timer_tread_t), + tu->tqueue = kmalloc(tu->queue_size * sizeof(struct snd_timer_tread), GFP_KERNEL); if (tu->tqueue == NULL) err = -ENOMEM; } else { - tu->queue = kmalloc(tu->queue_size * sizeof(snd_timer_read_t), + tu->queue = kmalloc(tu->queue_size * sizeof(struct snd_timer_read), GFP_KERNEL); if (tu->queue == NULL) err = -ENOMEM; @@ -1552,11 +1550,11 @@ static int snd_timer_user_tselect(struct file *file, } static int snd_timer_user_info(struct file *file, - snd_timer_info_t __user *_info) + struct snd_timer_info __user *_info) { - snd_timer_user_t *tu; - snd_timer_info_t *info; - snd_timer_t *t; + struct snd_timer_user *tu; + struct snd_timer_info *info; + struct snd_timer *t; int err = 0; tu = file->private_data; @@ -1580,13 +1578,13 @@ static int snd_timer_user_info(struct file *file, } static int snd_timer_user_params(struct file *file, - snd_timer_params_t __user *_params) + struct snd_timer_params __user *_params) { - snd_timer_user_t *tu; - snd_timer_params_t params; - snd_timer_t *t; - snd_timer_read_t *tr; - snd_timer_tread_t *ttr; + struct snd_timer_user *tu; + struct snd_timer_params params; + struct snd_timer *t; + struct snd_timer_read *tr; + struct snd_timer_tread *ttr; int err; tu = file->private_data; @@ -1656,14 +1654,14 @@ static int snd_timer_user_params(struct file *file, tu->qhead = tu->qtail = tu->qused = 0; if (tu->timeri->flags & SNDRV_TIMER_IFLG_EARLY_EVENT) { if (tu->tread) { - snd_timer_tread_t tread; + struct snd_timer_tread tread; tread.event = SNDRV_TIMER_EVENT_EARLY; tread.tstamp.tv_sec = 0; tread.tstamp.tv_nsec = 0; tread.val = 0; snd_timer_user_append_to_tqueue(tu, &tread); } else { - snd_timer_read_t *r = &tu->queue[0]; + struct snd_timer_read *r = &tu->queue[0]; r->resolution = 0; r->ticks = 0; tu->qused++; @@ -1680,10 +1678,10 @@ static int snd_timer_user_params(struct file *file, } static int snd_timer_user_status(struct file *file, - snd_timer_status_t __user *_status) + struct snd_timer_status __user *_status) { - snd_timer_user_t *tu; - snd_timer_status_t status; + struct snd_timer_user *tu; + struct snd_timer_status status; tu = file->private_data; snd_assert(tu->timeri != NULL, return -ENXIO); @@ -1703,7 +1701,7 @@ static int snd_timer_user_status(struct file *file, static int snd_timer_user_start(struct file *file) { int err; - snd_timer_user_t *tu; + struct snd_timer_user *tu; tu = file->private_data; snd_assert(tu->timeri != NULL, return -ENXIO); @@ -1716,7 +1714,7 @@ static int snd_timer_user_start(struct file *file) static int snd_timer_user_stop(struct file *file) { int err; - snd_timer_user_t *tu; + struct snd_timer_user *tu; tu = file->private_data; snd_assert(tu->timeri != NULL, return -ENXIO); @@ -1726,7 +1724,7 @@ static int snd_timer_user_stop(struct file *file) static int snd_timer_user_continue(struct file *file) { int err; - snd_timer_user_t *tu; + struct snd_timer_user *tu; tu = file->private_data; snd_assert(tu->timeri != NULL, return -ENXIO); @@ -1737,7 +1735,7 @@ static int snd_timer_user_continue(struct file *file) static int snd_timer_user_pause(struct file *file) { int err; - snd_timer_user_t *tu; + struct snd_timer_user *tu; tu = file->private_data; snd_assert(tu->timeri != NULL, return -ENXIO); @@ -1754,7 +1752,7 @@ enum { static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - snd_timer_user_t *tu; + struct snd_timer_user *tu; void __user *argp = (void __user *)arg; int __user *p = argp; @@ -1813,7 +1811,7 @@ static long snd_timer_user_ioctl(struct file *file, unsigned int cmd, static int snd_timer_user_fasync(int fd, struct file * file, int on) { - snd_timer_user_t *tu; + struct snd_timer_user *tu; int err; tu = file->private_data; @@ -1826,12 +1824,12 @@ static int snd_timer_user_fasync(int fd, struct file * file, int on) static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, size_t count, loff_t *offset) { - snd_timer_user_t *tu; + struct snd_timer_user *tu; long result = 0, unit; int err = 0; tu = file->private_data; - unit = tu->tread ? sizeof(snd_timer_tread_t) : sizeof(snd_timer_read_t); + unit = tu->tread ? sizeof(struct snd_timer_tread) : sizeof(struct snd_timer_read); spin_lock_irq(&tu->qlock); while ((long)count - result >= unit) { while (!tu->qused) { @@ -1864,13 +1862,13 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, if (tu->tread) { if (copy_to_user(buffer, &tu->tqueue[tu->qhead++], - sizeof(snd_timer_tread_t))) { + sizeof(struct snd_timer_tread))) { err = -EFAULT; goto _error; } } else { if (copy_to_user(buffer, &tu->queue[tu->qhead++], - sizeof(snd_timer_read_t))) { + sizeof(struct snd_timer_read))) { err = -EFAULT; goto _error; } @@ -1892,7 +1890,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer, static unsigned int snd_timer_user_poll(struct file *file, poll_table * wait) { unsigned int mask; - snd_timer_user_t *tu; + struct snd_timer_user *tu; tu = file->private_data; @@ -1923,7 +1921,7 @@ static struct file_operations snd_timer_f_ops = .fasync = snd_timer_user_fasync, }; -static snd_minor_t snd_timer_reg = +static struct snd_minor snd_timer_reg = { .comment = "timer", .f_ops = &snd_timer_f_ops, @@ -1933,12 +1931,12 @@ static snd_minor_t snd_timer_reg = * ENTRY functions */ -static snd_info_entry_t *snd_timer_proc_entry = NULL; +static struct snd_info_entry *snd_timer_proc_entry = NULL; static int __init alsa_timer_init(void) { int err; - snd_info_entry_t *entry; + struct snd_info_entry *entry; #ifdef SNDRV_OSS_INFO_DEV_TIMERS snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1, @@ -1971,7 +1969,7 @@ static void __exit alsa_timer_exit(void) snd_unregister_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0); /* unregister the system timer */ list_for_each_safe(p, n, &snd_timer_list) { - snd_timer_t *timer = list_entry(p, snd_timer_t, device_list); + struct snd_timer *timer = list_entry(p, struct snd_timer, device_list); snd_timer_unregister(timer); } if (snd_timer_proc_entry) { diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c index 3de552d..5512f53 100644 --- a/sound/core/timer_compat.c +++ b/sound/core/timer_compat.c @@ -22,7 +22,7 @@ #include <linux/compat.h> -struct sndrv_timer_info32 { +struct snd_timer_info32 { u32 flags; s32 card; unsigned char id[64]; @@ -33,11 +33,11 @@ struct sndrv_timer_info32 { }; static int snd_timer_user_info_compat(struct file *file, - struct sndrv_timer_info32 __user *_info) + struct snd_timer_info32 __user *_info) { - snd_timer_user_t *tu; - struct sndrv_timer_info32 info; - snd_timer_t *t; + struct snd_timer_user *tu; + struct snd_timer_info32 info; + struct snd_timer *t; tu = file->private_data; snd_assert(tu->timeri != NULL, return -ENXIO); @@ -55,7 +55,7 @@ static int snd_timer_user_info_compat(struct file *file, return 0; } -struct sndrv_timer_status32 { +struct snd_timer_status32 { struct compat_timespec tstamp; u32 resolution; u32 lost; @@ -65,10 +65,10 @@ struct sndrv_timer_status32 { }; static int snd_timer_user_status_compat(struct file *file, - struct sndrv_timer_status32 __user *_status) + struct snd_timer_status32 __user *_status) { - snd_timer_user_t *tu; - snd_timer_status_t status; + struct snd_timer_user *tu; + struct snd_timer_status status; tu = file->private_data; snd_assert(tu->timeri != NULL, return -ENXIO); @@ -89,8 +89,8 @@ static int snd_timer_user_status_compat(struct file *file, */ enum { - SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct sndrv_timer_info32), - SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct sndrv_timer_status32), + SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct snd_timer_info32), + SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct snd_timer_status32), }; static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) -- cgit v1.1 From 48c9d417d7269da2a2da5b602fcb5fdbee36305e Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 13:56:51 +0100 Subject: [ALSA] Remove xxx_t typedefs: Raw MIDI Modules: RawMidi Midlevel Remove xxx_t typedefs from the core raw MIDI codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/rawmidi.h | 123 +++++++++---------- sound/core/rawmidi.c | 280 +++++++++++++++++++++++--------------------- sound/core/rawmidi_compat.c | 22 ++-- 3 files changed, 220 insertions(+), 205 deletions(-) diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h index 3f9db51..9492a32 100644 --- a/include/sound/rawmidi.h +++ b/include/sound/rawmidi.h @@ -36,11 +36,6 @@ * Raw MIDI interface */ -typedef enum sndrv_rawmidi_stream snd_rawmidi_stream_t; -typedef struct sndrv_rawmidi_info snd_rawmidi_info_t; -typedef struct sndrv_rawmidi_params snd_rawmidi_params_t; -typedef struct sndrv_rawmidi_status snd_rawmidi_status_t; - #define SNDRV_RAWMIDI_DEVICES 8 #define SNDRV_RAWMIDI_LFLG_OUTPUT (1<<0) @@ -49,23 +44,22 @@ typedef struct sndrv_rawmidi_status snd_rawmidi_status_t; #define SNDRV_RAWMIDI_LFLG_APPEND (1<<2) #define SNDRV_RAWMIDI_LFLG_NOOPENLOCK (1<<3) -typedef struct _snd_rawmidi_runtime snd_rawmidi_runtime_t; -typedef struct _snd_rawmidi_substream snd_rawmidi_substream_t; -typedef struct _snd_rawmidi_str snd_rawmidi_str_t; +struct snd_rawmidi; +struct snd_rawmidi_substream; -typedef struct _snd_rawmidi_ops { - int (*open) (snd_rawmidi_substream_t * substream); - int (*close) (snd_rawmidi_substream_t * substream); - void (*trigger) (snd_rawmidi_substream_t * substream, int up); - void (*drain) (snd_rawmidi_substream_t * substream); -} snd_rawmidi_ops_t; +struct snd_rawmidi_ops { + int (*open) (struct snd_rawmidi_substream * substream); + int (*close) (struct snd_rawmidi_substream * substream); + void (*trigger) (struct snd_rawmidi_substream * substream, int up); + void (*drain) (struct snd_rawmidi_substream * substream); +}; -typedef struct _snd_rawmidi_global_ops { - int (*dev_register) (snd_rawmidi_t * rmidi); - int (*dev_unregister) (snd_rawmidi_t * rmidi); -} snd_rawmidi_global_ops_t; +struct snd_rawmidi_global_ops { + int (*dev_register) (struct snd_rawmidi * rmidi); + int (*dev_unregister) (struct snd_rawmidi * rmidi); +}; -struct _snd_rawmidi_runtime { +struct snd_rawmidi_runtime { unsigned int drain: 1, /* drain stage */ oss: 1; /* OSS compatible mode */ /* midi stream buffer */ @@ -80,15 +74,15 @@ struct _snd_rawmidi_runtime { spinlock_t lock; wait_queue_head_t sleep; /* event handler (new bytes, input only) */ - void (*event)(snd_rawmidi_substream_t *substream); + void (*event)(struct snd_rawmidi_substream *substream); /* defers calls to event [input] or ops->trigger [output] */ struct tasklet_struct tasklet; /* private data */ void *private_data; - void (*private_free)(snd_rawmidi_substream_t *substream); + void (*private_free)(struct snd_rawmidi_substream *substream); }; -struct _snd_rawmidi_substream { +struct snd_rawmidi_substream { struct list_head list; /* list of all substream for given stream */ int stream; /* direction */ int number; /* substream number */ @@ -97,28 +91,28 @@ struct _snd_rawmidi_substream { active_sensing: 1; /* send active sensing when close */ int use_count; /* use counter (for output) */ size_t bytes; - snd_rawmidi_t *rmidi; - snd_rawmidi_str_t *pstr; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_str *pstr; char name[32]; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi_runtime *runtime; /* hardware layer */ - snd_rawmidi_ops_t *ops; + struct snd_rawmidi_ops *ops; }; -typedef struct _snd_rawmidi_file { - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *input; - snd_rawmidi_substream_t *output; -} snd_rawmidi_file_t; +struct snd_rawmidi_file { + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *input; + struct snd_rawmidi_substream *output; +}; -struct _snd_rawmidi_str { +struct snd_rawmidi_str { unsigned int substream_count; unsigned int substream_opened; struct list_head substreams; }; -struct _snd_rawmidi { - snd_card_t *card; +struct snd_rawmidi { + struct snd_card *card; unsigned int device; /* device number */ unsigned int info_flags; /* SNDRV_RAWMIDI_INFO_XXXX */ @@ -129,52 +123,61 @@ struct _snd_rawmidi { int ossreg; #endif - snd_rawmidi_global_ops_t *ops; + struct snd_rawmidi_global_ops *ops; - snd_rawmidi_str_t streams[2]; + struct snd_rawmidi_str streams[2]; void *private_data; - void (*private_free) (snd_rawmidi_t *rmidi); + void (*private_free) (struct snd_rawmidi *rmidi); struct semaphore open_mutex; wait_queue_head_t open_wait; - snd_info_entry_t *dev; - snd_info_entry_t *proc_entry; + struct snd_info_entry *dev; + struct snd_info_entry *proc_entry; #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) - snd_seq_device_t *seq_dev; + struct snd_seq_device *seq_dev; #endif }; /* main rawmidi functions */ -int snd_rawmidi_new(snd_card_t * card, char *id, int device, +int snd_rawmidi_new(struct snd_card *card, char *id, int device, int output_count, int input_count, - snd_rawmidi_t ** rmidi); -void snd_rawmidi_set_ops(snd_rawmidi_t * rmidi, int stream, snd_rawmidi_ops_t * ops); + struct snd_rawmidi **rmidi); +void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream, + struct snd_rawmidi_ops *ops); /* callbacks */ -void snd_rawmidi_receive_reset(snd_rawmidi_substream_t * substream); -int snd_rawmidi_receive(snd_rawmidi_substream_t * substream, const unsigned char *buffer, int count); -void snd_rawmidi_transmit_reset(snd_rawmidi_substream_t * substream); -int snd_rawmidi_transmit_empty(snd_rawmidi_substream_t * substream); -int snd_rawmidi_transmit_peek(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count); -int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count); -int snd_rawmidi_transmit(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count); +void snd_rawmidi_receive_reset(struct snd_rawmidi_substream *substream); +int snd_rawmidi_receive(struct snd_rawmidi_substream *substream, + const unsigned char *buffer, int count); +void snd_rawmidi_transmit_reset(struct snd_rawmidi_substream *substream); +int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream); +int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream, + unsigned char *buffer, int count); +int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count); +int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, + unsigned char *buffer, int count); /* main midi functions */ -int snd_rawmidi_info_select(snd_card_t *card, snd_rawmidi_info_t *info); -int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, int mode, snd_rawmidi_file_t * rfile); -int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile); -int snd_rawmidi_output_params(snd_rawmidi_substream_t * substream, snd_rawmidi_params_t * params); -int snd_rawmidi_input_params(snd_rawmidi_substream_t * substream, snd_rawmidi_params_t * params); -int snd_rawmidi_drop_output(snd_rawmidi_substream_t * substream); -int snd_rawmidi_drain_output(snd_rawmidi_substream_t * substream); -int snd_rawmidi_drain_input(snd_rawmidi_substream_t * substream); -long snd_rawmidi_kernel_read(snd_rawmidi_substream_t * substream, unsigned char *buf, long count); -long snd_rawmidi_kernel_write(snd_rawmidi_substream_t * substream, const unsigned char *buf, long count); +int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info); +int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, int mode, + struct snd_rawmidi_file *rfile); +int snd_rawmidi_kernel_release(struct snd_rawmidi_file *rfile); +int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_params *params); +int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_params *params); +int snd_rawmidi_drop_output(struct snd_rawmidi_substream *substream); +int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream); +int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream); +long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream, + unsigned char *buf, long count); +long snd_rawmidi_kernel_write(struct snd_rawmidi_substream *substream, + const unsigned char *buf, long count); #endif /* __SOUND_RAWMIDI_H */ diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index d033e61..ede0a60 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -50,13 +50,13 @@ module_param_array(amidi_map, int, NULL, 0444); MODULE_PARM_DESC(amidi_map, "Raw MIDI device number assigned to 2nd OSS device."); #endif /* CONFIG_SND_OSSEMUL */ -static int snd_rawmidi_free(snd_rawmidi_t *rawmidi); -static int snd_rawmidi_dev_free(snd_device_t *device); -static int snd_rawmidi_dev_register(snd_device_t *device); -static int snd_rawmidi_dev_disconnect(snd_device_t *device); -static int snd_rawmidi_dev_unregister(snd_device_t *device); +static int snd_rawmidi_free(struct snd_rawmidi *rawmidi); +static int snd_rawmidi_dev_free(struct snd_device *device); +static int snd_rawmidi_dev_register(struct snd_device *device); +static int snd_rawmidi_dev_disconnect(struct snd_device *device); +static int snd_rawmidi_dev_unregister(struct snd_device *device); -static snd_rawmidi_t *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; +static struct snd_rawmidi *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; static DECLARE_MUTEX(register_mutex); @@ -72,34 +72,35 @@ static inline unsigned short snd_rawmidi_file_flags(struct file *file) } } -static inline int snd_rawmidi_ready(snd_rawmidi_substream_t * substream) +static inline int snd_rawmidi_ready(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; return runtime->avail >= runtime->avail_min; } -static inline int snd_rawmidi_ready_append(snd_rawmidi_substream_t * substream, size_t count) +static inline int snd_rawmidi_ready_append(struct snd_rawmidi_substream *substream, + size_t count) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; return runtime->avail >= runtime->avail_min && (!substream->append || runtime->avail >= count); } static void snd_rawmidi_input_event_tasklet(unsigned long data) { - snd_rawmidi_substream_t *substream = (snd_rawmidi_substream_t *)data; + struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *)data; substream->runtime->event(substream); } static void snd_rawmidi_output_trigger_tasklet(unsigned long data) { - snd_rawmidi_substream_t *substream = (snd_rawmidi_substream_t *)data; + struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *)data; substream->ops->trigger(substream, 1); } -static int snd_rawmidi_runtime_create(snd_rawmidi_substream_t * substream) +static int snd_rawmidi_runtime_create(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi_runtime *runtime; if ((runtime = kzalloc(sizeof(*runtime), GFP_KERNEL)) == NULL) return -ENOMEM; @@ -129,9 +130,9 @@ static int snd_rawmidi_runtime_create(snd_rawmidi_substream_t * substream) return 0; } -static int snd_rawmidi_runtime_free(snd_rawmidi_substream_t * substream) +static int snd_rawmidi_runtime_free(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; kfree(runtime->buffer); kfree(runtime); @@ -139,7 +140,7 @@ static int snd_rawmidi_runtime_free(snd_rawmidi_substream_t * substream) return 0; } -static inline void snd_rawmidi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static inline void snd_rawmidi_output_trigger(struct snd_rawmidi_substream *substream,int up) { if (up) { tasklet_hi_schedule(&substream->runtime->tasklet); @@ -149,17 +150,17 @@ static inline void snd_rawmidi_output_trigger(snd_rawmidi_substream_t * substrea } } -static void snd_rawmidi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_rawmidi_input_trigger(struct snd_rawmidi_substream *substream, int up) { substream->ops->trigger(substream, up); if (!up && substream->runtime->event) tasklet_kill(&substream->runtime->tasklet); } -int snd_rawmidi_drop_output(snd_rawmidi_substream_t * substream) +int snd_rawmidi_drop_output(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; snd_rawmidi_output_trigger(substream, 0); runtime->drain = 0; @@ -170,11 +171,11 @@ int snd_rawmidi_drop_output(snd_rawmidi_substream_t * substream) return 0; } -int snd_rawmidi_drain_output(snd_rawmidi_substream_t * substream) +int snd_rawmidi_drain_output(struct snd_rawmidi_substream *substream) { int err; long timeout; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; err = 0; runtime->drain = 1; @@ -199,10 +200,10 @@ int snd_rawmidi_drain_output(snd_rawmidi_substream_t * substream) return err; } -int snd_rawmidi_drain_input(snd_rawmidi_substream_t * substream) +int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; snd_rawmidi_input_trigger(substream, 0); runtime->drain = 0; @@ -214,12 +215,12 @@ int snd_rawmidi_drain_input(snd_rawmidi_substream_t * substream) } int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, - int mode, snd_rawmidi_file_t * rfile) + int mode, struct snd_rawmidi_file * rfile) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; struct list_head *list1, *list2; - snd_rawmidi_substream_t *sinput = NULL, *soutput = NULL; - snd_rawmidi_runtime_t *input = NULL, *output = NULL; + struct snd_rawmidi_substream *sinput = NULL, *soutput = NULL; + struct snd_rawmidi_runtime *input = NULL, *output = NULL; int err; if (rfile) @@ -275,7 +276,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, } break; } - sinput = list_entry(list1, snd_rawmidi_substream_t, list); + sinput = list_entry(list1, struct snd_rawmidi_substream, list); if ((mode & SNDRV_RAWMIDI_LFLG_INPUT) && sinput->opened) goto __nexti; if (subdevice < 0 || (subdevice >= 0 && subdevice == sinput->number)) @@ -293,7 +294,7 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, } break; } - soutput = list_entry(list2, snd_rawmidi_substream_t, list); + soutput = list_entry(list2, struct snd_rawmidi_substream, list); if (mode & SNDRV_RAWMIDI_LFLG_OUTPUT) { if (mode & SNDRV_RAWMIDI_LFLG_APPEND) { if (soutput->opened && !soutput->append) @@ -368,15 +369,15 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) { int maj = imajor(inode); int cardnum; - snd_card_t *card; + struct snd_card *card; int device, subdevice; unsigned short fflags; int err; - snd_rawmidi_t *rmidi; - snd_rawmidi_file_t *rawmidi_file; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_file *rawmidi_file; wait_queue_t wait; struct list_head *list; - snd_ctl_file_t *kctl; + struct snd_ctl_file *kctl; if (maj == snd_major) { cardnum = SNDRV_MINOR_CARD(iminor(inode)); @@ -465,11 +466,11 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) return err; } -int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile) +int snd_rawmidi_kernel_release(struct snd_rawmidi_file * rfile) { - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream; + struct snd_rawmidi_runtime *runtime; snd_assert(rfile != NULL, return -ENXIO); snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO); @@ -515,8 +516,8 @@ int snd_rawmidi_kernel_release(snd_rawmidi_file_t * rfile) static int snd_rawmidi_release(struct inode *inode, struct file *file) { - snd_rawmidi_file_t *rfile; - snd_rawmidi_t *rmidi; + struct snd_rawmidi_file *rfile; + struct snd_rawmidi *rmidi; int err; rfile = file->private_data; @@ -528,9 +529,10 @@ static int snd_rawmidi_release(struct inode *inode, struct file *file) return err; } -int snd_rawmidi_info(snd_rawmidi_substream_t *substream, snd_rawmidi_info_t *info) +int snd_rawmidi_info(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_info *info) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; if (substream == NULL) return -ENODEV; @@ -550,22 +552,23 @@ int snd_rawmidi_info(snd_rawmidi_substream_t *substream, snd_rawmidi_info_t *inf return 0; } -static int snd_rawmidi_info_user(snd_rawmidi_substream_t *substream, snd_rawmidi_info_t __user * _info) +static int snd_rawmidi_info_user(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_info __user * _info) { - snd_rawmidi_info_t info; + struct snd_rawmidi_info info; int err; if ((err = snd_rawmidi_info(substream, &info)) < 0) return err; - if (copy_to_user(_info, &info, sizeof(snd_rawmidi_info_t))) + if (copy_to_user(_info, &info, sizeof(struct snd_rawmidi_info))) return -EFAULT; return 0; } -int snd_rawmidi_info_select(snd_card_t *card, snd_rawmidi_info_t *info) +int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info) { - snd_rawmidi_t *rmidi; - snd_rawmidi_str_t *pstr; - snd_rawmidi_substream_t *substream; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_str *pstr; + struct snd_rawmidi_substream *substream; struct list_head *list; if (info->device >= SNDRV_RAWMIDI_DEVICES) return -ENXIO; @@ -578,18 +581,18 @@ int snd_rawmidi_info_select(snd_card_t *card, snd_rawmidi_info_t *info) if (info->subdevice >= pstr->substream_count) return -ENXIO; list_for_each(list, &pstr->substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); if ((unsigned int)substream->number == info->subdevice) return snd_rawmidi_info(substream, info); } return -ENXIO; } -static int snd_rawmidi_info_select_user(snd_card_t *card, - snd_rawmidi_info_t __user *_info) +static int snd_rawmidi_info_select_user(struct snd_card *card, + struct snd_rawmidi_info __user *_info) { int err; - snd_rawmidi_info_t info; + struct snd_rawmidi_info info; if (get_user(info.device, &_info->device)) return -EFAULT; if (get_user(info.stream, &_info->stream)) @@ -598,16 +601,16 @@ static int snd_rawmidi_info_select_user(snd_card_t *card, return -EFAULT; if ((err = snd_rawmidi_info_select(card, &info)) < 0) return err; - if (copy_to_user(_info, &info, sizeof(snd_rawmidi_info_t))) + if (copy_to_user(_info, &info, sizeof(struct snd_rawmidi_info))) return -EFAULT; return 0; } -int snd_rawmidi_output_params(snd_rawmidi_substream_t * substream, - snd_rawmidi_params_t * params) +int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_params * params) { char *newbuf; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; if (substream->append && substream->use_count > 1) return -EBUSY; @@ -630,11 +633,11 @@ int snd_rawmidi_output_params(snd_rawmidi_substream_t * substream, return 0; } -int snd_rawmidi_input_params(snd_rawmidi_substream_t * substream, - snd_rawmidi_params_t * params) +int snd_rawmidi_input_params(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_params * params) { char *newbuf; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; snd_rawmidi_drain_input(substream); if (params->buffer_size < 32 || params->buffer_size > 1024L * 1024L) { @@ -654,10 +657,10 @@ int snd_rawmidi_input_params(snd_rawmidi_substream_t * substream, return 0; } -static int snd_rawmidi_output_status(snd_rawmidi_substream_t * substream, - snd_rawmidi_status_t * status) +static int snd_rawmidi_output_status(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_status * status) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; memset(status, 0, sizeof(*status)); status->stream = SNDRV_RAWMIDI_STREAM_OUTPUT; @@ -667,10 +670,10 @@ static int snd_rawmidi_output_status(snd_rawmidi_substream_t * substream, return 0; } -static int snd_rawmidi_input_status(snd_rawmidi_substream_t * substream, - snd_rawmidi_status_t * status) +static int snd_rawmidi_input_status(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_status * status) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; memset(status, 0, sizeof(*status)); status->stream = SNDRV_RAWMIDI_STREAM_INPUT; @@ -684,7 +687,7 @@ static int snd_rawmidi_input_status(snd_rawmidi_substream_t * substream, static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - snd_rawmidi_file_t *rfile; + struct snd_rawmidi_file *rfile; void __user *argp = (void __user *)arg; rfile = file->private_data; @@ -695,8 +698,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long return put_user(SNDRV_RAWMIDI_VERSION, (int __user *)argp) ? -EFAULT : 0; case SNDRV_RAWMIDI_IOCTL_INFO: { - snd_rawmidi_stream_t stream; - snd_rawmidi_info_t __user *info = argp; + int stream; + struct snd_rawmidi_info __user *info = argp; if (get_user(stream, &info->stream)) return -EFAULT; switch (stream) { @@ -710,8 +713,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long } case SNDRV_RAWMIDI_IOCTL_PARAMS: { - snd_rawmidi_params_t params; - if (copy_from_user(¶ms, argp, sizeof(snd_rawmidi_params_t))) + struct snd_rawmidi_params params; + if (copy_from_user(¶ms, argp, sizeof(struct snd_rawmidi_params))) return -EFAULT; switch (params.stream) { case SNDRV_RAWMIDI_STREAM_OUTPUT: @@ -729,8 +732,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long case SNDRV_RAWMIDI_IOCTL_STATUS: { int err = 0; - snd_rawmidi_status_t status; - if (copy_from_user(&status, argp, sizeof(snd_rawmidi_status_t))) + struct snd_rawmidi_status status; + if (copy_from_user(&status, argp, sizeof(struct snd_rawmidi_status))) return -EFAULT; switch (status.stream) { case SNDRV_RAWMIDI_STREAM_OUTPUT: @@ -748,7 +751,7 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long } if (err < 0) return err; - if (copy_to_user(argp, &status, sizeof(snd_rawmidi_status_t))) + if (copy_to_user(argp, &status, sizeof(struct snd_rawmidi_status))) return -EFAULT; return 0; } @@ -792,8 +795,8 @@ static long snd_rawmidi_ioctl(struct file *file, unsigned int cmd, unsigned long return -ENOTTY; } -static int snd_rawmidi_control_ioctl(snd_card_t * card, - snd_ctl_file_t * control, +static int snd_rawmidi_control_ioctl(struct snd_card *card, + struct snd_ctl_file *control, unsigned int cmd, unsigned long arg) { @@ -845,11 +848,12 @@ static int snd_rawmidi_control_ioctl(snd_card_t * card, * * Returns the size of read data, or a negative error code on failure. */ -int snd_rawmidi_receive(snd_rawmidi_substream_t * substream, const unsigned char *buffer, int count) +int snd_rawmidi_receive(struct snd_rawmidi_substream *substream, + const unsigned char *buffer, int count) { unsigned long flags; int result = 0, count1; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; if (runtime->buffer == NULL) { snd_printd("snd_rawmidi_receive: input is not active!!!\n"); @@ -904,12 +908,12 @@ int snd_rawmidi_receive(snd_rawmidi_substream_t * substream, const unsigned char return result; } -static long snd_rawmidi_kernel_read1(snd_rawmidi_substream_t *substream, +static long snd_rawmidi_kernel_read1(struct snd_rawmidi_substream *substream, unsigned char *buf, long count, int kernel) { unsigned long flags; long result = 0, count1; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; while (count > 0 && runtime->avail) { count1 = runtime->buffer_size - runtime->appl_ptr; @@ -938,19 +942,21 @@ static long snd_rawmidi_kernel_read1(snd_rawmidi_substream_t *substream, return result; } -long snd_rawmidi_kernel_read(snd_rawmidi_substream_t *substream, unsigned char *buf, long count) +long snd_rawmidi_kernel_read(struct snd_rawmidi_substream *substream, + unsigned char *buf, long count) { snd_rawmidi_input_trigger(substream, 1); return snd_rawmidi_kernel_read1(substream, buf, count, 1); } -static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t count, + loff_t *offset) { long result; int count1; - snd_rawmidi_file_t *rfile; - snd_rawmidi_substream_t *substream; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi_file *rfile; + struct snd_rawmidi_substream *substream; + struct snd_rawmidi_runtime *runtime; rfile = file->private_data; substream = rfile->input; @@ -998,9 +1004,9 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun * * Returns 1 if the internal output buffer is empty, 0 if not. */ -int snd_rawmidi_transmit_empty(snd_rawmidi_substream_t * substream) +int snd_rawmidi_transmit_empty(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; int result; unsigned long flags; @@ -1028,11 +1034,12 @@ int snd_rawmidi_transmit_empty(snd_rawmidi_substream_t * substream) * * Returns the size of copied data, or a negative error code on failure. */ -int snd_rawmidi_transmit_peek(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count) +int snd_rawmidi_transmit_peek(struct snd_rawmidi_substream *substream, + unsigned char *buffer, int count) { unsigned long flags; int result, count1; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; if (runtime->buffer == NULL) { snd_printd("snd_rawmidi_transmit_peek: output is not active!!!\n"); @@ -1079,10 +1086,10 @@ int snd_rawmidi_transmit_peek(snd_rawmidi_substream_t * substream, unsigned char * * Returns the advanced size if successful, or a negative error code on failure. */ -int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count) +int snd_rawmidi_transmit_ack(struct snd_rawmidi_substream *substream, int count) { unsigned long flags; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; if (runtime->buffer == NULL) { snd_printd("snd_rawmidi_transmit_ack: output is not active!!!\n"); @@ -1112,7 +1119,8 @@ int snd_rawmidi_transmit_ack(snd_rawmidi_substream_t * substream, int count) * * Returns the copied size if successful, or a negative error code on failure. */ -int snd_rawmidi_transmit(snd_rawmidi_substream_t * substream, unsigned char *buffer, int count) +int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, + unsigned char *buffer, int count) { count = snd_rawmidi_transmit_peek(substream, buffer, count); if (count < 0) @@ -1120,11 +1128,12 @@ int snd_rawmidi_transmit(snd_rawmidi_substream_t * substream, unsigned char *buf return snd_rawmidi_transmit_ack(substream, count); } -static long snd_rawmidi_kernel_write1(snd_rawmidi_substream_t * substream, const unsigned char *buf, long count, int kernel) +static long snd_rawmidi_kernel_write1(struct snd_rawmidi_substream *substream, + const unsigned char *buf, long count, int kernel) { unsigned long flags; long count1, result; - snd_rawmidi_runtime_t *runtime = substream->runtime; + struct snd_rawmidi_runtime *runtime = substream->runtime; snd_assert(buf != NULL, return -EINVAL); snd_assert(runtime->buffer != NULL, return -EINVAL); @@ -1170,18 +1179,20 @@ static long snd_rawmidi_kernel_write1(snd_rawmidi_substream_t * substream, const return result; } -long snd_rawmidi_kernel_write(snd_rawmidi_substream_t * substream, const unsigned char *buf, long count) +long snd_rawmidi_kernel_write(struct snd_rawmidi_substream *substream, + const unsigned char *buf, long count) { return snd_rawmidi_kernel_write1(substream, buf, count, 1); } -static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) +static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, + size_t count, loff_t *offset) { long result, timeout; int count1; - snd_rawmidi_file_t *rfile; - snd_rawmidi_runtime_t *runtime; - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_file *rfile; + struct snd_rawmidi_runtime *runtime; + struct snd_rawmidi_substream *substream; rfile = file->private_data; substream = rfile->output; @@ -1246,8 +1257,8 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, size static unsigned int snd_rawmidi_poll(struct file *file, poll_table * wait) { - snd_rawmidi_file_t *rfile; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi_file *rfile; + struct snd_rawmidi_runtime *runtime; unsigned int mask; rfile = file->private_data; @@ -1284,12 +1295,12 @@ static unsigned int snd_rawmidi_poll(struct file *file, poll_table * wait) */ -static void snd_rawmidi_proc_info_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream; - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream; + struct snd_rawmidi_runtime *runtime; struct list_head *list; rmidi = entry->private_data; @@ -1297,7 +1308,7 @@ static void snd_rawmidi_proc_info_read(snd_info_entry_t *entry, down(&rmidi->open_mutex); if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) { list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); snd_iprintf(buffer, "Output %d\n" " Tx bytes : %lu\n", @@ -1317,7 +1328,7 @@ static void snd_rawmidi_proc_info_read(snd_info_entry_t *entry, } if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_INPUT) { list_for_each(list, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); snd_iprintf(buffer, "Input %d\n" " Rx bytes : %lu\n", @@ -1354,18 +1365,18 @@ static struct file_operations snd_rawmidi_f_ops = .compat_ioctl = snd_rawmidi_ioctl_compat, }; -static snd_minor_t snd_rawmidi_reg = +static struct snd_minor snd_rawmidi_reg = { .comment = "raw midi", .f_ops = &snd_rawmidi_f_ops, }; -static int snd_rawmidi_alloc_substreams(snd_rawmidi_t *rmidi, - snd_rawmidi_str_t *stream, +static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, + struct snd_rawmidi_str *stream, int direction, int count) { - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_substream *substream; int idx; INIT_LIST_HEAD(&stream->substreams); @@ -1397,13 +1408,13 @@ static int snd_rawmidi_alloc_substreams(snd_rawmidi_t *rmidi, * * Returns zero if successful, or a negative error code on failure. */ -int snd_rawmidi_new(snd_card_t * card, char *id, int device, +int snd_rawmidi_new(struct snd_card *card, char *id, int device, int output_count, int input_count, - snd_rawmidi_t ** rrawmidi) + struct snd_rawmidi ** rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_rawmidi_dev_free, .dev_register = snd_rawmidi_dev_register, .dev_disconnect = snd_rawmidi_dev_disconnect, @@ -1438,18 +1449,18 @@ int snd_rawmidi_new(snd_card_t * card, char *id, int device, return 0; } -static void snd_rawmidi_free_substreams(snd_rawmidi_str_t *stream) +static void snd_rawmidi_free_substreams(struct snd_rawmidi_str *stream) { - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_substream *substream; while (!list_empty(&stream->substreams)) { - substream = list_entry(stream->substreams.next, snd_rawmidi_substream_t, list); + substream = list_entry(stream->substreams.next, struct snd_rawmidi_substream, list); list_del(&substream->list); kfree(substream); } } -static int snd_rawmidi_free(snd_rawmidi_t *rmidi) +static int snd_rawmidi_free(struct snd_rawmidi *rmidi) { snd_assert(rmidi != NULL, return -ENXIO); snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]); @@ -1460,26 +1471,26 @@ static int snd_rawmidi_free(snd_rawmidi_t *rmidi) return 0; } -static int snd_rawmidi_dev_free(snd_device_t *device) +static int snd_rawmidi_dev_free(struct snd_device *device) { - snd_rawmidi_t *rmidi = device->device_data; + struct snd_rawmidi *rmidi = device->device_data; return snd_rawmidi_free(rmidi); } #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) -static void snd_rawmidi_dev_seq_free(snd_seq_device_t *device) +static void snd_rawmidi_dev_seq_free(struct snd_seq_device *device) { - snd_rawmidi_t *rmidi = device->private_data; + struct snd_rawmidi *rmidi = device->private_data; rmidi->seq_dev = NULL; } #endif -static int snd_rawmidi_dev_register(snd_device_t *device) +static int snd_rawmidi_dev_register(struct snd_device *device) { int idx, err; - snd_info_entry_t *entry; + struct snd_info_entry *entry; char name[16]; - snd_rawmidi_t *rmidi = device->device_data; + struct snd_rawmidi *rmidi = device->device_data; if (rmidi->device >= SNDRV_RAWMIDI_DEVICES) return -ENOMEM; @@ -1554,9 +1565,9 @@ static int snd_rawmidi_dev_register(snd_device_t *device) return 0; } -static int snd_rawmidi_dev_disconnect(snd_device_t *device) +static int snd_rawmidi_dev_disconnect(struct snd_device *device) { - snd_rawmidi_t *rmidi = device->device_data; + struct snd_rawmidi *rmidi = device->device_data; int idx; down(®ister_mutex); @@ -1566,10 +1577,10 @@ static int snd_rawmidi_dev_disconnect(snd_device_t *device) return 0; } -static int snd_rawmidi_dev_unregister(snd_device_t *device) +static int snd_rawmidi_dev_unregister(struct snd_device *device) { int idx; - snd_rawmidi_t *rmidi = device->device_data; + struct snd_rawmidi *rmidi = device->device_data; snd_assert(rmidi != NULL, return -ENXIO); down(®ister_mutex); @@ -1613,13 +1624,14 @@ static int snd_rawmidi_dev_unregister(snd_device_t *device) * * Sets the rawmidi operators for the given stream direction. */ -void snd_rawmidi_set_ops(snd_rawmidi_t *rmidi, int stream, snd_rawmidi_ops_t *ops) +void snd_rawmidi_set_ops(struct snd_rawmidi *rmidi, int stream, + struct snd_rawmidi_ops *ops) { struct list_head *list; - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_substream *substream; list_for_each(list, &rmidi->streams[stream].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); substream->ops = ops; } } diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c index d97631c..5268c1f 100644 --- a/sound/core/rawmidi_compat.c +++ b/sound/core/rawmidi_compat.c @@ -22,7 +22,7 @@ #include <linux/compat.h> -struct sndrv_rawmidi_params32 { +struct snd_rawmidi_params32 { s32 stream; u32 buffer_size; u32 avail_min; @@ -30,10 +30,10 @@ struct sndrv_rawmidi_params32 { unsigned char reserved[16]; } __attribute__((packed)); -static int snd_rawmidi_ioctl_params_compat(snd_rawmidi_file_t *rfile, - struct sndrv_rawmidi_params32 __user *src) +static int snd_rawmidi_ioctl_params_compat(struct snd_rawmidi_file *rfile, + struct snd_rawmidi_params32 __user *src) { - snd_rawmidi_params_t params; + struct snd_rawmidi_params params; unsigned int val; if (rfile->output == NULL) @@ -53,7 +53,7 @@ static int snd_rawmidi_ioctl_params_compat(snd_rawmidi_file_t *rfile, return -EINVAL; } -struct sndrv_rawmidi_status32 { +struct snd_rawmidi_status32 { s32 stream; struct compat_timespec tstamp; u32 avail; @@ -61,11 +61,11 @@ struct sndrv_rawmidi_status32 { unsigned char reserved[16]; } __attribute__((packed)); -static int snd_rawmidi_ioctl_status_compat(snd_rawmidi_file_t *rfile, - struct sndrv_rawmidi_status32 __user *src) +static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile, + struct snd_rawmidi_status32 __user *src) { int err; - snd_rawmidi_status_t status; + struct snd_rawmidi_status status; if (rfile->output == NULL) return -EINVAL; @@ -95,13 +95,13 @@ static int snd_rawmidi_ioctl_status_compat(snd_rawmidi_file_t *rfile, } enum { - SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct sndrv_rawmidi_params32), - SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct sndrv_rawmidi_status32), + SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct snd_rawmidi_params32), + SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct snd_rawmidi_status32), }; static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) { - snd_rawmidi_file_t *rfile; + struct snd_rawmidi_file *rfile; void __user *argp = compat_ptr(arg); rfile = file->private_data; -- cgit v1.1 From d9a98de218ce18befabb5782c43cb4a2766b4b02 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 13:58:21 +0100 Subject: [ALSA] Remove xxx_t typedefs: Hwdep Modules: HWDEP Midlevel Remove xxx_t typedefs from the core hwdep codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/hwdep.h | 42 +++++++++++----------- sound/core/hwdep.c | 90 ++++++++++++++++++++++++++--------------------- sound/core/hwdep_compat.c | 15 ++++---- 3 files changed, 77 insertions(+), 70 deletions(-) diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h index 0438763..04b20bc 100644 --- a/include/sound/hwdep.h +++ b/include/sound/hwdep.h @@ -25,27 +25,24 @@ #include <sound/asound.h> #include <linux/poll.h> -typedef enum sndrv_hwdep_iface snd_hwdep_iface_t; -typedef struct sndrv_hwdep_info snd_hwdep_info_t; -typedef struct sndrv_hwdep_dsp_status snd_hwdep_dsp_status_t; -typedef struct sndrv_hwdep_dsp_image snd_hwdep_dsp_image_t; +struct snd_hwdep; -typedef struct _snd_hwdep_ops { - long long (*llseek) (snd_hwdep_t *hw, struct file * file, long long offset, int orig); - long (*read) (snd_hwdep_t * hw, char __user *buf, long count, loff_t *offset); - long (*write) (snd_hwdep_t * hw, const char __user *buf, long count, loff_t *offset); - int (*open) (snd_hwdep_t * hw, struct file * file); - int (*release) (snd_hwdep_t * hw, struct file * file); - unsigned int (*poll) (snd_hwdep_t * hw, struct file * file, poll_table * wait); - int (*ioctl) (snd_hwdep_t * hw, struct file * file, unsigned int cmd, unsigned long arg); - int (*ioctl_compat) (snd_hwdep_t * hw, struct file * file, unsigned int cmd, unsigned long arg); - int (*mmap) (snd_hwdep_t * hw, struct file * file, struct vm_area_struct * vma); - int (*dsp_status) (snd_hwdep_t * hw, snd_hwdep_dsp_status_t * status); - int (*dsp_load) (snd_hwdep_t * hw, snd_hwdep_dsp_image_t * image); -} snd_hwdep_ops_t; +struct snd_hwdep_ops { + long long (*llseek) (struct snd_hwdep *hw, struct file * file, long long offset, int orig); + long (*read) (struct snd_hwdep *hw, char __user *buf, long count, loff_t *offset); + long (*write) (struct snd_hwdep *hw, const char __user *buf, long count, loff_t *offset); + int (*open) (struct snd_hwdep * hw, struct file * file); + int (*release) (struct snd_hwdep *hw, struct file * file); + unsigned int (*poll) (struct snd_hwdep *hw, struct file * file, poll_table * wait); + int (*ioctl) (struct snd_hwdep *hw, struct file * file, unsigned int cmd, unsigned long arg); + int (*ioctl_compat) (struct snd_hwdep *hw, struct file * file, unsigned int cmd, unsigned long arg); + int (*mmap) (struct snd_hwdep *hw, struct file * file, struct vm_area_struct * vma); + int (*dsp_status) (struct snd_hwdep *hw, struct snd_hwdep_dsp_status *status); + int (*dsp_load) (struct snd_hwdep *hw, struct snd_hwdep_dsp_image *image); +}; -struct _snd_hwdep { - snd_card_t *card; +struct snd_hwdep { + struct snd_card *card; int device; char id[32]; char name[80]; @@ -57,10 +54,10 @@ struct _snd_hwdep { int ossreg; #endif - snd_hwdep_ops_t ops; + struct snd_hwdep_ops ops; wait_queue_head_t open_wait; void *private_data; - void (*private_free) (snd_hwdep_t *hwdep); + void (*private_free) (struct snd_hwdep *hwdep); struct semaphore open_mutex; int used; @@ -68,6 +65,7 @@ struct _snd_hwdep { unsigned int exclusive: 1; }; -extern int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep); +extern int snd_hwdep_new(struct snd_card *card, char *id, int device, + struct snd_hwdep **rhwdep); #endif /* __SOUND_HWDEP_H */ diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index e91cee3..da0fb9f 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -35,14 +35,14 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("Hardware dependent layer"); MODULE_LICENSE("GPL"); -static snd_hwdep_t *snd_hwdep_devices[SNDRV_CARDS * SNDRV_MINOR_HWDEPS]; +static struct snd_hwdep *snd_hwdep_devices[SNDRV_CARDS * SNDRV_MINOR_HWDEPS]; static DECLARE_MUTEX(register_mutex); -static int snd_hwdep_free(snd_hwdep_t *hwdep); -static int snd_hwdep_dev_free(snd_device_t *device); -static int snd_hwdep_dev_register(snd_device_t *device); -static int snd_hwdep_dev_unregister(snd_device_t *device); +static int snd_hwdep_free(struct snd_hwdep *hwdep); +static int snd_hwdep_dev_free(struct snd_device *device); +static int snd_hwdep_dev_register(struct snd_device *device); +static int snd_hwdep_dev_unregister(struct snd_device *device); /* @@ -50,23 +50,25 @@ static int snd_hwdep_dev_unregister(snd_device_t *device); static loff_t snd_hwdep_llseek(struct file * file, loff_t offset, int orig) { - snd_hwdep_t *hw = file->private_data; + struct snd_hwdep *hw = file->private_data; if (hw->ops.llseek) return hw->ops.llseek(hw, file, offset, orig); return -ENXIO; } -static ssize_t snd_hwdep_read(struct file * file, char __user *buf, size_t count, loff_t *offset) +static ssize_t snd_hwdep_read(struct file * file, char __user *buf, + size_t count, loff_t *offset) { - snd_hwdep_t *hw = file->private_data; + struct snd_hwdep *hw = file->private_data; if (hw->ops.read) return hw->ops.read(hw, buf, count, offset); return -ENXIO; } -static ssize_t snd_hwdep_write(struct file * file, const char __user *buf, size_t count, loff_t *offset) +static ssize_t snd_hwdep_write(struct file * file, const char __user *buf, + size_t count, loff_t *offset) { - snd_hwdep_t *hw = file->private_data; + struct snd_hwdep *hw = file->private_data; if (hw->ops.write) return hw->ops.write(hw, buf, count, offset); return -ENXIO; @@ -77,7 +79,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) int major = imajor(inode); int cardnum; int device; - snd_hwdep_t *hw; + struct snd_hwdep *hw; int err; wait_queue_t wait; @@ -154,7 +156,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) static int snd_hwdep_release(struct inode *inode, struct file * file) { int err = -ENXIO; - snd_hwdep_t *hw = file->private_data; + struct snd_hwdep *hw = file->private_data; down(&hw->open_mutex); if (hw->ops.release) { err = hw->ops.release(hw, file); @@ -170,15 +172,16 @@ static int snd_hwdep_release(struct inode *inode, struct file * file) static unsigned int snd_hwdep_poll(struct file * file, poll_table * wait) { - snd_hwdep_t *hw = file->private_data; + struct snd_hwdep *hw = file->private_data; if (hw->ops.poll) return hw->ops.poll(hw, file, wait); return 0; } -static int snd_hwdep_info(snd_hwdep_t *hw, snd_hwdep_info_t __user *_info) +static int snd_hwdep_info(struct snd_hwdep *hw, + struct snd_hwdep_info __user *_info) { - snd_hwdep_info_t info; + struct snd_hwdep_info info; memset(&info, 0, sizeof(info)); info.card = hw->card->number; @@ -190,9 +193,10 @@ static int snd_hwdep_info(snd_hwdep_t *hw, snd_hwdep_info_t __user *_info) return 0; } -static int snd_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t __user *_info) +static int snd_hwdep_dsp_status(struct snd_hwdep *hw, + struct snd_hwdep_dsp_status __user *_info) { - snd_hwdep_dsp_status_t info; + struct snd_hwdep_dsp_status info; int err; if (! hw->ops.dsp_status) @@ -206,9 +210,10 @@ static int snd_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t __user * return 0; } -static int snd_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t __user *_info) +static int snd_hwdep_dsp_load(struct snd_hwdep *hw, + struct snd_hwdep_dsp_image __user *_info) { - snd_hwdep_dsp_image_t info; + struct snd_hwdep_dsp_image info; int err; if (! hw->ops.dsp_load) @@ -228,9 +233,10 @@ static int snd_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t __user *_in return 0; } -static long snd_hwdep_ioctl(struct file * file, unsigned int cmd, unsigned long arg) +static long snd_hwdep_ioctl(struct file * file, unsigned int cmd, + unsigned long arg) { - snd_hwdep_t *hw = file->private_data; + struct snd_hwdep *hw = file->private_data; void __user *argp = (void __user *)arg; switch (cmd) { case SNDRV_HWDEP_IOCTL_PVERSION: @@ -249,13 +255,14 @@ static long snd_hwdep_ioctl(struct file * file, unsigned int cmd, unsigned long static int snd_hwdep_mmap(struct file * file, struct vm_area_struct * vma) { - snd_hwdep_t *hw = file->private_data; + struct snd_hwdep *hw = file->private_data; if (hw->ops.mmap) return hw->ops.mmap(hw, file, vma); return -ENXIO; } -static int snd_hwdep_control_ioctl(snd_card_t * card, snd_ctl_file_t * control, +static int snd_hwdep_control_ioctl(struct snd_card *card, + struct snd_ctl_file * control, unsigned int cmd, unsigned long arg) { unsigned int tmp; @@ -282,9 +289,9 @@ static int snd_hwdep_control_ioctl(snd_card_t * card, snd_ctl_file_t * control, } case SNDRV_CTL_IOCTL_HWDEP_INFO: { - snd_hwdep_info_t __user *info = (snd_hwdep_info_t __user *)arg; + struct snd_hwdep_info __user *info = (struct snd_hwdep_info __user *)arg; int device; - snd_hwdep_t *hwdep; + struct snd_hwdep *hwdep; if (get_user(device, &info->device)) return -EFAULT; @@ -323,7 +330,7 @@ static struct file_operations snd_hwdep_f_ops = .mmap = snd_hwdep_mmap, }; -static snd_minor_t snd_hwdep_reg = +static struct snd_minor snd_hwdep_reg = { .comment = "hardware dependent", .f_ops = &snd_hwdep_f_ops, @@ -342,11 +349,12 @@ static snd_minor_t snd_hwdep_reg = * * Returns zero if successful, or a negative error code on failure. */ -int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep) +int snd_hwdep_new(struct snd_card *card, char *id, int device, + struct snd_hwdep **rhwdep) { - snd_hwdep_t *hwdep; + struct snd_hwdep *hwdep; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_hwdep_dev_free, .dev_register = snd_hwdep_dev_register, .dev_unregister = snd_hwdep_dev_unregister @@ -376,7 +384,7 @@ int snd_hwdep_new(snd_card_t * card, char *id, int device, snd_hwdep_t ** rhwdep return 0; } -static int snd_hwdep_free(snd_hwdep_t *hwdep) +static int snd_hwdep_free(struct snd_hwdep *hwdep) { snd_assert(hwdep != NULL, return -ENXIO); if (hwdep->private_free) @@ -385,15 +393,15 @@ static int snd_hwdep_free(snd_hwdep_t *hwdep) return 0; } -static int snd_hwdep_dev_free(snd_device_t *device) +static int snd_hwdep_dev_free(struct snd_device *device) { - snd_hwdep_t *hwdep = device->device_data; + struct snd_hwdep *hwdep = device->device_data; return snd_hwdep_free(hwdep); } -static int snd_hwdep_dev_register(snd_device_t *device) +static int snd_hwdep_dev_register(struct snd_device *device) { - snd_hwdep_t *hwdep = device->device_data; + struct snd_hwdep *hwdep = device->device_data; int idx, err; char name[32]; @@ -434,9 +442,9 @@ static int snd_hwdep_dev_register(snd_device_t *device) return 0; } -static int snd_hwdep_dev_unregister(snd_device_t *device) +static int snd_hwdep_dev_unregister(struct snd_device *device) { - snd_hwdep_t *hwdep = device->device_data; + struct snd_hwdep *hwdep = device->device_data; int idx; snd_assert(hwdep != NULL, return -ENXIO); @@ -460,11 +468,11 @@ static int snd_hwdep_dev_unregister(snd_device_t *device) * Info interface */ -static void snd_hwdep_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_hwdep_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int idx; - snd_hwdep_t *hwdep; + struct snd_hwdep *hwdep; down(®ister_mutex); for (idx = 0; idx < SNDRV_CARDS * SNDRV_MINOR_HWDEPS; idx++) { @@ -483,11 +491,11 @@ static void snd_hwdep_proc_read(snd_info_entry_t *entry, * ENTRY functions */ -static snd_info_entry_t *snd_hwdep_proc_entry = NULL; +static struct snd_info_entry *snd_hwdep_proc_entry = NULL; static int __init alsa_hwdep_init(void) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; memset(snd_hwdep_devices, 0, sizeof(snd_hwdep_devices)); if ((entry = snd_info_create_module_entry(THIS_MODULE, "hwdep", NULL)) != NULL) { diff --git a/sound/core/hwdep_compat.c b/sound/core/hwdep_compat.c index 6866f42..938f775 100644 --- a/sound/core/hwdep_compat.c +++ b/sound/core/hwdep_compat.c @@ -22,7 +22,7 @@ #include <linux/compat.h> -struct sndrv_hwdep_dsp_image32 { +struct snd_hwdep_dsp_image32 { u32 index; unsigned char name[64]; u32 image; /* pointer */ @@ -30,10 +30,10 @@ struct sndrv_hwdep_dsp_image32 { u32 driver_data; } /* don't set packed attribute here */; -static int snd_hwdep_dsp_load_compat(snd_hwdep_t *hw, - struct sndrv_hwdep_dsp_image32 __user *src) +static int snd_hwdep_dsp_load_compat(struct snd_hwdep *hw, + struct snd_hwdep_dsp_image32 __user *src) { - struct sndrv_hwdep_dsp_image *dst; + struct snd_hwdep_dsp_image *dst; compat_caddr_t ptr; u32 val; @@ -56,12 +56,13 @@ static int snd_hwdep_dsp_load_compat(snd_hwdep_t *hw, } enum { - SNDRV_HWDEP_IOCTL_DSP_LOAD32 = _IOW('H', 0x03, struct sndrv_hwdep_dsp_image32) + SNDRV_HWDEP_IOCTL_DSP_LOAD32 = _IOW('H', 0x03, struct snd_hwdep_dsp_image32) }; -static long snd_hwdep_ioctl_compat(struct file * file, unsigned int cmd, unsigned long arg) +static long snd_hwdep_ioctl_compat(struct file * file, unsigned int cmd, + unsigned long arg) { - snd_hwdep_t *hw = file->private_data; + struct snd_hwdep *hw = file->private_data; void __user *argp = compat_ptr(arg); switch (cmd) { case SNDRV_HWDEP_IOCTL_PVERSION: -- cgit v1.1 From 24c1f93188b4438c7f30df5b4cd78340cdb28daf Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 13:58:48 +0100 Subject: [ALSA] Remove xxx_t typedefs: Proc handler Modules: ALSA Core Remove xxx_t typedefs from the core proc handler codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/info.h | 94 +++++++++++++++++++++---------------------- sound/core/info.c | 110 +++++++++++++++++++++++++-------------------------- 2 files changed, 101 insertions(+), 103 deletions(-) diff --git a/include/sound/info.h b/include/sound/info.h index 1d76bf3..df03e60 100644 --- a/include/sound/info.h +++ b/include/sound/info.h @@ -34,8 +34,6 @@ struct snd_info_buffer { int error; /* error code */ }; -typedef struct snd_info_buffer snd_info_buffer_t; - #define SNDRV_INFO_CONTENT_TEXT 0 #define SNDRV_INFO_CONTENT_DATA 1 @@ -44,28 +42,28 @@ struct snd_info_entry; struct snd_info_entry_text { unsigned long read_size; unsigned long write_size; - void (*read) (snd_info_entry_t *entry, snd_info_buffer_t * buffer); - void (*write) (snd_info_entry_t *entry, snd_info_buffer_t * buffer); + void (*read) (struct snd_info_entry *entry, struct snd_info_buffer *buffer); + void (*write) (struct snd_info_entry *entry, struct snd_info_buffer *buffer); }; struct snd_info_entry_ops { - int (*open) (snd_info_entry_t *entry, + int (*open) (struct snd_info_entry *entry, unsigned short mode, void **file_private_data); - int (*release) (snd_info_entry_t * entry, + int (*release) (struct snd_info_entry * entry, unsigned short mode, void *file_private_data); - long (*read) (snd_info_entry_t *entry, void *file_private_data, + long (*read) (struct snd_info_entry *entry, void *file_private_data, struct file * file, char __user *buf, unsigned long count, unsigned long pos); - long (*write) (snd_info_entry_t *entry, void *file_private_data, + long (*write) (struct snd_info_entry *entry, void *file_private_data, struct file * file, const char __user *buf, unsigned long count, unsigned long pos); - long long (*llseek) (snd_info_entry_t *entry, void *file_private_data, + long long (*llseek) (struct snd_info_entry *entry, void *file_private_data, struct file * file, long long offset, int orig); - unsigned int (*poll) (snd_info_entry_t *entry, void *file_private_data, + unsigned int (*poll) (struct snd_info_entry *entry, void *file_private_data, struct file * file, poll_table * wait); - int (*ioctl) (snd_info_entry_t *entry, void *file_private_data, + int (*ioctl) (struct snd_info_entry *entry, void *file_private_data, struct file * file, unsigned int cmd, unsigned long arg); - int (*mmap) (snd_info_entry_t *entry, void *file_private_data, + int (*mmap) (struct snd_info_entry *entry, void *file_private_data, struct inode * inode, struct file * file, struct vm_area_struct * vma); }; @@ -80,20 +78,20 @@ struct snd_info_entry { struct snd_info_entry_text text; struct snd_info_entry_ops *ops; } c; - snd_info_entry_t *parent; - snd_card_t *card; + struct snd_info_entry *parent; + struct snd_card *card; struct module *module; void *private_data; - void (*private_free)(snd_info_entry_t *entry); + void (*private_free)(struct snd_info_entry *entry); struct proc_dir_entry *p; struct semaphore access; }; -extern int snd_info_check_reserved_words(const char *str); +int snd_info_check_reserved_words(const char *str); #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) -extern int snd_info_minor_register(void); -extern int snd_info_minor_unregister(void); +int snd_info_minor_register(void); +int snd_info_minor_unregister(void); #else #define snd_info_minor_register() /* NOP */ #define snd_info_minor_unregister() /* NOP */ @@ -102,42 +100,42 @@ extern int snd_info_minor_unregister(void); #ifdef CONFIG_PROC_FS -extern snd_info_entry_t *snd_seq_root; +extern struct snd_info_entry *snd_seq_root; #ifdef CONFIG_SND_OSSEMUL -extern snd_info_entry_t *snd_oss_root; +extern struct snd_info_entry *snd_oss_root; #else #define snd_oss_root NULL #endif -int snd_iprintf(snd_info_buffer_t * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3))); +int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3))); int snd_info_init(void); int snd_info_done(void); -int snd_info_get_line(snd_info_buffer_t * buffer, char *line, int len); +int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len); char *snd_info_get_str(char *dest, char *src, int len); -snd_info_entry_t *snd_info_create_module_entry(struct module * module, +struct snd_info_entry *snd_info_create_module_entry(struct module * module, const char *name, - snd_info_entry_t * parent); -snd_info_entry_t *snd_info_create_card_entry(snd_card_t * card, + struct snd_info_entry * parent); +struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card, const char *name, - snd_info_entry_t * parent); -void snd_info_free_entry(snd_info_entry_t * entry); -int snd_info_store_text(snd_info_entry_t * entry); -int snd_info_restore_text(snd_info_entry_t * entry); + struct snd_info_entry * parent); +void snd_info_free_entry(struct snd_info_entry * entry); +int snd_info_store_text(struct snd_info_entry * entry); +int snd_info_restore_text(struct snd_info_entry * entry); -int snd_info_card_create(snd_card_t * card); -int snd_info_card_register(snd_card_t * card); -int snd_info_card_free(snd_card_t * card); -int snd_info_register(snd_info_entry_t * entry); -int snd_info_unregister(snd_info_entry_t * entry); +int snd_info_card_create(struct snd_card * card); +int snd_info_card_register(struct snd_card * card); +int snd_info_card_free(struct snd_card * card); +int snd_info_register(struct snd_info_entry * entry); +int snd_info_unregister(struct snd_info_entry * entry); /* for card drivers */ -int snd_card_proc_new(snd_card_t *card, const char *name, snd_info_entry_t **entryp); +int snd_card_proc_new(struct snd_card *card, const char *name, struct snd_info_entry **entryp); -static inline void snd_info_set_text_ops(snd_info_entry_t *entry, +static inline void snd_info_set_text_ops(struct snd_info_entry *entry, void *private_data, long read_size, - void (*read)(snd_info_entry_t *, snd_info_buffer_t *)) + void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) { entry->private_data = private_data; entry->c.text.read_size = read_size; @@ -150,21 +148,21 @@ static inline void snd_info_set_text_ops(snd_info_entry_t *entry, #define snd_seq_root NULL #define snd_oss_root NULL -static inline int snd_iprintf(snd_info_buffer_t * buffer, char *fmt,...) { return 0; } +static inline int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) { return 0; } static inline int snd_info_init(void) { return 0; } static inline int snd_info_done(void) { return 0; } -static inline int snd_info_get_line(snd_info_buffer_t * buffer, char *line, int len) { return 0; } +static inline int snd_info_get_line(struct snd_info_buffer * buffer, char *line, int len) { return 0; } static inline char *snd_info_get_str(char *dest, char *src, int len) { return NULL; } -static inline snd_info_entry_t *snd_info_create_module_entry(struct module * module, const char *name, snd_info_entry_t * parent) { return NULL; } -static inline snd_info_entry_t *snd_info_create_card_entry(snd_card_t * card, const char *name, snd_info_entry_t * parent) { return NULL; } -static inline void snd_info_free_entry(snd_info_entry_t * entry) { ; } +static inline struct snd_info_entry *snd_info_create_module_entry(struct module * module, const char *name, struct snd_info_entry * parent) { return NULL; } +static inline struct snd_info_entry *snd_info_create_card_entry(struct snd_card * card, const char *name, struct snd_info_entry * parent) { return NULL; } +static inline void snd_info_free_entry(struct snd_info_entry * entry) { ; } -static inline int snd_info_card_create(snd_card_t * card) { return 0; } -static inline int snd_info_card_register(snd_card_t * card) { return 0; } -static inline int snd_info_card_free(snd_card_t * card) { return 0; } -static inline int snd_info_register(snd_info_entry_t * entry) { return 0; } -static inline int snd_info_unregister(snd_info_entry_t * entry) { return 0; } +static inline int snd_info_card_create(struct snd_card * card) { return 0; } +static inline int snd_info_card_register(struct snd_card * card) { return 0; } +static inline int snd_info_card_free(struct snd_card * card) { return 0; } +static inline int snd_info_register(struct snd_info_entry * entry) { return 0; } +static inline int snd_info_unregister(struct snd_info_entry * entry) { return 0; } #define snd_card_proc_new(card,name,entryp) 0 /* always success */ #define snd_info_set_text_ops(entry,private_data,read_size,read) /*NOP*/ @@ -185,7 +183,7 @@ static inline int snd_info_unregister(snd_info_entry_t * entry) { return 0; } #define SNDRV_OSS_INFO_DEV_COUNT 6 -extern int snd_oss_info_register(int dev, int num, char *string); +int snd_oss_info_register(int dev, int num, char *string); #define snd_oss_info_unregister(dev, num) snd_oss_info_register(dev, num, NULL) #endif /* CONFIG_SND_OSSEMUL && CONFIG_PROC_FS */ diff --git a/sound/core/info.c b/sound/core/info.c index 39f9b97..ec3282f 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -70,12 +70,12 @@ int snd_info_check_reserved_words(const char *str) static DECLARE_MUTEX(info_mutex); -typedef struct _snd_info_private_data { - snd_info_buffer_t *rbuffer; - snd_info_buffer_t *wbuffer; - snd_info_entry_t *entry; +struct snd_info_private_data { + struct snd_info_buffer *rbuffer; + struct snd_info_buffer *wbuffer; + struct snd_info_entry *entry; void *file_private_data; -} snd_info_private_data_t; +}; static int snd_info_version_init(void); static int snd_info_version_done(void); @@ -90,7 +90,7 @@ static int snd_info_version_done(void); * * Returns the size of output string. */ -int snd_iprintf(snd_info_buffer_t * buffer, char *fmt,...) +int snd_iprintf(struct snd_info_buffer *buffer, char *fmt,...) { va_list args; int len, res; @@ -115,9 +115,9 @@ int snd_iprintf(snd_info_buffer_t * buffer, char *fmt,...) */ static struct proc_dir_entry *snd_proc_root = NULL; -snd_info_entry_t *snd_seq_root = NULL; +struct snd_info_entry *snd_seq_root = NULL; #ifdef CONFIG_SND_OSSEMUL -snd_info_entry_t *snd_oss_root = NULL; +struct snd_info_entry *snd_oss_root = NULL; #endif static inline void snd_info_entry_prepare(struct proc_dir_entry *de) @@ -134,7 +134,7 @@ static void snd_remove_proc_entry(struct proc_dir_entry *parent, static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig) { - snd_info_private_data_t *data; + struct snd_info_private_data *data; struct snd_info_entry *entry; loff_t ret; @@ -176,9 +176,9 @@ out: static ssize_t snd_info_entry_read(struct file *file, char __user *buffer, size_t count, loff_t * offset) { - snd_info_private_data_t *data; + struct snd_info_private_data *data; struct snd_info_entry *entry; - snd_info_buffer_t *buf; + struct snd_info_buffer *buf; size_t size = 0; loff_t pos; @@ -217,9 +217,9 @@ static ssize_t snd_info_entry_read(struct file *file, char __user *buffer, static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer, size_t count, loff_t * offset) { - snd_info_private_data_t *data; + struct snd_info_private_data *data; struct snd_info_entry *entry; - snd_info_buffer_t *buf; + struct snd_info_buffer *buf; size_t size = 0; loff_t pos; @@ -259,15 +259,15 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer static int snd_info_entry_open(struct inode *inode, struct file *file) { - snd_info_entry_t *entry; - snd_info_private_data_t *data; - snd_info_buffer_t *buffer; + struct snd_info_entry *entry; + struct snd_info_private_data *data; + struct snd_info_buffer *buffer; struct proc_dir_entry *p; int mode, err; down(&info_mutex); p = PDE(inode); - entry = p == NULL ? NULL : (snd_info_entry_t *)p->data; + entry = p == NULL ? NULL : (struct snd_info_entry *)p->data; if (entry == NULL || entry->disconnected) { up(&info_mutex); return -ENODEV; @@ -381,8 +381,8 @@ static int snd_info_entry_open(struct inode *inode, struct file *file) static int snd_info_entry_release(struct inode *inode, struct file *file) { - snd_info_entry_t *entry; - snd_info_private_data_t *data; + struct snd_info_entry *entry; + struct snd_info_private_data *data; int mode; mode = file->f_flags & O_ACCMODE; @@ -420,7 +420,7 @@ static int snd_info_entry_release(struct inode *inode, struct file *file) static unsigned int snd_info_entry_poll(struct file *file, poll_table * wait) { - snd_info_private_data_t *data; + struct snd_info_private_data *data; struct snd_info_entry *entry; unsigned int mask; @@ -447,7 +447,7 @@ static unsigned int snd_info_entry_poll(struct file *file, poll_table * wait) static inline int _snd_info_entry_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { - snd_info_private_data_t *data; + struct snd_info_private_data *data; struct snd_info_entry *entry; data = file->private_data; @@ -479,7 +479,7 @@ static int snd_info_entry_ioctl(struct inode *inode, struct file *file, static int snd_info_entry_mmap(struct file *file, struct vm_area_struct *vma) { struct inode *inode = file->f_dentry->d_inode; - snd_info_private_data_t *data; + struct snd_info_private_data *data; struct snd_info_entry *entry; data = file->private_data; @@ -541,7 +541,7 @@ int __init snd_info_init(void) snd_proc_root = p; #ifdef CONFIG_SND_OSSEMUL { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if ((entry = snd_info_create_module_entry(THIS_MODULE, "oss", NULL)) == NULL) return -ENOMEM; entry->mode = S_IFDIR | S_IRUGO | S_IXUGO; @@ -554,7 +554,7 @@ int __init snd_info_init(void) #endif #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if ((entry = snd_info_create_module_entry(THIS_MODULE, "seq", NULL)) == NULL) return -ENOMEM; entry->mode = S_IFDIR | S_IRUGO | S_IXUGO; @@ -601,10 +601,10 @@ int __exit snd_info_done(void) * create a card proc file * called from init.c */ -int snd_info_card_create(snd_card_t * card) +int snd_info_card_create(struct snd_card *card) { char str[8]; - snd_info_entry_t *entry; + struct snd_info_entry *entry; snd_assert(card != NULL, return -ENXIO); @@ -624,7 +624,7 @@ int snd_info_card_create(snd_card_t * card) * register the card proc file * called from init.c */ -int snd_info_card_register(snd_card_t * card) +int snd_info_card_register(struct snd_card *card) { struct proc_dir_entry *p; @@ -644,7 +644,7 @@ int snd_info_card_register(snd_card_t * card) * de-register the card proc file * called from init.c */ -int snd_info_card_free(snd_card_t * card) +int snd_info_card_free(struct snd_card *card) { snd_assert(card != NULL, return -ENXIO); if (card->proc_root_link) { @@ -669,7 +669,7 @@ int snd_info_card_free(snd_card_t * card) * * Returns zero if successful, or 1 if error or EOF. */ -int snd_info_get_line(snd_info_buffer_t * buffer, char *line, int len) +int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len) { int c = -1; @@ -747,9 +747,9 @@ char *snd_info_get_str(char *dest, char *src, int len) * * Returns the pointer of the new instance, or NULL on failure. */ -static snd_info_entry_t *snd_info_create_entry(const char *name) +static struct snd_info_entry *snd_info_create_entry(const char *name) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = kzalloc(sizeof(*entry), GFP_KERNEL); if (entry == NULL) return NULL; @@ -774,11 +774,11 @@ static snd_info_entry_t *snd_info_create_entry(const char *name) * * Returns the pointer of the new instance, or NULL on failure. */ -snd_info_entry_t *snd_info_create_module_entry(struct module * module, +struct snd_info_entry *snd_info_create_module_entry(struct module * module, const char *name, - snd_info_entry_t *parent) + struct snd_info_entry *parent) { - snd_info_entry_t *entry = snd_info_create_entry(name); + struct snd_info_entry *entry = snd_info_create_entry(name); if (entry) { entry->module = module; entry->parent = parent; @@ -796,11 +796,11 @@ snd_info_entry_t *snd_info_create_module_entry(struct module * module, * * Returns the pointer of the new instance, or NULL on failure. */ -snd_info_entry_t *snd_info_create_card_entry(snd_card_t * card, +struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card, const char *name, - snd_info_entry_t * parent) + struct snd_info_entry * parent) { - snd_info_entry_t *entry = snd_info_create_entry(name); + struct snd_info_entry *entry = snd_info_create_entry(name); if (entry) { entry->module = card->module; entry->card = card; @@ -809,29 +809,29 @@ snd_info_entry_t *snd_info_create_card_entry(snd_card_t * card, return entry; } -static int snd_info_dev_free_entry(snd_device_t *device) +static int snd_info_dev_free_entry(struct snd_device *device) { - snd_info_entry_t *entry = device->device_data; + struct snd_info_entry *entry = device->device_data; snd_info_free_entry(entry); return 0; } -static int snd_info_dev_register_entry(snd_device_t *device) +static int snd_info_dev_register_entry(struct snd_device *device) { - snd_info_entry_t *entry = device->device_data; + struct snd_info_entry *entry = device->device_data; return snd_info_register(entry); } -static int snd_info_dev_disconnect_entry(snd_device_t *device) +static int snd_info_dev_disconnect_entry(struct snd_device *device) { - snd_info_entry_t *entry = device->device_data; + struct snd_info_entry *entry = device->device_data; entry->disconnected = 1; return 0; } -static int snd_info_dev_unregister_entry(snd_device_t *device) +static int snd_info_dev_unregister_entry(struct snd_device *device) { - snd_info_entry_t *entry = device->device_data; + struct snd_info_entry *entry = device->device_data; return snd_info_unregister(entry); } @@ -855,16 +855,16 @@ static int snd_info_dev_unregister_entry(snd_device_t *device) * * Returns zero if successful, or a negative error code on failure. */ -int snd_card_proc_new(snd_card_t *card, const char *name, - snd_info_entry_t **entryp) +int snd_card_proc_new(struct snd_card *card, const char *name, + struct snd_info_entry **entryp) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_info_dev_free_entry, .dev_register = snd_info_dev_register_entry, .dev_disconnect = snd_info_dev_disconnect_entry, .dev_unregister = snd_info_dev_unregister_entry }; - snd_info_entry_t *entry; + struct snd_info_entry *entry; int err; entry = snd_info_create_card_entry(card, name, card->proc_root); @@ -885,7 +885,7 @@ int snd_card_proc_new(snd_card_t *card, const char *name, * * Releases the info entry. Don't call this after registered. */ -void snd_info_free_entry(snd_info_entry_t * entry) +void snd_info_free_entry(struct snd_info_entry * entry) { if (entry == NULL) return; @@ -903,7 +903,7 @@ void snd_info_free_entry(snd_info_entry_t * entry) * * Returns zero if successful, or a negative error code on failure. */ -int snd_info_register(snd_info_entry_t * entry) +int snd_info_register(struct snd_info_entry * entry) { struct proc_dir_entry *root, *p = NULL; @@ -933,7 +933,7 @@ int snd_info_register(snd_info_entry_t * entry) * * Returns zero if successful, or a negative error code on failure. */ -int snd_info_unregister(snd_info_entry_t * entry) +int snd_info_unregister(struct snd_info_entry * entry) { struct proc_dir_entry *root; @@ -952,9 +952,9 @@ int snd_info_unregister(snd_info_entry_t * entry) */ -static snd_info_entry_t *snd_info_version_entry = NULL; +static struct snd_info_entry *snd_info_version_entry = NULL; -static void snd_info_version_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_info_version_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { snd_iprintf(buffer, "Advanced Linux Sound Architecture Driver Version " @@ -964,7 +964,7 @@ static void snd_info_version_read(snd_info_entry_t *entry, snd_info_buffer_t * b static int __init snd_info_version_init(void) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = snd_info_create_module_entry(THIS_MODULE, "version", NULL); if (entry == NULL) -- cgit v1.1 From 877211f5e1b1196179ba1290e8e1a3dc00427c55 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 13:59:38 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCM Modules: PCM Midlevel Remove xxx_t typedefs from the core PCM codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/pcm-indirect.h | 28 +- include/sound/pcm.h | 477 ++++++++++++++++----------------- include/sound/pcm_params.h | 86 +++--- sound/core/pcm.c | 214 ++++++++------- sound/core/pcm_compat.c | 110 ++++---- sound/core/pcm_lib.c | 320 +++++++++++----------- sound/core/pcm_memory.c | 45 ++-- sound/core/pcm_misc.c | 2 +- sound/core/pcm_native.c | 623 +++++++++++++++++++++++-------------------- sound/core/pcm_timer.c | 30 +-- 10 files changed, 983 insertions(+), 952 deletions(-) diff --git a/include/sound/pcm-indirect.h b/include/sound/pcm-indirect.h index 31fa7a5..7003d77 100644 --- a/include/sound/pcm-indirect.h +++ b/include/sound/pcm-indirect.h @@ -24,7 +24,7 @@ #include <sound/pcm.h> -typedef struct sndrv_pcm_indirect { +struct snd_pcm_indirect { unsigned int hw_buffer_size; /* Byte size of hardware buffer */ unsigned int hw_queue_size; /* Max queue size of hw buffer (0 = buffer size) */ unsigned int hw_data; /* Offset to next dst (or src) in hw ring buffer */ @@ -35,20 +35,20 @@ typedef struct sndrv_pcm_indirect { unsigned int sw_io; /* Current software pointer in bytes */ int sw_ready; /* Bytes ready to be transferred to/from hw */ snd_pcm_uframes_t appl_ptr; /* Last seen appl_ptr */ -} snd_pcm_indirect_t; +}; -typedef void (*snd_pcm_indirect_copy_t)(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, size_t bytes); +typedef void (*snd_pcm_indirect_copy_t)(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes); /* * helper function for playback ack callback */ static inline void -snd_pcm_indirect_playback_transfer(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, +snd_pcm_indirect_playback_transfer(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, snd_pcm_indirect_copy_t copy) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t appl_ptr = runtime->control->appl_ptr; snd_pcm_sframes_t diff = appl_ptr - rec->appl_ptr; int qsize; @@ -89,8 +89,8 @@ snd_pcm_indirect_playback_transfer(snd_pcm_substream_t *substream, * ptr = current byte pointer */ static inline snd_pcm_uframes_t -snd_pcm_indirect_playback_pointer(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, unsigned int ptr) +snd_pcm_indirect_playback_pointer(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, unsigned int ptr) { int bytes = ptr - rec->hw_io; if (bytes < 0) @@ -110,11 +110,11 @@ snd_pcm_indirect_playback_pointer(snd_pcm_substream_t *substream, * helper function for capture ack callback */ static inline void -snd_pcm_indirect_capture_transfer(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, +snd_pcm_indirect_capture_transfer(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, snd_pcm_indirect_copy_t copy) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t appl_ptr = runtime->control->appl_ptr; snd_pcm_sframes_t diff = appl_ptr - rec->appl_ptr; @@ -154,8 +154,8 @@ snd_pcm_indirect_capture_transfer(snd_pcm_substream_t *substream, * ptr = current byte pointer */ static inline snd_pcm_uframes_t -snd_pcm_indirect_capture_pointer(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, unsigned int ptr) +snd_pcm_indirect_capture_pointer(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, unsigned int ptr) { int qsize; int bytes = ptr - rec->hw_io; diff --git a/include/sound/pcm.h b/include/sound/pcm.h index acc4fa9..7e77c0a 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -28,36 +28,9 @@ #include <linux/poll.h> #include <linux/bitops.h> -typedef sndrv_pcm_uframes_t snd_pcm_uframes_t; -typedef sndrv_pcm_sframes_t snd_pcm_sframes_t; -typedef enum sndrv_pcm_class snd_pcm_class_t; -typedef enum sndrv_pcm_subclass snd_pcm_subclass_t; -typedef enum sndrv_pcm_stream snd_pcm_stream_t; -typedef enum sndrv_pcm_access snd_pcm_access_t; -typedef enum sndrv_pcm_format snd_pcm_format_t; -typedef enum sndrv_pcm_subformat snd_pcm_subformat_t; -typedef enum sndrv_pcm_state snd_pcm_state_t; -typedef union sndrv_pcm_sync_id snd_pcm_sync_id_t; -typedef struct sndrv_pcm_info snd_pcm_info_t; -typedef enum sndrv_pcm_hw_param snd_pcm_hw_param_t; -typedef struct sndrv_pcm_hw_params snd_pcm_hw_params_t; -typedef enum sndrv_pcm_start snd_pcm_start_t; -typedef enum sndrv_pcm_xrun snd_pcm_xrun_t; -typedef enum sndrv_pcm_tstamp snd_pcm_tstamp_t; -typedef struct sndrv_pcm_sw_params snd_pcm_sw_params_t; -typedef struct sndrv_pcm_channel_info snd_pcm_channel_info_t; -typedef struct sndrv_pcm_status snd_pcm_status_t; -typedef struct sndrv_pcm_mmap_status snd_pcm_mmap_status_t; -typedef struct sndrv_pcm_mmap_control snd_pcm_mmap_control_t; -typedef struct sndrv_mask snd_mask_t; -typedef struct snd_sg_buf snd_pcm_sgbuf_t; - #define snd_pcm_substream_chip(substream) ((substream)->private_data) #define snd_pcm_chip(pcm) ((pcm)->private_data) -typedef struct _snd_pcm_file snd_pcm_file_t; -typedef struct _snd_pcm_runtime snd_pcm_runtime_t; - #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) #include "pcm_oss.h" #endif @@ -66,7 +39,7 @@ typedef struct _snd_pcm_runtime snd_pcm_runtime_t; * Hardware (lowlevel) section */ -typedef struct _snd_pcm_hardware { +struct snd_pcm_hardware { unsigned int info; /* SNDRV_PCM_INFO_* */ u64 formats; /* SNDRV_PCM_FMTBIT_* */ unsigned int rates; /* SNDRV_PCM_RATE_* */ @@ -80,26 +53,29 @@ typedef struct _snd_pcm_hardware { unsigned int periods_min; /* min # of periods */ unsigned int periods_max; /* max # of periods */ size_t fifo_size; /* fifo size in bytes */ -} snd_pcm_hardware_t; +}; -typedef struct _snd_pcm_ops { - int (*open)(snd_pcm_substream_t *substream); - int (*close)(snd_pcm_substream_t *substream); - int (*ioctl)(snd_pcm_substream_t * substream, +struct snd_pcm_ops { + int (*open)(struct snd_pcm_substream *substream); + int (*close)(struct snd_pcm_substream *substream); + int (*ioctl)(struct snd_pcm_substream * substream, unsigned int cmd, void *arg); - int (*hw_params)(snd_pcm_substream_t * substream, snd_pcm_hw_params_t * params); - int (*hw_free)(snd_pcm_substream_t *substream); - int (*prepare)(snd_pcm_substream_t * substream); - int (*trigger)(snd_pcm_substream_t * substream, int cmd); - snd_pcm_uframes_t (*pointer)(snd_pcm_substream_t * substream); - int (*copy)(snd_pcm_substream_t *substream, int channel, snd_pcm_uframes_t pos, + int (*hw_params)(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params); + int (*hw_free)(struct snd_pcm_substream *substream); + int (*prepare)(struct snd_pcm_substream *substream); + int (*trigger)(struct snd_pcm_substream *substream, int cmd); + snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *substream); + int (*copy)(struct snd_pcm_substream *substream, int channel, + snd_pcm_uframes_t pos, void __user *buf, snd_pcm_uframes_t count); - int (*silence)(snd_pcm_substream_t *substream, int channel, + int (*silence)(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, snd_pcm_uframes_t count); - struct page *(*page)(snd_pcm_substream_t *substream, unsigned long offset); - int (*mmap)(snd_pcm_substream_t *substream, struct vm_area_struct *vma); - int (*ack)(snd_pcm_substream_t *substream); -} snd_pcm_ops_t; + struct page *(*page)(struct snd_pcm_substream *substream, + unsigned long offset); + int (*mmap)(struct snd_pcm_substream *substream, struct vm_area_struct *vma); + int (*ack)(struct snd_pcm_substream *substream); +}; /* * @@ -212,17 +188,16 @@ typedef struct _snd_pcm_ops { #define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE #endif -struct _snd_pcm_file { - snd_pcm_substream_t * substream; - struct _snd_pcm_file * next; +struct snd_pcm_file { + struct snd_pcm_substream *substream; + struct snd_pcm_file *next; }; -typedef struct _snd_pcm_hw_rule snd_pcm_hw_rule_t; +struct snd_pcm_hw_rule; +typedef int (*snd_pcm_hw_rule_func_t)(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule); -typedef int (*snd_pcm_hw_rule_func_t)(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule); - -struct _snd_pcm_hw_rule { +struct snd_pcm_hw_rule { unsigned int cond; snd_pcm_hw_rule_func_t func; int var; @@ -230,57 +205,57 @@ struct _snd_pcm_hw_rule { void *private; }; -typedef struct _snd_pcm_hw_constraints { - snd_mask_t masks[SNDRV_PCM_HW_PARAM_LAST_MASK - +struct snd_pcm_hw_constraints { + struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; - snd_interval_t intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - + struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; unsigned int rules_num; unsigned int rules_all; - snd_pcm_hw_rule_t *rules; -} snd_pcm_hw_constraints_t; + struct snd_pcm_hw_rule *rules; +}; -static inline snd_mask_t *constrs_mask(snd_pcm_hw_constraints_t *constrs, - snd_pcm_hw_param_t var) +static inline struct snd_mask *constrs_mask(struct snd_pcm_hw_constraints *constrs, + snd_pcm_hw_param_t var) { return &constrs->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; } -static inline snd_interval_t *constrs_interval(snd_pcm_hw_constraints_t *constrs, - snd_pcm_hw_param_t var) +static inline struct snd_interval *constrs_interval(struct snd_pcm_hw_constraints *constrs, + snd_pcm_hw_param_t var) { return &constrs->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; } -typedef struct { +struct snd_ratnum { unsigned int num; unsigned int den_min, den_max, den_step; -} ratnum_t; +}; -typedef struct { +struct snd_ratden { unsigned int num_min, num_max, num_step; unsigned int den; -} ratden_t; +}; -typedef struct { +struct snd_pcm_hw_constraint_ratnums { int nrats; - ratnum_t *rats; -} snd_pcm_hw_constraint_ratnums_t; + struct snd_ratnum *rats; +}; -typedef struct { +struct snd_pcm_hw_constraint_ratdens { int nrats; - ratden_t *rats; -} snd_pcm_hw_constraint_ratdens_t; + struct snd_ratden *rats; +}; -typedef struct { +struct snd_pcm_hw_constraint_list { unsigned int count; unsigned int *list; unsigned int mask; -} snd_pcm_hw_constraint_list_t; +}; -struct _snd_pcm_runtime { +struct snd_pcm_runtime { /* -- Status -- */ - snd_pcm_substream_t *trigger_master; + struct snd_pcm_substream *trigger_master; struct timespec trigger_tstamp; /* trigger timestamp */ int overrange; snd_pcm_uframes_t avail_max; @@ -306,7 +281,7 @@ struct _snd_pcm_runtime { unsigned int rate_den; /* -- SW params -- */ - snd_pcm_tstamp_t tstamp_mode; /* mmap timestamp is updated */ + int tstamp_mode; /* mmap timestamp is updated */ unsigned int period_step; unsigned int sleep_min; /* min ticks to sleep */ snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */ @@ -320,11 +295,11 @@ struct _snd_pcm_runtime { snd_pcm_uframes_t silence_start; /* starting pointer to silence area */ snd_pcm_uframes_t silence_filled; /* size filled with silence */ - snd_pcm_sync_id_t sync; /* hardware synchronization ID */ + union snd_pcm_sync_id sync; /* hardware synchronization ID */ /* -- mmap -- */ - volatile snd_pcm_mmap_status_t *status; - volatile snd_pcm_mmap_control_t *control; + volatile struct snd_pcm_mmap_status *status; + volatile struct snd_pcm_mmap_control *control; atomic_t mmap_count; /* -- locking / scheduling -- */ @@ -334,15 +309,15 @@ struct _snd_pcm_runtime { /* -- private section -- */ void *private_data; - void (*private_free)(snd_pcm_runtime_t *runtime); + void (*private_free)(struct snd_pcm_runtime *runtime); /* -- hardware description -- */ - snd_pcm_hardware_t hw; - snd_pcm_hw_constraints_t hw_constraints; + struct snd_pcm_hardware hw; + struct snd_pcm_hw_constraints hw_constraints; /* -- interrupt callbacks -- */ - void (*transfer_ack_begin)(snd_pcm_substream_t *substream); - void (*transfer_ack_end)(snd_pcm_substream_t *substream); + void (*transfer_ack_begin)(struct snd_pcm_substream *substream); + void (*transfer_ack_end)(struct snd_pcm_substream *substream); /* -- timer -- */ unsigned int timer_resolution; /* timer resolution */ @@ -356,19 +331,19 @@ struct _snd_pcm_runtime { #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) /* -- OSS things -- */ - snd_pcm_oss_runtime_t oss; + struct snd_pcm_oss_runtime oss; #endif }; -typedef struct _snd_pcm_group { /* keep linked substreams */ +struct snd_pcm_group { /* keep linked substreams */ spinlock_t lock; struct list_head substreams; int count; -} snd_pcm_group_t; +}; -struct _snd_pcm_substream { - snd_pcm_t *pcm; - snd_pcm_str_t *pstr; +struct snd_pcm_substream { + struct snd_pcm *pcm; + struct snd_pcm_str *pstr; void *private_data; /* copied from pcm->private_data */ int number; char name[32]; /* substream name */ @@ -378,32 +353,32 @@ struct _snd_pcm_substream { unsigned int dma_buf_id; size_t dma_max; /* -- hardware operations -- */ - snd_pcm_ops_t *ops; + struct snd_pcm_ops *ops; /* -- runtime information -- */ - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; /* -- timer section -- */ - snd_timer_t *timer; /* timer */ + struct snd_timer *timer; /* timer */ unsigned timer_running: 1; /* time is running */ spinlock_t timer_lock; /* -- next substream -- */ - snd_pcm_substream_t *next; + struct snd_pcm_substream *next; /* -- linked substreams -- */ struct list_head link_list; /* linked list member */ - snd_pcm_group_t self_group; /* fake group for non linked substream (with substream lock inside) */ - snd_pcm_group_t *group; /* pointer to current group */ + struct snd_pcm_group self_group; /* fake group for non linked substream (with substream lock inside) */ + struct snd_pcm_group *group; /* pointer to current group */ /* -- assigned files -- */ - snd_pcm_file_t *file; + struct snd_pcm_file *file; struct file *ffile; #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) /* -- OSS things -- */ - snd_pcm_oss_substream_t oss; + struct snd_pcm_oss_substream oss; #endif - snd_info_entry_t *proc_root; - snd_info_entry_t *proc_info_entry; - snd_info_entry_t *proc_hw_params_entry; - snd_info_entry_t *proc_sw_params_entry; - snd_info_entry_t *proc_status_entry; - snd_info_entry_t *proc_prealloc_entry; + struct snd_info_entry *proc_root; + struct snd_info_entry *proc_info_entry; + struct snd_info_entry *proc_hw_params_entry; + struct snd_info_entry *proc_sw_params_entry; + struct snd_info_entry *proc_status_entry; + struct snd_info_entry *proc_prealloc_entry; /* misc flags */ unsigned int no_mmap_ctrl: 1; }; @@ -415,65 +390,65 @@ struct _snd_pcm_substream { #endif -struct _snd_pcm_str { +struct snd_pcm_str { int stream; /* stream (direction) */ - snd_pcm_t *pcm; + struct snd_pcm *pcm; /* -- substreams -- */ unsigned int substream_count; unsigned int substream_opened; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) /* -- OSS things -- */ - snd_pcm_oss_stream_t oss; + struct snd_pcm_oss_stream oss; #endif - snd_pcm_file_t *files; - snd_minor_t *reg; - snd_info_entry_t *proc_root; - snd_info_entry_t *proc_info_entry; + struct snd_pcm_file *files; + struct snd_minor *reg; + struct snd_info_entry *proc_root; + struct snd_info_entry *proc_info_entry; #ifdef CONFIG_SND_DEBUG unsigned int xrun_debug; /* 0 = disabled, 1 = verbose, 2 = stacktrace */ - snd_info_entry_t *proc_xrun_debug_entry; + struct snd_info_entry *proc_xrun_debug_entry; #endif }; -struct _snd_pcm { - snd_card_t *card; +struct snd_pcm { + struct snd_card *card; unsigned int device; /* device number */ unsigned int info_flags; unsigned short dev_class; unsigned short dev_subclass; char id[64]; char name[80]; - snd_pcm_str_t streams[2]; + struct snd_pcm_str streams[2]; struct semaphore open_mutex; wait_queue_head_t open_wait; void *private_data; - void (*private_free) (snd_pcm_t *pcm); + void (*private_free) (struct snd_pcm *pcm); #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) - snd_pcm_oss_t oss; + struct snd_pcm_oss oss; #endif }; -typedef struct _snd_pcm_notify { - int (*n_register) (snd_pcm_t * pcm); - int (*n_disconnect) (snd_pcm_t * pcm); - int (*n_unregister) (snd_pcm_t * pcm); +struct snd_pcm_notify { + int (*n_register) (struct snd_pcm * pcm); + int (*n_disconnect) (struct snd_pcm * pcm); + int (*n_unregister) (struct snd_pcm * pcm); struct list_head list; -} snd_pcm_notify_t; +}; /* * Registering */ -extern snd_pcm_t *snd_pcm_devices[]; -extern snd_minor_t snd_pcm_reg[2]; +extern struct snd_pcm *snd_pcm_devices[]; +extern struct snd_minor snd_pcm_reg[2]; -int snd_pcm_new(snd_card_t * card, char *id, int device, +int snd_pcm_new(struct snd_card *card, char *id, int device, int playback_count, int capture_count, - snd_pcm_t **rpcm); -int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count); + struct snd_pcm **rpcm); +int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count); -int snd_pcm_notify(snd_pcm_notify_t *notify, int nfree); +int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree); /* * Native I/O @@ -481,24 +456,26 @@ int snd_pcm_notify(snd_pcm_notify_t *notify, int nfree); extern rwlock_t snd_pcm_link_rwlock; -int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info); -int snd_pcm_info_user(snd_pcm_substream_t * substream, snd_pcm_info_t __user *info); -int snd_pcm_status(snd_pcm_substream_t * substream, snd_pcm_status_t *status); -int snd_pcm_prepare(snd_pcm_substream_t *substream); -int snd_pcm_start(snd_pcm_substream_t *substream); -int snd_pcm_stop(snd_pcm_substream_t *substream, int status); -int snd_pcm_drain_done(snd_pcm_substream_t *substream); +int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info); +int snd_pcm_info_user(struct snd_pcm_substream *substream, + struct snd_pcm_info __user *info); +int snd_pcm_status(struct snd_pcm_substream *substream, + struct snd_pcm_status *status); +int snd_pcm_prepare(struct snd_pcm_substream *substream); +int snd_pcm_start(struct snd_pcm_substream *substream); +int snd_pcm_stop(struct snd_pcm_substream *substream, int status); +int snd_pcm_drain_done(struct snd_pcm_substream *substream); #ifdef CONFIG_PM -int snd_pcm_suspend(snd_pcm_substream_t *substream); -int snd_pcm_suspend_all(snd_pcm_t *pcm); +int snd_pcm_suspend(struct snd_pcm_substream *substream); +int snd_pcm_suspend_all(struct snd_pcm *pcm); #endif -int snd_pcm_kernel_playback_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg); -int snd_pcm_kernel_capture_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg); -int snd_pcm_kernel_ioctl(snd_pcm_substream_t *substream, unsigned int cmd, void *arg); -int snd_pcm_open_substream(snd_pcm_t *pcm, int stream, snd_pcm_substream_t **rsubstream); -void snd_pcm_release_substream(snd_pcm_substream_t *substream); +int snd_pcm_kernel_playback_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg); +int snd_pcm_kernel_capture_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg); +int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg); +int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, struct snd_pcm_substream **rsubstream); +void snd_pcm_release_substream(struct snd_pcm_substream *substream); void snd_pcm_vma_notify_data(void *client, void *data); -int snd_pcm_mmap_data(snd_pcm_substream_t *substream, struct file *file, struct vm_area_struct *area); +int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area); #if BITS_PER_LONG >= 64 @@ -578,30 +555,30 @@ static inline void div64_32(u_int64_t *n, u_int32_t div, u_int32_t *rem) * PCM library */ -static inline int snd_pcm_stream_linked(snd_pcm_substream_t *substream) +static inline int snd_pcm_stream_linked(struct snd_pcm_substream *substream) { return substream->group != &substream->self_group; } -static inline void snd_pcm_stream_lock(snd_pcm_substream_t *substream) +static inline void snd_pcm_stream_lock(struct snd_pcm_substream *substream) { read_lock(&snd_pcm_link_rwlock); spin_lock(&substream->self_group.lock); } -static inline void snd_pcm_stream_unlock(snd_pcm_substream_t *substream) +static inline void snd_pcm_stream_unlock(struct snd_pcm_substream *substream) { spin_unlock(&substream->self_group.lock); read_unlock(&snd_pcm_link_rwlock); } -static inline void snd_pcm_stream_lock_irq(snd_pcm_substream_t *substream) +static inline void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) { read_lock_irq(&snd_pcm_link_rwlock); spin_lock(&substream->self_group.lock); } -static inline void snd_pcm_stream_unlock_irq(snd_pcm_substream_t *substream) +static inline void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream) { spin_unlock(&substream->self_group.lock); read_unlock_irq(&snd_pcm_link_rwlock); @@ -623,56 +600,56 @@ do { \ list_for_each(pos, &substream->group->substreams) #define snd_pcm_group_substream_entry(pos) \ - list_entry(pos, snd_pcm_substream_t, link_list) + list_entry(pos, struct snd_pcm_substream, link_list) -static inline int snd_pcm_running(snd_pcm_substream_t *substream) +static inline int snd_pcm_running(struct snd_pcm_substream *substream) { return (substream->runtime->status->state == SNDRV_PCM_STATE_RUNNING || (substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING && substream->stream == SNDRV_PCM_STREAM_PLAYBACK)); } -static inline ssize_t bytes_to_samples(snd_pcm_runtime_t *runtime, ssize_t size) +static inline ssize_t bytes_to_samples(struct snd_pcm_runtime *runtime, ssize_t size) { return size * 8 / runtime->sample_bits; } -static inline snd_pcm_sframes_t bytes_to_frames(snd_pcm_runtime_t *runtime, ssize_t size) +static inline snd_pcm_sframes_t bytes_to_frames(struct snd_pcm_runtime *runtime, ssize_t size) { return size * 8 / runtime->frame_bits; } -static inline ssize_t samples_to_bytes(snd_pcm_runtime_t *runtime, ssize_t size) +static inline ssize_t samples_to_bytes(struct snd_pcm_runtime *runtime, ssize_t size) { return size * runtime->sample_bits / 8; } -static inline ssize_t frames_to_bytes(snd_pcm_runtime_t *runtime, snd_pcm_sframes_t size) +static inline ssize_t frames_to_bytes(struct snd_pcm_runtime *runtime, snd_pcm_sframes_t size) { return size * runtime->frame_bits / 8; } -static inline int frame_aligned(snd_pcm_runtime_t *runtime, ssize_t bytes) +static inline int frame_aligned(struct snd_pcm_runtime *runtime, ssize_t bytes) { return bytes % runtime->byte_align == 0; } -static inline size_t snd_pcm_lib_buffer_bytes(snd_pcm_substream_t *substream) +static inline size_t snd_pcm_lib_buffer_bytes(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; return frames_to_bytes(runtime, runtime->buffer_size); } -static inline size_t snd_pcm_lib_period_bytes(snd_pcm_substream_t *substream) +static inline size_t snd_pcm_lib_period_bytes(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; return frames_to_bytes(runtime, runtime->period_size); } /* * result is: 0 ... (boundary - 1) */ -static inline snd_pcm_uframes_t snd_pcm_playback_avail(snd_pcm_runtime_t *runtime) +static inline snd_pcm_uframes_t snd_pcm_playback_avail(struct snd_pcm_runtime *runtime) { snd_pcm_sframes_t avail = runtime->status->hw_ptr + runtime->buffer_size - runtime->control->appl_ptr; if (avail < 0) @@ -685,7 +662,7 @@ static inline snd_pcm_uframes_t snd_pcm_playback_avail(snd_pcm_runtime_t *runtim /* * result is: 0 ... (boundary - 1) */ -static inline snd_pcm_uframes_t snd_pcm_capture_avail(snd_pcm_runtime_t *runtime) +static inline snd_pcm_uframes_t snd_pcm_capture_avail(struct snd_pcm_runtime *runtime) { snd_pcm_sframes_t avail = runtime->status->hw_ptr - runtime->control->appl_ptr; if (avail < 0) @@ -693,12 +670,12 @@ static inline snd_pcm_uframes_t snd_pcm_capture_avail(snd_pcm_runtime_t *runtime return avail; } -static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(snd_pcm_runtime_t *runtime) +static inline snd_pcm_sframes_t snd_pcm_playback_hw_avail(struct snd_pcm_runtime *runtime) { return runtime->buffer_size - snd_pcm_playback_avail(runtime); } -static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(snd_pcm_runtime_t *runtime) +static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(struct snd_pcm_runtime *runtime) { return runtime->buffer_size - snd_pcm_capture_avail(runtime); } @@ -711,9 +688,9 @@ static inline snd_pcm_sframes_t snd_pcm_capture_hw_avail(snd_pcm_runtime_t *runt * * Returns non-zero if available, or zero if not. */ -static inline int snd_pcm_playback_ready(snd_pcm_substream_t *substream) +static inline int snd_pcm_playback_ready(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; return snd_pcm_playback_avail(runtime) >= runtime->control->avail_min; } @@ -725,9 +702,9 @@ static inline int snd_pcm_playback_ready(snd_pcm_substream_t *substream) * * Returns non-zero if available, or zero if not. */ -static inline int snd_pcm_capture_ready(snd_pcm_substream_t *substream) +static inline int snd_pcm_capture_ready(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; return snd_pcm_capture_avail(runtime) >= runtime->control->avail_min; } @@ -740,9 +717,9 @@ static inline int snd_pcm_capture_ready(snd_pcm_substream_t *substream) * * Returns non-zero if exists, or zero if not. */ -static inline int snd_pcm_playback_data(snd_pcm_substream_t *substream) +static inline int snd_pcm_playback_data(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->stop_threshold >= runtime->boundary) return 1; @@ -757,9 +734,9 @@ static inline int snd_pcm_playback_data(snd_pcm_substream_t *substream) * * Returns non-zero if empty, or zero if not. */ -static inline int snd_pcm_playback_empty(snd_pcm_substream_t *substream) +static inline int snd_pcm_playback_empty(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; return snd_pcm_playback_avail(runtime) >= runtime->buffer_size; } @@ -771,14 +748,14 @@ static inline int snd_pcm_playback_empty(snd_pcm_substream_t *substream) * * Returns non-zero if empty, or zero if not. */ -static inline int snd_pcm_capture_empty(snd_pcm_substream_t *substream) +static inline int snd_pcm_capture_empty(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; return snd_pcm_capture_avail(runtime) == 0; } -static inline void snd_pcm_trigger_done(snd_pcm_substream_t *substream, - snd_pcm_substream_t *master) +static inline void snd_pcm_trigger_done(struct snd_pcm_substream *substream, + struct snd_pcm_substream *master) { substream->runtime->trigger_master = master; } @@ -795,28 +772,28 @@ static inline int hw_is_interval(int var) var <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; } -static inline snd_mask_t *hw_param_mask(snd_pcm_hw_params_t *params, +static inline struct snd_mask *hw_param_mask(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { return ¶ms->masks[var - SNDRV_PCM_HW_PARAM_FIRST_MASK]; } -static inline snd_interval_t *hw_param_interval(snd_pcm_hw_params_t *params, +static inline struct snd_interval *hw_param_interval(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { return ¶ms->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]; } -static inline const snd_mask_t *hw_param_mask_c(const snd_pcm_hw_params_t *params, +static inline const struct snd_mask *hw_param_mask_c(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { - return (const snd_mask_t *)hw_param_mask((snd_pcm_hw_params_t*) params, var); + return (const struct snd_mask *)hw_param_mask((struct snd_pcm_hw_params*) params, var); } -static inline const snd_interval_t *hw_param_interval_c(const snd_pcm_hw_params_t *params, +static inline const struct snd_interval *hw_param_interval_c(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { - return (const snd_interval_t *)hw_param_interval((snd_pcm_hw_params_t*) params, var); + return (const struct snd_interval *)hw_param_interval((struct snd_pcm_hw_params*) params, var); } #define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS)) @@ -832,66 +809,66 @@ static inline const snd_interval_t *hw_param_interval_c(const snd_pcm_hw_params_ #define params_tick_time(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_TICK_TIME)->min -int snd_interval_refine(snd_interval_t *i, const snd_interval_t *v); -void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c); -void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c); -void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b, - unsigned int k, snd_interval_t *c); -void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k, - const snd_interval_t *b, snd_interval_t *c); -int snd_interval_list(snd_interval_t *i, unsigned int count, unsigned int *list, unsigned int mask); -int snd_interval_ratnum(snd_interval_t *i, - unsigned int rats_count, ratnum_t *rats, +int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v); +void snd_interval_mul(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c); +void snd_interval_div(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c); +void snd_interval_muldivk(const struct snd_interval *a, const struct snd_interval *b, + unsigned int k, struct snd_interval *c); +void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k, + const struct snd_interval *b, struct snd_interval *c); +int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *list, unsigned int mask); +int snd_interval_ratnum(struct snd_interval *i, + unsigned int rats_count, struct snd_ratnum *rats, unsigned int *nump, unsigned int *denp); -void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params); -void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, snd_pcm_hw_param_t var); -int snd_pcm_hw_param_near(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params, +void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params); +void _snd_pcm_hw_param_setempty(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var); +int snd_pcm_hw_param_near(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int *dir); -int snd_pcm_hw_param_set(snd_pcm_substream_t *pcm, - snd_pcm_hw_params_t *params, +int snd_pcm_hw_param_set(struct snd_pcm_substream *pcm, + struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int dir); -int snd_pcm_hw_params_choose(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params); +int snd_pcm_hw_params_choose(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); -int snd_pcm_hw_refine(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *params); +int snd_pcm_hw_refine(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params); -int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream); -int snd_pcm_hw_constraints_complete(snd_pcm_substream_t *substream); +int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream); +int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream); -int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, +int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int32_t mask); -int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, +int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int64_t mask); -int snd_pcm_hw_constraint_minmax(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, +int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, unsigned int min, unsigned int max); -int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var); -int snd_pcm_hw_constraint_list(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var); +int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, - snd_pcm_hw_constraint_list_t *l); -int snd_pcm_hw_constraint_ratnums(snd_pcm_runtime_t *runtime, + struct snd_pcm_hw_constraint_list *l); +int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, - snd_pcm_hw_constraint_ratnums_t *r); -int snd_pcm_hw_constraint_ratdens(snd_pcm_runtime_t *runtime, + struct snd_pcm_hw_constraint_ratnums *r); +int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, - snd_pcm_hw_constraint_ratdens_t *r); -int snd_pcm_hw_constraint_msbits(snd_pcm_runtime_t *runtime, + struct snd_pcm_hw_constraint_ratdens *r); +int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, unsigned int cond, unsigned int width, unsigned int msbits); -int snd_pcm_hw_constraint_step(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, unsigned long step); -int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var); -int snd_pcm_hw_rule_add(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, int var, snd_pcm_hw_rule_func_t func, void *private, @@ -925,37 +902,37 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_endian); const char *snd_pcm_format_name(snd_pcm_format_t format); -void snd_pcm_set_ops(snd_pcm_t * pcm, int direction, snd_pcm_ops_t *ops); -void snd_pcm_set_sync(snd_pcm_substream_t * substream); -int snd_pcm_lib_interleave_len(snd_pcm_substream_t *substream); -int snd_pcm_lib_ioctl(snd_pcm_substream_t *substream, +void snd_pcm_set_ops(struct snd_pcm * pcm, int direction, struct snd_pcm_ops *ops); +void snd_pcm_set_sync(struct snd_pcm_substream *substream); +int snd_pcm_lib_interleave_len(struct snd_pcm_substream *substream); +int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg); -int snd_pcm_update_hw_ptr(snd_pcm_substream_t *substream); -int snd_pcm_playback_xrun_check(snd_pcm_substream_t *substream); -int snd_pcm_capture_xrun_check(snd_pcm_substream_t *substream); -int snd_pcm_playback_xrun_asap(snd_pcm_substream_t *substream); -int snd_pcm_capture_xrun_asap(snd_pcm_substream_t *substream); -void snd_pcm_playback_silence(snd_pcm_substream_t *substream, snd_pcm_uframes_t new_hw_ptr); -void snd_pcm_tick_prepare(snd_pcm_substream_t *substream); -void snd_pcm_tick_set(snd_pcm_substream_t *substream, unsigned long ticks); -void snd_pcm_tick_elapsed(snd_pcm_substream_t *substream); -void snd_pcm_period_elapsed(snd_pcm_substream_t *substream); -snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, +int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream); +int snd_pcm_playback_xrun_check(struct snd_pcm_substream *substream); +int snd_pcm_capture_xrun_check(struct snd_pcm_substream *substream); +int snd_pcm_playback_xrun_asap(struct snd_pcm_substream *substream); +int snd_pcm_capture_xrun_asap(struct snd_pcm_substream *substream); +void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr); +void snd_pcm_tick_prepare(struct snd_pcm_substream *substream); +void snd_pcm_tick_set(struct snd_pcm_substream *substream, unsigned long ticks); +void snd_pcm_tick_elapsed(struct snd_pcm_substream *substream); +void snd_pcm_period_elapsed(struct snd_pcm_substream *substream); +snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, snd_pcm_uframes_t frames); -snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, +snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream, void __user *buf, snd_pcm_uframes_t frames); -snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, +snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream, void __user **bufs, snd_pcm_uframes_t frames); -snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, +snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream, void __user **bufs, snd_pcm_uframes_t frames); -int snd_pcm_limit_hw_rates(snd_pcm_runtime_t *runtime); +int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime); -static inline void snd_pcm_set_runtime_buffer(snd_pcm_substream_t *substream, +static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream, struct snd_dma_buffer *bufp) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (bufp) { runtime->dma_buffer_p = bufp; runtime->dma_area = bufp->area; @@ -973,47 +950,47 @@ static inline void snd_pcm_set_runtime_buffer(snd_pcm_substream_t *substream, * Timer interface */ -void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream); -void snd_pcm_timer_init(snd_pcm_substream_t * substream); -void snd_pcm_timer_done(snd_pcm_substream_t * substream); +void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream); +void snd_pcm_timer_init(struct snd_pcm_substream *substream); +void snd_pcm_timer_done(struct snd_pcm_substream *substream); /* * Memory */ -int snd_pcm_lib_preallocate_free(snd_pcm_substream_t *substream); -int snd_pcm_lib_preallocate_free_for_all(snd_pcm_t *pcm); -int snd_pcm_lib_preallocate_pages(snd_pcm_substream_t *substream, +int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream); +int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm); +int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, int type, struct device *data, size_t size, size_t max); -int snd_pcm_lib_preallocate_pages_for_all(snd_pcm_t *pcm, +int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, int type, void *data, size_t size, size_t max); -int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size); -int snd_pcm_lib_free_pages(snd_pcm_substream_t *substream); +int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size); +int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream); #define snd_pcm_substream_sgbuf(substream) ((substream)->runtime->dma_buffer_p->private_data) #define snd_pcm_sgbuf_pages(size) snd_sgbuf_aligned_pages(size) #define snd_pcm_sgbuf_get_addr(sgbuf,ofs) snd_sgbuf_get_addr(sgbuf,ofs) -struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset); +struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigned long offset); /* handle mmap counter - PCM mmap callback should handle this counter properly */ static inline void snd_pcm_mmap_data_open(struct vm_area_struct *area) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; + struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; atomic_inc(&substream->runtime->mmap_count); } static inline void snd_pcm_mmap_data_close(struct vm_area_struct *area) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; + struct snd_pcm_substream *substream = (struct snd_pcm_substream *)area->vm_private_data; atomic_dec(&substream->runtime->mmap_count); } /* mmap for io-memory area */ #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA) #define SNDRV_PCM_INFO_MMAP_IOMEM SNDRV_PCM_INFO_MMAP -int snd_pcm_lib_mmap_iomem(snd_pcm_substream_t *substream, struct vm_area_struct *area); +int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, struct vm_area_struct *area); #else #define SNDRV_PCM_INFO_MMAP_IOMEM 0 #define snd_pcm_lib_mmap_iomem NULL diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h index 60b0e92..fb18aef7 100644 --- a/include/sound/pcm_params.h +++ b/include/sound/pcm_params.h @@ -22,17 +22,17 @@ * */ -extern int snd_pcm_hw_param_mask(snd_pcm_substream_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, const snd_mask_t *val); -extern unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params, +extern int snd_pcm_hw_param_mask(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, + snd_pcm_hw_param_t var, const struct snd_mask *val); +extern unsigned int snd_pcm_hw_param_value_min(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir); -extern unsigned int snd_pcm_hw_param_value_max(const snd_pcm_hw_params_t *params, +extern unsigned int snd_pcm_hw_param_value_max(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir); -extern int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, +extern int _snd_pcm_hw_param_min(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int dir); -extern int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params, +extern int _snd_pcm_hw_param_setinteger(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var); -extern int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, +extern int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int dir); /* To share the same code we have alsa-lib */ @@ -71,20 +71,20 @@ INLINE unsigned int ld2(u_int32_t v) INLINE size_t snd_mask_sizeof(void) { - return sizeof(snd_mask_t); + return sizeof(struct snd_mask); } -INLINE void snd_mask_none(snd_mask_t *mask) +INLINE void snd_mask_none(struct snd_mask *mask) { memset(mask, 0, sizeof(*mask)); } -INLINE void snd_mask_any(snd_mask_t *mask) +INLINE void snd_mask_any(struct snd_mask *mask) { memset(mask, 0xff, SNDRV_MASK_SIZE * sizeof(u_int32_t)); } -INLINE int snd_mask_empty(const snd_mask_t *mask) +INLINE int snd_mask_empty(const struct snd_mask *mask) { int i; for (i = 0; i < SNDRV_MASK_SIZE; i++) @@ -93,7 +93,7 @@ INLINE int snd_mask_empty(const snd_mask_t *mask) return 1; } -INLINE unsigned int snd_mask_min(const snd_mask_t *mask) +INLINE unsigned int snd_mask_min(const struct snd_mask *mask) { int i; assert(!snd_mask_empty(mask)); @@ -104,7 +104,7 @@ INLINE unsigned int snd_mask_min(const snd_mask_t *mask) return 0; } -INLINE unsigned int snd_mask_max(const snd_mask_t *mask) +INLINE unsigned int snd_mask_max(const struct snd_mask *mask) { int i; assert(!snd_mask_empty(mask)); @@ -115,19 +115,19 @@ INLINE unsigned int snd_mask_max(const snd_mask_t *mask) return 0; } -INLINE void snd_mask_set(snd_mask_t *mask, unsigned int val) +INLINE void snd_mask_set(struct snd_mask *mask, unsigned int val) { assert(val <= SNDRV_MASK_BITS); mask->bits[MASK_OFS(val)] |= MASK_BIT(val); } -INLINE void snd_mask_reset(snd_mask_t *mask, unsigned int val) +INLINE void snd_mask_reset(struct snd_mask *mask, unsigned int val) { assert(val <= SNDRV_MASK_BITS); mask->bits[MASK_OFS(val)] &= ~MASK_BIT(val); } -INLINE void snd_mask_set_range(snd_mask_t *mask, unsigned int from, unsigned int to) +INLINE void snd_mask_set_range(struct snd_mask *mask, unsigned int from, unsigned int to) { unsigned int i; assert(to <= SNDRV_MASK_BITS && from <= to); @@ -135,7 +135,7 @@ INLINE void snd_mask_set_range(snd_mask_t *mask, unsigned int from, unsigned int mask->bits[MASK_OFS(i)] |= MASK_BIT(i); } -INLINE void snd_mask_reset_range(snd_mask_t *mask, unsigned int from, unsigned int to) +INLINE void snd_mask_reset_range(struct snd_mask *mask, unsigned int from, unsigned int to) { unsigned int i; assert(to <= SNDRV_MASK_BITS && from <= to); @@ -143,7 +143,7 @@ INLINE void snd_mask_reset_range(snd_mask_t *mask, unsigned int from, unsigned i mask->bits[MASK_OFS(i)] &= ~MASK_BIT(i); } -INLINE void snd_mask_leave(snd_mask_t *mask, unsigned int val) +INLINE void snd_mask_leave(struct snd_mask *mask, unsigned int val) { unsigned int v; assert(val <= SNDRV_MASK_BITS); @@ -152,30 +152,30 @@ INLINE void snd_mask_leave(snd_mask_t *mask, unsigned int val) mask->bits[MASK_OFS(val)] = v; } -INLINE void snd_mask_intersect(snd_mask_t *mask, const snd_mask_t *v) +INLINE void snd_mask_intersect(struct snd_mask *mask, const struct snd_mask *v) { int i; for (i = 0; i < SNDRV_MASK_SIZE; i++) mask->bits[i] &= v->bits[i]; } -INLINE int snd_mask_eq(const snd_mask_t *mask, const snd_mask_t *v) +INLINE int snd_mask_eq(const struct snd_mask *mask, const struct snd_mask *v) { return ! memcmp(mask, v, SNDRV_MASK_SIZE * sizeof(u_int32_t)); } -INLINE void snd_mask_copy(snd_mask_t *mask, const snd_mask_t *v) +INLINE void snd_mask_copy(struct snd_mask *mask, const struct snd_mask *v) { *mask = *v; } -INLINE int snd_mask_test(const snd_mask_t *mask, unsigned int val) +INLINE int snd_mask_test(const struct snd_mask *mask, unsigned int val) { assert(val <= SNDRV_MASK_BITS); return mask->bits[MASK_OFS(val)] & MASK_BIT(val); } -INLINE int snd_mask_single(const snd_mask_t *mask) +INLINE int snd_mask_single(const struct snd_mask *mask) { int i, c = 0; assert(!snd_mask_empty(mask)); @@ -191,9 +191,9 @@ INLINE int snd_mask_single(const snd_mask_t *mask) return 1; } -INLINE int snd_mask_refine(snd_mask_t *mask, const snd_mask_t *v) +INLINE int snd_mask_refine(struct snd_mask *mask, const struct snd_mask *v) { - snd_mask_t old; + struct snd_mask old; assert(!snd_mask_empty(mask)); snd_mask_copy(&old, mask); snd_mask_intersect(mask, v); @@ -202,7 +202,7 @@ INLINE int snd_mask_refine(snd_mask_t *mask, const snd_mask_t *v) return !snd_mask_eq(mask, &old); } -INLINE int snd_mask_refine_first(snd_mask_t *mask) +INLINE int snd_mask_refine_first(struct snd_mask *mask) { assert(!snd_mask_empty(mask)); if (snd_mask_single(mask)) @@ -211,7 +211,7 @@ INLINE int snd_mask_refine_first(snd_mask_t *mask) return 1; } -INLINE int snd_mask_refine_last(snd_mask_t *mask) +INLINE int snd_mask_refine_last(struct snd_mask *mask) { assert(!snd_mask_empty(mask)); if (snd_mask_single(mask)) @@ -220,7 +220,7 @@ INLINE int snd_mask_refine_last(snd_mask_t *mask) return 1; } -INLINE int snd_mask_refine_min(snd_mask_t *mask, unsigned int val) +INLINE int snd_mask_refine_min(struct snd_mask *mask, unsigned int val) { assert(!snd_mask_empty(mask)); if (snd_mask_min(mask) >= val) @@ -231,7 +231,7 @@ INLINE int snd_mask_refine_min(snd_mask_t *mask, unsigned int val) return 1; } -INLINE int snd_mask_refine_max(snd_mask_t *mask, unsigned int val) +INLINE int snd_mask_refine_max(struct snd_mask *mask, unsigned int val) { assert(!snd_mask_empty(mask)); if (snd_mask_max(mask) <= val) @@ -242,7 +242,7 @@ INLINE int snd_mask_refine_max(snd_mask_t *mask, unsigned int val) return 1; } -INLINE int snd_mask_refine_set(snd_mask_t *mask, unsigned int val) +INLINE int snd_mask_refine_set(struct snd_mask *mask, unsigned int val) { int changed; assert(!snd_mask_empty(mask)); @@ -253,13 +253,13 @@ INLINE int snd_mask_refine_set(snd_mask_t *mask, unsigned int val) return changed; } -INLINE int snd_mask_value(const snd_mask_t *mask) +INLINE int snd_mask_value(const struct snd_mask *mask) { assert(!snd_mask_empty(mask)); return snd_mask_min(mask); } -INLINE void snd_interval_any(snd_interval_t *i) +INLINE void snd_interval_any(struct snd_interval *i) { i->min = 0; i->openmin = 0; @@ -269,42 +269,42 @@ INLINE void snd_interval_any(snd_interval_t *i) i->empty = 0; } -INLINE void snd_interval_none(snd_interval_t *i) +INLINE void snd_interval_none(struct snd_interval *i) { i->empty = 1; } -INLINE int snd_interval_checkempty(const snd_interval_t *i) +INLINE int snd_interval_checkempty(const struct snd_interval *i) { return (i->min > i->max || (i->min == i->max && (i->openmin || i->openmax))); } -INLINE int snd_interval_empty(const snd_interval_t *i) +INLINE int snd_interval_empty(const struct snd_interval *i) { return i->empty; } -INLINE int snd_interval_single(const snd_interval_t *i) +INLINE int snd_interval_single(const struct snd_interval *i) { assert(!snd_interval_empty(i)); return (i->min == i->max || (i->min + 1 == i->max && i->openmax)); } -INLINE int snd_interval_value(const snd_interval_t *i) +INLINE int snd_interval_value(const struct snd_interval *i) { assert(snd_interval_single(i)); return i->min; } -INLINE int snd_interval_min(const snd_interval_t *i) +INLINE int snd_interval_min(const struct snd_interval *i) { assert(!snd_interval_empty(i)); return i->min; } -INLINE int snd_interval_max(const snd_interval_t *i) +INLINE int snd_interval_max(const struct snd_interval *i) { unsigned int v; assert(!snd_interval_empty(i)); @@ -314,18 +314,18 @@ INLINE int snd_interval_max(const snd_interval_t *i) return v; } -INLINE int snd_interval_test(const snd_interval_t *i, unsigned int val) +INLINE int snd_interval_test(const struct snd_interval *i, unsigned int val) { return !((i->min > val || (i->min == val && i->openmin) || i->max < val || (i->max == val && i->openmax))); } -INLINE void snd_interval_copy(snd_interval_t *d, const snd_interval_t *s) +INLINE void snd_interval_copy(struct snd_interval *d, const struct snd_interval *s) { *d = *s; } -INLINE int snd_interval_setinteger(snd_interval_t *i) +INLINE int snd_interval_setinteger(struct snd_interval *i) { if (i->integer) return 0; @@ -335,7 +335,7 @@ INLINE int snd_interval_setinteger(snd_interval_t *i) return 1; } -INLINE int snd_interval_eq(const snd_interval_t *i1, const snd_interval_t *i2) +INLINE int snd_interval_eq(const struct snd_interval *i1, const struct snd_interval *i2) { if (i1->empty) return i2->empty; diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 184e74b..59c995b 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -33,18 +33,18 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Abramo Bagnara <abramo@alsa-proj MODULE_DESCRIPTION("Midlevel PCM code for ALSA."); MODULE_LICENSE("GPL"); -snd_pcm_t *snd_pcm_devices[SNDRV_CARDS * SNDRV_PCM_DEVICES]; +struct snd_pcm *snd_pcm_devices[SNDRV_CARDS * SNDRV_PCM_DEVICES]; static LIST_HEAD(snd_pcm_notify_list); static DECLARE_MUTEX(register_mutex); -static int snd_pcm_free(snd_pcm_t *pcm); -static int snd_pcm_dev_free(snd_device_t *device); -static int snd_pcm_dev_register(snd_device_t *device); -static int snd_pcm_dev_disconnect(snd_device_t *device); -static int snd_pcm_dev_unregister(snd_device_t *device); +static int snd_pcm_free(struct snd_pcm *pcm); +static int snd_pcm_dev_free(struct snd_device *device); +static int snd_pcm_dev_register(struct snd_device *device); +static int snd_pcm_dev_disconnect(struct snd_device *device); +static int snd_pcm_dev_unregister(struct snd_device *device); -static int snd_pcm_control_ioctl(snd_card_t * card, - snd_ctl_file_t * control, +static int snd_pcm_control_ioctl(struct snd_card *card, + struct snd_ctl_file *control, unsigned int cmd, unsigned long arg) { unsigned int tmp; @@ -71,13 +71,13 @@ static int snd_pcm_control_ioctl(snd_card_t * card, } case SNDRV_CTL_IOCTL_PCM_INFO: { - snd_pcm_info_t __user *info; + struct snd_pcm_info __user *info; unsigned int device, subdevice; - snd_pcm_stream_t stream; - snd_pcm_t *pcm; - snd_pcm_str_t *pstr; - snd_pcm_substream_t *substream; - info = (snd_pcm_info_t __user *)arg; + int stream; + struct snd_pcm *pcm; + struct snd_pcm_str *pstr; + struct snd_pcm_substream *substream; + info = (struct snd_pcm_info __user *)arg; if (get_user(device, &info->device)) return -EFAULT; if (device >= SNDRV_PCM_DEVICES) @@ -200,7 +200,7 @@ static char *snd_pcm_tstamp_mode_names[] = { TSTAMP(MMAP), }; -static const char *snd_pcm_stream_name(snd_pcm_stream_t stream) +static const char *snd_pcm_stream_name(int stream) { snd_assert(stream <= SNDRV_PCM_STREAM_LAST, return NULL); return snd_pcm_stream_names[stream]; @@ -208,23 +208,20 @@ static const char *snd_pcm_stream_name(snd_pcm_stream_t stream) static const char *snd_pcm_access_name(snd_pcm_access_t access) { - snd_assert(access <= SNDRV_PCM_ACCESS_LAST, return NULL); return snd_pcm_access_names[access]; } const char *snd_pcm_format_name(snd_pcm_format_t format) { - snd_assert(format <= SNDRV_PCM_FORMAT_LAST, return NULL); return snd_pcm_format_names[format]; } static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat) { - snd_assert(subformat <= SNDRV_PCM_SUBFORMAT_LAST, return NULL); return snd_pcm_subformat_names[subformat]; } -static const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode) +static const char *snd_pcm_tstamp_mode_name(int mode) { snd_assert(mode <= SNDRV_PCM_TSTAMP_LAST, return NULL); return snd_pcm_tstamp_mode_names[mode]; @@ -232,7 +229,6 @@ static const char *snd_pcm_tstamp_mode_name(snd_pcm_tstamp_t mode) static const char *snd_pcm_state_name(snd_pcm_state_t state) { - snd_assert(state <= SNDRV_PCM_STATE_LAST, return NULL); return snd_pcm_state_names[state]; } @@ -268,9 +264,10 @@ static const char *snd_pcm_oss_format_name(int format) #endif #ifdef CONFIG_PROC_FS -static void snd_pcm_proc_info_read(snd_pcm_substream_t *substream, snd_info_buffer_t *buffer) +static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, + struct snd_info_buffer *buffer) { - snd_pcm_info_t *info; + struct snd_pcm_info *info; int err; if (! substream) @@ -302,20 +299,25 @@ static void snd_pcm_proc_info_read(snd_pcm_substream_t *substream, snd_info_buff kfree(info); } -static void snd_pcm_stream_proc_info_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_pcm_stream_proc_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_proc_info_read(((snd_pcm_str_t *)entry->private_data)->substream, buffer); + snd_pcm_proc_info_read(((struct snd_pcm_str *)entry->private_data)->substream, + buffer); } -static void snd_pcm_substream_proc_info_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_pcm_substream_proc_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_proc_info_read((snd_pcm_substream_t *)entry->private_data, buffer); + snd_pcm_proc_info_read((struct snd_pcm_substream *)entry->private_data, + buffer); } -static void snd_pcm_substream_proc_hw_params_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_pcm_substream_proc_hw_params_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)entry->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_substream *substream = entry->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; if (!runtime) { snd_iprintf(buffer, "closed\n"); return; @@ -347,10 +349,11 @@ static void snd_pcm_substream_proc_hw_params_read(snd_info_entry_t *entry, snd_i snd_pcm_stream_unlock_irq(substream); } -static void snd_pcm_substream_proc_sw_params_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_pcm_substream_proc_sw_params_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)entry->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_substream *substream = entry->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; if (!runtime) { snd_iprintf(buffer, "closed\n"); return; @@ -374,11 +377,12 @@ static void snd_pcm_substream_proc_sw_params_read(snd_info_entry_t *entry, snd_i snd_pcm_stream_unlock_irq(substream); } -static void snd_pcm_substream_proc_status_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)entry->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; - snd_pcm_status_t status; + struct snd_pcm_substream *substream = entry->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_pcm_status status; int err; if (!runtime) { snd_iprintf(buffer, "closed\n"); @@ -405,25 +409,27 @@ static void snd_pcm_substream_proc_status_read(snd_info_entry_t *entry, snd_info #endif #ifdef CONFIG_SND_DEBUG -static void snd_pcm_xrun_debug_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_str_t *pstr = (snd_pcm_str_t *)entry->private_data; + struct snd_pcm_str *pstr = entry->private_data; snd_iprintf(buffer, "%d\n", pstr->xrun_debug); } -static void snd_pcm_xrun_debug_write(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_pcm_xrun_debug_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_str_t *pstr = (snd_pcm_str_t *)entry->private_data; + struct snd_pcm_str *pstr = entry->private_data; char line[64]; if (!snd_info_get_line(buffer, line, sizeof(line))) pstr->xrun_debug = simple_strtoul(line, NULL, 10); } #endif -static int snd_pcm_stream_proc_init(snd_pcm_str_t *pstr) +static int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { - snd_pcm_t *pcm = pstr->pcm; - snd_info_entry_t *entry; + struct snd_pcm *pcm = pstr->pcm; + struct snd_info_entry *entry; char name[16]; sprintf(name, "pcm%i%c", pcm->device, @@ -447,7 +453,8 @@ static int snd_pcm_stream_proc_init(snd_pcm_str_t *pstr) pstr->proc_info_entry = entry; #ifdef CONFIG_SND_DEBUG - if ((entry = snd_info_create_card_entry(pcm->card, "xrun_debug", pstr->proc_root)) != NULL) { + if ((entry = snd_info_create_card_entry(pcm->card, "xrun_debug", + pstr->proc_root)) != NULL) { entry->c.text.read_size = 64; entry->c.text.read = snd_pcm_xrun_debug_read; entry->c.text.write_size = 64; @@ -464,7 +471,7 @@ static int snd_pcm_stream_proc_init(snd_pcm_str_t *pstr) return 0; } -static int snd_pcm_stream_proc_done(snd_pcm_str_t *pstr) +static int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { #ifdef CONFIG_SND_DEBUG if (pstr->proc_xrun_debug_entry) { @@ -483,10 +490,10 @@ static int snd_pcm_stream_proc_done(snd_pcm_str_t *pstr) return 0; } -static int snd_pcm_substream_proc_init(snd_pcm_substream_t *substream) +static int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { - snd_info_entry_t *entry; - snd_card_t *card; + struct snd_info_entry *entry; + struct snd_card *card; char name[16]; card = substream->pcm->card; @@ -540,7 +547,7 @@ static int snd_pcm_substream_proc_init(snd_pcm_substream_t *substream) return 0; } -static int snd_pcm_substream_proc_done(snd_pcm_substream_t *substream) +static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { if (substream->proc_info_entry) { snd_info_unregister(substream->proc_info_entry); @@ -578,11 +585,11 @@ static int snd_pcm_substream_proc_done(snd_pcm_substream_t *substream) * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count) +int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) { int idx, err; - snd_pcm_str_t *pstr = &pcm->streams[stream]; - snd_pcm_substream_t *substream, *prev; + struct snd_pcm_str *pstr = &pcm->streams[stream]; + struct snd_pcm_substream *substream, *prev; #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) init_MUTEX(&pstr->oss.setup_mutex); @@ -642,13 +649,13 @@ int snd_pcm_new_stream(snd_pcm_t *pcm, int stream, int substream_count) * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_new(snd_card_t * card, char *id, int device, +int snd_pcm_new(struct snd_card *card, char *id, int device, int playback_count, int capture_count, - snd_pcm_t ** rpcm) + struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_pcm_dev_free, .dev_register = snd_pcm_dev_register, .dev_disconnect = snd_pcm_dev_disconnect, @@ -684,11 +691,11 @@ int snd_pcm_new(snd_card_t * card, char *id, int device, return 0; } -static void snd_pcm_free_stream(snd_pcm_str_t * pstr) +static void snd_pcm_free_stream(struct snd_pcm_str * pstr) { - snd_pcm_substream_t *substream, *substream_next; + struct snd_pcm_substream *substream, *substream_next; #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) - snd_pcm_oss_setup_t *setup, *setupn; + struct snd_pcm_oss_setup *setup, *setupn; #endif substream = pstr->substream; while (substream) { @@ -707,7 +714,7 @@ static void snd_pcm_free_stream(snd_pcm_str_t * pstr) #endif } -static int snd_pcm_free(snd_pcm_t *pcm) +static int snd_pcm_free(struct snd_pcm *pcm) { snd_assert(pcm != NULL, return -ENXIO); if (pcm->private_free) @@ -719,26 +726,26 @@ static int snd_pcm_free(snd_pcm_t *pcm) return 0; } -static int snd_pcm_dev_free(snd_device_t *device) +static int snd_pcm_dev_free(struct snd_device *device) { - snd_pcm_t *pcm = device->device_data; + struct snd_pcm *pcm = device->device_data; return snd_pcm_free(pcm); } static void snd_pcm_tick_timer_func(unsigned long data) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t*) data; + struct snd_pcm_substream *substream = (struct snd_pcm_substream *) data; snd_pcm_tick_elapsed(substream); } -int snd_pcm_open_substream(snd_pcm_t *pcm, int stream, - snd_pcm_substream_t **rsubstream) +int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, + struct snd_pcm_substream **rsubstream) { - snd_pcm_str_t * pstr; - snd_pcm_substream_t * substream; - snd_pcm_runtime_t * runtime; - snd_ctl_file_t *kctl; - snd_card_t *card; + struct snd_pcm_str * pstr; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; + struct snd_ctl_file *kctl; + struct snd_card *card; struct list_head *list; int prefer_subdevice = -1; size_t size; @@ -800,7 +807,7 @@ int snd_pcm_open_substream(snd_pcm_t *pcm, int stream, if (runtime == NULL) return -ENOMEM; - size = PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t)); + size = PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status)); runtime->status = snd_malloc_pages(size, GFP_KERNEL); if (runtime->status == NULL) { kfree(runtime); @@ -808,10 +815,11 @@ int snd_pcm_open_substream(snd_pcm_t *pcm, int stream, } memset((void*)runtime->status, 0, size); - size = PAGE_ALIGN(sizeof(snd_pcm_mmap_control_t)); + size = PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control)); runtime->control = snd_malloc_pages(size, GFP_KERNEL); if (runtime->control == NULL) { - snd_free_pages((void*)runtime->status, PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t))); + snd_free_pages((void*)runtime->status, + PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))); kfree(runtime); return -ENOMEM; } @@ -832,30 +840,32 @@ int snd_pcm_open_substream(snd_pcm_t *pcm, int stream, return 0; } -void snd_pcm_release_substream(snd_pcm_substream_t *substream) +void snd_pcm_release_substream(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t * runtime; + struct snd_pcm_runtime *runtime; substream->file = NULL; runtime = substream->runtime; snd_assert(runtime != NULL, return); if (runtime->private_free != NULL) runtime->private_free(runtime); - snd_free_pages((void*)runtime->status, PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t))); - snd_free_pages((void*)runtime->control, PAGE_ALIGN(sizeof(snd_pcm_mmap_control_t))); + snd_free_pages((void*)runtime->status, + PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))); + snd_free_pages((void*)runtime->control, + PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))); kfree(runtime->hw_constraints.rules); kfree(runtime); substream->runtime = NULL; substream->pstr->substream_opened--; } -static int snd_pcm_dev_register(snd_device_t *device) +static int snd_pcm_dev_register(struct snd_device *device) { int idx, cidx, err; unsigned short minor; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; struct list_head *list; char str[16]; - snd_pcm_t *pcm = device->device_data; + struct snd_pcm *pcm = device->device_data; snd_assert(pcm != NULL && device != NULL, return -ENXIO); down(®ister_mutex); @@ -890,19 +900,19 @@ static int snd_pcm_dev_register(snd_device_t *device) snd_pcm_timer_init(substream); } list_for_each(list, &snd_pcm_notify_list) { - snd_pcm_notify_t *notify; - notify = list_entry(list, snd_pcm_notify_t, list); + struct snd_pcm_notify *notify; + notify = list_entry(list, struct snd_pcm_notify, list); notify->n_register(pcm); } up(®ister_mutex); return 0; } -static int snd_pcm_dev_disconnect(snd_device_t *device) +static int snd_pcm_dev_disconnect(struct snd_device *device) { - snd_pcm_t *pcm = device->device_data; + struct snd_pcm *pcm = device->device_data; struct list_head *list; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int idx, cidx; down(®ister_mutex); @@ -913,20 +923,20 @@ static int snd_pcm_dev_disconnect(snd_device_t *device) if (substream->runtime) substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED; list_for_each(list, &snd_pcm_notify_list) { - snd_pcm_notify_t *notify; - notify = list_entry(list, snd_pcm_notify_t, list); + struct snd_pcm_notify *notify; + notify = list_entry(list, struct snd_pcm_notify, list); notify->n_disconnect(pcm); } up(®ister_mutex); return 0; } -static int snd_pcm_dev_unregister(snd_device_t *device) +static int snd_pcm_dev_unregister(struct snd_device *device) { int idx, cidx, devtype; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; struct list_head *list; - snd_pcm_t *pcm = device->device_data; + struct snd_pcm *pcm = device->device_data; snd_assert(pcm != NULL, return -ENXIO); down(®ister_mutex); @@ -947,15 +957,15 @@ static int snd_pcm_dev_unregister(snd_device_t *device) snd_pcm_timer_done(substream); } list_for_each(list, &snd_pcm_notify_list) { - snd_pcm_notify_t *notify; - notify = list_entry(list, snd_pcm_notify_t, list); + struct snd_pcm_notify *notify; + notify = list_entry(list, struct snd_pcm_notify, list); notify->n_unregister(pcm); } up(®ister_mutex); return snd_pcm_free(pcm); } -int snd_pcm_notify(snd_pcm_notify_t *notify, int nfree) +int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) { int idx; @@ -984,10 +994,11 @@ int snd_pcm_notify(snd_pcm_notify_t *notify, int nfree) * Info interface */ -static void snd_pcm_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_pcm_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int idx; - snd_pcm_t *pcm; + struct snd_pcm *pcm; down(®ister_mutex); for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) { @@ -997,9 +1008,11 @@ static void snd_pcm_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffe snd_iprintf(buffer, "%02i-%02i: %s : %s", idx / SNDRV_PCM_DEVICES, idx % SNDRV_PCM_DEVICES, pcm->id, pcm->name); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) - snd_iprintf(buffer, " : playback %i", pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count); + snd_iprintf(buffer, " : playback %i", + pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count); if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) - snd_iprintf(buffer, " : capture %i", pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count); + snd_iprintf(buffer, " : capture %i", + pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream_count); snd_iprintf(buffer, "\n"); } up(®ister_mutex); @@ -1009,16 +1022,17 @@ static void snd_pcm_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffe * ENTRY functions */ -static snd_info_entry_t *snd_pcm_proc_entry = NULL; +static struct snd_info_entry *snd_pcm_proc_entry = NULL; static int __init alsa_pcm_init(void) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; snd_ctl_register_ioctl(snd_pcm_control_ioctl); snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl); if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) { - snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128, snd_pcm_proc_read); + snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128, + snd_pcm_proc_read); if (snd_info_register(entry) < 0) { snd_info_free_entry(entry); entry = NULL; diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 4b6307d..e513303 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -22,7 +22,7 @@ #include <linux/compat.h> -static int snd_pcm_ioctl_delay_compat(snd_pcm_substream_t *substream, +static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream, s32 __user *src) { snd_pcm_sframes_t delay; @@ -39,7 +39,7 @@ static int snd_pcm_ioctl_delay_compat(snd_pcm_substream_t *substream, return err; } -static int snd_pcm_ioctl_rewind_compat(snd_pcm_substream_t *substream, +static int snd_pcm_ioctl_rewind_compat(struct snd_pcm_substream *substream, u32 __user *src) { snd_pcm_uframes_t frames; @@ -56,7 +56,7 @@ static int snd_pcm_ioctl_rewind_compat(snd_pcm_substream_t *substream, return err < 0 ? err : 0; } -static int snd_pcm_ioctl_forward_compat(snd_pcm_substream_t *substream, +static int snd_pcm_ioctl_forward_compat(struct snd_pcm_substream *substream, u32 __user *src) { snd_pcm_uframes_t frames; @@ -73,12 +73,12 @@ static int snd_pcm_ioctl_forward_compat(snd_pcm_substream_t *substream, return err < 0 ? err : 0; } -struct sndrv_pcm_hw_params32 { +struct snd_pcm_hw_params32 { u32 flags; - struct sndrv_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; /* this must be identical */ - struct sndrv_mask mres[5]; /* reserved masks */ - struct sndrv_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; - struct sndrv_interval ires[9]; /* reserved intervals */ + struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; /* this must be identical */ + struct snd_mask mres[5]; /* reserved masks */ + struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1]; + struct snd_interval ires[9]; /* reserved intervals */ u32 rmask; u32 cmask; u32 info; @@ -89,7 +89,7 @@ struct sndrv_pcm_hw_params32 { unsigned char reserved[64]; }; -struct sndrv_pcm_sw_params32 { +struct snd_pcm_sw_params32 { s32 tstamp_mode; u32 period_step; u32 sleep_min; @@ -104,7 +104,7 @@ struct sndrv_pcm_sw_params32 { }; /* recalcuate the boundary within 32bit */ -static snd_pcm_uframes_t recalculate_boundary(snd_pcm_runtime_t *runtime) +static snd_pcm_uframes_t recalculate_boundary(struct snd_pcm_runtime *runtime) { snd_pcm_uframes_t boundary; @@ -116,10 +116,10 @@ static snd_pcm_uframes_t recalculate_boundary(snd_pcm_runtime_t *runtime) return boundary; } -static int snd_pcm_ioctl_sw_params_compat(snd_pcm_substream_t *substream, - struct sndrv_pcm_sw_params32 __user *src) +static int snd_pcm_ioctl_sw_params_compat(struct snd_pcm_substream *substream, + struct snd_pcm_sw_params32 __user *src) { - snd_pcm_sw_params_t params; + struct snd_pcm_sw_params params; snd_pcm_uframes_t boundary; int err; @@ -149,17 +149,17 @@ static int snd_pcm_ioctl_sw_params_compat(snd_pcm_substream_t *substream, return err; } -struct sndrv_pcm_channel_info32 { +struct snd_pcm_channel_info32 { u32 channel; u32 offset; u32 first; u32 step; }; -static int snd_pcm_ioctl_channel_info_compat(snd_pcm_substream_t *substream, - struct sndrv_pcm_channel_info32 __user *src) +static int snd_pcm_ioctl_channel_info_compat(struct snd_pcm_substream *substream, + struct snd_pcm_channel_info32 __user *src) { - snd_pcm_channel_info_t info; + struct snd_pcm_channel_info info; int err; if (get_user(info.channel, &src->channel) || @@ -178,7 +178,7 @@ static int snd_pcm_ioctl_channel_info_compat(snd_pcm_substream_t *substream, return err; } -struct sndrv_pcm_status32 { +struct snd_pcm_status32 { s32 state; struct compat_timespec trigger_tstamp; struct compat_timespec tstamp; @@ -193,10 +193,10 @@ struct sndrv_pcm_status32 { } __attribute__((packed)); -static int snd_pcm_status_user_compat(snd_pcm_substream_t *substream, - struct sndrv_pcm_status32 __user *src) +static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream, + struct snd_pcm_status32 __user *src) { - snd_pcm_status_t status; + struct snd_pcm_status status; int err; err = snd_pcm_status(substream, &status); @@ -221,12 +221,12 @@ static int snd_pcm_status_user_compat(snd_pcm_substream_t *substream, } /* both for HW_PARAMS and HW_REFINE */ -static int snd_pcm_ioctl_hw_params_compat(snd_pcm_substream_t *substream, +static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream, int refine, - struct sndrv_pcm_hw_params32 __user *data32) + struct snd_pcm_hw_params32 __user *data32) { - struct sndrv_pcm_hw_params *data; - snd_pcm_runtime_t *runtime; + struct snd_pcm_hw_params *data; + struct snd_pcm_runtime *runtime; int err; if (! (runtime = substream->runtime)) @@ -265,14 +265,14 @@ static int snd_pcm_ioctl_hw_params_compat(snd_pcm_substream_t *substream, /* */ -struct sndrv_xferi32 { +struct snd_xferi32 { s32 result; u32 buf; u32 frames; }; -static int snd_pcm_ioctl_xferi_compat(snd_pcm_substream_t *substream, - int dir, struct sndrv_xferi32 __user *data32) +static int snd_pcm_ioctl_xferi_compat(struct snd_pcm_substream *substream, + int dir, struct snd_xferi32 __user *data32) { compat_caddr_t buf; u32 frames; @@ -303,7 +303,7 @@ static int snd_pcm_ioctl_xferi_compat(snd_pcm_substream_t *substream, /* snd_xfern needs remapping of bufs */ -struct sndrv_xfern32 { +struct snd_xfern32 { s32 result; u32 bufs; /* this is void **; */ u32 frames; @@ -315,8 +315,8 @@ struct sndrv_xfern32 { * handler there expands again the same 128 pointers on stack, so it is better * to handle the function (calling pcm_readv/writev) directly in this handler. */ -static int snd_pcm_ioctl_xfern_compat(snd_pcm_substream_t *substream, - int dir, struct sndrv_xfern32 __user *data32) +static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream, + int dir, struct snd_xfern32 __user *data32) { compat_caddr_t buf; compat_caddr_t __user *bufptr; @@ -360,7 +360,7 @@ static int snd_pcm_ioctl_xfern_compat(snd_pcm_substream_t *substream, } -struct sndrv_pcm_mmap_status32 { +struct snd_pcm_mmap_status32 { s32 state; s32 pad1; u32 hw_ptr; @@ -368,32 +368,32 @@ struct sndrv_pcm_mmap_status32 { s32 suspended_state; } __attribute__((packed)); -struct sndrv_pcm_mmap_control32 { +struct snd_pcm_mmap_control32 { u32 appl_ptr; u32 avail_min; }; -struct sndrv_pcm_sync_ptr32 { +struct snd_pcm_sync_ptr32 { u32 flags; union { - struct sndrv_pcm_mmap_status32 status; + struct snd_pcm_mmap_status32 status; unsigned char reserved[64]; } s; union { - struct sndrv_pcm_mmap_control32 control; + struct snd_pcm_mmap_control32 control; unsigned char reserved[64]; } c; } __attribute__((packed)); -static int snd_pcm_ioctl_sync_ptr_compat(snd_pcm_substream_t *substream, - struct sndrv_pcm_sync_ptr32 __user *src) +static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, + struct snd_pcm_sync_ptr32 __user *src) { - snd_pcm_runtime_t *runtime = substream->runtime; - volatile struct sndrv_pcm_mmap_status *status; - volatile struct sndrv_pcm_mmap_control *control; + struct snd_pcm_runtime *runtime = substream->runtime; + volatile struct snd_pcm_mmap_status *status; + volatile struct snd_pcm_mmap_control *control; u32 sflags; - struct sndrv_pcm_mmap_control scontrol; - struct sndrv_pcm_mmap_status sstatus; + struct snd_pcm_mmap_control scontrol; + struct snd_pcm_mmap_status sstatus; snd_pcm_uframes_t boundary; int err; @@ -444,26 +444,26 @@ static int snd_pcm_ioctl_sync_ptr_compat(snd_pcm_substream_t *substream, /* */ enum { - SNDRV_PCM_IOCTL_HW_REFINE32 = _IOWR('A', 0x10, struct sndrv_pcm_hw_params32), - SNDRV_PCM_IOCTL_HW_PARAMS32 = _IOWR('A', 0x11, struct sndrv_pcm_hw_params32), - SNDRV_PCM_IOCTL_SW_PARAMS32 = _IOWR('A', 0x13, struct sndrv_pcm_sw_params32), - SNDRV_PCM_IOCTL_STATUS32 = _IOR('A', 0x20, struct sndrv_pcm_status32), + SNDRV_PCM_IOCTL_HW_REFINE32 = _IOWR('A', 0x10, struct snd_pcm_hw_params32), + SNDRV_PCM_IOCTL_HW_PARAMS32 = _IOWR('A', 0x11, struct snd_pcm_hw_params32), + SNDRV_PCM_IOCTL_SW_PARAMS32 = _IOWR('A', 0x13, struct snd_pcm_sw_params32), + SNDRV_PCM_IOCTL_STATUS32 = _IOR('A', 0x20, struct snd_pcm_status32), SNDRV_PCM_IOCTL_DELAY32 = _IOR('A', 0x21, s32), - SNDRV_PCM_IOCTL_CHANNEL_INFO32 = _IOR('A', 0x32, struct sndrv_pcm_channel_info32), + SNDRV_PCM_IOCTL_CHANNEL_INFO32 = _IOR('A', 0x32, struct snd_pcm_channel_info32), SNDRV_PCM_IOCTL_REWIND32 = _IOW('A', 0x46, u32), SNDRV_PCM_IOCTL_FORWARD32 = _IOW('A', 0x49, u32), - SNDRV_PCM_IOCTL_WRITEI_FRAMES32 = _IOW('A', 0x50, struct sndrv_xferi32), - SNDRV_PCM_IOCTL_READI_FRAMES32 = _IOR('A', 0x51, struct sndrv_xferi32), - SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct sndrv_xfern32), - SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct sndrv_xfern32), - SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct sndrv_pcm_sync_ptr32), + SNDRV_PCM_IOCTL_WRITEI_FRAMES32 = _IOW('A', 0x50, struct snd_xferi32), + SNDRV_PCM_IOCTL_READI_FRAMES32 = _IOR('A', 0x51, struct snd_xferi32), + SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct snd_xfern32), + SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct snd_xfern32), + SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32), }; static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) { - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream; void __user *argp = compat_ptr(arg); pcm_file = file->private_data; diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 3dbf9bf..c58ec67 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -39,9 +39,9 @@ * * when runtime->silence_size >= runtime->boundary - fill processed area with silence immediately */ -void snd_pcm_playback_silence(snd_pcm_substream_t *substream, snd_pcm_uframes_t new_hw_ptr) +void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t frames, ofs, transfer; if (runtime->silence_size < runtime->boundary) { @@ -128,7 +128,7 @@ void snd_pcm_playback_silence(snd_pcm_substream_t *substream, snd_pcm_uframes_t } } -static void xrun(snd_pcm_substream_t *substream) +static void xrun(struct snd_pcm_substream *substream) { snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); #ifdef CONFIG_SND_DEBUG @@ -143,8 +143,8 @@ static void xrun(snd_pcm_substream_t *substream) #endif } -static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(snd_pcm_substream_t *substream, - snd_pcm_runtime_t *runtime) +static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(struct snd_pcm_substream *substream, + struct snd_pcm_runtime *runtime) { snd_pcm_uframes_t pos; @@ -162,8 +162,8 @@ static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(snd_pcm_substream_t *s return pos; } -static inline int snd_pcm_update_hw_ptr_post(snd_pcm_substream_t *substream, - snd_pcm_runtime_t *runtime) +static inline int snd_pcm_update_hw_ptr_post(struct snd_pcm_substream *substream, + struct snd_pcm_runtime *runtime) { snd_pcm_uframes_t avail; @@ -185,9 +185,9 @@ static inline int snd_pcm_update_hw_ptr_post(snd_pcm_substream_t *substream, return 0; } -static inline int snd_pcm_update_hw_ptr_interrupt(snd_pcm_substream_t *substream) +static inline int snd_pcm_update_hw_ptr_interrupt(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t pos; snd_pcm_uframes_t new_hw_ptr, hw_ptr_interrupt; snd_pcm_sframes_t delta; @@ -232,9 +232,9 @@ static inline int snd_pcm_update_hw_ptr_interrupt(snd_pcm_substream_t *substream } /* CAUTION: call it with irq disabled */ -int snd_pcm_update_hw_ptr(snd_pcm_substream_t *substream) +int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t pos; snd_pcm_uframes_t old_hw_ptr, new_hw_ptr; snd_pcm_sframes_t delta; @@ -281,10 +281,10 @@ int snd_pcm_update_hw_ptr(snd_pcm_substream_t *substream) * * Sets the given PCM operators to the pcm instance. */ -void snd_pcm_set_ops(snd_pcm_t *pcm, int direction, snd_pcm_ops_t *ops) +void snd_pcm_set_ops(struct snd_pcm *pcm, int direction, struct snd_pcm_ops *ops) { - snd_pcm_str_t *stream = &pcm->streams[direction]; - snd_pcm_substream_t *substream; + struct snd_pcm_str *stream = &pcm->streams[direction]; + struct snd_pcm_substream *substream; for (substream = stream->substream; substream != NULL; substream = substream->next) substream->ops = ops; @@ -297,9 +297,9 @@ void snd_pcm_set_ops(snd_pcm_t *pcm, int direction, snd_pcm_ops_t *ops) * * Sets the PCM sync identifier for the card. */ -void snd_pcm_set_sync(snd_pcm_substream_t * substream) +void snd_pcm_set_sync(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; runtime->sync.id32[0] = substream->pcm->card->number; runtime->sync.id32[1] = -1; @@ -370,7 +370,7 @@ static inline unsigned int muldiv32(unsigned int a, unsigned int b, return n; } -static int snd_interval_refine_min(snd_interval_t *i, unsigned int min, int openmin) +static int snd_interval_refine_min(struct snd_interval *i, unsigned int min, int openmin) { int changed = 0; assert(!snd_interval_empty(i)); @@ -395,7 +395,7 @@ static int snd_interval_refine_min(snd_interval_t *i, unsigned int min, int open return changed; } -static int snd_interval_refine_max(snd_interval_t *i, unsigned int max, int openmax) +static int snd_interval_refine_max(struct snd_interval *i, unsigned int max, int openmax) { int changed = 0; assert(!snd_interval_empty(i)); @@ -431,7 +431,7 @@ static int snd_interval_refine_max(snd_interval_t *i, unsigned int max, int open * * Returns non-zero if the value is changed, zero if not changed. */ -int snd_interval_refine(snd_interval_t *i, const snd_interval_t *v) +int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v) { int changed = 0; assert(!snd_interval_empty(i)); @@ -473,7 +473,7 @@ int snd_interval_refine(snd_interval_t *i, const snd_interval_t *v) return changed; } -static int snd_interval_refine_first(snd_interval_t *i) +static int snd_interval_refine_first(struct snd_interval *i) { assert(!snd_interval_empty(i)); if (snd_interval_single(i)) @@ -485,7 +485,7 @@ static int snd_interval_refine_first(snd_interval_t *i) return 1; } -static int snd_interval_refine_last(snd_interval_t *i) +static int snd_interval_refine_last(struct snd_interval *i) { assert(!snd_interval_empty(i)); if (snd_interval_single(i)) @@ -497,9 +497,9 @@ static int snd_interval_refine_last(snd_interval_t *i) return 1; } -static int snd_interval_refine_set(snd_interval_t *i, unsigned int val) +static int snd_interval_refine_set(struct snd_interval *i, unsigned int val) { - snd_interval_t t; + struct snd_interval t; t.empty = 0; t.min = t.max = val; t.openmin = t.openmax = 0; @@ -507,7 +507,7 @@ static int snd_interval_refine_set(snd_interval_t *i, unsigned int val) return snd_interval_refine(i, &t); } -void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c) +void snd_interval_mul(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c) { if (a->empty || b->empty) { snd_interval_none(c); @@ -531,7 +531,7 @@ void snd_interval_mul(const snd_interval_t *a, const snd_interval_t *b, snd_inte * * Returns non-zero if the value is changed, zero if not changed. */ -void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_interval_t *c) +void snd_interval_div(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c) { unsigned int r; if (a->empty || b->empty) { @@ -566,8 +566,8 @@ void snd_interval_div(const snd_interval_t *a, const snd_interval_t *b, snd_inte * * Returns non-zero if the value is changed, zero if not changed. */ -void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b, - unsigned int k, snd_interval_t *c) +void snd_interval_muldivk(const struct snd_interval *a, const struct snd_interval *b, + unsigned int k, struct snd_interval *c) { unsigned int r; if (a->empty || b->empty) { @@ -597,8 +597,8 @@ void snd_interval_muldivk(const snd_interval_t *a, const snd_interval_t *b, * * Returns non-zero if the value is changed, zero if not changed. */ -void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k, - const snd_interval_t *b, snd_interval_t *c) +void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k, + const struct snd_interval *b, struct snd_interval *c) { unsigned int r; if (a->empty || b->empty) { @@ -636,13 +636,13 @@ void snd_interval_mulkdiv(const snd_interval_t *a, unsigned int k, * * Returns non-zero if the value is changed, zero if not changed. */ -int snd_interval_ratnum(snd_interval_t *i, - unsigned int rats_count, ratnum_t *rats, - unsigned int *nump, unsigned int *denp) +int snd_interval_ratnum(struct snd_interval *i, + unsigned int rats_count, struct snd_ratnum *rats, + unsigned int *nump, unsigned int *denp) { unsigned int best_num, best_diff, best_den; unsigned int k; - snd_interval_t t; + struct snd_interval t; int err; best_num = best_den = best_diff = 0; @@ -731,20 +731,20 @@ int snd_interval_ratnum(snd_interval_t *i, /** * snd_interval_ratden - refine the interval value * @i: interval to refine - * @rats_count: number of ratden_t - * @rats: ratden_t array + * @rats_count: number of struct ratden + * @rats: struct ratden array * @nump: pointer to store the resultant numerator * @denp: pointer to store the resultant denominator * * Returns non-zero if the value is changed, zero if not changed. */ -static int snd_interval_ratden(snd_interval_t *i, - unsigned int rats_count, ratden_t *rats, +static int snd_interval_ratden(struct snd_interval *i, + unsigned int rats_count, struct snd_ratden *rats, unsigned int *nump, unsigned int *denp) { unsigned int best_num, best_diff, best_den; unsigned int k; - snd_interval_t t; + struct snd_interval t; int err; best_num = best_den = best_diff = 0; @@ -837,7 +837,7 @@ static int snd_interval_ratden(snd_interval_t *i, * * Returns non-zero if the value is changed, zero if not changed. */ -int snd_interval_list(snd_interval_t *i, unsigned int count, unsigned int *list, unsigned int mask) +int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *list, unsigned int mask) { unsigned int k; int changed = 0; @@ -878,7 +878,7 @@ int snd_interval_list(snd_interval_t *i, unsigned int count, unsigned int *list, return changed; } -static int snd_interval_step(snd_interval_t *i, unsigned int min, unsigned int step) +static int snd_interval_step(struct snd_interval *i, unsigned int min, unsigned int step) { unsigned int n; int changed = 0; @@ -912,18 +912,18 @@ static int snd_interval_step(snd_interval_t *i, unsigned int min, unsigned int s * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_hw_rule_add(snd_pcm_runtime_t *runtime, unsigned int cond, +int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, int var, snd_pcm_hw_rule_func_t func, void *private, int dep, ...) { - snd_pcm_hw_constraints_t *constrs = &runtime->hw_constraints; - snd_pcm_hw_rule_t *c; + struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; + struct snd_pcm_hw_rule *c; unsigned int k; va_list args; va_start(args, dep); if (constrs->rules_num >= constrs->rules_all) { - snd_pcm_hw_rule_t *new; + struct snd_pcm_hw_rule *new; unsigned int new_rules = constrs->rules_all + 16; new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL); if (!new) @@ -962,11 +962,11 @@ int snd_pcm_hw_rule_add(snd_pcm_runtime_t *runtime, unsigned int cond, * * Apply the constraint of the given bitmap mask to a mask parameter. */ -int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, +int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int32_t mask) { - snd_pcm_hw_constraints_t *constrs = &runtime->hw_constraints; - snd_mask_t *maskp = constrs_mask(constrs, var); + struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; + struct snd_mask *maskp = constrs_mask(constrs, var); *maskp->bits &= mask; memset(maskp->bits + 1, 0, (SNDRV_MASK_MAX-32) / 8); /* clear rest */ if (*maskp->bits == 0) @@ -982,11 +982,11 @@ int snd_pcm_hw_constraint_mask(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t va * * Apply the constraint of the given bitmap mask to a mask parameter. */ -int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, +int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, u_int64_t mask) { - snd_pcm_hw_constraints_t *constrs = &runtime->hw_constraints; - snd_mask_t *maskp = constrs_mask(constrs, var); + struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; + struct snd_mask *maskp = constrs_mask(constrs, var); maskp->bits[0] &= (u_int32_t)mask; maskp->bits[1] &= (u_int32_t)(mask >> 32); memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX-64) / 8); /* clear rest */ @@ -1002,9 +1002,9 @@ int snd_pcm_hw_constraint_mask64(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t * * Apply the constraint of integer to an interval parameter. */ -int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var) +int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var) { - snd_pcm_hw_constraints_t *constrs = &runtime->hw_constraints; + struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; return snd_interval_setinteger(constrs_interval(constrs, var)); } @@ -1017,11 +1017,11 @@ int snd_pcm_hw_constraint_integer(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t * * Apply the min/max range constraint to an interval parameter. */ -int snd_pcm_hw_constraint_minmax(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t var, +int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, unsigned int min, unsigned int max) { - snd_pcm_hw_constraints_t *constrs = &runtime->hw_constraints; - snd_interval_t t; + struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; + struct snd_interval t; t.min = min; t.max = max; t.openmin = t.openmax = 0; @@ -1029,10 +1029,10 @@ int snd_pcm_hw_constraint_minmax(snd_pcm_runtime_t *runtime, snd_pcm_hw_param_t return snd_interval_refine(constrs_interval(constrs, var), &t); } -static int snd_pcm_hw_rule_list(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_list(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_pcm_hw_constraint_list_t *list = rule->private; + struct snd_pcm_hw_constraint_list *list = rule->private; return snd_interval_list(hw_param_interval(params, rule->var), list->count, list->list, list->mask); } @@ -1046,20 +1046,20 @@ static int snd_pcm_hw_rule_list(snd_pcm_hw_params_t *params, * * Apply the list of constraints to an interval parameter. */ -int snd_pcm_hw_constraint_list(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, - snd_pcm_hw_constraint_list_t *l) + struct snd_pcm_hw_constraint_list *l) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_list, l, var, -1); } -static int snd_pcm_hw_rule_ratnums(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_ratnums(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_pcm_hw_constraint_ratnums_t *r = rule->private; + struct snd_pcm_hw_constraint_ratnums *r = rule->private; unsigned int num = 0, den = 0; int err; err = snd_interval_ratnum(hw_param_interval(params, rule->var), @@ -1076,22 +1076,22 @@ static int snd_pcm_hw_rule_ratnums(snd_pcm_hw_params_t *params, * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the ratnums constraint - * @r: ratnums_t constriants + * @r: struct snd_ratnums constriants */ -int snd_pcm_hw_constraint_ratnums(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, - snd_pcm_hw_constraint_ratnums_t *r) + struct snd_pcm_hw_constraint_ratnums *r) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_ratnums, r, var, -1); } -static int snd_pcm_hw_rule_ratdens(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_ratdens(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_pcm_hw_constraint_ratdens_t *r = rule->private; + struct snd_pcm_hw_constraint_ratdens *r = rule->private; unsigned int num = 0, den = 0; int err = snd_interval_ratden(hw_param_interval(params, rule->var), r->nrats, r->rats, &num, &den); @@ -1107,25 +1107,25 @@ static int snd_pcm_hw_rule_ratdens(snd_pcm_hw_params_t *params, * @runtime: PCM runtime instance * @cond: condition bits * @var: hw_params variable to apply the ratdens constraint - * @r: ratdens_t constriants + * @r: struct snd_ratdens constriants */ -int snd_pcm_hw_constraint_ratdens(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, - snd_pcm_hw_constraint_ratdens_t *r) + struct snd_pcm_hw_constraint_ratdens *r) { return snd_pcm_hw_rule_add(runtime, cond, var, snd_pcm_hw_rule_ratdens, r, var, -1); } -static int snd_pcm_hw_rule_msbits(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { unsigned int l = (unsigned long) rule->private; int width = l & 0xffff; unsigned int msbits = l >> 16; - snd_interval_t *i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); + struct snd_interval *i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); if (snd_interval_single(i) && snd_interval_value(i) == width) params->msbits = msbits; return 0; @@ -1138,7 +1138,7 @@ static int snd_pcm_hw_rule_msbits(snd_pcm_hw_params_t *params, * @width: sample bits width * @msbits: msbits width */ -int snd_pcm_hw_constraint_msbits(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, unsigned int cond, unsigned int width, unsigned int msbits) @@ -1150,8 +1150,8 @@ int snd_pcm_hw_constraint_msbits(snd_pcm_runtime_t *runtime, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); } -static int snd_pcm_hw_rule_step(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_step(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { unsigned long step = (unsigned long) rule->private; return snd_interval_step(hw_param_interval(params, rule->var), 0, step); @@ -1164,7 +1164,7 @@ static int snd_pcm_hw_rule_step(snd_pcm_hw_params_t *params, * @var: hw_params variable to apply the step constraint * @step: step size */ -int snd_pcm_hw_constraint_step(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var, unsigned long step) @@ -1174,7 +1174,7 @@ int snd_pcm_hw_constraint_step(snd_pcm_runtime_t *runtime, var, -1); } -static int snd_pcm_hw_rule_pow2(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_pow2(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { static int pow2_sizes[] = { 1<<0, 1<<1, 1<<2, 1<<3, 1<<4, 1<<5, 1<<6, 1<<7, @@ -1192,7 +1192,7 @@ static int snd_pcm_hw_rule_pow2(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t * * @cond: condition bits * @var: hw_params variable to apply the power-of-2 constraint */ -int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime, +int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, unsigned int cond, snd_pcm_hw_param_t var) { @@ -1202,13 +1202,12 @@ int snd_pcm_hw_constraint_pow2(snd_pcm_runtime_t *runtime, } /* To use the same code we have in alsa-lib */ -#define snd_pcm_t snd_pcm_substream_t #define assert(i) snd_assert((i), return -EINVAL) #ifndef INT_MIN #define INT_MIN ((int)((unsigned int)INT_MAX+1)) #endif -static void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params, +static void _snd_pcm_hw_param_any(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { if (hw_is_mask(var)) { @@ -1230,7 +1229,7 @@ static void _snd_pcm_hw_param_any(snd_pcm_hw_params_t *params, /* * snd_pcm_hw_param_any */ -int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, +int snd_pcm_hw_param_any(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { _snd_pcm_hw_param_any(params, var); @@ -1238,7 +1237,7 @@ int snd_pcm_hw_param_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, } #endif /* 0 */ -void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) +void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params) { unsigned int k; memset(params, 0, sizeof(*params)); @@ -1255,7 +1254,7 @@ void _snd_pcm_hw_params_any(snd_pcm_hw_params_t *params) * * Fill PARAMS with full configuration space boundaries */ -int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +int snd_pcm_hw_params_any(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params) { _snd_pcm_hw_params_any(params); return snd_pcm_hw_refine(pcm, params); @@ -1271,11 +1270,11 @@ int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) * Return the value for field PAR if it's fixed in configuration space * defined by PARAMS. Return -EINVAL otherwise */ -static int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, +static int snd_pcm_hw_param_value(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { if (hw_is_mask(var)) { - const snd_mask_t *mask = hw_param_mask_c(params, var); + const struct snd_mask *mask = hw_param_mask_c(params, var); if (!snd_mask_single(mask)) return -EINVAL; if (dir) @@ -1283,7 +1282,7 @@ static int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, return snd_mask_value(mask); } if (hw_is_interval(var)) { - const snd_interval_t *i = hw_param_interval_c(params, var); + const struct snd_interval *i = hw_param_interval_c(params, var); if (!snd_interval_single(i)) return -EINVAL; if (dir) @@ -1302,7 +1301,7 @@ static int snd_pcm_hw_param_value(const snd_pcm_hw_params_t *params, * * Return the minimum value for field PAR. */ -unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params, +unsigned int snd_pcm_hw_param_value_min(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { if (hw_is_mask(var)) { @@ -1311,7 +1310,7 @@ unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params, return snd_mask_min(hw_param_mask_c(params, var)); } if (hw_is_interval(var)) { - const snd_interval_t *i = hw_param_interval_c(params, var); + const struct snd_interval *i = hw_param_interval_c(params, var); if (dir) *dir = i->openmin; return snd_interval_min(i); @@ -1328,7 +1327,7 @@ unsigned int snd_pcm_hw_param_value_min(const snd_pcm_hw_params_t *params, * * Return the maximum value for field PAR. */ -unsigned int snd_pcm_hw_param_value_max(const snd_pcm_hw_params_t *params, +unsigned int snd_pcm_hw_param_value_max(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { if (hw_is_mask(var)) { @@ -1337,7 +1336,7 @@ unsigned int snd_pcm_hw_param_value_max(const snd_pcm_hw_params_t *params, return snd_mask_max(hw_param_mask_c(params, var)); } if (hw_is_interval(var)) { - const snd_interval_t *i = hw_param_interval_c(params, var); + const struct snd_interval *i = hw_param_interval_c(params, var); if (dir) *dir = - (int) i->openmax; return snd_interval_max(i); @@ -1346,7 +1345,7 @@ unsigned int snd_pcm_hw_param_value_max(const snd_pcm_hw_params_t *params, return -EINVAL; } -void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, +void _snd_pcm_hw_param_setempty(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { if (hw_is_mask(var)) { @@ -1362,7 +1361,7 @@ void _snd_pcm_hw_param_setempty(snd_pcm_hw_params_t *params, } } -int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params, +int _snd_pcm_hw_param_setinteger(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { int changed; @@ -1383,8 +1382,8 @@ int _snd_pcm_hw_param_setinteger(snd_pcm_hw_params_t *params, * non integer values. Reduce configuration space accordingly. * Return -EINVAL if the configuration space is empty */ -int snd_pcm_hw_param_setinteger(snd_pcm_t *pcm, - snd_pcm_hw_params_t *params, +int snd_pcm_hw_param_setinteger(struct snd_pcm_substream *pcm, + struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { int changed = _snd_pcm_hw_param_setinteger(params, var); @@ -1399,7 +1398,7 @@ int snd_pcm_hw_param_setinteger(snd_pcm_t *pcm, } #endif /* 0 */ -static int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, +static int _snd_pcm_hw_param_first(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { int changed; @@ -1430,8 +1429,8 @@ static int _snd_pcm_hw_param_first(snd_pcm_hw_params_t *params, * values > minimum. Reduce configuration space accordingly. * Return the minimum. */ -static int snd_pcm_hw_param_first(snd_pcm_t *pcm, - snd_pcm_hw_params_t *params, +static int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm, + struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { int changed = _snd_pcm_hw_param_first(params, var); @@ -1444,7 +1443,7 @@ static int snd_pcm_hw_param_first(snd_pcm_t *pcm, return snd_pcm_hw_param_value(params, var, dir); } -static int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, +static int _snd_pcm_hw_param_last(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var) { int changed; @@ -1475,8 +1474,8 @@ static int _snd_pcm_hw_param_last(snd_pcm_hw_params_t *params, * values < maximum. Reduce configuration space accordingly. * Return the maximum. */ -static int snd_pcm_hw_param_last(snd_pcm_t *pcm, - snd_pcm_hw_params_t *params, +static int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm, + struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { int changed = _snd_pcm_hw_param_last(params, var); @@ -1489,7 +1488,7 @@ static int snd_pcm_hw_param_last(snd_pcm_t *pcm, return snd_pcm_hw_param_value(params, var, dir); } -int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, +int _snd_pcm_hw_param_min(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int dir) { int changed; @@ -1531,7 +1530,7 @@ int _snd_pcm_hw_param_min(snd_pcm_hw_params_t *params, * values < VAL. Reduce configuration space accordingly. * Return new minimum or -EINVAL if the configuration space is empty */ -static int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, +static int snd_pcm_hw_param_min(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int *dir) { @@ -1546,7 +1545,7 @@ static int snd_pcm_hw_param_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, return snd_pcm_hw_param_value_min(params, var, dir); } -static int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, +static int _snd_pcm_hw_param_max(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int dir) { @@ -1591,7 +1590,7 @@ static int _snd_pcm_hw_param_max(snd_pcm_hw_params_t *params, * values >= VAL + 1. Reduce configuration space accordingly. * Return new maximum or -EINVAL if the configuration space is empty */ -static int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, +static int snd_pcm_hw_param_max(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int *dir) { @@ -1606,12 +1605,12 @@ static int snd_pcm_hw_param_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, return snd_pcm_hw_param_value_max(params, var, dir); } -int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, +int _snd_pcm_hw_param_set(struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int dir) { int changed; if (hw_is_mask(var)) { - snd_mask_t *m = hw_param_mask(params, var); + struct snd_mask *m = hw_param_mask(params, var); if (val == 0 && dir < 0) { changed = -EINVAL; snd_mask_none(m); @@ -1623,14 +1622,14 @@ int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, changed = snd_mask_refine_set(hw_param_mask(params, var), val); } } else if (hw_is_interval(var)) { - snd_interval_t *i = hw_param_interval(params, var); + struct snd_interval *i = hw_param_interval(params, var); if (val == 0 && dir < 0) { changed = -EINVAL; snd_interval_none(i); } else if (dir == 0) changed = snd_interval_refine_set(i, val); else { - snd_interval_t t; + struct snd_interval t; t.openmin = 1; t.openmax = 1; t.empty = 0; @@ -1667,7 +1666,7 @@ int _snd_pcm_hw_param_set(snd_pcm_hw_params_t *params, * values != VAL. Reduce configuration space accordingly. * Return VAL or -EINVAL if the configuration space is empty */ -int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, +int snd_pcm_hw_param_set(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int val, int dir) { int changed = _snd_pcm_hw_param_set(params, var, val, dir); @@ -1681,8 +1680,8 @@ int snd_pcm_hw_param_set(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, return snd_pcm_hw_param_value(params, var, NULL); } -static int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, const snd_mask_t *val) +static int _snd_pcm_hw_param_mask(struct snd_pcm_hw_params *params, + snd_pcm_hw_param_t var, const struct snd_mask *val) { int changed; assert(hw_is_mask(var)); @@ -1708,8 +1707,8 @@ static int _snd_pcm_hw_param_mask(snd_pcm_hw_params_t *params, * Return 0 on success or -EINVAL * if the configuration space is empty */ -int snd_pcm_hw_param_mask(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, - snd_pcm_hw_param_t var, const snd_mask_t *val) +int snd_pcm_hw_param_mask(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, + snd_pcm_hw_param_t var, const struct snd_mask *val) { int changed = _snd_pcm_hw_param_mask(params, var, val); if (changed < 0) @@ -1784,10 +1783,10 @@ static int boundary_nearer(int min, int mindir, * SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_SUBFORMAT. * Return the value found. */ -int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, +int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, unsigned int best, int *dir) { - snd_pcm_hw_params_t *save = NULL; + struct snd_pcm_hw_params *save = NULL; int v; unsigned int saved_min; int last = 0; @@ -1814,7 +1813,7 @@ int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, saved_min = min; min = snd_pcm_hw_param_min(pcm, params, var, min, &mindir); if (min >= 0) { - snd_pcm_hw_params_t *params1; + struct snd_pcm_hw_params *params1; if (max < 0) goto _end; if ((unsigned int)min == saved_min && mindir == valdir) @@ -1861,7 +1860,7 @@ int snd_pcm_hw_param_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, * first access, first format, first subformat, min channels, * min rate, min period time, max buffer size, min tick time */ -int snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) +int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm, struct snd_pcm_hw_params *params) { int err; @@ -1892,13 +1891,12 @@ int snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) return 0; } -#undef snd_pcm_t #undef assert -static int snd_pcm_lib_ioctl_reset(snd_pcm_substream_t *substream, +static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, void *arg) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; snd_pcm_stream_lock_irqsave(substream, flags); if (snd_pcm_running(substream) && @@ -1910,11 +1908,11 @@ static int snd_pcm_lib_ioctl_reset(snd_pcm_substream_t *substream, return 0; } -static int snd_pcm_lib_ioctl_channel_info(snd_pcm_substream_t *substream, +static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream, void *arg) { - snd_pcm_channel_info_t *info = arg; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_channel_info *info = arg; + struct snd_pcm_runtime *runtime = substream->runtime; int width; if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) { info->offset = -1; @@ -1956,7 +1954,7 @@ static int snd_pcm_lib_ioctl_channel_info(snd_pcm_substream_t *substream, * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_lib_ioctl(snd_pcm_substream_t *substream, +int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { switch (cmd) { @@ -1974,10 +1972,10 @@ int snd_pcm_lib_ioctl(snd_pcm_substream_t *substream, * Conditions */ -static void snd_pcm_system_tick_set(snd_pcm_substream_t *substream, +static void snd_pcm_system_tick_set(struct snd_pcm_substream *substream, unsigned long ticks) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (ticks == 0) del_timer(&runtime->tick_timer); else { @@ -1988,14 +1986,14 @@ static void snd_pcm_system_tick_set(snd_pcm_substream_t *substream, } /* Temporary alias */ -void snd_pcm_tick_set(snd_pcm_substream_t *substream, unsigned long ticks) +void snd_pcm_tick_set(struct snd_pcm_substream *substream, unsigned long ticks) { snd_pcm_system_tick_set(substream, ticks); } -void snd_pcm_tick_prepare(snd_pcm_substream_t *substream) +void snd_pcm_tick_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t frames = ULONG_MAX; snd_pcm_uframes_t avail, dist; unsigned int ticks; @@ -2046,9 +2044,9 @@ void snd_pcm_tick_prepare(snd_pcm_substream_t *substream) snd_pcm_tick_set(substream, (unsigned long) ticks); } -void snd_pcm_tick_elapsed(snd_pcm_substream_t *substream) +void snd_pcm_tick_elapsed(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; unsigned long flags; snd_assert(substream != NULL, return); @@ -2076,9 +2074,9 @@ void snd_pcm_tick_elapsed(snd_pcm_substream_t *substream) * Even if more than one periods have elapsed since the last call, you * have to call this only once. */ -void snd_pcm_period_elapsed(snd_pcm_substream_t *substream) +void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; unsigned long flags; snd_assert(substream != NULL, return); @@ -2104,12 +2102,12 @@ void snd_pcm_period_elapsed(snd_pcm_substream_t *substream) kill_fasync(&runtime->fasync, SIGIO, POLL_IN); } -static int snd_pcm_lib_write_transfer(snd_pcm_substream_t *substream, +static int snd_pcm_lib_write_transfer(struct snd_pcm_substream *substream, unsigned int hwoff, unsigned long data, unsigned int off, snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; char __user *buf = (char __user *) data + frames_to_bytes(runtime, off); if (substream->ops->copy) { @@ -2124,17 +2122,17 @@ static int snd_pcm_lib_write_transfer(snd_pcm_substream_t *substream, return 0; } -typedef int (*transfer_f)(snd_pcm_substream_t *substream, unsigned int hwoff, +typedef int (*transfer_f)(struct snd_pcm_substream *substream, unsigned int hwoff, unsigned long data, unsigned int off, snd_pcm_uframes_t size); -static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream, +static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, unsigned long data, snd_pcm_uframes_t size, int nonblock, transfer_f transfer) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t xfer = 0; snd_pcm_uframes_t offset = 0; int err = 0; @@ -2290,9 +2288,9 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(snd_pcm_substream_t *substream, return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; } -snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void __user *buf, snd_pcm_uframes_t size) +snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, snd_pcm_uframes_t size) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; int nonblock; snd_assert(substream != NULL, return -ENXIO); @@ -2306,7 +2304,7 @@ snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void _ nonblock = !!(substream->ffile->f_flags & O_NONBLOCK); #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) if (substream->oss.oss) { - snd_pcm_oss_setup_t *setup = substream->oss.setup; + struct snd_pcm_oss_setup *setup = substream->oss.setup; if (setup != NULL) { if (setup->nonblock) nonblock = 1; @@ -2323,12 +2321,12 @@ snd_pcm_sframes_t snd_pcm_lib_write(snd_pcm_substream_t *substream, const void _ snd_pcm_lib_write_transfer); } -static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream, +static int snd_pcm_lib_writev_transfer(struct snd_pcm_substream *substream, unsigned int hwoff, unsigned long data, unsigned int off, snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; void __user **bufs = (void __user **)data; int channels = runtime->channels; @@ -2363,11 +2361,11 @@ static int snd_pcm_lib_writev_transfer(snd_pcm_substream_t *substream, return 0; } -snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, +snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream, void __user **bufs, snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; int nonblock; snd_assert(substream != NULL, return -ENXIO); @@ -2381,7 +2379,7 @@ snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, nonblock = !!(substream->ffile->f_flags & O_NONBLOCK); #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) if (substream->oss.oss) { - snd_pcm_oss_setup_t *setup = substream->oss.setup; + struct snd_pcm_oss_setup *setup = substream->oss.setup; if (setup != NULL) { if (setup->nonblock) nonblock = 1; @@ -2397,12 +2395,12 @@ snd_pcm_sframes_t snd_pcm_lib_writev(snd_pcm_substream_t *substream, nonblock, snd_pcm_lib_writev_transfer); } -static int snd_pcm_lib_read_transfer(snd_pcm_substream_t *substream, +static int snd_pcm_lib_read_transfer(struct snd_pcm_substream *substream, unsigned int hwoff, unsigned long data, unsigned int off, snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; char __user *buf = (char __user *) data + frames_to_bytes(runtime, off); if (substream->ops->copy) { @@ -2417,13 +2415,13 @@ static int snd_pcm_lib_read_transfer(snd_pcm_substream_t *substream, return 0; } -static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, +static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, unsigned long data, snd_pcm_uframes_t size, int nonblock, transfer_f transfer) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t xfer = 0; snd_pcm_uframes_t offset = 0; int err = 0; @@ -2587,9 +2585,9 @@ static snd_pcm_sframes_t snd_pcm_lib_read1(snd_pcm_substream_t *substream, return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; } -snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void __user *buf, snd_pcm_uframes_t size) +snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream, void __user *buf, snd_pcm_uframes_t size) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; int nonblock; snd_assert(substream != NULL, return -ENXIO); @@ -2603,7 +2601,7 @@ snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void __user * nonblock = !!(substream->ffile->f_flags & O_NONBLOCK); #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) if (substream->oss.oss) { - snd_pcm_oss_setup_t *setup = substream->oss.setup; + struct snd_pcm_oss_setup *setup = substream->oss.setup; if (setup != NULL) { if (setup->nonblock) nonblock = 1; @@ -2617,12 +2615,12 @@ snd_pcm_sframes_t snd_pcm_lib_read(snd_pcm_substream_t *substream, void __user * return snd_pcm_lib_read1(substream, (unsigned long)buf, size, nonblock, snd_pcm_lib_read_transfer); } -static int snd_pcm_lib_readv_transfer(snd_pcm_substream_t *substream, +static int snd_pcm_lib_readv_transfer(struct snd_pcm_substream *substream, unsigned int hwoff, unsigned long data, unsigned int off, snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; void __user **bufs = (void __user **)data; int channels = runtime->channels; @@ -2654,11 +2652,11 @@ static int snd_pcm_lib_readv_transfer(snd_pcm_substream_t *substream, return 0; } -snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, +snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream, void __user **bufs, snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; int nonblock; snd_assert(substream != NULL, return -ENXIO); @@ -2672,7 +2670,7 @@ snd_pcm_sframes_t snd_pcm_lib_readv(snd_pcm_substream_t *substream, nonblock = !!(substream->ffile->f_flags & O_NONBLOCK); #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) if (substream->oss.oss) { - snd_pcm_oss_setup_t *setup = substream->oss.setup; + struct snd_pcm_oss_setup *setup = substream->oss.setup; if (setup != NULL) { if (setup->nonblock) nonblock = 1; diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index b3f5344..d37bcb7 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -46,7 +46,7 @@ static const size_t snd_minimum_buffer = 16384; * * the minimum size is snd_minimum_buffer. it should be power of 2. */ -static int preallocate_pcm_pages(snd_pcm_substream_t *substream, size_t size) +static int preallocate_pcm_pages(struct snd_pcm_substream *substream, size_t size) { struct snd_dma_buffer *dmab = &substream->dma_buffer; int err; @@ -78,7 +78,7 @@ static int preallocate_pcm_pages(snd_pcm_substream_t *substream, size_t size) /* * release the preallocated buffer if not yet done. */ -static void snd_pcm_lib_preallocate_dma_free(snd_pcm_substream_t *substream) +static void snd_pcm_lib_preallocate_dma_free(struct snd_pcm_substream *substream) { if (substream->dma_buffer.area == NULL) return; @@ -97,7 +97,7 @@ static void snd_pcm_lib_preallocate_dma_free(snd_pcm_substream_t *substream) * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_lib_preallocate_free(snd_pcm_substream_t *substream) +int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) { snd_pcm_lib_preallocate_dma_free(substream); if (substream->proc_prealloc_entry) { @@ -115,9 +115,9 @@ int snd_pcm_lib_preallocate_free(snd_pcm_substream_t *substream) * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_lib_preallocate_free_for_all(snd_pcm_t *pcm) +int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int stream; for (stream = 0; stream < 2; stream++) @@ -131,10 +131,10 @@ int snd_pcm_lib_preallocate_free_for_all(snd_pcm_t *pcm) * * prints the current allocated size in kB. */ -static void snd_pcm_lib_preallocate_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t *buffer) +static void snd_pcm_lib_preallocate_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)entry->private_data; + struct snd_pcm_substream *substream = entry->private_data; snd_iprintf(buffer, "%lu\n", (unsigned long) substream->dma_buffer.bytes / 1024); } @@ -143,10 +143,10 @@ static void snd_pcm_lib_preallocate_proc_read(snd_info_entry_t *entry, * * accepts the preallocation size in kB. */ -static void snd_pcm_lib_preallocate_proc_write(snd_info_entry_t *entry, - snd_info_buffer_t *buffer) +static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)entry->private_data; + struct snd_pcm_substream *substream = entry->private_data; char line[64], str[64]; size_t size; struct snd_dma_buffer new_dmab; @@ -188,10 +188,10 @@ static void snd_pcm_lib_preallocate_proc_write(snd_info_entry_t *entry, /* * pre-allocate the buffer and create a proc file for the substream */ -static int snd_pcm_lib_preallocate_pages1(snd_pcm_substream_t *substream, +static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream, size_t size, size_t max) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (size > 0 && preallocate_dma && substream->number < maximum_substreams) preallocate_pcm_pages(substream, size); @@ -233,7 +233,7 @@ static int snd_pcm_lib_preallocate_pages1(snd_pcm_substream_t *substream, * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_lib_preallocate_pages(snd_pcm_substream_t *substream, +int snd_pcm_lib_preallocate_pages(struct snd_pcm_substream *substream, int type, struct device *data, size_t size, size_t max) { @@ -255,11 +255,11 @@ int snd_pcm_lib_preallocate_pages(snd_pcm_substream_t *substream, * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_lib_preallocate_pages_for_all(snd_pcm_t *pcm, +int snd_pcm_lib_preallocate_pages_for_all(struct snd_pcm *pcm, int type, void *data, size_t size, size_t max) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int stream, err; for (stream = 0; stream < 2; stream++) @@ -277,7 +277,7 @@ int snd_pcm_lib_preallocate_pages_for_all(snd_pcm_t *pcm, * Returns the page struct at the given buffer offset. * Used as the page callback of PCM ops. */ -struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset) +struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigned long offset) { struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); @@ -298,9 +298,9 @@ struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned lon * Returns 1 if the buffer is changed, 0 if not changed, or a negative * code on failure. */ -int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size) +int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; struct snd_dma_buffer *dmab = NULL; snd_assert(substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_UNKNOWN, return -EINVAL); @@ -318,7 +318,8 @@ int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size) } snd_pcm_lib_free_pages(substream); } - if (substream->dma_buffer.area != NULL && substream->dma_buffer.bytes >= size) { + if (substream->dma_buffer.area != NULL && + substream->dma_buffer.bytes >= size) { dmab = &substream->dma_buffer; /* use the pre-allocated buffer */ } else { dmab = kzalloc(sizeof(*dmab), GFP_KERNEL); @@ -345,9 +346,9 @@ int snd_pcm_lib_malloc_pages(snd_pcm_substream_t *substream, size_t size) * * Returns zero if successful, or a negative error code on failure. */ -int snd_pcm_lib_free_pages(snd_pcm_substream_t *substream) +int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; snd_assert(substream != NULL, return -EINVAL); runtime = substream->runtime; diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index 1453743..593c77f 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -441,7 +441,7 @@ snd_pcm_format_t snd_pcm_build_linear_format(int width, int unsignd, int big_end * * Returns zero if successful. */ -int snd_pcm_limit_hw_rates(snd_pcm_runtime_t *runtime) +int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime) { static unsigned rates[] = { /* ATTENTION: these values depend on the definition in pcm.h! */ diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 16e252f..263c01a 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -39,11 +39,11 @@ * Compatibility */ -struct sndrv_pcm_hw_params_old { +struct snd_pcm_hw_params_old { unsigned int flags; unsigned int masks[SNDRV_PCM_HW_PARAM_SUBFORMAT - SNDRV_PCM_HW_PARAM_ACCESS + 1]; - struct sndrv_interval intervals[SNDRV_PCM_HW_PARAM_TICK_TIME - + struct snd_interval intervals[SNDRV_PCM_HW_PARAM_TICK_TIME - SNDRV_PCM_HW_PARAM_SAMPLE_BITS + 1]; unsigned int rmask; unsigned int cmask; @@ -51,15 +51,17 @@ struct sndrv_pcm_hw_params_old { unsigned int msbits; unsigned int rate_num; unsigned int rate_den; - sndrv_pcm_uframes_t fifo_size; + snd_pcm_uframes_t fifo_size; unsigned char reserved[64]; }; -#define SNDRV_PCM_IOCTL_HW_REFINE_OLD _IOWR('A', 0x10, struct sndrv_pcm_hw_params_old) -#define SNDRV_PCM_IOCTL_HW_PARAMS_OLD _IOWR('A', 0x11, struct sndrv_pcm_hw_params_old) +#define SNDRV_PCM_IOCTL_HW_REFINE_OLD _IOWR('A', 0x10, struct snd_pcm_hw_params_old) +#define SNDRV_PCM_IOCTL_HW_PARAMS_OLD _IOWR('A', 0x11, struct snd_pcm_hw_params_old) -static int snd_pcm_hw_refine_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old __user * _oparams); -static int snd_pcm_hw_params_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old __user * _oparams); +static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params_old __user * _oparams); +static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params_old __user * _oparams); /* * @@ -83,11 +85,11 @@ static inline void snd_leave_user(mm_segment_t fs) -int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info) +int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) { - snd_pcm_runtime_t * runtime; - snd_pcm_t *pcm = substream->pcm; - snd_pcm_str_t *pstr = substream->pstr; + struct snd_pcm_runtime *runtime; + struct snd_pcm *pcm = substream->pcm; + struct snd_pcm_str *pstr = substream->pstr; snd_assert(substream != NULL, return -ENXIO); memset(info, 0, sizeof(*info)); @@ -111,9 +113,10 @@ int snd_pcm_info(snd_pcm_substream_t * substream, snd_pcm_info_t *info) return 0; } -int snd_pcm_info_user(snd_pcm_substream_t * substream, snd_pcm_info_t __user * _info) +int snd_pcm_info_user(struct snd_pcm_substream *substream, + struct snd_pcm_info __user * _info) { - snd_pcm_info_t *info; + struct snd_pcm_info *info; int err; info = kmalloc(sizeof(*info), GFP_KERNEL); @@ -151,14 +154,14 @@ char *snd_pcm_hw_param_names[] = { }; #endif -int snd_pcm_hw_refine(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +int snd_pcm_hw_refine(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { unsigned int k; - snd_pcm_hardware_t *hw; - snd_interval_t *i = NULL; - snd_mask_t *m = NULL; - snd_pcm_hw_constraints_t *constrs = &substream->runtime->hw_constraints; + struct snd_pcm_hardware *hw; + struct snd_interval *i = NULL; + struct snd_mask *m = NULL; + struct snd_pcm_hw_constraints *constrs = &substream->runtime->hw_constraints; unsigned int rstamps[constrs->rules_num]; unsigned int vstamps[SNDRV_PCM_HW_PARAM_LAST_INTERVAL + 1]; unsigned int stamp = 2; @@ -231,7 +234,7 @@ int snd_pcm_hw_refine(snd_pcm_substream_t *substream, do { again = 0; for (k = 0; k < constrs->rules_num; k++) { - snd_pcm_hw_rule_t *r = &constrs->rules[k]; + struct snd_pcm_hw_rule *r = &constrs->rules[k]; unsigned int d; int doit = 0; if (r->cond && !(r->cond & params->flags)) @@ -313,9 +316,10 @@ int snd_pcm_hw_refine(snd_pcm_substream_t *substream, return 0; } -static int snd_pcm_hw_refine_user(snd_pcm_substream_t * substream, snd_pcm_hw_params_t __user * _params) +static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params __user * _params) { - snd_pcm_hw_params_t *params; + struct snd_pcm_hw_params *params; int err; params = kmalloc(sizeof(*params), GFP_KERNEL); @@ -337,10 +341,10 @@ out: return err; } -static int snd_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +static int snd_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; int err; unsigned int bits; snd_pcm_uframes_t frames; @@ -432,9 +436,10 @@ static int snd_pcm_hw_params(snd_pcm_substream_t *substream, return err; } -static int snd_pcm_hw_params_user(snd_pcm_substream_t * substream, snd_pcm_hw_params_t __user * _params) +static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params __user * _params) { - snd_pcm_hw_params_t *params; + struct snd_pcm_hw_params *params; int err; params = kmalloc(sizeof(*params), GFP_KERNEL); @@ -456,9 +461,9 @@ out: return err; } -static int snd_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_pcm_hw_free(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; int result = 0; snd_assert(substream != NULL, return -ENXIO); @@ -482,9 +487,10 @@ static int snd_pcm_hw_free(snd_pcm_substream_t * substream) return result; } -static int snd_pcm_sw_params(snd_pcm_substream_t * substream, snd_pcm_sw_params_t *params) +static int snd_pcm_sw_params(struct snd_pcm_substream *substream, + struct snd_pcm_sw_params *params) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; snd_assert(substream != NULL, return -ENXIO); runtime = substream->runtime; @@ -537,9 +543,10 @@ static int snd_pcm_sw_params(snd_pcm_substream_t * substream, snd_pcm_sw_params_ return 0; } -static int snd_pcm_sw_params_user(snd_pcm_substream_t * substream, snd_pcm_sw_params_t __user * _params) +static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, + struct snd_pcm_sw_params __user * _params) { - snd_pcm_sw_params_t params; + struct snd_pcm_sw_params params; int err; if (copy_from_user(¶ms, _params, sizeof(params))) return -EFAULT; @@ -549,10 +556,10 @@ static int snd_pcm_sw_params_user(snd_pcm_substream_t * substream, snd_pcm_sw_pa return err; } -int snd_pcm_status(snd_pcm_substream_t *substream, - snd_pcm_status_t *status) +int snd_pcm_status(struct snd_pcm_substream *substream, + struct snd_pcm_status *status) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_stream_lock_irq(substream); status->state = runtime->status->state; @@ -593,10 +600,11 @@ int snd_pcm_status(snd_pcm_substream_t *substream, return 0; } -static int snd_pcm_status_user(snd_pcm_substream_t * substream, snd_pcm_status_t __user * _status) +static int snd_pcm_status_user(struct snd_pcm_substream *substream, + struct snd_pcm_status __user * _status) { - snd_pcm_status_t status; - snd_pcm_runtime_t *runtime; + struct snd_pcm_status status; + struct snd_pcm_runtime *runtime; int res; snd_assert(substream != NULL, return -ENXIO); @@ -610,9 +618,10 @@ static int snd_pcm_status_user(snd_pcm_substream_t * substream, snd_pcm_status_t return 0; } -static int snd_pcm_channel_info(snd_pcm_substream_t * substream, snd_pcm_channel_info_t * info) +static int snd_pcm_channel_info(struct snd_pcm_substream *substream, + struct snd_pcm_channel_info * info) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; unsigned int channel; snd_assert(substream != NULL, return -ENXIO); @@ -631,9 +640,10 @@ static int snd_pcm_channel_info(snd_pcm_substream_t * substream, snd_pcm_channel return substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); } -static int snd_pcm_channel_info_user(snd_pcm_substream_t * substream, snd_pcm_channel_info_t __user * _info) +static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, + struct snd_pcm_channel_info __user * _info) { - snd_pcm_channel_info_t info; + struct snd_pcm_channel_info info; int res; if (copy_from_user(&info, _info, sizeof(info))) @@ -646,9 +656,9 @@ static int snd_pcm_channel_info_user(snd_pcm_substream_t * substream, snd_pcm_ch return 0; } -static void snd_pcm_trigger_tstamp(snd_pcm_substream_t *substream) +static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->trigger_master == NULL) return; if (runtime->trigger_master == substream) { @@ -661,10 +671,10 @@ static void snd_pcm_trigger_tstamp(snd_pcm_substream_t *substream) } struct action_ops { - int (*pre_action)(snd_pcm_substream_t *substream, int state); - int (*do_action)(snd_pcm_substream_t *substream, int state); - void (*undo_action)(snd_pcm_substream_t *substream, int state); - void (*post_action)(snd_pcm_substream_t *substream, int state); + int (*pre_action)(struct snd_pcm_substream *substream, int state); + int (*do_action)(struct snd_pcm_substream *substream, int state); + void (*undo_action)(struct snd_pcm_substream *substream, int state); + void (*post_action)(struct snd_pcm_substream *substream, int state); }; /* @@ -673,12 +683,12 @@ struct action_ops { * Note2: call with calling stream lock + link lock */ static int snd_pcm_action_group(struct action_ops *ops, - snd_pcm_substream_t *substream, + struct snd_pcm_substream *substream, int state, int do_lock) { struct list_head *pos; - snd_pcm_substream_t *s = NULL; - snd_pcm_substream_t *s1; + struct snd_pcm_substream *s = NULL; + struct snd_pcm_substream *s1; int res = 0; snd_pcm_group_for_each(pos, substream) { @@ -727,7 +737,7 @@ static int snd_pcm_action_group(struct action_ops *ops, * Note: call with stream lock */ static int snd_pcm_action_single(struct action_ops *ops, - snd_pcm_substream_t *substream, + struct snd_pcm_substream *substream, int state) { int res; @@ -747,7 +757,7 @@ static int snd_pcm_action_single(struct action_ops *ops, * Note: call with stream lock */ static int snd_pcm_action(struct action_ops *ops, - snd_pcm_substream_t *substream, + struct snd_pcm_substream *substream, int state) { int res; @@ -770,7 +780,7 @@ static int snd_pcm_action(struct action_ops *ops, * Note: don't use any locks before */ static int snd_pcm_action_lock_irq(struct action_ops *ops, - snd_pcm_substream_t *substream, + struct snd_pcm_substream *substream, int state) { int res; @@ -794,7 +804,7 @@ static int snd_pcm_action_lock_irq(struct action_ops *ops, /* */ static int snd_pcm_action_nonatomic(struct action_ops *ops, - snd_pcm_substream_t *substream, + struct snd_pcm_substream *substream, int state) { int res; @@ -811,9 +821,9 @@ static int snd_pcm_action_nonatomic(struct action_ops *ops, /* * start callbacks */ -static int snd_pcm_pre_start(snd_pcm_substream_t *substream, int state) +static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state != SNDRV_PCM_STATE_PREPARED) return -EBADFD; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && @@ -823,22 +833,22 @@ static int snd_pcm_pre_start(snd_pcm_substream_t *substream, int state) return 0; } -static int snd_pcm_do_start(snd_pcm_substream_t *substream, int state) +static int snd_pcm_do_start(struct snd_pcm_substream *substream, int state) { if (substream->runtime->trigger_master != substream) return 0; return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); } -static void snd_pcm_undo_start(snd_pcm_substream_t *substream, int state) +static void snd_pcm_undo_start(struct snd_pcm_substream *substream, int state) { if (substream->runtime->trigger_master == substream) substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); } -static void snd_pcm_post_start(snd_pcm_substream_t *substream, int state) +static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_trigger_tstamp(substream); runtime->status->state = state; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && @@ -847,7 +857,8 @@ static void snd_pcm_post_start(snd_pcm_substream_t *substream, int state) if (runtime->sleep_min) snd_pcm_tick_prepare(substream); if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTART, &runtime->trigger_tstamp); + snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTART, + &runtime->trigger_tstamp); } static struct action_ops snd_pcm_action_start = { @@ -863,24 +874,25 @@ static struct action_ops snd_pcm_action_start = { * * Start all linked streams. */ -int snd_pcm_start(snd_pcm_substream_t *substream) +int snd_pcm_start(struct snd_pcm_substream *substream) { - return snd_pcm_action(&snd_pcm_action_start, substream, SNDRV_PCM_STATE_RUNNING); + return snd_pcm_action(&snd_pcm_action_start, substream, + SNDRV_PCM_STATE_RUNNING); } /* * stop callbacks */ -static int snd_pcm_pre_stop(snd_pcm_substream_t *substream, int state) +static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state == SNDRV_PCM_STATE_OPEN) return -EBADFD; runtime->trigger_master = substream; return 0; } -static int snd_pcm_do_stop(snd_pcm_substream_t *substream, int state) +static int snd_pcm_do_stop(struct snd_pcm_substream *substream, int state) { if (substream->runtime->trigger_master == substream && snd_pcm_running(substream)) @@ -888,13 +900,14 @@ static int snd_pcm_do_stop(snd_pcm_substream_t *substream, int state) return 0; /* unconditonally stop all substreams */ } -static void snd_pcm_post_stop(snd_pcm_substream_t *substream, int state) +static void snd_pcm_post_stop(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state != state) { snd_pcm_trigger_tstamp(substream); if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTOP, &runtime->trigger_tstamp); + snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTOP, + &runtime->trigger_tstamp); runtime->status->state = state; snd_pcm_tick_set(substream, 0); } @@ -915,7 +928,7 @@ static struct action_ops snd_pcm_action_stop = { * Try to stop all running streams in the substream group. * The state of each stream is changed to the given value after that unconditionally. */ -int snd_pcm_stop(snd_pcm_substream_t *substream, int state) +int snd_pcm_stop(struct snd_pcm_substream *substream, int state) { return snd_pcm_action(&snd_pcm_action_stop, substream, state); } @@ -928,17 +941,18 @@ int snd_pcm_stop(snd_pcm_substream_t *substream, int state) * The state is changed to SETUP. * Unlike snd_pcm_stop(), this affects only the given stream. */ -int snd_pcm_drain_done(snd_pcm_substream_t *substream) +int snd_pcm_drain_done(struct snd_pcm_substream *substream) { - return snd_pcm_action_single(&snd_pcm_action_stop, substream, SNDRV_PCM_STATE_SETUP); + return snd_pcm_action_single(&snd_pcm_action_stop, substream, + SNDRV_PCM_STATE_SETUP); } /* * pause callbacks */ -static int snd_pcm_pre_pause(snd_pcm_substream_t *substream, int push) +static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, int push) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (!(runtime->info & SNDRV_PCM_INFO_PAUSE)) return -ENOSYS; if (push) { @@ -950,7 +964,7 @@ static int snd_pcm_pre_pause(snd_pcm_substream_t *substream, int push) return 0; } -static int snd_pcm_do_pause(snd_pcm_substream_t *substream, int push) +static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push) { if (substream->runtime->trigger_master != substream) return 0; @@ -959,7 +973,7 @@ static int snd_pcm_do_pause(snd_pcm_substream_t *substream, int push) SNDRV_PCM_TRIGGER_PAUSE_RELEASE); } -static void snd_pcm_undo_pause(snd_pcm_substream_t *substream, int push) +static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, int push) { if (substream->runtime->trigger_master == substream) substream->ops->trigger(substream, @@ -967,14 +981,16 @@ static void snd_pcm_undo_pause(snd_pcm_substream_t *substream, int push) SNDRV_PCM_TRIGGER_PAUSE_PUSH); } -static void snd_pcm_post_pause(snd_pcm_substream_t *substream, int push) +static void snd_pcm_post_pause(struct snd_pcm_substream *substream, int push) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_trigger_tstamp(substream); if (push) { runtime->status->state = SNDRV_PCM_STATE_PAUSED; if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MPAUSE, &runtime->trigger_tstamp); + snd_timer_notify(substream->timer, + SNDRV_TIMER_EVENT_MPAUSE, + &runtime->trigger_tstamp); snd_pcm_tick_set(substream, 0); wake_up(&runtime->sleep); } else { @@ -982,7 +998,9 @@ static void snd_pcm_post_pause(snd_pcm_substream_t *substream, int push) if (runtime->sleep_min) snd_pcm_tick_prepare(substream); if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MCONTINUE, &runtime->trigger_tstamp); + snd_timer_notify(substream->timer, + SNDRV_TIMER_EVENT_MCONTINUE, + &runtime->trigger_tstamp); } } @@ -996,7 +1014,7 @@ static struct action_ops snd_pcm_action_pause = { /* * Push/release the pause for all linked streams. */ -static int snd_pcm_pause(snd_pcm_substream_t *substream, int push) +static int snd_pcm_pause(struct snd_pcm_substream *substream, int push) { return snd_pcm_action(&snd_pcm_action_pause, substream, push); } @@ -1004,18 +1022,18 @@ static int snd_pcm_pause(snd_pcm_substream_t *substream, int push) #ifdef CONFIG_PM /* suspend */ -static int snd_pcm_pre_suspend(snd_pcm_substream_t *substream, int state) +static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) return -EBUSY; runtime->trigger_master = substream; return 0; } -static int snd_pcm_do_suspend(snd_pcm_substream_t *substream, int state) +static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->trigger_master != substream) return 0; if (! snd_pcm_running(substream)) @@ -1024,12 +1042,13 @@ static int snd_pcm_do_suspend(snd_pcm_substream_t *substream, int state) return 0; /* suspend unconditionally */ } -static void snd_pcm_post_suspend(snd_pcm_substream_t *substream, int state) +static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_trigger_tstamp(substream); if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSUSPEND, &runtime->trigger_tstamp); + snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSUSPEND, + &runtime->trigger_tstamp); runtime->status->suspended_state = runtime->status->state; runtime->status->state = SNDRV_PCM_STATE_SUSPENDED; snd_pcm_tick_set(substream, 0); @@ -1049,7 +1068,7 @@ static struct action_ops snd_pcm_action_suspend = { * Trigger SUSPEND to all linked streams. * After this call, all streams are changed to SUSPENDED state. */ -int snd_pcm_suspend(snd_pcm_substream_t *substream) +int snd_pcm_suspend(struct snd_pcm_substream *substream) { int err; unsigned long flags; @@ -1067,13 +1086,14 @@ int snd_pcm_suspend(snd_pcm_substream_t *substream) * Trigger SUSPEND to all substreams in the given pcm. * After this call, all streams are changed to SUSPENDED state. */ -int snd_pcm_suspend_all(snd_pcm_t *pcm) +int snd_pcm_suspend_all(struct snd_pcm *pcm) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int stream, err = 0; for (stream = 0; stream < 2; stream++) { - for (substream = pcm->streams[stream].substream; substream; substream = substream->next) { + for (substream = pcm->streams[stream].substream; + substream; substream = substream->next) { /* FIXME: the open/close code should lock this as well */ if (substream->runtime == NULL) continue; @@ -1087,18 +1107,18 @@ int snd_pcm_suspend_all(snd_pcm_t *pcm) /* resume */ -static int snd_pcm_pre_resume(snd_pcm_substream_t *substream, int state) +static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (!(runtime->info & SNDRV_PCM_INFO_RESUME)) return -ENOSYS; runtime->trigger_master = substream; return 0; } -static int snd_pcm_do_resume(snd_pcm_substream_t *substream, int state) +static int snd_pcm_do_resume(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->trigger_master != substream) return 0; /* DMA not running previously? */ @@ -1109,19 +1129,20 @@ static int snd_pcm_do_resume(snd_pcm_substream_t *substream, int state) return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); } -static void snd_pcm_undo_resume(snd_pcm_substream_t *substream, int state) +static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, int state) { if (substream->runtime->trigger_master == substream && snd_pcm_running(substream)) substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); } -static void snd_pcm_post_resume(snd_pcm_substream_t *substream, int state) +static void snd_pcm_post_resume(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_trigger_tstamp(substream); if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MRESUME, &runtime->trigger_tstamp); + snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MRESUME, + &runtime->trigger_tstamp); runtime->status->state = runtime->status->suspended_state; if (runtime->sleep_min) snd_pcm_tick_prepare(substream); @@ -1134,9 +1155,9 @@ static struct action_ops snd_pcm_action_resume = { .post_action = snd_pcm_post_resume }; -static int snd_pcm_resume(snd_pcm_substream_t *substream) +static int snd_pcm_resume(struct snd_pcm_substream *substream) { - snd_card_t *card = substream->pcm->card; + struct snd_card *card = substream->pcm->card; int res; snd_power_lock(card); @@ -1148,7 +1169,7 @@ static int snd_pcm_resume(snd_pcm_substream_t *substream) #else -static int snd_pcm_resume(snd_pcm_substream_t *substream) +static int snd_pcm_resume(struct snd_pcm_substream *substream) { return -ENOSYS; } @@ -1160,10 +1181,10 @@ static int snd_pcm_resume(snd_pcm_substream_t *substream) * * Change the RUNNING stream(s) to XRUN state. */ -static int snd_pcm_xrun(snd_pcm_substream_t *substream) +static int snd_pcm_xrun(struct snd_pcm_substream *substream) { - snd_card_t *card = substream->pcm->card; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_card *card = substream->pcm->card; + struct snd_pcm_runtime *runtime = substream->runtime; int result; snd_power_lock(card); @@ -1193,9 +1214,9 @@ static int snd_pcm_xrun(snd_pcm_substream_t *substream) /* * reset ioctl */ -static int snd_pcm_pre_reset(snd_pcm_substream_t * substream, int state) +static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; switch (runtime->status->state) { case SNDRV_PCM_STATE_RUNNING: case SNDRV_PCM_STATE_PREPARED: @@ -1207,23 +1228,24 @@ static int snd_pcm_pre_reset(snd_pcm_substream_t * substream, int state) } } -static int snd_pcm_do_reset(snd_pcm_substream_t * substream, int state) +static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); if (err < 0) return err; // snd_assert(runtime->status->hw_ptr < runtime->buffer_size, ); runtime->hw_ptr_base = 0; - runtime->hw_ptr_interrupt = runtime->status->hw_ptr - runtime->status->hw_ptr % runtime->period_size; + runtime->hw_ptr_interrupt = runtime->status->hw_ptr - + runtime->status->hw_ptr % runtime->period_size; runtime->silence_start = runtime->status->hw_ptr; runtime->silence_filled = 0; return 0; } -static void snd_pcm_post_reset(snd_pcm_substream_t * substream, int state) +static void snd_pcm_post_reset(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; runtime->control->appl_ptr = runtime->status->hw_ptr; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && runtime->silence_size > 0) @@ -1236,7 +1258,7 @@ static struct action_ops snd_pcm_action_reset = { .post_action = snd_pcm_post_reset }; -static int snd_pcm_reset(snd_pcm_substream_t *substream) +static int snd_pcm_reset(struct snd_pcm_substream *substream) { return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, 0); } @@ -1244,9 +1266,9 @@ static int snd_pcm_reset(snd_pcm_substream_t *substream) /* * prepare ioctl */ -static int snd_pcm_pre_prepare(snd_pcm_substream_t * substream, int state) +static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->status->state == SNDRV_PCM_STATE_OPEN) return -EBADFD; if (snd_pcm_running(substream)) @@ -1254,7 +1276,7 @@ static int snd_pcm_pre_prepare(snd_pcm_substream_t * substream, int state) return 0; } -static int snd_pcm_do_prepare(snd_pcm_substream_t * substream, int state) +static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, int state) { int err; err = substream->ops->prepare(substream); @@ -1263,9 +1285,9 @@ static int snd_pcm_do_prepare(snd_pcm_substream_t * substream, int state) return snd_pcm_do_reset(substream, 0); } -static void snd_pcm_post_prepare(snd_pcm_substream_t * substream, int state) +static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; runtime->control->appl_ptr = runtime->status->hw_ptr; runtime->status->state = SNDRV_PCM_STATE_PREPARED; } @@ -1282,10 +1304,10 @@ static struct action_ops snd_pcm_action_prepare = { * * Prepare the PCM substream to be triggerable. */ -int snd_pcm_prepare(snd_pcm_substream_t *substream) +int snd_pcm_prepare(struct snd_pcm_substream *substream) { int res; - snd_card_t *card = substream->pcm->card; + struct snd_card *card = substream->pcm->card; snd_power_lock(card); if ((res = snd_power_wait(card, SNDRV_CTL_POWER_D0, substream->ffile)) >= 0) @@ -1298,7 +1320,7 @@ int snd_pcm_prepare(snd_pcm_substream_t *substream) * drain ioctl */ -static int snd_pcm_pre_drain_init(snd_pcm_substream_t * substream, int state) +static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) { if (substream->ffile->f_flags & O_NONBLOCK) return -EAGAIN; @@ -1306,9 +1328,9 @@ static int snd_pcm_pre_drain_init(snd_pcm_substream_t * substream, int state) return 0; } -static int snd_pcm_do_drain_init(snd_pcm_substream_t * substream, int state) +static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { switch (runtime->status->state) { case SNDRV_PCM_STATE_PREPARED: @@ -1336,7 +1358,7 @@ static int snd_pcm_do_drain_init(snd_pcm_substream_t * substream, int state) return 0; } -static void snd_pcm_post_drain_init(snd_pcm_substream_t * substream, int state) +static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, int state) { } @@ -1347,12 +1369,12 @@ static struct action_ops snd_pcm_action_drain_init = { }; struct drain_rec { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; wait_queue_t wait; snd_pcm_uframes_t stop_threshold; }; -static int snd_pcm_drop(snd_pcm_substream_t *substream); +static int snd_pcm_drop(struct snd_pcm_substream *substream); /* * Drain the stream(s). @@ -1361,10 +1383,10 @@ static int snd_pcm_drop(snd_pcm_substream_t *substream); * After this call, all streams are supposed to be either SETUP or DRAINING * (capture only) state. */ -static int snd_pcm_drain(snd_pcm_substream_t *substream) +static int snd_pcm_drain(struct snd_pcm_substream *substream) { - snd_card_t *card; - snd_pcm_runtime_t *runtime; + struct snd_card *card; + struct snd_pcm_runtime *runtime; struct list_head *pos; int result = 0; int i, num_drecs; @@ -1401,7 +1423,7 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream) /* count only playback streams */ num_drecs = 0; snd_pcm_group_for_each(pos, substream) { - snd_pcm_substream_t *s = snd_pcm_group_substream_entry(pos); + struct snd_pcm_substream *s = snd_pcm_group_substream_entry(pos); runtime = s->runtime; if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { d = &drec[num_drecs++]; @@ -1487,10 +1509,10 @@ static int snd_pcm_drain(snd_pcm_substream_t *substream) * * Immediately put all linked substreams into SETUP state. */ -static int snd_pcm_drop(snd_pcm_substream_t *substream) +static int snd_pcm_drop(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime; - snd_card_t *card; + struct snd_pcm_runtime *runtime; + struct snd_card *card; int result = 0; snd_assert(substream != NULL, return -ENXIO); @@ -1548,12 +1570,12 @@ static struct file *snd_pcm_file_fd(int fd) /* * PCM link handling */ -static int snd_pcm_link(snd_pcm_substream_t *substream, int fd) +static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) { int res = 0; struct file *file; - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream1; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream1; file = snd_pcm_file_fd(fd); if (!file) @@ -1572,7 +1594,7 @@ static int snd_pcm_link(snd_pcm_substream_t *substream, int fd) goto _end; } if (!snd_pcm_stream_linked(substream)) { - substream->group = kmalloc(sizeof(snd_pcm_group_t), GFP_ATOMIC); + substream->group = kmalloc(sizeof(struct snd_pcm_group), GFP_ATOMIC); if (substream->group == NULL) { res = -ENOMEM; goto _end; @@ -1592,14 +1614,14 @@ static int snd_pcm_link(snd_pcm_substream_t *substream, int fd) return res; } -static void relink_to_local(snd_pcm_substream_t *substream) +static void relink_to_local(struct snd_pcm_substream *substream) { substream->group = &substream->self_group; INIT_LIST_HEAD(&substream->self_group.substreams); list_add_tail(&substream->link_list, &substream->self_group.substreams); } -static int snd_pcm_unlink(snd_pcm_substream_t *substream) +static int snd_pcm_unlink(struct snd_pcm_substream *substream) { struct list_head *pos; int res = 0; @@ -1629,51 +1651,51 @@ static int snd_pcm_unlink(snd_pcm_substream_t *substream) /* * hw configurator */ -static int snd_pcm_hw_rule_mul(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_mul(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t t; + struct snd_interval t; snd_interval_mul(hw_param_interval_c(params, rule->deps[0]), hw_param_interval_c(params, rule->deps[1]), &t); return snd_interval_refine(hw_param_interval(params, rule->var), &t); } -static int snd_pcm_hw_rule_div(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_div(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t t; + struct snd_interval t; snd_interval_div(hw_param_interval_c(params, rule->deps[0]), hw_param_interval_c(params, rule->deps[1]), &t); return snd_interval_refine(hw_param_interval(params, rule->var), &t); } -static int snd_pcm_hw_rule_muldivk(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_muldivk(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t t; + struct snd_interval t; snd_interval_muldivk(hw_param_interval_c(params, rule->deps[0]), hw_param_interval_c(params, rule->deps[1]), (unsigned long) rule->private, &t); return snd_interval_refine(hw_param_interval(params, rule->var), &t); } -static int snd_pcm_hw_rule_mulkdiv(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_mulkdiv(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t t; + struct snd_interval t; snd_interval_mulkdiv(hw_param_interval_c(params, rule->deps[0]), (unsigned long) rule->private, hw_param_interval_c(params, rule->deps[1]), &t); return snd_interval_refine(hw_param_interval(params, rule->var), &t); } -static int snd_pcm_hw_rule_format(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_format(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { unsigned int k; - snd_interval_t *i = hw_param_interval(params, rule->deps[0]); - snd_mask_t m; - snd_mask_t *mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + struct snd_interval *i = hw_param_interval(params, rule->deps[0]); + struct snd_mask m; + struct snd_mask *mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); snd_mask_any(&m); for (k = 0; k <= SNDRV_PCM_FORMAT_LAST; ++k) { int bits; @@ -1688,10 +1710,10 @@ static int snd_pcm_hw_rule_format(snd_pcm_hw_params_t *params, return snd_mask_refine(mask, &m); } -static int snd_pcm_hw_rule_sample_bits(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_sample_bits(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t t; + struct snd_interval t; unsigned int k; t.min = UINT_MAX; t.max = 0; @@ -1720,19 +1742,19 @@ static int snd_pcm_hw_rule_sample_bits(snd_pcm_hw_params_t *params, static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000 }; -static int snd_pcm_hw_rule_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_pcm_hardware_t *hw = rule->private; + struct snd_pcm_hardware *hw = rule->private; return snd_interval_list(hw_param_interval(params, rule->var), ARRAY_SIZE(rates), rates, hw->rates); } -static int snd_pcm_hw_rule_buffer_bytes_max(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t t; - snd_pcm_substream_t *substream = rule->private; + struct snd_interval t; + struct snd_pcm_substream *substream = rule->private; t.min = 0; t.max = substream->buffer_bytes_max; t.openmin = 0; @@ -1741,10 +1763,10 @@ static int snd_pcm_hw_rule_buffer_bytes_max(snd_pcm_hw_params_t *params, return snd_interval_refine(hw_param_interval(params, rule->var), &t); } -int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream) +int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_pcm_hw_constraints_t *constrs = &runtime->hw_constraints; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; int k, err; for (k = SNDRV_PCM_HW_PARAM_FIRST_MASK; k <= SNDRV_PCM_HW_PARAM_LAST_MASK; k++) { @@ -1865,10 +1887,10 @@ int snd_pcm_hw_constraints_init(snd_pcm_substream_t *substream) return 0; } -int snd_pcm_hw_constraints_complete(snd_pcm_substream_t *substream) +int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_pcm_hardware_t *hw = &runtime->hw; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_pcm_hardware *hw = &runtime->hw; int err; unsigned int mask = 0; @@ -1941,17 +1963,17 @@ int snd_pcm_hw_constraints_complete(snd_pcm_substream_t *substream) return 0; } -static void snd_pcm_add_file(snd_pcm_str_t *str, - snd_pcm_file_t *pcm_file) +static void snd_pcm_add_file(struct snd_pcm_str *str, + struct snd_pcm_file *pcm_file) { pcm_file->next = str->files; str->files = pcm_file; } -static void snd_pcm_remove_file(snd_pcm_str_t *str, - snd_pcm_file_t *pcm_file) +static void snd_pcm_remove_file(struct snd_pcm_str *str, + struct snd_pcm_file *pcm_file) { - snd_pcm_file_t * pcm_file1; + struct snd_pcm_file * pcm_file1; if (str->files == pcm_file) { str->files = pcm_file->next; } else { @@ -1963,11 +1985,11 @@ static void snd_pcm_remove_file(snd_pcm_str_t *str, } } -static int snd_pcm_release_file(snd_pcm_file_t * pcm_file) +static int snd_pcm_release_file(struct snd_pcm_file * pcm_file) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; - snd_pcm_str_t * str; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; + struct snd_pcm_str * str; snd_assert(pcm_file != NULL, return -ENXIO); substream = pcm_file->substream; @@ -1988,14 +2010,14 @@ static int snd_pcm_release_file(snd_pcm_file_t * pcm_file) } static int snd_pcm_open_file(struct file *file, - snd_pcm_t *pcm, + struct snd_pcm *pcm, int stream, - snd_pcm_file_t **rpcm_file) + struct snd_pcm_file **rpcm_file) { int err = 0; - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream; - snd_pcm_str_t *str; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream; + struct snd_pcm_str *str; snd_assert(rpcm_file != NULL, return -EINVAL); *rpcm_file = NULL; @@ -2048,8 +2070,8 @@ static int snd_pcm_open(struct inode *inode, struct file *file) int cardnum = SNDRV_MINOR_CARD(iminor(inode)); int device = SNDRV_MINOR_DEVICE(iminor(inode)); int err; - snd_pcm_t *pcm; - snd_pcm_file_t *pcm_file; + struct snd_pcm *pcm; + struct snd_pcm_file *pcm_file; wait_queue_t wait; if (device < SNDRV_MINOR_PCM_PLAYBACK || device >= SNDRV_MINOR_DEVICES) @@ -2105,9 +2127,9 @@ static int snd_pcm_open(struct inode *inode, struct file *file) static int snd_pcm_release(struct inode *inode, struct file *file) { - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; - snd_pcm_file_t *pcm_file; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; + struct snd_pcm_file *pcm_file; pcm_file = file->private_data; substream = pcm_file->substream; @@ -2125,9 +2147,10 @@ static int snd_pcm_release(struct inode *inode, struct file *file) return 0; } -static snd_pcm_sframes_t snd_pcm_playback_rewind(snd_pcm_substream_t *substream, snd_pcm_uframes_t frames) +static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *substream, + snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t appl_ptr; snd_pcm_sframes_t ret; snd_pcm_sframes_t hw_avail; @@ -2174,9 +2197,10 @@ static snd_pcm_sframes_t snd_pcm_playback_rewind(snd_pcm_substream_t *substream, return ret; } -static snd_pcm_sframes_t snd_pcm_capture_rewind(snd_pcm_substream_t *substream, snd_pcm_uframes_t frames) +static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substream, + snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t appl_ptr; snd_pcm_sframes_t ret; snd_pcm_sframes_t hw_avail; @@ -2223,9 +2247,10 @@ static snd_pcm_sframes_t snd_pcm_capture_rewind(snd_pcm_substream_t *substream, return ret; } -static snd_pcm_sframes_t snd_pcm_playback_forward(snd_pcm_substream_t *substream, snd_pcm_uframes_t frames) +static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *substream, + snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t appl_ptr; snd_pcm_sframes_t ret; snd_pcm_sframes_t avail; @@ -2273,9 +2298,10 @@ static snd_pcm_sframes_t snd_pcm_playback_forward(snd_pcm_substream_t *substream return ret; } -static snd_pcm_sframes_t snd_pcm_capture_forward(snd_pcm_substream_t *substream, snd_pcm_uframes_t frames) +static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *substream, + snd_pcm_uframes_t frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t appl_ptr; snd_pcm_sframes_t ret; snd_pcm_sframes_t avail; @@ -2323,9 +2349,9 @@ static snd_pcm_sframes_t snd_pcm_capture_forward(snd_pcm_substream_t *substream, return ret; } -static int snd_pcm_hwsync(snd_pcm_substream_t *substream) +static int snd_pcm_hwsync(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; snd_pcm_stream_lock_irq(substream); @@ -2353,9 +2379,10 @@ static int snd_pcm_hwsync(snd_pcm_substream_t *substream) return err; } -static int snd_pcm_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t __user *res) +static int snd_pcm_delay(struct snd_pcm_substream *substream, + snd_pcm_sframes_t __user *res) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; snd_pcm_sframes_t n = 0; @@ -2391,18 +2418,19 @@ static int snd_pcm_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t __use return err; } -static int snd_pcm_sync_ptr(snd_pcm_substream_t *substream, struct sndrv_pcm_sync_ptr __user *_sync_ptr) +static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, + struct snd_pcm_sync_ptr __user *_sync_ptr) { - snd_pcm_runtime_t *runtime = substream->runtime; - struct sndrv_pcm_sync_ptr sync_ptr; - volatile struct sndrv_pcm_mmap_status *status; - volatile struct sndrv_pcm_mmap_control *control; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_pcm_sync_ptr sync_ptr; + volatile struct snd_pcm_mmap_status *status; + volatile struct snd_pcm_mmap_control *control; int err; memset(&sync_ptr, 0, sizeof(sync_ptr)); if (get_user(sync_ptr.flags, (unsigned __user *)&(_sync_ptr->flags))) return -EFAULT; - if (copy_from_user(&sync_ptr.c.control, &(_sync_ptr->c.control), sizeof(struct sndrv_pcm_mmap_control))) + if (copy_from_user(&sync_ptr.c.control, &(_sync_ptr->c.control), sizeof(struct snd_pcm_mmap_control))) return -EFAULT; status = runtime->status; control = runtime->control; @@ -2430,12 +2458,12 @@ static int snd_pcm_sync_ptr(snd_pcm_substream_t *substream, struct sndrv_pcm_syn return 0; } -static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, +static int snd_pcm_playback_ioctl1(struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg); -static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, +static int snd_pcm_capture_ioctl1(struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg); -static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream, +static int snd_pcm_common_ioctl1(struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { snd_assert(substream != NULL, return -ENXIO); @@ -2492,7 +2520,7 @@ static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream, return -ENOTTY; } -static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, +static int snd_pcm_playback_ioctl1(struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { snd_assert(substream != NULL, return -ENXIO); @@ -2500,9 +2528,9 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, switch (cmd) { case SNDRV_PCM_IOCTL_WRITEI_FRAMES: { - snd_xferi_t xferi; - snd_xferi_t __user *_xferi = arg; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_xferi xferi; + struct snd_xferi __user *_xferi = arg; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t result; if (runtime->status->state == SNDRV_PCM_STATE_OPEN) return -EBADFD; @@ -2516,9 +2544,9 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, } case SNDRV_PCM_IOCTL_WRITEN_FRAMES: { - snd_xfern_t xfern; - snd_xfern_t __user *_xfern = arg; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_xfern xfern; + struct snd_xfern __user *_xfern = arg; + struct snd_pcm_runtime *runtime = substream->runtime; void __user **bufs; snd_pcm_sframes_t result; if (runtime->status->state == SNDRV_PCM_STATE_OPEN) @@ -2579,7 +2607,7 @@ static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream, return snd_pcm_common_ioctl1(substream, cmd, arg); } -static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, +static int snd_pcm_capture_ioctl1(struct snd_pcm_substream *substream, unsigned int cmd, void __user *arg) { snd_assert(substream != NULL, return -ENXIO); @@ -2587,9 +2615,9 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, switch (cmd) { case SNDRV_PCM_IOCTL_READI_FRAMES: { - snd_xferi_t xferi; - snd_xferi_t __user *_xferi = arg; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_xferi xferi; + struct snd_xferi __user *_xferi = arg; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t result; if (runtime->status->state == SNDRV_PCM_STATE_OPEN) return -EBADFD; @@ -2603,9 +2631,9 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, } case SNDRV_PCM_IOCTL_READN_FRAMES: { - snd_xfern_t xfern; - snd_xfern_t __user *_xfern = arg; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_xfern xfern; + struct snd_xfern __user *_xfern = arg; + struct snd_pcm_runtime *runtime = substream->runtime; void *bufs; snd_pcm_sframes_t result; if (runtime->status->state == SNDRV_PCM_STATE_OPEN) @@ -2658,9 +2686,10 @@ static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream, return snd_pcm_common_ioctl1(substream, cmd, arg); } -static long snd_pcm_playback_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +static long snd_pcm_playback_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) { - snd_pcm_file_t *pcm_file; + struct snd_pcm_file *pcm_file; pcm_file = file->private_data; @@ -2670,9 +2699,10 @@ static long snd_pcm_playback_ioctl(struct file *file, unsigned int cmd, unsigned return snd_pcm_playback_ioctl1(pcm_file->substream, cmd, (void __user *)arg); } -static long snd_pcm_capture_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +static long snd_pcm_capture_ioctl(struct file *file, unsigned int cmd, + unsigned long arg) { - snd_pcm_file_t *pcm_file; + struct snd_pcm_file *pcm_file; pcm_file = file->private_data; @@ -2682,7 +2712,7 @@ static long snd_pcm_capture_ioctl(struct file *file, unsigned int cmd, unsigned return snd_pcm_capture_ioctl1(pcm_file->substream, cmd, (void __user *)arg); } -int snd_pcm_kernel_playback_ioctl(snd_pcm_substream_t *substream, +int snd_pcm_kernel_playback_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { mm_segment_t fs; @@ -2694,7 +2724,7 @@ int snd_pcm_kernel_playback_ioctl(snd_pcm_substream_t *substream, return result; } -int snd_pcm_kernel_capture_ioctl(snd_pcm_substream_t *substream, +int snd_pcm_kernel_capture_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { mm_segment_t fs; @@ -2706,7 +2736,7 @@ int snd_pcm_kernel_capture_ioctl(snd_pcm_substream_t *substream, return result; } -int snd_pcm_kernel_ioctl(snd_pcm_substream_t *substream, +int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { switch (substream->stream) { @@ -2719,11 +2749,12 @@ int snd_pcm_kernel_ioctl(snd_pcm_substream_t *substream, } } -static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count, loff_t * offset) +static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count, + loff_t * offset) { - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; pcm_file = file->private_data; @@ -2741,11 +2772,12 @@ static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count, l return result; } -static ssize_t snd_pcm_write(struct file *file, const char __user *buf, size_t count, loff_t * offset) +static ssize_t snd_pcm_write(struct file *file, const char __user *buf, + size_t count, loff_t * offset) { - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; pcm_file = file->private_data; @@ -2772,9 +2804,9 @@ static ssize_t snd_pcm_readv(struct file *file, const struct iovec *_vector, unsigned long count, loff_t * offset) { - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; unsigned long i; void __user **bufs; @@ -2806,9 +2838,9 @@ static ssize_t snd_pcm_readv(struct file *file, const struct iovec *_vector, static ssize_t snd_pcm_writev(struct file *file, const struct iovec *_vector, unsigned long count, loff_t * offset) { - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_pcm_sframes_t result; unsigned long i; void __user **bufs; @@ -2843,9 +2875,9 @@ static ssize_t snd_pcm_writev(struct file *file, const struct iovec *_vector, static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) { - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; unsigned int mask; snd_pcm_uframes_t avail; @@ -2881,9 +2913,9 @@ static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) static unsigned int snd_pcm_capture_poll(struct file *file, poll_table * wait) { - snd_pcm_file_t *pcm_file; - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_file *pcm_file; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; unsigned int mask; snd_pcm_uframes_t avail; @@ -2933,10 +2965,11 @@ static unsigned int snd_pcm_capture_poll(struct file *file, poll_table * wait) /* * mmap status record */ -static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area, unsigned long address, int *type) +static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area, + unsigned long address, int *type) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream = area->vm_private_data; + struct snd_pcm_runtime *runtime; struct page * page; if (substream == NULL) @@ -2954,17 +2987,17 @@ static struct vm_operations_struct snd_pcm_vm_ops_status = .nopage = snd_pcm_mmap_status_nopage, }; -static int snd_pcm_mmap_status(snd_pcm_substream_t *substream, struct file *file, +static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; long size; if (!(area->vm_flags & VM_READ)) return -EINVAL; runtime = substream->runtime; snd_assert(runtime != NULL, return -EAGAIN); size = area->vm_end - area->vm_start; - if (size != PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t))) + if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_status; area->vm_private_data = substream; @@ -2975,10 +3008,11 @@ static int snd_pcm_mmap_status(snd_pcm_substream_t *substream, struct file *file /* * mmap control record */ -static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area, unsigned long address, int *type) +static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area, + unsigned long address, int *type) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream = area->vm_private_data; + struct snd_pcm_runtime *runtime; struct page * page; if (substream == NULL) @@ -2996,17 +3030,17 @@ static struct vm_operations_struct snd_pcm_vm_ops_control = .nopage = snd_pcm_mmap_control_nopage, }; -static int snd_pcm_mmap_control(snd_pcm_substream_t *substream, struct file *file, +static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; long size; if (!(area->vm_flags & VM_READ)) return -EINVAL; runtime = substream->runtime; snd_assert(runtime != NULL, return -EAGAIN); size = area->vm_end - area->vm_start; - if (size != PAGE_ALIGN(sizeof(snd_pcm_mmap_control_t))) + if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) return -EINVAL; area->vm_ops = &snd_pcm_vm_ops_control; area->vm_private_data = substream; @@ -3017,12 +3051,12 @@ static int snd_pcm_mmap_control(snd_pcm_substream_t *substream, struct file *fil /* * don't support mmap for status and control records. */ -static int snd_pcm_mmap_status(snd_pcm_substream_t *substream, struct file *file, +static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { return -ENXIO; } -static int snd_pcm_mmap_control(snd_pcm_substream_t *substream, struct file *file, +static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { return -ENXIO; @@ -3032,10 +3066,11 @@ static int snd_pcm_mmap_control(snd_pcm_substream_t *substream, struct file *fil /* * nopage callback for mmapping a RAM page */ -static struct page *snd_pcm_mmap_data_nopage(struct vm_area_struct *area, unsigned long address, int *type) +static struct page *snd_pcm_mmap_data_nopage(struct vm_area_struct *area, + unsigned long address, int *type) { - snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream = area->vm_private_data; + struct snd_pcm_runtime *runtime; unsigned long offset; struct page * page; void *vaddr; @@ -3074,7 +3109,8 @@ static struct vm_operations_struct snd_pcm_vm_ops_data = /* * mmap the DMA buffer on RAM */ -static int snd_pcm_default_mmap(snd_pcm_substream_t *substream, struct vm_area_struct *area) +static int snd_pcm_default_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *area) { area->vm_ops = &snd_pcm_vm_ops_data; area->vm_private_data = substream; @@ -3093,7 +3129,8 @@ static struct vm_operations_struct snd_pcm_vm_ops_data_mmio = .close = snd_pcm_mmap_data_close, }; -int snd_pcm_lib_mmap_iomem(snd_pcm_substream_t *substream, struct vm_area_struct *area) +int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, + struct vm_area_struct *area) { long size; unsigned long offset; @@ -3118,10 +3155,10 @@ int snd_pcm_lib_mmap_iomem(snd_pcm_substream_t *substream, struct vm_area_struct /* * mmap DMA buffer */ -int snd_pcm_mmap_data(snd_pcm_substream_t *substream, struct file *file, +int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, struct vm_area_struct *area) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; long size; unsigned long offset; size_t dma_bytes; @@ -3158,8 +3195,8 @@ int snd_pcm_mmap_data(snd_pcm_substream_t *substream, struct file *file, static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area) { - snd_pcm_file_t * pcm_file; - snd_pcm_substream_t *substream; + struct snd_pcm_file * pcm_file; + struct snd_pcm_substream *substream; unsigned long offset; pcm_file = file->private_data; @@ -3184,9 +3221,9 @@ static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area) static int snd_pcm_fasync(int fd, struct file * file, int on) { - snd_pcm_file_t * pcm_file; - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_file * pcm_file; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; int err; pcm_file = file->private_data; @@ -3216,7 +3253,8 @@ static int snd_pcm_fasync(int fd, struct file * file, int on) #define __OLD_TO_NEW_MASK(x) ((x&7)|((x&0x07fffff8)<<5)) #define __NEW_TO_OLD_MASK(x) ((x&7)|((x&0xffffff00)>>5)) -static void snd_pcm_hw_convert_from_old_params(snd_pcm_hw_params_t *params, struct sndrv_pcm_hw_params_old *oparams) +static void snd_pcm_hw_convert_from_old_params(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_params_old *oparams) { unsigned int i; @@ -3234,7 +3272,8 @@ static void snd_pcm_hw_convert_from_old_params(snd_pcm_hw_params_t *params, stru params->fifo_size = oparams->fifo_size; } -static void snd_pcm_hw_convert_to_old_params(struct sndrv_pcm_hw_params_old *oparams, snd_pcm_hw_params_t *params) +static void snd_pcm_hw_convert_to_old_params(struct snd_pcm_hw_params_old *oparams, + struct snd_pcm_hw_params *params) { unsigned int i; @@ -3252,10 +3291,11 @@ static void snd_pcm_hw_convert_to_old_params(struct sndrv_pcm_hw_params_old *opa oparams->fifo_size = params->fifo_size; } -static int snd_pcm_hw_refine_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old __user * _oparams) +static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params_old __user * _oparams) { - snd_pcm_hw_params_t *params; - struct sndrv_pcm_hw_params_old *oparams = NULL; + struct snd_pcm_hw_params *params; + struct snd_pcm_hw_params_old *oparams = NULL; int err; params = kmalloc(sizeof(*params), GFP_KERNEL); @@ -3286,10 +3326,11 @@ out: return err; } -static int snd_pcm_hw_params_old_user(snd_pcm_substream_t * substream, struct sndrv_pcm_hw_params_old __user * _oparams) +static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params_old __user * _oparams) { - snd_pcm_hw_params_t *params; - struct sndrv_pcm_hw_params_old *oparams = NULL; + struct snd_pcm_hw_params *params; + struct snd_pcm_hw_params_old *oparams = NULL; int err; params = kmalloc(sizeof(*params), GFP_KERNEL); @@ -3349,7 +3390,7 @@ static struct file_operations snd_pcm_f_ops_capture = { .fasync = snd_pcm_fasync, }; -snd_minor_t snd_pcm_reg[2] = +struct snd_minor snd_pcm_reg[2] = { { .comment = "digital audio playback", diff --git a/sound/core/pcm_timer.c b/sound/core/pcm_timer.c index 884eaea..d94ed16 100644 --- a/sound/core/pcm_timer.c +++ b/sound/core/pcm_timer.c @@ -45,10 +45,10 @@ static unsigned long gcd(unsigned long a, unsigned long b) return b; } -void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream) +void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream) { unsigned long rate, mult, fsize, l, post; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; mult = 1000000000; rate = runtime->rate; @@ -74,18 +74,18 @@ void snd_pcm_timer_resolution_change(snd_pcm_substream_t *substream) runtime->timer_resolution = (mult * fsize / rate) * post; } -static unsigned long snd_pcm_timer_resolution(snd_timer_t * timer) +static unsigned long snd_pcm_timer_resolution(struct snd_timer * timer) { - snd_pcm_substream_t * substream; + struct snd_pcm_substream *substream; substream = timer->private_data; return substream->runtime ? substream->runtime->timer_resolution : 0; } -static int snd_pcm_timer_start(snd_timer_t * timer) +static int snd_pcm_timer_start(struct snd_timer * timer) { unsigned long flags; - snd_pcm_substream_t * substream; + struct snd_pcm_substream *substream; substream = snd_timer_chip(timer); spin_lock_irqsave(&substream->timer_lock, flags); @@ -94,10 +94,10 @@ static int snd_pcm_timer_start(snd_timer_t * timer) return 0; } -static int snd_pcm_timer_stop(snd_timer_t * timer) +static int snd_pcm_timer_stop(struct snd_timer * timer) { unsigned long flags; - snd_pcm_substream_t * substream; + struct snd_pcm_substream *substream; substream = snd_timer_chip(timer); spin_lock_irqsave(&substream->timer_lock, flags); @@ -106,7 +106,7 @@ static int snd_pcm_timer_stop(snd_timer_t * timer) return 0; } -static struct _snd_timer_hardware snd_pcm_timer = +static struct snd_timer_hardware snd_pcm_timer = { .flags = SNDRV_TIMER_HW_AUTO | SNDRV_TIMER_HW_SLAVE, .resolution = 0, @@ -120,16 +120,16 @@ static struct _snd_timer_hardware snd_pcm_timer = * Init functions */ -static void snd_pcm_timer_free(snd_timer_t *timer) +static void snd_pcm_timer_free(struct snd_timer *timer) { - snd_pcm_substream_t *substream = timer->private_data; + struct snd_pcm_substream *substream = timer->private_data; substream->timer = NULL; } -void snd_pcm_timer_init(snd_pcm_substream_t *substream) +void snd_pcm_timer_init(struct snd_pcm_substream *substream) { - snd_timer_id_t tid; - snd_timer_t *timer; + struct snd_timer_id tid; + struct snd_timer *timer; tid.dev_sclass = SNDRV_TIMER_SCLASS_NONE; tid.dev_class = SNDRV_TIMER_CLASS_PCM; @@ -152,7 +152,7 @@ void snd_pcm_timer_init(snd_pcm_substream_t *substream) substream->timer = timer; } -void snd_pcm_timer_done(snd_pcm_substream_t *substream) +void snd_pcm_timer_done(struct snd_pcm_substream *substream) { if (substream->timer) { snd_device_free(substream->pcm->card, substream->timer); -- cgit v1.1 From 174c1f65e5b81f616a5b5c8e41fc2b5eeb7a71af Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:00:19 +0100 Subject: [ALSA] Remove xxx_t typedefs: OSS-emulation Modules: ALSA Core Remove xxx_t typedefs from the core OSS-emulation codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/core/info_oss.c | 11 ++++++----- sound/core/sound_oss.c | 30 ++++++++++++++++-------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/sound/core/info_oss.c b/sound/core/info_oss.c index 1210796..820f477 100644 --- a/sound/core/info_oss.c +++ b/sound/core/info_oss.c @@ -37,7 +37,7 @@ static DECLARE_MUTEX(strings); static char *snd_sndstat_strings[SNDRV_CARDS][SNDRV_OSS_INFO_DEV_COUNT]; -static snd_info_entry_t *snd_sndstat_proc_entry; +static struct snd_info_entry *snd_sndstat_proc_entry; int snd_oss_info_register(int dev, int num, char *string) { @@ -63,9 +63,9 @@ int snd_oss_info_register(int dev, int num, char *string) return 0; } -extern void snd_card_info_read_oss(snd_info_buffer_t * buffer); +extern void snd_card_info_read_oss(struct snd_info_buffer *buffer); -static int snd_sndstat_show_strings(snd_info_buffer_t * buf, char *id, int dev) +static int snd_sndstat_show_strings(struct snd_info_buffer *buf, char *id, int dev) { int idx, ok = -1; char *str; @@ -88,7 +88,8 @@ static int snd_sndstat_show_strings(snd_info_buffer_t * buf, char *id, int dev) return ok; } -static void snd_sndstat_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_sndstat_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_iprintf(buffer, "Sound Driver:3.8.1a-980706 (ALSA v" CONFIG_SND_VERSION " emulation code)\n"); snd_iprintf(buffer, "Kernel: %s %s %s %s %s\n", @@ -111,7 +112,7 @@ static void snd_sndstat_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * b int snd_info_minor_register(void) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; memset(snd_sndstat_strings, 0, sizeof(snd_sndstat_strings)); if ((entry = snd_info_create_module_entry(THIS_MODULE, "sndstat", snd_oss_root)) != NULL) { diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index e401c67..ec37604 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -41,20 +41,20 @@ static struct list_head snd_oss_minors_hash[SNDRV_CARDS]; static DECLARE_MUTEX(sound_oss_mutex); -static snd_minor_t *snd_oss_minor_search(int minor) +static struct snd_minor *snd_oss_minor_search(int minor) { struct list_head *list; - snd_minor_t *mptr; + struct snd_minor *mptr; list_for_each(list, &snd_oss_minors_hash[SNDRV_MINOR_OSS_CARD(minor)]) { - mptr = list_entry(list, snd_minor_t, list); + mptr = list_entry(list, struct snd_minor, list); if (mptr->number == minor) return mptr; } return NULL; } -static int snd_oss_kernel_minor(int type, snd_card_t * card, int dev) +static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) { int minor; @@ -90,11 +90,12 @@ static int snd_oss_kernel_minor(int type, snd_card_t * card, int dev) return minor; } -int snd_register_oss_device(int type, snd_card_t * card, int dev, snd_minor_t * reg, const char *name) +int snd_register_oss_device(int type, struct snd_card *card, int dev, + struct snd_minor * reg, const char *name) { int minor = snd_oss_kernel_minor(type, card, dev); int minor_unit; - snd_minor_t *preg; + struct snd_minor *preg; int cidx = SNDRV_MINOR_OSS_CARD(minor); int track2 = -1; int register1 = -1, register2 = -1; @@ -102,7 +103,7 @@ int snd_register_oss_device(int type, snd_card_t * card, int dev, snd_minor_t * if (minor < 0) return minor; - preg = (snd_minor_t *)kmalloc(sizeof(snd_minor_t), GFP_KERNEL); + preg = (struct snd_minor *)kmalloc(sizeof(struct snd_minor), GFP_KERNEL); if (preg == NULL) return -ENOMEM; *preg = *reg; @@ -146,12 +147,12 @@ int snd_register_oss_device(int type, snd_card_t * card, int dev, snd_minor_t * return -EBUSY; } -int snd_unregister_oss_device(int type, snd_card_t * card, int dev) +int snd_unregister_oss_device(int type, struct snd_card *card, int dev) { int minor = snd_oss_kernel_minor(type, card, dev); int cidx = SNDRV_MINOR_OSS_CARD(minor); int track2 = -1; - snd_minor_t *mptr; + struct snd_minor *mptr; if (minor < 0) return minor; @@ -187,18 +188,19 @@ int snd_unregister_oss_device(int type, snd_card_t * card, int dev) #ifdef CONFIG_PROC_FS -static snd_info_entry_t *snd_minor_info_oss_entry = NULL; +static struct snd_info_entry *snd_minor_info_oss_entry = NULL; -static void snd_minor_info_oss_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_minor_info_oss_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int card, dev; struct list_head *list; - snd_minor_t *mptr; + struct snd_minor *mptr; down(&sound_oss_mutex); for (card = 0; card < SNDRV_CARDS; card++) { list_for_each(list, &snd_oss_minors_hash[card]) { - mptr = list_entry(list, snd_minor_t, list); + mptr = list_entry(list, struct snd_minor, list); dev = SNDRV_MINOR_OSS_DEVICE(mptr->number); if (dev != SNDRV_MINOR_OSS_SNDSTAT && dev != SNDRV_MINOR_OSS_SEQUENCER && @@ -216,7 +218,7 @@ static void snd_minor_info_oss_read(snd_info_entry_t *entry, snd_info_buffer_t * int __init snd_minor_info_oss_init(void) { #ifdef CONFIG_PROC_FS - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = snd_info_create_module_entry(THIS_MODULE, "devices", snd_oss_root); if (entry) { -- cgit v1.1 From f956b4a3ae790e1bdde865ac42dd1b99b64a6256 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:01:22 +0100 Subject: [ALSA] Remove xxx_t typedefs: Mixer OSS-emulation Modules: ALSA<-OSS emulation Remove xxx_t typedefs from the core mixer OSS-emulation codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/mixer_oss.h | 54 +++++----- sound/core/oss/mixer_oss.c | 240 ++++++++++++++++++++++----------------------- 2 files changed, 148 insertions(+), 146 deletions(-) diff --git a/include/sound/mixer_oss.h b/include/sound/mixer_oss.h index ed75b2f..ca5b482 100644 --- a/include/sound/mixer_oss.h +++ b/include/sound/mixer_oss.h @@ -24,51 +24,53 @@ #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) -typedef struct _snd_oss_mixer_slot snd_mixer_oss_slot_t; -typedef struct _snd_oss_file snd_mixer_oss_file_t; - -typedef int (*snd_mixer_oss_get_volume_t)(snd_mixer_oss_file_t *fmixer, snd_mixer_oss_slot_t *chn, int *left, int *right); -typedef int (*snd_mixer_oss_put_volume_t)(snd_mixer_oss_file_t *fmixer, snd_mixer_oss_slot_t *chn, int left, int right); -typedef int (*snd_mixer_oss_get_recsrc_t)(snd_mixer_oss_file_t *fmixer, snd_mixer_oss_slot_t *chn, int *active); -typedef int (*snd_mixer_oss_put_recsrc_t)(snd_mixer_oss_file_t *fmixer, snd_mixer_oss_slot_t *chn, int active); -typedef int (*snd_mixer_oss_get_recsrce_t)(snd_mixer_oss_file_t *fmixer, unsigned int *active_index); -typedef int (*snd_mixer_oss_put_recsrce_t)(snd_mixer_oss_file_t *fmixer, unsigned int active_index); - #define SNDRV_OSS_MAX_MIXERS 32 -struct _snd_oss_mixer_slot { +struct snd_mixer_oss_file; + +struct snd_mixer_oss_slot { int number; unsigned int stereo: 1; - snd_mixer_oss_get_volume_t get_volume; - snd_mixer_oss_put_volume_t put_volume; - snd_mixer_oss_get_recsrc_t get_recsrc; - snd_mixer_oss_put_recsrc_t put_recsrc; + int (*get_volume)(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *chn, + int *left, int *right); + int (*put_volume)(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *chn, + int left, int right); + int (*get_recsrc)(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *chn, + int *active); + int (*put_recsrc)(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *chn, + int active); unsigned long private_value; void *private_data; - void (*private_free)(snd_mixer_oss_slot_t *slot); + void (*private_free)(struct snd_mixer_oss_slot *slot); int volume[2]; }; -struct _snd_oss_mixer { - snd_card_t *card; +struct snd_mixer_oss { + struct snd_card *card; char id[16]; char name[32]; - snd_mixer_oss_slot_t slots[SNDRV_OSS_MAX_MIXERS]; /* OSS mixer slots */ + struct snd_mixer_oss_slot slots[SNDRV_OSS_MAX_MIXERS]; /* OSS mixer slots */ unsigned int mask_recsrc; /* exclusive recsrc mask */ - snd_mixer_oss_get_recsrce_t get_recsrc; - snd_mixer_oss_put_recsrce_t put_recsrc; + int (*get_recsrc)(struct snd_mixer_oss_file *fmixer, + unsigned int *active_index); + int (*put_recsrc)(struct snd_mixer_oss_file *fmixer, + unsigned int active_index); void *private_data_recsrc; - void (*private_free_recsrc)(snd_mixer_oss_t *mixer); + void (*private_free_recsrc)(struct snd_mixer_oss *mixer); struct semaphore reg_mutex; - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; int oss_dev_alloc; /* --- */ int oss_recsrc; }; -struct _snd_oss_file { - snd_card_t *card; - snd_mixer_oss_t *mixer; +struct snd_mixer_oss_file { + struct snd_card *card; + struct snd_mixer_oss *mixer; }; #endif /* CONFIG_SND_MIXER_OSS */ diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 214933c..e448002c 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -42,8 +42,8 @@ MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_MIXER); static int snd_mixer_oss_open(struct inode *inode, struct file *file) { int cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode)); - snd_card_t *card; - snd_mixer_oss_file_t *fmixer; + struct snd_card *card; + struct snd_mixer_oss_file *fmixer; int err; if ((card = snd_cards[cardnum]) == NULL) @@ -71,10 +71,10 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file) static int snd_mixer_oss_release(struct inode *inode, struct file *file) { - snd_mixer_oss_file_t *fmixer; + struct snd_mixer_oss_file *fmixer; if (file->private_data) { - fmixer = (snd_mixer_oss_file_t *) file->private_data; + fmixer = (struct snd_mixer_oss_file *) file->private_data; module_put(fmixer->card->module); snd_card_file_remove(fmixer->card, file); kfree(fmixer); @@ -82,11 +82,11 @@ static int snd_mixer_oss_release(struct inode *inode, struct file *file) return 0; } -static int snd_mixer_oss_info(snd_mixer_oss_file_t *fmixer, +static int snd_mixer_oss_info(struct snd_mixer_oss_file *fmixer, mixer_info __user *_info) { - snd_card_t *card = fmixer->card; - snd_mixer_oss_t *mixer = fmixer->mixer; + struct snd_card *card = fmixer->card; + struct snd_mixer_oss *mixer = fmixer->mixer; struct mixer_info info; memset(&info, 0, sizeof(info)); @@ -98,11 +98,11 @@ static int snd_mixer_oss_info(snd_mixer_oss_file_t *fmixer, return 0; } -static int snd_mixer_oss_info_obsolete(snd_mixer_oss_file_t *fmixer, +static int snd_mixer_oss_info_obsolete(struct snd_mixer_oss_file *fmixer, _old_mixer_info __user *_info) { - snd_card_t *card = fmixer->card; - snd_mixer_oss_t *mixer = fmixer->mixer; + struct snd_card *card = fmixer->card; + struct snd_mixer_oss *mixer = fmixer->mixer; _old_mixer_info info; memset(&info, 0, sizeof(info)); @@ -113,9 +113,9 @@ static int snd_mixer_oss_info_obsolete(snd_mixer_oss_file_t *fmixer, return 0; } -static int snd_mixer_oss_caps(snd_mixer_oss_file_t *fmixer) +static int snd_mixer_oss_caps(struct snd_mixer_oss_file *fmixer) { - snd_mixer_oss_t *mixer = fmixer->mixer; + struct snd_mixer_oss *mixer = fmixer->mixer; int result = 0; if (mixer == NULL) @@ -125,10 +125,10 @@ static int snd_mixer_oss_caps(snd_mixer_oss_file_t *fmixer) return result; } -static int snd_mixer_oss_devmask(snd_mixer_oss_file_t *fmixer) +static int snd_mixer_oss_devmask(struct snd_mixer_oss_file *fmixer) { - snd_mixer_oss_t *mixer = fmixer->mixer; - snd_mixer_oss_slot_t *pslot; + struct snd_mixer_oss *mixer = fmixer->mixer; + struct snd_mixer_oss_slot *pslot; int result = 0, chn; if (mixer == NULL) @@ -141,10 +141,10 @@ static int snd_mixer_oss_devmask(snd_mixer_oss_file_t *fmixer) return result; } -static int snd_mixer_oss_stereodevs(snd_mixer_oss_file_t *fmixer) +static int snd_mixer_oss_stereodevs(struct snd_mixer_oss_file *fmixer) { - snd_mixer_oss_t *mixer = fmixer->mixer; - snd_mixer_oss_slot_t *pslot; + struct snd_mixer_oss *mixer = fmixer->mixer; + struct snd_mixer_oss_slot *pslot; int result = 0, chn; if (mixer == NULL) @@ -157,9 +157,9 @@ static int snd_mixer_oss_stereodevs(snd_mixer_oss_file_t *fmixer) return result; } -static int snd_mixer_oss_recmask(snd_mixer_oss_file_t *fmixer) +static int snd_mixer_oss_recmask(struct snd_mixer_oss_file *fmixer) { - snd_mixer_oss_t *mixer = fmixer->mixer; + struct snd_mixer_oss *mixer = fmixer->mixer; int result = 0; if (mixer == NULL) @@ -167,7 +167,7 @@ static int snd_mixer_oss_recmask(snd_mixer_oss_file_t *fmixer) if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */ result = mixer->mask_recsrc; } else { - snd_mixer_oss_slot_t *pslot; + struct snd_mixer_oss_slot *pslot; int chn; for (chn = 0; chn < 31; chn++) { pslot = &mixer->slots[chn]; @@ -178,9 +178,9 @@ static int snd_mixer_oss_recmask(snd_mixer_oss_file_t *fmixer) return result; } -static int snd_mixer_oss_get_recsrc(snd_mixer_oss_file_t *fmixer) +static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer) { - snd_mixer_oss_t *mixer = fmixer->mixer; + struct snd_mixer_oss *mixer = fmixer->mixer; int result = 0; if (mixer == NULL) @@ -191,7 +191,7 @@ static int snd_mixer_oss_get_recsrc(snd_mixer_oss_file_t *fmixer) return err; result = 1 << result; } else { - snd_mixer_oss_slot_t *pslot; + struct snd_mixer_oss_slot *pslot; int chn; for (chn = 0; chn < 31; chn++) { pslot = &mixer->slots[chn]; @@ -206,10 +206,10 @@ static int snd_mixer_oss_get_recsrc(snd_mixer_oss_file_t *fmixer) return mixer->oss_recsrc = result; } -static int snd_mixer_oss_set_recsrc(snd_mixer_oss_file_t *fmixer, int recsrc) +static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsrc) { - snd_mixer_oss_t *mixer = fmixer->mixer; - snd_mixer_oss_slot_t *pslot; + struct snd_mixer_oss *mixer = fmixer->mixer; + struct snd_mixer_oss_slot *pslot; int chn, active; int result = 0; @@ -243,10 +243,10 @@ static int snd_mixer_oss_set_recsrc(snd_mixer_oss_file_t *fmixer, int recsrc) return result; } -static int snd_mixer_oss_get_volume(snd_mixer_oss_file_t *fmixer, int slot) +static int snd_mixer_oss_get_volume(struct snd_mixer_oss_file *fmixer, int slot) { - snd_mixer_oss_t *mixer = fmixer->mixer; - snd_mixer_oss_slot_t *pslot; + struct snd_mixer_oss *mixer = fmixer->mixer; + struct snd_mixer_oss_slot *pslot; int result = 0, left, right; if (mixer == NULL || slot > 30) @@ -268,11 +268,11 @@ static int snd_mixer_oss_get_volume(snd_mixer_oss_file_t *fmixer, int slot) return result; } -static int snd_mixer_oss_set_volume(snd_mixer_oss_file_t *fmixer, +static int snd_mixer_oss_set_volume(struct snd_mixer_oss_file *fmixer, int slot, int volume) { - snd_mixer_oss_t *mixer = fmixer->mixer; - snd_mixer_oss_slot_t *pslot; + struct snd_mixer_oss *mixer = fmixer->mixer; + struct snd_mixer_oss_slot *pslot; int result = 0, left = volume & 0xff, right = (volume >> 8) & 0xff; if (mixer == NULL || slot > 30) @@ -293,7 +293,7 @@ static int snd_mixer_oss_set_volume(snd_mixer_oss_file_t *fmixer, return (left & 0xff) | ((right & 0xff) << 8); } -static int snd_mixer_oss_ioctl1(snd_mixer_oss_file_t *fmixer, unsigned int cmd, unsigned long arg) +static int snd_mixer_oss_ioctl1(struct snd_mixer_oss_file *fmixer, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int __user *p = argp; @@ -362,12 +362,12 @@ static int snd_mixer_oss_ioctl1(snd_mixer_oss_file_t *fmixer, unsigned int cmd, static long snd_mixer_oss_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - return snd_mixer_oss_ioctl1((snd_mixer_oss_file_t *) file->private_data, cmd, arg); + return snd_mixer_oss_ioctl1((struct snd_mixer_oss_file *) file->private_data, cmd, arg); } -int snd_mixer_oss_ioctl_card(snd_card_t *card, unsigned int cmd, unsigned long arg) +int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg) { - snd_mixer_oss_file_t fmixer; + struct snd_mixer_oss_file fmixer; snd_assert(card != NULL, return -ENXIO); if (card->mixer_oss == NULL) @@ -398,7 +398,7 @@ static struct file_operations snd_mixer_oss_f_ops = .compat_ioctl = snd_mixer_oss_ioctl_compat, }; -static snd_minor_t snd_mixer_oss_reg = +static struct snd_minor snd_mixer_oss_reg = { .comment = "mixer", .f_ops = &snd_mixer_oss_f_ops, @@ -432,16 +432,16 @@ static long snd_mixer_oss_conv2(long val, long min, long max) } #if 0 -static void snd_mixer_oss_recsrce_set(snd_card_t *card, int slot) +static void snd_mixer_oss_recsrce_set(struct snd_card *card, int slot) { - snd_mixer_oss_t *mixer = card->mixer_oss; + struct snd_mixer_oss *mixer = card->mixer_oss; if (mixer) mixer->mask_recsrc |= 1 << slot; } -static int snd_mixer_oss_recsrce_get(snd_card_t *card, int slot) +static int snd_mixer_oss_recsrce_get(struct snd_card *card, int slot) { - snd_mixer_oss_t *mixer = card->mixer_oss; + struct snd_mixer_oss *mixer = card->mixer_oss; if (mixer && (mixer->mask_recsrc & (1 << slot))) return 1; return 0; @@ -488,10 +488,10 @@ struct slot { #define ID_UNKNOWN ((unsigned int)-1) -static snd_kcontrol_t *snd_mixer_oss_test_id(snd_mixer_oss_t *mixer, const char *name, int index) +static struct snd_kcontrol *snd_mixer_oss_test_id(struct snd_mixer_oss *mixer, const char *name, int index) { - snd_card_t * card = mixer->card; - snd_ctl_elem_id_t id; + struct snd_card *card = mixer->card; + struct snd_ctl_elem_id id; memset(&id, 0, sizeof(id)); id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; @@ -500,15 +500,15 @@ static snd_kcontrol_t *snd_mixer_oss_test_id(snd_mixer_oss_t *mixer, const char return snd_ctl_find_id(card, &id); } -static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static void snd_mixer_oss_get_volume1_vol(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, unsigned int numid, int *left, int *right) { - snd_ctl_elem_info_t *uinfo; - snd_ctl_elem_value_t *uctl; - snd_kcontrol_t *kctl; - snd_card_t *card = fmixer->card; + struct snd_ctl_elem_info *uinfo; + struct snd_ctl_elem_value *uctl; + struct snd_kcontrol *kctl; + struct snd_card *card = fmixer->card; if (numid == ID_UNKNOWN) return; @@ -537,16 +537,16 @@ static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer, kfree(uinfo); } -static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static void snd_mixer_oss_get_volume1_sw(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, unsigned int numid, int *left, int *right, int route) { - snd_ctl_elem_info_t *uinfo; - snd_ctl_elem_value_t *uctl; - snd_kcontrol_t *kctl; - snd_card_t *card = fmixer->card; + struct snd_ctl_elem_info *uinfo; + struct snd_ctl_elem_value *uctl; + struct snd_kcontrol *kctl; + struct snd_card *card = fmixer->card; if (numid == ID_UNKNOWN) return; @@ -576,8 +576,8 @@ static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer, kfree(uinfo); } -static int snd_mixer_oss_get_volume1(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static int snd_mixer_oss_get_volume1(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, int *left, int *right) { struct slot *slot = (struct slot *)pslot->private_data; @@ -602,15 +602,15 @@ static int snd_mixer_oss_get_volume1(snd_mixer_oss_file_t *fmixer, return 0; } -static void snd_mixer_oss_put_volume1_vol(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, unsigned int numid, int left, int right) { - snd_ctl_elem_info_t *uinfo; - snd_ctl_elem_value_t *uctl; - snd_kcontrol_t *kctl; - snd_card_t *card = fmixer->card; + struct snd_ctl_elem_info *uinfo; + struct snd_ctl_elem_value *uctl; + struct snd_kcontrol *kctl; + struct snd_card *card = fmixer->card; int res; if (numid == ID_UNKNOWN) @@ -640,16 +640,16 @@ static void snd_mixer_oss_put_volume1_vol(snd_mixer_oss_file_t *fmixer, kfree(uinfo); } -static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, unsigned int numid, int left, int right, int route) { - snd_ctl_elem_info_t *uinfo; - snd_ctl_elem_value_t *uctl; - snd_kcontrol_t *kctl; - snd_card_t *card = fmixer->card; + struct snd_ctl_elem_info *uinfo; + struct snd_ctl_elem_value *uctl; + struct snd_kcontrol *kctl; + struct snd_card *card = fmixer->card; int res; if (numid == ID_UNKNOWN) @@ -685,8 +685,8 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer, kfree(uinfo); } -static int snd_mixer_oss_put_volume1(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static int snd_mixer_oss_put_volume1(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, int left, int right) { struct slot *slot = (struct slot *)pslot->private_data; @@ -723,8 +723,8 @@ static int snd_mixer_oss_put_volume1(snd_mixer_oss_file_t *fmixer, return 0; } -static int snd_mixer_oss_get_recsrc1_sw(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static int snd_mixer_oss_get_recsrc1_sw(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, int *active) { struct slot *slot = (struct slot *)pslot->private_data; @@ -736,8 +736,8 @@ static int snd_mixer_oss_get_recsrc1_sw(snd_mixer_oss_file_t *fmixer, return 0; } -static int snd_mixer_oss_get_recsrc1_route(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static int snd_mixer_oss_get_recsrc1_route(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, int *active) { struct slot *slot = (struct slot *)pslot->private_data; @@ -749,8 +749,8 @@ static int snd_mixer_oss_get_recsrc1_route(snd_mixer_oss_file_t *fmixer, return 0; } -static int snd_mixer_oss_put_recsrc1_sw(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static int snd_mixer_oss_put_recsrc1_sw(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, int active) { struct slot *slot = (struct slot *)pslot->private_data; @@ -759,8 +759,8 @@ static int snd_mixer_oss_put_recsrc1_sw(snd_mixer_oss_file_t *fmixer, return 0; } -static int snd_mixer_oss_put_recsrc1_route(snd_mixer_oss_file_t *fmixer, - snd_mixer_oss_slot_t *pslot, +static int snd_mixer_oss_put_recsrc1_route(struct snd_mixer_oss_file *fmixer, + struct snd_mixer_oss_slot *pslot, int active) { struct slot *slot = (struct slot *)pslot->private_data; @@ -769,15 +769,15 @@ static int snd_mixer_oss_put_recsrc1_route(snd_mixer_oss_file_t *fmixer, return 0; } -static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int *active_index) +static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned int *active_index) { - snd_card_t *card = fmixer->card; - snd_mixer_oss_t *mixer = fmixer->mixer; - snd_kcontrol_t *kctl; - snd_mixer_oss_slot_t *pslot; + struct snd_card *card = fmixer->card; + struct snd_mixer_oss *mixer = fmixer->mixer; + struct snd_kcontrol *kctl; + struct snd_mixer_oss_slot *pslot; struct slot *slot; - snd_ctl_elem_info_t *uinfo; - snd_ctl_elem_value_t *uctl; + struct snd_ctl_elem_info *uinfo; + struct snd_ctl_elem_value *uctl; int err, idx; uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); @@ -818,15 +818,15 @@ static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int return err; } -static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int active_index) +static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned int active_index) { - snd_card_t *card = fmixer->card; - snd_mixer_oss_t *mixer = fmixer->mixer; - snd_kcontrol_t *kctl; - snd_mixer_oss_slot_t *pslot; + struct snd_card *card = fmixer->card; + struct snd_mixer_oss *mixer = fmixer->mixer; + struct snd_kcontrol *kctl; + struct snd_mixer_oss_slot *pslot; struct slot *slot = NULL; - snd_ctl_elem_info_t *uinfo; - snd_ctl_elem_value_t *uctl; + struct snd_ctl_elem_info *uinfo; + struct snd_ctl_elem_value *uctl; int err; unsigned int idx; @@ -878,11 +878,11 @@ struct snd_mixer_oss_assign_table { int index; }; -static int snd_mixer_oss_build_test(snd_mixer_oss_t *mixer, struct slot *slot, const char *name, int index, int item) +static int snd_mixer_oss_build_test(struct snd_mixer_oss *mixer, struct slot *slot, const char *name, int index, int item) { - snd_ctl_elem_info_t *info; - snd_kcontrol_t *kcontrol; - snd_card_t *card = mixer->card; + struct snd_ctl_elem_info *info; + struct snd_kcontrol *kcontrol; + struct snd_card *card = mixer->card; int err; down_read(&card->controls_rwsem); @@ -910,7 +910,7 @@ static int snd_mixer_oss_build_test(snd_mixer_oss_t *mixer, struct slot *slot, c return 0; } -static void snd_mixer_oss_slot_free(snd_mixer_oss_slot_t *chn) +static void snd_mixer_oss_slot_free(struct snd_mixer_oss_slot *chn) { struct slot *p = (struct slot *)chn->private_data; if (p) { @@ -922,7 +922,7 @@ static void snd_mixer_oss_slot_free(snd_mixer_oss_slot_t *chn) } } -static void mixer_slot_clear(snd_mixer_oss_slot_t *rslot) +static void mixer_slot_clear(struct snd_mixer_oss_slot *rslot) { int idx = rslot->number; /* remember this */ if (rslot->private_free) @@ -936,12 +936,12 @@ static void mixer_slot_clear(snd_mixer_oss_slot_t *rslot) * ptr_allocated means the entry is dynamically allocated (change via proc file). * when replace_old = 1, the old entry is replaced with the new one. */ -static int snd_mixer_oss_build_input(snd_mixer_oss_t *mixer, struct snd_mixer_oss_assign_table *ptr, int ptr_allocated, int replace_old) +static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mixer_oss_assign_table *ptr, int ptr_allocated, int replace_old) { struct slot slot; struct slot *pslot; - snd_kcontrol_t *kctl; - snd_mixer_oss_slot_t *rslot; + struct snd_kcontrol *kctl; + struct snd_mixer_oss_slot *rslot; char str[64]; /* check if already assigned */ @@ -991,7 +991,7 @@ static int snd_mixer_oss_build_input(snd_mixer_oss_t *mixer, struct snd_mixer_os return 0; down_read(&mixer->card->controls_rwsem); if (ptr->index == 0 && (kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0)) != NULL) { - snd_ctl_elem_info_t *uinfo; + struct snd_ctl_elem_info *uinfo; uinfo = kmalloc(sizeof(*uinfo), GFP_KERNEL); if (! uinfo) { @@ -1093,10 +1093,10 @@ static char *oss_mixer_names[SNDRV_OSS_MAX_MIXERS] = { * /proc interface */ -static void snd_mixer_oss_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_mixer_oss_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_mixer_oss_t *mixer = entry->private_data; + struct snd_mixer_oss *mixer = entry->private_data; int i; down(&mixer->reg_mutex); @@ -1117,10 +1117,10 @@ static void snd_mixer_oss_proc_read(snd_info_entry_t *entry, up(&mixer->reg_mutex); } -static void snd_mixer_oss_proc_write(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_mixer_oss_proc_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_mixer_oss_t *mixer = entry->private_data; + struct snd_mixer_oss *mixer = entry->private_data; char line[128], str[32], idxstr[16], *cptr; int ch, idx; struct snd_mixer_oss_assign_table *tbl; @@ -1176,9 +1176,9 @@ static void snd_mixer_oss_proc_write(snd_info_entry_t *entry, } } -static void snd_mixer_oss_proc_init(snd_mixer_oss_t *mixer) +static void snd_mixer_oss_proc_init(struct snd_mixer_oss *mixer) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = snd_info_create_card_entry(mixer->card, "oss_mixer", mixer->card->proc_root); @@ -1198,7 +1198,7 @@ static void snd_mixer_oss_proc_init(snd_mixer_oss_t *mixer) mixer->proc_entry = entry; } -static void snd_mixer_oss_proc_done(snd_mixer_oss_t *mixer) +static void snd_mixer_oss_proc_done(struct snd_mixer_oss *mixer) { if (mixer->proc_entry) { snd_info_unregister(mixer->proc_entry); @@ -1206,7 +1206,7 @@ static void snd_mixer_oss_proc_done(snd_mixer_oss_t *mixer) } } -static void snd_mixer_oss_build(snd_mixer_oss_t *mixer) +static void snd_mixer_oss_build(struct snd_mixer_oss *mixer) { static struct snd_mixer_oss_assign_table table[] = { { SOUND_MIXER_VOLUME, "Master", 0 }, @@ -1260,8 +1260,8 @@ static void snd_mixer_oss_build(snd_mixer_oss_t *mixer) static int snd_mixer_oss_free1(void *private) { - snd_mixer_oss_t *mixer = private; - snd_card_t * card; + struct snd_mixer_oss *mixer = private; + struct snd_card *card; int idx; snd_assert(mixer != NULL, return -ENXIO); @@ -1269,7 +1269,7 @@ static int snd_mixer_oss_free1(void *private) snd_assert(mixer == card->mixer_oss, return -ENXIO); card->mixer_oss = NULL; for (idx = 0; idx < SNDRV_OSS_MAX_MIXERS; idx++) { - snd_mixer_oss_slot_t *chn = &mixer->slots[idx]; + struct snd_mixer_oss_slot *chn = &mixer->slots[idx]; if (chn->private_free) chn->private_free(chn); } @@ -1277,9 +1277,9 @@ static int snd_mixer_oss_free1(void *private) return 0; } -static int snd_mixer_oss_notify_handler(snd_card_t * card, int cmd) +static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) { - snd_mixer_oss_t *mixer; + struct snd_mixer_oss *mixer; if (cmd == SND_MIXER_OSS_NOTIFY_REGISTER) { char name[128]; -- cgit v1.1 From 6ac77bc180fbd985988015020c2e2347e802959d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:01:49 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCM OSS-emulation Modules: ALSA<-OSS emulation Remove xxx_t typedefs from the core PCM OSS-emulation codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/pcm_oss.h | 41 +++-- sound/core/oss/copy.c | 16 +- sound/core/oss/io.c | 28 ++-- sound/core/oss/linear.c | 38 ++--- sound/core/oss/mulaw.c | 54 +++---- sound/core/oss/pcm_oss.c | 364 ++++++++++++++++++++++---------------------- sound/core/oss/pcm_plugin.c | 110 ++++++------- sound/core/oss/pcm_plugin.h | 208 +++++++++++++------------ sound/core/oss/rate.c | 83 +++++----- sound/core/oss/route.c | 134 ++++++++-------- 10 files changed, 543 insertions(+), 533 deletions(-) diff --git a/include/sound/pcm_oss.h b/include/sound/pcm_oss.h index 0b67c9d..fddaddd 100644 --- a/include/sound/pcm_oss.h +++ b/include/sound/pcm_oss.h @@ -22,10 +22,7 @@ * */ -typedef struct _snd_pcm_plugin snd_pcm_plugin_t; -typedef struct _snd_pcm_oss_setup snd_pcm_oss_setup_t; - -struct _snd_pcm_oss_setup { +struct snd_pcm_oss_setup { char *task_name; unsigned int disable:1, direct:1, @@ -36,10 +33,10 @@ struct _snd_pcm_oss_setup { buggyptr:1; unsigned int periods; unsigned int period_size; - snd_pcm_oss_setup_t *next; + struct snd_pcm_oss_setup *next; }; -typedef struct _snd_pcm_oss_runtime { +struct snd_pcm_oss_runtime { unsigned params: 1, /* format/parameter change */ prepare: 1, /* need to prepare the operation */ trigger: 1, /* trigger flag */ @@ -59,30 +56,30 @@ typedef struct _snd_pcm_oss_runtime { size_t mmap_bytes; char *buffer; /* vmallocated period */ size_t buffer_used; /* used length from period buffer */ - snd_pcm_plugin_t *plugin_first; - snd_pcm_plugin_t *plugin_last; + struct snd_pcm_plugin *plugin_first; + struct snd_pcm_plugin *plugin_last; unsigned int prev_hw_ptr_interrupt; -} snd_pcm_oss_runtime_t; +}; -typedef struct _snd_pcm_oss_file { - snd_pcm_substream_t *streams[2]; -} snd_pcm_oss_file_t; +struct snd_pcm_oss_file { + struct snd_pcm_substream *streams[2]; +}; -typedef struct _snd_pcm_oss_substream { +struct snd_pcm_oss_substream { unsigned oss: 1; /* oss mode */ - snd_pcm_oss_setup_t *setup; /* active setup */ - snd_pcm_oss_file_t *file; -} snd_pcm_oss_substream_t; + struct snd_pcm_oss_setup *setup; /* active setup */ + struct snd_pcm_oss_file *file; +}; -typedef struct _snd_pcm_oss_stream { - snd_pcm_oss_setup_t *setup_list; /* setup list */ +struct snd_pcm_oss_stream { + struct snd_pcm_oss_setup *setup_list; /* setup list */ struct semaphore setup_mutex; - snd_info_entry_t *proc_entry; -} snd_pcm_oss_stream_t; + struct snd_info_entry *proc_entry; +}; -typedef struct _snd_pcm_oss { +struct snd_pcm_oss { int reg; unsigned int reg_mask; -} snd_pcm_oss_t; +}; #endif /* __SOUND_PCM_OSS_H */ diff --git a/sound/core/oss/copy.c b/sound/core/oss/copy.c index edecbe7..d6a04c2 100644 --- a/sound/core/oss/copy.c +++ b/sound/core/oss/copy.c @@ -25,9 +25,9 @@ #include <sound/pcm.h> #include "pcm_plugin.h" -static snd_pcm_sframes_t copy_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static snd_pcm_sframes_t copy_transfer(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { unsigned int channel; @@ -58,13 +58,13 @@ static snd_pcm_sframes_t copy_transfer(snd_pcm_plugin_t *plugin, return frames; } -int snd_pcm_plugin_build_copy(snd_pcm_plug_t *plug, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin) +int snd_pcm_plugin_build_copy(struct snd_pcm_substream *plug, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin) { int err; - snd_pcm_plugin_t *plugin; + struct snd_pcm_plugin *plugin; int width; snd_assert(r_plugin != NULL, return -ENXIO); diff --git a/sound/core/oss/io.c b/sound/core/oss/io.c index 63eca9a..322702e 100644 --- a/sound/core/oss/io.c +++ b/sound/core/oss/io.c @@ -35,9 +35,9 @@ * Basic io plugin */ -static snd_pcm_sframes_t io_playback_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static snd_pcm_sframes_t io_playback_transfer(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { snd_assert(plugin != NULL, return -ENXIO); @@ -58,9 +58,9 @@ static snd_pcm_sframes_t io_playback_transfer(snd_pcm_plugin_t *plugin, } } -static snd_pcm_sframes_t io_capture_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static snd_pcm_sframes_t io_capture_transfer(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { snd_assert(plugin != NULL, return -ENXIO); @@ -82,13 +82,13 @@ static snd_pcm_sframes_t io_capture_transfer(snd_pcm_plugin_t *plugin, return 0; } -static snd_pcm_sframes_t io_src_channels(snd_pcm_plugin_t *plugin, +static snd_pcm_sframes_t io_src_channels(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t frames, - snd_pcm_plugin_channel_t **channels) + struct snd_pcm_plugin_channel **channels) { int err; unsigned int channel; - snd_pcm_plugin_channel_t *v; + struct snd_pcm_plugin_channel *v; err = snd_pcm_plugin_client_channels(plugin, frames, &v); if (err < 0) return err; @@ -100,13 +100,13 @@ static snd_pcm_sframes_t io_src_channels(snd_pcm_plugin_t *plugin, return frames; } -int snd_pcm_plugin_build_io(snd_pcm_plug_t *plug, - snd_pcm_hw_params_t *params, - snd_pcm_plugin_t **r_plugin) +int snd_pcm_plugin_build_io(struct snd_pcm_substream *plug, + struct snd_pcm_hw_params *params, + struct snd_pcm_plugin **r_plugin) { int err; - snd_pcm_plugin_format_t format; - snd_pcm_plugin_t *plugin; + struct snd_pcm_plugin_format format; + struct snd_pcm_plugin *plugin; snd_assert(r_plugin != NULL, return -ENXIO); *r_plugin = NULL; diff --git a/sound/core/oss/linear.c b/sound/core/oss/linear.c index 12ed27a..8cbfa41 100644 --- a/sound/core/oss/linear.c +++ b/sound/core/oss/linear.c @@ -30,19 +30,19 @@ * Basic linear conversion plugin */ -typedef struct linear_private_data { +struct linear_priv { int conv; -} linear_t; +}; -static void convert(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static void convert(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { #define CONV_LABELS #include "plugin_ops.h" #undef CONV_LABELS - linear_t *data = (linear_t *)plugin->extra_data; + struct linear_priv *data = (struct linear_priv *)plugin->extra_data; void *conv = conv_labels[data->conv]; int channel; int nchannels = plugin->src_format.channels; @@ -75,15 +75,15 @@ static void convert(snd_pcm_plugin_t *plugin, } } -static snd_pcm_sframes_t linear_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { - linear_t *data; + struct linear_priv *data; snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); - data = (linear_t *)plugin->extra_data; + data = (struct linear_priv *)plugin->extra_data; if (frames == 0) return 0; #ifdef CONFIG_SND_DEBUG @@ -128,14 +128,14 @@ int conv_index(int src_format, int dst_format) return src_width * 32 + src_endian * 16 + sign * 8 + dst_width * 2 + dst_endian; } -int snd_pcm_plugin_build_linear(snd_pcm_plug_t *plug, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin) +int snd_pcm_plugin_build_linear(struct snd_pcm_substream *plug, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin) { int err; - struct linear_private_data *data; - snd_pcm_plugin_t *plugin; + struct linear_priv *data; + struct snd_pcm_plugin *plugin; snd_assert(r_plugin != NULL, return -ENXIO); *r_plugin = NULL; @@ -147,10 +147,10 @@ int snd_pcm_plugin_build_linear(snd_pcm_plug_t *plug, err = snd_pcm_plugin_build(plug, "linear format conversion", src_format, dst_format, - sizeof(linear_t), &plugin); + sizeof(struct linear_priv), &plugin); if (err < 0) return err; - data = (linear_t *)plugin->extra_data; + data = (struct linear_priv *)plugin->extra_data; data->conv = conv_index(src_format->format, dst_format->format); plugin->transfer = linear_transfer; *r_plugin = plugin; diff --git a/sound/core/oss/mulaw.c b/sound/core/oss/mulaw.c index 44ec4c6..14f5578 100644 --- a/sound/core/oss/mulaw.c +++ b/sound/core/oss/mulaw.c @@ -139,25 +139,25 @@ static int ulaw2linear(unsigned char u_val) * Basic Mu-Law plugin */ -typedef void (*mulaw_f)(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +typedef void (*mulaw_f)(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames); -typedef struct mulaw_private_data { +struct mulaw_priv { mulaw_f func; int conv; -} mulaw_t; +}; -static void mulaw_decode(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static void mulaw_decode(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { #define PUT_S16_LABELS #include "plugin_ops.h" #undef PUT_S16_LABELS - mulaw_t *data = (mulaw_t *)plugin->extra_data; + struct mulaw_priv *data = (struct mulaw_priv *)plugin->extra_data; void *put = put_s16_labels[data->conv]; int channel; int nchannels = plugin->src_format.channels; @@ -191,15 +191,15 @@ static void mulaw_decode(snd_pcm_plugin_t *plugin, } } -static void mulaw_encode(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static void mulaw_encode(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { #define GET_S16_LABELS #include "plugin_ops.h" #undef GET_S16_LABELS - mulaw_t *data = (mulaw_t *)plugin->extra_data; + struct mulaw_priv *data = (struct mulaw_priv *)plugin->extra_data; void *get = get_s16_labels[data->conv]; int channel; int nchannels = plugin->src_format.channels; @@ -234,12 +234,12 @@ static void mulaw_encode(snd_pcm_plugin_t *plugin, } } -static snd_pcm_sframes_t mulaw_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { - mulaw_t *data; + struct mulaw_priv *data; snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); if (frames == 0) @@ -257,20 +257,20 @@ static snd_pcm_sframes_t mulaw_transfer(snd_pcm_plugin_t *plugin, } } #endif - data = (mulaw_t *)plugin->extra_data; + data = (struct mulaw_priv *)plugin->extra_data; data->func(plugin, src_channels, dst_channels, frames); return frames; } -int snd_pcm_plugin_build_mulaw(snd_pcm_plug_t *plug, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin) +int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin) { int err; - mulaw_t *data; - snd_pcm_plugin_t *plugin; - snd_pcm_plugin_format_t *format; + struct mulaw_priv *data; + struct snd_pcm_plugin *plugin; + struct snd_pcm_plugin_format *format; mulaw_f func; snd_assert(r_plugin != NULL, return -ENXIO); @@ -295,10 +295,10 @@ int snd_pcm_plugin_build_mulaw(snd_pcm_plug_t *plug, err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion", src_format, dst_format, - sizeof(mulaw_t), &plugin); + sizeof(struct mulaw_priv), &plugin); if (err < 0) return err; - data = (mulaw_t*)plugin->extra_data; + data = (struct mulaw_priv *)plugin->extra_data; data->func = func; data->conv = getput_index(format->format); snd_assert(data->conv >= 0 && data->conv < 4*2*2, return -EINVAL); diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index bcc9707..ffc13b9 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -61,10 +61,10 @@ MODULE_PARM_DESC(nonblock_open, "Don't block opening busy PCM devices."); MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM); MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM1); -extern int snd_mixer_oss_ioctl_card(snd_card_t *card, unsigned int cmd, unsigned long arg); -static int snd_pcm_oss_get_rate(snd_pcm_oss_file_t *pcm_oss_file); -static int snd_pcm_oss_get_channels(snd_pcm_oss_file_t *pcm_oss_file); -static int snd_pcm_oss_get_format(snd_pcm_oss_file_t *pcm_oss_file); +extern int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg); +static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file); +static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file); +static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file); static inline mm_segment_t snd_enter_user(void) { @@ -78,10 +78,10 @@ static inline void snd_leave_user(mm_segment_t fs) set_fs(fs); } -static int snd_pcm_oss_plugin_clear(snd_pcm_substream_t *substream) +static int snd_pcm_oss_plugin_clear(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_pcm_plugin_t *plugin, *next; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_pcm_plugin *plugin, *next; plugin = runtime->oss.plugin_first; while (plugin) { @@ -93,9 +93,9 @@ static int snd_pcm_oss_plugin_clear(snd_pcm_substream_t *substream) return 0; } -static int snd_pcm_plugin_insert(snd_pcm_plugin_t *plugin) +static int snd_pcm_plugin_insert(struct snd_pcm_plugin *plugin) { - snd_pcm_runtime_t *runtime = plugin->plug->runtime; + struct snd_pcm_runtime *runtime = plugin->plug->runtime; plugin->next = runtime->oss.plugin_first; plugin->prev = NULL; if (runtime->oss.plugin_first) { @@ -108,9 +108,9 @@ static int snd_pcm_plugin_insert(snd_pcm_plugin_t *plugin) return 0; } -int snd_pcm_plugin_append(snd_pcm_plugin_t *plugin) +int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin) { - snd_pcm_runtime_t *runtime = plugin->plug->runtime; + struct snd_pcm_runtime *runtime = plugin->plug->runtime; plugin->next = NULL; plugin->prev = runtime->oss.plugin_last; if (runtime->oss.plugin_last) { @@ -123,9 +123,9 @@ int snd_pcm_plugin_append(snd_pcm_plugin_t *plugin) return 0; } -static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames) +static long snd_pcm_oss_bytes(struct snd_pcm_substream *substream, long frames) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; long buffer_size = snd_pcm_lib_buffer_bytes(substream); long bytes = frames_to_bytes(runtime, frames); if (buffer_size == runtime->oss.buffer_bytes) @@ -142,9 +142,9 @@ static long snd_pcm_oss_bytes(snd_pcm_substream_t *substream, long frames) #endif } -static long snd_pcm_alsa_frames(snd_pcm_substream_t *substream, long bytes) +static long snd_pcm_alsa_frames(struct snd_pcm_substream *substream, long bytes) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; long buffer_size = snd_pcm_lib_buffer_bytes(substream); if (buffer_size == runtime->oss.buffer_bytes) return bytes_to_frames(runtime, bytes); @@ -185,14 +185,14 @@ static int snd_pcm_oss_format_to(int format) } } -static int snd_pcm_oss_period_size(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *oss_params, - snd_pcm_hw_params_t *slave_params) +static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *oss_params, + struct snd_pcm_hw_params *slave_params) { size_t s; size_t oss_buffer_size, oss_period_size, oss_periods; size_t min_period_size, max_period_size; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; size_t oss_frame_size; oss_frame_size = snd_pcm_format_physical_width(params_format(oss_params)) * @@ -277,11 +277,11 @@ static int snd_pcm_oss_period_size(snd_pcm_substream_t *substream, return 0; } -static int choose_rate(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params, unsigned int best_rate) +static int choose_rate(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, unsigned int best_rate) { - snd_interval_t *it; - snd_pcm_hw_params_t *save; + struct snd_interval *it; + struct snd_pcm_hw_params *save; unsigned int rate, prev; save = kmalloc(sizeof(*save), GFP_KERNEL); @@ -317,18 +317,18 @@ static int choose_rate(snd_pcm_substream_t *substream, return snd_pcm_hw_param_near(substream, params, SNDRV_PCM_HW_PARAM_RATE, best_rate, NULL); } -static int snd_pcm_oss_change_params(snd_pcm_substream_t *substream) +static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_pcm_hw_params_t *params, *sparams; - snd_pcm_sw_params_t *sw_params; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_pcm_hw_params *params, *sparams; + struct snd_pcm_sw_params *sw_params; ssize_t oss_buffer_size, oss_period_size; size_t oss_frame_size; int err; int direct; int format, sformat, n; - snd_mask_t sformat_mask; - snd_mask_t mask; + struct snd_mask sformat_mask; + struct snd_mask mask; sw_params = kmalloc(sizeof(*sw_params), GFP_KERNEL); params = kmalloc(sizeof(*params), GFP_KERNEL); @@ -342,7 +342,7 @@ static int snd_pcm_oss_change_params(snd_pcm_substream_t *substream) if (atomic_read(&runtime->mmap_count)) { direct = 1; } else { - snd_pcm_oss_setup_t *setup = substream->oss.setup; + struct snd_pcm_oss_setup *setup = substream->oss.setup; direct = (setup != NULL && setup->direct); } @@ -424,7 +424,7 @@ static int snd_pcm_oss_change_params(snd_pcm_substream_t *substream) goto failure; } if (runtime->oss.plugin_first) { - snd_pcm_plugin_t *plugin; + struct snd_pcm_plugin *plugin; if ((err = snd_pcm_plugin_build_io(substream, sparams, &plugin)) < 0) { snd_printd("snd_pcm_plugin_build_io failed: %i\n", err); snd_pcm_oss_plugin_clear(substream); @@ -540,10 +540,10 @@ failure: return err; } -static int snd_pcm_oss_get_active_substream(snd_pcm_oss_file_t *pcm_oss_file, snd_pcm_substream_t **r_substream) +static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_file, struct snd_pcm_substream **r_substream) { int idx, err; - snd_pcm_substream_t *asubstream = NULL, *substream; + struct snd_pcm_substream *asubstream = NULL, *substream; for (idx = 0; idx < 2; idx++) { substream = pcm_oss_file->streams[idx]; @@ -563,10 +563,10 @@ static int snd_pcm_oss_get_active_substream(snd_pcm_oss_file_t *pcm_oss_file, sn return 0; } -static int snd_pcm_oss_prepare(snd_pcm_substream_t *substream) +static int snd_pcm_oss_prepare(struct snd_pcm_substream *substream) { int err; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_PREPARE, NULL); if (err < 0) { @@ -581,9 +581,9 @@ static int snd_pcm_oss_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_pcm_oss_make_ready(snd_pcm_substream_t *substream) +static int snd_pcm_oss_make_ready(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; int err; if (substream == NULL) @@ -602,9 +602,9 @@ static int snd_pcm_oss_make_ready(snd_pcm_substream_t *substream) return 0; } -static int snd_pcm_oss_capture_position_fixup(snd_pcm_substream_t *substream, snd_pcm_sframes_t *delay) +static int snd_pcm_oss_capture_position_fixup(struct snd_pcm_substream *substream, snd_pcm_sframes_t *delay) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; snd_pcm_uframes_t frames; int err = 0; @@ -627,9 +627,9 @@ static int snd_pcm_oss_capture_position_fixup(snd_pcm_substream_t *substream, sn return err; } -snd_pcm_sframes_t snd_pcm_oss_write3(snd_pcm_substream_t *substream, const char *ptr, snd_pcm_uframes_t frames, int in_kernel) +snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const char *ptr, snd_pcm_uframes_t frames, int in_kernel) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int ret; while (1) { if (runtime->status->state == SNDRV_PCM_STATE_XRUN || @@ -662,9 +662,9 @@ snd_pcm_sframes_t snd_pcm_oss_write3(snd_pcm_substream_t *substream, const char return ret; } -snd_pcm_sframes_t snd_pcm_oss_read3(snd_pcm_substream_t *substream, char *ptr, snd_pcm_uframes_t frames, int in_kernel) +snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *ptr, snd_pcm_uframes_t frames, int in_kernel) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t delay; int ret; while (1) { @@ -709,9 +709,9 @@ snd_pcm_sframes_t snd_pcm_oss_read3(snd_pcm_substream_t *substream, char *ptr, s return ret; } -snd_pcm_sframes_t snd_pcm_oss_writev3(snd_pcm_substream_t *substream, void **bufs, snd_pcm_uframes_t frames, int in_kernel) +snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, void **bufs, snd_pcm_uframes_t frames, int in_kernel) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int ret; while (1) { if (runtime->status->state == SNDRV_PCM_STATE_XRUN || @@ -745,9 +745,9 @@ snd_pcm_sframes_t snd_pcm_oss_writev3(snd_pcm_substream_t *substream, void **buf return ret; } -snd_pcm_sframes_t snd_pcm_oss_readv3(snd_pcm_substream_t *substream, void **bufs, snd_pcm_uframes_t frames, int in_kernel) +snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, void **bufs, snd_pcm_uframes_t frames, int in_kernel) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int ret; while (1) { if (runtime->status->state == SNDRV_PCM_STATE_XRUN || @@ -780,12 +780,12 @@ snd_pcm_sframes_t snd_pcm_oss_readv3(snd_pcm_substream_t *substream, void **bufs return ret; } -static ssize_t snd_pcm_oss_write2(snd_pcm_substream_t *substream, const char *buf, size_t bytes, int in_kernel) +static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const char *buf, size_t bytes, int in_kernel) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t frames, frames1; if (runtime->oss.plugin_first) { - snd_pcm_plugin_channel_t *channels; + struct snd_pcm_plugin_channel *channels; size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8; if (!in_kernel) { if (copy_from_user(runtime->oss.buffer, (const char __user *)buf, bytes)) @@ -810,11 +810,11 @@ static ssize_t snd_pcm_oss_write2(snd_pcm_substream_t *substream, const char *bu return bytes; } -static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __user *buf, size_t bytes) +static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const char __user *buf, size_t bytes) { size_t xfer = 0; ssize_t tmp; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (atomic_read(&runtime->mmap_count)) return -ENXIO; @@ -867,13 +867,13 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __u return xfer; } -static ssize_t snd_pcm_oss_read2(snd_pcm_substream_t *substream, char *buf, size_t bytes, int in_kernel) +static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf, size_t bytes, int in_kernel) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_sframes_t frames, frames1; char __user *final_dst = (char __user *)buf; if (runtime->oss.plugin_first) { - snd_pcm_plugin_channel_t *channels; + struct snd_pcm_plugin_channel *channels; size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8; if (!in_kernel) buf = runtime->oss.buffer; @@ -897,11 +897,11 @@ static ssize_t snd_pcm_oss_read2(snd_pcm_substream_t *substream, char *buf, size return bytes; } -static ssize_t snd_pcm_oss_read1(snd_pcm_substream_t *substream, char __user *buf, size_t bytes) +static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __user *buf, size_t bytes) { size_t xfer = 0; ssize_t tmp; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (atomic_read(&runtime->mmap_count)) return -ENXIO; @@ -941,9 +941,9 @@ static ssize_t snd_pcm_oss_read1(snd_pcm_substream_t *substream, char __user *bu return xfer; } -static int snd_pcm_oss_reset(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_reset(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; if (substream != NULL) { @@ -958,9 +958,9 @@ static int snd_pcm_oss_reset(snd_pcm_oss_file_t *pcm_oss_file) return 0; } -static int snd_pcm_oss_post(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_post(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int err; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; @@ -974,9 +974,9 @@ static int snd_pcm_oss_post(snd_pcm_oss_file_t *pcm_oss_file) return 0; } -static int snd_pcm_oss_sync1(snd_pcm_substream_t *substream, size_t size) +static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; ssize_t result = 0; long res; wait_queue_t wait; @@ -1020,12 +1020,12 @@ static int snd_pcm_oss_sync1(snd_pcm_substream_t *substream, size_t size) return result; } -static int snd_pcm_oss_sync(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file) { int err = 0; unsigned int saved_f_flags; - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_pcm_format_t format; unsigned long width; size_t size; @@ -1117,13 +1117,13 @@ static int snd_pcm_oss_sync(snd_pcm_oss_file_t *pcm_oss_file) return 0; } -static int snd_pcm_oss_set_rate(snd_pcm_oss_file_t *pcm_oss_file, int rate) +static int snd_pcm_oss_set_rate(struct snd_pcm_oss_file *pcm_oss_file, int rate) { int idx; for (idx = 1; idx >= 0; --idx) { - snd_pcm_substream_t *substream = pcm_oss_file->streams[idx]; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream = pcm_oss_file->streams[idx]; + struct snd_pcm_runtime *runtime; if (substream == NULL) continue; runtime = substream->runtime; @@ -1139,9 +1139,9 @@ static int snd_pcm_oss_set_rate(snd_pcm_oss_file_t *pcm_oss_file, int rate) return snd_pcm_oss_get_rate(pcm_oss_file); } -static int snd_pcm_oss_get_rate(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int err; if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) @@ -1149,7 +1149,7 @@ static int snd_pcm_oss_get_rate(snd_pcm_oss_file_t *pcm_oss_file) return substream->runtime->oss.rate; } -static int snd_pcm_oss_set_channels(snd_pcm_oss_file_t *pcm_oss_file, unsigned int channels) +static int snd_pcm_oss_set_channels(struct snd_pcm_oss_file *pcm_oss_file, unsigned int channels) { int idx; if (channels < 1) @@ -1157,8 +1157,8 @@ static int snd_pcm_oss_set_channels(snd_pcm_oss_file_t *pcm_oss_file, unsigned i if (channels > 128) return -EINVAL; for (idx = 1; idx >= 0; --idx) { - snd_pcm_substream_t *substream = pcm_oss_file->streams[idx]; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream = pcm_oss_file->streams[idx]; + struct snd_pcm_runtime *runtime; if (substream == NULL) continue; runtime = substream->runtime; @@ -1170,9 +1170,9 @@ static int snd_pcm_oss_set_channels(snd_pcm_oss_file_t *pcm_oss_file, unsigned i return snd_pcm_oss_get_channels(pcm_oss_file); } -static int snd_pcm_oss_get_channels(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int err; if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) @@ -1180,9 +1180,9 @@ static int snd_pcm_oss_get_channels(snd_pcm_oss_file_t *pcm_oss_file) return substream->runtime->oss.channels; } -static int snd_pcm_oss_get_block_size(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_get_block_size(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int err; if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) @@ -1190,14 +1190,14 @@ static int snd_pcm_oss_get_block_size(snd_pcm_oss_file_t *pcm_oss_file) return substream->runtime->oss.period_bytes; } -static int snd_pcm_oss_get_formats(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int err; int direct; - snd_pcm_hw_params_t *params; + struct snd_pcm_hw_params *params; unsigned int formats = 0; - snd_mask_t format_mask; + struct snd_mask format_mask; int fmt; if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) @@ -1205,7 +1205,7 @@ static int snd_pcm_oss_get_formats(snd_pcm_oss_file_t *pcm_oss_file) if (atomic_read(&substream->runtime->mmap_count)) { direct = 1; } else { - snd_pcm_oss_setup_t *setup = substream->oss.setup; + struct snd_pcm_oss_setup *setup = substream->oss.setup; direct = (setup != NULL && setup->direct); } if (!direct) @@ -1231,7 +1231,7 @@ static int snd_pcm_oss_get_formats(snd_pcm_oss_file_t *pcm_oss_file) return formats; } -static int snd_pcm_oss_set_format(snd_pcm_oss_file_t *pcm_oss_file, int format) +static int snd_pcm_oss_set_format(struct snd_pcm_oss_file *pcm_oss_file, int format) { int formats, idx; @@ -1240,8 +1240,8 @@ static int snd_pcm_oss_set_format(snd_pcm_oss_file_t *pcm_oss_file, int format) if (!(formats & format)) format = AFMT_U8; for (idx = 1; idx >= 0; --idx) { - snd_pcm_substream_t *substream = pcm_oss_file->streams[idx]; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream = pcm_oss_file->streams[idx]; + struct snd_pcm_runtime *runtime; if (substream == NULL) continue; runtime = substream->runtime; @@ -1254,9 +1254,9 @@ static int snd_pcm_oss_set_format(snd_pcm_oss_file_t *pcm_oss_file, int format) return snd_pcm_oss_get_format(pcm_oss_file); } -static int snd_pcm_oss_get_format(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int err; if ((err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream)) < 0) @@ -1264,9 +1264,9 @@ static int snd_pcm_oss_get_format(snd_pcm_oss_file_t *pcm_oss_file) return substream->runtime->oss.format; } -static int snd_pcm_oss_set_subdivide1(snd_pcm_substream_t *substream, int subdivide) +static int snd_pcm_oss_set_subdivide1(struct snd_pcm_substream *substream, int subdivide) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; if (substream == NULL) return 0; @@ -1287,12 +1287,12 @@ static int snd_pcm_oss_set_subdivide1(snd_pcm_substream_t *substream, int subdiv return subdivide; } -static int snd_pcm_oss_set_subdivide(snd_pcm_oss_file_t *pcm_oss_file, int subdivide) +static int snd_pcm_oss_set_subdivide(struct snd_pcm_oss_file *pcm_oss_file, int subdivide) { int err = -EINVAL, idx; for (idx = 1; idx >= 0; --idx) { - snd_pcm_substream_t *substream = pcm_oss_file->streams[idx]; + struct snd_pcm_substream *substream = pcm_oss_file->streams[idx]; if (substream == NULL) continue; if ((err = snd_pcm_oss_set_subdivide1(substream, subdivide)) < 0) @@ -1301,9 +1301,9 @@ static int snd_pcm_oss_set_subdivide(snd_pcm_oss_file_t *pcm_oss_file, int subdi return err; } -static int snd_pcm_oss_set_fragment1(snd_pcm_substream_t *substream, unsigned int val) +static int snd_pcm_oss_set_fragment1(struct snd_pcm_substream *substream, unsigned int val) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; if (substream == NULL) return 0; @@ -1320,12 +1320,12 @@ static int snd_pcm_oss_set_fragment1(snd_pcm_substream_t *substream, unsigned in return 0; } -static int snd_pcm_oss_set_fragment(snd_pcm_oss_file_t *pcm_oss_file, unsigned int val) +static int snd_pcm_oss_set_fragment(struct snd_pcm_oss_file *pcm_oss_file, unsigned int val) { int err = -EINVAL, idx; for (idx = 1; idx >= 0; --idx) { - snd_pcm_substream_t *substream = pcm_oss_file->streams[idx]; + struct snd_pcm_substream *substream = pcm_oss_file->streams[idx]; if (substream == NULL) continue; if ((err = snd_pcm_oss_set_fragment1(substream, val)) < 0) @@ -1340,7 +1340,7 @@ static int snd_pcm_oss_nonblock(struct file * file) return 0; } -static int snd_pcm_oss_get_caps1(snd_pcm_substream_t *substream, int res) +static int snd_pcm_oss_get_caps1(struct snd_pcm_substream *substream, int res) { if (substream == NULL) { @@ -1356,7 +1356,7 @@ static int snd_pcm_oss_get_caps1(snd_pcm_substream_t *substream, int res) /* all ALSA drivers can return actual pointer in ring buffer */ #if defined(DSP_CAP_REALTIME) && 0 { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->info & (SNDRV_PCM_INFO_BLOCK_TRANSFER|SNDRV_PCM_INFO_BATCH)) res &= ~DSP_CAP_REALTIME; } @@ -1364,32 +1364,32 @@ static int snd_pcm_oss_get_caps1(snd_pcm_substream_t *substream, int res) return res; } -static int snd_pcm_oss_get_caps(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_get_caps(struct snd_pcm_oss_file *pcm_oss_file) { int result, idx; result = DSP_CAP_TRIGGER | DSP_CAP_MMAP | DSP_CAP_DUPLEX | DSP_CAP_REALTIME; for (idx = 0; idx < 2; idx++) { - snd_pcm_substream_t *substream = pcm_oss_file->streams[idx]; + struct snd_pcm_substream *substream = pcm_oss_file->streams[idx]; result = snd_pcm_oss_get_caps1(substream, result); } result |= 0x0001; /* revision - same as SB AWE 64 */ return result; } -static void snd_pcm_oss_simulate_fill(snd_pcm_substream_t *substream, snd_pcm_uframes_t hw_ptr) +static void snd_pcm_oss_simulate_fill(struct snd_pcm_substream *substream, snd_pcm_uframes_t hw_ptr) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_uframes_t appl_ptr; appl_ptr = hw_ptr + runtime->buffer_size; appl_ptr %= runtime->boundary; runtime->control->appl_ptr = appl_ptr; } -static int snd_pcm_oss_set_trigger(snd_pcm_oss_file_t *pcm_oss_file, int trigger) +static int snd_pcm_oss_set_trigger(struct snd_pcm_oss_file *pcm_oss_file, int trigger) { - snd_pcm_runtime_t *runtime; - snd_pcm_substream_t *psubstream = NULL, *csubstream = NULL; + struct snd_pcm_runtime *runtime; + struct snd_pcm_substream *psubstream = NULL, *csubstream = NULL; int err, cmd; #ifdef OSS_DEBUG @@ -1454,9 +1454,9 @@ static int snd_pcm_oss_set_trigger(snd_pcm_oss_file_t *pcm_oss_file, int trigger return 0; } -static int snd_pcm_oss_get_trigger(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_get_trigger(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *psubstream = NULL, *csubstream = NULL; + struct snd_pcm_substream *psubstream = NULL, *csubstream = NULL; int result = 0; psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; @@ -1468,10 +1468,10 @@ static int snd_pcm_oss_get_trigger(snd_pcm_oss_file_t *pcm_oss_file) return result; } -static int snd_pcm_oss_get_odelay(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_get_odelay(struct snd_pcm_oss_file *pcm_oss_file) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_pcm_sframes_t delay; int err; @@ -1491,10 +1491,10 @@ static int snd_pcm_oss_get_odelay(snd_pcm_oss_file_t *pcm_oss_file) return snd_pcm_oss_bytes(substream, delay); } -static int snd_pcm_oss_get_ptr(snd_pcm_oss_file_t *pcm_oss_file, int stream, struct count_info __user * _info) +static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct count_info __user * _info) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_pcm_sframes_t delay; int fixup; struct count_info info; @@ -1543,7 +1543,7 @@ static int snd_pcm_oss_get_ptr(snd_pcm_oss_file_t *pcm_oss_file, int stream, str } else { delay = snd_pcm_oss_bytes(substream, delay); if (stream == SNDRV_PCM_STREAM_PLAYBACK) { - snd_pcm_oss_setup_t *setup = substream->oss.setup; + struct snd_pcm_oss_setup *setup = substream->oss.setup; if (setup && setup->buggyptr) info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes; else @@ -1560,10 +1560,10 @@ static int snd_pcm_oss_get_ptr(snd_pcm_oss_file_t *pcm_oss_file, int stream, str return 0; } -static int snd_pcm_oss_get_space(snd_pcm_oss_file_t *pcm_oss_file, int stream, struct audio_buf_info __user *_info) +static int snd_pcm_oss_get_space(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct audio_buf_info __user *_info) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_pcm_sframes_t avail; int fixup; struct audio_buf_info info; @@ -1619,17 +1619,17 @@ static int snd_pcm_oss_get_space(snd_pcm_oss_file_t *pcm_oss_file, int stream, s return 0; } -static int snd_pcm_oss_get_mapbuf(snd_pcm_oss_file_t *pcm_oss_file, int stream, struct buffmem_desc __user * _info) +static int snd_pcm_oss_get_mapbuf(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct buffmem_desc __user * _info) { // it won't be probably implemented // snd_printd("TODO: snd_pcm_oss_get_mapbuf\n"); return -EINVAL; } -static snd_pcm_oss_setup_t *snd_pcm_oss_look_for_setup(snd_pcm_t *pcm, int stream, const char *task_name) +static struct snd_pcm_oss_setup *snd_pcm_oss_look_for_setup(struct snd_pcm *pcm, int stream, const char *task_name) { const char *ptr, *ptrl; - snd_pcm_oss_setup_t *setup; + struct snd_pcm_oss_setup *setup; down(&pcm->streams[stream].oss.setup_mutex); for (setup = pcm->streams[stream].oss.setup_list; setup; setup = setup->next) { @@ -1659,11 +1659,11 @@ static snd_pcm_oss_setup_t *snd_pcm_oss_look_for_setup(snd_pcm_t *pcm, int strea return NULL; } -static void snd_pcm_oss_init_substream(snd_pcm_substream_t *substream, - snd_pcm_oss_setup_t *setup, +static void snd_pcm_oss_init_substream(struct snd_pcm_substream *substream, + struct snd_pcm_oss_setup *setup, int minor) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; substream->oss.oss = 1; substream->oss.setup = setup; @@ -1687,9 +1687,9 @@ static void snd_pcm_oss_init_substream(snd_pcm_substream_t *substream, runtime->oss.subdivision = 0; } -static void snd_pcm_oss_release_substream(snd_pcm_substream_t *substream) +static void snd_pcm_oss_release_substream(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; runtime = substream->runtime; vfree(runtime->oss.buffer); snd_pcm_oss_plugin_clear(substream); @@ -1697,13 +1697,13 @@ static void snd_pcm_oss_release_substream(snd_pcm_substream_t *substream) substream->oss.oss = 0; } -static int snd_pcm_oss_release_file(snd_pcm_oss_file_t *pcm_oss_file) +static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file) { int cidx; snd_assert(pcm_oss_file != NULL, return -ENXIO); for (cidx = 0; cidx < 2; ++cidx) { - snd_pcm_substream_t *substream = pcm_oss_file->streams[cidx]; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx]; + struct snd_pcm_runtime *runtime; if (substream == NULL) continue; runtime = substream->runtime; @@ -1726,15 +1726,15 @@ static int snd_pcm_oss_release_file(snd_pcm_oss_file_t *pcm_oss_file) } static int snd_pcm_oss_open_file(struct file *file, - snd_pcm_t *pcm, - snd_pcm_oss_file_t **rpcm_oss_file, + struct snd_pcm *pcm, + struct snd_pcm_oss_file **rpcm_oss_file, int minor, - snd_pcm_oss_setup_t *psetup, - snd_pcm_oss_setup_t *csetup) + struct snd_pcm_oss_setup *psetup, + struct snd_pcm_oss_setup *csetup) { int err = 0; - snd_pcm_oss_file_t *pcm_oss_file; - snd_pcm_substream_t *psubstream = NULL, *csubstream = NULL; + struct snd_pcm_oss_file *pcm_oss_file; + struct snd_pcm_substream *psubstream = NULL, *csubstream = NULL; unsigned int f_mode = file->f_mode; snd_assert(rpcm_oss_file != NULL, return -EINVAL); @@ -1839,9 +1839,9 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) int device; int err; char task_name[32]; - snd_pcm_t *pcm; - snd_pcm_oss_file_t *pcm_oss_file; - snd_pcm_oss_setup_t *psetup = NULL, *csetup = NULL; + struct snd_pcm *pcm; + struct snd_pcm_oss_file *pcm_oss_file; + struct snd_pcm_oss_setup *psetup = NULL, *csetup = NULL; int nonblock; wait_queue_t wait; @@ -1925,9 +1925,9 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) static int snd_pcm_oss_release(struct inode *inode, struct file *file) { - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; - snd_pcm_oss_file_t *pcm_oss_file; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; + struct snd_pcm_oss_file *pcm_oss_file; pcm_oss_file = file->private_data; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; @@ -1947,7 +1947,7 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file) static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - snd_pcm_oss_file_t *pcm_oss_file; + struct snd_pcm_oss_file *pcm_oss_file; int __user *p = (int __user *)arg; int res; @@ -1958,7 +1958,7 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long return put_user(1, p); #if defined(CONFIG_SND_MIXER_OSS) || (defined(MODULE) && defined(CONFIG_SND_MIXER_OSS_MODULE)) if (((cmd >> 8) & 0xff) == 'M') { /* mixer ioctl - for OSS compatibility */ - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int idx; for (idx = 0; idx < 2; ++idx) { substream = pcm_oss_file->streams[idx]; @@ -2113,8 +2113,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long static ssize_t snd_pcm_oss_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { - snd_pcm_oss_file_t *pcm_oss_file; - snd_pcm_substream_t *substream; + struct snd_pcm_oss_file *pcm_oss_file; + struct snd_pcm_substream *substream; pcm_oss_file = file->private_data; substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; @@ -2133,8 +2133,8 @@ static ssize_t snd_pcm_oss_read(struct file *file, char __user *buf, size_t coun static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) { - snd_pcm_oss_file_t *pcm_oss_file; - snd_pcm_substream_t *substream; + struct snd_pcm_oss_file *pcm_oss_file; + struct snd_pcm_substream *substream; long result; pcm_oss_file = file->private_data; @@ -2150,18 +2150,18 @@ static ssize_t snd_pcm_oss_write(struct file *file, const char __user *buf, size return result; } -static int snd_pcm_oss_playback_ready(snd_pcm_substream_t *substream) +static int snd_pcm_oss_playback_ready(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (atomic_read(&runtime->mmap_count)) return runtime->oss.prev_hw_ptr_interrupt != runtime->hw_ptr_interrupt; else return snd_pcm_playback_avail(runtime) >= runtime->oss.period_frames; } -static int snd_pcm_oss_capture_ready(snd_pcm_substream_t *substream) +static int snd_pcm_oss_capture_ready(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (atomic_read(&runtime->mmap_count)) return runtime->oss.prev_hw_ptr_interrupt != runtime->hw_ptr_interrupt; else @@ -2170,9 +2170,9 @@ static int snd_pcm_oss_capture_ready(snd_pcm_substream_t *substream) static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) { - snd_pcm_oss_file_t *pcm_oss_file; + struct snd_pcm_oss_file *pcm_oss_file; unsigned int mask; - snd_pcm_substream_t *psubstream = NULL, *csubstream = NULL; + struct snd_pcm_substream *psubstream = NULL, *csubstream = NULL; pcm_oss_file = file->private_data; @@ -2181,7 +2181,7 @@ static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) mask = 0; if (psubstream != NULL) { - snd_pcm_runtime_t *runtime = psubstream->runtime; + struct snd_pcm_runtime *runtime = psubstream->runtime; poll_wait(file, &runtime->sleep, wait); snd_pcm_stream_lock_irq(psubstream); if (runtime->status->state != SNDRV_PCM_STATE_DRAINING && @@ -2191,8 +2191,8 @@ static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) snd_pcm_stream_unlock_irq(psubstream); } if (csubstream != NULL) { - snd_pcm_runtime_t *runtime = csubstream->runtime; - enum sndrv_pcm_state ostate; + struct snd_pcm_runtime *runtime = csubstream->runtime; + snd_pcm_state_t ostate; poll_wait(file, &runtime->sleep, wait); snd_pcm_stream_lock_irq(csubstream); if ((ostate = runtime->status->state) != SNDRV_PCM_STATE_RUNNING || @@ -2200,7 +2200,7 @@ static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) mask |= POLLIN | POLLRDNORM; snd_pcm_stream_unlock_irq(csubstream); if (ostate != SNDRV_PCM_STATE_RUNNING && runtime->oss.trigger) { - snd_pcm_oss_file_t ofile; + struct snd_pcm_oss_file ofile; memset(&ofile, 0, sizeof(ofile)); ofile.streams[SNDRV_PCM_STREAM_CAPTURE] = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; runtime->oss.trigger = 0; @@ -2213,9 +2213,9 @@ static unsigned int snd_pcm_oss_poll(struct file *file, poll_table * wait) static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area) { - snd_pcm_oss_file_t *pcm_oss_file; - snd_pcm_substream_t *substream = NULL; - snd_pcm_runtime_t *runtime; + struct snd_pcm_oss_file *pcm_oss_file; + struct snd_pcm_substream *substream = NULL; + struct snd_pcm_runtime *runtime; int err; #ifdef OSS_DEBUG @@ -2279,11 +2279,11 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area) * /proc interface */ -static void snd_pcm_oss_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_pcm_oss_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_str_t *pstr = (snd_pcm_str_t *)entry->private_data; - snd_pcm_oss_setup_t *setup = pstr->oss.setup_list; + struct snd_pcm_str *pstr = entry->private_data; + struct snd_pcm_oss_setup *setup = pstr->oss.setup_list; down(&pstr->oss.setup_mutex); while (setup) { snd_iprintf(buffer, "%s %u %u%s%s%s%s%s%s\n", @@ -2301,11 +2301,11 @@ static void snd_pcm_oss_proc_read(snd_info_entry_t *entry, up(&pstr->oss.setup_mutex); } -static void snd_pcm_oss_proc_free_setup_list(snd_pcm_str_t * pstr) +static void snd_pcm_oss_proc_free_setup_list(struct snd_pcm_str * pstr) { unsigned int idx; - snd_pcm_substream_t *substream; - snd_pcm_oss_setup_t *setup, *setupn; + struct snd_pcm_substream *substream; + struct snd_pcm_oss_setup *setup, *setupn; for (idx = 0, substream = pstr->substream; idx < pstr->substream_count; idx++, substream = substream->next) @@ -2319,13 +2319,13 @@ static void snd_pcm_oss_proc_free_setup_list(snd_pcm_str_t * pstr) pstr->oss.setup_list = NULL; } -static void snd_pcm_oss_proc_write(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_pcm_oss_proc_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_pcm_str_t *pstr = (snd_pcm_str_t *)entry->private_data; + struct snd_pcm_str *pstr = entry->private_data; char line[128], str[32], task_name[32], *ptr; int idx1; - snd_pcm_oss_setup_t *setup, *setup1, template; + struct snd_pcm_oss_setup *setup, *setup1, template; while (!snd_info_get_line(buffer, line, sizeof(line))) { down(&pstr->oss.setup_mutex); @@ -2370,7 +2370,7 @@ static void snd_pcm_oss_proc_write(snd_info_entry_t *entry, } } while (*str); if (setup == NULL) { - setup = (snd_pcm_oss_setup_t *) kmalloc(sizeof(snd_pcm_oss_setup_t), GFP_KERNEL); + setup = kmalloc(sizeof(struct snd_pcm_oss_setup), GFP_KERNEL); if (setup) { if (pstr->oss.setup_list == NULL) { pstr->oss.setup_list = setup; @@ -2389,12 +2389,12 @@ static void snd_pcm_oss_proc_write(snd_info_entry_t *entry, } } -static void snd_pcm_oss_proc_init(snd_pcm_t *pcm) +static void snd_pcm_oss_proc_init(struct snd_pcm *pcm) { int stream; for (stream = 0; stream < 2; ++stream) { - snd_info_entry_t *entry; - snd_pcm_str_t *pstr = &pcm->streams[stream]; + struct snd_info_entry *entry; + struct snd_pcm_str *pstr = &pcm->streams[stream]; if (pstr->substream_count == 0) continue; if ((entry = snd_info_create_card_entry(pcm->card, "oss", pstr->proc_root)) != NULL) { @@ -2414,11 +2414,11 @@ static void snd_pcm_oss_proc_init(snd_pcm_t *pcm) } } -static void snd_pcm_oss_proc_done(snd_pcm_t *pcm) +static void snd_pcm_oss_proc_done(struct snd_pcm *pcm) { int stream; for (stream = 0; stream < 2; ++stream) { - snd_pcm_str_t *pstr = &pcm->streams[stream]; + struct snd_pcm_str *pstr = &pcm->streams[stream]; if (pstr->oss.proc_entry) { snd_info_unregister(pstr->oss.proc_entry); pstr->oss.proc_entry = NULL; @@ -2444,13 +2444,13 @@ static struct file_operations snd_pcm_oss_f_reg = .mmap = snd_pcm_oss_mmap, }; -static snd_minor_t snd_pcm_oss_reg = +static struct snd_minor snd_pcm_oss_reg = { .comment = "digital audio", .f_ops = &snd_pcm_oss_f_reg, }; -static void register_oss_dsp(snd_pcm_t *pcm, int index) +static void register_oss_dsp(struct snd_pcm *pcm, int index) { char name[128]; sprintf(name, "dsp%i%i", pcm->card->number, pcm->device); @@ -2462,7 +2462,7 @@ static void register_oss_dsp(snd_pcm_t *pcm, int index) } } -static int snd_pcm_oss_register_minor(snd_pcm_t * pcm) +static int snd_pcm_oss_register_minor(struct snd_pcm *pcm) { pcm->oss.reg = 0; if (dsp_map[pcm->card->number] == (int)pcm->device) { @@ -2493,7 +2493,7 @@ static int snd_pcm_oss_register_minor(snd_pcm_t * pcm) return 0; } -static int snd_pcm_oss_disconnect_minor(snd_pcm_t * pcm) +static int snd_pcm_oss_disconnect_minor(struct snd_pcm *pcm) { if (pcm->oss.reg) { if (pcm->oss.reg_mask & 1) { @@ -2510,7 +2510,7 @@ static int snd_pcm_oss_disconnect_minor(snd_pcm_t * pcm) return 0; } -static int snd_pcm_oss_unregister_minor(snd_pcm_t * pcm) +static int snd_pcm_oss_unregister_minor(struct snd_pcm *pcm) { snd_pcm_oss_disconnect_minor(pcm); if (pcm->oss.reg) { @@ -2525,7 +2525,7 @@ static int snd_pcm_oss_unregister_minor(snd_pcm_t * pcm) return 0; } -static snd_pcm_notify_t snd_pcm_oss_notify = +static struct snd_pcm_notify snd_pcm_oss_notify = { .n_register = snd_pcm_oss_register_minor, .n_disconnect = snd_pcm_oss_disconnect_minor, diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c index 312ae1f..7e86768 100644 --- a/sound/core/oss/pcm_plugin.c +++ b/sound/core/oss/pcm_plugin.c @@ -36,7 +36,7 @@ #define snd_pcm_plug_first(plug) ((plug)->runtime->oss.plugin_first) #define snd_pcm_plug_last(plug) ((plug)->runtime->oss.plugin_last) -static int snd_pcm_plugin_src_channels_mask(snd_pcm_plugin_t *plugin, +static int snd_pcm_plugin_src_channels_mask(struct snd_pcm_plugin *plugin, unsigned long *dst_vmask, unsigned long **src_vmask) { @@ -46,7 +46,7 @@ static int snd_pcm_plugin_src_channels_mask(snd_pcm_plugin_t *plugin, return 0; } -static int snd_pcm_plugin_dst_channels_mask(snd_pcm_plugin_t *plugin, +static int snd_pcm_plugin_dst_channels_mask(struct snd_pcm_plugin *plugin, unsigned long *src_vmask, unsigned long **dst_vmask) { @@ -67,13 +67,13 @@ static int rate_match(unsigned int src_rate, unsigned int dst_rate) return dst_rate >= low && dst_rate <= high; } -static int snd_pcm_plugin_alloc(snd_pcm_plugin_t *plugin, snd_pcm_uframes_t frames) +static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t frames) { - snd_pcm_plugin_format_t *format; + struct snd_pcm_plugin_format *format; ssize_t width; size_t size; unsigned int channel; - snd_pcm_plugin_channel_t *c; + struct snd_pcm_plugin_channel *c; if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK) { format = &plugin->src_format; @@ -120,12 +120,12 @@ static int snd_pcm_plugin_alloc(snd_pcm_plugin_t *plugin, snd_pcm_uframes_t fram return 0; } -int snd_pcm_plug_alloc(snd_pcm_plug_t *plug, snd_pcm_uframes_t frames) +int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames) { int err; snd_assert(snd_pcm_plug_first(plug) != NULL, return -ENXIO); if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) { - snd_pcm_plugin_t *plugin = snd_pcm_plug_first(plug); + struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug); while (plugin->next) { if (plugin->dst_frames) frames = plugin->dst_frames(plugin, frames); @@ -136,7 +136,7 @@ int snd_pcm_plug_alloc(snd_pcm_plug_t *plug, snd_pcm_uframes_t frames) return err; } } else { - snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug); + struct snd_pcm_plugin *plugin = snd_pcm_plug_last(plug); while (plugin->prev) { if (plugin->src_frames) frames = plugin->src_frames(plugin, frames); @@ -151,22 +151,22 @@ int snd_pcm_plug_alloc(snd_pcm_plug_t *plug, snd_pcm_uframes_t frames) } -snd_pcm_sframes_t snd_pcm_plugin_client_channels(snd_pcm_plugin_t *plugin, +snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t frames, - snd_pcm_plugin_channel_t **channels) + struct snd_pcm_plugin_channel **channels) { *channels = plugin->buf_channels; return frames; } -int snd_pcm_plugin_build(snd_pcm_plug_t *plug, +int snd_pcm_plugin_build(struct snd_pcm_substream *plug, const char *name, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, size_t extra, - snd_pcm_plugin_t **ret) + struct snd_pcm_plugin **ret) { - snd_pcm_plugin_t *plugin; + struct snd_pcm_plugin *plugin; unsigned int channels; snd_assert(plug != NULL, return -ENXIO); @@ -210,7 +210,7 @@ int snd_pcm_plugin_build(snd_pcm_plug_t *plug, return 0; } -int snd_pcm_plugin_free(snd_pcm_plugin_t *plugin) +int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin) { if (! plugin) return 0; @@ -224,9 +224,9 @@ int snd_pcm_plugin_free(snd_pcm_plugin_t *plugin) return 0; } -snd_pcm_sframes_t snd_pcm_plug_client_size(snd_pcm_plug_t *plug, snd_pcm_uframes_t drv_frames) +snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t drv_frames) { - snd_pcm_plugin_t *plugin, *plugin_prev, *plugin_next; + struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next; int stream = snd_pcm_plug_stream(plug); snd_assert(plug != NULL, return -ENXIO); @@ -253,9 +253,9 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(snd_pcm_plug_t *plug, snd_pcm_uframes return drv_frames; } -snd_pcm_sframes_t snd_pcm_plug_slave_size(snd_pcm_plug_t *plug, snd_pcm_uframes_t clt_frames) +snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pcm_uframes_t clt_frames) { - snd_pcm_plugin_t *plugin, *plugin_prev, *plugin_next; + struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next; snd_pcm_sframes_t frames; int stream = snd_pcm_plug_stream(plug); @@ -290,9 +290,9 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(snd_pcm_plug_t *plug, snd_pcm_uframes_ return frames; } -static int snd_pcm_plug_formats(snd_mask_t *mask, int format) +static int snd_pcm_plug_formats(struct snd_mask *mask, int format) { - snd_mask_t formats = *mask; + struct snd_mask formats = *mask; u64 linfmts = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_BE | SNDRV_PCM_FMTBIT_S16_BE | @@ -326,7 +326,7 @@ static int preferred_formats[] = { SNDRV_PCM_FORMAT_U8 }; -int snd_pcm_plug_slave_format(int format, snd_mask_t *format_mask) +int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask) { if (snd_mask_test(format_mask, format)) return format; @@ -376,15 +376,15 @@ int snd_pcm_plug_slave_format(int format, snd_mask_t *format_mask) } } -int snd_pcm_plug_format_plugins(snd_pcm_plug_t *plug, - snd_pcm_hw_params_t *params, - snd_pcm_hw_params_t *slave_params) +int snd_pcm_plug_format_plugins(struct snd_pcm_substream *plug, + struct snd_pcm_hw_params *params, + struct snd_pcm_hw_params *slave_params) { - snd_pcm_plugin_format_t tmpformat; - snd_pcm_plugin_format_t dstformat; - snd_pcm_plugin_format_t srcformat; + struct snd_pcm_plugin_format tmpformat; + struct snd_pcm_plugin_format dstformat; + struct snd_pcm_plugin_format srcformat; int src_access, dst_access; - snd_pcm_plugin_t *plugin = NULL; + struct snd_pcm_plugin *plugin = NULL; int err; int stream = snd_pcm_plug_stream(plug); int slave_interleaved = (params_channels(slave_params) == 1 || @@ -462,7 +462,7 @@ int snd_pcm_plug_format_plugins(snd_pcm_plug_t *plug, if (srcformat.channels > dstformat.channels) { int sv = srcformat.channels; int dv = dstformat.channels; - route_ttable_entry_t *ttable = kcalloc(dv * sv, sizeof(*ttable), GFP_KERNEL); + int *ttable = kcalloc(dv * sv, sizeof(*ttable), GFP_KERNEL); if (ttable == NULL) return -ENOMEM; #if 1 @@ -525,7 +525,7 @@ int snd_pcm_plug_format_plugins(snd_pcm_plug_t *plug, if (srcformat.channels < dstformat.channels) { int sv = srcformat.channels; int dv = dstformat.channels; - route_ttable_entry_t *ttable = kcalloc(dv * sv, sizeof(*ttable), GFP_KERNEL); + int *ttable = kcalloc(dv * sv, sizeof(*ttable), GFP_KERNEL); if (ttable == NULL) return -ENOMEM; #if 0 @@ -614,14 +614,14 @@ int snd_pcm_plug_format_plugins(snd_pcm_plug_t *plug, return 0; } -snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(snd_pcm_plug_t *plug, +snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plug, char *buf, snd_pcm_uframes_t count, - snd_pcm_plugin_channel_t **channels) + struct snd_pcm_plugin_channel **channels) { - snd_pcm_plugin_t *plugin; - snd_pcm_plugin_channel_t *v; - snd_pcm_plugin_format_t *format; + struct snd_pcm_plugin *plugin; + struct snd_pcm_plugin_channel *v; + struct snd_pcm_plugin_format *format; int width, nchannels, channel; int stream = snd_pcm_plug_stream(plug); @@ -650,10 +650,10 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(snd_pcm_plug_t *plug, return count; } -static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug, +static int snd_pcm_plug_playback_channels_mask(struct snd_pcm_substream *plug, unsigned long *client_vmask) { - snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug); + struct snd_pcm_plugin *plugin = snd_pcm_plug_last(plug); if (plugin == NULL) { return 0; } else { @@ -678,10 +678,10 @@ static int snd_pcm_plug_playback_channels_mask(snd_pcm_plug_t *plug, } } -static int snd_pcm_plug_playback_disable_useless_channels(snd_pcm_plug_t *plug, - snd_pcm_plugin_channel_t *src_channels) +static int snd_pcm_plug_playback_disable_useless_channels(struct snd_pcm_substream *plug, + struct snd_pcm_plugin_channel *src_channels) { - snd_pcm_plugin_t *plugin = snd_pcm_plug_first(plug); + struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug); unsigned int nchannels = plugin->src_format.channels; DECLARE_BITMAP(bs, nchannels); unsigned long *srcmask = bs; @@ -703,11 +703,11 @@ static int snd_pcm_plug_playback_disable_useless_channels(snd_pcm_plug_t *plug, return 0; } -static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug, - snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *client_channels) +static int snd_pcm_plug_capture_disable_useless_channels(struct snd_pcm_substream *plug, + struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *client_channels) { - snd_pcm_plugin_t *plugin = snd_pcm_plug_last(plug); + struct snd_pcm_plugin *plugin = snd_pcm_plug_last(plug); unsigned int nchannels = plugin->dst_format.channels; DECLARE_BITMAP(bs, nchannels); unsigned long *dstmask = bs; @@ -736,10 +736,10 @@ static int snd_pcm_plug_capture_disable_useless_channels(snd_pcm_plug_t *plug, return 0; } -snd_pcm_sframes_t snd_pcm_plug_write_transfer(snd_pcm_plug_t *plug, snd_pcm_plugin_channel_t *src_channels, snd_pcm_uframes_t size) +snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *plug, struct snd_pcm_plugin_channel *src_channels, snd_pcm_uframes_t size) { - snd_pcm_plugin_t *plugin, *next; - snd_pcm_plugin_channel_t *dst_channels; + struct snd_pcm_plugin *plugin, *next; + struct snd_pcm_plugin_channel *dst_channels; int err; snd_pcm_sframes_t frames = size; @@ -771,10 +771,10 @@ snd_pcm_sframes_t snd_pcm_plug_write_transfer(snd_pcm_plug_t *plug, snd_pcm_plug return snd_pcm_plug_client_size(plug, frames); } -snd_pcm_sframes_t snd_pcm_plug_read_transfer(snd_pcm_plug_t *plug, snd_pcm_plugin_channel_t *dst_channels_final, snd_pcm_uframes_t size) +snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *plug, struct snd_pcm_plugin_channel *dst_channels_final, snd_pcm_uframes_t size) { - snd_pcm_plugin_t *plugin, *next; - snd_pcm_plugin_channel_t *src_channels, *dst_channels; + struct snd_pcm_plugin *plugin, *next; + struct snd_pcm_plugin_channel *src_channels, *dst_channels; snd_pcm_sframes_t frames = size; int err; @@ -806,7 +806,7 @@ snd_pcm_sframes_t snd_pcm_plug_read_transfer(snd_pcm_plug_t *plug, snd_pcm_plugi return frames; } -int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, size_t dst_offset, +int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_area, size_t dst_offset, size_t samples, int format) { /* FIXME: sub byte resolution and odd dst_offset */ @@ -852,8 +852,8 @@ int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_area, size_t dst_offs return 0; } -int snd_pcm_area_copy(const snd_pcm_channel_area_t *src_area, size_t src_offset, - const snd_pcm_channel_area_t *dst_area, size_t dst_offset, +int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_area, size_t src_offset, + const struct snd_pcm_channel_area *dst_area, size_t dst_offset, size_t samples, int format) { /* FIXME: sub byte resolution and odd dst_offset */ diff --git a/sound/core/oss/pcm_plugin.h b/sound/core/oss/pcm_plugin.h index 69a4317..29198da 100644 --- a/sound/core/oss/pcm_plugin.h +++ b/sound/core/oss/pcm_plugin.h @@ -29,147 +29,157 @@ static inline unsigned long *bitmap_alloc(unsigned int nbits) return kmalloc(BITS_TO_LONGS(nbits), GFP_KERNEL); } -#define snd_pcm_plug_t snd_pcm_substream_t #define snd_pcm_plug_stream(plug) ((plug)->stream) -typedef enum { +enum snd_pcm_plugin_action { INIT = 0, PREPARE = 1, -} snd_pcm_plugin_action_t; +}; -typedef struct _snd_pcm_channel_area { +struct snd_pcm_channel_area { void *addr; /* base address of channel samples */ unsigned int first; /* offset to first sample in bits */ unsigned int step; /* samples distance in bits */ -} snd_pcm_channel_area_t; +}; -typedef struct _snd_pcm_plugin_channel { +struct snd_pcm_plugin_channel { void *aptr; /* pointer to the allocated area */ - snd_pcm_channel_area_t area; + struct snd_pcm_channel_area area; snd_pcm_uframes_t frames; /* allocated frames */ unsigned int enabled:1; /* channel need to be processed */ unsigned int wanted:1; /* channel is wanted */ -} snd_pcm_plugin_channel_t; +}; -typedef struct _snd_pcm_plugin_format { +struct snd_pcm_plugin_format { int format; unsigned int rate; unsigned int channels; -} snd_pcm_plugin_format_t; +}; -struct _snd_pcm_plugin { +struct snd_pcm_plugin { const char *name; /* plug-in name */ int stream; - snd_pcm_plugin_format_t src_format; /* source format */ - snd_pcm_plugin_format_t dst_format; /* destination format */ + struct snd_pcm_plugin_format src_format; /* source format */ + struct snd_pcm_plugin_format dst_format; /* destination format */ int src_width; /* sample width in bits */ int dst_width; /* sample width in bits */ int access; - snd_pcm_sframes_t (*src_frames)(snd_pcm_plugin_t *plugin, snd_pcm_uframes_t dst_frames); - snd_pcm_sframes_t (*dst_frames)(snd_pcm_plugin_t *plugin, snd_pcm_uframes_t src_frames); - snd_pcm_sframes_t (*client_channels)(snd_pcm_plugin_t *plugin, - snd_pcm_uframes_t frames, - snd_pcm_plugin_channel_t **channels); - int (*src_channels_mask)(snd_pcm_plugin_t *plugin, + snd_pcm_sframes_t (*src_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t dst_frames); + snd_pcm_sframes_t (*dst_frames)(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t src_frames); + snd_pcm_sframes_t (*client_channels)(struct snd_pcm_plugin *plugin, + snd_pcm_uframes_t frames, + struct snd_pcm_plugin_channel **channels); + int (*src_channels_mask)(struct snd_pcm_plugin *plugin, unsigned long *dst_vmask, unsigned long **src_vmask); - int (*dst_channels_mask)(snd_pcm_plugin_t *plugin, + int (*dst_channels_mask)(struct snd_pcm_plugin *plugin, unsigned long *src_vmask, unsigned long **dst_vmask); - snd_pcm_sframes_t (*transfer)(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, - snd_pcm_uframes_t frames); - int (*action)(snd_pcm_plugin_t *plugin, - snd_pcm_plugin_action_t action, + snd_pcm_sframes_t (*transfer)(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, + snd_pcm_uframes_t frames); + int (*action)(struct snd_pcm_plugin *plugin, + enum snd_pcm_plugin_action action, unsigned long data); - snd_pcm_plugin_t *prev; - snd_pcm_plugin_t *next; - snd_pcm_plug_t *plug; + struct snd_pcm_plugin *prev; + struct snd_pcm_plugin *next; + struct snd_pcm_substream *plug; void *private_data; - void (*private_free)(snd_pcm_plugin_t *plugin); + void (*private_free)(struct snd_pcm_plugin *plugin); char *buf; snd_pcm_uframes_t buf_frames; - snd_pcm_plugin_channel_t *buf_channels; + struct snd_pcm_plugin_channel *buf_channels; unsigned long *src_vmask; unsigned long *dst_vmask; char extra_data[0]; }; -int snd_pcm_plugin_build(snd_pcm_plug_t *handle, +int snd_pcm_plugin_build(struct snd_pcm_substream *handle, const char *name, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, size_t extra, - snd_pcm_plugin_t **ret); -int snd_pcm_plugin_free(snd_pcm_plugin_t *plugin); -int snd_pcm_plugin_clear(snd_pcm_plugin_t **first); -int snd_pcm_plug_alloc(snd_pcm_plug_t *plug, snd_pcm_uframes_t frames); -snd_pcm_sframes_t snd_pcm_plug_client_size(snd_pcm_plug_t *handle, snd_pcm_uframes_t drv_size); -snd_pcm_sframes_t snd_pcm_plug_slave_size(snd_pcm_plug_t *handle, snd_pcm_uframes_t clt_size); + struct snd_pcm_plugin **ret); +int snd_pcm_plugin_free(struct snd_pcm_plugin *plugin); +int snd_pcm_plugin_clear(struct snd_pcm_plugin **first); +int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames); +snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t drv_size); +snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *handle, snd_pcm_uframes_t clt_size); #define FULL ROUTE_PLUGIN_RESOLUTION #define HALF ROUTE_PLUGIN_RESOLUTION / 2 -typedef int route_ttable_entry_t; - -int snd_pcm_plugin_build_io(snd_pcm_plug_t *handle, - snd_pcm_hw_params_t *params, - snd_pcm_plugin_t **r_plugin); -int snd_pcm_plugin_build_linear(snd_pcm_plug_t *handle, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin); -int snd_pcm_plugin_build_mulaw(snd_pcm_plug_t *handle, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin); -int snd_pcm_plugin_build_rate(snd_pcm_plug_t *handle, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin); -int snd_pcm_plugin_build_route(snd_pcm_plug_t *handle, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - route_ttable_entry_t *ttable, - snd_pcm_plugin_t **r_plugin); -int snd_pcm_plugin_build_copy(snd_pcm_plug_t *handle, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin); - -int snd_pcm_plug_format_plugins(snd_pcm_plug_t *substream, - snd_pcm_hw_params_t *params, - snd_pcm_hw_params_t *slave_params); - -int snd_pcm_plug_slave_format(int format, snd_mask_t *format_mask); - -int snd_pcm_plugin_append(snd_pcm_plugin_t *plugin); - -snd_pcm_sframes_t snd_pcm_plug_write_transfer(snd_pcm_plug_t *handle, snd_pcm_plugin_channel_t *src_channels, snd_pcm_uframes_t size); -snd_pcm_sframes_t snd_pcm_plug_read_transfer(snd_pcm_plug_t *handle, snd_pcm_plugin_channel_t *dst_channels_final, snd_pcm_uframes_t size); - -snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(snd_pcm_plug_t *handle, - char *buf, snd_pcm_uframes_t count, - snd_pcm_plugin_channel_t **channels); - -snd_pcm_sframes_t snd_pcm_plugin_client_channels(snd_pcm_plugin_t *plugin, - snd_pcm_uframes_t frames, - snd_pcm_plugin_channel_t **channels); - -int snd_pcm_area_silence(const snd_pcm_channel_area_t *dst_channel, size_t dst_offset, + +int snd_pcm_plugin_build_io(struct snd_pcm_substream *handle, + struct snd_pcm_hw_params *params, + struct snd_pcm_plugin **r_plugin); +int snd_pcm_plugin_build_linear(struct snd_pcm_substream *handle, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin); +int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *handle, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin); +int snd_pcm_plugin_build_rate(struct snd_pcm_substream *handle, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin); +int snd_pcm_plugin_build_route(struct snd_pcm_substream *handle, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + int *ttable, + struct snd_pcm_plugin **r_plugin); +int snd_pcm_plugin_build_copy(struct snd_pcm_substream *handle, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin); + +int snd_pcm_plug_format_plugins(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_pcm_hw_params *slave_params); + +int snd_pcm_plug_slave_format(int format, struct snd_mask *format_mask); + +int snd_pcm_plugin_append(struct snd_pcm_plugin *plugin); + +snd_pcm_sframes_t snd_pcm_plug_write_transfer(struct snd_pcm_substream *handle, + struct snd_pcm_plugin_channel *src_channels, + snd_pcm_uframes_t size); +snd_pcm_sframes_t snd_pcm_plug_read_transfer(struct snd_pcm_substream *handle, + struct snd_pcm_plugin_channel *dst_channels_final, + snd_pcm_uframes_t size); + +snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *handle, + char *buf, snd_pcm_uframes_t count, + struct snd_pcm_plugin_channel **channels); + +snd_pcm_sframes_t snd_pcm_plugin_client_channels(struct snd_pcm_plugin *plugin, + snd_pcm_uframes_t frames, + struct snd_pcm_plugin_channel **channels); + +int snd_pcm_area_silence(const struct snd_pcm_channel_area *dst_channel, + size_t dst_offset, size_t samples, int format); -int snd_pcm_area_copy(const snd_pcm_channel_area_t *src_channel, size_t src_offset, - const snd_pcm_channel_area_t *dst_channel, size_t dst_offset, +int snd_pcm_area_copy(const struct snd_pcm_channel_area *src_channel, + size_t src_offset, + const struct snd_pcm_channel_area *dst_channel, + size_t dst_offset, size_t samples, int format); -void *snd_pcm_plug_buf_alloc(snd_pcm_plug_t *plug, snd_pcm_uframes_t size); -void snd_pcm_plug_buf_unlock(snd_pcm_plug_t *plug, void *ptr); -snd_pcm_sframes_t snd_pcm_oss_write3(snd_pcm_substream_t *substream, const char *ptr, snd_pcm_uframes_t size, int in_kernel); -snd_pcm_sframes_t snd_pcm_oss_read3(snd_pcm_substream_t *substream, char *ptr, snd_pcm_uframes_t size, int in_kernel); -snd_pcm_sframes_t snd_pcm_oss_writev3(snd_pcm_substream_t *substream, void **bufs, snd_pcm_uframes_t frames, int in_kernel); -snd_pcm_sframes_t snd_pcm_oss_readv3(snd_pcm_substream_t *substream, void **bufs, snd_pcm_uframes_t frames, int in_kernel); - - +void *snd_pcm_plug_buf_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t size); +void snd_pcm_plug_buf_unlock(struct snd_pcm_substream *plug, void *ptr); +snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, + const char *ptr, snd_pcm_uframes_t size, + int in_kernel); +snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, + char *ptr, snd_pcm_uframes_t size, int in_kernel); +snd_pcm_sframes_t snd_pcm_oss_writev3(struct snd_pcm_substream *substream, + void **bufs, snd_pcm_uframes_t frames, + int in_kernel); +snd_pcm_sframes_t snd_pcm_oss_readv3(struct snd_pcm_substream *substream, + void **bufs, snd_pcm_uframes_t frames, + int in_kernel); #define ROUTE_PLUGIN_RESOLUTION 16 @@ -177,8 +187,8 @@ int getput_index(int format); int copy_index(int format); int conv_index(int src_format, int dst_format); -void zero_channel(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *dst_channel, +void zero_channel(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *dst_channel, size_t samples); #ifdef PLUGIN_DEBUG diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c index 7e325ca..4854cef 100644 --- a/sound/core/oss/rate.c +++ b/sound/core/oss/rate.c @@ -33,29 +33,29 @@ * Basic rate conversion plugin */ -typedef struct { +struct rate_channel { signed short last_S1; signed short last_S2; -} rate_channel_t; +}; -typedef void (*rate_f)(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +typedef void (*rate_f)(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, int src_frames, int dst_frames); -typedef struct rate_private_data { +struct rate_priv { unsigned int pitch; unsigned int pos; rate_f func; int get, put; snd_pcm_sframes_t old_src_frames, old_dst_frames; - rate_channel_t channels[0]; -} rate_t; + struct rate_channel channels[0]; +}; -static void rate_init(snd_pcm_plugin_t *plugin) +static void rate_init(struct snd_pcm_plugin *plugin) { unsigned int channel; - rate_t *data = (rate_t *)plugin->extra_data; + struct rate_priv *data = (struct rate_priv *)plugin->extra_data; data->pos = 0; for (channel = 0; channel < plugin->src_format.channels; channel++) { data->channels[channel].last_S1 = 0; @@ -63,9 +63,9 @@ static void rate_init(snd_pcm_plugin_t *plugin) } } -static void resample_expand(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static void resample_expand(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, int src_frames, int dst_frames) { unsigned int pos = 0; @@ -75,8 +75,8 @@ static void resample_expand(snd_pcm_plugin_t *plugin, unsigned int channel; int src_step, dst_step; int src_frames1, dst_frames1; - rate_t *data = (rate_t *)plugin->extra_data; - rate_channel_t *rchannels = data->channels; + struct rate_priv *data = (struct rate_priv *)plugin->extra_data; + struct rate_channel *rchannels = data->channels; #define GET_S16_LABELS #define PUT_S16_LABELS @@ -139,9 +139,9 @@ static void resample_expand(snd_pcm_plugin_t *plugin, data->pos = pos; } -static void resample_shrink(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static void resample_shrink(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, int src_frames, int dst_frames) { unsigned int pos = 0; @@ -151,8 +151,8 @@ static void resample_shrink(snd_pcm_plugin_t *plugin, unsigned int channel; int src_step, dst_step; int src_frames1, dst_frames1; - rate_t *data = (rate_t *)plugin->extra_data; - rate_channel_t *rchannels = data->channels; + struct rate_priv *data = (struct rate_priv *)plugin->extra_data; + struct rate_channel *rchannels = data->channels; #define GET_S16_LABELS #define PUT_S16_LABELS @@ -216,15 +216,15 @@ static void resample_shrink(snd_pcm_plugin_t *plugin, data->pos = pos; } -static snd_pcm_sframes_t rate_src_frames(snd_pcm_plugin_t *plugin, snd_pcm_uframes_t frames) +static snd_pcm_sframes_t rate_src_frames(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t frames) { - rate_t *data; + struct rate_priv *data; snd_pcm_sframes_t res; snd_assert(plugin != NULL, return -ENXIO); if (frames == 0) return 0; - data = (rate_t *)plugin->extra_data; + data = (struct rate_priv *)plugin->extra_data; if (plugin->src_format.rate < plugin->dst_format.rate) { res = (((frames * data->pitch) + (BITS/2)) >> SHIFT); } else { @@ -248,15 +248,15 @@ static snd_pcm_sframes_t rate_src_frames(snd_pcm_plugin_t *plugin, snd_pcm_ufram return res; } -static snd_pcm_sframes_t rate_dst_frames(snd_pcm_plugin_t *plugin, snd_pcm_uframes_t frames) +static snd_pcm_sframes_t rate_dst_frames(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t frames) { - rate_t *data; + struct rate_priv *data; snd_pcm_sframes_t res; snd_assert(plugin != NULL, return -ENXIO); if (frames == 0) return 0; - data = (rate_t *)plugin->extra_data; + data = (struct rate_priv *)plugin->extra_data; if (plugin->src_format.rate < plugin->dst_format.rate) { res = (((frames << SHIFT) + (data->pitch / 2)) / data->pitch); } else { @@ -280,13 +280,13 @@ static snd_pcm_sframes_t rate_dst_frames(snd_pcm_plugin_t *plugin, snd_pcm_ufram return res; } -static snd_pcm_sframes_t rate_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static snd_pcm_sframes_t rate_transfer(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { snd_pcm_uframes_t dst_frames; - rate_t *data; + struct rate_priv *data; snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); if (frames == 0) @@ -308,13 +308,13 @@ static snd_pcm_sframes_t rate_transfer(snd_pcm_plugin_t *plugin, dst_frames = rate_dst_frames(plugin, frames); if (dst_frames > dst_channels[0].frames) dst_frames = dst_channels[0].frames; - data = (rate_t *)plugin->extra_data; + data = (struct rate_priv *)plugin->extra_data; data->func(plugin, src_channels, dst_channels, frames, dst_frames); return dst_frames; } -static int rate_action(snd_pcm_plugin_t *plugin, - snd_pcm_plugin_action_t action, +static int rate_action(struct snd_pcm_plugin *plugin, + enum snd_pcm_plugin_action action, unsigned long udata) { snd_assert(plugin != NULL, return -ENXIO); @@ -329,14 +329,14 @@ static int rate_action(snd_pcm_plugin_t *plugin, return 0; /* silenty ignore other actions */ } -int snd_pcm_plugin_build_rate(snd_pcm_plug_t *plug, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - snd_pcm_plugin_t **r_plugin) +int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + struct snd_pcm_plugin **r_plugin) { int err; - rate_t *data; - snd_pcm_plugin_t *plugin; + struct rate_priv *data; + struct snd_pcm_plugin *plugin; snd_assert(r_plugin != NULL, return -ENXIO); *r_plugin = NULL; @@ -349,11 +349,12 @@ int snd_pcm_plugin_build_rate(snd_pcm_plug_t *plug, err = snd_pcm_plugin_build(plug, "rate conversion", src_format, dst_format, - sizeof(rate_t) + src_format->channels * sizeof(rate_channel_t), + sizeof(struct rate_priv) + + src_format->channels * sizeof(struct rate_channel), &plugin); if (err < 0) return err; - data = (rate_t *)plugin->extra_data; + data = (struct rate_priv *)plugin->extra_data; data->get = getput_index(src_format->format); snd_assert(data->get >= 0 && data->get < 4*2*2, return -EINVAL); data->put = getput_index(dst_format->format); diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c index 7519aed..726c5ca 100644 --- a/sound/core/oss/route.c +++ b/sound/core/oss/route.c @@ -35,61 +35,62 @@ #error "Add some code here" #endif -typedef struct ttable_dst ttable_dst_t; -typedef struct route_private_data route_t; +struct ttable_dst; -typedef void (*route_channel_f)(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channel, - ttable_dst_t* ttable, snd_pcm_uframes_t frames); +typedef void (*route_channel_f)(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channel, + struct ttable_dst *ttable, snd_pcm_uframes_t frames); -typedef struct { +struct ttable_src { int channel; int as_int; -} ttable_src_t; +}; struct ttable_dst { int att; /* Attenuated */ unsigned int nsrcs; - ttable_src_t* srcs; + struct ttable_src *srcs; route_channel_f func; }; -struct route_private_data { +struct route_priv { enum {R_UINT32=0, R_UINT64=1} sum_type; int get, put; int conv; int src_sample_size; - ttable_dst_t ttable[0]; + struct ttable_dst ttable[0]; }; -typedef union { +union sum { u_int32_t as_uint32; u_int64_t as_uint64; -} sum_t; +}; -static void route_to_channel_from_zero(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channel, - ttable_dst_t* ttable, snd_pcm_uframes_t frames) +static void route_to_channel_from_zero(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channel, + struct ttable_dst *ttable, + snd_pcm_uframes_t frames) { if (dst_channel->wanted) snd_pcm_area_silence(&dst_channel->area, 0, frames, plugin->dst_format.format); dst_channel->enabled = 0; } -static void route_to_channel_from_one(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channel, - ttable_dst_t* ttable, snd_pcm_uframes_t frames) +static void route_to_channel_from_one(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channel, + struct ttable_dst *ttable, + snd_pcm_uframes_t frames) { #define CONV_LABELS #include "plugin_ops.h" #undef CONV_LABELS - route_t *data = (route_t *)plugin->extra_data; + struct route_priv *data = (struct route_priv *)plugin->extra_data; void *conv; - const snd_pcm_plugin_channel_t *src_channel = NULL; + const struct snd_pcm_plugin_channel *src_channel = NULL; unsigned int srcidx; char *src, *dst; int src_step, dst_step; @@ -120,10 +121,10 @@ static void route_to_channel_from_one(snd_pcm_plugin_t *plugin, } } -static void route_to_channel(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channel, - ttable_dst_t* ttable, snd_pcm_uframes_t frames) +static void route_to_channel(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channel, + struct ttable_dst *ttable, snd_pcm_uframes_t frames) { #define GET_U_LABELS #define PUT_U32_LABELS @@ -153,18 +154,18 @@ static void route_to_channel(snd_pcm_plugin_t *plugin, &&norm_int64_16_att, &&norm_int64_24_att, }; - route_t *data = (route_t *)plugin->extra_data; + struct route_priv *data = (struct route_priv *)plugin->extra_data; void *zero, *get, *add, *norm, *put_u32; int nsrcs = ttable->nsrcs; char *dst; int dst_step; char *srcs[nsrcs]; int src_steps[nsrcs]; - ttable_src_t src_tt[nsrcs]; + struct ttable_src src_tt[nsrcs]; u_int32_t sample = 0; int srcidx, srcidx1 = 0; for (srcidx = 0; srcidx < nsrcs; ++srcidx) { - const snd_pcm_plugin_channel_t *src_channel = &src_channels[ttable->srcs[srcidx].channel]; + const struct snd_pcm_plugin_channel *src_channel = &src_channels[ttable->srcs[srcidx].channel]; if (!src_channel->enabled) continue; srcs[srcidx1] = src_channel->area.addr + src_channel->area.first / 8; @@ -191,8 +192,8 @@ static void route_to_channel(snd_pcm_plugin_t *plugin, dst_step = dst_channel->area.step / 8; while (frames-- > 0) { - ttable_src_t *ttp = src_tt; - sum_t sum; + struct ttable_src *ttp = src_tt; + union sum sum; /* Zero sum */ goto *zero; @@ -297,20 +298,20 @@ static void route_to_channel(snd_pcm_plugin_t *plugin, } } -static int route_src_channels_mask(snd_pcm_plugin_t *plugin, +static int route_src_channels_mask(struct snd_pcm_plugin *plugin, unsigned long *dst_vmask, unsigned long **src_vmask) { - route_t *data = (route_t *)plugin->extra_data; + struct route_priv *data = (struct route_priv *)plugin->extra_data; int schannels = plugin->src_format.channels; int dchannels = plugin->dst_format.channels; unsigned long *vmask = plugin->src_vmask; int channel; - ttable_dst_t *dp = data->ttable; + struct ttable_dst *dp = data->ttable; bitmap_zero(vmask, schannels); for (channel = 0; channel < dchannels; channel++, dp++) { unsigned int src; - ttable_src_t *sp; + struct ttable_src *sp; if (!test_bit(channel, dst_vmask)) continue; sp = dp->srcs; @@ -321,19 +322,19 @@ static int route_src_channels_mask(snd_pcm_plugin_t *plugin, return 0; } -static int route_dst_channels_mask(snd_pcm_plugin_t *plugin, +static int route_dst_channels_mask(struct snd_pcm_plugin *plugin, unsigned long *src_vmask, unsigned long **dst_vmask) { - route_t *data = (route_t *)plugin->extra_data; + struct route_priv *data = (struct route_priv *)plugin->extra_data; int dchannels = plugin->dst_format.channels; unsigned long *vmask = plugin->dst_vmask; int channel; - ttable_dst_t *dp = data->ttable; + struct ttable_dst *dp = data->ttable; bitmap_zero(vmask, dchannels); for (channel = 0; channel < dchannels; channel++, dp++) { unsigned int src; - ttable_src_t *sp; + struct ttable_src *sp; sp = dp->srcs; for (src = 0; src < dp->nsrcs; src++, sp++) { if (test_bit(sp->channel, src_vmask)) { @@ -346,33 +347,33 @@ static int route_dst_channels_mask(snd_pcm_plugin_t *plugin, return 0; } -static void route_free(snd_pcm_plugin_t *plugin) +static void route_free(struct snd_pcm_plugin *plugin) { - route_t *data = (route_t *)plugin->extra_data; + struct route_priv *data = (struct route_priv *)plugin->extra_data; unsigned int dst_channel; for (dst_channel = 0; dst_channel < plugin->dst_format.channels; ++dst_channel) { kfree(data->ttable[dst_channel].srcs); } } -static int route_load_ttable(snd_pcm_plugin_t *plugin, - const route_ttable_entry_t* src_ttable) +static int route_load_ttable(struct snd_pcm_plugin *plugin, + const int *src_ttable) { - route_t *data; + struct route_priv *data; unsigned int src_channel, dst_channel; - const route_ttable_entry_t *sptr; - ttable_dst_t *dptr; + const int *sptr; + struct ttable_dst *dptr; if (src_ttable == NULL) return 0; - data = (route_t *)plugin->extra_data; + data = (struct route_priv *)plugin->extra_data; dptr = data->ttable; sptr = src_ttable; plugin->private_free = route_free; for (dst_channel = 0; dst_channel < plugin->dst_format.channels; ++dst_channel) { - route_ttable_entry_t t = 0; + int t = 0; int att = 0; int nsrcs = 0; - ttable_src_t srcs[plugin->src_format.channels]; + struct ttable_src srcs[plugin->src_format.channels]; for (src_channel = 0; src_channel < plugin->src_format.channels; ++src_channel) { snd_assert(*sptr >= 0 || *sptr <= FULL, return -ENXIO); if (*sptr != 0) { @@ -405,21 +406,21 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin, return 0; } -static snd_pcm_sframes_t route_transfer(snd_pcm_plugin_t *plugin, - const snd_pcm_plugin_channel_t *src_channels, - snd_pcm_plugin_channel_t *dst_channels, +static snd_pcm_sframes_t route_transfer(struct snd_pcm_plugin *plugin, + const struct snd_pcm_plugin_channel *src_channels, + struct snd_pcm_plugin_channel *dst_channels, snd_pcm_uframes_t frames) { - route_t *data; + struct route_priv *data; int src_nchannels, dst_nchannels; int dst_channel; - ttable_dst_t *ttp; - snd_pcm_plugin_channel_t *dvp; + struct ttable_dst *ttp; + struct snd_pcm_plugin_channel *dvp; snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); if (frames == 0) return 0; - data = (route_t *)plugin->extra_data; + data = (struct route_priv *)plugin->extra_data; src_nchannels = plugin->src_format.channels; dst_nchannels = plugin->dst_format.channels; @@ -469,14 +470,14 @@ int getput_index(int format) return width * 4 + endian * 2 + sign; } -int snd_pcm_plugin_build_route(snd_pcm_plug_t *plug, - snd_pcm_plugin_format_t *src_format, - snd_pcm_plugin_format_t *dst_format, - route_ttable_entry_t *ttable, - snd_pcm_plugin_t **r_plugin) +int snd_pcm_plugin_build_route(struct snd_pcm_substream *plug, + struct snd_pcm_plugin_format *src_format, + struct snd_pcm_plugin_format *dst_format, + int *ttable, + struct snd_pcm_plugin **r_plugin) { - route_t *data; - snd_pcm_plugin_t *plugin; + struct route_priv *data; + struct snd_pcm_plugin *plugin; int err; snd_assert(r_plugin != NULL, return -ENXIO); @@ -488,12 +489,13 @@ int snd_pcm_plugin_build_route(snd_pcm_plug_t *plug, err = snd_pcm_plugin_build(plug, "attenuated route conversion", src_format, dst_format, - sizeof(route_t) + sizeof(data->ttable[0]) * dst_format->channels, + sizeof(struct route_priv) + + sizeof(data->ttable[0]) * dst_format->channels, &plugin); if (err < 0) return err; - data = (route_t *) plugin->extra_data; + data = (struct route_priv *)plugin->extra_data; data->get = getput_index(src_format->format); snd_assert(data->get >= 0 && data->get < 4*2*2, return -EINVAL); -- cgit v1.1 From c7e0b5bf9fff1b726495081447c107a2333fb82c Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:04:02 +0100 Subject: [ALSA] Remove xxx_t typedefs: Sequencer Modules: ALSA sequencer Remove xxx_t typedefs from the core sequencer codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/asequencer.h | 368 ++++++++++++++++---------------- include/sound/seq_device.h | 18 +- include/sound/seq_instr.h | 64 +++--- include/sound/seq_kernel.h | 119 +++-------- include/sound/seq_midi_emul.h | 44 ++-- include/sound/seq_midi_event.h | 22 +- include/sound/seq_virmidi.h | 22 +- sound/core/seq/seq_clientmgr.c | 460 ++++++++++++++++++++++------------------ sound/core/seq/seq_clientmgr.h | 42 ++-- sound/core/seq/seq_compat.c | 22 +- sound/core/seq/seq_device.c | 120 ++++++----- sound/core/seq/seq_dummy.c | 31 +-- sound/core/seq/seq_fifo.c | 40 ++-- sound/core/seq/seq_fifo.h | 26 +-- sound/core/seq/seq_info.c | 13 +- sound/core/seq/seq_info.h | 6 +- sound/core/seq/seq_instr.c | 162 +++++++------- sound/core/seq/seq_memory.c | 71 ++++--- sound/core/seq/seq_memory.h | 37 ++-- sound/core/seq/seq_midi.c | 102 ++++----- sound/core/seq/seq_midi_emul.c | 86 ++++---- sound/core/seq/seq_midi_event.c | 98 +++++---- sound/core/seq/seq_ports.c | 152 +++++++------ sound/core/seq/seq_ports.h | 64 +++--- sound/core/seq/seq_prioq.c | 52 ++--- sound/core/seq/seq_prioq.h | 26 +-- sound/core/seq/seq_queue.c | 105 ++++----- sound/core/seq/seq_queue.h | 22 +- sound/core/seq/seq_system.c | 18 +- sound/core/seq/seq_system.h | 2 +- sound/core/seq/seq_timer.c | 68 +++--- sound/core/seq/seq_timer.h | 54 ++--- sound/core/seq/seq_virmidi.c | 106 ++++----- 33 files changed, 1363 insertions(+), 1279 deletions(-) diff --git a/include/sound/asequencer.h b/include/sound/asequencer.h index 562637b..59485be 100644 --- a/include/sound/asequencer.h +++ b/include/sound/asequencer.h @@ -35,13 +35,13 @@ */ /** system messages - * event data type = #sndrv_seq_result_t + * event data type = #snd_seq_result */ #define SNDRV_SEQ_EVENT_SYSTEM 0 #define SNDRV_SEQ_EVENT_RESULT 1 /** note messages (channel specific) - * event data type = #sndrv_seq_ev_note + * event data type = #snd_seq_ev_note */ #define SNDRV_SEQ_EVENT_NOTE 5 #define SNDRV_SEQ_EVENT_NOTEON 6 @@ -49,7 +49,7 @@ #define SNDRV_SEQ_EVENT_KEYPRESS 8 /** control messages (channel specific) - * event data type = #sndrv_seq_ev_ctrl + * event data type = #snd_seq_ev_ctrl */ #define SNDRV_SEQ_EVENT_CONTROLLER 10 #define SNDRV_SEQ_EVENT_PGMCHANGE 11 @@ -60,7 +60,7 @@ #define SNDRV_SEQ_EVENT_REGPARAM 16 /**< 14 bit RPN address + 14 bit unsigned value */ /** synchronisation messages - * event data type = #sndrv_seq_ev_ctrl + * event data type = #snd_seq_ev_ctrl */ #define SNDRV_SEQ_EVENT_SONGPOS 20 /* Song Position Pointer with LSB and MSB values */ #define SNDRV_SEQ_EVENT_SONGSEL 21 /* Song Select with song ID number */ @@ -69,7 +69,7 @@ #define SNDRV_SEQ_EVENT_KEYSIGN 24 /* SMF Key Signature event */ /** timer messages - * event data type = sndrv_seq_ev_queue_control_t + * event data type = snd_seq_ev_queue_control */ #define SNDRV_SEQ_EVENT_START 30 /* midi Real Time Start message */ #define SNDRV_SEQ_EVENT_CONTINUE 31 /* midi Real Time Continue message */ @@ -95,7 +95,7 @@ #define SNDRV_SEQ_EVENT_OSS 51 /* OSS raw event */ /** system status messages (broadcast for subscribers) - * event data type = sndrv_seq_addr_t + * event data type = snd_seq_addr */ #define SNDRV_SEQ_EVENT_CLIENT_START 60 /* new client has connected */ #define SNDRV_SEQ_EVENT_CLIENT_EXIT 61 /* client has left the system */ @@ -105,13 +105,13 @@ #define SNDRV_SEQ_EVENT_PORT_CHANGE 65 /* port status/info has changed */ /** port connection changes - * event data type = sndrv_seq_connect_t + * event data type = snd_seq_connect */ #define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED 66 /* ports connected */ #define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67 /* ports disconnected */ /** synthesizer events - * event data type = sndrv_seq_eve_sample_control_t + * event data type = snd_seq_eve_sample_control */ #define SNDRV_SEQ_EVENT_SAMPLE 70 /* sample select */ #define SNDRV_SEQ_EVENT_SAMPLE_CLUSTER 71 /* sample cluster select */ @@ -162,7 +162,7 @@ /* 119-129: reserved */ /* 130-139: variable length events - * event data type = sndrv_seq_ev_ext + * event data type = snd_seq_ev_ext * (SNDRV_SEQ_EVENT_LENGTH_VARIABLE must be set) */ #define SNDRV_SEQ_EVENT_SYSEX 130 /* system exclusive data (variable length) */ @@ -186,18 +186,18 @@ #define SNDRV_SEQ_EVENT_NONE 255 -typedef unsigned char sndrv_seq_event_type_t; +typedef unsigned char snd_seq_event_type_t; /** event address */ -struct sndrv_seq_addr { +struct snd_seq_addr { unsigned char client; /**< Client number: 0..255, 255 = broadcast to all clients */ unsigned char port; /**< Port within client: 0..255, 255 = broadcast to all ports */ }; /** port connection */ -struct sndrv_seq_connect { - struct sndrv_seq_addr sender; - struct sndrv_seq_addr dest; +struct snd_seq_connect { + struct snd_seq_addr sender; + struct snd_seq_addr dest; }; @@ -226,7 +226,7 @@ struct sndrv_seq_connect { /* note event */ -struct sndrv_seq_ev_note { +struct snd_seq_ev_note { unsigned char channel; unsigned char note; unsigned char velocity; @@ -235,7 +235,7 @@ struct sndrv_seq_ev_note { }; /* controller event */ -struct sndrv_seq_ev_ctrl { +struct snd_seq_ev_ctrl { unsigned char channel; unsigned char unused1, unused2, unused3; /* pad */ unsigned int param; @@ -243,59 +243,59 @@ struct sndrv_seq_ev_ctrl { }; /* generic set of bytes (12x8 bit) */ -struct sndrv_seq_ev_raw8 { +struct snd_seq_ev_raw8 { unsigned char d[12]; /* 8 bit value */ }; /* generic set of integers (3x32 bit) */ -struct sndrv_seq_ev_raw32 { +struct snd_seq_ev_raw32 { unsigned int d[3]; /* 32 bit value */ }; /* external stored data */ -struct sndrv_seq_ev_ext { +struct snd_seq_ev_ext { unsigned int len; /* length of data */ void *ptr; /* pointer to data (note: maybe 64-bit) */ } __attribute__((packed)); /* Instrument cluster type */ -typedef unsigned int sndrv_seq_instr_cluster_t; +typedef unsigned int snd_seq_instr_cluster_t; /* Instrument type */ -struct sndrv_seq_instr { - sndrv_seq_instr_cluster_t cluster; +struct snd_seq_instr { + snd_seq_instr_cluster_t cluster; unsigned int std; /* the upper byte means a private instrument (owner - client #) */ unsigned short bank; unsigned short prg; }; /* sample number */ -struct sndrv_seq_ev_sample { +struct snd_seq_ev_sample { unsigned int std; unsigned short bank; unsigned short prg; }; /* sample cluster */ -struct sndrv_seq_ev_cluster { - sndrv_seq_instr_cluster_t cluster; +struct snd_seq_ev_cluster { + snd_seq_instr_cluster_t cluster; }; /* sample position */ -typedef unsigned int sndrv_seq_position_t; /* playback position (in samples) * 16 */ +typedef unsigned int snd_seq_position_t; /* playback position (in samples) * 16 */ /* sample stop mode */ -enum sndrv_seq_stop_mode { +enum { SAMPLE_STOP_IMMEDIATELY = 0, /* terminate playing immediately */ SAMPLE_STOP_VENVELOPE = 1, /* finish volume envelope */ SAMPLE_STOP_LOOP = 2 /* terminate loop and finish wave */ }; /* sample frequency */ -typedef int sndrv_seq_frequency_t; /* playback frequency in HZ * 16 */ +typedef int snd_seq_frequency_t; /* playback frequency in HZ * 16 */ /* sample volume control; if any value is set to -1 == do not change */ -struct sndrv_seq_ev_volume { +struct snd_seq_ev_volume { signed short volume; /* range: 0-16383 */ signed short lr; /* left-right balance; range: 0-16383 */ signed short fr; /* front-rear balance; range: 0-16383 */ @@ -303,22 +303,22 @@ struct sndrv_seq_ev_volume { }; /* simple loop redefinition */ -struct sndrv_seq_ev_loop { +struct snd_seq_ev_loop { unsigned int start; /* loop start (in samples) * 16 */ unsigned int end; /* loop end (in samples) * 16 */ }; -struct sndrv_seq_ev_sample_control { +struct snd_seq_ev_sample_control { unsigned char channel; unsigned char unused1, unused2, unused3; /* pad */ union { - struct sndrv_seq_ev_sample sample; - struct sndrv_seq_ev_cluster cluster; - sndrv_seq_position_t position; - enum sndrv_seq_stop_mode stop_mode; - sndrv_seq_frequency_t frequency; - struct sndrv_seq_ev_volume volume; - struct sndrv_seq_ev_loop loop; + struct snd_seq_ev_sample sample; + struct snd_seq_ev_cluster cluster; + snd_seq_position_t position; + int stop_mode; + snd_seq_frequency_t frequency; + struct snd_seq_ev_volume volume; + struct snd_seq_ev_loop loop; unsigned char raw8[8]; } param; }; @@ -326,82 +326,82 @@ struct sndrv_seq_ev_sample_control { /* INSTR_BEGIN event */ -struct sndrv_seq_ev_instr_begin { +struct snd_seq_ev_instr_begin { int timeout; /* zero = forever, otherwise timeout in ms */ }; -struct sndrv_seq_result { +struct snd_seq_result { int event; /* processed event type */ int result; }; -struct sndrv_seq_real_time { +struct snd_seq_real_time { unsigned int tv_sec; /* seconds */ unsigned int tv_nsec; /* nanoseconds */ }; -typedef unsigned int sndrv_seq_tick_time_t; /* midi ticks */ +typedef unsigned int snd_seq_tick_time_t; /* midi ticks */ -union sndrv_seq_timestamp { - sndrv_seq_tick_time_t tick; - struct sndrv_seq_real_time time; +union snd_seq_timestamp { + snd_seq_tick_time_t tick; + struct snd_seq_real_time time; }; -struct sndrv_seq_queue_skew { +struct snd_seq_queue_skew { unsigned int value; unsigned int base; }; /* queue timer control */ -struct sndrv_seq_ev_queue_control { +struct snd_seq_ev_queue_control { unsigned char queue; /* affected queue */ unsigned char pad[3]; /* reserved */ union { signed int value; /* affected value (e.g. tempo) */ - union sndrv_seq_timestamp time; /* time */ + union snd_seq_timestamp time; /* time */ unsigned int position; /* sync position */ - struct sndrv_seq_queue_skew skew; + struct snd_seq_queue_skew skew; unsigned int d32[2]; unsigned char d8[8]; } param; }; /* quoted event - inside the kernel only */ -struct sndrv_seq_ev_quote { - struct sndrv_seq_addr origin; /* original sender */ +struct snd_seq_ev_quote { + struct snd_seq_addr origin; /* original sender */ unsigned short value; /* optional data */ - struct sndrv_seq_event *event; /* quoted event */ + struct snd_seq_event *event; /* quoted event */ } __attribute__((packed)); /* sequencer event */ -struct sndrv_seq_event { - sndrv_seq_event_type_t type; /* event type */ +struct snd_seq_event { + snd_seq_event_type_t type; /* event type */ unsigned char flags; /* event flags */ char tag; unsigned char queue; /* schedule queue */ - union sndrv_seq_timestamp time; /* schedule time */ + union snd_seq_timestamp time; /* schedule time */ - struct sndrv_seq_addr source; /* source address */ - struct sndrv_seq_addr dest; /* destination address */ + struct snd_seq_addr source; /* source address */ + struct snd_seq_addr dest; /* destination address */ union { /* event data... */ - struct sndrv_seq_ev_note note; - struct sndrv_seq_ev_ctrl control; - struct sndrv_seq_ev_raw8 raw8; - struct sndrv_seq_ev_raw32 raw32; - struct sndrv_seq_ev_ext ext; - struct sndrv_seq_ev_queue_control queue; - union sndrv_seq_timestamp time; - struct sndrv_seq_addr addr; - struct sndrv_seq_connect connect; - struct sndrv_seq_result result; - struct sndrv_seq_ev_instr_begin instr_begin; - struct sndrv_seq_ev_sample_control sample; - struct sndrv_seq_ev_quote quote; + struct snd_seq_ev_note note; + struct snd_seq_ev_ctrl control; + struct snd_seq_ev_raw8 raw8; + struct snd_seq_ev_raw32 raw32; + struct snd_seq_ev_ext ext; + struct snd_seq_ev_queue_control queue; + union snd_seq_timestamp time; + struct snd_seq_addr addr; + struct snd_seq_connect connect; + struct snd_seq_result result; + struct snd_seq_ev_instr_begin instr_begin; + struct snd_seq_ev_sample_control sample; + struct snd_seq_ev_quote quote; } data; }; @@ -409,72 +409,77 @@ struct sndrv_seq_event { /* * bounce event - stored as variable size data */ -struct sndrv_seq_event_bounce { +struct snd_seq_event_bounce { int err; - struct sndrv_seq_event event; + struct snd_seq_event event; /* external data follows here. */ }; -#define sndrv_seq_event_bounce_ext_data(ev) ((void*)((char *)(ev)->data.ext.ptr + sizeof(sndrv_seq_event_bounce_t))) +#ifdef __KERNEL__ + +/* helper macro */ +#define snd_seq_event_bounce_ext_data(ev) ((void*)((char *)(ev)->data.ext.ptr + sizeof(struct snd_seq_event_bounce))) /* * type check macros */ /* result events: 0-4 */ -#define sndrv_seq_ev_is_result_type(ev) ((ev)->type < 5) +#define snd_seq_ev_is_result_type(ev) ((ev)->type < 5) /* channel specific events: 5-19 */ -#define sndrv_seq_ev_is_channel_type(ev) ((ev)->type >= 5 && (ev)->type < 20) +#define snd_seq_ev_is_channel_type(ev) ((ev)->type >= 5 && (ev)->type < 20) /* note events: 5-9 */ -#define sndrv_seq_ev_is_note_type(ev) ((ev)->type >= 5 && (ev)->type < 10) +#define snd_seq_ev_is_note_type(ev) ((ev)->type >= 5 && (ev)->type < 10) /* control events: 10-19 */ -#define sndrv_seq_ev_is_control_type(ev) ((ev)->type >= 10 && (ev)->type < 20) +#define snd_seq_ev_is_control_type(ev) ((ev)->type >= 10 && (ev)->type < 20) /* queue control events: 30-39 */ -#define sndrv_seq_ev_is_queue_type(ev) ((ev)->type >= 30 && (ev)->type < 40) +#define snd_seq_ev_is_queue_type(ev) ((ev)->type >= 30 && (ev)->type < 40) /* system status messages */ -#define sndrv_seq_ev_is_message_type(ev) ((ev)->type >= 60 && (ev)->type < 69) +#define snd_seq_ev_is_message_type(ev) ((ev)->type >= 60 && (ev)->type < 69) /* sample messages */ -#define sndrv_seq_ev_is_sample_type(ev) ((ev)->type >= 70 && (ev)->type < 79) +#define snd_seq_ev_is_sample_type(ev) ((ev)->type >= 70 && (ev)->type < 79) /* user-defined messages */ -#define sndrv_seq_ev_is_user_type(ev) ((ev)->type >= 90 && (ev)->type < 99) +#define snd_seq_ev_is_user_type(ev) ((ev)->type >= 90 && (ev)->type < 99) /* fixed length events: 0-99 */ -#define sndrv_seq_ev_is_fixed_type(ev) ((ev)->type < 100) +#define snd_seq_ev_is_fixed_type(ev) ((ev)->type < 100) /* instrument layer events: 100-129 */ -#define sndrv_seq_ev_is_instr_type(ev) ((ev)->type >= 100 && (ev)->type < 130) +#define snd_seq_ev_is_instr_type(ev) ((ev)->type >= 100 && (ev)->type < 130) /* variable length events: 130-139 */ -#define sndrv_seq_ev_is_variable_type(ev) ((ev)->type >= 130 && (ev)->type < 140) +#define snd_seq_ev_is_variable_type(ev) ((ev)->type >= 130 && (ev)->type < 140) /* reserved for kernel */ -#define sndrv_seq_ev_is_reserved(ev) ((ev)->type >= 150) +#define snd_seq_ev_is_reserved(ev) ((ev)->type >= 150) /* direct dispatched events */ -#define sndrv_seq_ev_is_direct(ev) ((ev)->queue == SNDRV_SEQ_QUEUE_DIRECT) +#define snd_seq_ev_is_direct(ev) ((ev)->queue == SNDRV_SEQ_QUEUE_DIRECT) /* * macros to check event flags */ /* prior events */ -#define sndrv_seq_ev_is_prior(ev) (((ev)->flags & SNDRV_SEQ_PRIORITY_MASK) == SNDRV_SEQ_PRIORITY_HIGH) +#define snd_seq_ev_is_prior(ev) (((ev)->flags & SNDRV_SEQ_PRIORITY_MASK) == SNDRV_SEQ_PRIORITY_HIGH) /* event length type */ -#define sndrv_seq_ev_length_type(ev) ((ev)->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) -#define sndrv_seq_ev_is_fixed(ev) (sndrv_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_FIXED) -#define sndrv_seq_ev_is_variable(ev) (sndrv_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARIABLE) -#define sndrv_seq_ev_is_varusr(ev) (sndrv_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARUSR) +#define snd_seq_ev_length_type(ev) ((ev)->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) +#define snd_seq_ev_is_fixed(ev) (snd_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_FIXED) +#define snd_seq_ev_is_variable(ev) (snd_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARIABLE) +#define snd_seq_ev_is_varusr(ev) (snd_seq_ev_length_type(ev) == SNDRV_SEQ_EVENT_LENGTH_VARUSR) /* time-stamp type */ -#define sndrv_seq_ev_timestamp_type(ev) ((ev)->flags & SNDRV_SEQ_TIME_STAMP_MASK) -#define sndrv_seq_ev_is_tick(ev) (sndrv_seq_ev_timestamp_type(ev) == SNDRV_SEQ_TIME_STAMP_TICK) -#define sndrv_seq_ev_is_real(ev) (sndrv_seq_ev_timestamp_type(ev) == SNDRV_SEQ_TIME_STAMP_REAL) +#define snd_seq_ev_timestamp_type(ev) ((ev)->flags & SNDRV_SEQ_TIME_STAMP_MASK) +#define snd_seq_ev_is_tick(ev) (snd_seq_ev_timestamp_type(ev) == SNDRV_SEQ_TIME_STAMP_TICK) +#define snd_seq_ev_is_real(ev) (snd_seq_ev_timestamp_type(ev) == SNDRV_SEQ_TIME_STAMP_REAL) /* time-mode type */ -#define sndrv_seq_ev_timemode_type(ev) ((ev)->flags & SNDRV_SEQ_TIME_MODE_MASK) -#define sndrv_seq_ev_is_abstime(ev) (sndrv_seq_ev_timemode_type(ev) == SNDRV_SEQ_TIME_MODE_ABS) -#define sndrv_seq_ev_is_reltime(ev) (sndrv_seq_ev_timemode_type(ev) == SNDRV_SEQ_TIME_MODE_REL) +#define snd_seq_ev_timemode_type(ev) ((ev)->flags & SNDRV_SEQ_TIME_MODE_MASK) +#define snd_seq_ev_is_abstime(ev) (snd_seq_ev_timemode_type(ev) == SNDRV_SEQ_TIME_MODE_ABS) +#define snd_seq_ev_is_reltime(ev) (snd_seq_ev_timemode_type(ev) == SNDRV_SEQ_TIME_MODE_REL) /* queue sync port */ -#define sndrv_seq_queue_sync_port(q) ((q) + 16) +#define snd_seq_queue_sync_port(q) ((q) + 16) + +#endif /* __KERNEL__ */ /* system information */ -struct sndrv_seq_system_info { +struct snd_seq_system_info { int queues; /* maximum queues count */ int clients; /* maximum clients count */ int ports; /* maximum ports per client */ @@ -486,7 +491,7 @@ struct sndrv_seq_system_info { /* system running information */ -struct sndrv_seq_running_info { +struct snd_seq_running_info { unsigned char client; /* client id */ unsigned char big_endian; /* 1 = big-endian */ unsigned char cpu_mode; /* 4 = 32bit, 8 = 64bit */ @@ -502,11 +507,10 @@ struct sndrv_seq_running_info { /* client types */ -enum sndrv_seq_client_type { - NO_CLIENT = 0, - USER_CLIENT = 1, - KERNEL_CLIENT = 2 -}; +typedef int __bitwise snd_seq_client_type_t; +#define NO_CLIENT ((__force snd_seq_client_type_t) 0) +#define USER_CLIENT ((__force snd_seq_client_type_t) 1) +#define KERNEL_CLIENT ((__force snd_seq_client_type_t) 2) /* event filter flags */ #define SNDRV_SEQ_FILTER_BROADCAST (1<<0) /* accept broadcast messages */ @@ -514,9 +518,9 @@ enum sndrv_seq_client_type { #define SNDRV_SEQ_FILTER_BOUNCE (1<<2) /* accept bounce event in error */ #define SNDRV_SEQ_FILTER_USE_EVENT (1<<31) /* use event filter */ -struct sndrv_seq_client_info { +struct snd_seq_client_info { int client; /* client number to inquire */ - enum sndrv_seq_client_type type; /* client type */ + snd_seq_client_type_t type; /* client type */ char name[64]; /* client name */ unsigned int filter; /* filter flags */ unsigned char multicast_filter[8]; /* multicast filter bitmap */ @@ -528,7 +532,7 @@ struct sndrv_seq_client_info { /* client pool size */ -struct sndrv_seq_client_pool { +struct snd_seq_client_pool { int client; /* client number to inquire */ int output_pool; /* outgoing (write) pool size */ int input_pool; /* incoming (read) pool size */ @@ -552,13 +556,13 @@ struct sndrv_seq_client_pool { #define SNDRV_SEQ_REMOVE_IGNORE_OFF (1<<8) /* Do not flush off events */ #define SNDRV_SEQ_REMOVE_TAG_MATCH (1<<9) /* Restrict to events with given tag */ -struct sndrv_seq_remove_events { +struct snd_seq_remove_events { unsigned int remove_mode; /* Flags that determine what gets removed */ - union sndrv_seq_timestamp time; + union snd_seq_timestamp time; unsigned char queue; /* Queue for REMOVE_DEST */ - struct sndrv_seq_addr dest; /* Address for REMOVE_DEST */ + struct snd_seq_addr dest; /* Address for REMOVE_DEST */ unsigned char channel; /* Channel for REMOVE_DEST */ int type; /* For REMOVE_EVENT_TYPE */ @@ -607,8 +611,8 @@ struct sndrv_seq_remove_events { #define SNDRV_SEQ_PORT_FLG_TIMESTAMP (1<<1) #define SNDRV_SEQ_PORT_FLG_TIME_REAL (1<<2) -struct sndrv_seq_port_info { - struct sndrv_seq_addr addr; /* client/port numbers */ +struct snd_seq_port_info { + struct snd_seq_addr addr; /* client/port numbers */ char name[64]; /* port name */ unsigned int capability; /* port capability bits */ @@ -631,7 +635,7 @@ struct sndrv_seq_port_info { #define SNDRV_SEQ_QUEUE_FLG_SYNC (1<<0) /* sync enabled */ /* queue information */ -struct sndrv_seq_queue_info { +struct snd_seq_queue_info { int queue; /* queue id */ /* @@ -647,11 +651,11 @@ struct sndrv_seq_queue_info { }; /* queue info/status */ -struct sndrv_seq_queue_status { +struct snd_seq_queue_status { int queue; /* queue id */ int events; /* read-only - queue size */ - sndrv_seq_tick_time_t tick; /* current tick */ - struct sndrv_seq_real_time time; /* current time */ + snd_seq_tick_time_t tick; /* current tick */ + struct snd_seq_real_time time; /* current time */ int running; /* running state of queue */ int flags; /* various flags */ char reserved[64]; /* for the future */ @@ -659,7 +663,7 @@ struct sndrv_seq_queue_status { /* queue tempo */ -struct sndrv_seq_queue_tempo { +struct snd_seq_queue_tempo { int queue; /* sequencer queue */ unsigned int tempo; /* current tempo, us/tick */ int ppq; /* time resolution, ticks/quarter */ @@ -675,12 +679,12 @@ struct sndrv_seq_queue_tempo { #define SNDRV_SEQ_TIMER_MIDI_TICK 2 /* Midi Timer Tick (TICK event) */ /* queue timer info */ -struct sndrv_seq_queue_timer { +struct snd_seq_queue_timer { int queue; /* sequencer queue */ int type; /* source timer type */ union { struct { - struct sndrv_timer_id id; /* ALSA's timer ID */ + struct snd_timer_id id; /* ALSA's timer ID */ unsigned int resolution; /* resolution in Hz */ } alsa; } u; @@ -688,7 +692,7 @@ struct sndrv_seq_queue_timer { }; -struct sndrv_seq_queue_client { +struct snd_seq_queue_client { int queue; /* sequencer queue */ int client; /* sequencer client */ int used; /* queue is used with this client @@ -702,9 +706,9 @@ struct sndrv_seq_queue_client { #define SNDRV_SEQ_PORT_SUBS_TIMESTAMP (1<<1) #define SNDRV_SEQ_PORT_SUBS_TIME_REAL (1<<2) -struct sndrv_seq_port_subscribe { - struct sndrv_seq_addr sender; /* sender address */ - struct sndrv_seq_addr dest; /* destination address */ +struct snd_seq_port_subscribe { + struct snd_seq_addr sender; /* sender address */ + struct snd_seq_addr dest; /* destination address */ unsigned int voices; /* number of voices to be allocated (0 = don't care) */ unsigned int flags; /* modes */ unsigned char queue; /* input time-stamp queue (optional) */ @@ -716,12 +720,12 @@ struct sndrv_seq_port_subscribe { #define SNDRV_SEQ_QUERY_SUBS_READ 0 #define SNDRV_SEQ_QUERY_SUBS_WRITE 1 -struct sndrv_seq_query_subs { - struct sndrv_seq_addr root; /* client/port id to be searched */ +struct snd_seq_query_subs { + struct snd_seq_addr root; /* client/port id to be searched */ int type; /* READ or WRITE */ int index; /* 0..N-1 */ int num_subs; /* R/O: number of subscriptions on this port */ - struct sndrv_seq_addr addr; /* R/O: result */ + struct snd_seq_addr addr; /* R/O: result */ unsigned char queue; /* R/O: result */ unsigned int flags; /* R/O: result */ char reserved[64]; /* for future use */ @@ -778,72 +782,72 @@ struct sndrv_seq_query_subs { #define SNDRV_SEQ_INSTR_FREE_CMD_SINGLE 3 /* size of ROM/RAM */ -typedef unsigned int sndrv_seq_instr_size_t; +typedef unsigned int snd_seq_instr_size_t; /* INSTR_INFO */ -struct sndrv_seq_instr_info { +struct snd_seq_instr_info { int result; /* operation result */ unsigned int formats[8]; /* bitmap of supported formats */ int ram_count; /* count of RAM banks */ - sndrv_seq_instr_size_t ram_sizes[16]; /* size of RAM banks */ + snd_seq_instr_size_t ram_sizes[16]; /* size of RAM banks */ int rom_count; /* count of ROM banks */ - sndrv_seq_instr_size_t rom_sizes[8]; /* size of ROM banks */ + snd_seq_instr_size_t rom_sizes[8]; /* size of ROM banks */ char reserved[128]; }; /* INSTR_STATUS */ -struct sndrv_seq_instr_status { +struct snd_seq_instr_status { int result; /* operation result */ - sndrv_seq_instr_size_t free_ram[16]; /* free RAM in banks */ + snd_seq_instr_size_t free_ram[16]; /* free RAM in banks */ int instrument_count; /* count of downloaded instruments */ char reserved[128]; }; /* INSTR_FORMAT_INFO */ -struct sndrv_seq_instr_format_info { +struct snd_seq_instr_format_info { char format[16]; /* format identifier - SNDRV_SEQ_INSTR_ID_* */ unsigned int len; /* max data length (without this structure) */ }; -struct sndrv_seq_instr_format_info_result { +struct snd_seq_instr_format_info_result { int result; /* operation result */ char format[16]; /* format identifier */ unsigned int len; /* filled data length (without this structure) */ }; /* instrument data */ -struct sndrv_seq_instr_data { +struct snd_seq_instr_data { char name[32]; /* instrument name */ char reserved[16]; /* for the future use */ int type; /* instrument type */ union { char format[16]; /* format identifier */ - struct sndrv_seq_instr alias; + struct snd_seq_instr alias; } data; }; /* INSTR_PUT/GET, data are stored in one block (extended), header + data */ -struct sndrv_seq_instr_header { +struct snd_seq_instr_header { union { - struct sndrv_seq_instr instr; - sndrv_seq_instr_cluster_t cluster; + struct snd_seq_instr instr; + snd_seq_instr_cluster_t cluster; } id; /* instrument identifier */ unsigned int cmd; /* get/put/free command */ unsigned int flags; /* query flags (only for get) */ unsigned int len; /* real instrument data length (without header) */ int result; /* operation result */ char reserved[16]; /* for the future */ - struct sndrv_seq_instr_data data; /* instrument data (for put/get result) */ + struct snd_seq_instr_data data; /* instrument data (for put/get result) */ }; /* INSTR_CLUSTER_SET */ -struct sndrv_seq_instr_cluster_set { - sndrv_seq_instr_cluster_t cluster; /* cluster identifier */ +struct snd_seq_instr_cluster_set { + snd_seq_instr_cluster_t cluster; /* cluster identifier */ char name[32]; /* cluster name */ int priority; /* cluster priority */ char reserved[64]; /* for the future use */ @@ -851,8 +855,8 @@ struct sndrv_seq_instr_cluster_set { /* INSTR_CLUSTER_GET */ -struct sndrv_seq_instr_cluster_get { - sndrv_seq_instr_cluster_t cluster; /* cluster identifier */ +struct snd_seq_instr_cluster_get { + snd_seq_instr_cluster_t cluster; /* cluster identifier */ char name[32]; /* cluster name */ int priority; /* cluster priority */ char reserved[64]; /* for the future use */ @@ -864,44 +868,44 @@ struct sndrv_seq_instr_cluster_get { #define SNDRV_SEQ_IOCTL_PVERSION _IOR ('S', 0x00, int) #define SNDRV_SEQ_IOCTL_CLIENT_ID _IOR ('S', 0x01, int) -#define SNDRV_SEQ_IOCTL_SYSTEM_INFO _IOWR('S', 0x02, struct sndrv_seq_system_info) -#define SNDRV_SEQ_IOCTL_RUNNING_MODE _IOWR('S', 0x03, struct sndrv_seq_running_info) - -#define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO _IOWR('S', 0x10, struct sndrv_seq_client_info) -#define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO _IOW ('S', 0x11, struct sndrv_seq_client_info) - -#define SNDRV_SEQ_IOCTL_CREATE_PORT _IOWR('S', 0x20, struct sndrv_seq_port_info) -#define SNDRV_SEQ_IOCTL_DELETE_PORT _IOW ('S', 0x21, struct sndrv_seq_port_info) -#define SNDRV_SEQ_IOCTL_GET_PORT_INFO _IOWR('S', 0x22, struct sndrv_seq_port_info) -#define SNDRV_SEQ_IOCTL_SET_PORT_INFO _IOW ('S', 0x23, struct sndrv_seq_port_info) - -#define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT _IOW ('S', 0x30, struct sndrv_seq_port_subscribe) -#define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW ('S', 0x31, struct sndrv_seq_port_subscribe) - -#define SNDRV_SEQ_IOCTL_CREATE_QUEUE _IOWR('S', 0x32, struct sndrv_seq_queue_info) -#define SNDRV_SEQ_IOCTL_DELETE_QUEUE _IOW ('S', 0x33, struct sndrv_seq_queue_info) -#define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO _IOWR('S', 0x34, struct sndrv_seq_queue_info) -#define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO _IOWR('S', 0x35, struct sndrv_seq_queue_info) -#define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE _IOWR('S', 0x36, struct sndrv_seq_queue_info) -#define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct sndrv_seq_queue_status) -#define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO _IOWR('S', 0x41, struct sndrv_seq_queue_tempo) -#define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO _IOW ('S', 0x42, struct sndrv_seq_queue_tempo) -#define SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER _IOWR('S', 0x43, struct sndrv_seq_queue_owner) -#define SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER _IOW ('S', 0x44, struct sndrv_seq_queue_owner) -#define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER _IOWR('S', 0x45, struct sndrv_seq_queue_timer) -#define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER _IOW ('S', 0x46, struct sndrv_seq_queue_timer) +#define SNDRV_SEQ_IOCTL_SYSTEM_INFO _IOWR('S', 0x02, struct snd_seq_system_info) +#define SNDRV_SEQ_IOCTL_RUNNING_MODE _IOWR('S', 0x03, struct snd_seq_running_info) + +#define SNDRV_SEQ_IOCTL_GET_CLIENT_INFO _IOWR('S', 0x10, struct snd_seq_client_info) +#define SNDRV_SEQ_IOCTL_SET_CLIENT_INFO _IOW ('S', 0x11, struct snd_seq_client_info) + +#define SNDRV_SEQ_IOCTL_CREATE_PORT _IOWR('S', 0x20, struct snd_seq_port_info) +#define SNDRV_SEQ_IOCTL_DELETE_PORT _IOW ('S', 0x21, struct snd_seq_port_info) +#define SNDRV_SEQ_IOCTL_GET_PORT_INFO _IOWR('S', 0x22, struct snd_seq_port_info) +#define SNDRV_SEQ_IOCTL_SET_PORT_INFO _IOW ('S', 0x23, struct snd_seq_port_info) + +#define SNDRV_SEQ_IOCTL_SUBSCRIBE_PORT _IOW ('S', 0x30, struct snd_seq_port_subscribe) +#define SNDRV_SEQ_IOCTL_UNSUBSCRIBE_PORT _IOW ('S', 0x31, struct snd_seq_port_subscribe) + +#define SNDRV_SEQ_IOCTL_CREATE_QUEUE _IOWR('S', 0x32, struct snd_seq_queue_info) +#define SNDRV_SEQ_IOCTL_DELETE_QUEUE _IOW ('S', 0x33, struct snd_seq_queue_info) +#define SNDRV_SEQ_IOCTL_GET_QUEUE_INFO _IOWR('S', 0x34, struct snd_seq_queue_info) +#define SNDRV_SEQ_IOCTL_SET_QUEUE_INFO _IOWR('S', 0x35, struct snd_seq_queue_info) +#define SNDRV_SEQ_IOCTL_GET_NAMED_QUEUE _IOWR('S', 0x36, struct snd_seq_queue_info) +#define SNDRV_SEQ_IOCTL_GET_QUEUE_STATUS _IOWR('S', 0x40, struct snd_seq_queue_status) +#define SNDRV_SEQ_IOCTL_GET_QUEUE_TEMPO _IOWR('S', 0x41, struct snd_seq_queue_tempo) +#define SNDRV_SEQ_IOCTL_SET_QUEUE_TEMPO _IOW ('S', 0x42, struct snd_seq_queue_tempo) +#define SNDRV_SEQ_IOCTL_GET_QUEUE_OWNER _IOWR('S', 0x43, struct snd_seq_queue_owner) +#define SNDRV_SEQ_IOCTL_SET_QUEUE_OWNER _IOW ('S', 0x44, struct snd_seq_queue_owner) +#define SNDRV_SEQ_IOCTL_GET_QUEUE_TIMER _IOWR('S', 0x45, struct snd_seq_queue_timer) +#define SNDRV_SEQ_IOCTL_SET_QUEUE_TIMER _IOW ('S', 0x46, struct snd_seq_queue_timer) /* XXX -#define SNDRV_SEQ_IOCTL_GET_QUEUE_SYNC _IOWR('S', 0x53, struct sndrv_seq_queue_sync) -#define SNDRV_SEQ_IOCTL_SET_QUEUE_SYNC _IOW ('S', 0x54, struct sndrv_seq_queue_sync) +#define SNDRV_SEQ_IOCTL_GET_QUEUE_SYNC _IOWR('S', 0x53, struct snd_seq_queue_sync) +#define SNDRV_SEQ_IOCTL_SET_QUEUE_SYNC _IOW ('S', 0x54, struct snd_seq_queue_sync) */ -#define SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT _IOWR('S', 0x49, struct sndrv_seq_queue_client) -#define SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT _IOW ('S', 0x4a, struct sndrv_seq_queue_client) -#define SNDRV_SEQ_IOCTL_GET_CLIENT_POOL _IOWR('S', 0x4b, struct sndrv_seq_client_pool) -#define SNDRV_SEQ_IOCTL_SET_CLIENT_POOL _IOW ('S', 0x4c, struct sndrv_seq_client_pool) -#define SNDRV_SEQ_IOCTL_REMOVE_EVENTS _IOW ('S', 0x4e, struct sndrv_seq_remove_events) -#define SNDRV_SEQ_IOCTL_QUERY_SUBS _IOWR('S', 0x4f, struct sndrv_seq_query_subs) -#define SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION _IOWR('S', 0x50, struct sndrv_seq_port_subscribe) -#define SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT _IOWR('S', 0x51, struct sndrv_seq_client_info) -#define SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT _IOWR('S', 0x52, struct sndrv_seq_port_info) +#define SNDRV_SEQ_IOCTL_GET_QUEUE_CLIENT _IOWR('S', 0x49, struct snd_seq_queue_client) +#define SNDRV_SEQ_IOCTL_SET_QUEUE_CLIENT _IOW ('S', 0x4a, struct snd_seq_queue_client) +#define SNDRV_SEQ_IOCTL_GET_CLIENT_POOL _IOWR('S', 0x4b, struct snd_seq_client_pool) +#define SNDRV_SEQ_IOCTL_SET_CLIENT_POOL _IOW ('S', 0x4c, struct snd_seq_client_pool) +#define SNDRV_SEQ_IOCTL_REMOVE_EVENTS _IOW ('S', 0x4e, struct snd_seq_remove_events) +#define SNDRV_SEQ_IOCTL_QUERY_SUBS _IOWR('S', 0x4f, struct snd_seq_query_subs) +#define SNDRV_SEQ_IOCTL_GET_SUBSCRIPTION _IOWR('S', 0x50, struct snd_seq_port_subscribe) +#define SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT _IOWR('S', 0x51, struct snd_seq_client_info) +#define SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT _IOWR('S', 0x52, struct snd_seq_port_info) #endif /* __SOUND_ASEQUENCER_H */ diff --git a/include/sound/seq_device.h b/include/sound/seq_device.h index 204ca54..2b5f24c 100644 --- a/include/sound/seq_device.h +++ b/include/sound/seq_device.h @@ -21,9 +21,6 @@ * */ -typedef struct snd_seq_device snd_seq_device_t; -typedef struct snd_seq_dev_ops snd_seq_dev_ops_t; - /* * registered device information */ @@ -36,7 +33,7 @@ typedef struct snd_seq_dev_ops snd_seq_dev_ops_t; struct snd_seq_device { /* device info */ - snd_card_t *card; /* sound card */ + struct snd_card *card; /* sound card */ int device; /* device number */ char id[ID_LEN]; /* driver id */ char name[80]; /* device name */ @@ -44,7 +41,7 @@ struct snd_seq_device { void *driver_data; /* private data for driver */ int status; /* flag - read only */ void *private_data; /* private data for the caller */ - void (*private_free)(snd_seq_device_t *device); + void (*private_free)(struct snd_seq_device *device); struct list_head list; /* link to next device */ }; @@ -63,19 +60,19 @@ struct snd_seq_device { * Typically, call snd_device_free(dev->card, dev->driver_data) */ struct snd_seq_dev_ops { - int (*init_device)(snd_seq_device_t *dev); - int (*free_device)(snd_seq_device_t *dev); + int (*init_device)(struct snd_seq_device *dev); + int (*free_device)(struct snd_seq_device *dev); }; /* * prototypes */ void snd_seq_device_load_drivers(void); -int snd_seq_device_new(snd_card_t *card, int device, char *id, int argsize, snd_seq_device_t **result); -int snd_seq_device_register_driver(char *id, snd_seq_dev_ops_t *entry, int argsize); +int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, struct snd_seq_device **result); +int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, int argsize); int snd_seq_device_unregister_driver(char *id); -#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(snd_seq_device_t)) +#define SNDRV_SEQ_DEVICE_ARGPTR(dev) (void *)((char *)(dev) + sizeof(struct snd_seq_device)) /* @@ -84,5 +81,4 @@ int snd_seq_device_unregister_driver(char *id); #define SNDRV_SEQ_DEV_ID_MIDISYNTH "seq-midi" #define SNDRV_SEQ_DEV_ID_OPL3 "opl3-synth" - #endif /* __SOUND_SEQ_DEVICE_H */ diff --git a/include/sound/seq_instr.h b/include/sound/seq_instr.h index 1a654df..db764f0 100644 --- a/include/sound/seq_instr.h +++ b/include/sound/seq_instr.h @@ -24,29 +24,27 @@ #include "seq_kernel.h" /* Instrument cluster */ -typedef struct _snd_seq_kcluster { +struct snd_seq_kcluster { snd_seq_instr_cluster_t cluster; char name[32]; int priority; - struct _snd_seq_kcluster *next; -} snd_seq_kcluster_t; + struct snd_seq_kcluster *next; +}; /* return pointer to private data */ -#define KINSTR_DATA(kinstr) (void *)(((char *)kinstr) + sizeof(snd_seq_kinstr_t)) - -typedef struct snd_seq_kinstr_ops snd_seq_kinstr_ops_t; +#define KINSTR_DATA(kinstr) (void *)(((char *)kinstr) + sizeof(struct snd_seq_kinstr)) /* Instrument structure */ -typedef struct _snd_seq_kinstr { - snd_seq_instr_t instr; +struct snd_seq_kinstr { + struct snd_seq_instr instr; char name[32]; int type; /* instrument type */ int use; /* use count */ int busy; /* not useable */ int add_len; /* additional length */ - snd_seq_kinstr_ops_t *ops; /* operations */ - struct _snd_seq_kinstr *next; -} snd_seq_kinstr_t; + struct snd_seq_kinstr_ops *ops; /* operations */ + struct snd_seq_kinstr *next; +}; #define SNDRV_SEQ_INSTR_HASH_SIZE 32 @@ -54,11 +52,11 @@ typedef struct _snd_seq_kinstr { #define SNDRV_SEQ_INSTR_FLG_DIRECT (1<<0) /* accept only direct events */ /* List of all instruments */ -typedef struct { - snd_seq_kinstr_t *hash[SNDRV_SEQ_INSTR_HASH_SIZE]; +struct snd_seq_kinstr_list { + struct snd_seq_kinstr *hash[SNDRV_SEQ_INSTR_HASH_SIZE]; int count; /* count of all instruments */ - snd_seq_kcluster_t *chash[SNDRV_SEQ_INSTR_HASH_SIZE]; + struct snd_seq_kcluster *chash[SNDRV_SEQ_INSTR_HASH_SIZE]; int ccount; /* count of all clusters */ int owner; /* current owner of the instrument list */ @@ -68,7 +66,7 @@ typedef struct { spinlock_t ops_lock; struct semaphore ops_mutex; unsigned long ops_flags; -} snd_seq_kinstr_list_t; +}; #define SNDRV_SEQ_INSTR_NOTIFY_REMOVE 0 #define SNDRV_SEQ_INSTR_NOTIFY_CHANGE 1 @@ -78,33 +76,33 @@ struct snd_seq_kinstr_ops { long add_len; /* additional length */ char *instr_type; int (*info)(void *private_data, char *info_data, long len); - int (*put)(void *private_data, snd_seq_kinstr_t *kinstr, + int (*put)(void *private_data, struct snd_seq_kinstr *kinstr, char __user *instr_data, long len, int atomic, int cmd); - int (*get)(void *private_data, snd_seq_kinstr_t *kinstr, + int (*get)(void *private_data, struct snd_seq_kinstr *kinstr, char __user *instr_data, long len, int atomic, int cmd); - int (*get_size)(void *private_data, snd_seq_kinstr_t *kinstr, long *size); - int (*remove)(void *private_data, snd_seq_kinstr_t *kinstr, int atomic); - void (*notify)(void *private_data, snd_seq_kinstr_t *kinstr, int what); + int (*get_size)(void *private_data, struct snd_seq_kinstr *kinstr, long *size); + int (*remove)(void *private_data, struct snd_seq_kinstr *kinstr, int atomic); + void (*notify)(void *private_data, struct snd_seq_kinstr *kinstr, int what); struct snd_seq_kinstr_ops *next; }; /* instrument operations */ -snd_seq_kinstr_list_t *snd_seq_instr_list_new(void); -void snd_seq_instr_list_free(snd_seq_kinstr_list_t **list); -int snd_seq_instr_list_free_cond(snd_seq_kinstr_list_t *list, - snd_seq_instr_header_t *ifree, +struct snd_seq_kinstr_list *snd_seq_instr_list_new(void); +void snd_seq_instr_list_free(struct snd_seq_kinstr_list **list); +int snd_seq_instr_list_free_cond(struct snd_seq_kinstr_list *list, + struct snd_seq_instr_header *ifree, int client, int atomic); -snd_seq_kinstr_t *snd_seq_instr_find(snd_seq_kinstr_list_t *list, - snd_seq_instr_t *instr, - int exact, - int follow_alias); -void snd_seq_instr_free_use(snd_seq_kinstr_list_t *list, - snd_seq_kinstr_t *instr); -int snd_seq_instr_event(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +struct snd_seq_kinstr *snd_seq_instr_find(struct snd_seq_kinstr_list *list, + struct snd_seq_instr *instr, + int exact, + int follow_alias); +void snd_seq_instr_free_use(struct snd_seq_kinstr_list *list, + struct snd_seq_kinstr *instr); +int snd_seq_instr_event(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int client, int atomic, int hop); diff --git a/include/sound/seq_kernel.h b/include/sound/seq_kernel.h index 4beca19..1b60890 100644 --- a/include/sound/seq_kernel.h +++ b/include/sound/seq_kernel.h @@ -24,62 +24,8 @@ #include <linux/time.h> #include "asequencer.h" -typedef sndrv_seq_tick_time_t snd_seq_tick_time_t; -typedef sndrv_seq_position_t snd_seq_position_t; -typedef sndrv_seq_frequency_t snd_seq_frequency_t; -typedef sndrv_seq_instr_cluster_t snd_seq_instr_cluster_t; -typedef enum sndrv_seq_client_type snd_seq_client_type_t; -typedef enum sndrv_seq_stop_mode snd_seq_stop_mode_t; -typedef struct sndrv_seq_port_info snd_seq_port_info_t; -typedef struct sndrv_seq_port_subscribe snd_seq_port_subscribe_t; -typedef struct sndrv_seq_event snd_seq_event_t; -typedef struct sndrv_seq_addr snd_seq_addr_t; -typedef struct sndrv_seq_ev_volume snd_seq_ev_volume_t; -typedef struct sndrv_seq_ev_loop snd_seq_ev_loop_t; -typedef struct sndrv_seq_remove_events snd_seq_remove_events_t; -typedef struct sndrv_seq_query_subs snd_seq_query_subs_t; -typedef struct sndrv_seq_real_time snd_seq_real_time_t; -typedef struct sndrv_seq_system_info snd_seq_system_info_t; -typedef struct sndrv_seq_client_info snd_seq_client_info_t; -typedef struct sndrv_seq_queue_info snd_seq_queue_info_t; -typedef struct sndrv_seq_queue_status snd_seq_queue_status_t; -typedef struct sndrv_seq_queue_tempo snd_seq_queue_tempo_t; -typedef struct sndrv_seq_queue_owner snd_seq_queue_owner_t; -typedef struct sndrv_seq_queue_timer snd_seq_queue_timer_t; -typedef struct sndrv_seq_queue_client snd_seq_queue_client_t; -typedef struct sndrv_seq_client_pool snd_seq_client_pool_t; -typedef struct sndrv_seq_instr snd_seq_instr_t; -typedef struct sndrv_seq_instr_data snd_seq_instr_data_t; -typedef struct sndrv_seq_instr_header snd_seq_instr_header_t; -typedef union sndrv_seq_timestamp snd_seq_timestamp_t; - -#define snd_seq_event_bounce_ext_data sndrv_seq_event_bounce_ext_data -#define snd_seq_ev_is_result_type sndrv_seq_ev_is_result_type -#define snd_seq_ev_is_channel_type sndrv_seq_ev_is_channel_type -#define snd_seq_ev_is_note_type sndrv_seq_ev_is_note_type -#define snd_seq_ev_is_control_type sndrv_seq_ev_is_control_type -#define snd_seq_ev_is_queue_type sndrv_seq_ev_is_queue_type -#define snd_seq_ev_is_message_type sndrv_seq_ev_is_message_type -#define snd_seq_ev_is_sample_type sndrv_seq_ev_is_sample_type -#define snd_seq_ev_is_user_type sndrv_seq_ev_is_user_type -#define snd_seq_ev_is_fixed_type sndrv_seq_ev_is_fixed_type -#define snd_seq_ev_is_instr_type sndrv_seq_ev_is_instr_type -#define snd_seq_ev_is_variable_type sndrv_seq_ev_is_variable_type -#define snd_seq_ev_is_reserved sndrv_seq_ev_is_reserved -#define snd_seq_ev_is_direct sndrv_seq_ev_is_direct -#define snd_seq_ev_is_prior sndrv_seq_ev_is_prior -#define snd_seq_ev_length_type sndrv_seq_ev_length_type -#define snd_seq_ev_is_fixed sndrv_seq_ev_is_fixed -#define snd_seq_ev_is_variable sndrv_seq_ev_is_variable -#define snd_seq_ev_is_varusr sndrv_seq_ev_is_varusr -#define snd_seq_ev_timestamp_type sndrv_seq_ev_timestamp_type -#define snd_seq_ev_is_tick sndrv_seq_ev_is_tick -#define snd_seq_ev_is_real sndrv_seq_ev_is_real -#define snd_seq_ev_timemode_type sndrv_seq_ev_timemode_type -#define snd_seq_ev_is_abstime sndrv_seq_ev_is_abstime -#define snd_seq_ev_is_reltime sndrv_seq_ev_is_reltime -#define snd_seq_queue_sync_port sndrv_seq_queue_sync_port -#define snd_seq_queue_owner sndrv_seq_queue_owner +typedef struct snd_seq_real_time snd_seq_real_time_t; +typedef union snd_seq_timestamp snd_seq_timestamp_t; /* maximum number of events dequeued per schedule interval */ #define SNDRV_SEQ_MAX_DEQUEUE 50 @@ -114,69 +60,56 @@ typedef union sndrv_seq_timestamp snd_seq_timestamp_t; /* max size of event size */ #define SNDRV_SEQ_MAX_EVENT_LEN 0x3fffffff -/* typedefs */ -struct _snd_seq_user_client; -struct _snd_seq_kernel_client; -struct _snd_seq_client; -struct _snd_seq_queue; - -typedef struct _snd_seq_user_client user_client_t; -typedef struct _snd_seq_kernel_client kernel_client_t; -typedef struct _snd_seq_client client_t; -typedef struct _snd_seq_queue queue_t; - /* call-backs for kernel client */ -typedef struct { +struct snd_seq_client_callback { void *private_data; unsigned allow_input: 1, allow_output: 1; /*...*/ -} snd_seq_client_callback_t; +}; /* call-backs for kernel port */ -typedef int (snd_seq_kernel_port_open_t)(void *private_data, snd_seq_port_subscribe_t *info); -typedef int (snd_seq_kernel_port_close_t)(void *private_data, snd_seq_port_subscribe_t *info); -typedef int (snd_seq_kernel_port_input_t)(snd_seq_event_t *ev, int direct, void *private_data, int atomic, int hop); -typedef void (snd_seq_kernel_port_private_free_t)(void *private_data); - -typedef struct { +struct snd_seq_port_callback { struct module *owner; void *private_data; - snd_seq_kernel_port_open_t *subscribe; - snd_seq_kernel_port_close_t *unsubscribe; - snd_seq_kernel_port_open_t *use; - snd_seq_kernel_port_close_t *unuse; - snd_seq_kernel_port_input_t *event_input; - snd_seq_kernel_port_private_free_t *private_free; + int (*subscribe)(void *private_data, struct snd_seq_port_subscribe *info); + int (*unsubscribe)(void *private_data, struct snd_seq_port_subscribe *info); + int (*use)(void *private_data, struct snd_seq_port_subscribe *info); + int (*unuse)(void *private_data, struct snd_seq_port_subscribe *info); + int (*event_input)(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop); + void (*private_free)(void *private_data); unsigned int callback_all; /* call subscribe callbacks at each connection/disconnection */ /*...*/ -} snd_seq_port_callback_t; +}; /* interface for kernel client */ -extern int snd_seq_create_kernel_client(snd_card_t *card, int client_index, snd_seq_client_callback_t *callback); -extern int snd_seq_delete_kernel_client(int client); -extern int snd_seq_kernel_client_enqueue(int client, snd_seq_event_t *ev, int atomic, int hop); -extern int snd_seq_kernel_client_dispatch(int client, snd_seq_event_t *ev, int atomic, int hop); -extern int snd_seq_kernel_client_ctl(int client, unsigned int cmd, void *arg); +int snd_seq_create_kernel_client(struct snd_card *card, int client_index, + struct snd_seq_client_callback *callback); +int snd_seq_delete_kernel_client(int client); +int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop); +int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop); +int snd_seq_kernel_client_ctl(int client, unsigned int cmd, void *arg); #define SNDRV_SEQ_EXT_MASK 0xc0000000 #define SNDRV_SEQ_EXT_USRPTR 0x80000000 #define SNDRV_SEQ_EXT_CHAINED 0x40000000 typedef int (*snd_seq_dump_func_t)(void *ptr, void *buf, int count); -int snd_seq_expand_var_event(const snd_seq_event_t *event, int count, char *buf, int in_kernel, int size_aligned); -int snd_seq_dump_var_event(const snd_seq_event_t *event, snd_seq_dump_func_t func, void *private_data); +int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, char *buf, + int in_kernel, int size_aligned); +int snd_seq_dump_var_event(const struct snd_seq_event *event, + snd_seq_dump_func_t func, void *private_data); /* interface for OSS emulation */ -int snd_seq_set_queue_tempo(int client, snd_seq_queue_tempo_t *tempo); +int snd_seq_set_queue_tempo(int client, struct snd_seq_queue_tempo *tempo); /* port callback routines */ -void snd_port_init_callback(snd_seq_port_callback_t *p); -snd_seq_port_callback_t *snd_port_alloc_callback(void); +void snd_port_init_callback(struct snd_seq_port_callback *p); +struct snd_seq_port_callback *snd_port_alloc_callback(void); /* port attach/detach */ -int snd_seq_event_port_attach(int client, snd_seq_port_callback_t *pcbp, +int snd_seq_event_port_attach(int client, struct snd_seq_port_callback *pcbp, int cap, int type, int midi_channels, int midi_voices, char *portname); int snd_seq_event_port_detach(int client, int port); diff --git a/include/sound/seq_midi_emul.h b/include/sound/seq_midi_emul.h index e58ca45..d6c4615 100644 --- a/include/sound/seq_midi_emul.h +++ b/include/sound/seq_midi_emul.h @@ -29,7 +29,7 @@ * channel. All drivers for hardware that does not understand midi * directly will probably need to use this structure. */ -typedef struct snd_midi_channel { +struct snd_midi_channel { void *private; /* A back pointer to driver data */ int number; /* The channel number */ int client; /* The client associated with this channel */ @@ -53,41 +53,43 @@ typedef struct snd_midi_channel { short gm_rpn_fine_tuning; /* Master fine tuning */ short gm_rpn_coarse_tuning; /* Master coarse tuning */ -} snd_midi_channel_t; +}; /* * A structure that represets a set of channels bound to a port. There * would usually be 16 channels per port. But fewer could be used for * particular cases. * The channel set consists of information describing the client and - * port for this midi synth and an array of snd_midi_channel_t structures. - * A driver that had no need for snd_midi_channel_t could still use the + * port for this midi synth and an array of snd_midi_channel structures. + * A driver that had no need for snd_midi_channel could still use the * channel set type if it wished with the channel array null. */ -typedef struct snd_midi_channel_set { +struct snd_midi_channel_set { void *private_data; /* Driver data */ int client; /* Client for this port */ int port; /* The port number */ int max_channels; /* Size of the channels array */ - snd_midi_channel_t *channels; + struct snd_midi_channel *channels; unsigned char midi_mode; /* MIDI operating mode */ unsigned char gs_master_volume; /* SYSEX master volume: 0-127 */ unsigned char gs_chorus_mode; unsigned char gs_reverb_mode; -} snd_midi_channel_set_t; +}; -typedef struct snd_seq_midi_op { - void (*note_on)(void *private_data, int note, int vel, snd_midi_channel_t *chan); - void (*note_off)(void *private_data,int note, int vel, snd_midi_channel_t *chan); /* release note */ - void (*key_press)(void *private_data, int note, int vel, snd_midi_channel_t *chan); - void (*note_terminate)(void *private_data, int note, snd_midi_channel_t *chan); /* terminate note immediately */ - void (*control)(void *private_data, int type, snd_midi_channel_t *chan); - void (*nrpn)(void *private_data, snd_midi_channel_t *chan, snd_midi_channel_set_t *chset); - void (*sysex)(void *private_data, unsigned char *buf, int len, int parsed, snd_midi_channel_set_t *chset); -} snd_midi_op_t; +struct snd_midi_op { + void (*note_on)(void *private_data, int note, int vel, struct snd_midi_channel *chan); + void (*note_off)(void *private_data,int note, int vel, struct snd_midi_channel *chan); /* release note */ + void (*key_press)(void *private_data, int note, int vel, struct snd_midi_channel *chan); + void (*note_terminate)(void *private_data, int note, struct snd_midi_channel *chan); /* terminate note immediately */ + void (*control)(void *private_data, int type, struct snd_midi_channel *chan); + void (*nrpn)(void *private_data, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset); + void (*sysex)(void *private_data, unsigned char *buf, int len, int parsed, + struct snd_midi_channel_set *chset); +}; /* * These defines are used so that pitchbend, aftertouch etc, can be @@ -186,10 +188,10 @@ enum { }; /* Prototypes for midi_process.c */ -void snd_midi_process_event(snd_midi_op_t *ops, snd_seq_event_t *ev, - snd_midi_channel_set_t *chanset); -void snd_midi_channel_set_clear(snd_midi_channel_set_t *chset); -snd_midi_channel_set_t *snd_midi_channel_alloc_set(int n); -void snd_midi_channel_free_set(snd_midi_channel_set_t *chset); +void snd_midi_process_event(struct snd_midi_op *ops, struct snd_seq_event *ev, + struct snd_midi_channel_set *chanset); +void snd_midi_channel_set_clear(struct snd_midi_channel_set *chset); +struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n); +void snd_midi_channel_free_set(struct snd_midi_channel_set *chset); #endif /* __SOUND_SEQ_MIDI_EMUL_H */ diff --git a/include/sound/seq_midi_event.h b/include/sound/seq_midi_event.h index 8857e2b..dd789e7 100644 --- a/include/sound/seq_midi_event.h +++ b/include/sound/seq_midi_event.h @@ -26,10 +26,8 @@ #define MAX_MIDI_EVENT_BUF 256 -typedef struct snd_midi_event_t snd_midi_event_t; - /* midi status */ -struct snd_midi_event_t { +struct snd_midi_event { int qlen; /* queue length */ int read; /* chars read */ int type; /* current event type */ @@ -40,15 +38,17 @@ struct snd_midi_event_t { spinlock_t lock; }; -int snd_midi_event_new(int bufsize, snd_midi_event_t **rdev); -void snd_midi_event_free(snd_midi_event_t *dev); -void snd_midi_event_reset_encode(snd_midi_event_t *dev); -void snd_midi_event_reset_decode(snd_midi_event_t *dev); -void snd_midi_event_no_status(snd_midi_event_t *dev, int on); +int snd_midi_event_new(int bufsize, struct snd_midi_event **rdev); +void snd_midi_event_free(struct snd_midi_event *dev); +void snd_midi_event_reset_encode(struct snd_midi_event *dev); +void snd_midi_event_reset_decode(struct snd_midi_event *dev); +void snd_midi_event_no_status(struct snd_midi_event *dev, int on); /* encode from byte stream - return number of written bytes if success */ -long snd_midi_event_encode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev); -int snd_midi_event_encode_byte(snd_midi_event_t *dev, int c, snd_seq_event_t *ev); +long snd_midi_event_encode(struct snd_midi_event *dev, unsigned char *buf, long count, + struct snd_seq_event *ev); +int snd_midi_event_encode_byte(struct snd_midi_event *dev, int c, struct snd_seq_event *ev); /* decode from event to bytes - return number of written bytes if success */ -long snd_midi_event_decode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev); +long snd_midi_event_decode(struct snd_midi_event *dev, unsigned char *buf, long count, + struct snd_seq_event *ev); #endif /* __SOUND_SEQ_MIDI_EVENT_H */ diff --git a/include/sound/seq_virmidi.h b/include/sound/seq_virmidi.h index 1ad27e8..8d5aea7 100644 --- a/include/sound/seq_virmidi.h +++ b/include/sound/seq_virmidi.h @@ -25,25 +25,23 @@ #include "rawmidi.h" #include "seq_midi_event.h" -typedef struct _snd_virmidi_dev snd_virmidi_dev_t; - /* * device file instance: * This instance is created at each time the midi device file is * opened. Each instance has its own input buffer and MIDI parser * (buffer), and is associated with the device instance. */ -typedef struct _snd_virmidi { +struct snd_virmidi { struct list_head list; int seq_mode; int client; int port; unsigned int trigger: 1; - snd_midi_event_t *parser; - snd_seq_event_t event; - snd_virmidi_dev_t *rdev; - snd_rawmidi_substream_t *substream; -} snd_virmidi_t; + struct snd_midi_event *parser; + struct snd_seq_event event; + struct snd_virmidi_dev *rdev; + struct snd_rawmidi_substream *substream; +}; #define SNDRV_VIRMIDI_SUBSCRIBE (1<<0) #define SNDRV_VIRMIDI_USE (1<<1) @@ -53,9 +51,9 @@ typedef struct _snd_virmidi { * Each virtual midi device has one device instance. It contains * common information and the linked-list of opened files, */ -struct _snd_virmidi_dev { - snd_card_t *card; /* associated card */ - snd_rawmidi_t *rmidi; /* rawmidi device */ +struct snd_virmidi_dev { + struct snd_card *card; /* associated card */ + struct snd_rawmidi *rmidi; /* rawmidi device */ int seq_mode; /* SNDRV_VIRMIDI_XXX */ int device; /* sequencer device */ int client; /* created/attached client */ @@ -78,6 +76,6 @@ struct _snd_virmidi_dev { #define SNDRV_VIRMIDI_SEQ_ATTACH 1 #define SNDRV_VIRMIDI_SEQ_DISPATCH 2 -int snd_virmidi_new(snd_card_t *card, int device, snd_rawmidi_t **rrmidi); +int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmidi); #endif /* __SOUND_SEQ_VIRMIDI */ diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index a886db9..5eab420 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -58,14 +58,18 @@ static DECLARE_MUTEX(register_mutex); * client table */ static char clienttablock[SNDRV_SEQ_MAX_CLIENTS]; -static client_t *clienttab[SNDRV_SEQ_MAX_CLIENTS]; -static usage_t client_usage; +static struct snd_seq_client *clienttab[SNDRV_SEQ_MAX_CLIENTS]; +static struct snd_seq_usage client_usage; /* * prototypes */ -static int bounce_error_event(client_t *client, snd_seq_event_t *event, int err, int atomic, int hop); -static int snd_seq_deliver_single_event(client_t *client, snd_seq_event_t *event, int filter, int atomic, int hop); +static int bounce_error_event(struct snd_seq_client *client, + struct snd_seq_event *event, + int err, int atomic, int hop); +static int snd_seq_deliver_single_event(struct snd_seq_client *client, + struct snd_seq_event *event, + int filter, int atomic, int hop); /* */ @@ -96,16 +100,17 @@ static inline unsigned short snd_seq_file_flags(struct file *file) } } -static inline int snd_seq_write_pool_allocated(client_t *client) +static inline int snd_seq_write_pool_allocated(struct snd_seq_client *client) { return snd_seq_total_cells(client->pool) > 0; } /* return pointer to client structure for specified id */ -static client_t *clientptr(int clientid) +static struct snd_seq_client *clientptr(int clientid) { if (clientid < 0 || clientid >= SNDRV_SEQ_MAX_CLIENTS) { - snd_printd("Seq: oops. Trying to get pointer to client %d\n", clientid); + snd_printd("Seq: oops. Trying to get pointer to client %d\n", + clientid); return NULL; } return clienttab[clientid]; @@ -113,13 +118,14 @@ static client_t *clientptr(int clientid) extern int seq_client_load[]; -client_t *snd_seq_client_use_ptr(int clientid) +struct snd_seq_client *snd_seq_client_use_ptr(int clientid) { unsigned long flags; - client_t *client; + struct snd_seq_client *client; if (clientid < 0 || clientid >= SNDRV_SEQ_MAX_CLIENTS) { - snd_printd("Seq: oops. Trying to get pointer to client %d\n", clientid); + snd_printd("Seq: oops. Trying to get pointer to client %d\n", + clientid); return NULL; } spin_lock_irqsave(&clients_lock, flags); @@ -144,7 +150,8 @@ client_t *snd_seq_client_use_ptr(int clientid) if (seq_client_load[idx] < 0) break; if (seq_client_load[idx] == clientid) { - request_module("snd-seq-client-%i", clientid); + request_module("snd-seq-client-%i", + clientid); break; } } @@ -174,14 +181,14 @@ client_t *snd_seq_client_use_ptr(int clientid) return client; } -static void usage_alloc(usage_t * res, int num) +static void usage_alloc(struct snd_seq_usage *res, int num) { res->cur += num; if (res->cur > res->peak) res->peak = res->cur; } -static void usage_free(usage_t * res, int num) +static void usage_free(struct snd_seq_usage *res, int num) { res->cur -= num; } @@ -196,11 +203,11 @@ int __init client_init_data(void) } -static client_t *seq_create_client1(int client_index, int poolsize) +static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) { unsigned long flags; int c; - client_t *client; + struct snd_seq_client *client; /* init client data */ client = kzalloc(sizeof(*client), GFP_KERNEL); @@ -241,7 +248,7 @@ static client_t *seq_create_client1(int client_index, int poolsize) } -static int seq_free_client1(client_t *client) +static int seq_free_client1(struct snd_seq_client *client) { unsigned long flags; @@ -263,12 +270,13 @@ static int seq_free_client1(client_t *client) } -static void seq_free_client(client_t * client) +static void seq_free_client(struct snd_seq_client * client) { down(®ister_mutex); switch (client->type) { case NO_CLIENT: - snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n", client->number); + snd_printk(KERN_WARNING "Seq: Trying to free unused client %d\n", + client->number); break; case USER_CLIENT: case KERNEL_CLIENT: @@ -277,7 +285,8 @@ static void seq_free_client(client_t * client) break; default: - snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n", client->number, client->type); + snd_printk(KERN_ERR "Seq: Trying to free client %d with undefined type = %d\n", + client->number, client->type); } up(®ister_mutex); @@ -292,8 +301,8 @@ static void seq_free_client(client_t * client) static int snd_seq_open(struct inode *inode, struct file *file) { int c, mode; /* client id */ - client_t *client; - user_client_t *user; + struct snd_seq_client *client; + struct snd_seq_user_client *user; if (down_interruptible(®ister_mutex)) return -ERESTARTSYS; @@ -344,7 +353,7 @@ static int snd_seq_open(struct inode *inode, struct file *file) /* delete a user client */ static int snd_seq_release(struct inode *inode, struct file *file) { - client_t *client = (client_t *) file->private_data; + struct snd_seq_client *client = file->private_data; if (client) { seq_free_client(client); @@ -364,13 +373,14 @@ static int snd_seq_release(struct inode *inode, struct file *file) * -EINVAL no enough user-space buffer to write the whole event * -EFAULT seg. fault during copy to user space */ -static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, loff_t *offset) +static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, + loff_t *offset) { - client_t *client = (client_t *) file->private_data; - fifo_t *fifo; + struct snd_seq_client *client = file->private_data; + struct snd_seq_fifo *fifo; int err; long result = 0; - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; if (!(snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_INPUT)) return -ENXIO; @@ -396,7 +406,7 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, l snd_seq_fifo_lock(fifo); /* while data available in queue */ - while (count >= sizeof(snd_seq_event_t)) { + while (count >= sizeof(struct snd_seq_event)) { int nonblock; nonblock = (file->f_flags & O_NONBLOCK) || result > 0; @@ -404,34 +414,34 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, l break; } if (snd_seq_ev_is_variable(&cell->event)) { - snd_seq_event_t tmpev; + struct snd_seq_event tmpev; tmpev = cell->event; tmpev.data.ext.len &= ~SNDRV_SEQ_EXT_MASK; - if (copy_to_user(buf, &tmpev, sizeof(snd_seq_event_t))) { + if (copy_to_user(buf, &tmpev, sizeof(struct snd_seq_event))) { err = -EFAULT; break; } - count -= sizeof(snd_seq_event_t); - buf += sizeof(snd_seq_event_t); + count -= sizeof(struct snd_seq_event); + buf += sizeof(struct snd_seq_event); err = snd_seq_expand_var_event(&cell->event, count, (char __force *)buf, 0, - sizeof(snd_seq_event_t)); + sizeof(struct snd_seq_event)); if (err < 0) break; result += err; count -= err; buf += err; } else { - if (copy_to_user(buf, &cell->event, sizeof(snd_seq_event_t))) { + if (copy_to_user(buf, &cell->event, sizeof(struct snd_seq_event))) { err = -EFAULT; break; } - count -= sizeof(snd_seq_event_t); - buf += sizeof(snd_seq_event_t); + count -= sizeof(struct snd_seq_event); + buf += sizeof(struct snd_seq_event); } snd_seq_cell_free(cell); cell = NULL; /* to be sure */ - result += sizeof(snd_seq_event_t); + result += sizeof(struct snd_seq_event); } if (err < 0) { @@ -449,7 +459,7 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, l /* * check access permission to the port */ -static int check_port_perm(client_port_t *port, unsigned int flags) +static int check_port_perm(struct snd_seq_client_port *port, unsigned int flags) { if ((port->capability & flags) != flags) return 0; @@ -460,9 +470,10 @@ static int check_port_perm(client_port_t *port, unsigned int flags) * check if the destination client is available, and return the pointer * if filter is non-zero, client filter bitmap is tested. */ -static client_t *get_event_dest_client(snd_seq_event_t *event, int filter) +static struct snd_seq_client *get_event_dest_client(struct snd_seq_event *event, + int filter) { - client_t *dest; + struct snd_seq_client *dest; dest = snd_seq_client_use_ptr(event->dest.client); if (dest == NULL) @@ -493,10 +504,11 @@ __not_avail: * quoted in SNDRV_SEQ_EVENT_KERNEL_ERROR, since this requires no extra * kmalloc. */ -static int bounce_error_event(client_t *client, snd_seq_event_t *event, +static int bounce_error_event(struct snd_seq_client *client, + struct snd_seq_event *event, int err, int atomic, int hop) { - snd_seq_event_t bounce_ev; + struct snd_seq_event bounce_ev; int result; if (client == NULL || @@ -531,9 +543,10 @@ static int bounce_error_event(client_t *client, snd_seq_event_t *event, * of the given queue. * return non-zero if updated. */ -static int update_timestamp_of_queue(snd_seq_event_t *event, int queue, int real_time) +static int update_timestamp_of_queue(struct snd_seq_event *event, + int queue, int real_time) { - queue_t *q; + struct snd_seq_queue *q; q = queueptr(queue); if (! q) @@ -559,12 +572,12 @@ static int update_timestamp_of_queue(snd_seq_event_t *event, int queue, int real * RETURN VALUE: 0 : if succeeded * <0 : error */ -static int snd_seq_deliver_single_event(client_t *client, - snd_seq_event_t *event, +static int snd_seq_deliver_single_event(struct snd_seq_client *client, + struct snd_seq_event *event, int filter, int atomic, int hop) { - client_t *dest = NULL; - client_port_t *dest_port = NULL; + struct snd_seq_client *dest = NULL; + struct snd_seq_client_port *dest_port = NULL; int result = -ENOENT; int direct; @@ -596,7 +609,9 @@ static int snd_seq_deliver_single_event(client_t *client, case KERNEL_CLIENT: if (dest_port->event_input == NULL) break; - result = dest_port->event_input(event, direct, dest_port->private_data, atomic, hop); + result = dest_port->event_input(event, direct, + dest_port->private_data, + atomic, hop); break; default: break; @@ -618,16 +633,16 @@ static int snd_seq_deliver_single_event(client_t *client, /* * send the event to all subscribers: */ -static int deliver_to_subscribers(client_t *client, - snd_seq_event_t *event, +static int deliver_to_subscribers(struct snd_seq_client *client, + struct snd_seq_event *event, int atomic, int hop) { - subscribers_t *subs; + struct snd_seq_subscribers *subs; int err = 0, num_ev = 0; - snd_seq_event_t event_saved; - client_port_t *src_port; + struct snd_seq_event event_saved; + struct snd_seq_client_port *src_port; struct list_head *p; - port_subs_info_t *grp; + struct snd_seq_port_subs_info *grp; src_port = snd_seq_port_use_ptr(client, event->source.port); if (src_port == NULL) @@ -642,7 +657,7 @@ static int deliver_to_subscribers(client_t *client, else down_read(&grp->list_mutex); list_for_each(p, &grp->list_head) { - subs = list_entry(p, subscribers_t, src_list); + subs = list_entry(p, struct snd_seq_subscribers, src_list); event->dest = subs->info.dest; if (subs->info.flags & SNDRV_SEQ_PORT_SUBS_TIMESTAMP) /* convert time according to flag with subscription */ @@ -670,12 +685,12 @@ static int deliver_to_subscribers(client_t *client, /* * broadcast to all ports: */ -static int port_broadcast_event(client_t *client, - snd_seq_event_t *event, +static int port_broadcast_event(struct snd_seq_client *client, + struct snd_seq_event *event, int atomic, int hop) { int num_ev = 0, err = 0; - client_t *dest_client; + struct snd_seq_client *dest_client; struct list_head *p; dest_client = get_event_dest_client(event, SNDRV_SEQ_FILTER_BROADCAST); @@ -684,7 +699,7 @@ static int port_broadcast_event(client_t *client, read_lock(&dest_client->ports_lock); list_for_each(p, &dest_client->ports_list_head) { - client_port_t *port = list_entry(p, client_port_t, list); + struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list); event->dest.port = port->addr.port; /* pass NULL as source client to avoid error bounce */ err = snd_seq_deliver_single_event(NULL, event, @@ -704,12 +719,12 @@ static int port_broadcast_event(client_t *client, * send the event to all clients: * if destination port is also ADDRESS_BROADCAST, deliver to all ports. */ -static int broadcast_event(client_t *client, - snd_seq_event_t *event, int atomic, int hop) +static int broadcast_event(struct snd_seq_client *client, + struct snd_seq_event *event, int atomic, int hop) { int err = 0, num_ev = 0; int dest; - snd_seq_addr_t addr; + struct snd_seq_addr addr; addr = event->dest; /* save */ @@ -736,7 +751,7 @@ static int broadcast_event(client_t *client, /* multicast - not supported yet */ -static int multicast_event(client_t *client, snd_seq_event_t *event, +static int multicast_event(struct snd_seq_client *client, struct snd_seq_event *event, int atomic, int hop) { snd_printd("seq: multicast not supported yet.\n"); @@ -753,7 +768,7 @@ static int multicast_event(client_t *client, snd_seq_event_t *event, * n == 0 : the event was not passed to any client. * n < 0 : error - event was not processed. */ -static int snd_seq_deliver_event(client_t *client, snd_seq_event_t *event, +static int snd_seq_deliver_event(struct snd_seq_client *client, struct snd_seq_event *event, int atomic, int hop) { int result; @@ -794,9 +809,9 @@ static int snd_seq_deliver_event(client_t *client, snd_seq_event_t *event, * n == 0 : the event was not passed to any client. * n < 0 : error - event was not processed. */ -int snd_seq_dispatch_event(snd_seq_event_cell_t *cell, int atomic, int hop) +int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop) { - client_t *client; + struct snd_seq_client *client; int result; snd_assert(cell != NULL, return -EINVAL); @@ -812,7 +827,7 @@ int snd_seq_dispatch_event(snd_seq_event_cell_t *cell, int atomic, int hop) * the event cell is re-used as a NOTE-OFF event and * enqueued again. */ - snd_seq_event_t tmpev, *ev; + struct snd_seq_event tmpev, *ev; /* reserve this event to enqueue note-off later */ tmpev = cell->event; @@ -865,12 +880,12 @@ int snd_seq_dispatch_event(snd_seq_event_cell_t *cell, int atomic, int hop) * if pool is empty and blocking is TRUE, sleep until a new cell is * available. */ -static int snd_seq_client_enqueue_event(client_t *client, - snd_seq_event_t *event, +static int snd_seq_client_enqueue_event(struct snd_seq_client *client, + struct snd_seq_event *event, struct file *file, int blocking, int atomic, int hop) { - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; int err; /* special queue values - force direct passing */ @@ -886,7 +901,7 @@ static int snd_seq_client_enqueue_event(client_t *client, #endif if (event->dest.client == SNDRV_SEQ_ADDRESS_SUBSCRIBERS) { /* check presence of source port */ - client_port_t *src_port = snd_seq_port_use_ptr(client, event->source.port); + struct snd_seq_client_port *src_port = snd_seq_port_use_ptr(client, event->source.port); if (src_port == NULL) return -EINVAL; snd_seq_port_unlock(src_port); @@ -924,7 +939,7 @@ static int snd_seq_client_enqueue_event(client_t *client, * check validity of event type and data length. * return non-zero if invalid. */ -static int check_event_type_and_length(snd_seq_event_t *ev) +static int check_event_type_and_length(struct snd_seq_event *ev) { switch (snd_seq_ev_length_type(ev)) { case SNDRV_SEQ_EVENT_LENGTH_FIXED: @@ -957,12 +972,13 @@ static int check_event_type_and_length(snd_seq_event_t *ev) * -EMLINK too many hops * others depends on return value from driver callback */ -static ssize_t snd_seq_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) +static ssize_t snd_seq_write(struct file *file, const char __user *buf, + size_t count, loff_t *offset) { - client_t *client = (client_t *) file->private_data; + struct snd_seq_client *client = file->private_data; int written = 0, len; int err = -EINVAL; - snd_seq_event_t event; + struct snd_seq_event event; if (!(snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_OUTPUT)) return -ENXIO; @@ -980,7 +996,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, size_t c } /* only process whole events */ - while (count >= sizeof(snd_seq_event_t)) { + while (count >= sizeof(struct snd_seq_event)) { /* Read in the event header from the user */ len = sizeof(event); if (copy_from_user(&event, buf, len)) { @@ -1012,7 +1028,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, size_t c /* set user space pointer */ event.data.ext.len = extlen | SNDRV_SEQ_EXT_USRPTR; event.data.ext.ptr = (char __force *)buf - + sizeof(snd_seq_event_t); + + sizeof(struct snd_seq_event); len += extlen; /* increment data length */ } else { #ifdef CONFIG_COMPAT @@ -1046,7 +1062,7 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, size_t c */ static unsigned int snd_seq_poll(struct file *file, poll_table * wait) { - client_t *client = (client_t *) file->private_data; + struct snd_seq_client *client = file->private_data; unsigned int mask = 0; /* check client structures are in place */ @@ -1076,9 +1092,9 @@ static unsigned int snd_seq_poll(struct file *file, poll_table * wait) /* SYSTEM_INFO ioctl() */ -static int snd_seq_ioctl_system_info(client_t *client, void __user *arg) +static int snd_seq_ioctl_system_info(struct snd_seq_client *client, void __user *arg) { - snd_seq_system_info_t info; + struct snd_seq_system_info info; memset(&info, 0, sizeof(info)); /* fill the info fields */ @@ -1096,10 +1112,10 @@ static int snd_seq_ioctl_system_info(client_t *client, void __user *arg) /* RUNNING_MODE ioctl() */ -static int snd_seq_ioctl_running_mode(client_t *client, void __user *arg) +static int snd_seq_ioctl_running_mode(struct snd_seq_client *client, void __user *arg) { - struct sndrv_seq_running_info info; - client_t *cptr; + struct snd_seq_running_info info; + struct snd_seq_client *cptr; int err = 0; if (copy_from_user(&info, arg, sizeof(info))) @@ -1133,7 +1149,8 @@ static int snd_seq_ioctl_running_mode(client_t *client, void __user *arg) } /* CLIENT_INFO ioctl() */ -static void get_client_info(client_t *cptr, snd_seq_client_info_t *info) +static void get_client_info(struct snd_seq_client *cptr, + struct snd_seq_client_info *info) { info->client = cptr->number; @@ -1147,10 +1164,11 @@ static void get_client_info(client_t *cptr, snd_seq_client_info_t *info) memset(info->reserved, 0, sizeof(info->reserved)); } -static int snd_seq_ioctl_get_client_info(client_t * client, void __user *arg) +static int snd_seq_ioctl_get_client_info(struct snd_seq_client *client, + void __user *arg) { - client_t *cptr; - snd_seq_client_info_t client_info; + struct snd_seq_client *cptr; + struct snd_seq_client_info client_info; if (copy_from_user(&client_info, arg, sizeof(client_info))) return -EFAULT; @@ -1170,9 +1188,10 @@ static int snd_seq_ioctl_get_client_info(client_t * client, void __user *arg) /* CLIENT_INFO ioctl() */ -static int snd_seq_ioctl_set_client_info(client_t * client, void __user *arg) +static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client, + void __user *arg) { - snd_seq_client_info_t client_info; + struct snd_seq_client_info client_info; if (copy_from_user(&client_info, arg, sizeof(client_info))) return -EFAULT; @@ -1199,11 +1218,12 @@ static int snd_seq_ioctl_set_client_info(client_t * client, void __user *arg) /* * CREATE PORT ioctl() */ -static int snd_seq_ioctl_create_port(client_t * client, void __user *arg) +static int snd_seq_ioctl_create_port(struct snd_seq_client *client, + void __user *arg) { - client_port_t *port; - snd_seq_port_info_t info; - snd_seq_port_callback_t *callback; + struct snd_seq_client_port *port; + struct snd_seq_port_info info; + struct snd_seq_port_callback *callback; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1249,9 +1269,10 @@ static int snd_seq_ioctl_create_port(client_t * client, void __user *arg) /* * DELETE PORT ioctl() */ -static int snd_seq_ioctl_delete_port(client_t * client, void __user *arg) +static int snd_seq_ioctl_delete_port(struct snd_seq_client *client, + void __user *arg) { - snd_seq_port_info_t info; + struct snd_seq_port_info info; int err; /* set passed parameters */ @@ -1272,11 +1293,12 @@ static int snd_seq_ioctl_delete_port(client_t * client, void __user *arg) /* * GET_PORT_INFO ioctl() (on any client) */ -static int snd_seq_ioctl_get_port_info(client_t *client, void __user *arg) +static int snd_seq_ioctl_get_port_info(struct snd_seq_client *client, + void __user *arg) { - client_t *cptr; - client_port_t *port; - snd_seq_port_info_t info; + struct snd_seq_client *cptr; + struct snd_seq_client_port *port; + struct snd_seq_port_info info; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1304,10 +1326,11 @@ static int snd_seq_ioctl_get_port_info(client_t *client, void __user *arg) /* * SET_PORT_INFO ioctl() (only ports on this/own client) */ -static int snd_seq_ioctl_set_port_info(client_t * client, void __user *arg) +static int snd_seq_ioctl_set_port_info(struct snd_seq_client *client, + void __user *arg) { - client_port_t *port; - snd_seq_port_info_t info; + struct snd_seq_client_port *port; + struct snd_seq_port_info info; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1329,9 +1352,10 @@ static int snd_seq_ioctl_set_port_info(client_t * client, void __user *arg) #define PERM_RD (SNDRV_SEQ_PORT_CAP_READ|SNDRV_SEQ_PORT_CAP_SUBS_READ) #define PERM_WR (SNDRV_SEQ_PORT_CAP_WRITE|SNDRV_SEQ_PORT_CAP_SUBS_WRITE) -static int check_subscription_permission(client_t *client, client_port_t *sport, - client_port_t *dport, - snd_seq_port_subscribe_t *subs) +static int check_subscription_permission(struct snd_seq_client *client, + struct snd_seq_client_port *sport, + struct snd_seq_client_port *dport, + struct snd_seq_port_subscribe *subs) { if (client->number != subs->sender.client && client->number != subs->dest.client) { @@ -1363,9 +1387,10 @@ static int check_subscription_permission(client_t *client, client_port_t *sport, * client must be user client. */ int snd_seq_client_notify_subscription(int client, int port, - snd_seq_port_subscribe_t *info, int evtype) + struct snd_seq_port_subscribe *info, + int evtype) { - snd_seq_event_t event; + struct snd_seq_event event; memset(&event, 0, sizeof(event)); event.type = evtype; @@ -1379,12 +1404,13 @@ int snd_seq_client_notify_subscription(int client, int port, /* * add to port's subscription list IOCTL interface */ -static int snd_seq_ioctl_subscribe_port(client_t * client, void __user *arg) +static int snd_seq_ioctl_subscribe_port(struct snd_seq_client *client, + void __user *arg) { int result = -EINVAL; - client_t *receiver = NULL, *sender = NULL; - client_port_t *sport = NULL, *dport = NULL; - snd_seq_port_subscribe_t subs; + struct snd_seq_client *receiver = NULL, *sender = NULL; + struct snd_seq_client_port *sport = NULL, *dport = NULL; + struct snd_seq_port_subscribe subs; if (copy_from_user(&subs, arg, sizeof(subs))) return -EFAULT; @@ -1423,12 +1449,13 @@ static int snd_seq_ioctl_subscribe_port(client_t * client, void __user *arg) /* * remove from port's subscription list */ -static int snd_seq_ioctl_unsubscribe_port(client_t * client, void __user *arg) +static int snd_seq_ioctl_unsubscribe_port(struct snd_seq_client *client, + void __user *arg) { int result = -ENXIO; - client_t *receiver = NULL, *sender = NULL; - client_port_t *sport = NULL, *dport = NULL; - snd_seq_port_subscribe_t subs; + struct snd_seq_client *receiver = NULL, *sender = NULL; + struct snd_seq_client_port *sport = NULL, *dport = NULL; + struct snd_seq_port_subscribe subs; if (copy_from_user(&subs, arg, sizeof(subs))) return -EFAULT; @@ -1464,11 +1491,12 @@ static int snd_seq_ioctl_unsubscribe_port(client_t * client, void __user *arg) /* CREATE_QUEUE ioctl() */ -static int snd_seq_ioctl_create_queue(client_t *client, void __user *arg) +static int snd_seq_ioctl_create_queue(struct snd_seq_client *client, + void __user *arg) { - snd_seq_queue_info_t info; + struct snd_seq_queue_info info; int result; - queue_t *q; + struct snd_seq_queue *q; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1498,9 +1526,10 @@ static int snd_seq_ioctl_create_queue(client_t *client, void __user *arg) } /* DELETE_QUEUE ioctl() */ -static int snd_seq_ioctl_delete_queue(client_t *client, void __user *arg) +static int snd_seq_ioctl_delete_queue(struct snd_seq_client *client, + void __user *arg) { - snd_seq_queue_info_t info; + struct snd_seq_queue_info info; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1509,10 +1538,11 @@ static int snd_seq_ioctl_delete_queue(client_t *client, void __user *arg) } /* GET_QUEUE_INFO ioctl() */ -static int snd_seq_ioctl_get_queue_info(client_t *client, void __user *arg) +static int snd_seq_ioctl_get_queue_info(struct snd_seq_client *client, + void __user *arg) { - snd_seq_queue_info_t info; - queue_t *q; + struct snd_seq_queue_info info; + struct snd_seq_queue *q; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1535,10 +1565,11 @@ static int snd_seq_ioctl_get_queue_info(client_t *client, void __user *arg) } /* SET_QUEUE_INFO ioctl() */ -static int snd_seq_ioctl_set_queue_info(client_t *client, void __user *arg) +static int snd_seq_ioctl_set_queue_info(struct snd_seq_client *client, + void __user *arg) { - snd_seq_queue_info_t info; - queue_t *q; + struct snd_seq_queue_info info; + struct snd_seq_queue *q; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1570,10 +1601,10 @@ static int snd_seq_ioctl_set_queue_info(client_t *client, void __user *arg) } /* GET_NAMED_QUEUE ioctl() */ -static int snd_seq_ioctl_get_named_queue(client_t *client, void __user *arg) +static int snd_seq_ioctl_get_named_queue(struct snd_seq_client *client, void __user *arg) { - snd_seq_queue_info_t info; - queue_t *q; + struct snd_seq_queue_info info; + struct snd_seq_queue *q; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1593,11 +1624,12 @@ static int snd_seq_ioctl_get_named_queue(client_t *client, void __user *arg) } /* GET_QUEUE_STATUS ioctl() */ -static int snd_seq_ioctl_get_queue_status(client_t * client, void __user *arg) +static int snd_seq_ioctl_get_queue_status(struct snd_seq_client *client, + void __user *arg) { - snd_seq_queue_status_t status; - queue_t *queue; - seq_timer_t *tmr; + struct snd_seq_queue_status status; + struct snd_seq_queue *queue; + struct snd_seq_timer *tmr; if (copy_from_user(&status, arg, sizeof(status))) return -EFAULT; @@ -1626,11 +1658,12 @@ static int snd_seq_ioctl_get_queue_status(client_t * client, void __user *arg) /* GET_QUEUE_TEMPO ioctl() */ -static int snd_seq_ioctl_get_queue_tempo(client_t * client, void __user *arg) +static int snd_seq_ioctl_get_queue_tempo(struct snd_seq_client *client, + void __user *arg) { - snd_seq_queue_tempo_t tempo; - queue_t *queue; - seq_timer_t *tmr; + struct snd_seq_queue_tempo tempo; + struct snd_seq_queue *queue; + struct snd_seq_timer *tmr; if (copy_from_user(&tempo, arg, sizeof(tempo))) return -EFAULT; @@ -1656,17 +1689,18 @@ static int snd_seq_ioctl_get_queue_tempo(client_t * client, void __user *arg) /* SET_QUEUE_TEMPO ioctl() */ -int snd_seq_set_queue_tempo(int client, snd_seq_queue_tempo_t *tempo) +int snd_seq_set_queue_tempo(int client, struct snd_seq_queue_tempo *tempo) { if (!snd_seq_queue_check_access(tempo->queue, client)) return -EPERM; return snd_seq_queue_timer_set_tempo(tempo->queue, client, tempo); } -static int snd_seq_ioctl_set_queue_tempo(client_t * client, void __user *arg) +static int snd_seq_ioctl_set_queue_tempo(struct snd_seq_client *client, + void __user *arg) { int result; - snd_seq_queue_tempo_t tempo; + struct snd_seq_queue_tempo tempo; if (copy_from_user(&tempo, arg, sizeof(tempo))) return -EFAULT; @@ -1677,11 +1711,12 @@ static int snd_seq_ioctl_set_queue_tempo(client_t * client, void __user *arg) /* GET_QUEUE_TIMER ioctl() */ -static int snd_seq_ioctl_get_queue_timer(client_t * client, void __user *arg) +static int snd_seq_ioctl_get_queue_timer(struct snd_seq_client *client, + void __user *arg) { - snd_seq_queue_timer_t timer; - queue_t *queue; - seq_timer_t *tmr; + struct snd_seq_queue_timer timer; + struct snd_seq_queue *queue; + struct snd_seq_timer *tmr; if (copy_from_user(&timer, arg, sizeof(timer))) return -EFAULT; @@ -1713,10 +1748,11 @@ static int snd_seq_ioctl_get_queue_timer(client_t * client, void __user *arg) /* SET_QUEUE_TIMER ioctl() */ -static int snd_seq_ioctl_set_queue_timer(client_t * client, void __user *arg) +static int snd_seq_ioctl_set_queue_timer(struct snd_seq_client *client, + void __user *arg) { int result = 0; - snd_seq_queue_timer_t timer; + struct snd_seq_queue_timer timer; if (copy_from_user(&timer, arg, sizeof(timer))) return -EFAULT; @@ -1725,8 +1761,8 @@ static int snd_seq_ioctl_set_queue_timer(client_t * client, void __user *arg) return -EINVAL; if (snd_seq_queue_check_access(timer.queue, client->number)) { - queue_t *q; - seq_timer_t *tmr; + struct snd_seq_queue *q; + struct snd_seq_timer *tmr; q = queueptr(timer.queue); if (q == NULL) @@ -1754,9 +1790,10 @@ static int snd_seq_ioctl_set_queue_timer(client_t * client, void __user *arg) /* GET_QUEUE_CLIENT ioctl() */ -static int snd_seq_ioctl_get_queue_client(client_t * client, void __user *arg) +static int snd_seq_ioctl_get_queue_client(struct snd_seq_client *client, + void __user *arg) { - snd_seq_queue_client_t info; + struct snd_seq_queue_client info; int used; if (copy_from_user(&info, arg, sizeof(info))) @@ -1775,10 +1812,11 @@ static int snd_seq_ioctl_get_queue_client(client_t * client, void __user *arg) /* SET_QUEUE_CLIENT ioctl() */ -static int snd_seq_ioctl_set_queue_client(client_t * client, void __user *arg) +static int snd_seq_ioctl_set_queue_client(struct snd_seq_client *client, + void __user *arg) { int err; - snd_seq_queue_client_t info; + struct snd_seq_queue_client info; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1794,10 +1832,11 @@ static int snd_seq_ioctl_set_queue_client(client_t * client, void __user *arg) /* GET_CLIENT_POOL ioctl() */ -static int snd_seq_ioctl_get_client_pool(client_t * client, void __user *arg) +static int snd_seq_ioctl_get_client_pool(struct snd_seq_client *client, + void __user *arg) { - snd_seq_client_pool_t info; - client_t *cptr; + struct snd_seq_client_pool info; + struct snd_seq_client *cptr; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1828,9 +1867,10 @@ static int snd_seq_ioctl_get_client_pool(client_t * client, void __user *arg) } /* SET_CLIENT_POOL ioctl() */ -static int snd_seq_ioctl_set_client_pool(client_t * client, void __user *arg) +static int snd_seq_ioctl_set_client_pool(struct snd_seq_client *client, + void __user *arg) { - snd_seq_client_pool_t info; + struct snd_seq_client_pool info; int rc; if (copy_from_user(&info, arg, sizeof(info))) @@ -1872,9 +1912,10 @@ static int snd_seq_ioctl_set_client_pool(client_t * client, void __user *arg) /* REMOVE_EVENTS ioctl() */ -static int snd_seq_ioctl_remove_events(client_t * client, void __user *arg) +static int snd_seq_ioctl_remove_events(struct snd_seq_client *client, + void __user *arg) { - snd_seq_remove_events_t info; + struct snd_seq_remove_events info; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -1901,13 +1942,14 @@ static int snd_seq_ioctl_remove_events(client_t * client, void __user *arg) /* * get subscription info */ -static int snd_seq_ioctl_get_subscription(client_t *client, void __user *arg) +static int snd_seq_ioctl_get_subscription(struct snd_seq_client *client, + void __user *arg) { int result; - client_t *sender = NULL; - client_port_t *sport = NULL; - snd_seq_port_subscribe_t subs; - subscribers_t *p; + struct snd_seq_client *sender = NULL; + struct snd_seq_client_port *sport = NULL; + struct snd_seq_port_subscribe subs; + struct snd_seq_subscribers *p; if (copy_from_user(&subs, arg, sizeof(subs))) return -EFAULT; @@ -1940,13 +1982,14 @@ static int snd_seq_ioctl_get_subscription(client_t *client, void __user *arg) /* * get subscription info - check only its presence */ -static int snd_seq_ioctl_query_subs(client_t *client, void __user *arg) +static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, + void __user *arg) { int result = -ENXIO; - client_t *cptr = NULL; - client_port_t *port = NULL; - snd_seq_query_subs_t subs; - port_subs_info_t *group; + struct snd_seq_client *cptr = NULL; + struct snd_seq_client_port *port = NULL; + struct snd_seq_query_subs subs; + struct snd_seq_port_subs_info *group; struct list_head *p; int i; @@ -1977,12 +2020,12 @@ static int snd_seq_ioctl_query_subs(client_t *client, void __user *arg) list_for_each(p, &group->list_head) { if (i++ == subs.index) { /* found! */ - subscribers_t *s; + struct snd_seq_subscribers *s; if (subs.type == SNDRV_SEQ_QUERY_SUBS_READ) { - s = list_entry(p, subscribers_t, src_list); + s = list_entry(p, struct snd_seq_subscribers, src_list); subs.addr = s->info.dest; } else { - s = list_entry(p, subscribers_t, dest_list); + s = list_entry(p, struct snd_seq_subscribers, dest_list); subs.addr = s->info.sender; } subs.flags = s->info.flags; @@ -2009,10 +2052,11 @@ static int snd_seq_ioctl_query_subs(client_t *client, void __user *arg) /* * query next client */ -static int snd_seq_ioctl_query_next_client(client_t *client, void __user *arg) +static int snd_seq_ioctl_query_next_client(struct snd_seq_client *client, + void __user *arg) { - client_t *cptr = NULL; - snd_seq_client_info_t info; + struct snd_seq_client *cptr = NULL; + struct snd_seq_client_info info; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -2040,11 +2084,12 @@ static int snd_seq_ioctl_query_next_client(client_t *client, void __user *arg) /* * query next port */ -static int snd_seq_ioctl_query_next_port(client_t *client, void __user *arg) +static int snd_seq_ioctl_query_next_port(struct snd_seq_client *client, + void __user *arg) { - client_t *cptr; - client_port_t *port = NULL; - snd_seq_port_info_t info; + struct snd_seq_client *cptr; + struct snd_seq_client_port *port = NULL; + struct snd_seq_port_info info; if (copy_from_user(&info, arg, sizeof(info))) return -EFAULT; @@ -2075,7 +2120,7 @@ static int snd_seq_ioctl_query_next_port(client_t *client, void __user *arg) static struct seq_ioctl_table { unsigned int cmd; - int (*func)(client_t *client, void __user * arg); + int (*func)(struct snd_seq_client *client, void __user * arg); } ioctl_tables[] = { { SNDRV_SEQ_IOCTL_SYSTEM_INFO, snd_seq_ioctl_system_info }, { SNDRV_SEQ_IOCTL_RUNNING_MODE, snd_seq_ioctl_running_mode }, @@ -2109,7 +2154,8 @@ static struct seq_ioctl_table { { 0, NULL }, }; -static int snd_seq_do_ioctl(client_t *client, unsigned int cmd, void __user *arg) +static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd, + void __user *arg) { struct seq_ioctl_table *p; @@ -2136,7 +2182,7 @@ static int snd_seq_do_ioctl(client_t *client, unsigned int cmd, void __user *arg static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - client_t *client = (client_t *) file->private_data; + struct snd_seq_client *client = file->private_data; snd_assert(client != NULL, return -ENXIO); @@ -2153,9 +2199,10 @@ static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg /* exported to kernel modules */ -int snd_seq_create_kernel_client(snd_card_t *card, int client_index, snd_seq_client_callback_t * callback) +int snd_seq_create_kernel_client(struct snd_card *card, int client_index, + struct snd_seq_client_callback *callback) { - client_t *client; + struct snd_seq_client *client; snd_assert(! in_interrupt(), return -EBUSY); @@ -2199,7 +2246,7 @@ int snd_seq_create_kernel_client(snd_card_t *card, int client_index, snd_seq_cli /* exported to kernel modules */ int snd_seq_delete_kernel_client(int client) { - client_t *ptr; + struct snd_seq_client *ptr; snd_assert(! in_interrupt(), return -EBUSY); @@ -2216,11 +2263,11 @@ int snd_seq_delete_kernel_client(int client) /* skeleton to enqueue event, called from snd_seq_kernel_client_enqueue * and snd_seq_kernel_client_enqueue_blocking */ -static int kernel_client_enqueue(int client, snd_seq_event_t *ev, +static int kernel_client_enqueue(int client, struct snd_seq_event *ev, struct file *file, int blocking, int atomic, int hop) { - client_t *cptr; + struct snd_seq_client *cptr; int result; snd_assert(ev != NULL, return -EINVAL); @@ -2254,7 +2301,7 @@ static int kernel_client_enqueue(int client, snd_seq_event_t *ev, * * RETURN VALUE: zero if succeed, negative if error */ -int snd_seq_kernel_client_enqueue(int client, snd_seq_event_t * ev, +int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event * ev, int atomic, int hop) { return kernel_client_enqueue(client, ev, NULL, 0, atomic, hop); @@ -2265,7 +2312,7 @@ int snd_seq_kernel_client_enqueue(int client, snd_seq_event_t * ev, * * RETURN VALUE: zero if succeed, negative if error */ -int snd_seq_kernel_client_enqueue_blocking(int client, snd_seq_event_t * ev, +int snd_seq_kernel_client_enqueue_blocking(int client, struct snd_seq_event * ev, struct file *file, int atomic, int hop) { @@ -2280,10 +2327,10 @@ int snd_seq_kernel_client_enqueue_blocking(int client, snd_seq_event_t * ev, * RETURN VALUE: negative = delivery failed, * zero, or positive: the number of delivered events */ -int snd_seq_kernel_client_dispatch(int client, snd_seq_event_t * ev, +int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event * ev, int atomic, int hop) { - client_t *cptr; + struct snd_seq_client *cptr; int result; snd_assert(ev != NULL, return -EINVAL); @@ -2315,7 +2362,7 @@ int snd_seq_kernel_client_dispatch(int client, snd_seq_event_t * ev, */ int snd_seq_kernel_client_ctl(int clientid, unsigned int cmd, void *arg) { - client_t *client; + struct snd_seq_client *client; mm_segment_t fs; int result; @@ -2332,7 +2379,7 @@ int snd_seq_kernel_client_ctl(int clientid, unsigned int cmd, void *arg) /* exported (for OSS emulator) */ int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table *wait) { - client_t *client; + struct snd_seq_client *client; client = clientptr(clientid); if (client == NULL) @@ -2350,10 +2397,12 @@ int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table /* * /proc interface */ -static void snd_seq_info_dump_subscribers(snd_info_buffer_t *buffer, port_subs_info_t *group, int is_src, char *msg) +static void snd_seq_info_dump_subscribers(struct snd_info_buffer *buffer, + struct snd_seq_port_subs_info *group, + int is_src, char *msg) { struct list_head *p; - subscribers_t *s; + struct snd_seq_subscribers *s; int count = 0; down_read(&group->list_mutex); @@ -2364,9 +2413,9 @@ static void snd_seq_info_dump_subscribers(snd_info_buffer_t *buffer, port_subs_i snd_iprintf(buffer, msg); list_for_each(p, &group->list_head) { if (is_src) - s = list_entry(p, subscribers_t, src_list); + s = list_entry(p, struct snd_seq_subscribers, src_list); else - s = list_entry(p, subscribers_t, dest_list); + s = list_entry(p, struct snd_seq_subscribers, dest_list); if (count++) snd_iprintf(buffer, ", "); snd_iprintf(buffer, "%d:%d", @@ -2387,13 +2436,14 @@ static void snd_seq_info_dump_subscribers(snd_info_buffer_t *buffer, port_subs_i #define FLAG_PERM_DUPLEX(perm) ((perm) & SNDRV_SEQ_PORT_CAP_DUPLEX ? 'X' : '-') -static void snd_seq_info_dump_ports(snd_info_buffer_t *buffer, client_t *client) +static void snd_seq_info_dump_ports(struct snd_info_buffer *buffer, + struct snd_seq_client *client) { struct list_head *l; down(&client->ports_mutex); list_for_each(l, &client->ports_list_head) { - client_port_t *p = list_entry(l, client_port_t, list); + struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); snd_iprintf(buffer, " Port %3d : \"%s\" (%c%c%c%c)\n", p->addr.port, p->name, FLAG_PERM_RD(p->capability), @@ -2407,13 +2457,15 @@ static void snd_seq_info_dump_ports(snd_info_buffer_t *buffer, client_t *client) } +void snd_seq_info_pool(struct snd_info_buffer *buffer, + struct snd_seq_pool *pool, char *space); + /* exported to seq_info.c */ -void snd_seq_info_clients_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +void snd_seq_info_clients_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - extern void snd_seq_info_pool(snd_info_buffer_t * buffer, pool_t * pool, char *space); int c; - client_t *client; + struct snd_seq_client *client; snd_iprintf(buffer, "Client info\n"); snd_iprintf(buffer, " cur clients : %d\n", client_usage.cur); @@ -2468,7 +2520,7 @@ static struct file_operations snd_seq_f_ops = .compat_ioctl = snd_seq_ioctl_compat, }; -static snd_minor_t snd_seq_reg = +static struct snd_minor snd_seq_reg = { .comment = "sequencer", .f_ops = &snd_seq_f_ops, diff --git a/sound/core/seq/seq_clientmgr.h b/sound/core/seq/seq_clientmgr.h index 3715c36..9df5624 100644 --- a/sound/core/seq/seq_clientmgr.h +++ b/sound/core/seq/seq_clientmgr.h @@ -30,24 +30,24 @@ /* client manager */ -struct _snd_seq_user_client { +struct snd_seq_user_client { struct file *file; /* file struct of client */ /* ... */ /* fifo */ - fifo_t *fifo; /* queue for incoming events */ + struct snd_seq_fifo *fifo; /* queue for incoming events */ int fifo_pool_size; }; -struct _snd_seq_kernel_client { - snd_card_t *card; +struct snd_seq_kernel_client { + struct snd_card *card; /* pointer to client functions */ void *private_data; /* private data for client */ /* ... */ }; -struct _snd_seq_client { +struct snd_seq_client { snd_seq_client_type_t type; unsigned int accept_input: 1, accept_output: 1; @@ -65,40 +65,42 @@ struct _snd_seq_client { int convert32; /* convert 32->64bit */ /* output pool */ - pool_t *pool; /* memory pool for this client */ + struct snd_seq_pool *pool; /* memory pool for this client */ union { - user_client_t user; - kernel_client_t kernel; + struct snd_seq_user_client user; + struct snd_seq_kernel_client kernel; } data; }; /* usage statistics */ -typedef struct { +struct snd_seq_usage { int cur; int peak; -} usage_t; +}; -extern int client_init_data(void); -extern int snd_sequencer_device_init(void); -extern void snd_sequencer_device_done(void); +int client_init_data(void); +int snd_sequencer_device_init(void); +void snd_sequencer_device_done(void); /* get locked pointer to client */ -extern client_t *snd_seq_client_use_ptr(int clientid); +struct snd_seq_client *snd_seq_client_use_ptr(int clientid); /* unlock pointer to client */ #define snd_seq_client_unlock(client) snd_use_lock_free(&(client)->use_lock) /* dispatch event to client(s) */ -extern int snd_seq_dispatch_event(snd_seq_event_cell_t *cell, int atomic, int hop); +int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop); /* exported to other modules */ -extern int snd_seq_register_kernel_client(snd_seq_client_callback_t *callback, void *private_data); -extern int snd_seq_unregister_kernel_client(int client); -extern int snd_seq_kernel_client_enqueue(int client, snd_seq_event_t *ev, int atomic, int hop); -int snd_seq_kernel_client_enqueue_blocking(int client, snd_seq_event_t * ev, struct file *file, int atomic, int hop); +int snd_seq_register_kernel_client(struct snd_seq_client_callback *callback, void *private_data); +int snd_seq_unregister_kernel_client(int client); +int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop); +int snd_seq_kernel_client_enqueue_blocking(int client, struct snd_seq_event * ev, + struct file *file, int atomic, int hop); int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table *wait); -int snd_seq_client_notify_subscription(int client, int port, snd_seq_port_subscribe_t *info, int evtype); +int snd_seq_client_notify_subscription(int client, int port, + struct snd_seq_port_subscribe *info, int evtype); #endif diff --git a/sound/core/seq/seq_compat.c b/sound/core/seq/seq_compat.c index 902ad8b..9628c06 100644 --- a/sound/core/seq/seq_compat.c +++ b/sound/core/seq/seq_compat.c @@ -22,8 +22,8 @@ #include <linux/compat.h> -struct sndrv_seq_port_info32 { - struct sndrv_seq_addr addr; /* client/port numbers */ +struct snd_seq_port_info32 { + struct snd_seq_addr addr; /* client/port numbers */ char name[64]; /* port name */ u32 capability; /* port capability bits */ @@ -41,11 +41,11 @@ struct sndrv_seq_port_info32 { char reserved[59]; /* for future use */ }; -static int snd_seq_call_port_info_ioctl(client_t *client, unsigned int cmd, - struct sndrv_seq_port_info32 __user *data32) +static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned int cmd, + struct snd_seq_port_info32 __user *data32) { int err = -EFAULT; - snd_seq_port_info_t *data; + struct snd_seq_port_info *data; mm_segment_t fs; data = kmalloc(sizeof(*data), GFP_KERNEL); @@ -80,16 +80,16 @@ static int snd_seq_call_port_info_ioctl(client_t *client, unsigned int cmd, */ enum { - SNDRV_SEQ_IOCTL_CREATE_PORT32 = _IOWR('S', 0x20, struct sndrv_seq_port_info32), - SNDRV_SEQ_IOCTL_DELETE_PORT32 = _IOW ('S', 0x21, struct sndrv_seq_port_info32), - SNDRV_SEQ_IOCTL_GET_PORT_INFO32 = _IOWR('S', 0x22, struct sndrv_seq_port_info32), - SNDRV_SEQ_IOCTL_SET_PORT_INFO32 = _IOW ('S', 0x23, struct sndrv_seq_port_info32), - SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT32 = _IOWR('S', 0x52, struct sndrv_seq_port_info32), + SNDRV_SEQ_IOCTL_CREATE_PORT32 = _IOWR('S', 0x20, struct snd_seq_port_info32), + SNDRV_SEQ_IOCTL_DELETE_PORT32 = _IOW ('S', 0x21, struct snd_seq_port_info32), + SNDRV_SEQ_IOCTL_GET_PORT_INFO32 = _IOWR('S', 0x22, struct snd_seq_port_info32), + SNDRV_SEQ_IOCTL_SET_PORT_INFO32 = _IOW ('S', 0x23, struct snd_seq_port_info32), + SNDRV_SEQ_IOCTL_QUERY_NEXT_PORT32 = _IOWR('S', 0x52, struct snd_seq_port_info32), }; static long snd_seq_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg) { - client_t *client = (client_t *) file->private_data; + struct snd_seq_client *client = file->private_data; void __user *argp = compat_ptr(arg); snd_assert(client != NULL, return -ENXIO); diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c index 252b527..3f935a1 100644 --- a/sound/core/seq/seq_device.c +++ b/sound/core/seq/seq_device.c @@ -50,11 +50,6 @@ MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); MODULE_DESCRIPTION("ALSA sequencer device management"); MODULE_LICENSE("GPL"); -/* - * driver list - */ -typedef struct ops_list ops_list_t; - /* driver state */ #define DRIVER_EMPTY 0 #define DRIVER_LOADED (1<<0) @@ -68,7 +63,7 @@ struct ops_list { int argsize; /* argument size */ /* operators */ - snd_seq_dev_ops_t ops; + struct snd_seq_dev_ops ops; /* registred devices */ struct list_head dev_list; /* list of devices */ @@ -83,35 +78,36 @@ struct ops_list { static LIST_HEAD(opslist); static int num_ops; static DECLARE_MUTEX(ops_mutex); -static snd_info_entry_t *info_entry = NULL; +static struct snd_info_entry *info_entry = NULL; /* * prototypes */ -static int snd_seq_device_free(snd_seq_device_t *dev); -static int snd_seq_device_dev_free(snd_device_t *device); -static int snd_seq_device_dev_register(snd_device_t *device); -static int snd_seq_device_dev_disconnect(snd_device_t *device); -static int snd_seq_device_dev_unregister(snd_device_t *device); - -static int init_device(snd_seq_device_t *dev, ops_list_t *ops); -static int free_device(snd_seq_device_t *dev, ops_list_t *ops); -static ops_list_t *find_driver(char *id, int create_if_empty); -static ops_list_t *create_driver(char *id); -static void unlock_driver(ops_list_t *ops); +static int snd_seq_device_free(struct snd_seq_device *dev); +static int snd_seq_device_dev_free(struct snd_device *device); +static int snd_seq_device_dev_register(struct snd_device *device); +static int snd_seq_device_dev_disconnect(struct snd_device *device); +static int snd_seq_device_dev_unregister(struct snd_device *device); + +static int init_device(struct snd_seq_device *dev, struct ops_list *ops); +static int free_device(struct snd_seq_device *dev, struct ops_list *ops); +static struct ops_list *find_driver(char *id, int create_if_empty); +static struct ops_list *create_driver(char *id); +static void unlock_driver(struct ops_list *ops); static void remove_drivers(void); /* * show all drivers and their status */ -static void snd_seq_device_info(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_seq_device_info(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { struct list_head *head; down(&ops_mutex); list_for_each(head, &opslist) { - ops_list_t *ops = list_entry(head, ops_list_t, list); + struct ops_list *ops = list_entry(head, struct ops_list, list); snd_iprintf(buffer, "snd-%s%s%s%s,%d\n", ops->id, ops->driver & DRIVER_LOADED ? ",loaded" : (ops->driver == DRIVER_EMPTY ? ",empty" : ""), @@ -156,7 +152,7 @@ void snd_seq_device_load_drivers(void) down(&ops_mutex); list_for_each(head, &opslist) { - ops_list_t *ops = list_entry(head, ops_list_t, list); + struct ops_list *ops = list_entry(head, struct ops_list, list); if (! (ops->driver & DRIVER_LOADED) && ! (ops->driver & DRIVER_REQUESTED)) { ops->used++; @@ -178,13 +174,13 @@ void snd_seq_device_load_drivers(void) * id = id of driver * result = return pointer (NULL allowed if unnecessary) */ -int snd_seq_device_new(snd_card_t *card, int device, char *id, int argsize, - snd_seq_device_t **result) +int snd_seq_device_new(struct snd_card *card, int device, char *id, int argsize, + struct snd_seq_device **result) { - snd_seq_device_t *dev; - ops_list_t *ops; + struct snd_seq_device *dev; + struct ops_list *ops; int err; - static snd_device_ops_t dops = { + static struct snd_device_ops dops = { .dev_free = snd_seq_device_dev_free, .dev_register = snd_seq_device_dev_register, .dev_disconnect = snd_seq_device_dev_disconnect, @@ -235,9 +231,9 @@ int snd_seq_device_new(snd_card_t *card, int device, char *id, int argsize, /* * free the existing device */ -static int snd_seq_device_free(snd_seq_device_t *dev) +static int snd_seq_device_free(struct snd_seq_device *dev) { - ops_list_t *ops; + struct ops_list *ops; snd_assert(dev != NULL, return -EINVAL); @@ -261,19 +257,19 @@ static int snd_seq_device_free(snd_seq_device_t *dev) return 0; } -static int snd_seq_device_dev_free(snd_device_t *device) +static int snd_seq_device_dev_free(struct snd_device *device) { - snd_seq_device_t *dev = device->device_data; + struct snd_seq_device *dev = device->device_data; return snd_seq_device_free(dev); } /* * register the device */ -static int snd_seq_device_dev_register(snd_device_t *device) +static int snd_seq_device_dev_register(struct snd_device *device) { - snd_seq_device_t *dev = device->device_data; - ops_list_t *ops; + struct snd_seq_device *dev = device->device_data; + struct ops_list *ops; ops = find_driver(dev->id, 0); if (ops == NULL) @@ -292,10 +288,10 @@ static int snd_seq_device_dev_register(snd_device_t *device) /* * disconnect the device */ -static int snd_seq_device_dev_disconnect(snd_device_t *device) +static int snd_seq_device_dev_disconnect(struct snd_device *device) { - snd_seq_device_t *dev = device->device_data; - ops_list_t *ops; + struct snd_seq_device *dev = device->device_data; + struct ops_list *ops; ops = find_driver(dev->id, 0); if (ops == NULL) @@ -310,9 +306,9 @@ static int snd_seq_device_dev_disconnect(snd_device_t *device) /* * unregister the existing device */ -static int snd_seq_device_dev_unregister(snd_device_t *device) +static int snd_seq_device_dev_unregister(struct snd_device *device) { - snd_seq_device_t *dev = device->device_data; + struct snd_seq_device *dev = device->device_data; return snd_seq_device_free(dev); } @@ -321,10 +317,11 @@ static int snd_seq_device_dev_unregister(snd_device_t *device) * id = driver id * entry = driver operators - duplicated to each instance */ -int snd_seq_device_register_driver(char *id, snd_seq_dev_ops_t *entry, int argsize) +int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry, + int argsize) { struct list_head *head; - ops_list_t *ops; + struct ops_list *ops; if (id == NULL || entry == NULL || entry->init_device == NULL || entry->free_device == NULL) @@ -351,7 +348,7 @@ int snd_seq_device_register_driver(char *id, snd_seq_dev_ops_t *entry, int argsi /* initialize existing devices if necessary */ list_for_each(head, &ops->dev_list) { - snd_seq_device_t *dev = list_entry(head, snd_seq_device_t, list); + struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); init_device(dev, ops); } up(&ops->reg_mutex); @@ -366,9 +363,9 @@ int snd_seq_device_register_driver(char *id, snd_seq_dev_ops_t *entry, int argsi /* * create driver record */ -static ops_list_t * create_driver(char *id) +static struct ops_list * create_driver(char *id) { - ops_list_t *ops; + struct ops_list *ops; ops = kmalloc(sizeof(*ops), GFP_KERNEL); if (ops == NULL) @@ -399,14 +396,15 @@ static ops_list_t * create_driver(char *id) int snd_seq_device_unregister_driver(char *id) { struct list_head *head; - ops_list_t *ops; + struct ops_list *ops; ops = find_driver(id, 0); if (ops == NULL) return -ENXIO; if (! (ops->driver & DRIVER_LOADED) || (ops->driver & DRIVER_LOCKED)) { - snd_printk(KERN_ERR "driver_unregister: cannot unload driver '%s': status=%x\n", id, ops->driver); + snd_printk(KERN_ERR "driver_unregister: cannot unload driver '%s': status=%x\n", + id, ops->driver); unlock_driver(ops); return -EBUSY; } @@ -415,13 +413,14 @@ int snd_seq_device_unregister_driver(char *id) down(&ops->reg_mutex); ops->driver |= DRIVER_LOCKED; /* do not remove this driver recursively */ list_for_each(head, &ops->dev_list) { - snd_seq_device_t *dev = list_entry(head, snd_seq_device_t, list); + struct snd_seq_device *dev = list_entry(head, struct snd_seq_device, list); free_device(dev, ops); } ops->driver = 0; if (ops->num_init_devices > 0) - snd_printk(KERN_ERR "free_driver: init_devices > 0!! (%d)\n", ops->num_init_devices); + snd_printk(KERN_ERR "free_driver: init_devices > 0!! (%d)\n", + ops->num_init_devices); up(&ops->reg_mutex); unlock_driver(ops); @@ -443,7 +442,7 @@ static void remove_drivers(void) down(&ops_mutex); head = opslist.next; while (head != &opslist) { - ops_list_t *ops = list_entry(head, ops_list_t, list); + struct ops_list *ops = list_entry(head, struct ops_list, list); if (! (ops->driver & DRIVER_LOADED) && ops->used == 0 && ops->num_devices == 0) { head = head->next; @@ -459,21 +458,23 @@ static void remove_drivers(void) /* * initialize the device - call init_device operator */ -static int init_device(snd_seq_device_t *dev, ops_list_t *ops) +static int init_device(struct snd_seq_device *dev, struct ops_list *ops) { if (! (ops->driver & DRIVER_LOADED)) return 0; /* driver is not loaded yet */ if (dev->status != SNDRV_SEQ_DEVICE_FREE) return 0; /* already initialized */ if (ops->argsize != dev->argsize) { - snd_printk(KERN_ERR "incompatible device '%s' for plug-in '%s' (%d %d)\n", dev->name, ops->id, ops->argsize, dev->argsize); + snd_printk(KERN_ERR "incompatible device '%s' for plug-in '%s' (%d %d)\n", + dev->name, ops->id, ops->argsize, dev->argsize); return -EINVAL; } if (ops->ops.init_device(dev) >= 0) { dev->status = SNDRV_SEQ_DEVICE_REGISTERED; ops->num_init_devices++; } else { - snd_printk(KERN_ERR "init_device failed: %s: %s\n", dev->name, dev->id); + snd_printk(KERN_ERR "init_device failed: %s: %s\n", + dev->name, dev->id); } return 0; @@ -482,7 +483,7 @@ static int init_device(snd_seq_device_t *dev, ops_list_t *ops) /* * release the device - call free_device operator */ -static int free_device(snd_seq_device_t *dev, ops_list_t *ops) +static int free_device(struct snd_seq_device *dev, struct ops_list *ops) { int result; @@ -491,7 +492,8 @@ static int free_device(snd_seq_device_t *dev, ops_list_t *ops) if (dev->status != SNDRV_SEQ_DEVICE_REGISTERED) return 0; /* not registered */ if (ops->argsize != dev->argsize) { - snd_printk(KERN_ERR "incompatible device '%s' for plug-in '%s' (%d %d)\n", dev->name, ops->id, ops->argsize, dev->argsize); + snd_printk(KERN_ERR "incompatible device '%s' for plug-in '%s' (%d %d)\n", + dev->name, ops->id, ops->argsize, dev->argsize); return -EINVAL; } if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) { @@ -499,7 +501,8 @@ static int free_device(snd_seq_device_t *dev, ops_list_t *ops) dev->driver_data = NULL; ops->num_init_devices--; } else { - snd_printk(KERN_ERR "free_device failed: %s: %s\n", dev->name, dev->id); + snd_printk(KERN_ERR "free_device failed: %s: %s\n", + dev->name, dev->id); } return 0; @@ -508,13 +511,13 @@ static int free_device(snd_seq_device_t *dev, ops_list_t *ops) /* * find the matching driver with given id */ -static ops_list_t * find_driver(char *id, int create_if_empty) +static struct ops_list * find_driver(char *id, int create_if_empty) { struct list_head *head; down(&ops_mutex); list_for_each(head, &opslist) { - ops_list_t *ops = list_entry(head, ops_list_t, list); + struct ops_list *ops = list_entry(head, struct ops_list, list); if (strcmp(ops->id, id) == 0) { ops->used++; up(&ops_mutex); @@ -527,7 +530,7 @@ static ops_list_t * find_driver(char *id, int create_if_empty) return NULL; } -static void unlock_driver(ops_list_t *ops) +static void unlock_driver(struct ops_list *ops) { down(&ops_mutex); ops->used--; @@ -541,7 +544,8 @@ static void unlock_driver(ops_list_t *ops) static int __init alsa_seq_device_init(void) { - info_entry = snd_info_create_module_entry(THIS_MODULE, "drivers", snd_seq_root); + info_entry = snd_info_create_module_entry(THIS_MODULE, "drivers", + snd_seq_root); if (info_entry == NULL) return -ENOMEM; info_entry->content = SNDRV_INFO_CONTENT_TEXT; diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c index 5dd0e6a..8101a47 100644 --- a/sound/core/seq/seq_dummy.c +++ b/sound/core/seq/seq_dummy.c @@ -73,12 +73,12 @@ MODULE_PARM_DESC(ports, "number of ports to be created"); module_param(duplex, bool, 0444); MODULE_PARM_DESC(duplex, "create DUPLEX ports"); -typedef struct snd_seq_dummy_port { +struct snd_seq_dummy_port { int client; int port; int duplex; int connect; -} snd_seq_dummy_port_t; +}; static int my_client = -1; @@ -88,11 +88,11 @@ static int my_client = -1; * Note: this callback is called only after all subscribers are removed. */ static int -dummy_unuse(void *private_data, snd_seq_port_subscribe_t *info) +dummy_unuse(void *private_data, struct snd_seq_port_subscribe *info) { - snd_seq_dummy_port_t *p; + struct snd_seq_dummy_port *p; int i; - snd_seq_event_t ev; + struct snd_seq_event ev; p = private_data; memset(&ev, 0, sizeof(ev)); @@ -116,10 +116,11 @@ dummy_unuse(void *private_data, snd_seq_port_subscribe_t *info) * event input callback - just redirect events to subscribers */ static int -dummy_input(snd_seq_event_t *ev, int direct, void *private_data, int atomic, int hop) +dummy_input(struct snd_seq_event *ev, int direct, void *private_data, + int atomic, int hop) { - snd_seq_dummy_port_t *p; - snd_seq_event_t tmpev; + struct snd_seq_dummy_port *p; + struct snd_seq_event tmpev; p = private_data; if (ev->source.client == SNDRV_SEQ_CLIENT_SYSTEM || @@ -146,12 +147,12 @@ dummy_free(void *private_data) /* * create a port */ -static snd_seq_dummy_port_t __init * +static struct snd_seq_dummy_port __init * create_port(int idx, int type) { - snd_seq_port_info_t pinfo; - snd_seq_port_callback_t pcb; - snd_seq_dummy_port_t *rec; + struct snd_seq_port_info pinfo; + struct snd_seq_port_callback pcb; + struct snd_seq_dummy_port *rec; if ((rec = kzalloc(sizeof(*rec), GFP_KERNEL)) == NULL) return NULL; @@ -192,9 +193,9 @@ create_port(int idx, int type) static int __init register_client(void) { - snd_seq_client_callback_t cb; - snd_seq_client_info_t cinfo; - snd_seq_dummy_port_t *rec1, *rec2; + struct snd_seq_client_callback cb; + struct snd_seq_client_info cinfo; + struct snd_seq_dummy_port *rec1, *rec2; int i; if (ports < 1) { diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c index 4767cfd..6b055ae 100644 --- a/sound/core/seq/seq_fifo.c +++ b/sound/core/seq/seq_fifo.c @@ -29,9 +29,9 @@ /* FIFO */ /* create new fifo */ -fifo_t *snd_seq_fifo_new(int poolsize) +struct snd_seq_fifo *snd_seq_fifo_new(int poolsize) { - fifo_t *f; + struct snd_seq_fifo *f; f = kzalloc(sizeof(*f), GFP_KERNEL); if (f == NULL) { @@ -62,9 +62,9 @@ fifo_t *snd_seq_fifo_new(int poolsize) return f; } -void snd_seq_fifo_delete(fifo_t **fifo) +void snd_seq_fifo_delete(struct snd_seq_fifo **fifo) { - fifo_t *f; + struct snd_seq_fifo *f; snd_assert(fifo != NULL, return); f = *fifo; @@ -88,12 +88,12 @@ void snd_seq_fifo_delete(fifo_t **fifo) kfree(f); } -static snd_seq_event_cell_t *fifo_cell_out(fifo_t *f); +static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f); /* clear queue */ -void snd_seq_fifo_clear(fifo_t *f) +void snd_seq_fifo_clear(struct snd_seq_fifo *f) { - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; unsigned long flags; /* clear overflow flag */ @@ -110,9 +110,10 @@ void snd_seq_fifo_clear(fifo_t *f) /* enqueue event to fifo */ -int snd_seq_fifo_event_in(fifo_t *f, snd_seq_event_t *event) +int snd_seq_fifo_event_in(struct snd_seq_fifo *f, + struct snd_seq_event *event) { - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; unsigned long flags; int err; @@ -148,9 +149,9 @@ int snd_seq_fifo_event_in(fifo_t *f, snd_seq_event_t *event) } /* dequeue cell from fifo */ -static snd_seq_event_cell_t *fifo_cell_out(fifo_t *f) +static struct snd_seq_event_cell *fifo_cell_out(struct snd_seq_fifo *f) { - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; if ((cell = f->head) != NULL) { f->head = cell->next; @@ -167,9 +168,10 @@ static snd_seq_event_cell_t *fifo_cell_out(fifo_t *f) } /* dequeue cell from fifo and copy on user space */ -int snd_seq_fifo_cell_out(fifo_t *f, snd_seq_event_cell_t **cellp, int nonblock) +int snd_seq_fifo_cell_out(struct snd_seq_fifo *f, + struct snd_seq_event_cell **cellp, int nonblock) { - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; unsigned long flags; wait_queue_t wait; @@ -202,7 +204,8 @@ int snd_seq_fifo_cell_out(fifo_t *f, snd_seq_event_cell_t **cellp, int nonblock) } -void snd_seq_fifo_cell_putback(fifo_t *f, snd_seq_event_cell_t *cell) +void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f, + struct snd_seq_event_cell *cell) { unsigned long flags; @@ -217,18 +220,19 @@ void snd_seq_fifo_cell_putback(fifo_t *f, snd_seq_event_cell_t *cell) /* polling; return non-zero if queue is available */ -int snd_seq_fifo_poll_wait(fifo_t *f, struct file *file, poll_table *wait) +int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, + poll_table *wait) { poll_wait(file, &f->input_sleep, wait); return (f->cells > 0); } /* change the size of pool; all old events are removed */ -int snd_seq_fifo_resize(fifo_t *f, int poolsize) +int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) { unsigned long flags; - pool_t *newpool, *oldpool; - snd_seq_event_cell_t *cell, *next, *oldhead; + struct snd_seq_pool *newpool, *oldpool; + struct snd_seq_event_cell *cell, *next, *oldhead; snd_assert(f != NULL && f->pool != NULL, return -EINVAL); diff --git a/sound/core/seq/seq_fifo.h b/sound/core/seq/seq_fifo.h index d677c26..062c446 100644 --- a/sound/core/seq/seq_fifo.h +++ b/sound/core/seq/seq_fifo.h @@ -27,46 +27,46 @@ /* === FIFO === */ -typedef struct { - pool_t *pool; /* FIFO pool */ - snd_seq_event_cell_t* head; /* pointer to head of fifo */ - snd_seq_event_cell_t* tail; /* pointer to tail of fifo */ +struct snd_seq_fifo { + struct snd_seq_pool *pool; /* FIFO pool */ + struct snd_seq_event_cell *head; /* pointer to head of fifo */ + struct snd_seq_event_cell *tail; /* pointer to tail of fifo */ int cells; spinlock_t lock; snd_use_lock_t use_lock; wait_queue_head_t input_sleep; atomic_t overflow; -} fifo_t; +}; /* create new fifo (constructor) */ -extern fifo_t *snd_seq_fifo_new(int poolsize); +struct snd_seq_fifo *snd_seq_fifo_new(int poolsize); /* delete fifo (destructor) */ -extern void snd_seq_fifo_delete(fifo_t **f); +void snd_seq_fifo_delete(struct snd_seq_fifo **f); /* enqueue event to fifo */ -extern int snd_seq_fifo_event_in(fifo_t *f, snd_seq_event_t *event); +int snd_seq_fifo_event_in(struct snd_seq_fifo *f, struct snd_seq_event *event); /* lock fifo from release */ #define snd_seq_fifo_lock(fifo) snd_use_lock_use(&(fifo)->use_lock) #define snd_seq_fifo_unlock(fifo) snd_use_lock_free(&(fifo)->use_lock) /* get a cell from fifo - fifo should be locked */ -int snd_seq_fifo_cell_out(fifo_t *f, snd_seq_event_cell_t **cellp, int nonblock); +int snd_seq_fifo_cell_out(struct snd_seq_fifo *f, struct snd_seq_event_cell **cellp, int nonblock); /* free dequeued cell - fifo should be locked */ -extern void snd_seq_fifo_cell_putback(fifo_t *f, snd_seq_event_cell_t *cell); +void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f, struct snd_seq_event_cell *cell); /* clean up queue */ -extern void snd_seq_fifo_clear(fifo_t *f); +void snd_seq_fifo_clear(struct snd_seq_fifo *f); /* polling */ -extern int snd_seq_fifo_poll_wait(fifo_t *f, struct file *file, poll_table *wait); +int snd_seq_fifo_poll_wait(struct snd_seq_fifo *f, struct file *file, poll_table *wait); /* resize pool in fifo */ -int snd_seq_fifo_resize(fifo_t *f, int poolsize); +int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize); #endif diff --git a/sound/core/seq/seq_info.c b/sound/core/seq/seq_info.c index b50b695..3257cf4 100644 --- a/sound/core/seq/seq_info.c +++ b/sound/core/seq/seq_info.c @@ -28,15 +28,16 @@ #include "seq_timer.h" -static snd_info_entry_t *queues_entry; -static snd_info_entry_t *clients_entry; -static snd_info_entry_t *timer_entry; +static struct snd_info_entry *queues_entry; +static struct snd_info_entry *clients_entry; +static struct snd_info_entry *timer_entry; -static snd_info_entry_t * __init -create_info_entry(char *name, int size, void (*read)(snd_info_entry_t *, snd_info_buffer_t *)) +static struct snd_info_entry * __init +create_info_entry(char *name, int size, void (*read)(struct snd_info_entry *, + struct snd_info_buffer *)) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = snd_info_create_module_entry(THIS_MODULE, name, snd_seq_root); if (entry == NULL) diff --git a/sound/core/seq/seq_info.h b/sound/core/seq/seq_info.h index efd099a..5a91ebc 100644 --- a/sound/core/seq/seq_info.h +++ b/sound/core/seq/seq_info.h @@ -24,9 +24,9 @@ #include <sound/info.h> #include <sound/seq_kernel.h> -void snd_seq_info_clients_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer); -void snd_seq_info_timer_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer); -void snd_seq_info_queues_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer); +void snd_seq_info_clients_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer); +void snd_seq_info_timer_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer); +void snd_seq_info_queues_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer); int snd_seq_info_init( void ); diff --git a/sound/core/seq/seq_instr.c b/sound/core/seq/seq_instr.c index 1d525b1..4874520 100644 --- a/sound/core/seq/seq_instr.c +++ b/sound/core/seq/seq_instr.c @@ -31,7 +31,7 @@ MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer instrument libra MODULE_LICENSE("GPL"); -static void snd_instr_lock_ops(snd_seq_kinstr_list_t *list) +static void snd_instr_lock_ops(struct snd_seq_kinstr_list *list) { if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) { spin_lock_irqsave(&list->ops_lock, list->ops_flags); @@ -40,7 +40,7 @@ static void snd_instr_lock_ops(snd_seq_kinstr_list_t *list) } } -static void snd_instr_unlock_ops(snd_seq_kinstr_list_t *list) +static void snd_instr_unlock_ops(struct snd_seq_kinstr_list *list) { if (!(list->flags & SNDRV_SEQ_INSTR_FLG_DIRECT)) { spin_unlock_irqrestore(&list->ops_lock, list->ops_flags); @@ -49,18 +49,18 @@ static void snd_instr_unlock_ops(snd_seq_kinstr_list_t *list) } } -static snd_seq_kinstr_t *snd_seq_instr_new(int add_len, int atomic) +static struct snd_seq_kinstr *snd_seq_instr_new(int add_len, int atomic) { - snd_seq_kinstr_t *instr; + struct snd_seq_kinstr *instr; - instr = kzalloc(sizeof(snd_seq_kinstr_t) + add_len, atomic ? GFP_ATOMIC : GFP_KERNEL); + instr = kzalloc(sizeof(struct snd_seq_kinstr) + add_len, atomic ? GFP_ATOMIC : GFP_KERNEL); if (instr == NULL) return NULL; instr->add_len = add_len; return instr; } -static int snd_seq_instr_free(snd_seq_kinstr_t *instr, int atomic) +static int snd_seq_instr_free(struct snd_seq_kinstr *instr, int atomic) { int result = 0; @@ -73,11 +73,11 @@ static int snd_seq_instr_free(snd_seq_kinstr_t *instr, int atomic) return result; } -snd_seq_kinstr_list_t *snd_seq_instr_list_new(void) +struct snd_seq_kinstr_list *snd_seq_instr_list_new(void) { - snd_seq_kinstr_list_t *list; + struct snd_seq_kinstr_list *list; - list = kzalloc(sizeof(snd_seq_kinstr_list_t), GFP_KERNEL); + list = kzalloc(sizeof(struct snd_seq_kinstr_list), GFP_KERNEL); if (list == NULL) return NULL; spin_lock_init(&list->lock); @@ -87,11 +87,11 @@ snd_seq_kinstr_list_t *snd_seq_instr_list_new(void) return list; } -void snd_seq_instr_list_free(snd_seq_kinstr_list_t **list_ptr) +void snd_seq_instr_list_free(struct snd_seq_kinstr_list **list_ptr) { - snd_seq_kinstr_list_t *list; - snd_seq_kinstr_t *instr; - snd_seq_kcluster_t *cluster; + struct snd_seq_kinstr_list *list; + struct snd_seq_kinstr *instr; + struct snd_seq_kcluster *cluster; int idx; unsigned long flags; @@ -125,8 +125,8 @@ void snd_seq_instr_list_free(snd_seq_kinstr_list_t **list_ptr) kfree(list); } -static int instr_free_compare(snd_seq_kinstr_t *instr, - snd_seq_instr_header_t *ifree, +static int instr_free_compare(struct snd_seq_kinstr *instr, + struct snd_seq_instr_header *ifree, unsigned int client) { switch (ifree->cmd) { @@ -160,12 +160,12 @@ static int instr_free_compare(snd_seq_kinstr_t *instr, return 1; } -int snd_seq_instr_list_free_cond(snd_seq_kinstr_list_t *list, - snd_seq_instr_header_t *ifree, +int snd_seq_instr_list_free_cond(struct snd_seq_kinstr_list *list, + struct snd_seq_instr_header *ifree, int client, int atomic) { - snd_seq_kinstr_t *instr, *prev, *next, *flist; + struct snd_seq_kinstr *instr, *prev, *next, *flist; int idx; unsigned long flags; @@ -209,7 +209,7 @@ int snd_seq_instr_list_free_cond(snd_seq_kinstr_list_t *list, return 0; } -static int compute_hash_instr_key(snd_seq_instr_t *instr) +static int compute_hash_instr_key(struct snd_seq_instr *instr) { int result; @@ -233,7 +233,7 @@ static int compute_hash_cluster_key(snd_seq_instr_cluster_t cluster) } #endif -static int compare_instr(snd_seq_instr_t *i1, snd_seq_instr_t *i2, int exact) +static int compare_instr(struct snd_seq_instr *i1, struct snd_seq_instr *i2, int exact) { if (exact) { if (i1->cluster != i2->cluster || @@ -262,14 +262,14 @@ static int compare_instr(snd_seq_instr_t *i1, snd_seq_instr_t *i2, int exact) } } -snd_seq_kinstr_t *snd_seq_instr_find(snd_seq_kinstr_list_t *list, - snd_seq_instr_t *instr, - int exact, - int follow_alias) +struct snd_seq_kinstr *snd_seq_instr_find(struct snd_seq_kinstr_list *list, + struct snd_seq_instr *instr, + int exact, + int follow_alias) { unsigned long flags; int depth = 0; - snd_seq_kinstr_t *result; + struct snd_seq_kinstr *result; if (list == NULL || instr == NULL) return NULL; @@ -279,7 +279,7 @@ snd_seq_kinstr_t *snd_seq_instr_find(snd_seq_kinstr_list_t *list, while (result) { if (!compare_instr(&result->instr, instr, exact)) { if (follow_alias && (result->type == SNDRV_SEQ_INSTR_ATYPE_ALIAS)) { - instr = (snd_seq_instr_t *)KINSTR_DATA(result); + instr = (struct snd_seq_instr *)KINSTR_DATA(result); if (++depth > 10) goto __not_found; goto __again; @@ -295,8 +295,8 @@ snd_seq_kinstr_t *snd_seq_instr_find(snd_seq_kinstr_list_t *list, return NULL; } -void snd_seq_instr_free_use(snd_seq_kinstr_list_t *list, - snd_seq_kinstr_t *instr) +void snd_seq_instr_free_use(struct snd_seq_kinstr_list *list, + struct snd_seq_kinstr *instr) { unsigned long flags; @@ -311,7 +311,8 @@ void snd_seq_instr_free_use(snd_seq_kinstr_list_t *list, spin_unlock_irqrestore(&list->lock, flags); } -static snd_seq_kinstr_ops_t *instr_ops(snd_seq_kinstr_ops_t *ops, char *instr_type) +static struct snd_seq_kinstr_ops *instr_ops(struct snd_seq_kinstr_ops *ops, + char *instr_type) { while (ops) { if (!strcmp(ops->instr_type, instr_type)) @@ -321,11 +322,11 @@ static snd_seq_kinstr_ops_t *instr_ops(snd_seq_kinstr_ops_t *ops, char *instr_ty return NULL; } -static int instr_result(snd_seq_event_t *ev, +static int instr_result(struct snd_seq_event *ev, int type, int result, int atomic) { - snd_seq_event_t sev; + struct snd_seq_event sev; memset(&sev, 0, sizeof(sev)); sev.type = SNDRV_SEQ_EVENT_RESULT; @@ -345,9 +346,9 @@ static int instr_result(snd_seq_event_t *ev, return snd_seq_kernel_client_dispatch(sev.source.client, &sev, atomic, 0); } -static int instr_begin(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_begin(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { unsigned long flags; @@ -362,9 +363,9 @@ static int instr_begin(snd_seq_kinstr_ops_t *ops, return instr_result(ev, SNDRV_SEQ_EVENT_INSTR_BEGIN, 0, atomic); } -static int instr_end(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_end(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { unsigned long flags; @@ -380,54 +381,55 @@ static int instr_end(snd_seq_kinstr_ops_t *ops, return instr_result(ev, SNDRV_SEQ_EVENT_INSTR_END, -EINVAL, atomic); } -static int instr_info(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_info(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { return -ENXIO; } -static int instr_format_info(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_format_info(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { return -ENXIO; } -static int instr_reset(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_reset(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { return -ENXIO; } -static int instr_status(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_status(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { return -ENXIO; } -static int instr_put(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_put(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { unsigned long flags; - snd_seq_instr_header_t put; - snd_seq_kinstr_t *instr; + struct snd_seq_instr_header put; + struct snd_seq_kinstr *instr; int result = -EINVAL, len, key; if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARUSR) goto __return; - if (ev->data.ext.len < sizeof(snd_seq_instr_header_t)) + if (ev->data.ext.len < sizeof(struct snd_seq_instr_header)) goto __return; - if (copy_from_user(&put, (void __user *)ev->data.ext.ptr, sizeof(snd_seq_instr_header_t))) { + if (copy_from_user(&put, (void __user *)ev->data.ext.ptr, + sizeof(struct snd_seq_instr_header))) { result = -EFAULT; goto __return; } @@ -449,7 +451,7 @@ static int instr_put(snd_seq_kinstr_ops_t *ops, } len = ops->add_len; if (put.data.type == SNDRV_SEQ_INSTR_ATYPE_ALIAS) - len = sizeof(snd_seq_instr_t); + len = sizeof(struct snd_seq_instr); instr = snd_seq_instr_new(len, atomic); if (instr == NULL) { snd_instr_unlock_ops(list); @@ -463,8 +465,8 @@ static int instr_put(snd_seq_kinstr_ops_t *ops, if (instr->type == SNDRV_SEQ_INSTR_ATYPE_DATA) { result = ops->put(ops->private_data, instr, - (void __user *)ev->data.ext.ptr + sizeof(snd_seq_instr_header_t), - ev->data.ext.len - sizeof(snd_seq_instr_header_t), + (void __user *)ev->data.ext.ptr + sizeof(struct snd_seq_instr_header), + ev->data.ext.len - sizeof(struct snd_seq_instr_header), atomic, put.cmd); if (result < 0) { @@ -486,21 +488,21 @@ static int instr_put(snd_seq_kinstr_ops_t *ops, return result; } -static int instr_get(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_get(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { return -ENXIO; } -static int instr_free(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_free(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { - snd_seq_instr_header_t ifree; - snd_seq_kinstr_t *instr, *prev; + struct snd_seq_instr_header ifree; + struct snd_seq_kinstr *instr, *prev; int result = -EINVAL; unsigned long flags; unsigned int hash; @@ -508,9 +510,10 @@ static int instr_free(snd_seq_kinstr_ops_t *ops, if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARUSR) goto __return; - if (ev->data.ext.len < sizeof(snd_seq_instr_header_t)) + if (ev->data.ext.len < sizeof(struct snd_seq_instr_header)) goto __return; - if (copy_from_user(&ifree, (void __user *)ev->data.ext.ptr, sizeof(snd_seq_instr_header_t))) { + if (copy_from_user(&ifree, (void __user *)ev->data.ext.ptr, + sizeof(struct snd_seq_instr_header))) { result = -EFAULT; goto __return; } @@ -548,7 +551,8 @@ static int instr_free(snd_seq_kinstr_ops_t *ops, list->hash[hash] = instr->next; } if (instr->ops && instr->ops->notify) - instr->ops->notify(instr->ops->private_data, instr, SNDRV_SEQ_INSTR_NOTIFY_REMOVE); + instr->ops->notify(instr->ops->private_data, instr, + SNDRV_SEQ_INSTR_NOTIFY_REMOVE); while (instr->use) { spin_unlock_irqrestore(&list->lock, flags); schedule_timeout_interruptible(1); @@ -565,25 +569,25 @@ static int instr_free(snd_seq_kinstr_ops_t *ops, return result; } -static int instr_list(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_list(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { return -ENXIO; } -static int instr_cluster(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +static int instr_cluster(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int atomic, int hop) { return -ENXIO; } -int snd_seq_instr_event(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_list_t *list, - snd_seq_event_t *ev, +int snd_seq_instr_event(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_list *list, + struct snd_seq_event *ev, int client, int atomic, int hop) diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c index 8416bcf..9ee6c17 100644 --- a/sound/core/seq/seq_memory.c +++ b/sound/core/seq/seq_memory.c @@ -36,12 +36,12 @@ #define semaphore_of(fp) ((fp)->f_dentry->d_inode->i_sem) -static inline int snd_seq_pool_available(pool_t *pool) +static inline int snd_seq_pool_available(struct snd_seq_pool *pool) { return pool->total_elements - atomic_read(&pool->counter); } -static inline int snd_seq_output_ok(pool_t *pool) +static inline int snd_seq_output_ok(struct snd_seq_pool *pool) { return snd_seq_pool_available(pool) >= pool->room; } @@ -72,7 +72,7 @@ static inline int snd_seq_output_ok(pool_t *pool) * call dump function to expand external data. */ -static int get_var_len(const snd_seq_event_t *event) +static int get_var_len(const struct snd_seq_event *event) { if ((event->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARIABLE) return -EINVAL; @@ -80,10 +80,11 @@ static int get_var_len(const snd_seq_event_t *event) return event->data.ext.len & ~SNDRV_SEQ_EXT_MASK; } -int snd_seq_dump_var_event(const snd_seq_event_t *event, snd_seq_dump_func_t func, void *private_data) +int snd_seq_dump_var_event(const struct snd_seq_event *event, + snd_seq_dump_func_t func, void *private_data) { int len, err; - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; if ((len = get_var_len(event)) <= 0) return len; @@ -108,9 +109,9 @@ int snd_seq_dump_var_event(const snd_seq_event_t *event, snd_seq_dump_func_t fun return func(private_data, event->data.ext.ptr, len); } - cell = (snd_seq_event_cell_t*)event->data.ext.ptr; + cell = (struct snd_seq_event_cell *)event->data.ext.ptr; for (; len > 0 && cell; cell = cell->next) { - int size = sizeof(snd_seq_event_t); + int size = sizeof(struct snd_seq_event); if (len < size) size = len; err = func(private_data, &cell->event, size); @@ -142,7 +143,8 @@ static int seq_copy_in_user(char __user **bufptr, const void *src, int size) return 0; } -int snd_seq_expand_var_event(const snd_seq_event_t *event, int count, char *buf, int in_kernel, int size_aligned) +int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, char *buf, + int in_kernel, int size_aligned) { int len, newlen; int err; @@ -174,17 +176,18 @@ int snd_seq_expand_var_event(const snd_seq_event_t *event, int count, char *buf, * release this cell, free extended data if available */ -static inline void free_cell(pool_t *pool, snd_seq_event_cell_t *cell) +static inline void free_cell(struct snd_seq_pool *pool, + struct snd_seq_event_cell *cell) { cell->next = pool->free; pool->free = cell; atomic_dec(&pool->counter); } -void snd_seq_cell_free(snd_seq_event_cell_t * cell) +void snd_seq_cell_free(struct snd_seq_event_cell * cell) { unsigned long flags; - pool_t *pool; + struct snd_seq_pool *pool; snd_assert(cell != NULL, return); pool = cell->pool; @@ -194,7 +197,7 @@ void snd_seq_cell_free(snd_seq_event_cell_t * cell) free_cell(pool, cell); if (snd_seq_ev_is_variable(&cell->event)) { if (cell->event.data.ext.len & SNDRV_SEQ_EXT_CHAINED) { - snd_seq_event_cell_t *curp, *nextptr; + struct snd_seq_event_cell *curp, *nextptr; curp = cell->event.data.ext.ptr; for (; curp; curp = nextptr) { nextptr = curp->next; @@ -215,9 +218,11 @@ void snd_seq_cell_free(snd_seq_event_cell_t * cell) /* * allocate an event cell. */ -static int snd_seq_cell_alloc(pool_t *pool, snd_seq_event_cell_t **cellp, int nonblock, struct file *file) +static int snd_seq_cell_alloc(struct snd_seq_pool *pool, + struct snd_seq_event_cell **cellp, + int nonblock, struct file *file) { - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; unsigned long flags; int err = -EAGAIN; wait_queue_t wait; @@ -280,11 +285,13 @@ __error: * if the event has external data, the data is decomposed to additional * cells. */ -int snd_seq_event_dup(pool_t *pool, snd_seq_event_t *event, snd_seq_event_cell_t **cellp, int nonblock, struct file *file) +int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event, + struct snd_seq_event_cell **cellp, int nonblock, + struct file *file) { int ncells, err; unsigned int extlen; - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; *cellp = NULL; @@ -292,7 +299,7 @@ int snd_seq_event_dup(pool_t *pool, snd_seq_event_t *event, snd_seq_event_cell_t extlen = 0; if (snd_seq_ev_is_variable(event)) { extlen = event->data.ext.len & ~SNDRV_SEQ_EXT_MASK; - ncells = (extlen + sizeof(snd_seq_event_t) - 1) / sizeof(snd_seq_event_t); + ncells = (extlen + sizeof(struct snd_seq_event) - 1) / sizeof(struct snd_seq_event); } if (ncells >= pool->total_elements) return -ENOMEM; @@ -309,18 +316,18 @@ int snd_seq_event_dup(pool_t *pool, snd_seq_event_t *event, snd_seq_event_cell_t int len = extlen; int is_chained = event->data.ext.len & SNDRV_SEQ_EXT_CHAINED; int is_usrptr = event->data.ext.len & SNDRV_SEQ_EXT_USRPTR; - snd_seq_event_cell_t *src, *tmp, *tail; + struct snd_seq_event_cell *src, *tmp, *tail; char *buf; cell->event.data.ext.len = extlen | SNDRV_SEQ_EXT_CHAINED; cell->event.data.ext.ptr = NULL; - src = (snd_seq_event_cell_t*)event->data.ext.ptr; + src = (struct snd_seq_event_cell *)event->data.ext.ptr; buf = (char *)event->data.ext.ptr; tail = NULL; while (ncells-- > 0) { - int size = sizeof(snd_seq_event_t); + int size = sizeof(struct snd_seq_event); if (len < size) size = len; err = snd_seq_cell_alloc(pool, &tmp, nonblock, file); @@ -358,7 +365,8 @@ __error: /* poll wait */ -int snd_seq_pool_poll_wait(pool_t *pool, struct file *file, poll_table *wait) +int snd_seq_pool_poll_wait(struct snd_seq_pool *pool, struct file *file, + poll_table *wait) { poll_wait(file, &pool->output_sleep, wait); return snd_seq_output_ok(pool); @@ -366,17 +374,17 @@ int snd_seq_pool_poll_wait(pool_t *pool, struct file *file, poll_table *wait) /* allocate room specified number of events */ -int snd_seq_pool_init(pool_t *pool) +int snd_seq_pool_init(struct snd_seq_pool *pool) { int cell; - snd_seq_event_cell_t *cellptr; + struct snd_seq_event_cell *cellptr; unsigned long flags; snd_assert(pool != NULL, return -EINVAL); if (pool->ptr) /* should be atomic? */ return 0; - pool->ptr = vmalloc(sizeof(snd_seq_event_cell_t) * pool->size); + pool->ptr = vmalloc(sizeof(struct snd_seq_event_cell) * pool->size); if (pool->ptr == NULL) { snd_printd("seq: malloc for sequencer events failed\n"); return -ENOMEM; @@ -402,10 +410,10 @@ int snd_seq_pool_init(pool_t *pool) } /* remove events */ -int snd_seq_pool_done(pool_t *pool) +int snd_seq_pool_done(struct snd_seq_pool *pool) { unsigned long flags; - snd_seq_event_cell_t *ptr; + struct snd_seq_event_cell *ptr; int max_count = 5 * HZ; snd_assert(pool != NULL, return -EINVAL); @@ -446,9 +454,9 @@ int snd_seq_pool_done(pool_t *pool) /* init new memory pool */ -pool_t *snd_seq_pool_new(int poolsize) +struct snd_seq_pool *snd_seq_pool_new(int poolsize) { - pool_t *pool; + struct snd_seq_pool *pool; /* create pool block */ pool = kzalloc(sizeof(*pool), GFP_KERNEL); @@ -472,9 +480,9 @@ pool_t *snd_seq_pool_new(int poolsize) } /* remove memory pool */ -int snd_seq_pool_delete(pool_t **ppool) +int snd_seq_pool_delete(struct snd_seq_pool **ppool) { - pool_t *pool = *ppool; + struct snd_seq_pool *pool = *ppool; *ppool = NULL; if (pool == NULL) @@ -497,7 +505,8 @@ void __exit snd_sequencer_memory_done(void) /* exported to seq_clientmgr.c */ -void snd_seq_info_pool(snd_info_buffer_t * buffer, pool_t *pool, char *space) +void snd_seq_info_pool(struct snd_info_buffer *buffer, + struct snd_seq_pool *pool, char *space) { if (pool == NULL) return; diff --git a/sound/core/seq/seq_memory.h b/sound/core/seq/seq_memory.h index 6c4dde5..39c60d9 100644 --- a/sound/core/seq/seq_memory.h +++ b/sound/core/seq/seq_memory.h @@ -24,23 +24,21 @@ #include <sound/seq_kernel.h> #include <linux/poll.h> -typedef struct pool pool_t; - /* container for sequencer event (internal use) */ -typedef struct snd_seq_event_cell_t { - snd_seq_event_t event; - pool_t *pool; /* used pool */ - struct snd_seq_event_cell_t *next; /* next cell */ -} snd_seq_event_cell_t; +struct snd_seq_event_cell { + struct snd_seq_event event; + struct snd_seq_pool *pool; /* used pool */ + struct snd_seq_event_cell *next; /* next cell */ +}; /* design note: the pool is a contigious block of memory, if we dynamicly want to add additional cells to the pool be better store this in another pool as we need to know the base address of the pool when releasing memory. */ -struct pool { - snd_seq_event_cell_t *ptr; /* pointer to first event chunk */ - snd_seq_event_cell_t *free; /* pointer to the head of the free list */ +struct snd_seq_pool { + struct snd_seq_event_cell *ptr; /* pointer to first event chunk */ + struct snd_seq_event_cell *free; /* pointer to the head of the free list */ int total_elements; /* pool size actually allocated */ atomic_t counter; /* cells free */ @@ -63,33 +61,34 @@ struct pool { spinlock_t lock; }; -extern void snd_seq_cell_free(snd_seq_event_cell_t* cell); +void snd_seq_cell_free(struct snd_seq_event_cell *cell); -int snd_seq_event_dup(pool_t *pool, snd_seq_event_t *event, snd_seq_event_cell_t **cellp, int nonblock, struct file *file); +int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event, + struct snd_seq_event_cell **cellp, int nonblock, struct file *file); /* return number of unused (free) cells */ -static inline int snd_seq_unused_cells(pool_t *pool) +static inline int snd_seq_unused_cells(struct snd_seq_pool *pool) { return pool ? pool->total_elements - atomic_read(&pool->counter) : 0; } /* return total number of allocated cells */ -static inline int snd_seq_total_cells(pool_t *pool) +static inline int snd_seq_total_cells(struct snd_seq_pool *pool) { return pool ? pool->total_elements : 0; } /* init pool - allocate events */ -int snd_seq_pool_init(pool_t *pool); +int snd_seq_pool_init(struct snd_seq_pool *pool); /* done pool - free events */ -int snd_seq_pool_done(pool_t *pool); +int snd_seq_pool_done(struct snd_seq_pool *pool); /* create pool */ -pool_t *snd_seq_pool_new(int poolsize); +struct snd_seq_pool *snd_seq_pool_new(int poolsize); /* remove pool */ -int snd_seq_pool_delete(pool_t **pool); +int snd_seq_pool_delete(struct snd_seq_pool **pool); /* init memory */ int snd_sequencer_memory_init(void); @@ -98,7 +97,7 @@ int snd_sequencer_memory_init(void); void snd_sequencer_memory_done(void); /* polling */ -int snd_seq_pool_poll_wait(pool_t *pool, struct file *file, poll_table *wait); +int snd_seq_pool_poll_wait(struct snd_seq_pool *pool, struct file *file, poll_table *wait); #endif diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index f89f40f..f88d2e3 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -51,40 +51,40 @@ module_param(input_buffer_size, int, 0644); MODULE_PARM_DESC(input_buffer_size, "Input buffer size in bytes."); /* data for this midi synth driver */ -typedef struct { - snd_card_t *card; +struct seq_midisynth { + struct snd_card *card; int device; int subdevice; - snd_rawmidi_file_t input_rfile; - snd_rawmidi_file_t output_rfile; + struct snd_rawmidi_file input_rfile; + struct snd_rawmidi_file output_rfile; int seq_client; int seq_port; - snd_midi_event_t *parser; -} seq_midisynth_t; + struct snd_midi_event *parser; +}; -typedef struct { +struct seq_midisynth_client { int seq_client; int num_ports; int ports_per_device[SNDRV_RAWMIDI_DEVICES]; - seq_midisynth_t *ports[SNDRV_RAWMIDI_DEVICES]; -} seq_midisynth_client_t; + struct seq_midisynth *ports[SNDRV_RAWMIDI_DEVICES]; +}; -static seq_midisynth_client_t *synths[SNDRV_CARDS]; +static struct seq_midisynth_client *synths[SNDRV_CARDS]; static DECLARE_MUTEX(register_mutex); /* handle rawmidi input event (MIDI v1.0 stream) */ -static void snd_midi_input_event(snd_rawmidi_substream_t * substream) +static void snd_midi_input_event(struct snd_rawmidi_substream *substream) { - snd_rawmidi_runtime_t *runtime; - seq_midisynth_t *msynth; - snd_seq_event_t ev; + struct snd_rawmidi_runtime *runtime; + struct seq_midisynth *msynth; + struct snd_seq_event ev; char buf[16], *pbuf; long res, count; if (substream == NULL) return; runtime = substream->runtime; - msynth = (seq_midisynth_t *) runtime->private_data; + msynth = runtime->private_data; if (msynth == NULL) return; memset(&ev, 0, sizeof(ev)); @@ -112,9 +112,9 @@ static void snd_midi_input_event(snd_rawmidi_substream_t * substream) } } -static int dump_midi(snd_rawmidi_substream_t *substream, const char *buf, int count) +static int dump_midi(struct snd_rawmidi_substream *substream, const char *buf, int count) { - snd_rawmidi_runtime_t *runtime; + struct snd_rawmidi_runtime *runtime; int tmp; snd_assert(substream != NULL || buf != NULL, return -EINVAL); @@ -128,12 +128,12 @@ static int dump_midi(snd_rawmidi_substream_t *substream, const char *buf, int co return 0; } -static int event_process_midi(snd_seq_event_t * ev, int direct, +static int event_process_midi(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - seq_midisynth_t *msynth = (seq_midisynth_t *) private_data; + struct seq_midisynth *msynth = private_data; unsigned char msg[10]; /* buffer for constructing midi messages */ - snd_rawmidi_substream_t *substream; + struct snd_rawmidi_substream *substream; int len; snd_assert(msynth != NULL, return -EINVAL); @@ -161,8 +161,8 @@ static int event_process_midi(snd_seq_event_t * ev, int direct, } -static int snd_seq_midisynth_new(seq_midisynth_t *msynth, - snd_card_t *card, +static int snd_seq_midisynth_new(struct seq_midisynth *msynth, + struct snd_card *card, int device, int subdevice) { @@ -175,12 +175,12 @@ static int snd_seq_midisynth_new(seq_midisynth_t *msynth, } /* open associated midi device for input */ -static int midisynth_subscribe(void *private_data, snd_seq_port_subscribe_t *info) +static int midisynth_subscribe(void *private_data, struct snd_seq_port_subscribe *info) { int err; - seq_midisynth_t *msynth = (seq_midisynth_t *)private_data; - snd_rawmidi_runtime_t *runtime; - snd_rawmidi_params_t params; + struct seq_midisynth *msynth = private_data; + struct snd_rawmidi_runtime *runtime; + struct snd_rawmidi_params params; /* open midi port */ if ((err = snd_rawmidi_kernel_open(msynth->card->number, msynth->device, msynth->subdevice, SNDRV_RAWMIDI_LFLG_INPUT, &msynth->input_rfile)) < 0) { @@ -203,10 +203,10 @@ static int midisynth_subscribe(void *private_data, snd_seq_port_subscribe_t *inf } /* close associated midi device for input */ -static int midisynth_unsubscribe(void *private_data, snd_seq_port_subscribe_t *info) +static int midisynth_unsubscribe(void *private_data, struct snd_seq_port_subscribe *info) { int err; - seq_midisynth_t *msynth = (seq_midisynth_t *)private_data; + struct seq_midisynth *msynth = private_data; snd_assert(msynth->input_rfile.input != NULL, return -EINVAL); err = snd_rawmidi_kernel_release(&msynth->input_rfile); @@ -214,11 +214,11 @@ static int midisynth_unsubscribe(void *private_data, snd_seq_port_subscribe_t *i } /* open associated midi device for output */ -static int midisynth_use(void *private_data, snd_seq_port_subscribe_t *info) +static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *info) { int err; - seq_midisynth_t *msynth = (seq_midisynth_t *)private_data; - snd_rawmidi_params_t params; + struct seq_midisynth *msynth = private_data; + struct snd_rawmidi_params params; /* open midi port */ if ((err = snd_rawmidi_kernel_open(msynth->card->number, msynth->device, msynth->subdevice, SNDRV_RAWMIDI_LFLG_OUTPUT, &msynth->output_rfile)) < 0) { @@ -237,9 +237,9 @@ static int midisynth_use(void *private_data, snd_seq_port_subscribe_t *info) } /* close associated midi device for output */ -static int midisynth_unuse(void *private_data, snd_seq_port_subscribe_t *info) +static int midisynth_unuse(void *private_data, struct snd_seq_port_subscribe *info) { - seq_midisynth_t *msynth = (seq_midisynth_t *)private_data; + struct seq_midisynth *msynth = private_data; unsigned char buf = 0xff; /* MIDI reset */ snd_assert(msynth->output_rfile.output != NULL, return -EINVAL); @@ -250,7 +250,7 @@ static int midisynth_unuse(void *private_data, snd_seq_port_subscribe_t *info) } /* delete given midi synth port */ -static void snd_seq_midisynth_delete(seq_midisynth_t *msynth) +static void snd_seq_midisynth_delete(struct seq_midisynth *msynth) { if (msynth == NULL) return; @@ -265,10 +265,10 @@ static void snd_seq_midisynth_delete(seq_midisynth_t *msynth) } /* set our client name */ -static int set_client_name(seq_midisynth_client_t *client, snd_card_t *card, - snd_rawmidi_info_t *rmidi) +static int set_client_name(struct seq_midisynth_client *client, struct snd_card *card, + struct snd_rawmidi_info *rmidi) { - snd_seq_client_info_t cinfo; + struct snd_seq_client_info cinfo; const char *name; memset(&cinfo, 0, sizeof(cinfo)); @@ -281,17 +281,17 @@ static int set_client_name(seq_midisynth_client_t *client, snd_card_t *card, /* register new midi synth port */ static int -snd_seq_midisynth_register_port(snd_seq_device_t *dev) +snd_seq_midisynth_register_port(struct snd_seq_device *dev) { - seq_midisynth_client_t *client; - seq_midisynth_t *msynth, *ms; - snd_seq_port_info_t *port; - snd_rawmidi_info_t *info; + struct seq_midisynth_client *client; + struct seq_midisynth *msynth, *ms; + struct snd_seq_port_info *port; + struct snd_rawmidi_info *info; int newclient = 0; unsigned int p, ports; - snd_seq_client_callback_t callbacks; - snd_seq_port_callback_t pcallbacks; - snd_card_t *card = dev->card; + struct snd_seq_client_callback callbacks; + struct snd_seq_port_callback pcallbacks; + struct snd_card *card = dev->card; int device = dev->device; unsigned int input_count = 0, output_count = 0; @@ -342,7 +342,7 @@ snd_seq_midisynth_register_port(snd_seq_device_t *dev) } else if (device == 0) set_client_name(client, card, info); /* use the first device's name */ - msynth = kcalloc(ports, sizeof(seq_midisynth_t), GFP_KERNEL); + msynth = kcalloc(ports, sizeof(struct seq_midisynth), GFP_KERNEL); port = kmalloc(sizeof(*port), GFP_KERNEL); if (msynth == NULL || port == NULL) goto __nomem; @@ -432,11 +432,11 @@ snd_seq_midisynth_register_port(snd_seq_device_t *dev) /* release midi synth port */ static int -snd_seq_midisynth_unregister_port(snd_seq_device_t *dev) +snd_seq_midisynth_unregister_port(struct snd_seq_device *dev) { - seq_midisynth_client_t *client; - seq_midisynth_t *msynth; - snd_card_t *card = dev->card; + struct seq_midisynth_client *client; + struct seq_midisynth *msynth; + struct snd_card *card = dev->card; int device = dev->device, p, ports; down(®ister_mutex); @@ -465,7 +465,7 @@ snd_seq_midisynth_unregister_port(snd_seq_device_t *dev) static int __init alsa_seq_midi_init(void) { - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_seq_midisynth_register_port, snd_seq_midisynth_unregister_port, }; diff --git a/sound/core/seq/seq_midi_emul.c b/sound/core/seq/seq_midi_emul.c index 35fe8a7..d7c4fb8 100644 --- a/sound/core/seq/seq_midi_emul.c +++ b/sound/core/seq/seq_midi_emul.c @@ -44,17 +44,25 @@ MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI emulation." MODULE_LICENSE("GPL"); /* Prototypes for static functions */ -static void note_off(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan, int note, int vel); -static void do_control(snd_midi_op_t *ops, void *private, - snd_midi_channel_set_t *chset, snd_midi_channel_t *chan, +static void note_off(struct snd_midi_op *ops, void *drv, + struct snd_midi_channel *chan, + int note, int vel); +static void do_control(struct snd_midi_op *ops, void *private, + struct snd_midi_channel_set *chset, + struct snd_midi_channel *chan, int control, int value); -static void rpn(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan, snd_midi_channel_set_t *chset); -static void nrpn(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan, snd_midi_channel_set_t *chset); -static void sysex(snd_midi_op_t *ops, void *private, unsigned char *sysex, int len, snd_midi_channel_set_t *chset); -static void all_sounds_off(snd_midi_op_t *ops, void *private, snd_midi_channel_t *chan); -static void all_notes_off(snd_midi_op_t *ops, void *private, snd_midi_channel_t *chan); -static void snd_midi_reset_controllers(snd_midi_channel_t *chan); -static void reset_all_channels(snd_midi_channel_set_t *chset); +static void rpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset); +static void nrpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset); +static void sysex(struct snd_midi_op *ops, void *private, unsigned char *sysex, + int len, struct snd_midi_channel_set *chset); +static void all_sounds_off(struct snd_midi_op *ops, void *private, + struct snd_midi_channel *chan); +static void all_notes_off(struct snd_midi_op *ops, void *private, + struct snd_midi_channel *chan); +static void snd_midi_reset_controllers(struct snd_midi_channel *chan); +static void reset_all_channels(struct snd_midi_channel_set *chset); /* @@ -72,10 +80,11 @@ static void reset_all_channels(snd_midi_channel_set_t *chset); * be interpreted. */ void -snd_midi_process_event(snd_midi_op_t *ops, - snd_seq_event_t *ev, snd_midi_channel_set_t *chanset) +snd_midi_process_event(struct snd_midi_op *ops, + struct snd_seq_event *ev, + struct snd_midi_channel_set *chanset) { - snd_midi_channel_t *chan; + struct snd_midi_channel *chan; void *drv; int dest_channel = 0; @@ -89,7 +98,8 @@ snd_midi_process_event(snd_midi_op_t *ops, if (snd_seq_ev_is_channel_type(ev)) { dest_channel = ev->data.note.channel; if (dest_channel >= chanset->max_channels) { - snd_printd("dest channel is %d, max is %d\n", dest_channel, chanset->max_channels); + snd_printd("dest channel is %d, max is %d\n", + dest_channel, chanset->max_channels); return; } } @@ -239,7 +249,8 @@ snd_midi_process_event(snd_midi_op_t *ops, * release note */ static void -note_off(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan, int note, int vel) +note_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, + int note, int vel) { if (chan->gm_hold) { /* Hold this note until pedal is turned off */ @@ -260,8 +271,8 @@ note_off(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan, int note, int * events that need to take place immediately to the driver. */ static void -do_control(snd_midi_op_t *ops, void *drv, snd_midi_channel_set_t *chset, - snd_midi_channel_t *chan, int control, int value) +do_control(struct snd_midi_op *ops, void *drv, struct snd_midi_channel_set *chset, + struct snd_midi_channel *chan, int control, int value) { int i; @@ -376,7 +387,7 @@ do_control(snd_midi_op_t *ops, void *drv, snd_midi_channel_set_t *chset, * initialize the MIDI status */ void -snd_midi_channel_set_clear(snd_midi_channel_set_t *chset) +snd_midi_channel_set_clear(struct snd_midi_channel_set *chset) { int i; @@ -384,7 +395,7 @@ snd_midi_channel_set_clear(snd_midi_channel_set_t *chset) chset->gs_master_volume = 127; for (i = 0; i < chset->max_channels; i++) { - snd_midi_channel_t *chan = chset->channels + i; + struct snd_midi_channel *chan = chset->channels + i; memset(chan->note, 0, sizeof(chan->note)); chan->midi_aftertouch = 0; @@ -407,8 +418,8 @@ snd_midi_channel_set_clear(snd_midi_channel_set_t *chset) * Process a rpn message. */ static void -rpn(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan, - snd_midi_channel_set_t *chset) +rpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset) { int type; int val; @@ -447,8 +458,8 @@ rpn(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan, * Process an nrpn message. */ static void -nrpn(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan, - snd_midi_channel_set_t *chset) +nrpn(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset) { /* parse XG NRPNs here if possible */ if (ops->nrpn) @@ -475,7 +486,8 @@ get_channel(unsigned char cmd) * Process a sysex message. */ static void -sysex(snd_midi_op_t *ops, void *private, unsigned char *buf, int len, snd_midi_channel_set_t *chset) +sysex(struct snd_midi_op *ops, void *private, unsigned char *buf, int len, + struct snd_midi_channel_set *chset) { /* GM on */ static unsigned char gm_on_macro[] = { @@ -588,7 +600,7 @@ sysex(snd_midi_op_t *ops, void *private, unsigned char *buf, int len, snd_midi_c * all sound off */ static void -all_sounds_off(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan) +all_sounds_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan) { int n; @@ -606,7 +618,7 @@ all_sounds_off(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan) * all notes off */ static void -all_notes_off(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan) +all_notes_off(struct snd_midi_op *ops, void *drv, struct snd_midi_channel *chan) { int n; @@ -621,12 +633,12 @@ all_notes_off(snd_midi_op_t *ops, void *drv, snd_midi_channel_t *chan) /* * Initialise a single midi channel control block. */ -static void snd_midi_channel_init(snd_midi_channel_t *p, int n) +static void snd_midi_channel_init(struct snd_midi_channel *p, int n) { if (p == NULL) return; - memset(p, 0, sizeof(snd_midi_channel_t)); + memset(p, 0, sizeof(struct snd_midi_channel)); p->private = NULL; p->number = n; @@ -642,12 +654,12 @@ static void snd_midi_channel_init(snd_midi_channel_t *p, int n) /* * Allocate and initialise a set of midi channel control blocks. */ -static snd_midi_channel_t *snd_midi_channel_init_set(int n) +static struct snd_midi_channel *snd_midi_channel_init_set(int n) { - snd_midi_channel_t *chan; + struct snd_midi_channel *chan; int i; - chan = kmalloc(n * sizeof(snd_midi_channel_t), GFP_KERNEL); + chan = kmalloc(n * sizeof(struct snd_midi_channel), GFP_KERNEL); if (chan) { for (i = 0; i < n; i++) snd_midi_channel_init(chan+i, i); @@ -660,11 +672,11 @@ static snd_midi_channel_t *snd_midi_channel_init_set(int n) * reset all midi channels */ static void -reset_all_channels(snd_midi_channel_set_t *chset) +reset_all_channels(struct snd_midi_channel_set *chset) { int ch; for (ch = 0; ch < chset->max_channels; ch++) { - snd_midi_channel_t *chan = chset->channels + ch; + struct snd_midi_channel *chan = chset->channels + ch; snd_midi_reset_controllers(chan); chan->gm_rpn_pitch_bend_range = 256; /* 2 semitones */ chan->gm_rpn_fine_tuning = 0; @@ -681,9 +693,9 @@ reset_all_channels(snd_midi_channel_set_t *chset) /* * Allocate and initialise a midi channel set. */ -snd_midi_channel_set_t *snd_midi_channel_alloc_set(int n) +struct snd_midi_channel_set *snd_midi_channel_alloc_set(int n) { - snd_midi_channel_set_t *chset; + struct snd_midi_channel_set *chset; chset = kmalloc(sizeof(*chset), GFP_KERNEL); if (chset) { @@ -697,7 +709,7 @@ snd_midi_channel_set_t *snd_midi_channel_alloc_set(int n) /* * Reset the midi controllers on a particular channel to default values. */ -static void snd_midi_reset_controllers(snd_midi_channel_t *chan) +static void snd_midi_reset_controllers(struct snd_midi_channel *chan) { memset(chan->control, 0, sizeof(chan->control)); chan->gm_volume = 127; @@ -709,7 +721,7 @@ static void snd_midi_reset_controllers(snd_midi_channel_t *chan) /* * Free a midi channel set. */ -void snd_midi_channel_free_set(snd_midi_channel_set_t *chset) +void snd_midi_channel_free_set(struct snd_midi_channel_set *chset) { if (chset == NULL) return; diff --git a/sound/core/seq/seq_midi_event.c b/sound/core/seq/seq_midi_event.c index 2dc1aec..5ff80b7 100644 --- a/sound/core/seq/seq_midi_event.c +++ b/sound/core/seq/seq_midi_event.c @@ -41,33 +41,29 @@ MODULE_LICENSE("GPL"); /* from 8 to 15 are events for 0xf0-0xf7 */ -/* status event types */ -typedef void (*event_encode_t)(snd_midi_event_t *dev, snd_seq_event_t *ev); -typedef void (*event_decode_t)(snd_seq_event_t *ev, unsigned char *buf); - /* * prototypes */ -static void note_event(snd_midi_event_t *dev, snd_seq_event_t *ev); -static void one_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev); -static void pitchbend_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev); -static void two_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev); -static void one_param_event(snd_midi_event_t *dev, snd_seq_event_t *ev); -static void songpos_event(snd_midi_event_t *dev, snd_seq_event_t *ev); -static void note_decode(snd_seq_event_t *ev, unsigned char *buf); -static void one_param_decode(snd_seq_event_t *ev, unsigned char *buf); -static void pitchbend_decode(snd_seq_event_t *ev, unsigned char *buf); -static void two_param_decode(snd_seq_event_t *ev, unsigned char *buf); -static void songpos_decode(snd_seq_event_t *ev, unsigned char *buf); +static void note_event(struct snd_midi_event *dev, struct snd_seq_event *ev); +static void one_param_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev); +static void pitchbend_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev); +static void two_param_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev); +static void one_param_event(struct snd_midi_event *dev, struct snd_seq_event *ev); +static void songpos_event(struct snd_midi_event *dev, struct snd_seq_event *ev); +static void note_decode(struct snd_seq_event *ev, unsigned char *buf); +static void one_param_decode(struct snd_seq_event *ev, unsigned char *buf); +static void pitchbend_decode(struct snd_seq_event *ev, unsigned char *buf); +static void two_param_decode(struct snd_seq_event *ev, unsigned char *buf); +static void songpos_decode(struct snd_seq_event *ev, unsigned char *buf); /* * event list */ -static struct status_event_list_t { +static struct status_event_list { int event; int qlen; - event_encode_t encode; - event_decode_t decode; + void (*encode)(struct snd_midi_event *dev, struct snd_seq_event *ev); + void (*decode)(struct snd_seq_event *ev, unsigned char *buf); } status_event[] = { /* 0x80 - 0xf0 */ {SNDRV_SEQ_EVENT_NOTEOFF, 2, note_event, note_decode}, @@ -97,12 +93,15 @@ static struct status_event_list_t { {SNDRV_SEQ_EVENT_RESET, 0, NULL, NULL}, /* 0xff */ }; -static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int len, snd_seq_event_t *ev); -static int extra_decode_xrpn(snd_midi_event_t *dev, unsigned char *buf, int count, snd_seq_event_t *ev); +static int extra_decode_ctrl14(struct snd_midi_event *dev, unsigned char *buf, int len, + struct snd_seq_event *ev); +static int extra_decode_xrpn(struct snd_midi_event *dev, unsigned char *buf, int count, + struct snd_seq_event *ev); -static struct extra_event_list_t { +static struct extra_event_list { int event; - int (*decode)(snd_midi_event_t *dev, unsigned char *buf, int len, snd_seq_event_t *ev); + int (*decode)(struct snd_midi_event *dev, unsigned char *buf, int len, + struct snd_seq_event *ev); } extra_event[] = { {SNDRV_SEQ_EVENT_CONTROL14, extra_decode_ctrl14}, {SNDRV_SEQ_EVENT_NONREGPARAM, extra_decode_xrpn}, @@ -113,9 +112,9 @@ static struct extra_event_list_t { * new/delete record */ -int snd_midi_event_new(int bufsize, snd_midi_event_t **rdev) +int snd_midi_event_new(int bufsize, struct snd_midi_event **rdev) { - snd_midi_event_t *dev; + struct snd_midi_event *dev; *rdev = NULL; dev = kzalloc(sizeof(*dev), GFP_KERNEL); @@ -135,7 +134,7 @@ int snd_midi_event_new(int bufsize, snd_midi_event_t **rdev) return 0; } -void snd_midi_event_free(snd_midi_event_t *dev) +void snd_midi_event_free(struct snd_midi_event *dev) { if (dev != NULL) { kfree(dev->buf); @@ -146,14 +145,14 @@ void snd_midi_event_free(snd_midi_event_t *dev) /* * initialize record */ -static inline void reset_encode(snd_midi_event_t *dev) +static inline void reset_encode(struct snd_midi_event *dev) { dev->read = 0; dev->qlen = 0; dev->type = 0; } -void snd_midi_event_reset_encode(snd_midi_event_t *dev) +void snd_midi_event_reset_encode(struct snd_midi_event *dev) { unsigned long flags; @@ -162,7 +161,7 @@ void snd_midi_event_reset_encode(snd_midi_event_t *dev) spin_unlock_irqrestore(&dev->lock, flags); } -void snd_midi_event_reset_decode(snd_midi_event_t *dev) +void snd_midi_event_reset_decode(struct snd_midi_event *dev) { unsigned long flags; @@ -172,14 +171,14 @@ void snd_midi_event_reset_decode(snd_midi_event_t *dev) } #if 0 -void snd_midi_event_init(snd_midi_event_t *dev) +void snd_midi_event_init(struct snd_midi_event *dev) { snd_midi_event_reset_encode(dev); snd_midi_event_reset_decode(dev); } #endif /* 0 */ -void snd_midi_event_no_status(snd_midi_event_t *dev, int on) +void snd_midi_event_no_status(struct snd_midi_event *dev, int on) { dev->nostat = on ? 1 : 0; } @@ -188,7 +187,7 @@ void snd_midi_event_no_status(snd_midi_event_t *dev, int on) * resize buffer */ #if 0 -int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize) +int snd_midi_event_resize_buffer(struct snd_midi_event *dev, int bufsize) { unsigned char *new_buf, *old_buf; unsigned long flags; @@ -213,7 +212,8 @@ int snd_midi_event_resize_buffer(snd_midi_event_t *dev, int bufsize) * read bytes and encode to sequencer event if finished * return the size of encoded bytes */ -long snd_midi_event_encode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev) +long snd_midi_event_encode(struct snd_midi_event *dev, unsigned char *buf, long count, + struct snd_seq_event *ev) { long result = 0; int rc; @@ -238,7 +238,8 @@ long snd_midi_event_encode(snd_midi_event_t *dev, unsigned char *buf, long count * 0 data is not finished * negative for error */ -int snd_midi_event_encode_byte(snd_midi_event_t *dev, int c, snd_seq_event_t *ev) +int snd_midi_event_encode_byte(struct snd_midi_event *dev, int c, + struct snd_seq_event *ev) { int rc = 0; unsigned long flags; @@ -303,7 +304,7 @@ int snd_midi_event_encode_byte(snd_midi_event_t *dev, int c, snd_seq_event_t *ev } /* encode note event */ -static void note_event(snd_midi_event_t *dev, snd_seq_event_t *ev) +static void note_event(struct snd_midi_event *dev, struct snd_seq_event *ev) { ev->data.note.channel = dev->buf[0] & 0x0f; ev->data.note.note = dev->buf[1]; @@ -311,21 +312,21 @@ static void note_event(snd_midi_event_t *dev, snd_seq_event_t *ev) } /* encode one parameter controls */ -static void one_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev) +static void one_param_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev) { ev->data.control.channel = dev->buf[0] & 0x0f; ev->data.control.value = dev->buf[1]; } /* encode pitch wheel change */ -static void pitchbend_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev) +static void pitchbend_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev) { ev->data.control.channel = dev->buf[0] & 0x0f; ev->data.control.value = (int)dev->buf[2] * 128 + (int)dev->buf[1] - 8192; } /* encode midi control change */ -static void two_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev) +static void two_param_ctrl_event(struct snd_midi_event *dev, struct snd_seq_event *ev) { ev->data.control.channel = dev->buf[0] & 0x0f; ev->data.control.param = dev->buf[1]; @@ -333,13 +334,13 @@ static void two_param_ctrl_event(snd_midi_event_t *dev, snd_seq_event_t *ev) } /* encode one parameter value*/ -static void one_param_event(snd_midi_event_t *dev, snd_seq_event_t *ev) +static void one_param_event(struct snd_midi_event *dev, struct snd_seq_event *ev) { ev->data.control.value = dev->buf[1]; } /* encode song position */ -static void songpos_event(snd_midi_event_t *dev, snd_seq_event_t *ev) +static void songpos_event(struct snd_midi_event *dev, struct snd_seq_event *ev) { ev->data.control.value = (int)dev->buf[2] * 128 + (int)dev->buf[1]; } @@ -348,7 +349,8 @@ static void songpos_event(snd_midi_event_t *dev, snd_seq_event_t *ev) * decode from a sequencer event to midi bytes * return the size of decoded midi events */ -long snd_midi_event_decode(snd_midi_event_t *dev, unsigned char *buf, long count, snd_seq_event_t *ev) +long snd_midi_event_decode(struct snd_midi_event *dev, unsigned char *buf, long count, + struct snd_seq_event *ev) { unsigned int cmd, type; @@ -404,20 +406,20 @@ long snd_midi_event_decode(snd_midi_event_t *dev, unsigned char *buf, long count /* decode note event */ -static void note_decode(snd_seq_event_t *ev, unsigned char *buf) +static void note_decode(struct snd_seq_event *ev, unsigned char *buf) { buf[0] = ev->data.note.note & 0x7f; buf[1] = ev->data.note.velocity & 0x7f; } /* decode one parameter controls */ -static void one_param_decode(snd_seq_event_t *ev, unsigned char *buf) +static void one_param_decode(struct snd_seq_event *ev, unsigned char *buf) { buf[0] = ev->data.control.value & 0x7f; } /* decode pitch wheel change */ -static void pitchbend_decode(snd_seq_event_t *ev, unsigned char *buf) +static void pitchbend_decode(struct snd_seq_event *ev, unsigned char *buf) { int value = ev->data.control.value + 8192; buf[0] = value & 0x7f; @@ -425,21 +427,22 @@ static void pitchbend_decode(snd_seq_event_t *ev, unsigned char *buf) } /* decode midi control change */ -static void two_param_decode(snd_seq_event_t *ev, unsigned char *buf) +static void two_param_decode(struct snd_seq_event *ev, unsigned char *buf) { buf[0] = ev->data.control.param & 0x7f; buf[1] = ev->data.control.value & 0x7f; } /* decode song position */ -static void songpos_decode(snd_seq_event_t *ev, unsigned char *buf) +static void songpos_decode(struct snd_seq_event *ev, unsigned char *buf) { buf[0] = ev->data.control.value & 0x7f; buf[1] = (ev->data.control.value >> 7) & 0x7f; } /* decode 14bit control */ -static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int count, snd_seq_event_t *ev) +static int extra_decode_ctrl14(struct snd_midi_event *dev, unsigned char *buf, + int count, struct snd_seq_event *ev) { unsigned char cmd; int idx = 0; @@ -476,7 +479,8 @@ static int extra_decode_ctrl14(snd_midi_event_t *dev, unsigned char *buf, int co } /* decode reg/nonreg param */ -static int extra_decode_xrpn(snd_midi_event_t *dev, unsigned char *buf, int count, snd_seq_event_t *ev) +static int extra_decode_xrpn(struct snd_midi_event *dev, unsigned char *buf, + int count, struct snd_seq_event *ev) { unsigned char cmd; char *cbytes; diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 57ec31d..2b384fd 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -56,16 +56,17 @@ much elements are in array. */ /* return pointer to port structure - port is locked if found */ -client_port_t *snd_seq_port_use_ptr(client_t *client, int num) +struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client, + int num) { struct list_head *p; - client_port_t *port; + struct snd_seq_client_port *port; if (client == NULL) return NULL; read_lock(&client->ports_lock); list_for_each(p, &client->ports_list_head) { - port = list_entry(p, client_port_t, list); + port = list_entry(p, struct snd_seq_client_port, list); if (port->addr.port == num) { if (port->closing) break; /* deleting now */ @@ -80,17 +81,18 @@ client_port_t *snd_seq_port_use_ptr(client_t *client, int num) /* search for the next port - port is locked if found */ -client_port_t *snd_seq_port_query_nearest(client_t *client, snd_seq_port_info_t *pinfo) +struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *client, + struct snd_seq_port_info *pinfo) { int num; struct list_head *p; - client_port_t *port, *found; + struct snd_seq_client_port *port, *found; num = pinfo->addr.port; found = NULL; read_lock(&client->ports_lock); list_for_each(p, &client->ports_list_head) { - port = list_entry(p, client_port_t, list); + port = list_entry(p, struct snd_seq_client_port, list); if (port->addr.port < num) continue; if (port->addr.port == num) { @@ -111,8 +113,8 @@ client_port_t *snd_seq_port_query_nearest(client_t *client, snd_seq_port_info_t } -/* initialize port_subs_info_t */ -static void port_subs_info_init(port_subs_info_t *grp) +/* initialize snd_seq_port_subs_info */ +static void port_subs_info_init(struct snd_seq_port_subs_info *grp) { INIT_LIST_HEAD(&grp->list_head); grp->count = 0; @@ -125,10 +127,11 @@ static void port_subs_info_init(port_subs_info_t *grp) /* create a port, port number is returned (-1 on failure) */ -client_port_t *snd_seq_create_port(client_t *client, int port) +struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, + int port) { unsigned long flags; - client_port_t *new_port; + struct snd_seq_client_port *new_port; struct list_head *l; int num = -1; @@ -159,7 +162,7 @@ client_port_t *snd_seq_create_port(client_t *client, int port) down(&client->ports_mutex); write_lock_irqsave(&client->ports_lock, flags); list_for_each(l, &client->ports_list_head) { - client_port_t *p = list_entry(l, client_port_t, list); + struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); if (p->addr.port > num) break; if (port < 0) /* auto-probe mode */ @@ -177,17 +180,24 @@ client_port_t *snd_seq_create_port(client_t *client, int port) } /* */ -enum group_type_t { +enum group_type { SRC_LIST, DEST_LIST }; -static int subscribe_port(client_t *client, client_port_t *port, port_subs_info_t *grp, snd_seq_port_subscribe_t *info, int send_ack); -static int unsubscribe_port(client_t *client, client_port_t *port, port_subs_info_t *grp, snd_seq_port_subscribe_t *info, int send_ack); +static int subscribe_port(struct snd_seq_client *client, + struct snd_seq_client_port *port, + struct snd_seq_port_subs_info *grp, + struct snd_seq_port_subscribe *info, int send_ack); +static int unsubscribe_port(struct snd_seq_client *client, + struct snd_seq_client_port *port, + struct snd_seq_port_subs_info *grp, + struct snd_seq_port_subscribe *info, int send_ack); -static client_port_t *get_client_port(snd_seq_addr_t *addr, client_t **cp) +static struct snd_seq_client_port *get_client_port(struct snd_seq_addr *addr, + struct snd_seq_client **cp) { - client_port_t *p; + struct snd_seq_client_port *p; *cp = snd_seq_client_use_ptr(addr->client); if (*cp) { p = snd_seq_port_use_ptr(*cp, addr->port); @@ -204,22 +214,24 @@ static client_port_t *get_client_port(snd_seq_addr_t *addr, client_t **cp) * remove all subscribers on the list * this is called from port_delete, for each src and dest list. */ -static void clear_subscriber_list(client_t *client, client_port_t *port, - port_subs_info_t *grp, int grptype) +static void clear_subscriber_list(struct snd_seq_client *client, + struct snd_seq_client_port *port, + struct snd_seq_port_subs_info *grp, + int grptype) { struct list_head *p, *n; down_write(&grp->list_mutex); list_for_each_safe(p, n, &grp->list_head) { - subscribers_t *subs; - client_t *c; - client_port_t *aport; + struct snd_seq_subscribers *subs; + struct snd_seq_client *c; + struct snd_seq_client_port *aport; if (grptype == SRC_LIST) { - subs = list_entry(p, subscribers_t, src_list); + subs = list_entry(p, struct snd_seq_subscribers, src_list); aport = get_client_port(&subs->info.dest, &c); } else { - subs = list_entry(p, subscribers_t, dest_list); + subs = list_entry(p, struct snd_seq_subscribers, dest_list); aport = get_client_port(&subs->info.sender, &c); } list_del(p); @@ -233,7 +245,7 @@ static void clear_subscriber_list(client_t *client, client_port_t *port, kfree(subs); } else { /* ok we got the connected port */ - port_subs_info_t *agrp; + struct snd_seq_port_subs_info *agrp; agrp = (grptype == SRC_LIST) ? &aport->c_dest : &aport->c_src; down_write(&agrp->list_mutex); if (grptype == SRC_LIST) @@ -251,7 +263,8 @@ static void clear_subscriber_list(client_t *client, client_port_t *port, } /* delete port data */ -static int port_delete(client_t *client, client_port_t *port) +static int port_delete(struct snd_seq_client *client, + struct snd_seq_client_port *port) { /* set closing flag and wait for all port access are gone */ port->closing = 1; @@ -273,16 +286,16 @@ static int port_delete(client_t *client, client_port_t *port) /* delete a port with the given port id */ -int snd_seq_delete_port(client_t *client, int port) +int snd_seq_delete_port(struct snd_seq_client *client, int port) { unsigned long flags; struct list_head *l; - client_port_t *found = NULL; + struct snd_seq_client_port *found = NULL; down(&client->ports_mutex); write_lock_irqsave(&client->ports_lock, flags); list_for_each(l, &client->ports_list_head) { - client_port_t *p = list_entry(l, client_port_t, list); + struct snd_seq_client_port *p = list_entry(l, struct snd_seq_client_port, list); if (p->addr.port == port) { /* ok found. delete from the list at first */ list_del(l); @@ -300,7 +313,7 @@ int snd_seq_delete_port(client_t *client, int port) } /* delete the all ports belonging to the given client */ -int snd_seq_delete_all_ports(client_t *client) +int snd_seq_delete_all_ports(struct snd_seq_client *client) { unsigned long flags; struct list_head deleted_list, *p, *n; @@ -323,7 +336,7 @@ int snd_seq_delete_all_ports(client_t *client) /* remove each port in deleted_list */ list_for_each_safe(p, n, &deleted_list) { - client_port_t *port = list_entry(p, client_port_t, list); + struct snd_seq_client_port *port = list_entry(p, struct snd_seq_client_port, list); list_del(p); snd_seq_system_client_ev_port_exit(port->addr.client, port->addr.port); port_delete(client, port); @@ -333,7 +346,8 @@ int snd_seq_delete_all_ports(client_t *client) } /* set port info fields */ -int snd_seq_set_port_info(client_port_t * port, snd_seq_port_info_t * info) +int snd_seq_set_port_info(struct snd_seq_client_port * port, + struct snd_seq_port_info * info) { snd_assert(port && info, return -EINVAL); @@ -361,7 +375,8 @@ int snd_seq_set_port_info(client_port_t * port, snd_seq_port_info_t * info) } /* get port info fields */ -int snd_seq_get_port_info(client_port_t * port, snd_seq_port_info_t * info) +int snd_seq_get_port_info(struct snd_seq_client_port * port, + struct snd_seq_port_info * info) { snd_assert(port && info, return -EINVAL); @@ -410,8 +425,11 @@ int snd_seq_get_port_info(client_port_t * port, snd_seq_port_info_t * info) * at each connnection/disconnection. */ -static int subscribe_port(client_t *client, client_port_t *port, port_subs_info_t *grp, - snd_seq_port_subscribe_t *info, int send_ack) +static int subscribe_port(struct snd_seq_client *client, + struct snd_seq_client_port *port, + struct snd_seq_port_subs_info *grp, + struct snd_seq_port_subscribe *info, + int send_ack) { int err = 0; @@ -432,9 +450,11 @@ static int subscribe_port(client_t *client, client_port_t *port, port_subs_info_ return err; } -static int unsubscribe_port(client_t *client, client_port_t *port, - port_subs_info_t *grp, - snd_seq_port_subscribe_t *info, int send_ack) +static int unsubscribe_port(struct snd_seq_client *client, + struct snd_seq_client_port *port, + struct snd_seq_port_subs_info *grp, + struct snd_seq_port_subscribe *info, + int send_ack) { int err = 0; @@ -453,15 +473,15 @@ static int unsubscribe_port(client_t *client, client_port_t *port, /* check if both addresses are identical */ -static inline int addr_match(snd_seq_addr_t *r, snd_seq_addr_t *s) +static inline int addr_match(struct snd_seq_addr *r, struct snd_seq_addr *s) { return (r->client == s->client) && (r->port == s->port); } /* check the two subscribe info match */ /* if flags is zero, checks only sender and destination addresses */ -static int match_subs_info(snd_seq_port_subscribe_t *r, - snd_seq_port_subscribe_t *s) +static int match_subs_info(struct snd_seq_port_subscribe *r, + struct snd_seq_port_subscribe *s) { if (addr_match(&r->sender, &s->sender) && addr_match(&r->dest, &s->dest)) { @@ -475,14 +495,16 @@ static int match_subs_info(snd_seq_port_subscribe_t *r, /* connect two ports */ -int snd_seq_port_connect(client_t *connector, - client_t *src_client, client_port_t *src_port, - client_t *dest_client, client_port_t *dest_port, - snd_seq_port_subscribe_t *info) +int snd_seq_port_connect(struct snd_seq_client *connector, + struct snd_seq_client *src_client, + struct snd_seq_client_port *src_port, + struct snd_seq_client *dest_client, + struct snd_seq_client_port *dest_port, + struct snd_seq_port_subscribe *info) { - port_subs_info_t *src = &src_port->c_src; - port_subs_info_t *dest = &dest_port->c_dest; - subscribers_t *subs; + struct snd_seq_port_subs_info *src = &src_port->c_src; + struct snd_seq_port_subs_info *dest = &dest_port->c_dest; + struct snd_seq_subscribers *subs; struct list_head *p; int err, src_called = 0; unsigned long flags; @@ -508,12 +530,12 @@ int snd_seq_port_connect(client_t *connector, goto __error; /* check whether already exists */ list_for_each(p, &src->list_head) { - subscribers_t *s = list_entry(p, subscribers_t, src_list); + struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, src_list); if (match_subs_info(info, &s->info)) goto __error; } list_for_each(p, &dest->list_head) { - subscribers_t *s = list_entry(p, subscribers_t, dest_list); + struct snd_seq_subscribers *s = list_entry(p, struct snd_seq_subscribers, dest_list); if (match_subs_info(info, &s->info)) goto __error; } @@ -554,14 +576,16 @@ int snd_seq_port_connect(client_t *connector, /* remove the connection */ -int snd_seq_port_disconnect(client_t *connector, - client_t *src_client, client_port_t *src_port, - client_t *dest_client, client_port_t *dest_port, - snd_seq_port_subscribe_t *info) +int snd_seq_port_disconnect(struct snd_seq_client *connector, + struct snd_seq_client *src_client, + struct snd_seq_client_port *src_port, + struct snd_seq_client *dest_client, + struct snd_seq_client_port *dest_port, + struct snd_seq_port_subscribe *info) { - port_subs_info_t *src = &src_port->c_src; - port_subs_info_t *dest = &dest_port->c_dest; - subscribers_t *subs; + struct snd_seq_port_subs_info *src = &src_port->c_src; + struct snd_seq_port_subs_info *dest = &dest_port->c_dest; + struct snd_seq_subscribers *subs; struct list_head *p; int err = -ENOENT; unsigned long flags; @@ -571,7 +595,7 @@ int snd_seq_port_disconnect(client_t *connector, /* look for the connection */ list_for_each(p, &src->list_head) { - subs = list_entry(p, subscribers_t, src_list); + subs = list_entry(p, struct snd_seq_subscribers, src_list); if (match_subs_info(info, &subs->info)) { write_lock_irqsave(&src->list_lock, flags); // write_lock(&dest->list_lock); // no lock yet @@ -597,15 +621,15 @@ int snd_seq_port_disconnect(client_t *connector, /* get matched subscriber */ -subscribers_t *snd_seq_port_get_subscription(port_subs_info_t *src_grp, - snd_seq_addr_t *dest_addr) +struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp, + struct snd_seq_addr *dest_addr) { struct list_head *p; - subscribers_t *s, *found = NULL; + struct snd_seq_subscribers *s, *found = NULL; down_read(&src_grp->list_mutex); list_for_each(p, &src_grp->list_head) { - s = list_entry(p, subscribers_t, src_list); + s = list_entry(p, struct snd_seq_subscribers, src_list); if (addr_match(dest_addr, &s->info.dest)) { found = s; break; @@ -623,11 +647,11 @@ subscribers_t *snd_seq_port_get_subscription(port_subs_info_t *src_grp, */ /* exported */ int snd_seq_event_port_attach(int client, - snd_seq_port_callback_t *pcbp, + struct snd_seq_port_callback *pcbp, int cap, int type, int midi_channels, int midi_voices, char *portname) { - snd_seq_port_info_t portinfo; + struct snd_seq_port_info portinfo; int ret; /* Set up the port */ @@ -660,7 +684,7 @@ int snd_seq_event_port_attach(int client, /* exported */ int snd_seq_event_port_detach(int client, int port) { - snd_seq_port_info_t portinfo; + struct snd_seq_port_info portinfo; int err; memset(&portinfo, 0, sizeof(portinfo)); diff --git a/sound/core/seq/seq_ports.h b/sound/core/seq/seq_ports.h index 89fd4416..9d71171 100644 --- a/sound/core/seq/seq_ports.h +++ b/sound/core/seq/seq_ports.h @@ -40,37 +40,38 @@ */ -typedef struct subscribers_t { - snd_seq_port_subscribe_t info; /* additional info */ +struct snd_seq_subscribers { + struct snd_seq_port_subscribe info; /* additional info */ struct list_head src_list; /* link of sources */ struct list_head dest_list; /* link of destinations */ atomic_t ref_count; -} subscribers_t; +}; -typedef struct port_subs_info_t { +struct snd_seq_port_subs_info { struct list_head list_head; /* list of subscribed ports */ unsigned int count; /* count of subscribers */ unsigned int exclusive: 1; /* exclusive mode */ struct rw_semaphore list_mutex; rwlock_t list_lock; - snd_seq_kernel_port_open_t *open; - snd_seq_kernel_port_close_t *close; -} port_subs_info_t; + int (*open)(void *private_data, struct snd_seq_port_subscribe *info); + int (*close)(void *private_data, struct snd_seq_port_subscribe *info); +}; -typedef struct client_port_t { +struct snd_seq_client_port { - snd_seq_addr_t addr; /* client/port number */ + struct snd_seq_addr addr; /* client/port number */ struct module *owner; /* owner of this port */ char name[64]; /* port name */ struct list_head list; /* port list */ snd_use_lock_t use_lock; /* subscribers */ - port_subs_info_t c_src; /* read (sender) list */ - port_subs_info_t c_dest; /* write (dest) list */ + struct snd_seq_port_subs_info c_src; /* read (sender) list */ + struct snd_seq_port_subs_info c_dest; /* write (dest) list */ - snd_seq_kernel_port_input_t *event_input; - snd_seq_kernel_port_private_free_t *private_free; + int (*event_input)(struct snd_seq_event *ev, int direct, void *private_data, + int atomic, int hop); + void (*private_free)(void *private_data); void *private_data; unsigned int callback_all : 1; unsigned int closing : 1; @@ -87,42 +88,55 @@ typedef struct client_port_t { int midi_voices; int synth_voices; -} client_port_t; +}; + +struct snd_seq_client; /* return pointer to port structure and lock port */ -client_port_t *snd_seq_port_use_ptr(client_t *client, int num); +struct snd_seq_client_port *snd_seq_port_use_ptr(struct snd_seq_client *client, int num); /* search for next port - port is locked if found */ -client_port_t *snd_seq_port_query_nearest(client_t *client, snd_seq_port_info_t *pinfo); +struct snd_seq_client_port *snd_seq_port_query_nearest(struct snd_seq_client *client, + struct snd_seq_port_info *pinfo); /* unlock the port */ #define snd_seq_port_unlock(port) snd_use_lock_free(&(port)->use_lock) /* create a port, port number is returned (-1 on failure) */ -client_port_t *snd_seq_create_port(client_t *client, int port_index); +struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client, int port_index); /* delete a port */ -int snd_seq_delete_port(client_t *client, int port); +int snd_seq_delete_port(struct snd_seq_client *client, int port); /* delete all ports */ -int snd_seq_delete_all_ports(client_t *client); +int snd_seq_delete_all_ports(struct snd_seq_client *client); /* set port info fields */ -int snd_seq_set_port_info(client_port_t *port, snd_seq_port_info_t *info); +int snd_seq_set_port_info(struct snd_seq_client_port *port, + struct snd_seq_port_info *info); /* get port info fields */ -int snd_seq_get_port_info(client_port_t *port, snd_seq_port_info_t *info); +int snd_seq_get_port_info(struct snd_seq_client_port *port, + struct snd_seq_port_info *info); /* add subscriber to subscription list */ -int snd_seq_port_connect(client_t *caller, client_t *s, client_port_t *sp, client_t *d, client_port_t *dp, snd_seq_port_subscribe_t *info); +int snd_seq_port_connect(struct snd_seq_client *caller, + struct snd_seq_client *s, struct snd_seq_client_port *sp, + struct snd_seq_client *d, struct snd_seq_client_port *dp, + struct snd_seq_port_subscribe *info); /* remove subscriber from subscription list */ -int snd_seq_port_disconnect(client_t *caller, client_t *s, client_port_t *sp, client_t *d, client_port_t *dp, snd_seq_port_subscribe_t *info); +int snd_seq_port_disconnect(struct snd_seq_client *caller, + struct snd_seq_client *s, struct snd_seq_client_port *sp, + struct snd_seq_client *d, struct snd_seq_client_port *dp, + struct snd_seq_port_subscribe *info); /* subscribe port */ -int snd_seq_port_subscribe(client_port_t *port, snd_seq_port_subscribe_t *info); +int snd_seq_port_subscribe(struct snd_seq_client_port *port, + struct snd_seq_port_subscribe *info); /* get matched subscriber */ -subscribers_t *snd_seq_port_get_subscription(port_subs_info_t *src_grp, snd_seq_addr_t *dest_addr); +struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp, + struct snd_seq_addr *dest_addr); #endif diff --git a/sound/core/seq/seq_prioq.c b/sound/core/seq/seq_prioq.c index cd641bc..0744186 100644 --- a/sound/core/seq/seq_prioq.c +++ b/sound/core/seq/seq_prioq.c @@ -55,9 +55,9 @@ /* create new prioq (constructor) */ -prioq_t *snd_seq_prioq_new(void) +struct snd_seq_prioq *snd_seq_prioq_new(void) { - prioq_t *f; + struct snd_seq_prioq *f; f = kzalloc(sizeof(*f), GFP_KERNEL); if (f == NULL) { @@ -74,9 +74,9 @@ prioq_t *snd_seq_prioq_new(void) } /* delete prioq (destructor) */ -void snd_seq_prioq_delete(prioq_t **fifo) +void snd_seq_prioq_delete(struct snd_seq_prioq **fifo) { - prioq_t *f = *fifo; + struct snd_seq_prioq *f = *fifo; *fifo = NULL; if (f == NULL) { @@ -101,7 +101,8 @@ void snd_seq_prioq_delete(prioq_t **fifo) /* compare timestamp between events */ /* return 1 if a >= b; 0 */ -static inline int compare_timestamp(snd_seq_event_t * a, snd_seq_event_t * b) +static inline int compare_timestamp(struct snd_seq_event *a, + struct snd_seq_event *b) { if ((a->flags & SNDRV_SEQ_TIME_STAMP_MASK) == SNDRV_SEQ_TIME_STAMP_TICK) { /* compare ticks */ @@ -117,7 +118,8 @@ static inline int compare_timestamp(snd_seq_event_t * a, snd_seq_event_t * b) * zero if a = b; * positive if a > b; */ -static inline int compare_timestamp_rel(snd_seq_event_t *a, snd_seq_event_t *b) +static inline int compare_timestamp_rel(struct snd_seq_event *a, + struct snd_seq_event *b) { if ((a->flags & SNDRV_SEQ_TIME_STAMP_MASK) == SNDRV_SEQ_TIME_STAMP_TICK) { /* compare ticks */ @@ -144,9 +146,10 @@ static inline int compare_timestamp_rel(snd_seq_event_t *a, snd_seq_event_t *b) } /* enqueue cell to prioq */ -int snd_seq_prioq_cell_in(prioq_t * f, snd_seq_event_cell_t * cell) +int snd_seq_prioq_cell_in(struct snd_seq_prioq * f, + struct snd_seq_event_cell * cell) { - snd_seq_event_cell_t *cur, *prev; + struct snd_seq_event_cell *cur, *prev; unsigned long flags; int count; int prior; @@ -215,9 +218,9 @@ int snd_seq_prioq_cell_in(prioq_t * f, snd_seq_event_cell_t * cell) } /* dequeue cell from prioq */ -snd_seq_event_cell_t *snd_seq_prioq_cell_out(prioq_t * f) +struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f) { - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; unsigned long flags; if (f == NULL) { @@ -243,7 +246,7 @@ snd_seq_event_cell_t *snd_seq_prioq_cell_out(prioq_t * f) } /* return number of events available in prioq */ -int snd_seq_prioq_avail(prioq_t * f) +int snd_seq_prioq_avail(struct snd_seq_prioq * f) { if (f == NULL) { snd_printd("oops: snd_seq_prioq_cell_in() called with NULL prioq\n"); @@ -254,7 +257,7 @@ int snd_seq_prioq_avail(prioq_t * f) /* peek at cell at the head of the prioq */ -snd_seq_event_cell_t *snd_seq_prioq_cell_peek(prioq_t * f) +struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq * f) { if (f == NULL) { snd_printd("oops: snd_seq_prioq_cell_in() called with NULL prioq\n"); @@ -264,7 +267,8 @@ snd_seq_event_cell_t *snd_seq_prioq_cell_peek(prioq_t * f) } -static inline int prioq_match(snd_seq_event_cell_t *cell, int client, int timestamp) +static inline int prioq_match(struct snd_seq_event_cell *cell, + int client, int timestamp) { if (cell->event.source.client == client || cell->event.dest.client == client) @@ -286,12 +290,12 @@ static inline int prioq_match(snd_seq_event_cell_t *cell, int client, int timest } /* remove cells for left client */ -void snd_seq_prioq_leave(prioq_t * f, int client, int timestamp) +void snd_seq_prioq_leave(struct snd_seq_prioq * f, int client, int timestamp) { - register snd_seq_event_cell_t *cell, *next; + register struct snd_seq_event_cell *cell, *next; unsigned long flags; - snd_seq_event_cell_t *prev = NULL; - snd_seq_event_cell_t *freefirst = NULL, *freeprev = NULL, *freenext; + struct snd_seq_event_cell *prev = NULL; + struct snd_seq_event_cell *freefirst = NULL, *freeprev = NULL, *freenext; /* collect all removed cells */ spin_lock_irqsave(&f->lock, flags); @@ -338,8 +342,8 @@ void snd_seq_prioq_leave(prioq_t * f, int client, int timestamp) } } -static int prioq_remove_match(snd_seq_remove_events_t *info, - snd_seq_event_t *ev) +static int prioq_remove_match(struct snd_seq_remove_events *info, + struct snd_seq_event *ev) { int res; @@ -394,13 +398,13 @@ static int prioq_remove_match(snd_seq_remove_events_t *info, } /* remove cells matching remove criteria */ -void snd_seq_prioq_remove_events(prioq_t * f, int client, - snd_seq_remove_events_t *info) +void snd_seq_prioq_remove_events(struct snd_seq_prioq * f, int client, + struct snd_seq_remove_events *info) { - register snd_seq_event_cell_t *cell, *next; + struct snd_seq_event_cell *cell, *next; unsigned long flags; - snd_seq_event_cell_t *prev = NULL; - snd_seq_event_cell_t *freefirst = NULL, *freeprev = NULL, *freenext; + struct snd_seq_event_cell *prev = NULL; + struct snd_seq_event_cell *freefirst = NULL, *freeprev = NULL, *freenext; /* collect all removed cells */ spin_lock_irqsave(&f->lock, flags); diff --git a/sound/core/seq/seq_prioq.h b/sound/core/seq/seq_prioq.h index f12af79..d38bb78 100644 --- a/sound/core/seq/seq_prioq.h +++ b/sound/core/seq/seq_prioq.h @@ -26,37 +26,37 @@ /* === PRIOQ === */ -typedef struct { - snd_seq_event_cell_t* head; /* pointer to head of prioq */ - snd_seq_event_cell_t* tail; /* pointer to tail of prioq */ +struct snd_seq_prioq { + struct snd_seq_event_cell *head; /* pointer to head of prioq */ + struct snd_seq_event_cell *tail; /* pointer to tail of prioq */ int cells; spinlock_t lock; -} prioq_t; +}; /* create new prioq (constructor) */ -extern prioq_t *snd_seq_prioq_new(void); +struct snd_seq_prioq *snd_seq_prioq_new(void); /* delete prioq (destructor) */ -extern void snd_seq_prioq_delete(prioq_t **fifo); +void snd_seq_prioq_delete(struct snd_seq_prioq **fifo); /* enqueue cell to prioq */ -extern int snd_seq_prioq_cell_in(prioq_t *f, snd_seq_event_cell_t *cell); +int snd_seq_prioq_cell_in(struct snd_seq_prioq *f, struct snd_seq_event_cell *cell); /* dequeue cell from prioq */ -extern snd_seq_event_cell_t *snd_seq_prioq_cell_out(prioq_t *f); +struct snd_seq_event_cell *snd_seq_prioq_cell_out(struct snd_seq_prioq *f); /* return number of events available in prioq */ -extern int snd_seq_prioq_avail(prioq_t *f); +int snd_seq_prioq_avail(struct snd_seq_prioq *f); /* peek at cell at the head of the prioq */ -extern snd_seq_event_cell_t *snd_seq_prioq_cell_peek(prioq_t *f); +struct snd_seq_event_cell *snd_seq_prioq_cell_peek(struct snd_seq_prioq *f); /* client left queue */ -extern void snd_seq_prioq_leave(prioq_t *f, int client, int timestamp); +void snd_seq_prioq_leave(struct snd_seq_prioq *f, int client, int timestamp); /* Remove events */ -void snd_seq_prioq_remove_events(prioq_t * f, int client, - snd_seq_remove_events_t *info); +void snd_seq_prioq_remove_events(struct snd_seq_prioq *f, int client, + struct snd_seq_remove_events *info); #endif diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index 5f5c3cb..b537a71 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c @@ -29,7 +29,7 @@ * Aug. 30, 2000 Takashi Iwai * - Queues are managed in static array again, but with better way. * The API itself is identical. - * - The queue is locked when queue_t pinter is returned via + * - The queue is locked when struct snd_seq_queue pointer is returned via * queueptr(). This pointer *MUST* be released afterward by * queuefree(ptr). * - Addition of experimental sync support. @@ -48,7 +48,7 @@ #include "seq_info.h" /* list of allocated queues */ -static queue_t *queue_list[SNDRV_SEQ_MAX_QUEUES]; +static struct snd_seq_queue *queue_list[SNDRV_SEQ_MAX_QUEUES]; static DEFINE_SPINLOCK(queue_list_lock); /* number of queues allocated */ static int num_queues; @@ -61,7 +61,7 @@ int snd_seq_queue_get_cur_queues(void) /*----------------------------------------------------------------*/ /* assign queue id and insert to list */ -static int queue_list_add(queue_t *q) +static int queue_list_add(struct snd_seq_queue *q) { int i; unsigned long flags; @@ -80,9 +80,9 @@ static int queue_list_add(queue_t *q) return -1; } -static queue_t *queue_list_remove(int id, int client) +static struct snd_seq_queue *queue_list_remove(int id, int client) { - queue_t *q; + struct snd_seq_queue *q; unsigned long flags; spin_lock_irqsave(&queue_list_lock, flags); @@ -107,9 +107,9 @@ static queue_t *queue_list_remove(int id, int client) /*----------------------------------------------------------------*/ /* create new queue (constructor) */ -static queue_t *queue_new(int owner, int locked) +static struct snd_seq_queue *queue_new(int owner, int locked) { - queue_t *q; + struct snd_seq_queue *q; q = kzalloc(sizeof(*q), GFP_KERNEL); if (q == NULL) { @@ -142,7 +142,7 @@ static queue_t *queue_new(int owner, int locked) } /* delete queue (destructor) */ -static void queue_delete(queue_t *q) +static void queue_delete(struct snd_seq_queue *q) { /* stop and release the timer */ snd_seq_timer_stop(q->timer); @@ -187,7 +187,7 @@ void __exit snd_seq_queues_delete(void) */ int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) { - queue_t *q; + struct snd_seq_queue *q; q = queue_new(client, locked); if (q == NULL) @@ -204,7 +204,7 @@ int snd_seq_queue_alloc(int client, int locked, unsigned int info_flags) /* delete a queue - queue must be owned by the client */ int snd_seq_queue_delete(int client, int queueid) { - queue_t *q; + struct snd_seq_queue *q; if (queueid < 0 || queueid >= SNDRV_SEQ_MAX_QUEUES) return -EINVAL; @@ -218,9 +218,9 @@ int snd_seq_queue_delete(int client, int queueid) /* return pointer to queue structure for specified id */ -queue_t *queueptr(int queueid) +struct snd_seq_queue *queueptr(int queueid) { - queue_t *q; + struct snd_seq_queue *q; unsigned long flags; if (queueid < 0 || queueid >= SNDRV_SEQ_MAX_QUEUES) @@ -234,10 +234,10 @@ queue_t *queueptr(int queueid) } /* return the (first) queue matching with the specified name */ -queue_t *snd_seq_queue_find_name(char *name) +struct snd_seq_queue *snd_seq_queue_find_name(char *name) { int i; - queue_t *q; + struct snd_seq_queue *q; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) != NULL) { @@ -252,10 +252,10 @@ queue_t *snd_seq_queue_find_name(char *name) /* -------------------------------------------------------- */ -void snd_seq_check_queue(queue_t *q, int atomic, int hop) +void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop) { unsigned long flags; - snd_seq_event_cell_t *cell; + struct snd_seq_event_cell *cell; if (q == NULL) return; @@ -273,7 +273,8 @@ void snd_seq_check_queue(queue_t *q, int atomic, int hop) __again: /* Process tick queue... */ while ((cell = snd_seq_prioq_cell_peek(q->tickq)) != NULL) { - if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick, &cell->event.time.tick)) { + if (snd_seq_compare_tick_time(&q->timer->tick.cur_tick, + &cell->event.time.tick)) { cell = snd_seq_prioq_cell_out(q->tickq); if (cell) snd_seq_dispatch_event(cell, atomic, hop); @@ -286,7 +287,8 @@ void snd_seq_check_queue(queue_t *q, int atomic, int hop) /* Process time queue... */ while ((cell = snd_seq_prioq_cell_peek(q->timeq)) != NULL) { - if (snd_seq_compare_real_time(&q->timer->cur_time, &cell->event.time.time)) { + if (snd_seq_compare_real_time(&q->timer->cur_time, + &cell->event.time.time)) { cell = snd_seq_prioq_cell_out(q->timeq); if (cell) snd_seq_dispatch_event(cell, atomic, hop); @@ -309,10 +311,10 @@ void snd_seq_check_queue(queue_t *q, int atomic, int hop) /* enqueue a event to singe queue */ -int snd_seq_enqueue_event(snd_seq_event_cell_t *cell, int atomic, int hop) +int snd_seq_enqueue_event(struct snd_seq_event_cell *cell, int atomic, int hop) { int dest, err; - queue_t *q; + struct snd_seq_queue *q; snd_assert(cell != NULL, return -EINVAL); dest = cell->event.queue; /* destination queue */ @@ -327,7 +329,8 @@ int snd_seq_enqueue_event(snd_seq_event_cell_t *cell, int atomic, int hop) break; case SNDRV_SEQ_TIME_STAMP_REAL: - snd_seq_inc_real_time(&cell->event.time.time, &q->timer->cur_time); + snd_seq_inc_real_time(&cell->event.time.time, + &q->timer->cur_time); break; } cell->event.flags &= ~SNDRV_SEQ_TIME_MODE_MASK; @@ -361,7 +364,7 @@ int snd_seq_enqueue_event(snd_seq_event_cell_t *cell, int atomic, int hop) /*----------------------------------------------------------------*/ -static inline int check_access(queue_t *q, int client) +static inline int check_access(struct snd_seq_queue *q, int client) { return (q->owner == client) || (!q->locked && !q->klocked); } @@ -369,7 +372,7 @@ static inline int check_access(queue_t *q, int client) /* check if the client has permission to modify queue parameters. * if it does, lock the queue */ -static int queue_access_lock(queue_t *q, int client) +static int queue_access_lock(struct snd_seq_queue *q, int client) { unsigned long flags; int access_ok; @@ -383,7 +386,7 @@ static int queue_access_lock(queue_t *q, int client) } /* unlock the queue */ -static inline void queue_access_unlock(queue_t *q) +static inline void queue_access_unlock(struct snd_seq_queue *q) { unsigned long flags; @@ -395,7 +398,7 @@ static inline void queue_access_unlock(queue_t *q) /* exported - only checking permission */ int snd_seq_queue_check_access(int queueid, int client) { - queue_t *q = queueptr(queueid); + struct snd_seq_queue *q = queueptr(queueid); int access_ok; unsigned long flags; @@ -415,7 +418,7 @@ int snd_seq_queue_check_access(int queueid, int client) */ int snd_seq_queue_set_owner(int queueid, int client, int locked) { - queue_t *q = queueptr(queueid); + struct snd_seq_queue *q = queueptr(queueid); if (q == NULL) return -EINVAL; @@ -443,8 +446,8 @@ int snd_seq_queue_set_owner(int queueid, int client, int locked) int snd_seq_queue_timer_open(int queueid) { int result = 0; - queue_t *queue; - seq_timer_t *tmr; + struct snd_seq_queue *queue; + struct snd_seq_timer *tmr; queue = queueptr(queueid); if (queue == NULL) @@ -463,8 +466,8 @@ int snd_seq_queue_timer_open(int queueid) */ int snd_seq_queue_timer_close(int queueid) { - queue_t *queue; - seq_timer_t *tmr; + struct snd_seq_queue *queue; + struct snd_seq_timer *tmr; int result = 0; queue = queueptr(queueid); @@ -477,9 +480,10 @@ int snd_seq_queue_timer_close(int queueid) } /* change queue tempo and ppq */ -int snd_seq_queue_timer_set_tempo(int queueid, int client, snd_seq_queue_tempo_t *info) +int snd_seq_queue_timer_set_tempo(int queueid, int client, + struct snd_seq_queue_tempo *info) { - queue_t *q = queueptr(queueid); + struct snd_seq_queue *q = queueptr(queueid); int result; if (q == NULL) @@ -493,7 +497,8 @@ int snd_seq_queue_timer_set_tempo(int queueid, int client, snd_seq_queue_tempo_t if (result >= 0) result = snd_seq_timer_set_ppq(q->timer, info->ppq); if (result >= 0 && info->skew_base > 0) - result = snd_seq_timer_set_skew(q->timer, info->skew_value, info->skew_base); + result = snd_seq_timer_set_skew(q->timer, info->skew_value, + info->skew_base); queue_access_unlock(q); queuefree(q); return result; @@ -506,7 +511,7 @@ int snd_seq_queue_timer_set_tempo(int queueid, int client, snd_seq_queue_tempo_t */ int snd_seq_queue_use(int queueid, int client, int use) { - queue_t *queue; + struct snd_seq_queue *queue; queue = queueptr(queueid); if (queue == NULL) @@ -538,7 +543,7 @@ int snd_seq_queue_use(int queueid, int client, int use) */ int snd_seq_queue_is_used(int queueid, int client) { - queue_t *q; + struct snd_seq_queue *q; int result; q = queueptr(queueid); @@ -559,7 +564,7 @@ void snd_seq_queue_client_termination(int client) { unsigned long flags; int i; - queue_t *q; + struct snd_seq_queue *q; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) @@ -584,7 +589,7 @@ void snd_seq_queue_client_termination(int client) void snd_seq_queue_client_leave(int client) { int i; - queue_t *q; + struct snd_seq_queue *q; /* delete own queues from queue list */ for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { @@ -615,7 +620,7 @@ void snd_seq_queue_client_leave(int client) void snd_seq_queue_client_leave_cells(int client) { int i; - queue_t *q; + struct snd_seq_queue *q; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) @@ -627,10 +632,10 @@ void snd_seq_queue_client_leave_cells(int client) } /* remove cells based on flush criteria */ -void snd_seq_queue_remove_cells(int client, snd_seq_remove_events_t *info) +void snd_seq_queue_remove_cells(int client, struct snd_seq_remove_events *info) { int i; - queue_t *q; + struct snd_seq_queue *q; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) @@ -650,9 +655,10 @@ void snd_seq_queue_remove_cells(int client, snd_seq_remove_events_t *info) /* * send events to all subscribed ports */ -static void queue_broadcast_event(queue_t *q, snd_seq_event_t *ev, int atomic, int hop) +static void queue_broadcast_event(struct snd_seq_queue *q, struct snd_seq_event *ev, + int atomic, int hop) { - snd_seq_event_t sev; + struct snd_seq_event sev; sev = *ev; @@ -672,7 +678,8 @@ static void queue_broadcast_event(queue_t *q, snd_seq_event_t *ev, int atomic, i * process a received queue-control event. * this function is exported for seq_sync.c. */ -static void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, +static void snd_seq_queue_process_event(struct snd_seq_queue *q, + struct snd_seq_event *ev, int atomic, int hop) { switch (ev->type) { @@ -724,9 +731,9 @@ static void snd_seq_queue_process_event(queue_t *q, snd_seq_event_t *ev, * Queue control via timer control port: * this function is exported as a callback of timer port. */ -int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop) +int snd_seq_control_queue(struct snd_seq_event *ev, int atomic, int hop) { - queue_t *q; + struct snd_seq_queue *q; snd_assert(ev != NULL, return -EINVAL); q = queueptr(ev->data.queue.queue); @@ -750,12 +757,12 @@ int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop) /*----------------------------------------------------------------*/ /* exported to seq_info.c */ -void snd_seq_info_queues_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +void snd_seq_info_queues_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int i, bpm; - queue_t *q; - seq_timer_t *tmr; + struct snd_seq_queue *q; + struct snd_seq_timer *tmr; for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) { if ((q = queueptr(i)) == NULL) diff --git a/sound/core/seq/seq_queue.h b/sound/core/seq/seq_queue.h index ea3c542..8884385 100644 --- a/sound/core/seq/seq_queue.h +++ b/sound/core/seq/seq_queue.h @@ -30,15 +30,15 @@ #define SEQ_QUEUE_NO_OWNER (-1) -struct _snd_seq_queue { +struct snd_seq_queue { int queue; /* queue number */ char name[64]; /* name of this queue */ - prioq_t *tickq; /* midi tick event queue */ - prioq_t *timeq; /* real-time event queue */ + struct snd_seq_prioq *tickq; /* midi tick event queue */ + struct snd_seq_prioq *timeq; /* real-time event queue */ - seq_timer_t *timer; /* time keeper for this queue */ + struct snd_seq_timer *timer; /* time keeper for this queue */ int owner; /* client that 'owns' the timer */ unsigned int locked:1, /* timer is only accesibble by owner if set */ klocked:1, /* kernel lock (after START) */ @@ -83,26 +83,26 @@ void snd_seq_queue_client_termination(int client); void snd_seq_queue_client_leave(int client); /* enqueue a event received from one the clients */ -int snd_seq_enqueue_event(snd_seq_event_cell_t *cell, int atomic, int hop); +int snd_seq_enqueue_event(struct snd_seq_event_cell *cell, int atomic, int hop); /* Remove events */ void snd_seq_queue_client_leave_cells(int client); -void snd_seq_queue_remove_cells(int client, snd_seq_remove_events_t *info); +void snd_seq_queue_remove_cells(int client, struct snd_seq_remove_events *info); /* return pointer to queue structure for specified id */ -queue_t *queueptr(int queueid); +struct snd_seq_queue *queueptr(int queueid); /* unlock */ #define queuefree(q) snd_use_lock_free(&(q)->use_lock) /* return the (first) queue matching with the specified name */ -queue_t *snd_seq_queue_find_name(char *name); +struct snd_seq_queue *snd_seq_queue_find_name(char *name); /* check single queue and dispatch events */ -void snd_seq_check_queue(queue_t *q, int atomic, int hop); +void snd_seq_check_queue(struct snd_seq_queue *q, int atomic, int hop); /* access to queue's parameters */ int snd_seq_queue_check_access(int queueid, int client); -int snd_seq_queue_timer_set_tempo(int queueid, int client, snd_seq_queue_tempo_t *info); +int snd_seq_queue_timer_set_tempo(int queueid, int client, struct snd_seq_queue_tempo *info); int snd_seq_queue_set_owner(int queueid, int client, int locked); int snd_seq_queue_set_locked(int queueid, int client, int locked); int snd_seq_queue_timer_open(int queueid); @@ -110,7 +110,7 @@ int snd_seq_queue_timer_close(int queueid); int snd_seq_queue_use(int queueid, int client, int use); int snd_seq_queue_is_used(int queueid, int client); -int snd_seq_control_queue(snd_seq_event_t *ev, int atomic, int hop); +int snd_seq_control_queue(struct snd_seq_event *ev, int atomic, int hop); /* * 64bit division - for sync stuff.. diff --git a/sound/core/seq/seq_system.c b/sound/core/seq/seq_system.c index 0d9eff8..86b1cba 100644 --- a/sound/core/seq/seq_system.c +++ b/sound/core/seq/seq_system.c @@ -66,12 +66,12 @@ static int announce_port = -1; /* fill standard header data, source port & channel are filled in */ -static int setheader(snd_seq_event_t * ev, int client, int port) +static int setheader(struct snd_seq_event * ev, int client, int port) { if (announce_port < 0) return -ENODEV; - memset(ev, 0, sizeof(snd_seq_event_t)); + memset(ev, 0, sizeof(struct snd_seq_event)); ev->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK; ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED; @@ -92,7 +92,7 @@ static int setheader(snd_seq_event_t * ev, int client, int port) /* entry points for broadcasting system events */ void snd_seq_system_broadcast(int client, int port, int type) { - snd_seq_event_t ev; + struct snd_seq_event ev; if (setheader(&ev, client, port) < 0) return; @@ -101,7 +101,7 @@ void snd_seq_system_broadcast(int client, int port, int type) } /* entry points for broadcasting system events */ -int snd_seq_system_notify(int client, int port, snd_seq_event_t *ev) +int snd_seq_system_notify(int client, int port, struct snd_seq_event *ev) { ev->flags = SNDRV_SEQ_EVENT_LENGTH_FIXED; ev->source.client = sysclient; @@ -112,7 +112,7 @@ int snd_seq_system_notify(int client, int port, snd_seq_event_t *ev) } /* call-back handler for timer events */ -static int event_input_timer(snd_seq_event_t * ev, int direct, void *private_data, int atomic, int hop) +static int event_input_timer(struct snd_seq_event * ev, int direct, void *private_data, int atomic, int hop) { return snd_seq_control_queue(ev, atomic, hop); } @@ -121,10 +121,10 @@ static int event_input_timer(snd_seq_event_t * ev, int direct, void *private_dat int __init snd_seq_system_client_init(void) { - snd_seq_client_callback_t callbacks; - snd_seq_port_callback_t pcallbacks; - snd_seq_client_info_t *inf; - snd_seq_port_info_t *port; + struct snd_seq_client_callback callbacks; + struct snd_seq_port_callback pcallbacks; + struct snd_seq_client_info *inf; + struct snd_seq_port_info *port; inf = kzalloc(sizeof(*inf), GFP_KERNEL); port = kzalloc(sizeof(*port), GFP_KERNEL); diff --git a/sound/core/seq/seq_system.h b/sound/core/seq/seq_system.h index 9000072..cf2cfa2 100644 --- a/sound/core/seq/seq_system.h +++ b/sound/core/seq/seq_system.h @@ -34,7 +34,7 @@ void snd_seq_system_broadcast(int client, int port, int type); #define snd_seq_system_client_ev_port_exit(client, port) snd_seq_system_broadcast(client, port, SNDRV_SEQ_EVENT_PORT_EXIT) #define snd_seq_system_client_ev_port_change(client, port) snd_seq_system_broadcast(client, port, SNDRV_SEQ_EVENT_PORT_CHANGE) -int snd_seq_system_notify(int client, int port, snd_seq_event_t *ev); +int snd_seq_system_notify(int client, int port, struct snd_seq_event *ev); /* register our internal client */ int snd_seq_system_client_init(void); diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c index 65b64a7..a1d8bfd 100644 --- a/sound/core/seq/seq_timer.c +++ b/sound/core/seq/seq_timer.c @@ -41,7 +41,7 @@ extern int seq_default_timer_resolution; #define SKEW_BASE 0x10000 /* 16bit shift */ -static void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick, +static void snd_seq_timer_set_tick_resolution(struct snd_seq_timer_tick *tick, int tempo, int ppq) { if (tempo < 1000000) @@ -60,9 +60,9 @@ static void snd_seq_timer_set_tick_resolution(seq_timer_tick_t *tick, } /* create new timer (constructor) */ -seq_timer_t *snd_seq_timer_new(void) +struct snd_seq_timer *snd_seq_timer_new(void) { - seq_timer_t *tmr; + struct snd_seq_timer *tmr; tmr = kzalloc(sizeof(*tmr), GFP_KERNEL); if (tmr == NULL) { @@ -81,9 +81,9 @@ seq_timer_t *snd_seq_timer_new(void) } /* delete timer (destructor) */ -void snd_seq_timer_delete(seq_timer_t **tmr) +void snd_seq_timer_delete(struct snd_seq_timer **tmr) { - seq_timer_t *t = *tmr; + struct snd_seq_timer *t = *tmr; *tmr = NULL; if (t == NULL) { @@ -99,7 +99,7 @@ void snd_seq_timer_delete(seq_timer_t **tmr) kfree(t); } -void snd_seq_timer_defaults(seq_timer_t * tmr) +void snd_seq_timer_defaults(struct snd_seq_timer * tmr) { /* setup defaults */ tmr->ppq = 96; /* 96 PPQ */ @@ -118,7 +118,7 @@ void snd_seq_timer_defaults(seq_timer_t * tmr) tmr->skew = tmr->skew_base = SKEW_BASE; } -void snd_seq_timer_reset(seq_timer_t * tmr) +void snd_seq_timer_reset(struct snd_seq_timer * tmr) { unsigned long flags; @@ -136,13 +136,13 @@ void snd_seq_timer_reset(seq_timer_t * tmr) /* called by timer interrupt routine. the period time since previous invocation is passed */ -static void snd_seq_timer_interrupt(snd_timer_instance_t *timeri, +static void snd_seq_timer_interrupt(struct snd_timer_instance *timeri, unsigned long resolution, unsigned long ticks) { unsigned long flags; - queue_t *q = (queue_t *)timeri->callback_data; - seq_timer_t *tmr; + struct snd_seq_queue *q = timeri->callback_data; + struct snd_seq_timer *tmr; if (q == NULL) return; @@ -177,7 +177,7 @@ static void snd_seq_timer_interrupt(snd_timer_instance_t *timeri, } /* set current tempo */ -int snd_seq_timer_set_tempo(seq_timer_t * tmr, int tempo) +int snd_seq_timer_set_tempo(struct snd_seq_timer * tmr, int tempo) { unsigned long flags; @@ -194,7 +194,7 @@ int snd_seq_timer_set_tempo(seq_timer_t * tmr, int tempo) } /* set current ppq */ -int snd_seq_timer_set_ppq(seq_timer_t * tmr, int ppq) +int snd_seq_timer_set_ppq(struct snd_seq_timer * tmr, int ppq) { unsigned long flags; @@ -217,7 +217,8 @@ int snd_seq_timer_set_ppq(seq_timer_t * tmr, int ppq) } /* set current tick position */ -int snd_seq_timer_set_position_tick(seq_timer_t *tmr, snd_seq_tick_time_t position) +int snd_seq_timer_set_position_tick(struct snd_seq_timer *tmr, + snd_seq_tick_time_t position) { unsigned long flags; @@ -231,7 +232,8 @@ int snd_seq_timer_set_position_tick(seq_timer_t *tmr, snd_seq_tick_time_t positi } /* set current real-time position */ -int snd_seq_timer_set_position_time(seq_timer_t *tmr, snd_seq_real_time_t position) +int snd_seq_timer_set_position_time(struct snd_seq_timer *tmr, + snd_seq_real_time_t position) { unsigned long flags; @@ -245,7 +247,8 @@ int snd_seq_timer_set_position_time(seq_timer_t *tmr, snd_seq_real_time_t positi } /* set timer skew */ -int snd_seq_timer_set_skew(seq_timer_t *tmr, unsigned int skew, unsigned int base) +int snd_seq_timer_set_skew(struct snd_seq_timer *tmr, unsigned int skew, + unsigned int base) { unsigned long flags; @@ -262,10 +265,10 @@ int snd_seq_timer_set_skew(seq_timer_t *tmr, unsigned int skew, unsigned int bas return 0; } -int snd_seq_timer_open(queue_t *q) +int snd_seq_timer_open(struct snd_seq_queue *q) { - snd_timer_instance_t *t; - seq_timer_t *tmr; + struct snd_timer_instance *t; + struct snd_seq_timer *tmr; char str[32]; int err; @@ -282,7 +285,7 @@ int snd_seq_timer_open(queue_t *q) if (err < 0 && tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_SLAVE) { if (tmr->alsa_id.dev_class != SNDRV_TIMER_CLASS_GLOBAL || tmr->alsa_id.device != SNDRV_TIMER_GLOBAL_SYSTEM) { - snd_timer_id_t tid; + struct snd_timer_id tid; memset(&tid, 0, sizeof(tid)); tid.dev_class = SNDRV_TIMER_CLASS_GLOBAL; tid.dev_sclass = SNDRV_TIMER_SCLASS_SEQUENCER; @@ -302,9 +305,9 @@ int snd_seq_timer_open(queue_t *q) return 0; } -int snd_seq_timer_close(queue_t *q) +int snd_seq_timer_close(struct snd_seq_queue *q) { - seq_timer_t *tmr; + struct snd_seq_timer *tmr; tmr = q->timer; snd_assert(tmr != NULL, return -EINVAL); @@ -316,7 +319,7 @@ int snd_seq_timer_close(queue_t *q) return 0; } -int snd_seq_timer_stop(seq_timer_t * tmr) +int snd_seq_timer_stop(struct snd_seq_timer * tmr) { if (! tmr->timeri) return -EINVAL; @@ -327,9 +330,9 @@ int snd_seq_timer_stop(seq_timer_t * tmr) return 0; } -static int initialize_timer(seq_timer_t *tmr) +static int initialize_timer(struct snd_seq_timer *tmr) { - snd_timer_t *t; + struct snd_timer *t; unsigned long freq; t = tmr->timeri->timer; @@ -358,7 +361,7 @@ static int initialize_timer(seq_timer_t *tmr) return 0; } -int snd_seq_timer_start(seq_timer_t * tmr) +int snd_seq_timer_start(struct snd_seq_timer * tmr) { if (! tmr->timeri) return -EINVAL; @@ -373,7 +376,7 @@ int snd_seq_timer_start(seq_timer_t * tmr) return 0; } -int snd_seq_timer_continue(seq_timer_t * tmr) +int snd_seq_timer_continue(struct snd_seq_timer * tmr) { if (! tmr->timeri) return -EINVAL; @@ -391,7 +394,7 @@ int snd_seq_timer_continue(seq_timer_t * tmr) } /* return current 'real' time. use timeofday() to get better granularity. */ -snd_seq_real_time_t snd_seq_timer_get_cur_time(seq_timer_t *tmr) +snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr) { snd_seq_real_time_t cur_time; @@ -416,19 +419,20 @@ snd_seq_real_time_t snd_seq_timer_get_cur_time(seq_timer_t *tmr) /* TODO: use interpolation on tick queue (will only be useful for very high PPQ values) */ -snd_seq_tick_time_t snd_seq_timer_get_cur_tick(seq_timer_t *tmr) +snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr) { return tmr->tick.cur_tick; } /* exported to seq_info.c */ -void snd_seq_info_timer_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +void snd_seq_info_timer_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int idx; - queue_t *q; - seq_timer_t *tmr; - snd_timer_instance_t *ti; + struct snd_seq_queue *q; + struct snd_seq_timer *tmr; + struct snd_timer_instance *ti; unsigned long resolution; for (idx = 0; idx < SNDRV_SEQ_MAX_QUEUES; idx++) { diff --git a/sound/core/seq/seq_timer.h b/sound/core/seq/seq_timer.h index 287ed68..e9ee154 100644 --- a/sound/core/seq/seq_timer.h +++ b/sound/core/seq/seq_timer.h @@ -24,13 +24,13 @@ #include <sound/timer.h> #include <sound/seq_kernel.h> -typedef struct { +struct snd_seq_timer_tick { snd_seq_tick_time_t cur_tick; /* current tick */ unsigned long resolution; /* time per tick in nsec */ unsigned long fraction; /* current time per tick in nsec */ -} seq_timer_tick_t; +}; -typedef struct { +struct snd_seq_timer { /* ... tempo / offset / running state */ unsigned int running:1, /* running state of queue */ @@ -40,12 +40,12 @@ typedef struct { int ppq; /* time resolution, ticks/quarter */ snd_seq_real_time_t cur_time; /* current time */ - seq_timer_tick_t tick; /* current tick */ + struct snd_seq_timer_tick tick; /* current tick */ int tick_updated; int type; /* timer type */ - snd_timer_id_t alsa_id; /* ALSA's timer ID */ - snd_timer_instance_t *timeri; /* timer instance */ + struct snd_timer_id alsa_id; /* ALSA's timer ID */ + struct snd_timer_instance *timeri; /* timer instance */ unsigned int ticks; unsigned long preferred_resolution; /* timer resolution, ticks/sec */ @@ -55,17 +55,18 @@ typedef struct { struct timeval last_update; /* time of last clock update, used for interpolation */ spinlock_t lock; -} seq_timer_t; +}; /* create new timer (constructor) */ -extern seq_timer_t *snd_seq_timer_new(void); +struct snd_seq_timer *snd_seq_timer_new(void); /* delete timer (destructor) */ -extern void snd_seq_timer_delete(seq_timer_t **tmr); +void snd_seq_timer_delete(struct snd_seq_timer **tmr); /* */ -static inline void snd_seq_timer_update_tick(seq_timer_tick_t *tick, unsigned long resolution) +static inline void snd_seq_timer_update_tick(struct snd_seq_timer_tick *tick, + unsigned long resolution) { if (tick->resolution > 0) { tick->fraction += resolution; @@ -119,21 +120,22 @@ static inline void snd_seq_inc_time_nsec(snd_seq_real_time_t *tm, unsigned long } /* called by timer isr */ -int snd_seq_timer_open(queue_t *q); -int snd_seq_timer_close(queue_t *q); -int snd_seq_timer_midi_open(queue_t *q); -int snd_seq_timer_midi_close(queue_t *q); -void snd_seq_timer_defaults(seq_timer_t *tmr); -void snd_seq_timer_reset(seq_timer_t *tmr); -int snd_seq_timer_stop(seq_timer_t *tmr); -int snd_seq_timer_start(seq_timer_t *tmr); -int snd_seq_timer_continue(seq_timer_t *tmr); -int snd_seq_timer_set_tempo(seq_timer_t *tmr, int tempo); -int snd_seq_timer_set_ppq(seq_timer_t *tmr, int ppq); -int snd_seq_timer_set_position_tick(seq_timer_t *tmr, snd_seq_tick_time_t position); -int snd_seq_timer_set_position_time(seq_timer_t *tmr, snd_seq_real_time_t position); -int snd_seq_timer_set_skew(seq_timer_t *tmr, unsigned int skew, unsigned int base); -snd_seq_real_time_t snd_seq_timer_get_cur_time(seq_timer_t *tmr); -snd_seq_tick_time_t snd_seq_timer_get_cur_tick(seq_timer_t *tmr); +struct snd_seq_queue; +int snd_seq_timer_open(struct snd_seq_queue *q); +int snd_seq_timer_close(struct snd_seq_queue *q); +int snd_seq_timer_midi_open(struct snd_seq_queue *q); +int snd_seq_timer_midi_close(struct snd_seq_queue *q); +void snd_seq_timer_defaults(struct snd_seq_timer *tmr); +void snd_seq_timer_reset(struct snd_seq_timer *tmr); +int snd_seq_timer_stop(struct snd_seq_timer *tmr); +int snd_seq_timer_start(struct snd_seq_timer *tmr); +int snd_seq_timer_continue(struct snd_seq_timer *tmr); +int snd_seq_timer_set_tempo(struct snd_seq_timer *tmr, int tempo); +int snd_seq_timer_set_ppq(struct snd_seq_timer *tmr, int ppq); +int snd_seq_timer_set_position_tick(struct snd_seq_timer *tmr, snd_seq_tick_time_t position); +int snd_seq_timer_set_position_time(struct snd_seq_timer *tmr, snd_seq_real_time_t position); +int snd_seq_timer_set_skew(struct snd_seq_timer *tmr, unsigned int skew, unsigned int base); +snd_seq_real_time_t snd_seq_timer_get_cur_time(struct snd_seq_timer *tmr); +snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr); #endif diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index e4f512a..ea21139 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -56,7 +56,8 @@ MODULE_LICENSE("GPL"); /* * initialize an event record */ -static void snd_virmidi_init_event(snd_virmidi_t *vmidi, snd_seq_event_t *ev) +static void snd_virmidi_init_event(struct snd_virmidi *vmidi, + struct snd_seq_event *ev) { memset(ev, 0, sizeof(*ev)); ev->source.port = vmidi->port; @@ -76,16 +77,17 @@ static void snd_virmidi_init_event(snd_virmidi_t *vmidi, snd_seq_event_t *ev) /* * decode input event and put to read buffer of each opened file */ -static int snd_virmidi_dev_receive_event(snd_virmidi_dev_t *rdev, snd_seq_event_t *ev) +static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev, + struct snd_seq_event *ev) { - snd_virmidi_t *vmidi; + struct snd_virmidi *vmidi; struct list_head *list; unsigned char msg[4]; int len; read_lock(&rdev->filelist_lock); list_for_each(list, &rdev->filelist) { - vmidi = list_entry(list, snd_virmidi_t, list); + vmidi = list_entry(list, struct snd_virmidi, list); if (!vmidi->trigger) continue; if (ev->type == SNDRV_SEQ_EVENT_SYSEX) { @@ -111,9 +113,9 @@ static int snd_virmidi_dev_receive_event(snd_virmidi_dev_t *rdev, snd_seq_event_ * SNDRV_VIRMIDI_SEQ_ATTACH. */ #if 0 -int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev) +int snd_virmidi_receive(struct snd_rawmidi *rmidi, struct snd_seq_event *ev) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = rmidi->private_data; return snd_virmidi_dev_receive_event(rdev, ev); @@ -123,10 +125,10 @@ int snd_virmidi_receive(snd_rawmidi_t *rmidi, snd_seq_event_t *ev) /* * event handler of virmidi port */ -static int snd_virmidi_event_input(snd_seq_event_t *ev, int direct, +static int snd_virmidi_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; if (!(rdev->flags & SNDRV_VIRMIDI_USE)) @@ -137,9 +139,9 @@ static int snd_virmidi_event_input(snd_seq_event_t *ev, int direct, /* * trigger rawmidi stream for input */ -static void snd_virmidi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_virmidi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - snd_virmidi_t *vmidi = substream->runtime->private_data; + struct snd_virmidi *vmidi = substream->runtime->private_data; if (up) { vmidi->trigger = 1; @@ -151,9 +153,9 @@ static void snd_virmidi_input_trigger(snd_rawmidi_substream_t * substream, int u /* * trigger rawmidi stream for output */ -static void snd_virmidi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_virmidi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - snd_virmidi_t *vmidi = substream->runtime->private_data; + struct snd_virmidi *vmidi = substream->runtime->private_data; int count, res; unsigned char buf[32], *pbuf; @@ -198,11 +200,11 @@ static void snd_virmidi_output_trigger(snd_rawmidi_substream_t * substream, int /* * open rawmidi handle for input */ -static int snd_virmidi_input_open(snd_rawmidi_substream_t * substream) +static int snd_virmidi_input_open(struct snd_rawmidi_substream *substream) { - snd_virmidi_dev_t *rdev = substream->rmidi->private_data; - snd_rawmidi_runtime_t *runtime = substream->runtime; - snd_virmidi_t *vmidi; + struct snd_virmidi_dev *rdev = substream->rmidi->private_data; + struct snd_rawmidi_runtime *runtime = substream->runtime; + struct snd_virmidi *vmidi; unsigned long flags; vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL); @@ -227,11 +229,11 @@ static int snd_virmidi_input_open(snd_rawmidi_substream_t * substream) /* * open rawmidi handle for output */ -static int snd_virmidi_output_open(snd_rawmidi_substream_t * substream) +static int snd_virmidi_output_open(struct snd_rawmidi_substream *substream) { - snd_virmidi_dev_t *rdev = substream->rmidi->private_data; - snd_rawmidi_runtime_t *runtime = substream->runtime; - snd_virmidi_t *vmidi; + struct snd_virmidi_dev *rdev = substream->rmidi->private_data; + struct snd_rawmidi_runtime *runtime = substream->runtime; + struct snd_virmidi *vmidi; vmidi = kzalloc(sizeof(*vmidi), GFP_KERNEL); if (vmidi == NULL) @@ -253,9 +255,9 @@ static int snd_virmidi_output_open(snd_rawmidi_substream_t * substream) /* * close rawmidi handle for input */ -static int snd_virmidi_input_close(snd_rawmidi_substream_t * substream) +static int snd_virmidi_input_close(struct snd_rawmidi_substream *substream) { - snd_virmidi_t *vmidi = substream->runtime->private_data; + struct snd_virmidi *vmidi = substream->runtime->private_data; snd_midi_event_free(vmidi->parser); list_del(&vmidi->list); substream->runtime->private_data = NULL; @@ -266,9 +268,9 @@ static int snd_virmidi_input_close(snd_rawmidi_substream_t * substream) /* * close rawmidi handle for output */ -static int snd_virmidi_output_close(snd_rawmidi_substream_t * substream) +static int snd_virmidi_output_close(struct snd_rawmidi_substream *substream) { - snd_virmidi_t *vmidi = substream->runtime->private_data; + struct snd_virmidi *vmidi = substream->runtime->private_data; snd_midi_event_free(vmidi->parser); substream->runtime->private_data = NULL; kfree(vmidi); @@ -278,9 +280,10 @@ static int snd_virmidi_output_close(snd_rawmidi_substream_t * substream) /* * subscribe callback - allow output to rawmidi device */ -static int snd_virmidi_subscribe(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_virmidi_subscribe(void *private_data, + struct snd_seq_port_subscribe *info) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; if (!try_module_get(rdev->card->module)) @@ -292,9 +295,10 @@ static int snd_virmidi_subscribe(void *private_data, snd_seq_port_subscribe_t *i /* * unsubscribe callback - disallow output to rawmidi device */ -static int snd_virmidi_unsubscribe(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_virmidi_unsubscribe(void *private_data, + struct snd_seq_port_subscribe *info) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; rdev->flags &= ~SNDRV_VIRMIDI_SUBSCRIBE; @@ -306,9 +310,10 @@ static int snd_virmidi_unsubscribe(void *private_data, snd_seq_port_subscribe_t /* * use callback - allow input to rawmidi device */ -static int snd_virmidi_use(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_virmidi_use(void *private_data, + struct snd_seq_port_subscribe *info) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; if (!try_module_get(rdev->card->module)) @@ -320,9 +325,10 @@ static int snd_virmidi_use(void *private_data, snd_seq_port_subscribe_t *info) /* * unuse callback - disallow input to rawmidi device */ -static int snd_virmidi_unuse(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_virmidi_unuse(void *private_data, + struct snd_seq_port_subscribe *info) { - snd_virmidi_dev_t *rdev; + struct snd_virmidi_dev *rdev; rdev = private_data; rdev->flags &= ~SNDRV_VIRMIDI_USE; @@ -335,13 +341,13 @@ static int snd_virmidi_unuse(void *private_data, snd_seq_port_subscribe_t *info) * Register functions */ -static snd_rawmidi_ops_t snd_virmidi_input_ops = { +static struct snd_rawmidi_ops snd_virmidi_input_ops = { .open = snd_virmidi_input_open, .close = snd_virmidi_input_close, .trigger = snd_virmidi_input_trigger, }; -static snd_rawmidi_ops_t snd_virmidi_output_ops = { +static struct snd_rawmidi_ops snd_virmidi_output_ops = { .open = snd_virmidi_output_open, .close = snd_virmidi_output_close, .trigger = snd_virmidi_output_trigger, @@ -350,13 +356,13 @@ static snd_rawmidi_ops_t snd_virmidi_output_ops = { /* * create a sequencer client and a port */ -static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev) +static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev) { int client; - snd_seq_client_callback_t callbacks; - snd_seq_port_callback_t pcallbacks; - snd_seq_client_info_t *info; - snd_seq_port_info_t *pinfo; + struct snd_seq_client_callback callbacks; + struct snd_seq_port_callback pcallbacks; + struct snd_seq_client_info *info; + struct snd_seq_port_info *pinfo; int err; if (rdev->client >= 0) @@ -426,7 +432,7 @@ static int snd_virmidi_dev_attach_seq(snd_virmidi_dev_t *rdev) /* * release the sequencer client */ -static void snd_virmidi_dev_detach_seq(snd_virmidi_dev_t *rdev) +static void snd_virmidi_dev_detach_seq(struct snd_virmidi_dev *rdev) { if (rdev->client >= 0) { snd_seq_delete_kernel_client(rdev->client); @@ -437,9 +443,9 @@ static void snd_virmidi_dev_detach_seq(snd_virmidi_dev_t *rdev) /* * register the device */ -static int snd_virmidi_dev_register(snd_rawmidi_t *rmidi) +static int snd_virmidi_dev_register(struct snd_rawmidi *rmidi) { - snd_virmidi_dev_t *rdev = rmidi->private_data; + struct snd_virmidi_dev *rdev = rmidi->private_data; int err; switch (rdev->seq_mode) { @@ -464,9 +470,9 @@ static int snd_virmidi_dev_register(snd_rawmidi_t *rmidi) /* * unregister the device */ -static int snd_virmidi_dev_unregister(snd_rawmidi_t *rmidi) +static int snd_virmidi_dev_unregister(struct snd_rawmidi *rmidi) { - snd_virmidi_dev_t *rdev = rmidi->private_data; + struct snd_virmidi_dev *rdev = rmidi->private_data; if (rdev->seq_mode == SNDRV_VIRMIDI_SEQ_DISPATCH) snd_virmidi_dev_detach_seq(rdev); @@ -476,7 +482,7 @@ static int snd_virmidi_dev_unregister(snd_rawmidi_t *rmidi) /* * */ -static snd_rawmidi_global_ops_t snd_virmidi_global_ops = { +static struct snd_rawmidi_global_ops snd_virmidi_global_ops = { .dev_register = snd_virmidi_dev_register, .dev_unregister = snd_virmidi_dev_unregister, }; @@ -484,9 +490,9 @@ static snd_rawmidi_global_ops_t snd_virmidi_global_ops = { /* * free device */ -static void snd_virmidi_free(snd_rawmidi_t *rmidi) +static void snd_virmidi_free(struct snd_rawmidi *rmidi) { - snd_virmidi_dev_t *rdev = rmidi->private_data; + struct snd_virmidi_dev *rdev = rmidi->private_data; kfree(rdev); } @@ -495,10 +501,10 @@ static void snd_virmidi_free(snd_rawmidi_t *rmidi) * */ /* exported */ -int snd_virmidi_new(snd_card_t *card, int device, snd_rawmidi_t **rrmidi) +int snd_virmidi_new(struct snd_card *card, int device, struct snd_rawmidi **rrmidi) { - snd_rawmidi_t *rmidi; - snd_virmidi_dev_t *rdev; + struct snd_rawmidi *rmidi; + struct snd_virmidi_dev *rdev; int err; *rrmidi = NULL; -- cgit v1.1 From 19ac31e82cc7328c01bf26f824f33c7c38cb6075 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:04:44 +0100 Subject: [ALSA] Remove xxx_t typedefs: Instrument layer Modules: Instrument layer Remove xxx_t typedefs from the core instrument layer codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/ainstr_fm.h | 28 ++++--- include/sound/ainstr_gf1.h | 46 ++++++----- include/sound/ainstr_iw.h | 115 ++++++++++++++------------- include/sound/ainstr_simple.h | 35 +++++---- sound/core/seq/instr/ainstr_fm.c | 26 +++---- sound/core/seq/instr/ainstr_gf1.c | 76 +++++++++--------- sound/core/seq/instr/ainstr_iw.c | 146 +++++++++++++++++------------------ sound/core/seq/instr/ainstr_simple.c | 50 ++++++------ 8 files changed, 272 insertions(+), 250 deletions(-) diff --git a/include/sound/ainstr_fm.h b/include/sound/ainstr_fm.h index 0ec0295..c4afb1f 100644 --- a/include/sound/ainstr_fm.h +++ b/include/sound/ainstr_fm.h @@ -39,13 +39,13 @@ * FM operator */ -typedef struct fm_operator { +struct fm_operator { unsigned char am_vib; unsigned char ksl_level; unsigned char attack_decay; unsigned char sustain_release; unsigned char wave_select; -} fm_operator_t; +}; /* * Instrument @@ -54,11 +54,11 @@ typedef struct fm_operator { #define FM_PATCH_OPL2 0x01 /* OPL2 2 operators FM instrument */ #define FM_PATCH_OPL3 0x02 /* OPL3 4 operators FM instrument */ -typedef struct { +struct fm_instrument { unsigned int share_id[4]; /* share id - zero = no sharing */ unsigned char type; /* instrument type */ - fm_operator_t op[4]; + struct fm_operator op[4]; unsigned char feedback_connection[2]; unsigned char echo_delay; @@ -68,7 +68,7 @@ typedef struct { unsigned char fix_dur; unsigned char modes; unsigned char fix_key; -} fm_instrument_t; +}; /* * @@ -88,25 +88,25 @@ typedef struct { * FM operator */ -typedef struct fm_xoperator { +struct fm_xoperator { __u8 am_vib; __u8 ksl_level; __u8 attack_decay; __u8 sustain_release; __u8 wave_select; -} fm_xoperator_t; +}; /* * Instrument */ -typedef struct fm_xinstrument { +struct fm_xinstrument { __u32 stype; /* structure type */ __u32 share_id[4]; /* share id - zero = no sharing */ __u8 type; /* instrument type */ - fm_xoperator_t op[4]; /* fm operators */ + struct fm_xoperator op[4]; /* fm operators */ __u8 feedback_connection[2]; __u8 echo_delay; @@ -116,15 +116,19 @@ typedef struct fm_xinstrument { __u8 fix_dur; __u8 modes; __u8 fix_key; -} fm_xinstrument_t; +}; #ifdef __KERNEL__ #include "seq_instr.h" -int snd_seq_fm_init(snd_seq_kinstr_ops_t * ops, - snd_seq_kinstr_ops_t * next); +int snd_seq_fm_init(struct snd_seq_kinstr_ops * ops, + struct snd_seq_kinstr_ops * next); #endif +/* typedefs for compatibility to user-space */ +typedef struct fm_xoperator fm_xoperator_t; +typedef struct fm_xinstrument fm_xinstrument_t; + #endif /* __SOUND_AINSTR_FM_H */ diff --git a/include/sound/ainstr_gf1.h b/include/sound/ainstr_gf1.h index ae2ddda..47726fe 100644 --- a/include/sound/ainstr_gf1.h +++ b/include/sound/ainstr_gf1.h @@ -52,7 +52,7 @@ * Wavetable definitions */ -typedef struct gf1_wave { +struct gf1_wave { unsigned int share_id[4]; /* share id - zero = no sharing */ unsigned int format; /* wave format */ @@ -88,7 +88,7 @@ typedef struct gf1_wave { unsigned short scale_factor; /* 0-2048 or 0-2 */ struct gf1_wave *next; -} gf1_wave_t; +}; /* * Instrument @@ -103,7 +103,7 @@ typedef struct gf1_wave { #define IWFFFF_EFFECT_CHORUS 2 #define IWFFFF_EFFECT_ECHO 3 -typedef struct { +struct gf1_instrument { unsigned short exclusion; unsigned short exclusion_group; /* 0 - none, 1-65535 */ @@ -112,8 +112,8 @@ typedef struct { unsigned char effect2; /* effect 2 */ unsigned char effect2_depth; /* 0-127 */ - gf1_wave_t *wave; /* first waveform */ -} gf1_instrument_t; + struct gf1_wave *wave; /* first waveform */ +}; /* * @@ -135,7 +135,7 @@ typedef struct { * Wavetable definitions */ -typedef struct gf1_xwave { +struct gf1_xwave { __u32 stype; /* structure type */ __u32 share_id[4]; /* share id - zero = no sharing */ @@ -165,13 +165,13 @@ typedef struct gf1_xwave { __u8 vibrato_depth; __u16 scale_frequency; __u16 scale_factor; /* 0-2048 or 0-2 */ -} gf1_xwave_t; +}; /* * Instrument */ -typedef struct gf1_xinstrument { +struct gf1_xinstrument { __u32 stype; __u16 exclusion; @@ -181,7 +181,7 @@ typedef struct gf1_xinstrument { __u8 effect1_depth; /* 0-127 */ __u8 effect2; /* effect 2 */ __u8 effect2_depth; /* 0-127 */ -} gf1_xinstrument_t; +}; /* * Instrument info @@ -191,35 +191,39 @@ typedef struct gf1_xinstrument { #define GF1_INFO_TREMOLO (1<<1) #define GF1_INFO_VIBRATO (1<<2) -typedef struct gf1_info { +struct gf1_info { unsigned char flags; /* supported wave flags */ unsigned char pad[3]; unsigned int features; /* supported features */ unsigned int max8_len; /* maximum 8-bit wave length */ unsigned int max16_len; /* maximum 16-bit wave length */ -} gf1_info_t; +}; #ifdef __KERNEL__ #include "seq_instr.h" -typedef struct { +struct snd_gf1_ops { void *private_data; - int (*info)(void *private_data, gf1_info_t *info); - int (*put_sample)(void *private_data, gf1_wave_t *wave, + int (*info)(void *private_data, struct gf1_info *info); + int (*put_sample)(void *private_data, struct gf1_wave *wave, char __user *data, long len, int atomic); - int (*get_sample)(void *private_data, gf1_wave_t *wave, + int (*get_sample)(void *private_data, struct gf1_wave *wave, char __user *data, long len, int atomic); - int (*remove_sample)(void *private_data, gf1_wave_t *wave, + int (*remove_sample)(void *private_data, struct gf1_wave *wave, int atomic); - void (*notify)(void *private_data, snd_seq_kinstr_t *instr, int what); - snd_seq_kinstr_ops_t kops; -} snd_gf1_ops_t; + void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what); + struct snd_seq_kinstr_ops kops; +}; -int snd_seq_gf1_init(snd_gf1_ops_t *ops, +int snd_seq_gf1_init(struct snd_gf1_ops *ops, void *private_data, - snd_seq_kinstr_ops_t *next); + struct snd_seq_kinstr_ops *next); #endif +/* typedefs for compatibility to user-space */ +typedef struct gf1_xwave gf1_xwave_t; +typedef struct gf1_xinstrument gf1_xinstrument_t; + #endif /* __SOUND_AINSTR_GF1_H */ diff --git a/include/sound/ainstr_iw.h b/include/sound/ainstr_iw.h index 8adf744..251feaf 100644 --- a/include/sound/ainstr_iw.h +++ b/include/sound/ainstr_iw.h @@ -54,7 +54,7 @@ * Wavetable definitions */ -typedef struct iwffff_wave { +struct iwffff_wave { unsigned int share_id[4]; /* share id - zero = no sharing */ unsigned int format; /* wave format */ @@ -76,7 +76,7 @@ typedef struct iwffff_wave { unsigned char pad; struct iwffff_wave *next; -} iwffff_wave_t; +}; /* * Layer @@ -85,13 +85,13 @@ typedef struct iwffff_wave { #define IWFFFF_LFO_SHAPE_TRIANGLE 0 #define IWFFFF_LFO_SHAPE_POSTRIANGLE 1 -typedef struct iwffff_lfo { +struct iwffff_lfo { unsigned short freq; /* (0-2047) 0.01Hz - 21.5Hz */ signed short depth; /* volume +- (0-255) 0.48675dB/step */ signed short sweep; /* 0 - 950 deciseconds */ unsigned char shape; /* see to IWFFFF_LFO_SHAPE_XXXX */ unsigned char delay; /* 0 - 255 deciseconds */ -} iwffff_lfo_t; +}; #define IWFFFF_ENV_FLAG_RETRIGGER 0x0001 /* flag - retrigger */ @@ -102,12 +102,12 @@ typedef struct iwffff_lfo { #define IWFFFF_ENV_INDEX_VELOCITY 0x0001 /* index - velocity */ #define IWFFFF_ENV_INDEX_FREQUENCY 0x0002 /* index - frequency */ -typedef struct iwffff_env_point { +struct iwffff_env_point { unsigned short offset; unsigned short rate; -} iwffff_env_point_t; +}; -typedef struct iwffff_env_record { +struct iwffff_env_record { unsigned short nattack; unsigned short nrelease; unsigned short sustain_offset; @@ -118,15 +118,15 @@ typedef struct iwffff_env_record { struct iwffff_env_record *next; /* points are stored here */ /* count of points = nattack + nrelease */ -} iwffff_env_record_t; +}; -typedef struct iwffff_env { +struct iwffff_env { unsigned char flags; unsigned char mode; unsigned char index; unsigned char pad; struct iwffff_env_record *record; -} iwffff_env_t; +}; #define IWFFFF_LAYER_FLAG_RETRIGGER 0x0001 /* retrigger */ @@ -138,7 +138,7 @@ typedef struct iwffff_env { #define IWFFFF_LAYER_EVENT_RETRIG 0x0002 /* layer event - retrigger */ #define IWFFFF_LAYER_EVENT_LEGATO 0x0003 /* layer event - legato */ -typedef struct iwffff_layer { +struct iwffff_layer { unsigned char flags; unsigned char velocity_mode; unsigned char layer_event; @@ -147,17 +147,17 @@ typedef struct iwffff_layer { unsigned char pan; /* pan offset from CC1 (0 left - 127 right) */ unsigned char pan_freq_scale; /* position based on frequency (0-127) */ unsigned char attenuation; /* 0-127 (no corresponding midi controller) */ - iwffff_lfo_t tremolo; /* tremolo effect */ - iwffff_lfo_t vibrato; /* vibrato effect */ + struct iwffff_lfo tremolo; /* tremolo effect */ + struct iwffff_lfo vibrato; /* vibrato effect */ unsigned short freq_scale; /* 0-2048, 1024 is equal to semitone scaling */ unsigned char freq_center; /* center for keyboard frequency scaling */ unsigned char pad; - iwffff_env_t penv; /* pitch envelope */ - iwffff_env_t venv; /* volume envelope */ + struct iwffff_env penv; /* pitch envelope */ + struct iwffff_env venv; /* volume envelope */ - iwffff_wave_t *wave; + struct iwffff_wave *wave; struct iwffff_layer *next; -} iwffff_layer_t; +}; /* * Instrument @@ -177,7 +177,7 @@ typedef struct iwffff_layer { #define IWFFFF_EFFECT_CHORUS 2 #define IWFFFF_EFFECT_ECHO 3 -typedef struct { +struct iwffff_instrument { unsigned short exclusion; unsigned short layer_type; unsigned short exclusion_group; /* 0 - none, 1-65535 */ @@ -187,8 +187,8 @@ typedef struct { unsigned char effect2; /* effect 2 */ unsigned char effect2_depth; /* 0-127 */ - iwffff_layer_t *layer; /* first layer */ -} iwffff_instrument_t; + struct iwffff_layer *layer; /* first layer */ +}; /* * @@ -216,7 +216,7 @@ typedef struct { * Wavetable definitions */ -typedef struct iwffff_xwave { +struct iwffff_xwave { __u32 stype; /* structure type */ __u32 share_id[4]; /* share id - zero = no sharing */ @@ -234,26 +234,26 @@ typedef struct iwffff_xwave { __u8 low_note; /* lower frequency range for this waveform */ __u8 high_note; /* higher frequency range for this waveform */ __u8 pad; -} iwffff_xwave_t; +}; /* * Layer */ -typedef struct iwffff_xlfo { +struct iwffff_xlfo { __u16 freq; /* (0-2047) 0.01Hz - 21.5Hz */ __s16 depth; /* volume +- (0-255) 0.48675dB/step */ __s16 sweep; /* 0 - 950 deciseconds */ __u8 shape; /* see to ULTRA_IW_LFO_SHAPE_XXXX */ __u8 delay; /* 0 - 255 deciseconds */ -} iwffff_xlfo_t; +}; -typedef struct iwffff_xenv_point { +struct iwffff_xenv_point { __u16 offset; __u16 rate; -} iwffff_xenv_point_t; +}; -typedef struct iwffff_xenv_record { +struct iwffff_xenv_record { __u32 stype; __u16 nattack; __u16 nrelease; @@ -264,16 +264,16 @@ typedef struct iwffff_xenv_record { __u8 pad; /* points are stored here.. */ /* count of points = nattack + nrelease */ -} iwffff_xenv_record_t; +}; -typedef struct iwffff_xenv { +struct iwffff_xenv { __u8 flags; __u8 mode; __u8 index; __u8 pad; -} iwffff_xenv_t; +}; -typedef struct iwffff_xlayer { +struct iwffff_xlayer { __u32 stype; __u8 flags; __u8 velocity_mode; @@ -283,20 +283,20 @@ typedef struct iwffff_xlayer { __u8 pan; /* pan offset from CC1 (0 left - 127 right) */ __u8 pan_freq_scale; /* position based on frequency (0-127) */ __u8 attenuation; /* 0-127 (no corresponding midi controller) */ - iwffff_xlfo_t tremolo; /* tremolo effect */ - iwffff_xlfo_t vibrato; /* vibrato effect */ + struct iwffff_xlfo tremolo; /* tremolo effect */ + struct iwffff_xlfo vibrato; /* vibrato effect */ __u16 freq_scale; /* 0-2048, 1024 is equal to semitone scaling */ __u8 freq_center; /* center for keyboard frequency scaling */ __u8 pad; - iwffff_xenv_t penv; /* pitch envelope */ - iwffff_xenv_t venv; /* volume envelope */ -} iwffff_xlayer_t; + struct iwffff_xenv penv; /* pitch envelope */ + struct iwffff_xenv venv; /* volume envelope */ +}; /* * Instrument */ -typedef struct iwffff_xinstrument { +struct iwffff_xinstrument { __u32 stype; __u16 exclusion; @@ -307,7 +307,7 @@ typedef struct iwffff_xinstrument { __u8 effect1_depth; /* 0-127 */ __u8 effect2; /* effect 2 */ __u8 effect2_depth; /* 0-127 */ -} iwffff_xinstrument_t; +}; /* * ROM support @@ -316,7 +316,7 @@ typedef struct iwffff_xinstrument { #define IWFFFF_ROM_HDR_SIZE 512 -typedef struct { +struct iwffff_rom_header { __u8 iwave[8]; __u8 revision; __u8 series_number; @@ -328,7 +328,7 @@ typedef struct { __u8 copyright[128]; __u8 vendor_name[64]; __u8 description[128]; -} iwffff_rom_header_t; +}; /* * Instrument info @@ -339,35 +339,46 @@ typedef struct { #define IWFFFF_INFO_LFO_TREMOLO (1<<2) #define IWFFFF_INFO_LFO_TREMOLO_SHAPE (1<<3) -typedef struct iwffff_info { +struct iwffff_info { unsigned int format; /* supported format bits */ unsigned int effects; /* supported effects (1 << IWFFFF_EFFECT*) */ unsigned int lfos; /* LFO effects */ unsigned int max8_len; /* maximum 8-bit wave length */ unsigned int max16_len; /* maximum 16-bit wave length */ -} iwffff_info_t; +}; #ifdef __KERNEL__ #include "seq_instr.h" -typedef struct { +struct snd_iwffff_ops { void *private_data; - int (*info)(void *private_data, iwffff_info_t *info); - int (*put_sample)(void *private_data, iwffff_wave_t *wave, + int (*info)(void *private_data, struct iwffff_info *info); + int (*put_sample)(void *private_data, struct iwffff_wave *wave, char __user *data, long len, int atomic); - int (*get_sample)(void *private_data, iwffff_wave_t *wave, + int (*get_sample)(void *private_data, struct iwffff_wave *wave, char __user *data, long len, int atomic); - int (*remove_sample)(void *private_data, iwffff_wave_t *wave, + int (*remove_sample)(void *private_data, struct iwffff_wave *wave, int atomic); - void (*notify)(void *private_data, snd_seq_kinstr_t *instr, int what); - snd_seq_kinstr_ops_t kops; -} snd_iwffff_ops_t; + void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what); + struct snd_seq_kinstr_ops kops; +}; -int snd_seq_iwffff_init(snd_iwffff_ops_t *ops, +int snd_seq_iwffff_init(struct snd_iwffff_ops *ops, void *private_data, - snd_seq_kinstr_ops_t *next); + struct snd_seq_kinstr_ops *next); #endif +/* typedefs for compatibility to user-space */ +typedef struct iwffff_xwave iwffff_xwave_t; +typedef struct iwffff_xlfo iwffff_xlfo_t; +typedef struct iwffff_xenv_point iwffff_xenv_point_t; +typedef struct iwffff_xenv_record iwffff_xenv_record_t; +typedef struct iwffff_xenv iwffff_xenv_t; +typedef struct iwffff_xlayer iwffff_xlayer_t; +typedef struct iwffff_xinstrument iwffff_xinstrument_t; +typedef struct iwffff_rom_header iwffff_rom_header_t; +typedef struct iwffff_info iwffff_info_t; + #endif /* __SOUND_AINSTR_IW_H */ diff --git a/include/sound/ainstr_simple.h b/include/sound/ainstr_simple.h index 40824b4..5eead12 100644 --- a/include/sound/ainstr_simple.h +++ b/include/sound/ainstr_simple.h @@ -61,18 +61,18 @@ * instrument info */ -typedef struct simple_instrument_info { +struct simple_instrument_info { unsigned int format; /* supported format bits */ unsigned int effects; /* supported effects (1 << SIMPLE_EFFECT_*) */ unsigned int max8_len; /* maximum 8-bit wave length */ unsigned int max16_len; /* maximum 16-bit wave length */ -} simple_instrument_info_t; +}; /* * Instrument */ -typedef struct { +struct simple_instrument { unsigned int share_id[4]; /* share id - zero = no sharing */ unsigned int format; /* wave format */ @@ -92,7 +92,7 @@ typedef struct { unsigned char effect1_depth; /* 0-127 */ unsigned char effect2; /* effect 2 */ unsigned char effect2_depth; /* 0-127 */ -} simple_instrument_t; +}; /* * @@ -112,7 +112,7 @@ typedef struct { * Instrument */ -typedef struct simple_xinstrument { +struct simple_xinstrument { __u32 stype; __u32 share_id[4]; /* share id - zero = no sharing */ @@ -128,29 +128,32 @@ typedef struct simple_xinstrument { __u8 effect1_depth; /* 0-127 */ __u8 effect2; /* effect 2 */ __u8 effect2_depth; /* 0-127 */ -} simple_xinstrument_t; +}; #ifdef __KERNEL__ #include "seq_instr.h" -typedef struct { +struct snd_simple_ops { void *private_data; - int (*info)(void *private_data, simple_instrument_info_t *info); - int (*put_sample)(void *private_data, simple_instrument_t *instr, + int (*info)(void *private_data, struct simple_instrument_info *info); + int (*put_sample)(void *private_data, struct simple_instrument *instr, char __user *data, long len, int atomic); - int (*get_sample)(void *private_data, simple_instrument_t *instr, + int (*get_sample)(void *private_data, struct simple_instrument *instr, char __user *data, long len, int atomic); - int (*remove_sample)(void *private_data, simple_instrument_t *instr, + int (*remove_sample)(void *private_data, struct simple_instrument *instr, int atomic); - void (*notify)(void *private_data, snd_seq_kinstr_t *instr, int what); - snd_seq_kinstr_ops_t kops; -} snd_simple_ops_t; + void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what); + struct snd_seq_kinstr_ops kops; +}; -int snd_seq_simple_init(snd_simple_ops_t *ops, +int snd_seq_simple_init(struct snd_simple_ops *ops, void *private_data, - snd_seq_kinstr_ops_t *next); + struct snd_seq_kinstr_ops *next); #endif +/* typedefs for compatibility to user-space */ +typedef struct simple_xinstrument simple_xinstrument_t; + #endif /* __SOUND_AINSTR_SIMPLE_H */ diff --git a/sound/core/seq/instr/ainstr_fm.c b/sound/core/seq/instr/ainstr_fm.c index 5c671e6..b09babf 100644 --- a/sound/core/seq/instr/ainstr_fm.c +++ b/sound/core/seq/instr/ainstr_fm.c @@ -30,11 +30,11 @@ MODULE_AUTHOR("Uros Bizjak <uros@kss-loka.si>"); MODULE_DESCRIPTION("Advanced Linux Sound Architecture FM Instrument support."); MODULE_LICENSE("GPL"); -static int snd_seq_fm_put(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_fm_put(void *private_data, struct snd_seq_kinstr *instr, char __user *instr_data, long len, int atomic, int cmd) { - fm_instrument_t *ip; - fm_xinstrument_t ix; + struct fm_instrument *ip; + struct fm_xinstrument ix; int idx; if (cmd != SNDRV_SEQ_INSTR_PUT_CMD_CREATE) @@ -46,7 +46,7 @@ static int snd_seq_fm_put(void *private_data, snd_seq_kinstr_t *instr, return -EFAULT; if (ix.stype != FM_STRU_INSTR) return -EINVAL; - ip = (fm_instrument_t *)KINSTR_DATA(instr); + ip = (struct fm_instrument *)KINSTR_DATA(instr); ip->share_id[0] = le32_to_cpu(ix.share_id[0]); ip->share_id[1] = le32_to_cpu(ix.share_id[1]); ip->share_id[2] = le32_to_cpu(ix.share_id[2]); @@ -72,12 +72,12 @@ static int snd_seq_fm_put(void *private_data, snd_seq_kinstr_t *instr, return 0; } -static int snd_seq_fm_get(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_fm_get(void *private_data, struct snd_seq_kinstr *instr, char __user *instr_data, long len, int atomic, int cmd) { - fm_instrument_t *ip; - fm_xinstrument_t ix; + struct fm_instrument *ip; + struct fm_xinstrument ix; int idx; if (cmd != SNDRV_SEQ_INSTR_GET_CMD_FULL) @@ -85,7 +85,7 @@ static int snd_seq_fm_get(void *private_data, snd_seq_kinstr_t *instr, if (len < (long)sizeof(ix)) return -ENOMEM; memset(&ix, 0, sizeof(ix)); - ip = (fm_instrument_t *)KINSTR_DATA(instr); + ip = (struct fm_instrument *)KINSTR_DATA(instr); ix.stype = FM_STRU_INSTR; ix.share_id[0] = cpu_to_le32(ip->share_id[0]); ix.share_id[1] = cpu_to_le32(ip->share_id[1]); @@ -114,19 +114,19 @@ static int snd_seq_fm_get(void *private_data, snd_seq_kinstr_t *instr, return 0; } -static int snd_seq_fm_get_size(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_fm_get_size(void *private_data, struct snd_seq_kinstr *instr, long *size) { - *size = sizeof(fm_xinstrument_t); + *size = sizeof(struct fm_xinstrument); return 0; } -int snd_seq_fm_init(snd_seq_kinstr_ops_t *ops, - snd_seq_kinstr_ops_t *next) +int snd_seq_fm_init(struct snd_seq_kinstr_ops *ops, + struct snd_seq_kinstr_ops *next) { memset(ops, 0, sizeof(*ops)); // ops->private_data = private_data; - ops->add_len = sizeof(fm_instrument_t); + ops->add_len = sizeof(struct fm_instrument); ops->instr_type = SNDRV_SEQ_INSTR_ID_OPL2_3; ops->put = snd_seq_fm_put; ops->get = snd_seq_fm_get; diff --git a/sound/core/seq/instr/ainstr_gf1.c b/sound/core/seq/instr/ainstr_gf1.c index 0e4df88..3c31038 100644 --- a/sound/core/seq/instr/ainstr_gf1.c +++ b/sound/core/seq/instr/ainstr_gf1.c @@ -42,14 +42,14 @@ static unsigned int snd_seq_gf1_size(unsigned int size, unsigned int format) return format; } -static int snd_seq_gf1_copy_wave_from_stream(snd_gf1_ops_t *ops, - gf1_instrument_t *ip, +static int snd_seq_gf1_copy_wave_from_stream(struct snd_gf1_ops *ops, + struct gf1_instrument *ip, char __user **data, long *len, int atomic) { - gf1_wave_t *wp, *prev; - gf1_xwave_t xp; + struct gf1_wave *wp, *prev; + struct gf1_xwave xp; int err; gfp_t gfp_mask; unsigned int real_size; @@ -116,8 +116,8 @@ static int snd_seq_gf1_copy_wave_from_stream(snd_gf1_ops_t *ops, return 0; } -static void snd_seq_gf1_wave_free(snd_gf1_ops_t *ops, - gf1_wave_t *wave, +static void snd_seq_gf1_wave_free(struct snd_gf1_ops *ops, + struct gf1_wave *wave, int atomic) { if (ops->remove_sample) @@ -125,11 +125,11 @@ static void snd_seq_gf1_wave_free(snd_gf1_ops_t *ops, kfree(wave); } -static void snd_seq_gf1_instr_free(snd_gf1_ops_t *ops, - gf1_instrument_t *ip, +static void snd_seq_gf1_instr_free(struct snd_gf1_ops *ops, + struct gf1_instrument *ip, int atomic) { - gf1_wave_t *wave; + struct gf1_wave *wave; while ((wave = ip->wave) != NULL) { ip->wave = wave->next; @@ -137,13 +137,13 @@ static void snd_seq_gf1_instr_free(snd_gf1_ops_t *ops, } } -static int snd_seq_gf1_put(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_gf1_put(void *private_data, struct snd_seq_kinstr *instr, char __user *instr_data, long len, int atomic, int cmd) { - snd_gf1_ops_t *ops = (snd_gf1_ops_t *)private_data; - gf1_instrument_t *ip; - gf1_xinstrument_t ix; + struct snd_gf1_ops *ops = private_data; + struct gf1_instrument *ip; + struct gf1_xinstrument ix; int err; gfp_t gfp_mask; @@ -159,7 +159,7 @@ static int snd_seq_gf1_put(void *private_data, snd_seq_kinstr_t *instr, return -EINVAL; instr_data += sizeof(ix); len -= sizeof(ix); - ip = (gf1_instrument_t *)KINSTR_DATA(instr); + ip = (struct gf1_instrument *)KINSTR_DATA(instr); ip->exclusion = le16_to_cpu(ix.exclusion); ip->exclusion_group = le16_to_cpu(ix.exclusion_group); ip->effect1 = ix.effect1; @@ -189,14 +189,14 @@ static int snd_seq_gf1_put(void *private_data, snd_seq_kinstr_t *instr, return 0; } -static int snd_seq_gf1_copy_wave_to_stream(snd_gf1_ops_t *ops, - gf1_instrument_t *ip, +static int snd_seq_gf1_copy_wave_to_stream(struct snd_gf1_ops *ops, + struct gf1_instrument *ip, char __user **data, long *len, int atomic) { - gf1_wave_t *wp; - gf1_xwave_t xp; + struct gf1_wave *wp; + struct gf1_xwave xp; int err; unsigned int real_size; @@ -251,20 +251,20 @@ static int snd_seq_gf1_copy_wave_to_stream(snd_gf1_ops_t *ops, return 0; } -static int snd_seq_gf1_get(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_gf1_get(void *private_data, struct snd_seq_kinstr *instr, char __user *instr_data, long len, int atomic, int cmd) { - snd_gf1_ops_t *ops = (snd_gf1_ops_t *)private_data; - gf1_instrument_t *ip; - gf1_xinstrument_t ix; + struct snd_gf1_ops *ops = private_data; + struct gf1_instrument *ip; + struct gf1_xinstrument ix; if (cmd != SNDRV_SEQ_INSTR_GET_CMD_FULL) return -EINVAL; if (len < (long)sizeof(ix)) return -ENOMEM; memset(&ix, 0, sizeof(ix)); - ip = (gf1_instrument_t *)KINSTR_DATA(instr); + ip = (struct gf1_instrument *)KINSTR_DATA(instr); ix.stype = GF1_STRU_INSTR; ix.exclusion = cpu_to_le16(ip->exclusion); ix.exclusion_group = cpu_to_le16(ip->exclusion_group); @@ -283,18 +283,18 @@ static int snd_seq_gf1_get(void *private_data, snd_seq_kinstr_t *instr, atomic); } -static int snd_seq_gf1_get_size(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_gf1_get_size(void *private_data, struct snd_seq_kinstr *instr, long *size) { long result; - gf1_instrument_t *ip; - gf1_wave_t *wp; + struct gf1_instrument *ip; + struct gf1_wave *wp; *size = 0; - ip = (gf1_instrument_t *)KINSTR_DATA(instr); - result = sizeof(gf1_xinstrument_t); + ip = (struct gf1_instrument *)KINSTR_DATA(instr); + result = sizeof(struct gf1_xinstrument); for (wp = ip->wave; wp; wp = wp->next) { - result += sizeof(gf1_xwave_t); + result += sizeof(struct gf1_xwave); result += wp->size; } *size = result; @@ -302,35 +302,35 @@ static int snd_seq_gf1_get_size(void *private_data, snd_seq_kinstr_t *instr, } static int snd_seq_gf1_remove(void *private_data, - snd_seq_kinstr_t *instr, + struct snd_seq_kinstr *instr, int atomic) { - snd_gf1_ops_t *ops = (snd_gf1_ops_t *)private_data; - gf1_instrument_t *ip; + struct snd_gf1_ops *ops = private_data; + struct gf1_instrument *ip; - ip = (gf1_instrument_t *)KINSTR_DATA(instr); + ip = (struct gf1_instrument *)KINSTR_DATA(instr); snd_seq_gf1_instr_free(ops, ip, atomic); return 0; } static void snd_seq_gf1_notify(void *private_data, - snd_seq_kinstr_t *instr, + struct snd_seq_kinstr *instr, int what) { - snd_gf1_ops_t *ops = (snd_gf1_ops_t *)private_data; + struct snd_gf1_ops *ops = private_data; if (ops->notify) ops->notify(ops->private_data, instr, what); } -int snd_seq_gf1_init(snd_gf1_ops_t *ops, +int snd_seq_gf1_init(struct snd_gf1_ops *ops, void *private_data, - snd_seq_kinstr_ops_t *next) + struct snd_seq_kinstr_ops *next) { memset(ops, 0, sizeof(*ops)); ops->private_data = private_data; ops->kops.private_data = ops; - ops->kops.add_len = sizeof(gf1_instrument_t); + ops->kops.add_len = sizeof(struct gf1_instrument); ops->kops.instr_type = SNDRV_SEQ_INSTR_ID_GUS_PATCH; ops->kops.put = snd_seq_gf1_put; ops->kops.get = snd_seq_gf1_get; diff --git a/sound/core/seq/instr/ainstr_iw.c b/sound/core/seq/instr/ainstr_iw.c index 7c19fbb..7f8df19 100644 --- a/sound/core/seq/instr/ainstr_iw.c +++ b/sound/core/seq/instr/ainstr_iw.c @@ -42,8 +42,8 @@ static unsigned int snd_seq_iwffff_size(unsigned int size, unsigned int format) return result; } -static void snd_seq_iwffff_copy_lfo_from_stream(iwffff_lfo_t *fp, - iwffff_xlfo_t *fx) +static void snd_seq_iwffff_copy_lfo_from_stream(struct iwffff_lfo *fp, + struct iwffff_xlfo *fx) { fp->freq = le16_to_cpu(fx->freq); fp->depth = le16_to_cpu(fx->depth); @@ -53,18 +53,18 @@ static void snd_seq_iwffff_copy_lfo_from_stream(iwffff_lfo_t *fp, } static int snd_seq_iwffff_copy_env_from_stream(__u32 req_stype, - iwffff_layer_t *lp, - iwffff_env_t *ep, - iwffff_xenv_t *ex, + struct iwffff_layer *lp, + struct iwffff_env *ep, + struct iwffff_xenv *ex, char __user **data, long *len, gfp_t gfp_mask) { __u32 stype; - iwffff_env_record_t *rp, *rp_last; - iwffff_xenv_record_t rx; - iwffff_env_point_t *pp; - iwffff_xenv_point_t px; + struct iwffff_env_record *rp, *rp_last; + struct iwffff_xenv_record rx; + struct iwffff_env_point *pp; + struct iwffff_xenv_point px; int points_size, idx; ep->flags = ex->flags; @@ -101,7 +101,7 @@ static int snd_seq_iwffff_copy_env_from_stream(__u32 req_stype, rp->sustain_rate = le16_to_cpu(rx.sustain_rate); rp->release_rate = le16_to_cpu(rx.release_rate); rp->hirange = rx.hirange; - pp = (iwffff_env_point_t *)(rp + 1); + pp = (struct iwffff_env_point *)(rp + 1); for (idx = 0; idx < rp->nattack + rp->nrelease; idx++) { if (copy_from_user(&px, *data, sizeof(px))) return -EFAULT; @@ -120,14 +120,14 @@ static int snd_seq_iwffff_copy_env_from_stream(__u32 req_stype, return 0; } -static int snd_seq_iwffff_copy_wave_from_stream(snd_iwffff_ops_t *ops, - iwffff_layer_t *lp, +static int snd_seq_iwffff_copy_wave_from_stream(struct snd_iwffff_ops *ops, + struct iwffff_layer *lp, char __user **data, long *len, int atomic) { - iwffff_wave_t *wp, *prev; - iwffff_xwave_t xp; + struct iwffff_wave *wp, *prev; + struct iwffff_xwave xp; int err; gfp_t gfp_mask; unsigned int real_size; @@ -186,11 +186,11 @@ static int snd_seq_iwffff_copy_wave_from_stream(snd_iwffff_ops_t *ops, return 0; } -static void snd_seq_iwffff_env_free(snd_iwffff_ops_t *ops, - iwffff_env_t *env, +static void snd_seq_iwffff_env_free(struct snd_iwffff_ops *ops, + struct iwffff_env *env, int atomic) { - iwffff_env_record_t *rec; + struct iwffff_env_record *rec; while ((rec = env->record) != NULL) { env->record = rec->next; @@ -198,8 +198,8 @@ static void snd_seq_iwffff_env_free(snd_iwffff_ops_t *ops, } } -static void snd_seq_iwffff_wave_free(snd_iwffff_ops_t *ops, - iwffff_wave_t *wave, +static void snd_seq_iwffff_wave_free(struct snd_iwffff_ops *ops, + struct iwffff_wave *wave, int atomic) { if (ops->remove_sample) @@ -207,12 +207,12 @@ static void snd_seq_iwffff_wave_free(snd_iwffff_ops_t *ops, kfree(wave); } -static void snd_seq_iwffff_instr_free(snd_iwffff_ops_t *ops, - iwffff_instrument_t *ip, +static void snd_seq_iwffff_instr_free(struct snd_iwffff_ops *ops, + struct iwffff_instrument *ip, int atomic) { - iwffff_layer_t *layer; - iwffff_wave_t *wave; + struct iwffff_layer *layer; + struct iwffff_wave *wave; while ((layer = ip->layer) != NULL) { ip->layer = layer->next; @@ -226,15 +226,15 @@ static void snd_seq_iwffff_instr_free(snd_iwffff_ops_t *ops, } } -static int snd_seq_iwffff_put(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_iwffff_put(void *private_data, struct snd_seq_kinstr *instr, char __user *instr_data, long len, int atomic, int cmd) { - snd_iwffff_ops_t *ops = (snd_iwffff_ops_t *)private_data; - iwffff_instrument_t *ip; - iwffff_xinstrument_t ix; - iwffff_layer_t *lp, *prev_lp; - iwffff_xlayer_t lx; + struct snd_iwffff_ops *ops = private_data; + struct iwffff_instrument *ip; + struct iwffff_xinstrument ix; + struct iwffff_layer *lp, *prev_lp; + struct iwffff_xlayer lx; int err; gfp_t gfp_mask; @@ -250,7 +250,7 @@ static int snd_seq_iwffff_put(void *private_data, snd_seq_kinstr_t *instr, return -EINVAL; instr_data += sizeof(ix); len -= sizeof(ix); - ip = (iwffff_instrument_t *)KINSTR_DATA(instr); + ip = (struct iwffff_instrument *)KINSTR_DATA(instr); ip->exclusion = le16_to_cpu(ix.exclusion); ip->layer_type = le16_to_cpu(ix.layer_type); ip->exclusion_group = le16_to_cpu(ix.exclusion_group); @@ -261,7 +261,7 @@ static int snd_seq_iwffff_put(void *private_data, snd_seq_kinstr_t *instr, /* copy layers */ prev_lp = NULL; while (len > 0) { - if (len < (long)sizeof(iwffff_xlayer_t)) { + if (len < (long)sizeof(struct iwffff_xlayer)) { snd_seq_iwffff_instr_free(ops, ip, atomic); return -EINVAL; } @@ -335,8 +335,8 @@ static int snd_seq_iwffff_put(void *private_data, snd_seq_kinstr_t *instr, return 0; } -static void snd_seq_iwffff_copy_lfo_to_stream(iwffff_xlfo_t *fx, - iwffff_lfo_t *fp) +static void snd_seq_iwffff_copy_lfo_to_stream(struct iwffff_xlfo *fx, + struct iwffff_lfo *fp) { fx->freq = cpu_to_le16(fp->freq); fx->depth = cpu_to_le16(fp->depth); @@ -346,16 +346,16 @@ static void snd_seq_iwffff_copy_lfo_to_stream(iwffff_xlfo_t *fx, } static int snd_seq_iwffff_copy_env_to_stream(__u32 req_stype, - iwffff_layer_t *lp, - iwffff_xenv_t *ex, - iwffff_env_t *ep, + struct iwffff_layer *lp, + struct iwffff_xenv *ex, + struct iwffff_env *ep, char __user **data, long *len) { - iwffff_env_record_t *rp; - iwffff_xenv_record_t rx; - iwffff_env_point_t *pp; - iwffff_xenv_point_t px; + struct iwffff_env_record *rp; + struct iwffff_xenv_record rx; + struct iwffff_env_point *pp; + struct iwffff_xenv_point px; int points_size, idx; ex->flags = ep->flags; @@ -379,7 +379,7 @@ static int snd_seq_iwffff_copy_env_to_stream(__u32 req_stype, points_size = (rp->nattack + rp->nrelease) * 2 * sizeof(__u16); if (*len < points_size) return -ENOMEM; - pp = (iwffff_env_point_t *)(rp + 1); + pp = (struct iwffff_env_point *)(rp + 1); for (idx = 0; idx < rp->nattack + rp->nrelease; idx++) { px.offset = cpu_to_le16(pp->offset); px.rate = cpu_to_le16(pp->rate); @@ -392,14 +392,14 @@ static int snd_seq_iwffff_copy_env_to_stream(__u32 req_stype, return 0; } -static int snd_seq_iwffff_copy_wave_to_stream(snd_iwffff_ops_t *ops, - iwffff_layer_t *lp, +static int snd_seq_iwffff_copy_wave_to_stream(struct snd_iwffff_ops *ops, + struct iwffff_layer *lp, char __user **data, long *len, int atomic) { - iwffff_wave_t *wp; - iwffff_xwave_t xp; + struct iwffff_wave *wp; + struct iwffff_xwave xp; int err; unsigned int real_size; @@ -447,14 +447,14 @@ static int snd_seq_iwffff_copy_wave_to_stream(snd_iwffff_ops_t *ops, return 0; } -static int snd_seq_iwffff_get(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_iwffff_get(void *private_data, struct snd_seq_kinstr *instr, char __user *instr_data, long len, int atomic, int cmd) { - snd_iwffff_ops_t *ops = (snd_iwffff_ops_t *)private_data; - iwffff_instrument_t *ip; - iwffff_xinstrument_t ix; - iwffff_layer_t *lp; - iwffff_xlayer_t lx; + struct snd_iwffff_ops *ops = private_data; + struct iwffff_instrument *ip; + struct iwffff_xinstrument ix; + struct iwffff_layer *lp; + struct iwffff_xlayer lx; char __user *layer_instr_data; int err; @@ -463,7 +463,7 @@ static int snd_seq_iwffff_get(void *private_data, snd_seq_kinstr_t *instr, if (len < (long)sizeof(ix)) return -ENOMEM; memset(&ix, 0, sizeof(ix)); - ip = (iwffff_instrument_t *)KINSTR_DATA(instr); + ip = (struct iwffff_instrument *)KINSTR_DATA(instr); ix.stype = IWFFFF_STRU_INSTR; ix.exclusion = cpu_to_le16(ip->exclusion); ix.layer_type = cpu_to_le16(ip->layer_type); @@ -520,43 +520,43 @@ static int snd_seq_iwffff_get(void *private_data, snd_seq_kinstr_t *instr, return 0; } -static long snd_seq_iwffff_env_size_in_stream(iwffff_env_t *ep) +static long snd_seq_iwffff_env_size_in_stream(struct iwffff_env *ep) { long result = 0; - iwffff_env_record_t *rp; + struct iwffff_env_record *rp; for (rp = ep->record; rp; rp = rp->next) { - result += sizeof(iwffff_xenv_record_t); + result += sizeof(struct iwffff_xenv_record); result += (rp->nattack + rp->nrelease) * 2 * sizeof(__u16); } return 0; } -static long snd_seq_iwffff_wave_size_in_stream(iwffff_layer_t *lp) +static long snd_seq_iwffff_wave_size_in_stream(struct iwffff_layer *lp) { long result = 0; - iwffff_wave_t *wp; + struct iwffff_wave *wp; for (wp = lp->wave; wp; wp = wp->next) { - result += sizeof(iwffff_xwave_t); + result += sizeof(struct iwffff_xwave); if (!(wp->format & IWFFFF_WAVE_ROM)) result += wp->size; } return result; } -static int snd_seq_iwffff_get_size(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_iwffff_get_size(void *private_data, struct snd_seq_kinstr *instr, long *size) { long result; - iwffff_instrument_t *ip; - iwffff_layer_t *lp; + struct iwffff_instrument *ip; + struct iwffff_layer *lp; *size = 0; - ip = (iwffff_instrument_t *)KINSTR_DATA(instr); - result = sizeof(iwffff_xinstrument_t); + ip = (struct iwffff_instrument *)KINSTR_DATA(instr); + result = sizeof(struct iwffff_xinstrument); for (lp = ip->layer; lp; lp = lp->next) { - result += sizeof(iwffff_xlayer_t); + result += sizeof(struct iwffff_xlayer); result += snd_seq_iwffff_env_size_in_stream(&lp->penv); result += snd_seq_iwffff_env_size_in_stream(&lp->venv); result += snd_seq_iwffff_wave_size_in_stream(lp); @@ -566,35 +566,35 @@ static int snd_seq_iwffff_get_size(void *private_data, snd_seq_kinstr_t *instr, } static int snd_seq_iwffff_remove(void *private_data, - snd_seq_kinstr_t *instr, + struct snd_seq_kinstr *instr, int atomic) { - snd_iwffff_ops_t *ops = (snd_iwffff_ops_t *)private_data; - iwffff_instrument_t *ip; + struct snd_iwffff_ops *ops = private_data; + struct iwffff_instrument *ip; - ip = (iwffff_instrument_t *)KINSTR_DATA(instr); + ip = (struct iwffff_instrument *)KINSTR_DATA(instr); snd_seq_iwffff_instr_free(ops, ip, atomic); return 0; } static void snd_seq_iwffff_notify(void *private_data, - snd_seq_kinstr_t *instr, + struct snd_seq_kinstr *instr, int what) { - snd_iwffff_ops_t *ops = (snd_iwffff_ops_t *)private_data; + struct snd_iwffff_ops *ops = private_data; if (ops->notify) ops->notify(ops->private_data, instr, what); } -int snd_seq_iwffff_init(snd_iwffff_ops_t *ops, +int snd_seq_iwffff_init(struct snd_iwffff_ops *ops, void *private_data, - snd_seq_kinstr_ops_t *next) + struct snd_seq_kinstr_ops *next) { memset(ops, 0, sizeof(*ops)); ops->private_data = private_data; ops->kops.private_data = ops; - ops->kops.add_len = sizeof(iwffff_instrument_t); + ops->kops.add_len = sizeof(struct iwffff_instrument); ops->kops.instr_type = SNDRV_SEQ_INSTR_ID_INTERWAVE; ops->kops.put = snd_seq_iwffff_put; ops->kops.get = snd_seq_iwffff_get; diff --git a/sound/core/seq/instr/ainstr_simple.c b/sound/core/seq/instr/ainstr_simple.c index 17ab94e..6d6ffec 100644 --- a/sound/core/seq/instr/ainstr_simple.c +++ b/sound/core/seq/instr/ainstr_simple.c @@ -42,21 +42,21 @@ static unsigned int snd_seq_simple_size(unsigned int size, unsigned int format) return result; } -static void snd_seq_simple_instr_free(snd_simple_ops_t *ops, - simple_instrument_t *ip, +static void snd_seq_simple_instr_free(struct snd_simple_ops *ops, + struct simple_instrument *ip, int atomic) { if (ops->remove_sample) ops->remove_sample(ops->private_data, ip, atomic); } -static int snd_seq_simple_put(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_simple_put(void *private_data, struct snd_seq_kinstr *instr, char __user *instr_data, long len, int atomic, int cmd) { - snd_simple_ops_t *ops = (snd_simple_ops_t *)private_data; - simple_instrument_t *ip; - simple_xinstrument_t ix; + struct snd_simple_ops *ops = private_data; + struct simple_instrument *ip; + struct simple_xinstrument ix; int err; gfp_t gfp_mask; unsigned int real_size; @@ -73,7 +73,7 @@ static int snd_seq_simple_put(void *private_data, snd_seq_kinstr_t *instr, return -EINVAL; instr_data += sizeof(ix); len -= sizeof(ix); - ip = (simple_instrument_t *)KINSTR_DATA(instr); + ip = (struct simple_instrument *)KINSTR_DATA(instr); ip->share_id[0] = le32_to_cpu(ix.share_id[0]); ip->share_id[1] = le32_to_cpu(ix.share_id[1]); ip->share_id[2] = le32_to_cpu(ix.share_id[2]); @@ -100,13 +100,13 @@ static int snd_seq_simple_put(void *private_data, snd_seq_kinstr_t *instr, return 0; } -static int snd_seq_simple_get(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_simple_get(void *private_data, struct snd_seq_kinstr *instr, char __user *instr_data, long len, int atomic, int cmd) { - snd_simple_ops_t *ops = (snd_simple_ops_t *)private_data; - simple_instrument_t *ip; - simple_xinstrument_t ix; + struct snd_simple_ops *ops = private_data; + struct simple_instrument *ip; + struct simple_xinstrument ix; int err; unsigned int real_size; @@ -115,7 +115,7 @@ static int snd_seq_simple_get(void *private_data, snd_seq_kinstr_t *instr, if (len < (long)sizeof(ix)) return -ENOMEM; memset(&ix, 0, sizeof(ix)); - ip = (simple_instrument_t *)KINSTR_DATA(instr); + ip = (struct simple_instrument *)KINSTR_DATA(instr); ix.stype = SIMPLE_STRU_INSTR; ix.share_id[0] = cpu_to_le32(ip->share_id[0]); ix.share_id[1] = cpu_to_le32(ip->share_id[1]); @@ -147,46 +147,46 @@ static int snd_seq_simple_get(void *private_data, snd_seq_kinstr_t *instr, return 0; } -static int snd_seq_simple_get_size(void *private_data, snd_seq_kinstr_t *instr, +static int snd_seq_simple_get_size(void *private_data, struct snd_seq_kinstr *instr, long *size) { - simple_instrument_t *ip; + struct simple_instrument *ip; - ip = (simple_instrument_t *)KINSTR_DATA(instr); - *size = sizeof(simple_xinstrument_t) + snd_seq_simple_size(ip->size, ip->format); + ip = (struct simple_instrument *)KINSTR_DATA(instr); + *size = sizeof(struct simple_xinstrument) + snd_seq_simple_size(ip->size, ip->format); return 0; } static int snd_seq_simple_remove(void *private_data, - snd_seq_kinstr_t *instr, + struct snd_seq_kinstr *instr, int atomic) { - snd_simple_ops_t *ops = (snd_simple_ops_t *)private_data; - simple_instrument_t *ip; + struct snd_simple_ops *ops = private_data; + struct simple_instrument *ip; - ip = (simple_instrument_t *)KINSTR_DATA(instr); + ip = (struct simple_instrument *)KINSTR_DATA(instr); snd_seq_simple_instr_free(ops, ip, atomic); return 0; } static void snd_seq_simple_notify(void *private_data, - snd_seq_kinstr_t *instr, + struct snd_seq_kinstr *instr, int what) { - snd_simple_ops_t *ops = (snd_simple_ops_t *)private_data; + struct snd_simple_ops *ops = private_data; if (ops->notify) ops->notify(ops->private_data, instr, what); } -int snd_seq_simple_init(snd_simple_ops_t *ops, +int snd_seq_simple_init(struct snd_simple_ops *ops, void *private_data, - snd_seq_kinstr_ops_t *next) + struct snd_seq_kinstr_ops *next) { memset(ops, 0, sizeof(*ops)); ops->private_data = private_data; ops->kops.private_data = ops; - ops->kops.add_len = sizeof(simple_instrument_t); + ops->kops.add_len = sizeof(struct simple_instrument); ops->kops.instr_type = SNDRV_SEQ_INSTR_ID_SIMPLE; ops->kops.put = snd_seq_simple_put; ops->kops.get = snd_seq_simple_get; -- cgit v1.1 From 080dece3460b534bedc4ef4ba3abaa57e9486331 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:05:16 +0100 Subject: [ALSA] Remove xxx_t typedefs: Sequencer OSS-emulation Modules: ALSA<-OSS sequencer,ALSA sequencer Remove xxx_t typedefs from the core sequencer OSS-emulation codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/seq_oss.h | 30 +++++------- sound/core/seq/oss/seq_oss.c | 24 +++++----- sound/core/seq/oss/seq_oss_device.h | 60 ++++++++++------------- sound/core/seq/oss/seq_oss_event.c | 60 +++++++++++------------ sound/core/seq/oss/seq_oss_event.h | 50 +++++++++---------- sound/core/seq/oss/seq_oss_init.c | 52 ++++++++++---------- sound/core/seq/oss/seq_oss_ioctl.c | 12 ++--- sound/core/seq/oss/seq_oss_midi.c | 96 ++++++++++++++++++------------------- sound/core/seq/oss/seq_oss_midi.h | 27 +++++------ sound/core/seq/oss/seq_oss_readq.c | 32 ++++++------- sound/core/seq/oss/seq_oss_readq.h | 24 +++++----- sound/core/seq/oss/seq_oss_rw.c | 18 +++---- sound/core/seq/oss/seq_oss_synth.c | 92 +++++++++++++++++------------------ sound/core/seq/oss/seq_oss_synth.h | 32 +++++++------ sound/core/seq/oss/seq_oss_timer.c | 34 ++++++------- sound/core/seq/oss/seq_oss_timer.h | 22 ++++----- sound/core/seq/oss/seq_oss_writeq.c | 34 ++++++------- sound/core/seq/oss/seq_oss_writeq.h | 18 +++---- 18 files changed, 352 insertions(+), 365 deletions(-) diff --git a/include/sound/seq_oss.h b/include/sound/seq_oss.h index bd7e573..9b060bb 100644 --- a/include/sound/seq_oss.h +++ b/include/sound/seq_oss.h @@ -25,22 +25,16 @@ #include "seq_kernel.h" /* - * type definitions - */ -typedef struct snd_seq_oss_arg_t snd_seq_oss_arg_t; -typedef struct snd_seq_oss_callback_t snd_seq_oss_callback_t; - -/* * argument structure for synthesizer operations */ -struct snd_seq_oss_arg_t { +struct snd_seq_oss_arg { /* given by OSS sequencer */ int app_index; /* application unique index */ int file_mode; /* file mode - see below */ int seq_mode; /* sequencer mode - see below */ /* following must be initialized in open callback */ - snd_seq_addr_t addr; /* opened port address */ + struct snd_seq_addr addr; /* opened port address */ void *private_data; /* private data for lowlevel drivers */ /* note-on event passing mode: initially given by OSS seq, @@ -53,14 +47,14 @@ struct snd_seq_oss_arg_t { /* * synthesizer operation callbacks */ -struct snd_seq_oss_callback_t { +struct snd_seq_oss_callback { struct module *owner; - int (*open)(snd_seq_oss_arg_t *p, void *closure); - int (*close)(snd_seq_oss_arg_t *p); - int (*ioctl)(snd_seq_oss_arg_t *p, unsigned int cmd, unsigned long arg); - int (*load_patch)(snd_seq_oss_arg_t *p, int format, const char __user *buf, int offs, int count); - int (*reset)(snd_seq_oss_arg_t *p); - int (*raw_event)(snd_seq_oss_arg_t *p, unsigned char *data); + int (*open)(struct snd_seq_oss_arg *p, void *closure); + int (*close)(struct snd_seq_oss_arg *p); + int (*ioctl)(struct snd_seq_oss_arg *p, unsigned int cmd, unsigned long arg); + int (*load_patch)(struct snd_seq_oss_arg *p, int format, const char __user *buf, int offs, int count); + int (*reset)(struct snd_seq_oss_arg *p); + int (*raw_event)(struct snd_seq_oss_arg *p, unsigned char *data); }; /* flag: file_mode */ @@ -88,13 +82,13 @@ struct snd_seq_oss_callback_t { /* * data pointer to snd_seq_register_device */ -typedef struct snd_seq_oss_reg { +struct snd_seq_oss_reg { int type; int subtype; int nvoices; - snd_seq_oss_callback_t oper; + struct snd_seq_oss_callback oper; void *private_data; -} snd_seq_oss_reg_t; +}; /* device id */ #define SNDRV_SEQ_DEV_ID_OSS "seq-oss" diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 4c0558c..2371e41 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c @@ -62,7 +62,7 @@ static ssize_t odev_write(struct file *file, const char __user *buf, size_t coun static long odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static unsigned int odev_poll(struct file *file, poll_table * wait); #ifdef CONFIG_PROC_FS -static void info_read(snd_info_entry_t *entry, snd_info_buffer_t *buf); +static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf); #endif @@ -73,7 +73,7 @@ static void info_read(snd_info_entry_t *entry, snd_info_buffer_t *buf); static int __init alsa_seq_oss_init(void) { int rc; - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_seq_oss_synth_register, snd_seq_oss_synth_unregister, }; @@ -92,7 +92,7 @@ static int __init alsa_seq_oss_init(void) } if ((rc = snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OSS, &ops, - sizeof(snd_seq_oss_reg_t))) < 0) { + sizeof(struct snd_seq_oss_reg))) < 0) { snd_seq_oss_delete_client(); unregister_proc(); unregister_device(); @@ -144,7 +144,7 @@ odev_open(struct inode *inode, struct file *file) static int odev_release(struct inode *inode, struct file *file) { - seq_oss_devinfo_t *dp; + struct seq_oss_devinfo *dp; if ((dp = file->private_data) == NULL) return 0; @@ -161,7 +161,7 @@ odev_release(struct inode *inode, struct file *file) static ssize_t odev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) { - seq_oss_devinfo_t *dp; + struct seq_oss_devinfo *dp; dp = file->private_data; snd_assert(dp != NULL, return -EIO); return snd_seq_oss_read(dp, buf, count); @@ -171,7 +171,7 @@ odev_read(struct file *file, char __user *buf, size_t count, loff_t *offset) static ssize_t odev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset) { - seq_oss_devinfo_t *dp; + struct seq_oss_devinfo *dp; dp = file->private_data; snd_assert(dp != NULL, return -EIO); return snd_seq_oss_write(dp, buf, count, file); @@ -180,7 +180,7 @@ odev_write(struct file *file, const char __user *buf, size_t count, loff_t *offs static long odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - seq_oss_devinfo_t *dp; + struct seq_oss_devinfo *dp; dp = file->private_data; snd_assert(dp != NULL, return -EIO); return snd_seq_oss_ioctl(dp, cmd, arg); @@ -195,7 +195,7 @@ odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static unsigned int odev_poll(struct file *file, poll_table * wait) { - seq_oss_devinfo_t *dp; + struct seq_oss_devinfo *dp; dp = file->private_data; snd_assert(dp != NULL, return 0); return snd_seq_oss_poll(dp, file, wait); @@ -217,7 +217,7 @@ static struct file_operations seq_oss_f_ops = .compat_ioctl = odev_ioctl_compat, }; -static snd_minor_t seq_oss_reg = { +static struct snd_minor seq_oss_reg = { .comment = "sequencer", .f_ops = &seq_oss_f_ops, }; @@ -268,10 +268,10 @@ unregister_device(void) #ifdef CONFIG_PROC_FS -static snd_info_entry_t *info_entry; +static struct snd_info_entry *info_entry; static void -info_read(snd_info_entry_t *entry, snd_info_buffer_t *buf) +info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) { down(®ister_mutex); snd_iprintf(buf, "OSS sequencer emulation version %s\n", SNDRV_SEQ_OSS_VERSION_STR); @@ -287,7 +287,7 @@ static int __init register_proc(void) { #ifdef CONFIG_PROC_FS - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = snd_info_create_module_entry(THIS_MODULE, SNDRV_SEQ_OSS_PROCNAME, snd_seq_root); if (entry == NULL) diff --git a/sound/core/seq/oss/seq_oss_device.h b/sound/core/seq/oss/seq_oss_device.h index 9737867..9a8567c 100644 --- a/sound/core/seq/oss/seq_oss_device.h +++ b/sound/core/seq/oss/seq_oss_device.h @@ -55,32 +55,24 @@ * type definitions */ -typedef struct seq_oss_devinfo_t seq_oss_devinfo_t; -typedef struct seq_oss_writeq_t seq_oss_writeq_t; -typedef struct seq_oss_readq_t seq_oss_readq_t; -typedef struct seq_oss_timer_t seq_oss_timer_t; -typedef struct seq_oss_synthinfo_t seq_oss_synthinfo_t; -typedef struct seq_oss_synth_sysex_t seq_oss_synth_sysex_t; -typedef struct seq_oss_chinfo_t seq_oss_chinfo_t; typedef unsigned int reltime_t; typedef unsigned int abstime_t; -typedef union evrec_t evrec_t; /* * synthesizer channel information */ -struct seq_oss_chinfo_t { +struct seq_oss_chinfo { int note, vel; }; /* * synthesizer information */ -struct seq_oss_synthinfo_t { - snd_seq_oss_arg_t arg; - seq_oss_chinfo_t *ch; - seq_oss_synth_sysex_t *sysex; +struct seq_oss_synthinfo { + struct snd_seq_oss_arg arg; + struct seq_oss_chinfo *ch; + struct seq_oss_synth_sysex *sysex; int nr_voices; int opened; int is_midi; @@ -92,14 +84,14 @@ struct seq_oss_synthinfo_t { * sequencer client information */ -struct seq_oss_devinfo_t { +struct seq_oss_devinfo { int index; /* application index */ int cseq; /* sequencer client number */ int port; /* sequencer port number */ int queue; /* sequencer queue number */ - snd_seq_addr_t addr; /* address of this device */ + struct snd_seq_addr addr; /* address of this device */ int seq_mode; /* sequencer mode */ int file_mode; /* file access */ @@ -109,17 +101,17 @@ struct seq_oss_devinfo_t { /* synth device table */ int max_synthdev; - seq_oss_synthinfo_t synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS]; + struct seq_oss_synthinfo synths[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS]; int synth_opened; /* output queue */ - seq_oss_writeq_t *writeq; + struct seq_oss_writeq *writeq; /* midi input queue */ - seq_oss_readq_t *readq; + struct seq_oss_readq *readq; /* timer */ - seq_oss_timer_t *timer; + struct seq_oss_timer *timer; }; @@ -133,24 +125,24 @@ int snd_seq_oss_delete_client(void); /* device file interface */ int snd_seq_oss_open(struct file *file, int level); -void snd_seq_oss_release(seq_oss_devinfo_t *dp); -int snd_seq_oss_ioctl(seq_oss_devinfo_t *dp, unsigned int cmd, unsigned long arg); -int snd_seq_oss_read(seq_oss_devinfo_t *dev, char __user *buf, int count); -int snd_seq_oss_write(seq_oss_devinfo_t *dp, const char __user *buf, int count, struct file *opt); -unsigned int snd_seq_oss_poll(seq_oss_devinfo_t *dp, struct file *file, poll_table * wait); +void snd_seq_oss_release(struct seq_oss_devinfo *dp); +int snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long arg); +int snd_seq_oss_read(struct seq_oss_devinfo *dev, char __user *buf, int count); +int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt); +unsigned int snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait); -void snd_seq_oss_reset(seq_oss_devinfo_t *dp); -void snd_seq_oss_drain_write(seq_oss_devinfo_t *dp); +void snd_seq_oss_reset(struct seq_oss_devinfo *dp); +void snd_seq_oss_drain_write(struct seq_oss_devinfo *dp); /* */ -void snd_seq_oss_process_queue(seq_oss_devinfo_t *dp, abstime_t time); +void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time); /* proc interface */ -void snd_seq_oss_system_info_read(snd_info_buffer_t *buf); -void snd_seq_oss_midi_info_read(snd_info_buffer_t *buf); -void snd_seq_oss_synth_info_read(snd_info_buffer_t *buf); -void snd_seq_oss_readq_info_read(seq_oss_readq_t *q, snd_info_buffer_t *buf); +void snd_seq_oss_system_info_read(struct snd_info_buffer *buf); +void snd_seq_oss_midi_info_read(struct snd_info_buffer *buf); +void snd_seq_oss_synth_info_read(struct snd_info_buffer *buf); +void snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf); /* file mode macros */ #define is_read_mode(mode) ((mode) & SNDRV_SEQ_OSS_FILE_READ) @@ -159,21 +151,21 @@ void snd_seq_oss_readq_info_read(seq_oss_readq_t *q, snd_info_buffer_t *buf); /* dispatch event */ static inline int -snd_seq_oss_dispatch(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, int atomic, int hop) +snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int atomic, int hop) { return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop); } /* ioctl */ static inline int -snd_seq_oss_control(seq_oss_devinfo_t *dp, unsigned int type, void *arg) +snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg) { return snd_seq_kernel_client_ctl(dp->cseq, type, arg); } /* fill the addresses in header */ static inline void -snd_seq_oss_fill_addr(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, +snd_seq_oss_fill_addr(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int dest_client, int dest_port) { ev->queue = dp->queue; diff --git a/sound/core/seq/oss/seq_oss_event.c b/sound/core/seq/oss/seq_oss_event.c index 58e52dd..066f5f3 100644 --- a/sound/core/seq/oss/seq_oss_event.c +++ b/sound/core/seq/oss/seq_oss_event.c @@ -31,17 +31,17 @@ /* * prototypes */ -static int extended_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev); -static int chn_voice_event(seq_oss_devinfo_t *dp, evrec_t *event_rec, snd_seq_event_t *ev); -static int chn_common_event(seq_oss_devinfo_t *dp, evrec_t *event_rec, snd_seq_event_t *ev); -static int timing_event(seq_oss_devinfo_t *dp, evrec_t *event_rec, snd_seq_event_t *ev); -static int local_event(seq_oss_devinfo_t *dp, evrec_t *event_rec, snd_seq_event_t *ev); -static int old_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev); -static int note_on_event(seq_oss_devinfo_t *dp, int dev, int ch, int note, int vel, snd_seq_event_t *ev); -static int note_off_event(seq_oss_devinfo_t *dp, int dev, int ch, int note, int vel, snd_seq_event_t *ev); -static int set_note_event(seq_oss_devinfo_t *dp, int dev, int type, int ch, int note, int vel, snd_seq_event_t *ev); -static int set_control_event(seq_oss_devinfo_t *dp, int dev, int type, int ch, int param, int val, snd_seq_event_t *ev); -static int set_echo_event(seq_oss_devinfo_t *dp, evrec_t *rec, snd_seq_event_t *ev); +static int extended_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev); +static int chn_voice_event(struct seq_oss_devinfo *dp, union evrec *event_rec, struct snd_seq_event *ev); +static int chn_common_event(struct seq_oss_devinfo *dp, union evrec *event_rec, struct snd_seq_event *ev); +static int timing_event(struct seq_oss_devinfo *dp, union evrec *event_rec, struct snd_seq_event *ev); +static int local_event(struct seq_oss_devinfo *dp, union evrec *event_rec, struct snd_seq_event *ev); +static int old_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev); +static int note_on_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, struct snd_seq_event *ev); +static int note_off_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, struct snd_seq_event *ev); +static int set_note_event(struct seq_oss_devinfo *dp, int dev, int type, int ch, int note, int vel, struct snd_seq_event *ev); +static int set_control_event(struct seq_oss_devinfo *dp, int dev, int type, int ch, int param, int val, struct snd_seq_event *ev); +static int set_echo_event(struct seq_oss_devinfo *dp, union evrec *rec, struct snd_seq_event *ev); /* @@ -51,7 +51,7 @@ static int set_echo_event(seq_oss_devinfo_t *dp, evrec_t *rec, snd_seq_event_t * */ int -snd_seq_oss_process_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) +snd_seq_oss_process_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev) { switch (q->s.code) { case SEQ_EXTENDED: @@ -104,7 +104,7 @@ snd_seq_oss_process_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev /* old type events: mode1 only */ static int -old_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) +old_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev) { switch (q->s.code) { case SEQ_NOTEOFF: @@ -130,7 +130,7 @@ old_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) /* 8bytes extended event: mode1 only */ static int -extended_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) +extended_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev) { int val; @@ -184,7 +184,7 @@ extended_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) /* channel voice events: mode1 and 2 */ static int -chn_voice_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) +chn_voice_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev) { if (q->v.chn >= 32) return -EINVAL; @@ -205,7 +205,7 @@ chn_voice_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) /* channel common events: mode1 and 2 */ static int -chn_common_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) +chn_common_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev) { if (q->l.chn >= 32) return -EINVAL; @@ -232,14 +232,14 @@ chn_common_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) /* timer events: mode1 and mode2 */ static int -timing_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) +timing_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev) { switch (q->t.cmd) { case TMR_ECHO: if (dp->seq_mode == SNDRV_SEQ_OSS_MODE_MUSIC) return set_echo_event(dp, q, ev); else { - evrec_t tmp; + union evrec tmp; memset(&tmp, 0, sizeof(tmp)); /* XXX: only for little-endian! */ tmp.echo = (q->t.time << 8) | SEQ_ECHO; @@ -267,7 +267,7 @@ timing_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) /* local events: mode1 and 2 */ static int -local_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) +local_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev) { return -EINVAL; } @@ -283,9 +283,9 @@ local_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev) * Use key-pressure if note >= 128 */ static int -note_on_event(seq_oss_devinfo_t *dp, int dev, int ch, int note, int vel, snd_seq_event_t *ev) +note_on_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, struct snd_seq_event *ev) { - seq_oss_synthinfo_t *info = &dp->synths[dev]; + struct seq_oss_synthinfo *info = &dp->synths[dev]; switch (info->arg.event_passing) { case SNDRV_SEQ_OSS_PROCESS_EVENTS: if (! info->ch || ch < 0 || ch >= info->nr_voices) { @@ -338,9 +338,9 @@ note_on_event(seq_oss_devinfo_t *dp, int dev, int ch, int note, int vel, snd_seq * process note-off event for OSS synth */ static int -note_off_event(seq_oss_devinfo_t *dp, int dev, int ch, int note, int vel, snd_seq_event_t *ev) +note_off_event(struct seq_oss_devinfo *dp, int dev, int ch, int note, int vel, struct snd_seq_event *ev) { - seq_oss_synthinfo_t *info = &dp->synths[dev]; + struct seq_oss_synthinfo *info = &dp->synths[dev]; switch (info->arg.event_passing) { case SNDRV_SEQ_OSS_PROCESS_EVENTS: if (! info->ch || ch < 0 || ch >= info->nr_voices) { @@ -369,7 +369,7 @@ note_off_event(seq_oss_devinfo_t *dp, int dev, int ch, int note, int vel, snd_se * create a note event */ static int -set_note_event(seq_oss_devinfo_t *dp, int dev, int type, int ch, int note, int vel, snd_seq_event_t *ev) +set_note_event(struct seq_oss_devinfo *dp, int dev, int type, int ch, int note, int vel, struct snd_seq_event *ev) { if (! snd_seq_oss_synth_is_valid(dp, dev)) return -ENXIO; @@ -387,7 +387,7 @@ set_note_event(seq_oss_devinfo_t *dp, int dev, int type, int ch, int note, int v * create a control event */ static int -set_control_event(seq_oss_devinfo_t *dp, int dev, int type, int ch, int param, int val, snd_seq_event_t *ev) +set_control_event(struct seq_oss_devinfo *dp, int dev, int type, int ch, int param, int val, struct snd_seq_event *ev) { if (! snd_seq_oss_synth_is_valid(dp, dev)) return -ENXIO; @@ -405,7 +405,7 @@ set_control_event(seq_oss_devinfo_t *dp, int dev, int type, int ch, int param, i * create an echo event */ static int -set_echo_event(seq_oss_devinfo_t *dp, evrec_t *rec, snd_seq_event_t *ev) +set_echo_event(struct seq_oss_devinfo *dp, union evrec *rec, struct snd_seq_event *ev) { ev->type = SNDRV_SEQ_EVENT_ECHO; /* echo back to itself */ @@ -419,11 +419,11 @@ set_echo_event(seq_oss_devinfo_t *dp, evrec_t *rec, snd_seq_event_t *ev) * the echo event is processed here. */ int -snd_seq_oss_event_input(snd_seq_event_t *ev, int direct, void *private_data, +snd_seq_oss_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - seq_oss_devinfo_t *dp = (seq_oss_devinfo_t *)private_data; - evrec_t *rec; + struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private_data; + union evrec *rec; if (ev->type != SNDRV_SEQ_EVENT_ECHO) return snd_seq_oss_midi_input(ev, direct, private_data); @@ -431,7 +431,7 @@ snd_seq_oss_event_input(snd_seq_event_t *ev, int direct, void *private_data, if (ev->source.client != dp->cseq) return 0; /* ignored */ - rec = (evrec_t*)&ev->data; + rec = (union evrec*)&ev->data; if (rec->s.code == SEQ_SYNCTIMER) { /* sync echo back */ snd_seq_oss_writeq_wakeup(dp->writeq, rec->t.time); diff --git a/sound/core/seq/oss/seq_oss_event.h b/sound/core/seq/oss/seq_oss_event.h index bf1d4d3..9a4d9ad 100644 --- a/sound/core/seq/oss/seq_oss_event.h +++ b/sound/core/seq/oss/seq_oss_event.h @@ -29,74 +29,74 @@ #define LONG_EVENT_SIZE 8 /* short event (4bytes) */ -typedef struct evrec_short_t { +struct evrec_short { unsigned char code; unsigned char parm1; unsigned char dev; unsigned char parm2; -} evrec_short_t; +}; /* short note events (4bytes) */ -typedef struct evrec_note_t { +struct evrec_note { unsigned char code; unsigned char chn; unsigned char note; unsigned char vel; -} evrec_note_t; +}; /* long timer events (8bytes) */ -typedef struct evrec_timer_t { +struct evrec_timer { unsigned char code; unsigned char cmd; unsigned char dummy1, dummy2; unsigned int time; -} evrec_timer_t; +}; /* long extended events (8bytes) */ -typedef struct evrec_extended_t { +struct evrec_extended { unsigned char code; unsigned char cmd; unsigned char dev; unsigned char chn; unsigned char p1, p2, p3, p4; -} evrec_extended_t; +}; /* long channel events (8bytes) */ -typedef struct evrec_long_t { +struct evrec_long { unsigned char code; unsigned char dev; unsigned char cmd; unsigned char chn; unsigned char p1, p2; unsigned short val; -} evrec_long_t; +}; /* channel voice events (8bytes) */ -typedef struct evrec_voice_t { +struct evrec_voice { unsigned char code; unsigned char dev; unsigned char cmd; unsigned char chn; unsigned char note, parm; unsigned short dummy; -} evrec_voice_t; +}; /* sysex events (8bytes) */ -typedef struct evrec_sysex_t { +struct evrec_sysex { unsigned char code; unsigned char dev; unsigned char buf[6]; -} evrec_sysex_t; +}; /* event record */ -union evrec_t { - evrec_short_t s; - evrec_note_t n; - evrec_long_t l; - evrec_voice_t v; - evrec_timer_t t; - evrec_extended_t e; - evrec_sysex_t x; +union evrec { + struct evrec_short s; + struct evrec_note n; + struct evrec_long l; + struct evrec_voice v; + struct evrec_timer t; + struct evrec_extended e; + struct evrec_sysex x; unsigned int echo; unsigned char c[LONG_EVENT_SIZE]; }; @@ -104,9 +104,9 @@ union evrec_t { #define ev_is_long(ev) ((ev)->s.code >= 128) #define ev_length(ev) ((ev)->s.code >= 128 ? LONG_EVENT_SIZE : SHORT_EVENT_SIZE) -int snd_seq_oss_process_event(seq_oss_devinfo_t *dp, evrec_t *q, snd_seq_event_t *ev); -int snd_seq_oss_process_timer_event(seq_oss_timer_t *rec, evrec_t *q); -int snd_seq_oss_event_input(snd_seq_event_t *ev, int direct, void *private_data, int atomic, int hop); +int snd_seq_oss_process_event(struct seq_oss_devinfo *dp, union evrec *q, struct snd_seq_event *ev); +int snd_seq_oss_process_timer_event(struct seq_oss_timer *rec, union evrec *q); +int snd_seq_oss_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop); #endif /* __SEQ_OSS_EVENT_H */ diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index 1ab1cf8..1d4473e 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c @@ -41,17 +41,17 @@ static int system_client = -1; /* ALSA sequencer client number */ static int system_port = -1; static int num_clients; -static seq_oss_devinfo_t *client_table[SNDRV_SEQ_OSS_MAX_CLIENTS]; +static struct seq_oss_devinfo *client_table[SNDRV_SEQ_OSS_MAX_CLIENTS]; /* * prototypes */ -static int receive_announce(snd_seq_event_t *ev, int direct, void *private, int atomic, int hop); +static int receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic, int hop); static int translate_mode(struct file *file); -static int create_port(seq_oss_devinfo_t *dp); -static int delete_port(seq_oss_devinfo_t *dp); -static int alloc_seq_queue(seq_oss_devinfo_t *dp); +static int create_port(struct seq_oss_devinfo *dp); +static int delete_port(struct seq_oss_devinfo *dp); +static int alloc_seq_queue(struct seq_oss_devinfo *dp); static int delete_seq_queue(int queue); static void free_devinfo(void *private); @@ -65,10 +65,10 @@ int __init snd_seq_oss_create_client(void) { int rc; - snd_seq_client_callback_t callback; - snd_seq_client_info_t *info; - snd_seq_port_info_t *port; - snd_seq_port_callback_t port_callback; + struct snd_seq_client_callback callback; + struct snd_seq_client_info *info; + struct snd_seq_port_info *port; + struct snd_seq_port_callback port_callback; info = kmalloc(sizeof(*info), GFP_KERNEL); port = kmalloc(sizeof(*port), GFP_KERNEL); @@ -118,7 +118,7 @@ snd_seq_oss_create_client(void) call_ctl(SNDRV_SEQ_IOCTL_CREATE_PORT, port); if ((system_port = port->addr.port) >= 0) { - snd_seq_port_subscribe_t subs; + struct snd_seq_port_subscribe subs; memset(&subs, 0, sizeof(subs)); subs.sender.client = SNDRV_SEQ_CLIENT_SYSTEM; @@ -140,9 +140,9 @@ snd_seq_oss_create_client(void) * receive annoucement from system port, and check the midi device */ static int -receive_announce(snd_seq_event_t *ev, int direct, void *private, int atomic, int hop) +receive_announce(struct snd_seq_event *ev, int direct, void *private, int atomic, int hop) { - snd_seq_port_info_t pinfo; + struct snd_seq_port_info pinfo; if (atomic) return 0; /* it must not happen */ @@ -191,7 +191,7 @@ int snd_seq_oss_open(struct file *file, int level) { int i, rc; - seq_oss_devinfo_t *dp; + struct seq_oss_devinfo *dp; if ((dp = kzalloc(sizeof(*dp), GFP_KERNEL)) == NULL) { snd_printk(KERN_ERR "can't malloc device info\n"); @@ -323,11 +323,11 @@ translate_mode(struct file *file) * create sequencer port */ static int -create_port(seq_oss_devinfo_t *dp) +create_port(struct seq_oss_devinfo *dp) { int rc; - snd_seq_port_info_t port; - snd_seq_port_callback_t callback; + struct snd_seq_port_info port; + struct snd_seq_port_callback callback; memset(&port, 0, sizeof(port)); port.addr.client = dp->cseq; @@ -358,7 +358,7 @@ create_port(seq_oss_devinfo_t *dp) * delete ALSA port */ static int -delete_port(seq_oss_devinfo_t *dp) +delete_port(struct seq_oss_devinfo *dp) { if (dp->port < 0) return 0; @@ -371,9 +371,9 @@ delete_port(seq_oss_devinfo_t *dp) * allocate a queue */ static int -alloc_seq_queue(seq_oss_devinfo_t *dp) +alloc_seq_queue(struct seq_oss_devinfo *dp) { - snd_seq_queue_info_t qinfo; + struct snd_seq_queue_info qinfo; int rc; memset(&qinfo, 0, sizeof(qinfo)); @@ -392,7 +392,7 @@ alloc_seq_queue(seq_oss_devinfo_t *dp) static int delete_seq_queue(int queue) { - snd_seq_queue_info_t qinfo; + struct snd_seq_queue_info qinfo; int rc; if (queue < 0) @@ -412,7 +412,7 @@ delete_seq_queue(int queue) static void free_devinfo(void *private) { - seq_oss_devinfo_t *dp = (seq_oss_devinfo_t *)private; + struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private; if (dp->timer) snd_seq_oss_timer_delete(dp->timer); @@ -431,7 +431,7 @@ free_devinfo(void *private) * close sequencer device */ void -snd_seq_oss_release(seq_oss_devinfo_t *dp) +snd_seq_oss_release(struct seq_oss_devinfo *dp) { int queue; @@ -460,7 +460,7 @@ snd_seq_oss_release(seq_oss_devinfo_t *dp) * Wait until the queue is empty (if we don't have nonblock) */ void -snd_seq_oss_drain_write(seq_oss_devinfo_t *dp) +snd_seq_oss_drain_write(struct seq_oss_devinfo *dp) { if (! dp->timer->running) return; @@ -477,7 +477,7 @@ snd_seq_oss_drain_write(seq_oss_devinfo_t *dp) * reset sequencer devices */ void -snd_seq_oss_reset(seq_oss_devinfo_t *dp) +snd_seq_oss_reset(struct seq_oss_devinfo *dp) { int i; @@ -525,10 +525,10 @@ filemode_str(int val) * proc interface */ void -snd_seq_oss_system_info_read(snd_info_buffer_t *buf) +snd_seq_oss_system_info_read(struct snd_info_buffer *buf) { int i; - seq_oss_devinfo_t *dp; + struct seq_oss_devinfo *dp; snd_iprintf(buf, "ALSA client number %d\n", system_client); snd_iprintf(buf, "ALSA receiver port %d\n", system_port); diff --git a/sound/core/seq/oss/seq_oss_ioctl.c b/sound/core/seq/oss/seq_oss_ioctl.c index e86f18d..5ac701c 100644 --- a/sound/core/seq/oss/seq_oss_ioctl.c +++ b/sound/core/seq/oss/seq_oss_ioctl.c @@ -28,7 +28,7 @@ #include "seq_oss_midi.h" #include "seq_oss_event.h" -static int snd_seq_oss_synth_info_user(seq_oss_devinfo_t *dp, void __user *arg) +static int snd_seq_oss_synth_info_user(struct seq_oss_devinfo *dp, void __user *arg) { struct synth_info info; @@ -41,7 +41,7 @@ static int snd_seq_oss_synth_info_user(seq_oss_devinfo_t *dp, void __user *arg) return 0; } -static int snd_seq_oss_midi_info_user(seq_oss_devinfo_t *dp, void __user *arg) +static int snd_seq_oss_midi_info_user(struct seq_oss_devinfo *dp, void __user *arg) { struct midi_info info; @@ -54,24 +54,24 @@ static int snd_seq_oss_midi_info_user(seq_oss_devinfo_t *dp, void __user *arg) return 0; } -static int snd_seq_oss_oob_user(seq_oss_devinfo_t *dp, void __user *arg) +static int snd_seq_oss_oob_user(struct seq_oss_devinfo *dp, void __user *arg) { unsigned char ev[8]; - snd_seq_event_t tmpev; + struct snd_seq_event tmpev; if (copy_from_user(ev, arg, 8)) return -EFAULT; memset(&tmpev, 0, sizeof(tmpev)); snd_seq_oss_fill_addr(dp, &tmpev, dp->addr.port, dp->addr.client); tmpev.time.tick = 0; - if (! snd_seq_oss_process_event(dp, (evrec_t*)ev, &tmpev)) { + if (! snd_seq_oss_process_event(dp, (union evrec *)ev, &tmpev)) { snd_seq_oss_dispatch(dp, &tmpev, 0, 0); } return 0; } int -snd_seq_oss_ioctl(seq_oss_devinfo_t *dp, unsigned int cmd, unsigned long carg) +snd_seq_oss_ioctl(struct seq_oss_devinfo *dp, unsigned int cmd, unsigned long carg) { int dev, val; void __user *arg = (void __user *)carg; diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index f0e95c8..eb7ae99 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c @@ -37,15 +37,15 @@ /* * definition of midi device record */ -struct seq_oss_midi_t { +struct seq_oss_midi { int seq_device; /* device number */ int client; /* sequencer client number */ int port; /* sequencer port number */ unsigned int flags; /* port capability */ int opened; /* flag for opening */ unsigned char name[SNDRV_SEQ_OSS_MAX_MIDI_NAME]; - snd_midi_event_t *coder; /* MIDI event coder */ - seq_oss_devinfo_t *devinfo; /* assigned OSSseq device */ + struct snd_midi_event *coder; /* MIDI event coder */ + struct seq_oss_devinfo *devinfo; /* assigned OSSseq device */ snd_use_lock_t use_lock; }; @@ -54,17 +54,17 @@ struct seq_oss_midi_t { * midi device table */ static int max_midi_devs; -static seq_oss_midi_t *midi_devs[SNDRV_SEQ_OSS_MAX_MIDI_DEVS]; +static struct seq_oss_midi *midi_devs[SNDRV_SEQ_OSS_MAX_MIDI_DEVS]; static DEFINE_SPINLOCK(register_lock); /* * prototypes */ -static seq_oss_midi_t *get_mdev(int dev); -static seq_oss_midi_t *get_mididev(seq_oss_devinfo_t *dp, int dev); -static int send_synth_event(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, int dev); -static int send_midi_event(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, seq_oss_midi_t *mdev); +static struct seq_oss_midi *get_mdev(int dev); +static struct seq_oss_midi *get_mididev(struct seq_oss_devinfo *dp, int dev); +static int send_synth_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int dev); +static int send_midi_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, struct seq_oss_midi *mdev); /* * look up the existing ports @@ -73,8 +73,8 @@ static int send_midi_event(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, seq_oss_m int __init snd_seq_oss_midi_lookup_ports(int client) { - snd_seq_client_info_t *clinfo; - snd_seq_port_info_t *pinfo; + struct snd_seq_client_info *clinfo; + struct snd_seq_port_info *pinfo; clinfo = kzalloc(sizeof(*clinfo), GFP_KERNEL); pinfo = kzalloc(sizeof(*pinfo), GFP_KERNEL); @@ -100,10 +100,10 @@ snd_seq_oss_midi_lookup_ports(int client) /* */ -static seq_oss_midi_t * +static struct seq_oss_midi * get_mdev(int dev) { - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; unsigned long flags; spin_lock_irqsave(®ister_lock, flags); @@ -117,11 +117,11 @@ get_mdev(int dev) /* * look for the identical slot */ -static seq_oss_midi_t * +static struct seq_oss_midi * find_slot(int client, int port) { int i; - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; unsigned long flags; spin_lock_irqsave(®ister_lock, flags); @@ -145,10 +145,10 @@ find_slot(int client, int port) * register a new port if it doesn't exist yet */ int -snd_seq_oss_midi_check_new_port(snd_seq_port_info_t *pinfo) +snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo) { int i; - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; unsigned long flags; debug_printk(("check for MIDI client %d port %d\n", pinfo->addr.client, pinfo->addr.port)); @@ -226,7 +226,7 @@ snd_seq_oss_midi_check_new_port(snd_seq_port_info_t *pinfo) int snd_seq_oss_midi_check_exit_port(int client, int port) { - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; unsigned long flags; int index; @@ -258,7 +258,7 @@ void snd_seq_oss_midi_clear_all(void) { int i; - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; unsigned long flags; spin_lock_irqsave(®ister_lock, flags); @@ -279,7 +279,7 @@ snd_seq_oss_midi_clear_all(void) * set up midi tables */ void -snd_seq_oss_midi_setup(seq_oss_devinfo_t *dp) +snd_seq_oss_midi_setup(struct seq_oss_devinfo *dp) { dp->max_mididev = max_midi_devs; } @@ -288,7 +288,7 @@ snd_seq_oss_midi_setup(seq_oss_devinfo_t *dp) * clean up midi tables */ void -snd_seq_oss_midi_cleanup(seq_oss_devinfo_t *dp) +snd_seq_oss_midi_cleanup(struct seq_oss_devinfo *dp) { int i; for (i = 0; i < dp->max_mididev; i++) @@ -301,7 +301,7 @@ snd_seq_oss_midi_cleanup(seq_oss_devinfo_t *dp) * open all midi devices. ignore errors. */ void -snd_seq_oss_midi_open_all(seq_oss_devinfo_t *dp, int file_mode) +snd_seq_oss_midi_open_all(struct seq_oss_devinfo *dp, int file_mode) { int i; for (i = 0; i < dp->max_mididev; i++) @@ -312,8 +312,8 @@ snd_seq_oss_midi_open_all(seq_oss_devinfo_t *dp, int file_mode) /* * get the midi device information */ -static seq_oss_midi_t * -get_mididev(seq_oss_devinfo_t *dp, int dev) +static struct seq_oss_midi * +get_mididev(struct seq_oss_devinfo *dp, int dev) { if (dev < 0 || dev >= dp->max_mididev) return NULL; @@ -325,11 +325,11 @@ get_mididev(seq_oss_devinfo_t *dp, int dev) * open the midi device if not opened yet */ int -snd_seq_oss_midi_open(seq_oss_devinfo_t *dp, int dev, int fmode) +snd_seq_oss_midi_open(struct seq_oss_devinfo *dp, int dev, int fmode) { int perm; - seq_oss_midi_t *mdev; - snd_seq_port_subscribe_t subs; + struct seq_oss_midi *mdev; + struct snd_seq_port_subscribe subs; if ((mdev = get_mididev(dp, dev)) == NULL) return -ENODEV; @@ -392,10 +392,10 @@ snd_seq_oss_midi_open(seq_oss_devinfo_t *dp, int dev, int fmode) * close the midi device if already opened */ int -snd_seq_oss_midi_close(seq_oss_devinfo_t *dp, int dev) +snd_seq_oss_midi_close(struct seq_oss_devinfo *dp, int dev) { - seq_oss_midi_t *mdev; - snd_seq_port_subscribe_t subs; + struct seq_oss_midi *mdev; + struct snd_seq_port_subscribe subs; if ((mdev = get_mididev(dp, dev)) == NULL) return -ENODEV; @@ -430,9 +430,9 @@ snd_seq_oss_midi_close(seq_oss_devinfo_t *dp, int dev) * change seq capability flags to file mode flags */ int -snd_seq_oss_midi_filemode(seq_oss_devinfo_t *dp, int dev) +snd_seq_oss_midi_filemode(struct seq_oss_devinfo *dp, int dev) { - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; int mode; if ((mdev = get_mididev(dp, dev)) == NULL) @@ -453,9 +453,9 @@ snd_seq_oss_midi_filemode(seq_oss_devinfo_t *dp, int dev) * so far, only close the device. */ void -snd_seq_oss_midi_reset(seq_oss_devinfo_t *dp, int dev) +snd_seq_oss_midi_reset(struct seq_oss_devinfo *dp, int dev) { - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; if ((mdev = get_mididev(dp, dev)) == NULL) return; @@ -465,7 +465,7 @@ snd_seq_oss_midi_reset(seq_oss_devinfo_t *dp, int dev) } if (mdev->opened & PERM_WRITE) { - snd_seq_event_t ev; + struct snd_seq_event ev; int c; debug_printk(("resetting client %d port %d\n", mdev->client, mdev->port)); @@ -501,9 +501,9 @@ snd_seq_oss_midi_reset(seq_oss_devinfo_t *dp, int dev) * get client/port of the specified MIDI device */ void -snd_seq_oss_midi_get_addr(seq_oss_devinfo_t *dp, int dev, snd_seq_addr_t *addr) +snd_seq_oss_midi_get_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_addr *addr) { - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; if ((mdev = get_mididev(dp, dev)) == NULL) return; @@ -517,10 +517,10 @@ snd_seq_oss_midi_get_addr(seq_oss_devinfo_t *dp, int dev, snd_seq_addr_t *addr) * input callback - this can be atomic */ int -snd_seq_oss_midi_input(snd_seq_event_t *ev, int direct, void *private_data) +snd_seq_oss_midi_input(struct snd_seq_event *ev, int direct, void *private_data) { - seq_oss_devinfo_t *dp = (seq_oss_devinfo_t *)private_data; - seq_oss_midi_t *mdev; + struct seq_oss_devinfo *dp = (struct seq_oss_devinfo *)private_data; + struct seq_oss_midi *mdev; int rc; if (dp->readq == NULL) @@ -545,9 +545,9 @@ snd_seq_oss_midi_input(snd_seq_event_t *ev, int direct, void *private_data) * convert ALSA sequencer event to OSS synth event */ static int -send_synth_event(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, int dev) +send_synth_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int dev) { - evrec_t ossev; + union evrec ossev; memset(&ossev, 0, sizeof(ossev)); @@ -606,7 +606,7 @@ send_synth_event(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, int dev) * decode event and send MIDI bytes to read queue */ static int -send_midi_event(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, seq_oss_midi_t *mdev) +send_midi_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, struct seq_oss_midi *mdev) { char msg[32]; int len; @@ -634,9 +634,9 @@ send_midi_event(seq_oss_devinfo_t *dp, snd_seq_event_t *ev, seq_oss_midi_t *mdev * non-zero : invalid - ignored */ int -snd_seq_oss_midi_putc(seq_oss_devinfo_t *dp, int dev, unsigned char c, snd_seq_event_t *ev) +snd_seq_oss_midi_putc(struct seq_oss_devinfo *dp, int dev, unsigned char c, struct snd_seq_event *ev) { - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; if ((mdev = get_mididev(dp, dev)) == NULL) return -ENODEV; @@ -653,9 +653,9 @@ snd_seq_oss_midi_putc(seq_oss_devinfo_t *dp, int dev, unsigned char c, snd_seq_e * create OSS compatible midi_info record */ int -snd_seq_oss_midi_make_info(seq_oss_devinfo_t *dp, int dev, struct midi_info *inf) +snd_seq_oss_midi_make_info(struct seq_oss_devinfo *dp, int dev, struct midi_info *inf) { - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; if ((mdev = get_mididev(dp, dev)) == NULL) return -ENXIO; @@ -686,10 +686,10 @@ capmode_str(int val) } void -snd_seq_oss_midi_info_read(snd_info_buffer_t *buf) +snd_seq_oss_midi_info_read(struct snd_info_buffer *buf) { int i; - seq_oss_midi_t *mdev; + struct seq_oss_midi *mdev; snd_iprintf(buf, "\nNumber of MIDI devices: %d\n", max_midi_devs); for (i = 0; i < max_midi_devs; i++) { diff --git a/sound/core/seq/oss/seq_oss_midi.h b/sound/core/seq/oss/seq_oss_midi.h index 462484b..84eb866 100644 --- a/sound/core/seq/oss/seq_oss_midi.h +++ b/sound/core/seq/oss/seq_oss_midi.h @@ -26,24 +26,23 @@ #include "seq_oss_device.h" #include <sound/seq_oss_legacy.h> -typedef struct seq_oss_midi_t seq_oss_midi_t; - int snd_seq_oss_midi_lookup_ports(int client); -int snd_seq_oss_midi_check_new_port(snd_seq_port_info_t *pinfo); +int snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo); int snd_seq_oss_midi_check_exit_port(int client, int port); void snd_seq_oss_midi_clear_all(void); -void snd_seq_oss_midi_setup(seq_oss_devinfo_t *dp); -void snd_seq_oss_midi_cleanup(seq_oss_devinfo_t *dp); +void snd_seq_oss_midi_setup(struct seq_oss_devinfo *dp); +void snd_seq_oss_midi_cleanup(struct seq_oss_devinfo *dp); -int snd_seq_oss_midi_open(seq_oss_devinfo_t *dp, int dev, int file_mode); -void snd_seq_oss_midi_open_all(seq_oss_devinfo_t *dp, int file_mode); -int snd_seq_oss_midi_close(seq_oss_devinfo_t *dp, int dev); -void snd_seq_oss_midi_reset(seq_oss_devinfo_t *dp, int dev); -int snd_seq_oss_midi_putc(seq_oss_devinfo_t *dp, int dev, unsigned char c, snd_seq_event_t *ev); -int snd_seq_oss_midi_input(snd_seq_event_t *ev, int direct, void *private); -int snd_seq_oss_midi_filemode(seq_oss_devinfo_t *dp, int dev); -int snd_seq_oss_midi_make_info(seq_oss_devinfo_t *dp, int dev, struct midi_info *inf); -void snd_seq_oss_midi_get_addr(seq_oss_devinfo_t *dp, int dev, snd_seq_addr_t *addr); +int snd_seq_oss_midi_open(struct seq_oss_devinfo *dp, int dev, int file_mode); +void snd_seq_oss_midi_open_all(struct seq_oss_devinfo *dp, int file_mode); +int snd_seq_oss_midi_close(struct seq_oss_devinfo *dp, int dev); +void snd_seq_oss_midi_reset(struct seq_oss_devinfo *dp, int dev); +int snd_seq_oss_midi_putc(struct seq_oss_devinfo *dp, int dev, unsigned char c, + struct snd_seq_event *ev); +int snd_seq_oss_midi_input(struct snd_seq_event *ev, int direct, void *private); +int snd_seq_oss_midi_filemode(struct seq_oss_devinfo *dp, int dev); +int snd_seq_oss_midi_make_info(struct seq_oss_devinfo *dp, int dev, struct midi_info *inf); +void snd_seq_oss_midi_get_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_addr *addr); #endif diff --git a/sound/core/seq/oss/seq_oss_readq.c b/sound/core/seq/oss/seq_oss_readq.c index 55571e1..abc7007 100644 --- a/sound/core/seq/oss/seq_oss_readq.c +++ b/sound/core/seq/oss/seq_oss_readq.c @@ -41,17 +41,17 @@ /* * create a read queue */ -seq_oss_readq_t * -snd_seq_oss_readq_new(seq_oss_devinfo_t *dp, int maxlen) +struct seq_oss_readq * +snd_seq_oss_readq_new(struct seq_oss_devinfo *dp, int maxlen) { - seq_oss_readq_t *q; + struct seq_oss_readq *q; if ((q = kzalloc(sizeof(*q), GFP_KERNEL)) == NULL) { snd_printk(KERN_ERR "can't malloc read queue\n"); return NULL; } - if ((q->q = kcalloc(maxlen, sizeof(evrec_t), GFP_KERNEL)) == NULL) { + if ((q->q = kcalloc(maxlen, sizeof(union evrec), GFP_KERNEL)) == NULL) { snd_printk(KERN_ERR "can't malloc read queue buffer\n"); kfree(q); return NULL; @@ -72,7 +72,7 @@ snd_seq_oss_readq_new(seq_oss_devinfo_t *dp, int maxlen) * delete the read queue */ void -snd_seq_oss_readq_delete(seq_oss_readq_t *q) +snd_seq_oss_readq_delete(struct seq_oss_readq *q) { if (q) { kfree(q->q); @@ -84,7 +84,7 @@ snd_seq_oss_readq_delete(seq_oss_readq_t *q) * reset the read queue */ void -snd_seq_oss_readq_clear(seq_oss_readq_t *q) +snd_seq_oss_readq_clear(struct seq_oss_readq *q) { if (q->qlen) { q->qlen = 0; @@ -100,9 +100,9 @@ snd_seq_oss_readq_clear(seq_oss_readq_t *q) * put a midi byte */ int -snd_seq_oss_readq_puts(seq_oss_readq_t *q, int dev, unsigned char *data, int len) +snd_seq_oss_readq_puts(struct seq_oss_readq *q, int dev, unsigned char *data, int len) { - evrec_t rec; + union evrec rec; int result; memset(&rec, 0, sizeof(rec)); @@ -123,7 +123,7 @@ snd_seq_oss_readq_puts(seq_oss_readq_t *q, int dev, unsigned char *data, int len * return zero if enqueued */ int -snd_seq_oss_readq_put_event(seq_oss_readq_t *q, evrec_t *ev) +snd_seq_oss_readq_put_event(struct seq_oss_readq *q, union evrec *ev) { unsigned long flags; @@ -152,7 +152,7 @@ snd_seq_oss_readq_put_event(seq_oss_readq_t *q, evrec_t *ev) * caller must hold lock */ int -snd_seq_oss_readq_pick(seq_oss_readq_t *q, evrec_t *rec) +snd_seq_oss_readq_pick(struct seq_oss_readq *q, union evrec *rec) { if (q->qlen == 0) return -EAGAIN; @@ -164,7 +164,7 @@ snd_seq_oss_readq_pick(seq_oss_readq_t *q, evrec_t *rec) * sleep until ready */ void -snd_seq_oss_readq_wait(seq_oss_readq_t *q) +snd_seq_oss_readq_wait(struct seq_oss_readq *q) { wait_event_interruptible_timeout(q->midi_sleep, (q->qlen > 0 || q->head == q->tail), @@ -176,7 +176,7 @@ snd_seq_oss_readq_wait(seq_oss_readq_t *q) * caller must hold lock */ void -snd_seq_oss_readq_free(seq_oss_readq_t *q) +snd_seq_oss_readq_free(struct seq_oss_readq *q) { if (q->qlen > 0) { q->head = (q->head + 1) % q->maxlen; @@ -189,7 +189,7 @@ snd_seq_oss_readq_free(seq_oss_readq_t *q) * return non-zero if readq is not empty. */ unsigned int -snd_seq_oss_readq_poll(seq_oss_readq_t *q, struct file *file, poll_table *wait) +snd_seq_oss_readq_poll(struct seq_oss_readq *q, struct file *file, poll_table *wait) { poll_wait(file, &q->midi_sleep, wait); return q->qlen; @@ -199,10 +199,10 @@ snd_seq_oss_readq_poll(seq_oss_readq_t *q, struct file *file, poll_table *wait) * put a timestamp */ int -snd_seq_oss_readq_put_timestamp(seq_oss_readq_t *q, unsigned long curt, int seq_mode) +snd_seq_oss_readq_put_timestamp(struct seq_oss_readq *q, unsigned long curt, int seq_mode) { if (curt != q->input_time) { - evrec_t rec; + union evrec rec; memset(&rec, 0, sizeof(rec)); switch (seq_mode) { case SNDRV_SEQ_OSS_MODE_SYNTH: @@ -226,7 +226,7 @@ snd_seq_oss_readq_put_timestamp(seq_oss_readq_t *q, unsigned long curt, int seq_ * proc interface */ void -snd_seq_oss_readq_info_read(seq_oss_readq_t *q, snd_info_buffer_t *buf) +snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf) { snd_iprintf(buf, " read queue [%s] length = %d : tick = %ld\n", (waitqueue_active(&q->midi_sleep) ? "sleeping":"running"), diff --git a/sound/core/seq/oss/seq_oss_readq.h b/sound/core/seq/oss/seq_oss_readq.h index 303b929..f1463f1 100644 --- a/sound/core/seq/oss/seq_oss_readq.h +++ b/sound/core/seq/oss/seq_oss_readq.h @@ -28,8 +28,8 @@ /* * definition of read queue */ -struct seq_oss_readq_t { - evrec_t *q; +struct seq_oss_readq { + union evrec *q; int qlen; int maxlen; int head, tail; @@ -39,16 +39,16 @@ struct seq_oss_readq_t { spinlock_t lock; }; -seq_oss_readq_t *snd_seq_oss_readq_new(seq_oss_devinfo_t *dp, int maxlen); -void snd_seq_oss_readq_delete(seq_oss_readq_t *q); -void snd_seq_oss_readq_clear(seq_oss_readq_t *readq); -unsigned int snd_seq_oss_readq_poll(seq_oss_readq_t *readq, struct file *file, poll_table *wait); -int snd_seq_oss_readq_puts(seq_oss_readq_t *readq, int dev, unsigned char *data, int len); -int snd_seq_oss_readq_put_event(seq_oss_readq_t *readq, evrec_t *ev); -int snd_seq_oss_readq_put_timestamp(seq_oss_readq_t *readq, unsigned long curt, int seq_mode); -int snd_seq_oss_readq_pick(seq_oss_readq_t *q, evrec_t *rec); -void snd_seq_oss_readq_wait(seq_oss_readq_t *q); -void snd_seq_oss_readq_free(seq_oss_readq_t *q); +struct seq_oss_readq *snd_seq_oss_readq_new(struct seq_oss_devinfo *dp, int maxlen); +void snd_seq_oss_readq_delete(struct seq_oss_readq *q); +void snd_seq_oss_readq_clear(struct seq_oss_readq *readq); +unsigned int snd_seq_oss_readq_poll(struct seq_oss_readq *readq, struct file *file, poll_table *wait); +int snd_seq_oss_readq_puts(struct seq_oss_readq *readq, int dev, unsigned char *data, int len); +int snd_seq_oss_readq_put_event(struct seq_oss_readq *readq, union evrec *ev); +int snd_seq_oss_readq_put_timestamp(struct seq_oss_readq *readq, unsigned long curt, int seq_mode); +int snd_seq_oss_readq_pick(struct seq_oss_readq *q, union evrec *rec); +void snd_seq_oss_readq_wait(struct seq_oss_readq *q); +void snd_seq_oss_readq_free(struct seq_oss_readq *q); #define snd_seq_oss_readq_lock(q, flags) spin_lock_irqsave(&(q)->lock, flags) #define snd_seq_oss_readq_unlock(q, flags) spin_unlock_irqrestore(&(q)->lock, flags) diff --git a/sound/core/seq/oss/seq_oss_rw.c b/sound/core/seq/oss/seq_oss_rw.c index 1d8fbd2..6a7b6ac 100644 --- a/sound/core/seq/oss/seq_oss_rw.c +++ b/sound/core/seq/oss/seq_oss_rw.c @@ -33,7 +33,7 @@ /* * protoypes */ -static int insert_queue(seq_oss_devinfo_t *dp, evrec_t *rec, struct file *opt); +static int insert_queue(struct seq_oss_devinfo *dp, union evrec *rec, struct file *opt); /* @@ -41,12 +41,12 @@ static int insert_queue(seq_oss_devinfo_t *dp, evrec_t *rec, struct file *opt); */ int -snd_seq_oss_read(seq_oss_devinfo_t *dp, char __user *buf, int count) +snd_seq_oss_read(struct seq_oss_devinfo *dp, char __user *buf, int count) { - seq_oss_readq_t *readq = dp->readq; + struct seq_oss_readq *readq = dp->readq; int result = 0, err = 0; int ev_len; - evrec_t rec; + union evrec rec; unsigned long flags; if (readq == NULL || ! is_read_mode(dp->file_mode)) @@ -93,11 +93,11 @@ snd_seq_oss_read(seq_oss_devinfo_t *dp, char __user *buf, int count) */ int -snd_seq_oss_write(seq_oss_devinfo_t *dp, const char __user *buf, int count, struct file *opt) +snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int count, struct file *opt) { int result = 0, err = 0; int ev_size, fmt; - evrec_t rec; + union evrec rec; if (! is_write_mode(dp->file_mode) || dp->writeq == NULL) return -ENXIO; @@ -161,10 +161,10 @@ snd_seq_oss_write(seq_oss_devinfo_t *dp, const char __user *buf, int count, stru * return: 0 = OK, non-zero = NG */ static int -insert_queue(seq_oss_devinfo_t *dp, evrec_t *rec, struct file *opt) +insert_queue(struct seq_oss_devinfo *dp, union evrec *rec, struct file *opt) { int rc = 0; - snd_seq_event_t event; + struct snd_seq_event event; /* if this is a timing event, process the current time */ if (snd_seq_oss_process_timer_event(dp->timer, rec)) @@ -197,7 +197,7 @@ insert_queue(seq_oss_devinfo_t *dp, evrec_t *rec, struct file *opt) */ unsigned int -snd_seq_oss_poll(seq_oss_devinfo_t *dp, struct file *file, poll_table * wait) +snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait) { unsigned int mask = 0; diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 8257fce..0b6025c 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -37,14 +37,14 @@ */ /* sysex buffer */ -struct seq_oss_synth_sysex_t { +struct seq_oss_synth_sysex { int len; int skip; unsigned char buf[MAX_SYSEX_BUFLEN]; }; /* synth info */ -struct seq_oss_synth_t { +struct seq_oss_synth { int seq_device; /* for synth_info */ @@ -53,7 +53,7 @@ struct seq_oss_synth_t { int nr_voices; char name[SNDRV_SEQ_OSS_MAX_SYNTH_NAME]; - snd_seq_oss_callback_t oper; + struct snd_seq_oss_callback oper; int opened; @@ -66,8 +66,8 @@ struct seq_oss_synth_t { * device table */ static int max_synth_devs; -static seq_oss_synth_t *synth_devs[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS]; -static seq_oss_synth_t midi_synth_dev = { +static struct seq_oss_synth *synth_devs[SNDRV_SEQ_OSS_MAX_SYNTH_DEVS]; +static struct seq_oss_synth midi_synth_dev = { -1, /* seq_device */ SYNTH_TYPE_MIDI, /* synth_type */ 0, /* synth_subtype */ @@ -80,8 +80,8 @@ static DEFINE_SPINLOCK(register_lock); /* * prototypes */ -static seq_oss_synth_t *get_synthdev(seq_oss_devinfo_t *dp, int dev); -static void reset_channels(seq_oss_synthinfo_t *info); +static struct seq_oss_synth *get_synthdev(struct seq_oss_devinfo *dp, int dev); +static void reset_channels(struct seq_oss_synthinfo *info); /* * global initialization @@ -96,11 +96,11 @@ snd_seq_oss_synth_init(void) * registration of the synth device */ int -snd_seq_oss_synth_register(snd_seq_device_t *dev) +snd_seq_oss_synth_register(struct snd_seq_device *dev) { int i; - seq_oss_synth_t *rec; - snd_seq_oss_reg_t *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev); + struct seq_oss_synth *rec; + struct snd_seq_oss_reg *reg = SNDRV_SEQ_DEVICE_ARGPTR(dev); unsigned long flags; if ((rec = kzalloc(sizeof(*rec), GFP_KERNEL)) == NULL) { @@ -148,10 +148,10 @@ snd_seq_oss_synth_register(snd_seq_device_t *dev) int -snd_seq_oss_synth_unregister(snd_seq_device_t *dev) +snd_seq_oss_synth_unregister(struct snd_seq_device *dev) { int index; - seq_oss_synth_t *rec = dev->driver_data; + struct seq_oss_synth *rec = dev->driver_data; unsigned long flags; spin_lock_irqsave(®ister_lock, flags); @@ -187,10 +187,10 @@ snd_seq_oss_synth_unregister(snd_seq_device_t *dev) /* */ -static seq_oss_synth_t * +static struct seq_oss_synth * get_sdev(int dev) { - seq_oss_synth_t *rec; + struct seq_oss_synth *rec; unsigned long flags; spin_lock_irqsave(®ister_lock, flags); @@ -207,11 +207,11 @@ get_sdev(int dev) */ void -snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp) +snd_seq_oss_synth_setup(struct seq_oss_devinfo *dp) { int i; - seq_oss_synth_t *rec; - seq_oss_synthinfo_t *info; + struct seq_oss_synth *rec; + struct seq_oss_synthinfo *info; dp->max_synthdev = max_synth_devs; dp->synth_opened = 0; @@ -244,7 +244,7 @@ snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp) } info->nr_voices = rec->nr_voices; if (info->nr_voices > 0) { - info->ch = kcalloc(info->nr_voices, sizeof(seq_oss_chinfo_t), GFP_KERNEL); + info->ch = kcalloc(info->nr_voices, sizeof(struct seq_oss_chinfo), GFP_KERNEL); if (!info->ch) BUG(); reset_channels(info); @@ -263,7 +263,7 @@ snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp) */ void -snd_seq_oss_synth_setup_midi(seq_oss_devinfo_t *dp) +snd_seq_oss_synth_setup_midi(struct seq_oss_devinfo *dp) { int i; @@ -271,7 +271,7 @@ snd_seq_oss_synth_setup_midi(seq_oss_devinfo_t *dp) return; for (i = 0; i < dp->max_mididev; i++) { - seq_oss_synthinfo_t *info; + struct seq_oss_synthinfo *info; info = &dp->synths[dp->max_synthdev]; if (snd_seq_oss_midi_open(dp, i, dp->file_mode) < 0) continue; @@ -297,11 +297,11 @@ snd_seq_oss_synth_setup_midi(seq_oss_devinfo_t *dp) */ void -snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp) +snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp) { int i; - seq_oss_synth_t *rec; - seq_oss_synthinfo_t *info; + struct seq_oss_synth *rec; + struct seq_oss_synthinfo *info; snd_assert(dp->max_synthdev <= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS, return); for (i = 0; i < dp->max_synthdev; i++) { @@ -338,7 +338,7 @@ snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp) * check if the specified device is MIDI mapped device */ static int -is_midi_dev(seq_oss_devinfo_t *dp, int dev) +is_midi_dev(struct seq_oss_devinfo *dp, int dev) { if (dev < 0 || dev >= dp->max_synthdev) return 0; @@ -350,10 +350,10 @@ is_midi_dev(seq_oss_devinfo_t *dp, int dev) /* * return synth device information pointer */ -static seq_oss_synth_t * -get_synthdev(seq_oss_devinfo_t *dp, int dev) +static struct seq_oss_synth * +get_synthdev(struct seq_oss_devinfo *dp, int dev) { - seq_oss_synth_t *rec; + struct seq_oss_synth *rec; if (dev < 0 || dev >= dp->max_synthdev) return NULL; if (! dp->synths[dev].opened) @@ -374,7 +374,7 @@ get_synthdev(seq_oss_devinfo_t *dp, int dev) * reset note and velocity on each channel. */ static void -reset_channels(seq_oss_synthinfo_t *info) +reset_channels(struct seq_oss_synthinfo *info) { int i; if (info->ch == NULL || ! info->nr_voices) @@ -392,10 +392,10 @@ reset_channels(seq_oss_synthinfo_t *info) * event to the corresponding port. */ void -snd_seq_oss_synth_reset(seq_oss_devinfo_t *dp, int dev) +snd_seq_oss_synth_reset(struct seq_oss_devinfo *dp, int dev) { - seq_oss_synth_t *rec; - seq_oss_synthinfo_t *info; + struct seq_oss_synth *rec; + struct seq_oss_synthinfo *info; snd_assert(dev >= 0 && dev < dp->max_synthdev, return); info = &dp->synths[dev]; @@ -428,7 +428,7 @@ snd_seq_oss_synth_reset(seq_oss_devinfo_t *dp, int dev) if (rec->oper.reset) { rec->oper.reset(&info->arg); } else { - snd_seq_event_t ev; + struct snd_seq_event ev; memset(&ev, 0, sizeof(ev)); snd_seq_oss_fill_addr(dp, &ev, info->arg.addr.client, info->arg.addr.port); @@ -444,10 +444,10 @@ snd_seq_oss_synth_reset(seq_oss_devinfo_t *dp, int dev) * call load_patch callback function */ int -snd_seq_oss_synth_load_patch(seq_oss_devinfo_t *dp, int dev, int fmt, +snd_seq_oss_synth_load_patch(struct seq_oss_devinfo *dp, int dev, int fmt, const char __user *buf, int p, int c) { - seq_oss_synth_t *rec; + struct seq_oss_synth *rec; int rc; if (dev < 0 || dev >= dp->max_synthdev) @@ -470,9 +470,9 @@ snd_seq_oss_synth_load_patch(seq_oss_devinfo_t *dp, int dev, int fmt, * check if the device is valid synth device */ int -snd_seq_oss_synth_is_valid(seq_oss_devinfo_t *dp, int dev) +snd_seq_oss_synth_is_valid(struct seq_oss_devinfo *dp, int dev) { - seq_oss_synth_t *rec; + struct seq_oss_synth *rec; rec = get_synthdev(dp, dev); if (rec) { snd_use_lock_free(&rec->use_lock); @@ -488,11 +488,11 @@ snd_seq_oss_synth_is_valid(seq_oss_devinfo_t *dp, int dev) * (0xff). */ int -snd_seq_oss_synth_sysex(seq_oss_devinfo_t *dp, int dev, unsigned char *buf, snd_seq_event_t *ev) +snd_seq_oss_synth_sysex(struct seq_oss_devinfo *dp, int dev, unsigned char *buf, struct snd_seq_event *ev) { int i, send; unsigned char *dest; - seq_oss_synth_sysex_t *sysex; + struct seq_oss_synth_sysex *sysex; if (! snd_seq_oss_synth_is_valid(dp, dev)) return -ENXIO; @@ -545,7 +545,7 @@ snd_seq_oss_synth_sysex(seq_oss_devinfo_t *dp, int dev, unsigned char *buf, snd_ * fill the event source/destination addresses */ int -snd_seq_oss_synth_addr(seq_oss_devinfo_t *dp, int dev, snd_seq_event_t *ev) +snd_seq_oss_synth_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_event *ev) { if (! snd_seq_oss_synth_is_valid(dp, dev)) return -EINVAL; @@ -559,9 +559,9 @@ snd_seq_oss_synth_addr(seq_oss_devinfo_t *dp, int dev, snd_seq_event_t *ev) * OSS compatible ioctl */ int -snd_seq_oss_synth_ioctl(seq_oss_devinfo_t *dp, int dev, unsigned int cmd, unsigned long addr) +snd_seq_oss_synth_ioctl(struct seq_oss_devinfo *dp, int dev, unsigned int cmd, unsigned long addr) { - seq_oss_synth_t *rec; + struct seq_oss_synth *rec; int rc; if (is_midi_dev(dp, dev)) @@ -581,7 +581,7 @@ snd_seq_oss_synth_ioctl(seq_oss_devinfo_t *dp, int dev, unsigned int cmd, unsign * send OSS raw events - SEQ_PRIVATE and SEQ_VOLUME */ int -snd_seq_oss_synth_raw_event(seq_oss_devinfo_t *dp, int dev, unsigned char *data, snd_seq_event_t *ev) +snd_seq_oss_synth_raw_event(struct seq_oss_devinfo *dp, int dev, unsigned char *data, struct snd_seq_event *ev) { if (! snd_seq_oss_synth_is_valid(dp, dev) || is_midi_dev(dp, dev)) return -ENXIO; @@ -595,9 +595,9 @@ snd_seq_oss_synth_raw_event(seq_oss_devinfo_t *dp, int dev, unsigned char *data, * create OSS compatible synth_info record */ int -snd_seq_oss_synth_make_info(seq_oss_devinfo_t *dp, int dev, struct synth_info *inf) +snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_info *inf) { - seq_oss_synth_t *rec; + struct seq_oss_synth *rec; if (dp->synths[dev].is_midi) { struct midi_info minf; @@ -625,10 +625,10 @@ snd_seq_oss_synth_make_info(seq_oss_devinfo_t *dp, int dev, struct synth_info *i * proc interface */ void -snd_seq_oss_synth_info_read(snd_info_buffer_t *buf) +snd_seq_oss_synth_info_read(struct snd_info_buffer *buf) { int i; - seq_oss_synth_t *rec; + struct seq_oss_synth *rec; snd_iprintf(buf, "\nNumber of synth devices: %d\n", max_synth_devs); for (i = 0; i < max_synth_devs; i++) { diff --git a/sound/core/seq/oss/seq_oss_synth.h b/sound/core/seq/oss/seq_oss_synth.h index 07bc0e2..dbdfcbb 100644 --- a/sound/core/seq/oss/seq_oss_synth.h +++ b/sound/core/seq/oss/seq_oss_synth.h @@ -27,23 +27,25 @@ #include <sound/seq_oss_legacy.h> #include <sound/seq_device.h> -typedef struct seq_oss_synth_t seq_oss_synth_t; - void snd_seq_oss_synth_init(void); -int snd_seq_oss_synth_register(snd_seq_device_t *dev); -int snd_seq_oss_synth_unregister(snd_seq_device_t *dev); -void snd_seq_oss_synth_setup(seq_oss_devinfo_t *dp); -void snd_seq_oss_synth_setup_midi(seq_oss_devinfo_t *dp); -void snd_seq_oss_synth_cleanup(seq_oss_devinfo_t *dp); +int snd_seq_oss_synth_register(struct snd_seq_device *dev); +int snd_seq_oss_synth_unregister(struct snd_seq_device *dev); +void snd_seq_oss_synth_setup(struct seq_oss_devinfo *dp); +void snd_seq_oss_synth_setup_midi(struct seq_oss_devinfo *dp); +void snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp); -void snd_seq_oss_synth_reset(seq_oss_devinfo_t *dp, int dev); -int snd_seq_oss_synth_load_patch(seq_oss_devinfo_t *dp, int dev, int fmt, const char __user *buf, int p, int c); -int snd_seq_oss_synth_is_valid(seq_oss_devinfo_t *dp, int dev); -int snd_seq_oss_synth_sysex(seq_oss_devinfo_t *dp, int dev, unsigned char *buf, snd_seq_event_t *ev); -int snd_seq_oss_synth_addr(seq_oss_devinfo_t *dp, int dev, snd_seq_event_t *ev); -int snd_seq_oss_synth_ioctl(seq_oss_devinfo_t *dp, int dev, unsigned int cmd, unsigned long addr); -int snd_seq_oss_synth_raw_event(seq_oss_devinfo_t *dp, int dev, unsigned char *data, snd_seq_event_t *ev); +void snd_seq_oss_synth_reset(struct seq_oss_devinfo *dp, int dev); +int snd_seq_oss_synth_load_patch(struct seq_oss_devinfo *dp, int dev, int fmt, + const char __user *buf, int p, int c); +int snd_seq_oss_synth_is_valid(struct seq_oss_devinfo *dp, int dev); +int snd_seq_oss_synth_sysex(struct seq_oss_devinfo *dp, int dev, unsigned char *buf, + struct snd_seq_event *ev); +int snd_seq_oss_synth_addr(struct seq_oss_devinfo *dp, int dev, struct snd_seq_event *ev); +int snd_seq_oss_synth_ioctl(struct seq_oss_devinfo *dp, int dev, unsigned int cmd, + unsigned long addr); +int snd_seq_oss_synth_raw_event(struct seq_oss_devinfo *dp, int dev, + unsigned char *data, struct snd_seq_event *ev); -int snd_seq_oss_synth_make_info(seq_oss_devinfo_t *dp, int dev, struct synth_info *inf); +int snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_info *inf); #endif diff --git a/sound/core/seq/oss/seq_oss_timer.c b/sound/core/seq/oss/seq_oss_timer.c index 64d594b..c440fda 100644 --- a/sound/core/seq/oss/seq_oss_timer.c +++ b/sound/core/seq/oss/seq_oss_timer.c @@ -33,18 +33,18 @@ /* */ -static void calc_alsa_tempo(seq_oss_timer_t *timer); -static int send_timer_event(seq_oss_devinfo_t *dp, int type, int value); +static void calc_alsa_tempo(struct seq_oss_timer *timer); +static int send_timer_event(struct seq_oss_devinfo *dp, int type, int value); /* * create and register a new timer. * if queue is not started yet, start it. */ -seq_oss_timer_t * -snd_seq_oss_timer_new(seq_oss_devinfo_t *dp) +struct seq_oss_timer * +snd_seq_oss_timer_new(struct seq_oss_devinfo *dp) { - seq_oss_timer_t *rec; + struct seq_oss_timer *rec; rec = kzalloc(sizeof(*rec), GFP_KERNEL); if (rec == NULL) @@ -67,7 +67,7 @@ snd_seq_oss_timer_new(seq_oss_devinfo_t *dp) * if no more timer exists, stop the queue. */ void -snd_seq_oss_timer_delete(seq_oss_timer_t *rec) +snd_seq_oss_timer_delete(struct seq_oss_timer *rec) { if (rec) { snd_seq_oss_timer_stop(rec); @@ -82,7 +82,7 @@ snd_seq_oss_timer_delete(seq_oss_timer_t *rec) * 0 : not a timer event -- enqueue this event */ int -snd_seq_oss_process_timer_event(seq_oss_timer_t *rec, evrec_t *ev) +snd_seq_oss_process_timer_event(struct seq_oss_timer *rec, union evrec *ev) { abstime_t parm = ev->t.time; @@ -125,7 +125,7 @@ snd_seq_oss_process_timer_event(seq_oss_timer_t *rec, evrec_t *ev) * convert tempo units */ static void -calc_alsa_tempo(seq_oss_timer_t *timer) +calc_alsa_tempo(struct seq_oss_timer *timer) { timer->tempo = (60 * 1000000) / timer->oss_tempo; timer->ppq = timer->oss_timebase; @@ -136,9 +136,9 @@ calc_alsa_tempo(seq_oss_timer_t *timer) * dispatch a timer event */ static int -send_timer_event(seq_oss_devinfo_t *dp, int type, int value) +send_timer_event(struct seq_oss_devinfo *dp, int type, int value) { - snd_seq_event_t ev; + struct snd_seq_event ev; memset(&ev, 0, sizeof(ev)); ev.type = type; @@ -156,10 +156,10 @@ send_timer_event(seq_oss_devinfo_t *dp, int type, int value) * set queue tempo and start queue */ int -snd_seq_oss_timer_start(seq_oss_timer_t *timer) +snd_seq_oss_timer_start(struct seq_oss_timer *timer) { - seq_oss_devinfo_t *dp = timer->dp; - snd_seq_queue_tempo_t tmprec; + struct seq_oss_devinfo *dp = timer->dp; + struct snd_seq_queue_tempo tmprec; if (timer->running) snd_seq_oss_timer_stop(timer); @@ -181,7 +181,7 @@ snd_seq_oss_timer_start(seq_oss_timer_t *timer) * stop queue */ int -snd_seq_oss_timer_stop(seq_oss_timer_t *timer) +snd_seq_oss_timer_stop(struct seq_oss_timer *timer) { if (! timer->running) return 0; @@ -195,7 +195,7 @@ snd_seq_oss_timer_stop(seq_oss_timer_t *timer) * continue queue */ int -snd_seq_oss_timer_continue(seq_oss_timer_t *timer) +snd_seq_oss_timer_continue(struct seq_oss_timer *timer) { if (timer->running) return 0; @@ -209,7 +209,7 @@ snd_seq_oss_timer_continue(seq_oss_timer_t *timer) * change queue tempo */ int -snd_seq_oss_timer_tempo(seq_oss_timer_t *timer, int value) +snd_seq_oss_timer_tempo(struct seq_oss_timer *timer, int value) { if (value < MIN_OSS_TEMPO) value = MIN_OSS_TEMPO; @@ -227,7 +227,7 @@ snd_seq_oss_timer_tempo(seq_oss_timer_t *timer, int value) * ioctls */ int -snd_seq_oss_timer_ioctl(seq_oss_timer_t *timer, unsigned int cmd, int __user *arg) +snd_seq_oss_timer_ioctl(struct seq_oss_timer *timer, unsigned int cmd, int __user *arg) { int value; diff --git a/sound/core/seq/oss/seq_oss_timer.h b/sound/core/seq/oss/seq_oss_timer.h index 6e4dbd8..b995bd6 100644 --- a/sound/core/seq/oss/seq_oss_timer.h +++ b/sound/core/seq/oss/seq_oss_timer.h @@ -27,8 +27,8 @@ /* * timer information definition */ -struct seq_oss_timer_t { - seq_oss_devinfo_t *dp; +struct seq_oss_timer { + struct seq_oss_devinfo *dp; reltime_t cur_tick; int realtime; int running; @@ -37,22 +37,22 @@ struct seq_oss_timer_t { }; -seq_oss_timer_t *snd_seq_oss_timer_new(seq_oss_devinfo_t *dp); -void snd_seq_oss_timer_delete(seq_oss_timer_t *dp); +struct seq_oss_timer *snd_seq_oss_timer_new(struct seq_oss_devinfo *dp); +void snd_seq_oss_timer_delete(struct seq_oss_timer *dp); -int snd_seq_oss_timer_start(seq_oss_timer_t *timer); -int snd_seq_oss_timer_stop(seq_oss_timer_t *timer); -int snd_seq_oss_timer_continue(seq_oss_timer_t *timer); -int snd_seq_oss_timer_tempo(seq_oss_timer_t *timer, int value); +int snd_seq_oss_timer_start(struct seq_oss_timer *timer); +int snd_seq_oss_timer_stop(struct seq_oss_timer *timer); +int snd_seq_oss_timer_continue(struct seq_oss_timer *timer); +int snd_seq_oss_timer_tempo(struct seq_oss_timer *timer, int value); #define snd_seq_oss_timer_reset snd_seq_oss_timer_start -int snd_seq_oss_timer_ioctl(seq_oss_timer_t *timer, unsigned int cmd, int __user *arg); +int snd_seq_oss_timer_ioctl(struct seq_oss_timer *timer, unsigned int cmd, int __user *arg); /* * get current processed time */ static inline abstime_t -snd_seq_oss_timer_cur_tick(seq_oss_timer_t *timer) +snd_seq_oss_timer_cur_tick(struct seq_oss_timer *timer) { return timer->cur_tick; } @@ -62,7 +62,7 @@ snd_seq_oss_timer_cur_tick(seq_oss_timer_t *timer) * is realtime event? */ static inline int -snd_seq_oss_timer_is_realtime(seq_oss_timer_t *timer) +snd_seq_oss_timer_is_realtime(struct seq_oss_timer *timer) { return timer->realtime; } diff --git a/sound/core/seq/oss/seq_oss_writeq.c b/sound/core/seq/oss/seq_oss_writeq.c index b203780..5c84956 100644 --- a/sound/core/seq/oss/seq_oss_writeq.c +++ b/sound/core/seq/oss/seq_oss_writeq.c @@ -32,11 +32,11 @@ /* * create a write queue record */ -seq_oss_writeq_t * -snd_seq_oss_writeq_new(seq_oss_devinfo_t *dp, int maxlen) +struct seq_oss_writeq * +snd_seq_oss_writeq_new(struct seq_oss_devinfo *dp, int maxlen) { - seq_oss_writeq_t *q; - snd_seq_client_pool_t pool; + struct seq_oss_writeq *q; + struct snd_seq_client_pool pool; if ((q = kzalloc(sizeof(*q), GFP_KERNEL)) == NULL) return NULL; @@ -61,7 +61,7 @@ snd_seq_oss_writeq_new(seq_oss_devinfo_t *dp, int maxlen) * delete the write queue */ void -snd_seq_oss_writeq_delete(seq_oss_writeq_t *q) +snd_seq_oss_writeq_delete(struct seq_oss_writeq *q) { snd_seq_oss_writeq_clear(q); /* to be sure */ kfree(q); @@ -72,9 +72,9 @@ snd_seq_oss_writeq_delete(seq_oss_writeq_t *q) * reset the write queue */ void -snd_seq_oss_writeq_clear(seq_oss_writeq_t *q) +snd_seq_oss_writeq_clear(struct seq_oss_writeq *q) { - snd_seq_remove_events_t reset; + struct snd_seq_remove_events reset; memset(&reset, 0, sizeof(reset)); reset.remove_mode = SNDRV_SEQ_REMOVE_OUTPUT; /* remove all */ @@ -88,9 +88,9 @@ snd_seq_oss_writeq_clear(seq_oss_writeq_t *q) * wait until the write buffer has enough room */ int -snd_seq_oss_writeq_sync(seq_oss_writeq_t *q) +snd_seq_oss_writeq_sync(struct seq_oss_writeq *q) { - seq_oss_devinfo_t *dp = q->dp; + struct seq_oss_devinfo *dp = q->dp; abstime_t time; time = snd_seq_oss_timer_cur_tick(dp->timer); @@ -98,8 +98,8 @@ snd_seq_oss_writeq_sync(seq_oss_writeq_t *q) return 0; /* already finished */ if (! q->sync_event_put) { - snd_seq_event_t ev; - evrec_t *rec; + struct snd_seq_event ev; + union evrec *rec; /* put echoback event */ memset(&ev, 0, sizeof(ev)); @@ -108,7 +108,7 @@ snd_seq_oss_writeq_sync(seq_oss_writeq_t *q) ev.time.tick = time; /* echo back to itself */ snd_seq_oss_fill_addr(dp, &ev, dp->addr.client, dp->addr.port); - rec = (evrec_t*)&ev.data; + rec = (union evrec *)&ev.data; rec->t.code = SEQ_SYNCTIMER; rec->t.time = time; q->sync_event_put = 1; @@ -128,7 +128,7 @@ snd_seq_oss_writeq_sync(seq_oss_writeq_t *q) * wake up sync - echo event was catched */ void -snd_seq_oss_writeq_wakeup(seq_oss_writeq_t *q, abstime_t time) +snd_seq_oss_writeq_wakeup(struct seq_oss_writeq *q, abstime_t time) { unsigned long flags; @@ -146,9 +146,9 @@ snd_seq_oss_writeq_wakeup(seq_oss_writeq_t *q, abstime_t time) * return the unused pool size */ int -snd_seq_oss_writeq_get_free_size(seq_oss_writeq_t *q) +snd_seq_oss_writeq_get_free_size(struct seq_oss_writeq *q) { - snd_seq_client_pool_t pool; + struct snd_seq_client_pool pool; pool.client = q->dp->cseq; snd_seq_oss_control(q->dp, SNDRV_SEQ_IOCTL_GET_CLIENT_POOL, &pool); return pool.output_free; @@ -159,9 +159,9 @@ snd_seq_oss_writeq_get_free_size(seq_oss_writeq_t *q) * set output threshold size from ioctl */ void -snd_seq_oss_writeq_set_output(seq_oss_writeq_t *q, int val) +snd_seq_oss_writeq_set_output(struct seq_oss_writeq *q, int val) { - snd_seq_client_pool_t pool; + struct snd_seq_client_pool pool; pool.client = q->dp->cseq; snd_seq_oss_control(q->dp, SNDRV_SEQ_IOCTL_GET_CLIENT_POOL, &pool); pool.output_room = val; diff --git a/sound/core/seq/oss/seq_oss_writeq.h b/sound/core/seq/oss/seq_oss_writeq.h index 6a13c85..c469d29 100644 --- a/sound/core/seq/oss/seq_oss_writeq.h +++ b/sound/core/seq/oss/seq_oss_writeq.h @@ -25,8 +25,8 @@ #include "seq_oss_device.h" -struct seq_oss_writeq_t { - seq_oss_devinfo_t *dp; +struct seq_oss_writeq { + struct seq_oss_devinfo *dp; int maxlen; abstime_t sync_time; int sync_event_put; @@ -38,13 +38,13 @@ struct seq_oss_writeq_t { /* * seq_oss_writeq.c */ -seq_oss_writeq_t *snd_seq_oss_writeq_new(seq_oss_devinfo_t *dp, int maxlen); -void snd_seq_oss_writeq_delete(seq_oss_writeq_t *q); -void snd_seq_oss_writeq_clear(seq_oss_writeq_t *q); -int snd_seq_oss_writeq_sync(seq_oss_writeq_t *q); -void snd_seq_oss_writeq_wakeup(seq_oss_writeq_t *q, abstime_t time); -int snd_seq_oss_writeq_get_free_size(seq_oss_writeq_t *q); -void snd_seq_oss_writeq_set_output(seq_oss_writeq_t *q, int size); +struct seq_oss_writeq *snd_seq_oss_writeq_new(struct seq_oss_devinfo *dp, int maxlen); +void snd_seq_oss_writeq_delete(struct seq_oss_writeq *q); +void snd_seq_oss_writeq_clear(struct seq_oss_writeq *q); +int snd_seq_oss_writeq_sync(struct seq_oss_writeq *q); +void snd_seq_oss_writeq_wakeup(struct seq_oss_writeq *q, abstime_t time); +int snd_seq_oss_writeq_get_free_size(struct seq_oss_writeq *q); +void snd_seq_oss_writeq_set_output(struct seq_oss_writeq *q, int size); #endif -- cgit v1.1 From 87e1f0e2b206eaf8265997a8d0cb7126ea11c844 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:08:02 +0100 Subject: [ALSA] Backward-compatibility typedefs Modules: ALSA Core Backward-compatibility typedefs are stored in the new header, typedefs.h, for out-of-tree drivers. This will be removed in future. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/typedefs.h | 173 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 include/sound/typedefs.h diff --git a/include/sound/typedefs.h b/include/sound/typedefs.h new file mode 100644 index 0000000..f454b02 --- /dev/null +++ b/include/sound/typedefs.h @@ -0,0 +1,173 @@ +/* + * Typedef's for backward compatibility (for out-of-kernel drivers) + * + * This file will be removed soon in future + */ + +/* core stuff */ +typedef struct snd_card snd_card_t; +typedef struct snd_device snd_device_t; +typedef struct snd_device_ops snd_device_ops_t; +typedef enum snd_card_type snd_card_type_t; +typedef struct snd_minor snd_minor_t; + +/* info */ +typedef struct snd_info_entry snd_info_entry_t; +typedef struct snd_info_buffer snd_info_buffer_t; + +/* control */ +typedef struct snd_ctl_file snd_ctl_file_t; +typedef struct snd_kcontrol snd_kcontrol_t; +typedef struct snd_kcontrol_new snd_kcontrol_new_t; +typedef struct snd_kcontrol_volatile snd_kcontrol_volatile_t; +typedef struct snd_kctl_event snd_kctl_event_t; +typedef struct snd_aes_iec958 snd_aes_iec958_t; +typedef struct snd_ctl_card_info snd_ctl_card_info_t; +typedef struct snd_ctl_elem_id snd_ctl_elem_id_t; +typedef struct snd_ctl_elem_list snd_ctl_elem_list_t; +typedef struct snd_ctl_elem_info snd_ctl_elem_info_t; +typedef struct snd_ctl_elem_value snd_ctl_elem_value_t; +typedef struct snd_ctl_event snd_ctl_event_t; +#if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) +typedef struct snd_mixer_oss snd_mixer_oss_t; +#endif + +/* timer */ +typedef struct snd_timer snd_timer_t; +typedef struct snd_timer_instance snd_timer_instance_t; +typedef struct snd_timer_id snd_timer_id_t; +typedef struct snd_timer_ginfo snd_timer_ginfo_t; +typedef struct snd_timer_gparams snd_timer_gparams_t; +typedef struct snd_timer_gstatus snd_timer_gstatus_t; +typedef struct snd_timer_select snd_timer_select_t; +typedef struct snd_timer_info snd_timer_info_t; +typedef struct snd_timer_params snd_timer_params_t; +typedef struct snd_timer_status snd_timer_status_t; +typedef struct snd_timer_read snd_timer_read_t; +typedef struct snd_timer_tread snd_timer_tread_t; + +/* PCM */ +typedef struct snd_pcm snd_pcm_t; +typedef struct snd_pcm_str snd_pcm_str_t; +typedef struct snd_pcm_substream snd_pcm_substream_t; +typedef struct snd_pcm_info snd_pcm_info_t; +typedef struct snd_pcm_hw_params snd_pcm_hw_params_t; +typedef struct snd_pcm_sw_params snd_pcm_sw_params_t; +typedef struct snd_pcm_channel_info snd_pcm_channel_info_t; +typedef struct snd_pcm_status snd_pcm_status_t; +typedef struct snd_pcm_mmap_status snd_pcm_mmap_status_t; +typedef struct snd_pcm_mmap_control snd_pcm_mmap_control_t; +typedef struct snd_mask snd_mask_t; +typedef struct snd_sg_buf snd_pcm_sgbuf_t; + +typedef struct snd_interval snd_interval_t; +typedef struct snd_xferi snd_xferi_t; +typedef struct snd_xfern snd_xfern_t; +typedef struct snd_xferv snd_xferv_t; + +typedef struct snd_pcm_file snd_pcm_file_t; +typedef struct snd_pcm_runtime snd_pcm_runtime_t; +typedef struct snd_pcm_hardware snd_pcm_hardware_t; +typedef struct snd_pcm_ops snd_pcm_ops_t; +typedef struct snd_pcm_hw_rule snd_pcm_hw_rule_t; +typedef struct snd_pcm_hw_constraints snd_pcm_hw_constraints_t; +typedef struct snd_ratnum ratnum_t; +typedef struct snd_ratden ratden_t; +typedef struct snd_pcm_hw_constraint_ratnums snd_pcm_hw_constraint_ratnums_t; +typedef struct snd_pcm_hw_constraint_ratdens snd_pcm_hw_constraint_ratdens_t; +typedef struct snd_pcm_hw_constraint_list snd_pcm_hw_constraint_list_t; +typedef struct snd_pcm_group snd_pcm_group_t; +typedef struct snd_pcm_notify snd_pcm_notify_t; + +/* rawmidi */ +typedef struct snd_rawmidi snd_rawmidi_t; +typedef struct snd_rawmidi_info snd_rawmidi_info_t; +typedef struct snd_rawmidi_params snd_rawmidi_params_t; +typedef struct snd_rawmidi_status snd_rawmidi_status_t; +typedef struct snd_rawmidi_runtime snd_rawmidi_runtime_t; +typedef struct snd_rawmidi_substream snd_rawmidi_substream_t; +typedef struct snd_rawmidi_str snd_rawmidi_str_t; +typedef struct snd_rawmidi_ops snd_rawmidi_ops_t; +typedef struct snd_rawmidi_global_ops snd_rawmidi_global_ops_t; +typedef struct snd_rawmidi_file snd_rawmidi_file_t; + +/* hwdep */ +typedef struct snd_hwdep snd_hwdep_t; +typedef struct snd_hwdep_info snd_hwdep_info_t; +typedef struct snd_hwdep_dsp_status snd_hwdep_dsp_status_t; +typedef struct snd_hwdep_dsp_image snd_hwdep_dsp_image_t; +typedef struct snd_hwdep_ops snd_hwdep_ops_t; + +/* sequencer */ +typedef struct snd_seq_port_info snd_seq_port_info_t; +typedef struct snd_seq_port_subscribe snd_seq_port_subscribe_t; +typedef struct snd_seq_event snd_seq_event_t; +typedef struct snd_seq_addr snd_seq_addr_t; +typedef struct snd_seq_ev_volume snd_seq_ev_volume_t; +typedef struct snd_seq_ev_loop snd_seq_ev_loop_t; +typedef struct snd_seq_remove_events snd_seq_remove_events_t; +typedef struct snd_seq_query_subs snd_seq_query_subs_t; +typedef struct snd_seq_system_info snd_seq_system_info_t; +typedef struct snd_seq_client_info snd_seq_client_info_t; +typedef struct snd_seq_queue_info snd_seq_queue_info_t; +typedef struct snd_seq_queue_status snd_seq_queue_status_t; +typedef struct snd_seq_queue_tempo snd_seq_queue_tempo_t; +typedef struct snd_seq_queue_owner snd_seq_queue_owner_t; +typedef struct snd_seq_queue_timer snd_seq_queue_timer_t; +typedef struct snd_seq_queue_client snd_seq_queue_client_t; +typedef struct snd_seq_client_pool snd_seq_client_pool_t; +typedef struct snd_seq_instr snd_seq_instr_t; +typedef struct snd_seq_instr_data snd_seq_instr_data_t; +typedef struct snd_seq_instr_header snd_seq_instr_header_t; + +typedef struct snd_seq_user_client user_client_t; +typedef struct snd_seq_kernel_client kernel_client_t; +typedef struct snd_seq_client client_t; +typedef struct snd_seq_queue queue_t; + +/* seq_device */ +typedef struct snd_seq_device snd_seq_device_t; +typedef struct snd_seq_dev_ops snd_seq_dev_ops_t; + +/* seq_midi */ +typedef struct snd_midi_event snd_midi_event_t; + +/* seq_midi_emul */ +typedef struct snd_midi_channel snd_midi_channel_t; +typedef struct snd_midi_channel_set snd_midi_channel_set_t; +typedef struct snd_midi_op snd_midi_op_t; + +/* seq_oss */ +typedef struct snd_seq_oss_arg snd_seq_oss_arg_t; +typedef struct snd_seq_oss_callback snd_seq_oss_callback_t; +typedef struct snd_seq_oss_reg snd_seq_oss_reg_t; + +/* virmidi */ +typedef struct snd_virmidi_dev snd_virmidi_dev_t; +typedef struct snd_virmidi snd_virmidi_t; + +/* seq_instr */ +typedef struct snd_seq_kcluster snd_seq_kcluster_t; +typedef struct snd_seq_kinstr_ops snd_seq_kinstr_ops_t; +typedef struct snd_seq_kinstr snd_seq_kinstr_t; +typedef struct snd_seq_kinstr_list snd_seq_kinstr_list_t; + +/* ac97 */ +typedef struct snd_ac97_bus ac97_bus_t; +typedef struct snd_ac97_bus_ops ac97_bus_ops_t; +typedef struct snd_ac97_template ac97_template_t; +typedef struct snd_ac97 ac97_t; + +/* opl3/4 */ +typedef struct snd_opl3 opl3_t; +typedef struct snd_opl4 opl4_t; + +/* mpu401 */ +typedef struct snd_mpu401 mpu401_t; + +/* i2c */ +typedef struct snd_i2c_device snd_i2c_device_t; +typedef struct snd_i2c_bus snd_i2c_bus_t; + +typedef struct snd_ak4531 ak4531_t; + -- cgit v1.1 From e1fad17bb4084dc7c435360185417aed55656ec8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:12:45 +0100 Subject: [ALSA] Remove xxx_t typedefs: MPU401 Modules: MPU401 UART Remove xxx_t typedefs from the MPU401-UART and MPU401 drivers Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/mpu401.h | 26 +++++++------- sound/drivers/mpu401/mpu401.c | 10 +++--- sound/drivers/mpu401/mpu401_uart.c | 72 +++++++++++++++++++------------------- 3 files changed, 53 insertions(+), 55 deletions(-) diff --git a/include/sound/mpu401.h b/include/sound/mpu401.h index ae39e38..8e97ace 100644 --- a/include/sound/mpu401.h +++ b/include/sound/mpu401.h @@ -58,10 +58,8 @@ #define MPU401_MODE_INPUT_TIMER (1<<0) #define MPU401_MODE_OUTPUT_TIMER (1<<1) -typedef struct _snd_mpu401 mpu401_t; - -struct _snd_mpu401 { - snd_rawmidi_t *rmidi; +struct snd_mpu401 { + struct snd_rawmidi *rmidi; unsigned short hardware; /* MPU401_HW_XXXX */ unsigned long port; /* base port of MPU-401 chip */ @@ -73,14 +71,14 @@ struct _snd_mpu401 { unsigned long mode; /* MPU401_MODE_XXXX */ int timer_invoked; - int (*open_input) (mpu401_t * mpu); - void (*close_input) (mpu401_t * mpu); - int (*open_output) (mpu401_t * mpu); - void (*close_output) (mpu401_t * mpu); + int (*open_input) (struct snd_mpu401 * mpu); + void (*close_input) (struct snd_mpu401 * mpu); + int (*open_output) (struct snd_mpu401 * mpu); + void (*close_output) (struct snd_mpu401 * mpu); void *private_data; - snd_rawmidi_substream_t *substream_input; - snd_rawmidi_substream_t *substream_output; + struct snd_rawmidi_substream *substream_input; + struct snd_rawmidi_substream *substream_output; spinlock_t input_lock; spinlock_t output_lock; @@ -88,8 +86,8 @@ struct _snd_mpu401 { struct timer_list timer; - void (*write) (mpu401_t * mpu, unsigned char data, unsigned long addr); - unsigned char (*read) (mpu401_t * mpu, unsigned long addr); + void (*write) (struct snd_mpu401 * mpu, unsigned char data, unsigned long addr); + unsigned char (*read) (struct snd_mpu401 *mpu, unsigned long addr); }; /* I/O ports */ @@ -103,13 +101,13 @@ struct _snd_mpu401 { irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *regs); -int snd_mpu401_uart_new(snd_card_t * card, +int snd_mpu401_uart_new(struct snd_card *card, int device, unsigned short hardware, unsigned long port, int integrated, int irq, int irq_flags, - snd_rawmidi_t ** rrawmidi); + struct snd_rawmidi ** rrawmidi); #endif /* __SOUND_MPU401_H */ diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index 54e2ff9..b1242ee 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -56,12 +56,12 @@ MODULE_PARM_DESC(port, "Port # for MPU-401 device."); module_param_array(irq, int, NULL, 0444); MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); -static snd_card_t *snd_mpu401_legacy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_mpu401_legacy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static int pnp_registered = 0; -static int snd_mpu401_create(int dev, snd_card_t **rcard) +static int snd_mpu401_create(int dev, struct snd_card **rcard) { - snd_card_t *card; + struct snd_card *card; int err; *rcard = NULL; @@ -152,7 +152,7 @@ static int __devinit snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) { static int dev; - snd_card_t *card; + struct snd_card *card; int err; for ( ; dev < SNDRV_CARDS; ++dev) { @@ -174,7 +174,7 @@ static int __devinit snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev, static void __devexit snd_mpu401_pnp_remove(struct pnp_dev *dev) { - snd_card_t *card = (snd_card_t *) pnp_get_drvdata(dev); + struct snd_card *card = (struct snd_card *) pnp_get_drvdata(dev); snd_card_disconnect(card); snd_card_free_in_thread(card); diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index bdeb2c0..16e87f3 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -43,8 +43,8 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("Routines for control of MPU-401 in UART mode"); MODULE_LICENSE("GPL"); -static void snd_mpu401_uart_input_read(mpu401_t * mpu); -static void snd_mpu401_uart_output_write(mpu401_t * mpu); +static void snd_mpu401_uart_input_read(struct snd_mpu401 * mpu); +static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu); /* @@ -58,28 +58,28 @@ static void snd_mpu401_uart_output_write(mpu401_t * mpu); #define MPU401_ACK 0xfe /* Build in lowlevel io */ -static void mpu401_write_port(mpu401_t *mpu, unsigned char data, unsigned long addr) +static void mpu401_write_port(struct snd_mpu401 *mpu, unsigned char data, unsigned long addr) { outb(data, addr); } -static unsigned char mpu401_read_port(mpu401_t *mpu, unsigned long addr) +static unsigned char mpu401_read_port(struct snd_mpu401 *mpu, unsigned long addr) { return inb(addr); } -static void mpu401_write_mmio(mpu401_t *mpu, unsigned char data, unsigned long addr) +static void mpu401_write_mmio(struct snd_mpu401 *mpu, unsigned char data, unsigned long addr) { writeb(data, (void __iomem *)addr); } -static unsigned char mpu401_read_mmio(mpu401_t *mpu, unsigned long addr) +static unsigned char mpu401_read_mmio(struct snd_mpu401 *mpu, unsigned long addr) { return readb((void __iomem *)addr); } /* */ -static void snd_mpu401_uart_clear_rx(mpu401_t *mpu) +static void snd_mpu401_uart_clear_rx(struct snd_mpu401 *mpu) { int timeout = 100000; for (; timeout > 0 && snd_mpu401_input_avail(mpu); timeout--) @@ -90,7 +90,7 @@ static void snd_mpu401_uart_clear_rx(mpu401_t *mpu) #endif } -static void _snd_mpu401_uart_interrupt(mpu401_t *mpu) +static void _snd_mpu401_uart_interrupt(struct snd_mpu401 *mpu) { spin_lock(&mpu->input_lock); if (test_bit(MPU401_MODE_BIT_INPUT, &mpu->mode)) { @@ -118,7 +118,7 @@ static void _snd_mpu401_uart_interrupt(mpu401_t *mpu) */ irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - mpu401_t *mpu = dev_id; + struct snd_mpu401 *mpu = dev_id; if (mpu == NULL) return IRQ_NONE; @@ -132,7 +132,7 @@ irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *reg */ static void snd_mpu401_uart_timer(unsigned long data) { - mpu401_t *mpu = (mpu401_t *)data; + struct snd_mpu401 *mpu = (struct snd_mpu401 *)data; spin_lock(&mpu->timer_lock); /*mpu->mode |= MPU401_MODE_TIMER;*/ @@ -146,7 +146,7 @@ static void snd_mpu401_uart_timer(unsigned long data) /* * initialize the timer callback if not programmed yet */ -static void snd_mpu401_uart_add_timer (mpu401_t *mpu, int input) +static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu, int input) { unsigned long flags; @@ -165,7 +165,7 @@ static void snd_mpu401_uart_add_timer (mpu401_t *mpu, int input) /* * remove the timer callback if still active */ -static void snd_mpu401_uart_remove_timer (mpu401_t *mpu, int input) +static void snd_mpu401_uart_remove_timer (struct snd_mpu401 *mpu, int input) { unsigned long flags; @@ -182,7 +182,7 @@ static void snd_mpu401_uart_remove_timer (mpu401_t *mpu, int input) */ -static void snd_mpu401_uart_cmd(mpu401_t * mpu, unsigned char cmd, int ack) +static void snd_mpu401_uart_cmd(struct snd_mpu401 * mpu, unsigned char cmd, int ack) { unsigned long flags; int timeout, ok; @@ -225,9 +225,9 @@ static void snd_mpu401_uart_cmd(mpu401_t * mpu, unsigned char cmd, int ack) /* * input/output open/close - protected by open_mutex in rawmidi.c */ -static int snd_mpu401_uart_input_open(snd_rawmidi_substream_t * substream) +static int snd_mpu401_uart_input_open(struct snd_rawmidi_substream *substream) { - mpu401_t *mpu; + struct snd_mpu401 *mpu; int err; mpu = substream->rmidi->private_data; @@ -242,9 +242,9 @@ static int snd_mpu401_uart_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_mpu401_uart_output_open(snd_rawmidi_substream_t * substream) +static int snd_mpu401_uart_output_open(struct snd_rawmidi_substream *substream) { - mpu401_t *mpu; + struct snd_mpu401 *mpu; int err; mpu = substream->rmidi->private_data; @@ -259,9 +259,9 @@ static int snd_mpu401_uart_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_mpu401_uart_input_close(snd_rawmidi_substream_t * substream) +static int snd_mpu401_uart_input_close(struct snd_rawmidi_substream *substream) { - mpu401_t *mpu; + struct snd_mpu401 *mpu; mpu = substream->rmidi->private_data; clear_bit(MPU401_MODE_BIT_INPUT, &mpu->mode); @@ -273,9 +273,9 @@ static int snd_mpu401_uart_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_mpu401_uart_output_close(snd_rawmidi_substream_t * substream) +static int snd_mpu401_uart_output_close(struct snd_rawmidi_substream *substream) { - mpu401_t *mpu; + struct snd_mpu401 *mpu; mpu = substream->rmidi->private_data; clear_bit(MPU401_MODE_BIT_OUTPUT, &mpu->mode); @@ -290,10 +290,10 @@ static int snd_mpu401_uart_output_close(snd_rawmidi_substream_t * substream) /* * trigger input callback */ -static void snd_mpu401_uart_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_mpu401_uart_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - mpu401_t *mpu; + struct snd_mpu401 *mpu; int max = 64; mpu = substream->rmidi->private_data; @@ -321,7 +321,7 @@ static void snd_mpu401_uart_input_trigger(snd_rawmidi_substream_t * substream, i * transfer input pending data * call with input_lock spinlock held */ -static void snd_mpu401_uart_input_read(mpu401_t * mpu) +static void snd_mpu401_uart_input_read(struct snd_mpu401 * mpu) { int max = 128; unsigned char byte; @@ -349,7 +349,7 @@ static void snd_mpu401_uart_input_read(mpu401_t * mpu) * write output pending bytes * call with output_lock spinlock held */ -static void snd_mpu401_uart_output_write(mpu401_t * mpu) +static void snd_mpu401_uart_output_write(struct snd_mpu401 * mpu) { unsigned char byte; int max = 256, timeout; @@ -375,10 +375,10 @@ static void snd_mpu401_uart_output_write(mpu401_t * mpu) /* * output trigger callback */ -static void snd_mpu401_uart_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_mpu401_uart_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - mpu401_t *mpu; + struct snd_mpu401 *mpu; mpu = substream->rmidi->private_data; if (up) { @@ -404,23 +404,23 @@ static void snd_mpu401_uart_output_trigger(snd_rawmidi_substream_t * substream, */ -static snd_rawmidi_ops_t snd_mpu401_uart_output = +static struct snd_rawmidi_ops snd_mpu401_uart_output = { .open = snd_mpu401_uart_output_open, .close = snd_mpu401_uart_output_close, .trigger = snd_mpu401_uart_output_trigger, }; -static snd_rawmidi_ops_t snd_mpu401_uart_input = +static struct snd_rawmidi_ops snd_mpu401_uart_input = { .open = snd_mpu401_uart_input_open, .close = snd_mpu401_uart_input_close, .trigger = snd_mpu401_uart_input_trigger, }; -static void snd_mpu401_uart_free(snd_rawmidi_t *rmidi) +static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi) { - mpu401_t *mpu = rmidi->private_data; + struct snd_mpu401 *mpu = rmidi->private_data; if (mpu->irq_flags && mpu->irq >= 0) free_irq(mpu->irq, (void *) mpu); release_and_free_resource(mpu->res); @@ -442,18 +442,18 @@ static void snd_mpu401_uart_free(snd_rawmidi_t *rmidi) * * Note that the rawmidi instance is returned on the rrawmidi argument, * not the mpu401 instance itself. To access to the mpu401 instance, - * cast from rawmidi->private_data (with mpu401_t magic-cast). + * cast from rawmidi->private_data (with struct snd_mpu401 magic-cast). * * Returns zero if successful, or a negative error code. */ -int snd_mpu401_uart_new(snd_card_t * card, int device, +int snd_mpu401_uart_new(struct snd_card *card, int device, unsigned short hardware, unsigned long port, int integrated, int irq, int irq_flags, - snd_rawmidi_t ** rrawmidi) + struct snd_rawmidi ** rrawmidi) { - mpu401_t *mpu; - snd_rawmidi_t *rmidi; + struct snd_mpu401 *mpu; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) -- cgit v1.1 From 5b1646a8eceff0a4ff06f309abb6e7f43f99a498 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:13:14 +0100 Subject: [ALSA] Remove xxx_t typedefs: OPL3 Modules: OPL3,Raw OPL FM Remove xxx_t typedefs from the OPL3 driver Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/asound_fm.h | 24 ++++++------- include/sound/opl3.h | 57 ++++++++++++++--------------- sound/drivers/opl3/opl3_drums.c | 45 ++++++++++++----------- sound/drivers/opl3/opl3_lib.c | 80 ++++++++++++++++++++--------------------- sound/drivers/opl3/opl3_midi.c | 70 ++++++++++++++++++------------------ sound/drivers/opl3/opl3_oss.c | 68 +++++++++++++++++------------------ sound/drivers/opl3/opl3_seq.c | 48 ++++++++++++------------- sound/drivers/opl3/opl3_synth.c | 50 +++++++++++++------------- sound/drivers/opl3/opl3_voice.h | 24 ++++++------- 9 files changed, 235 insertions(+), 231 deletions(-) diff --git a/include/sound/asound_fm.h b/include/sound/asound_fm.h index b0da677..956fdc2 100644 --- a/include/sound/asound_fm.h +++ b/include/sound/asound_fm.h @@ -29,16 +29,16 @@ #define SNDRV_DM_FM_MODE_OPL2 0x00 #define SNDRV_DM_FM_MODE_OPL3 0x01 -typedef struct snd_dm_fm_info { +struct snd_dm_fm_info { unsigned char fm_mode; /* OPL mode, see SNDRV_DM_FM_MODE_XXX */ unsigned char rhythm; /* percussion mode flag */ -} snd_dm_fm_info_t; +}; /* * Data structure composing an FM "note" or sound event. */ -typedef struct snd_dm_fm_voice { +struct snd_dm_fm_voice { unsigned char op; /* operator cell (0 or 1) */ unsigned char voice; /* FM voice (0 to 17) */ @@ -60,25 +60,25 @@ typedef struct snd_dm_fm_voice { unsigned char left; /* stereo left */ unsigned char right; /* stereo right */ unsigned char waveform; /* 3 bits: waveform shape */ -} snd_dm_fm_voice_t; +}; /* * This describes an FM note by its voice, octave, frequency number (10bit) * and key on/off. */ -typedef struct snd_dm_fm_note { +struct snd_dm_fm_note { unsigned char voice; /* 0-17 voice channel */ unsigned char octave; /* 3 bits: what octave to play */ unsigned int fnum; /* 10 bits: frequency number */ unsigned char key_on; /* set for active, clear for silent */ -} snd_dm_fm_note_t; +}; /* * FM parameters that apply globally to all voices, and thus are not "notes" */ -typedef struct snd_dm_fm_params { +struct snd_dm_fm_params { unsigned char am_depth; /* amplitude modulation depth (1=hi) */ unsigned char vib_depth; /* vibrato depth (1=hi) */ unsigned char kbd_split; /* keyboard split */ @@ -90,17 +90,17 @@ typedef struct snd_dm_fm_params { unsigned char tomtom; unsigned char cymbal; unsigned char hihat; -} snd_dm_fm_params_t; +}; /* * FM mode ioctl settings */ -#define SNDRV_DM_FM_IOCTL_INFO _IOR('H', 0x20, snd_dm_fm_info_t) +#define SNDRV_DM_FM_IOCTL_INFO _IOR('H', 0x20, struct snd_dm_fm_info) #define SNDRV_DM_FM_IOCTL_RESET _IO ('H', 0x21) -#define SNDRV_DM_FM_IOCTL_PLAY_NOTE _IOW('H', 0x22, snd_dm_fm_note_t) -#define SNDRV_DM_FM_IOCTL_SET_VOICE _IOW('H', 0x23, snd_dm_fm_voice_t) -#define SNDRV_DM_FM_IOCTL_SET_PARAMS _IOW('H', 0x24, snd_dm_fm_params_t) +#define SNDRV_DM_FM_IOCTL_PLAY_NOTE _IOW('H', 0x22, struct snd_dm_fm_note) +#define SNDRV_DM_FM_IOCTL_SET_VOICE _IOW('H', 0x23, struct snd_dm_fm_voice) +#define SNDRV_DM_FM_IOCTL_SET_PARAMS _IOW('H', 0x24, struct snd_dm_fm_params) #define SNDRV_DM_FM_IOCTL_SET_MODE _IOW('H', 0x25, int) /* for OPL3 only */ #define SNDRV_DM_FM_IOCTL_SET_CONNECTION _IOW('H', 0x26, int) diff --git a/include/sound/opl3.h b/include/sound/opl3.h index 19f657d..8339264 100644 --- a/include/sound/opl3.h +++ b/include/sound/opl3.h @@ -237,12 +237,12 @@ #define MAX_OPL2_VOICES 9 #define MAX_OPL3_VOICES 18 -typedef struct snd_opl3 opl3_t; +struct snd_opl3; /* * A structure to keep track of each hardware voice */ -typedef struct snd_opl3_voice { +struct snd_opl3_voice { int state; /* status */ #define SNDRV_OPL3_ST_OFF 0 /* Not playing */ #define SNDRV_OPL3_ST_ON_2OP 1 /* 2op voice is allocated */ @@ -257,8 +257,8 @@ typedef struct snd_opl3_voice { unsigned char keyon_reg; /* KON register shadow */ - snd_midi_channel_t *chan; /* Midi channel for this note */ -} snd_opl3_voice_t; + struct snd_midi_channel *chan; /* Midi channel for this note */ +}; struct snd_opl3 { unsigned long l_port; @@ -267,18 +267,18 @@ struct snd_opl3 { struct resource *res_r_port; unsigned short hardware; /* hardware access */ - void (*command) (opl3_t * opl3, unsigned short cmd, unsigned char val); + void (*command) (struct snd_opl3 * opl3, unsigned short cmd, unsigned char val); unsigned short timer_enable; int seq_dev_num; /* sequencer device number */ - snd_timer_t *timer1; - snd_timer_t *timer2; + struct snd_timer *timer1; + struct snd_timer *timer2; spinlock_t timer_lock; void *private_data; - void (*private_free)(opl3_t *); + void (*private_free)(struct snd_opl3 *); spinlock_t reg_lock; - snd_card_t *card; /* The card that this belongs to */ + struct snd_card *card; /* The card that this belongs to */ int used; /* usage flag - exclusive */ unsigned char fm_mode; /* OPL mode, see SNDRV_DM_FM_MODE_XXX */ unsigned char rhythm; /* percussion mode flag */ @@ -289,18 +289,18 @@ struct snd_opl3 { int synth_mode; /* synth mode */ int seq_client; - snd_seq_device_t *seq_dev; /* sequencer device */ - snd_midi_channel_set_t * chset; + struct snd_seq_device *seq_dev; /* sequencer device */ + struct snd_midi_channel_set * chset; #ifdef CONFIG_SND_SEQUENCER_OSS - snd_seq_device_t *oss_seq_dev; /* OSS sequencer device */ - snd_midi_channel_set_t * oss_chset; + struct snd_seq_device *oss_seq_dev; /* OSS sequencer device */ + struct snd_midi_channel_set * oss_chset; #endif - snd_seq_kinstr_ops_t fm_ops; - snd_seq_kinstr_list_t *ilist; + struct snd_seq_kinstr_ops fm_ops; + struct snd_seq_kinstr_list *ilist; - snd_opl3_voice_t voices[MAX_OPL3_VOICES]; /* Voices (OPL3 'channel') */ + struct snd_opl3_voice voices[MAX_OPL3_VOICES]; /* Voices (OPL3 'channel') */ int use_time; /* allocation counter */ unsigned short connection_reg; /* connection reg shadow */ @@ -316,24 +316,25 @@ struct snd_opl3 { }; /* opl3.c */ -void snd_opl3_interrupt(snd_hwdep_t * hw); -int snd_opl3_new(snd_card_t *card, unsigned short hardware, opl3_t **ropl3); -int snd_opl3_init(opl3_t *opl3); -int snd_opl3_create(snd_card_t * card, +void snd_opl3_interrupt(struct snd_hwdep * hw); +int snd_opl3_new(struct snd_card *card, unsigned short hardware, + struct snd_opl3 **ropl3); +int snd_opl3_init(struct snd_opl3 *opl3); +int snd_opl3_create(struct snd_card *card, unsigned long l_port, unsigned long r_port, unsigned short hardware, int integrated, - opl3_t ** opl3); -int snd_opl3_timer_new(opl3_t * opl3, int timer1_dev, int timer2_dev); -int snd_opl3_hwdep_new(opl3_t * opl3, int device, int seq_device, - snd_hwdep_t ** rhwdep); + struct snd_opl3 ** opl3); +int snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev); +int snd_opl3_hwdep_new(struct snd_opl3 * opl3, int device, int seq_device, + struct snd_hwdep ** rhwdep); /* opl3_synth */ -int snd_opl3_open(snd_hwdep_t * hw, struct file *file); -int snd_opl3_ioctl(snd_hwdep_t * hw, struct file *file, +int snd_opl3_open(struct snd_hwdep * hw, struct file *file); +int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg); -int snd_opl3_release(snd_hwdep_t * hw, struct file *file); +int snd_opl3_release(struct snd_hwdep * hw, struct file *file); -void snd_opl3_reset(opl3_t * opl3); +void snd_opl3_reset(struct snd_opl3 * opl3); #endif /* __SOUND_OPL3_H */ diff --git a/sound/drivers/opl3/opl3_drums.c b/sound/drivers/opl3/opl3_drums.c index f263326..7369438 100644 --- a/sound/drivers/opl3/opl3_drums.c +++ b/sound/drivers/opl3/opl3_drums.c @@ -45,7 +45,7 @@ static char snd_opl3_drum_table[47] = OPL3_CYMBAL_ON, OPL3_CYMBAL_ON /* 80 - 81 */ }; -typedef struct snd_opl3_drum_voice { +struct snd_opl3_drum_voice { int voice; int op; unsigned char am_vib; @@ -54,33 +54,34 @@ typedef struct snd_opl3_drum_voice { unsigned char sustain_release; unsigned char feedback_connection; unsigned char wave_select; -} snd_opl3_drum_voice_t; +}; -typedef struct snd_opl3_drum_note { +struct snd_opl3_drum_note { int voice; unsigned char fnum; unsigned char octave_f; unsigned char feedback_connection; -} snd_opl3_drum_note_t; +}; -static snd_opl3_drum_voice_t bass_op0 = {6, 0, 0x00, 0x32, 0xf8, 0x66, 0x30, 0x00}; -static snd_opl3_drum_voice_t bass_op1 = {6, 1, 0x00, 0x03, 0xf6, 0x57, 0x30, 0x00}; -static snd_opl3_drum_note_t bass_note = {6, 0x90, 0x09}; +static struct snd_opl3_drum_voice bass_op0 = {6, 0, 0x00, 0x32, 0xf8, 0x66, 0x30, 0x00}; +static struct snd_opl3_drum_voice bass_op1 = {6, 1, 0x00, 0x03, 0xf6, 0x57, 0x30, 0x00}; +static struct snd_opl3_drum_note bass_note = {6, 0x90, 0x09}; -static snd_opl3_drum_voice_t hihat = {7, 0, 0x00, 0x03, 0xf0, 0x06, 0x20, 0x00}; +static struct snd_opl3_drum_voice hihat = {7, 0, 0x00, 0x03, 0xf0, 0x06, 0x20, 0x00}; -static snd_opl3_drum_voice_t snare = {7, 1, 0x00, 0x03, 0xf0, 0x07, 0x20, 0x02}; -static snd_opl3_drum_note_t snare_note = {7, 0xf4, 0x0d}; +static struct snd_opl3_drum_voice snare = {7, 1, 0x00, 0x03, 0xf0, 0x07, 0x20, 0x02}; +static struct snd_opl3_drum_note snare_note = {7, 0xf4, 0x0d}; -static snd_opl3_drum_voice_t tomtom = {8, 0, 0x02, 0x03, 0xf0, 0x06, 0x10, 0x00}; -static snd_opl3_drum_note_t tomtom_note = {8, 0xf4, 0x09}; +static struct snd_opl3_drum_voice tomtom = {8, 0, 0x02, 0x03, 0xf0, 0x06, 0x10, 0x00}; +static struct snd_opl3_drum_note tomtom_note = {8, 0xf4, 0x09}; -static snd_opl3_drum_voice_t cymbal = {8, 1, 0x04, 0x03, 0xf0, 0x06, 0x10, 0x00}; +static struct snd_opl3_drum_voice cymbal = {8, 1, 0x04, 0x03, 0xf0, 0x06, 0x10, 0x00}; /* * set drum voice characteristics */ -static void snd_opl3_drum_voice_set(opl3_t *opl3, snd_opl3_drum_voice_t *data) +static void snd_opl3_drum_voice_set(struct snd_opl3 *opl3, + struct snd_opl3_drum_voice *data) { unsigned char op_offset = snd_opl3_regmap[data->voice][data->op]; unsigned char voice_offset = data->voice; @@ -114,7 +115,8 @@ static void snd_opl3_drum_voice_set(opl3_t *opl3, snd_opl3_drum_voice_t *data) /* * Set drum voice pitch */ -static void snd_opl3_drum_note_set(opl3_t *opl3, snd_opl3_drum_note_t *data) +static void snd_opl3_drum_note_set(struct snd_opl3 *opl3, + struct snd_opl3_drum_note *data) { unsigned char voice_offset = data->voice; unsigned short opl3_reg; @@ -131,8 +133,9 @@ static void snd_opl3_drum_note_set(opl3_t *opl3, snd_opl3_drum_note_t *data) /* * Set drum voice volume and position */ -static void snd_opl3_drum_vol_set(opl3_t *opl3, snd_opl3_drum_voice_t *data, - int vel, snd_midi_channel_t *chan) +static void snd_opl3_drum_vol_set(struct snd_opl3 *opl3, + struct snd_opl3_drum_voice *data, + int vel, struct snd_midi_channel *chan) { unsigned char op_offset = snd_opl3_regmap[data->voice][data->op]; unsigned char voice_offset = data->voice; @@ -159,7 +162,7 @@ static void snd_opl3_drum_vol_set(opl3_t *opl3, snd_opl3_drum_voice_t *data, /* * Loads drum voices at init time */ -void snd_opl3_load_drums(opl3_t *opl3) +void snd_opl3_load_drums(struct snd_opl3 *opl3) { snd_opl3_drum_voice_set(opl3, &bass_op0); snd_opl3_drum_voice_set(opl3, &bass_op1); @@ -179,11 +182,11 @@ void snd_opl3_load_drums(opl3_t *opl3) /* * Switch drum voice on or off */ -void snd_opl3_drum_switch(opl3_t *opl3, int note, int vel, int on_off, - snd_midi_channel_t *chan) +void snd_opl3_drum_switch(struct snd_opl3 *opl3, int note, int vel, int on_off, + struct snd_midi_channel *chan) { unsigned char drum_mask; - snd_opl3_drum_voice_t *drum_voice; + struct snd_opl3_drum_voice *drum_voice; if (!(opl3->drum_reg & OPL3_PERCUSSION_ENABLE)) return; diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index 0624650..cbd37e9 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -37,7 +37,7 @@ MODULE_LICENSE("GPL"); extern char snd_opl3_regmap[MAX_OPL2_VOICES][4]; -static void snd_opl2_command(opl3_t * opl3, unsigned short cmd, unsigned char val) +static void snd_opl2_command(struct snd_opl3 * opl3, unsigned short cmd, unsigned char val) { unsigned long flags; unsigned long port; @@ -60,7 +60,7 @@ static void snd_opl2_command(opl3_t * opl3, unsigned short cmd, unsigned char va spin_unlock_irqrestore(&opl3->reg_lock, flags); } -static void snd_opl3_command(opl3_t * opl3, unsigned short cmd, unsigned char val) +static void snd_opl3_command(struct snd_opl3 * opl3, unsigned short cmd, unsigned char val) { unsigned long flags; unsigned long port; @@ -85,7 +85,7 @@ static void snd_opl3_command(opl3_t * opl3, unsigned short cmd, unsigned char va spin_unlock_irqrestore(&opl3->reg_lock, flags); } -static int snd_opl3_detect(opl3_t * opl3) +static int snd_opl3_detect(struct snd_opl3 * opl3) { /* * This function returns 1 if the FM chip is present at the given I/O port @@ -153,12 +153,12 @@ static int snd_opl3_detect(opl3_t * opl3) * Timer 1 - 80us */ -static int snd_opl3_timer1_start(snd_timer_t * timer) +static int snd_opl3_timer1_start(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; unsigned int ticks; - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = snd_timer_chip(timer); spin_lock_irqsave(&opl3->timer_lock, flags); @@ -171,11 +171,11 @@ static int snd_opl3_timer1_start(snd_timer_t * timer) return 0; } -static int snd_opl3_timer1_stop(snd_timer_t * timer) +static int snd_opl3_timer1_stop(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = snd_timer_chip(timer); spin_lock_irqsave(&opl3->timer_lock, flags); @@ -190,12 +190,12 @@ static int snd_opl3_timer1_stop(snd_timer_t * timer) * Timer 2 - 320us */ -static int snd_opl3_timer2_start(snd_timer_t * timer) +static int snd_opl3_timer2_start(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; unsigned int ticks; - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = snd_timer_chip(timer); spin_lock_irqsave(&opl3->timer_lock, flags); @@ -208,11 +208,11 @@ static int snd_opl3_timer2_start(snd_timer_t * timer) return 0; } -static int snd_opl3_timer2_stop(snd_timer_t * timer) +static int snd_opl3_timer2_stop(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = snd_timer_chip(timer); spin_lock_irqsave(&opl3->timer_lock, flags); @@ -227,7 +227,7 @@ static int snd_opl3_timer2_stop(snd_timer_t * timer) */ -static struct _snd_timer_hardware snd_opl3_timer1 = +static struct snd_timer_hardware snd_opl3_timer1 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 80000, @@ -236,7 +236,7 @@ static struct _snd_timer_hardware snd_opl3_timer1 = .stop = snd_opl3_timer1_stop, }; -static struct _snd_timer_hardware snd_opl3_timer2 = +static struct snd_timer_hardware snd_opl3_timer2 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 320000, @@ -245,10 +245,10 @@ static struct _snd_timer_hardware snd_opl3_timer2 = .stop = snd_opl3_timer2_stop, }; -static int snd_opl3_timer1_init(opl3_t * opl3, int timer_no) +static int snd_opl3_timer1_init(struct snd_opl3 * opl3, int timer_no) { - snd_timer_t *timer = NULL; - snd_timer_id_t tid; + struct snd_timer *timer = NULL; + struct snd_timer_id tid; int err; tid.dev_class = SNDRV_TIMER_CLASS_CARD; @@ -265,10 +265,10 @@ static int snd_opl3_timer1_init(opl3_t * opl3, int timer_no) return err; } -static int snd_opl3_timer2_init(opl3_t * opl3, int timer_no) +static int snd_opl3_timer2_init(struct snd_opl3 * opl3, int timer_no) { - snd_timer_t *timer = NULL; - snd_timer_id_t tid; + struct snd_timer *timer = NULL; + struct snd_timer_id tid; int err; tid.dev_class = SNDRV_TIMER_CLASS_CARD; @@ -289,11 +289,11 @@ static int snd_opl3_timer2_init(opl3_t * opl3, int timer_no) */ -void snd_opl3_interrupt(snd_hwdep_t * hw) +void snd_opl3_interrupt(struct snd_hwdep * hw) { unsigned char status; - opl3_t *opl3; - snd_timer_t *timer; + struct snd_opl3 *opl3; + struct snd_timer *timer; if (hw == NULL) return; @@ -320,7 +320,7 @@ void snd_opl3_interrupt(snd_hwdep_t * hw) */ -static int snd_opl3_free(opl3_t *opl3) +static int snd_opl3_free(struct snd_opl3 *opl3) { snd_assert(opl3 != NULL, return -ENXIO); if (opl3->private_free) @@ -331,20 +331,20 @@ static int snd_opl3_free(opl3_t *opl3) return 0; } -static int snd_opl3_dev_free(snd_device_t *device) +static int snd_opl3_dev_free(struct snd_device *device) { - opl3_t *opl3 = device->device_data; + struct snd_opl3 *opl3 = device->device_data; return snd_opl3_free(opl3); } -int snd_opl3_new(snd_card_t *card, +int snd_opl3_new(struct snd_card *card, unsigned short hardware, - opl3_t **ropl3) + struct snd_opl3 **ropl3) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_opl3_dev_free, }; - opl3_t *opl3; + struct snd_opl3 *opl3; int err; *ropl3 = NULL; @@ -367,7 +367,7 @@ int snd_opl3_new(snd_card_t *card, return 0; } -int snd_opl3_init(opl3_t *opl3) +int snd_opl3_init(struct snd_opl3 *opl3) { if (! opl3->command) { printk(KERN_ERR "snd_opl3_init: command not defined!\n"); @@ -391,14 +391,14 @@ int snd_opl3_init(opl3_t *opl3) return 0; } -int snd_opl3_create(snd_card_t * card, +int snd_opl3_create(struct snd_card *card, unsigned long l_port, unsigned long r_port, unsigned short hardware, int integrated, - opl3_t ** ropl3) + struct snd_opl3 ** ropl3) { - opl3_t *opl3; + struct snd_opl3 *opl3; int err; *ropl3 = NULL; @@ -449,7 +449,7 @@ int snd_opl3_create(snd_card_t * card, return 0; } -int snd_opl3_timer_new(opl3_t * opl3, int timer1_dev, int timer2_dev) +int snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev) { int err; @@ -466,12 +466,12 @@ int snd_opl3_timer_new(opl3_t * opl3, int timer1_dev, int timer2_dev) return 0; } -int snd_opl3_hwdep_new(opl3_t * opl3, +int snd_opl3_hwdep_new(struct snd_opl3 * opl3, int device, int seq_device, - snd_hwdep_t ** rhwdep) + struct snd_hwdep ** rhwdep) { - snd_hwdep_t *hw; - snd_card_t *card = opl3->card; + struct snd_hwdep *hw; + struct snd_card *card = opl3->card; int err; if (rhwdep) @@ -514,9 +514,9 @@ int snd_opl3_hwdep_new(opl3_t * opl3, opl3->seq_dev_num = seq_device; #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) if (snd_seq_device_new(card, seq_device, SNDRV_SEQ_DEV_ID_OPL3, - sizeof(opl3_t*), &opl3->seq_dev) >= 0) { + sizeof(struct snd_opl3 *), &opl3->seq_dev) >= 0) { strcpy(opl3->seq_dev->name, hw->name); - *(opl3_t**)SNDRV_SEQ_DEVICE_ARGPTR(opl3->seq_dev) = opl3; + *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(opl3->seq_dev) = opl3; } #endif if (rhwdep) diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 93d6740..48c480e 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -60,7 +60,7 @@ static char opl3_volume_table[128] = }; void snd_opl3_calc_volume(unsigned char *volbyte, int vel, - snd_midi_channel_t *chan) + struct snd_midi_channel *chan) { int oldvol, newvol, n; int volume; @@ -93,7 +93,7 @@ static short opl3_note_table[16] = }; static void snd_opl3_calc_pitch(unsigned char *fnum, unsigned char *blocknum, - int note, snd_midi_channel_t *chan) + int note, struct snd_midi_channel *chan) { int block = ((note / 12) & 0x07) - 1; int idx = (note % 12) + 2; @@ -121,7 +121,7 @@ static void snd_opl3_calc_pitch(unsigned char *fnum, unsigned char *blocknum, #ifdef DEBUG_ALLOC -static void debug_alloc(opl3_t *opl3, char *s, int voice) { +static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice) { int i; char *str = "x.24"; @@ -135,12 +135,12 @@ static void debug_alloc(opl3_t *opl3, char *s, int voice) { /* * Get a FM voice (channel) to play a note on. */ -static int opl3_get_voice(opl3_t *opl3, int instr_4op, - snd_midi_channel_t *chan) { +static int opl3_get_voice(struct snd_opl3 *opl3, int instr_4op, + struct snd_midi_channel *chan) { int chan_4op_1; /* first voice for 4op instrument */ int chan_4op_2; /* second voice for 4op instrument */ - snd_opl3_voice_t *vp, *vp2; + struct snd_opl3_voice *vp, *vp2; unsigned int voice_time; int i; @@ -237,13 +237,13 @@ static int opl3_get_voice(opl3_t *opl3, int instr_4op, void snd_opl3_timer_func(unsigned long data) { - opl3_t *opl3 = (opl3_t *)data; + struct snd_opl3 *opl3 = (struct snd_opl3 *)data; int again = 0; int i; spin_lock(&opl3->sys_timer_lock); for (i = 0; i < opl3->max_voices; i++) { - snd_opl3_voice_t *vp = &opl3->voices[i]; + struct snd_opl3_voice *vp = &opl3->voices[i]; if (vp->state > 0 && vp->note_off_check) { if (vp->note_off == jiffies) snd_opl3_note_off(opl3, vp->note, 0, vp->chan); @@ -263,7 +263,7 @@ void snd_opl3_timer_func(unsigned long data) /* * Start system timer */ -static void snd_opl3_start_timer(opl3_t *opl3) +static void snd_opl3_start_timer(struct snd_opl3 *opl3) { unsigned long flags; spin_lock_irqsave(&opl3->sys_timer_lock, flags); @@ -285,15 +285,15 @@ static int snd_opl3_oss_map[MAX_OPL3_VOICES] = { /* * Start a note. */ -void snd_opl3_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) +void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) { - opl3_t *opl3; - snd_seq_instr_t wanted; - snd_seq_kinstr_t *kinstr; + struct snd_opl3 *opl3; + struct snd_seq_instr wanted; + struct snd_seq_kinstr *kinstr; int instr_4op; int voice; - snd_opl3_voice_t *vp, *vp2; + struct snd_opl3_voice *vp, *vp2; unsigned short connect_mask; unsigned char connection; unsigned char vol_op[4]; @@ -310,7 +310,7 @@ void snd_opl3_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) unsigned char fnum, blocknum; int i; - fm_instrument_t *fm; + struct fm_instrument *fm; unsigned long flags; opl3 = p; @@ -615,13 +615,13 @@ void snd_opl3_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) spin_unlock_irqrestore(&opl3->voice_lock, flags); } -static void snd_opl3_kill_voice(opl3_t *opl3, int voice) +static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice) { unsigned short reg_side; unsigned char voice_offset; unsigned short opl3_reg; - snd_opl3_voice_t *vp, *vp2; + struct snd_opl3_voice *vp, *vp2; snd_assert(voice < MAX_OPL3_VOICES, return); @@ -663,12 +663,12 @@ static void snd_opl3_kill_voice(opl3_t *opl3, int voice) /* * Release a note in response to a midi note off. */ -void snd_opl3_note_off(void *p, int note, int vel, snd_midi_channel_t *chan) +void snd_opl3_note_off(void *p, int note, int vel, struct snd_midi_channel *chan) { - opl3_t *opl3; + struct snd_opl3 *opl3; int voice; - snd_opl3_voice_t *vp; + struct snd_opl3_voice *vp; unsigned long flags; @@ -708,9 +708,9 @@ void snd_opl3_note_off(void *p, int note, int vel, snd_midi_channel_t *chan) /* * key pressure change */ -void snd_opl3_key_press(void *p, int note, int vel, snd_midi_channel_t *chan) +void snd_opl3_key_press(void *p, int note, int vel, struct snd_midi_channel *chan) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI @@ -722,9 +722,9 @@ void snd_opl3_key_press(void *p, int note, int vel, snd_midi_channel_t *chan) /* * terminate note */ -void snd_opl3_terminate_note(void *p, int note, snd_midi_channel_t *chan) +void snd_opl3_terminate_note(void *p, int note, struct snd_midi_channel *chan) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI @@ -733,7 +733,7 @@ void snd_opl3_terminate_note(void *p, int note, snd_midi_channel_t *chan) #endif } -static void snd_opl3_update_pitch(opl3_t *opl3, int voice) +static void snd_opl3_update_pitch(struct snd_opl3 *opl3, int voice) { unsigned short reg_side; unsigned char voice_offset; @@ -741,7 +741,7 @@ static void snd_opl3_update_pitch(opl3_t *opl3, int voice) unsigned char fnum, blocknum; - snd_opl3_voice_t *vp; + struct snd_opl3_voice *vp; snd_assert(voice < MAX_OPL3_VOICES, return); @@ -780,10 +780,10 @@ static void snd_opl3_update_pitch(opl3_t *opl3, int voice) /* * Update voice pitch controller */ -static void snd_opl3_pitch_ctrl(opl3_t *opl3, snd_midi_channel_t *chan) +static void snd_opl3_pitch_ctrl(struct snd_opl3 *opl3, struct snd_midi_channel *chan) { int voice; - snd_opl3_voice_t *vp; + struct snd_opl3_voice *vp; unsigned long flags; @@ -810,9 +810,9 @@ static void snd_opl3_pitch_ctrl(opl3_t *opl3, snd_midi_channel_t *chan) * Deal with a controler type event. This includes all types of * control events, not just the midi controllers */ -void snd_opl3_control(void *p, int type, snd_midi_channel_t *chan) +void snd_opl3_control(void *p, int type, struct snd_midi_channel *chan) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI @@ -846,10 +846,10 @@ void snd_opl3_control(void *p, int type, snd_midi_channel_t *chan) /* * NRPN events */ -void snd_opl3_nrpn(void *p, snd_midi_channel_t *chan, - snd_midi_channel_set_t *chset) +void snd_opl3_nrpn(void *p, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI @@ -862,9 +862,9 @@ void snd_opl3_nrpn(void *p, snd_midi_channel_t *chan, * receive sysex */ void snd_opl3_sysex(void *p, unsigned char *buf, int len, - int parsed, snd_midi_channel_set_t *chset) + int parsed, struct snd_midi_channel_set *chset) { - opl3_t *opl3; + struct snd_opl3 *opl3; opl3 = p; #ifdef DEBUG_MIDI diff --git a/sound/drivers/opl3/opl3_oss.c b/sound/drivers/opl3/opl3_oss.c index 21a2b40..31f1f2e 100644 --- a/sound/drivers/opl3/opl3_oss.c +++ b/sound/drivers/opl3/opl3_oss.c @@ -21,11 +21,11 @@ #include "opl3_voice.h" #include <linux/slab.h> -static int snd_opl3_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure); -static int snd_opl3_close_seq_oss(snd_seq_oss_arg_t *arg); -static int snd_opl3_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, unsigned long ioarg); -static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, const char __user *buf, int offs, int count); -static int snd_opl3_reset_seq_oss(snd_seq_oss_arg_t *arg); +static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure); +static int snd_opl3_close_seq_oss(struct snd_seq_oss_arg *arg); +static int snd_opl3_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, unsigned long ioarg); +static int snd_opl3_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format, const char __user *buf, int offs, int count); +static int snd_opl3_reset_seq_oss(struct snd_seq_oss_arg *arg); /* */ @@ -43,9 +43,9 @@ static inline void snd_leave_user(mm_segment_t fs) /* operators */ -extern snd_midi_op_t opl3_ops; +extern struct snd_midi_op opl3_ops; -static snd_seq_oss_callback_t oss_callback = { +static struct snd_seq_oss_callback oss_callback = { .owner = THIS_MODULE, .open = snd_opl3_open_seq_oss, .close = snd_opl3_close_seq_oss, @@ -54,10 +54,10 @@ static snd_seq_oss_callback_t oss_callback = { .reset = snd_opl3_reset_seq_oss, }; -static int snd_opl3_oss_event_input(snd_seq_event_t *ev, int direct, +static int snd_opl3_oss_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - opl3_t *opl3 = private_data; + struct snd_opl3 *opl3 = private_data; if (ev->type != SNDRV_SEQ_EVENT_OSS) snd_midi_process_event(&opl3_ops, ev, opl3->oss_chset); @@ -68,14 +68,14 @@ static int snd_opl3_oss_event_input(snd_seq_event_t *ev, int direct, static void snd_opl3_oss_free_port(void *private_data) { - opl3_t *opl3 = private_data; + struct snd_opl3 *opl3 = private_data; snd_midi_channel_free_set(opl3->oss_chset); } -static int snd_opl3_oss_create_port(opl3_t * opl3) +static int snd_opl3_oss_create_port(struct snd_opl3 * opl3) { - snd_seq_port_callback_t callbacks; + struct snd_seq_port_callback callbacks; char name[32]; int voices, opl_ver; @@ -113,13 +113,13 @@ static int snd_opl3_oss_create_port(opl3_t * opl3) /* ------------------------------ */ /* register OSS synth */ -void snd_opl3_init_seq_oss(opl3_t *opl3, char *name) +void snd_opl3_init_seq_oss(struct snd_opl3 *opl3, char *name) { - snd_seq_oss_reg_t *arg; - snd_seq_device_t *dev; + struct snd_seq_oss_reg *arg; + struct snd_seq_device *dev; if (snd_seq_device_new(opl3->card, 0, SNDRV_SEQ_DEV_ID_OSS, - sizeof(snd_seq_oss_reg_t), &dev) < 0) + sizeof(struct snd_seq_oss_reg), &dev) < 0) return; opl3->oss_seq_dev = dev; @@ -143,7 +143,7 @@ void snd_opl3_init_seq_oss(opl3_t *opl3, char *name) } /* unregister */ -void snd_opl3_free_seq_oss(opl3_t *opl3) +void snd_opl3_free_seq_oss(struct snd_opl3 *opl3) { if (opl3->oss_seq_dev) { snd_device_free(opl3->card, opl3->oss_seq_dev); @@ -154,9 +154,9 @@ void snd_opl3_free_seq_oss(opl3_t *opl3) /* ------------------------------ */ /* open OSS sequencer */ -static int snd_opl3_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure) +static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure) { - opl3_t *opl3 = closure; + struct snd_opl3 *opl3 = closure; int err; snd_assert(arg != NULL, return -ENXIO); @@ -177,9 +177,9 @@ static int snd_opl3_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure) } /* close OSS sequencer */ -static int snd_opl3_close_seq_oss(snd_seq_oss_arg_t *arg) +static int snd_opl3_close_seq_oss(struct snd_seq_oss_arg *arg) { - opl3_t *opl3; + struct snd_opl3 *opl3; snd_assert(arg != NULL, return -ENXIO); opl3 = arg->private_data; @@ -206,10 +206,10 @@ static int snd_opl3_close_seq_oss(snd_seq_oss_arg_t *arg) /* from sound_config.h */ #define SBFM_MAXINSTR 256 -static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, +static int snd_opl3_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format, const char __user *buf, int offs, int count) { - opl3_t *opl3; + struct snd_opl3 *opl3; int err = -EINVAL; snd_assert(arg != NULL, return -ENXIO); @@ -219,11 +219,11 @@ static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, struct sbi_instrument sbi; size_t size; - snd_seq_instr_header_t *put; - snd_seq_instr_data_t *data; - fm_xinstrument_t *xinstr; + struct snd_seq_instr_header *put; + struct snd_seq_instr_data *data; + struct fm_xinstrument *xinstr; - snd_seq_event_t ev; + struct snd_seq_event ev; int i; mm_segment_t fs; @@ -240,7 +240,7 @@ static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, return -EINVAL; } - size = sizeof(*put) + sizeof(fm_xinstrument_t); + size = sizeof(*put) + sizeof(struct fm_xinstrument); put = kzalloc(size, GFP_KERNEL); if (put == NULL) return -ENOMEM; @@ -249,7 +249,7 @@ static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, data->type = SNDRV_SEQ_INSTR_ATYPE_DATA; strcpy(data->data.format, SNDRV_SEQ_INSTR_ID_OPL2_3); /* build data section */ - xinstr = (fm_xinstrument_t *)(data + 1); + xinstr = (struct fm_xinstrument *)(data + 1); xinstr->stype = FM_STRU_INSTR; for (i = 0; i < 2; i++) { @@ -296,7 +296,7 @@ static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, err = snd_seq_instr_event(&opl3->fm_ops, opl3->ilist, &ev, opl3->seq_client, 0, 0); if (err == -EBUSY) { - snd_seq_instr_header_t remove; + struct snd_seq_instr_header remove; memset (&remove, 0, sizeof(remove)); remove.cmd = SNDRV_SEQ_INSTR_FREE_CMD_SINGLE; @@ -319,10 +319,10 @@ static int snd_opl3_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, } /* ioctl */ -static int snd_opl3_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, +static int snd_opl3_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, unsigned long ioarg) { - opl3_t *opl3; + struct snd_opl3 *opl3; snd_assert(arg != NULL, return -ENXIO); opl3 = arg->private_data; @@ -345,9 +345,9 @@ static int snd_opl3_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, } /* reset device */ -static int snd_opl3_reset_seq_oss(snd_seq_oss_arg_t *arg) +static int snd_opl3_reset_seq_oss(struct snd_seq_oss_arg *arg) { - opl3_t *opl3; + struct snd_opl3 *opl3; snd_assert(arg != NULL, return -ENXIO); opl3 = arg->private_data; diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 136964b..1886b29 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -35,7 +35,7 @@ int use_internal_drums = 0; module_param(use_internal_drums, bool, 0444); MODULE_PARM_DESC(use_internal_drums, "Enable internal OPL2/3 drums."); -int snd_opl3_synth_use_inc(opl3_t * opl3) +int snd_opl3_synth_use_inc(struct snd_opl3 * opl3) { if (!try_module_get(opl3->card->module)) return -EFAULT; @@ -43,12 +43,12 @@ int snd_opl3_synth_use_inc(opl3_t * opl3) } -void snd_opl3_synth_use_dec(opl3_t * opl3) +void snd_opl3_synth_use_dec(struct snd_opl3 * opl3) { module_put(opl3->card->module); } -int snd_opl3_synth_setup(opl3_t * opl3) +int snd_opl3_synth_setup(struct snd_opl3 * opl3) { int idx; @@ -78,7 +78,7 @@ int snd_opl3_synth_setup(opl3_t * opl3) return 0; } -void snd_opl3_synth_cleanup(opl3_t * opl3) +void snd_opl3_synth_cleanup(struct snd_opl3 * opl3) { unsigned long flags; @@ -96,9 +96,9 @@ void snd_opl3_synth_cleanup(opl3_t * opl3) up(&opl3->access_mutex); } -static int snd_opl3_synth_use(void *private_data, snd_seq_port_subscribe_t * info) +static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe * info) { - opl3_t *opl3 = private_data; + struct snd_opl3 *opl3 = private_data; int err; if ((err = snd_opl3_synth_setup(opl3)) < 0) @@ -123,9 +123,9 @@ static int snd_opl3_synth_use(void *private_data, snd_seq_port_subscribe_t * inf return 0; } -static int snd_opl3_synth_unuse(void *private_data, snd_seq_port_subscribe_t * info) +static int snd_opl3_synth_unuse(void *private_data, struct snd_seq_port_subscribe * info) { - opl3_t *opl3 = private_data; + struct snd_opl3 *opl3 = private_data; snd_opl3_synth_cleanup(opl3); @@ -137,7 +137,7 @@ static int snd_opl3_synth_unuse(void *private_data, snd_seq_port_subscribe_t * i /* * MIDI emulation operators */ -snd_midi_op_t opl3_ops = { +struct snd_midi_op opl3_ops = { .note_on = snd_opl3_note_on, .note_off = snd_opl3_note_off, .key_press = snd_opl3_key_press, @@ -147,10 +147,10 @@ snd_midi_op_t opl3_ops = { .sysex = snd_opl3_sysex, }; -static int snd_opl3_synth_event_input(snd_seq_event_t * ev, int direct, +static int snd_opl3_synth_event_input(struct snd_seq_event * ev, int direct, void *private_data, int atomic, int hop) { - opl3_t *opl3 = private_data; + struct snd_opl3 *opl3 = private_data; if (ev->type >= SNDRV_SEQ_EVENT_INSTR_BEGIN && ev->type <= SNDRV_SEQ_EVENT_INSTR_CHANGE) { @@ -168,14 +168,14 @@ static int snd_opl3_synth_event_input(snd_seq_event_t * ev, int direct, static void snd_opl3_synth_free_port(void *private_data) { - opl3_t *opl3 = private_data; + struct snd_opl3 *opl3 = private_data; snd_midi_channel_free_set(opl3->chset); } -static int snd_opl3_synth_create_port(opl3_t * opl3) +static int snd_opl3_synth_create_port(struct snd_opl3 * opl3) { - snd_seq_port_callback_t callbacks; + struct snd_seq_port_callback callbacks; char name[32]; int voices, opl_ver; @@ -215,15 +215,15 @@ static int snd_opl3_synth_create_port(opl3_t * opl3) /* ------------------------------ */ -static int snd_opl3_seq_new_device(snd_seq_device_t *dev) +static int snd_opl3_seq_new_device(struct snd_seq_device *dev) { - opl3_t *opl3; + struct snd_opl3 *opl3; int client; - snd_seq_client_callback_t callbacks; - snd_seq_client_info_t cinfo; + struct snd_seq_client_callback callbacks; + struct snd_seq_client_info cinfo; int opl_ver; - opl3 = *(opl3_t **)SNDRV_SEQ_DEVICE_ARGPTR(dev); + opl3 = *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (opl3 == NULL) return -EINVAL; @@ -273,11 +273,11 @@ static int snd_opl3_seq_new_device(snd_seq_device_t *dev) return 0; } -static int snd_opl3_seq_delete_device(snd_seq_device_t *dev) +static int snd_opl3_seq_delete_device(struct snd_seq_device *dev) { - opl3_t *opl3; + struct snd_opl3 *opl3; - opl3 = *(opl3_t **)SNDRV_SEQ_DEVICE_ARGPTR(dev); + opl3 = *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (opl3 == NULL) return -EINVAL; @@ -295,14 +295,14 @@ static int snd_opl3_seq_delete_device(snd_seq_device_t *dev) static int __init alsa_opl3_seq_init(void) { - static snd_seq_dev_ops_t ops = + static struct snd_seq_dev_ops ops = { snd_opl3_seq_new_device, snd_opl3_seq_delete_device }; return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OPL3, &ops, - sizeof(opl3_t*)); + sizeof(struct snd_opl3 *)); } static void __exit alsa_opl3_seq_exit(void) diff --git a/sound/drivers/opl3/opl3_synth.c b/sound/drivers/opl3/opl3_synth.c index 04f9f95..3534a0e 100644 --- a/sound/drivers/opl3/opl3_synth.c +++ b/sound/drivers/opl3/opl3_synth.c @@ -61,20 +61,20 @@ char snd_opl3_regmap[MAX_OPL2_VOICES][4] = /* * prototypes */ -static int snd_opl3_play_note(opl3_t * opl3, snd_dm_fm_note_t * note); -static int snd_opl3_set_voice(opl3_t * opl3, snd_dm_fm_voice_t * voice); -static int snd_opl3_set_params(opl3_t * opl3, snd_dm_fm_params_t * params); -static int snd_opl3_set_mode(opl3_t * opl3, int mode); -static int snd_opl3_set_connection(opl3_t * opl3, int connection); +static int snd_opl3_play_note(struct snd_opl3 * opl3, struct snd_dm_fm_note * note); +static int snd_opl3_set_voice(struct snd_opl3 * opl3, struct snd_dm_fm_voice * voice); +static int snd_opl3_set_params(struct snd_opl3 * opl3, struct snd_dm_fm_params * params); +static int snd_opl3_set_mode(struct snd_opl3 * opl3, int mode); +static int snd_opl3_set_connection(struct snd_opl3 * opl3, int connection); /* ------------------------------ */ /* * open the device exclusively */ -int snd_opl3_open(snd_hwdep_t * hw, struct file *file) +int snd_opl3_open(struct snd_hwdep * hw, struct file *file) { - opl3_t *opl3 = hw->private_data; + struct snd_opl3 *opl3 = hw->private_data; down(&opl3->access_mutex); if (opl3->used) { @@ -90,10 +90,10 @@ int snd_opl3_open(snd_hwdep_t * hw, struct file *file) /* * ioctl for hwdep device: */ -int snd_opl3_ioctl(snd_hwdep_t * hw, struct file *file, +int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) { - opl3_t *opl3 = hw->private_data; + struct snd_opl3 *opl3 = hw->private_data; void __user *argp = (void __user *)arg; snd_assert(opl3 != NULL, return -EINVAL); @@ -102,11 +102,11 @@ int snd_opl3_ioctl(snd_hwdep_t * hw, struct file *file, /* get information */ case SNDRV_DM_FM_IOCTL_INFO: { - snd_dm_fm_info_t info; + struct snd_dm_fm_info info; info.fm_mode = opl3->fm_mode; info.rhythm = opl3->rhythm; - if (copy_to_user(argp, &info, sizeof(snd_dm_fm_info_t))) + if (copy_to_user(argp, &info, sizeof(struct snd_dm_fm_info))) return -EFAULT; return 0; } @@ -123,8 +123,8 @@ int snd_opl3_ioctl(snd_hwdep_t * hw, struct file *file, case SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE: #endif { - snd_dm_fm_note_t note; - if (copy_from_user(¬e, argp, sizeof(snd_dm_fm_note_t))) + struct snd_dm_fm_note note; + if (copy_from_user(¬e, argp, sizeof(struct snd_dm_fm_note))) return -EFAULT; return snd_opl3_play_note(opl3, ¬e); } @@ -134,8 +134,8 @@ int snd_opl3_ioctl(snd_hwdep_t * hw, struct file *file, case SNDRV_DM_FM_OSS_IOCTL_SET_VOICE: #endif { - snd_dm_fm_voice_t voice; - if (copy_from_user(&voice, argp, sizeof(snd_dm_fm_voice_t))) + struct snd_dm_fm_voice voice; + if (copy_from_user(&voice, argp, sizeof(struct snd_dm_fm_voice))) return -EFAULT; return snd_opl3_set_voice(opl3, &voice); } @@ -145,8 +145,8 @@ int snd_opl3_ioctl(snd_hwdep_t * hw, struct file *file, case SNDRV_DM_FM_OSS_IOCTL_SET_PARAMS: #endif { - snd_dm_fm_params_t params; - if (copy_from_user(¶ms, argp, sizeof(snd_dm_fm_params_t))) + struct snd_dm_fm_params params; + if (copy_from_user(¶ms, argp, sizeof(struct snd_dm_fm_params))) return -EFAULT; return snd_opl3_set_params(opl3, ¶ms); } @@ -174,9 +174,9 @@ int snd_opl3_ioctl(snd_hwdep_t * hw, struct file *file, /* * close the device */ -int snd_opl3_release(snd_hwdep_t * hw, struct file *file) +int snd_opl3_release(struct snd_hwdep * hw, struct file *file) { - opl3_t *opl3 = hw->private_data; + struct snd_opl3 *opl3 = hw->private_data; snd_opl3_reset(opl3); down(&opl3->access_mutex); @@ -188,7 +188,7 @@ int snd_opl3_release(snd_hwdep_t * hw, struct file *file) /* ------------------------------ */ -void snd_opl3_reset(opl3_t * opl3) +void snd_opl3_reset(struct snd_opl3 * opl3) { unsigned short opl3_reg; @@ -229,7 +229,7 @@ void snd_opl3_reset(opl3_t * opl3) } -static int snd_opl3_play_note(opl3_t * opl3, snd_dm_fm_note_t * note) +static int snd_opl3_play_note(struct snd_opl3 * opl3, struct snd_dm_fm_note * note) { unsigned short reg_side; unsigned char voice_offset; @@ -276,7 +276,7 @@ static int snd_opl3_play_note(opl3_t * opl3, snd_dm_fm_note_t * note) } -static int snd_opl3_set_voice(opl3_t * opl3, snd_dm_fm_voice_t * voice) +static int snd_opl3_set_voice(struct snd_opl3 * opl3, struct snd_dm_fm_voice * voice) { unsigned short reg_side; unsigned char op_offset; @@ -378,7 +378,7 @@ static int snd_opl3_set_voice(opl3_t * opl3, snd_dm_fm_voice_t * voice) return 0; } -static int snd_opl3_set_params(opl3_t * opl3, snd_dm_fm_params_t * params) +static int snd_opl3_set_params(struct snd_opl3 * opl3, struct snd_dm_fm_params * params) { unsigned char reg_val; @@ -418,7 +418,7 @@ static int snd_opl3_set_params(opl3_t * opl3, snd_dm_fm_params_t * params) return 0; } -static int snd_opl3_set_mode(opl3_t * opl3, int mode) +static int snd_opl3_set_mode(struct snd_opl3 * opl3, int mode) { if ((mode == SNDRV_DM_FM_MODE_OPL3) && (opl3->hardware < OPL3_HW_OPL3)) return -EINVAL; @@ -430,7 +430,7 @@ static int snd_opl3_set_mode(opl3_t * opl3, int mode) return 0; } -static int snd_opl3_set_connection(opl3_t * opl3, int connection) +static int snd_opl3_set_connection(struct snd_opl3 * opl3, int connection) { unsigned char reg_val; diff --git a/sound/drivers/opl3/opl3_voice.h b/sound/drivers/opl3/opl3_voice.h index 63346a5..a371c075 100644 --- a/sound/drivers/opl3/opl3_voice.h +++ b/sound/drivers/opl3/opl3_voice.h @@ -22,31 +22,31 @@ #include <sound/opl3.h> /* Prototypes for opl3_seq.c */ -int snd_opl3_synth_use_inc(opl3_t * opl3); -void snd_opl3_synth_use_dec(opl3_t * opl3); -int snd_opl3_synth_setup(opl3_t * opl3); -void snd_opl3_synth_cleanup(opl3_t * opl3); +int snd_opl3_synth_use_inc(struct snd_opl3 * opl3); +void snd_opl3_synth_use_dec(struct snd_opl3 * opl3); +int snd_opl3_synth_setup(struct snd_opl3 * opl3); +void snd_opl3_synth_cleanup(struct snd_opl3 * opl3); /* Prototypes for opl3_midi.c */ void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan); void snd_opl3_note_off(void *p, int note, int vel, struct snd_midi_channel *chan); void snd_opl3_key_press(void *p, int note, int vel, struct snd_midi_channel *chan); -void snd_opl3_terminate_note(void *p, int note, snd_midi_channel_t *chan); +void snd_opl3_terminate_note(void *p, int note, struct snd_midi_channel *chan); void snd_opl3_control(void *p, int type, struct snd_midi_channel *chan); -void snd_opl3_nrpn(void *p, snd_midi_channel_t *chan, snd_midi_channel_set_t *chset); -void snd_opl3_sysex(void *p, unsigned char *buf, int len, int parsed, snd_midi_channel_set_t *chset); +void snd_opl3_nrpn(void *p, struct snd_midi_channel *chan, struct snd_midi_channel_set *chset); +void snd_opl3_sysex(void *p, unsigned char *buf, int len, int parsed, struct snd_midi_channel_set *chset); -void snd_opl3_calc_volume(unsigned char *reg, int vel, snd_midi_channel_t *chan); +void snd_opl3_calc_volume(unsigned char *reg, int vel, struct snd_midi_channel *chan); void snd_opl3_timer_func(unsigned long data); /* Prototypes for opl3_drums.c */ -void snd_opl3_load_drums(opl3_t *opl3); -void snd_opl3_drum_switch(opl3_t *opl3, int note, int on_off, int vel, snd_midi_channel_t *chan); +void snd_opl3_load_drums(struct snd_opl3 *opl3); +void snd_opl3_drum_switch(struct snd_opl3 *opl3, int note, int on_off, int vel, struct snd_midi_channel *chan); /* Prototypes for opl3_oss.c */ #ifdef CONFIG_SND_SEQUENCER_OSS -void snd_opl3_init_seq_oss(opl3_t *opl3, char *name); -void snd_opl3_free_seq_oss(opl3_t *opl3); +void snd_opl3_init_seq_oss(struct snd_opl3 *opl3, char *name); +void snd_opl3_free_seq_oss(struct snd_opl3 *opl3); #endif #endif -- cgit v1.1 From a42dd420bea7a5cd130162183d95f640c299a337 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:13:47 +0100 Subject: [ALSA] Remove xxx_t typedefs: OPL4 Modules: OPL4 Remove xxx_t typedefs from the OPL4 driver Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/opl4.h | 6 +- sound/drivers/opl4/opl4_lib.c | 40 +++--- sound/drivers/opl4/opl4_local.h | 68 +++++------ sound/drivers/opl4/opl4_mixer.c | 16 +-- sound/drivers/opl4/opl4_proc.c | 24 ++-- sound/drivers/opl4/opl4_seq.c | 42 +++---- sound/drivers/opl4/opl4_synth.c | 76 ++++++------ sound/drivers/opl4/yrw801.c | 262 ++++++++++++++++++++-------------------- 8 files changed, 269 insertions(+), 265 deletions(-) diff --git a/include/sound/opl4.h b/include/sound/opl4.h index 20c0442..60ae845 100644 --- a/include/sound/opl4.h +++ b/include/sound/opl4.h @@ -22,11 +22,11 @@ #include <sound/opl3.h> -typedef struct opl4 opl4_t; +struct snd_opl4; -extern int snd_opl4_create(snd_card_t *card, +extern int snd_opl4_create(struct snd_card *card, unsigned long fm_port, unsigned long pcm_port, int seq_device, - opl3_t **opl3, opl4_t **opl4); + struct snd_opl3 **opl3, struct snd_opl4 **opl4); #endif /* __SOUND_OPL4_H */ diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c index 4ae5dd8..ddfc10d 100644 --- a/sound/drivers/opl4/opl4_lib.c +++ b/sound/drivers/opl4/opl4_lib.c @@ -27,14 +27,14 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); MODULE_DESCRIPTION("OPL4 driver"); MODULE_LICENSE("GPL"); -static void inline snd_opl4_wait(opl4_t *opl4) +static void inline snd_opl4_wait(struct snd_opl4 *opl4) { int timeout = 10; while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0) ; } -void snd_opl4_write(opl4_t *opl4, u8 reg, u8 value) +void snd_opl4_write(struct snd_opl4 *opl4, u8 reg, u8 value) { snd_opl4_wait(opl4); outb(reg, opl4->pcm_port); @@ -43,7 +43,7 @@ void snd_opl4_write(opl4_t *opl4, u8 reg, u8 value) outb(value, opl4->pcm_port + 1); } -u8 snd_opl4_read(opl4_t *opl4, u8 reg) +u8 snd_opl4_read(struct snd_opl4 *opl4, u8 reg) { snd_opl4_wait(opl4); outb(reg, opl4->pcm_port); @@ -52,7 +52,7 @@ u8 snd_opl4_read(opl4_t *opl4, u8 reg) return inb(opl4->pcm_port + 1); } -void snd_opl4_read_memory(opl4_t *opl4, char *buf, int offset, int size) +void snd_opl4_read_memory(struct snd_opl4 *opl4, char *buf, int offset, int size) { unsigned long flags; u8 memcfg; @@ -76,7 +76,7 @@ void snd_opl4_read_memory(opl4_t *opl4, char *buf, int offset, int size) spin_unlock_irqrestore(&opl4->reg_lock, flags); } -void snd_opl4_write_memory(opl4_t *opl4, const char *buf, int offset, int size) +void snd_opl4_write_memory(struct snd_opl4 *opl4, const char *buf, int offset, int size) { unsigned long flags; u8 memcfg; @@ -100,7 +100,7 @@ void snd_opl4_write_memory(opl4_t *opl4, const char *buf, int offset, int size) spin_unlock_irqrestore(&opl4->reg_lock, flags); } -static void snd_opl4_enable_opl4(opl4_t *opl4) +static void snd_opl4_enable_opl4(struct snd_opl4 *opl4) { outb(OPL3_REG_MODE, opl4->fm_port + 2); inb(opl4->fm_port); @@ -110,7 +110,7 @@ static void snd_opl4_enable_opl4(opl4_t *opl4) inb(opl4->fm_port); } -static int snd_opl4_detect(opl4_t *opl4) +static int snd_opl4_detect(struct snd_opl4 *opl4) { u8 id1, id2; @@ -144,19 +144,19 @@ static int snd_opl4_detect(opl4_t *opl4) } #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) -static void snd_opl4_seq_dev_free(snd_seq_device_t *seq_dev) +static void snd_opl4_seq_dev_free(struct snd_seq_device *seq_dev) { - opl4_t *opl4 = seq_dev->private_data; + struct snd_opl4 *opl4 = seq_dev->private_data; opl4->seq_dev = NULL; } -static int snd_opl4_create_seq_dev(opl4_t *opl4, int seq_device) +static int snd_opl4_create_seq_dev(struct snd_opl4 *opl4, int seq_device) { opl4->seq_dev_num = seq_device; if (snd_seq_device_new(opl4->card, seq_device, SNDRV_SEQ_DEV_ID_OPL4, - sizeof(opl4_t *), &opl4->seq_dev) >= 0) { + sizeof(struct snd_opl4 *), &opl4->seq_dev) >= 0) { strcpy(opl4->seq_dev->name, "OPL4 Wavetable"); - *(opl4_t **)SNDRV_SEQ_DEVICE_ARGPTR(opl4->seq_dev) = opl4; + *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(opl4->seq_dev) = opl4; opl4->seq_dev->private_data = opl4; opl4->seq_dev->private_free = snd_opl4_seq_dev_free; } @@ -164,7 +164,7 @@ static int snd_opl4_create_seq_dev(opl4_t *opl4, int seq_device) } #endif -static void snd_opl4_free(opl4_t *opl4) +static void snd_opl4_free(struct snd_opl4 *opl4) { #ifdef CONFIG_PROC_FS snd_opl4_free_proc(opl4); @@ -174,22 +174,22 @@ static void snd_opl4_free(opl4_t *opl4) kfree(opl4); } -static int snd_opl4_dev_free(snd_device_t *device) +static int snd_opl4_dev_free(struct snd_device *device) { - opl4_t *opl4 = device->device_data; + struct snd_opl4 *opl4 = device->device_data; snd_opl4_free(opl4); return 0; } -int snd_opl4_create(snd_card_t *card, +int snd_opl4_create(struct snd_card *card, unsigned long fm_port, unsigned long pcm_port, int seq_device, - opl3_t **ropl3, opl4_t **ropl4) + struct snd_opl3 **ropl3, struct snd_opl4 **ropl4) { - opl4_t *opl4; - opl3_t *opl3; + struct snd_opl4 *opl4; + struct snd_opl3 *opl3; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_opl4_dev_free }; diff --git a/sound/drivers/opl4/opl4_local.h b/sound/drivers/opl4/opl4_local.h index c455680..7e088a4 100644 --- a/sound/drivers/opl4/opl4_local.h +++ b/sound/drivers/opl4/opl4_local.h @@ -131,7 +131,7 @@ #define SNDRV_SEQ_DEV_ID_OPL4 "opl4-synth" -typedef struct opl4_sound { +struct opl4_sound { u16 tone; s16 pitch_offset; u8 key_scaling; @@ -144,42 +144,42 @@ typedef struct opl4_sound { u8 reg_level_decay2; u8 reg_release_correction; u8 reg_tremolo; -} opl4_sound_t; +}; -typedef struct opl4_region { +struct opl4_region { u8 key_min, key_max; - opl4_sound_t sound; -} opl4_region_t; + struct opl4_sound sound; +}; -typedef struct opl4_region_ptr { +struct opl4_region_ptr { int count; - const opl4_region_t *regions; -} opl4_region_ptr_t; + const struct opl4_region *regions; +}; -typedef struct opl4_voice { +struct opl4_voice { struct list_head list; int number; - snd_midi_channel_t *chan; + struct snd_midi_channel *chan; int note; int velocity; - const opl4_sound_t *sound; + const struct opl4_sound *sound; u8 level_direct; u8 reg_f_number; u8 reg_misc; u8 reg_lfo_vibrato; -} opl4_voice_t; +}; -struct opl4 { +struct snd_opl4 { unsigned long fm_port; unsigned long pcm_port; struct resource *res_fm_port; struct resource *res_pcm_port; unsigned short hardware; spinlock_t reg_lock; - snd_card_t *card; + struct snd_card *card; #ifdef CONFIG_PROC_FS - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; int memory_access; #endif struct semaphore access_mutex; @@ -189,44 +189,44 @@ struct opl4 { int seq_dev_num; int seq_client; - snd_seq_device_t *seq_dev; + struct snd_seq_device *seq_dev; - snd_midi_channel_set_t *chset; - opl4_voice_t voices[OPL4_MAX_VOICES]; + struct snd_midi_channel_set *chset; + struct opl4_voice voices[OPL4_MAX_VOICES]; struct list_head off_voices; struct list_head on_voices; #endif }; /* opl4_lib.c */ -void snd_opl4_write(opl4_t *opl4, u8 reg, u8 value); -u8 snd_opl4_read(opl4_t *opl4, u8 reg); -void snd_opl4_read_memory(opl4_t *opl4, char *buf, int offset, int size); -void snd_opl4_write_memory(opl4_t *opl4, const char *buf, int offset, int size); +void snd_opl4_write(struct snd_opl4 *opl4, u8 reg, u8 value); +u8 snd_opl4_read(struct snd_opl4 *opl4, u8 reg); +void snd_opl4_read_memory(struct snd_opl4 *opl4, char *buf, int offset, int size); +void snd_opl4_write_memory(struct snd_opl4 *opl4, const char *buf, int offset, int size); /* opl4_mixer.c */ -int snd_opl4_create_mixer(opl4_t *opl4); +int snd_opl4_create_mixer(struct snd_opl4 *opl4); #ifdef CONFIG_PROC_FS /* opl4_proc.c */ -int snd_opl4_create_proc(opl4_t *opl4); -void snd_opl4_free_proc(opl4_t *opl4); +int snd_opl4_create_proc(struct snd_opl4 *opl4); +void snd_opl4_free_proc(struct snd_opl4 *opl4); #endif /* opl4_seq.c */ extern int volume_boost; /* opl4_synth.c */ -void snd_opl4_synth_reset(opl4_t *opl4); -void snd_opl4_synth_shutdown(opl4_t *opl4); -void snd_opl4_note_on(void *p, int note, int vel, snd_midi_channel_t *chan); -void snd_opl4_note_off(void *p, int note, int vel, snd_midi_channel_t *chan); -void snd_opl4_terminate_note(void *p, int note, snd_midi_channel_t *chan); -void snd_opl4_control(void *p, int type, snd_midi_channel_t *chan); -void snd_opl4_sysex(void *p, unsigned char *buf, int len, int parsed, snd_midi_channel_set_t *chset); +void snd_opl4_synth_reset(struct snd_opl4 *opl4); +void snd_opl4_synth_shutdown(struct snd_opl4 *opl4); +void snd_opl4_note_on(void *p, int note, int vel, struct snd_midi_channel *chan); +void snd_opl4_note_off(void *p, int note, int vel, struct snd_midi_channel *chan); +void snd_opl4_terminate_note(void *p, int note, struct snd_midi_channel *chan); +void snd_opl4_control(void *p, int type, struct snd_midi_channel *chan); +void snd_opl4_sysex(void *p, unsigned char *buf, int len, int parsed, struct snd_midi_channel_set *chset); /* yrw801.c */ -int snd_yrw801_detect(opl4_t *opl4); -extern const opl4_region_ptr_t snd_yrw801_regions[]; +int snd_yrw801_detect(struct snd_opl4 *opl4); +extern const struct opl4_region_ptr snd_yrw801_regions[]; #endif /* __OPL4_LOCAL_H */ diff --git a/sound/drivers/opl4/opl4_mixer.c b/sound/drivers/opl4/opl4_mixer.c index ec7a228..04079de4 100644 --- a/sound/drivers/opl4/opl4_mixer.c +++ b/sound/drivers/opl4/opl4_mixer.c @@ -20,7 +20,7 @@ #include "opl4_local.h" #include <sound/control.h> -static int snd_opl4_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_opl4_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -29,9 +29,9 @@ static int snd_opl4_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinf return 0; } -static int snd_opl4_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_opl4_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl4_t *opl4 = snd_kcontrol_chip(kcontrol); + struct snd_opl4 *opl4 = snd_kcontrol_chip(kcontrol); unsigned long flags; u8 reg = kcontrol->private_value; u8 value; @@ -44,9 +44,9 @@ static int snd_opl4_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon return 0; } -static int snd_opl4_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_opl4_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl4_t *opl4 = snd_kcontrol_chip(kcontrol); + struct snd_opl4 *opl4 = snd_kcontrol_chip(kcontrol); unsigned long flags; u8 reg = kcontrol->private_value; u8 value, old_value; @@ -60,7 +60,7 @@ static int snd_opl4_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon return value != old_value; } -static snd_kcontrol_new_t snd_opl4_controls[] = { +static struct snd_kcontrol_new snd_opl4_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "FM Playback Volume", @@ -79,9 +79,9 @@ static snd_kcontrol_new_t snd_opl4_controls[] = { } }; -int snd_opl4_create_mixer(opl4_t *opl4) +int snd_opl4_create_mixer(struct snd_opl4 *opl4) { - snd_card_t *card = opl4->card; + struct snd_card *card = opl4->card; int i, err; strcat(card->mixername, ",OPL4"); diff --git a/sound/drivers/opl4/opl4_proc.c b/sound/drivers/opl4/opl4_proc.c index 6a14862..f4b4e74 100644 --- a/sound/drivers/opl4/opl4_proc.c +++ b/sound/drivers/opl4/opl4_proc.c @@ -23,10 +23,10 @@ #ifdef CONFIG_PROC_FS -static int snd_opl4_mem_proc_open(snd_info_entry_t *entry, +static int snd_opl4_mem_proc_open(struct snd_info_entry *entry, unsigned short mode, void **file_private_data) { - opl4_t *opl4 = entry->private_data; + struct snd_opl4 *opl4 = entry->private_data; down(&opl4->access_mutex); if (opl4->memory_access) { @@ -38,10 +38,10 @@ static int snd_opl4_mem_proc_open(snd_info_entry_t *entry, return 0; } -static int snd_opl4_mem_proc_release(snd_info_entry_t *entry, +static int snd_opl4_mem_proc_release(struct snd_info_entry *entry, unsigned short mode, void *file_private_data) { - opl4_t *opl4 = entry->private_data; + struct snd_opl4 *opl4 = entry->private_data; down(&opl4->access_mutex); opl4->memory_access--; @@ -49,11 +49,11 @@ static int snd_opl4_mem_proc_release(snd_info_entry_t *entry, return 0; } -static long snd_opl4_mem_proc_read(snd_info_entry_t *entry, void *file_private_data, +static long snd_opl4_mem_proc_read(struct snd_info_entry *entry, void *file_private_data, struct file *file, char __user *_buf, unsigned long count, unsigned long pos) { - opl4_t *opl4 = entry->private_data; + struct snd_opl4 *opl4 = entry->private_data; long size; char* buf; @@ -75,11 +75,11 @@ static long snd_opl4_mem_proc_read(snd_info_entry_t *entry, void *file_private_d return 0; } -static long snd_opl4_mem_proc_write(snd_info_entry_t *entry, void *file_private_data, +static long snd_opl4_mem_proc_write(struct snd_info_entry *entry, void *file_private_data, struct file *file, const char __user *_buf, unsigned long count, unsigned long pos) { - opl4_t *opl4 = entry->private_data; + struct snd_opl4 *opl4 = entry->private_data; long size; char *buf; @@ -101,7 +101,7 @@ static long snd_opl4_mem_proc_write(snd_info_entry_t *entry, void *file_private_ return 0; } -static long long snd_opl4_mem_proc_llseek(snd_info_entry_t *entry, void *file_private_data, +static long long snd_opl4_mem_proc_llseek(struct snd_info_entry *entry, void *file_private_data, struct file *file, long long offset, int orig) { switch (orig) { @@ -130,9 +130,9 @@ static struct snd_info_entry_ops snd_opl4_mem_proc_ops = { .llseek = snd_opl4_mem_proc_llseek, }; -int snd_opl4_create_proc(opl4_t *opl4) +int snd_opl4_create_proc(struct snd_opl4 *opl4) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; entry = snd_info_create_card_entry(opl4->card, "opl4-mem", opl4->card->proc_root); if (entry) { @@ -157,7 +157,7 @@ int snd_opl4_create_proc(opl4_t *opl4) return 0; } -void snd_opl4_free_proc(opl4_t *opl4) +void snd_opl4_free_proc(struct snd_opl4 *opl4) { if (opl4->proc_entry) snd_info_unregister(opl4->proc_entry); diff --git a/sound/drivers/opl4/opl4_seq.c b/sound/drivers/opl4/opl4_seq.c index 958dfe8..bfd68e4 100644 --- a/sound/drivers/opl4/opl4_seq.c +++ b/sound/drivers/opl4/opl4_seq.c @@ -45,21 +45,21 @@ int volume_boost = 8; module_param(volume_boost, int, 0644); MODULE_PARM_DESC(volume_boost, "Additional volume for OPL4 wavetable sounds."); -static int snd_opl4_seq_use_inc(opl4_t *opl4) +static int snd_opl4_seq_use_inc(struct snd_opl4 *opl4) { if (!try_module_get(opl4->card->module)) return -EFAULT; return 0; } -static void snd_opl4_seq_use_dec(opl4_t *opl4) +static void snd_opl4_seq_use_dec(struct snd_opl4 *opl4) { module_put(opl4->card->module); } -static int snd_opl4_seq_use(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_opl4_seq_use(void *private_data, struct snd_seq_port_subscribe *info) { - opl4_t *opl4 = private_data; + struct snd_opl4 *opl4 = private_data; int err; down(&opl4->access_mutex); @@ -84,9 +84,9 @@ static int snd_opl4_seq_use(void *private_data, snd_seq_port_subscribe_t *info) return 0; } -static int snd_opl4_seq_unuse(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_opl4_seq_unuse(void *private_data, struct snd_seq_port_subscribe *info) { - opl4_t *opl4 = private_data; + struct snd_opl4 *opl4 = private_data; snd_opl4_synth_shutdown(opl4); @@ -99,7 +99,7 @@ static int snd_opl4_seq_unuse(void *private_data, snd_seq_port_subscribe_t *info return 0; } -static snd_midi_op_t opl4_ops = { +static struct snd_midi_op opl4_ops = { .note_on = snd_opl4_note_on, .note_off = snd_opl4_note_off, .note_terminate = snd_opl4_terminate_note, @@ -107,10 +107,10 @@ static snd_midi_op_t opl4_ops = { .sysex = snd_opl4_sysex, }; -static int snd_opl4_seq_event_input(snd_seq_event_t *ev, int direct, +static int snd_opl4_seq_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - opl4_t *opl4 = private_data; + struct snd_opl4 *opl4 = private_data; snd_midi_process_event(&opl4_ops, ev, opl4->chset); return 0; @@ -118,20 +118,20 @@ static int snd_opl4_seq_event_input(snd_seq_event_t *ev, int direct, static void snd_opl4_seq_free_port(void *private_data) { - opl4_t *opl4 = private_data; + struct snd_opl4 *opl4 = private_data; snd_midi_channel_free_set(opl4->chset); } -static int snd_opl4_seq_new_device(snd_seq_device_t *dev) +static int snd_opl4_seq_new_device(struct snd_seq_device *dev) { - opl4_t *opl4; + struct snd_opl4 *opl4; int client; - snd_seq_client_callback_t callbacks; - snd_seq_client_info_t cinfo; - snd_seq_port_callback_t pcallbacks; + struct snd_seq_client_callback callbacks; + struct snd_seq_client_info cinfo; + struct snd_seq_port_callback pcallbacks; - opl4 = *(opl4_t **)SNDRV_SEQ_DEVICE_ARGPTR(dev); + opl4 = *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (!opl4) return -EINVAL; @@ -188,11 +188,11 @@ static int snd_opl4_seq_new_device(snd_seq_device_t *dev) return 0; } -static int snd_opl4_seq_delete_device(snd_seq_device_t *dev) +static int snd_opl4_seq_delete_device(struct snd_seq_device *dev) { - opl4_t *opl4; + struct snd_opl4 *opl4; - opl4 = *(opl4_t **)SNDRV_SEQ_DEVICE_ARGPTR(dev); + opl4 = *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (!opl4) return -EINVAL; @@ -205,13 +205,13 @@ static int snd_opl4_seq_delete_device(snd_seq_device_t *dev) static int __init alsa_opl4_synth_init(void) { - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_opl4_seq_new_device, snd_opl4_seq_delete_device }; return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_OPL4, &ops, - sizeof(opl4_t*)); + sizeof(struct snd_opl4 *)); } static void __exit alsa_opl4_synth_exit(void) diff --git a/sound/drivers/opl4/opl4_synth.c b/sound/drivers/opl4/opl4_synth.c index b146a1c99..74f6e53 100644 --- a/sound/drivers/opl4/opl4_synth.c +++ b/sound/drivers/opl4/opl4_synth.c @@ -270,7 +270,7 @@ static unsigned char snd_opl4_volume_table[128] = { /* * Initializes all voices. */ -void snd_opl4_synth_reset(opl4_t *opl4) +void snd_opl4_synth_reset(struct snd_opl4 *opl4) { unsigned long flags; int i; @@ -294,7 +294,7 @@ void snd_opl4_synth_reset(opl4_t *opl4) /* * Shuts down all voices. */ -void snd_opl4_synth_shutdown(opl4_t *opl4) +void snd_opl4_synth_shutdown(struct snd_opl4 *opl4) { unsigned long flags; int i; @@ -309,12 +309,12 @@ void snd_opl4_synth_shutdown(opl4_t *opl4) /* * Executes the callback for all voices playing the specified note. */ -static void snd_opl4_do_for_note(opl4_t *opl4, int note, snd_midi_channel_t *chan, - void (*func)(opl4_t *opl4, opl4_voice_t *voice)) +static void snd_opl4_do_for_note(struct snd_opl4 *opl4, int note, struct snd_midi_channel *chan, + void (*func)(struct snd_opl4 *opl4, struct opl4_voice *voice)) { int i; unsigned long flags; - opl4_voice_t *voice; + struct opl4_voice *voice; spin_lock_irqsave(&opl4->reg_lock, flags); for (i = 0; i < OPL4_MAX_VOICES; i++) { @@ -329,12 +329,13 @@ static void snd_opl4_do_for_note(opl4_t *opl4, int note, snd_midi_channel_t *cha /* * Executes the callback for all voices of to the specified channel. */ -static void snd_opl4_do_for_channel(opl4_t *opl4, snd_midi_channel_t *chan, - void (*func)(opl4_t *opl4, opl4_voice_t *voice)) +static void snd_opl4_do_for_channel(struct snd_opl4 *opl4, + struct snd_midi_channel *chan, + void (*func)(struct snd_opl4 *opl4, struct opl4_voice *voice)) { int i; unsigned long flags; - opl4_voice_t *voice; + struct opl4_voice *voice; spin_lock_irqsave(&opl4->reg_lock, flags); for (i = 0; i < OPL4_MAX_VOICES; i++) { @@ -349,12 +350,12 @@ static void snd_opl4_do_for_channel(opl4_t *opl4, snd_midi_channel_t *chan, /* * Executes the callback for all active voices. */ -static void snd_opl4_do_for_all(opl4_t *opl4, - void (*func)(opl4_t *opl4, opl4_voice_t *voice)) +static void snd_opl4_do_for_all(struct snd_opl4 *opl4, + void (*func)(struct snd_opl4 *opl4, struct opl4_voice *voice)) { int i; unsigned long flags; - opl4_voice_t *voice; + struct opl4_voice *voice; spin_lock_irqsave(&opl4->reg_lock, flags); for (i = 0; i < OPL4_MAX_VOICES; i++) { @@ -365,7 +366,7 @@ static void snd_opl4_do_for_all(opl4_t *opl4, spin_unlock_irqrestore(&opl4->reg_lock, flags); } -static void snd_opl4_update_volume(opl4_t *opl4, opl4_voice_t *voice) +static void snd_opl4_update_volume(struct snd_opl4 *opl4, struct opl4_voice *voice) { int att; @@ -384,7 +385,7 @@ static void snd_opl4_update_volume(opl4_t *opl4, opl4_voice_t *voice) voice->level_direct = 0; } -static void snd_opl4_update_pan(opl4_t *opl4, opl4_voice_t *voice) +static void snd_opl4_update_pan(struct snd_opl4 *opl4, struct opl4_voice *voice) { int pan = voice->sound->panpot; @@ -399,7 +400,8 @@ static void snd_opl4_update_pan(opl4_t *opl4, opl4_voice_t *voice) snd_opl4_write(opl4, OPL4_REG_MISC + voice->number, voice->reg_misc); } -static void snd_opl4_update_vibrato_depth(opl4_t *opl4, opl4_voice_t *voice) +static void snd_opl4_update_vibrato_depth(struct snd_opl4 *opl4, + struct opl4_voice *voice) { int depth; @@ -414,9 +416,10 @@ static void snd_opl4_update_vibrato_depth(opl4_t *opl4, opl4_voice_t *voice) voice->reg_lfo_vibrato); } -static void snd_opl4_update_pitch(opl4_t *opl4, opl4_voice_t *voice) +static void snd_opl4_update_pitch(struct snd_opl4 *opl4, + struct opl4_voice *voice) { - snd_midi_channel_t *chan = voice->chan; + struct snd_midi_channel *chan = voice->chan; int note, pitch, octave; note = chan->drum_channel ? 60 : voice->note; @@ -444,7 +447,8 @@ static void snd_opl4_update_pitch(opl4_t *opl4, opl4_voice_t *voice) snd_opl4_write(opl4, OPL4_REG_F_NUMBER + voice->number, voice->reg_f_number); } -static void snd_opl4_update_tone_parameters(opl4_t *opl4, opl4_voice_t *voice) +static void snd_opl4_update_tone_parameters(struct snd_opl4 *opl4, + struct opl4_voice *voice) { snd_opl4_write(opl4, OPL4_REG_ATTACK_DECAY1 + voice->number, voice->sound->reg_attack_decay1); @@ -457,17 +461,17 @@ static void snd_opl4_update_tone_parameters(opl4_t *opl4, opl4_voice_t *voice) } /* allocate one voice */ -static opl4_voice_t *snd_opl4_get_voice(opl4_t *opl4) +static struct opl4_voice *snd_opl4_get_voice(struct snd_opl4 *opl4) { /* first, try to get the oldest key-off voice */ if (!list_empty(&opl4->off_voices)) - return list_entry(opl4->off_voices.next, opl4_voice_t, list); + return list_entry(opl4->off_voices.next, struct opl4_voice, list); /* then get the oldest key-on voice */ snd_assert(!list_empty(&opl4->on_voices), ); - return list_entry(opl4->on_voices.next, opl4_voice_t, list); + return list_entry(opl4->on_voices.next, struct opl4_voice, list); } -static void snd_opl4_wait_for_wave_headers(opl4_t *opl4) +static void snd_opl4_wait_for_wave_headers(struct snd_opl4 *opl4) { int timeout = 200; @@ -475,12 +479,12 @@ static void snd_opl4_wait_for_wave_headers(opl4_t *opl4) udelay(10); } -void snd_opl4_note_on(void *private_data, int note, int vel, snd_midi_channel_t *chan) +void snd_opl4_note_on(void *private_data, int note, int vel, struct snd_midi_channel *chan) { - opl4_t *opl4 = private_data; - const opl4_region_ptr_t *regions; - opl4_voice_t *voice[2]; - const opl4_sound_t *sound[2]; + struct snd_opl4 *opl4 = private_data; + const struct opl4_region_ptr *regions; + struct opl4_voice *voice[2]; + const struct opl4_sound *sound[2]; int voices = 0, i; unsigned long flags; @@ -549,7 +553,7 @@ void snd_opl4_note_on(void *private_data, int note, int vel, snd_midi_channel_t spin_unlock_irqrestore(&opl4->reg_lock, flags); } -static void snd_opl4_voice_off(opl4_t *opl4, opl4_voice_t *voice) +static void snd_opl4_voice_off(struct snd_opl4 *opl4, struct opl4_voice *voice) { list_del(&voice->list); list_add_tail(&voice->list, &opl4->off_voices); @@ -558,14 +562,14 @@ static void snd_opl4_voice_off(opl4_t *opl4, opl4_voice_t *voice) snd_opl4_write(opl4, OPL4_REG_MISC + voice->number, voice->reg_misc); } -void snd_opl4_note_off(void *private_data, int note, int vel, snd_midi_channel_t *chan) +void snd_opl4_note_off(void *private_data, int note, int vel, struct snd_midi_channel *chan) { - opl4_t *opl4 = private_data; + struct snd_opl4 *opl4 = private_data; snd_opl4_do_for_note(opl4, note, chan, snd_opl4_voice_off); } -static void snd_opl4_terminate_voice(opl4_t *opl4, opl4_voice_t *voice) +static void snd_opl4_terminate_voice(struct snd_opl4 *opl4, struct opl4_voice *voice) { list_del(&voice->list); list_add_tail(&voice->list, &opl4->off_voices); @@ -574,16 +578,16 @@ static void snd_opl4_terminate_voice(opl4_t *opl4, opl4_voice_t *voice) snd_opl4_write(opl4, OPL4_REG_MISC + voice->number, voice->reg_misc); } -void snd_opl4_terminate_note(void *private_data, int note, snd_midi_channel_t *chan) +void snd_opl4_terminate_note(void *private_data, int note, struct snd_midi_channel *chan) { - opl4_t *opl4 = private_data; + struct snd_opl4 *opl4 = private_data; snd_opl4_do_for_note(opl4, note, chan, snd_opl4_terminate_voice); } -void snd_opl4_control(void *private_data, int type, snd_midi_channel_t *chan) +void snd_opl4_control(void *private_data, int type, struct snd_midi_channel *chan) { - opl4_t *opl4 = private_data; + struct snd_opl4 *opl4 = private_data; switch (type) { case MIDI_CTL_MSB_MODWHEEL: @@ -621,9 +625,9 @@ void snd_opl4_control(void *private_data, int type, snd_midi_channel_t *chan) } void snd_opl4_sysex(void *private_data, unsigned char *buf, int len, - int parsed, snd_midi_channel_set_t *chset) + int parsed, struct snd_midi_channel_set *chset) { - opl4_t *opl4 = private_data; + struct snd_opl4 *opl4 = private_data; if (parsed == SNDRV_MIDI_SYSEX_GS_MASTER_VOLUME) snd_opl4_do_for_all(opl4, snd_opl4_update_volume); diff --git a/sound/drivers/opl4/yrw801.c b/sound/drivers/opl4/yrw801.c index a51174d..6c33549 100644 --- a/sound/drivers/opl4/yrw801.c +++ b/sound/drivers/opl4/yrw801.c @@ -33,7 +33,7 @@ #include "opl4_local.h" -int snd_yrw801_detect(opl4_t *opl4) +int snd_yrw801_detect(struct snd_opl4 *opl4) { char buf[15]; @@ -54,7 +54,7 @@ int snd_yrw801_detect(opl4_t *opl4) * by this driver. */ -static const opl4_region_t regions_00[] = { /* Acoustic Grand Piano */ +static const struct opl4_region regions_00[] = { /* Acoustic Grand Piano */ {0x14, 0x27, {0x12c,7474,100, 0,0,0x00,0xc8,0x20,0xf2,0x13,0x08,0x0}}, {0x28, 0x2d, {0x12d,6816,100, 0,0,0x00,0xc8,0x20,0xf2,0x14,0x08,0x0}}, {0x2e, 0x33, {0x12e,5899,100, 0,0,0x00,0xc8,0x20,0xf2,0x14,0x08,0x0}}, @@ -66,7 +66,7 @@ static const opl4_region_t regions_00[] = { /* Acoustic Grand Piano */ {0x53, 0x58, {0x134,1444,100, 0,0,0x07,0xc8,0x20,0xf3,0x14,0x18,0x0}}, {0x59, 0x6d, {0x135,1915,100, 0,0,0x00,0xc8,0x20,0xf4,0x15,0x08,0x0}} }; -static const opl4_region_t regions_01[] = { /* Bright Acoustic Piano */ +static const struct opl4_region regions_01[] = { /* Bright Acoustic Piano */ {0x14, 0x2d, {0x12c,7474,100, 0,0,0x00,0xc8,0x20,0xf2,0x13,0x08,0x0}}, {0x2e, 0x33, {0x12d,6816,100, 0,0,0x00,0xc8,0x20,0xf2,0x14,0x08,0x0}}, {0x34, 0x39, {0x12e,5899,100, 0,0,0x00,0xc8,0x20,0xf2,0x14,0x08,0x0}}, @@ -78,7 +78,7 @@ static const opl4_region_t regions_01[] = { /* Bright Acoustic Piano */ {0x59, 0x5e, {0x134,1444,100, 0,0,0x0a,0xc8,0x20,0xf3,0x14,0x18,0x0}}, {0x5f, 0x6d, {0x135,1915,100, 0,0,0x00,0xc8,0x20,0xf4,0x15,0x08,0x0}} }; -static const opl4_region_t regions_02[] = { /* Electric Grand Piano */ +static const struct opl4_region regions_02[] = { /* Electric Grand Piano */ {0x14, 0x2d, {0x12c,7476,100, 1,0,0x00,0xae,0x20,0xf2,0x13,0x07,0x0}}, {0x2e, 0x33, {0x12d,6818,100, 1,0,0x00,0xae,0x20,0xf2,0x14,0x07,0x0}}, {0x34, 0x39, {0x12e,5901,100, 1,0,0x00,0xae,0x20,0xf2,0x14,0x07,0x0}}, @@ -91,7 +91,7 @@ static const opl4_region_t regions_02[] = { /* Electric Grand Piano */ {0x5f, 0x6d, {0x135,1917,100, 1,0,0x00,0xae,0x20,0xf4,0x15,0x07,0x0}}, {0x00, 0x7f, {0x06c,6375,100,-1,0,0x00,0xc2,0x28,0xf4,0x23,0x18,0x0}} }; -static const opl4_region_t regions_03[] = { /* Honky-Tonk Piano */ +static const struct opl4_region regions_03[] = { /* Honky-Tonk Piano */ {0x14, 0x27, {0x12c,7474,100, 0,0,0x00,0xb4,0x20,0xf2,0x13,0x08,0x0}}, {0x28, 0x2d, {0x12d,6816,100, 0,0,0x00,0xb4,0x20,0xf2,0x14,0x08,0x0}}, {0x2e, 0x33, {0x12e,5899,100, 0,0,0x00,0xb4,0x20,0xf2,0x14,0x08,0x0}}, @@ -113,11 +113,11 @@ static const opl4_region_t regions_03[] = { /* Honky-Tonk Piano */ {0x53, 0x58, {0x134,1457,100, 0,0,0x01,0xb4,0x20,0xf3,0x14,0x18,0x0}}, {0x59, 0x6d, {0x135,1903,100, 0,0,0x00,0xb4,0x20,0xf4,0x15,0x08,0x0}} }; -static const opl4_region_t regions_04[] = { /* Electric Piano 1 */ +static const struct opl4_region regions_04[] = { /* Electric Piano 1 */ {0x15, 0x6c, {0x00b,6570,100, 0,0,0x00,0x28,0x38,0xf0,0x00,0x0c,0x0}}, {0x00, 0x7f, {0x06c,6375,100, 0,2,0x00,0xb0,0x22,0xf4,0x23,0x19,0x0}} }; -static const opl4_region_t regions_05[] = { /* Electric Piano 2 */ +static const struct opl4_region regions_05[] = { /* Electric Piano 2 */ {0x14, 0x27, {0x12c,7476,100, 0,3,0x00,0xa2,0x1b,0xf2,0x13,0x08,0x0}}, {0x28, 0x2d, {0x12d,6818,100, 0,3,0x00,0xa2,0x1b,0xf2,0x14,0x08,0x0}}, {0x2e, 0x33, {0x12e,5901,100, 0,3,0x00,0xa2,0x1b,0xf2,0x14,0x08,0x0}}, @@ -139,103 +139,103 @@ static const opl4_region_t regions_05[] = { /* Electric Piano 2 */ {0x59, 0x5e, {0x134,1442,100, 0,0,0x0a,0xa2,0x18,0xf3,0x14,0x18,0x0}}, {0x5f, 0x6d, {0x135,1913,100, 0,0,0x00,0xa2,0x18,0xf4,0x15,0x08,0x0}} }; -static const opl4_region_t regions_06[] = { /* Harpsichord */ +static const struct opl4_region regions_06[] = { /* Harpsichord */ {0x15, 0x39, {0x080,5158,100, 0,0,0x00,0xb2,0x20,0xf5,0x24,0x19,0x0}}, {0x3a, 0x3f, {0x081,4408,100, 0,0,0x00,0xb2,0x20,0xf5,0x25,0x09,0x0}}, {0x40, 0x45, {0x082,3622,100, 0,0,0x00,0xb2,0x20,0xf5,0x25,0x09,0x0}}, {0x46, 0x4d, {0x083,2843,100, 0,0,0x00,0xb2,0x20,0xf5,0x25,0x19,0x0}}, {0x4e, 0x6c, {0x084,1307,100, 0,0,0x00,0xb2,0x20,0xf5,0x25,0x29,0x0}} }; -static const opl4_region_t regions_07[] = { /* Clavinet */ +static const struct opl4_region regions_07[] = { /* Clavinet */ {0x15, 0x51, {0x027,5009,100, 0,0,0x00,0xd2,0x28,0xf5,0x13,0x2b,0x0}}, {0x52, 0x6c, {0x028,3495,100, 0,0,0x00,0xd2,0x28,0xf5,0x13,0x3b,0x0}} }; -static const opl4_region_t regions_08[] = { /* Celesta */ +static const struct opl4_region regions_08[] = { /* Celesta */ {0x15, 0x6c, {0x02b,3267,100, 0,0,0x00,0xdc,0x20,0xf4,0x15,0x07,0x3}} }; -static const opl4_region_t regions_09[] = { /* Glockenspiel */ +static const struct opl4_region regions_09[] = { /* Glockenspiel */ {0x15, 0x78, {0x0f3, 285,100, 0,0,0x00,0xc2,0x28,0xf6,0x25,0x25,0x0}} }; -static const opl4_region_t regions_0a[] = { /* Music Box */ +static const struct opl4_region regions_0a[] = { /* Music Box */ {0x15, 0x6c, {0x0f3,3362,100, 0,0,0x00,0xb6,0x20,0xa6,0x25,0x25,0x0}}, {0x15, 0x6c, {0x101,4773,100, 0,0,0x00,0xaa,0x20,0xd4,0x14,0x16,0x0}} }; -static const opl4_region_t regions_0b[] = { /* Vibraphone */ +static const struct opl4_region regions_0b[] = { /* Vibraphone */ {0x15, 0x6c, {0x101,4778,100, 0,0,0x00,0xc0,0x28,0xf4,0x14,0x16,0x4}} }; -static const opl4_region_t regions_0c[] = { /* Marimba */ +static const struct opl4_region regions_0c[] = { /* Marimba */ {0x15, 0x3f, {0x0f4,4778,100, 0,0,0x00,0xc4,0x38,0xf7,0x47,0x08,0x0}}, {0x40, 0x4c, {0x0f5,3217,100, 0,0,0x00,0xc4,0x38,0xf7,0x47,0x08,0x0}}, {0x4d, 0x5a, {0x0f5,3217,100, 0,0,0x00,0xc4,0x38,0xf7,0x48,0x08,0x0}}, {0x5b, 0x7f, {0x0f5,3218,100, 0,0,0x00,0xc4,0x38,0xf7,0x48,0x18,0x0}} }; -static const opl4_region_t regions_0d[] = { /* Xylophone */ +static const struct opl4_region regions_0d[] = { /* Xylophone */ {0x00, 0x7f, {0x136,1729,100, 0,0,0x00,0xd2,0x38,0xf0,0x06,0x36,0x0}} }; -static const opl4_region_t regions_0e[] = { /* Tubular Bell */ +static const struct opl4_region regions_0e[] = { /* Tubular Bell */ {0x01, 0x7f, {0x0ff,3999,100, 0,1,0x00,0x90,0x21,0xf4,0xa3,0x25,0x1}} }; -static const opl4_region_t regions_0f[] = { /* Dulcimer */ +static const struct opl4_region regions_0f[] = { /* Dulcimer */ {0x00, 0x7f, {0x03f,4236,100, 0,1,0x00,0xbc,0x29,0xf5,0x16,0x07,0x0}}, {0x00, 0x7f, {0x040,4236,100, 0,2,0x0e,0x94,0x2a,0xf5,0x16,0x07,0x0}} }; -static const opl4_region_t regions_10[] = { /* Drawbar Organ */ +static const struct opl4_region regions_10[] = { /* Drawbar Organ */ {0x01, 0x7f, {0x08e,4394,100, 0,2,0x14,0xc2,0x3a,0xf0,0x00,0x0a,0x0}} }; -static const opl4_region_t regions_11[] = { /* Percussive Organ */ +static const struct opl4_region regions_11[] = { /* Percussive Organ */ {0x15, 0x3b, {0x08c,6062,100, 0,3,0x00,0xbe,0x3b,0xf0,0x00,0x09,0x0}}, {0x3c, 0x6c, {0x08d,2984,100, 0,3,0x00,0xbe,0x3b,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_12[] = { /* Rock Organ */ +static const struct opl4_region regions_12[] = { /* Rock Organ */ {0x15, 0x30, {0x128,6574,100, 0,1,0x00,0xcc,0x39,0xf0,0x00,0x0a,0x0}}, {0x31, 0x3c, {0x129,5040,100, 0,1,0x00,0xcc,0x39,0xf0,0x00,0x0a,0x0}}, {0x3d, 0x48, {0x12a,3498,100, 0,1,0x00,0xcc,0x39,0xf0,0x00,0x0a,0x0}}, {0x49, 0x54, {0x12b,1957,100, 0,1,0x00,0xcc,0x39,0xf0,0x00,0x0a,0x0}}, {0x55, 0x6c, {0x127, 423,100, 0,1,0x00,0xcc,0x39,0xf0,0x00,0x0a,0x0}} }; -static const opl4_region_t regions_13[] = { /* Church Organ */ +static const struct opl4_region regions_13[] = { /* Church Organ */ {0x15, 0x29, {0x087,7466,100, 0,1,0x00,0xc4,0x11,0xf0,0x00,0x09,0x0}}, {0x2a, 0x30, {0x088,6456,100, 0,1,0x00,0xc4,0x11,0xf0,0x00,0x09,0x0}}, {0x31, 0x38, {0x089,5428,100, 0,1,0x00,0xc4,0x11,0xf0,0x00,0x09,0x0}}, {0x39, 0x41, {0x08a,4408,100, 0,1,0x00,0xc4,0x11,0xf0,0x00,0x09,0x0}}, {0x42, 0x6c, {0x08b,3406,100, 0,1,0x00,0xc4,0x11,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_14[] = { /* Reed Organ */ +static const struct opl4_region regions_14[] = { /* Reed Organ */ {0x00, 0x53, {0x0ac,5570,100, 0,0,0x06,0xc0,0x38,0xf0,0x00,0x09,0x1}}, {0x54, 0x7f, {0x0ad,2497,100, 0,0,0x00,0xc0,0x38,0xf0,0x00,0x09,0x1}} }; -static const opl4_region_t regions_15[] = { /* Accordion */ +static const struct opl4_region regions_15[] = { /* Accordion */ {0x15, 0x4c, {0x006,4261,100, 0,2,0x00,0xa4,0x22,0x90,0x00,0x09,0x0}}, {0x4d, 0x6c, {0x007,1530,100, 0,2,0x00,0xa4,0x22,0x90,0x00,0x09,0x0}}, {0x15, 0x6c, {0x070,4391,100, 0,3,0x00,0x8a,0x23,0xa0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_16[] = { /* Harmonica */ +static const struct opl4_region regions_16[] = { /* Harmonica */ {0x15, 0x6c, {0x070,4408,100, 0,0,0x00,0xae,0x30,0xa0,0x00,0x09,0x2}} }; -static const opl4_region_t regions_17[] = { /* Tango Accordion */ +static const struct opl4_region regions_17[] = { /* Tango Accordion */ {0x00, 0x53, {0x0ac,5573,100, 0,0,0x00,0xae,0x38,0xf0,0x00,0x09,0x0}}, {0x54, 0x7f, {0x0ad,2500,100, 0,0,0x00,0xae,0x38,0xf0,0x00,0x09,0x0}}, {0x15, 0x6c, {0x041,8479,100, 0,2,0x00,0x6a,0x3a,0x75,0x20,0x0a,0x0}} }; -static const opl4_region_t regions_18[] = { /* Nylon Guitar */ +static const struct opl4_region regions_18[] = { /* Nylon Guitar */ {0x15, 0x2f, {0x0b3,6964,100, 0,0,0x05,0xca,0x28,0xf5,0x34,0x09,0x0}}, {0x30, 0x36, {0x0b7,5567,100, 0,0,0x0c,0xca,0x28,0xf5,0x34,0x09,0x0}}, {0x37, 0x3c, {0x0b5,4653,100, 0,0,0x00,0xca,0x28,0xf6,0x34,0x09,0x0}}, {0x3d, 0x43, {0x0b4,3892,100, 0,0,0x00,0xca,0x28,0xf6,0x35,0x09,0x0}}, {0x44, 0x60, {0x0b6,2723,100, 0,0,0x00,0xca,0x28,0xf6,0x35,0x19,0x0}} }; -static const opl4_region_t regions_19[] = { /* Steel Guitar */ +static const struct opl4_region regions_19[] = { /* Steel Guitar */ {0x15, 0x31, {0x00c,6937,100, 0,0,0x00,0xbc,0x28,0xf0,0x04,0x19,0x0}}, {0x32, 0x38, {0x00d,5410,100, 0,0,0x00,0xbc,0x28,0xf0,0x05,0x09,0x0}}, {0x39, 0x47, {0x00e,4379,100, 0,0,0x00,0xbc,0x28,0xf5,0x94,0x09,0x0}}, {0x48, 0x6c, {0x00f,2843,100, 0,0,0x00,0xbc,0x28,0xf6,0x95,0x09,0x0}} }; -static const opl4_region_t regions_1a[] = { /* Jazz Guitar */ +static const struct opl4_region regions_1a[] = { /* Jazz Guitar */ {0x15, 0x31, {0x05a,6832,100, 0,0,0x00,0xca,0x28,0xf6,0x34,0x09,0x0}}, {0x32, 0x3f, {0x05b,4897,100, 0,0,0x00,0xca,0x28,0xf6,0x34,0x09,0x0}}, {0x40, 0x6c, {0x05c,3218,100, 0,0,0x00,0xca,0x28,0xf6,0x34,0x09,0x0}} }; -static const opl4_region_t regions_1b[] = { /* Clean Guitar */ +static const struct opl4_region regions_1b[] = { /* Clean Guitar */ {0x15, 0x2c, {0x061,7053,100, 0,1,0x00,0xb4,0x29,0xf5,0x54,0x0a,0x0}}, {0x2d, 0x31, {0x060,6434,100, 0,1,0x00,0xb4,0x29,0xf5,0x54,0x0a,0x0}}, {0x32, 0x38, {0x063,5764,100, 0,1,0x00,0xbe,0x29,0xf5,0x55,0x0a,0x0}}, @@ -245,14 +245,14 @@ static const opl4_region_t regions_1b[] = { /* Clean Guitar */ {0x4c, 0x54, {0x066,2462,100, 0,1,0x00,0xb4,0x29,0xf5,0x55,0x2a,0x0}}, {0x55, 0x6c, {0x067,1307,100, 0,1,0x00,0xb4,0x29,0xf6,0x56,0x0a,0x0}} }; -static const opl4_region_t regions_1c[] = { /* Muted Guitar */ +static const struct opl4_region regions_1c[] = { /* Muted Guitar */ {0x01, 0x7f, {0x068,4408,100, 0,0,0x00,0xcc,0x28,0xf6,0x15,0x09,0x0}} }; -static const opl4_region_t regions_1d[] = { /* Overdriven Guitar */ +static const struct opl4_region regions_1d[] = { /* Overdriven Guitar */ {0x00, 0x40, {0x0a5,6589,100, 0,1,0x00,0xc0,0x29,0xf2,0x11,0x09,0x0}}, {0x41, 0x7f, {0x0a6,5428,100, 0,1,0x00,0xc0,0x29,0xf2,0x11,0x09,0x0}} }; -static const opl4_region_t regions_1e[] = { /* Distortion Guitar */ +static const struct opl4_region regions_1e[] = { /* Distortion Guitar */ {0x15, 0x2a, {0x051,6928,100, 0,1,0x00,0xbc,0x21,0xa2,0x12,0x0a,0x0}}, {0x2b, 0x2e, {0x052,6433,100, 0,1,0x00,0xbc,0x21,0xa2,0x12,0x0a,0x0}}, {0x2f, 0x32, {0x053,5944,100, 0,1,0x00,0xbc,0x21,0xa2,0x12,0x0a,0x0}}, @@ -263,44 +263,44 @@ static const opl4_region_t regions_1e[] = { /* Distortion Guitar */ {0x43, 0x46, {0x058,3361,100, 0,1,0x00,0xbc,0x21,0xa2,0x12,0x0a,0x0}}, {0x47, 0x6c, {0x059,2784,100, 0,1,0x00,0xbc,0x21,0xa2,0x12,0x0a,0x0}} }; -static const opl4_region_t regions_1f[] = { /* Guitar Harmonics */ +static const struct opl4_region regions_1f[] = { /* Guitar Harmonics */ {0x15, 0x44, {0x05e,5499,100, 0,0,0x00,0xce,0x28,0xf4,0x24,0x09,0x0}}, {0x45, 0x49, {0x05d,4850,100, 0,0,0x00,0xe2,0x28,0xf4,0x24,0x09,0x0}}, {0x4a, 0x6c, {0x05f,4259,100, 0,0,0x00,0xce,0x28,0xf4,0x24,0x09,0x0}} }; -static const opl4_region_t regions_20[] = { /* Acoustic Bass */ +static const struct opl4_region regions_20[] = { /* Acoustic Bass */ {0x15, 0x30, {0x004,8053,100, 0,0,0x00,0xe2,0x18,0xf5,0x15,0x09,0x0}}, {0x31, 0x6c, {0x005,4754,100, 0,0,0x00,0xe2,0x18,0xf5,0x15,0x09,0x0}} }; -static const opl4_region_t regions_21[] = { /* Fingered Bass */ +static const struct opl4_region regions_21[] = { /* Fingered Bass */ {0x01, 0x20, {0x04a,8762,100, 0,0,0x00,0xde,0x18,0xf6,0x14,0x09,0x0}}, {0x21, 0x25, {0x04b,8114,100, 0,0,0x00,0xde,0x18,0xf6,0x14,0x09,0x0}}, {0x26, 0x2a, {0x04c,7475,100, 0,0,0x00,0xde,0x18,0xf6,0x14,0x09,0x0}}, {0x2b, 0x7f, {0x04d,6841,100, 0,0,0x00,0xde,0x18,0xf6,0x14,0x09,0x0}} }; -static const opl4_region_t regions_22[] = { /* Picked Bass */ +static const struct opl4_region regions_22[] = { /* Picked Bass */ {0x15, 0x23, {0x04f,7954,100, 0,0,0x00,0xcc,0x18,0xf3,0x90,0x0a,0x0}}, {0x24, 0x2a, {0x050,7318,100, 0,0,0x05,0xcc,0x18,0xf3,0x90,0x1a,0x0}}, {0x2b, 0x2f, {0x06b,6654,100, 0,0,0x00,0xcc,0x18,0xf3,0x90,0x2a,0x0}}, {0x30, 0x47, {0x069,6031,100, 0,0,0x00,0xcc,0x18,0xf5,0xb0,0x0a,0x0}}, {0x48, 0x6c, {0x06a,5393,100, 0,0,0x00,0xcc,0x18,0xf5,0xb0,0x0a,0x0}} }; -static const opl4_region_t regions_23[] = { /* Fretless Bass */ +static const struct opl4_region regions_23[] = { /* Fretless Bass */ {0x01, 0x7f, {0x04e,5297,100, 0,0,0x00,0xd2,0x10,0xf3,0x63,0x19,0x0}} }; -static const opl4_region_t regions_24[] = { /* Slap Bass 1 */ +static const struct opl4_region regions_24[] = { /* Slap Bass 1 */ {0x15, 0x6c, {0x0a3,7606,100, 0,1,0x00,0xde,0x19,0xf5,0x32,0x1a,0x0}} }; -static const opl4_region_t regions_25[] = { /* Slap Bass 2 */ +static const struct opl4_region regions_25[] = { /* Slap Bass 2 */ {0x01, 0x7f, {0x0a2,6694,100, 0,0,0x00,0xda,0x20,0xb0,0x02,0x09,0x0}} }; -static const opl4_region_t regions_26[] = { /* Synth Bass 1 */ +static const struct opl4_region regions_26[] = { /* Synth Bass 1 */ {0x15, 0x6c, {0x0be,7466,100, 0,1,0x00,0xb8,0x39,0xf4,0x14,0x09,0x0}} }; -static const opl4_region_t regions_27[] = { /* Synth Bass 2 */ +static const struct opl4_region regions_27[] = { /* Synth Bass 2 */ {0x00, 0x7f, {0x117,8103,100, 0,1,0x00,0xca,0x39,0xf3,0x50,0x08,0x0}} }; -static const opl4_region_t regions_28[] = { /* Violin */ +static const struct opl4_region regions_28[] = { /* Violin */ {0x15, 0x3a, {0x105,5158,100, 0,3,0x00,0xcc,0x3b,0xf3,0x20,0x09,0x0}}, {0x3b, 0x3f, {0x102,4754,100, 0,3,0x00,0xcc,0x3b,0xf3,0x20,0x09,0x0}}, {0x40, 0x41, {0x106,4132,100, 0,3,0x00,0xcc,0x3b,0xf3,0x20,0x09,0x0}}, @@ -312,7 +312,7 @@ static const opl4_region_t regions_28[] = { /* Violin */ {0x4f, 0x51, {0x10d,2166,100, 0,3,0x00,0xcc,0x3b,0xf3,0x20,0x09,0x0}}, {0x52, 0x6c, {0x109,1825,100, 0,3,0x00,0xcc,0x3b,0xf3,0x20,0x09,0x0}} }; -static const opl4_region_t regions_29[] = { /* Viola */ +static const struct opl4_region regions_29[] = { /* Viola */ {0x15, 0x32, {0x103,5780,100, 0,3,0x00,0xc4,0x3b,0xa3,0x20,0x09,0x0}}, {0x33, 0x35, {0x104,5534,100, 0,3,0x00,0xc4,0x3b,0xa3,0x20,0x09,0x0}}, {0x36, 0x38, {0x105,5158,100, 0,3,0x00,0xc4,0x3b,0xa3,0x20,0x09,0x0}}, @@ -326,76 +326,76 @@ static const opl4_region_t regions_29[] = { /* Viola */ {0x4d, 0x4f, {0x10d,2166,100, 0,3,0x00,0xd0,0x3b,0xa3,0x20,0x09,0x0}}, {0x50, 0x6c, {0x109,1825,100, 0,3,0x00,0xd0,0x3b,0xa3,0x20,0x09,0x0}} }; -static const opl4_region_t regions_2a[] = { /* Cello */ +static const struct opl4_region regions_2a[] = { /* Cello */ {0x15, 0x2d, {0x112,6545,100, 0,3,0x00,0xc0,0x33,0xa0,0x00,0x08,0x0}}, {0x2e, 0x37, {0x113,5764,100, 0,3,0x00,0xc0,0x33,0xa0,0x00,0x08,0x0}}, {0x38, 0x3e, {0x115,4378,100, 0,3,0x00,0xc0,0x33,0xa0,0x00,0x18,0x0}}, {0x3f, 0x44, {0x116,3998,100, 0,3,0x00,0xc0,0x33,0xa0,0x00,0x18,0x0}}, {0x45, 0x6c, {0x114,3218,100, 0,3,0x00,0xc0,0x33,0xa0,0x00,0x18,0x0}} }; -static const opl4_region_t regions_2b[] = { /* Contrabass */ +static const struct opl4_region regions_2b[] = { /* Contrabass */ {0x15, 0x29, {0x110,7713,100, 0,1,0x00,0xc2,0x19,0x90,0x00,0x09,0x0}}, {0x2a, 0x6c, {0x111,6162,100, 0,1,0x00,0xc2,0x19,0x90,0x00,0x09,0x0}} }; -static const opl4_region_t regions_2c[] = { /* Tremolo Strings */ +static const struct opl4_region regions_2c[] = { /* Tremolo Strings */ {0x15, 0x3b, {0x0b0,4810,100, 0,0,0x0a,0xde,0x38,0xf0,0x00,0x07,0x6}}, {0x3c, 0x41, {0x035,4035,100, 0,0,0x05,0xde,0x38,0xf0,0x00,0x07,0x6}}, {0x42, 0x47, {0x033,3129,100, 0,0,0x05,0xde,0x38,0xf0,0x00,0x07,0x6}}, {0x48, 0x52, {0x034,2625,100, 0,0,0x05,0xde,0x38,0xf0,0x00,0x07,0x6}}, {0x53, 0x6c, {0x0af, 936,100, 0,0,0x00,0xde,0x38,0xf0,0x00,0x07,0x6}} }; -static const opl4_region_t regions_2d[] = { /* Pizzicato Strings */ +static const struct opl4_region regions_2d[] = { /* Pizzicato Strings */ {0x15, 0x32, {0x0b8,6186,100, 0,0,0x00,0xbc,0x28,0xf0,0x00,0x05,0x0}}, {0x33, 0x3b, {0x0b9,5031,100, 0,0,0x00,0xbc,0x28,0xf0,0x00,0x05,0x0}}, {0x3c, 0x42, {0x0bb,4146,100, 0,0,0x00,0xbc,0x28,0xf0,0x00,0x05,0x0}}, {0x43, 0x48, {0x0ba,3245,100, 0,0,0x00,0xc2,0x28,0xf0,0x00,0x05,0x0}}, {0x49, 0x6c, {0x0bc,2352,100, 0,0,0x00,0xbc,0x28,0xf0,0x00,0x05,0x0}} }; -static const opl4_region_t regions_2e[] = { /* Harp */ +static const struct opl4_region regions_2e[] = { /* Harp */ {0x15, 0x46, {0x07e,3740,100, 0,1,0x00,0xd2,0x29,0xf5,0x25,0x07,0x0}}, {0x47, 0x6c, {0x07f,2319,100, 0,1,0x00,0xd2,0x29,0xf5,0x25,0x07,0x0}} }; -static const opl4_region_t regions_2f[] = { /* Timpani */ +static const struct opl4_region regions_2f[] = { /* Timpani */ {0x15, 0x6c, {0x100,6570,100, 0,0,0x00,0xf8,0x28,0xf0,0x05,0x16,0x0}} }; -static const opl4_region_t regions_30[] = { /* Strings */ +static const struct opl4_region regions_30[] = { /* Strings */ {0x15, 0x3b, {0x13c,4806,100, 0,0,0x00,0xc8,0x20,0x80,0x00,0x07,0x0}}, {0x3c, 0x41, {0x13e,4035,100, 0,0,0x00,0xc8,0x20,0x80,0x00,0x07,0x0}}, {0x42, 0x47, {0x13d,3122,100, 0,0,0x00,0xc8,0x20,0x80,0x00,0x07,0x0}}, {0x48, 0x52, {0x13f,2629,100, 0,0,0x00,0xbe,0x20,0x80,0x00,0x07,0x0}}, {0x53, 0x6c, {0x140, 950,100, 0,0,0x00,0xbe,0x20,0x80,0x00,0x07,0x0}} }; -static const opl4_region_t regions_31[] = { /* Slow Strings */ +static const struct opl4_region regions_31[] = { /* Slow Strings */ {0x15, 0x3b, {0x0b0,4810,100, 0,1,0x0a,0xbe,0x19,0xf0,0x00,0x07,0x0}}, {0x3c, 0x41, {0x035,4035,100, 0,1,0x05,0xbe,0x19,0xf0,0x00,0x07,0x0}}, {0x42, 0x47, {0x033,3129,100, 0,1,0x05,0xbe,0x19,0xf0,0x00,0x07,0x0}}, {0x48, 0x52, {0x034,2625,100, 0,1,0x05,0xbe,0x19,0xf0,0x00,0x07,0x0}}, {0x53, 0x6c, {0x0af, 936,100, 0,1,0x00,0xbe,0x19,0xf0,0x00,0x07,0x0}} }; -static const opl4_region_t regions_32[] = { /* Synth Strings 1 */ +static const struct opl4_region regions_32[] = { /* Synth Strings 1 */ {0x05, 0x71, {0x002,6045,100,-2,0,0x00,0xa6,0x20,0x93,0x22,0x06,0x0}}, {0x15, 0x6c, {0x0ae,3261,100, 2,0,0x00,0xc6,0x20,0x70,0x01,0x06,0x0}} }; -static const opl4_region_t regions_33[] = { /* Synth Strings 2 */ +static const struct opl4_region regions_33[] = { /* Synth Strings 2 */ {0x15, 0x6c, {0x002,4513,100, 5,1,0x00,0xb4,0x19,0x70,0x00,0x06,0x0}}, {0x15, 0x6c, {0x002,4501,100,-5,1,0x00,0xb4,0x19,0x70,0x00,0x06,0x0}} }; -static const opl4_region_t regions_34[] = { /* Choir Aahs */ +static const struct opl4_region regions_34[] = { /* Choir Aahs */ {0x15, 0x3a, {0x018,5010,100, 0,2,0x00,0xc2,0x1a,0x70,0x00,0x08,0x0}}, {0x3b, 0x40, {0x019,4370,100, 0,2,0x00,0xc2,0x1a,0x70,0x00,0x08,0x0}}, {0x41, 0x47, {0x01a,3478,100, 0,2,0x00,0xc2,0x1a,0x70,0x00,0x08,0x0}}, {0x48, 0x6c, {0x01b,2197,100, 0,2,0x00,0xc2,0x1a,0x70,0x00,0x08,0x0}} }; -static const opl4_region_t regions_35[] = { /* Voice Oohs */ +static const struct opl4_region regions_35[] = { /* Voice Oohs */ {0x15, 0x6c, {0x029,3596,100, 0,0,0x00,0xe6,0x20,0xf7,0x20,0x08,0x0}} }; -static const opl4_region_t regions_36[] = { /* Synth Voice */ +static const struct opl4_region regions_36[] = { /* Synth Voice */ {0x15, 0x6c, {0x02a,3482,100, 0,1,0x00,0xc2,0x19,0x85,0x21,0x07,0x0}} }; -static const opl4_region_t regions_37[] = { /* Orchestra Hit */ +static const struct opl4_region regions_37[] = { /* Orchestra Hit */ {0x15, 0x6c, {0x049,4394,100, 0,0,0x00,0xfe,0x30,0x80,0x05,0x05,0x0}} }; -static const opl4_region_t regions_38[] = { /* Trumpet */ +static const struct opl4_region regions_38[] = { /* Trumpet */ {0x15, 0x3c, {0x0f6,4706,100, 0,2,0x00,0xd6,0x32,0xf3,0x20,0x0a,0x0}}, {0x3d, 0x43, {0x0f8,3894,100, 0,2,0x00,0xd6,0x32,0xf3,0x20,0x0a,0x0}}, {0x44, 0x48, {0x0f7,3118,100, 0,2,0x00,0xd6,0x32,0xf3,0x20,0x0a,0x0}}, @@ -403,28 +403,28 @@ static const opl4_region_t regions_38[] = { /* Trumpet */ {0x4f, 0x55, {0x0f9,1634,100, 0,2,0x00,0xd6,0x32,0xf3,0x20,0x0a,0x0}}, {0x56, 0x6c, {0x0fb, 786,100, 0,2,0x00,0xd6,0x32,0xf3,0x20,0x0a,0x0}} }; -static const opl4_region_t regions_39[] = { /* Trombone */ +static const struct opl4_region regions_39[] = { /* Trombone */ {0x15, 0x3a, {0x0f0,5053,100, 0,1,0x00,0xd6,0x21,0xf0,0x00,0x09,0x0}}, {0x3b, 0x3f, {0x0f1,4290,100, 0,1,0x00,0xd6,0x21,0xf0,0x00,0x09,0x0}}, {0x40, 0x6c, {0x0f2,3580,100, 0,1,0x00,0xd6,0x21,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_3a[] = { /* Tuba */ +static const struct opl4_region regions_3a[] = { /* Tuba */ {0x15, 0x2d, {0x085,7096,100, 0,1,0x00,0xde,0x21,0xf5,0x10,0x09,0x0}}, {0x2e, 0x6c, {0x086,6014,100, 0,1,0x00,0xde,0x21,0xf5,0x10,0x09,0x0}} }; -static const opl4_region_t regions_3b[] = { /* Muted Trumpet */ +static const struct opl4_region regions_3b[] = { /* Muted Trumpet */ {0x15, 0x45, {0x0b1,4135,100, 0,0,0x00,0xcc,0x28,0xf3,0x10,0x0a,0x1}}, {0x46, 0x6c, {0x0b2,2599,100, 0,0,0x00,0xcc,0x28,0x83,0x10,0x0a,0x1}} }; -static const opl4_region_t regions_3c[] = { /* French Horns */ +static const struct opl4_region regions_3c[] = { /* French Horns */ {0x15, 0x49, {0x07c,3624,100, 0,2,0x00,0xd0,0x1a,0xf0,0x00,0x09,0x0}}, {0x4a, 0x6c, {0x07d,2664,100, 0,2,0x00,0xd0,0x1a,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_3d[] = { /* Brass Section */ +static const struct opl4_region regions_3d[] = { /* Brass Section */ {0x15, 0x42, {0x0fc,4375,100, 0,0,0x00,0xd6,0x28,0xf0,0x00,0x0a,0x0}}, {0x43, 0x6c, {0x0fd,2854,100, 0,0,0x00,0xd6,0x28,0xf0,0x00,0x0a,0x0}} }; -static const opl4_region_t regions_3e[] = { /* Synth Brass 1 */ +static const struct opl4_region regions_3e[] = { /* Synth Brass 1 */ {0x01, 0x27, {0x0d3,9094,100,-1,0,0x00,0xbe,0x18,0xa5,0x11,0x08,0x0}}, {0x28, 0x2d, {0x0da,8335,100,-1,0,0x00,0xbe,0x18,0xa5,0x11,0x08,0x0}}, {0x2e, 0x33, {0x0d4,7558,100,-1,0,0x00,0xbe,0x18,0xa5,0x11,0x08,0x0}}, @@ -450,7 +450,7 @@ static const opl4_region_t regions_3e[] = { /* Synth Brass 1 */ {0x5e, 0x64, {0x122,1421,100, 1,1,0x00,0xbe,0x19,0x85,0x23,0x08,0x0}}, {0x65, 0x7f, {0x123,-115,100, 1,1,0x00,0xbe,0x19,0x85,0x23,0x08,0x0}} }; -static const opl4_region_t regions_3f[] = { /* Synth Brass 2 */ +static const struct opl4_region regions_3f[] = { /* Synth Brass 2 */ {0x01, 0x27, {0x118,9113,100, 3,6,0x00,0xae,0x26,0x85,0x23,0x08,0x0}}, {0x28, 0x2d, {0x119,8350,100, 3,6,0x00,0xae,0x26,0x85,0x23,0x08,0x0}}, {0x2e, 0x33, {0x11a,7575,100, 3,6,0x00,0xae,0x26,0x85,0x23,0x08,0x0}}, @@ -465,7 +465,7 @@ static const opl4_region_t regions_3f[] = { /* Synth Brass 2 */ {0x65, 0x7f, {0x123,-105,100, 3,6,0x00,0xae,0x26,0x85,0x23,0x08,0x0}}, {0x00, 0x7f, {0x124,4034,100,-3,2,0x00,0xea,0x22,0x85,0x23,0x08,0x0}} }; -static const opl4_region_t regions_40[] = { /* Soprano Sax */ +static const struct opl4_region regions_40[] = { /* Soprano Sax */ {0x15, 0x3f, {0x0e3,4228,100, 0,1,0x00,0xc8,0x21,0xf5,0x20,0x0a,0x0}}, {0x40, 0x45, {0x0e4,3495,100, 0,1,0x00,0xc8,0x21,0xf5,0x20,0x0a,0x0}}, {0x46, 0x4b, {0x0e5,2660,100, 0,1,0x00,0xd6,0x21,0xf5,0x20,0x0a,0x0}}, @@ -473,7 +473,7 @@ static const opl4_region_t regions_40[] = { /* Soprano Sax */ {0x52, 0x59, {0x0e7,1186,100, 0,1,0x00,0xd6,0x21,0xf5,0x20,0x0a,0x0}}, {0x59, 0x6c, {0x0e8,1730,100, 0,1,0x00,0xc8,0x21,0xf5,0x20,0x0a,0x0}} }; -static const opl4_region_t regions_41[] = { /* Alto Sax */ +static const struct opl4_region regions_41[] = { /* Alto Sax */ {0x15, 0x32, {0x092,6204,100, 0,1,0x00,0xbe,0x19,0xf5,0x20,0x0b,0x0}}, {0x33, 0x35, {0x096,5812,100, 0,1,0x00,0xbe,0x19,0xf5,0x20,0x0b,0x0}}, {0x36, 0x3a, {0x099,5318,100, 0,1,0x00,0xbe,0x19,0xf5,0x20,0x0b,0x0}}, @@ -488,7 +488,7 @@ static const opl4_region_t regions_41[] = { /* Alto Sax */ {0x51, 0x53, {0x091,2088,100, 0,1,0x00,0xbe,0x19,0xf5,0x20,0x0b,0x0}}, {0x54, 0x6c, {0x095,1732,100, 0,1,0x00,0xbe,0x19,0xf5,0x20,0x0b,0x0}} }; -static const opl4_region_t regions_42[] = { /* Tenor Sax */ +static const struct opl4_region regions_42[] = { /* Tenor Sax */ {0x24, 0x30, {0x0e9,6301,100, 0,1,0x00,0xbc,0x19,0xf4,0x10,0x0b,0x0}}, {0x31, 0x34, {0x0ea,5781,100, 0,1,0x00,0xbc,0x19,0xf4,0x10,0x0b,0x0}}, {0x35, 0x3a, {0x0eb,5053,100, 0,1,0x00,0xbc,0x19,0xf4,0x10,0x0b,0x0}}, @@ -497,13 +497,13 @@ static const opl4_region_t regions_42[] = { /* Tenor Sax */ {0x48, 0x51, {0x0ee,2462,100, 0,1,0x00,0xbc,0x19,0xf4,0x10,0x0b,0x0}}, {0x52, 0x6c, {0x0ef,1421,100, 0,1,0x00,0xbc,0x19,0xf4,0x10,0x0b,0x0}} }; -static const opl4_region_t regions_43[] = { /* Baritone Sax */ +static const struct opl4_region regions_43[] = { /* Baritone Sax */ {0x15, 0x2d, {0x0df,6714,100, 0,1,0x00,0xce,0x19,0xf0,0x00,0x0a,0x0}}, {0x2e, 0x34, {0x0e1,5552,100, 0,1,0x00,0xce,0x19,0xf0,0x00,0x0a,0x0}}, {0x35, 0x39, {0x0e2,5178,100, 0,1,0x00,0xce,0x19,0xf0,0x00,0x0a,0x0}}, {0x3a, 0x6c, {0x0e0,4437,100, 0,1,0x00,0xce,0x19,0xf0,0x00,0x0a,0x0}} }; -static const opl4_region_t regions_44[] = { /* Oboe */ +static const struct opl4_region regions_44[] = { /* Oboe */ {0x15, 0x3c, {0x042,4493,100, 0,1,0x00,0xe6,0x39,0xf4,0x10,0x0a,0x0}}, {0x3d, 0x43, {0x044,3702,100, 0,1,0x00,0xdc,0x39,0xf4,0x10,0x0a,0x0}}, {0x44, 0x49, {0x043,2956,100, 0,1,0x00,0xdc,0x39,0xf4,0x10,0x0a,0x0}}, @@ -511,55 +511,55 @@ static const opl4_region_t regions_44[] = { /* Oboe */ {0x50, 0x55, {0x045,1420,100, 0,1,0x00,0xdc,0x39,0xf4,0x10,0x0a,0x0}}, {0x56, 0x6c, {0x047, 630,100, 0,1,0x00,0xe6,0x39,0xf4,0x10,0x0a,0x0}} }; -static const opl4_region_t regions_45[] = { /* English Horn */ +static const struct opl4_region regions_45[] = { /* English Horn */ {0x15, 0x38, {0x03c,5098,100, 0,1,0x00,0xc4,0x31,0xf0,0x00,0x09,0x0}}, {0x39, 0x3e, {0x03b,4291,100, 0,1,0x00,0xc4,0x31,0xf0,0x00,0x09,0x0}}, {0x3f, 0x6c, {0x03d,3540,100, 0,1,0x00,0xc4,0x31,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_46[] = { /* Bassoon */ +static const struct opl4_region regions_46[] = { /* Bassoon */ {0x15, 0x22, {0x038,7833,100, 0,1,0x00,0xc6,0x31,0xf0,0x00,0x0b,0x0}}, {0x23, 0x2e, {0x03a,7070,100, 0,1,0x00,0xc6,0x31,0xf0,0x00,0x0b,0x0}}, {0x2f, 0x6c, {0x039,6302,100, 0,1,0x00,0xc6,0x31,0xf0,0x00,0x0b,0x0}} }; -static const opl4_region_t regions_47[] = { /* Clarinet */ +static const struct opl4_region regions_47[] = { /* Clarinet */ {0x15, 0x3b, {0x09e,5900,100, 0,1,0x00,0xc8,0x29,0xf3,0x20,0x0a,0x0}}, {0x3c, 0x41, {0x0a0,5158,100, 0,1,0x00,0xc8,0x29,0xf3,0x20,0x0a,0x0}}, {0x42, 0x4a, {0x09f,4260,100, 0,1,0x00,0xc8,0x29,0xf3,0x20,0x0a,0x0}}, {0x4b, 0x6c, {0x0a1,2957,100, 0,1,0x00,0xc8,0x29,0xf3,0x20,0x0a,0x0}} }; -static const opl4_region_t regions_48[] = { /* Piccolo */ +static const struct opl4_region regions_48[] = { /* Piccolo */ {0x15, 0x40, {0x071,4803,100, 0,0,0x00,0xe6,0x38,0xf0,0x00,0x0a,0x2}}, {0x41, 0x4d, {0x072,3314,100, 0,0,0x00,0xe6,0x38,0xf0,0x00,0x0a,0x2}}, {0x4e, 0x53, {0x073,1731,100, 0,0,0x00,0xe6,0x38,0xf0,0x00,0x0a,0x2}}, {0x54, 0x5f, {0x074,2085,100, 0,0,0x00,0xe6,0x38,0xf0,0x00,0x0a,0x2}}, {0x60, 0x6c, {0x075,1421,100, 0,0,0x00,0xe6,0x38,0xf0,0x00,0x0a,0x2}} }; -static const opl4_region_t regions_49[] = { /* Flute */ +static const struct opl4_region regions_49[] = { /* Flute */ {0x15, 0x40, {0x071,4803,100, 0,0,0x00,0xdc,0x38,0xf0,0x00,0x0a,0x2}}, {0x41, 0x4d, {0x072,3314,100, 0,0,0x00,0xdc,0x38,0xf0,0x00,0x0a,0x2}}, {0x4e, 0x6c, {0x073,1731,100, 0,0,0x00,0xe6,0x38,0xf0,0x00,0x0a,0x2}} }; -static const opl4_region_t regions_4a[] = { /* Recorder */ +static const struct opl4_region regions_4a[] = { /* Recorder */ {0x15, 0x6f, {0x0bd,4897,100, 0,0,0x00,0xec,0x30,0x70,0x00,0x09,0x1}} }; -static const opl4_region_t regions_4b[] = { /* Pan Flute */ +static const struct opl4_region regions_4b[] = { /* Pan Flute */ {0x15, 0x6c, {0x077,2359,100, 0,0,0x00,0xde,0x38,0xf0,0x00,0x09,0x3}} }; -static const opl4_region_t regions_4c[] = { /* Bottle Blow */ +static const struct opl4_region regions_4c[] = { /* Bottle Blow */ {0x15, 0x6c, {0x077,2359,100, 0,0,0x00,0xc8,0x38,0xf0,0x00,0x09,0x1}}, {0x01, 0x7f, {0x125,7372,100, 0,0,0x1e,0x80,0x00,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_4d[] = { /* Shakuhachi */ +static const struct opl4_region regions_4d[] = { /* Shakuhachi */ {0x00, 0x7f, {0x0ab,4548,100, 0,0,0x00,0xd6,0x30,0xf0,0x00,0x0a,0x3}}, {0x15, 0x6c, {0x076,3716,100, 0,0,0x00,0xa2,0x28,0x70,0x00,0x09,0x2}} }; -static const opl4_region_t regions_4e[] = { /* Whistle */ +static const struct opl4_region regions_4e[] = { /* Whistle */ {0x00, 0x7f, {0x0aa,1731,100, 0,4,0x00,0xd2,0x2c,0x70,0x00,0x0a,0x0}} }; -static const opl4_region_t regions_4f[] = { /* Ocarina */ +static const struct opl4_region regions_4f[] = { /* Ocarina */ {0x00, 0x7f, {0x0aa,1731,100, 0,1,0x00,0xce,0x29,0x90,0x00,0x0a,0x1}} }; -static const opl4_region_t regions_50[] = { /* Square Lead */ +static const struct opl4_region regions_50[] = { /* Square Lead */ {0x01, 0x2a, {0x0cc,9853,100, 3,0,0x00,0xac,0x38,0xc6,0x21,0x09,0x0}}, {0x2b, 0x36, {0x0cd,6785,100, 3,0,0x00,0xac,0x38,0xc6,0x21,0x09,0x0}}, {0x37, 0x42, {0x0ca,5248,100, 3,0,0x00,0xac,0x38,0xc6,0x21,0x09,0x0}}, @@ -573,7 +573,7 @@ static const opl4_region_t regions_50[] = { /* Square Lead */ {0x4f, 0x5a, {0x0ce,2167,100,-3,0,0x00,0xac,0x08,0xc6,0x21,0x09,0x0}}, {0x5b, 0x7f, {0x0cb, 631,100,-3,0,0x00,0xac,0x08,0xc6,0x21,0x09,0x0}} }; -static const opl4_region_t regions_51[] = { /* Sawtooth Lead */ +static const struct opl4_region regions_51[] = { /* Sawtooth Lead */ {0x01, 0x27, {0x118,9108,100, 0,0,0x00,0xc8,0x30,0xf2,0x22,0x0a,0x0}}, {0x28, 0x2d, {0x119,8345,100, 0,0,0x00,0xc8,0x30,0xf2,0x22,0x0a,0x0}}, {0x2e, 0x33, {0x11a,7570,100, 0,0,0x00,0xc8,0x30,0xf2,0x22,0x0a,0x0}}, @@ -599,15 +599,15 @@ static const opl4_region_t regions_51[] = { /* Sawtooth Lead */ {0x5e, 0x66, {0x122,1416,100, 0,0,0x00,0xc8,0x30,0xf2,0x22,0x0a,0x0}}, {0x67, 0x7f, {0x123,-120,100, 0,0,0x00,0xc8,0x30,0xf2,0x22,0x0a,0x0}} }; -static const opl4_region_t regions_52[] = { /* Calliope Lead */ +static const struct opl4_region regions_52[] = { /* Calliope Lead */ {0x00, 0x7f, {0x0aa,1731,100, 0,0,0x00,0xc2,0x28,0x90,0x00,0x0a,0x2}}, {0x15, 0x6c, {0x076,3716,100, 0,0,0x00,0xb6,0x28,0xb0,0x00,0x09,0x2}} }; -static const opl4_region_t regions_53[] = { /* Chiffer Lead */ +static const struct opl4_region regions_53[] = { /* Chiffer Lead */ {0x00, 0x7f, {0x13a,3665,100, 0,2,0x00,0xcc,0x2a,0xf0,0x10,0x09,0x1}}, {0x01, 0x7f, {0x0fe,3660,100, 0,0,0x00,0xbe,0x28,0xf3,0x10,0x17,0x0}} }; -static const opl4_region_t regions_54[] = { /* Charang Lead */ +static const struct opl4_region regions_54[] = { /* Charang Lead */ {0x00, 0x40, {0x0a5,6594,100, 0,3,0x00,0xba,0x33,0xf2,0x11,0x09,0x0}}, {0x41, 0x7f, {0x0a6,5433,100, 0,3,0x00,0xba,0x33,0xf2,0x11,0x09,0x0}}, {0x01, 0x27, {0x118,9098,100, 0,2,0x00,0xa4,0x2a,0xf2,0x22,0x0e,0x0}}, @@ -623,11 +623,11 @@ static const opl4_region_t regions_54[] = { /* Charang Lead */ {0x5e, 0x66, {0x122,1416,100, 0,2,0x00,0xa4,0x2a,0xf2,0x22,0x0e,0x0}}, {0x67, 0x7f, {0x123,-120,100, 0,2,0x00,0xa4,0x2a,0xf2,0x22,0x0e,0x0}} }; -static const opl4_region_t regions_55[] = { /* Voice Lead */ +static const struct opl4_region regions_55[] = { /* Voice Lead */ {0x00, 0x7f, {0x0aa,1739,100, 0,6,0x00,0x8c,0x2e,0x90,0x00,0x0a,0x0}}, {0x15, 0x6c, {0x02a,3474,100, 0,1,0x00,0xd8,0x29,0xf0,0x05,0x0a,0x0}} }; -static const opl4_region_t regions_56[] = { /* 5ths Lead */ +static const struct opl4_region regions_56[] = { /* 5ths Lead */ {0x01, 0x27, {0x118,8468,100, 0,2,0x00,0xd0,0x32,0xf5,0x20,0x08,0x0}}, {0x28, 0x2d, {0x119,7705,100, 0,2,0x00,0xd0,0x32,0xf5,0x20,0x08,0x0}}, {0x2e, 0x33, {0x11a,6930,100, 0,2,0x00,0xd0,0x32,0xf5,0x20,0x08,0x0}}, @@ -642,7 +642,7 @@ static const opl4_region_t regions_56[] = { /* 5ths Lead */ {0x65, 0x7f, {0x123,-750,100, 0,2,0x00,0xd0,0x32,0xf5,0x20,0x08,0x0}}, {0x05, 0x71, {0x002,4503,100, 0,1,0x00,0xb8,0x31,0xb3,0x20,0x0b,0x0}} }; -static const opl4_region_t regions_57[] = { /* Bass & Lead */ +static const struct opl4_region regions_57[] = { /* Bass & Lead */ {0x00, 0x7f, {0x117,8109,100, 0,1,0x00,0xbc,0x29,0xf3,0x50,0x08,0x0}}, {0x01, 0x27, {0x118,9097,100, 0,2,0x00,0xbc,0x2a,0xf2,0x20,0x0a,0x0}}, {0x28, 0x2d, {0x119,8334,100, 0,2,0x00,0xbc,0x2a,0xf2,0x20,0x0a,0x0}}, @@ -657,15 +657,15 @@ static const opl4_region_t regions_57[] = { /* Bass & Lead */ {0x5e, 0x66, {0x122,1415,100, 0,2,0x00,0xbc,0x2a,0xf2,0x20,0x0a,0x0}}, {0x67, 0x7f, {0x123,-121,100, 0,2,0x00,0xbc,0x2a,0xf2,0x20,0x0a,0x0}} }; -static const opl4_region_t regions_58[] = { /* New Age Pad */ +static const struct opl4_region regions_58[] = { /* New Age Pad */ {0x15, 0x6c, {0x002,4501,100, 0,4,0x00,0xa4,0x24,0x80,0x01,0x05,0x0}}, {0x15, 0x6c, {0x0f3,4253,100, 0,3,0x00,0x8c,0x23,0xa2,0x14,0x06,0x1}} }; -static const opl4_region_t regions_59[] = { /* Warm Pad */ +static const struct opl4_region regions_59[] = { /* Warm Pad */ {0x15, 0x6c, {0x04e,5306,100, 2,2,0x00,0x92,0x2a,0x34,0x23,0x05,0x2}}, {0x15, 0x6c, {0x029,3575,100,-2,2,0x00,0xbe,0x22,0x31,0x23,0x06,0x0}} }; -static const opl4_region_t regions_5a[] = { /* Polysynth Pad */ +static const struct opl4_region regions_5a[] = { /* Polysynth Pad */ {0x01, 0x27, {0x118,9111,100, 0,3,0x00,0xae,0x23,0xf2,0x20,0x07,0x1}}, {0x28, 0x2d, {0x119,8348,100, 0,3,0x00,0xae,0x23,0xf2,0x20,0x07,0x1}}, {0x2e, 0x33, {0x11a,7573,100, 0,3,0x00,0xae,0x23,0xf2,0x20,0x07,0x1}}, @@ -680,29 +680,29 @@ static const opl4_region_t regions_5a[] = { /* Polysynth Pad */ {0x67, 0x7f, {0x123,-107,100, 0,3,0x00,0xae,0x23,0xf2,0x20,0x07,0x1}}, {0x00, 0x7f, {0x124,4024,100, 0,2,0x00,0xae,0x22,0xe5,0x20,0x08,0x0}} }; -static const opl4_region_t regions_5b[] = { /* Choir Pad */ +static const struct opl4_region regions_5b[] = { /* Choir Pad */ {0x15, 0x3a, {0x018,5010,100, 0,5,0x00,0xb0,0x25,0x70,0x00,0x06,0x0}}, {0x3b, 0x40, {0x019,4370,100, 0,5,0x00,0xb0,0x25,0x70,0x00,0x06,0x0}}, {0x41, 0x47, {0x01a,3478,100, 0,5,0x00,0xb0,0x25,0x70,0x00,0x06,0x0}}, {0x48, 0x6c, {0x01b,2197,100, 0,5,0x00,0xb0,0x25,0x70,0x00,0x06,0x0}}, {0x15, 0x6c, {0x02a,3482,100, 0,4,0x00,0x98,0x24,0x65,0x21,0x06,0x0}} }; -static const opl4_region_t regions_5c[] = { /* Bowed Pad */ +static const struct opl4_region regions_5c[] = { /* Bowed Pad */ {0x15, 0x6c, {0x101,4790,100,-1,1,0x00,0xbe,0x19,0x44,0x14,0x16,0x0}}, {0x00, 0x7f, {0x0aa,1720,100, 1,1,0x00,0x94,0x19,0x40,0x00,0x06,0x0}} }; -static const opl4_region_t regions_5d[] = { /* Metallic Pad */ +static const struct opl4_region regions_5d[] = { /* Metallic Pad */ {0x15, 0x31, {0x00c,6943,100, 0,2,0x00,0xa0,0x0a,0x60,0x03,0x06,0x0}}, {0x32, 0x38, {0x00d,5416,100, 0,2,0x00,0xa0,0x0a,0x60,0x03,0x06,0x0}}, {0x39, 0x47, {0x00e,4385,100, 0,2,0x00,0xa0,0x0a,0x60,0x03,0x06,0x0}}, {0x48, 0x6c, {0x00f,2849,100, 0,2,0x00,0xa0,0x0a,0x60,0x03,0x06,0x0}}, {0x00, 0x7f, {0x03f,4224,100, 0,1,0x00,0x9c,0x31,0x65,0x16,0x07,0x0}} }; -static const opl4_region_t regions_5e[] = { /* Halo Pad */ +static const struct opl4_region regions_5e[] = { /* Halo Pad */ {0x00, 0x7f, {0x124,4038,100, 0,2,0x00,0xa6,0x1a,0x85,0x23,0x08,0x0}}, {0x15, 0x6c, {0x02a,3471,100, 0,3,0x00,0xc0,0x1b,0xc0,0x05,0x06,0x0}} }; -static const opl4_region_t regions_5f[] = { /* Sweep Pad */ +static const struct opl4_region regions_5f[] = { /* Sweep Pad */ {0x01, 0x27, {0x0d3,9100,100, 0,1,0x00,0xce,0x19,0x13,0x11,0x06,0x0}}, {0x28, 0x2d, {0x0da,8341,100, 0,1,0x00,0xce,0x19,0x13,0x11,0x06,0x0}}, {0x2e, 0x33, {0x0d4,7564,100, 0,1,0x00,0xce,0x19,0x13,0x11,0x06,0x0}}, @@ -728,21 +728,21 @@ static const opl4_region_t regions_5f[] = { /* Sweep Pad */ {0x5e, 0x63, {0x0d8,1415,100, 0,0,0x00,0xce,0x18,0x13,0x11,0x06,0x0}}, {0x64, 0x7f, {0x0d9,-121,100, 0,0,0x00,0xce,0x18,0x13,0x11,0x06,0x0}} }; -static const opl4_region_t regions_60[] = { /* Ice Rain */ +static const struct opl4_region regions_60[] = { /* Ice Rain */ {0x01, 0x7f, {0x04e,9345,100, 0,2,0x00,0xcc,0x22,0xa3,0x63,0x17,0x0}}, {0x00, 0x7f, {0x143,5586, 20, 0,2,0x00,0x6e,0x2a,0xf0,0x05,0x05,0x0}} }; -static const opl4_region_t regions_61[] = { /* Soundtrack */ +static const struct opl4_region regions_61[] = { /* Soundtrack */ {0x15, 0x6c, {0x002,4501,100, 0,2,0x00,0xb6,0x2a,0x60,0x01,0x05,0x0}}, {0x15, 0x6c, {0x0f3,1160,100, 0,5,0x00,0xa8,0x2d,0x52,0x14,0x06,0x2}} }; -static const opl4_region_t regions_62[] = { /* Crystal */ +static const struct opl4_region regions_62[] = { /* Crystal */ {0x15, 0x6c, {0x0f3,1826,100, 0,3,0x00,0xb8,0x33,0xf6,0x25,0x25,0x0}}, {0x15, 0x2c, {0x06d,7454,100, 0,3,0x00,0xac,0x3b,0x85,0x24,0x06,0x0}}, {0x2d, 0x36, {0x06e,5925,100, 0,3,0x00,0xac,0x3b,0x85,0x24,0x06,0x0}}, {0x37, 0x6c, {0x06f,4403,100, 0,3,0x09,0xac,0x3b,0x85,0x24,0x06,0x0}} }; -static const opl4_region_t regions_63[] = { /* Atmosphere */ +static const struct opl4_region regions_63[] = { /* Atmosphere */ {0x05, 0x71, {0x002,4509,100, 0,2,0x00,0xc8,0x32,0x73,0x22,0x06,0x1}}, {0x15, 0x2f, {0x0b3,6964,100, 0,2,0x05,0xc2,0x32,0xf5,0x34,0x07,0x2}}, {0x30, 0x36, {0x0b7,5567,100, 0,2,0x0c,0xc2,0x32,0xf5,0x34,0x07,0x2}}, @@ -750,29 +750,29 @@ static const opl4_region_t regions_63[] = { /* Atmosphere */ {0x3d, 0x43, {0x0b4,3892,100, 0,2,0x00,0xc2,0x32,0xf6,0x35,0x07,0x2}}, {0x44, 0x60, {0x0b6,2723,100, 0,2,0x00,0xc2,0x32,0xf6,0x35,0x17,0x2}} }; -static const opl4_region_t regions_64[] = { /* Brightness */ +static const struct opl4_region regions_64[] = { /* Brightness */ {0x00, 0x7f, {0x137,5285,100, 0,2,0x00,0xbe,0x2a,0xa5,0x18,0x08,0x0}}, {0x15, 0x6c, {0x02a,3481,100, 0,1,0x00,0xc8,0x29,0x80,0x05,0x05,0x0}} }; -static const opl4_region_t regions_65[] = { /* Goblins */ +static const struct opl4_region regions_65[] = { /* Goblins */ {0x15, 0x6c, {0x002,4501,100,-1,2,0x00,0xca,0x2a,0x40,0x01,0x05,0x0}}, {0x15, 0x6c, {0x009,9679, 20, 1,4,0x00,0x3c,0x0c,0x22,0x11,0x06,0x0}} }; -static const opl4_region_t regions_66[] = { /* Echoes */ +static const struct opl4_region regions_66[] = { /* Echoes */ {0x15, 0x6c, {0x02a,3487,100, 0,3,0x00,0xae,0x2b,0xf5,0x21,0x06,0x0}}, {0x00, 0x7f, {0x124,4027,100, 0,3,0x00,0xae,0x2b,0x85,0x23,0x07,0x0}} }; -static const opl4_region_t regions_67[] = { /* Sci-Fi */ +static const struct opl4_region regions_67[] = { /* Sci-Fi */ {0x15, 0x31, {0x00c,6940,100, 0,3,0x00,0xc8,0x2b,0x90,0x05,0x06,0x3}}, {0x32, 0x38, {0x00d,5413,100, 0,3,0x00,0xc8,0x2b,0x90,0x05,0x06,0x3}}, {0x39, 0x47, {0x00e,4382,100, 0,3,0x00,0xc8,0x2b,0x90,0x05,0x06,0x3}}, {0x48, 0x6c, {0x00f,2846,100, 0,3,0x00,0xc8,0x2b,0x90,0x05,0x06,0x3}}, {0x15, 0x6c, {0x002,4498,100, 0,2,0x00,0xd4,0x22,0x80,0x01,0x05,0x0}} }; -static const opl4_region_t regions_68[] = { /* Sitar */ +static const struct opl4_region regions_68[] = { /* Sitar */ {0x00, 0x7f, {0x10f,4408,100, 0,2,0x00,0xc4,0x32,0xf4,0x15,0x16,0x1}} }; -static const opl4_region_t regions_69[] = { /* Banjo */ +static const struct opl4_region regions_69[] = { /* Banjo */ {0x15, 0x34, {0x013,5685,100, 0,0,0x00,0xdc,0x38,0xf6,0x15,0x09,0x0}}, {0x35, 0x38, {0x014,5009,100, 0,0,0x00,0xdc,0x38,0xf6,0x15,0x09,0x0}}, {0x39, 0x3c, {0x012,4520,100, 0,0,0x00,0xdc,0x38,0xf6,0x15,0x09,0x0}}, @@ -780,21 +780,21 @@ static const opl4_region_t regions_69[] = { /* Banjo */ {0x45, 0x4c, {0x017,2661,100, 0,0,0x00,0xdc,0x38,0xf6,0x15,0x09,0x0}}, {0x4d, 0x6d, {0x016,1632,100, 0,0,0x00,0xdc,0x38,0xf6,0x15,0x09,0x0}} }; -static const opl4_region_t regions_6a[] = { /* Shamisen */ +static const struct opl4_region regions_6a[] = { /* Shamisen */ {0x15, 0x6c, {0x10e,3273,100, 0,0,0x00,0xc0,0x28,0xf7,0x76,0x08,0x0}} }; -static const opl4_region_t regions_6b[] = { /* Koto */ +static const struct opl4_region regions_6b[] = { /* Koto */ {0x00, 0x7f, {0x0a9,4033,100, 0,0,0x00,0xc6,0x20,0xf0,0x06,0x07,0x0}} }; -static const opl4_region_t regions_6c[] = { /* Kalimba */ +static const struct opl4_region regions_6c[] = { /* Kalimba */ {0x00, 0x7f, {0x137,3749,100, 0,0,0x00,0xce,0x38,0xf5,0x18,0x08,0x0}} }; -static const opl4_region_t regions_6d[] = { /* Bagpipe */ +static const struct opl4_region regions_6d[] = { /* Bagpipe */ {0x15, 0x39, {0x0a4,7683,100, 0,4,0x00,0xc0,0x1c,0xf0,0x00,0x09,0x0}}, {0x15, 0x39, {0x0a7,7680,100, 0,1,0x00,0xaa,0x19,0xf0,0x00,0x09,0x0}}, {0x3a, 0x6c, {0x0a8,3697,100, 0,1,0x00,0xaa,0x19,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_6e[] = { /* Fiddle */ +static const struct opl4_region regions_6e[] = { /* Fiddle */ {0x15, 0x3a, {0x105,5158,100, 0,1,0x00,0xca,0x31,0xf3,0x20,0x09,0x0}}, {0x3b, 0x3f, {0x102,4754,100, 0,1,0x00,0xca,0x31,0xf3,0x20,0x09,0x0}}, {0x40, 0x41, {0x106,4132,100, 0,1,0x00,0xca,0x31,0xf3,0x20,0x09,0x0}}, @@ -806,64 +806,64 @@ static const opl4_region_t regions_6e[] = { /* Fiddle */ {0x4f, 0x51, {0x10d,2166,100, 0,1,0x00,0xca,0x31,0xf3,0x20,0x09,0x0}}, {0x52, 0x6c, {0x109,1825,100, 0,1,0x00,0xca,0x31,0xf3,0x20,0x09,0x0}} }; -static const opl4_region_t regions_6f[] = { /* Shanai */ +static const struct opl4_region regions_6f[] = { /* Shanai */ {0x15, 0x6c, {0x041,6946,100, 0,1,0x00,0xc4,0x31,0x95,0x20,0x09,0x0}} }; -static const opl4_region_t regions_70[] = { /* Tinkle Bell */ +static const struct opl4_region regions_70[] = { /* Tinkle Bell */ {0x15, 0x73, {0x0f3,1821,100, 0,3,0x00,0xc8,0x3b,0xd6,0x25,0x25,0x0}}, {0x00, 0x7f, {0x137,5669,100, 0,3,0x00,0x66,0x3b,0xf5,0x18,0x08,0x0}} }; -static const opl4_region_t regions_71[] = { /* Agogo */ +static const struct opl4_region regions_71[] = { /* Agogo */ {0x15, 0x74, {0x00b,2474,100, 0,0,0x00,0xd2,0x38,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_72[] = { /* Steel Drums */ +static const struct opl4_region regions_72[] = { /* Steel Drums */ {0x01, 0x7f, {0x0fe,3670,100, 0,0,0x00,0xca,0x38,0xf3,0x06,0x17,0x1}}, {0x15, 0x6c, {0x100,9602,100, 0,0,0x00,0x54,0x38,0xb0,0x05,0x16,0x1}} }; -static const opl4_region_t regions_73[] = { /* Woodblock */ +static const struct opl4_region regions_73[] = { /* Woodblock */ {0x15, 0x6c, {0x02c,2963, 50, 0,0,0x07,0xd4,0x00,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_74[] = { /* Taiko Drum */ +static const struct opl4_region regions_74[] = { /* Taiko Drum */ {0x13, 0x6c, {0x03e,1194, 50, 0,0,0x00,0xaa,0x38,0xf0,0x04,0x04,0x0}} }; -static const opl4_region_t regions_75[] = { /* Melodic Tom */ +static const struct opl4_region regions_75[] = { /* Melodic Tom */ {0x15, 0x6c, {0x0c7,6418, 50, 0,0,0x00,0xe4,0x38,0xf0,0x05,0x01,0x0}} }; -static const opl4_region_t regions_76[] = { /* Synth Drum */ +static const struct opl4_region regions_76[] = { /* Synth Drum */ {0x15, 0x6c, {0x026,3898, 50, 0,0,0x00,0xd0,0x38,0xf0,0x04,0x04,0x0}} }; -static const opl4_region_t regions_77[] = { /* Reverse Cymbal */ +static const struct opl4_region regions_77[] = { /* Reverse Cymbal */ {0x15, 0x6c, {0x031,4138, 50, 0,0,0x00,0xfe,0x38,0x3a,0xf0,0x09,0x0}} }; -static const opl4_region_t regions_78[] = { /* Guitar Fret Noise */ +static const struct opl4_region regions_78[] = { /* Guitar Fret Noise */ {0x15, 0x6c, {0x138,5266,100, 0,0,0x00,0xa0,0x38,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_79[] = { /* Breath Noise */ +static const struct opl4_region regions_79[] = { /* Breath Noise */ {0x01, 0x7f, {0x125,4269,100, 0,0,0x1e,0xd0,0x38,0xf0,0x00,0x09,0x0}} }; -static const opl4_region_t regions_7a[] = { /* Seashore */ +static const struct opl4_region regions_7a[] = { /* Seashore */ {0x15, 0x6c, {0x008,2965, 20,-2,0,0x00,0xfe,0x00,0x20,0x03,0x04,0x0}}, {0x01, 0x7f, {0x037,4394, 20, 2,0,0x14,0xfe,0x00,0x20,0x04,0x05,0x0}} }; -static const opl4_region_t regions_7b[] = { /* Bird Tweet */ +static const struct opl4_region regions_7b[] = { /* Bird Tweet */ {0x15, 0x6c, {0x009,8078, 5,-4,7,0x00,0xc2,0x0f,0x22,0x12,0x07,0x0}}, {0x15, 0x6c, {0x009,3583, 5, 4,5,0x00,0xae,0x15,0x72,0x12,0x07,0x0}} }; -static const opl4_region_t regions_7c[] = { /* Telephone Ring */ +static const struct opl4_region regions_7c[] = { /* Telephone Ring */ {0x15, 0x6c, {0x003,3602, 10, 0,0,0x00,0xce,0x00,0xf0,0x00,0x0f,0x0}} }; -static const opl4_region_t regions_7d[] = { /* Helicopter */ +static const struct opl4_region regions_7d[] = { /* Helicopter */ {0x0c, 0x7f, {0x001,2965, 10,-2,0,0x00,0xe0,0x08,0x30,0x01,0x07,0x0}}, {0x01, 0x7f, {0x037,4394, 10, 2,0,0x44,0x76,0x00,0x30,0x01,0x07,0x0}} }; -static const opl4_region_t regions_7e[] = { /* Applause */ +static const struct opl4_region regions_7e[] = { /* Applause */ {0x15, 0x6c, {0x036,8273, 20,-6,7,0x00,0xc4,0x0f,0x70,0x01,0x05,0x0}}, {0x15, 0x6c, {0x036,8115, 5, 6,7,0x00,0xc6,0x07,0x70,0x01,0x05,0x0}} }; -static const opl4_region_t regions_7f[] = { /* Gun Shot */ +static const struct opl4_region regions_7f[] = { /* Gun Shot */ {0x15, 0x6c, {0x139,2858, 20, 0,0,0x00,0xbe,0x38,0xf0,0x03,0x00,0x0}} }; -static const opl4_region_t regions_drums[] = { +static const struct opl4_region regions_drums[] = { {0x18, 0x18, {0x0cb,6397,100, 3,0,0x00,0xf4,0x38,0xc9,0x1c,0x0c,0x0}}, {0x19, 0x19, {0x0c4,3714,100, 0,0,0x00,0xe0,0x00,0x97,0x19,0x09,0x0}}, {0x1a, 0x1a, {0x0c4,3519,100, 0,0,0x00,0xea,0x00,0x61,0x01,0x07,0x0}}, @@ -924,7 +924,7 @@ static const opl4_region_t regions_drums[] = { }; #define REGION(num) { ARRAY_SIZE(regions ## num), regions ## num } -const opl4_region_ptr_t snd_yrw801_regions[0x81] = { +const struct opl4_region_ptr snd_yrw801_regions[0x81] = { REGION(_00), REGION(_01), REGION(_02), REGION(_03), REGION(_04), REGION(_05), REGION(_06), REGION(_07), REGION(_08), REGION(_09), REGION(_0a), REGION(_0b), -- cgit v1.1 From 97f02e05f246a2346275c1c93a3079e8933e74b2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:17:19 +0100 Subject: [ALSA] Remove xxx_t typedefs: I2C drivers Remove xxx_t typedefs from the i2c drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/cs8403.h | 8 +-- include/sound/cs8427.h | 17 +++-- include/sound/i2c.h | 78 +++++++++++----------- include/sound/tea575x-tuner.h | 12 ++-- include/sound/tea6330t.h | 5 +- include/sound/uda1341.h | 4 +- sound/i2c/cs8427.c | 142 ++++++++++++++++++++++------------------ sound/i2c/i2c.c | 79 ++++++++++++---------- sound/i2c/l3/uda1341.c | 69 ++++++++++--------- sound/i2c/other/ak4114.c | 122 +++++++++++++++++----------------- sound/i2c/other/ak4117.c | 122 +++++++++++++++++----------------- sound/i2c/other/ak4xxx-adda.c | 49 ++++++++------ sound/i2c/other/tea575x-tuner.c | 8 +-- sound/i2c/tea6330t.c | 84 ++++++++++++++---------- 14 files changed, 429 insertions(+), 370 deletions(-) diff --git a/include/sound/cs8403.h b/include/sound/cs8403.h index 0b7d216..c6c3f9f 100644 --- a/include/sound/cs8403.h +++ b/include/sound/cs8403.h @@ -36,7 +36,7 @@ #endif -SND_CS8403_DECL void SND_CS8403_DECODE(snd_aes_iec958_t *diga, unsigned char bits) +SND_CS8403_DECL void SND_CS8403_DECODE(struct snd_aes_iec958 *diga, unsigned char bits) { if (bits & 0x01) { /* consumer */ if (!(bits & 0x02)) @@ -79,7 +79,7 @@ SND_CS8403_DECL void SND_CS8403_DECODE(snd_aes_iec958_t *diga, unsigned char bit } } -SND_CS8403_DECL unsigned char SND_CS8403_ENCODE(snd_aes_iec958_t *diga) +SND_CS8403_DECL unsigned char SND_CS8403_ENCODE(struct snd_aes_iec958 *diga) { unsigned char bits; @@ -166,7 +166,7 @@ SND_CS8403_DECL unsigned char SND_CS8403_ENCODE(snd_aes_iec958_t *diga) #endif -SND_CS8404_DECL void SND_CS8404_DECODE(snd_aes_iec958_t *diga, unsigned char bits) +SND_CS8404_DECL void SND_CS8404_DECODE(struct snd_aes_iec958 *diga, unsigned char bits) { if (bits & 0x10) { /* consumer */ if (!(bits & 0x20)) @@ -205,7 +205,7 @@ SND_CS8404_DECL void SND_CS8404_DECODE(snd_aes_iec958_t *diga, unsigned char bit } } -SND_CS8404_DECL unsigned char SND_CS8404_ENCODE(snd_aes_iec958_t *diga) +SND_CS8404_DECL unsigned char SND_CS8404_ENCODE(struct snd_aes_iec958 *diga) { unsigned char bits; diff --git a/include/sound/cs8427.h b/include/sound/cs8427.h index e725b70..97fd9ac 100644 --- a/include/sound/cs8427.h +++ b/include/sound/cs8427.h @@ -186,11 +186,16 @@ #define CS8427_VERSHIFT 0 #define CS8427_VER8427A 0x71 -int snd_cs8427_create(snd_i2c_bus_t *bus, unsigned char addr, - unsigned int reset_timeout, snd_i2c_device_t **r_cs8427); -int snd_cs8427_reg_write(snd_i2c_device_t *device, unsigned char reg, unsigned char val); -int snd_cs8427_iec958_build(snd_i2c_device_t *cs8427, snd_pcm_substream_t *playback_substream, snd_pcm_substream_t *capture_substream); -int snd_cs8427_iec958_active(snd_i2c_device_t *cs8427, int active); -int snd_cs8427_iec958_pcm(snd_i2c_device_t *cs8427, unsigned int rate); +struct snd_pcm_substream; + +int snd_cs8427_create(struct snd_i2c_bus *bus, unsigned char addr, + unsigned int reset_timeout, struct snd_i2c_device **r_cs8427); +int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg, + unsigned char val); +int snd_cs8427_iec958_build(struct snd_i2c_device *cs8427, + struct snd_pcm_substream *playback_substream, + struct snd_pcm_substream *capture_substream); +int snd_cs8427_iec958_active(struct snd_i2c_device *cs8427, int active); +int snd_cs8427_iec958_pcm(struct snd_i2c_device *cs8427, unsigned int rate); #endif /* __SOUND_CS8427_H */ diff --git a/include/sound/i2c.h b/include/sound/i2c.h index a665ddf..81eb23e 100644 --- a/include/sound/i2c.h +++ b/include/sound/i2c.h @@ -21,82 +21,84 @@ * */ -typedef struct _snd_i2c_device snd_i2c_device_t; -typedef struct _snd_i2c_bus snd_i2c_bus_t; - #define SND_I2C_DEVICE_ADDRTEN (1<<0) /* 10-bit I2C address */ -struct _snd_i2c_device { +struct snd_i2c_device { struct list_head list; - snd_i2c_bus_t *bus; /* I2C bus */ + struct snd_i2c_bus *bus; /* I2C bus */ char name[32]; /* some useful device name */ unsigned short flags; /* device flags */ unsigned short addr; /* device address (might be 10-bit) */ unsigned long private_value; void *private_data; - void (*private_free)(snd_i2c_device_t *device); + void (*private_free)(struct snd_i2c_device *device); +}; + +#define snd_i2c_device(n) list_entry(n, struct snd_i2c_device, list) + +struct snd_i2c_bit_ops { + void (*start)(struct snd_i2c_bus *bus); /* transfer start */ + void (*stop)(struct snd_i2c_bus *bus); /* transfer stop */ + void (*direction)(struct snd_i2c_bus *bus, int clock, int data); /* set line direction (0 = write, 1 = read) */ + void (*setlines)(struct snd_i2c_bus *bus, int clock, int data); + int (*getclock)(struct snd_i2c_bus *bus); + int (*getdata)(struct snd_i2c_bus *bus, int ack); }; -#define snd_i2c_device(n) list_entry(n, snd_i2c_device_t, list) - -typedef struct _snd_i2c_bit_ops { - void (*start)(snd_i2c_bus_t *bus); /* transfer start */ - void (*stop)(snd_i2c_bus_t *bus); /* transfer stop */ - void (*direction)(snd_i2c_bus_t *bus, int clock, int data); /* set line direction (0 = write, 1 = read) */ - void (*setlines)(snd_i2c_bus_t *bus, int clock, int data); - int (*getclock)(snd_i2c_bus_t *bus); - int (*getdata)(snd_i2c_bus_t *bus, int ack); -} snd_i2c_bit_ops_t; - -typedef struct _snd_i2c_ops { - int (*sendbytes)(snd_i2c_device_t *device, unsigned char *bytes, int count); - int (*readbytes)(snd_i2c_device_t *device, unsigned char *bytes, int count); - int (*probeaddr)(snd_i2c_bus_t *bus, unsigned short addr); -} snd_i2c_ops_t; - -struct _snd_i2c_bus { - snd_card_t *card; /* card which I2C belongs to */ +struct snd_i2c_ops { + int (*sendbytes)(struct snd_i2c_device *device, unsigned char *bytes, int count); + int (*readbytes)(struct snd_i2c_device *device, unsigned char *bytes, int count); + int (*probeaddr)(struct snd_i2c_bus *bus, unsigned short addr); +}; + +struct snd_i2c_bus { + struct snd_card *card; /* card which I2C belongs to */ char name[32]; /* some useful label */ struct semaphore lock_mutex; - snd_i2c_bus_t *master; /* master bus when SCK/SCL is shared */ + struct snd_i2c_bus *master; /* master bus when SCK/SCL is shared */ struct list_head buses; /* master: slave buses sharing SCK/SCL, slave: link list */ struct list_head devices; /* attached devices to this bus */ union { - snd_i2c_bit_ops_t *bit; + struct snd_i2c_bit_ops *bit; void *ops; } hw_ops; /* lowlevel operations */ - snd_i2c_ops_t *ops; /* midlevel operations */ + struct snd_i2c_ops *ops; /* midlevel operations */ unsigned long private_value; void *private_data; - void (*private_free)(snd_i2c_bus_t *bus); + void (*private_free)(struct snd_i2c_bus *bus); }; -#define snd_i2c_slave_bus(n) list_entry(n, snd_i2c_bus_t, buses) +#define snd_i2c_slave_bus(n) list_entry(n, struct snd_i2c_bus, buses) -int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master, snd_i2c_bus_t **ri2c); -int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char addr, snd_i2c_device_t **rdevice); -int snd_i2c_device_free(snd_i2c_device_t *device); +int snd_i2c_bus_create(struct snd_card *card, const char *name, + struct snd_i2c_bus *master, struct snd_i2c_bus **ri2c); +int snd_i2c_device_create(struct snd_i2c_bus *bus, const char *name, + unsigned char addr, struct snd_i2c_device **rdevice); +int snd_i2c_device_free(struct snd_i2c_device *device); -static inline void snd_i2c_lock(snd_i2c_bus_t *bus) { +static inline void snd_i2c_lock(struct snd_i2c_bus *bus) +{ if (bus->master) down(&bus->master->lock_mutex); else down(&bus->lock_mutex); } -static inline void snd_i2c_unlock(snd_i2c_bus_t *bus) { + +static inline void snd_i2c_unlock(struct snd_i2c_bus *bus) +{ if (bus->master) up(&bus->master->lock_mutex); else up(&bus->lock_mutex); } -int snd_i2c_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); -int snd_i2c_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); -int snd_i2c_probeaddr(snd_i2c_bus_t *bus, unsigned short addr); +int snd_i2c_sendbytes(struct snd_i2c_device *device, unsigned char *bytes, int count); +int snd_i2c_readbytes(struct snd_i2c_device *device, unsigned char *bytes, int count); +int snd_i2c_probeaddr(struct snd_i2c_bus *bus, unsigned short addr); #endif /* __SOUND_I2C_H */ diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h index b82e408..a4f55452 100644 --- a/include/sound/tea575x-tuner.h +++ b/include/sound/tea575x-tuner.h @@ -24,15 +24,15 @@ #include <linux/videodev.h> -typedef struct snd_tea575x tea575x_t; +struct snd_tea575x; struct snd_tea575x_ops { - void (*write)(tea575x_t *tea, unsigned int val); - unsigned int (*read)(tea575x_t *tea); + void (*write)(struct snd_tea575x *tea, unsigned int val); + unsigned int (*read)(struct snd_tea575x *tea); }; struct snd_tea575x { - snd_card_t *card; + struct snd_card *card; struct video_device vd; /* video device */ struct file_operations fops; int dev_nr; /* requested device number + 1 */ @@ -45,7 +45,7 @@ struct snd_tea575x { void *private_data; }; -void snd_tea575x_init(tea575x_t *tea); -void snd_tea575x_exit(tea575x_t *tea); +void snd_tea575x_init(struct snd_tea575x *tea); +void snd_tea575x_exit(struct snd_tea575x *tea); #endif /* __SOUND_TEA575X_TUNER_H */ diff --git a/include/sound/tea6330t.h b/include/sound/tea6330t.h index 1b265bf..51b282b 100644 --- a/include/sound/tea6330t.h +++ b/include/sound/tea6330t.h @@ -24,7 +24,8 @@ #include "i2c.h" /* generic i2c support */ -int snd_tea6330t_detect(snd_i2c_bus_t *bus, int equalizer); -int snd_tea6330t_update_mixer(snd_card_t * card, snd_i2c_bus_t * bus, int equalizer, int fader); +int snd_tea6330t_detect(struct snd_i2c_bus *bus, int equalizer); +int snd_tea6330t_update_mixer(struct snd_card *card, struct snd_i2c_bus *bus, + int equalizer, int fader); #endif /* __SOUND_TEA6330T_H */ diff --git a/include/sound/uda1341.h b/include/sound/uda1341.h index 54a048a..2e564bf 100644 --- a/include/sound/uda1341.h +++ b/include/sound/uda1341.h @@ -15,7 +15,7 @@ * features support */ -/* $Id: uda1341.h,v 1.7 2005/11/17 10:25:22 tiwai Exp $ */ +/* $Id: uda1341.h,v 1.8 2005/11/17 14:17:21 tiwai Exp $ */ #define UDA1341_ALSA_NAME "snd-uda1341" @@ -119,7 +119,7 @@ enum write_through { FLUSH, }; -int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clnt); +int __init snd_chip_uda1341_mixer_new(struct snd_card *card, struct l3_client **clnt); /* * Local variables: diff --git a/sound/i2c/cs8427.c b/sound/i2c/cs8427.c index 1a05cfb..9deba80 100644 --- a/sound/i2c/cs8427.c +++ b/sound/i2c/cs8427.c @@ -30,7 +30,7 @@ #include <sound/cs8427.h> #include <sound/asoundef.h> -static void snd_cs8427_reset(snd_i2c_device_t *cs8427); +static void snd_cs8427_reset(struct snd_i2c_device *cs8427); MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("IEC958 (S/PDIF) receiver & transmitter by Cirrus Logic"); @@ -38,22 +38,22 @@ MODULE_LICENSE("GPL"); #define CS8427_ADDR (0x20>>1) /* fixed address */ -typedef struct { - snd_pcm_substream_t *substream; +struct cs8427_stream { + struct snd_pcm_substream *substream; char hw_status[24]; /* hardware status */ char def_status[24]; /* default status */ char pcm_status[24]; /* PCM private status */ char hw_udata[32]; - snd_kcontrol_t *pcm_ctl; -} cs8427_stream_t; + struct snd_kcontrol *pcm_ctl; +}; -typedef struct { +struct cs8427 { unsigned char regmap[0x14]; /* map of first 1 + 13 registers */ unsigned int rate; unsigned int reset_timeout; - cs8427_stream_t playback; - cs8427_stream_t capture; -} cs8427_t; + struct cs8427_stream playback; + struct cs8427_stream capture; +}; static unsigned char swapbits(unsigned char val) { @@ -67,7 +67,8 @@ static unsigned char swapbits(unsigned char val) return res; } -int snd_cs8427_reg_write(snd_i2c_device_t *device, unsigned char reg, unsigned char val) +int snd_cs8427_reg_write(struct snd_i2c_device *device, unsigned char reg, + unsigned char val) { int err; unsigned char buf[2]; @@ -81,7 +82,7 @@ int snd_cs8427_reg_write(snd_i2c_device_t *device, unsigned char reg, unsigned c return 0; } -static int snd_cs8427_reg_read(snd_i2c_device_t *device, unsigned char reg) +static int snd_cs8427_reg_read(struct snd_i2c_device *device, unsigned char reg) { int err; unsigned char buf; @@ -97,28 +98,29 @@ static int snd_cs8427_reg_read(snd_i2c_device_t *device, unsigned char reg) return buf; } -static int snd_cs8427_select_corudata(snd_i2c_device_t *device, int udata) +static int snd_cs8427_select_corudata(struct snd_i2c_device *device, int udata) { - cs8427_t *chip = device->private_data; + struct cs8427 *chip = device->private_data; int err; udata = udata ? CS8427_BSEL : 0; if (udata != (chip->regmap[CS8427_REG_CSDATABUF] & udata)) { chip->regmap[CS8427_REG_CSDATABUF] &= ~CS8427_BSEL; chip->regmap[CS8427_REG_CSDATABUF] |= udata; - err = snd_cs8427_reg_write(device, CS8427_REG_CSDATABUF, chip->regmap[CS8427_REG_CSDATABUF]); + err = snd_cs8427_reg_write(device, CS8427_REG_CSDATABUF, + chip->regmap[CS8427_REG_CSDATABUF]); if (err < 0) return err; } return 0; } -static int snd_cs8427_send_corudata(snd_i2c_device_t *device, +static int snd_cs8427_send_corudata(struct snd_i2c_device *device, int udata, unsigned char *ndata, int count) { - cs8427_t *chip = device->private_data; + struct cs8427 *chip = device->private_data; char *hw_data = udata ? chip->playback.hw_udata : chip->playback.hw_status; char data[32]; int err, idx; @@ -133,7 +135,8 @@ static int snd_cs8427_send_corudata(snd_i2c_device_t *device, if (memcmp(hw_data, data, count) == 0) { chip->regmap[CS8427_REG_UDATABUF] &= ~CS8427_UBMMASK; chip->regmap[CS8427_REG_UDATABUF] |= CS8427_UBMZEROS | CS8427_EFTUI; - if ((err = snd_cs8427_reg_write(device, CS8427_REG_UDATABUF, chip->regmap[CS8427_REG_UDATABUF])) < 0) + if ((err = snd_cs8427_reg_write(device, CS8427_REG_UDATABUF, + chip->regmap[CS8427_REG_UDATABUF])) < 0) return err; return 0; } @@ -146,15 +149,15 @@ static int snd_cs8427_send_corudata(snd_i2c_device_t *device, return 1; } -static void snd_cs8427_free(snd_i2c_device_t *device) +static void snd_cs8427_free(struct snd_i2c_device *device) { kfree(device->private_data); } -int snd_cs8427_create(snd_i2c_bus_t *bus, +int snd_cs8427_create(struct snd_i2c_bus *bus, unsigned char addr, unsigned int reset_timeout, - snd_i2c_device_t **r_cs8427) + struct snd_i2c_device **r_cs8427) { static unsigned char initvals1[] = { CS8427_REG_CONTROL1 | CS8427_REG_AUTOINC, @@ -194,11 +197,12 @@ int snd_cs8427_create(snd_i2c_bus_t *bus, CS8427_UD | CS8427_EFTUI | CS8427_DETUI, }; int err; - cs8427_t *chip; - snd_i2c_device_t *device; + struct cs8427 *chip; + struct snd_i2c_device *device; unsigned char buf[24]; - if ((err = snd_i2c_device_create(bus, "CS8427", CS8427_ADDR | (addr & 7), &device)) < 0) + if ((err = snd_i2c_device_create(bus, "CS8427", CS8427_ADDR | (addr & 7), + &device)) < 0) return err; chip = device->private_data = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { @@ -208,9 +212,13 @@ int snd_cs8427_create(snd_i2c_bus_t *bus, device->private_free = snd_cs8427_free; snd_i2c_lock(bus); - if ((err = snd_cs8427_reg_read(device, CS8427_REG_ID_AND_VER)) != CS8427_VER8427A) { + if ((err = snd_cs8427_reg_read(device, CS8427_REG_ID_AND_VER)) != + CS8427_VER8427A) { snd_i2c_unlock(bus); - snd_printk(KERN_ERR "unable to find CS8427 signature (expected 0x%x, read 0x%x), initialization is not completed\n", CS8427_VER8427A, err); + snd_printk(KERN_ERR "unable to find CS8427 signature " + "(expected 0x%x, read 0x%x),\n", + CS8427_VER8427A, err); + snd_printk(KERN_ERR " initialization is not completed\n"); return -EFAULT; } /* turn off run bit while making changes to configuration */ @@ -279,9 +287,9 @@ int snd_cs8427_create(snd_i2c_bus_t *bus, * put back AES3INPUT. This workaround is described in latest * CS8427 datasheet, otherwise TXDSERIAL will not work. */ -static void snd_cs8427_reset(snd_i2c_device_t *cs8427) +static void snd_cs8427_reset(struct snd_i2c_device *cs8427) { - cs8427_t *chip; + struct cs8427 *chip; unsigned long end_time; int data; @@ -289,10 +297,12 @@ static void snd_cs8427_reset(snd_i2c_device_t *cs8427) chip = cs8427->private_data; snd_i2c_lock(cs8427->bus); chip->regmap[CS8427_REG_CLOCKSOURCE] &= ~(CS8427_RUN | CS8427_RXDMASK); - snd_cs8427_reg_write(cs8427, CS8427_REG_CLOCKSOURCE, chip->regmap[CS8427_REG_CLOCKSOURCE]); + snd_cs8427_reg_write(cs8427, CS8427_REG_CLOCKSOURCE, + chip->regmap[CS8427_REG_CLOCKSOURCE]); udelay(200); chip->regmap[CS8427_REG_CLOCKSOURCE] |= CS8427_RUN | CS8427_RXDILRCK; - snd_cs8427_reg_write(cs8427, CS8427_REG_CLOCKSOURCE, chip->regmap[CS8427_REG_CLOCKSOURCE]); + snd_cs8427_reg_write(cs8427, CS8427_REG_CLOCKSOURCE, + chip->regmap[CS8427_REG_CLOCKSOURCE]); udelay(200); snd_i2c_unlock(cs8427->bus); end_time = jiffies + chip->reset_timeout; @@ -307,12 +317,13 @@ static void snd_cs8427_reset(snd_i2c_device_t *cs8427) snd_i2c_lock(cs8427->bus); chip->regmap[CS8427_REG_CLOCKSOURCE] &= ~CS8427_RXDMASK; chip->regmap[CS8427_REG_CLOCKSOURCE] |= CS8427_RXDAES3INPUT; - snd_cs8427_reg_write(cs8427, CS8427_REG_CLOCKSOURCE, chip->regmap[CS8427_REG_CLOCKSOURCE]); + snd_cs8427_reg_write(cs8427, CS8427_REG_CLOCKSOURCE, + chip->regmap[CS8427_REG_CLOCKSOURCE]); snd_i2c_unlock(cs8427->bus); } -static int snd_cs8427_in_status_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cs8427_in_status_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -321,10 +332,10 @@ static int snd_cs8427_in_status_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs8427_in_status_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs8427_in_status_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_i2c_device_t *device = snd_kcontrol_chip(kcontrol); + struct snd_i2c_device *device = snd_kcontrol_chip(kcontrol); int data; snd_i2c_lock(device->bus); @@ -336,18 +347,18 @@ static int snd_cs8427_in_status_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs8427_qsubcode_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cs8427_qsubcode_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; uinfo->count = 10; return 0; } -static int snd_cs8427_qsubcode_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs8427_qsubcode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_i2c_device_t *device = snd_kcontrol_chip(kcontrol); + struct snd_i2c_device *device = snd_kcontrol_chip(kcontrol); unsigned char reg = CS8427_REG_QSUBCODE; int err; @@ -366,18 +377,18 @@ static int snd_cs8427_qsubcode_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs8427_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs8427_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_cs8427_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs8427_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_i2c_device_t *device = snd_kcontrol_chip(kcontrol); - cs8427_t *chip = device->private_data; + struct snd_i2c_device *device = snd_kcontrol_chip(kcontrol); + struct cs8427 *chip = device->private_data; snd_i2c_lock(device->bus); memcpy(ucontrol->value.iec958.status, chip->playback.def_status, 24); @@ -385,13 +396,15 @@ static int snd_cs8427_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs8427_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs8427_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_i2c_device_t *device = snd_kcontrol_chip(kcontrol); - cs8427_t *chip = device->private_data; - unsigned char *status = kcontrol->private_value ? chip->playback.pcm_status : chip->playback.def_status; - snd_pcm_runtime_t *runtime = chip->playback.substream ? chip->playback.substream->runtime : NULL; + struct snd_i2c_device *device = snd_kcontrol_chip(kcontrol); + struct cs8427 *chip = device->private_data; + unsigned char *status = kcontrol->private_value ? + chip->playback.pcm_status : chip->playback.def_status; + struct snd_pcm_runtime *runtime = chip->playback.substream ? + chip->playback.substream->runtime : NULL; int err, change; snd_i2c_lock(device->bus); @@ -406,21 +419,22 @@ static int snd_cs8427_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static int snd_cs8427_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs8427_spdif_mask_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_cs8427_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs8427_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { memset(ucontrol->value.iec958.status, 0xff, 24); return 0; } -static snd_kcontrol_new_t snd_cs8427_iec958_controls[] = { +static struct snd_kcontrol_new snd_cs8427_iec958_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .info = snd_cs8427_in_status_info, @@ -469,12 +483,12 @@ static snd_kcontrol_new_t snd_cs8427_iec958_controls[] = { .get = snd_cs8427_qsubcode_get }}; -int snd_cs8427_iec958_build(snd_i2c_device_t *cs8427, - snd_pcm_substream_t *play_substream, - snd_pcm_substream_t *cap_substream) +int snd_cs8427_iec958_build(struct snd_i2c_device *cs8427, + struct snd_pcm_substream *play_substream, + struct snd_pcm_substream *cap_substream) { - cs8427_t *chip = cs8427->private_data; - snd_kcontrol_t *kctl; + struct cs8427 *chip = cs8427->private_data; + struct snd_kcontrol *kctl; unsigned int idx; int err; @@ -498,9 +512,9 @@ int snd_cs8427_iec958_build(snd_i2c_device_t *cs8427, return 0; } -int snd_cs8427_iec958_active(snd_i2c_device_t *cs8427, int active) +int snd_cs8427_iec958_active(struct snd_i2c_device *cs8427, int active) { - cs8427_t *chip; + struct cs8427 *chip; snd_assert(cs8427, return -ENXIO); chip = cs8427->private_data; @@ -512,9 +526,9 @@ int snd_cs8427_iec958_active(snd_i2c_device_t *cs8427, int active) return 0; } -int snd_cs8427_iec958_pcm(snd_i2c_device_t *cs8427, unsigned int rate) +int snd_cs8427_iec958_pcm(struct snd_i2c_device *cs8427, unsigned int rate) { - cs8427_t *chip; + struct cs8427 *chip; char *status; int err, reset; diff --git a/sound/i2c/i2c.c b/sound/i2c/i2c.c index e4e505b..c4e1f2c 100644 --- a/sound/i2c/i2c.c +++ b/sound/i2c/i2c.c @@ -32,20 +32,23 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("Generic i2c interface for ALSA"); MODULE_LICENSE("GPL"); -static int snd_i2c_bit_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); -static int snd_i2c_bit_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count); -static int snd_i2c_bit_probeaddr(snd_i2c_bus_t *bus, unsigned short addr); - -static snd_i2c_ops_t snd_i2c_bit_ops = { +static int snd_i2c_bit_sendbytes(struct snd_i2c_device *device, + unsigned char *bytes, int count); +static int snd_i2c_bit_readbytes(struct snd_i2c_device *device, + unsigned char *bytes, int count); +static int snd_i2c_bit_probeaddr(struct snd_i2c_bus *bus, + unsigned short addr); + +static struct snd_i2c_ops snd_i2c_bit_ops = { .sendbytes = snd_i2c_bit_sendbytes, .readbytes = snd_i2c_bit_readbytes, .probeaddr = snd_i2c_bit_probeaddr, }; -static int snd_i2c_bus_free(snd_i2c_bus_t *bus) +static int snd_i2c_bus_free(struct snd_i2c_bus *bus) { - snd_i2c_bus_t *slave; - snd_i2c_device_t *device; + struct snd_i2c_bus *slave; + struct snd_i2c_device *device; snd_assert(bus != NULL, return -EINVAL); while (!list_empty(&bus->devices)) { @@ -66,17 +69,18 @@ static int snd_i2c_bus_free(snd_i2c_bus_t *bus) return 0; } -static int snd_i2c_bus_dev_free(snd_device_t *device) +static int snd_i2c_bus_dev_free(struct snd_device *device) { - snd_i2c_bus_t *bus = device->device_data; + struct snd_i2c_bus *bus = device->device_data; return snd_i2c_bus_free(bus); } -int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master, snd_i2c_bus_t **ri2c) +int snd_i2c_bus_create(struct snd_card *card, const char *name, + struct snd_i2c_bus *master, struct snd_i2c_bus **ri2c) { - snd_i2c_bus_t *bus; + struct snd_i2c_bus *bus; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_i2c_bus_dev_free, }; @@ -102,9 +106,10 @@ int snd_i2c_bus_create(snd_card_t *card, const char *name, snd_i2c_bus_t *master return 0; } -int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char addr, snd_i2c_device_t **rdevice) +int snd_i2c_device_create(struct snd_i2c_bus *bus, const char *name, + unsigned char addr, struct snd_i2c_device **rdevice) { - snd_i2c_device_t *device; + struct snd_i2c_device *device; *rdevice = NULL; snd_assert(bus != NULL, return -EINVAL); @@ -119,7 +124,7 @@ int snd_i2c_device_create(snd_i2c_bus_t *bus, const char *name, unsigned char ad return 0; } -int snd_i2c_device_free(snd_i2c_device_t *device) +int snd_i2c_device_free(struct snd_i2c_device *device) { if (device->bus) list_del(&device->list); @@ -129,18 +134,18 @@ int snd_i2c_device_free(snd_i2c_device_t *device) return 0; } -int snd_i2c_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count) +int snd_i2c_sendbytes(struct snd_i2c_device *device, unsigned char *bytes, int count) { return device->bus->ops->sendbytes(device, bytes, count); } -int snd_i2c_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count) +int snd_i2c_readbytes(struct snd_i2c_device *device, unsigned char *bytes, int count) { return device->bus->ops->readbytes(device, bytes, count); } -int snd_i2c_probeaddr(snd_i2c_bus_t *bus, unsigned short addr) +int snd_i2c_probeaddr(struct snd_i2c_bus *bus, unsigned short addr) { return bus->ops->probeaddr(bus, addr); } @@ -149,31 +154,31 @@ int snd_i2c_probeaddr(snd_i2c_bus_t *bus, unsigned short addr) * bit-operations */ -static inline void snd_i2c_bit_hw_start(snd_i2c_bus_t *bus) +static inline void snd_i2c_bit_hw_start(struct snd_i2c_bus *bus) { if (bus->hw_ops.bit->start) bus->hw_ops.bit->start(bus); } -static inline void snd_i2c_bit_hw_stop(snd_i2c_bus_t *bus) +static inline void snd_i2c_bit_hw_stop(struct snd_i2c_bus *bus) { if (bus->hw_ops.bit->stop) bus->hw_ops.bit->stop(bus); } -static void snd_i2c_bit_direction(snd_i2c_bus_t *bus, int clock, int data) +static void snd_i2c_bit_direction(struct snd_i2c_bus *bus, int clock, int data) { if (bus->hw_ops.bit->direction) bus->hw_ops.bit->direction(bus, clock, data); } -static void snd_i2c_bit_set(snd_i2c_bus_t *bus, int clock, int data) +static void snd_i2c_bit_set(struct snd_i2c_bus *bus, int clock, int data) { bus->hw_ops.bit->setlines(bus, clock, data); } #if 0 -static int snd_i2c_bit_clock(snd_i2c_bus_t *bus) +static int snd_i2c_bit_clock(struct snd_i2c_bus *bus) { if (bus->hw_ops.bit->getclock) return bus->hw_ops.bit->getclock(bus); @@ -181,12 +186,12 @@ static int snd_i2c_bit_clock(snd_i2c_bus_t *bus) } #endif -static int snd_i2c_bit_data(snd_i2c_bus_t *bus, int ack) +static int snd_i2c_bit_data(struct snd_i2c_bus *bus, int ack) { return bus->hw_ops.bit->getdata(bus, ack); } -static void snd_i2c_bit_start(snd_i2c_bus_t *bus) +static void snd_i2c_bit_start(struct snd_i2c_bus *bus) { snd_i2c_bit_hw_start(bus); snd_i2c_bit_direction(bus, 1, 1); /* SCL - wr, SDA - wr */ @@ -195,7 +200,7 @@ static void snd_i2c_bit_start(snd_i2c_bus_t *bus) snd_i2c_bit_set(bus, 0, 0); } -static void snd_i2c_bit_stop(snd_i2c_bus_t *bus) +static void snd_i2c_bit_stop(struct snd_i2c_bus *bus) { snd_i2c_bit_set(bus, 0, 0); snd_i2c_bit_set(bus, 1, 0); @@ -203,14 +208,14 @@ static void snd_i2c_bit_stop(snd_i2c_bus_t *bus) snd_i2c_bit_hw_stop(bus); } -static void snd_i2c_bit_send(snd_i2c_bus_t *bus, int data) +static void snd_i2c_bit_send(struct snd_i2c_bus *bus, int data) { snd_i2c_bit_set(bus, 0, data); snd_i2c_bit_set(bus, 1, data); snd_i2c_bit_set(bus, 0, data); } -static int snd_i2c_bit_ack(snd_i2c_bus_t *bus) +static int snd_i2c_bit_ack(struct snd_i2c_bus *bus) { int ack; @@ -223,7 +228,7 @@ static int snd_i2c_bit_ack(snd_i2c_bus_t *bus) return ack ? -EIO : 0; } -static int snd_i2c_bit_sendbyte(snd_i2c_bus_t *bus, unsigned char data) +static int snd_i2c_bit_sendbyte(struct snd_i2c_bus *bus, unsigned char data) { int i, err; @@ -234,7 +239,7 @@ static int snd_i2c_bit_sendbyte(snd_i2c_bus_t *bus, unsigned char data) return 0; } -static int snd_i2c_bit_readbyte(snd_i2c_bus_t *bus, int last) +static int snd_i2c_bit_readbyte(struct snd_i2c_bus *bus, int last) { int i; unsigned char data = 0; @@ -252,9 +257,10 @@ static int snd_i2c_bit_readbyte(snd_i2c_bus_t *bus, int last) return data; } -static int snd_i2c_bit_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count) +static int snd_i2c_bit_sendbytes(struct snd_i2c_device *device, + unsigned char *bytes, int count) { - snd_i2c_bus_t *bus = device->bus; + struct snd_i2c_bus *bus = device->bus; int err, res = 0; if (device->flags & SND_I2C_DEVICE_ADDRTEN) @@ -275,9 +281,10 @@ static int snd_i2c_bit_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, return res; } -static int snd_i2c_bit_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count) +static int snd_i2c_bit_readbytes(struct snd_i2c_device *device, + unsigned char *bytes, int count) { - snd_i2c_bus_t *bus = device->bus; + struct snd_i2c_bus *bus = device->bus; int err, res = 0; if (device->flags & SND_I2C_DEVICE_ADDRTEN) @@ -299,7 +306,7 @@ static int snd_i2c_bit_readbytes(snd_i2c_device_t *device, unsigned char *bytes, return res; } -static int snd_i2c_bit_probeaddr(snd_i2c_bus_t *bus, unsigned short addr) +static int snd_i2c_bit_probeaddr(struct snd_i2c_bus *bus, unsigned short addr) { int err; diff --git a/sound/i2c/l3/uda1341.c b/sound/i2c/l3/uda1341.c index bc7eb23..746500e 100644 --- a/sound/i2c/l3/uda1341.c +++ b/sound/i2c/l3/uda1341.c @@ -17,7 +17,7 @@ * 2002-05-12 Tomas Kasparek another code cleanup */ -/* $Id: uda1341.c,v 1.17 2005/11/17 10:25:22 tiwai Exp $ */ +/* $Id: uda1341.c,v 1.18 2005/11/17 14:17:21 tiwai Exp $ */ #include <sound/driver.h> #include <linux/module.h> @@ -140,15 +140,13 @@ static const char ** uda1341_enum_names[] = { typedef int uda1341_cfg[CMD_LAST]; -typedef struct uda1341 uda1341_t; - struct uda1341 { int (*write) (struct l3_client *uda1341, unsigned short reg, unsigned short val); int (*read) (struct l3_client *uda1341, unsigned short reg); unsigned char regs[uda1341_reg_last]; int active; spinlock_t reg_lock; - snd_card_t *card; + struct snd_card *card; uda1341_cfg cfg; #ifdef CONFIG_PM unsigned char suspend_regs[uda1341_reg_last]; @@ -429,8 +427,8 @@ static const char *peak_value[] = { "-8.76 dB", "-7.28 dB", "-5.81 dB", "-4.34 dB", "-2.88 dB", "-1.43 dB", "0.00 dB", }; -static void snd_uda1341_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_uda1341_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { struct l3_client *clnt = entry->private_data; struct uda1341 *uda = clnt->driver_data; @@ -494,8 +492,8 @@ static void snd_uda1341_proc_read(snd_info_entry_t *entry, snd_iprintf(buffer, "Input Amp. Gain ch 2: %s dB\n", ig_small_value[uda->cfg[CMD_IG]]); } -static void snd_uda1341_proc_regs_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_uda1341_proc_regs_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { struct l3_client *clnt = entry->private_data; struct uda1341 *uda = clnt->driver_data; @@ -514,9 +512,9 @@ static void snd_uda1341_proc_regs_read(snd_info_entry_t *entry, } #endif /* CONFIG_PROC_FS */ -static void __devinit snd_uda1341_proc_init(snd_card_t *card, struct l3_client *clnt) +static void __devinit snd_uda1341_proc_init(struct snd_card *card, struct l3_client *clnt) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(card, "uda1341", &entry)) snd_info_set_text_ops(entry, clnt, 1024, snd_uda1341_proc_read); @@ -536,7 +534,8 @@ static void __devinit snd_uda1341_proc_init(snd_card_t *card, struct l3_client * .private_value = where | (reg << 5) | (shift << 9) | (mask << 12) | (invert << 18) \ } -static int snd_uda1341_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_uda1341_info_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 12) & 63; @@ -547,10 +546,11 @@ static int snd_uda1341_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_uda1341_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_uda1341_get_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct l3_client *clnt = snd_kcontrol_chip(kcontrol); - uda1341_t *uda = clnt->driver_data; + struct uda1341 *uda = clnt->driver_data; int where = kcontrol->private_value & 31; int mask = (kcontrol->private_value >> 12) & 63; int invert = (kcontrol->private_value >> 18) & 1; @@ -562,10 +562,11 @@ static int snd_uda1341_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_uda1341_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_uda1341_put_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct l3_client *clnt = snd_kcontrol_chip(kcontrol); - uda1341_t *uda = clnt->driver_data; + struct uda1341 *uda = clnt->driver_data; int where = kcontrol->private_value & 31; int reg = (kcontrol->private_value >> 5) & 15; int shift = (kcontrol->private_value >> 9) & 7; @@ -591,7 +592,8 @@ static int snd_uda1341_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .private_value = where | (reg << 5) | (shift << 9) | (mask << 12) | (invert << 18) \ } -static int snd_uda1341_info_enum(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_uda1341_info_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int where = kcontrol->private_value & 31; const char **texts; @@ -612,20 +614,22 @@ static int snd_uda1341_info_enum(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_uda1341_get_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_uda1341_get_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct l3_client *clnt = snd_kcontrol_chip(kcontrol); - uda1341_t *uda = clnt->driver_data; + struct uda1341 *uda = clnt->driver_data; int where = kcontrol->private_value & 31; ucontrol->value.enumerated.item[0] = uda->cfg[where]; return 0; } -static int snd_uda1341_put_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_uda1341_put_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct l3_client *clnt = snd_kcontrol_chip(kcontrol); - uda1341_t *uda = clnt->driver_data; + struct uda1341 *uda = clnt->driver_data; int where = kcontrol->private_value & 31; int reg = (kcontrol->private_value >> 5) & 15; int shift = (kcontrol->private_value >> 9) & 7; @@ -648,7 +652,8 @@ static int snd_uda1341_put_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t } -static int snd_uda1341_info_2regs(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_uda1341_info_2regs(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask_1 = (kcontrol->private_value >> 19) & 63; int mask_2 = (kcontrol->private_value >> 25) & 63; @@ -662,10 +667,11 @@ static int snd_uda1341_info_2regs(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_uda1341_get_2regs(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_uda1341_get_2regs(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct l3_client *clnt = snd_kcontrol_chip(kcontrol); - uda1341_t *uda = clnt->driver_data; + struct uda1341 *uda = clnt->driver_data; int where = kcontrol->private_value & 31; int mask_1 = (kcontrol->private_value >> 19) & 63; int mask_2 = (kcontrol->private_value >> 25) & 63; @@ -680,10 +686,11 @@ static int snd_uda1341_get_2regs(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_uda1341_put_2regs(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_uda1341_put_2regs(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct l3_client *clnt = snd_kcontrol_chip(kcontrol); - uda1341_t *uda = clnt->driver_data; + struct uda1341 *uda = clnt->driver_data; int where = kcontrol->private_value & 31; int reg_1 = (kcontrol->private_value >> 5) & 15; int reg_2 = (kcontrol->private_value >> 9) & 15; @@ -716,7 +723,7 @@ static int snd_uda1341_put_2regs(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t /* }}} */ -static snd_kcontrol_new_t snd_uda1341_controls[] = { +static struct snd_kcontrol_new snd_uda1341_controls[] = { UDA1341_SINGLE("Master Playback Switch", CMD_MUTE, data0_2, 2, 1, 1), UDA1341_SINGLE("Master Playback Volume", CMD_VOLUME, data0_0, 0, 63, 1), @@ -748,20 +755,20 @@ static snd_kcontrol_new_t snd_uda1341_controls[] = { static void uda1341_free(struct l3_client *clnt) { - l3_detach_client(clnt); // calls kfree for driver_data (uda1341_t) + l3_detach_client(clnt); // calls kfree for driver_data (struct uda1341) kfree(clnt); } -static int uda1341_dev_free(snd_device_t *device) +static int uda1341_dev_free(struct snd_device *device) { struct l3_client *clnt = device->device_data; uda1341_free(clnt); return 0; } -int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clntp) +int __init snd_chip_uda1341_mixer_new(struct snd_card *card, struct l3_client **clntp) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = uda1341_dev_free, }; struct l3_client *clnt; @@ -792,7 +799,7 @@ int __init snd_chip_uda1341_mixer_new(snd_card_t *card, struct l3_client **clntp *clntp = clnt; strcpy(card->mixername, "UDA1341TS Mixer"); - ((uda1341_t *)uda1341->driver_data)->card = card; + ((struct uda1341 *)clnt->driver_data)->card = card; snd_uda1341_proc_init(card, clnt); diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c index d351b3a..12ffffc 100644 --- a/sound/i2c/other/ak4114.c +++ b/sound/i2c/other/ak4114.c @@ -37,7 +37,7 @@ MODULE_LICENSE("GPL"); static void ak4114_stats(void *); -static void reg_write(ak4114_t *ak4114, unsigned char reg, unsigned char val) +static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val) { ak4114->write(ak4114->private_data, reg, val); if (reg <= AK4114_REG_INT1_MASK) @@ -46,13 +46,13 @@ static void reg_write(ak4114_t *ak4114, unsigned char reg, unsigned char val) ak4114->txcsb[reg-AK4114_REG_RXCSB0] = val; } -static inline unsigned char reg_read(ak4114_t *ak4114, unsigned char reg) +static inline unsigned char reg_read(struct ak4114 *ak4114, unsigned char reg) { return ak4114->read(ak4114->private_data, reg); } #if 0 -static void reg_dump(ak4114_t *ak4114) +static void reg_dump(struct ak4114 *ak4114) { int i; @@ -62,7 +62,7 @@ static void reg_dump(ak4114_t *ak4114) } #endif -static void snd_ak4114_free(ak4114_t *chip) +static void snd_ak4114_free(struct ak4114 *chip) { chip->init = 1; /* don't schedule new work */ mb(); @@ -73,22 +73,22 @@ static void snd_ak4114_free(ak4114_t *chip) kfree(chip); } -static int snd_ak4114_dev_free(snd_device_t *device) +static int snd_ak4114_dev_free(struct snd_device *device) { - ak4114_t *chip = device->device_data; + struct ak4114 *chip = device->device_data; snd_ak4114_free(chip); return 0; } -int snd_ak4114_create(snd_card_t *card, +int snd_ak4114_create(struct snd_card *card, ak4114_read_t *read, ak4114_write_t *write, unsigned char pgm[7], unsigned char txcsb[5], - void *private_data, ak4114_t **r_ak4114) + void *private_data, struct ak4114 **r_ak4114) { - ak4114_t *chip; + struct ak4114 *chip; int err = 0; unsigned char reg; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ak4114_dev_free, }; @@ -129,7 +129,7 @@ int snd_ak4114_create(snd_card_t *card, return err < 0 ? err : -EIO; } -void snd_ak4114_reg_write(ak4114_t *chip, unsigned char reg, unsigned char mask, unsigned char val) +void snd_ak4114_reg_write(struct ak4114 *chip, unsigned char reg, unsigned char mask, unsigned char val) { if (reg <= AK4114_REG_INT1_MASK) reg_write(chip, reg, (chip->regmap[reg] & ~mask) | val); @@ -137,7 +137,7 @@ void snd_ak4114_reg_write(ak4114_t *chip, unsigned char reg, unsigned char mask, reg_write(chip, reg, (chip->txcsb[reg] & ~mask) | val); } -void snd_ak4114_reinit(ak4114_t *chip) +void snd_ak4114_reinit(struct ak4114 *chip) { unsigned char old = chip->regmap[AK4114_REG_PWRDN], reg; @@ -176,8 +176,8 @@ static unsigned int external_rate(unsigned char rcs1) } } -static int snd_ak4114_in_error_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ak4114_in_error_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -186,10 +186,10 @@ static int snd_ak4114_in_error_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4114_in_error_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ak4114_in_error_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4114_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4114 *chip = snd_kcontrol_chip(kcontrol); long *ptr; spin_lock_irq(&chip->lock); @@ -200,8 +200,8 @@ static int snd_ak4114_in_error_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4114_in_bit_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ak4114_in_bit_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -210,10 +210,10 @@ static int snd_ak4114_in_bit_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4114_in_bit_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ak4114_in_bit_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4114_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4114 *chip = snd_kcontrol_chip(kcontrol); unsigned char reg = kcontrol->private_value & 0xff; unsigned char bit = (kcontrol->private_value >> 8) & 0xff; unsigned char inv = (kcontrol->private_value >> 31) & 1; @@ -222,8 +222,8 @@ static int snd_ak4114_in_bit_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4114_rate_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ak4114_rate_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -232,26 +232,26 @@ static int snd_ak4114_rate_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4114_rate_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ak4114_rate_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4114_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4114 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = external_rate(reg_read(chip, AK4114_REG_RCS1)); return 0; } -static int snd_ak4114_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4114_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ak4114_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4114_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4114_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4114 *chip = snd_kcontrol_chip(kcontrol); unsigned i; for (i = 0; i < AK4114_REG_RXCSB_SIZE; i++) @@ -259,10 +259,10 @@ static int snd_ak4114_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ak4114_spdif_playback_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4114_spdif_playback_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4114_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4114 *chip = snd_kcontrol_chip(kcontrol); unsigned i; for (i = 0; i < AK4114_REG_TXCSB_SIZE; i++) @@ -270,10 +270,10 @@ static int snd_ak4114_spdif_playback_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ak4114_spdif_playback_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4114_spdif_playback_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4114_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4114 *chip = snd_kcontrol_chip(kcontrol); unsigned i; for (i = 0; i < AK4114_REG_TXCSB_SIZE; i++) @@ -281,21 +281,21 @@ static int snd_ak4114_spdif_playback_put(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ak4114_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4114_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ak4114_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4114_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { memset(ucontrol->value.iec958.status, 0xff, AK4114_REG_RXCSB_SIZE); return 0; } -static int snd_ak4114_spdif_pinfo(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4114_spdif_pinfo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->value.integer.min = 0; @@ -304,10 +304,10 @@ static int snd_ak4114_spdif_pinfo(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ak4114_spdif_pget(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4114_spdif_pget(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4114_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4114 *chip = snd_kcontrol_chip(kcontrol); unsigned short tmp; ucontrol->value.integer.value[0] = 0xf8f2; @@ -319,17 +319,17 @@ static int snd_ak4114_spdif_pget(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ak4114_spdif_qinfo(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4114_spdif_qinfo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; uinfo->count = AK4114_REG_QSUB_SIZE; return 0; } -static int snd_ak4114_spdif_qget(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4114_spdif_qget(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4114_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4114 *chip = snd_kcontrol_chip(kcontrol); unsigned i; for (i = 0; i < AK4114_REG_QSUB_SIZE; i++) @@ -338,14 +338,14 @@ static int snd_ak4114_spdif_qget(snd_kcontrol_t * kcontrol, } /* Don't forget to change AK4114_CONTROLS define!!! */ -static snd_kcontrol_new_t snd_ak4114_iec958_controls[] = { +static struct snd_kcontrol_new snd_ak4114_iec958_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "IEC958 Parity Errors", .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, .info = snd_ak4114_in_error_info, .get = snd_ak4114_in_error_get, - .private_value = offsetof(ak4114_t, parity_errors), + .private_value = offsetof(struct ak4114, parity_errors), }, { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -353,7 +353,7 @@ static snd_kcontrol_new_t snd_ak4114_iec958_controls[] = { .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, .info = snd_ak4114_in_error_info, .get = snd_ak4114_in_error_get, - .private_value = offsetof(ak4114_t, v_bit_errors), + .private_value = offsetof(struct ak4114, v_bit_errors), }, { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -361,7 +361,7 @@ static snd_kcontrol_new_t snd_ak4114_iec958_controls[] = { .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, .info = snd_ak4114_in_error_info, .get = snd_ak4114_in_error_get, - .private_value = offsetof(ak4114_t, ccrc_errors), + .private_value = offsetof(struct ak4114, ccrc_errors), }, { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -369,7 +369,7 @@ static snd_kcontrol_new_t snd_ak4114_iec958_controls[] = { .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, .info = snd_ak4114_in_error_info, .get = snd_ak4114_in_error_get, - .private_value = offsetof(ak4114_t, qcrc_errors), + .private_value = offsetof(struct ak4114, qcrc_errors), }, { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -447,11 +447,11 @@ static snd_kcontrol_new_t snd_ak4114_iec958_controls[] = { } }; -int snd_ak4114_build(ak4114_t *ak4114, - snd_pcm_substream_t *ply_substream, - snd_pcm_substream_t *cap_substream) +int snd_ak4114_build(struct ak4114 *ak4114, + struct snd_pcm_substream *ply_substream, + struct snd_pcm_substream *cap_substream) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; unsigned int idx; int err; @@ -482,7 +482,7 @@ int snd_ak4114_build(ak4114_t *ak4114, return 0; } -int snd_ak4114_external_rate(ak4114_t *ak4114) +int snd_ak4114_external_rate(struct ak4114 *ak4114) { unsigned char rcs1; @@ -490,9 +490,9 @@ int snd_ak4114_external_rate(ak4114_t *ak4114) return external_rate(rcs1); } -int snd_ak4114_check_rate_and_errors(ak4114_t *ak4114, unsigned int flags) +int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags) { - snd_pcm_runtime_t *runtime = ak4114->capture_substream ? ak4114->capture_substream->runtime : NULL; + struct snd_pcm_runtime *runtime = ak4114->capture_substream ? ak4114->capture_substream->runtime : NULL; unsigned long _flags; int res = 0; unsigned char rcs0, rcs1; @@ -563,7 +563,7 @@ int snd_ak4114_check_rate_and_errors(ak4114_t *ak4114, unsigned int flags) static void ak4114_stats(void *data) { - ak4114_t *chip = (ak4114_t *)data; + struct ak4114 *chip = (struct ak4114 *)data; if (chip->init) return; diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c index 35b4584..4e45952 100644 --- a/sound/i2c/other/ak4117.c +++ b/sound/i2c/other/ak4117.c @@ -37,20 +37,20 @@ MODULE_LICENSE("GPL"); static void snd_ak4117_timer(unsigned long data); -static void reg_write(ak4117_t *ak4117, unsigned char reg, unsigned char val) +static void reg_write(struct ak4117 *ak4117, unsigned char reg, unsigned char val) { ak4117->write(ak4117->private_data, reg, val); if (reg < sizeof(ak4117->regmap)) ak4117->regmap[reg] = val; } -static inline unsigned char reg_read(ak4117_t *ak4117, unsigned char reg) +static inline unsigned char reg_read(struct ak4117 *ak4117, unsigned char reg) { return ak4117->read(ak4117->private_data, reg); } #if 0 -static void reg_dump(ak4117_t *ak4117) +static void reg_dump(struct ak4117 *ak4117) { int i; @@ -60,26 +60,26 @@ static void reg_dump(ak4117_t *ak4117) } #endif -static void snd_ak4117_free(ak4117_t *chip) +static void snd_ak4117_free(struct ak4117 *chip) { del_timer(&chip->timer); kfree(chip); } -static int snd_ak4117_dev_free(snd_device_t *device) +static int snd_ak4117_dev_free(struct snd_device *device) { - ak4117_t *chip = device->device_data; + struct ak4117 *chip = device->device_data; snd_ak4117_free(chip); return 0; } -int snd_ak4117_create(snd_card_t *card, ak4117_read_t *read, ak4117_write_t *write, - unsigned char pgm[5], void *private_data, ak4117_t **r_ak4117) +int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t *write, + unsigned char pgm[5], void *private_data, struct ak4117 **r_ak4117) { - ak4117_t *chip; + struct ak4117 *chip; int err = 0; unsigned char reg; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ak4117_dev_free, }; @@ -115,14 +115,14 @@ int snd_ak4117_create(snd_card_t *card, ak4117_read_t *read, ak4117_write_t *wri return err < 0 ? err : -EIO; } -void snd_ak4117_reg_write(ak4117_t *chip, unsigned char reg, unsigned char mask, unsigned char val) +void snd_ak4117_reg_write(struct ak4117 *chip, unsigned char reg, unsigned char mask, unsigned char val) { if (reg >= 5) return; reg_write(chip, reg, (chip->regmap[reg] & ~mask) | val); } -void snd_ak4117_reinit(ak4117_t *chip) +void snd_ak4117_reinit(struct ak4117 *chip) { unsigned char old = chip->regmap[AK4117_REG_PWRDN], reg; @@ -157,8 +157,8 @@ static unsigned int external_rate(unsigned char rcs1) } } -static int snd_ak4117_in_error_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ak4117_in_error_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -167,10 +167,10 @@ static int snd_ak4117_in_error_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4117_in_error_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ak4117_in_error_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4117_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4117 *chip = snd_kcontrol_chip(kcontrol); long *ptr; spin_lock_irq(&chip->lock); @@ -181,8 +181,8 @@ static int snd_ak4117_in_error_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4117_in_bit_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ak4117_in_bit_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -191,10 +191,10 @@ static int snd_ak4117_in_bit_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4117_in_bit_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ak4117_in_bit_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4117_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4117 *chip = snd_kcontrol_chip(kcontrol); unsigned char reg = kcontrol->private_value & 0xff; unsigned char bit = (kcontrol->private_value >> 8) & 0xff; unsigned char inv = (kcontrol->private_value >> 31) & 1; @@ -203,8 +203,8 @@ static int snd_ak4117_in_bit_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4117_rx_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ak4117_rx_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -213,19 +213,19 @@ static int snd_ak4117_rx_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4117_rx_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ak4117_rx_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4117_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4117 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (chip->regmap[AK4117_REG_IO] & AK4117_IPS) ? 1 : 0; return 0; } -static int snd_ak4117_rx_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ak4117_rx_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4117_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4117 *chip = snd_kcontrol_chip(kcontrol); int change; u8 old_val; @@ -238,8 +238,8 @@ static int snd_ak4117_rx_put(snd_kcontrol_t *kcontrol, return change; } -static int snd_ak4117_rate_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ak4117_rate_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -248,26 +248,26 @@ static int snd_ak4117_rate_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ak4117_rate_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ak4117_rate_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4117_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4117 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = external_rate(reg_read(chip, AK4117_REG_RCS1)); return 0; } -static int snd_ak4117_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4117_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ak4117_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4117_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4117_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4117 *chip = snd_kcontrol_chip(kcontrol); unsigned i; for (i = 0; i < AK4117_REG_RXCSB_SIZE; i++) @@ -275,21 +275,21 @@ static int snd_ak4117_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ak4117_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4117_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ak4117_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4117_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { memset(ucontrol->value.iec958.status, 0xff, AK4117_REG_RXCSB_SIZE); return 0; } -static int snd_ak4117_spdif_pinfo(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4117_spdif_pinfo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->value.integer.min = 0; @@ -298,10 +298,10 @@ static int snd_ak4117_spdif_pinfo(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ak4117_spdif_pget(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4117_spdif_pget(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4117_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4117 *chip = snd_kcontrol_chip(kcontrol); unsigned short tmp; ucontrol->value.integer.value[0] = 0xf8f2; @@ -313,17 +313,17 @@ static int snd_ak4117_spdif_pget(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ak4117_spdif_qinfo(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4117_spdif_qinfo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; uinfo->count = AK4117_REG_QSUB_SIZE; return 0; } -static int snd_ak4117_spdif_qget(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ak4117_spdif_qget(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ak4117_t *chip = snd_kcontrol_chip(kcontrol); + struct ak4117 *chip = snd_kcontrol_chip(kcontrol); unsigned i; for (i = 0; i < AK4117_REG_QSUB_SIZE; i++) @@ -332,14 +332,14 @@ static int snd_ak4117_spdif_qget(snd_kcontrol_t * kcontrol, } /* Don't forget to change AK4117_CONTROLS define!!! */ -static snd_kcontrol_new_t snd_ak4117_iec958_controls[] = { +static struct snd_kcontrol_new snd_ak4117_iec958_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "IEC958 Parity Errors", .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, .info = snd_ak4117_in_error_info, .get = snd_ak4117_in_error_get, - .private_value = offsetof(ak4117_t, parity_errors), + .private_value = offsetof(struct ak4117, parity_errors), }, { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -347,7 +347,7 @@ static snd_kcontrol_new_t snd_ak4117_iec958_controls[] = { .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, .info = snd_ak4117_in_error_info, .get = snd_ak4117_in_error_get, - .private_value = offsetof(ak4117_t, v_bit_errors), + .private_value = offsetof(struct ak4117, v_bit_errors), }, { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -355,7 +355,7 @@ static snd_kcontrol_new_t snd_ak4117_iec958_controls[] = { .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, .info = snd_ak4117_in_error_info, .get = snd_ak4117_in_error_get, - .private_value = offsetof(ak4117_t, ccrc_errors), + .private_value = offsetof(struct ak4117, ccrc_errors), }, { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -363,7 +363,7 @@ static snd_kcontrol_new_t snd_ak4117_iec958_controls[] = { .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, .info = snd_ak4117_in_error_info, .get = snd_ak4117_in_error_get, - .private_value = offsetof(ak4117_t, qcrc_errors), + .private_value = offsetof(struct ak4117, qcrc_errors), }, { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -434,9 +434,9 @@ static snd_kcontrol_new_t snd_ak4117_iec958_controls[] = { } }; -int snd_ak4117_build(ak4117_t *ak4117, snd_pcm_substream_t *cap_substream) +int snd_ak4117_build(struct ak4117 *ak4117, struct snd_pcm_substream *cap_substream) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; unsigned int idx; int err; @@ -456,7 +456,7 @@ int snd_ak4117_build(ak4117_t *ak4117, snd_pcm_substream_t *cap_substream) return 0; } -int snd_ak4117_external_rate(ak4117_t *ak4117) +int snd_ak4117_external_rate(struct ak4117 *ak4117) { unsigned char rcs1; @@ -464,9 +464,9 @@ int snd_ak4117_external_rate(ak4117_t *ak4117) return external_rate(rcs1); } -int snd_ak4117_check_rate_and_errors(ak4117_t *ak4117, unsigned int flags) +int snd_ak4117_check_rate_and_errors(struct ak4117 *ak4117, unsigned int flags) { - snd_pcm_runtime_t *runtime = ak4117->substream ? ak4117->substream->runtime : NULL; + struct snd_pcm_runtime *runtime = ak4117->substream ? ak4117->substream->runtime : NULL; unsigned long _flags; int res = 0; unsigned char rcs0, rcs1, rcs2; @@ -542,7 +542,7 @@ int snd_ak4117_check_rate_and_errors(ak4117_t *ak4117, unsigned int flags) static void snd_ak4117_timer(unsigned long data) { - ak4117_t *chip = (ak4117_t *)data; + struct ak4117 *chip = (struct ak4117 *)data; if (chip->init) return; diff --git a/sound/i2c/other/ak4xxx-adda.c b/sound/i2c/other/ak4xxx-adda.c index db2b727..045e32a 100644 --- a/sound/i2c/other/ak4xxx-adda.c +++ b/sound/i2c/other/ak4xxx-adda.c @@ -34,7 +34,7 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Takashi Iwai <tiwai@suse.de>"); MODULE_DESCRIPTION("Routines for control of AK452x / AK43xx AD/DA converters"); MODULE_LICENSE("GPL"); -void snd_akm4xxx_write(akm4xxx_t *ak, int chip, unsigned char reg, unsigned char val) +void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsigned char val) { ak->ops.lock(ak, chip); ak->ops.write(ak, chip, reg, val); @@ -58,7 +58,7 @@ void snd_akm4xxx_write(akm4xxx_t *ak, int chip, unsigned char reg, unsigned char * * assert the reset operation and restores the register values to the chips. */ -void snd_akm4xxx_reset(akm4xxx_t *ak, int state) +void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state) { unsigned int chip; unsigned char reg; @@ -109,7 +109,7 @@ void snd_akm4xxx_reset(akm4xxx_t *ak, int state) /* * initialize all the ak4xxx chips */ -void snd_akm4xxx_init(akm4xxx_t *ak) +void snd_akm4xxx_init(struct snd_akm4xxx *ak) { static unsigned char inits_ak4524[] = { 0x00, 0x07, /* 0: all power up */ @@ -247,7 +247,8 @@ void snd_akm4xxx_init(akm4xxx_t *ak) #define AK_COMPOSE(chip,addr,shift,mask) (((chip) << 8) | (addr) | ((shift) << 16) | ((mask) << 24)) #define AK_INVERT (1<<23) -static int snd_akm4xxx_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_akm4xxx_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { unsigned int mask = AK_GET_MASK(kcontrol->private_value); @@ -258,9 +259,10 @@ static int snd_akm4xxx_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_akm4xxx_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_akm4xxx_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - akm4xxx_t *ak = snd_kcontrol_chip(kcontrol); + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); int chip = AK_GET_CHIP(kcontrol->private_value); int addr = AK_GET_ADDR(kcontrol->private_value); int invert = AK_GET_INVERT(kcontrol->private_value); @@ -271,9 +273,10 @@ static int snd_akm4xxx_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_akm4xxx_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_akm4xxx_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - akm4xxx_t *ak = snd_kcontrol_chip(kcontrol); + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); int chip = AK_GET_CHIP(kcontrol->private_value); int addr = AK_GET_ADDR(kcontrol->private_value); int invert = AK_GET_INVERT(kcontrol->private_value); @@ -289,7 +292,8 @@ static int snd_akm4xxx_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return change; } -static int snd_akm4xxx_ipga_gain_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_akm4xxx_ipga_gain_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -298,18 +302,20 @@ static int snd_akm4xxx_ipga_gain_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_akm4xxx_ipga_gain_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_akm4xxx_ipga_gain_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - akm4xxx_t *ak = snd_kcontrol_chip(kcontrol); + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); int chip = AK_GET_CHIP(kcontrol->private_value); int addr = AK_GET_ADDR(kcontrol->private_value); ucontrol->value.integer.value[0] = snd_akm4xxx_get_ipga(ak, chip, addr) & 0x7f; return 0; } -static int snd_akm4xxx_ipga_gain_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_akm4xxx_ipga_gain_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - akm4xxx_t *ak = snd_kcontrol_chip(kcontrol); + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); int chip = AK_GET_CHIP(kcontrol->private_value); int addr = AK_GET_ADDR(kcontrol->private_value); unsigned char nval = (ucontrol->value.integer.value[0] % 37) | 0x80; @@ -319,7 +325,8 @@ static int snd_akm4xxx_ipga_gain_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu return change; } -static int snd_akm4xxx_deemphasis_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_akm4xxx_deemphasis_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "44.1kHz", "Off", "48kHz", "32kHz", @@ -333,9 +340,10 @@ static int snd_akm4xxx_deemphasis_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_in return 0; } -static int snd_akm4xxx_deemphasis_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_akm4xxx_deemphasis_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - akm4xxx_t *ak = snd_kcontrol_chip(kcontrol); + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); int chip = AK_GET_CHIP(kcontrol->private_value); int addr = AK_GET_ADDR(kcontrol->private_value); int shift = AK_GET_SHIFT(kcontrol->private_value); @@ -343,9 +351,10 @@ static int snd_akm4xxx_deemphasis_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_va return 0; } -static int snd_akm4xxx_deemphasis_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_akm4xxx_deemphasis_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - akm4xxx_t *ak = snd_kcontrol_chip(kcontrol); + struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol); int chip = AK_GET_CHIP(kcontrol->private_value); int addr = AK_GET_ADDR(kcontrol->private_value); int shift = AK_GET_SHIFT(kcontrol->private_value); @@ -363,10 +372,10 @@ static int snd_akm4xxx_deemphasis_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val * build AK4xxx controls */ -int snd_akm4xxx_build_controls(akm4xxx_t *ak) +int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak) { unsigned int idx, num_emphs; - snd_kcontrol_t *ctl; + struct snd_kcontrol *ctl; int err; ctl = kmalloc(sizeof(*ctl), GFP_KERNEL); diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c index 0f05a2b..4c2fd14 100644 --- a/sound/i2c/other/tea575x-tuner.c +++ b/sound/i2c/other/tea575x-tuner.c @@ -58,7 +58,7 @@ MODULE_LICENSE("GPL"); * lowlevel part */ -static void snd_tea575x_set_freq(tea575x_t *tea) +static void snd_tea575x_set_freq(struct snd_tea575x *tea) { unsigned long freq; @@ -89,7 +89,7 @@ static int snd_tea575x_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data) { struct video_device *dev = video_devdata(file); - tea575x_t *tea = video_get_drvdata(dev); + struct snd_tea575x *tea = video_get_drvdata(dev); void __user *arg = (void __user *)data; switch(cmd) { @@ -175,7 +175,7 @@ static void snd_tea575x_release(struct video_device *vfd) /* * initialize all the tea575x chips */ -void snd_tea575x_init(tea575x_t *tea) +void snd_tea575x_init(struct snd_tea575x *tea) { unsigned int val; @@ -209,7 +209,7 @@ void snd_tea575x_init(tea575x_t *tea) snd_tea575x_set_freq(tea); } -void snd_tea575x_exit(tea575x_t *tea) +void snd_tea575x_exit(struct snd_tea575x *tea) { if (tea->vd_registered) { video_unregister_device(&tea->vd); diff --git a/sound/i2c/tea6330t.c b/sound/i2c/tea6330t.c index 7bd4948..ae5b1e3 100644 --- a/sound/i2c/tea6330t.c +++ b/sound/i2c/tea6330t.c @@ -44,18 +44,20 @@ MODULE_LICENSE("GPL"); #define TEA6330T_GMU 0x80 /* mute control, general mute */ #define TEA6330T_EQN 0x40 /* equalizer switchover (0=equalizer-on) */ -typedef struct { - snd_i2c_device_t *device; - snd_i2c_bus_t *bus; + +struct tea6330t { + struct snd_i2c_device *device; + struct snd_i2c_bus *bus; int equalizer; int fader; unsigned char regs[8]; unsigned char mleft, mright; unsigned char bass, treble; unsigned char max_bass, max_treble; -} tea6330t_t; +}; + -int snd_tea6330t_detect(snd_i2c_bus_t *bus, int equalizer) +int snd_tea6330t_detect(struct snd_i2c_bus *bus, int equalizer) { int res; @@ -66,7 +68,7 @@ int snd_tea6330t_detect(snd_i2c_bus_t *bus, int equalizer) } #if 0 -static void snd_tea6330t_set(tea6330t_t *tea, +static void snd_tea6330t_set(struct tea6330t *tea, unsigned char addr, unsigned char value) { #if 0 @@ -81,7 +83,8 @@ static void snd_tea6330t_set(tea6330t_t *tea, .info = snd_tea6330t_info_master_volume, \ .get = snd_tea6330t_get_master_volume, .put = snd_tea6330t_put_master_volume } -static int snd_tea6330t_info_master_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_tea6330t_info_master_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -90,9 +93,10 @@ static int snd_tea6330t_info_master_volume(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_tea6330t_get_master_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_tea6330t_get_master_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); snd_i2c_lock(tea->bus); ucontrol->value.integer.value[0] = tea->mleft - 0x14; @@ -101,9 +105,10 @@ static int snd_tea6330t_get_master_volume(snd_kcontrol_t * kcontrol, snd_ctl_ele return 0; } -static int snd_tea6330t_put_master_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_tea6330t_put_master_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); int change, count, err; unsigned char bytes[3]; unsigned char val1, val2; @@ -137,7 +142,8 @@ static int snd_tea6330t_put_master_volume(snd_kcontrol_t * kcontrol, snd_ctl_ele .info = snd_tea6330t_info_master_switch, \ .get = snd_tea6330t_get_master_switch, .put = snd_tea6330t_put_master_switch } -static int snd_tea6330t_info_master_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_tea6330t_info_master_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -146,9 +152,10 @@ static int snd_tea6330t_info_master_switch(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_tea6330t_get_master_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_tea6330t_get_master_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); snd_i2c_lock(tea->bus); ucontrol->value.integer.value[0] = tea->regs[TEA6330T_SADDR_VOLUME_LEFT] == 0 ? 0 : 1; @@ -157,9 +164,10 @@ static int snd_tea6330t_get_master_switch(snd_kcontrol_t * kcontrol, snd_ctl_ele return 0; } -static int snd_tea6330t_put_master_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_tea6330t_put_master_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); int change, err; unsigned char bytes[3]; unsigned char oval1, oval2, val1, val2; @@ -186,9 +194,10 @@ static int snd_tea6330t_put_master_switch(snd_kcontrol_t * kcontrol, snd_ctl_ele .info = snd_tea6330t_info_bass, \ .get = snd_tea6330t_get_bass, .put = snd_tea6330t_put_bass } -static int snd_tea6330t_info_bass(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_tea6330t_info_bass(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -197,17 +206,19 @@ static int snd_tea6330t_info_bass(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_tea6330t_get_bass(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_tea6330t_get_bass(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = tea->bass; return 0; } -static int snd_tea6330t_put_bass(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_tea6330t_put_bass(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); int change, err; unsigned char bytes[2]; unsigned char val1; @@ -230,9 +241,10 @@ static int snd_tea6330t_put_bass(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .info = snd_tea6330t_info_treble, \ .get = snd_tea6330t_get_treble, .put = snd_tea6330t_put_treble } -static int snd_tea6330t_info_treble(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_tea6330t_info_treble(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -241,17 +253,19 @@ static int snd_tea6330t_info_treble(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_tea6330t_get_treble(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_tea6330t_get_treble(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = tea->treble; return 0; } -static int snd_tea6330t_put_treble(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_tea6330t_put_treble(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - tea6330t_t *tea = snd_kcontrol_chip(kcontrol); + struct tea6330t *tea = snd_kcontrol_chip(kcontrol); int change, err; unsigned char bytes[2]; unsigned char val1; @@ -269,25 +283,25 @@ static int snd_tea6330t_put_treble(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return change; } -static snd_kcontrol_new_t snd_tea6330t_controls[] = { +static struct snd_kcontrol_new snd_tea6330t_controls[] = { TEA6330T_MASTER_SWITCH("Master Playback Switch", 0), TEA6330T_MASTER_VOLUME("Master Playback Volume", 0), TEA6330T_BASS("Tone Control - Bass", 0), TEA6330T_TREBLE("Tone Control - Treble", 0) }; -static void snd_tea6330_free(snd_i2c_device_t *device) +static void snd_tea6330_free(struct snd_i2c_device *device) { kfree(device->private_data); } -int snd_tea6330t_update_mixer(snd_card_t * card, - snd_i2c_bus_t *bus, +int snd_tea6330t_update_mixer(struct snd_card *card, + struct snd_i2c_bus *bus, int equalizer, int fader) { - snd_i2c_device_t *device; - tea6330t_t *tea; - snd_kcontrol_new_t *knew; + struct snd_i2c_device *device; + struct tea6330t *tea; + struct snd_kcontrol_new *knew; unsigned int idx; int err = -ENOMEM; u8 default_treble, default_bass; -- cgit v1.1 From dc4cafbadad1ae2322e598f2cb72720ef4095fee Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:19:28 +0100 Subject: [ALSA] Remove xxx_t typedefs: I2C drivers Modules: AK4114 receiver,AK4117 receiver,AK4XXX AD/DA converters [Missing files in last commit] Remove xxx_t typedefs from the i2c drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/ak4114.h | 30 ++++++++++++++---------------- include/sound/ak4117.h | 24 +++++++++++------------- include/sound/ak4xxx-adda.h | 22 +++++++++++----------- 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h index f3f2c3e..11702aa 100644 --- a/include/sound/ak4114.h +++ b/include/sound/ak4114.h @@ -163,10 +163,8 @@ typedef void (ak4114_write_t)(void *private_data, unsigned char addr, unsigned char data); typedef unsigned char (ak4114_read_t)(void *private_data, unsigned char addr); -typedef struct ak4114 ak4114_t; - struct ak4114 { - snd_card_t * card; + struct snd_card *card; ak4114_write_t * write; ak4114_read_t * read; void * private_data; @@ -174,9 +172,9 @@ struct ak4114 { spinlock_t lock; unsigned char regmap[7]; unsigned char txcsb[5]; - snd_kcontrol_t *kctls[AK4114_CONTROLS]; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_kcontrol *kctls[AK4114_CONTROLS]; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; unsigned long parity_errors; unsigned long v_bit_errors; unsigned long qcrc_errors; @@ -186,20 +184,20 @@ struct ak4114 { struct workqueue_struct *workqueue; struct work_struct work; void *change_callback_private; - void (*change_callback)(ak4114_t *ak4114, unsigned char c0, unsigned char c1); + void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1); }; -int snd_ak4114_create(snd_card_t *card, +int snd_ak4114_create(struct snd_card *card, ak4114_read_t *read, ak4114_write_t *write, unsigned char pgm[7], unsigned char txcsb[5], - void *private_data, ak4114_t **r_ak4114); -void snd_ak4114_reg_write(ak4114_t *ak4114, unsigned char reg, unsigned char mask, unsigned char val); -void snd_ak4114_reinit(ak4114_t *ak4114); -int snd_ak4114_build(ak4114_t *ak4114, - snd_pcm_substream_t *playback_substream, - snd_pcm_substream_t *capture_substream); -int snd_ak4114_external_rate(ak4114_t *ak4114); -int snd_ak4114_check_rate_and_errors(ak4114_t *ak4114, unsigned int flags); + void *private_data, struct ak4114 **r_ak4114); +void snd_ak4114_reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char mask, unsigned char val); +void snd_ak4114_reinit(struct ak4114 *ak4114); +int snd_ak4114_build(struct ak4114 *ak4114, + struct snd_pcm_substream *playback_substream, + struct snd_pcm_substream *capture_substream); +int snd_ak4114_external_rate(struct ak4114 *ak4114); +int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags); #endif /* __SOUND_AK4114_H */ diff --git a/include/sound/ak4117.h b/include/sound/ak4117.h index 9e1dab1..2b96c32 100644 --- a/include/sound/ak4117.h +++ b/include/sound/ak4117.h @@ -155,18 +155,16 @@ typedef void (ak4117_write_t)(void *private_data, unsigned char addr, unsigned char data); typedef unsigned char (ak4117_read_t)(void *private_data, unsigned char addr); -typedef struct ak4117 ak4117_t; - struct ak4117 { - snd_card_t * card; + struct snd_card *card; ak4117_write_t * write; ak4117_read_t * read; void * private_data; unsigned int init: 1; spinlock_t lock; unsigned char regmap[5]; - snd_kcontrol_t *kctls[AK4117_CONTROLS]; - snd_pcm_substream_t *substream; + struct snd_kcontrol *kctls[AK4117_CONTROLS]; + struct snd_pcm_substream *substream; unsigned long parity_errors; unsigned long v_bit_errors; unsigned long qcrc_errors; @@ -176,16 +174,16 @@ struct ak4117 { unsigned char rcs2; struct timer_list timer; /* statistic timer */ void *change_callback_private; - void (*change_callback)(ak4117_t *ak4117, unsigned char c0, unsigned char c1); + void (*change_callback)(struct ak4117 *ak4117, unsigned char c0, unsigned char c1); }; -int snd_ak4117_create(snd_card_t *card, ak4117_read_t *read, ak4117_write_t *write, - unsigned char pgm[5], void *private_data, ak4117_t **r_ak4117); -void snd_ak4117_reg_write(ak4117_t *ak4117, unsigned char reg, unsigned char mask, unsigned char val); -void snd_ak4117_reinit(ak4117_t *ak4117); -int snd_ak4117_build(ak4117_t *ak4117, snd_pcm_substream_t *capture_substream); -int snd_ak4117_external_rate(ak4117_t *ak4117); -int snd_ak4117_check_rate_and_errors(ak4117_t *ak4117, unsigned int flags); +int snd_ak4117_create(struct snd_card *card, ak4117_read_t *read, ak4117_write_t *write, + unsigned char pgm[5], void *private_data, struct ak4117 **r_ak4117); +void snd_ak4117_reg_write(struct ak4117 *ak4117, unsigned char reg, unsigned char mask, unsigned char val); +void snd_ak4117_reinit(struct ak4117 *ak4117); +int snd_ak4117_build(struct ak4117 *ak4117, struct snd_pcm_substream *capture_substream); +int snd_ak4117_external_rate(struct ak4117 *ak4117); +int snd_ak4117_check_rate_and_errors(struct ak4117 *ak4117, unsigned int flags); #endif /* __SOUND_AK4117_H */ diff --git a/include/sound/ak4xxx-adda.h b/include/sound/ak4xxx-adda.h index e94ac02..3bf5911 100644 --- a/include/sound/ak4xxx-adda.h +++ b/include/sound/ak4xxx-adda.h @@ -27,20 +27,20 @@ #define AK4XXX_MAX_CHIPS 4 #endif -typedef struct snd_akm4xxx akm4xxx_t; +struct snd_akm4xxx; struct snd_ak4xxx_ops { - void (*lock)(akm4xxx_t *ak, int chip); - void (*unlock)(akm4xxx_t *ak, int chip); - void (*write)(akm4xxx_t *ak, int chip, unsigned char reg, unsigned char val); - // unsigned char (*read)(akm4xxx_t *ak, int chip, unsigned char reg); - void (*set_rate_val)(akm4xxx_t *ak, unsigned int rate); + void (*lock)(struct snd_akm4xxx *ak, int chip); + void (*unlock)(struct snd_akm4xxx *ak, int chip); + void (*write)(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsigned char val); + // unsigned char (*read)(struct snd_akm4xxx *ak, int chip, unsigned char reg); + void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate); }; #define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */ struct snd_akm4xxx { - snd_card_t *card; + struct snd_card *card; unsigned int num_adcs; /* AK4524 or AK4528 ADCs */ unsigned int num_dacs; /* AK4524 or AK4528 DACs */ unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */ @@ -56,10 +56,10 @@ struct snd_akm4xxx { struct snd_ak4xxx_ops ops; }; -void snd_akm4xxx_write(akm4xxx_t *ak, int chip, unsigned char reg, unsigned char val); -void snd_akm4xxx_reset(akm4xxx_t *ak, int state); -void snd_akm4xxx_init(akm4xxx_t *ak); -int snd_akm4xxx_build_controls(akm4xxx_t *ak); +void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg, unsigned char val); +void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state); +void snd_akm4xxx_init(struct snd_akm4xxx *ak); +int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak); #define snd_akm4xxx_get(ak,chip,reg) (ak)->images[(chip) * 16 + (reg)] #define snd_akm4xxx_set(ak,chip,reg,val) ((ak)->images[(chip) * 16 + (reg)] = (val)) -- cgit v1.1 From ee42381e71c56328db9e9d64d19a4de7a2f09a93 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:21:36 +0100 Subject: [ALSA] Remove xxx_t typedefs: AC97 Modules: AC97 Codec Remove xxx_t typedefs from the AC97 codec support. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/ac97_codec.h | 107 ++++++------ sound/pci/ac97/ac97_bus.c | 2 +- sound/pci/ac97/ac97_codec.c | 313 ++++++++++++++++----------------- sound/pci/ac97/ac97_local.h | 45 ++--- sound/pci/ac97/ac97_patch.c | 408 ++++++++++++++++++++++---------------------- sound/pci/ac97/ac97_patch.h | 74 ++++---- sound/pci/ac97/ac97_pcm.c | 38 ++--- sound/pci/ac97/ac97_proc.c | 33 ++-- 8 files changed, 511 insertions(+), 509 deletions(-) diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h index 6f1e6ba..a1814cd 100644 --- a/include/sound/ac97_codec.h +++ b/include/sound/ac97_codec.h @@ -391,38 +391,35 @@ * */ -typedef struct _snd_ac97_bus ac97_bus_t; -typedef struct _snd_ac97_bus_ops ac97_bus_ops_t; -typedef struct _snd_ac97_template ac97_template_t; -typedef struct _snd_ac97 ac97_t; +struct snd_ac97; struct snd_ac97_build_ops { - int (*build_3d) (ac97_t *ac97); - int (*build_specific) (ac97_t *ac97); - int (*build_spdif) (ac97_t *ac97); - int (*build_post_spdif) (ac97_t *ac97); + int (*build_3d) (struct snd_ac97 *ac97); + int (*build_specific) (struct snd_ac97 *ac97); + int (*build_spdif) (struct snd_ac97 *ac97); + int (*build_post_spdif) (struct snd_ac97 *ac97); #ifdef CONFIG_PM - void (*suspend) (ac97_t *ac97); - void (*resume) (ac97_t *ac97); + void (*suspend) (struct snd_ac97 *ac97); + void (*resume) (struct snd_ac97 *ac97); #endif - void (*update_jacks) (ac97_t *ac97); /* for jack-sharing */ + void (*update_jacks) (struct snd_ac97 *ac97); /* for jack-sharing */ }; -struct _snd_ac97_bus_ops { - void (*reset) (ac97_t *ac97); - void (*write) (ac97_t *ac97, unsigned short reg, unsigned short val); - unsigned short (*read) (ac97_t *ac97, unsigned short reg); - void (*wait) (ac97_t *ac97); - void (*init) (ac97_t *ac97); +struct snd_ac97_bus_ops { + void (*reset) (struct snd_ac97 *ac97); + void (*write) (struct snd_ac97 *ac97, unsigned short reg, unsigned short val); + unsigned short (*read) (struct snd_ac97 *ac97, unsigned short reg); + void (*wait) (struct snd_ac97 *ac97); + void (*init) (struct snd_ac97 *ac97); }; -struct _snd_ac97_bus { +struct snd_ac97_bus { /* -- lowlevel (hardware) driver specific -- */ - ac97_bus_ops_t *ops; + struct snd_ac97_bus_ops *ops; void *private_data; - void (*private_free) (ac97_bus_t *bus); + void (*private_free) (struct snd_ac97_bus *bus); /* --- */ - snd_card_t *card; + struct snd_card *card; unsigned short num; /* bus number */ unsigned short no_vra: 1, /* bridge doesn't support VRA */ dra: 1, /* bridge supports double rate */ @@ -432,13 +429,13 @@ struct _snd_ac97_bus { unsigned short used_slots[2][4]; /* actually used PCM slots */ unsigned short pcms_count; /* count of PCMs */ struct ac97_pcm *pcms; - ac97_t *codec[4]; - snd_info_entry_t *proc; + struct snd_ac97 *codec[4]; + struct snd_info_entry *proc; }; -struct _snd_ac97_template { +struct snd_ac97_template { void *private_data; - void (*private_free) (ac97_t *ac97); + void (*private_free) (struct snd_ac97 *ac97); struct pci_dev *pci; /* assigned PCI device - used for quirks */ unsigned short num; /* number of codec: 0 = primary, 1 = secondary */ unsigned short addr; /* physical address of codec [0-3] */ @@ -447,16 +444,16 @@ struct _snd_ac97_template { DECLARE_BITMAP(reg_accessed, 0x80); /* bit flags */ }; -struct _snd_ac97 { +struct snd_ac97 { /* -- lowlevel (hardware) driver specific -- */ struct snd_ac97_build_ops * build_ops; void *private_data; - void (*private_free) (ac97_t *ac97); + void (*private_free) (struct snd_ac97 *ac97); /* --- */ - ac97_bus_t *bus; + struct snd_ac97_bus *bus; struct pci_dev *pci; /* assigned PCI device - used for quirks */ - snd_info_entry_t *proc; - snd_info_entry_t *proc_regs; + struct snd_info_entry *proc; + struct snd_info_entry *proc_regs; unsigned short subsystem_vendor; unsigned short subsystem_device; struct semaphore reg_mutex; @@ -490,43 +487,47 @@ struct _snd_ac97 { struct device dev; }; -#define to_ac97_t(d) container_of(d, struct _snd_ac97, dev) +#define to_ac97_t(d) container_of(d, struct snd_ac97, dev) /* conditions */ -static inline int ac97_is_audio(ac97_t * ac97) +static inline int ac97_is_audio(struct snd_ac97 * ac97) { return (ac97->scaps & AC97_SCAP_AUDIO); } -static inline int ac97_is_modem(ac97_t * ac97) +static inline int ac97_is_modem(struct snd_ac97 * ac97) { return (ac97->scaps & AC97_SCAP_MODEM); } -static inline int ac97_is_rev22(ac97_t * ac97) +static inline int ac97_is_rev22(struct snd_ac97 * ac97) { return (ac97->ext_id & AC97_EI_REV_MASK) >= AC97_EI_REV_22; } -static inline int ac97_can_amap(ac97_t * ac97) +static inline int ac97_can_amap(struct snd_ac97 * ac97) { return (ac97->ext_id & AC97_EI_AMAP) != 0; } -static inline int ac97_can_spdif(ac97_t * ac97) +static inline int ac97_can_spdif(struct snd_ac97 * ac97) { return (ac97->ext_id & AC97_EI_SPDIF) != 0; } /* functions */ -int snd_ac97_bus(snd_card_t *card, int num, ac97_bus_ops_t *ops, void *private_data, ac97_bus_t **rbus); /* create new AC97 bus */ -int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97); /* create mixer controls */ -const char *snd_ac97_get_short_name(ac97_t *ac97); - -void snd_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short value); -unsigned short snd_ac97_read(ac97_t *ac97, unsigned short reg); -void snd_ac97_write_cache(ac97_t *ac97, unsigned short reg, unsigned short value); -int snd_ac97_update(ac97_t *ac97, unsigned short reg, unsigned short value); -int snd_ac97_update_bits(ac97_t *ac97, unsigned short reg, unsigned short mask, unsigned short value); +/* create new AC97 bus */ +int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops, + void *private_data, struct snd_ac97_bus **rbus); +/* create mixer controls */ +int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, + struct snd_ac97 **rac97); +const char *snd_ac97_get_short_name(struct snd_ac97 *ac97); + +void snd_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short value); +unsigned short snd_ac97_read(struct snd_ac97 *ac97, unsigned short reg); +void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned short value); +int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value); +int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value); #ifdef CONFIG_PM -void snd_ac97_suspend(ac97_t *ac97); -void snd_ac97_resume(ac97_t *ac97); +void snd_ac97_suspend(struct snd_ac97 *ac97); +void snd_ac97_resume(struct snd_ac97 *ac97); #endif /* quirk types */ @@ -551,8 +552,8 @@ struct ac97_quirk { int type; /* quirk type above */ }; -int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, const char *override); -int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned int rate); +int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, const char *override); +int snd_ac97_set_rate(struct snd_ac97 *ac97, int reg, unsigned int rate); /* * PCM allocation @@ -568,7 +569,7 @@ enum ac97_pcm_cfg { }; struct ac97_pcm { - ac97_bus_t *bus; + struct snd_ac97_bus *bus; unsigned int stream: 1, /* stream type: 1 = capture */ exclusive: 1, /* exclusive mode, don't override with other pcms */ copy_flag: 1, /* lowlevel driver must fill all entries */ @@ -579,18 +580,18 @@ struct ac97_pcm { unsigned short slots; /* driver input: requested AC97 slot numbers */ unsigned short rslots[4]; /* allocated slots per codecs */ unsigned char rate_table[4]; - ac97_t *codec[4]; /* allocated codecs */ + struct snd_ac97 *codec[4]; /* allocated codecs */ } r[2]; /* 0 = standard rates, 1 = double rates */ unsigned long private_value; /* used by the hardware driver */ }; -int snd_ac97_pcm_assign(ac97_bus_t *ac97, +int snd_ac97_pcm_assign(struct snd_ac97_bus *ac97, unsigned short pcms_count, const struct ac97_pcm *pcms); int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate, enum ac97_pcm_cfg cfg, unsigned short slots); int snd_ac97_pcm_close(struct ac97_pcm *pcm); -int snd_ac97_pcm_double_rate_rules(snd_pcm_runtime_t *runtime); +int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime); /* ad hoc AC97 device driver access */ extern struct bus_type ac97_bus_type; diff --git a/sound/pci/ac97/ac97_bus.c b/sound/pci/ac97/ac97_bus.c index ec70fad..66de2c2 100644 --- a/sound/pci/ac97/ac97_bus.c +++ b/sound/pci/ac97/ac97_bus.c @@ -18,7 +18,7 @@ /* * Let drivers decide whether they want to support given codec from their - * probe method. Drivers have direct access to the ac97_t structure and may + * probe method. Drivers have direct access to the struct snd_ac97 structure and may * decide based on the id field amongst other things. */ static int ac97_bus_match(struct device *dev, struct device_driver *drv) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 9bde76c..bdb6a8c 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -50,16 +50,16 @@ MODULE_PARM_DESC(enable_loopback, "Enable AC97 ADC/DAC Loopback Control"); */ -typedef struct { +struct ac97_codec_id { unsigned int id; unsigned int mask; const char *name; - int (*patch)(ac97_t *ac97); - int (*mpatch)(ac97_t *ac97); + int (*patch)(struct snd_ac97 *ac97); + int (*mpatch)(struct snd_ac97 *ac97); unsigned int flags; -} ac97_codec_id_t; +}; -static const ac97_codec_id_t snd_ac97_codec_id_vendors[] = { +static const struct ac97_codec_id snd_ac97_codec_id_vendors[] = { { 0x414b4d00, 0xffffff00, "Asahi Kasei", NULL, NULL }, { 0x41445300, 0xffffff00, "Analog Devices", NULL, NULL }, { 0x414c4300, 0xffffff00, "Realtek", NULL, NULL }, @@ -86,7 +86,7 @@ static const ac97_codec_id_t snd_ac97_codec_id_vendors[] = { { 0, 0, NULL, NULL, NULL } }; -static const ac97_codec_id_t snd_ac97_codec_ids[] = { +static const struct ac97_codec_id snd_ac97_codec_ids[] = { { 0x414b4d00, 0xffffffff, "AK4540", NULL, NULL }, { 0x414b4d01, 0xffffffff, "AK4542", NULL, NULL }, { 0x414b4d02, 0xffffffff, "AK4543", NULL, NULL }, @@ -225,7 +225,7 @@ const char *snd_ac97_stereo_enhancements[] = * I/O routines */ -static int snd_ac97_valid_reg(ac97_t *ac97, unsigned short reg) +static int snd_ac97_valid_reg(struct snd_ac97 *ac97, unsigned short reg) { if (ac97->limited_regs && ! test_bit(reg, ac97->reg_accessed)) return 0; @@ -278,7 +278,7 @@ static int snd_ac97_valid_reg(ac97_t *ac97, unsigned short reg) * #snd_ca97_write_cache(), so use this only when you don't want to * reflect the change to the suspend/resume state. */ -void snd_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short value) +void snd_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) { if (!snd_ac97_valid_reg(ac97, reg)) return; @@ -301,7 +301,7 @@ void snd_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short value) * * Returns the read value. */ -unsigned short snd_ac97_read(ac97_t *ac97, unsigned short reg) +unsigned short snd_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { if (!snd_ac97_valid_reg(ac97, reg)) return 0; @@ -309,7 +309,7 @@ unsigned short snd_ac97_read(ac97_t *ac97, unsigned short reg) } /* read a register - return the cached value if already read */ -static inline unsigned short snd_ac97_read_cache(ac97_t *ac97, unsigned short reg) +static inline unsigned short snd_ac97_read_cache(struct snd_ac97 *ac97, unsigned short reg) { if (! test_bit(reg, ac97->reg_accessed)) { ac97->regs[reg] = ac97->bus->ops->read(ac97, reg); @@ -328,7 +328,7 @@ static inline unsigned short snd_ac97_read_cache(ac97_t *ac97, unsigned short re * cache. The cached values are used for the cached-read and the * suspend/resume. */ -void snd_ac97_write_cache(ac97_t *ac97, unsigned short reg, unsigned short value) +void snd_ac97_write_cache(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) { if (!snd_ac97_valid_reg(ac97, reg)) return; @@ -351,7 +351,7 @@ void snd_ac97_write_cache(ac97_t *ac97, unsigned short reg, unsigned short value * Returns 1 if the value is changed, 0 if no change, or a negative * code on failure. */ -int snd_ac97_update(ac97_t *ac97, unsigned short reg, unsigned short value) +int snd_ac97_update(struct snd_ac97 *ac97, unsigned short reg, unsigned short value) { int change; @@ -381,7 +381,7 @@ int snd_ac97_update(ac97_t *ac97, unsigned short reg, unsigned short value) * Returns 1 if the bits are changed, 0 if no change, or a negative * code on failure. */ -int snd_ac97_update_bits(ac97_t *ac97, unsigned short reg, unsigned short mask, unsigned short value) +int snd_ac97_update_bits(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value) { int change; @@ -394,7 +394,7 @@ int snd_ac97_update_bits(ac97_t *ac97, unsigned short reg, unsigned short mask, } /* no lock version - see snd_ac97_updat_bits() */ -int snd_ac97_update_bits_nolock(ac97_t *ac97, unsigned short reg, +int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value) { int change; @@ -411,7 +411,7 @@ int snd_ac97_update_bits_nolock(ac97_t *ac97, unsigned short reg, return change; } -static int snd_ac97_ad18xx_update_pcm_bits(ac97_t *ac97, int codec, unsigned short mask, unsigned short value) +static int snd_ac97_ad18xx_update_pcm_bits(struct snd_ac97 *ac97, int codec, unsigned short mask, unsigned short value) { int change; unsigned short old, new, cfg; @@ -443,7 +443,7 @@ static int snd_ac97_ad18xx_update_pcm_bits(ac97_t *ac97, int codec, unsigned sho * Controls */ -int snd_ac97_info_enum_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; @@ -457,9 +457,9 @@ int snd_ac97_info_enum_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * ui return 0; } -int snd_ac97_get_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; unsigned short val, bitmask; @@ -473,9 +473,9 @@ int snd_ac97_get_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u return 0; } -int snd_ac97_put_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); struct ac97_enum *e = (struct ac97_enum *)kcontrol->private_value; unsigned short val; unsigned short mask, bitmask; @@ -496,7 +496,7 @@ int snd_ac97_put_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u } /* save/restore ac97 v2.3 paging */ -static int snd_ac97_page_save(ac97_t *ac97, int reg, snd_kcontrol_t *kcontrol) +static int snd_ac97_page_save(struct snd_ac97 *ac97, int reg, struct snd_kcontrol *kcontrol) { int page_save = -1; if ((kcontrol->private_value & (1<<25)) && @@ -510,7 +510,7 @@ static int snd_ac97_page_save(ac97_t *ac97, int reg, snd_kcontrol_t *kcontrol) return page_save; } -static void snd_ac97_page_restore(ac97_t *ac97, int page_save) +static void snd_ac97_page_restore(struct snd_ac97 *ac97, int page_save) { if (page_save >= 0) { snd_ac97_update_bits(ac97, AC97_INT_PAGING, AC97_PAGE_MASK, page_save); @@ -519,7 +519,7 @@ static void snd_ac97_page_restore(ac97_t *ac97, int page_save) } /* volume and switch controls */ -int snd_ac97_info_volsw(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; int shift = (kcontrol->private_value >> 8) & 0x0f; @@ -532,9 +532,9 @@ int snd_ac97_info_volsw(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) return 0; } -int snd_ac97_get_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0x0f; int rshift = (kcontrol->private_value >> 12) & 0x0f; @@ -555,9 +555,9 @@ int snd_ac97_get_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontro return 0; } -int snd_ac97_put_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0x0f; int rshift = (kcontrol->private_value >> 12) & 0x0f; @@ -584,22 +584,22 @@ int snd_ac97_put_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontro return err; } -static const snd_kcontrol_new_t snd_ac97_controls_master_mono[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_master_mono[2] = { AC97_SINGLE("Master Mono Playback Switch", AC97_MASTER_MONO, 15, 1, 1), AC97_SINGLE("Master Mono Playback Volume", AC97_MASTER_MONO, 0, 31, 1) }; -static const snd_kcontrol_new_t snd_ac97_controls_tone[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_tone[2] = { AC97_SINGLE("Tone Control - Bass", AC97_MASTER_TONE, 8, 15, 1), AC97_SINGLE("Tone Control - Treble", AC97_MASTER_TONE, 0, 15, 1) }; -static const snd_kcontrol_new_t snd_ac97_controls_pc_beep[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_pc_beep[2] = { AC97_SINGLE("PC Speaker Playback Switch", AC97_PC_BEEP, 15, 1, 1), AC97_SINGLE("PC Speaker Playback Volume", AC97_PC_BEEP, 1, 15, 1) }; -static const snd_kcontrol_new_t snd_ac97_controls_mic_boost = +static const struct snd_kcontrol_new snd_ac97_controls_mic_boost = AC97_SINGLE("Mic Boost (+20dB)", AC97_MIC, 6, 1, 0); @@ -615,18 +615,18 @@ AC97_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 9, 2, std_mix), AC97_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 8, 2, std_mic), }; -static const snd_kcontrol_new_t snd_ac97_control_capture_src = +static const struct snd_kcontrol_new snd_ac97_control_capture_src = AC97_ENUM("Capture Source", std_enum[0]); -static const snd_kcontrol_new_t snd_ac97_control_capture_vol = +static const struct snd_kcontrol_new snd_ac97_control_capture_vol = AC97_DOUBLE("Capture Volume", AC97_REC_GAIN, 8, 0, 15, 0); -static const snd_kcontrol_new_t snd_ac97_controls_mic_capture[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_mic_capture[2] = { AC97_SINGLE("Mic Capture Switch", AC97_REC_GAIN_MIC, 15, 1, 1), AC97_SINGLE("Mic Capture Volume", AC97_REC_GAIN_MIC, 0, 15, 0) }; -typedef enum { +enum { AC97_GENERAL_PCM_OUT = 0, AC97_GENERAL_STEREO_ENHANCEMENT, AC97_GENERAL_3D, @@ -634,9 +634,9 @@ typedef enum { AC97_GENERAL_MONO, AC97_GENERAL_MIC, AC97_GENERAL_LOOPBACK -} ac97_general_index_t; +}; -static const snd_kcontrol_new_t snd_ac97_controls_general[7] = { +static const struct snd_kcontrol_new snd_ac97_controls_general[7] = { AC97_ENUM("PCM Out Path & Mute", std_enum[1]), AC97_SINGLE("Simulated Stereo Enhancement", AC97_GENERAL_PURPOSE, 14, 1, 0), AC97_SINGLE("3D Control - Switch", AC97_GENERAL_PURPOSE, 13, 1, 0), @@ -646,45 +646,45 @@ AC97_ENUM("Mic Select", std_enum[3]), AC97_SINGLE("ADC/DAC Loopback", AC97_GENERAL_PURPOSE, 7, 1, 0) }; -const snd_kcontrol_new_t snd_ac97_controls_3d[2] = { +const struct snd_kcontrol_new snd_ac97_controls_3d[2] = { AC97_SINGLE("3D Control - Center", AC97_3D_CONTROL, 8, 15, 0), AC97_SINGLE("3D Control - Depth", AC97_3D_CONTROL, 0, 15, 0) }; -static const snd_kcontrol_new_t snd_ac97_controls_center[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_center[2] = { AC97_SINGLE("Center Playback Switch", AC97_CENTER_LFE_MASTER, 7, 1, 1), AC97_SINGLE("Center Playback Volume", AC97_CENTER_LFE_MASTER, 0, 31, 1) }; -static const snd_kcontrol_new_t snd_ac97_controls_lfe[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_lfe[2] = { AC97_SINGLE("LFE Playback Switch", AC97_CENTER_LFE_MASTER, 15, 1, 1), AC97_SINGLE("LFE Playback Volume", AC97_CENTER_LFE_MASTER, 8, 31, 1) }; -static const snd_kcontrol_new_t snd_ac97_control_eapd = +static const struct snd_kcontrol_new snd_ac97_control_eapd = AC97_SINGLE("External Amplifier", AC97_POWERDOWN, 15, 1, 1); -static const snd_kcontrol_new_t snd_ac97_controls_modem_switches[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_modem_switches[2] = { AC97_SINGLE("Off-hook Switch", AC97_GPIO_STATUS, 0, 1, 0), AC97_SINGLE("Caller ID Switch", AC97_GPIO_STATUS, 2, 1, 0) }; /* change the existing EAPD control as inverted */ -static void set_inv_eapd(ac97_t *ac97, snd_kcontrol_t *kctl) +static void set_inv_eapd(struct snd_ac97 *ac97, struct snd_kcontrol *kctl) { kctl->private_value = AC97_SINGLE_VALUE(AC97_POWERDOWN, 15, 1, 0); snd_ac97_update_bits(ac97, AC97_POWERDOWN, (1<<15), (1<<15)); /* EAPD up */ ac97->scaps |= AC97_SCAP_INV_EAPD; } -static int snd_ac97_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ac97_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ac97_spdif_cmask_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | IEC958_AES0_NONAUDIO | @@ -696,7 +696,7 @@ static int snd_ac97_spdif_cmask_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value return 0; } -static int snd_ac97_spdif_pmask_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { /* FIXME: AC'97 spec doesn't say which bits are used for what */ ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | @@ -706,9 +706,9 @@ static int snd_ac97_spdif_pmask_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value return 0; } -static int snd_ac97_spdif_default_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); down(&ac97->reg_mutex); ucontrol->value.iec958.status[0] = ac97->spdif_status & 0xff; @@ -719,9 +719,9 @@ static int snd_ac97_spdif_default_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return 0; } -static int snd_ac97_spdif_default_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned int new = 0; unsigned short val = 0; int change; @@ -787,9 +787,9 @@ static int snd_ac97_spdif_default_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return change; } -static int snd_ac97_put_spsa(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ac97_put_spsa(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -817,7 +817,7 @@ static int snd_ac97_put_spsa(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return change; } -const snd_kcontrol_new_t snd_ac97_controls_spdif[5] = { +const struct snd_kcontrol_new snd_ac97_controls_spdif[5] = { { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -856,9 +856,9 @@ const snd_kcontrol_new_t snd_ac97_controls_spdif[5] = { .get = snd_ac97_ad18xx_pcm_get_bits, .put = snd_ac97_ad18xx_pcm_put_bits, \ .private_value = (codec) | ((lshift) << 8) | ((rshift) << 12) | ((mask) << 16) } -static int snd_ac97_ad18xx_pcm_info_bits(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ac97_ad18xx_pcm_info_bits(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int mask = (kcontrol->private_value >> 16) & 0x0f; int lshift = (kcontrol->private_value >> 8) & 0x0f; int rshift = (kcontrol->private_value >> 12) & 0x0f; @@ -873,9 +873,9 @@ static int snd_ac97_ad18xx_pcm_info_bits(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_ac97_ad18xx_pcm_get_bits(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ad18xx_pcm_get_bits(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int codec = kcontrol->private_value & 3; int lshift = (kcontrol->private_value >> 8) & 0x0f; int rshift = (kcontrol->private_value >> 12) & 0x0f; @@ -887,9 +887,9 @@ static int snd_ac97_ad18xx_pcm_get_bits(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return 0; } -static int snd_ac97_ad18xx_pcm_put_bits(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ad18xx_pcm_put_bits(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int codec = kcontrol->private_value & 3; int lshift = (kcontrol->private_value >> 8) & 0x0f; int rshift = (kcontrol->private_value >> 12) & 0x0f; @@ -910,7 +910,7 @@ static int snd_ac97_ad18xx_pcm_put_bits(snd_kcontrol_t * kcontrol, snd_ctl_elem_ .get = snd_ac97_ad18xx_pcm_get_volume, .put = snd_ac97_ad18xx_pcm_put_volume, \ .private_value = codec } -static int snd_ac97_ad18xx_pcm_info_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ac97_ad18xx_pcm_info_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -919,9 +919,9 @@ static int snd_ac97_ad18xx_pcm_info_volume(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_ac97_ad18xx_pcm_get_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ad18xx_pcm_get_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int codec = kcontrol->private_value & 3; down(&ac97->page_mutex); @@ -931,9 +931,9 @@ static int snd_ac97_ad18xx_pcm_get_volume(snd_kcontrol_t * kcontrol, snd_ctl_ele return 0; } -static int snd_ac97_ad18xx_pcm_put_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ad18xx_pcm_put_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int codec = kcontrol->private_value & 3; unsigned short val1, val2; @@ -942,22 +942,22 @@ static int snd_ac97_ad18xx_pcm_put_volume(snd_kcontrol_t * kcontrol, snd_ctl_ele return snd_ac97_ad18xx_update_pcm_bits(ac97, codec, 0x1f1f, (val1 << 8) | val2); } -static const snd_kcontrol_new_t snd_ac97_controls_ad18xx_pcm[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_ad18xx_pcm[2] = { AD18XX_PCM_BITS("PCM Playback Switch", 0, 15, 7, 1), AD18XX_PCM_VOLUME("PCM Playback Volume", 0) }; -static const snd_kcontrol_new_t snd_ac97_controls_ad18xx_surround[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_ad18xx_surround[2] = { AD18XX_PCM_BITS("Surround Playback Switch", 1, 15, 7, 1), AD18XX_PCM_VOLUME("Surround Playback Volume", 1) }; -static const snd_kcontrol_new_t snd_ac97_controls_ad18xx_center[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_ad18xx_center[2] = { AD18XX_PCM_BITS("Center Playback Switch", 2, 15, 15, 1), AD18XX_PCM_BITS("Center Playback Volume", 2, 8, 8, 31) }; -static const snd_kcontrol_new_t snd_ac97_controls_ad18xx_lfe[2] = { +static const struct snd_kcontrol_new snd_ac97_controls_ad18xx_lfe[2] = { AD18XX_PCM_BITS("LFE Playback Switch", 2, 7, 7, 1), AD18XX_PCM_BITS("LFE Playback Volume", 2, 0, 0, 31) }; @@ -966,9 +966,9 @@ AD18XX_PCM_BITS("LFE Playback Volume", 2, 0, 0, 31) * */ -static void snd_ac97_powerdown(ac97_t *ac97); +static void snd_ac97_powerdown(struct snd_ac97 *ac97); -static int snd_ac97_bus_free(ac97_bus_t *bus) +static int snd_ac97_bus_free(struct snd_ac97_bus *bus) { if (bus) { snd_ac97_bus_proc_done(bus); @@ -980,13 +980,13 @@ static int snd_ac97_bus_free(ac97_bus_t *bus) return 0; } -static int snd_ac97_bus_dev_free(snd_device_t *device) +static int snd_ac97_bus_dev_free(struct snd_device *device) { - ac97_bus_t *bus = device->device_data; + struct snd_ac97_bus *bus = device->device_data; return snd_ac97_bus_free(bus); } -static int snd_ac97_free(ac97_t *ac97) +static int snd_ac97_free(struct snd_ac97 *ac97) { if (ac97) { snd_ac97_proc_done(ac97); @@ -999,14 +999,14 @@ static int snd_ac97_free(ac97_t *ac97) return 0; } -static int snd_ac97_dev_free(snd_device_t *device) +static int snd_ac97_dev_free(struct snd_device *device) { - ac97_t *ac97 = device->device_data; + struct snd_ac97 *ac97 = device->device_data; snd_ac97_powerdown(ac97); /* for avoiding click noises during shut down */ return snd_ac97_free(ac97); } -static int snd_ac97_try_volume_mix(ac97_t * ac97, int reg) +static int snd_ac97_try_volume_mix(struct snd_ac97 * ac97, int reg) { unsigned short val, mask = 0x8000; @@ -1052,13 +1052,14 @@ static int snd_ac97_try_volume_mix(ac97_t * ac97, int reg) /* try another test */ snd_ac97_write_cache(ac97, reg, val | mask); val = snd_ac97_read(ac97, reg); + val = snd_ac97_read(ac97, reg); if (!(val & mask)) return 0; /* nothing here */ } return 1; /* success, useable */ } -static void check_volume_resolution(ac97_t *ac97, int reg, unsigned char *lo_max, unsigned char *hi_max) +static void check_volume_resolution(struct snd_ac97 *ac97, int reg, unsigned char *lo_max, unsigned char *hi_max) { unsigned short cbit[3] = { 0x20, 0x10, 0x01 }; unsigned char max[3] = { 63, 31, 15 }; @@ -1083,7 +1084,7 @@ static void check_volume_resolution(ac97_t *ac97, int reg, unsigned char *lo_max } } -int snd_ac97_try_bit(ac97_t * ac97, int reg, int bit) +int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit) { unsigned short mask, val, orig, res; @@ -1097,7 +1098,7 @@ int snd_ac97_try_bit(ac97_t * ac97, int reg, int bit) } /* check the volume resolution of center/lfe */ -static void snd_ac97_change_volume_params2(ac97_t * ac97, int reg, int shift, unsigned char *max) +static void snd_ac97_change_volume_params2(struct snd_ac97 * ac97, int reg, int shift, unsigned char *max) { unsigned short val, val1; @@ -1123,9 +1124,9 @@ static inline int printable(unsigned int x) return x; } -snd_kcontrol_t *snd_ac97_cnew(const snd_kcontrol_new_t *_template, ac97_t * ac97) +struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97) { - snd_kcontrol_new_t template; + struct snd_kcontrol_new template; memcpy(&template, _template, sizeof(template)); template.index = ac97->num; return snd_ctl_new1(&template, ac97); @@ -1134,9 +1135,9 @@ snd_kcontrol_t *snd_ac97_cnew(const snd_kcontrol_new_t *_template, ac97_t * ac97 /* * create mute switch(es) for normal stereo controls */ -static int snd_ac97_cmute_new_stereo(snd_card_t *card, char *name, int reg, int check_stereo, ac97_t *ac97) +static int snd_ac97_cmute_new_stereo(struct snd_card *card, char *name, int reg, int check_stereo, struct snd_ac97 *ac97) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; int err; unsigned short val, val1, mute_mask; @@ -1153,11 +1154,11 @@ static int snd_ac97_cmute_new_stereo(snd_card_t *card, char *name, int reg, int mute_mask = 0x8080; } if (mute_mask == 0x8080) { - snd_kcontrol_new_t tmp = AC97_DOUBLE(name, reg, 15, 7, 1, 1); + struct snd_kcontrol_new tmp = AC97_DOUBLE(name, reg, 15, 7, 1, 1); tmp.index = ac97->num; kctl = snd_ctl_new1(&tmp, ac97); } else { - snd_kcontrol_new_t tmp = AC97_SINGLE(name, reg, 15, 1, 1); + struct snd_kcontrol_new tmp = AC97_SINGLE(name, reg, 15, 1, 1); tmp.index = ac97->num; kctl = snd_ctl_new1(&tmp, ac97); } @@ -1172,22 +1173,22 @@ static int snd_ac97_cmute_new_stereo(snd_card_t *card, char *name, int reg, int /* * create a volume for normal stereo/mono controls */ -static int snd_ac97_cvol_new(snd_card_t *card, char *name, int reg, unsigned int lo_max, - unsigned int hi_max, ac97_t *ac97) +static int snd_ac97_cvol_new(struct snd_card *card, char *name, int reg, unsigned int lo_max, + unsigned int hi_max, struct snd_ac97 *ac97) { int err; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; if (! snd_ac97_valid_reg(ac97, reg)) return 0; if (hi_max) { /* invert */ - snd_kcontrol_new_t tmp = AC97_DOUBLE(name, reg, 8, 0, lo_max, 1); + struct snd_kcontrol_new tmp = AC97_DOUBLE(name, reg, 8, 0, lo_max, 1); tmp.index = ac97->num; kctl = snd_ctl_new1(&tmp, ac97); } else { /* invert */ - snd_kcontrol_new_t tmp = AC97_SINGLE(name, reg, 0, lo_max, 1); + struct snd_kcontrol_new tmp = AC97_SINGLE(name, reg, 0, lo_max, 1); tmp.index = ac97->num; kctl = snd_ctl_new1(&tmp, ac97); } @@ -1203,7 +1204,7 @@ static int snd_ac97_cvol_new(snd_card_t *card, char *name, int reg, unsigned int /* * create a mute-switch and a volume for normal stereo/mono controls */ -static int snd_ac97_cmix_new_stereo(snd_card_t *card, const char *pfx, int reg, int check_stereo, ac97_t *ac97) +static int snd_ac97_cmix_new_stereo(struct snd_card *card, const char *pfx, int reg, int check_stereo, struct snd_ac97 *ac97) { int err; char name[44]; @@ -1229,12 +1230,12 @@ static int snd_ac97_cmix_new_stereo(snd_card_t *card, const char *pfx, int reg, #define snd_ac97_cmix_new(card, pfx, reg, ac97) snd_ac97_cmix_new_stereo(card, pfx, reg, 0, ac97) #define snd_ac97_cmute_new(card, name, reg, ac97) snd_ac97_cmute_new_stereo(card, name, reg, 0, ac97) -static unsigned int snd_ac97_determine_spdif_rates(ac97_t *ac97); +static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97); -static int snd_ac97_mixer_build(ac97_t * ac97) +static int snd_ac97_mixer_build(struct snd_ac97 * ac97) { - snd_card_t *card = ac97->bus->card; - snd_kcontrol_t *kctl; + struct snd_card *card = ac97->bus->card; + struct snd_kcontrol *kctl; int err; unsigned int idx; unsigned char max; @@ -1531,7 +1532,7 @@ static int snd_ac97_mixer_build(ac97_t * ac97) return 0; } -static int snd_ac97_modem_build(snd_card_t * card, ac97_t * ac97) +static int snd_ac97_modem_build(struct snd_card *card, struct snd_ac97 * ac97) { int err, idx; @@ -1555,7 +1556,7 @@ static int snd_ac97_modem_build(snd_card_t * card, ac97_t * ac97) return 0; } -static int snd_ac97_test_rate(ac97_t *ac97, int reg, int shadow_reg, int rate) +static int snd_ac97_test_rate(struct snd_ac97 *ac97, int reg, int shadow_reg, int rate) { unsigned short val; unsigned int tmp; @@ -1568,7 +1569,7 @@ static int snd_ac97_test_rate(ac97_t *ac97, int reg, int shadow_reg, int rate) return val == (tmp & 0xffff); } -static void snd_ac97_determine_rates(ac97_t *ac97, int reg, int shadow_reg, unsigned int *r_result) +static void snd_ac97_determine_rates(struct snd_ac97 *ac97, int reg, int shadow_reg, unsigned int *r_result) { unsigned int result = 0; unsigned short saved; @@ -1628,7 +1629,7 @@ static void snd_ac97_determine_rates(ac97_t *ac97, int reg, int shadow_reg, unsi } /* check AC97_SPDIF register to accept which sample rates */ -static unsigned int snd_ac97_determine_spdif_rates(ac97_t *ac97) +static unsigned int snd_ac97_determine_spdif_rates(struct snd_ac97 *ac97) { unsigned int result = 0; int i; @@ -1648,10 +1649,10 @@ static unsigned int snd_ac97_determine_spdif_rates(ac97_t *ac97) } /* look for the codec id table matching with the given id */ -static const ac97_codec_id_t *look_for_codec_id(const ac97_codec_id_t *table, - unsigned int id) +static const struct ac97_codec_id *look_for_codec_id(const struct ac97_codec_id *table, + unsigned int id) { - const ac97_codec_id_t *pid; + const struct ac97_codec_id *pid; for (pid = table; pid->id; pid++) if (pid->id == (id & pid->mask)) @@ -1659,9 +1660,9 @@ static const ac97_codec_id_t *look_for_codec_id(const ac97_codec_id_t *table, return NULL; } -void snd_ac97_get_name(ac97_t *ac97, unsigned int id, char *name, int modem) +void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem) { - const ac97_codec_id_t *pid; + const struct ac97_codec_id *pid; sprintf(name, "0x%x %c%c%c", id, printable(id >> 24), @@ -1699,9 +1700,9 @@ void snd_ac97_get_name(ac97_t *ac97, unsigned int id, char *name, int modem) * * Returns the short identifying name of the codec. */ -const char *snd_ac97_get_short_name(ac97_t *ac97) +const char *snd_ac97_get_short_name(struct snd_ac97 *ac97) { - const ac97_codec_id_t *pid; + const struct ac97_codec_id *pid; for (pid = snd_ac97_codec_ids; pid->id; pid++) if (pid->id == (ac97->id & pid->mask)) @@ -1713,7 +1714,7 @@ const char *snd_ac97_get_short_name(ac97_t *ac97) /* wait for a while until registers are accessible after RESET * return 0 if ok, negative not ready */ -static int ac97_reset_wait(ac97_t *ac97, int timeout, int with_modem) +static int ac97_reset_wait(struct snd_ac97 *ac97, int timeout, int with_modem) { unsigned long end_time; unsigned short val; @@ -1758,7 +1759,7 @@ static int ac97_reset_wait(ac97_t *ac97, int timeout, int with_modem) * @private_data: private data pointer for the new instance * @rbus: the pointer to store the new AC97 bus instance. * - * Creates an AC97 bus component. An ac97_bus_t instance is newly + * Creates an AC97 bus component. An struct snd_ac97_bus instance is newly * allocated and initialized. * * The ops table must include valid callbacks (at least read and @@ -1772,12 +1773,12 @@ static int ac97_reset_wait(ac97_t *ac97, int timeout, int with_modem) * * Returns zero if successful, or a negative error code on failure. */ -int snd_ac97_bus(snd_card_t *card, int num, ac97_bus_ops_t *ops, - void *private_data, ac97_bus_t **rbus) +int snd_ac97_bus(struct snd_card *card, int num, struct snd_ac97_bus_ops *ops, + void *private_data, struct snd_ac97_bus **rbus) { int err; - ac97_bus_t *bus; - static snd_device_ops_t dev_ops = { + struct snd_ac97_bus *bus; + static struct snd_device_ops dev_ops = { .dev_free = snd_ac97_bus_dev_free, }; @@ -1807,9 +1808,9 @@ static void ac97_device_release(struct device * dev) } /* register ac97 codec to bus */ -static int snd_ac97_dev_register(snd_device_t *device) +static int snd_ac97_dev_register(struct snd_device *device) { - ac97_t *ac97 = device->device_data; + struct snd_ac97 *ac97 = device->device_data; int err; ac97->dev.bus = &ac97_bus_type; @@ -1825,9 +1826,9 @@ static int snd_ac97_dev_register(snd_device_t *device) } /* unregister ac97 codec */ -static int snd_ac97_dev_unregister(snd_device_t *device) +static int snd_ac97_dev_unregister(struct snd_device *device) { - ac97_t *ac97 = device->device_data; + struct snd_ac97 *ac97 = device->device_data; if (ac97->dev.bus) device_unregister(&ac97->dev); return snd_ac97_free(ac97); @@ -1843,7 +1844,7 @@ static struct snd_ac97_build_ops null_build_ops; * the private data. * @rac97: the pointer to store the new ac97 instance. * - * Creates an Codec97 component. An ac97_t instance is newly + * Creates an Codec97 component. An struct snd_ac97 instance is newly * allocated and initialized from the template. The codec * is then initialized by the standard procedure. * @@ -1855,16 +1856,16 @@ static struct snd_ac97_build_ops null_build_ops; * * Returns zero if successful, or a negative error code on failure. */ -int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97) +int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, struct snd_ac97 **rac97) { int err; - ac97_t *ac97; - snd_card_t *card; + struct snd_ac97 *ac97; + struct snd_card *card; char name[64]; unsigned long end_time; unsigned int reg; - const ac97_codec_id_t *pid; - static snd_device_ops_t ops = { + const struct ac97_codec_id *pid; + static struct snd_device_ops ops = { .dev_free = snd_ac97_dev_free, .dev_register = snd_ac97_dev_register, .dev_unregister = snd_ac97_dev_unregister, @@ -2148,7 +2149,7 @@ int snd_ac97_mixer(ac97_bus_t *bus, ac97_template_t *template, ac97_t **rac97) * MASTER and HEADPHONE registers are muted but the register cache values * are not changed, so that the values can be restored in snd_ac97_resume(). */ -static void snd_ac97_powerdown(ac97_t *ac97) +static void snd_ac97_powerdown(struct snd_ac97 *ac97) { unsigned short power; @@ -2181,7 +2182,7 @@ static void snd_ac97_powerdown(ac97_t *ac97) * * Suspends the codec, power down the chip. */ -void snd_ac97_suspend(ac97_t *ac97) +void snd_ac97_suspend(struct snd_ac97 *ac97) { if (ac97->build_ops->suspend) ac97->build_ops->suspend(ac97); @@ -2191,7 +2192,7 @@ void snd_ac97_suspend(ac97_t *ac97) /* * restore ac97 status */ -void snd_ac97_restore_status(ac97_t *ac97) +void snd_ac97_restore_status(struct snd_ac97 *ac97) { int i; @@ -2212,7 +2213,7 @@ void snd_ac97_restore_status(ac97_t *ac97) /* * restore IEC958 status */ -void snd_ac97_restore_iec958(ac97_t *ac97) +void snd_ac97_restore_iec958(struct snd_ac97 *ac97) { if (ac97->ext_id & AC97_EI_SPDIF) { if (ac97->regs[AC97_EXTENDED_STATUS] & AC97_EA_SPDIF) { @@ -2235,7 +2236,7 @@ void snd_ac97_restore_iec958(ac97_t *ac97) * Do the standard resume procedure, power up and restoring the * old register values. */ -void snd_ac97_resume(ac97_t *ac97) +void snd_ac97_resume(struct snd_ac97 *ac97) { unsigned long end_time; @@ -2301,18 +2302,18 @@ static void set_ctl_name(char *dst, const char *src, const char *suffix) } /* remove the control with the given name and optional suffix */ -int snd_ac97_remove_ctl(ac97_t *ac97, const char *name, const char *suffix) +int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; memset(&id, 0, sizeof(id)); set_ctl_name(id.name, name, suffix); id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; return snd_ctl_remove_id(ac97->bus->card, &id); } -static snd_kcontrol_t *ctl_find(ac97_t *ac97, const char *name, const char *suffix) +static struct snd_kcontrol *ctl_find(struct snd_ac97 *ac97, const char *name, const char *suffix) { - snd_ctl_elem_id_t sid; + struct snd_ctl_elem_id sid; memset(&sid, 0, sizeof(sid)); set_ctl_name(sid.name, name, suffix); sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; @@ -2320,9 +2321,9 @@ static snd_kcontrol_t *ctl_find(ac97_t *ac97, const char *name, const char *suff } /* rename the control with the given name and optional suffix */ -int snd_ac97_rename_ctl(ac97_t *ac97, const char *src, const char *dst, const char *suffix) +int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix) { - snd_kcontrol_t *kctl = ctl_find(ac97, src, suffix); + struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix); if (kctl) { set_ctl_name(kctl->id.name, dst, suffix); return 0; @@ -2331,16 +2332,16 @@ int snd_ac97_rename_ctl(ac97_t *ac97, const char *src, const char *dst, const ch } /* rename both Volume and Switch controls - don't check the return value */ -void snd_ac97_rename_vol_ctl(ac97_t *ac97, const char *src, const char *dst) +void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst) { snd_ac97_rename_ctl(ac97, src, dst, "Switch"); snd_ac97_rename_ctl(ac97, src, dst, "Volume"); } /* swap controls */ -int snd_ac97_swap_ctl(ac97_t *ac97, const char *s1, const char *s2, const char *suffix) +int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix) { - snd_kcontrol_t *kctl1, *kctl2; + struct snd_kcontrol *kctl1, *kctl2; kctl1 = ctl_find(ac97, s1, suffix); kctl2 = ctl_find(ac97, s2, suffix); if (kctl1 && kctl2) { @@ -2353,7 +2354,7 @@ int snd_ac97_swap_ctl(ac97_t *ac97, const char *s1, const char *s2, const char * #if 1 /* bind hp and master controls instead of using only hp control */ -static int bind_hp_volsw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int bind_hp_volsw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int err = snd_ac97_put_volsw(kcontrol, ucontrol); if (err > 0) { @@ -2366,10 +2367,10 @@ static int bind_hp_volsw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco } /* ac97 tune: bind Master and Headphone controls */ -static int tune_hp_only(ac97_t *ac97) +static int tune_hp_only(struct snd_ac97 *ac97) { - snd_kcontrol_t *msw = ctl_find(ac97, "Master Playback Switch", NULL); - snd_kcontrol_t *mvol = ctl_find(ac97, "Master Playback Volume", NULL); + struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); + struct snd_kcontrol *mvol = ctl_find(ac97, "Master Playback Volume", NULL); if (! msw || ! mvol) return -ENOENT; msw->put = bind_hp_volsw_put; @@ -2381,7 +2382,7 @@ static int tune_hp_only(ac97_t *ac97) #else /* ac97 tune: use Headphone control as master */ -static int tune_hp_only(ac97_t *ac97) +static int tune_hp_only(struct snd_ac97 *ac97) { if (ctl_find(ac97, "Headphone Playback Switch", NULL) == NULL) return -ENOENT; @@ -2393,7 +2394,7 @@ static int tune_hp_only(ac97_t *ac97) #endif /* ac97 tune: swap Headphone and Master controls */ -static int tune_swap_hp(ac97_t *ac97) +static int tune_swap_hp(struct snd_ac97 *ac97) { if (ctl_find(ac97, "Headphone Playback Switch", NULL) == NULL) return -ENOENT; @@ -2403,7 +2404,7 @@ static int tune_swap_hp(ac97_t *ac97) } /* ac97 tune: swap Surround and Master controls */ -static int tune_swap_surround(ac97_t *ac97) +static int tune_swap_surround(struct snd_ac97 *ac97) { if (snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Switch") || snd_ac97_swap_ctl(ac97, "Master Playback", "Surround Playback", "Volume")) @@ -2412,7 +2413,7 @@ static int tune_swap_surround(ac97_t *ac97) } /* ac97 tune: set up mic sharing for AD codecs */ -static int tune_ad_sharing(ac97_t *ac97) +static int tune_ad_sharing(struct snd_ac97 *ac97) { unsigned short scfg; if ((ac97->id & 0xffffff00) != 0x41445300) { @@ -2425,11 +2426,11 @@ static int tune_ad_sharing(ac97_t *ac97) return 0; } -static const snd_kcontrol_new_t snd_ac97_alc_jack_detect = +static const struct snd_kcontrol_new snd_ac97_alc_jack_detect = AC97_SINGLE("Jack Detect", AC97_ALC650_CLOCK, 5, 1, 0); /* ac97 tune: set up ALC jack-select */ -static int tune_alc_jack(ac97_t *ac97) +static int tune_alc_jack(struct snd_ac97 *ac97) { if ((ac97->id & 0xffffff00) != 0x414c4700) { snd_printk(KERN_ERR "ac97_quirk ALC_JACK is only for Realtek codecs\n"); @@ -2441,20 +2442,20 @@ static int tune_alc_jack(ac97_t *ac97) } /* ac97 tune: inversed EAPD bit */ -static int tune_inv_eapd(ac97_t *ac97) +static int tune_inv_eapd(struct snd_ac97 *ac97) { - snd_kcontrol_t *kctl = ctl_find(ac97, "External Amplifier", NULL); + struct snd_kcontrol *kctl = ctl_find(ac97, "External Amplifier", NULL); if (! kctl) return -ENOENT; set_inv_eapd(ac97, kctl); return 0; } -static int master_mute_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int master_mute_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int err = snd_ac97_put_volsw(kcontrol, ucontrol); if (err > 0) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int shift = (kcontrol->private_value >> 8) & 0x0f; int rshift = (kcontrol->private_value >> 12) & 0x0f; unsigned short mask; @@ -2470,9 +2471,9 @@ static int master_mute_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc } /* ac97 tune: EAPD controls mute LED bound with the master mute */ -static int tune_mute_led(ac97_t *ac97) +static int tune_mute_led(struct snd_ac97 *ac97) { - snd_kcontrol_t *msw = ctl_find(ac97, "Master Playback Switch", NULL); + struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); if (! msw) return -ENOENT; msw->put = master_mute_sw_put; @@ -2483,7 +2484,7 @@ static int tune_mute_led(ac97_t *ac97) struct quirk_table { const char *name; - int (*func)(ac97_t *); + int (*func)(struct snd_ac97 *); }; static struct quirk_table applicable_quirks[] = { @@ -2498,7 +2499,7 @@ static struct quirk_table applicable_quirks[] = { }; /* apply the quirk with the given type */ -static int apply_quirk(ac97_t *ac97, int type) +static int apply_quirk(struct snd_ac97 *ac97, int type) { if (type <= 0) return 0; @@ -2510,7 +2511,7 @@ static int apply_quirk(ac97_t *ac97, int type) } /* apply the quirk with the given name */ -static int apply_quirk_str(ac97_t *ac97, const char *typestr) +static int apply_quirk_str(struct snd_ac97 *ac97, const char *typestr) { int i; struct quirk_table *q; @@ -2539,7 +2540,7 @@ static int apply_quirk_str(ac97_t *ac97, const char *typestr) * Returns zero if successful, or a negative error code on failure. */ -int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, const char *override) +int snd_ac97_tune_hardware(struct snd_ac97 *ac97, struct ac97_quirk *quirk, const char *override) { int result; diff --git a/sound/pci/ac97/ac97_local.h b/sound/pci/ac97/ac97_local.h index 5ff3ef2..e98587e 100644 --- a/sound/pci/ac97/ac97_local.h +++ b/sound/pci/ac97/ac97_local.h @@ -37,6 +37,7 @@ .get = snd_ac97_get_volsw, .put = snd_ac97_put_volsw, \ .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) } +/* enum control */ struct ac97_enum { unsigned char reg; unsigned char shift_l; @@ -57,33 +58,33 @@ struct ac97_enum { /* ac97_codec.c */ extern const char *snd_ac97_stereo_enhancements[]; -extern const snd_kcontrol_new_t snd_ac97_controls_3d[]; -extern const snd_kcontrol_new_t snd_ac97_controls_spdif[]; -snd_kcontrol_t *snd_ac97_cnew(const snd_kcontrol_new_t *_template, ac97_t * ac97); -void snd_ac97_get_name(ac97_t *ac97, unsigned int id, char *name, int modem); -int snd_ac97_info_volsw(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo); -int snd_ac97_get_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); -int snd_ac97_put_volsw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); -int snd_ac97_try_bit(ac97_t * ac97, int reg, int bit); -int snd_ac97_remove_ctl(ac97_t *ac97, const char *name, const char *suffix); -int snd_ac97_rename_ctl(ac97_t *ac97, const char *src, const char *dst, const char *suffix); -int snd_ac97_swap_ctl(ac97_t *ac97, const char *s1, const char *s2, const char *suffix); -void snd_ac97_rename_vol_ctl(ac97_t *ac97, const char *src, const char *dst); -void snd_ac97_restore_status(ac97_t *ac97); -void snd_ac97_restore_iec958(ac97_t *ac97); -int snd_ac97_info_enum_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo); -int snd_ac97_get_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); -int snd_ac97_put_enum_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); +extern const struct snd_kcontrol_new snd_ac97_controls_3d[]; +extern const struct snd_kcontrol_new snd_ac97_controls_spdif[]; +struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97); +void snd_ac97_get_name(struct snd_ac97 *ac97, unsigned int id, char *name, int modem); +int snd_ac97_info_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_ac97_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_ac97_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_ac97_try_bit(struct snd_ac97 * ac97, int reg, int bit); +int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, const char *suffix); +int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix); +int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix); +void snd_ac97_rename_vol_ctl(struct snd_ac97 *ac97, const char *src, const char *dst); +void snd_ac97_restore_status(struct snd_ac97 *ac97); +void snd_ac97_restore_iec958(struct snd_ac97 *ac97); +int snd_ac97_info_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_ac97_get_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_ac97_put_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); -int snd_ac97_update_bits_nolock(ac97_t *ac97, unsigned short reg, +int snd_ac97_update_bits_nolock(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value); /* ac97_proc.c */ #ifdef CONFIG_PROC_FS -void snd_ac97_bus_proc_init(ac97_bus_t * ac97); -void snd_ac97_bus_proc_done(ac97_bus_t * ac97); -void snd_ac97_proc_init(ac97_t * ac97); -void snd_ac97_proc_done(ac97_t * ac97); +void snd_ac97_bus_proc_init(struct snd_ac97_bus * ac97); +void snd_ac97_bus_proc_done(struct snd_ac97_bus * ac97); +void snd_ac97_proc_init(struct snd_ac97 * ac97); +void snd_ac97_proc_done(struct snd_ac97 * ac97); #else #define snd_ac97_bus_proc_init(ac97_bus_t) do { } while (0) #define snd_ac97_bus_proc_done(ac97_bus_t) do { } while (0) diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index de1c72a..c68ee0f 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -39,7 +39,7 @@ * Chip specific initialization */ -static int patch_build_controls(ac97_t * ac97, const snd_kcontrol_new_t *controls, int count) +static int patch_build_controls(struct snd_ac97 * ac97, const struct snd_kcontrol_new *controls, int count) { int idx, err; @@ -50,7 +50,7 @@ static int patch_build_controls(ac97_t * ac97, const snd_kcontrol_new_t *control } /* set to the page, update bits and restore the page */ -static int ac97_update_bits_page(ac97_t *ac97, unsigned short reg, unsigned short mask, unsigned short value, unsigned short page) +static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value, unsigned short page) { unsigned short page_save; int ret; @@ -67,7 +67,7 @@ static int ac97_update_bits_page(ac97_t *ac97, unsigned short reg, unsigned shor /* * shared line-in/mic controls */ -static int ac97_enum_text_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo, +static int ac97_enum_text_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo, const char **texts, unsigned int nums) { uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -79,23 +79,23 @@ static int ac97_enum_text_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *ui return 0; } -static int ac97_surround_jack_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int ac97_surround_jack_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static const char *texts[] = { "Shared", "Independent" }; return ac97_enum_text_info(kcontrol, uinfo, texts, 2); } -static int ac97_surround_jack_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ac97_surround_jack_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = ac97->indep_surround; return 0; } -static int ac97_surround_jack_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ac97_surround_jack_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned char indep = !!ucontrol->value.enumerated.item[0]; if (indep != ac97->indep_surround) { @@ -107,7 +107,7 @@ static int ac97_surround_jack_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return 0; } -static int ac97_channel_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int ac97_channel_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static const char *texts[] = { "2ch", "4ch", "6ch" }; if (kcontrol->private_value) @@ -115,17 +115,17 @@ static int ac97_channel_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return ac97_enum_text_info(kcontrol, uinfo, texts, 3); } -static int ac97_channel_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ac97_channel_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = ac97->channel_mode; return 0; } -static int ac97_channel_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ac97_channel_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned char mode = ucontrol->value.enumerated.item[0]; if (mode != ac97->channel_mode) { @@ -163,22 +163,22 @@ static int ac97_channel_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t .private_value = 1, \ } -static inline int is_surround_on(ac97_t *ac97) +static inline int is_surround_on(struct snd_ac97 *ac97) { return ac97->channel_mode >= 1; } -static inline int is_clfe_on(ac97_t *ac97) +static inline int is_clfe_on(struct snd_ac97 *ac97) { return ac97->channel_mode >= 2; } -static inline int is_shared_linein(ac97_t *ac97) +static inline int is_shared_linein(struct snd_ac97 *ac97) { return ! ac97->indep_surround && is_surround_on(ac97); } -static inline int is_shared_micin(ac97_t *ac97) +static inline int is_shared_micin(struct snd_ac97 *ac97) { return ! ac97->indep_surround && is_clfe_on(ac97); } @@ -187,7 +187,7 @@ static inline int is_shared_micin(ac97_t *ac97) /* The following snd_ac97_ymf753_... items added by David Shust (dshust@shustring.com) */ /* It is possible to indicate to the Yamaha YMF753 the type of speakers being used. */ -static int snd_ac97_ymf753_info_speaker(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ac97_ymf753_info_speaker(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "Standard", "Small", "Smaller" @@ -202,9 +202,9 @@ static int snd_ac97_ymf753_info_speaker(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_ac97_ymf753_get_speaker(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ymf753_get_speaker(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = ac97->regs[AC97_YMF753_3D_MODE_SEL]; @@ -215,9 +215,9 @@ static int snd_ac97_ymf753_get_speaker(snd_kcontrol_t * kcontrol, snd_ctl_elem_v return 0; } -static int snd_ac97_ymf753_put_speaker(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ymf753_put_speaker(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; if (ucontrol->value.enumerated.item[0] > 2) @@ -226,7 +226,7 @@ static int snd_ac97_ymf753_put_speaker(snd_kcontrol_t * kcontrol, snd_ctl_elem_v return snd_ac97_update(ac97, AC97_YMF753_3D_MODE_SEL, val); } -static const snd_kcontrol_new_t snd_ac97_ymf753_controls_speaker = +static const struct snd_kcontrol_new snd_ac97_ymf753_controls_speaker = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "3D Control - Speaker", @@ -236,7 +236,7 @@ static const snd_kcontrol_new_t snd_ac97_ymf753_controls_speaker = }; /* It is possible to indicate to the Yamaha YMF753 the source to direct to the S/PDIF output. */ -static int snd_ac97_ymf753_spdif_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ac97_ymf753_spdif_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "AC-Link", "A/D Converter" }; @@ -249,9 +249,9 @@ static int snd_ac97_ymf753_spdif_source_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_ac97_ymf753_spdif_source_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ymf753_spdif_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = ac97->regs[AC97_YMF753_DIT_CTRL2]; @@ -259,9 +259,9 @@ static int snd_ac97_ymf753_spdif_source_get(snd_kcontrol_t * kcontrol, snd_ctl_e return 0; } -static int snd_ac97_ymf753_spdif_source_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ymf753_spdif_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; if (ucontrol->value.enumerated.item[0] > 1) @@ -274,7 +274,7 @@ static int snd_ac97_ymf753_spdif_source_put(snd_kcontrol_t * kcontrol, snd_ctl_e The YMF753 will output the S/PDIF signal to pin 43, 47 (EAPD), or 48. By default, no output pin is selected, and the S/PDIF signal is not output. There is also a bit to mute S/PDIF output in a vendor-specific register. */ -static int snd_ac97_ymf753_spdif_output_pin_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ac97_ymf753_spdif_output_pin_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "Disabled", "Pin 43", "Pin 48" }; @@ -287,9 +287,9 @@ static int snd_ac97_ymf753_spdif_output_pin_info(snd_kcontrol_t *kcontrol, snd_c return 0; } -static int snd_ac97_ymf753_spdif_output_pin_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ymf753_spdif_output_pin_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = ac97->regs[AC97_YMF753_DIT_CTRL2]; @@ -297,9 +297,9 @@ static int snd_ac97_ymf753_spdif_output_pin_get(snd_kcontrol_t * kcontrol, snd_c return 0; } -static int snd_ac97_ymf753_spdif_output_pin_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ymf753_spdif_output_pin_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; if (ucontrol->value.enumerated.item[0] > 2) @@ -311,7 +311,7 @@ static int snd_ac97_ymf753_spdif_output_pin_put(snd_kcontrol_t * kcontrol, snd_c snd_ac97_write_cache(ac97, 0x62, snd_ac97_read(ac97, 0x62) | 0x0008); */ } -static const snd_kcontrol_new_t snd_ac97_ymf753_controls_spdif[3] = { +static const struct snd_kcontrol_new snd_ac97_ymf753_controls_spdif[3] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", @@ -329,9 +329,9 @@ static const snd_kcontrol_new_t snd_ac97_ymf753_controls_spdif[3] = { AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",NONE,NONE) "Mute", AC97_YMF753_DIT_CTRL2, 2, 1, 1) }; -static int patch_yamaha_ymf753_3d(ac97_t * ac97) +static int patch_yamaha_ymf753_3d(struct snd_ac97 * ac97) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; int err; if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) @@ -345,7 +345,7 @@ static int patch_yamaha_ymf753_3d(ac97_t * ac97) return 0; } -static int patch_yamaha_ymf753_post_spdif(ac97_t * ac97) +static int patch_yamaha_ymf753_post_spdif(struct snd_ac97 * ac97) { int err; @@ -359,7 +359,7 @@ static struct snd_ac97_build_ops patch_yamaha_ymf753_ops = { .build_post_spdif = patch_yamaha_ymf753_post_spdif }; -int patch_yamaha_ymf753(ac97_t * ac97) +int patch_yamaha_ymf753(struct snd_ac97 * ac97) { /* Patch for Yamaha YMF753, Copyright (c) by David Shust, dshust@shustring.com. This chip has nonstandard and extended behaviour with regard to its S/PDIF output. @@ -380,12 +380,12 @@ int patch_yamaha_ymf753(ac97_t * ac97) * added support for WM9705,WM9708,WM9709,WM9710,WM9711,WM9712 and WM9717. */ -static const snd_kcontrol_new_t wm97xx_snd_ac97_controls[] = { +static const struct snd_kcontrol_new wm97xx_snd_ac97_controls[] = { AC97_DOUBLE("Front Playback Volume", AC97_WM97XX_FMIXER_VOL, 8, 0, 31, 1), AC97_SINGLE("Front Playback Switch", AC97_WM97XX_FMIXER_VOL, 15, 1, 1), }; -static int patch_wolfson_wm9703_specific(ac97_t * ac97) +static int patch_wolfson_wm9703_specific(struct snd_ac97 * ac97) { /* This is known to work for the ViewSonic ViewPad 1000 * Randolph Bentson <bentson@holmsjoen.com> @@ -405,13 +405,13 @@ static struct snd_ac97_build_ops patch_wolfson_wm9703_ops = { .build_specific = patch_wolfson_wm9703_specific, }; -int patch_wolfson03(ac97_t * ac97) +int patch_wolfson03(struct snd_ac97 * ac97) { ac97->build_ops = &patch_wolfson_wm9703_ops; return 0; } -static const snd_kcontrol_new_t wm9704_snd_ac97_controls[] = { +static const struct snd_kcontrol_new wm9704_snd_ac97_controls[] = { AC97_DOUBLE("Front Playback Volume", AC97_WM97XX_FMIXER_VOL, 8, 0, 31, 1), AC97_SINGLE("Front Playback Switch", AC97_WM97XX_FMIXER_VOL, 15, 1, 1), AC97_DOUBLE("Rear Playback Volume", AC97_WM9704_RMIXER_VOL, 8, 0, 31, 1), @@ -420,7 +420,7 @@ AC97_DOUBLE("Rear DAC Volume", AC97_WM9704_RPCM_VOL, 8, 0, 31, 1), AC97_DOUBLE("Surround Volume", AC97_SURROUND_MASTER, 8, 0, 31, 1), }; -static int patch_wolfson_wm9704_specific(ac97_t * ac97) +static int patch_wolfson_wm9704_specific(struct snd_ac97 * ac97) { int err, i; for (i = 0; i < ARRAY_SIZE(wm9704_snd_ac97_controls); i++) { @@ -436,14 +436,14 @@ static struct snd_ac97_build_ops patch_wolfson_wm9704_ops = { .build_specific = patch_wolfson_wm9704_specific, }; -int patch_wolfson04(ac97_t * ac97) +int patch_wolfson04(struct snd_ac97 * ac97) { /* WM9704M/9704Q */ ac97->build_ops = &patch_wolfson_wm9704_ops; return 0; } -static int patch_wolfson_wm9705_specific(ac97_t * ac97) +static int patch_wolfson_wm9705_specific(struct snd_ac97 * ac97) { int err, i; for (i = 0; i < ARRAY_SIZE(wm97xx_snd_ac97_controls); i++) { @@ -458,7 +458,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9705_ops = { .build_specific = patch_wolfson_wm9705_specific, }; -int patch_wolfson05(ac97_t * ac97) +int patch_wolfson05(struct snd_ac97 * ac97) { /* WM9705, WM9710 */ ac97->build_ops = &patch_wolfson_wm9705_ops; @@ -490,7 +490,7 @@ AC97_ENUM_DOUBLE(AC97_REC_SEL, 8, 0, 8, wm9711_rec_sel), AC97_ENUM_SINGLE(AC97_PCI_SVID, 5, 2, wm9711_ng_type), }; -static const snd_kcontrol_new_t wm9711_snd_ac97_controls[] = { +static const struct snd_kcontrol_new wm9711_snd_ac97_controls[] = { AC97_SINGLE("ALC Target Volume", AC97_CODEC_CLASS_REV, 12, 15, 0), AC97_SINGLE("ALC Hold Time", AC97_CODEC_CLASS_REV, 8, 15, 0), AC97_SINGLE("ALC Decay Time", AC97_CODEC_CLASS_REV, 4, 15, 0), @@ -568,7 +568,7 @@ AC97_SINGLE("Headphone ZC Switch", AC97_HEADPHONE, 7, 1, 0), AC97_SINGLE("Mono ZC Switch", AC97_MASTER_MONO, 7, 1, 0), }; -static int patch_wolfson_wm9711_specific(ac97_t * ac97) +static int patch_wolfson_wm9711_specific(struct snd_ac97 * ac97) { int err, i; @@ -589,7 +589,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9711_ops = { .build_specific = patch_wolfson_wm9711_specific, }; -int patch_wolfson11(ac97_t * ac97) +int patch_wolfson11(struct snd_ac97 * ac97) { /* WM9711, WM9712 */ ac97->build_ops = &patch_wolfson_wm9711_ops; @@ -636,7 +636,7 @@ AC97_ENUM_SINGLE(AC97_GENERAL_PURPOSE, 15, 2, wm9713_base), AC97_ENUM_SINGLE(AC97_PCI_SVID, 5, 2, wm9713_ng_type), }; -static const snd_kcontrol_new_t wm13_snd_ac97_controls[] = { +static const struct snd_kcontrol_new wm13_snd_ac97_controls[] = { AC97_DOUBLE("Line In Volume", AC97_PC_BEEP, 8, 0, 31, 1), AC97_SINGLE("Line In to Headphone Switch", AC97_PC_BEEP, 15, 1, 1), AC97_SINGLE("Line In to Master Switch", AC97_PC_BEEP, 14, 1, 1), @@ -728,14 +728,14 @@ AC97_SINGLE("Bass Volume", AC97_GENERAL_PURPOSE, 8, 15, 1), AC97_SINGLE("Tone Volume", AC97_GENERAL_PURPOSE, 0, 15, 1), }; -static const snd_kcontrol_new_t wm13_snd_ac97_controls_3d[] = { +static const struct snd_kcontrol_new wm13_snd_ac97_controls_3d[] = { AC97_ENUM("Inv Input Mux", wm9713_enum[11]), AC97_SINGLE("3D Upper Cut-off Switch", AC97_REC_GAIN_MIC, 5, 1, 0), AC97_SINGLE("3D Lower Cut-off Switch", AC97_REC_GAIN_MIC, 4, 1, 0), AC97_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), }; -static int patch_wolfson_wm9713_3d (ac97_t * ac97) +static int patch_wolfson_wm9713_3d (struct snd_ac97 * ac97) { int err, i; @@ -746,7 +746,7 @@ static int patch_wolfson_wm9713_3d (ac97_t * ac97) return 0; } -static int patch_wolfson_wm9713_specific(ac97_t * ac97) +static int patch_wolfson_wm9713_specific(struct snd_ac97 * ac97) { int err, i; @@ -765,13 +765,13 @@ static int patch_wolfson_wm9713_specific(ac97_t * ac97) } #ifdef CONFIG_PM -static void patch_wolfson_wm9713_suspend (ac97_t * ac97) +static void patch_wolfson_wm9713_suspend (struct snd_ac97 * ac97) { snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xfeff); snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0xffff); } -static void patch_wolfson_wm9713_resume (ac97_t * ac97) +static void patch_wolfson_wm9713_resume (struct snd_ac97 * ac97) { snd_ac97_write_cache(ac97, AC97_EXTENDED_MID, 0xda00); snd_ac97_write_cache(ac97, AC97_EXTENDED_MSTATUS, 0x3810); @@ -788,7 +788,7 @@ static struct snd_ac97_build_ops patch_wolfson_wm9713_ops = { #endif }; -int patch_wolfson13(ac97_t * ac97) +int patch_wolfson13(struct snd_ac97 * ac97) { /* WM9713, WM9714 */ ac97->build_ops = &patch_wolfson_wm9713_ops; @@ -808,7 +808,7 @@ int patch_wolfson13(ac97_t * ac97) /* * Tritech codec */ -int patch_tritech_tr28028(ac97_t * ac97) +int patch_tritech_tr28028(struct snd_ac97 * ac97) { snd_ac97_write_cache(ac97, 0x26, 0x0300); snd_ac97_write_cache(ac97, 0x26, 0x0000); @@ -820,9 +820,9 @@ int patch_tritech_tr28028(ac97_t * ac97) /* * Sigmatel STAC97xx codecs */ -static int patch_sigmatel_stac9700_3d(ac97_t * ac97) +static int patch_sigmatel_stac9700_3d(struct snd_ac97 * ac97) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; int err; if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) @@ -833,9 +833,9 @@ static int patch_sigmatel_stac9700_3d(ac97_t * ac97) return 0; } -static int patch_sigmatel_stac9708_3d(ac97_t * ac97) +static int patch_sigmatel_stac9708_3d(struct snd_ac97 * ac97) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; int err; if ((err = snd_ctl_add(ac97->bus->card, kctl = snd_ac97_cnew(&snd_ac97_controls_3d[0], ac97))) < 0) @@ -850,18 +850,18 @@ static int patch_sigmatel_stac9708_3d(ac97_t * ac97) return 0; } -static const snd_kcontrol_new_t snd_ac97_sigmatel_4speaker = +static const struct snd_kcontrol_new snd_ac97_sigmatel_4speaker = AC97_SINGLE("Sigmatel 4-Speaker Stereo Playback Switch", AC97_SIGMATEL_DAC2INVERT, 2, 1, 0); -static const snd_kcontrol_new_t snd_ac97_sigmatel_phaseinvert = +static const struct snd_kcontrol_new snd_ac97_sigmatel_phaseinvert = AC97_SINGLE("Sigmatel Surround Phase Inversion Playback Switch", AC97_SIGMATEL_DAC2INVERT, 3, 1, 0); -static const snd_kcontrol_new_t snd_ac97_sigmatel_controls[] = { +static const struct snd_kcontrol_new snd_ac97_sigmatel_controls[] = { AC97_SINGLE("Sigmatel DAC 6dB Attenuate", AC97_SIGMATEL_ANALOG, 1, 1, 0), AC97_SINGLE("Sigmatel ADC 6dB Attenuate", AC97_SIGMATEL_ANALOG, 0, 1, 0) }; -static int patch_sigmatel_stac97xx_specific(ac97_t * ac97) +static int patch_sigmatel_stac97xx_specific(struct snd_ac97 * ac97) { int err; @@ -886,15 +886,15 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9700_ops = { .build_specific = patch_sigmatel_stac97xx_specific }; -int patch_sigmatel_stac9700(ac97_t * ac97) +int patch_sigmatel_stac9700(struct snd_ac97 * ac97) { ac97->build_ops = &patch_sigmatel_stac9700_ops; return 0; } -static int snd_ac97_stac9708_put_bias(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ac97_stac9708_put_bias(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int err; down(&ac97->page_mutex); @@ -906,7 +906,7 @@ static int snd_ac97_stac9708_put_bias(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return err; } -static const snd_kcontrol_new_t snd_ac97_stac9708_bias_control = { +static const struct snd_kcontrol_new snd_ac97_stac9708_bias_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Sigmatel Output Bias Switch", .info = snd_ac97_info_volsw, @@ -915,7 +915,7 @@ static const snd_kcontrol_new_t snd_ac97_stac9708_bias_control = { .private_value = AC97_SINGLE_VALUE(AC97_SIGMATEL_BIAS2, 4, 1, 0), }; -static int patch_sigmatel_stac9708_specific(ac97_t *ac97) +static int patch_sigmatel_stac9708_specific(struct snd_ac97 *ac97) { int err; @@ -930,7 +930,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9708_ops = { .build_specific = patch_sigmatel_stac9708_specific }; -int patch_sigmatel_stac9708(ac97_t * ac97) +int patch_sigmatel_stac9708(struct snd_ac97 * ac97) { unsigned int codec72, codec6c; @@ -956,7 +956,7 @@ int patch_sigmatel_stac9708(ac97_t * ac97) return 0; } -int patch_sigmatel_stac9721(ac97_t * ac97) +int patch_sigmatel_stac9721(struct snd_ac97 * ac97) { ac97->build_ops = &patch_sigmatel_stac9700_ops; if (snd_ac97_read(ac97, AC97_SIGMATEL_ANALOG) == 0) { @@ -970,7 +970,7 @@ int patch_sigmatel_stac9721(ac97_t * ac97) return 0; } -int patch_sigmatel_stac9744(ac97_t * ac97) +int patch_sigmatel_stac9744(struct snd_ac97 * ac97) { // patch for SigmaTel ac97->build_ops = &patch_sigmatel_stac9700_ops; @@ -982,7 +982,7 @@ int patch_sigmatel_stac9744(ac97_t * ac97) return 0; } -int patch_sigmatel_stac9756(ac97_t * ac97) +int patch_sigmatel_stac9756(struct snd_ac97 * ac97) { // patch for SigmaTel ac97->build_ops = &patch_sigmatel_stac9700_ops; @@ -994,7 +994,7 @@ int patch_sigmatel_stac9756(ac97_t * ac97) return 0; } -static int snd_ac97_stac9758_output_jack_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ac97_stac9758_output_jack_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[5] = { "Input/Disabled", "Front Output", "Rear Output", "Center/LFE Output", "Mixer Output" }; @@ -1008,9 +1008,9 @@ static int snd_ac97_stac9758_output_jack_info(snd_kcontrol_t *kcontrol, snd_ctl_ return 0; } -static int snd_ac97_stac9758_output_jack_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t* ucontrol) +static int snd_ac97_stac9758_output_jack_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value; unsigned short val; @@ -1022,9 +1022,9 @@ static int snd_ac97_stac9758_output_jack_get(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_ac97_stac9758_output_jack_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ac97_stac9758_output_jack_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value; unsigned short val; @@ -1038,7 +1038,7 @@ static int snd_ac97_stac9758_output_jack_put(snd_kcontrol_t *kcontrol, snd_ctl_e 7 << shift, val << shift, 0); } -static int snd_ac97_stac9758_input_jack_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ac97_stac9758_input_jack_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[7] = { "Mic2 Jack", "Mic1 Jack", "Line In Jack", "Front Jack", "Rear Jack", "Center/LFE Jack", "Mute" }; @@ -1052,9 +1052,9 @@ static int snd_ac97_stac9758_input_jack_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_ac97_stac9758_input_jack_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t* ucontrol) +static int snd_ac97_stac9758_input_jack_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value; unsigned short val; @@ -1063,16 +1063,16 @@ static int snd_ac97_stac9758_input_jack_get(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_ac97_stac9758_input_jack_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ac97_stac9758_input_jack_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value; return ac97_update_bits_page(ac97, AC97_SIGMATEL_INSEL, 7 << shift, ucontrol->value.enumerated.item[0] << shift, 0); } -static int snd_ac97_stac9758_phonesel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ac97_stac9758_phonesel_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "None", "Front Jack", "Rear Jack" }; @@ -1085,17 +1085,17 @@ static int snd_ac97_stac9758_phonesel_info(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_ac97_stac9758_phonesel_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t* ucontrol) +static int snd_ac97_stac9758_phonesel_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = ac97->regs[AC97_SIGMATEL_IOMISC] & 3; return 0; } -static int snd_ac97_stac9758_phonesel_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ac97_stac9758_phonesel_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); return ac97_update_bits_page(ac97, AC97_SIGMATEL_IOMISC, 3, ucontrol->value.enumerated.item[0], 0); @@ -1113,7 +1113,7 @@ static int snd_ac97_stac9758_phonesel_put(snd_kcontrol_t *kcontrol, snd_ctl_elem .get = snd_ac97_stac9758_input_jack_get, \ .put = snd_ac97_stac9758_input_jack_put, \ .private_value = shift } -static const snd_kcontrol_new_t snd_ac97_sigmatel_stac9758_controls[] = { +static const struct snd_kcontrol_new snd_ac97_sigmatel_stac9758_controls[] = { STAC9758_OUTPUT_JACK("Mic1 Jack", 1), STAC9758_OUTPUT_JACK("LineIn Jack", 4), STAC9758_OUTPUT_JACK("Front Jack", 7), @@ -1132,7 +1132,7 @@ static const snd_kcontrol_new_t snd_ac97_sigmatel_stac9758_controls[] = { AC97_SINGLE("Headphone +3dB Boost", AC97_SIGMATEL_IOMISC, 8, 1, 0) }; -static int patch_sigmatel_stac9758_specific(ac97_t *ac97) +static int patch_sigmatel_stac9758_specific(struct snd_ac97 *ac97) { int err; @@ -1159,7 +1159,7 @@ static struct snd_ac97_build_ops patch_sigmatel_stac9758_ops = { .build_specific = patch_sigmatel_stac9758_specific }; -int patch_sigmatel_stac9758(ac97_t * ac97) +int patch_sigmatel_stac9758(struct snd_ac97 * ac97) { static unsigned short regs[4] = { AC97_SIGMATEL_OUTSEL, @@ -1202,12 +1202,12 @@ int patch_sigmatel_stac9758(ac97_t * ac97) /* * Cirrus Logic CS42xx codecs */ -static const snd_kcontrol_new_t snd_ac97_cirrus_controls_spdif[2] = { +static const struct snd_kcontrol_new snd_ac97_cirrus_controls_spdif[2] = { AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), AC97_CSR_SPDIF, 15, 1, 0), AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "AC97-SPSA", AC97_CSR_ACMODE, 0, 3, 0) }; -static int patch_cirrus_build_spdif(ac97_t * ac97) +static int patch_cirrus_build_spdif(struct snd_ac97 * ac97) { int err; @@ -1233,7 +1233,7 @@ static struct snd_ac97_build_ops patch_cirrus_ops = { .build_spdif = patch_cirrus_build_spdif }; -int patch_cirrus_spdif(ac97_t * ac97) +int patch_cirrus_spdif(struct snd_ac97 * ac97) { /* Basically, the cs4201/cs4205/cs4297a has non-standard sp/dif registers. WHY CAN'T ANYONE FOLLOW THE BLOODY SPEC? *sigh* @@ -1254,7 +1254,7 @@ int patch_cirrus_spdif(ac97_t * ac97) return 0; } -int patch_cirrus_cs4299(ac97_t * ac97) +int patch_cirrus_cs4299(struct snd_ac97 * ac97) { /* force the detection of PC Beep */ ac97->flags |= AC97_HAS_PC_BEEP; @@ -1265,11 +1265,11 @@ int patch_cirrus_cs4299(ac97_t * ac97) /* * Conexant codecs */ -static const snd_kcontrol_new_t snd_ac97_conexant_controls_spdif[1] = { +static const struct snd_kcontrol_new snd_ac97_conexant_controls_spdif[1] = { AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), AC97_CXR_AUDIO_MISC, 3, 1, 0), }; -static int patch_conexant_build_spdif(ac97_t * ac97) +static int patch_conexant_build_spdif(struct snd_ac97 * ac97) { int err; @@ -1290,7 +1290,7 @@ static struct snd_ac97_build_ops patch_conexant_ops = { .build_spdif = patch_conexant_build_spdif }; -int patch_conexant(ac97_t * ac97) +int patch_conexant(struct snd_ac97 * ac97) { ac97->build_ops = &patch_conexant_ops; ac97->flags |= AC97_CX_SPDIF; @@ -1303,7 +1303,7 @@ int patch_conexant(ac97_t * ac97) * Analog Device AD18xx, AD19xx codecs */ #ifdef CONFIG_PM -static void ad18xx_resume(ac97_t *ac97) +static void ad18xx_resume(struct snd_ac97 *ac97) { static unsigned short setup_regs[] = { AC97_AD_MISC, AC97_AD_SERIAL_CFG, AC97_AD_JACK_SPDIF, @@ -1367,7 +1367,7 @@ static void ad18xx_resume(ac97_t *ac97) } #endif -int patch_ad1819(ac97_t * ac97) +int patch_ad1819(struct snd_ac97 * ac97) { unsigned short scfg; @@ -1377,7 +1377,7 @@ int patch_ad1819(ac97_t * ac97) return 0; } -static unsigned short patch_ad1881_unchained(ac97_t * ac97, int idx, unsigned short mask) +static unsigned short patch_ad1881_unchained(struct snd_ac97 * ac97, int idx, unsigned short mask) { unsigned short val; @@ -1393,7 +1393,7 @@ static unsigned short patch_ad1881_unchained(ac97_t * ac97, int idx, unsigned sh return mask; } -static int patch_ad1881_chained1(ac97_t * ac97, int idx, unsigned short codec_bits) +static int patch_ad1881_chained1(struct snd_ac97 * ac97, int idx, unsigned short codec_bits) { static int cfg_bits[3] = { 1<<12, 1<<14, 1<<13 }; unsigned short val; @@ -1411,7 +1411,7 @@ static int patch_ad1881_chained1(ac97_t * ac97, int idx, unsigned short codec_bi return 1; } -static void patch_ad1881_chained(ac97_t * ac97, int unchained_idx, int cidx1, int cidx2) +static void patch_ad1881_chained(struct snd_ac97 * ac97, int unchained_idx, int cidx1, int cidx2) { // already detected? if (ac97->spec.ad18xx.unchained[cidx1] || ac97->spec.ad18xx.chained[cidx1]) @@ -1441,7 +1441,7 @@ static struct snd_ac97_build_ops patch_ad1881_build_ops = { #endif }; -int patch_ad1881(ac97_t * ac97) +int patch_ad1881(struct snd_ac97 * ac97) { static const char cfg_idxs[3][2] = { {2, 1}, @@ -1500,7 +1500,7 @@ int patch_ad1881(ac97_t * ac97) return 0; } -static const snd_kcontrol_new_t snd_ac97_controls_ad1885[] = { +static const struct snd_kcontrol_new snd_ac97_controls_ad1885[] = { AC97_SINGLE("Digital Mono Direct", AC97_AD_MISC, 11, 1, 0), /* AC97_SINGLE("Digital Audio Mode", AC97_AD_MISC, 12, 1, 0), */ /* seems problematic */ AC97_SINGLE("Low Power Mixer", AC97_AD_MISC, 14, 1, 0), @@ -1509,7 +1509,7 @@ static const snd_kcontrol_new_t snd_ac97_controls_ad1885[] = { AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 8, 1, 1), /* inverted */ }; -static int patch_ad1885_specific(ac97_t * ac97) +static int patch_ad1885_specific(struct snd_ac97 * ac97) { int err; @@ -1525,7 +1525,7 @@ static struct snd_ac97_build_ops patch_ad1885_build_ops = { #endif }; -int patch_ad1885(ac97_t * ac97) +int patch_ad1885(struct snd_ac97 * ac97) { patch_ad1881(ac97); /* This is required to deal with the Intel D815EEAL2 */ @@ -1538,7 +1538,7 @@ int patch_ad1885(ac97_t * ac97) return 0; } -int patch_ad1886(ac97_t * ac97) +int patch_ad1886(struct snd_ac97 * ac97) { patch_ad1881(ac97); /* Presario700 workaround */ @@ -1569,7 +1569,7 @@ int patch_ad1886(ac97_t * ac97) #define AC97_AD198X_DACZ 0x8000 /* DAC zero-fill mode */ -static int snd_ac97_ad198x_spdif_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ac97_ad198x_spdif_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "AC-Link", "A/D Converter" }; @@ -1582,9 +1582,9 @@ static int snd_ac97_ad198x_spdif_source_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_ac97_ad198x_spdif_source_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ad198x_spdif_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = ac97->regs[AC97_AD_SERIAL_CFG]; @@ -1592,9 +1592,9 @@ static int snd_ac97_ad198x_spdif_source_get(snd_kcontrol_t * kcontrol, snd_ctl_e return 0; } -static int snd_ac97_ad198x_spdif_source_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_ad198x_spdif_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; if (ucontrol->value.enumerated.item[0] > 1) @@ -1603,7 +1603,7 @@ static int snd_ac97_ad198x_spdif_source_put(snd_kcontrol_t * kcontrol, snd_ctl_e return snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 0x0004, val); } -static const snd_kcontrol_new_t snd_ac97_ad198x_spdif_source = { +static const struct snd_kcontrol_new snd_ac97_ad198x_spdif_source = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", .info = snd_ac97_ad198x_spdif_source_info, @@ -1611,17 +1611,17 @@ static const snd_kcontrol_new_t snd_ac97_ad198x_spdif_source = { .put = snd_ac97_ad198x_spdif_source_put, }; -static int patch_ad198x_post_spdif(ac97_t * ac97) +static int patch_ad198x_post_spdif(struct snd_ac97 * ac97) { return patch_build_controls(ac97, &snd_ac97_ad198x_spdif_source, 1); } -static const snd_kcontrol_new_t snd_ac97_ad1981x_jack_sense[] = { +static const struct snd_kcontrol_new snd_ac97_ad1981x_jack_sense[] = { AC97_SINGLE("Headphone Jack Sense", AC97_AD_JACK_SPDIF, 11, 1, 0), AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0), }; -static int patch_ad1981a_specific(ac97_t * ac97) +static int patch_ad1981a_specific(struct snd_ac97 * ac97) { return patch_build_controls(ac97, snd_ac97_ad1981x_jack_sense, ARRAY_SIZE(snd_ac97_ad1981x_jack_sense)); @@ -1635,7 +1635,7 @@ static struct snd_ac97_build_ops patch_ad1981a_build_ops = { #endif }; -static void check_ad1981_hp_jack_sense(ac97_t *ac97) +static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97) { u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device; switch (subid) { @@ -1649,7 +1649,7 @@ static void check_ad1981_hp_jack_sense(ac97_t *ac97) } } -int patch_ad1981a(ac97_t *ac97) +int patch_ad1981a(struct snd_ac97 *ac97) { patch_ad1881(ac97); ac97->build_ops = &patch_ad1981a_build_ops; @@ -1659,10 +1659,10 @@ int patch_ad1981a(ac97_t *ac97) return 0; } -static const snd_kcontrol_new_t snd_ac97_ad198x_2cmic = +static const struct snd_kcontrol_new snd_ac97_ad198x_2cmic = AC97_SINGLE("Stereo Mic", AC97_AD_MISC, 6, 1, 0); -static int patch_ad1981b_specific(ac97_t *ac97) +static int patch_ad1981b_specific(struct snd_ac97 *ac97) { int err; @@ -1680,7 +1680,7 @@ static struct snd_ac97_build_ops patch_ad1981b_build_ops = { #endif }; -int patch_ad1981b(ac97_t *ac97) +int patch_ad1981b(struct snd_ac97 *ac97) { patch_ad1881(ac97); ac97->build_ops = &patch_ad1981b_build_ops; @@ -1690,7 +1690,7 @@ int patch_ad1981b(ac97_t *ac97) return 0; } -static int snd_ac97_ad1888_lohpsel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ac97_ad1888_lohpsel_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1699,9 +1699,9 @@ static int snd_ac97_ad1888_lohpsel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_ac97_ad1888_lohpsel_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t* ucontrol) +static int snd_ac97_ad1888_lohpsel_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = ac97->regs[AC97_AD_MISC]; @@ -1709,9 +1709,9 @@ static int snd_ac97_ad1888_lohpsel_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return 0; } -static int snd_ac97_ad1888_lohpsel_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ac97_ad1888_lohpsel_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = !ucontrol->value.integer.value[0] @@ -1720,7 +1720,7 @@ static int snd_ac97_ad1888_lohpsel_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va AC97_AD198X_LOSEL | AC97_AD198X_HPSEL, val); } -static int snd_ac97_ad1888_downmix_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ac97_ad1888_downmix_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = {"Off", "6 -> 4", "6 -> 2"}; @@ -1733,9 +1733,9 @@ static int snd_ac97_ad1888_downmix_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_ac97_ad1888_downmix_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t* ucontrol) +static int snd_ac97_ad1888_downmix_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = ac97->regs[AC97_AD_MISC]; @@ -1746,9 +1746,9 @@ static int snd_ac97_ad1888_downmix_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return 0; } -static int snd_ac97_ad1888_downmix_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ac97_ad1888_downmix_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; if (ucontrol->value.enumerated.item[0] > 2) @@ -1762,7 +1762,7 @@ static int snd_ac97_ad1888_downmix_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va AC97_AD198X_DMIX0 | AC97_AD198X_DMIX1, val); } -static void ad1888_update_jacks(ac97_t *ac97) +static void ad1888_update_jacks(struct snd_ac97 *ac97) { unsigned short val = 0; if (! is_shared_linein(ac97)) @@ -1773,7 +1773,7 @@ static void ad1888_update_jacks(ac97_t *ac97) snd_ac97_update_bits(ac97, AC97_AD_MISC, (1 << 11) | (1 << 12), val); } -static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = { +static const struct snd_kcontrol_new snd_ac97_ad1888_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Exchange Front/Surround", @@ -1796,7 +1796,7 @@ static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = { AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 12, 1, 0), }; -static int patch_ad1888_specific(ac97_t *ac97) +static int patch_ad1888_specific(struct snd_ac97 *ac97) { /* rename 0x04 as "Master" and 0x02 as "Master Surround" */ snd_ac97_rename_vol_ctl(ac97, "Master Playback", "Master Surround Playback"); @@ -1813,7 +1813,7 @@ static struct snd_ac97_build_ops patch_ad1888_build_ops = { .update_jacks = ad1888_update_jacks, }; -int patch_ad1888(ac97_t * ac97) +int patch_ad1888(struct snd_ac97 * ac97) { unsigned short misc; @@ -1833,7 +1833,7 @@ int patch_ad1888(ac97_t * ac97) return 0; } -static int patch_ad1980_specific(ac97_t *ac97) +static int patch_ad1980_specific(struct snd_ac97 *ac97) { int err; @@ -1851,25 +1851,25 @@ static struct snd_ac97_build_ops patch_ad1980_build_ops = { .update_jacks = ad1888_update_jacks, }; -int patch_ad1980(ac97_t * ac97) +int patch_ad1980(struct snd_ac97 * ac97) { patch_ad1888(ac97); ac97->build_ops = &patch_ad1980_build_ops; return 0; } -static const snd_kcontrol_new_t snd_ac97_ad1985_controls[] = { +static const struct snd_kcontrol_new snd_ac97_ad1985_controls[] = { AC97_SINGLE("Exchange Center/LFE", AC97_AD_SERIAL_CFG, 3, 1, 0) }; -static void ad1985_update_jacks(ac97_t *ac97) +static void ad1985_update_jacks(struct snd_ac97 *ac97) { ad1888_update_jacks(ac97); snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9, is_shared_micin(ac97) ? 0 : 1 << 9); } -static int patch_ad1985_specific(ac97_t *ac97) +static int patch_ad1985_specific(struct snd_ac97 *ac97) { int err; @@ -1887,7 +1887,7 @@ static struct snd_ac97_build_ops patch_ad1985_build_ops = { .update_jacks = ad1985_update_jacks, }; -int patch_ad1985(ac97_t * ac97) +int patch_ad1985(struct snd_ac97 * ac97) { unsigned short misc; @@ -1916,7 +1916,7 @@ int patch_ad1985(ac97_t * ac97) /* * realtek ALC65x/850 codecs */ -static void alc650_update_jacks(ac97_t *ac97) +static void alc650_update_jacks(struct snd_ac97 *ac97) { int shared; @@ -1937,7 +1937,7 @@ static void alc650_update_jacks(ac97_t *ac97) shared ? 0 : 0x100); } -static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = { +static const struct snd_kcontrol_new snd_ac97_controls_alc650[] = { AC97_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0), AC97_SINGLE("Surround Down Mix", AC97_ALC650_MULTICH, 1, 1, 0), AC97_SINGLE("Center/LFE Down Mix", AC97_ALC650_MULTICH, 2, 1, 0), @@ -1963,14 +1963,14 @@ static const snd_kcontrol_new_t snd_ac97_controls_alc650[] = { AC97_CHANNEL_MODE_CTL, }; -static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc650[] = { +static const struct snd_kcontrol_new snd_ac97_spdif_controls_alc650[] = { AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), AC97_ALC650_MULTICH, 11, 1, 0), AC97_SINGLE("Analog to IEC958 Output", AC97_ALC650_MULTICH, 12, 1, 0), /* disable this controls since it doesn't work as expected */ /* AC97_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 13, 1, 0), */ }; -static int patch_alc650_specific(ac97_t * ac97) +static int patch_alc650_specific(struct snd_ac97 * ac97) { int err; @@ -1988,7 +1988,7 @@ static struct snd_ac97_build_ops patch_alc650_ops = { .update_jacks = alc650_update_jacks }; -int patch_alc650(ac97_t * ac97) +int patch_alc650(struct snd_ac97 * ac97) { unsigned short val; @@ -2043,7 +2043,7 @@ int patch_alc650(ac97_t * ac97) return 0; } -static void alc655_update_jacks(ac97_t *ac97) +static void alc655_update_jacks(struct snd_ac97 *ac97) { int shared; @@ -2060,17 +2060,17 @@ static void alc655_update_jacks(ac97_t *ac97) shared ? (1 << 10) : 0, 0); } -static const snd_kcontrol_new_t snd_ac97_controls_alc655[] = { +static const struct snd_kcontrol_new snd_ac97_controls_alc655[] = { AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), AC97_SURROUND_JACK_MODE_CTL, AC97_CHANNEL_MODE_CTL, }; -static int alc655_iec958_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int alc655_iec958_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts_655[3] = { "PCM", "Analog In", "IEC958 In" }; static char *texts_658[4] = { "PCM", "Analog1 In", "Analog2 In", "IEC958 In" }; - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -2084,9 +2084,9 @@ static int alc655_iec958_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int alc655_iec958_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc655_iec958_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = ac97->regs[AC97_ALC650_MULTICH]; @@ -2097,16 +2097,16 @@ static int alc655_iec958_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return 0; } -static int alc655_iec958_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc655_iec958_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); return ac97_update_bits_page(ac97, AC97_ALC650_MULTICH, 3 << 12, (unsigned short)ucontrol->value.enumerated.item[0] << 12, 0); } -static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc655[] = { +static const struct snd_kcontrol_new snd_ac97_spdif_controls_alc655[] = { AC97_PAGE_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), AC97_ALC650_MULTICH, 11, 1, 0, 0), /* disable this controls since it doesn't work as expected */ /* AC97_PAGE_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 14, 1, 0, 0), */ @@ -2119,7 +2119,7 @@ static const snd_kcontrol_new_t snd_ac97_spdif_controls_alc655[] = { }, }; -static int patch_alc655_specific(ac97_t * ac97) +static int patch_alc655_specific(struct snd_ac97 * ac97) { int err; @@ -2137,7 +2137,7 @@ static struct snd_ac97_build_ops patch_alc655_ops = { .update_jacks = alc655_update_jacks }; -int patch_alc655(ac97_t * ac97) +int patch_alc655(struct snd_ac97 * ac97) { unsigned int val; @@ -2189,7 +2189,7 @@ int patch_alc655(ac97_t * ac97) #define AC97_ALC850_JACK_SELECT 0x76 #define AC97_ALC850_MISC1 0x7a -static void alc850_update_jacks(ac97_t *ac97) +static void alc850_update_jacks(struct snd_ac97 *ac97) { int shared; @@ -2211,14 +2211,14 @@ static void alc850_update_jacks(ac97_t *ac97) shared ? (2<<4) : (1<<4)); } -static const snd_kcontrol_new_t snd_ac97_controls_alc850[] = { +static const struct snd_kcontrol_new snd_ac97_controls_alc850[] = { AC97_PAGE_SINGLE("Duplicate Front", AC97_ALC650_MULTICH, 0, 1, 0, 0), AC97_SINGLE("Mic Front Input Switch", AC97_ALC850_JACK_SELECT, 15, 1, 1), AC97_SURROUND_JACK_MODE_CTL, AC97_CHANNEL_MODE_CTL, }; -static int patch_alc850_specific(ac97_t *ac97) +static int patch_alc850_specific(struct snd_ac97 *ac97) { int err; @@ -2236,7 +2236,7 @@ static struct snd_ac97_build_ops patch_alc850_ops = { .update_jacks = alc850_update_jacks }; -int patch_alc850(ac97_t *ac97) +int patch_alc850(struct snd_ac97 *ac97) { ac97->build_ops = &patch_alc850_ops; @@ -2273,20 +2273,20 @@ int patch_alc850(ac97_t *ac97) /* * C-Media CM97xx codecs */ -static void cm9738_update_jacks(ac97_t *ac97) +static void cm9738_update_jacks(struct snd_ac97 *ac97) { /* shared Line-In */ snd_ac97_update_bits(ac97, AC97_CM9738_VENDOR_CTRL, 1 << 10, is_shared_linein(ac97) ? (1 << 10) : 0); } -static const snd_kcontrol_new_t snd_ac97_cm9738_controls[] = { +static const struct snd_kcontrol_new snd_ac97_cm9738_controls[] = { AC97_SINGLE("Duplicate Front", AC97_CM9738_VENDOR_CTRL, 13, 1, 0), AC97_SURROUND_JACK_MODE_CTL, AC97_CHANNEL_MODE_4CH_CTL, }; -static int patch_cm9738_specific(ac97_t * ac97) +static int patch_cm9738_specific(struct snd_ac97 * ac97) { return patch_build_controls(ac97, snd_ac97_cm9738_controls, ARRAY_SIZE(snd_ac97_cm9738_controls)); } @@ -2296,7 +2296,7 @@ static struct snd_ac97_build_ops patch_cm9738_ops = { .update_jacks = cm9738_update_jacks }; -int patch_cm9738(ac97_t * ac97) +int patch_cm9738(struct snd_ac97 * ac97) { ac97->build_ops = &patch_cm9738_ops; /* FIXME: can anyone confirm below? */ @@ -2307,7 +2307,7 @@ int patch_cm9738(ac97_t * ac97) return 0; } -static int snd_ac97_cmedia_spdif_playback_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ac97_cmedia_spdif_playback_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "Analog", "Digital" }; @@ -2320,9 +2320,9 @@ static int snd_ac97_cmedia_spdif_playback_source_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ac97_cmedia_spdif_playback_source_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_cmedia_spdif_playback_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); unsigned short val; val = ac97->regs[AC97_CM9739_SPDIF_CTRL]; @@ -2330,16 +2330,16 @@ static int snd_ac97_cmedia_spdif_playback_source_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ac97_cmedia_spdif_playback_source_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ac97_cmedia_spdif_playback_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); return snd_ac97_update_bits(ac97, AC97_CM9739_SPDIF_CTRL, 0x01 << 1, (ucontrol->value.enumerated.item[0] & 0x01) << 1); } -static const snd_kcontrol_new_t snd_ac97_cm9739_controls_spdif[] = { +static const struct snd_kcontrol_new snd_ac97_cm9739_controls_spdif[] = { /* BIT 0: SPDI_EN - always true */ { /* BIT 1: SPDIFS */ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -2357,7 +2357,7 @@ static const snd_kcontrol_new_t snd_ac97_cm9739_controls_spdif[] = { /* BIT 8: SPD32 - 32bit SPDIF - not supported yet */ }; -static void cm9739_update_jacks(ac97_t *ac97) +static void cm9739_update_jacks(struct snd_ac97 *ac97) { /* shared Line-In */ snd_ac97_update_bits(ac97, AC97_CM9739_MULTI_CHAN, 1 << 10, @@ -2367,17 +2367,17 @@ static void cm9739_update_jacks(ac97_t *ac97) is_shared_micin(ac97) ? 0x1000 : 0x2000); } -static const snd_kcontrol_new_t snd_ac97_cm9739_controls[] = { +static const struct snd_kcontrol_new snd_ac97_cm9739_controls[] = { AC97_SURROUND_JACK_MODE_CTL, AC97_CHANNEL_MODE_CTL, }; -static int patch_cm9739_specific(ac97_t * ac97) +static int patch_cm9739_specific(struct snd_ac97 * ac97) { return patch_build_controls(ac97, snd_ac97_cm9739_controls, ARRAY_SIZE(snd_ac97_cm9739_controls)); } -static int patch_cm9739_post_spdif(ac97_t * ac97) +static int patch_cm9739_post_spdif(struct snd_ac97 * ac97) { return patch_build_controls(ac97, snd_ac97_cm9739_controls_spdif, ARRAY_SIZE(snd_ac97_cm9739_controls_spdif)); } @@ -2388,7 +2388,7 @@ static struct snd_ac97_build_ops patch_cm9739_ops = { .update_jacks = cm9739_update_jacks }; -int patch_cm9739(ac97_t * ac97) +int patch_cm9739(struct snd_ac97 * ac97) { unsigned short val; @@ -2447,7 +2447,7 @@ int patch_cm9739(ac97_t * ac97) #define AC97_CM9761_FUNC 0x66 #define AC97_CM9761_SPDIF_CTRL 0x6c -static void cm9761_update_jacks(ac97_t *ac97) +static void cm9761_update_jacks(struct snd_ac97 *ac97) { /* FIXME: check the bits for each model * model 83 is confirmed to work @@ -2482,12 +2482,12 @@ static void cm9761_update_jacks(ac97_t *ac97) snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val); } -static const snd_kcontrol_new_t snd_ac97_cm9761_controls[] = { +static const struct snd_kcontrol_new snd_ac97_cm9761_controls[] = { AC97_SURROUND_JACK_MODE_CTL, AC97_CHANNEL_MODE_CTL, }; -static int cm9761_spdif_out_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int cm9761_spdif_out_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "AC-Link", "ADC", "SPDIF-In" }; @@ -2500,9 +2500,9 @@ static int cm9761_spdif_out_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int cm9761_spdif_out_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int cm9761_spdif_out_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); if (ac97->regs[AC97_CM9761_FUNC] & 0x1) ucontrol->value.enumerated.item[0] = 2; /* SPDIF-loopback */ @@ -2513,9 +2513,9 @@ static int cm9761_spdif_out_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return 0; } -static int cm9761_spdif_out_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int cm9761_spdif_out_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ac97_t *ac97 = snd_kcontrol_chip(kcontrol); + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); if (ucontrol->value.enumerated.item[0] == 2) return snd_ac97_update_bits(ac97, AC97_CM9761_FUNC, 0x1, 0x1); @@ -2528,7 +2528,7 @@ static const char *cm9761_dac_clock[] = { "AC-Link", "SPDIF-In", "Both" }; static const struct ac97_enum cm9761_dac_clock_enum = AC97_ENUM_SINGLE(AC97_CM9761_SPDIF_CTRL, 9, 3, cm9761_dac_clock); -static const snd_kcontrol_new_t snd_ac97_cm9761_controls_spdif[] = { +static const struct snd_kcontrol_new snd_ac97_cm9761_controls_spdif[] = { { /* BIT 1: SPDIFS */ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", @@ -2546,12 +2546,12 @@ static const snd_kcontrol_new_t snd_ac97_cm9761_controls_spdif[] = { AC97_ENUM("DAC Clock Source", cm9761_dac_clock_enum), }; -static int patch_cm9761_post_spdif(ac97_t * ac97) +static int patch_cm9761_post_spdif(struct snd_ac97 * ac97) { return patch_build_controls(ac97, snd_ac97_cm9761_controls_spdif, ARRAY_SIZE(snd_ac97_cm9761_controls_spdif)); } -static int patch_cm9761_specific(ac97_t * ac97) +static int patch_cm9761_specific(struct snd_ac97 * ac97) { return patch_build_controls(ac97, snd_ac97_cm9761_controls, ARRAY_SIZE(snd_ac97_cm9761_controls)); } @@ -2562,7 +2562,7 @@ static struct snd_ac97_build_ops patch_cm9761_ops = { .update_jacks = cm9761_update_jacks }; -int patch_cm9761(ac97_t *ac97) +int patch_cm9761(struct snd_ac97 *ac97) { unsigned short val; @@ -2641,13 +2641,13 @@ int patch_cm9761(ac97_t *ac97) static const char *cm9780_ch_select[] = { "Front", "Side", "Center/LFE", "Rear" }; static const struct ac97_enum cm9780_ch_select_enum = AC97_ENUM_SINGLE(AC97_CM9780_MULTI_CHAN, 6, 4, cm9780_ch_select); -static const snd_kcontrol_new_t cm9780_controls[] = { +static const struct snd_kcontrol_new cm9780_controls[] = { AC97_DOUBLE("Side Playback Switch", AC97_CM9780_SIDE, 15, 7, 1, 1), AC97_DOUBLE("Side Playback Volume", AC97_CM9780_SIDE, 8, 0, 31, 0), AC97_ENUM("Side Playback Route", cm9780_ch_select_enum), }; -static int patch_cm9780_specific(ac97_t *ac97) +static int patch_cm9780_specific(struct snd_ac97 *ac97) { return patch_build_controls(ac97, cm9780_controls, ARRAY_SIZE(cm9780_controls)); } @@ -2657,7 +2657,7 @@ static struct snd_ac97_build_ops patch_cm9780_ops = { .build_post_spdif = patch_cm9761_post_spdif /* identical with CM9761 */ }; -int patch_cm9780(ac97_t *ac97) +int patch_cm9780(struct snd_ac97 *ac97) { unsigned short val; @@ -2677,14 +2677,14 @@ int patch_cm9780(ac97_t *ac97) /* * VIA VT1616 codec */ -static const snd_kcontrol_new_t snd_ac97_controls_vt1616[] = { +static const struct snd_kcontrol_new snd_ac97_controls_vt1616[] = { AC97_SINGLE("DC Offset removal", 0x5a, 10, 1, 0), AC97_SINGLE("Alternate Level to Surround Out", 0x5a, 15, 1, 0), AC97_SINGLE("Downmix LFE and Center to Front", 0x5a, 12, 1, 0), AC97_SINGLE("Downmix Surround to Front", 0x5a, 11, 1, 0), }; -static int patch_vt1616_specific(ac97_t * ac97) +static int patch_vt1616_specific(struct snd_ac97 * ac97) { int err; @@ -2700,7 +2700,7 @@ static struct snd_ac97_build_ops patch_vt1616_ops = { .build_specific = patch_vt1616_specific }; -int patch_vt1616(ac97_t * ac97) +int patch_vt1616(struct snd_ac97 * ac97) { ac97->build_ops = &patch_vt1616_ops; return 0; @@ -2709,7 +2709,7 @@ int patch_vt1616(ac97_t * ac97) /* * VT1617A codec */ -int patch_vt1617a(ac97_t * ac97) +int patch_vt1617a(struct snd_ac97 * ac97) { ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; @@ -2718,7 +2718,7 @@ int patch_vt1617a(ac97_t * ac97) /* */ -static void it2646_update_jacks(ac97_t *ac97) +static void it2646_update_jacks(struct snd_ac97 *ac97) { /* shared Line-In */ snd_ac97_update_bits(ac97, 0x76, 1 << 9, @@ -2728,18 +2728,18 @@ static void it2646_update_jacks(ac97_t *ac97) is_shared_micin(ac97) ? (1<<10) : 0); } -static const snd_kcontrol_new_t snd_ac97_controls_it2646[] = { +static const struct snd_kcontrol_new snd_ac97_controls_it2646[] = { AC97_SURROUND_JACK_MODE_CTL, AC97_CHANNEL_MODE_CTL, }; -static const snd_kcontrol_new_t snd_ac97_spdif_controls_it2646[] = { +static const struct snd_kcontrol_new snd_ac97_spdif_controls_it2646[] = { AC97_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0x76, 11, 1, 0), AC97_SINGLE("Analog to IEC958 Output", 0x76, 12, 1, 0), AC97_SINGLE("IEC958 Input Monitor", 0x76, 13, 1, 0), }; -static int patch_it2646_specific(ac97_t * ac97) +static int patch_it2646_specific(struct snd_ac97 * ac97) { int err; if ((err = patch_build_controls(ac97, snd_ac97_controls_it2646, ARRAY_SIZE(snd_ac97_controls_it2646))) < 0) @@ -2754,7 +2754,7 @@ static struct snd_ac97_build_ops patch_it2646_ops = { .update_jacks = it2646_update_jacks }; -int patch_it2646(ac97_t * ac97) +int patch_it2646(struct snd_ac97 * ac97) { ac97->build_ops = &patch_it2646_ops; /* full DAC volume */ @@ -2770,11 +2770,11 @@ int patch_it2646(ac97_t * ac97) #define AC97_SI3036_CHIP_ID 0x5a #define AC97_SI3036_LINE_CFG 0x5c -static const snd_kcontrol_new_t snd_ac97_controls_si3036[] = { +static const struct snd_kcontrol_new snd_ac97_controls_si3036[] = { AC97_DOUBLE("Modem Speaker Volume", 0x5c, 14, 12, 3, 1) }; -static int patch_si3036_specific(ac97_t * ac97) +static int patch_si3036_specific(struct snd_ac97 * ac97) { int idx, err; for (idx = 0; idx < ARRAY_SIZE(snd_ac97_controls_si3036); idx++) @@ -2787,7 +2787,7 @@ static struct snd_ac97_build_ops patch_si3036_ops = { .build_specific = patch_si3036_specific, }; -int mpatch_si3036(ac97_t * ac97) +int mpatch_si3036(struct snd_ac97 * ac97) { ac97->build_ops = &patch_si3036_ops; snd_ac97_write_cache(ac97, 0x5c, 0xf210 ); diff --git a/sound/pci/ac97/ac97_patch.h b/sound/pci/ac97/ac97_patch.h index ec18113..5060cb6 100644 --- a/sound/pci/ac97/ac97_patch.h +++ b/sound/pci/ac97/ac97_patch.h @@ -22,40 +22,40 @@ * */ -int patch_yamaha_ymf753(ac97_t * ac97); -int patch_wolfson00(ac97_t * ac97); -int patch_wolfson03(ac97_t * ac97); -int patch_wolfson04(ac97_t * ac97); -int patch_wolfson05(ac97_t * ac97); -int patch_wolfson11(ac97_t * ac97); -int patch_wolfson13(ac97_t * ac97); -int patch_tritech_tr28028(ac97_t * ac97); -int patch_sigmatel_stac9700(ac97_t * ac97); -int patch_sigmatel_stac9708(ac97_t * ac97); -int patch_sigmatel_stac9721(ac97_t * ac97); -int patch_sigmatel_stac9744(ac97_t * ac97); -int patch_sigmatel_stac9756(ac97_t * ac97); -int patch_sigmatel_stac9758(ac97_t * ac97); -int patch_cirrus_cs4299(ac97_t * ac97); -int patch_cirrus_spdif(ac97_t * ac97); -int patch_conexant(ac97_t * ac97); -int patch_ad1819(ac97_t * ac97); -int patch_ad1881(ac97_t * ac97); -int patch_ad1885(ac97_t * ac97); -int patch_ad1886(ac97_t * ac97); -int patch_ad1888(ac97_t * ac97); -int patch_ad1980(ac97_t * ac97); -int patch_ad1981a(ac97_t * ac97); -int patch_ad1981b(ac97_t * ac97); -int patch_ad1985(ac97_t * ac97); -int patch_alc650(ac97_t * ac97); -int patch_alc655(ac97_t * ac97); -int patch_alc850(ac97_t * ac97); -int patch_cm9738(ac97_t * ac97); -int patch_cm9739(ac97_t * ac97); -int patch_cm9761(ac97_t * ac97); -int patch_cm9780(ac97_t * ac97); -int patch_vt1616(ac97_t * ac97); -int patch_vt1617a(ac97_t * ac97); -int patch_it2646(ac97_t * ac97); -int mpatch_si3036(ac97_t * ac97); +int patch_yamaha_ymf753(struct snd_ac97 * ac97); +int patch_wolfson00(struct snd_ac97 * ac97); +int patch_wolfson03(struct snd_ac97 * ac97); +int patch_wolfson04(struct snd_ac97 * ac97); +int patch_wolfson05(struct snd_ac97 * ac97); +int patch_wolfson11(struct snd_ac97 * ac97); +int patch_wolfson13(struct snd_ac97 * ac97); +int patch_tritech_tr28028(struct snd_ac97 * ac97); +int patch_sigmatel_stac9700(struct snd_ac97 * ac97); +int patch_sigmatel_stac9708(struct snd_ac97 * ac97); +int patch_sigmatel_stac9721(struct snd_ac97 * ac97); +int patch_sigmatel_stac9744(struct snd_ac97 * ac97); +int patch_sigmatel_stac9756(struct snd_ac97 * ac97); +int patch_sigmatel_stac9758(struct snd_ac97 * ac97); +int patch_cirrus_cs4299(struct snd_ac97 * ac97); +int patch_cirrus_spdif(struct snd_ac97 * ac97); +int patch_conexant(struct snd_ac97 * ac97); +int patch_ad1819(struct snd_ac97 * ac97); +int patch_ad1881(struct snd_ac97 * ac97); +int patch_ad1885(struct snd_ac97 * ac97); +int patch_ad1886(struct snd_ac97 * ac97); +int patch_ad1888(struct snd_ac97 * ac97); +int patch_ad1980(struct snd_ac97 * ac97); +int patch_ad1981a(struct snd_ac97 * ac97); +int patch_ad1981b(struct snd_ac97 * ac97); +int patch_ad1985(struct snd_ac97 * ac97); +int patch_alc650(struct snd_ac97 * ac97); +int patch_alc655(struct snd_ac97 * ac97); +int patch_alc850(struct snd_ac97 * ac97); +int patch_cm9738(struct snd_ac97 * ac97); +int patch_cm9739(struct snd_ac97 * ac97); +int patch_cm9761(struct snd_ac97 * ac97); +int patch_cm9780(struct snd_ac97 * ac97); +int patch_vt1616(struct snd_ac97 * ac97); +int patch_vt1617a(struct snd_ac97 * ac97); +int patch_it2646(struct snd_ac97 * ac97); +int mpatch_si3036(struct snd_ac97 * ac97); diff --git a/sound/pci/ac97/ac97_pcm.c b/sound/pci/ac97/ac97_pcm.c index ded1316..c3e590b 100644 --- a/sound/pci/ac97/ac97_pcm.c +++ b/sound/pci/ac97/ac97_pcm.c @@ -170,7 +170,7 @@ static unsigned char get_slot_reg(struct ac97_pcm *pcm, unsigned short cidx, return rate_cregs[slot - 3]; } -static int set_spdif_rate(ac97_t *ac97, unsigned short rate) +static int set_spdif_rate(struct snd_ac97 *ac97, unsigned short rate) { unsigned short old, bits, reg, mask; unsigned int sbits; @@ -254,7 +254,7 @@ static int set_spdif_rate(ac97_t *ac97, unsigned short rate) * * Returns zero if successful, or a negative error code on failure. */ -int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned int rate) +int snd_ac97_set_rate(struct snd_ac97 *ac97, int reg, unsigned int rate) { int dbl; unsigned int tmp; @@ -315,7 +315,7 @@ int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned int rate) return 0; } -static unsigned short get_pslots(ac97_t *ac97, unsigned char *rate_table, unsigned short *spdif_slots) +static unsigned short get_pslots(struct snd_ac97 *ac97, unsigned char *rate_table, unsigned short *spdif_slots) { if (!ac97_is_audio(ac97)) return 0; @@ -390,7 +390,7 @@ static unsigned short get_pslots(ac97_t *ac97, unsigned char *rate_table, unsign } } -static unsigned short get_cslots(ac97_t *ac97) +static unsigned short get_cslots(struct snd_ac97 *ac97) { unsigned short slots; @@ -437,7 +437,7 @@ static unsigned int get_rates(struct ac97_pcm *pcm, unsigned int cidx, unsigned * some slots are available, pcm->xxx.slots and pcm->xxx.rslots[] members * are reduced and might be zero. */ -int snd_ac97_pcm_assign(ac97_bus_t *bus, +int snd_ac97_pcm_assign(struct snd_ac97_bus *bus, unsigned short pcms_count, const struct ac97_pcm *pcms) { @@ -449,7 +449,7 @@ int snd_ac97_pcm_assign(ac97_bus_t *bus, unsigned short tmp, slots; unsigned short spdif_slots[4]; unsigned int rates; - ac97_t *codec; + struct snd_ac97 *codec; rpcms = kcalloc(pcms_count, sizeof(struct ac97_pcm), GFP_KERNEL); if (rpcms == NULL) @@ -560,7 +560,7 @@ int snd_ac97_pcm_assign(ac97_bus_t *bus, int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate, enum ac97_pcm_cfg cfg, unsigned short slots) { - ac97_bus_t *bus; + struct snd_ac97_bus *bus; int i, cidx, r, ok_flag; unsigned int reg_ok[4] = {0,0,0,0}; unsigned char reg; @@ -639,7 +639,7 @@ int snd_ac97_pcm_open(struct ac97_pcm *pcm, unsigned int rate, */ int snd_ac97_pcm_close(struct ac97_pcm *pcm) { - ac97_bus_t *bus; + struct snd_ac97_bus *bus; unsigned short slots = pcm->aslots; int i, cidx; @@ -656,31 +656,31 @@ int snd_ac97_pcm_close(struct ac97_pcm *pcm) return 0; } -static int double_rate_hw_constraint_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int double_rate_hw_constraint_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (channels->min > 2) { - static const snd_interval_t single_rates = { + static const struct snd_interval single_rates = { .min = 1, .max = 48000, }; - snd_interval_t *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); return snd_interval_refine(rate, &single_rates); } return 0; } -static int double_rate_hw_constraint_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int double_rate_hw_constraint_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (rate->min > 48000) { - static const snd_interval_t double_rate_channels = { + static const struct snd_interval double_rate_channels = { .min = 2, .max = 2, }; - snd_interval_t *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); return snd_interval_refine(channels, &double_rate_channels); } return 0; @@ -693,7 +693,7 @@ static int double_rate_hw_constraint_channels(snd_pcm_hw_params_t *params, * Installs the hardware constraint rules to prevent using double rates and * more than two channels at the same time. */ -int snd_ac97_pcm_double_rate_rules(snd_pcm_runtime_t *runtime) +int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime) { int err; diff --git a/sound/pci/ac97/ac97_proc.c b/sound/pci/ac97/ac97_proc.c index f4333b8..2660732 100644 --- a/sound/pci/ac97/ac97_proc.c +++ b/sound/pci/ac97/ac97_proc.c @@ -34,7 +34,7 @@ * proc interface */ -static void snd_ac97_proc_read_functions(ac97_t *ac97, snd_info_buffer_t *buffer) +static void snd_ac97_proc_read_functions(struct snd_ac97 *ac97, struct snd_info_buffer *buffer) { int header = 0, function; unsigned short info, sense_info; @@ -68,7 +68,7 @@ static void snd_ac97_proc_read_functions(ac97_t *ac97, snd_info_buffer_t *buffer } } -static void snd_ac97_proc_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, int subidx) +static void snd_ac97_proc_read_main(struct snd_ac97 *ac97, struct snd_info_buffer *buffer, int subidx) { char name[64]; unsigned short val, tmp, ext, mext; @@ -80,7 +80,6 @@ static void snd_ac97_proc_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, in snd_ac97_get_name(NULL, ac97->id, name, 0); snd_iprintf(buffer, "%d-%d/%d: %s\n\n", ac97->addr, ac97->num, subidx, name); - if ((ac97->scaps & AC97_SCAP_AUDIO) == 0) goto __modem; @@ -299,9 +298,9 @@ static void snd_ac97_proc_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, in } } -static void snd_ac97_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void snd_ac97_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - ac97_t *ac97 = entry->private_data; + struct snd_ac97 *ac97 = entry->private_data; down(&ac97->page_mutex); if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86 @@ -334,9 +333,9 @@ static void snd_ac97_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buff #ifdef CONFIG_SND_DEBUG /* direct register write for debugging */ -static void snd_ac97_proc_regs_write(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_ac97_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - ac97_t *ac97 = entry->private_data; + struct snd_ac97 *ac97 = entry->private_data; char line[64]; unsigned int reg, val; down(&ac97->page_mutex); @@ -351,7 +350,7 @@ static void snd_ac97_proc_regs_write(snd_info_entry_t *entry, snd_info_buffer_t } #endif -static void snd_ac97_proc_regs_read_main(ac97_t *ac97, snd_info_buffer_t * buffer, int subidx) +static void snd_ac97_proc_regs_read_main(struct snd_ac97 *ac97, struct snd_info_buffer *buffer, int subidx) { int reg, val; @@ -361,10 +360,10 @@ static void snd_ac97_proc_regs_read_main(ac97_t *ac97, snd_info_buffer_t * buffe } } -static void snd_ac97_proc_regs_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ac97_proc_regs_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ac97_t *ac97 = entry->private_data; + struct snd_ac97 *ac97 = entry->private_data; down(&ac97->page_mutex); if ((ac97->id & 0xffffff40) == AC97_ID_AD1881) { // Analog Devices AD1881/85/86 @@ -385,9 +384,9 @@ static void snd_ac97_proc_regs_read(snd_info_entry_t *entry, up(&ac97->page_mutex); } -void snd_ac97_proc_init(ac97_t * ac97) +void snd_ac97_proc_init(struct snd_ac97 * ac97) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; char name[32]; const char *prefix; @@ -419,7 +418,7 @@ void snd_ac97_proc_init(ac97_t * ac97) ac97->proc_regs = entry; } -void snd_ac97_proc_done(ac97_t * ac97) +void snd_ac97_proc_done(struct snd_ac97 * ac97) { if (ac97->proc_regs) { snd_info_unregister(ac97->proc_regs); @@ -431,9 +430,9 @@ void snd_ac97_proc_done(ac97_t * ac97) } } -void snd_ac97_bus_proc_init(ac97_bus_t * bus) +void snd_ac97_bus_proc_init(struct snd_ac97_bus * bus) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; char name[32]; sprintf(name, "codec97#%d", bus->num); @@ -447,7 +446,7 @@ void snd_ac97_bus_proc_init(ac97_bus_t * bus) bus->proc = entry; } -void snd_ac97_bus_proc_done(ac97_bus_t * bus) +void snd_ac97_bus_proc_done(struct snd_ac97_bus * bus) { if (bus->proc) { snd_info_unregister(bus->proc); -- cgit v1.1 From 03da312ac080b4f5c9359c233b8812cc93a035fe Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:24:47 +0100 Subject: [ALSA] Remove xxx_t typedefs: Emu-X synth Modules: Common EMU synth,SoundFont,Synth Remove xxx_t typedefs from the Emu-X synth support. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/emux_synth.h | 105 ++++++++--------- include/sound/sfnt_info.h | 36 +++--- include/sound/soundfont.h | 75 ++++++------- include/sound/util_mem.h | 32 +++--- sound/synth/emux/emux.c | 29 ++--- sound/synth/emux/emux_effect.c | 44 ++++---- sound/synth/emux/emux_hwdep.c | 23 ++-- sound/synth/emux/emux_nrpn.c | 30 ++--- sound/synth/emux/emux_oss.c | 90 ++++++++------- sound/synth/emux/emux_proc.c | 14 +-- sound/synth/emux/emux_seq.c | 74 ++++++------ sound/synth/emux/emux_synth.c | 139 ++++++++++++----------- sound/synth/emux/emux_voice.h | 67 ++++++----- sound/synth/emux/soundfont.c | 248 +++++++++++++++++++++++------------------ sound/synth/util_mem.c | 39 +++---- 15 files changed, 550 insertions(+), 495 deletions(-) diff --git a/include/sound/emux_synth.h b/include/sound/emux_synth.h index c6970aa..b2d6b2a 100644 --- a/include/sound/emux_synth.h +++ b/include/sound/emux_synth.h @@ -36,39 +36,40 @@ */ #define SNDRV_EMUX_USE_RAW_EFFECT - -/* - * typedefs - */ -typedef struct snd_emux_effect_table snd_emux_effect_table_t; -typedef struct snd_emux_port snd_emux_port_t; -typedef struct snd_emux_voice snd_emux_voice_t; -typedef struct snd_emux snd_emux_t; - +struct snd_emux; +struct snd_emux_port; +struct snd_emux_voice; +struct snd_emux_effect_table; /* * operators */ -typedef struct snd_emux_operators { +struct snd_emux_operators { struct module *owner; - snd_emux_voice_t *(*get_voice)(snd_emux_t *emu, snd_emux_port_t *port); - int (*prepare)(snd_emux_voice_t *vp); - void (*trigger)(snd_emux_voice_t *vp); - void (*release)(snd_emux_voice_t *vp); - void (*update)(snd_emux_voice_t *vp, int update); - void (*terminate)(snd_emux_voice_t *vp); - void (*free_voice)(snd_emux_voice_t *vp); - void (*reset)(snd_emux_t *emu, int ch); - /* the first parameters are snd_emux_t */ - int (*sample_new)(snd_emux_t *emu, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr, const void __user *data, long count); - int (*sample_free)(snd_emux_t *emu, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr); - void (*sample_reset)(snd_emux_t *emu); - int (*load_fx)(snd_emux_t *emu, int type, int arg, const void __user *data, long count); - void (*sysex)(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *chset); + struct snd_emux_voice *(*get_voice)(struct snd_emux *emu, + struct snd_emux_port *port); + int (*prepare)(struct snd_emux_voice *vp); + void (*trigger)(struct snd_emux_voice *vp); + void (*release)(struct snd_emux_voice *vp); + void (*update)(struct snd_emux_voice *vp, int update); + void (*terminate)(struct snd_emux_voice *vp); + void (*free_voice)(struct snd_emux_voice *vp); + void (*reset)(struct snd_emux *emu, int ch); + /* the first parameters are struct snd_emux */ + int (*sample_new)(struct snd_emux *emu, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *data, long count); + int (*sample_free)(struct snd_emux *emu, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr); + void (*sample_reset)(struct snd_emux *emu); + int (*load_fx)(struct snd_emux *emu, int type, int arg, + const void __user *data, long count); + void (*sysex)(struct snd_emux *emu, char *buf, int len, int parsed, + struct snd_midi_channel_set *chset); #ifdef CONFIG_SND_SEQUENCER_OSS - int (*oss_ioctl)(snd_emux_t *emu, int cmd, int p1, int p2); + int (*oss_ioctl)(struct snd_emux *emu, int cmd, int p1, int p2); #endif -} snd_emux_operators_t; +}; /* @@ -90,46 +91,46 @@ typedef struct snd_emux_operators { */ struct snd_emux { - snd_card_t *card; /* assigned card */ + struct snd_card *card; /* assigned card */ /* following should be initialized before registration */ int max_voices; /* Number of voices */ int mem_size; /* memory size (in byte) */ int num_ports; /* number of ports to be created */ int pitch_shift; /* pitch shift value (for Emu10k1) */ - snd_emux_operators_t ops; /* operators */ + struct snd_emux_operators ops; /* operators */ void *hw; /* hardware */ unsigned long flags; /* other conditions */ int midi_ports; /* number of virtual midi devices */ int midi_devidx; /* device offset of virtual midi */ unsigned int linear_panning: 1; /* panning is linear (sbawe = 1, emu10k1 = 0) */ int hwdep_idx; /* hwdep device index */ - snd_hwdep_t *hwdep; /* hwdep device */ + struct snd_hwdep *hwdep; /* hwdep device */ /* private */ int num_voices; /* current number of voices */ - snd_sf_list_t *sflist; /* root of SoundFont list */ - snd_emux_voice_t *voices; /* Voices (EMU 'channel') */ + struct snd_sf_list *sflist; /* root of SoundFont list */ + struct snd_emux_voice *voices; /* Voices (EMU 'channel') */ int use_time; /* allocation counter */ spinlock_t voice_lock; /* Lock for voice access */ struct semaphore register_mutex; int client; /* For the sequencer client */ int ports[SNDRV_EMUX_MAX_PORTS]; /* The ports for this device */ - snd_emux_port_t *portptrs[SNDRV_EMUX_MAX_PORTS]; + struct snd_emux_port *portptrs[SNDRV_EMUX_MAX_PORTS]; int used; /* use counter */ char *name; /* name of the device (internal) */ - snd_rawmidi_t **vmidi; + struct snd_rawmidi **vmidi; struct timer_list tlist; /* for pending note-offs */ int timer_active; - snd_util_memhdr_t *memhdr; /* memory chunk information */ + struct snd_util_memhdr *memhdr; /* memory chunk information */ #ifdef CONFIG_PROC_FS - snd_info_entry_t *proc; + struct snd_info_entry *proc; #endif #ifdef CONFIG_SND_SEQUENCER_OSS - snd_seq_device_t *oss_synth; + struct snd_seq_device *oss_synth; #endif }; @@ -139,18 +140,18 @@ struct snd_emux { */ struct snd_emux_port { - snd_midi_channel_set_t chset; - snd_emux_t *emu; + struct snd_midi_channel_set chset; + struct snd_emux *emu; char port_mode; /* operation mode */ int volume_atten; /* emuX raw attenuation */ unsigned long drum_flags; /* drum bitmaps */ int ctrls[EMUX_MD_END]; /* control parameters */ #ifdef SNDRV_EMUX_USE_RAW_EFFECT - snd_emux_effect_table_t *effect; + struct snd_emux_effect_table *effect; #endif #ifdef CONFIG_SND_SEQUENCER_OSS - snd_seq_oss_arg_t *oss_arg; + struct snd_seq_oss_arg *oss_arg; #endif }; @@ -179,16 +180,16 @@ struct snd_emux_voice { unsigned char key; unsigned char velocity; /* Velocity of current note */ - snd_sf_zone_t *zone; /* Zone assigned to this note */ + struct snd_sf_zone *zone; /* Zone assigned to this note */ void *block; /* sample block pointer (optional) */ - snd_midi_channel_t *chan; /* Midi channel for this note */ - snd_emux_port_t *port; /* associated port */ - snd_emux_t *emu; /* assigned root info */ - void *hw; /* hardware pointer (emu8000_t or emu10k1_t) */ + struct snd_midi_channel *chan; /* Midi channel for this note */ + struct snd_emux_port *port; /* associated port */ + struct snd_emux *emu; /* assigned root info */ + void *hw; /* hardware pointer (emu8000 or emu10k1) */ unsigned long ontime; /* jiffies at note triggered */ /* Emu8k/Emu10k1 registers */ - soundfont_voice_info_t reg; + struct soundfont_voice_info reg; /* additional registers */ int avol; /* volume attenuation */ @@ -229,15 +230,15 @@ struct snd_emux_effect_table { /* * prototypes - interface to Emu10k1 and Emu8k routines */ -int snd_emux_new(snd_emux_t **remu); -int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name); -int snd_emux_free(snd_emux_t *emu); +int snd_emux_new(struct snd_emux **remu); +int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name); +int snd_emux_free(struct snd_emux *emu); /* * exported functions */ -void snd_emux_terminate_all(snd_emux_t *emu); -void snd_emux_lock_voice(snd_emux_t *emu, int voice); -void snd_emux_unlock_voice(snd_emux_t *emu, int voice); +void snd_emux_terminate_all(struct snd_emux *emu); +void snd_emux_lock_voice(struct snd_emux *emu, int voice); +void snd_emux_unlock_voice(struct snd_emux *emu, int voice); #endif /* __SOUND_EMUX_SYNTH_H */ diff --git a/include/sound/sfnt_info.h b/include/sound/sfnt_info.h index 674585f..5d1ab9c 100644 --- a/include/sound/sfnt_info.h +++ b/include/sound/sfnt_info.h @@ -35,7 +35,7 @@ #endif /* patch interface header: 16 bytes */ -typedef struct soundfont_patch_info_t { +struct soundfont_patch_info { unsigned short key; /* use the key below */ #define SNDRV_OSS_SOUNDFONT_PATCH SNDRV_OSS_PATCHKEY(0x07) @@ -59,7 +59,7 @@ typedef struct soundfont_patch_info_t { short reserved; /* word alignment data */ /* the actual patch data begins after this */ -} soundfont_patch_info_t; +}; /* @@ -68,7 +68,7 @@ typedef struct soundfont_patch_info_t { #define SNDRV_SFNT_PATCH_NAME_LEN 32 -typedef struct soundfont_open_parm_t { +struct soundfont_open_parm { unsigned short type; /* sample type */ #define SNDRV_SFNT_PAT_TYPE_MISC 0 #define SNDRV_SFNT_PAT_TYPE_GUS 6 @@ -78,7 +78,7 @@ typedef struct soundfont_open_parm_t { short reserved; char name[SNDRV_SFNT_PATCH_NAME_LEN]; -} soundfont_open_parm_t; +}; /* @@ -86,7 +86,7 @@ typedef struct soundfont_open_parm_t { */ /* wave table envelope & effect parameters to control EMU8000 */ -typedef struct soundfont_voice_parm_t { +struct soundfont_voice_parm { unsigned short moddelay; /* modulation delay (0x8000) */ unsigned short modatkhld; /* modulation attack & hold time (0x7f7f) */ unsigned short moddcysus; /* modulation decay & sustain (0x7f7f) */ @@ -108,11 +108,11 @@ typedef struct soundfont_voice_parm_t { unsigned char chorus; /* chorus send (0x00) */ unsigned char reverb; /* reverb send (0x00) */ unsigned short reserved[4]; /* not used */ -} soundfont_voice_parm_t; +}; /* wave table parameters: 92 bytes */ -typedef struct soundfont_voice_info_t { +struct soundfont_voice_info { unsigned short sf_id; /* file id (should be zero) */ unsigned short sample; /* sample id */ int start, end; /* sample offset correction */ @@ -135,13 +135,13 @@ typedef struct soundfont_voice_info_t { unsigned char amplitude; /* sample volume (127 max) */ unsigned char attenuation; /* attenuation (0.375dB) */ short scaleTuning; /* pitch scale tuning(%), normally 100 */ - soundfont_voice_parm_t parm; /* voice envelope parameters */ + struct soundfont_voice_parm parm; /* voice envelope parameters */ unsigned short sample_mode; /* sample mode_flag (set by driver) */ -} soundfont_voice_info_t; +}; /* instrument info header: 4 bytes */ -typedef struct soundfont_voice_rec_hdr_t { +struct soundfont_voice_rec_hdr { unsigned char bank; /* midi bank number */ unsigned char instr; /* midi preset number */ char nvoices; /* number of voices */ @@ -149,7 +149,7 @@ typedef struct soundfont_voice_rec_hdr_t { #define SNDRV_SFNT_WR_APPEND 0 /* append anyway */ #define SNDRV_SFNT_WR_EXCLUSIVE 1 /* skip if already exists */ #define SNDRV_SFNT_WR_REPLACE 2 /* replace if already exists */ -} soundfont_voice_rec_hdr_t; +}; /* @@ -157,7 +157,7 @@ typedef struct soundfont_voice_rec_hdr_t { */ /* wave table sample header: 32 bytes */ -typedef struct soundfont_sample_info_t { +struct soundfont_sample_info { unsigned short sf_id; /* file id (should be zero) */ unsigned short sample; /* sample id */ int start, end; /* start & end offset */ @@ -174,17 +174,17 @@ typedef struct soundfont_sample_info_t { #define SNDRV_SFNT_SAMPLE_STEREO_RIGHT 64 /* stereo right sound */ #define SNDRV_SFNT_SAMPLE_REVERSE_LOOP 128 /* reverse looping */ unsigned int truesize; /* used memory size (set by driver) */ -} soundfont_sample_info_t; +}; /* * voice preset mapping (aliasing) */ -typedef struct soundfont_voice_map_t { +struct soundfont_voice_map { int map_bank, map_instr, map_key; /* key = -1 means all keys */ int src_bank, src_instr, src_key; -} soundfont_voice_map_t; +}; /* @@ -195,7 +195,7 @@ typedef struct soundfont_voice_map_t { #define SNDRV_EMUX_VERSION ((1 << 16) | (0 << 8) | 0) /* 1.0.0 */ -struct sndrv_emux_misc_mode { +struct snd_emux_misc_mode { int port; /* -1 = all */ int mode; int value; @@ -204,11 +204,11 @@ struct sndrv_emux_misc_mode { enum { SNDRV_EMUX_IOCTL_VERSION = _IOR('H', 0x80, unsigned int), - SNDRV_EMUX_IOCTL_LOAD_PATCH = _IOWR('H', 0x81, soundfont_patch_info_t), + SNDRV_EMUX_IOCTL_LOAD_PATCH = _IOWR('H', 0x81, struct soundfont_patch_info), SNDRV_EMUX_IOCTL_RESET_SAMPLES = _IO('H', 0x82), SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES = _IO('H', 0x83), SNDRV_EMUX_IOCTL_MEM_AVAIL = _IOW('H', 0x84, int), - SNDRV_EMUX_IOCTL_MISC_MODE = _IOWR('H', 0x84, struct sndrv_emux_misc_mode), + SNDRV_EMUX_IOCTL_MISC_MODE = _IOWR('H', 0x84, struct snd_emux_misc_mode), }; #endif /* __SOUND_SFNT_INFO_H */ diff --git a/include/sound/soundfont.h b/include/sound/soundfont.h index c992958..61a010c 100644 --- a/include/sound/soundfont.h +++ b/include/sound/soundfont.h @@ -29,94 +29,93 @@ #define SF_MAX_PRESETS 256 /* drums are mapped from 128 to 256 */ #define SF_IS_DRUM_BANK(z) ((z) == 128) -typedef struct snd_sf_zone { +struct snd_sf_zone { struct snd_sf_zone *next; /* Link to next */ unsigned char bank; /* Midi bank for this zone */ unsigned char instr; /* Midi program for this zone */ unsigned char mapped; /* True if mapped to something else */ - soundfont_voice_info_t v; /* All the soundfont parameters */ + struct soundfont_voice_info v; /* All the soundfont parameters */ int counter; struct snd_sf_sample *sample; /* Link to sample */ /* The following deals with preset numbers (programs) */ struct snd_sf_zone *next_instr; /* Next zone of this instrument */ struct snd_sf_zone *next_zone; /* Next zone in play list */ -} snd_sf_zone_t; +}; -typedef struct snd_sf_sample { - soundfont_sample_info_t v; +struct snd_sf_sample { + struct soundfont_sample_info v; int counter; - snd_util_memblk_t *block; /* allocated data block */ + struct snd_util_memblk *block; /* allocated data block */ struct snd_sf_sample *next; -} snd_sf_sample_t; +}; /* * This represents all the information relating to a soundfont. */ -typedef struct snd_soundfont { +struct snd_soundfont { struct snd_soundfont *next; /* Link to next */ /*struct snd_soundfont *prev;*/ /* Link to previous */ short id; /* file id */ short type; /* font type */ unsigned char name[SNDRV_SFNT_PATCH_NAME_LEN]; /* identifier */ - snd_sf_zone_t *zones; /* Font information */ - snd_sf_sample_t *samples; /* The sample headers */ -} snd_soundfont_t; + struct snd_sf_zone *zones; /* Font information */ + struct snd_sf_sample *samples; /* The sample headers */ +}; /* * Type of the sample access callback */ -typedef int (*snd_sf_sample_new_t)(void *private_data, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr, const void __user *buf, long count); -typedef int (*snd_sf_sample_free_t)(void *private_data, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr); -typedef void (*snd_sf_sample_reset_t)(void *private); - -typedef struct snd_sf_callback { +struct snd_sf_callback { void *private_data; - snd_sf_sample_new_t sample_new; - snd_sf_sample_free_t sample_free; - snd_sf_sample_reset_t sample_reset; -} snd_sf_callback_t; + int (*sample_new)(void *private_data, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *buf, long count); + int (*sample_free)(void *private_data, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr); + void (*sample_reset)(void *private); +}; /* * List of soundfonts. */ -typedef struct snd_sf_list { - snd_soundfont_t *currsf; /* The currently open soundfont */ +struct snd_sf_list { + struct snd_soundfont *currsf; /* The currently open soundfont */ int open_client; /* client pointer for lock */ int mem_used; /* used memory size */ - snd_sf_zone_t *presets[SF_MAX_PRESETS]; - snd_soundfont_t *fonts; /* The list of soundfonts */ + struct snd_sf_zone *presets[SF_MAX_PRESETS]; + struct snd_soundfont *fonts; /* The list of soundfonts */ int fonts_size; /* number of fonts allocated */ int zone_counter; /* last allocated time for zone */ int sample_counter; /* last allocated time for sample */ int zone_locked; /* locked time for zone */ int sample_locked; /* locked time for sample */ - snd_sf_callback_t callback; /* callback functions */ + struct snd_sf_callback callback; /* callback functions */ int presets_locked; struct semaphore presets_mutex; spinlock_t lock; - snd_util_memhdr_t *memhdr; -} snd_sf_list_t; + struct snd_util_memhdr *memhdr; +}; /* Prototypes for soundfont.c */ -int snd_soundfont_load(snd_sf_list_t *sflist, const void __user *data, long count, int client); -int snd_soundfont_load_guspatch(snd_sf_list_t *sflist, const char __user *data, +int snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data, + long count, int client); +int snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count, int client); -int snd_soundfont_close_check(snd_sf_list_t *sflist, int client); +int snd_soundfont_close_check(struct snd_sf_list *sflist, int client); -snd_sf_list_t *snd_sf_new(snd_sf_callback_t *callback, snd_util_memhdr_t *hdr); -void snd_sf_free(snd_sf_list_t *sflist); +struct snd_sf_list *snd_sf_new(struct snd_sf_callback *callback, + struct snd_util_memhdr *hdr); +void snd_sf_free(struct snd_sf_list *sflist); -int snd_soundfont_remove_samples(snd_sf_list_t *sflist); -int snd_soundfont_remove_unlocked(snd_sf_list_t *sflist); +int snd_soundfont_remove_samples(struct snd_sf_list *sflist); +int snd_soundfont_remove_unlocked(struct snd_sf_list *sflist); -int snd_soundfont_search_zone(snd_sf_list_t *sflist, int *notep, int vel, +int snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel, int preset, int bank, int def_preset, int def_bank, - snd_sf_zone_t **table, int max_layers); + struct snd_sf_zone **table, int max_layers); /* Parameter conversions */ int snd_sf_calc_parm_hold(int msec); diff --git a/include/sound/util_mem.h b/include/sound/util_mem.h index 9d2cdfa..69944bbb 100644 --- a/include/sound/util_mem.h +++ b/include/sound/util_mem.h @@ -20,29 +20,25 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -typedef struct snd_util_memblk snd_util_memblk_t; -typedef struct snd_util_memhdr snd_util_memhdr_t; -typedef unsigned int snd_util_unit_t; - /* * memory block */ struct snd_util_memblk { - snd_util_unit_t size; /* size of this block */ - snd_util_unit_t offset; /* zero-offset of this block */ + unsigned int size; /* size of this block */ + unsigned int offset; /* zero-offset of this block */ struct list_head list; /* link */ }; -#define snd_util_memblk_argptr(blk) (void*)((char*)(blk) + sizeof(snd_util_memblk_t)) +#define snd_util_memblk_argptr(blk) (void*)((char*)(blk) + sizeof(struct snd_util_memblk)) /* * memory management information */ struct snd_util_memhdr { - snd_util_unit_t size; /* size of whole data */ + unsigned int size; /* size of whole data */ struct list_head block; /* block linked-list header */ int nblocks; /* # of allocated blocks */ - snd_util_unit_t used; /* used memory size */ + unsigned int used; /* used memory size */ int block_extra_size; /* extra data size of chunk */ struct semaphore block_mutex; /* lock */ }; @@ -50,15 +46,17 @@ struct snd_util_memhdr { /* * prototypes */ -snd_util_memhdr_t *snd_util_memhdr_new(int memsize); -void snd_util_memhdr_free(snd_util_memhdr_t *hdr); -snd_util_memblk_t *snd_util_mem_alloc(snd_util_memhdr_t *hdr, int size); -int snd_util_mem_free(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk); -int snd_util_mem_avail(snd_util_memhdr_t *hdr); +struct snd_util_memhdr *snd_util_memhdr_new(int memsize); +void snd_util_memhdr_free(struct snd_util_memhdr *hdr); +struct snd_util_memblk *snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size); +int snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk); +int snd_util_mem_avail(struct snd_util_memhdr *hdr); /* functions without mutex */ -snd_util_memblk_t *__snd_util_mem_alloc(snd_util_memhdr_t *hdr, int size); -void __snd_util_mem_free(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk); -snd_util_memblk_t *__snd_util_memblk_new(snd_util_memhdr_t *hdr, snd_util_unit_t units, struct list_head *prev); +struct snd_util_memblk *__snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size); +void __snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk); +struct snd_util_memblk *__snd_util_memblk_new(struct snd_util_memhdr *hdr, + unsigned int units, + struct list_head *prev); #endif /* __SOUND_UTIL_MEM_H */ diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c index 2aacd8a..7c8e328 100644 --- a/sound/synth/emux/emux.c +++ b/sound/synth/emux/emux.c @@ -35,9 +35,9 @@ MODULE_LICENSE("GPL"); /* * create a new hardware dependent device for Emu8000/Emu10k1 */ -int snd_emux_new(snd_emux_t **remu) +int snd_emux_new(struct snd_emux **remu) { - snd_emux_t *emu; + struct snd_emux *emu; *remu = NULL; emu = kzalloc(sizeof(*emu), GFP_KERNEL); @@ -66,33 +66,33 @@ int snd_emux_new(snd_emux_t **remu) /* */ -static int sf_sample_new(void *private_data, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr, - const void __user *buf, long count) +static int sf_sample_new(void *private_data, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *buf, long count) { - snd_emux_t *emu = private_data; + struct snd_emux *emu = private_data; return emu->ops.sample_new(emu, sp, hdr, buf, count); } -static int sf_sample_free(void *private_data, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr) +static int sf_sample_free(void *private_data, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr) { - snd_emux_t *emu = private_data; + struct snd_emux *emu = private_data; return emu->ops.sample_free(emu, sp, hdr); } static void sf_sample_reset(void *private_data) { - snd_emux_t *emu = private_data; + struct snd_emux *emu = private_data; emu->ops.sample_reset(emu); } -int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name) +int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, char *name) { int err; - snd_sf_callback_t sf_cb; + struct snd_sf_callback sf_cb; snd_assert(emu->hw != NULL, return -EINVAL); snd_assert(emu->max_voices > 0, return -EINVAL); @@ -101,7 +101,8 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name) emu->card = card; emu->name = kstrdup(name, GFP_KERNEL); - emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL); + emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice), + GFP_KERNEL); if (emu->voices == NULL) return -ENOMEM; @@ -138,7 +139,7 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name) /* */ -int snd_emux_free(snd_emux_t *emu) +int snd_emux_free(struct snd_emux *emu) { unsigned long flags; diff --git a/sound/synth/emux/emux_effect.c b/sound/synth/emux/emux_effect.c index 4764940..a447218 100644 --- a/sound/synth/emux/emux_effect.c +++ b/sound/synth/emux/emux_effect.c @@ -32,7 +32,7 @@ #define xoffsetof(type,tag) ((long)(&((type)NULL)->tag) - (long)(NULL)) -#define parm_offset(tag) xoffsetof(soundfont_voice_parm_t*, tag) +#define parm_offset(tag) xoffsetof(struct soundfont_voice_parm *, tag) #define PARM_IS_BYTE (1 << 0) #define PARM_IS_WORD (1 << 1) @@ -97,10 +97,10 @@ static struct emux_parm_defs { /* set byte effect value */ static void -effect_set_byte(unsigned char *valp, snd_midi_channel_t *chan, int type) +effect_set_byte(unsigned char *valp, struct snd_midi_channel *chan, int type) { short effect; - snd_emux_effect_table_t *fx = chan->private; + struct snd_emux_effect_table *fx = chan->private; effect = fx->val[type]; if (fx->flag[type] == EMUX_FX_FLAG_ADD) { @@ -118,10 +118,10 @@ effect_set_byte(unsigned char *valp, snd_midi_channel_t *chan, int type) /* set word effect value */ static void -effect_set_word(unsigned short *valp, snd_midi_channel_t *chan, int type) +effect_set_word(unsigned short *valp, struct snd_midi_channel *chan, int type) { int effect; - snd_emux_effect_table_t *fx = chan->private; + struct snd_emux_effect_table *fx = chan->private; effect = *(unsigned short*)&fx->val[type]; if (fx->flag[type] == EMUX_FX_FLAG_ADD) @@ -135,10 +135,10 @@ effect_set_word(unsigned short *valp, snd_midi_channel_t *chan, int type) /* address offset */ static int -effect_get_offset(snd_midi_channel_t *chan, int lo, int hi, int mode) +effect_get_offset(struct snd_midi_channel *chan, int lo, int hi, int mode) { int addr = 0; - snd_emux_effect_table_t *fx = chan->private; + struct snd_emux_effect_table *fx = chan->private; if (fx->flag[hi]) addr = (short)fx->val[hi]; @@ -153,7 +153,8 @@ effect_get_offset(snd_midi_channel_t *chan, int lo, int hi, int mode) #ifdef CONFIG_SND_SEQUENCER_OSS /* change effects - for OSS sequencer compatibility */ void -snd_emux_send_effect_oss(snd_emux_port_t *port, snd_midi_channel_t *chan, int type, int val) +snd_emux_send_effect_oss(struct snd_emux_port *port, + struct snd_midi_channel *chan, int type, int val) { int mode; @@ -173,13 +174,14 @@ snd_emux_send_effect_oss(snd_emux_port_t *port, snd_midi_channel_t *chan, int ty * if update is necessary, call emu8000_control */ void -snd_emux_send_effect(snd_emux_port_t *port, snd_midi_channel_t *chan, int type, int val, int mode) +snd_emux_send_effect(struct snd_emux_port *port, struct snd_midi_channel *chan, + int type, int val, int mode) { int i; int offset; unsigned char *srcp, *origp; - snd_emux_t *emu; - snd_emux_effect_table_t *fx; + struct snd_emux *emu; + struct snd_emux_effect_table *fx; unsigned long flags; emu = port->emu; @@ -206,7 +208,7 @@ snd_emux_send_effect(snd_emux_port_t *port, snd_midi_channel_t *chan, int type, /* modify the register values */ spin_lock_irqsave(&emu->voice_lock, flags); for (i = 0; i < emu->max_voices; i++) { - snd_emux_voice_t *vp = &emu->voices[i]; + struct snd_emux_voice *vp = &emu->voices[i]; if (!STATE_IS_PLAYING(vp->state) || vp->chan != chan) continue; srcp = (unsigned char*)&vp->reg.parm + offset; @@ -228,10 +230,10 @@ snd_emux_send_effect(snd_emux_port_t *port, snd_midi_channel_t *chan, int type, /* copy wavetable registers to voice table */ void -snd_emux_setup_effect(snd_emux_voice_t *vp) +snd_emux_setup_effect(struct snd_emux_voice *vp) { - snd_midi_channel_t *chan = vp->chan; - snd_emux_effect_table_t *fx; + struct snd_midi_channel *chan = vp->chan; + struct snd_emux_effect_table *fx; unsigned char *srcp; int i; @@ -275,10 +277,11 @@ snd_emux_setup_effect(snd_emux_voice_t *vp) * effect table */ void -snd_emux_create_effect(snd_emux_port_t *p) +snd_emux_create_effect(struct snd_emux_port *p) { int i; - p->effect = kcalloc(p->chset.max_channels, sizeof(snd_emux_effect_table_t), GFP_KERNEL); + p->effect = kcalloc(p->chset.max_channels, + sizeof(struct snd_emux_effect_table), GFP_KERNEL); if (p->effect) { for (i = 0; i < p->chset.max_channels; i++) p->chset.channels[i].private = p->effect + i; @@ -289,17 +292,18 @@ snd_emux_create_effect(snd_emux_port_t *p) } void -snd_emux_delete_effect(snd_emux_port_t *p) +snd_emux_delete_effect(struct snd_emux_port *p) { kfree(p->effect); p->effect = NULL; } void -snd_emux_clear_effect(snd_emux_port_t *p) +snd_emux_clear_effect(struct snd_emux_port *p) { if (p->effect) { - memset(p->effect, 0, sizeof(snd_emux_effect_table_t) * p->chset.max_channels); + memset(p->effect, 0, sizeof(struct snd_emux_effect_table) * + p->chset.max_channels); } } diff --git a/sound/synth/emux/emux_hwdep.c b/sound/synth/emux/emux_hwdep.c index 4182b44..9b63814 100644 --- a/sound/synth/emux/emux_hwdep.c +++ b/sound/synth/emux/emux_hwdep.c @@ -29,7 +29,7 @@ * open the hwdep device */ static int -snd_emux_hwdep_open(snd_hwdep_t *hw, struct file *file) +snd_emux_hwdep_open(struct snd_hwdep *hw, struct file *file) { return 0; } @@ -39,7 +39,7 @@ snd_emux_hwdep_open(snd_hwdep_t *hw, struct file *file) * close the device */ static int -snd_emux_hwdep_release(snd_hwdep_t *hw, struct file *file) +snd_emux_hwdep_release(struct snd_hwdep *hw, struct file *file) { return 0; } @@ -51,10 +51,10 @@ snd_emux_hwdep_release(snd_hwdep_t *hw, struct file *file) * load patch */ static int -snd_emux_hwdep_load_patch(snd_emux_t *emu, void __user *arg) +snd_emux_hwdep_load_patch(struct snd_emux *emu, void __user *arg) { int err; - soundfont_patch_info_t patch; + struct soundfont_patch_info patch; if (copy_from_user(&patch, arg, sizeof(patch))) return -EFAULT; @@ -77,9 +77,9 @@ snd_emux_hwdep_load_patch(snd_emux_t *emu, void __user *arg) * set misc mode */ static int -snd_emux_hwdep_misc_mode(snd_emux_t *emu, void __user *arg) +snd_emux_hwdep_misc_mode(struct snd_emux *emu, void __user *arg) { - struct sndrv_emux_misc_mode info; + struct snd_emux_misc_mode info; int i; if (copy_from_user(&info, arg, sizeof(info))) @@ -102,9 +102,10 @@ snd_emux_hwdep_misc_mode(snd_emux_t *emu, void __user *arg) * ioctl */ static int -snd_emux_hwdep_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg) +snd_emux_hwdep_ioctl(struct snd_hwdep * hw, struct file *file, + unsigned int cmd, unsigned long arg) { - snd_emux_t *emu = hw->private_data; + struct snd_emux *emu = hw->private_data; switch (cmd) { case SNDRV_EMUX_IOCTL_VERSION: @@ -136,9 +137,9 @@ snd_emux_hwdep_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsi */ int -snd_emux_init_hwdep(snd_emux_t *emu) +snd_emux_init_hwdep(struct snd_emux *emu) { - snd_hwdep_t *hw; + struct snd_hwdep *hw; int err; if ((err = snd_hwdep_new(emu->card, SNDRV_EMUX_HWDEP_NAME, emu->hwdep_idx, &hw)) < 0) @@ -162,7 +163,7 @@ snd_emux_init_hwdep(snd_emux_t *emu) * unregister */ void -snd_emux_delete_hwdep(snd_emux_t *emu) +snd_emux_delete_hwdep(struct snd_emux *emu) { if (emu->hwdep) { snd_device_free(emu->card, emu->hwdep); diff --git a/sound/synth/emux/emux_nrpn.c b/sound/synth/emux/emux_nrpn.c index 25edff9..c6917ba 100644 --- a/sound/synth/emux/emux_nrpn.c +++ b/sound/synth/emux/emux_nrpn.c @@ -27,11 +27,11 @@ */ /* NRPN / CC -> Emu8000 parameter converter */ -typedef struct { +struct nrpn_conv_table { int control; int effect; int (*convert)(int val); -} nrpn_conv_table; +}; /* effect sensitivity */ @@ -48,8 +48,9 @@ typedef struct { * convert NRPN/control values */ -static int send_converted_effect(nrpn_conv_table *table, int num_tables, - snd_emux_port_t *port, snd_midi_channel_t *chan, +static int send_converted_effect(struct nrpn_conv_table *table, int num_tables, + struct snd_emux_port *port, + struct snd_midi_channel *chan, int type, int val, int mode) { int i, cval; @@ -178,7 +179,7 @@ static int fx_conv_Q(int val) } -static nrpn_conv_table awe_effects[] = +static struct nrpn_conv_table awe_effects[] = { { 0, EMUX_FX_LFO1_DELAY, fx_lfo1_delay}, { 1, EMUX_FX_LFO1_FREQ, fx_lfo1_freq}, @@ -265,7 +266,7 @@ static int gs_vib_delay(int val) return -(val - 64) * gs_sense[FX_VIBDELAY] / 50; } -static nrpn_conv_table gs_effects[] = +static struct nrpn_conv_table gs_effects[] = { {32, EMUX_FX_CUTOFF, gs_cutoff}, {33, EMUX_FX_FILTERQ, gs_filterQ}, @@ -282,9 +283,10 @@ static nrpn_conv_table gs_effects[] = * NRPN events */ void -snd_emux_nrpn(void *p, snd_midi_channel_t *chan, snd_midi_channel_set_t *chset) +snd_emux_nrpn(void *p, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset) { - snd_emux_port_t *port; + struct snd_emux_port *port; port = p; snd_assert(port != NULL, return); @@ -348,7 +350,7 @@ static int xg_release(int val) return -(val - 64) * xg_sense[FX_RELEASE] / 64; } -static nrpn_conv_table xg_effects[] = +static struct nrpn_conv_table xg_effects[] = { {71, EMUX_FX_CUTOFF, xg_cutoff}, {74, EMUX_FX_FILTERQ, xg_filterQ}, @@ -357,7 +359,8 @@ static nrpn_conv_table xg_effects[] = }; int -snd_emux_xg_control(snd_emux_port_t *port, snd_midi_channel_t *chan, int param) +snd_emux_xg_control(struct snd_emux_port *port, struct snd_midi_channel *chan, + int param) { return send_converted_effect(xg_effects, ARRAY_SIZE(xg_effects), port, chan, param, @@ -369,10 +372,11 @@ snd_emux_xg_control(snd_emux_port_t *port, snd_midi_channel_t *chan, int param) * receive sysex */ void -snd_emux_sysex(void *p, unsigned char *buf, int len, int parsed, snd_midi_channel_set_t *chset) +snd_emux_sysex(void *p, unsigned char *buf, int len, int parsed, + struct snd_midi_channel_set *chset) { - snd_emux_port_t *port; - snd_emux_t *emu; + struct snd_emux_port *port; + struct snd_emux *emu; port = p; snd_assert(port != NULL, return); diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c index 5272f4a..dfbfcfb 100644 --- a/sound/synth/emux/emux_oss.c +++ b/sound/synth/emux/emux_oss.c @@ -31,19 +31,25 @@ #include "emux_voice.h" #include <sound/asoundef.h> -static int snd_emux_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure); -static int snd_emux_close_seq_oss(snd_seq_oss_arg_t *arg); -static int snd_emux_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, unsigned long ioarg); -static int snd_emux_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, const char __user *buf, int offs, int count); -static int snd_emux_reset_seq_oss(snd_seq_oss_arg_t *arg); -static int snd_emux_event_oss_input(snd_seq_event_t *ev, int direct, void *private, int atomic, int hop); -static void reset_port_mode(snd_emux_port_t *port, int midi_mode); -static void emuspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd, unsigned char *event, int atomic, int hop); -static void gusspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd, unsigned char *event, int atomic, int hop); -static void fake_event(snd_emux_t *emu, snd_emux_port_t *port, int ch, int param, int val, int atomic, int hop); +static int snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure); +static int snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg); +static int snd_emux_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, + unsigned long ioarg); +static int snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format, + const char __user *buf, int offs, int count); +static int snd_emux_reset_seq_oss(struct snd_seq_oss_arg *arg); +static int snd_emux_event_oss_input(struct snd_seq_event *ev, int direct, + void *private, int atomic, int hop); +static void reset_port_mode(struct snd_emux_port *port, int midi_mode); +static void emuspec_control(struct snd_emux *emu, struct snd_emux_port *port, + int cmd, unsigned char *event, int atomic, int hop); +static void gusspec_control(struct snd_emux *emu, struct snd_emux_port *port, + int cmd, unsigned char *event, int atomic, int hop); +static void fake_event(struct snd_emux *emu, struct snd_emux_port *port, + int ch, int param, int val, int atomic, int hop); /* operators */ -static snd_seq_oss_callback_t oss_callback = { +static struct snd_seq_oss_callback oss_callback = { .owner = THIS_MODULE, .open = snd_emux_open_seq_oss, .close = snd_emux_close_seq_oss, @@ -58,13 +64,13 @@ static snd_seq_oss_callback_t oss_callback = { */ void -snd_emux_init_seq_oss(snd_emux_t *emu) +snd_emux_init_seq_oss(struct snd_emux *emu) { - snd_seq_oss_reg_t *arg; - snd_seq_device_t *dev; + struct snd_seq_oss_reg *arg; + struct snd_seq_device *dev; if (snd_seq_device_new(emu->card, 0, SNDRV_SEQ_DEV_ID_OSS, - sizeof(snd_seq_oss_reg_t), &dev) < 0) + sizeof(struct snd_seq_oss_reg), &dev) < 0) return; emu->oss_synth = dev; @@ -85,7 +91,7 @@ snd_emux_init_seq_oss(snd_emux_t *emu) * unregister */ void -snd_emux_detach_seq_oss(snd_emux_t *emu) +snd_emux_detach_seq_oss(struct snd_emux *emu) { if (emu->oss_synth) { snd_device_free(emu->card, emu->oss_synth); @@ -101,11 +107,11 @@ snd_emux_detach_seq_oss(snd_emux_t *emu) * open port for OSS sequencer */ static int -snd_emux_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure) +snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure) { - snd_emux_t *emu; - snd_emux_port_t *p; - snd_seq_port_callback_t callback; + struct snd_emux *emu; + struct snd_emux_port *p; + struct snd_seq_port_callback callback; char tmpname[64]; emu = closure; @@ -153,7 +159,7 @@ snd_emux_open_seq_oss(snd_seq_oss_arg_t *arg, void *closure) * reset port mode */ static void -reset_port_mode(snd_emux_port_t *port, int midi_mode) +reset_port_mode(struct snd_emux_port *port, int midi_mode) { if (midi_mode) { port->port_mode = SNDRV_EMUX_PORT_MODE_OSS_MIDI; @@ -173,10 +179,10 @@ reset_port_mode(snd_emux_port_t *port, int midi_mode) * close port */ static int -snd_emux_close_seq_oss(snd_seq_oss_arg_t *arg) +snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg) { - snd_emux_t *emu; - snd_emux_port_t *p; + struct snd_emux *emu; + struct snd_emux_port *p; snd_assert(arg != NULL, return -ENXIO); p = arg->private_data; @@ -200,11 +206,11 @@ snd_emux_close_seq_oss(snd_seq_oss_arg_t *arg) * load patch */ static int -snd_emux_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, +snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format, const char __user *buf, int offs, int count) { - snd_emux_t *emu; - snd_emux_port_t *p; + struct snd_emux *emu; + struct snd_emux_port *p; int rc; snd_assert(arg != NULL, return -ENXIO); @@ -218,7 +224,7 @@ snd_emux_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, rc = snd_soundfont_load_guspatch(emu->sflist, buf, count, SF_CLIENT_NO(p->chset.port)); else if (format == SNDRV_OSS_SOUNDFONT_PATCH) { - soundfont_patch_info_t patch; + struct soundfont_patch_info patch; if (count < (int)sizeof(patch)) rc = -EINVAL; if (copy_from_user(&patch, buf, sizeof(patch))) @@ -242,10 +248,10 @@ snd_emux_load_patch_seq_oss(snd_seq_oss_arg_t *arg, int format, * ioctl */ static int -snd_emux_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, unsigned long ioarg) +snd_emux_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, unsigned long ioarg) { - snd_emux_port_t *p; - snd_emux_t *emu; + struct snd_emux_port *p; + struct snd_emux *emu; snd_assert(arg != NULL, return -ENXIO); p = arg->private_data; @@ -273,9 +279,9 @@ snd_emux_ioctl_seq_oss(snd_seq_oss_arg_t *arg, unsigned int cmd, unsigned long i * reset device */ static int -snd_emux_reset_seq_oss(snd_seq_oss_arg_t *arg) +snd_emux_reset_seq_oss(struct snd_seq_oss_arg *arg) { - snd_emux_port_t *p; + struct snd_emux_port *p; snd_assert(arg != NULL, return -ENXIO); p = arg->private_data; @@ -289,11 +295,11 @@ snd_emux_reset_seq_oss(snd_seq_oss_arg_t *arg) * receive raw events: only SEQ_PRIVATE is accepted. */ static int -snd_emux_event_oss_input(snd_seq_event_t *ev, int direct, void *private_data, +snd_emux_event_oss_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - snd_emux_t *emu; - snd_emux_port_t *p; + struct snd_emux *emu; + struct snd_emux_port *p; unsigned char cmd, *data; p = private_data; @@ -320,14 +326,14 @@ snd_emux_event_oss_input(snd_seq_event_t *ev, int direct, void *private_data, * OSS/AWE driver specific h/w controls */ static void -emuspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd, +emuspec_control(struct snd_emux *emu, struct snd_emux_port *port, int cmd, unsigned char *event, int atomic, int hop) { int voice; unsigned short p1; short p2; int i; - snd_midi_channel_t *chan; + struct snd_midi_channel *chan; voice = event[3]; if (voice < 0 || voice >= port->chset.max_channels) @@ -415,14 +421,14 @@ emuspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd, #include <linux/ultrasound.h> static void -gusspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd, +gusspec_control(struct snd_emux *emu, struct snd_emux_port *port, int cmd, unsigned char *event, int atomic, int hop) { int voice; unsigned short p1; short p2; int plong; - snd_midi_channel_t *chan; + struct snd_midi_channel *chan; if (port->port_mode != SNDRV_EMUX_PORT_MODE_OSS_SYNTH) return; @@ -483,9 +489,9 @@ gusspec_control(snd_emux_t *emu, snd_emux_port_t *port, int cmd, * send an event to midi emulation */ static void -fake_event(snd_emux_t *emu, snd_emux_port_t *port, int ch, int param, int val, int atomic, int hop) +fake_event(struct snd_emux *emu, struct snd_emux_port *port, int ch, int param, int val, int atomic, int hop) { - snd_seq_event_t ev; + struct snd_seq_event ev; memset(&ev, 0, sizeof(ev)); ev.type = SNDRV_SEQ_EVENT_CONTROLLER; ev.data.control.channel = ch; diff --git a/sound/synth/emux/emux_proc.c b/sound/synth/emux/emux_proc.c index 0f155d6..a70a179 100644 --- a/sound/synth/emux/emux_proc.c +++ b/sound/synth/emux/emux_proc.c @@ -30,10 +30,10 @@ #ifdef CONFIG_PROC_FS static void -snd_emux_proc_info_read(snd_info_entry_t *entry, - snd_info_buffer_t *buf) +snd_emux_proc_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buf) { - snd_emux_t *emu; + struct snd_emux *emu; int i; emu = entry->private_data; @@ -66,7 +66,7 @@ snd_emux_proc_info_read(snd_info_entry_t *entry, } #if 0 /* debug */ if (emu->voices[0].state != SNDRV_EMUX_ST_OFF && emu->voices[0].ch >= 0) { - snd_emux_voice_t *vp = &emu->voices[0]; + struct snd_emux_voice *vp = &emu->voices[0]; snd_iprintf(buf, "voice 0: on\n"); snd_iprintf(buf, "mod delay=%x, atkhld=%x, dcysus=%x, rel=%x\n", vp->reg.parm.moddelay, @@ -107,9 +107,9 @@ snd_emux_proc_info_read(snd_info_entry_t *entry, } -void snd_emux_proc_init(snd_emux_t *emu, snd_card_t *card, int device) +void snd_emux_proc_init(struct snd_emux *emu, struct snd_card *card, int device) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; char name[64]; sprintf(name, "wavetableD%d", device); @@ -127,7 +127,7 @@ void snd_emux_proc_init(snd_emux_t *emu, snd_card_t *card, int device) emu->proc = entry; } -void snd_emux_proc_free(snd_emux_t *emu) +void snd_emux_proc_free(struct snd_emux *emu) { if (emu->proc) { snd_info_unregister(emu->proc); diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index 8ccd33f..f5a832f 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -25,15 +25,15 @@ /* Prototypes for static functions */ static void free_port(void *private); -static void snd_emux_init_port(snd_emux_port_t *p); -static int snd_emux_use(void *private_data, snd_seq_port_subscribe_t *info); -static int snd_emux_unuse(void *private_data, snd_seq_port_subscribe_t *info); -static int get_client(snd_card_t *card, int index, char *name); +static void snd_emux_init_port(struct snd_emux_port *p); +static int snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info); +static int snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info); +static int get_client(struct snd_card *card, int index, char *name); /* * MIDI emulation operators */ -static snd_midi_op_t emux_ops = { +static struct snd_midi_op emux_ops = { snd_emux_note_on, snd_emux_note_off, snd_emux_key_press, @@ -65,10 +65,10 @@ static snd_midi_op_t emux_ops = { * can connect to these ports to play midi data. */ int -snd_emux_init_seq(snd_emux_t *emu, snd_card_t *card, int index) +snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index) { int i; - snd_seq_port_callback_t pinfo; + struct snd_seq_port_callback pinfo; char tmpname[64]; sprintf(tmpname, "%s WaveTable", emu->name); @@ -94,7 +94,7 @@ snd_emux_init_seq(snd_emux_t *emu, snd_card_t *card, int index) pinfo.event_input = snd_emux_event_input; for (i = 0; i < emu->num_ports; i++) { - snd_emux_port_t *p; + struct snd_emux_port *p; sprintf(tmpname, "%s Port %d", emu->name, i); p = snd_emux_create_port(emu, tmpname, MIDI_CHANNELS, @@ -119,7 +119,7 @@ snd_emux_init_seq(snd_emux_t *emu, snd_card_t *card, int index) * destroy the kernel client. */ void -snd_emux_detach_seq(snd_emux_t *emu) +snd_emux_detach_seq(struct snd_emux *emu) { if (emu->voices) snd_emux_terminate_all(emu); @@ -137,12 +137,12 @@ snd_emux_detach_seq(snd_emux_t *emu) * create a sequencer port and channel_set */ -snd_emux_port_t * -snd_emux_create_port(snd_emux_t *emu, char *name, - int max_channels, int oss_port, - snd_seq_port_callback_t *callback) +struct snd_emux_port * +snd_emux_create_port(struct snd_emux *emu, char *name, + int max_channels, int oss_port, + struct snd_seq_port_callback *callback) { - snd_emux_port_t *p; + struct snd_emux_port *p; int i, type, cap; /* Allocate structures for this channel */ @@ -150,7 +150,7 @@ snd_emux_create_port(snd_emux_t *emu, char *name, snd_printk("no memory\n"); return NULL; } - p->chset.channels = kcalloc(max_channels, sizeof(snd_midi_channel_t), GFP_KERNEL); + p->chset.channels = kcalloc(max_channels, sizeof(struct snd_midi_channel), GFP_KERNEL); if (p->chset.channels == NULL) { snd_printk("no memory\n"); kfree(p); @@ -190,7 +190,7 @@ snd_emux_create_port(snd_emux_t *emu, char *name, static void free_port(void *private_data) { - snd_emux_port_t *p; + struct snd_emux_port *p; p = private_data; if (p) { @@ -209,7 +209,7 @@ free_port(void *private_data) * initialize the port specific parameters */ static void -snd_emux_init_port(snd_emux_port_t *p) +snd_emux_init_port(struct snd_emux_port *p) { p->drum_flags = DEFAULT_DRUM_FLAGS; p->volume_atten = 0; @@ -222,7 +222,7 @@ snd_emux_init_port(snd_emux_port_t *p) * reset port */ void -snd_emux_reset_port(snd_emux_port_t *port) +snd_emux_reset_port(struct snd_emux_port *port) { int i; @@ -241,7 +241,7 @@ snd_emux_reset_port(snd_emux_port_t *port) port->ctrls[EMUX_MD_REALTIME_PAN] = 1; for (i = 0; i < port->chset.max_channels; i++) { - snd_midi_channel_t *chan = port->chset.channels + i; + struct snd_midi_channel *chan = port->chset.channels + i; chan->drum_channel = ((port->drum_flags >> i) & 1) ? 1 : 0; } } @@ -251,10 +251,10 @@ snd_emux_reset_port(snd_emux_port_t *port) * input sequencer event */ int -snd_emux_event_input(snd_seq_event_t *ev, int direct, void *private_data, +snd_emux_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - snd_emux_port_t *port; + struct snd_emux_port *port; port = private_data; snd_assert(port != NULL && ev != NULL, return -EINVAL); @@ -269,7 +269,7 @@ snd_emux_event_input(snd_seq_event_t *ev, int direct, void *private_data, * increment usage count */ int -snd_emux_inc_count(snd_emux_t *emu) +snd_emux_inc_count(struct snd_emux *emu) { emu->used++; if (!try_module_get(emu->ops.owner)) @@ -288,7 +288,7 @@ snd_emux_inc_count(snd_emux_t *emu) * decrease usage count */ void -snd_emux_dec_count(snd_emux_t *emu) +snd_emux_dec_count(struct snd_emux *emu) { module_put(emu->card->module); emu->used--; @@ -302,10 +302,10 @@ snd_emux_dec_count(snd_emux_t *emu) * Routine that is called upon a first use of a particular port */ static int -snd_emux_use(void *private_data, snd_seq_port_subscribe_t *info) +snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info) { - snd_emux_port_t *p; - snd_emux_t *emu; + struct snd_emux_port *p; + struct snd_emux *emu; p = private_data; snd_assert(p != NULL, return -EINVAL); @@ -323,10 +323,10 @@ snd_emux_use(void *private_data, snd_seq_port_subscribe_t *info) * Routine that is called upon the last unuse() of a particular port. */ static int -snd_emux_unuse(void *private_data, snd_seq_port_subscribe_t *info) +snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info) { - snd_emux_port_t *p; - snd_emux_t *emu; + struct snd_emux_port *p; + struct snd_emux *emu; p = private_data; snd_assert(p != NULL, return -EINVAL); @@ -345,10 +345,10 @@ snd_emux_unuse(void *private_data, snd_seq_port_subscribe_t *info) * Create a sequencer client */ static int -get_client(snd_card_t *card, int index, char *name) +get_client(struct snd_card *card, int index, char *name) { - snd_seq_client_callback_t callbacks; - snd_seq_client_info_t cinfo; + struct snd_seq_client_callback callbacks; + struct snd_seq_client_info cinfo; int client; memset(&callbacks, 0, sizeof(callbacks)); @@ -374,7 +374,7 @@ get_client(snd_card_t *card, int index, char *name) /* * attach virtual rawmidi devices */ -int snd_emux_init_virmidi(snd_emux_t *emu, snd_card_t *card) +int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card) { int i; @@ -382,13 +382,13 @@ int snd_emux_init_virmidi(snd_emux_t *emu, snd_card_t *card) if (emu->midi_ports <= 0) return 0; - emu->vmidi = kcalloc(emu->midi_ports, sizeof(snd_rawmidi_t*), GFP_KERNEL); + emu->vmidi = kcalloc(emu->midi_ports, sizeof(struct snd_rawmidi *), GFP_KERNEL); if (emu->vmidi == NULL) return -ENOMEM; for (i = 0; i < emu->midi_ports; i++) { - snd_rawmidi_t *rmidi; - snd_virmidi_dev_t *rdev; + struct snd_rawmidi *rmidi; + struct snd_virmidi_dev *rdev; if (snd_virmidi_new(card, emu->midi_devidx + i, &rmidi) < 0) goto __error; rdev = rmidi->private_data; @@ -411,7 +411,7 @@ __error: return -ENOMEM; } -int snd_emux_delete_virmidi(snd_emux_t *emu) +int snd_emux_delete_virmidi(struct snd_emux *emu) { int i; diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c index bd71b73..c387a83 100644 --- a/sound/synth/emux/emux_synth.c +++ b/sound/synth/emux/emux_synth.c @@ -36,30 +36,34 @@ #define LIMITVALUE(x, a, b) do { if ((x) < (a)) (x) = (a); else if ((x) > (b)) (x) = (b); } while (0) #define LIMITMAX(x, a) do {if ((x) > (a)) (x) = (a); } while (0) -static int get_zone(snd_emux_t *emu, snd_emux_port_t *port, int *notep, int vel, snd_midi_channel_t *chan, snd_sf_zone_t **table); -static int get_bank(snd_emux_port_t *port, snd_midi_channel_t *chan); -static void terminate_note1(snd_emux_t *emu, int note, snd_midi_channel_t *chan, int free); -static void exclusive_note_off(snd_emux_t *emu, snd_emux_port_t *port, int exclass); -static void terminate_voice(snd_emux_t *emu, snd_emux_voice_t *vp, int free); -static void update_voice(snd_emux_t *emu, snd_emux_voice_t *vp, int update); -static void setup_voice(snd_emux_voice_t *vp); -static int calc_pan(snd_emux_voice_t *vp); -static int calc_volume(snd_emux_voice_t *vp); -static int calc_pitch(snd_emux_voice_t *vp); +static int get_zone(struct snd_emux *emu, struct snd_emux_port *port, + int *notep, int vel, struct snd_midi_channel *chan, + struct snd_sf_zone **table); +static int get_bank(struct snd_emux_port *port, struct snd_midi_channel *chan); +static void terminate_note1(struct snd_emux *emu, int note, + struct snd_midi_channel *chan, int free); +static void exclusive_note_off(struct snd_emux *emu, struct snd_emux_port *port, + int exclass); +static void terminate_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int free); +static void update_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int update); +static void setup_voice(struct snd_emux_voice *vp); +static int calc_pan(struct snd_emux_voice *vp); +static int calc_volume(struct snd_emux_voice *vp); +static int calc_pitch(struct snd_emux_voice *vp); /* * Start a note. */ void -snd_emux_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) +snd_emux_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) { - snd_emux_t *emu; + struct snd_emux *emu; int i, key, nvoices; - snd_emux_voice_t *vp; - snd_sf_zone_t *table[SNDRV_EMUX_MAX_MULTI_VOICES]; + struct snd_emux_voice *vp; + struct snd_sf_zone *table[SNDRV_EMUX_MAX_MULTI_VOICES]; unsigned long flags; - snd_emux_port_t *port; + struct snd_emux_port *port; port = p; snd_assert(port != NULL && chan != NULL, return); @@ -76,7 +80,7 @@ snd_emux_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) /* exclusive note off */ for (i = 0; i < nvoices; i++) { - snd_sf_zone_t *zp = table[i]; + struct snd_sf_zone *zp = table[i]; if (zp && zp->v.exclusiveClass) exclusive_note_off(emu, port, zp->v.exclusiveClass); } @@ -138,7 +142,7 @@ snd_emux_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) #ifdef SNDRV_EMUX_USE_RAW_EFFECT if (port->port_mode == SNDRV_EMUX_PORT_MODE_OSS_SYNTH) { /* clear voice position for the next note on this channel */ - snd_emux_effect_table_t *fx = chan->private; + struct snd_emux_effect_table *fx = chan->private; if (fx) { fx->flag[EMUX_FX_SAMPLE_START] = 0; fx->flag[EMUX_FX_COARSE_SAMPLE_START] = 0; @@ -151,13 +155,13 @@ snd_emux_note_on(void *p, int note, int vel, snd_midi_channel_t *chan) * Release a note in response to a midi note off. */ void -snd_emux_note_off(void *p, int note, int vel, snd_midi_channel_t *chan) +snd_emux_note_off(void *p, int note, int vel, struct snd_midi_channel *chan) { int ch; - snd_emux_t *emu; - snd_emux_voice_t *vp; + struct snd_emux *emu; + struct snd_emux_voice *vp; unsigned long flags; - snd_emux_port_t *port; + struct snd_emux_port *port; port = p; snd_assert(port != NULL && chan != NULL, return); @@ -199,8 +203,8 @@ snd_emux_note_off(void *p, int note, int vel, snd_midi_channel_t *chan) */ void snd_emux_timer_callback(unsigned long data) { - snd_emux_t *emu = (snd_emux_t*) data; - snd_emux_voice_t *vp; + struct snd_emux *emu = (struct snd_emux *) data; + struct snd_emux_voice *vp; int ch, do_again = 0; spin_lock(&emu->voice_lock); @@ -228,13 +232,13 @@ void snd_emux_timer_callback(unsigned long data) * key pressure change */ void -snd_emux_key_press(void *p, int note, int vel, snd_midi_channel_t *chan) +snd_emux_key_press(void *p, int note, int vel, struct snd_midi_channel *chan) { int ch; - snd_emux_t *emu; - snd_emux_voice_t *vp; + struct snd_emux *emu; + struct snd_emux_voice *vp; unsigned long flags; - snd_emux_port_t *port; + struct snd_emux_port *port; port = p; snd_assert(port != NULL && chan != NULL, return); @@ -260,10 +264,10 @@ snd_emux_key_press(void *p, int note, int vel, snd_midi_channel_t *chan) * Modulate the voices which belong to the channel */ void -snd_emux_update_channel(snd_emux_port_t *port, snd_midi_channel_t *chan, int update) +snd_emux_update_channel(struct snd_emux_port *port, struct snd_midi_channel *chan, int update) { - snd_emux_t *emu; - snd_emux_voice_t *vp; + struct snd_emux *emu; + struct snd_emux_voice *vp; int i; unsigned long flags; @@ -287,10 +291,10 @@ snd_emux_update_channel(snd_emux_port_t *port, snd_midi_channel_t *chan, int upd * Modulate all the voices which belong to the port. */ void -snd_emux_update_port(snd_emux_port_t *port, int update) +snd_emux_update_port(struct snd_emux_port *port, int update) { - snd_emux_t *emu; - snd_emux_voice_t *vp; + struct snd_emux *emu; + struct snd_emux_voice *vp; int i; unsigned long flags; @@ -316,9 +320,9 @@ snd_emux_update_port(snd_emux_port_t *port, int update) * control events, not just the midi controllers */ void -snd_emux_control(void *p, int type, snd_midi_channel_t *chan) +snd_emux_control(void *p, int type, struct snd_midi_channel *chan) { - snd_emux_port_t *port; + struct snd_emux_port *port; port = p; snd_assert(port != NULL && chan != NULL, return); @@ -364,10 +368,10 @@ snd_emux_control(void *p, int type, snd_midi_channel_t *chan) * terminate note - if free flag is true, free the terminated voice */ static void -terminate_note1(snd_emux_t *emu, int note, snd_midi_channel_t *chan, int free) +terminate_note1(struct snd_emux *emu, int note, struct snd_midi_channel *chan, int free) { int i; - snd_emux_voice_t *vp; + struct snd_emux_voice *vp; unsigned long flags; spin_lock_irqsave(&emu->voice_lock, flags); @@ -385,10 +389,10 @@ terminate_note1(snd_emux_t *emu, int note, snd_midi_channel_t *chan, int free) * terminate note - exported for midi emulation */ void -snd_emux_terminate_note(void *p, int note, snd_midi_channel_t *chan) +snd_emux_terminate_note(void *p, int note, struct snd_midi_channel *chan) { - snd_emux_t *emu; - snd_emux_port_t *port; + struct snd_emux *emu; + struct snd_emux_port *port; port = p; snd_assert(port != NULL && chan != NULL, return); @@ -405,10 +409,10 @@ snd_emux_terminate_note(void *p, int note, snd_midi_channel_t *chan) * Terminate all the notes */ void -snd_emux_terminate_all(snd_emux_t *emu) +snd_emux_terminate_all(struct snd_emux *emu) { int i; - snd_emux_voice_t *vp; + struct snd_emux_voice *vp; unsigned long flags; spin_lock_irqsave(&emu->voice_lock, flags); @@ -434,11 +438,11 @@ snd_emux_terminate_all(snd_emux_t *emu) * Terminate all voices associated with the given port */ void -snd_emux_sounds_off_all(snd_emux_port_t *port) +snd_emux_sounds_off_all(struct snd_emux_port *port) { int i; - snd_emux_t *emu; - snd_emux_voice_t *vp; + struct snd_emux *emu; + struct snd_emux_voice *vp; unsigned long flags; snd_assert(port != NULL, return); @@ -468,9 +472,9 @@ snd_emux_sounds_off_all(snd_emux_port_t *port) * is mainly for drums. */ static void -exclusive_note_off(snd_emux_t *emu, snd_emux_port_t *port, int exclass) +exclusive_note_off(struct snd_emux *emu, struct snd_emux_port *port, int exclass) { - snd_emux_voice_t *vp; + struct snd_emux_voice *vp; int i; unsigned long flags; @@ -490,7 +494,7 @@ exclusive_note_off(snd_emux_t *emu, snd_emux_port_t *port, int exclass) * if free flag is true, call free_voice after termination */ static void -terminate_voice(snd_emux_t *emu, snd_emux_voice_t *vp, int free) +terminate_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int free) { emu->ops.terminate(vp); vp->time = emu->use_time++; @@ -508,7 +512,7 @@ terminate_voice(snd_emux_t *emu, snd_emux_voice_t *vp, int free) * Modulate the voice */ static void -update_voice(snd_emux_t *emu, snd_emux_voice_t *vp, int update) +update_voice(struct snd_emux *emu, struct snd_emux_voice *vp, int update) { if (!STATE_IS_PLAYING(vp->state)) return; @@ -543,9 +547,9 @@ static unsigned short voltarget[16] = { * will be needed later. */ static void -setup_voice(snd_emux_voice_t *vp) +setup_voice(struct snd_emux_voice *vp) { - soundfont_voice_parm_t *parm; + struct soundfont_voice_parm *parm; int pitch; /* copy the original register values */ @@ -636,9 +640,9 @@ static unsigned char pan_volumes[256] = { }; static int -calc_pan(snd_emux_voice_t *vp) +calc_pan(struct snd_emux_voice *vp) { - snd_midi_channel_t *chan = vp->chan; + struct snd_midi_channel *chan = vp->chan; int pan; /* pan & loop start (pan 8bit, MSB, 0:right, 0xff:left) */ @@ -737,12 +741,12 @@ static unsigned char expressiontab[128] = { * voice and channels parameters. */ static int -calc_volume(snd_emux_voice_t *vp) +calc_volume(struct snd_emux_voice *vp) { int vol; int main_vol, expression_vol, master_vol; - snd_midi_channel_t *chan = vp->chan; - snd_emux_port_t *port = vp->port; + struct snd_midi_channel *chan = vp->chan; + struct snd_emux_port *port = vp->port; expression_vol = chan->control[MIDI_CTL_MSB_EXPRESSION]; LIMITMAX(vp->velocity, 127); @@ -775,7 +779,7 @@ calc_volume(snd_emux_voice_t *vp) #ifdef SNDRV_EMUX_USE_RAW_EFFECT if (chan->private) { - snd_emux_effect_table_t *fx = chan->private; + struct snd_emux_effect_table *fx = chan->private; vol += fx->val[EMUX_FX_ATTEN]; } #endif @@ -808,9 +812,9 @@ calc_volume(snd_emux_voice_t *vp) */ static int -calc_pitch(snd_emux_voice_t *vp) +calc_pitch(struct snd_emux_voice *vp) { - snd_midi_channel_t *chan = vp->chan; + struct snd_midi_channel *chan = vp->chan; int offset; /* calculate offset */ @@ -837,7 +841,7 @@ calc_pitch(snd_emux_voice_t *vp) #ifdef SNDRV_EMUX_USE_RAW_EFFECT /* add initial pitch correction */ if (chan->private) { - snd_emux_effect_table_t *fx = chan->private; + struct snd_emux_effect_table *fx = chan->private; if (fx->flag[EMUX_FX_INIT_PITCH]) offset += fx->val[EMUX_FX_INIT_PITCH]; } @@ -857,7 +861,7 @@ calc_pitch(snd_emux_voice_t *vp) * Get the bank number assigned to the channel */ static int -get_bank(snd_emux_port_t *port, snd_midi_channel_t *chan) +get_bank(struct snd_emux_port *port, struct snd_midi_channel *chan) { int val; @@ -886,8 +890,9 @@ get_bank(snd_emux_port_t *port, snd_midi_channel_t *chan) * The resultant zones are stored on table. */ static int -get_zone(snd_emux_t *emu, snd_emux_port_t *port, - int *notep, int vel, snd_midi_channel_t *chan, snd_sf_zone_t **table) +get_zone(struct snd_emux *emu, struct snd_emux_port *port, + int *notep, int vel, struct snd_midi_channel *chan, + struct snd_sf_zone **table) { int preset, bank, def_preset, def_bank; @@ -910,9 +915,9 @@ get_zone(snd_emux_t *emu, snd_emux_port_t *port, /* */ void -snd_emux_init_voices(snd_emux_t *emu) +snd_emux_init_voices(struct snd_emux *emu) { - snd_emux_voice_t *vp; + struct snd_emux_voice *vp; int i; unsigned long flags; @@ -932,7 +937,7 @@ snd_emux_init_voices(snd_emux_t *emu) /* */ -void snd_emux_lock_voice(snd_emux_t *emu, int voice) +void snd_emux_lock_voice(struct snd_emux *emu, int voice) { unsigned long flags; @@ -947,7 +952,7 @@ void snd_emux_lock_voice(snd_emux_t *emu, int voice) /* */ -void snd_emux_unlock_voice(snd_emux_t *emu, int voice) +void snd_emux_unlock_voice(struct snd_emux *emu, int voice) { unsigned long flags; diff --git a/sound/synth/emux/emux_voice.h b/sound/synth/emux/emux_voice.h index 67eb553..0a56ca18 100644 --- a/sound/synth/emux/emux_voice.h +++ b/sound/synth/emux/emux_voice.h @@ -29,60 +29,69 @@ #include <sound/emux_synth.h> /* Prototypes for emux_seq.c */ -int snd_emux_init_seq(snd_emux_t *emu, snd_card_t *card, int index); -void snd_emux_detach_seq(snd_emux_t *emu); -snd_emux_port_t *snd_emux_create_port(snd_emux_t *emu, char *name, int max_channels, int type, snd_seq_port_callback_t *callback); -void snd_emux_reset_port(snd_emux_port_t *port); -int snd_emux_event_input(snd_seq_event_t *ev, int direct, void *private, int atomic, int hop); -int snd_emux_inc_count(snd_emux_t *emu); -void snd_emux_dec_count(snd_emux_t *emu); -int snd_emux_init_virmidi(snd_emux_t *emu, snd_card_t *card); -int snd_emux_delete_virmidi(snd_emux_t *emu); +int snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index); +void snd_emux_detach_seq(struct snd_emux *emu); +struct snd_emux_port *snd_emux_create_port(struct snd_emux *emu, char *name, + int max_channels, int type, + struct snd_seq_port_callback *callback); +void snd_emux_reset_port(struct snd_emux_port *port); +int snd_emux_event_input(struct snd_seq_event *ev, int direct, void *private, + int atomic, int hop); +int snd_emux_inc_count(struct snd_emux *emu); +void snd_emux_dec_count(struct snd_emux *emu); +int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card); +int snd_emux_delete_virmidi(struct snd_emux *emu); /* Prototypes for emux_synth.c */ -void snd_emux_init_voices(snd_emux_t *emu); +void snd_emux_init_voices(struct snd_emux *emu); void snd_emux_note_on(void *p, int note, int vel, struct snd_midi_channel *chan); void snd_emux_note_off(void *p, int note, int vel, struct snd_midi_channel *chan); void snd_emux_key_press(void *p, int note, int vel, struct snd_midi_channel *chan); -void snd_emux_terminate_note(void *p, int note, snd_midi_channel_t *chan); +void snd_emux_terminate_note(void *p, int note, struct snd_midi_channel *chan); void snd_emux_control(void *p, int type, struct snd_midi_channel *chan); -void snd_emux_sounds_off_all(snd_emux_port_t *port); -void snd_emux_update_channel(snd_emux_port_t *port, snd_midi_channel_t *chan, int update); -void snd_emux_update_port(snd_emux_port_t *port, int update); +void snd_emux_sounds_off_all(struct snd_emux_port *port); +void snd_emux_update_channel(struct snd_emux_port *port, + struct snd_midi_channel *chan, int update); +void snd_emux_update_port(struct snd_emux_port *port, int update); void snd_emux_timer_callback(unsigned long data); /* emux_effect.c */ #ifdef SNDRV_EMUX_USE_RAW_EFFECT -void snd_emux_create_effect(snd_emux_port_t *p); -void snd_emux_delete_effect(snd_emux_port_t *p); -void snd_emux_clear_effect(snd_emux_port_t *p); -void snd_emux_setup_effect(snd_emux_voice_t *vp); -void snd_emux_send_effect_oss(snd_emux_port_t *port, snd_midi_channel_t *chan, int type, int val); -void snd_emux_send_effect(snd_emux_port_t *port, snd_midi_channel_t *chan, int type, int val, int mode); +void snd_emux_create_effect(struct snd_emux_port *p); +void snd_emux_delete_effect(struct snd_emux_port *p); +void snd_emux_clear_effect(struct snd_emux_port *p); +void snd_emux_setup_effect(struct snd_emux_voice *vp); +void snd_emux_send_effect_oss(struct snd_emux_port *port, + struct snd_midi_channel *chan, int type, int val); +void snd_emux_send_effect(struct snd_emux_port *port, + struct snd_midi_channel *chan, int type, int val, int mode); #endif /* emux_nrpn.c */ -void snd_emux_sysex(void *private_data, unsigned char *buf, int len, int parsed, snd_midi_channel_set_t *chset); -int snd_emux_xg_control(snd_emux_port_t *port, snd_midi_channel_t *chan, int param); -void snd_emux_nrpn(void *private_data, snd_midi_channel_t *chan, snd_midi_channel_set_t *chset); +void snd_emux_sysex(void *private_data, unsigned char *buf, int len, + int parsed, struct snd_midi_channel_set *chset); +int snd_emux_xg_control(struct snd_emux_port *port, + struct snd_midi_channel *chan, int param); +void snd_emux_nrpn(void *private_data, struct snd_midi_channel *chan, + struct snd_midi_channel_set *chset); /* emux_oss.c */ -void snd_emux_init_seq_oss(snd_emux_t *emu); -void snd_emux_detach_seq_oss(snd_emux_t *emu); +void snd_emux_init_seq_oss(struct snd_emux *emu); +void snd_emux_detach_seq_oss(struct snd_emux *emu); /* emux_proc.c */ #ifdef CONFIG_PROC_FS -void snd_emux_proc_init(snd_emux_t *emu, snd_card_t *card, int device); -void snd_emux_proc_free(snd_emux_t *emu); +void snd_emux_proc_init(struct snd_emux *emu, struct snd_card *card, int device); +void snd_emux_proc_free(struct snd_emux *emu); #endif #define STATE_IS_PLAYING(s) ((s) & SNDRV_EMUX_ST_ON) /* emux_hwdep.c */ -int snd_emux_init_hwdep(snd_emux_t *emu); -void snd_emux_delete_hwdep(snd_emux_t *emu); +int snd_emux_init_hwdep(struct snd_emux *emu); +void snd_emux_delete_hwdep(struct snd_emux *emu); #endif diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c index d0925ea..4c5754d 100644 --- a/sound/synth/emux/soundfont.c +++ b/sound/synth/emux/soundfont.c @@ -34,38 +34,49 @@ /* Prototypes for static functions */ -static int open_patch(snd_sf_list_t *sflist, const char __user *data, int count, int client); -static snd_soundfont_t *newsf(snd_sf_list_t *sflist, int type, char *name); -static int is_identical_font(snd_soundfont_t *sf, int type, unsigned char *name); -static int close_patch(snd_sf_list_t *sflist); -static int probe_data(snd_sf_list_t *sflist, int sample_id); -static void set_zone_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_zone_t *zp); -static snd_sf_zone_t *sf_zone_new(snd_sf_list_t *sflist, snd_soundfont_t *sf); -static void set_sample_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp); -static snd_sf_sample_t *sf_sample_new(snd_sf_list_t *sflist, snd_soundfont_t *sf); -static void sf_sample_delete(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp); -static int load_map(snd_sf_list_t *sflist, const void __user *data, int count); -static int load_info(snd_sf_list_t *sflist, const void __user *data, long count); -static int remove_info(snd_sf_list_t *sflist, snd_soundfont_t *sf, int bank, int instr); -static void init_voice_info(soundfont_voice_info_t *avp); -static void init_voice_parm(soundfont_voice_parm_t *pp); -static snd_sf_sample_t *set_sample(snd_soundfont_t *sf, soundfont_voice_info_t *avp); -static snd_sf_sample_t *find_sample(snd_soundfont_t *sf, int sample_id); -static int load_data(snd_sf_list_t *sflist, const void __user *data, long count); -static void rebuild_presets(snd_sf_list_t *sflist); -static void add_preset(snd_sf_list_t *sflist, snd_sf_zone_t *cur); -static void delete_preset(snd_sf_list_t *sflist, snd_sf_zone_t *zp); -static snd_sf_zone_t *search_first_zone(snd_sf_list_t *sflist, int bank, int preset, int key); -static int search_zones(snd_sf_list_t *sflist, int *notep, int vel, int preset, int bank, snd_sf_zone_t **table, int max_layers, int level); +static int open_patch(struct snd_sf_list *sflist, const char __user *data, + int count, int client); +static struct snd_soundfont *newsf(struct snd_sf_list *sflist, int type, char *name); +static int is_identical_font(struct snd_soundfont *sf, int type, unsigned char *name); +static int close_patch(struct snd_sf_list *sflist); +static int probe_data(struct snd_sf_list *sflist, int sample_id); +static void set_zone_counter(struct snd_sf_list *sflist, + struct snd_soundfont *sf, struct snd_sf_zone *zp); +static struct snd_sf_zone *sf_zone_new(struct snd_sf_list *sflist, + struct snd_soundfont *sf); +static void set_sample_counter(struct snd_sf_list *sflist, + struct snd_soundfont *sf, struct snd_sf_sample *sp); +static struct snd_sf_sample *sf_sample_new(struct snd_sf_list *sflist, + struct snd_soundfont *sf); +static void sf_sample_delete(struct snd_sf_list *sflist, + struct snd_soundfont *sf, struct snd_sf_sample *sp); +static int load_map(struct snd_sf_list *sflist, const void __user *data, int count); +static int load_info(struct snd_sf_list *sflist, const void __user *data, long count); +static int remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf, + int bank, int instr); +static void init_voice_info(struct soundfont_voice_info *avp); +static void init_voice_parm(struct soundfont_voice_parm *pp); +static struct snd_sf_sample *set_sample(struct snd_soundfont *sf, + struct soundfont_voice_info *avp); +static struct snd_sf_sample *find_sample(struct snd_soundfont *sf, int sample_id); +static int load_data(struct snd_sf_list *sflist, const void __user *data, long count); +static void rebuild_presets(struct snd_sf_list *sflist); +static void add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur); +static void delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp); +static struct snd_sf_zone *search_first_zone(struct snd_sf_list *sflist, + int bank, int preset, int key); +static int search_zones(struct snd_sf_list *sflist, int *notep, int vel, + int preset, int bank, struct snd_sf_zone **table, + int max_layers, int level); static int get_index(int bank, int instr, int key); -static void snd_sf_init(snd_sf_list_t *sflist); -static void snd_sf_clear(snd_sf_list_t *sflist); +static void snd_sf_init(struct snd_sf_list *sflist); +static void snd_sf_clear(struct snd_sf_list *sflist); /* * lock access to sflist */ static void -lock_preset(snd_sf_list_t *sflist) +lock_preset(struct snd_sf_list *sflist) { unsigned long flags; down(&sflist->presets_mutex); @@ -79,7 +90,7 @@ lock_preset(snd_sf_list_t *sflist) * remove lock */ static void -unlock_preset(snd_sf_list_t *sflist) +unlock_preset(struct snd_sf_list *sflist) { unsigned long flags; spin_lock_irqsave(&sflist->lock, flags); @@ -93,7 +104,7 @@ unlock_preset(snd_sf_list_t *sflist) * close the patch if the patch was opened by this client. */ int -snd_soundfont_close_check(snd_sf_list_t *sflist, int client) +snd_soundfont_close_check(struct snd_sf_list *sflist, int client) { unsigned long flags; spin_lock_irqsave(&sflist->lock, flags); @@ -115,9 +126,10 @@ snd_soundfont_close_check(snd_sf_list_t *sflist, int client) * it wants to do with it. */ int -snd_soundfont_load(snd_sf_list_t *sflist, const void __user *data, long count, int client) +snd_soundfont_load(struct snd_sf_list *sflist, const void __user *data, + long count, int client) { - soundfont_patch_info_t patch; + struct soundfont_patch_info patch; unsigned long flags; int rc; @@ -215,10 +227,11 @@ is_special_type(int type) /* open patch; create sf list */ static int -open_patch(snd_sf_list_t *sflist, const char __user *data, int count, int client) +open_patch(struct snd_sf_list *sflist, const char __user *data, + int count, int client) { - soundfont_open_parm_t parm; - snd_soundfont_t *sf; + struct soundfont_open_parm parm; + struct snd_soundfont *sf; unsigned long flags; spin_lock_irqsave(&sflist->lock, flags); @@ -251,10 +264,10 @@ open_patch(snd_sf_list_t *sflist, const char __user *data, int count, int client /* * Allocate a new soundfont structure. */ -static snd_soundfont_t * -newsf(snd_sf_list_t *sflist, int type, char *name) +static struct snd_soundfont * +newsf(struct snd_sf_list *sflist, int type, char *name) { - snd_soundfont_t *sf; + struct snd_soundfont *sf; /* check the shared fonts */ if (type & SNDRV_SFNT_PAT_SHARED) { @@ -287,7 +300,7 @@ newsf(snd_sf_list_t *sflist, int type, char *name) /* check if the given name matches to the existing list */ static int -is_identical_font(snd_soundfont_t *sf, int type, unsigned char *name) +is_identical_font(struct snd_soundfont *sf, int type, unsigned char *name) { return ((sf->type & SNDRV_SFNT_PAT_SHARED) && (sf->type & 0x0f) == (type & 0x0f) && @@ -299,7 +312,7 @@ is_identical_font(snd_soundfont_t *sf, int type, unsigned char *name) * Close the current patch. */ static int -close_patch(snd_sf_list_t *sflist) +close_patch(struct snd_sf_list *sflist) { unsigned long flags; @@ -316,7 +329,7 @@ close_patch(snd_sf_list_t *sflist) /* probe sample in the current list -- nothing to be loaded */ static int -probe_data(snd_sf_list_t *sflist, int sample_id) +probe_data(struct snd_sf_list *sflist, int sample_id) { /* patch must be opened */ if (sflist->currsf) { @@ -331,7 +344,8 @@ probe_data(snd_sf_list_t *sflist, int sample_id) * increment zone counter */ static void -set_zone_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_zone_t *zp) +set_zone_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, + struct snd_sf_zone *zp) { zp->counter = sflist->zone_counter++; if (sf->type & SNDRV_SFNT_PAT_LOCKED) @@ -341,10 +355,10 @@ set_zone_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_zone_t *zp) /* * allocate a new zone record */ -static snd_sf_zone_t * -sf_zone_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) +static struct snd_sf_zone * +sf_zone_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) { - snd_sf_zone_t *zp; + struct snd_sf_zone *zp; if ((zp = kzalloc(sizeof(*zp), GFP_KERNEL)) == NULL) return NULL; @@ -362,7 +376,8 @@ sf_zone_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) * increment sample couter */ static void -set_sample_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp) +set_sample_counter(struct snd_sf_list *sflist, struct snd_soundfont *sf, + struct snd_sf_sample *sp) { sp->counter = sflist->sample_counter++; if (sf->type & SNDRV_SFNT_PAT_LOCKED) @@ -372,10 +387,10 @@ set_sample_counter(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t * /* * allocate a new sample list record */ -static snd_sf_sample_t * -sf_sample_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) +static struct snd_sf_sample * +sf_sample_new(struct snd_sf_list *sflist, struct snd_soundfont *sf) { - snd_sf_sample_t *sp; + struct snd_sf_sample *sp; if ((sp = kzalloc(sizeof(*sp), GFP_KERNEL)) == NULL) return NULL; @@ -392,7 +407,8 @@ sf_sample_new(snd_sf_list_t *sflist, snd_soundfont_t *sf) * only the last allocated sample can be deleted. */ static void -sf_sample_delete(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp) +sf_sample_delete(struct snd_sf_list *sflist, struct snd_soundfont *sf, + struct snd_sf_sample *sp) { /* only last sample is accepted */ if (sp == sf->samples) { @@ -404,11 +420,11 @@ sf_sample_delete(snd_sf_list_t *sflist, snd_soundfont_t *sf, snd_sf_sample_t *sp /* load voice map */ static int -load_map(snd_sf_list_t *sflist, const void __user *data, int count) +load_map(struct snd_sf_list *sflist, const void __user *data, int count) { - snd_sf_zone_t *zp, *prevp; - snd_soundfont_t *sf; - soundfont_voice_map_t map; + struct snd_sf_zone *zp, *prevp; + struct snd_soundfont *sf; + struct soundfont_voice_map map; /* get the link info */ if (count < (int)sizeof(map)) @@ -469,9 +485,10 @@ load_map(snd_sf_list_t *sflist, const void __user *data, int count) /* remove the present instrument layers */ static int -remove_info(snd_sf_list_t *sflist, snd_soundfont_t *sf, int bank, int instr) +remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf, + int bank, int instr) { - snd_sf_zone_t *prev, *next, *p; + struct snd_sf_zone *prev, *next, *p; int removed = 0; prev = NULL; @@ -500,11 +517,11 @@ remove_info(snd_sf_list_t *sflist, snd_soundfont_t *sf, int bank, int instr) * open soundfont. */ static int -load_info(snd_sf_list_t *sflist, const void __user *data, long count) +load_info(struct snd_sf_list *sflist, const void __user *data, long count) { - snd_soundfont_t *sf; - snd_sf_zone_t *zone; - soundfont_voice_rec_hdr_t hdr; + struct snd_soundfont *sf; + struct snd_sf_zone *zone; + struct soundfont_voice_rec_hdr hdr; int i; /* patch must be opened */ @@ -529,7 +546,7 @@ load_info(snd_sf_list_t *sflist, const void __user *data, long count) return -EINVAL; } - if (count < (long)sizeof(soundfont_voice_info_t)*hdr.nvoices) { + if (count < (long)sizeof(struct soundfont_voice_info) * hdr.nvoices) { printk("Soundfont Error: patch length(%ld) is smaller than nvoices(%d)\n", count, hdr.nvoices); return -EINVAL; @@ -553,7 +570,7 @@ load_info(snd_sf_list_t *sflist, const void __user *data, long count) } for (i = 0; i < hdr.nvoices; i++) { - snd_sf_zone_t tmpzone; + struct snd_sf_zone tmpzone; /* copy awe_voice_info parameters */ if (copy_from_user(&tmpzone.v, data, sizeof(tmpzone.v))) { @@ -590,7 +607,7 @@ load_info(snd_sf_list_t *sflist, const void __user *data, long count) /* initialize voice_info record */ static void -init_voice_info(soundfont_voice_info_t *avp) +init_voice_info(struct soundfont_voice_info *avp) { memset(avp, 0, sizeof(*avp)); @@ -614,7 +631,7 @@ init_voice_info(soundfont_voice_info_t *avp) * Chorus and Reverb effects are zero. */ static void -init_voice_parm(soundfont_voice_parm_t *pp) +init_voice_parm(struct soundfont_voice_parm *pp) { memset(pp, 0, sizeof(*pp)); @@ -635,10 +652,10 @@ init_voice_parm(soundfont_voice_parm_t *pp) } /* search the specified sample */ -static snd_sf_sample_t * -set_sample(snd_soundfont_t *sf, soundfont_voice_info_t *avp) +static struct snd_sf_sample * +set_sample(struct snd_soundfont *sf, struct soundfont_voice_info *avp) { - snd_sf_sample_t *sample; + struct snd_sf_sample *sample; sample = find_sample(sf, avp->sample); if (sample == NULL) @@ -661,10 +678,10 @@ set_sample(snd_soundfont_t *sf, soundfont_voice_info_t *avp) } /* find the sample pointer with the given id in the soundfont */ -static snd_sf_sample_t * -find_sample(snd_soundfont_t *sf, int sample_id) +static struct snd_sf_sample * +find_sample(struct snd_soundfont *sf, int sample_id) { - snd_sf_sample_t *p; + struct snd_sf_sample *p; if (sf == NULL) return NULL; @@ -684,11 +701,11 @@ find_sample(snd_soundfont_t *sf, int sample_id) * routine. */ static int -load_data(snd_sf_list_t *sflist, const void __user *data, long count) +load_data(struct snd_sf_list *sflist, const void __user *data, long count) { - snd_soundfont_t *sf; - soundfont_sample_info_t sample_info; - snd_sf_sample_t *sp; + struct snd_soundfont *sf; + struct soundfont_sample_info sample_info; + struct snd_sf_sample *sp; long off; /* patch must be opened */ @@ -922,12 +939,13 @@ int snd_sf_vol_table[128] = { /* load GUS patch */ static int -load_guspatch(snd_sf_list_t *sflist, const char __user *data, long count, int client) +load_guspatch(struct snd_sf_list *sflist, const char __user *data, + long count, int client) { struct patch_info patch; - snd_soundfont_t *sf; - snd_sf_zone_t *zone; - snd_sf_sample_t *smp; + struct snd_soundfont *sf; + struct snd_sf_zone *zone; + struct snd_sf_sample *smp; int note, sample_id; int rc; @@ -992,7 +1010,8 @@ load_guspatch(snd_sf_list_t *sflist, const char __user *data, long count, int cl */ if (sflist->callback.sample_new) { rc = sflist->callback.sample_new - (sflist->callback.private_data, smp, sflist->memhdr, data, count); + (sflist->callback.private_data, smp, sflist->memhdr, + data, count); if (rc < 0) { sf_sample_delete(sflist, sf, smp); return rc; @@ -1095,7 +1114,7 @@ load_guspatch(snd_sf_list_t *sflist, const char __user *data, long count, int cl /* load GUS patch */ int -snd_soundfont_load_guspatch(snd_sf_list_t *sflist, const char __user *data, +snd_soundfont_load_guspatch(struct snd_sf_list *sflist, const char __user *data, long count, int client) { int rc; @@ -1114,10 +1133,10 @@ snd_soundfont_load_guspatch(snd_sf_list_t *sflist, const char __user *data, * bank/key combination). */ static void -rebuild_presets(snd_sf_list_t *sflist) +rebuild_presets(struct snd_sf_list *sflist) { - snd_soundfont_t *sf; - snd_sf_zone_t *cur; + struct snd_soundfont *sf; + struct snd_sf_zone *cur; /* clear preset table */ memset(sflist->presets, 0, sizeof(sflist->presets)); @@ -1142,15 +1161,15 @@ rebuild_presets(snd_sf_list_t *sflist) * add the given zone to preset table */ static void -add_preset(snd_sf_list_t *sflist, snd_sf_zone_t *cur) +add_preset(struct snd_sf_list *sflist, struct snd_sf_zone *cur) { - snd_sf_zone_t *zone; + struct snd_sf_zone *zone; int index; zone = search_first_zone(sflist, cur->bank, cur->instr, cur->v.low); if (zone && zone->v.sf_id != cur->v.sf_id) { /* different instrument was already defined */ - snd_sf_zone_t *p; + struct snd_sf_zone *p; /* compare the allocated time */ for (p = zone; p; p = p->next_zone) { if (p->counter > cur->counter) @@ -1174,10 +1193,10 @@ add_preset(snd_sf_list_t *sflist, snd_sf_zone_t *cur) * delete the given zones from preset_table */ static void -delete_preset(snd_sf_list_t *sflist, snd_sf_zone_t *zp) +delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp) { int index; - snd_sf_zone_t *p; + struct snd_sf_zone *p; if ((index = get_index(zp->bank, zp->instr, zp->v.low)) < 0) return; @@ -1200,10 +1219,10 @@ delete_preset(snd_sf_list_t *sflist, snd_sf_zone_t *zp) * This function returns the number of found zones. 0 if not found. */ int -snd_soundfont_search_zone(snd_sf_list_t *sflist, int *notep, int vel, +snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel, int preset, int bank, int def_preset, int def_bank, - snd_sf_zone_t **table, int max_layers) + struct snd_sf_zone **table, int max_layers) { int nvoices; unsigned long flags; @@ -1217,10 +1236,13 @@ snd_soundfont_search_zone(snd_sf_list_t *sflist, int *notep, int vel, spin_unlock_irqrestore(&sflist->lock, flags); return 0; } - nvoices = search_zones(sflist, notep, vel, preset, bank, table, max_layers, 0); + nvoices = search_zones(sflist, notep, vel, preset, bank, + table, max_layers, 0); if (! nvoices) { if (preset != def_preset || bank != def_bank) - nvoices = search_zones(sflist, notep, vel, def_preset, def_bank, table, max_layers, 0); + nvoices = search_zones(sflist, notep, vel, + def_preset, def_bank, + table, max_layers, 0); } spin_unlock_irqrestore(&sflist->lock, flags); return nvoices; @@ -1230,11 +1252,11 @@ snd_soundfont_search_zone(snd_sf_list_t *sflist, int *notep, int vel, /* * search the first matching zone */ -static snd_sf_zone_t * -search_first_zone(snd_sf_list_t *sflist, int bank, int preset, int key) +static struct snd_sf_zone * +search_first_zone(struct snd_sf_list *sflist, int bank, int preset, int key) { int index; - snd_sf_zone_t *zp; + struct snd_sf_zone *zp; if ((index = get_index(bank, preset, key)) < 0) return NULL; @@ -1250,9 +1272,11 @@ search_first_zone(snd_sf_list_t *sflist, int bank, int preset, int key) * search matching zones from sflist. can be called recursively. */ static int -search_zones(snd_sf_list_t *sflist, int *notep, int vel, int preset, int bank, snd_sf_zone_t **table, int max_layers, int level) +search_zones(struct snd_sf_list *sflist, int *notep, int vel, + int preset, int bank, struct snd_sf_zone **table, + int max_layers, int level) { - snd_sf_zone_t *zp; + struct snd_sf_zone *zp; int nvoices; zp = search_first_zone(sflist, bank, preset, *notep); @@ -1310,7 +1334,7 @@ get_index(int bank, int instr, int key) * Initialise the sflist structure. */ static void -snd_sf_init(snd_sf_list_t *sflist) +snd_sf_init(struct snd_sf_list *sflist) { memset(sflist->presets, 0, sizeof(sflist->presets)); @@ -1329,11 +1353,11 @@ snd_sf_init(snd_sf_list_t *sflist) * Release all list records */ static void -snd_sf_clear(snd_sf_list_t *sflist) +snd_sf_clear(struct snd_sf_list *sflist) { - snd_soundfont_t *sf, *nextsf; - snd_sf_zone_t *zp, *nextzp; - snd_sf_sample_t *sp, *nextsp; + struct snd_soundfont *sf, *nextsf; + struct snd_sf_zone *zp, *nextzp; + struct snd_sf_sample *sp, *nextsp; for (sf = sflist->fonts; sf; sf = nextsf) { nextsf = sf->next; @@ -1344,7 +1368,8 @@ snd_sf_clear(snd_sf_list_t *sflist) for (sp = sf->samples; sp; sp = nextsp) { nextsp = sp->next; if (sflist->callback.sample_free) - sflist->callback.sample_free(sflist->callback.private_data, sp, sflist->memhdr); + sflist->callback.sample_free(sflist->callback.private_data, + sp, sflist->memhdr); kfree(sp); } kfree(sf); @@ -1357,10 +1382,10 @@ snd_sf_clear(snd_sf_list_t *sflist) /* * Create a new sflist structure */ -snd_sf_list_t * -snd_sf_new(snd_sf_callback_t *callback, snd_util_memhdr_t *hdr) +struct snd_sf_list * +snd_sf_new(struct snd_sf_callback *callback, struct snd_util_memhdr *hdr) { - snd_sf_list_t *sflist; + struct snd_sf_list *sflist; if ((sflist = kzalloc(sizeof(*sflist), GFP_KERNEL)) == NULL) return NULL; @@ -1381,7 +1406,7 @@ snd_sf_new(snd_sf_callback_t *callback, snd_util_memhdr_t *hdr) * Free everything allocated off the sflist structure. */ void -snd_sf_free(snd_sf_list_t *sflist) +snd_sf_free(struct snd_sf_list *sflist) { if (sflist == NULL) return; @@ -1400,7 +1425,7 @@ snd_sf_free(snd_sf_list_t *sflist) * The soundcard should be silet before calling this function. */ int -snd_soundfont_remove_samples(snd_sf_list_t *sflist) +snd_soundfont_remove_samples(struct snd_sf_list *sflist) { lock_preset(sflist); if (sflist->callback.sample_reset) @@ -1416,11 +1441,11 @@ snd_soundfont_remove_samples(snd_sf_list_t *sflist) * The soundcard should be silent before calling this function. */ int -snd_soundfont_remove_unlocked(snd_sf_list_t *sflist) +snd_soundfont_remove_unlocked(struct snd_sf_list *sflist) { - snd_soundfont_t *sf; - snd_sf_zone_t *zp, *nextzp; - snd_sf_sample_t *sp, *nextsp; + struct snd_soundfont *sf; + struct snd_sf_zone *zp, *nextzp; + struct snd_sf_sample *sp, *nextsp; lock_preset(sflist); @@ -1446,7 +1471,8 @@ snd_soundfont_remove_unlocked(snd_sf_list_t *sflist) sf->samples = nextsp; sflist->mem_used -= sp->v.truesize; if (sflist->callback.sample_free) - sflist->callback.sample_free(sflist->callback.private_data, sp, sflist->memhdr); + sflist->callback.sample_free(sflist->callback.private_data, + sp, sflist->memhdr); kfree(sp); } } diff --git a/sound/synth/util_mem.c b/sound/synth/util_mem.c index 5f75bf3..217e8e5 100644 --- a/sound/synth/util_mem.c +++ b/sound/synth/util_mem.c @@ -28,15 +28,15 @@ MODULE_AUTHOR("Takashi Iwai"); MODULE_DESCRIPTION("Generic memory management routines for soundcard memory allocation"); MODULE_LICENSE("GPL"); -#define get_memblk(p) list_entry(p, snd_util_memblk_t, list) +#define get_memblk(p) list_entry(p, struct snd_util_memblk, list) /* * create a new memory manager */ -snd_util_memhdr_t * +struct snd_util_memhdr * snd_util_memhdr_new(int memsize) { - snd_util_memhdr_t *hdr; + struct snd_util_memhdr *hdr; hdr = kzalloc(sizeof(*hdr), GFP_KERNEL); if (hdr == NULL) @@ -51,7 +51,7 @@ snd_util_memhdr_new(int memsize) /* * free a memory manager */ -void snd_util_memhdr_free(snd_util_memhdr_t *hdr) +void snd_util_memhdr_free(struct snd_util_memhdr *hdr) { struct list_head *p; @@ -67,11 +67,11 @@ void snd_util_memhdr_free(snd_util_memhdr_t *hdr) /* * allocate a memory block (without mutex) */ -snd_util_memblk_t * -__snd_util_mem_alloc(snd_util_memhdr_t *hdr, int size) +struct snd_util_memblk * +__snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size) { - snd_util_memblk_t *blk; - snd_util_unit_t units, prev_offset; + struct snd_util_memblk *blk; + unsigned int units, prev_offset; struct list_head *p; snd_assert(hdr != NULL, return NULL); @@ -104,20 +104,21 @@ __found: * create a new memory block with the given size * the block is linked next to prev */ -snd_util_memblk_t * -__snd_util_memblk_new(snd_util_memhdr_t *hdr, snd_util_unit_t units, +struct snd_util_memblk * +__snd_util_memblk_new(struct snd_util_memhdr *hdr, unsigned int units, struct list_head *prev) { - snd_util_memblk_t *blk; + struct snd_util_memblk *blk; - blk = kmalloc(sizeof(snd_util_memblk_t) + hdr->block_extra_size, GFP_KERNEL); + blk = kmalloc(sizeof(struct snd_util_memblk) + hdr->block_extra_size, + GFP_KERNEL); if (blk == NULL) return NULL; if (! prev || prev == &hdr->block) blk->offset = 0; else { - snd_util_memblk_t *p = get_memblk(prev); + struct snd_util_memblk *p = get_memblk(prev); blk->offset = p->offset + p->size; } blk->size = units; @@ -131,10 +132,10 @@ __snd_util_memblk_new(snd_util_memhdr_t *hdr, snd_util_unit_t units, /* * allocate a memory block (with mutex) */ -snd_util_memblk_t * -snd_util_mem_alloc(snd_util_memhdr_t *hdr, int size) +struct snd_util_memblk * +snd_util_mem_alloc(struct snd_util_memhdr *hdr, int size) { - snd_util_memblk_t *blk; + struct snd_util_memblk *blk; down(&hdr->block_mutex); blk = __snd_util_mem_alloc(hdr, size); up(&hdr->block_mutex); @@ -147,7 +148,7 @@ snd_util_mem_alloc(snd_util_memhdr_t *hdr, int size) * (without mutex) */ void -__snd_util_mem_free(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk) +__snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk) { list_del(&blk->list); hdr->nblocks--; @@ -158,7 +159,7 @@ __snd_util_mem_free(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk) /* * free a memory block (with mutex) */ -int snd_util_mem_free(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk) +int snd_util_mem_free(struct snd_util_memhdr *hdr, struct snd_util_memblk *blk) { snd_assert(hdr && blk, return -EINVAL); @@ -171,7 +172,7 @@ int snd_util_mem_free(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk) /* * return available memory size */ -int snd_util_mem_avail(snd_util_memhdr_t *hdr) +int snd_util_mem_avail(struct snd_util_memhdr *hdr) { unsigned int size; down(&hdr->block_mutex); -- cgit v1.1 From 4a4d2cfd8cbca3076742547157ea135d0be77928 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:27:28 +0100 Subject: [ALSA] Remove xxx_t typedefs: Generic drivers Modules: Generic drivers Remove xxx_t typedefs from the generic drivers (dummy, mtpav, serial-u16550 and virmidi). Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/drivers/dummy.c | 124 ++++++++++++++++++++++-------------------- sound/drivers/mtpav.c | 38 ++++++------- sound/drivers/serial-u16550.c | 46 ++++++++-------- sound/drivers/virmidi.c | 16 +++--- 4 files changed, 115 insertions(+), 109 deletions(-) diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 8dfe5d4..9c827b1 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -42,7 +42,7 @@ MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}"); #if 0 /* emu10k1 emulation */ #define MAX_BUFFER_SIZE (128 * 1024) -static int emu10k1_playback_constraints(snd_pcm_runtime_t *runtime) +static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) { int err; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) @@ -149,15 +149,15 @@ MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver."); #define MIXER_ADDR_CD 4 #define MIXER_ADDR_LAST 4 -typedef struct snd_card_dummy { - snd_card_t *card; +struct snd_dummy { + struct snd_card *card; spinlock_t mixer_lock; int mixer_volume[MIXER_ADDR_LAST+1][2]; int capture_source[MIXER_ADDR_LAST+1][2]; -} snd_card_dummy_t; +}; -typedef struct snd_card_dummy_pcm { - snd_card_dummy_t *dummy; +struct snd_dummy_pcm { + struct snd_dummy *dummy; spinlock_t lock; struct timer_list timer; unsigned int pcm_size; @@ -166,27 +166,27 @@ typedef struct snd_card_dummy_pcm { unsigned int pcm_jiffie; /* bytes per one jiffie */ unsigned int pcm_irq_pos; /* IRQ position */ unsigned int pcm_buf_pos; /* position in buffer */ - snd_pcm_substream_t *substream; -} snd_card_dummy_pcm_t; + struct snd_pcm_substream *substream; +}; -static snd_card_t *snd_dummy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_dummy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; -static inline void snd_card_dummy_pcm_timer_start(snd_card_dummy_pcm_t *dpcm) +static inline void snd_card_dummy_pcm_timer_start(struct snd_dummy_pcm *dpcm) { dpcm->timer.expires = 1 + jiffies; add_timer(&dpcm->timer); } -static inline void snd_card_dummy_pcm_timer_stop(snd_card_dummy_pcm_t *dpcm) +static inline void snd_card_dummy_pcm_timer_stop(struct snd_dummy_pcm *dpcm) { del_timer(&dpcm->timer); } -static int snd_card_dummy_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_card_dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_dummy_card_pcm_t *dpcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_dummy_pcm *dpcm = runtime->private_data; int err = 0; spin_lock(&dpcm->lock); @@ -201,10 +201,10 @@ static int snd_card_dummy_pcm_trigger(snd_pcm_substream_t *substream, int cmd) return err; } -static int snd_card_dummy_pcm_prepare(snd_pcm_substream_t * substream) +static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_card_dummy_pcm_t *dpcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_dummy_pcm *dpcm = runtime->private_data; unsigned int bps; bps = runtime->rate * runtime->channels; @@ -223,7 +223,7 @@ static int snd_card_dummy_pcm_prepare(snd_pcm_substream_t * substream) static void snd_card_dummy_pcm_timer_function(unsigned long data) { - snd_card_dummy_pcm_t *dpcm = (snd_card_dummy_pcm_t *)data; + struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data; spin_lock(&dpcm->lock); dpcm->timer.expires = 1 + jiffies; @@ -240,15 +240,15 @@ static void snd_card_dummy_pcm_timer_function(unsigned long data) spin_unlock(&dpcm->lock); } -static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_card_dummy_pcm_t *dpcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_dummy_pcm *dpcm = runtime->private_data; return bytes_to_frames(runtime, dpcm->pcm_buf_pos); } -static snd_pcm_hardware_t snd_card_dummy_playback = +static struct snd_pcm_hardware snd_card_dummy_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -266,7 +266,7 @@ static snd_pcm_hardware_t snd_card_dummy_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_card_dummy_capture = +static struct snd_pcm_hardware snd_card_dummy_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -284,25 +284,25 @@ static snd_pcm_hardware_t snd_card_dummy_capture = .fifo_size = 0, }; -static void snd_card_dummy_runtime_free(snd_pcm_runtime_t *runtime) +static void snd_card_dummy_runtime_free(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static int snd_card_dummy_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_card_dummy_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_card_dummy_hw_free(snd_pcm_substream_t * substream) +static int snd_card_dummy_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static snd_card_dummy_pcm_t *new_pcm_stream(snd_pcm_substream_t *substream) +static struct snd_dummy_pcm *new_pcm_stream(struct snd_pcm_substream *substream) { - snd_card_dummy_pcm_t *dpcm; + struct snd_dummy_pcm *dpcm; dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); if (! dpcm) @@ -315,10 +315,10 @@ static snd_card_dummy_pcm_t *new_pcm_stream(snd_pcm_substream_t *substream) return dpcm; } -static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream) +static int snd_card_dummy_playback_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_card_dummy_pcm_t *dpcm; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_dummy_pcm *dpcm; int err; if ((dpcm = new_pcm_stream(substream)) == NULL) @@ -340,10 +340,10 @@ static int snd_card_dummy_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_card_dummy_capture_open(snd_pcm_substream_t * substream) +static int snd_card_dummy_capture_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_card_dummy_pcm_t *dpcm; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_dummy_pcm *dpcm; int err; if ((dpcm = new_pcm_stream(substream)) == NULL) @@ -365,17 +365,17 @@ static int snd_card_dummy_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_card_dummy_playback_close(snd_pcm_substream_t * substream) +static int snd_card_dummy_playback_close(struct snd_pcm_substream *substream) { return 0; } -static int snd_card_dummy_capture_close(snd_pcm_substream_t * substream) +static int snd_card_dummy_capture_close(struct snd_pcm_substream *substream) { return 0; } -static snd_pcm_ops_t snd_card_dummy_playback_ops = { +static struct snd_pcm_ops snd_card_dummy_playback_ops = { .open = snd_card_dummy_playback_open, .close = snd_card_dummy_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -386,7 +386,7 @@ static snd_pcm_ops_t snd_card_dummy_playback_ops = { .pointer = snd_card_dummy_pcm_pointer, }; -static snd_pcm_ops_t snd_card_dummy_capture_ops = { +static struct snd_pcm_ops snd_card_dummy_capture_ops = { .open = snd_card_dummy_capture_open, .close = snd_card_dummy_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -397,12 +397,13 @@ static snd_pcm_ops_t snd_card_dummy_capture_ops = { .pointer = snd_card_dummy_pcm_pointer, }; -static int __init snd_card_dummy_pcm(snd_card_dummy_t *dummy, int device, int substreams) +static int __init snd_card_dummy_pcm(struct snd_dummy *dummy, int device, int substreams) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; - if ((err = snd_pcm_new(dummy->card, "Dummy PCM", device, substreams, substreams, &pcm)) < 0) + if ((err = snd_pcm_new(dummy->card, "Dummy PCM", device, + substreams, substreams, &pcm)) < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_dummy_capture_ops); @@ -421,7 +422,8 @@ static int __init snd_card_dummy_pcm(snd_card_dummy_t *dummy, int device, int su .get = snd_dummy_volume_get, .put = snd_dummy_volume_put, \ .private_value = addr } -static int snd_dummy_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_dummy_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -430,9 +432,10 @@ static int snd_dummy_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_dummy_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_dummy_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_card_dummy_t *dummy = snd_kcontrol_chip(kcontrol); + struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol); int addr = kcontrol->private_value; spin_lock_irq(&dummy->mixer_lock); @@ -442,9 +445,10 @@ static int snd_dummy_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_dummy_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_dummy_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_card_dummy_t *dummy = snd_kcontrol_chip(kcontrol); + struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol); int change, addr = kcontrol->private_value; int left, right; @@ -473,7 +477,8 @@ static int snd_dummy_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_dummy_capsrc_get, .put = snd_dummy_capsrc_put, \ .private_value = addr } -static int snd_dummy_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_dummy_capsrc_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -482,9 +487,10 @@ static int snd_dummy_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_dummy_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_dummy_capsrc_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_card_dummy_t *dummy = snd_kcontrol_chip(kcontrol); + struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol); int addr = kcontrol->private_value; spin_lock_irq(&dummy->mixer_lock); @@ -494,9 +500,9 @@ static int snd_dummy_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_dummy_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_card_dummy_t *dummy = snd_kcontrol_chip(kcontrol); + struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol); int change, addr = kcontrol->private_value; int left, right; @@ -511,7 +517,7 @@ static int snd_dummy_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_dummy_controls[] = { +static struct snd_kcontrol_new snd_dummy_controls[] = { DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER), DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER), DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH), @@ -524,9 +530,9 @@ DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD), DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_MASTER) }; -static int __init snd_card_dummy_new_mixer(snd_card_dummy_t * dummy) +static int __init snd_card_dummy_new_mixer(struct snd_dummy *dummy) { - snd_card_t *card = dummy->card; + struct snd_card *card = dummy->card; unsigned int idx; int err; @@ -543,17 +549,17 @@ static int __init snd_card_dummy_new_mixer(snd_card_dummy_t * dummy) static int __init snd_card_dummy_probe(int dev) { - snd_card_t *card; - struct snd_card_dummy *dummy; + struct snd_card *card; + struct snd_dummy *dummy; int idx, err; if (!enable[dev]) return -ENODEV; card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_dummy)); + sizeof(struct snd_dummy)); if (card == NULL) return -ENOMEM; - dummy = (struct snd_card_dummy *)card->private_data; + dummy = card->private_data; dummy->card = card; for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) { if (pcm_substreams[dev] < 1) diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index e9d52c6..d32d5f6 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -130,12 +130,12 @@ typedef struct mtpav_port { u8 hwport; u8 mode; u8 running_status; - snd_rawmidi_substream_t *input; - snd_rawmidi_substream_t *output; + struct snd_rawmidi_substream *input; + struct snd_rawmidi_substream *output; } mtpav_port_t; typedef struct mtpav { - snd_card_t *card; + struct snd_card *card; unsigned long port; struct resource *res_port; int irq; /* interrupt (for inputs) */ @@ -143,7 +143,7 @@ typedef struct mtpav { int share_irq; /* number of accesses to input interrupts */ int istimer; /* number of accesses to timer interrupts */ struct timer_list timer; /* timer interrupts for outputs */ - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int num_ports; /* number of hw ports (1-8) */ mtpav_port_t ports[NUMPORTS]; /* all ports including computer, adat and bc */ @@ -292,7 +292,7 @@ static void snd_mtpav_send_byte(mtpav_t *chip, u8 byte) /* call this with spin lock held */ static void snd_mtpav_output_port_write(mtpav_port_t *port, - snd_rawmidi_substream_t *substream) + struct snd_rawmidi_substream *substream) { u8 outbyte; @@ -324,7 +324,7 @@ static void snd_mtpav_output_port_write(mtpav_port_t *port, } while (snd_rawmidi_transmit(substream, &outbyte, 1) == 1); } -static void snd_mtpav_output_write(snd_rawmidi_substream_t * substream) +static void snd_mtpav_output_write(struct snd_rawmidi_substream *substream) { mtpav_port_t *port = &mtp_card->ports[substream->number]; unsigned long flags; @@ -353,7 +353,7 @@ static void snd_mtpav_portscan(mtpav_t *chip) // put mtp into smart routing mode /* */ -static int snd_mtpav_input_open(snd_rawmidi_substream_t * substream) +static int snd_mtpav_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; mtpav_port_t *portp = &mtp_card->ports[substream->number]; @@ -371,7 +371,7 @@ static int snd_mtpav_input_open(snd_rawmidi_substream_t * substream) /* */ -static int snd_mtpav_input_close(snd_rawmidi_substream_t *substream) +static int snd_mtpav_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; mtpav_port_t *portp = &mtp_card->ports[substream->number]; @@ -392,7 +392,7 @@ static int snd_mtpav_input_close(snd_rawmidi_substream_t *substream) /* */ -static void snd_mtpav_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_mtpav_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; mtpav_port_t *portp = &mtp_card->ports[substream->number]; @@ -449,7 +449,7 @@ static void snd_mtpav_remove_output_timer(mtpav_t *chip) /* */ -static int snd_mtpav_output_open(snd_rawmidi_substream_t * substream) +static int snd_mtpav_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; mtpav_port_t *portp = &mtp_card->ports[substream->number]; @@ -464,7 +464,7 @@ static int snd_mtpav_output_open(snd_rawmidi_substream_t * substream) /* */ -static int snd_mtpav_output_close(snd_rawmidi_substream_t * substream) +static int snd_mtpav_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; mtpav_port_t *portp = &mtp_card->ports[substream->number]; @@ -479,7 +479,7 @@ static int snd_mtpav_output_close(snd_rawmidi_substream_t * substream) /* */ -static void snd_mtpav_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_mtpav_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; mtpav_port_t *portp = &mtp_card->ports[substream->number]; @@ -611,13 +611,13 @@ static int snd_mtpav_get_ISA(mtpav_t * mcard) /* */ -static snd_rawmidi_ops_t snd_mtpav_output = { +static struct snd_rawmidi_ops snd_mtpav_output = { .open = snd_mtpav_output_open, .close = snd_mtpav_output_close, .trigger = snd_mtpav_output_trigger, }; -static snd_rawmidi_ops_t snd_mtpav_input = { +static struct snd_rawmidi_ops snd_mtpav_input = { .open = snd_mtpav_input_open, .close = snd_mtpav_input_close, .trigger = snd_mtpav_input_trigger, @@ -628,7 +628,7 @@ static snd_rawmidi_ops_t snd_mtpav_input = { * get RAWMIDI resources */ -static void snd_mtpav_set_name(mtpav_t *chip, snd_rawmidi_substream_t *substream) +static void snd_mtpav_set_name(mtpav_t *chip, struct snd_rawmidi_substream *substream) { if (substream->number >= 0 && substream->number < chip->num_ports) sprintf(substream->name, "MTP direct %d", (substream->number % chip->num_ports) + 1); @@ -645,8 +645,8 @@ static void snd_mtpav_set_name(mtpav_t *chip, snd_rawmidi_substream_t *substream static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) { int rval = 0; - snd_rawmidi_t *rawmidi; - snd_rawmidi_substream_t *substream; + struct snd_rawmidi *rawmidi; + struct snd_rawmidi_substream *substream; struct list_head *list; //printk("entering snd_mtpav_get_RAWMIDI\n"); @@ -666,12 +666,12 @@ static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) rawmidi = mcard->rmidi; list_for_each(list, &rawmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); snd_mtpav_set_name(mcard, substream); substream->ops = &snd_mtpav_input; } list_for_each(list, &rawmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); snd_mtpav_set_name(mcard, substream); substream->ops = &snd_mtpav_output; mcard->ports[substream->number].hwport = translate_subdevice_to_hwport(mcard, substream->number); diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 1ed58df..ec285872 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -116,10 +116,10 @@ MODULE_PARM_DESC(adaptor, "Type of adaptor."); #define SERIAL_MODE_OUTPUT_TRIGGERED (1 << 3) typedef struct _snd_uart16550 { - snd_card_t *card; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *midi_output[SNDRV_SERIAL_MAX_OUTS]; - snd_rawmidi_substream_t *midi_input[SNDRV_SERIAL_MAX_INS]; + struct snd_card *card; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *midi_output[SNDRV_SERIAL_MAX_OUTS]; + struct snd_rawmidi_substream *midi_input[SNDRV_SERIAL_MAX_INS]; int filemode; //open status of file @@ -166,7 +166,7 @@ typedef struct _snd_uart16550 { } snd_uart16550_t; -static snd_card_t *snd_serial_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_serial_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static inline void snd_uart16550_add_timer(snd_uart16550_t *uart) { @@ -509,7 +509,7 @@ static void snd_uart16550_do_close(snd_uart16550_t * uart) } } -static int snd_uart16550_input_open(snd_rawmidi_substream_t * substream) +static int snd_uart16550_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_uart16550_t *uart = substream->rmidi->private_data; @@ -523,7 +523,7 @@ static int snd_uart16550_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_uart16550_input_close(snd_rawmidi_substream_t * substream) +static int snd_uart16550_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_uart16550_t *uart = substream->rmidi->private_data; @@ -537,7 +537,7 @@ static int snd_uart16550_input_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_uart16550_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_uart16550_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; snd_uart16550_t *uart = substream->rmidi->private_data; @@ -551,7 +551,7 @@ static void snd_uart16550_input_trigger(snd_rawmidi_substream_t * substream, int spin_unlock_irqrestore(&uart->open_lock, flags); } -static int snd_uart16550_output_open(snd_rawmidi_substream_t * substream) +static int snd_uart16550_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_uart16550_t *uart = substream->rmidi->private_data; @@ -565,7 +565,7 @@ static int snd_uart16550_output_open(snd_rawmidi_substream_t * substream) return 0; }; -static int snd_uart16550_output_close(snd_rawmidi_substream_t * substream) +static int snd_uart16550_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_uart16550_t *uart = substream->rmidi->private_data; @@ -603,7 +603,7 @@ static inline int snd_uart16550_write_buffer(snd_uart16550_t *uart, unsigned cha return 0; } -static int snd_uart16550_output_byte(snd_uart16550_t *uart, snd_rawmidi_substream_t * substream, unsigned char midi_byte) +static int snd_uart16550_output_byte(snd_uart16550_t *uart, struct snd_rawmidi_substream *substream, unsigned char midi_byte) { if (uart->buff_in_count == 0 /* Buffer empty? */ && ((uart->adaptor != SNDRV_SERIAL_MS124W_SA && @@ -636,7 +636,7 @@ static int snd_uart16550_output_byte(snd_uart16550_t *uart, snd_rawmidi_substrea return 1; } -static void snd_uart16550_output_write(snd_rawmidi_substream_t * substream) +static void snd_uart16550_output_write(struct snd_rawmidi_substream *substream) { unsigned long flags; unsigned char midi_byte, addr_byte; @@ -715,7 +715,7 @@ static void snd_uart16550_output_write(snd_rawmidi_substream_t * substream) spin_unlock_irqrestore(&uart->open_lock, flags); } -static void snd_uart16550_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_uart16550_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; snd_uart16550_t *uart = substream->rmidi->private_data; @@ -731,14 +731,14 @@ static void snd_uart16550_output_trigger(snd_rawmidi_substream_t * substream, in snd_uart16550_output_write(substream); } -static snd_rawmidi_ops_t snd_uart16550_output = +static struct snd_rawmidi_ops snd_uart16550_output = { .open = snd_uart16550_output_open, .close = snd_uart16550_output_close, .trigger = snd_uart16550_output_trigger, }; -static snd_rawmidi_ops_t snd_uart16550_input = +static struct snd_rawmidi_ops snd_uart16550_input = { .open = snd_uart16550_input_open, .close = snd_uart16550_input_close, @@ -754,13 +754,13 @@ static int snd_uart16550_free(snd_uart16550_t *uart) return 0; }; -static int snd_uart16550_dev_free(snd_device_t *device) +static int snd_uart16550_dev_free(struct snd_device *device) { snd_uart16550_t *uart = device->device_data; return snd_uart16550_free(uart); } -static int __init snd_uart16550_create(snd_card_t * card, +static int __init snd_uart16550_create(struct snd_card *card, unsigned long iobase, int irq, unsigned int speed, @@ -769,7 +769,7 @@ static int __init snd_uart16550_create(snd_card_t * card, int droponfull, snd_uart16550_t **ruart) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_uart16550_dev_free, }; snd_uart16550_t *uart; @@ -838,19 +838,19 @@ static int __init snd_uart16550_create(snd_card_t * card, return 0; } -static void __init snd_uart16550_substreams(snd_rawmidi_str_t *stream) +static void __init snd_uart16550_substreams(struct snd_rawmidi_str *stream) { struct list_head *list; list_for_each(list, &stream->substreams) { - snd_rawmidi_substream_t *substream = list_entry(list, snd_rawmidi_substream_t, list); + struct snd_rawmidi_substream *substream = list_entry(list, struct snd_rawmidi_substream, list); sprintf(substream->name, "Serial MIDI %d", substream->number + 1); } } -static int __init snd_uart16550_rmidi(snd_uart16550_t *uart, int device, int outs, int ins, snd_rawmidi_t **rmidi) +static int __init snd_uart16550_rmidi(snd_uart16550_t *uart, int device, int outs, int ins, struct snd_rawmidi **rmidi) { - snd_rawmidi_t *rrawmidi; + struct snd_rawmidi *rrawmidi; int err; if ((err = snd_rawmidi_new(uart->card, "UART Serial MIDI", device, outs, ins, &rrawmidi)) < 0) @@ -871,7 +871,7 @@ static int __init snd_uart16550_rmidi(snd_uart16550_t *uart, int device, int out static int __init snd_serial_probe(int dev) { - snd_card_t *card; + struct snd_card *card; snd_uart16550_t *uart; int err; diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index af12185..0d2cc6e 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -75,17 +75,17 @@ MODULE_PARM_DESC(enable, "Enable this soundcard."); module_param_array(midi_devs, int, NULL, 0444); MODULE_PARM_DESC(midi_devs, "MIDI devices # (1-8)"); -typedef struct snd_card_virmidi { - snd_card_t *card; - snd_rawmidi_t *midi[MAX_MIDI_DEVICES]; -} snd_card_virmidi_t; +struct snd_card_virmidi { + struct snd_card *card; + struct snd_rawmidi *midi[MAX_MIDI_DEVICES]; +}; -static snd_card_t *snd_virmidi_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_virmidi_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static int __init snd_card_virmidi_probe(int dev) { - snd_card_t *card; + struct snd_card *card; struct snd_card_virmidi *vmidi; int idx, err; @@ -103,8 +103,8 @@ static int __init snd_card_virmidi_probe(int dev) midi_devs[dev] = MAX_MIDI_DEVICES; } for (idx = 0; idx < midi_devs[dev]; idx++) { - snd_rawmidi_t *rmidi; - snd_virmidi_dev_t *rdev; + struct snd_rawmidi *rmidi; + struct snd_virmidi_dev *rdev; if ((err = snd_virmidi_new(card, idx, &rmidi)) < 0) goto __nodev; rdev = rmidi->private_data; -- cgit v1.1 From cbdd0dd15f06a989c519089bb24023a5bfa66eaf Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:28:35 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA AD1816A Modules: AD1816A driver Remove xxx_t typedefs from the ISA AD1816A driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/ad1816a.h | 22 +++-- sound/isa/ad1816a/ad1816a.c | 8 +- sound/isa/ad1816a/ad1816a_lib.c | 176 ++++++++++++++++++++-------------------- 3 files changed, 102 insertions(+), 104 deletions(-) diff --git a/include/sound/ad1816a.h b/include/sound/ad1816a.h index ca2e0e4..b3aa62e 100644 --- a/include/sound/ad1816a.h +++ b/include/sound/ad1816a.h @@ -123,9 +123,7 @@ #define AD1816A_CAPTURE_NOT_EQUAL 0x1000 #define AD1816A_WSS_ENABLE 0x8000 -typedef struct _snd_ad1816a ad1816a_t; - -struct _snd_ad1816a { +struct snd_ad1816a { unsigned long port; struct resource *res_port; int irq; @@ -140,15 +138,15 @@ struct _snd_ad1816a { unsigned short mode; unsigned int clock_freq; - snd_card_t *card; - snd_pcm_t *pcm; + struct snd_card *card; + struct snd_pcm *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; unsigned int p_dma_size; unsigned int c_dma_size; - snd_timer_t *timer; + struct snd_timer *timer; }; @@ -165,11 +163,11 @@ struct _snd_ad1816a { AD1816A_MODE_TIMER) -extern int snd_ad1816a_create(snd_card_t *card, unsigned long port, +extern int snd_ad1816a_create(struct snd_card *card, unsigned long port, int irq, int dma1, int dma2, - ad1816a_t **chip); + struct snd_ad1816a **chip); -extern int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm); -extern int snd_ad1816a_mixer(ad1816a_t *chip); +extern int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm); +extern int snd_ad1816a_mixer(struct snd_ad1816a *chip); #endif /* __SOUND_AD1816A_H */ diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index 0eb442c..543a4e2 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -188,10 +188,10 @@ static int __devinit snd_card_ad1816a_probe(int dev, struct pnp_card_link *pcard const struct pnp_card_device_id *pid) { int error; - snd_card_t *card; + struct snd_card *card; struct snd_card_ad1816a *acard; - ad1816a_t *chip; - opl3_t *opl3; + struct snd_ad1816a *chip; + struct snd_opl3 *opl3; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_ad1816a))) == NULL) @@ -282,7 +282,7 @@ static int __devinit snd_ad1816a_pnp_detect(struct pnp_card_link *card, static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 170409e..89d11af 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -34,7 +34,7 @@ MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>"); MODULE_DESCRIPTION("lowlevel code for Analog Devices AD1816A chip"); MODULE_LICENSE("GPL"); -static inline int snd_ad1816a_busy_wait(ad1816a_t *chip) +static inline int snd_ad1816a_busy_wait(struct snd_ad1816a *chip) { int timeout; @@ -46,34 +46,34 @@ static inline int snd_ad1816a_busy_wait(ad1816a_t *chip) return -EBUSY; } -static inline unsigned char snd_ad1816a_in(ad1816a_t *chip, unsigned char reg) +static inline unsigned char snd_ad1816a_in(struct snd_ad1816a *chip, unsigned char reg) { snd_ad1816a_busy_wait(chip); return inb(AD1816A_REG(reg)); } -static inline void snd_ad1816a_out(ad1816a_t *chip, unsigned char reg, +static inline void snd_ad1816a_out(struct snd_ad1816a *chip, unsigned char reg, unsigned char value) { snd_ad1816a_busy_wait(chip); outb(value, AD1816A_REG(reg)); } -static inline void snd_ad1816a_out_mask(ad1816a_t *chip, unsigned char reg, +static inline void snd_ad1816a_out_mask(struct snd_ad1816a *chip, unsigned char reg, unsigned char mask, unsigned char value) { snd_ad1816a_out(chip, reg, (value & mask) | (snd_ad1816a_in(chip, reg) & ~mask)); } -static unsigned short snd_ad1816a_read(ad1816a_t *chip, unsigned char reg) +static unsigned short snd_ad1816a_read(struct snd_ad1816a *chip, unsigned char reg) { snd_ad1816a_out(chip, AD1816A_INDIR_ADDR, reg & 0x3f); return snd_ad1816a_in(chip, AD1816A_INDIR_DATA_LOW) | (snd_ad1816a_in(chip, AD1816A_INDIR_DATA_HIGH) << 8); } -static void snd_ad1816a_write(ad1816a_t *chip, unsigned char reg, +static void snd_ad1816a_write(struct snd_ad1816a *chip, unsigned char reg, unsigned short value) { snd_ad1816a_out(chip, AD1816A_INDIR_ADDR, reg & 0x3f); @@ -81,7 +81,7 @@ static void snd_ad1816a_write(ad1816a_t *chip, unsigned char reg, snd_ad1816a_out(chip, AD1816A_INDIR_DATA_HIGH, (value >> 8) & 0xff); } -static void snd_ad1816a_write_mask(ad1816a_t *chip, unsigned char reg, +static void snd_ad1816a_write_mask(struct snd_ad1816a *chip, unsigned char reg, unsigned short mask, unsigned short value) { snd_ad1816a_write(chip, reg, @@ -89,7 +89,7 @@ static void snd_ad1816a_write_mask(ad1816a_t *chip, unsigned char reg, } -static unsigned char snd_ad1816a_get_format(ad1816a_t *chip, +static unsigned char snd_ad1816a_get_format(struct snd_ad1816a *chip, unsigned int format, int channels) { unsigned char retval = AD1816A_FMT_LINEAR_8; @@ -110,7 +110,7 @@ static unsigned char snd_ad1816a_get_format(ad1816a_t *chip, return (channels > 1) ? (retval | AD1816A_FMT_STEREO) : retval; } -static int snd_ad1816a_open(ad1816a_t *chip, unsigned int mode) +static int snd_ad1816a_open(struct snd_ad1816a *chip, unsigned int mode) { unsigned long flags; @@ -146,7 +146,7 @@ static int snd_ad1816a_open(ad1816a_t *chip, unsigned int mode) return 0; } -static void snd_ad1816a_close(ad1816a_t *chip, unsigned int mode) +static void snd_ad1816a_close(struct snd_ad1816a *chip, unsigned int mode) { unsigned long flags; @@ -178,7 +178,7 @@ static void snd_ad1816a_close(ad1816a_t *chip, unsigned int mode) } -static int snd_ad1816a_trigger(ad1816a_t *chip, unsigned char what, +static int snd_ad1816a_trigger(struct snd_ad1816a *chip, unsigned char what, int channel, int cmd) { int error = 0; @@ -204,36 +204,36 @@ static int snd_ad1816a_trigger(ad1816a_t *chip, unsigned char what, return error; } -static int snd_ad1816a_playback_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_ad1816a_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); return snd_ad1816a_trigger(chip, AD1816A_PLAYBACK_ENABLE, SNDRV_PCM_STREAM_PLAYBACK, cmd); } -static int snd_ad1816a_capture_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_ad1816a_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); return snd_ad1816a_trigger(chip, AD1816A_CAPTURE_ENABLE, SNDRV_PCM_STREAM_CAPTURE, cmd); } -static int snd_ad1816a_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ad1816a_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_ad1816a_hw_free(snd_pcm_substream_t * substream) +static int snd_ad1816a_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream) +static int snd_ad1816a_playback_prepare(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); unsigned long flags; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size, rate; spin_lock_irqsave(&chip->lock, flags); @@ -261,11 +261,11 @@ static int snd_ad1816a_playback_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream) +static int snd_ad1816a_capture_prepare(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); unsigned long flags; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size, rate; spin_lock_irqsave(&chip->lock, flags); @@ -294,9 +294,9 @@ static int snd_ad1816a_capture_prepare(snd_pcm_substream_t *substream) } -static snd_pcm_uframes_t snd_ad1816a_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_ad1816a_playback_pointer(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->mode & AD1816A_MODE_PLAYBACK)) return 0; @@ -304,9 +304,9 @@ static snd_pcm_uframes_t snd_ad1816a_playback_pointer(snd_pcm_substream_t *subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_ad1816a_capture_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_ad1816a_capture_pointer(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->mode & AD1816A_MODE_CAPTURE)) return 0; @@ -317,7 +317,7 @@ static snd_pcm_uframes_t snd_ad1816a_capture_pointer(snd_pcm_substream_t *substr static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ad1816a_t *chip = dev_id; + struct snd_ad1816a *chip = dev_id; unsigned char status; spin_lock(&chip->lock); @@ -340,7 +340,7 @@ static irqreturn_t snd_ad1816a_interrupt(int irq, void *dev_id, struct pt_regs * } -static snd_pcm_hardware_t snd_ad1816a_playback = { +static struct snd_pcm_hardware snd_ad1816a_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | @@ -359,7 +359,7 @@ static snd_pcm_hardware_t snd_ad1816a_playback = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ad1816a_capture = { +static struct snd_pcm_hardware snd_ad1816a_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | @@ -379,32 +379,32 @@ static snd_pcm_hardware_t snd_ad1816a_capture = { }; #if 0 /* not used now */ -static int snd_ad1816a_timer_close(snd_timer_t *timer) +static int snd_ad1816a_timer_close(struct snd_timer *timer) { - ad1816a_t *chip = snd_timer_chip(timer); + struct snd_ad1816a *chip = snd_timer_chip(timer); snd_ad1816a_close(chip, AD1816A_MODE_TIMER); return 0; } -static int snd_ad1816a_timer_open(snd_timer_t *timer) +static int snd_ad1816a_timer_open(struct snd_timer *timer) { - ad1816a_t *chip = snd_timer_chip(timer); + struct snd_ad1816a *chip = snd_timer_chip(timer); snd_ad1816a_open(chip, AD1816A_MODE_TIMER); return 0; } -static unsigned long snd_ad1816a_timer_resolution(snd_timer_t *timer) +static unsigned long snd_ad1816a_timer_resolution(struct snd_timer *timer) { snd_assert(timer != NULL, return 0); return 10000; } -static int snd_ad1816a_timer_start(snd_timer_t *timer) +static int snd_ad1816a_timer_start(struct snd_timer *timer) { unsigned short bits; unsigned long flags; - ad1816a_t *chip = snd_timer_chip(timer); + struct snd_ad1816a *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->lock, flags); bits = snd_ad1816a_read(chip, AD1816A_INTERRUPT_ENABLE); @@ -419,10 +419,10 @@ static int snd_ad1816a_timer_start(snd_timer_t *timer) return 0; } -static int snd_ad1816a_timer_stop(snd_timer_t *timer) +static int snd_ad1816a_timer_stop(struct snd_timer *timer) { unsigned long flags; - ad1816a_t *chip = snd_timer_chip(timer); + struct snd_ad1816a *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->lock, flags); snd_ad1816a_write_mask(chip, AD1816A_INTERRUPT_ENABLE, @@ -432,7 +432,7 @@ static int snd_ad1816a_timer_stop(snd_timer_t *timer) return 0; } -static struct _snd_timer_hardware snd_ad1816a_timer_table = { +static struct snd_timer_hardware snd_ad1816a_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 10000, .ticks = 65535, @@ -445,10 +445,10 @@ static struct _snd_timer_hardware snd_ad1816a_timer_table = { #endif /* not used now */ -static int snd_ad1816a_playback_open(snd_pcm_substream_t *substream) +static int snd_ad1816a_playback_open(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int error; if ((error = snd_ad1816a_open(chip, AD1816A_MODE_PLAYBACK)) < 0) @@ -461,10 +461,10 @@ static int snd_ad1816a_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_ad1816a_capture_open(snd_pcm_substream_t *substream) +static int snd_ad1816a_capture_open(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int error; if ((error = snd_ad1816a_open(chip, AD1816A_MODE_CAPTURE)) < 0) @@ -477,18 +477,18 @@ static int snd_ad1816a_capture_open(snd_pcm_substream_t *substream) return 0; } -static int snd_ad1816a_playback_close(snd_pcm_substream_t *substream) +static int snd_ad1816a_playback_close(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; snd_ad1816a_close(chip, AD1816A_MODE_PLAYBACK); return 0; } -static int snd_ad1816a_capture_close(snd_pcm_substream_t *substream) +static int snd_ad1816a_capture_close(struct snd_pcm_substream *substream) { - ad1816a_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1816a *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; snd_ad1816a_close(chip, AD1816A_MODE_CAPTURE); @@ -496,7 +496,7 @@ static int snd_ad1816a_capture_close(snd_pcm_substream_t *substream) } -static void snd_ad1816a_init(ad1816a_t *chip) +static void snd_ad1816a_init(struct snd_ad1816a *chip) { unsigned long flags; @@ -516,7 +516,7 @@ static void snd_ad1816a_init(ad1816a_t *chip) spin_unlock_irqrestore(&chip->lock, flags); } -static int snd_ad1816a_probe(ad1816a_t *chip) +static int snd_ad1816a_probe(struct snd_ad1816a *chip) { unsigned long flags; @@ -540,7 +540,7 @@ static int snd_ad1816a_probe(ad1816a_t *chip) return 0; } -static int snd_ad1816a_free(ad1816a_t *chip) +static int snd_ad1816a_free(struct snd_ad1816a *chip) { release_and_free_resource(chip->res_port); if (chip->irq >= 0) @@ -557,13 +557,13 @@ static int snd_ad1816a_free(ad1816a_t *chip) return 0; } -static int snd_ad1816a_dev_free(snd_device_t *device) +static int snd_ad1816a_dev_free(struct snd_device *device) { - ad1816a_t *chip = device->device_data; + struct snd_ad1816a *chip = device->device_data; return snd_ad1816a_free(chip); } -static const char *snd_ad1816a_chip_id(ad1816a_t *chip) +static const char *snd_ad1816a_chip_id(struct snd_ad1816a *chip) { switch (chip->hardware) { case AD1816A_HW_AD1816A: return "AD1816A"; @@ -576,15 +576,15 @@ static const char *snd_ad1816a_chip_id(ad1816a_t *chip) } } -int snd_ad1816a_create(snd_card_t *card, +int snd_ad1816a_create(struct snd_card *card, unsigned long port, int irq, int dma1, int dma2, - ad1816a_t **rchip) + struct snd_ad1816a **rchip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ad1816a_dev_free, }; int error; - ad1816a_t *chip; + struct snd_ad1816a *chip; *rchip = NULL; @@ -640,7 +640,7 @@ int snd_ad1816a_create(snd_card_t *card, return 0; } -static snd_pcm_ops_t snd_ad1816a_playback_ops = { +static struct snd_pcm_ops snd_ad1816a_playback_ops = { .open = snd_ad1816a_playback_open, .close = snd_ad1816a_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -651,7 +651,7 @@ static snd_pcm_ops_t snd_ad1816a_playback_ops = { .pointer = snd_ad1816a_playback_pointer, }; -static snd_pcm_ops_t snd_ad1816a_capture_ops = { +static struct snd_pcm_ops snd_ad1816a_capture_ops = { .open = snd_ad1816a_capture_open, .close = snd_ad1816a_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -662,10 +662,10 @@ static snd_pcm_ops_t snd_ad1816a_capture_ops = { .pointer = snd_ad1816a_capture_pointer, }; -int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm) +int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm) { int error; - snd_pcm_t *pcm; + struct snd_pcm *pcm; if ((error = snd_pcm_new(chip->card, "AD1816A", device, 1, 1, &pcm))) return error; @@ -690,16 +690,16 @@ int snd_ad1816a_pcm(ad1816a_t *chip, int device, snd_pcm_t **rpcm) } #if 0 /* not used now */ -static void snd_ad1816a_timer_free(snd_timer_t *timer) +static void snd_ad1816a_timer_free(struct snd_timer *timer) { - ad1816a_t *chip = timer->private_data; + struct snd_ad1816a *chip = timer->private_data; chip->timer = NULL; } -int snd_ad1816a_timer(ad1816a_t *chip, int device, snd_timer_t **rtimer) +int snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **rtimer) { - snd_timer_t *timer; - snd_timer_id_t tid; + struct snd_timer *timer; + struct snd_timer_id tid; int error; tid.dev_class = SNDRV_TIMER_CLASS_CARD; @@ -724,7 +724,7 @@ int snd_ad1816a_timer(ad1816a_t *chip, int device, snd_timer_t **rtimer) * */ -static int snd_ad1816a_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1816a_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[8] = { "Line", "Mix", "CD", "Synth", "Video", @@ -740,9 +740,9 @@ static int snd_ad1816a_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_ad1816a_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short val; @@ -754,9 +754,9 @@ static int snd_ad1816a_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_ad1816a_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short val; int change; @@ -778,7 +778,7 @@ static int snd_ad1816a_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_ad1816a_get_single, .put = snd_ad1816a_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_ad1816a_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1816a_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -789,9 +789,9 @@ static int snd_ad1816a_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ad1816a_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -806,9 +806,9 @@ static int snd_ad1816a_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_ad1816a_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -835,7 +835,7 @@ static int snd_ad1816a_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .get = snd_ad1816a_get_double, .put = snd_ad1816a_put_double, \ .private_value = reg | (shift_left << 8) | (shift_right << 12) | (mask << 16) | (invert << 24) } -static int snd_ad1816a_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1816a_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -846,9 +846,9 @@ static int snd_ad1816a_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ad1816a_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift_left = (kcontrol->private_value >> 8) & 0x0f; @@ -869,9 +869,9 @@ static int snd_ad1816a_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_ad1816a_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1816a_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1816a_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1816a *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift_left = (kcontrol->private_value >> 8) & 0x0f; @@ -898,7 +898,7 @@ static int snd_ad1816a_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -static snd_kcontrol_new_t snd_ad1816a_controls[] = { +static struct snd_kcontrol_new snd_ad1816a_controls[] = { AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1), AD1816A_DOUBLE("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1), AD1816A_DOUBLE("PCM Playback Switch", AD1816A_VOICE_ATT, 15, 7, 1, 1), @@ -933,9 +933,9 @@ AD1816A_SINGLE("3D Control - Switch", AD1816A_3D_PHAT_CTRL, 15, 1, 1), AD1816A_SINGLE("3D Control - Level", AD1816A_3D_PHAT_CTRL, 0, 15, 0), }; -int snd_ad1816a_mixer(ad1816a_t *chip) +int snd_ad1816a_mixer(struct snd_ad1816a *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx; int err; -- cgit v1.1 From c8ff6647bb8a1865608b2d0c8565ca0ac47fb9b7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:29:37 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA AD1848 Modules: AD1848 driver Remove xxx_t typedefs from the ISA AD1848 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/ad1848.h | 28 ++++--- sound/isa/ad1848/ad1848.c | 8 +- sound/isa/ad1848/ad1848_lib.c | 176 +++++++++++++++++++++--------------------- 3 files changed, 105 insertions(+), 107 deletions(-) diff --git a/include/sound/ad1848.h b/include/sound/ad1848.h index 7e33b11..a038070 100644 --- a/include/sound/ad1848.h +++ b/include/sound/ad1848.h @@ -127,7 +127,7 @@ #define AD1848_THINKPAD_CTL_PORT2 0x15e9 #define AD1848_THINKPAD_CS4248_ENABLE_BIT 0x02 -struct _snd_ad1848 { +struct snd_ad1848 { unsigned long port; /* i/o port */ struct resource *res_port; int irq; /* IRQ line */ @@ -137,10 +137,10 @@ struct _snd_ad1848 { unsigned short hardware; /* see to AD1848_HW_XXXX */ unsigned short single_dma:1; /* forced single DMA mode (GUS 16-bit daughter board) or dma1 == dma2 */ - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; - snd_card_t *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; + struct snd_card *card; unsigned char image[32]; /* SGalaxy needs an access to extended registers */ int mce_bit; @@ -152,21 +152,19 @@ struct _snd_ad1848 { struct semaphore open_mutex; }; -typedef struct _snd_ad1848 ad1848_t; - /* exported functions */ -void snd_ad1848_out(ad1848_t *chip, unsigned char reg, unsigned char value); +void snd_ad1848_out(struct snd_ad1848 *chip, unsigned char reg, unsigned char value); -int snd_ad1848_create(snd_card_t * card, +int snd_ad1848_create(struct snd_card *card, unsigned long port, int irq, int dma, unsigned short hardware, - ad1848_t ** chip); + struct snd_ad1848 ** chip); -int snd_ad1848_pcm(ad1848_t * chip, int device, snd_pcm_t **rpcm); -const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction); -int snd_ad1848_mixer(ad1848_t * chip); +int snd_ad1848_pcm(struct snd_ad1848 * chip, int device, struct snd_pcm **rpcm); +const struct snd_pcm_ops *snd_ad1848_get_pcm_ops(int direction); +int snd_ad1848_mixer(struct snd_ad1848 * chip); /* exported mixer stuffs */ enum { AD1848_MIX_SINGLE, AD1848_MIX_DOUBLE, AD1848_MIX_CAPTURE }; @@ -176,7 +174,7 @@ enum { AD1848_MIX_SINGLE, AD1848_MIX_DOUBLE, AD1848_MIX_CAPTURE }; #define AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert) \ ((left_reg) | ((right_reg) << 8) | ((shift_left) << 16) | ((shift_right) << 19) | ((mask) << 24) | ((invert) << 22)) -int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, unsigned long value); +int snd_ad1848_add_ctl(struct snd_ad1848 *chip, const char *name, int index, int type, unsigned long value); /* for ease of use */ struct ad1848_mix_elem { @@ -198,7 +196,7 @@ struct ad1848_mix_elem { .type = AD1848_MIX_DOUBLE, \ .private_value = AD1848_MIXVAL_DOUBLE(left_reg, right_reg, shift_left, shift_right, mask, invert) } -static inline int snd_ad1848_add_ctl_elem(ad1848_t *chip, const struct ad1848_mix_elem *c) +static inline int snd_ad1848_add_ctl_elem(struct snd_ad1848 *chip, const struct ad1848_mix_elem *c) { return snd_ad1848_add_ctl(chip, c->name, c->index, c->type, c->private_value); } diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 3ebcc48..ffc373b 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -60,14 +60,14 @@ MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver."); module_param_array(thinkpad, bool, NULL, 0444); MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); -static snd_card_t *snd_ad1848_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_ad1848_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static int __init snd_card_ad1848_probe(int dev) { - snd_card_t *card; - ad1848_t *chip; - snd_pcm_t *pcm; + struct snd_card *card; + struct snd_ad1848 *chip; + struct snd_pcm *pcm; int err; if (port[dev] == SNDRV_AUTO_PORT) { diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c index 84a3c55..55ba32d 100644 --- a/sound/isa/ad1848/ad1848_lib.c +++ b/sound/isa/ad1848/ad1848_lib.c @@ -69,7 +69,7 @@ static unsigned int rates[14] = { 27042, 32000, 33075, 37800, 44100, 48000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = 14, .list = rates, .mask = 0, @@ -99,7 +99,7 @@ static unsigned char snd_ad1848_original_image[16] = * Basic I/O functions */ -void snd_ad1848_out(ad1848_t *chip, +void snd_ad1848_out(struct snd_ad1848 *chip, unsigned char reg, unsigned char value) { @@ -119,7 +119,7 @@ void snd_ad1848_out(ad1848_t *chip, #endif } -static void snd_ad1848_dout(ad1848_t *chip, +static void snd_ad1848_dout(struct snd_ad1848 *chip, unsigned char reg, unsigned char value) { int timeout; @@ -131,7 +131,7 @@ static void snd_ad1848_dout(ad1848_t *chip, mb(); } -static unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg) +static unsigned char snd_ad1848_in(struct snd_ad1848 *chip, unsigned char reg) { int timeout; @@ -148,7 +148,7 @@ static unsigned char snd_ad1848_in(ad1848_t *chip, unsigned char reg) #if 0 -static void snd_ad1848_debug(ad1848_t *chip) +static void snd_ad1848_debug(struct snd_ad1848 *chip) { printk("AD1848 REGS: INDEX = 0x%02x ", inb(AD1848P(chip, REGSEL))); printk(" STATUS = 0x%02x\n", inb(AD1848P(chip, STATUS))); @@ -176,7 +176,7 @@ static void snd_ad1848_debug(ad1848_t *chip) * AD1848 detection / MCE routines */ -static void snd_ad1848_mce_up(ad1848_t *chip) +static void snd_ad1848_mce_up(struct snd_ad1848 *chip) { unsigned long flags; int timeout; @@ -197,7 +197,7 @@ static void snd_ad1848_mce_up(ad1848_t *chip) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_ad1848_mce_down(ad1848_t *chip) +static void snd_ad1848_mce_down(struct snd_ad1848 *chip) { unsigned long flags; int timeout; @@ -279,7 +279,7 @@ static unsigned int snd_ad1848_get_count(unsigned char format, return size; } -static int snd_ad1848_trigger(ad1848_t *chip, unsigned char what, +static int snd_ad1848_trigger(struct snd_ad1848 *chip, unsigned char what, int channel, int cmd) { int result = 0; @@ -324,7 +324,7 @@ static unsigned char snd_ad1848_get_rate(unsigned int rate) return freq_bits[13]; } -static int snd_ad1848_ioctl(snd_pcm_substream_t * substream, +static int snd_ad1848_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { return snd_pcm_lib_ioctl(substream, cmd, arg); @@ -348,7 +348,7 @@ static unsigned char snd_ad1848_get_format(int format, int channels) return rformat; } -static void snd_ad1848_calibrate_mute(ad1848_t *chip, int mute) +static void snd_ad1848_calibrate_mute(struct snd_ad1848 *chip, int mute) { unsigned long flags; @@ -372,7 +372,7 @@ static void snd_ad1848_calibrate_mute(ad1848_t *chip, int mute) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_ad1848_set_data_format(ad1848_t *chip, snd_pcm_hw_params_t *hw_params) +static void snd_ad1848_set_data_format(struct snd_ad1848 *chip, struct snd_pcm_hw_params *hw_params) { if (hw_params == NULL) { chip->image[AD1848_DATA_FORMAT] = 0x20; @@ -384,7 +384,7 @@ static void snd_ad1848_set_data_format(ad1848_t *chip, snd_pcm_hw_params_t *hw_p // snd_printk(">>> pmode = 0x%x, dfr = 0x%x\n", pstr->mode, chip->image[AD1848_DATA_FORMAT]); } -static int snd_ad1848_open(ad1848_t *chip, unsigned int mode) +static int snd_ad1848_open(struct snd_ad1848 *chip, unsigned int mode) { unsigned long flags; @@ -438,7 +438,7 @@ static int snd_ad1848_open(ad1848_t *chip, unsigned int mode) return 0; } -static void snd_ad1848_close(ad1848_t *chip) +static void snd_ad1848_close(struct snd_ad1848 *chip) { unsigned long flags; @@ -479,24 +479,24 @@ static void snd_ad1848_close(ad1848_t *chip) * ok.. exported functions.. */ -static int snd_ad1848_playback_trigger(snd_pcm_substream_t * substream, +static int snd_ad1848_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); return snd_ad1848_trigger(chip, AD1848_PLAYBACK_ENABLE, SNDRV_PCM_STREAM_PLAYBACK, cmd); } -static int snd_ad1848_capture_trigger(snd_pcm_substream_t * substream, +static int snd_ad1848_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); return snd_ad1848_trigger(chip, AD1848_CAPTURE_ENABLE, SNDRV_PCM_STREAM_CAPTURE, cmd); } -static int snd_ad1848_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ad1848_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); unsigned long flags; int err; @@ -513,15 +513,15 @@ static int snd_ad1848_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_ad1848_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_ad1848_playback_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ad1848_playback_prepare(snd_pcm_substream_t * substream) +static int snd_ad1848_playback_prepare(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -537,10 +537,10 @@ static int snd_ad1848_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ad1848_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); unsigned long flags; int err; @@ -557,15 +557,15 @@ static int snd_ad1848_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_ad1848_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_ad1848_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ad1848_capture_prepare(snd_pcm_substream_t * substream) +static int snd_ad1848_capture_prepare(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -583,7 +583,7 @@ static int snd_ad1848_capture_prepare(snd_pcm_substream_t * substream) static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ad1848_t *chip = dev_id; + struct snd_ad1848 *chip = dev_id; if ((chip->mode & AD1848_MODE_PLAY) && chip->playback_substream && (chip->mode & AD1848_MODE_RUNNING)) @@ -595,9 +595,9 @@ static irqreturn_t snd_ad1848_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_ad1848_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ad1848_playback_pointer(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_PLAYBACK_ENABLE)) @@ -606,9 +606,9 @@ static snd_pcm_uframes_t snd_ad1848_playback_pointer(snd_pcm_substream_t * subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_ad1848_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ad1848_capture_pointer(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[AD1848_IFACE_CTRL] & AD1848_CAPTURE_ENABLE)) @@ -621,7 +621,7 @@ static snd_pcm_uframes_t snd_ad1848_capture_pointer(snd_pcm_substream_t * substr */ -static void snd_ad1848_thinkpad_twiddle(ad1848_t *chip, int on) { +static void snd_ad1848_thinkpad_twiddle(struct snd_ad1848 *chip, int on) { int tmp; @@ -642,9 +642,9 @@ static void snd_ad1848_thinkpad_twiddle(ad1848_t *chip, int on) { } #ifdef CONFIG_PM -static int snd_ad1848_suspend(snd_card_t *card, pm_message_t state) +static int snd_ad1848_suspend(struct snd_card *card, pm_message_t state) { - ad1848_t *chip = card->pm_private_data; + struct snd_ad1848 *chip = card->pm_private_data; snd_pcm_suspend_all(chip->pcm); /* FIXME: save registers? */ @@ -655,9 +655,9 @@ static int snd_ad1848_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_ad1848_resume(snd_card_t *card) +static int snd_ad1848_resume(struct snd_card *card) { - ad1848_t *chip = card->pm_private_data; + struct snd_ad1848 *chip = card->pm_private_data; if (chip->thinkpad_flag) snd_ad1848_thinkpad_twiddle(chip, 1); @@ -668,7 +668,7 @@ static int snd_ad1848_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -static int snd_ad1848_probe(ad1848_t * chip) +static int snd_ad1848_probe(struct snd_ad1848 * chip) { unsigned long flags; int i, id, rev, ad1847; @@ -748,7 +748,7 @@ static int snd_ad1848_probe(ad1848_t * chip) */ -static snd_pcm_hardware_t snd_ad1848_playback = +static struct snd_pcm_hardware snd_ad1848_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -767,7 +767,7 @@ static snd_pcm_hardware_t snd_ad1848_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ad1848_capture = +static struct snd_pcm_hardware snd_ad1848_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -790,10 +790,10 @@ static snd_pcm_hardware_t snd_ad1848_capture = */ -static int snd_ad1848_playback_open(snd_pcm_substream_t * substream) +static int snd_ad1848_playback_open(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_ad1848_open(chip, AD1848_MODE_PLAY)) < 0) @@ -806,10 +806,10 @@ static int snd_ad1848_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_capture_open(snd_pcm_substream_t * substream) +static int snd_ad1848_capture_open(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_ad1848_open(chip, AD1848_MODE_CAPTURE)) < 0) @@ -822,9 +822,9 @@ static int snd_ad1848_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_playback_close(snd_pcm_substream_t * substream) +static int snd_ad1848_playback_close(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); chip->mode &= ~AD1848_MODE_PLAY; chip->playback_substream = NULL; @@ -832,9 +832,9 @@ static int snd_ad1848_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_capture_close(snd_pcm_substream_t * substream) +static int snd_ad1848_capture_close(struct snd_pcm_substream *substream) { - ad1848_t *chip = snd_pcm_substream_chip(substream); + struct snd_ad1848 *chip = snd_pcm_substream_chip(substream); chip->mode &= ~AD1848_MODE_CAPTURE; chip->capture_substream = NULL; @@ -842,7 +842,7 @@ static int snd_ad1848_capture_close(snd_pcm_substream_t * substream) return 0; } -static int snd_ad1848_free(ad1848_t *chip) +static int snd_ad1848_free(struct snd_ad1848 *chip) { release_and_free_resource(chip->res_port); if (chip->irq >= 0) @@ -855,13 +855,13 @@ static int snd_ad1848_free(ad1848_t *chip) return 0; } -static int snd_ad1848_dev_free(snd_device_t *device) +static int snd_ad1848_dev_free(struct snd_device *device) { - ad1848_t *chip = device->device_data; + struct snd_ad1848 *chip = device->device_data; return snd_ad1848_free(chip); } -static const char *snd_ad1848_chip_id(ad1848_t *chip) +static const char *snd_ad1848_chip_id(struct snd_ad1848 *chip) { switch (chip->hardware) { case AD1848_HW_AD1847: return "AD1847"; @@ -872,16 +872,16 @@ static const char *snd_ad1848_chip_id(ad1848_t *chip) } } -int snd_ad1848_create(snd_card_t * card, +int snd_ad1848_create(struct snd_card *card, unsigned long port, int irq, int dma, unsigned short hardware, - ad1848_t ** rchip) + struct snd_ad1848 ** rchip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ad1848_dev_free, }; - ad1848_t *chip; + struct snd_ad1848 *chip; int err; *rchip = NULL; @@ -937,7 +937,7 @@ int snd_ad1848_create(snd_card_t * card, return 0; } -static snd_pcm_ops_t snd_ad1848_playback_ops = { +static struct snd_pcm_ops snd_ad1848_playback_ops = { .open = snd_ad1848_playback_open, .close = snd_ad1848_playback_close, .ioctl = snd_ad1848_ioctl, @@ -948,7 +948,7 @@ static snd_pcm_ops_t snd_ad1848_playback_ops = { .pointer = snd_ad1848_playback_pointer, }; -static snd_pcm_ops_t snd_ad1848_capture_ops = { +static struct snd_pcm_ops snd_ad1848_capture_ops = { .open = snd_ad1848_capture_open, .close = snd_ad1848_capture_close, .ioctl = snd_ad1848_ioctl, @@ -959,9 +959,9 @@ static snd_pcm_ops_t snd_ad1848_capture_ops = { .pointer = snd_ad1848_capture_pointer, }; -int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm) +int snd_ad1848_pcm(struct snd_ad1848 *chip, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "AD1848", device, 1, 1, &pcm)) < 0) @@ -984,7 +984,7 @@ int snd_ad1848_pcm(ad1848_t *chip, int device, snd_pcm_t **rpcm) return 0; } -const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction) +const struct snd_pcm_ops *snd_ad1848_get_pcm_ops(int direction) { return direction == SNDRV_PCM_STREAM_PLAYBACK ? &snd_ad1848_playback_ops : &snd_ad1848_capture_ops; @@ -994,7 +994,7 @@ const snd_pcm_ops_t *snd_ad1848_get_pcm_ops(int direction) * MIXER part */ -static int snd_ad1848_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1848_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "Line", "Aux", "Mic", "Mix" @@ -1009,9 +1009,9 @@ static int snd_ad1848_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_ad1848_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -1021,9 +1021,9 @@ static int snd_ad1848_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_ad1848_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short left, right; int change; @@ -1044,7 +1044,7 @@ static int snd_ad1848_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -static int snd_ad1848_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1848_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1055,9 +1055,9 @@ static int snd_ad1848_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ad1848_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1072,9 +1072,9 @@ static int snd_ad1848_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ad1848_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1095,7 +1095,7 @@ static int snd_ad1848_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static int snd_ad1848_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ad1848_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1106,9 +1106,9 @@ static int snd_ad1848_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ad1848_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1128,9 +1128,9 @@ static int snd_ad1848_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ad1848_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ad1848_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ad1848_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ad1848 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1167,9 +1167,9 @@ static int snd_ad1848_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t /* */ -int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, unsigned long value) +int snd_ad1848_add_ctl(struct snd_ad1848 *chip, const char *name, int index, int type, unsigned long value) { - static snd_kcontrol_new_t newctls[] = { + static struct snd_kcontrol_new newctls[] = { [AD1848_MIX_SINGLE] = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_ad1848_info_single, @@ -1189,7 +1189,7 @@ int snd_ad1848_add_ctl(ad1848_t *chip, const char *name, int index, int type, un .put = snd_ad1848_put_mux, }, }; - snd_kcontrol_t *ctl; + struct snd_kcontrol *ctl; int err; ctl = snd_ctl_new1(&newctls[type], chip); @@ -1222,10 +1222,10 @@ AD1848_SINGLE("Loopback Capture Switch", 0, AD1848_LOOPBACK, 0, 1, 0), AD1848_SINGLE("Loopback Capture Volume", 0, AD1848_LOOPBACK, 1, 63, 0) }; -int snd_ad1848_mixer(ad1848_t *chip) +int snd_ad1848_mixer(struct snd_ad1848 *chip) { - snd_card_t *card; - snd_pcm_t *pcm; + struct snd_card *card; + struct snd_pcm *pcm; unsigned int idx; int err; -- cgit v1.1 From ba2375a45c528fd902676ea01014ea0f8931464b Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:30:42 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA CS423x Modules: CS4231 driver,CS4236+ driver Remove xxx_t typedefs from the ISA CS423x drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/cs4231.h | 74 +++++++------- sound/isa/cs423x/cs4231.c | 8 +- sound/isa/cs423x/cs4231_lib.c | 230 +++++++++++++++++++++--------------------- sound/isa/cs423x/cs4236.c | 14 +-- sound/isa/cs423x/cs4236_lib.c | 106 +++++++++---------- 5 files changed, 215 insertions(+), 217 deletions(-) diff --git a/include/sound/cs4231.h b/include/sound/cs4231.h index d956de9..ac6a5d8 100644 --- a/include/sound/cs4231.h +++ b/include/sound/cs4231.h @@ -217,9 +217,7 @@ #define CS4231_HWSHARE_DMA1 (1<<1) #define CS4231_HWSHARE_DMA2 (1<<2) -typedef struct _snd_cs4231 cs4231_t; - -struct _snd_cs4231 { +struct snd_cs4231 { unsigned long port; /* base i/o port */ struct resource *res_port; unsigned long cport; /* control base i/o port (CS4236) */ @@ -234,11 +232,11 @@ struct _snd_cs4231 { unsigned short single_dma:1, /* forced single DMA mode (GUS 16-bit daughter board) or dma1 == dma2 */ ebus_flag:1; /* SPARC: EBUS present */ - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; - snd_timer_t *timer; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; + struct snd_timer *timer; unsigned char image[32]; /* registers image */ unsigned char eimage[32]; /* extended registers image */ @@ -253,52 +251,52 @@ struct _snd_cs4231 { struct semaphore mce_mutex; struct semaphore open_mutex; - int (*rate_constraint) (snd_pcm_runtime_t *runtime); - void (*set_playback_format) (cs4231_t *chip, snd_pcm_hw_params_t *hw_params, unsigned char pdfr); - void (*set_capture_format) (cs4231_t *chip, snd_pcm_hw_params_t *hw_params, unsigned char cdfr); - void (*trigger) (cs4231_t *chip, unsigned int what, int start); + int (*rate_constraint) (struct snd_pcm_runtime *runtime); + void (*set_playback_format) (struct snd_cs4231 *chip, struct snd_pcm_hw_params *hw_params, unsigned char pdfr); + void (*set_capture_format) (struct snd_cs4231 *chip, struct snd_pcm_hw_params *hw_params, unsigned char cdfr); + void (*trigger) (struct snd_cs4231 *chip, unsigned int what, int start); #ifdef CONFIG_PM - void (*suspend) (cs4231_t *chip); - void (*resume) (cs4231_t *chip); + void (*suspend) (struct snd_cs4231 *chip); + void (*resume) (struct snd_cs4231 *chip); #endif void *dma_private_data; - int (*claim_dma) (cs4231_t *chip, void *dma_private_data, int dma); - int (*release_dma) (cs4231_t *chip, void *dma_private_data, int dma); + int (*claim_dma) (struct snd_cs4231 *chip, void *dma_private_data, int dma); + int (*release_dma) (struct snd_cs4231 *chip, void *dma_private_data, int dma); }; /* exported functions */ -void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char val); -unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg); -void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val); -unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg); -void snd_cs4231_mce_up(cs4231_t *chip); -void snd_cs4231_mce_down(cs4231_t *chip); +void snd_cs4231_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val); +unsigned char snd_cs4231_in(struct snd_cs4231 *chip, unsigned char reg); +void snd_cs4236_ext_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val); +unsigned char snd_cs4236_ext_in(struct snd_cs4231 *chip, unsigned char reg); +void snd_cs4231_mce_up(struct snd_cs4231 *chip); +void snd_cs4231_mce_down(struct snd_cs4231 *chip); irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs); -const char *snd_cs4231_chip_id(cs4231_t *chip); +const char *snd_cs4231_chip_id(struct snd_cs4231 *chip); -int snd_cs4231_create(snd_card_t * card, +int snd_cs4231_create(struct snd_card *card, unsigned long port, unsigned long cport, int irq, int dma1, int dma2, unsigned short hardware, unsigned short hwshare, - cs4231_t ** rchip); -int snd_cs4231_pcm(cs4231_t * chip, int device, snd_pcm_t **rpcm); -int snd_cs4231_timer(cs4231_t * chip, int device, snd_timer_t **rtimer); -int snd_cs4231_mixer(cs4231_t * chip); + struct snd_cs4231 ** rchip); +int snd_cs4231_pcm(struct snd_cs4231 * chip, int device, struct snd_pcm **rpcm); +int snd_cs4231_timer(struct snd_cs4231 * chip, int device, struct snd_timer **rtimer); +int snd_cs4231_mixer(struct snd_cs4231 * chip); -int snd_cs4236_create(snd_card_t * card, +int snd_cs4236_create(struct snd_card *card, unsigned long port, unsigned long cport, int irq, int dma1, int dma2, unsigned short hardware, unsigned short hwshare, - cs4231_t ** rchip); -int snd_cs4236_pcm(cs4231_t * chip, int device, snd_pcm_t **rpcm); -int snd_cs4236_mixer(cs4231_t * chip); + struct snd_cs4231 ** rchip); +int snd_cs4236_pcm(struct snd_cs4231 * chip, int device, struct snd_pcm **rpcm); +int snd_cs4236_mixer(struct snd_cs4231 * chip); /* * mixer library @@ -310,9 +308,9 @@ int snd_cs4236_mixer(cs4231_t * chip); .get = snd_cs4231_get_single, .put = snd_cs4231_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo); -int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); -int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); +int snd_cs4231_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_cs4231_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_cs4231_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); #define CS4231_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ @@ -320,8 +318,8 @@ int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon .get = snd_cs4231_get_double, .put = snd_cs4231_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo); -int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); -int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); +int snd_cs4231_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_cs4231_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); #endif /* __SOUND_CS4231_H */ diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index 9be5416..a8da879 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -64,15 +64,15 @@ MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); -static snd_card_t *snd_cs4231_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_cs4231_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static int __init snd_card_cs4231_probe(int dev) { - snd_card_t *card; + struct snd_card *card; struct snd_card_cs4231 *acard; - snd_pcm_t *pcm = NULL; - cs4231_t *chip; + struct snd_pcm *pcm = NULL; + struct snd_cs4231 *chip; int err; if (port[dev] == SNDRV_AUTO_PORT) { diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 94e07a7c..ab9075f 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -73,13 +73,13 @@ static unsigned int rates[14] = { 27042, 32000, 33075, 37800, 44100, 48000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = 14, .list = rates, .mask = 0, }; -static int snd_cs4231_xrate(snd_pcm_runtime_t *runtime) +static int snd_cs4231_xrate(struct snd_pcm_runtime *runtime) { return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); } @@ -124,17 +124,17 @@ static unsigned char snd_cs4231_original_image[32] = * Basic I/O functions */ -static inline void cs4231_outb(cs4231_t *chip, u8 offset, u8 val) +static inline void cs4231_outb(struct snd_cs4231 *chip, u8 offset, u8 val) { outb(val, chip->port + offset); } -static inline u8 cs4231_inb(cs4231_t *chip, u8 offset) +static inline u8 cs4231_inb(struct snd_cs4231 *chip, u8 offset) { return inb(chip->port + offset); } -static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, +static void snd_cs4231_outm(struct snd_cs4231 *chip, unsigned char reg, unsigned char mask, unsigned char value) { int timeout; @@ -161,7 +161,7 @@ static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, } } -static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char value) +static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) { int timeout; @@ -174,7 +174,7 @@ static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char val mb(); } -void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value) +void snd_cs4231_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) { int timeout; @@ -195,7 +195,7 @@ void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value) #endif } -unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) +unsigned char snd_cs4231_in(struct snd_cs4231 *chip, unsigned char reg) { int timeout; @@ -212,7 +212,7 @@ unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) return cs4231_inb(chip, CS4231P(REG)); } -void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val) +void snd_cs4236_ext_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val) { cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); @@ -223,7 +223,7 @@ void snd_cs4236_ext_out(cs4231_t *chip, unsigned char reg, unsigned char val) #endif } -unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg) +unsigned char snd_cs4236_ext_in(struct snd_cs4231 *chip, unsigned char reg) { cs4231_outb(chip, CS4231P(REGSEL), chip->mce_bit | 0x17); cs4231_outb(chip, CS4231P(REG), reg | (chip->image[CS4236_EXT_REG] & 0x01)); @@ -241,7 +241,7 @@ unsigned char snd_cs4236_ext_in(cs4231_t *chip, unsigned char reg) #if 0 -static void snd_cs4231_debug(cs4231_t *chip) +static void snd_cs4231_debug(struct snd_cs4231 *chip) { printk("CS4231 REGS: INDEX = 0x%02x ", cs4231_inb(chip, CS4231P(REGSEL))); printk(" STATUS = 0x%02x\n", cs4231_inb(chip, CS4231P(STATUS))); @@ -285,7 +285,7 @@ static void snd_cs4231_debug(cs4231_t *chip) * CS4231 detection / MCE routines */ -static void snd_cs4231_busy_wait(cs4231_t *chip) +static void snd_cs4231_busy_wait(struct snd_cs4231 *chip) { int timeout; @@ -299,7 +299,7 @@ static void snd_cs4231_busy_wait(cs4231_t *chip) udelay(10); } -void snd_cs4231_mce_up(cs4231_t *chip) +void snd_cs4231_mce_up(struct snd_cs4231 *chip) { unsigned long flags; int timeout; @@ -320,7 +320,7 @@ void snd_cs4231_mce_up(cs4231_t *chip) spin_unlock_irqrestore(&chip->reg_lock, flags); } -void snd_cs4231_mce_down(cs4231_t *chip) +void snd_cs4231_mce_down(struct snd_cs4231 *chip) { unsigned long flags; int timeout; @@ -399,14 +399,14 @@ static unsigned int snd_cs4231_get_count(unsigned char format, unsigned int size return size; } -static int snd_cs4231_trigger(snd_pcm_substream_t *substream, +static int snd_cs4231_trigger(struct snd_pcm_substream *substream, int cmd) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); int result = 0; unsigned int what; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; int do_start; #if 0 @@ -468,7 +468,7 @@ static unsigned char snd_cs4231_get_rate(unsigned int rate) return freq_bits[13]; } -static unsigned char snd_cs4231_get_format(cs4231_t *chip, +static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, int channels) { @@ -490,7 +490,7 @@ static unsigned char snd_cs4231_get_format(cs4231_t *chip, return rformat; } -static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) +static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) { unsigned long flags; @@ -524,8 +524,8 @@ static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs4231_playback_format(cs4231_t *chip, - snd_pcm_hw_params_t *params, +static void snd_cs4231_playback_format(struct snd_cs4231 *chip, + struct snd_pcm_hw_params *params, unsigned char pdfr) { unsigned long flags; @@ -563,8 +563,8 @@ static void snd_cs4231_playback_format(cs4231_t *chip, up(&chip->mce_mutex); } -static void snd_cs4231_capture_format(cs4231_t *chip, - snd_pcm_hw_params_t *params, +static void snd_cs4231_capture_format(struct snd_cs4231 *chip, + struct snd_pcm_hw_params *params, unsigned char cdfr) { unsigned long flags; @@ -610,20 +610,20 @@ static void snd_cs4231_capture_format(cs4231_t *chip, * Timer interface */ -static unsigned long snd_cs4231_timer_resolution(snd_timer_t * timer) +static unsigned long snd_cs4231_timer_resolution(struct snd_timer * timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); if (chip->hardware & CS4231_HW_CS4236B_MASK) return 14467; else return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; } -static int snd_cs4231_timer_start(snd_timer_t * timer) +static int snd_cs4231_timer_start(struct snd_timer * timer) { unsigned long flags; unsigned int ticks; - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->reg_lock, flags); ticks = timer->sticks; if ((chip->image[CS4231_ALT_FEATURE_1] & CS4231_TIMER_ENABLE) == 0 || @@ -637,17 +637,17 @@ static int snd_cs4231_timer_start(snd_timer_t * timer) return 0; } -static int snd_cs4231_timer_stop(snd_timer_t * timer) +static int snd_cs4231_timer_stop(struct snd_timer * timer) { unsigned long flags; - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->reg_lock, flags); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, chip->image[CS4231_ALT_FEATURE_1] &= ~CS4231_TIMER_ENABLE); spin_unlock_irqrestore(&chip->reg_lock, flags); return 0; } -static void snd_cs4231_init(cs4231_t *chip) +static void snd_cs4231_init(struct snd_cs4231 *chip) { unsigned long flags; @@ -705,7 +705,7 @@ static void snd_cs4231_init(cs4231_t *chip) #endif } -static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) +static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode) { unsigned long flags; @@ -741,7 +741,7 @@ static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) return 0; } -static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) +static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) { unsigned long flags; @@ -792,21 +792,21 @@ static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) * timer open/close */ -static int snd_cs4231_timer_open(snd_timer_t * timer) +static int snd_cs4231_timer_open(struct snd_timer * timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); snd_cs4231_open(chip, CS4231_MODE_TIMER); return 0; } -static int snd_cs4231_timer_close(snd_timer_t * timer) +static int snd_cs4231_timer_close(struct snd_timer * timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); snd_cs4231_close(chip, CS4231_MODE_TIMER); return 0; } -static struct _snd_timer_hardware snd_cs4231_timer_table = +static struct snd_timer_hardware snd_cs4231_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 9945, @@ -822,10 +822,10 @@ static struct _snd_timer_hardware snd_cs4231_timer_table = * ok.. exported functions.. */ -static int snd_cs4231_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_pdfr; int err; @@ -837,15 +837,15 @@ static int snd_cs4231_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_cs4231_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_cs4231_playback_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) +static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -864,10 +864,10 @@ static int snd_cs4231_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_cdfr; int err; @@ -879,15 +879,15 @@ static int snd_cs4231_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_cs4231_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_cs4231_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) +static int snd_cs4231_capture_prepare(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -908,7 +908,7 @@ static int snd_cs4231_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static void snd_cs4231_overrange(cs4231_t *chip) +static void snd_cs4231_overrange(struct snd_cs4231 *chip) { unsigned long flags; unsigned char res; @@ -922,7 +922,7 @@ static void snd_cs4231_overrange(cs4231_t *chip) irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - cs4231_t *chip = dev_id; + struct snd_cs4231 *chip = dev_id; unsigned char status; status = snd_cs4231_in(chip, CS4231_IRQ_STATUS); @@ -962,9 +962,9 @@ irqreturn_t snd_cs4231_interrupt(int irq, void *dev_id, struct pt_regs *regs) return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) @@ -973,9 +973,9 @@ static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t * subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) @@ -988,7 +988,7 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr */ -static int snd_cs4231_probe(cs4231_t *chip) +static int snd_cs4231_probe(struct snd_cs4231 *chip) { unsigned long flags; int i, id, rev; @@ -1152,7 +1152,7 @@ static int snd_cs4231_probe(cs4231_t *chip) */ -static snd_pcm_hardware_t snd_cs4231_playback = +static struct snd_pcm_hardware snd_cs4231_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | @@ -1173,7 +1173,7 @@ static snd_pcm_hardware_t snd_cs4231_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_cs4231_capture = +static struct snd_pcm_hardware snd_cs4231_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | @@ -1198,10 +1198,10 @@ static snd_pcm_hardware_t snd_cs4231_capture = */ -static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) +static int snd_cs4231_playback_open(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; runtime->hw = snd_cs4231_playback; @@ -1235,10 +1235,10 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) +static int snd_cs4231_capture_open(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; runtime->hw = snd_cs4231_capture; @@ -1268,18 +1268,18 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_cs4231_playback_close(snd_pcm_substream_t * substream) +static int snd_cs4231_playback_close(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; snd_cs4231_close(chip, CS4231_MODE_PLAY); return 0; } -static int snd_cs4231_capture_close(snd_pcm_substream_t * substream) +static int snd_cs4231_capture_close(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; snd_cs4231_close(chip, CS4231_MODE_RECORD); @@ -1289,7 +1289,7 @@ static int snd_cs4231_capture_close(snd_pcm_substream_t * substream) #ifdef CONFIG_PM /* lowlevel suspend callback for CS4231 */ -static void snd_cs4231_suspend(cs4231_t *chip) +static void snd_cs4231_suspend(struct snd_cs4231 *chip) { int reg; unsigned long flags; @@ -1303,7 +1303,7 @@ static void snd_cs4231_suspend(cs4231_t *chip) } /* lowlevel resume callback for CS4231 */ -static void snd_cs4231_resume(cs4231_t *chip) +static void snd_cs4231_resume(struct snd_cs4231 *chip) { int reg; unsigned long flags; @@ -1344,24 +1344,24 @@ static void snd_cs4231_resume(cs4231_t *chip) #endif } -static int snd_cs4231_pm_suspend(snd_card_t *card, pm_message_t state) +static int snd_cs4231_pm_suspend(struct snd_card *card, pm_message_t state) { - cs4231_t *chip = card->pm_private_data; + struct snd_cs4231 *chip = card->pm_private_data; if (chip->suspend) chip->suspend(chip); return 0; } -static int snd_cs4231_pm_resume(snd_card_t *card) +static int snd_cs4231_pm_resume(struct snd_card *card) { - cs4231_t *chip = card->pm_private_data; + struct snd_cs4231 *chip = card->pm_private_data; if (chip->resume) chip->resume(chip); return 0; } #endif /* CONFIG_PM */ -static int snd_cs4231_free(cs4231_t *chip) +static int snd_cs4231_free(struct snd_cs4231 *chip) { release_and_free_resource(chip->res_port); release_and_free_resource(chip->res_cport); @@ -1384,13 +1384,13 @@ static int snd_cs4231_free(cs4231_t *chip) return 0; } -static int snd_cs4231_dev_free(snd_device_t *device) +static int snd_cs4231_dev_free(struct snd_device *device) { - cs4231_t *chip = device->device_data; + struct snd_cs4231 *chip = device->device_data; return snd_cs4231_free(chip); } -const char *snd_cs4231_chip_id(cs4231_t *chip) +const char *snd_cs4231_chip_id(struct snd_cs4231 *chip) { switch (chip->hardware) { case CS4231_HW_CS4231: return "CS4231"; @@ -1410,12 +1410,12 @@ const char *snd_cs4231_chip_id(cs4231_t *chip) } } -static int snd_cs4231_new(snd_card_t * card, +static int snd_cs4231_new(struct snd_card *card, unsigned short hardware, unsigned short hwshare, - cs4231_t ** rchip) + struct snd_cs4231 ** rchip) { - cs4231_t *chip; + struct snd_cs4231 *chip; *rchip = NULL; chip = kzalloc(sizeof(*chip), GFP_KERNEL); @@ -1437,18 +1437,18 @@ static int snd_cs4231_new(snd_card_t * card, return 0; } -int snd_cs4231_create(snd_card_t * card, +int snd_cs4231_create(struct snd_card *card, unsigned long port, unsigned long cport, int irq, int dma1, int dma2, unsigned short hardware, unsigned short hwshare, - cs4231_t ** rchip) + struct snd_cs4231 ** rchip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_cs4231_dev_free, }; - cs4231_t *chip; + struct snd_cs4231 *chip; int err; err = snd_cs4231_new(card, hardware, hwshare, &chip); @@ -1523,7 +1523,7 @@ int snd_cs4231_create(snd_card_t * card, return 0; } -static snd_pcm_ops_t snd_cs4231_playback_ops = { +static struct snd_pcm_ops snd_cs4231_playback_ops = { .open = snd_cs4231_playback_open, .close = snd_cs4231_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1534,7 +1534,7 @@ static snd_pcm_ops_t snd_cs4231_playback_ops = { .pointer = snd_cs4231_playback_pointer, }; -static snd_pcm_ops_t snd_cs4231_capture_ops = { +static struct snd_pcm_ops snd_cs4231_capture_ops = { .open = snd_cs4231_capture_open, .close = snd_cs4231_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1545,9 +1545,9 @@ static snd_pcm_ops_t snd_cs4231_capture_ops = { .pointer = snd_cs4231_capture_pointer, }; -int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) +int snd_cs4231_pcm(struct snd_cs4231 *chip, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "CS4231", device, 1, 1, &pcm)) < 0) @@ -1579,16 +1579,16 @@ int snd_cs4231_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) return 0; } -static void snd_cs4231_timer_free(snd_timer_t *timer) +static void snd_cs4231_timer_free(struct snd_timer *timer) { - cs4231_t *chip = timer->private_data; + struct snd_cs4231 *chip = timer->private_data; chip->timer = NULL; } -int snd_cs4231_timer(cs4231_t *chip, int device, snd_timer_t **rtimer) +int snd_cs4231_timer(struct snd_cs4231 *chip, int device, struct snd_timer **rtimer) { - snd_timer_t *timer; - snd_timer_id_t tid; + struct snd_timer *timer; + struct snd_timer_id tid; int err; /* Timer initialization */ @@ -1613,7 +1613,7 @@ int snd_cs4231_timer(cs4231_t *chip, int device, snd_timer_t **rtimer) * MIXER part */ -static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs4231_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "Line", "Aux", "Mic", "Mix" @@ -1625,7 +1625,7 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u "Line", "Synth", "Mic", "Mix" }; char **ptexts = texts; - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); snd_assert(chip->card != NULL, return -EINVAL); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -1643,9 +1643,9 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_cs4231_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4231_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -1655,9 +1655,9 @@ static int snd_cs4231_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_cs4231_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4231_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short left, right; int change; @@ -1678,7 +1678,7 @@ static int snd_cs4231_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +int snd_cs4231_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1689,9 +1689,9 @@ int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo return 0; } -int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_cs4231_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1706,9 +1706,9 @@ int snd_cs4231_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon return 0; } -int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_cs4231_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1729,7 +1729,7 @@ int snd_cs4231_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon return change; } -int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +int snd_cs4231_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1740,9 +1740,9 @@ int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo return 0; } -int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_cs4231_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1762,9 +1762,9 @@ int snd_cs4231_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon return 0; } -int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1793,7 +1793,7 @@ int snd_cs4231_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucon return change; } -static snd_kcontrol_new_t snd_cs4231_controls[] = { +static struct snd_kcontrol_new snd_cs4231_controls[] = { CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), @@ -1819,9 +1819,9 @@ CS4231_SINGLE("Loopback Capture Switch", 0, CS4231_LOOPBACK, 0, 1, 0), CS4231_SINGLE("Loopback Capture Volume", 0, CS4231_LOOPBACK, 2, 63, 1) }; -int snd_cs4231_mixer(cs4231_t *chip) +int snd_cs4231_mixer(struct snd_cs4231 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx; int err; diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index d60a55e..a28f24c 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -131,7 +131,7 @@ struct snd_card_cs4236 { #endif }; -static snd_card_t *snd_cs4236_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_cs4236_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -375,7 +375,7 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, } #endif /* CONFIG_PNP */ -static void snd_card_cs4236_free(snd_card_t *card) +static void snd_card_cs4236_free(struct snd_card *card) { struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data; @@ -392,11 +392,11 @@ static void snd_card_cs4236_free(snd_card_t *card) static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { - snd_card_t *card; + struct snd_card *card; struct snd_card_cs4236 *acard; - snd_pcm_t *pcm = NULL; - cs4231_t *chip; - opl3_t *opl3; + struct snd_pcm *pcm = NULL; + struct snd_cs4231 *chip; + struct snd_opl3 *opl3; int err; if (! is_isapnp_selected(dev)) { @@ -538,7 +538,7 @@ static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *card, static void __devexit snd_cs423x_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index 1adb88d..e36981d 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c @@ -122,13 +122,13 @@ static unsigned char snd_cs4236_ext_map[18] = { * */ -static void snd_cs4236_ctrl_out(cs4231_t *chip, unsigned char reg, unsigned char val) +static void snd_cs4236_ctrl_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char val) { outb(reg, chip->cport + 3); outb(chip->cimage[reg] = val, chip->cport + 4); } -static unsigned char snd_cs4236_ctrl_in(cs4231_t *chip, unsigned char reg) +static unsigned char snd_cs4236_ctrl_in(struct snd_cs4231 *chip, unsigned char reg) { outb(reg, chip->cport + 3); return inb(chip->cport + 4); @@ -140,7 +140,7 @@ static unsigned char snd_cs4236_ctrl_in(cs4231_t *chip, unsigned char reg) #define CLOCKS 8 -static ratnum_t clocks[CLOCKS] = { +static struct snd_ratnum clocks[CLOCKS] = { { .num = 16934400, .den_min = 353, .den_max = 353, .den_step = 1 }, { .num = 16934400, .den_min = 529, .den_max = 529, .den_step = 1 }, { .num = 16934400, .den_min = 617, .den_max = 617, .den_step = 1 }, @@ -151,12 +151,12 @@ static ratnum_t clocks[CLOCKS] = { { .num = 16934400/16, .den_min = 21, .den_max = 192, .den_step = 1 } }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = { .nrats = CLOCKS, .rats = clocks, }; -static int snd_cs4236_xrate(snd_pcm_runtime_t *runtime) +static int snd_cs4236_xrate(struct snd_pcm_runtime *runtime) { return snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_clocks); @@ -181,7 +181,7 @@ static unsigned char divisor_to_rate_register(unsigned int divisor) } } -static void snd_cs4236_playback_format(cs4231_t *chip, snd_pcm_hw_params_t *params, unsigned char pdfr) +static void snd_cs4236_playback_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char pdfr) { unsigned long flags; unsigned char rate = divisor_to_rate_register(params->rate_den); @@ -195,7 +195,7 @@ static void snd_cs4236_playback_format(cs4231_t *chip, snd_pcm_hw_params_t *para spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs4236_capture_format(cs4231_t *chip, snd_pcm_hw_params_t *params, unsigned char cdfr) +static void snd_cs4236_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char cdfr) { unsigned long flags; unsigned char rate = divisor_to_rate_register(params->rate_den); @@ -211,7 +211,7 @@ static void snd_cs4236_capture_format(cs4231_t *chip, snd_pcm_hw_params_t *param #ifdef CONFIG_PM -static void snd_cs4236_suspend(cs4231_t *chip) +static void snd_cs4236_suspend(struct snd_cs4231 *chip) { int reg; unsigned long flags; @@ -226,7 +226,7 @@ static void snd_cs4236_suspend(cs4231_t *chip) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs4236_resume(cs4231_t *chip) +static void snd_cs4236_resume(struct snd_cs4231 *chip) { int reg; unsigned long flags; @@ -261,15 +261,15 @@ static void snd_cs4236_resume(cs4231_t *chip) #endif /* CONFIG_PM */ -int snd_cs4236_create(snd_card_t * card, +int snd_cs4236_create(struct snd_card *card, unsigned long port, unsigned long cport, int irq, int dma1, int dma2, unsigned short hardware, unsigned short hwshare, - cs4231_t ** rchip) + struct snd_cs4231 ** rchip) { - cs4231_t *chip; + struct snd_cs4231 *chip; unsigned char ver1, ver2; unsigned int reg; int err; @@ -352,9 +352,9 @@ int snd_cs4236_create(snd_card_t * card, return 0; } -int snd_cs4236_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) +int snd_cs4236_pcm(struct snd_cs4231 *chip, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_cs4231_pcm(chip, device, &pcm)) < 0) @@ -375,7 +375,7 @@ int snd_cs4236_pcm(cs4231_t *chip, int device, snd_pcm_t **rpcm) .get = snd_cs4236_get_single, .put = snd_cs4236_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_cs4236_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs4236_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -386,9 +386,9 @@ static int snd_cs4236_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_cs4236_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -403,9 +403,9 @@ static int snd_cs4236_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_cs4236_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -432,9 +432,9 @@ static int snd_cs4236_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_cs4236_get_singlec, .put = snd_cs4236_put_singlec, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_cs4236_get_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -449,9 +449,9 @@ static int snd_cs4236_get_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_cs4236_put_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_singlec(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -478,7 +478,7 @@ static int snd_cs4236_put_singlec(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .get = snd_cs4236_get_double, .put = snd_cs4236_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_cs4236_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs4236_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -489,9 +489,9 @@ static int snd_cs4236_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_cs4236_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -511,9 +511,9 @@ static int snd_cs4236_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_cs4236_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -554,9 +554,9 @@ static int snd_cs4236_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_cs4236_get_double1, .put = snd_cs4236_put_double1, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_cs4236_get_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -576,9 +576,9 @@ static int snd_cs4236_get_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_cs4236_put_double1(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_double1(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -618,9 +618,9 @@ static inline int snd_cs4236_mixer_master_digital_invert_volume(int vol) return (vol < 64) ? 63 - vol : 64 + (71 - vol); } -static int snd_cs4236_get_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -630,9 +630,9 @@ static int snd_cs4236_get_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem return 0; } -static int snd_cs4236_put_master_digital(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_master_digital(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1, val2; @@ -677,9 +677,9 @@ static inline int snd_cs4235_mixer_output_accu_set_volume(int vol) return 1 << 5; } -static int snd_cs4235_get_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4235_get_output_accu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -689,9 +689,9 @@ static int snd_cs4235_get_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_va return 0; } -static int snd_cs4235_put_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4235_put_output_accu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1, val2; @@ -708,7 +708,7 @@ static int snd_cs4235_put_output_accu(snd_kcontrol_t * kcontrol, snd_ctl_elem_va return change; } -static snd_kcontrol_new_t snd_cs4236_controls[] = { +static struct snd_kcontrol_new snd_cs4236_controls[] = { CS4236_DOUBLE("Master Digital Playback Switch", 0, CS4236_LEFT_MASTER, CS4236_RIGHT_MASTER, 7, 7, 1, 1), CS4236_DOUBLE("Master Digital Capture Switch", 0, CS4236_DAC_MUTE, CS4236_DAC_MUTE, 7, 6, 1, 1), @@ -759,7 +759,7 @@ CS4231_SINGLE("Digital Loopback Playback Switch", 0, CS4231_LOOPBACK, 0, 1, 0), CS4236_DOUBLE1("Digital Loopback Playback Volume", 0, CS4231_LOOPBACK, CS4236_RIGHT_LOOPBACK, 2, 0, 63, 1) }; -static snd_kcontrol_new_t snd_cs4235_controls[] = { +static struct snd_kcontrol_new snd_cs4235_controls[] = { CS4231_DOUBLE("Master Switch", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 7, 7, 1, 1), CS4231_DOUBLE("Master Volume", 0, CS4235_LEFT_MASTER, CS4235_RIGHT_MASTER, 0, 0, 31, 1), @@ -812,9 +812,9 @@ CS4231_DOUBLE("Analog Loopback Switch", 0, CS4231_LEFT_INPUT, CS4231_RIGHT_INPUT .get = snd_cs4236_get_iec958_switch, .put = snd_cs4236_put_iec958_switch, \ .private_value = 1 << 16 } -static int snd_cs4236_get_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_get_iec958_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -832,9 +832,9 @@ static int snd_cs4236_get_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return 0; } -static int snd_cs4236_put_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4236_put_iec958_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short enable, val; @@ -868,7 +868,7 @@ static int snd_cs4236_put_iec958_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return change; } -static snd_kcontrol_new_t snd_cs4236_iec958_controls[] = { +static struct snd_kcontrol_new snd_cs4236_iec958_controls[] = { CS4236_IEC958_ENABLE("IEC958 Output Enable", 0), CS4236_SINGLEC("IEC958 Output Validity", 0, 4, 4, 1, 0), CS4236_SINGLEC("IEC958 Output User", 0, 4, 5, 1, 0), @@ -877,12 +877,12 @@ CS4236_SINGLEC("IEC958 Output Channel Status Low", 0, 5, 1, 127, 0), CS4236_SINGLEC("IEC958 Output Channel Status High", 0, 6, 0, 255, 0) }; -static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4235[] = { +static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4235[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1) }; -static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4237[] = { +static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4237[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 7, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1), CS4236_SINGLEC("3D Control - Center", 0, 2, 0, 15, 1), @@ -890,19 +890,19 @@ CS4236_SINGLEC("3D Control - Mono", 0, 3, 6, 1, 0), CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0) }; -static snd_kcontrol_new_t snd_cs4236_3d_controls_cs4238[] = { +static struct snd_kcontrol_new snd_cs4236_3d_controls_cs4238[] = { CS4236_SINGLEC("3D Control - Switch", 0, 3, 4, 1, 0), CS4236_SINGLEC("3D Control - Space", 0, 2, 4, 15, 1), CS4236_SINGLEC("3D Control - Volume", 0, 2, 0, 15, 1), CS4236_SINGLEC("3D Control - IEC958", 0, 3, 5, 1, 0) }; -int snd_cs4236_mixer(cs4231_t *chip) +int snd_cs4236_mixer(struct snd_cs4231 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx, count; int err; - snd_kcontrol_new_t *kcontrol; + struct snd_kcontrol_new *kcontrol; snd_assert(chip != NULL && chip->card != NULL, return -EINVAL); card = chip->card; -- cgit v1.1 From d3a7e476740dc23588ea65fa0df1aacdf8e70003 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:31:42 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA ES1688 Modules: ES1688 driver Remove xxx_t typedefs from the ISA ES1688 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/es1688.h | 22 +++---- sound/isa/es1688/es1688.c | 10 +-- sound/isa/es1688/es1688_lib.c | 150 +++++++++++++++++++++--------------------- 3 files changed, 90 insertions(+), 92 deletions(-) diff --git a/include/sound/es1688.h b/include/sound/es1688.h index 604f495..fc1c47d 100644 --- a/include/sound/es1688.h +++ b/include/sound/es1688.h @@ -30,7 +30,7 @@ #define ES1688_HW_688 0x0001 #define ES1688_HW_1688 0x0002 -struct _snd_es1688 { +struct snd_es1688 { unsigned long port; /* port of ESS chip */ struct resource *res_port; unsigned long mpu_port; /* MPU-401 port of ESS chip */ @@ -44,17 +44,15 @@ struct _snd_es1688 { unsigned char pad; unsigned int dma_size; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; spinlock_t reg_lock; spinlock_t mixer_lock; }; -typedef struct _snd_es1688 es1688_t; - /* I/O ports */ #define ES1688P(codec, x) ((codec)->port + e_s_s_ESS1688##x) @@ -107,17 +105,17 @@ typedef struct _snd_es1688 es1688_t; */ -void snd_es1688_mixer_write(es1688_t *chip, unsigned char reg, unsigned char data); +void snd_es1688_mixer_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data); -int snd_es1688_create(snd_card_t * card, +int snd_es1688_create(struct snd_card *card, unsigned long port, unsigned long mpu_port, int irq, int mpu_irq, int dma8, unsigned short hardware, - es1688_t ** rchip); -int snd_es1688_pcm(es1688_t *chip, int device, snd_pcm_t ** rpcm); -int snd_es1688_mixer(es1688_t *chip); + struct snd_es1688 ** rchip); +int snd_es1688_pcm(struct snd_es1688 *chip, int device, struct snd_pcm ** rpcm); +int snd_es1688_mixer(struct snd_es1688 *chip); #endif /* __SOUND_ES1688_H */ diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 26a7d33..278511b 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -68,7 +68,7 @@ MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); module_param_array(dma8, int, NULL, 0444); MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); -static snd_card_t *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "es1688: " @@ -77,10 +77,10 @@ static int __init snd_audiodrive_probe(int dev) static int possible_irqs[] = {5, 9, 10, 7, -1}; static int possible_dmas[] = {1, 3, 0, -1}; int xirq, xdma, xmpu_irq; - snd_card_t *card; - es1688_t *chip; - opl3_t *opl3; - snd_pcm_t *pcm; + struct snd_card *card; + struct snd_es1688 *chip; + struct snd_opl3 *opl3; + struct snd_pcm *pcm; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index 841e9ac..702ad51 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -36,7 +36,7 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("ESS ESx688 lowlevel module"); MODULE_LICENSE("GPL"); -static int snd_es1688_dsp_command(es1688_t *chip, unsigned char val) +static int snd_es1688_dsp_command(struct snd_es1688 *chip, unsigned char val) { int i; @@ -51,7 +51,7 @@ static int snd_es1688_dsp_command(es1688_t *chip, unsigned char val) return 0; } -static int snd_es1688_dsp_get_byte(es1688_t *chip) +static int snd_es1688_dsp_get_byte(struct snd_es1688 *chip) { int i; @@ -62,7 +62,7 @@ static int snd_es1688_dsp_get_byte(es1688_t *chip) return -ENODEV; } -static int snd_es1688_write(es1688_t *chip, +static int snd_es1688_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data) { if (!snd_es1688_dsp_command(chip, reg)) @@ -70,7 +70,7 @@ static int snd_es1688_write(es1688_t *chip, return snd_es1688_dsp_command(chip, data); } -static int snd_es1688_read(es1688_t *chip, unsigned char reg) +static int snd_es1688_read(struct snd_es1688 *chip, unsigned char reg) { /* Read a byte from an extended mode register of ES1688 */ if (!snd_es1688_dsp_command(chip, 0xc0)) @@ -80,7 +80,7 @@ static int snd_es1688_read(es1688_t *chip, unsigned char reg) return snd_es1688_dsp_get_byte(chip); } -void snd_es1688_mixer_write(es1688_t *chip, +void snd_es1688_mixer_write(struct snd_es1688 *chip, unsigned char reg, unsigned char data) { outb(reg, ES1688P(chip, MIXER_ADDR)); @@ -89,7 +89,7 @@ void snd_es1688_mixer_write(es1688_t *chip, udelay(10); } -static unsigned char snd_es1688_mixer_read(es1688_t *chip, unsigned char reg) +static unsigned char snd_es1688_mixer_read(struct snd_es1688 *chip, unsigned char reg) { unsigned char result; @@ -100,7 +100,7 @@ static unsigned char snd_es1688_mixer_read(es1688_t *chip, unsigned char reg) return result; } -static int snd_es1688_reset(es1688_t *chip) +static int snd_es1688_reset(struct snd_es1688 *chip) { int i; @@ -117,7 +117,7 @@ static int snd_es1688_reset(es1688_t *chip) return 0; } -static int snd_es1688_probe(es1688_t *chip) +static int snd_es1688_probe(struct snd_es1688 *chip) { unsigned long flags; unsigned short major, minor, hw; @@ -191,7 +191,7 @@ static int snd_es1688_probe(es1688_t *chip) return 0; } -static int snd_es1688_init(es1688_t * chip, int enable) +static int snd_es1688_init(struct snd_es1688 * chip, int enable) { static int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1}; unsigned long flags; @@ -283,7 +283,7 @@ static int snd_es1688_init(es1688_t * chip, int enable) */ -static ratnum_t clocks[2] = { +static struct snd_ratnum clocks[2] = { { .num = 795444, .den_min = 1, @@ -298,14 +298,14 @@ static ratnum_t clocks[2] = { } }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = { .nrats = 2, .rats = clocks, }; -static void snd_es1688_set_rate(es1688_t *chip, snd_pcm_substream_t *substream) +static void snd_es1688_set_rate(struct snd_es1688 *chip, struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int bits, divider; if (runtime->rate_num == clocks[0].num) @@ -319,13 +319,13 @@ static void snd_es1688_set_rate(es1688_t *chip, snd_pcm_substream_t *substream) snd_es1688_write(chip, 0xa2, divider); } -static int snd_es1688_ioctl(snd_pcm_substream_t * substream, +static int snd_es1688_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { return snd_pcm_lib_ioctl(substream, cmd, arg); } -static int snd_es1688_trigger(es1688_t *chip, int cmd, unsigned char value) +static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char value) { int val; @@ -350,22 +350,22 @@ static int snd_es1688_trigger(es1688_t *chip, int cmd, unsigned char value) return 0; } -static int snd_es1688_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_es1688_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_es1688_hw_free(snd_pcm_substream_t * substream) +static int snd_es1688_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_es1688_playback_prepare(snd_pcm_substream_t * substream) +static int snd_es1688_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - es1688_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -415,18 +415,18 @@ static int snd_es1688_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_es1688_playback_trigger(snd_pcm_substream_t * substream, +static int snd_es1688_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); return snd_es1688_trigger(chip, cmd, 0x05); } -static int snd_es1688_capture_prepare(snd_pcm_substream_t * substream) +static int snd_es1688_capture_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - es1688_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -472,16 +472,16 @@ static int snd_es1688_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_es1688_capture_trigger(snd_pcm_substream_t * substream, +static int snd_es1688_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); return snd_es1688_trigger(chip, cmd, 0x0f); } static irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - es1688_t *chip = dev_id; + struct snd_es1688 *chip = dev_id; if (chip->trigger_value == 0x05) /* ok.. playback is active */ snd_pcm_period_elapsed(chip->playback_substream); @@ -492,9 +492,9 @@ static irqreturn_t snd_es1688_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_es1688_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es1688_playback_pointer(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (chip->trigger_value != 0x05) @@ -503,9 +503,9 @@ static snd_pcm_uframes_t snd_es1688_playback_pointer(snd_pcm_substream_t * subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_es1688_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es1688_capture_pointer(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (chip->trigger_value != 0x0f) @@ -518,7 +518,7 @@ static snd_pcm_uframes_t snd_es1688_capture_pointer(snd_pcm_substream_t * substr */ -static snd_pcm_hardware_t snd_es1688_playback = +static struct snd_pcm_hardware snd_es1688_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -536,7 +536,7 @@ static snd_pcm_hardware_t snd_es1688_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_es1688_capture = +static struct snd_pcm_hardware snd_es1688_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -558,10 +558,10 @@ static snd_pcm_hardware_t snd_es1688_capture = */ -static int snd_es1688_playback_open(snd_pcm_substream_t * substream) +static int snd_es1688_playback_open(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (chip->capture_substream != NULL) return -EAGAIN; @@ -572,10 +572,10 @@ static int snd_es1688_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es1688_capture_open(snd_pcm_substream_t * substream) +static int snd_es1688_capture_open(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (chip->playback_substream != NULL) return -EAGAIN; @@ -586,23 +586,23 @@ static int snd_es1688_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es1688_playback_close(snd_pcm_substream_t * substream) +static int snd_es1688_playback_close(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; return 0; } -static int snd_es1688_capture_close(snd_pcm_substream_t * substream) +static int snd_es1688_capture_close(struct snd_pcm_substream *substream) { - es1688_t *chip = snd_pcm_substream_chip(substream); + struct snd_es1688 *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; return 0; } -static int snd_es1688_free(es1688_t *chip) +static int snd_es1688_free(struct snd_es1688 *chip) { if (chip->res_port) { snd_es1688_init(chip, 0); @@ -618,33 +618,33 @@ static int snd_es1688_free(es1688_t *chip) return 0; } -static int snd_es1688_dev_free(snd_device_t *device) +static int snd_es1688_dev_free(struct snd_device *device) { - es1688_t *chip = device->device_data; + struct snd_es1688 *chip = device->device_data; return snd_es1688_free(chip); } -static const char *snd_es1688_chip_id(es1688_t *chip) +static const char *snd_es1688_chip_id(struct snd_es1688 *chip) { static char tmp[16]; sprintf(tmp, "ES%s688 rev %i", chip->hardware == ES1688_HW_688 ? "" : "1", chip->version & 0x0f); return tmp; } -int snd_es1688_create(snd_card_t * card, +int snd_es1688_create(struct snd_card *card, unsigned long port, unsigned long mpu_port, int irq, int mpu_irq, int dma8, unsigned short hardware, - es1688_t **rchip) + struct snd_es1688 **rchip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_es1688_dev_free, }; - es1688_t *chip; + struct snd_es1688 *chip; int err; *rchip = NULL; @@ -702,7 +702,7 @@ int snd_es1688_create(snd_card_t * card, return 0; } -static snd_pcm_ops_t snd_es1688_playback_ops = { +static struct snd_pcm_ops snd_es1688_playback_ops = { .open = snd_es1688_playback_open, .close = snd_es1688_playback_close, .ioctl = snd_es1688_ioctl, @@ -713,7 +713,7 @@ static snd_pcm_ops_t snd_es1688_playback_ops = { .pointer = snd_es1688_playback_pointer, }; -static snd_pcm_ops_t snd_es1688_capture_ops = { +static struct snd_pcm_ops snd_es1688_capture_ops = { .open = snd_es1688_capture_open, .close = snd_es1688_capture_close, .ioctl = snd_es1688_ioctl, @@ -724,9 +724,9 @@ static snd_pcm_ops_t snd_es1688_capture_ops = { .pointer = snd_es1688_capture_pointer, }; -int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm) +int snd_es1688_pcm(struct snd_es1688 * chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0) @@ -753,7 +753,7 @@ int snd_es1688_pcm(es1688_t * chip, int device, snd_pcm_t ** rpcm) * MIXER part */ -static int snd_es1688_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1688_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[9] = { "Mic", "Mic Master", "CD", "AOUT", @@ -769,16 +769,16 @@ static int snd_es1688_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_es1688_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = snd_es1688_mixer_read(chip, ES1688_REC_DEV) & 7; return 0; } -static int snd_es1688_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned char oval, nval; int change; @@ -801,7 +801,7 @@ static int snd_es1688_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_es1688_get_single, .put = snd_es1688_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_es1688_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1688_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -812,9 +812,9 @@ static int snd_es1688_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es1688_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -829,9 +829,9 @@ static int snd_es1688_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es1688_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -860,7 +860,7 @@ static int snd_es1688_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_es1688_get_double, .put = snd_es1688_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_es1688_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1688_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -871,9 +871,9 @@ static int snd_es1688_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es1688_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -905,9 +905,9 @@ static int snd_es1688_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es1688_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1688_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es1688_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -968,7 +968,7 @@ static int snd_es1688_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_es1688_controls[] = { +static struct snd_kcontrol_new snd_es1688_controls[] = { ES1688_DOUBLE("Master Playback Volume", 0, ES1688_MASTER_DEV, ES1688_MASTER_DEV, 4, 0, 15, 0), ES1688_DOUBLE("PCM Playback Volume", 0, ES1688_PCM_DEV, ES1688_PCM_DEV, 4, 0, 15, 0), ES1688_DOUBLE("Line Playback Volume", 0, ES1688_LINE_DEV, ES1688_LINE_DEV, 4, 0, 15, 0), @@ -1003,9 +1003,9 @@ static unsigned char snd_es1688_init_table[][2] = { { ES1688_REC_DEV, 0x17 } }; -int snd_es1688_mixer(es1688_t *chip) +int snd_es1688_mixer(struct snd_es1688 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx; int err; unsigned char reg, val; -- cgit v1.1 From 029d64b0cfa30abc10f722e2f67d282abe09c9da Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:34:36 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA SB8/SB16/SBAWE Remove xxx_t typedefs from the ISA SB8/SB16/SBAWE drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/emu8000.h | 39 ++++----- include/sound/sb.h | 66 ++++++++------- include/sound/sb16_csp.h | 52 ++++++------ sound/isa/sb/emu8000.c | 121 ++++++++++++++-------------- sound/isa/sb/emu8000_callback.c | 107 ++++++++++++------------ sound/isa/sb/emu8000_local.h | 13 +-- sound/isa/sb/emu8000_patch.c | 20 ++--- sound/isa/sb/emu8000_pcm.c | 104 ++++++++++++------------ sound/isa/sb/emu8000_synth.c | 17 ++-- sound/isa/sb/es968.c | 8 +- sound/isa/sb/sb16.c | 16 ++-- sound/isa/sb/sb16_csp.c | 174 ++++++++++++++++++++-------------------- sound/isa/sb/sb16_main.c | 120 +++++++++++++-------------- sound/isa/sb/sb8.c | 12 +-- sound/isa/sb/sb8_main.c | 88 ++++++++++---------- sound/isa/sb/sb8_midi.c | 44 +++++----- sound/isa/sb/sb_common.c | 24 +++--- sound/isa/sb/sb_mixer.c | 68 ++++++++-------- 18 files changed, 551 insertions(+), 542 deletions(-) diff --git a/include/sound/emu8000.h b/include/sound/emu8000.h index 4362c54..c8f66bd 100644 --- a/include/sound/emu8000.h +++ b/include/sound/emu8000.h @@ -56,9 +56,9 @@ enum { * some of the channels may be used for other things so max_channels is * the number in use for wave voices. */ -typedef struct snd_emu8000 { +struct snd_emu8000 { - snd_emux_t *emu; + struct snd_emux *emu; int index; /* sequencer client index */ int seq_ports; /* number of sequencer ports */ @@ -77,44 +77,45 @@ typedef struct snd_emu8000 { int dram_checked; - snd_card_t *card; /* The card that this belongs to */ + struct snd_card *card; /* The card that this belongs to */ int chorus_mode; int reverb_mode; int bass_level; int treble_level; - snd_util_memhdr_t *memhdr; + struct snd_util_memhdr *memhdr; spinlock_t control_lock; - snd_kcontrol_t *controls[EMU8000_NUM_CONTROLS]; + struct snd_kcontrol *controls[EMU8000_NUM_CONTROLS]; - snd_pcm_t *pcm; /* pcm on emu8000 wavetable */ + struct snd_pcm *pcm; /* pcm on emu8000 wavetable */ -} emu8000_t; +}; /* sequencer device id */ #define SNDRV_SEQ_DEV_ID_EMU8000 "emu8000-synth" /* exported functions */ -int snd_emu8000_new(snd_card_t *card, int device, long port, int seq_ports, snd_seq_device_t **ret); -void snd_emu8000_poke(emu8000_t *emu, unsigned int port, unsigned int reg, +int snd_emu8000_new(struct snd_card *card, int device, long port, int seq_ports, + struct snd_seq_device **ret); +void snd_emu8000_poke(struct snd_emu8000 *emu, unsigned int port, unsigned int reg, unsigned int val); -unsigned short snd_emu8000_peek(emu8000_t *emu, unsigned int port, +unsigned short snd_emu8000_peek(struct snd_emu8000 *emu, unsigned int port, unsigned int reg); -void snd_emu8000_poke_dw(emu8000_t *emu, unsigned int port, unsigned int reg, +void snd_emu8000_poke_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg, unsigned int val); -unsigned int snd_emu8000_peek_dw(emu8000_t *emu, unsigned int port, +unsigned int snd_emu8000_peek_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg); -void snd_emu8000_dma_chan(emu8000_t *emu, int ch, int mode); +void snd_emu8000_dma_chan(struct snd_emu8000 *emu, int ch, int mode); -void snd_emu8000_init_fm(emu8000_t *emu); +void snd_emu8000_init_fm(struct snd_emu8000 *emu); -void snd_emu8000_update_chorus_mode(emu8000_t *emu); -void snd_emu8000_update_reverb_mode(emu8000_t *emu); -void snd_emu8000_update_equalizer(emu8000_t *emu); -int snd_emu8000_load_chorus_fx(emu8000_t *emu, int mode, const void __user *buf, long len); -int snd_emu8000_load_reverb_fx(emu8000_t *emu, int mode, const void __user *buf, long len); +void snd_emu8000_update_chorus_mode(struct snd_emu8000 *emu); +void snd_emu8000_update_reverb_mode(struct snd_emu8000 *emu); +void snd_emu8000_update_equalizer(struct snd_emu8000 *emu); +int snd_emu8000_load_chorus_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len); +int snd_emu8000_load_reverb_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len); #endif /* __SOUND_EMU8000_H */ diff --git a/include/sound/sb.h b/include/sound/sb.h index 7960452..8e82460 100644 --- a/include/sound/sb.h +++ b/include/sound/sb.h @@ -60,7 +60,7 @@ enum sb_hw_type { #define SB_MPU_INPUT 1 -struct _snd_sb { +struct snd_sb { unsigned long port; /* base port of DSP chip */ struct resource *res_port; unsigned long mpu_port; /* MPU port for SB DSP 4.0+ */ @@ -92,25 +92,23 @@ struct _snd_sb { void *csp; /* used only when CONFIG_SND_SB16_CSP is set */ - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *midi_substream_input; - snd_rawmidi_substream_t *midi_substream_output; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *midi_substream_input; + struct snd_rawmidi_substream *midi_substream_output; irqreturn_t (*rmidi_callback)(int irq, void *dev_id, struct pt_regs *regs); spinlock_t reg_lock; spinlock_t open_lock; spinlock_t midi_input_lock; - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; }; -typedef struct _snd_sb sb_t; - /* I/O ports */ #define SBP(chip, x) ((chip)->port + s_b_SB_##x) @@ -267,48 +265,48 @@ typedef struct _snd_sb sb_t; * */ -static inline void snd_sb_ack_8bit(sb_t *chip) +static inline void snd_sb_ack_8bit(struct snd_sb *chip) { inb(SBP(chip, DATA_AVAIL)); } -static inline void snd_sb_ack_16bit(sb_t *chip) +static inline void snd_sb_ack_16bit(struct snd_sb *chip) { inb(SBP(chip, DATA_AVAIL_16)); } /* sb_common.c */ -int snd_sbdsp_command(sb_t *chip, unsigned char val); -int snd_sbdsp_get_byte(sb_t *chip); -int snd_sbdsp_reset(sb_t *chip); -int snd_sbdsp_create(snd_card_t *card, +int snd_sbdsp_command(struct snd_sb *chip, unsigned char val); +int snd_sbdsp_get_byte(struct snd_sb *chip); +int snd_sbdsp_reset(struct snd_sb *chip); +int snd_sbdsp_create(struct snd_card *card, unsigned long port, int irq, irqreturn_t (*irq_handler)(int, void *, struct pt_regs *), int dma8, int dma16, unsigned short hardware, - sb_t **r_chip); + struct snd_sb **r_chip); /* sb_mixer.c */ -void snd_sbmixer_write(sb_t *chip, unsigned char reg, unsigned char data); -unsigned char snd_sbmixer_read(sb_t *chip, unsigned char reg); -int snd_sbmixer_new(sb_t *chip); +void snd_sbmixer_write(struct snd_sb *chip, unsigned char reg, unsigned char data); +unsigned char snd_sbmixer_read(struct snd_sb *chip, unsigned char reg); +int snd_sbmixer_new(struct snd_sb *chip); /* sb8_init.c */ -int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm); +int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm); /* sb8.c */ -irqreturn_t snd_sb8dsp_interrupt(sb_t *chip); -int snd_sb8_playback_open(snd_pcm_substream_t *substream); -int snd_sb8_capture_open(snd_pcm_substream_t *substream); -int snd_sb8_playback_close(snd_pcm_substream_t *substream); -int snd_sb8_capture_close(snd_pcm_substream_t *substream); +irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip); +int snd_sb8_playback_open(struct snd_pcm_substream *substream); +int snd_sb8_capture_open(struct snd_pcm_substream *substream); +int snd_sb8_playback_close(struct snd_pcm_substream *substream); +int snd_sb8_capture_close(struct snd_pcm_substream *substream); /* midi8.c */ -irqreturn_t snd_sb8dsp_midi_interrupt(sb_t *chip); -int snd_sb8dsp_midi(sb_t *chip, int device, snd_rawmidi_t ** rrawmidi); +irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb *chip); +int snd_sb8dsp_midi(struct snd_sb *chip, int device, struct snd_rawmidi ** rrawmidi); /* sb16_init.c */ -int snd_sb16dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm); -const snd_pcm_ops_t *snd_sb16dsp_get_pcm_ops(int direction); -int snd_sb16dsp_configure(sb_t *chip); +int snd_sb16dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm); +const struct snd_pcm_ops *snd_sb16dsp_get_pcm_ops(int direction); +int snd_sb16dsp_configure(struct snd_sb *chip); /* sb16.c */ irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs); @@ -328,7 +326,7 @@ enum { #define SB_MIXVAL_INPUT_SW(reg1, reg2, left_shift, right_shift) \ ((reg1) | ((reg2) << 8) | ((left_shift) << 16) | ((right_shift) << 24)) -int snd_sbmixer_add_ctl(sb_t *chip, const char *name, int index, int type, unsigned long value); +int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int type, unsigned long value); /* for ease of use */ struct sbmix_elem { @@ -352,7 +350,7 @@ struct sbmix_elem { .type = SB_MIX_INPUT_SW, \ .private_value = SB_MIXVAL_INPUT_SW(reg1, reg2, left_shift, right_shift) } -static inline int snd_sbmixer_add_ctl_elem(sb_t *chip, const struct sbmix_elem *c) +static inline int snd_sbmixer_add_ctl_elem(struct snd_sb *chip, const struct sbmix_elem *c) { return snd_sbmixer_add_ctl(chip, c->name, 0, c->type, c->private_value); } diff --git a/include/sound/sb16_csp.h b/include/sound/sb16_csp.h index eb8368b..3b44d4b 100644 --- a/include/sound/sb16_csp.h +++ b/include/sound/sb16_csp.h @@ -63,25 +63,25 @@ #define SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE 0x3000 /* microcode header */ -typedef struct snd_sb_csp_mc_header { +struct snd_sb_csp_mc_header { char codec_name[16]; /* id name of codec */ unsigned short func_req; /* requested function */ -} snd_sb_csp_mc_header_t; +}; /* microcode to be loaded */ -typedef struct snd_sb_csp_microcode { - snd_sb_csp_mc_header_t info; +struct snd_sb_csp_microcode { + struct snd_sb_csp_mc_header info; unsigned char data[SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE]; -} snd_sb_csp_microcode_t; +}; /* start CSP with sample_width in mono/stereo */ -typedef struct snd_sb_csp_start { +struct snd_sb_csp_start { int sample_width; /* sample width, look above */ int channels; /* channels, look above */ -} snd_sb_csp_start_t; +}; /* CSP information */ -typedef struct snd_sb_csp_info { +struct snd_sb_csp_info { char codec_name[16]; /* id name of codec */ unsigned short func_nr; /* function number */ unsigned int acc_format; /* accepted PCM formats */ @@ -93,17 +93,17 @@ typedef struct snd_sb_csp_info { unsigned short run_width; /* current sample width */ unsigned short version; /* version id: 0x10 - 0x1f */ unsigned short state; /* state bits */ -} snd_sb_csp_info_t; +}; /* HWDEP controls */ /* get CSP information */ -#define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, snd_sb_csp_info_t) +#define SNDRV_SB_CSP_IOCTL_INFO _IOR('H', 0x10, struct snd_sb_csp_info) /* load microcode to CSP */ -#define SNDRV_SB_CSP_IOCTL_LOAD_CODE _IOW('H', 0x11, snd_sb_csp_microcode_t) +#define SNDRV_SB_CSP_IOCTL_LOAD_CODE _IOW('H', 0x11, struct snd_sb_csp_microcode) /* unload microcode from CSP */ #define SNDRV_SB_CSP_IOCTL_UNLOAD_CODE _IO('H', 0x12) /* start CSP */ -#define SNDRV_SB_CSP_IOCTL_START _IOW('H', 0x13, snd_sb_csp_start_t) +#define SNDRV_SB_CSP_IOCTL_START _IOW('H', 0x13, struct snd_sb_csp_start) /* stop CSP */ #define SNDRV_SB_CSP_IOCTL_STOP _IO('H', 0x14) /* pause CSP and DMA transfer */ @@ -115,25 +115,25 @@ typedef struct snd_sb_csp_info { #include "sb.h" #include "hwdep.h" -typedef struct snd_sb_csp snd_sb_csp_t; +struct snd_sb_csp; /* * CSP operators */ -typedef struct { - int (*csp_use) (snd_sb_csp_t * p); - int (*csp_unuse) (snd_sb_csp_t * p); - int (*csp_autoload) (snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode); - int (*csp_start) (snd_sb_csp_t * p, int sample_width, int channels); - int (*csp_stop) (snd_sb_csp_t * p); - int (*csp_qsound_transfer) (snd_sb_csp_t * p); -} snd_sb_csp_ops_t; +struct snd_sb_csp_ops { + int (*csp_use) (struct snd_sb_csp * p); + int (*csp_unuse) (struct snd_sb_csp * p); + int (*csp_autoload) (struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode); + int (*csp_start) (struct snd_sb_csp * p, int sample_width, int channels); + int (*csp_stop) (struct snd_sb_csp * p); + int (*csp_qsound_transfer) (struct snd_sb_csp * p); +}; /* * CSP private data */ struct snd_sb_csp { - sb_t *chip; /* SB16 DSP */ + struct snd_sb *chip; /* SB16 DSP */ int used; /* usage flag - exclusive */ char codec_name[16]; /* name of codec */ unsigned short func_nr; /* function number */ @@ -147,7 +147,7 @@ struct snd_sb_csp { int version; /* CSP version (0x10 - 0x1f) */ int running; /* running state */ - snd_sb_csp_ops_t ops; /* operators */ + struct snd_sb_csp_ops ops; /* operators */ spinlock_t q_lock; /* locking */ int q_enabled; /* enabled flag */ @@ -155,13 +155,13 @@ struct snd_sb_csp { int qpos_right; /* right position */ int qpos_changed; /* position changed flag */ - snd_kcontrol_t *qsound_switch; - snd_kcontrol_t *qsound_space; + struct snd_kcontrol *qsound_switch; + struct snd_kcontrol *qsound_space; struct semaphore access_mutex; /* locking */ }; -int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep); +int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep); #endif #endif /* __SOUND_SB16_CSP */ diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index b09c657..c0b8d61 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -45,7 +45,7 @@ * directly. The macros handle the port number and command word. */ /* Write a word */ -void snd_emu8000_poke(emu8000_t *emu, unsigned int port, unsigned int reg, unsigned int val) +void snd_emu8000_poke(struct snd_emu8000 *emu, unsigned int port, unsigned int reg, unsigned int val) { unsigned long flags; spin_lock_irqsave(&emu->reg_lock, flags); @@ -58,7 +58,7 @@ void snd_emu8000_poke(emu8000_t *emu, unsigned int port, unsigned int reg, unsig } /* Read a word */ -unsigned short snd_emu8000_peek(emu8000_t *emu, unsigned int port, unsigned int reg) +unsigned short snd_emu8000_peek(struct snd_emu8000 *emu, unsigned int port, unsigned int reg) { unsigned short res; unsigned long flags; @@ -73,7 +73,7 @@ unsigned short snd_emu8000_peek(emu8000_t *emu, unsigned int port, unsigned int } /* Write a double word */ -void snd_emu8000_poke_dw(emu8000_t *emu, unsigned int port, unsigned int reg, unsigned int val) +void snd_emu8000_poke_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg, unsigned int val) { unsigned long flags; spin_lock_irqsave(&emu->reg_lock, flags); @@ -87,7 +87,7 @@ void snd_emu8000_poke_dw(emu8000_t *emu, unsigned int port, unsigned int reg, un } /* Read a double word */ -unsigned int snd_emu8000_peek_dw(emu8000_t *emu, unsigned int port, unsigned int reg) +unsigned int snd_emu8000_peek_dw(struct snd_emu8000 *emu, unsigned int port, unsigned int reg) { unsigned short low; unsigned int res; @@ -107,7 +107,7 @@ unsigned int snd_emu8000_peek_dw(emu8000_t *emu, unsigned int port, unsigned int * Set up / close a channel to be used for DMA. */ /*exported*/ void -snd_emu8000_dma_chan(emu8000_t *emu, int ch, int mode) +snd_emu8000_dma_chan(struct snd_emu8000 *emu, int ch, int mode) { unsigned right_bit = (mode & EMU8000_RAM_RIGHT) ? 0x01000000 : 0; mode &= EMU8000_RAM_MODE_MASK; @@ -132,7 +132,7 @@ snd_emu8000_dma_chan(emu8000_t *emu, int ch, int mode) /* */ static void __init -snd_emu8000_read_wait(emu8000_t *emu) +snd_emu8000_read_wait(struct snd_emu8000 *emu) { while ((EMU8000_SMALR_READ(emu) & 0x80000000) != 0) { schedule_timeout_interruptible(1); @@ -144,7 +144,7 @@ snd_emu8000_read_wait(emu8000_t *emu) /* */ static void __init -snd_emu8000_write_wait(emu8000_t *emu) +snd_emu8000_write_wait(struct snd_emu8000 *emu) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { schedule_timeout_interruptible(1); @@ -157,7 +157,7 @@ snd_emu8000_write_wait(emu8000_t *emu) * detect a card at the given port */ static int __init -snd_emu8000_detect(emu8000_t *emu) +snd_emu8000_detect(struct snd_emu8000 *emu) { /* Initialise */ EMU8000_HWCF1_WRITE(emu, 0x0059); @@ -183,7 +183,7 @@ snd_emu8000_detect(emu8000_t *emu) * intiailize audio channels */ static void __init -init_audio(emu8000_t *emu) +init_audio(struct snd_emu8000 *emu) { int ch; @@ -224,7 +224,7 @@ init_audio(emu8000_t *emu) * initialize DMA address */ static void __init -init_dma(emu8000_t *emu) +init_dma(struct snd_emu8000 *emu) { EMU8000_SMALR_WRITE(emu, 0); EMU8000_SMARR_WRITE(emu, 0); @@ -328,7 +328,7 @@ static unsigned short init4[128] /*__devinitdata*/ = { * is meant to work */ static void __init -send_array(emu8000_t *emu, unsigned short *data, int size) +send_array(struct snd_emu8000 *emu, unsigned short *data, int size) { int i; unsigned short *p; @@ -350,7 +350,7 @@ send_array(emu8000_t *emu, unsigned short *data, int size) * initialisation sequence in the adip. */ static void __init -init_arrays(emu8000_t *emu) +init_arrays(struct snd_emu8000 *emu) { send_array(emu, init1, ARRAY_SIZE(init1)/4); @@ -376,7 +376,7 @@ init_arrays(emu8000_t *emu) * reallocating between read and write. */ static void __init -size_dram(emu8000_t *emu) +size_dram(struct snd_emu8000 *emu) { int i, size; @@ -455,7 +455,7 @@ size_dram(emu8000_t *emu) * and therefore lose 2 voices. */ /*exported*/ void -snd_emu8000_init_fm(emu8000_t *emu) +snd_emu8000_init_fm(struct snd_emu8000 *emu) { unsigned long flags; @@ -501,7 +501,7 @@ snd_emu8000_init_fm(emu8000_t *emu) * The main initialization routine. */ static void __init -snd_emu8000_init_hw(emu8000_t *emu) +snd_emu8000_init_hw(struct snd_emu8000 *emu) { int i; @@ -585,7 +585,7 @@ static unsigned short treble_parm[12][9] = { * set Emu8000 digital equalizer; from 0 to 11 [-12dB - 12dB] */ /*exported*/ void -snd_emu8000_update_equalizer(emu8000_t *emu) +snd_emu8000_update_equalizer(struct snd_emu8000 *emu) { unsigned short w; int bass = emu->bass_level; @@ -628,17 +628,17 @@ snd_emu8000_update_equalizer(emu8000_t *emu) /* user can define chorus modes up to 32 */ #define SNDRV_EMU8000_CHORUS_NUMBERS 32 -typedef struct soundfont_chorus_fx_t { +struct soundfont_chorus_fx { unsigned short feedback; /* feedback level (0xE600-0xE6FF) */ unsigned short delay_offset; /* delay (0-0x0DA3) [1/44100 sec] */ unsigned short lfo_depth; /* LFO depth (0xBC00-0xBCFF) */ unsigned int delay; /* right delay (0-0xFFFFFFFF) [1/256/44100 sec] */ unsigned int lfo_freq; /* LFO freq LFO freq (0-0xFFFFFFFF) */ -} soundfont_chorus_fx_t; +}; /* 5 parameters for each chorus mode; 3 x 16bit, 2 x 32bit */ static char chorus_defined[SNDRV_EMU8000_CHORUS_NUMBERS]; -static soundfont_chorus_fx_t chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = { +static struct soundfont_chorus_fx chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = { {0xE600, 0x03F6, 0xBC2C ,0x00000000, 0x0000006D}, /* chorus 1 */ {0xE608, 0x031A, 0xBC6E, 0x00000000, 0x0000017C}, /* chorus 2 */ {0xE610, 0x031A, 0xBC84, 0x00000000, 0x00000083}, /* chorus 3 */ @@ -650,9 +650,9 @@ static soundfont_chorus_fx_t chorus_parm[SNDRV_EMU8000_CHORUS_NUMBERS] = { }; /*exported*/ int -snd_emu8000_load_chorus_fx(emu8000_t *emu, int mode, const void __user *buf, long len) +snd_emu8000_load_chorus_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len) { - soundfont_chorus_fx_t rec; + struct soundfont_chorus_fx rec; if (mode < SNDRV_EMU8000_CHORUS_PREDEFINED || mode >= SNDRV_EMU8000_CHORUS_NUMBERS) { snd_printk(KERN_WARNING "invalid chorus mode %d for uploading\n", mode); return -EINVAL; @@ -665,7 +665,7 @@ snd_emu8000_load_chorus_fx(emu8000_t *emu, int mode, const void __user *buf, lon } /*exported*/ void -snd_emu8000_update_chorus_mode(emu8000_t *emu) +snd_emu8000_update_chorus_mode(struct snd_emu8000 *emu) { int effect = emu->chorus_mode; if (effect < 0 || effect >= SNDRV_EMU8000_CHORUS_NUMBERS || @@ -699,15 +699,15 @@ snd_emu8000_update_chorus_mode(emu8000_t *emu) /* user can define reverb modes up to 32 */ #define SNDRV_EMU8000_REVERB_NUMBERS 32 -typedef struct soundfont_reverb_fx_t { +struct soundfont_reverb_fx { unsigned short parms[28]; -} soundfont_reverb_fx_t; +}; /* reverb mode settings; write the following 28 data of 16 bit length * on the corresponding ports in the reverb_cmds array */ static char reverb_defined[SNDRV_EMU8000_CHORUS_NUMBERS]; -static soundfont_reverb_fx_t reverb_parm[SNDRV_EMU8000_REVERB_NUMBERS] = { +static struct soundfont_reverb_fx reverb_parm[SNDRV_EMU8000_REVERB_NUMBERS] = { {{ /* room 1 */ 0xB488, 0xA450, 0x9550, 0x84B5, 0x383A, 0x3EB5, 0x72F4, 0x72A4, 0x7254, 0x7204, 0x7204, 0x7204, 0x4416, 0x4516, @@ -777,9 +777,9 @@ static struct reverb_cmd_pair { }; /*exported*/ int -snd_emu8000_load_reverb_fx(emu8000_t *emu, int mode, const void __user *buf, long len) +snd_emu8000_load_reverb_fx(struct snd_emu8000 *emu, int mode, const void __user *buf, long len) { - soundfont_reverb_fx_t rec; + struct soundfont_reverb_fx rec; if (mode < SNDRV_EMU8000_REVERB_PREDEFINED || mode >= SNDRV_EMU8000_REVERB_NUMBERS) { snd_printk(KERN_WARNING "invalid reverb mode %d for uploading\n", mode); @@ -793,7 +793,7 @@ snd_emu8000_load_reverb_fx(emu8000_t *emu, int mode, const void __user *buf, lon } /*exported*/ void -snd_emu8000_update_reverb_mode(emu8000_t *emu) +snd_emu8000_update_reverb_mode(struct snd_emu8000 *emu) { int effect = emu->reverb_mode; int i; @@ -819,7 +819,7 @@ snd_emu8000_update_reverb_mode(emu8000_t *emu) /* * bass/treble */ -static int mixer_bass_treble_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int mixer_bass_treble_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -828,17 +828,17 @@ static int mixer_bass_treble_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int mixer_bass_treble_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_bass_treble_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->treble_level : emu->bass_level; return 0; } -static int mixer_bass_treble_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_bass_treble_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1; @@ -857,7 +857,7 @@ static int mixer_bass_treble_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t mixer_bass_control = +static struct snd_kcontrol_new mixer_bass_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Synth Tone Control - Bass", @@ -867,7 +867,7 @@ static snd_kcontrol_new_t mixer_bass_control = .private_value = 0, }; -static snd_kcontrol_new_t mixer_treble_control = +static struct snd_kcontrol_new mixer_treble_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Synth Tone Control - Treble", @@ -880,7 +880,7 @@ static snd_kcontrol_new_t mixer_treble_control = /* * chorus/reverb mode */ -static int mixer_chorus_reverb_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int mixer_chorus_reverb_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -889,17 +889,17 @@ static int mixer_chorus_reverb_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int mixer_chorus_reverb_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_chorus_reverb_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->chorus_mode : emu->reverb_mode; return 0; } -static int mixer_chorus_reverb_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_chorus_reverb_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1; @@ -924,7 +924,7 @@ static int mixer_chorus_reverb_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return change; } -static snd_kcontrol_new_t mixer_chorus_mode_control = +static struct snd_kcontrol_new mixer_chorus_mode_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Chorus Mode", @@ -934,7 +934,7 @@ static snd_kcontrol_new_t mixer_chorus_mode_control = .private_value = 1, }; -static snd_kcontrol_new_t mixer_reverb_mode_control = +static struct snd_kcontrol_new mixer_reverb_mode_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Reverb Mode", @@ -947,7 +947,7 @@ static snd_kcontrol_new_t mixer_reverb_mode_control = /* * FM OPL3 chorus/reverb depth */ -static int mixer_fm_depth_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int mixer_fm_depth_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -956,17 +956,17 @@ static int mixer_fm_depth_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int mixer_fm_depth_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_fm_depth_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = kcontrol->private_value ? emu->fm_chorus_depth : emu->fm_reverb_depth; return 0; } -static int mixer_fm_depth_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int mixer_fm_depth_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu8000_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu8000 *emu = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned short val1; @@ -986,7 +986,7 @@ static int mixer_fm_depth_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -static snd_kcontrol_new_t mixer_fm_chorus_depth_control = +static struct snd_kcontrol_new mixer_fm_chorus_depth_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "FM Chorus Depth", @@ -996,7 +996,7 @@ static snd_kcontrol_new_t mixer_fm_chorus_depth_control = .private_value = 1, }; -static snd_kcontrol_new_t mixer_fm_reverb_depth_control = +static struct snd_kcontrol_new mixer_fm_reverb_depth_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "FM Reverb Depth", @@ -1007,7 +1007,7 @@ static snd_kcontrol_new_t mixer_fm_reverb_depth_control = }; -static snd_kcontrol_new_t *mixer_defs[EMU8000_NUM_CONTROLS] = { +static struct snd_kcontrol_new *mixer_defs[EMU8000_NUM_CONTROLS] = { &mixer_bass_control, &mixer_treble_control, &mixer_chorus_mode_control, @@ -1020,7 +1020,7 @@ static snd_kcontrol_new_t *mixer_defs[EMU8000_NUM_CONTROLS] = { * create and attach mixer elements for WaveTable treble/bass controls */ static int __init -snd_emu8000_create_mixer(snd_card_t *card, emu8000_t *emu) +snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu) { int i, err = 0; @@ -1049,7 +1049,7 @@ __error: /* * free resources */ -static int snd_emu8000_free(emu8000_t *hw) +static int snd_emu8000_free(struct snd_emu8000 *hw) { release_and_free_resource(hw->res_port1); release_and_free_resource(hw->res_port2); @@ -1060,9 +1060,9 @@ static int snd_emu8000_free(emu8000_t *hw) /* */ -static int snd_emu8000_dev_free(snd_device_t *device) +static int snd_emu8000_dev_free(struct snd_device *device) { - emu8000_t *hw = device->device_data; + struct snd_emu8000 *hw = device->device_data; return snd_emu8000_free(hw); } @@ -1070,12 +1070,13 @@ static int snd_emu8000_dev_free(snd_device_t *device) * initialize and register emu8000 synth device. */ int __init -snd_emu8000_new(snd_card_t *card, int index, long port, int seq_ports, snd_seq_device_t **awe_ret) +snd_emu8000_new(struct snd_card *card, int index, long port, int seq_ports, + struct snd_seq_device **awe_ret) { - snd_seq_device_t *awe; - emu8000_t *hw; + struct snd_seq_device *awe; + struct snd_emu8000 *hw; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_emu8000_dev_free, }; @@ -1127,9 +1128,9 @@ snd_emu8000_new(snd_card_t *card, int index, long port, int seq_ports, snd_seq_d } #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) if (snd_seq_device_new(card, index, SNDRV_SEQ_DEV_ID_EMU8000, - sizeof(emu8000_t*), &awe) >= 0) { + sizeof(struct snd_emu8000*), &awe) >= 0) { strcpy(awe->name, "EMU-8000"); - *(emu8000_t**)SNDRV_SEQ_DEVICE_ARGPTR(awe) = hw; + *(struct snd_emu8000 **)SNDRV_SEQ_DEVICE_ARGPTR(awe) = hw; } #else awe = NULL; diff --git a/sound/isa/sb/emu8000_callback.c b/sound/isa/sb/emu8000_callback.c index 1cc4101..9a3c71cc 100644 --- a/sound/isa/sb/emu8000_callback.c +++ b/sound/isa/sb/emu8000_callback.c @@ -25,27 +25,30 @@ /* * prototypes */ -static snd_emux_voice_t *get_voice(snd_emux_t *emu, snd_emux_port_t *port); -static int start_voice(snd_emux_voice_t *vp); -static void trigger_voice(snd_emux_voice_t *vp); -static void release_voice(snd_emux_voice_t *vp); -static void update_voice(snd_emux_voice_t *vp, int update); -static void reset_voice(snd_emux_t *emu, int ch); -static void terminate_voice(snd_emux_voice_t *vp); -static void sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *chset); +static struct snd_emux_voice *get_voice(struct snd_emux *emu, + struct snd_emux_port *port); +static int start_voice(struct snd_emux_voice *vp); +static void trigger_voice(struct snd_emux_voice *vp); +static void release_voice(struct snd_emux_voice *vp); +static void update_voice(struct snd_emux_voice *vp, int update); +static void reset_voice(struct snd_emux *emu, int ch); +static void terminate_voice(struct snd_emux_voice *vp); +static void sysex(struct snd_emux *emu, char *buf, int len, int parsed, + struct snd_midi_channel_set *chset); #ifdef CONFIG_SND_SEQUENCER_OSS -static int oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2); +static int oss_ioctl(struct snd_emux *emu, int cmd, int p1, int p2); #endif -static int load_fx(snd_emux_t *emu, int type, int mode, const void __user *buf, long len); - -static void set_pitch(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_volume(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_pan(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_tremfreq(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp); -static void set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp); -static void snd_emu8000_tweak_voice(emu8000_t *emu, int ch); +static int load_fx(struct snd_emux *emu, int type, int mode, + const void __user *buf, long len); + +static void set_pitch(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_volume(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_pan(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_fmmod(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_tremfreq(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_fm2frq2(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void set_filterQ(struct snd_emu8000 *hw, struct snd_emux_voice *vp); +static void snd_emu8000_tweak_voice(struct snd_emu8000 *emu, int ch); /* * Ensure a value is between two points @@ -58,7 +61,7 @@ static void snd_emu8000_tweak_voice(emu8000_t *emu, int ch); /* * set up operators */ -static snd_emux_operators_t emu8000_ops = { +static struct snd_emux_operators emu8000_ops = { .owner = THIS_MODULE, .get_voice = get_voice, .prepare = start_voice, @@ -78,7 +81,7 @@ static snd_emux_operators_t emu8000_ops = { }; void -snd_emu8000_ops_setup(emu8000_t *hw) +snd_emu8000_ops_setup(struct snd_emu8000 *hw) { hw->emu->ops = emu8000_ops; } @@ -89,10 +92,10 @@ snd_emu8000_ops_setup(emu8000_t *hw) * Terminate a voice */ static void -release_voice(snd_emux_voice_t *vp) +release_voice(struct snd_emux_voice *vp) { int dcysusv; - emu8000_t *hw; + struct snd_emu8000 *hw; hw = vp->hw; dcysusv = 0x8000 | (unsigned char)vp->reg.parm.modrelease; @@ -105,9 +108,9 @@ release_voice(snd_emux_voice_t *vp) /* */ static void -terminate_voice(snd_emux_voice_t *vp) +terminate_voice(struct snd_emux_voice *vp) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = vp->hw; EMU8000_DCYSUSV_WRITE(hw, vp->ch, 0x807F); @@ -117,9 +120,9 @@ terminate_voice(snd_emux_voice_t *vp) /* */ static void -update_voice(snd_emux_voice_t *vp, int update) +update_voice(struct snd_emux_voice *vp, int update) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = vp->hw; if (update & SNDRV_EMUX_UPDATE_VOLUME) @@ -149,12 +152,12 @@ update_voice(snd_emux_voice_t *vp, int update) * The channel index (vp->ch) must be initialized in this routine. * In Emu8k, it is identical with the array index. */ -static snd_emux_voice_t * -get_voice(snd_emux_t *emu, snd_emux_port_t *port) +static struct snd_emux_voice * +get_voice(struct snd_emux *emu, struct snd_emux_port *port) { int i; - snd_emux_voice_t *vp; - emu8000_t *hw; + struct snd_emux_voice *vp; + struct snd_emu8000 *hw; /* what we are looking for, in order of preference */ enum { @@ -227,13 +230,13 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port) /* */ static int -start_voice(snd_emux_voice_t *vp) +start_voice(struct snd_emux_voice *vp) { unsigned int temp; int ch; int addr; - snd_midi_channel_t *chan; - emu8000_t *hw; + struct snd_midi_channel *chan; + struct snd_emu8000 *hw; hw = vp->hw; ch = vp->ch; @@ -307,11 +310,11 @@ start_voice(snd_emux_voice_t *vp) * Start envelope */ static void -trigger_voice(snd_emux_voice_t *vp) +trigger_voice(struct snd_emux_voice *vp) { int ch = vp->ch; unsigned int temp; - emu8000_t *hw; + struct snd_emu8000 *hw; hw = vp->hw; @@ -329,9 +332,9 @@ trigger_voice(snd_emux_voice_t *vp) * reset voice parameters */ static void -reset_voice(snd_emux_t *emu, int ch) +reset_voice(struct snd_emux *emu, int ch) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = emu->hw; EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F); @@ -342,7 +345,7 @@ reset_voice(snd_emux_t *emu, int ch) * Set the pitch of a possibly playing note. */ static void -set_pitch(emu8000_t *hw, snd_emux_voice_t *vp) +set_pitch(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { EMU8000_IP_WRITE(hw, vp->ch, vp->apitch); } @@ -351,7 +354,7 @@ set_pitch(emu8000_t *hw, snd_emux_voice_t *vp) * Set the volume of a possibly already playing note */ static void -set_volume(emu8000_t *hw, snd_emux_voice_t *vp) +set_volume(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { int ifatn; @@ -365,7 +368,7 @@ set_volume(emu8000_t *hw, snd_emux_voice_t *vp) * Set pan and loop start address. */ static void -set_pan(emu8000_t *hw, snd_emux_voice_t *vp) +set_pan(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { unsigned int temp; @@ -376,7 +379,7 @@ set_pan(emu8000_t *hw, snd_emux_voice_t *vp) #define MOD_SENSE 18 static void -set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp) +set_fmmod(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { unsigned short fmmod; short pitch; @@ -394,14 +397,14 @@ set_fmmod(emu8000_t *hw, snd_emux_voice_t *vp) /* set tremolo (lfo1) volume & frequency */ static void -set_tremfreq(emu8000_t *hw, snd_emux_voice_t *vp) +set_tremfreq(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { EMU8000_TREMFRQ_WRITE(hw, vp->ch, vp->reg.parm.tremfrq); } /* set lfo2 pitch & frequency */ static void -set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp) +set_fm2frq2(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { unsigned short fm2frq2; short pitch; @@ -419,7 +422,7 @@ set_fm2frq2(emu8000_t *hw, snd_emux_voice_t *vp) /* set filterQ */ static void -set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp) +set_filterQ(struct snd_emu8000 *hw, struct snd_emux_voice *vp) { unsigned int addr; addr = EMU8000_CCCA_READ(hw, vp->ch) & 0xffffff; @@ -431,7 +434,7 @@ set_filterQ(emu8000_t *hw, snd_emux_voice_t *vp) * set the envelope & LFO parameters to the default values */ static void -snd_emu8000_tweak_voice(emu8000_t *emu, int i) +snd_emu8000_tweak_voice(struct snd_emu8000 *emu, int i) { /* set all mod/vol envelope shape to minimum */ EMU8000_ENVVOL_WRITE(emu, i, 0x8000); @@ -453,9 +456,9 @@ snd_emu8000_tweak_voice(emu8000_t *emu, int i) * sysex callback */ static void -sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *chset) +sysex(struct snd_emux *emu, char *buf, int len, int parsed, struct snd_midi_channel_set *chset) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = emu->hw; @@ -478,9 +481,9 @@ sysex(snd_emux_t *emu, char *buf, int len, int parsed, snd_midi_channel_set_t *c * OSS ioctl callback */ static int -oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2) +oss_ioctl(struct snd_emux *emu, int cmd, int p1, int p2) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = emu->hw; @@ -523,9 +526,9 @@ oss_ioctl(snd_emux_t *emu, int cmd, int p1, int p2) */ static int -load_fx(snd_emux_t *emu, int type, int mode, const void __user *buf, long len) +load_fx(struct snd_emux *emu, int type, int mode, const void __user *buf, long len) { - emu8000_t *hw; + struct snd_emu8000 *hw; hw = emu->hw; /* skip header */ diff --git a/sound/isa/sb/emu8000_local.h b/sound/isa/sb/emu8000_local.h index ea4996a..2ac77f1 100644 --- a/sound/isa/sb/emu8000_local.h +++ b/sound/isa/sb/emu8000_local.h @@ -30,14 +30,17 @@ #include <sound/emu8000_reg.h> /* emu8000_patch.c */ -int snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr, const void __user *data, long count); -int snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr); -void snd_emu8000_sample_reset(snd_emux_t *rec); +int snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *data, long count); +int snd_emu8000_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr); +void snd_emu8000_sample_reset(struct snd_emux *rec); /* emu8000_callback.c */ -void snd_emu8000_ops_setup(emu8000_t *emu); +void snd_emu8000_ops_setup(struct snd_emu8000 *emu); /* emu8000_pcm.c */ -int snd_emu8000_pcm_new(snd_card_t *card, emu8000_t *emu, int index); +int snd_emu8000_pcm_new(struct snd_card *card, struct snd_emu8000 *emu, int index); #endif /* __EMU8000_LOCAL_H */ diff --git a/sound/isa/sb/emu8000_patch.c b/sound/isa/sb/emu8000_patch.c index 2fea67e..80b1cf8 100644 --- a/sound/isa/sb/emu8000_patch.c +++ b/sound/isa/sb/emu8000_patch.c @@ -32,7 +32,7 @@ MODULE_PARM_DESC(emu8000_reset_addr, "reset write address at each time (makes sl * Open up channels. */ static int -snd_emu8000_open_dma(emu8000_t *emu, int write) +snd_emu8000_open_dma(struct snd_emu8000 *emu, int write) { int i; @@ -59,7 +59,7 @@ snd_emu8000_open_dma(emu8000_t *emu, int write) * Close all dram channels. */ static void -snd_emu8000_close_dma(emu8000_t *emu) +snd_emu8000_close_dma(struct snd_emu8000 *emu) { int i; @@ -106,7 +106,7 @@ read_word(const void __user *buf, int offset, int mode) /* */ static void -snd_emu8000_write_wait(emu8000_t *emu) +snd_emu8000_write_wait(struct snd_emu8000 *emu) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { schedule_timeout_interruptible(1); @@ -128,7 +128,7 @@ snd_emu8000_write_wait(emu8000_t *emu) * working. */ static inline void -write_word(emu8000_t *emu, int *offset, unsigned short data) +write_word(struct snd_emu8000 *emu, int *offset, unsigned short data) { if (emu8000_reset_addr) { if (emu8000_reset_addr > 1) @@ -144,15 +144,16 @@ write_word(emu8000_t *emu, int *offset, unsigned short data) * the generic soundfont routines as a callback. */ int -snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr, const void __user *data, long count) +snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *data, long count) { int i; int rc; int offset; int truesize; int dram_offset, dram_start; - emu8000_t *emu; + struct snd_emu8000 *emu; emu = rec->hw; snd_assert(sp != NULL, return -EINVAL); @@ -282,7 +283,8 @@ snd_emu8000_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, * free a sample block */ int -snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr) +snd_emu8000_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr) { if (sp->block) { snd_util_mem_free(hdr, sp->block); @@ -296,7 +298,7 @@ snd_emu8000_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, snd_util_memhdr_t * sample_reset callback - terminate voices */ void -snd_emu8000_sample_reset(snd_emux_t *rec) +snd_emu8000_sample_reset(struct snd_emux *rec) { snd_emux_terminate_all(rec); } diff --git a/sound/isa/sb/emu8000_pcm.c b/sound/isa/sb/emu8000_pcm.c index b323bee..91dc3d8 100644 --- a/sound/isa/sb/emu8000_pcm.c +++ b/sound/isa/sb/emu8000_pcm.c @@ -46,14 +46,12 @@ */ -typedef struct snd_emu8k_pcm emu8k_pcm_t; - struct snd_emu8k_pcm { - emu8000_t *emu; - snd_pcm_substream_t *substream; + struct snd_emu8000 *emu; + struct snd_pcm_substream *substream; unsigned int allocated_bytes; - snd_util_memblk_t *block; + struct snd_util_memblk *block; unsigned int offset; unsigned int buf_size; unsigned int period_size; @@ -77,7 +75,7 @@ struct snd_emu8k_pcm { * open up channels for the simultaneous data transfer and playback */ static int -emu8k_open_dram_for_pcm(emu8000_t *emu, int channels) +emu8k_open_dram_for_pcm(struct snd_emu8000 *emu, int channels) { int i; @@ -113,7 +111,7 @@ emu8k_open_dram_for_pcm(emu8000_t *emu, int channels) /* */ static void -snd_emu8000_write_wait(emu8000_t *emu, int can_schedule) +snd_emu8000_write_wait(struct snd_emu8000 *emu, int can_schedule) { while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) { if (can_schedule) { @@ -128,7 +126,7 @@ snd_emu8000_write_wait(emu8000_t *emu, int can_schedule) * close all channels */ static void -emu8k_close_dram(emu8000_t *emu) +emu8k_close_dram(struct snd_emu8000 *emu) { int i; @@ -156,7 +154,7 @@ static int calc_rate_offset(int hz) /* */ -static snd_pcm_hardware_t emu8k_pcm_hw = { +static struct snd_pcm_hardware emu8k_pcm_hw = { #ifdef USE_NONINTERLEAVE .info = SNDRV_PCM_INFO_NONINTERLEAVED, #else @@ -180,7 +178,7 @@ static snd_pcm_hardware_t emu8k_pcm_hw = { /* * get the current position at the given channel from CCCA register */ -static inline int emu8k_get_curpos(emu8k_pcm_t *rec, int ch) +static inline int emu8k_get_curpos(struct snd_emu8k_pcm *rec, int ch) { int val = EMU8000_CCCA_READ(rec->emu, ch) & 0xfffffff; val -= rec->loop_start[ch] - 1; @@ -194,7 +192,7 @@ static inline int emu8k_get_curpos(emu8k_pcm_t *rec, int ch) */ static void emu8k_pcm_timer_func(unsigned long data) { - emu8k_pcm_t *rec = (emu8k_pcm_t *)data; + struct snd_emu8k_pcm *rec = (struct snd_emu8k_pcm *)data; int ptr, delta; spin_lock(&rec->timer_lock); @@ -226,11 +224,11 @@ static void emu8k_pcm_timer_func(unsigned long data) * open pcm * creating an instance here */ -static int emu8k_pcm_open(snd_pcm_substream_t *subs) +static int emu8k_pcm_open(struct snd_pcm_substream *subs) { - emu8000_t *emu = snd_pcm_substream_chip(subs); - emu8k_pcm_t *rec; - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_emu8000 *emu = snd_pcm_substream_chip(subs); + struct snd_emu8k_pcm *rec; + struct snd_pcm_runtime *runtime = subs->runtime; rec = kzalloc(sizeof(*rec), GFP_KERNEL); if (! rec) @@ -256,9 +254,9 @@ static int emu8k_pcm_open(snd_pcm_substream_t *subs) return 0; } -static int emu8k_pcm_close(snd_pcm_substream_t *subs) +static int emu8k_pcm_close(struct snd_pcm_substream *subs) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; kfree(rec); subs->runtime->private_data = NULL; return 0; @@ -281,9 +279,9 @@ static int calc_pitch_target(int pitch) /* * set up the voice */ -static void setup_voice(emu8k_pcm_t *rec, int ch) +static void setup_voice(struct snd_emu8k_pcm *rec, int ch) { - emu8000_t *hw = rec->emu; + struct snd_emu8000 *hw = rec->emu; unsigned int temp; /* channel to be silent and idle */ @@ -334,10 +332,10 @@ static void setup_voice(emu8k_pcm_t *rec, int ch) /* * trigger the voice */ -static void start_voice(emu8k_pcm_t *rec, int ch) +static void start_voice(struct snd_emu8k_pcm *rec, int ch) { unsigned long flags; - emu8000_t *hw = rec->emu; + struct snd_emu8000 *hw = rec->emu; unsigned int temp, aux; int pt = calc_pitch_target(rec->pitch); @@ -370,10 +368,10 @@ static void start_voice(emu8k_pcm_t *rec, int ch) /* * stop the voice immediately */ -static void stop_voice(emu8k_pcm_t *rec, int ch) +static void stop_voice(struct snd_emu8k_pcm *rec, int ch) { unsigned long flags; - emu8000_t *hw = rec->emu; + struct snd_emu8000 *hw = rec->emu; EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F); @@ -386,9 +384,9 @@ static void stop_voice(emu8k_pcm_t *rec, int ch) spin_unlock_irqrestore(&rec->timer_lock, flags); } -static int emu8k_pcm_trigger(snd_pcm_substream_t *subs, int cmd) +static int emu8k_pcm_trigger(struct snd_pcm_substream *subs, int cmd) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; int ch; switch (cmd) { @@ -428,7 +426,7 @@ do { \ #ifdef USE_NONINTERLEAVE /* copy one channel block */ -static int emu8k_transfer_block(emu8000_t *emu, int offset, unsigned short *buf, int count) +static int emu8k_transfer_block(struct snd_emu8000 *emu, int offset, unsigned short *buf, int count) { EMU8000_SMALW_WRITE(emu, offset); while (count > 0) { @@ -442,14 +440,14 @@ static int emu8k_transfer_block(emu8000_t *emu, int offset, unsigned short *buf, return 0; } -static int emu8k_pcm_copy(snd_pcm_substream_t *subs, +static int emu8k_pcm_copy(struct snd_pcm_substream *subs, int voice, snd_pcm_uframes_t pos, void *src, snd_pcm_uframes_t count) { - emu8k_pcm_t *rec = subs->runtime->private_data; - emu8000_t *emu = rec->emu; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; + struct snd_emu8000 *emu = rec->emu; snd_emu8000_write_wait(emu, 1); if (voice == -1) { @@ -469,7 +467,7 @@ static int emu8k_pcm_copy(snd_pcm_substream_t *subs, } /* make a channel block silence */ -static int emu8k_silence_block(emu8000_t *emu, int offset, int count) +static int emu8k_silence_block(struct snd_emu8000 *emu, int offset, int count) { EMU8000_SMALW_WRITE(emu, offset); while (count > 0) { @@ -480,13 +478,13 @@ static int emu8k_silence_block(emu8000_t *emu, int offset, int count) return 0; } -static int emu8k_pcm_silence(snd_pcm_substream_t *subs, +static int emu8k_pcm_silence(struct snd_pcm_substream *subs, int voice, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - emu8k_pcm_t *rec = subs->runtime->private_data; - emu8000_t *emu = rec->emu; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; + struct snd_emu8000 *emu = rec->emu; snd_emu8000_write_wait(emu, 1); if (voice == -1 && rec->voices == 1) @@ -508,14 +506,14 @@ static int emu8k_pcm_silence(snd_pcm_substream_t *subs, * copy the interleaved data can be done easily by using * DMA "left" and "right" channels on emu8k engine. */ -static int emu8k_pcm_copy(snd_pcm_substream_t *subs, +static int emu8k_pcm_copy(struct snd_pcm_substream *subs, int voice, snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - emu8k_pcm_t *rec = subs->runtime->private_data; - emu8000_t *emu = rec->emu; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; + struct snd_emu8000 *emu = rec->emu; unsigned short __user *buf = src; snd_emu8000_write_wait(emu, 1); @@ -539,13 +537,13 @@ static int emu8k_pcm_copy(snd_pcm_substream_t *subs, return 0; } -static int emu8k_pcm_silence(snd_pcm_substream_t *subs, +static int emu8k_pcm_silence(struct snd_pcm_substream *subs, int voice, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - emu8k_pcm_t *rec = subs->runtime->private_data; - emu8000_t *emu = rec->emu; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; + struct snd_emu8000 *emu = rec->emu; snd_emu8000_write_wait(emu, 1); EMU8000_SMALW_WRITE(emu, rec->loop_start[0] + pos); @@ -567,10 +565,10 @@ static int emu8k_pcm_silence(snd_pcm_substream_t *subs, /* * allocate a memory block */ -static int emu8k_pcm_hw_params(snd_pcm_substream_t *subs, - snd_pcm_hw_params_t *hw_params) +static int emu8k_pcm_hw_params(struct snd_pcm_substream *subs, + struct snd_pcm_hw_params *hw_params) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; if (rec->block) { /* reallocation - release the old block */ @@ -592,9 +590,9 @@ static int emu8k_pcm_hw_params(snd_pcm_substream_t *subs, /* * free the memory block */ -static int emu8k_pcm_hw_free(snd_pcm_substream_t *subs) +static int emu8k_pcm_hw_free(struct snd_pcm_substream *subs) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; if (rec->block) { int ch; @@ -610,9 +608,9 @@ static int emu8k_pcm_hw_free(snd_pcm_substream_t *subs) /* */ -static int emu8k_pcm_prepare(snd_pcm_substream_t *subs) +static int emu8k_pcm_prepare(struct snd_pcm_substream *subs) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; rec->pitch = 0xe000 + calc_rate_offset(subs->runtime->rate); rec->last_ptr = 0; @@ -656,16 +654,16 @@ static int emu8k_pcm_prepare(snd_pcm_substream_t *subs) return 0; } -static snd_pcm_uframes_t emu8k_pcm_pointer(snd_pcm_substream_t *subs) +static snd_pcm_uframes_t emu8k_pcm_pointer(struct snd_pcm_substream *subs) { - emu8k_pcm_t *rec = subs->runtime->private_data; + struct snd_emu8k_pcm *rec = subs->runtime->private_data; if (rec->running) return emu8k_get_curpos(rec, 0); return 0; } -static snd_pcm_ops_t emu8k_pcm_ops = { +static struct snd_pcm_ops emu8k_pcm_ops = { .open = emu8k_pcm_open, .close = emu8k_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -679,15 +677,15 @@ static snd_pcm_ops_t emu8k_pcm_ops = { }; -static void snd_emu8000_pcm_free(snd_pcm_t *pcm) +static void snd_emu8000_pcm_free(struct snd_pcm *pcm) { - emu8000_t *emu = pcm->private_data; + struct snd_emu8000 *emu = pcm->private_data; emu->pcm = NULL; } -int snd_emu8000_pcm_new(snd_card_t *card, emu8000_t *emu, int index) +int snd_emu8000_pcm_new(struct snd_card *card, struct snd_emu8000 *emu, int index) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(card, "Emu8000 PCM", index, 1, 0, &pcm)) < 0) diff --git a/sound/isa/sb/emu8000_synth.c b/sound/isa/sb/emu8000_synth.c index f68e2174..3d72742 100644 --- a/sound/isa/sb/emu8000_synth.c +++ b/sound/isa/sb/emu8000_synth.c @@ -33,12 +33,12 @@ MODULE_LICENSE("GPL"); /* * create a new hardware dependent device for Emu8000 */ -static int snd_emu8000_new_device(snd_seq_device_t *dev) +static int snd_emu8000_new_device(struct snd_seq_device *dev) { - emu8000_t *hw; - snd_emux_t *emu; + struct snd_emu8000 *hw; + struct snd_emux *emu; - hw = *(emu8000_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); + hw = *(struct snd_emu8000**)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (hw == NULL) return -EINVAL; @@ -92,9 +92,9 @@ static int snd_emu8000_new_device(snd_seq_device_t *dev) /* * free all resources */ -static int snd_emu8000_delete_device(snd_seq_device_t *dev) +static int snd_emu8000_delete_device(struct snd_seq_device *dev) { - emu8000_t *hw; + struct snd_emu8000 *hw; if (dev->driver_data == NULL) return 0; /* no synth was allocated actually */ @@ -118,11 +118,12 @@ static int snd_emu8000_delete_device(snd_seq_device_t *dev) static int __init alsa_emu8000_init(void) { - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_emu8000_new_device, snd_emu8000_delete_device, }; - return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU8000, &ops, sizeof(emu8000_t*)); + return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU8000, &ops, + sizeof(struct snd_emu8000*)); } static void __exit alsa_emu8000_exit(void) diff --git a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c index c859917..f7d1afe 100644 --- a/sound/isa/sb/es968.c +++ b/sound/isa/sb/es968.c @@ -72,7 +72,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_es968_pnpids); static irqreturn_t snd_card_es968_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - sb_t *chip = dev_id; + struct snd_sb *chip = dev_id; if (chip->open & SB_OPEN_PCM) { return snd_sb8dsp_interrupt(chip); @@ -128,8 +128,8 @@ static int __init snd_card_es968_probe(int dev, const struct pnp_card_device_id *pid) { int error; - sb_t *chip; - snd_card_t *card; + struct snd_sb *chip; + struct snd_card *card; struct snd_card_es968 *acard; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, @@ -200,7 +200,7 @@ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card, static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index c2fa451..96e4013 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -138,7 +138,7 @@ struct snd_card_sb16 { #endif }; -static snd_card_t *snd_sb16_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_sb16_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -339,7 +339,7 @@ __wt_error: #endif /* CONFIG_PNP */ -static void snd_sb16_free(snd_card_t *card) +static void snd_sb16_free(struct snd_card *card) { struct snd_card_sb16 *acard = (struct snd_card_sb16 *)card->private_data; @@ -362,13 +362,13 @@ static int __init snd_sb16_probe(int dev, static int possible_dmas8[] = {1, 3, 0, -1}; static int possible_dmas16[] = {5, 6, 7, -1}; int xirq, xdma8, xdma16; - sb_t *chip; - snd_card_t *card; + struct snd_sb *chip; + struct snd_card *card; struct snd_card_sb16 *acard; - opl3_t *opl3; - snd_hwdep_t *synth = NULL; + struct snd_opl3 *opl3; + struct snd_hwdep *synth = NULL; #ifdef CONFIG_SND_SB16_CSP - snd_hwdep_t *xcsp = NULL; + struct snd_hwdep *xcsp = NULL; #endif unsigned long flags; int err; @@ -583,7 +583,7 @@ static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card, static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 7192d4c..9c2b5ef 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -72,46 +72,47 @@ struct desc_header { /* * prototypes */ -static void snd_sb_csp_free(snd_hwdep_t *hw); -static int snd_sb_csp_open(snd_hwdep_t * hw, struct file *file); -static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg); -static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file); - -static int csp_detect(sb_t *chip, int *version); -static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val); -static int set_register(sb_t *chip, unsigned char reg, unsigned char val); -static int read_register(sb_t *chip, unsigned char reg); -static int set_mode_register(sb_t *chip, unsigned char mode); -static int get_version(sb_t *chip); - -static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user * code); -static int snd_sb_csp_unload(snd_sb_csp_t * p); -static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *buf, int size, int load_flags); -static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode); -static int snd_sb_csp_check_version(snd_sb_csp_t * p); - -static int snd_sb_csp_use(snd_sb_csp_t * p); -static int snd_sb_csp_unuse(snd_sb_csp_t * p); -static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels); -static int snd_sb_csp_stop(snd_sb_csp_t * p); -static int snd_sb_csp_pause(snd_sb_csp_t * p); -static int snd_sb_csp_restart(snd_sb_csp_t * p); - -static int snd_sb_qsound_build(snd_sb_csp_t * p); -static void snd_sb_qsound_destroy(snd_sb_csp_t * p); -static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p); - -static int init_proc_entry(snd_sb_csp_t * p, int device); -static void info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer); +static void snd_sb_csp_free(struct snd_hwdep *hw); +static int snd_sb_csp_open(struct snd_hwdep * hw, struct file *file); +static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg); +static int snd_sb_csp_release(struct snd_hwdep * hw, struct file *file); + +static int csp_detect(struct snd_sb *chip, int *version); +static int set_codec_parameter(struct snd_sb *chip, unsigned char par, unsigned char val); +static int set_register(struct snd_sb *chip, unsigned char reg, unsigned char val); +static int read_register(struct snd_sb *chip, unsigned char reg); +static int set_mode_register(struct snd_sb *chip, unsigned char mode); +static int get_version(struct snd_sb *chip); + +static int snd_sb_csp_riff_load(struct snd_sb_csp * p, + struct snd_sb_csp_microcode __user * code); +static int snd_sb_csp_unload(struct snd_sb_csp * p); +static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags); +static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode); +static int snd_sb_csp_check_version(struct snd_sb_csp * p); + +static int snd_sb_csp_use(struct snd_sb_csp * p); +static int snd_sb_csp_unuse(struct snd_sb_csp * p); +static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channels); +static int snd_sb_csp_stop(struct snd_sb_csp * p); +static int snd_sb_csp_pause(struct snd_sb_csp * p); +static int snd_sb_csp_restart(struct snd_sb_csp * p); + +static int snd_sb_qsound_build(struct snd_sb_csp * p); +static void snd_sb_qsound_destroy(struct snd_sb_csp * p); +static int snd_sb_csp_qsound_transfer(struct snd_sb_csp * p); + +static int init_proc_entry(struct snd_sb_csp * p, int device); +static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer); /* * Detect CSP chip and create a new instance */ -int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep) +int snd_sb_csp_new(struct snd_sb *chip, int device, struct snd_hwdep ** rhwdep) { - snd_sb_csp_t *p; + struct snd_sb_csp *p; int version, err; - snd_hwdep_t *hw; + struct snd_hwdep *hw; if (rhwdep) *rhwdep = NULL; @@ -158,9 +159,9 @@ int snd_sb_csp_new(sb_t *chip, int device, snd_hwdep_t ** rhwdep) /* * free_private for hwdep instance */ -static void snd_sb_csp_free(snd_hwdep_t *hwdep) +static void snd_sb_csp_free(struct snd_hwdep *hwdep) { - snd_sb_csp_t *p = hwdep->private_data; + struct snd_sb_csp *p = hwdep->private_data; if (p) { if (p->running & SNDRV_SB_CSP_ST_RUNNING) snd_sb_csp_stop(p); @@ -173,20 +174,20 @@ static void snd_sb_csp_free(snd_hwdep_t *hwdep) /* * open the device exclusively */ -static int snd_sb_csp_open(snd_hwdep_t * hw, struct file *file) +static int snd_sb_csp_open(struct snd_hwdep * hw, struct file *file) { - snd_sb_csp_t *p = hw->private_data; + struct snd_sb_csp *p = hw->private_data; return (snd_sb_csp_use(p)); } /* * ioctl for hwdep device: */ -static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg) +static int snd_sb_csp_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) { - snd_sb_csp_t *p = hw->private_data; - snd_sb_csp_info_t info; - snd_sb_csp_start_t start_info; + struct snd_sb_csp *p = hw->private_data; + struct snd_sb_csp_info info; + struct snd_sb_csp_start start_info; int err; snd_assert(p != NULL, return -EINVAL); @@ -217,7 +218,7 @@ static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cm /* load CSP microcode */ case SNDRV_SB_CSP_IOCTL_LOAD_CODE: err = (p->running & SNDRV_SB_CSP_ST_RUNNING ? - -EBUSY : snd_sb_csp_riff_load(p, (snd_sb_csp_microcode_t __user *) arg)); + -EBUSY : snd_sb_csp_riff_load(p, (struct snd_sb_csp_microcode __user *) arg)); break; case SNDRV_SB_CSP_IOCTL_UNLOAD_CODE: err = (p->running & SNDRV_SB_CSP_ST_RUNNING ? @@ -251,9 +252,9 @@ static int snd_sb_csp_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cm /* * close the device */ -static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file) +static int snd_sb_csp_release(struct snd_hwdep * hw, struct file *file) { - snd_sb_csp_t *p = hw->private_data; + struct snd_sb_csp *p = hw->private_data; return (snd_sb_csp_unuse(p)); } @@ -262,7 +263,7 @@ static int snd_sb_csp_release(snd_hwdep_t * hw, struct file *file) /* * acquire device */ -static int snd_sb_csp_use(snd_sb_csp_t * p) +static int snd_sb_csp_use(struct snd_sb_csp * p) { down(&p->access_mutex); if (p->used) { @@ -279,7 +280,7 @@ static int snd_sb_csp_use(snd_sb_csp_t * p) /* * release device */ -static int snd_sb_csp_unuse(snd_sb_csp_t * p) +static int snd_sb_csp_unuse(struct snd_sb_csp * p) { down(&p->access_mutex); p->used--; @@ -292,9 +293,10 @@ static int snd_sb_csp_unuse(snd_sb_csp_t * p) * load microcode via ioctl: * code is user-space pointer */ -static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user * mcode) +static int snd_sb_csp_riff_load(struct snd_sb_csp * p, + struct snd_sb_csp_microcode __user * mcode) { - snd_sb_csp_mc_header_t info; + struct snd_sb_csp_mc_header info; unsigned char __user *data_ptr; unsigned char __user *data_end; @@ -449,7 +451,7 @@ static int snd_sb_csp_riff_load(snd_sb_csp_t * p, snd_sb_csp_microcode_t __user /* * unload CSP microcode */ -static int snd_sb_csp_unload(snd_sb_csp_t * p) +static int snd_sb_csp_unload(struct snd_sb_csp * p) { if (p->running & SNDRV_SB_CSP_ST_RUNNING) return -EBUSY; @@ -472,7 +474,7 @@ static int snd_sb_csp_unload(snd_sb_csp_t * p) /* * send command sequence to DSP */ -static inline int command_seq(sb_t *chip, const unsigned char *seq, int size) +static inline int command_seq(struct snd_sb *chip, const unsigned char *seq, int size) { int i; for (i = 0; i < size; i++) { @@ -485,7 +487,7 @@ static inline int command_seq(sb_t *chip, const unsigned char *seq, int size) /* * set CSP codec parameter */ -static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val) +static int set_codec_parameter(struct snd_sb *chip, unsigned char par, unsigned char val) { unsigned char dsp_cmd[3]; @@ -502,7 +504,7 @@ static int set_codec_parameter(sb_t *chip, unsigned char par, unsigned char val) /* * set CSP register */ -static int set_register(sb_t *chip, unsigned char reg, unsigned char val) +static int set_register(struct snd_sb *chip, unsigned char reg, unsigned char val) { unsigned char dsp_cmd[3]; @@ -516,7 +518,7 @@ static int set_register(sb_t *chip, unsigned char reg, unsigned char val) * read CSP register * return < 0 -> error */ -static int read_register(sb_t *chip, unsigned char reg) +static int read_register(struct snd_sb *chip, unsigned char reg) { unsigned char dsp_cmd[2]; @@ -529,7 +531,7 @@ static int read_register(sb_t *chip, unsigned char reg) /* * set CSP mode register */ -static int set_mode_register(sb_t *chip, unsigned char mode) +static int set_mode_register(struct snd_sb *chip, unsigned char mode) { unsigned char dsp_cmd[2]; @@ -542,7 +544,7 @@ static int set_mode_register(sb_t *chip, unsigned char mode) * Detect CSP * return 0 if CSP exists. */ -static int csp_detect(sb_t *chip, int *version) +static int csp_detect(struct snd_sb *chip, int *version) { unsigned char csp_test1, csp_test2; unsigned long flags; @@ -579,7 +581,7 @@ static int csp_detect(sb_t *chip, int *version) /* * get CSP version number */ -static int get_version(sb_t *chip) +static int get_version(struct snd_sb *chip) { unsigned char dsp_cmd[2]; @@ -593,7 +595,7 @@ static int get_version(sb_t *chip) /* * check if the CSP version is valid */ -static int snd_sb_csp_check_version(snd_sb_csp_t * p) +static int snd_sb_csp_check_version(struct snd_sb_csp * p) { if (p->version < 0x10 || p->version > 0x1f) { snd_printd("%s: Invalid CSP version: 0x%x\n", __FUNCTION__, p->version); @@ -605,7 +607,7 @@ static int snd_sb_csp_check_version(snd_sb_csp_t * p) /* * download microcode to CSP (microcode should have one "main" block). */ -static int snd_sb_csp_load(snd_sb_csp_t * p, const unsigned char *buf, int size, int load_flags) +static int snd_sb_csp_load(struct snd_sb_csp * p, const unsigned char *buf, int size, int load_flags) { int status, i; int err; @@ -671,7 +673,7 @@ static int snd_sb_csp_load(snd_sb_csp_t * p, const unsigned char *buf, int size, return result; } -static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *buf, int size, int load_flags) +static int snd_sb_csp_load_user(struct snd_sb_csp * p, const unsigned char __user *buf, int size, int load_flags) { int err = -ENOMEM; unsigned char *kbuf = kmalloc(size, GFP_KERNEL); @@ -691,7 +693,7 @@ static int snd_sb_csp_load_user(snd_sb_csp_t * p, const unsigned char __user *bu * autoload hardware codec if necessary * return 0 if CSP is loaded and ready to run (p->running != 0) */ -static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode) +static int snd_sb_csp_autoload(struct snd_sb_csp * p, int pcm_sfmt, int play_rec_mode) { unsigned long flags; int err = 0; @@ -763,7 +765,7 @@ static int snd_sb_csp_autoload(snd_sb_csp_t * p, int pcm_sfmt, int play_rec_mode /* * start CSP */ -static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels) +static int snd_sb_csp_start(struct snd_sb_csp * p, int sample_width, int channels) { unsigned char s_type; /* sample type */ unsigned char mixL, mixR; @@ -842,7 +844,7 @@ static int snd_sb_csp_start(snd_sb_csp_t * p, int sample_width, int channels) /* * stop CSP */ -static int snd_sb_csp_stop(snd_sb_csp_t * p) +static int snd_sb_csp_stop(struct snd_sb_csp * p) { int result; unsigned char mixL, mixR; @@ -883,7 +885,7 @@ static int snd_sb_csp_stop(snd_sb_csp_t * p) /* * pause CSP codec and hold DMA transfer */ -static int snd_sb_csp_pause(snd_sb_csp_t * p) +static int snd_sb_csp_pause(struct snd_sb_csp * p) { int result; unsigned long flags; @@ -903,7 +905,7 @@ static int snd_sb_csp_pause(snd_sb_csp_t * p) /* * restart CSP codec and resume DMA transfer */ -static int snd_sb_csp_restart(snd_sb_csp_t * p) +static int snd_sb_csp_restart(struct snd_sb_csp * p) { int result; unsigned long flags; @@ -926,7 +928,7 @@ static int snd_sb_csp_restart(snd_sb_csp_t * p) * QSound mixer control for PCM */ -static int snd_sb_qsound_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb_qsound_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -935,17 +937,17 @@ static int snd_sb_qsound_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_sb_qsound_switch_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb_qsound_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); + struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = p->q_enabled ? 1 : 0; return 0; } -static int snd_sb_qsound_switch_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb_qsound_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); + struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval; @@ -958,7 +960,7 @@ static int snd_sb_qsound_switch_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return change; } -static int snd_sb_qsound_space_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb_qsound_space_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -967,9 +969,9 @@ static int snd_sb_qsound_space_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_sb_qsound_space_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb_qsound_space_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); + struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&p->q_lock, flags); @@ -979,9 +981,9 @@ static int snd_sb_qsound_space_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_sb_qsound_space_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb_qsound_space_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_sb_csp_t *p = snd_kcontrol_chip(kcontrol); + struct snd_sb_csp *p = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval1, nval2; @@ -1001,7 +1003,7 @@ static int snd_sb_qsound_space_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return change; } -static snd_kcontrol_new_t snd_sb_qsound_switch = { +static struct snd_kcontrol_new snd_sb_qsound_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "3D Control - Switch", .info = snd_sb_qsound_switch_info, @@ -1009,7 +1011,7 @@ static snd_kcontrol_new_t snd_sb_qsound_switch = { .put = snd_sb_qsound_switch_put }; -static snd_kcontrol_new_t snd_sb_qsound_space = { +static struct snd_kcontrol_new snd_sb_qsound_space = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "3D Control - Space", .info = snd_sb_qsound_space_info, @@ -1017,9 +1019,9 @@ static snd_kcontrol_new_t snd_sb_qsound_space = { .put = snd_sb_qsound_space_put }; -static int snd_sb_qsound_build(snd_sb_csp_t * p) +static int snd_sb_qsound_build(struct snd_sb_csp * p) { - snd_card_t * card; + struct snd_card *card; int err; snd_assert(p != NULL, return -EINVAL); @@ -1042,9 +1044,9 @@ static int snd_sb_qsound_build(snd_sb_csp_t * p) return err; } -static void snd_sb_qsound_destroy(snd_sb_csp_t * p) +static void snd_sb_qsound_destroy(struct snd_sb_csp * p) { - snd_card_t * card; + struct snd_card *card; unsigned long flags; snd_assert(p != NULL, return); @@ -1068,7 +1070,7 @@ static void snd_sb_qsound_destroy(snd_sb_csp_t * p) * Transfer qsound parameters to CSP, * function should be called from interrupt routine */ -static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p) +static int snd_sb_csp_qsound_transfer(struct snd_sb_csp * p) { int err = -ENXIO; @@ -1093,19 +1095,19 @@ static int snd_sb_csp_qsound_transfer(snd_sb_csp_t * p) /* * proc interface */ -static int init_proc_entry(snd_sb_csp_t * p, int device) +static int init_proc_entry(struct snd_sb_csp * p, int device) { char name[16]; - snd_info_entry_t *entry; + struct snd_info_entry *entry; sprintf(name, "cspD%d", device); if (! snd_card_proc_new(p->chip->card, name, &entry)) snd_info_set_text_ops(entry, p, 1024, info_read); return 0; } -static void info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - snd_sb_csp_t *p = entry->private_data; + struct snd_sb_csp *p = entry->private_data; snd_iprintf(buffer, "Creative Signal Processor [v%d.%d]\n", (p->version >> 4), (p->version & 0x0f)); snd_iprintf(buffer, "State: %cx%c%c%c\n", ((p->running & SNDRV_SB_CSP_ST_QSOUND) ? 'Q' : '-'), diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 17312e0..97786ed 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -50,10 +50,10 @@ MODULE_DESCRIPTION("Routines for control of 16-bit SoundBlaster cards and clones MODULE_LICENSE("GPL"); #ifdef CONFIG_SND_SB16_CSP -static void snd_sb16_csp_playback_prepare(sb_t *chip, snd_pcm_runtime_t *runtime) +static void snd_sb16_csp_playback_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime) { if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->running & SNDRV_SB_CSP_ST_LOADED) { /* manually loaded codec */ @@ -98,10 +98,10 @@ static void snd_sb16_csp_playback_prepare(sb_t *chip, snd_pcm_runtime_t *runtime } } -static void snd_sb16_csp_capture_prepare(sb_t *chip, snd_pcm_runtime_t *runtime) +static void snd_sb16_csp_capture_prepare(struct snd_sb *chip, struct snd_pcm_runtime *runtime) { if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->running & SNDRV_SB_CSP_ST_LOADED) { /* manually loaded codec */ @@ -136,10 +136,10 @@ static void snd_sb16_csp_capture_prepare(sb_t *chip, snd_pcm_runtime_t *runtime) } } -static void snd_sb16_csp_update(sb_t *chip) +static void snd_sb16_csp_update(struct snd_sb *chip) { if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->qpos_changed) { spin_lock(&chip->reg_lock); @@ -149,11 +149,11 @@ static void snd_sb16_csp_update(sb_t *chip) } } -static void snd_sb16_csp_playback_open(sb_t *chip, snd_pcm_runtime_t *runtime) +static void snd_sb16_csp_playback_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime) { /* CSP decoders (QSound excluded) support only 16bit transfers */ if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->running & SNDRV_SB_CSP_ST_LOADED) { /* manually loaded codec */ @@ -168,10 +168,10 @@ static void snd_sb16_csp_playback_open(sb_t *chip, snd_pcm_runtime_t *runtime) } } -static void snd_sb16_csp_playback_close(sb_t *chip) +static void snd_sb16_csp_playback_close(struct snd_sb *chip) { if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_WRITE)) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->ops.csp_stop(csp) == 0) { csp->ops.csp_unuse(csp); @@ -180,11 +180,11 @@ static void snd_sb16_csp_playback_close(sb_t *chip) } } -static void snd_sb16_csp_capture_open(sb_t *chip, snd_pcm_runtime_t *runtime) +static void snd_sb16_csp_capture_open(struct snd_sb *chip, struct snd_pcm_runtime *runtime) { /* CSP coders support only 16bit transfers */ if (chip->hardware == SB_HW_16CSP) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->running & SNDRV_SB_CSP_ST_LOADED) { /* manually loaded codec */ @@ -199,10 +199,10 @@ static void snd_sb16_csp_capture_open(sb_t *chip, snd_pcm_runtime_t *runtime) } } -static void snd_sb16_csp_capture_close(sb_t *chip) +static void snd_sb16_csp_capture_close(struct snd_sb *chip) { if ((chip->hardware == SB_HW_16CSP) && (chip->open == SNDRV_SB_CSP_MODE_DSP_READ)) { - snd_sb_csp_t *csp = chip->csp; + struct snd_sb_csp *csp = chip->csp; if (csp->ops.csp_stop(csp) == 0) { csp->ops.csp_unuse(csp); @@ -221,7 +221,7 @@ static void snd_sb16_csp_capture_close(sb_t *chip) #endif -static void snd_sb16_setup_rate(sb_t *chip, +static void snd_sb16_setup_rate(struct snd_sb *chip, unsigned short rate, int channel) { @@ -244,23 +244,23 @@ static void snd_sb16_setup_rate(sb_t *chip, spin_unlock_irqrestore(&chip->reg_lock, flags); } -static int snd_sb16_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_sb16_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_sb16_hw_free(snd_pcm_substream_t * substream) +static int snd_sb16_hw_free(struct snd_pcm_substream *substream) { snd_pcm_lib_free_pages(substream); return 0; } -static int snd_sb16_playback_prepare(snd_pcm_substream_t * substream) +static int snd_sb16_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned char format; unsigned int size, count, dma; @@ -298,10 +298,10 @@ static int snd_sb16_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_playback_trigger(snd_pcm_substream_t * substream, +static int snd_sb16_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); int result = 0; spin_lock(&chip->reg_lock); @@ -324,11 +324,11 @@ static int snd_sb16_playback_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_sb16_capture_prepare(snd_pcm_substream_t * substream) +static int snd_sb16_capture_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned char format; unsigned int size, count, dma; @@ -365,10 +365,10 @@ static int snd_sb16_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_capture_trigger(snd_pcm_substream_t * substream, +static int snd_sb16_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); int result = 0; spin_lock(&chip->reg_lock); @@ -393,7 +393,7 @@ static int snd_sb16_capture_trigger(snd_pcm_substream_t * substream, irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - sb_t *chip = dev_id; + struct snd_sb *chip = dev_id; unsigned char status; int ok; @@ -443,9 +443,9 @@ irqreturn_t snd_sb16dsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) */ -static snd_pcm_uframes_t snd_sb16_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sb16_playback_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int dma; size_t ptr; @@ -454,9 +454,9 @@ static snd_pcm_uframes_t snd_sb16_playback_pointer(snd_pcm_substream_t * substre return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_sb16_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sb16_capture_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int dma; size_t ptr; @@ -469,7 +469,7 @@ static snd_pcm_uframes_t snd_sb16_capture_pointer(snd_pcm_substream_t * substrea */ -static snd_pcm_hardware_t snd_sb16_playback = +static struct snd_pcm_hardware snd_sb16_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -487,7 +487,7 @@ static snd_pcm_hardware_t snd_sb16_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_sb16_capture = +static struct snd_pcm_hardware snd_sb16_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -509,11 +509,11 @@ static snd_pcm_hardware_t snd_sb16_capture = * open/close */ -static int snd_sb16_playback_open(snd_pcm_substream_t * substream) +static int snd_sb16_playback_open(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irqsave(&chip->open_lock, flags); if (chip->mode & SB_MODE_PLAYBACK) { @@ -566,10 +566,10 @@ static int snd_sb16_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_playback_close(snd_pcm_substream_t * substream) +static int snd_sb16_playback_close(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); snd_sb16_csp_playback_close(chip); spin_lock_irqsave(&chip->open_lock, flags); @@ -579,11 +579,11 @@ static int snd_sb16_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_capture_open(snd_pcm_substream_t * substream) +static int snd_sb16_capture_open(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irqsave(&chip->open_lock, flags); if (chip->mode & SB_MODE_CAPTURE) { @@ -636,10 +636,10 @@ static int snd_sb16_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_sb16_capture_close(snd_pcm_substream_t * substream) +static int snd_sb16_capture_close(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); snd_sb16_csp_capture_close(chip); spin_lock_irqsave(&chip->open_lock, flags); @@ -653,7 +653,7 @@ static int snd_sb16_capture_close(snd_pcm_substream_t * substream) * DMA control interface */ -static int snd_sb16_set_dma_mode(sb_t *chip, int what) +static int snd_sb16_set_dma_mode(struct snd_sb *chip, int what) { if (chip->dma8 < 0 || chip->dma16 < 0) { snd_assert(what == 0, return -EINVAL); @@ -671,7 +671,7 @@ static int snd_sb16_set_dma_mode(sb_t *chip, int what) return 0; } -static int snd_sb16_get_dma_mode(sb_t *chip) +static int snd_sb16_get_dma_mode(struct snd_sb *chip) { if (chip->dma8 < 0 || chip->dma16 < 0) return 0; @@ -685,7 +685,7 @@ static int snd_sb16_get_dma_mode(sb_t *chip) } } -static int snd_sb16_dma_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb16_dma_control_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "Auto", "Playback", "Capture" @@ -700,9 +700,9 @@ static int snd_sb16_dma_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_sb16_dma_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb16_dma_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_sb *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -711,9 +711,9 @@ static int snd_sb16_dma_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return 0; } -static int snd_sb16_dma_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb16_dma_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_sb *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned char nval, oval; int change; @@ -728,7 +728,7 @@ static int snd_sb16_dma_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return change; } -static snd_kcontrol_new_t snd_sb16_dma_control = { +static struct snd_kcontrol_new snd_sb16_dma_control = { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = "16-bit DMA Allocation", .info = snd_sb16_dma_control_info, @@ -740,7 +740,7 @@ static snd_kcontrol_new_t snd_sb16_dma_control = { * Initialization part */ -int snd_sb16dsp_configure(sb_t * chip) +int snd_sb16dsp_configure(struct snd_sb * chip) { unsigned long flags; unsigned char irqreg = 0, dmareg = 0, mpureg; @@ -829,7 +829,7 @@ int snd_sb16dsp_configure(sb_t * chip) return 0; } -static snd_pcm_ops_t snd_sb16_playback_ops = { +static struct snd_pcm_ops snd_sb16_playback_ops = { .open = snd_sb16_playback_open, .close = snd_sb16_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -840,7 +840,7 @@ static snd_pcm_ops_t snd_sb16_playback_ops = { .pointer = snd_sb16_playback_pointer, }; -static snd_pcm_ops_t snd_sb16_capture_ops = { +static struct snd_pcm_ops snd_sb16_capture_ops = { .open = snd_sb16_capture_open, .close = snd_sb16_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -851,10 +851,10 @@ static snd_pcm_ops_t snd_sb16_capture_ops = { .pointer = snd_sb16_capture_pointer, }; -int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm) +int snd_sb16dsp_pcm(struct snd_sb * chip, int device, struct snd_pcm ** rpcm) { - snd_card_t *card = chip->card; - snd_pcm_t *pcm; + struct snd_card *card = chip->card; + struct snd_pcm *pcm; int err; if (rpcm) @@ -882,7 +882,7 @@ int snd_sb16dsp_pcm(sb_t * chip, int device, snd_pcm_t ** rpcm) return 0; } -const snd_pcm_ops_t *snd_sb16dsp_get_pcm_ops(int direction) +const struct snd_pcm_ops *snd_sb16dsp_get_pcm_ops(int direction) { return direction == SNDRV_PCM_STREAM_PLAYBACK ? &snd_sb16_playback_ops : &snd_sb16_capture_ops; diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 0bc0a3a..5116038 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -59,11 +59,11 @@ struct snd_sb8 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ }; -static snd_card_t *snd_sb8_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_sb8_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - sb_t *chip = dev_id; + struct snd_sb *chip = dev_id; if (chip->open & SB_OPEN_PCM) { return snd_sb8dsp_interrupt(chip); @@ -72,7 +72,7 @@ static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs } } -static void snd_sb8_free(snd_card_t *card) +static void snd_sb8_free(struct snd_card *card) { struct snd_sb8 *acard = (struct snd_sb8 *)card->private_data; @@ -83,10 +83,10 @@ static void snd_sb8_free(snd_card_t *card) static int __init snd_sb8_probe(int dev) { - sb_t *chip; - snd_card_t *card; + struct snd_sb *chip; + struct snd_card *card; struct snd_sb8 *acard; - opl3_t *opl3; + struct snd_opl3 *opl3; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, diff --git a/sound/isa/sb/sb8_main.c b/sound/isa/sb/sb8_main.c index 28d8afd..aea9e5e 100644 --- a/sound/isa/sb/sb8_main.c +++ b/sound/isa/sb/sb8_main.c @@ -46,19 +46,19 @@ MODULE_LICENSE("GPL"); #define SB8_DEN(v) ((SB8_CLOCK + (v) / 2) / (v)) #define SB8_RATE(v) (SB8_CLOCK / SB8_DEN(v)) -static ratnum_t clock = { +static struct snd_ratnum clock = { .num = SB8_CLOCK, .den_min = 1, .den_max = 256, .den_step = 1, }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clock = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clock = { .nrats = 1, .rats = &clock, }; -static ratnum_t stereo_clocks[] = { +static struct snd_ratnum stereo_clocks[] = { { .num = SB8_CLOCK, .den_min = SB8_DEN(22050), @@ -73,10 +73,10 @@ static ratnum_t stereo_clocks[] = { } }; -static int snd_sb8_hw_constraint_rate_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_sb8_hw_constraint_rate_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (c->min > 1) { unsigned int num = 0, den = 0; int err = snd_interval_ratnum(hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE), @@ -90,22 +90,22 @@ static int snd_sb8_hw_constraint_rate_channels(snd_pcm_hw_params_t *params, return 0; } -static int snd_sb8_hw_constraint_channels_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_sb8_hw_constraint_channels_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (r->min > SB8_RATE(22050) || r->max <= SB8_RATE(11025)) { - snd_interval_t t = { .min = 1, .max = 1 }; + struct snd_interval t = { .min = 1, .max = 1 }; return snd_interval_refine(hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS), &t); } return 0; } -static int snd_sb8_playback_prepare(snd_pcm_substream_t * substream) +static int snd_sb8_playback_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mixreg, rate, size, count; rate = runtime->rate; @@ -178,11 +178,11 @@ static int snd_sb8_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream, +static int snd_sb8_playback_trigger(struct snd_pcm_substream *substream, int cmd) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int count; spin_lock_irqsave(&chip->reg_lock, flags); @@ -197,7 +197,7 @@ static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream, break; case SNDRV_PCM_TRIGGER_STOP: if (chip->playback_format == SB_DSP_HI_OUTPUT_AUTO) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_sbdsp_reset(chip); if (runtime->channels > 1) { spin_lock(&chip->mixer_lock); @@ -215,23 +215,23 @@ static int snd_sb8_playback_trigger(snd_pcm_substream_t * substream, return 0; } -static int snd_sb8_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_sb8_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_sb8_hw_free(snd_pcm_substream_t * substream) +static int snd_sb8_hw_free(struct snd_pcm_substream *substream) { snd_pcm_lib_free_pages(substream); return 0; } -static int snd_sb8_capture_prepare(snd_pcm_substream_t * substream) +static int snd_sb8_capture_prepare(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mixreg, rate, size, count; rate = runtime->rate; @@ -290,11 +290,11 @@ static int snd_sb8_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream, +static int snd_sb8_capture_trigger(struct snd_pcm_substream *substream, int cmd) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int count; spin_lock_irqsave(&chip->reg_lock, flags); @@ -309,7 +309,7 @@ static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream, break; case SNDRV_PCM_TRIGGER_STOP: if (chip->capture_format == SB_DSP_HI_INPUT_AUTO) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; snd_sbdsp_reset(chip); if (runtime->channels > 1) { /* restore input filter status */ @@ -329,10 +329,10 @@ static int snd_sb8_capture_trigger(snd_pcm_substream_t * substream, return 0; } -irqreturn_t snd_sb8dsp_interrupt(sb_t *chip) +irqreturn_t snd_sb8dsp_interrupt(struct snd_sb *chip) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; snd_sb_ack_8bit(chip); switch (chip->mode) { @@ -354,9 +354,9 @@ irqreturn_t snd_sb8dsp_interrupt(sb_t *chip) return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_sb8_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sb8_playback_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); size_t ptr; if (chip->mode != SB_MODE_PLAYBACK_8) @@ -365,9 +365,9 @@ static snd_pcm_uframes_t snd_sb8_playback_pointer(snd_pcm_substream_t * substrea return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_sb8_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sb8_capture_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); size_t ptr; if (chip->mode != SB_MODE_CAPTURE_8) @@ -380,7 +380,7 @@ static snd_pcm_uframes_t snd_sb8_capture_pointer(snd_pcm_substream_t * substream */ -static snd_pcm_hardware_t snd_sb8_playback = +static struct snd_pcm_hardware snd_sb8_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -399,7 +399,7 @@ static snd_pcm_hardware_t snd_sb8_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_sb8_capture = +static struct snd_pcm_hardware snd_sb8_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -422,10 +422,10 @@ static snd_pcm_hardware_t snd_sb8_capture = * */ -static int snd_sb8_open(snd_pcm_substream_t *substream) +static int snd_sb8_open(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; spin_lock_irqsave(&chip->open_lock, flags); @@ -468,10 +468,10 @@ static int snd_sb8_open(snd_pcm_substream_t *substream) return 0; } -static int snd_sb8_close(snd_pcm_substream_t *substream) +static int snd_sb8_close(struct snd_pcm_substream *substream) { unsigned long flags; - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; chip->capture_substream = NULL; @@ -485,7 +485,7 @@ static int snd_sb8_close(snd_pcm_substream_t *substream) * Initialization part */ -static snd_pcm_ops_t snd_sb8_playback_ops = { +static struct snd_pcm_ops snd_sb8_playback_ops = { .open = snd_sb8_open, .close = snd_sb8_close, .ioctl = snd_pcm_lib_ioctl, @@ -496,7 +496,7 @@ static snd_pcm_ops_t snd_sb8_playback_ops = { .pointer = snd_sb8_playback_pointer, }; -static snd_pcm_ops_t snd_sb8_capture_ops = { +static struct snd_pcm_ops snd_sb8_capture_ops = { .open = snd_sb8_open, .close = snd_sb8_close, .ioctl = snd_pcm_lib_ioctl, @@ -507,10 +507,10 @@ static snd_pcm_ops_t snd_sb8_capture_ops = { .pointer = snd_sb8_capture_pointer, }; -int snd_sb8dsp_pcm(sb_t *chip, int device, snd_pcm_t ** rpcm) +int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm) { - snd_card_t *card = chip->card; - snd_pcm_t *pcm; + struct snd_card *card = chip->card; + struct snd_pcm *pcm; int err; if (rpcm) diff --git a/sound/isa/sb/sb8_midi.c b/sound/isa/sb/sb8_midi.c index d2c633a..c549ace 100644 --- a/sound/isa/sb/sb8_midi.c +++ b/sound/isa/sb/sb8_midi.c @@ -36,9 +36,9 @@ */ -irqreturn_t snd_sb8dsp_midi_interrupt(sb_t * chip) +irqreturn_t snd_sb8dsp_midi_interrupt(struct snd_sb * chip) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int max = 64; char byte; @@ -63,10 +63,10 @@ irqreturn_t snd_sb8dsp_midi_interrupt(sb_t * chip) */ -static int snd_sb8dsp_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_sb8dsp_midi_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; unsigned int valid_open_flags; chip = substream->rmidi->private_data; @@ -90,10 +90,10 @@ static int snd_sb8dsp_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_sb8dsp_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_sb8dsp_midi_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; unsigned int valid_open_flags; chip = substream->rmidi->private_data; @@ -117,10 +117,10 @@ static int snd_sb8dsp_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_sb8dsp_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_sb8dsp_midi_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->open_lock, flags); @@ -135,10 +135,10 @@ static int snd_sb8dsp_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_sb8dsp_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_sb8dsp_midi_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->open_lock, flags); @@ -153,10 +153,10 @@ static int snd_sb8dsp_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_sb8dsp_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_sb8dsp_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->open_lock, flags); @@ -176,10 +176,10 @@ static void snd_sb8dsp_midi_input_trigger(snd_rawmidi_substream_t * substream, i spin_unlock_irqrestore(&chip->open_lock, flags); } -static void snd_sb8dsp_midi_output_write(snd_rawmidi_substream_t * substream) +static void snd_sb8dsp_midi_output_write(struct snd_rawmidi_substream *substream) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; char byte; int max = 32; @@ -214,8 +214,8 @@ static void snd_sb8dsp_midi_output_write(snd_rawmidi_substream_t * substream) static void snd_sb8dsp_midi_output_timer(unsigned long data) { - snd_rawmidi_substream_t * substream = (snd_rawmidi_substream_t *) data; - sb_t * chip = substream->rmidi->private_data; + struct snd_rawmidi_substream *substream = (struct snd_rawmidi_substream *) data; + struct snd_sb * chip = substream->rmidi->private_data; unsigned long flags; spin_lock_irqsave(&chip->open_lock, flags); @@ -225,10 +225,10 @@ static void snd_sb8dsp_midi_output_timer(unsigned long data) snd_sb8dsp_midi_output_write(substream); } -static void snd_sb8dsp_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_sb8dsp_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - sb_t *chip; + struct snd_sb *chip; chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->open_lock, flags); @@ -256,23 +256,23 @@ static void snd_sb8dsp_midi_output_trigger(snd_rawmidi_substream_t * substream, */ -static snd_rawmidi_ops_t snd_sb8dsp_midi_output = +static struct snd_rawmidi_ops snd_sb8dsp_midi_output = { .open = snd_sb8dsp_midi_output_open, .close = snd_sb8dsp_midi_output_close, .trigger = snd_sb8dsp_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_sb8dsp_midi_input = +static struct snd_rawmidi_ops snd_sb8dsp_midi_input = { .open = snd_sb8dsp_midi_input_open, .close = snd_sb8dsp_midi_input_close, .trigger = snd_sb8dsp_midi_input_trigger, }; -int snd_sb8dsp_midi(sb_t *chip, int device, snd_rawmidi_t ** rrawmidi) +int snd_sb8dsp_midi(struct snd_sb *chip, int device, struct snd_rawmidi ** rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index 603e923..eb86b44 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -41,7 +41,7 @@ MODULE_LICENSE("GPL"); #undef IO_DEBUG -int snd_sbdsp_command(sb_t *chip, unsigned char val) +int snd_sbdsp_command(struct snd_sb *chip, unsigned char val) { int i; #ifdef IO_DEBUG @@ -56,7 +56,7 @@ int snd_sbdsp_command(sb_t *chip, unsigned char val) return 0; } -int snd_sbdsp_get_byte(sb_t *chip) +int snd_sbdsp_get_byte(struct snd_sb *chip) { int val; int i; @@ -73,7 +73,7 @@ int snd_sbdsp_get_byte(sb_t *chip) return -ENODEV; } -int snd_sbdsp_reset(sb_t *chip) +int snd_sbdsp_reset(struct snd_sb *chip) { int i; @@ -92,7 +92,7 @@ int snd_sbdsp_reset(sb_t *chip) return -ENODEV; } -static int snd_sbdsp_version(sb_t * chip) +static int snd_sbdsp_version(struct snd_sb * chip) { unsigned int result = -ENODEV; @@ -102,7 +102,7 @@ static int snd_sbdsp_version(sb_t * chip) return result; } -static int snd_sbdsp_probe(sb_t * chip) +static int snd_sbdsp_probe(struct snd_sb * chip) { int version; int major, minor; @@ -176,7 +176,7 @@ static int snd_sbdsp_probe(sb_t * chip) return 0; } -static int snd_sbdsp_free(sb_t *chip) +static int snd_sbdsp_free(struct snd_sb *chip) { if (chip->res_port) release_and_free_resource(chip->res_port); @@ -196,24 +196,24 @@ static int snd_sbdsp_free(sb_t *chip) return 0; } -static int snd_sbdsp_dev_free(snd_device_t *device) +static int snd_sbdsp_dev_free(struct snd_device *device) { - sb_t *chip = device->device_data; + struct snd_sb *chip = device->device_data; return snd_sbdsp_free(chip); } -int snd_sbdsp_create(snd_card_t *card, +int snd_sbdsp_create(struct snd_card *card, unsigned long port, int irq, irqreturn_t (*irq_handler)(int, void *, struct pt_regs *), int dma8, int dma16, unsigned short hardware, - sb_t **r_chip) + struct snd_sb **r_chip) { - sb_t *chip; + struct snd_sb *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_sbdsp_dev_free, }; diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 23cfa6a..6e0b935 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c @@ -29,7 +29,7 @@ #undef IO_DEBUG -void snd_sbmixer_write(sb_t *chip, unsigned char reg, unsigned char data) +void snd_sbmixer_write(struct snd_sb *chip, unsigned char reg, unsigned char data) { outb(reg, SBP(chip, MIXER_ADDR)); udelay(10); @@ -40,7 +40,7 @@ void snd_sbmixer_write(sb_t *chip, unsigned char reg, unsigned char data) #endif } -unsigned char snd_sbmixer_read(sb_t *chip, unsigned char reg) +unsigned char snd_sbmixer_read(struct snd_sb *chip, unsigned char reg) { unsigned char result; @@ -58,7 +58,7 @@ unsigned char snd_sbmixer_read(sb_t *chip, unsigned char reg) * Single channel mixer element */ -static int snd_sbmixer_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sbmixer_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -69,9 +69,9 @@ static int snd_sbmixer_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_sbmixer_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sbmixer_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 16) & 0xff; @@ -85,9 +85,9 @@ static int snd_sbmixer_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_sbmixer_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sbmixer_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 16) & 0x07; @@ -110,7 +110,7 @@ static int snd_sbmixer_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ * Double channel mixer element */ -static int snd_sbmixer_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sbmixer_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -121,9 +121,9 @@ static int snd_sbmixer_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_sbmixer_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sbmixer_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -141,9 +141,9 @@ static int snd_sbmixer_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_sbmixer_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sbmixer_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -181,7 +181,7 @@ static int snd_sbmixer_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ * DT-019x / ALS-007 capture/input switch */ -static int snd_dt019x_input_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_dt019x_input_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[5] = { "CD", "Mic", "Line", "Synth", "Master" @@ -196,9 +196,9 @@ static int snd_dt019x_input_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_dt019x_input_sw_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_dt019x_input_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned char oval; @@ -232,9 +232,9 @@ static int snd_dt019x_input_sw_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_dt019x_input_sw_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_dt019x_input_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval, oval; @@ -273,7 +273,7 @@ static int snd_dt019x_input_sw_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value * SBPRO input multiplexer */ -static int snd_sb8mixer_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb8mixer_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "Mic", "CD", "Line" @@ -289,9 +289,9 @@ static int snd_sb8mixer_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * } -static int snd_sb8mixer_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb8mixer_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned char oval; @@ -312,9 +312,9 @@ static int snd_sb8mixer_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_sb8mixer_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb8mixer_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval, oval; @@ -346,7 +346,7 @@ static int snd_sb8mixer_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * SB16 input switch */ -static int snd_sb16mixer_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sb16mixer_info_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 4; @@ -355,9 +355,9 @@ static int snd_sb16mixer_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_i return 0; } -static int snd_sb16mixer_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb16mixer_get_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg1 = kcontrol->private_value & 0xff; int reg2 = (kcontrol->private_value >> 8) & 0xff; @@ -376,9 +376,9 @@ static int snd_sb16mixer_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_va return 0; } -static int snd_sb16mixer_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sb16mixer_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sb_t *sb = snd_kcontrol_chip(kcontrol); + struct snd_sb *sb = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg1 = kcontrol->private_value & 0xff; int reg2 = (kcontrol->private_value >> 8) & 0xff; @@ -410,9 +410,9 @@ static int snd_sb16mixer_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_va */ /* */ -int snd_sbmixer_add_ctl(sb_t *chip, const char *name, int index, int type, unsigned long value) +int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int type, unsigned long value) { - static snd_kcontrol_new_t newctls[] = { + static struct snd_kcontrol_new newctls[] = { [SB_MIX_SINGLE] = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_sbmixer_info_single, @@ -444,7 +444,7 @@ int snd_sbmixer_add_ctl(sb_t *chip, const char *name, int index, int type, unsig .put = snd_dt019x_input_sw_put, }, }; - snd_kcontrol_t *ctl; + struct snd_kcontrol *ctl; int err; ctl = snd_ctl_new1(&newctls[type], chip); @@ -758,7 +758,7 @@ static unsigned char snd_als4000_init_values[][2] = { /* */ -static int snd_sbmixer_init(sb_t *chip, +static int snd_sbmixer_init(struct snd_sb *chip, struct sbmix_elem **controls, int controls_count, unsigned char map[][2], @@ -766,7 +766,7 @@ static int snd_sbmixer_init(sb_t *chip, char *name) { unsigned long flags; - snd_card_t *card = chip->card; + struct snd_card *card = chip->card; int idx, err; /* mixer reset */ @@ -790,9 +790,9 @@ static int snd_sbmixer_init(sb_t *chip, return 0; } -int snd_sbmixer_new(sb_t *chip) +int snd_sbmixer_new(struct snd_sb *chip) { - snd_card_t * card; + struct snd_card *card; int err; snd_assert(chip != NULL && chip->card != NULL, return -EINVAL); -- cgit v1.1 From 5e2da20648e39a0e3cb33861499b686a6fe38112 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:36:44 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA GUS Remove xxx_t typedefs from the ISA GUS drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/gus.h | 317 +++++++++++++++++++++---------------------- sound/isa/gus/gus_dma.c | 24 ++-- sound/isa/gus/gus_dram.c | 8 +- sound/isa/gus/gus_instr.c | 42 +++--- sound/isa/gus/gus_io.c | 72 +++++----- sound/isa/gus/gus_irq.c | 16 +-- sound/isa/gus/gus_main.c | 54 ++++---- sound/isa/gus/gus_mem.c | 64 ++++----- sound/isa/gus/gus_mem_proc.c | 26 ++-- sound/isa/gus/gus_mixer.c | 28 ++-- sound/isa/gus/gus_pcm.c | 194 +++++++++++++------------- sound/isa/gus/gus_reset.c | 54 ++++---- sound/isa/gus/gus_sample.c | 42 +++--- sound/isa/gus/gus_simple.c | 86 ++++++------ sound/isa/gus/gus_synth.c | 70 +++++----- sound/isa/gus/gus_timer.c | 44 +++--- sound/isa/gus/gus_uart.c | 38 +++--- sound/isa/gus/gus_volume.c | 4 +- sound/isa/gus/gusclassic.c | 10 +- sound/isa/gus/gusextreme.c | 26 ++-- sound/isa/gus/gusmax.c | 26 ++-- sound/isa/gus/interwave.c | 60 ++++---- 22 files changed, 658 insertions(+), 647 deletions(-) diff --git a/include/sound/gus.h b/include/sound/gus.h index bb12e9f..63da50f 100644 --- a/include/sound/gus.h +++ b/include/sound/gus.h @@ -183,17 +183,16 @@ /* --- */ -struct _snd_gus_card; -typedef struct _snd_gus_card snd_gus_card_t; +struct snd_gus_card; /* GF1 specific structure */ -typedef struct _snd_gf1_bank_info { +struct snd_gf1_bank_info { unsigned int address; unsigned int size; -} snd_gf1_bank_info_t; +}; -typedef struct _snd_gf1_mem_block { +struct snd_gf1_mem_block { unsigned short flags; /* flags - SNDRV_GF1_MEM_BLOCK_XXXX */ unsigned short owner; /* owner - SNDRV_GF1_MEM_OWNER_XXXX */ unsigned int share; /* share count */ @@ -201,68 +200,68 @@ typedef struct _snd_gf1_mem_block { unsigned int ptr; unsigned int size; char *name; - struct _snd_gf1_mem_block *next; - struct _snd_gf1_mem_block *prev; -} snd_gf1_mem_block_t; - -typedef struct _snd_gf1_mem { - snd_gf1_bank_info_t banks_8[4]; - snd_gf1_bank_info_t banks_16[4]; - snd_gf1_mem_block_t *first; - snd_gf1_mem_block_t *last; + struct snd_gf1_mem_block *next; + struct snd_gf1_mem_block *prev; +}; + +struct snd_gf1_mem { + struct snd_gf1_bank_info banks_8[4]; + struct snd_gf1_bank_info banks_16[4]; + struct snd_gf1_mem_block *first; + struct snd_gf1_mem_block *last; struct semaphore memory_mutex; -} snd_gf1_mem_t; +}; -typedef struct snd_gf1_dma_block { +struct snd_gf1_dma_block { void *buffer; /* buffer in computer's RAM */ unsigned long buf_addr; /* buffer address */ unsigned int addr; /* address in onboard memory */ unsigned int count; /* count in bytes */ unsigned int cmd; /* DMA command (format) */ - void (*ack)(snd_gus_card_t * gus, void *private_data); + void (*ack)(struct snd_gus_card * gus, void *private_data); void *private_data; struct snd_gf1_dma_block *next; -} snd_gf1_dma_block_t; +}; -typedef struct { - snd_midi_channel_set_t * chset; - snd_gus_card_t * gus; +struct snd_gus_port { + struct snd_midi_channel_set * chset; + struct snd_gus_card * gus; int mode; /* operation mode */ int client; /* sequencer client number */ int port; /* sequencer port number */ unsigned int midi_has_voices: 1; -} snd_gus_port_t; +}; -typedef struct _snd_gus_voice snd_gus_voice_t; +struct snd_gus_voice; -typedef struct { - void (*sample_start)(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position); - void (*sample_stop)(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_stop_mode_t mode); - void (*sample_freq)(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_frequency_t freq); - void (*sample_volume)(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_volume_t *volume); - void (*sample_loop)(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_ev_loop_t *loop); - void (*sample_pos)(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_position_t position); - void (*sample_private1)(snd_gus_card_t *card, snd_gus_voice_t *voice, unsigned char *data); -} snd_gus_sample_ops_t; +struct snd_gus_sample_ops { + void (*sample_start)(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position); + void (*sample_stop)(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode); + void (*sample_freq)(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq); + void (*sample_volume)(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume); + void (*sample_loop)(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop); + void (*sample_pos)(struct snd_gus_card *card, struct snd_gus_voice *voice, snd_seq_position_t position); + void (*sample_private1)(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data); +}; -#define SNDRV_GF1_VOICE_TYPE_PCM 0 +#define SNDRV_GF1_VOICE_TYPE_PCM 0 #define SNDRV_GF1_VOICE_TYPE_SYNTH 1 -#define SNDRV_GF1_VOICE_TYPE_MIDI 2 +#define SNDRV_GF1_VOICE_TYPE_MIDI 2 #define SNDRV_GF1_VFLG_RUNNING (1<<0) #define SNDRV_GF1_VFLG_EFFECT_TIMER1 (1<<1) #define SNDRV_GF1_VFLG_PAN (1<<2) -typedef enum { +enum snd_gus_volume_state { VENV_BEFORE, VENV_ATTACK, VENV_SUSTAIN, VENV_RELEASE, VENV_DONE, VENV_VOLUME -} snd_gus_volume_state_t; +}; -struct _snd_gus_voice { +struct snd_gus_voice { int number; unsigned int use: 1, pcm: 1, @@ -278,18 +277,18 @@ struct _snd_gus_voice { unsigned int interrupt_stat_wave; unsigned int interrupt_stat_volume; #endif - void (*handler_wave) (snd_gus_card_t * gus, snd_gus_voice_t * voice); - void (*handler_volume) (snd_gus_card_t * gus, snd_gus_voice_t * voice); - void (*handler_effect) (snd_gus_card_t * gus, snd_gus_voice_t * voice); - void (*volume_change) (snd_gus_card_t * gus); + void (*handler_wave) (struct snd_gus_card * gus, struct snd_gus_voice * voice); + void (*handler_volume) (struct snd_gus_card * gus, struct snd_gus_voice * voice); + void (*handler_effect) (struct snd_gus_card * gus, struct snd_gus_voice * voice); + void (*volume_change) (struct snd_gus_card * gus); - snd_gus_sample_ops_t *sample_ops; + struct snd_gus_sample_ops *sample_ops; - snd_seq_instr_t instr; + struct snd_seq_instr instr; /* running status / registers */ - snd_seq_ev_volume_t sample_volume; + struct snd_seq_ev_volume sample_volume; unsigned short fc_register; unsigned short fc_lfo; @@ -300,8 +299,8 @@ struct _snd_gus_voice { unsigned char effect_accumulator; unsigned char volume_control; unsigned char venv_value_next; - snd_gus_volume_state_t venv_state; - snd_gus_volume_state_t venv_state_prev; + enum snd_gus_volume_state venv_state; + enum snd_gus_volume_state venv_state_prev; unsigned short vlo; unsigned short vro; unsigned short gf1_effect_volume; @@ -309,10 +308,10 @@ struct _snd_gus_voice { /* --- */ void *private_data; - void (*private_free)(snd_gus_voice_t *voice); + void (*private_free)(struct snd_gus_voice *voice); }; -struct _snd_gf1 { +struct snd_gf1 { unsigned int enh_mode:1, /* enhanced mode (GFA1) */ hw_lfo:1, /* use hardware LFO */ @@ -330,7 +329,7 @@ struct _snd_gf1 { unsigned int rom_present; /* bitmask */ unsigned int rom_banks; /* GUS's ROM banks */ - snd_gf1_mem_t mem_alloc; + struct snd_gf1_mem mem_alloc; /* registers */ unsigned short reg_page; @@ -347,7 +346,7 @@ struct _snd_gf1 { unsigned char active_voices; /* active voices */ unsigned char active_voice; /* selected voice (GF1PAGE register) */ - snd_gus_voice_t voices[32]; /* GF1 voices */ + struct snd_gus_voice voices[32]; /* GF1 voices */ unsigned int default_voice_address; @@ -362,12 +361,12 @@ struct _snd_gf1 { /* interrupt handlers */ - void (*interrupt_handler_midi_out) (snd_gus_card_t * gus); - void (*interrupt_handler_midi_in) (snd_gus_card_t * gus); - void (*interrupt_handler_timer1) (snd_gus_card_t * gus); - void (*interrupt_handler_timer2) (snd_gus_card_t * gus); - void (*interrupt_handler_dma_write) (snd_gus_card_t * gus); - void (*interrupt_handler_dma_read) (snd_gus_card_t * gus); + void (*interrupt_handler_midi_out) (struct snd_gus_card * gus); + void (*interrupt_handler_midi_in) (struct snd_gus_card * gus); + void (*interrupt_handler_timer1) (struct snd_gus_card * gus); + void (*interrupt_handler_timer2) (struct snd_gus_card * gus); + void (*interrupt_handler_dma_write) (struct snd_gus_card * gus); + void (*interrupt_handler_dma_read) (struct snd_gus_card * gus); #ifdef CONFIG_SND_DEBUG unsigned int interrupt_stat_midi_out; @@ -382,17 +381,17 @@ struct _snd_gf1 { /* synthesizer */ int seq_client; - snd_gus_port_t seq_ports[4]; - snd_seq_kinstr_list_t *ilist; - snd_iwffff_ops_t iwffff_ops; - snd_gf1_ops_t gf1_ops; - snd_simple_ops_t simple_ops; + struct snd_gus_port seq_ports[4]; + struct snd_seq_kinstr_list *ilist; + struct snd_iwffff_ops iwffff_ops; + struct snd_gf1_ops gf1_ops; + struct snd_simple_ops simple_ops; /* timer */ unsigned short timer_enabled; - snd_timer_t *timer1; - snd_timer_t *timer2; + struct snd_timer *timer1; + struct snd_timer *timer2; /* midi */ @@ -404,11 +403,11 @@ struct _snd_gf1 { unsigned int dma_flags; unsigned int dma_shared; - snd_gf1_dma_block_t *dma_data_pcm; - snd_gf1_dma_block_t *dma_data_pcm_last; - snd_gf1_dma_block_t *dma_data_synth; - snd_gf1_dma_block_t *dma_data_synth_last; - void (*dma_ack)(snd_gus_card_t * gus, void *private_data); + struct snd_gf1_dma_block *dma_data_pcm; + struct snd_gf1_dma_block *dma_data_pcm_last; + struct snd_gf1_dma_block *dma_data_synth; + struct snd_gf1_dma_block *dma_data_synth_last; + void (*dma_ack)(struct snd_gus_card * gus, void *private_data); void *dma_private_data; /* pcm */ @@ -425,8 +424,8 @@ struct _snd_gf1 { /* main structure for GUS card */ -struct _snd_gus_card { - snd_card_t *card; +struct snd_gus_card { + struct snd_card *card; unsigned int initialized: 1, /* resources were initialized */ @@ -448,18 +447,18 @@ struct _snd_gus_card { unsigned short joystick_dac; /* joystick DAC level */ int timer_dev; /* timer device */ - struct _snd_gf1 gf1; /* gf1 specific variables */ - snd_pcm_t *pcm; - snd_pcm_substream_t *pcm_cap_substream; + struct snd_gf1 gf1; /* gf1 specific variables */ + struct snd_pcm *pcm; + struct snd_pcm_substream *pcm_cap_substream; unsigned int c_dma_size; unsigned int c_period_size; unsigned int c_pos; - snd_rawmidi_t *midi_uart; - snd_rawmidi_substream_t *midi_substream_output; - snd_rawmidi_substream_t *midi_substream_input; + struct snd_rawmidi *midi_uart; + struct snd_rawmidi_substream *midi_substream_output; + struct snd_rawmidi_substream *midi_substream_input; - snd_seq_device_t *seq_dev; + struct snd_seq_device *seq_dev; spinlock_t reg_lock; spinlock_t voice_alloc; @@ -474,7 +473,7 @@ struct _snd_gus_card { /* I/O functions for GF1/InterWave chip - gus_io.c */ -static inline void snd_gf1_select_voice(snd_gus_card_t * gus, int voice) +static inline void snd_gf1_select_voice(struct snd_gus_card * gus, int voice) { unsigned long flags; @@ -486,63 +485,63 @@ static inline void snd_gf1_select_voice(snd_gus_card_t * gus, int voice) spin_unlock_irqrestore(&gus->active_voice_lock, flags); } -static inline void snd_gf1_uart_cmd(snd_gus_card_t * gus, unsigned char b) +static inline void snd_gf1_uart_cmd(struct snd_gus_card * gus, unsigned char b) { outb(gus->gf1.uart_cmd = b, GUSP(gus, MIDICTRL)); } -static inline unsigned char snd_gf1_uart_stat(snd_gus_card_t * gus) +static inline unsigned char snd_gf1_uart_stat(struct snd_gus_card * gus) { return inb(GUSP(gus, MIDISTAT)); } -static inline void snd_gf1_uart_put(snd_gus_card_t * gus, unsigned char b) +static inline void snd_gf1_uart_put(struct snd_gus_card * gus, unsigned char b) { outb(b, GUSP(gus, MIDIDATA)); } -static inline unsigned char snd_gf1_uart_get(snd_gus_card_t * gus) +static inline unsigned char snd_gf1_uart_get(struct snd_gus_card * gus) { return inb(GUSP(gus, MIDIDATA)); } -extern void snd_gf1_delay(snd_gus_card_t * gus); +extern void snd_gf1_delay(struct snd_gus_card * gus); -extern void snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg); +extern void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg); -extern void snd_gf1_write8(snd_gus_card_t * gus, unsigned char reg, unsigned char data); -extern unsigned char snd_gf1_look8(snd_gus_card_t * gus, unsigned char reg); -static inline unsigned char snd_gf1_read8(snd_gus_card_t * gus, unsigned char reg) +extern void snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data); +extern unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg); +static inline unsigned char snd_gf1_read8(struct snd_gus_card * gus, unsigned char reg) { return snd_gf1_look8(gus, reg | 0x80); } -extern void snd_gf1_write16(snd_gus_card_t * gus, unsigned char reg, unsigned int data); -extern unsigned short snd_gf1_look16(snd_gus_card_t * gus, unsigned char reg); -static inline unsigned short snd_gf1_read16(snd_gus_card_t * gus, unsigned char reg) +extern void snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data); +extern unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg); +static inline unsigned short snd_gf1_read16(struct snd_gus_card * gus, unsigned char reg) { return snd_gf1_look16(gus, reg | 0x80); } -extern void snd_gf1_adlib_write(snd_gus_card_t * gus, unsigned char reg, unsigned char data); -extern void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr); -extern void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data); -extern unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr); -extern void snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, unsigned int addr, short w_16bit); -extern unsigned int snd_gf1_read_addr(snd_gus_card_t * gus, unsigned char reg, short w_16bit); -extern void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg); -extern void snd_gf1_i_write8(snd_gus_card_t * gus, unsigned char reg, unsigned char data); -extern unsigned char snd_gf1_i_look8(snd_gus_card_t * gus, unsigned char reg); -extern void snd_gf1_i_write16(snd_gus_card_t * gus, unsigned char reg, unsigned int data); -static inline unsigned char snd_gf1_i_read8(snd_gus_card_t * gus, unsigned char reg) +extern void snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data); +extern void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr); +extern void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data); +extern unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr); +extern void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit); +extern unsigned int snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit); +extern void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg); +extern void snd_gf1_i_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data); +extern unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg); +extern void snd_gf1_i_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data); +static inline unsigned char snd_gf1_i_read8(struct snd_gus_card * gus, unsigned char reg) { return snd_gf1_i_look8(gus, reg | 0x80); } -extern unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg); -static inline unsigned short snd_gf1_i_read16(snd_gus_card_t * gus, unsigned char reg) +extern unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg); +static inline unsigned short snd_gf1_i_read16(struct snd_gus_card * gus, unsigned char reg) { return snd_gf1_i_look16(gus, reg | 0x80); } -extern void snd_gf1_select_active_voices(snd_gus_card_t * gus); +extern void snd_gf1_select_active_voices(struct snd_gus_card * gus); /* gus_lfo.c */ @@ -555,98 +554,98 @@ struct _SND_IW_LFO_PROGRAM { }; #if 0 -extern irqreturn_t snd_gf1_lfo_effect_interrupt(snd_gus_card_t * gus, snd_gf1_voice_t * voice); +extern irqreturn_t snd_gf1_lfo_effect_interrupt(struct snd_gus_card * gus, snd_gf1_voice_t * voice); #endif -extern void snd_gf1_lfo_init(snd_gus_card_t * gus); -extern void snd_gf1_lfo_done(snd_gus_card_t * gus); -extern void snd_gf1_lfo_program(snd_gus_card_t * gus, int voice, int lfo_type, struct _SND_IW_LFO_PROGRAM *program); -extern void snd_gf1_lfo_enable(snd_gus_card_t * gus, int voice, int lfo_type); -extern void snd_gf1_lfo_disable(snd_gus_card_t * gus, int voice, int lfo_type); -extern void snd_gf1_lfo_change_freq(snd_gus_card_t * gus, int voice, int lfo_type, int freq); -extern void snd_gf1_lfo_change_depth(snd_gus_card_t * gus, int voice, int lfo_type, int depth); -extern void snd_gf1_lfo_setup(snd_gus_card_t * gus, int voice, int lfo_type, int freq, int current_depth, int depth, int sweep, int shape); -extern void snd_gf1_lfo_shutdown(snd_gus_card_t * gus, int voice, int lfo_type); +extern void snd_gf1_lfo_init(struct snd_gus_card * gus); +extern void snd_gf1_lfo_done(struct snd_gus_card * gus); +extern void snd_gf1_lfo_program(struct snd_gus_card * gus, int voice, int lfo_type, struct _SND_IW_LFO_PROGRAM *program); +extern void snd_gf1_lfo_enable(struct snd_gus_card * gus, int voice, int lfo_type); +extern void snd_gf1_lfo_disable(struct snd_gus_card * gus, int voice, int lfo_type); +extern void snd_gf1_lfo_change_freq(struct snd_gus_card * gus, int voice, int lfo_type, int freq); +extern void snd_gf1_lfo_change_depth(struct snd_gus_card * gus, int voice, int lfo_type, int depth); +extern void snd_gf1_lfo_setup(struct snd_gus_card * gus, int voice, int lfo_type, int freq, int current_depth, int depth, int sweep, int shape); +extern void snd_gf1_lfo_shutdown(struct snd_gus_card * gus, int voice, int lfo_type); #if 0 -extern void snd_gf1_lfo_command(snd_gus_card_t * gus, int voice, unsigned char *command); +extern void snd_gf1_lfo_command(struct snd_gus_card * gus, int voice, unsigned char *command); #endif /* gus_mem.c */ -void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup); -int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block); -snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, +void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup); +int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block); +struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owner, char *name, int size, int w_16, int align, unsigned int *share_id); -int snd_gf1_mem_free(snd_gf1_mem_t * alloc, unsigned int address); -int snd_gf1_mem_free_owner(snd_gf1_mem_t * alloc, int owner); -int snd_gf1_mem_init(snd_gus_card_t * gus); -int snd_gf1_mem_done(snd_gus_card_t * gus); +int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address); +int snd_gf1_mem_free_owner(struct snd_gf1_mem * alloc, int owner); +int snd_gf1_mem_init(struct snd_gus_card * gus); +int snd_gf1_mem_done(struct snd_gus_card * gus); /* gus_mem_proc.c */ -int snd_gf1_mem_proc_init(snd_gus_card_t * gus); +int snd_gf1_mem_proc_init(struct snd_gus_card * gus); /* gus_dma.c */ -int snd_gf1_dma_init(snd_gus_card_t * gus); -int snd_gf1_dma_done(snd_gus_card_t * gus); -int snd_gf1_dma_transfer_block(snd_gus_card_t * gus, - snd_gf1_dma_block_t * block, +int snd_gf1_dma_init(struct snd_gus_card * gus); +int snd_gf1_dma_done(struct snd_gus_card * gus); +int snd_gf1_dma_transfer_block(struct snd_gus_card * gus, + struct snd_gf1_dma_block * block, int atomic, int synth); /* gus_volume.c */ unsigned short snd_gf1_lvol_to_gvol_raw(unsigned int vol); -unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq2); +unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int freq2); /* gus_reset.c */ -void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what); -void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice); -void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice); -void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max); -snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client, int port); -void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice); -int snd_gf1_start(snd_gus_card_t * gus); -int snd_gf1_stop(snd_gus_card_t * gus); +void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what); +void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice); +void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice); +void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max); +struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port); +void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice); +int snd_gf1_start(struct snd_gus_card * gus); +int snd_gf1_stop(struct snd_gus_card * gus); /* gus_mixer.c */ -int snd_gf1_new_mixer(snd_gus_card_t * gus); +int snd_gf1_new_mixer(struct snd_gus_card * gus); /* gus_pcm.c */ -int snd_gf1_pcm_new(snd_gus_card_t * gus, int pcm_dev, int control_index, snd_pcm_t ** rpcm); +int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm); #ifdef CONFIG_SND_DEBUG -extern void snd_gf1_print_voice_registers(snd_gus_card_t * gus); +extern void snd_gf1_print_voice_registers(struct snd_gus_card * gus); #endif /* gus.c */ -int snd_gus_use_inc(snd_gus_card_t * gus); -void snd_gus_use_dec(snd_gus_card_t * gus); -int snd_gus_create(snd_card_t * card, +int snd_gus_use_inc(struct snd_gus_card * gus); +void snd_gus_use_dec(struct snd_gus_card * gus); +int snd_gus_create(struct snd_card *card, unsigned long port, int irq, int dma1, int dma2, int timer_dev, int voices, int pcm_channels, int effect, - snd_gus_card_t ** rgus); -int snd_gus_initialize(snd_gus_card_t * gus); + struct snd_gus_card ** rgus); +int snd_gus_initialize(struct snd_gus_card * gus); /* gus_irq.c */ irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs); #ifdef CONFIG_SND_DEBUG -void snd_gus_irq_profile_init(snd_gus_card_t *gus); +void snd_gus_irq_profile_init(struct snd_gus_card *gus); #endif /* gus_uart.c */ -int snd_gf1_rawmidi_new(snd_gus_card_t * gus, int device, snd_rawmidi_t **rrawmidi); +int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi **rrawmidi); #if 0 extern void snd_engine_instrument_register(unsigned short mode, @@ -657,37 +656,37 @@ extern int snd_engine_instrument_register_ask(unsigned short mode); #endif /* gus_dram.c */ -int snd_gus_dram_write(snd_gus_card_t *gus, char __user *ptr, +int snd_gus_dram_write(struct snd_gus_card *gus, char __user *ptr, unsigned int addr, unsigned int size); -int snd_gus_dram_read(snd_gus_card_t *gus, char __user *ptr, +int snd_gus_dram_read(struct snd_gus_card *gus, char __user *ptr, unsigned int addr, unsigned int size, int rom); #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) /* gus_sample.c */ -void snd_gus_sample_event(snd_seq_event_t *ev, snd_gus_port_t *p); +void snd_gus_sample_event(struct snd_seq_event *ev, struct snd_gus_port *p); /* gus_simple.c */ -void snd_gf1_simple_init(snd_gus_voice_t *voice); +void snd_gf1_simple_init(struct snd_gus_voice *voice); /* gus_instr.c */ -int snd_gus_iwffff_put_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_put_sample(void *private_data, struct iwffff_wave *wave, char __user *data, long len, int atomic); -int snd_gus_iwffff_get_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_get_sample(void *private_data, struct iwffff_wave *wave, char __user *data, long len, int atomic); -int snd_gus_iwffff_remove_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_remove_sample(void *private_data, struct iwffff_wave *wave, int atomic); -int snd_gus_gf1_put_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_put_sample(void *private_data, struct gf1_wave *wave, char __user *data, long len, int atomic); -int snd_gus_gf1_get_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_get_sample(void *private_data, struct gf1_wave *wave, char __user *data, long len, int atomic); -int snd_gus_gf1_remove_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_remove_sample(void *private_data, struct gf1_wave *wave, int atomic); -int snd_gus_simple_put_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_put_sample(void *private_data, struct simple_instrument *instr, char __user *data, long len, int atomic); -int snd_gus_simple_get_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_get_sample(void *private_data, struct simple_instrument *instr, char __user *data, long len, int atomic); -int snd_gus_simple_remove_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_remove_sample(void *private_data, struct simple_instrument *instr, int atomic); #endif /* CONFIG_SND_SEQUENCER */ diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c index ef1b2e9..930f4bc 100644 --- a/sound/isa/gus/gus_dma.c +++ b/sound/isa/gus/gus_dma.c @@ -25,7 +25,7 @@ #include <sound/core.h> #include <sound/gus.h> -static void snd_gf1_dma_ack(snd_gus_card_t * gus) +static void snd_gf1_dma_ack(struct snd_gus_card * gus) { unsigned long flags; @@ -35,7 +35,7 @@ static void snd_gf1_dma_ack(snd_gus_card_t * gus) spin_unlock_irqrestore(&gus->reg_lock, flags); } -static void snd_gf1_dma_program(snd_gus_card_t * gus, +static void snd_gf1_dma_program(struct snd_gus_card * gus, unsigned int addr, unsigned long buf_addr, unsigned int count, @@ -91,9 +91,9 @@ static void snd_gf1_dma_program(snd_gus_card_t * gus, spin_unlock_irqrestore(&gus->reg_lock, flags); } -static snd_gf1_dma_block_t *snd_gf1_dma_next_block(snd_gus_card_t * gus) +static struct snd_gf1_dma_block *snd_gf1_dma_next_block(struct snd_gus_card * gus) { - snd_gf1_dma_block_t *block; + struct snd_gf1_dma_block *block; /* PCM block have bigger priority than synthesizer one */ if (gus->gf1.dma_data_pcm) { @@ -123,9 +123,9 @@ static snd_gf1_dma_block_t *snd_gf1_dma_next_block(snd_gus_card_t * gus) } -static void snd_gf1_dma_interrupt(snd_gus_card_t * gus) +static void snd_gf1_dma_interrupt(struct snd_gus_card * gus) { - snd_gf1_dma_block_t *block; + struct snd_gf1_dma_block *block; snd_gf1_dma_ack(gus); if (gus->gf1.dma_ack) @@ -147,7 +147,7 @@ static void snd_gf1_dma_interrupt(snd_gus_card_t * gus) #endif } -int snd_gf1_dma_init(snd_gus_card_t * gus) +int snd_gf1_dma_init(struct snd_gus_card * gus) { down(&gus->dma_mutex); gus->gf1.dma_shared++; @@ -164,9 +164,9 @@ int snd_gf1_dma_init(snd_gus_card_t * gus) return 0; } -int snd_gf1_dma_done(snd_gus_card_t * gus) +int snd_gf1_dma_done(struct snd_gus_card * gus) { - snd_gf1_dma_block_t *block; + struct snd_gf1_dma_block *block; down(&gus->dma_mutex); gus->gf1.dma_shared--; @@ -189,13 +189,13 @@ int snd_gf1_dma_done(snd_gus_card_t * gus) return 0; } -int snd_gf1_dma_transfer_block(snd_gus_card_t * gus, - snd_gf1_dma_block_t * __block, +int snd_gf1_dma_transfer_block(struct snd_gus_card * gus, + struct snd_gf1_dma_block * __block, int atomic, int synth) { unsigned long flags; - snd_gf1_dma_block_t *block; + struct snd_gf1_dma_block *block; block = kmalloc(sizeof(*block), atomic ? GFP_ATOMIC : GFP_KERNEL); if (block == NULL) { diff --git a/sound/isa/gus/gus_dram.c b/sound/isa/gus/gus_dram.c index 22120b8..f22fe79 100644 --- a/sound/isa/gus/gus_dram.c +++ b/sound/isa/gus/gus_dram.c @@ -26,7 +26,7 @@ #include <sound/info.h> -static int snd_gus_dram_poke(snd_gus_card_t *gus, char __user *_buffer, +static int snd_gus_dram_poke(struct snd_gus_card *gus, char __user *_buffer, unsigned int address, unsigned int size) { unsigned long flags; @@ -57,13 +57,13 @@ static int snd_gus_dram_poke(snd_gus_card_t *gus, char __user *_buffer, } -int snd_gus_dram_write(snd_gus_card_t *gus, char __user *buffer, +int snd_gus_dram_write(struct snd_gus_card *gus, char __user *buffer, unsigned int address, unsigned int size) { return snd_gus_dram_poke(gus, buffer, address, size); } -static int snd_gus_dram_peek(snd_gus_card_t *gus, char __user *_buffer, +static int snd_gus_dram_peek(struct snd_gus_card *gus, char __user *_buffer, unsigned int address, unsigned int size, int rom) { @@ -95,7 +95,7 @@ static int snd_gus_dram_peek(snd_gus_card_t *gus, char __user *_buffer, return 0; } -int snd_gus_dram_read(snd_gus_card_t *gus, char __user *buffer, +int snd_gus_dram_read(struct snd_gus_card *gus, char __user *buffer, unsigned int address, unsigned int size, int rom) { diff --git a/sound/isa/gus/gus_instr.c b/sound/isa/gus/gus_instr.c index 591a9a1..d0c38e1 100644 --- a/sound/isa/gus/gus_instr.c +++ b/sound/isa/gus/gus_instr.c @@ -28,11 +28,11 @@ * */ -int snd_gus_iwffff_put_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_put_sample(void *private_data, struct iwffff_wave *wave, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; - snd_gf1_mem_block_t *block; + struct snd_gus_card *gus = private_data; + struct snd_gf1_mem_block *block; int err; if (wave->format & IWFFFF_WAVE_ROM) @@ -58,19 +58,19 @@ int snd_gus_iwffff_put_sample(void *private_data, iwffff_wave_t *wave, return 0; } -int snd_gus_iwffff_get_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_get_sample(void *private_data, struct iwffff_wave *wave, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, wave->format & IWFFFF_WAVE_ROM ? 1 : 0); } -int snd_gus_iwffff_remove_sample(void *private_data, iwffff_wave_t *wave, +int snd_gus_iwffff_remove_sample(void *private_data, struct iwffff_wave *wave, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; if (wave->format & IWFFFF_WAVE_ROM) return 0; /* it's probably ok - verify the address? */ @@ -81,11 +81,11 @@ int snd_gus_iwffff_remove_sample(void *private_data, iwffff_wave_t *wave, * */ -int snd_gus_gf1_put_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_put_sample(void *private_data, struct gf1_wave *wave, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; - snd_gf1_mem_block_t *block; + struct snd_gus_card *gus = private_data; + struct snd_gf1_mem_block *block; int err; if (wave->format & GF1_WAVE_STEREO) @@ -109,18 +109,18 @@ int snd_gus_gf1_put_sample(void *private_data, gf1_wave_t *wave, return 0; } -int snd_gus_gf1_get_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_get_sample(void *private_data, struct gf1_wave *wave, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gus_dram_read(gus, data, wave->address.memory, wave->size, 0); } -int snd_gus_gf1_remove_sample(void *private_data, gf1_wave_t *wave, +int snd_gus_gf1_remove_sample(void *private_data, struct gf1_wave *wave, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gf1_mem_free(&gus->gf1.mem_alloc, wave->address.memory); } @@ -129,11 +129,11 @@ int snd_gus_gf1_remove_sample(void *private_data, gf1_wave_t *wave, * */ -int snd_gus_simple_put_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_put_sample(void *private_data, struct simple_instrument *instr, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; - snd_gf1_mem_block_t *block; + struct snd_gus_card *gus = private_data; + struct snd_gf1_mem_block *block; int err; if (instr->format & SIMPLE_WAVE_STEREO) @@ -156,18 +156,18 @@ int snd_gus_simple_put_sample(void *private_data, simple_instrument_t *instr, return 0; } -int snd_gus_simple_get_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_get_sample(void *private_data, struct simple_instrument *instr, char __user *data, long len, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gus_dram_read(gus, data, instr->address.memory, instr->size, 0); } -int snd_gus_simple_remove_sample(void *private_data, simple_instrument_t *instr, +int snd_gus_simple_remove_sample(void *private_data, struct simple_instrument *instr, int atomic) { - snd_gus_card_t *gus = private_data; + struct snd_gus_card *gus = private_data; return snd_gf1_mem_free(&gus->gf1.mem_alloc, instr->address.memory); } diff --git a/sound/isa/gus/gus_io.c b/sound/isa/gus/gus_io.c index 8d5752b..9b1fe29 100644 --- a/sound/isa/gus/gus_io.c +++ b/sound/isa/gus/gus_io.c @@ -25,7 +25,7 @@ #include <sound/core.h> #include <sound/gus.h> -void snd_gf1_delay(snd_gus_card_t * gus) +void snd_gf1_delay(struct snd_gus_card * gus) { int i; @@ -44,7 +44,7 @@ void snd_gf1_delay(snd_gus_card_t * gus) * big UltraClick (tm) elimination... */ -static inline void __snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) +static inline void __snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg) { unsigned char value; @@ -58,7 +58,7 @@ static inline void __snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) mb(); } -static inline void __snd_gf1_write8(snd_gus_card_t * gus, +static inline void __snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { @@ -68,7 +68,7 @@ static inline void __snd_gf1_write8(snd_gus_card_t * gus, mb(); } -static inline unsigned char __snd_gf1_look8(snd_gus_card_t * gus, +static inline unsigned char __snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg) { outb(reg, gus->gf1.reg_regsel); @@ -76,7 +76,7 @@ static inline unsigned char __snd_gf1_look8(snd_gus_card_t * gus, return inb(gus->gf1.reg_data8); } -static inline void __snd_gf1_write16(snd_gus_card_t * gus, +static inline void __snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data) { outb(reg, gus->gf1.reg_regsel); @@ -85,7 +85,7 @@ static inline void __snd_gf1_write16(snd_gus_card_t * gus, mb(); } -static inline unsigned short __snd_gf1_look16(snd_gus_card_t * gus, +static inline unsigned short __snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg) { outb(reg, gus->gf1.reg_regsel); @@ -93,7 +93,7 @@ static inline unsigned short __snd_gf1_look16(snd_gus_card_t * gus, return inw(gus->gf1.reg_data16); } -static inline void __snd_gf1_adlib_write(snd_gus_card_t * gus, +static inline void __snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { outb(reg, gus->gf1.reg_timerctrl); @@ -104,7 +104,7 @@ static inline void __snd_gf1_adlib_write(snd_gus_card_t * gus, inb(gus->gf1.reg_timerctrl); } -static inline void __snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, +static inline void __snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, int w_16bit) { if (gus->gf1.enh_mode) { @@ -117,7 +117,7 @@ static inline void __snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, __snd_gf1_write16(gus, reg + 1, (unsigned short) (addr << 5)); } -static inline unsigned int __snd_gf1_read_addr(snd_gus_card_t * gus, +static inline unsigned int __snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit) { unsigned int res; @@ -138,49 +138,49 @@ static inline unsigned int __snd_gf1_read_addr(snd_gus_card_t * gus, * ======================================================================= */ -void snd_gf1_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) +void snd_gf1_ctrl_stop(struct snd_gus_card * gus, unsigned char reg) { __snd_gf1_ctrl_stop(gus, reg); } -void snd_gf1_write8(snd_gus_card_t * gus, +void snd_gf1_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { __snd_gf1_write8(gus, reg, data); } -unsigned char snd_gf1_look8(snd_gus_card_t * gus, unsigned char reg) +unsigned char snd_gf1_look8(struct snd_gus_card * gus, unsigned char reg) { return __snd_gf1_look8(gus, reg); } -void snd_gf1_write16(snd_gus_card_t * gus, +void snd_gf1_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data) { __snd_gf1_write16(gus, reg, data); } -unsigned short snd_gf1_look16(snd_gus_card_t * gus, unsigned char reg) +unsigned short snd_gf1_look16(struct snd_gus_card * gus, unsigned char reg) { return __snd_gf1_look16(gus, reg); } -void snd_gf1_adlib_write(snd_gus_card_t * gus, +void snd_gf1_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { __snd_gf1_adlib_write(gus, reg, data); } -void snd_gf1_write_addr(snd_gus_card_t * gus, unsigned char reg, +void snd_gf1_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit) { __snd_gf1_write_addr(gus, reg, addr, w_16bit); } -unsigned int snd_gf1_read_addr(snd_gus_card_t * gus, +unsigned int snd_gf1_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit) { @@ -191,7 +191,7 @@ unsigned int snd_gf1_read_addr(snd_gus_card_t * gus, */ -void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) +void snd_gf1_i_ctrl_stop(struct snd_gus_card * gus, unsigned char reg) { unsigned long flags; @@ -200,7 +200,7 @@ void snd_gf1_i_ctrl_stop(snd_gus_card_t * gus, unsigned char reg) spin_unlock_irqrestore(&gus->reg_lock, flags); } -void snd_gf1_i_write8(snd_gus_card_t * gus, +void snd_gf1_i_write8(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { @@ -211,7 +211,7 @@ void snd_gf1_i_write8(snd_gus_card_t * gus, spin_unlock_irqrestore(&gus->reg_lock, flags); } -unsigned char snd_gf1_i_look8(snd_gus_card_t * gus, unsigned char reg) +unsigned char snd_gf1_i_look8(struct snd_gus_card * gus, unsigned char reg) { unsigned long flags; unsigned char res; @@ -222,7 +222,7 @@ unsigned char snd_gf1_i_look8(snd_gus_card_t * gus, unsigned char reg) return res; } -void snd_gf1_i_write16(snd_gus_card_t * gus, +void snd_gf1_i_write16(struct snd_gus_card * gus, unsigned char reg, unsigned int data) { @@ -233,7 +233,7 @@ void snd_gf1_i_write16(snd_gus_card_t * gus, spin_unlock_irqrestore(&gus->reg_lock, flags); } -unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg) +unsigned short snd_gf1_i_look16(struct snd_gus_card * gus, unsigned char reg) { unsigned long flags; unsigned short res; @@ -246,7 +246,7 @@ unsigned short snd_gf1_i_look16(snd_gus_card_t * gus, unsigned char reg) #if 0 -void snd_gf1_i_adlib_write(snd_gus_card_t * gus, +void snd_gf1_i_adlib_write(struct snd_gus_card * gus, unsigned char reg, unsigned char data) { @@ -257,7 +257,7 @@ void snd_gf1_i_adlib_write(snd_gus_card_t * gus, spin_unlock_irqrestore(&gus->reg_lock, flags); } -void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg, +void snd_gf1_i_write_addr(struct snd_gus_card * gus, unsigned char reg, unsigned int addr, short w_16bit) { unsigned long flags; @@ -270,7 +270,7 @@ void snd_gf1_i_write_addr(snd_gus_card_t * gus, unsigned char reg, #endif /* 0 */ #ifdef CONFIG_SND_DEBUG -static unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, +static unsigned int snd_gf1_i_read_addr(struct snd_gus_card * gus, unsigned char reg, short w_16bit) { unsigned int res; @@ -287,7 +287,7 @@ static unsigned int snd_gf1_i_read_addr(snd_gus_card_t * gus, */ -void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr) +void snd_gf1_dram_addr(struct snd_gus_card * gus, unsigned int addr) { outb(0x43, gus->gf1.reg_regsel); mb(); @@ -299,7 +299,7 @@ void snd_gf1_dram_addr(snd_gus_card_t * gus, unsigned int addr) mb(); } -void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data) +void snd_gf1_poke(struct snd_gus_card * gus, unsigned int addr, unsigned char data) { unsigned long flags; @@ -316,7 +316,7 @@ void snd_gf1_poke(snd_gus_card_t * gus, unsigned int addr, unsigned char data) spin_unlock_irqrestore(&gus->reg_lock, flags); } -unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr) +unsigned char snd_gf1_peek(struct snd_gus_card * gus, unsigned int addr) { unsigned long flags; unsigned char res; @@ -337,7 +337,7 @@ unsigned char snd_gf1_peek(snd_gus_card_t * gus, unsigned int addr) #if 0 -void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data) +void snd_gf1_pokew(struct snd_gus_card * gus, unsigned int addr, unsigned short data) { unsigned long flags; @@ -360,7 +360,7 @@ void snd_gf1_pokew(snd_gus_card_t * gus, unsigned int addr, unsigned short data) spin_unlock_irqrestore(&gus->reg_lock, flags); } -unsigned short snd_gf1_peekw(snd_gus_card_t * gus, unsigned int addr) +unsigned short snd_gf1_peekw(struct snd_gus_card * gus, unsigned int addr) { unsigned long flags; unsigned short res; @@ -385,7 +385,7 @@ unsigned short snd_gf1_peekw(snd_gus_card_t * gus, unsigned int addr) return res; } -void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr, +void snd_gf1_dram_setmem(struct snd_gus_card * gus, unsigned int addr, unsigned short value, unsigned int count) { unsigned long port; @@ -415,7 +415,7 @@ void snd_gf1_dram_setmem(snd_gus_card_t * gus, unsigned int addr, #endif /* 0 */ -void snd_gf1_select_active_voices(snd_gus_card_t * gus) +void snd_gf1_select_active_voices(struct snd_gus_card * gus) { unsigned short voices; @@ -443,7 +443,7 @@ void snd_gf1_select_active_voices(snd_gus_card_t * gus) #ifdef CONFIG_SND_DEBUG -void snd_gf1_print_voice_registers(snd_gus_card_t * gus) +void snd_gf1_print_voice_registers(struct snd_gus_card * gus) { unsigned char mode; int voice, ctrl; @@ -477,7 +477,7 @@ void snd_gf1_print_voice_registers(snd_gus_card_t * gus) #if 0 -void snd_gf1_print_global_registers(snd_gus_card_t * gus) +void snd_gf1_print_global_registers(struct snd_gus_card * gus) { unsigned char global_mode = 0x00; @@ -504,7 +504,7 @@ void snd_gf1_print_global_registers(snd_gus_card_t * gus) } } -void snd_gf1_print_setup_registers(snd_gus_card_t * gus) +void snd_gf1_print_setup_registers(struct snd_gus_card * gus) { printk(KERN_INFO " -S- mix control = 0x%x\n", inb(GUSP(gus, MIXCNTRLREG))); printk(KERN_INFO " -S- IRQ status = 0x%x\n", inb(GUSP(gus, IRQSTAT))); @@ -523,7 +523,7 @@ void snd_gf1_print_setup_registers(snd_gus_card_t * gus) } } -void snd_gf1_peek_print_block(snd_gus_card_t * gus, unsigned int addr, int count, int w_16bit) +void snd_gf1_peek_print_block(struct snd_gus_card * gus, unsigned int addr, int count, int w_16bit) { if (!w_16bit) { while (count-- > 0) diff --git a/sound/isa/gus/gus_irq.c b/sound/isa/gus/gus_irq.c index 1e2a15e..c19ba29 100644 --- a/sound/isa/gus/gus_irq.c +++ b/sound/isa/gus/gus_irq.c @@ -32,7 +32,7 @@ irqreturn_t snd_gus_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - snd_gus_card_t * gus = dev_id; + struct snd_gus_card * gus = dev_id; unsigned char status; int loop = 100; int handled = 0; @@ -54,7 +54,7 @@ __again: if (status & (0x20 | 0x40)) { unsigned int already, _current_; unsigned char voice_status, voice; - snd_gus_voice_t *pvoice; + struct snd_gus_voice *pvoice; already = 0; while (((voice_status = snd_gf1_i_read8(gus, SNDRV_GF1_GB_VOICES_IRQ)) & 0xc0) != 0xc0) { @@ -107,11 +107,11 @@ __again: } #ifdef CONFIG_SND_DEBUG -static void snd_gus_irq_info_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_gus_irq_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_gus_card_t *gus; - snd_gus_voice_t *pvoice; + struct snd_gus_card *gus; + struct snd_gus_voice *pvoice; int idx; gus = entry->private_data; @@ -131,9 +131,9 @@ static void snd_gus_irq_info_read(snd_info_entry_t *entry, } } -void snd_gus_irq_profile_init(snd_gus_card_t *gus) +void snd_gus_irq_profile_init(struct snd_gus_card *gus) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(gus->card, "gusirq", &entry)) snd_info_set_text_ops(entry, gus, 1024, snd_gus_irq_info_read); diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 4f57ff4..6d15b3d 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -35,21 +35,21 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("Routines for Gravis UltraSound soundcards"); MODULE_LICENSE("GPL"); -static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches); +static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches); -int snd_gus_use_inc(snd_gus_card_t * gus) +int snd_gus_use_inc(struct snd_gus_card * gus) { if (!try_module_get(gus->card->module)) return 0; return 1; } -void snd_gus_use_dec(snd_gus_card_t * gus) +void snd_gus_use_dec(struct snd_gus_card * gus) { module_put(gus->card->module); } -static int snd_gus_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_gus_joystick_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -58,17 +58,17 @@ static int snd_gus_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_gus_joystick_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gus_joystick_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = gus->joystick_dac & 31; return 0; } -static int snd_gus_joystick_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gus_joystick_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned char nval; @@ -82,7 +82,7 @@ static int snd_gus_joystick_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_gus_joystick_control = { +static struct snd_kcontrol_new snd_gus_joystick_control = { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = "Joystick Speed", .info = snd_gus_joystick_info, @@ -90,7 +90,7 @@ static snd_kcontrol_new_t snd_gus_joystick_control = { .put = snd_gus_joystick_put }; -static void snd_gus_init_control(snd_gus_card_t *gus) +static void snd_gus_init_control(struct snd_gus_card *gus) { if (!gus->ace_flag) snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus)); @@ -100,7 +100,7 @@ static void snd_gus_init_control(snd_gus_card_t *gus) * */ -static int snd_gus_free(snd_gus_card_t *gus) +static int snd_gus_free(struct snd_gus_card *gus) { if (gus->gf1.res_port2 == NULL) goto __hw_end; @@ -129,24 +129,24 @@ static int snd_gus_free(snd_gus_card_t *gus) return 0; } -static int snd_gus_dev_free(snd_device_t *device) +static int snd_gus_dev_free(struct snd_device *device) { - snd_gus_card_t *gus = device->device_data; + struct snd_gus_card *gus = device->device_data; return snd_gus_free(gus); } -int snd_gus_create(snd_card_t * card, +int snd_gus_create(struct snd_card *card, unsigned long port, int irq, int dma1, int dma2, int timer_dev, int voices, int pcm_channels, int effect, - snd_gus_card_t **rgus) + struct snd_gus_card **rgus) { - snd_gus_card_t *gus; + struct snd_gus_card *gus; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_gus_dev_free, }; @@ -238,7 +238,7 @@ int snd_gus_create(snd_card_t * card, * Memory detection routine for plain GF1 soundcards */ -static int snd_gus_detect_memory(snd_gus_card_t * gus) +static int snd_gus_detect_memory(struct snd_gus_card * gus) { int l, idx, local; unsigned char d; @@ -273,9 +273,9 @@ static int snd_gus_detect_memory(snd_gus_card_t * gus) return 0; /* some memory were detected */ } -static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches) +static int snd_gus_init_dma_irq(struct snd_gus_card * gus, int latches) { - snd_card_t *card; + struct snd_card *card; unsigned long flags; int irq, dma1, dma2; static unsigned char irqs[16] = @@ -360,11 +360,11 @@ static int snd_gus_init_dma_irq(snd_gus_card_t * gus, int latches) return 0; } -static int snd_gus_check_version(snd_gus_card_t * gus) +static int snd_gus_check_version(struct snd_gus_card * gus) { unsigned long flags; unsigned char val, rev; - snd_card_t *card; + struct snd_card *card; card = gus->card; spin_lock_irqsave(&gus->reg_lock, flags); @@ -409,14 +409,14 @@ static int snd_gus_check_version(snd_gus_card_t * gus) } #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) -static void snd_gus_seq_dev_free(snd_seq_device_t *seq_dev) +static void snd_gus_seq_dev_free(struct snd_seq_device *seq_dev) { - snd_gus_card_t *gus = seq_dev->private_data; + struct snd_gus_card *gus = seq_dev->private_data; gus->seq_dev = NULL; } #endif -int snd_gus_initialize(snd_gus_card_t *gus) +int snd_gus_initialize(struct snd_gus_card *gus) { int err; @@ -432,9 +432,9 @@ int snd_gus_initialize(snd_gus_card_t *gus) return err; #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) if (snd_seq_device_new(gus->card, 1, SNDRV_SEQ_DEV_ID_GUS, - sizeof(snd_gus_card_t*), &gus->seq_dev) >= 0) { + sizeof(struct snd_gus_card *), &gus->seq_dev) >= 0) { strcpy(gus->seq_dev->name, "GUS"); - *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(gus->seq_dev) = gus; + *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(gus->seq_dev) = gus; gus->seq_dev->private_data = gus; gus->seq_dev->private_free = snd_gus_seq_dev_free; } diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c index 2e23f2a..e8bdb86 100644 --- a/sound/isa/gus/gus_mem.c +++ b/sound/isa/gus/gus_mem.c @@ -27,11 +27,11 @@ #include <sound/info.h> #ifdef CONFIG_SND_DEBUG -static void snd_gf1_mem_info_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer); +static void snd_gf1_mem_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer); #endif -void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup) +void snd_gf1_mem_lock(struct snd_gf1_mem * alloc, int xup) { if (!xup) { down(&alloc->memory_mutex); @@ -40,12 +40,12 @@ void snd_gf1_mem_lock(snd_gf1_mem_t * alloc, int xup) } } -static snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc, - snd_gf1_mem_block_t * block) +static struct snd_gf1_mem_block *snd_gf1_mem_xalloc(struct snd_gf1_mem * alloc, + struct snd_gf1_mem_block * block) { - snd_gf1_mem_block_t *pblock, *nblock; + struct snd_gf1_mem_block *pblock, *nblock; - nblock = (snd_gf1_mem_block_t *) kmalloc(sizeof(snd_gf1_mem_block_t), GFP_KERNEL); + nblock = kmalloc(sizeof(struct snd_gf1_mem_block), GFP_KERNEL); if (nblock == NULL) return NULL; *nblock = *block; @@ -76,7 +76,7 @@ static snd_gf1_mem_block_t *snd_gf1_mem_xalloc(snd_gf1_mem_t * alloc, return nblock; } -int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block) +int snd_gf1_mem_xfree(struct snd_gf1_mem * alloc, struct snd_gf1_mem_block * block) { if (block->share) { /* ok.. shared block */ block->share--; @@ -106,10 +106,10 @@ int snd_gf1_mem_xfree(snd_gf1_mem_t * alloc, snd_gf1_mem_block_t * block) return 0; } -static snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, +static struct snd_gf1_mem_block *snd_gf1_mem_look(struct snd_gf1_mem * alloc, unsigned int address) { - snd_gf1_mem_block_t *block; + struct snd_gf1_mem_block *block; for (block = alloc->first; block; block = block->next) { if (block->ptr == address) { @@ -119,10 +119,10 @@ static snd_gf1_mem_block_t *snd_gf1_mem_look(snd_gf1_mem_t * alloc, return NULL; } -static snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc, +static struct snd_gf1_mem_block *snd_gf1_mem_share(struct snd_gf1_mem * alloc, unsigned int *share_id) { - snd_gf1_mem_block_t *block; + struct snd_gf1_mem_block *block; if (!share_id[0] && !share_id[1] && !share_id[2] && !share_id[3]) @@ -133,14 +133,14 @@ static snd_gf1_mem_block_t *snd_gf1_mem_share(snd_gf1_mem_t * alloc, return NULL; } -static int snd_gf1_mem_find(snd_gf1_mem_t * alloc, - snd_gf1_mem_block_t * block, +static int snd_gf1_mem_find(struct snd_gf1_mem * alloc, + struct snd_gf1_mem_block * block, unsigned int size, int w_16, int align) { - snd_gf1_bank_info_t *info = w_16 ? alloc->banks_16 : alloc->banks_8; + struct snd_gf1_bank_info *info = w_16 ? alloc->banks_16 : alloc->banks_8; unsigned int idx, boundary; int size1; - snd_gf1_mem_block_t *pblock; + struct snd_gf1_mem_block *pblock; unsigned int ptr1, ptr2; align--; @@ -186,11 +186,11 @@ static int snd_gf1_mem_find(snd_gf1_mem_t * alloc, return -ENOMEM; } -snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, +struct snd_gf1_mem_block *snd_gf1_mem_alloc(struct snd_gf1_mem * alloc, int owner, char *name, int size, int w_16, int align, unsigned int *share_id) { - snd_gf1_mem_block_t block, *nblock; + struct snd_gf1_mem_block block, *nblock; snd_gf1_mem_lock(alloc, 0); if (share_id != NULL) { @@ -220,10 +220,10 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, return nblock; } -int snd_gf1_mem_free(snd_gf1_mem_t * alloc, unsigned int address) +int snd_gf1_mem_free(struct snd_gf1_mem * alloc, unsigned int address) { int result; - snd_gf1_mem_block_t *block; + struct snd_gf1_mem_block *block; snd_gf1_mem_lock(alloc, 0); if ((block = snd_gf1_mem_look(alloc, address)) != NULL) { @@ -235,12 +235,12 @@ int snd_gf1_mem_free(snd_gf1_mem_t * alloc, unsigned int address) return -EINVAL; } -int snd_gf1_mem_init(snd_gus_card_t * gus) +int snd_gf1_mem_init(struct snd_gus_card * gus) { - snd_gf1_mem_t *alloc; - snd_gf1_mem_block_t block; + struct snd_gf1_mem *alloc; + struct snd_gf1_mem_block block; #ifdef CONFIG_SND_DEBUG - snd_info_entry_t *entry; + struct snd_info_entry *entry; #endif alloc = &gus->gf1.mem_alloc; @@ -272,10 +272,10 @@ int snd_gf1_mem_init(snd_gus_card_t * gus) return 0; } -int snd_gf1_mem_done(snd_gus_card_t * gus) +int snd_gf1_mem_done(struct snd_gus_card * gus) { - snd_gf1_mem_t *alloc; - snd_gf1_mem_block_t *block, *nblock; + struct snd_gf1_mem *alloc; + struct snd_gf1_mem_block *block, *nblock; alloc = &gus->gf1.mem_alloc; block = alloc->first; @@ -288,12 +288,12 @@ int snd_gf1_mem_done(snd_gus_card_t * gus) } #ifdef CONFIG_SND_DEBUG -static void snd_gf1_mem_info_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_gf1_mem_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - snd_gus_card_t *gus; - snd_gf1_mem_t *alloc; - snd_gf1_mem_block_t *block; + struct snd_gus_card *gus; + struct snd_gf1_mem *alloc; + struct snd_gf1_mem_block *block; unsigned int total, used; int i; diff --git a/sound/isa/gus/gus_mem_proc.c b/sound/isa/gus/gus_mem_proc.c index 7f96ac2..4080255 100644 --- a/sound/isa/gus/gus_mem_proc.c +++ b/sound/isa/gus/gus_mem_proc.c @@ -25,20 +25,20 @@ #include <sound/gus.h> #include <sound/info.h> -typedef struct gus_proc_private { +struct gus_proc_private { int rom; /* data are in ROM */ unsigned int address; unsigned int size; - snd_gus_card_t * gus; -} gus_proc_private_t; + struct snd_gus_card * gus; +}; -static long snd_gf1_mem_proc_dump(snd_info_entry_t *entry, void *file_private_data, +static long snd_gf1_mem_proc_dump(struct snd_info_entry *entry, void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { long size; - gus_proc_private_t *priv = entry->private_data; - snd_gus_card_t *gus = priv->gus; + struct gus_proc_private *priv = entry->private_data; + struct snd_gus_card *gus = priv->gus; int err; size = count; @@ -52,13 +52,13 @@ static long snd_gf1_mem_proc_dump(snd_info_entry_t *entry, void *file_private_da return 0; } -static long long snd_gf1_mem_proc_llseek(snd_info_entry_t *entry, +static long long snd_gf1_mem_proc_llseek(struct snd_info_entry *entry, void *private_file_data, struct file *file, long long offset, int orig) { - gus_proc_private_t *priv = entry->private_data; + struct gus_proc_private *priv = entry->private_data; switch (orig) { case 0: /* SEEK_SET */ @@ -78,9 +78,9 @@ static long long snd_gf1_mem_proc_llseek(snd_info_entry_t *entry, return file->f_pos; } -static void snd_gf1_mem_proc_free(snd_info_entry_t *entry) +static void snd_gf1_mem_proc_free(struct snd_info_entry *entry) { - gus_proc_private_t *priv = entry->private_data; + struct gus_proc_private *priv = entry->private_data; kfree(priv); } @@ -89,12 +89,12 @@ static struct snd_info_entry_ops snd_gf1_mem_proc_ops = { .llseek = snd_gf1_mem_proc_llseek, }; -int snd_gf1_mem_proc_init(snd_gus_card_t * gus) +int snd_gf1_mem_proc_init(struct snd_gus_card * gus) { int idx; char name[16]; - gus_proc_private_t *priv; - snd_info_entry_t *entry; + struct gus_proc_private *priv; + struct snd_info_entry *entry; for (idx = 0; idx < 4; idx++) { if (gus->gf1.mem_alloc.banks_8[idx].size > 0) { diff --git a/sound/isa/gus/gus_mixer.c b/sound/isa/gus/gus_mixer.c index a051094..acc25a2 100644 --- a/sound/isa/gus/gus_mixer.c +++ b/sound/isa/gus/gus_mixer.c @@ -36,7 +36,7 @@ .get = snd_gf1_get_single, .put = snd_gf1_put_single, \ .private_value = shift | (invert << 8) } -static int snd_gf1_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_gf1_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -45,9 +45,9 @@ static int snd_gf1_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_gf1_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gf1_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value >> 8) & 1; @@ -57,9 +57,9 @@ static int snd_gf1_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_gf1_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gf1_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value >> 8) & 1; @@ -86,7 +86,7 @@ static int snd_gf1_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_ics_get_double, .put = snd_ics_put_double, \ .private_value = addr } -static int snd_ics_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ics_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -95,9 +95,9 @@ static int snd_ics_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_ics_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ics_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int addr = kcontrol->private_value & 0xff; unsigned char left, right; @@ -111,9 +111,9 @@ static int snd_ics_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_ics_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ics_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int addr = kcontrol->private_value & 0xff; int change; @@ -146,13 +146,13 @@ static int snd_ics_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -static snd_kcontrol_new_t snd_gf1_controls[] = { +static struct snd_kcontrol_new snd_gf1_controls[] = { GF1_SINGLE("Master Playback Switch", 0, 1, 1), GF1_SINGLE("Line Switch", 0, 0, 1), GF1_SINGLE("Mic Switch", 0, 2, 0) }; -static snd_kcontrol_new_t snd_ics_controls[] = { +static struct snd_kcontrol_new snd_ics_controls[] = { GF1_SINGLE("Master Playback Switch", 0, 1, 1), ICS_DOUBLE("Master Playback Volume", 0, SNDRV_ICS_MASTER_DEV), ICS_DOUBLE("Synth Playback Volume", 0, SNDRV_ICS_GF1_DEV), @@ -163,9 +163,9 @@ ICS_DOUBLE("Mic Playback Volume", 0, SNDRV_ICS_MIC_DEV), ICS_DOUBLE("CD Playback Volume", 0, SNDRV_ICS_CD_DEV) }; -int snd_gf1_new_mixer(snd_gus_card_t * gus) +int snd_gf1_new_mixer(struct snd_gus_card * gus) { - snd_card_t *card; + struct snd_card *card; unsigned int idx, max; int err; diff --git a/sound/isa/gus/gus_pcm.c b/sound/isa/gus/gus_pcm.c index bae0fee..d082939 100644 --- a/sound/isa/gus/gus_pcm.c +++ b/sound/isa/gus/gus_pcm.c @@ -42,12 +42,12 @@ #define SNDRV_GF1_PCM_PFLG_ACTIVE (1<<0) #define SNDRV_GF1_PCM_PFLG_NEUTRAL (2<<0) -typedef struct { - snd_gus_card_t * gus; - snd_pcm_substream_t * substream; +struct gus_pcm_private { + struct snd_gus_card * gus; + struct snd_pcm_substream *substream; spinlock_t lock; unsigned int voices; - snd_gus_voice_t *pvoices[2]; + struct snd_gus_voice *pvoices[2]; unsigned int memory; unsigned short flags; unsigned char voice_ctrl, ramp_ctrl; @@ -58,13 +58,13 @@ typedef struct { wait_queue_head_t sleep; atomic_t dma_count; int final_volume; -} gus_pcm_private_t; +}; static int snd_gf1_pcm_use_dma = 1; -static void snd_gf1_pcm_block_change_ack(snd_gus_card_t * gus, void *private_data) +static void snd_gf1_pcm_block_change_ack(struct snd_gus_card * gus, void *private_data) { - gus_pcm_private_t *pcmp = private_data; + struct gus_pcm_private *pcmp = private_data; if (pcmp) { atomic_dec(&pcmp->dma_count); @@ -72,14 +72,14 @@ static void snd_gf1_pcm_block_change_ack(snd_gus_card_t * gus, void *private_dat } } -static int snd_gf1_pcm_block_change(snd_pcm_substream_t * substream, +static int snd_gf1_pcm_block_change(struct snd_pcm_substream *substream, unsigned int offset, unsigned int addr, unsigned int count) { - snd_gf1_dma_block_t block; - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gf1_dma_block block; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; count += offset & 31; offset &= ~31; @@ -101,11 +101,11 @@ static int snd_gf1_pcm_block_change(snd_pcm_substream_t * substream, return 0; } -static void snd_gf1_pcm_trigger_up(snd_pcm_substream_t * substream) +static void snd_gf1_pcm_trigger_up(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; - snd_gus_card_t * gus = pcmp->gus; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; + struct snd_gus_card * gus = pcmp->gus; unsigned long flags; unsigned char voice_ctrl, ramp_ctrl; unsigned short rate; @@ -179,10 +179,11 @@ static void snd_gf1_pcm_trigger_up(snd_pcm_substream_t * substream) spin_unlock_irqrestore(&gus->reg_lock, flags); } -static void snd_gf1_pcm_interrupt_wave(snd_gus_card_t * gus, snd_gus_voice_t *pvoice) +static void snd_gf1_pcm_interrupt_wave(struct snd_gus_card * gus, + struct snd_gus_voice *pvoice) { - gus_pcm_private_t * pcmp; - snd_pcm_runtime_t * runtime; + struct gus_pcm_private * pcmp; + struct snd_pcm_runtime *runtime; unsigned char voice_ctrl, ramp_ctrl; unsigned int idx; unsigned int end, step; @@ -261,11 +262,12 @@ static void snd_gf1_pcm_interrupt_wave(snd_gus_card_t * gus, snd_gus_voice_t *pv #endif } -static void snd_gf1_pcm_interrupt_volume(snd_gus_card_t * gus, snd_gus_voice_t * pvoice) +static void snd_gf1_pcm_interrupt_volume(struct snd_gus_card * gus, + struct snd_gus_voice * pvoice) { unsigned short vol; int cvoice; - gus_pcm_private_t *pcmp = pvoice->private_data; + struct gus_pcm_private *pcmp = pvoice->private_data; /* stop ramp, but leave rollover bit untouched */ spin_lock(&gus->reg_lock); @@ -289,11 +291,11 @@ static void snd_gf1_pcm_interrupt_volume(snd_gus_card_t * gus, snd_gus_voice_t * spin_unlock(&gus->reg_lock); } -static void snd_gf1_pcm_volume_change(snd_gus_card_t * gus) +static void snd_gf1_pcm_volume_change(struct snd_gus_card * gus) { } -static int snd_gf1_pcm_poke_block(snd_gus_card_t *gus, unsigned char *buf, +static int snd_gf1_pcm_poke_block(struct snd_gus_card *gus, unsigned char *buf, unsigned int pos, unsigned int count, int w16, int invert) { @@ -341,14 +343,14 @@ static int snd_gf1_pcm_poke_block(snd_gus_card_t *gus, unsigned char *buf, return 0; } -static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream, +static int snd_gf1_pcm_playback_copy(struct snd_pcm_substream *substream, int voice, snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; unsigned int bpos, len; bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2)); @@ -360,7 +362,7 @@ static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream, if (snd_gf1_pcm_use_dma && len > 32) { return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len); } else { - snd_gus_card_t *gus = pcmp->gus; + struct snd_gus_card *gus = pcmp->gus; int err, w16, invert; w16 = (snd_pcm_format_width(runtime->format) == 16); @@ -371,13 +373,13 @@ static int snd_gf1_pcm_playback_copy(snd_pcm_substream_t *substream, return 0; } -static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream, +static int snd_gf1_pcm_playback_silence(struct snd_pcm_substream *substream, int voice, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; unsigned int bpos, len; bpos = samples_to_bytes(runtime, pos) + (voice * (pcmp->dma_size / 2)); @@ -388,7 +390,7 @@ static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream, if (snd_gf1_pcm_use_dma && len > 32) { return snd_gf1_pcm_block_change(substream, bpos, pcmp->memory + bpos, len); } else { - snd_gus_card_t *gus = pcmp->gus; + struct snd_gus_card *gus = pcmp->gus; int err, w16, invert; w16 = (snd_pcm_format_width(runtime->format) == 16); @@ -399,18 +401,18 @@ static int snd_gf1_pcm_playback_silence(snd_pcm_substream_t *substream, return 0; } -static int snd_gf1_pcm_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_gf1_pcm_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) return err; if (err > 0) { /* change */ - snd_gf1_mem_block_t *block; + struct snd_gf1_mem_block *block; if (pcmp->memory > 0) { snd_gf1_mem_free(&gus->gf1.mem_alloc, pcmp->memory); pcmp->memory = 0; @@ -448,10 +450,10 @@ static int snd_gf1_pcm_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_gf1_pcm_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_playback_hw_free(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; snd_pcm_lib_free_pages(substream); if (pcmp->pvoices[0]) { @@ -469,10 +471,10 @@ static int snd_gf1_pcm_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_playback_prepare(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_playback_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; pcmp->bpos = 0; pcmp->dma_size = snd_pcm_lib_buffer_bytes(substream); @@ -481,12 +483,12 @@ static int snd_gf1_pcm_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_playback_trigger(snd_pcm_substream_t * substream, +static int snd_gf1_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; int voice; if (cmd == SNDRV_PCM_TRIGGER_START) { @@ -507,11 +509,11 @@ static int snd_gf1_pcm_playback_trigger(snd_pcm_substream_t * substream, return 0; } -static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; unsigned int pos; unsigned char voice_ctrl; @@ -529,22 +531,22 @@ static snd_pcm_uframes_t snd_gf1_pcm_playback_pointer(snd_pcm_substream_t * subs return pos; } -static ratnum_t clock = { +static struct snd_ratnum clock = { .num = 9878400/16, .den_min = 2, .den_max = 257, .den_step = 1, }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = { .nrats = 1, .rats = &clock, }; -static int snd_gf1_pcm_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_gf1_pcm_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); gus->c_dma_size = params_buffer_bytes(hw_params); gus->c_period_size = params_period_bytes(hw_params); @@ -559,15 +561,15 @@ static int snd_gf1_pcm_capture_hw_params(snd_pcm_substream_t * substream, return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_gf1_pcm_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_gf1_pcm_capture_prepare(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_capture_prepare(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_gf1_i_write8(gus, SNDRV_GF1_GB_RECORD_RATE, runtime->rate_den - 2); snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */ @@ -576,10 +578,10 @@ static int snd_gf1_pcm_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_capture_trigger(snd_pcm_substream_t * substream, +static int snd_gf1_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); int val; if (cmd == SNDRV_PCM_TRIGGER_START) { @@ -597,15 +599,15 @@ static int snd_gf1_pcm_capture_trigger(snd_pcm_substream_t * substream, return 0; } -static snd_pcm_uframes_t snd_gf1_pcm_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_gf1_pcm_capture_pointer(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); int pos = snd_dma_pointer(gus->gf1.dma2, gus->c_period_size); pos = bytes_to_frames(substream->runtime, (gus->c_pos + pos) % gus->c_dma_size); return pos; } -static void snd_gf1_pcm_interrupt_dma_read(snd_gus_card_t * gus) +static void snd_gf1_pcm_interrupt_dma_read(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL, 0); /* disable sampling */ snd_gf1_i_look8(gus, SNDRV_GF1_GB_REC_DMA_CONTROL); /* Sampling Control Register */ @@ -617,7 +619,7 @@ static void snd_gf1_pcm_interrupt_dma_read(snd_gus_card_t * gus) } } -static snd_pcm_hardware_t snd_gf1_pcm_playback = +static struct snd_pcm_hardware snd_gf1_pcm_playback = { .info = SNDRV_PCM_INFO_NONINTERLEAVED, .formats = (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | @@ -635,7 +637,7 @@ static snd_pcm_hardware_t snd_gf1_pcm_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_gf1_pcm_capture = +static struct snd_pcm_hardware snd_gf1_pcm_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -653,16 +655,16 @@ static snd_pcm_hardware_t snd_gf1_pcm_capture = .fifo_size = 0, }; -static void snd_gf1_pcm_playback_free(snd_pcm_runtime_t *runtime) +static void snd_gf1_pcm_playback_free(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) +static int snd_gf1_pcm_playback_open(struct snd_pcm_substream *substream) { - gus_pcm_private_t *pcmp; - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct gus_pcm_private *pcmp; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; pcmp = kzalloc(sizeof(*pcmp), GFP_KERNEL); @@ -690,11 +692,11 @@ static int snd_gf1_pcm_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_gf1_pcm_playback_close(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_playback_close(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - gus_pcm_private_t *pcmp = runtime->private_data; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct gus_pcm_private *pcmp = runtime->private_data; if (!wait_event_timeout(pcmp->sleep, (atomic_read(&pcmp->dma_count) <= 0), 2*HZ)) snd_printk(KERN_ERR "gf1 pcm - serious DMA problem\n"); @@ -703,10 +705,10 @@ static int snd_gf1_pcm_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_capture_open(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_capture_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); gus->gf1.interrupt_handler_dma_read = snd_gf1_pcm_interrupt_dma_read; gus->pcm_cap_substream = substream; @@ -718,16 +720,16 @@ static int snd_gf1_pcm_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_gf1_pcm_capture_close(snd_pcm_substream_t * substream) +static int snd_gf1_pcm_capture_close(struct snd_pcm_substream *substream) { - snd_gus_card_t *gus = snd_pcm_substream_chip(substream); + struct snd_gus_card *gus = snd_pcm_substream_chip(substream); gus->pcm_cap_substream = NULL; snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_DMA_READ); return 0; } -static int snd_gf1_pcm_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_gf1_pcm_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -736,9 +738,9 @@ static int snd_gf1_pcm_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_gf1_pcm_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gf1_pcm_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&gus->pcm_volume_level_lock, flags); @@ -748,15 +750,15 @@ static int snd_gf1_pcm_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_gf1_pcm_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_gf1_pcm_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - snd_gus_card_t *gus = snd_kcontrol_chip(kcontrol); + struct snd_gus_card *gus = snd_kcontrol_chip(kcontrol); unsigned long flags; int change; unsigned int idx; unsigned short val1, val2, vol; - gus_pcm_private_t *pcmp; - snd_gus_voice_t *pvoice; + struct gus_pcm_private *pcmp; + struct snd_gus_voice *pvoice; val1 = ucontrol->value.integer.value[0] & 127; val2 = ucontrol->value.integer.value[1] & 127; @@ -790,7 +792,7 @@ static int snd_gf1_pcm_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -static snd_kcontrol_new_t snd_gf1_pcm_volume_control = +static struct snd_kcontrol_new snd_gf1_pcm_volume_control = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Volume", @@ -799,7 +801,7 @@ static snd_kcontrol_new_t snd_gf1_pcm_volume_control = .put = snd_gf1_pcm_volume_put }; -static snd_kcontrol_new_t snd_gf1_pcm_volume_control1 = +static struct snd_kcontrol_new snd_gf1_pcm_volume_control1 = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "GPCM Playback Volume", @@ -808,7 +810,7 @@ static snd_kcontrol_new_t snd_gf1_pcm_volume_control1 = .put = snd_gf1_pcm_volume_put }; -static snd_pcm_ops_t snd_gf1_pcm_playback_ops = { +static struct snd_pcm_ops snd_gf1_pcm_playback_ops = { .open = snd_gf1_pcm_playback_open, .close = snd_gf1_pcm_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -821,7 +823,7 @@ static snd_pcm_ops_t snd_gf1_pcm_playback_ops = { .silence = snd_gf1_pcm_playback_silence, }; -static snd_pcm_ops_t snd_gf1_pcm_capture_ops = { +static struct snd_pcm_ops snd_gf1_pcm_capture_ops = { .open = snd_gf1_pcm_capture_open, .close = snd_gf1_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -832,12 +834,12 @@ static snd_pcm_ops_t snd_gf1_pcm_capture_ops = { .pointer = snd_gf1_pcm_capture_pointer, }; -int snd_gf1_pcm_new(snd_gus_card_t * gus, int pcm_dev, int control_index, snd_pcm_t ** rpcm) +int snd_gf1_pcm_new(struct snd_gus_card * gus, int pcm_dev, int control_index, struct snd_pcm ** rpcm) { - snd_card_t *card; - snd_kcontrol_t *kctl; - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; + struct snd_card *card; + struct snd_kcontrol *kctl; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; int capture, err; if (rpcm) diff --git a/sound/isa/gus/gus_reset.c b/sound/isa/gus/gus_reset.c index 9071096..b263655 100644 --- a/sound/isa/gus/gus_reset.c +++ b/sound/isa/gus/gus_reset.c @@ -25,52 +25,52 @@ #include <sound/core.h> #include <sound/gus.h> -extern void snd_gf1_timers_init(snd_gus_card_t * gus); -extern void snd_gf1_timers_done(snd_gus_card_t * gus); -extern int snd_gf1_synth_init(snd_gus_card_t * gus); -extern void snd_gf1_synth_done(snd_gus_card_t * gus); +extern void snd_gf1_timers_init(struct snd_gus_card * gus); +extern void snd_gf1_timers_done(struct snd_gus_card * gus); +extern int snd_gf1_synth_init(struct snd_gus_card * gus); +extern void snd_gf1_synth_done(struct snd_gus_card * gus); /* * ok.. default interrupt handlers... */ -static void snd_gf1_default_interrupt_handler_midi_out(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_midi_out(struct snd_gus_card * gus) { snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x20); } -static void snd_gf1_default_interrupt_handler_midi_in(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_midi_in(struct snd_gus_card * gus) { snd_gf1_uart_cmd(gus, gus->gf1.uart_cmd &= ~0x80); } -static void snd_gf1_default_interrupt_handler_timer1(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_timer1(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~4); } -static void snd_gf1_default_interrupt_handler_timer2(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_timer2(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, gus->gf1.timer_enabled &= ~8); } -static void snd_gf1_default_interrupt_handler_wave_and_volume(snd_gus_card_t * gus, snd_gus_voice_t * voice) +static void snd_gf1_default_interrupt_handler_wave_and_volume(struct snd_gus_card * gus, struct snd_gus_voice * voice) { snd_gf1_i_ctrl_stop(gus, 0x00); snd_gf1_i_ctrl_stop(gus, 0x0d); } -static void snd_gf1_default_interrupt_handler_dma_write(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_dma_write(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, 0x41, 0x00); } -static void snd_gf1_default_interrupt_handler_dma_read(snd_gus_card_t * gus) +static void snd_gf1_default_interrupt_handler_dma_read(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, 0x49, 0x00); } -void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what) +void snd_gf1_set_default_handlers(struct snd_gus_card * gus, unsigned int what) { if (what & SNDRV_GF1_HANDLER_MIDI_OUT) gus->gf1.interrupt_handler_midi_out = snd_gf1_default_interrupt_handler_midi_out; @@ -81,7 +81,7 @@ void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what) if (what & SNDRV_GF1_HANDLER_TIMER2) gus->gf1.interrupt_handler_timer2 = snd_gf1_default_interrupt_handler_timer2; if (what & SNDRV_GF1_HANDLER_VOICE) { - snd_gus_voice_t *voice; + struct snd_gus_voice *voice; voice = &gus->gf1.voices[what & 0xffff]; voice->handler_wave = @@ -99,7 +99,7 @@ void snd_gf1_set_default_handlers(snd_gus_card_t * gus, unsigned int what) */ -static void snd_gf1_clear_regs(snd_gus_card_t * gus) +static void snd_gf1_clear_regs(struct snd_gus_card * gus) { unsigned long flags; @@ -111,7 +111,7 @@ static void snd_gf1_clear_regs(snd_gus_card_t * gus) spin_unlock_irqrestore(&gus->reg_lock, flags); } -static void snd_gf1_look_regs(snd_gus_card_t * gus) +static void snd_gf1_look_regs(struct snd_gus_card * gus) { unsigned long flags; @@ -127,7 +127,7 @@ static void snd_gf1_look_regs(snd_gus_card_t * gus) * put selected GF1 voices to initial stage... */ -void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice) +void snd_gf1_smart_stop_voice(struct snd_gus_card * gus, unsigned short voice) { unsigned long flags; @@ -141,7 +141,7 @@ void snd_gf1_smart_stop_voice(snd_gus_card_t * gus, unsigned short voice) spin_unlock_irqrestore(&gus->reg_lock, flags); } -void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice) +void snd_gf1_stop_voice(struct snd_gus_card * gus, unsigned short voice) { unsigned long flags; @@ -161,7 +161,7 @@ void snd_gf1_stop_voice(snd_gus_card_t * gus, unsigned short voice) #endif } -static void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, +static void snd_gf1_clear_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max) { unsigned long flags; @@ -203,7 +203,7 @@ static void snd_gf1_clear_voices(snd_gus_card_t * gus, unsigned short v_min, } } -void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned short v_max) +void snd_gf1_stop_voices(struct snd_gus_card * gus, unsigned short v_min, unsigned short v_max) { unsigned long flags; short i, ramp_ok; @@ -232,8 +232,8 @@ void snd_gf1_stop_voices(snd_gus_card_t * gus, unsigned short v_min, unsigned sh snd_gf1_clear_voices(gus, v_min, v_max); } -static void snd_gf1_alloc_voice_use(snd_gus_card_t * gus, - snd_gus_voice_t * pvoice, +static void snd_gf1_alloc_voice_use(struct snd_gus_card * gus, + struct snd_gus_voice * pvoice, int type, int client, int port) { pvoice->use = 1; @@ -255,9 +255,9 @@ static void snd_gf1_alloc_voice_use(snd_gus_card_t * gus, } } -snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client, int port) +struct snd_gus_voice *snd_gf1_alloc_voice(struct snd_gus_card * gus, int type, int client, int port) { - snd_gus_voice_t *pvoice; + struct snd_gus_voice *pvoice; unsigned long flags; int idx; @@ -289,10 +289,10 @@ snd_gus_voice_t *snd_gf1_alloc_voice(snd_gus_card_t * gus, int type, int client, return NULL; } -void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice) +void snd_gf1_free_voice(struct snd_gus_card * gus, struct snd_gus_voice *voice) { unsigned long flags; - void (*private_free)(snd_gus_voice_t *voice); + void (*private_free)(struct snd_gus_voice *voice); void *private_data; if (voice == NULL || !voice->use) @@ -317,7 +317,7 @@ void snd_gf1_free_voice(snd_gus_card_t * gus, snd_gus_voice_t *voice) * call this function only by start of driver */ -int snd_gf1_start(snd_gus_card_t * gus) +int snd_gf1_start(struct snd_gus_card * gus) { unsigned long flags; unsigned int i; @@ -400,7 +400,7 @@ int snd_gf1_start(snd_gus_card_t * gus) * call this function only by shutdown of driver */ -int snd_gf1_stop(snd_gus_card_t * gus) +int snd_gf1_stop(struct snd_gus_card * gus) { snd_gf1_i_write8(gus, SNDRV_GF1_GB_SOUND_BLASTER_CONTROL, 0); /* stop all timers */ snd_gf1_stop_voices(gus, 0, 31); /* stop all voices */ diff --git a/sound/isa/gus/gus_sample.c b/sound/isa/gus/gus_sample.c index 4290e03..9e0c55a 100644 --- a/sound/isa/gus/gus_sample.c +++ b/sound/isa/gus/gus_sample.c @@ -28,9 +28,9 @@ * */ -static void select_instrument(snd_gus_card_t * gus, snd_gus_voice_t * v) +static void select_instrument(struct snd_gus_card * gus, struct snd_gus_voice * v) { - snd_seq_kinstr_t *instr; + struct snd_seq_kinstr *instr; #if 0 printk("select instrument: cluster = %li, std = 0x%x, bank = %i, prg = %i\n", @@ -53,7 +53,8 @@ static void select_instrument(snd_gus_card_t * gus, snd_gus_voice_t * v) * */ -static void event_sample(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_sample(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY); @@ -67,7 +68,8 @@ static void event_sample(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t select_instrument(p->gus, v); } -static void event_cluster(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_cluster(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->gus, v, SAMPLE_STOP_IMMEDIATELY); @@ -75,50 +77,58 @@ static void event_cluster(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_ select_instrument(p->gus, v); } -static void event_start(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_start(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_start) v->sample_ops->sample_start(p->gus, v, ev->data.sample.param.position); } -static void event_stop(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_stop(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->gus, v, ev->data.sample.param.stop_mode); } -static void event_freq(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_freq(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_freq) v->sample_ops->sample_freq(p->gus, v, ev->data.sample.param.frequency); } -static void event_volume(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_volume(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_volume) v->sample_ops->sample_volume(p->gus, v, &ev->data.sample.param.volume); } -static void event_loop(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_loop(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_loop) v->sample_ops->sample_loop(p->gus, v, &ev->data.sample.param.loop); } -static void event_position(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_position(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_pos) v->sample_ops->sample_pos(p->gus, v, ev->data.sample.param.position); } -static void event_private1(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v) +static void event_private1(struct snd_seq_event *ev, struct snd_gus_port *p, + struct snd_gus_voice *v) { if (v->sample_ops && v->sample_ops->sample_private1) v->sample_ops->sample_private1(p->gus, v, (unsigned char *)&ev->data.sample.param.raw8); } -typedef void (gus_sample_event_handler_t)(snd_seq_event_t *ev, snd_gus_port_t *p, snd_gus_voice_t *v); - +typedef void (gus_sample_event_handler_t)(struct snd_seq_event *ev, + struct snd_gus_port *p, + struct snd_gus_voice *v); static gus_sample_event_handler_t *gus_sample_event_handlers[9] = { event_sample, event_cluster, @@ -131,11 +141,11 @@ static gus_sample_event_handler_t *gus_sample_event_handlers[9] = { event_private1 }; -void snd_gus_sample_event(snd_seq_event_t *ev, snd_gus_port_t *p) +void snd_gus_sample_event(struct snd_seq_event *ev, struct snd_gus_port *p) { int idx, voice; - snd_gus_card_t *gus = p->gus; - snd_gus_voice_t *v; + struct snd_gus_card *gus = p->gus; + struct snd_gus_voice *v; unsigned long flags; idx = ev->type - SNDRV_SEQ_EVENT_SAMPLE; diff --git a/sound/isa/gus/gus_simple.c b/sound/isa/gus/gus_simple.c index dfed85b..dcad6ed 100644 --- a/sound/isa/gus/gus_simple.c +++ b/sound/isa/gus/gus_simple.c @@ -29,19 +29,19 @@ * */ -static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice); -static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice); -static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice); - -static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position); -static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_stop_mode_t mode); -static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_frequency_t freq); -static void sample_volume(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_ev_volume_t *volume); -static void sample_loop(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_ev_loop_t *loop); -static void sample_pos(snd_gus_card_t *card, snd_gus_voice_t *voice, snd_seq_position_t position); -static void sample_private1(snd_gus_card_t *card, snd_gus_voice_t *voice, unsigned char *data); - -static snd_gus_sample_ops_t sample_ops = { +static void interrupt_wave(struct snd_gus_card *gus, struct snd_gus_voice *voice); +static void interrupt_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice); +static void interrupt_effect(struct snd_gus_card *gus, struct snd_gus_voice *voice); + +static void sample_start(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position); +static void sample_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode); +static void sample_freq(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq); +static void sample_volume(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume); +static void sample_loop(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop); +static void sample_pos(struct snd_gus_card *card, struct snd_gus_voice *voice, snd_seq_position_t position); +static void sample_private1(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data); + +static struct snd_gus_sample_ops sample_ops = { sample_start, sample_stop, sample_freq, @@ -53,13 +53,13 @@ static snd_gus_sample_ops_t sample_ops = { #if 0 -static void note_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, int wait); -static void note_wait(snd_gus_card_t *gus, snd_gus_voice_t *voice); -static void note_off(snd_gus_card_t *gus, snd_gus_voice_t *voice); -static void note_volume(snd_gus_card_t *card, snd_gus_voice_t *voice); -static void note_pitchbend(snd_gus_card_t *card, snd_gus_voice_t *voice); -static void note_vibrato(snd_gus_card_t *card, snd_gus_voice_t *voice); -static void note_tremolo(snd_gus_card_t *card, snd_gus_voice_t *voice); +static void note_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int wait); +static void note_wait(struct snd_gus_card *gus, struct snd_gus_voice *voice); +static void note_off(struct snd_gus_card *gus, struct snd_gus_voice *voice); +static void note_volume(struct snd_gus_card *card, struct snd_gus_voice *voice); +static void note_pitchbend(struct snd_gus_card *card, struct snd_gus_voice *voice); +static void note_vibrato(struct snd_gus_card *card, struct snd_gus_voice *voice); +static void note_tremolo(struct snd_gus_card *card, struct snd_gus_voice *voice); static struct snd_gus_note_handlers note_commands = { note_stop, @@ -71,7 +71,7 @@ static struct snd_gus_note_handlers note_commands = { note_tremolo }; -static void chn_trigger_down(snd_gus_card_t *card, ultra_channel_t *channel, ultra_instrument_t *instrument, unsigned char note, unsigned char velocity, unsigned char priority ); +static void chn_trigger_down(struct snd_gus_card *card, ultra_channel_t *channel, ultra_instrument_t *instrument, unsigned char note, unsigned char velocity, unsigned char priority ); static void chn_trigger_up( ultra_card_t *card, ultra_note_t *note ); static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned short p1, unsigned short p2 ); @@ -83,14 +83,14 @@ static struct ULTRA_STRU_INSTRUMENT_CHANNEL_COMMANDS channel_commands = { #endif -static void do_volume_envelope(snd_gus_card_t *card, snd_gus_voice_t *voice); -static void do_pan_envelope(snd_gus_card_t *card, snd_gus_voice_t *voice); +static void do_volume_envelope(struct snd_gus_card *card, struct snd_gus_voice *voice); +static void do_pan_envelope(struct snd_gus_card *card, struct snd_gus_voice *voice); /* * */ -static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void interrupt_wave(struct snd_gus_card *gus, struct snd_gus_voice *voice) { spin_lock(&gus->event_lock); snd_gf1_stop_voice(gus, voice->number); @@ -102,7 +102,7 @@ static void interrupt_wave(snd_gus_card_t *gus, snd_gus_voice_t *voice) spin_unlock(&gus->event_lock); } -static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void interrupt_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice) { spin_lock(&gus->event_lock); if (voice->flags & SNDRV_GF1_VFLG_RUNNING) @@ -112,7 +112,7 @@ static void interrupt_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice) spin_unlock(&gus->event_lock); } -static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void interrupt_effect(struct snd_gus_card *gus, struct snd_gus_voice *voice) { spin_lock(&gus->event_lock); if ((voice->flags & (SNDRV_GF1_VFLG_RUNNING|SNDRV_GF1_VFLG_EFFECT_TIMER1)) == @@ -125,7 +125,7 @@ static void interrupt_effect(snd_gus_card_t *gus, snd_gus_voice_t *voice) * */ -static void do_volume_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void do_volume_envelope(struct snd_gus_card *gus, struct snd_gus_voice *voice) { unsigned short next, rate, old_volume; int program_next_ramp; @@ -229,7 +229,7 @@ static void do_volume_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) } } -static void do_pan_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) +static void do_pan_envelope(struct snd_gus_card *gus, struct snd_gus_voice *voice) { unsigned long flags; unsigned char old_pan; @@ -276,7 +276,7 @@ static void do_pan_envelope(snd_gus_card_t *gus, snd_gus_voice_t *voice) #endif } -static void set_enhanced_pan(snd_gus_card_t *gus, snd_gus_voice_t *voice, unsigned short pan) +static void set_enhanced_pan(struct snd_gus_card *gus, struct snd_gus_voice *voice, unsigned short pan) { unsigned long flags; unsigned short vlo, vro; @@ -307,13 +307,13 @@ static void set_enhanced_pan(snd_gus_card_t *gus, snd_gus_voice_t *voice, unsign * */ -static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position) +static void sample_start(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position) { unsigned long flags; unsigned int begin, addr, addr_end, addr_start; int w_16; - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; instr = snd_seq_instr_find(gus->gf1.ilist, &voice->instr, 0, 1); if (instr == NULL) @@ -397,7 +397,7 @@ static void sample_start(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_po snd_seq_instr_free_use(gus->gf1.ilist, instr); } -static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_stop_mode_t mode) +static void sample_stop(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode) { unsigned char control; unsigned long flags; @@ -433,7 +433,7 @@ static void sample_stop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_sto } } -static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_frequency_t freq) +static void sample_freq(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq) { unsigned long flags; @@ -444,7 +444,7 @@ static void sample_freq(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_fre spin_unlock_irqrestore(&gus->reg_lock, flags); } -static void sample_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_volume_t *volume) +static void sample_volume(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume) { if (volume->volume >= 0) { volume->volume &= 0x3fff; @@ -471,13 +471,13 @@ static void sample_volume(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_e } } -static void sample_loop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_loop_t *loop) +static void sample_loop(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop) { unsigned long flags; int w_16 = voice->control & 0x04; unsigned int begin, addr_start, addr_end; - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; #if 0 printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end); @@ -500,13 +500,13 @@ static void sample_loop(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_ev_ snd_seq_instr_free_use(gus->gf1.ilist, instr); } -static void sample_pos(snd_gus_card_t *gus, snd_gus_voice_t *voice, snd_seq_position_t position) +static void sample_pos(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position) { unsigned long flags; int w_16 = voice->control & 0x04; unsigned int begin, addr; - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; #if 0 printk("voice_loop: start = 0x%x, end = 0x%x\n", loop->start, loop->end); @@ -537,7 +537,7 @@ static unsigned char get_effects_mask( ultra_card_t *card, int value ) #endif -static void sample_private1(snd_gus_card_t *card, snd_gus_voice_t *voice, unsigned char *data) +static void sample_private1(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data) { #if 0 unsigned long flags; @@ -624,7 +624,7 @@ static void chn_control( ultra_card_t *card, ultra_channel_t *channel, unsigned #endif -void snd_gf1_simple_init(snd_gus_voice_t *voice) +void snd_gf1_simple_init(struct snd_gus_voice *voice) { voice->handler_wave = interrupt_wave; voice->handler_volume = interrupt_volume; diff --git a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c index f51c386..9c7d698 100644 --- a/sound/isa/gus/gus_synth.c +++ b/sound/isa/gus/gus_synth.c @@ -34,10 +34,10 @@ MODULE_LICENSE("GPL"); * */ -static void snd_gus_synth_free_voices(snd_gus_card_t * gus, int client, int port) +static void snd_gus_synth_free_voices(struct snd_gus_card * gus, int client, int port) { int idx; - snd_gus_voice_t * voice; + struct snd_gus_voice * voice; for (idx = 0; idx < 32; idx++) { voice = &gus->gf1.voices[idx]; @@ -46,11 +46,11 @@ static void snd_gus_synth_free_voices(snd_gus_card_t * gus, int client, int port } } -static int snd_gus_synth_use(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_gus_synth_use(void *private_data, struct snd_seq_port_subscribe *info) { - snd_gus_port_t * port = (snd_gus_port_t *)private_data; - snd_gus_card_t * gus = port->gus; - snd_gus_voice_t * voice; + struct snd_gus_port * port = private_data; + struct snd_gus_card * gus = port->gus; + struct snd_gus_voice * voice; unsigned int idx; if (info->voices > 32) @@ -74,10 +74,10 @@ static int snd_gus_synth_use(void *private_data, snd_seq_port_subscribe_t *info) return 0; } -static int snd_gus_synth_unuse(void *private_data, snd_seq_port_subscribe_t *info) +static int snd_gus_synth_unuse(void *private_data, struct snd_seq_port_subscribe *info) { - snd_gus_port_t * port = (snd_gus_port_t *)private_data; - snd_gus_card_t * gus = port->gus; + struct snd_gus_port * port = private_data; + struct snd_gus_card * gus = port->gus; down(&gus->register_mutex); snd_gus_synth_free_voices(gus, info->sender.client, info->sender.port); @@ -90,19 +90,19 @@ static int snd_gus_synth_unuse(void *private_data, snd_seq_port_subscribe_t *inf * */ -static void snd_gus_synth_free_private_instruments(snd_gus_port_t *p, int client) +static void snd_gus_synth_free_private_instruments(struct snd_gus_port *p, int client) { - snd_seq_instr_header_t ifree; + struct snd_seq_instr_header ifree; memset(&ifree, 0, sizeof(ifree)); ifree.cmd = SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE; snd_seq_instr_list_free_cond(p->gus->gf1.ilist, &ifree, client, 0); } -static int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct, +static int snd_gus_synth_event_input(struct snd_seq_event *ev, int direct, void *private_data, int atomic, int hop) { - snd_gus_port_t * p = (snd_gus_port_t *) private_data; + struct snd_gus_port * p = private_data; snd_assert(p != NULL, return -EINVAL); if (ev->type >= SNDRV_SEQ_EVENT_SAMPLE && @@ -131,12 +131,12 @@ static int snd_gus_synth_event_input(snd_seq_event_t *ev, int direct, } static void snd_gus_synth_instr_notify(void *private_data, - snd_seq_kinstr_t *instr, + struct snd_seq_kinstr *instr, int what) { unsigned int idx; - snd_gus_card_t *gus = private_data; - snd_gus_voice_t *pvoice; + struct snd_gus_card *gus = private_data; + struct snd_gus_voice *pvoice; unsigned long flags; spin_lock_irqsave(&gus->event_lock, flags); @@ -160,16 +160,16 @@ static void snd_gus_synth_instr_notify(void *private_data, static void snd_gus_synth_free_port(void *private_data) { - snd_gus_port_t * p = (snd_gus_port_t *)private_data; + struct snd_gus_port * p = private_data; if (p) snd_midi_channel_free_set(p->chset); } -static int snd_gus_synth_create_port(snd_gus_card_t * gus, int idx) +static int snd_gus_synth_create_port(struct snd_gus_card * gus, int idx) { - snd_gus_port_t * p; - snd_seq_port_callback_t callbacks; + struct snd_gus_port * p; + struct snd_seq_port_callback callbacks; char name[32]; int result; @@ -210,18 +210,18 @@ static int snd_gus_synth_create_port(snd_gus_card_t * gus, int idx) * */ -static int snd_gus_synth_new_device(snd_seq_device_t *dev) +static int snd_gus_synth_new_device(struct snd_seq_device *dev) { - snd_gus_card_t *gus; + struct snd_gus_card *gus; int client, i; - snd_seq_client_callback_t callbacks; - snd_seq_client_info_t *cinfo; - snd_seq_port_subscribe_t sub; - snd_iwffff_ops_t *iwops; - snd_gf1_ops_t *gf1ops; - snd_simple_ops_t *simpleops; - - gus = *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); + struct snd_seq_client_callback callbacks; + struct snd_seq_client_info *cinfo; + struct snd_seq_port_subscribe sub; + struct snd_iwffff_ops *iwops; + struct snd_gf1_ops *gf1ops; + struct snd_simple_ops *simpleops; + + gus = *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (gus == NULL) return -EINVAL; @@ -293,11 +293,11 @@ static int snd_gus_synth_new_device(snd_seq_device_t *dev) return 0; } -static int snd_gus_synth_delete_device(snd_seq_device_t *dev) +static int snd_gus_synth_delete_device(struct snd_seq_device *dev) { - snd_gus_card_t *gus; + struct snd_gus_card *gus; - gus = *(snd_gus_card_t**)SNDRV_SEQ_DEVICE_ARGPTR(dev); + gus = *(struct snd_gus_card **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (gus == NULL) return -EINVAL; @@ -312,13 +312,13 @@ static int snd_gus_synth_delete_device(snd_seq_device_t *dev) static int __init alsa_gus_synth_init(void) { - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_gus_synth_new_device, snd_gus_synth_delete_device }; return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_GUS, &ops, - sizeof(snd_gus_card_t*)); + sizeof(struct snd_gus_card *)); } static void __exit alsa_gus_synth_exit(void) diff --git a/sound/isa/gus/gus_timer.c b/sound/isa/gus/gus_timer.c index 9876603..a43b662 100644 --- a/sound/isa/gus/gus_timer.c +++ b/sound/isa/gus/gus_timer.c @@ -30,12 +30,12 @@ * Timer 1 - 80us */ -static int snd_gf1_timer1_start(snd_timer_t * timer) +static int snd_gf1_timer1_start(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; unsigned int ticks; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = snd_timer_chip(timer); spin_lock_irqsave(&gus->reg_lock, flags); @@ -48,11 +48,11 @@ static int snd_gf1_timer1_start(snd_timer_t * timer) return 0; } -static int snd_gf1_timer1_stop(snd_timer_t * timer) +static int snd_gf1_timer1_stop(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = snd_timer_chip(timer); spin_lock_irqsave(&gus->reg_lock, flags); @@ -66,12 +66,12 @@ static int snd_gf1_timer1_stop(snd_timer_t * timer) * Timer 2 - 320us */ -static int snd_gf1_timer2_start(snd_timer_t * timer) +static int snd_gf1_timer2_start(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; unsigned int ticks; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = snd_timer_chip(timer); spin_lock_irqsave(&gus->reg_lock, flags); @@ -84,11 +84,11 @@ static int snd_gf1_timer2_start(snd_timer_t * timer) return 0; } -static int snd_gf1_timer2_stop(snd_timer_t * timer) +static int snd_gf1_timer2_stop(struct snd_timer * timer) { unsigned long flags; unsigned char tmp; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = snd_timer_chip(timer); spin_lock_irqsave(&gus->reg_lock, flags); @@ -102,18 +102,18 @@ static int snd_gf1_timer2_stop(snd_timer_t * timer) */ -static void snd_gf1_interrupt_timer1(snd_gus_card_t * gus) +static void snd_gf1_interrupt_timer1(struct snd_gus_card * gus) { - snd_timer_t *timer = gus->gf1.timer1; + struct snd_timer *timer = gus->gf1.timer1; if (timer == NULL) return; snd_timer_interrupt(timer, timer->sticks); } -static void snd_gf1_interrupt_timer2(snd_gus_card_t * gus) +static void snd_gf1_interrupt_timer2(struct snd_gus_card * gus) { - snd_timer_t *timer = gus->gf1.timer2; + struct snd_timer *timer = gus->gf1.timer2; if (timer == NULL) return; @@ -124,7 +124,7 @@ static void snd_gf1_interrupt_timer2(snd_gus_card_t * gus) */ -static struct _snd_timer_hardware snd_gf1_timer1 = +static struct snd_timer_hardware snd_gf1_timer1 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 80000, @@ -133,7 +133,7 @@ static struct _snd_timer_hardware snd_gf1_timer1 = .stop = snd_gf1_timer1_stop, }; -static struct _snd_timer_hardware snd_gf1_timer2 = +static struct snd_timer_hardware snd_gf1_timer2 = { .flags = SNDRV_TIMER_HW_STOP, .resolution = 320000, @@ -142,22 +142,22 @@ static struct _snd_timer_hardware snd_gf1_timer2 = .stop = snd_gf1_timer2_stop, }; -static void snd_gf1_timer1_free(snd_timer_t *timer) +static void snd_gf1_timer1_free(struct snd_timer *timer) { - snd_gus_card_t *gus = timer->private_data; + struct snd_gus_card *gus = timer->private_data; gus->gf1.timer1 = NULL; } -static void snd_gf1_timer2_free(snd_timer_t *timer) +static void snd_gf1_timer2_free(struct snd_timer *timer) { - snd_gus_card_t *gus = timer->private_data; + struct snd_gus_card *gus = timer->private_data; gus->gf1.timer2 = NULL; } -void snd_gf1_timers_init(snd_gus_card_t * gus) +void snd_gf1_timers_init(struct snd_gus_card * gus) { - snd_timer_t *timer; - snd_timer_id_t tid; + struct snd_timer *timer; + struct snd_timer_id tid; if (gus->gf1.timer1 != NULL || gus->gf1.timer2 != NULL) return; @@ -190,7 +190,7 @@ void snd_gf1_timers_init(snd_gus_card_t * gus) gus->gf1.timer2 = timer; } -void snd_gf1_timers_done(snd_gus_card_t * gus) +void snd_gf1_timers_done(struct snd_gus_card * gus) { snd_gf1_set_default_handlers(gus, SNDRV_GF1_HANDLER_TIMER1 | SNDRV_GF1_HANDLER_TIMER2); if (gus->gf1.timer1) { diff --git a/sound/isa/gus/gus_uart.c b/sound/isa/gus/gus_uart.c index fbc95e9..654290a 100644 --- a/sound/isa/gus/gus_uart.c +++ b/sound/isa/gus/gus_uart.c @@ -26,7 +26,7 @@ #include <sound/core.h> #include <sound/gus.h> -static void snd_gf1_interrupt_midi_in(snd_gus_card_t * gus) +static void snd_gf1_interrupt_midi_in(struct snd_gus_card * gus) { int count; unsigned char stat, data, byte; @@ -61,7 +61,7 @@ static void snd_gf1_interrupt_midi_in(snd_gus_card_t * gus) } } -static void snd_gf1_interrupt_midi_out(snd_gus_card_t * gus) +static void snd_gf1_interrupt_midi_out(struct snd_gus_card * gus) { char byte; unsigned long flags; @@ -81,7 +81,7 @@ static void snd_gf1_interrupt_midi_out(snd_gus_card_t * gus) spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); } -static void snd_gf1_uart_reset(snd_gus_card_t * gus, int close) +static void snd_gf1_uart_reset(struct snd_gus_card * gus, int close) { snd_gf1_uart_cmd(gus, 0x03); /* reset */ if (!close && gus->uart_enable) { @@ -90,10 +90,10 @@ static void snd_gf1_uart_reset(snd_gus_card_t * gus, int close) } } -static int snd_gf1_uart_output_open(snd_rawmidi_substream_t * substream) +static int snd_gf1_uart_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = substream->rmidi->private_data; spin_lock_irqsave(&gus->uart_cmd_lock, flags); @@ -109,10 +109,10 @@ static int snd_gf1_uart_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_gf1_uart_input_open(snd_rawmidi_substream_t * substream) +static int snd_gf1_uart_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; int i; gus = substream->rmidi->private_data; @@ -136,10 +136,10 @@ static int snd_gf1_uart_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_gf1_uart_output_close(snd_rawmidi_substream_t * substream) +static int snd_gf1_uart_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = substream->rmidi->private_data; spin_lock_irqsave(&gus->uart_cmd_lock, flags); @@ -151,10 +151,10 @@ static int snd_gf1_uart_output_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_gf1_uart_input_close(snd_rawmidi_substream_t * substream) +static int snd_gf1_uart_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; gus = substream->rmidi->private_data; spin_lock_irqsave(&gus->uart_cmd_lock, flags); @@ -166,9 +166,9 @@ static int snd_gf1_uart_input_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_gf1_uart_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_gf1_uart_input_trigger(struct snd_rawmidi_substream *substream, int up) { - snd_gus_card_t *gus; + struct snd_gus_card *gus; unsigned long flags; gus = substream->rmidi->private_data; @@ -184,10 +184,10 @@ static void snd_gf1_uart_input_trigger(snd_rawmidi_substream_t * substream, int spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); } -static void snd_gf1_uart_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_gf1_uart_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - snd_gus_card_t *gus; + struct snd_gus_card *gus; char byte; int timeout; @@ -222,23 +222,23 @@ static void snd_gf1_uart_output_trigger(snd_rawmidi_substream_t * substream, int spin_unlock_irqrestore(&gus->uart_cmd_lock, flags); } -static snd_rawmidi_ops_t snd_gf1_uart_output = +static struct snd_rawmidi_ops snd_gf1_uart_output = { .open = snd_gf1_uart_output_open, .close = snd_gf1_uart_output_close, .trigger = snd_gf1_uart_output_trigger, }; -static snd_rawmidi_ops_t snd_gf1_uart_input = +static struct snd_rawmidi_ops snd_gf1_uart_input = { .open = snd_gf1_uart_input_open, .close = snd_gf1_uart_input_close, .trigger = snd_gf1_uart_input_trigger, }; -int snd_gf1_rawmidi_new(snd_gus_card_t * gus, int device, snd_rawmidi_t ** rrawmidi) +int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi ** rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) diff --git a/sound/isa/gus/gus_volume.c b/sound/isa/gus/gus_volume.c index b3382fe..dbbc0a6 100644 --- a/sound/isa/gus/gus_volume.c +++ b/sound/isa/gus/gus_volume.c @@ -72,7 +72,7 @@ unsigned int snd_gf1_gvol_to_lvol_raw(unsigned short gf1_vol) return rvol | (m >> (8 - e)); } -unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus, +unsigned int snd_gf1_calc_ramp_rate(struct snd_gus_card * gus, unsigned short start, unsigned short end, unsigned int us) @@ -112,7 +112,7 @@ unsigned int snd_gf1_calc_ramp_rate(snd_gus_card_t * gus, #endif /* 0 */ -unsigned short snd_gf1_translate_freq(snd_gus_card_t * gus, unsigned int freq16) +unsigned short snd_gf1_translate_freq(struct snd_gus_card * gus, unsigned int freq16) { freq16 >>= 3; if (freq16 < 50) diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 39cef38..6db484f 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -70,11 +70,11 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); -static snd_card_t *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "gusclassic: " -static int __init snd_gusclassic_detect(snd_gus_card_t * gus) +static int __init snd_gusclassic_detect(struct snd_gus_card * gus) { unsigned char d; @@ -93,7 +93,7 @@ static int __init snd_gusclassic_detect(snd_gus_card_t * gus) return 0; } -static void __init snd_gusclassic_init(int dev, snd_gus_card_t * gus) +static void __init snd_gusclassic_init(int dev, struct snd_gus_card * gus) { gus->equal_irq = 0; gus->codec_flag = 0; @@ -106,9 +106,9 @@ static int __init snd_gusclassic_probe(int dev) static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2; - snd_card_t *card; + struct snd_card *card; struct snd_gusclassic *guscard; - snd_gus_card_t *gus = NULL; + struct snd_gus_card *gus = NULL; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index d2e7cb1..9be59d5 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -85,14 +85,14 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); -static snd_card_t *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "gusextreme: " static int __init snd_gusextreme_detect(int dev, - snd_card_t * card, - snd_gus_card_t * gus, - es1688_t *es1688) + struct snd_card *card, + struct snd_gus_card * gus, + struct snd_es1688 *es1688) { unsigned long flags; unsigned char d; @@ -139,15 +139,15 @@ static int __init snd_gusextreme_detect(int dev, return 0; } -static void __init snd_gusextreme_init(int dev, snd_gus_card_t * gus) +static void __init snd_gusextreme_init(int dev, struct snd_gus_card * gus) { gus->joystick_dac = joystick_dac[dev]; } -static int __init snd_gusextreme_mixer(es1688_t *chip) +static int __init snd_gusextreme_mixer(struct snd_es1688 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; int err; memset(&id1, 0, sizeof(id1)); @@ -173,11 +173,11 @@ static int __init snd_gusextreme_probe(int dev) static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1}; int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma; - snd_card_t *card; + struct snd_card *card; struct snd_gusextreme *acard; - snd_gus_card_t *gus; - es1688_t *es1688; - opl3_t *opl3; + struct snd_gus_card *gus; + struct snd_es1688 *es1688; + struct snd_opl3 *opl3; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); @@ -345,7 +345,7 @@ static int __init alsa_card_gusextreme_init(void) static void __exit alsa_card_gusextreme_exit(void) { int idx; - snd_card_t *card; + struct snd_card *card; struct snd_gusextreme *acard; for (idx = 0; idx < SNDRV_CARDS; idx++) { diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 0bb44b5..63311cd 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -73,18 +73,18 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); struct snd_gusmax { int irq; - snd_card_t *card; - snd_gus_card_t *gus; - cs4231_t *cs4231; + struct snd_card *card; + struct snd_gus_card *gus; + struct snd_cs4231 *cs4231; unsigned short gus_status_reg; unsigned short pcm_status_reg; }; -static snd_card_t *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "gusmax: " -static int __init snd_gusmax_detect(snd_gus_card_t * gus) +static int __init snd_gusmax_detect(struct snd_gus_card * gus) { unsigned char d; @@ -126,7 +126,7 @@ static irqreturn_t snd_gusmax_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_RETVAL(handled); } -static void __init snd_gusmax_init(int dev, snd_card_t * card, snd_gus_card_t * gus) +static void __init snd_gusmax_init(int dev, struct snd_card *card, struct snd_gus_card * gus) { gus->equal_irq = 1; gus->codec_flag = 1; @@ -144,10 +144,10 @@ static void __init snd_gusmax_init(int dev, snd_card_t * card, snd_gus_card_t * #define CS4231_PRIVATE( left, right, shift, mute ) \ ((left << 24)|(right << 16)|(shift<<8)|mute) -static int __init snd_gusmax_mixer(cs4231_t *chip) +static int __init snd_gusmax_mixer(struct snd_cs4231 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; int err; memset(&id1, 0, sizeof(id1)); @@ -193,7 +193,7 @@ static int __init snd_gusmax_mixer(cs4231_t *chip) return 0; } -static void snd_gusmax_free(snd_card_t *card) +static void snd_gusmax_free(struct snd_card *card) { struct snd_gusmax *maxcard = (struct snd_gusmax *)card->private_data; @@ -208,9 +208,9 @@ static int __init snd_gusmax_probe(int dev) static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2, err; - snd_card_t *card; - snd_gus_card_t *gus = NULL; - cs4231_t *cs4231; + struct snd_card *card; + struct snd_gus_card *gus = NULL; + struct snd_cs4231 *cs4231; struct snd_gusmax *maxcard; card = snd_card_new(index[dev], id[dev], THIS_MODULE, diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index f703a9f..f2e9c50 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -112,9 +112,9 @@ MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); struct snd_interwave { int irq; - snd_card_t *card; - snd_gus_card_t *gus; - cs4231_t *cs4231; + struct snd_card *card; + struct snd_gus_card *gus; + struct snd_cs4231 *cs4231; #ifdef SNDRV_STB struct resource *i2c_res; #endif @@ -128,7 +128,7 @@ struct snd_interwave { #endif }; -static snd_card_t *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -160,7 +160,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_interwave_pnpids); #ifdef SNDRV_STB -static void snd_interwave_i2c_setlines(snd_i2c_bus_t *bus, int ctrl, int data) +static void snd_interwave_i2c_setlines(struct snd_i2c_bus *bus, int ctrl, int data) { unsigned long port = bus->private_value; @@ -171,7 +171,7 @@ static void snd_interwave_i2c_setlines(snd_i2c_bus_t *bus, int ctrl, int data) udelay(10); } -static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus) +static int snd_interwave_i2c_getclockline(struct snd_i2c_bus *bus) { unsigned long port = bus->private_value; unsigned char res; @@ -183,7 +183,7 @@ static int snd_interwave_i2c_getclockline(snd_i2c_bus_t *bus) return res; } -static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack) +static int snd_interwave_i2c_getdataline(struct snd_i2c_bus *bus, int ack) { unsigned long port = bus->private_value; unsigned char res; @@ -197,19 +197,19 @@ static int snd_interwave_i2c_getdataline(snd_i2c_bus_t *bus, int ack) return res; } -static snd_i2c_bit_ops_t snd_interwave_i2c_bit_ops = { +static struct snd_i2c_bit_ops snd_interwave_i2c_bit_ops = { .setlines = snd_interwave_i2c_setlines, .getclock = snd_interwave_i2c_getclockline, .getdata = snd_interwave_i2c_getdataline, }; static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard, - snd_gus_card_t * gus, int dev, - snd_i2c_bus_t **rbus) + struct snd_gus_card * gus, int dev, + struct snd_i2c_bus **rbus) { unsigned long port; - snd_i2c_bus_t *bus; - snd_card_t *card = iwcard->card; + struct snd_i2c_bus *bus; + struct snd_card *card = iwcard->card; char name[32]; int err; @@ -246,10 +246,10 @@ static int __devinit snd_interwave_detect_stb(struct snd_interwave *iwcard, #endif static int __devinit snd_interwave_detect(struct snd_interwave *iwcard, - snd_gus_card_t * gus, + struct snd_gus_card * gus, int dev #ifdef SNDRV_STB - , snd_i2c_bus_t **rbus + , struct snd_i2c_bus **rbus #endif ) { @@ -314,7 +314,7 @@ static irqreturn_t snd_interwave_interrupt(int irq, void *dev_id, struct pt_regs return IRQ_RETVAL(handled); } -static void __devinit snd_interwave_reset(snd_gus_card_t * gus) +static void __devinit snd_interwave_reset(struct snd_gus_card * gus) { snd_gf1_write8(gus, SNDRV_GF1_GB_RESET, 0x00); udelay(160); @@ -322,7 +322,7 @@ static void __devinit snd_interwave_reset(snd_gus_card_t * gus) udelay(160); } -static void __devinit snd_interwave_bank_sizes(snd_gus_card_t * gus, int *sizes) +static void __devinit snd_interwave_bank_sizes(struct snd_gus_card * gus, int *sizes) { unsigned int idx; unsigned int local; @@ -371,7 +371,7 @@ struct rom_hdr { /* 511 */ unsigned char csum; }; -static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus) +static void __devinit snd_interwave_detect_memory(struct snd_gus_card * gus) { static unsigned int lmc[13] = { @@ -470,7 +470,7 @@ static void __devinit snd_interwave_detect_memory(snd_gus_card_t * gus) snd_interwave_reset(gus); } -static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus) +static void __devinit snd_interwave_init(int dev, struct snd_gus_card * gus) { unsigned long flags; @@ -492,17 +492,17 @@ static void __devinit snd_interwave_init(int dev, snd_gus_card_t * gus) } -static snd_kcontrol_new_t snd_interwave_controls[] = { +static struct snd_kcontrol_new snd_interwave_controls[] = { CS4231_DOUBLE("Master Playback Switch", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("Master Playback Volume", 0, CS4231_LINE_LEFT_OUTPUT, CS4231_LINE_RIGHT_OUTPUT, 0, 0, 31, 1), CS4231_DOUBLE("Mic Playback Switch", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 7, 7, 1, 1), CS4231_DOUBLE("Mic Playback Volume", 0, CS4231_LEFT_MIC_INPUT, CS4231_RIGHT_MIC_INPUT, 0, 0, 31, 1) }; -static int __devinit snd_interwave_mixer(cs4231_t *chip) +static int __devinit snd_interwave_mixer(struct snd_cs4231 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; unsigned int idx; int err; @@ -631,7 +631,7 @@ static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard, } #endif /* CONFIG_PNP */ -static void snd_interwave_free(snd_card_t *card) +static void snd_interwave_free(struct snd_card *card) { struct snd_interwave *iwcard = (struct snd_interwave *)card->private_data; @@ -650,14 +650,14 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; int xirq, xdma1, xdma2; - snd_card_t *card; + struct snd_card *card; struct snd_interwave *iwcard; - cs4231_t *cs4231; - snd_gus_card_t *gus; + struct snd_cs4231 *cs4231; + struct snd_gus_card *gus; #ifdef SNDRV_STB - snd_i2c_bus_t *i2c_bus; + struct snd_i2c_bus *i2c_bus; #endif - snd_pcm_t *pcm; + struct snd_pcm *pcm; char *str; int err; @@ -761,7 +761,7 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, #ifdef SNDRV_STB { - snd_ctl_elem_id_t id1, id2; + struct snd_ctl_elem_id id1, id2; memset(&id1, 0, sizeof(id1)); memset(&id2, 0, sizeof(id2)); id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; @@ -863,7 +863,7 @@ static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *card, static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); -- cgit v1.1 From 346c7a689542285aef9b899eda7693d4b912d60d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:37:56 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA Opti9xx Modules: Opti9xx drivers Remove xxx_t typedefs from the ISA Opti 9xx drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/opti9xx/opti92x-ad1848.c | 224 ++++++++++++++++++------------------- 1 file changed, 110 insertions(+), 114 deletions(-) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 1be3299..fddf7b9 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -120,8 +120,6 @@ MODULE_PARM_DESC(dma2, "2nd dma # for opti9xx driver."); #define OPTi9XX_MC_REG(n) n -typedef struct _snd_opti9xx opti9xx_t; - #ifdef OPTi93X #define OPTi93X_INDEX 0x00 @@ -193,16 +191,14 @@ typedef struct _snd_opti9xx opti9xx_t; #define OPTi93X_IRQ_CAPTURE 0x08 -typedef struct _snd_opti93x opti93x_t; - -struct _snd_opti93x { +struct snd_opti93x { unsigned long port; struct resource *res_port; int irq; int dma1; int dma2; - opti9xx_t *chip; + struct snd_opti9xx *chip; unsigned short hardware; unsigned char image[32]; @@ -212,10 +208,10 @@ struct _snd_opti93x { spinlock_t lock; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; unsigned int p_dma_size; unsigned int c_dma_size; }; @@ -227,7 +223,7 @@ struct _snd_opti93x { #endif /* OPTi93X */ -struct _snd_opti9xx { +struct snd_opti9xx { unsigned short hardware; unsigned char password; char name[7]; @@ -261,7 +257,7 @@ struct _snd_opti9xx { }; static int snd_opti9xx_first_hit = 1; -static snd_card_t *snd_opti9xx_legacy = SNDRV_DEFAULT_PTR1; +static struct snd_card *snd_opti9xx_legacy = SNDRV_DEFAULT_PTR1; #ifdef CONFIG_PNP @@ -308,7 +304,7 @@ static long snd_legacy_find_free_ioport(long *port_table, long size) return -1; } -static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware) +static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) { static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; @@ -363,7 +359,7 @@ static int __devinit snd_opti9xx_init(opti9xx_t *chip, unsigned short hardware) return 0; } -static unsigned char snd_opti9xx_read(opti9xx_t *chip, +static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip, unsigned char reg) { unsigned long flags; @@ -406,7 +402,7 @@ static unsigned char snd_opti9xx_read(opti9xx_t *chip, return retval; } -static void snd_opti9xx_write(opti9xx_t *chip, unsigned char reg, +static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, unsigned char value) { unsigned long flags; @@ -453,7 +449,7 @@ static void snd_opti9xx_write(opti9xx_t *chip, unsigned char reg, (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) -static int __devinit snd_opti9xx_configure(opti9xx_t *chip) +static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) { unsigned char wss_base_bits; unsigned char irq_bits; @@ -684,7 +680,7 @@ static unsigned char snd_opti93x_default_image[32] = }; -static int snd_opti93x_busy_wait(opti93x_t *chip) +static int snd_opti93x_busy_wait(struct snd_opti93x *chip) { int timeout; @@ -696,14 +692,14 @@ static int snd_opti93x_busy_wait(opti93x_t *chip) return -EBUSY; } -static unsigned char snd_opti93x_in(opti93x_t *chip, unsigned char reg) +static unsigned char snd_opti93x_in(struct snd_opti93x *chip, unsigned char reg) { snd_opti93x_busy_wait(chip); outb(chip->mce_bit | (reg & 0x1f), OPTi93X_PORT(chip, INDEX)); return inb(OPTi93X_PORT(chip, DATA)); } -static void snd_opti93x_out(opti93x_t *chip, unsigned char reg, +static void snd_opti93x_out(struct snd_opti93x *chip, unsigned char reg, unsigned char value) { snd_opti93x_busy_wait(chip); @@ -711,13 +707,13 @@ static void snd_opti93x_out(opti93x_t *chip, unsigned char reg, outb(value, OPTi93X_PORT(chip, DATA)); } -static void snd_opti93x_out_image(opti93x_t *chip, unsigned char reg, +static void snd_opti93x_out_image(struct snd_opti93x *chip, unsigned char reg, unsigned char value) { snd_opti93x_out(chip, reg, chip->image[reg] = value); } -static void snd_opti93x_out_mask(opti93x_t *chip, unsigned char reg, +static void snd_opti93x_out_mask(struct snd_opti93x *chip, unsigned char reg, unsigned char mask, unsigned char value) { snd_opti93x_out_image(chip, reg, @@ -725,7 +721,7 @@ static void snd_opti93x_out_mask(opti93x_t *chip, unsigned char reg, } -static void snd_opti93x_mce_up(opti93x_t *chip) +static void snd_opti93x_mce_up(struct snd_opti93x *chip) { snd_opti93x_busy_wait(chip); @@ -734,7 +730,7 @@ static void snd_opti93x_mce_up(opti93x_t *chip) outb(chip->mce_bit, OPTi93X_PORT(chip, INDEX)); } -static void snd_opti93x_mce_down(opti93x_t *chip) +static void snd_opti93x_mce_down(struct snd_opti93x *chip) { snd_opti93x_busy_wait(chip); @@ -746,7 +742,7 @@ static void snd_opti93x_mce_down(opti93x_t *chip) #define snd_opti93x_mute_reg(chip, reg, mute) \ snd_opti93x_out(chip, reg, mute ? 0x80 : chip->image[reg]); -static void snd_opti93x_mute(opti93x_t *chip, int mute) +static void snd_opti93x_mute(struct snd_opti93x *chip, int mute) { mute = mute ? 1 : 0; if (chip->mute == mute) @@ -798,7 +794,7 @@ static unsigned int rates[] = { 5512, 6615, 8000, 9600, 11025, 16000, 44100, 48000 }; #define RATES ARRAY_SIZE(rates) -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = RATES, .list = rates, .mask = 0, @@ -820,7 +816,7 @@ static unsigned char snd_opti93x_get_freq(unsigned int rate) return bits[RATES-1]; } -static unsigned char snd_opti93x_get_format(opti93x_t *chip, +static unsigned char snd_opti93x_get_format(struct snd_opti93x *chip, unsigned int format, int channels) { unsigned char retval = OPTi93X_LINEAR_8; @@ -845,7 +841,7 @@ static unsigned char snd_opti93x_get_format(opti93x_t *chip, } -static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt) +static void snd_opti93x_playback_format(struct snd_opti93x *chip, unsigned char fmt) { unsigned char mask; @@ -859,7 +855,7 @@ static void snd_opti93x_playback_format(opti93x_t *chip, unsigned char fmt) snd_opti93x_mute(chip, 0); } -static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt) +static void snd_opti93x_capture_format(struct snd_opti93x *chip, unsigned char fmt) { snd_opti93x_mute(chip, 1); @@ -875,7 +871,7 @@ static void snd_opti93x_capture_format(opti93x_t *chip, unsigned char fmt) } -static int snd_opti93x_open(opti93x_t *chip, unsigned int mode) +static int snd_opti93x_open(struct snd_opti93x *chip, unsigned int mode) { unsigned long flags; @@ -899,7 +895,7 @@ static int snd_opti93x_open(opti93x_t *chip, unsigned int mode) return 0; } -static void snd_opti93x_close(opti93x_t *chip, unsigned int mode) +static void snd_opti93x_close(struct snd_opti93x *chip, unsigned int mode) { unsigned long flags; @@ -926,10 +922,10 @@ static void snd_opti93x_close(opti93x_t *chip, unsigned int mode) spin_unlock_irqrestore(&chip->lock, flags); } -static int snd_opti93x_trigger(snd_pcm_substream_t *substream, +static int snd_opti93x_trigger(struct snd_pcm_substream *substream, unsigned char what, int cmd) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -937,7 +933,7 @@ static int snd_opti93x_trigger(snd_pcm_substream_t *substream, { unsigned int what = 0; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == chip->playback_substream) { @@ -964,36 +960,36 @@ static int snd_opti93x_trigger(snd_pcm_substream_t *substream, return 0; } -static int snd_opti93x_playback_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_opti93x_playback_trigger(struct snd_pcm_substream *substream, int cmd) { return snd_opti93x_trigger(substream, OPTi93X_PLAYBACK_ENABLE, cmd); } -static int snd_opti93x_capture_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_opti93x_capture_trigger(struct snd_pcm_substream *substream, int cmd) { return snd_opti93x_trigger(substream, OPTi93X_CAPTURE_ENABLE, cmd); } -static int snd_opti93x_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_opti93x_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_opti93x_hw_free(snd_pcm_substream_t * substream) +static int snd_opti93x_hw_free(struct snd_pcm_substream *substream) { snd_pcm_lib_free_pages(substream); return 0; } -static int snd_opti93x_playback_prepare(snd_pcm_substream_t * substream) +static int snd_opti93x_playback_prepare(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned char format; unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -1023,10 +1019,10 @@ static int snd_opti93x_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream) +static int snd_opti93x_capture_prepare(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; unsigned char format; unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -1055,9 +1051,9 @@ static int snd_opti93x_capture_prepare(snd_pcm_substream_t *substream) return 0; } -static snd_pcm_uframes_t snd_opti93x_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_opti93x_playback_pointer(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_PLAYBACK_ENABLE)) @@ -1067,9 +1063,9 @@ static snd_pcm_uframes_t snd_opti93x_playback_pointer(snd_pcm_substream_t *subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_opti93x_capture_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_opti93x_capture_pointer(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->image[OPTi93X_IFACE_CONF] & OPTi93X_CAPTURE_ENABLE)) @@ -1080,7 +1076,7 @@ static snd_pcm_uframes_t snd_opti93x_capture_pointer(snd_pcm_substream_t *substr } -static void snd_opti93x_overrange(opti93x_t *chip) +static void snd_opti93x_overrange(struct snd_opti93x *chip) { unsigned long flags; @@ -1094,7 +1090,7 @@ static void snd_opti93x_overrange(opti93x_t *chip) static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - opti93x_t *codec = dev_id; + struct snd_opti93x *codec = dev_id; unsigned char status; status = snd_opti9xx_read(codec->chip, OPTi9XX_MC_REG(11)); @@ -1109,7 +1105,7 @@ static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id, struct pt_regs * } -static snd_pcm_hardware_t snd_opti93x_playback = { +static struct snd_pcm_hardware snd_opti93x_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | @@ -1127,7 +1123,7 @@ static snd_pcm_hardware_t snd_opti93x_playback = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_opti93x_capture = { +static struct snd_pcm_hardware snd_opti93x_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), .formats = (SNDRV_PCM_FMTBIT_MU_LAW | SNDRV_PCM_FMTBIT_A_LAW | SNDRV_PCM_FMTBIT_IMA_ADPCM | @@ -1145,11 +1141,11 @@ static snd_pcm_hardware_t snd_opti93x_capture = { .fifo_size = 0, }; -static int snd_opti93x_playback_open(snd_pcm_substream_t *substream) +static int snd_opti93x_playback_open(struct snd_pcm_substream *substream) { int error; - opti93x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if ((error = snd_opti93x_open(chip, OPTi93X_MODE_PLAY)) < 0) return error; @@ -1161,11 +1157,11 @@ static int snd_opti93x_playback_open(snd_pcm_substream_t *substream) return error; } -static int snd_opti93x_capture_open(snd_pcm_substream_t *substream) +static int snd_opti93x_capture_open(struct snd_pcm_substream *substream) { int error; - opti93x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if ((error = snd_opti93x_open(chip, OPTi93X_MODE_CAPTURE)) < 0) return error; @@ -1177,18 +1173,18 @@ static int snd_opti93x_capture_open(snd_pcm_substream_t *substream) return error; } -static int snd_opti93x_playback_close(snd_pcm_substream_t *substream) +static int snd_opti93x_playback_close(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; snd_opti93x_close(chip, OPTi93X_MODE_PLAY); return 0; } -static int snd_opti93x_capture_close(snd_pcm_substream_t *substream) +static int snd_opti93x_capture_close(struct snd_pcm_substream *substream) { - opti93x_t *chip = snd_pcm_substream_chip(substream); + struct snd_opti93x *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; snd_opti93x_close(chip, OPTi93X_MODE_CAPTURE); @@ -1196,7 +1192,7 @@ static int snd_opti93x_capture_close(snd_pcm_substream_t *substream) } -static void snd_opti93x_init(opti93x_t *chip) +static void snd_opti93x_init(struct snd_opti93x *chip) { unsigned long flags; int i; @@ -1211,7 +1207,7 @@ static void snd_opti93x_init(opti93x_t *chip) spin_unlock_irqrestore(&chip->lock, flags); } -static int snd_opti93x_probe(opti93x_t *chip) +static int snd_opti93x_probe(struct snd_opti93x *chip) { unsigned long flags; unsigned char val; @@ -1223,7 +1219,7 @@ static int snd_opti93x_probe(opti93x_t *chip) return (val == 0x0a) ? 0 : -ENODEV; } -static int snd_opti93x_free(opti93x_t *chip) +static int snd_opti93x_free(struct snd_opti93x *chip) { release_and_free_resource(chip->res_port); if (chip->dma1 >= 0) { @@ -1241,13 +1237,13 @@ static int snd_opti93x_free(opti93x_t *chip) return 0; } -static int snd_opti93x_dev_free(snd_device_t *device) +static int snd_opti93x_dev_free(struct snd_device *device) { - opti93x_t *chip = device->device_data; + struct snd_opti93x *chip = device->device_data; return snd_opti93x_free(chip); } -static const char *snd_opti93x_chip_id(opti93x_t *codec) +static const char *snd_opti93x_chip_id(struct snd_opti93x *codec) { switch (codec->hardware) { case OPTi9XX_HW_82C930: return "82C930"; @@ -1257,15 +1253,15 @@ static const char *snd_opti93x_chip_id(opti93x_t *codec) } } -static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip, +static int snd_opti93x_create(struct snd_card *card, struct snd_opti9xx *chip, int dma1, int dma2, - opti93x_t **rcodec) + struct snd_opti93x **rcodec) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_opti93x_dev_free, }; int error; - opti93x_t *codec; + struct snd_opti93x *codec; *rcodec = NULL; codec = kzalloc(sizeof(*codec), GFP_KERNEL); @@ -1324,7 +1320,7 @@ static int snd_opti93x_create(snd_card_t *card, opti9xx_t *chip, return 0; } -static snd_pcm_ops_t snd_opti93x_playback_ops = { +static struct snd_pcm_ops snd_opti93x_playback_ops = { .open = snd_opti93x_playback_open, .close = snd_opti93x_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1335,7 +1331,7 @@ static snd_pcm_ops_t snd_opti93x_playback_ops = { .pointer = snd_opti93x_playback_pointer, }; -static snd_pcm_ops_t snd_opti93x_capture_ops = { +static struct snd_pcm_ops snd_opti93x_capture_ops = { .open = snd_opti93x_capture_open, .close = snd_opti93x_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1346,10 +1342,10 @@ static snd_pcm_ops_t snd_opti93x_capture_ops = { .pointer = snd_opti93x_capture_pointer, }; -static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm) +static int snd_opti93x_pcm(struct snd_opti93x *codec, int device, struct snd_pcm **rpcm) { int error; - snd_pcm_t *pcm; + struct snd_pcm *pcm; if ((error = snd_pcm_new(codec->card, "OPTi 82C93X", device, 1, 1, &pcm))) return error; @@ -1376,7 +1372,7 @@ static int snd_opti93x_pcm(opti93x_t *codec, int device, snd_pcm_t **rpcm) * MIXER part */ -static int snd_opti93x_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opti93x_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "Line1", "Aux", "Mic", "Mix" @@ -1391,9 +1387,9 @@ static int snd_opti93x_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_opti93x_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -1403,9 +1399,9 @@ static int snd_opti93x_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_opti93x_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short left, right; int change; @@ -1434,7 +1430,7 @@ static int snd_opti93x_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_opti93x_get_single, .put = snd_opti93x_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_opti93x_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opti93x_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1445,9 +1441,9 @@ static int snd_opti93x_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_opti93x_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1462,9 +1458,9 @@ static int snd_opti93x_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_opti93x_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1499,7 +1495,7 @@ static int snd_opti93x_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ do { xctl.private_value &= ~0x0000ffff; \ xctl.private_value |= left_reg | (right_reg << 8); } while (0) -static int snd_opti93x_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opti93x_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1510,9 +1506,9 @@ static int snd_opti93x_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_opti93x_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1532,9 +1528,9 @@ static int snd_opti93x_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opti93x_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opti93x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opti93x *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1563,7 +1559,7 @@ static int snd_opti93x_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -static snd_kcontrol_new_t snd_opti93x_controls[] = { +static struct snd_kcontrol_new snd_opti93x_controls[] = { OPTi93X_DOUBLE("Master Playback Switch", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1), OPTi93X_DOUBLE("Master Playback Volume", 0, OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1), OPTi93X_DOUBLE("PCM Playback Switch", 0, OPTi93X_DAC_LEFT, OPTi93X_DAC_RIGHT, 7, 7, 1, 1), @@ -1589,10 +1585,10 @@ OPTi93X_DOUBLE("Capture Volume", 0, OPTi93X_MIXOUT_LEFT, OPTi93X_MIXOUT_RIGHT, 0 } }; -static int snd_opti93x_mixer(opti93x_t *chip) +static int snd_opti93x_mixer(struct snd_opti93x *chip) { - snd_card_t *card; - snd_kcontrol_new_t knew; + struct snd_card *card; + struct snd_kcontrol_new knew; int err; unsigned int idx; @@ -1624,7 +1620,7 @@ static int snd_opti93x_mixer(opti93x_t *chip) #endif /* OPTi93X */ -static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip) +static int __devinit snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) { int i, err; @@ -1678,7 +1674,7 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip) } #ifdef CONFIG_PNP -static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link *card, +static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card, const struct pnp_card_device_id *pid) { struct pnp_dev *pdev; @@ -1772,7 +1768,7 @@ static int __devinit snd_card_opti9xx_pnp(opti9xx_t *chip, struct pnp_card_link #if 0 static int __devinit snd_card_opti9xx_resources(struct snd_card_opti9xx *chip, - snd_card_t *card) + struct snd_card *card) { int error, i, pnp = 0; @@ -1867,9 +1863,9 @@ static int __devinit snd_card_opti9xx_resources(struct snd_card_opti9xx *chip, } #endif -static void snd_card_opti9xx_free(snd_card_t *card) +static void snd_card_opti9xx_free(struct snd_card *card) { - opti9xx_t *chip = (opti9xx_t *)card->private_data; + struct snd_opti9xx *chip = (struct snd_opti9xx *)card->private_data; if (chip) release_and_free_resource(chip->res_mc_base); @@ -1891,19 +1887,19 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; #endif /* CS4231 || OPTi93X */ int error; - opti9xx_t *chip; + struct snd_opti9xx *chip; #if defined(OPTi93X) - opti93x_t *codec; + struct snd_opti93x *codec; #elif defined(CS4231) - cs4231_t *codec; - snd_timer_t *timer; + struct snd_cs4231 *codec; + struct snd_timer *timer; #else - ad1848_t *codec; + struct snd_ad1848 *codec; #endif - snd_card_t *card; - snd_pcm_t *pcm; - snd_rawmidi_t *rmidi; - snd_hwdep_t *synth; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_rawmidi *rmidi; + struct snd_hwdep *synth; #ifdef CONFIG_PNP int hw; #endif /* CONFIG_PNP */ @@ -1911,10 +1907,10 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, if (pcard && !snd_opti9xx_first_hit) return -EBUSY; if (!(card = snd_card_new(index, id, THIS_MODULE, - sizeof(opti9xx_t)))) + sizeof(struct snd_opti9xx)))) return -ENOMEM; card->private_free = snd_card_opti9xx_free; - chip = (opti9xx_t *)card->private_data; + chip = (struct snd_opti9xx *)card->private_data; #ifdef CONFIG_PNP if (isapnp && pcard && (hw = snd_card_opti9xx_pnp(chip, pcard, pid)) > 0) { @@ -2098,12 +2094,12 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, snd_printk("no MPU-401 device at 0x%lx?\n", chip->mpu_port); if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { - opl3_t *opl3 = NULL; + struct snd_opl3 *opl3 = NULL; #ifndef OPTi93X if (chip->hardware == OPTi9XX_HW_82C928 || chip->hardware == OPTi9XX_HW_82C929 || chip->hardware == OPTi9XX_HW_82C924) { - opl4_t *opl4; + struct snd_opl4 *opl4; /* assume we have an OPL4 */ snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x20, 0x20); @@ -2156,7 +2152,7 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, #ifdef CONFIG_PNP static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); -- cgit v1.1 From 542172f31d41e689988aedcf0d6e67dfe757736a Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:39:06 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA Wavefront Modules: Wavefront drivers Remove xxx_t typedefs from the ISA Wavefront driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/snd_wavefront.h | 20 +++++++++--------- sound/isa/wavefront/wavefront.c | 38 +++++++++++++++++------------------ sound/isa/wavefront/wavefront_fx.c | 8 ++++---- sound/isa/wavefront/wavefront_midi.c | 22 ++++++++++---------- sound/isa/wavefront/wavefront_synth.c | 24 +++++++++++----------- 5 files changed, 56 insertions(+), 56 deletions(-) diff --git a/include/sound/snd_wavefront.h b/include/sound/snd_wavefront.h index 4b0b2b9..0b9e5de 100644 --- a/include/sound/snd_wavefront.h +++ b/include/sound/snd_wavefront.h @@ -26,8 +26,8 @@ struct _snd_wavefront_midi { snd_wavefront_mpu_id output_mpu; /* most-recently-used */ snd_wavefront_mpu_id input_mpu; /* most-recently-used */ unsigned int mode[2]; /* MPU401_MODE_XXX */ - snd_rawmidi_substream_t *substream_output[2]; - snd_rawmidi_substream_t *substream_input[2]; + struct snd_rawmidi_substream *substream_output[2]; + struct snd_rawmidi_substream *substream_input[2]; struct timer_list timer; spinlock_t open; spinlock_t virtual; /* protects isvirtual */ @@ -38,8 +38,8 @@ struct _snd_wavefront_midi { #define MPU_ACK 0xFE #define UART_MODE_ON 0x3F -extern snd_rawmidi_ops_t snd_wavefront_midi_output; -extern snd_rawmidi_ops_t snd_wavefront_midi_input; +extern struct snd_rawmidi_ops snd_wavefront_midi_output; +extern struct snd_rawmidi_ops snd_wavefront_midi_input; extern void snd_wavefront_midi_enable_virtual (snd_wavefront_card_t *); extern void snd_wavefront_midi_disable_virtual (snd_wavefront_card_t *); @@ -116,23 +116,23 @@ extern int snd_wavefront_config_midi (snd_wavefront_t *dev) ; extern int snd_wavefront_cmd (snd_wavefront_t *, int, unsigned char *, unsigned char *); -extern int snd_wavefront_synth_ioctl (snd_hwdep_t *, +extern int snd_wavefront_synth_ioctl (struct snd_hwdep *, struct file *, unsigned int cmd, unsigned long arg); -extern int snd_wavefront_synth_open (snd_hwdep_t *, struct file *); -extern int snd_wavefront_synth_release (snd_hwdep_t *, struct file *); +extern int snd_wavefront_synth_open (struct snd_hwdep *, struct file *); +extern int snd_wavefront_synth_release (struct snd_hwdep *, struct file *); /* FX processor - see also yss225.[ch] */ extern int snd_wavefront_fx_start (snd_wavefront_t *); extern int snd_wavefront_fx_detect (snd_wavefront_t *); -extern int snd_wavefront_fx_ioctl (snd_hwdep_t *, +extern int snd_wavefront_fx_ioctl (struct snd_hwdep *, struct file *, unsigned int cmd, unsigned long arg); -extern int snd_wavefront_fx_open (snd_hwdep_t *, struct file *); -extern int snd_wavefront_fx_release (snd_hwdep_t *, struct file *); +extern int snd_wavefront_fx_open (struct snd_hwdep *, struct file *); +extern int snd_wavefront_fx_release (struct snd_hwdep *, struct file *); /* prefix in all snd_printk() delivered messages */ diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 1818f10..9e5b571 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -81,7 +81,7 @@ MODULE_PARM_DESC(fm_port, "FM port #."); module_param_array(use_cs4232_midi, bool, NULL, 0444); MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); -static snd_card_t *snd_wavefront_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_wavefront_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -279,12 +279,12 @@ static irqreturn_t snd_wavefront_ics2115_interrupt(int irq, return IRQ_HANDLED; } -static snd_hwdep_t * __devinit -snd_wavefront_new_synth (snd_card_t *card, +static struct snd_hwdep * __devinit +snd_wavefront_new_synth (struct snd_card *card, int hw_dev, snd_wavefront_card_t *acard) { - snd_hwdep_t *wavefront_synth; + struct snd_hwdep *wavefront_synth; if (snd_wavefront_detect (acard) < 0) { return NULL; @@ -305,14 +305,14 @@ snd_wavefront_new_synth (snd_card_t *card, return wavefront_synth; } -static snd_hwdep_t * __devinit -snd_wavefront_new_fx (snd_card_t *card, +static struct snd_hwdep * __devinit +snd_wavefront_new_fx (struct snd_card *card, int hw_dev, snd_wavefront_card_t *acard, unsigned long port) { - snd_hwdep_t *fx_processor; + struct snd_hwdep *fx_processor; if (snd_wavefront_fx_start (&acard->wavefront)) { snd_printk ("cannot initialize YSS225 FX processor"); @@ -332,15 +332,15 @@ snd_wavefront_new_fx (snd_card_t *card, static snd_wavefront_mpu_id internal_id = internal_mpu; static snd_wavefront_mpu_id external_id = external_mpu; -static snd_rawmidi_t * __devinit -snd_wavefront_new_midi (snd_card_t *card, +static struct snd_rawmidi *__devinit +snd_wavefront_new_midi (struct snd_card *card, int midi_dev, snd_wavefront_card_t *acard, unsigned long port, snd_wavefront_mpu_id mpu) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; static int first = 1; if (first) { @@ -374,7 +374,7 @@ snd_wavefront_new_midi (snd_card_t *card, } static void -snd_wavefront_free(snd_card_t *card) +snd_wavefront_free(struct snd_card *card) { snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data; @@ -389,13 +389,13 @@ static int __devinit snd_wavefront_probe (int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { - snd_card_t *card; + struct snd_card *card; snd_wavefront_card_t *acard; - cs4231_t *chip; - snd_hwdep_t *wavefront_synth; - snd_rawmidi_t *ics2115_internal_rmidi = NULL; - snd_rawmidi_t *ics2115_external_rmidi = NULL; - snd_hwdep_t *fx_processor; + struct snd_cs4231 *chip; + struct snd_hwdep *wavefront_synth; + struct snd_rawmidi *ics2115_internal_rmidi = NULL; + struct snd_rawmidi *ics2115_external_rmidi = NULL; + struct snd_hwdep *fx_processor; int hw_dev = 0, midi_dev = 0, err; #ifdef CONFIG_PNP @@ -467,7 +467,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, /* ---------- OPL3 synth --------- */ if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { - opl3_t *opl3; + struct snd_opl3 *opl3; if ((err = snd_opl3_create(card, fm_port[dev], @@ -658,7 +658,7 @@ static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *card, static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index 3237968..180661c 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -460,7 +460,7 @@ snd_wavefront_fx_detect (snd_wavefront_t *dev) } int -snd_wavefront_fx_open (snd_hwdep_t *hw, struct file *file) +snd_wavefront_fx_open (struct snd_hwdep *hw, struct file *file) { if (!try_module_get(hw->card->module)) @@ -470,7 +470,7 @@ snd_wavefront_fx_open (snd_hwdep_t *hw, struct file *file) } int -snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file) +snd_wavefront_fx_release (struct snd_hwdep *hw, struct file *file) { module_put(hw->card->module); @@ -478,11 +478,11 @@ snd_wavefront_fx_release (snd_hwdep_t *hw, struct file *file) } int -snd_wavefront_fx_ioctl (snd_hwdep_t *sdev, struct file *file, +snd_wavefront_fx_ioctl (struct snd_hwdep *sdev, struct file *file, unsigned int cmd, unsigned long arg) { - snd_card_t *card; + struct snd_card *card; snd_wavefront_card_t *acard; snd_wavefront_t *dev; wavefront_fx_info r; diff --git a/sound/isa/wavefront/wavefront_midi.c b/sound/isa/wavefront/wavefront_midi.c index 6f51d64..15888ba 100644 --- a/sound/isa/wavefront/wavefront_midi.c +++ b/sound/isa/wavefront/wavefront_midi.c @@ -91,10 +91,10 @@ write_data (snd_wavefront_midi_t *midi, unsigned char byte) } static snd_wavefront_midi_t * -get_wavefront_midi (snd_rawmidi_substream_t *substream) +get_wavefront_midi (struct snd_rawmidi_substream *substream) { - snd_card_t *card; + struct snd_card *card; snd_wavefront_card_t *acard; if (substream == NULL || substream->rmidi == NULL) @@ -230,7 +230,7 @@ static void snd_wavefront_midi_output_write(snd_wavefront_card_t *card) } } -static int snd_wavefront_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_wavefront_midi_input_open(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -252,7 +252,7 @@ static int snd_wavefront_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_wavefront_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_wavefront_midi_output_open(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -274,7 +274,7 @@ static int snd_wavefront_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_wavefront_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_wavefront_midi_input_close(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -295,7 +295,7 @@ static int snd_wavefront_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_wavefront_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_wavefront_midi_output_close(struct snd_rawmidi_substream *substream) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -315,7 +315,7 @@ static int snd_wavefront_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_wavefront_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_wavefront_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -355,7 +355,7 @@ static void snd_wavefront_midi_output_timer(unsigned long data) snd_wavefront_midi_output_write(card); } -static void snd_wavefront_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_wavefront_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; snd_wavefront_midi_t *midi; @@ -401,7 +401,7 @@ snd_wavefront_midi_interrupt (snd_wavefront_card_t *card) { unsigned long flags; snd_wavefront_midi_t *midi; - static snd_rawmidi_substream_t *substream = NULL; + static struct snd_rawmidi_substream *substream = NULL; static int mpu = external_mpu; int max = 128; unsigned char byte; @@ -554,14 +554,14 @@ snd_wavefront_midi_start (snd_wavefront_card_t *card) return 0; } -snd_rawmidi_ops_t snd_wavefront_midi_output = +struct snd_rawmidi_ops snd_wavefront_midi_output = { .open = snd_wavefront_midi_output_open, .close = snd_wavefront_midi_output_close, .trigger = snd_wavefront_midi_output_trigger, }; -snd_rawmidi_ops_t snd_wavefront_midi_input = +struct snd_rawmidi_ops snd_wavefront_midi_input = { .open = snd_wavefront_midi_input_open, .close = snd_wavefront_midi_input_close, diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index abd79b7..679d0ae 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -144,13 +144,13 @@ MODULE_PARM_DESC(osrun_time, "how many seconds to wait for the ICS2115 OS"); static int wavefront_delete_sample (snd_wavefront_t *, int sampnum); static int wavefront_find_free_sample (snd_wavefront_t *); -typedef struct { +struct wavefront_command { int cmd; char *action; unsigned int read_cnt; unsigned int write_cnt; int need_ack; -} wavefront_command; +}; static struct { int errno; @@ -170,7 +170,7 @@ static struct { #define NEEDS_ACK 1 -static wavefront_command wavefront_commands[] = { +static struct wavefront_command wavefront_commands[] = { { WFC_SET_SYNTHVOL, "set synthesizer volume", 0, 1, NEEDS_ACK }, { WFC_GET_SYNTHVOL, "get synthesizer volume", 1, 0, 0}, { WFC_SET_NVOICES, "set number of voices", 0, 1, NEEDS_ACK }, @@ -249,7 +249,7 @@ wavefront_errorstr (int errnum) return "Unknown WaveFront error"; } -static wavefront_command * +static struct wavefront_command * wavefront_get_command (int cmd) { @@ -261,7 +261,7 @@ wavefront_get_command (int cmd) } } - return (wavefront_command *) 0; + return NULL; } static inline int @@ -345,9 +345,9 @@ snd_wavefront_cmd (snd_wavefront_t *dev, int ack; unsigned int i; int c; - wavefront_command *wfcmd; + struct wavefront_command *wfcmd; - if ((wfcmd = wavefront_get_command (cmd)) == (wavefront_command *) 0) { + if ((wfcmd = wavefront_get_command (cmd)) == NULL) { snd_printk ("command 0x%x not supported.\n", cmd); return 1; @@ -1625,7 +1625,7 @@ wavefront_synth_control (snd_wavefront_card_t *acard, } int -snd_wavefront_synth_open (snd_hwdep_t *hw, struct file *file) +snd_wavefront_synth_open (struct snd_hwdep *hw, struct file *file) { if (!try_module_get(hw->card->module)) @@ -1635,7 +1635,7 @@ snd_wavefront_synth_open (snd_hwdep_t *hw, struct file *file) } int -snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file) +snd_wavefront_synth_release (struct snd_hwdep *hw, struct file *file) { module_put(hw->card->module); @@ -1643,18 +1643,18 @@ snd_wavefront_synth_release (snd_hwdep_t *hw, struct file *file) } int -snd_wavefront_synth_ioctl (snd_hwdep_t *hw, struct file *file, +snd_wavefront_synth_ioctl (struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg) { - snd_card_t *card; + struct snd_card *card; snd_wavefront_t *dev; snd_wavefront_card_t *acard; wavefront_control *wc; void __user *argp = (void __user *)arg; int err; - card = (snd_card_t *) hw->card; + card = (struct snd_card *) hw->card; snd_assert(card != NULL, return -ENODEV); -- cgit v1.1 From e3561703723fcc2315f852cb85e80533a2c58e3e Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:41:02 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA CMI8330 Modules: CMI8330 driver Remove xxx_t typedefs from the ISA CMI8330 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/cmi8330.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index 6038529..cf16006 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -137,26 +137,26 @@ static unsigned char snd_cmi8330_image[((CMI8330_CDINGAIN)-16) + 1] = 0x0 /* 26 - cd-in rec gain */ }; -typedef int (*snd_pcm_open_callback_t)(snd_pcm_substream_t *); +typedef int (*snd_pcm_open_callback_t)(struct snd_pcm_substream *); struct snd_cmi8330 { #ifdef CONFIG_PNP struct pnp_dev *cap; struct pnp_dev *play; #endif - snd_card_t *card; - ad1848_t *wss; - sb_t *sb; + struct snd_card *card; + struct snd_ad1848 *wss; + struct snd_sb *sb; - snd_pcm_t *pcm; + struct snd_pcm *pcm; struct snd_cmi8330_stream { - snd_pcm_ops_t ops; + struct snd_pcm_ops ops; snd_pcm_open_callback_t open; void *private_data; /* sb or wss */ } streams[2]; }; -static snd_card_t *snd_cmi8330_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_cmi8330_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -231,7 +231,7 @@ static unsigned char cmi8330_sb_init_values[][2] __initdata = { }; -static int __devinit cmi8330_add_sb_mixers(sb_t *chip) +static int __devinit cmi8330_add_sb_mixers(struct snd_sb *chip) { int idx, err; unsigned long flags; @@ -256,7 +256,7 @@ static int __devinit cmi8330_add_sb_mixers(sb_t *chip) } #endif -static int __devinit snd_cmi8330_mixer(snd_card_t *card, struct snd_cmi8330 *acard) +static int __devinit snd_cmi8330_mixer(struct snd_card *card, struct snd_cmi8330 *acard) { unsigned int idx; int err; @@ -370,7 +370,7 @@ static int __devinit snd_cmi8330_pnp(int dev, struct snd_cmi8330 *acard, #define CMI_AD_STREAM SNDRV_PCM_STREAM_PLAYBACK #endif -static int snd_cmi8330_playback_open(snd_pcm_substream_t * substream) +static int snd_cmi8330_playback_open(struct snd_pcm_substream *substream) { struct snd_cmi8330 *chip = snd_pcm_substream_chip(substream); @@ -379,7 +379,7 @@ static int snd_cmi8330_playback_open(snd_pcm_substream_t * substream) return chip->streams[SNDRV_PCM_STREAM_PLAYBACK].open(substream); } -static int snd_cmi8330_capture_open(snd_pcm_substream_t * substream) +static int snd_cmi8330_capture_open(struct snd_pcm_substream *substream) { struct snd_cmi8330 *chip = snd_pcm_substream_chip(substream); @@ -388,10 +388,10 @@ static int snd_cmi8330_capture_open(snd_pcm_substream_t * substream) return chip->streams[SNDRV_PCM_STREAM_CAPTURE].open(substream); } -static int __devinit snd_cmi8330_pcm(snd_card_t *card, struct snd_cmi8330 *chip) +static int __devinit snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 *chip) { - snd_pcm_t *pcm; - const snd_pcm_ops_t *ops; + struct snd_pcm *pcm; + const struct snd_pcm_ops *ops; int err; static snd_pcm_open_callback_t cmi_open_callbacks[2] = { snd_cmi8330_playback_open, @@ -444,7 +444,7 @@ static int __devinit snd_cmi8330_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { - snd_card_t *card; + struct snd_card *card; struct snd_cmi8330 *acard; int i, err; @@ -567,7 +567,7 @@ static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *card, static void __devexit snd_cmi8330_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); -- cgit v1.1 From 8047c910ff27811060e6983ac446ed5a0fe550c6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:41:22 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA ES18xx Modules: ES18xx driver Remove xxx_t typedefs from the ISA ES18xx driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/es18xx.c | 282 ++++++++++++++++++++++++++--------------------------- 1 file changed, 140 insertions(+), 142 deletions(-) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 7191ff9..06c0e77 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -86,7 +86,7 @@ #define PFX "es18xx: " -struct _snd_es18xx { +struct snd_es18xx { unsigned long port; /* port of ESS chip */ unsigned long mpu_port; /* MPU-401 port of ESS chip */ unsigned long fm_port; /* FM port */ @@ -107,18 +107,18 @@ struct _snd_es18xx { unsigned int dma1_shift; unsigned int dma2_shift; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_a_substream; - snd_pcm_substream_t *capture_a_substream; - snd_pcm_substream_t *playback_b_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_a_substream; + struct snd_pcm_substream *capture_a_substream; + struct snd_pcm_substream *playback_b_substream; - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; - snd_kcontrol_t *hw_volume; - snd_kcontrol_t *hw_switch; - snd_kcontrol_t *master_volume; - snd_kcontrol_t *master_switch; + struct snd_kcontrol *hw_volume; + struct snd_kcontrol *hw_switch; + struct snd_kcontrol *master_volume; + struct snd_kcontrol *master_switch; spinlock_t reg_lock; spinlock_t mixer_lock; @@ -155,8 +155,6 @@ struct _snd_es18xx { #define ES18XX_PM_FM 0x020 #define ES18XX_PM_SUS 0x080 -typedef struct _snd_es18xx es18xx_t; - /* Lowlevel */ #define DAC1 0x01 @@ -164,7 +162,7 @@ typedef struct _snd_es18xx es18xx_t; #define DAC2 0x04 #define MILLISECOND 10000 -static int snd_es18xx_dsp_command(es18xx_t *chip, unsigned char val) +static int snd_es18xx_dsp_command(struct snd_es18xx *chip, unsigned char val) { int i; @@ -177,7 +175,7 @@ static int snd_es18xx_dsp_command(es18xx_t *chip, unsigned char val) return -EINVAL; } -static int snd_es18xx_dsp_get_byte(es18xx_t *chip) +static int snd_es18xx_dsp_get_byte(struct snd_es18xx *chip) { int i; @@ -191,7 +189,7 @@ static int snd_es18xx_dsp_get_byte(es18xx_t *chip) #undef REG_DEBUG -static int snd_es18xx_write(es18xx_t *chip, +static int snd_es18xx_write(struct snd_es18xx *chip, unsigned char reg, unsigned char data) { unsigned long flags; @@ -210,7 +208,7 @@ static int snd_es18xx_write(es18xx_t *chip, return ret; } -static int snd_es18xx_read(es18xx_t *chip, unsigned char reg) +static int snd_es18xx_read(struct snd_es18xx *chip, unsigned char reg) { unsigned long flags; int ret, data; @@ -232,7 +230,7 @@ static int snd_es18xx_read(es18xx_t *chip, unsigned char reg) } /* Return old value */ -static int snd_es18xx_bits(es18xx_t *chip, unsigned char reg, +static int snd_es18xx_bits(struct snd_es18xx *chip, unsigned char reg, unsigned char mask, unsigned char val) { int ret; @@ -270,7 +268,7 @@ static int snd_es18xx_bits(es18xx_t *chip, unsigned char reg, return ret; } -static inline void snd_es18xx_mixer_write(es18xx_t *chip, +static inline void snd_es18xx_mixer_write(struct snd_es18xx *chip, unsigned char reg, unsigned char data) { unsigned long flags; @@ -283,7 +281,7 @@ static inline void snd_es18xx_mixer_write(es18xx_t *chip, #endif } -static inline int snd_es18xx_mixer_read(es18xx_t *chip, unsigned char reg) +static inline int snd_es18xx_mixer_read(struct snd_es18xx *chip, unsigned char reg) { unsigned long flags; int data; @@ -298,7 +296,7 @@ static inline int snd_es18xx_mixer_read(es18xx_t *chip, unsigned char reg) } /* Return old value */ -static inline int snd_es18xx_mixer_bits(es18xx_t *chip, unsigned char reg, +static inline int snd_es18xx_mixer_bits(struct snd_es18xx *chip, unsigned char reg, unsigned char mask, unsigned char val) { unsigned char old, new, oval; @@ -319,7 +317,7 @@ static inline int snd_es18xx_mixer_bits(es18xx_t *chip, unsigned char reg, return oval; } -static inline int snd_es18xx_mixer_writable(es18xx_t *chip, unsigned char reg, +static inline int snd_es18xx_mixer_writable(struct snd_es18xx *chip, unsigned char reg, unsigned char mask) { int old, expected, new; @@ -339,7 +337,7 @@ static inline int snd_es18xx_mixer_writable(es18xx_t *chip, unsigned char reg, } -static int snd_es18xx_reset(es18xx_t *chip) +static int snd_es18xx_reset(struct snd_es18xx *chip) { int i; outb(0x03, chip->port + 0x06); @@ -351,7 +349,7 @@ static int snd_es18xx_reset(es18xx_t *chip) return 0; } -static int snd_es18xx_reset_fifo(es18xx_t *chip) +static int snd_es18xx_reset_fifo(struct snd_es18xx *chip) { outb(0x02, chip->port + 0x06); inb(chip->port + 0x06); @@ -359,7 +357,7 @@ static int snd_es18xx_reset_fifo(es18xx_t *chip) return 0; } -static ratnum_t new_clocks[2] = { +static struct snd_ratnum new_clocks[2] = { { .num = 793800, .den_min = 1, @@ -374,12 +372,12 @@ static ratnum_t new_clocks[2] = { } }; -static snd_pcm_hw_constraint_ratnums_t new_hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums new_hw_constraints_clocks = { .nrats = 2, .rats = new_clocks, }; -static ratnum_t old_clocks[2] = { +static struct snd_ratnum old_clocks[2] = { { .num = 795444, .den_min = 1, @@ -394,18 +392,18 @@ static ratnum_t old_clocks[2] = { } }; -static snd_pcm_hw_constraint_ratnums_t old_hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums old_hw_constraints_clocks = { .nrats = 2, .rats = old_clocks, }; -static void snd_es18xx_rate_set(es18xx_t *chip, - snd_pcm_substream_t *substream, +static void snd_es18xx_rate_set(struct snd_es18xx *chip, + struct snd_pcm_substream *substream, int mode) { unsigned int bits, div0; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (chip->caps & ES18XX_NEW_RATE) { if (runtime->rate_num == new_clocks[0].num) bits = 128 - runtime->rate_den; @@ -435,10 +433,10 @@ static void snd_es18xx_rate_set(es18xx_t *chip, } } -static int snd_es18xx_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_es18xx_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int shift, err; shift = 0; @@ -463,15 +461,15 @@ static int snd_es18xx_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_es18xx_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_es18xx_pcm_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_es18xx_playback1_prepare(es18xx_t *chip, - snd_pcm_substream_t *substream) +static int snd_es18xx_playback1_prepare(struct snd_es18xx *chip, + struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -496,8 +494,8 @@ static int snd_es18xx_playback1_prepare(es18xx_t *chip, return 0; } -static int snd_es18xx_playback1_trigger(es18xx_t *chip, - snd_pcm_substream_t * substream, +static int snd_es18xx_playback1_trigger(struct snd_es18xx *chip, + struct snd_pcm_substream *substream, int cmd) { switch (cmd) { @@ -546,10 +544,10 @@ static int snd_es18xx_playback1_trigger(es18xx_t *chip, return 0; } -static int snd_es18xx_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_es18xx_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int shift, err; shift = 0; @@ -569,10 +567,10 @@ static int snd_es18xx_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_es18xx_capture_prepare(snd_pcm_substream_t *substream) +static int snd_es18xx_capture_prepare(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -608,10 +606,10 @@ static int snd_es18xx_capture_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_es18xx_capture_trigger(snd_pcm_substream_t *substream, +static int snd_es18xx_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -637,10 +635,10 @@ static int snd_es18xx_capture_trigger(snd_pcm_substream_t *substream, return 0; } -static int snd_es18xx_playback2_prepare(es18xx_t *chip, - snd_pcm_substream_t *substream) +static int snd_es18xx_playback2_prepare(struct snd_es18xx *chip, + struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -674,8 +672,8 @@ static int snd_es18xx_playback2_prepare(es18xx_t *chip, return 0; } -static int snd_es18xx_playback2_trigger(es18xx_t *chip, - snd_pcm_substream_t *substream, +static int snd_es18xx_playback2_trigger(struct snd_es18xx *chip, + struct snd_pcm_substream *substream, int cmd) { switch (cmd) { @@ -714,19 +712,19 @@ static int snd_es18xx_playback2_trigger(es18xx_t *chip, return 0; } -static int snd_es18xx_playback_prepare(snd_pcm_substream_t *substream) +static int snd_es18xx_playback_prepare(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) return snd_es18xx_playback1_prepare(chip, substream); else return snd_es18xx_playback2_prepare(chip, substream); } -static int snd_es18xx_playback_trigger(snd_pcm_substream_t *substream, +static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) return snd_es18xx_playback1_trigger(chip, substream, cmd); else @@ -735,7 +733,7 @@ static int snd_es18xx_playback_trigger(snd_pcm_substream_t *substream, static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - es18xx_t *chip = dev_id; + struct snd_es18xx *chip = dev_id; unsigned char status; if (chip->caps & ES18XX_CONTROL) { @@ -795,9 +793,9 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_es18xx_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es18xx_playback_pointer(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int pos; if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { @@ -813,9 +811,9 @@ static snd_pcm_uframes_t snd_es18xx_playback_pointer(snd_pcm_substream_t * subst } } -static snd_pcm_uframes_t snd_es18xx_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es18xx_capture_pointer(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); int pos; if (!(chip->active & ADC1)) @@ -824,7 +822,7 @@ static snd_pcm_uframes_t snd_es18xx_capture_pointer(snd_pcm_substream_t * substr return pos >> chip->dma1_shift; } -static snd_pcm_hardware_t snd_es18xx_playback = +static struct snd_pcm_hardware snd_es18xx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | @@ -844,7 +842,7 @@ static snd_pcm_hardware_t snd_es18xx_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_es18xx_capture = +static struct snd_pcm_hardware snd_es18xx_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | @@ -864,10 +862,10 @@ static snd_pcm_hardware_t snd_es18xx_capture = .fifo_size = 0, }; -static int snd_es18xx_playback_open(snd_pcm_substream_t * substream) +static int snd_es18xx_playback_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) { if ((chip->caps & ES18XX_DUPLEX_MONO) && @@ -889,10 +887,10 @@ static int snd_es18xx_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es18xx_capture_open(snd_pcm_substream_t * substream) +static int snd_es18xx_capture_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (chip->playback_b_substream) return -EAGAIN; @@ -907,9 +905,9 @@ static int snd_es18xx_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es18xx_playback_close(snd_pcm_substream_t * substream) +static int snd_es18xx_playback_close(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); if (substream->number == 0 && (chip->caps & ES18XX_PCM2)) chip->playback_a_substream = NULL; @@ -920,9 +918,9 @@ static int snd_es18xx_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_es18xx_capture_close(snd_pcm_substream_t * substream) +static int snd_es18xx_capture_close(struct snd_pcm_substream *substream) { - es18xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_es18xx *chip = snd_pcm_substream_chip(substream); chip->capture_a_substream = NULL; snd_pcm_lib_free_pages(substream); @@ -933,7 +931,7 @@ static int snd_es18xx_capture_close(snd_pcm_substream_t * substream) * MIXER part */ -static int snd_es18xx_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[8] = { "Mic", "Mic Master", "CD", "AOUT", @@ -949,16 +947,16 @@ static int snd_es18xx_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_es18xx_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = snd_es18xx_mixer_read(chip, 0x1c) & 0x07; return 0; } -static int snd_es18xx_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); unsigned char val = ucontrol->value.enumerated.item[0]; if (val > 7) @@ -966,7 +964,7 @@ static int snd_es18xx_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return snd_es18xx_mixer_bits(chip, 0x1c, 0x07, val) != val; } -static int snd_es18xx_info_spatializer_enable(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -975,17 +973,17 @@ static int snd_es18xx_info_spatializer_enable(snd_kcontrol_t *kcontrol, snd_ctl_ return 0; } -static int snd_es18xx_get_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); unsigned char val = snd_es18xx_mixer_read(chip, 0x50); ucontrol->value.integer.value[0] = !!(val & 8); return 0; } -static int snd_es18xx_put_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_put_spatializer_enable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); unsigned char oval, nval; int change; nval = ucontrol->value.integer.value[0] ? 0x0c : 0x04; @@ -998,7 +996,7 @@ static int snd_es18xx_put_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_ return change; } -static int snd_es18xx_info_hw_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_hw_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1007,15 +1005,15 @@ static int snd_es18xx_info_hw_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_es18xx_get_hw_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_hw_volume(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = snd_es18xx_mixer_read(chip, 0x61) & 0x3f; ucontrol->value.integer.value[1] = snd_es18xx_mixer_read(chip, 0x63) & 0x3f; return 0; } -static int snd_es18xx_info_hw_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_hw_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -1024,24 +1022,24 @@ static int snd_es18xx_info_hw_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_es18xx_get_hw_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_hw_switch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = !(snd_es18xx_mixer_read(chip, 0x61) & 0x40); ucontrol->value.integer.value[1] = !(snd_es18xx_mixer_read(chip, 0x63) & 0x40); return 0; } -static void snd_es18xx_hwv_free(snd_kcontrol_t *kcontrol) +static void snd_es18xx_hwv_free(struct snd_kcontrol *kcontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); chip->master_volume = NULL; chip->master_switch = NULL; chip->hw_volume = NULL; chip->hw_switch = NULL; } -static int snd_es18xx_reg_bits(es18xx_t *chip, unsigned char reg, +static int snd_es18xx_reg_bits(struct snd_es18xx *chip, unsigned char reg, unsigned char mask, unsigned char val) { if (reg < 0xa0) @@ -1050,7 +1048,7 @@ static int snd_es18xx_reg_bits(es18xx_t *chip, unsigned char reg, return snd_es18xx_bits(chip, reg, mask, val); } -static int snd_es18xx_reg_read(es18xx_t *chip, unsigned char reg) +static int snd_es18xx_reg_read(struct snd_es18xx *chip, unsigned char reg) { if (reg < 0xa0) return snd_es18xx_mixer_read(chip, reg); @@ -1064,7 +1062,7 @@ static int snd_es18xx_reg_read(es18xx_t *chip, unsigned char reg) .get = snd_es18xx_get_single, .put = snd_es18xx_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_es18xx_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1075,9 +1073,9 @@ static int snd_es18xx_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es18xx_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1091,9 +1089,9 @@ static int snd_es18xx_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es18xx_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1114,7 +1112,7 @@ static int snd_es18xx_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_es18xx_get_double, .put = snd_es18xx_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_es18xx_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es18xx_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1125,9 +1123,9 @@ static int snd_es18xx_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es18xx_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int shift_left = (kcontrol->private_value >> 16) & 0x07; @@ -1150,9 +1148,9 @@ static int snd_es18xx_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es18xx_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es18xx_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - es18xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_es18xx *chip = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int shift_left = (kcontrol->private_value >> 16) & 0x07; @@ -1185,7 +1183,7 @@ static int snd_es18xx_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_es18xx_base_controls[] = { +static struct snd_kcontrol_new snd_es18xx_base_controls[] = { ES18XX_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0), ES18XX_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), ES18XX_DOUBLE("Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0), @@ -1207,10 +1205,10 @@ ES18XX_SINGLE("Capture Switch", 0, 0x1c, 4, 1, 1), } }; -static snd_kcontrol_new_t snd_es18xx_mono_in_control = +static struct snd_kcontrol_new snd_es18xx_mono_in_control = ES18XX_DOUBLE("Mono Input Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0); -static snd_kcontrol_new_t snd_es18xx_recmix_controls[] = { +static struct snd_kcontrol_new snd_es18xx_recmix_controls[] = { ES18XX_DOUBLE("PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0), ES18XX_DOUBLE("Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0), ES18XX_DOUBLE("Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0), @@ -1220,16 +1218,16 @@ ES18XX_DOUBLE("CD Capture Volume", 0, 0x6a, 0x6a, 4, 0, 15, 0), ES18XX_DOUBLE("Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0) }; -static snd_kcontrol_new_t snd_es18xx_pcm1_controls[] = { +static struct snd_kcontrol_new snd_es18xx_pcm1_controls[] = { ES18XX_DOUBLE("PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0), }; -static snd_kcontrol_new_t snd_es18xx_pcm2_controls[] = { +static struct snd_kcontrol_new snd_es18xx_pcm2_controls[] = { ES18XX_DOUBLE("PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0), ES18XX_DOUBLE("PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0) }; -static snd_kcontrol_new_t snd_es18xx_spatializer_controls[] = { +static struct snd_kcontrol_new snd_es18xx_spatializer_controls[] = { ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -1240,13 +1238,13 @@ ES18XX_SINGLE("3D Control - Level", 0, 0x52, 0, 63, 0), } }; -static snd_kcontrol_new_t snd_es18xx_micpre1_control = +static struct snd_kcontrol_new snd_es18xx_micpre1_control = ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0xa9, 2, 1, 0); -static snd_kcontrol_new_t snd_es18xx_micpre2_control = +static struct snd_kcontrol_new snd_es18xx_micpre2_control = ES18XX_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0); -static snd_kcontrol_new_t snd_es18xx_hw_volume_controls[] = { +static struct snd_kcontrol_new snd_es18xx_hw_volume_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Hardware Master Playback Volume", @@ -1265,7 +1263,7 @@ ES18XX_SINGLE("Hardware Master Volume Split", 0, 0x64, 7, 1, 0), }; #if 0 -static int __devinit snd_es18xx_config_read(es18xx_t *chip, unsigned char reg) +static int __devinit snd_es18xx_config_read(struct snd_es18xx *chip, unsigned char reg) { int data; unsigned long flags; @@ -1277,7 +1275,7 @@ static int __devinit snd_es18xx_config_read(es18xx_t *chip, unsigned char reg) } #endif -static void __devinit snd_es18xx_config_write(es18xx_t *chip, +static void __devinit snd_es18xx_config_write(struct snd_es18xx *chip, unsigned char reg, unsigned char data) { /* No need for spinlocks, this function is used only in @@ -1289,7 +1287,7 @@ static void __devinit snd_es18xx_config_write(es18xx_t *chip, #endif } -static int __devinit snd_es18xx_initialize(es18xx_t *chip) +static int __devinit snd_es18xx_initialize(struct snd_es18xx *chip) { int mask = 0; @@ -1438,7 +1436,7 @@ static int __devinit snd_es18xx_initialize(es18xx_t *chip) return 0; } -static int __devinit snd_es18xx_identify(es18xx_t *chip) +static int __devinit snd_es18xx_identify(struct snd_es18xx *chip) { int hi,lo; @@ -1504,7 +1502,7 @@ static int __devinit snd_es18xx_identify(es18xx_t *chip) return 0; } -static int __devinit snd_es18xx_probe(es18xx_t *chip) +static int __devinit snd_es18xx_probe(struct snd_es18xx *chip) { if (snd_es18xx_identify(chip) < 0) { snd_printk(KERN_ERR PFX "[0x%lx] ESS chip not found\n", chip->port); @@ -1544,7 +1542,7 @@ static int __devinit snd_es18xx_probe(es18xx_t *chip) return snd_es18xx_initialize(chip); } -static snd_pcm_ops_t snd_es18xx_playback_ops = { +static struct snd_pcm_ops snd_es18xx_playback_ops = { .open = snd_es18xx_playback_open, .close = snd_es18xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1555,7 +1553,7 @@ static snd_pcm_ops_t snd_es18xx_playback_ops = { .pointer = snd_es18xx_playback_pointer, }; -static snd_pcm_ops_t snd_es18xx_capture_ops = { +static struct snd_pcm_ops snd_es18xx_capture_ops = { .open = snd_es18xx_capture_open, .close = snd_es18xx_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1566,9 +1564,9 @@ static snd_pcm_ops_t snd_es18xx_capture_ops = { .pointer = snd_es18xx_capture_pointer, }; -static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpcm) +static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; char str[16]; int err; @@ -1608,9 +1606,9 @@ static int __devinit snd_es18xx_pcm(es18xx_t *chip, int device, snd_pcm_t ** rpc /* Power Management support functions */ #ifdef CONFIG_PM -static int snd_es18xx_suspend(snd_card_t *card, pm_message_t state) +static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) { - es18xx_t *chip = card->pm_private_data; + struct snd_es18xx *chip = card->pm_private_data; snd_pcm_suspend_all(chip->pcm); @@ -1623,9 +1621,9 @@ static int snd_es18xx_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_es18xx_resume(snd_card_t *card) +static int snd_es18xx_resume(struct snd_card *card) { - es18xx_t *chip = card->pm_private_data; + struct snd_es18xx *chip = card->pm_private_data; /* restore PM register, we won't wake till (not 0x07) i/o activity though */ snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); @@ -1634,7 +1632,7 @@ static int snd_es18xx_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -static int snd_es18xx_free(es18xx_t *chip) +static int snd_es18xx_free(struct snd_es18xx *chip) { release_and_free_resource(chip->res_port); release_and_free_resource(chip->res_ctrl_port); @@ -1653,21 +1651,21 @@ static int snd_es18xx_free(es18xx_t *chip) return 0; } -static int snd_es18xx_dev_free(snd_device_t *device) +static int snd_es18xx_dev_free(struct snd_device *device) { - es18xx_t *chip = device->device_data; + struct snd_es18xx *chip = device->device_data; return snd_es18xx_free(chip); } -static int __devinit snd_es18xx_new_device(snd_card_t * card, +static int __devinit snd_es18xx_new_device(struct snd_card *card, unsigned long port, unsigned long mpu_port, unsigned long fm_port, int irq, int dma1, int dma2, - es18xx_t ** rchip) + struct snd_es18xx ** rchip) { - es18xx_t *chip; - static snd_device_ops_t ops = { + struct snd_es18xx *chip; + static struct snd_device_ops ops = { .dev_free = snd_es18xx_dev_free, }; int err; @@ -1728,9 +1726,9 @@ static int __devinit snd_es18xx_new_device(snd_card_t * card, return 0; } -static int __devinit snd_es18xx_mixer(es18xx_t *chip) +static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip) { - snd_card_t *card; + struct snd_card *card; int err; unsigned int idx; @@ -1739,7 +1737,7 @@ static int __devinit snd_es18xx_mixer(es18xx_t *chip) strcpy(card->mixername, chip->pcm->name); for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_es18xx_base_controls[idx], chip); if (chip->caps & ES18XX_HWV) { switch (idx) { @@ -1797,7 +1795,7 @@ static int __devinit snd_es18xx_mixer(es18xx_t *chip) } if (chip->caps & ES18XX_HWV) { for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_hw_volume_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_es18xx_hw_volume_controls[idx], chip); if (idx == 0) chip->hw_volume = kctl; @@ -1874,7 +1872,7 @@ struct snd_audiodrive { #endif }; -static snd_card_t *snd_audiodrive_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_audiodrive_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -1987,10 +1985,10 @@ static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; static int possible_dmas[] = {1, 0, 3, 5, -1}; int xirq, xdma1, xdma2; - snd_card_t *card; + struct snd_card *card; struct snd_audiodrive *acard; - es18xx_t *chip; - opl3_t *opl3; + struct snd_es18xx *chip; + struct snd_opl3 *opl3; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, @@ -2139,7 +2137,7 @@ static int __devinit snd_audiodrive_pnp_detect(struct pnp_card_link *card, static void __devexit snd_audiodrive_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); -- cgit v1.1 From ec6c5ae353fd9b1141da67094e125e75d031d740 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:41:45 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA OPL3SA2 Modules: OPL3SA2 driver Remove xxx_t typedefs from the ISA OPL3SA2 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/opl3sa2.c | 100 +++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 47cabda..a343af7 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -115,33 +115,31 @@ MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: #define OPL3SA2_PM_D0 0x00 #define OPL3SA2_PM_D3 (OPL3SA2_PM_ADOWN|OPL3SA2_PM_PSV|OPL3SA2_PM_PDN|OPL3SA2_PM_PDX) -typedef struct snd_opl3sa2 opl3sa2_t; - struct snd_opl3sa2 { - snd_card_t *card; + struct snd_card *card; int version; /* 2 or 3 */ unsigned long port; /* control port */ struct resource *res_port; /* control port resource */ int irq; int single_dma; spinlock_t reg_lock; - snd_hwdep_t *synth; - snd_rawmidi_t *rmidi; - cs4231_t *cs4231; + struct snd_hwdep *synth; + struct snd_rawmidi *rmidi; + struct snd_cs4231 *cs4231; #ifdef CONFIG_PNP struct pnp_dev *dev; #endif unsigned char ctlregs[0x20]; int ymode; /* SL added */ - snd_kcontrol_t *master_switch; - snd_kcontrol_t *master_volume; + struct snd_kcontrol *master_switch; + struct snd_kcontrol *master_volume; #ifdef CONFIG_PM - void (*cs4231_suspend)(cs4231_t *); - void (*cs4231_resume)(cs4231_t *); + void (*cs4231_suspend)(struct snd_cs4231 *); + void (*cs4231_resume)(struct snd_cs4231 *); #endif }; -static snd_card_t *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "opl3sa2: " @@ -176,7 +174,7 @@ MODULE_DEVICE_TABLE(pnp_card, snd_opl3sa2_pnpids); /* read control port (w/o spinlock) */ -static unsigned char __snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) +static unsigned char __snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg) { unsigned char result; #if 0 @@ -192,7 +190,7 @@ static unsigned char __snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) } /* read control port (with spinlock) */ -static unsigned char snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) +static unsigned char snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg) { unsigned long flags; unsigned char result; @@ -204,7 +202,7 @@ static unsigned char snd_opl3sa2_read(opl3sa2_t *chip, unsigned char reg) } /* write control port (w/o spinlock) */ -static void __snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char value) +static void __snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value) { #if 0 outb(0x1d, port); /* password */ @@ -215,7 +213,7 @@ static void __snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned cha } /* write control port (with spinlock) */ -static void snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char value) +static void snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -223,9 +221,9 @@ static void snd_opl3sa2_write(opl3sa2_t *chip, unsigned char reg, unsigned char spin_unlock_irqrestore(&chip->reg_lock, flags); } -static int __init snd_opl3sa2_detect(opl3sa2_t *chip) +static int __init snd_opl3sa2_detect(struct snd_opl3sa2 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned long port; unsigned char tmp, tmp1; char str[2]; @@ -298,7 +296,7 @@ static int __init snd_opl3sa2_detect(opl3sa2_t *chip) static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs *regs) { unsigned short status; - opl3sa2_t *chip = dev_id; + struct snd_opl3sa2 *chip = dev_id; int handled = 0; if (chip == NULL || chip->card == NULL) @@ -340,7 +338,7 @@ static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id, struct pt_regs * .get = snd_opl3sa2_get_single, .put = snd_opl3sa2_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_opl3sa2_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opl3sa2_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -351,9 +349,9 @@ static int snd_opl3sa2_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_opl3sa2_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opl3sa2_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -368,9 +366,9 @@ static int snd_opl3sa2_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_opl3sa2_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opl3sa2_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -398,7 +396,7 @@ static int snd_opl3sa2_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .get = snd_opl3sa2_get_double, .put = snd_opl3sa2_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_opl3sa2_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_opl3sa2_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -409,9 +407,9 @@ static int snd_opl3sa2_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_opl3sa2_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opl3sa2_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -431,9 +429,9 @@ static int snd_opl3sa2_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_opl3sa2_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_opl3sa2_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -471,31 +469,31 @@ static int snd_opl3sa2_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return change; } -static snd_kcontrol_new_t snd_opl3sa2_controls[] = { +static struct snd_kcontrol_new snd_opl3sa2_controls[] = { OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1), OPL3SA2_DOUBLE("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1), OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1), OPL3SA2_SINGLE("Mic Playback Volume", 0, 0x09, 0, 31, 1) }; -static snd_kcontrol_new_t snd_opl3sa2_tone_controls[] = { +static struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = { OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0), OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0), OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0) }; -static void snd_opl3sa2_master_free(snd_kcontrol_t *kcontrol) +static void snd_opl3sa2_master_free(struct snd_kcontrol *kcontrol) { - opl3sa2_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); chip->master_switch = NULL; chip->master_volume = NULL; } -static int __init snd_opl3sa2_mixer(opl3sa2_t *chip) +static int __init snd_opl3sa2_mixer(struct snd_opl3sa2 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; - snd_kcontrol_t *kctl; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; + struct snd_kcontrol *kctl; unsigned int idx; int err; @@ -539,9 +537,9 @@ static int __init snd_opl3sa2_mixer(opl3sa2_t *chip) /* Power Management support functions */ #ifdef CONFIG_PM -static int snd_opl3sa2_suspend(snd_card_t *card, pm_message_t state) +static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state) { - opl3sa2_t *chip = card->pm_private_data; + struct snd_opl3sa2 *chip = card->pm_private_data; snd_pcm_suspend_all(chip->cs4231->pcm); /* stop before saving regs */ chip->cs4231_suspend(chip->cs4231); @@ -552,9 +550,9 @@ static int snd_opl3sa2_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_opl3sa2_resume(snd_card_t *card) +static int snd_opl3sa2_resume(struct snd_card *card) { - opl3sa2_t *chip = card->pm_private_data; + struct snd_opl3sa2 *chip = card->pm_private_data; int i; /* power up */ @@ -577,7 +575,7 @@ static int snd_opl3sa2_resume(snd_card_t *card) #endif /* CONFIG_PM */ #ifdef CONFIG_PNP -static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip, +static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, struct pnp_dev *pdev, int isapnp) { @@ -634,7 +632,7 @@ static int __init snd_opl3sa2_pnp(int dev, opl3sa2_t *chip, return 0; } -static int __init snd_opl3sa2_cpnp(int dev, opl3sa2_t *chip, +static int __init snd_opl3sa2_cpnp(int dev, struct snd_opl3sa2 *chip, struct pnp_card_link *card, const struct pnp_card_device_id *id) { @@ -652,7 +650,7 @@ static int __init snd_opl3sa2_cpnp(int dev, opl3sa2_t *chip, } #endif /* CONFIG_PNP */ -static int snd_opl3sa2_free(opl3sa2_t *chip) +static int snd_opl3sa2_free(struct snd_opl3sa2 *chip) { if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); @@ -661,9 +659,9 @@ static int snd_opl3sa2_free(opl3sa2_t *chip) return 0; } -static int snd_opl3sa2_dev_free(snd_device_t *device) +static int snd_opl3sa2_dev_free(struct snd_device *device) { - opl3sa2_t *chip = device->device_data; + struct snd_opl3sa2 *chip = device->device_data; return snd_opl3sa2_free(chip); } @@ -679,11 +677,11 @@ static int __devinit snd_opl3sa2_probe(int dev, const struct pnp_card_device_id *pid) { int xirq, xdma1, xdma2; - snd_card_t *card; + struct snd_card *card; struct snd_opl3sa2 *chip; - cs4231_t *cs4231; - opl3_t *opl3; - static snd_device_ops_t ops = { + struct snd_cs4231 *cs4231; + struct snd_opl3 *opl3; + static struct snd_device_ops ops = { .dev_free = snd_opl3sa2_dev_free, }; int err; @@ -837,7 +835,7 @@ static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, static void __devexit snd_opl3sa2_pnp_remove(struct pnp_dev * pdev) { - snd_card_t *card = (snd_card_t *) pnp_get_drvdata(pdev); + struct snd_card *card = (struct snd_card *) pnp_get_drvdata(pdev); snd_card_disconnect(card); snd_card_free_in_thread(card); @@ -872,7 +870,7 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *card, static void __devexit snd_opl3sa2_pnp_cremove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); -- cgit v1.1 From be6245373f46eb21839ba1b54c83bc7cc8274208 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:42:05 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA SoundScape Modules: Sound Scape driver Remove xxx_t typedefs from the ISA SoundScape driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/sscape.c | 78 +++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 1158806..d07963e 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -75,7 +75,7 @@ static struct pnp_card_device_id sscape_pnpids[] = { MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids); #endif -static snd_card_t *sscape_card[SNDRV_CARDS]; +static struct snd_card *sscape_card[SNDRV_CARDS]; #define MPU401_IO(i) ((i) + 0) @@ -127,9 +127,9 @@ struct soundscape { int codec_type; int ic_type; struct resource *io_res; - cs4231_t *chip; - mpu401_t *mpu; - snd_hwdep_t *hw; + struct snd_cs4231 *chip; + struct snd_mpu401 *mpu; + struct snd_hwdep *hw; /* * The MIDI device won't work until we've loaded @@ -144,17 +144,17 @@ struct soundscape { #define INVALID_IRQ ((unsigned)-1) -static inline struct soundscape *get_card_soundscape(snd_card_t * c) +static inline struct soundscape *get_card_soundscape(struct snd_card *c) { return (struct soundscape *) (c->private_data); } -static inline struct soundscape *get_mpu401_soundscape(mpu401_t * mpu) +static inline struct soundscape *get_mpu401_soundscape(struct snd_mpu401 * mpu) { return (struct soundscape *) (mpu->private_data); } -static inline struct soundscape *get_hwdep_soundscape(snd_hwdep_t * hw) +static inline struct soundscape *get_hwdep_soundscape(struct snd_hwdep * hw) { return (struct soundscape *) (hw->private_data); } @@ -308,7 +308,7 @@ static int host_write_ctrl_unsafe(unsigned io_base, unsigned char data, * * NOTE: This check is based upon observation, not documentation. */ -static inline int verify_mpu401(const mpu401_t * mpu) +static inline int verify_mpu401(const struct snd_mpu401 * mpu) { return ((inb(MIDI_CTRL_IO(mpu->port)) & 0xc0) == 0x80); } @@ -316,7 +316,7 @@ static inline int verify_mpu401(const mpu401_t * mpu) /* * This is apparently the standard way to initailise an MPU-401 */ -static inline void initialise_mpu401(const mpu401_t * mpu) +static inline void initialise_mpu401(const struct snd_mpu401 * mpu) { outb(0, MIDI_DATA_IO(mpu->port)); } @@ -335,7 +335,7 @@ static inline void activate_ad1845_unsafe(unsigned io_base) /* * Do the necessary ALSA-level cleanup to deallocate our driver ... */ -static void soundscape_free(snd_card_t * c) +static void soundscape_free(struct snd_card *c) { register struct soundscape *sscape = get_card_soundscape(c); release_and_free_resource(sscape->io_res); @@ -613,7 +613,7 @@ static int sscape_upload_microcode(struct soundscape *sscape, * simultaneously, and that we can't open it at all if * someone is using the MIDI device. */ -static int sscape_hw_open(snd_hwdep_t * hw, struct file *file) +static int sscape_hw_open(struct snd_hwdep * hw, struct file *file) { register struct soundscape *sscape = get_hwdep_soundscape(hw); unsigned long flags; @@ -632,7 +632,7 @@ static int sscape_hw_open(snd_hwdep_t * hw, struct file *file) return err; } -static int sscape_hw_release(snd_hwdep_t * hw, struct file *file) +static int sscape_hw_release(struct snd_hwdep * hw, struct file *file) { register struct soundscape *sscape = get_hwdep_soundscape(hw); unsigned long flags; @@ -643,7 +643,7 @@ static int sscape_hw_release(snd_hwdep_t * hw, struct file *file) return 0; } -static int sscape_hw_ioctl(snd_hwdep_t * hw, struct file *file, +static int sscape_hw_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) { struct soundscape *sscape = get_hwdep_soundscape(hw); @@ -692,8 +692,8 @@ static int sscape_hw_ioctl(snd_hwdep_t * hw, struct file *file, /* * Mixer control for the SoundScape's MIDI device. */ -static int sscape_midi_info(snd_kcontrol_t * ctl, - snd_ctl_elem_info_t * uinfo) +static int sscape_midi_info(struct snd_kcontrol *ctl, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -702,11 +702,11 @@ static int sscape_midi_info(snd_kcontrol_t * ctl, return 0; } -static int sscape_midi_get(snd_kcontrol_t * kctl, - snd_ctl_elem_value_t * uctl) +static int sscape_midi_get(struct snd_kcontrol *kctl, + struct snd_ctl_elem_value *uctl) { - cs4231_t *chip = snd_kcontrol_chip(kctl); - snd_card_t *card = chip->card; + struct snd_cs4231 *chip = snd_kcontrol_chip(kctl); + struct snd_card *card = chip->card; register struct soundscape *s = get_card_soundscape(card); unsigned long flags; @@ -722,11 +722,11 @@ static int sscape_midi_get(snd_kcontrol_t * kctl, return 0; } -static int sscape_midi_put(snd_kcontrol_t * kctl, - snd_ctl_elem_value_t * uctl) +static int sscape_midi_put(struct snd_kcontrol *kctl, + struct snd_ctl_elem_value *uctl) { - cs4231_t *chip = snd_kcontrol_chip(kctl); - snd_card_t *card = chip->card; + struct snd_cs4231 *chip = snd_kcontrol_chip(kctl); + struct snd_card *card = chip->card; register struct soundscape *s = get_card_soundscape(card); unsigned long flags; int change; @@ -763,7 +763,7 @@ static int sscape_midi_put(snd_kcontrol_t * kctl, return change; } -static snd_kcontrol_new_t midi_mixer_ctl = { +static struct snd_kcontrol_new midi_mixer_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "MIDI", .info = sscape_midi_info, @@ -849,7 +849,7 @@ static int __devinit detect_sscape(struct soundscape *s) * to crash the machine. Also check that someone isn't using the hardware * IOCTL device. */ -static int mpu401_open(mpu401_t * mpu) +static int mpu401_open(struct snd_mpu401 * mpu) { int err; @@ -875,7 +875,7 @@ static int mpu401_open(mpu401_t * mpu) return err; } -static void mpu401_close(mpu401_t * mpu) +static void mpu401_close(struct snd_mpu401 * mpu) { register struct soundscape *sscape = get_mpu401_soundscape(mpu); unsigned long flags; @@ -888,10 +888,10 @@ static void mpu401_close(mpu401_t * mpu) /* * Initialse an MPU-401 subdevice for MIDI support on the SoundScape. */ -static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long port, int irq) +static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned long port, int irq) { struct soundscape *sscape = get_card_soundscape(card); - snd_rawmidi_t *rawmidi; + struct snd_rawmidi *rawmidi; int err; #define MPU401_SHARE_HARDWARE 1 @@ -900,7 +900,7 @@ static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long port, MPU401_SHARE_HARDWARE, irq, SA_INTERRUPT, &rawmidi)) == 0) { - mpu401_t *mpu = (mpu401_t *) rawmidi->private_data; + struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data; mpu->open_input = mpu401_open; mpu->open_output = mpu401_open; mpu->close_input = mpu401_close; @@ -919,7 +919,7 @@ static int __devinit create_mpu401(snd_card_t * card, int devnum, unsigned long * Override for the CS4231 playback format function. * The AD1845 has much simpler format and rate selection. */ -static void ad1845_playback_format(cs4231_t * chip, snd_pcm_hw_params_t * params, unsigned char format) +static void ad1845_playback_format(struct snd_cs4231 * chip, struct snd_pcm_hw_params *params, unsigned char format) { unsigned long flags; unsigned rate = params_rate(params); @@ -955,7 +955,7 @@ static void ad1845_playback_format(cs4231_t * chip, snd_pcm_hw_params_t * params * Override for the CS4231 capture format function. * The AD1845 has much simpler format and rate selection. */ -static void ad1845_capture_format(cs4231_t * chip, snd_pcm_hw_params_t * params, unsigned char format) +static void ad1845_capture_format(struct snd_cs4231 * chip, struct snd_pcm_hw_params *params, unsigned char format) { unsigned long flags; unsigned rate = params_rate(params); @@ -993,10 +993,10 @@ static void ad1845_capture_format(cs4231_t * chip, snd_pcm_hw_params_t * params, * try to support at least some of the extra bits by overriding * some of the CS4231 callback. */ -static int __devinit create_ad1845(snd_card_t * card, unsigned port, int irq, int dma1) +static int __devinit create_ad1845(struct snd_card *card, unsigned port, int irq, int dma1) { register struct soundscape *sscape = get_card_soundscape(card); - cs4231_t *chip; + struct snd_cs4231 *chip; int err; #define CS4231_SHARE_HARDWARE (CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2) @@ -1009,7 +1009,7 @@ static int __devinit create_ad1845(snd_card_t * card, unsigned port, int irq, in CS4231_HW_DETECT, CS4231_HWSHARE_DMA1, &chip)) == 0) { unsigned long flags; - snd_pcm_t *pcm; + struct snd_pcm *pcm; #define AD1845_FREQ_SEL_ENABLE 0x08 @@ -1115,9 +1115,9 @@ init_params(struct params *params, * Create an ALSA soundcard entry for the SoundScape, using * the given list of port, IRQ and DMA resources. */ -static int __devinit create_sscape(const struct params *params, snd_card_t **rcardp) +static int __devinit create_sscape(const struct params *params, struct snd_card **rcardp) { - snd_card_t *card; + struct snd_card *card; register struct soundscape *sscape; register unsigned dma_cfg; unsigned irq_cfg; @@ -1370,7 +1370,7 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, * Do we know about this sound card already? */ if ( !is_port_known(this->port, sscape_params, sscape_cards) ) { - snd_card_t *card; + struct snd_card *card; ret = create_sscape(this, &card); if (ret < 0) @@ -1394,7 +1394,7 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, static void __devexit sscape_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); pnp_set_card_drvdata(pcard, NULL); snd_card_disconnect(card); @@ -1415,7 +1415,7 @@ static int __init sscape_manual_probe(struct params *params) { int ret; unsigned i; - snd_card_t *card; + struct snd_card *card; for (i = 0; i < SNDRV_CARDS; ++i) { /* -- cgit v1.1 From 11ff5c62b1327cc7bdcfcf66b4b718495fea0043 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:42:36 +0100 Subject: [ALSA] Remove xxx_t typedefs: ISA SB/AD-clone Modules: ALS100 driver,AZT2320 driver,DT019x driver,Sound Galaxy driver Remove xxx_t typedefs from the ISA SB/AD-clone drivers (als100, azt2320, dt019x, sgalaxy). Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/isa/als100.c | 8 ++++---- sound/isa/azt2320.c | 8 ++++---- sound/isa/dt019x.c | 8 ++++---- sound/isa/sgalaxy.c | 14 +++++++------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sound/isa/als100.c b/sound/isa/als100.c index ac8f136..0d709bc 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -203,10 +203,10 @@ static int __init snd_card_als100_probe(int dev, const struct pnp_card_device_id *pid) { int error; - sb_t *chip; - snd_card_t *card; + struct snd_sb *chip; + struct snd_card *card; struct snd_card_als100 *acard; - opl3_t *opl3; + struct snd_opl3 *opl3; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_als100))) == NULL) @@ -299,7 +299,7 @@ static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card, static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c index bb41c6ec..db4e733 100644 --- a/sound/isa/azt2320.c +++ b/sound/isa/azt2320.c @@ -227,10 +227,10 @@ static int __devinit snd_card_azt2320_probe(int dev, const struct pnp_card_device_id *pid) { int error; - snd_card_t *card; + struct snd_card *card; struct snd_card_azt2320 *acard; - cs4231_t *chip; - opl3_t *opl3; + struct snd_cs4231 *chip; + struct snd_opl3 *opl3; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_azt2320))) == NULL) @@ -329,7 +329,7 @@ static int __devinit snd_azt2320_pnp_detect(struct pnp_card_link *card, static void __devexit snd_azt2320_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); diff --git a/sound/isa/dt019x.c b/sound/isa/dt019x.c index db7c339..7559956 100644 --- a/sound/isa/dt019x.c +++ b/sound/isa/dt019x.c @@ -188,10 +188,10 @@ static int __devinit snd_card_dt019x_pnp(int dev, struct snd_card_dt019x *acard, static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { int error; - sb_t *chip; - snd_card_t *card; + struct snd_sb *chip; + struct snd_card *card; struct snd_card_dt019x *acard; - opl3_t *opl3; + struct snd_opl3 *opl3; if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_dt019x))) == NULL) @@ -290,7 +290,7 @@ static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) { - snd_card_t *card = (snd_card_t *) pnp_get_card_drvdata(pcard); + struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); snd_card_disconnect(card); snd_card_free_in_thread(card); } diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 52f2294d..c16b53b 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c @@ -65,7 +65,7 @@ MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); #define SGALAXY_AUXC_LEFT 18 #define SGALAXY_AUXC_RIGHT 19 -static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; +static struct snd_card *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "sgalaxy: " @@ -75,7 +75,7 @@ static snd_card_t *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define AD1848P1( port, x ) ( port + c_d_c_AD1848##x ) -/* from lowlevel/sb/sb.c - to avoid having to allocate a sb_t for the */ +/* from lowlevel/sb/sb.c - to avoid having to allocate a struct snd_sb for the */ /* short time we actually need it.. */ static int snd_sgalaxy_sbdsp_reset(unsigned long port) @@ -180,10 +180,10 @@ AD1848_DOUBLE("Aux Playback Switch", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 7 AD1848_DOUBLE("Aux Playback Volume", 0, SGALAXY_AUXC_LEFT, SGALAXY_AUXC_RIGHT, 0, 0, 31, 0) }; -static int __init snd_sgalaxy_mixer(ad1848_t *chip) +static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id1, id2; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id1, id2; unsigned int idx; int err; @@ -221,8 +221,8 @@ static int __init snd_sgalaxy_probe(int dev) static int possible_irqs[] = {7, 9, 10, 11, -1}; static int possible_dmas[] = {1, 3, 0, -1}; int err, xirq, xdma1; - snd_card_t *card; - ad1848_t *chip; + struct snd_card *card; + struct snd_ad1848 *chip; if (sbport[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR PFX "specify SB port\n"); -- cgit v1.1 From 9f38945fab04a0a0ea50880fa634f9bfa28f6226 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:44:47 +0100 Subject: [ALSA] Remove xxx_t typedefs: AK4531 codec Modules: AK4531 codec Remove xxx_t typedefs from the AK4531 codec support code. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/ak4531_codec.h | 12 ++++----- sound/pci/ac97/ak4531_codec.c | 59 ++++++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/include/sound/ak4531_codec.h b/include/sound/ak4531_codec.h index 8b18992..4e7c661 100644 --- a/include/sound/ak4531_codec.h +++ b/include/sound/ak4531_codec.h @@ -64,17 +64,17 @@ #define AK4531_AD_IN 0x18 /* AD input select */ #define AK4531_MIC_GAIN 0x19 /* MIC amplified gain */ -typedef struct _snd_ak4531 ak4531_t; - -struct _snd_ak4531 { - void (*write) (ak4531_t *ak4531, unsigned short reg, unsigned short val); +struct snd_ak4531 { + void (*write) (struct snd_ak4531 *ak4531, unsigned short reg, + unsigned short val); void *private_data; - void (*private_free) (ak4531_t *ak4531); + void (*private_free) (struct snd_ak4531 *ak4531); /* --- */ unsigned char regs[0x20]; struct semaphore reg_mutex; }; -int snd_ak4531_mixer(snd_card_t * card, ak4531_t * _ak4531, ak4531_t ** rak4531); +int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531, + struct snd_ak4531 **rak4531); #endif /* __SOUND_AK4531_CODEC_H */ diff --git a/sound/pci/ac97/ak4531_codec.c b/sound/pci/ac97/ak4531_codec.c index 4032c57..088d8dc 100644 --- a/sound/pci/ac97/ak4531_codec.c +++ b/sound/pci/ac97/ak4531_codec.c @@ -30,7 +30,7 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("Universal routines for AK4531 codec"); MODULE_LICENSE("GPL"); -static void snd_ak4531_proc_init(snd_card_t * card, ak4531_t * ak4531); +static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531); /* * @@ -38,7 +38,7 @@ static void snd_ak4531_proc_init(snd_card_t * card, ak4531_t * ak4531); #if 0 -static void snd_ak4531_dump(ak4531_t *ak4531) +static void snd_ak4531_dump(struct snd_ak4531 *ak4531) { int idx; @@ -58,7 +58,7 @@ static void snd_ak4531_dump(ak4531_t *ak4531) .get = snd_ak4531_get_single, .put = snd_ak4531_put_single, \ .private_value = reg | (shift << 16) | (mask << 24) | (invert << 22) } -static int snd_ak4531_info_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4531_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -69,9 +69,9 @@ static int snd_ak4531_info_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ak4531_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ak4531_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol); + struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 16) & 0x07; int mask = (kcontrol->private_value >> 24) & 0xff; @@ -88,9 +88,9 @@ static int snd_ak4531_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ak4531_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ak4531_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol); + struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 16) & 0x07; int mask = (kcontrol->private_value >> 24) & 0xff; @@ -117,7 +117,7 @@ static int snd_ak4531_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_ak4531_get_double, .put = snd_ak4531_put_double, \ .private_value = left_reg | (right_reg << 8) | (left_shift << 16) | (right_shift << 19) | (mask << 24) | (invert << 22) } -static int snd_ak4531_info_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4531_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -128,9 +128,9 @@ static int snd_ak4531_info_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ak4531_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ak4531_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol); + struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int left_shift = (kcontrol->private_value >> 16) & 0x07; @@ -152,9 +152,9 @@ static int snd_ak4531_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ak4531_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ak4531_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol); + struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int left_shift = (kcontrol->private_value >> 16) & 0x07; @@ -194,7 +194,7 @@ static int snd_ak4531_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_ak4531_get_input_sw, .put = snd_ak4531_put_input_sw, \ .private_value = reg1 | (reg2 << 8) | (left_shift << 16) | (right_shift << 24) } -static int snd_ak4531_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ak4531_info_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 4; @@ -203,9 +203,9 @@ static int snd_ak4531_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_info return 0; } -static int snd_ak4531_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ak4531_get_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol); + struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); int reg1 = kcontrol->private_value & 0xff; int reg2 = (kcontrol->private_value >> 8) & 0xff; int left_shift = (kcontrol->private_value >> 16) & 0x0f; @@ -220,9 +220,9 @@ static int snd_ak4531_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_ak4531_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ak4531_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ak4531_t *ak4531 = snd_kcontrol_chip(kcontrol); + struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol); int reg1 = kcontrol->private_value & 0xff; int reg2 = (kcontrol->private_value >> 8) & 0xff; int left_shift = (kcontrol->private_value >> 16) & 0x0f; @@ -244,7 +244,7 @@ static int snd_ak4531_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return change; } -static snd_kcontrol_new_t snd_ak4531_controls[] = { +static struct snd_kcontrol_new snd_ak4531_controls[] = { AK4531_DOUBLE("Master Playback Switch", 0, AK4531_LMASTER, AK4531_RMASTER, 7, 7, 1, 1), AK4531_DOUBLE("Master Playback Volume", 0, AK4531_LMASTER, AK4531_RMASTER, 0, 0, 0x1f, 1), @@ -300,7 +300,7 @@ AK4531_SINGLE("AD Input Select", 0, AK4531_AD_IN, 0, 1, 0), AK4531_SINGLE("Mic Boost (+30dB)", 0, AK4531_MIC_GAIN, 0, 1, 0) }; -static int snd_ak4531_free(ak4531_t *ak4531) +static int snd_ak4531_free(struct snd_ak4531 *ak4531) { if (ak4531) { if (ak4531->private_free) @@ -310,9 +310,9 @@ static int snd_ak4531_free(ak4531_t *ak4531) return 0; } -static int snd_ak4531_dev_free(snd_device_t *device) +static int snd_ak4531_dev_free(struct snd_device *device) { - ak4531_t *ak4531 = device->device_data; + struct snd_ak4531 *ak4531 = device->device_data; return snd_ak4531_free(ak4531); } @@ -345,12 +345,13 @@ static u8 snd_ak4531_initial_map[0x19 + 1] = { 0x01 /* 19: Mic Amp Setup */ }; -int snd_ak4531_mixer(snd_card_t * card, ak4531_t * _ak4531, ak4531_t ** rak4531) +int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531, + struct snd_ak4531 **rak4531) { unsigned int idx; int err; - ak4531_t * ak4531; - static snd_device_ops_t ops = { + struct snd_ak4531 *ak4531; + static struct snd_device_ops ops = { .dev_free = snd_ak4531_dev_free, }; @@ -398,10 +399,10 @@ int snd_ak4531_mixer(snd_card_t * card, ak4531_t * _ak4531, ak4531_t ** rak4531) */ -static void snd_ak4531_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ak4531_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ak4531_t *ak4531 = entry->private_data; + struct snd_ak4531 *ak4531 = entry->private_data; snd_iprintf(buffer, "Asahi Kasei AK4531\n\n"); snd_iprintf(buffer, "Recording source : %s\n" @@ -410,9 +411,9 @@ static void snd_ak4531_proc_read(snd_info_entry_t *entry, ak4531->regs[AK4531_MIC_GAIN] & 1 ? "+30dB" : "+0dB"); } -static void snd_ak4531_proc_init(snd_card_t * card, ak4531_t * ak4531) +static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(card, "ak4531", &entry)) snd_info_set_text_ops(entry, ak4531, 1024, snd_ak4531_proc_read); -- cgit v1.1 From af26367f69a474ed809e4a59abb5855b47daaff4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:46:59 +0100 Subject: [ALSA] Remove xxx_t typedefs: VXdriver Remove xxx_t typedefs from the VXdriver codes (vx_core support, vx222 and vxpocket). Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/vx_core.h | 123 ++++++++++++++------------- sound/drivers/vx/vx_core.c | 58 ++++++------- sound/drivers/vx/vx_hwdep.c | 24 +++--- sound/drivers/vx/vx_mixer.c | 162 +++++++++++++++++------------------ sound/drivers/vx/vx_pcm.c | 200 ++++++++++++++++++++++++-------------------- sound/drivers/vx/vx_uer.c | 22 ++--- sound/pci/vx222/vx222.c | 16 ++-- sound/pci/vx222/vx222.h | 2 +- sound/pci/vx222/vx222_ops.c | 84 +++++++++---------- sound/pcmcia/vx/vxp_mixer.c | 26 +++--- sound/pcmcia/vx/vxp_ops.c | 48 +++++------ sound/pcmcia/vx/vxpocket.c | 26 +++--- sound/pcmcia/vx/vxpocket.h | 8 +- 13 files changed, 410 insertions(+), 389 deletions(-) diff --git a/include/sound/vx_core.h b/include/sound/vx_core.h index 43c901b..0a85c37 100644 --- a/include/sound/vx_core.h +++ b/include/sound/vx_core.h @@ -36,9 +36,6 @@ struct firmware; struct device; -typedef struct snd_vx_core vx_core_t; -typedef struct vx_pipe vx_pipe_t; - #define VX_DRIVER_VERSION 0x010000 /* 1.0.0 */ /* @@ -76,7 +73,7 @@ struct vx_pipe { int channels; unsigned int differed_type; pcx_time_t pcx_time; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int hbuf_size; /* H-buffer size in bytes */ int buffer_bytes; /* the ALSA pcm buffer size in bytes */ @@ -88,36 +85,38 @@ struct vx_pipe { u64 cur_count; /* current sample position (for playback) */ unsigned int references; /* an output pipe may be used for monitoring and/or playback */ - vx_pipe_t *monitoring_pipe; /* pointer to the monitoring pipe (capture pipe only)*/ + struct vx_pipe *monitoring_pipe; /* pointer to the monitoring pipe (capture pipe only)*/ struct tasklet_struct start_tq; }; +struct vx_core; + struct snd_vx_ops { /* low-level i/o */ - unsigned char (*in8)(vx_core_t *chip, int reg); - unsigned int (*in32)(vx_core_t *chip, int reg); - void (*out8)(vx_core_t *chip, int reg, unsigned char val); - void (*out32)(vx_core_t *chip, int reg, unsigned int val); + unsigned char (*in8)(struct vx_core *chip, int reg); + unsigned int (*in32)(struct vx_core *chip, int reg); + void (*out8)(struct vx_core *chip, int reg, unsigned char val); + void (*out32)(struct vx_core *chip, int reg, unsigned int val); /* irq */ - int (*test_and_ack)(vx_core_t *chip); - void (*validate_irq)(vx_core_t *chip, int enable); + int (*test_and_ack)(struct vx_core *chip); + void (*validate_irq)(struct vx_core *chip, int enable); /* codec */ - void (*write_codec)(vx_core_t *chip, int codec, unsigned int data); - void (*akm_write)(vx_core_t *chip, int reg, unsigned int data); - void (*reset_codec)(vx_core_t *chip); - void (*change_audio_source)(vx_core_t *chip, int src); - void (*set_clock_source)(vx_core_t *chp, int src); + void (*write_codec)(struct vx_core *chip, int codec, unsigned int data); + void (*akm_write)(struct vx_core *chip, int reg, unsigned int data); + void (*reset_codec)(struct vx_core *chip); + void (*change_audio_source)(struct vx_core *chip, int src); + void (*set_clock_source)(struct vx_core *chp, int src); /* chip init */ - int (*load_dsp)(vx_core_t *chip, int idx, const struct firmware *fw); - void (*reset_dsp)(vx_core_t *chip); - void (*reset_board)(vx_core_t *chip, int cold_reset); - int (*add_controls)(vx_core_t *chip); + int (*load_dsp)(struct vx_core *chip, int idx, const struct firmware *fw); + void (*reset_dsp)(struct vx_core *chip); + void (*reset_board)(struct vx_core *chip, int cold_reset); + int (*add_controls)(struct vx_core *chip); /* pcm */ - void (*dma_write)(vx_core_t *chip, snd_pcm_runtime_t *runtime, - vx_pipe_t *pipe, int count); - void (*dma_read)(vx_core_t *chip, snd_pcm_runtime_t *runtime, - vx_pipe_t *pipe, int count); + void (*dma_write)(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int count); + void (*dma_read)(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int count); }; struct snd_vx_hardware { @@ -158,10 +157,10 @@ enum { /* min/max values for analog output for old codecs */ #define VX_ANALOG_OUT_LEVEL_MAX 0xe3 -struct snd_vx_core { +struct vx_core { /* ALSA stuff */ - snd_card_t *card; - snd_pcm_t *pcm[VX_MAX_CODECS]; + struct snd_card *card; + struct snd_pcm *pcm[VX_MAX_CODECS]; int type; /* VX_TYPE_XXX */ int irq; @@ -179,7 +178,7 @@ struct snd_vx_core { unsigned int pcm_running; struct device *dev; - snd_hwdep_t *hwdep; + struct snd_hwdep *hwdep; struct vx_rmh irq_rmh; /* RMH used in interrupts */ @@ -216,14 +215,14 @@ struct snd_vx_core { /* * constructor */ -vx_core_t *snd_vx_create(snd_card_t *card, struct snd_vx_hardware *hw, - struct snd_vx_ops *ops, int extra_size); -int snd_vx_setup_firmware(vx_core_t *chip); -int snd_vx_load_boot_image(vx_core_t *chip, const struct firmware *dsp); -int snd_vx_dsp_boot(vx_core_t *chip, const struct firmware *dsp); -int snd_vx_dsp_load(vx_core_t *chip, const struct firmware *dsp); +struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw, + struct snd_vx_ops *ops, int extra_size); +int snd_vx_setup_firmware(struct vx_core *chip); +int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *dsp); +int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *dsp); +int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp); -void snd_vx_free_firmware(vx_core_t *chip); +void snd_vx_free_firmware(struct vx_core *chip); /* * interrupt handler; exported for pcmcia @@ -233,37 +232,37 @@ irqreturn_t snd_vx_irq_handler(int irq, void *dev, struct pt_regs *regs); /* * lowlevel functions */ -static inline int vx_test_and_ack(vx_core_t *chip) +static inline int vx_test_and_ack(struct vx_core *chip) { snd_assert(chip->ops->test_and_ack, return -ENXIO); return chip->ops->test_and_ack(chip); } -static inline void vx_validate_irq(vx_core_t *chip, int enable) +static inline void vx_validate_irq(struct vx_core *chip, int enable) { snd_assert(chip->ops->validate_irq, return); chip->ops->validate_irq(chip, enable); } -static inline unsigned char snd_vx_inb(vx_core_t *chip, int reg) +static inline unsigned char snd_vx_inb(struct vx_core *chip, int reg) { snd_assert(chip->ops->in8, return 0); return chip->ops->in8(chip, reg); } -static inline unsigned int snd_vx_inl(vx_core_t *chip, int reg) +static inline unsigned int snd_vx_inl(struct vx_core *chip, int reg) { snd_assert(chip->ops->in32, return 0); return chip->ops->in32(chip, reg); } -static inline void snd_vx_outb(vx_core_t *chip, int reg, unsigned char val) +static inline void snd_vx_outb(struct vx_core *chip, int reg, unsigned char val) { snd_assert(chip->ops->out8, return); chip->ops->out8(chip, reg, val); } -static inline void snd_vx_outl(vx_core_t *chip, int reg, unsigned int val) +static inline void snd_vx_outl(struct vx_core *chip, int reg, unsigned int val) { snd_assert(chip->ops->out32, return); chip->ops->out32(chip, reg, val); @@ -274,25 +273,25 @@ static inline void snd_vx_outl(vx_core_t *chip, int reg, unsigned int val) #define vx_inl(chip,reg) snd_vx_inl(chip, VX_##reg) #define vx_outl(chip,reg,val) snd_vx_outl(chip, VX_##reg,val) -static inline void vx_reset_dsp(vx_core_t *chip) +static inline void vx_reset_dsp(struct vx_core *chip) { snd_assert(chip->ops->reset_dsp, return); chip->ops->reset_dsp(chip); } -int vx_send_msg(vx_core_t *chip, struct vx_rmh *rmh); -int vx_send_msg_nolock(vx_core_t *chip, struct vx_rmh *rmh); -int vx_send_rih(vx_core_t *chip, int cmd); -int vx_send_rih_nolock(vx_core_t *chip, int cmd); +int vx_send_msg(struct vx_core *chip, struct vx_rmh *rmh); +int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh); +int vx_send_rih(struct vx_core *chip, int cmd); +int vx_send_rih_nolock(struct vx_core *chip, int cmd); -void vx_reset_codec(vx_core_t *chip, int cold_reset); +void vx_reset_codec(struct vx_core *chip, int cold_reset); /* * check the bit on the specified register * returns zero if a bit matches, or a negative error code. * exported for vxpocket driver */ -int snd_vx_check_reg_bit(vx_core_t *chip, int reg, int mask, int bit, int time); +int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int time); #define vx_check_isr(chip,mask,bit,time) snd_vx_check_reg_bit(chip, VX_ISR, mask, bit, time) #define vx_wait_isr_bit(chip,bit) vx_check_isr(chip, bit, bit, 200) #define vx_wait_for_rx_full(chip) vx_wait_isr_bit(chip, ISR_RX_FULL) @@ -301,15 +300,15 @@ int snd_vx_check_reg_bit(vx_core_t *chip, int reg, int mask, int bit, int time); /* * pseudo-DMA transfer */ -static inline void vx_pseudo_dma_write(vx_core_t *chip, snd_pcm_runtime_t *runtime, - vx_pipe_t *pipe, int count) +static inline void vx_pseudo_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int count) { snd_assert(chip->ops->dma_write, return); chip->ops->dma_write(chip, runtime, pipe, count); } -static inline void vx_pseudo_dma_read(vx_core_t *chip, snd_pcm_runtime_t *runtime, - vx_pipe_t *pipe, int count) +static inline void vx_pseudo_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int count) { snd_assert(chip->ops->dma_read, return); chip->ops->dma_read(chip, runtime, pipe, count); @@ -327,24 +326,24 @@ static inline void vx_pseudo_dma_read(vx_core_t *chip, snd_pcm_runtime_t *runtim /* * pcm stuff */ -int snd_vx_pcm_new(vx_core_t *chip); -void vx_pcm_update_intr(vx_core_t *chip, unsigned int events); +int snd_vx_pcm_new(struct vx_core *chip); +void vx_pcm_update_intr(struct vx_core *chip, unsigned int events); /* * mixer stuff */ -int snd_vx_mixer_new(vx_core_t *chip); -void vx_toggle_dac_mute(vx_core_t *chip, int mute); -int vx_sync_audio_source(vx_core_t *chip); -int vx_set_monitor_level(vx_core_t *chip, int audio, int level, int active); +int snd_vx_mixer_new(struct vx_core *chip); +void vx_toggle_dac_mute(struct vx_core *chip, int mute); +int vx_sync_audio_source(struct vx_core *chip); +int vx_set_monitor_level(struct vx_core *chip, int audio, int level, int active); /* * IEC958 & clock stuff */ -void vx_set_iec958_status(vx_core_t *chip, unsigned int bits); -int vx_set_clock(vx_core_t *chip, unsigned int freq); -void vx_set_internal_clock(vx_core_t *chip, unsigned int freq); -int vx_change_frequency(vx_core_t *chip); +void vx_set_iec958_status(struct vx_core *chip, unsigned int bits); +int vx_set_clock(struct vx_core *chip, unsigned int freq); +void vx_set_internal_clock(struct vx_core *chip, unsigned int freq); +int vx_change_frequency(struct vx_core *chip); /* diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index e6e4cf9..5abf423 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -49,7 +49,7 @@ MODULE_LICENSE("GPL"); * * returns zero if a bit matches, or a negative error code. */ -int snd_vx_check_reg_bit(vx_core_t *chip, int reg, int mask, int bit, int time) +int snd_vx_check_reg_bit(struct vx_core *chip, int reg, int mask, int bit, int time) { unsigned long end_time = jiffies + (time * HZ + 999) / 1000; #ifdef CONFIG_SND_DEBUG @@ -78,7 +78,7 @@ int snd_vx_check_reg_bit(vx_core_t *chip, int reg, int mask, int bit, int time) * returns 0 if successful, or a negative error code. * */ -static int vx_send_irq_dsp(vx_core_t *chip, int num) +static int vx_send_irq_dsp(struct vx_core *chip, int num) { int nirq; @@ -99,7 +99,7 @@ static int vx_send_irq_dsp(vx_core_t *chip, int num) * * returns 0 if successful, or a negative error code. */ -static int vx_reset_chk(vx_core_t *chip) +static int vx_reset_chk(struct vx_core *chip) { /* Reset irq CHK */ if (vx_send_irq_dsp(chip, IRQ_RESET_CHK) < 0) @@ -118,7 +118,7 @@ static int vx_reset_chk(vx_core_t *chip) * the error code can be VX-specific, retrieved via vx_get_error(). * NB: call with spinlock held! */ -static int vx_transfer_end(vx_core_t *chip, int cmd) +static int vx_transfer_end(struct vx_core *chip, int cmd) { int err; @@ -156,7 +156,7 @@ static int vx_transfer_end(vx_core_t *chip, int cmd) * the error code can be VX-specific, retrieved via vx_get_error(). * NB: call with spinlock held! */ -static int vx_read_status(vx_core_t *chip, struct vx_rmh *rmh) +static int vx_read_status(struct vx_core *chip, struct vx_rmh *rmh) { int i, err, val, size; @@ -236,7 +236,7 @@ static int vx_read_status(vx_core_t *chip, struct vx_rmh *rmh) * * this function doesn't call spinlock at all. */ -int vx_send_msg_nolock(vx_core_t *chip, struct vx_rmh *rmh) +int vx_send_msg_nolock(struct vx_core *chip, struct vx_rmh *rmh) { int i, err; @@ -341,7 +341,7 @@ int vx_send_msg_nolock(vx_core_t *chip, struct vx_rmh *rmh) * returns 0 if successful, or a negative error code. * see vx_send_msg_nolock(). */ -int vx_send_msg(vx_core_t *chip, struct vx_rmh *rmh) +int vx_send_msg(struct vx_core *chip, struct vx_rmh *rmh) { unsigned long flags; int err; @@ -364,7 +364,7 @@ int vx_send_msg(vx_core_t *chip, struct vx_rmh *rmh) * * unlike RMH, no command is sent to DSP. */ -int vx_send_rih_nolock(vx_core_t *chip, int cmd) +int vx_send_rih_nolock(struct vx_core *chip, int cmd) { int err; @@ -401,7 +401,7 @@ int vx_send_rih_nolock(vx_core_t *chip, int cmd) * * see vx_send_rih_nolock(). */ -int vx_send_rih(vx_core_t *chip, int cmd) +int vx_send_rih(struct vx_core *chip, int cmd) { unsigned long flags; int err; @@ -418,7 +418,7 @@ int vx_send_rih(vx_core_t *chip, int cmd) * snd_vx_boot_xilinx - boot up the xilinx interface * @boot: the boot record to load */ -int snd_vx_load_boot_image(vx_core_t *chip, const struct firmware *boot) +int snd_vx_load_boot_image(struct vx_core *chip, const struct firmware *boot) { unsigned int i; int no_fillup = vx_has_new_dsp(chip); @@ -470,7 +470,7 @@ int snd_vx_load_boot_image(vx_core_t *chip, const struct firmware *boot) * * called from irq handler only */ -static int vx_test_irq_src(vx_core_t *chip, unsigned int *ret) +static int vx_test_irq_src(struct vx_core *chip, unsigned int *ret) { int err; @@ -491,7 +491,7 @@ static int vx_test_irq_src(vx_core_t *chip, unsigned int *ret) */ static void vx_interrupt(unsigned long private_data) { - vx_core_t *chip = (vx_core_t *) private_data; + struct vx_core *chip = (struct vx_core *) private_data; unsigned int events; if (chip->chip_status & VX_STAT_IS_STALE) @@ -535,7 +535,7 @@ static void vx_interrupt(unsigned long private_data) */ irqreturn_t snd_vx_irq_handler(int irq, void *dev, struct pt_regs *regs) { - vx_core_t *chip = dev; + struct vx_core *chip = dev; if (! (chip->chip_status & VX_STAT_CHIP_INIT) || (chip->chip_status & VX_STAT_IS_STALE)) @@ -548,7 +548,7 @@ irqreturn_t snd_vx_irq_handler(int irq, void *dev, struct pt_regs *regs) /* */ -static void vx_reset_board(vx_core_t *chip, int cold_reset) +static void vx_reset_board(struct vx_core *chip, int cold_reset) { snd_assert(chip->ops->reset_board, return); @@ -587,9 +587,9 @@ static void vx_reset_board(vx_core_t *chip, int cold_reset) * proc interface */ -static void vx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void vx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - vx_core_t *chip = entry->private_data; + struct vx_core *chip = entry->private_data; static char *audio_src_vxp[] = { "Line", "Mic", "Digital" }; static char *audio_src_vx2[] = { "Analog", "Analog", "Digital" }; static char *clock_mode[] = { "Auto", "Internal", "External" }; @@ -630,9 +630,9 @@ static void vx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) chip->ibl.granularity); } -static void vx_proc_init(vx_core_t *chip) +static void vx_proc_init(struct vx_core *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "vx-status", &entry)) snd_info_set_text_ops(entry, chip, 1024, vx_proc_read); @@ -642,7 +642,7 @@ static void vx_proc_init(vx_core_t *chip) /** * snd_vx_dsp_boot - load the DSP boot */ -int snd_vx_dsp_boot(vx_core_t *chip, const struct firmware *boot) +int snd_vx_dsp_boot(struct vx_core *chip, const struct firmware *boot) { int err; int cold_reset = !(chip->chip_status & VX_STAT_DEVICE_INIT); @@ -660,7 +660,7 @@ int snd_vx_dsp_boot(vx_core_t *chip, const struct firmware *boot) /** * snd_vx_dsp_load - load the DSP image */ -int snd_vx_dsp_load(vx_core_t *chip, const struct firmware *dsp) +int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp) { unsigned int i; int err; @@ -709,9 +709,9 @@ int snd_vx_dsp_load(vx_core_t *chip, const struct firmware *dsp) /* * suspend */ -static int snd_vx_suspend(snd_card_t *card, pm_message_t state) +static int snd_vx_suspend(struct snd_card *card, pm_message_t state) { - vx_core_t *chip = card->pm_private_data; + struct vx_core *chip = card->pm_private_data; unsigned int i; snd_assert(chip, return -EINVAL); @@ -726,9 +726,9 @@ static int snd_vx_suspend(snd_card_t *card, pm_message_t state) /* * resume */ -static int snd_vx_resume(snd_card_t *card) +static int snd_vx_resume(struct snd_card *card) { - vx_core_t *chip = card->pm_private_data; + struct vx_core *chip = card->pm_private_data; int i, err; snd_assert(chip, return -EINVAL); @@ -754,7 +754,7 @@ static int snd_vx_resume(snd_card_t *card) #endif /** - * snd_vx_create - constructor for vx_core_t + * snd_vx_create - constructor for struct vx_core * @hw: hardware specific record * * this function allocates the instance and prepare for the hardware @@ -762,11 +762,11 @@ static int snd_vx_resume(snd_card_t *card) * * return the instance pointer if successful, NULL in error. */ -vx_core_t *snd_vx_create(snd_card_t *card, struct snd_vx_hardware *hw, - struct snd_vx_ops *ops, - int extra_size) +struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw, + struct snd_vx_ops *ops, + int extra_size) { - vx_core_t *chip; + struct vx_core *chip; snd_assert(card && hw && ops, return NULL); diff --git a/sound/drivers/vx/vx_hwdep.c b/sound/drivers/vx/vx_hwdep.c index c4993b0..d837783 100644 --- a/sound/drivers/vx/vx_hwdep.c +++ b/sound/drivers/vx/vx_hwdep.c @@ -30,7 +30,7 @@ #ifdef SND_VX_FW_LOADER -int snd_vx_setup_firmware(vx_core_t *chip) +int snd_vx_setup_firmware(struct vx_core *chip) { static char *fw_files[VX_TYPE_NUMS][4] = { [VX_TYPE_BOARD] = { @@ -95,7 +95,7 @@ int snd_vx_setup_firmware(vx_core_t *chip) } /* exported */ -void snd_vx_free_firmware(vx_core_t *chip) +void snd_vx_free_firmware(struct vx_core *chip) { #ifdef CONFIG_PM int i; @@ -106,17 +106,18 @@ void snd_vx_free_firmware(vx_core_t *chip) #else /* old style firmware loading */ -static int vx_hwdep_open(snd_hwdep_t *hw, struct file *file) +static int vx_hwdep_open(struct snd_hwdep *hw, struct file *file) { return 0; } -static int vx_hwdep_release(snd_hwdep_t *hw, struct file *file) +static int vx_hwdep_release(struct snd_hwdep *hw, struct file *file) { return 0; } -static int vx_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *info) +static int vx_hwdep_dsp_status(struct snd_hwdep *hw, + struct snd_hwdep_dsp_status *info) { static char *type_ids[VX_TYPE_NUMS] = { [VX_TYPE_BOARD] = "vxboard", @@ -125,7 +126,7 @@ static int vx_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *info) [VX_TYPE_VXPOCKET] = "vxpocket", [VX_TYPE_VXP440] = "vxp440", }; - vx_core_t *vx = hw->private_data; + struct vx_core *vx = hw->private_data; snd_assert(type_ids[vx->type], return -EINVAL); strcpy(info->id, type_ids[vx->type]); @@ -147,9 +148,10 @@ static void free_fw(const struct firmware *fw) } } -static int vx_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) +static int vx_hwdep_dsp_load(struct snd_hwdep *hw, + struct snd_hwdep_dsp_image *dsp) { - vx_core_t *vx = hw->private_data; + struct vx_core *vx = hw->private_data; int index, err; struct firmware *fw; @@ -216,10 +218,10 @@ static int vx_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) /* exported */ -int snd_vx_setup_firmware(vx_core_t *chip) +int snd_vx_setup_firmware(struct vx_core *chip) { int err; - snd_hwdep_t *hw; + struct snd_hwdep *hw; if ((err = snd_hwdep_new(chip->card, SND_VX_HWDEP_ID, 0, &hw)) < 0) return err; @@ -238,7 +240,7 @@ int snd_vx_setup_firmware(vx_core_t *chip) } /* exported */ -void snd_vx_free_firmware(vx_core_t *chip) +void snd_vx_free_firmware(struct vx_core *chip) { #ifdef CONFIG_PM int i; diff --git a/sound/drivers/vx/vx_mixer.c b/sound/drivers/vx/vx_mixer.c index 19fc68c..8ec2c60 100644 --- a/sound/drivers/vx/vx_mixer.c +++ b/sound/drivers/vx/vx_mixer.c @@ -30,7 +30,7 @@ /* * write a codec data (24bit) */ -static void vx_write_codec_reg(vx_core_t *chip, int codec, unsigned int data) +static void vx_write_codec_reg(struct vx_core *chip, int codec, unsigned int data) { unsigned long flags; @@ -47,7 +47,7 @@ static void vx_write_codec_reg(vx_core_t *chip, int codec, unsigned int data) /* * Data type used to access the Codec */ -typedef union { +union vx_codec_data { u32 l; #ifdef SNDRV_BIG_ENDIAN struct w { @@ -72,7 +72,7 @@ typedef union { u8 hh; } b; #endif -} vx_codec_data_t; +}; #define SET_CDC_DATA_SEL(di,s) ((di).b.mh = (u8) (s)) #define SET_CDC_DATA_REG(di,r) ((di).b.ml = (u8) (r)) @@ -85,9 +85,9 @@ typedef union { * @reg: register index * @val: data value */ -static void vx_set_codec_reg(vx_core_t *chip, int codec, int reg, int val) +static void vx_set_codec_reg(struct vx_core *chip, int codec, int reg, int val) { - vx_codec_data_t data; + union vx_codec_data data; /* DAC control register */ SET_CDC_DATA_INIT(data); SET_CDC_DATA_REG(data, reg); @@ -102,7 +102,7 @@ static void vx_set_codec_reg(vx_core_t *chip, int codec, int reg, int val) * @left: left output level, 0 = mute * @right: right output level */ -static void vx_set_analog_output_level(vx_core_t *chip, int codec, int left, int right) +static void vx_set_analog_output_level(struct vx_core *chip, int codec, int left, int right) { left = chip->hw->output_level_max - left; right = chip->hw->output_level_max - right; @@ -126,7 +126,7 @@ static void vx_set_analog_output_level(vx_core_t *chip, int codec, int left, int #define DAC_ATTEN_MIN 0x08 #define DAC_ATTEN_MAX 0x38 -void vx_toggle_dac_mute(vx_core_t *chip, int mute) +void vx_toggle_dac_mute(struct vx_core *chip, int mute) { unsigned int i; for (i = 0; i < chip->hw->num_codecs; i++) { @@ -141,7 +141,7 @@ void vx_toggle_dac_mute(vx_core_t *chip, int mute) /* * vx_reset_codec - reset and initialize the codecs */ -void vx_reset_codec(vx_core_t *chip, int cold_reset) +void vx_reset_codec(struct vx_core *chip, int cold_reset) { unsigned int i; int port = chip->type >= VX_TYPE_VXPOCKET ? 0x75 : 0x65; @@ -175,7 +175,7 @@ void vx_reset_codec(vx_core_t *chip, int cold_reset) * change the audio input source * @src: the target source (VX_AUDIO_SRC_XXX) */ -static void vx_change_audio_source(vx_core_t *chip, int src) +static void vx_change_audio_source(struct vx_core *chip, int src) { unsigned long flags; @@ -192,7 +192,7 @@ static void vx_change_audio_source(vx_core_t *chip, int src) * change the audio source if necessary and possible * returns 1 if the source is actually changed. */ -int vx_sync_audio_source(vx_core_t *chip) +int vx_sync_audio_source(struct vx_core *chip) { if (chip->audio_source_target == chip->audio_source || chip->pcm_running) @@ -217,7 +217,7 @@ struct vx_audio_level { short monitor_level; }; -static int vx_adjust_audio_level(vx_core_t *chip, int audio, int capture, +static int vx_adjust_audio_level(struct vx_core *chip, int audio, int capture, struct vx_audio_level *info) { struct vx_rmh rmh; @@ -256,7 +256,7 @@ static int vx_adjust_audio_level(vx_core_t *chip, int audio, int capture, #if 0 // not used -static int vx_read_audio_level(vx_core_t *chip, int audio, int capture, +static int vx_read_audio_level(struct vx_core *chip, int audio, int capture, struct vx_audio_level *info) { int err; @@ -283,7 +283,7 @@ static int vx_read_audio_level(vx_core_t *chip, int audio, int capture, * set the monitoring level and mute state of the given audio * no more static, because must be called from vx_pcm to demute monitoring */ -int vx_set_monitor_level(vx_core_t *chip, int audio, int level, int active) +int vx_set_monitor_level(struct vx_core *chip, int audio, int level, int active) { struct vx_audio_level info; @@ -301,7 +301,7 @@ int vx_set_monitor_level(vx_core_t *chip, int audio, int level, int active) /* * set the mute status of the given audio */ -static int vx_set_audio_switch(vx_core_t *chip, int audio, int active) +static int vx_set_audio_switch(struct vx_core *chip, int audio, int active) { struct vx_audio_level info; @@ -315,7 +315,7 @@ static int vx_set_audio_switch(vx_core_t *chip, int audio, int active) /* * set the mute status of the given audio */ -static int vx_set_audio_gain(vx_core_t *chip, int audio, int capture, int level) +static int vx_set_audio_gain(struct vx_core *chip, int audio, int capture, int level) { struct vx_audio_level info; @@ -329,7 +329,7 @@ static int vx_set_audio_gain(vx_core_t *chip, int audio, int capture, int level) /* * reset all audio levels */ -static void vx_reset_audio_levels(vx_core_t *chip) +static void vx_reset_audio_levels(struct vx_core *chip) { unsigned int i, c; struct vx_audio_level info; @@ -375,7 +375,7 @@ struct vx_vu_meter { * @capture: 0 = playback, 1 = capture operation * @info: the array of vx_vu_meter records (size = 2). */ -static int vx_get_audio_vu_meter(vx_core_t *chip, int audio, int capture, struct vx_vu_meter *info) +static int vx_get_audio_vu_meter(struct vx_core *chip, int audio, int capture, struct vx_vu_meter *info) { struct vx_rmh rmh; int i, err; @@ -413,9 +413,9 @@ static int vx_get_audio_vu_meter(vx_core_t *chip, int audio, int capture, struct /* * output level control */ -static int vx_output_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_output_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; uinfo->value.integer.min = 0; @@ -423,9 +423,9 @@ static int vx_output_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *u return 0; } -static int vx_output_level_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_output_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int codec = kcontrol->id.index; down(&chip->mixer_mutex); ucontrol->value.integer.value[0] = chip->output_level[codec][0]; @@ -434,9 +434,9 @@ static int vx_output_level_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u return 0; } -static int vx_output_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_output_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int codec = kcontrol->id.index; down(&chip->mixer_mutex); if (ucontrol->value.integer.value[0] != chip->output_level[codec][0] || @@ -453,7 +453,7 @@ static int vx_output_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u return 0; } -static snd_kcontrol_new_t vx_control_output_level = { +static struct snd_kcontrol_new vx_control_output_level = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Volume", .info = vx_output_level_info, @@ -464,7 +464,7 @@ static snd_kcontrol_new_t vx_control_output_level = { /* * audio source select */ -static int vx_audio_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_audio_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts_mic[3] = { "Digital", "Line", "Mic" @@ -472,7 +472,7 @@ static int vx_audio_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinf static char *texts_vx2[2] = { "Digital", "Analog" }; - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -492,16 +492,16 @@ static int vx_audio_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinf return 0; } -static int vx_audio_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_audio_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = chip->audio_source_target; return 0; } -static int vx_audio_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_audio_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); down(&chip->mixer_mutex); if (chip->audio_source_target != ucontrol->value.enumerated.item[0]) { chip->audio_source_target = ucontrol->value.enumerated.item[0]; @@ -513,7 +513,7 @@ static int vx_audio_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon return 0; } -static snd_kcontrol_new_t vx_control_audio_src = { +static struct snd_kcontrol_new vx_control_audio_src = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Source", .info = vx_audio_src_info, @@ -524,7 +524,7 @@ static snd_kcontrol_new_t vx_control_audio_src = { /* * clock mode selection */ -static int vx_clock_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_clock_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "Auto", "Internal", "External" @@ -540,16 +540,16 @@ static int vx_clock_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uin return 0; } -static int vx_clock_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_clock_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = chip->clock_mode; return 0; } -static int vx_clock_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_clock_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); down(&chip->mixer_mutex); if (chip->clock_mode != ucontrol->value.enumerated.item[0]) { chip->clock_mode = ucontrol->value.enumerated.item[0]; @@ -561,7 +561,7 @@ static int vx_clock_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return 0; } -static snd_kcontrol_new_t vx_control_clock_mode = { +static struct snd_kcontrol_new vx_control_clock_mode = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Clock Mode", .info = vx_clock_mode_info, @@ -572,7 +572,7 @@ static snd_kcontrol_new_t vx_control_clock_mode = { /* * Audio Gain */ -static int vx_audio_gain_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_audio_gain_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -581,9 +581,9 @@ static int vx_audio_gain_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uin return 0; } -static int vx_audio_gain_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_audio_gain_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int audio = kcontrol->private_value & 0xff; int capture = (kcontrol->private_value >> 8) & 1; @@ -594,9 +594,9 @@ static int vx_audio_gain_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return 0; } -static int vx_audio_gain_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_audio_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int audio = kcontrol->private_value & 0xff; int capture = (kcontrol->private_value >> 8) & 1; @@ -612,9 +612,9 @@ static int vx_audio_gain_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return 0; } -static int vx_audio_monitor_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_audio_monitor_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int audio = kcontrol->private_value & 0xff; down(&chip->mixer_mutex); @@ -624,9 +624,9 @@ static int vx_audio_monitor_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int vx_audio_monitor_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_audio_monitor_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int audio = kcontrol->private_value & 0xff; down(&chip->mixer_mutex); @@ -643,7 +643,7 @@ static int vx_audio_monitor_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int vx_audio_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_audio_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -652,9 +652,9 @@ static int vx_audio_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo return 0; } -static int vx_audio_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_audio_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int audio = kcontrol->private_value & 0xff; down(&chip->mixer_mutex); @@ -664,9 +664,9 @@ static int vx_audio_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int vx_audio_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int audio = kcontrol->private_value & 0xff; down(&chip->mixer_mutex); @@ -681,9 +681,9 @@ static int vx_audio_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int vx_monitor_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_monitor_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int audio = kcontrol->private_value & 0xff; down(&chip->mixer_mutex); @@ -693,9 +693,9 @@ static int vx_monitor_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return 0; } -static int vx_monitor_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); int audio = kcontrol->private_value & 0xff; down(&chip->mixer_mutex); @@ -712,28 +712,28 @@ static int vx_monitor_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return 0; } -static snd_kcontrol_new_t vx_control_audio_gain = { +static struct snd_kcontrol_new vx_control_audio_gain = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, /* name will be filled later */ .info = vx_audio_gain_info, .get = vx_audio_gain_get, .put = vx_audio_gain_put }; -static snd_kcontrol_new_t vx_control_output_switch = { +static struct snd_kcontrol_new vx_control_output_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Switch", .info = vx_audio_sw_info, .get = vx_audio_sw_get, .put = vx_audio_sw_put }; -static snd_kcontrol_new_t vx_control_monitor_gain = { +static struct snd_kcontrol_new vx_control_monitor_gain = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Monitoring Volume", .info = vx_audio_gain_info, /* shared */ .get = vx_audio_monitor_get, .put = vx_audio_monitor_put }; -static snd_kcontrol_new_t vx_control_monitor_switch = { +static struct snd_kcontrol_new vx_control_monitor_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Monitoring Switch", .info = vx_audio_sw_info, /* shared */ @@ -745,16 +745,16 @@ static snd_kcontrol_new_t vx_control_monitor_switch = { /* * IEC958 status bits */ -static int vx_iec958_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_iec958_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int vx_iec958_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); down(&chip->mixer_mutex); ucontrol->value.iec958.status[0] = (chip->uer_bits >> 0) & 0xff; @@ -765,7 +765,7 @@ static int vx_iec958_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontro return 0; } -static int vx_iec958_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_iec958_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -774,9 +774,9 @@ static int vx_iec958_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *u return 0; } -static int vx_iec958_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_iec958_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); unsigned int val; val = (ucontrol->value.iec958.status[0] << 0) | @@ -794,7 +794,7 @@ static int vx_iec958_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontro return 0; } -static snd_kcontrol_new_t vx_control_iec958_mask = { +static struct snd_kcontrol_new vx_control_iec958_mask = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), @@ -802,7 +802,7 @@ static snd_kcontrol_new_t vx_control_iec958_mask = { .get = vx_iec958_mask_get, }; -static snd_kcontrol_new_t vx_control_iec958 = { +static struct snd_kcontrol_new vx_control_iec958 = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), .info = vx_iec958_info, @@ -818,7 +818,7 @@ static snd_kcontrol_new_t vx_control_iec958 = { #define METER_MAX 0xff #define METER_SHIFT 16 -static int vx_vu_meter_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_vu_meter_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -827,9 +827,9 @@ static int vx_vu_meter_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo return 0; } -static int vx_vu_meter_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_vu_meter_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); struct vx_vu_meter meter[2]; int audio = kcontrol->private_value & 0xff; int capture = (kcontrol->private_value >> 8) & 1; @@ -840,9 +840,9 @@ static int vx_vu_meter_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int vx_peak_meter_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_peak_meter_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); struct vx_vu_meter meter[2]; int audio = kcontrol->private_value & 0xff; int capture = (kcontrol->private_value >> 8) & 1; @@ -853,7 +853,7 @@ static int vx_peak_meter_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return 0; } -static int vx_saturation_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_saturation_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -862,9 +862,9 @@ static int vx_saturation_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uin return 0; } -static int vx_saturation_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_saturation_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *chip = snd_kcontrol_chip(kcontrol); + struct vx_core *chip = snd_kcontrol_chip(kcontrol); struct vx_vu_meter meter[2]; int audio = kcontrol->private_value & 0xff; @@ -874,7 +874,7 @@ static int vx_saturation_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return 0; } -static snd_kcontrol_new_t vx_control_vu_meter = { +static struct snd_kcontrol_new vx_control_vu_meter = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, /* name will be filled later */ @@ -882,7 +882,7 @@ static snd_kcontrol_new_t vx_control_vu_meter = { .get = vx_vu_meter_get, }; -static snd_kcontrol_new_t vx_control_peak_meter = { +static struct snd_kcontrol_new vx_control_peak_meter = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, /* name will be filled later */ @@ -890,7 +890,7 @@ static snd_kcontrol_new_t vx_control_peak_meter = { .get = vx_peak_meter_get, }; -static snd_kcontrol_new_t vx_control_saturation = { +static struct snd_kcontrol_new vx_control_saturation = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Input Saturation", .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, @@ -904,12 +904,12 @@ static snd_kcontrol_new_t vx_control_saturation = { * */ -int snd_vx_mixer_new(vx_core_t *chip) +int snd_vx_mixer_new(struct vx_core *chip) { unsigned int i, c; int err; - snd_kcontrol_new_t temp; - snd_card_t *card = chip->card; + struct snd_kcontrol_new temp; + struct snd_card *card = chip->card; char name[32]; strcpy(card->mixername, card->driver); diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index 2b46758..464109e 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -61,7 +61,8 @@ */ /* get the physical page pointer on the given offset */ -static struct page *snd_pcm_get_vmalloc_page(snd_pcm_substream_t *subs, unsigned long offset) +static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, + unsigned long offset) { void *pageptr = subs->runtime->dma_area + offset; return vmalloc_to_page(pageptr); @@ -72,9 +73,9 @@ static struct page *snd_pcm_get_vmalloc_page(snd_pcm_substream_t *subs, unsigned * called from hw_params * NOTE: this may be called not only once per pcm open! */ -static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) +static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) { - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (runtime->dma_area) { /* already allocated */ if (runtime->dma_bytes >= size) @@ -94,9 +95,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) * called from hw_free callback * NOTE: this may be called not only once per pcm open! */ -static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) +static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (runtime->dma_area) { vfree(runtime->dma_area); runtime->dma_area = NULL; @@ -108,7 +109,8 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) /* * read three pending pcm bytes via inb() */ -static void vx_pcm_read_per_bytes(vx_core_t *chip, snd_pcm_runtime_t *runtime, vx_pipe_t *pipe) +static void vx_pcm_read_per_bytes(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe) { int offset = pipe->hw_ptr; unsigned char *buf = (unsigned char *)(runtime->dma_area + offset); @@ -135,7 +137,8 @@ static void vx_pcm_read_per_bytes(vx_core_t *chip, snd_pcm_runtime_t *runtime, v * @pc_time: the pointer for the PC-time to set * @dsp_time: the pointer for RMH status time array */ -static void vx_set_pcx_time(vx_core_t *chip, pcx_time_t *pc_time, unsigned int *dsp_time) +static void vx_set_pcx_time(struct vx_core *chip, pcx_time_t *pc_time, + unsigned int *dsp_time) { dsp_time[0] = (unsigned int)((*pc_time) >> 24) & PCX_TIME_HI_MASK; dsp_time[1] = (unsigned int)(*pc_time) & MASK_DSP_WORD; @@ -151,7 +154,8 @@ static void vx_set_pcx_time(vx_core_t *chip, pcx_time_t *pc_time, unsigned int * * * returns the increase of the command length. */ -static int vx_set_differed_time(vx_core_t *chip, struct vx_rmh *rmh, vx_pipe_t *pipe) +static int vx_set_differed_time(struct vx_core *chip, struct vx_rmh *rmh, + struct vx_pipe *pipe) { /* Update The length added to the RMH command by the timestamp */ if (! (pipe->differed_type & DC_DIFFERED_DELAY)) @@ -184,7 +188,8 @@ static int vx_set_differed_time(vx_core_t *chip, struct vx_rmh *rmh, vx_pipe_t * * @pipe: the affected pipe * @data: format bitmask */ -static int vx_set_stream_format(vx_core_t *chip, vx_pipe_t *pipe, unsigned int data) +static int vx_set_stream_format(struct vx_core *chip, struct vx_pipe *pipe, + unsigned int data) { struct vx_rmh rmh; @@ -210,8 +215,8 @@ static int vx_set_stream_format(vx_core_t *chip, vx_pipe_t *pipe, unsigned int d * * returns 0 if successful, or a negative error code. */ -static int vx_set_format(vx_core_t *chip, vx_pipe_t *pipe, - snd_pcm_runtime_t *runtime) +static int vx_set_format(struct vx_core *chip, struct vx_pipe *pipe, + struct snd_pcm_runtime *runtime) { unsigned int header = HEADER_FMT_BASE; @@ -239,7 +244,7 @@ static int vx_set_format(vx_core_t *chip, vx_pipe_t *pipe, /* * set / query the IBL size */ -static int vx_set_ibl(vx_core_t *chip, struct vx_ibl_info *info) +static int vx_set_ibl(struct vx_core *chip, struct vx_ibl_info *info) { int err; struct vx_rmh rmh; @@ -269,7 +274,7 @@ static int vx_set_ibl(vx_core_t *chip, struct vx_ibl_info *info) * * called from trigger callback only */ -static int vx_get_pipe_state(vx_core_t *chip, vx_pipe_t *pipe, int *state) +static int vx_get_pipe_state(struct vx_core *chip, struct vx_pipe *pipe, int *state) { int err; struct vx_rmh rmh; @@ -294,7 +299,7 @@ static int vx_get_pipe_state(vx_core_t *chip, vx_pipe_t *pipe, int *state) * you'll need to disconnect the host to get back to the * normal mode. */ -static int vx_query_hbuffer_size(vx_core_t *chip, vx_pipe_t *pipe) +static int vx_query_hbuffer_size(struct vx_core *chip, struct vx_pipe *pipe) { int result; struct vx_rmh rmh; @@ -318,7 +323,7 @@ static int vx_query_hbuffer_size(vx_core_t *chip, vx_pipe_t *pipe) * * called from trigger callback only */ -static int vx_pipe_can_start(vx_core_t *chip, vx_pipe_t *pipe) +static int vx_pipe_can_start(struct vx_core *chip, struct vx_pipe *pipe) { int err; struct vx_rmh rmh; @@ -339,7 +344,7 @@ static int vx_pipe_can_start(vx_core_t *chip, vx_pipe_t *pipe) * vx_conf_pipe - tell the pipe to stand by and wait for IRQA. * @pipe: the pipe to be configured */ -static int vx_conf_pipe(vx_core_t *chip, vx_pipe_t *pipe) +static int vx_conf_pipe(struct vx_core *chip, struct vx_pipe *pipe) { struct vx_rmh rmh; @@ -353,7 +358,7 @@ static int vx_conf_pipe(vx_core_t *chip, vx_pipe_t *pipe) /* * vx_send_irqa - trigger IRQA */ -static int vx_send_irqa(vx_core_t *chip) +static int vx_send_irqa(struct vx_core *chip) { struct vx_rmh rmh; @@ -378,7 +383,7 @@ static int vx_send_irqa(vx_core_t *chip) * called from trigger callback only * */ -static int vx_toggle_pipe(vx_core_t *chip, vx_pipe_t *pipe, int state) +static int vx_toggle_pipe(struct vx_core *chip, struct vx_pipe *pipe, int state) { int err, i, cur_state; @@ -431,7 +436,7 @@ static int vx_toggle_pipe(vx_core_t *chip, vx_pipe_t *pipe, int state) * * called from trigger callback only */ -static int vx_stop_pipe(vx_core_t *chip, vx_pipe_t *pipe) +static int vx_stop_pipe(struct vx_core *chip, struct vx_pipe *pipe) { struct vx_rmh rmh; vx_init_rmh(&rmh, CMD_STOP_PIPE); @@ -449,12 +454,12 @@ static int vx_stop_pipe(vx_core_t *chip, vx_pipe_t *pipe) * * return 0 on success, or a negative error code. */ -static int vx_alloc_pipe(vx_core_t *chip, int capture, +static int vx_alloc_pipe(struct vx_core *chip, int capture, int audioid, int num_audio, - vx_pipe_t **pipep) + struct vx_pipe **pipep) { int err; - vx_pipe_t *pipe; + struct vx_pipe *pipe; struct vx_rmh rmh; int data_mode; @@ -499,7 +504,7 @@ static int vx_alloc_pipe(vx_core_t *chip, int capture, * vx_free_pipe - release a pipe * @pipe: pipe to be released */ -static int vx_free_pipe(vx_core_t *chip, vx_pipe_t *pipe) +static int vx_free_pipe(struct vx_core *chip, struct vx_pipe *pipe) { struct vx_rmh rmh; @@ -517,7 +522,7 @@ static int vx_free_pipe(vx_core_t *chip, vx_pipe_t *pipe) * * called from trigger callback only */ -static int vx_start_stream(vx_core_t *chip, vx_pipe_t *pipe) +static int vx_start_stream(struct vx_core *chip, struct vx_pipe *pipe) { struct vx_rmh rmh; @@ -533,7 +538,7 @@ static int vx_start_stream(vx_core_t *chip, vx_pipe_t *pipe) * * called from trigger callback only */ -static int vx_stop_stream(vx_core_t *chip, vx_pipe_t *pipe) +static int vx_stop_stream(struct vx_core *chip, struct vx_pipe *pipe) { struct vx_rmh rmh; @@ -547,11 +552,12 @@ static int vx_stop_stream(vx_core_t *chip, vx_pipe_t *pipe) * playback hw information */ -static snd_pcm_hardware_t vx_pcm_playback_hw = { +static struct snd_pcm_hardware vx_pcm_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_MMAP_VALID /*|*/ /*SNDRV_PCM_INFO_RESUME*/), - .formats = /*SNDRV_PCM_FMTBIT_U8 |*/ SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE, + .formats = (/*SNDRV_PCM_FMTBIT_U8 |*/ + SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE), .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, .rate_min = 5000, .rate_max = 48000, @@ -571,11 +577,11 @@ static void vx_pcm_delayed_start(unsigned long arg); /* * vx_pcm_playback_open - open callback for playback */ -static int vx_pcm_playback_open(snd_pcm_substream_t *subs) +static int vx_pcm_playback_open(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; - vx_core_t *chip = snd_pcm_substream_chip(subs); - vx_pipe_t *pipe = NULL; + struct snd_pcm_runtime *runtime = subs->runtime; + struct vx_core *chip = snd_pcm_substream_chip(subs); + struct vx_pipe *pipe = NULL; unsigned int audio; int err; @@ -615,10 +621,10 @@ static int vx_pcm_playback_open(snd_pcm_substream_t *subs) /* * vx_pcm_playback_close - close callback for playback */ -static int vx_pcm_playback_close(snd_pcm_substream_t *subs) +static int vx_pcm_playback_close(struct snd_pcm_substream *subs) { - vx_core_t *chip = snd_pcm_substream_chip(subs); - vx_pipe_t *pipe; + struct vx_core *chip = snd_pcm_substream_chip(subs); + struct vx_pipe *pipe; if (! subs->runtime->private_data) return -EINVAL; @@ -641,7 +647,7 @@ static int vx_pcm_playback_close(snd_pcm_substream_t *subs) * * NB: call with a certain lock. */ -static int vx_notify_end_of_buffer(vx_core_t *chip, vx_pipe_t *pipe) +static int vx_notify_end_of_buffer(struct vx_core *chip, struct vx_pipe *pipe) { int err; struct vx_rmh rmh; /* use a temporary rmh here */ @@ -669,7 +675,9 @@ static int vx_notify_end_of_buffer(vx_core_t *chip, vx_pipe_t *pipe) * * return 0 if ok. */ -static int vx_pcm_playback_transfer_chunk(vx_core_t *chip, snd_pcm_runtime_t *runtime, vx_pipe_t *pipe, int size) +static int vx_pcm_playback_transfer_chunk(struct vx_core *chip, + struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int size) { int space, err = 0; @@ -705,7 +713,9 @@ static int vx_pcm_playback_transfer_chunk(vx_core_t *chip, snd_pcm_runtime_t *ru * so that the caller can check the total transferred size later * (to call snd_pcm_period_elapsed). */ -static int vx_update_pipe_position(vx_core_t *chip, snd_pcm_runtime_t *runtime, vx_pipe_t *pipe) +static int vx_update_pipe_position(struct vx_core *chip, + struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe) { struct vx_rmh rmh; int err, update; @@ -731,10 +741,12 @@ static int vx_update_pipe_position(vx_core_t *chip, snd_pcm_runtime_t *runtime, * transfer the pending playback buffer data to DSP * called from interrupt handler */ -static void vx_pcm_playback_transfer(vx_core_t *chip, snd_pcm_substream_t *subs, vx_pipe_t *pipe, int nchunks) +static void vx_pcm_playback_transfer(struct vx_core *chip, + struct snd_pcm_substream *subs, + struct vx_pipe *pipe, int nchunks) { int i, err; - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE)) return; @@ -749,10 +761,12 @@ static void vx_pcm_playback_transfer(vx_core_t *chip, snd_pcm_substream_t *subs, * update the playback position and call snd_pcm_period_elapsed() if necessary * called from interrupt handler */ -static void vx_pcm_playback_update(vx_core_t *chip, snd_pcm_substream_t *subs, vx_pipe_t *pipe) +static void vx_pcm_playback_update(struct vx_core *chip, + struct snd_pcm_substream *subs, + struct vx_pipe *pipe) { int err; - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (pipe->running && ! (chip->chip_status & VX_STAT_IS_STALE)) { if ((err = vx_update_pipe_position(chip, runtime, pipe)) < 0) @@ -771,9 +785,9 @@ static void vx_pcm_playback_update(vx_core_t *chip, snd_pcm_substream_t *subs, v */ static void vx_pcm_delayed_start(unsigned long arg) { - snd_pcm_substream_t *subs = (snd_pcm_substream_t *)arg; - vx_core_t *chip = subs->pcm->private_data; - vx_pipe_t *pipe = subs->runtime->private_data; + struct snd_pcm_substream *subs = (struct snd_pcm_substream *)arg; + struct vx_core *chip = subs->pcm->private_data; + struct vx_pipe *pipe = subs->runtime->private_data; int err; /* printk( KERN_DEBUG "DDDD tasklet delayed start jiffies = %ld\n", jiffies);*/ @@ -792,10 +806,10 @@ static void vx_pcm_delayed_start(unsigned long arg) /* * vx_pcm_playback_trigger - trigger callback for playback */ -static int vx_pcm_trigger(snd_pcm_substream_t *subs, int cmd) +static int vx_pcm_trigger(struct snd_pcm_substream *subs, int cmd) { - vx_core_t *chip = snd_pcm_substream_chip(subs); - vx_pipe_t *pipe = subs->runtime->private_data; + struct vx_core *chip = snd_pcm_substream_chip(subs); + struct vx_pipe *pipe = subs->runtime->private_data; int err; if (chip->chip_status & VX_STAT_IS_STALE) @@ -839,18 +853,18 @@ static int vx_pcm_trigger(snd_pcm_substream_t *subs, int cmd) /* * vx_pcm_playback_pointer - pointer callback for playback */ -static snd_pcm_uframes_t vx_pcm_playback_pointer(snd_pcm_substream_t *subs) +static snd_pcm_uframes_t vx_pcm_playback_pointer(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; - vx_pipe_t *pipe = runtime->private_data; + struct snd_pcm_runtime *runtime = subs->runtime; + struct vx_pipe *pipe = runtime->private_data; return pipe->position; } /* * vx_pcm_hw_params - hw_params callback for playback and capture */ -static int vx_pcm_hw_params(snd_pcm_substream_t *subs, - snd_pcm_hw_params_t *hw_params) +static int vx_pcm_hw_params(struct snd_pcm_substream *subs, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); } @@ -858,7 +872,7 @@ static int vx_pcm_hw_params(snd_pcm_substream_t *subs, /* * vx_pcm_hw_free - hw_free callback for playback and capture */ -static int vx_pcm_hw_free(snd_pcm_substream_t *subs) +static int vx_pcm_hw_free(struct snd_pcm_substream *subs) { return snd_pcm_free_vmalloc_buffer(subs); } @@ -866,11 +880,11 @@ static int vx_pcm_hw_free(snd_pcm_substream_t *subs) /* * vx_pcm_prepare - prepare callback for playback and capture */ -static int vx_pcm_prepare(snd_pcm_substream_t *subs) +static int vx_pcm_prepare(struct snd_pcm_substream *subs) { - vx_core_t *chip = snd_pcm_substream_chip(subs); - snd_pcm_runtime_t *runtime = subs->runtime; - vx_pipe_t *pipe = runtime->private_data; + struct vx_core *chip = snd_pcm_substream_chip(subs); + struct snd_pcm_runtime *runtime = subs->runtime; + struct vx_pipe *pipe = runtime->private_data; int err, data_mode; // int max_size, nchunks; @@ -897,7 +911,8 @@ static int vx_pcm_prepare(snd_pcm_substream_t *subs) } if (chip->pcm_running && chip->freq != runtime->rate) { - snd_printk(KERN_ERR "vx: cannot set different clock %d from the current %d\n", runtime->rate, chip->freq); + snd_printk(KERN_ERR "vx: cannot set different clock %d " + "from the current %d\n", runtime->rate, chip->freq); return -EINVAL; } vx_set_clock(chip, runtime->rate); @@ -930,7 +945,7 @@ static int vx_pcm_prepare(snd_pcm_substream_t *subs) /* * operators for PCM playback */ -static snd_pcm_ops_t vx_pcm_playback_ops = { +static struct snd_pcm_ops vx_pcm_playback_ops = { .open = vx_pcm_playback_open, .close = vx_pcm_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -947,11 +962,12 @@ static snd_pcm_ops_t vx_pcm_playback_ops = { * playback hw information */ -static snd_pcm_hardware_t vx_pcm_capture_hw = { +static struct snd_pcm_hardware vx_pcm_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_MMAP_VALID /*|*/ /*SNDRV_PCM_INFO_RESUME*/), - .formats = /*SNDRV_PCM_FMTBIT_U8 |*/ SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE, + .formats = (/*SNDRV_PCM_FMTBIT_U8 |*/ + SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_3LE), .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, .rate_min = 5000, .rate_max = 48000, @@ -969,12 +985,12 @@ static snd_pcm_hardware_t vx_pcm_capture_hw = { /* * vx_pcm_capture_open - open callback for capture */ -static int vx_pcm_capture_open(snd_pcm_substream_t *subs) +static int vx_pcm_capture_open(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; - vx_core_t *chip = snd_pcm_substream_chip(subs); - vx_pipe_t *pipe; - vx_pipe_t *pipe_out_monitoring = NULL; + struct snd_pcm_runtime *runtime = subs->runtime; + struct vx_core *chip = snd_pcm_substream_chip(subs); + struct vx_pipe *pipe; + struct vx_pipe *pipe_out_monitoring = NULL; unsigned int audio; int err; @@ -1005,9 +1021,11 @@ static int vx_pcm_capture_open(snd_pcm_substream_t *subs) if an output pipe is available, it's audios still may need to be unmuted. hence we'll have to call a mixer entry point. */ - vx_set_monitor_level(chip, audio, chip->audio_monitor[audio], chip->audio_monitor_active[audio]); + vx_set_monitor_level(chip, audio, chip->audio_monitor[audio], + chip->audio_monitor_active[audio]); /* assuming stereo */ - vx_set_monitor_level(chip, audio+1, chip->audio_monitor[audio+1], chip->audio_monitor_active[audio+1]); + vx_set_monitor_level(chip, audio+1, chip->audio_monitor[audio+1], + chip->audio_monitor_active[audio+1]); } pipe->monitoring_pipe = pipe_out_monitoring; /* default value NULL */ @@ -1026,11 +1044,11 @@ static int vx_pcm_capture_open(snd_pcm_substream_t *subs) /* * vx_pcm_capture_close - close callback for capture */ -static int vx_pcm_capture_close(snd_pcm_substream_t *subs) +static int vx_pcm_capture_close(struct snd_pcm_substream *subs) { - vx_core_t *chip = snd_pcm_substream_chip(subs); - vx_pipe_t *pipe; - vx_pipe_t *pipe_out_monitoring; + struct vx_core *chip = snd_pcm_substream_chip(subs); + struct vx_pipe *pipe; + struct vx_pipe *pipe_out_monitoring; if (! subs->runtime->private_data) return -EINVAL; @@ -1062,10 +1080,11 @@ static int vx_pcm_capture_close(snd_pcm_substream_t *subs) /* * vx_pcm_capture_update - update the capture buffer */ -static void vx_pcm_capture_update(vx_core_t *chip, snd_pcm_substream_t *subs, vx_pipe_t *pipe) +static void vx_pcm_capture_update(struct vx_core *chip, struct snd_pcm_substream *subs, + struct vx_pipe *pipe) { int size, space, count; - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (! pipe->prepared || (chip->chip_status & VX_STAT_IS_STALE)) return; @@ -1135,17 +1154,17 @@ static void vx_pcm_capture_update(vx_core_t *chip, snd_pcm_substream_t *subs, vx /* * vx_pcm_capture_pointer - pointer callback for capture */ -static snd_pcm_uframes_t vx_pcm_capture_pointer(snd_pcm_substream_t *subs) +static snd_pcm_uframes_t vx_pcm_capture_pointer(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; - vx_pipe_t *pipe = runtime->private_data; + struct snd_pcm_runtime *runtime = subs->runtime; + struct vx_pipe *pipe = runtime->private_data; return bytes_to_frames(runtime, pipe->hw_ptr); } /* * operators for PCM capture */ -static snd_pcm_ops_t vx_pcm_capture_ops = { +static struct snd_pcm_ops vx_pcm_capture_ops = { .open = vx_pcm_capture_open, .close = vx_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1161,10 +1180,10 @@ static snd_pcm_ops_t vx_pcm_capture_ops = { /* * interrupt handler for pcm streams */ -void vx_pcm_update_intr(vx_core_t *chip, unsigned int events) +void vx_pcm_update_intr(struct vx_core *chip, unsigned int events) { unsigned int i; - vx_pipe_t *pipe; + struct vx_pipe *pipe; #define EVENT_MASK (END_OF_BUFFER_EVENTS_PENDING|ASYNC_EVENTS_PENDING) @@ -1218,7 +1237,7 @@ void vx_pcm_update_intr(vx_core_t *chip, unsigned int events) /* * vx_init_audio_io - check the availabe audio i/o and allocate pipe arrays */ -static int vx_init_audio_io(vx_core_t *chip) +static int vx_init_audio_io(struct vx_core *chip) { struct vx_rmh rmh; int preferred; @@ -1234,19 +1253,20 @@ static int vx_init_audio_io(vx_core_t *chip) chip->audio_info = rmh.Stat[1]; /* allocate pipes */ - chip->playback_pipes = kmalloc(sizeof(vx_pipe_t *) * chip->audio_outs, GFP_KERNEL); - chip->capture_pipes = kmalloc(sizeof(vx_pipe_t *) * chip->audio_ins, GFP_KERNEL); + chip->playback_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_outs, GFP_KERNEL); + chip->capture_pipes = kmalloc(sizeof(struct vx_pipe *) * chip->audio_ins, GFP_KERNEL); if (! chip->playback_pipes || ! chip->capture_pipes) return -ENOMEM; - memset(chip->playback_pipes, 0, sizeof(vx_pipe_t *) * chip->audio_outs); - memset(chip->capture_pipes, 0, sizeof(vx_pipe_t *) * chip->audio_ins); + memset(chip->playback_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_outs); + memset(chip->capture_pipes, 0, sizeof(struct vx_pipe *) * chip->audio_ins); preferred = chip->ibl.size; chip->ibl.size = 0; vx_set_ibl(chip, &chip->ibl); /* query the info */ if (preferred > 0) { - chip->ibl.size = ((preferred + chip->ibl.granularity - 1) / chip->ibl.granularity) * chip->ibl.granularity; + chip->ibl.size = ((preferred + chip->ibl.granularity - 1) / + chip->ibl.granularity) * chip->ibl.granularity; if (chip->ibl.size > chip->ibl.max_size) chip->ibl.size = chip->ibl.max_size; } else @@ -1260,9 +1280,9 @@ static int vx_init_audio_io(vx_core_t *chip) /* * free callback for pcm */ -static void snd_vx_pcm_free(snd_pcm_t *pcm) +static void snd_vx_pcm_free(struct snd_pcm *pcm) { - vx_core_t *chip = pcm->private_data; + struct vx_core *chip = pcm->private_data; chip->pcm[pcm->device] = NULL; kfree(chip->playback_pipes); chip->playback_pipes = NULL; @@ -1273,9 +1293,9 @@ static void snd_vx_pcm_free(snd_pcm_t *pcm) /* * snd_vx_pcm_new - create and initialize a pcm */ -int snd_vx_pcm_new(vx_core_t *chip) +int snd_vx_pcm_new(struct vx_core *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; unsigned int i; int err; diff --git a/sound/drivers/vx/vx_uer.c b/sound/drivers/vx/vx_uer.c index 4fc38bd..7400306 100644 --- a/sound/drivers/vx/vx_uer.c +++ b/sound/drivers/vx/vx_uer.c @@ -31,7 +31,7 @@ * vx_modify_board_clock - tell the board that its clock has been modified * @sync: DSP needs to resynchronize its FIFO */ -static int vx_modify_board_clock(vx_core_t *chip, int sync) +static int vx_modify_board_clock(struct vx_core *chip, int sync) { struct vx_rmh rmh; @@ -45,7 +45,7 @@ static int vx_modify_board_clock(vx_core_t *chip, int sync) /* * vx_modify_board_inputs - resync audio inputs */ -static int vx_modify_board_inputs(vx_core_t *chip) +static int vx_modify_board_inputs(struct vx_core *chip) { struct vx_rmh rmh; @@ -59,7 +59,7 @@ static int vx_modify_board_inputs(vx_core_t *chip) * @index: the bit index * returns 0 or 1. */ -static int vx_read_one_cbit(vx_core_t *chip, int index) +static int vx_read_one_cbit(struct vx_core *chip, int index) { unsigned long flags; int val; @@ -82,7 +82,7 @@ static int vx_read_one_cbit(vx_core_t *chip, int index) * @index: the bit index * @val: bit value, 0 or 1 */ -static void vx_write_one_cbit(vx_core_t *chip, int index, int val) +static void vx_write_one_cbit(struct vx_core *chip, int index, int val) { unsigned long flags; val = !!val; /* 0 or 1 */ @@ -104,7 +104,7 @@ static void vx_write_one_cbit(vx_core_t *chip, int index, int val) * returns the frequency of UER, or 0 if not sync, * or a negative error code. */ -static int vx_read_uer_status(vx_core_t *chip, int *mode) +static int vx_read_uer_status(struct vx_core *chip, int *mode) { int val, freq; @@ -160,7 +160,7 @@ static int vx_read_uer_status(vx_core_t *chip, int *mode) * default : HexFreq = (dword) ((double) 28224000 / (double) (Frequency*4)) - 0x000001FF */ -static int vx_calc_clock_from_freq(vx_core_t *chip, int freq) +static int vx_calc_clock_from_freq(struct vx_core *chip, int freq) { int hexfreq; @@ -187,7 +187,7 @@ static int vx_calc_clock_from_freq(vx_core_t *chip, int freq) * vx_change_clock_source - change the clock source * @source: the new source */ -static void vx_change_clock_source(vx_core_t *chip, int source) +static void vx_change_clock_source(struct vx_core *chip, int source) { unsigned long flags; @@ -205,7 +205,7 @@ static void vx_change_clock_source(vx_core_t *chip, int source) /* * set the internal clock */ -void vx_set_internal_clock(vx_core_t *chip, unsigned int freq) +void vx_set_internal_clock(struct vx_core *chip, unsigned int freq) { int clock; unsigned long flags; @@ -228,7 +228,7 @@ void vx_set_internal_clock(vx_core_t *chip, unsigned int freq) * set the iec958 status bits * @bits: 32-bit status bits */ -void vx_set_iec958_status(vx_core_t *chip, unsigned int bits) +void vx_set_iec958_status(struct vx_core *chip, unsigned int bits) { int i; @@ -243,7 +243,7 @@ void vx_set_iec958_status(vx_core_t *chip, unsigned int bits) /* * vx_set_clock - change the clock and audio source if necessary */ -int vx_set_clock(vx_core_t *chip, unsigned int freq) +int vx_set_clock(struct vx_core *chip, unsigned int freq) { int src_changed = 0; @@ -285,7 +285,7 @@ int vx_set_clock(vx_core_t *chip, unsigned int freq) /* * vx_change_frequency - called from interrupt handler */ -int vx_change_frequency(vx_core_t *chip) +int vx_change_frequency(struct vx_core *chip) { int freq; diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index dca6bd2..4ebbabe 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -108,7 +108,7 @@ static struct snd_vx_hardware vx222_mic_hw = { /* */ -static int snd_vx222_free(vx_core_t *chip) +static int snd_vx222_free(struct vx_core *chip) { struct snd_vx222 *vx = (struct snd_vx222 *)chip; @@ -121,21 +121,21 @@ static int snd_vx222_free(vx_core_t *chip) return 0; } -static int snd_vx222_dev_free(snd_device_t *device) +static int snd_vx222_dev_free(struct snd_device *device) { - vx_core_t *chip = device->device_data; + struct vx_core *chip = device->device_data; return snd_vx222_free(chip); } -static int __devinit snd_vx222_create(snd_card_t *card, struct pci_dev *pci, +static int __devinit snd_vx222_create(struct snd_card *card, struct pci_dev *pci, struct snd_vx_hardware *hw, struct snd_vx222 **rchip) { - vx_core_t *chip; + struct vx_core *chip; struct snd_vx222 *vx; int i, err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_vx222_dev_free, }; struct snd_vx_ops *vx_ops; @@ -147,7 +147,7 @@ static int __devinit snd_vx222_create(snd_card_t *card, struct pci_dev *pci, vx_ops = hw->type == VX_TYPE_BOARD ? &vx222_old_ops : &vx222_ops; chip = snd_vx_create(card, hw, vx_ops, - sizeof(struct snd_vx222) - sizeof(vx_core_t)); + sizeof(struct snd_vx222) - sizeof(struct vx_core)); if (! chip) { pci_disable_device(pci); return -ENOMEM; @@ -186,7 +186,7 @@ static int __devinit snd_vx222_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; + struct snd_card *card; struct snd_vx_hardware *hw; struct snd_vx222 *vx; int err; diff --git a/sound/pci/vx222/vx222.h b/sound/pci/vx222/vx222.h index 18478ae..2f0d78f 100644 --- a/sound/pci/vx222/vx222.h +++ b/sound/pci/vx222/vx222.h @@ -25,7 +25,7 @@ struct snd_vx222 { - vx_core_t core; + struct vx_core core; /* h/w config; for PLX and for DSP */ struct pci_dev *pci; diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c index 2d4d0c2..c705af4 100644 --- a/sound/pci/vx222/vx222_ops.c +++ b/sound/pci/vx222/vx222_ops.c @@ -82,7 +82,7 @@ static int vx2_reg_index[VX_REG_MAX] = { [VX_GPIOC] = 0, /* on the PLX */ }; -static inline unsigned long vx2_reg_addr(vx_core_t *_chip, int reg) +static inline unsigned long vx2_reg_addr(struct vx_core *_chip, int reg) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; return chip->port[vx2_reg_index[reg]] + vx2_reg_offset[reg]; @@ -92,7 +92,7 @@ static inline unsigned long vx2_reg_addr(vx_core_t *_chip, int reg) * snd_vx_inb - read a byte from the register * @offset: register enum */ -static unsigned char vx2_inb(vx_core_t *chip, int offset) +static unsigned char vx2_inb(struct vx_core *chip, int offset) { return inb(vx2_reg_addr(chip, offset)); } @@ -102,7 +102,7 @@ static unsigned char vx2_inb(vx_core_t *chip, int offset) * @offset: the register offset * @val: the value to write */ -static void vx2_outb(vx_core_t *chip, int offset, unsigned char val) +static void vx2_outb(struct vx_core *chip, int offset, unsigned char val) { outb(val, vx2_reg_addr(chip, offset)); //printk("outb: %x -> %x\n", val, vx2_reg_addr(chip, offset)); @@ -112,7 +112,7 @@ static void vx2_outb(vx_core_t *chip, int offset, unsigned char val) * snd_vx_inl - read a 32bit word from the register * @offset: register enum */ -static unsigned int vx2_inl(vx_core_t *chip, int offset) +static unsigned int vx2_inl(struct vx_core *chip, int offset) { return inl(vx2_reg_addr(chip, offset)); } @@ -122,7 +122,7 @@ static unsigned int vx2_inl(vx_core_t *chip, int offset) * @offset: the register enum * @val: the value to write */ -static void vx2_outl(vx_core_t *chip, int offset, unsigned int val) +static void vx2_outl(struct vx_core *chip, int offset, unsigned int val) { // printk("outl: %x -> %x\n", val, vx2_reg_addr(chip, offset)); outl(val, vx2_reg_addr(chip, offset)); @@ -132,13 +132,13 @@ static void vx2_outl(vx_core_t *chip, int offset, unsigned int val) * redefine macros to call directly */ #undef vx_inb -#define vx_inb(chip,reg) vx2_inb((vx_core_t*)(chip), VX_##reg) +#define vx_inb(chip,reg) vx2_inb((struct vx_core*)(chip), VX_##reg) #undef vx_outb -#define vx_outb(chip,reg,val) vx2_outb((vx_core_t*)(chip), VX_##reg, val) +#define vx_outb(chip,reg,val) vx2_outb((struct vx_core*)(chip), VX_##reg, val) #undef vx_inl -#define vx_inl(chip,reg) vx2_inl((vx_core_t*)(chip), VX_##reg) +#define vx_inl(chip,reg) vx2_inl((struct vx_core*)(chip), VX_##reg) #undef vx_outl -#define vx_outl(chip,reg,val) vx2_outl((vx_core_t*)(chip), VX_##reg, val) +#define vx_outl(chip,reg,val) vx2_outl((struct vx_core*)(chip), VX_##reg, val) /* @@ -147,7 +147,7 @@ static void vx2_outl(vx_core_t *chip, int offset, unsigned int val) #define XX_DSP_RESET_WAIT_TIME 2 /* ms */ -static void vx2_reset_dsp(vx_core_t *_chip) +static void vx2_reset_dsp(struct vx_core *_chip) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; @@ -162,7 +162,7 @@ static void vx2_reset_dsp(vx_core_t *_chip) } -static int vx2_test_xilinx(vx_core_t *_chip) +static int vx2_test_xilinx(struct vx_core *_chip) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; unsigned int data; @@ -219,7 +219,7 @@ static int vx2_test_xilinx(vx_core_t *_chip) * vx_setup_pseudo_dma - set up the pseudo dma read/write mode. * @do_write: 0 = read, 1 = set up for DMA write */ -static void vx2_setup_pseudo_dma(vx_core_t *chip, int do_write) +static void vx2_setup_pseudo_dma(struct vx_core *chip, int do_write) { /* Interrupt mode and HREQ pin enabled for host transmit data transfers * (in case of the use of the pseudo-dma facility). @@ -235,7 +235,7 @@ static void vx2_setup_pseudo_dma(vx_core_t *chip, int do_write) /* * vx_release_pseudo_dma - disable the pseudo-DMA mode */ -static inline void vx2_release_pseudo_dma(vx_core_t *chip) +static inline void vx2_release_pseudo_dma(struct vx_core *chip) { /* HREQ pin disabled. */ vx_outl(chip, ICR, 0); @@ -244,8 +244,8 @@ static inline void vx2_release_pseudo_dma(vx_core_t *chip) /* pseudo-dma write */ -static void vx2_dma_write(vx_core_t *chip, snd_pcm_runtime_t *runtime, - vx_pipe_t *pipe, int count) +static void vx2_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int count) { unsigned long port = vx2_reg_addr(chip, VX_DMA); int offset = pipe->hw_ptr; @@ -282,8 +282,8 @@ static void vx2_dma_write(vx_core_t *chip, snd_pcm_runtime_t *runtime, /* pseudo dma read */ -static void vx2_dma_read(vx_core_t *chip, snd_pcm_runtime_t *runtime, - vx_pipe_t *pipe, int count) +static void vx2_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int count) { int offset = pipe->hw_ptr; u32 *addr = (u32 *)(runtime->dma_area + offset); @@ -321,7 +321,7 @@ static void vx2_dma_read(vx_core_t *chip, snd_pcm_runtime_t *runtime, /* * transfer counts bits to PLX */ -static int put_xilinx_data(vx_core_t *chip, unsigned int port, unsigned int counts, unsigned char data) +static int put_xilinx_data(struct vx_core *chip, unsigned int port, unsigned int counts, unsigned char data) { unsigned int i; @@ -353,7 +353,7 @@ static int put_xilinx_data(vx_core_t *chip, unsigned int port, unsigned int coun /* * load the xilinx image */ -static int vx2_load_xilinx_binary(vx_core_t *chip, const struct firmware *xilinx) +static int vx2_load_xilinx_binary(struct vx_core *chip, const struct firmware *xilinx) { unsigned int i; unsigned int port; @@ -400,7 +400,7 @@ static int vx2_load_xilinx_binary(vx_core_t *chip, const struct firmware *xilinx /* * load the boot/dsp images */ -static int vx2_load_dsp(vx_core_t *vx, int index, const struct firmware *dsp) +static int vx2_load_dsp(struct vx_core *vx, int index, const struct firmware *dsp) { int err; @@ -432,7 +432,7 @@ static int vx2_load_dsp(vx_core_t *vx, int index, const struct firmware *dsp) * * spinlock held! */ -static int vx2_test_and_ack(vx_core_t *chip) +static int vx2_test_and_ack(struct vx_core *chip) { /* not booted yet? */ if (! (chip->chip_status & VX_STAT_XILINX_LOADED)) @@ -463,7 +463,7 @@ static int vx2_test_and_ack(vx_core_t *chip) /* * vx_validate_irq - enable/disable IRQ */ -static void vx2_validate_irq(vx_core_t *_chip, int enable) +static void vx2_validate_irq(struct vx_core *_chip, int enable) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; @@ -484,7 +484,7 @@ static void vx2_validate_irq(vx_core_t *_chip, int enable) /* * write an AKM codec data (24bit) */ -static void vx2_write_codec_reg(vx_core_t *chip, unsigned int data) +static void vx2_write_codec_reg(struct vx_core *chip, unsigned int data) { unsigned int i; @@ -660,7 +660,7 @@ static const u8 vx2_akm_gains_lut[VX2_AKM_LEVEL_MAX+1] = { /* * pseudo-codec write entry */ -static void vx2_write_akm(vx_core_t *chip, int reg, unsigned int data) +static void vx2_write_akm(struct vx_core *chip, int reg, unsigned int data) { unsigned int val; @@ -695,7 +695,7 @@ static void vx2_write_akm(vx_core_t *chip, int reg, unsigned int data) /* * write codec bit for old VX222 board */ -static void vx2_old_write_codec_bit(vx_core_t *chip, int codec, unsigned int data) +static void vx2_old_write_codec_bit(struct vx_core *chip, int codec, unsigned int data) { int i; @@ -713,7 +713,7 @@ static void vx2_old_write_codec_bit(vx_core_t *chip, int codec, unsigned int dat /* * reset codec bit */ -static void vx2_reset_codec(vx_core_t *_chip) +static void vx2_reset_codec(struct vx_core *_chip) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; @@ -755,7 +755,7 @@ static void vx2_reset_codec(vx_core_t *_chip) /* * change the audio source */ -static void vx2_change_audio_source(vx_core_t *_chip, int src) +static void vx2_change_audio_source(struct vx_core *_chip, int src) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; @@ -774,7 +774,7 @@ static void vx2_change_audio_source(vx_core_t *_chip, int src) /* * set the clock source */ -static void vx2_set_clock_source(vx_core_t *_chip, int source) +static void vx2_set_clock_source(struct vx_core *_chip, int source) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; @@ -788,7 +788,7 @@ static void vx2_set_clock_source(vx_core_t *_chip, int source) /* * reset the board */ -static void vx2_reset_board(vx_core_t *_chip, int cold_reset) +static void vx2_reset_board(struct vx_core *_chip, int cold_reset) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; @@ -848,7 +848,7 @@ static void vx2_set_input_level(struct snd_vx222 *chip) */ /* input levels */ -static int vx_input_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_input_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -857,9 +857,9 @@ static int vx_input_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *ui return 0; } -static int vx_input_level_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_input_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *_chip = snd_kcontrol_chip(kcontrol); + struct vx_core *_chip = snd_kcontrol_chip(kcontrol); struct snd_vx222 *chip = (struct snd_vx222 *)_chip; down(&_chip->mixer_mutex); ucontrol->value.integer.value[0] = chip->input_level[0]; @@ -868,9 +868,9 @@ static int vx_input_level_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc return 0; } -static int vx_input_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_input_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *_chip = snd_kcontrol_chip(kcontrol); + struct vx_core *_chip = snd_kcontrol_chip(kcontrol); struct snd_vx222 *chip = (struct snd_vx222 *)_chip; down(&_chip->mixer_mutex); if (chip->input_level[0] != ucontrol->value.integer.value[0] || @@ -886,7 +886,7 @@ static int vx_input_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc } /* mic level */ -static int vx_mic_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_mic_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -895,17 +895,17 @@ static int vx_mic_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinf return 0; } -static int vx_mic_level_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *_chip = snd_kcontrol_chip(kcontrol); + struct vx_core *_chip = snd_kcontrol_chip(kcontrol); struct snd_vx222 *chip = (struct snd_vx222 *)_chip; ucontrol->value.integer.value[0] = chip->mic_level; return 0; } -static int vx_mic_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *_chip = snd_kcontrol_chip(kcontrol); + struct vx_core *_chip = snd_kcontrol_chip(kcontrol); struct snd_vx222 *chip = (struct snd_vx222 *)_chip; down(&_chip->mixer_mutex); if (chip->mic_level != ucontrol->value.integer.value[0]) { @@ -918,7 +918,7 @@ static int vx_mic_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon return 0; } -static snd_kcontrol_new_t vx_control_input_level = { +static struct snd_kcontrol_new vx_control_input_level = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Volume", .info = vx_input_level_info, @@ -926,7 +926,7 @@ static snd_kcontrol_new_t vx_control_input_level = { .put = vx_input_level_put, }; -static snd_kcontrol_new_t vx_control_mic_level = { +static struct snd_kcontrol_new vx_control_mic_level = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic Capture Volume", .info = vx_mic_level_info, @@ -938,7 +938,7 @@ static snd_kcontrol_new_t vx_control_mic_level = { * FIXME: compressor/limiter implementation is missing yet... */ -static int vx2_add_mic_controls(vx_core_t *_chip) +static int vx2_add_mic_controls(struct vx_core *_chip) { struct snd_vx222 *chip = (struct snd_vx222 *)_chip; int err; diff --git a/sound/pcmcia/vx/vxp_mixer.c b/sound/pcmcia/vx/vxp_mixer.c index aeaef3d..9450149 100644 --- a/sound/pcmcia/vx/vxp_mixer.c +++ b/sound/pcmcia/vx/vxp_mixer.c @@ -31,7 +31,7 @@ /* * mic level control (for VXPocket) */ -static int vx_mic_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_mic_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -40,17 +40,17 @@ static int vx_mic_level_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinf return 0; } -static int vx_mic_level_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *_chip = snd_kcontrol_chip(kcontrol); + struct vx_core *_chip = snd_kcontrol_chip(kcontrol); struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; ucontrol->value.integer.value[0] = chip->mic_level; return 0; } -static int vx_mic_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *_chip = snd_kcontrol_chip(kcontrol); + struct vx_core *_chip = snd_kcontrol_chip(kcontrol); struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; down(&_chip->mixer_mutex); if (chip->mic_level != ucontrol->value.integer.value[0]) { @@ -63,7 +63,7 @@ static int vx_mic_level_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon return 0; } -static snd_kcontrol_new_t vx_control_mic_level = { +static struct snd_kcontrol_new vx_control_mic_level = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic Capture Volume", .info = vx_mic_level_info, @@ -74,7 +74,7 @@ static snd_kcontrol_new_t vx_control_mic_level = { /* * mic boost level control (for VXP440) */ -static int vx_mic_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int vx_mic_boost_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -83,17 +83,17 @@ static int vx_mic_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinf return 0; } -static int vx_mic_boost_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_mic_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *_chip = snd_kcontrol_chip(kcontrol); + struct vx_core *_chip = snd_kcontrol_chip(kcontrol); struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; ucontrol->value.integer.value[0] = chip->mic_level; return 0; } -static int vx_mic_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int vx_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - vx_core_t *_chip = snd_kcontrol_chip(kcontrol); + struct vx_core *_chip = snd_kcontrol_chip(kcontrol); struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; down(&_chip->mixer_mutex); if (chip->mic_level != ucontrol->value.integer.value[0]) { @@ -106,7 +106,7 @@ static int vx_mic_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon return 0; } -static snd_kcontrol_new_t vx_control_mic_boost = { +static struct snd_kcontrol_new vx_control_mic_boost = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic Boost", .info = vx_mic_boost_info, @@ -115,7 +115,7 @@ static snd_kcontrol_new_t vx_control_mic_boost = { }; -int vxp_add_mic_controls(vx_core_t *_chip) +int vxp_add_mic_controls(struct vx_core *_chip) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; int err; diff --git a/sound/pcmcia/vx/vxp_ops.c b/sound/pcmcia/vx/vxp_ops.c index 2754d657..7f82f61 100644 --- a/sound/pcmcia/vx/vxp_ops.c +++ b/sound/pcmcia/vx/vxp_ops.c @@ -49,7 +49,7 @@ static int vxp_reg_offset[VX_REG_MAX] = { }; -static inline unsigned long vxp_reg_addr(vx_core_t *_chip, int reg) +static inline unsigned long vxp_reg_addr(struct vx_core *_chip, int reg) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; return chip->port + vxp_reg_offset[reg]; @@ -59,7 +59,7 @@ static inline unsigned long vxp_reg_addr(vx_core_t *_chip, int reg) * snd_vx_inb - read a byte from the register * @offset: register offset */ -static unsigned char vxp_inb(vx_core_t *chip, int offset) +static unsigned char vxp_inb(struct vx_core *chip, int offset) { return inb(vxp_reg_addr(chip, offset)); } @@ -69,7 +69,7 @@ static unsigned char vxp_inb(vx_core_t *chip, int offset) * @offset: the register offset * @val: the value to write */ -static void vxp_outb(vx_core_t *chip, int offset, unsigned char val) +static void vxp_outb(struct vx_core *chip, int offset, unsigned char val) { outb(val, vxp_reg_addr(chip, offset)); } @@ -78,9 +78,9 @@ static void vxp_outb(vx_core_t *chip, int offset, unsigned char val) * redefine macros to call directly */ #undef vx_inb -#define vx_inb(chip,reg) vxp_inb((vx_core_t*)(chip), VX_##reg) +#define vx_inb(chip,reg) vxp_inb((struct vx_core *)(chip), VX_##reg) #undef vx_outb -#define vx_outb(chip,reg,val) vxp_outb((vx_core_t*)(chip), VX_##reg,val) +#define vx_outb(chip,reg,val) vxp_outb((struct vx_core *)(chip), VX_##reg,val) /* @@ -88,7 +88,7 @@ static void vxp_outb(vx_core_t *chip, int offset, unsigned char val) * * returns zero if a magic word is detected, or a negative error code. */ -static int vx_check_magic(vx_core_t *chip) +static int vx_check_magic(struct vx_core *chip) { unsigned long end_time = jiffies + HZ / 5; int c; @@ -109,7 +109,7 @@ static int vx_check_magic(vx_core_t *chip) #define XX_DSP_RESET_WAIT_TIME 2 /* ms */ -static void vxp_reset_dsp(vx_core_t *_chip) +static void vxp_reset_dsp(struct vx_core *_chip) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; @@ -127,7 +127,7 @@ static void vxp_reset_dsp(vx_core_t *_chip) /* * reset codec bit */ -static void vxp_reset_codec(vx_core_t *_chip) +static void vxp_reset_codec(struct vx_core *_chip) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; @@ -146,7 +146,7 @@ static void vxp_reset_codec(vx_core_t *_chip) * vx_load_xilinx_binary - load the xilinx binary image * the binary image is the binary array converted from the bitstream file. */ -static int vxp_load_xilinx_binary(vx_core_t *_chip, const struct firmware *fw) +static int vxp_load_xilinx_binary(struct vx_core *_chip, const struct firmware *fw) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; unsigned int i; @@ -244,7 +244,7 @@ static int vxp_load_xilinx_binary(vx_core_t *_chip, const struct firmware *fw) /* * vxp_load_dsp - load_dsp callback */ -static int vxp_load_dsp(vx_core_t *vx, int index, const struct firmware *fw) +static int vxp_load_dsp(struct vx_core *vx, int index, const struct firmware *fw) { int err; @@ -279,7 +279,7 @@ static int vxp_load_dsp(vx_core_t *vx, int index, const struct firmware *fw) * * spinlock held! */ -static int vxp_test_and_ack(vx_core_t *_chip) +static int vxp_test_and_ack(struct vx_core *_chip) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; @@ -306,7 +306,7 @@ static int vxp_test_and_ack(vx_core_t *_chip) /* * vx_validate_irq - enable/disable IRQ */ -static void vxp_validate_irq(vx_core_t *_chip, int enable) +static void vxp_validate_irq(struct vx_core *_chip, int enable) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; @@ -322,7 +322,7 @@ static void vxp_validate_irq(vx_core_t *_chip, int enable) * vx_setup_pseudo_dma - set up the pseudo dma read/write mode. * @do_write: 0 = read, 1 = set up for DMA write */ -static void vx_setup_pseudo_dma(vx_core_t *_chip, int do_write) +static void vx_setup_pseudo_dma(struct vx_core *_chip, int do_write) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; @@ -342,7 +342,7 @@ static void vx_setup_pseudo_dma(vx_core_t *_chip, int do_write) /* * vx_release_pseudo_dma - disable the pseudo-DMA mode */ -static void vx_release_pseudo_dma(vx_core_t *_chip) +static void vx_release_pseudo_dma(struct vx_core *_chip) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; @@ -362,8 +362,8 @@ static void vx_release_pseudo_dma(vx_core_t *_chip) * data size must be aligned to 6 bytes to ensure the 24bit alignment on DSP. * NB: call with a certain lock! */ -static void vxp_dma_write(vx_core_t *chip, snd_pcm_runtime_t *runtime, - vx_pipe_t *pipe, int count) +static void vxp_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int count) { long port = vxp_reg_addr(chip, VX_DMA); int offset = pipe->hw_ptr; @@ -401,8 +401,8 @@ static void vxp_dma_write(vx_core_t *chip, snd_pcm_runtime_t *runtime, * the read length must be aligned to 6 bytes, as well as write. * NB: call with a certain lock! */ -static void vxp_dma_read(vx_core_t *chip, snd_pcm_runtime_t *runtime, - vx_pipe_t *pipe, int count) +static void vxp_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime, + struct vx_pipe *pipe, int count) { struct snd_vxpocket *pchip = (struct snd_vxpocket *)chip; long port = vxp_reg_addr(chip, VX_DMA); @@ -442,7 +442,7 @@ static void vxp_dma_read(vx_core_t *chip, snd_pcm_runtime_t *runtime, /* * write a codec data (24bit) */ -static void vxp_write_codec_reg(vx_core_t *chip, int codec, unsigned int data) +static void vxp_write_codec_reg(struct vx_core *chip, int codec, unsigned int data) { int i; @@ -465,7 +465,7 @@ static void vxp_write_codec_reg(vx_core_t *chip, int codec, unsigned int data) * vx_set_mic_boost - set mic boost level (on vxp440 only) * @boost: 0 = 20dB, 1 = +38dB */ -void vx_set_mic_boost(vx_core_t *chip, int boost) +void vx_set_mic_boost(struct vx_core *chip, int boost) { struct snd_vxpocket *pchip = (struct snd_vxpocket *)chip; unsigned long flags; @@ -508,7 +508,7 @@ static int vx_compute_mic_level(int level) * vx_set_mic_level - set mic level (on vxpocket only) * @level: the mic level = 0 - 8 (max) */ -void vx_set_mic_level(vx_core_t *chip, int level) +void vx_set_mic_level(struct vx_core *chip, int level) { struct snd_vxpocket *pchip = (struct snd_vxpocket *)chip; unsigned long flags; @@ -528,7 +528,7 @@ void vx_set_mic_level(vx_core_t *chip, int level) /* * change the input audio source */ -static void vxp_change_audio_source(vx_core_t *_chip, int src) +static void vxp_change_audio_source(struct vx_core *_chip, int src) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; @@ -568,7 +568,7 @@ static void vxp_change_audio_source(vx_core_t *_chip, int src) * change the clock source * source = INTERNAL_QUARTZ or UER_SYNC */ -static void vxp_set_clock_source(vx_core_t *_chip, int source) +static void vxp_set_clock_source(struct vx_core *_chip, int source) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; @@ -583,7 +583,7 @@ static void vxp_set_clock_source(vx_core_t *_chip, int source) /* * reset the board */ -static void vxp_reset_board(vx_core_t *_chip, int cold_reset) +static void vxp_reset_board(struct vx_core *_chip, int cold_reset) { struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 1e8f16b..0096297 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -83,9 +83,9 @@ static void vxpocket_release(dev_link_t *link) /* * destructor, called from snd_card_free_in_thread() */ -static int snd_vxpocket_dev_free(snd_device_t *device) +static int snd_vxpocket_dev_free(struct snd_device *device) { - vx_core_t *chip = device->device_data; + struct vx_core *chip = device->device_data; snd_vx_free_firmware(chip); kfree(chip); @@ -142,19 +142,19 @@ static struct snd_vx_hardware vxp440_hw = { /* * create vxpocket instance */ -static struct snd_vxpocket *snd_vxpocket_new(snd_card_t *card, int ibl) +static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) { client_reg_t client_reg; /* Register with cardmgr */ dev_link_t *link; /* Info for cardmgr */ - vx_core_t *chip; + struct vx_core *chip; struct snd_vxpocket *vxp; int ret; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_vxpocket_dev_free, }; chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops, - sizeof(struct snd_vxpocket) - sizeof(vx_core_t)); + sizeof(struct snd_vxpocket) - sizeof(struct vx_core)); if (! chip) return NULL; @@ -218,10 +218,10 @@ static struct snd_vxpocket *snd_vxpocket_new(snd_card_t *card, int ibl) * * returns 0 if successful, or a negative error code. */ -static int snd_vxpocket_assign_resources(vx_core_t *chip, int port, int irq) +static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq) { int err; - snd_card_t *card = chip->card; + struct snd_card *card = chip->card; struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; snd_printdd(KERN_DEBUG "vxpocket assign resources: port = 0x%x, irq = %d\n", port, irq); @@ -250,7 +250,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static void vxpocket_config(dev_link_t *link) { client_handle_t handle = link->handle; - vx_core_t *chip = link->priv; + struct vx_core *chip = link->priv; struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; tuple_t tuple; cisparse_t *parse; @@ -324,7 +324,7 @@ failed: static int vxpocket_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - vx_core_t *chip = link->priv; + struct vx_core *chip = link->priv; switch (event) { case CS_EVENT_CARD_REMOVAL: @@ -379,7 +379,7 @@ static int vxpocket_event(event_t event, int priority, event_callback_args_t *ar */ static dev_link_t *vxpocket_attach(void) { - snd_card_t *card; + struct snd_card *card; struct snd_vxpocket *vxp; int i; @@ -421,14 +421,14 @@ static dev_link_t *vxpocket_attach(void) static void vxpocket_detach(dev_link_t *link) { struct snd_vxpocket *vxp; - vx_core_t *chip; + struct vx_core *chip; dev_link_t **linkp; if (! link) return; vxp = link->priv; - chip = (vx_core_t *)vxp; + chip = (struct vx_core *)vxp; card_alloc &= ~(1 << vxp->index); /* Remove the interface data from the linked list */ diff --git a/sound/pcmcia/vx/vxpocket.h b/sound/pcmcia/vx/vxpocket.h index 70754aa..67efae3 100644 --- a/sound/pcmcia/vx/vxpocket.h +++ b/sound/pcmcia/vx/vxpocket.h @@ -30,7 +30,7 @@ struct snd_vxpocket { - vx_core_t core; + struct vx_core core; unsigned long port; @@ -48,10 +48,10 @@ struct snd_vxpocket { extern struct snd_vx_ops snd_vxpocket_ops; -void vx_set_mic_boost(vx_core_t *chip, int boost); -void vx_set_mic_level(vx_core_t *chip, int level); +void vx_set_mic_boost(struct vx_core *chip, int boost); +void vx_set_mic_level(struct vx_core *chip, int level); -int vxp_add_mic_controls(vx_core_t *chip); +int vxp_add_mic_controls(struct vx_core *chip); /* Constants used to access the CDSP register (0x08). */ #define CDSP_MAGIC 0xA7 /* magic value (for read) */ -- cgit v1.1 From 3d19f804ef5f1d15fe001fc8d1ed58fac9d591fb Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:48:14 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI CS46xx Modules: CS46xx driver Remove xxx_t typedefs from the PCI CS46xx driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/cs46xx.h | 87 +++-- include/sound/cs46xx_dsp_scb_types.h | 145 +++++---- include/sound/cs46xx_dsp_spos.h | 119 ++++--- include/sound/cs46xx_dsp_task_types.h | 35 +- sound/pci/cs46xx/cs46xx.c | 4 +- sound/pci/cs46xx/cs46xx_lib.c | 584 +++++++++++++++++----------------- sound/pci/cs46xx/cs46xx_lib.h | 211 ++++++------ sound/pci/cs46xx/dsp_spos.c | 264 ++++++++------- sound/pci/cs46xx/dsp_spos.h | 18 +- sound/pci/cs46xx/dsp_spos_scb_lib.c | 338 ++++++++++---------- sound/pci/cs46xx/imgs/cwc4630.h | 6 +- sound/pci/cs46xx/imgs/cwcasync.h | 6 +- sound/pci/cs46xx/imgs/cwcbinhack.h | 6 +- sound/pci/cs46xx/imgs/cwcdma.h | 6 +- sound/pci/cs46xx/imgs/cwcemb80.h | 6 +- sound/pci/cs46xx/imgs/cwcsnoop.h | 6 +- 16 files changed, 938 insertions(+), 903 deletions(-) diff --git a/include/sound/cs46xx.h b/include/sound/cs46xx.h index b0c0e19..b33ca2a 100644 --- a/include/sound/cs46xx.h +++ b/include/sound/cs46xx.h @@ -1631,42 +1631,41 @@ #define CS46XX_MIXER_SPDIF_INPUT_ELEMENT 1 #define CS46XX_MIXER_SPDIF_OUTPUT_ELEMENT 2 -typedef struct _snd_cs46xx cs46xx_t; -typedef struct _snd_cs46xx_pcm_t { +struct snd_cs46xx_pcm { struct snd_dma_buffer hw_buf; unsigned int ctl; unsigned int shift; /* Shift count to trasform frames in bytes */ - snd_pcm_indirect_t pcm_rec; - snd_pcm_substream_t *substream; + struct snd_pcm_indirect pcm_rec; + struct snd_pcm_substream *substream; - pcm_channel_descriptor_t * pcm_channel; + struct dsp_pcm_channel_descriptor * pcm_channel; int pcm_channel_id; /* Fron Rear, Center Lfe ... */ -} cs46xx_pcm_t; +}; -typedef struct { +struct snd_cs46xx_region { char name[24]; unsigned long base; void __iomem *remap_addr; unsigned long size; struct resource *resource; -} snd_cs46xx_region_t; +}; -struct _snd_cs46xx { +struct snd_cs46xx { int irq; unsigned long ba0_addr; unsigned long ba1_addr; union { struct { - snd_cs46xx_region_t ba0; - snd_cs46xx_region_t data0; - snd_cs46xx_region_t data1; - snd_cs46xx_region_t pmem; - snd_cs46xx_region_t reg; + struct snd_cs46xx_region ba0; + struct snd_cs46xx_region data0; + struct snd_cs46xx_region data1; + struct snd_cs46xx_region pmem; + struct snd_cs46xx_region reg; } name; - snd_cs46xx_region_t idx[5]; + struct snd_cs46xx_region idx[5]; } region; unsigned int mode; @@ -1676,34 +1675,34 @@ struct _snd_cs46xx { unsigned int ctl; unsigned int shift; /* Shift count to trasform frames in bytes */ - snd_pcm_indirect_t pcm_rec; - snd_pcm_substream_t *substream; + struct snd_pcm_indirect pcm_rec; + struct snd_pcm_substream *substream; } capt; int nr_ac97_codecs; - ac97_bus_t *ac97_bus; - ac97_t *ac97[MAX_NR_AC97]; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97[MAX_NR_AC97]; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; + struct snd_card *card; + struct snd_pcm *pcm; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *midi_input; - snd_rawmidi_substream_t *midi_output; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *midi_input; + struct snd_rawmidi_substream *midi_output; spinlock_t reg_lock; unsigned int midcr; unsigned int uartm; int amplifier; - void (*amplifier_ctrl)(cs46xx_t *, int); - void (*active_ctrl)(cs46xx_t *, int); - void (*mixer_init)(cs46xx_t *); + void (*amplifier_ctrl)(struct snd_cs46xx *, int); + void (*active_ctrl)(struct snd_cs46xx *, int); + void (*mixer_init)(struct snd_cs46xx *); int acpi_port; - snd_kcontrol_t *eapd_switch; /* for amplifier hack */ + struct snd_kcontrol *eapd_switch; /* for amplifier hack */ int accept_valid; /* accept mmap valid (for OSS) */ struct gameport *gameport; @@ -1714,29 +1713,29 @@ struct _snd_cs46xx { #ifdef CONFIG_SND_CS46XX_NEW_DSP struct semaphore spos_mutex; - dsp_spos_instance_t * dsp_spos_instance; + struct dsp_spos_instance * dsp_spos_instance; - snd_pcm_t *pcm_rear; - snd_pcm_t *pcm_center_lfe; - snd_pcm_t *pcm_iec958; + struct snd_pcm *pcm_rear; + struct snd_pcm *pcm_center_lfe; + struct snd_pcm *pcm_iec958; #else /* for compatibility */ - cs46xx_pcm_t *playback_pcm; + struct snd_cs46xx_pcm *playback_pcm; unsigned int play_ctl; #endif }; -int snd_cs46xx_create(snd_card_t *card, +int snd_cs46xx_create(struct snd_card *card, struct pci_dev *pci, int external_amp, int thinkpad, - cs46xx_t **rcodec); - -int snd_cs46xx_pcm(cs46xx_t *chip, int device, snd_pcm_t **rpcm); -int snd_cs46xx_pcm_rear(cs46xx_t *chip, int device, snd_pcm_t **rpcm); -int snd_cs46xx_pcm_iec958(cs46xx_t *chip, int device, snd_pcm_t **rpcm); -int snd_cs46xx_pcm_center_lfe(cs46xx_t *chip, int device, snd_pcm_t **rpcm); -int snd_cs46xx_mixer(cs46xx_t *chip, int spdif_device); -int snd_cs46xx_midi(cs46xx_t *chip, int device, snd_rawmidi_t **rmidi); -int snd_cs46xx_start_dsp(cs46xx_t *chip); -int snd_cs46xx_gameport(cs46xx_t *chip); + struct snd_cs46xx **rcodec); + +int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); +int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); +int snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); +int snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); +int snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device); +int snd_cs46xx_midi(struct snd_cs46xx *chip, int device, struct snd_rawmidi **rmidi); +int snd_cs46xx_start_dsp(struct snd_cs46xx *chip); +int snd_cs46xx_gameport(struct snd_cs46xx *chip); #endif /* __SOUND_CS46XX_H */ diff --git a/include/sound/cs46xx_dsp_scb_types.h b/include/sound/cs46xx_dsp_scb_types.h index 3f990a3..9cb6c7d 100644 --- a/include/sound/cs46xx_dsp_scb_types.h +++ b/include/sound/cs46xx_dsp_scb_types.h @@ -41,7 +41,7 @@ /* This structs are used internally by the SP */ -typedef struct _basic_dma_req_t { +struct dsp_basic_dma_req { /* DMA Requestor Word 0 (DCW) fields: 31 [30-28]27 [26:24] 23 22 21 20 [19:18] [17:16] 15 14 13 12 11 10 9 8 7 6 [5:0] @@ -53,9 +53,9 @@ typedef struct _basic_dma_req_t { u32 dmw; /* DMA Mode Word */ u32 saw; /* Source Address Word */ u32 daw; /* Destination Address Word */ -} basic_dma_req_t; +}; -typedef struct _scatter_gather_ext_t { +struct dsp_scatter_gather_ext { u32 npaw; /* Next-Page Address Word */ /* DMA Requestor Word 5 (NPCW) fields: @@ -69,9 +69,9 @@ typedef struct _scatter_gather_ext_t { u32 lbaw; /* Loop-Begin Address Word */ u32 nplbaw; /* Next-Page after Loop-Begin Address Word */ u32 sgaw; /* Scatter/Gather Address Word */ -} scatter_gather_ext_t; +}; -typedef struct _volume_control_t { +struct dsp_volume_control { ___DSP_DUAL_16BIT_ALLOC( rightTarg, /* Target volume for left & right channels */ leftTarg @@ -80,10 +80,10 @@ typedef struct _volume_control_t { rightVol, /* Current left & right channel volumes */ leftVol ) -} volume_control_t; +}; /* Generic stream control block (SCB) structure definition */ -typedef struct _generic_scb_t { +struct dsp_generic_scb { /* For streaming I/O, the DSP should never alter any words in the DMA requestor or the scatter/gather extension. Only ad hoc DMA request streams are free to alter the requestor (currently only occur in the @@ -99,13 +99,13 @@ typedef struct _generic_scb_t { /* Initialized by the host, only modified by DMA R/O for the DSP task */ - basic_dma_req_t basic_req; /* Optional */ + struct dsp_basic_dma_req basic_req; /* Optional */ /* Scatter/gather DMA requestor extension (5 ints) Initialized by the host, only modified by DMA DSP task never needs to even read these. */ - scatter_gather_ext_t sg_ext; /* Optional */ + struct dsp_scatter_gather_ext sg_ext; /* Optional */ /* Sublist pointer & next stream control block (SCB) link. Initialized & modified by the host R/O for the DSP task @@ -179,11 +179,11 @@ typedef struct _generic_scb_t { These two 32-bit words are redefined for wavetable & 3-D voices. */ - volume_control_t vol_ctrl_t; /* Optional */ -} generic_scb_t; + struct dsp_volume_control vol_ctrl_t; /* Optional */ +}; -typedef struct _spos_control_block_t { +struct dsp_spos_control_block { /* WARNING: Certain items in this structure are modified by the host Any dword that can be modified by the host, must not be modified by the SP as the host can only do atomic dword @@ -273,10 +273,10 @@ typedef struct _spos_control_block_t { u32 r32_save_for_spurious_int; u32 r32_save_for_trap; u32 r32_save_for_HFG; -} spos_control_block_t; +}; /* SPB for MIX_TO_OSTREAM algorithm family */ -typedef struct _mix2_ostream_spb_t +struct dsp_mix2_ostream_spb { /* 16b.16b integer.frac approximation to the number of 3 sample triplets to output each @@ -290,13 +290,13 @@ typedef struct _mix2_ostream_spb_t output triplets since the start of group */ u32 accumOutTriplets; -} mix2_ostream_spb_t; +}; /* SCB for Timing master algorithm */ -typedef struct _timing_master_scb_t { +struct dsp_timing_master_scb { /* First 12 dwords from generic_scb_t */ - basic_dma_req_t basic_req; /* Optional */ - scatter_gather_ext_t sg_ext; /* Optional */ + struct dsp_basic_dma_req basic_req; /* Optional */ + struct dsp_scatter_gather_ext sg_ext; /* Optional */ ___DSP_DUAL_16BIT_ALLOC( next_scb, /* REQUIRED */ sub_list_ptr /* REQUIRED */ @@ -358,13 +358,13 @@ typedef struct _timing_master_scb_t { number of samples to output each frame. (approximation must be floor, to insure */ u32 nsamp_per_frm_q15; -} timing_master_scb_t; +}; /* SCB for CODEC output algorithm */ -typedef struct _codec_output_scb_t { +struct dsp_codec_output_scb { /* First 13 dwords from generic_scb_t */ - basic_dma_req_t basic_req; /* Optional */ - scatter_gather_ext_t sg_ext; /* Optional */ + struct dsp_basic_dma_req basic_req; /* Optional */ + struct dsp_scatter_gather_ext sg_ext; /* Optional */ ___DSP_DUAL_16BIT_ALLOC( next_scb, /* REQUIRED */ sub_list_ptr /* REQUIRED */ @@ -422,13 +422,13 @@ typedef struct _codec_output_scb_t { reserved, last_sub_ptr ) -} codec_output_scb_t; +}; /* SCB for CODEC input algorithm */ -typedef struct _codec_input_scb_t { +struct dsp_codec_input_scb { /* First 13 dwords from generic_scb_t */ - basic_dma_req_t basic_req; /* Optional */ - scatter_gather_ext_t sg_ext; /* Optional */ + struct dsp_basic_dma_req basic_req; /* Optional */ + struct dsp_scatter_gather_ext sg_ext; /* Optional */ ___DSP_DUAL_16BIT_ALLOC( next_scb, /* REQUIRED */ sub_list_ptr /* REQUIRED */ @@ -479,13 +479,13 @@ typedef struct _codec_input_scb_t { ) u32 reserved2; -} codec_input_scb_t; +}; -typedef struct _pcm_serial_input_scb_t { +struct dsp_pcm_serial_input_scb { /* First 13 dwords from generic_scb_t */ - basic_dma_req_t basic_req; /* Optional */ - scatter_gather_ext_t sg_ext; /* Optional */ + struct dsp_basic_dma_req basic_req; /* Optional */ + struct dsp_scatter_gather_ext sg_ext; /* Optional */ ___DSP_DUAL_16BIT_ALLOC( next_scb, /* REQUIRED */ sub_list_ptr /* REQUIRED */ @@ -512,11 +512,11 @@ typedef struct _pcm_serial_input_scb_t { ) /* Initialized by the host (host updates target volumes) */ - volume_control_t psi_vol_ctrl; + struct dsp_volume_control psi_vol_ctrl; -} pcm_serial_input_scb_t; +}; -typedef struct _src_task_scb_t { +struct dsp_src_task_scb { ___DSP_DUAL_16BIT_ALLOC( frames_left_in_gof, gofs_left_in_sec @@ -571,10 +571,10 @@ typedef struct _src_task_scb_t { u32 phiIncr6int_26frac; - volume_control_t src_vol_ctrl; -} src_task_scb_t; + struct dsp_volume_control src_vol_ctrl; +}; -typedef struct _decimate_by_pow2_scb_t { +struct dsp_decimate_by_pow2_scb { /* decimationFactor = 2, 4, or 8 (larger factors waste too much memory when compared to cascading decimators) */ @@ -648,10 +648,10 @@ typedef struct _decimate_by_pow2_scb_t { u32 dec2_reserved4; - volume_control_t dec2_vol_ctrl; /* Not used! */ -} decimate_by_pow2_scb_t; + struct dsp_volume_control dec2_vol_ctrl; /* Not used! */ +}; -typedef struct _vari_decimate_scb_t { +struct dsp_vari_decimate_scb { ___DSP_DUAL_16BIT_ALLOC( vdec_frames_left_in_gof, vdec_gofs_left_in_sec @@ -711,15 +711,15 @@ typedef struct _vari_decimate_scb_t { u32 vdec_phi_incr_6int_26frac; - volume_control_t vdec_vol_ctrl; -} vari_decimate_scb_t; + struct dsp_volume_control vdec_vol_ctrl; +}; /* SCB for MIX_TO_OSTREAM algorithm family */ -typedef struct _mix2_ostream_scb_t { +struct dsp_mix2_ostream_scb { /* First 13 dwords from generic_scb_t */ - basic_dma_req_t basic_req; /* Optional */ - scatter_gather_ext_t sg_ext; /* Optional */ + struct dsp_basic_dma_req basic_req; /* Optional */ + struct dsp_scatter_gather_ext sg_ext; /* Optional */ ___DSP_DUAL_16BIT_ALLOC( next_scb, /* REQUIRED */ sub_list_ptr /* REQUIRED */ @@ -758,14 +758,14 @@ typedef struct _mix2_ostream_scb_t { const_FFFF, const_zero ) -} mix2_ostream_scb_t; +}; /* SCB for S16_MIX algorithm */ -typedef struct _mix_only_scb_t { +struct dsp_mix_only_scb { /* First 13 dwords from generic_scb_t */ - basic_dma_req_t basic_req; /* Optional */ - scatter_gather_ext_t sg_ext; /* Optional */ + struct dsp_basic_dma_req basic_req; /* Optional */ + struct dsp_scatter_gather_ext sg_ext; /* Optional */ ___DSP_DUAL_16BIT_ALLOC( next_scb, /* REQUIRED */ sub_list_ptr /* REQUIRED */ @@ -780,11 +780,11 @@ typedef struct _mix_only_scb_t { u32 strm_buf_ptr; /* REQUIRED */ u32 reserved; - volume_control_t vol_ctrl; -} mix_only_scb_t; + struct dsp_volume_control vol_ctrl; +}; /* SCB for the async. CODEC input algorithm */ -typedef struct _async_codec_input_scb_t { +struct dsp_async_codec_input_scb { u32 io_free2; u32 io_current_total; @@ -837,11 +837,11 @@ typedef struct _async_codec_input_scb_t { ) u32 i_free; -} async_codec_input_scb_t; +}; /* SCB for the SP/DIF CODEC input and output */ -typedef struct _spdifiscb_t { +struct dsp_spdifiscb { ___DSP_DUAL_16BIT_ALLOC( status_ptr, status_start_ptr @@ -895,12 +895,11 @@ typedef struct _spdifiscb_t { ) u32 free1; -} spdifiscb_t; +}; /* SCB for the SP/DIF CODEC input and output */ -typedef struct _spdifoscb_t { - +struct dsp_spdifoscb { u32 free2; @@ -941,11 +940,10 @@ typedef struct _spdifoscb_t { ) u32 free1; -} spdifoscb_t; - +}; -typedef struct _asynch_fg_rx_scb_t { +struct dsp_asynch_fg_rx_scb { ___DSP_DUAL_16BIT_ALLOC( bot_buf_mask, buf_Mask @@ -993,11 +991,10 @@ typedef struct _asynch_fg_rx_scb_t { right_vol, left_vol ) -} asynch_fg_rx_scb_t; - +}; -typedef struct _asynch_fg_tx_scb_t { +struct dsp_asynch_fg_tx_scb { ___DSP_DUAL_16BIT_ALLOC( not_buf_mask, buf_mask @@ -1052,13 +1049,13 @@ typedef struct _asynch_fg_tx_scb_t { unused_right_vol, unused_left_vol ) -} asynch_fg_tx_scb_t; +}; -typedef struct _output_snoop_scb_t { +struct dsp_output_snoop_scb { /* First 13 dwords from generic_scb_t */ - basic_dma_req_t basic_req; /* Optional */ - scatter_gather_ext_t sg_ext; /* Optional */ + struct dsp_basic_dma_req basic_req; /* Optional */ + struct dsp_scatter_gather_ext sg_ext; /* Optional */ ___DSP_DUAL_16BIT_ALLOC( next_scb, /* REQUIRED */ sub_list_ptr /* REQUIRED */ @@ -1083,9 +1080,9 @@ typedef struct _output_snoop_scb_t { reserved, input_scb ) -} output_snoop_scb_t; +}; -typedef struct _spio_write_scb_t { +struct dsp_spio_write_scb { ___DSP_DUAL_16BIT_ALLOC( address1, address2 @@ -1122,9 +1119,9 @@ typedef struct _spio_write_scb_t { ) u32 unused3[5]; -} spio_write_scb_t; +}; -typedef struct _magic_snoop_task_t { +struct dsp_magic_snoop_task { u32 i0; u32 i1; @@ -1155,11 +1152,11 @@ typedef struct _magic_snoop_task_t { u32 i8; - volume_control_t vdec_vol_ctrl; -} magic_snoop_task_t; + struct dsp_volume_control vdec_vol_ctrl; +}; -typedef struct _filter_scb_t { +struct dsp_filter_scb { ___DSP_DUAL_16BIT_ALLOC( a0_right, /* 0x00 */ a0_left @@ -1212,5 +1209,5 @@ typedef struct _filter_scb_t { b2_right, /* 0x0F */ b2_left ) -} filter_scb_t; +}; #endif /* __DSP_SCB_TYPES_H__ */ diff --git a/include/sound/cs46xx_dsp_spos.h b/include/sound/cs46xx_dsp_spos.h index 10014cb6..da934de 100644 --- a/include/sound/cs46xx_dsp_spos.h +++ b/include/sound/cs46xx_dsp_spos.h @@ -65,133 +65,130 @@ #define DSP_SPDIF_STATUS_HW_ENABLED 4 #define DSP_SPDIF_STATUS_INPUT_CTRL_ENABLED 8 -struct _dsp_module_desc_t; - -typedef struct _symbol_entry_t { +struct dsp_symbol_entry { u32 address; char symbol_name[DSP_MAX_SYMBOL_NAME]; int symbol_type; /* initialized by driver */ - struct _dsp_module_desc_t * module; + struct dsp_module_desc * module; int deleted; -} symbol_entry_t; +}; -typedef struct _symbol_desc_t { +struct dsp_symbol_desc { int nsymbols; - symbol_entry_t * symbols; + struct dsp_symbol_entry *symbols; /* initialized by driver */ int highest_frag_index; -} symbol_desc_t; - +}; -typedef struct _segment_desc_t { +struct dsp_segment_desc { int segment_type; u32 offset; u32 size; u32 * data; -} segment_desc_t; +}; -typedef struct _dsp_module_desc_t { +struct dsp_module_desc { char * module_name; - symbol_desc_t symbol_table; + struct dsp_symbol_desc symbol_table; int nsegments; - segment_desc_t * segments; + struct dsp_segment_desc * segments; /* initialized by driver */ u32 overlay_begin_address; u32 load_address; int nfixups; -} dsp_module_desc_t; +}; -typedef struct _dsp_scb_descriptor_t { +struct dsp_scb_descriptor { char scb_name[DSP_MAX_SCB_NAME]; u32 address; int index; - struct _dsp_scb_descriptor_t * sub_list_ptr; - struct _dsp_scb_descriptor_t * next_scb_ptr; - struct _dsp_scb_descriptor_t * parent_scb_ptr; + struct dsp_scb_descriptor * sub_list_ptr; + struct dsp_scb_descriptor * next_scb_ptr; + struct dsp_scb_descriptor * parent_scb_ptr; - symbol_entry_t * task_entry; - symbol_entry_t * scb_symbol; + struct dsp_symbol_entry * task_entry; + struct dsp_symbol_entry * scb_symbol; - snd_info_entry_t *proc_info; + struct snd_info_entry *proc_info; int ref_count; spinlock_t lock; int deleted; -} dsp_scb_descriptor_t; +}; -typedef struct _dsp_task_descriptor_t { +struct dsp_task_descriptor { char task_name[DSP_MAX_TASK_NAME]; int size; u32 address; int index; -} dsp_task_descriptor_t; +}; -typedef struct _pcm_channel_descriptor_t { +struct dsp_pcm_channel_descriptor { int active; int src_slot; int pcm_slot; u32 sample_rate; u32 unlinked; - dsp_scb_descriptor_t * pcm_reader_scb; - dsp_scb_descriptor_t * src_scb; - dsp_scb_descriptor_t * mixer_scb; + struct dsp_scb_descriptor * pcm_reader_scb; + struct dsp_scb_descriptor * src_scb; + struct dsp_scb_descriptor * mixer_scb; void * private_data; -} pcm_channel_descriptor_t; +}; -typedef struct _dsp_spos_instance_t { - symbol_desc_t symbol_table; /* currently availble loaded symbols in SP */ +struct dsp_spos_instance { + struct dsp_symbol_desc symbol_table; /* currently availble loaded symbols in SP */ int nmodules; - dsp_module_desc_t * modules; /* modules loaded into SP */ + struct dsp_module_desc * modules; /* modules loaded into SP */ - segment_desc_t code; + struct dsp_segment_desc code; /* Main PCM playback mixer */ - dsp_scb_descriptor_t * master_mix_scb; + struct dsp_scb_descriptor * master_mix_scb; u16 dac_volume_right; u16 dac_volume_left; /* Rear/surround PCM playback mixer */ - dsp_scb_descriptor_t * rear_mix_scb; + struct dsp_scb_descriptor * rear_mix_scb; /* Center/LFE mixer */ - dsp_scb_descriptor_t * center_lfe_mix_scb; + struct dsp_scb_descriptor * center_lfe_mix_scb; int npcm_channels; int nsrc_scb; - pcm_channel_descriptor_t pcm_channels[DSP_MAX_PCM_CHANNELS]; + struct dsp_pcm_channel_descriptor pcm_channels[DSP_MAX_PCM_CHANNELS]; int src_scb_slots[DSP_MAX_SRC_NR]; /* cache this symbols */ - symbol_entry_t * null_algorithm; /* used by PCMreaderSCB's */ - symbol_entry_t * s16_up; /* used by SRCtaskSCB's */ + struct dsp_symbol_entry * null_algorithm; /* used by PCMreaderSCB's */ + struct dsp_symbol_entry * s16_up; /* used by SRCtaskSCB's */ /* proc fs */ - snd_card_t * snd_card; - snd_info_entry_t * proc_dsp_dir; - snd_info_entry_t * proc_sym_info_entry; - snd_info_entry_t * proc_modules_info_entry; - snd_info_entry_t * proc_parameter_dump_info_entry; - snd_info_entry_t * proc_sample_dump_info_entry; + struct snd_card *snd_card; + struct snd_info_entry * proc_dsp_dir; + struct snd_info_entry * proc_sym_info_entry; + struct snd_info_entry * proc_modules_info_entry; + struct snd_info_entry * proc_parameter_dump_info_entry; + struct snd_info_entry * proc_sample_dump_info_entry; /* SCB's descriptors */ int nscb; int scb_highest_frag_index; - dsp_scb_descriptor_t scbs[DSP_MAX_SCB_DESC]; - snd_info_entry_t * proc_scb_info_entry; - dsp_scb_descriptor_t * the_null_scb; + struct dsp_scb_descriptor scbs[DSP_MAX_SCB_DESC]; + struct snd_info_entry * proc_scb_info_entry; + struct dsp_scb_descriptor * the_null_scb; /* Task's descriptors */ int ntask; - dsp_task_descriptor_t tasks[DSP_MAX_TASK_DESC]; - snd_info_entry_t * proc_task_info_entry; + struct dsp_task_descriptor tasks[DSP_MAX_TASK_DESC]; + struct snd_info_entry * proc_task_info_entry; /* SPDIF status */ int spdif_status_out; @@ -204,30 +201,30 @@ typedef struct _dsp_spos_instance_t { unsigned int spdif_csuv_stream; /* SPDIF input sample rate converter */ - dsp_scb_descriptor_t * spdif_in_src; + struct dsp_scb_descriptor * spdif_in_src; /* SPDIF input asynch. receiver */ - dsp_scb_descriptor_t * asynch_rx_scb; + struct dsp_scb_descriptor * asynch_rx_scb; /* Capture record mixer SCB */ - dsp_scb_descriptor_t * record_mixer_scb; + struct dsp_scb_descriptor * record_mixer_scb; /* CODEC input SCB */ - dsp_scb_descriptor_t * codec_in_scb; + struct dsp_scb_descriptor * codec_in_scb; /* reference snooper */ - dsp_scb_descriptor_t * ref_snoop_scb; + struct dsp_scb_descriptor * ref_snoop_scb; /* SPDIF output PCM reference */ - dsp_scb_descriptor_t * spdif_pcm_input_scb; + struct dsp_scb_descriptor * spdif_pcm_input_scb; /* asynch TX task */ - dsp_scb_descriptor_t * asynch_tx_scb; + struct dsp_scb_descriptor * asynch_tx_scb; /* record sources */ - dsp_scb_descriptor_t * pcm_input; - dsp_scb_descriptor_t * adc_input; + struct dsp_scb_descriptor * pcm_input; + struct dsp_scb_descriptor * adc_input; int spdif_in_sample_rate; -} dsp_spos_instance_t; +}; #endif /* __DSP_SPOS_H__ */ diff --git a/include/sound/cs46xx_dsp_task_types.h b/include/sound/cs46xx_dsp_task_types.h index 5dd3bf6..b3076c4 100644 --- a/include/sound/cs46xx_dsp_task_types.h +++ b/include/sound/cs46xx_dsp_task_types.h @@ -71,7 +71,7 @@ Ptr____Call (c) at the end of BG */ /* Minimal context save area for Hyper Forground */ -typedef struct _hf_save_area_t { +struct dsp_hf_save_area { u32 r10_save; u32 r54_save; u32 r98_save; @@ -96,11 +96,11 @@ typedef struct _hf_save_area_t { rsa2Save ) /* saved as part of HFG context */ -} hf_save_area_t; +}; /* Task link data structure */ -typedef struct _tree_link_t { +struct dsp_tree_link { ___DSP_DUAL_16BIT_ALLOC( /* Pointer to sibling task control block */ next_scb, @@ -114,10 +114,10 @@ typedef struct _tree_link_t { /* Pointer to local data */ this_spb ) -} tree_link_t; +}; -typedef struct _task_tree_data_t { +struct dsp_task_tree_data { ___DSP_DUAL_16BIT_ALLOC( /* Initial tock count; controls task tree execution rate */ tock_count_limit, @@ -155,11 +155,10 @@ typedef struct _task_tree_data_t { data_stack_base_ptr ) -} task_tree_data_t; +}; - -typedef struct _interval_timer_data_t +struct dsp_interval_timer_data { /* These data items have the same relative locations to those */ ___DSP_DUAL_16BIT_ALLOC( @@ -172,12 +171,12 @@ typedef struct _interval_timer_data_t num_FG_ticks_this_interval, num_intervals ) -} interval_timer_data_t; +}; /* This structure contains extra storage for the task tree Currently, this additional data is related only to a full context save */ -typedef struct _task_tree_context_block_t { +struct dsp_task_tree_context_block { /* Up to 10 values are saved onto the stack. 8 for the task tree, 1 for The access to the context switch (call or interrupt), and 1 spare that users should never use. This last may be required by the system */ @@ -238,16 +237,16 @@ typedef struct _task_tree_context_block_t { u32 saveaux2xaux3x; u32 savershouthl; u32 savershoutxmacmode; -} task_tree_context_block_t; +}; -typedef struct _task_tree_control_block_t { - hf_save_area_t context; - tree_link_t links; - task_tree_data_t data; - task_tree_context_block_t context_blk; - interval_timer_data_t int_timer; -} task_tree_control_block_t; +struct dsp_task_tree_control_block { + struct dsp_hf_save_area context; + struct dsp_tree_link links; + struct dsp_task_tree_data data; + struct dsp_task_tree_context_block context_blk; + struct dsp_interval_timer_data int_timer; +}; #endif /* __DSP_TASK_TYPES_H__ */ diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index b9fff4e..7d6b29e 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c @@ -78,8 +78,8 @@ static int __devinit snd_card_cs46xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - cs46xx_t *chip; + struct snd_card *card; + struct snd_cs46xx *chip; int err; if (dev >= SNDRV_CARDS) diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 9a86148..11d91d0 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -66,23 +66,23 @@ #include "cs46xx_lib.h" #include "dsp_spos.h" -static void amp_voyetra(cs46xx_t *chip, int change); +static void amp_voyetra(struct snd_cs46xx *chip, int change); #ifdef CONFIG_SND_CS46XX_NEW_DSP -static snd_pcm_ops_t snd_cs46xx_playback_rear_ops; -static snd_pcm_ops_t snd_cs46xx_playback_indirect_rear_ops; -static snd_pcm_ops_t snd_cs46xx_playback_clfe_ops; -static snd_pcm_ops_t snd_cs46xx_playback_indirect_clfe_ops; -static snd_pcm_ops_t snd_cs46xx_playback_iec958_ops; -static snd_pcm_ops_t snd_cs46xx_playback_indirect_iec958_ops; +static struct snd_pcm_ops snd_cs46xx_playback_rear_ops; +static struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops; +static struct snd_pcm_ops snd_cs46xx_playback_clfe_ops; +static struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops; +static struct snd_pcm_ops snd_cs46xx_playback_iec958_ops; +static struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops; #endif -static snd_pcm_ops_t snd_cs46xx_playback_ops; -static snd_pcm_ops_t snd_cs46xx_playback_indirect_ops; -static snd_pcm_ops_t snd_cs46xx_capture_ops; -static snd_pcm_ops_t snd_cs46xx_capture_indirect_ops; +static struct snd_pcm_ops snd_cs46xx_playback_ops; +static struct snd_pcm_ops snd_cs46xx_playback_indirect_ops; +static struct snd_pcm_ops snd_cs46xx_capture_ops; +static struct snd_pcm_ops snd_cs46xx_capture_indirect_ops; -static unsigned short snd_cs46xx_codec_read(cs46xx_t *chip, +static unsigned short snd_cs46xx_codec_read(struct snd_cs46xx *chip, unsigned short reg, int codec_index) { @@ -204,10 +204,10 @@ static unsigned short snd_cs46xx_codec_read(cs46xx_t *chip, return result; } -static unsigned short snd_cs46xx_ac97_read(ac97_t * ac97, +static unsigned short snd_cs46xx_ac97_read(struct snd_ac97 * ac97, unsigned short reg) { - cs46xx_t *chip = ac97->private_data; + struct snd_cs46xx *chip = ac97->private_data; unsigned short val; int codec_index = ac97->num; @@ -221,7 +221,7 @@ static unsigned short snd_cs46xx_ac97_read(ac97_t * ac97, } -static void snd_cs46xx_codec_write(cs46xx_t *chip, +static void snd_cs46xx_codec_write(struct snd_cs46xx *chip, unsigned short reg, unsigned short val, int codec_index) @@ -286,11 +286,11 @@ static void snd_cs46xx_codec_write(cs46xx_t *chip, chip->active_ctrl(chip, -1); } -static void snd_cs46xx_ac97_write(ac97_t *ac97, +static void snd_cs46xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - cs46xx_t *chip = ac97->private_data; + struct snd_cs46xx *chip = ac97->private_data; int codec_index = ac97->num; snd_assert(codec_index == CS46XX_PRIMARY_CODEC_INDEX || @@ -305,7 +305,7 @@ static void snd_cs46xx_ac97_write(ac97_t *ac97, * Chip initialization */ -int snd_cs46xx_download(cs46xx_t *chip, +int snd_cs46xx_download(struct snd_cs46xx *chip, u32 *src, unsigned long offset, unsigned long len) @@ -334,7 +334,7 @@ int snd_cs46xx_download(cs46xx_t *chip, #include "imgs/cwcbinhack.h" #include "imgs/cwcdma.h" -int snd_cs46xx_clear_BA1(cs46xx_t *chip, +int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len) { @@ -358,7 +358,7 @@ int snd_cs46xx_clear_BA1(cs46xx_t *chip, #include "cs46xx_image.h" -int snd_cs46xx_download_image(cs46xx_t *chip) +int snd_cs46xx_download_image(struct snd_cs46xx *chip) { int idx, err; unsigned long offset = 0; @@ -379,7 +379,7 @@ int snd_cs46xx_download_image(cs46xx_t *chip) * Chip reset */ -static void snd_cs46xx_reset(cs46xx_t *chip) +static void snd_cs46xx_reset(struct snd_cs46xx *chip) { int idx; @@ -408,7 +408,7 @@ static void snd_cs46xx_reset(cs46xx_t *chip) snd_cs46xx_poke(chip, BA1_FRMT, 0xadf); } -static int cs46xx_wait_for_fifo(cs46xx_t * chip,int retry_timeout) +static int cs46xx_wait_for_fifo(struct snd_cs46xx * chip,int retry_timeout) { u32 i, status = 0; /* @@ -432,7 +432,7 @@ static int cs46xx_wait_for_fifo(cs46xx_t * chip,int retry_timeout) return 0; } -static void snd_cs46xx_clear_serial_FIFOs(cs46xx_t *chip) +static void snd_cs46xx_clear_serial_FIFOs(struct snd_cs46xx *chip) { int idx, powerdown = 0; unsigned int tmp; @@ -486,7 +486,7 @@ static void snd_cs46xx_clear_serial_FIFOs(cs46xx_t *chip) snd_cs46xx_pokeBA0(chip, BA0_CLKCR1, tmp); } -static void snd_cs46xx_proc_start(cs46xx_t *chip) +static void snd_cs46xx_proc_start(struct snd_cs46xx *chip) { int cnt; @@ -513,7 +513,7 @@ static void snd_cs46xx_proc_start(cs46xx_t *chip) snd_printk(KERN_ERR "SPCR_RUNFR never reset\n"); } -static void snd_cs46xx_proc_stop(cs46xx_t *chip) +static void snd_cs46xx_proc_stop(struct snd_cs46xx *chip) { /* * Turn off the run, run at frame, and DMA enable bits in the local copy of @@ -528,7 +528,7 @@ static void snd_cs46xx_proc_stop(cs46xx_t *chip) #define GOF_PER_SEC 200 -static void snd_cs46xx_set_play_sample_rate(cs46xx_t *chip, unsigned int rate) +static void snd_cs46xx_set_play_sample_rate(struct snd_cs46xx *chip, unsigned int rate) { unsigned long flags; unsigned int tmp1, tmp2; @@ -574,7 +574,7 @@ static void snd_cs46xx_set_play_sample_rate(cs46xx_t *chip, unsigned int rate) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs46xx_set_capture_sample_rate(cs46xx_t *chip, unsigned int rate) +static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned int rate) { unsigned long flags; unsigned int phiIncr, coeffIncr, tmp1, tmp2; @@ -684,43 +684,43 @@ static void snd_cs46xx_set_capture_sample_rate(cs46xx_t *chip, unsigned int rate * PCM part */ -static void snd_cs46xx_pb_trans_copy(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, size_t bytes) +static void snd_cs46xx_pb_trans_copy(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes) { - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t * cpcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm * cpcm = runtime->private_data; memcpy(cpcm->hw_buf.area + rec->hw_data, runtime->dma_area + rec->sw_data, bytes); } -static int snd_cs46xx_playback_transfer(snd_pcm_substream_t *substream) +static int snd_cs46xx_playback_transfer(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t * cpcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm * cpcm = runtime->private_data; snd_pcm_indirect_playback_transfer(substream, &cpcm->pcm_rec, snd_cs46xx_pb_trans_copy); return 0; } -static void snd_cs46xx_cp_trans_copy(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, size_t bytes) +static void snd_cs46xx_cp_trans_copy(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; memcpy(runtime->dma_area + rec->sw_data, chip->capt.hw_buf.area + rec->hw_data, bytes); } -static int snd_cs46xx_capture_transfer(snd_pcm_substream_t *substream) +static int snd_cs46xx_capture_transfer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); snd_pcm_indirect_capture_transfer(substream, &chip->capt.pcm_rec, snd_cs46xx_cp_trans_copy); return 0; } -static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); size_t ptr; - cs46xx_pcm_t *cpcm = substream->runtime->private_data; + struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; snd_assert (cpcm->pcm_channel,return -ENXIO); #ifdef CONFIG_SND_CS46XX_NEW_DSP @@ -732,11 +732,11 @@ static snd_pcm_uframes_t snd_cs46xx_playback_direct_pointer(snd_pcm_substream_t return ptr >> cpcm->shift; } -static snd_pcm_uframes_t snd_cs46xx_playback_indirect_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs46xx_playback_indirect_pointer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); size_t ptr; - cs46xx_pcm_t *cpcm = substream->runtime->private_data; + struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; #ifdef CONFIG_SND_CS46XX_NEW_DSP snd_assert (cpcm->pcm_channel,return -ENXIO); @@ -748,29 +748,29 @@ static snd_pcm_uframes_t snd_cs46xx_playback_indirect_pointer(snd_pcm_substream_ return snd_pcm_indirect_playback_pointer(substream, &cpcm->pcm_rec, ptr); } -static snd_pcm_uframes_t snd_cs46xx_capture_direct_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs46xx_capture_direct_pointer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_buf.addr; return ptr >> chip->capt.shift; } -static snd_pcm_uframes_t snd_cs46xx_capture_indirect_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs46xx_capture_indirect_pointer(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); size_t ptr = snd_cs46xx_peek(chip, BA1_CBA) - chip->capt.hw_buf.addr; return snd_pcm_indirect_capture_pointer(substream, &chip->capt.pcm_rec, ptr); } -static int snd_cs46xx_playback_trigger(snd_pcm_substream_t * substream, +static int snd_cs46xx_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - /*snd_pcm_runtime_t *runtime = substream->runtime;*/ + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + /*struct snd_pcm_runtime *runtime = substream->runtime;*/ int result = 0; #ifdef CONFIG_SND_CS46XX_NEW_DSP - cs46xx_pcm_t *cpcm = substream->runtime->private_data; + struct snd_cs46xx_pcm *cpcm = substream->runtime->private_data; if (! cpcm->pcm_channel) { return -ENXIO; } @@ -827,10 +827,10 @@ static int snd_cs46xx_playback_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_cs46xx_capture_trigger(snd_pcm_substream_t * substream, +static int snd_cs46xx_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); unsigned int tmp; int result = 0; @@ -858,7 +858,7 @@ static int snd_cs46xx_capture_trigger(snd_pcm_substream_t * substream, } #ifdef CONFIG_SND_CS46XX_NEW_DSP -static int _cs46xx_adjust_sample_rate (cs46xx_t *chip, cs46xx_pcm_t *cpcm, +static int _cs46xx_adjust_sample_rate (struct snd_cs46xx *chip, struct snd_cs46xx_pcm *cpcm, int sample_rate) { @@ -893,14 +893,14 @@ static int _cs46xx_adjust_sample_rate (cs46xx_t *chip, cs46xx_pcm_t *cpcm, #endif -static int snd_cs46xx_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs46xx_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t *cpcm; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm *cpcm; int err; #ifdef CONFIG_SND_CS46XX_NEW_DSP - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); int sample_rate = params_rate(hw_params); int period_size = params_period_bytes(hw_params); #endif @@ -995,11 +995,11 @@ static int snd_cs46xx_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_cs46xx_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_hw_free(struct snd_pcm_substream *substream) { - /*cs46xx_t *chip = snd_pcm_substream_chip(substream);*/ - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t *cpcm; + /*struct snd_cs46xx *chip = snd_pcm_substream_chip(substream);*/ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm *cpcm; cpcm = runtime->private_data; @@ -1017,13 +1017,13 @@ static int snd_cs46xx_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_playback_prepare(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_prepare(struct snd_pcm_substream *substream) { unsigned int tmp; unsigned int pfie; - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t *cpcm; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm *cpcm; cpcm = runtime->private_data; @@ -1087,11 +1087,11 @@ static int snd_cs46xx_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs46xx_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; #ifdef CONFIG_SND_CS46XX_NEW_DSP @@ -1118,10 +1118,10 @@ static int snd_cs46xx_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_cs46xx_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_cs46xx_capture_hw_free(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->dma_area != chip->capt.hw_buf.area) snd_pcm_lib_free_pages(substream); @@ -1132,10 +1132,10 @@ static int snd_cs46xx_capture_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_capture_prepare(snd_pcm_substream_t * substream) +static int snd_cs46xx_capture_prepare(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_cs46xx_poke(chip, BA1_CBA, chip->capt.hw_buf.addr); chip->capt.shift = 2; @@ -1149,13 +1149,13 @@ static int snd_cs46xx_capture_prepare(snd_pcm_substream_t * substream) static irqreturn_t snd_cs46xx_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - cs46xx_t *chip = dev_id; + struct snd_cs46xx *chip = dev_id; u32 status1; #ifdef CONFIG_SND_CS46XX_NEW_DSP - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; u32 status2; int i; - cs46xx_pcm_t *cpcm = NULL; + struct snd_cs46xx_pcm *cpcm = NULL; #endif /* @@ -1239,7 +1239,7 @@ static irqreturn_t snd_cs46xx_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_hardware_t snd_cs46xx_playback = +static struct snd_pcm_hardware snd_cs46xx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -1261,7 +1261,7 @@ static snd_pcm_hardware_t snd_cs46xx_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_cs46xx_capture = +static struct snd_pcm_hardware snd_cs46xx_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -1285,7 +1285,7 @@ static snd_pcm_hardware_t snd_cs46xx_capture = static unsigned int period_sizes[] = { 32, 64, 128, 256, 512, 1024, 2048 }; -static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = { +static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes = { .count = ARRAY_SIZE(period_sizes), .list = period_sizes, .mask = 0 @@ -1293,16 +1293,16 @@ static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = { #endif -static void snd_cs46xx_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_cs46xx_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pcm_channel_id) +static int _cs46xx_playback_open_channel (struct snd_pcm_substream *substream,int pcm_channel_id) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - cs46xx_pcm_t * cpcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx_pcm * cpcm; + struct snd_pcm_runtime *runtime = substream->runtime; cpcm = kzalloc(sizeof(*cpcm), GFP_KERNEL); if (cpcm == NULL) @@ -1340,30 +1340,30 @@ static int _cs46xx_playback_open_channel (snd_pcm_substream_t * substream,int pc return 0; } -static int snd_cs46xx_playback_open(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_open(struct snd_pcm_substream *substream) { snd_printdd("open front channel\n"); return _cs46xx_playback_open_channel(substream,DSP_PCM_MAIN_CHANNEL); } #ifdef CONFIG_SND_CS46XX_NEW_DSP -static int snd_cs46xx_playback_open_rear(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_open_rear(struct snd_pcm_substream *substream) { snd_printdd("open rear channel\n"); return _cs46xx_playback_open_channel(substream,DSP_PCM_REAR_CHANNEL); } -static int snd_cs46xx_playback_open_clfe(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_open_clfe(struct snd_pcm_substream *substream) { snd_printdd("open center - LFE channel\n"); return _cs46xx_playback_open_channel(substream,DSP_PCM_CENTER_LFE_CHANNEL); } -static int snd_cs46xx_playback_open_iec958(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_open_iec958(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); snd_printdd("open raw iec958 channel\n"); @@ -1374,12 +1374,12 @@ static int snd_cs46xx_playback_open_iec958(snd_pcm_substream_t * substream) return _cs46xx_playback_open_channel(substream,DSP_IEC958_CHANNEL); } -static int snd_cs46xx_playback_close(snd_pcm_substream_t * substream); +static int snd_cs46xx_playback_close(struct snd_pcm_substream *substream); -static int snd_cs46xx_playback_close_iec958(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_close_iec958(struct snd_pcm_substream *substream) { int err; - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); snd_printdd("close raw iec958 channel\n"); @@ -1393,9 +1393,9 @@ static int snd_cs46xx_playback_close_iec958(snd_pcm_substream_t * substream) } #endif -static int snd_cs46xx_capture_open(snd_pcm_substream_t * substream) +static int snd_cs46xx_capture_open(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), PAGE_SIZE, &chip->capt.hw_buf) < 0) @@ -1416,11 +1416,11 @@ static int snd_cs46xx_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_playback_close(snd_pcm_substream_t * substream) +static int snd_cs46xx_playback_close(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - cs46xx_pcm_t * cpcm; + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_cs46xx_pcm * cpcm; cpcm = runtime->private_data; @@ -1445,9 +1445,9 @@ static int snd_cs46xx_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_cs46xx_capture_close(snd_pcm_substream_t * substream) +static int snd_cs46xx_capture_close(struct snd_pcm_substream *substream) { - cs46xx_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs46xx *chip = snd_pcm_substream_chip(substream); chip->capt.substream = NULL; snd_dma_free_pages(&chip->capt.hw_buf); @@ -1457,7 +1457,7 @@ static int snd_cs46xx_capture_close(snd_pcm_substream_t * substream) } #ifdef CONFIG_SND_CS46XX_NEW_DSP -static snd_pcm_ops_t snd_cs46xx_playback_rear_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_rear_ops = { .open = snd_cs46xx_playback_open_rear, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1468,7 +1468,7 @@ static snd_pcm_ops_t snd_cs46xx_playback_rear_ops = { .pointer = snd_cs46xx_playback_direct_pointer, }; -static snd_pcm_ops_t snd_cs46xx_playback_indirect_rear_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_indirect_rear_ops = { .open = snd_cs46xx_playback_open_rear, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1480,7 +1480,7 @@ static snd_pcm_ops_t snd_cs46xx_playback_indirect_rear_ops = { .ack = snd_cs46xx_playback_transfer, }; -static snd_pcm_ops_t snd_cs46xx_playback_clfe_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_clfe_ops = { .open = snd_cs46xx_playback_open_clfe, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1491,7 +1491,7 @@ static snd_pcm_ops_t snd_cs46xx_playback_clfe_ops = { .pointer = snd_cs46xx_playback_direct_pointer, }; -static snd_pcm_ops_t snd_cs46xx_playback_indirect_clfe_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_indirect_clfe_ops = { .open = snd_cs46xx_playback_open_clfe, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1503,7 +1503,7 @@ static snd_pcm_ops_t snd_cs46xx_playback_indirect_clfe_ops = { .ack = snd_cs46xx_playback_transfer, }; -static snd_pcm_ops_t snd_cs46xx_playback_iec958_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_iec958_ops = { .open = snd_cs46xx_playback_open_iec958, .close = snd_cs46xx_playback_close_iec958, .ioctl = snd_pcm_lib_ioctl, @@ -1514,7 +1514,7 @@ static snd_pcm_ops_t snd_cs46xx_playback_iec958_ops = { .pointer = snd_cs46xx_playback_direct_pointer, }; -static snd_pcm_ops_t snd_cs46xx_playback_indirect_iec958_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_indirect_iec958_ops = { .open = snd_cs46xx_playback_open_iec958, .close = snd_cs46xx_playback_close_iec958, .ioctl = snd_pcm_lib_ioctl, @@ -1528,7 +1528,7 @@ static snd_pcm_ops_t snd_cs46xx_playback_indirect_iec958_ops = { #endif -static snd_pcm_ops_t snd_cs46xx_playback_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_ops = { .open = snd_cs46xx_playback_open, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1539,7 +1539,7 @@ static snd_pcm_ops_t snd_cs46xx_playback_ops = { .pointer = snd_cs46xx_playback_direct_pointer, }; -static snd_pcm_ops_t snd_cs46xx_playback_indirect_ops = { +static struct snd_pcm_ops snd_cs46xx_playback_indirect_ops = { .open = snd_cs46xx_playback_open, .close = snd_cs46xx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1551,7 +1551,7 @@ static snd_pcm_ops_t snd_cs46xx_playback_indirect_ops = { .ack = snd_cs46xx_playback_transfer, }; -static snd_pcm_ops_t snd_cs46xx_capture_ops = { +static struct snd_pcm_ops snd_cs46xx_capture_ops = { .open = snd_cs46xx_capture_open, .close = snd_cs46xx_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1562,7 +1562,7 @@ static snd_pcm_ops_t snd_cs46xx_capture_ops = { .pointer = snd_cs46xx_capture_direct_pointer, }; -static snd_pcm_ops_t snd_cs46xx_capture_indirect_ops = { +static struct snd_pcm_ops snd_cs46xx_capture_indirect_ops = { .open = snd_cs46xx_capture_open, .close = snd_cs46xx_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1580,9 +1580,9 @@ static snd_pcm_ops_t snd_cs46xx_capture_indirect_ops = { #define MAX_PLAYBACK_CHANNELS 1 #endif -int __devinit snd_cs46xx_pcm(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1611,9 +1611,9 @@ int __devinit snd_cs46xx_pcm(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) #ifdef CONFIG_SND_CS46XX_NEW_DSP -int __devinit snd_cs46xx_pcm_rear(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1640,9 +1640,9 @@ int __devinit snd_cs46xx_pcm_rear(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) return 0; } -int __devinit snd_cs46xx_pcm_center_lfe(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_cs46xx_pcm_center_lfe(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1669,9 +1669,9 @@ int __devinit snd_cs46xx_pcm_center_lfe(cs46xx_t *chip, int device, snd_pcm_t ** return 0; } -int __devinit snd_cs46xx_pcm_iec958(cs46xx_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_cs46xx_pcm_iec958(struct snd_cs46xx *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1702,16 +1702,16 @@ int __devinit snd_cs46xx_pcm_iec958(cs46xx_t *chip, int device, snd_pcm_t ** rpc /* * Mixer routines */ -static void snd_cs46xx_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_cs46xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - cs46xx_t *chip = bus->private_data; + struct snd_cs46xx *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_cs46xx_mixer_free_ac97(ac97_t *ac97) +static void snd_cs46xx_mixer_free_ac97(struct snd_ac97 *ac97) { - cs46xx_t *chip = ac97->private_data; + struct snd_cs46xx *chip = ac97->private_data; snd_assert ((ac97 == chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]) || (ac97 == chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]), @@ -1725,8 +1725,8 @@ static void snd_cs46xx_mixer_free_ac97(ac97_t *ac97) chip->ac97[CS46XX_SECONDARY_CODEC_INDEX] = NULL; } -static int snd_cs46xx_vol_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cs46xx_vol_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1735,9 +1735,9 @@ static int snd_cs46xx_vol_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_vol_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; unsigned int val = snd_cs46xx_peek(chip, reg); ucontrol->value.integer.value[0] = 0xffff - (val >> 16); @@ -1745,9 +1745,9 @@ static int snd_cs46xx_vol_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_cs46xx_vol_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; unsigned int val = ((0xffff - ucontrol->value.integer.value[0]) << 16 | (0xffff - ucontrol->value.integer.value[1])); @@ -1763,9 +1763,9 @@ static int snd_cs46xx_vol_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * #ifdef CONFIG_SND_CS46XX_NEW_DSP -static int snd_cs46xx_vol_dac_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_dac_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = chip->dsp_spos_instance->dac_volume_left; ucontrol->value.integer.value[1] = chip->dsp_spos_instance->dac_volume_right; @@ -1773,9 +1773,9 @@ static int snd_cs46xx_vol_dac_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_cs46xx_vol_dac_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_dac_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int change = 0; if (chip->dsp_spos_instance->dac_volume_right != ucontrol->value.integer.value[0] || @@ -1790,18 +1790,18 @@ static int snd_cs46xx_vol_dac_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ } #if 0 -static int snd_cs46xx_vol_iec958_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = chip->dsp_spos_instance->spdif_input_volume_left; ucontrol->value.integer.value[1] = chip->dsp_spos_instance->spdif_input_volume_right; return 0; } -static int snd_cs46xx_vol_iec958_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_vol_iec958_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int change = 0; if (chip->dsp_spos_instance->spdif_input_volume_left != ucontrol->value.integer.value[0] || @@ -1816,8 +1816,8 @@ static int snd_cs46xx_vol_iec958_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_val } #endif -static int snd_mixer_boolean_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_mixer_boolean_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1826,10 +1826,10 @@ static int snd_mixer_boolean_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_iec958_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_iec958_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; if (reg == CS46XX_MIXER_SPDIF_OUTPUT_ELEMENT) @@ -1840,10 +1840,10 @@ static int snd_cs46xx_iec958_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_iec958_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_iec958_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int change, res; switch (kcontrol->private_value) { @@ -1877,11 +1877,11 @@ static int snd_cs46xx_iec958_put(snd_kcontrol_t *kcontrol, return res; } -static int snd_cs46xx_adc_capture_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_adc_capture_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; if (ins->adc_input != NULL) ucontrol->value.integer.value[0] = 1; @@ -1891,11 +1891,11 @@ static int snd_cs46xx_adc_capture_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_adc_capture_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_adc_capture_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int change = 0; if (ucontrol->value.integer.value[0] && !ins->adc_input) { @@ -1908,11 +1908,11 @@ static int snd_cs46xx_adc_capture_put(snd_kcontrol_t *kcontrol, return change; } -static int snd_cs46xx_pcm_capture_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_pcm_capture_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; if (ins->pcm_input != NULL) ucontrol->value.integer.value[0] = 1; @@ -1923,11 +1923,11 @@ static int snd_cs46xx_pcm_capture_get(snd_kcontrol_t *kcontrol, } -static int snd_cs46xx_pcm_capture_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_pcm_capture_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int change = 0; if (ucontrol->value.integer.value[0] && !ins->pcm_input) { @@ -1941,10 +1941,10 @@ static int snd_cs46xx_pcm_capture_put(snd_kcontrol_t *kcontrol, return change; } -static int snd_herc_spdif_select_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_herc_spdif_select_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); @@ -1959,10 +1959,10 @@ static int snd_herc_spdif_select_get(snd_kcontrol_t *kcontrol, /* * Game Theatre XP card - EGPIO[0] is used to select SPDIF input optical or coaxial. */ -static int snd_herc_spdif_select_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_herc_spdif_select_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); int val2 = snd_cs46xx_peekBA0(chip, BA0_EGPIOPTR); @@ -1984,18 +1984,18 @@ static int snd_herc_spdif_select_put(snd_kcontrol_t *kcontrol, } -static int snd_cs46xx_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs46xx_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_cs46xx_spdif_default_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; down (&chip->spos_mutex); ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_default >> 24) & 0xff); @@ -2007,11 +2007,11 @@ static int snd_cs46xx_spdif_default_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs46xx_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t * chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx * chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; unsigned int val; int change; @@ -2034,8 +2034,8 @@ static int snd_cs46xx_spdif_default_put(snd_kcontrol_t * kcontrol, return change; } -static int snd_cs46xx_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -2044,11 +2044,11 @@ static int snd_cs46xx_spdif_mask_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs46xx_spdif_stream_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; down (&chip->spos_mutex); ucontrol->value.iec958.status[0] = _wrap_all_bits((ins->spdif_csuv_stream >> 24) & 0xff); @@ -2060,11 +2060,11 @@ static int snd_cs46xx_spdif_stream_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs46xx_spdif_stream_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs46xx_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t * chip = snd_kcontrol_chip(kcontrol); - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx * chip = snd_kcontrol_chip(kcontrol); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; unsigned int val; int change; @@ -2091,8 +2091,8 @@ static int snd_cs46xx_spdif_stream_put(snd_kcontrol_t * kcontrol, #ifdef CONFIG_SND_CS46XX_DEBUG_GPIO -static int snd_cs46xx_egpio_select_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cs46xx_egpio_select_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -2101,19 +2101,19 @@ static int snd_cs46xx_egpio_select_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_egpio_select_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_egpio_select_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = chip->current_gpio; return 0; } -static int snd_cs46xx_egpio_select_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_egpio_select_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int change = (chip->current_gpio != ucontrol->value.integer.value[0]); chip->current_gpio = ucontrol->value.integer.value[0]; @@ -2121,10 +2121,10 @@ static int snd_cs46xx_egpio_select_put(snd_kcontrol_t *kcontrol, } -static int snd_cs46xx_egpio_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_egpio_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; snd_printdd ("put: reg = %04x, gpio %02x\n",reg,chip->current_gpio); @@ -2134,10 +2134,10 @@ static int snd_cs46xx_egpio_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cs46xx_egpio_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_egpio_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value; int val = snd_cs46xx_peekBA0(chip, reg); int oldval = val; @@ -2155,7 +2155,7 @@ static int snd_cs46xx_egpio_put(snd_kcontrol_t *kcontrol, } #endif /* CONFIG_SND_CS46XX_DEBUG_GPIO */ -static snd_kcontrol_new_t snd_cs46xx_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_cs46xx_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "DAC Volume", @@ -2285,26 +2285,26 @@ static snd_kcontrol_new_t snd_cs46xx_controls[] __devinitdata = { #ifdef CONFIG_SND_CS46XX_NEW_DSP /* set primary cs4294 codec into Extended Audio Mode */ -static int snd_cs46xx_front_dup_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_front_dup_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); unsigned short val; val = snd_ac97_read(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX], AC97_CSR_ACMODE); ucontrol->value.integer.value[0] = (val & 0x200) ? 0 : 1; return 0; } -static int snd_cs46xx_front_dup_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cs46xx_front_dup_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs46xx_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs46xx *chip = snd_kcontrol_chip(kcontrol); return snd_ac97_update_bits(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX], AC97_CSR_ACMODE, 0x200, ucontrol->value.integer.value[0] ? 0 : 0x200); } -static snd_kcontrol_new_t snd_cs46xx_front_dup_ctl = { +static struct snd_kcontrol_new snd_cs46xx_front_dup_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Duplicate Front", .info = snd_mixer_boolean_info, @@ -2315,7 +2315,7 @@ static snd_kcontrol_new_t snd_cs46xx_front_dup_ctl = { #ifdef CONFIG_SND_CS46XX_NEW_DSP /* Only available on the Hercules Game Theater XP soundcard */ -static snd_kcontrol_new_t snd_hercules_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_hercules_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Optical/Coaxial SPDIF Input Switch", @@ -2326,7 +2326,7 @@ static snd_kcontrol_new_t snd_hercules_controls[] __devinitdata = { }; -static void snd_cs46xx_codec_reset (ac97_t * ac97) +static void snd_cs46xx_codec_reset (struct snd_ac97 * ac97) { unsigned long end_time; int err; @@ -2375,10 +2375,10 @@ static void snd_cs46xx_codec_reset (ac97_t * ac97) } #endif -static int __devinit cs46xx_detect_codec(cs46xx_t *chip, int codec) +static int __devinit cs46xx_detect_codec(struct snd_cs46xx *chip, int codec) { int idx, err; - ac97_template_t ac97; + struct snd_ac97_template ac97; memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; @@ -2408,13 +2408,13 @@ static int __devinit cs46xx_detect_codec(cs46xx_t *chip, int codec) return -ENXIO; } -int __devinit snd_cs46xx_mixer(cs46xx_t *chip, int spdif_device) +int __devinit snd_cs46xx_mixer(struct snd_cs46xx *chip, int spdif_device) { - snd_card_t *card = chip->card; - snd_ctl_elem_id_t id; + struct snd_card *card = chip->card; + struct snd_ctl_elem_id id; int err; unsigned int idx; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { #ifdef CONFIG_SND_CS46XX_NEW_DSP .reset = snd_cs46xx_codec_reset, #endif @@ -2442,7 +2442,7 @@ int __devinit snd_cs46xx_mixer(cs46xx_t *chip, int spdif_device) /* add cs4630 mixer controls */ for (idx = 0; idx < ARRAY_SIZE(snd_cs46xx_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_cs46xx_controls[idx], chip); if (kctl && kctl->id.iface == SNDRV_CTL_ELEM_IFACE_PCM) kctl->id.device = spdif_device; @@ -2484,16 +2484,16 @@ int __devinit snd_cs46xx_mixer(cs46xx_t *chip, int spdif_device) * RawMIDI interface */ -static void snd_cs46xx_midi_reset(cs46xx_t *chip) +static void snd_cs46xx_midi_reset(struct snd_cs46xx *chip) { snd_cs46xx_pokeBA0(chip, BA0_MIDCR, MIDCR_MRST); udelay(100); snd_cs46xx_pokeBA0(chip, BA0_MIDCR, chip->midcr); } -static int snd_cs46xx_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_cs46xx_midi_input_open(struct snd_rawmidi_substream *substream) { - cs46xx_t *chip = substream->rmidi->private_data; + struct snd_cs46xx *chip = substream->rmidi->private_data; chip->active_ctrl(chip, 1); spin_lock_irq(&chip->reg_lock); @@ -2509,9 +2509,9 @@ static int snd_cs46xx_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_cs46xx_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_cs46xx_midi_input_close(struct snd_rawmidi_substream *substream) { - cs46xx_t *chip = substream->rmidi->private_data; + struct snd_cs46xx *chip = substream->rmidi->private_data; spin_lock_irq(&chip->reg_lock); chip->midcr &= ~(MIDCR_RXE | MIDCR_RIE); @@ -2527,9 +2527,9 @@ static int snd_cs46xx_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_cs46xx_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_cs46xx_midi_output_open(struct snd_rawmidi_substream *substream) { - cs46xx_t *chip = substream->rmidi->private_data; + struct snd_cs46xx *chip = substream->rmidi->private_data; chip->active_ctrl(chip, 1); @@ -2546,9 +2546,9 @@ static int snd_cs46xx_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_cs46xx_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_cs46xx_midi_output_close(struct snd_rawmidi_substream *substream) { - cs46xx_t *chip = substream->rmidi->private_data; + struct snd_cs46xx *chip = substream->rmidi->private_data; spin_lock_irq(&chip->reg_lock); chip->midcr &= ~(MIDCR_TXE | MIDCR_TIE); @@ -2564,10 +2564,10 @@ static int snd_cs46xx_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_cs46xx_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_cs46xx_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - cs46xx_t *chip = substream->rmidi->private_data; + struct snd_cs46xx *chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->reg_lock, flags); if (up) { @@ -2584,10 +2584,10 @@ static void snd_cs46xx_midi_input_trigger(snd_rawmidi_substream_t * substream, i spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs46xx_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_cs46xx_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - cs46xx_t *chip = substream->rmidi->private_data; + struct snd_cs46xx *chip = substream->rmidi->private_data; unsigned char byte; spin_lock_irqsave(&chip->reg_lock, flags); @@ -2614,23 +2614,23 @@ static void snd_cs46xx_midi_output_trigger(snd_rawmidi_substream_t * substream, spin_unlock_irqrestore(&chip->reg_lock, flags); } -static snd_rawmidi_ops_t snd_cs46xx_midi_output = +static struct snd_rawmidi_ops snd_cs46xx_midi_output = { .open = snd_cs46xx_midi_output_open, .close = snd_cs46xx_midi_output_close, .trigger = snd_cs46xx_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_cs46xx_midi_input = +static struct snd_rawmidi_ops snd_cs46xx_midi_input = { .open = snd_cs46xx_midi_input_open, .close = snd_cs46xx_midi_input_close, .trigger = snd_cs46xx_midi_input_trigger, }; -int __devinit snd_cs46xx_midi(cs46xx_t *chip, int device, snd_rawmidi_t **rrawmidi) +int __devinit snd_cs46xx_midi(struct snd_cs46xx *chip, int device, struct snd_rawmidi **rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) @@ -2657,7 +2657,7 @@ int __devinit snd_cs46xx_midi(cs46xx_t *chip, int device, snd_rawmidi_t **rrawmi static void snd_cs46xx_gameport_trigger(struct gameport *gameport) { - cs46xx_t *chip = gameport_get_port_data(gameport); + struct snd_cs46xx *chip = gameport_get_port_data(gameport); snd_assert(chip, return); snd_cs46xx_pokeBA0(chip, BA0_JSPT, 0xFF); //outb(gameport->io, 0xFF); @@ -2665,7 +2665,7 @@ static void snd_cs46xx_gameport_trigger(struct gameport *gameport) static unsigned char snd_cs46xx_gameport_read(struct gameport *gameport) { - cs46xx_t *chip = gameport_get_port_data(gameport); + struct snd_cs46xx *chip = gameport_get_port_data(gameport); snd_assert(chip, return 0); return snd_cs46xx_peekBA0(chip, BA0_JSPT); //inb(gameport->io); @@ -2673,7 +2673,7 @@ static unsigned char snd_cs46xx_gameport_read(struct gameport *gameport) static int snd_cs46xx_gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons) { - cs46xx_t *chip = gameport_get_port_data(gameport); + struct snd_cs46xx *chip = gameport_get_port_data(gameport); unsigned js1, js2, jst; snd_assert(chip, return 0); @@ -2707,7 +2707,7 @@ static int snd_cs46xx_gameport_open(struct gameport *gameport, int mode) return 0; } -int __devinit snd_cs46xx_gameport(cs46xx_t *chip) +int __devinit snd_cs46xx_gameport(struct snd_cs46xx *chip) { struct gameport *gp; @@ -2735,7 +2735,7 @@ int __devinit snd_cs46xx_gameport(cs46xx_t *chip) return 0; } -static inline void snd_cs46xx_remove_gameport(cs46xx_t *chip) +static inline void snd_cs46xx_remove_gameport(struct snd_cs46xx *chip) { if (chip->gameport) { gameport_unregister_port(chip->gameport); @@ -2743,20 +2743,20 @@ static inline void snd_cs46xx_remove_gameport(cs46xx_t *chip) } } #else -int __devinit snd_cs46xx_gameport(cs46xx_t *chip) { return -ENOSYS; } -static inline void snd_cs46xx_remove_gameport(cs46xx_t *chip) { } +int __devinit snd_cs46xx_gameport(struct snd_cs46xx *chip) { return -ENOSYS; } +static inline void snd_cs46xx_remove_gameport(struct snd_cs46xx *chip) { } #endif /* CONFIG_GAMEPORT */ /* * proc interface */ -static long snd_cs46xx_io_read(snd_info_entry_t *entry, void *file_private_data, +static long snd_cs46xx_io_read(struct snd_info_entry *entry, void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { long size; - snd_cs46xx_region_t *region = (snd_cs46xx_region_t *)entry->private_data; + struct snd_cs46xx_region *region = entry->private_data; size = count; if (pos + (size_t)size > region->size) @@ -2772,13 +2772,13 @@ static struct snd_info_entry_ops snd_cs46xx_proc_io_ops = { .read = snd_cs46xx_io_read, }; -static int __devinit snd_cs46xx_proc_init(snd_card_t * card, cs46xx_t *chip) +static int __devinit snd_cs46xx_proc_init(struct snd_card *card, struct snd_cs46xx *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; int idx; for (idx = 0; idx < 5; idx++) { - snd_cs46xx_region_t *region = &chip->region.idx[idx]; + struct snd_cs46xx_region *region = &chip->region.idx[idx]; if (! snd_card_proc_new(card, region->name, &entry)) { entry->content = SNDRV_INFO_CONTENT_DATA; entry->private_data = chip; @@ -2793,7 +2793,7 @@ static int __devinit snd_cs46xx_proc_init(snd_card_t * card, cs46xx_t *chip) return 0; } -static int snd_cs46xx_proc_done(cs46xx_t *chip) +static int snd_cs46xx_proc_done(struct snd_cs46xx *chip) { #ifdef CONFIG_SND_CS46XX_NEW_DSP cs46xx_dsp_proc_done(chip); @@ -2804,7 +2804,7 @@ static int snd_cs46xx_proc_done(cs46xx_t *chip) /* * stop the h/w */ -static void snd_cs46xx_hw_stop(cs46xx_t *chip) +static void snd_cs46xx_hw_stop(struct snd_cs46xx *chip) { unsigned int tmp; @@ -2851,7 +2851,7 @@ static void snd_cs46xx_hw_stop(cs46xx_t *chip) } -static int snd_cs46xx_free(cs46xx_t *chip) +static int snd_cs46xx_free(struct snd_cs46xx *chip) { int idx; @@ -2871,13 +2871,13 @@ static int snd_cs46xx_free(cs46xx_t *chip) snd_cs46xx_hw_stop(chip); for (idx = 0; idx < 5; idx++) { - snd_cs46xx_region_t *region = &chip->region.idx[idx]; + struct snd_cs46xx_region *region = &chip->region.idx[idx]; if (region->remap_addr) iounmap(region->remap_addr); release_and_free_resource(region->resource); } if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); if (chip->active_ctrl) chip->active_ctrl(chip, -chip->amplifier); @@ -2894,16 +2894,16 @@ static int snd_cs46xx_free(cs46xx_t *chip) return 0; } -static int snd_cs46xx_dev_free(snd_device_t *device) +static int snd_cs46xx_dev_free(struct snd_device *device) { - cs46xx_t *chip = device->device_data; + struct snd_cs46xx *chip = device->device_data; return snd_cs46xx_free(chip); } /* * initialize chip */ -static int snd_cs46xx_chip_init(cs46xx_t *chip) +static int snd_cs46xx_chip_init(struct snd_cs46xx *chip) { int timeout; @@ -3132,7 +3132,7 @@ static int snd_cs46xx_chip_init(cs46xx_t *chip) /* * start and load DSP */ -int __devinit snd_cs46xx_start_dsp(cs46xx_t *chip) +int __devinit snd_cs46xx_start_dsp(struct snd_cs46xx *chip) { unsigned int tmp; /* @@ -3234,12 +3234,12 @@ int __devinit snd_cs46xx_start_dsp(cs46xx_t *chip) * AMP control - null AMP */ -static void amp_none(cs46xx_t *chip, int change) +static void amp_none(struct snd_cs46xx *chip, int change) { } #ifdef CONFIG_SND_CS46XX_NEW_DSP -static int voyetra_setup_eapd_slot(cs46xx_t *chip) +static int voyetra_setup_eapd_slot(struct snd_cs46xx *chip) { u32 idx, valid_slots,tmp,powerdown = 0; @@ -3359,7 +3359,7 @@ static int voyetra_setup_eapd_slot(cs46xx_t *chip) * Crystal EAPD mode */ -static void amp_voyetra(cs46xx_t *chip, int change) +static void amp_voyetra(struct snd_cs46xx *chip, int change) { /* Manage the EAPD bit on the Crystal 4297 and the Analog AD1885 */ @@ -3395,7 +3395,7 @@ static void amp_voyetra(cs46xx_t *chip, int change) #endif } -static void hercules_init(cs46xx_t *chip) +static void hercules_init(struct snd_cs46xx *chip) { /* default: AMP off, and SPDIF input optical */ snd_cs46xx_pokeBA0(chip, BA0_EGPIODR, EGPIODR_GPOE0); @@ -3406,7 +3406,7 @@ static void hercules_init(cs46xx_t *chip) /* * Game Theatre XP card - EGPIO[2] is used to enable the external amp. */ -static void amp_hercules(cs46xx_t *chip, int change) +static void amp_hercules(struct snd_cs46xx *chip, int change) { int old = chip->amplifier; int val1 = snd_cs46xx_peekBA0(chip, BA0_EGPIODR); @@ -3427,7 +3427,7 @@ static void amp_hercules(cs46xx_t *chip, int change) } } -static void voyetra_mixer_init (cs46xx_t *chip) +static void voyetra_mixer_init (struct snd_cs46xx *chip) { snd_printdd ("initializing Voyetra mixer\n"); @@ -3436,12 +3436,12 @@ static void voyetra_mixer_init (cs46xx_t *chip) snd_cs46xx_pokeBA0(chip, BA0_EGPIOPTR, EGPIODR_GPOE0); } -static void hercules_mixer_init (cs46xx_t *chip) +static void hercules_mixer_init (struct snd_cs46xx *chip) { #ifdef CONFIG_SND_CS46XX_NEW_DSP unsigned int idx; int err; - snd_card_t *card = chip->card; + struct snd_card *card = chip->card; #endif /* set EGPIO to default */ @@ -3451,7 +3451,7 @@ static void hercules_mixer_init (cs46xx_t *chip) #ifdef CONFIG_SND_CS46XX_NEW_DSP for (idx = 0 ; idx < ARRAY_SIZE(snd_hercules_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_hercules_controls[idx], chip); if ((err = snd_ctl_add(card, kctl)) < 0) { @@ -3468,7 +3468,7 @@ static void hercules_mixer_init (cs46xx_t *chip) * Untested */ -static void amp_voyetra_4294(cs46xx_t *chip, int change) +static void amp_voyetra_4294(struct snd_cs46xx *chip, int change) { chip->amplifier += change; @@ -3498,7 +3498,7 @@ static void amp_voyetra_4294(cs46xx_t *chip, int change) * enough to make them useful. */ -static void clkrun_hack(cs46xx_t *chip, int change) +static void clkrun_hack(struct snd_cs46xx *chip, int change) { u16 control, nval; @@ -3523,7 +3523,7 @@ static void clkrun_hack(cs46xx_t *chip, int change) /* * detect intel piix4 */ -static void clkrun_init(cs46xx_t *chip) +static void clkrun_init(struct snd_cs46xx *chip) { struct pci_dev *pdev; u8 pp; @@ -3551,10 +3551,10 @@ struct cs_card_type u16 vendor; u16 id; char *name; - void (*init)(cs46xx_t *); - void (*amp)(cs46xx_t *, int); - void (*active)(cs46xx_t *, int); - void (*mixer_init)(cs46xx_t *); + void (*init)(struct snd_cs46xx *); + void (*amp)(struct snd_cs46xx *, int); + void (*active)(struct snd_cs46xx *, int); + void (*mixer_init)(struct snd_cs46xx *); }; static struct cs_card_type __devinitdata cards[] = { @@ -3654,9 +3654,9 @@ static struct cs_card_type __devinitdata cards[] = { * APM support */ #ifdef CONFIG_PM -static int snd_cs46xx_suspend(snd_card_t *card, pm_message_t state) +static int snd_cs46xx_suspend(struct snd_card *card, pm_message_t state) { - cs46xx_t *chip = card->pm_private_data; + struct snd_cs46xx *chip = card->pm_private_data; int amp_saved; snd_pcm_suspend_all(chip->pcm); @@ -3678,9 +3678,9 @@ static int snd_cs46xx_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_cs46xx_resume(snd_card_t *card) +static int snd_cs46xx_resume(struct snd_card *card) { - cs46xx_t *chip = card->pm_private_data; + struct snd_cs46xx *chip = card->pm_private_data; int amp_saved; pci_enable_device(chip->pci); @@ -3719,17 +3719,17 @@ static int snd_cs46xx_resume(snd_card_t *card) /* */ -int __devinit snd_cs46xx_create(snd_card_t * card, +int __devinit snd_cs46xx_create(struct snd_card *card, struct pci_dev * pci, int external_amp, int thinkpad, - cs46xx_t ** rchip) + struct snd_cs46xx ** rchip) { - cs46xx_t *chip; + struct snd_cs46xx *chip; int err, idx; - snd_cs46xx_region_t *region; + struct snd_cs46xx_region *region; struct cs_card_type *cp; u16 ss_card, ss_vendor; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_cs46xx_dev_free, }; @@ -3755,7 +3755,8 @@ int __devinit snd_cs46xx_create(snd_card_t * card, chip->ba1_addr = pci_resource_start(pci, 1); if (chip->ba0_addr == 0 || chip->ba0_addr == (unsigned long)~0 || chip->ba1_addr == 0 || chip->ba1_addr == (unsigned long)~0) { - snd_printk(KERN_ERR "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n", chip->ba0_addr, chip->ba1_addr); + snd_printk(KERN_ERR "wrong address(es) - ba0 = 0x%lx, ba1 = 0x%lx\n", + chip->ba0_addr, chip->ba1_addr); snd_cs46xx_free(chip); return -ENOMEM; } @@ -3825,8 +3826,10 @@ int __devinit snd_cs46xx_create(snd_card_t * card, for (idx = 0; idx < 5; idx++) { region = &chip->region.idx[idx]; - if ((region->resource = request_mem_region(region->base, region->size, region->name)) == NULL) { - snd_printk(KERN_ERR "unable to request memory region 0x%lx-0x%lx\n", region->base, region->base + region->size - 1); + if ((region->resource = request_mem_region(region->base, region->size, + region->name)) == NULL) { + snd_printk(KERN_ERR "unable to request memory region 0x%lx-0x%lx\n", + region->base, region->base + region->size - 1); snd_cs46xx_free(chip); return -EBUSY; } @@ -3838,7 +3841,8 @@ int __devinit snd_cs46xx_create(snd_card_t * card, } } - if (request_irq(pci->irq, snd_cs46xx_interrupt, SA_INTERRUPT|SA_SHIRQ, "CS46XX", (void *) chip)) { + if (request_irq(pci->irq, snd_cs46xx_interrupt, SA_INTERRUPT|SA_SHIRQ, + "CS46XX", chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_cs46xx_free(chip); return -EBUSY; diff --git a/sound/pci/cs46xx/cs46xx_lib.h b/sound/pci/cs46xx/cs46xx_lib.h index d7bec09..8b4a4ae 100644 --- a/sound/pci/cs46xx/cs46xx_lib.h +++ b/sound/pci/cs46xx/cs46xx_lib.h @@ -57,7 +57,7 @@ * common I/O routines */ -static inline void snd_cs46xx_poke(cs46xx_t *chip, unsigned long reg, unsigned int val) +static inline void snd_cs46xx_poke(struct snd_cs46xx *chip, unsigned long reg, unsigned int val) { unsigned int bank = reg >> 16; unsigned int offset = reg & 0xffff; @@ -66,117 +66,128 @@ static inline void snd_cs46xx_poke(cs46xx_t *chip, unsigned long reg, unsigned i writel(val, chip->region.idx[bank+1].remap_addr + offset); } -static inline unsigned int snd_cs46xx_peek(cs46xx_t *chip, unsigned long reg) +static inline unsigned int snd_cs46xx_peek(struct snd_cs46xx *chip, unsigned long reg) { unsigned int bank = reg >> 16; unsigned int offset = reg & 0xffff; return readl(chip->region.idx[bank+1].remap_addr + offset); } -static inline void snd_cs46xx_pokeBA0(cs46xx_t *chip, unsigned long offset, unsigned int val) +static inline void snd_cs46xx_pokeBA0(struct snd_cs46xx *chip, unsigned long offset, unsigned int val) { writel(val, chip->region.name.ba0.remap_addr + offset); } -static inline unsigned int snd_cs46xx_peekBA0(cs46xx_t *chip, unsigned long offset) +static inline unsigned int snd_cs46xx_peekBA0(struct snd_cs46xx *chip, unsigned long offset) { return readl(chip->region.name.ba0.remap_addr + offset); } -dsp_spos_instance_t * cs46xx_dsp_spos_create (cs46xx_t * chip); -void cs46xx_dsp_spos_destroy (cs46xx_t * chip); -int cs46xx_dsp_load_module (cs46xx_t * chip,dsp_module_desc_t * module); -symbol_entry_t * cs46xx_dsp_lookup_symbol (cs46xx_t * chip,char * symbol_name,int symbol_type); -int cs46xx_dsp_proc_init (snd_card_t * card, cs46xx_t *chip); -int cs46xx_dsp_proc_done (cs46xx_t *chip); -int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip); -int snd_cs46xx_download (cs46xx_t *chip,u32 *src,unsigned long offset, - unsigned long len); -int snd_cs46xx_clear_BA1(cs46xx_t *chip,unsigned long offset,unsigned long len); -int cs46xx_dsp_enable_spdif_out (cs46xx_t *chip); -int cs46xx_dsp_enable_spdif_hw (cs46xx_t *chip); -int cs46xx_dsp_disable_spdif_out (cs46xx_t *chip); -int cs46xx_dsp_enable_spdif_in (cs46xx_t *chip); -int cs46xx_dsp_disable_spdif_in (cs46xx_t *chip); -int cs46xx_dsp_enable_pcm_capture (cs46xx_t *chip); -int cs46xx_dsp_disable_pcm_capture (cs46xx_t *chip); -int cs46xx_dsp_enable_adc_capture (cs46xx_t *chip); -int cs46xx_dsp_disable_adc_capture (cs46xx_t *chip); -int cs46xx_poke_via_dsp (cs46xx_t *chip,u32 address,u32 data); -dsp_scb_descriptor_t * cs46xx_dsp_create_scb (cs46xx_t *chip,char * name, u32 * scb_data,u32 dest); -void cs46xx_dsp_proc_free_scb_desc (dsp_scb_descriptor_t * scb); -void cs46xx_dsp_proc_register_scb_desc (cs46xx_t *chip,dsp_scb_descriptor_t * scb); -dsp_scb_descriptor_t * cs46xx_dsp_create_timing_master_scb (cs46xx_t *chip); -dsp_scb_descriptor_t * cs46xx_dsp_create_codec_out_scb(cs46xx_t * chip,char * codec_name, - u16 channel_disp,u16 fifo_addr, - u16 child_scb_addr, - u32 dest, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type); -dsp_scb_descriptor_t * cs46xx_dsp_create_codec_in_scb(cs46xx_t * chip,char * codec_name, - u16 channel_disp,u16 fifo_addr, - u16 sample_buffer_addr, - u32 dest, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type); -void cs46xx_dsp_remove_scb (cs46xx_t *chip,dsp_scb_descriptor_t * scb); -dsp_scb_descriptor_t * cs46xx_dsp_create_codec_in_scb(cs46xx_t * chip,char * codec_name, - u16 channel_disp,u16 fifo_addr, - u16 sample_buffer_addr, - u32 dest,dsp_scb_descriptor_t * parent_scb, - int scb_child_type); -dsp_scb_descriptor_t * cs46xx_dsp_create_src_task_scb(cs46xx_t * chip,char * scb_name, - int sample_rate, - u16 src_buffer_addr, - u16 src_delay_buffer_addr,u32 dest, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type, - int pass_through); -dsp_scb_descriptor_t * cs46xx_dsp_create_mix_only_scb(cs46xx_t * chip,char * scb_name, - u16 mix_buffer_addr,u32 dest, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type); - -dsp_scb_descriptor_t * cs46xx_dsp_create_vari_decimate_scb(cs46xx_t * chip,char * scb_name, - u16 vari_buffer_addr0, - u16 vari_buffer_addr1, - u32 dest, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type); -dsp_scb_descriptor_t * cs46xx_dsp_create_asynch_fg_rx_scb(cs46xx_t * chip,char * scb_name,u32 dest, - u16 hfg_scb_address, - u16 asynch_buffer_address, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type); -dsp_scb_descriptor_t * cs46xx_dsp_create_spio_write_scb(cs46xx_t * chip,char * scb_name,u32 dest, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type); -dsp_scb_descriptor_t * cs46xx_dsp_create_mix_to_ostream_scb(cs46xx_t * chip,char * scb_name, - u16 mix_buffer_addr,u16 writeback_spb,u32 dest, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type); -dsp_scb_descriptor_t * cs46xx_dsp_create_magic_snoop_scb(cs46xx_t * chip,char * scb_name,u32 dest, - u16 snoop_buffer_address, - dsp_scb_descriptor_t * snoop_scb, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type); -pcm_channel_descriptor_t * cs46xx_dsp_create_pcm_channel (cs46xx_t * chip,u32 sample_rate, void * private_data, u32 hw_dma_addr, - int pcm_channel_id); -void cs46xx_dsp_destroy_pcm_channel (cs46xx_t * chip, - pcm_channel_descriptor_t * pcm_channel); -int cs46xx_dsp_pcm_unlink (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel); -int cs46xx_dsp_pcm_link (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel); -dsp_scb_descriptor_t * cs46xx_add_record_source (cs46xx_t *chip,dsp_scb_descriptor_t * source, - u16 addr,char * scb_name); -int cs46xx_src_unlink(cs46xx_t *chip,dsp_scb_descriptor_t * src); -int cs46xx_src_link(cs46xx_t *chip,dsp_scb_descriptor_t * src); -int cs46xx_iec958_pre_open (cs46xx_t *chip); -int cs46xx_iec958_post_close (cs46xx_t *chip); -int cs46xx_dsp_pcm_channel_set_period (cs46xx_t * chip, - pcm_channel_descriptor_t * pcm_channel, - int period_size); -int cs46xx_dsp_pcm_ostream_set_period (cs46xx_t * chip, - int period_size); -int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 left,u16 right); -int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 left,u16 right); +struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip); +void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip); +int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module); +struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, + int symbol_type); +int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip); +int cs46xx_dsp_proc_done (struct snd_cs46xx *chip); +int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip); +int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset, + unsigned long len); +int snd_cs46xx_clear_BA1(struct snd_cs46xx *chip, unsigned long offset, unsigned long len); +int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip); +int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx *chip); +int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip); +int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip); +int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip); +int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip); +int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip); +int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip); +int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip); +int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data); +struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, + u32 * scb_data, u32 dest); +void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb); +void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip, + struct dsp_scb_descriptor * scb); +struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip); +struct dsp_scb_descriptor * +cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip, + char * codec_name, u16 channel_disp, u16 fifo_addr, + u16 child_scb_addr, u32 dest, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); +struct dsp_scb_descriptor * +cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name, + u16 channel_disp, u16 fifo_addr, + u16 sample_buffer_addr, u32 dest, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); +void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, + struct dsp_scb_descriptor * scb); +struct dsp_scb_descriptor * +cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name, + u16 channel_disp, u16 fifo_addr, + u16 sample_buffer_addr, u32 dest, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); +struct dsp_scb_descriptor * +cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name, + int sample_rate, u16 src_buffer_addr, + u16 src_delay_buffer_addr, u32 dest, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type, int pass_through); +struct dsp_scb_descriptor * +cs46xx_dsp_create_mix_only_scb(struct snd_cs46xx * chip, char * scb_name, + u16 mix_buffer_addr, u32 dest, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); + +struct dsp_scb_descriptor * +cs46xx_dsp_create_vari_decimate_scb(struct snd_cs46xx * chip, char * scb_name, + u16 vari_buffer_addr0, u16 vari_buffer_addr1, u32 dest, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); +struct dsp_scb_descriptor * +cs46xx_dsp_create_asynch_fg_rx_scb(struct snd_cs46xx * chip, char * scb_name, + u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); +struct dsp_scb_descriptor * +cs46xx_dsp_create_spio_write_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); +struct dsp_scb_descriptor * +cs46xx_dsp_create_mix_to_ostream_scb(struct snd_cs46xx * chip, char * scb_name, + u16 mix_buffer_addr, u16 writeback_spb, u32 dest, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); +struct dsp_scb_descriptor * +cs46xx_dsp_create_magic_snoop_scb(struct snd_cs46xx * chip, char * scb_name, + u32 dest, u16 snoop_buffer_address, + struct dsp_scb_descriptor * snoop_scb, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type); +struct dsp_pcm_channel_descriptor * +cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, u32 sample_rate, + void * private_data, u32 hw_dma_addr, + int pcm_channel_id); +void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip, + struct dsp_pcm_channel_descriptor * pcm_channel); +int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, + struct dsp_pcm_channel_descriptor * pcm_channel); +int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, + struct dsp_pcm_channel_descriptor * pcm_channel); +struct dsp_scb_descriptor * +cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * source, + u16 addr, char * scb_name); +int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src); +int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src); +int cs46xx_iec958_pre_open (struct snd_cs46xx *chip); +int cs46xx_iec958_post_close (struct snd_cs46xx *chip); +int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip, + struct dsp_pcm_channel_descriptor * pcm_channel, + int period_size); +int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip, int period_size); +int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right); +int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right); #endif /* __CS46XX_LIB_H__ */ diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index b66304f..ac98917 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c @@ -37,9 +37,10 @@ #include "cs46xx_lib.h" #include "dsp_spos.h" -static int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entry); +static int cs46xx_dsp_async_init (struct snd_cs46xx *chip, + struct dsp_scb_descriptor * fg_entry); -static wide_opcode_t wide_opcodes[] = { +static enum wide_opcode wide_opcodes[] = { WIDE_FOR_BEGIN_LOOP, WIDE_FOR_BEGIN_LOOP2, WIDE_COND_GOTO_ADDR, @@ -54,12 +55,13 @@ static wide_opcode_t wide_opcodes[] = { WIDE_TBEQ_NCOND_CALL1_ADDR }; -static int shadow_and_reallocate_code (cs46xx_t * chip,u32 * data,u32 size, u32 overlay_begin_address) +static int shadow_and_reallocate_code (struct snd_cs46xx * chip, u32 * data, u32 size, + u32 overlay_begin_address) { unsigned int i = 0, j, nreallocated = 0; u32 hival,loval,address; u32 mop_operands,mop_type,wide_op; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; snd_assert( ((size % 2) == 0), return -EINVAL); @@ -114,7 +116,7 @@ static int shadow_and_reallocate_code (cs46xx_t * chip,u32 * data,u32 size, u32 return nreallocated; } -static segment_desc_t * get_segment_desc (dsp_module_desc_t * module, int seg_type) +static struct dsp_segment_desc * get_segment_desc (struct dsp_module_desc * module, int seg_type) { int i; for (i = 0;i < module->nsegments; ++i) { @@ -126,7 +128,7 @@ static segment_desc_t * get_segment_desc (dsp_module_desc_t * module, int seg_ty return NULL; }; -static int find_free_symbol_index (dsp_spos_instance_t * ins) +static int find_free_symbol_index (struct dsp_spos_instance * ins) { int index = ins->symbol_table.nsymbols,i; @@ -140,10 +142,10 @@ static int find_free_symbol_index (dsp_spos_instance_t * ins) return index; } -static int add_symbols (cs46xx_t * chip, dsp_module_desc_t * module) +static int add_symbols (struct snd_cs46xx * chip, struct dsp_module_desc * module) { int i; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; if (module->symbol_table.nsymbols > 0) { if (!strcmp(module->symbol_table.symbols[0].symbol_name, "OVERLAYBEGINADDRESS") && @@ -181,10 +183,11 @@ static int add_symbols (cs46xx_t * chip, dsp_module_desc_t * module) return 0; } -static symbol_entry_t * add_symbol (cs46xx_t * chip, char * symbol_name, u32 address, int type) +static struct dsp_symbol_entry * +add_symbol (struct snd_cs46xx * chip, char * symbol_name, u32 address, int type) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - symbol_entry_t * symbol = NULL; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_symbol_entry * symbol = NULL; int index; if (ins->symbol_table.nsymbols == (DSP_MAX_SYMBOLS - 1)) { @@ -217,17 +220,17 @@ static symbol_entry_t * add_symbol (cs46xx_t * chip, char * symbol_name, u32 add return symbol; } -dsp_spos_instance_t * cs46xx_dsp_spos_create (cs46xx_t * chip) +struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) { - dsp_spos_instance_t * ins = kmalloc(sizeof(dsp_spos_instance_t), GFP_KERNEL); + struct dsp_spos_instance * ins = kzalloc(sizeof(struct dsp_spos_instance), GFP_KERNEL); if (ins == NULL) return NULL; - memset(ins, 0, sizeof(*ins)); /* better to use vmalloc for this big table */ ins->symbol_table.nsymbols = 0; - ins->symbol_table.symbols = vmalloc(sizeof(symbol_entry_t) * DSP_MAX_SYMBOLS); + ins->symbol_table.symbols = vmalloc(sizeof(struct dsp_symbol_entry) * + DSP_MAX_SYMBOLS); ins->symbol_table.highest_frag_index = 0; if (ins->symbol_table.symbols == NULL) { @@ -248,7 +251,7 @@ dsp_spos_instance_t * cs46xx_dsp_spos_create (cs46xx_t * chip) ins->ntask = 0; ins->nmodules = 0; - ins->modules = kmalloc(sizeof(dsp_module_desc_t) * DSP_MAX_MODULES, GFP_KERNEL); + ins->modules = kmalloc(sizeof(struct dsp_module_desc) * DSP_MAX_MODULES, GFP_KERNEL); if (ins->modules == NULL) { cs46xx_dsp_spos_destroy(chip); @@ -277,10 +280,10 @@ dsp_spos_instance_t * cs46xx_dsp_spos_create (cs46xx_t * chip) return ins; } -void cs46xx_dsp_spos_destroy (cs46xx_t * chip) +void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip) { int i; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; snd_assert(ins != NULL, return); @@ -298,12 +301,12 @@ void cs46xx_dsp_spos_destroy (cs46xx_t * chip) up(&chip->spos_mutex); } -int cs46xx_dsp_load_module (cs46xx_t * chip, dsp_module_desc_t * module) +int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - segment_desc_t * code = get_segment_desc (module,SEGTYPE_SP_PROGRAM); - segment_desc_t * parameter = get_segment_desc (module,SEGTYPE_SP_PARAMETER); - segment_desc_t * sample = get_segment_desc (module,SEGTYPE_SP_SAMPLE); + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_segment_desc * code = get_segment_desc (module,SEGTYPE_SP_PROGRAM); + struct dsp_segment_desc * parameter = get_segment_desc (module,SEGTYPE_SP_PARAMETER); + struct dsp_segment_desc * sample = get_segment_desc (module,SEGTYPE_SP_SAMPLE); u32 doffset, dsize; if (ins->nmodules == DSP_MAX_MODULES - 1) { @@ -410,10 +413,11 @@ int cs46xx_dsp_load_module (cs46xx_t * chip, dsp_module_desc_t * module) return 0; } -symbol_entry_t * cs46xx_dsp_lookup_symbol (cs46xx_t * chip, char * symbol_name, int symbol_type) +struct dsp_symbol_entry * +cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, int symbol_type) { int i; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; for ( i = 0; i < ins->symbol_table.nsymbols; ++i ) { @@ -435,10 +439,11 @@ symbol_entry_t * cs46xx_dsp_lookup_symbol (cs46xx_t * chip, char * symbol_name, } -static symbol_entry_t * cs46xx_dsp_lookup_symbol_addr (cs46xx_t * chip, u32 address, int symbol_type) +static struct dsp_symbol_entry * +cs46xx_dsp_lookup_symbol_addr (struct snd_cs46xx * chip, u32 address, int symbol_type) { int i; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; for ( i = 0; i < ins->symbol_table.nsymbols; ++i ) { @@ -456,10 +461,11 @@ static symbol_entry_t * cs46xx_dsp_lookup_symbol_addr (cs46xx_t * chip, u32 addr } -static void cs46xx_dsp_proc_symbol_table_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void cs46xx_dsp_proc_symbol_table_read (struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - cs46xx_t *chip = entry->private_data; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = entry->private_data; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int i; snd_iprintf(buffer, "SYMBOLS:\n"); @@ -483,10 +489,11 @@ static void cs46xx_dsp_proc_symbol_table_read (snd_info_entry_t *entry, snd_info } -static void cs46xx_dsp_proc_modules_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void cs46xx_dsp_proc_modules_read (struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - cs46xx_t *chip = entry->private_data; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = entry->private_data; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int i,j; down(&chip->spos_mutex); @@ -497,7 +504,7 @@ static void cs46xx_dsp_proc_modules_read (snd_info_entry_t *entry, snd_info_buff snd_iprintf(buffer, " %d fixups\n", ins->modules[i].nfixups); for (j = 0; j < ins->modules[i].nsegments; ++ j) { - segment_desc_t * desc = (ins->modules[i].segments + j); + struct dsp_segment_desc * desc = (ins->modules[i].segments + j); snd_iprintf(buffer, " segment %02x offset %08x size %08x\n", desc->segment_type,desc->offset, desc->size); } @@ -505,11 +512,12 @@ static void cs46xx_dsp_proc_modules_read (snd_info_entry_t *entry, snd_info_buff up(&chip->spos_mutex); } -static void cs46xx_dsp_proc_task_tree_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void cs46xx_dsp_proc_task_tree_read (struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - cs46xx_t *chip = entry->private_data; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - int i,j,col; + struct snd_cs46xx *chip = entry->private_data; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + int i, j, col; void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; down(&chip->spos_mutex); @@ -532,10 +540,11 @@ static void cs46xx_dsp_proc_task_tree_read (snd_info_entry_t *entry, snd_info_bu up(&chip->spos_mutex); } -static void cs46xx_dsp_proc_scb_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void cs46xx_dsp_proc_scb_read (struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - cs46xx_t *chip = entry->private_data; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_cs46xx *chip = entry->private_data; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int i; down(&chip->spos_mutex); @@ -564,13 +573,14 @@ static void cs46xx_dsp_proc_scb_read (snd_info_entry_t *entry, snd_info_buffer_t up(&chip->spos_mutex); } -static void cs46xx_dsp_proc_parameter_dump_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void cs46xx_dsp_proc_parameter_dump_read (struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - cs46xx_t *chip = entry->private_data; - /*dsp_spos_instance_t * ins = chip->dsp_spos_instance; */ - unsigned int i,col = 0; + struct snd_cs46xx *chip = entry->private_data; + /*struct dsp_spos_instance * ins = chip->dsp_spos_instance; */ + unsigned int i, col = 0; void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; - symbol_entry_t * symbol; + struct dsp_symbol_entry * symbol; for (i = 0;i < DSP_PARAMETER_BYTE_SIZE; i += sizeof(u32),col ++) { if (col == 4) { @@ -591,9 +601,10 @@ static void cs46xx_dsp_proc_parameter_dump_read (snd_info_entry_t *entry, snd_in } } -static void cs46xx_dsp_proc_sample_dump_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void cs46xx_dsp_proc_sample_dump_read (struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - cs46xx_t *chip = entry->private_data; + struct snd_cs46xx *chip = entry->private_data; int i,col = 0; void __iomem *dst = chip->region.idx[2].remap_addr; @@ -738,10 +749,10 @@ static void cs46xx_dsp_proc_sample_dump_read (snd_info_entry_t *entry, snd_info_ snd_iprintf(buffer,"\n"); } -int cs46xx_dsp_proc_init (snd_card_t * card, cs46xx_t *chip) +int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip) { - snd_info_entry_t *entry; - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct snd_info_entry *entry; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int i; ins->snd_card = card; @@ -852,9 +863,9 @@ int cs46xx_dsp_proc_init (snd_card_t * card, cs46xx_t *chip) return 0; } -int cs46xx_dsp_proc_done (cs46xx_t *chip) +int cs46xx_dsp_proc_done (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int i; if (ins->proc_sym_info_entry) { @@ -903,7 +914,8 @@ int cs46xx_dsp_proc_done (cs46xx_t *chip) } static int debug_tree; -static void _dsp_create_task_tree (cs46xx_t *chip,u32 * task_data, u32 dest, int size) +static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data, + u32 dest, int size) { void __iomem *spdst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET + dest * sizeof(u32); @@ -917,7 +929,7 @@ static void _dsp_create_task_tree (cs46xx_t *chip,u32 * task_data, u32 dest, in } static int debug_scb; -static void _dsp_create_scb (cs46xx_t *chip,u32 * scb_data, u32 dest) +static void _dsp_create_scb (struct snd_cs46xx *chip, u32 * scb_data, u32 dest) { void __iomem *spdst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET + dest * sizeof(u32); @@ -930,7 +942,7 @@ static void _dsp_create_scb (cs46xx_t *chip,u32 * scb_data, u32 dest) } } -static int find_free_scb_index (dsp_spos_instance_t * ins) +static int find_free_scb_index (struct dsp_spos_instance * ins) { int index = ins->nscb, i; @@ -944,10 +956,10 @@ static int find_free_scb_index (dsp_spos_instance_t * ins) return index; } -static dsp_scb_descriptor_t * _map_scb (cs46xx_t *chip,char * name,u32 dest) +static struct dsp_scb_descriptor * _map_scb (struct snd_cs46xx *chip, char * name, u32 dest) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * desc = NULL; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * desc = NULL; int index; if (ins->nscb == DSP_MAX_SCB_DESC - 1) { @@ -977,10 +989,11 @@ static dsp_scb_descriptor_t * _map_scb (cs46xx_t *chip,char * name,u32 dest) return desc; } -static dsp_task_descriptor_t * _map_task_tree (cs46xx_t *chip,char * name,u32 dest,u32 size) +static struct dsp_task_descriptor * +_map_task_tree (struct snd_cs46xx *chip, char * name, u32 dest, u32 size) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_task_descriptor_t * desc = NULL; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_task_descriptor * desc = NULL; if (ins->ntask == DSP_MAX_TASK_DESC - 1) { snd_printk(KERN_ERR "dsp_spos: got no place for other TASK\n"); @@ -1000,9 +1013,10 @@ static dsp_task_descriptor_t * _map_task_tree (cs46xx_t *chip,char * name,u32 de return desc; } -dsp_scb_descriptor_t * cs46xx_dsp_create_scb (cs46xx_t *chip,char * name, u32 * scb_data,u32 dest) +struct dsp_scb_descriptor * +cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest) { - dsp_scb_descriptor_t * desc; + struct dsp_scb_descriptor * desc; desc = _map_scb (chip,name,dest); if (desc) { @@ -1015,9 +1029,11 @@ dsp_scb_descriptor_t * cs46xx_dsp_create_scb (cs46xx_t *chip,char * name, u32 * } -static dsp_task_descriptor_t * cs46xx_dsp_create_task_tree (cs46xx_t *chip,char * name, u32 * task_data,u32 dest,int size) +static struct dsp_task_descriptor * +cs46xx_dsp_create_task_tree (struct snd_cs46xx *chip, char * name, u32 * task_data, + u32 dest, int size) { - dsp_task_descriptor_t * desc; + struct dsp_task_descriptor * desc; desc = _map_task_tree (chip,name,dest,size); if (desc) { @@ -1029,31 +1045,31 @@ static dsp_task_descriptor_t * cs46xx_dsp_create_task_tree (cs46xx_t *chip,char return desc; } -int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip) +int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - symbol_entry_t * fg_task_tree_header_code; - symbol_entry_t * task_tree_header_code; - symbol_entry_t * task_tree_thread; - symbol_entry_t * null_algorithm; - symbol_entry_t * magic_snoop_task; - - dsp_scb_descriptor_t * timing_master_scb; - dsp_scb_descriptor_t * codec_out_scb; - dsp_scb_descriptor_t * codec_in_scb; - dsp_scb_descriptor_t * src_task_scb; - dsp_scb_descriptor_t * master_mix_scb; - dsp_scb_descriptor_t * rear_mix_scb; - dsp_scb_descriptor_t * record_mix_scb; - dsp_scb_descriptor_t * write_back_scb; - dsp_scb_descriptor_t * vari_decimate_scb; - dsp_scb_descriptor_t * rear_codec_out_scb; - dsp_scb_descriptor_t * clfe_codec_out_scb; - dsp_scb_descriptor_t * magic_snoop_scb; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_symbol_entry * fg_task_tree_header_code; + struct dsp_symbol_entry * task_tree_header_code; + struct dsp_symbol_entry * task_tree_thread; + struct dsp_symbol_entry * null_algorithm; + struct dsp_symbol_entry * magic_snoop_task; + + struct dsp_scb_descriptor * timing_master_scb; + struct dsp_scb_descriptor * codec_out_scb; + struct dsp_scb_descriptor * codec_in_scb; + struct dsp_scb_descriptor * src_task_scb; + struct dsp_scb_descriptor * master_mix_scb; + struct dsp_scb_descriptor * rear_mix_scb; + struct dsp_scb_descriptor * record_mix_scb; + struct dsp_scb_descriptor * write_back_scb; + struct dsp_scb_descriptor * vari_decimate_scb; + struct dsp_scb_descriptor * rear_codec_out_scb; + struct dsp_scb_descriptor * clfe_codec_out_scb; + struct dsp_scb_descriptor * magic_snoop_scb; - int fifo_addr,fifo_span,valid_slots; + int fifo_addr, fifo_span, valid_slots; - static spos_control_block_t sposcb = { + static struct dsp_spos_control_block sposcb = { /* 0 */ HFG_TREE_SCB,HFG_STACK, /* 1 */ SPOSCB_ADDR,BG_TREE_SCB_ADDR, /* 2 */ DSP_SPOS_DC,0, @@ -1106,7 +1122,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip) { /* create the null SCB */ - static generic_scb_t null_scb = { + static struct dsp_generic_scb null_scb = { { 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, NULL_SCB_ADDR, NULL_SCB_ADDR, @@ -1128,7 +1144,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip) { /* setup foreground task tree */ - static task_tree_control_block_t fg_task_tree_hdr = { + static struct dsp_task_tree_control_block fg_task_tree_hdr = { { FG_TASK_HEADER_ADDR | (DSP_SPOS_DC << 0x10), DSP_SPOS_DC_DC, DSP_SPOS_DC_DC, @@ -1204,7 +1220,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip) { /* setup foreground task tree */ - static task_tree_control_block_t bg_task_tree_hdr = { + static struct dsp_task_tree_control_block bg_task_tree_hdr = { { DSP_SPOS_DC_DC, DSP_SPOS_DC_DC, DSP_SPOS_DC_DC, @@ -1313,7 +1329,7 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip) if (!write_back_scb) goto _fail_end; { - static mix2_ostream_spb_t mix2_ostream_spb = { + static struct dsp_mix2_ostream_spb mix2_ostream_spb = { 0x00020000, 0x0000ffff }; @@ -1448,13 +1464,14 @@ int cs46xx_dsp_scb_and_task_init (cs46xx_t *chip) return -EINVAL; } -static int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entry) +static int cs46xx_dsp_async_init (struct snd_cs46xx *chip, + struct dsp_scb_descriptor * fg_entry) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - symbol_entry_t * s16_async_codec_input_task; - symbol_entry_t * spdifo_task; - symbol_entry_t * spdifi_task; - dsp_scb_descriptor_t * spdifi_scb_desc,* spdifo_scb_desc,* async_codec_scb_desc; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_symbol_entry * s16_async_codec_input_task; + struct dsp_symbol_entry * spdifo_task; + struct dsp_symbol_entry * spdifi_task; + struct dsp_scb_descriptor * spdifi_scb_desc, * spdifo_scb_desc, * async_codec_scb_desc; s16_async_codec_input_task = cs46xx_dsp_lookup_symbol(chip, "S16_ASYNCCODECINPUTTASK", SYMBOL_CODE); if (s16_async_codec_input_task == NULL) { @@ -1475,7 +1492,7 @@ static int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entr { /* 0xBC0 */ - spdifoscb_t spdifo_scb = { + struct dsp_spdifoscb spdifo_scb = { /* 0 */ DSP_SPOS_UUUU, { /* 1 */ 0xb0, @@ -1504,7 +1521,7 @@ static int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entr }; /* 0xBB0 */ - spdifiscb_t spdifi_scb = { + struct dsp_spdifiscb spdifi_scb = { /* 0 */ DSP_SPOS_UULO,DSP_SPOS_UUHI, /* 1 */ 0, /* 2 */ 0, @@ -1529,7 +1546,7 @@ static int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entr }; /* 0xBA0 */ - async_codec_input_scb_t async_codec_input_scb = { + struct dsp_async_codec_input_scb async_codec_input_scb = { /* 0 */ DSP_SPOS_UUUU, /* 1 */ 0, /* 2 */ 0, @@ -1620,9 +1637,9 @@ static int cs46xx_dsp_async_init (cs46xx_t *chip, dsp_scb_descriptor_t * fg_entr } -static void cs46xx_dsp_disable_spdif_hw (cs46xx_t *chip) +static void cs46xx_dsp_disable_spdif_hw (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; /* set SPDIF output FIFO slot */ snd_cs46xx_pokeBA0(chip, BA0_ASER_FADDR, 0); @@ -1641,9 +1658,9 @@ static void cs46xx_dsp_disable_spdif_hw (cs46xx_t *chip) ins->spdif_status_out &= ~DSP_SPDIF_STATUS_HW_ENABLED; } -int cs46xx_dsp_enable_spdif_hw (cs46xx_t *chip) +int cs46xx_dsp_enable_spdif_hw (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; /* if hw-ctrl already enabled, turn off to reset logic ... */ cs46xx_dsp_disable_spdif_hw (chip); @@ -1664,9 +1681,9 @@ int cs46xx_dsp_enable_spdif_hw (cs46xx_t *chip) return 0; } -int cs46xx_dsp_enable_spdif_in (cs46xx_t *chip) +int cs46xx_dsp_enable_spdif_in (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; /* turn on amplifier */ chip->active_ctrl(chip, 1); @@ -1724,9 +1741,9 @@ int cs46xx_dsp_enable_spdif_in (cs46xx_t *chip) return 0; } -int cs46xx_dsp_disable_spdif_in (cs46xx_t *chip) +int cs46xx_dsp_disable_spdif_in (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; snd_assert (ins->asynch_rx_scb != NULL, return -EINVAL); snd_assert (ins->spdif_in_src != NULL,return -EINVAL); @@ -1750,9 +1767,9 @@ int cs46xx_dsp_disable_spdif_in (cs46xx_t *chip) return 0; } -int cs46xx_dsp_enable_pcm_capture (cs46xx_t *chip) +int cs46xx_dsp_enable_pcm_capture (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; snd_assert (ins->pcm_input == NULL,return -EINVAL); snd_assert (ins->ref_snoop_scb != NULL,return -EINVAL); @@ -1765,9 +1782,9 @@ int cs46xx_dsp_enable_pcm_capture (cs46xx_t *chip) return 0; } -int cs46xx_dsp_disable_pcm_capture (cs46xx_t *chip) +int cs46xx_dsp_disable_pcm_capture (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; snd_assert (ins->pcm_input != NULL,return -EINVAL); @@ -1779,9 +1796,9 @@ int cs46xx_dsp_disable_pcm_capture (cs46xx_t *chip) return 0; } -int cs46xx_dsp_enable_adc_capture (cs46xx_t *chip) +int cs46xx_dsp_enable_adc_capture (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; snd_assert (ins->adc_input == NULL,return -EINVAL); snd_assert (ins->codec_in_scb != NULL,return -EINVAL); @@ -1794,9 +1811,9 @@ int cs46xx_dsp_enable_adc_capture (cs46xx_t *chip) return 0; } -int cs46xx_dsp_disable_adc_capture (cs46xx_t *chip) +int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; snd_assert (ins->adc_input != NULL,return -EINVAL); @@ -1808,7 +1825,7 @@ int cs46xx_dsp_disable_adc_capture (cs46xx_t *chip) return 0; } -int cs46xx_poke_via_dsp (cs46xx_t *chip,u32 address,u32 data) +int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data) { u32 temp; int i; @@ -1845,10 +1862,10 @@ int cs46xx_poke_via_dsp (cs46xx_t *chip,u32 address,u32 data) return 0; } -int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 left,u16 right) +int cs46xx_dsp_set_dac_volume (struct snd_cs46xx * chip, u16 left, u16 right) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * scb; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * scb; down(&chip->spos_mutex); @@ -1874,8 +1891,9 @@ int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 left,u16 right) return 0; } -int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 left,u16 right) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; +int cs46xx_dsp_set_iec958_volume (struct snd_cs46xx * chip, u16 left, u16 right) +{ + struct dsp_spos_instance * ins = chip->dsp_spos_instance; down(&chip->spos_mutex); diff --git a/sound/pci/cs46xx/dsp_spos.h b/sound/pci/cs46xx/dsp_spos.h index 90871bf..0d246bc 100644 --- a/sound/pci/cs46xx/dsp_spos.h +++ b/sound/pci/cs46xx/dsp_spos.h @@ -43,7 +43,7 @@ /* this instruction types needs to be reallocated when load code into DSP */ -typedef enum { +enum wide_opcode { WIDE_FOR_BEGIN_LOOP = 0x20, WIDE_FOR_BEGIN_LOOP2, @@ -58,7 +58,7 @@ typedef enum { WIDE_TBEQ_COND_CALL1_ADDR, WIDE_TBEQ_NCOND_GOTOI_ADDR, WIDE_TBEQ_NCOND_CALL1_ADDR, -} wide_opcode_t; +}; /* SAMPLE segment */ #define VARI_DECIMATE_BUF1 0x0000 @@ -186,7 +186,8 @@ typedef enum { #define SP_SPDOUT_CONTROL 0x804D #define SP_SPDOUT_CSUV 0x808E -static inline u8 _wrap_all_bits (u8 val) { +static inline u8 _wrap_all_bits (u8 val) +{ u8 wrapped; /* wrap all 8 bits */ @@ -201,11 +202,10 @@ static inline u8 _wrap_all_bits (u8 val) { ((val & 0x80) >> 7); return wrapped; - } - -static inline void cs46xx_dsp_spos_update_scb (cs46xx_t * chip,dsp_scb_descriptor_t * scb) +static inline void cs46xx_dsp_spos_update_scb (struct snd_cs46xx * chip, + struct dsp_scb_descriptor * scb) { /* update nextSCB and subListPtr in SCB */ snd_cs46xx_poke(chip, @@ -214,8 +214,10 @@ static inline void cs46xx_dsp_spos_update_scb (cs46xx_t * chip,dsp_scb_descripto (scb->next_scb_ptr->address)); } -static inline void cs46xx_dsp_scb_set_volume (cs46xx_t * chip,dsp_scb_descriptor_t * scb, - u16 left,u16 right) { +static inline void cs46xx_dsp_scb_set_volume (struct snd_cs46xx * chip, + struct dsp_scb_descriptor * scb, + u16 left, u16 right) +{ unsigned int val = ((0xffff - left) << 16 | (0xffff - right)); snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl) << 2, val); diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index 92849e1..6e86500 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -36,14 +36,14 @@ #include "cs46xx_lib.h" #include "dsp_spos.h" -typedef struct _proc_scb_info_t { - dsp_scb_descriptor_t * scb_desc; - cs46xx_t *chip; -} proc_scb_info_t; +struct proc_scb_info { + struct dsp_scb_descriptor * scb_desc; + struct snd_cs46xx *chip; +}; -static void remove_symbol (cs46xx_t * chip,symbol_entry_t * symbol) +static void remove_symbol (struct snd_cs46xx * chip, struct dsp_symbol_entry * symbol) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; int symbol_index = (int)(symbol - ins->symbol_table.symbols); snd_assert(ins->symbol_table.nsymbols > 0,return); @@ -64,12 +64,13 @@ static void remove_symbol (cs46xx_t * chip,symbol_entry_t * symbol) } -static void cs46xx_dsp_proc_scb_info_read (snd_info_entry_t *entry, snd_info_buffer_t * buffer) +static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - proc_scb_info_t * scb_info = (proc_scb_info_t *)entry->private_data; - dsp_scb_descriptor_t * scb = scb_info->scb_desc; - dsp_spos_instance_t * ins; - cs46xx_t *chip = scb_info->chip; + struct proc_scb_info * scb_info = entry->private_data; + struct dsp_scb_descriptor * scb = scb_info->scb_desc; + struct dsp_spos_instance * ins; + struct snd_cs46xx *chip = scb_info->chip; int j,col; void __iomem *dst = chip->region.idx[1].remap_addr + DSP_PARAMETER_BYTE_OFFSET; @@ -106,9 +107,9 @@ static void cs46xx_dsp_proc_scb_info_read (snd_info_entry_t *entry, snd_info_buf up(&chip->spos_mutex); } -static void _dsp_unlink_scb (cs46xx_t *chip,dsp_scb_descriptor_t * scb) +static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; unsigned long flags; if ( scb->parent_scb_ptr ) { @@ -160,7 +161,8 @@ static void _dsp_unlink_scb (cs46xx_t *chip,dsp_scb_descriptor_t * scb) } } -static void _dsp_clear_sample_buffer (cs46xx_t *chip, u32 sample_buffer_addr, int dword_count) +static void _dsp_clear_sample_buffer (struct snd_cs46xx *chip, u32 sample_buffer_addr, + int dword_count) { void __iomem *dst = chip->region.idx[2].remap_addr + sample_buffer_addr; int i; @@ -171,9 +173,9 @@ static void _dsp_clear_sample_buffer (cs46xx_t *chip, u32 sample_buffer_addr, in } } -void cs46xx_dsp_remove_scb (cs46xx_t *chip, dsp_scb_descriptor_t * scb) +void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; /* check integrety */ snd_assert ( (scb->index >= 0 && @@ -218,10 +220,10 @@ void cs46xx_dsp_remove_scb (cs46xx_t *chip, dsp_scb_descriptor_t * scb) } -void cs46xx_dsp_proc_free_scb_desc (dsp_scb_descriptor_t * scb) +void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb) { if (scb->proc_info) { - proc_scb_info_t * scb_info = (proc_scb_info_t *)scb->proc_info->private_data; + struct proc_scb_info * scb_info = scb->proc_info->private_data; snd_printdd("cs46xx_dsp_proc_free_scb_desc: freeing %s\n",scb->scb_name); @@ -233,11 +235,12 @@ void cs46xx_dsp_proc_free_scb_desc (dsp_scb_descriptor_t * scb) } } -void cs46xx_dsp_proc_register_scb_desc (cs46xx_t *chip,dsp_scb_descriptor_t * scb) +void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip, + struct dsp_scb_descriptor * scb) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - snd_info_entry_t * entry; - proc_scb_info_t * scb_info; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct snd_info_entry * entry; + struct proc_scb_info * scb_info; /* register to proc */ if (ins->snd_card != NULL && ins->proc_dsp_dir != NULL && @@ -245,7 +248,7 @@ void cs46xx_dsp_proc_register_scb_desc (cs46xx_t *chip,dsp_scb_descriptor_t * sc if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name, ins->proc_dsp_dir)) != NULL) { - scb_info = kmalloc(sizeof(proc_scb_info_t), GFP_KERNEL); + scb_info = kmalloc(sizeof(struct proc_scb_info), GFP_KERNEL); if (!scb_info) { snd_info_free_entry(entry); entry = NULL; @@ -273,14 +276,14 @@ out: } } -static dsp_scb_descriptor_t * -_dsp_create_generic_scb (cs46xx_t *chip,char * name, u32 * scb_data,u32 dest, - symbol_entry_t * task_entry, - dsp_scb_descriptor_t * parent_scb, +static struct dsp_scb_descriptor * +_dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest, + struct dsp_symbol_entry * task_entry, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * scb; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * scb; unsigned long flags; @@ -342,13 +345,13 @@ _dsp_create_generic_scb (cs46xx_t *chip,char * name, u32 * scb_data,u32 dest, return scb; } -static dsp_scb_descriptor_t * -cs46xx_dsp_create_generic_scb (cs46xx_t *chip,char * name, u32 * scb_data,u32 dest, - char * task_entry_name, - dsp_scb_descriptor_t * parent_scb, +static struct dsp_scb_descriptor * +cs46xx_dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, + u32 dest, char * task_entry_name, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - symbol_entry_t * task_entry; + struct dsp_symbol_entry * task_entry; task_entry = cs46xx_dsp_lookup_symbol (chip,task_entry_name, SYMBOL_CODE); @@ -362,12 +365,12 @@ cs46xx_dsp_create_generic_scb (cs46xx_t *chip,char * name, u32 * scb_data,u32 de parent_scb,scb_child_type); } -dsp_scb_descriptor_t * -cs46xx_dsp_create_timing_master_scb (cs46xx_t *chip) +struct dsp_scb_descriptor * +cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - timing_master_scb_t timing_master_scb = { + struct dsp_timing_master_scb timing_master_scb = { { 0, 0, 0, @@ -396,16 +399,15 @@ cs46xx_dsp_create_timing_master_scb (cs46xx_t *chip) } -dsp_scb_descriptor_t * -cs46xx_dsp_create_codec_out_scb(cs46xx_t * chip,char * codec_name, - u16 channel_disp,u16 fifo_addr, - u16 child_scb_addr, - u32 dest,dsp_scb_descriptor_t * parent_scb, +struct dsp_scb_descriptor * +cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip, char * codec_name, + u16 channel_disp, u16 fifo_addr, u16 child_scb_addr, + u32 dest, struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - codec_output_scb_t codec_out_scb = { + struct dsp_codec_output_scb codec_out_scb = { { 0, 0, 0, @@ -435,16 +437,15 @@ cs46xx_dsp_create_codec_out_scb(cs46xx_t * chip,char * codec_name, return scb; } -dsp_scb_descriptor_t * -cs46xx_dsp_create_codec_in_scb(cs46xx_t * chip,char * codec_name, - u16 channel_disp,u16 fifo_addr, - u16 sample_buffer_addr, - u32 dest,dsp_scb_descriptor_t * parent_scb, - int scb_child_type) +struct dsp_scb_descriptor * +cs46xx_dsp_create_codec_in_scb(struct snd_cs46xx * chip, char * codec_name, + u16 channel_disp, u16 fifo_addr, u16 sample_buffer_addr, + u32 dest, struct dsp_scb_descriptor * parent_scb, + int scb_child_type) { - dsp_scb_descriptor_t * scb; - codec_input_scb_t codec_input_scb = { + struct dsp_scb_descriptor * scb; + struct dsp_codec_input_scb codec_input_scb = { { 0, 0, 0, @@ -481,17 +482,17 @@ cs46xx_dsp_create_codec_in_scb(cs46xx_t * chip,char * codec_name, } -static dsp_scb_descriptor_t * -cs46xx_dsp_create_pcm_reader_scb(cs46xx_t * chip,char * scb_name, - u16 sample_buffer_addr,u32 dest, +static struct dsp_scb_descriptor * +cs46xx_dsp_create_pcm_reader_scb(struct snd_cs46xx * chip, char * scb_name, + u16 sample_buffer_addr, u32 dest, int virtual_channel, u32 playback_hw_addr, - dsp_scb_descriptor_t * parent_scb, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * scb; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * scb; - generic_scb_t pcm_reader_scb = { + struct dsp_generic_scb pcm_reader_scb = { /* Play DMA Task xfers data from host buffer to SP buffer @@ -584,18 +585,18 @@ cs46xx_dsp_create_pcm_reader_scb(cs46xx_t * chip,char * scb_name, #define GOF_PER_SEC 200 -dsp_scb_descriptor_t * -cs46xx_dsp_create_src_task_scb(cs46xx_t * chip,char * scb_name, +struct dsp_scb_descriptor * +cs46xx_dsp_create_src_task_scb(struct snd_cs46xx * chip, char * scb_name, int rate, u16 src_buffer_addr, - u16 src_delay_buffer_addr,u32 dest, - dsp_scb_descriptor_t * parent_scb, + u16 src_delay_buffer_addr, u32 dest, + struct dsp_scb_descriptor * parent_scb, int scb_child_type, int pass_through) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * scb; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * scb; unsigned int tmp1, tmp2; unsigned int phiIncr; unsigned int correctionPerGOF, correctionPerSec; @@ -632,7 +633,7 @@ cs46xx_dsp_create_src_task_scb(cs46xx_t * chip,char * scb_name, correctionPerSec = tmp1; { - src_task_scb_t src_task_scb = { + struct dsp_src_task_scb src_task_scb = { 0x0028,0x00c8, 0x5555,0x0000, 0x0000,0x0000, @@ -688,14 +689,14 @@ cs46xx_dsp_create_src_task_scb(cs46xx_t * chip,char * scb_name, } #if 0 /* not used */ -dsp_scb_descriptor_t * -cs46xx_dsp_create_filter_scb(cs46xx_t * chip,char * scb_name, - u16 buffer_addr,u32 dest, - dsp_scb_descriptor_t * parent_scb, +struct dsp_scb_descriptor * +cs46xx_dsp_create_filter_scb(struct snd_cs46xx * chip, char * scb_name, + u16 buffer_addr, u32 dest, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - filter_scb_t filter_scb = { + struct dsp_filter_scb filter_scb = { .a0_right = 0x41a9, .a0_left = 0x41a9, .a1_right = 0xb8e4, @@ -738,15 +739,15 @@ cs46xx_dsp_create_filter_scb(cs46xx_t * chip,char * scb_name, } #endif /* not used */ -dsp_scb_descriptor_t * -cs46xx_dsp_create_mix_only_scb(cs46xx_t * chip,char * scb_name, - u16 mix_buffer_addr,u32 dest, - dsp_scb_descriptor_t * parent_scb, +struct dsp_scb_descriptor * +cs46xx_dsp_create_mix_only_scb(struct snd_cs46xx * chip, char * scb_name, + u16 mix_buffer_addr, u32 dest, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - mix_only_scb_t master_mix_scb = { + struct dsp_mix_only_scb master_mix_scb = { /* 0 */ { 0, /* 1 */ 0, /* 2 */ mix_buffer_addr, @@ -778,15 +779,15 @@ cs46xx_dsp_create_mix_only_scb(cs46xx_t * chip,char * scb_name, } -dsp_scb_descriptor_t * -cs46xx_dsp_create_mix_to_ostream_scb(cs46xx_t * chip,char * scb_name, - u16 mix_buffer_addr,u16 writeback_spb,u32 dest, - dsp_scb_descriptor_t * parent_scb, +struct dsp_scb_descriptor * +cs46xx_dsp_create_mix_to_ostream_scb(struct snd_cs46xx * chip, char * scb_name, + u16 mix_buffer_addr, u16 writeback_spb, u32 dest, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - mix2_ostream_scb_t mix2_ostream_scb = { + struct dsp_mix2_ostream_scb mix2_ostream_scb = { /* Basic (non scatter/gather) DMA requestor (4 ints) */ { DMA_RQ_C1_SOURCE_MOD64 + @@ -832,18 +833,18 @@ cs46xx_dsp_create_mix_to_ostream_scb(cs46xx_t * chip,char * scb_name, } -dsp_scb_descriptor_t * -cs46xx_dsp_create_vari_decimate_scb(cs46xx_t * chip,char * scb_name, +struct dsp_scb_descriptor * +cs46xx_dsp_create_vari_decimate_scb(struct snd_cs46xx * chip,char * scb_name, u16 vari_buffer_addr0, u16 vari_buffer_addr1, u32 dest, - dsp_scb_descriptor_t * parent_scb, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - vari_decimate_scb_t vari_decimate_scb = { + struct dsp_vari_decimate_scb vari_decimate_scb = { 0x0028,0x00c8, 0x5555,0x0000, 0x0000,0x0000, @@ -876,17 +877,17 @@ cs46xx_dsp_create_vari_decimate_scb(cs46xx_t * chip,char * scb_name, } -static dsp_scb_descriptor_t * -cs46xx_dsp_create_pcm_serial_input_scb(cs46xx_t * chip,char * scb_name,u32 dest, - dsp_scb_descriptor_t * input_scb, - dsp_scb_descriptor_t * parent_scb, +static struct dsp_scb_descriptor * +cs46xx_dsp_create_pcm_serial_input_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest, + struct dsp_scb_descriptor * input_scb, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - pcm_serial_input_scb_t pcm_serial_input_scb = { + struct dsp_pcm_serial_input_scb pcm_serial_input_scb = { { 0, 0, 0, @@ -919,17 +920,17 @@ cs46xx_dsp_create_pcm_serial_input_scb(cs46xx_t * chip,char * scb_name,u32 dest, } -static dsp_scb_descriptor_t * -cs46xx_dsp_create_asynch_fg_tx_scb(cs46xx_t * chip,char * scb_name,u32 dest, +static struct dsp_scb_descriptor * +cs46xx_dsp_create_asynch_fg_tx_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address, - dsp_scb_descriptor_t * parent_scb, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - asynch_fg_tx_scb_t asynch_fg_tx_scb = { + struct dsp_asynch_fg_tx_scb asynch_fg_tx_scb = { 0xfc00,0x03ff, /* Prototype sample buffer size of 256 dwords */ 0x0058,0x0028, /* Min Delta 7 dwords == 28 bytes */ /* : Max delta 25 dwords == 100 bytes */ @@ -966,17 +967,17 @@ cs46xx_dsp_create_asynch_fg_tx_scb(cs46xx_t * chip,char * scb_name,u32 dest, } -dsp_scb_descriptor_t * -cs46xx_dsp_create_asynch_fg_rx_scb(cs46xx_t * chip,char * scb_name,u32 dest, +struct dsp_scb_descriptor * +cs46xx_dsp_create_asynch_fg_rx_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest, u16 hfg_scb_address, u16 asynch_buffer_address, - dsp_scb_descriptor_t * parent_scb, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * scb; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * scb; - asynch_fg_rx_scb_t asynch_fg_rx_scb = { + struct dsp_asynch_fg_rx_scb asynch_fg_rx_scb = { 0xfe00,0x01ff, /* Prototype sample buffer size of 128 dwords */ 0x0064,0x001c, /* Min Delta 7 dwords == 28 bytes */ /* : Max delta 25 dwords == 100 bytes */ @@ -1016,17 +1017,17 @@ cs46xx_dsp_create_asynch_fg_rx_scb(cs46xx_t * chip,char * scb_name,u32 dest, #if 0 /* not used */ -dsp_scb_descriptor_t * -cs46xx_dsp_create_output_snoop_scb(cs46xx_t * chip,char * scb_name,u32 dest, +struct dsp_scb_descriptor * +cs46xx_dsp_create_output_snoop_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest, u16 snoop_buffer_address, - dsp_scb_descriptor_t * snoop_scb, - dsp_scb_descriptor_t * parent_scb, + struct dsp_scb_descriptor * snoop_scb, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - output_snoop_scb_t output_snoop_scb = { + struct dsp_output_snoop_scb output_snoop_scb = { { 0, /* not used. Zero */ 0, 0, @@ -1058,14 +1059,14 @@ cs46xx_dsp_create_output_snoop_scb(cs46xx_t * chip,char * scb_name,u32 dest, #endif /* not used */ -dsp_scb_descriptor_t * -cs46xx_dsp_create_spio_write_scb(cs46xx_t * chip,char * scb_name,u32 dest, - dsp_scb_descriptor_t * parent_scb, +struct dsp_scb_descriptor * +cs46xx_dsp_create_spio_write_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest, + struct dsp_scb_descriptor * parent_scb, int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - spio_write_scb_t spio_write_scb = { + struct dsp_spio_write_scb spio_write_scb = { 0,0, /* SPIOWAddress2:SPIOWAddress1; */ 0, /* SPIOWData1; */ 0, /* SPIOWData2; */ @@ -1094,15 +1095,16 @@ cs46xx_dsp_create_spio_write_scb(cs46xx_t * chip,char * scb_name,u32 dest, return scb; } -dsp_scb_descriptor_t * cs46xx_dsp_create_magic_snoop_scb(cs46xx_t * chip,char * scb_name,u32 dest, - u16 snoop_buffer_address, - dsp_scb_descriptor_t * snoop_scb, - dsp_scb_descriptor_t * parent_scb, - int scb_child_type) +struct dsp_scb_descriptor * +cs46xx_dsp_create_magic_snoop_scb(struct snd_cs46xx * chip, char * scb_name, u32 dest, + u16 snoop_buffer_address, + struct dsp_scb_descriptor * snoop_scb, + struct dsp_scb_descriptor * parent_scb, + int scb_child_type) { - dsp_scb_descriptor_t * scb; + struct dsp_scb_descriptor * scb; - magic_snoop_task_t magic_snoop_scb = { + struct dsp_magic_snoop_task magic_snoop_scb = { /* 0 */ 0, /* i0 */ /* 1 */ 0, /* i1 */ /* 2 */ snoop_buffer_address << 0x10, @@ -1129,10 +1131,11 @@ dsp_scb_descriptor_t * cs46xx_dsp_create_magic_snoop_scb(cs46xx_t * chip,char * return scb; } -static dsp_scb_descriptor_t * find_next_free_scb (cs46xx_t * chip,dsp_scb_descriptor_t * from) +static struct dsp_scb_descriptor * +find_next_free_scb (struct snd_cs46xx * chip, struct dsp_scb_descriptor * from) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * scb = from; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * scb = from; while (scb->next_scb_ptr != ins->the_null_scb) { snd_assert (scb->next_scb_ptr != NULL, return NULL); @@ -1212,18 +1215,19 @@ static u32 src_delay_buffer_addr[DSP_MAX_SRC_NR] = { 0x2B00 }; -pcm_channel_descriptor_t * cs46xx_dsp_create_pcm_channel (cs46xx_t * chip, - u32 sample_rate, void * private_data, - u32 hw_dma_addr, - int pcm_channel_id) +struct dsp_pcm_channel_descriptor * +cs46xx_dsp_create_pcm_channel (struct snd_cs46xx * chip, + u32 sample_rate, void * private_data, + u32 hw_dma_addr, + int pcm_channel_id) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * src_scb = NULL,* pcm_scb, * mixer_scb = NULL; - dsp_scb_descriptor_t * src_parent_scb = NULL; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * src_scb = NULL, * pcm_scb, * mixer_scb = NULL; + struct dsp_scb_descriptor * src_parent_scb = NULL; - /* dsp_scb_descriptor_t * pcm_parent_scb; */ + /* struct dsp_scb_descriptor * pcm_parent_scb; */ char scb_name[DSP_MAX_SCB_NAME]; - int i,pcm_index = -1, insert_point, src_index = -1,pass_through = 0; + int i, pcm_index = -1, insert_point, src_index = -1, pass_through = 0; unsigned long flags; switch (pcm_channel_id) { @@ -1371,8 +1375,8 @@ pcm_channel_descriptor_t * cs46xx_dsp_create_pcm_channel (cs46xx_t * chip, return (ins->pcm_channels + pcm_index); } -int cs46xx_dsp_pcm_channel_set_period (cs46xx_t * chip, - pcm_channel_descriptor_t * pcm_channel, +int cs46xx_dsp_pcm_channel_set_period (struct snd_cs46xx * chip, + struct dsp_pcm_channel_descriptor * pcm_channel, int period_size) { u32 temp = snd_cs46xx_peek (chip,pcm_channel->pcm_reader_scb->address << 2); @@ -1410,7 +1414,7 @@ int cs46xx_dsp_pcm_channel_set_period (cs46xx_t * chip, return 0; } -int cs46xx_dsp_pcm_ostream_set_period (cs46xx_t * chip, +int cs46xx_dsp_pcm_ostream_set_period (struct snd_cs46xx * chip, int period_size) { u32 temp = snd_cs46xx_peek (chip,WRITEBACK_SCB_ADDR << 2); @@ -1448,9 +1452,10 @@ int cs46xx_dsp_pcm_ostream_set_period (cs46xx_t * chip, return 0; } -void cs46xx_dsp_destroy_pcm_channel (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel) +void cs46xx_dsp_destroy_pcm_channel (struct snd_cs46xx * chip, + struct dsp_pcm_channel_descriptor * pcm_channel) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; unsigned long flags; snd_assert(pcm_channel->active, return ); @@ -1478,9 +1483,10 @@ void cs46xx_dsp_destroy_pcm_channel (cs46xx_t * chip,pcm_channel_descriptor_t * } } -int cs46xx_dsp_pcm_unlink (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel) +int cs46xx_dsp_pcm_unlink (struct snd_cs46xx * chip, + struct dsp_pcm_channel_descriptor * pcm_channel) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; unsigned long flags; snd_assert(pcm_channel->active,return -EIO); @@ -1503,11 +1509,12 @@ int cs46xx_dsp_pcm_unlink (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channe return 0; } -int cs46xx_dsp_pcm_link (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel) +int cs46xx_dsp_pcm_link (struct snd_cs46xx * chip, + struct dsp_pcm_channel_descriptor * pcm_channel) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * parent_scb; - dsp_scb_descriptor_t * src_scb = pcm_channel->src_scb; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * parent_scb; + struct dsp_scb_descriptor * src_scb = pcm_channel->src_scb; unsigned long flags; spin_lock(&pcm_channel->src_scb->lock); @@ -1544,12 +1551,13 @@ int cs46xx_dsp_pcm_link (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel) return 0; } -dsp_scb_descriptor_t * cs46xx_add_record_source (cs46xx_t *chip,dsp_scb_descriptor_t * source, - u16 addr,char * scb_name) +struct dsp_scb_descriptor * +cs46xx_add_record_source (struct snd_cs46xx *chip, struct dsp_scb_descriptor * source, + u16 addr, char * scb_name) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * parent; - dsp_scb_descriptor_t * pcm_input; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * parent; + struct dsp_scb_descriptor * pcm_input; int insert_point; snd_assert (ins->record_mixer_scb != NULL,return NULL); @@ -1569,7 +1577,7 @@ dsp_scb_descriptor_t * cs46xx_add_record_source (cs46xx_t *chip,dsp_scb_descript return pcm_input; } -int cs46xx_src_unlink(cs46xx_t *chip,dsp_scb_descriptor_t * src) +int cs46xx_src_unlink(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) { snd_assert (src->parent_scb_ptr != NULL, return -EINVAL ); @@ -1581,10 +1589,10 @@ int cs46xx_src_unlink(cs46xx_t *chip,dsp_scb_descriptor_t * src) return 0; } -int cs46xx_src_link(cs46xx_t *chip,dsp_scb_descriptor_t * src) +int cs46xx_src_link(struct snd_cs46xx *chip, struct dsp_scb_descriptor * src) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; - dsp_scb_descriptor_t * parent_scb; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; + struct dsp_scb_descriptor * parent_scb; snd_assert (src->parent_scb_ptr == NULL, return -EINVAL ); snd_assert(ins->master_mix_scb !=NULL, return -EINVAL ); @@ -1605,9 +1613,9 @@ int cs46xx_src_link(cs46xx_t *chip,dsp_scb_descriptor_t * src) return 0; } -int cs46xx_dsp_enable_spdif_out (cs46xx_t *chip) +int cs46xx_dsp_enable_spdif_out (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; if ( ! (ins->spdif_status_out & DSP_SPDIF_STATUS_HW_ENABLED) ) { cs46xx_dsp_enable_spdif_hw (chip); @@ -1653,9 +1661,9 @@ int cs46xx_dsp_enable_spdif_out (cs46xx_t *chip) return 0; } -int cs46xx_dsp_disable_spdif_out (cs46xx_t *chip) +int cs46xx_dsp_disable_spdif_out (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; /* dont touch anything if SPDIF is open */ if ( ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) { @@ -1685,9 +1693,9 @@ int cs46xx_dsp_disable_spdif_out (cs46xx_t *chip) return 0; } -int cs46xx_iec958_pre_open (cs46xx_t *chip) +int cs46xx_iec958_pre_open (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; if ( ins->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED ) { /* remove AsynchFGTxSCB and and PCMSerialInput_II */ @@ -1718,9 +1726,9 @@ int cs46xx_iec958_pre_open (cs46xx_t *chip) return 0; } -int cs46xx_iec958_post_close (cs46xx_t *chip) +int cs46xx_iec958_post_close (struct snd_cs46xx *chip) { - dsp_spos_instance_t * ins = chip->dsp_spos_instance; + struct dsp_spos_instance * ins = chip->dsp_spos_instance; snd_assert (ins->asynch_tx_scb != NULL, return -EINVAL); diff --git a/sound/pci/cs46xx/imgs/cwc4630.h b/sound/pci/cs46xx/imgs/cwc4630.h index 8bed07f..37c4f13 100644 --- a/sound/pci/cs46xx/imgs/cwc4630.h +++ b/sound/pci/cs46xx/imgs/cwc4630.h @@ -3,7 +3,7 @@ #ifndef __HEADER_cwc4630_H__ #define __HEADER_cwc4630_H__ -static symbol_entry_t cwc4630_symbols[] = { +static struct dsp_symbol_entry cwc4630_symbols[] = { { 0x0000, "BEGINADDRESS",0x00 }, { 0x8000, "EXECCHILD",0x03 }, { 0x8001, "EXECCHILD_98",0x03 }, @@ -302,12 +302,12 @@ static u32 cwc4630_parameter[] = { }; /* #PARAMETER_END */ -static segment_desc_t cwc4630_segments[] = { +static struct dsp_segment_desc cwc4630_segments[] = { { SEGTYPE_SP_PROGRAM, 0x00000000, 0x00000328, cwc4630_code }, { SEGTYPE_SP_PARAMETER, 0x00000000, 0x00000080, cwc4630_parameter }, }; -static dsp_module_desc_t cwc4630_module = { +static struct dsp_module_desc cwc4630_module = { "cwc4630", { 38, diff --git a/sound/pci/cs46xx/imgs/cwcasync.h b/sound/pci/cs46xx/imgs/cwcasync.h index e01a7b6..70e63e1 100644 --- a/sound/pci/cs46xx/imgs/cwcasync.h +++ b/sound/pci/cs46xx/imgs/cwcasync.h @@ -3,7 +3,7 @@ #ifndef __HEADER_cwcasync_H__ #define __HEADER_cwcasync_H__ -static symbol_entry_t cwcasync_symbols[] = { +static struct dsp_symbol_entry cwcasync_symbols[] = { { 0x8000, "EXECCHILD",0x03 }, { 0x8001, "EXECCHILD_98",0x03 }, { 0x8003, "EXECCHILD_PUSH1IND",0x03 }, @@ -159,11 +159,11 @@ static u32 cwcasync_code[] = { }; /* #CODE_END */ -static segment_desc_t cwcasync_segments[] = { +static struct dsp_segment_desc cwcasync_segments[] = { { SEGTYPE_SP_PROGRAM, 0x00000000, 0x000001b6, cwcasync_code }, }; -static dsp_module_desc_t cwcasync_module = { +static struct dsp_module_desc cwcasync_module = { "cwcasync", { 32, diff --git a/sound/pci/cs46xx/imgs/cwcbinhack.h b/sound/pci/cs46xx/imgs/cwcbinhack.h index 436b38b..f4d9368 100644 --- a/sound/pci/cs46xx/imgs/cwcbinhack.h +++ b/sound/pci/cs46xx/imgs/cwcbinhack.h @@ -4,7 +4,7 @@ #ifndef __HEADER_cwcbinhack_H__ #define __HEADER_cwcbinhack_H__ -static symbol_entry_t cwcbinhack_symbols[] = { +static struct dsp_symbol_entry cwcbinhack_symbols[] = { { 0x02c8, "OVERLAYBEGINADDRESS",0x00 }, { 0x02c8, "MAGICSNOOPTASK",0x03 }, { 0x0308, "#CODE_END",0x00 }, @@ -31,11 +31,11 @@ static u32 cwcbinhack_code[] = { }; /* #CODE_END */ -static segment_desc_t cwcbinhack_segments[] = { +static struct dsp_segment_desc cwcbinhack_segments[] = { { SEGTYPE_SP_PROGRAM, 0x00000000, 64, cwcbinhack_code }, }; -static dsp_module_desc_t cwcbinhack_module = { +static struct dsp_module_desc cwcbinhack_module = { "cwcbinhack", { 3, diff --git a/sound/pci/cs46xx/imgs/cwcdma.h b/sound/pci/cs46xx/imgs/cwcdma.h index 9286043..7ff0d45 100644 --- a/sound/pci/cs46xx/imgs/cwcdma.h +++ b/sound/pci/cs46xx/imgs/cwcdma.h @@ -3,7 +3,7 @@ #ifndef __HEADER_cwcdma_H__ #define __HEADER_cwcdma_H__ -static symbol_entry_t cwcdma_symbols[] = { +static struct dsp_symbol_entry cwcdma_symbols[] = { { 0x8000, "EXECCHILD",0x03 }, { 0x8001, "EXECCHILD_98",0x03 }, { 0x8003, "EXECCHILD_PUSH1IND",0x03 }, @@ -51,11 +51,11 @@ static u32 cwcdma_code[] = { /* #CODE_END */ -static segment_desc_t cwcdma_segments[] = { +static struct dsp_segment_desc cwcdma_segments[] = { { SEGTYPE_SP_PROGRAM, 0x00000000, 0x00000030, cwcdma_code }, }; -static dsp_module_desc_t cwcdma_module = { +static struct dsp_module_desc cwcdma_module = { "cwcdma", { 27, diff --git a/sound/pci/cs46xx/imgs/cwcemb80.h b/sound/pci/cs46xx/imgs/cwcemb80.h index 4b13551..a64c6ff 100644 --- a/sound/pci/cs46xx/imgs/cwcemb80.h +++ b/sound/pci/cs46xx/imgs/cwcemb80.h @@ -3,7 +3,7 @@ #ifndef __HEADER_cwcemb80_H__ #define __HEADER_cwcemb80_H__ -static symbol_entry_t cwcemb80_symbols[] = { +static struct dsp_symbol_entry cwcemb80_symbols[] = { { 0x0000, "BEGINADDRESS",0x00 }, { 0x8000, "EXECCHILD",0x03 }, { 0x8001, "EXECCHILD_98",0x03 }, @@ -1588,13 +1588,13 @@ static u32 cwcemb80_sample[] = { }; /* #SAMPLE_END */ -static segment_desc_t cwcemb80_segments[] = { +static struct dsp_segment_desc cwcemb80_segments[] = { { SEGTYPE_SP_PROGRAM, 0x00000000, 0x0000031c, cwcemb80_code }, { SEGTYPE_SP_PARAMETER, 0x00000000, 0x00000697, cwcemb80_parameter }, { SEGTYPE_SP_SAMPLE, 0x00000000, 0x00000e00, cwcemb80_sample }, }; -static dsp_module_desc_t cwcemb80_module = { +static struct dsp_module_desc cwcemb80_module = { "cwcemb80", { 38, diff --git a/sound/pci/cs46xx/imgs/cwcsnoop.h b/sound/pci/cs46xx/imgs/cwcsnoop.h index be1162b..6929d0a 100644 --- a/sound/pci/cs46xx/imgs/cwcsnoop.h +++ b/sound/pci/cs46xx/imgs/cwcsnoop.h @@ -3,7 +3,7 @@ #ifndef __HEADER_cwcsnoop_H__ #define __HEADER_cwcsnoop_H__ -static symbol_entry_t cwcsnoop_symbols[] = { +static struct dsp_symbol_entry cwcsnoop_symbols[] = { { 0x0500, "OVERLAYBEGINADDRESS",0x00 }, { 0x0500, "OUTPUTSNOOP",0x03 }, { 0x051f, "#CODE_END",0x00 }, @@ -29,11 +29,11 @@ static u32 cwcsnoop_code[] = { }; /* #CODE_END */ -static segment_desc_t cwcsnoop_segments[] = { +static struct dsp_segment_desc cwcsnoop_segments[] = { { SEGTYPE_SP_PROGRAM, 0x00000000, 0x0000003e, cwcsnoop_code }, }; -static dsp_module_desc_t cwcsnoop_module = { +static struct dsp_module_desc cwcsnoop_module = { "cwcsnoop", { 3, -- cgit v1.1 From eb4698f347ec908c365504c4edddadd1acd406ea Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:50:13 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI emu10k1 Modules: EMU10K1/EMU10K2 driver Remove xxx_t typedefs from the PCI emu10k1 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/emu10k1.h | 336 +++++++++++++++--------------- include/sound/emu10k1_synth.h | 6 +- sound/pci/emu10k1/emu10k1.c | 10 +- sound/pci/emu10k1/emu10k1_callback.c | 105 +++++----- sound/pci/emu10k1/emu10k1_main.c | 39 ++-- sound/pci/emu10k1/emu10k1_patch.c | 13 +- sound/pci/emu10k1/emu10k1_synth.c | 19 +- sound/pci/emu10k1/emu10k1_synth_local.h | 15 +- sound/pci/emu10k1/emufx.c | 244 ++++++++++++---------- sound/pci/emu10k1/emumixer.c | 229 +++++++++++---------- sound/pci/emu10k1/emumpu401.c | 72 +++---- sound/pci/emu10k1/emupcm.c | 354 ++++++++++++++++---------------- sound/pci/emu10k1/emuproc.c | 101 ++++----- sound/pci/emu10k1/io.c | 38 ++-- sound/pci/emu10k1/irq.c | 8 +- sound/pci/emu10k1/memory.c | 94 +++++---- sound/pci/emu10k1/p16v.c | 254 +++++++++++------------ sound/pci/emu10k1/timer.c | 18 +- sound/pci/emu10k1/voice.c | 13 +- 19 files changed, 1022 insertions(+), 946 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 8411c7e..d14c543 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -887,47 +887,45 @@ /* ------------------- STRUCTURES -------------------- */ -typedef struct _snd_emu10k1 emu10k1_t; -typedef struct _snd_emu10k1_voice emu10k1_voice_t; -typedef struct _snd_emu10k1_pcm emu10k1_pcm_t; - -typedef enum { +enum { EMU10K1_EFX, EMU10K1_PCM, EMU10K1_SYNTH, EMU10K1_MIDI -} emu10k1_voice_type_t; +}; + +struct snd_emu10k1; -struct _snd_emu10k1_voice { - emu10k1_t *emu; +struct snd_emu10k1_voice { + struct snd_emu10k1 *emu; int number; unsigned int use: 1, pcm: 1, efx: 1, synth: 1, midi: 1; - void (*interrupt)(emu10k1_t *emu, emu10k1_voice_t *pvoice); + void (*interrupt)(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *pvoice); - emu10k1_pcm_t *epcm; + struct snd_emu10k1_pcm *epcm; }; -typedef enum { +enum { PLAYBACK_EMUVOICE, PLAYBACK_EFX, CAPTURE_AC97ADC, CAPTURE_AC97MIC, CAPTURE_EFX -} snd_emu10k1_pcm_type_t; - -struct _snd_emu10k1_pcm { - emu10k1_t *emu; - snd_emu10k1_pcm_type_t type; - snd_pcm_substream_t *substream; - emu10k1_voice_t *voices[NUM_EFX_PLAYBACK]; - emu10k1_voice_t *extra; +}; + +struct snd_emu10k1_pcm { + struct snd_emu10k1 *emu; + int type; + struct snd_pcm_substream *substream; + struct snd_emu10k1_voice *voices[NUM_EFX_PLAYBACK]; + struct snd_emu10k1_voice *extra; unsigned short running; unsigned short first_ptr; - snd_util_memblk_t *memblk; + struct snd_util_memblk *memblk; unsigned int start_addr; unsigned int ccca_start_addr; unsigned int capture_ipr; /* interrupt acknowledge mask */ @@ -941,13 +939,13 @@ struct _snd_emu10k1_pcm { unsigned int capture_bufsize; /* buffer size in bytes */ }; -typedef struct { +struct snd_emu10k1_pcm_mixer { /* mono, left, right x 8 sends (4 on emu10k1) */ unsigned char send_routing[3][8]; unsigned char send_volume[3][8]; unsigned short attn[3]; - emu10k1_pcm_t *epcm; -} emu10k1_pcm_mixer_t; + struct snd_emu10k1_pcm *epcm; +}; #define snd_emu10k1_compose_send_routing(route) \ ((route[0] | (route[1] << 4) | (route[2] << 8) | (route[3] << 12)) << 16) @@ -958,20 +956,20 @@ typedef struct { #define snd_emu10k1_compose_audigy_fxrt2(route) \ ((unsigned int)route[4] | ((unsigned int)route[5] << 8) | ((unsigned int)route[6] << 16) | ((unsigned int)route[7] << 24)) -typedef struct snd_emu10k1_memblk { - snd_util_memblk_t mem; +struct snd_emu10k1_memblk { + struct snd_util_memblk mem; /* private part */ int first_page, last_page, pages, mapped_page; unsigned int map_locked; struct list_head mapped_link; struct list_head mapped_order_link; -} emu10k1_memblk_t; +}; #define snd_emu10k1_memblk_offset(blk) (((blk)->mapped_page << PAGE_SHIFT) | ((blk)->mem.offset & (PAGE_SIZE - 1))) #define EMU10K1_MAX_TRAM_BLOCKS_PER_CODE 16 -typedef struct { +struct snd_emu10k1_fx8010_ctl { struct list_head list; /* list link container */ unsigned int vcount; unsigned int count; /* count of GPR (1..16) */ @@ -980,19 +978,19 @@ typedef struct { unsigned int min; /* minimum range */ unsigned int max; /* maximum range */ unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */ - snd_kcontrol_t *kcontrol; -} snd_emu10k1_fx8010_ctl_t; + struct snd_kcontrol *kcontrol; +}; -typedef void (snd_fx8010_irq_handler_t)(emu10k1_t *emu, void *private_data); +typedef void (snd_fx8010_irq_handler_t)(struct snd_emu10k1 *emu, void *private_data); -typedef struct _snd_emu10k1_fx8010_irq { - struct _snd_emu10k1_fx8010_irq *next; +struct snd_emu10k1_fx8010_irq { + struct snd_emu10k1_fx8010_irq *next; snd_fx8010_irq_handler_t *handler; unsigned short gpr_running; void *private_data; -} snd_emu10k1_fx8010_irq_t; +}; -typedef struct { +struct snd_emu10k1_fx8010_pcm { unsigned int valid: 1, opened: 1, active: 1; @@ -1006,13 +1004,13 @@ typedef struct { unsigned short gpr_trigger; /* GPR containing trigger (activate) information (host) */ unsigned short gpr_running; /* GPR containing info if PCM is running (FX8010) */ unsigned char etram[32]; /* external TRAM address & data */ - snd_pcm_indirect_t pcm_rec; + struct snd_pcm_indirect pcm_rec; unsigned int tram_pos; unsigned int tram_shift; - snd_emu10k1_fx8010_irq_t *irq; -} snd_emu10k1_fx8010_pcm_t; + struct snd_emu10k1_fx8010_irq *irq; +}; -typedef struct { +struct snd_emu10k1_fx8010 { unsigned short fxbus_mask; /* used FX buses (bitmask) */ unsigned short extin_mask; /* used external inputs (bitmask) */ unsigned short extout_mask; /* used external outputs (bitmask) */ @@ -1025,18 +1023,18 @@ typedef struct { int gpr_count; /* count of used kcontrols */ struct list_head gpr_ctl; /* GPR controls */ struct semaphore lock; - snd_emu10k1_fx8010_pcm_t pcm[8]; + struct snd_emu10k1_fx8010_pcm pcm[8]; spinlock_t irq_lock; - snd_emu10k1_fx8010_irq_t *irq_handlers; -} snd_emu10k1_fx8010_t; + struct snd_emu10k1_fx8010_irq *irq_handlers; +}; -#define emu10k1_gpr_ctl(n) list_entry(n, snd_emu10k1_fx8010_ctl_t, list) +#define emu10k1_gpr_ctl(n) list_entry(n, struct snd_emu10k1_fx8010_ctl, list) -typedef struct { - struct _snd_emu10k1 *emu; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream_input; - snd_rawmidi_substream_t *substream_output; +struct snd_emu10k1_midi { + struct snd_emu10k1 *emu; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream_input; + struct snd_rawmidi_substream *substream_output; unsigned int midi_mode; spinlock_t input_lock; spinlock_t output_lock; @@ -1044,10 +1042,10 @@ typedef struct { int tx_enable, rx_enable; int port; int ipr_tx, ipr_rx; - void (*interrupt)(emu10k1_t *emu, unsigned int status); -} emu10k1_midi_t; + void (*interrupt)(struct snd_emu10k1 *emu, unsigned int status); +}; -typedef struct { +struct snd_emu_chip_details { u32 vendor; u32 device; u32 subsystem; @@ -1066,15 +1064,16 @@ typedef struct { const char *driver; const char *name; const char *id; /* for backward compatibility - can be NULL if not needed */ -} emu_chip_details_t; +}; -struct _snd_emu10k1 { +struct snd_emu10k1 { int irq; unsigned long port; /* I/O port number */ unsigned int tos_link: 1, /* tos link detected */ rear_ac97: 1; /* rear channels are on AC'97 */ - const emu_chip_details_t *card_capabilities; /* Contains profile of card capabilities */ + /* Contains profile of card capabilities */ + const struct snd_emu_chip_details *card_capabilities; unsigned int audigy; /* is Audigy? */ unsigned int revision; /* chip revision */ unsigned int serial; /* serial number */ @@ -1088,8 +1087,8 @@ struct _snd_emu10k1 { struct snd_dma_device p16v_dma_dev; struct snd_dma_buffer p16v_buffer; - snd_util_memhdr_t *memhdr; /* page allocation list */ - emu10k1_memblk_t *reserved_page; /* reserved page */ + struct snd_util_memhdr *memhdr; /* page allocation list */ + struct snd_emu10k1_memblk *reserved_page; /* reserved page */ struct list_head mapped_link_head; struct list_head mapped_order_link_head; @@ -1099,142 +1098,142 @@ struct _snd_emu10k1 { unsigned int spdif_bits[3]; /* s/pdif out setup */ - snd_emu10k1_fx8010_t fx8010; /* FX8010 info */ + struct snd_emu10k1_fx8010 fx8010; /* FX8010 info */ int gpr_base; - ac97_t *ac97; + struct snd_ac97 *ac97; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_t *pcm_mic; - snd_pcm_t *pcm_efx; - snd_pcm_t *pcm_p16v; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm *pcm_mic; + struct snd_pcm *pcm_efx; + struct snd_pcm *pcm_p16v; spinlock_t synth_lock; void *synth; - int (*get_synth_voice)(emu10k1_t *emu); + int (*get_synth_voice)(struct snd_emu10k1 *emu); spinlock_t reg_lock; spinlock_t emu_lock; spinlock_t voice_lock; struct semaphore ptb_lock; - emu10k1_voice_t voices[NUM_G]; - emu10k1_voice_t p16v_voices[4]; - emu10k1_voice_t p16v_capture_voice; + struct snd_emu10k1_voice voices[NUM_G]; + struct snd_emu10k1_voice p16v_voices[4]; + struct snd_emu10k1_voice p16v_capture_voice; int p16v_device_offset; u32 p16v_capture_source; u32 p16v_capture_channel; - emu10k1_pcm_mixer_t pcm_mixer[32]; - emu10k1_pcm_mixer_t efx_pcm_mixer[NUM_EFX_PLAYBACK]; - snd_kcontrol_t *ctl_send_routing; - snd_kcontrol_t *ctl_send_volume; - snd_kcontrol_t *ctl_attn; - snd_kcontrol_t *ctl_efx_send_routing; - snd_kcontrol_t *ctl_efx_send_volume; - snd_kcontrol_t *ctl_efx_attn; - - void (*hwvol_interrupt)(emu10k1_t *emu, unsigned int status); - void (*capture_interrupt)(emu10k1_t *emu, unsigned int status); - void (*capture_mic_interrupt)(emu10k1_t *emu, unsigned int status); - void (*capture_efx_interrupt)(emu10k1_t *emu, unsigned int status); - void (*spdif_interrupt)(emu10k1_t *emu, unsigned int status); - void (*dsp_interrupt)(emu10k1_t *emu); - - snd_pcm_substream_t *pcm_capture_substream; - snd_pcm_substream_t *pcm_capture_mic_substream; - snd_pcm_substream_t *pcm_capture_efx_substream; - snd_pcm_substream_t *pcm_playback_efx_substream; - - snd_timer_t *timer; - - emu10k1_midi_t midi; - emu10k1_midi_t midi2; /* for audigy */ + struct snd_emu10k1_pcm_mixer pcm_mixer[32]; + struct snd_emu10k1_pcm_mixer efx_pcm_mixer[NUM_EFX_PLAYBACK]; + struct snd_kcontrol *ctl_send_routing; + struct snd_kcontrol *ctl_send_volume; + struct snd_kcontrol *ctl_attn; + struct snd_kcontrol *ctl_efx_send_routing; + struct snd_kcontrol *ctl_efx_send_volume; + struct snd_kcontrol *ctl_efx_attn; + + void (*hwvol_interrupt)(struct snd_emu10k1 *emu, unsigned int status); + void (*capture_interrupt)(struct snd_emu10k1 *emu, unsigned int status); + void (*capture_mic_interrupt)(struct snd_emu10k1 *emu, unsigned int status); + void (*capture_efx_interrupt)(struct snd_emu10k1 *emu, unsigned int status); + void (*spdif_interrupt)(struct snd_emu10k1 *emu, unsigned int status); + void (*dsp_interrupt)(struct snd_emu10k1 *emu); + + struct snd_pcm_substream *pcm_capture_substream; + struct snd_pcm_substream *pcm_capture_mic_substream; + struct snd_pcm_substream *pcm_capture_efx_substream; + struct snd_pcm_substream *pcm_playback_efx_substream; + + struct snd_timer *timer; + + struct snd_emu10k1_midi midi; + struct snd_emu10k1_midi midi2; /* for audigy */ unsigned int efx_voices_mask[2]; unsigned int next_free_voice; }; -int snd_emu10k1_create(snd_card_t * card, +int snd_emu10k1_create(struct snd_card *card, struct pci_dev *pci, unsigned short extin_mask, unsigned short extout_mask, long max_cache_bytes, int enable_ir, uint subsystem, - emu10k1_t ** remu); - -int snd_emu10k1_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm); -int snd_emu10k1_pcm_mic(emu10k1_t * emu, int device, snd_pcm_t ** rpcm); -int snd_emu10k1_pcm_efx(emu10k1_t * emu, int device, snd_pcm_t ** rpcm); -int snd_p16v_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm); -int snd_p16v_free(emu10k1_t * emu); -int snd_p16v_mixer(emu10k1_t * emu); -int snd_emu10k1_pcm_multi(emu10k1_t * emu, int device, snd_pcm_t ** rpcm); -int snd_emu10k1_fx8010_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm); -int snd_emu10k1_mixer(emu10k1_t * emu, int pcm_device, int multi_device); -int snd_emu10k1_timer(emu10k1_t * emu, int device); -int snd_emu10k1_fx8010_new(emu10k1_t *emu, int device, snd_hwdep_t ** rhwdep); + struct snd_emu10k1 ** remu); + +int snd_emu10k1_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm); +int snd_emu10k1_pcm_mic(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm); +int snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm); +int snd_p16v_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm); +int snd_p16v_free(struct snd_emu10k1 * emu); +int snd_p16v_mixer(struct snd_emu10k1 * emu); +int snd_emu10k1_pcm_multi(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm); +int snd_emu10k1_fx8010_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm); +int snd_emu10k1_mixer(struct snd_emu10k1 * emu, int pcm_device, int multi_device); +int snd_emu10k1_timer(struct snd_emu10k1 * emu, int device); +int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep ** rhwdep); irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs); /* initialization */ -void snd_emu10k1_voice_init(emu10k1_t * emu, int voice); -int snd_emu10k1_init_efx(emu10k1_t *emu); -void snd_emu10k1_free_efx(emu10k1_t *emu); -int snd_emu10k1_fx8010_tram_setup(emu10k1_t *emu, u32 size); +void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int voice); +int snd_emu10k1_init_efx(struct snd_emu10k1 *emu); +void snd_emu10k1_free_efx(struct snd_emu10k1 *emu); +int snd_emu10k1_fx8010_tram_setup(struct snd_emu10k1 *emu, u32 size); /* I/O functions */ -unsigned int snd_emu10k1_ptr_read(emu10k1_t * emu, unsigned int reg, unsigned int chn); -void snd_emu10k1_ptr_write(emu10k1_t *emu, unsigned int reg, unsigned int chn, unsigned int data); -unsigned int snd_emu10k1_ptr20_read(emu10k1_t * emu, unsigned int reg, unsigned int chn); -void snd_emu10k1_ptr20_write(emu10k1_t *emu, unsigned int reg, unsigned int chn, unsigned int data); -unsigned int snd_emu10k1_efx_read(emu10k1_t *emu, unsigned int pc); -void snd_emu10k1_intr_enable(emu10k1_t *emu, unsigned int intrenb); -void snd_emu10k1_intr_disable(emu10k1_t *emu, unsigned int intrenb); -void snd_emu10k1_voice_intr_enable(emu10k1_t *emu, unsigned int voicenum); -void snd_emu10k1_voice_intr_disable(emu10k1_t *emu, unsigned int voicenum); -void snd_emu10k1_voice_intr_ack(emu10k1_t *emu, unsigned int voicenum); -void snd_emu10k1_voice_half_loop_intr_enable(emu10k1_t *emu, unsigned int voicenum); -void snd_emu10k1_voice_half_loop_intr_disable(emu10k1_t *emu, unsigned int voicenum); -void snd_emu10k1_voice_half_loop_intr_ack(emu10k1_t *emu, unsigned int voicenum); -void snd_emu10k1_voice_set_loop_stop(emu10k1_t *emu, unsigned int voicenum); -void snd_emu10k1_voice_clear_loop_stop(emu10k1_t *emu, unsigned int voicenum); -void snd_emu10k1_wait(emu10k1_t *emu, unsigned int wait); -static inline unsigned int snd_emu10k1_wc(emu10k1_t *emu) { return (inl(emu->port + WC) >> 6) & 0xfffff; } -unsigned short snd_emu10k1_ac97_read(ac97_t *ac97, unsigned short reg); -void snd_emu10k1_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short data); +unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn); +void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data); +unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn); +void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data); +unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc); +void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb); +void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb); +void snd_emu10k1_voice_intr_enable(struct snd_emu10k1 *emu, unsigned int voicenum); +void snd_emu10k1_voice_intr_disable(struct snd_emu10k1 *emu, unsigned int voicenum); +void snd_emu10k1_voice_intr_ack(struct snd_emu10k1 *emu, unsigned int voicenum); +void snd_emu10k1_voice_half_loop_intr_enable(struct snd_emu10k1 *emu, unsigned int voicenum); +void snd_emu10k1_voice_half_loop_intr_disable(struct snd_emu10k1 *emu, unsigned int voicenum); +void snd_emu10k1_voice_half_loop_intr_ack(struct snd_emu10k1 *emu, unsigned int voicenum); +void snd_emu10k1_voice_set_loop_stop(struct snd_emu10k1 *emu, unsigned int voicenum); +void snd_emu10k1_voice_clear_loop_stop(struct snd_emu10k1 *emu, unsigned int voicenum); +void snd_emu10k1_wait(struct snd_emu10k1 *emu, unsigned int wait); +static inline unsigned int snd_emu10k1_wc(struct snd_emu10k1 *emu) { return (inl(emu->port + WC) >> 6) & 0xfffff; } +unsigned short snd_emu10k1_ac97_read(struct snd_ac97 *ac97, unsigned short reg); +void snd_emu10k1_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short data); unsigned int snd_emu10k1_rate_to_pitch(unsigned int rate); /* memory allocation */ -snd_util_memblk_t *snd_emu10k1_alloc_pages(emu10k1_t *emu, snd_pcm_substream_t *substream); -int snd_emu10k1_free_pages(emu10k1_t *emu, snd_util_memblk_t *blk); -snd_util_memblk_t *snd_emu10k1_synth_alloc(emu10k1_t *emu, unsigned int size); -int snd_emu10k1_synth_free(emu10k1_t *emu, snd_util_memblk_t *blk); -int snd_emu10k1_synth_bzero(emu10k1_t *emu, snd_util_memblk_t *blk, int offset, int size); -int snd_emu10k1_synth_copy_from_user(emu10k1_t *emu, snd_util_memblk_t *blk, int offset, const char __user *data, int size); -int snd_emu10k1_memblk_map(emu10k1_t *emu, emu10k1_memblk_t *blk); +struct snd_util_memblk *snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream); +int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk); +struct snd_util_memblk *snd_emu10k1_synth_alloc(struct snd_emu10k1 *emu, unsigned int size); +int snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *blk); +int snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, int offset, int size); +int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, int offset, const char __user *data, int size); +int snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk); /* voice allocation */ -int snd_emu10k1_voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int pair, emu10k1_voice_t **rvoice); -int snd_emu10k1_voice_free(emu10k1_t *emu, emu10k1_voice_t *pvoice); +int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int pair, struct snd_emu10k1_voice **rvoice); +int snd_emu10k1_voice_free(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *pvoice); /* MIDI uart */ -int snd_emu10k1_midi(emu10k1_t * emu); -int snd_emu10k1_audigy_midi(emu10k1_t * emu); +int snd_emu10k1_midi(struct snd_emu10k1 * emu); +int snd_emu10k1_audigy_midi(struct snd_emu10k1 * emu); /* proc interface */ -int snd_emu10k1_proc_init(emu10k1_t * emu); +int snd_emu10k1_proc_init(struct snd_emu10k1 * emu); /* fx8010 irq handler */ -int snd_emu10k1_fx8010_register_irq_handler(emu10k1_t *emu, +int snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu, snd_fx8010_irq_handler_t *handler, unsigned char gpr_running, void *private_data, - snd_emu10k1_fx8010_irq_t **r_irq); -int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu, - snd_emu10k1_fx8010_irq_t *irq); + struct snd_emu10k1_fx8010_irq **r_irq); +int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_irq *irq); #endif /* __KERNEL__ */ @@ -1469,14 +1468,14 @@ int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu, #define TANKMEMADDRREG_READ 0x00100000 /* Read from tank memory */ #endif -typedef struct { +struct snd_emu10k1_fx8010_info { unsigned int internal_tram_size; /* in samples */ unsigned int external_tram_size; /* in samples */ char fxbus_names[16][32]; /* names of FXBUSes */ char extin_names[16][32]; /* names of external inputs */ char extout_names[32][32]; /* names of external outputs */ unsigned int gpr_controls; /* count of GPR controls */ -} emu10k1_fx8010_info_t; +}; #define EMU10K1_GPR_TRANSLATION_NONE 0 #define EMU10K1_GPR_TRANSLATION_TABLE100 1 @@ -1484,8 +1483,8 @@ typedef struct { #define EMU10K1_GPR_TRANSLATION_TREBLE 3 #define EMU10K1_GPR_TRANSLATION_ONOFF 4 -typedef struct { - snd_ctl_elem_id_t id; /* full control ID definition */ +struct snd_emu10k1_fx8010_control_gpr { + struct snd_ctl_elem_id id; /* full control ID definition */ unsigned int vcount; /* visible count */ unsigned int count; /* count of GPR (1..16) */ unsigned short gpr[32]; /* GPR number(s) */ @@ -1493,23 +1492,23 @@ typedef struct { unsigned int min; /* minimum range */ unsigned int max; /* maximum range */ unsigned int translation; /* translation type (EMU10K1_GPR_TRANSLATION*) */ -} emu10k1_fx8010_control_gpr_t; +}; -typedef struct { +struct snd_emu10k1_fx8010_code { char name[128]; DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */ u_int32_t __user *gpr_map; /* initializers */ unsigned int gpr_add_control_count; /* count of GPR controls to add/replace */ - emu10k1_fx8010_control_gpr_t __user *gpr_add_controls; /* GPR controls to add/replace */ + struct snd_emu10k1_fx8010_control_gpr __user *gpr_add_controls; /* GPR controls to add/replace */ unsigned int gpr_del_control_count; /* count of GPR controls to remove */ - snd_ctl_elem_id_t __user *gpr_del_controls; /* IDs of GPR controls to remove */ + struct snd_ctl_elem_id __user *gpr_del_controls; /* IDs of GPR controls to remove */ unsigned int gpr_list_control_count; /* count of GPR controls to list */ unsigned int gpr_list_control_total; /* total count of GPR controls */ - emu10k1_fx8010_control_gpr_t __user *gpr_list_controls; /* listed GPR controls */ + struct snd_emu10k1_fx8010_control_gpr __user *gpr_list_controls; /* listed GPR controls */ DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */ u_int32_t __user *tram_data_map; /* data initializers */ @@ -1517,16 +1516,16 @@ typedef struct { DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions */ u_int32_t __user *code; /* one instruction - 64 bits */ -} emu10k1_fx8010_code_t; +}; -typedef struct { +struct snd_emu10k1_fx8010_tram { unsigned int address; /* 31.bit == 1 -> external TRAM */ unsigned int size; /* size in samples (4 bytes) */ unsigned int *samples; /* pointer to samples (20-bit) */ /* NULL->clear memory */ -} emu10k1_fx8010_tram_t; +}; -typedef struct { +struct snd_emu10k1_fx8010_pcm_rec { unsigned int substream; /* substream number */ unsigned int res1; /* reserved */ unsigned int channels; /* 16-bit channels count, zero = remove this substream */ @@ -1541,20 +1540,27 @@ typedef struct { unsigned char pad; /* reserved */ unsigned char etram[32]; /* external TRAM address & data (one per channel) */ unsigned int res2; /* reserved */ -} emu10k1_fx8010_pcm_t; +}; -#define SNDRV_EMU10K1_IOCTL_INFO _IOR ('H', 0x10, emu10k1_fx8010_info_t) -#define SNDRV_EMU10K1_IOCTL_CODE_POKE _IOW ('H', 0x11, emu10k1_fx8010_code_t) -#define SNDRV_EMU10K1_IOCTL_CODE_PEEK _IOWR('H', 0x12, emu10k1_fx8010_code_t) +#define SNDRV_EMU10K1_IOCTL_INFO _IOR ('H', 0x10, struct snd_emu10k1_fx8010_info) +#define SNDRV_EMU10K1_IOCTL_CODE_POKE _IOW ('H', 0x11, struct snd_emu10k1_fx8010_code) +#define SNDRV_EMU10K1_IOCTL_CODE_PEEK _IOWR('H', 0x12, struct snd_emu10k1_fx8010_code) #define SNDRV_EMU10K1_IOCTL_TRAM_SETUP _IOW ('H', 0x20, int) -#define SNDRV_EMU10K1_IOCTL_TRAM_POKE _IOW ('H', 0x21, emu10k1_fx8010_tram_t) -#define SNDRV_EMU10K1_IOCTL_TRAM_PEEK _IOWR('H', 0x22, emu10k1_fx8010_tram_t) -#define SNDRV_EMU10K1_IOCTL_PCM_POKE _IOW ('H', 0x30, emu10k1_fx8010_pcm_t) -#define SNDRV_EMU10K1_IOCTL_PCM_PEEK _IOWR('H', 0x31, emu10k1_fx8010_pcm_t) +#define SNDRV_EMU10K1_IOCTL_TRAM_POKE _IOW ('H', 0x21, struct snd_emu10k1_fx8010_tram) +#define SNDRV_EMU10K1_IOCTL_TRAM_PEEK _IOWR('H', 0x22, struct snd_emu10k1_fx8010_tram) +#define SNDRV_EMU10K1_IOCTL_PCM_POKE _IOW ('H', 0x30, struct snd_emu10k1_fx8010_pcm_rec) +#define SNDRV_EMU10K1_IOCTL_PCM_PEEK _IOWR('H', 0x31, struct snd_emu10k1_fx8010_pcm_rec) #define SNDRV_EMU10K1_IOCTL_STOP _IO ('H', 0x80) #define SNDRV_EMU10K1_IOCTL_CONTINUE _IO ('H', 0x81) #define SNDRV_EMU10K1_IOCTL_ZERO_TRAM_COUNTER _IO ('H', 0x82) #define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int) #define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int) +/* typedefs for compatibility to user-space */ +typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t; +typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t; +typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t; +typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t; +typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t; + #endif /* __SOUND_EMU10K1_H */ diff --git a/include/sound/emu10k1_synth.h b/include/sound/emu10k1_synth.h index df0df1d..6ef61c4 100644 --- a/include/sound/emu10k1_synth.h +++ b/include/sound/emu10k1_synth.h @@ -27,12 +27,12 @@ #define SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH "emu10k1-synth" /* argument for snd_seq_device_new */ -typedef struct snd_emu10k1_synth_arg { - emu10k1_t *hwptr; /* chip */ +struct snd_emu10k1_synth_arg { + struct snd_emu10k1 *hwptr; /* chip */ int index; /* sequencer client index */ int seq_ports; /* number of sequencer ports to be created */ int max_voices; /* maximum number of voices for wavetable */ -} snd_emu10k1_synth_arg_t; +}; #define EMU10K1_MAX_MEMSIZE (32 * 1024 * 1024) /* 32MB */ diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 78270f8..9be9002 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -101,10 +101,10 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - emu10k1_t *emu; + struct snd_card *card; + struct snd_emu10k1 *emu; #ifdef ENABLE_SYNTH - snd_seq_device_t *wave = NULL; + struct snd_seq_device *wave = NULL; #endif int err; @@ -186,11 +186,11 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci, } #ifdef ENABLE_SYNTH if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, - sizeof(snd_emu10k1_synth_arg_t), &wave) < 0 || + sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 || wave == NULL) { snd_printk(KERN_WARNING "can't initialize Emu10k1 wavetable synth\n"); } else { - snd_emu10k1_synth_arg_t *arg; + struct snd_emu10k1_synth_arg *arg; arg = SNDRV_SEQ_DEVICE_ARGPTR(wave); strcpy(wave->name, "Emu-10k1 Synth"); arg->hwptr = emu; diff --git a/sound/pci/emu10k1/emu10k1_callback.c b/sound/pci/emu10k1/emu10k1_callback.c index 6589bf2..01965bd 100644 --- a/sound/pci/emu10k1/emu10k1_callback.c +++ b/sound/pci/emu10k1/emu10k1_callback.c @@ -27,26 +27,28 @@ enum { }; /* Keeps track of what we are finding */ -typedef struct best_voice { +struct best_voice { unsigned int time; int voice; -} best_voice_t; +}; /* * prototypes */ -static void lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_only); -static snd_emux_voice_t *get_voice(snd_emux_t *emu, snd_emux_port_t *port); -static int start_voice(snd_emux_voice_t *vp); -static void trigger_voice(snd_emux_voice_t *vp); -static void release_voice(snd_emux_voice_t *vp); -static void update_voice(snd_emux_voice_t *vp, int update); -static void terminate_voice(snd_emux_voice_t *vp); -static void free_voice(snd_emux_voice_t *vp); - -static void set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp); -static void set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp); -static void set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp); +static void lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, + struct best_voice *best, int active_only); +static struct snd_emux_voice *get_voice(struct snd_emux *emu, + struct snd_emux_port *port); +static int start_voice(struct snd_emux_voice *vp); +static void trigger_voice(struct snd_emux_voice *vp); +static void release_voice(struct snd_emux_voice *vp); +static void update_voice(struct snd_emux_voice *vp, int update); +static void terminate_voice(struct snd_emux_voice *vp); +static void free_voice(struct snd_emux_voice *vp); + +static void set_fmmod(struct snd_emu10k1 *hw, struct snd_emux_voice *vp); +static void set_fm2frq2(struct snd_emu10k1 *hw, struct snd_emux_voice *vp); +static void set_filterQ(struct snd_emu10k1 *hw, struct snd_emux_voice *vp); /* * Ensure a value is between two points @@ -59,7 +61,7 @@ static void set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp); /* * set up operators */ -static snd_emux_operators_t emu10k1_ops = { +static struct snd_emux_operators emu10k1_ops = { .owner = THIS_MODULE, .get_voice = get_voice, .prepare = start_voice, @@ -73,7 +75,7 @@ static snd_emux_operators_t emu10k1_ops = { }; void -snd_emu10k1_ops_setup(snd_emux_t *emu) +snd_emu10k1_ops_setup(struct snd_emux *emu) { emu->ops = emu10k1_ops; } @@ -85,11 +87,11 @@ snd_emu10k1_ops_setup(snd_emux_t *emu) * terminate most inactive voice and give it as a pcm voice. */ int -snd_emu10k1_synth_get_voice(emu10k1_t *hw) +snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw) { - snd_emux_t *emu; - snd_emux_voice_t *vp; - best_voice_t best[V_END]; + struct snd_emux *emu; + struct snd_emux_voice *vp; + struct best_voice best[V_END]; unsigned long flags; int i; @@ -123,10 +125,10 @@ snd_emu10k1_synth_get_voice(emu10k1_t *hw) * turn off the voice (not terminated) */ static void -release_voice(snd_emux_voice_t *vp) +release_voice(struct snd_emux_voice *vp) { int dcysusv; - emu10k1_t *hw; + struct snd_emu10k1 *hw; hw = vp->hw; dcysusv = 0x8000 | (unsigned char)vp->reg.parm.modrelease; @@ -140,16 +142,16 @@ release_voice(snd_emux_voice_t *vp) * terminate the voice */ static void -terminate_voice(snd_emux_voice_t *vp) +terminate_voice(struct snd_emux_voice *vp) { - emu10k1_t *hw; + struct snd_emu10k1 *hw; snd_assert(vp, return); hw = vp->hw; snd_emu10k1_ptr_write(hw, DCYSUSV, vp->ch, 0x807f | DCYSUSV_CHANNELENABLE_MASK); if (vp->block) { - emu10k1_memblk_t *emem; - emem = (emu10k1_memblk_t *)vp->block; + struct snd_emu10k1_memblk *emem; + emem = (struct snd_emu10k1_memblk *)vp->block; if (emem->map_locked > 0) emem->map_locked--; } @@ -159,9 +161,9 @@ terminate_voice(snd_emux_voice_t *vp) * release the voice to system */ static void -free_voice(snd_emux_voice_t *vp) +free_voice(struct snd_emux_voice *vp) { - emu10k1_t *hw; + struct snd_emu10k1 *hw; hw = vp->hw; if (vp->ch >= 0) { @@ -181,9 +183,9 @@ free_voice(snd_emux_voice_t *vp) * update registers */ static void -update_voice(snd_emux_voice_t *vp, int update) +update_voice(struct snd_emux_voice *vp, int update) { - emu10k1_t *hw; + struct snd_emu10k1 *hw; hw = vp->hw; if (update & SNDRV_EMUX_UPDATE_VOLUME) @@ -210,10 +212,11 @@ update_voice(snd_emux_voice_t *vp, int update) */ /* spinlock held! */ static void -lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_only) +lookup_voices(struct snd_emux *emu, struct snd_emu10k1 *hw, + struct best_voice *best, int active_only) { - snd_emux_voice_t *vp; - best_voice_t *bp; + struct snd_emux_voice *vp; + struct best_voice *bp; int i; for (i = 0; i < V_END; i++) { @@ -274,12 +277,12 @@ lookup_voices(snd_emux_t *emu, emu10k1_t *hw, best_voice_t *best, int active_onl * * emu->voice_lock is already held. */ -static snd_emux_voice_t * -get_voice(snd_emux_t *emu, snd_emux_port_t *port) +static struct snd_emux_voice * +get_voice(struct snd_emux *emu, struct snd_emux_port *port) { - emu10k1_t *hw; - snd_emux_voice_t *vp; - best_voice_t best[V_END]; + struct snd_emu10k1 *hw; + struct snd_emux_voice *vp; + struct best_voice best[V_END]; int i; hw = emu->hw; @@ -290,7 +293,7 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port) vp = &emu->voices[best[i].voice]; if (vp->ch < 0) { /* allocate a voice */ - emu10k1_voice_t *hwvoice; + struct snd_emu10k1_voice *hwvoice; if (snd_emu10k1_voice_alloc(hw, EMU10K1_SYNTH, 1, &hwvoice) < 0 || hwvoice == NULL) continue; vp->ch = hwvoice->number; @@ -308,21 +311,21 @@ get_voice(snd_emux_t *emu, snd_emux_port_t *port) * prepare envelopes and LFOs */ static int -start_voice(snd_emux_voice_t *vp) +start_voice(struct snd_emux_voice *vp) { unsigned int temp; int ch; unsigned int addr, mapped_offset; - snd_midi_channel_t *chan; - emu10k1_t *hw; - emu10k1_memblk_t *emem; + struct snd_midi_channel *chan; + struct snd_emu10k1 *hw; + struct snd_emu10k1_memblk *emem; hw = vp->hw; ch = vp->ch; snd_assert(ch >= 0, return -EINVAL); chan = vp->chan; - emem = (emu10k1_memblk_t *)vp->block; + emem = (struct snd_emu10k1_memblk *)vp->block; if (emem == NULL) return -EINVAL; emem->map_locked++; @@ -463,15 +466,15 @@ start_voice(snd_emux_voice_t *vp) * Start envelope */ static void -trigger_voice(snd_emux_voice_t *vp) +trigger_voice(struct snd_emux_voice *vp) { unsigned int temp, ptarget; - emu10k1_t *hw; - emu10k1_memblk_t *emem; + struct snd_emu10k1 *hw; + struct snd_emu10k1_memblk *emem; hw = vp->hw; - emem = (emu10k1_memblk_t *)vp->block; + emem = (struct snd_emu10k1_memblk *)vp->block; if (! emem || emem->mapped_page < 0) return; /* not mapped */ @@ -495,7 +498,7 @@ trigger_voice(snd_emux_voice_t *vp) /* set lfo1 modulation height and cutoff */ static void -set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp) +set_fmmod(struct snd_emu10k1 *hw, struct snd_emux_voice *vp) { unsigned short fmmod; short pitch; @@ -513,7 +516,7 @@ set_fmmod(emu10k1_t *hw, snd_emux_voice_t *vp) /* set lfo2 pitch & frequency */ static void -set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp) +set_fm2frq2(struct snd_emu10k1 *hw, struct snd_emux_voice *vp) { unsigned short fm2frq2; short pitch; @@ -531,7 +534,7 @@ set_fm2frq2(emu10k1_t *hw, snd_emux_voice_t *vp) /* set filterQ */ static void -set_filterQ(emu10k1_t *hw, snd_emux_voice_t *vp) +set_filterQ(struct snd_emu10k1 *hw, struct snd_emux_voice *vp) { unsigned int val; val = snd_emu10k1_ptr_read(hw, CCCA, vp->ch) & ~CCCA_RESONANCE; diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 2d1ebe8..f985507 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -52,7 +52,7 @@ MODULE_LICENSE("GPL"); * EMU10K1 init / done *************************************************************************/ -void snd_emu10k1_voice_init(emu10k1_t * emu, int ch) +void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int ch) { snd_emu10k1_ptr_write(emu, DCYSUSV, ch, 0); snd_emu10k1_ptr_write(emu, IP, ch, 0); @@ -97,7 +97,7 @@ void snd_emu10k1_voice_init(emu10k1_t * emu, int ch) } } -static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) +static int __devinit snd_emu10k1_init(struct snd_emu10k1 * emu, int enable_ir) { int ch, idx, err; unsigned int silent_page; @@ -336,14 +336,14 @@ static int __devinit snd_emu10k1_init(emu10k1_t * emu, int enable_ir) snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE); - emu->reserved_page = (emu10k1_memblk_t *)snd_emu10k1_synth_alloc(emu, 4096); + emu->reserved_page = (struct snd_emu10k1_memblk *)snd_emu10k1_synth_alloc(emu, 4096); if (emu->reserved_page) emu->reserved_page->map_locked = 1; return 0; } -static int snd_emu10k1_done(emu10k1_t * emu) +static int snd_emu10k1_done(struct snd_emu10k1 * emu) { int ch; @@ -384,7 +384,7 @@ static int snd_emu10k1_done(emu10k1_t * emu) /* remove reserved page */ if (emu->reserved_page != NULL) { - snd_emu10k1_synth_free(emu, (snd_util_memblk_t *)emu->reserved_page); + snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page); emu->reserved_page = NULL; } @@ -474,7 +474,7 @@ static int snd_emu10k1_done(emu10k1_t * emu) * register. */ -static void snd_emu10k1_ecard_write(emu10k1_t * emu, unsigned int value) +static void snd_emu10k1_ecard_write(struct snd_emu10k1 * emu, unsigned int value) { unsigned short count; unsigned int data; @@ -512,7 +512,7 @@ static void snd_emu10k1_ecard_write(emu10k1_t * emu, unsigned int value) * channel. */ -static void snd_emu10k1_ecard_setadcgain(emu10k1_t * emu, +static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu, unsigned short gain) { unsigned int bit; @@ -540,7 +540,7 @@ static void snd_emu10k1_ecard_setadcgain(emu10k1_t * emu, snd_emu10k1_ecard_write(emu, emu->ecard_ctrl); } -static int __devinit snd_emu10k1_ecard_init(emu10k1_t * emu) +static int __devinit snd_emu10k1_ecard_init(struct snd_emu10k1 * emu) { unsigned int hc_value; @@ -580,7 +580,7 @@ static int __devinit snd_emu10k1_ecard_init(emu10k1_t * emu) return 0; } -static int __devinit snd_emu10k1_cardbus_init(emu10k1_t * emu) +static int __devinit snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) { unsigned long special_port; unsigned int value; @@ -609,7 +609,7 @@ static int __devinit snd_emu10k1_cardbus_init(emu10k1_t * emu) * Create the EMU10K1 instance */ -static int snd_emu10k1_free(emu10k1_t *emu) +static int snd_emu10k1_free(struct snd_emu10k1 *emu) { if (emu->port) { /* avoid access to already used hardware */ snd_emu10k1_fx8010_tram_setup(emu, 0); @@ -634,13 +634,13 @@ static int snd_emu10k1_free(emu10k1_t *emu) return 0; } -static int snd_emu10k1_dev_free(snd_device_t *device) +static int snd_emu10k1_dev_free(struct snd_device *device) { - emu10k1_t *emu = device->device_data; + struct snd_emu10k1 *emu = device->device_data; return snd_emu10k1_free(emu); } -static emu_chip_details_t emu_chip_details[] = { +static struct snd_emu_chip_details emu_chip_details[] = { /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ /* Tested by James@superbug.co.uk 3rd July 2005 */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, @@ -890,21 +890,21 @@ static emu_chip_details_t emu_chip_details[] = { { } /* terminator */ }; -int __devinit snd_emu10k1_create(snd_card_t * card, +int __devinit snd_emu10k1_create(struct snd_card *card, struct pci_dev * pci, unsigned short extin_mask, unsigned short extout_mask, long max_cache_bytes, int enable_ir, uint subsystem, - emu10k1_t ** remu) + struct snd_emu10k1 ** remu) { - emu10k1_t *emu; + struct snd_emu10k1 *emu; int err; int is_audigy; unsigned char revision; - const emu_chip_details_t *c; - static snd_device_ops_t ops = { + const struct snd_emu_chip_details *c; + static struct snd_device_ops ops = { .dev_free = snd_emu10k1_dev_free, }; @@ -1041,7 +1041,8 @@ int __devinit snd_emu10k1_create(snd_card_t * card, snd_emu10k1_free(emu); return -ENOMEM; } - emu->memhdr->block_extra_size = sizeof(emu10k1_memblk_t) - sizeof(snd_util_memblk_t); + emu->memhdr->block_extra_size = sizeof(struct snd_emu10k1_memblk) - + sizeof(struct snd_util_memblk); pci_set_master(pci); diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c index 4df668eb3..42bae6f 100644 --- a/sound/pci/emu10k1/emu10k1_patch.c +++ b/sound/pci/emu10k1/emu10k1_patch.c @@ -35,14 +35,15 @@ * allocate a sample block and copy data from userspace */ int -snd_emu10k1_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr, const void __user *data, long count) +snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *data, long count) { int offset; int truesize, size, loopsize, blocksize; int loopend, sampleend; unsigned int start_addr; - emu10k1_t *emu; + struct snd_emu10k1 *emu; emu = rec->hw; snd_assert(sp != NULL, return -EINVAL); @@ -205,10 +206,10 @@ snd_emu10k1_sample_new(snd_emux_t *rec, snd_sf_sample_t *sp, * free a sample block */ int -snd_emu10k1_sample_free(snd_emux_t *rec, snd_sf_sample_t *sp, - snd_util_memhdr_t *hdr) +snd_emu10k1_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr) { - emu10k1_t *emu; + struct snd_emu10k1 *emu; emu = rec->hw; snd_assert(sp != NULL, return -EINVAL); diff --git a/sound/pci/emu10k1/emu10k1_synth.c b/sound/pci/emu10k1/emu10k1_synth.c index 8bd58d1..1fa393f 100644 --- a/sound/pci/emu10k1/emu10k1_synth.c +++ b/sound/pci/emu10k1/emu10k1_synth.c @@ -28,11 +28,11 @@ MODULE_LICENSE("GPL"); /* * create a new hardware dependent device for Emu10k1 */ -static int snd_emu10k1_synth_new_device(snd_seq_device_t *dev) +static int snd_emu10k1_synth_new_device(struct snd_seq_device *dev) { - snd_emux_t *emu; - emu10k1_t *hw; - snd_emu10k1_synth_arg_t *arg; + struct snd_emux *emu; + struct snd_emu10k1 *hw; + struct snd_emu10k1_synth_arg *arg; unsigned long flags; arg = SNDRV_SEQ_DEVICE_ARGPTR(dev); @@ -76,10 +76,10 @@ static int snd_emu10k1_synth_new_device(snd_seq_device_t *dev) return 0; } -static int snd_emu10k1_synth_delete_device(snd_seq_device_t *dev) +static int snd_emu10k1_synth_delete_device(struct snd_seq_device *dev) { - snd_emux_t *emu; - emu10k1_t *hw; + struct snd_emux *emu; + struct snd_emu10k1 *hw; unsigned long flags; if (dev->driver_data == NULL) @@ -104,11 +104,12 @@ static int snd_emu10k1_synth_delete_device(snd_seq_device_t *dev) static int __init alsa_emu10k1_synth_init(void) { - static snd_seq_dev_ops_t ops = { + static struct snd_seq_dev_ops ops = { snd_emu10k1_synth_new_device, snd_emu10k1_synth_delete_device, }; - return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops, sizeof(snd_emu10k1_synth_arg_t)); + return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, &ops, + sizeof(struct snd_emu10k1_synth_arg)); } static void __exit alsa_emu10k1_synth_exit(void) diff --git a/sound/pci/emu10k1/emu10k1_synth_local.h b/sound/pci/emu10k1/emu10k1_synth_local.h index 7f50b01..308ddc8 100644 --- a/sound/pci/emu10k1/emu10k1_synth_local.h +++ b/sound/pci/emu10k1/emu10k1_synth_local.h @@ -26,13 +26,18 @@ #include <sound/emu10k1_synth.h> /* emu10k1_patch.c */ -int snd_emu10k1_sample_new(snd_emux_t *private_data, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr, const void __user *_data, long count); -int snd_emu10k1_sample_free(snd_emux_t *private_data, snd_sf_sample_t *sp, snd_util_memhdr_t *hdr); -int snd_emu10k1_memhdr_init(snd_emux_t *emu); +int snd_emu10k1_sample_new(struct snd_emux *private_data, + struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr, + const void __user *_data, long count); +int snd_emu10k1_sample_free(struct snd_emux *private_data, + struct snd_sf_sample *sp, + struct snd_util_memhdr *hdr); +int snd_emu10k1_memhdr_init(struct snd_emux *emu); /* emu10k1_callback.c */ -void snd_emu10k1_ops_setup(snd_emux_t *emu); -int snd_emu10k1_synth_get_voice(emu10k1_t *hw); +void snd_emu10k1_ops_setup(struct snd_emux *emu); +int snd_emu10k1_synth_get_voice(struct snd_emu10k1 *hw); #endif /* __EMU10K1_SYNTH_LOCAL_H */ diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 03e8c16..f4452c5 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -309,9 +309,10 @@ static inline void snd_leave_user(mm_segment_t fs) * controls */ -static int snd_emu10k1_gpr_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_gpr_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - snd_emu10k1_fx8010_ctl_t *ctl = (snd_emu10k1_fx8010_ctl_t *)kcontrol->private_value; + struct snd_emu10k1_fx8010_ctl *ctl = + (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; if (ctl->min == 0 && ctl->max == 1) uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; @@ -323,10 +324,11 @@ static int snd_emu10k1_gpr_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_emu10k1_gpr_ctl_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_gpr_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - snd_emu10k1_fx8010_ctl_t *ctl = (snd_emu10k1_fx8010_ctl_t *)kcontrol->private_value; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_fx8010_ctl *ctl = + (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; unsigned long flags; unsigned int i; @@ -337,10 +339,11 @@ static int snd_emu10k1_gpr_ctl_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_emu10k1_gpr_ctl_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_gpr_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - snd_emu10k1_fx8010_ctl_t *ctl = (snd_emu10k1_fx8010_ctl_t *)kcontrol->private_value; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_fx8010_ctl *ctl = + (struct snd_emu10k1_fx8010_ctl *) kcontrol->private_value; unsigned long flags; unsigned int nval, val; unsigned int i, j; @@ -393,9 +396,9 @@ static int snd_emu10k1_gpr_ctl_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value * Interrupt handler */ -static void snd_emu10k1_fx8010_interrupt(emu10k1_t *emu) +static void snd_emu10k1_fx8010_interrupt(struct snd_emu10k1 *emu) { - snd_emu10k1_fx8010_irq_t *irq, *nirq; + struct snd_emu10k1_fx8010_irq *irq, *nirq; irq = emu->fx8010.irq_handlers; while (irq) { @@ -409,13 +412,13 @@ static void snd_emu10k1_fx8010_interrupt(emu10k1_t *emu) } } -int snd_emu10k1_fx8010_register_irq_handler(emu10k1_t *emu, - snd_fx8010_irq_handler_t *handler, - unsigned char gpr_running, - void *private_data, - snd_emu10k1_fx8010_irq_t **r_irq) +int snd_emu10k1_fx8010_register_irq_handler(struct snd_emu10k1 *emu, + snd_fx8010_irq_handler_t *handler, + unsigned char gpr_running, + void *private_data, + struct snd_emu10k1_fx8010_irq **r_irq) { - snd_emu10k1_fx8010_irq_t *irq; + struct snd_emu10k1_fx8010_irq *irq; unsigned long flags; irq = kmalloc(sizeof(*irq), GFP_ATOMIC); @@ -440,10 +443,10 @@ int snd_emu10k1_fx8010_register_irq_handler(emu10k1_t *emu, return 0; } -int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu, - snd_emu10k1_fx8010_irq_t *irq) +int snd_emu10k1_fx8010_unregister_irq_handler(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_irq *irq) { - snd_emu10k1_fx8010_irq_t *tmp; + struct snd_emu10k1_fx8010_irq *tmp; unsigned long flags; spin_lock_irqsave(&emu->fx8010.irq_lock, flags); @@ -468,7 +471,8 @@ int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu, * EMU10K1 effect manager *************************************************************************/ -static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr, +static void snd_emu10k1_write_op(struct snd_emu10k1_fx8010_code *icode, + unsigned int *ptr, u32 op, u32 r, u32 a, u32 x, u32 y) { u_int32_t *code; @@ -483,7 +487,8 @@ static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr #define OP(icode, ptr, op, r, a, x, y) \ snd_emu10k1_write_op(icode, ptr, op, r, a, x, y) -static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr, +static void snd_emu10k1_audigy_write_op(struct snd_emu10k1_fx8010_code *icode, + unsigned int *ptr, u32 op, u32 r, u32 a, u32 x, u32 y) { u_int32_t *code; @@ -498,19 +503,20 @@ static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned i #define A_OP(icode, ptr, op, r, a, x, y) \ snd_emu10k1_audigy_write_op(icode, ptr, op, r, a, x, y) -static void snd_emu10k1_efx_write(emu10k1_t *emu, unsigned int pc, unsigned int data) +static void snd_emu10k1_efx_write(struct snd_emu10k1 *emu, unsigned int pc, unsigned int data) { pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; snd_emu10k1_ptr_write(emu, pc, 0, data); } -unsigned int snd_emu10k1_efx_read(emu10k1_t *emu, unsigned int pc) +unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc) { pc += emu->audigy ? A_MICROCODEBASE : MICROCODEBASE; return snd_emu10k1_ptr_read(emu, pc, 0); } -static int snd_emu10k1_gpr_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int gpr; u32 val; @@ -525,7 +531,8 @@ static int snd_emu10k1_gpr_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_gpr_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_gpr_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int gpr; u32 val; @@ -539,7 +546,8 @@ static int snd_emu10k1_gpr_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_tram_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int tram; u32 addr, val; @@ -561,7 +569,8 @@ static int snd_emu10k1_tram_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_tram_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_tram_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int tram; u32 val, addr; @@ -583,7 +592,8 @@ static int snd_emu10k1_tram_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_code_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { u32 pc, lo, hi; @@ -599,7 +609,8 @@ static int snd_emu10k1_code_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static int snd_emu10k1_code_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { u32 pc; @@ -614,10 +625,11 @@ static int snd_emu10k1_code_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return 0; } -static snd_emu10k1_fx8010_ctl_t *snd_emu10k1_look_for_ctl(emu10k1_t *emu, snd_ctl_elem_id_t *id) +static struct snd_emu10k1_fx8010_ctl * +snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id) { - snd_emu10k1_fx8010_ctl_t *ctl; - snd_kcontrol_t *kcontrol; + struct snd_emu10k1_fx8010_ctl *ctl; + struct snd_kcontrol *kcontrol; struct list_head *list; list_for_each(list, &emu->fx8010.gpr_ctl) { @@ -631,13 +643,14 @@ static snd_emu10k1_fx8010_ctl_t *snd_emu10k1_look_for_ctl(emu10k1_t *emu, snd_ct return NULL; } -static int snd_emu10k1_verify_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { unsigned int i; - snd_ctl_elem_id_t __user *_id; - snd_ctl_elem_id_t id; - emu10k1_fx8010_control_gpr_t __user *_gctl; - emu10k1_fx8010_control_gpr_t *gctl; + struct snd_ctl_elem_id __user *_id; + struct snd_ctl_elem_id id; + struct snd_emu10k1_fx8010_control_gpr __user *_gctl; + struct snd_emu10k1_fx8010_control_gpr *gctl; int err; for (i = 0, _id = icode->gpr_del_controls; @@ -685,28 +698,29 @@ static int snd_emu10k1_verify_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *ic return err; } -static void snd_emu10k1_ctl_private_free(snd_kcontrol_t *kctl) +static void snd_emu10k1_ctl_private_free(struct snd_kcontrol *kctl) { - snd_emu10k1_fx8010_ctl_t *ctl; + struct snd_emu10k1_fx8010_ctl *ctl; - ctl = (snd_emu10k1_fx8010_ctl_t *)kctl->private_value; + ctl = (struct snd_emu10k1_fx8010_ctl *) kctl->private_value; kctl->private_value = 0; list_del(&ctl->list); kfree(ctl); } -static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { unsigned int i, j; - emu10k1_fx8010_control_gpr_t __user *_gctl; - emu10k1_fx8010_control_gpr_t *gctl; - snd_emu10k1_fx8010_ctl_t *ctl, *nctl; - snd_kcontrol_new_t knew; - snd_kcontrol_t *kctl; - snd_ctl_elem_value_t *val; + struct snd_emu10k1_fx8010_control_gpr __user *_gctl; + struct snd_emu10k1_fx8010_control_gpr *gctl; + struct snd_emu10k1_fx8010_ctl *ctl, *nctl; + struct snd_kcontrol_new knew; + struct snd_kcontrol *kctl; + struct snd_ctl_elem_value *val; int err = 0; - val = (snd_ctl_elem_value_t *)kmalloc(sizeof(*val), GFP_KERNEL); + val = kmalloc(sizeof(*val), GFP_KERNEL); gctl = kmalloc(sizeof(*gctl), GFP_KERNEL); nctl = kmalloc(sizeof(*nctl), GFP_KERNEL); if (!val || !gctl || !nctl) { @@ -751,7 +765,7 @@ static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode nctl->max = gctl->max; nctl->translation = gctl->translation; if (ctl == NULL) { - ctl = (snd_emu10k1_fx8010_ctl_t *)kmalloc(sizeof(*ctl), GFP_KERNEL); + ctl = kmalloc(sizeof(*ctl), GFP_KERNEL); if (ctl == NULL) { err = -ENOMEM; goto __error; @@ -782,13 +796,14 @@ static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode return err; } -static int snd_emu10k1_del_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { unsigned int i; - snd_ctl_elem_id_t id; - snd_ctl_elem_id_t __user *_id; - snd_emu10k1_fx8010_ctl_t *ctl; - snd_card_t *card = emu->card; + struct snd_ctl_elem_id id; + struct snd_ctl_elem_id __user *_id; + struct snd_emu10k1_fx8010_ctl *ctl; + struct snd_card *card = emu->card; for (i = 0, _id = icode->gpr_del_controls; i < icode->gpr_del_control_count; i++, _id++) { @@ -803,14 +818,15 @@ static int snd_emu10k1_del_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode return 0; } -static int snd_emu10k1_list_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { unsigned int i = 0, j; unsigned int total = 0; - emu10k1_fx8010_control_gpr_t *gctl; - emu10k1_fx8010_control_gpr_t __user *_gctl; - snd_emu10k1_fx8010_ctl_t *ctl; - snd_ctl_elem_id_t *id; + struct snd_emu10k1_fx8010_control_gpr *gctl; + struct snd_emu10k1_fx8010_control_gpr __user *_gctl; + struct snd_emu10k1_fx8010_ctl *ctl; + struct snd_ctl_elem_id *id; struct list_head *list; gctl = kmalloc(sizeof(*gctl), GFP_KERNEL); @@ -851,7 +867,8 @@ static int snd_emu10k1_list_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icod return 0; } -static int snd_emu10k1_icode_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_icode_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int err = 0; @@ -882,7 +899,8 @@ static int snd_emu10k1_icode_poke(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return err; } -static int snd_emu10k1_icode_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) +static int snd_emu10k1_icode_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_code *icode) { int err; @@ -900,11 +918,12 @@ static int snd_emu10k1_icode_peek(emu10k1_t *emu, emu10k1_fx8010_code_t *icode) return err; } -static int snd_emu10k1_ipcm_poke(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) +static int snd_emu10k1_ipcm_poke(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_pcm_rec *ipcm) { unsigned int i; int err = 0; - snd_emu10k1_fx8010_pcm_t *pcm; + struct snd_emu10k1_fx8010_pcm *pcm; if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) return -EINVAL; @@ -945,11 +964,12 @@ static int snd_emu10k1_ipcm_poke(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) return err; } -static int snd_emu10k1_ipcm_peek(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) +static int snd_emu10k1_ipcm_peek(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_pcm_rec *ipcm) { unsigned int i; int err = 0; - snd_emu10k1_fx8010_pcm_t *pcm; + struct snd_emu10k1_fx8010_pcm *pcm; if (ipcm->substream >= EMU10K1_FX8010_PCM_COUNT) return -EINVAL; @@ -979,7 +999,9 @@ static int snd_emu10k1_ipcm_peek(emu10k1_t *emu, emu10k1_fx8010_pcm_t *ipcm) #define SND_EMU10K1_PLAYBACK_CHANNELS 8 #define SND_EMU10K1_CAPTURE_CHANNELS 4 -static void __devinit snd_emu10k1_init_mono_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) +static void __devinit +snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl, + const char *name, int gpr, int defval) { ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(ctl->id.name, name); @@ -990,7 +1012,9 @@ static void __devinit snd_emu10k1_init_mono_control(emu10k1_fx8010_control_gpr_t ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; } -static void __devinit snd_emu10k1_init_stereo_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) +static void __devinit +snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl, + const char *name, int gpr, int defval) { ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(ctl->id.name, name); @@ -1002,7 +1026,9 @@ static void __devinit snd_emu10k1_init_stereo_control(emu10k1_fx8010_control_gpr ctl->translation = EMU10K1_GPR_TRANSLATION_TABLE100; } -static void __devinit snd_emu10k1_init_mono_onoff_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) +static void __devinit +snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, + const char *name, int gpr, int defval) { ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(ctl->id.name, name); @@ -1013,7 +1039,9 @@ static void __devinit snd_emu10k1_init_mono_onoff_control(emu10k1_fx8010_control ctl->translation = EMU10K1_GPR_TRANSLATION_ONOFF; } -static void __devinit snd_emu10k1_init_stereo_onoff_control(emu10k1_fx8010_control_gpr_t *ctl, const char *name, int gpr, int defval) +static void __devinit +snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, + const char *name, int gpr, int defval) { ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(ctl->id.name, name); @@ -1030,7 +1058,7 @@ static void __devinit snd_emu10k1_init_stereo_onoff_control(emu10k1_fx8010_contr * initial DSP configuration for Audigy */ -static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) +static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) { int err, i, z, gpr, nctl; const int playback = 10; @@ -1038,8 +1066,8 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) const int stereo_mix = capture + 2; const int tmp = 0x88; u32 ptr; - emu10k1_fx8010_code_t *icode = NULL; - emu10k1_fx8010_control_gpr_t *controls = NULL, *ctl; + struct snd_emu10k1_fx8010_code *icode = NULL; + struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl; u32 *gpr_map; mm_segment_t seg; @@ -1047,8 +1075,11 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu) INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || - (icode->gpr_map = (u_int32_t __user *)kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), GFP_KERNEL)) == NULL || - (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(*controls), GFP_KERNEL)) == NULL) { + (icode->gpr_map = (u_int32_t __user *) + kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), + GFP_KERNEL)) == NULL || + (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, + sizeof(*controls), GFP_KERNEL)) == NULL) { err = -ENOMEM; goto __err; } @@ -1434,7 +1465,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) seg = snd_enter_user(); icode->gpr_add_control_count = nctl; - icode->gpr_add_controls = (emu10k1_fx8010_control_gpr_t __user *)controls; + icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; err = snd_emu10k1_icode_poke(emu, icode); snd_leave_user(seg); @@ -1454,14 +1485,14 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) /* when volume = max, then copy only to avoid volume modification */ /* with iMAC0 (negative values) */ -static void __devinit _volume(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol) +static void __devinit _volume(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) { OP(icode, ptr, iMAC0, dst, C_00000000, src, vol); OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000001); OP(icode, ptr, iACC3, dst, src, C_00000000, C_00000000); } -static void __devinit _volume_add(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol) +static void __devinit _volume_add(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) { OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000002); @@ -1469,7 +1500,7 @@ static void __devinit _volume_add(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 ds OP(icode, ptr, iSKIP, C_00000000, C_7fffffff, C_7fffffff, C_00000001); OP(icode, ptr, iMAC0, dst, dst, src, vol); } -static void __devinit _volume_out(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 dst, u32 src, u32 vol) +static void __devinit _volume_out(struct snd_emu10k1_fx8010_code *icode, u32 *ptr, u32 dst, u32 src, u32 vol) { OP(icode, ptr, iANDXOR, C_00000000, vol, C_ffffffff, C_7fffffff); OP(icode, ptr, iSKIP, GPR_COND, GPR_COND, CC_REG_NONZERO, C_00000002); @@ -1500,13 +1531,13 @@ static void __devinit _volume_out(emu10k1_fx8010_code_t *icode, u32 *ptr, u32 ds _SWITCH_NEG(icode, ptr, GPR(dst), GPR(src)) -static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) +static int __devinit _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) { int err, i, z, gpr, tmp, playback, capture; u32 ptr; - emu10k1_fx8010_code_t *icode; - emu10k1_fx8010_pcm_t *ipcm = NULL; - emu10k1_fx8010_control_gpr_t *controls = NULL, *ctl; + struct snd_emu10k1_fx8010_code *icode; + struct snd_emu10k1_fx8010_pcm_rec *ipcm = NULL; + struct snd_emu10k1_fx8010_control_gpr *controls = NULL, *ctl; u32 *gpr_map; mm_segment_t seg; @@ -1515,8 +1546,12 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) return -ENOMEM; - if ((icode->gpr_map = (u_int32_t __user *)kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), GFP_KERNEL)) == NULL || - (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, sizeof(emu10k1_fx8010_control_gpr_t), GFP_KERNEL)) == NULL || + if ((icode->gpr_map = (u_int32_t __user *) + kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), + GFP_KERNEL)) == NULL || + (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, + sizeof(struct snd_emu10k1_fx8010_control_gpr), + GFP_KERNEL)) == NULL || (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { err = -ENOMEM; goto __err; @@ -2050,7 +2085,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) goto __err; seg = snd_enter_user(); icode->gpr_add_control_count = i; - icode->gpr_add_controls = (emu10k1_fx8010_control_gpr_t __user *)controls; + icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; err = snd_emu10k1_icode_poke(emu, icode); snd_leave_user(seg); if (err >= 0) @@ -2065,7 +2100,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu) return err; } -int __devinit snd_emu10k1_init_efx(emu10k1_t *emu) +int __devinit snd_emu10k1_init_efx(struct snd_emu10k1 *emu) { if (emu->audigy) return _snd_emu10k1_audigy_init_efx(emu); @@ -2073,7 +2108,7 @@ int __devinit snd_emu10k1_init_efx(emu10k1_t *emu) return _snd_emu10k1_init_efx(emu); } -void snd_emu10k1_free_efx(emu10k1_t *emu) +void snd_emu10k1_free_efx(struct snd_emu10k1 *emu) { /* stop processor */ if (emu->audigy) @@ -2083,7 +2118,7 @@ void snd_emu10k1_free_efx(emu10k1_t *emu) } #if 0 // FIXME: who use them? -int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output) +int snd_emu10k1_fx8010_tone_control_activate(struct snd_emu10k1 *emu, int output) { if (output < 0 || output >= 6) return -EINVAL; @@ -2091,7 +2126,7 @@ int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output) return 0; } -int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output) +int snd_emu10k1_fx8010_tone_control_deactivate(struct snd_emu10k1 *emu, int output) { if (output < 0 || output >= 6) return -EINVAL; @@ -2100,7 +2135,7 @@ int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output) } #endif -int snd_emu10k1_fx8010_tram_setup(emu10k1_t *emu, u32 size) +int snd_emu10k1_fx8010_tram_setup(struct snd_emu10k1 *emu, u32 size) { u8 size_reg = 0; @@ -2142,7 +2177,7 @@ int snd_emu10k1_fx8010_tram_setup(emu10k1_t *emu, u32 size) return 0; } -static int snd_emu10k1_fx8010_open(snd_hwdep_t * hw, struct file *file) +static int snd_emu10k1_fx8010_open(struct snd_hwdep * hw, struct file *file) { return 0; } @@ -2155,7 +2190,8 @@ static void copy_string(char *dst, char *src, char *null, int idx) strcpy(dst, src); } -static int snd_emu10k1_fx8010_info(emu10k1_t *emu, emu10k1_fx8010_info_t *info) +static int snd_emu10k1_fx8010_info(struct snd_emu10k1 *emu, + struct snd_emu10k1_fx8010_info *info) { char **fxbus, **extin, **extout; unsigned short fxbus_mask, extin_mask, extout_mask; @@ -2181,19 +2217,19 @@ static int snd_emu10k1_fx8010_info(emu10k1_t *emu, emu10k1_fx8010_info_t *info) return 0; } -static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigned int cmd, unsigned long arg) +static int snd_emu10k1_fx8010_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) { - emu10k1_t *emu = hw->private_data; - emu10k1_fx8010_info_t *info; - emu10k1_fx8010_code_t *icode; - emu10k1_fx8010_pcm_t *ipcm; + struct snd_emu10k1 *emu = hw->private_data; + struct snd_emu10k1_fx8010_info *info; + struct snd_emu10k1_fx8010_code *icode; + struct snd_emu10k1_fx8010_pcm_rec *ipcm; unsigned int addr; void __user *argp = (void __user *)arg; int res; switch (cmd) { case SNDRV_EMU10K1_IOCTL_INFO: - info = (emu10k1_fx8010_info_t *)kmalloc(sizeof(*info), GFP_KERNEL); + info = kmalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; if ((res = snd_emu10k1_fx8010_info(emu, info)) < 0) { @@ -2209,7 +2245,7 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne case SNDRV_EMU10K1_IOCTL_CODE_POKE: if (!capable(CAP_SYS_ADMIN)) return -EPERM; - icode = (emu10k1_fx8010_code_t *)kmalloc(sizeof(*icode), GFP_KERNEL); + icode = kmalloc(sizeof(*icode), GFP_KERNEL); if (icode == NULL) return -ENOMEM; if (copy_from_user(icode, argp, sizeof(*icode))) { @@ -2220,7 +2256,7 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne kfree(icode); return res; case SNDRV_EMU10K1_IOCTL_CODE_PEEK: - icode = (emu10k1_fx8010_code_t *)kmalloc(sizeof(*icode), GFP_KERNEL); + icode = kmalloc(sizeof(*icode), GFP_KERNEL); if (icode == NULL) return -ENOMEM; if (copy_from_user(icode, argp, sizeof(*icode))) { @@ -2235,7 +2271,7 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne kfree(icode); return res; case SNDRV_EMU10K1_IOCTL_PCM_POKE: - ipcm = (emu10k1_fx8010_pcm_t *)kmalloc(sizeof(*ipcm), GFP_KERNEL); + ipcm = kmalloc(sizeof(*ipcm), GFP_KERNEL); if (ipcm == NULL) return -ENOMEM; if (copy_from_user(ipcm, argp, sizeof(*ipcm))) { @@ -2327,14 +2363,14 @@ static int snd_emu10k1_fx8010_ioctl(snd_hwdep_t * hw, struct file *file, unsigne return -ENOTTY; } -static int snd_emu10k1_fx8010_release(snd_hwdep_t * hw, struct file *file) +static int snd_emu10k1_fx8010_release(struct snd_hwdep * hw, struct file *file) { return 0; } -int __devinit snd_emu10k1_fx8010_new(emu10k1_t *emu, int device, snd_hwdep_t ** rhwdep) +int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep ** rhwdep) { - snd_hwdep_t *hw; + struct snd_hwdep *hw; int err; if (rhwdep) diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 7cc831c..98fb813 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -35,17 +35,17 @@ #define AC97_ID_STAC9758 0x83847658 -static int snd_emu10k1_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_emu10k1_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned long flags; @@ -58,8 +58,8 @@ static int snd_emu10k1_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_spdif_get_mask(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_spdif_get_mask(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -69,7 +69,7 @@ static int snd_emu10k1_spdif_get_mask(snd_kcontrol_t * kcontrol, } #if 0 -static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_audigy_spdif_output_rate_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"44100", "48000", "96000"}; @@ -82,10 +82,10 @@ static int snd_audigy_spdif_output_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_audigy_spdif_output_rate_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_audigy_spdif_output_rate_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int tmp; unsigned long flags; @@ -109,10 +109,10 @@ static int snd_audigy_spdif_output_rate_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_audigy_spdif_output_rate_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_audigy_spdif_output_rate_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int change; unsigned int reg, val, tmp; unsigned long flags; @@ -143,7 +143,7 @@ static int snd_audigy_spdif_output_rate_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_audigy_spdif_output_rate = +static struct snd_kcontrol_new snd_audigy_spdif_output_rate = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -155,10 +155,10 @@ static snd_kcontrol_new_t snd_audigy_spdif_output_rate = }; #endif -static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); int change; unsigned int val; @@ -178,7 +178,7 @@ static int snd_emu10k1_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_spdif_mask_control = +static struct snd_kcontrol_new snd_emu10k1_spdif_mask_control = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -188,7 +188,7 @@ static snd_kcontrol_new_t snd_emu10k1_spdif_mask_control = .get = snd_emu10k1_spdif_get_mask }; -static snd_kcontrol_new_t snd_emu10k1_spdif_control = +static struct snd_kcontrol_new snd_emu10k1_spdif_control = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -199,7 +199,7 @@ static snd_kcontrol_new_t snd_emu10k1_spdif_control = }; -static void update_emu10k1_fxrt(emu10k1_t *emu, int voice, unsigned char *route) +static void update_emu10k1_fxrt(struct snd_emu10k1 *emu, int voice, unsigned char *route) { if (emu->audigy) { snd_emu10k1_ptr_write(emu, A_FXRT1, voice, @@ -212,7 +212,7 @@ static void update_emu10k1_fxrt(emu10k1_t *emu, int voice, unsigned char *route) } } -static void update_emu10k1_send_volume(emu10k1_t *emu, int voice, unsigned char *volume) +static void update_emu10k1_send_volume(struct snd_emu10k1 *emu, int voice, unsigned char *volume) { snd_emu10k1_ptr_write(emu, PTRX_FXSENDAMOUNT_A, voice, volume[0]); snd_emu10k1_ptr_write(emu, PTRX_FXSENDAMOUNT_B, voice, volume[1]); @@ -229,9 +229,9 @@ static void update_emu10k1_send_volume(emu10k1_t *emu, int voice, unsigned char /* PCM stream controls */ -static int snd_emu10k1_send_routing_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = emu->audigy ? 3*8 : 3*4; uinfo->value.integer.min = 0; @@ -239,12 +239,13 @@ static int snd_emu10k1_send_routing_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_emu10k1_send_routing_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_send_routing_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int voice, idx; int num_efx = emu->audigy ? 8 : 4; int mask = emu->audigy ? 0x3f : 0x0f; @@ -258,12 +259,13 @@ static int snd_emu10k1_send_routing_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_send_routing_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_send_routing_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int change = 0, voice, idx, val; int num_efx = emu->audigy ? 8 : 4; int mask = emu->audigy ? 0x3f : 0x0f; @@ -292,7 +294,7 @@ static int snd_emu10k1_send_routing_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_send_routing_control = +static struct snd_kcontrol_new snd_emu10k1_send_routing_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -303,9 +305,9 @@ static snd_kcontrol_new_t snd_emu10k1_send_routing_control = .put = snd_emu10k1_send_routing_put }; -static int snd_emu10k1_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = emu->audigy ? 3*8 : 3*4; uinfo->value.integer.min = 0; @@ -313,12 +315,13 @@ static int snd_emu10k1_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_emu10k1_send_volume_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_send_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int idx; int num_efx = emu->audigy ? 8 : 4; @@ -329,12 +332,13 @@ static int snd_emu10k1_send_volume_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_send_volume_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_send_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int change = 0, idx, val; int num_efx = emu->audigy ? 8 : 4; @@ -361,7 +365,7 @@ static int snd_emu10k1_send_volume_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_send_volume_control = +static struct snd_kcontrol_new snd_emu10k1_send_volume_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -372,7 +376,7 @@ static snd_kcontrol_new_t snd_emu10k1_send_volume_control = .put = snd_emu10k1_send_volume_put }; -static int snd_emu10k1_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 3; @@ -381,11 +385,12 @@ static int snd_emu10k1_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_emu10k1_attn_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_attn_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; unsigned long flags; int idx; @@ -396,12 +401,13 @@ static int snd_emu10k1_attn_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_attn_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_attn_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int change = 0, idx, val; spin_lock_irqsave(&emu->reg_lock, flags); @@ -424,7 +430,7 @@ static int snd_emu10k1_attn_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_attn_control = +static struct snd_kcontrol_new snd_emu10k1_attn_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -437,9 +443,9 @@ static snd_kcontrol_new_t snd_emu10k1_attn_control = /* Mutichannel PCM stream controls */ -static int snd_emu10k1_efx_send_routing_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_efx_send_routing_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = emu->audigy ? 8 : 4; uinfo->value.integer.min = 0; @@ -447,12 +453,13 @@ static int snd_emu10k1_efx_send_routing_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_emu10k1_efx_send_routing_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_send_routing_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int idx; int num_efx = emu->audigy ? 8 : 4; int mask = emu->audigy ? 0x3f : 0x0f; @@ -465,13 +472,13 @@ static int snd_emu10k1_efx_send_routing_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_efx_send_routing_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_send_routing_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[ch]; + struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; int change = 0, idx, val; int num_efx = emu->audigy ? 8 : 4; int mask = emu->audigy ? 0x3f : 0x0f; @@ -495,7 +502,7 @@ static int snd_emu10k1_efx_send_routing_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_efx_send_routing_control = +static struct snd_kcontrol_new snd_emu10k1_efx_send_routing_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -506,9 +513,9 @@ static snd_kcontrol_new_t snd_emu10k1_efx_send_routing_control = .put = snd_emu10k1_efx_send_routing_put }; -static int snd_emu10k1_efx_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_efx_send_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = emu->audigy ? 8 : 4; uinfo->value.integer.min = 0; @@ -516,12 +523,13 @@ static int snd_emu10k1_efx_send_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_emu10k1_efx_send_volume_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_send_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; int idx; int num_efx = emu->audigy ? 8 : 4; @@ -532,13 +540,13 @@ static int snd_emu10k1_efx_send_volume_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_efx_send_volume_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_send_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[ch]; + struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; int change = 0, idx, val; int num_efx = emu->audigy ? 8 : 4; @@ -561,7 +569,7 @@ static int snd_emu10k1_efx_send_volume_put(snd_kcontrol_t * kcontrol, } -static snd_kcontrol_new_t snd_emu10k1_efx_send_volume_control = +static struct snd_kcontrol_new snd_emu10k1_efx_send_volume_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -572,7 +580,7 @@ static snd_kcontrol_new_t snd_emu10k1_efx_send_volume_control = .put = snd_emu10k1_efx_send_volume_put }; -static int snd_emu10k1_efx_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_efx_attn_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -581,11 +589,12 @@ static int snd_emu10k1_efx_attn_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_emu10k1_efx_attn_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_attn_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1_pcm_mixer *mix = + &emu->efx_pcm_mixer[snd_ctl_get_ioffidx(kcontrol, &ucontrol->id)]; unsigned long flags; spin_lock_irqsave(&emu->reg_lock, flags); @@ -594,13 +603,13 @@ static int snd_emu10k1_efx_attn_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_efx_attn_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_efx_attn_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int ch = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - emu10k1_pcm_mixer_t *mix = &emu->efx_pcm_mixer[ch]; + struct snd_emu10k1_pcm_mixer *mix = &emu->efx_pcm_mixer[ch]; int change = 0, val; spin_lock_irqsave(&emu->reg_lock, flags); @@ -618,7 +627,7 @@ static int snd_emu10k1_efx_attn_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_efx_attn_control = +static struct snd_kcontrol_new snd_emu10k1_efx_attn_control = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -629,7 +638,7 @@ static snd_kcontrol_new_t snd_emu10k1_efx_attn_control = .put = snd_emu10k1_efx_attn_put }; -static int snd_emu10k1_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -638,10 +647,10 @@ static int snd_emu10k1_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_emu10k1_shared_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_shared_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); if (emu->audigy) ucontrol->value.integer.value[0] = inl(emu->port + A_IOCFG) & A_IOCFG_GPOUT0 ? 1 : 0; @@ -650,11 +659,11 @@ static int snd_emu10k1_shared_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1_shared_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_shared_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { unsigned long flags; - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int reg, val; int change = 0; @@ -681,7 +690,7 @@ static int snd_emu10k1_shared_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1_shared_spdif __devinitdata = +static struct snd_kcontrol_new snd_emu10k1_shared_spdif __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "SB Live Analog/Digital Output Jack", @@ -690,7 +699,7 @@ static snd_kcontrol_new_t snd_emu10k1_shared_spdif __devinitdata = .put = snd_emu10k1_shared_spdif_put }; -static snd_kcontrol_new_t snd_audigy_shared_spdif __devinitdata = +static struct snd_kcontrol_new snd_audigy_shared_spdif __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Audigy Analog/Digital Output Jack", @@ -701,35 +710,35 @@ static snd_kcontrol_new_t snd_audigy_shared_spdif __devinitdata = /* */ -static void snd_emu10k1_mixer_free_ac97(ac97_t *ac97) +static void snd_emu10k1_mixer_free_ac97(struct snd_ac97 *ac97) { - emu10k1_t *emu = ac97->private_data; + struct snd_emu10k1 *emu = ac97->private_data; emu->ac97 = NULL; } /* */ -static int remove_ctl(snd_card_t *card, const char *name) +static int remove_ctl(struct snd_card *card, const char *name) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; memset(&id, 0, sizeof(id)); strcpy(id.name, name); id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; return snd_ctl_remove_id(card, &id); } -static snd_kcontrol_t *ctl_find(snd_card_t *card, const char *name) +static struct snd_kcontrol *ctl_find(struct snd_card *card, const char *name) { - snd_ctl_elem_id_t sid; + struct snd_ctl_elem_id sid; memset(&sid, 0, sizeof(sid)); strcpy(sid.name, name); sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; return snd_ctl_find_id(card, &sid); } -static int rename_ctl(snd_card_t *card, const char *src, const char *dst) +static int rename_ctl(struct snd_card *card, const char *src, const char *dst) { - snd_kcontrol_t *kctl = ctl_find(card, src); + struct snd_kcontrol *kctl = ctl_find(card, src); if (kctl) { strcpy(kctl->id.name, dst); return 0; @@ -737,12 +746,12 @@ static int rename_ctl(snd_card_t *card, const char *src, const char *dst) return -ENOENT; } -int __devinit snd_emu10k1_mixer(emu10k1_t *emu, +int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu, int pcm_device, int multi_device) { int err, pcm; - snd_kcontrol_t *kctl; - snd_card_t *card = emu->card; + struct snd_kcontrol *kctl; + struct snd_card *card = emu->card; char **c; static char *emu10k1_remove_ctls[] = { /* no AC97 mono, surround, center/lfe */ @@ -795,9 +804,9 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu, }; if (emu->card_capabilities->ac97_chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; - static ac97_bus_ops_t ops = { + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; + static struct snd_ac97_bus_ops ops = { .write = snd_emu10k1_ac97_write, .read = snd_emu10k1_ac97_read, }; @@ -894,7 +903,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu, /* initialize the routing and volume table for each pcm playback stream */ for (pcm = 0; pcm < 32; pcm++) { - emu10k1_pcm_mixer_t *mix; + struct snd_emu10k1_pcm_mixer *mix; int v; mix = &emu->pcm_mixer[pcm]; @@ -914,7 +923,7 @@ int __devinit snd_emu10k1_mixer(emu10k1_t *emu, /* initialize the routing and volume table for the multichannel playback stream */ for (pcm = 0; pcm < NUM_EFX_PLAYBACK; pcm++) { - emu10k1_pcm_mixer_t *mix; + struct snd_emu10k1_pcm_mixer *mix; int v; mix = &emu->efx_pcm_mixer[pcm]; diff --git a/sound/pci/emu10k1/emumpu401.c b/sound/pci/emu10k1/emumpu401.c index eb57458..d96eb45 100644 --- a/sound/pci/emu10k1/emumpu401.c +++ b/sound/pci/emu10k1/emumpu401.c @@ -28,7 +28,8 @@ #define EMU10K1_MIDI_MODE_INPUT (1<<0) #define EMU10K1_MIDI_MODE_OUTPUT (1<<1) -static inline unsigned char mpu401_read(emu10k1_t *emu, emu10k1_midi_t *mpu, int idx) +static inline unsigned char mpu401_read(struct snd_emu10k1 *emu, + struct snd_emu10k1_midi *mpu, int idx) { if (emu->audigy) return (unsigned char)snd_emu10k1_ptr_read(emu, mpu->port + idx, 0); @@ -36,7 +37,8 @@ static inline unsigned char mpu401_read(emu10k1_t *emu, emu10k1_midi_t *mpu, int return inb(emu->port + mpu->port + idx); } -static inline void mpu401_write(emu10k1_t *emu, emu10k1_midi_t *mpu, int data, int idx) +static inline void mpu401_write(struct snd_emu10k1 *emu, + struct snd_emu10k1_midi *mpu, int data, int idx) { if (emu->audigy) snd_emu10k1_ptr_write(emu, mpu->port + idx, 0, data); @@ -56,7 +58,7 @@ static inline void mpu401_write(emu10k1_t *emu, emu10k1_midi_t *mpu, int data, i #define MPU401_ENTER_UART 0x3f #define MPU401_ACK 0xfe -static void mpu401_clear_rx(emu10k1_t *emu, emu10k1_midi_t *mpu) +static void mpu401_clear_rx(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *mpu) { int timeout = 100000; for (; timeout > 0 && mpu401_input_avail(emu, mpu); timeout--) @@ -71,7 +73,7 @@ static void mpu401_clear_rx(emu10k1_t *emu, emu10k1_midi_t *mpu) */ -static void do_emu10k1_midi_interrupt(emu10k1_t *emu, emu10k1_midi_t *midi, unsigned int status) +static void do_emu10k1_midi_interrupt(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, unsigned int status) { unsigned char byte; @@ -104,17 +106,17 @@ static void do_emu10k1_midi_interrupt(emu10k1_t *emu, emu10k1_midi_t *midi, unsi spin_unlock(&midi->output_lock); } -static void snd_emu10k1_midi_interrupt(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_midi_interrupt(struct snd_emu10k1 *emu, unsigned int status) { do_emu10k1_midi_interrupt(emu, &emu->midi, status); } -static void snd_emu10k1_midi_interrupt2(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_midi_interrupt2(struct snd_emu10k1 *emu, unsigned int status) { do_emu10k1_midi_interrupt(emu, &emu->midi2, status); } -static void snd_emu10k1_midi_cmd(emu10k1_t * emu, emu10k1_midi_t *midi, unsigned char cmd, int ack) +static void snd_emu10k1_midi_cmd(struct snd_emu10k1 * emu, struct snd_emu10k1_midi *midi, unsigned char cmd, int ack) { unsigned long flags; int timeout, ok; @@ -146,10 +148,10 @@ static void snd_emu10k1_midi_cmd(emu10k1_t * emu, emu10k1_midi_t *midi, unsigned mpu401_read_data(emu, midi)); } -static int snd_emu10k1_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1_midi_input_open(struct snd_rawmidi_substream *substream) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -167,10 +169,10 @@ static int snd_emu10k1_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1_midi_output_open(struct snd_rawmidi_substream *substream) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -188,10 +190,10 @@ static int snd_emu10k1_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1_midi_input_close(struct snd_rawmidi_substream *substream) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -209,10 +211,10 @@ static int snd_emu10k1_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1_midi_output_close(struct snd_rawmidi_substream *substream) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -230,10 +232,10 @@ static int snd_emu10k1_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_emu10k1_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; emu = midi->emu; snd_assert(emu, return); @@ -243,10 +245,10 @@ static void snd_emu10k1_midi_input_trigger(snd_rawmidi_substream_t * substream, snd_emu10k1_intr_disable(emu, midi->rx_enable); } -static void snd_emu10k1_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1_t *emu; - emu10k1_midi_t *midi = (emu10k1_midi_t *)substream->rmidi->private_data; + struct snd_emu10k1 *emu; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -283,30 +285,30 @@ static void snd_emu10k1_midi_output_trigger(snd_rawmidi_substream_t * substream, */ -static snd_rawmidi_ops_t snd_emu10k1_midi_output = +static struct snd_rawmidi_ops snd_emu10k1_midi_output = { .open = snd_emu10k1_midi_output_open, .close = snd_emu10k1_midi_output_close, .trigger = snd_emu10k1_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_emu10k1_midi_input = +static struct snd_rawmidi_ops snd_emu10k1_midi_input = { .open = snd_emu10k1_midi_input_open, .close = snd_emu10k1_midi_input_close, .trigger = snd_emu10k1_midi_input_trigger, }; -static void snd_emu10k1_midi_free(snd_rawmidi_t *rmidi) +static void snd_emu10k1_midi_free(struct snd_rawmidi *rmidi) { - emu10k1_midi_t *midi = (emu10k1_midi_t *)rmidi->private_data; + struct snd_emu10k1_midi *midi = (struct snd_emu10k1_midi *)rmidi->private_data; midi->interrupt = NULL; midi->rmidi = NULL; } -static int __devinit emu10k1_midi_init(emu10k1_t *emu, emu10k1_midi_t *midi, int device, char *name) +static int __devinit emu10k1_midi_init(struct snd_emu10k1 *emu, struct snd_emu10k1_midi *midi, int device, char *name) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if ((err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi)) < 0) @@ -327,9 +329,9 @@ static int __devinit emu10k1_midi_init(emu10k1_t *emu, emu10k1_midi_t *midi, int return 0; } -int __devinit snd_emu10k1_midi(emu10k1_t *emu) +int __devinit snd_emu10k1_midi(struct snd_emu10k1 *emu) { - emu10k1_midi_t *midi = &emu->midi; + struct snd_emu10k1_midi *midi = &emu->midi; int err; if ((err = emu10k1_midi_init(emu, midi, 0, "EMU10K1 MPU-401 (UART)")) < 0) @@ -344,9 +346,9 @@ int __devinit snd_emu10k1_midi(emu10k1_t *emu) return 0; } -int __devinit snd_emu10k1_audigy_midi(emu10k1_t *emu) +int __devinit snd_emu10k1_audigy_midi(struct snd_emu10k1 *emu) { - emu10k1_midi_t *midi; + struct snd_emu10k1_midi *midi; int err; midi = &emu->midi; diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 166f7c4..8e6caf5 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -35,9 +35,10 @@ #include <sound/core.h> #include <sound/emu10k1.h> -static void snd_emu10k1_pcm_interrupt(emu10k1_t *emu, emu10k1_voice_t *voice) +static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1 *emu, + struct snd_emu10k1_voice *voice) { - emu10k1_pcm_t *epcm; + struct snd_emu10k1_pcm *epcm; if ((epcm = voice->epcm) == NULL) return; @@ -52,7 +53,8 @@ static void snd_emu10k1_pcm_interrupt(emu10k1_t *emu, emu10k1_voice_t *voice) snd_pcm_period_elapsed(epcm->substream); } -static void snd_emu10k1_pcm_ac97adc_interrupt(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_pcm_ac97adc_interrupt(struct snd_emu10k1 *emu, + unsigned int status) { #if 0 if (status & IPR_ADCBUFHALFFULL) { @@ -63,7 +65,8 @@ static void snd_emu10k1_pcm_ac97adc_interrupt(emu10k1_t *emu, unsigned int statu snd_pcm_period_elapsed(emu->pcm_capture_substream); } -static void snd_emu10k1_pcm_ac97mic_interrupt(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_pcm_ac97mic_interrupt(struct snd_emu10k1 *emu, + unsigned int status) { #if 0 if (status & IPR_MICBUFHALFFULL) { @@ -74,7 +77,8 @@ static void snd_emu10k1_pcm_ac97mic_interrupt(emu10k1_t *emu, unsigned int statu snd_pcm_period_elapsed(emu->pcm_capture_mic_substream); } -static void snd_emu10k1_pcm_efx_interrupt(emu10k1_t *emu, unsigned int status) +static void snd_emu10k1_pcm_efx_interrupt(struct snd_emu10k1 *emu, + unsigned int status) { #if 0 if (status & IPR_EFXBUFHALFFULL) { @@ -85,11 +89,11 @@ static void snd_emu10k1_pcm_efx_interrupt(emu10k1_t *emu, unsigned int status) snd_pcm_period_elapsed(emu->pcm_capture_efx_substream); } -static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) @@ -102,7 +106,7 @@ static snd_pcm_uframes_t snd_emu10k1_efx_playback_pointer(snd_pcm_substream_t * return ptr; } -static int snd_emu10k1_pcm_channel_alloc(emu10k1_pcm_t * epcm, int voices) +static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm * epcm, int voices) { int err, i; @@ -167,7 +171,7 @@ static unsigned int capture_period_sizes[31] = { 384*128,448*128,512*128 }; -static snd_pcm_hw_constraint_list_t hw_constraints_capture_period_sizes = { +static struct snd_pcm_hw_constraint_list hw_constraints_capture_period_sizes = { .count = 31, .list = capture_period_sizes, .mask = 0 @@ -177,7 +181,7 @@ static unsigned int capture_rates[8] = { 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_capture_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_capture_rates = { .count = 8, .list = capture_rates, .mask = 0 @@ -271,15 +275,15 @@ static inline int emu10k1_ccis(int stereo, int w_16) } } -static void snd_emu10k1_pcm_init_voice(emu10k1_t *emu, +static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1 *emu, int master, int extra, - emu10k1_voice_t *evoice, + struct snd_emu10k1_voice *evoice, unsigned int start_addr, unsigned int end_addr, - emu10k1_pcm_mixer_t *mix) + struct snd_emu10k1_pcm_mixer *mix) { - snd_pcm_substream_t *substream = evoice->epcm->substream; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_substream *substream = evoice->epcm->substream; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int silent_page, tmp; int voice, stereo, w_16; unsigned char attn, send_amount[8]; @@ -392,12 +396,12 @@ static void snd_emu10k1_pcm_init_voice(emu10k1_t *emu, spin_unlock_irqrestore(&emu->reg_lock, flags); } -static int snd_emu10k1_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int err; if ((err = snd_emu10k1_pcm_channel_alloc(epcm, params_channels(hw_params))) < 0) @@ -412,7 +416,7 @@ static int snd_emu10k1_playback_hw_params(snd_pcm_substream_t * substream, epcm->start_addr = 0; if (! epcm->memblk) return -ENOMEM; - mapped = ((emu10k1_memblk_t *)epcm->memblk)->mapped_page; + mapped = ((struct snd_emu10k1_memblk *)epcm->memblk)->mapped_page; if (mapped < 0) return -ENOMEM; epcm->start_addr = mapped << PAGE_SHIFT; @@ -420,11 +424,11 @@ static int snd_emu10k1_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_emu10k1_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_emu10k1_playback_hw_free(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm; if (runtime->private_data == NULL) return 0; @@ -450,11 +454,11 @@ static int snd_emu10k1_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_efx_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_emu10k1_efx_playback_hw_free(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm; int i; if (runtime->private_data == NULL) @@ -479,11 +483,11 @@ static int snd_emu10k1_efx_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_playback_prepare(snd_pcm_substream_t * substream) +static int snd_emu10k1_playback_prepare(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int start_addr, end_addr; start_addr = epcm->start_addr; @@ -507,11 +511,11 @@ static int snd_emu10k1_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_efx_playback_prepare(snd_pcm_substream_t * substream) +static int snd_emu10k1_efx_playback_prepare(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int start_addr, end_addr; unsigned int channel_size; int i; @@ -543,7 +547,7 @@ static int snd_emu10k1_efx_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_hardware_t snd_emu10k1_efx_playback = +static struct snd_pcm_hardware snd_emu10k1_efx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_NONINTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -562,22 +566,22 @@ static snd_pcm_hardware_t snd_emu10k1_efx_playback = .fifo_size = 0, }; -static int snd_emu10k1_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_emu10k1_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_emu10k1_capture_prepare(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_prepare(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int idx; /* zeroing the buffer size will stop capture */ @@ -620,9 +624,9 @@ static int snd_emu10k1_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static void snd_emu10k1_playback_invalidate_cache(emu10k1_t *emu, int extra, emu10k1_voice_t *evoice) +static void snd_emu10k1_playback_invalidate_cache(struct snd_emu10k1 *emu, int extra, struct snd_emu10k1_voice *evoice) { - snd_pcm_runtime_t *runtime; + struct snd_pcm_runtime *runtime; unsigned int voice, stereo, i, ccis, cra = 64, cs, sample; if (evoice == NULL) @@ -655,12 +659,12 @@ static void snd_emu10k1_playback_invalidate_cache(emu10k1_t *emu, int extra, emu } } -static void snd_emu10k1_playback_prepare_voice(emu10k1_t *emu, emu10k1_voice_t *evoice, +static void snd_emu10k1_playback_prepare_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice, int master, int extra, - emu10k1_pcm_mixer_t *mix) + struct snd_emu10k1_pcm_mixer *mix) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; unsigned int attn, vattn; unsigned int voice, tmp; @@ -680,10 +684,10 @@ static void snd_emu10k1_playback_prepare_voice(emu10k1_t *emu, emu10k1_voice_t * snd_emu10k1_voice_clear_loop_stop(emu, voice); } -static void snd_emu10k1_playback_trigger_voice(emu10k1_t *emu, emu10k1_voice_t *evoice, int master, int extra) +static void snd_emu10k1_playback_trigger_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice, int master, int extra) { - snd_pcm_substream_t *substream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream; + struct snd_pcm_runtime *runtime; unsigned int voice, pitch, pitch_target; if (evoice == NULL) /* skip second voice for mono */ @@ -702,7 +706,7 @@ static void snd_emu10k1_playback_trigger_voice(emu10k1_t *emu, emu10k1_voice_t * snd_emu10k1_voice_intr_enable(emu, voice); } -static void snd_emu10k1_playback_stop_voice(emu10k1_t *emu, emu10k1_voice_t *evoice) +static void snd_emu10k1_playback_stop_voice(struct snd_emu10k1 *emu, struct snd_emu10k1_voice *evoice) { unsigned int voice; @@ -718,13 +722,13 @@ static void snd_emu10k1_playback_stop_voice(emu10k1_t *emu, emu10k1_voice_t *evo snd_emu10k1_ptr_write(emu, IP, voice, 0); } -static int snd_emu10k1_playback_trigger(snd_pcm_substream_t * substream, +static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; - emu10k1_pcm_mixer_t *mix; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; + struct snd_emu10k1_pcm_mixer *mix; int result = 0; // printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream)); @@ -759,12 +763,12 @@ static int snd_emu10k1_playback_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_emu10k1_capture_trigger(snd_pcm_substream_t * substream, +static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int result = 0; spin_lock(&emu->reg_lock); @@ -819,11 +823,11 @@ static int snd_emu10k1_capture_trigger(snd_pcm_substream_t * substream, return result; } -static snd_pcm_uframes_t snd_emu10k1_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_emu10k1_playback_pointer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) @@ -847,12 +851,12 @@ static snd_pcm_uframes_t snd_emu10k1_playback_pointer(snd_pcm_substream_t * subs } -static int snd_emu10k1_efx_playback_trigger(snd_pcm_substream_t * substream, +static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int i; int result = 0; @@ -896,11 +900,11 @@ static int snd_emu10k1_efx_playback_trigger(snd_pcm_substream_t * substream, } -static snd_pcm_uframes_t snd_emu10k1_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_emu10k1_capture_pointer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; unsigned int ptr; if (!epcm->running) @@ -917,7 +921,7 @@ static snd_pcm_uframes_t snd_emu10k1_capture_pointer(snd_pcm_substream_t * subst * Playback support device description */ -static snd_pcm_hardware_t snd_emu10k1_playback = +static struct snd_pcm_hardware snd_emu10k1_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -940,7 +944,7 @@ static snd_pcm_hardware_t snd_emu10k1_playback = * Capture support device description */ -static snd_pcm_hardware_t snd_emu10k1_capture = +static struct snd_pcm_hardware snd_emu10k1_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -963,9 +967,9 @@ static snd_pcm_hardware_t snd_emu10k1_capture = * */ -static void snd_emu10k1_pcm_mixer_notify1(emu10k1_t *emu, snd_kcontrol_t *kctl, int idx, int activate) +static void snd_emu10k1_pcm_mixer_notify1(struct snd_emu10k1 *emu, struct snd_kcontrol *kctl, int idx, int activate) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; if (! kctl) return; @@ -978,29 +982,29 @@ static void snd_emu10k1_pcm_mixer_notify1(emu10k1_t *emu, snd_kcontrol_t *kctl, snd_ctl_build_ioff(&id, kctl, idx)); } -static void snd_emu10k1_pcm_mixer_notify(emu10k1_t *emu, int idx, int activate) +static void snd_emu10k1_pcm_mixer_notify(struct snd_emu10k1 *emu, int idx, int activate) { snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_routing, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_send_volume, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_attn, idx, activate); } -static void snd_emu10k1_pcm_efx_mixer_notify(emu10k1_t *emu, int idx, int activate) +static void snd_emu10k1_pcm_efx_mixer_notify(struct snd_emu10k1 *emu, int idx, int activate) { snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_routing, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_send_volume, idx, activate); snd_emu10k1_pcm_mixer_notify1(emu, emu->ctl_efx_attn, idx, activate); } -static void snd_emu10k1_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_emu10k1_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_efx_playback_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_mixer_t *mix; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm_mixer *mix; int i; for (i=0; i < NUM_EFX_PLAYBACK; i++) { @@ -1011,12 +1015,12 @@ static int snd_emu10k1_efx_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_efx_playback_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_efx_playback_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_t *epcm; - emu10k1_pcm_mixer_t *mix; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm *epcm; + struct snd_emu10k1_pcm_mixer *mix; + struct snd_pcm_runtime *runtime = substream->runtime; int i; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -1044,12 +1048,12 @@ static int snd_emu10k1_efx_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_playback_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_playback_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_t *epcm; - emu10k1_pcm_mixer_t *mix; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm *epcm; + struct snd_emu10k1_pcm_mixer *mix; + struct snd_pcm_runtime *runtime = substream->runtime; int i, err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -1081,21 +1085,21 @@ static int snd_emu10k1_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_playback_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_playback_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_mixer_t *mix = &emu->pcm_mixer[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm_mixer *mix = &emu->pcm_mixer[substream->number]; mix->epcm = NULL; snd_emu10k1_pcm_mixer_notify(emu, substream->number, 0); return 0; } -static int snd_emu10k1_capture_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) @@ -1118,20 +1122,20 @@ static int snd_emu10k1_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_capture_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_substream = NULL; return 0; } -static int snd_emu10k1_capture_mic_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_mic_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); if (epcm == NULL) @@ -1156,20 +1160,20 @@ static int snd_emu10k1_capture_mic_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_capture_mic_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_mic_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_mic_substream = NULL; return 0; } -static int snd_emu10k1_capture_efx_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int nefx = emu->audigy ? 64 : 32; int idx; @@ -1206,16 +1210,16 @@ static int snd_emu10k1_capture_efx_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_capture_efx_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_capture_efx_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); emu->capture_interrupt = NULL; emu->pcm_capture_efx_substream = NULL; return 0; } -static snd_pcm_ops_t snd_emu10k1_playback_ops = { +static struct snd_pcm_ops snd_emu10k1_playback_ops = { .open = snd_emu10k1_playback_open, .close = snd_emu10k1_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1227,7 +1231,7 @@ static snd_pcm_ops_t snd_emu10k1_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static snd_pcm_ops_t snd_emu10k1_capture_ops = { +static struct snd_pcm_ops snd_emu10k1_capture_ops = { .open = snd_emu10k1_capture_open, .close = snd_emu10k1_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1239,7 +1243,7 @@ static snd_pcm_ops_t snd_emu10k1_capture_ops = { }; /* EFX playback */ -static snd_pcm_ops_t snd_emu10k1_efx_playback_ops = { +static struct snd_pcm_ops snd_emu10k1_efx_playback_ops = { .open = snd_emu10k1_efx_playback_open, .close = snd_emu10k1_efx_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1251,10 +1255,10 @@ static snd_pcm_ops_t snd_emu10k1_efx_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -int __devinit snd_emu10k1_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) +int __devinit snd_emu10k1_pcm(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; int err; if (rpcm) @@ -1286,10 +1290,10 @@ int __devinit snd_emu10k1_pcm(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) return 0; } -int __devinit snd_emu10k1_pcm_multi(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) +int __devinit snd_emu10k1_pcm_multi(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; int err; if (rpcm) @@ -1318,7 +1322,7 @@ int __devinit snd_emu10k1_pcm_multi(emu10k1_t * emu, int device, snd_pcm_t ** rp } -static snd_pcm_ops_t snd_emu10k1_capture_mic_ops = { +static struct snd_pcm_ops snd_emu10k1_capture_mic_ops = { .open = snd_emu10k1_capture_mic_open, .close = snd_emu10k1_capture_mic_close, .ioctl = snd_pcm_lib_ioctl, @@ -1329,9 +1333,9 @@ static snd_pcm_ops_t snd_emu10k1_capture_mic_ops = { .pointer = snd_emu10k1_capture_pointer, }; -int __devinit snd_emu10k1_pcm_mic(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) +int __devinit snd_emu10k1_pcm_mic(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1355,9 +1359,9 @@ int __devinit snd_emu10k1_pcm_mic(emu10k1_t * emu, int device, snd_pcm_t ** rpcm return 0; } -static int snd_emu10k1_pcm_efx_voices_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1_pcm_efx_voices_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int nefx = emu->audigy ? 64 : 32; uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = nefx; @@ -1366,9 +1370,9 @@ static int snd_emu10k1_pcm_efx_voices_mask_info(snd_kcontrol_t *kcontrol, snd_ct return 0; } -static int snd_emu10k1_pcm_efx_voices_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_pcm_efx_voices_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); int nefx = emu->audigy ? 64 : 32; int idx; @@ -1379,9 +1383,9 @@ static int snd_emu10k1_pcm_efx_voices_mask_get(snd_kcontrol_t * kcontrol, snd_ct return 0; } -static int snd_emu10k1_pcm_efx_voices_mask_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1_pcm_efx_voices_mask_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int nval[2], bits; int nefx = emu->audigy ? 64 : 32; int nefxb = emu->audigy ? 7 : 6; @@ -1410,7 +1414,7 @@ static int snd_emu10k1_pcm_efx_voices_mask_put(snd_kcontrol_t * kcontrol, snd_ct return change; } -static snd_kcontrol_new_t snd_emu10k1_pcm_efx_voices_mask = { +static struct snd_kcontrol_new snd_emu10k1_pcm_efx_voices_mask = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "Captured FX8010 Outputs", .info = snd_emu10k1_pcm_efx_voices_mask_info, @@ -1418,7 +1422,7 @@ static snd_kcontrol_new_t snd_emu10k1_pcm_efx_voices_mask = { .put = snd_emu10k1_pcm_efx_voices_mask_put }; -static snd_pcm_ops_t snd_emu10k1_capture_efx_ops = { +static struct snd_pcm_ops snd_emu10k1_capture_efx_ops = { .open = snd_emu10k1_capture_efx_open, .close = snd_emu10k1_capture_efx_close, .ioctl = snd_pcm_lib_ioctl, @@ -1435,9 +1439,9 @@ static snd_pcm_ops_t snd_emu10k1_capture_efx_ops = { #define INITIAL_TRAM_SHIFT 14 #define INITIAL_TRAM_POS(size) ((((size) / 2) - INITIAL_TRAM_SHIFT) - 1) -static void snd_emu10k1_fx8010_playback_irq(emu10k1_t *emu, void *private_data) +static void snd_emu10k1_fx8010_playback_irq(struct snd_emu10k1 *emu, void *private_data) { - snd_pcm_substream_t *substream = private_data; + struct snd_pcm_substream *substream = private_data; snd_pcm_period_elapsed(substream); } @@ -1461,11 +1465,11 @@ static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left, } } -static void fx8010_pb_trans_copy(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, size_t bytes) +static void fx8010_pb_trans_copy(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int tram_size = pcm->buffer_size; unsigned short *src = (unsigned short *)(substream->runtime->dma_area + rec->sw_data); unsigned int frames = bytes >> 2, count; @@ -1490,25 +1494,25 @@ static void fx8010_pb_trans_copy(snd_pcm_substream_t *substream, pcm->tram_shift = tram_shift; } -static int snd_emu10k1_fx8010_playback_transfer(snd_pcm_substream_t *substream) +static int snd_emu10k1_fx8010_playback_transfer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; snd_pcm_indirect_playback_transfer(substream, &pcm->pcm_rec, fx8010_pb_trans_copy); return 0; } -static int snd_emu10k1_fx8010_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1_fx8010_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_emu10k1_fx8010_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int i; for (i = 0; i < pcm->channels; i++) @@ -1517,11 +1521,11 @@ static int snd_emu10k1_fx8010_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_fx8010_playback_prepare(snd_pcm_substream_t * substream) +static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; unsigned int i; // printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2); @@ -1541,10 +1545,10 @@ static int snd_emu10k1_fx8010_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_fx8010_playback_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_emu10k1_fx8010_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; int result = 0; spin_lock(&emu->reg_lock); @@ -1586,10 +1590,10 @@ static int snd_emu10k1_fx8010_playback_trigger(snd_pcm_substream_t * substream, return result; } -static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; size_t ptr; /* byte pointer */ if (!snd_emu10k1_ptr_read(emu, emu->gpr_base + pcm->gpr_trigger, 0)) @@ -1598,7 +1602,7 @@ static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(snd_pcm_substream_t return snd_pcm_indirect_playback_pointer(substream, &pcm->pcm_rec, ptr); } -static snd_pcm_hardware_t snd_emu10k1_fx8010_playback = +static struct snd_pcm_hardware snd_emu10k1_fx8010_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE), @@ -1616,11 +1620,11 @@ static snd_pcm_hardware_t snd_emu10k1_fx8010_playback = .fifo_size = 0, }; -static int snd_emu10k1_fx8010_playback_open(snd_pcm_substream_t * substream) +static int snd_emu10k1_fx8010_playback_open(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; runtime->hw = snd_emu10k1_fx8010_playback; runtime->hw.channels_min = runtime->hw.channels_max = pcm->channels; @@ -1635,10 +1639,10 @@ static int snd_emu10k1_fx8010_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_emu10k1_fx8010_playback_close(snd_pcm_substream_t * substream) +static int snd_emu10k1_fx8010_playback_close(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_emu10k1_fx8010_pcm_t *pcm = &emu->fx8010.pcm[substream->number]; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_fx8010_pcm *pcm = &emu->fx8010.pcm[substream->number]; spin_lock_irq(&emu->reg_lock); pcm->opened = 0; @@ -1646,7 +1650,7 @@ static int snd_emu10k1_fx8010_playback_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_emu10k1_fx8010_playback_ops = { +static struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops = { .open = snd_emu10k1_fx8010_playback_open, .close = snd_emu10k1_fx8010_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1658,10 +1662,10 @@ static snd_pcm_ops_t snd_emu10k1_fx8010_playback_ops = { .ack = snd_emu10k1_fx8010_playback_transfer, }; -int __devinit snd_emu10k1_pcm_efx(emu10k1_t * emu, int device, snd_pcm_t ** rpcm) +int __devinit snd_emu10k1_pcm_efx(struct snd_emu10k1 * emu, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; - snd_kcontrol_t *kctl; + struct snd_pcm *pcm; + struct snd_kcontrol *kctl; int err; if (rpcm) diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index 6cdee58..b88137f 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c @@ -32,8 +32,8 @@ #include <sound/emu10k1.h> #include "p16v.h" -static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu, - snd_info_buffer_t * buffer, +static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu, + struct snd_info_buffer *buffer, char *title, int status_reg, int rate_reg) @@ -75,8 +75,8 @@ static void snd_emu10k1_proc_spdif_status(emu10k1_t * emu, } -static void snd_emu10k1_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { /* FIXME - output names are in emufx.c too */ static char *creative_outs[32] = { @@ -181,7 +181,7 @@ static void snd_emu10k1_proc_read(snd_info_entry_t *entry, /* 63 */ "FXBUS2_31" }; - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned int val, val1; int nefx = emu->audigy ? 64 : 32; char **outputs = emu->audigy ? audigy_outs : creative_outs; @@ -232,10 +232,10 @@ static void snd_emu10k1_proc_read(snd_info_entry_t *entry, snd_iprintf(buffer, " Output %02i [%s]\n", idx, outputs[idx]); } -static void snd_emu10k1_proc_spdif_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_spdif_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; snd_emu10k1_proc_spdif_status(emu, buffer, "CD-ROM S/PDIF In", CDCS, CDSRCS); snd_emu10k1_proc_spdif_status(emu, buffer, "Optical or Coax S/PDIF In", GPSCS, GPSRCS); #if 0 @@ -246,11 +246,11 @@ static void snd_emu10k1_proc_spdif_read(snd_info_entry_t *entry, #endif } -static void snd_emu10k1_proc_rates_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_rates_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { static int samplerate[8] = { 44100, 48000, 96000, 192000, 4, 5, 6, 7 }; - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned int val, tmp, n; val = snd_emu10k1_ptr20_read(emu, CAPTURE_RATE_STATUS, 0); tmp = (val >> 16) & 0x8; @@ -261,11 +261,11 @@ static void snd_emu10k1_proc_rates_read(snd_info_entry_t *entry, } } -static void snd_emu10k1_proc_acode_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_acode_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { u32 pc; - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; snd_iprintf(buffer, "FX8010 Instruction List '%s'\n", emu->fx8010.name); snd_iprintf(buffer, " Code dump :\n"); @@ -304,12 +304,13 @@ static void snd_emu10k1_proc_acode_read(snd_info_entry_t *entry, #define TOTAL_SIZE_CODE (0x200*8) #define A_TOTAL_SIZE_CODE (0x400*8) -static long snd_emu10k1_fx8010_read(snd_info_entry_t *entry, void *file_private_data, +static long snd_emu10k1_fx8010_read(struct snd_info_entry *entry, + void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { long size; - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned int offset; int tram_addr = 0; @@ -349,11 +350,11 @@ static long snd_emu10k1_fx8010_read(snd_info_entry_t *entry, void *file_private_ return 0; } -static void snd_emu10k1_proc_voices_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1_proc_voices_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1_t *emu = entry->private_data; - emu10k1_voice_t *voice; + struct snd_emu10k1 *emu = entry->private_data; + struct snd_emu10k1_voice *voice; int idx; snd_iprintf(buffer, "ch\tuse\tpcm\tefx\tsynth\tmidi\n"); @@ -370,10 +371,10 @@ static void snd_emu10k1_proc_voices_read(snd_info_entry_t *entry, } #ifdef CONFIG_SND_DEBUG -static void snd_emu_proc_io_reg_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_io_reg_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned long value; unsigned long flags; int i; @@ -386,10 +387,10 @@ static void snd_emu_proc_io_reg_read(snd_info_entry_t *entry, } } -static void snd_emu_proc_io_reg_write(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_io_reg_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned long flags; char line[64]; u32 reg, val; @@ -404,7 +405,7 @@ static void snd_emu_proc_io_reg_write(snd_info_entry_t *entry, } } -static unsigned int snd_ptr_read(emu10k1_t * emu, +static unsigned int snd_ptr_read(struct snd_emu10k1 * emu, unsigned int iobase, unsigned int reg, unsigned int chn) @@ -421,7 +422,7 @@ static unsigned int snd_ptr_read(emu10k1_t * emu, return val; } -static void snd_ptr_write(emu10k1_t *emu, +static void snd_ptr_write(struct snd_emu10k1 *emu, unsigned int iobase, unsigned int reg, unsigned int chn, @@ -439,10 +440,10 @@ static void snd_ptr_write(emu10k1_t *emu, } -static void snd_emu_proc_ptr_reg_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer, int iobase, int offset, int length, int voices) +static void snd_emu_proc_ptr_reg_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer, int iobase, int offset, int length, int voices) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; unsigned long value; int i,j; if (offset+length > 0xa0) { @@ -463,10 +464,10 @@ static void snd_emu_proc_ptr_reg_read(snd_info_entry_t *entry, } } -static void snd_emu_proc_ptr_reg_write(snd_info_entry_t *entry, - snd_info_buffer_t * buffer, int iobase) +static void snd_emu_proc_ptr_reg_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer, int iobase) { - emu10k1_t *emu = entry->private_data; + struct snd_emu10k1 *emu = entry->private_data; char line[64]; unsigned int reg, channel_id , val; while (!snd_info_get_line(buffer, line, sizeof(line))) { @@ -477,45 +478,45 @@ static void snd_emu_proc_ptr_reg_write(snd_info_entry_t *entry, } } -static void snd_emu_proc_ptr_reg_write00(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_write00(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_write(entry, buffer, 0); } -static void snd_emu_proc_ptr_reg_write20(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_write20(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_write(entry, buffer, 0x20); } -static void snd_emu_proc_ptr_reg_read00a(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read00a(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0, 0x40, 64); } -static void snd_emu_proc_ptr_reg_read00b(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read00b(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0, 0x40, 0x40, 64); } -static void snd_emu_proc_ptr_reg_read20a(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read20a(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0, 0x40, 4); } -static void snd_emu_proc_ptr_reg_read20b(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read20b(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x40, 0x40, 4); } -static void snd_emu_proc_ptr_reg_read20c(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu_proc_ptr_reg_read20c(struct snd_info_entry *entry, + struct snd_info_buffer * buffer) { snd_emu_proc_ptr_reg_read(entry, buffer, 0x20, 0x80, 0x20, 4); } @@ -525,9 +526,9 @@ static struct snd_info_entry_ops snd_emu10k1_proc_ops_fx8010 = { .read = snd_emu10k1_fx8010_read, }; -int __devinit snd_emu10k1_proc_init(emu10k1_t * emu) +int __devinit snd_emu10k1_proc_init(struct snd_emu10k1 * emu) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; #ifdef CONFIG_SND_DEBUG if (! snd_card_proc_new(emu->card, "io_regs", &entry)) { snd_info_set_text_ops(entry, emu, 1024, snd_emu_proc_io_reg_read); diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index b9d3ae0..5d116dd 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -30,7 +30,7 @@ #include <sound/core.h> #include <sound/emu10k1.h> -unsigned int snd_emu10k1_ptr_read(emu10k1_t * emu, unsigned int reg, unsigned int chn) +unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn) { unsigned long flags; unsigned int regptr, val; @@ -61,7 +61,7 @@ unsigned int snd_emu10k1_ptr_read(emu10k1_t * emu, unsigned int reg, unsigned in } } -void snd_emu10k1_ptr_write(emu10k1_t *emu, unsigned int reg, unsigned int chn, unsigned int data) +void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data) { unsigned int regptr; unsigned long flags; @@ -91,7 +91,7 @@ void snd_emu10k1_ptr_write(emu10k1_t *emu, unsigned int reg, unsigned int chn, u } } -unsigned int snd_emu10k1_ptr20_read(emu10k1_t * emu, +unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn) { @@ -107,7 +107,7 @@ unsigned int snd_emu10k1_ptr20_read(emu10k1_t * emu, return val; } -void snd_emu10k1_ptr20_write(emu10k1_t *emu, +void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data) @@ -123,7 +123,7 @@ void snd_emu10k1_ptr20_write(emu10k1_t *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_intr_enable(emu10k1_t *emu, unsigned int intrenb) +void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -134,7 +134,7 @@ void snd_emu10k1_intr_enable(emu10k1_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_intr_disable(emu10k1_t *emu, unsigned int intrenb) +void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -145,7 +145,7 @@ void snd_emu10k1_intr_disable(emu10k1_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_intr_enable(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_intr_enable(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int val; @@ -165,7 +165,7 @@ void snd_emu10k1_voice_intr_enable(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_intr_disable(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_intr_disable(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int val; @@ -185,7 +185,7 @@ void snd_emu10k1_voice_intr_disable(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_intr_ack(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_intr_ack(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; @@ -202,7 +202,7 @@ void snd_emu10k1_voice_intr_ack(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_half_loop_intr_enable(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_half_loop_intr_enable(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int val; @@ -222,7 +222,7 @@ void snd_emu10k1_voice_half_loop_intr_enable(emu10k1_t *emu, unsigned int voicen spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_half_loop_intr_disable(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_half_loop_intr_disable(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int val; @@ -242,7 +242,7 @@ void snd_emu10k1_voice_half_loop_intr_disable(emu10k1_t *emu, unsigned int voice spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_half_loop_intr_ack(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_half_loop_intr_ack(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; @@ -259,7 +259,7 @@ void snd_emu10k1_voice_half_loop_intr_ack(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_set_loop_stop(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_set_loop_stop(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int sol; @@ -279,7 +279,7 @@ void snd_emu10k1_voice_set_loop_stop(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_voice_clear_loop_stop(emu10k1_t *emu, unsigned int voicenum) +void snd_emu10k1_voice_clear_loop_stop(struct snd_emu10k1 *emu, unsigned int voicenum) { unsigned long flags; unsigned int sol; @@ -299,7 +299,7 @@ void snd_emu10k1_voice_clear_loop_stop(emu10k1_t *emu, unsigned int voicenum) spin_unlock_irqrestore(&emu->emu_lock, flags); } -void snd_emu10k1_wait(emu10k1_t *emu, unsigned int wait) +void snd_emu10k1_wait(struct snd_emu10k1 *emu, unsigned int wait) { volatile unsigned count; unsigned int newtime = 0, curtime; @@ -318,9 +318,9 @@ void snd_emu10k1_wait(emu10k1_t *emu, unsigned int wait) } } -unsigned short snd_emu10k1_ac97_read(ac97_t *ac97, unsigned short reg) +unsigned short snd_emu10k1_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - emu10k1_t *emu = ac97->private_data; + struct snd_emu10k1 *emu = ac97->private_data; unsigned long flags; unsigned short val; @@ -331,9 +331,9 @@ unsigned short snd_emu10k1_ac97_read(ac97_t *ac97, unsigned short reg) return val; } -void snd_emu10k1_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short data) +void snd_emu10k1_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short data) { - emu10k1_t *emu = ac97->private_data; + struct snd_emu10k1 *emu = ac97->private_data; unsigned long flags; spin_lock_irqsave(&emu->emu_lock, flags); diff --git a/sound/pci/emu10k1/irq.c b/sound/pci/emu10k1/irq.c index 594ea06..a8b3128 100644 --- a/sound/pci/emu10k1/irq.c +++ b/sound/pci/emu10k1/irq.c @@ -32,7 +32,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - emu10k1_t *emu = dev_id; + struct snd_emu10k1 *emu = dev_id; unsigned int status, status2, orig_status, orig_status2; int handled = 0; @@ -56,7 +56,7 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) int voice; int voice_max = status & IPR_CHANNELNUMBERMASK; u32 val; - emu10k1_voice_t *pvoice = emu->voices; + struct snd_emu10k1_voice *pvoice = emu->voices; val = snd_emu10k1_ptr_read(emu, CLIPL, 0); for (voice = 0; voice <= voice_max; voice++) { @@ -150,8 +150,8 @@ irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (status & IPR_P16V) { while ((status2 = inl(emu->port + IPR2)) != 0) { u32 mask = INTE2_PLAYBACK_CH_0_LOOP; /* Full Loop */ - emu10k1_voice_t *pvoice = &(emu->p16v_voices[0]); - emu10k1_voice_t *cvoice = &(emu->p16v_capture_voice); + struct snd_emu10k1_voice *pvoice = &(emu->p16v_voices[0]); + struct snd_emu10k1_voice *cvoice = &(emu->p16v_capture_voice); //printk(KERN_INFO "status2=0x%x\n", status2); orig_status2 = status2; diff --git a/sound/pci/emu10k1/memory.c b/sound/pci/emu10k1/memory.c index d42e4ae..68c795c 100644 --- a/sound/pci/emu10k1/memory.c +++ b/sound/pci/emu10k1/memory.c @@ -48,7 +48,7 @@ #define set_silent_ptb(emu,page) __set_ptb_entry(emu,page,emu->silent_page.addr) #else /* fill PTB entries -- we need to fill UNIT_PAGES entries */ -static inline void set_ptb_entry(emu10k1_t *emu, int page, dma_addr_t addr) +static inline void set_ptb_entry(struct snd_emu10k1 *emu, int page, dma_addr_t addr) { int i; page *= UNIT_PAGES; @@ -57,7 +57,7 @@ static inline void set_ptb_entry(emu10k1_t *emu, int page, dma_addr_t addr) addr += EMUPAGESIZE; } } -static inline void set_silent_ptb(emu10k1_t *emu, int page) +static inline void set_silent_ptb(struct snd_emu10k1 *emu, int page) { int i; page *= UNIT_PAGES; @@ -70,14 +70,14 @@ static inline void set_silent_ptb(emu10k1_t *emu, int page) /* */ -static int synth_alloc_pages(emu10k1_t *hw, emu10k1_memblk_t *blk); -static int synth_free_pages(emu10k1_t *hw, emu10k1_memblk_t *blk); +static int synth_alloc_pages(struct snd_emu10k1 *hw, struct snd_emu10k1_memblk *blk); +static int synth_free_pages(struct snd_emu10k1 *hw, struct snd_emu10k1_memblk *blk); -#define get_emu10k1_memblk(l,member) list_entry(l, emu10k1_memblk_t, member) +#define get_emu10k1_memblk(l,member) list_entry(l, struct snd_emu10k1_memblk, member) /* initialize emu10k1 part */ -static void emu10k1_memblk_init(emu10k1_memblk_t *blk) +static void emu10k1_memblk_init(struct snd_emu10k1_memblk *blk) { blk->mapped_page = -1; INIT_LIST_HEAD(&blk->mapped_link); @@ -96,7 +96,7 @@ static void emu10k1_memblk_init(emu10k1_memblk_t *blk) * in nextp * if not found, return a negative error code. */ -static int search_empty_map_area(emu10k1_t *emu, int npages, struct list_head **nextp) +static int search_empty_map_area(struct snd_emu10k1 *emu, int npages, struct list_head **nextp) { int page = 0, found_page = -ENOMEM; int max_size = npages; @@ -105,7 +105,7 @@ static int search_empty_map_area(emu10k1_t *emu, int npages, struct list_head ** struct list_head *pos; list_for_each (pos, &emu->mapped_link_head) { - emu10k1_memblk_t *blk = get_emu10k1_memblk(pos, mapped_link); + struct snd_emu10k1_memblk *blk = get_emu10k1_memblk(pos, mapped_link); snd_assert(blk->mapped_page >= 0, continue); size = blk->mapped_page - page; if (size == npages) { @@ -134,7 +134,7 @@ static int search_empty_map_area(emu10k1_t *emu, int npages, struct list_head ** * * call with memblk_lock held */ -static int map_memblk(emu10k1_t *emu, emu10k1_memblk_t *blk) +static int map_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int page, pg; struct list_head *next; @@ -161,11 +161,11 @@ static int map_memblk(emu10k1_t *emu, emu10k1_memblk_t *blk) * * call with memblk_lock held */ -static int unmap_memblk(emu10k1_t *emu, emu10k1_memblk_t *blk) +static int unmap_memblk(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int start_page, end_page, mpage, pg; struct list_head *p; - emu10k1_memblk_t *q; + struct snd_emu10k1_memblk *q; /* calculate the expected size of empty region */ if ((p = blk->mapped_link.prev) != &emu->mapped_link_head) { @@ -197,11 +197,11 @@ static int unmap_memblk(emu10k1_t *emu, emu10k1_memblk_t *blk) * * unlike synth_alloc the memory block is aligned to the page start */ -static emu10k1_memblk_t * -search_empty(emu10k1_t *emu, int size) +static struct snd_emu10k1_memblk * +search_empty(struct snd_emu10k1 *emu, int size) { struct list_head *p; - emu10k1_memblk_t *blk; + struct snd_emu10k1_memblk *blk; int page, psize; psize = get_aligned_page(size + PAGE_SIZE -1); @@ -217,7 +217,7 @@ search_empty(emu10k1_t *emu, int size) __found_pages: /* create a new memory block */ - blk = (emu10k1_memblk_t *)__snd_util_memblk_new(emu->memhdr, psize << PAGE_SHIFT, p->prev); + blk = (struct snd_emu10k1_memblk *)__snd_util_memblk_new(emu->memhdr, psize << PAGE_SHIFT, p->prev); if (blk == NULL) return NULL; blk->mem.offset = aligned_page_offset(page); /* set aligned offset */ @@ -229,7 +229,7 @@ __found_pages: /* * check if the given pointer is valid for pages */ -static int is_valid_page(emu10k1_t *emu, dma_addr_t addr) +static int is_valid_page(struct snd_emu10k1 *emu, dma_addr_t addr) { if (addr & ~emu->dma_mask) { snd_printk(KERN_ERR "max memory size is 0x%lx (addr = 0x%lx)!!\n", emu->dma_mask, (unsigned long)addr); @@ -248,12 +248,12 @@ static int is_valid_page(emu10k1_t *emu, dma_addr_t addr) * if no empty pages are found, tries to release unsed memory blocks * and retry the mapping. */ -int snd_emu10k1_memblk_map(emu10k1_t *emu, emu10k1_memblk_t *blk) +int snd_emu10k1_memblk_map(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int err; int size; struct list_head *p, *nextp; - emu10k1_memblk_t *deleted; + struct snd_emu10k1_memblk *deleted; unsigned long flags; spin_lock_irqsave(&emu->memblk_lock, flags); @@ -288,13 +288,13 @@ int snd_emu10k1_memblk_map(emu10k1_t *emu, emu10k1_memblk_t *blk) /* * page allocation for DMA */ -snd_util_memblk_t * -snd_emu10k1_alloc_pages(emu10k1_t *emu, snd_pcm_substream_t *substream) +struct snd_util_memblk * +snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); - snd_util_memhdr_t *hdr; - emu10k1_memblk_t *blk; + struct snd_util_memhdr *hdr; + struct snd_emu10k1_memblk *blk; int page, err, idx; snd_assert(emu, return NULL); @@ -336,19 +336,19 @@ snd_emu10k1_alloc_pages(emu10k1_t *emu, snd_pcm_substream_t *substream) blk->map_locked = 1; /* do not unmap this block! */ err = snd_emu10k1_memblk_map(emu, blk); if (err < 0) { - __snd_util_mem_free(hdr, (snd_util_memblk_t *)blk); + __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); up(&hdr->block_mutex); return NULL; } up(&hdr->block_mutex); - return (snd_util_memblk_t *)blk; + return (struct snd_util_memblk *)blk; } /* * release DMA buffer from page table */ -int snd_emu10k1_free_pages(emu10k1_t *emu, snd_util_memblk_t *blk) +int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk) { snd_assert(emu && blk, return -EINVAL); return snd_emu10k1_synth_free(emu, blk); @@ -363,26 +363,26 @@ int snd_emu10k1_free_pages(emu10k1_t *emu, snd_util_memblk_t *blk) /* * allocate a synth sample area */ -snd_util_memblk_t * -snd_emu10k1_synth_alloc(emu10k1_t *hw, unsigned int size) +struct snd_util_memblk * +snd_emu10k1_synth_alloc(struct snd_emu10k1 *hw, unsigned int size) { - emu10k1_memblk_t *blk; - snd_util_memhdr_t *hdr = hw->memhdr; + struct snd_emu10k1_memblk *blk; + struct snd_util_memhdr *hdr = hw->memhdr; down(&hdr->block_mutex); - blk = (emu10k1_memblk_t *)__snd_util_mem_alloc(hdr, size); + blk = (struct snd_emu10k1_memblk *)__snd_util_mem_alloc(hdr, size); if (blk == NULL) { up(&hdr->block_mutex); return NULL; } if (synth_alloc_pages(hw, blk)) { - __snd_util_mem_free(hdr, (snd_util_memblk_t *)blk); + __snd_util_mem_free(hdr, (struct snd_util_memblk *)blk); up(&hdr->block_mutex); return NULL; } snd_emu10k1_memblk_map(hw, blk); up(&hdr->block_mutex); - return (snd_util_memblk_t *)blk; + return (struct snd_util_memblk *)blk; } @@ -390,10 +390,10 @@ snd_emu10k1_synth_alloc(emu10k1_t *hw, unsigned int size) * free a synth sample area */ int -snd_emu10k1_synth_free(emu10k1_t *emu, snd_util_memblk_t *memblk) +snd_emu10k1_synth_free(struct snd_emu10k1 *emu, struct snd_util_memblk *memblk) { - snd_util_memhdr_t *hdr = emu->memhdr; - emu10k1_memblk_t *blk = (emu10k1_memblk_t *)memblk; + struct snd_util_memhdr *hdr = emu->memhdr; + struct snd_emu10k1_memblk *blk = (struct snd_emu10k1_memblk *)memblk; unsigned long flags; down(&hdr->block_mutex); @@ -409,10 +409,12 @@ snd_emu10k1_synth_free(emu10k1_t *emu, snd_util_memblk_t *memblk) /* check new allocation range */ -static void get_single_page_range(snd_util_memhdr_t *hdr, emu10k1_memblk_t *blk, int *first_page_ret, int *last_page_ret) +static void get_single_page_range(struct snd_util_memhdr *hdr, + struct snd_emu10k1_memblk *blk, + int *first_page_ret, int *last_page_ret) { struct list_head *p; - emu10k1_memblk_t *q; + struct snd_emu10k1_memblk *q; int first_page, last_page; first_page = blk->first_page; if ((p = blk->mem.list.prev) != &hdr->block) { @@ -433,7 +435,7 @@ static void get_single_page_range(snd_util_memhdr_t *hdr, emu10k1_memblk_t *blk, /* * allocate kernel pages */ -static int synth_alloc_pages(emu10k1_t *emu, emu10k1_memblk_t *blk) +static int synth_alloc_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int page, first_page, last_page; struct snd_dma_buffer dmab; @@ -472,7 +474,7 @@ __fail: /* * free pages */ -static int synth_free_pages(emu10k1_t *emu, emu10k1_memblk_t *blk) +static int synth_free_pages(struct snd_emu10k1 *emu, struct snd_emu10k1_memblk *blk) { int page, first_page, last_page; struct snd_dma_buffer dmab; @@ -495,7 +497,7 @@ static int synth_free_pages(emu10k1_t *emu, emu10k1_memblk_t *blk) } /* calculate buffer pointer from offset address */ -static inline void *offset_ptr(emu10k1_t *emu, int page, int offset) +static inline void *offset_ptr(struct snd_emu10k1 *emu, int page, int offset) { char *ptr; snd_assert(page >= 0 && page < emu->max_cache_pages, return NULL); @@ -511,11 +513,12 @@ static inline void *offset_ptr(emu10k1_t *emu, int page, int offset) /* * bzero(blk + offset, size) */ -int snd_emu10k1_synth_bzero(emu10k1_t *emu, snd_util_memblk_t *blk, int offset, int size) +int snd_emu10k1_synth_bzero(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, + int offset, int size) { int page, nextofs, end_offset, temp, temp1; void *ptr; - emu10k1_memblk_t *p = (emu10k1_memblk_t *)blk; + struct snd_emu10k1_memblk *p = (struct snd_emu10k1_memblk *)blk; offset += blk->offset & (PAGE_SIZE - 1); end_offset = offset + size; @@ -538,11 +541,12 @@ int snd_emu10k1_synth_bzero(emu10k1_t *emu, snd_util_memblk_t *blk, int offset, /* * copy_from_user(blk + offset, data, size) */ -int snd_emu10k1_synth_copy_from_user(emu10k1_t *emu, snd_util_memblk_t *blk, int offset, const char __user *data, int size) +int snd_emu10k1_synth_copy_from_user(struct snd_emu10k1 *emu, struct snd_util_memblk *blk, + int offset, const char __user *data, int size) { int page, nextofs, end_offset, temp, temp1; void *ptr; - emu10k1_memblk_t *p = (emu10k1_memblk_t *)blk; + struct snd_emu10k1_memblk *p = (struct snd_emu10k1_memblk *)blk; offset += blk->offset & (PAGE_SIZE - 1); end_offset = offset + size; diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 3b45600..90470de 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -121,7 +121,7 @@ */ /* hardware definition */ -static snd_pcm_hardware_t snd_p16v_playback_hw = { +static struct snd_pcm_hardware snd_p16v_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -140,7 +140,7 @@ static snd_pcm_hardware_t snd_p16v_playback_hw = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_p16v_capture_hw = { +static struct snd_pcm_hardware snd_p16v_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -159,9 +159,9 @@ static snd_pcm_hardware_t snd_p16v_capture_hw = { .fifo_size = 0, }; -static void snd_p16v_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_p16v_pcm_free_substream(struct snd_pcm_runtime *runtime) { - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1_pcm *epcm = runtime->private_data; if (epcm) { //snd_printk("epcm free: %p\n", epcm); @@ -170,12 +170,12 @@ static void snd_p16v_pcm_free_substream(snd_pcm_runtime_t *runtime) } /* open_playback callback */ -static int snd_p16v_pcm_open_playback_channel(snd_pcm_substream_t *substream, int channel_id) +static int snd_p16v_pcm_open_playback_channel(struct snd_pcm_substream *substream, int channel_id) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_voice_t *channel = &(emu->p16v_voices[channel_id]); - emu10k1_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_voice *channel = &(emu->p16v_voices[channel_id]); + struct snd_emu10k1_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -206,12 +206,12 @@ static int snd_p16v_pcm_open_playback_channel(snd_pcm_substream_t *substream, in return 0; } /* open_capture callback */ -static int snd_p16v_pcm_open_capture_channel(snd_pcm_substream_t *substream, int channel_id) +static int snd_p16v_pcm_open_capture_channel(struct snd_pcm_substream *substream, int channel_id) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - emu10k1_voice_t *channel = &(emu->p16v_capture_voice); - emu10k1_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_emu10k1_voice *channel = &(emu->p16v_capture_voice); + struct snd_emu10k1_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -244,41 +244,41 @@ static int snd_p16v_pcm_open_capture_channel(snd_pcm_substream_t *substream, int /* close callback */ -static int snd_p16v_pcm_close_playback(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_close_playback(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - //snd_pcm_runtime_t *runtime = substream->runtime; - //emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + //struct snd_pcm_runtime *runtime = substream->runtime; + //struct snd_emu10k1_pcm *epcm = runtime->private_data; emu->p16v_voices[substream->pcm->device - emu->p16v_device_offset].use=0; /* FIXME: maybe zero others */ return 0; } /* close callback */ -static int snd_p16v_pcm_close_capture(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_close_capture(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - //snd_pcm_runtime_t *runtime = substream->runtime; - //emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + //struct snd_pcm_runtime *runtime = substream->runtime; + //struct snd_emu10k1_pcm *epcm = runtime->private_data; emu->p16v_capture_voice.use=0; /* FIXME: maybe zero others */ return 0; } -static int snd_p16v_pcm_open_playback_front(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_open_playback_front(struct snd_pcm_substream *substream) { return snd_p16v_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); } -static int snd_p16v_pcm_open_capture(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_open_capture(struct snd_pcm_substream *substream) { // Only using channel 0 for now, but the card has 2 channels. return snd_p16v_pcm_open_capture_channel(substream, 0); } /* hw_params callback */ -static int snd_p16v_pcm_hw_params_playback(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_p16v_pcm_hw_params_playback(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int result; result = snd_pcm_lib_malloc_pages(substream, @@ -287,8 +287,8 @@ static int snd_p16v_pcm_hw_params_playback(snd_pcm_substream_t *substream, } /* hw_params callback */ -static int snd_p16v_pcm_hw_params_capture(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_p16v_pcm_hw_params_capture(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int result; result = snd_pcm_lib_malloc_pages(substream, @@ -298,7 +298,7 @@ static int snd_p16v_pcm_hw_params_capture(snd_pcm_substream_t *substream, /* hw_free callback */ -static int snd_p16v_pcm_hw_free_playback(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_hw_free_playback(struct snd_pcm_substream *substream) { int result; result = snd_pcm_lib_free_pages(substream); @@ -306,7 +306,7 @@ static int snd_p16v_pcm_hw_free_playback(snd_pcm_substream_t *substream) } /* hw_free callback */ -static int snd_p16v_pcm_hw_free_capture(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_hw_free_capture(struct snd_pcm_substream *substream) { int result; result = snd_pcm_lib_free_pages(substream); @@ -315,10 +315,10 @@ static int snd_p16v_pcm_hw_free_capture(snd_pcm_substream_t *substream) /* prepare playback callback */ -static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_prepare_playback(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int channel = substream->pcm->device - emu->p16v_device_offset; u32 *table_base = (u32 *)(emu->p16v_buffer.area+(8*16*channel)); u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); @@ -364,10 +364,10 @@ static int snd_p16v_pcm_prepare_playback(snd_pcm_substream_t *substream) } /* prepare capture callback */ -static int snd_p16v_pcm_prepare_capture(snd_pcm_substream_t *substream) +static int snd_p16v_pcm_prepare_capture(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int channel = substream->pcm->device - emu->p16v_device_offset; u32 tmp; //printk("prepare capture:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); @@ -398,7 +398,7 @@ static int snd_p16v_pcm_prepare_capture(snd_pcm_substream_t *substream) return 0; } -static void snd_p16v_intr_enable(emu10k1_t *emu, unsigned int intrenb) +static void snd_p16v_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -409,7 +409,7 @@ static void snd_p16v_intr_enable(emu10k1_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_p16v_intr_disable(emu10k1_t *emu, unsigned int intrenb) +static void snd_p16v_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; unsigned int disable; @@ -421,16 +421,16 @@ static void snd_p16v_intr_disable(emu10k1_t *emu, unsigned int intrenb) } /* trigger_playback callback */ -static int snd_p16v_pcm_trigger_playback(snd_pcm_substream_t *substream, +static int snd_p16v_pcm_trigger_playback(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime; - emu10k1_pcm_t *epcm; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime; + struct snd_emu10k1_pcm *epcm; int channel; int result = 0; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; u32 basic = 0; u32 inte = 0; int running=0; @@ -474,12 +474,12 @@ static int snd_p16v_pcm_trigger_playback(snd_pcm_substream_t *substream, } /* trigger_capture callback */ -static int snd_p16v_pcm_trigger_capture(snd_pcm_substream_t *substream, +static int snd_p16v_pcm_trigger_capture(struct snd_pcm_substream *substream, int cmd) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; int channel = 0; int result = 0; u32 inte = INTE2_CAPTURE_CH_0_LOOP | INTE2_CAPTURE_CH_0_HALF_LOOP; @@ -505,11 +505,11 @@ static int snd_p16v_pcm_trigger_capture(snd_pcm_substream_t *substream, /* pointer_playback callback */ static snd_pcm_uframes_t -snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream) +snd_p16v_pcm_pointer_playback(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; int channel = substream->pcm->device - emu->p16v_device_offset; if (!epcm->running) @@ -530,11 +530,11 @@ snd_p16v_pcm_pointer_playback(snd_pcm_substream_t *substream) /* pointer_capture callback */ static snd_pcm_uframes_t -snd_p16v_pcm_pointer_capture(snd_pcm_substream_t *substream) +snd_p16v_pcm_pointer_capture(struct snd_pcm_substream *substream) { - emu10k1_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1_pcm_t *epcm = runtime->private_data; + struct snd_emu10k1 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_emu10k1_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr, ptr1, ptr2 = 0; int channel = 0; @@ -554,7 +554,7 @@ snd_p16v_pcm_pointer_capture(snd_pcm_substream_t *substream) } /* operators */ -static snd_pcm_ops_t snd_p16v_playback_front_ops = { +static struct snd_pcm_ops snd_p16v_playback_front_ops = { .open = snd_p16v_pcm_open_playback_front, .close = snd_p16v_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -565,7 +565,7 @@ static snd_pcm_ops_t snd_p16v_playback_front_ops = { .pointer = snd_p16v_pcm_pointer_playback, }; -static snd_pcm_ops_t snd_p16v_capture_ops = { +static struct snd_pcm_ops snd_p16v_capture_ops = { .open = snd_p16v_pcm_open_capture, .close = snd_p16v_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -577,7 +577,7 @@ static snd_pcm_ops_t snd_p16v_capture_ops = { }; -int snd_p16v_free(emu10k1_t *chip) +int snd_p16v_free(struct snd_emu10k1 *chip) { // release the data if (chip->p16v_buffer.area) { @@ -587,10 +587,10 @@ int snd_p16v_free(emu10k1_t *chip) return 0; } -int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) +int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; int err; int capture=1; @@ -641,7 +641,7 @@ int snd_p16v_pcm(emu10k1_t *emu, int device, snd_pcm_t **rpcm) return 0; } -static int snd_p16v_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_p16v_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -650,10 +650,10 @@ static int snd_p16v_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_p16v_volume_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol, int reg, int high_low) +static int snd_p16v_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol, int reg, int high_low) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); u32 value; value = snd_emu10k1_ptr20_read(emu, reg, high_low); @@ -667,71 +667,71 @@ static int snd_p16v_volume_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_p16v_volume_get_spdif_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_get_spdif_front(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 0; int reg = PLAYBACK_VOLUME_MIXER7; return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_get_spdif_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_get_spdif_center_lfe(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 1; int reg = PLAYBACK_VOLUME_MIXER7; return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_get_spdif_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_get_spdif_unknown(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 0; int reg = PLAYBACK_VOLUME_MIXER8; return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_get_spdif_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_get_spdif_rear(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 1; int reg = PLAYBACK_VOLUME_MIXER8; return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_get_analog_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_get_analog_front(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 0; int reg = PLAYBACK_VOLUME_MIXER9; return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_get_analog_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_get_analog_center_lfe(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 1; int reg = PLAYBACK_VOLUME_MIXER9; return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_get_analog_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_get_analog_rear(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 1; int reg = PLAYBACK_VOLUME_MIXER10; return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_get_analog_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_get_analog_unknown(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 0; int reg = PLAYBACK_VOLUME_MIXER10; return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol, int reg, int high_low) +static int snd_p16v_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol, int reg, int high_low) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); u32 value; value = snd_emu10k1_ptr20_read(emu, reg, 0); //value = value & 0xffff; @@ -746,71 +746,71 @@ static int snd_p16v_volume_put(snd_kcontrol_t * kcontrol, return 1; } -static int snd_p16v_volume_put_spdif_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put_spdif_front(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 0; int reg = PLAYBACK_VOLUME_MIXER7; return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_put_spdif_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put_spdif_center_lfe(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 1; int reg = PLAYBACK_VOLUME_MIXER7; return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_put_spdif_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put_spdif_unknown(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 0; int reg = PLAYBACK_VOLUME_MIXER8; return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_put_spdif_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put_spdif_rear(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 1; int reg = PLAYBACK_VOLUME_MIXER8; return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_put_analog_front(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put_analog_front(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 0; int reg = PLAYBACK_VOLUME_MIXER9; return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_put_analog_center_lfe(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put_analog_center_lfe(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 1; int reg = PLAYBACK_VOLUME_MIXER9; return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_put_analog_rear(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put_analog_rear(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 1; int reg = PLAYBACK_VOLUME_MIXER10; return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); } -static int snd_p16v_volume_put_analog_unknown(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_volume_put_analog_unknown(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int high_low = 0; int reg = PLAYBACK_VOLUME_MIXER10; return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); } -static snd_kcontrol_new_t snd_p16v_volume_control_analog_front = +static struct snd_kcontrol_new snd_p16v_volume_control_analog_front = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD Analog Front Playback Volume", @@ -819,7 +819,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_analog_front = .put = snd_p16v_volume_put_analog_front }; -static snd_kcontrol_new_t snd_p16v_volume_control_analog_center_lfe = +static struct snd_kcontrol_new snd_p16v_volume_control_analog_center_lfe = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD Analog Center/LFE Playback Volume", @@ -828,7 +828,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_analog_center_lfe = .put = snd_p16v_volume_put_analog_center_lfe }; -static snd_kcontrol_new_t snd_p16v_volume_control_analog_unknown = +static struct snd_kcontrol_new snd_p16v_volume_control_analog_unknown = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD Analog Unknown Playback Volume", @@ -837,7 +837,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_analog_unknown = .put = snd_p16v_volume_put_analog_unknown }; -static snd_kcontrol_new_t snd_p16v_volume_control_analog_rear = +static struct snd_kcontrol_new snd_p16v_volume_control_analog_rear = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD Analog Rear Playback Volume", @@ -846,7 +846,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_analog_rear = .put = snd_p16v_volume_put_analog_rear }; -static snd_kcontrol_new_t snd_p16v_volume_control_spdif_front = +static struct snd_kcontrol_new snd_p16v_volume_control_spdif_front = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD SPDIF Front Playback Volume", @@ -855,7 +855,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_front = .put = snd_p16v_volume_put_spdif_front }; -static snd_kcontrol_new_t snd_p16v_volume_control_spdif_center_lfe = +static struct snd_kcontrol_new snd_p16v_volume_control_spdif_center_lfe = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD SPDIF Center/LFE Playback Volume", @@ -864,7 +864,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_center_lfe = .put = snd_p16v_volume_put_spdif_center_lfe }; -static snd_kcontrol_new_t snd_p16v_volume_control_spdif_unknown = +static struct snd_kcontrol_new snd_p16v_volume_control_spdif_unknown = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD SPDIF Unknown Playback Volume", @@ -873,7 +873,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_unknown = .put = snd_p16v_volume_put_spdif_unknown }; -static snd_kcontrol_new_t snd_p16v_volume_control_spdif_rear = +static struct snd_kcontrol_new snd_p16v_volume_control_spdif_rear = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD SPDIF Rear Playback Volume", @@ -882,7 +882,7 @@ static snd_kcontrol_new_t snd_p16v_volume_control_spdif_rear = .put = snd_p16v_volume_put_spdif_rear }; -static int snd_p16v_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_p16v_capture_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[8] = { "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", "CDIF", "FX", "AC97" }; @@ -895,19 +895,19 @@ static int snd_p16v_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_p16v_capture_source_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_capture_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = emu->p16v_capture_source; return 0; } -static int snd_p16v_capture_source_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_capture_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; u32 mask; @@ -924,7 +924,7 @@ static int snd_p16v_capture_source_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata = +static struct snd_kcontrol_new snd_p16v_capture_source __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD source Capture", @@ -933,7 +933,7 @@ static snd_kcontrol_new_t snd_p16v_capture_source __devinitdata = .put = snd_p16v_capture_source_put }; -static int snd_p16v_capture_channel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_p16v_capture_channel_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "0", "1", "2", "3", }; @@ -946,19 +946,19 @@ static int snd_p16v_capture_channel_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_p16v_capture_channel_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_capture_channel_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = emu->p16v_capture_channel; return 0; } -static int snd_p16v_capture_channel_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_p16v_capture_channel_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; u32 tmp; @@ -973,7 +973,7 @@ static int snd_p16v_capture_channel_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata = +static struct snd_kcontrol_new snd_p16v_capture_channel __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "HD channel Capture", @@ -982,11 +982,11 @@ static snd_kcontrol_new_t snd_p16v_capture_channel __devinitdata = .put = snd_p16v_capture_channel_put }; -int snd_p16v_mixer(emu10k1_t *emu) +int snd_p16v_mixer(struct snd_emu10k1 *emu) { int err; - snd_kcontrol_t *kctl; - snd_card_t *card = emu->card; + struct snd_kcontrol *kctl; + struct snd_card *card = emu->card; if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_front, emu)) == NULL) return -ENOMEM; if ((err = snd_ctl_add(card, kctl))) diff --git a/sound/pci/emu10k1/timer.c b/sound/pci/emu10k1/timer.c index d2e3646..6295b2d 100644 --- a/sound/pci/emu10k1/timer.c +++ b/sound/pci/emu10k1/timer.c @@ -30,9 +30,9 @@ #include <sound/core.h> #include <sound/emu10k1.h> -static int snd_emu10k1_timer_start(snd_timer_t *timer) +static int snd_emu10k1_timer_start(struct snd_timer *timer) { - emu10k1_t *emu; + struct snd_emu10k1 *emu; unsigned long flags; unsigned int delay; @@ -47,9 +47,9 @@ static int snd_emu10k1_timer_start(snd_timer_t *timer) return 0; } -static int snd_emu10k1_timer_stop(snd_timer_t *timer) +static int snd_emu10k1_timer_stop(struct snd_timer *timer) { - emu10k1_t *emu; + struct snd_emu10k1 *emu; unsigned long flags; emu = snd_timer_chip(timer); @@ -59,7 +59,7 @@ static int snd_emu10k1_timer_stop(snd_timer_t *timer) return 0; } -static int snd_emu10k1_timer_precise_resolution(snd_timer_t *timer, +static int snd_emu10k1_timer_precise_resolution(struct snd_timer *timer, unsigned long *num, unsigned long *den) { *num = 1; @@ -67,7 +67,7 @@ static int snd_emu10k1_timer_precise_resolution(snd_timer_t *timer, return 0; } -static struct _snd_timer_hardware snd_emu10k1_timer_hw = { +static struct snd_timer_hardware snd_emu10k1_timer_hw = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 20833, /* 1 sample @ 48KHZ = 20.833...us */ .ticks = 1024, @@ -76,10 +76,10 @@ static struct _snd_timer_hardware snd_emu10k1_timer_hw = { .precise_resolution = snd_emu10k1_timer_precise_resolution, }; -int __devinit snd_emu10k1_timer(emu10k1_t *emu, int device) +int __devinit snd_emu10k1_timer(struct snd_emu10k1 *emu, int device) { - snd_timer_t *timer = NULL; - snd_timer_id_t tid; + struct snd_timer *timer = NULL; + struct snd_timer_id tid; int err; tid.dev_class = SNDRV_TIMER_CLASS_CARD; diff --git a/sound/pci/emu10k1/voice.c b/sound/pci/emu10k1/voice.c index d251d34..56ffb7d 100644 --- a/sound/pci/emu10k1/voice.c +++ b/sound/pci/emu10k1/voice.c @@ -45,9 +45,10 @@ * --rlrevell */ -static int voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int number, emu10k1_voice_t **rvoice) +static int voice_alloc(struct snd_emu10k1 *emu, int type, int number, + struct snd_emu10k1_voice **rvoice) { - emu10k1_voice_t *voice; + struct snd_emu10k1_voice *voice; int i, j, k, first_voice, last_voice, skip; *rvoice = NULL; @@ -105,7 +106,8 @@ static int voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int number, em return 0; } -int snd_emu10k1_voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int number, emu10k1_voice_t **rvoice) +int snd_emu10k1_voice_alloc(struct snd_emu10k1 *emu, int type, int number, + struct snd_emu10k1_voice **rvoice) { unsigned long flags; int result; @@ -123,7 +125,7 @@ int snd_emu10k1_voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int numbe if (emu->get_synth_voice) { result = emu->get_synth_voice(emu); if (result >= 0) { - emu10k1_voice_t *pvoice = &emu->voices[result]; + struct snd_emu10k1_voice *pvoice = &emu->voices[result]; pvoice->interrupt = NULL; pvoice->use = pvoice->pcm = pvoice->synth = pvoice->midi = pvoice->efx = 0; pvoice->epcm = NULL; @@ -137,7 +139,8 @@ int snd_emu10k1_voice_alloc(emu10k1_t *emu, emu10k1_voice_type_t type, int numbe return result; } -int snd_emu10k1_voice_free(emu10k1_t *emu, emu10k1_voice_t *pvoice) +int snd_emu10k1_voice_free(struct snd_emu10k1 *emu, + struct snd_emu10k1_voice *pvoice) { unsigned long flags; -- cgit v1.1 From 4b32f1aae23f566e98fda140836023dd8275b5de Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:50:31 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI emu10k1x Modules: EMU10K1/EMU10K2 driver Remove xxx_t typedefs from the PCI emu10k1x driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/emu10k1/emu10k1x.c | 337 +++++++++++++++++++++---------------------- 1 file changed, 168 insertions(+), 169 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index 6c61ac60..1107c8e 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -195,30 +195,26 @@ MODULE_PARM_DESC(enable, "Enable the EMU10K1X soundcard."); * playback. */ -typedef struct snd_emu10k1x_voice emu10k1x_voice_t; -typedef struct snd_emu10k1x emu10k1x_t; -typedef struct snd_emu10k1x_pcm emu10k1x_pcm_t; - -struct snd_emu10k1x_voice { - emu10k1x_t *emu; +struct emu10k1x_voice { + struct emu10k1x *emu; int number; int use; - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; }; -struct snd_emu10k1x_pcm { - emu10k1x_t *emu; - snd_pcm_substream_t *substream; - emu10k1x_voice_t *voice; +struct emu10k1x_pcm { + struct emu10k1x *emu; + struct snd_pcm_substream *substream; + struct emu10k1x_voice *voice; unsigned short running; }; -typedef struct { - struct snd_emu10k1x *emu; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream_input; - snd_rawmidi_substream_t *substream_output; +struct emu10k1x_midi { + struct emu10k1x *emu; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream_input; + struct snd_rawmidi_substream *substream_output; unsigned int midi_mode; spinlock_t input_lock; spinlock_t output_lock; @@ -226,12 +222,12 @@ typedef struct { int tx_enable, rx_enable; int port; int ipr_tx, ipr_rx; - void (*interrupt)(emu10k1x_t *emu, unsigned int status); -} emu10k1x_midi_t; + void (*interrupt)(struct emu10k1x *emu, unsigned int status); +}; // definition of the chip-specific record -struct snd_emu10k1x { - snd_card_t *card; +struct emu10k1x { + struct snd_card *card; struct pci_dev *pci; unsigned long port; @@ -245,20 +241,20 @@ struct snd_emu10k1x { spinlock_t emu_lock; spinlock_t voice_lock; - ac97_t *ac97; - snd_pcm_t *pcm; + struct snd_ac97 *ac97; + struct snd_pcm *pcm; - emu10k1x_voice_t voices[3]; - emu10k1x_voice_t capture_voice; + struct emu10k1x_voice voices[3]; + struct emu10k1x_voice capture_voice; u32 spdif_bits[3]; // SPDIF out setup struct snd_dma_buffer dma_buffer; - emu10k1x_midi_t midi; + struct emu10k1x_midi midi; }; /* hardware definition */ -static snd_pcm_hardware_t snd_emu10k1x_playback_hw = { +static struct snd_pcm_hardware snd_emu10k1x_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -277,7 +273,7 @@ static snd_pcm_hardware_t snd_emu10k1x_playback_hw = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_emu10k1x_capture_hw = { +static struct snd_pcm_hardware snd_emu10k1x_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -296,7 +292,7 @@ static snd_pcm_hardware_t snd_emu10k1x_capture_hw = { .fifo_size = 0, }; -static unsigned int snd_emu10k1x_ptr_read(emu10k1x_t * emu, +static unsigned int snd_emu10k1x_ptr_read(struct emu10k1x * emu, unsigned int reg, unsigned int chn) { @@ -312,7 +308,7 @@ static unsigned int snd_emu10k1x_ptr_read(emu10k1x_t * emu, return val; } -static void snd_emu10k1x_ptr_write(emu10k1x_t *emu, +static void snd_emu10k1x_ptr_write(struct emu10k1x *emu, unsigned int reg, unsigned int chn, unsigned int data) @@ -328,7 +324,7 @@ static void snd_emu10k1x_ptr_write(emu10k1x_t *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_intr_enable(emu10k1x_t *emu, unsigned int intrenb) +static void snd_emu10k1x_intr_enable(struct emu10k1x *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -339,7 +335,7 @@ static void snd_emu10k1x_intr_enable(emu10k1x_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_intr_disable(emu10k1x_t *emu, unsigned int intrenb) +static void snd_emu10k1x_intr_disable(struct emu10k1x *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -350,7 +346,7 @@ static void snd_emu10k1x_intr_disable(emu10k1x_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value) +static void snd_emu10k1x_gpio_write(struct emu10k1x *emu, unsigned int value) { unsigned long flags; @@ -359,14 +355,14 @@ static void snd_emu10k1x_gpio_write(emu10k1x_t *emu, unsigned int value) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_emu10k1x_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_emu10k1x_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) +static void snd_emu10k1x_pcm_interrupt(struct emu10k1x *emu, struct emu10k1x_voice *voice) { - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; if ((epcm = voice->epcm) == NULL) return; @@ -382,11 +378,11 @@ static void snd_emu10k1x_pcm_interrupt(emu10k1x_t *emu, emu10k1x_voice_t *voice) } /* open callback */ -static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream) +static int snd_emu10k1x_playback_open(struct snd_pcm_substream *substream) { - emu10k1x_t *chip = snd_pcm_substream_chip(substream); - emu10k1x_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *chip = snd_pcm_substream_chip(substream); + struct emu10k1x_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) { @@ -410,17 +406,17 @@ static int snd_emu10k1x_playback_open(snd_pcm_substream_t *substream) } /* close callback */ -static int snd_emu10k1x_playback_close(snd_pcm_substream_t *substream) +static int snd_emu10k1x_playback_close(struct snd_pcm_substream *substream) { return 0; } /* hw_params callback */ -static int snd_emu10k1x_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1x_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; if (! epcm->voice) { epcm->voice = &epcm->emu->voices[substream->pcm->device]; @@ -433,10 +429,10 @@ static int snd_emu10k1x_pcm_hw_params(snd_pcm_substream_t *substream, } /* hw_free callback */ -static int snd_emu10k1x_pcm_hw_free(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_hw_free(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm; if (runtime->private_data == NULL) return 0; @@ -453,11 +449,11 @@ static int snd_emu10k1x_pcm_hw_free(snd_pcm_substream_t *substream) } /* prepare callback */ -static int snd_emu10k1x_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_prepare(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int voice = epcm->voice->number; u32 *table_base = (u32 *)(emu->dma_buffer.area+1024*voice); u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); @@ -482,12 +478,12 @@ static int snd_emu10k1x_pcm_prepare(snd_pcm_substream_t *substream) } /* trigger callback */ -static int snd_emu10k1x_pcm_trigger(snd_pcm_substream_t *substream, +static int snd_emu10k1x_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int channel = epcm->voice->number; int result = 0; @@ -516,11 +512,11 @@ static int snd_emu10k1x_pcm_trigger(snd_pcm_substream_t *substream, /* pointer callback */ static snd_pcm_uframes_t -snd_emu10k1x_pcm_pointer(snd_pcm_substream_t *substream) +snd_emu10k1x_pcm_pointer(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int channel = epcm->voice->number; snd_pcm_uframes_t ptr = 0, ptr1 = 0, ptr2= 0,ptr3 = 0,ptr4 = 0; @@ -547,7 +543,7 @@ snd_emu10k1x_pcm_pointer(snd_pcm_substream_t *substream) } /* operators */ -static snd_pcm_ops_t snd_emu10k1x_playback_ops = { +static struct snd_pcm_ops snd_emu10k1x_playback_ops = { .open = snd_emu10k1x_playback_open, .close = snd_emu10k1x_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -559,11 +555,11 @@ static snd_pcm_ops_t snd_emu10k1x_playback_ops = { }; /* open_capture callback */ -static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_open_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *chip = snd_pcm_substream_chip(substream); - emu10k1x_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *chip = snd_pcm_substream_chip(substream); + struct emu10k1x_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) @@ -587,17 +583,17 @@ static int snd_emu10k1x_pcm_open_capture(snd_pcm_substream_t *substream) } /* close callback */ -static int snd_emu10k1x_pcm_close_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_close_capture(struct snd_pcm_substream *substream) { return 0; } /* hw_params callback */ -static int snd_emu10k1x_pcm_hw_params_capture(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_emu10k1x_pcm_hw_params_capture(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; if (! epcm->voice) { if (epcm->emu->capture_voice.use) @@ -612,11 +608,11 @@ static int snd_emu10k1x_pcm_hw_params_capture(snd_pcm_substream_t *substream, } /* hw_free callback */ -static int snd_emu10k1x_pcm_hw_free_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_hw_free_capture(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; - emu10k1x_pcm_t *epcm; + struct emu10k1x_pcm *epcm; if (runtime->private_data == NULL) return 0; @@ -632,10 +628,10 @@ static int snd_emu10k1x_pcm_hw_free_capture(snd_pcm_substream_t *substream) } /* prepare capture callback */ -static int snd_emu10k1x_pcm_prepare_capture(snd_pcm_substream_t *substream) +static int snd_emu10k1x_pcm_prepare_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_emu10k1x_ptr_write(emu, CAPTURE_DMA_ADDR, 0, runtime->dma_addr); snd_emu10k1x_ptr_write(emu, CAPTURE_BUFFER_SIZE, 0, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes @@ -646,12 +642,12 @@ static int snd_emu10k1x_pcm_prepare_capture(snd_pcm_substream_t *substream) } /* trigger_capture callback */ -static int snd_emu10k1x_pcm_trigger_capture(snd_pcm_substream_t *substream, +static int snd_emu10k1x_pcm_trigger_capture(struct snd_pcm_substream *substream, int cmd) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; int result = 0; switch (cmd) { @@ -676,11 +672,11 @@ static int snd_emu10k1x_pcm_trigger_capture(snd_pcm_substream_t *substream, /* pointer_capture callback */ static snd_pcm_uframes_t -snd_emu10k1x_pcm_pointer_capture(snd_pcm_substream_t *substream) +snd_emu10k1x_pcm_pointer_capture(struct snd_pcm_substream *substream) { - emu10k1x_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - emu10k1x_pcm_t *epcm = runtime->private_data; + struct emu10k1x *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct emu10k1x_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr; if (!epcm->running) @@ -693,7 +689,7 @@ snd_emu10k1x_pcm_pointer_capture(snd_pcm_substream_t *substream) return ptr; } -static snd_pcm_ops_t snd_emu10k1x_capture_ops = { +static struct snd_pcm_ops snd_emu10k1x_capture_ops = { .open = snd_emu10k1x_pcm_open_capture, .close = snd_emu10k1x_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -704,10 +700,10 @@ static snd_pcm_ops_t snd_emu10k1x_capture_ops = { .pointer = snd_emu10k1x_pcm_pointer_capture, }; -static unsigned short snd_emu10k1x_ac97_read(ac97_t *ac97, +static unsigned short snd_emu10k1x_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - emu10k1x_t *emu = ac97->private_data; + struct emu10k1x *emu = ac97->private_data; unsigned long flags; unsigned short val; @@ -718,10 +714,10 @@ static unsigned short snd_emu10k1x_ac97_read(ac97_t *ac97, return val; } -static void snd_emu10k1x_ac97_write(ac97_t *ac97, +static void snd_emu10k1x_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - emu10k1x_t *emu = ac97->private_data; + struct emu10k1x *emu = ac97->private_data; unsigned long flags; spin_lock_irqsave(&emu->emu_lock, flags); @@ -730,12 +726,12 @@ static void snd_emu10k1x_ac97_write(ac97_t *ac97, spin_unlock_irqrestore(&emu->emu_lock, flags); } -static int snd_emu10k1x_ac97(emu10k1x_t *chip) +static int snd_emu10k1x_ac97(struct emu10k1x *chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_emu10k1x_ac97_write, .read = snd_emu10k1x_ac97_read, }; @@ -750,7 +746,7 @@ static int snd_emu10k1x_ac97(emu10k1x_t *chip) return snd_ac97_mixer(pbus, &ac97, &chip->ac97); } -static int snd_emu10k1x_free(emu10k1x_t *chip) +static int snd_emu10k1x_free(struct emu10k1x *chip) { snd_emu10k1x_ptr_write(chip, TRIGGER_CHANNEL, 0, 0); // disable interrupts @@ -777,9 +773,9 @@ static int snd_emu10k1x_free(emu10k1x_t *chip) return 0; } -static int snd_emu10k1x_dev_free(snd_device_t *device) +static int snd_emu10k1x_dev_free(struct snd_device *device) { - emu10k1x_t *chip = device->device_data; + struct emu10k1x *chip = device->device_data; return snd_emu10k1x_free(chip); } @@ -788,8 +784,8 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id, { unsigned int status; - emu10k1x_t *chip = dev_id; - emu10k1x_voice_t *pvoice = chip->voices; + struct emu10k1x *chip = dev_id; + struct emu10k1x_voice *pvoice = chip->voices; int i; int mask; @@ -800,8 +796,8 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id, // capture interrupt if (status & (IPR_CAP_0_LOOP | IPR_CAP_0_HALF_LOOP)) { - emu10k1x_voice_t *pvoice = &chip->capture_voice; - if(pvoice->use) + struct emu10k1x_voice *pvoice = &chip->capture_voice; + if (pvoice->use) snd_emu10k1x_pcm_interrupt(chip, pvoice); else snd_emu10k1x_intr_disable(chip, @@ -835,9 +831,9 @@ static irqreturn_t snd_emu10k1x_interrupt(int irq, void *dev_id, return IRQ_HANDLED; } -static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **rpcm) +static int __devinit snd_emu10k1x_pcm(struct emu10k1x *emu, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; int capture = 0; @@ -887,14 +883,14 @@ static int __devinit snd_emu10k1x_pcm(emu10k1x_t *emu, int device, snd_pcm_t **r return 0; } -static int __devinit snd_emu10k1x_create(snd_card_t *card, +static int __devinit snd_emu10k1x_create(struct snd_card *card, struct pci_dev *pci, - emu10k1x_t **rchip) + struct emu10k1x **rchip) { - emu10k1x_t *chip; + struct emu10k1x *chip; int err; int ch; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_emu10k1x_dev_free, }; @@ -1008,10 +1004,10 @@ static int __devinit snd_emu10k1x_create(snd_card_t *card, return 0; } -static void snd_emu10k1x_proc_reg_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_emu10k1x_proc_reg_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1x_t *emu = entry->private_data; + struct emu10k1x *emu = entry->private_data; unsigned long value,value1,value2; unsigned long flags; int i; @@ -1036,10 +1032,10 @@ static void snd_emu10k1x_proc_reg_read(snd_info_entry_t *entry, } } -static void snd_emu10k1x_proc_reg_write(snd_info_entry_t *entry, - snd_info_buffer_t *buffer) +static void snd_emu10k1x_proc_reg_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - emu10k1x_t *emu = entry->private_data; + struct emu10k1x *emu = entry->private_data; char line[64]; unsigned int reg, channel_id , val; @@ -1053,9 +1049,9 @@ static void snd_emu10k1x_proc_reg_write(snd_info_entry_t *entry, } } -static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu) +static int __devinit snd_emu10k1x_proc_init(struct emu10k1x * emu) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if(! snd_card_proc_new(emu->card, "emu10k1x_regs", &entry)) { snd_info_set_text_ops(entry, emu, 1024, snd_emu10k1x_proc_reg_read); @@ -1068,7 +1064,7 @@ static int __devinit snd_emu10k1x_proc_init(emu10k1x_t * emu) return 0; } -static int snd_emu10k1x_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1x_shared_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1077,20 +1073,20 @@ static int snd_emu10k1x_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_emu10k1x_shared_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_shared_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (snd_emu10k1x_ptr_read(emu, SPDIF_SELECT, 0) == 0x700) ? 0 : 1; return 0; } -static int snd_emu10k1x_shared_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_shared_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; @@ -1110,7 +1106,7 @@ static int snd_emu10k1x_shared_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1x_shared_spdif __devinitdata = +static struct snd_kcontrol_new snd_emu10k1x_shared_spdif __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Analog/Digital Output Jack", @@ -1119,17 +1115,17 @@ static snd_kcontrol_new_t snd_emu10k1x_shared_spdif __devinitdata = .put = snd_emu10k1x_shared_spdif_put }; -static int snd_emu10k1x_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_emu10k1x_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_emu10k1x_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff; @@ -1139,8 +1135,8 @@ static int snd_emu10k1x_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1x_spdif_get_mask(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_spdif_get_mask(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -1149,10 +1145,10 @@ static int snd_emu10k1x_spdif_get_mask(snd_kcontrol_t * kcontrol, return 0; } -static int snd_emu10k1x_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_emu10k1x_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - emu10k1x_t *emu = snd_kcontrol_chip(kcontrol); + struct emu10k1x *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); int change; unsigned int val; @@ -1169,7 +1165,7 @@ static int snd_emu10k1x_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_emu10k1x_spdif_mask_control = +static struct snd_kcontrol_new snd_emu10k1x_spdif_mask_control = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1179,7 +1175,7 @@ static snd_kcontrol_new_t snd_emu10k1x_spdif_mask_control = .get = snd_emu10k1x_spdif_get_mask }; -static snd_kcontrol_new_t snd_emu10k1x_spdif_control = +static struct snd_kcontrol_new snd_emu10k1x_spdif_control = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -1189,11 +1185,11 @@ static snd_kcontrol_new_t snd_emu10k1x_spdif_control = .put = snd_emu10k1x_spdif_put }; -static int __devinit snd_emu10k1x_mixer(emu10k1x_t *emu) +static int __devinit snd_emu10k1x_mixer(struct emu10k1x *emu) { int err; - snd_kcontrol_t *kctl; - snd_card_t *card = emu->card; + struct snd_kcontrol *kctl; + struct snd_card *card = emu->card; if ((kctl = snd_ctl_new1(&snd_emu10k1x_spdif_mask_control, emu)) == NULL) return -ENOMEM; @@ -1214,12 +1210,12 @@ static int __devinit snd_emu10k1x_mixer(emu10k1x_t *emu) #define EMU10K1X_MIDI_MODE_INPUT (1<<0) #define EMU10K1X_MIDI_MODE_OUTPUT (1<<1) -static inline unsigned char mpu401_read(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int idx) +static inline unsigned char mpu401_read(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int idx) { return (unsigned char)snd_emu10k1x_ptr_read(emu, mpu->port + idx, 0); } -static inline void mpu401_write(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int data, int idx) +static inline void mpu401_write(struct emu10k1x *emu, struct emu10k1x_midi *mpu, int data, int idx) { snd_emu10k1x_ptr_write(emu, mpu->port + idx, 0, data); } @@ -1236,7 +1232,7 @@ static inline void mpu401_write(emu10k1x_t *emu, emu10k1x_midi_t *mpu, int data, #define MPU401_ENTER_UART 0x3f #define MPU401_ACK 0xfe -static void mpu401_clear_rx(emu10k1x_t *emu, emu10k1x_midi_t *mpu) +static void mpu401_clear_rx(struct emu10k1x *emu, struct emu10k1x_midi *mpu) { int timeout = 100000; for (; timeout > 0 && mpu401_input_avail(emu, mpu); timeout--) @@ -1251,7 +1247,8 @@ static void mpu401_clear_rx(emu10k1x_t *emu, emu10k1x_midi_t *mpu) */ -static void do_emu10k1x_midi_interrupt(emu10k1x_t *emu, emu10k1x_midi_t *midi, unsigned int status) +static void do_emu10k1x_midi_interrupt(struct emu10k1x *emu, + struct emu10k1x_midi *midi, unsigned int status) { unsigned char byte; @@ -1284,12 +1281,13 @@ static void do_emu10k1x_midi_interrupt(emu10k1x_t *emu, emu10k1x_midi_t *midi, u spin_unlock(&midi->output_lock); } -static void snd_emu10k1x_midi_interrupt(emu10k1x_t *emu, unsigned int status) +static void snd_emu10k1x_midi_interrupt(struct emu10k1x *emu, unsigned int status) { do_emu10k1x_midi_interrupt(emu, &emu->midi, status); } -static void snd_emu10k1x_midi_cmd(emu10k1x_t * emu, emu10k1x_midi_t *midi, unsigned char cmd, int ack) +static void snd_emu10k1x_midi_cmd(struct emu10k1x * emu, + struct emu10k1x_midi *midi, unsigned char cmd, int ack) { unsigned long flags; int timeout, ok; @@ -1321,10 +1319,10 @@ static void snd_emu10k1x_midi_cmd(emu10k1x_t * emu, emu10k1x_midi_t *midi, unsig mpu401_read_data(emu, midi)); } -static int snd_emu10k1x_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_input_open(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1342,10 +1340,10 @@ static int snd_emu10k1x_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_output_open(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1363,10 +1361,10 @@ static int snd_emu10k1x_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_input_close(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1384,10 +1382,10 @@ static int snd_emu10k1x_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_emu10k1x_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_emu10k1x_midi_output_close(struct snd_rawmidi_substream *substream) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1405,10 +1403,10 @@ static int snd_emu10k1x_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_emu10k1x_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1x_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; emu = midi->emu; snd_assert(emu, return); @@ -1418,10 +1416,10 @@ static void snd_emu10k1x_midi_input_trigger(snd_rawmidi_substream_t * substream, snd_emu10k1x_intr_disable(emu, midi->rx_enable); } -static void snd_emu10k1x_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_emu10k1x_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - emu10k1x_t *emu; - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)substream->rmidi->private_data; + struct emu10k1x *emu; + struct emu10k1x_midi *midi = substream->rmidi->private_data; unsigned long flags; emu = midi->emu; @@ -1458,30 +1456,31 @@ static void snd_emu10k1x_midi_output_trigger(snd_rawmidi_substream_t * substream */ -static snd_rawmidi_ops_t snd_emu10k1x_midi_output = +static struct snd_rawmidi_ops snd_emu10k1x_midi_output = { .open = snd_emu10k1x_midi_output_open, .close = snd_emu10k1x_midi_output_close, .trigger = snd_emu10k1x_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_emu10k1x_midi_input = +static struct snd_rawmidi_ops snd_emu10k1x_midi_input = { .open = snd_emu10k1x_midi_input_open, .close = snd_emu10k1x_midi_input_close, .trigger = snd_emu10k1x_midi_input_trigger, }; -static void snd_emu10k1x_midi_free(snd_rawmidi_t *rmidi) +static void snd_emu10k1x_midi_free(struct snd_rawmidi *rmidi) { - emu10k1x_midi_t *midi = (emu10k1x_midi_t *)rmidi->private_data; + struct emu10k1x_midi *midi = rmidi->private_data; midi->interrupt = NULL; midi->rmidi = NULL; } -static int __devinit emu10k1x_midi_init(emu10k1x_t *emu, emu10k1x_midi_t *midi, int device, char *name) +static int __devinit emu10k1x_midi_init(struct emu10k1x *emu, + struct emu10k1x_midi *midi, int device, char *name) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if ((err = snd_rawmidi_new(emu->card, name, device, 1, 1, &rmidi)) < 0) @@ -1502,9 +1501,9 @@ static int __devinit emu10k1x_midi_init(emu10k1x_t *emu, emu10k1x_midi_t *midi, return 0; } -static int __devinit snd_emu10k1x_midi(emu10k1x_t *emu) +static int __devinit snd_emu10k1x_midi(struct emu10k1x *emu) { - emu10k1x_midi_t *midi = &emu->midi; + struct emu10k1x_midi *midi = &emu->midi; int err; if ((err = emu10k1x_midi_init(emu, midi, 0, "EMU10K1X MPU-401 (UART)")) < 0) @@ -1523,8 +1522,8 @@ static int __devinit snd_emu10k1x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - emu10k1x_t *chip; + struct snd_card *card; + struct emu10k1x *chip; int err; if (dev >= SNDRV_CARDS) -- cgit v1.1 From 55e957d8328ef1c75238b95033d8a61994b6adcc Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:52:13 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI HDSP Modules: RME HDSP driver Remove xxx_t typedefs from the PCI HDSP driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/hdsp.h | 51 ++-- sound/pci/rme9652/hdsp.c | 744 +++++++++++++++++++++++------------------------ 2 files changed, 394 insertions(+), 401 deletions(-) diff --git a/include/sound/hdsp.h b/include/sound/hdsp.h index 7ce3aa6..25e1951 100644 --- a/include/sound/hdsp.h +++ b/include/sound/hdsp.h @@ -21,17 +21,15 @@ #define HDSP_MATRIX_MIXER_SIZE 2048 -typedef enum { +enum HDSP_IO_Type { Digiface, Multiface, H9652, H9632, Undefined, -} HDSP_IO_Type; - -typedef struct _snd_hdsp_peak_rms hdsp_peak_rms_t; +}; -struct _snd_hdsp_peak_rms { +struct hdsp_peak_rms { u32 input_peaks[26]; u32 playback_peaks[26]; u32 output_peaks[28]; @@ -41,11 +39,9 @@ struct _snd_hdsp_peak_rms { u64 output_rms[26]; }; -#define SNDRV_HDSP_IOCTL_GET_PEAK_RMS _IOR('H', 0x40, hdsp_peak_rms_t) +#define SNDRV_HDSP_IOCTL_GET_PEAK_RMS _IOR('H', 0x40, struct hdsp_peak_rms) -typedef struct _snd_hdsp_config_info hdsp_config_info_t; - -struct _snd_hdsp_config_info { +struct hdsp_config_info { unsigned char pref_sync_ref; unsigned char wordclock_sync_check; unsigned char spdif_sync_check; @@ -71,40 +67,41 @@ struct _snd_hdsp_config_info { unsigned char analog_extension_board; }; -#define SNDRV_HDSP_IOCTL_GET_CONFIG_INFO _IOR('H', 0x41, hdsp_config_info_t) - -typedef struct _snd_hdsp_firmware hdsp_firmware_t; +#define SNDRV_HDSP_IOCTL_GET_CONFIG_INFO _IOR('H', 0x41, struct hdsp_config_info) -struct _snd_hdsp_firmware { +struct hdsp_firmware { void __user *firmware_data; /* 24413 x 4 bytes */ }; -#define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW('H', 0x42, hdsp_firmware_t) +#define SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE _IOW('H', 0x42, struct hdsp_firmware) -typedef struct _snd_hdsp_version hdsp_version_t; - -struct _snd_hdsp_version { - HDSP_IO_Type io_type; +struct hdsp_version { + enum HDSP_IO_Type io_type; unsigned short firmware_rev; }; -#define SNDRV_HDSP_IOCTL_GET_VERSION _IOR('H', 0x43, hdsp_version_t) - -typedef struct _snd_hdsp_mixer hdsp_mixer_t; +#define SNDRV_HDSP_IOCTL_GET_VERSION _IOR('H', 0x43, struct hdsp_version) -struct _snd_hdsp_mixer { +struct hdsp_mixer { unsigned short matrix[HDSP_MATRIX_MIXER_SIZE]; }; -#define SNDRV_HDSP_IOCTL_GET_MIXER _IOR('H', 0x44, hdsp_mixer_t) +#define SNDRV_HDSP_IOCTL_GET_MIXER _IOR('H', 0x44, struct hdsp_mixer) -typedef struct _snd_hdsp_9632_aeb hdsp_9632_aeb_t; - -struct _snd_hdsp_9632_aeb { +struct hdsp_9632_aeb { int aebi; int aebo; }; -#define SNDRV_HDSP_IOCTL_GET_9632_AEB _IOR('H', 0x45, hdsp_9632_aeb_t) +#define SNDRV_HDSP_IOCTL_GET_9632_AEB _IOR('H', 0x45, struct hdsp_9632_aeb) + +/* typedefs for compatibility to user-space */ +typedef enum HDSP_IO_Type HDSP_IO_Type; +typedef struct hdsp_peak_rms hdsp_peak_rms_t; +typedef struct hdsp_config_info hdsp_config_info_t; +typedef struct hdsp_firmware hdsp_firmware_t; +typedef struct hdsp_version hdsp_version_t; +typedef struct hdsp_mixer hdsp_mixer_t; +typedef struct hdsp_9632_aeb hdsp_9632_aeb_t; #endif /* __SOUND_HDSP_H */ diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index d15ffb3..ebf7a2b 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c @@ -394,11 +394,7 @@ MODULE_SUPPORTED_DEVICE("{{RME Hammerfall-DSP}," #endif #endif -typedef struct _hdsp hdsp_t; -typedef struct _hdsp_midi hdsp_midi_t; -typedef struct _hdsp_9632_meters hdsp_9632_meters_t; - -struct _hdsp_9632_meters { +struct hdsp_9632_meters { u32 input_peak[16]; u32 playback_peak[16]; u32 output_peak[16]; @@ -414,23 +410,23 @@ struct _hdsp_9632_meters { u32 xxx_rms_high[16]; }; -struct _hdsp_midi { - hdsp_t *hdsp; +struct hdsp_midi { + struct hdsp *hdsp; int id; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *input; - snd_rawmidi_substream_t *output; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *input; + struct snd_rawmidi_substream *output; char istimer; /* timer in use */ struct timer_list timer; spinlock_t lock; int pending; }; -struct _hdsp { +struct hdsp { spinlock_t lock; - snd_pcm_substream_t *capture_substream; - snd_pcm_substream_t *playback_substream; - hdsp_midi_t midi[2]; + struct snd_pcm_substream *capture_substream; + struct snd_pcm_substream *playback_substream; + struct hdsp_midi midi[2]; struct tasklet_struct midi_tasklet; int use_midi_tasklet; int precise_ptr; @@ -440,7 +436,7 @@ struct _hdsp { u32 creg_spdif_stream; int clock_source_locked; char *card_name; /* digiface/multiface */ - HDSP_IO_Type io_type; /* ditto, but for code use */ + enum HDSP_IO_Type io_type; /* ditto, but for code use */ unsigned short firmware_rev; unsigned short state; /* stores state bits */ u32 firmware_cache[24413]; /* this helps recover from accidental iobox power failure */ @@ -467,11 +463,11 @@ struct _hdsp { int irq; unsigned long port; void __iomem *iobase; - snd_card_t *card; - snd_pcm_t *pcm; - snd_hwdep_t *hwdep; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_hwdep *hwdep; struct pci_dev *pci; - snd_kcontrol_t *spdif_ctl; + struct snd_kcontrol *spdif_ctl; unsigned short mixer_matrix[HDSP_MATRIX_MIXER_SIZE]; }; @@ -585,17 +581,17 @@ static struct pci_device_id snd_hdsp_ids[] = { MODULE_DEVICE_TABLE(pci, snd_hdsp_ids); /* prototypes */ -static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp); -static int snd_hdsp_create_pcm(snd_card_t *card, hdsp_t *hdsp); -static int snd_hdsp_enable_io (hdsp_t *hdsp); -static void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp); -static void snd_hdsp_initialize_channels (hdsp_t *hdsp); -static int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout); -static int hdsp_autosync_ref(hdsp_t *hdsp); -static int snd_hdsp_set_defaults(hdsp_t *hdsp); -static void snd_hdsp_9652_enable_mixer (hdsp_t *hdsp); - -static int hdsp_playback_to_output_key (hdsp_t *hdsp, int in, int out) +static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp); +static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp); +static int snd_hdsp_enable_io (struct hdsp *hdsp); +static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp); +static void snd_hdsp_initialize_channels (struct hdsp *hdsp); +static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout); +static int hdsp_autosync_ref(struct hdsp *hdsp); +static int snd_hdsp_set_defaults(struct hdsp *hdsp); +static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp); + +static int hdsp_playback_to_output_key (struct hdsp *hdsp, int in, int out) { switch (hdsp->firmware_rev) { case 0xa: @@ -608,7 +604,7 @@ static int hdsp_playback_to_output_key (hdsp_t *hdsp, int in, int out) } } -static int hdsp_input_to_output_key (hdsp_t *hdsp, int in, int out) +static int hdsp_input_to_output_key (struct hdsp *hdsp, int in, int out) { switch (hdsp->firmware_rev) { case 0xa: @@ -621,17 +617,17 @@ static int hdsp_input_to_output_key (hdsp_t *hdsp, int in, int out) } } -static void hdsp_write(hdsp_t *hdsp, int reg, int val) +static void hdsp_write(struct hdsp *hdsp, int reg, int val) { writel(val, hdsp->iobase + reg); } -static unsigned int hdsp_read(hdsp_t *hdsp, int reg) +static unsigned int hdsp_read(struct hdsp *hdsp, int reg) { return readl (hdsp->iobase + reg); } -static int hdsp_check_for_iobox (hdsp_t *hdsp) +static int hdsp_check_for_iobox (struct hdsp *hdsp) { if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0; @@ -644,7 +640,7 @@ static int hdsp_check_for_iobox (hdsp_t *hdsp) } -static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) { +static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) { int i; unsigned long flags; @@ -699,7 +695,7 @@ static int snd_hdsp_load_firmware_from_cache(hdsp_t *hdsp) { return 0; } -static int hdsp_get_iobox_version (hdsp_t *hdsp) +static int hdsp_get_iobox_version (struct hdsp *hdsp) { if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { @@ -730,7 +726,7 @@ static int hdsp_get_iobox_version (hdsp_t *hdsp) } -static int hdsp_check_for_firmware (hdsp_t *hdsp, int show_err) +static int hdsp_check_for_firmware (struct hdsp *hdsp, int show_err) { if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0; if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { @@ -751,7 +747,7 @@ static int hdsp_check_for_firmware (hdsp_t *hdsp, int show_err) } -static int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout) +static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout) { int i; @@ -776,7 +772,7 @@ static int hdsp_fifo_wait(hdsp_t *hdsp, int count, int timeout) return -1; } -static int hdsp_read_gain (hdsp_t *hdsp, unsigned int addr) +static int hdsp_read_gain (struct hdsp *hdsp, unsigned int addr) { if (addr >= HDSP_MATRIX_MIXER_SIZE) return 0; @@ -784,7 +780,7 @@ static int hdsp_read_gain (hdsp_t *hdsp, unsigned int addr) return hdsp->mixer_matrix[addr]; } -static int hdsp_write_gain(hdsp_t *hdsp, unsigned int addr, unsigned short data) +static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short data) { unsigned int ad; @@ -844,7 +840,7 @@ static int hdsp_write_gain(hdsp_t *hdsp, unsigned int addr, unsigned short data) return 0; } -static int snd_hdsp_use_is_exclusive(hdsp_t *hdsp) +static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp) { unsigned long flags; int ret = 1; @@ -857,7 +853,7 @@ static int snd_hdsp_use_is_exclusive(hdsp_t *hdsp) return ret; } -static int hdsp_external_sample_rate (hdsp_t *hdsp) +static int hdsp_external_sample_rate (struct hdsp *hdsp) { unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); unsigned int rate_bits = status2 & HDSP_systemFrequencyMask; @@ -874,7 +870,7 @@ static int hdsp_external_sample_rate (hdsp_t *hdsp) } } -static int hdsp_spdif_sample_rate(hdsp_t *hdsp) +static int hdsp_spdif_sample_rate(struct hdsp *hdsp) { unsigned int status = hdsp_read(hdsp, HDSP_statusRegister); unsigned int rate_bits = (status & HDSP_spdifFrequencyMask); @@ -905,12 +901,12 @@ static int hdsp_spdif_sample_rate(hdsp_t *hdsp) return 0; } -static void hdsp_compute_period_size(hdsp_t *hdsp) +static void hdsp_compute_period_size(struct hdsp *hdsp) { hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8)); } -static snd_pcm_uframes_t hdsp_hw_pointer(hdsp_t *hdsp) +static snd_pcm_uframes_t hdsp_hw_pointer(struct hdsp *hdsp) { int position; @@ -925,29 +921,29 @@ static snd_pcm_uframes_t hdsp_hw_pointer(hdsp_t *hdsp) return position; } -static void hdsp_reset_hw_pointer(hdsp_t *hdsp) +static void hdsp_reset_hw_pointer(struct hdsp *hdsp) { hdsp_write (hdsp, HDSP_resetPointer, 0); } -static void hdsp_start_audio(hdsp_t *s) +static void hdsp_start_audio(struct hdsp *s) { s->control_register |= (HDSP_AudioInterruptEnable | HDSP_Start); hdsp_write(s, HDSP_controlRegister, s->control_register); } -static void hdsp_stop_audio(hdsp_t *s) +static void hdsp_stop_audio(struct hdsp *s) { s->control_register &= ~(HDSP_Start | HDSP_AudioInterruptEnable); hdsp_write(s, HDSP_controlRegister, s->control_register); } -static void hdsp_silence_playback(hdsp_t *hdsp) +static void hdsp_silence_playback(struct hdsp *hdsp) { memset(hdsp->playback_buffer, 0, HDSP_DMA_AREA_BYTES); } -static int hdsp_set_interrupt_interval(hdsp_t *s, unsigned int frames) +static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames) { int n; @@ -972,7 +968,7 @@ static int hdsp_set_interrupt_interval(hdsp_t *s, unsigned int frames) return 0; } -static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally) +static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally) { int reject_if_open = 0; int current_rate; @@ -1114,7 +1110,7 @@ static int hdsp_set_rate(hdsp_t *hdsp, int rate, int called_internally) MIDI ----------------------------------------------------------------------------*/ -static unsigned char snd_hdsp_midi_read_byte (hdsp_t *hdsp, int id) +static unsigned char snd_hdsp_midi_read_byte (struct hdsp *hdsp, int id) { /* the hardware already does the relevant bit-mask with 0xff */ if (id) @@ -1123,7 +1119,7 @@ static unsigned char snd_hdsp_midi_read_byte (hdsp_t *hdsp, int id) return hdsp_read(hdsp, HDSP_midiDataIn0); } -static void snd_hdsp_midi_write_byte (hdsp_t *hdsp, int id, int val) +static void snd_hdsp_midi_write_byte (struct hdsp *hdsp, int id, int val) { /* the hardware already does the relevant bit-mask with 0xff */ if (id) @@ -1132,7 +1128,7 @@ static void snd_hdsp_midi_write_byte (hdsp_t *hdsp, int id, int val) hdsp_write(hdsp, HDSP_midiDataOut0, val); } -static int snd_hdsp_midi_input_available (hdsp_t *hdsp, int id) +static int snd_hdsp_midi_input_available (struct hdsp *hdsp, int id) { if (id) return (hdsp_read(hdsp, HDSP_midiStatusIn1) & 0xff); @@ -1140,7 +1136,7 @@ static int snd_hdsp_midi_input_available (hdsp_t *hdsp, int id) return (hdsp_read(hdsp, HDSP_midiStatusIn0) & 0xff); } -static int snd_hdsp_midi_output_possible (hdsp_t *hdsp, int id) +static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id) { int fifo_bytes_used; @@ -1155,13 +1151,13 @@ static int snd_hdsp_midi_output_possible (hdsp_t *hdsp, int id) return 0; } -static void snd_hdsp_flush_midi_input (hdsp_t *hdsp, int id) +static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id) { while (snd_hdsp_midi_input_available (hdsp, id)) snd_hdsp_midi_read_byte (hdsp, id); } -static int snd_hdsp_midi_output_write (hdsp_midi_t *hmidi) +static int snd_hdsp_midi_output_write (struct hdsp_midi *hmidi) { unsigned long flags; int n_pending; @@ -1189,7 +1185,7 @@ static int snd_hdsp_midi_output_write (hdsp_midi_t *hmidi) return 0; } -static int snd_hdsp_midi_input_read (hdsp_midi_t *hmidi) +static int snd_hdsp_midi_input_read (struct hdsp_midi *hmidi) { unsigned char buf[128]; /* this buffer is designed to match the MIDI input FIFO size */ unsigned long flags; @@ -1221,14 +1217,14 @@ static int snd_hdsp_midi_input_read (hdsp_midi_t *hmidi) return snd_hdsp_midi_output_write (hmidi); } -static void snd_hdsp_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_hdsp_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - hdsp_t *hdsp; - hdsp_midi_t *hmidi; + struct hdsp *hdsp; + struct hdsp_midi *hmidi; unsigned long flags; u32 ie; - hmidi = (hdsp_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdsp_midi *) substream->rmidi->private_data; hdsp = hmidi->hdsp; ie = hmidi->id ? HDSP_Midi1InterruptEnable : HDSP_Midi0InterruptEnable; spin_lock_irqsave (&hdsp->lock, flags); @@ -1248,7 +1244,7 @@ static void snd_hdsp_midi_input_trigger(snd_rawmidi_substream_t * substream, int static void snd_hdsp_midi_output_timer(unsigned long data) { - hdsp_midi_t *hmidi = (hdsp_midi_t *) data; + struct hdsp_midi *hmidi = (struct hdsp_midi *) data; unsigned long flags; snd_hdsp_midi_output_write(hmidi); @@ -1268,12 +1264,12 @@ static void snd_hdsp_midi_output_timer(unsigned long data) spin_unlock_irqrestore (&hmidi->lock, flags); } -static void snd_hdsp_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_hdsp_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - hdsp_midi_t *hmidi; + struct hdsp_midi *hmidi; unsigned long flags; - hmidi = (hdsp_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdsp_midi *) substream->rmidi->private_data; spin_lock_irqsave (&hmidi->lock, flags); if (up) { if (!hmidi->istimer) { @@ -1293,11 +1289,11 @@ static void snd_hdsp_midi_output_trigger(snd_rawmidi_substream_t * substream, in snd_hdsp_midi_output_write(hmidi); } -static int snd_hdsp_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_hdsp_midi_input_open(struct snd_rawmidi_substream *substream) { - hdsp_midi_t *hmidi; + struct hdsp_midi *hmidi; - hmidi = (hdsp_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdsp_midi *) substream->rmidi->private_data; spin_lock_irq (&hmidi->lock); snd_hdsp_flush_midi_input (hmidi->hdsp, hmidi->id); hmidi->input = substream; @@ -1306,11 +1302,11 @@ static int snd_hdsp_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_hdsp_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_hdsp_midi_output_open(struct snd_rawmidi_substream *substream) { - hdsp_midi_t *hmidi; + struct hdsp_midi *hmidi; - hmidi = (hdsp_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdsp_midi *) substream->rmidi->private_data; spin_lock_irq (&hmidi->lock); hmidi->output = substream; spin_unlock_irq (&hmidi->lock); @@ -1318,13 +1314,13 @@ static int snd_hdsp_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_hdsp_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_hdsp_midi_input_close(struct snd_rawmidi_substream *substream) { - hdsp_midi_t *hmidi; + struct hdsp_midi *hmidi; snd_hdsp_midi_input_trigger (substream, 0); - hmidi = (hdsp_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdsp_midi *) substream->rmidi->private_data; spin_lock_irq (&hmidi->lock); hmidi->input = NULL; spin_unlock_irq (&hmidi->lock); @@ -1332,13 +1328,13 @@ static int snd_hdsp_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_hdsp_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_hdsp_midi_output_close(struct snd_rawmidi_substream *substream) { - hdsp_midi_t *hmidi; + struct hdsp_midi *hmidi; snd_hdsp_midi_output_trigger (substream, 0); - hmidi = (hdsp_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdsp_midi *) substream->rmidi->private_data; spin_lock_irq (&hmidi->lock); hmidi->output = NULL; spin_unlock_irq (&hmidi->lock); @@ -1346,21 +1342,21 @@ static int snd_hdsp_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static snd_rawmidi_ops_t snd_hdsp_midi_output = +static struct snd_rawmidi_ops snd_hdsp_midi_output = { .open = snd_hdsp_midi_output_open, .close = snd_hdsp_midi_output_close, .trigger = snd_hdsp_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_hdsp_midi_input = +static struct snd_rawmidi_ops snd_hdsp_midi_input = { .open = snd_hdsp_midi_input_open, .close = snd_hdsp_midi_input_close, .trigger = snd_hdsp_midi_input_trigger, }; -static int __devinit snd_hdsp_create_midi (snd_card_t *card, hdsp_t *hdsp, int id) +static int __devinit snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id) { char buf[32]; @@ -1394,7 +1390,7 @@ static int __devinit snd_hdsp_create_midi (snd_card_t *card, hdsp_t *hdsp, int i Control Interface ----------------------------------------------------------------------------*/ -static u32 snd_hdsp_convert_from_aes(snd_aes_iec958_t *aes) +static u32 snd_hdsp_convert_from_aes(struct snd_aes_iec958 *aes) { u32 val = 0; val |= (aes->status[0] & IEC958_AES0_PROFESSIONAL) ? HDSP_SPDIFProfessional : 0; @@ -1406,7 +1402,7 @@ static u32 snd_hdsp_convert_from_aes(snd_aes_iec958_t *aes) return val; } -static void snd_hdsp_convert_to_aes(snd_aes_iec958_t *aes, u32 val) +static void snd_hdsp_convert_to_aes(struct snd_aes_iec958 *aes, u32 val) { aes->status[0] = ((val & HDSP_SPDIFProfessional) ? IEC958_AES0_PROFESSIONAL : 0) | ((val & HDSP_SPDIFNonAudio) ? IEC958_AES0_NONAUDIO : 0); @@ -1416,24 +1412,24 @@ static void snd_hdsp_convert_to_aes(snd_aes_iec958_t *aes, u32 val) aes->status[0] |= (val & HDSP_SPDIFEmphasis) ? IEC958_AES0_CON_EMPHASIS_5015 : 0; } -static int snd_hdsp_control_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_control_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_hdsp_control_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif); return 0; } -static int snd_hdsp_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_control_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; u32 val; @@ -1445,24 +1441,24 @@ static int snd_hdsp_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_va return change; } -static int snd_hdsp_control_spdif_stream_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_control_spdif_stream_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_hdsp_control_spdif_stream_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream); return 0; } -static int snd_hdsp_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_control_spdif_stream_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; u32 val; @@ -1476,14 +1472,14 @@ static int snd_hdsp_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_ return change; } -static int snd_hdsp_control_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_control_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_hdsp_control_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_control_spdif_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = kcontrol->private_value; return 0; @@ -1497,12 +1493,12 @@ static int snd_hdsp_control_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_el .get = snd_hdsp_get_spdif_in, \ .put = snd_hdsp_put_spdif_in } -static unsigned int hdsp_spdif_in(hdsp_t *hdsp) +static unsigned int hdsp_spdif_in(struct hdsp *hdsp) { return hdsp_decode_spdif_in(hdsp->control_register & HDSP_SPDIFInputMask); } -static int hdsp_set_spdif_input(hdsp_t *hdsp, int in) +static int hdsp_set_spdif_input(struct hdsp *hdsp, int in) { hdsp->control_register &= ~HDSP_SPDIFInputMask; hdsp->control_register |= hdsp_encode_spdif_in(in); @@ -1510,10 +1506,10 @@ static int hdsp_set_spdif_input(hdsp_t *hdsp, int in) return 0; } -static int snd_hdsp_info_spdif_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = {"Optical", "Coaxial", "Internal", "AES"}; - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -1524,17 +1520,17 @@ static int snd_hdsp_info_spdif_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_hdsp_get_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp); return 0; } -static int snd_hdsp_put_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1554,12 +1550,12 @@ static int snd_hdsp_put_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .info = snd_hdsp_info_spdif_bits, \ .get = snd_hdsp_get_spdif_out, .put = snd_hdsp_put_spdif_out } -static int hdsp_spdif_out(hdsp_t *hdsp) +static int hdsp_spdif_out(struct hdsp *hdsp) { return (hdsp->control_register & HDSP_SPDIFOpticalOut) ? 1 : 0; } -static int hdsp_set_spdif_output(hdsp_t *hdsp, int out) +static int hdsp_set_spdif_output(struct hdsp *hdsp, int out) { if (out) hdsp->control_register |= HDSP_SPDIFOpticalOut; @@ -1569,7 +1565,7 @@ static int hdsp_set_spdif_output(hdsp_t *hdsp, int out) return 0; } -static int snd_hdsp_info_spdif_bits(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_spdif_bits(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1578,17 +1574,17 @@ static int snd_hdsp_info_spdif_bits(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_hdsp_get_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = hdsp_spdif_out(hdsp); return 0; } -static int snd_hdsp_put_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1607,12 +1603,12 @@ static int snd_hdsp_put_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .info = snd_hdsp_info_spdif_bits, \ .get = snd_hdsp_get_spdif_professional, .put = snd_hdsp_put_spdif_professional } -static int hdsp_spdif_professional(hdsp_t *hdsp) +static int hdsp_spdif_professional(struct hdsp *hdsp) { return (hdsp->control_register & HDSP_SPDIFProfessional) ? 1 : 0; } -static int hdsp_set_spdif_professional(hdsp_t *hdsp, int val) +static int hdsp_set_spdif_professional(struct hdsp *hdsp, int val) { if (val) hdsp->control_register |= HDSP_SPDIFProfessional; @@ -1622,17 +1618,17 @@ static int hdsp_set_spdif_professional(hdsp_t *hdsp, int val) return 0; } -static int snd_hdsp_get_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = hdsp_spdif_professional(hdsp); return 0; } -static int snd_hdsp_put_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_spdif_professional(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1651,12 +1647,12 @@ static int snd_hdsp_put_spdif_professional(snd_kcontrol_t * kcontrol, snd_ctl_el .info = snd_hdsp_info_spdif_bits, \ .get = snd_hdsp_get_spdif_emphasis, .put = snd_hdsp_put_spdif_emphasis } -static int hdsp_spdif_emphasis(hdsp_t *hdsp) +static int hdsp_spdif_emphasis(struct hdsp *hdsp) { return (hdsp->control_register & HDSP_SPDIFEmphasis) ? 1 : 0; } -static int hdsp_set_spdif_emphasis(hdsp_t *hdsp, int val) +static int hdsp_set_spdif_emphasis(struct hdsp *hdsp, int val) { if (val) hdsp->control_register |= HDSP_SPDIFEmphasis; @@ -1666,17 +1662,17 @@ static int hdsp_set_spdif_emphasis(hdsp_t *hdsp, int val) return 0; } -static int snd_hdsp_get_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = hdsp_spdif_emphasis(hdsp); return 0; } -static int snd_hdsp_put_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_spdif_emphasis(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1695,12 +1691,12 @@ static int snd_hdsp_put_spdif_emphasis(snd_kcontrol_t * kcontrol, snd_ctl_elem_v .info = snd_hdsp_info_spdif_bits, \ .get = snd_hdsp_get_spdif_nonaudio, .put = snd_hdsp_put_spdif_nonaudio } -static int hdsp_spdif_nonaudio(hdsp_t *hdsp) +static int hdsp_spdif_nonaudio(struct hdsp *hdsp) { return (hdsp->control_register & HDSP_SPDIFNonAudio) ? 1 : 0; } -static int hdsp_set_spdif_nonaudio(hdsp_t *hdsp, int val) +static int hdsp_set_spdif_nonaudio(struct hdsp *hdsp, int val) { if (val) hdsp->control_register |= HDSP_SPDIFNonAudio; @@ -1710,17 +1706,17 @@ static int hdsp_set_spdif_nonaudio(hdsp_t *hdsp, int val) return 0; } -static int snd_hdsp_get_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = hdsp_spdif_nonaudio(hdsp); return 0; } -static int snd_hdsp_put_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_spdif_nonaudio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1743,10 +1739,10 @@ static int snd_hdsp_put_spdif_nonaudio(snd_kcontrol_t * kcontrol, snd_ctl_elem_v .get = snd_hdsp_get_spdif_sample_rate \ } -static int snd_hdsp_info_spdif_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"}; - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -1757,9 +1753,9 @@ static int snd_hdsp_info_spdif_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_hdsp_get_spdif_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_spdif_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); switch (hdsp_spdif_sample_rate(hdsp)) { case 32000: @@ -1804,16 +1800,16 @@ static int snd_hdsp_get_spdif_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_ele .get = snd_hdsp_get_system_sample_rate \ } -static int snd_hdsp_info_system_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; return 0; } -static int snd_hdsp_get_system_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_system_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate; return 0; @@ -1828,9 +1824,9 @@ static int snd_hdsp_get_system_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_el .get = snd_hdsp_get_autosync_sample_rate \ } -static int snd_hdsp_info_autosync_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); static char *texts[] = {"32000", "44100", "48000", "64000", "88200", "96000", "None", "128000", "176400", "192000"}; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -1841,9 +1837,9 @@ static int snd_hdsp_info_autosync_sample_rate(snd_kcontrol_t *kcontrol, snd_ctl_ return 0; } -static int snd_hdsp_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); switch (hdsp_external_sample_rate(hdsp)) { case 32000: @@ -1888,7 +1884,7 @@ static int snd_hdsp_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, snd_ctl_ .get = snd_hdsp_get_system_clock_mode \ } -static int hdsp_system_clock_mode(hdsp_t *hdsp) +static int hdsp_system_clock_mode(struct hdsp *hdsp) { if (hdsp->control_register & HDSP_ClockModeMaster) return 0; @@ -1897,7 +1893,7 @@ static int hdsp_system_clock_mode(hdsp_t *hdsp) return 1; } -static int snd_hdsp_info_system_clock_mode(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"Master", "Slave" }; @@ -1910,9 +1906,9 @@ static int snd_hdsp_info_system_clock_mode(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_hdsp_get_system_clock_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_system_clock_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp); return 0; @@ -1927,7 +1923,7 @@ static int snd_hdsp_get_system_clock_mode(snd_kcontrol_t * kcontrol, snd_ctl_ele .put = snd_hdsp_put_clock_source \ } -static int hdsp_clock_source(hdsp_t *hdsp) +static int hdsp_clock_source(struct hdsp *hdsp) { if (hdsp->control_register & HDSP_ClockModeMaster) { switch (hdsp->system_sample_rate) { @@ -1957,7 +1953,7 @@ static int hdsp_clock_source(hdsp_t *hdsp) } } -static int hdsp_set_clock_source(hdsp_t *hdsp, int mode) +static int hdsp_set_clock_source(struct hdsp *hdsp, int mode) { int rate; switch (mode) { @@ -2006,10 +2002,10 @@ static int hdsp_set_clock_source(hdsp_t *hdsp, int mode) return 0; } -static int snd_hdsp_info_clock_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", "Internal 48.0 kHz", "Internal 64.0 kHz", "Internal 88.2 kHz", "Internal 96.0 kHz", "Internal 128 kHz", "Internal 176.4 kHz", "Internal 192.0 KHz" }; - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -2023,17 +2019,17 @@ static int snd_hdsp_info_clock_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_hdsp_get_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp); return 0; } -static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_clock_source(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; int val; @@ -2057,7 +2053,7 @@ static int snd_hdsp_put_clock_source(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return change; } -static int snd_hdsp_info_clock_source_lock(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2066,17 +2062,17 @@ static int snd_hdsp_info_clock_source_lock(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_hdsp_get_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = hdsp->clock_source_locked; return 0; } -static int snd_hdsp_put_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_clock_source_lock(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked; @@ -2094,7 +2090,7 @@ static int snd_hdsp_put_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_ele .put = snd_hdsp_put_da_gain \ } -static int hdsp_da_gain(hdsp_t *hdsp) +static int hdsp_da_gain(struct hdsp *hdsp) { switch (hdsp->control_register & HDSP_DAGainMask) { case HDSP_DAGainHighGain: @@ -2108,7 +2104,7 @@ static int hdsp_da_gain(hdsp_t *hdsp) } } -static int hdsp_set_da_gain(hdsp_t *hdsp, int mode) +static int hdsp_set_da_gain(struct hdsp *hdsp, int mode) { hdsp->control_register &= ~HDSP_DAGainMask; switch (mode) { @@ -2129,7 +2125,7 @@ static int hdsp_set_da_gain(hdsp_t *hdsp, int mode) return 0; } -static int snd_hdsp_info_da_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"Hi Gain", "+4 dBu", "-10 dbV"}; @@ -2142,17 +2138,17 @@ static int snd_hdsp_info_da_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_hdsp_get_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp); return 0; } -static int snd_hdsp_put_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_da_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; int val; @@ -2179,7 +2175,7 @@ static int snd_hdsp_put_da_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .put = snd_hdsp_put_ad_gain \ } -static int hdsp_ad_gain(hdsp_t *hdsp) +static int hdsp_ad_gain(struct hdsp *hdsp) { switch (hdsp->control_register & HDSP_ADGainMask) { case HDSP_ADGainMinus10dBV: @@ -2193,7 +2189,7 @@ static int hdsp_ad_gain(hdsp_t *hdsp) } } -static int hdsp_set_ad_gain(hdsp_t *hdsp, int mode) +static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode) { hdsp->control_register &= ~HDSP_ADGainMask; switch (mode) { @@ -2214,7 +2210,7 @@ static int hdsp_set_ad_gain(hdsp_t *hdsp, int mode) return 0; } -static int snd_hdsp_info_ad_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"-10 dBV", "+4 dBu", "Lo Gain"}; @@ -2227,17 +2223,17 @@ static int snd_hdsp_info_ad_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_hdsp_get_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp); return 0; } -static int snd_hdsp_put_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_ad_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; int val; @@ -2264,7 +2260,7 @@ static int snd_hdsp_put_ad_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .put = snd_hdsp_put_phone_gain \ } -static int hdsp_phone_gain(hdsp_t *hdsp) +static int hdsp_phone_gain(struct hdsp *hdsp) { switch (hdsp->control_register & HDSP_PhoneGainMask) { case HDSP_PhoneGain0dB: @@ -2278,7 +2274,7 @@ static int hdsp_phone_gain(hdsp_t *hdsp) } } -static int hdsp_set_phone_gain(hdsp_t *hdsp, int mode) +static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode) { hdsp->control_register &= ~HDSP_PhoneGainMask; switch (mode) { @@ -2299,7 +2295,7 @@ static int hdsp_set_phone_gain(hdsp_t *hdsp, int mode) return 0; } -static int snd_hdsp_info_phone_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"0 dB", "-6 dB", "-12 dB"}; @@ -2312,17 +2308,17 @@ static int snd_hdsp_info_phone_gain(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_hdsp_get_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp); return 0; } -static int snd_hdsp_put_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_phone_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; int val; @@ -2349,14 +2345,14 @@ static int snd_hdsp_put_phone_gain(snd_kcontrol_t * kcontrol, snd_ctl_elem_value .put = snd_hdsp_put_xlr_breakout_cable \ } -static int hdsp_xlr_breakout_cable(hdsp_t *hdsp) +static int hdsp_xlr_breakout_cable(struct hdsp *hdsp) { if (hdsp->control_register & HDSP_XLRBreakoutCable) return 1; return 0; } -static int hdsp_set_xlr_breakout_cable(hdsp_t *hdsp, int mode) +static int hdsp_set_xlr_breakout_cable(struct hdsp *hdsp, int mode) { if (mode) hdsp->control_register |= HDSP_XLRBreakoutCable; @@ -2366,7 +2362,7 @@ static int hdsp_set_xlr_breakout_cable(hdsp_t *hdsp, int mode) return 0; } -static int snd_hdsp_info_xlr_breakout_cable(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2375,17 +2371,17 @@ static int snd_hdsp_info_xlr_breakout_cable(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_hdsp_get_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_xlr_breakout_cable(hdsp); return 0; } -static int snd_hdsp_put_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_xlr_breakout_cable(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; int val; @@ -2412,14 +2408,14 @@ static int snd_hdsp_put_xlr_breakout_cable(snd_kcontrol_t * kcontrol, snd_ctl_el .put = snd_hdsp_put_aeb \ } -static int hdsp_aeb(hdsp_t *hdsp) +static int hdsp_aeb(struct hdsp *hdsp) { if (hdsp->control_register & HDSP_AnalogExtensionBoard) return 1; return 0; } -static int hdsp_set_aeb(hdsp_t *hdsp, int mode) +static int hdsp_set_aeb(struct hdsp *hdsp, int mode) { if (mode) hdsp->control_register |= HDSP_AnalogExtensionBoard; @@ -2429,7 +2425,7 @@ static int hdsp_set_aeb(hdsp_t *hdsp, int mode) return 0; } -static int snd_hdsp_info_aeb(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2438,17 +2434,17 @@ static int snd_hdsp_info_aeb(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uin return 0; } -static int snd_hdsp_get_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_aeb(hdsp); return 0; } -static int snd_hdsp_put_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_aeb(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; int val; @@ -2471,7 +2467,7 @@ static int snd_hdsp_put_aeb(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uc .put = snd_hdsp_put_pref_sync_ref \ } -static int hdsp_pref_sync_ref(hdsp_t *hdsp) +static int hdsp_pref_sync_ref(struct hdsp *hdsp) { /* Notice that this looks at the requested sync source, not the one actually in use. @@ -2496,7 +2492,7 @@ static int hdsp_pref_sync_ref(hdsp_t *hdsp) return 0; } -static int hdsp_set_pref_sync_ref(hdsp_t *hdsp, int pref) +static int hdsp_set_pref_sync_ref(struct hdsp *hdsp, int pref) { hdsp->control_register &= ~HDSP_SyncRefMask; switch (pref) { @@ -2525,10 +2521,10 @@ static int hdsp_set_pref_sync_ref(hdsp_t *hdsp, int pref) return 0; } -static int snd_hdsp_info_pref_sync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"Word", "IEC958", "ADAT1", "ADAT Sync", "ADAT2", "ADAT3" }; - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -2555,17 +2551,17 @@ static int snd_hdsp_info_pref_sync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_in return 0; } -static int snd_hdsp_get_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); return 0; } -static int snd_hdsp_put_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_pref_sync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change, max; unsigned int val; @@ -2604,7 +2600,7 @@ static int snd_hdsp_put_pref_sync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_va .get = snd_hdsp_get_autosync_ref, \ } -static int hdsp_autosync_ref(hdsp_t *hdsp) +static int hdsp_autosync_ref(struct hdsp *hdsp) { /* This looks at the autosync selected sync reference */ unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); @@ -2630,7 +2626,7 @@ static int hdsp_autosync_ref(hdsp_t *hdsp) return 0; } -static int snd_hdsp_info_autosync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"Word", "ADAT Sync", "IEC958", "None", "ADAT1", "ADAT2", "ADAT3" }; @@ -2643,9 +2639,9 @@ static int snd_hdsp_info_autosync_ref(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_hdsp_get_autosync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_autosync_ref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp); return 0; @@ -2660,12 +2656,12 @@ static int snd_hdsp_get_autosync_ref(snd_kcontrol_t * kcontrol, snd_ctl_elem_val .put = snd_hdsp_put_line_out \ } -static int hdsp_line_out(hdsp_t *hdsp) +static int hdsp_line_out(struct hdsp *hdsp) { return (hdsp->control_register & HDSP_LineOut) ? 1 : 0; } -static int hdsp_set_line_output(hdsp_t *hdsp, int out) +static int hdsp_set_line_output(struct hdsp *hdsp, int out) { if (out) hdsp->control_register |= HDSP_LineOut; @@ -2675,7 +2671,7 @@ static int hdsp_set_line_output(hdsp_t *hdsp, int out) return 0; } -static int snd_hdsp_info_line_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2684,9 +2680,9 @@ static int snd_hdsp_info_line_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_hdsp_get_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); spin_lock_irq(&hdsp->lock); ucontrol->value.integer.value[0] = hdsp_line_out(hdsp); @@ -2694,9 +2690,9 @@ static int snd_hdsp_get_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_hdsp_put_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_line_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -2719,7 +2715,7 @@ static int snd_hdsp_put_line_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .put = snd_hdsp_put_precise_pointer \ } -static int hdsp_set_precise_pointer(hdsp_t *hdsp, int precise) +static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise) { if (precise) hdsp->precise_ptr = 1; @@ -2728,7 +2724,7 @@ static int hdsp_set_precise_pointer(hdsp_t *hdsp, int precise) return 0; } -static int snd_hdsp_info_precise_pointer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2737,9 +2733,9 @@ static int snd_hdsp_info_precise_pointer(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_hdsp_get_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); spin_lock_irq(&hdsp->lock); ucontrol->value.integer.value[0] = hdsp->precise_ptr; @@ -2747,9 +2743,9 @@ static int snd_hdsp_get_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return 0; } -static int snd_hdsp_put_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_precise_pointer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -2772,7 +2768,7 @@ static int snd_hdsp_put_precise_pointer(snd_kcontrol_t * kcontrol, snd_ctl_elem_ .put = snd_hdsp_put_use_midi_tasklet \ } -static int hdsp_set_use_midi_tasklet(hdsp_t *hdsp, int use_tasklet) +static int hdsp_set_use_midi_tasklet(struct hdsp *hdsp, int use_tasklet) { if (use_tasklet) hdsp->use_midi_tasklet = 1; @@ -2781,7 +2777,7 @@ static int hdsp_set_use_midi_tasklet(hdsp_t *hdsp, int use_tasklet) return 0; } -static int snd_hdsp_info_use_midi_tasklet(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2790,9 +2786,9 @@ static int snd_hdsp_info_use_midi_tasklet(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_hdsp_get_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); spin_lock_irq(&hdsp->lock); ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet; @@ -2800,9 +2796,9 @@ static int snd_hdsp_get_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem return 0; } -static int snd_hdsp_put_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_use_midi_tasklet(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -2828,7 +2824,7 @@ static int snd_hdsp_put_use_midi_tasklet(snd_kcontrol_t * kcontrol, snd_ctl_elem .put = snd_hdsp_put_mixer \ } -static int snd_hdsp_info_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 3; @@ -2838,9 +2834,9 @@ static int snd_hdsp_info_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_hdsp_get_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int source; int destination; int addr; @@ -2859,9 +2855,9 @@ static int snd_hdsp_get_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_hdsp_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_put_mixer(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); int change; int source; int destination; @@ -2898,7 +2894,7 @@ static int snd_hdsp_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * .get = snd_hdsp_get_wc_sync_check \ } -static int snd_hdsp_info_sync_check(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_hdsp_info_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = {"No Lock", "Lock", "Sync" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -2910,7 +2906,7 @@ static int snd_hdsp_info_sync_check(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int hdsp_wc_sync_check(hdsp_t *hdsp) +static int hdsp_wc_sync_check(struct hdsp *hdsp) { int status2 = hdsp_read(hdsp, HDSP_status2Register); if (status2 & HDSP_wc_lock) { @@ -2923,9 +2919,9 @@ static int hdsp_wc_sync_check(hdsp_t *hdsp) return 0; } -static int snd_hdsp_get_wc_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_wc_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_wc_sync_check(hdsp); return 0; @@ -2940,7 +2936,7 @@ static int snd_hdsp_get_wc_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_va .get = snd_hdsp_get_spdif_sync_check \ } -static int hdsp_spdif_sync_check(hdsp_t *hdsp) +static int hdsp_spdif_sync_check(struct hdsp *hdsp) { int status = hdsp_read(hdsp, HDSP_statusRegister); if (status & HDSP_SPDIFErrorFlag) @@ -2954,9 +2950,9 @@ static int hdsp_spdif_sync_check(hdsp_t *hdsp) return 0; } -static int snd_hdsp_get_spdif_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_spdif_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_spdif_sync_check(hdsp); return 0; @@ -2971,7 +2967,7 @@ static int snd_hdsp_get_spdif_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem .get = snd_hdsp_get_adatsync_sync_check \ } -static int hdsp_adatsync_sync_check(hdsp_t *hdsp) +static int hdsp_adatsync_sync_check(struct hdsp *hdsp) { int status = hdsp_read(hdsp, HDSP_statusRegister); if (status & HDSP_TimecodeLock) { @@ -2983,9 +2979,9 @@ static int hdsp_adatsync_sync_check(hdsp_t *hdsp) return 0; } -static int snd_hdsp_get_adatsync_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_adatsync_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdsp_adatsync_sync_check(hdsp); return 0; @@ -2998,7 +2994,7 @@ static int snd_hdsp_get_adatsync_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_e .get = snd_hdsp_get_adat_sync_check \ } -static int hdsp_adat_sync_check(hdsp_t *hdsp, int idx) +static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx) { int status = hdsp_read(hdsp, HDSP_statusRegister); @@ -3011,10 +3007,10 @@ static int hdsp_adat_sync_check(hdsp_t *hdsp, int idx) return 0; } -static int snd_hdsp_get_adat_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int offset; - hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); + struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); offset = ucontrol->id.index - 1; snd_assert(offset >= 0); @@ -3038,14 +3034,14 @@ static int snd_hdsp_get_adat_sync_check(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return 0; } -static snd_kcontrol_new_t snd_hdsp_9632_controls[] = { +static struct snd_kcontrol_new snd_hdsp_9632_controls[] = { HDSP_DA_GAIN("DA Gain", 0), HDSP_AD_GAIN("AD Gain", 0), HDSP_PHONE_GAIN("Phones Gain", 0), HDSP_XLR_BREAKOUT_CABLE("XLR Breakout Cable", 0) }; -static snd_kcontrol_new_t snd_hdsp_controls[] = { +static struct snd_kcontrol_new snd_hdsp_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -3111,14 +3107,14 @@ HDSP_PRECISE_POINTER("Precise Pointer", 0), HDSP_USE_MIDI_TASKLET("Use Midi Tasklet", 0), }; -static snd_kcontrol_new_t snd_hdsp_96xx_aeb = HDSP_AEB("Analog Extension Board", 0); -static snd_kcontrol_new_t snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK; +static struct snd_kcontrol_new snd_hdsp_96xx_aeb = HDSP_AEB("Analog Extension Board", 0); +static struct snd_kcontrol_new snd_hdsp_adat_sync_check = HDSP_ADAT_SYNC_CHECK; -static int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp) +static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp) { unsigned int idx; int err; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; for (idx = 0; idx < ARRAY_SIZE(snd_hdsp_controls); idx++) { if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp))) < 0) @@ -3162,9 +3158,9 @@ static int snd_hdsp_create_controls(snd_card_t *card, hdsp_t *hdsp) ------------------------------------------------------------*/ static void -snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +snd_hdsp_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - hdsp_t *hdsp = (hdsp_t *) entry->private_data; + struct hdsp *hdsp = (struct hdsp *) entry->private_data; unsigned int status; unsigned int status2; char *pref_sync_ref; @@ -3469,21 +3465,21 @@ snd_hdsp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) } -static void __devinit snd_hdsp_proc_init(hdsp_t *hdsp) +static void __devinit snd_hdsp_proc_init(struct hdsp *hdsp) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(hdsp->card, "hdsp", &entry)) snd_info_set_text_ops(entry, hdsp, 1024, snd_hdsp_proc_read); } -static void snd_hdsp_free_buffers(hdsp_t *hdsp) +static void snd_hdsp_free_buffers(struct hdsp *hdsp) { snd_hammerfall_free_buffer(&hdsp->capture_dma_buf, hdsp->pci); snd_hammerfall_free_buffer(&hdsp->playback_dma_buf, hdsp->pci); } -static int __devinit snd_hdsp_initialize_memory(hdsp_t *hdsp) +static int __devinit snd_hdsp_initialize_memory(struct hdsp *hdsp) { unsigned long pb_bus, cb_bus; @@ -3511,7 +3507,7 @@ static int __devinit snd_hdsp_initialize_memory(hdsp_t *hdsp) return 0; } -static int snd_hdsp_set_defaults(hdsp_t *hdsp) +static int snd_hdsp_set_defaults(struct hdsp *hdsp) { unsigned int i; @@ -3576,7 +3572,7 @@ static int snd_hdsp_set_defaults(hdsp_t *hdsp) static void hdsp_midi_tasklet(unsigned long arg) { - hdsp_t *hdsp = (hdsp_t *)arg; + struct hdsp *hdsp = (struct hdsp *)arg; if (hdsp->midi[0].pending) snd_hdsp_midi_input_read (&hdsp->midi[0]); @@ -3586,7 +3582,7 @@ static void hdsp_midi_tasklet(unsigned long arg) static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - hdsp_t *hdsp = (hdsp_t *) dev_id; + struct hdsp *hdsp = (struct hdsp *) dev_id; unsigned int status; int audio; int midi0; @@ -3644,13 +3640,13 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id, struct pt_regs *reg return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_hdsp_hw_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_hdsp_hw_pointer(struct snd_pcm_substream *substream) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); return hdsp_hw_pointer(hdsp); } -static char *hdsp_channel_buffer_location(hdsp_t *hdsp, +static char *hdsp_channel_buffer_location(struct hdsp *hdsp, int stream, int channel) @@ -3668,10 +3664,10 @@ static char *hdsp_channel_buffer_location(hdsp_t *hdsp, return hdsp->playback_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); } -static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel, +static int snd_hdsp_playback_copy(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); char *channel_buf; snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); @@ -3683,10 +3679,10 @@ static int snd_hdsp_playback_copy(snd_pcm_substream_t *substream, int channel, return count; } -static int snd_hdsp_capture_copy(snd_pcm_substream_t *substream, int channel, +static int snd_hdsp_capture_copy(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); char *channel_buf; snd_assert(pos + count <= HDSP_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); @@ -3698,10 +3694,10 @@ static int snd_hdsp_capture_copy(snd_pcm_substream_t *substream, int channel, return count; } -static int snd_hdsp_hw_silence(snd_pcm_substream_t *substream, int channel, +static int snd_hdsp_hw_silence(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); char *channel_buf; channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); @@ -3710,11 +3706,11 @@ static int snd_hdsp_hw_silence(snd_pcm_substream_t *substream, int channel, return count; } -static int snd_hdsp_reset(snd_pcm_substream_t *substream) +static int snd_hdsp_reset(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - hdsp_t *hdsp = snd_pcm_substream_chip(substream); - snd_pcm_substream_t *other; + struct snd_pcm_runtime *runtime = substream->runtime; + struct hdsp *hdsp = snd_pcm_substream_chip(substream); + struct snd_pcm_substream *other; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) other = hdsp->capture_substream; else @@ -3725,8 +3721,8 @@ static int snd_hdsp_reset(snd_pcm_substream_t *substream) runtime->status->hw_ptr = 0; if (other) { struct list_head *pos; - snd_pcm_substream_t *s; - snd_pcm_runtime_t *oruntime = other->runtime; + struct snd_pcm_substream *s; + struct snd_pcm_runtime *oruntime = other->runtime; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == other) { @@ -3738,10 +3734,10 @@ static int snd_hdsp_reset(snd_pcm_substream_t *substream) return 0; } -static int snd_hdsp_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +static int snd_hdsp_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); int err; pid_t this_pid; pid_t other_pid; @@ -3813,10 +3809,10 @@ static int snd_hdsp_hw_params(snd_pcm_substream_t *substream, return 0; } -static int snd_hdsp_channel_info(snd_pcm_substream_t *substream, - snd_pcm_channel_info_t *info) +static int snd_hdsp_channel_info(struct snd_pcm_substream *substream, + struct snd_pcm_channel_info *info) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); int mapped_channel; snd_assert(info->channel < hdsp->max_channels, return -EINVAL); @@ -3830,7 +3826,7 @@ static int snd_hdsp_channel_info(snd_pcm_substream_t *substream, return 0; } -static int snd_hdsp_ioctl(snd_pcm_substream_t *substream, +static int snd_hdsp_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { switch (cmd) { @@ -3845,10 +3841,10 @@ static int snd_hdsp_ioctl(snd_pcm_substream_t *substream, return snd_pcm_lib_ioctl(substream, cmd, arg); } -static int snd_hdsp_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_hdsp_trigger(struct snd_pcm_substream *substream, int cmd) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); - snd_pcm_substream_t *other; + struct hdsp *hdsp = snd_pcm_substream_chip(substream); + struct snd_pcm_substream *other; int running; if (hdsp_check_for_iobox (hdsp)) @@ -3878,7 +3874,7 @@ static int snd_hdsp_trigger(snd_pcm_substream_t *substream, int cmd) if (other) { struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == other) { @@ -3915,9 +3911,9 @@ static int snd_hdsp_trigger(snd_pcm_substream_t *substream, int cmd) return 0; } -static int snd_hdsp_prepare(snd_pcm_substream_t *substream) +static int snd_hdsp_prepare(struct snd_pcm_substream *substream) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); int result = 0; if (hdsp_check_for_iobox (hdsp)) @@ -3933,7 +3929,7 @@ static int snd_hdsp_prepare(snd_pcm_substream_t *substream) return result; } -static snd_pcm_hardware_t snd_hdsp_playback_subinfo = +static struct snd_pcm_hardware snd_hdsp_playback_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -3963,7 +3959,7 @@ static snd_pcm_hardware_t snd_hdsp_playback_subinfo = .fifo_size = 0 }; -static snd_pcm_hardware_t snd_hdsp_capture_subinfo = +static struct snd_pcm_hardware snd_hdsp_capture_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -3994,7 +3990,7 @@ static snd_pcm_hardware_t snd_hdsp_capture_subinfo = static unsigned int hdsp_period_sizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192 }; -static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_period_sizes = { +static struct snd_pcm_hw_constraint_list hdsp_hw_constraints_period_sizes = { .count = ARRAY_SIZE(hdsp_period_sizes), .list = hdsp_period_sizes, .mask = 0 @@ -4002,17 +3998,17 @@ static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_period_sizes = { static unsigned int hdsp_9632_sample_rates[] = { 32000, 44100, 48000, 64000, 88200, 96000, 128000, 176400, 192000 }; -static snd_pcm_hw_constraint_list_t hdsp_hw_constraints_9632_sample_rates = { +static struct snd_pcm_hw_constraint_list hdsp_hw_constraints_9632_sample_rates = { .count = ARRAY_SIZE(hdsp_9632_sample_rates), .list = hdsp_9632_sample_rates, .mask = 0 }; -static int snd_hdsp_hw_rule_in_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_hdsp_hw_rule_in_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - hdsp_t *hdsp = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct hdsp *hdsp = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (hdsp->io_type == H9632) { unsigned int list[3]; list[0] = hdsp->qs_in_channels; @@ -4027,12 +4023,12 @@ static int snd_hdsp_hw_rule_in_channels(snd_pcm_hw_params_t *params, } } -static int snd_hdsp_hw_rule_out_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_hdsp_hw_rule_out_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { unsigned int list[3]; - hdsp_t *hdsp = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct hdsp *hdsp = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); if (hdsp->io_type == H9632) { list[0] = hdsp->qs_out_channels; list[1] = hdsp->ds_out_channels; @@ -4045,28 +4041,28 @@ static int snd_hdsp_hw_rule_out_channels(snd_pcm_hw_params_t *params, return snd_interval_list(c, 2, list, 0); } -static int snd_hdsp_hw_rule_in_channels_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_hdsp_hw_rule_in_channels_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - hdsp_t *hdsp = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct hdsp *hdsp = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (r->min > 96000 && hdsp->io_type == H9632) { - snd_interval_t t = { + struct snd_interval t = { .min = hdsp->qs_in_channels, .max = hdsp->qs_in_channels, .integer = 1, }; return snd_interval_refine(c, &t); } else if (r->min > 48000 && r->max <= 96000) { - snd_interval_t t = { + struct snd_interval t = { .min = hdsp->ds_in_channels, .max = hdsp->ds_in_channels, .integer = 1, }; return snd_interval_refine(c, &t); } else if (r->max < 64000) { - snd_interval_t t = { + struct snd_interval t = { .min = hdsp->ss_in_channels, .max = hdsp->ss_in_channels, .integer = 1, @@ -4076,28 +4072,28 @@ static int snd_hdsp_hw_rule_in_channels_rate(snd_pcm_hw_params_t *params, return 0; } -static int snd_hdsp_hw_rule_out_channels_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_hdsp_hw_rule_out_channels_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - hdsp_t *hdsp = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct hdsp *hdsp = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (r->min > 96000 && hdsp->io_type == H9632) { - snd_interval_t t = { + struct snd_interval t = { .min = hdsp->qs_out_channels, .max = hdsp->qs_out_channels, .integer = 1, }; return snd_interval_refine(c, &t); } else if (r->min > 48000 && r->max <= 96000) { - snd_interval_t t = { + struct snd_interval t = { .min = hdsp->ds_out_channels, .max = hdsp->ds_out_channels, .integer = 1, }; return snd_interval_refine(c, &t); } else if (r->max < 64000) { - snd_interval_t t = { + struct snd_interval t = { .min = hdsp->ss_out_channels, .max = hdsp->ss_out_channels, .integer = 1, @@ -4107,28 +4103,28 @@ static int snd_hdsp_hw_rule_out_channels_rate(snd_pcm_hw_params_t *params, return 0; } -static int snd_hdsp_hw_rule_rate_out_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_hdsp_hw_rule_rate_out_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - hdsp_t *hdsp = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct hdsp *hdsp = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (c->min >= hdsp->ss_out_channels) { - snd_interval_t t = { + struct snd_interval t = { .min = 32000, .max = 48000, .integer = 1, }; return snd_interval_refine(r, &t); } else if (c->max <= hdsp->qs_out_channels && hdsp->io_type == H9632) { - snd_interval_t t = { + struct snd_interval t = { .min = 128000, .max = 192000, .integer = 1, }; return snd_interval_refine(r, &t); } else if (c->max <= hdsp->ds_out_channels) { - snd_interval_t t = { + struct snd_interval t = { .min = 64000, .max = 96000, .integer = 1, @@ -4138,28 +4134,28 @@ static int snd_hdsp_hw_rule_rate_out_channels(snd_pcm_hw_params_t *params, return 0; } -static int snd_hdsp_hw_rule_rate_in_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_hdsp_hw_rule_rate_in_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - hdsp_t *hdsp = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct hdsp *hdsp = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (c->min >= hdsp->ss_in_channels) { - snd_interval_t t = { + struct snd_interval t = { .min = 32000, .max = 48000, .integer = 1, }; return snd_interval_refine(r, &t); } else if (c->max <= hdsp->qs_in_channels && hdsp->io_type == H9632) { - snd_interval_t t = { + struct snd_interval t = { .min = 128000, .max = 192000, .integer = 1, }; return snd_interval_refine(r, &t); } else if (c->max <= hdsp->ds_in_channels) { - snd_interval_t t = { + struct snd_interval t = { .min = 64000, .max = 96000, .integer = 1, @@ -4169,10 +4165,10 @@ static int snd_hdsp_hw_rule_rate_in_channels(snd_pcm_hw_params_t *params, return 0; } -static int snd_hdsp_playback_open(snd_pcm_substream_t *substream) +static int snd_hdsp_playback_open(struct snd_pcm_substream *substream) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct hdsp *hdsp = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (hdsp_check_for_iobox (hdsp)) return -EIO; @@ -4224,9 +4220,9 @@ static int snd_hdsp_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_hdsp_playback_release(snd_pcm_substream_t *substream) +static int snd_hdsp_playback_release(struct snd_pcm_substream *substream) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); spin_lock_irq(&hdsp->lock); @@ -4242,10 +4238,10 @@ static int snd_hdsp_playback_release(snd_pcm_substream_t *substream) } -static int snd_hdsp_capture_open(snd_pcm_substream_t *substream) +static int snd_hdsp_capture_open(struct snd_pcm_substream *substream) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct hdsp *hdsp = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (hdsp_check_for_iobox (hdsp)) return -EIO; @@ -4287,9 +4283,9 @@ static int snd_hdsp_capture_open(snd_pcm_substream_t *substream) return 0; } -static int snd_hdsp_capture_release(snd_pcm_substream_t *substream) +static int snd_hdsp_capture_release(struct snd_pcm_substream *substream) { - hdsp_t *hdsp = snd_pcm_substream_chip(substream); + struct hdsp *hdsp = snd_pcm_substream_chip(substream); spin_lock_irq(&hdsp->lock); @@ -4300,7 +4296,7 @@ static int snd_hdsp_capture_release(snd_pcm_substream_t *substream) return 0; } -static int snd_hdsp_hwdep_dummy_op(snd_hwdep_t *hw, struct file *file) +static int snd_hdsp_hwdep_dummy_op(struct snd_hwdep *hw, struct file *file) { /* we have nothing to initialize but the call is required */ return 0; @@ -4334,7 +4330,7 @@ static inline int copy_u48_le(void __user *dest, void __iomem *src_low, void __i return copy_to_user(dest, &rms, 8); } -static int hdsp_9652_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms) +static int hdsp_9652_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) { int doublespeed = 0; int i, j, channels, ofs; @@ -4371,15 +4367,15 @@ static int hdsp_9652_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms) return 0; } -static int hdsp_9632_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms) +static int hdsp_9632_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) { int i, j; - hdsp_9632_meters_t __iomem *m; + struct hdsp_9632_meters __iomem *m; int doublespeed = 0; if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) doublespeed = 1; - m = (hdsp_9632_meters_t __iomem *)(hdsp->iobase+HDSP_9632_metersBase); + m = (struct hdsp_9632_meters __iomem *)(hdsp->iobase+HDSP_9632_metersBase); for (i = 0, j = 0; i < 16; ++i, ++j) { if (copy_u32_le(&peak_rms->input_peaks[i], &m->input_peak[j])) return -EFAULT; @@ -4401,7 +4397,7 @@ static int hdsp_9632_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms) return 0; } -static int hdsp_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms) +static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) { int i; @@ -4431,14 +4427,14 @@ static int hdsp_get_peak(hdsp_t *hdsp, hdsp_peak_rms_t __user *peak_rms) return 0; } -static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int cmd, unsigned long arg) +static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigned int cmd, unsigned long arg) { - hdsp_t *hdsp = (hdsp_t *)hw->private_data; + struct hdsp *hdsp = (struct hdsp *)hw->private_data; void __user *argp = (void __user *)arg; switch (cmd) { case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: { - hdsp_peak_rms_t __user *peak_rms = (hdsp_peak_rms_t __user *)arg; + struct hdsp_peak_rms __user *peak_rms = (struct hdsp_peak_rms __user *)arg; if (!(hdsp->state & HDSP_FirmwareLoaded)) { snd_printk(KERN_ERR "Hammerfall-DSP: firmware needs to be uploaded to the card.\n"); @@ -4455,7 +4451,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int } } case SNDRV_HDSP_IOCTL_GET_CONFIG_INFO: { - hdsp_config_info_t info; + struct hdsp_config_info info; unsigned long flags; int i; @@ -4498,7 +4494,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int break; } case SNDRV_HDSP_IOCTL_GET_9632_AEB: { - hdsp_9632_aeb_t h9632_aeb; + struct hdsp_9632_aeb h9632_aeb; if (hdsp->io_type != H9632) return -EINVAL; h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS; @@ -4508,7 +4504,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int break; } case SNDRV_HDSP_IOCTL_GET_VERSION: { - hdsp_version_t hdsp_version; + struct hdsp_version hdsp_version; int err; if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; @@ -4523,7 +4519,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int break; } case SNDRV_HDSP_IOCTL_UPLOAD_FIRMWARE: { - hdsp_firmware_t __user *firmware; + struct hdsp_firmware __user *firmware; u32 __user *firmware_data; int err; @@ -4535,7 +4531,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int return -EBUSY; snd_printk(KERN_INFO "Hammerfall-DSP: initializing firmware upload\n"); - firmware = (hdsp_firmware_t __user *)argp; + firmware = (struct hdsp_firmware __user *)argp; if (get_user(firmware_data, &firmware->firmware_data)) return -EFAULT; @@ -4566,7 +4562,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int break; } case SNDRV_HDSP_IOCTL_GET_MIXER: { - hdsp_mixer_t __user *mixer = (hdsp_mixer_t __user *)argp; + struct hdsp_mixer __user *mixer = (struct hdsp_mixer __user *)argp; if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE)) return -EFAULT; break; @@ -4577,7 +4573,7 @@ static int snd_hdsp_hwdep_ioctl(snd_hwdep_t *hw, struct file *file, unsigned int return 0; } -static snd_pcm_ops_t snd_hdsp_playback_ops = { +static struct snd_pcm_ops snd_hdsp_playback_ops = { .open = snd_hdsp_playback_open, .close = snd_hdsp_playback_release, .ioctl = snd_hdsp_ioctl, @@ -4589,7 +4585,7 @@ static snd_pcm_ops_t snd_hdsp_playback_ops = { .silence = snd_hdsp_hw_silence, }; -static snd_pcm_ops_t snd_hdsp_capture_ops = { +static struct snd_pcm_ops snd_hdsp_capture_ops = { .open = snd_hdsp_capture_open, .close = snd_hdsp_capture_release, .ioctl = snd_hdsp_ioctl, @@ -4600,10 +4596,10 @@ static snd_pcm_ops_t snd_hdsp_capture_ops = { .copy = snd_hdsp_capture_copy, }; -static int __devinit snd_hdsp_create_hwdep(snd_card_t *card, - hdsp_t *hdsp) +static int __devinit snd_hdsp_create_hwdep(struct snd_card *card, + struct hdsp *hdsp) { - snd_hwdep_t *hw; + struct snd_hwdep *hw; int err; if ((err = snd_hwdep_new(card, "HDSP hwdep", 0, &hw)) < 0) @@ -4620,9 +4616,9 @@ static int __devinit snd_hdsp_create_hwdep(snd_card_t *card, return 0; } -static int snd_hdsp_create_pcm(snd_card_t *card, hdsp_t *hdsp) +static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(card, hdsp->card_name, 0, 1, 1, &pcm)) < 0) @@ -4640,13 +4636,13 @@ static int snd_hdsp_create_pcm(snd_card_t *card, hdsp_t *hdsp) return 0; } -static void snd_hdsp_9652_enable_mixer (hdsp_t *hdsp) +static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp) { hdsp->control2_register |= HDSP_9652_ENABLE_MIXER; hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); } -static int snd_hdsp_enable_io (hdsp_t *hdsp) +static int snd_hdsp_enable_io (struct hdsp *hdsp) { int i; @@ -4663,7 +4659,7 @@ static int snd_hdsp_enable_io (hdsp_t *hdsp) return 0; } -static void snd_hdsp_initialize_channels(hdsp_t *hdsp) +static void snd_hdsp_initialize_channels(struct hdsp *hdsp) { int status, aebi_channels, aebo_channels; @@ -4706,13 +4702,13 @@ static void snd_hdsp_initialize_channels(hdsp_t *hdsp) } } -static void snd_hdsp_initialize_midi_flush (hdsp_t *hdsp) +static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp) { snd_hdsp_flush_midi_input (hdsp, 0); snd_hdsp_flush_midi_input (hdsp, 1); } -static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp) +static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp) { int err; @@ -4769,7 +4765,7 @@ static int snd_hdsp_create_alsa_devices(snd_card_t *card, hdsp_t *hdsp) #ifdef HDSP_FW_LOADER /* load firmware via hotplug fw loader */ -static int __devinit hdsp_request_fw_loader(hdsp_t *hdsp) +static int __devinit hdsp_request_fw_loader(struct hdsp *hdsp) { const char *fwfile; const struct firmware *fw; @@ -4842,8 +4838,8 @@ static int __devinit hdsp_request_fw_loader(hdsp_t *hdsp) } #endif -static int __devinit snd_hdsp_create(snd_card_t *card, - hdsp_t *hdsp) +static int __devinit snd_hdsp_create(struct snd_card *card, + struct hdsp *hdsp) { struct pci_dev *pci = hdsp->pci; int err; @@ -4980,7 +4976,7 @@ static int __devinit snd_hdsp_create(snd_card_t *card, return 0; } -static int snd_hdsp_free(hdsp_t *hdsp) +static int snd_hdsp_free(struct hdsp *hdsp) { if (hdsp->port) { /* stop the audio, and cancel all interrupts */ @@ -5004,9 +5000,9 @@ static int snd_hdsp_free(hdsp_t *hdsp) return 0; } -static void snd_hdsp_card_free(snd_card_t *card) +static void snd_hdsp_card_free(struct snd_card *card) { - hdsp_t *hdsp = (hdsp_t *) card->private_data; + struct hdsp *hdsp = (struct hdsp *) card->private_data; if (hdsp) snd_hdsp_free(hdsp); @@ -5016,8 +5012,8 @@ static int __devinit snd_hdsp_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - hdsp_t *hdsp; - snd_card_t *card; + struct hdsp *hdsp; + struct snd_card *card; int err; if (dev >= SNDRV_CARDS) @@ -5027,10 +5023,10 @@ static int __devinit snd_hdsp_probe(struct pci_dev *pci, return -ENOENT; } - if (!(card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(hdsp_t)))) + if (!(card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct hdsp)))) return -ENOMEM; - hdsp = (hdsp_t *) card->private_data; + hdsp = (struct hdsp *) card->private_data; card->private_free = snd_hdsp_card_free; hdsp->dev = dev; hdsp->pci = pci; -- cgit v1.1 From 98274f0701f9e6579ae493ac190227fe93d11e20 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:52:34 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI HDSP-MADI Modules: HDSPM driver,RME9652 driver Remove xxx_t typedefs from the PCI HDSP-MADI driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/hdspm.h | 45 ++-- sound/pci/rme9652/hdspm.c | 592 +++++++++++++++++++++++----------------------- 2 files changed, 315 insertions(+), 322 deletions(-) diff --git a/include/sound/hdspm.h b/include/sound/hdspm.h index c34427c..c3c854d 100644 --- a/include/sound/hdspm.h +++ b/include/sound/hdspm.h @@ -25,8 +25,6 @@ /* -------------------- IOCTL Peak/RMS Meters -------------------- */ -typedef struct _snd_hdspm_peak_rms hdspm_peak_rms_t; - /* peam rms level structure like we get from hardware maybe in future we can memory map it so I just copy it @@ -36,7 +34,7 @@ typedef struct _snd_hdspm_peak_rms hdspm_peak_rms_t; (i asume so from the code) */ -struct _snd_hdspm_peak_rms { +struct hdspm_peak_rms { unsigned int level_offset[1024]; @@ -58,18 +56,16 @@ struct _snd_hdspm_peak_rms { unsigned int xxx_rms_h[64]; /* not used */ }; -struct sndrv_hdspm_peak_rms_ioctl { - hdspm_peak_rms_t *peak; +struct hdspm_peak_rms_ioctl { + struct hdspm_peak_rms *peak; }; /* use indirect access due to the limit of ioctl bit size */ -#define SNDRV_HDSPM_IOCTL_GET_PEAK_RMS _IOR('H', 0x40, struct sndrv_hdspm_peak_rms_ioctl) +#define SNDRV_HDSPM_IOCTL_GET_PEAK_RMS _IOR('H', 0x40, struct hdspm_peak_rms_ioctl) /* ------------ CONFIG block IOCTL ---------------------- */ -typedef struct _snd_hdspm_config_info hdspm_config_info_t; - -struct _snd_hdspm_config_info { +struct hdspm_config_info { unsigned char pref_sync_ref; unsigned char wordclock_sync_check; unsigned char madi_sync_check; @@ -83,18 +79,16 @@ struct _snd_hdspm_config_info { unsigned int analog_out; }; -#define SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO _IOR('H', 0x41, hdspm_config_info_t) +#define SNDRV_HDSPM_IOCTL_GET_CONFIG_INFO _IOR('H', 0x41, struct hdspm_config_info) /* get Soundcard Version */ -typedef struct _snd_hdspm_version hdspm_version_t; - -struct _snd_hdspm_version { +struct hdspm_version { unsigned short firmware_rev; }; -#define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x43, hdspm_version_t) +#define SNDRV_HDSPM_IOCTL_GET_VERSION _IOR('H', 0x43, struct hdspm_version) /* ------------- get Matrix Mixer IOCTL --------------- */ @@ -108,24 +102,27 @@ struct _snd_hdspm_version { #define HDSPM_MIXER_CHANNELS HDSPM_MAX_CHANNELS -typedef struct _snd_hdspm_channelfader snd_hdspm_channelfader_t; - -struct _snd_hdspm_channelfader { +struct hdspm_channelfader { unsigned int in[HDSPM_MIXER_CHANNELS]; unsigned int pb[HDSPM_MIXER_CHANNELS]; }; -typedef struct _snd_hdspm_mixer hdspm_mixer_t; - -struct _snd_hdspm_mixer { - snd_hdspm_channelfader_t ch[HDSPM_MIXER_CHANNELS]; +struct hdspm_mixer { + struct hdspm_channelfader ch[HDSPM_MIXER_CHANNELS]; }; -struct sndrv_hdspm_mixer_ioctl { - hdspm_mixer_t *mixer; +struct hdspm_mixer_ioctl { + struct hdspm_mixer *mixer; }; /* use indirect access due to the limit of ioctl bit size */ -#define SNDRV_HDSPM_IOCTL_GET_MIXER _IOR('H', 0x44, struct sndrv_hdspm_mixer_ioctl) +#define SNDRV_HDSPM_IOCTL_GET_MIXER _IOR('H', 0x44, struct hdspm_mixer_ioctl) + +/* typedefs for compatibility to user-space */ +typedef struct hdspm_peak_rms hdspm_peak_rms_t; +typedef struct hdspm_config_info hdspm_config_info_t; +typedef struct hdspm_version hdspm_version_t; +typedef struct hdspm_channelfader snd_hdspm_channelfader_t; +typedef struct hdspm_mixer hdspm_mixer_t; #endif /* __SOUND_HDSPM_H */ diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index ae2013a..3dec616 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c @@ -318,25 +318,22 @@ MODULE_SUPPORTED_DEVICE("{{RME HDSPM-MADI}}"); #define HDSPM_DMA_AREA_BYTES (HDSPM_MAX_CHANNELS * HDSPM_CHANNEL_BUFFER_BYTES) #define HDSPM_DMA_AREA_KILOBYTES (HDSPM_DMA_AREA_BYTES/1024) -typedef struct _hdspm hdspm_t; -typedef struct _hdspm_midi hdspm_midi_t; - -struct _hdspm_midi { - hdspm_t *hdspm; +struct hdspm_midi { + struct hdspm *hdspm; int id; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *input; - snd_rawmidi_substream_t *output; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *input; + struct snd_rawmidi_substream *output; char istimer; /* timer in use */ struct timer_list timer; spinlock_t lock; int pending; }; -struct _hdspm { +struct hdspm { spinlock_t lock; - snd_pcm_substream_t *capture_substream; /* only one playback */ - snd_pcm_substream_t *playback_substream; /* and/or capture stream */ + struct snd_pcm_substream *capture_substream; /* only one playback */ + struct snd_pcm_substream *playback_substream; /* and/or capture stream */ char *card_name; /* for procinfo */ unsigned short firmware_rev; /* dont know if relevant */ @@ -347,7 +344,7 @@ struct _hdspm { u32 control_register; /* cached value */ u32 control2_register; /* cached value */ - hdspm_midi_t midi[2]; + struct hdspm_midi midi[2]; struct tasklet_struct midi_tasklet; size_t period_bytes; @@ -375,15 +372,15 @@ struct _hdspm { int irq_count; /* for debug */ - snd_card_t *card; /* one card */ - snd_pcm_t *pcm; /* has one pcm */ - snd_hwdep_t *hwdep; /* and a hwdep for additional ioctl */ + struct snd_card *card; /* one card */ + struct snd_pcm *pcm; /* has one pcm */ + struct snd_hwdep *hwdep; /* and a hwdep for additional ioctl */ struct pci_dev *pci; /* and an pci info */ /* Mixer vars */ - snd_kcontrol_t *playback_mixer_ctls[HDSPM_MAX_CHANNELS]; /* fast alsa mixer */ - snd_kcontrol_t *input_mixer_ctls[HDSPM_MAX_CHANNELS]; /* but input to much, so not used */ - hdspm_mixer_t *mixer; /* full mixer accessable over mixer ioctl or hwdep-device */ + struct snd_kcontrol *playback_mixer_ctls[HDSPM_MAX_CHANNELS]; /* fast alsa mixer */ + struct snd_kcontrol *input_mixer_ctls[HDSPM_MAX_CHANNELS]; /* but input to much, so not used */ + struct hdspm_mixer *mixer; /* full mixer accessable over mixer ioctl or hwdep-device */ }; @@ -444,28 +441,28 @@ static struct pci_device_id snd_hdspm_ids[] = { MODULE_DEVICE_TABLE(pci, snd_hdspm_ids); /* prototypes */ -static int __devinit snd_hdspm_create_alsa_devices(snd_card_t * card, - hdspm_t * hdspm); -static int __devinit snd_hdspm_create_pcm(snd_card_t * card, - hdspm_t * hdspm); - -static inline void snd_hdspm_initialize_midi_flush(hdspm_t * hdspm); -static int hdspm_update_simple_mixer_controls(hdspm_t * hdspm); -static int hdspm_autosync_ref(hdspm_t * hdspm); -static int snd_hdspm_set_defaults(hdspm_t * hdspm); -static void hdspm_set_sgbuf(hdspm_t * hdspm, struct snd_sg_buf *sgbuf, +static int __devinit snd_hdspm_create_alsa_devices(struct snd_card *card, + struct hdspm * hdspm); +static int __devinit snd_hdspm_create_pcm(struct snd_card *card, + struct hdspm * hdspm); + +static inline void snd_hdspm_initialize_midi_flush(struct hdspm * hdspm); +static int hdspm_update_simple_mixer_controls(struct hdspm * hdspm); +static int hdspm_autosync_ref(struct hdspm * hdspm); +static int snd_hdspm_set_defaults(struct hdspm * hdspm); +static void hdspm_set_sgbuf(struct hdspm * hdspm, struct snd_sg_buf *sgbuf, unsigned int reg, int channels); /* Write/read to/from HDSPM with Adresses in Bytes not words but only 32Bit writes are allowed */ -static inline void hdspm_write(hdspm_t * hdspm, unsigned int reg, +static inline void hdspm_write(struct hdspm * hdspm, unsigned int reg, unsigned int val) { writel(val, hdspm->iobase + reg); } -static inline unsigned int hdspm_read(hdspm_t * hdspm, unsigned int reg) +static inline unsigned int hdspm_read(struct hdspm * hdspm, unsigned int reg) { return readl(hdspm->iobase + reg); } @@ -474,7 +471,7 @@ static inline unsigned int hdspm_read(hdspm_t * hdspm, unsigned int reg) mixer is write only on hardware so we have to cache him for read each fader is a u32, but uses only the first 16 bit */ -static inline int hdspm_read_in_gain(hdspm_t * hdspm, unsigned int chan, +static inline int hdspm_read_in_gain(struct hdspm * hdspm, unsigned int chan, unsigned int in) { if (chan > HDSPM_MIXER_CHANNELS || in > HDSPM_MIXER_CHANNELS) @@ -483,7 +480,7 @@ static inline int hdspm_read_in_gain(hdspm_t * hdspm, unsigned int chan, return hdspm->mixer->ch[chan].in[in]; } -static inline int hdspm_read_pb_gain(hdspm_t * hdspm, unsigned int chan, +static inline int hdspm_read_pb_gain(struct hdspm * hdspm, unsigned int chan, unsigned int pb) { if (chan > HDSPM_MIXER_CHANNELS || pb > HDSPM_MIXER_CHANNELS) @@ -491,7 +488,7 @@ static inline int hdspm_read_pb_gain(hdspm_t * hdspm, unsigned int chan, return hdspm->mixer->ch[chan].pb[pb]; } -static inline int hdspm_write_in_gain(hdspm_t * hdspm, unsigned int chan, +static inline int hdspm_write_in_gain(struct hdspm * hdspm, unsigned int chan, unsigned int in, unsigned short data) { if (chan >= HDSPM_MIXER_CHANNELS || in >= HDSPM_MIXER_CHANNELS) @@ -504,7 +501,7 @@ static inline int hdspm_write_in_gain(hdspm_t * hdspm, unsigned int chan, return 0; } -static inline int hdspm_write_pb_gain(hdspm_t * hdspm, unsigned int chan, +static inline int hdspm_write_pb_gain(struct hdspm * hdspm, unsigned int chan, unsigned int pb, unsigned short data) { if (chan >= HDSPM_MIXER_CHANNELS || pb >= HDSPM_MIXER_CHANNELS) @@ -519,18 +516,18 @@ static inline int hdspm_write_pb_gain(hdspm_t * hdspm, unsigned int chan, /* enable DMA for specific channels, now available for DSP-MADI */ -static inline void snd_hdspm_enable_in(hdspm_t * hdspm, int i, int v) +static inline void snd_hdspm_enable_in(struct hdspm * hdspm, int i, int v) { hdspm_write(hdspm, HDSPM_inputEnableBase + (4 * i), v); } -static inline void snd_hdspm_enable_out(hdspm_t * hdspm, int i, int v) +static inline void snd_hdspm_enable_out(struct hdspm * hdspm, int i, int v) { hdspm_write(hdspm, HDSPM_outputEnableBase + (4 * i), v); } /* check if same process is writing and reading */ -static inline int snd_hdspm_use_is_exclusive(hdspm_t * hdspm) +static inline int snd_hdspm_use_is_exclusive(struct hdspm * hdspm) { unsigned long flags; int ret = 1; @@ -545,7 +542,7 @@ static inline int snd_hdspm_use_is_exclusive(hdspm_t * hdspm) } /* check for external sample rate */ -static inline int hdspm_external_sample_rate(hdspm_t * hdspm) +static inline int hdspm_external_sample_rate(struct hdspm * hdspm) { unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); unsigned int status = hdspm_read(hdspm, HDSPM_statusRegister); @@ -630,13 +627,13 @@ static inline int hdspm_external_sample_rate(hdspm_t * hdspm) } /* Latency function */ -static inline void hdspm_compute_period_size(hdspm_t * hdspm) +static inline void hdspm_compute_period_size(struct hdspm * hdspm) { hdspm->period_bytes = 1 << ((hdspm_decode_latency(hdspm->control_register) + 8)); } -static snd_pcm_uframes_t hdspm_hw_pointer(hdspm_t * hdspm) +static snd_pcm_uframes_t hdspm_hw_pointer(struct hdspm * hdspm) { int position; @@ -660,20 +657,20 @@ static snd_pcm_uframes_t hdspm_hw_pointer(hdspm_t * hdspm) } -static inline void hdspm_start_audio(hdspm_t * s) +static inline void hdspm_start_audio(struct hdspm * s) { s->control_register |= (HDSPM_AudioInterruptEnable | HDSPM_Start); hdspm_write(s, HDSPM_controlRegister, s->control_register); } -static inline void hdspm_stop_audio(hdspm_t * s) +static inline void hdspm_stop_audio(struct hdspm * s) { s->control_register &= ~(HDSPM_Start | HDSPM_AudioInterruptEnable); hdspm_write(s, HDSPM_controlRegister, s->control_register); } /* should I silence all or only opened ones ? doit all for first even is 4MB*/ -static inline void hdspm_silence_playback(hdspm_t * hdspm) +static inline void hdspm_silence_playback(struct hdspm * hdspm) { int i; int n = hdspm->period_bytes; @@ -687,7 +684,7 @@ static inline void hdspm_silence_playback(hdspm_t * hdspm) } } -static int hdspm_set_interrupt_interval(hdspm_t * s, unsigned int frames) +static int hdspm_set_interrupt_interval(struct hdspm * s, unsigned int frames) { int n; @@ -713,7 +710,7 @@ static int hdspm_set_interrupt_interval(hdspm_t * s, unsigned int frames) /* dummy set rate lets see what happens */ -static int hdspm_set_rate(hdspm_t * hdspm, int rate, int called_internally) +static int hdspm_set_rate(struct hdspm * hdspm, int rate, int called_internally) { int reject_if_open = 0; int current_rate; @@ -838,7 +835,7 @@ static int hdspm_set_rate(hdspm_t * hdspm, int rate, int called_internally) } /* mainly for init to 0 on load */ -static void all_in_all_mixer(hdspm_t * hdspm, int sgain) +static void all_in_all_mixer(struct hdspm * hdspm, int sgain) { int i, j; unsigned int gain = @@ -855,7 +852,7 @@ static void all_in_all_mixer(hdspm_t * hdspm, int sgain) MIDI ----------------------------------------------------------------------------*/ -static inline unsigned char snd_hdspm_midi_read_byte (hdspm_t *hdspm, int id) +static inline unsigned char snd_hdspm_midi_read_byte (struct hdspm *hdspm, int id) { /* the hardware already does the relevant bit-mask with 0xff */ if (id) @@ -864,7 +861,7 @@ static inline unsigned char snd_hdspm_midi_read_byte (hdspm_t *hdspm, int id) return hdspm_read(hdspm, HDSPM_midiDataIn0); } -static inline void snd_hdspm_midi_write_byte (hdspm_t *hdspm, int id, int val) +static inline void snd_hdspm_midi_write_byte (struct hdspm *hdspm, int id, int val) { /* the hardware already does the relevant bit-mask with 0xff */ if (id) @@ -873,7 +870,7 @@ static inline void snd_hdspm_midi_write_byte (hdspm_t *hdspm, int id, int val) return hdspm_write(hdspm, HDSPM_midiDataOut0, val); } -static inline int snd_hdspm_midi_input_available (hdspm_t *hdspm, int id) +static inline int snd_hdspm_midi_input_available (struct hdspm *hdspm, int id) { if (id) return (hdspm_read(hdspm, HDSPM_midiStatusIn1) & 0xff); @@ -881,7 +878,7 @@ static inline int snd_hdspm_midi_input_available (hdspm_t *hdspm, int id) return (hdspm_read(hdspm, HDSPM_midiStatusIn0) & 0xff); } -static inline int snd_hdspm_midi_output_possible (hdspm_t *hdspm, int id) +static inline int snd_hdspm_midi_output_possible (struct hdspm *hdspm, int id) { int fifo_bytes_used; @@ -896,13 +893,13 @@ static inline int snd_hdspm_midi_output_possible (hdspm_t *hdspm, int id) return 0; } -static inline void snd_hdspm_flush_midi_input (hdspm_t *hdspm, int id) +static inline void snd_hdspm_flush_midi_input (struct hdspm *hdspm, int id) { while (snd_hdspm_midi_input_available (hdspm, id)) snd_hdspm_midi_read_byte (hdspm, id); } -static int snd_hdspm_midi_output_write (hdspm_midi_t *hmidi) +static int snd_hdspm_midi_output_write (struct hdspm_midi *hmidi) { unsigned long flags; int n_pending; @@ -930,7 +927,7 @@ static int snd_hdspm_midi_output_write (hdspm_midi_t *hmidi) return 0; } -static int snd_hdspm_midi_input_read (hdspm_midi_t *hmidi) +static int snd_hdspm_midi_input_read (struct hdspm_midi *hmidi) { unsigned char buf[128]; /* this buffer is designed to match the MIDI input FIFO size */ unsigned long flags; @@ -967,14 +964,14 @@ static int snd_hdspm_midi_input_read (hdspm_midi_t *hmidi) return snd_hdspm_midi_output_write (hmidi); } -static void snd_hdspm_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_hdspm_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - hdspm_t *hdspm; - hdspm_midi_t *hmidi; + struct hdspm *hdspm; + struct hdspm_midi *hmidi; unsigned long flags; u32 ie; - hmidi = (hdspm_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdspm_midi *) substream->rmidi->private_data; hdspm = hmidi->hdspm; ie = hmidi->id ? HDSPM_Midi1InterruptEnable : HDSPM_Midi0InterruptEnable; spin_lock_irqsave (&hdspm->lock, flags); @@ -993,7 +990,7 @@ static void snd_hdspm_midi_input_trigger(snd_rawmidi_substream_t * substream, in static void snd_hdspm_midi_output_timer(unsigned long data) { - hdspm_midi_t *hmidi = (hdspm_midi_t *) data; + struct hdspm_midi *hmidi = (struct hdspm_midi *) data; unsigned long flags; snd_hdspm_midi_output_write(hmidi); @@ -1013,12 +1010,12 @@ static void snd_hdspm_midi_output_timer(unsigned long data) spin_unlock_irqrestore (&hmidi->lock, flags); } -static void snd_hdspm_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_hdspm_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - hdspm_midi_t *hmidi; + struct hdspm_midi *hmidi; unsigned long flags; - hmidi = (hdspm_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdspm_midi *) substream->rmidi->private_data; spin_lock_irqsave (&hmidi->lock, flags); if (up) { if (!hmidi->istimer) { @@ -1039,11 +1036,11 @@ static void snd_hdspm_midi_output_trigger(snd_rawmidi_substream_t * substream, i snd_hdspm_midi_output_write(hmidi); } -static int snd_hdspm_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_hdspm_midi_input_open(struct snd_rawmidi_substream *substream) { - hdspm_midi_t *hmidi; + struct hdspm_midi *hmidi; - hmidi = (hdspm_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdspm_midi *) substream->rmidi->private_data; spin_lock_irq (&hmidi->lock); snd_hdspm_flush_midi_input (hmidi->hdspm, hmidi->id); hmidi->input = substream; @@ -1052,11 +1049,11 @@ static int snd_hdspm_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_hdspm_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_hdspm_midi_output_open(struct snd_rawmidi_substream *substream) { - hdspm_midi_t *hmidi; + struct hdspm_midi *hmidi; - hmidi = (hdspm_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdspm_midi *) substream->rmidi->private_data; spin_lock_irq (&hmidi->lock); hmidi->output = substream; spin_unlock_irq (&hmidi->lock); @@ -1064,13 +1061,13 @@ static int snd_hdspm_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_hdspm_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_hdspm_midi_input_close(struct snd_rawmidi_substream *substream) { - hdspm_midi_t *hmidi; + struct hdspm_midi *hmidi; snd_hdspm_midi_input_trigger (substream, 0); - hmidi = (hdspm_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdspm_midi *) substream->rmidi->private_data; spin_lock_irq (&hmidi->lock); hmidi->input = NULL; spin_unlock_irq (&hmidi->lock); @@ -1078,13 +1075,13 @@ static int snd_hdspm_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_hdspm_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_hdspm_midi_output_close(struct snd_rawmidi_substream *substream) { - hdspm_midi_t *hmidi; + struct hdspm_midi *hmidi; snd_hdspm_midi_output_trigger (substream, 0); - hmidi = (hdspm_midi_t *) substream->rmidi->private_data; + hmidi = (struct hdspm_midi *) substream->rmidi->private_data; spin_lock_irq (&hmidi->lock); hmidi->output = NULL; spin_unlock_irq (&hmidi->lock); @@ -1092,21 +1089,21 @@ static int snd_hdspm_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static snd_rawmidi_ops_t snd_hdspm_midi_output = +static struct snd_rawmidi_ops snd_hdspm_midi_output = { .open = snd_hdspm_midi_output_open, .close = snd_hdspm_midi_output_close, .trigger = snd_hdspm_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_hdspm_midi_input = +static struct snd_rawmidi_ops snd_hdspm_midi_input = { .open = snd_hdspm_midi_input_open, .close = snd_hdspm_midi_input_close, .trigger = snd_hdspm_midi_input_trigger, }; -static int __devinit snd_hdspm_create_midi (snd_card_t *card, hdspm_t *hdspm, int id) +static int __devinit snd_hdspm_create_midi (struct snd_card *card, struct hdspm *hdspm, int id) { int err; char buf[32]; @@ -1140,7 +1137,7 @@ static int __devinit snd_hdspm_create_midi (snd_card_t *card, hdspm_t *hdspm, in static void hdspm_midi_tasklet(unsigned long arg) { - hdspm_t *hdspm = (hdspm_t *)arg; + struct hdspm *hdspm = (struct hdspm *)arg; if (hdspm->midi[0].pending) snd_hdspm_midi_input_read (&hdspm->midi[0]); @@ -1164,19 +1161,19 @@ static void hdspm_midi_tasklet(unsigned long arg) .get = snd_hdspm_get_system_sample_rate \ } -static int snd_hdspm_info_system_sample_rate(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_system_sample_rate(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; return 0; } -static int snd_hdspm_get_system_sample_rate(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * +static int snd_hdspm_get_system_sample_rate(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value * ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdspm->system_sample_rate; return 0; @@ -1191,8 +1188,8 @@ static int snd_hdspm_get_system_sample_rate(snd_kcontrol_t * kcontrol, .get = snd_hdspm_get_autosync_sample_rate \ } -static int snd_hdspm_info_autosync_sample_rate(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_autosync_sample_rate(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "32000", "44100", "48000", "64000", "88200", "96000", @@ -1210,11 +1207,11 @@ static int snd_hdspm_info_autosync_sample_rate(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * +static int snd_hdspm_get_autosync_sample_rate(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value * ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); switch (hdspm_external_sample_rate(hdspm)) { case 32000: @@ -1262,7 +1259,7 @@ static int snd_hdspm_get_autosync_sample_rate(snd_kcontrol_t * kcontrol, -static int hdspm_system_clock_mode(hdspm_t * hdspm) +static int hdspm_system_clock_mode(struct hdspm * hdspm) { /* Always reflect the hardware info, rme is never wrong !!!! */ @@ -1271,8 +1268,8 @@ static int hdspm_system_clock_mode(hdspm_t * hdspm) return 1; } -static int snd_hdspm_info_system_clock_mode(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_system_clock_mode(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "Master", "Slave" }; @@ -1287,10 +1284,10 @@ static int snd_hdspm_info_system_clock_mode(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_system_clock_mode(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_system_clock_mode(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdspm_system_clock_mode(hdspm); @@ -1306,7 +1303,7 @@ static int snd_hdspm_get_system_clock_mode(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_clock_source \ } -static int hdspm_clock_source(hdspm_t * hdspm) +static int hdspm_clock_source(struct hdspm * hdspm) { if (hdspm->control_register & HDSPM_ClockModeMaster) { switch (hdspm->system_sample_rate) { @@ -1336,7 +1333,7 @@ static int hdspm_clock_source(hdspm_t * hdspm) } } -static int hdspm_set_clock_source(hdspm_t * hdspm, int mode) +static int hdspm_set_clock_source(struct hdspm * hdspm, int mode) { int rate; switch (mode) { @@ -1386,8 +1383,8 @@ static int hdspm_set_clock_source(hdspm_t * hdspm, int mode) return 0; } -static int snd_hdspm_info_clock_source(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_clock_source(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "AutoSync", "Internal 32.0 kHz", "Internal 44.1 kHz", @@ -1412,19 +1409,19 @@ static int snd_hdspm_info_clock_source(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_clock_source(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_clock_source(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdspm_clock_source(hdspm); return 0; } -static int snd_hdspm_put_clock_source(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_clock_source(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change; int val; @@ -1453,7 +1450,7 @@ static int snd_hdspm_put_clock_source(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_pref_sync_ref \ } -static int hdspm_pref_sync_ref(hdspm_t * hdspm) +static int hdspm_pref_sync_ref(struct hdspm * hdspm) { /* Notice that this looks at the requested sync source, not the one actually in use. @@ -1468,7 +1465,7 @@ static int hdspm_pref_sync_ref(hdspm_t * hdspm) return HDSPM_SYNC_FROM_WORD; } -static int hdspm_set_pref_sync_ref(hdspm_t * hdspm, int pref) +static int hdspm_set_pref_sync_ref(struct hdspm * hdspm, int pref) { hdspm->control_register &= ~HDSPM_SyncRefMask; @@ -1486,8 +1483,8 @@ static int hdspm_set_pref_sync_ref(hdspm_t * hdspm, int pref) return 0; } -static int snd_hdspm_info_pref_sync_ref(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_pref_sync_ref(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "Word", "MADI" }; @@ -1504,19 +1501,19 @@ static int snd_hdspm_info_pref_sync_ref(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_pref_sync_ref(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_pref_sync_ref(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdspm_pref_sync_ref(hdspm); return 0; } -static int snd_hdspm_put_pref_sync_ref(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_pref_sync_ref(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change, max; unsigned int val; @@ -1543,7 +1540,7 @@ static int snd_hdspm_put_pref_sync_ref(snd_kcontrol_t * kcontrol, .get = snd_hdspm_get_autosync_ref, \ } -static int hdspm_autosync_ref(hdspm_t * hdspm) +static int hdspm_autosync_ref(struct hdspm * hdspm) { /* This looks at the autosync selected sync reference */ unsigned int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); @@ -1566,8 +1563,8 @@ static int hdspm_autosync_ref(hdspm_t * hdspm) return 0; } -static int snd_hdspm_info_autosync_ref(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_autosync_ref(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "WordClock", "MADI", "None" }; @@ -1582,10 +1579,10 @@ static int snd_hdspm_info_autosync_ref(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_autosync_ref(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_autosync_ref(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdspm_pref_sync_ref(hdspm); return 0; @@ -1600,13 +1597,13 @@ static int snd_hdspm_get_autosync_ref(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_line_out \ } -static int hdspm_line_out(hdspm_t * hdspm) +static int hdspm_line_out(struct hdspm * hdspm) { return (hdspm->control_register & HDSPM_LineOut) ? 1 : 0; } -static int hdspm_set_line_output(hdspm_t * hdspm, int out) +static int hdspm_set_line_output(struct hdspm * hdspm, int out) { if (out) hdspm->control_register |= HDSPM_LineOut; @@ -1617,8 +1614,8 @@ static int hdspm_set_line_output(hdspm_t * hdspm, int out) return 0; } -static int snd_hdspm_info_line_out(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_line_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1627,10 +1624,10 @@ static int snd_hdspm_info_line_out(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_line_out(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_line_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); spin_lock_irq(&hdspm->lock); ucontrol->value.integer.value[0] = hdspm_line_out(hdspm); @@ -1638,10 +1635,10 @@ static int snd_hdspm_get_line_out(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_put_line_out(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_line_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1664,12 +1661,12 @@ static int snd_hdspm_put_line_out(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_tx_64 \ } -static int hdspm_tx_64(hdspm_t * hdspm) +static int hdspm_tx_64(struct hdspm * hdspm) { return (hdspm->control_register & HDSPM_TX_64ch) ? 1 : 0; } -static int hdspm_set_tx_64(hdspm_t * hdspm, int out) +static int hdspm_set_tx_64(struct hdspm * hdspm, int out) { if (out) hdspm->control_register |= HDSPM_TX_64ch; @@ -1680,8 +1677,8 @@ static int hdspm_set_tx_64(hdspm_t * hdspm, int out) return 0; } -static int snd_hdspm_info_tx_64(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_tx_64(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1690,10 +1687,10 @@ static int snd_hdspm_info_tx_64(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_tx_64(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_tx_64(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); spin_lock_irq(&hdspm->lock); ucontrol->value.integer.value[0] = hdspm_tx_64(hdspm); @@ -1701,10 +1698,10 @@ static int snd_hdspm_get_tx_64(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_put_tx_64(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_tx_64(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1727,12 +1724,12 @@ static int snd_hdspm_put_tx_64(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_c_tms \ } -static int hdspm_c_tms(hdspm_t * hdspm) +static int hdspm_c_tms(struct hdspm * hdspm) { return (hdspm->control_register & HDSPM_clr_tms) ? 1 : 0; } -static int hdspm_set_c_tms(hdspm_t * hdspm, int out) +static int hdspm_set_c_tms(struct hdspm * hdspm, int out) { if (out) hdspm->control_register |= HDSPM_clr_tms; @@ -1743,8 +1740,8 @@ static int hdspm_set_c_tms(hdspm_t * hdspm, int out) return 0; } -static int snd_hdspm_info_c_tms(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_c_tms(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1753,10 +1750,10 @@ static int snd_hdspm_info_c_tms(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_c_tms(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_c_tms(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); spin_lock_irq(&hdspm->lock); ucontrol->value.integer.value[0] = hdspm_c_tms(hdspm); @@ -1764,10 +1761,10 @@ static int snd_hdspm_get_c_tms(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_put_c_tms(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_c_tms(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1790,12 +1787,12 @@ static int snd_hdspm_put_c_tms(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_safe_mode \ } -static int hdspm_safe_mode(hdspm_t * hdspm) +static int hdspm_safe_mode(struct hdspm * hdspm) { return (hdspm->control_register & HDSPM_AutoInp) ? 1 : 0; } -static int hdspm_set_safe_mode(hdspm_t * hdspm, int out) +static int hdspm_set_safe_mode(struct hdspm * hdspm, int out) { if (out) hdspm->control_register |= HDSPM_AutoInp; @@ -1806,8 +1803,8 @@ static int hdspm_set_safe_mode(hdspm_t * hdspm, int out) return 0; } -static int snd_hdspm_info_safe_mode(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_safe_mode(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1816,10 +1813,10 @@ static int snd_hdspm_info_safe_mode(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_safe_mode(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_safe_mode(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); spin_lock_irq(&hdspm->lock); ucontrol->value.integer.value[0] = hdspm_safe_mode(hdspm); @@ -1827,10 +1824,10 @@ static int snd_hdspm_get_safe_mode(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_put_safe_mode(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_safe_mode(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1853,12 +1850,12 @@ static int snd_hdspm_put_safe_mode(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_input_select \ } -static int hdspm_input_select(hdspm_t * hdspm) +static int hdspm_input_select(struct hdspm * hdspm) { return (hdspm->control_register & HDSPM_InputSelect0) ? 1 : 0; } -static int hdspm_set_input_select(hdspm_t * hdspm, int out) +static int hdspm_set_input_select(struct hdspm * hdspm, int out) { if (out) hdspm->control_register |= HDSPM_InputSelect0; @@ -1869,8 +1866,8 @@ static int hdspm_set_input_select(hdspm_t * hdspm, int out) return 0; } -static int snd_hdspm_info_input_select(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_input_select(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "optical", "coaxial" }; @@ -1887,10 +1884,10 @@ static int snd_hdspm_info_input_select(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_input_select(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_input_select(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); spin_lock_irq(&hdspm->lock); ucontrol->value.enumerated.item[0] = hdspm_input_select(hdspm); @@ -1898,10 +1895,10 @@ static int snd_hdspm_get_input_select(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_put_input_select(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_input_select(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1937,8 +1934,8 @@ static int snd_hdspm_put_input_select(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_mixer \ } -static int snd_hdspm_info_mixer(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 3; @@ -1948,10 +1945,10 @@ static int snd_hdspm_info_mixer(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_mixer(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int source; int destination; @@ -1981,10 +1978,10 @@ static int snd_hdspm_get_mixer(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_put_mixer(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change; int source; int destination; @@ -2041,8 +2038,8 @@ static int snd_hdspm_put_mixer(snd_kcontrol_t * kcontrol, .put = snd_hdspm_put_playback_mixer \ } -static int snd_hdspm_info_playback_mixer(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_playback_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -2052,10 +2049,10 @@ static int snd_hdspm_info_playback_mixer(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_get_playback_mixer(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_playback_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int channel; int mapped_channel; @@ -2079,10 +2076,10 @@ static int snd_hdspm_get_playback_mixer(snd_kcontrol_t * kcontrol, return 0; } -static int snd_hdspm_put_playback_mixer(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_put_playback_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); int change; int channel; int mapped_channel; @@ -2121,8 +2118,8 @@ static int snd_hdspm_put_playback_mixer(snd_kcontrol_t * kcontrol, .get = snd_hdspm_get_wc_sync_check \ } -static int snd_hdspm_info_sync_check(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_hdspm_info_sync_check(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "No Lock", "Lock", "Sync" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -2136,7 +2133,7 @@ static int snd_hdspm_info_sync_check(snd_kcontrol_t * kcontrol, return 0; } -static int hdspm_wc_sync_check(hdspm_t * hdspm) +static int hdspm_wc_sync_check(struct hdspm * hdspm) { int status2 = hdspm_read(hdspm, HDSPM_statusRegister2); if (status2 & HDSPM_wcLock) { @@ -2148,10 +2145,10 @@ static int hdspm_wc_sync_check(hdspm_t * hdspm) return 0; } -static int snd_hdspm_get_wc_sync_check(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_hdspm_get_wc_sync_check(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdspm_wc_sync_check(hdspm); return 0; @@ -2167,7 +2164,7 @@ static int snd_hdspm_get_wc_sync_check(snd_kcontrol_t * kcontrol, .get = snd_hdspm_get_madisync_sync_check \ } -static int hdspm_madisync_sync_check(hdspm_t * hdspm) +static int hdspm_madisync_sync_check(struct hdspm * hdspm) { int status = hdspm_read(hdspm, HDSPM_statusRegister); if (status & HDSPM_madiLock) { @@ -2179,11 +2176,11 @@ static int hdspm_madisync_sync_check(hdspm_t * hdspm) return 0; } -static int snd_hdspm_get_madisync_sync_check(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * +static int snd_hdspm_get_madisync_sync_check(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value * ucontrol) { - hdspm_t *hdspm = snd_kcontrol_chip(kcontrol); + struct hdspm *hdspm = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = hdspm_madisync_sync_check(hdspm); @@ -2193,7 +2190,7 @@ static int snd_hdspm_get_madisync_sync_check(snd_kcontrol_t * kcontrol, -static snd_kcontrol_new_t snd_hdspm_controls[] = { +static struct snd_kcontrol_new snd_hdspm_controls[] = { HDSPM_MIXER("Mixer", 0), /* 'Sample Clock Source' complies with the alsa control naming scheme */ @@ -2214,10 +2211,10 @@ static snd_kcontrol_new_t snd_hdspm_controls[] = { HDSPM_INPUT_SELECT("Input Select", 0), }; -static snd_kcontrol_new_t snd_hdspm_playback_mixer = HDSPM_PLAYBACK_MIXER; +static struct snd_kcontrol_new snd_hdspm_playback_mixer = HDSPM_PLAYBACK_MIXER; -static int hdspm_update_simple_mixer_controls(hdspm_t * hdspm) +static int hdspm_update_simple_mixer_controls(struct hdspm * hdspm) { int i; @@ -2241,11 +2238,11 @@ static int hdspm_update_simple_mixer_controls(hdspm_t * hdspm) } -static int snd_hdspm_create_controls(snd_card_t * card, hdspm_t * hdspm) +static int snd_hdspm_create_controls(struct snd_card *card, struct hdspm * hdspm) { unsigned int idx, limit; int err; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; /* add control list first */ @@ -2292,9 +2289,9 @@ static int snd_hdspm_create_controls(snd_card_t * card, hdspm_t * hdspm) ------------------------------------------------------------*/ static void -snd_hdspm_proc_read(snd_info_entry_t * entry, snd_info_buffer_t * buffer) +snd_hdspm_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer) { - hdspm_t *hdspm = (hdspm_t *) entry->private_data; + struct hdspm *hdspm = (struct hdspm *) entry->private_data; unsigned int status; unsigned int status2; char *pref_sync_ref; @@ -2487,9 +2484,9 @@ snd_hdspm_proc_read(snd_info_entry_t * entry, snd_info_buffer_t * buffer) snd_iprintf(buffer, "\n"); } -static void __devinit snd_hdspm_proc_init(hdspm_t * hdspm) +static void __devinit snd_hdspm_proc_init(struct hdspm * hdspm) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (!snd_card_proc_new(hdspm->card, "hdspm", &entry)) snd_info_set_text_ops(entry, hdspm, 1024, @@ -2500,7 +2497,7 @@ static void __devinit snd_hdspm_proc_init(hdspm_t * hdspm) hdspm intitialize ------------------------------------------------------------*/ -static int snd_hdspm_set_defaults(hdspm_t * hdspm) +static int snd_hdspm_set_defaults(struct hdspm * hdspm) { unsigned int i; @@ -2562,7 +2559,7 @@ static int snd_hdspm_set_defaults(hdspm_t * hdspm) static irqreturn_t snd_hdspm_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - hdspm_t *hdspm = (hdspm_t *) dev_id; + struct hdspm *hdspm = (struct hdspm *) dev_id; unsigned int status; int audio; int midi0; @@ -2627,14 +2624,14 @@ static irqreturn_t snd_hdspm_interrupt(int irq, void *dev_id, ------------------------------------------------------------*/ -static snd_pcm_uframes_t snd_hdspm_hw_pointer(snd_pcm_substream_t * +static snd_pcm_uframes_t snd_hdspm_hw_pointer(struct snd_pcm_substream * substream) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); return hdspm_hw_pointer(hdspm); } -static char *hdspm_channel_buffer_location(hdspm_t * hdspm, +static char *hdspm_channel_buffer_location(struct hdspm * hdspm, int stream, int channel) { int mapped_channel; @@ -2656,11 +2653,11 @@ static char *hdspm_channel_buffer_location(hdspm_t * hdspm, /* dont know why need it ??? */ -static int snd_hdspm_playback_copy(snd_pcm_substream_t * substream, +static int snd_hdspm_playback_copy(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); char *channel_buf; snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4, @@ -2675,11 +2672,11 @@ static int snd_hdspm_playback_copy(snd_pcm_substream_t * substream, return copy_from_user(channel_buf + pos * 4, src, count * 4); } -static int snd_hdspm_capture_copy(snd_pcm_substream_t * substream, +static int snd_hdspm_capture_copy(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); char *channel_buf; snd_assert(pos + count <= HDSPM_CHANNEL_BUFFER_BYTES / 4, @@ -2692,11 +2689,11 @@ static int snd_hdspm_capture_copy(snd_pcm_substream_t * substream, return copy_to_user(dst, channel_buf + pos * 4, count * 4); } -static int snd_hdspm_hw_silence(snd_pcm_substream_t * substream, +static int snd_hdspm_hw_silence(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); char *channel_buf; channel_buf = @@ -2707,11 +2704,11 @@ static int snd_hdspm_hw_silence(snd_pcm_substream_t * substream, return 0; } -static int snd_hdspm_reset(snd_pcm_substream_t * substream) +static int snd_hdspm_reset(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - hdspm_t *hdspm = snd_pcm_substream_chip(substream); - snd_pcm_substream_t *other; + struct snd_pcm_runtime *runtime = substream->runtime; + struct hdspm *hdspm = snd_pcm_substream_chip(substream); + struct snd_pcm_substream *other; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) other = hdspm->capture_substream; @@ -2724,8 +2721,8 @@ static int snd_hdspm_reset(snd_pcm_substream_t * substream) runtime->status->hw_ptr = 0; if (other) { struct list_head *pos; - snd_pcm_substream_t *s; - snd_pcm_runtime_t *oruntime = other->runtime; + struct snd_pcm_substream *s; + struct snd_pcm_runtime *oruntime = other->runtime; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == other) { @@ -2738,10 +2735,10 @@ static int snd_hdspm_reset(snd_pcm_substream_t * substream) return 0; } -static int snd_hdspm_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * params) +static int snd_hdspm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); int err; int i; pid_t this_pid; @@ -2839,10 +2836,10 @@ static int snd_hdspm_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_hdspm_hw_free(snd_pcm_substream_t * substream) +static int snd_hdspm_hw_free(struct snd_pcm_substream *substream) { int i; - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { @@ -2865,10 +2862,10 @@ static int snd_hdspm_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_hdspm_channel_info(snd_pcm_substream_t * substream, - snd_pcm_channel_info_t * info) +static int snd_hdspm_channel_info(struct snd_pcm_substream *substream, + struct snd_pcm_channel_info * info) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); int mapped_channel; snd_assert(info->channel < HDSPM_MAX_CHANNELS, return -EINVAL); @@ -2882,7 +2879,7 @@ static int snd_hdspm_channel_info(snd_pcm_substream_t * substream, return 0; } -static int snd_hdspm_ioctl(snd_pcm_substream_t * substream, +static int snd_hdspm_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { switch (cmd) { @@ -2893,7 +2890,7 @@ static int snd_hdspm_ioctl(snd_pcm_substream_t * substream, case SNDRV_PCM_IOCTL1_CHANNEL_INFO: { - snd_pcm_channel_info_t *info = arg; + struct snd_pcm_channel_info *info = arg; return snd_hdspm_channel_info(substream, info); } default: @@ -2903,10 +2900,10 @@ static int snd_hdspm_ioctl(snd_pcm_substream_t * substream, return snd_pcm_lib_ioctl(substream, cmd, arg); } -static int snd_hdspm_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_hdspm_trigger(struct snd_pcm_substream *substream, int cmd) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); - snd_pcm_substream_t *other; + struct hdspm *hdspm = snd_pcm_substream_chip(substream); + struct snd_pcm_substream *other; int running; spin_lock(&hdspm->lock); @@ -2930,7 +2927,7 @@ static int snd_hdspm_trigger(snd_pcm_substream_t * substream, int cmd) if (other) { struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == other) { @@ -2968,7 +2965,7 @@ static int snd_hdspm_trigger(snd_pcm_substream_t * substream, int cmd) return 0; } -static int snd_hdspm_prepare(snd_pcm_substream_t * substream) +static int snd_hdspm_prepare(struct snd_pcm_substream *substream) { return 0; } @@ -2976,7 +2973,7 @@ static int snd_hdspm_prepare(snd_pcm_substream_t * substream) static unsigned int period_sizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192 }; -static snd_pcm_hardware_t snd_hdspm_playback_subinfo = { +static struct snd_pcm_hardware snd_hdspm_playback_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_NONINTERLEAVED | @@ -3000,7 +2997,7 @@ static snd_pcm_hardware_t snd_hdspm_playback_subinfo = { .fifo_size = 0 }; -static snd_pcm_hardware_t snd_hdspm_capture_subinfo = { +static struct snd_pcm_hardware snd_hdspm_capture_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_NONINTERLEAVED | @@ -3024,31 +3021,31 @@ static snd_pcm_hardware_t snd_hdspm_capture_subinfo = { .fifo_size = 0 }; -static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = { +static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes = { .count = ARRAY_SIZE(period_sizes), .list = period_sizes, .mask = 0 }; -static int snd_hdspm_hw_rule_channels_rate(snd_pcm_hw_params_t * params, - snd_pcm_hw_rule_t * rule) +static int snd_hdspm_hw_rule_channels_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule * rule) { - hdspm_t *hdspm = rule->private; - snd_interval_t *c = + struct hdspm *hdspm = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_interval_t *r = + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (r->min > 48000) { - snd_interval_t t = { + struct snd_interval t = { .min = 1, .max = hdspm->ds_channels, .integer = 1, }; return snd_interval_refine(c, &t); } else if (r->max < 64000) { - snd_interval_t t = { + struct snd_interval t = { .min = 1, .max = hdspm->ss_channels, .integer = 1, @@ -3058,24 +3055,24 @@ static int snd_hdspm_hw_rule_channels_rate(snd_pcm_hw_params_t * params, return 0; } -static int snd_hdspm_hw_rule_rate_channels(snd_pcm_hw_params_t * params, - snd_pcm_hw_rule_t * rule) +static int snd_hdspm_hw_rule_rate_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule * rule) { - hdspm_t *hdspm = rule->private; - snd_interval_t *c = + struct hdspm *hdspm = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_interval_t *r = + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (c->min <= hdspm->ss_channels) { - snd_interval_t t = { + struct snd_interval t = { .min = 32000, .max = 48000, .integer = 1, }; return snd_interval_refine(r, &t); } else if (c->max > hdspm->ss_channels) { - snd_interval_t t = { + struct snd_interval t = { .min = 64000, .max = 96000, .integer = 1, @@ -3086,10 +3083,10 @@ static int snd_hdspm_hw_rule_rate_channels(snd_pcm_hw_params_t * params, return 0; } -static int snd_hdspm_playback_open(snd_pcm_substream_t * substream) +static int snd_hdspm_playback_open(struct snd_pcm_substream *substream) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct hdspm *hdspm = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_printdd("Open device substream %d\n", substream->stream); @@ -3124,9 +3121,9 @@ static int snd_hdspm_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_hdspm_playback_release(snd_pcm_substream_t * substream) +static int snd_hdspm_playback_release(struct snd_pcm_substream *substream) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); spin_lock_irq(&hdspm->lock); @@ -3139,10 +3136,10 @@ static int snd_hdspm_playback_release(snd_pcm_substream_t * substream) } -static int snd_hdspm_capture_open(snd_pcm_substream_t * substream) +static int snd_hdspm_capture_open(struct snd_pcm_substream *substream) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct hdspm *hdspm = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irq(&hdspm->lock); snd_pcm_set_sync(substream); @@ -3171,9 +3168,9 @@ static int snd_hdspm_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_hdspm_capture_release(snd_pcm_substream_t * substream) +static int snd_hdspm_capture_release(struct snd_pcm_substream *substream) { - hdspm_t *hdspm = snd_pcm_substream_chip(substream); + struct hdspm *hdspm = snd_pcm_substream_chip(substream); spin_lock_irq(&hdspm->lock); @@ -3184,21 +3181,21 @@ static int snd_hdspm_capture_release(snd_pcm_substream_t * substream) return 0; } -static int snd_hdspm_hwdep_dummy_op(snd_hwdep_t * hw, struct file *file) +static int snd_hdspm_hwdep_dummy_op(struct snd_hwdep * hw, struct file *file) { /* we have nothing to initialize but the call is required */ return 0; } -static int snd_hdspm_hwdep_ioctl(snd_hwdep_t * hw, struct file *file, +static int snd_hdspm_hwdep_ioctl(struct snd_hwdep * hw, struct file *file, unsigned int cmd, unsigned long arg) { - hdspm_t *hdspm = (hdspm_t *) hw->private_data; - struct sndrv_hdspm_mixer_ioctl mixer; - hdspm_config_info_t info; - hdspm_version_t hdspm_version; - struct sndrv_hdspm_peak_rms_ioctl rms; + struct hdspm *hdspm = (struct hdspm *) hw->private_data; + struct hdspm_mixer_ioctl mixer; + struct hdspm_config_info info; + struct hdspm_version hdspm_version; + struct hdspm_peak_rms_ioctl rms; switch (cmd) { @@ -3209,7 +3206,7 @@ static int snd_hdspm_hwdep_ioctl(snd_hwdep_t * hw, struct file *file, /* maybe there is a chance to memorymap in future so dont touch just copy */ if(copy_to_user_fromio((void __user *)rms.peak, hdspm->iobase+HDSPM_MADI_peakrmsbase, - sizeof(hdspm_peak_rms_t)) != 0 ) + sizeof(struct hdspm_peak_rms)) != 0 ) return -EFAULT; break; @@ -3250,7 +3247,7 @@ static int snd_hdspm_hwdep_ioctl(snd_hwdep_t * hw, struct file *file, if (copy_from_user(&mixer, (void __user *)arg, sizeof(mixer))) return -EFAULT; if (copy_to_user - ((void __user *)mixer.mixer, hdspm->mixer, sizeof(hdspm_mixer_t))) + ((void __user *)mixer.mixer, hdspm->mixer, sizeof(struct hdspm_mixer))) return -EFAULT; break; @@ -3260,7 +3257,7 @@ static int snd_hdspm_hwdep_ioctl(snd_hwdep_t * hw, struct file *file, return 0; } -static snd_pcm_ops_t snd_hdspm_playback_ops = { +static struct snd_pcm_ops snd_hdspm_playback_ops = { .open = snd_hdspm_playback_open, .close = snd_hdspm_playback_release, .ioctl = snd_hdspm_ioctl, @@ -3274,7 +3271,7 @@ static snd_pcm_ops_t snd_hdspm_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static snd_pcm_ops_t snd_hdspm_capture_ops = { +static struct snd_pcm_ops snd_hdspm_capture_ops = { .open = snd_hdspm_capture_open, .close = snd_hdspm_capture_release, .ioctl = snd_hdspm_ioctl, @@ -3287,10 +3284,10 @@ static snd_pcm_ops_t snd_hdspm_capture_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static int __devinit snd_hdspm_create_hwdep(snd_card_t * card, - hdspm_t * hdspm) +static int __devinit snd_hdspm_create_hwdep(struct snd_card *card, + struct hdspm * hdspm) { - snd_hwdep_t *hw; + struct snd_hwdep *hw; int err; if ((err = snd_hwdep_new(card, "HDSPM hwdep", 0, &hw)) < 0) @@ -3311,10 +3308,10 @@ static int __devinit snd_hdspm_create_hwdep(snd_card_t * card, /*------------------------------------------------------------ memory interface ------------------------------------------------------------*/ -static int __devinit snd_hdspm_preallocate_memory(hdspm_t * hdspm) +static int __devinit snd_hdspm_preallocate_memory(struct hdspm * hdspm) { int err; - snd_pcm_t *pcm; + struct snd_pcm *pcm; size_t wanted; pcm = hdspm->pcm; @@ -3336,7 +3333,7 @@ static int __devinit snd_hdspm_preallocate_memory(hdspm_t * hdspm) return 0; } -static void hdspm_set_sgbuf(hdspm_t * hdspm, struct snd_sg_buf *sgbuf, +static void hdspm_set_sgbuf(struct hdspm * hdspm, struct snd_sg_buf *sgbuf, unsigned int reg, int channels) { int i; @@ -3347,10 +3344,10 @@ static void hdspm_set_sgbuf(hdspm_t * hdspm, struct snd_sg_buf *sgbuf, } /* ------------- ALSA Devices ---------------------------- */ -static int __devinit snd_hdspm_create_pcm(snd_card_t * card, - hdspm_t * hdspm) +static int __devinit snd_hdspm_create_pcm(struct snd_card *card, + struct hdspm * hdspm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(card, hdspm->card_name, 0, 1, 1, &pcm)) < 0) @@ -3373,14 +3370,14 @@ static int __devinit snd_hdspm_create_pcm(snd_card_t * card, return 0; } -static inline void snd_hdspm_initialize_midi_flush(hdspm_t * hdspm) +static inline void snd_hdspm_initialize_midi_flush(struct hdspm * hdspm) { snd_hdspm_flush_midi_input(hdspm, 0); snd_hdspm_flush_midi_input(hdspm, 1); } -static int __devinit snd_hdspm_create_alsa_devices(snd_card_t * card, - hdspm_t * hdspm) +static int __devinit snd_hdspm_create_alsa_devices(struct snd_card *card, + struct hdspm * hdspm) { int err; @@ -3430,7 +3427,7 @@ static int __devinit snd_hdspm_create_alsa_devices(snd_card_t * card, return 0; } -static int __devinit snd_hdspm_create(snd_card_t * card, hdspm_t * hdspm, +static int __devinit snd_hdspm_create(struct snd_card *card, struct hdspm * hdspm, int precise_ptr, int enable_monitor) { struct pci_dev *pci = hdspm->pci; @@ -3514,12 +3511,11 @@ static int __devinit snd_hdspm_create(snd_card_t * card, hdspm_t * hdspm, hdspm->monitor_outs = enable_monitor; snd_printdd("kmalloc Mixer memory of %d Bytes\n", - sizeof(hdspm_mixer_t)); - if ((hdspm->mixer = - (hdspm_mixer_t *) kmalloc(sizeof(hdspm_mixer_t), GFP_KERNEL)) + sizeof(struct hdspm_mixer)); + if ((hdspm->mixer = kmalloc(sizeof(struct hdspm_mixer), GFP_KERNEL)) == NULL) { snd_printk(KERN_ERR "HDSPM: unable to kmalloc Mixer memory of %d Bytes\n", - (int)sizeof(hdspm_mixer_t)); + (int)sizeof(struct hdspm_mixer)); return err; } @@ -3536,7 +3532,7 @@ static int __devinit snd_hdspm_create(snd_card_t * card, hdspm_t * hdspm, return 0; } -static int snd_hdspm_free(hdspm_t * hdspm) +static int snd_hdspm_free(struct hdspm * hdspm) { if (hdspm->port) { @@ -3566,9 +3562,9 @@ static int snd_hdspm_free(hdspm_t * hdspm) return 0; } -static void snd_hdspm_card_free(snd_card_t * card) +static void snd_hdspm_card_free(struct snd_card *card) { - hdspm_t *hdspm = (hdspm_t *) card->private_data; + struct hdspm *hdspm = (struct hdspm *) card->private_data; if (hdspm) snd_hdspm_free(hdspm); @@ -3578,8 +3574,8 @@ static int __devinit snd_hdspm_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - hdspm_t *hdspm; - snd_card_t *card; + struct hdspm *hdspm; + struct snd_card *card; int err; if (dev >= SNDRV_CARDS) @@ -3590,10 +3586,10 @@ static int __devinit snd_hdspm_probe(struct pci_dev *pci, } if (!(card = snd_card_new(index[dev], id[dev], - THIS_MODULE, sizeof(hdspm_t)))) + THIS_MODULE, sizeof(struct hdspm)))) return -ENOMEM; - hdspm = (hdspm_t *) card->private_data; + hdspm = (struct hdspm *) card->private_data; card->private_free = snd_hdspm_card_free; hdspm->dev = dev; hdspm->pci = pci; -- cgit v1.1 From abfd67bd6fcc07b54d54e00a9105900f478323a6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:52:53 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI RME9652 Modules: RME9652 driver Remove xxx_t typedefs from the PCI RME9652 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/rme9652/rme9652.c | 372 ++++++++++++++++++++++---------------------- 1 file changed, 186 insertions(+), 186 deletions(-) diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c index f9d0c12..a687eb6 100644 --- a/sound/pci/rme9652/rme9652.c +++ b/sound/pci/rme9652/rme9652.c @@ -198,7 +198,7 @@ MODULE_SUPPORTED_DEVICE("{{RME,Hammerfall}," #define RME9652_DMA_AREA_BYTES ((RME9652_NCHANNELS+1) * RME9652_CHANNEL_BUFFER_BYTES) #define RME9652_DMA_AREA_KILOBYTES (RME9652_DMA_AREA_BYTES/1024) -typedef struct snd_rme9652 { +struct snd_rme9652 { int dev; spinlock_t lock; @@ -234,8 +234,8 @@ typedef struct snd_rme9652 { pid_t capture_pid; pid_t playback_pid; - snd_pcm_substream_t *capture_substream; - snd_pcm_substream_t *playback_substream; + struct snd_pcm_substream *capture_substream; + struct snd_pcm_substream *playback_substream; int running; int passthru; /* non-zero if doing pass-thru */ @@ -246,12 +246,12 @@ typedef struct snd_rme9652 { char *channel_map; - snd_card_t *card; - snd_pcm_t *pcm; + struct snd_card *card; + struct snd_pcm *pcm; struct pci_dev *pci; - snd_kcontrol_t *spdif_ctl; + struct snd_kcontrol *spdif_ctl; -} rme9652_t; +}; /* These tables map the ALSA channels 1..N to the channels that we need to use in order to find the relevant channel buffer. RME @@ -327,17 +327,17 @@ static struct pci_device_id snd_rme9652_ids[] = { MODULE_DEVICE_TABLE(pci, snd_rme9652_ids); -static inline void rme9652_write(rme9652_t *rme9652, int reg, int val) +static inline void rme9652_write(struct snd_rme9652 *rme9652, int reg, int val) { writel(val, rme9652->iobase + reg); } -static inline unsigned int rme9652_read(rme9652_t *rme9652, int reg) +static inline unsigned int rme9652_read(struct snd_rme9652 *rme9652, int reg) { return readl(rme9652->iobase + reg); } -static inline int snd_rme9652_use_is_exclusive(rme9652_t *rme9652) +static inline int snd_rme9652_use_is_exclusive(struct snd_rme9652 *rme9652) { unsigned long flags; int ret = 1; @@ -351,7 +351,7 @@ static inline int snd_rme9652_use_is_exclusive(rme9652_t *rme9652) return ret; } -static inline int rme9652_adat_sample_rate(rme9652_t *rme9652) +static inline int rme9652_adat_sample_rate(struct snd_rme9652 *rme9652) { if (rme9652_running_double_speed(rme9652)) { return (rme9652_read(rme9652, RME9652_status_register) & @@ -362,7 +362,7 @@ static inline int rme9652_adat_sample_rate(rme9652_t *rme9652) } } -static inline void rme9652_compute_period_size(rme9652_t *rme9652) +static inline void rme9652_compute_period_size(struct snd_rme9652 *rme9652) { unsigned int i; @@ -373,7 +373,7 @@ static inline void rme9652_compute_period_size(rme9652_t *rme9652) rme9652->max_jitter = 80; } -static snd_pcm_uframes_t rme9652_hw_pointer(rme9652_t *rme9652) +static snd_pcm_uframes_t rme9652_hw_pointer(struct snd_rme9652 *rme9652) { int status; unsigned int offset, frag; @@ -420,7 +420,7 @@ static snd_pcm_uframes_t rme9652_hw_pointer(rme9652_t *rme9652) return offset; } -static inline void rme9652_reset_hw_pointer(rme9652_t *rme9652) +static inline void rme9652_reset_hw_pointer(struct snd_rme9652 *rme9652) { int i; @@ -437,19 +437,19 @@ static inline void rme9652_reset_hw_pointer(rme9652_t *rme9652) rme9652->prev_hw_offset = 0; } -static inline void rme9652_start(rme9652_t *s) +static inline void rme9652_start(struct snd_rme9652 *s) { s->control_register |= (RME9652_IE | RME9652_start_bit); rme9652_write(s, RME9652_control_register, s->control_register); } -static inline void rme9652_stop(rme9652_t *s) +static inline void rme9652_stop(struct snd_rme9652 *s) { s->control_register &= ~(RME9652_start_bit | RME9652_IE); rme9652_write(s, RME9652_control_register, s->control_register); } -static int rme9652_set_interrupt_interval(rme9652_t *s, +static int rme9652_set_interrupt_interval(struct snd_rme9652 *s, unsigned int frames) { int restart = 0; @@ -483,7 +483,7 @@ static int rme9652_set_interrupt_interval(rme9652_t *s, return 0; } -static int rme9652_set_rate(rme9652_t *rme9652, int rate) +static int rme9652_set_rate(struct snd_rme9652 *rme9652, int rate) { int restart; int reject_if_open = 0; @@ -571,7 +571,7 @@ static int rme9652_set_rate(rme9652_t *rme9652, int rate) return 0; } -static void rme9652_set_thru(rme9652_t *rme9652, int channel, int enable) +static void rme9652_set_thru(struct snd_rme9652 *rme9652, int channel, int enable) { int i; @@ -612,7 +612,7 @@ static void rme9652_set_thru(rme9652_t *rme9652, int channel, int enable) } } -static int rme9652_set_passthru(rme9652_t *rme9652, int onoff) +static int rme9652_set_passthru(struct snd_rme9652 *rme9652, int onoff) { if (onoff) { rme9652_set_thru(rme9652, -1, 1); @@ -640,7 +640,7 @@ static int rme9652_set_passthru(rme9652_t *rme9652, int onoff) return 0; } -static void rme9652_spdif_set_bit (rme9652_t *rme9652, int mask, int onoff) +static void rme9652_spdif_set_bit (struct snd_rme9652 *rme9652, int mask, int onoff) { if (onoff) rme9652->control_register |= mask; @@ -650,7 +650,7 @@ static void rme9652_spdif_set_bit (rme9652_t *rme9652, int mask, int onoff) rme9652_write(rme9652, RME9652_control_register, rme9652->control_register); } -static void rme9652_spdif_write_byte (rme9652_t *rme9652, const int val) +static void rme9652_spdif_write_byte (struct snd_rme9652 *rme9652, const int val) { long mask; long i; @@ -666,7 +666,7 @@ static void rme9652_spdif_write_byte (rme9652_t *rme9652, const int val) } } -static int rme9652_spdif_read_byte (rme9652_t *rme9652) +static int rme9652_spdif_read_byte (struct snd_rme9652 *rme9652) { long mask; long val; @@ -684,7 +684,7 @@ static int rme9652_spdif_read_byte (rme9652_t *rme9652) return val; } -static void rme9652_write_spdif_codec (rme9652_t *rme9652, const int address, const int data) +static void rme9652_write_spdif_codec (struct snd_rme9652 *rme9652, const int address, const int data) { rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_SELECT, 1); rme9652_spdif_write_byte (rme9652, 0x20); @@ -694,7 +694,7 @@ static void rme9652_write_spdif_codec (rme9652_t *rme9652, const int address, co } -static int rme9652_spdif_read_codec (rme9652_t *rme9652, const int address) +static int rme9652_spdif_read_codec (struct snd_rme9652 *rme9652, const int address) { int ret; @@ -711,7 +711,7 @@ static int rme9652_spdif_read_codec (rme9652_t *rme9652, const int address) return ret; } -static void rme9652_initialize_spdif_receiver (rme9652_t *rme9652) +static void rme9652_initialize_spdif_receiver (struct snd_rme9652 *rme9652) { /* XXX what unsets this ? */ @@ -722,7 +722,7 @@ static void rme9652_initialize_spdif_receiver (rme9652_t *rme9652) rme9652_write_spdif_codec (rme9652, 6, 0x02); } -static inline int rme9652_spdif_sample_rate(rme9652_t *s) +static inline int rme9652_spdif_sample_rate(struct snd_rme9652 *s) { unsigned int rate_bits; @@ -790,7 +790,7 @@ static inline int rme9652_spdif_sample_rate(rme9652_t *s) Control Interface ----------------------------------------------------------------------------*/ -static u32 snd_rme9652_convert_from_aes(snd_aes_iec958_t *aes) +static u32 snd_rme9652_convert_from_aes(struct snd_aes_iec958 *aes) { u32 val = 0; val |= (aes->status[0] & IEC958_AES0_PROFESSIONAL) ? RME9652_PRO : 0; @@ -802,7 +802,7 @@ static u32 snd_rme9652_convert_from_aes(snd_aes_iec958_t *aes) return val; } -static void snd_rme9652_convert_to_aes(snd_aes_iec958_t *aes, u32 val) +static void snd_rme9652_convert_to_aes(struct snd_aes_iec958 *aes, u32 val) { aes->status[0] = ((val & RME9652_PRO) ? IEC958_AES0_PROFESSIONAL : 0) | ((val & RME9652_Dolby) ? IEC958_AES0_NONAUDIO : 0); @@ -812,24 +812,24 @@ static void snd_rme9652_convert_to_aes(snd_aes_iec958_t *aes, u32 val) aes->status[0] |= (val & RME9652_EMP) ? IEC958_AES0_CON_EMPHASIS_5015 : 0; } -static int snd_rme9652_control_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_control_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme9652_control_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); snd_rme9652_convert_to_aes(&ucontrol->value.iec958, rme9652->creg_spdif); return 0; } -static int snd_rme9652_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_control_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change; u32 val; @@ -841,24 +841,24 @@ static int snd_rme9652_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem return change; } -static int snd_rme9652_control_spdif_stream_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_control_spdif_stream_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme9652_control_spdif_stream_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); snd_rme9652_convert_to_aes(&ucontrol->value.iec958, rme9652->creg_spdif_stream); return 0; } -static int snd_rme9652_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_control_spdif_stream_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change; u32 val; @@ -872,14 +872,14 @@ static int snd_rme9652_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_c return change; } -static int snd_rme9652_control_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_control_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme9652_control_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_control_spdif_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = kcontrol->private_value; return 0; @@ -891,14 +891,14 @@ static int snd_rme9652_control_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl .get = snd_rme9652_get_adat1_in, \ .put = snd_rme9652_put_adat1_in } -static unsigned int rme9652_adat1_in(rme9652_t *rme9652) +static unsigned int rme9652_adat1_in(struct snd_rme9652 *rme9652) { if (rme9652->control_register & RME9652_ADAT1_INTERNAL) return 1; return 0; } -static int rme9652_set_adat1_input(rme9652_t *rme9652, int internal) +static int rme9652_set_adat1_input(struct snd_rme9652 *rme9652, int internal) { int restart = 0; @@ -923,7 +923,7 @@ static int rme9652_set_adat1_input(rme9652_t *rme9652, int internal) return 0; } -static int snd_rme9652_info_adat1_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_adat1_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[2] = {"ADAT1", "Internal"}; @@ -936,9 +936,9 @@ static int snd_rme9652_info_adat1_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_rme9652_get_adat1_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_adat1_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme9652->lock); ucontrol->value.enumerated.item[0] = rme9652_adat1_in(rme9652); @@ -946,9 +946,9 @@ static int snd_rme9652_get_adat1_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return 0; } -static int snd_rme9652_put_adat1_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_put_adat1_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -968,13 +968,13 @@ static int snd_rme9652_put_adat1_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu .info = snd_rme9652_info_spdif_in, \ .get = snd_rme9652_get_spdif_in, .put = snd_rme9652_put_spdif_in } -static unsigned int rme9652_spdif_in(rme9652_t *rme9652) +static unsigned int rme9652_spdif_in(struct snd_rme9652 *rme9652) { return rme9652_decode_spdif_in(rme9652->control_register & RME9652_inp); } -static int rme9652_set_spdif_input(rme9652_t *rme9652, int in) +static int rme9652_set_spdif_input(struct snd_rme9652 *rme9652, int in) { int restart = 0; @@ -994,7 +994,7 @@ static int rme9652_set_spdif_input(rme9652_t *rme9652, int in) return 0; } -static int snd_rme9652_info_spdif_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = {"ADAT1", "Coaxial", "Internal"}; @@ -1007,9 +1007,9 @@ static int snd_rme9652_info_spdif_in(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_rme9652_get_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme9652->lock); ucontrol->value.enumerated.item[0] = rme9652_spdif_in(rme9652); @@ -1017,9 +1017,9 @@ static int snd_rme9652_get_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return 0; } -static int snd_rme9652_put_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_put_spdif_in(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1039,12 +1039,12 @@ static int snd_rme9652_put_spdif_in(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu .info = snd_rme9652_info_spdif_out, \ .get = snd_rme9652_get_spdif_out, .put = snd_rme9652_put_spdif_out } -static int rme9652_spdif_out(rme9652_t *rme9652) +static int rme9652_spdif_out(struct snd_rme9652 *rme9652) { return (rme9652->control_register & RME9652_opt_out) ? 1 : 0; } -static int rme9652_set_spdif_output(rme9652_t *rme9652, int out) +static int rme9652_set_spdif_output(struct snd_rme9652 *rme9652, int out) { int restart = 0; @@ -1067,7 +1067,7 @@ static int rme9652_set_spdif_output(rme9652_t *rme9652, int out) return 0; } -static int snd_rme9652_info_spdif_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1076,9 +1076,9 @@ static int snd_rme9652_info_spdif_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_rme9652_get_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme9652->lock); ucontrol->value.integer.value[0] = rme9652_spdif_out(rme9652); @@ -1086,9 +1086,9 @@ static int snd_rme9652_get_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return 0; } -static int snd_rme9652_put_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_put_spdif_out(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1107,7 +1107,7 @@ static int snd_rme9652_put_spdif_out(snd_kcontrol_t * kcontrol, snd_ctl_elem_val .info = snd_rme9652_info_sync_mode, \ .get = snd_rme9652_get_sync_mode, .put = snd_rme9652_put_sync_mode } -static int rme9652_sync_mode(rme9652_t *rme9652) +static int rme9652_sync_mode(struct snd_rme9652 *rme9652) { if (rme9652->control_register & RME9652_wsel) { return 2; @@ -1118,7 +1118,7 @@ static int rme9652_sync_mode(rme9652_t *rme9652) } } -static int rme9652_set_sync_mode(rme9652_t *rme9652, int mode) +static int rme9652_set_sync_mode(struct snd_rme9652 *rme9652, int mode) { int restart = 0; @@ -1150,7 +1150,7 @@ static int rme9652_set_sync_mode(rme9652_t *rme9652, int mode) return 0; } -static int snd_rme9652_info_sync_mode(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_sync_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = {"AutoSync", "Master", "Word Clock"}; @@ -1163,9 +1163,9 @@ static int snd_rme9652_info_sync_mode(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_rme9652_get_sync_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_sync_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme9652->lock); ucontrol->value.enumerated.item[0] = rme9652_sync_mode(rme9652); @@ -1173,9 +1173,9 @@ static int snd_rme9652_get_sync_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return 0; } -static int snd_rme9652_put_sync_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_put_sync_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change; unsigned int val; @@ -1192,7 +1192,7 @@ static int snd_rme9652_put_sync_mode(snd_kcontrol_t * kcontrol, snd_ctl_elem_val .info = snd_rme9652_info_sync_pref, \ .get = snd_rme9652_get_sync_pref, .put = snd_rme9652_put_sync_pref } -static int rme9652_sync_pref(rme9652_t *rme9652) +static int rme9652_sync_pref(struct snd_rme9652 *rme9652) { switch (rme9652->control_register & RME9652_SyncPref_Mask) { case RME9652_SyncPref_ADAT1: @@ -1208,7 +1208,7 @@ static int rme9652_sync_pref(rme9652_t *rme9652) return 0; } -static int rme9652_set_sync_pref(rme9652_t *rme9652, int pref) +static int rme9652_set_sync_pref(struct snd_rme9652 *rme9652, int pref) { int restart; @@ -1241,10 +1241,10 @@ static int rme9652_set_sync_pref(rme9652_t *rme9652, int pref) return 0; } -static int snd_rme9652_info_sync_pref(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_sync_pref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = {"IEC958 In", "ADAT1 In", "ADAT2 In", "ADAT3 In"}; - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -1255,9 +1255,9 @@ static int snd_rme9652_info_sync_pref(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_rme9652_get_sync_pref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_sync_pref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme9652->lock); ucontrol->value.enumerated.item[0] = rme9652_sync_pref(rme9652); @@ -1265,9 +1265,9 @@ static int snd_rme9652_get_sync_pref(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return 0; } -static int snd_rme9652_put_sync_pref(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_put_sync_pref(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change, max; unsigned int val; @@ -1282,9 +1282,9 @@ static int snd_rme9652_put_sync_pref(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return change; } -static int snd_rme9652_info_thru(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_thru(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = rme9652->ss_channels; uinfo->value.integer.min = 0; @@ -1292,9 +1292,9 @@ static int snd_rme9652_info_thru(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_rme9652_get_thru(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_thru(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); unsigned int k; u32 thru_bits = rme9652->thru_bits; @@ -1304,9 +1304,9 @@ static int snd_rme9652_get_thru(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_rme9652_put_thru(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_put_thru(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change; unsigned int chn; u32 thru_bits = 0; @@ -1338,7 +1338,7 @@ static int snd_rme9652_put_thru(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .put = snd_rme9652_put_passthru, \ .get = snd_rme9652_get_passthru } -static int snd_rme9652_info_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_passthru(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1347,9 +1347,9 @@ static int snd_rme9652_info_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_inf return 0; } -static int snd_rme9652_get_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_passthru(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme9652->lock); ucontrol->value.integer.value[0] = rme9652->passthru; @@ -1357,9 +1357,9 @@ static int snd_rme9652_get_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return 0; } -static int snd_rme9652_put_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_put_passthru(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); int change; unsigned int val; int err = 0; @@ -1384,7 +1384,7 @@ static int snd_rme9652_put_passthru(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu .info = snd_rme9652_info_spdif_rate, \ .get = snd_rme9652_get_spdif_rate } -static int snd_rme9652_info_spdif_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_spdif_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -1393,9 +1393,9 @@ static int snd_rme9652_info_spdif_rate(snd_kcontrol_t *kcontrol, snd_ctl_elem_in return 0; } -static int snd_rme9652_get_spdif_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_spdif_rate(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme9652->lock); ucontrol->value.integer.value[0] = rme9652_spdif_sample_rate(rme9652); @@ -1409,7 +1409,7 @@ static int snd_rme9652_get_spdif_rate(snd_kcontrol_t * kcontrol, snd_ctl_elem_va .info = snd_rme9652_info_adat_sync, \ .get = snd_rme9652_get_adat_sync, .private_value = xidx } -static int snd_rme9652_info_adat_sync(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_adat_sync(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = {"No Lock", "Lock", "No Lock Sync", "Lock Sync"}; @@ -1422,9 +1422,9 @@ static int snd_rme9652_info_adat_sync(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_rme9652_get_adat_sync(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_adat_sync(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); unsigned int mask1, mask2, val; switch (kcontrol->private_value) { @@ -1445,7 +1445,7 @@ static int snd_rme9652_get_adat_sync(snd_kcontrol_t * kcontrol, snd_ctl_elem_val .info = snd_rme9652_info_tc_valid, \ .get = snd_rme9652_get_tc_valid } -static int snd_rme9652_info_tc_valid(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme9652_info_tc_valid(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1454,9 +1454,9 @@ static int snd_rme9652_info_tc_valid(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_rme9652_get_tc_valid(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme9652_get_tc_valid(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme9652_t *rme9652 = snd_kcontrol_chip(kcontrol); + struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (rme9652_read(rme9652, RME9652_status_register) & RME9652_tc_valid) ? 1 : 0; @@ -1471,7 +1471,7 @@ static int snd_rme9652_get_tc_value(void *private_data, snd_kswitch_t *kswitch, snd_switch_t *uswitch) { - rme9652_t *s = (rme9652_t *) private_data; + struct snd_rme9652 *s = (struct snd_rme9652 *) private_data; u32 value; int i; @@ -1520,7 +1520,7 @@ static int snd_rme9652_get_tc_value(void *private_data, #endif /* ALSA_HAS_STANDARD_WAY_OF_RETURNING_TIMECODE */ -static snd_kcontrol_new_t snd_rme9652_controls[] = { +static struct snd_kcontrol_new snd_rme9652_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -1575,17 +1575,17 @@ RME9652_TC_VALID("Timecode Valid", 0), RME9652_PASSTHRU("Passthru", 0) }; -static snd_kcontrol_new_t snd_rme9652_adat3_check = +static struct snd_kcontrol_new snd_rme9652_adat3_check = RME9652_ADAT_SYNC("ADAT3 Sync Check", 0, 2); -static snd_kcontrol_new_t snd_rme9652_adat1_input = +static struct snd_kcontrol_new snd_rme9652_adat1_input = RME9652_ADAT1_IN("ADAT1 Input Source", 0); -static int snd_rme9652_create_controls(snd_card_t *card, rme9652_t *rme9652) +static int snd_rme9652_create_controls(struct snd_card *card, struct snd_rme9652 *rme9652) { unsigned int idx; int err; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; for (idx = 0; idx < ARRAY_SIZE(snd_rme9652_controls); idx++) { if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_rme9652_controls[idx], rme9652))) < 0) @@ -1610,9 +1610,9 @@ static int snd_rme9652_create_controls(snd_card_t *card, rme9652_t *rme9652) ------------------------------------------------------------*/ static void -snd_rme9652_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +snd_rme9652_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - rme9652_t *rme9652 = (rme9652_t *) entry->private_data; + struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) entry->private_data; u32 thru_bits = rme9652->thru_bits; int show_auto_sync_source = 0; int i; @@ -1782,21 +1782,21 @@ snd_rme9652_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) snd_iprintf(buffer, "\n"); } -static void __devinit snd_rme9652_proc_init(rme9652_t *rme9652) +static void __devinit snd_rme9652_proc_init(struct snd_rme9652 *rme9652) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(rme9652->card, "rme9652", &entry)) snd_info_set_text_ops(entry, rme9652, 1024, snd_rme9652_proc_read); } -static void snd_rme9652_free_buffers(rme9652_t *rme9652) +static void snd_rme9652_free_buffers(struct snd_rme9652 *rme9652) { snd_hammerfall_free_buffer(&rme9652->capture_dma_buf, rme9652->pci); snd_hammerfall_free_buffer(&rme9652->playback_dma_buf, rme9652->pci); } -static int snd_rme9652_free(rme9652_t *rme9652) +static int snd_rme9652_free(struct snd_rme9652 *rme9652) { if (rme9652->irq >= 0) rme9652_stop(rme9652); @@ -1813,7 +1813,7 @@ static int snd_rme9652_free(rme9652_t *rme9652) return 0; } -static int __devinit snd_rme9652_initialize_memory(rme9652_t *rme9652) +static int __devinit snd_rme9652_initialize_memory(struct snd_rme9652 *rme9652) { unsigned long pb_bus, cb_bus; @@ -1841,7 +1841,7 @@ static int __devinit snd_rme9652_initialize_memory(rme9652_t *rme9652) return 0; } -static void snd_rme9652_set_defaults(rme9652_t *rme9652) +static void snd_rme9652_set_defaults(struct snd_rme9652 *rme9652) { unsigned int k; @@ -1884,7 +1884,7 @@ static void snd_rme9652_set_defaults(rme9652_t *rme9652) static irqreturn_t snd_rme9652_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - rme9652_t *rme9652 = (rme9652_t *) dev_id; + struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) dev_id; if (!(rme9652_read(rme9652, RME9652_status_register) & RME9652_IRQ)) { return IRQ_NONE; @@ -1902,13 +1902,13 @@ static irqreturn_t snd_rme9652_interrupt(int irq, void *dev_id, struct pt_regs * return IRQ_HANDLED; } -static snd_pcm_uframes_t snd_rme9652_hw_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_rme9652_hw_pointer(struct snd_pcm_substream *substream) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); return rme9652_hw_pointer(rme9652); } -static char *rme9652_channel_buffer_location(rme9652_t *rme9652, +static char *rme9652_channel_buffer_location(struct snd_rme9652 *rme9652, int stream, int channel) @@ -1930,10 +1930,10 @@ static char *rme9652_channel_buffer_location(rme9652_t *rme9652, } } -static int snd_rme9652_playback_copy(snd_pcm_substream_t *substream, int channel, +static int snd_rme9652_playback_copy(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); char *channel_buf; snd_assert(pos + count <= RME9652_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); @@ -1947,10 +1947,10 @@ static int snd_rme9652_playback_copy(snd_pcm_substream_t *substream, int channel return count; } -static int snd_rme9652_capture_copy(snd_pcm_substream_t *substream, int channel, +static int snd_rme9652_capture_copy(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); char *channel_buf; snd_assert(pos + count <= RME9652_CHANNEL_BUFFER_BYTES / 4, return -EINVAL); @@ -1964,10 +1964,10 @@ static int snd_rme9652_capture_copy(snd_pcm_substream_t *substream, int channel, return count; } -static int snd_rme9652_hw_silence(snd_pcm_substream_t *substream, int channel, +static int snd_rme9652_hw_silence(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); char *channel_buf; channel_buf = rme9652_channel_buffer_location (rme9652, @@ -1978,11 +1978,11 @@ static int snd_rme9652_hw_silence(snd_pcm_substream_t *substream, int channel, return count; } -static int snd_rme9652_reset(snd_pcm_substream_t *substream) +static int snd_rme9652_reset(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); - snd_pcm_substream_t *other; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); + struct snd_pcm_substream *other; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) other = rme9652->capture_substream; else @@ -1993,8 +1993,8 @@ static int snd_rme9652_reset(snd_pcm_substream_t *substream) runtime->status->hw_ptr = 0; if (other) { struct list_head *pos; - snd_pcm_substream_t *s; - snd_pcm_runtime_t *oruntime = other->runtime; + struct snd_pcm_substream *s; + struct snd_pcm_runtime *oruntime = other->runtime; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == other) { @@ -2006,10 +2006,10 @@ static int snd_rme9652_reset(snd_pcm_substream_t *substream) return 0; } -static int snd_rme9652_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +static int snd_rme9652_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); int err; pid_t this_pid; pid_t other_pid; @@ -2071,10 +2071,10 @@ static int snd_rme9652_hw_params(snd_pcm_substream_t *substream, return 0; } -static int snd_rme9652_channel_info(snd_pcm_substream_t *substream, - snd_pcm_channel_info_t *info) +static int snd_rme9652_channel_info(struct snd_pcm_substream *substream, + struct snd_pcm_channel_info *info) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); int chn; snd_assert(info->channel < RME9652_NCHANNELS, return -EINVAL); @@ -2089,7 +2089,7 @@ static int snd_rme9652_channel_info(snd_pcm_substream_t *substream, return 0; } -static int snd_rme9652_ioctl(snd_pcm_substream_t *substream, +static int snd_rme9652_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { switch (cmd) { @@ -2099,7 +2099,7 @@ static int snd_rme9652_ioctl(snd_pcm_substream_t *substream, } case SNDRV_PCM_IOCTL1_CHANNEL_INFO: { - snd_pcm_channel_info_t *info = arg; + struct snd_pcm_channel_info *info = arg; return snd_rme9652_channel_info(substream, info); } default: @@ -2109,16 +2109,16 @@ static int snd_rme9652_ioctl(snd_pcm_substream_t *substream, return snd_pcm_lib_ioctl(substream, cmd, arg); } -static void rme9652_silence_playback(rme9652_t *rme9652) +static void rme9652_silence_playback(struct snd_rme9652 *rme9652) { memset(rme9652->playback_buffer, 0, RME9652_DMA_AREA_BYTES); } -static int snd_rme9652_trigger(snd_pcm_substream_t *substream, +static int snd_rme9652_trigger(struct snd_pcm_substream *substream, int cmd) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); - snd_pcm_substream_t *other; + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); + struct snd_pcm_substream *other; int running; spin_lock(&rme9652->lock); running = rme9652->running; @@ -2141,7 +2141,7 @@ static int snd_rme9652_trigger(snd_pcm_substream_t *substream, if (other) { struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == other) { @@ -2178,9 +2178,9 @@ static int snd_rme9652_trigger(snd_pcm_substream_t *substream, return 0; } -static int snd_rme9652_prepare(snd_pcm_substream_t *substream) +static int snd_rme9652_prepare(struct snd_pcm_substream *substream) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); unsigned long flags; int result = 0; @@ -2191,7 +2191,7 @@ static int snd_rme9652_prepare(snd_pcm_substream_t *substream) return result; } -static snd_pcm_hardware_t snd_rme9652_playback_subinfo = +static struct snd_pcm_hardware snd_rme9652_playback_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -2215,7 +2215,7 @@ static snd_pcm_hardware_t snd_rme9652_playback_subinfo = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_rme9652_capture_subinfo = +static struct snd_pcm_hardware snd_rme9652_capture_subinfo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -2240,36 +2240,36 @@ static snd_pcm_hardware_t snd_rme9652_capture_subinfo = static unsigned int period_sizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192 }; -static snd_pcm_hw_constraint_list_t hw_constraints_period_sizes = { +static struct snd_pcm_hw_constraint_list hw_constraints_period_sizes = { .count = ARRAY_SIZE(period_sizes), .list = period_sizes, .mask = 0 }; -static int snd_rme9652_hw_rule_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_rme9652_hw_rule_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - rme9652_t *rme9652 = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_rme9652 *rme9652 = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); unsigned int list[2] = { rme9652->ds_channels, rme9652->ss_channels }; return snd_interval_list(c, 2, list, 0); } -static int snd_rme9652_hw_rule_channels_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_rme9652_hw_rule_channels_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - rme9652_t *rme9652 = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_rme9652 *rme9652 = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (r->min > 48000) { - snd_interval_t t = { + struct snd_interval t = { .min = rme9652->ds_channels, .max = rme9652->ds_channels, .integer = 1, }; return snd_interval_refine(c, &t); } else if (r->max < 88200) { - snd_interval_t t = { + struct snd_interval t = { .min = rme9652->ss_channels, .max = rme9652->ss_channels, .integer = 1, @@ -2279,21 +2279,21 @@ static int snd_rme9652_hw_rule_channels_rate(snd_pcm_hw_params_t *params, return 0; } -static int snd_rme9652_hw_rule_rate_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_rme9652_hw_rule_rate_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - rme9652_t *rme9652 = rule->private; - snd_interval_t *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_interval_t *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_rme9652 *rme9652 = rule->private; + struct snd_interval *c = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *r = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); if (c->min >= rme9652->ss_channels) { - snd_interval_t t = { + struct snd_interval t = { .min = 44100, .max = 48000, .integer = 1, }; return snd_interval_refine(r, &t); } else if (c->max <= rme9652->ds_channels) { - snd_interval_t t = { + struct snd_interval t = { .min = 88200, .max = 96000, .integer = 1, @@ -2303,10 +2303,10 @@ static int snd_rme9652_hw_rule_rate_channels(snd_pcm_hw_params_t *params, return 0; } -static int snd_rme9652_playback_open(snd_pcm_substream_t *substream) +static int snd_rme9652_playback_open(struct snd_pcm_substream *substream) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irq(&rme9652->lock); @@ -2345,9 +2345,9 @@ static int snd_rme9652_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_rme9652_playback_release(snd_pcm_substream_t *substream) +static int snd_rme9652_playback_release(struct snd_pcm_substream *substream) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); spin_lock_irq(&rme9652->lock); @@ -2363,10 +2363,10 @@ static int snd_rme9652_playback_release(snd_pcm_substream_t *substream) } -static int snd_rme9652_capture_open(snd_pcm_substream_t *substream) +static int snd_rme9652_capture_open(struct snd_pcm_substream *substream) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; spin_lock_irq(&rme9652->lock); @@ -2400,9 +2400,9 @@ static int snd_rme9652_capture_open(snd_pcm_substream_t *substream) return 0; } -static int snd_rme9652_capture_release(snd_pcm_substream_t *substream) +static int snd_rme9652_capture_release(struct snd_pcm_substream *substream) { - rme9652_t *rme9652 = snd_pcm_substream_chip(substream); + struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream); spin_lock_irq(&rme9652->lock); @@ -2413,7 +2413,7 @@ static int snd_rme9652_capture_release(snd_pcm_substream_t *substream) return 0; } -static snd_pcm_ops_t snd_rme9652_playback_ops = { +static struct snd_pcm_ops snd_rme9652_playback_ops = { .open = snd_rme9652_playback_open, .close = snd_rme9652_playback_release, .ioctl = snd_rme9652_ioctl, @@ -2425,7 +2425,7 @@ static snd_pcm_ops_t snd_rme9652_playback_ops = { .silence = snd_rme9652_hw_silence, }; -static snd_pcm_ops_t snd_rme9652_capture_ops = { +static struct snd_pcm_ops snd_rme9652_capture_ops = { .open = snd_rme9652_capture_open, .close = snd_rme9652_capture_release, .ioctl = snd_rme9652_ioctl, @@ -2436,10 +2436,10 @@ static snd_pcm_ops_t snd_rme9652_capture_ops = { .copy = snd_rme9652_capture_copy, }; -static int __devinit snd_rme9652_create_pcm(snd_card_t *card, - rme9652_t *rme9652) +static int __devinit snd_rme9652_create_pcm(struct snd_card *card, + struct snd_rme9652 *rme9652) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(card, @@ -2460,8 +2460,8 @@ static int __devinit snd_rme9652_create_pcm(snd_card_t *card, return 0; } -static int __devinit snd_rme9652_create(snd_card_t *card, - rme9652_t *rme9652, +static int __devinit snd_rme9652_create(struct snd_card *card, + struct snd_rme9652 *rme9652, int precise_ptr) { struct pci_dev *pci = rme9652->pci; @@ -2591,9 +2591,9 @@ static int __devinit snd_rme9652_create(snd_card_t *card, return 0; } -static void snd_rme9652_card_free(snd_card_t *card) +static void snd_rme9652_card_free(struct snd_card *card) { - rme9652_t *rme9652 = (rme9652_t *) card->private_data; + struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) card->private_data; if (rme9652) snd_rme9652_free(rme9652); @@ -2603,8 +2603,8 @@ static int __devinit snd_rme9652_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - rme9652_t *rme9652; - snd_card_t *card; + struct snd_rme9652 *rme9652; + struct snd_card *card; int err; if (dev >= SNDRV_CARDS) @@ -2615,12 +2615,12 @@ static int __devinit snd_rme9652_probe(struct pci_dev *pci, } card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(rme9652_t)); + sizeof(struct snd_rme9652)); if (!card) return -ENOMEM; - rme9652 = (rme9652_t *) card->private_data; + rme9652 = (struct snd_rme9652 *) card->private_data; card->private_free = snd_rme9652_card_free; rme9652->dev = dev; rme9652->pci = pci; -- cgit v1.1 From bee1a5be8b6210a0a4e27e38d0f76847b0a014ae Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:53:15 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI Trident Modules: Trident driver Remove xxx_t typedefs from the PCI Trident driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/trident.h | 151 ++++---- sound/pci/trident/trident.c | 4 +- sound/pci/trident/trident_main.c | 708 ++++++++++++++++++++----------------- sound/pci/trident/trident_memory.c | 92 ++--- sound/pci/trident/trident_synth.c | 159 +++++---- 5 files changed, 592 insertions(+), 522 deletions(-) diff --git a/include/sound/trident.h b/include/sound/trident.h index a408d39..2c54569 100644 --- a/include/sound/trident.h +++ b/include/sound/trident.h @@ -253,43 +253,43 @@ enum serial_intf_ctrl_bits { #define T4D_DEFAULT_PCM_RVOL 127 /* 0 - 127 */ #define T4D_DEFAULT_PCM_CVOL 127 /* 0 - 127 */ -typedef struct _snd_trident trident_t; -typedef struct _snd_trident_voice snd_trident_voice_t; -typedef struct _snd_trident_pcm_mixer snd_trident_pcm_mixer_t; - -typedef struct { - void (*sample_start)(trident_t *gus, snd_trident_voice_t *voice, snd_seq_position_t position); - void (*sample_stop)(trident_t *gus, snd_trident_voice_t *voice, snd_seq_stop_mode_t mode); - void (*sample_freq)(trident_t *gus, snd_trident_voice_t *voice, snd_seq_frequency_t freq); - void (*sample_volume)(trident_t *gus, snd_trident_voice_t *voice, snd_seq_ev_volume_t *volume); - void (*sample_loop)(trident_t *card, snd_trident_voice_t *voice, snd_seq_ev_loop_t *loop); - void (*sample_pos)(trident_t *card, snd_trident_voice_t *voice, snd_seq_position_t position); - void (*sample_private1)(trident_t *card, snd_trident_voice_t *voice, unsigned char *data); -} snd_trident_sample_ops_t; - -typedef struct { - snd_midi_channel_set_t * chset; - trident_t * trident; +struct snd_trident; +struct snd_trident_voice; +struct snd_trident_pcm_mixer; + +struct snd_trident_sample_ops { + void (*sample_start)(struct snd_trident *gus, struct snd_trident_voice *voice, snd_seq_position_t position); + void (*sample_stop)(struct snd_trident *gus, struct snd_trident_voice *voice, int mode); + void (*sample_freq)(struct snd_trident *gus, struct snd_trident_voice *voice, snd_seq_frequency_t freq); + void (*sample_volume)(struct snd_trident *gus, struct snd_trident_voice *voice, struct snd_seq_ev_volume *volume); + void (*sample_loop)(struct snd_trident *card, struct snd_trident_voice *voice, struct snd_seq_ev_loop *loop); + void (*sample_pos)(struct snd_trident *card, struct snd_trident_voice *voice, snd_seq_position_t position); + void (*sample_private1)(struct snd_trident *card, struct snd_trident_voice *voice, unsigned char *data); +}; + +struct snd_trident_port { + struct snd_midi_channel_set * chset; + struct snd_trident * trident; int mode; /* operation mode */ int client; /* sequencer client number */ int port; /* sequencer port number */ unsigned int midi_has_voices: 1; -} snd_trident_port_t; +}; -typedef struct snd_trident_memblk_arg { +struct snd_trident_memblk_arg { short first_page, last_page; -} snd_trident_memblk_arg_t; +}; -typedef struct { +struct snd_trident_tlb { unsigned int * entries; /* 16k-aligned TLB table */ dma_addr_t entries_dmaaddr; /* 16k-aligned PCI address to TLB table */ unsigned long * shadow_entries; /* shadow entries with virtual addresses */ struct snd_dma_buffer buffer; - snd_util_memhdr_t * memhdr; /* page allocation list */ + struct snd_util_memhdr * memhdr; /* page allocation list */ struct snd_dma_buffer silent_page; -} snd_trident_tlb_t; +}; -struct _snd_trident_voice { +struct snd_trident_voice { unsigned int number; unsigned int use: 1, pcm: 1, @@ -300,8 +300,8 @@ struct _snd_trident_voice { unsigned char port; unsigned char index; - snd_seq_instr_t instr; - snd_trident_sample_ops_t *sample_ops; + struct snd_seq_instr instr; + struct snd_trident_sample_ops *sample_ops; /* channel parameters */ unsigned int CSO; /* 24 bits (16 on DX) */ @@ -323,13 +323,13 @@ struct _snd_trident_voice { unsigned int negCSO; /* nonzero - use negative CSO */ - snd_util_memblk_t *memblk; /* memory block if TLB enabled */ + struct snd_util_memblk *memblk; /* memory block if TLB enabled */ /* PCM data */ - trident_t *trident; - snd_pcm_substream_t *substream; - snd_trident_voice_t *extra; /* extra PCM voice (acts as interrupt generator) */ + struct snd_trident *trident; + struct snd_pcm_substream *substream; + struct snd_trident_voice *extra; /* extra PCM voice (acts as interrupt generator) */ unsigned int running: 1, capture: 1, spdif: 1, @@ -347,25 +347,25 @@ struct _snd_trident_voice { /* --- */ void *private_data; - void (*private_free)(snd_trident_voice_t *voice); + void (*private_free)(struct snd_trident_voice *voice); }; -struct _snd_4dwave { +struct snd_4dwave { int seq_client; - snd_trident_port_t seq_ports[4]; - snd_simple_ops_t simple_ops; - snd_seq_kinstr_list_t *ilist; + struct snd_trident_port seq_ports[4]; + struct snd_simple_ops simple_ops; + struct snd_seq_kinstr_list *ilist; - snd_trident_voice_t voices[64]; + struct snd_trident_voice voices[64]; int ChanSynthCount; /* number of allocated synth channels */ int max_size; /* maximum synth memory size in bytes */ int current_size; /* current allocated synth mem in bytes */ }; -struct _snd_trident_pcm_mixer { - snd_trident_voice_t *voice; /* active voice */ +struct snd_trident_pcm_mixer { + struct snd_trident_voice *voice; /* active voice */ unsigned short vol; /* front volume */ unsigned char pan; /* pan control */ unsigned char rvol; /* rear volume */ @@ -373,7 +373,7 @@ struct _snd_trident_pcm_mixer { unsigned char pad; }; -struct _snd_trident { +struct snd_trident { int irq; unsigned int device; /* device ID */ @@ -386,13 +386,13 @@ struct _snd_trident { unsigned int spurious_irq_count; unsigned int spurious_irq_max_delta; - snd_trident_tlb_t tlb; /* TLB entries for NX cards */ + struct snd_trident_tlb tlb; /* TLB entries for NX cards */ unsigned char spdif_ctrl; unsigned char spdif_pcm_ctrl; unsigned int spdif_bits; unsigned int spdif_pcm_bits; - snd_kcontrol_t *spdif_pcm_ctl; /* S/PDIF settings */ + struct snd_kcontrol *spdif_pcm_ctl; /* S/PDIF settings */ unsigned int ac97_ctrl; unsigned int ChanMap[2]; /* allocation map for hardware channels */ @@ -403,7 +403,7 @@ struct _snd_trident { unsigned int ac97_detect: 1; /* 1 = AC97 in detection phase */ unsigned int in_suspend: 1; /* 1 during suspend/resume */ - struct _snd_4dwave synth; /* synth specific variables */ + struct snd_4dwave synth; /* synth specific variables */ spinlock_t event_lock; spinlock_t voice_alloc; @@ -411,52 +411,55 @@ struct _snd_trident { struct snd_dma_device dma_dev; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; /* ADC/DAC PCM */ - snd_pcm_t *foldback; /* Foldback PCM */ - snd_pcm_t *spdif; /* SPDIF PCM */ - snd_rawmidi_t *rmidi; - snd_seq_device_t *seq_dev; + struct snd_card *card; + struct snd_pcm *pcm; /* ADC/DAC PCM */ + struct snd_pcm *foldback; /* Foldback PCM */ + struct snd_pcm *spdif; /* SPDIF PCM */ + struct snd_rawmidi *rmidi; + struct snd_seq_device *seq_dev; - ac97_bus_t *ac97_bus; - ac97_t *ac97; - ac97_t *ac97_sec; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97; + struct snd_ac97 *ac97_sec; unsigned int musicvol_wavevol; - snd_trident_pcm_mixer_t pcm_mixer[32]; - snd_kcontrol_t *ctl_vol; /* front volume */ - snd_kcontrol_t *ctl_pan; /* pan */ - snd_kcontrol_t *ctl_rvol; /* rear volume */ - snd_kcontrol_t *ctl_cvol; /* center volume */ + struct snd_trident_pcm_mixer pcm_mixer[32]; + struct snd_kcontrol *ctl_vol; /* front volume */ + struct snd_kcontrol *ctl_pan; /* pan */ + struct snd_kcontrol *ctl_rvol; /* rear volume */ + struct snd_kcontrol *ctl_cvol; /* center volume */ spinlock_t reg_lock; struct gameport *gameport; }; -int snd_trident_create(snd_card_t * card, +int snd_trident_create(struct snd_card *card, struct pci_dev *pci, int pcm_streams, int pcm_spdif_device, int max_wavetable_size, - trident_t ** rtrident); -int snd_trident_create_gameport(trident_t *trident); - -int snd_trident_pcm(trident_t * trident, int device, snd_pcm_t **rpcm); -int snd_trident_foldback_pcm(trident_t * trident, int device, snd_pcm_t **rpcm); -int snd_trident_spdif_pcm(trident_t * trident, int device, snd_pcm_t **rpcm); -int snd_trident_attach_synthesizer(trident_t * trident); -snd_trident_voice_t *snd_trident_alloc_voice(trident_t * trident, int type, int client, int port); -void snd_trident_free_voice(trident_t * trident, snd_trident_voice_t *voice); -void snd_trident_start_voice(trident_t * trident, unsigned int voice); -void snd_trident_stop_voice(trident_t * trident, unsigned int voice); -void snd_trident_write_voice_regs(trident_t * trident, snd_trident_voice_t *voice); + struct snd_trident ** rtrident); +int snd_trident_create_gameport(struct snd_trident *trident); + +int snd_trident_pcm(struct snd_trident * trident, int device, struct snd_pcm **rpcm); +int snd_trident_foldback_pcm(struct snd_trident * trident, int device, struct snd_pcm **rpcm); +int snd_trident_spdif_pcm(struct snd_trident * trident, int device, struct snd_pcm **rpcm); +int snd_trident_attach_synthesizer(struct snd_trident * trident); +struct snd_trident_voice *snd_trident_alloc_voice(struct snd_trident * trident, int type, + int client, int port); +void snd_trident_free_voice(struct snd_trident * trident, struct snd_trident_voice *voice); +void snd_trident_start_voice(struct snd_trident * trident, unsigned int voice); +void snd_trident_stop_voice(struct snd_trident * trident, unsigned int voice); +void snd_trident_write_voice_regs(struct snd_trident * trident, struct snd_trident_voice *voice); /* TLB memory allocation */ -snd_util_memblk_t *snd_trident_alloc_pages(trident_t *trident, snd_pcm_substream_t *substream); -int snd_trident_free_pages(trident_t *trident, snd_util_memblk_t *blk); -snd_util_memblk_t *snd_trident_synth_alloc(trident_t *trident, unsigned int size); -int snd_trident_synth_free(trident_t *trident, snd_util_memblk_t *blk); -int snd_trident_synth_copy_from_user(trident_t *trident, snd_util_memblk_t *blk, int offset, const char __user *data, int size); +struct snd_util_memblk *snd_trident_alloc_pages(struct snd_trident *trident, + struct snd_pcm_substream *substream); +int snd_trident_free_pages(struct snd_trident *trident, struct snd_util_memblk *blk); +struct snd_util_memblk *snd_trident_synth_alloc(struct snd_trident *trident, unsigned int size); +int snd_trident_synth_free(struct snd_trident *trident, struct snd_util_memblk *blk); +int snd_trident_synth_copy_from_user(struct snd_trident *trident, struct snd_util_memblk *blk, + int offset, const char __user *data, int size); #endif /* __SOUND_TRIDENT_H */ diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index 940d531..0999f1f 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c @@ -76,8 +76,8 @@ static int __devinit snd_trident_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - trident_t *trident; + struct snd_card *card; + struct snd_trident *trident; const char *str; int err, pcm_dev = 0; diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 62f109f..6277dcc 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -44,17 +44,23 @@ #include <asm/io.h> -static int snd_trident_pcm_mixer_build(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream); -static int snd_trident_pcm_mixer_free(trident_t *trident, snd_trident_voice_t * voice, snd_pcm_substream_t *substream); -static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs); +static int snd_trident_pcm_mixer_build(struct snd_trident *trident, + struct snd_trident_voice * voice, + struct snd_pcm_substream *substream); +static int snd_trident_pcm_mixer_free(struct snd_trident *trident, + struct snd_trident_voice * voice, + struct snd_pcm_substream *substream); +static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, + struct pt_regs *regs); #ifdef CONFIG_PM -static int snd_trident_suspend(snd_card_t *card, pm_message_t state); -static int snd_trident_resume(snd_card_t *card); +static int snd_trident_suspend(struct snd_card *card, pm_message_t state); +static int snd_trident_resume(struct snd_card *card); #endif -static int snd_trident_sis_reset(trident_t *trident); +static int snd_trident_sis_reset(struct snd_trident *trident); -static void snd_trident_clear_voices(trident_t * trident, unsigned short v_min, unsigned short v_max); -static int snd_trident_free(trident_t *trident); +static void snd_trident_clear_voices(struct snd_trident * trident, + unsigned short v_min, unsigned short v_max); +static int snd_trident_free(struct snd_trident *trident); /* * common I/O routines @@ -62,7 +68,7 @@ static int snd_trident_free(trident_t *trident); #if 0 -static void snd_trident_print_voice_regs(trident_t *trident, int voice) +static void snd_trident_print_voice_regs(struct snd_trident *trident, int voice) { unsigned int val, tmp; @@ -104,7 +110,7 @@ static void snd_trident_print_voice_regs(trident_t *trident, int voice) #endif /*--------------------------------------------------------------------------- - unsigned short snd_trident_codec_read(ac97_t *ac97, unsigned short reg) + unsigned short snd_trident_codec_read(struct snd_ac97 *ac97, unsigned short reg) Description: This routine will do all of the reading from the external CODEC (AC97). @@ -115,12 +121,12 @@ static void snd_trident_print_voice_regs(trident_t *trident, int voice) returns: 16 bit value read from the AC97. ---------------------------------------------------------------------------*/ -static unsigned short snd_trident_codec_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_trident_codec_read(struct snd_ac97 *ac97, unsigned short reg) { unsigned int data = 0, treg; unsigned short count = 0xffff; unsigned long flags; - trident_t *trident = ac97->private_data; + struct snd_trident *trident = ac97->private_data; spin_lock_irqsave(&trident->reg_lock, flags); if (trident->device == TRIDENT_DEVICE_ID_DX) { @@ -153,7 +159,8 @@ static unsigned short snd_trident_codec_read(ac97_t *ac97, unsigned short reg) } if (count == 0 && !trident->ac97_detect) { - snd_printk(KERN_ERR "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n", reg, data); + snd_printk(KERN_ERR "ac97 codec read TIMEOUT [0x%x/0x%x]!!!\n", + reg, data); data = 0; } @@ -162,7 +169,8 @@ static unsigned short snd_trident_codec_read(ac97_t *ac97, unsigned short reg) } /*--------------------------------------------------------------------------- - void snd_trident_codec_write(ac97_t *ac97, unsigned short reg, unsigned short wdata) + void snd_trident_codec_write(struct snd_ac97 *ac97, unsigned short reg, + unsigned short wdata) Description: This routine will do all of the writing to the external CODEC (AC97). @@ -174,12 +182,13 @@ static unsigned short snd_trident_codec_read(ac97_t *ac97, unsigned short reg) returns: TRUE if everything went ok, else FALSE. ---------------------------------------------------------------------------*/ -static void snd_trident_codec_write(ac97_t *ac97, unsigned short reg, unsigned short wdata) +static void snd_trident_codec_write(struct snd_ac97 *ac97, unsigned short reg, + unsigned short wdata) { unsigned int address, data; unsigned short count = 0xffff; unsigned long flags; - trident_t *trident = ac97->private_data; + struct snd_trident *trident = ac97->private_data; data = ((unsigned long) wdata) << 16; @@ -230,7 +239,7 @@ static void snd_trident_codec_write(ac97_t *ac97, unsigned short reg, unsigned s } /*--------------------------------------------------------------------------- - void snd_trident_enable_eso(trident_t *trident) + void snd_trident_enable_eso(struct snd_trident *trident) Description: This routine will enable end of loop interrupts. End of loop interrupts will occur when a running @@ -241,7 +250,7 @@ static void snd_trident_codec_write(ac97_t *ac97, unsigned short reg, unsigned s ---------------------------------------------------------------------------*/ -static void snd_trident_enable_eso(trident_t * trident) +static void snd_trident_enable_eso(struct snd_trident * trident) { unsigned int val; @@ -254,7 +263,7 @@ static void snd_trident_enable_eso(trident_t * trident) } /*--------------------------------------------------------------------------- - void snd_trident_disable_eso(trident_t *trident) + void snd_trident_disable_eso(struct snd_trident *trident) Description: This routine will disable end of loop interrupts. End of loop interrupts will occur when a running @@ -268,7 +277,7 @@ static void snd_trident_enable_eso(trident_t * trident) ---------------------------------------------------------------------------*/ -static void snd_trident_disable_eso(trident_t * trident) +static void snd_trident_disable_eso(struct snd_trident * trident) { unsigned int tmp; @@ -279,7 +288,7 @@ static void snd_trident_disable_eso(trident_t * trident) } /*--------------------------------------------------------------------------- - void snd_trident_start_voice(trident_t * trident, unsigned int voice) + void snd_trident_start_voice(struct snd_trident * trident, unsigned int voice) Description: Start a voice, any channel 0 thru 63. This routine automatically handles the fact that there are @@ -292,7 +301,7 @@ static void snd_trident_disable_eso(trident_t * trident) ---------------------------------------------------------------------------*/ -void snd_trident_start_voice(trident_t * trident, unsigned int voice) +void snd_trident_start_voice(struct snd_trident * trident, unsigned int voice) { unsigned int mask = 1 << (voice & 0x1f); unsigned int reg = (voice & 0x20) ? T4D_START_B : T4D_START_A; @@ -301,7 +310,7 @@ void snd_trident_start_voice(trident_t * trident, unsigned int voice) } /*--------------------------------------------------------------------------- - void snd_trident_stop_voice(trident_t * trident, unsigned int voice) + void snd_trident_stop_voice(struct snd_trident * trident, unsigned int voice) Description: Stop a voice, any channel 0 thru 63. This routine automatically handles the fact that there are @@ -314,7 +323,7 @@ void snd_trident_start_voice(trident_t * trident, unsigned int voice) ---------------------------------------------------------------------------*/ -void snd_trident_stop_voice(trident_t * trident, unsigned int voice) +void snd_trident_stop_voice(struct snd_trident * trident, unsigned int voice) { unsigned int mask = 1 << (voice & 0x1f); unsigned int reg = (voice & 0x20) ? T4D_STOP_B : T4D_STOP_A; @@ -323,7 +332,7 @@ void snd_trident_stop_voice(trident_t * trident, unsigned int voice) } /*--------------------------------------------------------------------------- - int snd_trident_allocate_pcm_channel(trident_t *trident) + int snd_trident_allocate_pcm_channel(struct snd_trident *trident) Description: Allocate hardware channel in Bank B (32-63). @@ -333,7 +342,7 @@ void snd_trident_stop_voice(trident_t * trident, unsigned int voice) ---------------------------------------------------------------------------*/ -static int snd_trident_allocate_pcm_channel(trident_t * trident) +static int snd_trident_allocate_pcm_channel(struct snd_trident * trident) { int idx; @@ -361,7 +370,7 @@ static int snd_trident_allocate_pcm_channel(trident_t * trident) ---------------------------------------------------------------------------*/ -static void snd_trident_free_pcm_channel(trident_t *trident, int channel) +static void snd_trident_free_pcm_channel(struct snd_trident *trident, int channel) { if (channel < 32 || channel > 63) return; @@ -383,7 +392,7 @@ static void snd_trident_free_pcm_channel(trident_t *trident, int channel) ---------------------------------------------------------------------------*/ -static int snd_trident_allocate_synth_channel(trident_t * trident) +static int snd_trident_allocate_synth_channel(struct snd_trident * trident) { int idx; @@ -409,7 +418,7 @@ static int snd_trident_allocate_synth_channel(trident_t * trident) ---------------------------------------------------------------------------*/ -static void snd_trident_free_synth_channel(trident_t *trident, int channel) +static void snd_trident_free_synth_channel(struct snd_trident *trident, int channel) { if (channel < 0 || channel > 31) return; @@ -432,8 +441,8 @@ static void snd_trident_free_synth_channel(trident_t *trident, int channel) ---------------------------------------------------------------------------*/ -void snd_trident_write_voice_regs(trident_t * trident, - snd_trident_voice_t * voice) +void snd_trident_write_voice_regs(struct snd_trident * trident, + struct snd_trident_voice * voice) { unsigned int FmcRvolCvol; unsigned int regs[5]; @@ -452,14 +461,16 @@ void snd_trident_write_voice_regs(trident_t * trident, (voice->Vol & 0x000003ff) : ((voice->Vol & 0x00003fc) << (16-2)) | (voice->EC & 0x00000fff); - regs[0] = (voice->CSO << 16) | ((voice->Alpha & 0x00000fff) << 4) | (voice->FMS & 0x0000000f); + regs[0] = (voice->CSO << 16) | ((voice->Alpha & 0x00000fff) << 4) | + (voice->FMS & 0x0000000f); regs[2] = (voice->ESO << 16) | (voice->Delta & 0x0ffff); regs[3] = (voice->Attribute << 16) | FmcRvolCvol; break; case TRIDENT_DEVICE_ID_DX: regs[4] |= ((voice->Vol & 0x000003fc) << (16-2)) | (voice->EC & 0x00000fff); - regs[0] = (voice->CSO << 16) | ((voice->Alpha & 0x00000fff) << 4) | (voice->FMS & 0x0000000f); + regs[0] = (voice->CSO << 16) | ((voice->Alpha & 0x00000fff) << 4) | + (voice->FMS & 0x0000000f); regs[2] = (voice->ESO << 16) | (voice->Delta & 0x0ffff); regs[3] = FmcRvolCvol; break; @@ -467,8 +478,10 @@ void snd_trident_write_voice_regs(trident_t * trident, regs[4] |= ((voice->Vol & 0x000003fc) << (16-2)) | (voice->EC & 0x00000fff); regs[0] = (voice->Delta << 24) | (voice->CSO & 0x00ffffff); - regs[2] = ((voice->Delta << 16) & 0xff000000) | (voice->ESO & 0x00ffffff); - regs[3] = (voice->Alpha << 20) | ((voice->FMS & 0x0000000f) << 16) | FmcRvolCvol; + regs[2] = ((voice->Delta << 16) & 0xff000000) | + (voice->ESO & 0x00ffffff); + regs[3] = (voice->Alpha << 20) | + ((voice->FMS & 0x0000000f) << 16) | FmcRvolCvol; break; default: snd_BUG(); @@ -504,14 +517,17 @@ void snd_trident_write_voice_regs(trident_t * trident, ---------------------------------------------------------------------------*/ -static void snd_trident_write_cso_reg(trident_t * trident, snd_trident_voice_t * voice, unsigned int CSO) +static void snd_trident_write_cso_reg(struct snd_trident * trident, + struct snd_trident_voice * voice, + unsigned int CSO) { voice->CSO = CSO; outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); if (trident->device != TRIDENT_DEVICE_ID_NX) { outw(voice->CSO, TRID_REG(trident, CH_DX_CSO_ALPHA_FMS) + 2); } else { - outl((voice->Delta << 24) | (voice->CSO & 0x00ffffff), TRID_REG(trident, CH_NX_DELTA_CSO)); + outl((voice->Delta << 24) | + (voice->CSO & 0x00ffffff), TRID_REG(trident, CH_NX_DELTA_CSO)); } } @@ -527,14 +543,17 @@ static void snd_trident_write_cso_reg(trident_t * trident, snd_trident_voice_t * ---------------------------------------------------------------------------*/ -static void snd_trident_write_eso_reg(trident_t * trident, snd_trident_voice_t * voice, unsigned int ESO) +static void snd_trident_write_eso_reg(struct snd_trident * trident, + struct snd_trident_voice * voice, + unsigned int ESO) { voice->ESO = ESO; outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); if (trident->device != TRIDENT_DEVICE_ID_NX) { outw(voice->ESO, TRID_REG(trident, CH_DX_ESO_DELTA) + 2); } else { - outl(((voice->Delta << 16) & 0xff000000) | (voice->ESO & 0x00ffffff), TRID_REG(trident, CH_NX_DELTA_ESO)); + outl(((voice->Delta << 16) & 0xff000000) | (voice->ESO & 0x00ffffff), + TRID_REG(trident, CH_NX_DELTA_ESO)); } } @@ -550,7 +569,9 @@ static void snd_trident_write_eso_reg(trident_t * trident, snd_trident_voice_t * ---------------------------------------------------------------------------*/ -static void snd_trident_write_vol_reg(trident_t * trident, snd_trident_voice_t * voice, unsigned int Vol) +static void snd_trident_write_vol_reg(struct snd_trident * trident, + struct snd_trident_voice * voice, + unsigned int Vol) { voice->Vol = Vol; outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); @@ -561,7 +582,8 @@ static void snd_trident_write_vol_reg(trident_t * trident, snd_trident_voice_t * break; case TRIDENT_DEVICE_ID_SI7018: // printk("voice->Vol = 0x%x\n", voice->Vol); - outw((voice->CTRL << 12) | voice->Vol, TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC)); + outw((voice->CTRL << 12) | voice->Vol, + TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC)); break; } } @@ -578,11 +600,14 @@ static void snd_trident_write_vol_reg(trident_t * trident, snd_trident_voice_t * ---------------------------------------------------------------------------*/ -static void snd_trident_write_pan_reg(trident_t * trident, snd_trident_voice_t * voice, unsigned int Pan) +static void snd_trident_write_pan_reg(struct snd_trident * trident, + struct snd_trident_voice * voice, + unsigned int Pan) { voice->Pan = Pan; outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); - outb(((voice->GVSel & 0x01) << 7) | (voice->Pan & 0x7f), TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC + 3)); + outb(((voice->GVSel & 0x01) << 7) | (voice->Pan & 0x7f), + TRID_REG(trident, CH_GVSEL_PAN_VOL_CTRL_EC + 3)); } /*--------------------------------------------------------------------------- @@ -597,12 +622,16 @@ static void snd_trident_write_pan_reg(trident_t * trident, snd_trident_voice_t * ---------------------------------------------------------------------------*/ -static void snd_trident_write_rvol_reg(trident_t * trident, snd_trident_voice_t * voice, unsigned int RVol) +static void snd_trident_write_rvol_reg(struct snd_trident * trident, + struct snd_trident_voice * voice, + unsigned int RVol) { voice->RVol = RVol; outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); - outw(((voice->FMC & 0x0003) << 14) | ((voice->RVol & 0x007f) << 7) | (voice->CVol & 0x007f), - TRID_REG(trident, trident->device == TRIDENT_DEVICE_ID_NX ? CH_NX_ALPHA_FMS_FMC_RVOL_CVOL : CH_DX_FMC_RVOL_CVOL)); + outw(((voice->FMC & 0x0003) << 14) | ((voice->RVol & 0x007f) << 7) | + (voice->CVol & 0x007f), + TRID_REG(trident, trident->device == TRIDENT_DEVICE_ID_NX ? + CH_NX_ALPHA_FMS_FMC_RVOL_CVOL : CH_DX_FMC_RVOL_CVOL)); } /*--------------------------------------------------------------------------- @@ -617,12 +646,16 @@ static void snd_trident_write_rvol_reg(trident_t * trident, snd_trident_voice_t ---------------------------------------------------------------------------*/ -static void snd_trident_write_cvol_reg(trident_t * trident, snd_trident_voice_t * voice, unsigned int CVol) +static void snd_trident_write_cvol_reg(struct snd_trident * trident, + struct snd_trident_voice * voice, + unsigned int CVol) { voice->CVol = CVol; outb(voice->number, TRID_REG(trident, T4D_LFO_GC_CIR)); - outw(((voice->FMC & 0x0003) << 14) | ((voice->RVol & 0x007f) << 7) | (voice->CVol & 0x007f), - TRID_REG(trident, trident->device == TRIDENT_DEVICE_ID_NX ? CH_NX_ALPHA_FMS_FMC_RVOL_CVOL : CH_DX_FMC_RVOL_CVOL)); + outw(((voice->FMC & 0x0003) << 14) | ((voice->RVol & 0x007f) << 7) | + (voice->CVol & 0x007f), + TRID_REG(trident, trident->device == TRIDENT_DEVICE_ID_NX ? + CH_NX_ALPHA_FMS_FMC_RVOL_CVOL : CH_DX_FMC_RVOL_CVOL)); } /*--------------------------------------------------------------------------- @@ -696,7 +729,8 @@ static unsigned int snd_trident_convert_adc_rate(unsigned int rate) Returns: Delta value. ---------------------------------------------------------------------------*/ -static unsigned int snd_trident_spurious_threshold(unsigned int rate, unsigned int period_size) +static unsigned int snd_trident_spurious_threshold(unsigned int rate, + unsigned int period_size) { unsigned int res = (rate * period_size) / 48000; if (res < 64) @@ -717,10 +751,10 @@ static unsigned int snd_trident_spurious_threshold(unsigned int rate, unsigned i Returns: Control value. ---------------------------------------------------------------------------*/ -static unsigned int snd_trident_control_mode(snd_pcm_substream_t *substream) +static unsigned int snd_trident_control_mode(struct snd_pcm_substream *substream) { unsigned int CTRL; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; /* set ctrl mode CTRL default: 8-bit (unsigned) mono, loop mode enabled @@ -752,7 +786,7 @@ static unsigned int snd_trident_control_mode(snd_pcm_substream_t *substream) ---------------------------------------------------------------------------*/ -static int snd_trident_ioctl(snd_pcm_substream_t * substream, +static int snd_trident_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { @@ -774,12 +808,12 @@ static int snd_trident_ioctl(snd_pcm_substream_t * substream, ---------------------------------------------------------------------------*/ -static int snd_trident_allocate_pcm_mem(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_trident_allocate_pcm_mem(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) @@ -808,13 +842,13 @@ static int snd_trident_allocate_pcm_mem(snd_pcm_substream_t * substream, ---------------------------------------------------------------------------*/ -static int snd_trident_allocate_evoice(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_trident_allocate_evoice(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; - snd_trident_voice_t *evoice = voice->extra; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; + struct snd_trident_voice *evoice = voice->extra; /* voice management */ @@ -848,8 +882,8 @@ static int snd_trident_allocate_evoice(snd_pcm_substream_t * substream, ---------------------------------------------------------------------------*/ -static int snd_trident_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_trident_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int err; @@ -870,12 +904,12 @@ static int snd_trident_hw_params(snd_pcm_substream_t * substream, ---------------------------------------------------------------------------*/ -static int snd_trident_hw_free(snd_pcm_substream_t * substream) +static int snd_trident_hw_free(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; - snd_trident_voice_t *evoice = voice ? voice->extra : NULL; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; + struct snd_trident_voice *evoice = voice ? voice->extra : NULL; if (trident->tlb.entries) { if (voice && voice->memblk) { @@ -902,13 +936,13 @@ static int snd_trident_hw_free(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_playback_prepare(snd_pcm_substream_t * substream) +static int snd_trident_playback_prepare(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; - snd_trident_voice_t *evoice = voice->extra; - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[substream->number]; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; + struct snd_trident_voice *evoice = voice->extra; + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[substream->number]; spin_lock_irq(&trident->reg_lock); @@ -988,8 +1022,8 @@ static int snd_trident_playback_prepare(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_trident_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_trident_allocate_pcm_mem(substream, hw_params); } @@ -1005,11 +1039,11 @@ static int snd_trident_capture_hw_params(snd_pcm_substream_t * substream, ---------------------------------------------------------------------------*/ -static int snd_trident_capture_prepare(snd_pcm_substream_t * substream) +static int snd_trident_capture_prepare(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; unsigned int val, ESO_bytes; spin_lock_irq(&trident->reg_lock); @@ -1097,8 +1131,8 @@ static int snd_trident_capture_prepare(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_si7018_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_trident_si7018_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int err; @@ -1119,12 +1153,12 @@ static int snd_trident_si7018_capture_hw_params(snd_pcm_substream_t * substream, ---------------------------------------------------------------------------*/ -static int snd_trident_si7018_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_trident_si7018_capture_hw_free(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; - snd_trident_voice_t *evoice = voice ? voice->extra : NULL; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; + struct snd_trident_voice *evoice = voice ? voice->extra : NULL; snd_pcm_lib_free_pages(substream); if (evoice != NULL) { @@ -1145,12 +1179,12 @@ static int snd_trident_si7018_capture_hw_free(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_si7018_capture_prepare(snd_pcm_substream_t * substream) +static int snd_trident_si7018_capture_prepare(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; - snd_trident_voice_t *evoice = voice->extra; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; + struct snd_trident_voice *evoice = voice->extra; spin_lock_irq(&trident->reg_lock); @@ -1216,12 +1250,12 @@ static int snd_trident_si7018_capture_prepare(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_foldback_prepare(snd_pcm_substream_t * substream) +static int snd_trident_foldback_prepare(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; - snd_trident_voice_t *evoice = voice->extra; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; + struct snd_trident_voice *evoice = voice->extra; spin_lock_irq(&trident->reg_lock); @@ -1294,10 +1328,10 @@ static int snd_trident_foldback_prepare(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_spdif_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_trident_spdif_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - trident_t *trident = snd_pcm_substream_chip(substream); + struct snd_trident *trident = snd_pcm_substream_chip(substream); unsigned int old_bits = 0, change = 0; int err; @@ -1359,13 +1393,13 @@ static int snd_trident_spdif_hw_params(snd_pcm_substream_t * substream, ---------------------------------------------------------------------------*/ -static int snd_trident_spdif_prepare(snd_pcm_substream_t * substream) +static int snd_trident_spdif_prepare(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; - snd_trident_voice_t *evoice = voice->extra; - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[substream->number]; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; + struct snd_trident_voice *evoice = voice->extra; + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[substream->number]; unsigned int RESO, LBAO; unsigned int temp; @@ -1498,15 +1532,15 @@ static int snd_trident_spdif_prepare(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_trigger(snd_pcm_substream_t *substream, +static int snd_trident_trigger(struct snd_pcm_substream *substream, int cmd) { - trident_t *trident = snd_pcm_substream_chip(substream); + struct snd_trident *trident = snd_pcm_substream_chip(substream); struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; unsigned int what, whati, capture_flag, spdif_flag; - snd_trident_voice_t *voice, *evoice; + struct snd_trident_voice *voice, *evoice; unsigned int val, go; switch (cmd) { @@ -1528,8 +1562,8 @@ static int snd_trident_trigger(snd_pcm_substream_t *substream, val = inl(TRID_REG(trident, T4D_STIMER)) & 0x00ffffff; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); - if ((trident_t *) snd_pcm_substream_chip(s) == trident) { - voice = (snd_trident_voice_t *) s->runtime->private_data; + if ((struct snd_trident *) snd_pcm_substream_chip(s) == trident) { + voice = s->runtime->private_data; evoice = voice->extra; what |= 1 << (voice->number & 0x1f); if (evoice == NULL) { @@ -1596,11 +1630,11 @@ static int snd_trident_trigger(snd_pcm_substream_t *substream, ---------------------------------------------------------------------------*/ -static snd_pcm_uframes_t snd_trident_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_trident_playback_pointer(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; unsigned int cso; if (!voice->running) @@ -1635,11 +1669,11 @@ static snd_pcm_uframes_t snd_trident_playback_pointer(snd_pcm_substream_t * subs ---------------------------------------------------------------------------*/ -static snd_pcm_uframes_t snd_trident_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_trident_capture_pointer(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; unsigned int result; if (!voice->running) @@ -1665,11 +1699,11 @@ static snd_pcm_uframes_t snd_trident_capture_pointer(snd_pcm_substream_t * subst ---------------------------------------------------------------------------*/ -static snd_pcm_uframes_t snd_trident_spdif_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_trident_spdif_pointer(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; unsigned int result; if (!voice->running) @@ -1684,7 +1718,7 @@ static snd_pcm_uframes_t snd_trident_spdif_pointer(snd_pcm_substream_t * substre * Playback support device description */ -static snd_pcm_hardware_t snd_trident_playback = +static struct snd_pcm_hardware snd_trident_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1709,7 +1743,7 @@ static snd_pcm_hardware_t snd_trident_playback = * Capture support device description */ -static snd_pcm_hardware_t snd_trident_capture = +static struct snd_pcm_hardware snd_trident_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1734,7 +1768,7 @@ static snd_pcm_hardware_t snd_trident_capture = * Foldback capture support device description */ -static snd_pcm_hardware_t snd_trident_foldback = +static struct snd_pcm_hardware snd_trident_foldback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1758,7 +1792,7 @@ static snd_pcm_hardware_t snd_trident_foldback = * SPDIF playback support device description */ -static snd_pcm_hardware_t snd_trident_spdif = +static struct snd_pcm_hardware snd_trident_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1779,7 +1813,7 @@ static snd_pcm_hardware_t snd_trident_spdif = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_trident_spdif_7018 = +static struct snd_pcm_hardware snd_trident_spdif_7018 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1799,10 +1833,10 @@ static snd_pcm_hardware_t snd_trident_spdif_7018 = .fifo_size = 0, }; -static void snd_trident_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_trident_pcm_free_substream(struct snd_pcm_runtime *runtime) { - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; - trident_t *trident; + struct snd_trident_voice *voice = runtime->private_data; + struct snd_trident *trident; if (voice) { trident = voice->trident; @@ -1810,11 +1844,11 @@ static void snd_trident_pcm_free_substream(snd_pcm_runtime_t *runtime) } } -static int snd_trident_playback_open(snd_pcm_substream_t * substream) +static int snd_trident_playback_open(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice; voice = snd_trident_alloc_voice(trident, SNDRV_TRIDENT_VOICE_TYPE_PCM, 0, 0); if (voice == NULL) @@ -1838,11 +1872,11 @@ static int snd_trident_playback_open(snd_pcm_substream_t * substream) Parameters: substream - PCM substream class ---------------------------------------------------------------------------*/ -static int snd_trident_playback_close(snd_pcm_substream_t * substream) +static int snd_trident_playback_close(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_trident_voice_t *voice = (snd_trident_voice_t *) runtime->private_data; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_trident_voice *voice = runtime->private_data; snd_trident_pcm_mixer_free(trident, voice, substream); return 0; @@ -1859,11 +1893,11 @@ static int snd_trident_playback_close(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_spdif_open(snd_pcm_substream_t * substream) +static int snd_trident_spdif_open(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_trident_voice_t *voice; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_trident_voice *voice; + struct snd_pcm_runtime *runtime = substream->runtime; voice = snd_trident_alloc_voice(trident, SNDRV_TRIDENT_VOICE_TYPE_PCM, 0, 0); if (voice == NULL) @@ -1900,9 +1934,9 @@ static int snd_trident_spdif_open(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_spdif_close(snd_pcm_substream_t * substream) +static int snd_trident_spdif_close(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); + struct snd_trident *trident = snd_pcm_substream_chip(substream); unsigned int temp; spin_lock_irq(&trident->reg_lock); @@ -1938,11 +1972,11 @@ static int snd_trident_spdif_close(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_capture_open(snd_pcm_substream_t * substream) +static int snd_trident_capture_open(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_trident_voice_t *voice; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_trident_voice *voice; + struct snd_pcm_runtime *runtime = substream->runtime; voice = snd_trident_alloc_voice(trident, SNDRV_TRIDENT_VOICE_TYPE_PCM, 0, 0); if (voice == NULL) @@ -1966,7 +2000,7 @@ static int snd_trident_capture_open(snd_pcm_substream_t * substream) Parameters: substream - PCM substream class ---------------------------------------------------------------------------*/ -static int snd_trident_capture_close(snd_pcm_substream_t * substream) +static int snd_trident_capture_close(struct snd_pcm_substream *substream) { return 0; } @@ -1982,11 +2016,11 @@ static int snd_trident_capture_close(snd_pcm_substream_t * substream) ---------------------------------------------------------------------------*/ -static int snd_trident_foldback_open(snd_pcm_substream_t * substream) +static int snd_trident_foldback_open(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_trident_voice_t *voice; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_trident_voice *voice; + struct snd_pcm_runtime *runtime = substream->runtime; voice = snd_trident_alloc_voice(trident, SNDRV_TRIDENT_VOICE_TYPE_PCM, 0, 0); if (voice == NULL) @@ -2009,12 +2043,12 @@ static int snd_trident_foldback_open(snd_pcm_substream_t * substream) Parameters: substream - PCM substream class ---------------------------------------------------------------------------*/ -static int snd_trident_foldback_close(snd_pcm_substream_t * substream) +static int snd_trident_foldback_close(struct snd_pcm_substream *substream) { - trident_t *trident = snd_pcm_substream_chip(substream); - snd_trident_voice_t *voice; - snd_pcm_runtime_t *runtime = substream->runtime; - voice = (snd_trident_voice_t *) runtime->private_data; + struct snd_trident *trident = snd_pcm_substream_chip(substream); + struct snd_trident_voice *voice; + struct snd_pcm_runtime *runtime = substream->runtime; + voice = runtime->private_data; /* stop capture channel */ spin_lock_irq(&trident->reg_lock); @@ -2027,7 +2061,7 @@ static int snd_trident_foldback_close(snd_pcm_substream_t * substream) PCM operations ---------------------------------------------------------------------------*/ -static snd_pcm_ops_t snd_trident_playback_ops = { +static struct snd_pcm_ops snd_trident_playback_ops = { .open = snd_trident_playback_open, .close = snd_trident_playback_close, .ioctl = snd_trident_ioctl, @@ -2038,7 +2072,7 @@ static snd_pcm_ops_t snd_trident_playback_ops = { .pointer = snd_trident_playback_pointer, }; -static snd_pcm_ops_t snd_trident_nx_playback_ops = { +static struct snd_pcm_ops snd_trident_nx_playback_ops = { .open = snd_trident_playback_open, .close = snd_trident_playback_close, .ioctl = snd_trident_ioctl, @@ -2050,7 +2084,7 @@ static snd_pcm_ops_t snd_trident_nx_playback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static snd_pcm_ops_t snd_trident_capture_ops = { +static struct snd_pcm_ops snd_trident_capture_ops = { .open = snd_trident_capture_open, .close = snd_trident_capture_close, .ioctl = snd_trident_ioctl, @@ -2061,7 +2095,7 @@ static snd_pcm_ops_t snd_trident_capture_ops = { .pointer = snd_trident_capture_pointer, }; -static snd_pcm_ops_t snd_trident_si7018_capture_ops = { +static struct snd_pcm_ops snd_trident_si7018_capture_ops = { .open = snd_trident_capture_open, .close = snd_trident_capture_close, .ioctl = snd_trident_ioctl, @@ -2072,7 +2106,7 @@ static snd_pcm_ops_t snd_trident_si7018_capture_ops = { .pointer = snd_trident_playback_pointer, }; -static snd_pcm_ops_t snd_trident_foldback_ops = { +static struct snd_pcm_ops snd_trident_foldback_ops = { .open = snd_trident_foldback_open, .close = snd_trident_foldback_close, .ioctl = snd_trident_ioctl, @@ -2083,7 +2117,7 @@ static snd_pcm_ops_t snd_trident_foldback_ops = { .pointer = snd_trident_playback_pointer, }; -static snd_pcm_ops_t snd_trident_nx_foldback_ops = { +static struct snd_pcm_ops snd_trident_nx_foldback_ops = { .open = snd_trident_foldback_open, .close = snd_trident_foldback_close, .ioctl = snd_trident_ioctl, @@ -2095,7 +2129,7 @@ static snd_pcm_ops_t snd_trident_nx_foldback_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static snd_pcm_ops_t snd_trident_spdif_ops = { +static struct snd_pcm_ops snd_trident_spdif_ops = { .open = snd_trident_spdif_open, .close = snd_trident_spdif_close, .ioctl = snd_trident_ioctl, @@ -2106,7 +2140,7 @@ static snd_pcm_ops_t snd_trident_spdif_ops = { .pointer = snd_trident_spdif_pointer, }; -static snd_pcm_ops_t snd_trident_spdif_7018_ops = { +static struct snd_pcm_ops snd_trident_spdif_7018_ops = { .open = snd_trident_spdif_open, .close = snd_trident_spdif_close, .ioctl = snd_trident_ioctl, @@ -2128,9 +2162,10 @@ static snd_pcm_ops_t snd_trident_spdif_7018_ops = { ---------------------------------------------------------------------------*/ -int __devinit snd_trident_pcm(trident_t * trident, int device, snd_pcm_t ** rpcm) +int __devinit snd_trident_pcm(struct snd_trident * trident, + int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -2156,7 +2191,7 @@ int __devinit snd_trident_pcm(trident_t * trident, int device, snd_pcm_t ** rpcm trident->pcm = pcm; if (trident->tlb.entries) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(trident->pci), @@ -2185,12 +2220,13 @@ int __devinit snd_trident_pcm(trident_t * trident, int device, snd_pcm_t ** rpcm ---------------------------------------------------------------------------*/ -int __devinit snd_trident_foldback_pcm(trident_t * trident, int device, snd_pcm_t ** rpcm) +int __devinit snd_trident_foldback_pcm(struct snd_trident * trident, + int device, struct snd_pcm ** rpcm) { - snd_pcm_t *foldback; + struct snd_pcm *foldback; int err; int num_chan = 3; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; if (rpcm) *rpcm = NULL; @@ -2241,9 +2277,10 @@ int __devinit snd_trident_foldback_pcm(trident_t * trident, int device, snd_pcm_ ---------------------------------------------------------------------------*/ -int __devinit snd_trident_spdif_pcm(trident_t * trident, int device, snd_pcm_t ** rpcm) +int __devinit snd_trident_spdif_pcm(struct snd_trident * trident, + int device, struct snd_pcm ** rpcm) { - snd_pcm_t *spdif; + struct snd_pcm *spdif; int err; if (rpcm) @@ -2279,7 +2316,8 @@ int __devinit snd_trident_spdif_pcm(trident_t * trident, int device, snd_pcm_t * Description: enable/disable S/PDIF out from ac97 mixer ---------------------------------------------------------------------------*/ -static int snd_trident_spdif_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_spdif_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2288,10 +2326,10 @@ static int snd_trident_spdif_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_trident_spdif_control_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_spdif_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); unsigned char val; spin_lock_irq(&trident->reg_lock); @@ -2301,10 +2339,10 @@ static int snd_trident_spdif_control_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_trident_spdif_control_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_spdif_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); unsigned char val; int change; @@ -2332,7 +2370,7 @@ static int snd_trident_spdif_control_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_spdif_control __devinitdata = +static struct snd_kcontrol_new snd_trident_spdif_control __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), @@ -2348,17 +2386,18 @@ static snd_kcontrol_new_t snd_trident_spdif_control __devinitdata = Description: put/get the S/PDIF default settings ---------------------------------------------------------------------------*/ -static int snd_trident_spdif_default_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_spdif_default_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_trident_spdif_default_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); spin_lock_irq(&trident->reg_lock); ucontrol->value.iec958.status[0] = (trident->spdif_bits >> 0) & 0xff; @@ -2369,10 +2408,10 @@ static int snd_trident_spdif_default_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_trident_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -2394,7 +2433,7 @@ static int snd_trident_spdif_default_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_spdif_default __devinitdata = +static struct snd_kcontrol_new snd_trident_spdif_default __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -2409,15 +2448,16 @@ static snd_kcontrol_new_t snd_trident_spdif_default __devinitdata = Description: put/get the S/PDIF mask ---------------------------------------------------------------------------*/ -static int snd_trident_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_spdif_mask_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_trident_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -2426,7 +2466,7 @@ static int snd_trident_spdif_mask_get(snd_kcontrol_t * kcontrol, return 0; } -static snd_kcontrol_new_t snd_trident_spdif_mask __devinitdata = +static struct snd_kcontrol_new snd_trident_spdif_mask __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -2441,17 +2481,18 @@ static snd_kcontrol_new_t snd_trident_spdif_mask __devinitdata = Description: put/get the S/PDIF stream settings ---------------------------------------------------------------------------*/ -static int snd_trident_spdif_stream_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_spdif_stream_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_trident_spdif_stream_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); spin_lock_irq(&trident->reg_lock); ucontrol->value.iec958.status[0] = (trident->spdif_pcm_bits >> 0) & 0xff; @@ -2462,10 +2503,10 @@ static int snd_trident_spdif_stream_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_trident_spdif_stream_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -2487,7 +2528,7 @@ static int snd_trident_spdif_stream_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_spdif_stream __devinitdata = +static struct snd_kcontrol_new snd_trident_spdif_stream __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -2503,7 +2544,8 @@ static snd_kcontrol_new_t snd_trident_spdif_stream __devinitdata = Description: enable/disable rear path for ac97 ---------------------------------------------------------------------------*/ -static int snd_trident_ac97_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_ac97_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2512,10 +2554,10 @@ static int snd_trident_ac97_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_trident_ac97_control_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_ac97_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); unsigned char val; spin_lock_irq(&trident->reg_lock); @@ -2525,10 +2567,10 @@ static int snd_trident_ac97_control_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_trident_ac97_control_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_ac97_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); unsigned char val; int change = 0; @@ -2544,7 +2586,7 @@ static int snd_trident_ac97_control_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_ac97_rear_control __devinitdata = +static struct snd_kcontrol_new snd_trident_ac97_rear_control __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Rear Path", @@ -2560,7 +2602,8 @@ static snd_kcontrol_new_t snd_trident_ac97_rear_control __devinitdata = Description: wave & music volume control ---------------------------------------------------------------------------*/ -static int snd_trident_vol_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_vol_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -2569,10 +2612,10 @@ static int snd_trident_vol_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_trident_vol_control_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_vol_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); unsigned int val; val = trident->musicvol_wavevol; @@ -2581,10 +2624,10 @@ static int snd_trident_vol_control_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_trident_vol_control_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_vol_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; @@ -2599,7 +2642,7 @@ static int snd_trident_vol_control_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_vol_music_control __devinitdata = +static struct snd_kcontrol_new snd_trident_vol_music_control __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Music Playback Volume", @@ -2609,7 +2652,7 @@ static snd_kcontrol_new_t snd_trident_vol_music_control __devinitdata = .private_value = 16, }; -static snd_kcontrol_new_t snd_trident_vol_wave_control __devinitdata = +static struct snd_kcontrol_new snd_trident_vol_wave_control __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Wave Playback Volume", @@ -2625,9 +2668,10 @@ static snd_kcontrol_new_t snd_trident_vol_wave_control __devinitdata = Description: PCM front volume control ---------------------------------------------------------------------------*/ -static int snd_trident_pcm_vol_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_pcm_vol_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - trident_t *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -2638,11 +2682,11 @@ static int snd_trident_pcm_vol_control_info(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_trident_pcm_vol_control_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_pcm_vol_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; if (trident->device == TRIDENT_DEVICE_ID_SI7018) { ucontrol->value.integer.value[0] = 1023 - mix->vol; @@ -2652,11 +2696,11 @@ static int snd_trident_pcm_vol_control_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_trident_pcm_vol_control_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_pcm_vol_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; unsigned int val; int change = 0; @@ -2674,7 +2718,7 @@ static int snd_trident_pcm_vol_control_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_pcm_vol_control __devinitdata = +static struct snd_kcontrol_new snd_trident_pcm_vol_control __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Front Playback Volume", @@ -2691,7 +2735,8 @@ static snd_kcontrol_new_t snd_trident_pcm_vol_control __devinitdata = Description: PCM front pan control ---------------------------------------------------------------------------*/ -static int snd_trident_pcm_pan_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_pcm_pan_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -2700,11 +2745,11 @@ static int snd_trident_pcm_pan_control_info(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_trident_pcm_pan_control_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_pcm_pan_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; ucontrol->value.integer.value[0] = mix->pan; if (ucontrol->value.integer.value[0] & 0x40) { @@ -2715,11 +2760,11 @@ static int snd_trident_pcm_pan_control_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_trident_pcm_pan_control_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_pcm_pan_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; unsigned char val; int change = 0; @@ -2736,7 +2781,7 @@ static int snd_trident_pcm_pan_control_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_pcm_pan_control __devinitdata = +static struct snd_kcontrol_new snd_trident_pcm_pan_control __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Pan Playback Control", @@ -2753,7 +2798,8 @@ static snd_kcontrol_new_t snd_trident_pcm_pan_control __devinitdata = Description: PCM reverb volume control ---------------------------------------------------------------------------*/ -static int snd_trident_pcm_rvol_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_pcm_rvol_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -2762,21 +2808,21 @@ static int snd_trident_pcm_rvol_control_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_trident_pcm_rvol_control_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_pcm_rvol_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; ucontrol->value.integer.value[0] = 127 - mix->rvol; return 0; } -static int snd_trident_pcm_rvol_control_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_pcm_rvol_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; unsigned short val; int change = 0; @@ -2790,7 +2836,7 @@ static int snd_trident_pcm_rvol_control_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_pcm_rvol_control __devinitdata = +static struct snd_kcontrol_new snd_trident_pcm_rvol_control __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Reverb Playback Volume", @@ -2807,7 +2853,8 @@ static snd_kcontrol_new_t snd_trident_pcm_rvol_control __devinitdata = Description: PCM chorus volume control ---------------------------------------------------------------------------*/ -static int snd_trident_pcm_cvol_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_trident_pcm_cvol_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -2816,21 +2863,21 @@ static int snd_trident_pcm_cvol_control_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_trident_pcm_cvol_control_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_pcm_cvol_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; ucontrol->value.integer.value[0] = 127 - mix->cvol; return 0; } -static int snd_trident_pcm_cvol_control_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_trident_pcm_cvol_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - trident_t *trident = snd_kcontrol_chip(kcontrol); - snd_trident_pcm_mixer_t *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; + struct snd_trident *trident = snd_kcontrol_chip(kcontrol); + struct snd_trident_pcm_mixer *mix = &trident->pcm_mixer[snd_ctl_get_ioffnum(kcontrol, &ucontrol->id)]; unsigned short val; int change = 0; @@ -2844,7 +2891,7 @@ static int snd_trident_pcm_cvol_control_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_trident_pcm_cvol_control __devinitdata = +static struct snd_kcontrol_new snd_trident_pcm_cvol_control __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Chorus Playback Volume", @@ -2855,9 +2902,11 @@ static snd_kcontrol_new_t snd_trident_pcm_cvol_control __devinitdata = .put = snd_trident_pcm_cvol_control_put, }; -static void snd_trident_notify_pcm_change1(snd_card_t * card, snd_kcontrol_t *kctl, int num, int activate) +static void snd_trident_notify_pcm_change1(struct snd_card *card, + struct snd_kcontrol *kctl, + int num, int activate) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; if (! kctl) return; @@ -2870,7 +2919,9 @@ static void snd_trident_notify_pcm_change1(snd_card_t * card, snd_kcontrol_t *kc snd_ctl_build_ioff(&id, kctl, num)); } -static void snd_trident_notify_pcm_change(trident_t *trident, snd_trident_pcm_mixer_t *tmix, int num, int activate) +static void snd_trident_notify_pcm_change(struct snd_trident *trident, + struct snd_trident_pcm_mixer *tmix, + int num, int activate) { snd_trident_notify_pcm_change1(trident->card, trident->ctl_vol, num, activate); snd_trident_notify_pcm_change1(trident->card, trident->ctl_pan, num, activate); @@ -2878,9 +2929,11 @@ static void snd_trident_notify_pcm_change(trident_t *trident, snd_trident_pcm_mi snd_trident_notify_pcm_change1(trident->card, trident->ctl_cvol, num, activate); } -static int snd_trident_pcm_mixer_build(trident_t *trident, snd_trident_voice_t *voice, snd_pcm_substream_t *substream) +static int snd_trident_pcm_mixer_build(struct snd_trident *trident, + struct snd_trident_voice *voice, + struct snd_pcm_substream *substream) { - snd_trident_pcm_mixer_t *tmix; + struct snd_trident_pcm_mixer *tmix; snd_assert(trident != NULL && voice != NULL && substream != NULL, return -EINVAL); tmix = &trident->pcm_mixer[substream->number]; @@ -2893,9 +2946,9 @@ static int snd_trident_pcm_mixer_build(trident_t *trident, snd_trident_voice_t * return 0; } -static int snd_trident_pcm_mixer_free(trident_t *trident, snd_trident_voice_t *voice, snd_pcm_substream_t *substream) +static int snd_trident_pcm_mixer_free(struct snd_trident *trident, struct snd_trident_voice *voice, struct snd_pcm_substream *substream) { - snd_trident_pcm_mixer_t *tmix; + struct snd_trident_pcm_mixer *tmix; snd_assert(trident != NULL && substream != NULL, return -EINVAL); tmix = &trident->pcm_mixer[substream->number]; @@ -2915,14 +2968,14 @@ static int snd_trident_pcm_mixer_free(trident_t *trident, snd_trident_voice_t *v ---------------------------------------------------------------------------*/ -static int __devinit snd_trident_mixer(trident_t * trident, int pcm_spdif_device) +static int __devinit snd_trident_mixer(struct snd_trident * trident, int pcm_spdif_device) { - ac97_template_t _ac97; - snd_card_t * card = trident->card; - snd_kcontrol_t *kctl; - snd_ctl_elem_value_t *uctl; + struct snd_ac97_template _ac97; + struct snd_card *card = trident->card; + struct snd_kcontrol *kctl; + struct snd_ctl_elem_value *uctl; int idx, err, retries = 2; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_trident_codec_write, .read = snd_trident_codec_read, }; @@ -2959,7 +3012,7 @@ static int __devinit snd_trident_mixer(trident_t * trident, int pcm_spdif_device snd_printk(KERN_ERR "SI7018: the secondary codec - invalid access\n"); #if 0 // only for my testing purpose --jk { - ac97_t *mc97; + struct snd_ac97 *mc97; err = snd_ac97_modem(trident->card, &_ac97, &mc97); if (err < 0) snd_printk(KERN_ERR "snd_ac97_modem returned error %i\n", err); @@ -2982,7 +3035,7 @@ static int __devinit snd_trident_mixer(trident_t * trident, int pcm_spdif_device } for (idx = 0; idx < 32; idx++) { - snd_trident_pcm_mixer_t *tmix; + struct snd_trident_pcm_mixer *tmix; tmix = &trident->pcm_mixer[idx]; tmix->voice = NULL; @@ -3080,7 +3133,7 @@ static int __devinit snd_trident_mixer(trident_t * trident, int pcm_spdif_device static unsigned char snd_trident_gameport_read(struct gameport *gameport) { - trident_t *chip = gameport_get_port_data(gameport); + struct snd_trident *chip = gameport_get_port_data(gameport); snd_assert(chip, return 0); return inb(TRID_REG(chip, GAMEPORT_LEGACY)); @@ -3088,7 +3141,7 @@ static unsigned char snd_trident_gameport_read(struct gameport *gameport) static void snd_trident_gameport_trigger(struct gameport *gameport) { - trident_t *chip = gameport_get_port_data(gameport); + struct snd_trident *chip = gameport_get_port_data(gameport); snd_assert(chip, return); outb(0xff, TRID_REG(chip, GAMEPORT_LEGACY)); @@ -3096,7 +3149,7 @@ static void snd_trident_gameport_trigger(struct gameport *gameport) static int snd_trident_gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons) { - trident_t *chip = gameport_get_port_data(gameport); + struct snd_trident *chip = gameport_get_port_data(gameport); int i; snd_assert(chip, return 0); @@ -3113,7 +3166,7 @@ static int snd_trident_gameport_cooked_read(struct gameport *gameport, int *axes static int snd_trident_gameport_open(struct gameport *gameport, int mode) { - trident_t *chip = gameport_get_port_data(gameport); + struct snd_trident *chip = gameport_get_port_data(gameport); snd_assert(chip, return 0); @@ -3130,7 +3183,7 @@ static int snd_trident_gameport_open(struct gameport *gameport, int mode) } } -int __devinit snd_trident_create_gameport(trident_t *chip) +int __devinit snd_trident_create_gameport(struct snd_trident *chip) { struct gameport *gp; @@ -3156,7 +3209,7 @@ int __devinit snd_trident_create_gameport(trident_t *chip) return 0; } -static inline void snd_trident_free_gameport(trident_t *chip) +static inline void snd_trident_free_gameport(struct snd_trident *chip) { if (chip->gameport) { gameport_unregister_port(chip->gameport); @@ -3164,14 +3217,14 @@ static inline void snd_trident_free_gameport(trident_t *chip) } } #else -int __devinit snd_trident_create_gameport(trident_t *chip) { return -ENOSYS; } -static inline void snd_trident_free_gameport(trident_t *chip) { } +int __devinit snd_trident_create_gameport(struct snd_trident *chip) { return -ENOSYS; } +static inline void snd_trident_free_gameport(struct snd_trident *chip) { } #endif /* CONFIG_GAMEPORT */ /* * delay for 1 tick */ -static inline void do_delay(trident_t *chip) +static inline void do_delay(struct snd_trident *chip) { schedule_timeout_uninterruptible(1); } @@ -3180,7 +3233,7 @@ static inline void do_delay(trident_t *chip) * SiS reset routine */ -static int snd_trident_sis_reset(trident_t *trident) +static int snd_trident_sis_reset(struct snd_trident *trident) { unsigned long end_time; unsigned int i; @@ -3233,10 +3286,10 @@ static int snd_trident_sis_reset(trident_t *trident) * /proc interface */ -static void snd_trident_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_trident_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - trident_t *trident = entry->private_data; + struct snd_trident *trident = entry->private_data; char *s; switch (trident->device) { @@ -3274,9 +3327,9 @@ static void snd_trident_proc_read(snd_info_entry_t *entry, #endif } -static void __devinit snd_trident_proc_init(trident_t * trident) +static void __devinit snd_trident_proc_init(struct snd_trident * trident) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; const char *s = "trident"; if (trident->device == TRIDENT_DEVICE_ID_SI7018) @@ -3285,9 +3338,9 @@ static void __devinit snd_trident_proc_init(trident_t * trident) snd_info_set_text_ops(entry, trident, 1024, snd_trident_proc_read); } -static int snd_trident_dev_free(snd_device_t *device) +static int snd_trident_dev_free(struct snd_device *device) { - trident_t *trident = device->device_data; + struct snd_trident *trident = device->device_data; return snd_trident_free(trident); } @@ -3303,7 +3356,7 @@ static int snd_trident_dev_free(snd_device_t *device) ---------------------------------------------------------------------------*/ -static int __devinit snd_trident_tlb_alloc(trident_t *trident) +static int __devinit snd_trident_tlb_alloc(struct snd_trident *trident) { int i; @@ -3318,7 +3371,7 @@ static int __devinit snd_trident_tlb_alloc(trident_t *trident) trident->tlb.entries = (unsigned int*)(((unsigned long)trident->tlb.buffer.area + SNDRV_TRIDENT_MAX_PAGES * 4 - 1) & ~(SNDRV_TRIDENT_MAX_PAGES * 4 - 1)); trident->tlb.entries_dmaaddr = (trident->tlb.buffer.addr + SNDRV_TRIDENT_MAX_PAGES * 4 - 1) & ~(SNDRV_TRIDENT_MAX_PAGES * 4 - 1); /* allocate shadow TLB page table (virtual addresses) */ - trident->tlb.shadow_entries = (unsigned long *)vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); + trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); if (trident->tlb.shadow_entries == NULL) { snd_printk(KERN_ERR "trident: unable to allocate shadow TLB entries\n"); return -ENOMEM; @@ -3340,7 +3393,7 @@ static int __devinit snd_trident_tlb_alloc(trident_t *trident) if (trident->tlb.memhdr == NULL) return -ENOMEM; - trident->tlb.memhdr->block_extra_size = sizeof(snd_trident_memblk_arg_t); + trident->tlb.memhdr->block_extra_size = sizeof(struct snd_trident_memblk_arg); return 0; } @@ -3348,7 +3401,7 @@ static int __devinit snd_trident_tlb_alloc(trident_t *trident) * initialize 4D DX chip */ -static void snd_trident_stop_all_voices(trident_t *trident) +static void snd_trident_stop_all_voices(struct snd_trident *trident) { outl(0xffffffff, TRID_REG(trident, T4D_STOP_A)); outl(0xffffffff, TRID_REG(trident, T4D_STOP_B)); @@ -3356,7 +3409,7 @@ static void snd_trident_stop_all_voices(trident_t *trident) outl(0, TRID_REG(trident, T4D_AINTEN_B)); } -static int snd_trident_4d_dx_init(trident_t *trident) +static int snd_trident_4d_dx_init(struct snd_trident *trident) { struct pci_dev *pci = trident->pci; unsigned long end_time; @@ -3396,7 +3449,7 @@ static int snd_trident_4d_dx_init(trident_t *trident) /* * initialize 4D NX chip */ -static int snd_trident_4d_nx_init(trident_t *trident) +static int snd_trident_4d_nx_init(struct snd_trident *trident) { struct pci_dev *pci = trident->pci; unsigned long end_time; @@ -3453,7 +3506,7 @@ static int snd_trident_4d_nx_init(trident_t *trident) /* * initialize sis7018 chip */ -static int snd_trident_sis_init(trident_t *trident) +static int snd_trident_sis_init(struct snd_trident *trident) { int err; @@ -3484,18 +3537,18 @@ static int snd_trident_sis_init(trident_t *trident) ---------------------------------------------------------------------------*/ -int __devinit snd_trident_create(snd_card_t * card, +int __devinit snd_trident_create(struct snd_card *card, struct pci_dev *pci, int pcm_streams, int pcm_spdif_device, int max_wavetable_size, - trident_t ** rtrident) + struct snd_trident ** rtrident) { - trident_t *trident; + struct snd_trident *trident; int i, err; - snd_trident_voice_t *voice; - snd_trident_pcm_mixer_t *tmix; - static snd_device_ops_t ops = { + struct snd_trident_voice *voice; + struct snd_trident_pcm_mixer *tmix; + static struct snd_device_ops ops = { .dev_free = snd_trident_dev_free, }; @@ -3543,7 +3596,8 @@ int __devinit snd_trident_create(snd_card_t * card, } trident->port = pci_resource_start(pci, 0); - if (request_irq(pci->irq, snd_trident_interrupt, SA_INTERRUPT|SA_SHIRQ, "Trident Audio", (void *) trident)) { + if (request_irq(pci->irq, snd_trident_interrupt, SA_INTERRUPT|SA_SHIRQ, + "Trident Audio", trident)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_trident_free(trident); return -EBUSY; @@ -3627,7 +3681,7 @@ int __devinit snd_trident_create(snd_card_t * card, ---------------------------------------------------------------------------*/ -static int snd_trident_free(trident_t *trident) +static int snd_trident_free(struct snd_trident *trident) { snd_trident_free_gameport(trident); snd_trident_disable_eso(trident); @@ -3647,7 +3701,7 @@ static int snd_trident_free(trident_t *trident) snd_dma_free_pages(&trident->tlb.buffer); } if (trident->irq >= 0) - free_irq(trident->irq, (void *)trident); + free_irq(trident->irq, trident); pci_release_regions(trident->pci); pci_disable_device(trident->pci); kfree(trident); @@ -3674,10 +3728,10 @@ static int snd_trident_free(trident_t *trident) static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - trident_t *trident = dev_id; + struct snd_trident *trident = dev_id; unsigned int audio_int, chn_int, stimer, channel, mask, tmp; int delta; - snd_trident_voice_t *voice; + struct snd_trident_voice *voice; audio_int = inl(TRID_REG(trident, T4D_MISCINT)); if ((audio_int & (ADDRESS_IRQ|MPU401_IRQ)) == 0) @@ -3779,21 +3833,21 @@ static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs * Returns: None. ---------------------------------------------------------------------------*/ -int snd_trident_attach_synthesizer(trident_t *trident) +int snd_trident_attach_synthesizer(struct snd_trident *trident) { #if defined(CONFIG_SND_SEQUENCER) || (defined(MODULE) && defined(CONFIG_SND_SEQUENCER_MODULE)) if (snd_seq_device_new(trident->card, 1, SNDRV_SEQ_DEV_ID_TRIDENT, - sizeof(trident_t*), &trident->seq_dev) >= 0) { + sizeof(struct snd_trident *), &trident->seq_dev) >= 0) { strcpy(trident->seq_dev->name, "4DWave"); - *(trident_t**)SNDRV_SEQ_DEVICE_ARGPTR(trident->seq_dev) = trident; + *(struct snd_trident **)SNDRV_SEQ_DEVICE_ARGPTR(trident->seq_dev) = trident; } #endif return 0; } -snd_trident_voice_t *snd_trident_alloc_voice(trident_t * trident, int type, int client, int port) +struct snd_trident_voice *snd_trident_alloc_voice(struct snd_trident * trident, int type, int client, int port) { - snd_trident_voice_t *pvoice; + struct snd_trident_voice *pvoice; unsigned long flags; int idx; @@ -3835,10 +3889,10 @@ snd_trident_voice_t *snd_trident_alloc_voice(trident_t * trident, int type, int return NULL; } -void snd_trident_free_voice(trident_t * trident, snd_trident_voice_t *voice) +void snd_trident_free_voice(struct snd_trident * trident, struct snd_trident_voice *voice) { unsigned long flags; - void (*private_free)(snd_trident_voice_t *); + void (*private_free)(struct snd_trident_voice *); void *private_data; if (voice == NULL || !voice->use) @@ -3863,7 +3917,7 @@ void snd_trident_free_voice(trident_t * trident, snd_trident_voice_t *voice) private_free(voice); } -static void snd_trident_clear_voices(trident_t * trident, unsigned short v_min, unsigned short v_max) +static void snd_trident_clear_voices(struct snd_trident * trident, unsigned short v_min, unsigned short v_max) { unsigned int i, val, mask[2] = { 0, 0 }; @@ -3884,9 +3938,9 @@ static void snd_trident_clear_voices(trident_t * trident, unsigned short v_min, } #ifdef CONFIG_PM -static int snd_trident_suspend(snd_card_t *card, pm_message_t state) +static int snd_trident_suspend(struct snd_card *card, pm_message_t state) { - trident_t *trident = card->pm_private_data; + struct snd_trident *trident = card->pm_private_data; trident->in_suspend = 1; snd_pcm_suspend_all(trident->pcm); @@ -3910,9 +3964,9 @@ static int snd_trident_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_trident_resume(snd_card_t *card) +static int snd_trident_resume(struct snd_card *card) { - trident_t *trident = card->pm_private_data; + struct snd_trident *trident = card->pm_private_data; pci_enable_device(trident->pci); if (pci_set_dma_mask(trident->pci, 0x3fffffff) < 0 || diff --git a/sound/pci/trident/trident_memory.c b/sound/pci/trident/trident_memory.c index f3e6c54..cf09ea9 100644 --- a/sound/pci/trident/trident_memory.c +++ b/sound/pci/trident/trident_memory.c @@ -68,13 +68,14 @@ #define page_to_addr(trident,page) __tlb_to_addr(trident, (page) << 1) /* fill TLB entries -- we need to fill two entries */ -static inline void set_tlb_bus(trident_t *trident, int page, unsigned long ptr, dma_addr_t addr) +static inline void set_tlb_bus(struct snd_trident *trident, int page, + unsigned long ptr, dma_addr_t addr) { page <<= 1; __set_tlb_bus(trident, page, ptr, addr); __set_tlb_bus(trident, page+1, ptr + SNDRV_TRIDENT_PAGE_SIZE, addr + SNDRV_TRIDENT_PAGE_SIZE); } -static inline void set_silent_tlb(trident_t *trident, int page) +static inline void set_silent_tlb(struct snd_trident *trident, int page) { page <<= 1; __set_tlb_bus(trident, page, (unsigned long)trident->tlb.silent_page.area, trident->tlb.silent_page.addr); @@ -97,7 +98,8 @@ static inline void set_silent_tlb(trident_t *trident, int page) #define page_to_addr(trident,page) __tlb_to_addr(trident, (page) * UNIT_PAGES) /* fill TLB entries -- UNIT_PAGES entries must be filled */ -static inline void set_tlb_bus(trident_t *trident, int page, unsigned long ptr, dma_addr_t addr) +static inline void set_tlb_bus(struct snd_trident *trident, int page, + unsigned long ptr, dma_addr_t addr) { int i; page *= UNIT_PAGES; @@ -107,7 +109,7 @@ static inline void set_tlb_bus(trident_t *trident, int page, unsigned long ptr, addr += SNDRV_TRIDENT_PAGE_SIZE; } } -static inline void set_silent_tlb(trident_t *trident, int page) +static inline void set_silent_tlb(struct snd_trident *trident, int page) { int i; page *= UNIT_PAGES; @@ -118,7 +120,7 @@ static inline void set_silent_tlb(trident_t *trident, int page) #endif /* PAGE_SIZE */ /* calculate buffer pointer from offset address */ -static inline void *offset_ptr(trident_t *trident, int offset) +static inline void *offset_ptr(struct snd_trident *trident, int offset) { char *ptr; ptr = page_to_ptr(trident, get_aligned_page(offset)); @@ -127,16 +129,16 @@ static inline void *offset_ptr(trident_t *trident, int offset) } /* first and last (aligned) pages of memory block */ -#define firstpg(blk) (((snd_trident_memblk_arg_t*)snd_util_memblk_argptr(blk))->first_page) -#define lastpg(blk) (((snd_trident_memblk_arg_t*)snd_util_memblk_argptr(blk))->last_page) +#define firstpg(blk) (((struct snd_trident_memblk_arg *)snd_util_memblk_argptr(blk))->first_page) +#define lastpg(blk) (((struct snd_trident_memblk_arg *)snd_util_memblk_argptr(blk))->last_page) /* * search empty pages which may contain given size */ -static snd_util_memblk_t * -search_empty(snd_util_memhdr_t *hdr, int size) +static struct snd_util_memblk * +search_empty(struct snd_util_memhdr *hdr, int size) { - snd_util_memblk_t *blk, *prev; + struct snd_util_memblk *blk, *prev; int page, psize; struct list_head *p; @@ -144,7 +146,7 @@ search_empty(snd_util_memhdr_t *hdr, int size) prev = NULL; page = 0; list_for_each(p, &hdr->block) { - blk = list_entry(p, snd_util_memblk_t, list); + blk = list_entry(p, struct snd_util_memblk, list); if (page + psize <= firstpg(blk)) goto __found_pages; page = lastpg(blk) + 1; @@ -183,12 +185,13 @@ static int is_valid_page(unsigned long ptr) /* * page allocation for DMA (Scatter-Gather version) */ -static snd_util_memblk_t * -snd_trident_alloc_sg_pages(trident_t *trident, snd_pcm_substream_t *substream) +static struct snd_util_memblk * +snd_trident_alloc_sg_pages(struct snd_trident *trident, + struct snd_pcm_substream *substream) { - snd_util_memhdr_t *hdr; - snd_util_memblk_t *blk; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_util_memhdr *hdr; + struct snd_util_memblk *blk; + struct snd_pcm_runtime *runtime = substream->runtime; int idx, page; struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); @@ -230,13 +233,14 @@ snd_trident_alloc_sg_pages(trident_t *trident, snd_pcm_substream_t *substream) /* * page allocation for DMA (contiguous version) */ -static snd_util_memblk_t * -snd_trident_alloc_cont_pages(trident_t *trident, snd_pcm_substream_t *substream) +static struct snd_util_memblk * +snd_trident_alloc_cont_pages(struct snd_trident *trident, + struct snd_pcm_substream *substream) { - snd_util_memhdr_t *hdr; - snd_util_memblk_t *blk; + struct snd_util_memhdr *hdr; + struct snd_util_memblk *blk; int page; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; dma_addr_t addr; unsigned long ptr; @@ -270,8 +274,9 @@ snd_trident_alloc_cont_pages(trident_t *trident, snd_pcm_substream_t *substream) /* * page allocation for DMA */ -snd_util_memblk_t * -snd_trident_alloc_pages(trident_t *trident, snd_pcm_substream_t *substream) +struct snd_util_memblk * +snd_trident_alloc_pages(struct snd_trident *trident, + struct snd_pcm_substream *substream) { snd_assert(trident != NULL, return NULL); snd_assert(substream != NULL, return NULL); @@ -285,9 +290,10 @@ snd_trident_alloc_pages(trident_t *trident, snd_pcm_substream_t *substream) /* * release DMA buffer from page table */ -int snd_trident_free_pages(trident_t *trident, snd_util_memblk_t *blk) +int snd_trident_free_pages(struct snd_trident *trident, + struct snd_util_memblk *blk) { - snd_util_memhdr_t *hdr; + struct snd_util_memhdr *hdr; int page; snd_assert(trident != NULL, return -EINVAL); @@ -314,17 +320,17 @@ int snd_trident_free_pages(trident_t *trident, snd_util_memblk_t *blk) /* */ -static int synth_alloc_pages(trident_t *hw, snd_util_memblk_t *blk); -static int synth_free_pages(trident_t *hw, snd_util_memblk_t *blk); +static int synth_alloc_pages(struct snd_trident *hw, struct snd_util_memblk *blk); +static int synth_free_pages(struct snd_trident *hw, struct snd_util_memblk *blk); /* * allocate a synth sample area */ -snd_util_memblk_t * -snd_trident_synth_alloc(trident_t *hw, unsigned int size) +struct snd_util_memblk * +snd_trident_synth_alloc(struct snd_trident *hw, unsigned int size) { - snd_util_memblk_t *blk; - snd_util_memhdr_t *hdr = hw->tlb.memhdr; + struct snd_util_memblk *blk; + struct snd_util_memhdr *hdr = hw->tlb.memhdr; down(&hdr->block_mutex); blk = __snd_util_mem_alloc(hdr, size); @@ -346,9 +352,9 @@ snd_trident_synth_alloc(trident_t *hw, unsigned int size) * free a synth sample area */ int -snd_trident_synth_free(trident_t *hw, snd_util_memblk_t *blk) +snd_trident_synth_free(struct snd_trident *hw, struct snd_util_memblk *blk) { - snd_util_memhdr_t *hdr = hw->tlb.memhdr; + struct snd_util_memhdr *hdr = hw->tlb.memhdr; down(&hdr->block_mutex); synth_free_pages(hw, blk); @@ -361,7 +367,7 @@ snd_trident_synth_free(trident_t *hw, snd_util_memblk_t *blk) /* * reset TLB entry and free kernel page */ -static void clear_tlb(trident_t *trident, int page) +static void clear_tlb(struct snd_trident *trident, int page) { void *ptr = page_to_ptr(trident, page); dma_addr_t addr = page_to_addr(trident, page); @@ -378,20 +384,22 @@ static void clear_tlb(trident_t *trident, int page) } /* check new allocation range */ -static void get_single_page_range(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk, int *first_page_ret, int *last_page_ret) +static void get_single_page_range(struct snd_util_memhdr *hdr, + struct snd_util_memblk *blk, + int *first_page_ret, int *last_page_ret) { struct list_head *p; - snd_util_memblk_t *q; + struct snd_util_memblk *q; int first_page, last_page; first_page = firstpg(blk); if ((p = blk->list.prev) != &hdr->block) { - q = list_entry(p, snd_util_memblk_t, list); + q = list_entry(p, struct snd_util_memblk, list); if (lastpg(q) == first_page) first_page++; /* first page was already allocated */ } last_page = lastpg(blk); if ((p = blk->list.next) != &hdr->block) { - q = list_entry(p, snd_util_memblk_t, list); + q = list_entry(p, struct snd_util_memblk, list); if (firstpg(q) == last_page) last_page--; /* last page was already allocated */ } @@ -402,7 +410,7 @@ static void get_single_page_range(snd_util_memhdr_t *hdr, snd_util_memblk_t *blk /* * allocate kernel pages and assign them to TLB */ -static int synth_alloc_pages(trident_t *hw, snd_util_memblk_t *blk) +static int synth_alloc_pages(struct snd_trident *hw, struct snd_util_memblk *blk) { int page, first_page, last_page; struct snd_dma_buffer dmab; @@ -438,7 +446,7 @@ __fail: /* * free pages */ -static int synth_free_pages(trident_t *trident, snd_util_memblk_t *blk) +static int synth_free_pages(struct snd_trident *trident, struct snd_util_memblk *blk) { int page, first_page, last_page; @@ -452,7 +460,9 @@ static int synth_free_pages(trident_t *trident, snd_util_memblk_t *blk) /* * copy_from_user(blk + offset, data, size) */ -int snd_trident_synth_copy_from_user(trident_t *trident, snd_util_memblk_t *blk, int offset, const char __user *data, int size) +int snd_trident_synth_copy_from_user(struct snd_trident *trident, + struct snd_util_memblk *blk, + int offset, const char __user *data, int size) { int page, nextofs, end_offset, temp, temp1; diff --git a/sound/pci/trident/trident_synth.c b/sound/pci/trident/trident_synth.c index 5d5a719..a49682e 100644 --- a/sound/pci/trident/trident_synth.c +++ b/sound/pci/trident/trident_synth.c @@ -192,15 +192,15 @@ static unsigned short log_from_linear( unsigned short value ) * Sample handling operations */ -static void sample_start(trident_t * trident, snd_trident_voice_t * voice, snd_seq_position_t position); -static void sample_stop(trident_t * trident, snd_trident_voice_t * voice, snd_seq_stop_mode_t mode); -static void sample_freq(trident_t * trident, snd_trident_voice_t * voice, snd_seq_frequency_t freq); -static void sample_volume(trident_t * trident, snd_trident_voice_t * voice, snd_seq_ev_volume_t * volume); -static void sample_loop(trident_t * trident, snd_trident_voice_t * voice, snd_seq_ev_loop_t * loop); -static void sample_pos(trident_t * trident, snd_trident_voice_t * voice, snd_seq_position_t position); -static void sample_private1(trident_t * trident, snd_trident_voice_t * voice, unsigned char *data); - -static snd_trident_sample_ops_t sample_ops = +static void sample_start(struct snd_trident * trident, struct snd_trident_voice * voice, snd_seq_position_t position); +static void sample_stop(struct snd_trident * trident, struct snd_trident_voice * voice, int mode); +static void sample_freq(struct snd_trident * trident, struct snd_trident_voice * voice, snd_seq_frequency_t freq); +static void sample_volume(struct snd_trident * trident, struct snd_trident_voice * voice, struct snd_seq_ev_volume * volume); +static void sample_loop(struct snd_trident * trident, struct snd_trident_voice * voice, struct snd_seq_ev_loop * loop); +static void sample_pos(struct snd_trident * trident, struct snd_trident_voice * voice, snd_seq_position_t position); +static void sample_private1(struct snd_trident * trident, struct snd_trident_voice * voice, unsigned char *data); + +static struct snd_trident_sample_ops sample_ops = { sample_start, sample_stop, @@ -211,7 +211,7 @@ static snd_trident_sample_ops_t sample_ops = sample_private1 }; -static void snd_trident_simple_init(snd_trident_voice_t * voice) +static void snd_trident_simple_init(struct snd_trident_voice * voice) { //voice->handler_wave = interrupt_wave; //voice->handler_volume = interrupt_volume; @@ -220,10 +220,10 @@ static void snd_trident_simple_init(snd_trident_voice_t * voice) voice->sample_ops = &sample_ops; } -static void sample_start(trident_t * trident, snd_trident_voice_t * voice, snd_seq_position_t position) +static void sample_start(struct snd_trident * trident, struct snd_trident_voice * voice, snd_seq_position_t position) { - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; unsigned long flags; unsigned int loop_start, loop_end, sample_start, sample_end, start_offset; unsigned int value; @@ -305,7 +305,7 @@ static void sample_start(trident_t * trident, snd_trident_voice_t * voice, snd_s snd_seq_instr_free_use(trident->synth.ilist, instr); } -static void sample_stop(trident_t * trident, snd_trident_voice_t * voice, snd_seq_stop_mode_t mode) +static void sample_stop(struct snd_trident * trident, struct snd_trident_voice * voice, int mode) { unsigned long flags; @@ -329,7 +329,7 @@ static void sample_stop(trident_t * trident, snd_trident_voice_t * voice, snd_se } } -static void sample_freq(trident_t * trident, snd_trident_voice_t * voice, snd_seq_frequency_t freq) +static void sample_freq(struct snd_trident * trident, struct snd_trident_voice * voice, snd_seq_frequency_t freq) { unsigned long flags; freq >>= 4; @@ -355,7 +355,7 @@ static void sample_freq(trident_t * trident, snd_trident_voice_t * voice, snd_se spin_unlock_irqrestore(&trident->reg_lock, flags); } -static void sample_volume(trident_t * trident, snd_trident_voice_t * voice, snd_seq_ev_volume_t * volume) +static void sample_volume(struct snd_trident * trident, struct snd_trident_voice * voice, struct snd_seq_ev_volume * volume) { unsigned long flags; unsigned short value; @@ -407,11 +407,11 @@ static void sample_volume(trident_t * trident, snd_trident_voice_t * voice, snd_ spin_unlock_irqrestore(&trident->reg_lock, flags); } -static void sample_loop(trident_t * trident, snd_trident_voice_t * voice, snd_seq_ev_loop_t * loop) +static void sample_loop(struct snd_trident * trident, struct snd_trident_voice * voice, struct snd_seq_ev_loop * loop) { unsigned long flags; - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; unsigned int loop_start, loop_end; instr = snd_seq_instr_find(trident->synth.ilist, &voice->instr, 0, 1); @@ -446,11 +446,11 @@ static void sample_loop(trident_t * trident, snd_trident_voice_t * voice, snd_se snd_seq_instr_free_use(trident->synth.ilist, instr); } -static void sample_pos(trident_t * trident, snd_trident_voice_t * voice, snd_seq_position_t position) +static void sample_pos(struct snd_trident * trident, struct snd_trident_voice * voice, snd_seq_position_t position) { unsigned long flags; - simple_instrument_t *simple; - snd_seq_kinstr_t *instr; + struct simple_instrument *simple; + struct snd_seq_kinstr *instr; unsigned int value; instr = snd_seq_instr_find(trident->synth.ilist, &voice->instr, 0, 1); @@ -496,7 +496,7 @@ static void sample_pos(trident_t * trident, snd_trident_voice_t * voice, snd_seq snd_seq_instr_free_use(trident->synth.ilist, instr); } -static void sample_private1(trident_t * trident, snd_trident_voice_t * voice, unsigned char *data) +static void sample_private1(struct snd_trident * trident, struct snd_trident_voice * voice, unsigned char *data) { } @@ -504,10 +504,11 @@ static void sample_private1(trident_t * trident, snd_trident_voice_t * voice, un * Memory management / sample loading */ -static int snd_trident_simple_put_sample(void *private_data, simple_instrument_t * instr, +static int snd_trident_simple_put_sample(void *private_data, + struct simple_instrument * instr, char __user *data, long len, int atomic) { - trident_t *trident = private_data; + struct snd_trident *trident = private_data; int size = instr->size; int shift = 0; @@ -529,7 +530,7 @@ static int snd_trident_simple_put_sample(void *private_data, simple_instrument_t return -EFAULT; if (trident->tlb.entries) { - snd_util_memblk_t *memblk; + struct snd_util_memblk *memblk; memblk = snd_trident_synth_alloc(trident, size); if (memblk == NULL) return -ENOMEM; @@ -557,10 +558,11 @@ static int snd_trident_simple_put_sample(void *private_data, simple_instrument_t return 0; } -static int snd_trident_simple_get_sample(void *private_data, simple_instrument_t * instr, +static int snd_trident_simple_get_sample(void *private_data, + struct simple_instrument * instr, char __user *data, long len, int atomic) { - //trident_t *trident = private_data; + //struct snd_trident *trident = private_data; int size = instr->size; int shift = 0; @@ -578,10 +580,11 @@ static int snd_trident_simple_get_sample(void *private_data, simple_instrument_t return -EBUSY; } -static int snd_trident_simple_remove_sample(void *private_data, simple_instrument_t * instr, +static int snd_trident_simple_remove_sample(void *private_data, + struct simple_instrument * instr, int atomic) { - trident_t *trident = private_data; + struct snd_trident *trident = private_data; int size = instr->size; if (instr->format & SIMPLE_WAVE_16BIT) @@ -590,7 +593,7 @@ static int snd_trident_simple_remove_sample(void *private_data, simple_instrumen size <<= 1; if (trident->tlb.entries) { - snd_util_memblk_t *memblk = (snd_util_memblk_t*)instr->address.ptr; + struct snd_util_memblk *memblk = (struct snd_util_memblk *)instr->address.ptr; if (memblk) snd_trident_synth_free(trident, memblk); else @@ -612,9 +615,9 @@ static int snd_trident_simple_remove_sample(void *private_data, simple_instrumen return 0; } -static void select_instrument(trident_t * trident, snd_trident_voice_t * v) +static void select_instrument(struct snd_trident * trident, struct snd_trident_voice * v) { - snd_seq_kinstr_t *instr; + struct snd_seq_kinstr *instr; instr = snd_seq_instr_find(trident->synth.ilist, &v->instr, 0, 1); if (instr != NULL) { if (instr->ops) { @@ -629,7 +632,7 @@ static void select_instrument(trident_t * trident, snd_trident_voice_t * v) */ -static void event_sample(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_sample(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->trident, v, SAMPLE_STOP_IMMEDIATELY); @@ -643,7 +646,7 @@ static void event_sample(snd_seq_event_t * ev, snd_trident_port_t * p, snd_tride select_instrument(p->trident, v); } -static void event_cluster(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_cluster(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->trident, v, SAMPLE_STOP_IMMEDIATELY); @@ -651,49 +654,49 @@ static void event_cluster(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trid select_instrument(p->trident, v); } -static void event_start(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_start(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_start) v->sample_ops->sample_start(p->trident, v, ev->data.sample.param.position); } -static void event_stop(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_stop(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_stop) v->sample_ops->sample_stop(p->trident, v, ev->data.sample.param.stop_mode); } -static void event_freq(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_freq(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_freq) v->sample_ops->sample_freq(p->trident, v, ev->data.sample.param.frequency); } -static void event_volume(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_volume(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_volume) v->sample_ops->sample_volume(p->trident, v, &ev->data.sample.param.volume); } -static void event_loop(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_loop(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_loop) v->sample_ops->sample_loop(p->trident, v, &ev->data.sample.param.loop); } -static void event_position(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_position(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_pos) v->sample_ops->sample_pos(p->trident, v, ev->data.sample.param.position); } -static void event_private1(snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v) +static void event_private1(struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v) { if (v->sample_ops && v->sample_ops->sample_private1) v->sample_ops->sample_private1(p->trident, v, (unsigned char *) &ev->data.sample.param.raw8); } -typedef void (trident_sample_event_handler_t) (snd_seq_event_t * ev, snd_trident_port_t * p, snd_trident_voice_t * v); +typedef void (trident_sample_event_handler_t) (struct snd_seq_event * ev, struct snd_trident_port * p, struct snd_trident_voice * v); static trident_sample_event_handler_t *trident_sample_event_handlers[9] = { @@ -708,11 +711,11 @@ static trident_sample_event_handler_t *trident_sample_event_handlers[9] = event_private1 }; -static void snd_trident_sample_event(snd_seq_event_t * ev, snd_trident_port_t * p) +static void snd_trident_sample_event(struct snd_seq_event * ev, struct snd_trident_port * p) { int idx, voice; - trident_t *trident = p->trident; - snd_trident_voice_t *v; + struct snd_trident *trident = p->trident; + struct snd_trident_voice *v; unsigned long flags; idx = ev->type - SNDRV_SEQ_EVENT_SAMPLE; @@ -735,10 +738,10 @@ static void snd_trident_sample_event(snd_seq_event_t * ev, snd_trident_port_t * */ -static void snd_trident_synth_free_voices(trident_t * trident, int client, int port) +static void snd_trident_synth_free_voices(struct snd_trident * trident, int client, int port) { int idx; - snd_trident_voice_t *voice; + struct snd_trident_voice *voice; for (idx = 0; idx < 32; idx++) { voice = &trident->synth.voices[idx]; @@ -747,11 +750,11 @@ static void snd_trident_synth_free_voices(trident_t * trident, int client, int p } } -static int snd_trident_synth_use(void *private_data, snd_seq_port_subscribe_t * info) +static int snd_trident_synth_use(void *private_data, struct snd_seq_port_subscribe * info) { - snd_trident_port_t *port = (snd_trident_port_t *) private_data; - trident_t *trident = port->trident; - snd_trident_voice_t *voice; + struct snd_trident_port *port = private_data; + struct snd_trident *trident = port->trident; + struct snd_trident_voice *voice; unsigned int idx; unsigned long flags; @@ -786,10 +789,10 @@ static int snd_trident_synth_use(void *private_data, snd_seq_port_subscribe_t * return 0; } -static int snd_trident_synth_unuse(void *private_data, snd_seq_port_subscribe_t * info) +static int snd_trident_synth_unuse(void *private_data, struct snd_seq_port_subscribe * info) { - snd_trident_port_t *port = (snd_trident_port_t *) private_data; - trident_t *trident = port->trident; + struct snd_trident_port *port = private_data; + struct snd_trident *trident = port->trident; unsigned long flags; spin_lock_irqsave(&trident->reg_lock, flags); @@ -802,18 +805,18 @@ static int snd_trident_synth_unuse(void *private_data, snd_seq_port_subscribe_t */ -static void snd_trident_synth_free_private_instruments(snd_trident_port_t * p, int client) +static void snd_trident_synth_free_private_instruments(struct snd_trident_port * p, int client) { - snd_seq_instr_header_t ifree; + struct snd_seq_instr_header ifree; memset(&ifree, 0, sizeof(ifree)); ifree.cmd = SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE; snd_seq_instr_list_free_cond(p->trident->synth.ilist, &ifree, client, 0); } -static int snd_trident_synth_event_input(snd_seq_event_t * ev, int direct, void *private_data, int atomic, int hop) +static int snd_trident_synth_event_input(struct snd_seq_event * ev, int direct, void *private_data, int atomic, int hop) { - snd_trident_port_t *p = (snd_trident_port_t *) private_data; + struct snd_trident_port *p = (struct snd_trident_port *) private_data; if (p == NULL) return -EINVAL; @@ -841,12 +844,12 @@ static int snd_trident_synth_event_input(snd_seq_event_t * ev, int direct, void } static void snd_trident_synth_instr_notify(void *private_data, - snd_seq_kinstr_t * instr, + struct snd_seq_kinstr * instr, int what) { int idx; - trident_t *trident = private_data; - snd_trident_voice_t *pvoice; + struct snd_trident *trident = private_data; + struct snd_trident_voice *pvoice; unsigned long flags; spin_lock_irqsave(&trident->event_lock, flags); @@ -870,16 +873,16 @@ static void snd_trident_synth_instr_notify(void *private_data, static void snd_trident_synth_free_port(void *private_data) { - snd_trident_port_t *p = (snd_trident_port_t *) private_data; + struct snd_trident_port *p = (struct snd_trident_port *) private_data; if (p) snd_midi_channel_free_set(p->chset); } -static int snd_trident_synth_create_port(trident_t * trident, int idx) +static int snd_trident_synth_create_port(struct snd_trident * trident, int idx) { - snd_trident_port_t *p; - snd_seq_port_callback_t callbacks; + struct snd_trident_port *p; + struct snd_seq_port_callback callbacks; char name[32]; char *str; int result; @@ -927,17 +930,17 @@ static int snd_trident_synth_create_port(trident_t * trident, int idx) */ -static int snd_trident_synth_new_device(snd_seq_device_t *dev) +static int snd_trident_synth_new_device(struct snd_seq_device *dev) { - trident_t *trident; + struct snd_trident *trident; int client, i; - snd_seq_client_callback_t callbacks; - snd_seq_client_info_t cinfo; - snd_seq_port_subscribe_t sub; - snd_simple_ops_t *simpleops; + struct snd_seq_client_callback callbacks; + struct snd_seq_client_info cinfo; + struct snd_seq_port_subscribe sub; + struct snd_simple_ops *simpleops; char *str; - trident = *(trident_t **)SNDRV_SEQ_DEVICE_ARGPTR(dev); + trident = *(struct snd_trident **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (trident == NULL) return -EINVAL; @@ -993,11 +996,11 @@ static int snd_trident_synth_new_device(snd_seq_device_t *dev) return 0; } -static int snd_trident_synth_delete_device(snd_seq_device_t *dev) +static int snd_trident_synth_delete_device(struct snd_seq_device *dev) { - trident_t *trident; + struct snd_trident *trident; - trident = *(trident_t **)SNDRV_SEQ_DEVICE_ARGPTR(dev); + trident = *(struct snd_trident **)SNDRV_SEQ_DEVICE_ARGPTR(dev); if (trident == NULL) return -EINVAL; @@ -1012,14 +1015,14 @@ static int snd_trident_synth_delete_device(snd_seq_device_t *dev) static int __init alsa_trident_synth_init(void) { - static snd_seq_dev_ops_t ops = + static struct snd_seq_dev_ops ops = { snd_trident_synth_new_device, snd_trident_synth_delete_device }; return snd_seq_device_register_driver(SNDRV_SEQ_DEV_ID_TRIDENT, &ops, - sizeof(trident_t*)); + sizeof(struct snd_trident *)); } static void __exit alsa_trident_synth_exit(void) -- cgit v1.1 From 208a1b4cb5ad97510aa9cbe51d09e55656691cb4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:53:41 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI YMFPCI Modules: YMFPCI driver Remove xxx_t typedefs from the PCI YMFPCI driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- include/sound/ymfpci.h | 109 +++++----- sound/pci/ymfpci/ymfpci.c | 14 +- sound/pci/ymfpci/ymfpci_main.c | 470 +++++++++++++++++++++-------------------- 3 files changed, 298 insertions(+), 295 deletions(-) diff --git a/include/sound/ymfpci.h b/include/sound/ymfpci.h index c3bccbfd..ec790a9 100644 --- a/include/sound/ymfpci.h +++ b/include/sound/ymfpci.h @@ -184,7 +184,7 @@ * */ -typedef struct _snd_ymfpci_playback_bank { +struct snd_ymfpci_playback_bank { u32 format; u32 loop_default; u32 base; /* 32-bit address */ @@ -215,46 +215,45 @@ typedef struct _snd_ymfpci_playback_bank { u32 eff3_gain; u32 lpfD1; u32 lpfD2; -} snd_ymfpci_playback_bank_t; + }; -typedef struct _snd_ymfpci_capture_bank { +struct snd_ymfpci_capture_bank { u32 base; /* 32-bit address */ u32 loop_end; /* 32-bit offset */ u32 start; /* 32-bit offset */ u32 num_of_loops; /* counter */ -} snd_ymfpci_capture_bank_t; +}; -typedef struct _snd_ymfpci_effect_bank { +struct snd_ymfpci_effect_bank { u32 base; /* 32-bit address */ u32 loop_end; /* 32-bit offset */ u32 start; /* 32-bit offset */ u32 temp; -} snd_ymfpci_effect_bank_t; +}; -typedef struct _snd_ymfpci_voice ymfpci_voice_t; -typedef struct _snd_ymfpci_pcm ymfpci_pcm_t; -typedef struct _snd_ymfpci ymfpci_t; +struct snd_ymfpci_pcm; +struct snd_ymfpci; -typedef enum { +enum snd_ymfpci_voice_type { YMFPCI_PCM, YMFPCI_SYNTH, YMFPCI_MIDI -} ymfpci_voice_type_t; +}; -struct _snd_ymfpci_voice { - ymfpci_t *chip; +struct snd_ymfpci_voice { + struct snd_ymfpci *chip; int number; unsigned int use: 1, pcm: 1, synth: 1, midi: 1; - snd_ymfpci_playback_bank_t *bank; + struct snd_ymfpci_playback_bank *bank; dma_addr_t bank_addr; - void (*interrupt)(ymfpci_t *chip, ymfpci_voice_t *voice); - ymfpci_pcm_t *ypcm; + void (*interrupt)(struct snd_ymfpci *chip, struct snd_ymfpci_voice *voice); + struct snd_ymfpci_pcm *ypcm; }; -typedef enum { +enum snd_ymfpci_pcm_type { PLAYBACK_VOICE, CAPTURE_REC, CAPTURE_AC97, @@ -263,13 +262,13 @@ typedef enum { EFFECT_EFF1, EFFECT_EFF2, EFFECT_EFF3 -} snd_ymfpci_pcm_type_t; +}; -struct _snd_ymfpci_pcm { - ymfpci_t *chip; - snd_ymfpci_pcm_type_t type; - snd_pcm_substream_t *substream; - ymfpci_voice_t *voices[2]; /* playback only */ +struct snd_ymfpci_pcm { + struct snd_ymfpci *chip; + enum snd_ymfpci_pcm_type type; + struct snd_pcm_substream *substream; + struct snd_ymfpci_voice *voices[2]; /* playback only */ unsigned int running: 1; unsigned int output_front: 1; unsigned int output_rear: 1; @@ -282,7 +281,7 @@ struct _snd_ymfpci_pcm { u32 shift; }; -struct _snd_ymfpci { +struct snd_ymfpci { int irq; unsigned int device_id; /* PCI device ID */ @@ -316,47 +315,47 @@ struct _snd_ymfpci { struct snd_dma_buffer ac3_tmp_base; u32 *ctrl_playback; - snd_ymfpci_playback_bank_t *bank_playback[YDSXG_PLAYBACK_VOICES][2]; - snd_ymfpci_capture_bank_t *bank_capture[YDSXG_CAPTURE_VOICES][2]; - snd_ymfpci_effect_bank_t *bank_effect[YDSXG_EFFECT_VOICES][2]; + struct snd_ymfpci_playback_bank *bank_playback[YDSXG_PLAYBACK_VOICES][2]; + struct snd_ymfpci_capture_bank *bank_capture[YDSXG_CAPTURE_VOICES][2]; + struct snd_ymfpci_effect_bank *bank_effect[YDSXG_EFFECT_VOICES][2]; int start_count; u32 active_bank; - ymfpci_voice_t voices[64]; + struct snd_ymfpci_voice voices[64]; - ac97_bus_t *ac97_bus; - ac97_t *ac97; - snd_rawmidi_t *rawmidi; - snd_timer_t *timer; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97; + struct snd_rawmidi *rawmidi; + struct snd_timer *timer; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_t *pcm2; - snd_pcm_t *pcm_spdif; - snd_pcm_t *pcm_4ch; - snd_pcm_substream_t *capture_substream[YDSXG_CAPTURE_VOICES]; - snd_pcm_substream_t *effect_substream[YDSXG_EFFECT_VOICES]; - snd_kcontrol_t *ctl_vol_recsrc; - snd_kcontrol_t *ctl_vol_adcrec; - snd_kcontrol_t *ctl_vol_spdifrec; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm *pcm2; + struct snd_pcm *pcm_spdif; + struct snd_pcm *pcm_4ch; + struct snd_pcm_substream *capture_substream[YDSXG_CAPTURE_VOICES]; + struct snd_pcm_substream *effect_substream[YDSXG_EFFECT_VOICES]; + struct snd_kcontrol *ctl_vol_recsrc; + struct snd_kcontrol *ctl_vol_adcrec; + struct snd_kcontrol *ctl_vol_spdifrec; unsigned short spdif_bits, spdif_pcm_bits; - snd_kcontrol_t *spdif_pcm_ctl; + struct snd_kcontrol *spdif_pcm_ctl; int mode_dup4ch; int rear_opened; int spdif_opened; struct { u16 left; u16 right; - snd_kcontrol_t *ctl; + struct snd_kcontrol *ctl; } pcm_mixer[32]; spinlock_t reg_lock; spinlock_t voice_lock; wait_queue_head_t interrupt_sleep; atomic_t interrupt_sleep_count; - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; #ifdef CONFIG_PM u32 *saved_regs; @@ -364,17 +363,17 @@ struct _snd_ymfpci { #endif }; -int snd_ymfpci_create(snd_card_t * card, +int snd_ymfpci_create(struct snd_card *card, struct pci_dev *pci, unsigned short old_legacy_ctrl, - ymfpci_t ** rcodec); -void snd_ymfpci_free_gameport(ymfpci_t *chip); - -int snd_ymfpci_pcm(ymfpci_t *chip, int device, snd_pcm_t **rpcm); -int snd_ymfpci_pcm2(ymfpci_t *chip, int device, snd_pcm_t **rpcm); -int snd_ymfpci_pcm_spdif(ymfpci_t *chip, int device, snd_pcm_t **rpcm); -int snd_ymfpci_pcm_4ch(ymfpci_t *chip, int device, snd_pcm_t **rpcm); -int snd_ymfpci_mixer(ymfpci_t *chip, int rear_switch); -int snd_ymfpci_timer(ymfpci_t *chip, int device); + struct snd_ymfpci ** rcodec); +void snd_ymfpci_free_gameport(struct snd_ymfpci *chip); + +int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); +int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); +int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); +int snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); +int snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch); +int snd_ymfpci_timer(struct snd_ymfpci *chip, int device); #endif /* __SOUND_YMFPCI_H */ diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index d013237..42499a9 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -80,7 +80,7 @@ static struct pci_device_id snd_ymfpci_ids[] = { MODULE_DEVICE_TABLE(pci, snd_ymfpci_ids); #ifdef SUPPORT_JOYSTICK -static int __devinit snd_ymfpci_create_gameport(ymfpci_t *chip, int dev, +static int __devinit snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev, int legacy_ctrl, int legacy_ctrl2) { struct gameport *gp; @@ -152,7 +152,7 @@ static int __devinit snd_ymfpci_create_gameport(ymfpci_t *chip, int dev, return 0; } -void snd_ymfpci_free_gameport(ymfpci_t *chip) +void snd_ymfpci_free_gameport(struct snd_ymfpci *chip) { if (chip->gameport) { struct resource *r = gameport_get_port_data(chip->gameport); @@ -164,19 +164,19 @@ void snd_ymfpci_free_gameport(ymfpci_t *chip) } } #else -static inline int snd_ymfpci_create_gameport(ymfpci_t *chip, int dev, int l, int l2) { return -ENOSYS; } -void snd_ymfpci_free_gameport(ymfpci_t *chip) { } +static inline int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev, int l, int l2) { return -ENOSYS; } +void snd_ymfpci_free_gameport(struct snd_ymfpci *chip) { } #endif /* SUPPORT_JOYSTICK */ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; + struct snd_card *card; struct resource *fm_res = NULL; struct resource *mpu_res = NULL; - ymfpci_t *chip; - opl3_t *opl3; + struct snd_ymfpci *chip; + struct snd_opl3 *opl3; char *str; int err; u16 legacy_ctrl, legacy_ctrl2, old_legacy_ctrl; diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 8229703..62c9f25 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -50,39 +50,39 @@ * common I/O routines */ -static void snd_ymfpci_irq_wait(ymfpci_t *chip); +static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip); -static inline u8 snd_ymfpci_readb(ymfpci_t *chip, u32 offset) +static inline u8 snd_ymfpci_readb(struct snd_ymfpci *chip, u32 offset) { return readb(chip->reg_area_virt + offset); } -static inline void snd_ymfpci_writeb(ymfpci_t *chip, u32 offset, u8 val) +static inline void snd_ymfpci_writeb(struct snd_ymfpci *chip, u32 offset, u8 val) { writeb(val, chip->reg_area_virt + offset); } -static inline u16 snd_ymfpci_readw(ymfpci_t *chip, u32 offset) +static inline u16 snd_ymfpci_readw(struct snd_ymfpci *chip, u32 offset) { return readw(chip->reg_area_virt + offset); } -static inline void snd_ymfpci_writew(ymfpci_t *chip, u32 offset, u16 val) +static inline void snd_ymfpci_writew(struct snd_ymfpci *chip, u32 offset, u16 val) { writew(val, chip->reg_area_virt + offset); } -static inline u32 snd_ymfpci_readl(ymfpci_t *chip, u32 offset) +static inline u32 snd_ymfpci_readl(struct snd_ymfpci *chip, u32 offset) { return readl(chip->reg_area_virt + offset); } -static inline void snd_ymfpci_writel(ymfpci_t *chip, u32 offset, u32 val) +static inline void snd_ymfpci_writel(struct snd_ymfpci *chip, u32 offset, u32 val) { writel(val, chip->reg_area_virt + offset); } -static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary) +static int snd_ymfpci_codec_ready(struct snd_ymfpci *chip, int secondary) { unsigned long end_time; u32 reg = secondary ? YDSXGR_SECSTATUSADR : YDSXGR_PRISTATUSADR; @@ -98,9 +98,9 @@ static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary) return -EBUSY; } -static void snd_ymfpci_codec_write(ac97_t *ac97, u16 reg, u16 val) +static void snd_ymfpci_codec_write(struct snd_ac97 *ac97, u16 reg, u16 val) { - ymfpci_t *chip = ac97->private_data; + struct snd_ymfpci *chip = ac97->private_data; u32 cmd; snd_ymfpci_codec_ready(chip, 0); @@ -108,9 +108,9 @@ static void snd_ymfpci_codec_write(ac97_t *ac97, u16 reg, u16 val) snd_ymfpci_writel(chip, YDSXGR_AC97CMDDATA, cmd); } -static u16 snd_ymfpci_codec_read(ac97_t *ac97, u16 reg) +static u16 snd_ymfpci_codec_read(struct snd_ac97 *ac97, u16 reg) { - ymfpci_t *chip = ac97->private_data; + struct snd_ymfpci *chip = ac97->private_data; if (snd_ymfpci_codec_ready(chip, 0)) return ~0; @@ -182,7 +182,7 @@ static u32 snd_ymfpci_calc_lpfQ(u32 rate) * Hardware start management */ -static void snd_ymfpci_hw_start(ymfpci_t *chip) +static void snd_ymfpci_hw_start(struct snd_ymfpci *chip) { unsigned long flags; @@ -196,7 +196,7 @@ static void snd_ymfpci_hw_start(ymfpci_t *chip) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_ymfpci_hw_stop(ymfpci_t *chip) +static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip) { unsigned long flags; long timeout = 1000; @@ -222,9 +222,11 @@ static void snd_ymfpci_hw_stop(ymfpci_t *chip) * Playback voice management */ -static int voice_alloc(ymfpci_t *chip, ymfpci_voice_type_t type, int pair, ymfpci_voice_t **rvoice) +static int voice_alloc(struct snd_ymfpci *chip, + enum snd_ymfpci_voice_type type, int pair, + struct snd_ymfpci_voice **rvoice) { - ymfpci_voice_t *voice, *voice2; + struct snd_ymfpci_voice *voice, *voice2; int idx; *rvoice = NULL; @@ -258,7 +260,9 @@ static int voice_alloc(ymfpci_t *chip, ymfpci_voice_type_t type, int pair, ymfpc return -ENOMEM; } -static int snd_ymfpci_voice_alloc(ymfpci_t *chip, ymfpci_voice_type_t type, int pair, ymfpci_voice_t **rvoice) +static int snd_ymfpci_voice_alloc(struct snd_ymfpci *chip, + enum snd_ymfpci_voice_type type, int pair, + struct snd_ymfpci_voice **rvoice) { unsigned long flags; int result; @@ -278,7 +282,7 @@ static int snd_ymfpci_voice_alloc(ymfpci_t *chip, ymfpci_voice_type_t type, int return result; } -static int snd_ymfpci_voice_free(ymfpci_t *chip, ymfpci_voice_t *pvoice) +static int snd_ymfpci_voice_free(struct snd_ymfpci *chip, struct snd_ymfpci_voice *pvoice) { unsigned long flags; @@ -296,9 +300,9 @@ static int snd_ymfpci_voice_free(ymfpci_t *chip, ymfpci_voice_t *pvoice) * PCM part */ -static void snd_ymfpci_pcm_interrupt(ymfpci_t *chip, ymfpci_voice_t *voice) +static void snd_ymfpci_pcm_interrupt(struct snd_ymfpci *chip, struct snd_ymfpci_voice *voice) { - ymfpci_pcm_t *ypcm; + struct snd_ymfpci_pcm *ypcm; u32 pos, delta; if ((ypcm = voice->ypcm) == NULL) @@ -325,7 +329,7 @@ static void snd_ymfpci_pcm_interrupt(ymfpci_t *chip, ymfpci_voice_t *voice) if (unlikely(ypcm->update_pcm_vol)) { unsigned int subs = ypcm->substream->number; unsigned int next_bank = 1 - chip->active_bank; - snd_ymfpci_playback_bank_t *bank; + struct snd_ymfpci_playback_bank *bank; u32 volume; bank = &voice->bank[next_bank]; @@ -345,11 +349,11 @@ static void snd_ymfpci_pcm_interrupt(ymfpci_t *chip, ymfpci_voice_t *voice) spin_unlock(&chip->reg_lock); } -static void snd_ymfpci_pcm_capture_interrupt(snd_pcm_substream_t *substream) +static void snd_ymfpci_pcm_capture_interrupt(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = runtime->private_data; - ymfpci_t *chip = ypcm->chip; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm = runtime->private_data; + struct snd_ymfpci *chip = ypcm->chip; u32 pos, delta; spin_lock(&chip->reg_lock); @@ -372,11 +376,11 @@ static void snd_ymfpci_pcm_capture_interrupt(snd_pcm_substream_t *substream) spin_unlock(&chip->reg_lock); } -static int snd_ymfpci_playback_trigger(snd_pcm_substream_t * substream, +static int snd_ymfpci_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - ymfpci_pcm_t *ypcm = substream->runtime->private_data; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_ymfpci_pcm *ypcm = substream->runtime->private_data; int result = 0; spin_lock(&chip->reg_lock); @@ -409,11 +413,11 @@ static int snd_ymfpci_playback_trigger(snd_pcm_substream_t * substream, spin_unlock(&chip->reg_lock); return result; } -static int snd_ymfpci_capture_trigger(snd_pcm_substream_t * substream, +static int snd_ymfpci_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - ymfpci_pcm_t *ypcm = substream->runtime->private_data; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_ymfpci_pcm *ypcm = substream->runtime->private_data; int result = 0; u32 tmp; @@ -441,7 +445,7 @@ static int snd_ymfpci_capture_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_ymfpci_pcm_voice_alloc(ymfpci_pcm_t *ypcm, int voices) +static int snd_ymfpci_pcm_voice_alloc(struct snd_ymfpci_pcm *ypcm, int voices) { int err; @@ -471,16 +475,16 @@ static int snd_ymfpci_pcm_voice_alloc(ymfpci_pcm_t *ypcm, int voices) return 0; } -static void snd_ymfpci_pcm_init_voice(ymfpci_pcm_t *ypcm, unsigned int voiceidx, - snd_pcm_runtime_t *runtime, +static void snd_ymfpci_pcm_init_voice(struct snd_ymfpci_pcm *ypcm, unsigned int voiceidx, + struct snd_pcm_runtime *runtime, int has_pcm_volume) { - ymfpci_voice_t *voice = ypcm->voices[voiceidx]; + struct snd_ymfpci_voice *voice = ypcm->voices[voiceidx]; u32 format; u32 delta = snd_ymfpci_calc_delta(runtime->rate); u32 lpfQ = snd_ymfpci_calc_lpfQ(runtime->rate); u32 lpfK = snd_ymfpci_calc_lpfK(runtime->rate); - snd_ymfpci_playback_bank_t *bank; + struct snd_ymfpci_playback_bank *bank; unsigned int nbank; u32 vol_left, vol_right; u8 use_left, use_right; @@ -544,7 +548,7 @@ static void snd_ymfpci_pcm_init_voice(ymfpci_pcm_t *ypcm, unsigned int voiceidx, } } -static int __devinit snd_ymfpci_ac3_init(ymfpci_t *chip) +static int __devinit snd_ymfpci_ac3_init(struct snd_ymfpci *chip) { if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), 4096, &chip->ac3_tmp_base) < 0) @@ -566,7 +570,7 @@ static int __devinit snd_ymfpci_ac3_init(ymfpci_t *chip) return 0; } -static int snd_ymfpci_ac3_done(ymfpci_t *chip) +static int snd_ymfpci_ac3_done(struct snd_ymfpci *chip) { spin_lock_irq(&chip->reg_lock); snd_ymfpci_writel(chip, YDSXGR_MAPOFEFFECT, @@ -580,11 +584,11 @@ static int snd_ymfpci_ac3_done(ymfpci_t *chip) return 0; } -static int snd_ymfpci_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ymfpci_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm = runtime->private_data; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) @@ -594,11 +598,11 @@ static int snd_ymfpci_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_ymfpci_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_hw_free(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm; if (runtime->private_data == NULL) return 0; @@ -618,11 +622,11 @@ static int snd_ymfpci_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_ymfpci_playback_prepare(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_prepare(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = runtime->private_data; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm = runtime->private_data; unsigned int nvoice; ypcm->period_size = runtime->period_size; @@ -635,27 +639,27 @@ static int snd_ymfpci_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ymfpci_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ymfpci_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_ymfpci_capture_hw_free(snd_pcm_substream_t * substream) +static int snd_ymfpci_capture_hw_free(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); /* wait, until the PCI operations are not finished */ snd_ymfpci_irq_wait(chip); return snd_pcm_lib_free_pages(substream); } -static int snd_ymfpci_capture_prepare(snd_pcm_substream_t * substream) +static int snd_ymfpci_capture_prepare(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = runtime->private_data; - snd_ymfpci_capture_bank_t * bank; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm = runtime->private_data; + struct snd_ymfpci_capture_bank * bank; int nbank; u32 rate, format; @@ -694,30 +698,30 @@ static int snd_ymfpci_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_ymfpci_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ymfpci_playback_pointer(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = runtime->private_data; - ymfpci_voice_t *voice = ypcm->voices[0]; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm = runtime->private_data; + struct snd_ymfpci_voice *voice = ypcm->voices[0]; if (!(ypcm->running && voice)) return 0; return le32_to_cpu(voice->bank[chip->active_bank].start); } -static snd_pcm_uframes_t snd_ymfpci_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ymfpci_capture_pointer(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = runtime->private_data; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm = runtime->private_data; if (!ypcm->running) return 0; return le32_to_cpu(chip->bank_capture[ypcm->capture_bank_number][chip->active_bank]->start) >> ypcm->shift; } -static void snd_ymfpci_irq_wait(ymfpci_t *chip) +static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip) { wait_queue_t wait; int loops = 4; @@ -735,9 +739,9 @@ static void snd_ymfpci_irq_wait(ymfpci_t *chip) static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ymfpci_t *chip = dev_id; + struct snd_ymfpci *chip = dev_id; u32 status, nvoice, mode; - ymfpci_voice_t *voice; + struct snd_ymfpci_voice *voice; status = snd_ymfpci_readl(chip, YDSXGR_STATUS); if (status & 0x80000000) { @@ -783,7 +787,7 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id, struct pt_regs *r return IRQ_HANDLED; } -static snd_pcm_hardware_t snd_ymfpci_playback = +static struct snd_pcm_hardware snd_ymfpci_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -805,7 +809,7 @@ static snd_pcm_hardware_t snd_ymfpci_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ymfpci_capture = +static struct snd_pcm_hardware snd_ymfpci_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -827,16 +831,16 @@ static snd_pcm_hardware_t snd_ymfpci_capture = .fifo_size = 0, }; -static void snd_ymfpci_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_ymfpci_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } -static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_open_1(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm; ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); if (ypcm == NULL) @@ -853,7 +857,7 @@ static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) } /* call with spinlock held */ -static void ymfpci_open_extension(ymfpci_t *chip) +static void ymfpci_open_extension(struct snd_ymfpci *chip) { if (! chip->rear_opened) { if (! chip->spdif_opened) /* set AC3 */ @@ -866,7 +870,7 @@ static void ymfpci_open_extension(ymfpci_t *chip) } /* call with spinlock held */ -static void ymfpci_close_extension(ymfpci_t *chip) +static void ymfpci_close_extension(struct snd_ymfpci *chip) { if (! chip->rear_opened) { if (! chip->spdif_opened) @@ -877,12 +881,12 @@ static void ymfpci_close_extension(ymfpci_t *chip) } } -static int snd_ymfpci_playback_open(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_open(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm; - snd_kcontrol_t *kctl; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm; + struct snd_kcontrol *kctl; int err; if ((err = snd_ymfpci_playback_open_1(substream)) < 0) @@ -903,11 +907,11 @@ static int snd_ymfpci_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ymfpci_playback_spdif_open(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_spdif_open(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm; int err; if ((err = snd_ymfpci_playback_open_1(substream)) < 0) @@ -930,11 +934,11 @@ static int snd_ymfpci_playback_spdif_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ymfpci_playback_4ch_open(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_4ch_open(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm; int err; if ((err = snd_ymfpci_playback_open_1(substream)) < 0) @@ -949,12 +953,12 @@ static int snd_ymfpci_playback_4ch_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ymfpci_capture_open(snd_pcm_substream_t * substream, +static int snd_ymfpci_capture_open(struct snd_pcm_substream *substream, u32 capture_bank_number) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm; ypcm = kzalloc(sizeof(*ypcm), GFP_KERNEL); if (ypcm == NULL) @@ -973,26 +977,26 @@ static int snd_ymfpci_capture_open(snd_pcm_substream_t * substream, return 0; } -static int snd_ymfpci_capture_rec_open(snd_pcm_substream_t * substream) +static int snd_ymfpci_capture_rec_open(struct snd_pcm_substream *substream) { return snd_ymfpci_capture_open(substream, 0); } -static int snd_ymfpci_capture_ac97_open(snd_pcm_substream_t * substream) +static int snd_ymfpci_capture_ac97_open(struct snd_pcm_substream *substream) { return snd_ymfpci_capture_open(substream, 1); } -static int snd_ymfpci_playback_close_1(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_close_1(struct snd_pcm_substream *substream) { return 0; } -static int snd_ymfpci_playback_close(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_close(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - ymfpci_pcm_t *ypcm = substream->runtime->private_data; - snd_kcontrol_t *kctl; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_ymfpci_pcm *ypcm = substream->runtime->private_data; + struct snd_kcontrol *kctl; spin_lock_irq(&chip->reg_lock); if (ypcm->output_rear && chip->rear_opened > 0) { @@ -1006,9 +1010,9 @@ static int snd_ymfpci_playback_close(snd_pcm_substream_t * substream) return snd_ymfpci_playback_close_1(substream); } -static int snd_ymfpci_playback_spdif_close(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_spdif_close(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); spin_lock_irq(&chip->reg_lock); chip->spdif_opened = 0; @@ -1023,9 +1027,9 @@ static int snd_ymfpci_playback_spdif_close(snd_pcm_substream_t * substream) return snd_ymfpci_playback_close_1(substream); } -static int snd_ymfpci_playback_4ch_close(snd_pcm_substream_t * substream) +static int snd_ymfpci_playback_4ch_close(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); spin_lock_irq(&chip->reg_lock); if (chip->rear_opened > 0) { @@ -1036,11 +1040,11 @@ static int snd_ymfpci_playback_4ch_close(snd_pcm_substream_t * substream) return snd_ymfpci_playback_close_1(substream); } -static int snd_ymfpci_capture_close(snd_pcm_substream_t * substream) +static int snd_ymfpci_capture_close(struct snd_pcm_substream *substream) { - ymfpci_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = runtime->private_data; + struct snd_ymfpci *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ymfpci_pcm *ypcm = runtime->private_data; if (ypcm != NULL) { chip->capture_substream[ypcm->capture_bank_number] = NULL; @@ -1049,7 +1053,7 @@ static int snd_ymfpci_capture_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_ymfpci_playback_ops = { +static struct snd_pcm_ops snd_ymfpci_playback_ops = { .open = snd_ymfpci_playback_open, .close = snd_ymfpci_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1060,7 +1064,7 @@ static snd_pcm_ops_t snd_ymfpci_playback_ops = { .pointer = snd_ymfpci_playback_pointer, }; -static snd_pcm_ops_t snd_ymfpci_capture_rec_ops = { +static struct snd_pcm_ops snd_ymfpci_capture_rec_ops = { .open = snd_ymfpci_capture_rec_open, .close = snd_ymfpci_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1071,9 +1075,9 @@ static snd_pcm_ops_t snd_ymfpci_capture_rec_ops = { .pointer = snd_ymfpci_capture_pointer, }; -int __devinit snd_ymfpci_pcm(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1098,7 +1102,7 @@ int __devinit snd_ymfpci_pcm(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) return 0; } -static snd_pcm_ops_t snd_ymfpci_capture_ac97_ops = { +static struct snd_pcm_ops snd_ymfpci_capture_ac97_ops = { .open = snd_ymfpci_capture_ac97_open, .close = snd_ymfpci_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1109,9 +1113,9 @@ static snd_pcm_ops_t snd_ymfpci_capture_ac97_ops = { .pointer = snd_ymfpci_capture_pointer, }; -int __devinit snd_ymfpci_pcm2(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1136,7 +1140,7 @@ int __devinit snd_ymfpci_pcm2(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) return 0; } -static snd_pcm_ops_t snd_ymfpci_playback_spdif_ops = { +static struct snd_pcm_ops snd_ymfpci_playback_spdif_ops = { .open = snd_ymfpci_playback_spdif_open, .close = snd_ymfpci_playback_spdif_close, .ioctl = snd_pcm_lib_ioctl, @@ -1147,9 +1151,9 @@ static snd_pcm_ops_t snd_ymfpci_playback_spdif_ops = { .pointer = snd_ymfpci_playback_pointer, }; -int __devinit snd_ymfpci_pcm_spdif(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1173,7 +1177,7 @@ int __devinit snd_ymfpci_pcm_spdif(ymfpci_t *chip, int device, snd_pcm_t ** rpcm return 0; } -static snd_pcm_ops_t snd_ymfpci_playback_4ch_ops = { +static struct snd_pcm_ops snd_ymfpci_playback_4ch_ops = { .open = snd_ymfpci_playback_4ch_open, .close = snd_ymfpci_playback_4ch_close, .ioctl = snd_pcm_lib_ioctl, @@ -1184,9 +1188,9 @@ static snd_pcm_ops_t snd_ymfpci_playback_4ch_ops = { .pointer = snd_ymfpci_playback_pointer, }; -int __devinit snd_ymfpci_pcm_4ch(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) +int __devinit snd_ymfpci_pcm_4ch(struct snd_ymfpci *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1210,17 +1214,17 @@ int __devinit snd_ymfpci_pcm_4ch(ymfpci_t *chip, int device, snd_pcm_t ** rpcm) return 0; } -static int snd_ymfpci_spdif_default_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ymfpci_spdif_default_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ymfpci_spdif_default_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); spin_lock_irq(&chip->reg_lock); ucontrol->value.iec958.status[0] = (chip->spdif_bits >> 0) & 0xff; @@ -1229,10 +1233,10 @@ static int snd_ymfpci_spdif_default_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ymfpci_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1247,7 +1251,7 @@ static int snd_ymfpci_spdif_default_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_ymfpci_spdif_default __devinitdata = +static struct snd_kcontrol_new snd_ymfpci_spdif_default __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -1256,17 +1260,17 @@ static snd_kcontrol_new_t snd_ymfpci_spdif_default __devinitdata = .put = snd_ymfpci_spdif_default_put }; -static int snd_ymfpci_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ymfpci_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ymfpci_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); spin_lock_irq(&chip->reg_lock); ucontrol->value.iec958.status[0] = 0x3e; @@ -1275,7 +1279,7 @@ static int snd_ymfpci_spdif_mask_get(snd_kcontrol_t * kcontrol, return 0; } -static snd_kcontrol_new_t snd_ymfpci_spdif_mask __devinitdata = +static struct snd_kcontrol_new snd_ymfpci_spdif_mask __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1284,17 +1288,17 @@ static snd_kcontrol_new_t snd_ymfpci_spdif_mask __devinitdata = .get = snd_ymfpci_spdif_mask_get, }; -static int snd_ymfpci_spdif_stream_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ymfpci_spdif_stream_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ymfpci_spdif_stream_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); spin_lock_irq(&chip->reg_lock); ucontrol->value.iec958.status[0] = (chip->spdif_pcm_bits >> 0) & 0xff; @@ -1303,10 +1307,10 @@ static int snd_ymfpci_spdif_stream_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ymfpci_spdif_stream_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1321,7 +1325,7 @@ static int snd_ymfpci_spdif_stream_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_ymfpci_spdif_stream __devinitdata = +static struct snd_kcontrol_new snd_ymfpci_spdif_stream __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1331,7 +1335,7 @@ static snd_kcontrol_new_t snd_ymfpci_spdif_stream __devinitdata = .put = snd_ymfpci_spdif_stream_put }; -static int snd_ymfpci_drec_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) +static int snd_ymfpci_drec_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *info) { static char *texts[3] = {"AC'97", "IEC958", "ZV Port"}; @@ -1344,9 +1348,9 @@ static int snd_ymfpci_drec_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_in return 0; } -static int snd_ymfpci_drec_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_ymfpci_drec_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *value) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); u16 reg; spin_lock_irq(&chip->reg_lock); @@ -1359,9 +1363,9 @@ static int snd_ymfpci_drec_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return 0; } -static int snd_ymfpci_drec_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_ymfpci_drec_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *value) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); u16 reg, old_reg; spin_lock_irq(&chip->reg_lock); @@ -1375,7 +1379,7 @@ static int snd_ymfpci_drec_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return reg != old_reg; } -static snd_kcontrol_new_t snd_ymfpci_drec_source __devinitdata = { +static struct snd_kcontrol_new snd_ymfpci_drec_source __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Direct Recording Source", @@ -1394,8 +1398,8 @@ static snd_kcontrol_new_t snd_ymfpci_drec_source __devinitdata = { .get = snd_ymfpci_get_single, .put = snd_ymfpci_put_single, \ .private_value = ((reg) | ((shift) << 16)) } -static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ymfpci_info_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int reg = kcontrol->private_value & 0xffff; @@ -1411,10 +1415,10 @@ static int snd_ymfpci_info_single(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ymfpci_get_single(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ymfpci_get_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xffff; unsigned int shift = (kcontrol->private_value >> 16) & 0xff; unsigned int mask = 1; @@ -1429,10 +1433,10 @@ static int snd_ymfpci_get_single(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ymfpci_put_single(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ymfpci_put_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xffff; unsigned int shift = (kcontrol->private_value >> 16) & 0xff; unsigned int mask = 1; @@ -1461,7 +1465,7 @@ static int snd_ymfpci_put_single(snd_kcontrol_t *kcontrol, .get = snd_ymfpci_get_double, .put = snd_ymfpci_put_double, \ .private_value = reg } -static int snd_ymfpci_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ymfpci_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { unsigned int reg = kcontrol->private_value; @@ -1474,9 +1478,9 @@ static int snd_ymfpci_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ymfpci_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); unsigned int reg = kcontrol->private_value; unsigned int shift_left = 0, shift_right = 16, mask = 16383; unsigned int val; @@ -1491,9 +1495,9 @@ static int snd_ymfpci_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ymfpci_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); unsigned int reg = kcontrol->private_value; unsigned int shift_left = 0, shift_right = 16, mask = 16383; int change; @@ -1517,7 +1521,7 @@ static int snd_ymfpci_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t /* * 4ch duplication */ -static int snd_ymfpci_info_dup4ch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ymfpci_info_dup4ch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1526,16 +1530,16 @@ static int snd_ymfpci_info_dup4ch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ymfpci_get_dup4ch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_get_dup4ch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = chip->mode_dup4ch; return 0; } -static int snd_ymfpci_put_dup4ch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ymfpci_put_dup4ch(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); int change; change = (ucontrol->value.integer.value[0] != chip->mode_dup4ch); if (change) @@ -1544,7 +1548,7 @@ static int snd_ymfpci_put_dup4ch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t } -static snd_kcontrol_new_t snd_ymfpci_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_ymfpci_controls[] __devinitdata = { YMFPCI_DOUBLE("Wave Playback Volume", 0, YDSXGR_NATIVEDACOUTVOL), YMFPCI_DOUBLE("Wave Capture Volume", 0, YDSXGR_NATIVEDACLOOPVOL), YMFPCI_DOUBLE("Digital Capture Volume", 0, YDSXGR_NATIVEDACINVOL), @@ -1575,7 +1579,7 @@ YMFPCI_SINGLE(SNDRV_CTL_NAME_IEC958("Loop",NONE,NONE), 0, YDSXGR_SPDIFINCTRL, 4) * GPIO */ -static int snd_ymfpci_get_gpio_out(ymfpci_t *chip, int pin) +static int snd_ymfpci_get_gpio_out(struct snd_ymfpci *chip, int pin) { u16 reg, mode; unsigned long flags; @@ -1595,7 +1599,7 @@ static int snd_ymfpci_get_gpio_out(ymfpci_t *chip, int pin) return (mode >> pin) & 1; } -static int snd_ymfpci_set_gpio_out(ymfpci_t *chip, int pin, int enable) +static int snd_ymfpci_set_gpio_out(struct snd_ymfpci *chip, int pin, int enable) { u16 reg; unsigned long flags; @@ -1612,7 +1616,7 @@ static int snd_ymfpci_set_gpio_out(ymfpci_t *chip, int pin, int enable) return 0; } -static int snd_ymfpci_gpio_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ymfpci_gpio_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1621,17 +1625,17 @@ static int snd_ymfpci_gpio_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ymfpci_gpio_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ymfpci_gpio_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); int pin = (int)kcontrol->private_value; ucontrol->value.integer.value[0] = snd_ymfpci_get_gpio_out(chip, pin); return 0; } -static int snd_ymfpci_gpio_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ymfpci_gpio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); int pin = (int)kcontrol->private_value; if (snd_ymfpci_get_gpio_out(chip, pin) != ucontrol->value.integer.value[0]) { @@ -1642,7 +1646,7 @@ static int snd_ymfpci_gpio_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static snd_kcontrol_new_t snd_ymfpci_rear_shared __devinitdata = { +static struct snd_kcontrol_new snd_ymfpci_rear_shared __devinitdata = { .name = "Shared Rear/Line-In Switch", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_ymfpci_gpio_sw_info, @@ -1655,8 +1659,8 @@ static snd_kcontrol_new_t snd_ymfpci_rear_shared __devinitdata = { * PCM voice volume */ -static int snd_ymfpci_pcm_vol_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_ymfpci_pcm_vol_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1665,10 +1669,10 @@ static int snd_ymfpci_pcm_vol_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ymfpci_pcm_vol_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ymfpci_pcm_vol_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); unsigned int subs = kcontrol->id.subdevice; ucontrol->value.integer.value[0] = chip->pcm_mixer[subs].left; @@ -1676,12 +1680,12 @@ static int snd_ymfpci_pcm_vol_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ymfpci_pcm_vol_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_ymfpci_pcm_vol_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_ymfpci *chip = snd_kcontrol_chip(kcontrol); unsigned int subs = kcontrol->id.subdevice; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; unsigned long flags; if (ucontrol->value.integer.value[0] != chip->pcm_mixer[subs].left || @@ -1689,10 +1693,10 @@ static int snd_ymfpci_pcm_vol_put(snd_kcontrol_t *kcontrol, chip->pcm_mixer[subs].left = ucontrol->value.integer.value[0]; chip->pcm_mixer[subs].right = ucontrol->value.integer.value[1]; - substream = (snd_pcm_substream_t *)kcontrol->private_value; + substream = (struct snd_pcm_substream *)kcontrol->private_value; spin_lock_irqsave(&chip->voice_lock, flags); if (substream->runtime && substream->runtime->private_data) { - ymfpci_pcm_t *ypcm = substream->runtime->private_data; + struct snd_ymfpci_pcm *ypcm = substream->runtime->private_data; ypcm->update_pcm_vol = 2; } spin_unlock_irqrestore(&chip->voice_lock, flags); @@ -1701,7 +1705,7 @@ static int snd_ymfpci_pcm_vol_put(snd_kcontrol_t *kcontrol, return 0; } -static snd_kcontrol_new_t snd_ymfpci_pcm_volume __devinitdata = { +static struct snd_kcontrol_new snd_ymfpci_pcm_volume __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "PCM Playback Volume", .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | @@ -1716,26 +1720,26 @@ static snd_kcontrol_new_t snd_ymfpci_pcm_volume __devinitdata = { * Mixer routines */ -static void snd_ymfpci_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_ymfpci_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - ymfpci_t *chip = bus->private_data; + struct snd_ymfpci *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_ymfpci_mixer_free_ac97(ac97_t *ac97) +static void snd_ymfpci_mixer_free_ac97(struct snd_ac97 *ac97) { - ymfpci_t *chip = ac97->private_data; + struct snd_ymfpci *chip = ac97->private_data; chip->ac97 = NULL; } -int __devinit snd_ymfpci_mixer(ymfpci_t *chip, int rear_switch) +int __devinit snd_ymfpci_mixer(struct snd_ymfpci *chip, int rear_switch) { - ac97_template_t ac97; - snd_kcontrol_t *kctl; - snd_pcm_substream_t *substream; + struct snd_ac97_template ac97; + struct snd_kcontrol *kctl; + struct snd_pcm_substream *substream; unsigned int idx; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_ymfpci_codec_write, .read = snd_ymfpci_codec_read, }; @@ -1811,9 +1815,9 @@ int __devinit snd_ymfpci_mixer(ymfpci_t *chip, int rear_switch) * timer */ -static int snd_ymfpci_timer_start(snd_timer_t *timer) +static int snd_ymfpci_timer_start(struct snd_timer *timer) { - ymfpci_t *chip; + struct snd_ymfpci *chip; unsigned long flags; unsigned int count; @@ -1826,9 +1830,9 @@ static int snd_ymfpci_timer_start(snd_timer_t *timer) return 0; } -static int snd_ymfpci_timer_stop(snd_timer_t *timer) +static int snd_ymfpci_timer_stop(struct snd_timer *timer) { - ymfpci_t *chip; + struct snd_ymfpci *chip; unsigned long flags; chip = snd_timer_chip(timer); @@ -1838,7 +1842,7 @@ static int snd_ymfpci_timer_stop(snd_timer_t *timer) return 0; } -static int snd_ymfpci_timer_precise_resolution(snd_timer_t *timer, +static int snd_ymfpci_timer_precise_resolution(struct snd_timer *timer, unsigned long *num, unsigned long *den) { *num = 1; @@ -1846,7 +1850,7 @@ static int snd_ymfpci_timer_precise_resolution(snd_timer_t *timer, return 0; } -static struct _snd_timer_hardware snd_ymfpci_timer_hw = { +static struct snd_timer_hardware snd_ymfpci_timer_hw = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 20833, /* 1/fs = 20.8333...us */ .ticks = 0x8000, @@ -1855,10 +1859,10 @@ static struct _snd_timer_hardware snd_ymfpci_timer_hw = { .precise_resolution = snd_ymfpci_timer_precise_resolution, }; -int __devinit snd_ymfpci_timer(ymfpci_t *chip, int device) +int __devinit snd_ymfpci_timer(struct snd_ymfpci *chip, int device) { - snd_timer_t *timer = NULL; - snd_timer_id_t tid; + struct snd_timer *timer = NULL; + struct snd_timer_id tid; int err; tid.dev_class = SNDRV_TIMER_CLASS_CARD; @@ -1880,10 +1884,10 @@ int __devinit snd_ymfpci_timer(ymfpci_t *chip, int device) * proc interface */ -static void snd_ymfpci_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ymfpci_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ymfpci_t *chip = entry->private_data; + struct snd_ymfpci *chip = entry->private_data; int i; snd_iprintf(buffer, "YMFPCI\n\n"); @@ -1891,9 +1895,9 @@ static void snd_ymfpci_proc_read(snd_info_entry_t *entry, snd_iprintf(buffer, "%04x: %04x\n", i, snd_ymfpci_readl(chip, i)); } -static int __devinit snd_ymfpci_proc_init(snd_card_t * card, ymfpci_t *chip) +static int __devinit snd_ymfpci_proc_init(struct snd_card *card, struct snd_ymfpci *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(card, "ymfpci", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_ymfpci_proc_read); @@ -1922,12 +1926,12 @@ static void snd_ymfpci_aclink_reset(struct pci_dev * pci) #endif } -static void snd_ymfpci_enable_dsp(ymfpci_t *chip) +static void snd_ymfpci_enable_dsp(struct snd_ymfpci *chip) { snd_ymfpci_writel(chip, YDSXGR_CONFIG, 0x00000001); } -static void snd_ymfpci_disable_dsp(ymfpci_t *chip) +static void snd_ymfpci_disable_dsp(struct snd_ymfpci *chip) { u32 val; int timeout = 1000; @@ -1944,7 +1948,7 @@ static void snd_ymfpci_disable_dsp(ymfpci_t *chip) #include "ymfpci_image.h" -static void snd_ymfpci_download_image(ymfpci_t *chip) +static void snd_ymfpci_download_image(struct snd_ymfpci *chip) { int i; u16 ctrl; @@ -1984,7 +1988,7 @@ static void snd_ymfpci_download_image(ymfpci_t *chip) snd_ymfpci_enable_dsp(chip); } -static int __devinit snd_ymfpci_memalloc(ymfpci_t *chip) +static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip) { long size, playback_ctrl_size; int voice, bank, reg; @@ -2019,10 +2023,10 @@ static int __devinit snd_ymfpci_memalloc(ymfpci_t *chip) ptr_addr += (playback_ctrl_size + 0x00ff) & ~0x00ff; for (voice = 0; voice < YDSXG_PLAYBACK_VOICES; voice++) { chip->voices[voice].number = voice; - chip->voices[voice].bank = (snd_ymfpci_playback_bank_t *)ptr; + chip->voices[voice].bank = (struct snd_ymfpci_playback_bank *)ptr; chip->voices[voice].bank_addr = ptr_addr; for (bank = 0; bank < 2; bank++) { - chip->bank_playback[voice][bank] = (snd_ymfpci_playback_bank_t *)ptr; + chip->bank_playback[voice][bank] = (struct snd_ymfpci_playback_bank *)ptr; ptr += chip->bank_size_playback; ptr_addr += chip->bank_size_playback; } @@ -2033,7 +2037,7 @@ static int __devinit snd_ymfpci_memalloc(ymfpci_t *chip) chip->bank_base_capture_addr = ptr_addr; for (voice = 0; voice < YDSXG_CAPTURE_VOICES; voice++) for (bank = 0; bank < 2; bank++) { - chip->bank_capture[voice][bank] = (snd_ymfpci_capture_bank_t *)ptr; + chip->bank_capture[voice][bank] = (struct snd_ymfpci_capture_bank *)ptr; ptr += chip->bank_size_capture; ptr_addr += chip->bank_size_capture; } @@ -2043,7 +2047,7 @@ static int __devinit snd_ymfpci_memalloc(ymfpci_t *chip) chip->bank_base_effect_addr = ptr_addr; for (voice = 0; voice < YDSXG_EFFECT_VOICES; voice++) for (bank = 0; bank < 2; bank++) { - chip->bank_effect[voice][bank] = (snd_ymfpci_effect_bank_t *)ptr; + chip->bank_effect[voice][bank] = (struct snd_ymfpci_effect_bank *)ptr; ptr += chip->bank_size_effect; ptr_addr += chip->bank_size_effect; } @@ -2082,7 +2086,7 @@ static int __devinit snd_ymfpci_memalloc(ymfpci_t *chip) return 0; } -static int snd_ymfpci_free(ymfpci_t *chip) +static int snd_ymfpci_free(struct snd_ymfpci *chip) { u16 ctrl; @@ -2135,9 +2139,9 @@ static int snd_ymfpci_free(ymfpci_t *chip) return 0; } -static int snd_ymfpci_dev_free(snd_device_t *device) +static int snd_ymfpci_dev_free(struct snd_device *device) { - ymfpci_t *chip = device->device_data; + struct snd_ymfpci *chip = device->device_data; return snd_ymfpci_free(chip); } @@ -2171,9 +2175,9 @@ static int saved_regs_index[] = { }; #define YDSXGR_NUM_SAVED_REGS ARRAY_SIZE(saved_regs_index) -static int snd_ymfpci_suspend(snd_card_t *card, pm_message_t state) +static int snd_ymfpci_suspend(struct snd_card *card, pm_message_t state) { - ymfpci_t *chip = card->pm_private_data; + struct snd_ymfpci *chip = card->pm_private_data; unsigned int i; snd_pcm_suspend_all(chip->pcm); @@ -2190,9 +2194,9 @@ static int snd_ymfpci_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_ymfpci_resume(snd_card_t *card) +static int snd_ymfpci_resume(struct snd_card *card) { - ymfpci_t *chip = card->pm_private_data; + struct snd_ymfpci *chip = card->pm_private_data; unsigned int i; pci_enable_device(chip->pci); @@ -2218,14 +2222,14 @@ static int snd_ymfpci_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -int __devinit snd_ymfpci_create(snd_card_t * card, +int __devinit snd_ymfpci_create(struct snd_card *card, struct pci_dev * pci, unsigned short old_legacy_ctrl, - ymfpci_t ** rchip) + struct snd_ymfpci ** rchip) { - ymfpci_t *chip; + struct snd_ymfpci *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ymfpci_dev_free, }; -- cgit v1.1 From 2fd16874aa6322e8b61879a78f3b485999506833 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:55:19 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI AU88x0 Modules: au88x0 driver Remove xxx_t typedefs from the PCI AU88x0 drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/au88x0/au88x0.c | 8 +++---- sound/pci/au88x0/au88x0.h | 20 ++++++++-------- sound/pci/au88x0/au88x0_a3d.c | 32 ++++++++++++------------- sound/pci/au88x0/au88x0_core.c | 8 +++---- sound/pci/au88x0/au88x0_eq.c | 28 +++++++++++----------- sound/pci/au88x0/au88x0_mixer.c | 6 ++--- sound/pci/au88x0/au88x0_mpu401.c | 4 ++-- sound/pci/au88x0/au88x0_pcm.c | 50 ++++++++++++++++++++-------------------- 8 files changed, 78 insertions(+), 78 deletions(-) diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index d965609..7c54785 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -118,7 +118,7 @@ static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix) // component-destructor // (see "Management of Cards and Components") -static int snd_vortex_dev_free(snd_device_t * device) +static int snd_vortex_dev_free(struct snd_device *device) { vortex_t *vortex = device->device_data; @@ -137,11 +137,11 @@ static int snd_vortex_dev_free(snd_device_t * device) // chip-specific constructor // (see "Management of Cards and Components") static int __devinit -snd_vortex_create(snd_card_t * card, struct pci_dev *pci, vortex_t ** rchip) +snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip) { vortex_t *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_vortex_dev_free, }; @@ -233,7 +233,7 @@ static int __devinit snd_vortex_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; + struct snd_card *card; vortex_t *chip; int err; diff --git a/sound/pci/au88x0/au88x0.h b/sound/pci/au88x0/au88x0.h index b1197cf..745f995 100644 --- a/sound/pci/au88x0/au88x0.h +++ b/sound/pci/au88x0/au88x0.h @@ -129,21 +129,21 @@ typedef struct { /* Virtual page extender stuff */ int nr_periods; int period_bytes; - snd_pcm_sgbuf_t *sgbuf; /* DMA Scatter Gather struct */ + struct snd_sg_buf *sgbuf; /* DMA Scatter Gather struct */ int period_real; int period_virt; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; } stream_t; typedef struct snd_vortex vortex_t; struct snd_vortex { /* ALSA structs. */ - snd_card_t *card; - snd_pcm_t *pcm[VORTEX_PCM_LAST]; + struct snd_card *card; + struct snd_pcm *pcm[VORTEX_PCM_LAST]; - snd_rawmidi_t *rmidi; /* Legacy Midi interface. */ - ac97_t *codec; + struct snd_rawmidi *rmidi; /* Legacy Midi interface. */ + struct snd_ac97 *codec; /* Stream structs. */ stream_t dma_adb[NR_ADB]; @@ -199,7 +199,7 @@ static void vortex_adb_setsrc(vortex_t * vortex, int adbdma, /* DMA Engines. */ static void vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma, - snd_pcm_sgbuf_t * sgbuf, int size, + struct snd_sg_buf * sgbuf, int size, int count); static void vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie, int dir, int fmt, int d, @@ -207,7 +207,7 @@ static void vortex_adbdma_setmode(vortex_t * vortex, int adbdma, int ie, static void vortex_adbdma_setstartbuffer(vortex_t * vortex, int adbdma, int sb); #ifndef CHIP_AU8810 static void vortex_wtdma_setbuffers(vortex_t * vortex, int wtdma, - snd_pcm_sgbuf_t * sgbuf, int size, + struct snd_sg_buf * sgbuf, int size, int count); static void vortex_wtdma_setmode(vortex_t * vortex, int wtdma, int ie, int fmt, int d, /*int e, */ unsigned long offset); @@ -231,9 +231,9 @@ static int inline vortex_wtdma_getlinearpos(vortex_t * vortex, int wtdma); /* global stuff. */ static void vortex_codec_init(vortex_t * vortex); -static void vortex_codec_write(ac97_t * codec, unsigned short addr, +static void vortex_codec_write(struct snd_ac97 * codec, unsigned short addr, unsigned short data); -static unsigned short vortex_codec_read(ac97_t * codec, unsigned short addr); +static unsigned short vortex_codec_read(struct snd_ac97 * codec, unsigned short addr); static void vortex_spdif_init(vortex_t * vortex, int spdif_sr, int spdif_mode); static int vortex_core_init(vortex_t * card); diff --git a/sound/pci/au88x0/au88x0_a3d.c b/sound/pci/au88x0/au88x0_a3d.c index d5755db..d215f39 100644 --- a/sound/pci/au88x0/au88x0_a3d.c +++ b/sound/pci/au88x0/au88x0_a3d.c @@ -725,7 +725,7 @@ static void vortex_a3d_translate_filter(a3d_atmos_t filter, int *params) /* ALSA control interface. */ static int -snd_vortex_a3d_hrtf_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_a3d_hrtf_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 6; @@ -734,7 +734,7 @@ snd_vortex_a3d_hrtf_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) return 0; } static int -snd_vortex_a3d_itd_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_a3d_itd_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -743,7 +743,7 @@ snd_vortex_a3d_itd_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) return 0; } static int -snd_vortex_a3d_ild_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_a3d_ild_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -752,8 +752,8 @@ snd_vortex_a3d_ild_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) return 0; } static int -snd_vortex_a3d_filter_info(snd_kcontrol_t * - kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_a3d_filter_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 4; @@ -763,7 +763,7 @@ snd_vortex_a3d_filter_info(snd_kcontrol_t * } static int -snd_vortex_a3d_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_a3d_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { //a3dsrc_t *a = kcontrol->private_data; /* No read yet. Would this be really useable/needed ? */ @@ -772,8 +772,8 @@ snd_vortex_a3d_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) } static int -snd_vortex_a3d_hrtf_put(snd_kcontrol_t * - kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_a3d_hrtf_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { a3dsrc_t *a = kcontrol->private_data; int changed = 1, i; @@ -789,8 +789,8 @@ snd_vortex_a3d_hrtf_put(snd_kcontrol_t * } static int -snd_vortex_a3d_itd_put(snd_kcontrol_t * - kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_a3d_itd_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { a3dsrc_t *a = kcontrol->private_data; int coord[6]; @@ -808,8 +808,8 @@ snd_vortex_a3d_itd_put(snd_kcontrol_t * } static int -snd_vortex_a3d_ild_put(snd_kcontrol_t * - kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_a3d_ild_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { a3dsrc_t *a = kcontrol->private_data; int changed = 1; @@ -825,8 +825,8 @@ snd_vortex_a3d_ild_put(snd_kcontrol_t * } static int -snd_vortex_a3d_filter_put(snd_kcontrol_t - * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_a3d_filter_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { a3dsrc_t *a = kcontrol->private_data; int i, changed = 1; @@ -845,7 +845,7 @@ snd_vortex_a3d_filter_put(snd_kcontrol_t return changed; } -static snd_kcontrol_new_t vortex_a3d_kcontrol __devinitdata = { +static struct snd_kcontrol_new vortex_a3d_kcontrol __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = "Playback PCM advanced processing", .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, @@ -857,7 +857,7 @@ static snd_kcontrol_new_t vortex_a3d_kcontrol __devinitdata = { /* Control (un)registration. */ static int vortex_a3d_register_controls(vortex_t * vortex) { - snd_kcontrol_t *kcontrol; + struct snd_kcontrol *kcontrol; int err, i; /* HRTF controls. */ for (i = 0; i < NR_A3D; i++) { diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c index 5905188..e3394fe 100644 --- a/sound/pci/au88x0/au88x0_core.c +++ b/sound/pci/au88x0/au88x0_core.c @@ -1097,7 +1097,7 @@ static void vortex_adbdma_setstartbuffer(vortex_t * vortex, int adbdma, int sb) static void vortex_adbdma_setbuffers(vortex_t * vortex, int adbdma, - snd_pcm_sgbuf_t * sgbuf, int psize, int count) + struct snd_sg_buf * sgbuf, int psize, int count) { stream_t *dma = &vortex->dma_adb[adbdma]; @@ -1367,7 +1367,7 @@ static void vortex_wtdma_setstartbuffer(vortex_t * vortex, int wtdma, int sb) static void vortex_wtdma_setbuffers(vortex_t * vortex, int wtdma, - snd_pcm_sgbuf_t * sgbuf, int psize, int count) + struct snd_sg_buf * sgbuf, int psize, int count) { stream_t *dma = &vortex->dma_wt[wtdma]; @@ -2514,7 +2514,7 @@ static void vortex_codec_init(vortex_t * vortex) } static void -vortex_codec_write(ac97_t * codec, unsigned short addr, unsigned short data) +vortex_codec_write(struct snd_ac97 * codec, unsigned short addr, unsigned short data) { vortex_t *card = (vortex_t *) codec->private_data; @@ -2539,7 +2539,7 @@ vortex_codec_write(ac97_t * codec, unsigned short addr, unsigned short data) hwread(card->mmio, VORTEX_CODEC_IO); } -static unsigned short vortex_codec_read(ac97_t * codec, unsigned short addr) +static unsigned short vortex_codec_read(struct snd_ac97 * codec, unsigned short addr) { vortex_t *card = (vortex_t *) codec->private_data; diff --git a/sound/pci/au88x0/au88x0_eq.c b/sound/pci/au88x0/au88x0_eq.c index 9d933cc..13bc8ed 100644 --- a/sound/pci/au88x0/au88x0_eq.c +++ b/sound/pci/au88x0/au88x0_eq.c @@ -730,7 +730,7 @@ static void vortex_Eqlzr_shutdown(vortex_t * vortex) /* Control interface */ static int -snd_vortex_eqtoggle_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_eqtoggle_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -740,8 +740,8 @@ snd_vortex_eqtoggle_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) } static int -snd_vortex_eqtoggle_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_vortex_eqtoggle_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); eqlzr_t *eq = &(vortex->eq); @@ -753,8 +753,8 @@ snd_vortex_eqtoggle_get(snd_kcontrol_t * kcontrol, } static int -snd_vortex_eqtoggle_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_vortex_eqtoggle_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); eqlzr_t *eq = &(vortex->eq); @@ -766,7 +766,7 @@ snd_vortex_eqtoggle_put(snd_kcontrol_t * kcontrol, return 1; /* Allways changes */ } -static snd_kcontrol_new_t vortex_eqtoggle_kcontrol __devinitdata = { +static struct snd_kcontrol_new vortex_eqtoggle_kcontrol __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "EQ Enable", .index = 0, @@ -778,7 +778,7 @@ static snd_kcontrol_new_t vortex_eqtoggle_kcontrol __devinitdata = { }; static int -snd_vortex_eq_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_eq_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -788,7 +788,7 @@ snd_vortex_eq_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) } static int -snd_vortex_eq_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); int i = kcontrol->private_value; @@ -802,7 +802,7 @@ snd_vortex_eq_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) } static int -snd_vortex_eq_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); int changed = 0, i = kcontrol->private_value; @@ -824,7 +824,7 @@ snd_vortex_eq_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) return changed; } -static snd_kcontrol_new_t vortex_eq_kcontrol __devinitdata = { +static struct snd_kcontrol_new vortex_eq_kcontrol __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = " .", .index = 0, @@ -836,7 +836,7 @@ static snd_kcontrol_new_t vortex_eq_kcontrol __devinitdata = { }; static int -snd_vortex_peaks_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +snd_vortex_peaks_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 20; @@ -846,7 +846,7 @@ snd_vortex_peaks_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) } static int -snd_vortex_peaks_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_vortex_peaks_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); int i, count; @@ -863,7 +863,7 @@ snd_vortex_peaks_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) return 0; } -static snd_kcontrol_new_t vortex_levels_kcontrol __devinitdata = { +static struct snd_kcontrol_new vortex_levels_kcontrol __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "EQ Peaks", .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, @@ -888,7 +888,7 @@ static char *EqBandLabels[10] __devinitdata = { /* ALSA driver entry points. Init and exit. */ static int vortex_eq_init(vortex_t * vortex) { - snd_kcontrol_t *kcontrol; + struct snd_kcontrol *kcontrol; int err, i; vortex_Eqlzr_init(vortex); diff --git a/sound/pci/au88x0/au88x0_mixer.c b/sound/pci/au88x0/au88x0_mixer.c index 86e27d69..c96da1d 100644 --- a/sound/pci/au88x0/au88x0_mixer.c +++ b/sound/pci/au88x0/au88x0_mixer.c @@ -13,10 +13,10 @@ static int __devinit snd_vortex_mixer(vortex_t * vortex) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = vortex_codec_write, .read = vortex_codec_read, }; diff --git a/sound/pci/au88x0/au88x0_mpu401.c b/sound/pci/au88x0/au88x0_mpu401.c index c0c2346..8ba6dd3 100644 --- a/sound/pci/au88x0/au88x0_mpu401.c +++ b/sound/pci/au88x0/au88x0_mpu401.c @@ -44,9 +44,9 @@ static int __devinit snd_vortex_midi(vortex_t * vortex) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int temp, mode; - mpu401_t *mpu; + struct snd_mpu401 *mpu; int port; #ifdef VORTEX_MPU401_LEGACY diff --git a/sound/pci/au88x0/au88x0_pcm.c b/sound/pci/au88x0/au88x0_pcm.c index 38bd2b5..6a13ca1 100644 --- a/sound/pci/au88x0/au88x0_pcm.c +++ b/sound/pci/au88x0/au88x0_pcm.c @@ -31,7 +31,7 @@ #define VORTEX_PCM_TYPE(x) (x->name[40]) /* hardware definition */ -static snd_pcm_hardware_t snd_vortex_playback_hw_adb = { +static struct snd_pcm_hardware snd_vortex_playback_hw_adb = { .info = (SNDRV_PCM_INFO_MMAP | /* SNDRV_PCM_INFO_RESUME | */ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_INTERLEAVED | @@ -56,7 +56,7 @@ static snd_pcm_hardware_t snd_vortex_playback_hw_adb = { }; #ifndef CHIP_AU8820 -static snd_pcm_hardware_t snd_vortex_playback_hw_a3d = { +static struct snd_pcm_hardware snd_vortex_playback_hw_a3d = { .info = (SNDRV_PCM_INFO_MMAP | /* SNDRV_PCM_INFO_RESUME | */ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_INTERLEAVED | @@ -76,7 +76,7 @@ static snd_pcm_hardware_t snd_vortex_playback_hw_a3d = { .periods_max = 64, }; #endif -static snd_pcm_hardware_t snd_vortex_playback_hw_spdif = { +static struct snd_pcm_hardware snd_vortex_playback_hw_spdif = { .info = (SNDRV_PCM_INFO_MMAP | /* SNDRV_PCM_INFO_RESUME | */ SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_INTERLEAVED | @@ -99,7 +99,7 @@ static snd_pcm_hardware_t snd_vortex_playback_hw_spdif = { }; #ifndef CHIP_AU8810 -static snd_pcm_hardware_t snd_vortex_playback_hw_wt = { +static struct snd_pcm_hardware snd_vortex_playback_hw_wt = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), @@ -117,10 +117,10 @@ static snd_pcm_hardware_t snd_vortex_playback_hw_wt = { }; #endif /* open callback */ -static int snd_vortex_pcm_open(snd_pcm_substream_t * substream) +static int snd_vortex_pcm_open(struct snd_pcm_substream *substream) { vortex_t *vortex = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; /* Force equal size periods */ @@ -169,7 +169,7 @@ static int snd_vortex_pcm_open(snd_pcm_substream_t * substream) } /* close callback */ -static int snd_vortex_pcm_close(snd_pcm_substream_t * substream) +static int snd_vortex_pcm_close(struct snd_pcm_substream *substream) { //vortex_t *chip = snd_pcm_substream_chip(substream); stream_t *stream = (stream_t *) substream->runtime->private_data; @@ -185,12 +185,12 @@ static int snd_vortex_pcm_close(snd_pcm_substream_t * substream) /* hw_params callback */ static int -snd_vortex_pcm_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +snd_vortex_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { vortex_t *chip = snd_pcm_substream_chip(substream); stream_t *stream = (stream_t *) (substream->runtime->private_data); - snd_pcm_sgbuf_t *sgbuf; + struct snd_sg_buf *sgbuf; int err; // Alloc buffer memory. @@ -200,7 +200,7 @@ snd_vortex_pcm_hw_params(snd_pcm_substream_t * substream, printk(KERN_ERR "Vortex: pcm page alloc failed!\n"); return err; } - //sgbuf = (snd_pcm_sgbuf_t *) substream->runtime->dma_private; + //sgbuf = (struct snd_sg_buf *) substream->runtime->dma_private; sgbuf = snd_pcm_substream_sgbuf(substream); /* printk(KERN_INFO "Vortex: periods %d, period_bytes %d, channels = %d\n", params_periods(hw_params), @@ -251,7 +251,7 @@ snd_vortex_pcm_hw_params(snd_pcm_substream_t * substream, } /* hw_free callback */ -static int snd_vortex_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_vortex_pcm_hw_free(struct snd_pcm_substream *substream) { vortex_t *chip = snd_pcm_substream_chip(substream); stream_t *stream = (stream_t *) (substream->runtime->private_data); @@ -277,10 +277,10 @@ static int snd_vortex_pcm_hw_free(snd_pcm_substream_t * substream) } /* prepare callback */ -static int snd_vortex_pcm_prepare(snd_pcm_substream_t * substream) +static int snd_vortex_pcm_prepare(struct snd_pcm_substream *substream) { vortex_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; stream_t *stream = (stream_t *) substream->runtime->private_data; int dma = stream->dma, fmt, dir; @@ -310,7 +310,7 @@ static int snd_vortex_pcm_prepare(snd_pcm_substream_t * substream) } /* trigger callback */ -static int snd_vortex_pcm_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_vortex_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { vortex_t *chip = snd_pcm_substream_chip(substream); stream_t *stream = (stream_t *) substream->runtime->private_data; @@ -374,7 +374,7 @@ static int snd_vortex_pcm_trigger(snd_pcm_substream_t * substream, int cmd) } /* pointer callback */ -static snd_pcm_uframes_t snd_vortex_pcm_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_vortex_pcm_pointer(struct snd_pcm_substream *substream) { vortex_t *chip = snd_pcm_substream_chip(substream); stream_t *stream = (stream_t *) substream->runtime->private_data; @@ -395,13 +395,13 @@ static snd_pcm_uframes_t snd_vortex_pcm_pointer(snd_pcm_substream_t * substream) /* Page callback. */ /* -static struct page *snd_pcm_sgbuf_ops_page(snd_pcm_substream_t *substream, unsigned long offset) { +static struct page *snd_pcm_sgbuf_ops_page(struct snd_pcm_substream *substream, unsigned long offset) { } */ /* operators */ -static snd_pcm_ops_t snd_vortex_playback_ops = { +static struct snd_pcm_ops snd_vortex_playback_ops = { .open = snd_vortex_pcm_open, .close = snd_vortex_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -434,14 +434,14 @@ static char *vortex_pcm_name[VORTEX_PCM_LAST] = { /* SPDIF kcontrol */ -static int snd_vortex_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vortex_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_vortex_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vortex_spdif_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -450,7 +450,7 @@ static int snd_vortex_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return 0; } -static int snd_vortex_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vortex_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); ucontrol->value.iec958.status[0] = 0x00; @@ -464,7 +464,7 @@ static int snd_vortex_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_vortex_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vortex_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { vortex_t *vortex = snd_kcontrol_chip(kcontrol); int spdif_sr = 48000; @@ -481,7 +481,7 @@ static int snd_vortex_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t } /* spdif controls */ -static snd_kcontrol_new_t snd_vortex_mixer_spdif[] __devinitdata = { +static struct snd_kcontrol_new snd_vortex_mixer_spdif[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -501,8 +501,8 @@ static snd_kcontrol_new_t snd_vortex_mixer_spdif[] __devinitdata = { /* create a pcm device */ static int __devinit snd_vortex_new_pcm(vortex_t * chip, int idx, int nr) { - snd_pcm_t *pcm; - snd_kcontrol_t *kctl; + struct snd_pcm *pcm; + struct snd_kcontrol *kctl; int i; int err, nr_capt; -- cgit v1.1 From e4a3d145455159955d6ac1df976b2ed2a135b858 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:55:40 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI CA0106 Modules: CA0106 driver Remove xxx_t typedefs from the PCI CA0106 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ca0106/ca0106.h | 54 +++++----- sound/pci/ca0106/ca0106_main.c | 234 ++++++++++++++++++++-------------------- sound/pci/ca0106/ca0106_mixer.c | 99 +++++++++-------- sound/pci/ca0106/ca0106_proc.c | 60 +++++------ sound/pci/ca0106/ca_midi.c | 49 +++++---- sound/pci/ca0106/ca_midi.h | 25 ++--- 6 files changed, 263 insertions(+), 258 deletions(-) diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h index 9a4b640..7088317 100644 --- a/sound/pci/ca0106/ca0106.h +++ b/sound/pci/ca0106/ca0106.h @@ -554,37 +554,35 @@ #include "ca_midi.h" -typedef struct snd_ca0106_channel ca0106_channel_t; -typedef struct snd_ca0106 ca0106_t; -typedef struct snd_ca0106_pcm ca0106_pcm_t; +struct snd_ca0106; struct snd_ca0106_channel { - ca0106_t *emu; + struct snd_ca0106 *emu; int number; int use; - void (*interrupt)(ca0106_t *emu, ca0106_channel_t *channel); - ca0106_pcm_t *epcm; + void (*interrupt)(struct snd_ca0106 *emu, struct snd_ca0106_channel *channel); + struct snd_ca0106_pcm *epcm; }; struct snd_ca0106_pcm { - ca0106_t *emu; - snd_pcm_substream_t *substream; + struct snd_ca0106 *emu; + struct snd_pcm_substream *substream; int channel_id; unsigned short running; }; -typedef struct { +struct snd_ca0106_details { u32 serial; char * name; int ac97; int gpio_type; int i2c_adc; -} ca0106_details_t; +}; // definition of the chip-specific record struct snd_ca0106 { - snd_card_t *card; - ca0106_details_t *details; + struct snd_card *card; + struct snd_ca0106_details *details; struct pci_dev *pci; unsigned long port; @@ -597,11 +595,11 @@ struct snd_ca0106 { spinlock_t emu_lock; - ac97_t *ac97; - snd_pcm_t *pcm; + struct snd_ac97 *ac97; + struct snd_pcm *pcm; - ca0106_channel_t playback_channels[4]; - ca0106_channel_t capture_channels[4]; + struct snd_ca0106_channel playback_channels[4]; + struct snd_ca0106_channel capture_channels[4]; u32 spdif_bits[4]; /* s/pdif out setup */ int spdif_enable; int capture_source; @@ -609,22 +607,22 @@ struct snd_ca0106 { struct snd_dma_buffer buffer; - ca_midi_t midi; - ca_midi_t midi2; + struct snd_ca_midi midi; + struct snd_ca_midi midi2; }; -int __devinit snd_ca0106_mixer(ca0106_t *emu); -int __devinit snd_ca0106_proc_init(ca0106_t * emu); +int snd_ca0106_mixer(struct snd_ca0106 *emu); +int snd_ca0106_proc_init(struct snd_ca0106 * emu); -unsigned int snd_ca0106_ptr_read(ca0106_t * emu, - unsigned int reg, - unsigned int chn); +unsigned int snd_ca0106_ptr_read(struct snd_ca0106 * emu, + unsigned int reg, + unsigned int chn); -void snd_ca0106_ptr_write(ca0106_t *emu, - unsigned int reg, - unsigned int chn, - unsigned int data); +void snd_ca0106_ptr_write(struct snd_ca0106 *emu, + unsigned int reg, + unsigned int chn, + unsigned int data); -int snd_ca0106_i2c_write(ca0106_t *emu, u32 reg, u32 value); +int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value); diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 0120c46..744f971 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -164,7 +164,7 @@ MODULE_PARM_DESC(enable, "Enable the CA0106 soundcard."); #include "ca0106.h" -static ca0106_details_t ca0106_chip_details[] = { +static struct snd_ca0106_details ca0106_chip_details[] = { /* AudigyLS[SB0310] */ { .serial = 0x10021102, .name = "AudigyLS [SB0310]", @@ -201,7 +201,7 @@ static ca0106_details_t ca0106_chip_details[] = { }; /* hardware definition */ -static snd_pcm_hardware_t snd_ca0106_playback_hw = { +static struct snd_pcm_hardware snd_ca0106_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -221,7 +221,7 @@ static snd_pcm_hardware_t snd_ca0106_playback_hw = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ca0106_capture_hw = { +static struct snd_pcm_hardware snd_ca0106_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -241,7 +241,7 @@ static snd_pcm_hardware_t snd_ca0106_capture_hw = { .fifo_size = 0, }; -unsigned int snd_ca0106_ptr_read(ca0106_t * emu, +unsigned int snd_ca0106_ptr_read(struct snd_ca0106 * emu, unsigned int reg, unsigned int chn) { @@ -257,7 +257,7 @@ unsigned int snd_ca0106_ptr_read(ca0106_t * emu, return val; } -void snd_ca0106_ptr_write(ca0106_t *emu, +void snd_ca0106_ptr_write(struct snd_ca0106 *emu, unsigned int reg, unsigned int chn, unsigned int data) @@ -273,7 +273,7 @@ void snd_ca0106_ptr_write(ca0106_t *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -int snd_ca0106_i2c_write(ca0106_t *emu, +int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value) { @@ -325,7 +325,7 @@ int snd_ca0106_i2c_write(ca0106_t *emu, } -static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) +static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -336,7 +336,7 @@ static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) spin_unlock_irqrestore(&emu->emu_lock, flags); } -static void snd_ca0106_intr_disable(ca0106_t *emu, unsigned int intrenb) +static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb) { unsigned long flags; unsigned int enable; @@ -348,18 +348,19 @@ static void snd_ca0106_intr_disable(ca0106_t *emu, unsigned int intrenb) } -static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_ca0106_pcm_free_substream(struct snd_pcm_runtime *runtime) { kfree(runtime->private_data); } /* open_playback callback */ -static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, int channel_id) +static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, + int channel_id) { - ca0106_t *chip = snd_pcm_substream_chip(substream); - ca0106_channel_t *channel = &(chip->playback_channels[channel_id]); - ca0106_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); + struct snd_ca0106_channel *channel = &(chip->playback_channels[channel_id]); + struct snd_ca0106_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -390,43 +391,44 @@ static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, } /* close callback */ -static int snd_ca0106_pcm_close_playback(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream) { - ca0106_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; - chip->playback_channels[epcm->channel_id].use=0; -/* FIXME: maybe zero others */ + struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; + chip->playback_channels[epcm->channel_id].use = 0; + /* FIXME: maybe zero others */ return 0; } -static int snd_ca0106_pcm_open_playback_front(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_playback_front(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); } -static int snd_ca0106_pcm_open_playback_center_lfe(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_playback_center_lfe(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_playback_channel(substream, PCM_CENTER_LFE_CHANNEL); } -static int snd_ca0106_pcm_open_playback_unknown(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_playback_unknown(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_playback_channel(substream, PCM_UNKNOWN_CHANNEL); } -static int snd_ca0106_pcm_open_playback_rear(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_playback_rear(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_playback_channel(substream, PCM_REAR_CHANNEL); } /* open_capture callback */ -static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, int channel_id) +static int snd_ca0106_pcm_open_capture_channel(struct snd_pcm_substream *substream, + int channel_id) { - ca0106_t *chip = snd_pcm_substream_chip(substream); - ca0106_channel_t *channel = &(chip->capture_channels[channel_id]); - ca0106_pcm_t *epcm; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); + struct snd_ca0106_channel *channel = &(chip->capture_channels[channel_id]); + struct snd_ca0106_pcm *epcm; + struct snd_pcm_runtime *runtime = substream->runtime; int err; epcm = kzalloc(sizeof(*epcm), GFP_KERNEL); @@ -449,7 +451,7 @@ static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, i channel->use = 1; //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); //channel->interrupt = snd_ca0106_pcm_channel_interrupt; - channel->epcm = epcm; + channel->epcm = epcm; if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; //snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hw_constraints_capture_period_sizes); @@ -459,70 +461,70 @@ static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, i } /* close callback */ -static int snd_ca0106_pcm_close_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_close_capture(struct snd_pcm_substream *substream) { - ca0106_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; - chip->capture_channels[epcm->channel_id].use=0; -/* FIXME: maybe zero others */ + struct snd_ca0106 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; + chip->capture_channels[epcm->channel_id].use = 0; + /* FIXME: maybe zero others */ return 0; } -static int snd_ca0106_pcm_open_0_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_0_capture(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_capture_channel(substream, 0); } -static int snd_ca0106_pcm_open_1_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_1_capture(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_capture_channel(substream, 1); } -static int snd_ca0106_pcm_open_2_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_2_capture(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_capture_channel(substream, 2); } -static int snd_ca0106_pcm_open_3_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_open_3_capture(struct snd_pcm_substream *substream) { return snd_ca0106_pcm_open_capture_channel(substream, 3); } /* hw_params callback */ -static int snd_ca0106_pcm_hw_params_playback(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ca0106_pcm_hw_params_playback(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } /* hw_free callback */ -static int snd_ca0106_pcm_hw_free_playback(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_hw_free_playback(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } /* hw_params callback */ -static int snd_ca0106_pcm_hw_params_capture(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ca0106_pcm_hw_params_capture(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } /* hw_free callback */ -static int snd_ca0106_pcm_hw_free_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_hw_free_capture(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } /* prepare playback callback */ -static int snd_ca0106_pcm_prepare_playback(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; int channel = epcm->channel_id; u32 *table_base = (u32 *)(emu->buffer.area+(8*16*channel)); u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); @@ -619,11 +621,11 @@ static int snd_ca0106_pcm_prepare_playback(snd_pcm_substream_t *substream) } /* prepare capture callback */ -static int snd_ca0106_pcm_prepare_capture(snd_pcm_substream_t *substream) +static int snd_ca0106_pcm_prepare_capture(struct snd_pcm_substream *substream) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; int channel = epcm->channel_id; u32 hcfg_mask = HCFG_CAPTURE_S32_LE; u32 hcfg_set = 0x00000000; @@ -690,16 +692,16 @@ static int snd_ca0106_pcm_prepare_capture(snd_pcm_substream_t *substream) } /* trigger_playback callback */ -static int snd_ca0106_pcm_trigger_playback(snd_pcm_substream_t *substream, +static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream, int cmd) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime; - ca0106_pcm_t *epcm; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime; + struct snd_ca0106_pcm *epcm; int channel; int result = 0; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; u32 basic = 0; u32 extended = 0; int running=0; @@ -743,12 +745,12 @@ static int snd_ca0106_pcm_trigger_playback(snd_pcm_substream_t *substream, } /* trigger_capture callback */ -static int snd_ca0106_pcm_trigger_capture(snd_pcm_substream_t *substream, +static int snd_ca0106_pcm_trigger_capture(struct snd_pcm_substream *substream, int cmd) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; int channel = epcm->channel_id; int result = 0; @@ -772,11 +774,11 @@ static int snd_ca0106_pcm_trigger_capture(snd_pcm_substream_t *substream, /* pointer_playback callback */ static snd_pcm_uframes_t -snd_ca0106_pcm_pointer_playback(snd_pcm_substream_t *substream) +snd_ca0106_pcm_pointer_playback(struct snd_pcm_substream *substream) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; int channel = epcm->channel_id; @@ -799,11 +801,11 @@ snd_ca0106_pcm_pointer_playback(snd_pcm_substream_t *substream) /* pointer_capture callback */ static snd_pcm_uframes_t -snd_ca0106_pcm_pointer_capture(snd_pcm_substream_t *substream) +snd_ca0106_pcm_pointer_capture(struct snd_pcm_substream *substream) { - ca0106_t *emu = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ca0106_pcm_t *epcm = runtime->private_data; + struct snd_ca0106 *emu = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ca0106_pcm *epcm = runtime->private_data; snd_pcm_uframes_t ptr, ptr1, ptr2 = 0; int channel = channel=epcm->channel_id; @@ -821,7 +823,7 @@ snd_ca0106_pcm_pointer_capture(snd_pcm_substream_t *substream) } /* operators */ -static snd_pcm_ops_t snd_ca0106_playback_front_ops = { +static struct snd_pcm_ops snd_ca0106_playback_front_ops = { .open = snd_ca0106_pcm_open_playback_front, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -832,7 +834,7 @@ static snd_pcm_ops_t snd_ca0106_playback_front_ops = { .pointer = snd_ca0106_pcm_pointer_playback, }; -static snd_pcm_ops_t snd_ca0106_capture_0_ops = { +static struct snd_pcm_ops snd_ca0106_capture_0_ops = { .open = snd_ca0106_pcm_open_0_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -843,7 +845,7 @@ static snd_pcm_ops_t snd_ca0106_capture_0_ops = { .pointer = snd_ca0106_pcm_pointer_capture, }; -static snd_pcm_ops_t snd_ca0106_capture_1_ops = { +static struct snd_pcm_ops snd_ca0106_capture_1_ops = { .open = snd_ca0106_pcm_open_1_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -854,7 +856,7 @@ static snd_pcm_ops_t snd_ca0106_capture_1_ops = { .pointer = snd_ca0106_pcm_pointer_capture, }; -static snd_pcm_ops_t snd_ca0106_capture_2_ops = { +static struct snd_pcm_ops snd_ca0106_capture_2_ops = { .open = snd_ca0106_pcm_open_2_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -865,7 +867,7 @@ static snd_pcm_ops_t snd_ca0106_capture_2_ops = { .pointer = snd_ca0106_pcm_pointer_capture, }; -static snd_pcm_ops_t snd_ca0106_capture_3_ops = { +static struct snd_pcm_ops snd_ca0106_capture_3_ops = { .open = snd_ca0106_pcm_open_3_capture, .close = snd_ca0106_pcm_close_capture, .ioctl = snd_pcm_lib_ioctl, @@ -876,7 +878,7 @@ static snd_pcm_ops_t snd_ca0106_capture_3_ops = { .pointer = snd_ca0106_pcm_pointer_capture, }; -static snd_pcm_ops_t snd_ca0106_playback_center_lfe_ops = { +static struct snd_pcm_ops snd_ca0106_playback_center_lfe_ops = { .open = snd_ca0106_pcm_open_playback_center_lfe, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -887,7 +889,7 @@ static snd_pcm_ops_t snd_ca0106_playback_center_lfe_ops = { .pointer = snd_ca0106_pcm_pointer_playback, }; -static snd_pcm_ops_t snd_ca0106_playback_unknown_ops = { +static struct snd_pcm_ops snd_ca0106_playback_unknown_ops = { .open = snd_ca0106_pcm_open_playback_unknown, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -898,7 +900,7 @@ static snd_pcm_ops_t snd_ca0106_playback_unknown_ops = { .pointer = snd_ca0106_pcm_pointer_playback, }; -static snd_pcm_ops_t snd_ca0106_playback_rear_ops = { +static struct snd_pcm_ops snd_ca0106_playback_rear_ops = { .open = snd_ca0106_pcm_open_playback_rear, .close = snd_ca0106_pcm_close_playback, .ioctl = snd_pcm_lib_ioctl, @@ -910,10 +912,10 @@ static snd_pcm_ops_t snd_ca0106_playback_rear_ops = { }; -static unsigned short snd_ca0106_ac97_read(ac97_t *ac97, +static unsigned short snd_ca0106_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - ca0106_t *emu = ac97->private_data; + struct snd_ca0106 *emu = ac97->private_data; unsigned long flags; unsigned short val; @@ -924,10 +926,10 @@ static unsigned short snd_ca0106_ac97_read(ac97_t *ac97, return val; } -static void snd_ca0106_ac97_write(ac97_t *ac97, +static void snd_ca0106_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - ca0106_t *emu = ac97->private_data; + struct snd_ca0106 *emu = ac97->private_data; unsigned long flags; spin_lock_irqsave(&emu->emu_lock, flags); @@ -936,12 +938,12 @@ static void snd_ca0106_ac97_write(ac97_t *ac97, spin_unlock_irqrestore(&emu->emu_lock, flags); } -static int snd_ca0106_ac97(ca0106_t *chip) +static int snd_ca0106_ac97(struct snd_ca0106 *chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_ca0106_ac97_write, .read = snd_ca0106_ac97_read, }; @@ -956,7 +958,7 @@ static int snd_ca0106_ac97(ca0106_t *chip) return snd_ac97_mixer(pbus, &ac97, &chip->ac97); } -static int snd_ca0106_free(ca0106_t *chip) +static int snd_ca0106_free(struct snd_ca0106 *chip) { if (chip->res_port != NULL) { /* avoid access to already used hardware */ // disable interrupts @@ -989,9 +991,9 @@ static int snd_ca0106_free(ca0106_t *chip) return 0; } -static int snd_ca0106_dev_free(snd_device_t *device) +static int snd_ca0106_dev_free(struct snd_device *device) { - ca0106_t *chip = device->device_data; + struct snd_ca0106 *chip = device->device_data; return snd_ca0106_free(chip); } @@ -1000,14 +1002,13 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, { unsigned int status; - ca0106_t *chip = dev_id; + struct snd_ca0106 *chip = dev_id; int i; int mask; unsigned int stat76; - ca0106_channel_t *pchannel; + struct snd_ca0106_channel *pchannel; status = inl(chip->port + IPR); - if (! status) return IRQ_NONE; @@ -1059,10 +1060,10 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, return IRQ_HANDLED; } -static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) +static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct snd_pcm **rpcm) { - snd_pcm_t *pcm; - snd_pcm_substream_t *substream; + struct snd_pcm *pcm; + struct snd_pcm_substream *substream; int err; if (rpcm) @@ -1122,15 +1123,15 @@ static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) return 0; } -static int __devinit snd_ca0106_create(snd_card_t *card, +static int __devinit snd_ca0106_create(struct snd_card *card, struct pci_dev *pci, - ca0106_t **rchip) + struct snd_ca0106 **rchip) { - ca0106_t *chip; - ca0106_details_t *c; + struct snd_ca0106 *chip; + struct snd_ca0106_details *c; int err; int ch; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ca0106_dev_free, }; @@ -1314,39 +1315,40 @@ static int __devinit snd_ca0106_create(snd_card_t *card, } -static void ca0106_midi_interrupt_enable(ca_midi_t *midi, int intr) +static void ca0106_midi_interrupt_enable(struct snd_ca_midi *midi, int intr) { - snd_ca0106_intr_enable((ca0106_t *)(midi->dev_id), intr); + snd_ca0106_intr_enable((struct snd_ca0106 *)(midi->dev_id), intr); } -static void ca0106_midi_interrupt_disable(ca_midi_t *midi, int intr) +static void ca0106_midi_interrupt_disable(struct snd_ca_midi *midi, int intr) { - snd_ca0106_intr_disable((ca0106_t *)(midi->dev_id), intr); + snd_ca0106_intr_disable((struct snd_ca0106 *)(midi->dev_id), intr); } -static unsigned char ca0106_midi_read(ca_midi_t *midi, int idx) +static unsigned char ca0106_midi_read(struct snd_ca_midi *midi, int idx) { - return (unsigned char)snd_ca0106_ptr_read((ca0106_t *)(midi->dev_id), midi->port + idx, 0); + return (unsigned char)snd_ca0106_ptr_read((struct snd_ca0106 *)(midi->dev_id), + midi->port + idx, 0); } -static void ca0106_midi_write(ca_midi_t *midi, int data, int idx) +static void ca0106_midi_write(struct snd_ca_midi *midi, int data, int idx) { - snd_ca0106_ptr_write((ca0106_t *)(midi->dev_id), midi->port + idx, 0, data); + snd_ca0106_ptr_write((struct snd_ca0106 *)(midi->dev_id), midi->port + idx, 0, data); } -static snd_card_t *ca0106_dev_id_card(void *dev_id) +static struct snd_card *ca0106_dev_id_card(void *dev_id) { - return ((ca0106_t *)dev_id)->card; + return ((struct snd_ca0106 *)dev_id)->card; } static int ca0106_dev_id_port(void *dev_id) { - return ((ca0106_t *)dev_id)->port; + return ((struct snd_ca0106 *)dev_id)->port; } -static int __devinit snd_ca0106_midi(ca0106_t *chip, unsigned int channel) +static int __devinit snd_ca0106_midi(struct snd_ca0106 *chip, unsigned int channel) { - ca_midi_t *midi; + struct snd_ca_midi *midi; char *name; int err; @@ -1399,8 +1401,8 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - ca0106_t *chip; + struct snd_card *card; + struct snd_ca0106 *chip; int err; if (dev >= SNDRV_CARDS) diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 0730dc7..39100cb 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -73,7 +73,8 @@ #include "ca0106.h" -static int snd_ca0106_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ca0106_shared_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -82,19 +83,19 @@ static int snd_ca0106_shared_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_ca0106_shared_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_shared_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = emu->spdif_enable; return 0; } -static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_shared_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; u32 mask; @@ -125,7 +126,8 @@ static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static int snd_ca0106_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ca0106_capture_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[6] = { "SPDIF out", "i2s mixer out", "SPDIF in", "i2s in", "AC97 in", "SRC out" @@ -140,19 +142,19 @@ static int snd_ca0106_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_ca0106_capture_source_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_capture_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = emu->capture_source; return 0; } -static int snd_ca0106_capture_source_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_capture_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; u32 mask; @@ -169,7 +171,8 @@ static int snd_ca0106_capture_source_put(snd_kcontrol_t * kcontrol, return change; } -static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ca0106_capture_mic_line_in_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "Line in", "Mic in" }; @@ -182,19 +185,19 @@ static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl return 0; } -static int snd_ca0106_capture_mic_line_in_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_capture_mic_line_in_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = emu->capture_mic_line_in; return 0; } -static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_capture_mic_line_in_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); unsigned int val; int change = 0; u32 tmp; @@ -219,7 +222,7 @@ static int snd_ca0106_capture_mic_line_in_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata = +static struct snd_kcontrol_new snd_ca0106_capture_mic_line_in __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic/Line in Capture", @@ -228,17 +231,18 @@ static snd_kcontrol_new_t snd_ca0106_capture_mic_line_in __devinitdata = .put = snd_ca0106_capture_mic_line_in_put }; -static int snd_ca0106_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ca0106_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ca0106_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff; @@ -248,8 +252,8 @@ static int snd_ca0106_spdif_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ca0106_spdif_get_mask(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_spdif_get_mask(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -258,10 +262,10 @@ static int snd_ca0106_spdif_get_mask(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ca0106_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); int change; unsigned int val; @@ -278,7 +282,8 @@ static int snd_ca0106_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ca0106_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -287,10 +292,10 @@ static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); unsigned int value; int channel_id, reg; @@ -303,10 +308,10 @@ static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ca0106_volume_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ca0106_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ca0106_t *emu = snd_kcontrol_chip(kcontrol); + struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); unsigned int oval, nval; int channel_id, reg; @@ -334,7 +339,7 @@ static int snd_ca0106_volume_put(snd_kcontrol_t * kcontrol, } -static snd_kcontrol_new_t snd_ca0106_volume_ctls[] __devinitdata = { +static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = { CA_VOLUME("Analog Front Playback Volume", CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2), CA_VOLUME("Analog Rear Playback Volume", @@ -388,18 +393,18 @@ static snd_kcontrol_new_t snd_ca0106_volume_ctls[] __devinitdata = { }, }; -static int __devinit remove_ctl(snd_card_t *card, const char *name) +static int __devinit remove_ctl(struct snd_card *card, const char *name) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; memset(&id, 0, sizeof(id)); strcpy(id.name, name); id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; return snd_ctl_remove_id(card, &id); } -static snd_kcontrol_t __devinit *ctl_find(snd_card_t *card, const char *name) +static struct snd_kcontrol __devinit *ctl_find(struct snd_card *card, const char *name) { - snd_ctl_elem_id_t sid; + struct snd_ctl_elem_id sid; memset(&sid, 0, sizeof(sid)); /* FIXME: strcpy is bad. */ strcpy(sid.name, name); @@ -407,9 +412,9 @@ static snd_kcontrol_t __devinit *ctl_find(snd_card_t *card, const char *name) return snd_ctl_find_id(card, &sid); } -static int __devinit rename_ctl(snd_card_t *card, const char *src, const char *dst) +static int __devinit rename_ctl(struct snd_card *card, const char *src, const char *dst) { - snd_kcontrol_t *kctl = ctl_find(card, src); + struct snd_kcontrol *kctl = ctl_find(card, src); if (kctl) { strcpy(kctl->id.name, dst); return 0; @@ -417,10 +422,10 @@ static int __devinit rename_ctl(snd_card_t *card, const char *src, const char *d return -ENOENT; } -int __devinit snd_ca0106_mixer(ca0106_t *emu) +int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu) { int i, err; - snd_card_t *card = emu->card; + struct snd_card *card = emu->card; char **c; static char *ca0106_remove_ctls[] = { "Master Mono Playback Switch", diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c index 1c9cc82..94b6225 100644 --- a/sound/pci/ca0106/ca0106_proc.c +++ b/sound/pci/ca0106/ca0106_proc.c @@ -97,7 +97,7 @@ static struct snd_ca0106_category_str snd_ca0106_con_category[] = { }; -static void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value) +static void snd_ca0106_proc_dump_iec958( struct snd_info_buffer *buffer, u32 value) { int i; u32 status[4]; @@ -271,10 +271,10 @@ static void snd_ca0106_proc_dump_iec958( snd_info_buffer_t *buffer, u32 value) } } -static void snd_ca0106_proc_iec958(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_iec958(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; u32 value; value = snd_ca0106_ptr_read(emu, SAMPLE_RATE_TRACKER_STATUS, 0); @@ -293,10 +293,10 @@ static void snd_ca0106_proc_iec958(snd_info_entry_t *entry, snd_iprintf(buffer, "\n"); } -static void snd_ca0106_proc_reg_write32(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; unsigned long flags; char line[64]; u32 reg, val; @@ -311,10 +311,10 @@ static void snd_ca0106_proc_reg_write32(snd_info_entry_t *entry, } } -static void snd_ca0106_proc_reg_read32(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_reg_read32(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; unsigned long value; unsigned long flags; int i; @@ -327,10 +327,10 @@ static void snd_ca0106_proc_reg_read32(snd_info_entry_t *entry, } } -static void snd_ca0106_proc_reg_read16(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_reg_read16(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; unsigned int value; unsigned long flags; int i; @@ -343,10 +343,10 @@ static void snd_ca0106_proc_reg_read16(snd_info_entry_t *entry, } } -static void snd_ca0106_proc_reg_read8(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_reg_read8(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; unsigned int value; unsigned long flags; int i; @@ -359,10 +359,10 @@ static void snd_ca0106_proc_reg_read8(snd_info_entry_t *entry, } } -static void snd_ca0106_proc_reg_read1(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_reg_read1(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; unsigned long value; int i,j; @@ -377,10 +377,10 @@ static void snd_ca0106_proc_reg_read1(snd_info_entry_t *entry, } } -static void snd_ca0106_proc_reg_read2(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_reg_read2(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; unsigned long value; int i,j; @@ -395,10 +395,10 @@ static void snd_ca0106_proc_reg_read2(snd_info_entry_t *entry, } } -static void snd_ca0106_proc_reg_write(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_reg_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; char line[64]; unsigned int reg, channel_id , val; while (!snd_info_get_line(buffer, line, sizeof(line))) { @@ -409,10 +409,10 @@ static void snd_ca0106_proc_reg_write(snd_info_entry_t *entry, } } -static void snd_ca0106_proc_i2c_write(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ca0106_proc_i2c_write(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ca0106_t *emu = entry->private_data; + struct snd_ca0106 *emu = entry->private_data; char line[64]; unsigned int reg, val; while (!snd_info_get_line(buffer, line, sizeof(line))) { @@ -424,9 +424,9 @@ static void snd_ca0106_proc_i2c_write(snd_info_entry_t *entry, } } -int __devinit snd_ca0106_proc_init(ca0106_t * emu) +int __devinit snd_ca0106_proc_init(struct snd_ca0106 * emu) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if(! snd_card_proc_new(emu->card, "iec958", &entry)) snd_info_set_text_ops(entry, emu, 1024, snd_ca0106_proc_iec958); diff --git a/sound/pci/ca0106/ca_midi.c b/sound/pci/ca0106/ca_midi.c index 2e08b27..2e6eab1 100644 --- a/sound/pci/ca0106/ca_midi.c +++ b/sound/pci/ca0106/ca_midi.c @@ -40,18 +40,20 @@ #define ca_midi_input_avail(midi) (!(ca_midi_read_stat(midi) & midi->input_avail)) #define ca_midi_output_ready(midi) (!(ca_midi_read_stat(midi) & midi->output_ready)) -static void ca_midi_clear_rx(ca_midi_t *midi) +static void ca_midi_clear_rx(struct snd_ca_midi *midi) { int timeout = 100000; for (; timeout > 0 && ca_midi_input_avail(midi); timeout--) ca_midi_read_data(midi); #ifdef CONFIG_SND_DEBUG if (timeout <= 0) - snd_printk(KERN_ERR "ca_midi_clear_rx: timeout (status = 0x%x)\n", ca_midi_read_stat(midi)); + snd_printk(KERN_ERR "ca_midi_clear_rx: timeout (status = 0x%x)\n", + ca_midi_read_stat(midi)); #endif } -static void ca_midi_interrupt(ca_midi_t *midi, unsigned int status) { +static void ca_midi_interrupt(struct snd_ca_midi *midi, unsigned int status) +{ unsigned char byte; if (midi->rmidi == NULL) { @@ -86,7 +88,7 @@ static void ca_midi_interrupt(ca_midi_t *midi, unsigned int status) { } -static void ca_midi_cmd(ca_midi_t *midi, unsigned char cmd, int ack) +static void ca_midi_cmd(struct snd_ca_midi *midi, unsigned char cmd, int ack) { unsigned long flags; int timeout, ok; @@ -119,9 +121,9 @@ static void ca_midi_cmd(ca_midi_t *midi, unsigned char cmd, int ack) ca_midi_read_data(midi)); } -static int ca_midi_input_open(snd_rawmidi_substream_t * substream) +static int ca_midi_input_open(struct snd_rawmidi_substream *substream) { - ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data; + struct snd_ca_midi *midi = substream->rmidi->private_data; unsigned long flags; snd_assert(midi->dev_id, return -ENXIO); @@ -138,9 +140,9 @@ static int ca_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int ca_midi_output_open(snd_rawmidi_substream_t * substream) +static int ca_midi_output_open(struct snd_rawmidi_substream *substream) { - ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data; + struct snd_ca_midi *midi = substream->rmidi->private_data; unsigned long flags; snd_assert(midi->dev_id, return -ENXIO); @@ -157,9 +159,9 @@ static int ca_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int ca_midi_input_close(snd_rawmidi_substream_t * substream) +static int ca_midi_input_close(struct snd_rawmidi_substream *substream) { - ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data; + struct snd_ca_midi *midi = substream->rmidi->private_data; unsigned long flags; snd_assert(midi->dev_id, return -ENXIO); @@ -176,9 +178,9 @@ static int ca_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int ca_midi_output_close(snd_rawmidi_substream_t * substream) +static int ca_midi_output_close(struct snd_rawmidi_substream *substream) { - ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data; + struct snd_ca_midi *midi = substream->rmidi->private_data; unsigned long flags; snd_assert(midi->dev_id, return -ENXIO); @@ -197,9 +199,9 @@ static int ca_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void ca_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void ca_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data; + struct snd_ca_midi *midi = substream->rmidi->private_data; snd_assert(midi->dev_id, return); if (up) { @@ -209,9 +211,9 @@ static void ca_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) } } -static void ca_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void ca_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - ca_midi_t *midi = (ca_midi_t *)substream->rmidi->private_data; + struct snd_ca_midi *midi = substream->rmidi->private_data; unsigned long flags; snd_assert(midi->dev_id, return); @@ -246,21 +248,22 @@ static void ca_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) } } -static snd_rawmidi_ops_t ca_midi_output = +static struct snd_rawmidi_ops ca_midi_output = { .open = ca_midi_output_open, .close = ca_midi_output_close, .trigger = ca_midi_output_trigger, }; -static snd_rawmidi_ops_t ca_midi_input = +static struct snd_rawmidi_ops ca_midi_input = { .open = ca_midi_input_open, .close = ca_midi_input_close, .trigger = ca_midi_input_trigger, }; -static void ca_midi_free(ca_midi_t *midi) { +static void ca_midi_free(struct snd_ca_midi *midi) +{ midi->interrupt = NULL; midi->interrupt_enable = NULL; midi->interrupt_disable = NULL; @@ -271,14 +274,14 @@ static void ca_midi_free(ca_midi_t *midi) { midi->rmidi = NULL; } -static void ca_rmidi_free(snd_rawmidi_t *rmidi) +static void ca_rmidi_free(struct snd_rawmidi *rmidi) { - ca_midi_free((ca_midi_t *)rmidi->private_data); + ca_midi_free(rmidi->private_data); } -int __devinit ca_midi_init(void *dev_id, ca_midi_t *midi, int device, char *name) +int __devinit ca_midi_init(void *dev_id, struct snd_ca_midi *midi, int device, char *name) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if ((err = snd_rawmidi_new(midi->get_dev_id_card(midi->dev_id), name, device, 1, 1, &rmidi)) < 0) diff --git a/sound/pci/ca0106/ca_midi.h b/sound/pci/ca0106/ca_midi.h index b452cec..b72c093 100644 --- a/sound/pci/ca0106/ca_midi.h +++ b/sound/pci/ca0106/ca_midi.h @@ -29,12 +29,11 @@ #define CA_MIDI_MODE_INPUT MPU401_MODE_INPUT #define CA_MIDI_MODE_OUTPUT MPU401_MODE_OUTPUT -typedef struct ca_midi ca_midi_t; -struct ca_midi { +struct snd_ca_midi { - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *substream_input; - snd_rawmidi_substream_t *substream_output; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *substream_input; + struct snd_rawmidi_substream *substream_output; void *dev_id; @@ -52,18 +51,16 @@ struct ca_midi { int input_avail, output_ready; int ack, reset, enter_uart; - void (*interrupt)(ca_midi_t *midi, unsigned int status); - void (*interrupt_enable)(ca_midi_t *midi, int intr); - void (*interrupt_disable)(ca_midi_t *midi, int intr); + void (*interrupt)(struct snd_ca_midi *midi, unsigned int status); + void (*interrupt_enable)(struct snd_ca_midi *midi, int intr); + void (*interrupt_disable)(struct snd_ca_midi *midi, int intr); - unsigned char (*read)(ca_midi_t *midi, int idx); - void (*write)(ca_midi_t *midi, int data, int idx); + unsigned char (*read)(struct snd_ca_midi *midi, int idx); + void (*write)(struct snd_ca_midi *midi, int data, int idx); /* get info from dev_id */ - snd_card_t *(*get_dev_id_card)(void *dev_id); + struct snd_card *(*get_dev_id_card)(void *dev_id); int (*get_dev_id_port)(void *dev_id); }; -int __devinit ca_midi_init(void *card, ca_midi_t *midi, int device, char *name); - - +int ca_midi_init(void *card, struct snd_ca_midi *midi, int device, char *name); -- cgit v1.1 From d1fabd9cbc2f17b525a39adc16331443dddbb15b Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:56:03 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI ALI5451 Modules: ALI5451 driver Remove xxx_t typedefs from the PCI ALI5451 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ali5451/ali5451.c | 368 ++++++++++++++++++++++---------------------- 1 file changed, 183 insertions(+), 185 deletions(-) diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 21be4c2..2538cda 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -170,10 +170,10 @@ module_param(enable, bool, 0444); #define MAX_CODECS 2 -typedef struct snd_stru_ali ali_t; -typedef struct snd_ali_stru_voice snd_ali_voice_t; +struct snd_ali; +struct snd_ali_voice; -typedef struct snd_ali_channel_control { +struct snd_ali_channel_control { // register data struct REGDATA { unsigned int start; @@ -192,9 +192,9 @@ typedef struct snd_ali_channel_control { unsigned int ac97write; } regs; -} snd_ali_channel_control_t; +}; -struct snd_ali_stru_voice { +struct snd_ali_voice { unsigned int number; unsigned int use: 1, pcm: 1, @@ -203,9 +203,9 @@ struct snd_ali_stru_voice { synth: 1; /* PCM data */ - ali_t *codec; - snd_pcm_substream_t *substream; - snd_ali_voice_t *extra; + struct snd_ali *codec; + struct snd_pcm_substream *substream; + struct snd_ali_voice *extra; unsigned int running: 1; @@ -219,28 +219,28 @@ struct snd_ali_stru_voice { }; -typedef struct snd_stru_alidev { +struct snd_alidev { - snd_ali_voice_t voices[ALI_CHANNELS]; + struct snd_ali_voice voices[ALI_CHANNELS]; unsigned int chcnt; /* num of opened channels */ unsigned int chmap; /* bitmap for opened channels */ unsigned int synthcount; -} alidev_t; +}; #ifdef CONFIG_PM #define ALI_GLOBAL_REGS 56 #define ALI_CHANNEL_REGS 8 -typedef struct snd_ali_image { +struct snd_ali_image { unsigned long regs[ALI_GLOBAL_REGS]; unsigned long channel_regs[ALI_CHANNELS][ALI_CHANNEL_REGS]; -} ali_image_t; +}; #endif -struct snd_stru_ali { +struct snd_ali { unsigned long irq; unsigned long port; unsigned char revision; @@ -252,10 +252,10 @@ struct snd_stru_ali { struct pci_dev *pci_m1533; struct pci_dev *pci_m7101; - snd_card_t *card; - snd_pcm_t *pcm[MAX_CODECS]; - alidev_t synth; - snd_ali_channel_control_t chregs; + struct snd_card *card; + struct snd_pcm *pcm[MAX_CODECS]; + struct snd_alidev synth; + struct snd_ali_channel_control chregs; /* S/PDIF Mask */ unsigned int spdif_mask; @@ -265,8 +265,8 @@ struct snd_stru_ali { unsigned int num_of_codecs; - ac97_bus_t *ac97_bus; - ac97_t *ac97[MAX_CODECS]; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97[MAX_CODECS]; unsigned short ac97_ext_id; unsigned short ac97_ext_status; @@ -274,7 +274,7 @@ struct snd_stru_ali { spinlock_t voice_alloc; #ifdef CONFIG_PM - ali_image_t *image; + struct snd_ali_image *image; #endif }; @@ -284,9 +284,9 @@ static struct pci_device_id snd_ali_ids[] = { }; MODULE_DEVICE_TABLE(pci, snd_ali_ids); -static void snd_ali_clear_voices(ali_t *, unsigned int, unsigned int); -static unsigned short snd_ali_codec_peek(ali_t *, int, unsigned short); -static void snd_ali_codec_poke(ali_t *, int, unsigned short, unsigned short); +static void snd_ali_clear_voices(struct snd_ali *, unsigned int, unsigned int); +static unsigned short snd_ali_codec_peek(struct snd_ali *, int, unsigned short); +static void snd_ali_codec_poke(struct snd_ali *, int, unsigned short, unsigned short); /* * Debug Part @@ -294,7 +294,7 @@ static void snd_ali_codec_poke(ali_t *, int, unsigned short, unsigned short); #ifdef ALI_DEBUG -static void ali_read_regs(ali_t *codec, int channel) +static void ali_read_regs(struct snd_ali *codec, int channel) { int i,j; unsigned int dwVal; @@ -344,7 +344,7 @@ static void ali_read_cfg(unsigned int vendor, unsigned deviceid) } pci_dev_put(pci_dev); } -static void ali_read_ac97regs(ali_t *codec, int secondary) +static void ali_read_ac97regs(struct snd_ali *codec, int secondary) { unsigned short i,j; unsigned short wVal; @@ -373,20 +373,20 @@ static void ali_read_ac97regs(ali_t *codec, int secondary) * AC97 ACCESS */ -static inline unsigned int snd_ali_5451_peek(ali_t *codec, +static inline unsigned int snd_ali_5451_peek(struct snd_ali *codec, unsigned int port ) { return (unsigned int)inl(ALI_REG(codec, port)); } -static inline void snd_ali_5451_poke( ali_t *codec, +static inline void snd_ali_5451_poke( struct snd_ali *codec, unsigned int port, unsigned int val ) { outl((unsigned int)val, ALI_REG(codec, port)); } -static int snd_ali_codec_ready( ali_t *codec, +static int snd_ali_codec_ready( struct snd_ali *codec, unsigned int port ) { unsigned long end_time; @@ -404,7 +404,7 @@ static int snd_ali_codec_ready( ali_t *codec, return -EIO; } -static int snd_ali_stimer_ready(ali_t *codec) +static int snd_ali_stimer_ready(struct snd_ali *codec) { unsigned long end_time; unsigned long dwChk1,dwChk2; @@ -423,7 +423,7 @@ static int snd_ali_stimer_ready(ali_t *codec) return -EIO; } -static void snd_ali_codec_poke(ali_t *codec,int secondary, +static void snd_ali_codec_poke(struct snd_ali *codec,int secondary, unsigned short reg, unsigned short val) { @@ -452,7 +452,7 @@ static void snd_ali_codec_poke(ali_t *codec,int secondary, return ; } -static unsigned short snd_ali_codec_peek( ali_t *codec, +static unsigned short snd_ali_codec_peek( struct snd_ali *codec, int secondary, unsigned short reg) { @@ -485,11 +485,11 @@ static unsigned short snd_ali_codec_peek( ali_t *codec, return (snd_ali_5451_peek(codec, port) & 0xffff0000)>>16; } -static void snd_ali_codec_write(ac97_t *ac97, +static void snd_ali_codec_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val ) { - ali_t *codec = ac97->private_data; + struct snd_ali *codec = ac97->private_data; snd_ali_printk("codec_write: reg=%xh data=%xh.\n", reg, val); if(reg == AC97_GPIO_STATUS) { @@ -502,9 +502,9 @@ static void snd_ali_codec_write(ac97_t *ac97, } -static unsigned short snd_ali_codec_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_ali_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - ali_t *codec = ac97->private_data; + struct snd_ali *codec = ac97->private_data; snd_ali_printk("codec_read reg=%xh.\n", reg); return (snd_ali_codec_peek(codec, ac97->num, reg)); @@ -514,7 +514,7 @@ static unsigned short snd_ali_codec_read(ac97_t *ac97, unsigned short reg) * AC97 Reset */ -static int snd_ali_reset_5451(ali_t *codec) +static int snd_ali_reset_5451(struct snd_ali *codec) { struct pci_dev *pci_dev = NULL; unsigned short wCount, wReg; @@ -552,7 +552,7 @@ static int snd_ali_reset_5451(ali_t *codec) #ifdef CODEC_RESET -static int snd_ali_reset_codec(ali_t *codec) +static int snd_ali_reset_codec(struct snd_ali *codec) { struct pci_dev *pci_dev = NULL; unsigned char bVal = 0; @@ -593,7 +593,7 @@ static int snd_ali_reset_codec(ali_t *codec) * ALI 5451 Controller */ -static void snd_ali_enable_special_channel(ali_t *codec, unsigned int channel) +static void snd_ali_enable_special_channel(struct snd_ali *codec, unsigned int channel) { unsigned long dwVal = 0; @@ -602,7 +602,7 @@ static void snd_ali_enable_special_channel(ali_t *codec, unsigned int channel) outl(dwVal, ALI_REG(codec,ALI_GLOBAL_CONTROL)); } -static void snd_ali_disable_special_channel(ali_t *codec, unsigned int channel) +static void snd_ali_disable_special_channel(struct snd_ali *codec, unsigned int channel) { unsigned long dwVal = 0; @@ -611,7 +611,7 @@ static void snd_ali_disable_special_channel(ali_t *codec, unsigned int channel) outl(dwVal, ALI_REG(codec,ALI_GLOBAL_CONTROL)); } -static void snd_ali_enable_address_interrupt(ali_t * codec) +static void snd_ali_enable_address_interrupt(struct snd_ali * codec) { unsigned int gc; @@ -621,7 +621,7 @@ static void snd_ali_enable_address_interrupt(ali_t * codec) outl( gc, ALI_REG(codec, ALI_GC_CIR)); } -static void snd_ali_disable_address_interrupt(ali_t * codec) +static void snd_ali_disable_address_interrupt(struct snd_ali * codec) { unsigned int gc; @@ -632,10 +632,10 @@ static void snd_ali_disable_address_interrupt(ali_t * codec) } #if 0 // not used -static void snd_ali_enable_voice_irq(ali_t *codec, unsigned int channel) +static void snd_ali_enable_voice_irq(struct snd_ali *codec, unsigned int channel) { unsigned int mask; - snd_ali_channel_control_t *pchregs = &(codec->chregs); + struct snd_ali_channel_control *pchregs = &(codec->chregs); snd_ali_printk("enable_voice_irq channel=%d\n",channel); @@ -646,10 +646,10 @@ static void snd_ali_enable_voice_irq(ali_t *codec, unsigned int channel) } #endif -static void snd_ali_disable_voice_irq(ali_t *codec, unsigned int channel) +static void snd_ali_disable_voice_irq(struct snd_ali *codec, unsigned int channel) { unsigned int mask; - snd_ali_channel_control_t *pchregs = &(codec->chregs); + struct snd_ali_channel_control *pchregs = &(codec->chregs); snd_ali_printk("disable_voice_irq channel=%d\n",channel); @@ -659,7 +659,7 @@ static void snd_ali_disable_voice_irq(ali_t *codec, unsigned int channel) outl(pchregs->data.ainten,ALI_REG(codec,pchregs->regs.ainten)); } -static int snd_ali_alloc_pcm_channel(ali_t *codec, int channel) +static int snd_ali_alloc_pcm_channel(struct snd_ali *codec, int channel) { unsigned int idx = channel & 0x1f; @@ -677,7 +677,7 @@ static int snd_ali_alloc_pcm_channel(ali_t *codec, int channel) return -1; } -static int snd_ali_find_free_channel(ali_t * codec, int rec) +static int snd_ali_find_free_channel(struct snd_ali * codec, int rec) { int idx; int result = -1; @@ -719,7 +719,7 @@ static int snd_ali_find_free_channel(ali_t * codec, int rec) return -1; } -static void snd_ali_free_channel_pcm(ali_t *codec, int channel) +static void snd_ali_free_channel_pcm(struct snd_ali *codec, int channel) { unsigned int idx = channel & 0x0000001f; @@ -738,7 +738,7 @@ static void snd_ali_free_channel_pcm(ali_t *codec, int channel) } #if 0 // not used -static void snd_ali_start_voice(ali_t * codec, unsigned int channel) +static void snd_ali_start_voice(struct snd_ali * codec, unsigned int channel) { unsigned int mask = 1 << (channel & 0x1f); @@ -747,7 +747,7 @@ static void snd_ali_start_voice(ali_t * codec, unsigned int channel) } #endif -static void snd_ali_stop_voice(ali_t * codec, unsigned int channel) +static void snd_ali_stop_voice(struct snd_ali * codec, unsigned int channel) { unsigned int mask = 1 << (channel & 0x1f); @@ -759,7 +759,7 @@ static void snd_ali_stop_voice(ali_t * codec, unsigned int channel) * S/PDIF Part */ -static void snd_ali_delay(ali_t *codec,int interval) +static void snd_ali_delay(struct snd_ali *codec,int interval) { unsigned long begintimer,currenttimer; @@ -773,7 +773,7 @@ static void snd_ali_delay(ali_t *codec,int interval) } } -static void snd_ali_detect_spdif_rate(ali_t *codec) +static void snd_ali_detect_spdif_rate(struct snd_ali *codec) { u16 wval = 0; u16 count = 0; @@ -827,7 +827,7 @@ static void snd_ali_detect_spdif_rate(ali_t *codec) } } -static unsigned int snd_ali_get_spdif_in_rate(ali_t *codec) +static unsigned int snd_ali_get_spdif_in_rate(struct snd_ali *codec) { u32 dwRate = 0; u8 bval = 0; @@ -849,7 +849,7 @@ static unsigned int snd_ali_get_spdif_in_rate(ali_t *codec) return dwRate; } -static void snd_ali_enable_spdif_in(ali_t *codec) +static void snd_ali_enable_spdif_in(struct snd_ali *codec) { unsigned int dwVal; @@ -864,7 +864,7 @@ static void snd_ali_enable_spdif_in(ali_t *codec) snd_ali_enable_special_channel(codec, ALI_SPDIF_IN_CHANNEL); } -static void snd_ali_disable_spdif_in(ali_t *codec) +static void snd_ali_disable_spdif_in(struct snd_ali *codec) { unsigned int dwVal; @@ -876,7 +876,7 @@ static void snd_ali_disable_spdif_in(ali_t *codec) } -static void snd_ali_set_spdif_out_rate(ali_t *codec, unsigned int rate) +static void snd_ali_set_spdif_out_rate(struct snd_ali *codec, unsigned int rate) { unsigned char bVal; unsigned int dwRate = 0; @@ -897,7 +897,7 @@ static void snd_ali_set_spdif_out_rate(ali_t *codec, unsigned int rate) outw(rate | 0x10, ALI_REG(codec, ALI_SPDIF_CS + 2)); } -static void snd_ali_enable_spdif_out(ali_t *codec) +static void snd_ali_enable_spdif_out(struct snd_ali *codec) { unsigned short wVal; unsigned char bVal; @@ -933,7 +933,7 @@ static void snd_ali_enable_spdif_out(ali_t *codec) } } -static void snd_ali_enable_spdif_chnout(ali_t *codec) +static void snd_ali_enable_spdif_chnout(struct snd_ali *codec) { unsigned short wVal = 0; @@ -951,7 +951,7 @@ static void snd_ali_enable_spdif_chnout(ali_t *codec) snd_ali_enable_special_channel(codec,ALI_SPDIF_OUT_CHANNEL); } -static void snd_ali_disable_spdif_chnout(ali_t *codec) +static void snd_ali_disable_spdif_chnout(struct snd_ali *codec) { unsigned short wVal = 0; wVal = inw(ALI_REG(codec, ALI_GLOBAL_CONTROL)); @@ -961,7 +961,7 @@ static void snd_ali_disable_spdif_chnout(ali_t *codec) snd_ali_enable_special_channel(codec, ALI_SPDIF_OUT_CHANNEL); } -static void snd_ali_disable_spdif_out(ali_t *codec) +static void snd_ali_disable_spdif_out(struct snd_ali *codec) { unsigned char bVal; @@ -971,11 +971,11 @@ static void snd_ali_disable_spdif_out(ali_t *codec) snd_ali_disable_spdif_chnout(codec); } -static void snd_ali_update_ptr(ali_t *codec,int channel) +static void snd_ali_update_ptr(struct snd_ali *codec,int channel) { - snd_ali_voice_t *pvoice = NULL; - snd_pcm_runtime_t *runtime; - snd_ali_channel_control_t *pchregs = NULL; + struct snd_ali_voice *pvoice = NULL; + struct snd_pcm_runtime *runtime; + struct snd_ali_channel_control *pchregs = NULL; unsigned int old, mask; #ifdef ALI_DEBUG unsigned int temp, cspf; @@ -1026,11 +1026,11 @@ static void snd_ali_update_ptr(ali_t *codec,int channel) pchregs->data.aint = old & (~mask); } -static void snd_ali_interrupt(ali_t * codec) +static void snd_ali_interrupt(struct snd_ali * codec) { int channel; unsigned int audio_int; - snd_ali_channel_control_t *pchregs = NULL; + struct snd_ali_channel_control *pchregs = NULL; pchregs = &(codec->chregs); audio_int = inl(ALI_REG(codec, ALI_MISCINT)); @@ -1050,7 +1050,7 @@ static irqreturn_t snd_ali_card_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ali_t *codec = dev_id; + struct snd_ali *codec = dev_id; if (codec == NULL) return IRQ_NONE; @@ -1059,9 +1059,9 @@ static irqreturn_t snd_ali_card_interrupt(int irq, } -static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec, int channel) +static struct snd_ali_voice *snd_ali_alloc_voice(struct snd_ali * codec, int type, int rec, int channel) { - snd_ali_voice_t *pvoice = NULL; + struct snd_ali_voice *pvoice = NULL; int idx; snd_ali_printk("alloc_voice: type=%d rec=%d\n",type,rec); @@ -1088,7 +1088,7 @@ static snd_ali_voice_t *snd_ali_alloc_voice(ali_t * codec, int type, int rec, in } -static void snd_ali_free_voice(ali_t * codec, snd_ali_voice_t *pvoice) +static void snd_ali_free_voice(struct snd_ali * codec, struct snd_ali_voice *pvoice) { void (*private_free)(void *); void *private_data; @@ -1113,7 +1113,7 @@ static void snd_ali_free_voice(ali_t * codec, snd_ali_voice_t *pvoice) } -static void snd_ali_clear_voices(ali_t * codec, +static void snd_ali_clear_voices(struct snd_ali * codec, unsigned int v_min, unsigned int v_max) { @@ -1125,7 +1125,7 @@ static void snd_ali_clear_voices(ali_t * codec, } } -static void snd_ali_write_voice_regs(ali_t * codec, +static void snd_ali_write_voice_regs(struct snd_ali * codec, unsigned int Channel, unsigned int LBA, unsigned int CSO, @@ -1192,10 +1192,10 @@ static unsigned int snd_ali_convert_rate(unsigned int rate, int rec) return delta; } -static unsigned int snd_ali_control_mode(snd_pcm_substream_t *substream) +static unsigned int snd_ali_control_mode(struct snd_pcm_substream *substream) { unsigned int CTRL; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; /* set ctrl mode CTRL default: 8-bit (unsigned) mono, loop mode enabled @@ -1214,21 +1214,21 @@ static unsigned int snd_ali_control_mode(snd_pcm_substream_t *substream) * PCM part */ -static int snd_ali_ioctl(snd_pcm_substream_t * substream, +static int snd_ali_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { return snd_pcm_lib_ioctl(substream, cmd, arg); } -static int snd_ali_trigger(snd_pcm_substream_t *substream, +static int snd_ali_trigger(struct snd_pcm_substream *substream, int cmd) { - ali_t *codec = snd_pcm_substream_chip(substream); + struct snd_ali *codec = snd_pcm_substream_chip(substream); struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; unsigned int what, whati, capture_flag; - snd_ali_voice_t *pvoice = NULL, *evoice = NULL; + struct snd_ali_voice *pvoice = NULL, *evoice = NULL; unsigned int val; int do_start; @@ -1246,8 +1246,8 @@ static int snd_ali_trigger(snd_pcm_substream_t *substream, what = whati = capture_flag = 0; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); - if ((ali_t *) snd_pcm_substream_chip(s) == codec) { - pvoice = (snd_ali_voice_t *) s->runtime->private_data; + if ((struct snd_ali *) snd_pcm_substream_chip(s) == codec) { + pvoice = s->runtime->private_data; evoice = pvoice->extra; what |= 1 << (pvoice->number & 0x1f); if (evoice == NULL) { @@ -1290,13 +1290,13 @@ static int snd_ali_trigger(snd_pcm_substream_t *substream, return 0; } -static int snd_ali_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ali_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ali_t *codec = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; - snd_ali_voice_t *evoice = pvoice->extra; + struct snd_ali *codec = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ali_voice *pvoice = runtime->private_data; + struct snd_ali_voice *evoice = pvoice->extra; int err; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); if (err < 0) return err; @@ -1321,12 +1321,12 @@ static int snd_ali_playback_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_ali_playback_hw_free(snd_pcm_substream_t * substream) +static int snd_ali_playback_hw_free(struct snd_pcm_substream *substream) { - ali_t *codec = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; - snd_ali_voice_t *evoice = pvoice ? pvoice->extra : NULL; + struct snd_ali *codec = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ali_voice *pvoice = runtime->private_data; + struct snd_ali_voice *evoice = pvoice ? pvoice->extra : NULL; snd_pcm_lib_free_pages(substream); if (evoice != NULL) { @@ -1336,23 +1336,23 @@ static int snd_ali_playback_hw_free(snd_pcm_substream_t * substream) return 0; } -static int snd_ali_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ali_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_ali_hw_free(snd_pcm_substream_t * substream) +static int snd_ali_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ali_playback_prepare(snd_pcm_substream_t * substream) +static int snd_ali_playback_prepare(struct snd_pcm_substream *substream) { - ali_t *codec = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; - snd_ali_voice_t *evoice = pvoice->extra; + struct snd_ali *codec = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ali_voice *pvoice = runtime->private_data; + struct snd_ali_voice *evoice = pvoice->extra; unsigned int LBA; unsigned int Delta; @@ -1435,11 +1435,11 @@ static int snd_ali_playback_prepare(snd_pcm_substream_t * substream) } -static int snd_ali_prepare(snd_pcm_substream_t * substream) +static int snd_ali_prepare(struct snd_pcm_substream *substream) { - ali_t *codec = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; + struct snd_ali *codec = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ali_voice *pvoice = runtime->private_data; unsigned int LBA; unsigned int Delta; unsigned int ESO; @@ -1522,11 +1522,11 @@ static int snd_ali_prepare(snd_pcm_substream_t * substream) } -static snd_pcm_uframes_t snd_ali_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_ali_playback_pointer(struct snd_pcm_substream *substream) { - ali_t *codec = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; + struct snd_ali *codec = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ali_voice *pvoice = runtime->private_data; unsigned int cso; spin_lock(&codec->reg_lock); @@ -1543,11 +1543,11 @@ static snd_pcm_uframes_t snd_ali_playback_pointer(snd_pcm_substream_t *substream } -static snd_pcm_uframes_t snd_ali_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_ali_pointer(struct snd_pcm_substream *substream) { - ali_t *codec = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; + struct snd_ali *codec = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ali_voice *pvoice = runtime->private_data; unsigned int cso; spin_lock(&codec->reg_lock); @@ -1562,7 +1562,7 @@ static snd_pcm_uframes_t snd_ali_pointer(snd_pcm_substream_t *substream) return cso; } -static snd_pcm_hardware_t snd_ali_playback = +static struct snd_pcm_hardware snd_ali_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1588,7 +1588,7 @@ static snd_pcm_hardware_t snd_ali_playback = * Capture support device description */ -static snd_pcm_hardware_t snd_ali_capture = +static struct snd_pcm_hardware snd_ali_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1610,10 +1610,10 @@ static snd_pcm_hardware_t snd_ali_capture = .fifo_size = 0, }; -static void snd_ali_pcm_free_substream(snd_pcm_runtime_t *runtime) +static void snd_ali_pcm_free_substream(struct snd_pcm_runtime *runtime) { - snd_ali_voice_t *pvoice = (snd_ali_voice_t *) runtime->private_data; - ali_t *codec; + struct snd_ali_voice *pvoice = runtime->private_data; + struct snd_ali *codec; if (pvoice) { codec = pvoice->codec; @@ -1621,12 +1621,12 @@ static void snd_ali_pcm_free_substream(snd_pcm_runtime_t *runtime) } } -static int snd_ali_open(snd_pcm_substream_t * substream, int rec, int channel, - snd_pcm_hardware_t *phw) +static int snd_ali_open(struct snd_pcm_substream *substream, int rec, int channel, + struct snd_pcm_hardware *phw) { - ali_t *codec = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_ali_voice_t *pvoice; + struct snd_ali *codec = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ali_voice *pvoice; pvoice = snd_ali_alloc_voice(codec, SNDRV_ALI_VOICE_TYPE_PCM, rec, channel); if (pvoice == NULL) @@ -1642,32 +1642,32 @@ static int snd_ali_open(snd_pcm_substream_t * substream, int rec, int channel, return 0; } -static int snd_ali_playback_open(snd_pcm_substream_t * substream) +static int snd_ali_playback_open(struct snd_pcm_substream *substream) { return snd_ali_open(substream, 0, -1, &snd_ali_playback); } -static int snd_ali_capture_open(snd_pcm_substream_t * substream) +static int snd_ali_capture_open(struct snd_pcm_substream *substream) { return snd_ali_open(substream, 1, -1, &snd_ali_capture); } -static int snd_ali_playback_close(snd_pcm_substream_t * substream) +static int snd_ali_playback_close(struct snd_pcm_substream *substream) { return 0; } -static int snd_ali_close(snd_pcm_substream_t * substream) +static int snd_ali_close(struct snd_pcm_substream *substream) { - ali_t *codec = snd_pcm_substream_chip(substream); - snd_ali_voice_t *pvoice = (snd_ali_voice_t *) substream->runtime->private_data; + struct snd_ali *codec = snd_pcm_substream_chip(substream); + struct snd_ali_voice *pvoice = substream->runtime->private_data; snd_ali_disable_special_channel(codec,pvoice->number); return 0; } -static snd_pcm_ops_t snd_ali_playback_ops = { +static struct snd_pcm_ops snd_ali_playback_ops = { .open = snd_ali_playback_open, .close = snd_ali_playback_close, .ioctl = snd_ali_ioctl, @@ -1678,7 +1678,7 @@ static snd_pcm_ops_t snd_ali_playback_ops = { .pointer = snd_ali_playback_pointer, }; -static snd_pcm_ops_t snd_ali_capture_ops = { +static struct snd_pcm_ops snd_ali_capture_ops = { .open = snd_ali_capture_open, .close = snd_ali_close, .ioctl = snd_ali_ioctl, @@ -1693,17 +1693,17 @@ static snd_pcm_ops_t snd_ali_capture_ops = { * Modem PCM */ -static int snd_ali_modem_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ali_modem_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ali_t *chip = snd_pcm_substream_chip(substream); + struct snd_ali *chip = snd_pcm_substream_chip(substream); unsigned int modem_num = chip->num_of_codecs - 1; snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_RATE, params_rate(hw_params)); snd_ac97_write(chip->ac97[modem_num], AC97_LINE1_LEVEL, 0); return snd_ali_hw_params(substream, hw_params); } -static snd_pcm_hardware_t snd_ali_modem = +static struct snd_pcm_hardware snd_ali_modem = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1724,10 +1724,10 @@ static snd_pcm_hardware_t snd_ali_modem = .fifo_size = 0, }; -static int snd_ali_modem_open(snd_pcm_substream_t * substream, int rec, int channel) +static int snd_ali_modem_open(struct snd_pcm_substream *substream, int rec, int channel) { static unsigned int rates [] = {8000,9600,12000,16000}; - static snd_pcm_hw_constraint_list_t hw_constraint_rates = { + static struct snd_pcm_hw_constraint_list hw_constraint_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, @@ -1739,17 +1739,17 @@ static int snd_ali_modem_open(snd_pcm_substream_t * substream, int rec, int chan SNDRV_PCM_HW_PARAM_RATE, &hw_constraint_rates); } -static int snd_ali_modem_playback_open(snd_pcm_substream_t * substream) +static int snd_ali_modem_playback_open(struct snd_pcm_substream *substream) { return snd_ali_modem_open(substream, 0, ALI_MODEM_OUT_CHANNEL); } -static int snd_ali_modem_capture_open(snd_pcm_substream_t * substream) +static int snd_ali_modem_capture_open(struct snd_pcm_substream *substream) { return snd_ali_modem_open(substream, 1, ALI_MODEM_IN_CHANNEL); } -static snd_pcm_ops_t snd_ali_modem_playback_ops = { +static struct snd_pcm_ops snd_ali_modem_playback_ops = { .open = snd_ali_modem_playback_open, .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, @@ -1760,7 +1760,7 @@ static snd_pcm_ops_t snd_ali_modem_playback_ops = { .pointer = snd_ali_pointer, }; -static snd_pcm_ops_t snd_ali_modem_capture_ops = { +static struct snd_pcm_ops snd_ali_modem_capture_ops = { .open = snd_ali_modem_capture_open, .close = snd_ali_close, .ioctl = snd_pcm_lib_ioctl, @@ -1776,22 +1776,22 @@ struct ali_pcm_description { char *name; unsigned int playback_num; unsigned int capture_num; - snd_pcm_ops_t *playback_ops; - snd_pcm_ops_t *capture_ops; + struct snd_pcm_ops *playback_ops; + struct snd_pcm_ops *capture_ops; unsigned short class; }; -static void snd_ali_pcm_free(snd_pcm_t *pcm) +static void snd_ali_pcm_free(struct snd_pcm *pcm) { - ali_t *codec = pcm->private_data; + struct snd_ali *codec = pcm->private_data; codec->pcm[pcm->device] = NULL; } -static int __devinit snd_ali_pcm(ali_t * codec, int device, struct ali_pcm_description *desc) +static int __devinit snd_ali_pcm(struct snd_ali * codec, int device, struct ali_pcm_description *desc) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; err = snd_pcm_new(codec->card, desc->name, device, @@ -1823,7 +1823,7 @@ static struct ali_pcm_description ali_pcms[] = { { "ALI 5451 modem", 1, 1, &snd_ali_modem_playback_ops, &snd_ali_modem_capture_ops, SNDRV_PCM_CLASS_MODEM } }; -static int __devinit snd_ali_build_pcms(ali_t *codec) +static int __devinit snd_ali_build_pcms(struct snd_ali *codec) { int i, err; for(i = 0 ; i < codec->num_of_codecs && i < ARRAY_SIZE(ali_pcms) ; i++) @@ -1838,7 +1838,7 @@ static int __devinit snd_ali_build_pcms(ali_t *codec) .info = snd_ali5451_spdif_info, .get = snd_ali5451_spdif_get, \ .put = snd_ali5451_spdif_put, .private_value = value} -static int snd_ali5451_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ali5451_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1847,9 +1847,9 @@ static int snd_ali5451_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_ali5451_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ali5451_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ali_t *codec = kcontrol->private_data; + struct snd_ali *codec = kcontrol->private_data; unsigned int enable; enable = ucontrol->value.integer.value[0] ? 1 : 0; @@ -1873,9 +1873,9 @@ static int snd_ali5451_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_ali5451_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ali5451_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ali_t *codec = kcontrol->private_data; + struct snd_ali *codec = kcontrol->private_data; unsigned int change = 0, enable = 0; enable = ucontrol->value.integer.value[0] ? 1 : 0; @@ -1930,7 +1930,7 @@ static int snd_ali5451_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_ali5451_mixer_spdif[] __devinitdata = { +static struct snd_kcontrol_new snd_ali5451_mixer_spdif[] __devinitdata = { /* spdif aplayback switch */ /* FIXME: "IEC958 Playback Switch" may conflict with one on ac97_codec */ ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), 0, 0), @@ -1940,24 +1940,24 @@ static snd_kcontrol_new_t snd_ali5451_mixer_spdif[] __devinitdata = { ALI5451_SPDIF(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 0, 2) }; -static void snd_ali_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_ali_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - ali_t *codec = bus->private_data; + struct snd_ali *codec = bus->private_data; codec->ac97_bus = NULL; } -static void snd_ali_mixer_free_ac97(ac97_t *ac97) +static void snd_ali_mixer_free_ac97(struct snd_ac97 *ac97) { - ali_t *codec = ac97->private_data; + struct snd_ali *codec = ac97->private_data; codec->ac97[ac97->num] = NULL; } -static int __devinit snd_ali_mixer(ali_t * codec) +static int __devinit snd_ali_mixer(struct snd_ali * codec) { - ac97_template_t ac97; + struct snd_ac97_template ac97; unsigned int idx; int i, err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_ali_codec_write, .read = snd_ali_codec_read, }; @@ -1991,10 +1991,10 @@ static int __devinit snd_ali_mixer(ali_t * codec) } #ifdef CONFIG_PM -static int ali_suspend(snd_card_t *card, pm_message_t state) +static int ali_suspend(struct snd_card *card, pm_message_t state) { - ali_t *chip = card->pm_private_data; - ali_image_t *im; + struct snd_ali *chip = card->pm_private_data; + struct snd_ali_image *im; int i, j; im = chip->image; @@ -2037,10 +2037,10 @@ static int ali_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int ali_resume(snd_card_t *card) +static int ali_resume(struct snd_card *card) { - ali_t *chip = card->pm_private_data; - ali_image_t *im; + struct snd_ali *chip = card->pm_private_data; + struct snd_ali_image *im; int i, j; im = chip->image; @@ -2078,7 +2078,7 @@ static int ali_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -static int snd_ali_free(ali_t * codec) +static int snd_ali_free(struct snd_ali * codec) { if (codec->hw_initialized) snd_ali_disable_address_interrupt(codec); @@ -2098,7 +2098,7 @@ static int snd_ali_free(ali_t * codec) return 0; } -static int snd_ali_chip_init(ali_t *codec) +static int snd_ali_chip_init(struct snd_ali *codec) { unsigned int legacy; unsigned char temp; @@ -2157,22 +2157,22 @@ static int snd_ali_chip_init(ali_t *codec) } /* proc for register dump */ -static void snd_ali_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buf) +static void snd_ali_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) { - ali_t *codec = entry->private_data; + struct snd_ali *codec = entry->private_data; int i; for(i = 0 ; i < 256 ; i+= 4) snd_iprintf(buf, "%02x: %08x\n", i, inl(ALI_REG(codec, i))); } -static void __devinit snd_ali_proc_init(ali_t *codec) +static void __devinit snd_ali_proc_init(struct snd_ali *codec) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if(!snd_card_proc_new(codec->card, "ali5451", &entry)) snd_info_set_text_ops(entry, codec, 1024, snd_ali_proc_read); } -static int __devinit snd_ali_resources(ali_t *codec) +static int __devinit snd_ali_resources(struct snd_ali *codec) { int err; @@ -2189,27 +2189,25 @@ static int __devinit snd_ali_resources(ali_t *codec) snd_ali_printk("resouces allocated.\n"); return 0; } -static int snd_ali_dev_free(snd_device_t *device) +static int snd_ali_dev_free(struct snd_device *device) { - ali_t *codec=device->device_data; + struct snd_ali *codec=device->device_data; snd_ali_free(codec); return 0; } -static int __devinit snd_ali_create(snd_card_t * card, +static int __devinit snd_ali_create(struct snd_card *card, struct pci_dev *pci, int pcm_streams, int spdif_support, - ali_t ** r_ali) + struct snd_ali ** r_ali) { - ali_t *codec; + struct snd_ali *codec; int i, err; unsigned short cmdw = 0; struct pci_dev *pci_dev = NULL; - static snd_device_ops_t ops = { - (snd_dev_free_t *)snd_ali_dev_free, - NULL, - NULL + static struct snd_device_ops ops = { + .dev_free = snd_ali_dev_free, }; *r_ali = NULL; @@ -2334,8 +2332,8 @@ static int __devinit snd_ali_create(snd_card_t * card, static int __devinit snd_ali_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - ali_t *codec; + struct snd_card *card; + struct snd_ali *codec; int err; snd_ali_printk("probe ...\n"); -- cgit v1.1 From 66f8df6bdd388d209c38197785148c994c8a738d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:56:21 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI CS5535 Modules: CS5535 driver Remove xxx_t typedefs from the PCI CS5535 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/cs5535audio/cs5535audio.c | 74 +++++++++--------- sound/pci/cs5535audio/cs5535audio.h | 44 +++++------ sound/pci/cs5535audio/cs5535audio_pcm.c | 128 ++++++++++++++++---------------- 3 files changed, 123 insertions(+), 123 deletions(-) diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 3f4379d..1899356 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -53,7 +53,7 @@ static struct pci_device_id snd_cs5535audio_ids[] = { MODULE_DEVICE_TABLE(pci, snd_cs5535audio_ids); -static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout) +static void wait_till_cmd_acked(struct cs5535audio *cs5535au, unsigned long timeout) { unsigned int tmp; do { @@ -66,11 +66,11 @@ static void wait_till_cmd_acked(cs5535audio_t *cs5535au, unsigned long timeout) snd_printk(KERN_ERR "Failure writing to cs5535 codec\n"); } -static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au, - unsigned short reg) +static unsigned short snd_cs5535audio_codec_read(struct cs5535audio *cs5535au, + unsigned short reg) { unsigned int regdata; - int timeout; + unsigned int timeout; unsigned int val; regdata = ((unsigned int) reg) << 24; @@ -93,8 +93,8 @@ static unsigned short snd_cs5535audio_codec_read(cs5535audio_t *cs5535au, return (unsigned short) val; } -static void snd_cs5535audio_codec_write(cs5535audio_t *cs5535au, - unsigned short reg, unsigned short val) +static void snd_cs5535audio_codec_write(struct cs5535audio *cs5535au, + unsigned short reg, unsigned short val) { unsigned int regdata; @@ -108,27 +108,27 @@ static void snd_cs5535audio_codec_write(cs5535audio_t *cs5535au, wait_till_cmd_acked(cs5535au, 50); } -static void snd_cs5535audio_ac97_codec_write(ac97_t *ac97, - unsigned short reg, unsigned short val) +static void snd_cs5535audio_ac97_codec_write(struct snd_ac97 *ac97, + unsigned short reg, unsigned short val) { - cs5535audio_t *cs5535au = ac97->private_data; + struct cs5535audio *cs5535au = ac97->private_data; snd_cs5535audio_codec_write(cs5535au, reg, val); } -static unsigned short snd_cs5535audio_ac97_codec_read(ac97_t *ac97, - unsigned short reg) +static unsigned short snd_cs5535audio_ac97_codec_read(struct snd_ac97 *ac97, + unsigned short reg) { - cs5535audio_t *cs5535au = ac97->private_data; + struct cs5535audio *cs5535au = ac97->private_data; return snd_cs5535audio_codec_read(cs5535au, reg); } -static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au) +static int snd_cs5535audio_mixer(struct cs5535audio *cs5535au) { - snd_card_t *card = cs5535au->card; - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_card *card = cs5535au->card; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_cs5535audio_ac97_codec_write, .read = snd_cs5535audio_ac97_codec_read, }; @@ -149,14 +149,14 @@ static int snd_cs5535audio_mixer(cs5535audio_t *cs5535au) return 0; } -static void process_bm0_irq(cs5535audio_t *cs5535au) +static void process_bm0_irq(struct cs5535audio *cs5535au) { u8 bm_stat; spin_lock(&cs5535au->reg_lock); bm_stat = cs_readb(cs5535au, ACC_BM0_STATUS); spin_unlock(&cs5535au->reg_lock); if (bm_stat & EOP) { - cs5535audio_dma_t *dma; + struct cs5535audio_dma *dma; dma = cs5535au->playback_substream->runtime->private_data; snd_pcm_period_elapsed(cs5535au->playback_substream); } else { @@ -165,26 +165,26 @@ static void process_bm0_irq(cs5535audio_t *cs5535au) } } -static void process_bm1_irq(cs5535audio_t *cs5535au) +static void process_bm1_irq(struct cs5535audio *cs5535au) { u8 bm_stat; spin_lock(&cs5535au->reg_lock); bm_stat = cs_readb(cs5535au, ACC_BM1_STATUS); spin_unlock(&cs5535au->reg_lock); if (bm_stat & EOP) { - cs5535audio_dma_t *dma; + struct cs5535audio_dma *dma; dma = cs5535au->capture_substream->runtime->private_data; snd_pcm_period_elapsed(cs5535au->capture_substream); } } static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id, - struct pt_regs *regs) + struct pt_regs *regs) { u16 acc_irq_stat; u8 bm_stat; unsigned char count; - cs5535audio_t *cs5535au = dev_id; + struct cs5535audio *cs5535au = dev_id; if (cs5535au == NULL) return IRQ_NONE; @@ -235,7 +235,7 @@ static irqreturn_t snd_cs5535audio_interrupt(int irq, void *dev_id, return IRQ_HANDLED; } -static int snd_cs5535audio_free(cs5535audio_t *cs5535au) +static int snd_cs5535audio_free(struct cs5535audio *cs5535au) { synchronize_irq(cs5535au->irq); pci_set_power_state(cs5535au->pci, 3); @@ -249,20 +249,20 @@ static int snd_cs5535audio_free(cs5535audio_t *cs5535au) return 0; } -static int snd_cs5535audio_dev_free(snd_device_t *device) +static int snd_cs5535audio_dev_free(struct snd_device *device) { - cs5535audio_t *cs5535au = device->device_data; + struct cs5535audio *cs5535au = device->device_data; return snd_cs5535audio_free(cs5535au); } -static int __devinit snd_cs5535audio_create(snd_card_t *card, - struct pci_dev *pci, - cs5535audio_t **rcs5535au) +static int __devinit snd_cs5535audio_create(struct snd_card *card, + struct pci_dev *pci, + struct cs5535audio **rcs5535au) { - cs5535audio_t *cs5535au; + struct cs5535audio *cs5535au; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_cs5535audio_dev_free, }; @@ -271,7 +271,7 @@ static int __devinit snd_cs5535audio_create(snd_card_t *card, return err; if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 || - pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { + pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { printk(KERN_WARNING "unable to get 32bit dma\n"); err = -ENXIO; goto pcifail; @@ -296,7 +296,7 @@ static int __devinit snd_cs5535audio_create(snd_card_t *card, cs5535au->port = pci_resource_start(pci, 0); if (request_irq(pci->irq, snd_cs5535audio_interrupt, - SA_INTERRUPT|SA_SHIRQ, "CS5535 Audio", cs5535au)) { + SA_INTERRUPT|SA_SHIRQ, "CS5535 Audio", cs5535au)) { snd_printk("unable to grab IRQ %d\n", pci->irq); err = -EBUSY; goto sndfail; @@ -306,7 +306,7 @@ static int __devinit snd_cs5535audio_create(snd_card_t *card, pci_set_master(pci); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, - cs5535au, &ops)) < 0) + cs5535au, &ops)) < 0) goto sndfail; snd_card_set_dev(card, &pci->dev); @@ -324,11 +324,11 @@ pcifail: } static int __devinit snd_cs5535audio_probe(struct pci_dev *pci, - const struct pci_device_id *pci_id) + const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - cs5535audio_t *cs5535au; + struct snd_card *card; + struct cs5535audio *cs5535au; int err; if (dev >= SNDRV_CARDS) diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 774185e..5e55a1a 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h @@ -78,46 +78,46 @@ #define PRD_EOP 0x4000 #define PRD_EOT 0x8000 -typedef struct _snd_cs5535audio cs5535audio_t; -typedef struct snd_cs5535audio_dma cs5535audio_dma_t; -typedef struct snd_cs5535audio_dma_ops cs5535audio_dma_ops_t; - enum { CS5535AUDIO_DMA_PLAYBACK, CS5535AUDIO_DMA_CAPTURE, NUM_CS5535AUDIO_DMAS }; -struct snd_cs5535audio_dma_ops { + +struct cs5535audio; + +struct cs5535audio_dma_ops { int type; - void (*enable_dma)(cs5535audio_t *cs5535au); - void (*disable_dma)(cs5535audio_t *cs5535au); - void (*pause_dma)(cs5535audio_t *cs5535au); - void (*setup_prd)(cs5535audio_t *cs5535au, u32 prd_addr); - u32 (*read_dma_pntr)(cs5535audio_t *cs5535au); + void (*enable_dma)(struct cs5535audio *cs5535au); + void (*disable_dma)(struct cs5535audio *cs5535au); + void (*pause_dma)(struct cs5535audio *cs5535au); + void (*setup_prd)(struct cs5535audio *cs5535au, u32 prd_addr); + u32 (*read_dma_pntr)(struct cs5535audio *cs5535au); }; -typedef struct cs5535audio_dma_desc { +struct cs5535audio_dma_desc { u32 addr; u16 size; u16 ctlreserved; -} cs5535audio_dma_desc_t; +}; -struct snd_cs5535audio_dma { - const cs5535audio_dma_ops_t *ops; +struct cs5535audio_dma { + const struct cs5535audio_dma_ops *ops; struct snd_dma_buffer desc_buf; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; unsigned int buf_addr, buf_bytes; unsigned int period_bytes, periods; }; -struct _snd_cs5535audio { - snd_card_t *card; - ac97_t *ac97; +struct cs5535audio { + struct snd_card *card; + struct snd_ac97 *ac97; int irq; struct pci_dev *pci; unsigned long port; spinlock_t reg_lock; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; - cs5535audio_dma_t dmas[NUM_CS5535AUDIO_DMAS]; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; + struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS]; }; -int __devinit snd_cs5535audio_pcm(cs5535audio_t *cs5535audio); +int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio); + #endif /* __SOUND_CS5535AUDIO_H */ diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index d32b23f2..60bb82b 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c @@ -35,7 +35,7 @@ #include <sound/ac97_codec.h> #include "cs5535audio.h" -static snd_pcm_hardware_t snd_cs5535audio_playback = +static struct snd_pcm_hardware snd_cs5535audio_playback = { .info = ( SNDRV_PCM_INFO_MMAP | @@ -64,7 +64,7 @@ static snd_pcm_hardware_t snd_cs5535audio_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_cs5535audio_capture = +static struct snd_pcm_hardware snd_cs5535audio_capture = { .info = ( SNDRV_PCM_INFO_MMAP | @@ -92,11 +92,11 @@ static snd_pcm_hardware_t snd_cs5535audio_capture = .fifo_size = 0, }; -static int snd_cs5535audio_playback_open(snd_pcm_substream_t *substream) +static int snd_cs5535audio_playback_open(struct snd_pcm_substream *substream) { int err; - cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; runtime->hw = snd_cs5535audio_playback; cs5535au->playback_substream = substream; @@ -109,23 +109,23 @@ static int snd_cs5535audio_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_cs5535audio_playback_close(snd_pcm_substream_t *substream) +static int snd_cs5535audio_playback_close(struct snd_pcm_substream *substream) { return 0; } #define CS5535AUDIO_DESC_LIST_SIZE \ - PAGE_ALIGN(CS5535AUDIO_MAX_DESCRIPTORS * sizeof(cs5535audio_dma_desc_t)) + PAGE_ALIGN(CS5535AUDIO_MAX_DESCRIPTORS * sizeof(struct cs5535audio_dma_desc)) -static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au, - cs5535audio_dma_t *dma, - snd_pcm_substream_t *substream, - unsigned int periods, - unsigned int period_bytes) +static int cs5535audio_build_dma_packets(struct cs5535audio *cs5535au, + struct cs5535audio_dma *dma, + struct snd_pcm_substream *substream, + unsigned int periods, + unsigned int period_bytes) { unsigned int i; u32 addr, desc_addr, jmpprd_addr; - cs5535audio_dma_desc_t *lastdesc; + struct cs5535audio_dma_desc *lastdesc; if (periods > CS5535AUDIO_MAX_DESCRIPTORS) return -ENOMEM; @@ -147,21 +147,21 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au, addr = (u32) substream->runtime->dma_addr; desc_addr = (u32) dma->desc_buf.addr; for (i = 0; i < periods; i++) { - cs5535audio_dma_desc_t *desc = - &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[i]; + struct cs5535audio_dma_desc *desc = + &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[i]; desc->addr = cpu_to_le32(addr); desc->size = cpu_to_le32(period_bytes); desc->ctlreserved = cpu_to_le32(PRD_EOP); - desc_addr += sizeof(cs5535audio_dma_desc_t); + desc_addr += sizeof(struct cs5535audio_dma_desc); addr += period_bytes; } /* we reserved one dummy descriptor at the end to do the PRD jump */ - lastdesc = &((cs5535audio_dma_desc_t *) dma->desc_buf.area)[periods]; + lastdesc = &((struct cs5535audio_dma_desc *) dma->desc_buf.area)[periods]; lastdesc->addr = cpu_to_le32((u32) dma->desc_buf.addr); lastdesc->size = 0; lastdesc->ctlreserved = cpu_to_le32(PRD_JMP); jmpprd_addr = cpu_to_le32(lastdesc->addr + - (sizeof(cs5535audio_dma_desc_t)*periods)); + (sizeof(struct cs5535audio_dma_desc)*periods)); dma->period_bytes = period_bytes; dma->periods = periods; @@ -172,71 +172,71 @@ static int cs5535audio_build_dma_packets(cs5535audio_t *cs5535au, return 0; } -static void cs5535audio_playback_enable_dma(cs5535audio_t *cs5535au) +static void cs5535audio_playback_enable_dma(struct cs5535audio *cs5535au) { cs_writeb(cs5535au, ACC_BM0_CMD, BM_CTL_EN); } -static void cs5535audio_playback_disable_dma(cs5535audio_t *cs5535au) +static void cs5535audio_playback_disable_dma(struct cs5535audio *cs5535au) { cs_writeb(cs5535au, ACC_BM0_CMD, 0); } -static void cs5535audio_playback_pause_dma(cs5535audio_t *cs5535au) +static void cs5535audio_playback_pause_dma(struct cs5535audio *cs5535au) { cs_writeb(cs5535au, ACC_BM0_CMD, BM_CTL_PAUSE); } -static void cs5535audio_playback_setup_prd(cs5535audio_t *cs5535au, - u32 prd_addr) +static void cs5535audio_playback_setup_prd(struct cs5535audio *cs5535au, + u32 prd_addr) { cs_writel(cs5535au, ACC_BM0_PRD, prd_addr); } -static u32 cs5535audio_playback_read_dma_pntr(cs5535audio_t *cs5535au) +static u32 cs5535audio_playback_read_dma_pntr(struct cs5535audio *cs5535au) { return cs_readl(cs5535au, ACC_BM0_PNTR); } -static void cs5535audio_capture_enable_dma(cs5535audio_t *cs5535au) +static void cs5535audio_capture_enable_dma(struct cs5535audio *cs5535au) { cs_writeb(cs5535au, ACC_BM1_CMD, BM_CTL_EN); } -static void cs5535audio_capture_disable_dma(cs5535audio_t *cs5535au) +static void cs5535audio_capture_disable_dma(struct cs5535audio *cs5535au) { cs_writeb(cs5535au, ACC_BM1_CMD, 0); } -static void cs5535audio_capture_pause_dma(cs5535audio_t *cs5535au) +static void cs5535audio_capture_pause_dma(struct cs5535audio *cs5535au) { cs_writeb(cs5535au, ACC_BM1_CMD, BM_CTL_PAUSE); } -static void cs5535audio_capture_setup_prd(cs5535audio_t *cs5535au, - u32 prd_addr) +static void cs5535audio_capture_setup_prd(struct cs5535audio *cs5535au, + u32 prd_addr) { cs_writel(cs5535au, ACC_BM1_PRD, prd_addr); } -static u32 cs5535audio_capture_read_dma_pntr(cs5535audio_t *cs5535au) +static u32 cs5535audio_capture_read_dma_pntr(struct cs5535audio *cs5535au) { return cs_readl(cs5535au, ACC_BM1_PNTR); } -static void cs5535audio_clear_dma_packets(cs5535audio_t *cs5535au, - cs5535audio_dma_t *dma, - snd_pcm_substream_t *substream) +static void cs5535audio_clear_dma_packets(struct cs5535audio *cs5535au, + struct cs5535audio_dma *dma, + struct snd_pcm_substream *substream) { snd_dma_free_pages(&dma->desc_buf); dma->desc_buf.area = NULL; } -static int snd_cs5535audio_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); - cs5535audio_dma_t *dma = substream->runtime->private_data; + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); + struct cs5535audio_dma *dma = substream->runtime->private_data; int err; err = snd_pcm_lib_malloc_pages(substream, @@ -247,31 +247,31 @@ static int snd_cs5535audio_hw_params(snd_pcm_substream_t *substream, dma->buf_bytes = params_buffer_bytes(hw_params); err = cs5535audio_build_dma_packets(cs5535au, dma, substream, - params_periods(hw_params), - params_period_bytes(hw_params)); + params_periods(hw_params), + params_period_bytes(hw_params)); return err; } -static int snd_cs5535audio_hw_free(snd_pcm_substream_t *substream) +static int snd_cs5535audio_hw_free(struct snd_pcm_substream *substream) { - cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); - cs5535audio_dma_t *dma = substream->runtime->private_data; + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); + struct cs5535audio_dma *dma = substream->runtime->private_data; cs5535audio_clear_dma_packets(cs5535au, dma, substream); return snd_pcm_lib_free_pages(substream); } -static int snd_cs5535audio_playback_prepare(snd_pcm_substream_t *substream) +static int snd_cs5535audio_playback_prepare(struct snd_pcm_substream *substream) { - cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); return snd_ac97_set_rate(cs5535au->ac97, AC97_PCM_FRONT_DAC_RATE, - substream->runtime->rate); + substream->runtime->rate); } -static int snd_cs5535audio_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_cs5535audio_trigger(struct snd_pcm_substream *substream, int cmd) { - cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); - cs5535audio_dma_t *dma = substream->runtime->private_data; + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); + struct cs5535audio_dma *dma = substream->runtime->private_data; int err = 0; spin_lock(&cs5535au->reg_lock); @@ -297,12 +297,12 @@ static int snd_cs5535audio_trigger(snd_pcm_substream_t *substream, int cmd) return err; } -static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t +static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(struct snd_pcm_substream *substream) { - cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); u32 curdma; - cs5535audio_dma_t *dma; + struct cs5535audio_dma *dma; dma = substream->runtime->private_data; curdma = dma->ops->read_dma_pntr(cs5535au); @@ -320,11 +320,11 @@ static snd_pcm_uframes_t snd_cs5535audio_pcm_pointer(snd_pcm_substream_t return bytes_to_frames(substream->runtime, curdma); } -static int snd_cs5535audio_capture_open(snd_pcm_substream_t *substream) +static int snd_cs5535audio_capture_open(struct snd_pcm_substream *substream) { int err; - cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; runtime->hw = snd_cs5535audio_capture; cs5535au->capture_substream = substream; @@ -336,19 +336,19 @@ static int snd_cs5535audio_capture_open(snd_pcm_substream_t *substream) return 0; } -static int snd_cs5535audio_capture_close(snd_pcm_substream_t *substream) +static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream) { return 0; } -static int snd_cs5535audio_capture_prepare(snd_pcm_substream_t *substream) +static int snd_cs5535audio_capture_prepare(struct snd_pcm_substream *substream) { - cs5535audio_t *cs5535au = snd_pcm_substream_chip(substream); + struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); return snd_ac97_set_rate(cs5535au->ac97, AC97_PCM_LR_ADC_RATE, - substream->runtime->rate); + substream->runtime->rate); } -static snd_pcm_ops_t snd_cs5535audio_playback_ops = { +static struct snd_pcm_ops snd_cs5535audio_playback_ops = { .open = snd_cs5535audio_playback_open, .close = snd_cs5535audio_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -359,7 +359,7 @@ static snd_pcm_ops_t snd_cs5535audio_playback_ops = { .pointer = snd_cs5535audio_pcm_pointer, }; -static snd_pcm_ops_t snd_cs5535audio_capture_ops = { +static struct snd_pcm_ops snd_cs5535audio_capture_ops = { .open = snd_cs5535audio_capture_open, .close = snd_cs5535audio_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -370,7 +370,7 @@ static snd_pcm_ops_t snd_cs5535audio_capture_ops = { .pointer = snd_cs5535audio_pcm_pointer, }; -static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = { +static struct cs5535audio_dma_ops snd_cs5535audio_playback_dma_ops = { .type = CS5535AUDIO_DMA_PLAYBACK, .enable_dma = cs5535audio_playback_enable_dma, .disable_dma = cs5535audio_playback_disable_dma, @@ -379,7 +379,7 @@ static cs5535audio_dma_ops_t snd_cs5535audio_playback_dma_ops = { .read_dma_pntr = cs5535audio_playback_read_dma_pntr, }; -static cs5535audio_dma_ops_t snd_cs5535audio_capture_dma_ops = { +static struct cs5535audio_dma_ops snd_cs5535audio_capture_dma_ops = { .type = CS5535AUDIO_DMA_CAPTURE, .enable_dma = cs5535audio_capture_enable_dma, .disable_dma = cs5535audio_capture_disable_dma, @@ -388,9 +388,9 @@ static cs5535audio_dma_ops_t snd_cs5535audio_capture_dma_ops = { .read_dma_pntr = cs5535audio_capture_read_dma_pntr, }; -int __devinit snd_cs5535audio_pcm(cs5535audio_t *cs5535au) +int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535au) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; err = snd_pcm_new(cs5535au->card, "CS5535 Audio", 0, 1, 1, &pcm); -- cgit v1.1 From c8b6bf9b5ef1f595a65a3414a5ca2588e8d993b2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:57:47 +0100 Subject: [ALSA] Remove xxx_t typedefs: HD-Audio codec Modules: HDA Codec driver,HDA generic driver Remove xxx_t typedefs from the HD-Audio codec support codes. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/hda_codec.c | 90 +++++++++++++++++++++--------------------- sound/pci/hda/hda_codec.h | 14 +++---- sound/pci/hda/hda_generic.c | 20 +++++----- sound/pci/hda/hda_local.h | 36 ++++++++--------- sound/pci/hda/hda_proc.c | 12 +++--- sound/pci/hda/patch_analog.c | 42 ++++++++++---------- sound/pci/hda/patch_cmedia.c | 30 +++++++------- sound/pci/hda/patch_realtek.c | 88 ++++++++++++++++++++--------------------- sound/pci/hda/patch_si3054.c | 20 +++++----- sound/pci/hda/patch_sigmatel.c | 44 ++++++++++----------- 10 files changed, 198 insertions(+), 198 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 2e9f587..7f4e199 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -332,7 +332,7 @@ static int snd_hda_bus_free(struct hda_bus *bus) return 0; } -static int snd_hda_bus_dev_free(snd_device_t *device) +static int snd_hda_bus_dev_free(struct snd_device *device) { struct hda_bus *bus = device->device_data; return snd_hda_bus_free(bus); @@ -346,12 +346,12 @@ static int snd_hda_bus_dev_free(snd_device_t *device) * * Returns 0 if successful, or a negative error code. */ -int snd_hda_bus_new(snd_card_t *card, const struct hda_bus_template *temp, +int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, struct hda_bus **busp) { struct hda_bus *bus; int err; - static snd_device_ops_t dev_ops = { + static struct snd_device_ops dev_ops = { .dev_free = snd_hda_bus_dev_free, }; @@ -732,7 +732,7 @@ static int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int #define get_amp_index(kc) (((kc)->private_value >> 19) & 0xf) /* volume */ -int snd_hda_mixer_amp_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); u16 nid = get_amp_nid(kcontrol); @@ -753,7 +753,7 @@ int snd_hda_mixer_amp_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -int snd_hda_mixer_amp_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = get_amp_nid(kcontrol); @@ -769,7 +769,7 @@ int snd_hda_mixer_amp_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -int snd_hda_mixer_amp_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = get_amp_nid(kcontrol); @@ -791,7 +791,7 @@ int snd_hda_mixer_amp_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t } /* switch */ -int snd_hda_mixer_amp_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int chs = get_amp_channels(kcontrol); @@ -802,7 +802,7 @@ int snd_hda_mixer_amp_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -int snd_hda_mixer_amp_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = get_amp_nid(kcontrol); @@ -818,7 +818,7 @@ int snd_hda_mixer_amp_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = get_amp_nid(kcontrol); @@ -849,7 +849,7 @@ int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t #define AMP_VAL_IDX_SHIFT 19 #define AMP_VAL_IDX_MASK (0x0f<<19) -int snd_hda_mixer_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); unsigned long pval; @@ -864,7 +864,7 @@ int snd_hda_mixer_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return err; } -int snd_hda_mixer_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); unsigned long pval; @@ -889,14 +889,14 @@ int snd_hda_mixer_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * SPDIF out controls */ -static int snd_hda_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_hda_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_hda_spdif_cmask_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_cmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | IEC958_AES0_NONAUDIO | @@ -907,7 +907,7 @@ static int snd_hda_spdif_cmask_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_hda_spdif_pmask_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_pmask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = IEC958_AES0_PROFESSIONAL | IEC958_AES0_NONAUDIO | @@ -915,7 +915,7 @@ static int snd_hda_spdif_pmask_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_hda_spdif_default_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); @@ -978,7 +978,7 @@ static unsigned int convert_to_spdif_status(unsigned short val) return sbits; } -static int snd_hda_spdif_default_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = kcontrol->private_value; @@ -1004,7 +1004,7 @@ static int snd_hda_spdif_default_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu return change; } -static int snd_hda_spdif_out_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_hda_spdif_out_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1013,7 +1013,7 @@ static int snd_hda_spdif_out_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_hda_spdif_out_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); @@ -1021,7 +1021,7 @@ static int snd_hda_spdif_out_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_v return 0; } -static int snd_hda_spdif_out_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = kcontrol->private_value; @@ -1044,7 +1044,7 @@ static int snd_hda_spdif_out_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_v return change; } -static snd_kcontrol_new_t dig_mixes[] = { +static struct snd_kcontrol_new dig_mixes[] = { { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_MIXER, @@ -1089,8 +1089,8 @@ static snd_kcontrol_new_t dig_mixes[] = { int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid) { int err; - snd_kcontrol_t *kctl; - snd_kcontrol_new_t *dig_mix; + struct snd_kcontrol *kctl; + struct snd_kcontrol_new *dig_mix; for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { kctl = snd_ctl_new1(dig_mix, codec); @@ -1109,7 +1109,7 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid) #define snd_hda_spdif_in_switch_info snd_hda_spdif_out_switch_info -static int snd_hda_spdif_in_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_in_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); @@ -1117,7 +1117,7 @@ static int snd_hda_spdif_in_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return 0; } -static int snd_hda_spdif_in_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_in_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = kcontrol->private_value; @@ -1134,7 +1134,7 @@ static int snd_hda_spdif_in_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return change; } -static int snd_hda_spdif_in_status_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = kcontrol->private_value; @@ -1150,7 +1150,7 @@ static int snd_hda_spdif_in_status_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return 0; } -static snd_kcontrol_new_t dig_in_ctls[] = { +static struct snd_kcontrol_new dig_in_ctls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), @@ -1181,8 +1181,8 @@ static snd_kcontrol_new_t dig_in_ctls[] = { int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) { int err; - snd_kcontrol_t *kctl; - snd_kcontrol_new_t *dig_mix; + struct snd_kcontrol *kctl; + struct snd_kcontrol_new *dig_mix; for (dig_mix = dig_in_ctls; dig_mix->name; dig_mix++) { kctl = snd_ctl_new1(dig_mix, codec); @@ -1498,7 +1498,7 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, */ static int hda_pcm_default_open_close(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { return 0; } @@ -1507,7 +1507,7 @@ static int hda_pcm_default_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { snd_hda_codec_setup_stream(codec, hinfo->nid, stream_tag, 0, format); return 0; @@ -1515,7 +1515,7 @@ static int hda_pcm_default_prepare(struct hda_pcm_stream *hinfo, static int hda_pcm_default_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { snd_hda_codec_setup_stream(codec, hinfo->nid, 0, 0, 0); return 0; @@ -1646,14 +1646,14 @@ int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_c /** * snd_hda_add_new_ctls - create controls from the array * @codec: the HDA codec - * @knew: the array of snd_kcontrol_new_t + * @knew: the array of struct snd_kcontrol_new * * This helper function creates and add new controls in the given array. * The array must be terminated with an empty entry as terminator. * * Returns 0 if successful, or a negative error code. */ -int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew) +int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) { int err; @@ -1666,10 +1666,10 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew) } - /* +/* * Channel mode helper */ -int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo, +int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, const struct hda_channel_mode *chmode, int num_chmodes) { uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -1682,7 +1682,7 @@ int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo, return 0; } -int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, +int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, const struct hda_channel_mode *chmode, int num_chmodes, int max_channels) { @@ -1697,7 +1697,7 @@ int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, return 0; } -int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, +int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, const struct hda_channel_mode *chmode, int num_chmodes, int *max_channelsp) { @@ -1717,7 +1717,7 @@ int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, /* * input MUX helper */ -int snd_hda_input_mux_info(const struct hda_input_mux *imux, snd_ctl_elem_info_t *uinfo) +int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo) { unsigned int index; @@ -1732,7 +1732,7 @@ int snd_hda_input_mux_info(const struct hda_input_mux *imux, snd_ctl_elem_info_t } int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, - snd_ctl_elem_value_t *ucontrol, hda_nid_t nid, + struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, unsigned int *cur_val) { unsigned int idx; @@ -1783,7 +1783,7 @@ int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *m * set up more restrictions for analog out */ int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { substream->runtime->hw.channels_max = mout->max_channels; return snd_pcm_hw_constraint_step(substream->runtime, 0, @@ -1797,7 +1797,7 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { hda_nid_t *nids = mout->dac_nids; int chs = substream->runtime->channels; @@ -2019,15 +2019,15 @@ int snd_hda_resume(struct hda_bus *bus) /** * snd_hda_resume_ctls - resume controls in the new control list * @codec: the HDA codec - * @knew: the array of snd_kcontrol_new_t + * @knew: the array of struct snd_kcontrol_new * - * This function resumes the mixer controls in the snd_kcontrol_new_t array, + * This function resumes the mixer controls in the struct snd_kcontrol_new array, * originally for snd_hda_add_new_ctls(). * The array must be terminated with an empty entry as terminator. */ -int snd_hda_resume_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew) +int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) { - snd_ctl_elem_value_t *val; + struct snd_ctl_elem_value *val; val = kmalloc(sizeof(*val), GFP_KERNEL); if (! val) diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 58b9949..0b5c367 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -420,7 +420,7 @@ struct hda_bus_template { * A hda_bus contains several codecs in the list codec_list. */ struct hda_bus { - snd_card_t *card; + struct snd_card *card; /* copied from template */ void *private_data; @@ -437,7 +437,7 @@ struct hda_bus { /* unsolicited event queue */ struct hda_bus_unsolicited *unsol; - snd_info_entry_t *proc; + struct snd_info_entry *proc; }; /* @@ -481,14 +481,14 @@ struct hda_amp_info { /* PCM callbacks */ struct hda_pcm_ops { int (*open)(struct hda_pcm_stream *info, struct hda_codec *codec, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); int (*close)(struct hda_pcm_stream *info, struct hda_codec *codec, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); int (*prepare)(struct hda_pcm_stream *info, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); }; /* PCM information for each substream */ @@ -563,7 +563,7 @@ enum { /* * constructors */ -int snd_hda_bus_new(snd_card_t *card, const struct hda_bus_template *temp, +int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, struct hda_bus **busp); int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, struct hda_codec **codecp); diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index d0eb9f2..863e8c6 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -389,14 +389,14 @@ static int parse_output(struct hda_codec *codec) */ /* control callbacks */ -static int capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int capture_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_gspec *spec = codec->spec; return snd_hda_input_mux_info(&spec->input_mux, uinfo); } -static int capture_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int capture_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_gspec *spec = codec->spec; @@ -405,7 +405,7 @@ static int capture_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc return 0; } -static int capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int capture_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_gspec *spec = codec->spec; @@ -617,7 +617,7 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, char name[32]; int err; int created = 0; - snd_kcontrol_new_t knew; + struct snd_kcontrol_new knew; if (type) sprintf(name, "%s %s Switch", type, dir_sfx); @@ -625,14 +625,14 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, sprintf(name, "%s Switch", dir_sfx); if ((node->wid_caps & AC_WCAP_IN_AMP) && (node->amp_in_caps & AC_AMPCAP_MUTE)) { - knew = (snd_kcontrol_new_t)HDA_CODEC_MUTE(name, node->nid, index, HDA_INPUT); + knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, index, HDA_INPUT); snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) return err; created = 1; } else if ((node->wid_caps & AC_WCAP_OUT_AMP) && (node->amp_out_caps & AC_AMPCAP_MUTE)) { - knew = (snd_kcontrol_new_t)HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT); + knew = (struct snd_kcontrol_new)HDA_CODEC_MUTE(name, node->nid, 0, HDA_OUTPUT); snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) return err; @@ -645,14 +645,14 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, sprintf(name, "%s Volume", dir_sfx); if ((node->wid_caps & AC_WCAP_IN_AMP) && (node->amp_in_caps & AC_AMPCAP_NUM_STEPS)) { - knew = (snd_kcontrol_new_t)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT); + knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, index, HDA_INPUT); snd_printdd("[%s] NID=0x%x, DIR=IN, IDX=0x%x\n", name, node->nid, index); if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) return err; created = 1; } else if ((node->wid_caps & AC_WCAP_OUT_AMP) && (node->amp_out_caps & AC_AMPCAP_NUM_STEPS)) { - knew = (snd_kcontrol_new_t)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT); + knew = (struct snd_kcontrol_new)HDA_CODEC_VOLUME(name, node->nid, 0, HDA_OUTPUT); snd_printdd("[%s] NID=0x%x, DIR=OUT\n", name, node->nid); if ((err = snd_ctl_add(codec->bus->card, snd_ctl_new1(&knew, codec))) < 0) return err; @@ -667,7 +667,7 @@ static int create_mixer(struct hda_codec *codec, struct hda_gnode *node, */ static int check_existing_control(struct hda_codec *codec, const char *type, const char *dir) { - snd_ctl_elem_id_t id; + struct snd_ctl_elem_id id; memset(&id, 0, sizeof(id)); sprintf(id.name, "%s %s Volume", type, dir); id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; @@ -710,7 +710,7 @@ static int build_input_controls(struct hda_codec *codec) /* create input MUX if multiple sources are available */ if (spec->input_mux.num_items > 1) { - static snd_kcontrol_new_t cap_sel = { + static struct snd_kcontrol_new cap_sel = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Source", .info = capture_source_info, diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 31d3c7e..5022904 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -60,12 +60,12 @@ #define HDA_CODEC_MUTE(xname, nid, xindex, direction) \ HDA_CODEC_MUTE_MONO(xname, nid, 3, xindex, direction) -int snd_hda_mixer_amp_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo); -int snd_hda_mixer_amp_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); -int snd_hda_mixer_amp_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); -int snd_hda_mixer_amp_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo); -int snd_hda_mixer_amp_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); -int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); +int snd_hda_mixer_amp_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_hda_mixer_amp_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_hda_mixer_amp_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); /* mono switch binding multiple inputs */ #define HDA_BIND_MUTE_MONO(xname, nid, channel, indices, direction) \ @@ -78,8 +78,8 @@ int snd_hda_mixer_amp_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t /* stereo switch binding multiple inputs */ #define HDA_BIND_MUTE(xname,nid,indices,dir) HDA_BIND_MUTE_MONO(xname,nid,3,indices,dir) -int snd_hda_mixer_bind_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); -int snd_hda_mixer_bind_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol); +int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid); int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid); @@ -97,12 +97,12 @@ struct hda_input_mux { struct hda_input_mux_item items[HDA_MAX_NUM_INPUTS]; }; -int snd_hda_input_mux_info(const struct hda_input_mux *imux, snd_ctl_elem_info_t *uinfo); +int snd_hda_input_mux_info(const struct hda_input_mux *imux, struct snd_ctl_elem_info *uinfo); int snd_hda_input_mux_put(struct hda_codec *codec, const struct hda_input_mux *imux, - snd_ctl_elem_value_t *ucontrol, hda_nid_t nid, + struct snd_ctl_elem_value *ucontrol, hda_nid_t nid, unsigned int *cur_val); - /* +/* * Channel mode helper */ struct hda_channel_mode { @@ -110,12 +110,12 @@ struct hda_channel_mode { const struct hda_verb *sequence; }; -int snd_hda_ch_mode_info(struct hda_codec *codec, snd_ctl_elem_info_t *uinfo, +int snd_hda_ch_mode_info(struct hda_codec *codec, struct snd_ctl_elem_info *uinfo, const struct hda_channel_mode *chmode, int num_chmodes); -int snd_hda_ch_mode_get(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, +int snd_hda_ch_mode_get(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, const struct hda_channel_mode *chmode, int num_chmodes, int max_channels); -int snd_hda_ch_mode_put(struct hda_codec *codec, snd_ctl_elem_value_t *ucontrol, +int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucontrol, const struct hda_channel_mode *chmode, int num_chmodes, int *max_channelsp); @@ -138,11 +138,11 @@ struct hda_multi_out { int snd_hda_multi_out_dig_open(struct hda_codec *codec, struct hda_multi_out *mout); int snd_hda_multi_out_dig_close(struct hda_codec *codec, struct hda_multi_out *mout); int snd_hda_multi_out_analog_open(struct hda_codec *codec, struct hda_multi_out *mout, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_out *mout); /* @@ -170,13 +170,13 @@ struct hda_board_config { }; int snd_hda_check_board_config(struct hda_codec *codec, const struct hda_board_config *tbl); -int snd_hda_add_new_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew); +int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew); /* * power management */ #ifdef CONFIG_PM -int snd_hda_resume_ctls(struct hda_codec *codec, snd_kcontrol_new_t *knew); +int snd_hda_resume_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew); int snd_hda_resume_spdif_out(struct hda_codec *codec); int snd_hda_resume_spdif_in(struct hda_codec *codec); #endif diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 39ddf1c..8cc5773 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c @@ -47,7 +47,7 @@ static const char *get_wid_type_name(unsigned int wid_value) return "UNKOWN Widget"; } -static void print_amp_caps(snd_info_buffer_t *buffer, +static void print_amp_caps(struct snd_info_buffer *buffer, struct hda_codec *codec, hda_nid_t nid, int dir) { unsigned int caps; @@ -66,7 +66,7 @@ static void print_amp_caps(snd_info_buffer_t *buffer, (caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT); } -static void print_amp_vals(snd_info_buffer_t *buffer, +static void print_amp_vals(struct snd_info_buffer *buffer, struct hda_codec *codec, hda_nid_t nid, int dir, int stereo, int indices) { @@ -91,7 +91,7 @@ static void print_amp_vals(snd_info_buffer_t *buffer, snd_iprintf(buffer, "\n"); } -static void print_pcm_caps(snd_info_buffer_t *buffer, +static void print_pcm_caps(struct snd_info_buffer *buffer, struct hda_codec *codec, hda_nid_t nid) { unsigned int pcm = snd_hda_param_read(codec, nid, AC_PAR_PCM); @@ -160,7 +160,7 @@ static const char *get_jack_color(u32 cfg) return "UNKNOWN"; } -static void print_pin_caps(snd_info_buffer_t *buffer, +static void print_pin_caps(struct snd_info_buffer *buffer, struct hda_codec *codec, hda_nid_t nid) { static char *jack_conns[4] = { "Jack", "N/A", "Fixed", "Both" }; @@ -194,7 +194,7 @@ static void print_pin_caps(snd_info_buffer_t *buffer, } -static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void print_codec_info(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { struct hda_codec *codec = entry->private_data; char buf[32]; @@ -309,7 +309,7 @@ static void print_codec_info(snd_info_entry_t *entry, snd_info_buffer_t *buffer) int snd_hda_codec_proc_new(struct hda_codec *codec) { char name[32]; - snd_info_entry_t *entry; + struct snd_info_entry *entry; int err; snprintf(name, sizeof(name), "codec#%d", codec->addr); diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 4687736..1f371fe 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -28,7 +28,7 @@ #include "hda_local.h" struct ad198x_spec { - snd_kcontrol_new_t *mixers[5]; + struct snd_kcontrol_new *mixers[5]; int num_mixers; const struct hda_verb *init_verbs[3]; /* initialization verbs @@ -65,7 +65,7 @@ struct ad198x_spec { /* * input MUX handling (common part) */ -static int ad198x_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *spec = codec->spec; @@ -73,7 +73,7 @@ static int ad198x_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *u return snd_hda_input_mux_info(spec->input_mux, uinfo); } -static int ad198x_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *spec = codec->spec; @@ -83,7 +83,7 @@ static int ad198x_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u return 0; } -static int ad198x_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *spec = codec->spec; @@ -135,7 +135,7 @@ static int ad198x_build_controls(struct hda_codec *codec) */ static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct ad198x_spec *spec = codec->spec; return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); @@ -145,7 +145,7 @@ static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct ad198x_spec *spec = codec->spec; return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, @@ -154,7 +154,7 @@ static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo, static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct ad198x_spec *spec = codec->spec; return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); @@ -165,7 +165,7 @@ static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, */ static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct ad198x_spec *spec = codec->spec; return snd_hda_multi_out_dig_open(codec, &spec->multiout); @@ -173,7 +173,7 @@ static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct ad198x_spec *spec = codec->spec; return snd_hda_multi_out_dig_close(codec, &spec->multiout); @@ -186,7 +186,7 @@ static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct ad198x_spec *spec = codec->spec; snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], @@ -196,7 +196,7 @@ static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo, static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct ad198x_spec *spec = codec->spec; snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], @@ -348,7 +348,7 @@ static struct hda_input_mux ad1986a_capture_source = { #define ad1986a_pcm_amp_vol_info snd_hda_mixer_amp_volume_info -static int ad1986a_pcm_amp_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ad1986a_pcm_amp_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *ad = codec->spec; @@ -359,7 +359,7 @@ static int ad1986a_pcm_amp_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return 0; } -static int ad1986a_pcm_amp_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ad1986a_pcm_amp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *ad = codec->spec; @@ -377,7 +377,7 @@ static int ad1986a_pcm_amp_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ #define ad1986a_pcm_amp_sw_info snd_hda_mixer_amp_switch_info -static int ad1986a_pcm_amp_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ad1986a_pcm_amp_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *ad = codec->spec; @@ -388,7 +388,7 @@ static int ad1986a_pcm_amp_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int ad1986a_pcm_amp_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ad1986a_pcm_amp_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *ad = codec->spec; @@ -407,7 +407,7 @@ static int ad1986a_pcm_amp_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t /* * mixers */ -static snd_kcontrol_new_t ad1986a_mixers[] = { +static struct snd_kcontrol_new ad1986a_mixers[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Volume", @@ -570,7 +570,7 @@ static struct hda_input_mux ad1983_capture_source = { /* * SPDIF playback route */ -static int ad1983_spdif_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int ad1983_spdif_route_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "PCM", "ADC" }; @@ -583,7 +583,7 @@ static int ad1983_spdif_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int ad1983_spdif_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ad1983_spdif_route_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *spec = codec->spec; @@ -592,7 +592,7 @@ static int ad1983_spdif_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int ad1983_spdif_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int ad1983_spdif_route_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct ad198x_spec *spec = codec->spec; @@ -606,7 +606,7 @@ static int ad1983_spdif_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static snd_kcontrol_new_t ad1983_mixers[] = { +static struct snd_kcontrol_new ad1983_mixers[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), @@ -736,7 +736,7 @@ static struct hda_input_mux ad1981_capture_source = { }, }; -static snd_kcontrol_new_t ad1981_mixers[] = { +static struct snd_kcontrol_new ad1981_mixers[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x05, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Front Playback Switch", 0x05, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Headphone Playback Volume", 0x06, 0x0, HDA_OUTPUT), diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index 37ee124..9a69811 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c @@ -79,14 +79,14 @@ struct cmi_spec { /* * input MUX */ -static int cmi_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int cmi_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; return snd_hda_input_mux_info(spec->input_mux, uinfo); } -static int cmi_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int cmi_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; @@ -96,7 +96,7 @@ static int cmi_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon return 0; } -static int cmi_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int cmi_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; @@ -149,7 +149,7 @@ static struct hda_channel_mode cmi9880_channel_modes[3] = { { 8, cmi9880_ch8_init }, }; -static int cmi_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int cmi_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; @@ -157,7 +157,7 @@ static int cmi_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo spec->num_channel_modes); } -static int cmi_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int cmi_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; @@ -165,7 +165,7 @@ static int cmi_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont spec->num_channel_modes, spec->multiout.max_channels); } -static int cmi_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int cmi_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct cmi_spec *spec = codec->spec; @@ -175,7 +175,7 @@ static int cmi_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont /* */ -static snd_kcontrol_new_t cmi9880_basic_mixer[] = { +static struct snd_kcontrol_new cmi9880_basic_mixer[] = { /* CMI9880 has no playback volumes! */ HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT), /* front */ HDA_CODEC_MUTE("Surround Playback Switch", 0x04, 0x0, HDA_OUTPUT), @@ -207,7 +207,7 @@ static snd_kcontrol_new_t cmi9880_basic_mixer[] = { /* * shared I/O pins */ -static snd_kcontrol_new_t cmi9880_ch_mode_mixer[] = { +static struct snd_kcontrol_new cmi9880_ch_mode_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Channel Mode", @@ -452,7 +452,7 @@ static int cmi9880_resume(struct hda_codec *codec) */ static int cmi9880_playback_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct cmi_spec *spec = codec->spec; return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); @@ -462,7 +462,7 @@ static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct cmi_spec *spec = codec->spec; return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, @@ -471,7 +471,7 @@ static int cmi9880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, static int cmi9880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct cmi_spec *spec = codec->spec; return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); @@ -482,7 +482,7 @@ static int cmi9880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, */ static int cmi9880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct cmi_spec *spec = codec->spec; return snd_hda_multi_out_dig_open(codec, &spec->multiout); @@ -490,7 +490,7 @@ static int cmi9880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, static int cmi9880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct cmi_spec *spec = codec->spec; return snd_hda_multi_out_dig_close(codec, &spec->multiout); @@ -503,7 +503,7 @@ static int cmi9880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct cmi_spec *spec = codec->spec; @@ -514,7 +514,7 @@ static int cmi9880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, static int cmi9880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct cmi_spec *spec = codec->spec; diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 3ff72c4..62e6993 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -63,7 +63,7 @@ enum { struct alc_spec { /* codec parameterization */ - snd_kcontrol_new_t *mixers[3]; /* mixer arrays */ + struct snd_kcontrol_new *mixers[3]; /* mixer arrays */ unsigned int num_mixers; const struct hda_verb *init_verbs[3]; /* initialization verbs @@ -104,7 +104,7 @@ struct alc_spec { /* dynamic controls, init_verbs and input_mux */ struct auto_pin_cfg autocfg; unsigned int num_kctl_alloc, num_kctl_used; - snd_kcontrol_new_t *kctl_alloc; + struct snd_kcontrol_new *kctl_alloc; struct hda_input_mux private_imux; hda_nid_t private_dac_nids[4]; }; @@ -113,14 +113,14 @@ struct alc_spec { /* * input MUX handling */ -static int alc_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; return snd_hda_input_mux_info(spec->input_mux, uinfo); } -static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -130,7 +130,7 @@ static int alc_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon return 0; } -static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -143,7 +143,7 @@ static int alc_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon /* * channel mode setting */ -static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int alc880_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -151,7 +151,7 @@ static int alc880_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *ui spec->num_channel_mode); } -static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc880_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -159,7 +159,7 @@ static int alc880_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc spec->num_channel_mode, spec->multiout.max_channels); } -static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc880_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -173,7 +173,7 @@ static int alc880_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc * supported, so VrefEn can't be controlled using these functions as they * stand. */ -static int alc_pinctl_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int alc_pinctl_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -182,7 +182,7 @@ static int alc_pinctl_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int alc_pinctl_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc_pinctl_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = kcontrol->private_value & 0xffff; @@ -195,7 +195,7 @@ static int alc_pinctl_switch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int alc_pinctl_switch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = kcontrol->private_value & 0xffff; @@ -284,7 +284,7 @@ static struct hda_channel_mode alc880_threestack_modes[2] = { { 6, alc880_threestack_ch6_init }, }; -static snd_kcontrol_new_t alc880_three_stack_mixer[] = { +static struct snd_kcontrol_new alc880_three_stack_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT), @@ -315,7 +315,7 @@ static snd_kcontrol_new_t alc880_three_stack_mixer[] = { }; /* capture mixer elements */ -static snd_kcontrol_new_t alc880_capture_mixer[] = { +static struct snd_kcontrol_new alc880_capture_mixer[] = { HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), @@ -339,7 +339,7 @@ static snd_kcontrol_new_t alc880_capture_mixer[] = { }; /* capture mixer elements (in case NID 0x07 not available) */ -static snd_kcontrol_new_t alc880_capture_alt_mixer[] = { +static struct snd_kcontrol_new alc880_capture_alt_mixer[] = { HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), @@ -371,7 +371,7 @@ static snd_kcontrol_new_t alc880_capture_alt_mixer[] = { */ /* additional mixers to alc880_three_stack_mixer */ -static snd_kcontrol_new_t alc880_five_stack_mixer[] = { +static struct snd_kcontrol_new alc880_five_stack_mixer[] = { HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT), { } /* end */ @@ -428,7 +428,7 @@ static struct hda_channel_mode alc880_sixstack_modes[1] = { { 8, NULL }, }; -static snd_kcontrol_new_t alc880_six_stack_mixer[] = { +static struct snd_kcontrol_new alc880_six_stack_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), @@ -496,7 +496,7 @@ static struct hda_channel_mode alc880_w810_modes[1] = { }; /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */ -static snd_kcontrol_new_t alc880_w810_base_mixer[] = { +static struct snd_kcontrol_new alc880_w810_base_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), @@ -527,7 +527,7 @@ static struct hda_channel_mode alc880_2_jack_modes[1] = { { 2, NULL } }; -static snd_kcontrol_new_t alc880_z71v_mixer[] = { +static struct snd_kcontrol_new alc880_z71v_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT), @@ -553,7 +553,7 @@ static hda_nid_t alc880_f1734_dac_nids[1] = { }; #define ALC880_F1734_HP_DAC 0x02 -static snd_kcontrol_new_t alc880_f1734_mixer[] = { +static struct snd_kcontrol_new alc880_f1734_mixer[] = { HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT), HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT), @@ -578,7 +578,7 @@ static snd_kcontrol_new_t alc880_f1734_mixer[] = { #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */ #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */ -static snd_kcontrol_new_t alc880_asus_mixer[] = { +static struct snd_kcontrol_new alc880_asus_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), @@ -613,14 +613,14 @@ static snd_kcontrol_new_t alc880_asus_mixer[] = { */ /* additional mixers to alc880_asus_mixer */ -static snd_kcontrol_new_t alc880_asus_w1v_mixer[] = { +static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = { HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT), HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT), { } /* end */ }; /* additional mixers to alc880_asus_mixer */ -static snd_kcontrol_new_t alc880_pcbeep_mixer[] = { +static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT), HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT), { } /* end */ @@ -974,7 +974,7 @@ static int alc_resume(struct hda_codec *codec) */ static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct alc_spec *spec = codec->spec; return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); @@ -984,7 +984,7 @@ static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct alc_spec *spec = codec->spec; return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, @@ -993,7 +993,7 @@ static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo, static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct alc_spec *spec = codec->spec; return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); @@ -1004,7 +1004,7 @@ static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, */ static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct alc_spec *spec = codec->spec; return snd_hda_multi_out_dig_open(codec, &spec->multiout); @@ -1012,7 +1012,7 @@ static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct alc_spec *spec = codec->spec; return snd_hda_multi_out_dig_close(codec, &spec->multiout); @@ -1025,7 +1025,7 @@ static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct alc_spec *spec = codec->spec; @@ -1036,7 +1036,7 @@ static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo, static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct alc_spec *spec = codec->spec; @@ -1185,7 +1185,7 @@ static struct hda_channel_mode alc880_test_modes[4] = { { 8, NULL }, }; -static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "N/A", "Line Out", "HP Out", @@ -1200,7 +1200,7 @@ static int alc_test_pin_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = (hda_nid_t)kcontrol->private_value; @@ -1226,7 +1226,7 @@ static int alc_test_pin_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = (hda_nid_t)kcontrol->private_value; @@ -1252,7 +1252,7 @@ static int alc_test_pin_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "Front", "Surround", "CLFE", "Side" @@ -1266,7 +1266,7 @@ static int alc_test_pin_src_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = (hda_nid_t)kcontrol->private_value; @@ -1277,7 +1277,7 @@ static int alc_test_pin_src_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); hda_nid_t nid = (hda_nid_t)kcontrol->private_value; @@ -1310,7 +1310,7 @@ static int alc_test_pin_src_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * .private_value = nid \ } -static snd_kcontrol_new_t alc880_test_mixer[] = { +static struct snd_kcontrol_new alc880_test_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT), @@ -1527,7 +1527,7 @@ static struct hda_board_config alc880_cfg_tbl[] = { * configuration template - to be copied to the spec instance */ struct alc_config_preset { - snd_kcontrol_new_t *mixers[4]; + struct snd_kcontrol_new *mixers[4]; const struct hda_verb *init_verbs[4]; unsigned int num_dacs; hda_nid_t *dac_nids; @@ -1698,7 +1698,7 @@ enum { ALC_CTL_WIDGET_MUTE, ALC_CTL_BIND_MUTE, }; -static snd_kcontrol_new_t alc880_control_templates[] = { +static struct snd_kcontrol_new alc880_control_templates[] = { HDA_CODEC_VOLUME(NULL, 0, 0, 0), HDA_CODEC_MUTE(NULL, 0, 0, 0), HDA_BIND_MUTE(NULL, 0, 0, 0), @@ -1707,7 +1707,7 @@ static snd_kcontrol_new_t alc880_control_templates[] = { /* add dynamic controls */ static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val) { - snd_kcontrol_new_t *knew; + struct snd_kcontrol_new *knew; if (spec->num_kctl_used >= spec->num_kctl_alloc) { int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; @@ -2168,7 +2168,7 @@ static struct hda_channel_mode alc260_modes[1] = { { 2, NULL }, }; -static snd_kcontrol_new_t alc260_base_mixer[] = { +static struct snd_kcontrol_new alc260_base_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), @@ -2197,7 +2197,7 @@ static snd_kcontrol_new_t alc260_base_mixer[] = { { } /* end */ }; -static snd_kcontrol_new_t alc260_hp_mixer[] = { +static struct snd_kcontrol_new alc260_hp_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), @@ -2224,7 +2224,7 @@ static snd_kcontrol_new_t alc260_hp_mixer[] = { { } /* end */ }; -static snd_kcontrol_new_t alc260_fujitsu_mixer[] = { +static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT), ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP), @@ -2498,7 +2498,7 @@ static struct hda_input_mux alc882_capture_source = { #define alc882_mux_enum_info alc_mux_enum_info #define alc882_mux_enum_get alc_mux_enum_get -static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -2526,7 +2526,7 @@ static int alc882_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b */ -static snd_kcontrol_new_t alc882_base_mixer[] = { +static struct snd_kcontrol_new alc882_base_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT), HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT), diff --git a/sound/pci/hda/patch_si3054.c b/sound/pci/hda/patch_si3054.c index 12b5de2..8f8840e 100644 --- a/sound/pci/hda/patch_si3054.c +++ b/sound/pci/hda/patch_si3054.c @@ -95,8 +95,8 @@ struct si3054_spec { #define PRIVATE_REG(val) ((val>>16)&0xffff) #define PRIVATE_MASK(val) (val&0xffff) -static int si3054_switch_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int si3054_switch_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -105,8 +105,8 @@ static int si3054_switch_info(snd_kcontrol_t *kcontrol, return 0; } -static int si3054_switch_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *uvalue) +static int si3054_switch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *uvalue) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); u16 reg = PRIVATE_REG(kcontrol->private_value); @@ -115,8 +115,8 @@ static int si3054_switch_get(snd_kcontrol_t *kcontrol, return 0; } -static int si3054_switch_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *uvalue) +static int si3054_switch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *uvalue) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); u16 reg = PRIVATE_REG(kcontrol->private_value); @@ -138,7 +138,7 @@ static int si3054_switch_put(snd_kcontrol_t *kcontrol, } -static snd_kcontrol_new_t si3054_modem_mixer[] = { +static struct snd_kcontrol_new si3054_modem_mixer[] = { SI3054_KCONTROL("Off-hook Switch", SI3054_GPIO_CONTROL, SI3054_GPIO_OH), SI3054_KCONTROL("Caller ID Switch", SI3054_GPIO_CONTROL, SI3054_GPIO_CID), {} @@ -158,7 +158,7 @@ static int si3054_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { u16 val; @@ -175,10 +175,10 @@ static int si3054_pcm_prepare(struct hda_pcm_stream *hinfo, static int si3054_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { static unsigned int rates[] = { 8000, 9600, 16000 }; - static snd_pcm_hw_constraint_list_t hw_constraints_rates = { + static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 33a8ada..d8d68f5 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -41,7 +41,7 @@ #define STAC_UNSOL_ENABLE (AC_USRSP_EN | STAC_HP_EVENT) struct sigmatel_spec { - snd_kcontrol_new_t *mixers[4]; + struct snd_kcontrol_new *mixers[4]; unsigned int num_mixers; unsigned int surr_switch: 1; @@ -66,7 +66,7 @@ struct sigmatel_spec { /* codec specific stuff */ struct hda_verb *init; - snd_kcontrol_new_t *mixer; + struct snd_kcontrol_new *mixer; /* capture source */ struct hda_input_mux *input_mux; @@ -81,7 +81,7 @@ struct sigmatel_spec { /* dynamic controls and input_mux */ struct auto_pin_cfg autocfg; unsigned int num_kctl_alloc, num_kctl_used; - snd_kcontrol_new_t *kctl_alloc; + struct snd_kcontrol_new *kctl_alloc; struct hda_input_mux private_imux; }; @@ -116,14 +116,14 @@ static hda_nid_t stac922x_pin_nids[10] = { }; #endif -static int stac92xx_mux_enum_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct sigmatel_spec *spec = codec->spec; return snd_hda_input_mux_info(spec->input_mux, uinfo); } -static int stac92xx_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct sigmatel_spec *spec = codec->spec; @@ -133,7 +133,7 @@ static int stac92xx_mux_enum_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int stac92xx_mux_enum_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct sigmatel_spec *spec = codec->spec; @@ -157,7 +157,7 @@ static struct hda_verb stac922x_core_init[] = { static int stac922x_channel_modes[3] = {2, 6, 8}; -static int stac922x_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int stac922x_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct sigmatel_spec *spec = codec->spec; @@ -172,7 +172,7 @@ static int stac922x_ch_mode_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int stac922x_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac922x_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct sigmatel_spec *spec = codec->spec; @@ -181,7 +181,7 @@ static int stac922x_ch_mode_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int stac922x_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac922x_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct sigmatel_spec *spec = codec->spec; @@ -198,7 +198,7 @@ static int stac922x_ch_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 1; } -static snd_kcontrol_new_t stac9200_mixer[] = { +static struct snd_kcontrol_new stac9200_mixer[] = { HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), { @@ -216,7 +216,7 @@ static snd_kcontrol_new_t stac9200_mixer[] = { }; /* This needs to be generated dynamically based on sequence */ -static snd_kcontrol_new_t stac922x_mixer[] = { +static struct snd_kcontrol_new stac922x_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Input Source", @@ -231,7 +231,7 @@ static snd_kcontrol_new_t stac922x_mixer[] = { { } /* end */ }; -static snd_kcontrol_new_t stac922x_ch_mode_mixer[] = { +static struct snd_kcontrol_new stac922x_ch_mode_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Channel Mode", @@ -320,7 +320,7 @@ static void stac92xx_set_config_regs(struct hda_codec *codec) */ static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct sigmatel_spec *spec = codec->spec; return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); @@ -333,7 +333,7 @@ static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, static int stac92xx_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { hda_nid_t *nids = mout->dac_nids; int chs = substream->runtime->channels; @@ -380,7 +380,7 @@ static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct sigmatel_spec *spec = codec->spec; return stac92xx_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, @@ -389,7 +389,7 @@ static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct sigmatel_spec *spec = codec->spec; return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); @@ -400,7 +400,7 @@ static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, */ static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct sigmatel_spec *spec = codec->spec; return snd_hda_multi_out_dig_open(codec, &spec->multiout); @@ -408,7 +408,7 @@ static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct sigmatel_spec *spec = codec->spec; return snd_hda_multi_out_dig_close(codec, &spec->multiout); @@ -422,7 +422,7 @@ static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct sigmatel_spec *spec = codec->spec; @@ -433,7 +433,7 @@ static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, struct hda_codec *codec, - snd_pcm_substream_t *substream) + struct snd_pcm_substream *substream) { struct sigmatel_spec *spec = codec->spec; @@ -516,7 +516,7 @@ enum { STAC_CTL_WIDGET_MUTE, }; -static snd_kcontrol_new_t stac92xx_control_templates[] = { +static struct snd_kcontrol_new stac92xx_control_templates[] = { HDA_CODEC_VOLUME(NULL, 0, 0, 0), HDA_CODEC_MUTE(NULL, 0, 0, 0), }; @@ -524,7 +524,7 @@ static snd_kcontrol_new_t stac92xx_control_templates[] = { /* add dynamic controls */ static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val) { - snd_kcontrol_new_t *knew; + struct snd_kcontrol_new *knew; if (spec->num_kctl_used >= spec->num_kctl_alloc) { int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; -- cgit v1.1 From a98f90fd826913519c3f704ea24fb9bea1e0e494 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:59:02 +0100 Subject: [ALSA] Remove xxx_t typedefs: HDA-Intel Modules: HDA Intel driver Remove xxx_t typedefs from the HDA-Intel driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/hda/hda_intel.c | 156 ++++++++++++++++++++++------------------------ 1 file changed, 76 insertions(+), 80 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 429ef38..abdbd96 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -238,11 +238,7 @@ enum { /* */ -typedef struct snd_azx azx_t; -typedef struct snd_azx_rb azx_rb_t; -typedef struct snd_azx_dev azx_dev_t; - -struct snd_azx_dev { +struct azx_dev { u32 *bdl; /* virtual address of the BDL */ dma_addr_t bdl_addr; /* physical address of the BDL */ volatile u32 *posbuf; /* position buffer pointer */ @@ -258,7 +254,7 @@ struct snd_azx_dev { u32 sd_int_sta_mask; /* stream int status mask */ /* pcm support */ - snd_pcm_substream_t *substream; /* assigned substream, set in PCM open */ + struct snd_pcm_substream *substream; /* assigned substream, set in PCM open */ unsigned int format_val; /* format value to be set in the controller and the codec */ unsigned char stream_tag; /* assigned stream */ unsigned char index; /* stream index */ @@ -269,7 +265,7 @@ struct snd_azx_dev { }; /* CORB/RIRB */ -struct snd_azx_rb { +struct azx_rb { u32 *buf; /* CORB/RIRB buffer * Each CORB entry is 4byte, RIRB is 8byte */ @@ -280,8 +276,8 @@ struct snd_azx_rb { u32 res; /* last read value */ }; -struct snd_azx { - snd_card_t *card; +struct azx { + struct snd_card *card; struct pci_dev *pci; /* chip type specific */ @@ -302,19 +298,19 @@ struct snd_azx { struct semaphore open_mutex; /* streams (x num_streams) */ - azx_dev_t *azx_dev; + struct azx_dev *azx_dev; /* PCM */ unsigned int pcm_devs; - snd_pcm_t *pcm[AZX_MAX_PCMS]; + struct snd_pcm *pcm[AZX_MAX_PCMS]; /* HD codec */ unsigned short codec_mask; struct hda_bus *bus; /* CORB/RIRB */ - azx_rb_t corb; - azx_rb_t rirb; + struct azx_rb corb; + struct azx_rb rirb; /* BDL, CORB/RIRB and position buffers */ struct snd_dma_buffer bdl; @@ -375,7 +371,7 @@ static char *driver_short_names[] __devinitdata = { readb((dev)->sd_addr + ICH6_REG_##reg) /* for pcm support */ -#define get_azx_dev(substream) (azx_dev_t*)(substream->runtime->private_data) +#define get_azx_dev(substream) (substream->runtime->private_data) /* Get the upper 32bit of the given dma_addr_t * Compiler should optimize and eliminate the code if dma_addr_t is 32bit @@ -391,7 +387,7 @@ static char *driver_short_names[] __devinitdata = { /* * CORB / RIRB interface */ -static int azx_alloc_cmd_io(azx_t *chip) +static int azx_alloc_cmd_io(struct azx *chip) { int err; @@ -405,7 +401,7 @@ static int azx_alloc_cmd_io(azx_t *chip) return 0; } -static void azx_init_cmd_io(azx_t *chip) +static void azx_init_cmd_io(struct azx *chip) { /* CORB set up */ chip->corb.addr = chip->rb.addr; @@ -443,7 +439,7 @@ static void azx_init_cmd_io(azx_t *chip) chip->rirb.rp = chip->rirb.cmds = 0; } -static void azx_free_cmd_io(azx_t *chip) +static void azx_free_cmd_io(struct azx *chip) { /* disable ringbuffer DMAs */ azx_writeb(chip, RIRBCTL, 0); @@ -454,7 +450,7 @@ static void azx_free_cmd_io(azx_t *chip) static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, unsigned int verb, unsigned int para) { - azx_t *chip = codec->bus->private_data; + struct azx *chip = codec->bus->private_data; unsigned int wp; u32 val; @@ -481,7 +477,7 @@ static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, #define ICH6_RIRB_EX_UNSOL_EV (1<<4) /* retrieve RIRB entry - called from interrupt handler */ -static void azx_update_rirb(azx_t *chip) +static void azx_update_rirb(struct azx *chip) { unsigned int rp, wp; u32 res, res_ex; @@ -510,7 +506,7 @@ static void azx_update_rirb(azx_t *chip) /* receive a response */ static unsigned int azx_get_response(struct hda_codec *codec) { - azx_t *chip = codec->bus->private_data; + struct azx *chip = codec->bus->private_data; int timeout = 50; while (chip->rirb.cmds) { @@ -546,7 +542,7 @@ static unsigned int azx_get_response(struct hda_codec *codec) static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, unsigned int verb, unsigned int para) { - azx_t *chip = codec->bus->private_data; + struct azx *chip = codec->bus->private_data; u32 val; int timeout = 50; @@ -574,7 +570,7 @@ static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid, int direct, /* receive a response */ static unsigned int azx_get_response(struct hda_codec *codec) { - azx_t *chip = codec->bus->private_data; + struct azx *chip = codec->bus->private_data; int timeout = 50; while (timeout--) { @@ -592,7 +588,7 @@ static unsigned int azx_get_response(struct hda_codec *codec) #endif /* USE_CORB_RIRB */ /* reset codec link */ -static int azx_reset(azx_t *chip) +static int azx_reset(struct azx *chip) { int count; @@ -642,7 +638,7 @@ static int azx_reset(azx_t *chip) */ /* enable interrupts */ -static void azx_int_enable(azx_t *chip) +static void azx_int_enable(struct azx *chip) { /* enable controller CIE and GIE */ azx_writel(chip, INTCTL, azx_readl(chip, INTCTL) | @@ -650,13 +646,13 @@ static void azx_int_enable(azx_t *chip) } /* disable interrupts */ -static void azx_int_disable(azx_t *chip) +static void azx_int_disable(struct azx *chip) { int i; /* disable interrupts in stream descriptor */ for (i = 0; i < chip->num_streams; i++) { - azx_dev_t *azx_dev = &chip->azx_dev[i]; + struct azx_dev *azx_dev = &chip->azx_dev[i]; azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & ~SD_INT_MASK); } @@ -670,13 +666,13 @@ static void azx_int_disable(azx_t *chip) } /* clear interrupts */ -static void azx_int_clear(azx_t *chip) +static void azx_int_clear(struct azx *chip) { int i; /* clear stream status */ for (i = 0; i < chip->num_streams; i++) { - azx_dev_t *azx_dev = &chip->azx_dev[i]; + struct azx_dev *azx_dev = &chip->azx_dev[i]; azx_sd_writeb(azx_dev, SD_STS, SD_INT_MASK); } @@ -691,7 +687,7 @@ static void azx_int_clear(azx_t *chip) } /* start a stream */ -static void azx_stream_start(azx_t *chip, azx_dev_t *azx_dev) +static void azx_stream_start(struct azx *chip, struct azx_dev *azx_dev) { /* enable SIE */ azx_writeb(chip, INTCTL, @@ -702,7 +698,7 @@ static void azx_stream_start(azx_t *chip, azx_dev_t *azx_dev) } /* stop a stream */ -static void azx_stream_stop(azx_t *chip, azx_dev_t *azx_dev) +static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev) { /* stop DMA */ azx_sd_writeb(azx_dev, SD_CTL, azx_sd_readb(azx_dev, SD_CTL) & @@ -717,7 +713,7 @@ static void azx_stream_stop(azx_t *chip, azx_dev_t *azx_dev) /* * initialize the chip */ -static void azx_init_chip(azx_t *chip) +static void azx_init_chip(struct azx *chip) { unsigned char reg; @@ -765,8 +761,8 @@ static void azx_init_chip(azx_t *chip) */ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs) { - azx_t *chip = dev_id; - azx_dev_t *azx_dev; + struct azx *chip = dev_id; + struct azx_dev *azx_dev; u32 status; int i; @@ -814,7 +810,7 @@ static irqreturn_t azx_interrupt(int irq, void* dev_id, struct pt_regs *regs) /* * set up BDL entries */ -static void azx_setup_periods(azx_dev_t *azx_dev) +static void azx_setup_periods(struct azx_dev *azx_dev) { u32 *bdl = azx_dev->bdl; dma_addr_t dma_addr = azx_dev->substream->runtime->dma_addr; @@ -843,7 +839,7 @@ static void azx_setup_periods(azx_dev_t *azx_dev) /* * set up the SD for streaming */ -static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev) +static int azx_setup_controller(struct azx *chip, struct azx_dev *azx_dev) { unsigned char val; int timeout; @@ -903,7 +899,7 @@ static int azx_setup_controller(azx_t *chip, azx_dev_t *azx_dev) * Codec initialization */ -static int __devinit azx_codec_create(azx_t *chip, const char *model) +static int __devinit azx_codec_create(struct azx *chip, const char *model) { struct hda_bus_template bus_temp; int c, codecs, err; @@ -941,7 +937,7 @@ static int __devinit azx_codec_create(azx_t *chip, const char *model) */ /* assign a stream for the PCM */ -static inline azx_dev_t *azx_assign_device(azx_t *chip, int stream) +static inline struct azx_dev *azx_assign_device(struct azx *chip, int stream) { int dev, i, nums; if (stream == SNDRV_PCM_STREAM_PLAYBACK) { @@ -960,12 +956,12 @@ static inline azx_dev_t *azx_assign_device(azx_t *chip, int stream) } /* release the assigned stream */ -static inline void azx_release_device(azx_dev_t *azx_dev) +static inline void azx_release_device(struct azx_dev *azx_dev) { azx_dev->opened = 0; } -static snd_pcm_hardware_t azx_pcm_hw = { +static struct snd_pcm_hardware azx_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID | @@ -986,18 +982,18 @@ static snd_pcm_hardware_t azx_pcm_hw = { }; struct azx_pcm { - azx_t *chip; + struct azx *chip; struct hda_codec *codec; struct hda_pcm_stream *hinfo[2]; }; -static int azx_pcm_open(snd_pcm_substream_t *substream) +static int azx_pcm_open(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; - azx_t *chip = apcm->chip; - azx_dev_t *azx_dev; - snd_pcm_runtime_t *runtime = substream->runtime; + struct azx *chip = apcm->chip; + struct azx_dev *azx_dev; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; int err; @@ -1029,12 +1025,12 @@ static int azx_pcm_open(snd_pcm_substream_t *substream) return 0; } -static int azx_pcm_close(snd_pcm_substream_t *substream) +static int azx_pcm_close(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; - azx_t *chip = apcm->chip; - azx_dev_t *azx_dev = get_azx_dev(substream); + struct azx *chip = apcm->chip; + struct azx_dev *azx_dev = get_azx_dev(substream); unsigned long flags; down(&chip->open_mutex); @@ -1048,15 +1044,15 @@ static int azx_pcm_close(snd_pcm_substream_t *substream) return 0; } -static int azx_pcm_hw_params(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *hw_params) +static int azx_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int azx_pcm_hw_free(snd_pcm_substream_t *substream) +static int azx_pcm_hw_free(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); - azx_dev_t *azx_dev = get_azx_dev(substream); + struct azx_dev *azx_dev = get_azx_dev(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; /* reset BDL address */ @@ -1069,13 +1065,13 @@ static int azx_pcm_hw_free(snd_pcm_substream_t *substream) return snd_pcm_lib_free_pages(substream); } -static int azx_pcm_prepare(snd_pcm_substream_t *substream) +static int azx_pcm_prepare(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); - azx_t *chip = apcm->chip; - azx_dev_t *azx_dev = get_azx_dev(substream); + struct azx *chip = apcm->chip; + struct azx_dev *azx_dev = get_azx_dev(substream); struct hda_pcm_stream *hinfo = apcm->hinfo[substream->stream]; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; azx_dev->bufsize = snd_pcm_lib_buffer_bytes(substream); azx_dev->fragsize = snd_pcm_lib_period_bytes(substream); @@ -1104,11 +1100,11 @@ static int azx_pcm_prepare(snd_pcm_substream_t *substream) azx_dev->format_val, substream); } -static int azx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int azx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); - azx_dev_t *azx_dev = get_azx_dev(substream); - azx_t *chip = apcm->chip; + struct azx_dev *azx_dev = get_azx_dev(substream); + struct azx *chip = apcm->chip; int err = 0; spin_lock(&chip->reg_lock); @@ -1139,11 +1135,11 @@ static int azx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) return err; } -static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) { struct azx_pcm *apcm = snd_pcm_substream_chip(substream); - azx_t *chip = apcm->chip; - azx_dev_t *azx_dev = get_azx_dev(substream); + struct azx *chip = apcm->chip; + struct azx_dev *azx_dev = get_azx_dev(substream); unsigned int pos; if (chip->position_fix == POS_FIX_POSBUF) { @@ -1185,7 +1181,7 @@ static snd_pcm_uframes_t azx_pcm_pointer(snd_pcm_substream_t *substream) return bytes_to_frames(substream->runtime, pos); } -static snd_pcm_ops_t azx_pcm_ops = { +static struct snd_pcm_ops azx_pcm_ops = { .open = azx_pcm_open, .close = azx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -1196,16 +1192,16 @@ static snd_pcm_ops_t azx_pcm_ops = { .pointer = azx_pcm_pointer, }; -static void azx_pcm_free(snd_pcm_t *pcm) +static void azx_pcm_free(struct snd_pcm *pcm) { kfree(pcm->private_data); } -static int __devinit create_codec_pcm(azx_t *chip, struct hda_codec *codec, +static int __devinit create_codec_pcm(struct azx *chip, struct hda_codec *codec, struct hda_pcm *cpcm, int pcm_dev) { int err; - snd_pcm_t *pcm; + struct snd_pcm *pcm; struct azx_pcm *apcm; snd_assert(cpcm->stream[0].substreams || cpcm->stream[1].substreams, return -EINVAL); @@ -1239,7 +1235,7 @@ static int __devinit create_codec_pcm(azx_t *chip, struct hda_codec *codec, return 0; } -static int __devinit azx_pcm_create(azx_t *chip) +static int __devinit azx_pcm_create(struct azx *chip) { struct list_head *p; struct hda_codec *codec; @@ -1291,7 +1287,7 @@ static int __devinit azx_pcm_create(azx_t *chip) /* * mixer creation - all stuff is implemented in hda module */ -static int __devinit azx_mixer_create(azx_t *chip) +static int __devinit azx_mixer_create(struct azx *chip) { return snd_hda_build_controls(chip->bus); } @@ -1300,7 +1296,7 @@ static int __devinit azx_mixer_create(azx_t *chip) /* * initialize SD streams */ -static int __devinit azx_init_stream(azx_t *chip) +static int __devinit azx_init_stream(struct azx *chip) { int i; @@ -1309,7 +1305,7 @@ static int __devinit azx_init_stream(azx_t *chip) */ for (i = 0; i < chip->num_streams; i++) { unsigned int off = sizeof(u32) * (i * AZX_MAX_FRAG * 4); - azx_dev_t *azx_dev = &chip->azx_dev[i]; + struct azx_dev *azx_dev = &chip->azx_dev[i]; azx_dev->bdl = (u32 *)(chip->bdl.area + off); azx_dev->bdl_addr = chip->bdl.addr + off; azx_dev->posbuf = (volatile u32 *)(chip->posbuf.area + i * 8); @@ -1330,9 +1326,9 @@ static int __devinit azx_init_stream(azx_t *chip) /* * power management */ -static int azx_suspend(snd_card_t *card, pm_message_t state) +static int azx_suspend(struct snd_card *card, pm_message_t state) { - azx_t *chip = card->pm_private_data; + struct azx *chip = card->pm_private_data; int i; for (i = 0; i < chip->pcm_devs; i++) @@ -1344,9 +1340,9 @@ static int azx_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int azx_resume(snd_card_t *card) +static int azx_resume(struct snd_card *card) { - azx_t *chip = card->pm_private_data; + struct azx *chip = card->pm_private_data; pci_enable_device(chip->pci); pci_set_master(chip->pci); @@ -1360,7 +1356,7 @@ static int azx_resume(snd_card_t *card) /* * destructor */ -static int azx_free(azx_t *chip) +static int azx_free(struct azx *chip) { if (chip->initialized) { int i; @@ -1402,7 +1398,7 @@ static int azx_free(azx_t *chip) return 0; } -static int azx_dev_free(snd_device_t *device) +static int azx_dev_free(struct snd_device *device) { return azx_free(device->device_data); } @@ -1410,13 +1406,13 @@ static int azx_dev_free(snd_device_t *device) /* * constructor */ -static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, +static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, int posfix, int driver_type, - azx_t **rchip) + struct azx **rchip) { - azx_t *chip; + struct azx *chip; int err = 0; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = azx_dev_free, }; @@ -1548,8 +1544,8 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - azx_t *chip; + struct snd_card *card; + struct azx *chip; int err = 0; card = snd_card_new(index, id, THIS_MODULE, 0); -- cgit v1.1 From 6ca308d4edd51c4f34ffff94ae0bbf193087d89f Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 14:59:52 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI ICE1712 Modules: ICE1712 driver Remove xxx_t typedefs from the PCI ICE1712 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ice1712/ak4xxx.c | 26 +- sound/pci/ice1712/delta.c | 82 +++---- sound/pci/ice1712/ews.c | 144 +++++------ sound/pci/ice1712/hoontech.c | 30 +-- sound/pci/ice1712/ice1712.c | 554 +++++++++++++++++++++++-------------------- sound/pci/ice1712/ice1712.h | 118 ++++----- 6 files changed, 500 insertions(+), 454 deletions(-) diff --git a/sound/pci/ice1712/ak4xxx.c b/sound/pci/ice1712/ak4xxx.c index ae9dc02..ab00cce 100644 --- a/sound/pci/ice1712/ak4xxx.c +++ b/sound/pci/ice1712/ak4xxx.c @@ -34,16 +34,16 @@ MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); MODULE_DESCRIPTION("ICEnsemble ICE17xx <-> AK4xxx AD/DA chip interface"); MODULE_LICENSE("GPL"); -static void snd_ice1712_akm4xxx_lock(akm4xxx_t *ak, int chip) +static void snd_ice1712_akm4xxx_lock(struct snd_akm4xxx *ak, int chip) { - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; snd_ice1712_save_gpio_status(ice); } -static void snd_ice1712_akm4xxx_unlock(akm4xxx_t *ak, int chip) +static void snd_ice1712_akm4xxx_unlock(struct snd_akm4xxx *ak, int chip) { - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; snd_ice1712_restore_gpio_status(ice); } @@ -51,14 +51,14 @@ static void snd_ice1712_akm4xxx_unlock(akm4xxx_t *ak, int chip) /* * write AK4xxx register */ -static void snd_ice1712_akm4xxx_write(akm4xxx_t *ak, int chip, +static void snd_ice1712_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char addr, unsigned char data) { unsigned int tmp; int idx; unsigned int addrdata; struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; snd_assert(chip >= 0 && chip < 4, return); @@ -119,10 +119,10 @@ static void snd_ice1712_akm4xxx_write(akm4xxx_t *ak, int chip, } /* - * initialize the akm4xxx_t record with the template + * initialize the struct snd_akm4xxx record with the template */ -int snd_ice1712_akm4xxx_init(akm4xxx_t *ak, const akm4xxx_t *temp, - const struct snd_ak4xxx_private *_priv, ice1712_t *ice) +int snd_ice1712_akm4xxx_init(struct snd_akm4xxx *ak, const struct snd_akm4xxx *temp, + const struct snd_ak4xxx_private *_priv, struct snd_ice1712 *ice) { struct snd_ak4xxx_private *priv; @@ -148,13 +148,13 @@ int snd_ice1712_akm4xxx_init(akm4xxx_t *ak, const akm4xxx_t *temp, return 0; } -void snd_ice1712_akm4xxx_free(ice1712_t *ice) +void snd_ice1712_akm4xxx_free(struct snd_ice1712 *ice) { unsigned int akidx; if (ice->akm == NULL) return; for (akidx = 0; akidx < ice->akm_codecs; akidx++) { - akm4xxx_t *ak = &ice->akm[akidx]; + struct snd_akm4xxx *ak = &ice->akm[akidx]; kfree((void*)ak->private_value[0]); } kfree(ice->akm); @@ -163,13 +163,13 @@ void snd_ice1712_akm4xxx_free(ice1712_t *ice) /* * build AK4xxx controls */ -int snd_ice1712_akm4xxx_build_controls(ice1712_t *ice) +int snd_ice1712_akm4xxx_build_controls(struct snd_ice1712 *ice) { unsigned int akidx; int err; for (akidx = 0; akidx < ice->akm_codecs; akidx++) { - akm4xxx_t *ak = &ice->akm[akidx]; + struct snd_akm4xxx *ak = &ice->akm[akidx]; err = snd_akm4xxx_build_controls(ak); if (err < 0) return err; diff --git a/sound/pci/ice1712/delta.c b/sound/pci/ice1712/delta.c index 576f69d..9a51d34 100644 --- a/sound/pci/ice1712/delta.c +++ b/sound/pci/ice1712/delta.c @@ -44,7 +44,7 @@ */ /* send 8 bits */ -static void ap_cs8427_write_byte(ice1712_t *ice, unsigned char data, unsigned char tmp) +static void ap_cs8427_write_byte(struct snd_ice1712 *ice, unsigned char data, unsigned char tmp) { int idx; @@ -61,7 +61,7 @@ static void ap_cs8427_write_byte(ice1712_t *ice, unsigned char data, unsigned ch } /* read 8 bits */ -static unsigned char ap_cs8427_read_byte(ice1712_t *ice, unsigned char tmp) +static unsigned char ap_cs8427_read_byte(struct snd_ice1712 *ice, unsigned char tmp) { unsigned char data = 0; int idx; @@ -80,7 +80,7 @@ static unsigned char ap_cs8427_read_byte(ice1712_t *ice, unsigned char tmp) } /* assert chip select */ -static unsigned char ap_cs8427_codec_select(ice1712_t *ice) +static unsigned char ap_cs8427_codec_select(struct snd_ice1712 *ice) { unsigned char tmp; tmp = snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA); @@ -105,7 +105,7 @@ static unsigned char ap_cs8427_codec_select(ice1712_t *ice) } /* deassert chip select */ -static void ap_cs8427_codec_deassert(ice1712_t *ice, unsigned char tmp) +static void ap_cs8427_codec_deassert(struct snd_ice1712 *ice, unsigned char tmp) { switch (ice->eeprom.subvendor) { case ICE1712_SUBDEVICE_DELTA1010LT: @@ -124,9 +124,9 @@ static void ap_cs8427_codec_deassert(ice1712_t *ice, unsigned char tmp) } /* sequential write */ -static int ap_cs8427_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, int count) +static int ap_cs8427_sendbytes(struct snd_i2c_device *device, unsigned char *bytes, int count) { - ice1712_t *ice = device->bus->private_data; + struct snd_ice1712 *ice = device->bus->private_data; int res = count; unsigned char tmp; @@ -141,9 +141,9 @@ static int ap_cs8427_sendbytes(snd_i2c_device_t *device, unsigned char *bytes, i } /* sequential read */ -static int ap_cs8427_readbytes(snd_i2c_device_t *device, unsigned char *bytes, int count) +static int ap_cs8427_readbytes(struct snd_i2c_device *device, unsigned char *bytes, int count) { - ice1712_t *ice = device->bus->private_data; + struct snd_ice1712 *ice = device->bus->private_data; int res = count; unsigned char tmp; @@ -157,14 +157,14 @@ static int ap_cs8427_readbytes(snd_i2c_device_t *device, unsigned char *bytes, i return res; } -static int ap_cs8427_probeaddr(snd_i2c_bus_t *bus, unsigned short addr) +static int ap_cs8427_probeaddr(struct snd_i2c_bus *bus, unsigned short addr) { if (addr == 0x10) return 1; return -ENOENT; } -static snd_i2c_ops_t ap_cs8427_i2c_ops = { +static struct snd_i2c_ops ap_cs8427_i2c_ops = { .sendbytes = ap_cs8427_sendbytes, .readbytes = ap_cs8427_readbytes, .probeaddr = ap_cs8427_probeaddr, @@ -173,7 +173,7 @@ static snd_i2c_ops_t ap_cs8427_i2c_ops = { /* */ -static void snd_ice1712_delta_cs8403_spdif_write(ice1712_t *ice, unsigned char bits) +static void snd_ice1712_delta_cs8403_spdif_write(struct snd_ice1712 *ice, unsigned char bits) { unsigned char tmp, mask1, mask2; int idx; @@ -198,12 +198,12 @@ static void snd_ice1712_delta_cs8403_spdif_write(ice1712_t *ice, unsigned char b } -static void delta_spdif_default_get(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol) +static void delta_spdif_default_get(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol) { snd_cs8403_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_bits); } -static int delta_spdif_default_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol) +static int delta_spdif_default_put(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol) { unsigned int val; int change; @@ -221,12 +221,12 @@ static int delta_spdif_default_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontr return change; } -static void delta_spdif_stream_get(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol) +static void delta_spdif_stream_get(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol) { snd_cs8403_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_stream_bits); } -static int delta_spdif_stream_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol) +static int delta_spdif_stream_put(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol) { unsigned int val; int change; @@ -248,10 +248,10 @@ static int delta_spdif_stream_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontro /* * AK4524 on Delta 44 and 66 to choose the chip mask */ -static void delta_ak4524_lock(akm4xxx_t *ak, int chip) +static void delta_ak4524_lock(struct snd_akm4xxx *ak, int chip) { struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; snd_ice1712_save_gpio_status(ice); priv->cs_mask = @@ -262,10 +262,10 @@ static void delta_ak4524_lock(akm4xxx_t *ak, int chip) /* * AK4524 on Delta1010LT to choose the chip address */ -static void delta1010lt_ak4524_lock(akm4xxx_t *ak, int chip) +static void delta1010lt_ak4524_lock(struct snd_akm4xxx *ak, int chip) { struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; snd_ice1712_save_gpio_status(ice); priv->cs_mask = ICE1712_DELTA_1010LT_CS; @@ -275,10 +275,10 @@ static void delta1010lt_ak4524_lock(akm4xxx_t *ak, int chip) /* * AK4528 on VX442 to choose the chip mask */ -static void vx442_ak4524_lock(akm4xxx_t *ak, int chip) +static void vx442_ak4524_lock(struct snd_akm4xxx *ak, int chip) { struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; snd_ice1712_save_gpio_status(ice); priv->cs_mask = @@ -289,7 +289,7 @@ static void vx442_ak4524_lock(akm4xxx_t *ak, int chip) /* * change the DFS bit according rate for Delta1010 */ -static void delta_1010_set_rate_val(ice1712_t *ice, unsigned int rate) +static void delta_1010_set_rate_val(struct snd_ice1712 *ice, unsigned int rate) { unsigned char tmp, tmp2; @@ -309,10 +309,10 @@ static void delta_1010_set_rate_val(ice1712_t *ice, unsigned int rate) /* * change the rate of AK4524 on Delta 44/66, AP, 1010LT */ -static void delta_ak4524_set_rate_val(akm4xxx_t *ak, unsigned int rate) +static void delta_ak4524_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) { unsigned char tmp, tmp2; - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; if (rate == 0) /* no hint - S/PDIF input is master, simply return */ return; @@ -341,7 +341,7 @@ static void delta_ak4524_set_rate_val(akm4xxx_t *ak, unsigned int rate) /* * change the rate of AK4524 on VX442 */ -static void vx442_ak4524_set_rate_val(akm4xxx_t *ak, unsigned int rate) +static void vx442_ak4524_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) { unsigned char val; @@ -361,13 +361,13 @@ static void vx442_ak4524_set_rate_val(akm4xxx_t *ak, unsigned int rate) */ /* open callback */ -static void delta_open_spdif(ice1712_t *ice, snd_pcm_substream_t * substream) +static void delta_open_spdif(struct snd_ice1712 *ice, struct snd_pcm_substream *substream) { ice->spdif.cs8403_stream_bits = ice->spdif.cs8403_bits; } /* set up */ -static void delta_setup_spdif(ice1712_t *ice, int rate) +static void delta_setup_spdif(struct snd_ice1712 *ice, int rate) { unsigned long flags; unsigned int tmp; @@ -396,7 +396,7 @@ static void delta_setup_spdif(ice1712_t *ice, int rate) * initialize the chips on M-Audio cards */ -static akm4xxx_t akm_audiophile __devinitdata = { +static struct snd_akm4xxx akm_audiophile __devinitdata = { .type = SND_AK4528, .num_adcs = 2, .num_dacs = 2, @@ -417,7 +417,7 @@ static struct snd_ak4xxx_private akm_audiophile_priv __devinitdata = { .mask_flags = 0, }; -static akm4xxx_t akm_delta410 __devinitdata = { +static struct snd_akm4xxx akm_delta410 __devinitdata = { .type = SND_AK4529, .num_adcs = 2, .num_dacs = 8, @@ -438,7 +438,7 @@ static struct snd_ak4xxx_private akm_delta410_priv __devinitdata = { .mask_flags = 0, }; -static akm4xxx_t akm_delta1010lt __devinitdata = { +static struct snd_akm4xxx akm_delta1010lt __devinitdata = { .type = SND_AK4524, .num_adcs = 8, .num_dacs = 8, @@ -460,7 +460,7 @@ static struct snd_ak4xxx_private akm_delta1010lt_priv __devinitdata = { .mask_flags = 0, }; -static akm4xxx_t akm_delta44 __devinitdata = { +static struct snd_akm4xxx akm_delta44 __devinitdata = { .type = SND_AK4524, .num_adcs = 4, .num_dacs = 4, @@ -482,7 +482,7 @@ static struct snd_ak4xxx_private akm_delta44_priv __devinitdata = { .mask_flags = 0, }; -static akm4xxx_t akm_vx442 __devinitdata = { +static struct snd_akm4xxx akm_vx442 __devinitdata = { .type = SND_AK4524, .num_adcs = 4, .num_dacs = 4, @@ -504,10 +504,10 @@ static struct snd_ak4xxx_private akm_vx442_priv __devinitdata = { .mask_flags = 0, }; -static int __devinit snd_ice1712_delta_init(ice1712_t *ice) +static int __devinit snd_ice1712_delta_init(struct snd_ice1712 *ice) { int err; - akm4xxx_t *ak; + struct snd_akm4xxx *ak; /* determine I2C, DACs and ADCs */ switch (ice->eeprom.subvendor) { @@ -582,7 +582,7 @@ static int __devinit snd_ice1712_delta_init(ice1712_t *ice) } /* second stage of initialization, analog parts and others */ - ak = ice->akm = kmalloc(sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kmalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ak) return -ENOMEM; ice->akm_codecs = 1; @@ -617,19 +617,19 @@ static int __devinit snd_ice1712_delta_init(ice1712_t *ice) * additional controls for M-Audio cards */ -static snd_kcontrol_new_t snd_ice1712_delta1010_wordclock_select __devinitdata = +static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_select __devinitdata = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_WORD_CLOCK_SELECT, 1, 0); -static snd_kcontrol_new_t snd_ice1712_delta1010lt_wordclock_select __devinitdata = +static struct snd_kcontrol_new snd_ice1712_delta1010lt_wordclock_select __devinitdata = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Sync", 0, ICE1712_DELTA_1010LT_WORDCLOCK, 1, 0); -static snd_kcontrol_new_t snd_ice1712_delta1010_wordclock_status __devinitdata = +static struct snd_kcontrol_new snd_ice1712_delta1010_wordclock_status __devinitdata = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Word Clock Status", 0, ICE1712_DELTA_WORD_CLOCK_STATUS, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); -static snd_kcontrol_new_t snd_ice1712_deltadio2496_spdif_in_select __devinitdata = +static struct snd_kcontrol_new snd_ice1712_deltadio2496_spdif_in_select __devinitdata = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, ICE1712_DELTA_SPDIF_INPUT_SELECT, 0, 0); -static snd_kcontrol_new_t snd_ice1712_delta_spdif_in_status __devinitdata = +static struct snd_kcontrol_new snd_ice1712_delta_spdif_in_status __devinitdata = ICE1712_GPIO(SNDRV_CTL_ELEM_IFACE_MIXER, "Delta IEC958 Input Status", 0, ICE1712_DELTA_SPDIF_IN_STAT, 1, SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE); -static int __devinit snd_ice1712_delta_add_controls(ice1712_t *ice) +static int __devinit snd_ice1712_delta_add_controls(struct snd_ice1712 *ice) { int err; diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c index c8ec5ca..2127d57 100644 --- a/sound/pci/ice1712/ews.c +++ b/sound/pci/ice1712/ews.c @@ -50,9 +50,9 @@ enum { */ /* send SDA and SCL */ -static void ewx_i2c_setlines(snd_i2c_bus_t *bus, int clk, int data) +static void ewx_i2c_setlines(struct snd_i2c_bus *bus, int clk, int data) { - ice1712_t *ice = bus->private_data; + struct snd_ice1712 *ice = bus->private_data; unsigned char tmp = 0; if (clk) tmp |= ICE1712_EWX2496_SERIAL_CLOCK; @@ -62,15 +62,15 @@ static void ewx_i2c_setlines(snd_i2c_bus_t *bus, int clk, int data) udelay(5); } -static int ewx_i2c_getclock(snd_i2c_bus_t *bus) +static int ewx_i2c_getclock(struct snd_i2c_bus *bus) { - ice1712_t *ice = bus->private_data; + struct snd_ice1712 *ice = bus->private_data; return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA) & ICE1712_EWX2496_SERIAL_CLOCK ? 1 : 0; } -static int ewx_i2c_getdata(snd_i2c_bus_t *bus, int ack) +static int ewx_i2c_getdata(struct snd_i2c_bus *bus, int ack) { - ice1712_t *ice = bus->private_data; + struct snd_ice1712 *ice = bus->private_data; int bit; /* set RW pin to low */ snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~ICE1712_EWX2496_RW); @@ -85,9 +85,9 @@ static int ewx_i2c_getdata(snd_i2c_bus_t *bus, int ack) return bit; } -static void ewx_i2c_start(snd_i2c_bus_t *bus) +static void ewx_i2c_start(struct snd_i2c_bus *bus) { - ice1712_t *ice = bus->private_data; + struct snd_ice1712 *ice = bus->private_data; unsigned char mask; snd_ice1712_save_gpio_status(ice); @@ -104,15 +104,15 @@ static void ewx_i2c_start(snd_i2c_bus_t *bus) snd_ice1712_gpio_write_bits(ice, mask, mask); } -static void ewx_i2c_stop(snd_i2c_bus_t *bus) +static void ewx_i2c_stop(struct snd_i2c_bus *bus) { - ice1712_t *ice = bus->private_data; + struct snd_ice1712 *ice = bus->private_data; snd_ice1712_restore_gpio_status(ice); } -static void ewx_i2c_direction(snd_i2c_bus_t *bus, int clock, int data) +static void ewx_i2c_direction(struct snd_i2c_bus *bus, int clock, int data) { - ice1712_t *ice = bus->private_data; + struct snd_ice1712 *ice = bus->private_data; unsigned char mask = 0; if (clock) @@ -125,7 +125,7 @@ static void ewx_i2c_direction(snd_i2c_bus_t *bus, int clock, int data) snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~mask); } -static snd_i2c_bit_ops_t snd_ice1712_ewx_cs8427_bit_ops = { +static struct snd_i2c_bit_ops snd_ice1712_ewx_cs8427_bit_ops = { .start = ewx_i2c_start, .stop = ewx_i2c_stop, .direction = ewx_i2c_direction, @@ -140,7 +140,7 @@ static snd_i2c_bit_ops_t snd_ice1712_ewx_cs8427_bit_ops = { */ /* AK4524 chip select; address 0x48 bit 0-3 */ -static int snd_ice1712_ews88mt_chip_select(ice1712_t *ice, int chip_mask) +static int snd_ice1712_ews88mt_chip_select(struct snd_ice1712 *ice, int chip_mask) { unsigned char data, ndata; @@ -162,9 +162,9 @@ static int snd_ice1712_ews88mt_chip_select(ice1712_t *ice, int chip_mask) } /* start callback for EWS88MT, needs to select a certain chip mask */ -static void ews88mt_ak4524_lock(akm4xxx_t *ak, int chip) +static void ews88mt_ak4524_lock(struct snd_akm4xxx *ak, int chip) { - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; unsigned char tmp; /* assert AK4524 CS */ if (snd_ice1712_ews88mt_chip_select(ice, ~(1 << chip) & 0x0f) < 0) @@ -179,18 +179,18 @@ static void ews88mt_ak4524_lock(akm4xxx_t *ak, int chip) } /* stop callback for EWS88MT, needs to deselect chip mask */ -static void ews88mt_ak4524_unlock(akm4xxx_t *ak, int chip) +static void ews88mt_ak4524_unlock(struct snd_akm4xxx *ak, int chip) { - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; snd_ice1712_restore_gpio_status(ice); udelay(1); snd_ice1712_ews88mt_chip_select(ice, 0x0f); } /* start callback for EWX24/96 */ -static void ewx2496_ak4524_lock(akm4xxx_t *ak, int chip) +static void ewx2496_ak4524_lock(struct snd_akm4xxx *ak, int chip) { - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; unsigned char tmp; snd_ice1712_save_gpio_status(ice); tmp = ICE1712_EWX2496_SERIAL_DATA | @@ -203,10 +203,10 @@ static void ewx2496_ak4524_lock(akm4xxx_t *ak, int chip) } /* start callback for DMX 6fire */ -static void dmx6fire_ak4524_lock(akm4xxx_t *ak, int chip) +static void dmx6fire_ak4524_lock(struct snd_akm4xxx *ak, int chip) { struct snd_ak4xxx_private *priv = (void *)ak->private_value[0]; - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; unsigned char tmp; snd_ice1712_save_gpio_status(ice); tmp = priv->cs_mask = priv->cs_addr = (1 << chip) & ICE1712_6FIRE_AK4524_CS_MASK; @@ -222,7 +222,7 @@ static void dmx6fire_ak4524_lock(akm4xxx_t *ak, int chip) * CS8404 interface on EWS88MT/D */ -static void snd_ice1712_ews_cs8404_spdif_write(ice1712_t *ice, unsigned char bits) +static void snd_ice1712_ews_cs8404_spdif_write(struct snd_ice1712 *ice, unsigned char bits) { unsigned char bytes[2]; @@ -251,12 +251,12 @@ static void snd_ice1712_ews_cs8404_spdif_write(ice1712_t *ice, unsigned char bit /* */ -static void ews88_spdif_default_get(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol) +static void ews88_spdif_default_get(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol) { snd_cs8404_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_bits); } -static int ews88_spdif_default_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol) +static int ews88_spdif_default_put(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol) { unsigned int val; int change; @@ -274,12 +274,12 @@ static int ews88_spdif_default_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontr return change; } -static void ews88_spdif_stream_get(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol) +static void ews88_spdif_stream_get(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol) { snd_cs8404_decode_spdif_bits(&ucontrol->value.iec958, ice->spdif.cs8403_stream_bits); } -static int ews88_spdif_stream_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontrol) +static int ews88_spdif_stream_put(struct snd_ice1712 *ice, struct snd_ctl_elem_value *ucontrol) { unsigned int val; int change; @@ -299,13 +299,13 @@ static int ews88_spdif_stream_put(ice1712_t *ice, snd_ctl_elem_value_t * ucontro /* open callback */ -static void ews88_open_spdif(ice1712_t *ice, snd_pcm_substream_t * substream) +static void ews88_open_spdif(struct snd_ice1712 *ice, struct snd_pcm_substream *substream) { ice->spdif.cs8403_stream_bits = ice->spdif.cs8403_bits; } /* set up SPDIF for EWS88MT / EWS88D */ -static void ews88_setup_spdif(ice1712_t *ice, int rate) +static void ews88_setup_spdif(struct snd_ice1712 *ice, int rate) { unsigned long flags; unsigned char tmp; @@ -332,7 +332,7 @@ static void ews88_setup_spdif(ice1712_t *ice, int rate) /* */ -static akm4xxx_t akm_ews88mt __devinitdata = { +static struct snd_akm4xxx akm_ews88mt __devinitdata = { .num_adcs = 8, .num_dacs = 8, .type = SND_AK4524, @@ -354,7 +354,7 @@ static struct snd_ak4xxx_private akm_ews88mt_priv __devinitdata = { .mask_flags = 0, }; -static akm4xxx_t akm_ewx2496 __devinitdata = { +static struct snd_akm4xxx akm_ewx2496 __devinitdata = { .num_adcs = 2, .num_dacs = 2, .type = SND_AK4524, @@ -375,7 +375,7 @@ static struct snd_ak4xxx_private akm_ewx2496_priv __devinitdata = { .mask_flags = 0, }; -static akm4xxx_t akm_6fire __devinitdata = { +static struct snd_akm4xxx akm_6fire __devinitdata = { .num_adcs = 6, .num_dacs = 6, .type = SND_AK4524, @@ -406,12 +406,12 @@ static struct snd_ak4xxx_private akm_6fire_priv __devinitdata = { #define PCF9554_REG_POLARITY 2 #define PCF9554_REG_CONFIG 3 -static int snd_ice1712_6fire_write_pca(ice1712_t *ice, unsigned char reg, unsigned char data); +static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data); -static int __devinit snd_ice1712_ews_init(ice1712_t *ice) +static int __devinit snd_ice1712_ews_init(struct snd_ice1712 *ice) { int err; - akm4xxx_t *ak; + struct snd_akm4xxx *ak; /* set the analog DACs */ switch (ice->eeprom.subvendor) { @@ -507,7 +507,7 @@ static int __devinit snd_ice1712_ews_init(ice1712_t *ice) } /* analog section */ - ak = ice->akm = kmalloc(sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kmalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ak) return -ENOMEM; ice->akm_codecs = 1; @@ -536,7 +536,7 @@ static int __devinit snd_ice1712_ews_init(ice1712_t *ice) */ /* i/o sensitivity - this callback is shared among other devices, too */ -static int snd_ice1712_ewx_io_sense_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo){ +static int snd_ice1712_ewx_io_sense_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo){ static char *texts[2] = { "+4dBu", "-10dBV", @@ -550,9 +550,9 @@ static int snd_ice1712_ewx_io_sense_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_ice1712_ewx_io_sense_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_ewx_io_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char mask = kcontrol->private_value & 0xff; snd_ice1712_save_gpio_status(ice); @@ -561,9 +561,9 @@ static int snd_ice1712_ewx_io_sense_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return 0; } -static int snd_ice1712_ewx_io_sense_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_ewx_io_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char mask = kcontrol->private_value & 0xff; int val, nval; @@ -578,7 +578,7 @@ static int snd_ice1712_ewx_io_sense_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_ return val != nval; } -static snd_kcontrol_new_t snd_ice1712_ewx2496_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_ewx2496_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Input Sensitivity Switch", @@ -602,9 +602,9 @@ static snd_kcontrol_new_t snd_ice1712_ewx2496_controls[] __devinitdata = { * EWS88MT specific controls */ /* analog output sensitivity;; address 0x48 bit 6 */ -static int snd_ice1712_ews88mt_output_sense_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_ews88mt_output_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char data; snd_i2c_lock(ice->i2c); @@ -618,9 +618,9 @@ static int snd_ice1712_ews88mt_output_sense_get(snd_kcontrol_t *kcontrol, snd_ct } /* analog output sensitivity;; address 0x48 bit 6 */ -static int snd_ice1712_ews88mt_output_sense_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_ews88mt_output_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char data, ndata; snd_i2c_lock(ice->i2c); @@ -638,9 +638,9 @@ static int snd_ice1712_ews88mt_output_sense_put(snd_kcontrol_t *kcontrol, snd_ct } /* analog input sensitivity; address 0x46 */ -static int snd_ice1712_ews88mt_input_sense_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_ews88mt_input_sense_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned char data; @@ -657,9 +657,9 @@ static int snd_ice1712_ews88mt_input_sense_get(snd_kcontrol_t *kcontrol, snd_ctl } /* analog output sensitivity; address 0x46 */ -static int snd_ice1712_ews88mt_input_sense_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_ews88mt_input_sense_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int channel = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned char data, ndata; @@ -678,7 +678,7 @@ static int snd_ice1712_ews88mt_input_sense_put(snd_kcontrol_t *kcontrol, snd_ctl return ndata != data; } -static snd_kcontrol_new_t snd_ice1712_ews88mt_input_sense __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_ews88mt_input_sense __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Input Sensitivity Switch", .info = snd_ice1712_ewx_io_sense_info, @@ -687,7 +687,7 @@ static snd_kcontrol_new_t snd_ice1712_ews88mt_input_sense __devinitdata = { .count = 8, }; -static snd_kcontrol_new_t snd_ice1712_ews88mt_output_sense __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_ews88mt_output_sense __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Output Sensitivity Switch", .info = snd_ice1712_ewx_io_sense_info, @@ -700,7 +700,7 @@ static snd_kcontrol_new_t snd_ice1712_ews88mt_output_sense __devinitdata = { * EWS88D specific controls */ -static int snd_ice1712_ews88d_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ice1712_ews88d_control_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -709,9 +709,9 @@ static int snd_ice1712_ews88d_control_info(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_ice1712_ews88d_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_ews88d_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value >> 8) & 1; unsigned char data[2]; @@ -729,9 +729,9 @@ static int snd_ice1712_ews88d_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_ice1712_ews88d_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_ews88d_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value >> 8) & 1; unsigned char data[2], ndata[2]; @@ -769,7 +769,7 @@ static int snd_ice1712_ews88d_control_put(snd_kcontrol_t * kcontrol, snd_ctl_ele .private_value = xshift | (xinvert << 8),\ } -static snd_kcontrol_new_t snd_ice1712_ews88d_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_ews88d_controls[] __devinitdata = { EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "IEC958 Input Optical", 0, 1, 0), /* inverted */ EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT Output Optical", 1, 0, 0), EWS88D_CONTROL(SNDRV_CTL_ELEM_IFACE_MIXER, "ADAT External Master Clock", 2, 0, 0), @@ -782,7 +782,7 @@ static snd_kcontrol_new_t snd_ice1712_ews88d_controls[] __devinitdata = { * DMX 6Fire specific controls */ -static int snd_ice1712_6fire_read_pca(ice1712_t *ice, unsigned char reg) +static int snd_ice1712_6fire_read_pca(struct snd_ice1712 *ice, unsigned char reg) { unsigned char byte; snd_i2c_lock(ice->i2c); @@ -798,7 +798,7 @@ static int snd_ice1712_6fire_read_pca(ice1712_t *ice, unsigned char reg) return byte; } -static int snd_ice1712_6fire_write_pca(ice1712_t *ice, unsigned char reg, unsigned char data) +static int snd_ice1712_6fire_write_pca(struct snd_ice1712 *ice, unsigned char reg, unsigned char data) { unsigned char bytes[2]; snd_i2c_lock(ice->i2c); @@ -812,7 +812,7 @@ static int snd_ice1712_6fire_write_pca(ice1712_t *ice, unsigned char reg, unsign return 0; } -static int snd_ice1712_6fire_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ice1712_6fire_control_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -821,9 +821,9 @@ static int snd_ice1712_6fire_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_ice1712_6fire_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_6fire_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value >> 8) & 1; int data; @@ -837,9 +837,9 @@ static int snd_ice1712_6fire_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_ice1712_6fire_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_6fire_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value >> 8) & 1; int data, ndata; @@ -858,7 +858,7 @@ static int snd_ice1712_6fire_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_ice1712_6fire_select_input_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ice1712_6fire_select_input_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "Internal", "Front Input", "Rear Input", "Wave Table" @@ -872,9 +872,9 @@ static int snd_ice1712_6fire_select_input_info(snd_kcontrol_t *kcontrol, snd_ctl return 0; } -static int snd_ice1712_6fire_select_input_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_6fire_select_input_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int data; if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0) @@ -883,9 +883,9 @@ static int snd_ice1712_6fire_select_input_get(snd_kcontrol_t *kcontrol, snd_ctl_ return 0; } -static int snd_ice1712_6fire_select_input_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_6fire_select_input_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int data, ndata; if ((data = snd_ice1712_6fire_read_pca(ice, PCF9554_REG_OUTPUT)) < 0) @@ -909,7 +909,7 @@ static int snd_ice1712_6fire_select_input_put(snd_kcontrol_t *kcontrol, snd_ctl_ .private_value = xshift | (xinvert << 8),\ } -static snd_kcontrol_new_t snd_ice1712_6fire_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Analog Input Select", @@ -925,7 +925,7 @@ static snd_kcontrol_new_t snd_ice1712_6fire_controls[] __devinitdata = { }; -static int __devinit snd_ice1712_ews_add_controls(ice1712_t *ice) +static int __devinit snd_ice1712_ews_add_controls(struct snd_ice1712 *ice) { unsigned int idx; int err; diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c index ab5fbd0..3f2f918 100644 --- a/sound/pci/ice1712/hoontech.c +++ b/sound/pci/ice1712/hoontech.c @@ -33,7 +33,7 @@ #include "hoontech.h" -static void __devinit snd_ice1712_stdsp24_gpio_write(ice1712_t *ice, unsigned char byte) +static void __devinit snd_ice1712_stdsp24_gpio_write(struct snd_ice1712 *ice, unsigned char byte) { byte |= ICE1712_STDSP24_CLOCK_BIT; udelay(100); @@ -46,7 +46,7 @@ static void __devinit snd_ice1712_stdsp24_gpio_write(ice1712_t *ice, unsigned ch snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, byte); } -static void __devinit snd_ice1712_stdsp24_darear(ice1712_t *ice, int activate) +static void __devinit snd_ice1712_stdsp24_darear(struct snd_ice1712 *ice, int activate) { down(&ice->gpio_mutex); ICE1712_STDSP24_0_DAREAR(ice->spec.hoontech.boxbits, activate); @@ -54,7 +54,7 @@ static void __devinit snd_ice1712_stdsp24_darear(ice1712_t *ice, int activate) up(&ice->gpio_mutex); } -static void __devinit snd_ice1712_stdsp24_mute(ice1712_t *ice, int activate) +static void __devinit snd_ice1712_stdsp24_mute(struct snd_ice1712 *ice, int activate) { down(&ice->gpio_mutex); ICE1712_STDSP24_3_MUTE(ice->spec.hoontech.boxbits, activate); @@ -62,7 +62,7 @@ static void __devinit snd_ice1712_stdsp24_mute(ice1712_t *ice, int activate) up(&ice->gpio_mutex); } -static void __devinit snd_ice1712_stdsp24_insel(ice1712_t *ice, int activate) +static void __devinit snd_ice1712_stdsp24_insel(struct snd_ice1712 *ice, int activate) { down(&ice->gpio_mutex); ICE1712_STDSP24_3_INSEL(ice->spec.hoontech.boxbits, activate); @@ -70,7 +70,7 @@ static void __devinit snd_ice1712_stdsp24_insel(ice1712_t *ice, int activate) up(&ice->gpio_mutex); } -static void __devinit snd_ice1712_stdsp24_box_channel(ice1712_t *ice, int box, int chn, int activate) +static void __devinit snd_ice1712_stdsp24_box_channel(struct snd_ice1712 *ice, int box, int chn, int activate) { down(&ice->gpio_mutex); @@ -118,7 +118,7 @@ static void __devinit snd_ice1712_stdsp24_box_channel(ice1712_t *ice, int box, i up(&ice->gpio_mutex); } -static void __devinit snd_ice1712_stdsp24_box_midi(ice1712_t *ice, int box, int master) +static void __devinit snd_ice1712_stdsp24_box_midi(struct snd_ice1712 *ice, int box, int master) { down(&ice->gpio_mutex); @@ -144,7 +144,7 @@ static void __devinit snd_ice1712_stdsp24_box_midi(ice1712_t *ice, int box, int up(&ice->gpio_mutex); } -static void __devinit snd_ice1712_stdsp24_midi2(ice1712_t *ice, int activate) +static void __devinit snd_ice1712_stdsp24_midi2(struct snd_ice1712 *ice, int activate) { down(&ice->gpio_mutex); ICE1712_STDSP24_3_MIDI2(ice->spec.hoontech.boxbits, activate); @@ -152,7 +152,7 @@ static void __devinit snd_ice1712_stdsp24_midi2(ice1712_t *ice, int activate) up(&ice->gpio_mutex); } -static int __devinit snd_ice1712_hoontech_init(ice1712_t *ice) +static int __devinit snd_ice1712_hoontech_init(struct snd_ice1712 *ice) { int box, chn; @@ -221,9 +221,9 @@ static int __devinit snd_ice1712_hoontech_init(ice1712_t *ice) */ /* start callback for STDSP24 with modified hardware */ -static void stdsp24_ak4524_lock(akm4xxx_t *ak, int chip) +static void stdsp24_ak4524_lock(struct snd_akm4xxx *ak, int chip) { - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; unsigned char tmp; snd_ice1712_save_gpio_status(ice); tmp = ICE1712_STDSP24_SERIAL_DATA | @@ -234,10 +234,10 @@ static void stdsp24_ak4524_lock(akm4xxx_t *ak, int chip) snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ~tmp); } -static int __devinit snd_ice1712_value_init(ice1712_t *ice) +static int __devinit snd_ice1712_value_init(struct snd_ice1712 *ice) { /* Hoontech STDSP24 with modified hardware */ - static akm4xxx_t akm_stdsp24_mv __devinitdata = { + static struct snd_akm4xxx akm_stdsp24_mv __devinitdata = { .num_adcs = 2, .num_dacs = 2, .type = SND_AK4524, @@ -258,7 +258,7 @@ static int __devinit snd_ice1712_value_init(ice1712_t *ice) }; int err; - akm4xxx_t *ak; + struct snd_akm4xxx *ak; /* set the analog DACs */ ice->num_total_dacs = 2; @@ -267,7 +267,7 @@ static int __devinit snd_ice1712_value_init(ice1712_t *ice) ice->num_total_adcs = 2; /* analog section */ - ak = ice->akm = kmalloc(sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kmalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ak) return -ENOMEM; ice->akm_codecs = 1; @@ -284,7 +284,7 @@ static int __devinit snd_ice1712_value_init(ice1712_t *ice) return 0; } -static int __devinit snd_ice1712_ez8_init(ice1712_t *ice) +static int __devinit snd_ice1712_ez8_init(struct snd_ice1712 *ice) { ice->gpio.write_mask = ice->eeprom.gpiomask; ice->gpio.direction = ice->eeprom.gpiodir; diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index b16c9c1..ef6f185 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c @@ -108,8 +108,8 @@ static struct pci_device_id snd_ice1712_ids[] = { MODULE_DEVICE_TABLE(pci, snd_ice1712_ids); -static int snd_ice1712_build_pro_mixer(ice1712_t *ice); -static int snd_ice1712_build_controls(ice1712_t *ice); +static int snd_ice1712_build_pro_mixer(struct snd_ice1712 *ice); +static int snd_ice1712_build_controls(struct snd_ice1712 *ice); static int PRO_RATE_LOCKED; static int PRO_RATE_RESET = 1; @@ -120,33 +120,33 @@ static unsigned int PRO_RATE_DEFAULT = 44100; */ /* check whether the clock mode is spdif-in */ -static inline int is_spdif_master(ice1712_t *ice) +static inline int is_spdif_master(struct snd_ice1712 *ice) { return (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER) ? 1 : 0; } -static inline int is_pro_rate_locked(ice1712_t *ice) +static inline int is_pro_rate_locked(struct snd_ice1712 *ice) { return is_spdif_master(ice) || PRO_RATE_LOCKED; } -static inline void snd_ice1712_ds_write(ice1712_t * ice, u8 channel, u8 addr, u32 data) +static inline void snd_ice1712_ds_write(struct snd_ice1712 * ice, u8 channel, u8 addr, u32 data) { outb((channel << 4) | addr, ICEDS(ice, INDEX)); outl(data, ICEDS(ice, DATA)); } -static inline u32 snd_ice1712_ds_read(ice1712_t * ice, u8 channel, u8 addr) +static inline u32 snd_ice1712_ds_read(struct snd_ice1712 * ice, u8 channel, u8 addr) { outb((channel << 4) | addr, ICEDS(ice, INDEX)); return inl(ICEDS(ice, DATA)); } -static void snd_ice1712_ac97_write(ac97_t *ac97, +static void snd_ice1712_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - ice1712_t *ice = (ice1712_t *)ac97->private_data; + struct snd_ice1712 *ice = ac97->private_data; int tm; unsigned char old_cmd = 0; @@ -167,10 +167,10 @@ static void snd_ice1712_ac97_write(ac97_t *ac97, break; } -static unsigned short snd_ice1712_ac97_read(ac97_t *ac97, +static unsigned short snd_ice1712_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - ice1712_t *ice = (ice1712_t *)ac97->private_data; + struct snd_ice1712 *ice = ac97->private_data; int tm; unsigned char old_cmd = 0; @@ -196,11 +196,11 @@ static unsigned short snd_ice1712_ac97_read(ac97_t *ac97, * pro ac97 section */ -static void snd_ice1712_pro_ac97_write(ac97_t *ac97, +static void snd_ice1712_pro_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - ice1712_t *ice = (ice1712_t *)ac97->private_data; + struct snd_ice1712 *ice = ac97->private_data; int tm; unsigned char old_cmd = 0; @@ -222,10 +222,10 @@ static void snd_ice1712_pro_ac97_write(ac97_t *ac97, } -static unsigned short snd_ice1712_pro_ac97_read(ac97_t *ac97, +static unsigned short snd_ice1712_pro_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - ice1712_t *ice = (ice1712_t *)ac97->private_data; + struct snd_ice1712 *ice = ac97->private_data; int tm; unsigned char old_cmd = 0; @@ -250,7 +250,7 @@ static unsigned short snd_ice1712_pro_ac97_read(ac97_t *ac97, /* * consumer ac97 digital mix */ -static int snd_ice1712_digmix_route_ac97_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ice1712_digmix_route_ac97_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -259,17 +259,17 @@ static int snd_ice1712_digmix_route_ac97_info(snd_kcontrol_t *kcontrol, snd_ctl_ return 0; } -static int snd_ice1712_digmix_route_ac97_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_digmix_route_ac97_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_ROUTECTRL)) & ICE1712_ROUTE_AC97 ? 1 : 0; return 0; } -static int snd_ice1712_digmix_route_ac97_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_digmix_route_ac97_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char val, nval; spin_lock_irq(&ice->reg_lock); @@ -281,7 +281,7 @@ static int snd_ice1712_digmix_route_ac97_put(snd_kcontrol_t *kcontrol, snd_ctl_e return val != nval; } -static snd_kcontrol_new_t snd_ice1712_mixer_digmix_route_ac97 __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_mixer_digmix_route_ac97 __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Digital Mixer To AC97", .info = snd_ice1712_digmix_route_ac97_info, @@ -293,24 +293,24 @@ static snd_kcontrol_new_t snd_ice1712_mixer_digmix_route_ac97 __devinitdata = { /* * gpio operations */ -static void snd_ice1712_set_gpio_dir(ice1712_t *ice, unsigned int data) +static void snd_ice1712_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data) { snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, data); inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */ } -static void snd_ice1712_set_gpio_mask(ice1712_t *ice, unsigned int data) +static void snd_ice1712_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data) { snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, data); inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */ } -static unsigned int snd_ice1712_get_gpio_data(ice1712_t *ice) +static unsigned int snd_ice1712_get_gpio_data(struct snd_ice1712 *ice) { return snd_ice1712_read(ice, ICE1712_IREG_GPIO_DATA); } -static void snd_ice1712_set_gpio_data(ice1712_t *ice, unsigned int val) +static void snd_ice1712_set_gpio_data(struct snd_ice1712 *ice, unsigned int val) { snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, val); inb(ICEREG(ice, DATA)); /* dummy read for pci-posting */ @@ -327,7 +327,7 @@ static void snd_ice1712_set_gpio_data(ice1712_t *ice, unsigned int val) * change the input clock selection * spdif_clock = 1 - IEC958 input, 0 - Envy24 */ -static int snd_ice1712_cs8427_set_input_clock(ice1712_t *ice, int spdif_clock) +static int snd_ice1712_cs8427_set_input_clock(struct snd_ice1712 *ice, int spdif_clock) { unsigned char reg[2] = { 0x80 | 4, 0 }; /* CS8427 auto increment | register number 4 + data */ unsigned char val, nval; @@ -362,17 +362,17 @@ static int snd_ice1712_cs8427_set_input_clock(ice1712_t *ice, int spdif_clock) /* * spdif callbacks */ -static void open_cs8427(ice1712_t *ice, snd_pcm_substream_t * substream) +static void open_cs8427(struct snd_ice1712 *ice, struct snd_pcm_substream *substream) { snd_cs8427_iec958_active(ice->cs8427, 1); } -static void close_cs8427(ice1712_t *ice, snd_pcm_substream_t * substream) +static void close_cs8427(struct snd_ice1712 *ice, struct snd_pcm_substream *substream) { snd_cs8427_iec958_active(ice->cs8427, 0); } -static void setup_cs8427(ice1712_t *ice, int rate) +static void setup_cs8427(struct snd_ice1712 *ice, int rate) { snd_cs8427_iec958_pcm(ice->cs8427, rate); } @@ -380,7 +380,7 @@ static void setup_cs8427(ice1712_t *ice, int rate) /* * create and initialize callbacks for cs8427 interface */ -int __devinit snd_ice1712_init_cs8427(ice1712_t *ice, int addr) +int __devinit snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr) { int err; @@ -403,7 +403,7 @@ int __devinit snd_ice1712_init_cs8427(ice1712_t *ice, int addr) static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ice1712_t *ice = dev_id; + struct snd_ice1712 *ice = dev_id; unsigned char status; int handled = 0; @@ -444,7 +444,7 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs * if (status & ICE1712_IRQ_PBKDS) { u32 idx; u16 pbkstatus; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; pbkstatus = inw(ICEDS(ice, INTSTAT)); //printk("pbkstatus = 0x%x\n", pbkstatus); for (idx = 0; idx < 6; idx++) { @@ -475,13 +475,13 @@ static irqreturn_t snd_ice1712_interrupt(int irq, void *dev_id, struct pt_regs * * PCM part - misc */ -static int snd_ice1712_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ice1712_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_ice1712_hw_free(snd_pcm_substream_t * substream) +static int snd_ice1712_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } @@ -490,10 +490,10 @@ static int snd_ice1712_hw_free(snd_pcm_substream_t * substream) * PCM part - consumer I/O */ -static int snd_ice1712_playback_trigger(snd_pcm_substream_t * substream, +static int snd_ice1712_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); int result = 0; u32 tmp; @@ -515,10 +515,10 @@ static int snd_ice1712_playback_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_ice1712_playback_ds_trigger(snd_pcm_substream_t * substream, +static int snd_ice1712_playback_ds_trigger(struct snd_pcm_substream *substream, int cmd) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); int result = 0; u32 tmp; @@ -540,10 +540,10 @@ static int snd_ice1712_playback_ds_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_ice1712_capture_trigger(snd_pcm_substream_t * substream, +static int snd_ice1712_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); int result = 0; u8 tmp; @@ -561,10 +561,10 @@ static int snd_ice1712_capture_trigger(snd_pcm_substream_t * substream, return result; } -static int snd_ice1712_playback_prepare(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; u32 period_size, buf_size, rate, tmp; period_size = (snd_pcm_lib_period_bytes(substream) >> 2) - 1; @@ -594,10 +594,10 @@ static int snd_ice1712_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_playback_ds_prepare(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_ds_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; u32 period_size, buf_size, rate, tmp, chn; period_size = snd_pcm_lib_period_bytes(substream) - 1; @@ -629,10 +629,10 @@ static int snd_ice1712_playback_ds_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_capture_prepare(snd_pcm_substream_t * substream) +static int snd_ice1712_capture_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; u32 period_size, buf_size; u8 tmp; @@ -654,10 +654,10 @@ static int snd_ice1712_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_ice1712_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ice1712_playback_pointer(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; size_t ptr; if (!(snd_ice1712_read(ice, ICE1712_IREG_PBK_CTRL) & 1)) @@ -668,9 +668,9 @@ static snd_pcm_uframes_t snd_ice1712_playback_pointer(snd_pcm_substream_t * subs return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); u8 addr; size_t ptr; @@ -687,9 +687,9 @@ static snd_pcm_uframes_t snd_ice1712_playback_ds_pointer(snd_pcm_substream_t * s return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_ice1712_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ice1712_capture_pointer(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); size_t ptr; if (!(snd_ice1712_read(ice, ICE1712_IREG_CAP_CTRL) & 1)) @@ -700,7 +700,7 @@ static snd_pcm_uframes_t snd_ice1712_capture_pointer(snd_pcm_substream_t * subst return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_hardware_t snd_ice1712_playback = +static struct snd_pcm_hardware snd_ice1712_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -720,7 +720,7 @@ static snd_pcm_hardware_t snd_ice1712_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ice1712_playback_ds = +static struct snd_pcm_hardware snd_ice1712_playback_ds = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -740,7 +740,7 @@ static snd_pcm_hardware_t snd_ice1712_playback_ds = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ice1712_capture = +static struct snd_pcm_hardware snd_ice1712_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -759,20 +759,20 @@ static snd_pcm_hardware_t snd_ice1712_capture = .fifo_size = 0, }; -static int snd_ice1712_playback_open(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); ice->playback_con_substream = substream; runtime->hw = snd_ice1712_playback; return 0; } -static int snd_ice1712_playback_ds_open(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_ds_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); u32 tmp; ice->playback_con_substream_ds[substream->number] = substream; @@ -784,10 +784,10 @@ static int snd_ice1712_playback_ds_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_capture_open(snd_pcm_substream_t * substream) +static int snd_ice1712_capture_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); ice->capture_con_substream = substream; runtime->hw = snd_ice1712_capture; @@ -797,17 +797,17 @@ static int snd_ice1712_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_playback_close(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); ice->playback_con_substream = NULL; return 0; } -static int snd_ice1712_playback_ds_close(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_ds_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); u32 tmp; spin_lock_irq(&ice->reg_lock); @@ -818,15 +818,15 @@ static int snd_ice1712_playback_ds_close(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_capture_close(snd_pcm_substream_t * substream) +static int snd_ice1712_capture_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); ice->capture_con_substream = NULL; return 0; } -static snd_pcm_ops_t snd_ice1712_playback_ops = { +static struct snd_pcm_ops snd_ice1712_playback_ops = { .open = snd_ice1712_playback_open, .close = snd_ice1712_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -837,7 +837,7 @@ static snd_pcm_ops_t snd_ice1712_playback_ops = { .pointer = snd_ice1712_playback_pointer, }; -static snd_pcm_ops_t snd_ice1712_playback_ds_ops = { +static struct snd_pcm_ops snd_ice1712_playback_ds_ops = { .open = snd_ice1712_playback_ds_open, .close = snd_ice1712_playback_ds_close, .ioctl = snd_pcm_lib_ioctl, @@ -848,7 +848,7 @@ static snd_pcm_ops_t snd_ice1712_playback_ds_ops = { .pointer = snd_ice1712_playback_ds_pointer, }; -static snd_pcm_ops_t snd_ice1712_capture_ops = { +static struct snd_pcm_ops snd_ice1712_capture_ops = { .open = snd_ice1712_capture_open, .close = snd_ice1712_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -859,9 +859,9 @@ static snd_pcm_ops_t snd_ice1712_capture_ops = { .pointer = snd_ice1712_capture_pointer, }; -static int __devinit snd_ice1712_pcm(ice1712_t * ice, int device, snd_pcm_t ** rpcm) +static int __devinit snd_ice1712_pcm(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -889,9 +889,9 @@ static int __devinit snd_ice1712_pcm(ice1712_t * ice, int device, snd_pcm_t ** r return 0; } -static int __devinit snd_ice1712_pcm_ds(ice1712_t * ice, int device, snd_pcm_t ** rpcm) +static int __devinit snd_ice1712_pcm_ds(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -923,16 +923,16 @@ static int __devinit snd_ice1712_pcm_ds(ice1712_t * ice, int device, snd_pcm_t * static unsigned int rates[] = { 8000, 9600, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, }; -static int snd_ice1712_pro_trigger(snd_pcm_substream_t *substream, +static int snd_ice1712_pro_trigger(struct snd_pcm_substream *substream, int cmd) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: @@ -959,7 +959,7 @@ static int snd_ice1712_pro_trigger(snd_pcm_substream_t *substream, unsigned int what = 0; unsigned int old; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); @@ -989,7 +989,7 @@ static int snd_ice1712_pro_trigger(snd_pcm_substream_t *substream, /* */ -static void snd_ice1712_set_pro_rate(ice1712_t *ice, unsigned int rate, int force) +static void snd_ice1712_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, int force) { unsigned long flags; unsigned char val, old; @@ -1043,9 +1043,9 @@ static void snd_ice1712_set_pro_rate(ice1712_t *ice, unsigned int rate, int forc ice->spdif.ops.setup_rate(ice, rate); } -static int snd_ice1712_playback_pro_prepare(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_pro_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); ice->playback_pro_size = snd_pcm_lib_buffer_bytes(substream); spin_lock_irq(&ice->reg_lock); @@ -1057,18 +1057,18 @@ static int snd_ice1712_playback_pro_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_playback_pro_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ice1712_playback_pro_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0); return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_ice1712_capture_pro_prepare(snd_pcm_substream_t * substream) +static int snd_ice1712_capture_pro_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); ice->capture_pro_size = snd_pcm_lib_buffer_bytes(substream); spin_lock_irq(&ice->reg_lock); @@ -1079,18 +1079,18 @@ static int snd_ice1712_capture_pro_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_capture_pro_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ice1712_capture_pro_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); snd_ice1712_set_pro_rate(ice, params_rate(hw_params), 0); return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); size_t ptr; if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_PLAYBACK_START)) @@ -1101,9 +1101,9 @@ static snd_pcm_uframes_t snd_ice1712_playback_pro_pointer(snd_pcm_substream_t * return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); size_t ptr; if (!(inl(ICEMT(ice, PLAYBACK_CONTROL)) & ICE1712_CAPTURE_START_SHADOW)) @@ -1114,7 +1114,7 @@ static snd_pcm_uframes_t snd_ice1712_capture_pro_pointer(snd_pcm_substream_t * s return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_hardware_t snd_ice1712_playback_pro = +static struct snd_pcm_hardware snd_ice1712_playback_pro = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1134,7 +1134,7 @@ static snd_pcm_hardware_t snd_ice1712_playback_pro = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ice1712_capture_pro = +static struct snd_pcm_hardware snd_ice1712_capture_pro = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1154,10 +1154,10 @@ static snd_pcm_hardware_t snd_ice1712_capture_pro = .fifo_size = 0, }; -static int snd_ice1712_playback_pro_open(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_pro_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); ice->playback_pro_substream = substream; runtime->hw = snd_ice1712_playback_pro; @@ -1171,10 +1171,10 @@ static int snd_ice1712_playback_pro_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_capture_pro_open(snd_pcm_substream_t * substream) +static int snd_ice1712_capture_pro_open(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; ice->capture_pro_substream = substream; runtime->hw = snd_ice1712_capture_pro; @@ -1184,9 +1184,9 @@ static int snd_ice1712_capture_pro_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_playback_pro_close(snd_pcm_substream_t * substream) +static int snd_ice1712_playback_pro_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); if (PRO_RATE_RESET) snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); @@ -1197,9 +1197,9 @@ static int snd_ice1712_playback_pro_close(snd_pcm_substream_t * substream) return 0; } -static int snd_ice1712_capture_pro_close(snd_pcm_substream_t * substream) +static int snd_ice1712_capture_pro_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); if (PRO_RATE_RESET) snd_ice1712_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); @@ -1207,7 +1207,7 @@ static int snd_ice1712_capture_pro_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_ice1712_playback_pro_ops = { +static struct snd_pcm_ops snd_ice1712_playback_pro_ops = { .open = snd_ice1712_playback_pro_open, .close = snd_ice1712_playback_pro_close, .ioctl = snd_pcm_lib_ioctl, @@ -1218,7 +1218,7 @@ static snd_pcm_ops_t snd_ice1712_playback_pro_ops = { .pointer = snd_ice1712_playback_pro_pointer, }; -static snd_pcm_ops_t snd_ice1712_capture_pro_ops = { +static struct snd_pcm_ops snd_ice1712_capture_pro_ops = { .open = snd_ice1712_capture_pro_open, .close = snd_ice1712_capture_pro_close, .ioctl = snd_pcm_lib_ioctl, @@ -1229,9 +1229,9 @@ static snd_pcm_ops_t snd_ice1712_capture_pro_ops = { .pointer = snd_ice1712_capture_pro_pointer, }; -static int __devinit snd_ice1712_pcm_profi(ice1712_t * ice, int device, snd_pcm_t ** rpcm) +static int __devinit snd_ice1712_pcm_profi(struct snd_ice1712 * ice, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1272,7 +1272,7 @@ static int __devinit snd_ice1712_pcm_profi(ice1712_t * ice, int device, snd_pcm_ * Mixer section */ -static void snd_ice1712_update_volume(ice1712_t *ice, int index) +static void snd_ice1712_update_volume(struct snd_ice1712 *ice, int index) { unsigned int vol = ice->pro_volumes[index]; unsigned short val = 0; @@ -1283,7 +1283,7 @@ static void snd_ice1712_update_volume(ice1712_t *ice, int index) outw(val, ICEMT(ice, MONITOR_VOLUME)); } -static int snd_ice1712_pro_mixer_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_mixer_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -1292,9 +1292,9 @@ static int snd_ice1712_pro_mixer_switch_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_ice1712_pro_mixer_switch_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_mixer_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; spin_lock_irq(&ice->reg_lock); @@ -1304,9 +1304,9 @@ static int snd_ice1712_pro_mixer_switch_get(snd_kcontrol_t * kcontrol, snd_ctl_e return 0; } -static int snd_ice1712_pro_mixer_switch_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_mixer_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; unsigned int nval, change; @@ -1321,7 +1321,7 @@ static int snd_ice1712_pro_mixer_switch_put(snd_kcontrol_t * kcontrol, snd_ctl_e return change; } -static int snd_ice1712_pro_mixer_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_mixer_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1330,9 +1330,9 @@ static int snd_ice1712_pro_mixer_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_ice1712_pro_mixer_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_mixer_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; spin_lock_irq(&ice->reg_lock); @@ -1342,9 +1342,9 @@ static int snd_ice1712_pro_mixer_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_e return 0; } -static int snd_ice1712_pro_mixer_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_mixer_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int index = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id) + kcontrol->private_value; unsigned int nval, change; @@ -1360,7 +1360,7 @@ static int snd_ice1712_pro_mixer_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_e } -static snd_kcontrol_new_t snd_ice1712_multi_playback_ctrls[] __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_multi_playback_ctrls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Playback Switch", @@ -1381,7 +1381,7 @@ static snd_kcontrol_new_t snd_ice1712_multi_playback_ctrls[] __devinitdata = { }, }; -static snd_kcontrol_new_t snd_ice1712_multi_capture_analog_switch __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_switch __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "H/W Multi Capture Switch", .info = snd_ice1712_pro_mixer_switch_info, @@ -1390,7 +1390,7 @@ static snd_kcontrol_new_t snd_ice1712_multi_capture_analog_switch __devinitdata .private_value = 10, }; -static snd_kcontrol_new_t snd_ice1712_multi_capture_spdif_switch __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_switch __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,SWITCH), .info = snd_ice1712_pro_mixer_switch_info, @@ -1400,7 +1400,7 @@ static snd_kcontrol_new_t snd_ice1712_multi_capture_spdif_switch __devinitdata = .count = 2, }; -static snd_kcontrol_new_t snd_ice1712_multi_capture_analog_volume __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_multi_capture_analog_volume __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "H/W Multi Capture Volume", .info = snd_ice1712_pro_mixer_volume_info, @@ -1409,7 +1409,7 @@ static snd_kcontrol_new_t snd_ice1712_multi_capture_analog_volume __devinitdata .private_value = 10, }; -static snd_kcontrol_new_t snd_ice1712_multi_capture_spdif_volume __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_multi_capture_spdif_volume __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("Multi ",CAPTURE,VOLUME), .info = snd_ice1712_pro_mixer_volume_info, @@ -1419,9 +1419,9 @@ static snd_kcontrol_new_t snd_ice1712_multi_capture_spdif_volume __devinitdata = .count = 2, }; -static int __devinit snd_ice1712_build_pro_mixer(ice1712_t *ice) +static int __devinit snd_ice1712_build_pro_mixer(struct snd_ice1712 *ice) { - snd_card_t * card = ice->card; + struct snd_card *card = ice->card; unsigned int idx; int err; @@ -1433,7 +1433,7 @@ static int __devinit snd_ice1712_build_pro_mixer(ice1712_t *ice) } if (ice->num_total_adcs > 0) { - snd_kcontrol_new_t tmp = snd_ice1712_multi_capture_analog_switch; + struct snd_kcontrol_new tmp = snd_ice1712_multi_capture_analog_switch; tmp.count = ice->num_total_adcs; err = snd_ctl_add(card, snd_ctl_new1(&tmp, ice)); if (err < 0) @@ -1445,7 +1445,7 @@ static int __devinit snd_ice1712_build_pro_mixer(ice1712_t *ice) return err; if (ice->num_total_adcs > 0) { - snd_kcontrol_new_t tmp = snd_ice1712_multi_capture_analog_volume; + struct snd_kcontrol_new tmp = snd_ice1712_multi_capture_analog_volume; tmp.count = ice->num_total_adcs; err = snd_ctl_add(card, snd_ctl_new1(&tmp, ice)); if (err < 0) @@ -1472,22 +1472,22 @@ static int __devinit snd_ice1712_build_pro_mixer(ice1712_t *ice) return 0; } -static void snd_ice1712_mixer_free_ac97(ac97_t *ac97) +static void snd_ice1712_mixer_free_ac97(struct snd_ac97 *ac97) { - ice1712_t *ice = ac97->private_data; + struct snd_ice1712 *ice = ac97->private_data; ice->ac97 = NULL; } -static int __devinit snd_ice1712_ac97_mixer(ice1712_t * ice) +static int __devinit snd_ice1712_ac97_mixer(struct snd_ice1712 * ice) { int err, bus_num = 0; - ac97_template_t ac97; - ac97_bus_t *pbus; - static ac97_bus_ops_t con_ops = { + struct snd_ac97_template ac97; + struct snd_ac97_bus *pbus; + static struct snd_ac97_bus_ops con_ops = { .write = snd_ice1712_ac97_write, .read = snd_ice1712_ac97_read, }; - static ac97_bus_ops_t pro_ops = { + static struct snd_ac97_bus_ops pro_ops = { .write = snd_ice1712_pro_ac97_write, .read = snd_ice1712_pro_ac97_read, }; @@ -1527,15 +1527,15 @@ static int __devinit snd_ice1712_ac97_mixer(ice1712_t * ice) * */ -static inline unsigned int eeprom_double(ice1712_t *ice, int idx) +static inline unsigned int eeprom_double(struct snd_ice1712 *ice, int idx) { return (unsigned int)ice->eeprom.data[idx] | ((unsigned int)ice->eeprom.data[idx + 1] << 8); } -static void snd_ice1712_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ice1712_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ice1712_t *ice = entry->private_data; + struct snd_ice1712 *ice = entry->private_data; unsigned int idx; snd_iprintf(buffer, "%s\n\n", ice->card->longname); @@ -1569,9 +1569,9 @@ static void snd_ice1712_proc_read(snd_info_entry_t *entry, snd_iprintf(buffer, " RATE : 0x%02x\n", (unsigned)inb(ICEMT(ice, RATE))); } -static void __devinit snd_ice1712_proc_init(ice1712_t * ice) +static void __devinit snd_ice1712_proc_init(struct snd_ice1712 * ice) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(ice->card, "ice1712", &entry)) snd_info_set_text_ops(entry, ice, 1024, snd_ice1712_proc_read); @@ -1581,22 +1581,24 @@ static void __devinit snd_ice1712_proc_init(ice1712_t * ice) * */ -static int snd_ice1712_eeprom_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_eeprom_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; - uinfo->count = sizeof(ice1712_eeprom_t); + uinfo->count = sizeof(struct snd_ice1712_eeprom); return 0; } -static int snd_ice1712_eeprom_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_eeprom_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom)); return 0; } -static snd_kcontrol_new_t snd_ice1712_eeprom __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_eeprom __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = "ICE1712 EEPROM", .access = SNDRV_CTL_ELEM_ACCESS_READ, @@ -1606,32 +1608,33 @@ static snd_kcontrol_new_t snd_ice1712_eeprom __devinitdata = { /* */ -static int snd_ice1712_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ice1712_spdif_default_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); if (ice->spdif.ops.default_get) ice->spdif.ops.default_get(ice, ucontrol); return 0; } -static int snd_ice1712_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); if (ice->spdif.ops.default_put) return ice->spdif.ops.default_put(ice, ucontrol); return 0; } -static snd_kcontrol_new_t snd_ice1712_spdif_default __devinitdata = +static struct snd_kcontrol_new snd_ice1712_spdif_default __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -1640,10 +1643,10 @@ static snd_kcontrol_new_t snd_ice1712_spdif_default __devinitdata = .put = snd_ice1712_spdif_default_put }; -static int snd_ice1712_spdif_maskc_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_spdif_maskc_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); if (ice->spdif.ops.default_get) { ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO | IEC958_AES0_PROFESSIONAL | @@ -1662,10 +1665,10 @@ static int snd_ice1712_spdif_maskc_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ice1712_spdif_maskp_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_spdif_maskp_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); if (ice->spdif.ops.default_get) { ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO | IEC958_AES0_PROFESSIONAL | @@ -1682,7 +1685,7 @@ static int snd_ice1712_spdif_maskp_get(snd_kcontrol_t * kcontrol, return 0; } -static snd_kcontrol_new_t snd_ice1712_spdif_maskc __devinitdata = +static struct snd_kcontrol_new snd_ice1712_spdif_maskc __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1691,7 +1694,7 @@ static snd_kcontrol_new_t snd_ice1712_spdif_maskc __devinitdata = .get = snd_ice1712_spdif_maskc_get, }; -static snd_kcontrol_new_t snd_ice1712_spdif_maskp __devinitdata = +static struct snd_kcontrol_new snd_ice1712_spdif_maskp __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1700,27 +1703,28 @@ static snd_kcontrol_new_t snd_ice1712_spdif_maskp __devinitdata = .get = snd_ice1712_spdif_maskp_get, }; -static int snd_ice1712_spdif_stream_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); if (ice->spdif.ops.stream_get) ice->spdif.ops.stream_get(ice, ucontrol); return 0; } -static int snd_ice1712_spdif_stream_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); if (ice->spdif.ops.stream_put) return ice->spdif.ops.stream_put(ice, ucontrol); return 0; } -static snd_kcontrol_new_t snd_ice1712_spdif_stream __devinitdata = +static struct snd_kcontrol_new snd_ice1712_spdif_stream __devinitdata = { - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, + .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | + SNDRV_CTL_ELEM_ACCESS_INACTIVE), .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM), .info = snd_ice1712_spdif_info, @@ -1728,7 +1732,8 @@ static snd_kcontrol_new_t snd_ice1712_spdif_stream __devinitdata = .put = snd_ice1712_spdif_stream_put }; -int snd_ice1712_gpio_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +int snd_ice1712_gpio_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1737,21 +1742,24 @@ int snd_ice1712_gpio_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) return 0; } -int snd_ice1712_gpio_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_ice1712_gpio_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char mask = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0; snd_ice1712_save_gpio_status(ice); - ucontrol->value.integer.value[0] = (snd_ice1712_gpio_read(ice) & mask ? 1 : 0) ^ invert; + ucontrol->value.integer.value[0] = + (snd_ice1712_gpio_read(ice) & mask ? 1 : 0) ^ invert; snd_ice1712_restore_gpio_status(ice); return 0; } -int snd_ice1712_gpio_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char mask = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value & (1<<24)) ? mask : 0; unsigned int val, nval; @@ -1771,7 +1779,8 @@ int snd_ice1712_gpio_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucont /* * rate */ -static int snd_ice1712_pro_internal_clock_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_internal_clock_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "8000", /* 0: 6 */ @@ -1798,9 +1807,10 @@ static int snd_ice1712_pro_internal_clock_info(snd_kcontrol_t *kcontrol, snd_ctl return 0; } -static int snd_ice1712_pro_internal_clock_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_internal_clock_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); static unsigned char xlate[16] = { 9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 255, 255, 255, 10 }; @@ -1821,9 +1831,10 @@ static int snd_ice1712_pro_internal_clock_get(snd_kcontrol_t * kcontrol, snd_ctl return 0; } -static int snd_ice1712_pro_internal_clock_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_internal_clock_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); static unsigned int xrate[13] = { 8000, 9600, 11025, 12000, 1600, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 @@ -1844,7 +1855,8 @@ static int snd_ice1712_pro_internal_clock_put(snd_kcontrol_t * kcontrol, snd_ctl change = inb(ICEMT(ice, RATE)) != oval; spin_unlock_irq(&ice->reg_lock); - if ((oval & ICE1712_SPDIF_MASTER) != (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER)) { + if ((oval & ICE1712_SPDIF_MASTER) != + (inb(ICEMT(ice, RATE)) & ICE1712_SPDIF_MASTER)) { /* change CS8427 clock source too */ if (ice->cs8427) { snd_ice1712_cs8427_set_input_clock(ice, is_spdif_master(ice)); @@ -1862,7 +1874,7 @@ static int snd_ice1712_pro_internal_clock_put(snd_kcontrol_t * kcontrol, snd_ctl return change; } -static snd_kcontrol_new_t snd_ice1712_pro_internal_clock __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_pro_internal_clock __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Internal Clock", .info = snd_ice1712_pro_internal_clock_info, @@ -1870,7 +1882,8 @@ static snd_kcontrol_new_t snd_ice1712_pro_internal_clock __devinitdata = { .put = snd_ice1712_pro_internal_clock_put }; -static int snd_ice1712_pro_internal_clock_default_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_internal_clock_default_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "8000", /* 0: 6 */ @@ -1897,7 +1910,8 @@ static int snd_ice1712_pro_internal_clock_default_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_ice1712_pro_internal_clock_default_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_internal_clock_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int val; static unsigned int xrate[13] = { @@ -1914,7 +1928,8 @@ static int snd_ice1712_pro_internal_clock_default_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ice1712_pro_internal_clock_default_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_internal_clock_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { static unsigned int xrate[13] = { 8000, 9600, 11025, 12000, 1600, 22050, 24000, @@ -1930,7 +1945,7 @@ static int snd_ice1712_pro_internal_clock_default_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_ice1712_pro_internal_clock_default __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_pro_internal_clock_default __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Internal Clock Default", .info = snd_ice1712_pro_internal_clock_default_info, @@ -1938,7 +1953,8 @@ static snd_kcontrol_new_t snd_ice1712_pro_internal_clock_default __devinitdata = .put = snd_ice1712_pro_internal_clock_default_put }; -static int snd_ice1712_pro_rate_locking_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_rate_locking_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1947,15 +1963,17 @@ static int snd_ice1712_pro_rate_locking_info(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_ice1712_pro_rate_locking_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_rate_locking_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = PRO_RATE_LOCKED; return 0; } -static int snd_ice1712_pro_rate_locking_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_rate_locking_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change = 0, nval; nval = ucontrol->value.integer.value[0] ? 1 : 0; @@ -1966,7 +1984,7 @@ static int snd_ice1712_pro_rate_locking_put(snd_kcontrol_t * kcontrol, snd_ctl_e return change; } -static snd_kcontrol_new_t snd_ice1712_pro_rate_locking __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_pro_rate_locking __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Rate Locking", .info = snd_ice1712_pro_rate_locking_info, @@ -1974,7 +1992,8 @@ static snd_kcontrol_new_t snd_ice1712_pro_rate_locking __devinitdata = { .put = snd_ice1712_pro_rate_locking_put }; -static int snd_ice1712_pro_rate_reset_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_rate_reset_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1983,15 +2002,17 @@ static int snd_ice1712_pro_rate_reset_info(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_ice1712_pro_rate_reset_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_rate_reset_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = PRO_RATE_RESET; return 0; } -static int snd_ice1712_pro_rate_reset_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_rate_reset_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change = 0, nval; nval = ucontrol->value.integer.value[0] ? 1 : 0; @@ -2002,7 +2023,7 @@ static int snd_ice1712_pro_rate_reset_put(snd_kcontrol_t * kcontrol, snd_ctl_ele return change; } -static snd_kcontrol_new_t snd_ice1712_pro_rate_reset __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_pro_rate_reset __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Rate Reset", .info = snd_ice1712_pro_rate_reset_info, @@ -2013,7 +2034,8 @@ static snd_kcontrol_new_t snd_ice1712_pro_rate_reset __devinitdata = { /* * routing */ -static int snd_ice1712_pro_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_route_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "PCM Out", /* 0 */ @@ -2025,16 +2047,18 @@ static int snd_ice1712_pro_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; - uinfo->value.enumerated.items = snd_ctl_get_ioffidx(kcontrol, &uinfo->id) < 2 ? 12 : 11; + uinfo->value.enumerated.items = + snd_ctl_get_ioffidx(kcontrol, &uinfo->id) < 2 ? 12 : 11; if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); return 0; } -static int snd_ice1712_pro_route_analog_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_pro_route_analog_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned int val, cval; @@ -2057,9 +2081,10 @@ static int snd_ice1712_pro_route_analog_get(snd_kcontrol_t * kcontrol, snd_ctl_e return 0; } -static int snd_ice1712_pro_route_analog_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_pro_route_analog_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change, shift; int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned int val, old_val, nval; @@ -2106,9 +2131,10 @@ static int snd_ice1712_pro_route_analog_put(snd_kcontrol_t * kcontrol, snd_ctl_e return change; } -static int snd_ice1712_pro_route_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_pro_route_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned int val, cval; val = inw(ICEMT(ice, ROUTE_SPDOUT)); @@ -2125,9 +2151,10 @@ static int snd_ice1712_pro_route_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_el return 0; } -static int snd_ice1712_pro_route_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_ice1712_pro_route_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change, shift; int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); unsigned int val, old_val, nval; @@ -2163,7 +2190,7 @@ static int snd_ice1712_pro_route_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_el return change; } -static snd_kcontrol_new_t snd_ice1712_mixer_pro_analog_route __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_mixer_pro_analog_route __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "H/W Playback Route", .info = snd_ice1712_pro_route_info, @@ -2171,7 +2198,7 @@ static snd_kcontrol_new_t snd_ice1712_mixer_pro_analog_route __devinitdata = { .put = snd_ice1712_pro_route_analog_put, }; -static snd_kcontrol_new_t snd_ice1712_mixer_pro_spdif_route __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_mixer_pro_spdif_route __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", .info = snd_ice1712_pro_route_info, @@ -2181,7 +2208,8 @@ static snd_kcontrol_new_t snd_ice1712_mixer_pro_spdif_route __devinitdata = { }; -static int snd_ice1712_pro_volume_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_volume_rate_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -2190,17 +2218,19 @@ static int snd_ice1712_pro_volume_rate_info(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_ice1712_pro_volume_rate_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_volume_rate_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = inb(ICEMT(ice, MONITOR_RATE)); return 0; } -static int snd_ice1712_pro_volume_rate_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_volume_rate_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change; spin_lock_irq(&ice->reg_lock); @@ -2210,7 +2240,7 @@ static int snd_ice1712_pro_volume_rate_put(snd_kcontrol_t * kcontrol, snd_ctl_el return change; } -static snd_kcontrol_new_t snd_ice1712_mixer_pro_volume_rate __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_mixer_pro_volume_rate __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Volume Rate", .info = snd_ice1712_pro_volume_rate_info, @@ -2218,7 +2248,8 @@ static snd_kcontrol_new_t snd_ice1712_mixer_pro_volume_rate __devinitdata = { .put = snd_ice1712_pro_volume_rate_put }; -static int snd_ice1712_pro_peak_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ice1712_pro_peak_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 22; @@ -2227,9 +2258,10 @@ static int snd_ice1712_pro_peak_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_ice1712_pro_peak_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ice1712_pro_peak_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx; spin_lock_irq(&ice->reg_lock); @@ -2241,7 +2273,7 @@ static int snd_ice1712_pro_peak_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu return 0; } -static snd_kcontrol_new_t snd_ice1712_mixer_pro_peak __devinitdata = { +static struct snd_kcontrol_new snd_ice1712_mixer_pro_peak __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Peak", .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, @@ -2263,7 +2295,7 @@ static struct snd_ice1712_card_info *card_tables[] __devinitdata = { NULL, }; -static unsigned char __devinit snd_ice1712_read_i2c(ice1712_t *ice, +static unsigned char __devinit snd_ice1712_read_i2c(struct snd_ice1712 *ice, unsigned char dev, unsigned char addr) { @@ -2275,7 +2307,8 @@ static unsigned char __devinit snd_ice1712_read_i2c(ice1712_t *ice, return inb(ICEREG(ice, I2C_DATA)); } -static int __devinit snd_ice1712_read_eeprom(ice1712_t *ice, const char *modelname) +static int __devinit snd_ice1712_read_eeprom(struct snd_ice1712 *ice, + const char *modelname) { int dev = 0xa0; /* EEPROM device address */ unsigned int i, size; @@ -2288,7 +2321,8 @@ static int __devinit snd_ice1712_read_eeprom(ice1712_t *ice, const char *modelna (snd_ice1712_read_i2c(ice, dev, 0x01) << 8) | (snd_ice1712_read_i2c(ice, dev, 0x02) << 16) | (snd_ice1712_read_i2c(ice, dev, 0x03) << 24); - if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) { + if (ice->eeprom.subvendor == 0 || + ice->eeprom.subvendor == (unsigned int)-1) { /* invalid subvendor from EEPROM, try the PCI subststem ID instead */ u16 vendor, device; pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID, &vendor); @@ -2317,7 +2351,8 @@ static int __devinit snd_ice1712_read_eeprom(ice1712_t *ice, const char *modelna goto read_skipped; } } - printk(KERN_WARNING "ice1712: No matching model found for ID 0x%x\n", ice->eeprom.subvendor); + printk(KERN_WARNING "ice1712: No matching model found for ID 0x%x\n", + ice->eeprom.subvendor); found: ice->eeprom.size = snd_ice1712_read_i2c(ice, dev, 0x04); @@ -2329,7 +2364,8 @@ static int __devinit snd_ice1712_read_eeprom(ice1712_t *ice, const char *modelna } ice->eeprom.version = snd_ice1712_read_i2c(ice, dev, 0x05); if (ice->eeprom.version != 1) { - snd_printk(KERN_ERR "invalid EEPROM version %i\n", ice->eeprom.version); + snd_printk(KERN_ERR "invalid EEPROM version %i\n", + ice->eeprom.version); /* return -EIO; */ } size = ice->eeprom.size - 6; @@ -2346,7 +2382,7 @@ static int __devinit snd_ice1712_read_eeprom(ice1712_t *ice, const char *modelna -static int __devinit snd_ice1712_chip_init(ice1712_t *ice) +static int __devinit snd_ice1712_chip_init(struct snd_ice1712 *ice) { outb(ICE1712_RESET | ICE1712_NATIVE, ICEREG(ice, CONTROL)); udelay(200); @@ -2359,15 +2395,19 @@ static int __devinit snd_ice1712_chip_init(ice1712_t *ice) if (ice->eeprom.subvendor != ICE1712_SUBDEVICE_STDSP24) { ice->gpio.write_mask = ice->eeprom.gpiomask; ice->gpio.direction = ice->eeprom.gpiodir; - snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, ice->eeprom.gpiomask); - snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, ice->eeprom.gpiodir); - snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, ice->eeprom.gpiostate); + snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, + ice->eeprom.gpiomask); + snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, + ice->eeprom.gpiodir); + snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, + ice->eeprom.gpiostate); } else { ice->gpio.write_mask = 0xc0; ice->gpio.direction = 0xff; snd_ice1712_write(ice, ICE1712_IREG_GPIO_WRITE_MASK, 0xc0); snd_ice1712_write(ice, ICE1712_IREG_GPIO_DIRECTION, 0xff); - snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, ICE1712_STDSP24_CLOCK_BIT); + snd_ice1712_write(ice, ICE1712_IREG_GPIO_DATA, + ICE1712_STDSP24_CLOCK_BIT); } snd_ice1712_write(ice, ICE1712_IREG_PRO_POWERDOWN, 0); if (!(ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97)) { @@ -2382,10 +2422,10 @@ static int __devinit snd_ice1712_chip_init(ice1712_t *ice) return 0; } -int __devinit snd_ice1712_spdif_build_controls(ice1712_t *ice) +int __devinit snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice) { int err; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; snd_assert(ice->pcm_pro != NULL, return -EIO); err = snd_ctl_add(ice->card, kctl = snd_ctl_new1(&snd_ice1712_spdif_default, ice)); @@ -2409,7 +2449,7 @@ int __devinit snd_ice1712_spdif_build_controls(ice1712_t *ice) } -static int __devinit snd_ice1712_build_controls(ice1712_t *ice) +static int __devinit snd_ice1712_build_controls(struct snd_ice1712 *ice) { int err; @@ -2431,7 +2471,7 @@ static int __devinit snd_ice1712_build_controls(ice1712_t *ice) return err; if (ice->num_total_dacs > 0) { - snd_kcontrol_new_t tmp = snd_ice1712_mixer_pro_analog_route; + struct snd_kcontrol_new tmp = snd_ice1712_mixer_pro_analog_route; tmp.count = ice->num_total_dacs; err = snd_ctl_add(ice->card, snd_ctl_new1(&tmp, ice)); if (err < 0) @@ -2452,7 +2492,7 @@ static int __devinit snd_ice1712_build_controls(ice1712_t *ice) return 0; } -static int snd_ice1712_free(ice1712_t *ice) +static int snd_ice1712_free(struct snd_ice1712 *ice) { if (! ice->port) goto __hw_end; @@ -2463,7 +2503,7 @@ static int snd_ice1712_free(ice1712_t *ice) __hw_end: if (ice->irq >= 0) { synchronize_irq(ice->irq); - free_irq(ice->irq, (void *) ice); + free_irq(ice->irq, ice); } if (ice->port) pci_release_regions(ice->pci); @@ -2473,22 +2513,22 @@ static int snd_ice1712_free(ice1712_t *ice) return 0; } -static int snd_ice1712_dev_free(snd_device_t *device) +static int snd_ice1712_dev_free(struct snd_device *device) { - ice1712_t *ice = device->device_data; + struct snd_ice1712 *ice = device->device_data; return snd_ice1712_free(ice); } -static int __devinit snd_ice1712_create(snd_card_t * card, +static int __devinit snd_ice1712_create(struct snd_card *card, struct pci_dev *pci, const char *modelname, int omni, int cs8427_timeout, - ice1712_t ** r_ice1712) + struct snd_ice1712 ** r_ice1712) { - ice1712_t *ice; + struct snd_ice1712 *ice; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ice1712_dev_free, }; @@ -2548,7 +2588,8 @@ static int __devinit snd_ice1712_create(snd_card_t * card, ice->dmapath_port = pci_resource_start(pci, 2); ice->profi_port = pci_resource_start(pci, 3); - if (request_irq(pci->irq, snd_ice1712_interrupt, SA_INTERRUPT|SA_SHIRQ, "ICE1712", (void *) ice)) { + if (request_irq(pci->irq, snd_ice1712_interrupt, SA_INTERRUPT|SA_SHIRQ, + "ICE1712", ice)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_ice1712_free(ice); return -EIO; @@ -2566,8 +2607,10 @@ static int __devinit snd_ice1712_create(snd_card_t * card, } /* unmask used interrupts */ - outb((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) == 0 ? ICE1712_IRQ_MPU2 : 0 | - (ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97) ? ICE1712_IRQ_PBKDS | ICE1712_IRQ_CONCAP | ICE1712_IRQ_CONPBK : 0, + outb(((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_2xMPU401) == 0 ? + ICE1712_IRQ_MPU2 : 0) | + ((ice->eeprom.data[ICE_EEP1_CODEC] & ICE1712_CFG_NO_CON_AC97) ? + ICE1712_IRQ_PBKDS | ICE1712_IRQ_CONCAP | ICE1712_IRQ_CONPBK : 0), ICEREG(ice, IRQMASK)); outb(0x00, ICEMT(ice, IRQ)); @@ -2595,8 +2638,8 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - ice1712_t *ice; + struct snd_card *card; + struct snd_ice1712 *ice; int pcm_dev = 0, err; struct snd_ice1712_card_info **tbl, *c; @@ -2614,7 +2657,8 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, strcpy(card->driver, "ICE1712"); strcpy(card->shortname, "ICEnsemble ICE1712"); - if ((err = snd_ice1712_create(card, pci, model[dev], omni[dev], cs8427_timeout[dev], &ice)) < 0) { + if ((err = snd_ice1712_create(card, pci, model[dev], omni[dev], + cs8427_timeout[dev], &ice)) < 0) { snd_card_free(card); return err; } diff --git a/sound/pci/ice1712/ice1712.h b/sound/pci/ice1712/ice1712.h index 5ad4728..ce96b3b 100644 --- a/sound/pci/ice1712/ice1712.h +++ b/sound/pci/ice1712/ice1712.h @@ -215,9 +215,9 @@ * */ -typedef struct _snd_ice1712 ice1712_t; +struct snd_ice1712; -typedef struct { +struct snd_ice1712_eeprom { unsigned int subvendor; /* PCI[2c-2f] */ unsigned char size; /* size of EEPROM image in bytes */ unsigned char version; /* must be 1 (or 2 for vt1724) */ @@ -225,7 +225,7 @@ typedef struct { unsigned int gpiomask; unsigned int gpiostate; unsigned int gpiodir; -} ice1712_eeprom_t; +}; enum { ICE_EEP1_CODEC = 0, /* 06 */ @@ -266,28 +266,28 @@ struct snd_ak4xxx_private { unsigned int add_flags; /* additional bits at init */ unsigned int mask_flags; /* total mask bits */ struct snd_akm4xxx_ops { - void (*set_rate_val)(akm4xxx_t *ak, unsigned int rate); + void (*set_rate_val)(struct snd_akm4xxx *ak, unsigned int rate); } ops; }; struct snd_ice1712_spdif { unsigned char cs8403_bits; unsigned char cs8403_stream_bits; - snd_kcontrol_t *stream_ctl; + struct snd_kcontrol *stream_ctl; struct snd_ice1712_spdif_ops { - void (*open)(ice1712_t *, snd_pcm_substream_t *); - void (*setup_rate)(ice1712_t *, int rate); - void (*close)(ice1712_t *, snd_pcm_substream_t *); - void (*default_get)(ice1712_t *, snd_ctl_elem_value_t * ucontrol); - int (*default_put)(ice1712_t *, snd_ctl_elem_value_t * ucontrol); - void (*stream_get)(ice1712_t *, snd_ctl_elem_value_t * ucontrol); - int (*stream_put)(ice1712_t *, snd_ctl_elem_value_t * ucontrol); + void (*open)(struct snd_ice1712 *, struct snd_pcm_substream *); + void (*setup_rate)(struct snd_ice1712 *, int rate); + void (*close)(struct snd_ice1712 *, struct snd_pcm_substream *); + void (*default_get)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol); + int (*default_put)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol); + void (*stream_get)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol); + int (*stream_put)(struct snd_ice1712 *, struct snd_ctl_elem_value *ucontrol); } ops; }; -struct _snd_ice1712 { +struct snd_ice1712 { unsigned long conp_dma_size; unsigned long conc_dma_size; unsigned long prop_dma_size; @@ -300,28 +300,28 @@ struct _snd_ice1712 { unsigned long profi_port; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_t *pcm_ds; - snd_pcm_t *pcm_pro; - snd_pcm_substream_t *playback_con_substream; - snd_pcm_substream_t *playback_con_substream_ds[6]; - snd_pcm_substream_t *capture_con_substream; - snd_pcm_substream_t *playback_pro_substream; - snd_pcm_substream_t *capture_pro_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm *pcm_ds; + struct snd_pcm *pcm_pro; + struct snd_pcm_substream *playback_con_substream; + struct snd_pcm_substream *playback_con_substream_ds[6]; + struct snd_pcm_substream *capture_con_substream; + struct snd_pcm_substream *playback_pro_substream; + struct snd_pcm_substream *capture_pro_substream; unsigned int playback_pro_size; unsigned int capture_pro_size; unsigned int playback_con_virt_addr[6]; unsigned int playback_con_active_buf[6]; unsigned int capture_con_virt_addr; unsigned int ac97_ext_id; - ac97_t *ac97; - snd_rawmidi_t *rmidi[2]; + struct snd_ac97 *ac97; + struct snd_rawmidi *rmidi[2]; spinlock_t reg_lock; - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; - ice1712_eeprom_t eeprom; + struct snd_ice1712_eeprom eeprom; unsigned int pro_volumes[20]; unsigned int omni: 1; /* Delta Omni I/O */ @@ -335,16 +335,16 @@ struct _snd_ice1712 { unsigned int cur_rate; /* current rate */ struct semaphore open_mutex; - snd_pcm_substream_t *pcm_reserved[4]; - snd_pcm_hw_constraint_list_t *hw_rates; /* card-specific rate constraints */ + struct snd_pcm_substream *pcm_reserved[4]; + struct snd_pcm_hw_constraint_list *hw_rates; /* card-specific rate constraints */ unsigned int akm_codecs; - akm4xxx_t *akm; + struct snd_akm4xxx *akm; struct snd_ice1712_spdif spdif; struct semaphore i2c_mutex; /* I2C mutex for ICE1724 registers */ - snd_i2c_bus_t *i2c; /* I2C bus */ - snd_i2c_device_t *cs8427; /* CS8427 I2C device */ + struct snd_i2c_bus *i2c; /* I2C bus */ + struct snd_i2c_device *cs8427; /* CS8427 I2C device */ unsigned int cs8427_timeout; /* CS8427 reset timeout in HZ/100 */ struct ice1712_gpio { @@ -352,20 +352,20 @@ struct _snd_ice1712 { unsigned int write_mask; /* current mask bits */ unsigned int saved[2]; /* for ewx_i2c */ /* operators */ - void (*set_mask)(ice1712_t *ice, unsigned int data); - void (*set_dir)(ice1712_t *ice, unsigned int data); - void (*set_data)(ice1712_t *ice, unsigned int data); - unsigned int (*get_data)(ice1712_t *ice); + void (*set_mask)(struct snd_ice1712 *ice, unsigned int data); + void (*set_dir)(struct snd_ice1712 *ice, unsigned int data); + void (*set_data)(struct snd_ice1712 *ice, unsigned int data); + unsigned int (*get_data)(struct snd_ice1712 *ice); /* misc operators - move to another place? */ - void (*set_pro_rate)(ice1712_t *ice, unsigned int rate); - void (*i2s_mclk_changed)(ice1712_t *ice); + void (*set_pro_rate)(struct snd_ice1712 *ice, unsigned int rate); + void (*i2s_mclk_changed)(struct snd_ice1712 *ice); } gpio; struct semaphore gpio_mutex; /* other board-specific data */ union { /* additional i2c devices for EWS boards */ - snd_i2c_device_t *i2cdevs[3]; + struct snd_i2c_device *i2cdevs[3]; /* AC97 register cache for Aureon */ struct aureon_spec { unsigned short stac9744[64]; @@ -385,7 +385,7 @@ struct _snd_ice1712 { unsigned short boxconfig[4]; } hoontech; struct { - ak4114_t *ak4114; + struct ak4114 *ak4114; unsigned int analog: 1; } juli; } spec; @@ -396,22 +396,22 @@ struct _snd_ice1712 { /* * gpio access functions */ -static inline void snd_ice1712_gpio_set_dir(ice1712_t *ice, unsigned int bits) +static inline void snd_ice1712_gpio_set_dir(struct snd_ice1712 *ice, unsigned int bits) { ice->gpio.set_dir(ice, bits); } -static inline void snd_ice1712_gpio_set_mask(ice1712_t *ice, unsigned int bits) +static inline void snd_ice1712_gpio_set_mask(struct snd_ice1712 *ice, unsigned int bits) { ice->gpio.set_mask(ice, bits); } -static inline void snd_ice1712_gpio_write(ice1712_t *ice, unsigned int val) +static inline void snd_ice1712_gpio_write(struct snd_ice1712 *ice, unsigned int val) { ice->gpio.set_data(ice, val); } -static inline unsigned int snd_ice1712_gpio_read(ice1712_t *ice) +static inline unsigned int snd_ice1712_gpio_read(struct snd_ice1712 *ice) { return ice->gpio.get_data(ice); } @@ -421,14 +421,14 @@ static inline unsigned int snd_ice1712_gpio_read(ice1712_t *ice) * The access to gpio will be protected by mutex, so don't forget to * restore! */ -static inline void snd_ice1712_save_gpio_status(ice1712_t *ice) +static inline void snd_ice1712_save_gpio_status(struct snd_ice1712 *ice) { down(&ice->gpio_mutex); ice->gpio.saved[0] = ice->gpio.direction; ice->gpio.saved[1] = ice->gpio.write_mask; } -static inline void snd_ice1712_restore_gpio_status(ice1712_t *ice) +static inline void snd_ice1712_restore_gpio_status(struct snd_ice1712 *ice) { ice->gpio.set_dir(ice, ice->gpio.saved[0]); ice->gpio.set_mask(ice, ice->gpio.saved[1]); @@ -443,14 +443,15 @@ static inline void snd_ice1712_restore_gpio_status(ice1712_t *ice) .get = snd_ice1712_gpio_get, .put = snd_ice1712_gpio_put, \ .private_value = mask | (invert << 24) } -int snd_ice1712_gpio_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo); -int snd_ice1712_gpio_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); -int snd_ice1712_gpio_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol); +int snd_ice1712_gpio_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_ice1712_gpio_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); +int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol); /* * set gpio direction, write mask and data */ -static inline void snd_ice1712_gpio_write_bits(ice1712_t *ice, unsigned int mask, unsigned int bits) +static inline void snd_ice1712_gpio_write_bits(struct snd_ice1712 *ice, + unsigned int mask, unsigned int bits) { ice->gpio.direction |= mask; snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); @@ -458,21 +459,22 @@ static inline void snd_ice1712_gpio_write_bits(ice1712_t *ice, unsigned int mask snd_ice1712_gpio_write(ice, mask & bits); } -int snd_ice1712_spdif_build_controls(ice1712_t *ice); +int snd_ice1712_spdif_build_controls(struct snd_ice1712 *ice); -int snd_ice1712_akm4xxx_init(akm4xxx_t *ak, const akm4xxx_t *template, const struct snd_ak4xxx_private *priv, ice1712_t *ice); -void snd_ice1712_akm4xxx_free(ice1712_t *ice); -int snd_ice1712_akm4xxx_build_controls(ice1712_t *ice); +int snd_ice1712_akm4xxx_init(struct snd_akm4xxx *ak, const struct snd_akm4xxx *template, + const struct snd_ak4xxx_private *priv, struct snd_ice1712 *ice); +void snd_ice1712_akm4xxx_free(struct snd_ice1712 *ice); +int snd_ice1712_akm4xxx_build_controls(struct snd_ice1712 *ice); -int snd_ice1712_init_cs8427(ice1712_t *ice, int addr); +int snd_ice1712_init_cs8427(struct snd_ice1712 *ice, int addr); -static inline void snd_ice1712_write(ice1712_t * ice, u8 addr, u8 data) +static inline void snd_ice1712_write(struct snd_ice1712 * ice, u8 addr, u8 data) { outb(addr, ICEREG(ice, INDEX)); outb(data, ICEREG(ice, DATA)); } -static inline u8 snd_ice1712_read(ice1712_t * ice, u8 addr) +static inline u8 snd_ice1712_read(struct snd_ice1712 * ice, u8 addr) { outb(addr, ICEREG(ice, INDEX)); return inb(ICEREG(ice, DATA)); @@ -488,8 +490,8 @@ struct snd_ice1712_card_info { char *name; char *model; char *driver; - int (*chip_init)(ice1712_t *); - int (*build_controls)(ice1712_t *); + int (*chip_init)(struct snd_ice1712 *); + int (*build_controls)(struct snd_ice1712 *); unsigned int no_mpu401: 1; unsigned int eeprom_size; unsigned char *eeprom_data; -- cgit v1.1 From ab0c7d72c32d703d1a2833ce2a1920cd3b46b131 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:00:18 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI ICE1724 Modules: ICE1724 driver,ICE1712 driver Remove xxx_t typedefs from the PCI ICE1724 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ice1712/amp.c | 6 +- sound/pci/ice1712/aureon.c | 242 +++++++++--------- sound/pci/ice1712/envy24ht.h | 4 +- sound/pci/ice1712/ice1724.c | 532 +++++++++++++++++++++++----------------- sound/pci/ice1712/juli.c | 24 +- sound/pci/ice1712/phase.c | 110 ++++----- sound/pci/ice1712/pontis.c | 130 +++++----- sound/pci/ice1712/prodigy192.c | 82 +++---- sound/pci/ice1712/revo.c | 16 +- sound/pci/ice1712/vt1720_mobo.c | 4 +- 10 files changed, 617 insertions(+), 533 deletions(-) diff --git a/sound/pci/ice1712/amp.c b/sound/pci/ice1712/amp.c index 289b0b5..59c4078 100644 --- a/sound/pci/ice1712/amp.c +++ b/sound/pci/ice1712/amp.c @@ -33,14 +33,14 @@ #include "envy24ht.h" #include "amp.h" -static void wm_put(ice1712_t *ice, int reg, unsigned short val) +static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val) { unsigned short cval; cval = (reg << 9) | val; snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff); } -static int __devinit snd_vt1724_amp_init(ice1712_t *ice) +static int __devinit snd_vt1724_amp_init(struct snd_ice1712 *ice) { static unsigned short wm_inits[] = { WM_ATTEN_L, 0x0000, /* 0 db */ @@ -66,7 +66,7 @@ static int __devinit snd_vt1724_amp_init(ice1712_t *ice) return 0; } -static int __devinit snd_vt1724_amp_add_controls(ice1712_t *ice) +static int __devinit snd_vt1724_amp_add_controls(struct snd_ice1712 *ice) { /* we use pins 39 and 41 of the VT1616 for left and right read outputs */ snd_ac97_write_cache(ice->ac97, 0x5a, snd_ac97_read(ice->ac97, 0x5a) & ~0x8000); diff --git a/sound/pci/ice1712/aureon.c b/sound/pci/ice1712/aureon.c index db12b03..8809812 100644 --- a/sound/pci/ice1712/aureon.c +++ b/sound/pci/ice1712/aureon.c @@ -22,7 +22,7 @@ * * NOTES: * - * - we reuse the akm4xxx_t record for storing the wm8770 codec data. + * - we reuse the struct snd_akm4xxx record for storing the wm8770 codec data. * both wm and akm codecs are pretty similar, so we can integrate * both controls in the future, once if wm codecs are reused in * many boards. @@ -85,7 +85,7 @@ #define CS8415_C_BUFFER 0x20 #define CS8415_ID 0x7F -static void aureon_ac97_write(ice1712_t *ice, unsigned short reg, unsigned short val) { +static void aureon_ac97_write(struct snd_ice1712 *ice, unsigned short reg, unsigned short val) { unsigned int tmp; /* Send address to XILINX chip */ @@ -136,7 +136,7 @@ static void aureon_ac97_write(ice1712_t *ice, unsigned short reg, unsigned short ice->spec.aureon.stac9744[(reg & 0x7F) >> 1] = val; } -static unsigned short aureon_ac97_read(ice1712_t *ice, unsigned short reg) +static unsigned short aureon_ac97_read(struct snd_ice1712 *ice, unsigned short reg) { return ice->spec.aureon.stac9744[(reg & 0x7F) >> 1]; } @@ -144,7 +144,7 @@ static unsigned short aureon_ac97_read(ice1712_t *ice, unsigned short reg) /* * Initialize STAC9744 chip */ -static int aureon_ac97_init (ice1712_t *ice) { +static int aureon_ac97_init (struct snd_ice1712 *ice) { int i; static unsigned short ac97_defaults[] = { 0x00, 0x9640, @@ -196,7 +196,7 @@ static int aureon_ac97_init (ice1712_t *ice) { /* * AC'97 volume controls */ -static int aureon_ac97_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int aureon_ac97_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = kcontrol->private_value & AUREON_AC97_STEREO ? 2 : 1; @@ -205,9 +205,9 @@ static int aureon_ac97_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *u return 0; } -static int aureon_ac97_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_ac97_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short vol; down(&ice->gpio_mutex); @@ -221,9 +221,9 @@ static int aureon_ac97_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u return 0; } -static int aureon_ac97_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_ac97_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short ovol, nvol; int change; @@ -248,9 +248,9 @@ static int aureon_ac97_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u */ #define aureon_ac97_mute_info aureon_mono_bool_info -static int aureon_ac97_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_ac97_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); @@ -260,9 +260,9 @@ static int aureon_ac97_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int aureon_ac97_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int aureon_ac97_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short ovol, nvol; int change; @@ -284,9 +284,9 @@ static int aureon_ac97_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t */ #define aureon_ac97_micboost_info aureon_mono_bool_info -static int aureon_ac97_micboost_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_ac97_micboost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); @@ -296,9 +296,9 @@ static int aureon_ac97_micboost_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value return 0; } -static int aureon_ac97_micboost_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int aureon_ac97_micboost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short ovol, nvol; int change; @@ -318,7 +318,7 @@ static int aureon_ac97_micboost_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_valu /* * write data in the SPI mode */ -static void aureon_spi_write(ice1712_t *ice, unsigned int cs, unsigned int data, int bits) +static void aureon_spi_write(struct snd_ice1712 *ice, unsigned int cs, unsigned int data, int bits) { unsigned int tmp; int i; @@ -359,7 +359,7 @@ static void aureon_spi_write(ice1712_t *ice, unsigned int cs, unsigned int data, /* * Read data in SPI mode */ -static void aureon_spi_read(ice1712_t *ice, unsigned int cs, unsigned int data, int bits, unsigned char *buffer, int size) { +static void aureon_spi_read(struct snd_ice1712 *ice, unsigned int cs, unsigned int data, int bits, unsigned char *buffer, int size) { int i, j; unsigned int tmp; @@ -409,26 +409,26 @@ static void aureon_spi_read(ice1712_t *ice, unsigned int cs, unsigned int data, snd_ice1712_gpio_write(ice, tmp); } -static unsigned char aureon_cs8415_get(ice1712_t *ice, int reg) { +static unsigned char aureon_cs8415_get(struct snd_ice1712 *ice, int reg) { unsigned char val; aureon_spi_write(ice, AUREON_CS8415_CS, 0x2000 | reg, 16); aureon_spi_read(ice, AUREON_CS8415_CS, 0x21, 8, &val, 1); return val; } -static void aureon_cs8415_read(ice1712_t *ice, int reg, unsigned char *buffer, int size) { +static void aureon_cs8415_read(struct snd_ice1712 *ice, int reg, unsigned char *buffer, int size) { aureon_spi_write(ice, AUREON_CS8415_CS, 0x2000 | reg, 16); aureon_spi_read(ice, AUREON_CS8415_CS, 0x21, 8, buffer, size); } -static void aureon_cs8415_put(ice1712_t *ice, int reg, unsigned char val) { +static void aureon_cs8415_put(struct snd_ice1712 *ice, int reg, unsigned char val) { aureon_spi_write(ice, AUREON_CS8415_CS, 0x200000 | (reg << 8) | val, 24); } /* * get the current register value of WM codec */ -static unsigned short wm_get(ice1712_t *ice, int reg) +static unsigned short wm_get(struct snd_ice1712 *ice, int reg) { reg <<= 1; return ((unsigned short)ice->akm[0].images[reg] << 8) | @@ -438,7 +438,7 @@ static unsigned short wm_get(ice1712_t *ice, int reg) /* * set the register value of WM codec */ -static void wm_put_nocache(ice1712_t *ice, int reg, unsigned short val) +static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val) { aureon_spi_write(ice, AUREON_WM_CS, (reg << 9) | (val & 0x1ff), 16); } @@ -446,7 +446,7 @@ static void wm_put_nocache(ice1712_t *ice, int reg, unsigned short val) /* * set the register value of WM codec and remember it */ -static void wm_put(ice1712_t *ice, int reg, unsigned short val) +static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val) { wm_put_nocache(ice, reg, val); reg <<= 1; @@ -456,7 +456,7 @@ static void wm_put(ice1712_t *ice, int reg, unsigned short val) /* */ -static int aureon_mono_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) +static int aureon_mono_bool_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -470,9 +470,9 @@ static int aureon_mono_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) */ #define aureon_ac97_mmute_info aureon_mono_bool_info -static int aureon_ac97_mmute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_ac97_mmute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); @@ -482,8 +482,8 @@ static int aureon_ac97_mmute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int aureon_ac97_mmute_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); +static int aureon_ac97_mmute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short ovol, nvol; int change; @@ -521,7 +521,7 @@ static unsigned char wm_vol[256] = { #define WM_VOL_MAX (sizeof(wm_vol) - 1) #define WM_VOL_MUTE 0x8000 -static void wm_set_vol(ice1712_t *ice, unsigned int index, unsigned short vol, unsigned short master) +static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) { unsigned char nvol; @@ -539,9 +539,9 @@ static void wm_set_vol(ice1712_t *ice, unsigned int index, unsigned short vol, u */ #define wm_pcm_mute_info aureon_mono_bool_info -static int wm_pcm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_pcm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1; @@ -549,9 +549,9 @@ static int wm_pcm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int wm_pcm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short nval, oval; int change; @@ -568,7 +568,7 @@ static int wm_pcm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uco /* * Master volume attenuation mixer control */ -static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -577,18 +577,18 @@ static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uin return 0; } -static int wm_master_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i; for (i=0; i<2; i++) ucontrol->value.integer.value[i] = ice->spec.aureon.master[i] & ~WM_VOL_MUTE; return 0; } -static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int ch, change = 0; snd_ice1712_save_gpio_status(ice); @@ -611,7 +611,7 @@ static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco /* * DAC volume attenuation mixer control */ -static int wm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int voices = kcontrol->private_value >> 8; uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -621,9 +621,9 @@ static int wm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, ofs, voices; voices = kcontrol->private_value >> 8; @@ -633,9 +633,9 @@ static int wm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) return 0; } -static int wm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, idx, ofs, voices; int change = 0; @@ -659,7 +659,7 @@ static int wm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) /* * WM8770 mute control */ -static int wm_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { +static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = kcontrol->private_value >> 8; uinfo->value.integer.min = 0; @@ -667,9 +667,9 @@ static int wm_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { return 0; } -static int wm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int voices, ofs, i; voices = kcontrol->private_value >> 8; @@ -680,9 +680,9 @@ static int wm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) return 0; } -static int wm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change = 0, voices, ofs, i; voices = kcontrol->private_value >> 8; @@ -708,7 +708,7 @@ static int wm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontro /* * WM8770 master mute control */ -static int wm_master_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { +static int wm_master_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; uinfo->value.integer.min = 0; @@ -716,18 +716,18 @@ static int wm_master_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *ui return 0; } -static int wm_master_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (ice->spec.aureon.master[0] & WM_VOL_MUTE) ? 0 : 1; ucontrol->value.integer.value[1] = (ice->spec.aureon.master[1] & WM_VOL_MUTE) ? 0 : 1; return 0; } -static int wm_master_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change = 0, i; snd_ice1712_save_gpio_status(ice); @@ -754,7 +754,7 @@ static int wm_master_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * #define PCM_0dB 0xff #define PCM_RES 128 /* -64dB */ #define PCM_MIN (PCM_0dB - PCM_RES) -static int wm_pcm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_pcm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -763,9 +763,9 @@ static int wm_pcm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val; down(&ice->gpio_mutex); @@ -776,9 +776,9 @@ static int wm_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -static int wm_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short ovol, nvol; int change = 0; @@ -798,7 +798,7 @@ static int wm_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr /* * ADC mute control */ -static int wm_adc_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_adc_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -807,9 +807,9 @@ static int wm_adc_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo return 0; } -static int wm_adc_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val; int i; @@ -822,9 +822,9 @@ static int wm_adc_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int wm_adc_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int wm_adc_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short new, old; int i, change = 0; @@ -845,7 +845,7 @@ static int wm_adc_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uco /* * ADC gain mixer control */ -static int wm_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_adc_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -854,9 +854,9 @@ static int wm_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, idx; unsigned short vol; @@ -870,9 +870,9 @@ static int wm_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, idx; unsigned short ovol, nvol; int change = 0; @@ -894,7 +894,7 @@ static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr /* * ADC input mux mixer control */ -static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_adc_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "CD", //AIN1 @@ -913,7 +913,7 @@ static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) "Aux3", //AIN7 "AC97" //AIN8 }; - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 2; @@ -932,9 +932,9 @@ static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_adc_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val; down(&ice->gpio_mutex); @@ -945,9 +945,9 @@ static int wm_adc_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int wm_adc_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short oval, nval; int change; @@ -966,9 +966,9 @@ static int wm_adc_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucont /* * CS8415 Input mux */ -static int aureon_cs8415_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int aureon_cs8415_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); static char *aureon_texts[] = { "CD", //RXP0 "Optical" //RXP1 @@ -989,9 +989,9 @@ static int aureon_cs8415_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int aureon_cs8415_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_cs8415_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); //snd_ice1712_save_gpio_status(ice); //val = aureon_cs8415_get(ice, CS8415_CTRL2); @@ -1000,9 +1000,9 @@ static int aureon_cs8415_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int aureon_cs8415_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_cs8415_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short oval, nval; int change; @@ -1018,7 +1018,7 @@ static int aureon_cs8415_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static int aureon_cs8415_rate_info (snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int aureon_cs8415_rate_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -1027,9 +1027,9 @@ static int aureon_cs8415_rate_info (snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int aureon_cs8415_rate_get (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_cs8415_rate_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char ratio; ratio = aureon_cs8415_get(ice, CS8415_RATIO); ucontrol->value.integer.value[0] = (int)((unsigned int)ratio * 750); @@ -1039,25 +1039,25 @@ static int aureon_cs8415_rate_get (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ /* * CS8415A Mute */ -static int aureon_cs8415_mute_info (snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int aureon_cs8415_mute_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; return 0; } -static int aureon_cs8415_mute_get (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_cs8415_mute_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); snd_ice1712_save_gpio_status(ice); ucontrol->value.integer.value[0] = (aureon_cs8415_get(ice, CS8415_CTRL1) & 0x20) ? 0 : 1; snd_ice1712_restore_gpio_status(ice); return 0; } -static int aureon_cs8415_mute_put (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_cs8415_mute_put (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char oval, nval; int change; snd_ice1712_save_gpio_status(ice); @@ -1075,14 +1075,14 @@ static int aureon_cs8415_mute_put (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ /* * CS8415A Q-Sub info */ -static int aureon_cs8415_qsub_info (snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { +static int aureon_cs8415_qsub_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; uinfo->count = 10; return 0; } -static int aureon_cs8415_qsub_get (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); +static int aureon_cs8415_qsub_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); snd_ice1712_save_gpio_status(ice); aureon_cs8415_read(ice, CS8415_QSUB, ucontrol->value.bytes.data, 10); @@ -1091,19 +1091,19 @@ static int aureon_cs8415_qsub_get (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return 0; } -static int aureon_cs8415_spdif_info (snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { +static int aureon_cs8415_spdif_info (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int aureon_cs8415_mask_get (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { +static int aureon_cs8415_mask_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { memset(ucontrol->value.iec958.status, 0xFF, 24); return 0; } -static int aureon_cs8415_spdif_get (snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); +static int aureon_cs8415_spdif_get (struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); snd_ice1712_save_gpio_status(ice); aureon_cs8415_read(ice, CS8415_C_BUFFER, ucontrol->value.iec958.status, 24); @@ -1114,7 +1114,7 @@ static int aureon_cs8415_spdif_get (snd_kcontrol_t *kcontrol, snd_ctl_elem_value /* * Headphone Amplifier */ -static int aureon_set_headphone_amp(ice1712_t *ice, int enable) +static int aureon_set_headphone_amp(struct snd_ice1712 *ice, int enable) { unsigned int tmp, tmp2; @@ -1130,7 +1130,7 @@ static int aureon_set_headphone_amp(ice1712_t *ice, int enable) return 0; } -static int aureon_get_headphone_amp(ice1712_t *ice) +static int aureon_get_headphone_amp(struct snd_ice1712 *ice) { unsigned int tmp = snd_ice1712_gpio_read(ice); @@ -1139,18 +1139,18 @@ static int aureon_get_headphone_amp(ice1712_t *ice) #define aureon_hpamp_info aureon_mono_bool_info -static int aureon_hpamp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_hpamp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = aureon_get_headphone_amp(ice); return 0; } -static int aureon_hpamp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_hpamp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); return aureon_set_headphone_amp(ice,ucontrol->value.integer.value[0]); } @@ -1161,16 +1161,16 @@ static int aureon_hpamp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon #define aureon_deemp_info aureon_mono_bool_info -static int aureon_deemp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_deemp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf; return 0; } -static int aureon_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int temp, temp2; temp2 = temp = wm_get(ice, WM_DAC_CTRL2); if (ucontrol->value.integer.value[0]) @@ -1187,7 +1187,7 @@ static int aureon_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon /* * ADC Oversampling */ -static int aureon_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) +static int aureon_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "128x", "64x" }; @@ -1202,17 +1202,17 @@ static int aureon_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinf return 0; } -static int aureon_oversampling_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_oversampling_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8; return 0; } -static int aureon_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int temp, temp2; - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); temp2 = temp = wm_get(ice, WM_MASTER); @@ -1232,7 +1232,7 @@ static int aureon_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ * mixers */ -static snd_kcontrol_new_t aureon_dac_controls[] __devinitdata = { +static struct snd_kcontrol_new aureon_dac_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", @@ -1329,7 +1329,7 @@ static snd_kcontrol_new_t aureon_dac_controls[] __devinitdata = { } }; -static snd_kcontrol_new_t wm_controls[] __devinitdata = { +static struct snd_kcontrol_new wm_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Switch", @@ -1389,7 +1389,7 @@ static snd_kcontrol_new_t wm_controls[] __devinitdata = { } }; -static snd_kcontrol_new_t ac97_controls[] __devinitdata = { +static struct snd_kcontrol_new ac97_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "AC97 Playback Switch", @@ -1479,7 +1479,7 @@ static snd_kcontrol_new_t ac97_controls[] __devinitdata = { } }; -static snd_kcontrol_new_t universe_ac97_controls[] __devinitdata = { +static struct snd_kcontrol_new universe_ac97_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "AC97 Playback Switch", @@ -1586,7 +1586,7 @@ static snd_kcontrol_new_t universe_ac97_controls[] __devinitdata = { }; -static snd_kcontrol_new_t cs8415_controls[] __devinitdata = { +static struct snd_kcontrol_new cs8415_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), @@ -1632,7 +1632,7 @@ static snd_kcontrol_new_t cs8415_controls[] __devinitdata = { }; -static int __devinit aureon_add_controls(ice1712_t *ice) +static int __devinit aureon_add_controls(struct snd_ice1712 *ice) { unsigned int i, counts; int err; @@ -1677,7 +1677,7 @@ static int __devinit aureon_add_controls(ice1712_t *ice) snd_printk(KERN_INFO "Detected unsupported CS8415 rev. (%c)\n", (char)((id & 0x0F) + 'A' - 1)); else { for (i = 0; i< ARRAY_SIZE(cs8415_controls); i++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; err = snd_ctl_add(ice->card, (kctl = snd_ctl_new1(&cs8415_controls[i], ice))); if (err < 0) return err; @@ -1695,7 +1695,7 @@ static int __devinit aureon_add_controls(ice1712_t *ice) /* * initialize the chip */ -static int __devinit aureon_init(ice1712_t *ice) +static int __devinit aureon_init(struct snd_ice1712 *ice) { static unsigned short wm_inits_aureon[] = { /* These come first to reduce init pop noise */ @@ -1796,7 +1796,7 @@ static int __devinit aureon_init(ice1712_t *ice) } /* to remeber the register values of CS8415 */ - ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); + ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ice->akm) return -ENOMEM; ice->akm_codecs = 1; diff --git a/sound/pci/ice1712/envy24ht.h b/sound/pci/ice1712/envy24ht.h index f787802..b58afcd 100644 --- a/sound/pci/ice1712/envy24ht.h +++ b/sound/pci/ice1712/envy24ht.h @@ -209,7 +209,7 @@ enum { #define VT1724_MT_PDMA1_COUNT 0x76 /* word */ -unsigned char snd_vt1724_read_i2c(ice1712_t *ice, unsigned char dev, unsigned char addr); -void snd_vt1724_write_i2c(ice1712_t *ice, unsigned char dev, unsigned char addr, unsigned char data); +unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice, unsigned char dev, unsigned char addr); +void snd_vt1724_write_i2c(struct snd_ice1712 *ice, unsigned char dev, unsigned char addr, unsigned char data); #endif /* __SOUND_VT1724_H */ diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 0b5389e..71f08c0 100644 --- a/sound/pci/ice1712/ice1724.c +++ b/sound/pci/ice1712/ice1724.c @@ -102,12 +102,12 @@ static unsigned int PRO_RATE_DEFAULT = 44100; */ /* check whether the clock mode is spdif-in */ -static inline int is_spdif_master(ice1712_t *ice) +static inline int is_spdif_master(struct snd_ice1712 *ice) { return (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER) ? 1 : 0; } -static inline int is_pro_rate_locked(ice1712_t *ice) +static inline int is_pro_rate_locked(struct snd_ice1712 *ice) { return is_spdif_master(ice) || PRO_RATE_LOCKED; } @@ -116,7 +116,7 @@ static inline int is_pro_rate_locked(ice1712_t *ice) * ac97 section */ -static unsigned char snd_vt1724_ac97_ready(ice1712_t *ice) +static unsigned char snd_vt1724_ac97_ready(struct snd_ice1712 *ice) { unsigned char old_cmd; int tm; @@ -132,7 +132,7 @@ static unsigned char snd_vt1724_ac97_ready(ice1712_t *ice) return old_cmd; } -static int snd_vt1724_ac97_wait_bit(ice1712_t *ice, unsigned char bit) +static int snd_vt1724_ac97_wait_bit(struct snd_ice1712 *ice, unsigned char bit) { int tm; for (tm = 0; tm < 0x10000; tm++) @@ -142,11 +142,11 @@ static int snd_vt1724_ac97_wait_bit(ice1712_t *ice, unsigned char bit) return -EIO; } -static void snd_vt1724_ac97_write(ac97_t *ac97, +static void snd_vt1724_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - ice1712_t *ice = (ice1712_t *)ac97->private_data; + struct snd_ice1712 *ice = ac97->private_data; unsigned char old_cmd; old_cmd = snd_vt1724_ac97_ready(ice); @@ -158,9 +158,9 @@ static void snd_vt1724_ac97_write(ac97_t *ac97, snd_vt1724_ac97_wait_bit(ice, VT1724_AC97_WRITE); } -static unsigned short snd_vt1724_ac97_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_vt1724_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - ice1712_t *ice = (ice1712_t *)ac97->private_data; + struct snd_ice1712 *ice = ac97->private_data; unsigned char old_cmd; old_cmd = snd_vt1724_ac97_ready(ice); @@ -179,14 +179,14 @@ static unsigned short snd_vt1724_ac97_read(ac97_t *ac97, unsigned short reg) */ /* set gpio direction 0 = read, 1 = write */ -static void snd_vt1724_set_gpio_dir(ice1712_t *ice, unsigned int data) +static void snd_vt1724_set_gpio_dir(struct snd_ice1712 *ice, unsigned int data) { outl(data, ICEREG1724(ice, GPIO_DIRECTION)); inw(ICEREG1724(ice, GPIO_DIRECTION)); /* dummy read for pci-posting */ } /* set the gpio mask (0 = writable) */ -static void snd_vt1724_set_gpio_mask(ice1712_t *ice, unsigned int data) +static void snd_vt1724_set_gpio_mask(struct snd_ice1712 *ice, unsigned int data) { outw(data, ICEREG1724(ice, GPIO_WRITE_MASK)); if (! ice->vt1720) /* VT1720 supports only 16 GPIO bits */ @@ -194,7 +194,7 @@ static void snd_vt1724_set_gpio_mask(ice1712_t *ice, unsigned int data) inw(ICEREG1724(ice, GPIO_WRITE_MASK)); /* dummy read for pci-posting */ } -static void snd_vt1724_set_gpio_data(ice1712_t *ice, unsigned int data) +static void snd_vt1724_set_gpio_data(struct snd_ice1712 *ice, unsigned int data) { outw(data, ICEREG1724(ice, GPIO_DATA)); if (! ice->vt1720) @@ -202,7 +202,7 @@ static void snd_vt1724_set_gpio_data(ice1712_t *ice, unsigned int data) inw(ICEREG1724(ice, GPIO_DATA)); /* dummy read for pci-posting */ } -static unsigned int snd_vt1724_get_gpio_data(ice1712_t *ice) +static unsigned int snd_vt1724_get_gpio_data(struct snd_ice1712 *ice) { unsigned int data; if (! ice->vt1720) @@ -219,7 +219,7 @@ static unsigned int snd_vt1724_get_gpio_data(ice1712_t *ice) static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ice1712_t *ice = dev_id; + struct snd_ice1712 *ice = dev_id; unsigned char status; int handled = 0; @@ -229,8 +229,10 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id, struct pt_regs *r break; handled = 1; - /* these should probably be separated at some point, - but as we don't currently have MPU support on the board I will leave it */ + /* these should probably be separated at some point, + * but as we don't currently have MPU support on the board + * I will leave it + */ if ((status & VT1724_IRQ_MPU_RX)||(status & VT1724_IRQ_MPU_TX)) { if (ice->rmidi[0]) snd_mpu401_uart_interrupt(irq, ice->rmidi[0]->private_data, regs); @@ -303,19 +305,19 @@ static unsigned int rates[] = { 176400, 192000, }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates_96 = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates_96 = { .count = ARRAY_SIZE(rates) - 2, /* up to 96000 */ .list = rates, .mask = 0, }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates_48 = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates_48 = { .count = ARRAY_SIZE(rates) - 5, /* up to 48000 */ .list = rates, .mask = 0, }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates_192 = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates_192 = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, @@ -328,13 +330,13 @@ struct vt1724_pcm_reg { unsigned int start; /* start & pause bit */ }; -static int snd_vt1724_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_vt1724_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); unsigned char what; unsigned char old; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; what = 0; snd_pcm_group_for_each(pos, substream) { @@ -384,7 +386,7 @@ static int snd_vt1724_pcm_trigger(snd_pcm_substream_t *substream, int cmd) #define DMA_PAUSES (VT1724_RDMA0_PAUSE|VT1724_PDMA0_PAUSE|VT1724_RDMA1_PAUSE|\ VT1724_PDMA1_PAUSE|VT1724_PDMA2_PAUSE|VT1724_PDMA3_PAUSE|VT1724_PDMA4_PAUSE) -static int get_max_rate(ice1712_t *ice) +static int get_max_rate(struct snd_ice1712 *ice) { if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720) @@ -395,7 +397,8 @@ static int get_max_rate(ice1712_t *ice) return 48000; } -static void snd_vt1724_set_pro_rate(ice1712_t *ice, unsigned int rate, int force) +static void snd_vt1724_set_pro_rate(struct snd_ice1712 *ice, unsigned int rate, + int force) { unsigned long flags; unsigned char val, old; @@ -477,10 +480,10 @@ static void snd_vt1724_set_pro_rate(ice1712_t *ice, unsigned int rate, int force ice->spdif.ops.setup_rate(ice, rate); } -static int snd_vt1724_pcm_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_vt1724_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); int i, chs; chs = params_channels(hw_params); @@ -490,7 +493,8 @@ static int snd_vt1724_pcm_hw_params(snd_pcm_substream_t * substream, /* PDMA0 can be multi-channel up to 8 */ chs = chs / 2 - 1; for (i = 0; i < chs; i++) { - if (ice->pcm_reserved[i] && ice->pcm_reserved[i] != substream) { + if (ice->pcm_reserved[i] && + ice->pcm_reserved[i] != substream) { up(&ice->open_mutex); return -EBUSY; } @@ -504,7 +508,8 @@ static int snd_vt1724_pcm_hw_params(snd_pcm_substream_t * substream, for (i = 0; i < 3; i++) { /* check individual playback stream */ if (ice->playback_con_substream_ds[i] == substream) { - if (ice->pcm_reserved[i] && ice->pcm_reserved[i] != substream) { + if (ice->pcm_reserved[i] && + ice->pcm_reserved[i] != substream) { up(&ice->open_mutex); return -EBUSY; } @@ -518,9 +523,9 @@ static int snd_vt1724_pcm_hw_params(snd_pcm_substream_t * substream, return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_vt1724_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); int i; down(&ice->open_mutex); @@ -532,9 +537,9 @@ static int snd_vt1724_pcm_hw_free(snd_pcm_substream_t * substream) return snd_pcm_lib_free_pages(substream); } -static int snd_vt1724_playback_pro_prepare(snd_pcm_substream_t * substream) +static int snd_vt1724_playback_pro_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); unsigned char val; unsigned int size; @@ -559,9 +564,9 @@ static int snd_vt1724_playback_pro_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); size_t ptr; if (!(inl(ICEMT1724(ice, DMA_CONTROL)) & VT1724_PDMA0_START)) @@ -575,7 +580,8 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(snd_pcm_substream_t * s ptr -= substream->runtime->dma_addr; ptr = bytes_to_frames(substream->runtime, ptr); if (ptr >= substream->runtime->buffer_size) { - snd_printd("ice1724: invalid ptr %d (size=%d)\n", (int)ptr, (int)substream->runtime->period_size); + snd_printd("ice1724: invalid ptr %d (size=%d)\n", + (int)ptr, (int)substream->runtime->period_size); return 0; } #else /* read PLAYBACK_SIZE */ @@ -587,29 +593,32 @@ static snd_pcm_uframes_t snd_vt1724_playback_pro_pointer(snd_pcm_substream_t * s else if (ptr <= substream->runtime->buffer_size) ptr = substream->runtime->buffer_size - ptr; else { - snd_printd("ice1724: invalid ptr %d (size=%d)\n", (int)ptr, (int)substream->runtime->buffer_size); + snd_printd("ice1724: invalid ptr %d (size=%d)\n", + (int)ptr, (int)substream->runtime->buffer_size); ptr = 0; } #endif return ptr; } -static int snd_vt1724_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_vt1724_pcm_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); struct vt1724_pcm_reg *reg = substream->runtime->private_data; spin_lock_irq(&ice->reg_lock); outl(substream->runtime->dma_addr, ice->profi_port + reg->addr); - outw((snd_pcm_lib_buffer_bytes(substream) >> 2) - 1, ice->profi_port + reg->size); - outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, ice->profi_port + reg->count); + outw((snd_pcm_lib_buffer_bytes(substream) >> 2) - 1, + ice->profi_port + reg->size); + outw((snd_pcm_lib_period_bytes(substream) >> 2) - 1, + ice->profi_port + reg->count); spin_unlock_irq(&ice->reg_lock); return 0; } -static snd_pcm_uframes_t snd_vt1724_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_vt1724_pcm_pointer(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); struct vt1724_pcm_reg *reg = substream->runtime->private_data; size_t ptr; @@ -628,7 +637,8 @@ static snd_pcm_uframes_t snd_vt1724_pcm_pointer(snd_pcm_substream_t *substream) else if (ptr <= substream->runtime->buffer_size) ptr = substream->runtime->buffer_size - ptr; else { - snd_printd("ice1724: invalid ptr %d (size=%d)\n", (int)ptr, (int)substream->runtime->buffer_size); + snd_printd("ice1724: invalid ptr %d (size=%d)\n", + (int)ptr, (int)substream->runtime->buffer_size); ptr = 0; } return ptr; @@ -649,7 +659,7 @@ static struct vt1724_pcm_reg vt1724_capture_pro_reg = { .start = VT1724_RDMA0_START, }; -static snd_pcm_hardware_t snd_vt1724_playback_pro = +static struct snd_pcm_hardware snd_vt1724_playback_pro = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -668,7 +678,7 @@ static snd_pcm_hardware_t snd_vt1724_playback_pro = .periods_max = 1024, }; -static snd_pcm_hardware_t snd_vt1724_spdif = +static struct snd_pcm_hardware snd_vt1724_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -690,7 +700,7 @@ static snd_pcm_hardware_t snd_vt1724_spdif = .periods_max = 1024, }; -static snd_pcm_hardware_t snd_vt1724_2ch_stereo = +static struct snd_pcm_hardware snd_vt1724_2ch_stereo = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -712,31 +722,41 @@ static snd_pcm_hardware_t snd_vt1724_2ch_stereo = /* * set rate constraints */ -static int set_rate_constraints(ice1712_t *ice, snd_pcm_substream_t *substream) +static int set_rate_constraints(struct snd_ice1712 *ice, + struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (ice->hw_rates) { /* hardware specific */ runtime->hw.rate_min = ice->hw_rates->list[0]; runtime->hw.rate_max = ice->hw_rates->list[ice->hw_rates->count - 1]; runtime->hw.rates = SNDRV_PCM_RATE_KNOT; - return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, ice->hw_rates); + return snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + ice->hw_rates); } if (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S) { /* I2S */ /* VT1720 doesn't support more than 96kHz */ if ((ice->eeprom.data[ICE_EEP2_I2S] & 0x08) && !ice->vt1720) - return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates_192); + return snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &hw_constraints_rates_192); else { - runtime->hw.rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_96000; + runtime->hw.rates = SNDRV_PCM_RATE_KNOT | + SNDRV_PCM_RATE_8000_96000; runtime->hw.rate_max = 96000; - return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates_96); + return snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &hw_constraints_rates_96); } } else if (ice->ac97) { /* ACLINK */ runtime->hw.rate_max = 48000; runtime->hw.rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000; - return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates_48); + return snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &hw_constraints_rates_48); } return 0; } @@ -746,10 +766,10 @@ static int set_rate_constraints(ice1712_t *ice, snd_pcm_substream_t *substream) */ #define VT1724_BUFFER_ALIGN 0x20 -static int snd_vt1724_playback_pro_open(snd_pcm_substream_t * substream) +static int snd_vt1724_playback_pro_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); int chs; runtime->private_data = &vt1724_playback_pro_reg; @@ -776,10 +796,10 @@ static int snd_vt1724_playback_pro_open(snd_pcm_substream_t * substream) return 0; } -static int snd_vt1724_capture_pro_open(snd_pcm_substream_t * substream) +static int snd_vt1724_capture_pro_open(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; runtime->private_data = &vt1724_capture_pro_reg; ice->capture_pro_substream = substream; @@ -794,9 +814,9 @@ static int snd_vt1724_capture_pro_open(snd_pcm_substream_t * substream) return 0; } -static int snd_vt1724_playback_pro_close(snd_pcm_substream_t * substream) +static int snd_vt1724_playback_pro_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); if (PRO_RATE_RESET) snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); @@ -805,9 +825,9 @@ static int snd_vt1724_playback_pro_close(snd_pcm_substream_t * substream) return 0; } -static int snd_vt1724_capture_pro_close(snd_pcm_substream_t * substream) +static int snd_vt1724_capture_pro_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); if (PRO_RATE_RESET) snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); @@ -815,7 +835,7 @@ static int snd_vt1724_capture_pro_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_vt1724_playback_pro_ops = { +static struct snd_pcm_ops snd_vt1724_playback_pro_ops = { .open = snd_vt1724_playback_pro_open, .close = snd_vt1724_playback_pro_close, .ioctl = snd_pcm_lib_ioctl, @@ -826,7 +846,7 @@ static snd_pcm_ops_t snd_vt1724_playback_pro_ops = { .pointer = snd_vt1724_playback_pro_pointer, }; -static snd_pcm_ops_t snd_vt1724_capture_pro_ops = { +static struct snd_pcm_ops snd_vt1724_capture_pro_ops = { .open = snd_vt1724_capture_pro_open, .close = snd_vt1724_capture_pro_close, .ioctl = snd_pcm_lib_ioctl, @@ -837,9 +857,9 @@ static snd_pcm_ops_t snd_vt1724_capture_pro_ops = { .pointer = snd_vt1724_pcm_pointer, }; -static int __devinit snd_vt1724_pcm_profi(ice1712_t * ice, int device) +static int __devinit snd_vt1724_pcm_profi(struct snd_ice1712 * ice, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; err = snd_pcm_new(ice->card, "ICE1724", device, 1, 1, &pcm); @@ -854,7 +874,8 @@ static int __devinit snd_vt1724_pcm_profi(ice1712_t * ice, int device) strcpy(pcm->name, "ICE1724"); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - snd_dma_pci_data(ice->pci), 256*1024, 256*1024); + snd_dma_pci_data(ice->pci), + 256*1024, 256*1024); ice->pcm_pro = pcm; @@ -881,7 +902,7 @@ static struct vt1724_pcm_reg vt1724_capture_spdif_reg = { }; /* update spdif control bits; call with reg_lock */ -static void update_spdif_bits(ice1712_t *ice, unsigned int val) +static void update_spdif_bits(struct snd_ice1712 *ice, unsigned int val) { unsigned char cbit, disabled; @@ -896,7 +917,7 @@ static void update_spdif_bits(ice1712_t *ice, unsigned int val) } /* update SPDIF control bits according to the given rate */ -static void update_spdif_rate(ice1712_t *ice, unsigned int rate) +static void update_spdif_rate(struct snd_ice1712 *ice, unsigned int rate) { unsigned int val, nval; unsigned long flags; @@ -918,18 +939,18 @@ static void update_spdif_rate(ice1712_t *ice, unsigned int rate) spin_unlock_irqrestore(&ice->reg_lock, flags); } -static int snd_vt1724_playback_spdif_prepare(snd_pcm_substream_t * substream) +static int snd_vt1724_playback_spdif_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); if (! ice->force_pdma4) update_spdif_rate(ice, substream->runtime->rate); return snd_vt1724_pcm_prepare(substream); } -static int snd_vt1724_playback_spdif_open(snd_pcm_substream_t *substream) +static int snd_vt1724_playback_spdif_open(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; runtime->private_data = &vt1724_playback_spdif_reg; ice->playback_con_substream = substream; @@ -947,9 +968,9 @@ static int snd_vt1724_playback_spdif_open(snd_pcm_substream_t *substream) return 0; } -static int snd_vt1724_playback_spdif_close(snd_pcm_substream_t * substream) +static int snd_vt1724_playback_spdif_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); if (PRO_RATE_RESET) snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); @@ -958,10 +979,10 @@ static int snd_vt1724_playback_spdif_close(snd_pcm_substream_t * substream) return 0; } -static int snd_vt1724_capture_spdif_open(snd_pcm_substream_t *substream) +static int snd_vt1724_capture_spdif_open(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; runtime->private_data = &vt1724_capture_spdif_reg; ice->capture_con_substream = substream; @@ -979,9 +1000,9 @@ static int snd_vt1724_capture_spdif_open(snd_pcm_substream_t *substream) return 0; } -static int snd_vt1724_capture_spdif_close(snd_pcm_substream_t * substream) +static int snd_vt1724_capture_spdif_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); if (PRO_RATE_RESET) snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); @@ -990,7 +1011,7 @@ static int snd_vt1724_capture_spdif_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_vt1724_playback_spdif_ops = { +static struct snd_pcm_ops snd_vt1724_playback_spdif_ops = { .open = snd_vt1724_playback_spdif_open, .close = snd_vt1724_playback_spdif_close, .ioctl = snd_pcm_lib_ioctl, @@ -1001,7 +1022,7 @@ static snd_pcm_ops_t snd_vt1724_playback_spdif_ops = { .pointer = snd_vt1724_pcm_pointer, }; -static snd_pcm_ops_t snd_vt1724_capture_spdif_ops = { +static struct snd_pcm_ops snd_vt1724_capture_spdif_ops = { .open = snd_vt1724_capture_spdif_open, .close = snd_vt1724_capture_spdif_close, .ioctl = snd_pcm_lib_ioctl, @@ -1013,10 +1034,10 @@ static snd_pcm_ops_t snd_vt1724_capture_spdif_ops = { }; -static int __devinit snd_vt1724_pcm_spdif(ice1712_t * ice, int device) +static int __devinit snd_vt1724_pcm_spdif(struct snd_ice1712 * ice, int device) { char *name; - snd_pcm_t *pcm; + struct snd_pcm *pcm; int play, capt; int err; @@ -1055,7 +1076,8 @@ static int __devinit snd_vt1724_pcm_spdif(ice1712_t * ice, int device) strcpy(pcm->name, name); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - snd_dma_pci_data(ice->pci), 64*1024, 64*1024); + snd_dma_pci_data(ice->pci), + 64*1024, 64*1024); ice->pcm = pcm; @@ -1088,9 +1110,9 @@ static struct vt1724_pcm_reg vt1724_playback_dma_regs[3] = { }, }; -static int snd_vt1724_playback_indep_prepare(snd_pcm_substream_t * substream) +static int snd_vt1724_playback_indep_prepare(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); unsigned char val; spin_lock_irq(&ice->reg_lock); @@ -1101,10 +1123,10 @@ static int snd_vt1724_playback_indep_prepare(snd_pcm_substream_t * substream) return snd_vt1724_pcm_prepare(substream); } -static int snd_vt1724_playback_indep_open(snd_pcm_substream_t *substream) +static int snd_vt1724_playback_indep_open(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; down(&ice->open_mutex); /* already used by PDMA0? */ @@ -1122,9 +1144,9 @@ static int snd_vt1724_playback_indep_open(snd_pcm_substream_t *substream) return 0; } -static int snd_vt1724_playback_indep_close(snd_pcm_substream_t * substream) +static int snd_vt1724_playback_indep_close(struct snd_pcm_substream *substream) { - ice1712_t *ice = snd_pcm_substream_chip(substream); + struct snd_ice1712 *ice = snd_pcm_substream_chip(substream); if (PRO_RATE_RESET) snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0); @@ -1134,7 +1156,7 @@ static int snd_vt1724_playback_indep_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_vt1724_playback_indep_ops = { +static struct snd_pcm_ops snd_vt1724_playback_indep_ops = { .open = snd_vt1724_playback_indep_open, .close = snd_vt1724_playback_indep_close, .ioctl = snd_pcm_lib_ioctl, @@ -1146,9 +1168,9 @@ static snd_pcm_ops_t snd_vt1724_playback_indep_ops = { }; -static int __devinit snd_vt1724_pcm_indep(ice1712_t * ice, int device) +static int __devinit snd_vt1724_pcm_indep(struct snd_ice1712 * ice, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int play; int err; @@ -1168,7 +1190,8 @@ static int __devinit snd_vt1724_pcm_indep(ice1712_t * ice, int device) strcpy(pcm->name, "ICE1724 Surround PCM"); snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - snd_dma_pci_data(ice->pci), 64*1024, 64*1024); + snd_dma_pci_data(ice->pci), + 64*1024, 64*1024); ice->pcm_ds = pcm; @@ -1180,14 +1203,14 @@ static int __devinit snd_vt1724_pcm_indep(ice1712_t * ice, int device) * Mixer section */ -static int __devinit snd_vt1724_ac97_mixer(ice1712_t * ice) +static int __devinit snd_vt1724_ac97_mixer(struct snd_ice1712 * ice) { int err; if (! (ice->eeprom.data[ICE_EEP2_ACLINK] & VT1724_CFG_PRO_I2S)) { - ac97_bus_t *pbus; - ac97_template_t ac97; - static ac97_bus_ops_t ops = { + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; + static struct snd_ac97_bus_ops ops = { .write = snd_vt1724_ac97_write, .read = snd_vt1724_ac97_read, }; @@ -1215,17 +1238,17 @@ static int __devinit snd_vt1724_ac97_mixer(ice1712_t * ice) * */ -static inline unsigned int eeprom_triple(ice1712_t *ice, int idx) +static inline unsigned int eeprom_triple(struct snd_ice1712 *ice, int idx) { return (unsigned int)ice->eeprom.data[idx] | \ ((unsigned int)ice->eeprom.data[idx + 1] << 8) | \ ((unsigned int)ice->eeprom.data[idx + 2] << 16); } -static void snd_vt1724_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_vt1724_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ice1712_t *ice = entry->private_data; + struct snd_ice1712 *ice = entry->private_data; unsigned int idx; snd_iprintf(buffer, "%s\n\n", ice->card->longname); @@ -1234,28 +1257,39 @@ static void snd_vt1724_proc_read(snd_info_entry_t *entry, snd_iprintf(buffer, " Subvendor : 0x%x\n", ice->eeprom.subvendor); snd_iprintf(buffer, " Size : %i bytes\n", ice->eeprom.size); snd_iprintf(buffer, " Version : %i\n", ice->eeprom.version); - snd_iprintf(buffer, " System Config : 0x%x\n", ice->eeprom.data[ICE_EEP2_SYSCONF]); - snd_iprintf(buffer, " ACLink : 0x%x\n", ice->eeprom.data[ICE_EEP2_ACLINK]); - snd_iprintf(buffer, " I2S : 0x%x\n", ice->eeprom.data[ICE_EEP2_I2S]); - snd_iprintf(buffer, " S/PDIF : 0x%x\n", ice->eeprom.data[ICE_EEP2_SPDIF]); - snd_iprintf(buffer, " GPIO direction : 0x%x\n", ice->eeprom.gpiodir); - snd_iprintf(buffer, " GPIO mask : 0x%x\n", ice->eeprom.gpiomask); - snd_iprintf(buffer, " GPIO state : 0x%x\n", ice->eeprom.gpiostate); + snd_iprintf(buffer, " System Config : 0x%x\n", + ice->eeprom.data[ICE_EEP2_SYSCONF]); + snd_iprintf(buffer, " ACLink : 0x%x\n", + ice->eeprom.data[ICE_EEP2_ACLINK]); + snd_iprintf(buffer, " I2S : 0x%x\n", + ice->eeprom.data[ICE_EEP2_I2S]); + snd_iprintf(buffer, " S/PDIF : 0x%x\n", + ice->eeprom.data[ICE_EEP2_SPDIF]); + snd_iprintf(buffer, " GPIO direction : 0x%x\n", + ice->eeprom.gpiodir); + snd_iprintf(buffer, " GPIO mask : 0x%x\n", + ice->eeprom.gpiomask); + snd_iprintf(buffer, " GPIO state : 0x%x\n", + ice->eeprom.gpiostate); for (idx = 0x12; idx < ice->eeprom.size; idx++) - snd_iprintf(buffer, " Extra #%02i : 0x%x\n", idx, ice->eeprom.data[idx]); + snd_iprintf(buffer, " Extra #%02i : 0x%x\n", + idx, ice->eeprom.data[idx]); snd_iprintf(buffer, "\nRegisters:\n"); - snd_iprintf(buffer, " PSDOUT03 : 0x%08x\n", (unsigned)inl(ICEMT1724(ice, ROUTE_PLAYBACK))); + snd_iprintf(buffer, " PSDOUT03 : 0x%08x\n", + (unsigned)inl(ICEMT1724(ice, ROUTE_PLAYBACK))); for (idx = 0x0; idx < 0x20 ; idx++) - snd_iprintf(buffer, " CCS%02x : 0x%02x\n", idx, inb(ice->port+idx)); + snd_iprintf(buffer, " CCS%02x : 0x%02x\n", + idx, inb(ice->port+idx)); for (idx = 0x0; idx < 0x30 ; idx++) - snd_iprintf(buffer, " MT%02x : 0x%02x\n", idx, inb(ice->profi_port+idx)); + snd_iprintf(buffer, " MT%02x : 0x%02x\n", + idx, inb(ice->profi_port+idx)); } -static void __devinit snd_vt1724_proc_init(ice1712_t * ice) +static void __devinit snd_vt1724_proc_init(struct snd_ice1712 * ice) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(ice->card, "ice1724", &entry)) snd_info_set_text_ops(entry, ice, 1024, snd_vt1724_proc_read); @@ -1265,22 +1299,24 @@ static void __devinit snd_vt1724_proc_init(ice1712_t * ice) * */ -static int snd_vt1724_eeprom_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vt1724_eeprom_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; - uinfo->count = sizeof(ice1712_eeprom_t); + uinfo->count = sizeof(struct snd_ice1712_eeprom); return 0; } -static int snd_vt1724_eeprom_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_eeprom_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); memcpy(ucontrol->value.bytes.data, &ice->eeprom, sizeof(ice->eeprom)); return 0; } -static snd_kcontrol_new_t snd_vt1724_eeprom __devinitdata = { +static struct snd_kcontrol_new snd_vt1724_eeprom __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_CARD, .name = "ICE1724 EEPROM", .access = SNDRV_CTL_ELEM_ACCESS_READ, @@ -1290,21 +1326,23 @@ static snd_kcontrol_new_t snd_vt1724_eeprom __devinitdata = { /* */ -static int snd_vt1724_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vt1724_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static unsigned int encode_spdif_bits(snd_aes_iec958_t *diga) +static unsigned int encode_spdif_bits(struct snd_aes_iec958 *diga) { unsigned int val, rbits; val = diga->status[0] & 0x03; /* professional, non-audio */ if (val & 0x01) { /* professional */ - if ((diga->status[0] & IEC958_AES0_PRO_EMPHASIS) == IEC958_AES0_PRO_EMPHASIS_5015) + if ((diga->status[0] & IEC958_AES0_PRO_EMPHASIS) == + IEC958_AES0_PRO_EMPHASIS_5015) val |= 1U << 3; rbits = (diga->status[4] >> 3) & 0x0f; if (rbits) { @@ -1329,7 +1367,8 @@ static unsigned int encode_spdif_bits(snd_aes_iec958_t *diga) } else { /* consumer */ val |= diga->status[1] & 0x04; /* copyright */ - if ((diga->status[0] & IEC958_AES0_CON_EMPHASIS)== IEC958_AES0_CON_EMPHASIS_5015) + if ((diga->status[0] & IEC958_AES0_CON_EMPHASIS) == + IEC958_AES0_CON_EMPHASIS_5015) val |= 1U << 3; val |= (unsigned int)(diga->status[1] & 0x3f) << 4; /* category */ val |= (unsigned int)(diga->status[3] & IEC958_AES3_CON_FS) << 12; /* fs */ @@ -1337,7 +1376,7 @@ static unsigned int encode_spdif_bits(snd_aes_iec958_t *diga) return val; } -static void decode_spdif_bits(snd_aes_iec958_t *diga, unsigned int val) +static void decode_spdif_bits(struct snd_aes_iec958 *diga, unsigned int val) { memset(diga->status, 0, sizeof(diga->status)); diga->status[0] = val & 0x03; /* professional, non-audio */ @@ -1365,20 +1404,20 @@ static void decode_spdif_bits(snd_aes_iec958_t *diga, unsigned int val) } } -static int snd_vt1724_spdif_default_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned int val; val = inw(ICEMT1724(ice, SPDIF_CTRL)); decode_spdif_bits(&ucontrol->value.iec958, val); return 0; } -static int snd_vt1724_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned int val, old; val = encode_spdif_bits(&ucontrol->value.iec958); @@ -1390,7 +1429,7 @@ static int snd_vt1724_spdif_default_put(snd_kcontrol_t * kcontrol, return (val != old); } -static snd_kcontrol_new_t snd_vt1724_spdif_default __devinitdata = +static struct snd_kcontrol_new snd_vt1724_spdif_default __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -1399,8 +1438,8 @@ static snd_kcontrol_new_t snd_vt1724_spdif_default __devinitdata = .put = snd_vt1724_spdif_default_put }; -static int snd_vt1724_spdif_maskc_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_spdif_maskc_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO | IEC958_AES0_PROFESSIONAL | @@ -1412,8 +1451,8 @@ static int snd_vt1724_spdif_maskc_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_vt1724_spdif_maskp_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_spdif_maskp_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = IEC958_AES0_NONAUDIO | IEC958_AES0_PROFESSIONAL | @@ -1422,7 +1461,7 @@ static int snd_vt1724_spdif_maskp_get(snd_kcontrol_t * kcontrol, return 0; } -static snd_kcontrol_new_t snd_vt1724_spdif_maskc __devinitdata = +static struct snd_kcontrol_new snd_vt1724_spdif_maskc __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1431,7 +1470,7 @@ static snd_kcontrol_new_t snd_vt1724_spdif_maskc __devinitdata = .get = snd_vt1724_spdif_maskc_get, }; -static snd_kcontrol_new_t snd_vt1724_spdif_maskp __devinitdata = +static struct snd_kcontrol_new snd_vt1724_spdif_maskp __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1440,7 +1479,8 @@ static snd_kcontrol_new_t snd_vt1724_spdif_maskp __devinitdata = .get = snd_vt1724_spdif_maskp_get, }; -static int snd_vt1724_spdif_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vt1724_spdif_sw_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1449,16 +1489,19 @@ static int snd_vt1724_spdif_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_vt1724_spdif_sw_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_spdif_sw_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); - ucontrol->value.integer.value[0] = inb(ICEREG1724(ice, SPDIF_CFG)) & VT1724_CFG_SPDIF_OUT_EN ? 1 : 0; + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); + ucontrol->value.integer.value[0] = inb(ICEREG1724(ice, SPDIF_CFG)) & + VT1724_CFG_SPDIF_OUT_EN ? 1 : 0; return 0; } -static int snd_vt1724_spdif_sw_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_spdif_sw_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char old, val; spin_lock_irq(&ice->reg_lock); @@ -1472,7 +1515,7 @@ static int snd_vt1724_spdif_sw_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return old != val; } -static snd_kcontrol_new_t snd_vt1724_spdif_switch __devinitdata = +static struct snd_kcontrol_new snd_vt1724_spdif_switch __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, /* FIXME: the following conflict with IEC958 Playback Route */ @@ -1489,7 +1532,8 @@ static snd_kcontrol_new_t snd_vt1724_spdif_switch __devinitdata = * GPIO access from extern */ -int snd_vt1724_gpio_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +int snd_vt1724_gpio_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1498,21 +1542,24 @@ int snd_vt1724_gpio_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) return 0; } -int snd_vt1724_gpio_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_vt1724_gpio_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value & (1<<24)) ? 1 : 0; snd_ice1712_save_gpio_status(ice); - ucontrol->value.integer.value[0] = (snd_ice1712_gpio_read(ice) & (1 << shift) ? 1 : 0) ^ invert; + ucontrol->value.integer.value[0] = + (snd_ice1712_gpio_read(ice) & (1 << shift) ? 1 : 0) ^ invert; snd_ice1712_restore_gpio_status(ice); return 0; } -int snd_ice1712_gpio_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +int snd_ice1712_gpio_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int shift = kcontrol->private_value & 0xff; int invert = (kcontrol->private_value & (1<<24)) ? mask : 0; unsigned int val, nval; @@ -1533,7 +1580,8 @@ int snd_ice1712_gpio_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucont /* * rate */ -static int snd_vt1724_pro_internal_clock_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vt1724_pro_internal_clock_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts_1724[] = { "8000", /* 0: 6 */ @@ -1569,7 +1617,7 @@ static int snd_vt1724_pro_internal_clock_info(snd_kcontrol_t *kcontrol, snd_ctl_ "96000", /* 12: 7 */ "IEC958 Input", /* 13: -- */ }; - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -1582,9 +1630,10 @@ static int snd_vt1724_pro_internal_clock_info(snd_kcontrol_t *kcontrol, snd_ctl_ return 0; } -static int snd_vt1724_pro_internal_clock_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_pro_internal_clock_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); static unsigned char xlate[16] = { 9, 6, 3, 1, 7, 4, 0, 12, 8, 5, 2, 11, 13, 255, 14, 10 }; @@ -1605,9 +1654,10 @@ static int snd_vt1724_pro_internal_clock_get(snd_kcontrol_t * kcontrol, snd_ctl_ return 0; } -static int snd_vt1724_pro_internal_clock_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_pro_internal_clock_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char oval; int rate; int change = 0; @@ -1629,7 +1679,8 @@ static int snd_vt1724_pro_internal_clock_put(snd_kcontrol_t * kcontrol, snd_ctl_ change = inb(ICEMT1724(ice, RATE)) != oval; spin_unlock_irq(&ice->reg_lock); - if ((oval & VT1724_SPDIF_MASTER) != (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER)) { + if ((oval & VT1724_SPDIF_MASTER) != + (inb(ICEMT1724(ice, RATE)) & VT1724_SPDIF_MASTER)) { /* notify akm chips as well */ if (is_spdif_master(ice)) { unsigned int i; @@ -1642,7 +1693,7 @@ static int snd_vt1724_pro_internal_clock_put(snd_kcontrol_t * kcontrol, snd_ctl_ return change; } -static snd_kcontrol_new_t snd_vt1724_pro_internal_clock __devinitdata = { +static struct snd_kcontrol_new snd_vt1724_pro_internal_clock __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Internal Clock", .info = snd_vt1724_pro_internal_clock_info, @@ -1650,7 +1701,8 @@ static snd_kcontrol_new_t snd_vt1724_pro_internal_clock __devinitdata = { .put = snd_vt1724_pro_internal_clock_put }; -static int snd_vt1724_pro_rate_locking_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vt1724_pro_rate_locking_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1659,15 +1711,17 @@ static int snd_vt1724_pro_rate_locking_info(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_vt1724_pro_rate_locking_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_pro_rate_locking_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = PRO_RATE_LOCKED; return 0; } -static int snd_vt1724_pro_rate_locking_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_pro_rate_locking_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change = 0, nval; nval = ucontrol->value.integer.value[0] ? 1 : 0; @@ -1678,7 +1732,7 @@ static int snd_vt1724_pro_rate_locking_put(snd_kcontrol_t * kcontrol, snd_ctl_el return change; } -static snd_kcontrol_new_t snd_vt1724_pro_rate_locking __devinitdata = { +static struct snd_kcontrol_new snd_vt1724_pro_rate_locking __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Rate Locking", .info = snd_vt1724_pro_rate_locking_info, @@ -1686,7 +1740,8 @@ static snd_kcontrol_new_t snd_vt1724_pro_rate_locking __devinitdata = { .put = snd_vt1724_pro_rate_locking_put }; -static int snd_vt1724_pro_rate_reset_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vt1724_pro_rate_reset_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1695,15 +1750,17 @@ static int snd_vt1724_pro_rate_reset_info(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_vt1724_pro_rate_reset_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_pro_rate_reset_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.integer.value[0] = PRO_RATE_RESET ? 1 : 0; return 0; } -static int snd_vt1724_pro_rate_reset_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_pro_rate_reset_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change = 0, nval; nval = ucontrol->value.integer.value[0] ? 1 : 0; @@ -1714,7 +1771,7 @@ static int snd_vt1724_pro_rate_reset_put(snd_kcontrol_t * kcontrol, snd_ctl_elem return change; } -static snd_kcontrol_new_t snd_vt1724_pro_rate_reset __devinitdata = { +static struct snd_kcontrol_new snd_vt1724_pro_rate_reset __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Rate Reset", .info = snd_vt1724_pro_rate_reset_info, @@ -1726,7 +1783,8 @@ static snd_kcontrol_new_t snd_vt1724_pro_rate_reset __devinitdata = { /* * routing */ -static int snd_vt1724_pro_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vt1724_pro_route_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "PCM Out", /* 0 */ @@ -1753,7 +1811,7 @@ static inline int digital_route_shift(int idx) return idx * 3; } -static int get_route_val(ice1712_t *ice, int shift) +static int get_route_val(struct snd_ice1712 *ice, int shift) { unsigned long val; unsigned char eitem; @@ -1772,7 +1830,7 @@ static int get_route_val(ice1712_t *ice, int shift) return eitem; } -static int put_route_val(ice1712_t *ice, unsigned int val, int shift) +static int put_route_val(struct snd_ice1712 *ice, unsigned int val, int shift) { unsigned int old_val, nval; int change; @@ -1794,39 +1852,45 @@ static int put_route_val(ice1712_t *ice, unsigned int val, int shift) return change; } -static int snd_vt1724_pro_route_analog_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_vt1724_pro_route_analog_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - ucontrol->value.enumerated.item[0] = get_route_val(ice, analog_route_shift(idx)); + ucontrol->value.enumerated.item[0] = + get_route_val(ice, analog_route_shift(idx)); return 0; } -static int snd_vt1724_pro_route_analog_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_vt1724_pro_route_analog_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); return put_route_val(ice, ucontrol->value.enumerated.item[0], analog_route_shift(idx)); } -static int snd_vt1724_pro_route_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_vt1724_pro_route_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); - ucontrol->value.enumerated.item[0] = get_route_val(ice, digital_route_shift(idx)); + ucontrol->value.enumerated.item[0] = + get_route_val(ice, digital_route_shift(idx)); return 0; } -static int snd_vt1724_pro_route_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_vt1724_pro_route_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); return put_route_val(ice, ucontrol->value.enumerated.item[0], digital_route_shift(idx)); } -static snd_kcontrol_new_t snd_vt1724_mixer_pro_analog_route __devinitdata = { +static struct snd_kcontrol_new snd_vt1724_mixer_pro_analog_route __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "H/W Playback Route", .info = snd_vt1724_pro_route_info, @@ -1834,7 +1898,7 @@ static snd_kcontrol_new_t snd_vt1724_mixer_pro_analog_route __devinitdata = { .put = snd_vt1724_pro_route_analog_put, }; -static snd_kcontrol_new_t snd_vt1724_mixer_pro_spdif_route __devinitdata = { +static struct snd_kcontrol_new snd_vt1724_mixer_pro_spdif_route __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", .info = snd_vt1724_pro_route_info, @@ -1844,7 +1908,8 @@ static snd_kcontrol_new_t snd_vt1724_mixer_pro_spdif_route __devinitdata = { }; -static int snd_vt1724_pro_peak_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_vt1724_pro_peak_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 22; /* FIXME: for compatibility with ice1712... */ @@ -1853,21 +1918,23 @@ static int snd_vt1724_pro_peak_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_vt1724_pro_peak_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_vt1724_pro_peak_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx; spin_lock_irq(&ice->reg_lock); for (idx = 0; idx < 22; idx++) { outb(idx, ICEMT1724(ice, MONITOR_PEAKINDEX)); - ucontrol->value.integer.value[idx] = inb(ICEMT1724(ice, MONITOR_PEAKDATA)); + ucontrol->value.integer.value[idx] = + inb(ICEMT1724(ice, MONITOR_PEAKDATA)); } spin_unlock_irq(&ice->reg_lock); return 0; } -static snd_kcontrol_new_t snd_vt1724_mixer_pro_peak __devinitdata = { +static struct snd_kcontrol_new snd_vt1724_mixer_pro_peak __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Multi Track Peak", .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, @@ -1897,7 +1964,7 @@ static struct snd_ice1712_card_info *card_tables[] __devinitdata = { /* */ -static void wait_i2c_busy(ice1712_t *ice) +static void wait_i2c_busy(struct snd_ice1712 *ice) { int t = 0x10000; while ((inb(ICEREG1724(ice, I2C_CTRL)) & VT1724_I2C_BUSY) && t--) @@ -1906,7 +1973,8 @@ static void wait_i2c_busy(ice1712_t *ice) printk(KERN_ERR "ice1724: i2c busy timeout\n"); } -unsigned char snd_vt1724_read_i2c(ice1712_t *ice, unsigned char dev, unsigned char addr) +unsigned char snd_vt1724_read_i2c(struct snd_ice1712 *ice, + unsigned char dev, unsigned char addr) { unsigned char val; @@ -1920,7 +1988,8 @@ unsigned char snd_vt1724_read_i2c(ice1712_t *ice, unsigned char dev, unsigned ch return val; } -void snd_vt1724_write_i2c(ice1712_t *ice, unsigned char dev, unsigned char addr, unsigned char data) +void snd_vt1724_write_i2c(struct snd_ice1712 *ice, + unsigned char dev, unsigned char addr, unsigned char data) { down(&ice->i2c_mutex); wait_i2c_busy(ice); @@ -1932,7 +2001,8 @@ void snd_vt1724_write_i2c(ice1712_t *ice, unsigned char dev, unsigned char addr, up(&ice->i2c_mutex); } -static int __devinit snd_vt1724_read_eeprom(ice1712_t *ice, const char *modelname) +static int __devinit snd_vt1724_read_eeprom(struct snd_ice1712 *ice, + const char *modelname) { const int dev = 0xa0; /* EEPROM device address */ unsigned int i, size; @@ -1946,13 +2016,19 @@ static int __devinit snd_vt1724_read_eeprom(ice1712_t *ice, const char *modelnam (snd_vt1724_read_i2c(ice, dev, 0x01) << 8) | (snd_vt1724_read_i2c(ice, dev, 0x02) << 16) | (snd_vt1724_read_i2c(ice, dev, 0x03) << 24); - if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) { - /* invalid subvendor from EEPROM, try the PCI subststem ID instead */ + if (ice->eeprom.subvendor == 0 || + ice->eeprom.subvendor == (unsigned int)-1) { + /* invalid subvendor from EEPROM, try the PCI + * subststem ID instead + */ u16 vendor, device; - pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID, &vendor); + pci_read_config_word(ice->pci, PCI_SUBSYSTEM_VENDOR_ID, + &vendor); pci_read_config_word(ice->pci, PCI_SUBSYSTEM_ID, &device); - ice->eeprom.subvendor = ((unsigned int)swab16(vendor) << 16) | swab16(device); - if (ice->eeprom.subvendor == 0 || ice->eeprom.subvendor == (unsigned int)-1) { + ice->eeprom.subvendor = + ((unsigned int)swab16(vendor) << 16) | swab16(device); + if (ice->eeprom.subvendor == 0 || + ice->eeprom.subvendor == (unsigned int)-1) { printk(KERN_ERR "ice1724: No valid ID is found\n"); return -ENXIO; } @@ -1960,8 +2036,10 @@ static int __devinit snd_vt1724_read_eeprom(ice1712_t *ice, const char *modelnam } for (tbl = card_tables; *tbl; tbl++) { for (c = *tbl; c->subvendor; c++) { - if (modelname && c->model && ! strcmp(modelname, c->model)) { - printk(KERN_INFO "ice1724: Using board model %s\n", c->name); + if (modelname && c->model && + ! strcmp(modelname, c->model)) { + printk(KERN_INFO "ice1724: Using board model %s\n", + c->name); ice->eeprom.subvendor = c->subvendor; } else if (c->subvendor != ice->eeprom.subvendor) continue; @@ -1975,19 +2053,22 @@ static int __devinit snd_vt1724_read_eeprom(ice1712_t *ice, const char *modelnam goto read_skipped; } } - printk(KERN_WARNING "ice1724: No matching model found for ID 0x%x\n", ice->eeprom.subvendor); + printk(KERN_WARNING "ice1724: No matching model found for ID 0x%x\n", + ice->eeprom.subvendor); found: ice->eeprom.size = snd_vt1724_read_i2c(ice, dev, 0x04); if (ice->eeprom.size < 6) ice->eeprom.size = 32; else if (ice->eeprom.size > 32) { - printk(KERN_ERR "ice1724: Invalid EEPROM (size = %i)\n", ice->eeprom.size); + printk(KERN_ERR "ice1724: Invalid EEPROM (size = %i)\n", + ice->eeprom.size); return -EIO; } ice->eeprom.version = snd_vt1724_read_i2c(ice, dev, 0x05); if (ice->eeprom.version != 2) - printk(KERN_WARNING "ice1724: Invalid EEPROM version %i\n", ice->eeprom.version); + printk(KERN_WARNING "ice1724: Invalid EEPROM version %i\n", + ice->eeprom.version); size = ice->eeprom.size - 6; for (i = 0; i < size; i++) ice->eeprom.data[i] = snd_vt1724_read_i2c(ice, dev, i + 6); @@ -2002,7 +2083,7 @@ static int __devinit snd_vt1724_read_eeprom(ice1712_t *ice, const char *modelnam -static int __devinit snd_vt1724_chip_init(ice1712_t *ice) +static int __devinit snd_vt1724_chip_init(struct snd_ice1712 *ice) { outb(VT1724_RESET , ICEREG1724(ice, CONTROL)); udelay(200); @@ -2024,10 +2105,10 @@ static int __devinit snd_vt1724_chip_init(ice1712_t *ice) return 0; } -static int __devinit snd_vt1724_spdif_build_controls(ice1712_t *ice) +static int __devinit snd_vt1724_spdif_build_controls(struct snd_ice1712 *ice) { int err; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; snd_assert(ice->pcm != NULL, return -EIO); @@ -2062,7 +2143,7 @@ static int __devinit snd_vt1724_spdif_build_controls(ice1712_t *ice) } -static int __devinit snd_vt1724_build_controls(ice1712_t *ice) +static int __devinit snd_vt1724_build_controls(struct snd_ice1712 *ice) { int err; @@ -2081,7 +2162,7 @@ static int __devinit snd_vt1724_build_controls(ice1712_t *ice) return err; if (ice->num_total_dacs > 0) { - snd_kcontrol_new_t tmp = snd_vt1724_mixer_pro_analog_route; + struct snd_kcontrol_new tmp = snd_vt1724_mixer_pro_analog_route; tmp.count = ice->num_total_dacs; if (ice->vt1720 && tmp.count > 2) tmp.count = 2; @@ -2097,7 +2178,7 @@ static int __devinit snd_vt1724_build_controls(ice1712_t *ice) return 0; } -static int snd_vt1724_free(ice1712_t *ice) +static int snd_vt1724_free(struct snd_ice1712 *ice) { if (! ice->port) goto __hw_end; @@ -2108,7 +2189,7 @@ static int snd_vt1724_free(ice1712_t *ice) __hw_end: if (ice->irq >= 0) { synchronize_irq(ice->irq); - free_irq(ice->irq, (void *) ice); + free_irq(ice->irq, ice); } pci_release_regions(ice->pci); snd_ice1712_akm4xxx_free(ice); @@ -2117,21 +2198,21 @@ static int snd_vt1724_free(ice1712_t *ice) return 0; } -static int snd_vt1724_dev_free(snd_device_t *device) +static int snd_vt1724_dev_free(struct snd_device *device) { - ice1712_t *ice = device->device_data; + struct snd_ice1712 *ice = device->device_data; return snd_vt1724_free(ice); } -static int __devinit snd_vt1724_create(snd_card_t * card, +static int __devinit snd_vt1724_create(struct snd_card *card, struct pci_dev *pci, const char *modelname, - ice1712_t ** r_ice1712) + struct snd_ice1712 ** r_ice1712) { - ice1712_t *ice; + struct snd_ice1712 *ice; int err; unsigned char mask; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_vt1724_dev_free, }; @@ -2170,7 +2251,8 @@ static int __devinit snd_vt1724_create(snd_card_t * card, ice->port = pci_resource_start(pci, 0); ice->profi_port = pci_resource_start(pci, 1); - if (request_irq(pci->irq, snd_vt1724_interrupt, SA_INTERRUPT|SA_SHIRQ, "ICE1724", (void *) ice)) { + if (request_irq(pci->irq, snd_vt1724_interrupt, + SA_INTERRUPT|SA_SHIRQ, "ICE1724", ice)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_vt1724_free(ice); return -EIO; @@ -2193,7 +2275,9 @@ static int __devinit snd_vt1724_create(snd_card_t * card, else mask = 0; outb(mask, ICEREG1724(ice, IRQMASK)); - /* don't handle FIFO overrun/underruns (just yet), since they cause machine lockups */ + /* don't handle FIFO overrun/underruns (just yet), + * since they cause machine lockups + */ outb(VT1724_MULTI_FIFO_ERR, ICEMT1724(ice, DMA_INT_MASK)); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, ice, &ops)) < 0) { @@ -2218,8 +2302,8 @@ static int __devinit snd_vt1724_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - ice1712_t *ice; + struct snd_card *card; + struct snd_ice1712 *ice; int pcm_dev = 0, err; struct snd_ice1712_card_info **tbl, *c; diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c index a5e04a3..5176b41 100644 --- a/sound/pci/ice1712/juli.c +++ b/sound/pci/ice1712/juli.c @@ -65,30 +65,30 @@ static void juli_ak4114_write(void *private_data, unsigned char reg, unsigned char val) { - snd_vt1724_write_i2c((ice1712_t *)private_data, AK4114_ADDR, reg, val); + snd_vt1724_write_i2c((struct snd_ice1712 *)private_data, AK4114_ADDR, reg, val); } static unsigned char juli_ak4114_read(void *private_data, unsigned char reg) { - return snd_vt1724_read_i2c((ice1712_t *)private_data, AK4114_ADDR, reg); + return snd_vt1724_read_i2c((struct snd_ice1712 *)private_data, AK4114_ADDR, reg); } /* * AK4358 section */ -static void juli_akm_lock(akm4xxx_t *ak, int chip) +static void juli_akm_lock(struct snd_akm4xxx *ak, int chip) { } -static void juli_akm_unlock(akm4xxx_t *ak, int chip) +static void juli_akm_unlock(struct snd_akm4xxx *ak, int chip) { } -static void juli_akm_write(akm4xxx_t *ak, int chip, +static void juli_akm_write(struct snd_akm4xxx *ak, int chip, unsigned char addr, unsigned char data) { - ice1712_t *ice = ak->private_data[0]; + struct snd_ice1712 *ice = ak->private_data[0]; snd_assert(chip == 0, return); snd_vt1724_write_i2c(ice, AK4358_ADDR, addr, data); @@ -97,7 +97,7 @@ static void juli_akm_write(akm4xxx_t *ak, int chip, /* * change the rate of envy24HT, AK4358 */ -static void juli_akm_set_rate_val(akm4xxx_t *ak, unsigned int rate) +static void juli_akm_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) { unsigned char old, tmp, dfs; @@ -125,7 +125,7 @@ static void juli_akm_set_rate_val(akm4xxx_t *ak, unsigned int rate) snd_akm4xxx_reset(ak, 0); } -static akm4xxx_t akm_juli_dac __devinitdata = { +static struct snd_akm4xxx akm_juli_dac __devinitdata = { .type = SND_AK4358, .num_dacs = 2, .ops = { @@ -136,7 +136,7 @@ static akm4xxx_t akm_juli_dac __devinitdata = { } }; -static int __devinit juli_add_controls(ice1712_t *ice) +static int __devinit juli_add_controls(struct snd_ice1712 *ice) { return snd_ice1712_akm4xxx_build_controls(ice); } @@ -144,7 +144,7 @@ static int __devinit juli_add_controls(ice1712_t *ice) /* * initialize the chip */ -static int __devinit juli_init(ice1712_t *ice) +static int __devinit juli_init(struct snd_ice1712 *ice) { static unsigned char ak4114_init_vals[] = { /* AK4117_REG_PWRDN */ AK4114_RST | AK4114_PWN | AK4114_OCKS0 | AK4114_OCKS1, @@ -158,7 +158,7 @@ static int __devinit juli_init(ice1712_t *ice) 0x41, 0x02, 0x2c, 0x00, 0x00 }; int err; - akm4xxx_t *ak; + struct snd_akm4xxx *ak; #if 0 for (err = 0; err < 0x20; err++) @@ -189,7 +189,7 @@ static int __devinit juli_init(ice1712_t *ice) ice->num_total_dacs = 2; ice->num_total_adcs = 2; - ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ak) return -ENOMEM; ice->akm_codecs = 1; diff --git a/sound/pci/ice1712/phase.c b/sound/pci/ice1712/phase.c index dcf1e8c..ec37578 100644 --- a/sound/pci/ice1712/phase.c +++ b/sound/pci/ice1712/phase.c @@ -86,7 +86,7 @@ static unsigned char wm_vol[256] = { #define WM_VOL_MAX (sizeof(wm_vol) - 1) #define WM_VOL_MUTE 0x8000 -static akm4xxx_t akm_phase22 __devinitdata = { +static struct snd_akm4xxx akm_phase22 __devinitdata = { .type = SND_AK4524, .num_dacs = 2, .num_adcs = 2, @@ -104,9 +104,9 @@ static struct snd_ak4xxx_private akm_phase22_priv __devinitdata = { .mask_flags = 0, }; -static int __devinit phase22_init(ice1712_t *ice) +static int __devinit phase22_init(struct snd_ice1712 *ice) { - akm4xxx_t *ak; + struct snd_akm4xxx *ak; int err; // Configure DAC/ADC description for generic part of ice1724 @@ -122,7 +122,7 @@ static int __devinit phase22_init(ice1712_t *ice) } // Initialize analog chips - ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ak) return -ENOMEM; ice->akm_codecs = 1; @@ -136,7 +136,7 @@ static int __devinit phase22_init(ice1712_t *ice) return 0; } -static int __devinit phase22_add_controls(ice1712_t *ice) +static int __devinit phase22_add_controls(struct snd_ice1712 *ice) { int err = 0; @@ -184,7 +184,7 @@ static unsigned char phase28_eeprom[] __devinitdata = { /* * write data in the SPI mode */ -static void phase28_spi_write(ice1712_t *ice, unsigned int cs, unsigned int data, int bits) +static void phase28_spi_write(struct snd_ice1712 *ice, unsigned int cs, unsigned int data, int bits) { unsigned int tmp; int i; @@ -225,7 +225,7 @@ static void phase28_spi_write(ice1712_t *ice, unsigned int cs, unsigned int data /* * get the current register value of WM codec */ -static unsigned short wm_get(ice1712_t *ice, int reg) +static unsigned short wm_get(struct snd_ice1712 *ice, int reg) { reg <<= 1; return ((unsigned short)ice->akm[0].images[reg] << 8) | @@ -235,7 +235,7 @@ static unsigned short wm_get(ice1712_t *ice, int reg) /* * set the register value of WM codec */ -static void wm_put_nocache(ice1712_t *ice, int reg, unsigned short val) +static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val) { phase28_spi_write(ice, PHASE28_WM_CS, (reg << 9) | (val & 0x1ff), 16); } @@ -243,7 +243,7 @@ static void wm_put_nocache(ice1712_t *ice, int reg, unsigned short val) /* * set the register value of WM codec and remember it */ -static void wm_put(ice1712_t *ice, int reg, unsigned short val) +static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val) { wm_put_nocache(ice, reg, val); reg <<= 1; @@ -251,7 +251,7 @@ static void wm_put(ice1712_t *ice, int reg, unsigned short val) ice->akm[0].images[reg + 1] = val; } -static void wm_set_vol(ice1712_t *ice, unsigned int index, unsigned short vol, unsigned short master) +static void wm_set_vol(struct snd_ice1712 *ice, unsigned int index, unsigned short vol, unsigned short master) { unsigned char nvol; @@ -269,9 +269,9 @@ static void wm_set_vol(ice1712_t *ice, unsigned int index, unsigned short vol, u */ #define wm_pcm_mute_info phase28_mono_bool_info -static int wm_pcm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_pcm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); ucontrol->value.integer.value[0] = (wm_get(ice, WM_MUTE) & 0x10) ? 0 : 1; @@ -279,9 +279,9 @@ static int wm_pcm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int wm_pcm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int wm_pcm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short nval, oval; int change; @@ -298,7 +298,7 @@ static int wm_pcm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uco /* * Master volume attenuation mixer control */ -static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_master_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -307,18 +307,18 @@ static int wm_master_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uin return 0; } -static int wm_master_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_master_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i; for (i=0; i<2; i++) ucontrol->value.integer.value[i] = ice->spec.phase28.master[i] & ~WM_VOL_MUTE; return 0; } -static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_master_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int ch, change = 0; snd_ice1712_save_gpio_status(ice); @@ -338,7 +338,7 @@ static int wm_master_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return change; } -static int __devinit phase28_init(ice1712_t *ice) +static int __devinit phase28_init(struct snd_ice1712 *ice) { static unsigned short wm_inits_phase28[] = { /* These come first to reduce init pop noise */ @@ -378,7 +378,7 @@ static int __devinit phase28_init(ice1712_t *ice) }; unsigned int tmp; - akm4xxx_t *ak; + struct snd_akm4xxx *ak; unsigned short *p; int i; @@ -386,7 +386,7 @@ static int __devinit phase28_init(ice1712_t *ice) ice->num_total_adcs = 2; // Initialize analog chips - ak = ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); if (!ak) return -ENOMEM; ice->akm_codecs = 1; @@ -427,7 +427,7 @@ static int __devinit phase28_init(ice1712_t *ice) /* * DAC volume attenuation mixer control */ -static int wm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int voices = kcontrol->private_value >> 8; uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -437,9 +437,9 @@ static int wm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, ofs, voices; voices = kcontrol->private_value >> 8; @@ -449,9 +449,9 @@ static int wm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) return 0; } -static int wm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, idx, ofs, voices; int change = 0; @@ -475,7 +475,7 @@ static int wm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) /* * WM8770 mute control */ -static int wm_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { +static int wm_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = kcontrol->private_value >> 8; uinfo->value.integer.min = 0; @@ -483,9 +483,9 @@ static int wm_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { return 0; } -static int wm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int voices, ofs, i; voices = kcontrol->private_value >> 8; @@ -496,9 +496,9 @@ static int wm_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) return 0; } -static int wm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int wm_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change = 0, voices, ofs, i; voices = kcontrol->private_value >> 8; @@ -524,7 +524,7 @@ static int wm_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontro /* * WM8770 master mute control */ -static int wm_master_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { +static int wm_master_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; uinfo->value.integer.min = 0; @@ -532,18 +532,18 @@ static int wm_master_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *ui return 0; } -static int wm_master_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_master_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (ice->spec.phase28.master[0] & WM_VOL_MUTE) ? 0 : 1; ucontrol->value.integer.value[1] = (ice->spec.phase28.master[1] & WM_VOL_MUTE) ? 0 : 1; return 0; } -static int wm_master_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int wm_master_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int change = 0, i; snd_ice1712_save_gpio_status(ice); @@ -570,7 +570,7 @@ static int wm_master_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * #define PCM_0dB 0xff #define PCM_RES 128 /* -64dB */ #define PCM_MIN (PCM_0dB - PCM_RES) -static int wm_pcm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_pcm_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -579,9 +579,9 @@ static int wm_pcm_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val; down(&ice->gpio_mutex); @@ -592,9 +592,9 @@ static int wm_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -static int wm_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short ovol, nvol; int change = 0; @@ -613,7 +613,7 @@ static int wm_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr /* */ -static int phase28_mono_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) +static int phase28_mono_bool_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -627,16 +627,16 @@ static int phase28_mono_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) */ #define phase28_deemp_info phase28_mono_bool_info -static int phase28_deemp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int phase28_deemp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf; return 0; } -static int phase28_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int phase28_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int temp, temp2; temp2 = temp = wm_get(ice, WM_DAC_CTRL2); if (ucontrol->value.integer.value[0]) @@ -653,7 +653,7 @@ static int phase28_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco /* * ADC Oversampling */ -static int phase28_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) +static int phase28_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "128x", "64x" }; @@ -668,17 +668,17 @@ static int phase28_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uin return 0; } -static int phase28_oversampling_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int phase28_oversampling_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8; return 0; } -static int phase28_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int phase28_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int temp, temp2; - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); temp2 = temp = wm_get(ice, WM_MASTER); @@ -694,7 +694,7 @@ static int phase28_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value return 0; } -static snd_kcontrol_new_t phase28_dac_controls[] __devinitdata = { +static struct snd_kcontrol_new phase28_dac_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", @@ -791,7 +791,7 @@ static snd_kcontrol_new_t phase28_dac_controls[] __devinitdata = { } }; -static snd_kcontrol_new_t wm_controls[] __devinitdata = { +static struct snd_kcontrol_new wm_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Switch", @@ -822,7 +822,7 @@ static snd_kcontrol_new_t wm_controls[] __devinitdata = { } }; -static int __devinit phase28_add_controls(ice1712_t *ice) +static int __devinit phase28_add_controls(struct snd_ice1712 *ice) { unsigned int i, counts; int err; diff --git a/sound/pci/ice1712/pontis.c b/sound/pci/ice1712/pontis.c index 773a1ec..0dccd77 100644 --- a/sound/pci/ice1712/pontis.c +++ b/sound/pci/ice1712/pontis.c @@ -76,7 +76,7 @@ /* * get the current register value of WM codec */ -static unsigned short wm_get(ice1712_t *ice, int reg) +static unsigned short wm_get(struct snd_ice1712 *ice, int reg) { reg <<= 1; return ((unsigned short)ice->akm[0].images[reg] << 8) | @@ -86,14 +86,14 @@ static unsigned short wm_get(ice1712_t *ice, int reg) /* * set the register value of WM codec and remember it */ -static void wm_put_nocache(ice1712_t *ice, int reg, unsigned short val) +static void wm_put_nocache(struct snd_ice1712 *ice, int reg, unsigned short val) { unsigned short cval; cval = (reg << 9) | val; snd_vt1724_write_i2c(ice, WM_DEV, cval >> 8, cval & 0xff); } -static void wm_put(ice1712_t *ice, int reg, unsigned short val) +static void wm_put(struct snd_ice1712 *ice, int reg, unsigned short val) { wm_put_nocache(ice, reg, val); reg <<= 1; @@ -109,7 +109,7 @@ static void wm_put(ice1712_t *ice, int reg, unsigned short val) #define DAC_RES 128 #define DAC_MIN (DAC_0dB - DAC_RES) -static int wm_dac_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_dac_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -118,9 +118,9 @@ static int wm_dac_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_dac_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_dac_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val; int i; @@ -134,9 +134,9 @@ static int wm_dac_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -static int wm_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short oval, nval; int i, idx, change = 0; @@ -164,7 +164,7 @@ static int wm_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr #define ADC_RES 128 #define ADC_MIN (ADC_0dB - ADC_RES) -static int wm_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_adc_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -173,9 +173,9 @@ static int wm_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val; int i; @@ -189,9 +189,9 @@ static int wm_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short ovol, nvol; int i, idx, change = 0; @@ -213,7 +213,7 @@ static int wm_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr /* * ADC input mux mixer control */ -static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_adc_mux_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -222,9 +222,9 @@ static int wm_adc_mux_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_adc_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_mux_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int bit = kcontrol->private_value; down(&ice->gpio_mutex); @@ -233,9 +233,9 @@ static int wm_adc_mux_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int wm_adc_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_adc_mux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int bit = kcontrol->private_value; unsigned short oval, nval; int change; @@ -257,7 +257,7 @@ static int wm_adc_mux_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucont /* * Analog bypass (In -> Out) */ -static int wm_bypass_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_bypass_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -266,9 +266,9 @@ static int wm_bypass_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_bypass_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_bypass_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); ucontrol->value.integer.value[0] = (wm_get(ice, WM_OUT_MUX) & 0x04) ? 1 : 0; @@ -276,9 +276,9 @@ static int wm_bypass_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -static int wm_bypass_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_bypass_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val, oval; int change = 0; @@ -299,7 +299,7 @@ static int wm_bypass_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontr /* * Left/Right swap */ -static int wm_chswap_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int wm_chswap_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -308,9 +308,9 @@ static int wm_chswap_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int wm_chswap_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_chswap_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL1) & 0xf0) != 0x90; @@ -318,9 +318,9 @@ static int wm_chswap_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -static int wm_chswap_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int wm_chswap_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned short val, oval; int change = 0; @@ -343,7 +343,7 @@ static int wm_chswap_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontr /* * write data in the SPI mode */ -static void set_gpio_bit(ice1712_t *ice, unsigned int bit, int val) +static void set_gpio_bit(struct snd_ice1712 *ice, unsigned int bit, int val) { unsigned int tmp = snd_ice1712_gpio_read(ice); if (val) @@ -353,7 +353,7 @@ static void set_gpio_bit(ice1712_t *ice, unsigned int bit, int val) snd_ice1712_gpio_write(ice, tmp); } -static void spi_send_byte(ice1712_t *ice, unsigned char data) +static void spi_send_byte(struct snd_ice1712 *ice, unsigned char data) { int i; for (i = 0; i < 8; i++) { @@ -367,7 +367,7 @@ static void spi_send_byte(ice1712_t *ice, unsigned char data) } } -static unsigned int spi_read_byte(ice1712_t *ice) +static unsigned int spi_read_byte(struct snd_ice1712 *ice) { int i; unsigned int val = 0; @@ -386,7 +386,7 @@ static unsigned int spi_read_byte(ice1712_t *ice) } -static void spi_write(ice1712_t *ice, unsigned int dev, unsigned int reg, unsigned int data) +static void spi_write(struct snd_ice1712 *ice, unsigned int dev, unsigned int reg, unsigned int data) { snd_ice1712_gpio_set_dir(ice, PONTIS_CS_CS|PONTIS_CS_WDATA|PONTIS_CS_CLK); snd_ice1712_gpio_set_mask(ice, ~(PONTIS_CS_CS|PONTIS_CS_WDATA|PONTIS_CS_CLK)); @@ -402,7 +402,7 @@ static void spi_write(ice1712_t *ice, unsigned int dev, unsigned int reg, unsign snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); } -static unsigned int spi_read(ice1712_t *ice, unsigned int dev, unsigned int reg) +static unsigned int spi_read(struct snd_ice1712 *ice, unsigned int dev, unsigned int reg) { unsigned int val; snd_ice1712_gpio_set_dir(ice, PONTIS_CS_CS|PONTIS_CS_WDATA|PONTIS_CS_CLK); @@ -429,7 +429,7 @@ static unsigned int spi_read(ice1712_t *ice, unsigned int dev, unsigned int reg) /* * SPDIF input source */ -static int cs_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int cs_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[] = { "Coax", /* RXP0 */ @@ -445,9 +445,9 @@ static int cs_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int cs_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int cs_source_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); ucontrol->value.enumerated.item[0] = ice->gpio.saved[0]; @@ -455,9 +455,9 @@ static int cs_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontro return 0; } -static int cs_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int cs_source_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char val; int change = 0; @@ -476,7 +476,7 @@ static int cs_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontro /* * GPIO controls */ -static int pontis_gpio_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int pontis_gpio_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -485,9 +485,9 @@ static int pontis_gpio_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int pontis_gpio_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pontis_gpio_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); /* 4-7 reserved */ ucontrol->value.integer.value[0] = (~ice->gpio.write_mask & 0xffff) | 0x00f0; @@ -495,9 +495,9 @@ static int pontis_gpio_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int pontis_gpio_mask_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pontis_gpio_mask_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned int val; int changed; down(&ice->gpio_mutex); @@ -509,9 +509,9 @@ static int pontis_gpio_mask_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return changed; } -static int pontis_gpio_dir_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pontis_gpio_dir_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); /* 4-7 reserved */ ucontrol->value.integer.value[0] = ice->gpio.direction & 0xff0f; @@ -519,9 +519,9 @@ static int pontis_gpio_dir_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int pontis_gpio_dir_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pontis_gpio_dir_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned int val; int changed; down(&ice->gpio_mutex); @@ -533,9 +533,9 @@ static int pontis_gpio_dir_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return changed; } -static int pontis_gpio_data_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pontis_gpio_data_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); down(&ice->gpio_mutex); snd_ice1712_gpio_set_dir(ice, ice->gpio.direction); snd_ice1712_gpio_set_mask(ice, ice->gpio.write_mask); @@ -544,9 +544,9 @@ static int pontis_gpio_data_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int pontis_gpio_data_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pontis_gpio_data_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned int val, nval; int changed = 0; down(&ice->gpio_mutex); @@ -566,7 +566,7 @@ static int pontis_gpio_data_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * * mixers */ -static snd_kcontrol_new_t pontis_controls[] __devinitdata = { +static struct snd_kcontrol_new pontis_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Playback Volume", @@ -646,9 +646,9 @@ static snd_kcontrol_new_t pontis_controls[] __devinitdata = { /* * WM codec registers */ -static void wm_proc_regs_write(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void wm_proc_regs_write(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - ice1712_t *ice = (ice1712_t *)entry->private_data; + struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; char line[64]; unsigned int reg, val; down(&ice->gpio_mutex); @@ -661,9 +661,9 @@ static void wm_proc_regs_write(snd_info_entry_t *entry, snd_info_buffer_t *buffe up(&ice->gpio_mutex); } -static void wm_proc_regs_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void wm_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - ice1712_t *ice = (ice1712_t *)entry->private_data; + struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; int reg, val; down(&ice->gpio_mutex); @@ -674,9 +674,9 @@ static void wm_proc_regs_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer up(&ice->gpio_mutex); } -static void wm_proc_init(ice1712_t *ice) +static void wm_proc_init(struct snd_ice1712 *ice) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(ice->card, "wm_codec", &entry)) { snd_info_set_text_ops(entry, ice, 1024, wm_proc_regs_read); entry->mode |= S_IWUSR; @@ -685,9 +685,9 @@ static void wm_proc_init(ice1712_t *ice) } } -static void cs_proc_regs_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void cs_proc_regs_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - ice1712_t *ice = (ice1712_t *)entry->private_data; + struct snd_ice1712 *ice = (struct snd_ice1712 *)entry->private_data; int reg, val; down(&ice->gpio_mutex); @@ -700,16 +700,16 @@ static void cs_proc_regs_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer up(&ice->gpio_mutex); } -static void cs_proc_init(ice1712_t *ice) +static void cs_proc_init(struct snd_ice1712 *ice) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(ice->card, "cs_codec", &entry)) { snd_info_set_text_ops(entry, ice, 1024, cs_proc_regs_read); } } -static int __devinit pontis_add_controls(ice1712_t *ice) +static int __devinit pontis_add_controls(struct snd_ice1712 *ice) { unsigned int i; int err; @@ -730,7 +730,7 @@ static int __devinit pontis_add_controls(ice1712_t *ice) /* * initialize the chip */ -static int __devinit pontis_init(ice1712_t *ice) +static int __devinit pontis_init(struct snd_ice1712 *ice) { static unsigned short wm_inits[] = { /* These come first to reduce init pop noise */ @@ -781,7 +781,7 @@ static int __devinit pontis_init(ice1712_t *ice) ice->num_total_adcs = 2; /* to remeber the register values */ - ice->akm = kzalloc(sizeof(akm4xxx_t), GFP_KERNEL); + ice->akm = kzalloc(sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ice->akm) return -ENOMEM; ice->akm_codecs = 1; diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c index d2c5963..fdb5cb8 100644 --- a/sound/pci/ice1712/prodigy192.c +++ b/sound/pci/ice1712/prodigy192.c @@ -36,12 +36,12 @@ #include "prodigy192.h" #include "stac946x.h" -static inline void stac9460_put(ice1712_t *ice, int reg, unsigned char val) +static inline void stac9460_put(struct snd_ice1712 *ice, int reg, unsigned char val) { snd_vt1724_write_i2c(ice, PRODIGY192_STAC9460_ADDR, reg, val); } -static inline unsigned char stac9460_get(ice1712_t *ice, int reg) +static inline unsigned char stac9460_get(struct snd_ice1712 *ice, int reg) { return snd_vt1724_read_i2c(ice, PRODIGY192_STAC9460_ADDR, reg); } @@ -49,7 +49,7 @@ static inline unsigned char stac9460_get(ice1712_t *ice, int reg) /* * DAC mute control */ -static int stac9460_dac_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int stac9460_dac_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -58,9 +58,9 @@ static int stac9460_dac_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int stac9460_dac_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac9460_dac_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char val; int idx; @@ -73,9 +73,9 @@ static int stac9460_dac_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int stac9460_dac_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int stac9460_dac_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char new, old; int idx; int change; @@ -96,7 +96,7 @@ static int stac9460_dac_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t /* * DAC volume attenuation mixer control */ -static int stac9460_dac_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int stac9460_dac_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -105,9 +105,9 @@ static int stac9460_dac_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int stac9460_dac_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac9460_dac_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx; unsigned char vol; @@ -121,9 +121,9 @@ static int stac9460_dac_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int stac9460_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac9460_dac_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int idx; unsigned char tmp, ovol, nvol; int change; @@ -145,7 +145,7 @@ static int stac9460_dac_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * /* * ADC mute control */ -static int stac9460_adc_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int stac9460_adc_mute_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -154,9 +154,9 @@ static int stac9460_adc_mute_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int stac9460_adc_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac9460_adc_mute_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char val; int i; @@ -168,9 +168,9 @@ static int stac9460_adc_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int stac9460_adc_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int stac9460_adc_mute_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); unsigned char new, old; int i, reg; int change; @@ -190,7 +190,7 @@ static int stac9460_adc_mute_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t /* * ADC gain mixer control */ -static int stac9460_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int stac9460_adc_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -199,9 +199,9 @@ static int stac9460_adc_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int stac9460_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac9460_adc_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, reg; unsigned char vol; @@ -214,9 +214,9 @@ static int stac9460_adc_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * return 0; } -static int stac9460_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int stac9460_adc_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int i, reg; unsigned char ovol, nvol; int change; @@ -237,7 +237,7 @@ static int stac9460_adc_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t * /* * Headphone Amplifier */ -static int aureon_set_headphone_amp(ice1712_t *ice, int enable) +static int aureon_set_headphone_amp(struct snd_ice1712 *ice, int enable) { unsigned int tmp, tmp2; @@ -253,14 +253,14 @@ static int aureon_set_headphone_amp(ice1712_t *ice, int enable) return 0; } -static int aureon_get_headphone_amp(ice1712_t *ice) +static int aureon_get_headphone_amp(struct snd_ice1712 *ice) { unsigned int tmp = snd_ice1712_gpio_read(ice); return ( tmp & AUREON_HP_SEL )!= 0; } -static int aureon_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) +static int aureon_bool_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -269,18 +269,18 @@ static int aureon_bool_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) return 0; } -static int aureon_hpamp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_hpamp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = aureon_get_headphone_amp(ice); return 0; } -static int aureon_hpamp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_hpamp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); return aureon_set_headphone_amp(ice,ucontrol->value.integer.value[0]); } @@ -288,16 +288,16 @@ static int aureon_hpamp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon /* * Deemphasis */ -static int aureon_deemp_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_deemp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = (wm_get(ice, WM_DAC_CTRL2) & 0xf) == 0xf; return 0; } -static int aureon_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_deemp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); int temp, temp2; temp2 = temp = wm_get(ice, WM_DAC_CTRL2); if (ucontrol->value.integer.value[0]) @@ -314,7 +314,7 @@ static int aureon_deemp_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucon /* * ADC Oversampling */ -static int aureon_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinfo) +static int aureon_oversampling_info(struct snd_kcontrol *k, struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "128x", "64x" }; @@ -329,17 +329,17 @@ static int aureon_oversampling_info(snd_kcontrol_t *k, snd_ctl_elem_info_t *uinf return 0; } -static int aureon_oversampling_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_oversampling_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = (wm_get(ice, WM_MASTER) & 0x8) == 0x8; return 0; } -static int aureon_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int aureon_oversampling_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int temp, temp2; - ice1712_t *ice = snd_kcontrol_chip(kcontrol); + struct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol); temp2 = temp = wm_get(ice, WM_MASTER); @@ -360,7 +360,7 @@ static int aureon_oversampling_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ * mixers */ -static snd_kcontrol_new_t stac_controls[] __devinitdata = { +static struct snd_kcontrol_new stac_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", @@ -442,7 +442,7 @@ static snd_kcontrol_new_t stac_controls[] __devinitdata = { #endif }; -static int __devinit prodigy192_add_controls(ice1712_t *ice) +static int __devinit prodigy192_add_controls(struct snd_ice1712 *ice) { unsigned int i; int err; @@ -459,7 +459,7 @@ static int __devinit prodigy192_add_controls(ice1712_t *ice) /* * initialize the chip */ -static int __devinit prodigy192_init(ice1712_t *ice) +static int __devinit prodigy192_init(struct snd_ice1712 *ice) { static unsigned short stac_inits_prodigy[] = { STAC946X_RESET, 0, diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c index 1fe2100..664b738 100644 --- a/sound/pci/ice1712/revo.c +++ b/sound/pci/ice1712/revo.c @@ -33,7 +33,7 @@ #include "envy24ht.h" #include "revo.h" -static void revo_i2s_mclk_changed(ice1712_t *ice) +static void revo_i2s_mclk_changed(struct snd_ice1712 *ice) { /* assert PRST# to converters; MT05 bit 7 */ outb(inb(ICEMT1724(ice, AC97_CMD)) | 0x80, ICEMT1724(ice, AC97_CMD)); @@ -45,7 +45,7 @@ static void revo_i2s_mclk_changed(ice1712_t *ice) /* * change the rate of envy24HT, AK4355 and AK4381 */ -static void revo_set_rate_val(akm4xxx_t *ak, unsigned int rate) +static void revo_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) { unsigned char old, tmp, dfs; int reg, shift; @@ -87,7 +87,7 @@ static void revo_set_rate_val(akm4xxx_t *ak, unsigned int rate) * initialize the chips on M-Audio Revolution cards */ -static akm4xxx_t akm_revo_front __devinitdata = { +static struct snd_akm4xxx akm_revo_front __devinitdata = { .type = SND_AK4381, .num_dacs = 2, .ops = { @@ -107,7 +107,7 @@ static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { .mask_flags = 0, }; -static akm4xxx_t akm_revo_surround __devinitdata = { +static struct snd_akm4xxx akm_revo_surround __devinitdata = { .type = SND_AK4355, .idx_offset = 1, .num_dacs = 6, @@ -128,9 +128,9 @@ static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { .mask_flags = 0, }; -static int __devinit revo_init(ice1712_t *ice) +static int __devinit revo_init(struct snd_ice1712 *ice) { - akm4xxx_t *ak; + struct snd_akm4xxx *ak; int err; /* determine I2C, DACs and ADCs */ @@ -147,7 +147,7 @@ static int __devinit revo_init(ice1712_t *ice) ice->gpio.i2s_mclk_changed = revo_i2s_mclk_changed; /* second stage of initialization, analog parts and others */ - ak = ice->akm = kcalloc(2, sizeof(akm4xxx_t), GFP_KERNEL); + ak = ice->akm = kcalloc(2, sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ak) return -ENOMEM; ice->akm_codecs = 2; @@ -166,7 +166,7 @@ static int __devinit revo_init(ice1712_t *ice) } -static int __devinit revo_add_controls(ice1712_t *ice) +static int __devinit revo_add_controls(struct snd_ice1712 *ice) { int err; diff --git a/sound/pci/ice1712/vt1720_mobo.c b/sound/pci/ice1712/vt1720_mobo.c index 90c85cd..7ca263c1 100644 --- a/sound/pci/ice1712/vt1720_mobo.c +++ b/sound/pci/ice1712/vt1720_mobo.c @@ -33,7 +33,7 @@ #include "vt1720_mobo.h" -static int __devinit k8x800_init(ice1712_t *ice) +static int __devinit k8x800_init(struct snd_ice1712 *ice) { ice->vt1720 = 1; @@ -47,7 +47,7 @@ static int __devinit k8x800_init(ice1712_t *ice) return 0; } -static int __devinit k8x800_add_controls(ice1712_t *ice) +static int __devinit k8x800_add_controls(struct snd_ice1712 *ice) { /* FIXME: needs some quirks for VT1616? */ return 0; -- cgit v1.1 From fcfd3332e3bf5f63116044c168110820996cd1fe Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:00:46 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI KORG1212 Modules: KORG1212 driver Remove xxx_t typedefs from the PCI KORG1212 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/korg1212/korg1212.c | 384 +++++++++++++++++++++--------------------- 1 file changed, 196 insertions(+), 188 deletions(-) diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index ec71613..a8a6a5c 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -61,7 +61,7 @@ // ---------------------------------------------------------------------------- // Valid states of the Korg 1212 I/O card. // ---------------------------------------------------------------------------- -typedef enum { +enum CardState { K1212_STATE_NONEXISTENT, // there is no card here K1212_STATE_UNINITIALIZED, // the card is awaiting DSP download K1212_STATE_DSP_IN_PROCESS, // the card is currently downloading its DSP code @@ -77,13 +77,13 @@ typedef enum { K1212_STATE_ERRORSTOP, // the card has stopped itself because of an error and we // are in the process of cleaning things up. K1212_STATE_MAX_STATE // state values of this and beyond are invalid -} CardState; +}; // ---------------------------------------------------------------------------- // The following enumeration defines the constants written to the card's // host-to-card doorbell to initiate a command. // ---------------------------------------------------------------------------- -typedef enum { +enum korg1212_dbcnst { K1212_DB_RequestForData = 0, // sent by the card to request a buffer fill. K1212_DB_TriggerPlay = 1, // starts playback/record on the card. K1212_DB_SelectPlayMode = 2, // select monitor, playback setup, or stop. @@ -101,14 +101,14 @@ typedef enum { K1212_DB_DSPDownloadDone = 0xAE, // sent by the card to indicate the download has // completed. K1212_DB_StartDSPDownload = 0xAF // tells the card to download its DSP firmware. -} korg1212_dbcnst_t; +}; // ---------------------------------------------------------------------------- // The following enumeration defines return codes // to the Korg 1212 I/O driver. // ---------------------------------------------------------------------------- -typedef enum { +enum snd_korg1212rc { K1212_CMDRET_Success = 0, // command was successfully placed K1212_CMDRET_DIOCFailure, // the DeviceIoControl call failed K1212_CMDRET_PMFailure, // the protected mode call failed @@ -126,27 +126,27 @@ typedef enum { K1212_CMDRET_BadDevice, // the specified wave device was out of range K1212_CMDRET_BadFormat // the specified wave format is unsupported -} snd_korg1212rc; +}; // ---------------------------------------------------------------------------- // The following enumeration defines the constants used to select the play // mode for the card in the SelectPlayMode command. // ---------------------------------------------------------------------------- -typedef enum { +enum PlayModeSelector { K1212_MODE_SetupPlay = 0x00000001, // provides card with pre-play information K1212_MODE_MonitorOn = 0x00000002, // tells card to turn on monitor mode K1212_MODE_MonitorOff = 0x00000004, // tells card to turn off monitor mode K1212_MODE_StopPlay = 0x00000008 // stops playback on the card -} PlayModeSelector; +}; // ---------------------------------------------------------------------------- // The following enumeration defines the constants used to select the monitor // mode for the card in the SetMonitorMode command. // ---------------------------------------------------------------------------- -typedef enum { +enum MonitorModeSelector { K1212_MONMODE_Off = 0, // tells card to turn off monitor mode K1212_MONMODE_On // tells card to turn on monitor mode -} MonitorModeSelector; +}; #define MAILBOX0_OFFSET 0x40 // location of mailbox 0 relative to base address #define MAILBOX1_OFFSET 0x44 // location of mailbox 1 relative to base address @@ -188,7 +188,7 @@ typedef enum { #define K1212_CHANNELS (K1212_ADAT_CHANNELS + K1212_ANALOG_CHANNELS) #define K1212_MIN_CHANNELS 1 #define K1212_MAX_CHANNELS K1212_CHANNELS -#define K1212_FRAME_SIZE (sizeof(KorgAudioFrame)) +#define K1212_FRAME_SIZE (sizeof(struct KorgAudioFrame)) #define K1212_MAX_SAMPLES (kPlayBufferFrames*kNumBuffers) #define K1212_PERIODS (kNumBuffers) #define K1212_PERIOD_BYTES (K1212_FRAME_SIZE*kPlayBufferFrames) @@ -264,14 +264,7 @@ typedef enum { #include "korg1212-firmware.h" -typedef struct _snd_korg1212 korg1212_t; - -typedef u16 K1212Sample; // channels 0-9 use 16 bit samples -typedef u32 K1212SpdifSample; // channels 10-11 use 32 bits - only 20 are sent - // across S/PDIF. -typedef u32 K1212TimeCodeSample; // holds the ADAT timecode value - -typedef enum { +enum ClockSourceIndex { K1212_CLKIDX_AdatAt44_1K = 0, // selects source as ADAT at 44.1 kHz K1212_CLKIDX_AdatAt48K, // selects source as ADAT at 48 kHz K1212_CLKIDX_WordAt44_1K, // selects source as S/PDIF at 44.1 kHz @@ -279,36 +272,36 @@ typedef enum { K1212_CLKIDX_LocalAt44_1K, // selects source as local clock at 44.1 kHz K1212_CLKIDX_LocalAt48K, // selects source as local clock at 48 kHz K1212_CLKIDX_Invalid // used to check validity of the index -} ClockSourceIndex; +}; -typedef enum { +enum ClockSourceType { K1212_CLKIDX_Adat = 0, // selects source as ADAT K1212_CLKIDX_Word, // selects source as S/PDIF K1212_CLKIDX_Local // selects source as local clock -} ClockSourceType; +}; -typedef struct KorgAudioFrame { - K1212Sample frameData16[k16BitChannels]; - K1212SpdifSample frameData32[k32BitChannels]; - K1212TimeCodeSample timeCodeVal; -} KorgAudioFrame; +struct KorgAudioFrame { + u16 frameData16[k16BitChannels]; /* channels 0-9 use 16 bit samples */ + u32 frameData32[k32BitChannels]; /* channels 10-11 use 32 bits - only 20 are sent across S/PDIF */ + u32 timeCodeVal; /* holds the ADAT timecode value */ +}; -typedef struct KorgAudioBuffer { - KorgAudioFrame bufferData[kPlayBufferFrames]; /* buffer definition */ -} KorgAudioBuffer; +struct KorgAudioBuffer { + struct KorgAudioFrame bufferData[kPlayBufferFrames]; /* buffer definition */ +}; -typedef struct KorgSharedBuffer { +struct KorgSharedBuffer { #ifdef K1212_LARGEALLOC - KorgAudioBuffer playDataBufs[kNumBuffers]; - KorgAudioBuffer recordDataBufs[kNumBuffers]; + struct KorgAudioBuffer playDataBufs[kNumBuffers]; + struct KorgAudioBuffer recordDataBufs[kNumBuffers]; #endif short volumeData[kAudioChannels]; u32 cardCommand; u16 routeData [kAudioChannels]; u32 AdatTimeCode; // ADAT timecode value -} KorgSharedBuffer; +}; -typedef struct SensBits { +struct SensBits { union { struct { unsigned int leftChanVal:8; @@ -323,12 +316,12 @@ typedef struct SensBits { } v; u16 rightSensBits; } r; -} SensBits; +}; -struct _snd_korg1212 { - snd_card_t *card; +struct snd_korg1212 { + struct snd_card *card; struct pci_dev *pci; - snd_pcm_t *pcm; + struct snd_pcm *pcm; int irq; spinlock_t lock; @@ -355,10 +348,10 @@ struct _snd_korg1212 { u32 DataBufsSize; - KorgAudioBuffer * playDataBufsPtr; - KorgAudioBuffer * recordDataBufsPtr; + struct KorgAudioBuffer * playDataBufsPtr; + struct KorgAudioBuffer * recordDataBufsPtr; - KorgSharedBuffer * sharedBufferPtr; + struct KorgSharedBuffer * sharedBufferPtr; u32 RecDataPhy; u32 PlayDataPhy; @@ -382,20 +375,20 @@ struct _snd_korg1212 { int channels; int currentBuffer; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; pid_t capture_pid; pid_t playback_pid; - CardState cardState; + enum CardState cardState; int running; int idleMonitorOn; // indicates whether the card is in idle monitor mode. u32 cmdRetryCount; // tracks how many times we have retried sending to the card. - ClockSourceIndex clkSrcRate; // sample rate and clock source + enum ClockSourceIndex clkSrcRate; // sample rate and clock source - ClockSourceType clkSource; // clock source + enum ClockSourceType clkSource; // clock source int clkRate; // clock rate int volumePhase[kAudioChannels]; @@ -440,6 +433,8 @@ static struct pci_device_id snd_korg1212_ids[] = { { 0, }, }; +MODULE_DEVICE_TABLE(pci, snd_korg1212_ids); + static char *stateName[] = { "Non-existent", "Uninitialized", @@ -489,11 +484,7 @@ static u16 ClockSourceSelector[] = { 0x0002 // selects source as local clock at 48 kHz }; -static snd_korg1212rc rc; - -MODULE_DEVICE_TABLE(pci, snd_korg1212_ids); - -typedef union swap_u32 { unsigned char c[4]; u32 i; } swap_u32; +union swap_u32 { unsigned char c[4]; u32 i; }; #ifdef SNDRV_BIG_ENDIAN static u32 LowerWordSwap(u32 swappee) @@ -501,7 +492,7 @@ static u32 LowerWordSwap(u32 swappee) static u32 UpperWordSwap(u32 swappee) #endif { - swap_u32 retVal, swapper; + union swap_u32 retVal, swapper; swapper.i = swappee; retVal.c[2] = swapper.c[3]; @@ -518,7 +509,7 @@ static u32 UpperWordSwap(u32 swappee) static u32 LowerWordSwap(u32 swappee) #endif { - swap_u32 retVal, swapper; + union swap_u32 retVal, swapper; swapper.i = swappee; retVal.c[2] = swapper.c[2]; @@ -534,12 +525,14 @@ static u32 LowerWordSwap(u32 swappee) #define ClearBitInWord(theWord,bitPosition) (*theWord) &= ~(0x0001 << bitPosition) #define ClearBitInDWord(theWord,bitPosition) (*theWord) &= ~(0x00000001 << bitPosition) -static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg1212_dbcnst_t doorbellVal, - u32 mailBox0Val, u32 mailBox1Val, u32 mailBox2Val, u32 mailBox3Val) +static int snd_korg1212_Send1212Command(struct snd_korg1212 *korg1212, + enum korg1212_dbcnst doorbellVal, + u32 mailBox0Val, u32 mailBox1Val, + u32 mailBox2Val, u32 mailBox3Val) { u32 retryCount; u16 mailBox3Lo; - snd_korg1212rc rc = K1212_CMDRET_Success; + int rc = K1212_CMDRET_Success; if (!korg1212->outDoorbellPtr) { K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: CardUninitialized\n"); @@ -591,7 +584,7 @@ static snd_korg1212rc snd_korg1212_Send1212Command(korg1212_t *korg1212, korg121 } /* spinlock already held */ -static void snd_korg1212_SendStop(korg1212_t *korg1212) +static void snd_korg1212_SendStop(struct snd_korg1212 *korg1212) { if (! korg1212->stop_pending_cnt) { korg1212->sharedBufferPtr->cardCommand = 0xffffffff; @@ -602,7 +595,7 @@ static void snd_korg1212_SendStop(korg1212_t *korg1212) } } -static void snd_korg1212_SendStopAndWait(korg1212_t *korg1212) +static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212) { unsigned long flags; spin_lock_irqsave(&korg1212->lock, flags); @@ -615,7 +608,7 @@ static void snd_korg1212_SendStopAndWait(korg1212_t *korg1212) /* timer callback for checking the ack of stop request */ static void snd_korg1212_timer_func(unsigned long data) { - korg1212_t *korg1212 = (korg1212_t *) data; + struct snd_korg1212 *korg1212 = (struct snd_korg1212 *) data; spin_lock(&korg1212->lock); if (korg1212->sharedBufferPtr->cardCommand == 0) { @@ -642,7 +635,7 @@ static void snd_korg1212_timer_func(unsigned long data) spin_unlock(&korg1212->lock); } -static int snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) +static int snd_korg1212_TurnOnIdleMonitor(struct snd_korg1212 *korg1212) { unsigned long flags; int rc; @@ -656,7 +649,7 @@ static int snd_korg1212_TurnOnIdleMonitor(korg1212_t *korg1212) return rc; } -static void snd_korg1212_TurnOffIdleMonitor(korg1212_t *korg1212) +static void snd_korg1212_TurnOffIdleMonitor(struct snd_korg1212 *korg1212) { if (korg1212->idleMonitorOn) { snd_korg1212_SendStopAndWait(korg1212); @@ -664,12 +657,12 @@ static void snd_korg1212_TurnOffIdleMonitor(korg1212_t *korg1212) } } -static inline void snd_korg1212_setCardState(korg1212_t * korg1212, CardState csState) +static inline void snd_korg1212_setCardState(struct snd_korg1212 * korg1212, enum CardState csState) { korg1212->cardState = csState; } -static int snd_korg1212_OpenCard(korg1212_t * korg1212) +static int snd_korg1212_OpenCard(struct snd_korg1212 * korg1212) { K1212_DEBUG_PRINTK("K1212_DEBUG: OpenCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt); @@ -683,7 +676,7 @@ static int snd_korg1212_OpenCard(korg1212_t * korg1212) return 1; } -static int snd_korg1212_CloseCard(korg1212_t * korg1212) +static int snd_korg1212_CloseCard(struct snd_korg1212 * korg1212) { K1212_DEBUG_PRINTK("K1212_DEBUG: CloseCard [%s] %d\n", stateName[korg1212->cardState], korg1212->opencnt); @@ -718,7 +711,7 @@ static int snd_korg1212_CloseCard(korg1212_t * korg1212) } /* spinlock already held */ -static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) +static int snd_korg1212_SetupForPlay(struct snd_korg1212 * korg1212) { int rc; @@ -741,7 +734,7 @@ static int snd_korg1212_SetupForPlay(korg1212_t * korg1212) } /* spinlock already held */ -static int snd_korg1212_TriggerPlay(korg1212_t * korg1212) +static int snd_korg1212_TriggerPlay(struct snd_korg1212 * korg1212) { int rc; @@ -763,7 +756,7 @@ static int snd_korg1212_TriggerPlay(korg1212_t * korg1212) } /* spinlock already held */ -static int snd_korg1212_StopPlay(korg1212_t * korg1212) +static int snd_korg1212_StopPlay(struct snd_korg1212 * korg1212) { K1212_DEBUG_PRINTK("K1212_DEBUG: StopPlay [%s] %d\n", stateName[korg1212->cardState], korg1212->playcnt); @@ -780,7 +773,7 @@ static int snd_korg1212_StopPlay(korg1212_t * korg1212) return 0; } -static void snd_korg1212_EnableCardInterrupts(korg1212_t * korg1212) +static void snd_korg1212_EnableCardInterrupts(struct snd_korg1212 * korg1212) { writel(PCI_INT_ENABLE_BIT | PCI_DOORBELL_INT_ENABLE_BIT | @@ -792,7 +785,8 @@ static void snd_korg1212_EnableCardInterrupts(korg1212_t * korg1212) #if 0 /* not used */ -static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector mode) +static int snd_korg1212_SetMonitorMode(struct snd_korg1212 *korg1212, + enum MonitorModeSelector mode) { K1212_DEBUG_PRINTK("K1212_DEBUG: SetMonitorMode [%s]\n", stateName[korg1212->cardState]); @@ -829,7 +823,7 @@ static int snd_korg1212_SetMonitorMode(korg1212_t *korg1212, MonitorModeSelector #endif /* not used */ -static inline int snd_korg1212_use_is_exclusive(korg1212_t *korg1212) +static inline int snd_korg1212_use_is_exclusive(struct snd_korg1212 *korg1212) { if (korg1212->playback_pid != korg1212->capture_pid && korg1212->playback_pid >= 0 && korg1212->capture_pid >= 0) @@ -838,14 +832,14 @@ static inline int snd_korg1212_use_is_exclusive(korg1212_t *korg1212) return 1; } -static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) +static int snd_korg1212_SetRate(struct snd_korg1212 *korg1212, int rate) { - static ClockSourceIndex s44[] = { + static enum ClockSourceIndex s44[] = { K1212_CLKIDX_AdatAt44_1K, K1212_CLKIDX_WordAt44_1K, K1212_CLKIDX_LocalAt44_1K }; - static ClockSourceIndex s48[] = { + static enum ClockSourceIndex s48[] = { K1212_CLKIDX_AdatAt48K, K1212_CLKIDX_WordAt48K, K1212_CLKIDX_LocalAt48K @@ -855,7 +849,7 @@ static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) if (!snd_korg1212_use_is_exclusive (korg1212)) return -EBUSY; - switch(rate) { + switch (rate) { case 44100: parm = s44[korg1212->clkSource]; break; @@ -875,7 +869,6 @@ static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SetClockSourceRate, ClockSourceSelector[korg1212->clkSrcRate], 0, 0, 0); - if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: Set Clock Source Selector - RC = %d [%s]\n", rc, stateName[korg1212->cardState]); @@ -883,7 +876,7 @@ static int snd_korg1212_SetRate(korg1212_t *korg1212, int rate) return 0; } -static int snd_korg1212_SetClockSource(korg1212_t *korg1212, int source) +static int snd_korg1212_SetClockSource(struct snd_korg1212 *korg1212, int source) { if (source < 0 || source > 2) @@ -896,14 +889,14 @@ static int snd_korg1212_SetClockSource(korg1212_t *korg1212, int source) return 0; } -static void snd_korg1212_DisableCardInterrupts(korg1212_t *korg1212) +static void snd_korg1212_DisableCardInterrupts(struct snd_korg1212 *korg1212) { writel(0, korg1212->statusRegPtr); } -static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) +static int snd_korg1212_WriteADCSensitivity(struct snd_korg1212 *korg1212) { - SensBits sensVals; + struct SensBits sensVals; int bitPosition; int channel; int clkIs48K; @@ -985,7 +978,7 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) for (bitPosition = 15; bitPosition >= 0; bitPosition--) { // for all the bits if (channel == 0) { if (sensVals.l.leftSensBits & (0x0001 << bitPosition)) - SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high + SetBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set high else ClearBitInWord(&controlValue, SET_SENS_DATA_BITPOS); // data bit set low } else { @@ -1034,7 +1027,7 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) udelay(SENSCLKPULSE_WIDTH); if (monModeSet) { - rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, + int rc = snd_korg1212_Send1212Command(korg1212, K1212_DB_SelectPlayMode, K1212_MODE_MonitorOn, 0, 0, 0); if (rc) K1212_DEBUG_PRINTK("K1212_DEBUG: WriteADCSensivity - RC = %d [%s]\n", @@ -1046,9 +1039,9 @@ static int snd_korg1212_WriteADCSensitivity(korg1212_t *korg1212) return 1; } -static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) +static void snd_korg1212_OnDSPDownloadComplete(struct snd_korg1212 *korg1212) { - int channel; + int channel, rc; K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is complete. [%s]\n", stateName[korg1212->cardState]); @@ -1127,7 +1120,7 @@ static void snd_korg1212_OnDSPDownloadComplete(korg1212_t *korg1212) static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs *regs) { u32 doorbellValue; - korg1212_t *korg1212 = dev_id; + struct snd_korg1212 *korg1212 = dev_id; if(irq != korg1212->irq) return IRQ_NONE; @@ -1176,7 +1169,7 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs // the semaphore in case someone is waiting for this. // ------------------------------------------------------------------------ case K1212_DB_CARDSTOPPED: - K1212_DEBUG_PRINTK_VEROBSE("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", + K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ CSTP count - %ld, %x, [%s].\n", korg1212->irqcount, doorbellValue, stateName[korg1212->cardState]); korg1212->sharedBufferPtr->cardCommand = 0; @@ -1184,9 +1177,8 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs default: K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: IRQ DFLT count - %ld, %x, cpos=%d [%s].\n", - korg1212->irqcount, doorbellValue, - korg1212->currentBuffer, - stateName[korg1212->cardState]); + korg1212->irqcount, doorbellValue, + korg1212->currentBuffer, stateName[korg1212->cardState]); if ((korg1212->cardState > K1212_STATE_SETUP) || korg1212->idleMonitorOn) { korg1212->currentBuffer++; @@ -1218,8 +1210,9 @@ static irqreturn_t snd_korg1212_interrupt(int irq, void *dev_id, struct pt_regs return IRQ_HANDLED; } -static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212) +static int snd_korg1212_downloadDSPCode(struct snd_korg1212 *korg1212) { + int rc; K1212_DEBUG_PRINTK("K1212_DEBUG: DSP download is starting... [%s]\n", stateName[korg1212->cardState]); @@ -1251,7 +1244,7 @@ static int snd_korg1212_downloadDSPCode(korg1212_t *korg1212) return 0; } -static snd_pcm_hardware_t snd_korg1212_playback_info = +static struct snd_pcm_hardware snd_korg1212_playback_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -1271,7 +1264,7 @@ static snd_pcm_hardware_t snd_korg1212_playback_info = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_korg1212_capture_info = +static struct snd_pcm_hardware snd_korg1212_capture_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -1291,9 +1284,9 @@ static snd_pcm_hardware_t snd_korg1212_capture_info = .fifo_size = 0, }; -static int snd_korg1212_silence(korg1212_t *korg1212, int pos, int count, int offset, int size) +static int snd_korg1212_silence(struct snd_korg1212 *korg1212, int pos, int count, int offset, int size) { - KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; + struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i; K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_silence pos=%d offset=%d size=%d count=%d\n", @@ -1316,9 +1309,9 @@ static int snd_korg1212_silence(korg1212_t *korg1212, int pos, int count, int of return 0; } -static int snd_korg1212_copy_to(korg1212_t *korg1212, void __user *dst, int pos, int count, int offset, int size) +static int snd_korg1212_copy_to(struct snd_korg1212 *korg1212, void __user *dst, int pos, int count, int offset, int size) { - KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos; + struct KorgAudioFrame * src = korg1212->recordDataBufsPtr[0].bufferData + pos; int i, rc; K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_to pos=%d offset=%d size=%d\n", @@ -1345,9 +1338,9 @@ static int snd_korg1212_copy_to(korg1212_t *korg1212, void __user *dst, int pos, return 0; } -static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int pos, int count, int offset, int size) +static int snd_korg1212_copy_from(struct snd_korg1212 *korg1212, void __user *src, int pos, int count, int offset, int size) { - KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; + struct KorgAudioFrame * dst = korg1212->playDataBufsPtr[0].bufferData + pos; int i, rc; K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_copy_from pos=%d offset=%d size=%d count=%d\n", @@ -1359,15 +1352,13 @@ static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int po #if K1212_DEBUG_LEVEL > 0 if ( (void *) dst < (void *) korg1212->playDataBufsPtr || (void *) dst > (void *) korg1212->playDataBufsPtr[8].bufferData ) { - printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", - src, dst, i); + printk(KERN_DEBUG "K1212_DEBUG: snd_korg1212_copy_from KERNEL EFAULT, src=%p dst=%p iter=%d\n", src, dst, i); return -EFAULT; } #endif rc = copy_from_user((void*) dst + offset, src, size); if (rc) { - K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", - src, dst, i); + K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_copy_from USER EFAULT src=%p dst=%p iter=%d\n", src, dst, i); return -EFAULT; } dst++; @@ -1377,9 +1368,9 @@ static int snd_korg1212_copy_from(korg1212_t *korg1212, void __user *src, int po return 0; } -static void snd_korg1212_free_pcm(snd_pcm_t *pcm) +static void snd_korg1212_free_pcm(struct snd_pcm *pcm) { - korg1212_t *korg1212 = (korg1212_t *) pcm->private_data; + struct snd_korg1212 *korg1212 = pcm->private_data; K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_free_pcm [%s]\n", stateName[korg1212->cardState]); @@ -1387,11 +1378,11 @@ static void snd_korg1212_free_pcm(snd_pcm_t *pcm) korg1212->pcm = NULL; } -static int snd_korg1212_playback_open(snd_pcm_substream_t *substream) +static int snd_korg1212_playback_open(struct snd_pcm_substream *substream) { unsigned long flags; - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_open [%s]\n", stateName[korg1212->cardState]); @@ -1418,11 +1409,11 @@ static int snd_korg1212_playback_open(snd_pcm_substream_t *substream) } -static int snd_korg1212_capture_open(snd_pcm_substream_t *substream) +static int snd_korg1212_capture_open(struct snd_pcm_substream *substream) { unsigned long flags; - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_open [%s]\n", stateName[korg1212->cardState]); @@ -1443,14 +1434,15 @@ static int snd_korg1212_capture_open(snd_pcm_substream_t *substream) spin_unlock_irqrestore(&korg1212->lock, flags); - snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, kPlayBufferFrames, kPlayBufferFrames); + snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, + kPlayBufferFrames, kPlayBufferFrames); return 0; } -static int snd_korg1212_playback_close(snd_pcm_substream_t *substream) +static int snd_korg1212_playback_close(struct snd_pcm_substream *substream) { unsigned long flags; - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_playback_close [%s]\n", stateName[korg1212->cardState]); @@ -1469,10 +1461,10 @@ static int snd_korg1212_playback_close(snd_pcm_substream_t *substream) return 0; } -static int snd_korg1212_capture_close(snd_pcm_substream_t *substream) +static int snd_korg1212_capture_close(struct snd_pcm_substream *substream) { unsigned long flags; - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_capture_close [%s]\n", stateName[korg1212->cardState]); @@ -1489,13 +1481,13 @@ static int snd_korg1212_capture_close(snd_pcm_substream_t *substream) return 0; } -static int snd_korg1212_ioctl(snd_pcm_substream_t *substream, +static int snd_korg1212_ioctl(struct snd_pcm_substream *substream, unsigned int cmd, void *arg) { K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_ioctl: cmd=%d\n", cmd); if (cmd == SNDRV_PCM_IOCTL1_CHANNEL_INFO ) { - snd_pcm_channel_info_t *info = arg; + struct snd_pcm_channel_info *info = arg; info->offset = 0; info->first = info->channel * 16; info->step = 256; @@ -1506,11 +1498,11 @@ static int snd_korg1212_ioctl(snd_pcm_substream_t *substream, return snd_pcm_lib_ioctl(substream, cmd, arg); } -static int snd_korg1212_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +static int snd_korg1212_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { unsigned long flags; - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int err; pid_t this_pid; pid_t other_pid; @@ -1558,9 +1550,9 @@ static int snd_korg1212_hw_params(snd_pcm_substream_t *substream, return 0; } -static int snd_korg1212_prepare(snd_pcm_substream_t *substream) +static int snd_korg1212_prepare(struct snd_pcm_substream *substream) { - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int rc; K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_prepare [%s]\n", @@ -1590,10 +1582,10 @@ static int snd_korg1212_prepare(snd_pcm_substream_t *substream) return rc ? -EINVAL : 0; } -static int snd_korg1212_trigger(snd_pcm_substream_t *substream, +static int snd_korg1212_trigger(struct snd_pcm_substream *substream, int cmd) { - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); int rc; K1212_DEBUG_PRINTK("K1212_DEBUG: snd_korg1212_trigger [%s] cmd=%d\n", @@ -1631,9 +1623,9 @@ static int snd_korg1212_trigger(snd_pcm_substream_t *substream, return rc ? -EINVAL : 0; } -static snd_pcm_uframes_t snd_korg1212_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_korg1212_playback_pointer(struct snd_pcm_substream *substream) { - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); snd_pcm_uframes_t pos; pos = korg1212->currentBuffer * kPlayBufferFrames; @@ -1644,9 +1636,9 @@ static snd_pcm_uframes_t snd_korg1212_playback_pointer(snd_pcm_substream_t *subs return pos; } -static snd_pcm_uframes_t snd_korg1212_capture_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_korg1212_capture_pointer(struct snd_pcm_substream *substream) { - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); snd_pcm_uframes_t pos; pos = korg1212->currentBuffer * kPlayBufferFrames; @@ -1657,13 +1649,13 @@ static snd_pcm_uframes_t snd_korg1212_capture_pointer(snd_pcm_substream_t *subst return pos; } -static int snd_korg1212_playback_copy(snd_pcm_substream_t *substream, +static int snd_korg1212_playback_copy(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count); @@ -1672,12 +1664,12 @@ static int snd_korg1212_playback_copy(snd_pcm_substream_t *substream, } -static int snd_korg1212_playback_silence(snd_pcm_substream_t *substream, +static int snd_korg1212_playback_silence(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_playback_silence [%s]\n", stateName[korg1212->cardState]); @@ -1685,13 +1677,13 @@ static int snd_korg1212_playback_silence(snd_pcm_substream_t *substream, return snd_korg1212_silence(korg1212, pos, count, 0, korg1212->channels * 2); } -static int snd_korg1212_capture_copy(snd_pcm_substream_t *substream, +static int snd_korg1212_capture_copy(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { - korg1212_t *korg1212 = snd_pcm_substream_chip(substream); + struct snd_korg1212 *korg1212 = snd_pcm_substream_chip(substream); K1212_DEBUG_PRINTK_VERBOSE("K1212_DEBUG: snd_korg1212_capture_copy [%s] %ld %ld\n", stateName[korg1212->cardState], pos, count); @@ -1699,7 +1691,7 @@ static int snd_korg1212_capture_copy(snd_pcm_substream_t *substream, return snd_korg1212_copy_to(korg1212, dst, pos, count, 0, korg1212->channels * 2); } -static snd_pcm_ops_t snd_korg1212_playback_ops = { +static struct snd_pcm_ops snd_korg1212_playback_ops = { .open = snd_korg1212_playback_open, .close = snd_korg1212_playback_close, .ioctl = snd_korg1212_ioctl, @@ -1711,7 +1703,7 @@ static snd_pcm_ops_t snd_korg1212_playback_ops = { .silence = snd_korg1212_playback_silence, }; -static snd_pcm_ops_t snd_korg1212_capture_ops = { +static struct snd_pcm_ops snd_korg1212_capture_ops = { .open = snd_korg1212_capture_open, .close = snd_korg1212_capture_close, .ioctl = snd_korg1212_ioctl, @@ -1726,16 +1718,18 @@ static snd_pcm_ops_t snd_korg1212_capture_ops = { * Control Interface */ -static int snd_korg1212_control_phase_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_korg1212_control_phase_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = (kcontrol->private_value >= 8) ? 2 : 1; return 0; } -static int snd_korg1212_control_phase_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +static int snd_korg1212_control_phase_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *u) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); int i = kcontrol->private_value; spin_lock_irq(&korg1212->lock); @@ -1750,9 +1744,10 @@ static int snd_korg1212_control_phase_get(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_korg1212_control_phase_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +static int snd_korg1212_control_phase_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *u) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); int change = 0; int i, val; @@ -1787,7 +1782,8 @@ static int snd_korg1212_control_phase_put(snd_kcontrol_t *kcontrol, snd_ctl_elem return change; } -static int snd_korg1212_control_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_korg1212_control_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = (kcontrol->private_value >= 8) ? 2 : 1; @@ -1796,9 +1792,10 @@ static int snd_korg1212_control_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_korg1212_control_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +static int snd_korg1212_control_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *u) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); int i; spin_lock_irq(&korg1212->lock); @@ -1814,9 +1811,10 @@ static int snd_korg1212_control_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_korg1212_control_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +static int snd_korg1212_control_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *u) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); int change = 0; int i; int val; @@ -1846,7 +1844,8 @@ static int snd_korg1212_control_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_ele return change; } -static int snd_korg1212_control_route_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_korg1212_control_route_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = (kcontrol->private_value >= 8) ? 2 : 1; @@ -1858,9 +1857,10 @@ static int snd_korg1212_control_route_info(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_korg1212_control_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +static int snd_korg1212_control_route_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *u) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); int i; spin_lock_irq(&korg1212->lock); @@ -1876,9 +1876,10 @@ static int snd_korg1212_control_route_get(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_korg1212_control_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +static int snd_korg1212_control_route_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *u) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); int change = 0, i; spin_lock_irq(&korg1212->lock); @@ -1902,7 +1903,8 @@ static int snd_korg1212_control_route_put(snd_kcontrol_t *kcontrol, snd_ctl_elem return change; } -static int snd_korg1212_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_korg1212_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1911,9 +1913,10 @@ static int snd_korg1212_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_korg1212_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +static int snd_korg1212_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *u) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&korg1212->lock); @@ -1925,9 +1928,10 @@ static int snd_korg1212_control_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value return 0; } -static int snd_korg1212_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +static int snd_korg1212_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *u) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); int change = 0; spin_lock_irq(&korg1212->lock); @@ -1949,7 +1953,8 @@ static int snd_korg1212_control_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value return change; } -static int snd_korg1212_control_sync_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_korg1212_control_sync_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -1961,9 +1966,10 @@ static int snd_korg1212_control_sync_info(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_korg1212_control_sync_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_korg1212_control_sync_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&korg1212->lock); @@ -1973,9 +1979,10 @@ static int snd_korg1212_control_sync_get(snd_kcontrol_t * kcontrol, snd_ctl_elem return 0; } -static int snd_korg1212_control_sync_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_korg1212_control_sync_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - korg1212_t *korg1212 = snd_kcontrol_chip(kcontrol); + struct snd_korg1212 *korg1212 = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -2016,7 +2023,7 @@ static int snd_korg1212_control_sync_put(snd_kcontrol_t * kcontrol, snd_ctl_elem .private_value = ord, \ } -static snd_kcontrol_new_t snd_korg1212_controls[] = { +static struct snd_kcontrol_new snd_korg1212_controls[] = { MON_MIXER(8, "Analog"), MON_MIXER(10, "SPDIF"), MON_MIXER(0, "ADAT-1"), MON_MIXER(1, "ADAT-2"), MON_MIXER(2, "ADAT-3"), MON_MIXER(3, "ADAT-4"), @@ -2043,10 +2050,11 @@ static snd_kcontrol_new_t snd_korg1212_controls[] = { * proc interface */ -static void snd_korg1212_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_korg1212_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int n; - korg1212_t *korg1212 = (korg1212_t *)entry->private_data; + struct snd_korg1212 *korg1212 = entry->private_data; snd_iprintf(buffer, korg1212->card->longname); snd_iprintf(buffer, " (index #%d)\n", korg1212->card->number + 1); @@ -2070,16 +2078,16 @@ static void snd_korg1212_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *b snd_iprintf(buffer, " Error count: %ld\n", korg1212->totalerrorcnt); } -static void __devinit snd_korg1212_proc_init(korg1212_t *korg1212) +static void __devinit snd_korg1212_proc_init(struct snd_korg1212 *korg1212) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(korg1212->card, "korg1212", &entry)) snd_info_set_text_ops(entry, korg1212, 1024, snd_korg1212_proc_read); } static int -snd_korg1212_free(korg1212_t *korg1212) +snd_korg1212_free(struct snd_korg1212 *korg1212) { snd_korg1212_TurnOffIdleMonitor(korg1212); @@ -2135,23 +2143,23 @@ snd_korg1212_free(korg1212_t *korg1212) return 0; } -static int snd_korg1212_dev_free(snd_device_t *device) +static int snd_korg1212_dev_free(struct snd_device *device) { - korg1212_t *korg1212 = device->device_data; + struct snd_korg1212 *korg1212 = device->device_data; K1212_DEBUG_PRINTK("K1212_DEBUG: Freeing device\n"); return snd_korg1212_free(korg1212); } -static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, - korg1212_t ** rchip) +static int __devinit snd_korg1212_create(struct snd_card *card, struct pci_dev *pci, + struct snd_korg1212 ** rchip) { int err, rc; unsigned int i; unsigned ioport_size, iomem_size, iomem2_size; - korg1212_t * korg1212; + struct snd_korg1212 * korg1212; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_korg1212_dev_free, }; @@ -2276,19 +2284,19 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, stateName[korg1212->cardState]); if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), - sizeof(KorgSharedBuffer), &korg1212->dma_shared) < 0) { - snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%Zd bytes)\n", sizeof(KorgSharedBuffer)); + sizeof(struct KorgSharedBuffer), &korg1212->dma_shared) < 0) { + snd_printk(KERN_ERR "korg1212: can not allocate shared buffer memory (%Zd bytes)\n", sizeof(struct KorgSharedBuffer)); snd_korg1212_free(korg1212); return -ENOMEM; } - korg1212->sharedBufferPtr = (KorgSharedBuffer *)korg1212->dma_shared.area; + korg1212->sharedBufferPtr = (struct KorgSharedBuffer *)korg1212->dma_shared.area; korg1212->sharedBufferPhy = korg1212->dma_shared.addr; - K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(KorgSharedBuffer)); + K1212_DEBUG_PRINTK("K1212_DEBUG: Shared Buffer Area = 0x%p (0x%08lx), %d bytes\n", korg1212->sharedBufferPtr, korg1212->sharedBufferPhy, sizeof(struct KorgSharedBuffer)); #ifndef K1212_LARGEALLOC - korg1212->DataBufsSize = sizeof(KorgAudioBuffer) * kNumBuffers; + korg1212->DataBufsSize = sizeof(struct KorgAudioBuffer) * kNumBuffers; if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->DataBufsSize, &korg1212->dma_play) < 0) { @@ -2296,7 +2304,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, snd_korg1212_free(korg1212); return -ENOMEM; } - korg1212->playDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_play.area; + korg1212->playDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_play.area; korg1212->PlayDataPhy = korg1212->dma_play.addr; K1212_DEBUG_PRINTK("K1212_DEBUG: Play Data Area = 0x%p (0x%08x), %d bytes\n", @@ -2308,7 +2316,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, snd_korg1212_free(korg1212); return -ENOMEM; } - korg1212->recordDataBufsPtr = (KorgAudioBuffer *)korg1212->dma_rec.area; + korg1212->recordDataBufsPtr = (struct KorgAudioBuffer *)korg1212->dma_rec.area; korg1212->RecDataPhy = korg1212->dma_rec.addr; K1212_DEBUG_PRINTK("K1212_DEBUG: Record Data Area = 0x%p (0x%08x), %d bytes\n", @@ -2318,19 +2326,19 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, korg1212->recordDataBufsPtr = korg1212->sharedBufferPtr->recordDataBufs; korg1212->playDataBufsPtr = korg1212->sharedBufferPtr->playDataBufs; - korg1212->PlayDataPhy = (u32) &((KorgSharedBuffer *) korg1212->sharedBufferPhy)->playDataBufs; - korg1212->RecDataPhy = (u32) &((KorgSharedBuffer *) korg1212->sharedBufferPhy)->recordDataBufs; + korg1212->PlayDataPhy = (u32) &((struct KorgSharedBuffer *) korg1212->sharedBufferPhy)->playDataBufs; + korg1212->RecDataPhy = (u32) &((struct KorgSharedBuffer *) korg1212->sharedBufferPhy)->recordDataBufs; #endif // K1212_LARGEALLOC korg1212->dspCodeSize = sizeof (dspCode); korg1212->VolumeTablePhy = korg1212->sharedBufferPhy + - offsetof(KorgSharedBuffer, volumeData); + offsetof(struct KorgSharedBuffer, volumeData); korg1212->RoutingTablePhy = korg1212->sharedBufferPhy + - offsetof(KorgSharedBuffer, routeData); + offsetof(struct KorgSharedBuffer, routeData); korg1212->AdatTimeCodePhy = korg1212->sharedBufferPhy + - offsetof(KorgSharedBuffer, AdatTimeCode); + offsetof(struct KorgSharedBuffer, AdatTimeCode); if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), korg1212->dspCodeSize, &korg1212->dma_dsp) < 0) { @@ -2360,7 +2368,7 @@ static int __devinit snd_korg1212_create(snd_card_t * card, struct pci_dev *pci, if (snd_korg1212_downloadDSPCode(korg1212)) return -EBUSY; - K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], " + K1212_DEBUG_PRINTK("korg1212: dspMemPhy = %08x U[%08x], " "PlayDataPhy = %08x L[%08x]\n" "korg1212: RecDataPhy = %08x L[%08x], " "VolumeTablePhy = %08x L[%08x]\n" @@ -2410,8 +2418,8 @@ snd_korg1212_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - korg1212_t *korg1212; - snd_card_t *card; + struct snd_korg1212 *korg1212; + struct snd_card *card; int err; if (dev >= SNDRV_CARDS) { -- cgit v1.1 From 67b48b880062ba1775f424c2dd2c68bc30ec180f Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:01:08 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI miXart Modules: MIXART driver Remove xxx_t typedefs from the PCI miXart driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/mixart/mixart.c | 211 +++++++++++++++++++++------------------- sound/pci/mixart/mixart.h | 69 +++++-------- sound/pci/mixart/mixart_core.c | 49 +++++----- sound/pci/mixart/mixart_core.h | 120 ++++++++--------------- sound/pci/mixart/mixart_hwdep.c | 76 +++++++-------- sound/pci/mixart/mixart_hwdep.h | 2 +- sound/pci/mixart/mixart_mixer.c | 108 ++++++++++---------- sound/pci/mixart/mixart_mixer.h | 6 +- 8 files changed, 300 insertions(+), 341 deletions(-) diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index b3090a1..b218e1d 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -66,11 +66,12 @@ static struct pci_device_id snd_mixart_ids[] = { MODULE_DEVICE_TABLE(pci, snd_mixart_ids); -static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int start) +static int mixart_set_pipe_state(struct mixart_mgr *mgr, + struct mixart_pipe *pipe, int start) { - mixart_group_state_req_t group_state; - mixart_group_state_resp_t group_state_resp; - mixart_msg_t request; + struct mixart_group_state_req group_state; + struct mixart_group_state_resp group_state_resp; + struct mixart_msg request; int err; u32 system_msg_uid; @@ -92,7 +93,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta /* wait on the last MSG_SYSTEM_SEND_SYNCHRO_CMD command to be really finished */ request.message_id = MSG_SYSTEM_WAIT_SYNCHRO_CMD; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = &system_msg_uid; request.size = sizeof(system_msg_uid); @@ -113,7 +114,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta else request.message_id = MSG_STREAM_STOP_STREAM_GRP_PACKET; - request.uid = pipe->group_uid; /*(mixart_uid_t){0,0};*/ + request.uid = pipe->group_uid; /*(struct mixart_uid){0,0};*/ request.data = &group_state; request.size = sizeof(group_state); @@ -137,7 +138,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta /* in case of start send a synchro top */ request.message_id = MSG_SYSTEM_SEND_SYNCHRO_CMD; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = NULL; request.size = 0; @@ -156,11 +157,12 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta } -static int mixart_set_clock(mixart_mgr_t *mgr, mixart_pipe_t *pipe, unsigned int rate) +static int mixart_set_clock(struct mixart_mgr *mgr, + struct mixart_pipe *pipe, unsigned int rate) { - mixart_msg_t request; - mixart_clock_properties_t clock_properties; - mixart_clock_properties_resp_t clock_prop_resp; + struct mixart_msg request; + struct mixart_clock_properties clock_properties; + struct mixart_clock_properties_resp clock_prop_resp; int err; switch(pipe->status) { @@ -208,11 +210,13 @@ static int mixart_set_clock(mixart_mgr_t *mgr, mixart_pipe_t *pipe, unsigned int /* * Allocate or reference output pipe for analog IOs (pcmp0/1) */ -mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capture, int monitoring) +struct mixart_pipe * +snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture, + int monitoring) { int stream_count; - mixart_pipe_t *pipe; - mixart_msg_t request; + struct mixart_pipe *pipe; + struct mixart_msg request; if(capture) { if (pcm_number == MIXART_PCM_ANALOG) { @@ -241,8 +245,8 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt if( pipe->status == PIPE_UNDEFINED ) { int err, i; struct { - mixart_streaming_group_req_t sgroup_req; - mixart_streaming_group_t sgroup_resp; + struct mixart_streaming_group_req sgroup_req; + struct mixart_streaming_group sgroup_resp; } *buf; snd_printdd("add_ref_pipe audio chip(%d) pcm(%d)\n", chip->chip_idx, pcm_number); @@ -251,7 +255,7 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt if (!buf) return NULL; - request.uid = (mixart_uid_t){0,0}; /* should be StreamManagerUID, but zero is OK if there is only one ! */ + request.uid = (struct mixart_uid){0,0}; /* should be StreamManagerUID, but zero is OK if there is only one ! */ request.data = &buf->sgroup_req; request.size = sizeof(buf->sgroup_req); @@ -279,7 +283,7 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt buf->sgroup_req.flow_entry[i] = j; flowinfo = (struct mixart_flowinfo *)chip->mgr->flowinfo.area; - flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(mixart_bufferinfo_t)); + flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(struct mixart_bufferinfo)); flowinfo[j].bufferinfo_count = 1; /* 1 will set the miXart to ring-buffer mode ! */ bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area; @@ -315,7 +319,8 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt } -int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monitoring) +int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr, + struct mixart_pipe *pipe, int monitoring) { int err = 0; @@ -329,8 +334,8 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito if((pipe->references <= 0) && (pipe->monitoring == 0)) { - mixart_msg_t request; - mixart_delete_group_resp_t delete_resp; + struct mixart_msg request; + struct mixart_delete_group_resp delete_resp; /* release the clock */ err = mixart_set_clock( mgr, pipe, 0); @@ -345,7 +350,7 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito } request.message_id = MSG_STREAM_DELETE_GROUP; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = &pipe->group_uid; /* the streaming group ! */ request.size = sizeof(pipe->group_uid); @@ -355,7 +360,7 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito snd_printk(KERN_ERR "error MSG_STREAM_DELETE_GROUP err(%x), status(%x)\n", err, delete_resp.status); } - pipe->group_uid = (mixart_uid_t){0,0}; + pipe->group_uid = (struct mixart_uid){0,0}; pipe->stream_count = 0; pipe->status = PIPE_UNDEFINED; } @@ -363,11 +368,11 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito return err; } -static int mixart_set_stream_state(mixart_stream_t *stream, int start) +static int mixart_set_stream_state(struct mixart_stream *stream, int start) { - mixart_t *chip; - mixart_stream_state_req_t stream_state_req; - mixart_msg_t request; + struct snd_mixart *chip; + struct mixart_stream_state_req stream_state_req; + struct mixart_msg request; if(!stream->substream) return -EINVAL; @@ -382,7 +387,7 @@ static int mixart_set_stream_state(mixart_stream_t *stream, int start) else request.message_id = start ? MSG_STREAM_START_OUTPUT_STAGE_PACKET : MSG_STREAM_STOP_OUTPUT_STAGE_PACKET; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = &stream_state_req; request.size = sizeof(stream_state_req); @@ -399,9 +404,9 @@ static int mixart_set_stream_state(mixart_stream_t *stream, int start) * Trigger callback */ -static int snd_mixart_trigger(snd_pcm_substream_t *subs, int cmd) +static int snd_mixart_trigger(struct snd_pcm_substream *subs, int cmd) { - mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data; + struct mixart_stream *stream = subs->runtime->private_data; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -443,7 +448,7 @@ static int snd_mixart_trigger(snd_pcm_substream_t *subs, int cmd) return 0; } -static int mixart_sync_nonblock_events(mixart_mgr_t *mgr) +static int mixart_sync_nonblock_events(struct mixart_mgr *mgr) { unsigned long timeout = jiffies + HZ; while (atomic_read(&mgr->msg_processed) > 0) { @@ -459,10 +464,10 @@ static int mixart_sync_nonblock_events(mixart_mgr_t *mgr) /* * prepare callback for all pcms */ -static int snd_mixart_prepare(snd_pcm_substream_t *subs) +static int snd_mixart_prepare(struct snd_pcm_substream *subs) { - mixart_t *chip = snd_pcm_substream_chip(subs); - mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data; + struct snd_mixart *chip = snd_pcm_substream_chip(subs); + struct mixart_stream *stream = subs->runtime->private_data; /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */ @@ -485,13 +490,13 @@ static int snd_mixart_prepare(snd_pcm_substream_t *subs) } -static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format) +static int mixart_set_format(struct mixart_stream *stream, snd_pcm_format_t format) { int err; - mixart_t *chip; - mixart_msg_t request; - mixart_stream_param_desc_t stream_param; - mixart_return_uid_t resp; + struct snd_mixart *chip; + struct mixart_msg request; + struct mixart_stream_param_desc stream_param; + struct mixart_return_uid resp; chip = snd_pcm_substream_chip(stream->substream); @@ -552,7 +557,7 @@ static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format) stream_param.stream_desc[0].stream_idx = stream->substream->number; request.message_id = MSG_STREAM_SET_INPUT_STAGE_PARAM; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = &stream_param; request.size = sizeof(stream_param); @@ -568,12 +573,12 @@ static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format) /* * HW_PARAMS callback for all pcms */ -static int snd_mixart_hw_params(snd_pcm_substream_t *subs, - snd_pcm_hw_params_t *hw) +static int snd_mixart_hw_params(struct snd_pcm_substream *subs, + struct snd_pcm_hw_params *hw) { - mixart_t *chip = snd_pcm_substream_chip(subs); - mixart_mgr_t *mgr = chip->mgr; - mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data; + struct snd_mixart *chip = snd_pcm_substream_chip(subs); + struct mixart_mgr *mgr = chip->mgr; + struct mixart_stream *stream = subs->runtime->private_data; snd_pcm_format_t format; int err; int channels; @@ -628,9 +633,9 @@ static int snd_mixart_hw_params(snd_pcm_substream_t *subs, return err; } -static int snd_mixart_hw_free(snd_pcm_substream_t *subs) +static int snd_mixart_hw_free(struct snd_pcm_substream *subs) { - mixart_t *chip = snd_pcm_substream_chip(subs); + struct snd_mixart *chip = snd_pcm_substream_chip(subs); snd_pcm_lib_free_pages(subs); mixart_sync_nonblock_events(chip->mgr); return 0; @@ -641,7 +646,7 @@ static int snd_mixart_hw_free(snd_pcm_substream_t *subs) /* * TODO CONFIGURATION SPACE for all pcms, mono pcm must update channels_max */ -static snd_pcm_hardware_t snd_mixart_analog_caps = +static struct snd_pcm_hardware snd_mixart_analog_caps = { .info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START | @@ -662,7 +667,7 @@ static snd_pcm_hardware_t snd_mixart_analog_caps = .periods_max = (32*1024/256), }; -static snd_pcm_hardware_t snd_mixart_digital_caps = +static struct snd_pcm_hardware snd_mixart_digital_caps = { .info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START | @@ -684,14 +689,14 @@ static snd_pcm_hardware_t snd_mixart_digital_caps = }; -static int snd_mixart_playback_open(snd_pcm_substream_t *subs) +static int snd_mixart_playback_open(struct snd_pcm_substream *subs) { - mixart_t *chip = snd_pcm_substream_chip(subs); - mixart_mgr_t *mgr = chip->mgr; - snd_pcm_runtime_t *runtime = subs->runtime; - snd_pcm_t *pcm = subs->pcm; - mixart_stream_t *stream; - mixart_pipe_t *pipe; + struct snd_mixart *chip = snd_pcm_substream_chip(subs); + struct mixart_mgr *mgr = chip->mgr; + struct snd_pcm_runtime *runtime = subs->runtime; + struct snd_pcm *pcm = subs->pcm; + struct mixart_stream *stream; + struct mixart_pipe *pipe; int err = 0; int pcm_number; @@ -759,14 +764,14 @@ static int snd_mixart_playback_open(snd_pcm_substream_t *subs) } -static int snd_mixart_capture_open(snd_pcm_substream_t *subs) +static int snd_mixart_capture_open(struct snd_pcm_substream *subs) { - mixart_t *chip = snd_pcm_substream_chip(subs); - mixart_mgr_t *mgr = chip->mgr; - snd_pcm_runtime_t *runtime = subs->runtime; - snd_pcm_t *pcm = subs->pcm; - mixart_stream_t *stream; - mixart_pipe_t *pipe; + struct snd_mixart *chip = snd_pcm_substream_chip(subs); + struct mixart_mgr *mgr = chip->mgr; + struct snd_pcm_runtime *runtime = subs->runtime; + struct snd_pcm *pcm = subs->pcm; + struct mixart_stream *stream; + struct mixart_pipe *pipe; int err = 0; int pcm_number; @@ -838,11 +843,11 @@ static int snd_mixart_capture_open(snd_pcm_substream_t *subs) -static int snd_mixart_close(snd_pcm_substream_t *subs) +static int snd_mixart_close(struct snd_pcm_substream *subs) { - mixart_t *chip = snd_pcm_substream_chip(subs); - mixart_mgr_t *mgr = chip->mgr; - mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data; + struct snd_mixart *chip = snd_pcm_substream_chip(subs); + struct mixart_mgr *mgr = chip->mgr; + struct mixart_stream *stream = subs->runtime->private_data; down(&mgr->setup_mutex); @@ -868,17 +873,17 @@ static int snd_mixart_close(snd_pcm_substream_t *subs) } -static snd_pcm_uframes_t snd_mixart_stream_pointer(snd_pcm_substream_t * subs) +static snd_pcm_uframes_t snd_mixart_stream_pointer(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; - mixart_stream_t *stream = (mixart_stream_t*)runtime->private_data; + struct snd_pcm_runtime *runtime = subs->runtime; + struct mixart_stream *stream = runtime->private_data; return (snd_pcm_uframes_t)((stream->buf_periods * runtime->period_size) + stream->buf_period_frag); } -static snd_pcm_ops_t snd_mixart_playback_ops = { +static struct snd_pcm_ops snd_mixart_playback_ops = { .open = snd_mixart_playback_open, .close = snd_mixart_close, .ioctl = snd_pcm_lib_ioctl, @@ -889,7 +894,7 @@ static snd_pcm_ops_t snd_mixart_playback_ops = { .pointer = snd_mixart_stream_pointer, }; -static snd_pcm_ops_t snd_mixart_capture_ops = { +static struct snd_pcm_ops snd_mixart_capture_ops = { .open = snd_mixart_capture_open, .close = snd_mixart_close, .ioctl = snd_pcm_lib_ioctl, @@ -900,10 +905,10 @@ static snd_pcm_ops_t snd_mixart_capture_ops = { .pointer = snd_mixart_stream_pointer, }; -static void preallocate_buffers(mixart_t *chip, snd_pcm_t *pcm) +static void preallocate_buffers(struct snd_mixart *chip, struct snd_pcm *pcm) { #if 0 - snd_pcm_substream_t *subs; + struct snd_pcm_substream *subs; int stream; for (stream = 0; stream < 2; stream++) { @@ -921,10 +926,10 @@ static void preallocate_buffers(mixart_t *chip, snd_pcm_t *pcm) /* */ -static int snd_mixart_pcm_analog(mixart_t *chip) +static int snd_mixart_pcm_analog(struct snd_mixart *chip) { int err; - snd_pcm_t *pcm; + struct snd_pcm *pcm; char name[32]; sprintf(name, "miXart analog %d", chip->chip_idx); @@ -952,10 +957,10 @@ static int snd_mixart_pcm_analog(mixart_t *chip) /* */ -static int snd_mixart_pcm_digital(mixart_t *chip) +static int snd_mixart_pcm_digital(struct snd_mixart *chip) { int err; - snd_pcm_t *pcm; + struct snd_pcm *pcm; char name[32]; sprintf(name, "miXart AES/EBU %d", chip->chip_idx); @@ -980,26 +985,26 @@ static int snd_mixart_pcm_digital(mixart_t *chip) return 0; } -static int snd_mixart_chip_free(mixart_t *chip) +static int snd_mixart_chip_free(struct snd_mixart *chip) { kfree(chip); return 0; } -static int snd_mixart_chip_dev_free(snd_device_t *device) +static int snd_mixart_chip_dev_free(struct snd_device *device) { - mixart_t *chip = device->device_data; + struct snd_mixart *chip = device->device_data; return snd_mixart_chip_free(chip); } /* */ -static int __devinit snd_mixart_create(mixart_mgr_t *mgr, snd_card_t *card, int idx) +static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int idx) { int err; - mixart_t *chip; - static snd_device_ops_t ops = { + struct snd_mixart *chip; + static struct snd_device_ops ops = { .dev_free = snd_mixart_chip_dev_free, }; @@ -1023,7 +1028,7 @@ static int __devinit snd_mixart_create(mixart_mgr_t *mgr, snd_card_t *card, int return 0; } -int snd_mixart_create_pcm(mixart_t* chip) +int snd_mixart_create_pcm(struct snd_mixart* chip) { int err; @@ -1044,7 +1049,7 @@ int snd_mixart_create_pcm(mixart_t* chip) /* * release all the cards assigned to a manager instance */ -static int snd_mixart_free(mixart_mgr_t *mgr) +static int snd_mixart_free(struct mixart_mgr *mgr) { unsigned int i; @@ -1092,7 +1097,7 @@ static int snd_mixart_free(mixart_mgr_t *mgr) /* * proc interface */ -static long long snd_mixart_BA0_llseek(snd_info_entry_t *entry, +static long long snd_mixart_BA0_llseek(struct snd_info_entry *entry, void *private_file_data, struct file *file, long long offset, @@ -1118,7 +1123,7 @@ static long long snd_mixart_BA0_llseek(snd_info_entry_t *entry, return file->f_pos; } -static long long snd_mixart_BA1_llseek(snd_info_entry_t *entry, +static long long snd_mixart_BA1_llseek(struct snd_info_entry *entry, void *private_file_data, struct file *file, long long offset, @@ -1147,11 +1152,11 @@ static long long snd_mixart_BA1_llseek(snd_info_entry_t *entry, /* mixart_BA0 proc interface for BAR 0 - read callback */ -static long snd_mixart_BA0_read(snd_info_entry_t *entry, void *file_private_data, +static long snd_mixart_BA0_read(struct snd_info_entry *entry, void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { - mixart_mgr_t *mgr = entry->private_data; + struct mixart_mgr *mgr = entry->private_data; count = count & ~3; /* make sure the read size is a multiple of 4 bytes */ if(count <= 0) @@ -1166,11 +1171,11 @@ static long snd_mixart_BA0_read(snd_info_entry_t *entry, void *file_private_data /* mixart_BA1 proc interface for BAR 1 - read callback */ -static long snd_mixart_BA1_read(snd_info_entry_t *entry, void *file_private_data, +static long snd_mixart_BA1_read(struct snd_info_entry *entry, void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { - mixart_mgr_t *mgr = entry->private_data; + struct mixart_mgr *mgr = entry->private_data; count = count & ~3; /* make sure the read size is a multiple of 4 bytes */ if(count <= 0) @@ -1193,10 +1198,10 @@ static struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = { }; -static void snd_mixart_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_mixart_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - mixart_t *chip = entry->private_data; + struct snd_mixart *chip = entry->private_data; u32 ref; snd_iprintf(buffer, "Digigram miXart (alsa card %d)\n\n", chip->chip_idx); @@ -1229,9 +1234,9 @@ static void snd_mixart_proc_read(snd_info_entry_t *entry, } /* endif elf loaded */ } -static void __devinit snd_mixart_proc_init(mixart_t *chip) +static void __devinit snd_mixart_proc_init(struct snd_mixart *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; /* text interface to read perf and temp meters */ if (! snd_card_proc_new(chip->card, "board_info", &entry)) { @@ -1263,7 +1268,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - mixart_mgr_t *mgr; + struct mixart_mgr *mgr; unsigned int i; int err; size_t size; @@ -1338,12 +1343,12 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, init_MUTEX(&mgr->setup_mutex); /* init message taslket */ - tasklet_init( &mgr->msg_taskq, snd_mixart_msg_tasklet, (unsigned long) mgr); + tasklet_init(&mgr->msg_taskq, snd_mixart_msg_tasklet, (unsigned long) mgr); /* card assignment */ mgr->num_cards = MIXART_MAX_CARDS; /* 4 FIXME: configurable? */ for (i = 0; i < mgr->num_cards; i++) { - snd_card_t *card; + struct snd_card *card; char tmpid[16]; int idx; @@ -1384,7 +1389,8 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, mgr->board_type = MIXART_DAUGHTER_TYPE_NONE; /* create array of streaminfo */ - size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * sizeof(mixart_flowinfo_t)) ); + size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * + sizeof(struct mixart_flowinfo)) ); if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), size, &mgr->flowinfo) < 0) { snd_mixart_free(mgr); @@ -1394,7 +1400,8 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, memset(mgr->flowinfo.area, 0, size); /* create array of bufferinfo */ - size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * sizeof(mixart_bufferinfo_t)) ); + size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * + sizeof(struct mixart_bufferinfo)) ); if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), size, &mgr->bufferinfo) < 0) { snd_mixart_free(mgr); diff --git a/sound/pci/mixart/mixart.h b/sound/pci/mixart/mixart.h index f87152f..3e84863 100644 --- a/sound/pci/mixart/mixart.h +++ b/sound/pci/mixart/mixart.h @@ -32,21 +32,7 @@ /* */ -#define mixart_t_magic 0xa17a3e01 -#define mixart_mgr_t_magic 0xa17a3e02 - -typedef struct snd_mixart mixart_t; -typedef struct snd_mixart_mgr mixart_mgr_t; - -typedef struct snd_mixart_stream mixart_stream_t; -typedef struct snd_mixart_pipe mixart_pipe_t; - -typedef struct mixart_bufferinfo mixart_bufferinfo_t; -typedef struct mixart_flowinfo mixart_flowinfo_t; -typedef struct mixart_uid mixart_uid_t; - -struct mixart_uid -{ +struct mixart_uid { u32 object_id; u32 desc; }; @@ -58,7 +44,6 @@ struct mem_area { }; -typedef struct mixart_route mixart_route_t; struct mixart_route { unsigned char connected; unsigned char phase_inv; @@ -77,9 +62,9 @@ struct mixart_route { #define MIXART_MAX_PHYS_CONNECTORS (MIXART_MAX_CARDS * 2 * 2) /* 4 * stereo * (analog+digital) */ -struct snd_mixart_mgr { +struct mixart_mgr { unsigned int num_cards; - mixart_t *chip[MIXART_MAX_CARDS]; + struct snd_mixart *chip[MIXART_MAX_CARDS]; struct pci_dev *pci; @@ -118,7 +103,7 @@ struct snd_mixart_mgr { struct snd_dma_buffer flowinfo; struct snd_dma_buffer bufferinfo; - mixart_uid_t uid_console_manager; + struct mixart_uid uid_console_manager; int sample_rate; int ref_count_rate; @@ -151,9 +136,9 @@ struct snd_mixart_mgr { #define MIXART_NOTIFY_SUBS_MASK 0x007F -struct snd_mixart_stream { - snd_pcm_substream_t *substream; - mixart_pipe_t *pipe; +struct mixart_stream { + struct snd_pcm_substream *substream; + struct mixart_pipe *pipe; int pcm_number; int status; /* nothing, running, draining */ @@ -173,11 +158,11 @@ enum mixart_pipe_status { PIPE_CLOCK_SET }; -struct snd_mixart_pipe { - mixart_uid_t group_uid; /* id of the pipe, as returned by embedded */ +struct mixart_pipe { + struct mixart_uid group_uid; /* id of the pipe, as returned by embedded */ int stream_count; - mixart_uid_t uid_left_connector; /* UID's for the audio connectors */ - mixart_uid_t uid_right_connector; + struct mixart_uid uid_left_connector; /* UID's for the audio connectors */ + struct mixart_uid uid_right_connector; enum mixart_pipe_status status; int references; /* number of subs openned */ int monitoring; /* pipe used for monitoring issue */ @@ -185,28 +170,28 @@ struct snd_mixart_pipe { struct snd_mixart { - snd_card_t *card; - mixart_mgr_t *mgr; + struct snd_card *card; + struct mixart_mgr *mgr; int chip_idx; /* zero based */ - snd_hwdep_t *hwdep; /* DSP loader, only for the first card */ + struct snd_hwdep *hwdep; /* DSP loader, only for the first card */ - snd_pcm_t *pcm; /* PCM analog i/o */ - snd_pcm_t *pcm_dig; /* PCM digital i/o */ + struct snd_pcm *pcm; /* PCM analog i/o */ + struct snd_pcm *pcm_dig; /* PCM digital i/o */ /* allocate stereo pipe for instance */ - mixart_pipe_t pipe_in_ana; - mixart_pipe_t pipe_out_ana; + struct mixart_pipe pipe_in_ana; + struct mixart_pipe pipe_out_ana; /* if AES/EBU daughter board is available, additional pipes possible on pcm_dig */ - mixart_pipe_t pipe_in_dig; - mixart_pipe_t pipe_out_dig; + struct mixart_pipe pipe_in_dig; + struct mixart_pipe pipe_out_dig; - mixart_stream_t playback_stream[MIXART_PCM_TOTAL][MIXART_PLAYBACK_STREAMS]; /* 0 = pcm, 1 = pcm_dig */ - mixart_stream_t capture_stream[MIXART_PCM_TOTAL]; /* 0 = pcm, 1 = pcm_dig */ + struct mixart_stream playback_stream[MIXART_PCM_TOTAL][MIXART_PLAYBACK_STREAMS]; /* 0 = pcm, 1 = pcm_dig */ + struct mixart_stream capture_stream[MIXART_PCM_TOTAL]; /* 0 = pcm, 1 = pcm_dig */ /* UID's for the physical io's */ - mixart_uid_t uid_out_analog_physio; - mixart_uid_t uid_in_analog_physio; + struct mixart_uid uid_out_analog_physio; + struct mixart_uid uid_in_analog_physio; int analog_playback_active[2]; /* Mixer : Master Playback active (!mute) */ int analog_playback_volume[2]; /* Mixer : Master Playback Volume */ @@ -235,8 +220,8 @@ struct mixart_flowinfo }; /* exported */ -int snd_mixart_create_pcm(mixart_t* chip); -mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capture, int monitoring); -int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monitoring); +int snd_mixart_create_pcm(struct snd_mixart * chip); +struct mixart_pipe *snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture, int monitoring); +int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr, struct mixart_pipe *pipe, int monitoring); #endif /* __SOUND_MIXART_H */ diff --git a/sound/pci/mixart/mixart_core.c b/sound/pci/mixart/mixart_core.c index ba0027f..07c707d 100644 --- a/sound/pci/mixart/mixart_core.c +++ b/sound/pci/mixart/mixart_core.c @@ -44,7 +44,7 @@ #define MSG_CANCEL_NOTIFY_MASK 0x80000000 /* this bit is set for a notification that has been canceled */ -static int retrieve_msg_frame(mixart_mgr_t *mgr, u32 *msg_frame) +static int retrieve_msg_frame(struct mixart_mgr *mgr, u32 *msg_frame) { /* read the message frame fifo */ u32 headptr, tailptr; @@ -69,7 +69,8 @@ static int retrieve_msg_frame(mixart_mgr_t *mgr, u32 *msg_frame) return 1; } -static int get_msg(mixart_mgr_t *mgr, mixart_msg_t *resp, u32 msg_frame_address ) +static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp, + u32 msg_frame_address ) { unsigned long flags; u32 headptr; @@ -137,8 +138,8 @@ static int get_msg(mixart_mgr_t *mgr, mixart_msg_t *resp, u32 msg_frame_address * send a message to miXart. return: the msg_frame used for this message */ /* call with mgr->msg_lock held! */ -static int send_msg( mixart_mgr_t *mgr, - mixart_msg_t *msg, +static int send_msg( struct mixart_mgr *mgr, + struct mixart_msg *msg, int max_answersize, int mark_pending, u32 *msg_event) @@ -230,9 +231,9 @@ static int send_msg( mixart_mgr_t *mgr, } -int snd_mixart_send_msg(mixart_mgr_t *mgr, mixart_msg_t *request, int max_resp_size, void *resp_data) +int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int max_resp_size, void *resp_data) { - mixart_msg_t resp; + struct mixart_msg resp; u32 msg_frame = 0; /* set to 0, so it's no notification to wait for, but the answer */ int err; wait_queue_t wait; @@ -264,9 +265,9 @@ int snd_mixart_send_msg(mixart_mgr_t *mgr, mixart_msg_t *request, int max_resp_s return -EIO; } - /* retrieve the answer into the same mixart_msg_t */ + /* retrieve the answer into the same struct mixart_msg */ resp.message_id = 0; - resp.uid = (mixart_uid_t){0,0}; + resp.uid = (struct mixart_uid){0,0}; resp.data = resp_data; resp.size = max_resp_size; @@ -280,7 +281,8 @@ int snd_mixart_send_msg(mixart_mgr_t *mgr, mixart_msg_t *request, int max_resp_s } -int snd_mixart_send_msg_wait_notif(mixart_mgr_t *mgr, mixart_msg_t *request, u32 notif_event) +int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr, + struct mixart_msg *request, u32 notif_event) { int err; wait_queue_t wait; @@ -321,7 +323,7 @@ int snd_mixart_send_msg_wait_notif(mixart_mgr_t *mgr, mixart_msg_t *request, u32 } -int snd_mixart_send_msg_nonblock(mixart_mgr_t *mgr, mixart_msg_t *request) +int snd_mixart_send_msg_nonblock(struct mixart_mgr *mgr, struct mixart_msg *request) { u32 message_frame; unsigned long flags; @@ -332,7 +334,7 @@ int snd_mixart_send_msg_nonblock(mixart_mgr_t *mgr, mixart_msg_t *request) err = send_msg(mgr, request, MSG_DEFAULT_SIZE, 0, &message_frame); spin_unlock_irqrestore(&mgr->msg_lock, flags); - /* the answer will be handled by snd_mixart_msg_tasklet() */ + /* the answer will be handled by snd_struct mixart_msgasklet() */ atomic_inc(&mgr->msg_processed); return err; @@ -343,10 +345,10 @@ int snd_mixart_send_msg_nonblock(mixart_mgr_t *mgr, mixart_msg_t *request) static u32 mixart_msg_data[MSG_DEFAULT_SIZE / 4]; -void snd_mixart_msg_tasklet( unsigned long arg) +void snd_mixart_msg_tasklet(unsigned long arg) { - mixart_mgr_t *mgr = ( mixart_mgr_t*)(arg); - mixart_msg_t resp; + struct mixart_mgr *mgr = ( struct mixart_mgr*)(arg); + struct mixart_msg resp; u32 msg, addr, type; int err; @@ -406,9 +408,9 @@ void snd_mixart_msg_tasklet( unsigned long arg) irqreturn_t snd_mixart_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - mixart_mgr_t *mgr = dev_id; + struct mixart_mgr *mgr = dev_id; int err; - mixart_msg_t resp; + struct mixart_msg resp; u32 msg; u32 it_reg; @@ -448,7 +450,8 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id, struct pt_regs *regs) if(resp.message_id == MSG_SERVICES_TIMER_NOTIFY) { int i; - mixart_timer_notify_t *notify = (mixart_timer_notify_t*)mixart_msg_data; + struct mixart_timer_notify *notify; + notify = (struct mixart_timer_notify *)mixart_msg_data; for(i=0; i<notify->stream_count; i++) { @@ -458,8 +461,8 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id, struct pt_regs *regs) unsigned int sub_number = buffer_id & MIXART_NOTIFY_SUBS_MASK; /* 0 to MIXART_PLAYBACK_STREAMS */ unsigned int is_capture = ((buffer_id & MIXART_NOTIFY_CAPT_MASK) != 0); /* playback == 0 / capture == 1 */ - mixart_t *chip = mgr->chip[chip_number]; - mixart_stream_t *stream; + struct snd_mixart *chip = mgr->chip[chip_number]; + struct mixart_stream *stream; if ((chip_number >= mgr->num_cards) || (pcm_number >= MIXART_PCM_TOTAL) || (sub_number >= MIXART_PLAYBACK_STREAMS)) { snd_printk(KERN_ERR "error MSG_SERVICES_TIMER_NOTIFY buffer_id (%x) pos(%d)\n", @@ -473,7 +476,7 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id, struct pt_regs *regs) stream = &chip->playback_stream[pcm_number][sub_number]; if (stream->substream && (stream->status == MIXART_STREAM_STATUS_RUNNING)) { - snd_pcm_runtime_t *runtime = stream->substream->runtime; + struct snd_pcm_runtime *runtime = stream->substream->runtime; int elapsed = 0; u64 sample_count = ((u64)notify->streams[i].sample_pos_high_part) << 32; sample_count |= notify->streams[i].sample_pos_low_part; @@ -561,7 +564,7 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id, struct pt_regs *regs) } -void snd_mixart_init_mailbox(mixart_mgr_t *mgr) +void snd_mixart_init_mailbox(struct mixart_mgr *mgr) { writel( 0, MIXART_MEM( mgr, MSG_HOST_RSC_PROTECTION ) ); writel( 0, MIXART_MEM( mgr, MSG_AGENT_RSC_PROTECTION ) ); @@ -573,14 +576,14 @@ void snd_mixart_init_mailbox(mixart_mgr_t *mgr) return; } -void snd_mixart_exit_mailbox(mixart_mgr_t *mgr) +void snd_mixart_exit_mailbox(struct mixart_mgr *mgr) { /* no more interrupts on outbound messagebox */ writel_le( MIXART_HOST_ALL_INTERRUPT_MASKED, MIXART_REG( mgr, MIXART_PCI_OMIMR_OFFSET)); return; } -void snd_mixart_reset_board(mixart_mgr_t *mgr) +void snd_mixart_reset_board(struct mixart_mgr *mgr) { /* reset miXart */ writel_be( 1, MIXART_REG(mgr, MIXART_BA1_BRUTAL_RESET_OFFSET) ); diff --git a/sound/pci/mixart/mixart_core.h b/sound/pci/mixart/mixart_core.h index 99450eb..1fe2bcf 100644 --- a/sound/pci/mixart/mixart_core.h +++ b/sound/pci/mixart/mixart_core.h @@ -63,25 +63,23 @@ enum mixart_message_id { }; -typedef struct mixart_msg mixart_msg_t; struct mixart_msg { u32 message_id; - mixart_uid_t uid; + struct mixart_uid uid; void* data; size_t size; }; /* structs used to communicate with miXart */ -typedef struct mixart_enum_connector_resp mixart_enum_connector_resp_t; struct mixart_enum_connector_resp { u32 error_code; u32 first_uid_offset; u32 uid_count; u32 current_uid_index; - mixart_uid_t uid[MIXART_MAX_PHYS_CONNECTORS]; + struct mixart_uid uid[MIXART_MAX_PHYS_CONNECTORS]; } __attribute__((packed)); @@ -90,7 +88,6 @@ struct mixart_enum_connector_resp #define MIXART_FLOAT_M_20_0_TO_HEX 0xc1a00000 /* -20.0f */ #define MIXART_FLOAT____0_0_TO_HEX 0x00000000 /* 0.0f */ -typedef struct mixart_audio_info_req mixart_audio_info_req_t; struct mixart_audio_info_req { u32 line_max_level; /* float */ @@ -98,7 +95,6 @@ struct mixart_audio_info_req u32 cd_max_level; /* float */ } __attribute__((packed)); -typedef struct mixart_analog_hw_info mixart_analog_hw_info_t; struct mixart_analog_hw_info { u32 is_present; @@ -111,7 +107,6 @@ struct mixart_analog_hw_info u32 zero_var; /* float */ } __attribute__((packed)); -typedef struct mixart_digital_hw_info mixart_digital_hw_info_t; struct mixart_digital_hw_info { u32 hw_connection_type; @@ -120,37 +115,33 @@ struct mixart_digital_hw_info u32 reserved; } __attribute__((packed)); -typedef struct mixart_analog_info mixart_analog_info_t; struct mixart_analog_info { u32 type_mask; - mixart_analog_hw_info_t micro_info; - mixart_analog_hw_info_t line_info; - mixart_analog_hw_info_t cd_info; + struct mixart_analog_hw_info micro_info; + struct mixart_analog_hw_info line_info; + struct mixart_analog_hw_info cd_info; u32 analog_level_present; } __attribute__((packed)); -typedef struct mixart_digital_info mixart_digital_info_t; struct mixart_digital_info { u32 type_mask; - mixart_digital_hw_info_t aes_info; - mixart_digital_hw_info_t adat_info; + struct mixart_digital_hw_info aes_info; + struct mixart_digital_hw_info adat_info; } __attribute__((packed)); -typedef struct mixart_audio_info mixart_audio_info_t; struct mixart_audio_info { u32 clock_type_mask; - mixart_analog_info_t analog_info; - mixart_digital_info_t digital_info; + struct mixart_analog_info analog_info; + struct mixart_digital_info digital_info; } __attribute__((packed)); -typedef struct mixart_audio_info_resp mixart_audio_info_resp_t; struct mixart_audio_info_resp { u32 txx_status; - mixart_audio_info_t info; + struct mixart_audio_info info; } __attribute__((packed)); @@ -158,7 +149,6 @@ struct mixart_audio_info_resp #define MIXART_FLOAT_P__4_0_TO_HEX 0x40800000 /* +4.0f */ #define MIXART_FLOAT_P__8_0_TO_HEX 0x41000000 /* +8.0f */ -typedef struct mixart_stream_info mixart_stream_info_t; struct mixart_stream_info { u32 size_max_byte_frame; @@ -169,7 +159,6 @@ struct mixart_stream_info /* MSG_STREAM_ADD_INPUT_GROUP */ /* MSG_STREAM_ADD_OUTPUT_GROUP */ -typedef struct mixart_streaming_group_req mixart_streaming_group_req_t; struct mixart_streaming_group_req { u32 stream_count; @@ -177,33 +166,30 @@ struct mixart_streaming_group_req u32 user_grp_number; u32 first_phys_audio; u32 latency; - mixart_stream_info_t stream_info[32]; - mixart_uid_t connector; + struct mixart_stream_info stream_info[32]; + struct mixart_uid connector; u32 flow_entry[32]; } __attribute__((packed)); -typedef struct mixart_stream_desc mixart_stream_desc_t; struct mixart_stream_desc { - mixart_uid_t stream_uid; + struct mixart_uid stream_uid; u32 stream_desc; } __attribute__((packed)); -typedef struct mixart_streaming_group mixart_streaming_group_t; struct mixart_streaming_group { u32 status; - mixart_uid_t group; + struct mixart_uid group; u32 pipe_desc; u32 stream_count; - mixart_stream_desc_t stream[32]; + struct mixart_stream_desc stream[32]; } __attribute__((packed)); /* MSG_STREAM_DELETE_GROUP */ /* request : mixart_uid_t group */ -typedef struct mixart_delete_group_resp mixart_delete_group_resp_t; struct mixart_delete_group_resp { u32 status; @@ -217,55 +203,49 @@ struct mixart_delete_group_resp MSG_STREAM_STOP_OUTPUT_STAGE_PACKET = 0x130000 + 11, */ -typedef struct mixart_fx_couple_uid mixart_fx_couple_uid_t; struct mixart_fx_couple_uid { - mixart_uid_t uid_fx_code; - mixart_uid_t uid_fx_data; + struct mixart_uid uid_fx_code; + struct mixart_uid uid_fx_data; } __attribute__((packed)); -typedef struct mixart_txx_stream_desc mixart_txx_stream_desc_t; struct mixart_txx_stream_desc { - mixart_uid_t uid_pipe; + struct mixart_uid uid_pipe; u32 stream_idx; u32 fx_number; - mixart_fx_couple_uid_t uid_fx[4]; + struct mixart_fx_couple_uid uid_fx[4]; } __attribute__((packed)); -typedef struct mixart_flow_info mixart_flow_info_t; struct mixart_flow_info { - mixart_txx_stream_desc_t stream_desc; + struct mixart_txx_stream_desc stream_desc; u32 flow_entry; u32 flow_phy_addr; } __attribute__((packed)); -typedef struct mixart_stream_state_req mixart_stream_state_req_t; struct mixart_stream_state_req { u32 delayed; u64 scheduler; u32 reserved4np[3]; u32 stream_count; /* set to 1 for instance */ - mixart_flow_info_t stream_info; /* could be an array[stream_count] */ + struct mixart_flow_info stream_info; /* could be an array[stream_count] */ } __attribute__((packed)); /* MSG_STREAM_START_STREAM_GRP_PACKET = 0x130000 + 6 MSG_STREAM_STOP_STREAM_GRP_PACKET = 0x130000 + 9 */ -typedef struct mixart_group_state_req mixart_group_state_req_t; struct mixart_group_state_req { u32 delayed; u64 scheduler; u32 reserved4np[2]; u32 pipe_count; /* set to 1 for instance */ - mixart_uid_t pipe_uid[1]; /* could be an array[pipe_count] */ + struct mixart_uid pipe_uid[1]; /* could be an array[pipe_count] */ } __attribute__((packed)); -typedef struct mixart_group_state_resp mixart_group_state_resp_t; struct mixart_group_state_resp { u32 txx_status; @@ -276,7 +256,6 @@ struct mixart_group_state_resp /* Structures used by the MSG_SERVICES_TIMER_NOTIFY command */ -typedef struct mixart_sample_pos mixart_sample_pos_t; struct mixart_sample_pos { u32 buffer_id; @@ -285,11 +264,10 @@ struct mixart_sample_pos u32 sample_pos_low_part; } __attribute__((packed)); -typedef struct mixart_timer_notify mixart_timer_notify_t; struct mixart_timer_notify { u32 stream_count; - mixart_sample_pos_t streams[MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS]; + struct mixart_sample_pos streams[MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS]; } __attribute__((packed)); @@ -298,11 +276,10 @@ struct mixart_timer_notify /* request is a uid with desc = MSG_CONSOLE_MANAGER | cardindex */ -typedef struct mixart_return_uid mixart_return_uid_t; struct mixart_return_uid { u32 error_code; - mixart_uid_t uid; + struct mixart_uid uid; } __attribute__((packed)); /* MSG_CLOCK_CHECK_PROPERTIES = 0x200001, @@ -327,7 +304,6 @@ enum mixart_clock_mode { }; -typedef struct mixart_clock_properties mixart_clock_properties_t; struct mixart_clock_properties { u32 error_code; @@ -336,17 +312,16 @@ struct mixart_clock_properties u32 reference_frequency; u32 clock_generic_type; u32 clock_mode; - mixart_uid_t uid_clock_source; - mixart_uid_t uid_event_source; + struct mixart_uid uid_clock_source; + struct mixart_uid uid_event_source; u32 event_mode; u32 synchro_signal_presence; u32 format; u32 board_mask; u32 nb_callers; /* set to 1 (see below) */ - mixart_uid_t uid_caller[1]; + struct mixart_uid uid_caller[1]; } __attribute__((packed)); -typedef struct mixart_clock_properties_resp mixart_clock_properties_resp_t; struct mixart_clock_properties_resp { u32 status; @@ -388,7 +363,6 @@ enum mixart_sample_type { ST_INTEGER_32LE }; -typedef struct mixart_stream_param_desc mixart_stream_param_desc_t; struct mixart_stream_param_desc { u32 coding_type; /* use enum mixart_coding_type */ @@ -432,7 +406,7 @@ struct mixart_stream_param_desc u32 reserved4np[3]; u32 pipe_count; /* set to 1 (array size !) */ u32 stream_count; /* set to 1 (array size !) */ - mixart_txx_stream_desc_t stream_desc[1]; /* only one stream per command, but this could be an array */ + struct mixart_txx_stream_desc stream_desc[1]; /* only one stream per command, but this could be an array */ } __attribute__((packed)); @@ -441,7 +415,6 @@ struct mixart_stream_param_desc */ -typedef struct mixart_get_out_audio_level mixart_get_out_audio_level_t; struct mixart_get_out_audio_level { u32 txx_status; @@ -465,7 +438,6 @@ struct mixart_get_out_audio_level #define MIXART_AUDIO_LEVEL_MUTE_M1_MASK 0x10 #define MIXART_AUDIO_LEVEL_MUTE_M2_MASK 0x20 -typedef struct mixart_set_out_audio_level mixart_set_out_audio_level_t; struct mixart_set_out_audio_level { u32 delayed; @@ -487,14 +459,13 @@ struct mixart_set_out_audio_level #define MIXART_MAX_PHYS_IO (MIXART_MAX_CARDS * 2 * 2) /* 4 * (analog+digital) * (playback+capture) */ -typedef struct mixart_uid_enumeration mixart_uid_enumeration_t; struct mixart_uid_enumeration { u32 error_code; u32 first_uid_offset; u32 nb_uid; u32 current_uid_index; - mixart_uid_t uid[MIXART_MAX_PHYS_IO]; + struct mixart_uid uid[MIXART_MAX_PHYS_IO]; } __attribute__((packed)); @@ -502,42 +473,38 @@ struct mixart_uid_enumeration MSG_PHYSICALIO_GET_LEVEL = 0x0F000C, */ -typedef struct mixart_io_channel_level mixart_io_channel_level_t; struct mixart_io_channel_level { u32 analog_level; /* float */ u32 unused[2]; } __attribute__((packed)); -typedef struct mixart_io_level mixart_io_level_t; struct mixart_io_level { s32 channel; /* 0=left, 1=right, -1=both, -2=both same */ - mixart_io_channel_level_t level[2]; + struct mixart_io_channel_level level[2]; } __attribute__((packed)); /* MSG_STREAM_SET_IN_AUDIO_LEVEL = 0x130015, */ -typedef struct mixart_in_audio_level_info mixart_in_audio_level_info_t; struct mixart_in_audio_level_info { - mixart_uid_t connector; + struct mixart_uid connector; u32 valid_mask1; u32 valid_mask2; u32 digital_level; u32 analog_level; } __attribute__((packed)); -typedef struct mixart_set_in_audio_level_req mixart_set_in_audio_level_req_t; struct mixart_set_in_audio_level_req { u32 delayed; u64 scheduler; u32 audio_count; /* set to <= 2 */ u32 reserved4np; - mixart_in_audio_level_info_t level[2]; + struct mixart_in_audio_level_info level[2]; } __attribute__((packed)); /* response is a 32 bit status */ @@ -556,7 +523,6 @@ struct mixart_set_in_audio_level_req #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_1 0x40 #define MIXART_OUT_STREAM_SET_LEVEL_MUTE_2 0x80 -typedef struct mixart_out_stream_level_info mixart_out_stream_level_info_t; struct mixart_out_stream_level_info { u32 valid_mask1; @@ -571,37 +537,35 @@ struct mixart_out_stream_level_info u32 mute2; } __attribute__((packed)); -typedef struct mixart_set_out_stream_level mixart_set_out_stream_level_t; struct mixart_set_out_stream_level { - mixart_txx_stream_desc_t desc; - mixart_out_stream_level_info_t out_level; + struct mixart_txx_stream_desc desc; + struct mixart_out_stream_level_info out_level; } __attribute__((packed)); -typedef struct mixart_set_out_stream_level_req mixart_set_out_stream_level_req_t; struct mixart_set_out_stream_level_req { u32 delayed; u64 scheduler; u32 reserved4np[2]; u32 nb_of_stream; /* set to 1 */ - mixart_set_out_stream_level_t stream_level; /* could be an array */ + struct mixart_set_out_stream_level stream_level; /* could be an array */ } __attribute__((packed)); /* response to this request is a u32 status value */ /* exported */ -void snd_mixart_init_mailbox(mixart_mgr_t *mgr); -void snd_mixart_exit_mailbox(mixart_mgr_t *mgr); +void snd_mixart_init_mailbox(struct mixart_mgr *mgr); +void snd_mixart_exit_mailbox(struct mixart_mgr *mgr); -int snd_mixart_send_msg(mixart_mgr_t *mgr, mixart_msg_t *request, int max_resp_size, void *resp_data); -int snd_mixart_send_msg_wait_notif(mixart_mgr_t *mgr, mixart_msg_t *request, u32 notif_event); -int snd_mixart_send_msg_nonblock(mixart_mgr_t *mgr, mixart_msg_t *request); +int snd_mixart_send_msg(struct mixart_mgr *mgr, struct mixart_msg *request, int max_resp_size, void *resp_data); +int snd_mixart_send_msg_wait_notif(struct mixart_mgr *mgr, struct mixart_msg *request, u32 notif_event); +int snd_mixart_send_msg_nonblock(struct mixart_mgr *mgr, struct mixart_msg *request); irqreturn_t snd_mixart_interrupt(int irq, void *dev_id, struct pt_regs *regs); -void snd_mixart_msg_tasklet( unsigned long arg); +void snd_mixart_msg_tasklet(unsigned long arg); -void snd_mixart_reset_board(mixart_mgr_t *mgr); +void snd_mixart_reset_board(struct mixart_mgr *mgr); #endif /* __SOUND_MIXART_CORE_H */ diff --git a/sound/pci/mixart/mixart_hwdep.c b/sound/pci/mixart/mixart_hwdep.c index edd1599..ca05075 100644 --- a/sound/pci/mixart/mixart_hwdep.c +++ b/sound/pci/mixart/mixart_hwdep.c @@ -40,7 +40,9 @@ * @param value value * @param timeout timeout in centisenconds */ -static int mixart_wait_nice_for_register_value(mixart_mgr_t *mgr, u32 offset, int is_egal, u32 value, unsigned long timeout) +static int mixart_wait_nice_for_register_value(struct mixart_mgr *mgr, + u32 offset, int is_egal, + u32 value, unsigned long timeout) { unsigned long end_time = jiffies + (timeout * HZ / 100); u32 read; @@ -66,8 +68,6 @@ static int mixart_wait_nice_for_register_value(mixart_mgr_t *mgr, u32 offset, in /* structures needed to upload elf code packets */ -typedef struct snd_mixart_elf32_ehdr snd_mixart_elf32_ehdr_t; - struct snd_mixart_elf32_ehdr { u8 e_ident[16]; u16 e_type; @@ -85,8 +85,6 @@ struct snd_mixart_elf32_ehdr { u16 e_shstrndx; }; -typedef struct snd_mixart_elf32_phdr snd_mixart_elf32_phdr_t; - struct snd_mixart_elf32_phdr { u32 p_type; u32 p_offset; @@ -98,19 +96,19 @@ struct snd_mixart_elf32_phdr { u32 p_align; }; -static int mixart_load_elf(mixart_mgr_t *mgr, const struct firmware *dsp ) +static int mixart_load_elf(struct mixart_mgr *mgr, const struct firmware *dsp ) { char elf32_magic_number[4] = {0x7f,'E','L','F'}; - snd_mixart_elf32_ehdr_t *elf_header; + struct snd_mixart_elf32_ehdr *elf_header; int i; - elf_header = (snd_mixart_elf32_ehdr_t *)dsp->data; + elf_header = (struct snd_mixart_elf32_ehdr *)dsp->data; for( i=0; i<4; i++ ) if ( elf32_magic_number[i] != elf_header->e_ident[i] ) return -EINVAL; if( elf_header->e_phoff != 0 ) { - snd_mixart_elf32_phdr_t elf_programheader; + struct snd_mixart_elf32_phdr elf_programheader; for( i=0; i < be16_to_cpu(elf_header->e_phnum); i++ ) { u32 pos = be32_to_cpu(elf_header->e_phoff) + (u32)(i * be16_to_cpu(elf_header->e_phentsize)); @@ -137,14 +135,14 @@ static int mixart_load_elf(mixart_mgr_t *mgr, const struct firmware *dsp ) #define MIXART_FIRST_ANA_AUDIO_ID 0 #define MIXART_FIRST_DIG_AUDIO_ID 8 -static int mixart_enum_connectors(mixart_mgr_t *mgr) +static int mixart_enum_connectors(struct mixart_mgr *mgr) { u32 k; int err; - mixart_msg_t request; - mixart_enum_connector_resp_t *connector; - mixart_audio_info_req_t *audio_info_req; - mixart_audio_info_resp_t *audio_info; + struct mixart_msg request; + struct mixart_enum_connector_resp *connector; + struct mixart_audio_info_req *audio_info_req; + struct mixart_audio_info_resp *audio_info; connector = kmalloc(sizeof(*connector), GFP_KERNEL); audio_info_req = kmalloc(sizeof(*audio_info_req), GFP_KERNEL); @@ -159,7 +157,7 @@ static int mixart_enum_connectors(mixart_mgr_t *mgr) audio_info_req->cd_max_level = MIXART_FLOAT____0_0_TO_HEX; request.message_id = MSG_SYSTEM_ENUM_PLAY_CONNECTOR; - request.uid = (mixart_uid_t){0,0}; /* board num = 0 */ + request.uid = (struct mixart_uid){0,0}; /* board num = 0 */ request.data = NULL; request.size = 0; @@ -171,7 +169,7 @@ static int mixart_enum_connectors(mixart_mgr_t *mgr) } for(k=0; k < connector->uid_count; k++) { - mixart_pipe_t* pipe; + struct mixart_pipe *pipe; if(k < MIXART_FIRST_DIG_AUDIO_ID) { pipe = &mgr->chip[k/2]->pipe_out_ana; @@ -201,7 +199,7 @@ static int mixart_enum_connectors(mixart_mgr_t *mgr) } request.message_id = MSG_SYSTEM_ENUM_RECORD_CONNECTOR; - request.uid = (mixart_uid_t){0,0}; /* board num = 0 */ + request.uid = (struct mixart_uid){0,0}; /* board num = 0 */ request.data = NULL; request.size = 0; @@ -213,7 +211,7 @@ static int mixart_enum_connectors(mixart_mgr_t *mgr) } for(k=0; k < connector->uid_count; k++) { - mixart_pipe_t* pipe; + struct mixart_pipe *pipe; if(k < MIXART_FIRST_DIG_AUDIO_ID) { pipe = &mgr->chip[k/2]->pipe_in_ana; @@ -251,14 +249,14 @@ static int mixart_enum_connectors(mixart_mgr_t *mgr) return err; } -static int mixart_enum_physio(mixart_mgr_t *mgr) +static int mixart_enum_physio(struct mixart_mgr *mgr) { u32 k; int err; - mixart_msg_t request; - mixart_uid_t get_console_mgr; - mixart_return_uid_t console_mgr; - mixart_uid_enumeration_t phys_io; + struct mixart_msg request; + struct mixart_uid get_console_mgr; + struct mixart_return_uid console_mgr; + struct mixart_uid_enumeration phys_io; /* get the uid for the console manager */ get_console_mgr.object_id = 0; @@ -280,7 +278,7 @@ static int mixart_enum_physio(mixart_mgr_t *mgr) mgr->uid_console_manager = console_mgr.uid; request.message_id = MSG_SYSTEM_ENUM_PHYSICAL_IO; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = &console_mgr.uid; request.size = sizeof(console_mgr.uid); @@ -301,11 +299,11 @@ static int mixart_enum_physio(mixart_mgr_t *mgr) } -static int mixart_first_init(mixart_mgr_t *mgr) +static int mixart_first_init(struct mixart_mgr *mgr) { u32 k; int err; - mixart_msg_t request; + struct mixart_msg request; if((err = mixart_enum_connectors(mgr)) < 0) return err; @@ -314,7 +312,7 @@ static int mixart_first_init(mixart_mgr_t *mgr) /* send a synchro command to card (necessary to do this before first MSG_STREAM_START_STREAM_GRP_PACKET) */ /* though why not here */ request.message_id = MSG_SYSTEM_SEND_SYNCHRO_CMD; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = NULL; request.size = 0; /* this command has no data. response is a 32 bit status */ @@ -331,7 +329,7 @@ static int mixart_first_init(mixart_mgr_t *mgr) /* firmware base addresses (when hard coded) */ #define MIXART_MOTHERBOARD_XLX_BASE_ADDRESS 0x00600000 -static int mixart_dsp_load(mixart_mgr_t* mgr, int index, const struct firmware *dsp) +static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmware *dsp) { int err, card_index; u32 status_xilinx, status_elf, status_daught; @@ -513,7 +511,7 @@ static int mixart_dsp_load(mixart_mgr_t* mgr, int index, const struct firmware * /* create devices and mixer in accordance with HW options*/ for (card_index = 0; card_index < mgr->num_cards; card_index++) { - mixart_t *chip = mgr->chip[card_index]; + struct snd_mixart *chip = mgr->chip[card_index]; if ((err = snd_mixart_create_pcm(chip)) < 0) return err; @@ -541,7 +539,7 @@ static int mixart_dsp_load(mixart_mgr_t* mgr, int index, const struct firmware * #ifdef SND_MIXART_FW_LOADER -int snd_mixart_setup_firmware(mixart_mgr_t *mgr) +int snd_mixart_setup_firmware(struct mixart_mgr *mgr) { static char *fw_files[3] = { "miXart8.xlx", "miXart8.elf", "miXart8AES.xlx" @@ -573,19 +571,20 @@ int snd_mixart_setup_firmware(mixart_mgr_t *mgr) /* miXart hwdep interface id string */ #define SND_MIXART_HWDEP_ID "miXart Loader" -static int mixart_hwdep_open(snd_hwdep_t *hw, struct file *file) +static int mixart_hwdep_open(struct snd_hwdep *hw, struct file *file) { return 0; } -static int mixart_hwdep_release(snd_hwdep_t *hw, struct file *file) +static int mixart_hwdep_release(struct snd_hwdep *hw, struct file *file) { return 0; } -static int mixart_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *info) +static int mixart_hwdep_dsp_status(struct snd_hwdep *hw, + struct snd_hwdep_dsp_status *info) { - mixart_mgr_t *mgr = hw->private_data; + struct mixart_mgr *mgr = hw->private_data; strcpy(info->id, "miXart"); info->num_dsps = MIXART_HARDW_FILES_MAX_INDEX; @@ -597,9 +596,10 @@ static int mixart_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *info return 0; } -static int mixart_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) +static int mixart_hwdep_dsp_load(struct snd_hwdep *hw, + struct snd_hwdep_dsp_image *dsp) { - mixart_mgr_t* mgr = hw->private_data; + struct mixart_mgr* mgr = hw->private_data; struct firmware fw; int err; @@ -622,10 +622,10 @@ static int mixart_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) return err; } -int snd_mixart_setup_firmware(mixart_mgr_t *mgr) +int snd_mixart_setup_firmware(struct mixart_mgr *mgr) { int err; - snd_hwdep_t *hw; + struct snd_hwdep *hw; /* only create hwdep interface for first cardX (see "index" module parameter)*/ if ((err = snd_hwdep_new(mgr->chip[0]->card, SND_MIXART_HWDEP_ID, 0, &hw)) < 0) diff --git a/sound/pci/mixart/mixart_hwdep.h b/sound/pci/mixart/mixart_hwdep.h index 25190cc..a46f508 100644 --- a/sound/pci/mixart/mixart_hwdep.h +++ b/sound/pci/mixart/mixart_hwdep.h @@ -140,6 +140,6 @@ #define MIXART_OIDI 0x008 /* 0000 0000 1000 */ -int snd_mixart_setup_firmware(mixart_mgr_t *mgr); +int snd_mixart_setup_firmware(struct mixart_mgr *mgr); #endif /* __SOUND_MIXART_HWDEP_H */ diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c index 39c1541..36a7e9d 100644 --- a/sound/pci/mixart/mixart_mixer.c +++ b/sound/pci/mixart/mixart_mixer.c @@ -298,12 +298,12 @@ static u32 mixart_analog_level[256] = { #define MIXART_ANALOG_PLAYBACK_LEVEL_MAX 192 /* 0.0 dB + 1.5 dB = 1.5 dB */ #define MIXART_ANALOG_PLAYBACK_ZERO_LEVEL 189 /* -1.5 dB + 1.5 dB = 0.0 dB */ -static int mixart_update_analog_audio_level(mixart_t* chip, int is_capture) +static int mixart_update_analog_audio_level(struct snd_mixart* chip, int is_capture) { int i, err; - mixart_msg_t request; - mixart_io_level_t io_level; - mixart_return_uid_t resp; + struct mixart_msg request; + struct mixart_io_level io_level; + struct mixart_return_uid resp; memset(&io_level, 0, sizeof(io_level)); io_level.channel = -1; /* left and right */ @@ -336,7 +336,7 @@ static int mixart_update_analog_audio_level(mixart_t* chip, int is_capture) /* * analog level control */ -static int mixart_analog_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int mixart_analog_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -350,9 +350,9 @@ static int mixart_analog_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int mixart_analog_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_analog_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); down(&chip->mgr->mixer_mutex); if(kcontrol->private_value == 0) { /* playback */ ucontrol->value.integer.value[0] = chip->analog_playback_volume[0]; @@ -365,9 +365,9 @@ static int mixart_analog_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int mixart_analog_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_analog_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); int changed = 0; int is_capture, i; @@ -386,7 +386,7 @@ static int mixart_analog_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return changed; } -static snd_kcontrol_new_t mixart_control_analog_level = { +static struct snd_kcontrol_new mixart_control_analog_level = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, /* name will be filled later */ .info = mixart_analog_vol_info, @@ -395,7 +395,7 @@ static snd_kcontrol_new_t mixart_control_analog_level = { }; /* shared */ -static int mixart_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int mixart_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -404,9 +404,9 @@ static int mixart_sw_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -static int mixart_audio_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_audio_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); down(&chip->mgr->mixer_mutex); ucontrol->value.integer.value[0] = chip->analog_playback_active[0]; @@ -415,9 +415,9 @@ static int mixart_audio_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u return 0; } -static int mixart_audio_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_audio_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); int i, changed = 0; down(&chip->mgr->mixer_mutex); for(i=0; i<2; i++) { @@ -431,7 +431,7 @@ static int mixart_audio_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u return changed; } -static snd_kcontrol_new_t mixart_control_output_switch = { +static struct snd_kcontrol_new mixart_control_output_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Switch", .info = mixart_sw_info, /* shared */ @@ -703,14 +703,14 @@ static u32 mixart_digital_level[256] = { #define MIXART_DIGITAL_ZERO_LEVEL 219 /* 0.0 dB */ -int mixart_update_playback_stream_level(mixart_t* chip, int is_aes, int idx) +int mixart_update_playback_stream_level(struct snd_mixart* chip, int is_aes, int idx) { int err, i; int volume[2]; - mixart_msg_t request; - mixart_set_out_stream_level_req_t set_level; + struct mixart_msg request; + struct mixart_set_out_stream_level_req set_level; u32 status; - mixart_pipe_t *pipe; + struct mixart_pipe *pipe; memset(&set_level, 0, sizeof(set_level)); set_level.nb_of_stream = 1; @@ -741,7 +741,7 @@ int mixart_update_playback_stream_level(mixart_t* chip, int is_aes, int idx) set_level.stream_level.out_level.right_to_out2_level = mixart_digital_level[volume[1]]; request.message_id = MSG_STREAM_SET_OUT_STREAM_LEVEL; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = &set_level; request.size = sizeof(set_level); @@ -753,12 +753,12 @@ int mixart_update_playback_stream_level(mixart_t* chip, int is_aes, int idx) return 0; } -int mixart_update_capture_stream_level(mixart_t* chip, int is_aes) +int mixart_update_capture_stream_level(struct snd_mixart* chip, int is_aes) { int err, i, idx; - mixart_pipe_t* pipe; - mixart_msg_t request; - mixart_set_in_audio_level_req_t set_level; + struct mixart_pipe *pipe; + struct mixart_msg request; + struct mixart_set_in_audio_level_req set_level; u32 status; if(is_aes) { @@ -784,7 +784,7 @@ int mixart_update_capture_stream_level(mixart_t* chip, int is_aes) } request.message_id = MSG_STREAM_SET_IN_AUDIO_LEVEL; - request.uid = (mixart_uid_t){0,0}; + request.uid = (struct mixart_uid){0,0}; request.data = &set_level; request.size = sizeof(set_level); @@ -798,7 +798,7 @@ int mixart_update_capture_stream_level(mixart_t* chip, int is_aes) /* shared */ -static int mixart_digital_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int mixart_digital_vol_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -810,9 +810,9 @@ static int mixart_digital_vol_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t #define MIXART_VOL_REC_MASK 1 #define MIXART_VOL_AES_MASK 2 -static int mixart_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_pcm_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ int *stored_volume; int is_capture = kcontrol->private_value & MIXART_VOL_REC_MASK; @@ -832,9 +832,9 @@ static int mixart_pcm_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc return 0; } -static int mixart_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_pcm_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ int changed = 0; int is_capture = kcontrol->private_value & MIXART_VOL_REC_MASK; @@ -864,7 +864,7 @@ static int mixart_pcm_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc return changed; } -static snd_kcontrol_new_t snd_mixart_pcm_vol = +static struct snd_kcontrol_new snd_mixart_pcm_vol = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, /* name will be filled later */ @@ -875,9 +875,9 @@ static snd_kcontrol_new_t snd_mixart_pcm_vol = }; -static int mixart_pcm_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_pcm_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ snd_assert ( idx < MIXART_PLAYBACK_STREAMS ); down(&chip->mgr->mixer_mutex); @@ -889,9 +889,9 @@ static int mixart_pcm_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return 0; } -static int mixart_pcm_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); int changed = 0; int is_aes = kcontrol->private_value & MIXART_VOL_AES_MASK; int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ @@ -911,7 +911,7 @@ static int mixart_pcm_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return changed; } -static snd_kcontrol_new_t mixart_control_pcm_switch = { +static struct snd_kcontrol_new mixart_control_pcm_switch = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, /* name will be filled later */ .count = MIXART_PLAYBACK_STREAMS, @@ -920,11 +920,11 @@ static snd_kcontrol_new_t mixart_control_pcm_switch = { .put = mixart_pcm_sw_put }; -static int mixart_update_monitoring(mixart_t* chip, int channel) +static int mixart_update_monitoring(struct snd_mixart* chip, int channel) { int err; - mixart_msg_t request; - mixart_set_out_audio_level_t audio_level; + struct mixart_msg request; + struct mixart_set_out_audio_level audio_level; u32 resp; if(chip->pipe_out_ana.status == PIPE_UNDEFINED) @@ -953,9 +953,9 @@ static int mixart_update_monitoring(mixart_t* chip, int channel) * monitoring level control */ -static int mixart_monitor_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_monitor_vol_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); down(&chip->mgr->mixer_mutex); ucontrol->value.integer.value[0] = chip->monitoring_volume[0]; ucontrol->value.integer.value[1] = chip->monitoring_volume[1]; @@ -963,9 +963,9 @@ static int mixart_monitor_vol_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int mixart_monitor_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_monitor_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); int changed = 0; int i; down(&chip->mgr->mixer_mutex); @@ -980,7 +980,7 @@ static int mixart_monitor_vol_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return changed; } -static snd_kcontrol_new_t mixart_control_monitor_vol = { +static struct snd_kcontrol_new mixart_control_monitor_vol = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Monitoring Volume", .info = mixart_digital_vol_info, /* shared */ @@ -992,9 +992,9 @@ static snd_kcontrol_new_t mixart_control_monitor_vol = { * monitoring switch control */ -static int mixart_monitor_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_monitor_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); down(&chip->mgr->mixer_mutex); ucontrol->value.integer.value[0] = chip->monitoring_active[0]; ucontrol->value.integer.value[1] = chip->monitoring_active[1]; @@ -1002,9 +1002,9 @@ static int mixart_monitor_sw_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int mixart_monitor_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixart_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - mixart_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_mixart *chip = snd_kcontrol_chip(kcontrol); int changed = 0; int i; down(&chip->mgr->mixer_mutex); @@ -1033,7 +1033,7 @@ static int mixart_monitor_sw_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return (changed != 0); } -static snd_kcontrol_new_t mixart_control_monitor_sw = { +static struct snd_kcontrol_new mixart_control_monitor_sw = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Monitoring Switch", .info = mixart_sw_info, /* shared */ @@ -1042,7 +1042,7 @@ static snd_kcontrol_new_t mixart_control_monitor_sw = { }; -static void mixart_reset_audio_levels(mixart_t *chip) +static void mixart_reset_audio_levels(struct snd_mixart *chip) { /* analog volumes can be set even if there is no pipe */ mixart_update_analog_audio_level(chip, 0); @@ -1054,15 +1054,15 @@ static void mixart_reset_audio_levels(mixart_t *chip) } -int snd_mixart_create_mixer(mixart_mgr_t *mgr) +int snd_mixart_create_mixer(struct mixart_mgr *mgr) { - mixart_t *chip; + struct snd_mixart *chip; int err, i; init_MUTEX(&mgr->mixer_mutex); /* can be in another place */ for(i=0; i<mgr->num_cards; i++) { - snd_kcontrol_new_t temp; + struct snd_kcontrol_new temp; chip = mgr->chip[i]; /* analog output level control */ diff --git a/sound/pci/mixart/mixart_mixer.h b/sound/pci/mixart/mixart_mixer.h index b4d9535..04aa24e 100644 --- a/sound/pci/mixart/mixart_mixer.h +++ b/sound/pci/mixart/mixart_mixer.h @@ -24,8 +24,8 @@ #define __SOUND_MIXART_MIXER_H /* exported */ -int mixart_update_playback_stream_level(mixart_t* chip, int is_aes, int idx); -int mixart_update_capture_stream_level(mixart_t* chip, int is_aes); -int snd_mixart_create_mixer(mixart_mgr_t* mgr); +int mixart_update_playback_stream_level(struct snd_mixart* chip, int is_aes, int idx); +int mixart_update_capture_stream_level(struct snd_mixart* chip, int is_aes); +int snd_mixart_create_mixer(struct mixart_mgr* mgr); #endif /* __SOUND_MIXART_MIXER_H */ -- cgit v1.1 From 10754f53450a2c2aababe69f20edd7d2077e588d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:01:29 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI NM256 Modules: NM256 driver Remove xxx_t typedefs from the PCI NM256 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/nm256/nm256.c | 250 ++++++++++++++++++++++++------------------------ 1 file changed, 127 insertions(+), 123 deletions(-) diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index a01b3e5..99ec1c1 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -183,17 +183,10 @@ module_param(enable, bool, 0444); #define NM_PBUFFER_WMARK (NM_PLAYBACK_REG_OFFSET + 0xc) #define NM_PBUFFER_CURRP (NM_PLAYBACK_REG_OFFSET + 0x8) -/* - * type definitions - */ - -typedef struct snd_nm256 nm256_t; -typedef struct snd_nm256_stream nm256_stream_t; - -struct snd_nm256_stream { +struct nm256_stream { - nm256_t *chip; - snd_pcm_substream_t *substream; + struct nm256 *chip; + struct snd_pcm_substream *substream; int running; int suspended; @@ -210,9 +203,9 @@ struct snd_nm256_stream { }; -struct snd_nm256 { +struct nm256 { - snd_card_t *card; + struct snd_card *card; void __iomem *cport; /* control port */ struct resource *res_cport; /* its resource */ @@ -244,11 +237,11 @@ struct snd_nm256 { int badintrcount; /* counter to check bogus interrupts */ struct semaphore irq_mutex; - nm256_stream_t streams[2]; + struct nm256_stream streams[2]; - ac97_t *ac97; + struct snd_ac97 *ac97; - snd_pcm_t *pcm; + struct snd_pcm *pcm; struct pci_dev *pci; @@ -281,48 +274,49 @@ MODULE_DEVICE_TABLE(pci, snd_nm256_ids); */ static inline u8 -snd_nm256_readb(nm256_t *chip, int offset) +snd_nm256_readb(struct nm256 *chip, int offset) { return readb(chip->cport + offset); } static inline u16 -snd_nm256_readw(nm256_t *chip, int offset) +snd_nm256_readw(struct nm256 *chip, int offset) { return readw(chip->cport + offset); } static inline u32 -snd_nm256_readl(nm256_t *chip, int offset) +snd_nm256_readl(struct nm256 *chip, int offset) { return readl(chip->cport + offset); } static inline void -snd_nm256_writeb(nm256_t *chip, int offset, u8 val) +snd_nm256_writeb(struct nm256 *chip, int offset, u8 val) { writeb(val, chip->cport + offset); } static inline void -snd_nm256_writew(nm256_t *chip, int offset, u16 val) +snd_nm256_writew(struct nm256 *chip, int offset, u16 val) { writew(val, chip->cport + offset); } static inline void -snd_nm256_writel(nm256_t *chip, int offset, u32 val) +snd_nm256_writel(struct nm256 *chip, int offset, u32 val) { writel(val, chip->cport + offset); } static inline void -snd_nm256_write_buffer(nm256_t *chip, void *src, int offset, int size) +snd_nm256_write_buffer(struct nm256 *chip, void *src, int offset, int size) { offset -= chip->buffer_start; #ifdef CONFIG_SND_DEBUG if (offset < 0 || offset >= chip->buffer_size) { - snd_printk(KERN_ERR "write_buffer invalid offset = %d size = %d\n", offset, size); + snd_printk(KERN_ERR "write_buffer invalid offset = %d size = %d\n", + offset, size); return; } #endif @@ -343,7 +337,7 @@ snd_nm256_get_start_offset(int which) } static void -snd_nm256_load_one_coefficient(nm256_t *chip, int stream, u32 port, int which) +snd_nm256_load_one_coefficient(struct nm256 *chip, int stream, u32 port, int which) { u32 coeff_buf = chip->coeff_buf[stream]; u16 offset = snd_nm256_get_start_offset(which); @@ -358,13 +352,15 @@ snd_nm256_load_one_coefficient(nm256_t *chip, int stream, u32 port, int which) } static void -snd_nm256_load_coefficient(nm256_t *chip, int stream, int number) +snd_nm256_load_coefficient(struct nm256 *chip, int stream, int number) { /* The enable register for the specified engine. */ - u32 poffset = (stream == SNDRV_PCM_STREAM_CAPTURE ? NM_RECORD_ENABLE_REG : NM_PLAYBACK_ENABLE_REG); + u32 poffset = (stream == SNDRV_PCM_STREAM_CAPTURE ? + NM_RECORD_ENABLE_REG : NM_PLAYBACK_ENABLE_REG); u32 addr = NM_COEFF_START_OFFSET; - addr += (stream == SNDRV_PCM_STREAM_CAPTURE ? NM_RECORD_REG_OFFSET : NM_PLAYBACK_REG_OFFSET); + addr += (stream == SNDRV_PCM_STREAM_CAPTURE ? + NM_RECORD_REG_OFFSET : NM_PLAYBACK_REG_OFFSET); if (snd_nm256_readb(chip, poffset) & 1) { snd_printd("NM256: Engine was enabled while loading coefficients!\n"); @@ -400,7 +396,7 @@ snd_nm256_load_coefficient(nm256_t *chip, int stream, int number) static unsigned int samplerates[8] = { 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, }; -static snd_pcm_hw_constraint_list_t constraints_rates = { +static struct snd_pcm_hw_constraint_list constraints_rates = { .count = ARRAY_SIZE(samplerates), .list = samplerates, .mask = 0, @@ -425,9 +421,10 @@ snd_nm256_fixed_rate(unsigned int rate) * set sample rate and format */ static void -snd_nm256_set_format(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t *substream) +snd_nm256_set_format(struct nm256 *chip, struct nm256_stream *s, + struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int rate_index = snd_nm256_fixed_rate(runtime->rate); unsigned char ratebits = (rate_index << 4) & NM_RATE_MASK; @@ -460,12 +457,12 @@ snd_nm256_set_format(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t *subs } /* acquire interrupt */ -static int snd_nm256_acquire_irq(nm256_t *chip) +static int snd_nm256_acquire_irq(struct nm256 *chip) { down(&chip->irq_mutex); if (chip->irq < 0) { if (request_irq(chip->pci->irq, chip->interrupt, SA_INTERRUPT|SA_SHIRQ, - chip->card->driver, (void*)chip)) { + chip->card->driver, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->pci->irq); up(&chip->irq_mutex); return -EBUSY; @@ -478,13 +475,13 @@ static int snd_nm256_acquire_irq(nm256_t *chip) } /* release interrupt */ -static void snd_nm256_release_irq(nm256_t *chip) +static void snd_nm256_release_irq(struct nm256 *chip) { down(&chip->irq_mutex); if (chip->irq_acks > 0) chip->irq_acks--; if (chip->irq_acks == 0 && chip->irq >= 0) { - free_irq(chip->irq, (void*)chip); + free_irq(chip->irq, chip); chip->irq = -1; } up(&chip->irq_mutex); @@ -495,7 +492,7 @@ static void snd_nm256_release_irq(nm256_t *chip) */ /* update the watermark (current period) */ -static void snd_nm256_pcm_mark(nm256_t *chip, nm256_stream_t *s, int reg) +static void snd_nm256_pcm_mark(struct nm256 *chip, struct nm256_stream *s, int reg) { s->cur_period++; s->cur_period %= s->periods; @@ -506,7 +503,8 @@ static void snd_nm256_pcm_mark(nm256_t *chip, nm256_stream_t *s, int reg) #define snd_nm256_capture_mark(chip, s) snd_nm256_pcm_mark(chip, s, NM_RBUFFER_WMARK) static void -snd_nm256_playback_start(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t *substream) +snd_nm256_playback_start(struct nm256 *chip, struct nm256_stream *s, + struct snd_pcm_substream *substream) { /* program buffer pointers */ snd_nm256_writel(chip, NM_PBUFFER_START, s->buf); @@ -522,7 +520,8 @@ snd_nm256_playback_start(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t * } static void -snd_nm256_capture_start(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t *substream) +snd_nm256_capture_start(struct nm256 *chip, struct nm256_stream *s, + struct snd_pcm_substream *substream) { /* program buffer pointers */ snd_nm256_writel(chip, NM_RBUFFER_START, s->buf); @@ -537,7 +536,7 @@ snd_nm256_capture_start(nm256_t *chip, nm256_stream_t *s, snd_pcm_substream_t *s /* Stop the play engine. */ static void -snd_nm256_playback_stop(nm256_t *chip) +snd_nm256_playback_stop(struct nm256 *chip) { /* Shut off sound from both channels. */ snd_nm256_writew(chip, NM_AUDIO_MUTE_REG, @@ -547,17 +546,17 @@ snd_nm256_playback_stop(nm256_t *chip) } static void -snd_nm256_capture_stop(nm256_t *chip) +snd_nm256_capture_stop(struct nm256 *chip) { /* Disable recording engine. */ snd_nm256_writeb(chip, NM_RECORD_ENABLE_REG, 0); } static int -snd_nm256_playback_trigger(snd_pcm_substream_t *substream, int cmd) +snd_nm256_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - nm256_t *chip = snd_pcm_substream_chip(substream); - nm256_stream_t *s = (nm256_stream_t*)substream->runtime->private_data; + struct nm256 *chip = snd_pcm_substream_chip(substream); + struct nm256_stream *s = substream->runtime->private_data; int err = 0; snd_assert(s != NULL, return -ENXIO); @@ -591,10 +590,10 @@ snd_nm256_playback_trigger(snd_pcm_substream_t *substream, int cmd) } static int -snd_nm256_capture_trigger(snd_pcm_substream_t *substream, int cmd) +snd_nm256_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - nm256_t *chip = snd_pcm_substream_chip(substream); - nm256_stream_t *s = (nm256_stream_t*)substream->runtime->private_data; + struct nm256 *chip = snd_pcm_substream_chip(substream); + struct nm256_stream *s = substream->runtime->private_data; int err = 0; snd_assert(s != NULL, return -ENXIO); @@ -627,11 +626,11 @@ snd_nm256_capture_trigger(snd_pcm_substream_t *substream, int cmd) /* * prepare playback/capture channel */ -static int snd_nm256_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_nm256_pcm_prepare(struct snd_pcm_substream *substream) { - nm256_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - nm256_stream_t *s = (nm256_stream_t*)runtime->private_data; + struct nm256 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct nm256_stream *s = runtime->private_data; snd_assert(s, return -ENXIO); s->dma_size = frames_to_bytes(runtime, substream->runtime->buffer_size); @@ -652,10 +651,10 @@ static int snd_nm256_pcm_prepare(snd_pcm_substream_t *substream) * get the current pointer */ static snd_pcm_uframes_t -snd_nm256_playback_pointer(snd_pcm_substream_t * substream) +snd_nm256_playback_pointer(struct snd_pcm_substream *substream) { - nm256_t *chip = snd_pcm_substream_chip(substream); - nm256_stream_t *s = (nm256_stream_t*)substream->runtime->private_data; + struct nm256 *chip = snd_pcm_substream_chip(substream); + struct nm256_stream *s = substream->runtime->private_data; unsigned long curp; snd_assert(s, return 0); @@ -665,10 +664,10 @@ snd_nm256_playback_pointer(snd_pcm_substream_t * substream) } static snd_pcm_uframes_t -snd_nm256_capture_pointer(snd_pcm_substream_t * substream) +snd_nm256_capture_pointer(struct snd_pcm_substream *substream) { - nm256_t *chip = snd_pcm_substream_chip(substream); - nm256_stream_t *s = (nm256_stream_t*)substream->runtime->private_data; + struct nm256 *chip = snd_pcm_substream_chip(substream); + struct nm256_stream *s = substream->runtime->private_data; unsigned long curp; snd_assert(s != NULL, return 0); @@ -684,13 +683,13 @@ snd_nm256_capture_pointer(snd_pcm_substream_t * substream) * silence / copy for playback */ static int -snd_nm256_playback_silence(snd_pcm_substream_t *substream, +snd_nm256_playback_silence(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - snd_pcm_runtime_t *runtime = substream->runtime; - nm256_stream_t *s = (nm256_stream_t*)runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct nm256_stream *s = runtime->private_data; count = frames_to_bytes(runtime, count); pos = frames_to_bytes(runtime, pos); memset_io(s->bufptr + pos, 0, count); @@ -698,14 +697,14 @@ snd_nm256_playback_silence(snd_pcm_substream_t *substream, } static int -snd_nm256_playback_copy(snd_pcm_substream_t *substream, +snd_nm256_playback_copy(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - snd_pcm_runtime_t *runtime = substream->runtime; - nm256_stream_t *s = (nm256_stream_t*)runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct nm256_stream *s = runtime->private_data; count = frames_to_bytes(runtime, count); pos = frames_to_bytes(runtime, pos); if (copy_from_user_toio(s->bufptr + pos, src, count)) @@ -717,14 +716,14 @@ snd_nm256_playback_copy(snd_pcm_substream_t *substream, * copy to user */ static int -snd_nm256_capture_copy(snd_pcm_substream_t *substream, +snd_nm256_capture_copy(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { - snd_pcm_runtime_t *runtime = substream->runtime; - nm256_stream_t *s = (nm256_stream_t*)runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct nm256_stream *s = runtime->private_data; count = frames_to_bytes(runtime, count); pos = frames_to_bytes(runtime, pos); if (copy_to_user_fromio(dst, s->bufptr + pos, count)) @@ -741,9 +740,9 @@ snd_nm256_capture_copy(snd_pcm_substream_t *substream, /* spinlock held! */ static void -snd_nm256_playback_update(nm256_t *chip) +snd_nm256_playback_update(struct nm256 *chip) { - nm256_stream_t *s; + struct nm256_stream *s; s = &chip->streams[SNDRV_PCM_STREAM_PLAYBACK]; if (s->running && s->substream) { @@ -756,9 +755,9 @@ snd_nm256_playback_update(nm256_t *chip) /* spinlock held! */ static void -snd_nm256_capture_update(nm256_t *chip) +snd_nm256_capture_update(struct nm256 *chip) { - nm256_stream_t *s; + struct nm256_stream *s; s = &chip->streams[SNDRV_PCM_STREAM_CAPTURE]; if (s->running && s->substream) { @@ -772,7 +771,7 @@ snd_nm256_capture_update(nm256_t *chip) /* * hardware info */ -static snd_pcm_hardware_t snd_nm256_playback = +static struct snd_pcm_hardware snd_nm256_playback = { .info = SNDRV_PCM_INFO_MMAP_IOMEM |SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -791,7 +790,7 @@ static snd_pcm_hardware_t snd_nm256_playback = .period_bytes_max = 128 * 1024, }; -static snd_pcm_hardware_t snd_nm256_capture = +static struct snd_pcm_hardware snd_nm256_capture = { .info = SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -812,7 +811,8 @@ static snd_pcm_hardware_t snd_nm256_capture = /* set dma transfer size */ -static int snd_nm256_pcm_hw_params(snd_pcm_substream_t *substream, snd_pcm_hw_params_t *hw_params) +static int snd_nm256_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { /* area and addr are already set and unchanged */ substream->runtime->dma_bytes = params_buffer_bytes(hw_params); @@ -822,11 +822,11 @@ static int snd_nm256_pcm_hw_params(snd_pcm_substream_t *substream, snd_pcm_hw_pa /* * open */ -static void snd_nm256_setup_stream(nm256_t *chip, nm256_stream_t *s, - snd_pcm_substream_t *substream, - snd_pcm_hardware_t *hw_ptr) +static void snd_nm256_setup_stream(struct nm256 *chip, struct nm256_stream *s, + struct snd_pcm_substream *substream, + struct snd_pcm_hardware *hw_ptr) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; s->running = 0; runtime->hw = *hw_ptr; @@ -844,9 +844,9 @@ static void snd_nm256_setup_stream(nm256_t *chip, nm256_stream_t *s, } static int -snd_nm256_playback_open(snd_pcm_substream_t *substream) +snd_nm256_playback_open(struct snd_pcm_substream *substream) { - nm256_t *chip = snd_pcm_substream_chip(substream); + struct nm256 *chip = snd_pcm_substream_chip(substream); if (snd_nm256_acquire_irq(chip) < 0) return -EBUSY; @@ -856,9 +856,9 @@ snd_nm256_playback_open(snd_pcm_substream_t *substream) } static int -snd_nm256_capture_open(snd_pcm_substream_t *substream) +snd_nm256_capture_open(struct snd_pcm_substream *substream) { - nm256_t *chip = snd_pcm_substream_chip(substream); + struct nm256 *chip = snd_pcm_substream_chip(substream); if (snd_nm256_acquire_irq(chip) < 0) return -EBUSY; @@ -871,9 +871,9 @@ snd_nm256_capture_open(snd_pcm_substream_t *substream) * close - we don't have to do special.. */ static int -snd_nm256_playback_close(snd_pcm_substream_t *substream) +snd_nm256_playback_close(struct snd_pcm_substream *substream) { - nm256_t *chip = snd_pcm_substream_chip(substream); + struct nm256 *chip = snd_pcm_substream_chip(substream); snd_nm256_release_irq(chip); return 0; @@ -881,9 +881,9 @@ snd_nm256_playback_close(snd_pcm_substream_t *substream) static int -snd_nm256_capture_close(snd_pcm_substream_t *substream) +snd_nm256_capture_close(struct snd_pcm_substream *substream) { - nm256_t *chip = snd_pcm_substream_chip(substream); + struct nm256 *chip = snd_pcm_substream_chip(substream); snd_nm256_release_irq(chip); return 0; @@ -892,7 +892,7 @@ snd_nm256_capture_close(snd_pcm_substream_t *substream) /* * create a pcm instance */ -static snd_pcm_ops_t snd_nm256_playback_ops = { +static struct snd_pcm_ops snd_nm256_playback_ops = { .open = snd_nm256_playback_open, .close = snd_nm256_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -907,7 +907,7 @@ static snd_pcm_ops_t snd_nm256_playback_ops = { .mmap = snd_pcm_lib_mmap_iomem, }; -static snd_pcm_ops_t snd_nm256_capture_ops = { +static struct snd_pcm_ops snd_nm256_capture_ops = { .open = snd_nm256_capture_open, .close = snd_nm256_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -922,13 +922,13 @@ static snd_pcm_ops_t snd_nm256_capture_ops = { }; static int __devinit -snd_nm256_pcm(nm256_t *chip, int device) +snd_nm256_pcm(struct nm256 *chip, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int i, err; for (i = 0; i < 2; i++) { - nm256_stream_t *s = &chip->streams[i]; + struct nm256_stream *s = &chip->streams[i]; s->bufptr = chip->buffer + (s->buf - chip->buffer_start); s->bufptr_addr = chip->buffer_addr + (s->buf - chip->buffer_start); } @@ -953,7 +953,7 @@ snd_nm256_pcm(nm256_t *chip, int device) * Initialize the hardware. */ static void -snd_nm256_init_chip(nm256_t *chip) +snd_nm256_init_chip(struct nm256 *chip) { /* Reset everything. */ snd_nm256_writeb(chip, 0x0, 0x11); @@ -965,7 +965,7 @@ snd_nm256_init_chip(nm256_t *chip) static irqreturn_t -snd_nm256_intr_check(nm256_t *chip) +snd_nm256_intr_check(struct nm256 *chip) { if (chip->badintrcount++ > 1000) { /* @@ -1002,7 +1002,7 @@ snd_nm256_intr_check(nm256_t *chip) static irqreturn_t snd_nm256_interrupt(int irq, void *dev_id, struct pt_regs *dummy) { - nm256_t *chip = dev_id; + struct nm256 *chip = dev_id; u16 status; u8 cbyte; @@ -1067,7 +1067,7 @@ snd_nm256_interrupt(int irq, void *dev_id, struct pt_regs *dummy) static irqreturn_t snd_nm256_interrupt_zx(int irq, void *dev_id, struct pt_regs *dummy) { - nm256_t *chip = dev_id; + struct nm256 *chip = dev_id; u32 status; u8 cbyte; @@ -1131,7 +1131,7 @@ snd_nm256_interrupt_zx(int irq, void *dev_id, struct pt_regs *dummy) * if it timed out. */ static int -snd_nm256_ac97_ready(nm256_t *chip) +snd_nm256_ac97_ready(struct nm256 *chip) { int timeout = 10; u32 testaddr; @@ -1154,9 +1154,9 @@ snd_nm256_ac97_ready(nm256_t *chip) /* */ static unsigned short -snd_nm256_ac97_read(ac97_t *ac97, unsigned short reg) +snd_nm256_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - nm256_t *chip = ac97->private_data; + struct nm256 *chip = ac97->private_data; int res; if (reg >= 128) @@ -1173,10 +1173,10 @@ snd_nm256_ac97_read(ac97_t *ac97, unsigned short reg) /* */ static void -snd_nm256_ac97_write(ac97_t *ac97, +snd_nm256_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - nm256_t *chip = ac97->private_data; + struct nm256 *chip = ac97->private_data; int tries = 2; u32 base; @@ -1196,9 +1196,9 @@ snd_nm256_ac97_write(ac97_t *ac97, /* initialize the ac97 into a known state */ static void -snd_nm256_ac97_reset(ac97_t *ac97) +snd_nm256_ac97_reset(struct snd_ac97 *ac97) { - nm256_t *chip = ac97->private_data; + struct nm256 *chip = ac97->private_data; /* Reset the mixer. 'Tis magic! */ snd_nm256_writeb(chip, 0x6c0, 1); @@ -1215,12 +1215,12 @@ snd_nm256_ac97_reset(ac97_t *ac97) /* create an ac97 mixer interface */ static int __devinit -snd_nm256_mixer(nm256_t *chip) +snd_nm256_mixer(struct nm256 *chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int i, err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .reset = snd_nm256_ac97_reset, .write = snd_nm256_ac97_write, .read = snd_nm256_ac97_read, @@ -1263,7 +1263,7 @@ snd_nm256_mixer(nm256_t *chip) */ static int __devinit -snd_nm256_peek_for_sig(nm256_t *chip) +snd_nm256_peek_for_sig(struct nm256 *chip) { /* The signature is located 1K below the end of video RAM. */ void __iomem *temp; @@ -1292,7 +1292,8 @@ snd_nm256_peek_for_sig(nm256_t *chip) return -ENODEV; } else { pointer_found = pointer; - printk(KERN_INFO "nm256: found card signature in video RAM: 0x%x\n", pointer); + printk(KERN_INFO "nm256: found card signature in video RAM: 0x%x\n", + pointer); } } @@ -1307,9 +1308,9 @@ snd_nm256_peek_for_sig(nm256_t *chip) * APM event handler, so the card is properly reinitialized after a power * event. */ -static int nm256_suspend(snd_card_t *card, pm_message_t state) +static int nm256_suspend(struct snd_card *card, pm_message_t state) { - nm256_t *chip = card->pm_private_data; + struct nm256 *chip = card->pm_private_data; snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); @@ -1318,9 +1319,9 @@ static int nm256_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int nm256_resume(snd_card_t *card) +static int nm256_resume(struct snd_card *card) { - nm256_t *chip = card->pm_private_data; + struct nm256 *chip = card->pm_private_data; int i; /* Perform a full reset on the hardware */ @@ -1331,7 +1332,7 @@ static int nm256_resume(snd_card_t *card) snd_ac97_resume(chip->ac97); for (i = 0; i < 2; i++) { - nm256_stream_t *s = &chip->streams[i]; + struct nm256_stream *s = &chip->streams[i]; if (s->substream && s->suspended) { spin_lock_irq(&chip->reg_lock); snd_nm256_set_format(chip, s, s->substream); @@ -1343,7 +1344,7 @@ static int nm256_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -static int snd_nm256_free(nm256_t *chip) +static int snd_nm256_free(struct nm256 *chip) { if (chip->streams[SNDRV_PCM_STREAM_PLAYBACK].running) snd_nm256_playback_stop(chip); @@ -1360,26 +1361,26 @@ static int snd_nm256_free(nm256_t *chip) release_and_free_resource(chip->res_cport); release_and_free_resource(chip->res_buffer); if (chip->irq >= 0) - free_irq(chip->irq, (void*)chip); + free_irq(chip->irq, chip); pci_disable_device(chip->pci); kfree(chip); return 0; } -static int snd_nm256_dev_free(snd_device_t *device) +static int snd_nm256_dev_free(struct snd_device *device) { - nm256_t *chip = device->device_data; + struct nm256 *chip = device->device_data; return snd_nm256_free(chip); } static int __devinit -snd_nm256_create(snd_card_t *card, struct pci_dev *pci, - nm256_t **chip_ret) +snd_nm256_create(struct snd_card *card, struct pci_dev *pci, + struct nm256 **chip_ret) { - nm256_t *chip; + struct nm256 *chip; int err, pval; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_nm256_dev_free, }; u32 addr; @@ -1439,7 +1440,8 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci, if ((pval & NM_PRESENCE_MASK) != NM_PRESENCE_VALUE) { if (! force_ac97) { printk(KERN_ERR "nm256: no ac97 is found!\n"); - printk(KERN_ERR " force the driver to load by passing in the module parameter\n"); + printk(KERN_ERR " force the driver to load by " + "passing in the module parameter\n"); printk(KERN_ERR " force_ac97=1\n"); printk(KERN_ERR " or try sb16 or cs423x drivers instead.\n"); err = -ENXIO; @@ -1462,7 +1464,8 @@ snd_nm256_create(snd_card_t *card, struct pci_dev *pci, chip->mixer_status_mask = NM2_MIXER_READY_MASK; } - chip->buffer_size = chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize + chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize; + chip->buffer_size = chip->streams[SNDRV_PCM_STREAM_PLAYBACK].bufsize + + chip->streams[SNDRV_PCM_STREAM_CAPTURE].bufsize; if (chip->use_cache) chip->buffer_size += NM_TOTAL_COEFF_COUNT * 4; else @@ -1561,8 +1564,8 @@ static struct nm256_quirk nm256_quirks[] __devinitdata = { static int __devinit snd_nm256_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - nm256_t *chip; + struct snd_card *card; + struct nm256 *chip; int err; struct nm256_quirk *q; u16 subsystem_vendor, subsystem_device; @@ -1574,7 +1577,8 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, if (q->vendor == subsystem_vendor && q->device == subsystem_device) { switch (q->type) { case NM_BLACKLISTED: - printk(KERN_INFO "nm256: The device is blacklisted. Loading stopped\n"); + printk(KERN_INFO "nm256: The device is blacklisted. " + "Loading stopped\n"); return -ENODEV; case NM_RESET_WORKAROUND_2: reset_workaround_2 = 1; -- cgit v1.1 From 02c2de69d0bb0ed39b413188241beb4a29d05378 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:01:46 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI AD1889 Modules: AD1889 driver Remove xxx_t typedefs from the PCI AD1889 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ad1889.c | 84 +++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 999aaea..61d6d52 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -87,20 +87,20 @@ struct ad1889_register_state { }; struct snd_ad1889 { - snd_card_t *card; + struct snd_card *card; struct pci_dev *pci; int irq; unsigned long bar; void __iomem *iobase; - ac97_t *ac97; - ac97_bus_t *ac97_bus; - snd_pcm_t *pcm; - snd_info_entry_t *proc; + struct snd_ac97 *ac97; + struct snd_ac97_bus *ac97_bus; + struct snd_pcm *pcm; + struct snd_info_entry *proc; - snd_pcm_substream_t *psubs; - snd_pcm_substream_t *csubs; + struct snd_pcm_substream *psubs; + struct snd_pcm_substream *csubs; /* playback register state */ struct ad1889_register_state wave; @@ -241,14 +241,14 @@ ad1889_channel_reset(struct snd_ad1889 *chip, unsigned int channel) } static inline u16 -snd_ad1889_ac97_read(ac97_t *ac97, unsigned short reg) +snd_ad1889_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { struct snd_ad1889 *chip = ac97->private_data; return ad1889_readw(chip, AD_AC97_BASE + reg); } static inline void -snd_ad1889_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +snd_ad1889_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { struct snd_ad1889 *chip = ac97->private_data; ad1889_writew(chip, AD_AC97_BASE + reg, val); @@ -273,20 +273,20 @@ snd_ad1889_ac97_ready(struct snd_ad1889 *chip) } static int -snd_ad1889_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +snd_ad1889_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } static int -snd_ad1889_hw_free(snd_pcm_substream_t *substream) +snd_ad1889_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static snd_pcm_hardware_t snd_ad1889_playback_hw = { +static struct snd_pcm_hardware snd_ad1889_playback_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER, .formats = SNDRV_PCM_FMTBIT_S16_LE, @@ -303,7 +303,7 @@ static snd_pcm_hardware_t snd_ad1889_playback_hw = { /*.fifo_size = 0,*/ }; -static snd_pcm_hardware_t snd_ad1889_capture_hw = { +static struct snd_pcm_hardware snd_ad1889_capture_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_BLOCK_TRANSFER, .formats = SNDRV_PCM_FMTBIT_S16_LE, @@ -321,10 +321,10 @@ static snd_pcm_hardware_t snd_ad1889_capture_hw = { }; static int -snd_ad1889_playback_open(snd_pcm_substream_t *ss) +snd_ad1889_playback_open(struct snd_pcm_substream *ss) { struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_pcm_runtime *rt = ss->runtime; chip->psubs = ss; rt->hw = snd_ad1889_playback_hw; @@ -333,10 +333,10 @@ snd_ad1889_playback_open(snd_pcm_substream_t *ss) } static int -snd_ad1889_capture_open(snd_pcm_substream_t *ss) +snd_ad1889_capture_open(struct snd_pcm_substream *ss) { struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_pcm_runtime *rt = ss->runtime; chip->csubs = ss; rt->hw = snd_ad1889_capture_hw; @@ -345,7 +345,7 @@ snd_ad1889_capture_open(snd_pcm_substream_t *ss) } static int -snd_ad1889_playback_close(snd_pcm_substream_t *ss) +snd_ad1889_playback_close(struct snd_pcm_substream *ss) { struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); chip->psubs = NULL; @@ -353,7 +353,7 @@ snd_ad1889_playback_close(snd_pcm_substream_t *ss) } static int -snd_ad1889_capture_close(snd_pcm_substream_t *ss) +snd_ad1889_capture_close(struct snd_pcm_substream *ss) { struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); chip->csubs = NULL; @@ -361,10 +361,10 @@ snd_ad1889_capture_close(snd_pcm_substream_t *ss) } static int -snd_ad1889_playback_prepare(snd_pcm_substream_t *ss) +snd_ad1889_playback_prepare(struct snd_pcm_substream *ss) { struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_pcm_runtime *rt = ss->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(ss); unsigned int count = snd_pcm_lib_period_bytes(ss); u16 reg; @@ -411,10 +411,10 @@ snd_ad1889_playback_prepare(snd_pcm_substream_t *ss) } static int -snd_ad1889_capture_prepare(snd_pcm_substream_t *ss) +snd_ad1889_capture_prepare(struct snd_pcm_substream *ss) { struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_pcm_runtime *rt = ss->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(ss); unsigned int count = snd_pcm_lib_period_bytes(ss); u16 reg; @@ -462,7 +462,7 @@ snd_ad1889_capture_prepare(snd_pcm_substream_t *ss) DMA should be *triggered* by this call. The WSMC "WAEN" bit triggers DMA Wave On/Off */ static int -snd_ad1889_playback_trigger(snd_pcm_substream_t *ss, int cmd) +snd_ad1889_playback_trigger(struct snd_pcm_substream *ss, int cmd) { u16 wsmc; struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); @@ -503,7 +503,7 @@ snd_ad1889_playback_trigger(snd_pcm_substream_t *ss, int cmd) DMA should be *triggered* by this call. The RAMC "ADEN" bit triggers DMA ADC On/Off */ static int -snd_ad1889_capture_trigger(snd_pcm_substream_t *ss, int cmd) +snd_ad1889_capture_trigger(struct snd_pcm_substream *ss, int cmd) { u16 ramc; struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); @@ -538,7 +538,7 @@ snd_ad1889_capture_trigger(snd_pcm_substream_t *ss, int cmd) /* Called in atomic context with IRQ disabled */ static snd_pcm_uframes_t -snd_ad1889_playback_pointer(snd_pcm_substream_t *ss) +snd_ad1889_playback_pointer(struct snd_pcm_substream *ss) { size_t ptr = 0; struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); @@ -556,7 +556,7 @@ snd_ad1889_playback_pointer(snd_pcm_substream_t *ss) /* Called in atomic context with IRQ disabled */ static snd_pcm_uframes_t -snd_ad1889_capture_pointer(snd_pcm_substream_t *ss) +snd_ad1889_capture_pointer(struct snd_pcm_substream *ss) { size_t ptr = 0; struct snd_ad1889 *chip = snd_pcm_substream_chip(ss); @@ -572,7 +572,7 @@ snd_ad1889_capture_pointer(snd_pcm_substream_t *ss) return bytes_to_frames(ss->runtime, ptr); } -static snd_pcm_ops_t snd_ad1889_playback_ops = { +static struct snd_pcm_ops snd_ad1889_playback_ops = { .open = snd_ad1889_playback_open, .close = snd_ad1889_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -583,7 +583,7 @@ static snd_pcm_ops_t snd_ad1889_playback_ops = { .pointer = snd_ad1889_playback_pointer, }; -static snd_pcm_ops_t snd_ad1889_capture_ops = { +static struct snd_pcm_ops snd_ad1889_capture_ops = { .open = snd_ad1889_capture_open, .close = snd_ad1889_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -624,10 +624,10 @@ snd_ad1889_interrupt(int irq, } static int __devinit -snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, snd_pcm_t **rpcm) +snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, struct snd_pcm **rpcm) { int err; - snd_pcm_t *pcm; + struct snd_pcm *pcm; if (rpcm) *rpcm = NULL; @@ -666,7 +666,7 @@ snd_ad1889_pcm_init(struct snd_ad1889 *chip, int device, snd_pcm_t **rpcm) } static void -snd_ad1889_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +snd_ad1889_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { struct snd_ad1889 *chip = entry->private_data; u16 reg; @@ -749,7 +749,7 @@ snd_ad1889_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) static void __devinit snd_ad1889_proc_init(struct snd_ad1889 *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (!snd_card_proc_new(chip->card, chip->card->driver, &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_ad1889_proc_read); @@ -791,14 +791,14 @@ snd_ad1889_ac97_xinit(struct snd_ad1889 *chip) } static void -snd_ad1889_ac97_bus_free(ac97_bus_t *bus) +snd_ad1889_ac97_bus_free(struct snd_ac97_bus *bus) { struct snd_ad1889 *chip = bus->private_data; chip->ac97_bus = NULL; } static void -snd_ad1889_ac97_free(ac97_t *ac97) +snd_ad1889_ac97_free(struct snd_ac97 *ac97) { struct snd_ad1889 *chip = ac97->private_data; chip->ac97 = NULL; @@ -808,8 +808,8 @@ static int __devinit snd_ad1889_ac97_init(struct snd_ad1889 *chip, const char *quirk_override) { int err; - ac97_template_t ac97; - static ac97_bus_ops_t ops = { + struct snd_ac97_template ac97; + static struct snd_ac97_bus_ops ops = { .write = snd_ad1889_ac97_write, .read = snd_ad1889_ac97_read, }; @@ -873,7 +873,7 @@ skip_hw: } static inline int -snd_ad1889_dev_free(snd_device_t *device) +snd_ad1889_dev_free(struct snd_device *device) { struct snd_ad1889 *chip = device->device_data; return snd_ad1889_free(chip); @@ -894,14 +894,14 @@ snd_ad1889_init(struct snd_ad1889 *chip) } static int __devinit -snd_ad1889_create(snd_card_t *card, +snd_ad1889_create(struct snd_card *card, struct pci_dev *pci, struct snd_ad1889 **rchip) { int err; struct snd_ad1889 *chip; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ad1889_dev_free, }; @@ -985,7 +985,7 @@ snd_ad1889_probe(struct pci_dev *pci, { int err; static int devno; - snd_card_t *card; + struct snd_card *card; struct snd_ad1889 *chip; /* (1) */ -- cgit v1.1 From 17c39d9a59cbf4b3a51a2694134754fc1d3668e7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:02:01 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI ALS4000 Modules: ALS4000 driver Remove xxx_t typedefs from the PCI ALS4000 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/als4000.c | 126 ++++++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 48b5175..8d0d9c0 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -105,14 +105,14 @@ module_param_array(joystick_port, int, NULL, 0444); MODULE_PARM_DESC(joystick_port, "Joystick port address for ALS4000 soundcard. (0 = disabled)"); #endif -typedef struct { +struct snd_card_als4000 { /* most frequent access first */ unsigned long gcr; struct pci_dev *pci; #ifdef SUPPORT_JOYSTICK struct gameport *gameport; #endif -} snd_card_als4000_t; +}; static struct pci_device_id snd_als4000_ids[] = { { 0x4005, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* ALS4000 */ @@ -127,7 +127,7 @@ static inline void snd_als4000_gcr_write_addr(unsigned long port, u32 reg, u32 v outl(val, port+0x08); } -static inline void snd_als4000_gcr_write(sb_t *sb, u32 reg, u32 val) +static inline void snd_als4000_gcr_write(struct snd_sb *sb, u32 reg, u32 val) { snd_als4000_gcr_write_addr(sb->alt_port, reg, val); } @@ -138,12 +138,12 @@ static inline u32 snd_als4000_gcr_read_addr(unsigned long port, u32 reg) return inl(port+0x08); } -static inline u32 snd_als4000_gcr_read(sb_t *sb, u32 reg) +static inline u32 snd_als4000_gcr_read(struct snd_sb *sb, u32 reg) { return snd_als4000_gcr_read_addr(sb->alt_port, reg); } -static void snd_als4000_set_rate(sb_t *chip, unsigned int rate) +static void snd_als4000_set_rate(struct snd_sb *chip, unsigned int rate) { if (!(chip->mode & SB_RATE_LOCK)) { snd_sbdsp_command(chip, SB_DSP_SAMPLE_RATE_OUT); @@ -152,13 +152,15 @@ static void snd_als4000_set_rate(sb_t *chip, unsigned int rate) } } -static inline void snd_als4000_set_capture_dma(sb_t *chip, dma_addr_t addr, unsigned size) +static inline void snd_als4000_set_capture_dma(struct snd_sb *chip, + dma_addr_t addr, unsigned size) { snd_als4000_gcr_write(chip, 0xa2, addr); snd_als4000_gcr_write(chip, 0xa3, (size-1)); } -static inline void snd_als4000_set_playback_dma(sb_t *chip, dma_addr_t addr, unsigned size) +static inline void snd_als4000_set_playback_dma(struct snd_sb *chip, + dma_addr_t addr, unsigned size) { snd_als4000_gcr_write(chip, 0x91, addr); snd_als4000_gcr_write(chip, 0x92, (size-1)|0x180000); @@ -168,7 +170,7 @@ static inline void snd_als4000_set_playback_dma(sb_t *chip, dma_addr_t addr, uns #define ALS4000_FORMAT_16BIT (1<<1) #define ALS4000_FORMAT_STEREO (1<<2) -static int snd_als4000_get_format(snd_pcm_runtime_t *runtime) +static int snd_als4000_get_format(struct snd_pcm_runtime *runtime) { int result; @@ -220,23 +222,22 @@ CMD_SIGNED|CMD_STEREO, /* ALS4000_FORMAT_S16L_STEREO */ }; #define capture_cmd(chip) (capture_cmd_vals[(chip)->capture_format]) -static int snd_als4000_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_als4000_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_als4000_hw_free(snd_pcm_substream_t * substream) +static int snd_als4000_hw_free(struct snd_pcm_substream *substream) { snd_pcm_lib_free_pages(substream); return 0; } -static int snd_als4000_capture_prepare(snd_pcm_substream_t * substream) +static int snd_als4000_capture_prepare(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - unsigned long flags; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long size; unsigned count; @@ -249,22 +250,21 @@ static int snd_als4000_capture_prepare(snd_pcm_substream_t * substream) count >>=1; count--; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); snd_als4000_set_rate(chip, runtime->rate); snd_als4000_set_capture_dma(chip, runtime->dma_addr, size); - spin_unlock_irqrestore(&chip->reg_lock, flags); - spin_lock_irqsave(&chip->mixer_lock, flags ); + spin_unlock_irq(&chip->reg_lock); + spin_lock_irq(&chip->mixer_lock); snd_sbmixer_write(chip, 0xdc, count); snd_sbmixer_write(chip, 0xdd, count>>8); - spin_unlock_irqrestore(&chip->mixer_lock, flags ); + spin_unlock_irq(&chip->mixer_lock); return 0; } -static int snd_als4000_playback_prepare(snd_pcm_substream_t *substream) +static int snd_als4000_playback_prepare(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - unsigned long flags; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long size; unsigned count; @@ -283,7 +283,7 @@ static int snd_als4000_playback_prepare(snd_pcm_substream_t *substream) * reordering, ...). Something seems to get enabled on playback * that I haven't found out how to disable again, which then causes * the switching pops to reach the speakers the next time here. */ - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); snd_als4000_set_rate(chip, runtime->rate); snd_als4000_set_playback_dma(chip, runtime->dma_addr, size); @@ -294,14 +294,14 @@ static int snd_als4000_playback_prepare(snd_pcm_substream_t *substream) snd_sbdsp_command(chip, count); snd_sbdsp_command(chip, count>>8); snd_sbdsp_command(chip, playback_cmd(chip).dma_off); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return 0; } -static int snd_als4000_capture_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_als4000_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); int result = 0; spin_lock(&chip->mixer_lock); @@ -318,9 +318,9 @@ static int snd_als4000_capture_trigger(snd_pcm_substream_t * substream, int cmd) return result; } -static int snd_als4000_playback_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_als4000_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); int result = 0; spin_lock(&chip->reg_lock); @@ -337,9 +337,9 @@ static int snd_als4000_playback_trigger(snd_pcm_substream_t * substream, int cmd return result; } -static snd_pcm_uframes_t snd_als4000_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_als4000_capture_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned int result; spin_lock(&chip->reg_lock); @@ -348,9 +348,9 @@ static snd_pcm_uframes_t snd_als4000_capture_pointer(snd_pcm_substream_t * subst return bytes_to_frames( substream->runtime, result ); } -static snd_pcm_uframes_t snd_als4000_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_als4000_playback_pointer(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); unsigned result; spin_lock(&chip->reg_lock); @@ -373,7 +373,7 @@ static snd_pcm_uframes_t snd_als4000_playback_pointer(snd_pcm_substream_t * subs * */ static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - sb_t *chip = dev_id; + struct snd_sb *chip = dev_id; unsigned gcr_status; unsigned sb_status; @@ -406,7 +406,7 @@ static irqreturn_t snd_als4000_interrupt(int irq, void *dev_id, struct pt_regs * /*****************************************************************/ -static snd_pcm_hardware_t snd_als4000_playback = +static struct snd_pcm_hardware snd_als4000_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -425,7 +425,7 @@ static snd_pcm_hardware_t snd_als4000_playback = .fifo_size = 0 }; -static snd_pcm_hardware_t snd_als4000_capture = +static struct snd_pcm_hardware snd_als4000_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID), @@ -446,38 +446,38 @@ static snd_pcm_hardware_t snd_als4000_capture = /*****************************************************************/ -static int snd_als4000_playback_open(snd_pcm_substream_t * substream) +static int snd_als4000_playback_open(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; chip->playback_substream = substream; runtime->hw = snd_als4000_playback; return 0; } -static int snd_als4000_playback_close(snd_pcm_substream_t * substream) +static int snd_als4000_playback_close(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; snd_pcm_lib_free_pages(substream); return 0; } -static int snd_als4000_capture_open(snd_pcm_substream_t * substream) +static int snd_als4000_capture_open(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_sb *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; chip->capture_substream = substream; runtime->hw = snd_als4000_capture; return 0; } -static int snd_als4000_capture_close(snd_pcm_substream_t * substream) +static int snd_als4000_capture_close(struct snd_pcm_substream *substream) { - sb_t *chip = snd_pcm_substream_chip(substream); + struct snd_sb *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; snd_pcm_lib_free_pages(substream); @@ -486,7 +486,7 @@ static int snd_als4000_capture_close(snd_pcm_substream_t * substream) /******************************************************************/ -static snd_pcm_ops_t snd_als4000_playback_ops = { +static struct snd_pcm_ops snd_als4000_playback_ops = { .open = snd_als4000_playback_open, .close = snd_als4000_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -497,7 +497,7 @@ static snd_pcm_ops_t snd_als4000_playback_ops = { .pointer = snd_als4000_playback_pointer }; -static snd_pcm_ops_t snd_als4000_capture_ops = { +static struct snd_pcm_ops snd_als4000_capture_ops = { .open = snd_als4000_capture_open, .close = snd_als4000_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -508,9 +508,9 @@ static snd_pcm_ops_t snd_als4000_capture_ops = { .pointer = snd_als4000_capture_pointer }; -static int __devinit snd_als4000_pcm(sb_t *chip, int device) +static int __devinit snd_als4000_pcm(struct snd_sb *chip, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "ALS4000 DSP", device, 1, 1, &pcm)) < 0) @@ -551,7 +551,7 @@ static void snd_als4000_set_addr(unsigned long gcr, snd_als4000_gcr_write_addr(gcr, 0xa9, confB); } -static void __devinit snd_als4000_configure(sb_t *chip) +static void __devinit snd_als4000_configure(struct snd_sb *chip) { unsigned tmp; int i; @@ -576,7 +576,7 @@ static void __devinit snd_als4000_configure(sb_t *chip) } #ifdef SUPPORT_JOYSTICK -static int __devinit snd_als4000_create_gameport(snd_card_als4000_t *acard, int dev) +static int __devinit snd_als4000_create_gameport(struct snd_card_als4000 *acard, int dev) { struct gameport *gp; struct resource *r; @@ -622,7 +622,7 @@ static int __devinit snd_als4000_create_gameport(snd_card_als4000_t *acard, int return 0; } -static void snd_als4000_free_gameport(snd_card_als4000_t *acard) +static void snd_als4000_free_gameport(struct snd_card_als4000 *acard) { if (acard->gameport) { struct resource *r = gameport_get_port_data(acard->gameport); @@ -635,13 +635,13 @@ static void snd_als4000_free_gameport(snd_card_als4000_t *acard) } } #else -static inline int snd_als4000_create_gameport(snd_card_als4000_t *acard, int dev) { return -ENOSYS; } -static inline void snd_als4000_free_gameport(snd_card_als4000_t *acard) { } +static inline int snd_als4000_create_gameport(struct snd_card_als4000 *acard, int dev) { return -ENOSYS; } +static inline void snd_als4000_free_gameport(struct snd_card_als4000 *acard) { } #endif -static void snd_card_als4000_free( snd_card_t *card ) +static void snd_card_als4000_free( struct snd_card *card ) { - snd_card_als4000_t * acard = (snd_card_als4000_t *)card->private_data; + struct snd_card_als4000 * acard = (struct snd_card_als4000 *)card->private_data; /* make sure that interrupts are disabled */ snd_als4000_gcr_write_addr( acard->gcr, 0x8c, 0); @@ -655,11 +655,11 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - snd_card_als4000_t *acard; + struct snd_card *card; + struct snd_card_als4000 *acard; unsigned long gcr; - sb_t *chip; - opl3_t *opl3; + struct snd_sb *chip; + struct snd_opl3 *opl3; unsigned short word; int err; @@ -693,14 +693,14 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci, pci_set_master(pci); card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof( snd_card_als4000_t ) ); + sizeof( struct snd_card_als4000 ) ); if (card == NULL) { pci_release_regions(pci); pci_disable_device(pci); return -ENOMEM; } - acard = (snd_card_als4000_t *)card->private_data; + acard = (struct snd_card_als4000 *)card->private_data; acard->pci = pci; acard->gcr = gcr; card->private_free = snd_card_als4000_free; -- cgit v1.1 From 74ee4ff1e62d9798361763f152c6f07d491be819 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:02:23 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI ATIIXP Modules: ATIIXP driver,ATIIXP-modem driver Remove xxx_t typedefs from the PCI ATIIXP and modem drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/atiixp.c | 295 +++++++++++++++++++++++++---------------------- sound/pci/atiixp_modem.c | 259 ++++++++++++++++++++++------------------- 2 files changed, 295 insertions(+), 259 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 36395d0..5ead666 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -197,24 +197,18 @@ module_param(enable, bool, 0444); #define ATI_MAX_DESCRIPTORS 256 /* max number of descriptor packets */ -/* - */ - -typedef struct snd_atiixp atiixp_t; -typedef struct snd_atiixp_dma atiixp_dma_t; -typedef struct snd_atiixp_dma_ops atiixp_dma_ops_t; - +struct atiixp; /* * DMA packate descriptor */ -typedef struct atiixp_dma_desc { +struct atiixp_dma_desc { u32 addr; /* DMA buffer address */ u16 status; /* status bits */ u16 size; /* size of the packet in dwords */ u32 next; /* address of the next packet descriptor */ -} atiixp_dma_desc_t; +}; /* * stream enum @@ -229,22 +223,25 @@ enum { ATI_PCMDEV_ANALOG, ATI_PCMDEV_DIGITAL, NUM_ATI_PCMDEVS }; /* pcm devices /* * constants and callbacks for each DMA type */ -struct snd_atiixp_dma_ops { +struct atiixp_dma_ops { int type; /* ATI_DMA_XXX */ unsigned int llp_offset; /* LINKPTR offset */ unsigned int dt_cur; /* DT_CUR offset */ - void (*enable_dma)(atiixp_t *chip, int on); /* called from open callback */ - void (*enable_transfer)(atiixp_t *chip, int on); /* called from trigger (START/STOP) */ - void (*flush_dma)(atiixp_t *chip); /* called from trigger (STOP only) */ + /* called from open callback */ + void (*enable_dma)(struct atiixp *chip, int on); + /* called from trigger (START/STOP) */ + void (*enable_transfer)(struct atiixp *chip, int on); + /* called from trigger (STOP only) */ + void (*flush_dma)(struct atiixp *chip); }; /* * DMA stream */ -struct snd_atiixp_dma { - const atiixp_dma_ops_t *ops; +struct atiixp_dma { + const struct atiixp_dma_ops *ops; struct snd_dma_buffer desc_buf; - snd_pcm_substream_t *substream; /* assigned PCM substream */ + struct snd_pcm_substream *substream; /* assigned PCM substream */ unsigned int buf_addr, buf_bytes; /* DMA buffer address, bytes */ unsigned int period_bytes, periods; int opened; @@ -258,22 +255,22 @@ struct snd_atiixp_dma { /* * ATI IXP chip */ -struct snd_atiixp { - snd_card_t *card; +struct atiixp { + struct snd_card *card; struct pci_dev *pci; unsigned long addr; void __iomem *remap_addr; int irq; - ac97_bus_t *ac97_bus; - ac97_t *ac97[NUM_ATI_CODECS]; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97[NUM_ATI_CODECS]; spinlock_t reg_lock; - atiixp_dma_t dmas[NUM_ATI_DMAS]; + struct atiixp_dma dmas[NUM_ATI_DMAS]; struct ac97_pcm *pcms[NUM_ATI_PCMS]; - snd_pcm_t *pcmdevs[NUM_ATI_PCMDEVS]; + struct snd_pcm *pcmdevs[NUM_ATI_PCMDEVS]; int max_channels; /* max. channels for PCM out */ @@ -304,7 +301,7 @@ MODULE_DEVICE_TABLE(pci, snd_atiixp_ids); * update the bits of the given register. * return 1 if the bits changed. */ -static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg, +static int snd_atiixp_update_bits(struct atiixp *chip, unsigned int reg, unsigned int mask, unsigned int value) { void __iomem *addr = chip->remap_addr + reg; @@ -336,7 +333,7 @@ static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg, */ #define ATI_DESC_LIST_SIZE \ - PAGE_ALIGN(ATI_MAX_DESCRIPTORS * sizeof(atiixp_dma_desc_t)) + PAGE_ALIGN(ATI_MAX_DESCRIPTORS * sizeof(struct atiixp_dma_desc)) /* * build packets ring for the given buffer size. @@ -347,10 +344,10 @@ static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg, * * the ring is built in this function, and is set up to the hardware. */ -static int atiixp_build_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, - snd_pcm_substream_t *substream, - unsigned int periods, - unsigned int period_bytes) +static int atiixp_build_dma_packets(struct atiixp *chip, struct atiixp_dma *dma, + struct snd_pcm_substream *substream, + unsigned int periods, + unsigned int period_bytes) { unsigned int i; u32 addr, desc_addr; @@ -360,8 +357,10 @@ static int atiixp_build_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, return -ENOMEM; if (dma->desc_buf.area == NULL) { - if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), - ATI_DESC_LIST_SIZE, &dma->desc_buf) < 0) + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, + snd_dma_pci_data(chip->pci), + ATI_DESC_LIST_SIZE, + &dma->desc_buf) < 0) return -ENOMEM; dma->period_bytes = dma->periods = 0; /* clear */ } @@ -380,11 +379,12 @@ static int atiixp_build_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, addr = (u32)substream->runtime->dma_addr; desc_addr = (u32)dma->desc_buf.addr; for (i = 0; i < periods; i++) { - atiixp_dma_desc_t *desc = &((atiixp_dma_desc_t *)dma->desc_buf.area)[i]; + struct atiixp_dma_desc *desc; + desc = &((struct atiixp_dma_desc *)dma->desc_buf.area)[i]; desc->addr = cpu_to_le32(addr); desc->status = 0; desc->size = period_bytes >> 2; /* in dwords */ - desc_addr += sizeof(atiixp_dma_desc_t); + desc_addr += sizeof(struct atiixp_dma_desc); if (i == periods - 1) desc->next = cpu_to_le32((u32)dma->desc_buf.addr); else @@ -404,7 +404,8 @@ static int atiixp_build_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, /* * remove the ring buffer and release it if assigned */ -static void atiixp_clear_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, snd_pcm_substream_t *substream) +static void atiixp_clear_dma_packets(struct atiixp *chip, struct atiixp_dma *dma, + struct snd_pcm_substream *substream) { if (dma->desc_buf.area) { writel(0, chip->remap_addr + dma->ops->llp_offset); @@ -416,7 +417,7 @@ static void atiixp_clear_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, snd_pcm_ /* * AC97 interface */ -static int snd_atiixp_acquire_codec(atiixp_t *chip) +static int snd_atiixp_acquire_codec(struct atiixp *chip) { int timeout = 1000; @@ -430,7 +431,7 @@ static int snd_atiixp_acquire_codec(atiixp_t *chip) return 0; } -static unsigned short snd_atiixp_codec_read(atiixp_t *chip, unsigned short codec, unsigned short reg) +static unsigned short snd_atiixp_codec_read(struct atiixp *chip, unsigned short codec, unsigned short reg) { unsigned int data; int timeout; @@ -458,7 +459,8 @@ static unsigned short snd_atiixp_codec_read(atiixp_t *chip, unsigned short codec } -static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigned short reg, unsigned short val) +static void snd_atiixp_codec_write(struct atiixp *chip, unsigned short codec, + unsigned short reg, unsigned short val) { unsigned int data; @@ -471,23 +473,25 @@ static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigne } -static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_atiixp_ac97_read(struct snd_ac97 *ac97, + unsigned short reg) { - atiixp_t *chip = ac97->private_data; + struct atiixp *chip = ac97->private_data; return snd_atiixp_codec_read(chip, ac97->num, reg); } -static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +static void snd_atiixp_ac97_write(struct snd_ac97 *ac97, unsigned short reg, + unsigned short val) { - atiixp_t *chip = ac97->private_data; + struct atiixp *chip = ac97->private_data; snd_atiixp_codec_write(chip, ac97->num, reg, val); } /* * reset AC link */ -static int snd_atiixp_aclink_reset(atiixp_t *chip) +static int snd_atiixp_aclink_reset(struct atiixp *chip) { int timeout; @@ -507,7 +511,7 @@ static int snd_atiixp_aclink_reset(atiixp_t *chip) atiixp_update(chip, CMD, ATI_REG_CMD_AC_SYNC|ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_SYNC); atiixp_read(chip, CMD); - msleep(1); + mdelay(1); atiixp_update(chip, CMD, ATI_REG_CMD_AC_RESET, ATI_REG_CMD_AC_RESET); if (--timeout) { snd_printk(KERN_ERR "atiixp: codec reset timeout\n"); @@ -523,7 +527,7 @@ static int snd_atiixp_aclink_reset(atiixp_t *chip) } #ifdef CONFIG_PM -static int snd_atiixp_aclink_down(atiixp_t *chip) +static int snd_atiixp_aclink_down(struct atiixp *chip) { // if (atiixp_read(chip, MODEM_MIRROR) & 0x1) /* modem running, too? */ // return -EBUSY; @@ -548,7 +552,7 @@ static int snd_atiixp_aclink_down(atiixp_t *chip) ATI_REG_ISR_CODEC2_NOT_READY) #define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME) -static int snd_atiixp_codec_detect(atiixp_t *chip) +static int snd_atiixp_codec_detect(struct atiixp *chip) { int timeout; @@ -557,7 +561,7 @@ static int snd_atiixp_codec_detect(atiixp_t *chip) /* wait for the interrupts */ timeout = 50; while (timeout-- > 0) { - msleep(1); + mdelay(1); if (chip->codec_not_ready_bits) break; } @@ -574,7 +578,7 @@ static int snd_atiixp_codec_detect(atiixp_t *chip) /* * enable DMA and irqs */ -static int snd_atiixp_chip_start(atiixp_t *chip) +static int snd_atiixp_chip_start(struct atiixp *chip) { unsigned int reg; @@ -604,7 +608,7 @@ static int snd_atiixp_chip_start(atiixp_t *chip) /* * disable DMA and IRQs */ -static int snd_atiixp_chip_stop(atiixp_t *chip) +static int snd_atiixp_chip_stop(struct atiixp *chip) { /* clear interrupt source */ atiixp_write(chip, ISR, atiixp_read(chip, ISR)); @@ -623,11 +627,11 @@ static int snd_atiixp_chip_stop(atiixp_t *chip) * position. when SG-buffer is implemented, the offset must be calculated * correctly... */ -static snd_pcm_uframes_t snd_atiixp_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_atiixp_pcm_pointer(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - atiixp_dma_t *dma = (atiixp_dma_t *)runtime->private_data; + struct atiixp *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct atiixp_dma *dma = runtime->private_data; unsigned int curptr; int timeout = 1000; @@ -648,7 +652,7 @@ static snd_pcm_uframes_t snd_atiixp_pcm_pointer(snd_pcm_substream_t *substream) /* * XRUN detected, and stop the PCM substream */ -static void snd_atiixp_xrun_dma(atiixp_t *chip, atiixp_dma_t *dma) +static void snd_atiixp_xrun_dma(struct atiixp *chip, struct atiixp_dma *dma) { if (! dma->substream || ! dma->running) return; @@ -659,7 +663,7 @@ static void snd_atiixp_xrun_dma(atiixp_t *chip, atiixp_dma_t *dma) /* * the period ack. update the substream. */ -static void snd_atiixp_update_dma(atiixp_t *chip, atiixp_dma_t *dma) +static void snd_atiixp_update_dma(struct atiixp *chip, struct atiixp_dma *dma) { if (! dma->substream || ! dma->running) return; @@ -668,7 +672,7 @@ static void snd_atiixp_update_dma(atiixp_t *chip, atiixp_dma_t *dma) /* set BUS_BUSY interrupt bit if any DMA is running */ /* call with spinlock held */ -static void snd_atiixp_check_bus_busy(atiixp_t *chip) +static void snd_atiixp_check_bus_busy(struct atiixp *chip) { unsigned int bus_busy; if (atiixp_read(chip, CMD) & (ATI_REG_CMD_SEND_EN | @@ -683,10 +687,10 @@ static void snd_atiixp_check_bus_busy(atiixp_t *chip) /* common trigger callback * calling the lowlevel callbacks in it */ -static int snd_atiixp_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; + struct atiixp *chip = snd_pcm_substream_chip(substream); + struct atiixp_dma *dma = substream->runtime->private_data; int err = 0; snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); @@ -730,13 +734,13 @@ static int snd_atiixp_pcm_trigger(snd_pcm_substream_t *substream, int cmd) */ /* flush FIFO of analog OUT DMA */ -static void atiixp_out_flush_dma(atiixp_t *chip) +static void atiixp_out_flush_dma(struct atiixp *chip) { atiixp_write(chip, FIFO_FLUSH, ATI_REG_FIFO_OUT_FLUSH); } /* enable/disable analog OUT DMA */ -static void atiixp_out_enable_dma(atiixp_t *chip, int on) +static void atiixp_out_enable_dma(struct atiixp *chip, int on) { unsigned int data; data = atiixp_read(chip, CMD); @@ -751,21 +755,21 @@ static void atiixp_out_enable_dma(atiixp_t *chip, int on) } /* start/stop transfer over OUT DMA */ -static void atiixp_out_enable_transfer(atiixp_t *chip, int on) +static void atiixp_out_enable_transfer(struct atiixp *chip, int on) { atiixp_update(chip, CMD, ATI_REG_CMD_SEND_EN, on ? ATI_REG_CMD_SEND_EN : 0); } /* enable/disable analog IN DMA */ -static void atiixp_in_enable_dma(atiixp_t *chip, int on) +static void atiixp_in_enable_dma(struct atiixp *chip, int on) { atiixp_update(chip, CMD, ATI_REG_CMD_IN_DMA_EN, on ? ATI_REG_CMD_IN_DMA_EN : 0); } /* start/stop analog IN DMA */ -static void atiixp_in_enable_transfer(atiixp_t *chip, int on) +static void atiixp_in_enable_transfer(struct atiixp *chip, int on) { if (on) { unsigned int data = atiixp_read(chip, CMD); @@ -784,20 +788,20 @@ static void atiixp_in_enable_transfer(atiixp_t *chip, int on) } /* flush FIFO of analog IN DMA */ -static void atiixp_in_flush_dma(atiixp_t *chip) +static void atiixp_in_flush_dma(struct atiixp *chip) { atiixp_write(chip, FIFO_FLUSH, ATI_REG_FIFO_IN_FLUSH); } /* enable/disable SPDIF OUT DMA */ -static void atiixp_spdif_enable_dma(atiixp_t *chip, int on) +static void atiixp_spdif_enable_dma(struct atiixp *chip, int on) { atiixp_update(chip, CMD, ATI_REG_CMD_SPDF_DMA_EN, on ? ATI_REG_CMD_SPDF_DMA_EN : 0); } /* start/stop SPDIF OUT DMA */ -static void atiixp_spdif_enable_transfer(atiixp_t *chip, int on) +static void atiixp_spdif_enable_transfer(struct atiixp *chip, int on) { unsigned int data; data = atiixp_read(chip, CMD); @@ -809,7 +813,7 @@ static void atiixp_spdif_enable_transfer(atiixp_t *chip, int on) } /* flush FIFO of SPDIF OUT DMA */ -static void atiixp_spdif_flush_dma(atiixp_t *chip) +static void atiixp_spdif_flush_dma(struct atiixp *chip) { int timeout; @@ -828,9 +832,9 @@ static void atiixp_spdif_flush_dma(atiixp_t *chip) } /* set up slots and formats for SPDIF OUT */ -static int snd_atiixp_spdif_prepare(snd_pcm_substream_t *substream) +static int snd_atiixp_spdif_prepare(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); spin_lock_irq(&chip->reg_lock); if (chip->spdif_over_aclink) { @@ -855,9 +859,9 @@ static int snd_atiixp_spdif_prepare(snd_pcm_substream_t *substream) } /* set up slots and formats for analog OUT */ -static int snd_atiixp_playback_prepare(snd_pcm_substream_t *substream) +static int snd_atiixp_playback_prepare(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); unsigned int data; spin_lock_irq(&chip->reg_lock); @@ -900,9 +904,9 @@ static int snd_atiixp_playback_prepare(snd_pcm_substream_t *substream) } /* set up slots and formats for analog IN */ -static int snd_atiixp_capture_prepare(snd_pcm_substream_t *substream) +static int snd_atiixp_capture_prepare(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); spin_lock_irq(&chip->reg_lock); atiixp_update(chip, CMD, ATI_REG_CMD_INTERLEAVE_IN, @@ -915,11 +919,11 @@ static int snd_atiixp_capture_prepare(snd_pcm_substream_t *substream) /* * hw_params - allocate the buffer and set up buffer descriptors */ -static int snd_atiixp_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; + struct atiixp *chip = snd_pcm_substream_chip(substream); + struct atiixp_dma *dma = substream->runtime->private_data; int err; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); @@ -953,10 +957,10 @@ static int snd_atiixp_pcm_hw_params(snd_pcm_substream_t *substream, return err; } -static int snd_atiixp_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; + struct atiixp *chip = snd_pcm_substream_chip(substream); + struct atiixp_dma *dma = substream->runtime->private_data; if (dma->pcm_open_flag) { struct ac97_pcm *pcm = chip->pcms[dma->ac97_pcm_type]; @@ -972,7 +976,7 @@ static int snd_atiixp_pcm_hw_free(snd_pcm_substream_t * substream) /* * pcm hardware definition, identical for all DMA types */ -static snd_pcm_hardware_t snd_atiixp_pcm_hw = +static struct snd_pcm_hardware snd_atiixp_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -992,10 +996,11 @@ static snd_pcm_hardware_t snd_atiixp_pcm_hw = .periods_max = ATI_MAX_DESCRIPTORS, }; -static int snd_atiixp_pcm_open(snd_pcm_substream_t *substream, atiixp_dma_t *dma, int pcm_type) +static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream, + struct atiixp_dma *dma, int pcm_type) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct atiixp *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); @@ -1025,9 +1030,10 @@ static int snd_atiixp_pcm_open(snd_pcm_substream_t *substream, atiixp_dma_t *dma return 0; } -static int snd_atiixp_pcm_close(snd_pcm_substream_t *substream, atiixp_dma_t *dma) +static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream, + struct atiixp_dma *dma) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); /* disable DMA bits */ snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); spin_lock_irq(&chip->reg_lock); @@ -1040,9 +1046,9 @@ static int snd_atiixp_pcm_close(snd_pcm_substream_t *substream, atiixp_dma_t *dm /* */ -static int snd_atiixp_playback_open(snd_pcm_substream_t *substream) +static int snd_atiixp_playback_open(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); int err; down(&chip->open_mutex); @@ -1058,9 +1064,9 @@ static int snd_atiixp_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_atiixp_playback_close(snd_pcm_substream_t *substream) +static int snd_atiixp_playback_close(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); int err; down(&chip->open_mutex); err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]); @@ -1068,21 +1074,21 @@ static int snd_atiixp_playback_close(snd_pcm_substream_t *substream) return err; } -static int snd_atiixp_capture_open(snd_pcm_substream_t *substream) +static int snd_atiixp_capture_open(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); return snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_CAPTURE], 1); } -static int snd_atiixp_capture_close(snd_pcm_substream_t *substream) +static int snd_atiixp_capture_close(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_CAPTURE]); } -static int snd_atiixp_spdif_open(snd_pcm_substream_t *substream) +static int snd_atiixp_spdif_open(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); int err; down(&chip->open_mutex); if (chip->spdif_over_aclink) /* share DMA_PLAYBACK */ @@ -1093,9 +1099,9 @@ static int snd_atiixp_spdif_open(snd_pcm_substream_t *substream) return err; } -static int snd_atiixp_spdif_close(snd_pcm_substream_t *substream) +static int snd_atiixp_spdif_close(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp *chip = snd_pcm_substream_chip(substream); int err; down(&chip->open_mutex); if (chip->spdif_over_aclink) @@ -1107,7 +1113,7 @@ static int snd_atiixp_spdif_close(snd_pcm_substream_t *substream) } /* AC97 playback */ -static snd_pcm_ops_t snd_atiixp_playback_ops = { +static struct snd_pcm_ops snd_atiixp_playback_ops = { .open = snd_atiixp_playback_open, .close = snd_atiixp_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1119,7 +1125,7 @@ static snd_pcm_ops_t snd_atiixp_playback_ops = { }; /* AC97 capture */ -static snd_pcm_ops_t snd_atiixp_capture_ops = { +static struct snd_pcm_ops snd_atiixp_capture_ops = { .open = snd_atiixp_capture_open, .close = snd_atiixp_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1131,7 +1137,7 @@ static snd_pcm_ops_t snd_atiixp_capture_ops = { }; /* SPDIF playback */ -static snd_pcm_ops_t snd_atiixp_spdif_ops = { +static struct snd_pcm_ops snd_atiixp_spdif_ops = { .open = snd_atiixp_spdif_open, .close = snd_atiixp_spdif_close, .ioctl = snd_pcm_lib_ioctl, @@ -1178,7 +1184,7 @@ static struct ac97_pcm atiixp_pcm_defs[] __devinitdata = { }, }; -static atiixp_dma_ops_t snd_atiixp_playback_dma_ops = { +static struct atiixp_dma_ops snd_atiixp_playback_dma_ops = { .type = ATI_DMA_PLAYBACK, .llp_offset = ATI_REG_OUT_DMA_LINKPTR, .dt_cur = ATI_REG_OUT_DMA_DT_CUR, @@ -1187,7 +1193,7 @@ static atiixp_dma_ops_t snd_atiixp_playback_dma_ops = { .flush_dma = atiixp_out_flush_dma, }; -static atiixp_dma_ops_t snd_atiixp_capture_dma_ops = { +static struct atiixp_dma_ops snd_atiixp_capture_dma_ops = { .type = ATI_DMA_CAPTURE, .llp_offset = ATI_REG_IN_DMA_LINKPTR, .dt_cur = ATI_REG_IN_DMA_DT_CUR, @@ -1196,7 +1202,7 @@ static atiixp_dma_ops_t snd_atiixp_capture_dma_ops = { .flush_dma = atiixp_in_flush_dma, }; -static atiixp_dma_ops_t snd_atiixp_spdif_dma_ops = { +static struct atiixp_dma_ops snd_atiixp_spdif_dma_ops = { .type = ATI_DMA_SPDIF, .llp_offset = ATI_REG_SPDF_DMA_LINKPTR, .dt_cur = ATI_REG_SPDF_DMA_DT_CUR, @@ -1206,10 +1212,10 @@ static atiixp_dma_ops_t snd_atiixp_spdif_dma_ops = { }; -static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) +static int __devinit snd_atiixp_pcm_new(struct atiixp *chip) { - snd_pcm_t *pcm; - ac97_bus_t *pbus = chip->ac97_bus; + struct snd_pcm *pcm; + struct snd_ac97_bus *pbus = chip->ac97_bus; int err, i, num_pcms; /* initialize constants */ @@ -1238,7 +1244,8 @@ static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) } /* PCM #0: analog I/O */ - err = snd_pcm_new(chip->card, "ATI IXP AC97", ATI_PCMDEV_ANALOG, 1, 1, &pcm); + err = snd_pcm_new(chip->card, "ATI IXP AC97", + ATI_PCMDEV_ANALOG, 1, 1, &pcm); if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_atiixp_playback_ops); @@ -1248,7 +1255,8 @@ static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm; snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024); + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024); /* no SPDIF support on codec? */ if (chip->pcms[ATI_PCM_SPDIF] && ! chip->pcms[ATI_PCM_SPDIF]->rates) @@ -1259,7 +1267,8 @@ static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) chip->pcms[ATI_PCM_SPDIF]->rates = SNDRV_PCM_RATE_48000; /* PCM #1: spdif playback */ - err = snd_pcm_new(chip->card, "ATI IXP IEC958", ATI_PCMDEV_DIGITAL, 1, 0, &pcm); + err = snd_pcm_new(chip->card, "ATI IXP IEC958", + ATI_PCMDEV_DIGITAL, 1, 0, &pcm); if (err < 0) return err; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_atiixp_spdif_ops); @@ -1271,12 +1280,15 @@ static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) chip->pcmdevs[ATI_PCMDEV_DIGITAL] = pcm; snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024); + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024); /* pre-select AC97 SPDIF slots 10/11 */ for (i = 0; i < NUM_ATI_CODECS; i++) { if (chip->ac97[i]) - snd_ac97_update_bits(chip->ac97[i], AC97_EXTENDED_STATUS, 0x03 << 4, 0x03 << 4); + snd_ac97_update_bits(chip->ac97[i], + AC97_EXTENDED_STATUS, + 0x03 << 4, 0x03 << 4); } return 0; @@ -1289,7 +1301,7 @@ static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) */ static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - atiixp_t *chip = dev_id; + struct atiixp *chip = dev_id; unsigned int status; status = atiixp_read(chip, ISR); @@ -1344,13 +1356,14 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { { } /* terminator */ }; -static int __devinit snd_atiixp_mixer_new(atiixp_t *chip, int clock, const char *quirk_override) +static int __devinit snd_atiixp_mixer_new(struct atiixp *chip, int clock, + const char *quirk_override) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int i, err; int codec_count; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_atiixp_ac97_write, .read = snd_atiixp_ac97_read, }; @@ -1402,16 +1415,17 @@ static int __devinit snd_atiixp_mixer_new(atiixp_t *chip, int clock, const char /* * power management */ -static int snd_atiixp_suspend(snd_card_t *card, pm_message_t state) +static int snd_atiixp_suspend(struct snd_card *card, pm_message_t state) { - atiixp_t *chip = card->pm_private_data; + struct atiixp *chip = card->pm_private_data; int i; for (i = 0; i < NUM_ATI_PCMDEVS; i++) if (chip->pcmdevs[i]) { - atiixp_dma_t *dma = &chip->dmas[i]; + struct atiixp_dma *dma = &chip->dmas[i]; if (dma->substream && dma->running) - dma->saved_curptr = readl(chip->remap_addr + dma->ops->dt_cur); + dma->saved_curptr = readl(chip->remap_addr + + dma->ops->dt_cur); snd_pcm_suspend_all(chip->pcmdevs[i]); } for (i = 0; i < NUM_ATI_CODECS; i++) @@ -1425,9 +1439,9 @@ static int snd_atiixp_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_atiixp_resume(snd_card_t *card) +static int snd_atiixp_resume(struct snd_card *card) { - atiixp_t *chip = card->pm_private_data; + struct atiixp *chip = card->pm_private_data; int i; pci_enable_device(chip->pci); @@ -1443,13 +1457,14 @@ static int snd_atiixp_resume(snd_card_t *card) for (i = 0; i < NUM_ATI_PCMDEVS; i++) if (chip->pcmdevs[i]) { - atiixp_dma_t *dma = &chip->dmas[i]; + struct atiixp_dma *dma = &chip->dmas[i]; if (dma->substream && dma->suspended) { dma->ops->enable_dma(chip, 1); dma->substream->ops->prepare(dma->substream); writel((u32)dma->desc_buf.addr | ATI_REG_LINKPTR_EN, chip->remap_addr + dma->ops->llp_offset); - writel(dma->saved_curptr, chip->remap_addr + dma->ops->dt_cur); + writel(dma->saved_curptr, chip->remap_addr + + dma->ops->dt_cur); } } @@ -1462,18 +1477,19 @@ static int snd_atiixp_resume(snd_card_t *card) * proc interface for register dump */ -static void snd_atiixp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_atiixp_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - atiixp_t *chip = entry->private_data; + struct atiixp *chip = entry->private_data; int i; for (i = 0; i < 256; i += 4) snd_iprintf(buffer, "%02x: %08x\n", i, readl(chip->remap_addr + i)); } -static void __devinit snd_atiixp_proc_init(atiixp_t *chip) +static void __devinit snd_atiixp_proc_init(struct atiixp *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "atiixp", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read); @@ -1485,7 +1501,7 @@ static void __devinit snd_atiixp_proc_init(atiixp_t *chip) * destructor */ -static int snd_atiixp_free(atiixp_t *chip) +static int snd_atiixp_free(struct atiixp *chip) { if (chip->irq < 0) goto __hw_end; @@ -1493,7 +1509,7 @@ static int snd_atiixp_free(atiixp_t *chip) synchronize_irq(chip->irq); __hw_end: if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); if (chip->remap_addr) iounmap(chip->remap_addr); pci_release_regions(chip->pci); @@ -1502,23 +1518,23 @@ static int snd_atiixp_free(atiixp_t *chip) return 0; } -static int snd_atiixp_dev_free(snd_device_t *device) +static int snd_atiixp_dev_free(struct snd_device *device) { - atiixp_t *chip = device->device_data; + struct atiixp *chip = device->device_data; return snd_atiixp_free(chip); } /* * constructor for chip instance */ -static int __devinit snd_atiixp_create(snd_card_t *card, +static int __devinit snd_atiixp_create(struct snd_card *card, struct pci_dev *pci, - atiixp_t **r_chip) + struct atiixp **r_chip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_atiixp_dev_free, }; - atiixp_t *chip; + struct atiixp *chip; int err; if ((err = pci_enable_device(pci)) < 0) @@ -1548,7 +1564,8 @@ static int __devinit snd_atiixp_create(snd_card_t *card, return -EIO; } - if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip)) { + if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ, + card->shortname, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_atiixp_free(chip); return -EBUSY; @@ -1572,8 +1589,8 @@ static int __devinit snd_atiixp_create(snd_card_t *card, static int __devinit snd_atiixp_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - atiixp_t *chip; + struct snd_card *card; + struct atiixp *chip; unsigned char revision; int err; diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 649a999..15be161 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -176,24 +176,18 @@ module_param(enable, bool, 0444); #define ATI_MAX_DESCRIPTORS 256 /* max number of descriptor packets */ -/* - */ - -typedef struct snd_atiixp atiixp_t; -typedef struct snd_atiixp_dma atiixp_dma_t; -typedef struct snd_atiixp_dma_ops atiixp_dma_ops_t; - +struct atiixp_modem; /* * DMA packate descriptor */ -typedef struct atiixp_dma_desc { +struct atiixp_dma_desc { u32 addr; /* DMA buffer address */ u16 status; /* status bits */ u16 size; /* size of the packet in dwords */ u32 next; /* address of the next packet descriptor */ -} atiixp_dma_desc_t; +}; /* * stream enum @@ -208,22 +202,25 @@ enum { ATI_PCMDEV_ANALOG, NUM_ATI_PCMDEVS }; /* pcm devices */ /* * constants and callbacks for each DMA type */ -struct snd_atiixp_dma_ops { +struct atiixp_dma_ops { int type; /* ATI_DMA_XXX */ unsigned int llp_offset; /* LINKPTR offset */ unsigned int dt_cur; /* DT_CUR offset */ - void (*enable_dma)(atiixp_t *chip, int on); /* called from open callback */ - void (*enable_transfer)(atiixp_t *chip, int on); /* called from trigger (START/STOP) */ - void (*flush_dma)(atiixp_t *chip); /* called from trigger (STOP only) */ + /* called from open callback */ + void (*enable_dma)(struct atiixp_modem *chip, int on); + /* called from trigger (START/STOP) */ + void (*enable_transfer)(struct atiixp_modem *chip, int on); + /* called from trigger (STOP only) */ + void (*flush_dma)(struct atiixp_modem *chip); }; /* * DMA stream */ -struct snd_atiixp_dma { - const atiixp_dma_ops_t *ops; +struct atiixp_dma { + const struct atiixp_dma_ops *ops; struct snd_dma_buffer desc_buf; - snd_pcm_substream_t *substream; /* assigned PCM substream */ + struct snd_pcm_substream *substream; /* assigned PCM substream */ unsigned int buf_addr, buf_bytes; /* DMA buffer address, bytes */ unsigned int period_bytes, periods; int opened; @@ -235,8 +232,8 @@ struct snd_atiixp_dma { /* * ATI IXP chip */ -struct snd_atiixp { - snd_card_t *card; +struct atiixp_modem { + struct snd_card *card; struct pci_dev *pci; struct resource *res; /* memory i/o */ @@ -244,14 +241,14 @@ struct snd_atiixp { void __iomem *remap_addr; int irq; - ac97_bus_t *ac97_bus; - ac97_t *ac97[NUM_ATI_CODECS]; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97[NUM_ATI_CODECS]; spinlock_t reg_lock; - atiixp_dma_t dmas[NUM_ATI_DMAS]; + struct atiixp_dma dmas[NUM_ATI_DMAS]; struct ac97_pcm *pcms[NUM_ATI_PCMS]; - snd_pcm_t *pcmdevs[NUM_ATI_PCMDEVS]; + struct snd_pcm *pcmdevs[NUM_ATI_PCMDEVS]; int max_channels; /* max. channels for PCM out */ @@ -281,8 +278,8 @@ MODULE_DEVICE_TABLE(pci, snd_atiixp_ids); * update the bits of the given register. * return 1 if the bits changed. */ -static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg, - unsigned int mask, unsigned int value) +static int snd_atiixp_update_bits(struct atiixp_modem *chip, unsigned int reg, + unsigned int mask, unsigned int value) { void __iomem *addr = chip->remap_addr + reg; unsigned int data, old_data; @@ -313,7 +310,7 @@ static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg, */ #define ATI_DESC_LIST_SIZE \ - PAGE_ALIGN(ATI_MAX_DESCRIPTORS * sizeof(atiixp_dma_desc_t)) + PAGE_ALIGN(ATI_MAX_DESCRIPTORS * sizeof(struct atiixp_dma_desc)) /* * build packets ring for the given buffer size. @@ -324,10 +321,11 @@ static int snd_atiixp_update_bits(atiixp_t *chip, unsigned int reg, * * the ring is built in this function, and is set up to the hardware. */ -static int atiixp_build_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, - snd_pcm_substream_t *substream, - unsigned int periods, - unsigned int period_bytes) +static int atiixp_build_dma_packets(struct atiixp_modem *chip, + struct atiixp_dma *dma, + struct snd_pcm_substream *substream, + unsigned int periods, + unsigned int period_bytes) { unsigned int i; u32 addr, desc_addr; @@ -357,11 +355,12 @@ static int atiixp_build_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, addr = (u32)substream->runtime->dma_addr; desc_addr = (u32)dma->desc_buf.addr; for (i = 0; i < periods; i++) { - atiixp_dma_desc_t *desc = &((atiixp_dma_desc_t *)dma->desc_buf.area)[i]; + struct atiixp_dma_desc *desc; + desc = &((struct atiixp_dma_desc *)dma->desc_buf.area)[i]; desc->addr = cpu_to_le32(addr); desc->status = 0; desc->size = period_bytes >> 2; /* in dwords */ - desc_addr += sizeof(atiixp_dma_desc_t); + desc_addr += sizeof(struct atiixp_dma_desc); if (i == periods - 1) desc->next = cpu_to_le32((u32)dma->desc_buf.addr); else @@ -381,7 +380,9 @@ static int atiixp_build_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, /* * remove the ring buffer and release it if assigned */ -static void atiixp_clear_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, snd_pcm_substream_t *substream) +static void atiixp_clear_dma_packets(struct atiixp_modem *chip, + struct atiixp_dma *dma, + struct snd_pcm_substream *substream) { if (dma->desc_buf.area) { writel(0, chip->remap_addr + dma->ops->llp_offset); @@ -393,7 +394,7 @@ static void atiixp_clear_dma_packets(atiixp_t *chip, atiixp_dma_t *dma, snd_pcm_ /* * AC97 interface */ -static int snd_atiixp_acquire_codec(atiixp_t *chip) +static int snd_atiixp_acquire_codec(struct atiixp_modem *chip) { int timeout = 1000; @@ -407,7 +408,9 @@ static int snd_atiixp_acquire_codec(atiixp_t *chip) return 0; } -static unsigned short snd_atiixp_codec_read(atiixp_t *chip, unsigned short codec, unsigned short reg) +static unsigned short snd_atiixp_codec_read(struct atiixp_modem *chip, + unsigned short codec, + unsigned short reg) { unsigned int data; int timeout; @@ -435,7 +438,9 @@ static unsigned short snd_atiixp_codec_read(atiixp_t *chip, unsigned short codec } -static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigned short reg, unsigned short val) +static void snd_atiixp_codec_write(struct atiixp_modem *chip, + unsigned short codec, + unsigned short reg, unsigned short val) { unsigned int data; @@ -448,16 +453,18 @@ static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigne } -static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_atiixp_ac97_read(struct snd_ac97 *ac97, + unsigned short reg) { - atiixp_t *chip = ac97->private_data; + struct atiixp_modem *chip = ac97->private_data; return snd_atiixp_codec_read(chip, ac97->num, reg); } -static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +static void snd_atiixp_ac97_write(struct snd_ac97 *ac97, unsigned short reg, + unsigned short val) { - atiixp_t *chip = ac97->private_data; + struct atiixp_modem *chip = ac97->private_data; if (reg == AC97_GPIO_STATUS) { atiixp_write(chip, MODEM_OUT_GPIO, (val << ATI_REG_MODEM_OUT_GPIO_DATA_SHIFT) | ATI_REG_MODEM_OUT_GPIO_EN); @@ -469,7 +476,7 @@ static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned sho /* * reset AC link */ -static int snd_atiixp_aclink_reset(atiixp_t *chip) +static int snd_atiixp_aclink_reset(struct atiixp_modem *chip) { int timeout; @@ -505,7 +512,7 @@ static int snd_atiixp_aclink_reset(atiixp_t *chip) } #ifdef CONFIG_PM -static int snd_atiixp_aclink_down(atiixp_t *chip) +static int snd_atiixp_aclink_down(struct atiixp_modem *chip) { // if (atiixp_read(chip, MODEM_MIRROR) & 0x1) /* modem running, too? */ // return -EBUSY; @@ -530,7 +537,7 @@ static int snd_atiixp_aclink_down(atiixp_t *chip) ATI_REG_ISR_CODEC2_NOT_READY) #define CODEC_CHECK_BITS (ALL_CODEC_NOT_READY|ATI_REG_ISR_NEW_FRAME) -static int snd_atiixp_codec_detect(atiixp_t *chip) +static int snd_atiixp_codec_detect(struct atiixp_modem *chip) { int timeout; @@ -556,7 +563,7 @@ static int snd_atiixp_codec_detect(atiixp_t *chip) /* * enable DMA and irqs */ -static int snd_atiixp_chip_start(atiixp_t *chip) +static int snd_atiixp_chip_start(struct atiixp_modem *chip) { unsigned int reg; @@ -581,7 +588,7 @@ static int snd_atiixp_chip_start(atiixp_t *chip) /* * disable DMA and IRQs */ -static int snd_atiixp_chip_stop(atiixp_t *chip) +static int snd_atiixp_chip_stop(struct atiixp_modem *chip) { /* clear interrupt source */ atiixp_write(chip, ISR, atiixp_read(chip, ISR)); @@ -600,11 +607,11 @@ static int snd_atiixp_chip_stop(atiixp_t *chip) * position. when SG-buffer is implemented, the offset must be calculated * correctly... */ -static snd_pcm_uframes_t snd_atiixp_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_atiixp_pcm_pointer(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - atiixp_dma_t *dma = (atiixp_dma_t *)runtime->private_data; + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct atiixp_dma *dma = runtime->private_data; unsigned int curptr; int timeout = 1000; @@ -625,7 +632,8 @@ static snd_pcm_uframes_t snd_atiixp_pcm_pointer(snd_pcm_substream_t *substream) /* * XRUN detected, and stop the PCM substream */ -static void snd_atiixp_xrun_dma(atiixp_t *chip, atiixp_dma_t *dma) +static void snd_atiixp_xrun_dma(struct atiixp_modem *chip, + struct atiixp_dma *dma) { if (! dma->substream || ! dma->running) return; @@ -636,7 +644,8 @@ static void snd_atiixp_xrun_dma(atiixp_t *chip, atiixp_dma_t *dma) /* * the period ack. update the substream. */ -static void snd_atiixp_update_dma(atiixp_t *chip, atiixp_dma_t *dma) +static void snd_atiixp_update_dma(struct atiixp_modem *chip, + struct atiixp_dma *dma) { if (! dma->substream || ! dma->running) return; @@ -645,7 +654,7 @@ static void snd_atiixp_update_dma(atiixp_t *chip, atiixp_dma_t *dma) /* set BUS_BUSY interrupt bit if any DMA is running */ /* call with spinlock held */ -static void snd_atiixp_check_bus_busy(atiixp_t *chip) +static void snd_atiixp_check_bus_busy(struct atiixp_modem *chip) { unsigned int bus_busy; if (atiixp_read(chip, CMD) & (ATI_REG_CMD_MODEM_SEND1_EN | @@ -659,10 +668,10 @@ static void snd_atiixp_check_bus_busy(atiixp_t *chip) /* common trigger callback * calling the lowlevel callbacks in it */ -static int snd_atiixp_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_atiixp_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); + struct atiixp_dma *dma = substream->runtime->private_data; int err = 0; snd_assert(dma->ops->enable_transfer && dma->ops->flush_dma, return -EINVAL); @@ -700,13 +709,13 @@ static int snd_atiixp_pcm_trigger(snd_pcm_substream_t *substream, int cmd) */ /* flush FIFO of analog OUT DMA */ -static void atiixp_out_flush_dma(atiixp_t *chip) +static void atiixp_out_flush_dma(struct atiixp_modem *chip) { atiixp_write(chip, MODEM_FIFO_FLUSH, ATI_REG_MODEM_FIFO_OUT1_FLUSH); } /* enable/disable analog OUT DMA */ -static void atiixp_out_enable_dma(atiixp_t *chip, int on) +static void atiixp_out_enable_dma(struct atiixp_modem *chip, int on) { unsigned int data; data = atiixp_read(chip, CMD); @@ -721,21 +730,21 @@ static void atiixp_out_enable_dma(atiixp_t *chip, int on) } /* start/stop transfer over OUT DMA */ -static void atiixp_out_enable_transfer(atiixp_t *chip, int on) +static void atiixp_out_enable_transfer(struct atiixp_modem *chip, int on) { atiixp_update(chip, CMD, ATI_REG_CMD_MODEM_SEND1_EN, on ? ATI_REG_CMD_MODEM_SEND1_EN : 0); } /* enable/disable analog IN DMA */ -static void atiixp_in_enable_dma(atiixp_t *chip, int on) +static void atiixp_in_enable_dma(struct atiixp_modem *chip, int on) { atiixp_update(chip, CMD, ATI_REG_CMD_MODEM_IN_DMA_EN, on ? ATI_REG_CMD_MODEM_IN_DMA_EN : 0); } /* start/stop analog IN DMA */ -static void atiixp_in_enable_transfer(atiixp_t *chip, int on) +static void atiixp_in_enable_transfer(struct atiixp_modem *chip, int on) { if (on) { unsigned int data = atiixp_read(chip, CMD); @@ -748,15 +757,15 @@ static void atiixp_in_enable_transfer(atiixp_t *chip, int on) } /* flush FIFO of analog IN DMA */ -static void atiixp_in_flush_dma(atiixp_t *chip) +static void atiixp_in_flush_dma(struct atiixp_modem *chip) { atiixp_write(chip, MODEM_FIFO_FLUSH, ATI_REG_MODEM_FIFO_IN_FLUSH); } /* set up slots and formats for analog OUT */ -static int snd_atiixp_playback_prepare(snd_pcm_substream_t *substream) +static int snd_atiixp_playback_prepare(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); unsigned int data; spin_lock_irq(&chip->reg_lock); @@ -770,7 +779,7 @@ static int snd_atiixp_playback_prepare(snd_pcm_substream_t *substream) } /* set up slots and formats for analog IN */ -static int snd_atiixp_capture_prepare(snd_pcm_substream_t *substream) +static int snd_atiixp_capture_prepare(struct snd_pcm_substream *substream) { return 0; } @@ -778,11 +787,11 @@ static int snd_atiixp_capture_prepare(snd_pcm_substream_t *substream) /* * hw_params - allocate the buffer and set up buffer descriptors */ -static int snd_atiixp_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_atiixp_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); + struct atiixp_dma *dma = substream->runtime->private_data; int err; int i; @@ -809,10 +818,10 @@ static int snd_atiixp_pcm_hw_params(snd_pcm_substream_t *substream, return err; } -static int snd_atiixp_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_atiixp_pcm_hw_free(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - atiixp_dma_t *dma = (atiixp_dma_t *)substream->runtime->private_data; + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); + struct atiixp_dma *dma = substream->runtime->private_data; atiixp_clear_dma_packets(chip, dma, substream); snd_pcm_lib_free_pages(substream); @@ -823,13 +832,15 @@ static int snd_atiixp_pcm_hw_free(snd_pcm_substream_t * substream) /* * pcm hardware definition, identical for all DMA types */ -static snd_pcm_hardware_t snd_atiixp_pcm_hw = +static struct snd_pcm_hardware snd_atiixp_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, - .rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_KNOT, + .rates = (SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000 | + SNDRV_PCM_RATE_KNOT), .rate_min = 8000, .rate_max = 16000, .channels_min = 2, @@ -841,13 +852,14 @@ static snd_pcm_hardware_t snd_atiixp_pcm_hw = .periods_max = ATI_MAX_DESCRIPTORS, }; -static int snd_atiixp_pcm_open(snd_pcm_substream_t *substream, atiixp_dma_t *dma, int pcm_type) +static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream, + struct atiixp_dma *dma, int pcm_type) { - atiixp_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; static unsigned int rates[] = { 8000, 9600, 12000, 16000 }; - static snd_pcm_hw_constraint_list_t hw_constraints_rates = { + static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, @@ -860,9 +872,12 @@ static int snd_atiixp_pcm_open(snd_pcm_substream_t *substream, atiixp_dma_t *dma dma->substream = substream; runtime->hw = snd_atiixp_pcm_hw; dma->ac97_pcm_type = pcm_type; - if ((err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates)) < 0) + if ((err = snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &hw_constraints_rates)) < 0) return err; - if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) + if ((err = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; runtime->private_data = dma; @@ -875,9 +890,10 @@ static int snd_atiixp_pcm_open(snd_pcm_substream_t *substream, atiixp_dma_t *dma return 0; } -static int snd_atiixp_pcm_close(snd_pcm_substream_t *substream, atiixp_dma_t *dma) +static int snd_atiixp_pcm_close(struct snd_pcm_substream *substream, + struct atiixp_dma *dma) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); /* disable DMA bits */ snd_assert(dma->ops && dma->ops->enable_dma, return -EINVAL); spin_lock_irq(&chip->reg_lock); @@ -890,9 +906,9 @@ static int snd_atiixp_pcm_close(snd_pcm_substream_t *substream, atiixp_dma_t *dm /* */ -static int snd_atiixp_playback_open(snd_pcm_substream_t *substream) +static int snd_atiixp_playback_open(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); int err; down(&chip->open_mutex); @@ -903,9 +919,9 @@ static int snd_atiixp_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_atiixp_playback_close(snd_pcm_substream_t *substream) +static int snd_atiixp_playback_close(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); int err; down(&chip->open_mutex); err = snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_PLAYBACK]); @@ -913,21 +929,21 @@ static int snd_atiixp_playback_close(snd_pcm_substream_t *substream) return err; } -static int snd_atiixp_capture_open(snd_pcm_substream_t *substream) +static int snd_atiixp_capture_open(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); return snd_atiixp_pcm_open(substream, &chip->dmas[ATI_DMA_CAPTURE], 1); } -static int snd_atiixp_capture_close(snd_pcm_substream_t *substream) +static int snd_atiixp_capture_close(struct snd_pcm_substream *substream) { - atiixp_t *chip = snd_pcm_substream_chip(substream); + struct atiixp_modem *chip = snd_pcm_substream_chip(substream); return snd_atiixp_pcm_close(substream, &chip->dmas[ATI_DMA_CAPTURE]); } /* AC97 playback */ -static snd_pcm_ops_t snd_atiixp_playback_ops = { +static struct snd_pcm_ops snd_atiixp_playback_ops = { .open = snd_atiixp_playback_open, .close = snd_atiixp_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -939,7 +955,7 @@ static snd_pcm_ops_t snd_atiixp_playback_ops = { }; /* AC97 capture */ -static snd_pcm_ops_t snd_atiixp_capture_ops = { +static struct snd_pcm_ops snd_atiixp_capture_ops = { .open = snd_atiixp_capture_open, .close = snd_atiixp_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -950,7 +966,7 @@ static snd_pcm_ops_t snd_atiixp_capture_ops = { .pointer = snd_atiixp_pcm_pointer, }; -static atiixp_dma_ops_t snd_atiixp_playback_dma_ops = { +static struct atiixp_dma_ops snd_atiixp_playback_dma_ops = { .type = ATI_DMA_PLAYBACK, .llp_offset = ATI_REG_MODEM_OUT_DMA1_LINKPTR, .dt_cur = ATI_REG_MODEM_OUT_DMA1_DT_CUR, @@ -959,7 +975,7 @@ static atiixp_dma_ops_t snd_atiixp_playback_dma_ops = { .flush_dma = atiixp_out_flush_dma, }; -static atiixp_dma_ops_t snd_atiixp_capture_dma_ops = { +static struct atiixp_dma_ops snd_atiixp_capture_dma_ops = { .type = ATI_DMA_CAPTURE, .llp_offset = ATI_REG_MODEM_IN_DMA_LINKPTR, .dt_cur = ATI_REG_MODEM_IN_DMA_DT_CUR, @@ -968,9 +984,9 @@ static atiixp_dma_ops_t snd_atiixp_capture_dma_ops = { .flush_dma = atiixp_in_flush_dma, }; -static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) +static int __devinit snd_atiixp_pcm_new(struct atiixp_modem *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; /* initialize constants */ @@ -989,7 +1005,8 @@ static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) chip->pcmdevs[ATI_PCMDEV_ANALOG] = pcm; snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024); + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024); return 0; } @@ -1001,7 +1018,7 @@ static int __devinit snd_atiixp_pcm_new(atiixp_t *chip) */ static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - atiixp_t *chip = dev_id; + struct atiixp_modem *chip = dev_id; unsigned int status; status = atiixp_read(chip, ISR); @@ -1040,13 +1057,13 @@ static irqreturn_t snd_atiixp_interrupt(int irq, void *dev_id, struct pt_regs *r * ac97 mixer section */ -static int __devinit snd_atiixp_mixer_new(atiixp_t *chip, int clock) +static int __devinit snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int i, err; int codec_count; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_atiixp_ac97_write, .read = snd_atiixp_ac97_read, }; @@ -1096,9 +1113,9 @@ static int __devinit snd_atiixp_mixer_new(atiixp_t *chip, int clock) /* * power management */ -static int snd_atiixp_suspend(snd_card_t *card, pm_message_t state) +static int snd_atiixp_suspend(struct snd_card *card, pm_message_t state) { - atiixp_t *chip = card->pm_private_data; + struct atiixp_modem *chip = card->pm_private_data; int i; for (i = 0; i < NUM_ATI_PCMDEVS; i++) @@ -1115,9 +1132,9 @@ static int snd_atiixp_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_atiixp_resume(snd_card_t *card) +static int snd_atiixp_resume(struct snd_card *card) { - atiixp_t *chip = card->pm_private_data; + struct atiixp_modem *chip = card->pm_private_data; int i; pci_enable_device(chip->pci); @@ -1140,18 +1157,19 @@ static int snd_atiixp_resume(snd_card_t *card) * proc interface for register dump */ -static void snd_atiixp_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_atiixp_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - atiixp_t *chip = entry->private_data; + struct atiixp_modem *chip = entry->private_data; int i; for (i = 0; i < 256; i += 4) snd_iprintf(buffer, "%02x: %08x\n", i, readl(chip->remap_addr + i)); } -static void __devinit snd_atiixp_proc_init(atiixp_t *chip) +static void __devinit snd_atiixp_proc_init(struct atiixp_modem *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "atiixp-modem", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read); @@ -1163,7 +1181,7 @@ static void __devinit snd_atiixp_proc_init(atiixp_t *chip) * destructor */ -static int snd_atiixp_free(atiixp_t *chip) +static int snd_atiixp_free(struct atiixp_modem *chip) { if (chip->irq < 0) goto __hw_end; @@ -1171,7 +1189,7 @@ static int snd_atiixp_free(atiixp_t *chip) synchronize_irq(chip->irq); __hw_end: if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); if (chip->remap_addr) iounmap(chip->remap_addr); pci_release_regions(chip->pci); @@ -1180,23 +1198,23 @@ static int snd_atiixp_free(atiixp_t *chip) return 0; } -static int snd_atiixp_dev_free(snd_device_t *device) +static int snd_atiixp_dev_free(struct snd_device *device) { - atiixp_t *chip = device->device_data; + struct atiixp_modem *chip = device->device_data; return snd_atiixp_free(chip); } /* * constructor for chip instance */ -static int __devinit snd_atiixp_create(snd_card_t *card, - struct pci_dev *pci, - atiixp_t **r_chip) +static int __devinit snd_atiixp_create(struct snd_card *card, + struct pci_dev *pci, + struct atiixp_modem **r_chip) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_atiixp_dev_free, }; - atiixp_t *chip; + struct atiixp_modem *chip; int err; if ((err = pci_enable_device(pci)) < 0) @@ -1226,7 +1244,8 @@ static int __devinit snd_atiixp_create(snd_card_t *card, return -EIO; } - if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip)) { + if (request_irq(pci->irq, snd_atiixp_interrupt, SA_INTERRUPT|SA_SHIRQ, + card->shortname, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_atiixp_free(chip); return -EBUSY; @@ -1250,8 +1269,8 @@ static int __devinit snd_atiixp_create(snd_card_t *card, static int __devinit snd_atiixp_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - atiixp_t *chip; + struct snd_card *card; + struct atiixp_modem *chip; unsigned char revision; int err; -- cgit v1.1 From 95de77660bb54e603d32f2ce342ae16e6de1b2d4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:02:42 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI AZT3328 Modules: AZT3328 driver Remove xxx_t typedefs from the PCI AZT3328 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/azt3328.c | 216 +++++++++++++++++++++++++++------------------------- 1 file changed, 111 insertions(+), 105 deletions(-) diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index 96d1ba0..e077eb3 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -186,7 +186,7 @@ static int seqtimer_scaling = 128; module_param(seqtimer_scaling, int, 0444); MODULE_PARM_DESC(seqtimer_scaling, "Set 1024000Hz sequencer timer scale factor (lockup danger!). Default 128."); -typedef struct _snd_azf3328 { +struct snd_azf3328 { /* often-used fields towards beginning, then grouped */ unsigned long codec_port; unsigned long io2_port; @@ -196,16 +196,16 @@ typedef struct _snd_azf3328 { spinlock_t reg_lock; - snd_timer_t *timer; + struct snd_timer *timer; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; unsigned int is_playing; unsigned int is_recording; - snd_card_t *card; - snd_rawmidi_t *rmidi; + struct snd_card *card; + struct snd_rawmidi *rmidi; #ifdef SUPPORT_JOYSTICK struct gameport *gameport; @@ -213,7 +213,7 @@ typedef struct _snd_azf3328 { struct pci_dev *pci; int irq; -} azf3328_t; +}; static const struct pci_device_id snd_azf3328_ids[] = { { 0x122D, 0x50DC, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* PCI168/3328 */ @@ -224,61 +224,61 @@ static const struct pci_device_id snd_azf3328_ids[] = { MODULE_DEVICE_TABLE(pci, snd_azf3328_ids); static inline void -snd_azf3328_codec_outb(const azf3328_t *chip, int reg, u8 value) +snd_azf3328_codec_outb(const struct snd_azf3328 *chip, int reg, u8 value) { outb(value, chip->codec_port + reg); } static inline u8 -snd_azf3328_codec_inb(const azf3328_t *chip, int reg) +snd_azf3328_codec_inb(const struct snd_azf3328 *chip, int reg) { return inb(chip->codec_port + reg); } static inline void -snd_azf3328_codec_outw(const azf3328_t *chip, int reg, u16 value) +snd_azf3328_codec_outw(const struct snd_azf3328 *chip, int reg, u16 value) { outw(value, chip->codec_port + reg); } static inline u16 -snd_azf3328_codec_inw(const azf3328_t *chip, int reg) +snd_azf3328_codec_inw(const struct snd_azf3328 *chip, int reg) { return inw(chip->codec_port + reg); } static inline void -snd_azf3328_codec_outl(const azf3328_t *chip, int reg, u32 value) +snd_azf3328_codec_outl(const struct snd_azf3328 *chip, int reg, u32 value) { outl(value, chip->codec_port + reg); } static inline void -snd_azf3328_io2_outb(const azf3328_t *chip, int reg, u8 value) +snd_azf3328_io2_outb(const struct snd_azf3328 *chip, int reg, u8 value) { outb(value, chip->io2_port + reg); } static inline u8 -snd_azf3328_io2_inb(const azf3328_t *chip, int reg) +snd_azf3328_io2_inb(const struct snd_azf3328 *chip, int reg) { return inb(chip->io2_port + reg); } static inline void -snd_azf3328_mixer_outw(const azf3328_t *chip, int reg, u16 value) +snd_azf3328_mixer_outw(const struct snd_azf3328 *chip, int reg, u16 value) { outw(value, chip->mixer_port + reg); } static inline u16 -snd_azf3328_mixer_inw(const azf3328_t *chip, int reg) +snd_azf3328_mixer_inw(const struct snd_azf3328 *chip, int reg) { return inw(chip->mixer_port + reg); } static void -snd_azf3328_mixer_set_mute(const azf3328_t *chip, int reg, int do_mute) +snd_azf3328_mixer_set_mute(const struct snd_azf3328 *chip, int reg, int do_mute) { unsigned long portbase = chip->mixer_port + reg + 1; unsigned char oldval; @@ -294,7 +294,7 @@ snd_azf3328_mixer_set_mute(const azf3328_t *chip, int reg, int do_mute) } static void -snd_azf3328_mixer_write_volume_gradually(const azf3328_t *chip, int reg, unsigned char dst_vol_left, unsigned char dst_vol_right, int chan_sel, int delay) +snd_azf3328_mixer_write_volume_gradually(const struct snd_azf3328 *chip, int reg, unsigned char dst_vol_left, unsigned char dst_vol_right, int chan_sel, int delay) { unsigned long portbase = chip->mixer_port + reg; unsigned char curr_vol_left = 0, curr_vol_right = 0; @@ -353,14 +353,14 @@ snd_azf3328_mixer_write_volume_gradually(const azf3328_t *chip, int reg, unsigne /* * general mixer element */ -typedef struct azf3328_mixer_reg { +struct azf3328_mixer_reg { unsigned int reg; unsigned int lchan_shift, rchan_shift; unsigned int mask; unsigned int invert: 1; unsigned int stereo: 1; unsigned int enum_c: 4; -} azf3328_mixer_reg_t; +}; #define COMPOSE_MIXER_REG(reg,lchan_shift,rchan_shift,mask,invert,stereo,enum_c) \ ((reg) | (lchan_shift << 8) | (rchan_shift << 12) | \ @@ -369,7 +369,7 @@ typedef struct azf3328_mixer_reg { (stereo << 25) | \ (enum_c << 26)) -static void snd_azf3328_mixer_reg_decode(azf3328_mixer_reg_t *r, unsigned long val) +static void snd_azf3328_mixer_reg_decode(struct azf3328_mixer_reg *r, unsigned long val) { r->reg = val & 0xff; r->lchan_shift = (val >> 8) & 0x0f; @@ -420,9 +420,10 @@ static void snd_azf3328_mixer_reg_decode(azf3328_mixer_reg_t *r, unsigned long v } static int -snd_azf3328_info_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +snd_azf3328_info_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - azf3328_mixer_reg_t reg; + struct azf3328_mixer_reg reg; snd_azf3328_dbgcallenter(); snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); @@ -436,10 +437,11 @@ snd_azf3328_info_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) } static int -snd_azf3328_get_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_azf3328_get_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - azf3328_t *chip = snd_kcontrol_chip(kcontrol); - azf3328_mixer_reg_t reg; + struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); + struct azf3328_mixer_reg reg; unsigned int oreg, val; snd_azf3328_dbgcallenter(); @@ -466,10 +468,11 @@ snd_azf3328_get_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol } static int -snd_azf3328_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_azf3328_put_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - azf3328_t *chip = snd_kcontrol_chip(kcontrol); - azf3328_mixer_reg_t reg; + struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); + struct azf3328_mixer_reg reg; unsigned int oreg, nreg, val; snd_azf3328_dbgcallenter(); @@ -506,7 +509,8 @@ snd_azf3328_put_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol } static int -snd_azf3328_info_mixer_enum(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +snd_azf3328_info_mixer_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static const char * const texts1[] = { "ModemOut1", "ModemOut2" @@ -518,7 +522,7 @@ snd_azf3328_info_mixer_enum(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinf "Mic", "CD", "Video", "Aux", "Line", "Mix", "Mix Mono", "Phone" }; - azf3328_mixer_reg_t reg; + struct azf3328_mixer_reg reg; snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -540,10 +544,11 @@ snd_azf3328_info_mixer_enum(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinf } static int -snd_azf3328_get_mixer_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_azf3328_get_mixer_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - azf3328_t *chip = snd_kcontrol_chip(kcontrol); - azf3328_mixer_reg_t reg; + struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); + struct azf3328_mixer_reg reg; unsigned short val; snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); @@ -563,10 +568,11 @@ snd_azf3328_get_mixer_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uco } static int -snd_azf3328_put_mixer_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_azf3328_put_mixer_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - azf3328_t *chip = snd_kcontrol_chip(kcontrol); - azf3328_mixer_reg_t reg; + struct snd_azf3328 *chip = snd_kcontrol_chip(kcontrol); + struct azf3328_mixer_reg reg; unsigned int oreg, nreg, val; snd_azf3328_mixer_reg_decode(®, kcontrol->private_value); @@ -594,7 +600,7 @@ snd_azf3328_put_mixer_enum(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * uco return (nreg != oreg); } -static const snd_kcontrol_new_t snd_azf3328_mixer_controls[] __devinitdata = { +static const struct snd_kcontrol_new snd_azf3328_mixer_controls[] __devinitdata = { AZF3328_MIXER_SWITCH("Master Playback Switch", IDX_MIXER_PLAY_MASTER, 15, 1), AZF3328_MIXER_VOL_STEREO("Master Playback Volume", IDX_MIXER_PLAY_MASTER, 0x1f, 1), AZF3328_MIXER_SWITCH("Wave Playback Switch", IDX_MIXER_WAVEOUT, 15, 1), @@ -666,10 +672,10 @@ static const u16 __devinitdata snd_azf3328_init_values[][2] = { }; static int __devinit -snd_azf3328_mixer_new(azf3328_t *chip) +snd_azf3328_mixer_new(struct snd_azf3328 *chip) { - snd_card_t *card; - const snd_kcontrol_new_t *sw; + struct snd_card *card; + const struct snd_kcontrol_new *sw; unsigned int idx; int err; @@ -702,8 +708,8 @@ snd_azf3328_mixer_new(azf3328_t *chip) } static int -snd_azf3328_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +snd_azf3328_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int res; snd_azf3328_dbgcallenter(); @@ -713,7 +719,7 @@ snd_azf3328_hw_params(snd_pcm_substream_t * substream, } static int -snd_azf3328_hw_free(snd_pcm_substream_t * substream) +snd_azf3328_hw_free(struct snd_pcm_substream *substream) { snd_azf3328_dbgcallenter(); snd_pcm_lib_free_pages(substream); @@ -722,7 +728,7 @@ snd_azf3328_hw_free(snd_pcm_substream_t * substream) } static void -snd_azf3328_setfmt(azf3328_t *chip, +snd_azf3328_setfmt(struct snd_azf3328 *chip, unsigned int reg, unsigned int bitrate, unsigned int format_width, @@ -796,7 +802,7 @@ snd_azf3328_setfmt(azf3328_t *chip, } static void -snd_azf3328_setdmaa(azf3328_t *chip, +snd_azf3328_setdmaa(struct snd_azf3328 *chip, long unsigned int addr, unsigned int count, unsigned int size, @@ -842,11 +848,11 @@ snd_azf3328_setdmaa(azf3328_t *chip, } static int -snd_azf3328_playback_prepare(snd_pcm_substream_t *substream) +snd_azf3328_playback_prepare(struct snd_pcm_substream *substream) { #if 0 - azf3328_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); #endif @@ -864,11 +870,11 @@ snd_azf3328_playback_prepare(snd_pcm_substream_t *substream) } static int -snd_azf3328_capture_prepare(snd_pcm_substream_t * substream) +snd_azf3328_capture_prepare(struct snd_pcm_substream *substream) { #if 0 - azf3328_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); #endif @@ -886,10 +892,10 @@ snd_azf3328_capture_prepare(snd_pcm_substream_t * substream) } static int -snd_azf3328_playback_trigger(snd_pcm_substream_t * substream, int cmd) +snd_azf3328_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - azf3328_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int result = 0; unsigned int status1; @@ -998,10 +1004,10 @@ snd_azf3328_playback_trigger(snd_pcm_substream_t * substream, int cmd) /* this is just analogous to playback; I'm not quite sure whether recording * should actually be triggered like that */ static int -snd_azf3328_capture_trigger(snd_pcm_substream_t * substream, int cmd) +snd_azf3328_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - azf3328_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int result = 0; unsigned int status1; @@ -1096,9 +1102,9 @@ snd_azf3328_capture_trigger(snd_pcm_substream_t * substream, int cmd) } static snd_pcm_uframes_t -snd_azf3328_playback_pointer(snd_pcm_substream_t * substream) +snd_azf3328_playback_pointer(struct snd_pcm_substream *substream) { - azf3328_t *chip = snd_pcm_substream_chip(substream); + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); unsigned long bufptr, result; snd_pcm_uframes_t frmres; @@ -1117,9 +1123,9 @@ snd_azf3328_playback_pointer(snd_pcm_substream_t * substream) } static snd_pcm_uframes_t -snd_azf3328_capture_pointer(snd_pcm_substream_t * substream) +snd_azf3328_capture_pointer(struct snd_pcm_substream *substream) { - azf3328_t *chip = snd_pcm_substream_chip(substream); + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); unsigned long bufptr, result; snd_pcm_uframes_t frmres; @@ -1140,7 +1146,7 @@ snd_azf3328_capture_pointer(snd_pcm_substream_t * substream) static irqreturn_t snd_azf3328_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - azf3328_t *chip = dev_id; + struct snd_azf3328 *chip = dev_id; u8 status, which; static unsigned long irq_count; @@ -1223,7 +1229,7 @@ snd_azf3328_interrupt(int irq, void *dev_id, struct pt_regs *regs) /*****************************************************************/ -static const snd_pcm_hardware_t snd_azf3328_playback = +static const struct snd_pcm_hardware snd_azf3328_playback = { /* FIXME!! Correct? */ .info = SNDRV_PCM_INFO_MMAP | @@ -1251,7 +1257,7 @@ static const snd_pcm_hardware_t snd_azf3328_playback = .fifo_size = 0, }; -static const snd_pcm_hardware_t snd_azf3328_capture = +static const struct snd_pcm_hardware snd_azf3328_capture = { /* FIXME */ .info = SNDRV_PCM_INFO_MMAP | @@ -1280,7 +1286,7 @@ static const snd_pcm_hardware_t snd_azf3328_capture = static unsigned int snd_azf3328_fixed_rates[] = { 4000, 4800, 5512, 6620, 8000, 9600, 11025, 13240, 16000, 22050, 32000, 44100, 48000, 66200 }; -static snd_pcm_hw_constraint_list_t snd_azf3328_hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list snd_azf3328_hw_constraints_rates = { .count = ARRAY_SIZE(snd_azf3328_fixed_rates), .list = snd_azf3328_fixed_rates, .mask = 0, @@ -1289,10 +1295,10 @@ static snd_pcm_hw_constraint_list_t snd_azf3328_hw_constraints_rates = { /*****************************************************************/ static int -snd_azf3328_playback_open(snd_pcm_substream_t * substream) +snd_azf3328_playback_open(struct snd_pcm_substream *substream) { - azf3328_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_azf3328_dbgcallenter(); chip->playback_substream = substream; @@ -1304,10 +1310,10 @@ snd_azf3328_playback_open(snd_pcm_substream_t * substream) } static int -snd_azf3328_capture_open(snd_pcm_substream_t * substream) +snd_azf3328_capture_open(struct snd_pcm_substream *substream) { - azf3328_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_azf3328_dbgcallenter(); chip->capture_substream = substream; @@ -1319,9 +1325,9 @@ snd_azf3328_capture_open(snd_pcm_substream_t * substream) } static int -snd_azf3328_playback_close(snd_pcm_substream_t * substream) +snd_azf3328_playback_close(struct snd_pcm_substream *substream) { - azf3328_t *chip = snd_pcm_substream_chip(substream); + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); snd_azf3328_dbgcallenter(); @@ -1331,9 +1337,9 @@ snd_azf3328_playback_close(snd_pcm_substream_t * substream) } static int -snd_azf3328_capture_close(snd_pcm_substream_t * substream) +snd_azf3328_capture_close(struct snd_pcm_substream *substream) { - azf3328_t *chip = snd_pcm_substream_chip(substream); + struct snd_azf3328 *chip = snd_pcm_substream_chip(substream); snd_azf3328_dbgcallenter(); chip->capture_substream = NULL; @@ -1343,7 +1349,7 @@ snd_azf3328_capture_close(snd_pcm_substream_t * substream) /******************************************************************/ -static snd_pcm_ops_t snd_azf3328_playback_ops = { +static struct snd_pcm_ops snd_azf3328_playback_ops = { .open = snd_azf3328_playback_open, .close = snd_azf3328_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1354,7 +1360,7 @@ static snd_pcm_ops_t snd_azf3328_playback_ops = { .pointer = snd_azf3328_playback_pointer }; -static snd_pcm_ops_t snd_azf3328_capture_ops = { +static struct snd_pcm_ops snd_azf3328_capture_ops = { .open = snd_azf3328_capture_open, .close = snd_azf3328_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1366,9 +1372,9 @@ static snd_pcm_ops_t snd_azf3328_capture_ops = { }; static int __devinit -snd_azf3328_pcm(azf3328_t *chip, int device) +snd_azf3328_pcm(struct snd_azf3328 *chip, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; snd_azf3328_dbgcallenter(); @@ -1393,7 +1399,7 @@ snd_azf3328_pcm(azf3328_t *chip, int device) #ifdef SUPPORT_JOYSTICK static int __devinit -snd_azf3328_config_joystick(azf3328_t *chip, int dev) +snd_azf3328_config_joystick(struct snd_azf3328 *chip, int dev) { struct gameport *gp; struct resource *r; @@ -1428,7 +1434,7 @@ snd_azf3328_config_joystick(azf3328_t *chip, int dev) } static void -snd_azf3328_free_joystick(azf3328_t *chip) +snd_azf3328_free_joystick(struct snd_azf3328 *chip) { if (chip->gameport) { struct resource *r = gameport_get_port_data(chip->gameport); @@ -1443,15 +1449,15 @@ snd_azf3328_free_joystick(azf3328_t *chip) } #else static inline int -snd_azf3328_config_joystick(azf3328_t *chip, int dev) { return -ENOSYS; } +snd_azf3328_config_joystick(struct snd_azf3328 *chip, int dev) { return -ENOSYS; } static inline void -snd_azf3328_free_joystick(azf3328_t *chip) { } +snd_azf3328_free_joystick(struct snd_azf3328 *chip) { } #endif /******************************************************************/ static int -snd_azf3328_free(azf3328_t *chip) +snd_azf3328_free(struct snd_azf3328 *chip) { if (chip->irq < 0) goto __end_hw; @@ -1477,9 +1483,9 @@ __end_hw: } static int -snd_azf3328_dev_free(snd_device_t *device) +snd_azf3328_dev_free(struct snd_device *device) { - azf3328_t *chip = device->device_data; + struct snd_azf3328 *chip = device->device_data; return snd_azf3328_free(chip); } @@ -1495,9 +1501,9 @@ snd_azf3328_dev_free(snd_device_t *device) ***/ static int -snd_azf3328_timer_start(snd_timer_t *timer) +snd_azf3328_timer_start(struct snd_timer *timer) { - azf3328_t *chip; + struct snd_azf3328 *chip; unsigned long flags; unsigned int delay; @@ -1523,9 +1529,9 @@ snd_azf3328_timer_start(snd_timer_t *timer) } static int -snd_azf3328_timer_stop(snd_timer_t *timer) +snd_azf3328_timer_stop(struct snd_timer *timer) { - azf3328_t *chip; + struct snd_azf3328 *chip; unsigned long flags; snd_azf3328_dbgcallenter(); @@ -1541,7 +1547,7 @@ snd_azf3328_timer_stop(snd_timer_t *timer) static int -snd_azf3328_timer_precise_resolution(snd_timer_t *timer, +snd_azf3328_timer_precise_resolution(struct snd_timer *timer, unsigned long *num, unsigned long *den) { snd_azf3328_dbgcallenter(); @@ -1551,7 +1557,7 @@ snd_azf3328_timer_precise_resolution(snd_timer_t *timer, return 0; } -static struct _snd_timer_hardware snd_azf3328_timer_hw = { +static struct snd_timer_hardware snd_azf3328_timer_hw = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 977, /* 1000000/1024000 = 0.9765625us */ .ticks = 1024000, /* max tick count, defined by the value register; actually it's not 1024000, but 1048576, but we don't care */ @@ -1561,10 +1567,10 @@ static struct _snd_timer_hardware snd_azf3328_timer_hw = { }; static int __devinit -snd_azf3328_timer(azf3328_t *chip, int device) +snd_azf3328_timer(struct snd_azf3328 *chip, int device) { - snd_timer_t *timer = NULL; - snd_timer_id_t tid; + struct snd_timer *timer = NULL; + struct snd_timer_id tid; int err; snd_azf3328_dbgcallenter(); @@ -1617,7 +1623,7 @@ snd_azf3328_test_bit(unsigned int reg, int bit) #endif static void -snd_azf3328_debug_show_ports(const azf3328_t *chip) +snd_azf3328_debug_show_ports(const struct snd_azf3328 *chip) { #if DEBUG_MISC u16 tmp; @@ -1635,14 +1641,14 @@ snd_azf3328_debug_show_ports(const azf3328_t *chip) } static int __devinit -snd_azf3328_create(snd_card_t * card, +snd_azf3328_create(struct snd_card *card, struct pci_dev *pci, unsigned long device_type, - azf3328_t ** rchip) + struct snd_azf3328 ** rchip) { - azf3328_t *chip; + struct snd_azf3328 *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_azf3328_dev_free, }; u16 tmp; @@ -1735,9 +1741,9 @@ static int __devinit snd_azf3328_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - azf3328_t *chip; - opl3_t *opl3; + struct snd_card *card; + struct snd_azf3328 *chip; + struct snd_opl3 *opl3; int err; snd_azf3328_dbgcallenter(); -- cgit v1.1 From 9f362dce9d6315fa24aab6290cb9628563160f75 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:02:58 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI BT87x Modules: BT87x driver Remove xxx_t typedefs from the PCI BT87x driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/bt87x.c | 138 +++++++++++++++++++++++++++++------------------------- 1 file changed, 73 insertions(+), 65 deletions(-) diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 8feca22..dc9cd30 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -147,9 +147,8 @@ MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards"); /* SYNC, one WRITE per line, one extra WRITE per page boundary, SYNC, JUMP */ #define MAX_RISC_SIZE ((1 + 255 + (PAGE_ALIGN(255 * 4092) / PAGE_SIZE - 1) + 1 + 1) * 8) -typedef struct snd_bt87x bt87x_t; struct snd_bt87x { - snd_card_t *card; + struct snd_card *card; struct pci_dev *pci; void __iomem *mmio; @@ -159,7 +158,7 @@ struct snd_bt87x { spinlock_t reg_lock; long opened; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; struct snd_dma_buffer dma_risc; unsigned int line_bytes; @@ -175,17 +174,17 @@ struct snd_bt87x { enum { DEVICE_DIGITAL, DEVICE_ANALOG }; -static inline u32 snd_bt87x_readl(bt87x_t *chip, u32 reg) +static inline u32 snd_bt87x_readl(struct snd_bt87x *chip, u32 reg) { return readl(chip->mmio + reg); } -static inline void snd_bt87x_writel(bt87x_t *chip, u32 reg, u32 value) +static inline void snd_bt87x_writel(struct snd_bt87x *chip, u32 reg, u32 value) { writel(value, chip->mmio + reg); } -static int snd_bt87x_create_risc(bt87x_t *chip, snd_pcm_substream_t *substream, +static int snd_bt87x_create_risc(struct snd_bt87x *chip, struct snd_pcm_substream *substream, unsigned int periods, unsigned int period_bytes) { struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); @@ -235,7 +234,7 @@ static int snd_bt87x_create_risc(bt87x_t *chip, snd_pcm_substream_t *substream, return 0; } -static void snd_bt87x_free_risc(bt87x_t *chip) +static void snd_bt87x_free_risc(struct snd_bt87x *chip) { if (chip->dma_risc.area) { snd_dma_free_pages(&chip->dma_risc); @@ -243,7 +242,7 @@ static void snd_bt87x_free_risc(bt87x_t *chip) } } -static void snd_bt87x_pci_error(bt87x_t *chip, unsigned int status) +static void snd_bt87x_pci_error(struct snd_bt87x *chip, unsigned int status) { u16 pci_status; @@ -272,7 +271,7 @@ static void snd_bt87x_pci_error(bt87x_t *chip, unsigned int status) static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - bt87x_t *chip = dev_id; + struct snd_bt87x *chip = dev_id; unsigned int status, irq_status; status = snd_bt87x_readl(chip, REG_INT_STAT); @@ -305,7 +304,7 @@ static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id, struct pt_regs *re return IRQ_HANDLED; } -static snd_pcm_hardware_t snd_bt87x_digital_hw = { +static struct snd_pcm_hardware snd_bt87x_digital_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -321,7 +320,7 @@ static snd_pcm_hardware_t snd_bt87x_digital_hw = { .periods_max = 255, }; -static snd_pcm_hardware_t snd_bt87x_analog_hw = { +static struct snd_pcm_hardware snd_bt87x_analog_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -339,7 +338,7 @@ static snd_pcm_hardware_t snd_bt87x_analog_hw = { .periods_max = 255, }; -static int snd_bt87x_set_digital_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime) +static int snd_bt87x_set_digital_hw(struct snd_bt87x *chip, struct snd_pcm_runtime *runtime) { static struct { int rate; @@ -368,15 +367,15 @@ static int snd_bt87x_set_digital_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime) return 0; } -static int snd_bt87x_set_analog_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime) +static int snd_bt87x_set_analog_hw(struct snd_bt87x *chip, struct snd_pcm_runtime *runtime) { - static ratnum_t analog_clock = { + static struct snd_ratnum analog_clock = { .num = ANALOG_CLOCK, .den_min = CLOCK_DIV_MIN, .den_max = CLOCK_DIV_MAX, .den_step = 1 }; - static snd_pcm_hw_constraint_ratnums_t constraint_rates = { + static struct snd_pcm_hw_constraint_ratnums constraint_rates = { .nrats = 1, .rats = &analog_clock }; @@ -387,10 +386,10 @@ static int snd_bt87x_set_analog_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime) &constraint_rates); } -static int snd_bt87x_pcm_open(snd_pcm_substream_t *substream) +static int snd_bt87x_pcm_open(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if (test_and_set_bit(0, &chip->opened)) @@ -416,9 +415,9 @@ _error: return err; } -static int snd_bt87x_close(snd_pcm_substream_t *substream) +static int snd_bt87x_close(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); chip->substream = NULL; clear_bit(0, &chip->opened); @@ -426,10 +425,10 @@ static int snd_bt87x_close(snd_pcm_substream_t *substream) return 0; } -static int snd_bt87x_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_bt87x_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - bt87x_t *chip = snd_pcm_substream_chip(substream); + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); int err; err = snd_pcm_lib_malloc_pages(substream, @@ -441,19 +440,19 @@ static int snd_bt87x_hw_params(snd_pcm_substream_t *substream, params_period_bytes(hw_params)); } -static int snd_bt87x_hw_free(snd_pcm_substream_t *substream) +static int snd_bt87x_hw_free(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); snd_bt87x_free_risc(chip); snd_pcm_lib_free_pages(substream); return 0; } -static int snd_bt87x_prepare(snd_pcm_substream_t *substream) +static int snd_bt87x_prepare(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int decimation; spin_lock_irq(&chip->reg_lock); @@ -467,7 +466,7 @@ static int snd_bt87x_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_bt87x_start(bt87x_t *chip) +static int snd_bt87x_start(struct snd_bt87x *chip) { spin_lock(&chip->reg_lock); chip->current_line = 0; @@ -481,7 +480,7 @@ static int snd_bt87x_start(bt87x_t *chip) return 0; } -static int snd_bt87x_stop(bt87x_t *chip) +static int snd_bt87x_stop(struct snd_bt87x *chip) { spin_lock(&chip->reg_lock); chip->reg_control &= ~(CTL_FIFO_ENABLE | CTL_RISC_ENABLE | CTL_ACAP_EN); @@ -492,9 +491,9 @@ static int snd_bt87x_stop(bt87x_t *chip) return 0; } -static int snd_bt87x_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_bt87x_trigger(struct snd_pcm_substream *substream, int cmd) { - bt87x_t *chip = snd_pcm_substream_chip(substream); + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -506,15 +505,15 @@ static int snd_bt87x_trigger(snd_pcm_substream_t *substream, int cmd) } } -static snd_pcm_uframes_t snd_bt87x_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_bt87x_pointer(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; return (snd_pcm_uframes_t)bytes_to_frames(runtime, chip->current_line * chip->line_bytes); } -static snd_pcm_ops_t snd_bt87x_pcm_ops = { +static struct snd_pcm_ops snd_bt87x_pcm_ops = { .open = snd_bt87x_pcm_open, .close = snd_bt87x_close, .ioctl = snd_pcm_lib_ioctl, @@ -526,7 +525,8 @@ static snd_pcm_ops_t snd_bt87x_pcm_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static int snd_bt87x_capture_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) +static int snd_bt87x_capture_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *info) { info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; info->count = 1; @@ -535,17 +535,19 @@ static int snd_bt87x_capture_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_bt87x_capture_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); value->value.integer.value[0] = (chip->reg_control & CTL_A_GAIN_MASK) >> CTL_A_GAIN_SHIFT; return 0; } -static int snd_bt87x_capture_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); u32 old_control; int changed; @@ -559,7 +561,7 @@ static int snd_bt87x_capture_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_v return changed; } -static snd_kcontrol_new_t snd_bt87x_capture_volume = { +static struct snd_kcontrol_new snd_bt87x_capture_volume = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Volume", .info = snd_bt87x_capture_volume_info, @@ -567,7 +569,8 @@ static snd_kcontrol_new_t snd_bt87x_capture_volume = { .put = snd_bt87x_capture_volume_put, }; -static int snd_bt87x_capture_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) +static int snd_bt87x_capture_boost_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *info) { info->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; info->count = 1; @@ -576,17 +579,19 @@ static int snd_bt87x_capture_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_bt87x_capture_boost_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_boost_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); value->value.integer.value[0] = !! (chip->reg_control & CTL_A_G2X); return 0; } -static int snd_bt87x_capture_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_boost_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); u32 old_control; int changed; @@ -600,7 +605,7 @@ static int snd_bt87x_capture_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return changed; } -static snd_kcontrol_new_t snd_bt87x_capture_boost = { +static struct snd_kcontrol_new snd_bt87x_capture_boost = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Boost", .info = snd_bt87x_capture_boost_info, @@ -608,7 +613,8 @@ static snd_kcontrol_new_t snd_bt87x_capture_boost = { .put = snd_bt87x_capture_boost_put, }; -static int snd_bt87x_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) +static int snd_bt87x_capture_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *info) { static char *texts[3] = {"TV Tuner", "FM", "Mic/Line"}; @@ -621,17 +627,19 @@ static int snd_bt87x_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_bt87x_capture_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); value->value.enumerated.item[0] = (chip->reg_control & CTL_A_SEL_MASK) >> CTL_A_SEL_SHIFT; return 0; } -static int snd_bt87x_capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); u32 old_control; int changed; @@ -645,7 +653,7 @@ static int snd_bt87x_capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_v return changed; } -static snd_kcontrol_new_t snd_bt87x_capture_source = { +static struct snd_kcontrol_new snd_bt87x_capture_source = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Source", .info = snd_bt87x_capture_source_info, @@ -653,7 +661,7 @@ static snd_kcontrol_new_t snd_bt87x_capture_source = { .put = snd_bt87x_capture_source_put, }; -static int snd_bt87x_free(bt87x_t *chip) +static int snd_bt87x_free(struct snd_bt87x *chip) { if (chip->mmio) { snd_bt87x_stop(chip); @@ -670,16 +678,16 @@ static int snd_bt87x_free(bt87x_t *chip) return 0; } -static int snd_bt87x_dev_free(snd_device_t *device) +static int snd_bt87x_dev_free(struct snd_device *device) { - bt87x_t *chip = device->device_data; + struct snd_bt87x *chip = device->device_data; return snd_bt87x_free(chip); } -static int __devinit snd_bt87x_pcm(bt87x_t *chip, int device, char *name) +static int __devinit snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name) { int err; - snd_pcm_t *pcm; + struct snd_pcm *pcm; err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm); if (err < 0) @@ -694,13 +702,13 @@ static int __devinit snd_bt87x_pcm(bt87x_t *chip, int device, char *name) (255 * 4092 + 1023) & ~1023); } -static int __devinit snd_bt87x_create(snd_card_t *card, +static int __devinit snd_bt87x_create(struct snd_card *card, struct pci_dev *pci, - bt87x_t **rchip) + struct snd_bt87x **rchip) { - bt87x_t *chip; + struct snd_bt87x *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_bt87x_dev_free }; @@ -823,8 +831,8 @@ static int __devinit snd_bt87x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - bt87x_t *chip; + struct snd_card *card; + struct snd_bt87x *chip; int err, rate; rate = pci_id->driver_data; -- cgit v1.1 From 2cbdb686dd8df8d80742738ab50acfcfe9a95939 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:03:13 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI CMIPCI Modules: CMIPCI driver Remove xxx_t typedefs from the PCI CMIPCI driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/cmipci.c | 506 ++++++++++++++++++++++++++++------------------------- 1 file changed, 264 insertions(+), 242 deletions(-) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 0309689..ce156ca 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -378,11 +378,8 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address."); * driver data */ -typedef struct snd_stru_cmipci cmipci_t; -typedef struct snd_stru_cmipci_pcm cmipci_pcm_t; - -struct snd_stru_cmipci_pcm { - snd_pcm_substream_t *substream; +struct cmipci_pcm { + struct snd_pcm_substream *substream; int running; /* dac/adc running? */ unsigned int dma_size; /* in frames */ unsigned int period_size; /* in frames */ @@ -408,8 +405,8 @@ static const struct cmipci_mixer_auto_switches cm_saved_mixer[] = { }; #define CM_SAVED_MIXERS ARRAY_SIZE(cm_saved_mixer) -struct snd_stru_cmipci { - snd_card_t *card; +struct cmipci { + struct snd_card *card; struct pci_dev *pci; unsigned int device; /* device ID */ @@ -418,9 +415,9 @@ struct snd_stru_cmipci { unsigned long iobase; unsigned int ctrl; /* FUNCTRL0 current value */ - snd_pcm_t *pcm; /* DAC/ADC PCM */ - snd_pcm_t *pcm2; /* 2nd DAC */ - snd_pcm_t *pcm_spdif; /* SPDIF */ + struct snd_pcm *pcm; /* DAC/ADC PCM */ + struct snd_pcm *pcm2; /* 2nd DAC */ + struct snd_pcm *pcm_spdif; /* SPDIF */ int chip_version; int max_channels; @@ -437,19 +434,19 @@ struct snd_stru_cmipci { unsigned int dig_status; unsigned int dig_pcm_status; - snd_pcm_hardware_t *hw_info[3]; /* for playbacks */ + struct snd_pcm_hardware *hw_info[3]; /* for playbacks */ int opened[2]; /* open mode */ struct semaphore open_mutex; unsigned int mixer_insensitive: 1; - snd_kcontrol_t *mixer_res_ctl[CM_SAVED_MIXERS]; + struct snd_kcontrol *mixer_res_ctl[CM_SAVED_MIXERS]; int mixer_res_status[CM_SAVED_MIXERS]; - cmipci_pcm_t channel[2]; /* ch0 - DAC, ch1 - ADC or 2nd DAC */ + struct cmipci_pcm channel[2]; /* ch0 - DAC, ch1 - ADC or 2nd DAC */ /* external MIDI */ - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; #ifdef SUPPORT_JOYSTICK struct gameport *gameport; @@ -460,40 +457,40 @@ struct snd_stru_cmipci { /* read/write operations for dword register */ -static inline void snd_cmipci_write(cmipci_t *cm, unsigned int cmd, unsigned int data) +static inline void snd_cmipci_write(struct cmipci *cm, unsigned int cmd, unsigned int data) { outl(data, cm->iobase + cmd); } -static inline unsigned int snd_cmipci_read(cmipci_t *cm, unsigned int cmd) +static inline unsigned int snd_cmipci_read(struct cmipci *cm, unsigned int cmd) { return inl(cm->iobase + cmd); } /* read/write operations for word register */ -static inline void snd_cmipci_write_w(cmipci_t *cm, unsigned int cmd, unsigned short data) +static inline void snd_cmipci_write_w(struct cmipci *cm, unsigned int cmd, unsigned short data) { outw(data, cm->iobase + cmd); } -static inline unsigned short snd_cmipci_read_w(cmipci_t *cm, unsigned int cmd) +static inline unsigned short snd_cmipci_read_w(struct cmipci *cm, unsigned int cmd) { return inw(cm->iobase + cmd); } /* read/write operations for byte register */ -static inline void snd_cmipci_write_b(cmipci_t *cm, unsigned int cmd, unsigned char data) +static inline void snd_cmipci_write_b(struct cmipci *cm, unsigned int cmd, unsigned char data) { outb(data, cm->iobase + cmd); } -static inline unsigned char snd_cmipci_read_b(cmipci_t *cm, unsigned int cmd) +static inline unsigned char snd_cmipci_read_b(struct cmipci *cm, unsigned int cmd) { return inb(cm->iobase + cmd); } /* bit operations for dword register */ -static int snd_cmipci_set_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) +static int snd_cmipci_set_bit(struct cmipci *cm, unsigned int cmd, unsigned int flag) { unsigned int val, oval; val = oval = inl(cm->iobase + cmd); @@ -504,7 +501,7 @@ static int snd_cmipci_set_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) return 1; } -static int snd_cmipci_clear_bit(cmipci_t *cm, unsigned int cmd, unsigned int flag) +static int snd_cmipci_clear_bit(struct cmipci *cm, unsigned int cmd, unsigned int flag) { unsigned int val, oval; val = oval = inl(cm->iobase + cmd); @@ -516,7 +513,7 @@ static int snd_cmipci_clear_bit(cmipci_t *cm, unsigned int cmd, unsigned int fla } /* bit operations for byte register */ -static int snd_cmipci_set_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag) +static int snd_cmipci_set_bit_b(struct cmipci *cm, unsigned int cmd, unsigned char flag) { unsigned char val, oval; val = oval = inb(cm->iobase + cmd); @@ -527,7 +524,7 @@ static int snd_cmipci_set_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char fl return 1; } -static int snd_cmipci_clear_bit_b(cmipci_t *cm, unsigned int cmd, unsigned char flag) +static int snd_cmipci_clear_bit_b(struct cmipci *cm, unsigned int cmd, unsigned char flag) { unsigned char val, oval; val = oval = inb(cm->iobase + cmd); @@ -608,7 +605,7 @@ out: * at the register CM_REG_FUNCTRL1 (0x04). * Problem: other ways are also possible (any information about that?) */ -static void snd_cmipci_set_pll(cmipci_t *cm, unsigned int rate, unsigned int slot) +static void snd_cmipci_set_pll(struct cmipci *cm, unsigned int rate, unsigned int slot) { unsigned int reg = CM_REG_PLL + slot; /* @@ -626,16 +623,16 @@ static void snd_cmipci_set_pll(cmipci_t *cm, unsigned int rate, unsigned int slo } #endif /* USE_VAR48KRATE */ -static int snd_cmipci_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cmipci_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_cmipci_playback2_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cmipci_playback2_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); if (params_channels(hw_params) > 2) { down(&cm->open_mutex); if (cm->opened[CM_CH_PLAY]) { @@ -649,7 +646,7 @@ static int snd_cmipci_playback2_hw_params(snd_pcm_substream_t * substream, return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static void snd_cmipci_ch_reset(cmipci_t *cm, int ch) +static void snd_cmipci_ch_reset(struct cmipci *cm, int ch) { int reset = CM_RST_CH0 << (cm->channel[ch].ch); snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl | reset); @@ -657,7 +654,7 @@ static void snd_cmipci_ch_reset(cmipci_t *cm, int ch) udelay(10); } -static int snd_cmipci_hw_free(snd_pcm_substream_t * substream) +static int snd_cmipci_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } @@ -667,23 +664,23 @@ static int snd_cmipci_hw_free(snd_pcm_substream_t * substream) */ static unsigned int hw_channels[] = {1, 2, 4, 5, 6, 8}; -static snd_pcm_hw_constraint_list_t hw_constraints_channels_4 = { +static struct snd_pcm_hw_constraint_list hw_constraints_channels_4 = { .count = 3, .list = hw_channels, .mask = 0, }; -static snd_pcm_hw_constraint_list_t hw_constraints_channels_6 = { +static struct snd_pcm_hw_constraint_list hw_constraints_channels_6 = { .count = 5, .list = hw_channels, .mask = 0, }; -static snd_pcm_hw_constraint_list_t hw_constraints_channels_8 = { +static struct snd_pcm_hw_constraint_list hw_constraints_channels_8 = { .count = 6, .list = hw_channels, .mask = 0, }; -static int set_dac_channels(cmipci_t *cm, cmipci_pcm_t *rec, int channels) +static int set_dac_channels(struct cmipci *cm, struct cmipci_pcm *rec, int channels) { if (channels > 2) { if (! cm->can_multi_ch) @@ -737,11 +734,11 @@ static int set_dac_channels(cmipci_t *cm, cmipci_pcm_t *rec, int channels) * prepare playback/capture channel * channel to be used must have been set in rec->ch. */ -static int snd_cmipci_pcm_prepare(cmipci_t *cm, cmipci_pcm_t *rec, - snd_pcm_substream_t *substream) +static int snd_cmipci_pcm_prepare(struct cmipci *cm, struct cmipci_pcm *rec, + struct snd_pcm_substream *substream) { unsigned int reg, freq, val; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; rec->fmt = 0; rec->shift = 0; @@ -820,8 +817,8 @@ static int snd_cmipci_pcm_prepare(cmipci_t *cm, cmipci_pcm_t *rec, /* * PCM trigger/stop */ -static int snd_cmipci_pcm_trigger(cmipci_t *cm, cmipci_pcm_t *rec, - snd_pcm_substream_t *substream, int cmd) +static int snd_cmipci_pcm_trigger(struct cmipci *cm, struct cmipci_pcm *rec, + struct snd_pcm_substream *substream, int cmd) { unsigned int inthld, chen, reset, pause; int result = 0; @@ -870,8 +867,8 @@ static int snd_cmipci_pcm_trigger(cmipci_t *cm, cmipci_pcm_t *rec, /* * return the current pointer */ -static snd_pcm_uframes_t snd_cmipci_pcm_pointer(cmipci_t *cm, cmipci_pcm_t *rec, - snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_cmipci_pcm_pointer(struct cmipci *cm, struct cmipci_pcm *rec, + struct snd_pcm_substream *substream) { size_t ptr; unsigned int reg; @@ -895,16 +892,16 @@ static snd_pcm_uframes_t snd_cmipci_pcm_pointer(cmipci_t *cm, cmipci_pcm_t *rec, * playback */ -static int snd_cmipci_playback_trigger(snd_pcm_substream_t *substream, +static int snd_cmipci_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); return snd_cmipci_pcm_trigger(cm, &cm->channel[CM_CH_PLAY], substream, cmd); } -static snd_pcm_uframes_t snd_cmipci_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_cmipci_playback_pointer(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); return snd_cmipci_pcm_pointer(cm, &cm->channel[CM_CH_PLAY], substream); } @@ -914,16 +911,16 @@ static snd_pcm_uframes_t snd_cmipci_playback_pointer(snd_pcm_substream_t *substr * capture */ -static int snd_cmipci_capture_trigger(snd_pcm_substream_t *substream, +static int snd_cmipci_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); return snd_cmipci_pcm_trigger(cm, &cm->channel[CM_CH_CAPT], substream, cmd); } -static snd_pcm_uframes_t snd_cmipci_capture_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_cmipci_capture_pointer(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); return snd_cmipci_pcm_pointer(cm, &cm->channel[CM_CH_CAPT], substream); } @@ -932,18 +929,18 @@ static snd_pcm_uframes_t snd_cmipci_capture_pointer(snd_pcm_substream_t *substre * hw preparation for spdif */ -static int snd_cmipci_spdif_default_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cmipci_spdif_default_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_cmipci_spdif_default_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *chip = snd_kcontrol_chip(kcontrol); + struct cmipci *chip = snd_kcontrol_chip(kcontrol); int i; spin_lock_irq(&chip->reg_lock); @@ -953,10 +950,10 @@ static int snd_cmipci_spdif_default_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cmipci_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cmipci_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *chip = snd_kcontrol_chip(kcontrol); + struct cmipci *chip = snd_kcontrol_chip(kcontrol); int i, change; unsigned int val; @@ -970,7 +967,7 @@ static int snd_cmipci_spdif_default_put(snd_kcontrol_t * kcontrol, return change; } -static snd_kcontrol_new_t snd_cmipci_spdif_default __devinitdata = +static struct snd_kcontrol_new snd_cmipci_spdif_default __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -979,16 +976,16 @@ static snd_kcontrol_new_t snd_cmipci_spdif_default __devinitdata = .put = snd_cmipci_spdif_default_put }; -static int snd_cmipci_spdif_mask_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cmipci_spdif_mask_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_cmipci_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -997,7 +994,7 @@ static int snd_cmipci_spdif_mask_get(snd_kcontrol_t * kcontrol, return 0; } -static snd_kcontrol_new_t snd_cmipci_spdif_mask __devinitdata = +static struct snd_kcontrol_new snd_cmipci_spdif_mask __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1006,18 +1003,18 @@ static snd_kcontrol_new_t snd_cmipci_spdif_mask __devinitdata = .get = snd_cmipci_spdif_mask_get, }; -static int snd_cmipci_spdif_stream_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cmipci_spdif_stream_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_cmipci_spdif_stream_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *chip = snd_kcontrol_chip(kcontrol); + struct cmipci *chip = snd_kcontrol_chip(kcontrol); int i; spin_lock_irq(&chip->reg_lock); @@ -1027,10 +1024,10 @@ static int snd_cmipci_spdif_stream_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cmipci_spdif_stream_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *chip = snd_kcontrol_chip(kcontrol); + struct cmipci *chip = snd_kcontrol_chip(kcontrol); int i, change; unsigned int val; @@ -1044,7 +1041,7 @@ static int snd_cmipci_spdif_stream_put(snd_kcontrol_t *kcontrol, return change; } -static snd_kcontrol_new_t snd_cmipci_spdif_stream __devinitdata = +static struct snd_kcontrol_new snd_cmipci_spdif_stream __devinitdata = { .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE, .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1058,17 +1055,17 @@ static snd_kcontrol_new_t snd_cmipci_spdif_stream __devinitdata = */ /* save mixer setting and mute for AC3 playback */ -static int save_mixer_state(cmipci_t *cm) +static int save_mixer_state(struct cmipci *cm) { if (! cm->mixer_insensitive) { - snd_ctl_elem_value_t *val; + struct snd_ctl_elem_value *val; unsigned int i; val = kmalloc(sizeof(*val), GFP_ATOMIC); if (!val) return -ENOMEM; for (i = 0; i < CM_SAVED_MIXERS; i++) { - snd_kcontrol_t *ctl = cm->mixer_res_ctl[i]; + struct snd_kcontrol *ctl = cm->mixer_res_ctl[i]; if (ctl) { int event; memset(val, 0, sizeof(*val)); @@ -1092,10 +1089,10 @@ static int save_mixer_state(cmipci_t *cm) /* restore the previously saved mixer status */ -static void restore_mixer_state(cmipci_t *cm) +static void restore_mixer_state(struct cmipci *cm) { if (cm->mixer_insensitive) { - snd_ctl_elem_value_t *val; + struct snd_ctl_elem_value *val; unsigned int i; val = kmalloc(sizeof(*val), GFP_KERNEL); @@ -1104,7 +1101,7 @@ static void restore_mixer_state(cmipci_t *cm) cm->mixer_insensitive = 0; /* at first clear this; otherwise the changes will be ignored */ for (i = 0; i < CM_SAVED_MIXERS; i++) { - snd_kcontrol_t *ctl = cm->mixer_res_ctl[i]; + struct snd_kcontrol *ctl = cm->mixer_res_ctl[i]; if (ctl) { int event; @@ -1125,7 +1122,7 @@ static void restore_mixer_state(cmipci_t *cm) } /* spinlock held! */ -static void setup_ac3(cmipci_t *cm, snd_pcm_substream_t *subs, int do_ac3, int rate) +static void setup_ac3(struct cmipci *cm, struct snd_pcm_substream *subs, int do_ac3, int rate) { if (do_ac3) { /* AC3EN for 037 */ @@ -1172,7 +1169,7 @@ static void setup_ac3(cmipci_t *cm, snd_pcm_substream_t *subs, int do_ac3, int r } } -static int setup_spdif_playback(cmipci_t *cm, snd_pcm_substream_t *subs, int up, int do_ac3) +static int setup_spdif_playback(struct cmipci *cm, struct snd_pcm_substream *subs, int up, int do_ac3) { int rate, err; @@ -1214,9 +1211,9 @@ static int setup_spdif_playback(cmipci_t *cm, snd_pcm_substream_t *subs, int up, */ /* playback - enable spdif only on the certain condition */ -static int snd_cmipci_playback_prepare(snd_pcm_substream_t *substream) +static int snd_cmipci_playback_prepare(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); int rate = substream->runtime->rate; int err, do_spdif, do_ac3 = 0; @@ -1231,9 +1228,9 @@ static int snd_cmipci_playback_prepare(snd_pcm_substream_t *substream) } /* playback (via device #2) - enable spdif always */ -static int snd_cmipci_playback_spdif_prepare(snd_pcm_substream_t *substream) +static int snd_cmipci_playback_spdif_prepare(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); int err, do_ac3; if (cm->can_ac3_hw) @@ -1245,25 +1242,25 @@ static int snd_cmipci_playback_spdif_prepare(snd_pcm_substream_t *substream) return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_PLAY], substream); } -static int snd_cmipci_playback_hw_free(snd_pcm_substream_t *substream) +static int snd_cmipci_playback_hw_free(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); setup_spdif_playback(cm, substream, 0, 0); restore_mixer_state(cm); return snd_cmipci_hw_free(substream); } /* capture */ -static int snd_cmipci_capture_prepare(snd_pcm_substream_t *substream) +static int snd_cmipci_capture_prepare(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_CAPT], substream); } /* capture with spdif (via device #2) */ -static int snd_cmipci_capture_spdif_prepare(snd_pcm_substream_t *substream) +static int snd_cmipci_capture_spdif_prepare(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); spin_lock_irq(&cm->reg_lock); snd_cmipci_set_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF); @@ -1272,9 +1269,9 @@ static int snd_cmipci_capture_spdif_prepare(snd_pcm_substream_t *substream) return snd_cmipci_pcm_prepare(cm, &cm->channel[CM_CH_CAPT], substream); } -static int snd_cmipci_capture_spdif_hw_free(snd_pcm_substream_t *subs) +static int snd_cmipci_capture_spdif_hw_free(struct snd_pcm_substream *subs) { - cmipci_t *cm = snd_pcm_substream_chip(subs); + struct cmipci *cm = snd_pcm_substream_chip(subs); spin_lock_irq(&cm->reg_lock); snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_CAPTURE_SPDF); @@ -1289,7 +1286,7 @@ static int snd_cmipci_capture_spdif_hw_free(snd_pcm_substream_t *subs) */ static irqreturn_t snd_cmipci_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - cmipci_t *cm = dev_id; + struct cmipci *cm = dev_id; unsigned int status, mask = 0; /* fastpath out, to ease interrupt sharing */ @@ -1324,7 +1321,7 @@ static irqreturn_t snd_cmipci_interrupt(int irq, void *dev_id, struct pt_regs *r */ /* playback on channel A */ -static snd_pcm_hardware_t snd_cmipci_playback = +static struct snd_pcm_hardware snd_cmipci_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1344,7 +1341,7 @@ static snd_pcm_hardware_t snd_cmipci_playback = }; /* capture on channel B */ -static snd_pcm_hardware_t snd_cmipci_capture = +static struct snd_pcm_hardware snd_cmipci_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1364,7 +1361,7 @@ static snd_pcm_hardware_t snd_cmipci_capture = }; /* playback on channel B - stereo 16bit only? */ -static snd_pcm_hardware_t snd_cmipci_playback2 = +static struct snd_pcm_hardware snd_cmipci_playback2 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1384,7 +1381,7 @@ static snd_pcm_hardware_t snd_cmipci_playback2 = }; /* spdif playback on channel A */ -static snd_pcm_hardware_t snd_cmipci_playback_spdif = +static struct snd_pcm_hardware snd_cmipci_playback_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1404,7 +1401,7 @@ static snd_pcm_hardware_t snd_cmipci_playback_spdif = }; /* spdif playback on channel A (32bit, IEC958 subframes) */ -static snd_pcm_hardware_t snd_cmipci_playback_iec958_subframe = +static struct snd_pcm_hardware snd_cmipci_playback_iec958_subframe = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1424,7 +1421,7 @@ static snd_pcm_hardware_t snd_cmipci_playback_iec958_subframe = }; /* spdif capture on channel B */ -static snd_pcm_hardware_t snd_cmipci_capture_spdif = +static struct snd_pcm_hardware snd_cmipci_capture_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | @@ -1446,7 +1443,7 @@ static snd_pcm_hardware_t snd_cmipci_capture_spdif = /* * check device open/close */ -static int open_device_check(cmipci_t *cm, int mode, snd_pcm_substream_t *subs) +static int open_device_check(struct cmipci *cm, int mode, struct snd_pcm_substream *subs) { int ch = mode & CM_OPEN_CH_MASK; @@ -1473,7 +1470,7 @@ static int open_device_check(cmipci_t *cm, int mode, snd_pcm_substream_t *subs) return 0; } -static void close_device_check(cmipci_t *cm, int mode) +static void close_device_check(struct cmipci *cm, int mode) { int ch = mode & CM_OPEN_CH_MASK; @@ -1499,10 +1496,10 @@ static void close_device_check(cmipci_t *cm, int mode) /* */ -static int snd_cmipci_playback_open(snd_pcm_substream_t *substream) +static int snd_cmipci_playback_open(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct cmipci *cm = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = open_device_check(cm, CM_OPEN_PLAYBACK, substream)) < 0) @@ -1514,10 +1511,10 @@ static int snd_cmipci_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_cmipci_capture_open(snd_pcm_substream_t *substream) +static int snd_cmipci_capture_open(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct cmipci *cm = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = open_device_check(cm, CM_OPEN_CAPTURE, substream)) < 0) @@ -1531,10 +1528,10 @@ static int snd_cmipci_capture_open(snd_pcm_substream_t *substream) return 0; } -static int snd_cmipci_playback2_open(snd_pcm_substream_t *substream) +static int snd_cmipci_playback2_open(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct cmipci *cm = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = open_device_check(cm, CM_OPEN_PLAYBACK2, substream)) < 0) /* use channel B */ @@ -1557,10 +1554,10 @@ static int snd_cmipci_playback2_open(snd_pcm_substream_t *substream) return 0; } -static int snd_cmipci_playback_spdif_open(snd_pcm_substream_t *substream) +static int snd_cmipci_playback_spdif_open(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct cmipci *cm = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = open_device_check(cm, CM_OPEN_SPDIF_PLAYBACK, substream)) < 0) /* use channel A */ @@ -1577,10 +1574,10 @@ static int snd_cmipci_playback_spdif_open(snd_pcm_substream_t *substream) return 0; } -static int snd_cmipci_capture_spdif_open(snd_pcm_substream_t * substream) +static int snd_cmipci_capture_spdif_open(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct cmipci *cm = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if ((err = open_device_check(cm, CM_OPEN_SPDIF_CAPTURE, substream)) < 0) /* use channel B */ @@ -1594,38 +1591,38 @@ static int snd_cmipci_capture_spdif_open(snd_pcm_substream_t * substream) /* */ -static int snd_cmipci_playback_close(snd_pcm_substream_t * substream) +static int snd_cmipci_playback_close(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); close_device_check(cm, CM_OPEN_PLAYBACK); return 0; } -static int snd_cmipci_capture_close(snd_pcm_substream_t * substream) +static int snd_cmipci_capture_close(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); close_device_check(cm, CM_OPEN_CAPTURE); return 0; } -static int snd_cmipci_playback2_close(snd_pcm_substream_t * substream) +static int snd_cmipci_playback2_close(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); close_device_check(cm, CM_OPEN_PLAYBACK2); close_device_check(cm, CM_OPEN_PLAYBACK_MULTI); return 0; } -static int snd_cmipci_playback_spdif_close(snd_pcm_substream_t * substream) +static int snd_cmipci_playback_spdif_close(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); close_device_check(cm, CM_OPEN_SPDIF_PLAYBACK); return 0; } -static int snd_cmipci_capture_spdif_close(snd_pcm_substream_t * substream) +static int snd_cmipci_capture_spdif_close(struct snd_pcm_substream *substream) { - cmipci_t *cm = snd_pcm_substream_chip(substream); + struct cmipci *cm = snd_pcm_substream_chip(substream); close_device_check(cm, CM_OPEN_SPDIF_CAPTURE); return 0; } @@ -1634,7 +1631,7 @@ static int snd_cmipci_capture_spdif_close(snd_pcm_substream_t * substream) /* */ -static snd_pcm_ops_t snd_cmipci_playback_ops = { +static struct snd_pcm_ops snd_cmipci_playback_ops = { .open = snd_cmipci_playback_open, .close = snd_cmipci_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1645,7 +1642,7 @@ static snd_pcm_ops_t snd_cmipci_playback_ops = { .pointer = snd_cmipci_playback_pointer, }; -static snd_pcm_ops_t snd_cmipci_capture_ops = { +static struct snd_pcm_ops snd_cmipci_capture_ops = { .open = snd_cmipci_capture_open, .close = snd_cmipci_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1656,7 +1653,7 @@ static snd_pcm_ops_t snd_cmipci_capture_ops = { .pointer = snd_cmipci_capture_pointer, }; -static snd_pcm_ops_t snd_cmipci_playback2_ops = { +static struct snd_pcm_ops snd_cmipci_playback2_ops = { .open = snd_cmipci_playback2_open, .close = snd_cmipci_playback2_close, .ioctl = snd_pcm_lib_ioctl, @@ -1667,7 +1664,7 @@ static snd_pcm_ops_t snd_cmipci_playback2_ops = { .pointer = snd_cmipci_capture_pointer, /* channel B */ }; -static snd_pcm_ops_t snd_cmipci_playback_spdif_ops = { +static struct snd_pcm_ops snd_cmipci_playback_spdif_ops = { .open = snd_cmipci_playback_spdif_open, .close = snd_cmipci_playback_spdif_close, .ioctl = snd_pcm_lib_ioctl, @@ -1678,7 +1675,7 @@ static snd_pcm_ops_t snd_cmipci_playback_spdif_ops = { .pointer = snd_cmipci_playback_pointer, }; -static snd_pcm_ops_t snd_cmipci_capture_spdif_ops = { +static struct snd_pcm_ops snd_cmipci_capture_spdif_ops = { .open = snd_cmipci_capture_spdif_open, .close = snd_cmipci_capture_spdif_close, .ioctl = snd_pcm_lib_ioctl, @@ -1693,9 +1690,9 @@ static snd_pcm_ops_t snd_cmipci_capture_spdif_ops = { /* */ -static int __devinit snd_cmipci_pcm_new(cmipci_t *cm, int device) +static int __devinit snd_cmipci_pcm_new(struct cmipci *cm, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 1, &pcm); @@ -1716,9 +1713,9 @@ static int __devinit snd_cmipci_pcm_new(cmipci_t *cm, int device) return 0; } -static int __devinit snd_cmipci_pcm2_new(cmipci_t *cm, int device) +static int __devinit snd_cmipci_pcm2_new(struct cmipci *cm, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 0, &pcm); @@ -1738,9 +1735,9 @@ static int __devinit snd_cmipci_pcm2_new(cmipci_t *cm, int device) return 0; } -static int __devinit snd_cmipci_pcm_spdif_new(cmipci_t *cm, int device) +static int __devinit snd_cmipci_pcm_spdif_new(struct cmipci *cm, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; err = snd_pcm_new(cm->card, cm->card->driver, device, 1, 1, &pcm); @@ -1770,13 +1767,13 @@ static int __devinit snd_cmipci_pcm_spdif_new(cmipci_t *cm, int device) * - Output mute switches */ -static void snd_cmipci_mixer_write(cmipci_t *s, unsigned char idx, unsigned char data) +static void snd_cmipci_mixer_write(struct cmipci *s, unsigned char idx, unsigned char data) { outb(idx, s->iobase + CM_REG_SB16_ADDR); outb(data, s->iobase + CM_REG_SB16_DATA); } -static unsigned char snd_cmipci_mixer_read(cmipci_t *s, unsigned char idx) +static unsigned char snd_cmipci_mixer_read(struct cmipci *s, unsigned char idx) { unsigned char v; @@ -1788,13 +1785,13 @@ static unsigned char snd_cmipci_mixer_read(cmipci_t *s, unsigned char idx) /* * general mixer element */ -typedef struct cmipci_sb_reg { +struct cmipci_sb_reg { unsigned int left_reg, right_reg; unsigned int left_shift, right_shift; unsigned int mask; unsigned int invert: 1; unsigned int stereo: 1; -} cmipci_sb_reg_t; +}; #define COMPOSE_SB_REG(lreg,rreg,lshift,rshift,mask,invert,stereo) \ ((lreg) | ((rreg) << 8) | (lshift << 16) | (rshift << 19) | (mask << 24) | (invert << 22) | (stereo << 23)) @@ -1811,7 +1808,7 @@ typedef struct cmipci_sb_reg { #define CMIPCI_SB_SW_STEREO(xname,lshift,rshift) CMIPCI_DOUBLE(xname, SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, lshift, rshift, 1, 0, 1) #define CMIPCI_SB_SW_MONO(xname,shift) CMIPCI_DOUBLE(xname, SB_DSP4_OUTPUT_SW, SB_DSP4_OUTPUT_SW, shift, shift, 1, 0, 0) -static void cmipci_sb_reg_decode(cmipci_sb_reg_t *r, unsigned long val) +static void cmipci_sb_reg_decode(struct cmipci_sb_reg *r, unsigned long val) { r->left_reg = val & 0xff; r->right_reg = (val >> 8) & 0xff; @@ -1822,9 +1819,10 @@ static void cmipci_sb_reg_decode(cmipci_sb_reg_t *r, unsigned long val) r->mask = (val >> 24) & 0xff; } -static int snd_cmipci_info_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cmipci_info_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - cmipci_sb_reg_t reg; + struct cmipci_sb_reg reg; cmipci_sb_reg_decode(®, kcontrol->private_value); uinfo->type = reg.mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -1834,10 +1832,11 @@ static int snd_cmipci_info_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_cmipci_get_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cmipci_get_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); - cmipci_sb_reg_t reg; + struct cmipci *cm = snd_kcontrol_chip(kcontrol); + struct cmipci_sb_reg reg; int val; cmipci_sb_reg_decode(®, kcontrol->private_value); @@ -1856,10 +1855,11 @@ static int snd_cmipci_get_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_cmipci_put_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cmipci_put_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); - cmipci_sb_reg_t reg; + struct cmipci *cm = snd_kcontrol_chip(kcontrol); + struct cmipci_sb_reg reg; int change; int left, right, oleft, oright; @@ -1904,7 +1904,8 @@ static int snd_cmipci_put_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .private_value = COMPOSE_SB_REG(SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, left_shift, right_shift, 1, 0, 1), \ } -static int snd_cmipci_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cmipci_info_input_sw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 4; @@ -1913,10 +1914,11 @@ static int snd_cmipci_info_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_info return 0; } -static int snd_cmipci_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cmipci_get_input_sw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); - cmipci_sb_reg_t reg; + struct cmipci *cm = snd_kcontrol_chip(kcontrol); + struct cmipci_sb_reg reg; int val1, val2; cmipci_sb_reg_decode(®, kcontrol->private_value); @@ -1931,10 +1933,11 @@ static int snd_cmipci_get_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_cmipci_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cmipci_put_input_sw(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); - cmipci_sb_reg_t reg; + struct cmipci *cm = snd_kcontrol_chip(kcontrol); + struct cmipci_sb_reg reg; int change; int val1, val2, oval1, oval2; @@ -1987,9 +1990,10 @@ static int snd_cmipci_put_input_sw(snd_kcontrol_t * kcontrol, snd_ctl_elem_value .private_value = COMPOSE_SB_REG(reg, reg, shift, shift, mask, 0, 0), \ } -static int snd_cmipci_info_native_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_cmipci_info_native_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - cmipci_sb_reg_t reg; + struct cmipci_sb_reg reg; cmipci_sb_reg_decode(®, kcontrol->private_value); uinfo->type = reg.mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -2000,10 +2004,11 @@ static int snd_cmipci_info_native_mixer(snd_kcontrol_t *kcontrol, snd_ctl_elem_i } -static int snd_cmipci_get_native_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cmipci_get_native_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); - cmipci_sb_reg_t reg; + struct cmipci *cm = snd_kcontrol_chip(kcontrol); + struct cmipci_sb_reg reg; unsigned char oreg, val; cmipci_sb_reg_decode(®, kcontrol->private_value); @@ -2023,10 +2028,11 @@ static int snd_cmipci_get_native_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_v return 0; } -static int snd_cmipci_put_native_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cmipci_put_native_mixer(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); - cmipci_sb_reg_t reg; + struct cmipci *cm = snd_kcontrol_chip(kcontrol); + struct cmipci_sb_reg reg; unsigned char oreg, nreg, val; cmipci_sb_reg_decode(®, kcontrol->private_value); @@ -2052,15 +2058,17 @@ static int snd_cmipci_put_native_mixer(snd_kcontrol_t * kcontrol, snd_ctl_elem_v /* * special case - check mixer sensitivity */ -static int snd_cmipci_get_native_mixer_sensitive(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_get_native_mixer_sensitive(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - //cmipci_t *cm = snd_kcontrol_chip(kcontrol); + //struct cmipci *cm = snd_kcontrol_chip(kcontrol); return snd_cmipci_get_native_mixer(kcontrol, ucontrol); } -static int snd_cmipci_put_native_mixer_sensitive(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_put_native_mixer_sensitive(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); + struct cmipci *cm = snd_kcontrol_chip(kcontrol); if (cm->mixer_insensitive) { /* ignored */ return 0; @@ -2069,7 +2077,7 @@ static int snd_cmipci_put_native_mixer_sensitive(snd_kcontrol_t *kcontrol, snd_c } -static snd_kcontrol_new_t snd_cmipci_mixers[] __devinitdata = { +static struct snd_kcontrol_new snd_cmipci_mixers[] __devinitdata = { CMIPCI_SB_VOL_STEREO("Master Playback Volume", SB_DSP4_MASTER_DEV, 3, 31), CMIPCI_MIXER_SW_MONO("3D Control - Switch", CM_REG_MIXER1, CM_X3DEN_SHIFT, 0), CMIPCI_SB_VOL_STEREO("PCM Playback Volume", SB_DSP4_PCM_DEV, 3, 31), @@ -2111,15 +2119,18 @@ static snd_kcontrol_new_t snd_cmipci_mixers[] __devinitdata = { * other switches */ -typedef struct snd_cmipci_switch_args { +struct cmipci_switch_args { int reg; /* register index */ unsigned int mask; /* mask bits */ unsigned int mask_on; /* mask bits to turn on */ unsigned int is_byte: 1; /* byte access? */ - unsigned int ac3_sensitive: 1; /* access forbidden during non-audio operation? */ -} snd_cmipci_switch_args_t; + unsigned int ac3_sensitive: 1; /* access forbidden during + * non-audio operation? + */ +}; -static int snd_cmipci_uswitch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_cmipci_uswitch_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -2128,10 +2139,12 @@ static int snd_cmipci_uswitch_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int _snd_cmipci_uswitch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol, snd_cmipci_switch_args_t *args) +static int _snd_cmipci_uswitch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol, + struct cmipci_switch_args *args) { unsigned int val; - cmipci_t *cm = snd_kcontrol_chip(kcontrol); + struct cmipci *cm = snd_kcontrol_chip(kcontrol); spin_lock_irq(&cm->reg_lock); if (args->ac3_sensitive && cm->mixer_insensitive) { @@ -2148,18 +2161,22 @@ static int _snd_cmipci_uswitch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_cmipci_uswitch_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_uswitch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_cmipci_switch_args_t *args = (snd_cmipci_switch_args_t*)kcontrol->private_value; + struct cmipci_switch_args *args; + args = (struct cmipci_switch_args *)kcontrol->private_value; snd_assert(args != NULL, return -EINVAL); return _snd_cmipci_uswitch_get(kcontrol, ucontrol, args); } -static int _snd_cmipci_uswitch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol, snd_cmipci_switch_args_t *args) +static int _snd_cmipci_uswitch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol, + struct cmipci_switch_args *args) { unsigned int val; int change; - cmipci_t *cm = snd_kcontrol_chip(kcontrol); + struct cmipci *cm = snd_kcontrol_chip(kcontrol); spin_lock_irq(&cm->reg_lock); if (args->ac3_sensitive && cm->mixer_insensitive) { @@ -2187,15 +2204,17 @@ static int _snd_cmipci_uswitch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return change; } -static int snd_cmipci_uswitch_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_uswitch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_cmipci_switch_args_t *args = (snd_cmipci_switch_args_t*)kcontrol->private_value; + struct cmipci_switch_args *args; + args = (struct cmipci_switch_args *)kcontrol->private_value; snd_assert(args != NULL, return -EINVAL); return _snd_cmipci_uswitch_put(kcontrol, ucontrol, args); } #define DEFINE_SWITCH_ARG(sname, xreg, xmask, xmask_on, xis_byte, xac3) \ -static snd_cmipci_switch_args_t cmipci_switch_arg_##sname = { \ +static struct cmipci_switch_args cmipci_switch_arg_##sname = { \ .reg = xreg, \ .mask = xmask, \ .mask_on = xmask_on, \ @@ -2252,7 +2271,8 @@ DEFINE_SWITCH_ARG(modem, CM_REG_MISC_CTRL, CM_FLINKON|CM_FLINKOFF, CM_FLINKON, 0 * callbacks for spdif output switch * needs toggle two registers.. */ -static int snd_cmipci_spdout_enable_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_spdout_enable_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int changed; changed = _snd_cmipci_uswitch_get(kcontrol, ucontrol, &cmipci_switch_arg_spdif_enable); @@ -2260,9 +2280,10 @@ static int snd_cmipci_spdout_enable_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_v return changed; } -static int snd_cmipci_spdout_enable_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_spdout_enable_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *chip = snd_kcontrol_chip(kcontrol); + struct cmipci *chip = snd_kcontrol_chip(kcontrol); int changed; changed = _snd_cmipci_uswitch_put(kcontrol, ucontrol, &cmipci_switch_arg_spdif_enable); changed |= _snd_cmipci_uswitch_put(kcontrol, ucontrol, &cmipci_switch_arg_spdo2dac); @@ -2280,10 +2301,10 @@ static int snd_cmipci_spdout_enable_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_v } -static int snd_cmipci_line_in_mode_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cmipci_line_in_mode_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); + struct cmipci *cm = snd_kcontrol_chip(kcontrol); static char *texts[3] = { "Line-In", "Rear Output", "Bass Output" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -2294,7 +2315,7 @@ static int snd_cmipci_line_in_mode_info(snd_kcontrol_t *kcontrol, return 0; } -static inline unsigned int get_line_in_mode(cmipci_t *cm) +static inline unsigned int get_line_in_mode(struct cmipci *cm) { unsigned int val; if (cm->chip_version >= 39) { @@ -2308,10 +2329,10 @@ static inline unsigned int get_line_in_mode(cmipci_t *cm) return 0; } -static int snd_cmipci_line_in_mode_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_line_in_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); + struct cmipci *cm = snd_kcontrol_chip(kcontrol); spin_lock_irq(&cm->reg_lock); ucontrol->value.enumerated.item[0] = get_line_in_mode(cm); @@ -2319,10 +2340,10 @@ static int snd_cmipci_line_in_mode_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cmipci_line_in_mode_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_line_in_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); + struct cmipci *cm = snd_kcontrol_chip(kcontrol); int change; spin_lock_irq(&cm->reg_lock); @@ -2338,8 +2359,8 @@ static int snd_cmipci_line_in_mode_put(snd_kcontrol_t *kcontrol, return change; } -static int snd_cmipci_mic_in_mode_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +static int snd_cmipci_mic_in_mode_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "Mic-In", "Center/LFE Output" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -2351,10 +2372,10 @@ static int snd_cmipci_mic_in_mode_info(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cmipci_mic_in_mode_get(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_mic_in_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); + struct cmipci *cm = snd_kcontrol_chip(kcontrol); /* same bit as spdi_phase */ spin_lock_irq(&cm->reg_lock); ucontrol->value.enumerated.item[0] = @@ -2363,10 +2384,10 @@ static int snd_cmipci_mic_in_mode_get(snd_kcontrol_t *kcontrol, return 0; } -static int snd_cmipci_mic_in_mode_put(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int snd_cmipci_mic_in_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cmipci_t *cm = snd_kcontrol_chip(kcontrol); + struct cmipci *cm = snd_kcontrol_chip(kcontrol); int change; spin_lock_irq(&cm->reg_lock); @@ -2379,7 +2400,7 @@ static int snd_cmipci_mic_in_mode_put(snd_kcontrol_t *kcontrol, } /* both for CM8338/8738 */ -static snd_kcontrol_new_t snd_cmipci_mixer_switches[] __devinitdata = { +static struct snd_kcontrol_new snd_cmipci_mixer_switches[] __devinitdata = { DEFINE_MIXER_SWITCH("Four Channel Mode", fourch), { .name = "Line-In Mode", @@ -2391,11 +2412,11 @@ static snd_kcontrol_new_t snd_cmipci_mixer_switches[] __devinitdata = { }; /* for non-multichannel chips */ -static snd_kcontrol_new_t snd_cmipci_nomulti_switch __devinitdata = +static struct snd_kcontrol_new snd_cmipci_nomulti_switch __devinitdata = DEFINE_MIXER_SWITCH("Exchange DAC", exchange_dac); /* only for CM8738 */ -static snd_kcontrol_new_t snd_cmipci_8738_mixer_switches[] __devinitdata = { +static struct snd_kcontrol_new snd_cmipci_8738_mixer_switches[] __devinitdata = { #if 0 /* controlled in pcm device */ DEFINE_MIXER_SWITCH("IEC958 In Record", spdif_in), DEFINE_MIXER_SWITCH("IEC958 Out", spdif_out), @@ -2417,14 +2438,14 @@ static snd_kcontrol_new_t snd_cmipci_8738_mixer_switches[] __devinitdata = { }; /* only for model 033/037 */ -static snd_kcontrol_new_t snd_cmipci_old_mixer_switches[] __devinitdata = { +static struct snd_kcontrol_new snd_cmipci_old_mixer_switches[] __devinitdata = { DEFINE_MIXER_SWITCH("IEC958 Mix Analog", spdif_dac_out), DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase), DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel1), }; /* only for model 039 or later */ -static snd_kcontrol_new_t snd_cmipci_extra_mixer_switches[] __devinitdata = { +static struct snd_kcontrol_new snd_cmipci_extra_mixer_switches[] __devinitdata = { DEFINE_MIXER_SWITCH("IEC958 In Select", spdif_in_sel2), DEFINE_MIXER_SWITCH("IEC958 In Phase Inverse", spdi_phase2), { @@ -2437,17 +2458,17 @@ static snd_kcontrol_new_t snd_cmipci_extra_mixer_switches[] __devinitdata = { }; /* card control switches */ -static snd_kcontrol_new_t snd_cmipci_control_switches[] __devinitdata = { +static struct snd_kcontrol_new snd_cmipci_control_switches[] __devinitdata = { // DEFINE_CARD_SWITCH("Joystick", joystick), /* now module option */ DEFINE_CARD_SWITCH("Modem", modem), }; -static int __devinit snd_cmipci_mixer_new(cmipci_t *cm, int pcm_spdif_device) +static int __devinit snd_cmipci_mixer_new(struct cmipci *cm, int pcm_spdif_device) { - snd_card_t *card; - snd_kcontrol_new_t *sw; - snd_kcontrol_t *kctl; + struct snd_card *card; + struct snd_kcontrol_new *sw; + struct snd_kcontrol *kctl; unsigned int idx; int err; @@ -2529,8 +2550,8 @@ static int __devinit snd_cmipci_mixer_new(cmipci_t *cm, int pcm_spdif_device) } for (idx = 0; idx < CM_SAVED_MIXERS; idx++) { - snd_ctl_elem_id_t id; - snd_kcontrol_t *ctl; + struct snd_ctl_elem_id id; + struct snd_kcontrol *ctl; memset(&id, 0, sizeof(id)); id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; strcpy(id.name, cm_saved_mixer[idx].name); @@ -2547,10 +2568,10 @@ static int __devinit snd_cmipci_mixer_new(cmipci_t *cm, int pcm_spdif_device) */ #ifdef CONFIG_PROC_FS -static void snd_cmipci_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t *buffer) +static void snd_cmipci_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - cmipci_t *cm = entry->private_data; + struct cmipci *cm = entry->private_data; int i; snd_iprintf(buffer, "%s\n\n", cm->card->longname); @@ -2566,15 +2587,15 @@ static void snd_cmipci_proc_read(snd_info_entry_t *entry, } } -static void __devinit snd_cmipci_proc_init(cmipci_t *cm) +static void __devinit snd_cmipci_proc_init(struct cmipci *cm) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(cm->card, "cmipci", &entry)) snd_info_set_text_ops(entry, cm, 1024, snd_cmipci_proc_read); } #else /* !CONFIG_PROC_FS */ -static inline void snd_cmipci_proc_init(cmipci_t *cm) {} +static inline void snd_cmipci_proc_init(struct cmipci *cm) {} #endif @@ -2592,7 +2613,7 @@ static struct pci_device_id snd_cmipci_ids[] = { * check chip version and capabilities * driver name is modified according to the chip model */ -static void __devinit query_chip(cmipci_t *cm) +static void __devinit query_chip(struct cmipci *cm) { unsigned int detect; @@ -2645,7 +2666,7 @@ static void __devinit query_chip(cmipci_t *cm) } #ifdef SUPPORT_JOYSTICK -static int __devinit snd_cmipci_create_gameport(cmipci_t *cm, int dev) +static int __devinit snd_cmipci_create_gameport(struct cmipci *cm, int dev) { static int ports[] = { 0x201, 0x200, 0 }; /* FIXME: majority is 0x201? */ struct gameport *gp; @@ -2691,7 +2712,7 @@ static int __devinit snd_cmipci_create_gameport(cmipci_t *cm, int dev) return 0; } -static void snd_cmipci_free_gameport(cmipci_t *cm) +static void snd_cmipci_free_gameport(struct cmipci *cm) { if (cm->gameport) { struct resource *r = gameport_get_port_data(cm->gameport); @@ -2704,11 +2725,11 @@ static void snd_cmipci_free_gameport(cmipci_t *cm) } } #else -static inline int snd_cmipci_create_gameport(cmipci_t *cm, int dev) { return -ENOSYS; } -static inline void snd_cmipci_free_gameport(cmipci_t *cm) { } +static inline int snd_cmipci_create_gameport(struct cmipci *cm, int dev) { return -ENOSYS; } +static inline void snd_cmipci_free_gameport(struct cmipci *cm) { } #endif -static int snd_cmipci_free(cmipci_t *cm) +static int snd_cmipci_free(struct cmipci *cm) { if (cm->irq >= 0) { snd_cmipci_clear_bit(cm, CM_REG_MISC_CTRL, CM_FM_EN); @@ -2724,7 +2745,7 @@ static int snd_cmipci_free(cmipci_t *cm) synchronize_irq(cm->irq); - free_irq(cm->irq, (void *)cm); + free_irq(cm->irq, cm); } snd_cmipci_free_gameport(cm); @@ -2734,17 +2755,17 @@ static int snd_cmipci_free(cmipci_t *cm) return 0; } -static int snd_cmipci_dev_free(snd_device_t *device) +static int snd_cmipci_dev_free(struct snd_device *device) { - cmipci_t *cm = device->device_data; + struct cmipci *cm = device->device_data; return snd_cmipci_free(cm); } -static int __devinit snd_cmipci_create_fm(cmipci_t *cm, long fm_port) +static int __devinit snd_cmipci_create_fm(struct cmipci *cm, long fm_port) { long iosynth; unsigned int val; - opl3_t *opl3; + struct snd_opl3 *opl3; int err; /* first try FM regs in PCI port range */ @@ -2785,12 +2806,12 @@ static int __devinit snd_cmipci_create_fm(cmipci_t *cm, long fm_port) return 0; } -static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, - int dev, cmipci_t **rcmipci) +static int __devinit snd_cmipci_create(struct snd_card *card, struct pci_dev *pci, + int dev, struct cmipci **rcmipci) { - cmipci_t *cm; + struct cmipci *cm; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_cmipci_dev_free, }; unsigned int val = 0; @@ -2830,7 +2851,8 @@ static int __devinit snd_cmipci_create(snd_card_t *card, struct pci_dev *pci, } cm->iobase = pci_resource_start(pci, 0); - if (request_irq(pci->irq, snd_cmipci_interrupt, SA_INTERRUPT|SA_SHIRQ, card->driver, (void *)cm)) { + if (request_irq(pci->irq, snd_cmipci_interrupt, + SA_INTERRUPT|SA_SHIRQ, card->driver, cm)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_cmipci_free(cm); return -EBUSY; @@ -2983,8 +3005,8 @@ static int __devinit snd_cmipci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - cmipci_t *cm; + struct snd_card *card; + struct cmipci *cm; int err; if (dev >= SNDRV_CARDS) -- cgit v1.1 From 93e35f956a1720eedcf95b8337dde25bde22d624 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:03:28 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI CS4281 Modules: CS4281 driver Remove xxx_t typedefs from the PCI CS4281 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/cs4281.c | 276 +++++++++++++++++++++++++++-------------------------- 1 file changed, 143 insertions(+), 133 deletions(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index c99bb1f..116cdc1 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -427,11 +427,8 @@ MODULE_PARM_DESC(dual_codec, "Secondary Codec ID (0 = disabled)."); * */ -typedef struct snd_cs4281 cs4281_t; -typedef struct snd_cs4281_dma cs4281_dma_t; - -struct snd_cs4281_dma { - snd_pcm_substream_t *substream; +struct cs4281_dma { + struct snd_pcm_substream *substream; unsigned int regDBA; /* offset to DBA register */ unsigned int regDCA; /* offset to DCA register */ unsigned int regDBC; /* offset to DBC register */ @@ -452,7 +449,7 @@ struct snd_cs4281_dma { #define SUSPEND_REGISTERS 20 -struct snd_cs4281 { +struct cs4281 { int irq; void __iomem *ba0; /* virtual (accessible) address */ @@ -462,18 +459,18 @@ struct snd_cs4281 { int dual_codec; - ac97_bus_t *ac97_bus; - ac97_t *ac97; - ac97_t *ac97_secondary; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97; + struct snd_ac97 *ac97_secondary; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *midi_input; - snd_rawmidi_substream_t *midi_output; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *midi_input; + struct snd_rawmidi_substream *midi_output; - cs4281_dma_t dma[4]; + struct cs4281_dma dma[4]; unsigned char src_left_play_slot; unsigned char src_right_play_slot; @@ -514,17 +511,18 @@ MODULE_DEVICE_TABLE(pci, snd_cs4281_ids); * common I/O routines */ -static inline void snd_cs4281_pokeBA0(cs4281_t *chip, unsigned long offset, unsigned int val) +static inline void snd_cs4281_pokeBA0(struct cs4281 *chip, unsigned long offset, + unsigned int val) { writel(val, chip->ba0 + offset); } -static inline unsigned int snd_cs4281_peekBA0(cs4281_t *chip, unsigned long offset) +static inline unsigned int snd_cs4281_peekBA0(struct cs4281 *chip, unsigned long offset) { return readl(chip->ba0 + offset); } -static void snd_cs4281_ac97_write(ac97_t *ac97, +static void snd_cs4281_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { /* @@ -534,7 +532,7 @@ static void snd_cs4281_ac97_write(ac97_t *ac97, * 4. Read ACCTL = 460h, DCV should be reset by now and 460h = 07h * 5. if DCV not cleared, break and return error */ - cs4281_t *chip = ac97->private_data; + struct cs4281 *chip = ac97->private_data; int count; /* @@ -569,15 +567,15 @@ static void snd_cs4281_ac97_write(ac97_t *ac97, snd_printk(KERN_ERR "AC'97 write problem, reg = 0x%x, val = 0x%x\n", reg, val); } -static unsigned short snd_cs4281_ac97_read(ac97_t *ac97, +static unsigned short snd_cs4281_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - cs4281_t *chip = ac97->private_data; + struct cs4281 *chip = ac97->private_data; int count; unsigned short result; // FIXME: volatile is necessary in the following due to a bug of // some gcc versions - volatile int ac97_num = ((volatile ac97_t *)ac97)->num; + volatile int ac97_num = ((volatile struct snd_ac97 *)ac97)->num; /* * 1. Write ACCAD = Command Address Register = 46Ch for AC97 register address @@ -664,10 +662,10 @@ static unsigned short snd_cs4281_ac97_read(ac97_t *ac97, * PCM part */ -static int snd_cs4281_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_cs4281_trigger(struct snd_pcm_substream *substream, int cmd) { - cs4281_dma_t *dma = (cs4281_dma_t *)substream->runtime->private_data; - cs4281_t *chip = snd_pcm_substream_chip(substream); + struct cs4281_dma *dma = substream->runtime->private_data; + struct cs4281 *chip = snd_pcm_substream_chip(substream); spin_lock(&chip->reg_lock); switch (cmd) { @@ -730,7 +728,9 @@ static unsigned int snd_cs4281_rate(unsigned int rate, unsigned int *real_rate) return val; } -static void snd_cs4281_mode(cs4281_t *chip, cs4281_dma_t *dma, snd_pcm_runtime_t *runtime, int capture, int src) +static void snd_cs4281_mode(struct cs4281 *chip, struct cs4281_dma *dma, + struct snd_pcm_runtime *runtime, + int capture, int src) { int rec_mono; @@ -793,22 +793,22 @@ static void snd_cs4281_mode(cs4281_t *chip, cs4281_dma_t *dma, snd_pcm_runtime_t snd_cs4281_pokeBA0(chip, dma->regFSIC, 0); } -static int snd_cs4281_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_cs4281_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_cs4281_hw_free(snd_pcm_substream_t * substream) +static int snd_cs4281_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_cs4281_playback_prepare(snd_pcm_substream_t * substream) +static int snd_cs4281_playback_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - cs4281_dma_t *dma = (cs4281_dma_t *)runtime->private_data; - cs4281_t *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct cs4281_dma *dma = runtime->private_data; + struct cs4281 *chip = snd_pcm_substream_chip(substream); spin_lock_irq(&chip->reg_lock); snd_cs4281_mode(chip, dma, runtime, 0, 1); @@ -816,11 +816,11 @@ static int snd_cs4281_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_cs4281_capture_prepare(snd_pcm_substream_t * substream) +static int snd_cs4281_capture_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - cs4281_dma_t *dma = (cs4281_dma_t *)runtime->private_data; - cs4281_t *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct cs4281_dma *dma = runtime->private_data; + struct cs4281 *chip = snd_pcm_substream_chip(substream); spin_lock_irq(&chip->reg_lock); snd_cs4281_mode(chip, dma, runtime, 1, 1); @@ -828,18 +828,18 @@ static int snd_cs4281_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_cs4281_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs4281_pointer(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - cs4281_dma_t *dma = (cs4281_dma_t *)runtime->private_data; - cs4281_t *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct cs4281_dma *dma = runtime->private_data; + struct cs4281 *chip = snd_pcm_substream_chip(substream); // printk("DCC = 0x%x, buffer_size = 0x%x, jiffies = %li\n", snd_cs4281_peekBA0(chip, dma->regDCC), runtime->buffer_size, jiffies); return runtime->buffer_size - snd_cs4281_peekBA0(chip, dma->regDCC) - 1; } -static snd_pcm_hardware_t snd_cs4281_playback = +static struct snd_pcm_hardware snd_cs4281_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -865,7 +865,7 @@ static snd_pcm_hardware_t snd_cs4281_playback = .fifo_size = CS4281_FIFO_SIZE, }; -static snd_pcm_hardware_t snd_cs4281_capture = +static struct snd_pcm_hardware snd_cs4281_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -891,11 +891,11 @@ static snd_pcm_hardware_t snd_cs4281_capture = .fifo_size = CS4281_FIFO_SIZE, }; -static int snd_cs4281_playback_open(snd_pcm_substream_t * substream) +static int snd_cs4281_playback_open(struct snd_pcm_substream *substream) { - cs4281_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - cs4281_dma_t *dma; + struct cs4281 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct cs4281_dma *dma; dma = &chip->dma[0]; dma->substream = substream; @@ -911,11 +911,11 @@ static int snd_cs4281_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_cs4281_capture_open(snd_pcm_substream_t * substream) +static int snd_cs4281_capture_open(struct snd_pcm_substream *substream) { - cs4281_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - cs4281_dma_t *dma; + struct cs4281 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct cs4281_dma *dma; dma = &chip->dma[1]; dma->substream = substream; @@ -931,23 +931,23 @@ static int snd_cs4281_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_cs4281_playback_close(snd_pcm_substream_t * substream) +static int snd_cs4281_playback_close(struct snd_pcm_substream *substream) { - cs4281_dma_t *dma = (cs4281_dma_t *)substream->runtime->private_data; + struct cs4281_dma *dma = substream->runtime->private_data; dma->substream = NULL; return 0; } -static int snd_cs4281_capture_close(snd_pcm_substream_t * substream) +static int snd_cs4281_capture_close(struct snd_pcm_substream *substream) { - cs4281_dma_t *dma = (cs4281_dma_t *)substream->runtime->private_data; + struct cs4281_dma *dma = substream->runtime->private_data; dma->substream = NULL; return 0; } -static snd_pcm_ops_t snd_cs4281_playback_ops = { +static struct snd_pcm_ops snd_cs4281_playback_ops = { .open = snd_cs4281_playback_open, .close = snd_cs4281_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -958,7 +958,7 @@ static snd_pcm_ops_t snd_cs4281_playback_ops = { .pointer = snd_cs4281_pointer, }; -static snd_pcm_ops_t snd_cs4281_capture_ops = { +static struct snd_pcm_ops snd_cs4281_capture_ops = { .open = snd_cs4281_capture_open, .close = snd_cs4281_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -969,9 +969,10 @@ static snd_pcm_ops_t snd_cs4281_capture_ops = { .pointer = snd_cs4281_pointer, }; -static int __devinit snd_cs4281_pcm(cs4281_t * chip, int device, snd_pcm_t ** rpcm) +static int __devinit snd_cs4281_pcm(struct cs4281 * chip, int device, + struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1002,7 +1003,8 @@ static int __devinit snd_cs4281_pcm(cs4281_t * chip, int device, snd_pcm_t ** rp #define CS_VOL_MASK 0x1f -static int snd_cs4281_info_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_cs4281_info_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1011,9 +1013,10 @@ static int snd_cs4281_info_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_cs4281_get_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4281_get_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs4281_t *chip = snd_kcontrol_chip(kcontrol); + struct cs4281 *chip = snd_kcontrol_chip(kcontrol); int regL = (kcontrol->private_value >> 16) & 0xffff; int regR = kcontrol->private_value & 0xffff; int volL, volR; @@ -1026,9 +1029,10 @@ static int snd_cs4281_get_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_cs4281_put_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_cs4281_put_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs4281_t *chip = snd_kcontrol_chip(kcontrol); + struct cs4281 *chip = snd_kcontrol_chip(kcontrol); int change = 0; int regL = (kcontrol->private_value >> 16) & 0xffff; int regR = kcontrol->private_value & 0xffff; @@ -1050,7 +1054,7 @@ static int snd_cs4281_put_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_cs4281_fm_vol = +static struct snd_kcontrol_new snd_cs4281_fm_vol = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Synth Playback Volume", @@ -1060,7 +1064,7 @@ static snd_kcontrol_new_t snd_cs4281_fm_vol = .private_value = ((BA0_FMLVC << 16) | BA0_FMRVC), }; -static snd_kcontrol_new_t snd_cs4281_pcm_vol = +static struct snd_kcontrol_new snd_cs4281_pcm_vol = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PCM Stream Playback Volume", @@ -1070,27 +1074,27 @@ static snd_kcontrol_new_t snd_cs4281_pcm_vol = .private_value = ((BA0_PPLVC << 16) | BA0_PPRVC), }; -static void snd_cs4281_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_cs4281_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - cs4281_t *chip = bus->private_data; + struct cs4281 *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_cs4281_mixer_free_ac97(ac97_t *ac97) +static void snd_cs4281_mixer_free_ac97(struct snd_ac97 *ac97) { - cs4281_t *chip = ac97->private_data; + struct cs4281 *chip = ac97->private_data; if (ac97->num) chip->ac97_secondary = NULL; else chip->ac97 = NULL; } -static int __devinit snd_cs4281_mixer(cs4281_t * chip) +static int __devinit snd_cs4281_mixer(struct cs4281 * chip) { - snd_card_t *card = chip->card; - ac97_template_t ac97; + struct snd_card *card = chip->card; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_cs4281_ac97_write, .read = snd_cs4281_ac97_read, }; @@ -1121,22 +1125,23 @@ static int __devinit snd_cs4281_mixer(cs4281_t * chip) * proc interface */ -static void snd_cs4281_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_cs4281_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - cs4281_t *chip = entry->private_data; + struct cs4281 *chip = entry->private_data; snd_iprintf(buffer, "Cirrus Logic CS4281\n\n"); snd_iprintf(buffer, "Spurious half IRQs : %u\n", chip->spurious_dhtc_irq); snd_iprintf(buffer, "Spurious end IRQs : %u\n", chip->spurious_dtc_irq); } -static long snd_cs4281_BA0_read(snd_info_entry_t *entry, void *file_private_data, +static long snd_cs4281_BA0_read(struct snd_info_entry *entry, + void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { long size; - cs4281_t *chip = entry->private_data; + struct cs4281 *chip = entry->private_data; size = count; if (pos + size > CS4281_BA0_SIZE) @@ -1148,12 +1153,13 @@ static long snd_cs4281_BA0_read(snd_info_entry_t *entry, void *file_private_data return size; } -static long snd_cs4281_BA1_read(snd_info_entry_t *entry, void *file_private_data, +static long snd_cs4281_BA1_read(struct snd_info_entry *entry, + void *file_private_data, struct file *file, char __user *buf, unsigned long count, unsigned long pos) { long size; - cs4281_t *chip = entry->private_data; + struct cs4281 *chip = entry->private_data; size = count; if (pos + size > CS4281_BA1_SIZE) @@ -1173,9 +1179,9 @@ static struct snd_info_entry_ops snd_cs4281_proc_ops_BA1 = { .read = snd_cs4281_BA1_read, }; -static void __devinit snd_cs4281_proc_init(cs4281_t * chip) +static void __devinit snd_cs4281_proc_init(struct cs4281 * chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "cs4281", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_cs4281_proc_read); @@ -1201,7 +1207,7 @@ static void __devinit snd_cs4281_proc_init(cs4281_t * chip) static void snd_cs4281_gameport_trigger(struct gameport *gameport) { - cs4281_t *chip = gameport_get_port_data(gameport); + struct cs4281 *chip = gameport_get_port_data(gameport); snd_assert(chip, return); snd_cs4281_pokeBA0(chip, BA0_JSPT, 0xff); @@ -1209,16 +1215,17 @@ static void snd_cs4281_gameport_trigger(struct gameport *gameport) static unsigned char snd_cs4281_gameport_read(struct gameport *gameport) { - cs4281_t *chip = gameport_get_port_data(gameport); + struct cs4281 *chip = gameport_get_port_data(gameport); snd_assert(chip, return 0); return snd_cs4281_peekBA0(chip, BA0_JSPT); } #ifdef COOKED_MODE -static int snd_cs4281_gameport_cooked_read(struct gameport *gameport, int *axes, int *buttons) +static int snd_cs4281_gameport_cooked_read(struct gameport *gameport, + int *axes, int *buttons) { - cs4281_t *chip = gameport_get_port_data(gameport); + struct cs4281 *chip = gameport_get_port_data(gameport); unsigned js1, js2, jst; snd_assert(chip, return 0); @@ -1257,7 +1264,7 @@ static int snd_cs4281_gameport_open(struct gameport *gameport, int mode) return 0; } -static int __devinit snd_cs4281_create_gameport(cs4281_t *chip) +static int __devinit snd_cs4281_create_gameport(struct cs4281 *chip) { struct gameport *gp; @@ -1284,7 +1291,7 @@ static int __devinit snd_cs4281_create_gameport(cs4281_t *chip) return 0; } -static void snd_cs4281_free_gameport(cs4281_t *chip) +static void snd_cs4281_free_gameport(struct cs4281 *chip) { if (chip->gameport) { gameport_unregister_port(chip->gameport); @@ -1292,11 +1299,11 @@ static void snd_cs4281_free_gameport(cs4281_t *chip) } } #else -static inline int snd_cs4281_create_gameport(cs4281_t *chip) { return -ENOSYS; } -static inline void snd_cs4281_free_gameport(cs4281_t *chip) { } +static inline int snd_cs4281_create_gameport(struct cs4281 *chip) { return -ENOSYS; } +static inline void snd_cs4281_free_gameport(struct cs4281 *chip) { } #endif /* CONFIG_GAMEPORT || (MODULE && CONFIG_GAMEPORT_MODULE) */ -static int snd_cs4281_free(cs4281_t *chip) +static int snd_cs4281_free(struct cs4281 *chip) { snd_cs4281_free_gameport(chip); @@ -1313,7 +1320,7 @@ static int snd_cs4281_free(cs4281_t *chip) pci_set_power_state(chip->pci, 3); if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); if (chip->ba0) iounmap(chip->ba0); if (chip->ba1) @@ -1325,27 +1332,27 @@ static int snd_cs4281_free(cs4281_t *chip) return 0; } -static int snd_cs4281_dev_free(snd_device_t *device) +static int snd_cs4281_dev_free(struct snd_device *device) { - cs4281_t *chip = device->device_data; + struct cs4281 *chip = device->device_data; return snd_cs4281_free(chip); } -static int snd_cs4281_chip_init(cs4281_t *chip); /* defined below */ +static int snd_cs4281_chip_init(struct cs4281 *chip); /* defined below */ #ifdef CONFIG_PM -static int cs4281_suspend(snd_card_t *card, pm_message_t state); -static int cs4281_resume(snd_card_t *card); +static int cs4281_suspend(struct snd_card *card, pm_message_t state); +static int cs4281_resume(struct snd_card *card); #endif -static int __devinit snd_cs4281_create(snd_card_t * card, +static int __devinit snd_cs4281_create(struct snd_card *card, struct pci_dev *pci, - cs4281_t ** rchip, + struct cs4281 ** rchip, int dual_codec) { - cs4281_t *chip; + struct cs4281 *chip; unsigned int tmp; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_cs4281_dev_free, }; @@ -1376,7 +1383,8 @@ static int __devinit snd_cs4281_create(snd_card_t * card, chip->ba0_addr = pci_resource_start(pci, 0); chip->ba1_addr = pci_resource_start(pci, 1); - if (request_irq(pci->irq, snd_cs4281_interrupt, SA_INTERRUPT|SA_SHIRQ, "CS4281", (void *)chip)) { + if (request_irq(pci->irq, snd_cs4281_interrupt, SA_INTERRUPT|SA_SHIRQ, + "CS4281", chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_cs4281_free(chip); return -ENOMEM; @@ -1411,7 +1419,7 @@ static int __devinit snd_cs4281_create(snd_card_t * card, return 0; } -static int snd_cs4281_chip_init(cs4281_t *chip) +static int snd_cs4281_chip_init(struct cs4281 *chip) { unsigned int tmp; int timeout; @@ -1587,7 +1595,7 @@ static int snd_cs4281_chip_init(cs4281_t *chip) * Initialize DMA structures */ for (tmp = 0; tmp < 4; tmp++) { - cs4281_dma_t *dma = &chip->dma[tmp]; + struct cs4281_dma *dma = &chip->dma[tmp]; dma->regDBA = BA0_DBA0 + (tmp * 0x10); dma->regDCA = BA0_DCA0 + (tmp * 0x10); dma->regDBC = BA0_DBC0 + (tmp * 0x10); @@ -1644,16 +1652,16 @@ static int snd_cs4281_chip_init(cs4281_t *chip) * MIDI section */ -static void snd_cs4281_midi_reset(cs4281_t *chip) +static void snd_cs4281_midi_reset(struct cs4281 *chip) { snd_cs4281_pokeBA0(chip, BA0_MIDCR, chip->midcr | BA0_MIDCR_MRST); udelay(100); snd_cs4281_pokeBA0(chip, BA0_MIDCR, chip->midcr); } -static int snd_cs4281_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_cs4281_midi_input_open(struct snd_rawmidi_substream *substream) { - cs4281_t *chip = substream->rmidi->private_data; + struct cs4281 *chip = substream->rmidi->private_data; spin_lock_irq(&chip->reg_lock); chip->midcr |= BA0_MIDCR_RXE; @@ -1667,9 +1675,9 @@ static int snd_cs4281_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_cs4281_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_cs4281_midi_input_close(struct snd_rawmidi_substream *substream) { - cs4281_t *chip = substream->rmidi->private_data; + struct cs4281 *chip = substream->rmidi->private_data; spin_lock_irq(&chip->reg_lock); chip->midcr &= ~(BA0_MIDCR_RXE | BA0_MIDCR_RIE); @@ -1684,9 +1692,9 @@ static int snd_cs4281_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_cs4281_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_cs4281_midi_output_open(struct snd_rawmidi_substream *substream) { - cs4281_t *chip = substream->rmidi->private_data; + struct cs4281 *chip = substream->rmidi->private_data; spin_lock_irq(&chip->reg_lock); chip->uartm |= CS4281_MODE_OUTPUT; @@ -1701,9 +1709,9 @@ static int snd_cs4281_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_cs4281_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_cs4281_midi_output_close(struct snd_rawmidi_substream *substream) { - cs4281_t *chip = substream->rmidi->private_data; + struct cs4281 *chip = substream->rmidi->private_data; spin_lock_irq(&chip->reg_lock); chip->midcr &= ~(BA0_MIDCR_TXE | BA0_MIDCR_TIE); @@ -1718,10 +1726,10 @@ static int snd_cs4281_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_cs4281_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_cs4281_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - cs4281_t *chip = substream->rmidi->private_data; + struct cs4281 *chip = substream->rmidi->private_data; spin_lock_irqsave(&chip->reg_lock, flags); if (up) { @@ -1738,10 +1746,10 @@ static void snd_cs4281_midi_input_trigger(snd_rawmidi_substream_t * substream, i spin_unlock_irqrestore(&chip->reg_lock, flags); } -static void snd_cs4281_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_cs4281_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - cs4281_t *chip = substream->rmidi->private_data; + struct cs4281 *chip = substream->rmidi->private_data; unsigned char byte; spin_lock_irqsave(&chip->reg_lock, flags); @@ -1768,23 +1776,24 @@ static void snd_cs4281_midi_output_trigger(snd_rawmidi_substream_t * substream, spin_unlock_irqrestore(&chip->reg_lock, flags); } -static snd_rawmidi_ops_t snd_cs4281_midi_output = +static struct snd_rawmidi_ops snd_cs4281_midi_output = { .open = snd_cs4281_midi_output_open, .close = snd_cs4281_midi_output_close, .trigger = snd_cs4281_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_cs4281_midi_input = +static struct snd_rawmidi_ops snd_cs4281_midi_input = { .open = snd_cs4281_midi_input_open, .close = snd_cs4281_midi_input_close, .trigger = snd_cs4281_midi_input_trigger, }; -static int __devinit snd_cs4281_midi(cs4281_t * chip, int device, snd_rawmidi_t **rrawmidi) +static int __devinit snd_cs4281_midi(struct cs4281 * chip, int device, + struct snd_rawmidi **rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) @@ -1808,9 +1817,9 @@ static int __devinit snd_cs4281_midi(cs4281_t * chip, int device, snd_rawmidi_t static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - cs4281_t *chip = dev_id; + struct cs4281 *chip = dev_id; unsigned int status, dma, val; - cs4281_dma_t *cdma; + struct cs4281_dma *cdma; if (chip == NULL) return IRQ_NONE; @@ -1880,10 +1889,11 @@ static irqreturn_t snd_cs4281_interrupt(int irq, void *dev_id, struct pt_regs *r /* * OPL3 command */ -static void snd_cs4281_opl3_command(opl3_t * opl3, unsigned short cmd, unsigned char val) +static void snd_cs4281_opl3_command(struct snd_opl3 *opl3, unsigned short cmd, + unsigned char val) { unsigned long flags; - cs4281_t *chip = opl3->private_data; + struct cs4281 *chip = opl3->private_data; void __iomem *port; if (cmd & OPL3_RIGHT) @@ -1906,9 +1916,9 @@ static int __devinit snd_cs4281_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - cs4281_t *chip; - opl3_t *opl3; + struct snd_card *card; + struct cs4281 *chip; + struct snd_opl3 *opl3; int err; if (dev >= SNDRV_CARDS) @@ -1997,9 +2007,9 @@ static int saved_regs[SUSPEND_REGISTERS] = { #define CLKCR1_CKRA 0x00010000L -static int cs4281_suspend(snd_card_t *card, pm_message_t state) +static int cs4281_suspend(struct snd_card *card, pm_message_t state) { - cs4281_t *chip = card->pm_private_data; + struct cs4281 *chip = card->pm_private_data; u32 ulCLK; unsigned int i; @@ -2042,9 +2052,9 @@ static int cs4281_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int cs4281_resume(snd_card_t *card) +static int cs4281_resume(struct snd_card *card) { - cs4281_t *chip = card->pm_private_data; + struct cs4281 *chip = card->pm_private_data; unsigned int i; u32 ulCLK; -- cgit v1.1 From eb3414b4652344972e86c85ce094cc4a780e1a55 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:03:46 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI ENS137x Modules: ENS1370/1+ driver Remove xxx_t typedefs from the PCI ENS137x drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/ens1370.c | 487 +++++++++++++++++++++++++++++----------------------- 1 file changed, 269 insertions(+), 218 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 180c49e..2cc0f83 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -367,9 +367,7 @@ MODULE_PARM_DESC(joystick, "Enable joystick."); */ -typedef struct _snd_ensoniq ensoniq_t; - -struct _snd_ensoniq { +struct ensoniq { spinlock_t reg_lock; struct semaphore src_mutex; @@ -392,12 +390,12 @@ struct _snd_ensoniq { union { #ifdef CHIP1371 struct { - ac97_t *ac97; + struct snd_ac97 *ac97; } es1371; #else struct { int pclkdiv_lock; - ak4531_t *ak4531; + struct snd_ak4531 *ak4531; } es1370; #endif } u; @@ -405,21 +403,21 @@ struct _snd_ensoniq { struct pci_dev *pci; unsigned short subsystem_vendor_id; unsigned short subsystem_device_id; - snd_card_t *card; - snd_pcm_t *pcm1; /* DAC1/ADC PCM */ - snd_pcm_t *pcm2; /* DAC2 PCM */ - snd_pcm_substream_t *playback1_substream; - snd_pcm_substream_t *playback2_substream; - snd_pcm_substream_t *capture_substream; + struct snd_card *card; + struct snd_pcm *pcm1; /* DAC1/ADC PCM */ + struct snd_pcm *pcm2; /* DAC2 PCM */ + struct snd_pcm_substream *playback1_substream; + struct snd_pcm_substream *playback2_substream; + struct snd_pcm_substream *capture_substream; unsigned int p1_dma_size; unsigned int p2_dma_size; unsigned int c_dma_size; unsigned int p1_period_size; unsigned int p2_period_size; unsigned int c_period_size; - snd_rawmidi_t *rmidi; - snd_rawmidi_substream_t *midi_input; - snd_rawmidi_substream_t *midi_output; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *midi_input; + struct snd_rawmidi_substream *midi_output; unsigned int spdif; unsigned int spdif_default; @@ -459,39 +457,39 @@ MODULE_DEVICE_TABLE(pci, snd_audiopci_ids); #ifdef CHIP1370 static unsigned int snd_es1370_fixed_rates[] = {5512, 11025, 22050, 44100}; -static snd_pcm_hw_constraint_list_t snd_es1370_hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list snd_es1370_hw_constraints_rates = { .count = 4, .list = snd_es1370_fixed_rates, .mask = 0, }; -static ratnum_t es1370_clock = { +static struct snd_ratnum es1370_clock = { .num = ES_1370_SRCLOCK, .den_min = 29, .den_max = 353, .den_step = 1, }; -static snd_pcm_hw_constraint_ratnums_t snd_es1370_hw_constraints_clock = { +static struct snd_pcm_hw_constraint_ratnums snd_es1370_hw_constraints_clock = { .nrats = 1, .rats = &es1370_clock, }; #else -static ratden_t es1371_dac_clock = { +static struct snd_ratden es1371_dac_clock = { .num_min = 3000 * (1 << 15), .num_max = 48000 * (1 << 15), .num_step = 3000, .den = 1 << 15, }; -static snd_pcm_hw_constraint_ratdens_t snd_es1371_hw_constraints_dac_clock = { +static struct snd_pcm_hw_constraint_ratdens snd_es1371_hw_constraints_dac_clock = { .nrats = 1, .rats = &es1371_dac_clock, }; -static ratnum_t es1371_adc_clock = { +static struct snd_ratnum es1371_adc_clock = { .num = 48000 << 15, .den_min = 32768, .den_max = 393216, .den_step = 1, }; -static snd_pcm_hw_constraint_ratnums_t snd_es1371_hw_constraints_adc_clock = { +static struct snd_pcm_hw_constraint_ratnums snd_es1371_hw_constraints_adc_clock = { .nrats = 1, .rats = &es1371_adc_clock, }; @@ -505,7 +503,7 @@ static const unsigned int snd_ensoniq_sample_shift[] = #ifdef CHIP1371 -static unsigned int snd_es1371_wait_src_ready(ensoniq_t * ensoniq) +static unsigned int snd_es1371_wait_src_ready(struct ensoniq * ensoniq) { unsigned int t, r = 0; @@ -515,11 +513,12 @@ static unsigned int snd_es1371_wait_src_ready(ensoniq_t * ensoniq) return r; cond_resched(); } - snd_printk(KERN_ERR "wait source ready timeout 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_SMPRATE), r); + snd_printk(KERN_ERR "wait source ready timeout 0x%lx [0x%x]\n", + ES_REG(ensoniq, 1371_SMPRATE), r); return 0; } -static unsigned int snd_es1371_src_read(ensoniq_t * ensoniq, unsigned short reg) +static unsigned int snd_es1371_src_read(struct ensoniq * ensoniq, unsigned short reg) { unsigned int temp, i, orig, r; @@ -553,7 +552,7 @@ static unsigned int snd_es1371_src_read(ensoniq_t * ensoniq, unsigned short reg) return temp; } -static void snd_es1371_src_write(ensoniq_t * ensoniq, +static void snd_es1371_src_write(struct ensoniq * ensoniq, unsigned short reg, unsigned short data) { unsigned int r; @@ -569,14 +568,15 @@ static void snd_es1371_src_write(ensoniq_t * ensoniq, #ifdef CHIP1370 -static void snd_es1370_codec_write(ak4531_t *ak4531, +static void snd_es1370_codec_write(struct snd_ak4531 *ak4531, unsigned short reg, unsigned short val) { - ensoniq_t *ensoniq = ak4531->private_data; + struct ensoniq *ensoniq = ak4531->private_data; unsigned long end_time = jiffies + HZ / 10; #if 0 - printk("CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); + printk("CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", + reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); #endif do { if (!(inl(ES_REG(ensoniq, STATUS)) & ES_1370_CSTAT)) { @@ -585,17 +585,18 @@ static void snd_es1370_codec_write(ak4531_t *ak4531, } schedule_timeout_uninterruptible(1); } while (time_after(end_time, jiffies)); - snd_printk(KERN_ERR "codec write timeout, status = 0x%x\n", inl(ES_REG(ensoniq, STATUS))); + snd_printk(KERN_ERR "codec write timeout, status = 0x%x\n", + inl(ES_REG(ensoniq, STATUS))); } #endif /* CHIP1370 */ #ifdef CHIP1371 -static void snd_es1371_codec_write(ac97_t *ac97, +static void snd_es1371_codec_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - ensoniq_t *ensoniq = ac97->private_data; + struct ensoniq *ensoniq = ac97->private_data; unsigned int t, x; down(&ensoniq->src_mutex); @@ -609,12 +610,14 @@ static void snd_es1371_codec_write(ac97_t *ac97, /* wait for not busy (state 0) first to avoid transition states */ for (t = 0; t < POLL_COUNT; t++) { - if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == 0x00000000) + if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == + 0x00000000) break; } /* wait for a SAFE time to write addr/data and then do it, dammit */ for (t = 0; t < POLL_COUNT; t++) { - if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == 0x00010000) + if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == + 0x00010000) break; } outl(ES_1371_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1371_CODEC)); @@ -626,13 +629,14 @@ static void snd_es1371_codec_write(ac97_t *ac97, } } up(&ensoniq->src_mutex); - snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); + snd_printk(KERN_ERR "codec write timeout at 0x%lx [0x%x]\n", + ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); } -static unsigned short snd_es1371_codec_read(ac97_t *ac97, +static unsigned short snd_es1371_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - ensoniq_t *ensoniq = ac97->private_data; + struct ensoniq *ensoniq = ac97->private_data; unsigned int t, x, fail = 0; __again: @@ -647,12 +651,14 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97, /* wait for not busy (state 0) first to avoid transition states */ for (t = 0; t < POLL_COUNT; t++) { - if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == 0x00000000) + if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == + 0x00000000) break; } /* wait for a SAFE time to write addr/data and then do it, dammit */ for (t = 0; t < POLL_COUNT; t++) { - if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == 0x00010000) + if ((inl(ES_REG(ensoniq, 1371_SMPRATE)) & 0x00870000) == + 0x00010000) break; } outl(ES_1371_CODEC_READS(reg), ES_REG(ensoniq, 1371_CODEC)); @@ -673,18 +679,22 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97, } up(&ensoniq->src_mutex); if (++fail > 10) { - snd_printk(KERN_ERR "codec read timeout (final) at 0x%lx, reg = 0x%x [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), reg, inl(ES_REG(ensoniq, 1371_CODEC))); + snd_printk(KERN_ERR "codec read timeout (final) " + "at 0x%lx, reg = 0x%x [0x%x]\n", + ES_REG(ensoniq, 1371_CODEC), reg, + inl(ES_REG(ensoniq, 1371_CODEC))); return 0; } goto __again; } } up(&ensoniq->src_mutex); - snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); + snd_printk(KERN_ERR "es1371: codec read timeout at 0x%lx [0x%x]\n", + ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); return 0; } -static void snd_es1371_codec_wait(ac97_t *ac97) +static void snd_es1371_codec_wait(struct snd_ac97 *ac97) { msleep(750); snd_es1371_codec_read(ac97, AC97_RESET); @@ -693,7 +703,7 @@ static void snd_es1371_codec_wait(ac97_t *ac97) msleep(50); } -static void snd_es1371_adc_rate(ensoniq_t * ensoniq, unsigned int rate) +static void snd_es1371_adc_rate(struct ensoniq * ensoniq, unsigned int rate) { unsigned int n, truncm, freq, result; @@ -716,60 +726,70 @@ static void snd_es1371_adc_rate(ensoniq_t * ensoniq, unsigned int rate) 0x8000 | (((119 - truncm) >> 1) << 9) | (n << 4)); } snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_INT_REGS, - (snd_es1371_src_read(ensoniq, ES_SMPREG_ADC + ES_SMPREG_INT_REGS) & 0x00ff) | - ((freq >> 5) & 0xfc00)); + (snd_es1371_src_read(ensoniq, ES_SMPREG_ADC + + ES_SMPREG_INT_REGS) & 0x00ff) | + ((freq >> 5) & 0xfc00)); snd_es1371_src_write(ensoniq, ES_SMPREG_ADC + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC, n << 8); snd_es1371_src_write(ensoniq, ES_SMPREG_VOL_ADC + 1, n << 8); up(&ensoniq->src_mutex); } -static void snd_es1371_dac1_rate(ensoniq_t * ensoniq, unsigned int rate) +static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate) { unsigned int freq, r; down(&ensoniq->src_mutex); freq = ((rate << 15) + 1500) / 3000; - r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1)) | ES_1371_DIS_P1; + r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | + ES_1371_DIS_P2 | ES_1371_DIS_R1)) | + ES_1371_DIS_P1; outl(r, ES_REG(ensoniq, 1371_SMPRATE)); snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_INT_REGS, - (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_INT_REGS) & 0x00ff) | + (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC1 + + ES_SMPREG_INT_REGS) & 0x00ff) | ((freq >> 5) & 0xfc00)); snd_es1371_src_write(ensoniq, ES_SMPREG_DAC1 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); - r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P2 | ES_1371_DIS_R1)); + r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | + ES_1371_DIS_P2 | ES_1371_DIS_R1)); outl(r, ES_REG(ensoniq, 1371_SMPRATE)); up(&ensoniq->src_mutex); } -static void snd_es1371_dac2_rate(ensoniq_t * ensoniq, unsigned int rate) +static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate) { unsigned int freq, r; down(&ensoniq->src_mutex); freq = ((rate << 15) + 1500) / 3000; - r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1)) | ES_1371_DIS_P2; + r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | + ES_1371_DIS_P1 | ES_1371_DIS_R1)) | + ES_1371_DIS_P2; outl(r, ES_REG(ensoniq, 1371_SMPRATE)); snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_INT_REGS, - (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_INT_REGS) & 0x00ff) | + (snd_es1371_src_read(ensoniq, ES_SMPREG_DAC2 + + ES_SMPREG_INT_REGS) & 0x00ff) | ((freq >> 5) & 0xfc00)); - snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_VFREQ_FRAC, freq & 0x7fff); - r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | ES_1371_DIS_P1 | ES_1371_DIS_R1)); + snd_es1371_src_write(ensoniq, ES_SMPREG_DAC2 + ES_SMPREG_VFREQ_FRAC, + freq & 0x7fff); + r = (snd_es1371_wait_src_ready(ensoniq) & (ES_1371_SRC_DISABLE | + ES_1371_DIS_P1 | ES_1371_DIS_R1)); outl(r, ES_REG(ensoniq, 1371_SMPRATE)); up(&ensoniq->src_mutex); } #endif /* CHIP1371 */ -static int snd_ensoniq_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_ensoniq_trigger(struct snd_pcm_substream *substream, int cmd) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: { unsigned int what = 0; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == ensoniq->playback1_substream) { @@ -795,7 +815,7 @@ static int snd_ensoniq_trigger(snd_pcm_substream_t *substream, int cmd) { unsigned int what = 0; struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; snd_pcm_group_for_each(pos, substream) { s = snd_pcm_group_substream_entry(pos); if (s == ensoniq->playback1_substream) { @@ -828,21 +848,21 @@ static int snd_ensoniq_trigger(snd_pcm_substream_t *substream, int cmd) * PCM part */ -static int snd_ensoniq_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_ensoniq_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_ensoniq_hw_free(snd_pcm_substream_t * substream) +static int snd_ensoniq_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_ensoniq_playback1_prepare(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback1_prepare(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mode = 0; ensoniq->p1_dma_size = snd_pcm_lib_buffer_bytes(substream); @@ -867,7 +887,8 @@ static int snd_ensoniq_playback1_prepare(snd_pcm_substream_t * substream) ensoniq->sctrl &= ~(ES_P1_LOOP_SEL | ES_P1_PAUSE | ES_P1_SCT_RLD | ES_P1_MODEM); ensoniq->sctrl |= ES_P1_INT_EN | ES_P1_MODEO(mode); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); - outl((ensoniq->p1_period_size >> snd_ensoniq_sample_shift[mode]) - 1, ES_REG(ensoniq, DAC1_COUNT)); + outl((ensoniq->p1_period_size >> snd_ensoniq_sample_shift[mode]) - 1, + ES_REG(ensoniq, DAC1_COUNT)); #ifdef CHIP1370 ensoniq->ctrl &= ~ES_1370_WTSRSELM; switch (runtime->rate) { @@ -886,10 +907,10 @@ static int snd_ensoniq_playback1_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_playback2_prepare(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback2_prepare(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mode = 0; ensoniq->p2_dma_size = snd_pcm_lib_buffer_bytes(substream); @@ -909,7 +930,8 @@ static int snd_ensoniq_playback2_prepare(snd_pcm_substream_t * substream) ensoniq->sctrl |= ES_P2_INT_EN | ES_P2_MODEO(mode) | ES_P2_END_INCO(mode & 2 ? 2 : 1) | ES_P2_ST_INCO(0); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); - outl((ensoniq->p2_period_size >> snd_ensoniq_sample_shift[mode]) - 1, ES_REG(ensoniq, DAC2_COUNT)); + outl((ensoniq->p2_period_size >> snd_ensoniq_sample_shift[mode]) - 1, + ES_REG(ensoniq, DAC2_COUNT)); #ifdef CHIP1370 if (!(ensoniq->u.es1370.pclkdiv_lock & ES_MODE_CAPTURE)) { ensoniq->ctrl &= ~ES_1370_PCLKDIVM; @@ -925,10 +947,10 @@ static int snd_ensoniq_playback2_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_capture_prepare(snd_pcm_substream_t * substream) +static int snd_ensoniq_capture_prepare(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int mode = 0; ensoniq->c_dma_size = snd_pcm_lib_buffer_bytes(substream); @@ -946,7 +968,8 @@ static int snd_ensoniq_capture_prepare(snd_pcm_substream_t * substream) ensoniq->sctrl &= ~(ES_R1_LOOP_SEL | ES_R1_MODEM); ensoniq->sctrl |= ES_R1_INT_EN | ES_R1_MODEO(mode); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); - outl((ensoniq->c_period_size >> snd_ensoniq_sample_shift[mode]) - 1, ES_REG(ensoniq, ADC_COUNT)); + outl((ensoniq->c_period_size >> snd_ensoniq_sample_shift[mode]) - 1, + ES_REG(ensoniq, ADC_COUNT)); #ifdef CHIP1370 if (!(ensoniq->u.es1370.pclkdiv_lock & ES_MODE_PLAY2)) { ensoniq->ctrl &= ~ES_1370_PCLKDIVM; @@ -962,9 +985,9 @@ static int snd_ensoniq_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_ensoniq_playback1_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ensoniq_playback1_pointer(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); size_t ptr; spin_lock(&ensoniq->reg_lock); @@ -979,9 +1002,9 @@ static snd_pcm_uframes_t snd_ensoniq_playback1_pointer(snd_pcm_substream_t * sub return ptr; } -static snd_pcm_uframes_t snd_ensoniq_playback2_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ensoniq_playback2_pointer(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); size_t ptr; spin_lock(&ensoniq->reg_lock); @@ -996,9 +1019,9 @@ static snd_pcm_uframes_t snd_ensoniq_playback2_pointer(snd_pcm_substream_t * sub return ptr; } -static snd_pcm_uframes_t snd_ensoniq_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_ensoniq_capture_pointer(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); size_t ptr; spin_lock(&ensoniq->reg_lock); @@ -1013,7 +1036,7 @@ static snd_pcm_uframes_t snd_ensoniq_capture_pointer(snd_pcm_substream_t * subst return ptr; } -static snd_pcm_hardware_t snd_ensoniq_playback1 = +static struct snd_pcm_hardware snd_ensoniq_playback1 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1040,7 +1063,7 @@ static snd_pcm_hardware_t snd_ensoniq_playback1 = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ensoniq_playback2 = +static struct snd_pcm_hardware snd_ensoniq_playback2 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1060,7 +1083,7 @@ static snd_pcm_hardware_t snd_ensoniq_playback2 = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_ensoniq_capture = +static struct snd_pcm_hardware snd_ensoniq_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1079,10 +1102,10 @@ static snd_pcm_hardware_t snd_ensoniq_capture = .fifo_size = 0, }; -static int snd_ensoniq_playback1_open(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback1_open(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; ensoniq->mode |= ES_MODE_PLAY1; ensoniq->playback1_substream = substream; @@ -1102,10 +1125,10 @@ static int snd_ensoniq_playback1_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_playback2_open(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback2_open(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; ensoniq->mode |= ES_MODE_PLAY2; ensoniq->playback2_substream = substream; @@ -1125,10 +1148,10 @@ static int snd_ensoniq_playback2_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_capture_open(snd_pcm_substream_t * substream) +static int snd_ensoniq_capture_open(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; ensoniq->mode |= ES_MODE_CAPTURE; ensoniq->capture_substream = substream; @@ -1144,18 +1167,18 @@ static int snd_ensoniq_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_playback1_close(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback1_close(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); ensoniq->playback1_substream = NULL; ensoniq->mode &= ~ES_MODE_PLAY1; return 0; } -static int snd_ensoniq_playback2_close(snd_pcm_substream_t * substream) +static int snd_ensoniq_playback2_close(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); ensoniq->playback2_substream = NULL; spin_lock_irq(&ensoniq->reg_lock); @@ -1167,9 +1190,9 @@ static int snd_ensoniq_playback2_close(snd_pcm_substream_t * substream) return 0; } -static int snd_ensoniq_capture_close(snd_pcm_substream_t * substream) +static int snd_ensoniq_capture_close(struct snd_pcm_substream *substream) { - ensoniq_t *ensoniq = snd_pcm_substream_chip(substream); + struct ensoniq *ensoniq = snd_pcm_substream_chip(substream); ensoniq->capture_substream = NULL; spin_lock_irq(&ensoniq->reg_lock); @@ -1181,7 +1204,7 @@ static int snd_ensoniq_capture_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_ensoniq_playback1_ops = { +static struct snd_pcm_ops snd_ensoniq_playback1_ops = { .open = snd_ensoniq_playback1_open, .close = snd_ensoniq_playback1_close, .ioctl = snd_pcm_lib_ioctl, @@ -1192,7 +1215,7 @@ static snd_pcm_ops_t snd_ensoniq_playback1_ops = { .pointer = snd_ensoniq_playback1_pointer, }; -static snd_pcm_ops_t snd_ensoniq_playback2_ops = { +static struct snd_pcm_ops snd_ensoniq_playback2_ops = { .open = snd_ensoniq_playback2_open, .close = snd_ensoniq_playback2_close, .ioctl = snd_pcm_lib_ioctl, @@ -1203,7 +1226,7 @@ static snd_pcm_ops_t snd_ensoniq_playback2_ops = { .pointer = snd_ensoniq_playback2_pointer, }; -static snd_pcm_ops_t snd_ensoniq_capture_ops = { +static struct snd_pcm_ops snd_ensoniq_capture_ops = { .open = snd_ensoniq_capture_open, .close = snd_ensoniq_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1214,9 +1237,10 @@ static snd_pcm_ops_t snd_ensoniq_capture_ops = { .pointer = snd_ensoniq_capture_pointer, }; -static int __devinit snd_ensoniq_pcm(ensoniq_t * ensoniq, int device, snd_pcm_t ** rpcm) +static int __devinit snd_ensoniq_pcm(struct ensoniq * ensoniq, int device, + struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1253,9 +1277,10 @@ static int __devinit snd_ensoniq_pcm(ensoniq_t * ensoniq, int device, snd_pcm_t return 0; } -static int __devinit snd_ensoniq_pcm2(ensoniq_t * ensoniq, int device, snd_pcm_t ** rpcm) +static int __devinit snd_ensoniq_pcm2(struct ensoniq * ensoniq, int device, + struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -1298,17 +1323,18 @@ static int __devinit snd_ensoniq_pcm2(ensoniq_t * ensoniq, int device, snd_pcm_t * ENS1371 mixer (including SPDIF interface) */ #ifdef CHIP1371 -static int snd_ens1373_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_ens1373_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_ens1373_spdif_default_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); spin_lock_irq(&ensoniq->reg_lock); ucontrol->value.iec958.status[0] = (ensoniq->spdif_default >> 0) & 0xff; ucontrol->value.iec958.status[1] = (ensoniq->spdif_default >> 8) & 0xff; @@ -1318,10 +1344,10 @@ static int snd_ens1373_spdif_default_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ens1373_spdif_default_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1332,14 +1358,15 @@ static int snd_ens1373_spdif_default_put(snd_kcontrol_t * kcontrol, spin_lock_irq(&ensoniq->reg_lock); change = ensoniq->spdif_default != val; ensoniq->spdif_default = val; - if (change && ensoniq->playback1_substream == NULL && ensoniq->playback2_substream == NULL) + if (change && ensoniq->playback1_substream == NULL && + ensoniq->playback2_substream == NULL) outl(val, ES_REG(ensoniq, CHANNEL_STATUS)); spin_unlock_irq(&ensoniq->reg_lock); return change; } -static int snd_ens1373_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = 0xff; ucontrol->value.iec958.status[1] = 0xff; @@ -1348,10 +1375,10 @@ static int snd_ens1373_spdif_mask_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ens1373_spdif_stream_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); spin_lock_irq(&ensoniq->reg_lock); ucontrol->value.iec958.status[0] = (ensoniq->spdif_stream >> 0) & 0xff; ucontrol->value.iec958.status[1] = (ensoniq->spdif_stream >> 8) & 0xff; @@ -1361,10 +1388,10 @@ static int snd_ens1373_spdif_stream_get(snd_kcontrol_t * kcontrol, return 0; } -static int snd_ens1373_spdif_stream_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_ens1373_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1375,7 +1402,8 @@ static int snd_ens1373_spdif_stream_put(snd_kcontrol_t * kcontrol, spin_lock_irq(&ensoniq->reg_lock); change = ensoniq->spdif_stream != val; ensoniq->spdif_stream = val; - if (change && (ensoniq->playback1_substream != NULL || ensoniq->playback2_substream != NULL)) + if (change && (ensoniq->playback1_substream != NULL || + ensoniq->playback2_substream != NULL)) outl(val, ES_REG(ensoniq, CHANNEL_STATUS)); spin_unlock_irq(&ensoniq->reg_lock); return change; @@ -1385,7 +1413,8 @@ static int snd_ens1373_spdif_stream_put(snd_kcontrol_t * kcontrol, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .info = snd_es1371_spdif_info, \ .get = snd_es1371_spdif_get, .put = snd_es1371_spdif_put } -static int snd_es1371_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_es1371_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1394,9 +1423,10 @@ static int snd_es1371_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_es1371_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1371_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); spin_lock_irq(&ensoniq->reg_lock); ucontrol->value.integer.value[0] = ensoniq->ctrl & ES_1373_SPDIF_THRU ? 1 : 0; @@ -1404,9 +1434,10 @@ static int snd_es1371_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es1371_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1371_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); unsigned int nval1, nval2; int change; @@ -1426,7 +1457,7 @@ static int snd_es1371_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t /* spdif controls */ -static snd_kcontrol_new_t snd_es1371_mixer_spdif[] __devinitdata = { +static struct snd_kcontrol_new snd_es1371_mixer_spdif[] __devinitdata = { ES1371_SPDIF(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH)), { .iface = SNDRV_CTL_ELEM_IFACE_PCM, @@ -1452,7 +1483,8 @@ static snd_kcontrol_new_t snd_es1371_mixer_spdif[] __devinitdata = { }; -static int snd_es1373_rear_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_es1373_rear_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1461,28 +1493,33 @@ static int snd_es1373_rear_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *u return 0; } -static int snd_es1373_rear_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1373_rear_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int val = 0; spin_lock_irq(&ensoniq->reg_lock); - if ((ensoniq->cssr & (ES_1373_REAR_BIT27|ES_1373_REAR_BIT26|ES_1373_REAR_BIT24)) == ES_1373_REAR_BIT26) + if ((ensoniq->cssr & (ES_1373_REAR_BIT27|ES_1373_REAR_BIT26| + ES_1373_REAR_BIT24)) == ES_1373_REAR_BIT26) val = 1; ucontrol->value.integer.value[0] = val; spin_unlock_irq(&ensoniq->reg_lock); return 0; } -static int snd_es1373_rear_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1373_rear_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); unsigned int nval1; int change; - nval1 = ucontrol->value.integer.value[0] ? ES_1373_REAR_BIT26 : (ES_1373_REAR_BIT27|ES_1373_REAR_BIT24); + nval1 = ucontrol->value.integer.value[0] ? + ES_1373_REAR_BIT26 : (ES_1373_REAR_BIT27|ES_1373_REAR_BIT24); spin_lock_irq(&ensoniq->reg_lock); - change = (ensoniq->cssr & (ES_1373_REAR_BIT27|ES_1373_REAR_BIT26|ES_1373_REAR_BIT24)) != nval1; + change = (ensoniq->cssr & (ES_1373_REAR_BIT27| + ES_1373_REAR_BIT26|ES_1373_REAR_BIT24)) != nval1; ensoniq->cssr &= ~(ES_1373_REAR_BIT27|ES_1373_REAR_BIT26|ES_1373_REAR_BIT24); ensoniq->cssr |= nval1; outl(ensoniq->cssr, ES_REG(ensoniq, STATUS)); @@ -1490,7 +1527,7 @@ static int snd_es1373_rear_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return change; } -static snd_kcontrol_new_t snd_ens1373_rear __devinitdata = +static struct snd_kcontrol_new snd_ens1373_rear __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "AC97 2ch->4ch Copy Switch", @@ -1499,7 +1536,8 @@ static snd_kcontrol_new_t snd_ens1373_rear __devinitdata = .put = snd_es1373_rear_put, }; -static int snd_es1373_line_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_es1373_line_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1508,9 +1546,10 @@ static int snd_es1373_line_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *u return 0; } -static int snd_es1373_line_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1373_line_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int val = 0; spin_lock_irq(&ensoniq->reg_lock); @@ -1521,9 +1560,10 @@ static int snd_es1373_line_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } -static int snd_es1373_line_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1373_line_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int changed; unsigned int ctrl; @@ -1540,7 +1580,7 @@ static int snd_es1373_line_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return changed; } -static snd_kcontrol_new_t snd_ens1373_line __devinitdata = +static struct snd_kcontrol_new snd_ens1373_line __devinitdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Line In->Rear Out Switch", @@ -1549,9 +1589,9 @@ static snd_kcontrol_new_t snd_ens1373_line __devinitdata = .put = snd_es1373_line_put, }; -static void snd_ensoniq_mixer_free_ac97(ac97_t *ac97) +static void snd_ensoniq_mixer_free_ac97(struct snd_ac97 *ac97) { - ensoniq_t *ensoniq = ac97->private_data; + struct ensoniq *ensoniq = ac97->private_data; ensoniq->u.es1371.ac97 = NULL; } @@ -1568,13 +1608,13 @@ static struct { { .vid = PCI_ANY_ID, .did = PCI_ANY_ID } }; -static int snd_ensoniq_1371_mixer(ensoniq_t * ensoniq) +static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq) { - snd_card_t *card = ensoniq->card; - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_card *card = ensoniq->card; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err, idx; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_es1371_codec_write, .read = snd_es1371_codec_read, .wait = snd_es1371_codec_wait, @@ -1593,10 +1633,11 @@ static int snd_ensoniq_1371_mixer(ensoniq_t * ensoniq) if (ensoniq->pci->vendor == es1371_spdif_present[idx].vid && ensoniq->pci->device == es1371_spdif_present[idx].did && ensoniq->rev == es1371_spdif_present[idx].rev) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; int i, index = 0; - ensoniq->spdif_default = ensoniq->spdif_stream = SNDRV_PCM_DEFAULT_CON_SPDIF; + ensoniq->spdif_default = ensoniq->spdif_stream = + SNDRV_PCM_DEFAULT_CON_SPDIF; outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS)); if (ensoniq->u.es1371.ac97->ext_id & AC97_EI_SPDIF) @@ -1641,7 +1682,8 @@ static int snd_ensoniq_1371_mixer(ensoniq_t * ensoniq) .get = snd_ensoniq_control_get, .put = snd_ensoniq_control_put, \ .private_value = mask } -static int snd_ensoniq_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_ensoniq_control_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1650,9 +1692,10 @@ static int snd_ensoniq_control_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_ return 0; } -static int snd_ensoniq_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ensoniq_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int mask = kcontrol->private_value; spin_lock_irq(&ensoniq->reg_lock); @@ -1661,9 +1704,10 @@ static int snd_ensoniq_control_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value return 0; } -static int snd_ensoniq_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_ensoniq_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - ensoniq_t *ensoniq = snd_kcontrol_chip(kcontrol); + struct ensoniq *ensoniq = snd_kcontrol_chip(kcontrol); int mask = kcontrol->private_value; unsigned int nval; int change; @@ -1682,23 +1726,23 @@ static int snd_ensoniq_control_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value * ENS1370 mixer */ -static snd_kcontrol_new_t snd_es1370_controls[2] __devinitdata = { +static struct snd_kcontrol_new snd_es1370_controls[2] __devinitdata = { ENSONIQ_CONTROL("PCM 0 Output also on Line-In Jack", ES_1370_XCTL0), ENSONIQ_CONTROL("Mic +5V bias", ES_1370_XCTL1) }; #define ES1370_CONTROLS ARRAY_SIZE(snd_es1370_controls) -static void snd_ensoniq_mixer_free_ak4531(ak4531_t *ak4531) +static void snd_ensoniq_mixer_free_ak4531(struct snd_ak4531 *ak4531) { - ensoniq_t *ensoniq = ak4531->private_data; + struct ensoniq *ensoniq = ak4531->private_data; ensoniq->u.es1370.ak4531 = NULL; } -static int __devinit snd_ensoniq_1370_mixer(ensoniq_t * ensoniq) +static int __devinit snd_ensoniq_1370_mixer(struct ensoniq * ensoniq) { - snd_card_t *card = ensoniq->card; - ak4531_t ak4531; + struct snd_card *card = ensoniq->card; + struct snd_ak4531 ak4531; unsigned int idx; int err; @@ -1752,7 +1796,7 @@ static inline int snd_ensoniq_get_joystick_port(int dev) } #endif -static int __devinit snd_ensoniq_create_gameport(ensoniq_t *ensoniq, int dev) +static int __devinit snd_ensoniq_create_gameport(struct ensoniq *ensoniq, int dev) { struct gameport *gp; int io_port; @@ -1775,7 +1819,8 @@ static int __devinit snd_ensoniq_create_gameport(ensoniq_t *ensoniq, int dev) default: if (!request_region(io_port, 8, "ens137x: gameport")) { - printk(KERN_WARNING "ens137x: gameport io port 0x%#x in use\n", io_port); + printk(KERN_WARNING "ens137x: gameport io port 0x%#x in use\n", + io_port); return -EBUSY; } break; @@ -1805,7 +1850,7 @@ static int __devinit snd_ensoniq_create_gameport(ensoniq_t *ensoniq, int dev) return 0; } -static void snd_ensoniq_free_gameport(ensoniq_t *ensoniq) +static void snd_ensoniq_free_gameport(struct ensoniq *ensoniq) { if (ensoniq->gameport) { int port = ensoniq->gameport->io; @@ -1818,36 +1863,40 @@ static void snd_ensoniq_free_gameport(ensoniq_t *ensoniq) } } #else -static inline int snd_ensoniq_create_gameport(ensoniq_t *ensoniq, long port) { return -ENOSYS; } -static inline void snd_ensoniq_free_gameport(ensoniq_t *ensoniq) { } +static inline int snd_ensoniq_create_gameport(struct ensoniq *ensoniq, long port) { return -ENOSYS; } +static inline void snd_ensoniq_free_gameport(struct ensoniq *ensoniq) { } #endif /* SUPPORT_JOYSTICK */ /* */ -static void snd_ensoniq_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_ensoniq_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - ensoniq_t *ensoniq = entry->private_data; + struct ensoniq *ensoniq = entry->private_data; #ifdef CHIP1370 snd_iprintf(buffer, "Ensoniq AudioPCI ES1370\n\n"); #else snd_iprintf(buffer, "Ensoniq AudioPCI ES1371\n\n"); #endif - snd_iprintf(buffer, "Joystick enable : %s\n", ensoniq->ctrl & ES_JYSTK_EN ? "on" : "off"); + snd_iprintf(buffer, "Joystick enable : %s\n", + ensoniq->ctrl & ES_JYSTK_EN ? "on" : "off"); #ifdef CHIP1370 - snd_iprintf(buffer, "MIC +5V bias : %s\n", ensoniq->ctrl & ES_1370_XCTL1 ? "on" : "off"); - snd_iprintf(buffer, "Line In to AOUT : %s\n", ensoniq->ctrl & ES_1370_XCTL0 ? "on" : "off"); + snd_iprintf(buffer, "MIC +5V bias : %s\n", + ensoniq->ctrl & ES_1370_XCTL1 ? "on" : "off"); + snd_iprintf(buffer, "Line In to AOUT : %s\n", + ensoniq->ctrl & ES_1370_XCTL0 ? "on" : "off"); #else - snd_iprintf(buffer, "Joystick port : 0x%x\n", (ES_1371_JOY_ASELI(ensoniq->ctrl) * 8) + 0x200); + snd_iprintf(buffer, "Joystick port : 0x%x\n", + (ES_1371_JOY_ASELI(ensoniq->ctrl) * 8) + 0x200); #endif } -static void __devinit snd_ensoniq_proc_init(ensoniq_t * ensoniq) +static void __devinit snd_ensoniq_proc_init(struct ensoniq * ensoniq) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(ensoniq->card, "audiopci", &entry)) snd_info_set_text_ops(entry, ensoniq, 1024, snd_ensoniq_proc_read); @@ -1857,7 +1906,7 @@ static void __devinit snd_ensoniq_proc_init(ensoniq_t * ensoniq) */ -static int snd_ensoniq_free(ensoniq_t *ensoniq) +static int snd_ensoniq_free(struct ensoniq *ensoniq) { snd_ensoniq_free_gameport(ensoniq); if (ensoniq->irq < 0) @@ -1877,16 +1926,16 @@ static int snd_ensoniq_free(ensoniq_t *ensoniq) snd_dma_free_pages(&ensoniq->dma_bug); #endif if (ensoniq->irq >= 0) - free_irq(ensoniq->irq, (void *)ensoniq); + free_irq(ensoniq->irq, ensoniq); pci_release_regions(ensoniq->pci); pci_disable_device(ensoniq->pci); kfree(ensoniq); return 0; } -static int snd_ensoniq_dev_free(snd_device_t *device) +static int snd_ensoniq_dev_free(struct snd_device *device) { - ensoniq_t *ensoniq = device->device_data; + struct ensoniq *ensoniq = device->device_data; return snd_ensoniq_free(ensoniq); } @@ -1915,13 +1964,15 @@ static struct { }; #endif -static void snd_ensoniq_chip_init(ensoniq_t * ensoniq) +static void snd_ensoniq_chip_init(struct ensoniq *ensoniq) { #ifdef CHIP1371 int idx; struct pci_dev *pci = ensoniq->pci; #endif -// this code was part of snd_ensoniq_create before intruduction of suspend/resume + /* this code was part of snd_ensoniq_create before intruduction + * of suspend/resume + */ #ifdef CHIP1370 outl(ensoniq->ctrl, ES_REG(ensoniq, CONTROL)); outl(ensoniq->sctrl, ES_REG(ensoniq, SERIAL)); @@ -1983,10 +2034,9 @@ static void snd_ensoniq_chip_init(ensoniq_t * ensoniq) } #ifdef CONFIG_PM -static int snd_ensoniq_suspend (snd_card_t * card, - pm_message_t state) +static int snd_ensoniq_suspend(struct snd_card *card, pm_message_t state) { - ensoniq_t *ensoniq = card->pm_private_data; + struct ensoniq *ensoniq = card->pm_private_data; snd_pcm_suspend_all(ensoniq->pcm1); snd_pcm_suspend_all(ensoniq->pcm2); @@ -1997,16 +2047,14 @@ static int snd_ensoniq_suspend (snd_card_t * card, #else /* FIXME */ #endif - pci_set_power_state(ensoniq->pci, 3); + pci_set_power_state(ensoniq->pci, 3); pci_disable_device(ensoniq->pci); - // snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); // only 2.6.10 return 0; } -static int snd_ensoniq_resume (snd_card_t * card - ) +static int snd_ensoniq_resume(struct snd_card *card) { - ensoniq_t *ensoniq = card->pm_private_data; + struct ensoniq *ensoniq = card->pm_private_data; pci_enable_device(ensoniq->pci); pci_set_power_state(ensoniq->pci, 0); @@ -2020,24 +2068,23 @@ static int snd_ensoniq_resume (snd_card_t * card #else /* FIXME */ #endif - // snd_power_change_state(card, SNDRV_CTL_POWER_D0); // only 2.6.10 return 0; } #endif /* CONFIG_PM */ -static int __devinit snd_ensoniq_create(snd_card_t * card, +static int __devinit snd_ensoniq_create(struct snd_card *card, struct pci_dev *pci, - ensoniq_t ** rensoniq) + struct ensoniq ** rensoniq) { - ensoniq_t *ensoniq; + struct ensoniq *ensoniq; unsigned short cmdw; unsigned char cmdb; #ifdef CHIP1371 int idx; #endif int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_ensoniq_dev_free, }; @@ -2060,7 +2107,8 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, return err; } ensoniq->port = pci_resource_start(pci, 0); - if (request_irq(pci->irq, snd_audiopci_interrupt, SA_INTERRUPT|SA_SHIRQ, "Ensoniq AudioPCI", (void *)ensoniq)) { + if (request_irq(pci->irq, snd_audiopci_interrupt, SA_INTERRUPT|SA_SHIRQ, + "Ensoniq AudioPCI", ensoniq)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_ensoniq_free(ensoniq); return -EBUSY; @@ -2083,7 +2131,8 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, ensoniq->subsystem_device_id = cmdw; #ifdef CHIP1370 #if 0 - ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); + ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_SERR_DISABLE | + ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); #else /* get microphone working */ ensoniq->ctrl = ES_1370_CDC_EN | ES_1370_PCLKDIVO(ES_1370_SRTODIV(8000)); #endif @@ -2128,9 +2177,9 @@ static int __devinit snd_ensoniq_create(snd_card_t * card, * MIDI section */ -static void snd_ensoniq_midi_interrupt(ensoniq_t * ensoniq) +static void snd_ensoniq_midi_interrupt(struct ensoniq * ensoniq) { - snd_rawmidi_t * rmidi = ensoniq->rmidi; + struct snd_rawmidi *rmidi = ensoniq->rmidi; unsigned char status, mask, byte; if (rmidi == NULL) @@ -2165,9 +2214,9 @@ static void snd_ensoniq_midi_interrupt(ensoniq_t * ensoniq) spin_unlock(&ensoniq->reg_lock); } -static int snd_ensoniq_midi_input_open(snd_rawmidi_substream_t * substream) +static int snd_ensoniq_midi_input_open(struct snd_rawmidi_substream *substream) { - ensoniq_t *ensoniq = substream->rmidi->private_data; + struct ensoniq *ensoniq = substream->rmidi->private_data; spin_lock_irq(&ensoniq->reg_lock); ensoniq->uartm |= ES_MODE_INPUT; @@ -2181,9 +2230,9 @@ static int snd_ensoniq_midi_input_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_ensoniq_midi_input_close(snd_rawmidi_substream_t * substream) +static int snd_ensoniq_midi_input_close(struct snd_rawmidi_substream *substream) { - ensoniq_t *ensoniq = substream->rmidi->private_data; + struct ensoniq *ensoniq = substream->rmidi->private_data; spin_lock_irq(&ensoniq->reg_lock); if (!(ensoniq->uartm & ES_MODE_OUTPUT)) { @@ -2198,9 +2247,9 @@ static int snd_ensoniq_midi_input_close(snd_rawmidi_substream_t * substream) return 0; } -static int snd_ensoniq_midi_output_open(snd_rawmidi_substream_t * substream) +static int snd_ensoniq_midi_output_open(struct snd_rawmidi_substream *substream) { - ensoniq_t *ensoniq = substream->rmidi->private_data; + struct ensoniq *ensoniq = substream->rmidi->private_data; spin_lock_irq(&ensoniq->reg_lock); ensoniq->uartm |= ES_MODE_OUTPUT; @@ -2214,9 +2263,9 @@ static int snd_ensoniq_midi_output_open(snd_rawmidi_substream_t * substream) return 0; } -static int snd_ensoniq_midi_output_close(snd_rawmidi_substream_t * substream) +static int snd_ensoniq_midi_output_close(struct snd_rawmidi_substream *substream) { - ensoniq_t *ensoniq = substream->rmidi->private_data; + struct ensoniq *ensoniq = substream->rmidi->private_data; spin_lock_irq(&ensoniq->reg_lock); if (!(ensoniq->uartm & ES_MODE_INPUT)) { @@ -2231,10 +2280,10 @@ static int snd_ensoniq_midi_output_close(snd_rawmidi_substream_t * substream) return 0; } -static void snd_ensoniq_midi_input_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_ensoniq_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - ensoniq_t *ensoniq = substream->rmidi->private_data; + struct ensoniq *ensoniq = substream->rmidi->private_data; int idx; spin_lock_irqsave(&ensoniq->reg_lock, flags); @@ -2255,10 +2304,10 @@ static void snd_ensoniq_midi_input_trigger(snd_rawmidi_substream_t * substream, spin_unlock_irqrestore(&ensoniq->reg_lock, flags); } -static void snd_ensoniq_midi_output_trigger(snd_rawmidi_substream_t * substream, int up) +static void snd_ensoniq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) { unsigned long flags; - ensoniq_t *ensoniq = substream->rmidi->private_data; + struct ensoniq *ensoniq = substream->rmidi->private_data; unsigned char byte; spin_lock_irqsave(&ensoniq->reg_lock, flags); @@ -2285,23 +2334,24 @@ static void snd_ensoniq_midi_output_trigger(snd_rawmidi_substream_t * substream, spin_unlock_irqrestore(&ensoniq->reg_lock, flags); } -static snd_rawmidi_ops_t snd_ensoniq_midi_output = +static struct snd_rawmidi_ops snd_ensoniq_midi_output = { .open = snd_ensoniq_midi_output_open, .close = snd_ensoniq_midi_output_close, .trigger = snd_ensoniq_midi_output_trigger, }; -static snd_rawmidi_ops_t snd_ensoniq_midi_input = +static struct snd_rawmidi_ops snd_ensoniq_midi_input = { .open = snd_ensoniq_midi_input_open, .close = snd_ensoniq_midi_input_close, .trigger = snd_ensoniq_midi_input_trigger, }; -static int __devinit snd_ensoniq_midi(ensoniq_t * ensoniq, int device, snd_rawmidi_t **rrawmidi) +static int __devinit snd_ensoniq_midi(struct ensoniq * ensoniq, int device, + struct snd_rawmidi **rrawmidi) { - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; int err; if (rrawmidi) @@ -2315,7 +2365,8 @@ static int __devinit snd_ensoniq_midi(ensoniq_t * ensoniq, int device, snd_rawmi #endif snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_ensoniq_midi_output); snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_ensoniq_midi_input); - rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; + rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | + SNDRV_RAWMIDI_INFO_DUPLEX; rmidi->private_data = ensoniq; ensoniq->rmidi = rmidi; if (rrawmidi) @@ -2329,7 +2380,7 @@ static int __devinit snd_ensoniq_midi(ensoniq_t * ensoniq, int device, snd_rawmi static irqreturn_t snd_audiopci_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ensoniq_t *ensoniq = dev_id; + struct ensoniq *ensoniq = dev_id; unsigned int status, sctrl; if (ensoniq == NULL) @@ -2366,8 +2417,8 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - ensoniq_t *ensoniq; + struct snd_card *card; + struct ensoniq *ensoniq; int err, pcm_devs[2]; if (dev >= SNDRV_CARDS) -- cgit v1.1 From e571f59436d1827b5f00f3fba90b30ad7a5ff01e Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:04:01 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI ES1938 Modules: ES1938 driver Remove xxx_t typedefs from the PCI ES1938 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/es1938.c | 320 +++++++++++++++++++++++++++++------------------------ 1 file changed, 173 insertions(+), 147 deletions(-) diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index d05c3d2b..577877d 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -191,11 +191,9 @@ MODULE_PARM_DESC(enable, "Enable ESS Solo-1 soundcard."); */ -typedef struct _snd_es1938 es1938_t; - #define SAVED_REG_SIZE 32 /* max. number of registers to save */ -struct _snd_es1938 { +struct es1938 { int irq; unsigned long io_port; @@ -208,19 +206,18 @@ struct _snd_es1938 { unsigned char irqmask; unsigned char revision; - snd_kcontrol_t *hw_volume; - snd_kcontrol_t *hw_switch; - snd_kcontrol_t *master_volume; - snd_kcontrol_t *master_switch; + struct snd_kcontrol *hw_volume; + struct snd_kcontrol *hw_switch; + struct snd_kcontrol *master_volume; + struct snd_kcontrol *master_switch; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *capture_substream; - snd_pcm_substream_t *playback1_substream; - snd_pcm_substream_t *playback2_substream; - snd_kmixer_t *mixer; - snd_rawmidi_t *rmidi; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *capture_substream; + struct snd_pcm_substream *playback1_substream; + struct snd_pcm_substream *playback2_substream; + struct snd_rawmidi *rmidi; unsigned int dma1_size; unsigned int dma2_size; @@ -232,7 +229,7 @@ struct _snd_es1938 { spinlock_t reg_lock; spinlock_t mixer_lock; - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; #ifdef SUPPORT_JOYSTICK struct gameport *gameport; @@ -259,7 +256,7 @@ MODULE_DEVICE_TABLE(pci, snd_es1938_ids); /* ----------------------------------------------------------------- * Write to a mixer register * -----------------------------------------------------------------*/ -static void snd_es1938_mixer_write(es1938_t *chip, unsigned char reg, unsigned char val) +static void snd_es1938_mixer_write(struct es1938 *chip, unsigned char reg, unsigned char val) { unsigned long flags; spin_lock_irqsave(&chip->mixer_lock, flags); @@ -274,7 +271,7 @@ static void snd_es1938_mixer_write(es1938_t *chip, unsigned char reg, unsigned c /* ----------------------------------------------------------------- * Read from a mixer register * -----------------------------------------------------------------*/ -static int snd_es1938_mixer_read(es1938_t *chip, unsigned char reg) +static int snd_es1938_mixer_read(struct es1938 *chip, unsigned char reg) { int data; unsigned long flags; @@ -291,7 +288,8 @@ static int snd_es1938_mixer_read(es1938_t *chip, unsigned char reg) /* ----------------------------------------------------------------- * Write to some bits of a mixer register (return old value) * -----------------------------------------------------------------*/ -static int snd_es1938_mixer_bits(es1938_t *chip, unsigned char reg, unsigned char mask, unsigned char val) +static int snd_es1938_mixer_bits(struct es1938 *chip, unsigned char reg, + unsigned char mask, unsigned char val) { unsigned long flags; unsigned char old, new, oval; @@ -314,7 +312,7 @@ static int snd_es1938_mixer_bits(es1938_t *chip, unsigned char reg, unsigned cha /* ----------------------------------------------------------------- * Write command to Controller Registers * -----------------------------------------------------------------*/ -static void snd_es1938_write_cmd(es1938_t *chip, unsigned char cmd) +static void snd_es1938_write_cmd(struct es1938 *chip, unsigned char cmd) { int i; unsigned char v; @@ -330,7 +328,7 @@ static void snd_es1938_write_cmd(es1938_t *chip, unsigned char cmd) /* ----------------------------------------------------------------- * Read the Read Data Buffer * -----------------------------------------------------------------*/ -static int snd_es1938_get_byte(es1938_t *chip) +static int snd_es1938_get_byte(struct es1938 *chip) { int i; unsigned char v; @@ -344,7 +342,7 @@ static int snd_es1938_get_byte(es1938_t *chip) /* ----------------------------------------------------------------- * Write value cmd register * -----------------------------------------------------------------*/ -static void snd_es1938_write(es1938_t *chip, unsigned char reg, unsigned char val) +static void snd_es1938_write(struct es1938 *chip, unsigned char reg, unsigned char val) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -359,7 +357,7 @@ static void snd_es1938_write(es1938_t *chip, unsigned char reg, unsigned char va /* ----------------------------------------------------------------- * Read data from cmd register and return it * -----------------------------------------------------------------*/ -static unsigned char snd_es1938_read(es1938_t *chip, unsigned char reg) +static unsigned char snd_es1938_read(struct es1938 *chip, unsigned char reg) { unsigned char val; unsigned long flags; @@ -377,7 +375,8 @@ static unsigned char snd_es1938_read(es1938_t *chip, unsigned char reg) /* ----------------------------------------------------------------- * Write data to cmd register and return old value * -----------------------------------------------------------------*/ -static int snd_es1938_bits(es1938_t *chip, unsigned char reg, unsigned char mask, unsigned char val) +static int snd_es1938_bits(struct es1938 *chip, unsigned char reg, unsigned char mask, + unsigned char val) { unsigned long flags; unsigned char old, new, oval; @@ -402,7 +401,7 @@ static int snd_es1938_bits(es1938_t *chip, unsigned char reg, unsigned char mask /* -------------------------------------------------------------------- * Reset the chip * --------------------------------------------------------------------*/ -static void snd_es1938_reset(es1938_t *chip) +static void snd_es1938_reset(struct es1938 *chip) { int i; @@ -441,13 +440,13 @@ static void snd_es1938_reset(es1938_t *chip) /* -------------------------------------------------------------------- * Reset the FIFOs * --------------------------------------------------------------------*/ -static void snd_es1938_reset_fifo(es1938_t *chip) +static void snd_es1938_reset_fifo(struct es1938 *chip) { outb(2, SLSB_REG(chip, RESET)); outb(0, SLSB_REG(chip, RESET)); } -static ratnum_t clocks[2] = { +static struct snd_ratnum clocks[2] = { { .num = 793800, .den_min = 1, @@ -462,18 +461,18 @@ static ratnum_t clocks[2] = { } }; -static snd_pcm_hw_constraint_ratnums_t hw_constraints_clocks = { +static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = { .nrats = 2, .rats = clocks, }; -static void snd_es1938_rate_set(es1938_t *chip, - snd_pcm_substream_t *substream, +static void snd_es1938_rate_set(struct es1938 *chip, + struct snd_pcm_substream *substream, int mode) { unsigned int bits, div0; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->rate_num == clocks[0].num) bits = 128 - runtime->rate_den; else @@ -495,7 +494,7 @@ static void snd_es1938_rate_set(es1938_t *chip, * Configure Solo1 builtin DMA Controller * --------------------------------------------------------------------*/ -static void snd_es1938_playback1_setdma(es1938_t *chip) +static void snd_es1938_playback1_setdma(struct es1938 *chip) { outb(0x00, SLIO_REG(chip, AUDIO2MODE)); outl(chip->dma2_start, SLIO_REG(chip, AUDIO2DMAADDR)); @@ -503,7 +502,7 @@ static void snd_es1938_playback1_setdma(es1938_t *chip) outw(chip->dma2_size, SLIO_REG(chip, AUDIO2DMACOUNT)); } -static void snd_es1938_playback2_setdma(es1938_t *chip) +static void snd_es1938_playback2_setdma(struct es1938 *chip) { /* Enable DMA controller */ outb(0xc4, SLDM_REG(chip, DMACOMMAND)); @@ -518,7 +517,7 @@ static void snd_es1938_playback2_setdma(es1938_t *chip) outb(0, SLDM_REG(chip, DMAMASK)); } -static void snd_es1938_capture_setdma(es1938_t *chip) +static void snd_es1938_capture_setdma(struct es1938 *chip) { /* Enable DMA controller */ outb(0xc4, SLDM_REG(chip, DMACOMMAND)); @@ -538,10 +537,10 @@ static void snd_es1938_capture_setdma(es1938_t *chip) * *** PCM part *** */ -static int snd_es1938_capture_trigger(snd_pcm_substream_t * substream, +static int snd_es1938_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - es1938_t *chip = snd_pcm_substream_chip(substream); + struct es1938 *chip = snd_pcm_substream_chip(substream); int val; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -561,10 +560,10 @@ static int snd_es1938_capture_trigger(snd_pcm_substream_t * substream, return 0; } -static int snd_es1938_playback1_trigger(snd_pcm_substream_t * substream, +static int snd_es1938_playback1_trigger(struct snd_pcm_substream *substream, int cmd) { - es1938_t *chip = snd_pcm_substream_chip(substream); + struct es1938 *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: @@ -591,10 +590,10 @@ static int snd_es1938_playback1_trigger(snd_pcm_substream_t * substream, return 0; } -static int snd_es1938_playback2_trigger(snd_pcm_substream_t * substream, +static int snd_es1938_playback2_trigger(struct snd_pcm_substream *substream, int cmd) { - es1938_t *chip = snd_pcm_substream_chip(substream); + struct es1938 *chip = snd_pcm_substream_chip(substream); int val; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -614,7 +613,7 @@ static int snd_es1938_playback2_trigger(snd_pcm_substream_t * substream, return 0; } -static int snd_es1938_playback_trigger(snd_pcm_substream_t *substream, +static int snd_es1938_playback_trigger(struct snd_pcm_substream *substream, int cmd) { switch (substream->number) { @@ -630,10 +629,10 @@ static int snd_es1938_playback_trigger(snd_pcm_substream_t *substream, /* -------------------------------------------------------------------- * First channel for Extended Mode Audio 1 ADC Operation * --------------------------------------------------------------------*/ -static int snd_es1938_capture_prepare(snd_pcm_substream_t * substream) +static int snd_es1938_capture_prepare(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct es1938 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int u, is8, mono; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -678,10 +677,10 @@ static int snd_es1938_capture_prepare(snd_pcm_substream_t * substream) /* ------------------------------------------------------------------------------ * Second Audio channel DAC Operation * ------------------------------------------------------------------------------*/ -static int snd_es1938_playback1_prepare(snd_pcm_substream_t * substream) +static int snd_es1938_playback1_prepare(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct es1938 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int u, is8, mono; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -706,7 +705,8 @@ static int snd_es1938_playback1_prepare(snd_pcm_substream_t * substream) snd_es1938_mixer_write(chip, ESSSB_IREG_AUDIO2TCOUNTH, count >> 8); /* initialize and configure Audio 2 DAC */ - snd_es1938_mixer_write(chip, ESSSB_IREG_AUDIO2CONTROL2, 0x40 | (u ? 0 : 4) | (mono ? 0 : 2) | (is8 ? 0 : 1)); + snd_es1938_mixer_write(chip, ESSSB_IREG_AUDIO2CONTROL2, 0x40 | (u ? 0 : 4) | + (mono ? 0 : 2) | (is8 ? 0 : 1)); /* program DMA */ snd_es1938_playback1_setdma(chip); @@ -714,10 +714,10 @@ static int snd_es1938_playback1_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_es1938_playback2_prepare(snd_pcm_substream_t * substream) +static int snd_es1938_playback2_prepare(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct es1938 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int u, is8, mono; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -756,7 +756,7 @@ static int snd_es1938_playback2_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_es1938_playback_prepare(snd_pcm_substream_t *substream) +static int snd_es1938_playback_prepare(struct snd_pcm_substream *substream) { switch (substream->number) { case 0: @@ -768,9 +768,9 @@ static int snd_es1938_playback_prepare(snd_pcm_substream_t *substream) return -EINVAL; } -static snd_pcm_uframes_t snd_es1938_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es1938_capture_pointer(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); + struct es1938 *chip = snd_pcm_substream_chip(substream); size_t ptr; size_t old, new; #if 1 @@ -785,9 +785,9 @@ static snd_pcm_uframes_t snd_es1938_capture_pointer(snd_pcm_substream_t * substr return ptr >> chip->dma1_shift; } -static snd_pcm_uframes_t snd_es1938_playback1_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es1938_playback1_pointer(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); + struct es1938 *chip = snd_pcm_substream_chip(substream); size_t ptr; #if 1 ptr = chip->dma2_size - inw(SLIO_REG(chip, AUDIO2DMACOUNT)); @@ -797,9 +797,9 @@ static snd_pcm_uframes_t snd_es1938_playback1_pointer(snd_pcm_substream_t * subs return ptr >> chip->dma2_shift; } -static snd_pcm_uframes_t snd_es1938_playback2_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_es1938_playback2_pointer(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); + struct es1938 *chip = snd_pcm_substream_chip(substream); size_t ptr; size_t old, new; #if 1 @@ -814,7 +814,7 @@ static snd_pcm_uframes_t snd_es1938_playback2_pointer(snd_pcm_substream_t * subs return ptr >> chip->dma1_shift; } -static snd_pcm_uframes_t snd_es1938_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_es1938_playback_pointer(struct snd_pcm_substream *substream) { switch (substream->number) { case 0: @@ -826,14 +826,14 @@ static snd_pcm_uframes_t snd_es1938_playback_pointer(snd_pcm_substream_t *substr return -EINVAL; } -static int snd_es1938_capture_copy(snd_pcm_substream_t *substream, +static int snd_es1938_capture_copy(struct snd_pcm_substream *substream, int channel, snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { - snd_pcm_runtime_t *runtime = substream->runtime; - es1938_t *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct es1938 *chip = snd_pcm_substream_chip(substream); pos <<= chip->dma1_shift; count <<= chip->dma1_shift; snd_assert(pos + count <= chip->dma1_size, return -EINVAL); @@ -852,8 +852,8 @@ static int snd_es1938_capture_copy(snd_pcm_substream_t *substream, /* * buffer management */ -static int snd_es1938_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) +static int snd_es1938_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int err; @@ -863,7 +863,7 @@ static int snd_es1938_pcm_hw_params(snd_pcm_substream_t *substream, return 0; } -static int snd_es1938_pcm_hw_free(snd_pcm_substream_t *substream) +static int snd_es1938_pcm_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } @@ -871,11 +871,12 @@ static int snd_es1938_pcm_hw_free(snd_pcm_substream_t *substream) /* ---------------------------------------------------------------------- * Audio1 Capture (ADC) * ----------------------------------------------------------------------*/ -static snd_pcm_hardware_t snd_es1938_capture = +static struct snd_pcm_hardware snd_es1938_capture = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER), - .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE, + .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, .rate_min = 6000, .rate_max = 48000, @@ -892,12 +893,13 @@ static snd_pcm_hardware_t snd_es1938_capture = /* ----------------------------------------------------------------------- * Audio2 Playback (DAC) * -----------------------------------------------------------------------*/ -static snd_pcm_hardware_t snd_es1938_playback = +static struct snd_pcm_hardware snd_es1938_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_MMAP_VALID), - .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE, + .formats = (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U16_LE), .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000, .rate_min = 6000, .rate_max = 48000, @@ -911,10 +913,10 @@ static snd_pcm_hardware_t snd_es1938_playback = .fifo_size = 256, }; -static int snd_es1938_capture_open(snd_pcm_substream_t * substream) +static int snd_es1938_capture_open(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct es1938 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (chip->playback2_substream) return -EAGAIN; @@ -926,10 +928,10 @@ static int snd_es1938_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es1938_playback_open(snd_pcm_substream_t * substream) +static int snd_es1938_playback_open(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct es1938 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; switch (substream->number) { case 0: @@ -951,17 +953,17 @@ static int snd_es1938_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_es1938_capture_close(snd_pcm_substream_t * substream) +static int snd_es1938_capture_close(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); + struct es1938 *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; return 0; } -static int snd_es1938_playback_close(snd_pcm_substream_t * substream) +static int snd_es1938_playback_close(struct snd_pcm_substream *substream) { - es1938_t *chip = snd_pcm_substream_chip(substream); + struct es1938 *chip = snd_pcm_substream_chip(substream); switch (substream->number) { case 0: @@ -977,7 +979,7 @@ static int snd_es1938_playback_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_es1938_playback_ops = { +static struct snd_pcm_ops snd_es1938_playback_ops = { .open = snd_es1938_playback_open, .close = snd_es1938_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -988,7 +990,7 @@ static snd_pcm_ops_t snd_es1938_playback_ops = { .pointer = snd_es1938_playback_pointer, }; -static snd_pcm_ops_t snd_es1938_capture_ops = { +static struct snd_pcm_ops snd_es1938_capture_ops = { .open = snd_es1938_capture_open, .close = snd_es1938_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1000,9 +1002,9 @@ static snd_pcm_ops_t snd_es1938_capture_ops = { .copy = snd_es1938_capture_copy, }; -static int __devinit snd_es1938_new_pcm(es1938_t *chip, int device) +static int __devinit snd_es1938_new_pcm(struct es1938 *chip, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "es-1938-1946", device, 2, 1, &pcm)) < 0) @@ -1026,7 +1028,8 @@ static int __devinit snd_es1938_new_pcm(es1938_t *chip, int device) * *** Mixer part *** */ -static int snd_es1938_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1938_info_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[8] = { "Mic", "Mic Master", "CD", "AOUT", @@ -1042,16 +1045,18 @@ static int snd_es1938_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * u return 0; } -static int snd_es1938_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_get_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.enumerated.item[0] = snd_es1938_mixer_read(chip, 0x1c) & 0x07; return 0; } -static int snd_es1938_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_put_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); unsigned char val = ucontrol->value.enumerated.item[0]; if (val > 7) @@ -1059,7 +1064,8 @@ static int snd_es1938_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return snd_es1938_mixer_bits(chip, 0x1c, 0x07, val) != val; } -static int snd_es1938_info_spatializer_enable(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1938_info_spatializer_enable(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1068,17 +1074,19 @@ static int snd_es1938_info_spatializer_enable(snd_kcontrol_t *kcontrol, snd_ctl_ return 0; } -static int snd_es1938_get_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_get_spatializer_enable(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); unsigned char val = snd_es1938_mixer_read(chip, 0x50); ucontrol->value.integer.value[0] = !!(val & 8); return 0; } -static int snd_es1938_put_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_put_spatializer_enable(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); unsigned char oval, nval; int change; nval = ucontrol->value.integer.value[0] ? 0x0c : 0x04; @@ -1091,7 +1099,8 @@ static int snd_es1938_put_spatializer_enable(snd_kcontrol_t * kcontrol, snd_ctl_ return change; } -static int snd_es1938_info_hw_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1938_info_hw_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1100,15 +1109,17 @@ static int snd_es1938_info_hw_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_es1938_get_hw_volume(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_get_hw_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = snd_es1938_mixer_read(chip, 0x61) & 0x3f; ucontrol->value.integer.value[1] = snd_es1938_mixer_read(chip, 0x63) & 0x3f; return 0; } -static int snd_es1938_info_hw_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1938_info_hw_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -1117,24 +1128,25 @@ static int snd_es1938_info_hw_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_info return 0; } -static int snd_es1938_get_hw_switch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_get_hw_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = !(snd_es1938_mixer_read(chip, 0x61) & 0x40); ucontrol->value.integer.value[1] = !(snd_es1938_mixer_read(chip, 0x63) & 0x40); return 0; } -static void snd_es1938_hwv_free(snd_kcontrol_t *kcontrol) +static void snd_es1938_hwv_free(struct snd_kcontrol *kcontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); chip->master_volume = NULL; chip->master_switch = NULL; chip->hw_volume = NULL; chip->hw_switch = NULL; } -static int snd_es1938_reg_bits(es1938_t *chip, unsigned char reg, +static int snd_es1938_reg_bits(struct es1938 *chip, unsigned char reg, unsigned char mask, unsigned char val) { if (reg < 0xa0) @@ -1143,7 +1155,7 @@ static int snd_es1938_reg_bits(es1938_t *chip, unsigned char reg, return snd_es1938_bits(chip, reg, mask, val); } -static int snd_es1938_reg_read(es1938_t *chip, unsigned char reg) +static int snd_es1938_reg_read(struct es1938 *chip, unsigned char reg) { if (reg < 0xa0) return snd_es1938_mixer_read(chip, reg); @@ -1157,7 +1169,8 @@ static int snd_es1938_reg_read(es1938_t *chip, unsigned char reg) .get = snd_es1938_get_single, .put = snd_es1938_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_es1938_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1938_info_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1168,9 +1181,10 @@ static int snd_es1938_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es1938_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_get_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1184,9 +1198,10 @@ static int snd_es1938_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es1938_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_put_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1207,7 +1222,8 @@ static int snd_es1938_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_es1938_get_double, .put = snd_es1938_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_es1938_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_es1938_info_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1218,9 +1234,10 @@ static int snd_es1938_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_es1938_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_get_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int shift_left = (kcontrol->private_value >> 16) & 0x07; @@ -1243,9 +1260,10 @@ static int snd_es1938_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_es1938_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_es1938_put_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - es1938_t *chip = snd_kcontrol_chip(kcontrol); + struct es1938 *chip = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int shift_left = (kcontrol->private_value >> 16) & 0x07; @@ -1278,7 +1296,7 @@ static int snd_es1938_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static snd_kcontrol_new_t snd_es1938_controls[] = { +static struct snd_kcontrol_new snd_es1938_controls[] = { ES1938_DOUBLE("Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0), ES1938_DOUBLE("Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1), { @@ -1341,7 +1359,7 @@ ES1938_SINGLE("Mic Boost (+26dB)", 0, 0x7d, 3, 1, 0) /* * initialize the chip - used by resume callback, too */ -static void snd_es1938_chip_init(es1938_t *chip) +static void snd_es1938_chip_init(struct es1938 *chip) { /* reset chip */ snd_es1938_reset(chip); @@ -1380,9 +1398,9 @@ static unsigned char saved_regs[SAVED_REG_SIZE+1] = { }; -static int es1938_suspend(snd_card_t *card, pm_message_t state) +static int es1938_suspend(struct snd_card *card, pm_message_t state) { - es1938_t *chip = card->pm_private_data; + struct es1938 *chip = card->pm_private_data; unsigned char *s, *d; snd_pcm_suspend_all(chip->pcm); @@ -1393,19 +1411,19 @@ static int es1938_suspend(snd_card_t *card, pm_message_t state) outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); pci_disable_device(chip->pci); return 0; } -static int es1938_resume(snd_card_t *card) +static int es1938_resume(struct snd_card *card) { - es1938_t *chip = card->pm_private_data; + struct es1938 *chip = card->pm_private_data; unsigned char *s, *d; pci_enable_device(chip->pci); request_irq(chip->pci->irq, snd_es1938_interrupt, - SA_INTERRUPT|SA_SHIRQ, "ES1938", (void *)chip); + SA_INTERRUPT|SA_SHIRQ, "ES1938", chip); chip->irq = chip->pci->irq; snd_es1938_chip_init(chip); @@ -1422,7 +1440,7 @@ static int es1938_resume(snd_card_t *card) #endif /* CONFIG_PM */ #ifdef SUPPORT_JOYSTICK -static int __devinit snd_es1938_create_gameport(es1938_t *chip) +static int __devinit snd_es1938_create_gameport(struct es1938 *chip) { struct gameport *gp; @@ -1442,7 +1460,7 @@ static int __devinit snd_es1938_create_gameport(es1938_t *chip) return 0; } -static void snd_es1938_free_gameport(es1938_t *chip) +static void snd_es1938_free_gameport(struct es1938 *chip) { if (chip->gameport) { gameport_unregister_port(chip->gameport); @@ -1450,11 +1468,11 @@ static void snd_es1938_free_gameport(es1938_t *chip) } } #else -static inline int snd_es1938_create_gameport(es1938_t *chip) { return -ENOSYS; } -static inline void snd_es1938_free_gameport(es1938_t *chip) { } +static inline int snd_es1938_create_gameport(struct es1938 *chip) { return -ENOSYS; } +static inline void snd_es1938_free_gameport(struct es1938 *chip) { } #endif /* SUPPORT_JOYSTICK */ -static int snd_es1938_free(es1938_t *chip) +static int snd_es1938_free(struct es1938 *chip) { /* disable irqs */ outb(0x00, SLIO_REG(chip, IRQCONTROL)); @@ -1464,26 +1482,26 @@ static int snd_es1938_free(es1938_t *chip) snd_es1938_free_gameport(chip); if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); return 0; } -static int snd_es1938_dev_free(snd_device_t *device) +static int snd_es1938_dev_free(struct snd_device *device) { - es1938_t *chip = device->device_data; + struct es1938 *chip = device->device_data; return snd_es1938_free(chip); } -static int __devinit snd_es1938_create(snd_card_t * card, +static int __devinit snd_es1938_create(struct snd_card *card, struct pci_dev * pci, - es1938_t ** rchip) + struct es1938 ** rchip) { - es1938_t *chip; + struct es1938 *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_es1938_dev_free, }; @@ -1519,7 +1537,8 @@ static int __devinit snd_es1938_create(snd_card_t * card, chip->vc_port = pci_resource_start(pci, 2); chip->mpu_port = pci_resource_start(pci, 3); chip->game_port = pci_resource_start(pci, 4); - if (request_irq(pci->irq, snd_es1938_interrupt, SA_INTERRUPT|SA_SHIRQ, "ES1938", (void *)chip)) { + if (request_irq(pci->irq, snd_es1938_interrupt, SA_INTERRUPT|SA_SHIRQ, + "ES1938", chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_es1938_free(chip); return -EBUSY; @@ -1552,7 +1571,7 @@ static int __devinit snd_es1938_create(snd_card_t * card, * -------------------------------------------------------------------- */ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - es1938_t *chip = dev_id; + struct es1938 *chip = dev_id; unsigned char status, audiostatus; int handled = 0; @@ -1565,9 +1584,12 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *r if (status & 0x10) { #if 0 printk("Es1938debug - AUDIO channel 1 interrupt\n"); - printk("Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n", inw(SLDM_REG(chip, DMACOUNT))); - printk("Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n", inl(SLDM_REG(chip, DMAADDR))); - printk("Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n", inl(SLDM_REG(chip, DMASTATUS))); + printk("Es1938debug - AUDIO channel 1 DMAC DMA count: %u\n", + inw(SLDM_REG(chip, DMACOUNT))); + printk("Es1938debug - AUDIO channel 1 DMAC DMA base: %u\n", + inl(SLDM_REG(chip, DMAADDR))); + printk("Es1938debug - AUDIO channel 1 DMAC DMA status: 0x%x\n", + inl(SLDM_REG(chip, DMASTATUS))); #endif /* clear irq */ handled = 1; @@ -1582,8 +1604,10 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *r if (status & 0x20) { #if 0 printk("Es1938debug - AUDIO channel 2 interrupt\n"); - printk("Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n", inw(SLIO_REG(chip, AUDIO2DMACOUNT))); - printk("Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n", inl(SLIO_REG(chip, AUDIO2DMAADDR))); + printk("Es1938debug - AUDIO channel 2 DMAC DMA count: %u\n", + inw(SLIO_REG(chip, AUDIO2DMACOUNT))); + printk("Es1938debug - AUDIO channel 2 DMAC DMA base: %u\n", + inl(SLIO_REG(chip, AUDIO2DMAADDR))); #endif /* clear irq */ @@ -1600,8 +1624,10 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *r snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); if (!split) { - snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id); - snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id); + snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, + &chip->master_switch->id); + snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, + &chip->master_volume->id); } /* ack interrupt */ snd_es1938_mixer_write(chip, 0x66, 0x00); @@ -1623,9 +1649,9 @@ static irqreturn_t snd_es1938_interrupt(int irq, void *dev_id, struct pt_regs *r #define ES1938_DMA_SIZE 64 -static int __devinit snd_es1938_mixer(es1938_t *chip) +static int __devinit snd_es1938_mixer(struct es1938 *chip) { - snd_card_t *card; + struct snd_card *card; unsigned int idx; int err; @@ -1634,7 +1660,7 @@ static int __devinit snd_es1938_mixer(es1938_t *chip) strcpy(card->mixername, "ESS Solo-1"); for (idx = 0; idx < ARRAY_SIZE(snd_es1938_controls); idx++) { - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; kctl = snd_ctl_new1(&snd_es1938_controls[idx], chip); switch (idx) { case 0: @@ -1665,9 +1691,9 @@ static int __devinit snd_es1938_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - es1938_t *chip; - opl3_t *opl3; + struct snd_card *card; + struct es1938 *chip; + struct snd_opl3 *opl3; int idx, err; if (dev >= SNDRV_CARDS) -- cgit v1.1 From 969165a8b5d9a5b3e3c205c312a13a1872844297 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:04:14 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI ES1968 Modules: ES1968 driver Remove xxx_t typedefs from the PCI ES1968 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/es1968.c | 288 ++++++++++++++++++++++++++--------------------------- 1 file changed, 142 insertions(+), 146 deletions(-) diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 50079dc..021862d 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -470,10 +470,6 @@ static u16 acpi_state_mask[] = { }; -typedef struct snd_es1968 es1968_t; -typedef struct snd_esschan esschan_t; -typedef struct snd_esm_memory esm_memory_t; - /* APU use in the driver */ enum snd_enum_apu_type { ESM_APU_PCM_PLAY, @@ -488,23 +484,23 @@ enum { }; /* DMA Hack! */ -struct snd_esm_memory { +struct esm_memory { struct snd_dma_buffer buf; int empty; /* status */ struct list_head list; }; /* Playback Channel */ -struct snd_esschan { +struct esschan { int running; u8 apu[4]; u8 apu_mode[4]; /* playback/capture pcm buffer */ - esm_memory_t *memory; + struct esm_memory *memory; /* capture mixer buffer */ - esm_memory_t *mixbuf; + struct esm_memory *mixbuf; unsigned int hwptr; /* current hw pointer in bytes */ unsigned int count; /* sample counter in bytes */ @@ -519,7 +515,7 @@ struct snd_esschan { int bob_freq; /* required timer frequency */ - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; /* linked list */ struct list_head list; @@ -529,7 +525,7 @@ struct snd_esschan { #endif }; -struct snd_es1968 { +struct es1968 { /* Module Config */ int total_bufsize; /* in bytes */ @@ -550,19 +546,19 @@ struct snd_es1968 { unsigned long io_port; int type; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; + struct snd_card *card; + struct snd_pcm *pcm; int do_pm; /* power-management enabled */ /* DMA memory block */ struct list_head buf_list; /* ALSA Stuff */ - ac97_t *ac97; - snd_kcontrol_t *master_switch; /* for h/w volume control */ - snd_kcontrol_t *master_volume; + struct snd_ac97 *ac97; + struct snd_kcontrol *master_switch; /* for h/w volume control */ + struct snd_kcontrol *master_volume; - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; spinlock_t reg_lock; spinlock_t ac97_lock; @@ -610,14 +606,14 @@ MODULE_DEVICE_TABLE(pci, snd_es1968_ids); *********************/ /* no spinlock */ -static void __maestro_write(es1968_t *chip, u16 reg, u16 data) +static void __maestro_write(struct es1968 *chip, u16 reg, u16 data) { outw(reg, chip->io_port + ESM_INDEX); outw(data, chip->io_port + ESM_DATA); chip->maestro_map[reg] = data; } -static inline void maestro_write(es1968_t *chip, u16 reg, u16 data) +static inline void maestro_write(struct es1968 *chip, u16 reg, u16 data) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -626,7 +622,7 @@ static inline void maestro_write(es1968_t *chip, u16 reg, u16 data) } /* no spinlock */ -static u16 __maestro_read(es1968_t *chip, u16 reg) +static u16 __maestro_read(struct es1968 *chip, u16 reg) { if (READABLE_MAP & (1 << reg)) { outw(reg, chip->io_port + ESM_INDEX); @@ -635,7 +631,7 @@ static u16 __maestro_read(es1968_t *chip, u16 reg) return chip->maestro_map[reg]; } -static inline u16 maestro_read(es1968_t *chip, u16 reg) +static inline u16 maestro_read(struct es1968 *chip, u16 reg) { unsigned long flags; u16 result; @@ -646,7 +642,7 @@ static inline u16 maestro_read(es1968_t *chip, u16 reg) } /* Wait for the codec bus to be free */ -static int snd_es1968_ac97_wait(es1968_t *chip) +static int snd_es1968_ac97_wait(struct es1968 *chip) { int timeout = 100000; @@ -659,9 +655,9 @@ static int snd_es1968_ac97_wait(es1968_t *chip) return 1; /* timeout */ } -static void snd_es1968_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +static void snd_es1968_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - es1968_t *chip = ac97->private_data; + struct es1968 *chip = ac97->private_data; unsigned long flags; snd_es1968_ac97_wait(chip); @@ -675,10 +671,10 @@ static void snd_es1968_ac97_write(ac97_t *ac97, unsigned short reg, unsigned sho spin_unlock_irqrestore(&chip->ac97_lock, flags); } -static unsigned short snd_es1968_ac97_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_es1968_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { u16 data = 0; - es1968_t *chip = ac97->private_data; + struct es1968 *chip = ac97->private_data; unsigned long flags; snd_es1968_ac97_wait(chip); @@ -697,7 +693,7 @@ static unsigned short snd_es1968_ac97_read(ac97_t *ac97, unsigned short reg) } /* no spinlock */ -static void apu_index_set(es1968_t *chip, u16 index) +static void apu_index_set(struct es1968 *chip, u16 index) { int i; __maestro_write(chip, IDR1_CRAM_POINTER, index); @@ -708,7 +704,7 @@ static void apu_index_set(es1968_t *chip, u16 index) } /* no spinlock */ -static void apu_data_set(es1968_t *chip, u16 data) +static void apu_data_set(struct es1968 *chip, u16 data) { int i; for (i = 0; i < 1000; i++) { @@ -720,7 +716,7 @@ static void apu_data_set(es1968_t *chip, u16 data) } /* no spinlock */ -static void __apu_set_register(es1968_t *chip, u16 channel, u8 reg, u16 data) +static void __apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data) { snd_assert(channel < NR_APUS, return); #ifdef CONFIG_PM @@ -731,7 +727,7 @@ static void __apu_set_register(es1968_t *chip, u16 channel, u8 reg, u16 data) apu_data_set(chip, data); } -static inline void apu_set_register(es1968_t *chip, u16 channel, u8 reg, u16 data) +static inline void apu_set_register(struct es1968 *chip, u16 channel, u8 reg, u16 data) { unsigned long flags; spin_lock_irqsave(&chip->reg_lock, flags); @@ -739,7 +735,7 @@ static inline void apu_set_register(es1968_t *chip, u16 channel, u8 reg, u16 dat spin_unlock_irqrestore(&chip->reg_lock, flags); } -static u16 __apu_get_register(es1968_t *chip, u16 channel, u8 reg) +static u16 __apu_get_register(struct es1968 *chip, u16 channel, u8 reg) { snd_assert(channel < NR_APUS, return 0); reg |= (channel << 4); @@ -747,7 +743,7 @@ static u16 __apu_get_register(es1968_t *chip, u16 channel, u8 reg) return __maestro_read(chip, IDR0_DATA_PORT); } -static inline u16 apu_get_register(es1968_t *chip, u16 channel, u8 reg) +static inline u16 apu_get_register(struct es1968 *chip, u16 channel, u8 reg) { unsigned long flags; u16 v; @@ -759,7 +755,7 @@ static inline u16 apu_get_register(es1968_t *chip, u16 channel, u8 reg) #if 0 /* ASSP is not supported */ -static void assp_set_register(es1968_t *chip, u32 reg, u32 value) +static void assp_set_register(struct es1968 *chip, u32 reg, u32 value) { unsigned long flags; @@ -769,7 +765,7 @@ static void assp_set_register(es1968_t *chip, u32 reg, u32 value) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static u32 assp_get_register(es1968_t *chip, u32 reg) +static u32 assp_get_register(struct es1968 *chip, u32 reg) { unsigned long flags; u32 value; @@ -784,7 +780,7 @@ static u32 assp_get_register(es1968_t *chip, u32 reg) #endif -static void wave_set_register(es1968_t *chip, u16 reg, u16 value) +static void wave_set_register(struct es1968 *chip, u16 reg, u16 value) { unsigned long flags; @@ -794,7 +790,7 @@ static void wave_set_register(es1968_t *chip, u16 reg, u16 value) spin_unlock_irqrestore(&chip->reg_lock, flags); } -static u16 wave_get_register(es1968_t *chip, u16 reg) +static u16 wave_get_register(struct es1968 *chip, u16 reg) { unsigned long flags; u16 value; @@ -811,7 +807,7 @@ static u16 wave_get_register(es1968_t *chip, u16 reg) * Bob the Timer! * *******************/ -static void snd_es1968_bob_stop(es1968_t *chip) +static void snd_es1968_bob_stop(struct es1968 *chip) { u16 reg; @@ -823,7 +819,7 @@ static void snd_es1968_bob_stop(es1968_t *chip) __maestro_write(chip, 0x17, reg); } -static void snd_es1968_bob_start(es1968_t *chip) +static void snd_es1968_bob_start(struct es1968 *chip) { int prescale; int divide; @@ -863,7 +859,7 @@ static void snd_es1968_bob_start(es1968_t *chip) } /* call with substream spinlock */ -static void snd_es1968_bob_inc(es1968_t *chip, int freq) +static void snd_es1968_bob_inc(struct es1968 *chip, int freq) { chip->bobclient++; if (chip->bobclient == 1) { @@ -877,7 +873,7 @@ static void snd_es1968_bob_inc(es1968_t *chip, int freq) } /* call with substream spinlock */ -static void snd_es1968_bob_dec(es1968_t *chip) +static void snd_es1968_bob_dec(struct es1968 *chip) { chip->bobclient--; if (chip->bobclient <= 0) @@ -887,7 +883,7 @@ static void snd_es1968_bob_dec(es1968_t *chip) struct list_head *p; int max_freq = ESM_BOB_FREQ; list_for_each(p, &chip->substream_list) { - esschan_t *es = list_entry(p, esschan_t, list); + struct esschan *es = list_entry(p, struct esschan, list); if (max_freq < es->bob_freq) max_freq = es->bob_freq; } @@ -900,8 +896,8 @@ static void snd_es1968_bob_dec(es1968_t *chip) } static int -snd_es1968_calc_bob_rate(es1968_t *chip, esschan_t *es, - snd_pcm_runtime_t *runtime) +snd_es1968_calc_bob_rate(struct es1968 *chip, struct esschan *es, + struct snd_pcm_runtime *runtime) { /* we acquire 4 interrupts per period for precise control.. */ int freq = runtime->rate * 4; @@ -922,7 +918,7 @@ snd_es1968_calc_bob_rate(es1968_t *chip, esschan_t *es, * PCM Part * *************/ -static u32 snd_es1968_compute_rate(es1968_t *chip, u32 freq) +static u32 snd_es1968_compute_rate(struct es1968 *chip, u32 freq) { u32 rate = (freq << 16) / chip->clock; #if 0 /* XXX: do we need this? */ @@ -934,7 +930,7 @@ static u32 snd_es1968_compute_rate(es1968_t *chip, u32 freq) /* get current pointer */ static inline unsigned int -snd_es1968_get_dma_ptr(es1968_t *chip, esschan_t *es) +snd_es1968_get_dma_ptr(struct es1968 *chip, struct esschan *es) { unsigned int offset; @@ -945,7 +941,7 @@ snd_es1968_get_dma_ptr(es1968_t *chip, esschan_t *es) return (offset & 0xFFFE); /* hardware is in words */ } -static void snd_es1968_apu_set_freq(es1968_t *chip, int apu, int freq) +static void snd_es1968_apu_set_freq(struct es1968 *chip, int apu, int freq) { apu_set_register(chip, apu, 2, (apu_get_register(chip, apu, 2) & 0x00FF) | @@ -954,7 +950,7 @@ static void snd_es1968_apu_set_freq(es1968_t *chip, int apu, int freq) } /* spin lock held */ -static inline void snd_es1968_trigger_apu(es1968_t *esm, int apu, int mode) +static inline void snd_es1968_trigger_apu(struct es1968 *esm, int apu, int mode) { /* set the APU mode */ __apu_set_register(esm, apu, 0, @@ -962,7 +958,7 @@ static inline void snd_es1968_trigger_apu(es1968_t *esm, int apu, int mode) (mode << 4)); } -static void snd_es1968_pcm_start(es1968_t *chip, esschan_t *es) +static void snd_es1968_pcm_start(struct es1968 *chip, struct esschan *es) { spin_lock(&chip->reg_lock); __apu_set_register(chip, es->apu[0], 5, es->base[0]); @@ -982,7 +978,7 @@ static void snd_es1968_pcm_start(es1968_t *chip, esschan_t *es) spin_unlock(&chip->reg_lock); } -static void snd_es1968_pcm_stop(es1968_t *chip, esschan_t *es) +static void snd_es1968_pcm_stop(struct es1968 *chip, struct esschan *es) { spin_lock(&chip->reg_lock); snd_es1968_trigger_apu(chip, es->apu[0], 0); @@ -995,7 +991,7 @@ static void snd_es1968_pcm_stop(es1968_t *chip, esschan_t *es) } /* set the wavecache control reg */ -static void snd_es1968_program_wavecache(es1968_t *chip, esschan_t *es, +static void snd_es1968_program_wavecache(struct es1968 *chip, struct esschan *es, int channel, u32 addr, int capture) { u32 tmpval = (addr - 0x10) & 0xFFF8; @@ -1016,8 +1012,8 @@ static void snd_es1968_program_wavecache(es1968_t *chip, esschan_t *es, } -static void snd_es1968_playback_setup(es1968_t *chip, esschan_t *es, - snd_pcm_runtime_t *runtime) +static void snd_es1968_playback_setup(struct es1968 *chip, struct esschan *es, + struct snd_pcm_runtime *runtime) { u32 pa; int high_apu = 0; @@ -1119,7 +1115,7 @@ static void snd_es1968_playback_setup(es1968_t *chip, esschan_t *es, } -static void init_capture_apu(es1968_t *chip, esschan_t *es, int channel, +static void init_capture_apu(struct es1968 *chip, struct esschan *es, int channel, unsigned int pa, unsigned int bsize, int mode, int route) { @@ -1164,8 +1160,8 @@ static void init_capture_apu(es1968_t *chip, esschan_t *es, int channel, apu_set_register(chip, apu, 0, 0x400F); } -static void snd_es1968_capture_setup(es1968_t *chip, esschan_t *es, - snd_pcm_runtime_t *runtime) +static void snd_es1968_capture_setup(struct es1968 *chip, struct esschan *es, + struct snd_pcm_runtime *runtime) { int size; u32 freq; @@ -1233,11 +1229,11 @@ static void snd_es1968_capture_setup(es1968_t *chip, esschan_t *es, * ALSA Interface * *******************/ -static int snd_es1968_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_es1968_pcm_prepare(struct snd_pcm_substream *substream) { - es1968_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - esschan_t *es = runtime->private_data; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct esschan *es = runtime->private_data; es->dma_size = snd_pcm_lib_buffer_bytes(substream); es->frag_size = snd_pcm_lib_period_bytes(substream); @@ -1265,10 +1261,10 @@ static int snd_es1968_pcm_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_es1968_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_es1968_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - es1968_t *chip = snd_pcm_substream_chip(substream); - esschan_t *es = substream->runtime->private_data; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct esschan *es = substream->runtime->private_data; spin_lock(&chip->substream_lock); switch (cmd) { @@ -1295,10 +1291,10 @@ static int snd_es1968_pcm_trigger(snd_pcm_substream_t *substream, int cmd) return 0; } -static snd_pcm_uframes_t snd_es1968_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_es1968_pcm_pointer(struct snd_pcm_substream *substream) { - es1968_t *chip = snd_pcm_substream_chip(substream); - esschan_t *es = substream->runtime->private_data; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct esschan *es = substream->runtime->private_data; unsigned int ptr; ptr = snd_es1968_get_dma_ptr(chip, es) << es->wav_shift; @@ -1306,7 +1302,7 @@ static snd_pcm_uframes_t snd_es1968_pcm_pointer(snd_pcm_substream_t *substream) return bytes_to_frames(substream->runtime, ptr % es->dma_size); } -static snd_pcm_hardware_t snd_es1968_playback = { +static struct snd_pcm_hardware snd_es1968_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -1327,7 +1323,7 @@ static snd_pcm_hardware_t snd_es1968_playback = { .fifo_size = 0, }; -static snd_pcm_hardware_t snd_es1968_capture = { +static struct snd_pcm_hardware snd_es1968_capture = { .info = (SNDRV_PCM_INFO_NONINTERLEAVED | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -1355,14 +1351,14 @@ static snd_pcm_hardware_t snd_es1968_capture = { /* Because the Maestro can only take addresses relative to the PCM base address register :( */ -static int calc_available_memory_size(es1968_t *chip) +static int calc_available_memory_size(struct es1968 *chip) { struct list_head *p; int max_size = 0; down(&chip->memory_mutex); list_for_each(p, &chip->buf_list) { - esm_memory_t *buf = list_entry(p, esm_memory_t, list); + struct esm_memory *buf = list_entry(p, struct esm_memory, list); if (buf->empty && buf->buf.bytes > max_size) max_size = buf->buf.bytes; } @@ -1373,15 +1369,15 @@ static int calc_available_memory_size(es1968_t *chip) } /* allocate a new memory chunk with the specified size */ -static esm_memory_t *snd_es1968_new_memory(es1968_t *chip, int size) +static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size) { - esm_memory_t *buf; + struct esm_memory *buf; struct list_head *p; size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN; down(&chip->memory_mutex); list_for_each(p, &chip->buf_list) { - buf = list_entry(p, esm_memory_t, list); + buf = list_entry(p, struct esm_memory, list); if (buf->empty && buf->buf.bytes >= size) goto __found; } @@ -1390,7 +1386,7 @@ static esm_memory_t *snd_es1968_new_memory(es1968_t *chip, int size) __found: if (buf->buf.bytes > size) { - esm_memory_t *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL); + struct esm_memory *chunk = kmalloc(sizeof(*chunk), GFP_KERNEL); if (chunk == NULL) { up(&chip->memory_mutex); return NULL; @@ -1409,14 +1405,14 @@ __found: } /* free a memory chunk */ -static void snd_es1968_free_memory(es1968_t *chip, esm_memory_t *buf) +static void snd_es1968_free_memory(struct es1968 *chip, struct esm_memory *buf) { - esm_memory_t *chunk; + struct esm_memory *chunk; down(&chip->memory_mutex); buf->empty = 1; if (buf->list.prev != &chip->buf_list) { - chunk = list_entry(buf->list.prev, esm_memory_t, list); + chunk = list_entry(buf->list.prev, struct esm_memory, list); if (chunk->empty) { chunk->buf.bytes += buf->buf.bytes; list_del(&buf->list); @@ -1425,7 +1421,7 @@ static void snd_es1968_free_memory(es1968_t *chip, esm_memory_t *buf) } } if (buf->list.next != &chip->buf_list) { - chunk = list_entry(buf->list.next, esm_memory_t, list); + chunk = list_entry(buf->list.next, struct esm_memory, list); if (chunk->empty) { buf->buf.bytes += chunk->buf.bytes; list_del(&chunk->list); @@ -1435,7 +1431,7 @@ static void snd_es1968_free_memory(es1968_t *chip, esm_memory_t *buf) up(&chip->memory_mutex); } -static void snd_es1968_free_dmabuf(es1968_t *chip) +static void snd_es1968_free_dmabuf(struct es1968 *chip) { struct list_head *p; @@ -1443,17 +1439,17 @@ static void snd_es1968_free_dmabuf(es1968_t *chip) return; snd_dma_reserve_buf(&chip->dma, snd_dma_pci_buf_id(chip->pci)); while ((p = chip->buf_list.next) != &chip->buf_list) { - esm_memory_t *chunk = list_entry(p, esm_memory_t, list); + struct esm_memory *chunk = list_entry(p, struct esm_memory, list); list_del(p); kfree(chunk); } } static int __devinit -snd_es1968_init_dmabuf(es1968_t *chip) +snd_es1968_init_dmabuf(struct es1968 *chip) { int err; - esm_memory_t *chunk; + struct esm_memory *chunk; chip->dma.dev.type = SNDRV_DMA_TYPE_DEV; chip->dma.dev.dev = snd_dma_pci_data(chip->pci); @@ -1493,12 +1489,12 @@ snd_es1968_init_dmabuf(es1968_t *chip) /* setup the dma_areas */ /* buffer is extracted from the pre-allocated memory chunk */ -static int snd_es1968_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_es1968_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - es1968_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - esschan_t *chan = runtime->private_data; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct esschan *chan = runtime->private_data; int size = params_buffer_bytes(hw_params); if (chan->memory) { @@ -1518,11 +1514,11 @@ static int snd_es1968_hw_params(snd_pcm_substream_t *substream, } /* remove dma areas if allocated */ -static int snd_es1968_hw_free(snd_pcm_substream_t * substream) +static int snd_es1968_hw_free(struct snd_pcm_substream *substream) { - es1968_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - esschan_t *chan; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct esschan *chan; if (runtime->private_data == NULL) return 0; @@ -1538,7 +1534,7 @@ static int snd_es1968_hw_free(snd_pcm_substream_t * substream) /* * allocate APU pair */ -static int snd_es1968_alloc_apu_pair(es1968_t *chip, int type) +static int snd_es1968_alloc_apu_pair(struct es1968 *chip, int type) { int apu; @@ -1555,7 +1551,7 @@ static int snd_es1968_alloc_apu_pair(es1968_t *chip, int type) /* * release APU pair */ -static void snd_es1968_free_apu_pair(es1968_t *chip, int apu) +static void snd_es1968_free_apu_pair(struct es1968 *chip, int apu) { chip->apu[apu] = chip->apu[apu + 1] = ESM_APU_FREE; } @@ -1565,11 +1561,11 @@ static void snd_es1968_free_apu_pair(es1968_t *chip, int apu) * PCM open/close * ******************/ -static int snd_es1968_playback_open(snd_pcm_substream_t *substream) +static int snd_es1968_playback_open(struct snd_pcm_substream *substream) { - es1968_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - esschan_t *es; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct esschan *es; int apu1; /* search 2 APUs */ @@ -1606,11 +1602,11 @@ static int snd_es1968_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_es1968_capture_open(snd_pcm_substream_t *substream) +static int snd_es1968_capture_open(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - es1968_t *chip = snd_pcm_substream_chip(substream); - esschan_t *es; + struct snd_pcm_runtime *runtime = substream->runtime; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct esschan *es; int apu1, apu2; apu1 = snd_es1968_alloc_apu_pair(chip, ESM_APU_PCM_CAPTURE); @@ -1665,10 +1661,10 @@ static int snd_es1968_capture_open(snd_pcm_substream_t *substream) return 0; } -static int snd_es1968_playback_close(snd_pcm_substream_t * substream) +static int snd_es1968_playback_close(struct snd_pcm_substream *substream) { - es1968_t *chip = snd_pcm_substream_chip(substream); - esschan_t *es; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct esschan *es; if (substream->runtime->private_data == NULL) return 0; @@ -1682,10 +1678,10 @@ static int snd_es1968_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_es1968_capture_close(snd_pcm_substream_t * substream) +static int snd_es1968_capture_close(struct snd_pcm_substream *substream) { - es1968_t *chip = snd_pcm_substream_chip(substream); - esschan_t *es; + struct es1968 *chip = snd_pcm_substream_chip(substream); + struct esschan *es; if (substream->runtime->private_data == NULL) return 0; @@ -1701,7 +1697,7 @@ static int snd_es1968_capture_close(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_ops_t snd_es1968_playback_ops = { +static struct snd_pcm_ops snd_es1968_playback_ops = { .open = snd_es1968_playback_open, .close = snd_es1968_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1712,7 +1708,7 @@ static snd_pcm_ops_t snd_es1968_playback_ops = { .pointer = snd_es1968_pcm_pointer, }; -static snd_pcm_ops_t snd_es1968_capture_ops = { +static struct snd_pcm_ops snd_es1968_capture_ops = { .open = snd_es1968_capture_open, .close = snd_es1968_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1729,11 +1725,11 @@ static snd_pcm_ops_t snd_es1968_capture_ops = { */ #define CLOCK_MEASURE_BUFSIZE 16768 /* enough large for a single shot */ -static void __devinit es1968_measure_clock(es1968_t *chip) +static void __devinit es1968_measure_clock(struct es1968 *chip) { int i, apu; unsigned int pa, offset, t; - esm_memory_t *memory; + struct esm_memory *memory; struct timeval start_time, stop_time; if (chip->clock == 0) @@ -1824,17 +1820,17 @@ static void __devinit es1968_measure_clock(es1968_t *chip) /* */ -static void snd_es1968_pcm_free(snd_pcm_t *pcm) +static void snd_es1968_pcm_free(struct snd_pcm *pcm) { - es1968_t *esm = pcm->private_data; + struct es1968 *esm = pcm->private_data; snd_es1968_free_dmabuf(esm); esm->pcm = NULL; } static int __devinit -snd_es1968_pcm(es1968_t *chip, int device) +snd_es1968_pcm(struct es1968 *chip, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; /* get DMA buffer */ @@ -1870,11 +1866,11 @@ snd_es1968_pcm(es1968_t *chip, int device) /* * update pointer */ -static void snd_es1968_update_pcm(es1968_t *chip, esschan_t *es) +static void snd_es1968_update_pcm(struct es1968 *chip, struct esschan *es) { unsigned int hwptr; unsigned int diff; - snd_pcm_substream_t *subs = es->substream; + struct snd_pcm_substream *subs = es->substream; if (subs == NULL || !es->running) return; @@ -1899,7 +1895,7 @@ static void snd_es1968_update_pcm(es1968_t *chip, esschan_t *es) */ static void es1968_update_hw_volume(unsigned long private_data) { - es1968_t *chip = (es1968_t *) private_data; + struct es1968 *chip = (struct es1968 *) private_data; int x, val; unsigned long flags; @@ -1959,7 +1955,7 @@ static void es1968_update_hw_volume(unsigned long private_data) */ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - es1968_t *chip = dev_id; + struct es1968 *chip = dev_id; u32 event; if (!(event = inb(chip->io_port + 0x1A))) @@ -1981,7 +1977,7 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id, struct pt_regs *r struct list_head *p; spin_lock(&chip->substream_lock); list_for_each(p, &chip->substream_list) { - esschan_t *es = list_entry(p, esschan_t, list); + struct esschan *es = list_entry(p, struct esschan, list); if (es->running) snd_es1968_update_pcm(chip, es); } @@ -2002,13 +1998,13 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id, struct pt_regs *r */ static int __devinit -snd_es1968_mixer(es1968_t *chip) +snd_es1968_mixer(struct es1968 *chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; - snd_ctl_elem_id_t id; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; + struct snd_ctl_elem_id id; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_es1968_ac97_write, .read = snd_es1968_ac97_read, }; @@ -2039,7 +2035,7 @@ snd_es1968_mixer(es1968_t *chip) * reset ac97 codec */ -static void snd_es1968_ac97_reset(es1968_t *chip) +static void snd_es1968_ac97_reset(struct es1968 *chip) { unsigned long ioaddr = chip->io_port; @@ -2144,7 +2140,7 @@ static void snd_es1968_ac97_reset(es1968_t *chip) outb(0x3f, ioaddr+0xd0); } -static void snd_es1968_reset(es1968_t *chip) +static void snd_es1968_reset(struct es1968 *chip) { /* Reset */ outw(ESM_RESET_MAESTRO | ESM_RESET_DIRECTSOUND, @@ -2157,7 +2153,7 @@ static void snd_es1968_reset(es1968_t *chip) /* * power management */ -static void snd_es1968_set_acpi(es1968_t *chip, int state) +static void snd_es1968_set_acpi(struct es1968 *chip, int state) { u16 active_mask = acpi_state_mask[state]; @@ -2172,7 +2168,7 @@ static void snd_es1968_set_acpi(es1968_t *chip, int state) /* * initialize maestro chip */ -static void snd_es1968_chip_init(es1968_t *chip) +static void snd_es1968_chip_init(struct es1968 *chip) { struct pci_dev *pci = chip->pci; int i; @@ -2369,7 +2365,7 @@ static void snd_es1968_chip_init(es1968_t *chip) } /* Enable IRQ's */ -static void snd_es1968_start_irq(es1968_t *chip) +static void snd_es1968_start_irq(struct es1968 *chip) { unsigned short w; w = ESM_HIRQ_DSIE | ESM_HIRQ_HW_VOLUME; @@ -2382,9 +2378,9 @@ static void snd_es1968_start_irq(es1968_t *chip) /* * PM support */ -static int es1968_suspend(snd_card_t *card, pm_message_t state) +static int es1968_suspend(struct snd_card *card, pm_message_t state) { - es1968_t *chip = card->pm_private_data; + struct es1968 *chip = card->pm_private_data; if (! chip->do_pm) return 0; @@ -2398,9 +2394,9 @@ static int es1968_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int es1968_resume(snd_card_t *card) +static int es1968_resume(struct snd_card *card) { - es1968_t *chip = card->pm_private_data; + struct es1968 *chip = card->pm_private_data; struct list_head *p; if (! chip->do_pm) @@ -2423,7 +2419,7 @@ static int es1968_resume(snd_card_t *card) snd_ac97_resume(chip->ac97); list_for_each(p, &chip->substream_list) { - esschan_t *es = list_entry(p, esschan_t, list); + struct esschan *es = list_entry(p, struct esschan, list); switch (es->mode) { case ESM_MODE_PLAY: snd_es1968_playback_setup(chip, es, es->substream->runtime); @@ -2445,7 +2441,7 @@ static int es1968_resume(snd_card_t *card) #ifdef SUPPORT_JOYSTICK #define JOYSTICK_ADDR 0x200 -static int __devinit snd_es1968_create_gameport(es1968_t *chip, int dev) +static int __devinit snd_es1968_create_gameport(struct es1968 *chip, int dev) { struct gameport *gp; struct resource *r; @@ -2479,7 +2475,7 @@ static int __devinit snd_es1968_create_gameport(es1968_t *chip, int dev) return 0; } -static void snd_es1968_free_gameport(es1968_t *chip) +static void snd_es1968_free_gameport(struct es1968 *chip) { if (chip->gameport) { struct resource *r = gameport_get_port_data(chip->gameport); @@ -2491,11 +2487,11 @@ static void snd_es1968_free_gameport(es1968_t *chip) } } #else -static inline int snd_es1968_create_gameport(es1968_t *chip, int dev) { return -ENOSYS; } -static inline void snd_es1968_free_gameport(es1968_t *chip) { } +static inline int snd_es1968_create_gameport(struct es1968 *chip, int dev) { return -ENOSYS; } +static inline void snd_es1968_free_gameport(struct es1968 *chip) { } #endif -static int snd_es1968_free(es1968_t *chip) +static int snd_es1968_free(struct es1968 *chip) { if (chip->io_port) { synchronize_irq(chip->irq); @@ -2515,9 +2511,9 @@ static int snd_es1968_free(es1968_t *chip) return 0; } -static int snd_es1968_dev_free(snd_device_t *device) +static int snd_es1968_dev_free(struct snd_device *device) { - es1968_t *chip = device->device_data; + struct es1968 *chip = device->device_data; return snd_es1968_free(chip); } @@ -2539,19 +2535,19 @@ static struct ess_device_list mpu_blacklist[] __devinitdata = { { TYPE_MAESTRO2, 0x125d }, }; -static int __devinit snd_es1968_create(snd_card_t * card, +static int __devinit snd_es1968_create(struct snd_card *card, struct pci_dev *pci, int total_bufsize, int play_streams, int capt_streams, int chip_type, int do_pm, - es1968_t **chip_ret) + struct es1968 **chip_ret) { - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_es1968_dev_free, }; - es1968_t *chip; + struct es1968 *chip; int i, err; *chip_ret = NULL; @@ -2657,8 +2653,8 @@ static int __devinit snd_es1968_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - es1968_t *chip; + struct snd_card *card; + struct es1968 *chip; unsigned int i; int err; -- cgit v1.1 From a5f22156e03d40f1da24a1b19a8a84c4fb3208f2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:04:28 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI FM801 Modules: FM801 driver Remove xxx_t typedefs from the PCI FM801 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/fm801.c | 229 +++++++++++++++++++++++++++++------------------------- 1 file changed, 121 insertions(+), 108 deletions(-) diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index 261061b..a57aca7 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -147,9 +147,7 @@ MODULE_PARM_DESC(tea575x_tuner, "Enable TEA575x tuner."); */ -typedef struct _snd_fm801 fm801_t; - -struct _snd_fm801 { +struct fm801 { int irq; unsigned long port; /* I/O port number */ @@ -172,24 +170,24 @@ struct _snd_fm801 { unsigned int cap_size; unsigned int cap_pos; - ac97_bus_t *ac97_bus; - ac97_t *ac97; - ac97_t *ac97_sec; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97; + struct snd_ac97 *ac97_sec; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; - snd_rawmidi_t *rmidi; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_rawmidi *rmidi; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; unsigned int p_dma_size; unsigned int c_dma_size; spinlock_t reg_lock; - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; #ifdef TEA575X_RADIO - tea575x_t tea; + struct snd_tea575x tea; #endif }; @@ -205,7 +203,7 @@ MODULE_DEVICE_TABLE(pci, snd_fm801_ids); * common I/O routines */ -static int snd_fm801_update_bits(fm801_t *chip, unsigned short reg, +static int snd_fm801_update_bits(struct fm801 *chip, unsigned short reg, unsigned short mask, unsigned short value) { int change; @@ -222,11 +220,11 @@ static int snd_fm801_update_bits(fm801_t *chip, unsigned short reg, return change; } -static void snd_fm801_codec_write(ac97_t *ac97, +static void snd_fm801_codec_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - fm801_t *chip = ac97->private_data; + struct fm801 *chip = ac97->private_data; int idx; /* @@ -255,9 +253,9 @@ static void snd_fm801_codec_write(ac97_t *ac97, snd_printk(KERN_ERR "AC'97 interface #%d is busy (2)\n", ac97->num); } -static unsigned short snd_fm801_codec_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - fm801_t *chip = ac97->private_data; + struct fm801 *chip = ac97->private_data; int idx; /* @@ -301,7 +299,7 @@ static unsigned int rates[] = { 38400, 44100, 48000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, @@ -313,7 +311,7 @@ static unsigned int channels[] = { #define CHANNELS sizeof(channels) / sizeof(channels[0]) -static snd_pcm_hw_constraint_list_t hw_constraints_channels = { +static struct snd_pcm_hw_constraint_list hw_constraints_channels = { .count = CHANNELS, .list = channels, .mask = 0, @@ -338,10 +336,10 @@ static unsigned short snd_fm801_rate_bits(unsigned int rate) * PCM part */ -static int snd_fm801_playback_trigger(snd_pcm_substream_t * substream, +static int snd_fm801_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - fm801_t *chip = snd_pcm_substream_chip(substream); + struct fm801 *chip = snd_pcm_substream_chip(substream); spin_lock(&chip->reg_lock); switch (cmd) { @@ -371,10 +369,10 @@ static int snd_fm801_playback_trigger(snd_pcm_substream_t * substream, return 0; } -static int snd_fm801_capture_trigger(snd_pcm_substream_t * substream, +static int snd_fm801_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - fm801_t *chip = snd_pcm_substream_chip(substream); + struct fm801 *chip = snd_pcm_substream_chip(substream); spin_lock(&chip->reg_lock); switch (cmd) { @@ -404,21 +402,21 @@ static int snd_fm801_capture_trigger(snd_pcm_substream_t * substream, return 0; } -static int snd_fm801_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_fm801_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_fm801_hw_free(snd_pcm_substream_t * substream) +static int snd_fm801_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_fm801_playback_prepare(snd_pcm_substream_t * substream) +static int snd_fm801_playback_prepare(struct snd_pcm_substream *substream) { - fm801_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct fm801 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; chip->ply_size = snd_pcm_lib_buffer_bytes(substream); chip->ply_count = snd_pcm_lib_period_bytes(substream); @@ -447,10 +445,10 @@ static int snd_fm801_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_fm801_capture_prepare(snd_pcm_substream_t * substream) +static int snd_fm801_capture_prepare(struct snd_pcm_substream *substream) { - fm801_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct fm801 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; chip->cap_size = snd_pcm_lib_buffer_bytes(substream); chip->cap_count = snd_pcm_lib_period_bytes(substream); @@ -473,9 +471,9 @@ static int snd_fm801_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_fm801_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_fm801_playback_pointer(struct snd_pcm_substream *substream) { - fm801_t *chip = snd_pcm_substream_chip(substream); + struct fm801 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->ply_ctrl & FM801_START)) @@ -490,9 +488,9 @@ static snd_pcm_uframes_t snd_fm801_playback_pointer(snd_pcm_substream_t * substr return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_fm801_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_fm801_capture_pointer(struct snd_pcm_substream *substream) { - fm801_t *chip = snd_pcm_substream_chip(substream); + struct fm801 *chip = snd_pcm_substream_chip(substream); size_t ptr; if (!(chip->cap_ctrl & FM801_START)) @@ -509,7 +507,7 @@ static snd_pcm_uframes_t snd_fm801_capture_pointer(snd_pcm_substream_t * substre static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - fm801_t *chip = dev_id; + struct fm801 *chip = dev_id; unsigned short status; unsigned int tmp; @@ -555,7 +553,7 @@ static irqreturn_t snd_fm801_interrupt(int irq, void *dev_id, struct pt_regs *re return IRQ_HANDLED; } -static snd_pcm_hardware_t snd_fm801_playback = +static struct snd_pcm_hardware snd_fm801_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -575,7 +573,7 @@ static snd_pcm_hardware_t snd_fm801_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_fm801_capture = +static struct snd_pcm_hardware snd_fm801_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -595,55 +593,59 @@ static snd_pcm_hardware_t snd_fm801_capture = .fifo_size = 0, }; -static int snd_fm801_playback_open(snd_pcm_substream_t * substream) +static int snd_fm801_playback_open(struct snd_pcm_substream *substream) { - fm801_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct fm801 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; chip->playback_substream = substream; runtime->hw = snd_fm801_playback; - snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &hw_constraints_rates); if (chip->multichannel) { runtime->hw.channels_max = 6; - snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + &hw_constraints_channels); } if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; return 0; } -static int snd_fm801_capture_open(snd_pcm_substream_t * substream) +static int snd_fm801_capture_open(struct snd_pcm_substream *substream) { - fm801_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct fm801 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; chip->capture_substream = substream; runtime->hw = snd_fm801_capture; - snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &hw_constraints_rates); if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; return 0; } -static int snd_fm801_playback_close(snd_pcm_substream_t * substream) +static int snd_fm801_playback_close(struct snd_pcm_substream *substream) { - fm801_t *chip = snd_pcm_substream_chip(substream); + struct fm801 *chip = snd_pcm_substream_chip(substream); chip->playback_substream = NULL; return 0; } -static int snd_fm801_capture_close(snd_pcm_substream_t * substream) +static int snd_fm801_capture_close(struct snd_pcm_substream *substream) { - fm801_t *chip = snd_pcm_substream_chip(substream); + struct fm801 *chip = snd_pcm_substream_chip(substream); chip->capture_substream = NULL; return 0; } -static snd_pcm_ops_t snd_fm801_playback_ops = { +static struct snd_pcm_ops snd_fm801_playback_ops = { .open = snd_fm801_playback_open, .close = snd_fm801_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -654,7 +656,7 @@ static snd_pcm_ops_t snd_fm801_playback_ops = { .pointer = snd_fm801_playback_pointer, }; -static snd_pcm_ops_t snd_fm801_capture_ops = { +static struct snd_pcm_ops snd_fm801_capture_ops = { .open = snd_fm801_capture_open, .close = snd_fm801_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -665,9 +667,9 @@ static snd_pcm_ops_t snd_fm801_capture_ops = { .pointer = snd_fm801_capture_pointer, }; -static int __devinit snd_fm801_pcm(fm801_t *chip, int device, snd_pcm_t ** rpcm) +static int __devinit snd_fm801_pcm(struct fm801 *chip, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if (rpcm) @@ -703,9 +705,9 @@ static int __devinit snd_fm801_pcm(fm801_t *chip, int device, snd_pcm_t ** rpcm) #define TEA_256PCS_WRITE_ENABLE 2 /* inverted */ #define TEA_256PCS_BUS_CLOCK 3 -static void snd_fm801_tea575x_256pcs_write(tea575x_t *tea, unsigned int val) +static void snd_fm801_tea575x_256pcs_write(struct snd_tea575x *tea, unsigned int val) { - fm801_t *chip = tea->private_data; + struct fm801 *chip = tea->private_data; unsigned short reg; int i = 25; @@ -747,9 +749,9 @@ static void snd_fm801_tea575x_256pcs_write(tea575x_t *tea, unsigned int val) spin_unlock_irq(&chip->reg_lock); } -static unsigned int snd_fm801_tea575x_256pcs_read(tea575x_t *tea) +static unsigned int snd_fm801_tea575x_256pcs_read(struct snd_tea575x *tea) { - fm801_t *chip = tea->private_data; + struct fm801 *chip = tea->private_data; unsigned short reg; unsigned int val = 0; int i; @@ -791,9 +793,9 @@ static unsigned int snd_fm801_tea575x_256pcs_read(tea575x_t *tea) #define TEA_256PCPR_DATA 1 #define TEA_256PCPR_WRITE_ENABLE 2 /* inverted */ -static void snd_fm801_tea575x_256pcpr_write(tea575x_t *tea, unsigned int val) +static void snd_fm801_tea575x_256pcpr_write(struct snd_tea575x *tea, unsigned int val) { - fm801_t *chip = tea->private_data; + struct fm801 *chip = tea->private_data; unsigned short reg; int i = 25; @@ -835,9 +837,9 @@ static void snd_fm801_tea575x_256pcpr_write(tea575x_t *tea, unsigned int val) spin_unlock_irq(&chip->reg_lock); } -static unsigned int snd_fm801_tea575x_256pcpr_read(tea575x_t *tea) +static unsigned int snd_fm801_tea575x_256pcpr_read(struct snd_tea575x *tea) { - fm801_t *chip = tea->private_data; + struct fm801 *chip = tea->private_data; unsigned short reg; unsigned int val = 0; int i; @@ -879,9 +881,9 @@ static unsigned int snd_fm801_tea575x_256pcpr_read(tea575x_t *tea) #define TEA_64PCR_WRITE_ENABLE 1 /* inverted */ #define TEA_64PCR_DATA 2 -static void snd_fm801_tea575x_64pcr_write(tea575x_t *tea, unsigned int val) +static void snd_fm801_tea575x_64pcr_write(struct snd_tea575x *tea, unsigned int val) { - fm801_t *chip = tea->private_data; + struct fm801 *chip = tea->private_data; unsigned short reg; int i = 25; @@ -923,9 +925,9 @@ static void snd_fm801_tea575x_64pcr_write(tea575x_t *tea, unsigned int val) spin_unlock_irq(&chip->reg_lock); } -static unsigned int snd_fm801_tea575x_64pcr_read(tea575x_t *tea) +static unsigned int snd_fm801_tea575x_64pcr_read(struct snd_tea575x *tea) { - fm801_t *chip = tea->private_data; + struct fm801 *chip = tea->private_data; unsigned short reg; unsigned int val = 0; int i; @@ -990,7 +992,8 @@ static struct snd_tea575x_ops snd_fm801_tea_ops[3] = { .get = snd_fm801_get_single, .put = snd_fm801_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_fm801_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_fm801_info_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1001,9 +1004,10 @@ static int snd_fm801_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_fm801_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_fm801_get_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - fm801_t *chip = snd_kcontrol_chip(kcontrol); + struct fm801 *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1015,9 +1019,10 @@ static int snd_fm801_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_fm801_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_fm801_put_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - fm801_t *chip = snd_kcontrol_chip(kcontrol); + struct fm801 *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1035,7 +1040,8 @@ static int snd_fm801_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t .get = snd_fm801_get_double, .put = snd_fm801_put_double, \ .private_value = reg | (shift_left << 8) | (shift_right << 12) | (mask << 16) | (invert << 24) } -static int snd_fm801_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_fm801_info_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1046,9 +1052,10 @@ static int snd_fm801_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } -static int snd_fm801_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_fm801_get_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - fm801_t *chip = snd_kcontrol_chip(kcontrol); + struct fm801 *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift_left = (kcontrol->private_value >> 8) & 0x0f; int shift_right = (kcontrol->private_value >> 12) & 0x0f; @@ -1066,9 +1073,10 @@ static int snd_fm801_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_fm801_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_fm801_put_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - fm801_t *chip = snd_kcontrol_chip(kcontrol); + struct fm801 *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift_left = (kcontrol->private_value >> 8) & 0x0f; int shift_right = (kcontrol->private_value >> 12) & 0x0f; @@ -1087,7 +1095,8 @@ static int snd_fm801_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t (val1 << shift_left ) | (val2 << shift_right)); } -static int snd_fm801_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_fm801_info_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[5] = { "AC97 Primary", "FM", "I2S", "PCM", "AC97 Secondary" @@ -1102,9 +1111,10 @@ static int snd_fm801_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * ui return 0; } -static int snd_fm801_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_fm801_get_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - fm801_t *chip = snd_kcontrol_chip(kcontrol); + struct fm801 *chip = snd_kcontrol_chip(kcontrol); unsigned short val; val = inw(FM801_REG(chip, REC_SRC)) & 7; @@ -1114,9 +1124,10 @@ static int snd_fm801_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u return 0; } -static int snd_fm801_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_fm801_put_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - fm801_t *chip = snd_kcontrol_chip(kcontrol); + struct fm801 *chip = snd_kcontrol_chip(kcontrol); unsigned short val; if ((val = ucontrol->value.enumerated.item[0]) > 4) @@ -1124,9 +1135,9 @@ static int snd_fm801_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * u return snd_fm801_update_bits(chip, FM801_REC_SRC, 7, val); } -#define FM801_CONTROLS (sizeof(snd_fm801_controls)/sizeof(snd_kcontrol_new_t)) +#define FM801_CONTROLS ARRAY_SIZE(snd_fm801_controls) -static snd_kcontrol_new_t snd_fm801_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_fm801_controls[] __devinitdata = { FM801_DOUBLE("Wave Playback Volume", FM801_PCM_VOL, 0, 8, 31, 1), FM801_SINGLE("Wave Playback Switch", FM801_PCM_VOL, 15, 1, 1), FM801_DOUBLE("I2S Playback Volume", FM801_I2S_VOL, 0, 8, 31, 1), @@ -1142,9 +1153,9 @@ FM801_SINGLE("FM Playback Switch", FM801_FM_VOL, 15, 1, 1), } }; -#define FM801_CONTROLS_MULTI (sizeof(snd_fm801_controls_multi)/sizeof(snd_kcontrol_new_t)) +#define FM801_CONTROLS_MULTI ARRAY_SIZE(snd_fm801_controls_multi) -static snd_kcontrol_new_t snd_fm801_controls_multi[] __devinitdata = { +static struct snd_kcontrol_new snd_fm801_controls_multi[] __devinitdata = { FM801_SINGLE("AC97 2ch->4ch Copy Switch", FM801_CODEC_CTRL, 7, 1, 0), FM801_SINGLE("AC97 18-bit Switch", FM801_CODEC_CTRL, 10, 1, 0), FM801_SINGLE(SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), FM801_I2S_MODE, 8, 1, 0), @@ -1153,15 +1164,15 @@ FM801_SINGLE(SNDRV_CTL_NAME_IEC958("Raw Data ",CAPTURE,SWITCH), FM801_I2S_MODE, FM801_SINGLE(SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), FM801_GEN_CTRL, 2, 1, 0), }; -static void snd_fm801_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_fm801_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - fm801_t *chip = bus->private_data; + struct fm801 *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_fm801_mixer_free_ac97(ac97_t *ac97) +static void snd_fm801_mixer_free_ac97(struct snd_ac97 *ac97) { - fm801_t *chip = ac97->private_data; + struct fm801 *chip = ac97->private_data; if (ac97->num == 0) { chip->ac97 = NULL; } else { @@ -1169,12 +1180,12 @@ static void snd_fm801_mixer_free_ac97(ac97_t *ac97) } } -static int __devinit snd_fm801_mixer(fm801_t *chip) +static int __devinit snd_fm801_mixer(struct fm801 *chip) { - ac97_template_t ac97; + struct snd_ac97_template ac97; unsigned int i; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_fm801_codec_write, .read = snd_fm801_codec_read, }; @@ -1207,7 +1218,7 @@ static int __devinit snd_fm801_mixer(fm801_t *chip) * initialization routines */ -static int snd_fm801_free(fm801_t *chip) +static int snd_fm801_free(struct fm801 *chip) { unsigned short cmdw; @@ -1224,7 +1235,7 @@ static int snd_fm801_free(fm801_t *chip) snd_tea575x_exit(&chip->tea); #endif if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); pci_release_regions(chip->pci); pci_disable_device(chip->pci); @@ -1232,23 +1243,23 @@ static int snd_fm801_free(fm801_t *chip) return 0; } -static int snd_fm801_dev_free(snd_device_t *device) +static int snd_fm801_dev_free(struct snd_device *device) { - fm801_t *chip = device->device_data; + struct fm801 *chip = device->device_data; return snd_fm801_free(chip); } -static int __devinit snd_fm801_create(snd_card_t * card, +static int __devinit snd_fm801_create(struct snd_card *card, struct pci_dev * pci, int tea575x_tuner, - fm801_t ** rchip) + struct fm801 ** rchip) { - fm801_t *chip; + struct fm801 *chip; unsigned char rev, id; unsigned short cmdw; unsigned long timeout; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_fm801_dev_free, }; @@ -1270,7 +1281,8 @@ static int __devinit snd_fm801_create(snd_card_t * card, return err; } chip->port = pci_resource_start(pci, 0); - if (request_irq(pci->irq, snd_fm801_interrupt, SA_INTERRUPT|SA_SHIRQ, "FM801", (void *)chip)) { + if (request_irq(pci->irq, snd_fm801_interrupt, SA_INTERRUPT|SA_SHIRQ, + "FM801", chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", chip->irq); snd_fm801_free(chip); return -EBUSY; @@ -1309,7 +1321,8 @@ static int __devinit snd_fm801_create(snd_card_t * card, timeout = jiffies + HZ / 20; - outw((1<<7) | (id << FM801_AC97_ADDR_SHIFT) | AC97_VENDOR_ID1, FM801_REG(chip, AC97_CMD)); + outw((1<<7) | (id << FM801_AC97_ADDR_SHIFT) | AC97_VENDOR_ID1, + FM801_REG(chip, AC97_CMD)); udelay(5); do { if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8)) { @@ -1383,9 +1396,9 @@ static int __devinit snd_card_fm801_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - fm801_t *chip; - opl3_t *opl3; + struct snd_card *card; + struct fm801 *chip; + struct snd_opl3 *opl3; int err; if (dev >= SNDRV_CARDS) -- cgit v1.1 From 6b75a9d8b6c794d4c41d1b875c3e8e920b09e151 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:04:53 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI Intel8x0 Modules: Intel8x0 driver,Intel8x0-modem driver Remove xxx_t typedefs from the PCI Intel8x0 and modem drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/intel8x0.c | 428 ++++++++++++++++++++++++++++---------------------- sound/pci/intel8x0m.c | 228 ++++++++++++++------------- 2 files changed, 362 insertions(+), 294 deletions(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index af2b143..3ea90f1 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -272,7 +272,8 @@ enum { #define ALI_INT_CPRAIS (1<<7) /* command port available */ #define ALI_INT_SPRAIS (1<<5) /* status port available */ #define ALI_INT_GPIO (1<<1) -#define ALI_INT_MASK (ALI_INT_SPDIFOUT|ALI_INT_CODECSPDIFOUT|ALI_INT_MICIN|ALI_INT_PCMOUT|ALI_INT_PCMIN) +#define ALI_INT_MASK (ALI_INT_SPDIFOUT|ALI_INT_CODECSPDIFOUT|\ + ALI_INT_MICIN|ALI_INT_PCMOUT|ALI_INT_PCMIN) #define ICH_ALI_SC_RESET (1<<31) /* master reset */ #define ICH_ALI_SC_AC97_DBL (1<<30) @@ -303,18 +304,40 @@ enum { * */ -enum { ICHD_PCMIN, ICHD_PCMOUT, ICHD_MIC, ICHD_MIC2, ICHD_PCM2IN, ICHD_SPBAR, ICHD_LAST = ICHD_SPBAR }; -enum { NVD_PCMIN, NVD_PCMOUT, NVD_MIC, NVD_SPBAR, NVD_LAST = NVD_SPBAR }; -enum { ALID_PCMIN, ALID_PCMOUT, ALID_MIC, ALID_AC97SPDIFOUT, ALID_SPDIFIN, ALID_SPDIFOUT, ALID_LAST = ALID_SPDIFOUT }; +enum { + ICHD_PCMIN, + ICHD_PCMOUT, + ICHD_MIC, + ICHD_MIC2, + ICHD_PCM2IN, + ICHD_SPBAR, + ICHD_LAST = ICHD_SPBAR +}; +enum { + NVD_PCMIN, + NVD_PCMOUT, + NVD_MIC, + NVD_SPBAR, + NVD_LAST = NVD_SPBAR +}; +enum { + ALID_PCMIN, + ALID_PCMOUT, + ALID_MIC, + ALID_AC97SPDIFOUT, + ALID_SPDIFIN, + ALID_SPDIFOUT, + ALID_LAST = ALID_SPDIFOUT +}; -#define get_ichdev(substream) (ichdev_t *)(substream->runtime->private_data) +#define get_ichdev(substream) (substream->runtime->private_data) -typedef struct { +struct ichdev { unsigned int ichd; /* ich device number */ unsigned long reg_offset; /* offset to bmaddr */ u32 *bdbar; /* CPU address (32bit) */ unsigned int bdbar_addr; /* PCI bus address (32bit) */ - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; unsigned int physbuf; /* physical address (32bit) */ unsigned int size; unsigned int fragsize; @@ -336,11 +359,9 @@ typedef struct { int pcm_open_flag; unsigned int page_attr_changed: 1; unsigned int suspended: 1; -} ichdev_t; - -typedef struct _snd_intel8x0 intel8x0_t; +}; -struct _snd_intel8x0 { +struct intel8x0 { unsigned int device_type; int irq; @@ -353,11 +374,11 @@ struct _snd_intel8x0 { void __iomem *remap_bmaddr; struct pci_dev *pci; - snd_card_t *card; + struct snd_card *card; int pcm_devs; - snd_pcm_t *pcm[6]; - ichdev_t ichd[6]; + struct snd_pcm *pcm[6]; + struct ichdev ichd[6]; unsigned multi4: 1, multi6: 1, @@ -374,8 +395,8 @@ struct _snd_intel8x0 { int spdif_idx; /* SPDIF BAR index; *_SPBAR or -1 if use PCMOUT */ unsigned int sdm_saved; /* SDM reg value */ - ac97_bus_t *ac97_bus; - ac97_t *ac97[3]; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97[3]; unsigned int ac97_sdin[3]; spinlock_t reg_lock; @@ -418,7 +439,7 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0_ids); * Lowlevel I/O - busmaster */ -static u8 igetbyte(intel8x0_t *chip, u32 offset) +static u8 igetbyte(struct intel8x0 *chip, u32 offset) { if (chip->bm_mmio) return readb(chip->remap_bmaddr + offset); @@ -426,7 +447,7 @@ static u8 igetbyte(intel8x0_t *chip, u32 offset) return inb(chip->bmaddr + offset); } -static u16 igetword(intel8x0_t *chip, u32 offset) +static u16 igetword(struct intel8x0 *chip, u32 offset) { if (chip->bm_mmio) return readw(chip->remap_bmaddr + offset); @@ -434,7 +455,7 @@ static u16 igetword(intel8x0_t *chip, u32 offset) return inw(chip->bmaddr + offset); } -static u32 igetdword(intel8x0_t *chip, u32 offset) +static u32 igetdword(struct intel8x0 *chip, u32 offset) { if (chip->bm_mmio) return readl(chip->remap_bmaddr + offset); @@ -442,7 +463,7 @@ static u32 igetdword(intel8x0_t *chip, u32 offset) return inl(chip->bmaddr + offset); } -static void iputbyte(intel8x0_t *chip, u32 offset, u8 val) +static void iputbyte(struct intel8x0 *chip, u32 offset, u8 val) { if (chip->bm_mmio) writeb(val, chip->remap_bmaddr + offset); @@ -450,7 +471,7 @@ static void iputbyte(intel8x0_t *chip, u32 offset, u8 val) outb(val, chip->bmaddr + offset); } -static void iputword(intel8x0_t *chip, u32 offset, u16 val) +static void iputword(struct intel8x0 *chip, u32 offset, u16 val) { if (chip->bm_mmio) writew(val, chip->remap_bmaddr + offset); @@ -458,7 +479,7 @@ static void iputword(intel8x0_t *chip, u32 offset, u16 val) outw(val, chip->bmaddr + offset); } -static void iputdword(intel8x0_t *chip, u32 offset, u32 val) +static void iputdword(struct intel8x0 *chip, u32 offset, u32 val) { if (chip->bm_mmio) writel(val, chip->remap_bmaddr + offset); @@ -470,7 +491,7 @@ static void iputdword(intel8x0_t *chip, u32 offset, u32 val) * Lowlevel I/O - AC'97 registers */ -static u16 iagetword(intel8x0_t *chip, u32 offset) +static u16 iagetword(struct intel8x0 *chip, u32 offset) { if (chip->mmio) return readw(chip->remap_addr + offset); @@ -478,7 +499,7 @@ static u16 iagetword(intel8x0_t *chip, u32 offset) return inw(chip->addr + offset); } -static void iaputword(intel8x0_t *chip, u32 offset, u16 val) +static void iaputword(struct intel8x0 *chip, u32 offset, u16 val) { if (chip->mmio) writew(val, chip->remap_addr + offset); @@ -495,7 +516,7 @@ static void iaputword(intel8x0_t *chip, u32 offset, u16 val) */ /* return the GLOB_STA bit for the corresponding codec */ -static unsigned int get_ich_codec_bit(intel8x0_t *chip, unsigned int codec) +static unsigned int get_ich_codec_bit(struct intel8x0 *chip, unsigned int codec) { static unsigned int codec_bit[3] = { ICH_PCR, ICH_SCR, ICH_TCR @@ -506,7 +527,7 @@ static unsigned int get_ich_codec_bit(intel8x0_t *chip, unsigned int codec) return codec_bit[codec]; } -static int snd_intel8x0_codec_semaphore(intel8x0_t *chip, unsigned int codec) +static int snd_intel8x0_codec_semaphore(struct intel8x0 *chip, unsigned int codec) { int time; @@ -545,11 +566,11 @@ static int snd_intel8x0_codec_semaphore(intel8x0_t *chip, unsigned int codec) return -EBUSY; } -static void snd_intel8x0_codec_write(ac97_t *ac97, +static void snd_intel8x0_codec_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - intel8x0_t *chip = ac97->private_data; + struct intel8x0 *chip = ac97->private_data; if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { if (! chip->in_ac97_init) @@ -558,10 +579,10 @@ static void snd_intel8x0_codec_write(ac97_t *ac97, iaputword(chip, reg + ac97->num * 0x80, val); } -static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, +static unsigned short snd_intel8x0_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - intel8x0_t *chip = ac97->private_data; + struct intel8x0 *chip = ac97->private_data; unsigned short res; unsigned int tmp; @@ -573,7 +594,8 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, res = iagetword(chip, reg + ac97->num * 0x80); if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) { /* reset RCS and preserve other R/WC bits */ - iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI)); + iputdword(chip, ICHREG(GLOB_STA), tmp & + ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI)); if (! chip->in_ac97_init) snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg); res = 0xffff; @@ -582,7 +604,7 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, return res; } -static void snd_intel8x0_codec_read_test(intel8x0_t *chip, unsigned int codec) +static void snd_intel8x0_codec_read_test(struct intel8x0 *chip, unsigned int codec) { unsigned int tmp; @@ -590,7 +612,8 @@ static void snd_intel8x0_codec_read_test(intel8x0_t *chip, unsigned int codec) iagetword(chip, codec * 0x80); if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) { /* reset RCS and preserve other R/WC bits */ - iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI)); + iputdword(chip, ICHREG(GLOB_STA), tmp & + ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI)); } } } @@ -598,7 +621,7 @@ static void snd_intel8x0_codec_read_test(intel8x0_t *chip, unsigned int codec) /* * access to AC97 for Ali5455 */ -static int snd_intel8x0_ali_codec_ready(intel8x0_t *chip, int mask) +static int snd_intel8x0_ali_codec_ready(struct intel8x0 *chip, int mask) { int count = 0; for (count = 0; count < 0x7f; count++) { @@ -611,7 +634,7 @@ static int snd_intel8x0_ali_codec_ready(intel8x0_t *chip, int mask) return -EBUSY; } -static int snd_intel8x0_ali_codec_semaphore(intel8x0_t *chip) +static int snd_intel8x0_ali_codec_semaphore(struct intel8x0 *chip) { int time = 100; if (chip->buggy_semaphore) @@ -623,9 +646,9 @@ static int snd_intel8x0_ali_codec_semaphore(intel8x0_t *chip) return snd_intel8x0_ali_codec_ready(chip, ALI_CSPSR_CODEC_READY); } -static unsigned short snd_intel8x0_ali_codec_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_intel8x0_ali_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - intel8x0_t *chip = ac97->private_data; + struct intel8x0 *chip = ac97->private_data; unsigned short data = 0xffff; if (snd_intel8x0_ali_codec_semaphore(chip)) @@ -641,9 +664,10 @@ static unsigned short snd_intel8x0_ali_codec_read(ac97_t *ac97, unsigned short r return data; } -static void snd_intel8x0_ali_codec_write(ac97_t *ac97, unsigned short reg, unsigned short val) +static void snd_intel8x0_ali_codec_write(struct snd_ac97 *ac97, unsigned short reg, + unsigned short val) { - intel8x0_t *chip = ac97->private_data; + struct intel8x0 *chip = ac97->private_data; if (snd_intel8x0_ali_codec_semaphore(chip)) return; @@ -658,7 +682,7 @@ static void snd_intel8x0_ali_codec_write(ac97_t *ac97, unsigned short reg, unsig /* * DMA I/O */ -static void snd_intel8x0_setup_periods(intel8x0_t *chip, ichdev_t *ichdev) +static void snd_intel8x0_setup_periods(struct intel8x0 *chip, struct ichdev *ichdev) { int idx; u32 *bdbar = ichdev->bdbar; @@ -681,10 +705,15 @@ static void snd_intel8x0_setup_periods(intel8x0_t *chip, ichdev_t *ichdev) ichdev->ack_reload = ichdev->ack = 1; ichdev->fragsize1 = ichdev->fragsize; for (idx = 0; idx < (ICH_REG_LVI_MASK + 1) * 2; idx += 2) { - bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + (((idx >> 1) * ichdev->fragsize) % ichdev->size)); + bdbar[idx + 0] = cpu_to_le32(ichdev->physbuf + + (((idx >> 1) * ichdev->fragsize) % + ichdev->size)); bdbar[idx + 1] = cpu_to_le32(0x80000000 | /* interrupt on completion */ ichdev->fragsize >> ichdev->pos_shift); - // printk("bdbar[%i] = 0x%x [0x%x]\n", idx + 0, bdbar[idx + 0], bdbar[idx + 1]); +#if 0 + printk("bdbar[%i] = 0x%x [0x%x]\n", + idx + 0, bdbar[idx + 0], bdbar[idx + 1]); +#endif } ichdev->frags = ichdev->size / ichdev->fragsize; } @@ -722,7 +751,7 @@ static void fill_nocache(void *buf, int size, int nocache) * Interrupt handler */ -static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev) +static inline void snd_intel8x0_update(struct intel8x0 *chip, struct ichdev *ichdev) { unsigned long port = ichdev->reg_offset; int status, civ, i, step; @@ -757,7 +786,12 @@ static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev) ichdev->lvi_frag++; ichdev->lvi_frag %= ichdev->frags; ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1); - // printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n", ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), inl(port + 4), inb(port + ICH_REG_OFF_CR)); +#if 0 + printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n", + ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], + ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), + inl(port + 4), inb(port + ICH_REG_OFF_CR)); +#endif if (--ichdev->ack == 0) { ichdev->ack = ichdev->ack_reload; ack = 1; @@ -773,8 +807,8 @@ static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev) static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - intel8x0_t *chip = dev_id; - ichdev_t *ichdev; + struct intel8x0 *chip = dev_id; + struct ichdev *ichdev; unsigned int status; unsigned int i; @@ -808,10 +842,10 @@ static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs * PCM part */ -static int snd_intel8x0_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - ichdev_t *ichdev = get_ichdev(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); + struct ichdev *ichdev = get_ichdev(substream); unsigned char val = 0; unsigned long port = ichdev->reg_offset; @@ -847,12 +881,14 @@ static int snd_intel8x0_pcm_trigger(snd_pcm_substream_t *substream, int cmd) return 0; } -static int snd_intel8x0_ali_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_intel8x0_ali_trigger(struct snd_pcm_substream *substream, int cmd) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - ichdev_t *ichdev = get_ichdev(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); + struct ichdev *ichdev = get_ichdev(substream); unsigned long port = ichdev->reg_offset; - static int fiforeg[] = { ICHREG(ALI_FIFOCR1), ICHREG(ALI_FIFOCR2), ICHREG(ALI_FIFOCR3) }; + static int fiforeg[] = { + ICHREG(ALI_FIFOCR1), ICHREG(ALI_FIFOCR2), ICHREG(ALI_FIFOCR3) + }; unsigned int val, fifo; val = igetdword(chip, ICHREG(ALI_DMACR)); @@ -871,14 +907,16 @@ static int snd_intel8x0_ali_trigger(snd_pcm_substream_t *substream, int cmd) } iputbyte(chip, port + ICH_REG_OFF_CR, ICH_IOCE); val &= ~(1 << (ichdev->ali_slot + 16)); /* clear PAUSE flag */ - iputdword(chip, ICHREG(ALI_DMACR), val | (1 << ichdev->ali_slot)); /* start DMA */ + /* start DMA */ + iputdword(chip, ICHREG(ALI_DMACR), val | (1 << ichdev->ali_slot)); break; case SNDRV_PCM_TRIGGER_SUSPEND: ichdev->suspended = 1; /* fallthru */ case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - iputdword(chip, ICHREG(ALI_DMACR), val | (1 << (ichdev->ali_slot + 16))); /* pause */ + /* pause */ + iputdword(chip, ICHREG(ALI_DMACR), val | (1 << (ichdev->ali_slot + 16))); iputbyte(chip, port + ICH_REG_OFF_CR, 0); while (igetbyte(chip, port + ICH_REG_OFF_CR)) ; @@ -887,7 +925,8 @@ static int snd_intel8x0_ali_trigger(snd_pcm_substream_t *substream, int cmd) /* reset whole DMA things */ iputbyte(chip, port + ICH_REG_OFF_CR, ICH_RESETREGS); /* clear interrupts */ - iputbyte(chip, port + ICH_REG_OFF_SR, igetbyte(chip, port + ICH_REG_OFF_SR) | 0x1e); + iputbyte(chip, port + ICH_REG_OFF_SR, + igetbyte(chip, port + ICH_REG_OFF_SR) | 0x1e); iputdword(chip, ICHREG(ALI_INTERRUPTSR), igetdword(chip, ICHREG(ALI_INTERRUPTSR)) & ichdev->int_sta_mask); break; @@ -897,12 +936,12 @@ static int snd_intel8x0_ali_trigger(snd_pcm_substream_t *substream, int cmd) return 0; } -static int snd_intel8x0_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_intel8x0_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - ichdev_t *ichdev = get_ichdev(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct intel8x0 *chip = snd_pcm_substream_chip(substream); + struct ichdev *ichdev = get_ichdev(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int dbl = params_rate(hw_params) > 48000; int err; @@ -930,15 +969,16 @@ static int snd_intel8x0_hw_params(snd_pcm_substream_t * substream, ichdev->pcm_open_flag = 1; /* Force SPDIF setting */ if (ichdev->ichd == ICHD_PCMOUT && chip->spdif_idx < 0) - snd_ac97_set_rate(ichdev->pcm->r[0].codec[0], AC97_SPDIF, params_rate(hw_params)); + snd_ac97_set_rate(ichdev->pcm->r[0].codec[0], AC97_SPDIF, + params_rate(hw_params)); } return err; } -static int snd_intel8x0_hw_free(snd_pcm_substream_t * substream) +static int snd_intel8x0_hw_free(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - ichdev_t *ichdev = get_ichdev(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); + struct ichdev *ichdev = get_ichdev(substream); if (ichdev->pcm_open_flag) { snd_ac97_pcm_close(ichdev->pcm); @@ -951,8 +991,8 @@ static int snd_intel8x0_hw_free(snd_pcm_substream_t * substream) return snd_pcm_lib_free_pages(substream); } -static void snd_intel8x0_setup_pcm_out(intel8x0_t *chip, - snd_pcm_runtime_t *runtime) +static void snd_intel8x0_setup_pcm_out(struct intel8x0 *chip, + struct snd_pcm_runtime *runtime) { unsigned int cnt; int dbl = runtime->rate > 48000; @@ -1004,11 +1044,11 @@ static void snd_intel8x0_setup_pcm_out(intel8x0_t *chip, spin_unlock_irq(&chip->reg_lock); } -static int snd_intel8x0_pcm_prepare(snd_pcm_substream_t * substream) +static int snd_intel8x0_pcm_prepare(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ichdev_t *ichdev = get_ichdev(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct ichdev *ichdev = get_ichdev(substream); ichdev->physbuf = runtime->dma_addr; ichdev->size = snd_pcm_lib_buffer_bytes(substream); @@ -1022,10 +1062,10 @@ static int snd_intel8x0_pcm_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - ichdev_t *ichdev = get_ichdev(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); + struct ichdev *ichdev = get_ichdev(substream); size_t ptr1, ptr; int civ, timeout = 100; unsigned int position; @@ -1052,7 +1092,7 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substrea return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_hardware_t snd_intel8x0_stream = +static struct snd_pcm_hardware snd_intel8x0_stream = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1077,7 +1117,7 @@ static unsigned int channels4[] = { 2, 4, }; -static snd_pcm_hw_constraint_list_t hw_constraints_channels4 = { +static struct snd_pcm_hw_constraint_list hw_constraints_channels4 = { .count = ARRAY_SIZE(channels4), .list = channels4, .mask = 0, @@ -1087,16 +1127,16 @@ static unsigned int channels6[] = { 2, 4, 6, }; -static snd_pcm_hw_constraint_list_t hw_constraints_channels6 = { +static struct snd_pcm_hw_constraint_list hw_constraints_channels6 = { .count = ARRAY_SIZE(channels6), .list = channels6, .mask = 0, }; -static int snd_intel8x0_pcm_open(snd_pcm_substream_t * substream, ichdev_t *ichdev) +static int snd_intel8x0_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct intel8x0 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; ichdev->substream = substream; @@ -1113,10 +1153,10 @@ static int snd_intel8x0_pcm_open(snd_pcm_substream_t * substream, ichdev_t *ichd return 0; } -static int snd_intel8x0_playback_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_playback_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct intel8x0 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; err = snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMOUT]); @@ -1125,10 +1165,12 @@ static int snd_intel8x0_playback_open(snd_pcm_substream_t * substream) if (chip->multi6) { runtime->hw.channels_max = 6; - snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels6); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &hw_constraints_channels6); } else if (chip->multi4) { runtime->hw.channels_max = 4; - snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels4); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &hw_constraints_channels4); } if (chip->dra) { snd_ac97_pcm_double_rate_rules(runtime); @@ -1140,94 +1182,94 @@ static int snd_intel8x0_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_intel8x0_playback_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_playback_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); chip->ichd[ICHD_PCMOUT].substream = NULL; return 0; } -static int snd_intel8x0_capture_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_capture_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCMIN]); } -static int snd_intel8x0_capture_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_capture_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); chip->ichd[ICHD_PCMIN].substream = NULL; return 0; } -static int snd_intel8x0_mic_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_mic_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_MIC]); } -static int snd_intel8x0_mic_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_mic_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); chip->ichd[ICHD_MIC].substream = NULL; return 0; } -static int snd_intel8x0_mic2_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_mic2_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_MIC2]); } -static int snd_intel8x0_mic2_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_mic2_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); chip->ichd[ICHD_MIC2].substream = NULL; return 0; } -static int snd_intel8x0_capture2_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_capture2_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); return snd_intel8x0_pcm_open(substream, &chip->ichd[ICHD_PCM2IN]); } -static int snd_intel8x0_capture2_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_capture2_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); chip->ichd[ICHD_PCM2IN].substream = NULL; return 0; } -static int snd_intel8x0_spdif_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_spdif_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); int idx = chip->device_type == DEVICE_NFORCE ? NVD_SPBAR : ICHD_SPBAR; return snd_intel8x0_pcm_open(substream, &chip->ichd[idx]); } -static int snd_intel8x0_spdif_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_spdif_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); int idx = chip->device_type == DEVICE_NFORCE ? NVD_SPBAR : ICHD_SPBAR; chip->ichd[idx].substream = NULL; return 0; } -static int snd_intel8x0_ali_ac97spdifout_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_ali_ac97spdifout_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); unsigned int val; spin_lock_irq(&chip->reg_lock); @@ -1240,9 +1282,9 @@ static int snd_intel8x0_ali_ac97spdifout_open(snd_pcm_substream_t * substream) return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_AC97SPDIFOUT]); } -static int snd_intel8x0_ali_ac97spdifout_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_ali_ac97spdifout_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); unsigned int val; chip->ichd[ALID_AC97SPDIFOUT].substream = NULL; @@ -1255,39 +1297,39 @@ static int snd_intel8x0_ali_ac97spdifout_close(snd_pcm_substream_t * substream) return 0; } -static int snd_intel8x0_ali_spdifin_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_ali_spdifin_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_SPDIFIN]); } -static int snd_intel8x0_ali_spdifin_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_ali_spdifin_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); chip->ichd[ALID_SPDIFIN].substream = NULL; return 0; } #if 0 // NYI -static int snd_intel8x0_ali_spdifout_open(snd_pcm_substream_t * substream) +static int snd_intel8x0_ali_spdifout_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); return snd_intel8x0_pcm_open(substream, &chip->ichd[ALID_SPDIFOUT]); } -static int snd_intel8x0_ali_spdifout_close(snd_pcm_substream_t * substream) +static int snd_intel8x0_ali_spdifout_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0 *chip = snd_pcm_substream_chip(substream); chip->ichd[ALID_SPDIFOUT].substream = NULL; return 0; } #endif -static snd_pcm_ops_t snd_intel8x0_playback_ops = { +static struct snd_pcm_ops snd_intel8x0_playback_ops = { .open = snd_intel8x0_playback_open, .close = snd_intel8x0_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1298,7 +1340,7 @@ static snd_pcm_ops_t snd_intel8x0_playback_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_capture_ops = { +static struct snd_pcm_ops snd_intel8x0_capture_ops = { .open = snd_intel8x0_capture_open, .close = snd_intel8x0_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1309,7 +1351,7 @@ static snd_pcm_ops_t snd_intel8x0_capture_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_capture_mic_ops = { +static struct snd_pcm_ops snd_intel8x0_capture_mic_ops = { .open = snd_intel8x0_mic_open, .close = snd_intel8x0_mic_close, .ioctl = snd_pcm_lib_ioctl, @@ -1320,7 +1362,7 @@ static snd_pcm_ops_t snd_intel8x0_capture_mic_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_capture_mic2_ops = { +static struct snd_pcm_ops snd_intel8x0_capture_mic2_ops = { .open = snd_intel8x0_mic2_open, .close = snd_intel8x0_mic2_close, .ioctl = snd_pcm_lib_ioctl, @@ -1331,7 +1373,7 @@ static snd_pcm_ops_t snd_intel8x0_capture_mic2_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_capture2_ops = { +static struct snd_pcm_ops snd_intel8x0_capture2_ops = { .open = snd_intel8x0_capture2_open, .close = snd_intel8x0_capture2_close, .ioctl = snd_pcm_lib_ioctl, @@ -1342,7 +1384,7 @@ static snd_pcm_ops_t snd_intel8x0_capture2_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_spdif_ops = { +static struct snd_pcm_ops snd_intel8x0_spdif_ops = { .open = snd_intel8x0_spdif_open, .close = snd_intel8x0_spdif_close, .ioctl = snd_pcm_lib_ioctl, @@ -1353,7 +1395,7 @@ static snd_pcm_ops_t snd_intel8x0_spdif_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_ali_playback_ops = { +static struct snd_pcm_ops snd_intel8x0_ali_playback_ops = { .open = snd_intel8x0_playback_open, .close = snd_intel8x0_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1364,7 +1406,7 @@ static snd_pcm_ops_t snd_intel8x0_ali_playback_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_ali_capture_ops = { +static struct snd_pcm_ops snd_intel8x0_ali_capture_ops = { .open = snd_intel8x0_capture_open, .close = snd_intel8x0_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1375,7 +1417,7 @@ static snd_pcm_ops_t snd_intel8x0_ali_capture_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_ali_capture_mic_ops = { +static struct snd_pcm_ops snd_intel8x0_ali_capture_mic_ops = { .open = snd_intel8x0_mic_open, .close = snd_intel8x0_mic_close, .ioctl = snd_pcm_lib_ioctl, @@ -1386,7 +1428,7 @@ static snd_pcm_ops_t snd_intel8x0_ali_capture_mic_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_ali_ac97spdifout_ops = { +static struct snd_pcm_ops snd_intel8x0_ali_ac97spdifout_ops = { .open = snd_intel8x0_ali_ac97spdifout_open, .close = snd_intel8x0_ali_ac97spdifout_close, .ioctl = snd_pcm_lib_ioctl, @@ -1397,7 +1439,7 @@ static snd_pcm_ops_t snd_intel8x0_ali_ac97spdifout_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0_ali_spdifin_ops = { +static struct snd_pcm_ops snd_intel8x0_ali_spdifin_ops = { .open = snd_intel8x0_ali_spdifin_open, .close = snd_intel8x0_ali_spdifin_close, .ioctl = snd_pcm_lib_ioctl, @@ -1409,7 +1451,7 @@ static snd_pcm_ops_t snd_intel8x0_ali_spdifin_ops = { }; #if 0 // NYI -static snd_pcm_ops_t snd_intel8x0_ali_spdifout_ops = { +static struct snd_pcm_ops snd_intel8x0_ali_spdifout_ops = { .open = snd_intel8x0_ali_spdifout_open, .close = snd_intel8x0_ali_spdifout_close, .ioctl = snd_pcm_lib_ioctl, @@ -1423,16 +1465,17 @@ static snd_pcm_ops_t snd_intel8x0_ali_spdifout_ops = { struct ich_pcm_table { char *suffix; - snd_pcm_ops_t *playback_ops; - snd_pcm_ops_t *capture_ops; + struct snd_pcm_ops *playback_ops; + struct snd_pcm_ops *capture_ops; size_t prealloc_size; size_t prealloc_max_size; int ac97_idx; }; -static int __devinit snd_intel8x0_pcm1(intel8x0_t *chip, int device, struct ich_pcm_table *rec) +static int __devinit snd_intel8x0_pcm1(struct intel8x0 *chip, int device, + struct ich_pcm_table *rec) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; char name[32]; @@ -1459,7 +1502,8 @@ static int __devinit snd_intel8x0_pcm1(intel8x0_t *chip, int device, struct ich_ strcpy(pcm->name, chip->card->shortname); chip->pcm[device] = pcm; - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_dma_pci_data(chip->pci), rec->prealloc_size, rec->prealloc_max_size); return 0; @@ -1557,7 +1601,7 @@ static struct ich_pcm_table ali_pcms[] __devinitdata = { #endif }; -static int __devinit snd_intel8x0_pcm(intel8x0_t *chip) +static int __devinit snd_intel8x0_pcm(struct intel8x0 *chip) { int i, tblsize, device, err; struct ich_pcm_table *tbl, *rec; @@ -1604,15 +1648,15 @@ static int __devinit snd_intel8x0_pcm(intel8x0_t *chip) * Mixer part */ -static void snd_intel8x0_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_intel8x0_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - intel8x0_t *chip = bus->private_data; + struct intel8x0 *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_intel8x0_mixer_free_ac97(ac97_t *ac97) +static void snd_intel8x0_mixer_free_ac97(struct snd_ac97 *ac97) { - intel8x0_t *chip = ac97->private_data; + struct intel8x0 *chip = ac97->private_data; chip->ac97[ac97->num] = NULL; } @@ -1961,19 +2005,20 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { { } /* terminator */ }; -static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock, const char *quirk_override) +static int __devinit snd_intel8x0_mixer(struct intel8x0 *chip, int ac97_clock, + const char *quirk_override) { - ac97_bus_t *pbus; - ac97_template_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; int err; unsigned int i, codecs; unsigned int glob_sta = 0; - ac97_bus_ops_t *ops; - static ac97_bus_ops_t standard_bus_ops = { + struct snd_ac97_bus_ops *ops; + static struct snd_ac97_bus_ops standard_bus_ops = { .write = snd_intel8x0_codec_write, .read = snd_intel8x0_codec_read, }; - static ac97_bus_ops_t ali_bus_ops = { + static struct snd_ac97_bus_ops ali_bus_ops = { .write = snd_intel8x0_ali_codec_write, .read = snd_intel8x0_ali_codec_read, }; @@ -2128,7 +2173,8 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock, const __err: /* clear the cold-reset bit for the next chance */ if (chip->device_type != DEVICE_ALI) - iputdword(chip, ICHREG(GLOB_CNT), igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD); + iputdword(chip, ICHREG(GLOB_CNT), + igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD); return err; } @@ -2137,7 +2183,7 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock, const * */ -static void do_ali_reset(intel8x0_t *chip) +static void do_ali_reset(struct intel8x0 *chip) { iputdword(chip, ICHREG(ALI_SCR), ICH_ALI_SC_RESET); iputdword(chip, ICHREG(ALI_FIFOCR1), 0x83838383); @@ -2149,7 +2195,7 @@ static void do_ali_reset(intel8x0_t *chip) iputdword(chip, ICHREG(ALI_INTERRUPTSR), 0x00000000); } -static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) +static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing) { unsigned long end_time; unsigned int cnt, status, nstatus; @@ -2174,7 +2220,8 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) goto __ok; schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); - snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", igetdword(chip, ICHREG(GLOB_CNT))); + snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", + igetdword(chip, ICHREG(GLOB_CNT))); return -EIO; __ok: @@ -2185,14 +2232,16 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) */ end_time = jiffies + HZ; do { - status = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR); + status = igetdword(chip, ICHREG(GLOB_STA)) & + (ICH_PCR | ICH_SCR | ICH_TCR); if (status) break; schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); if (! status) { /* no codec is found */ - snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n", igetdword(chip, ICHREG(GLOB_STA))); + snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n", + igetdword(chip, ICHREG(GLOB_STA))); return -EIO; } @@ -2220,7 +2269,8 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) /* wait until all the probed codecs are ready */ end_time = jiffies + HZ; do { - nstatus = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR); + nstatus = igetdword(chip, ICHREG(GLOB_STA)) & + (ICH_PCR | ICH_SCR | ICH_TCR); if (status == nstatus) break; schedule_timeout_uninterruptible(1); @@ -2241,7 +2291,7 @@ static int snd_intel8x0_ich_chip_init(intel8x0_t *chip, int probing) return 0; } -static int snd_intel8x0_ali_chip_init(intel8x0_t *chip, int probing) +static int snd_intel8x0_ali_chip_init(struct intel8x0 *chip, int probing) { u32 reg; int i = 0; @@ -2276,7 +2326,7 @@ static int snd_intel8x0_ali_chip_init(intel8x0_t *chip, int probing) return 0; } -static int snd_intel8x0_chip_init(intel8x0_t *chip, int probing) +static int snd_intel8x0_chip_init(struct intel8x0 *chip, int probing) { unsigned int i; int err; @@ -2298,11 +2348,12 @@ static int snd_intel8x0_chip_init(intel8x0_t *chip, int probing) iputbyte(chip, ICH_REG_OFF_CR + chip->ichd[i].reg_offset, ICH_RESETREGS); /* initialize Buffer Descriptor Lists */ for (i = 0; i < chip->bdbars_count; i++) - iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset, chip->ichd[i].bdbar_addr); + iputdword(chip, ICH_REG_OFF_BDBAR + chip->ichd[i].reg_offset, + chip->ichd[i].bdbar_addr); return 0; } -static int snd_intel8x0_free(intel8x0_t *chip) +static int snd_intel8x0_free(struct intel8x0 *chip) { unsigned int i; @@ -2325,7 +2376,7 @@ static int snd_intel8x0_free(intel8x0_t *chip) synchronize_irq(chip->irq); __hw_end: if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); if (chip->bdbars.area) { if (chip->fix_nocache) fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 0); @@ -2345,9 +2396,9 @@ static int snd_intel8x0_free(intel8x0_t *chip) /* * power management */ -static int intel8x0_suspend(snd_card_t *card, pm_message_t state) +static int intel8x0_suspend(struct snd_card *card, pm_message_t state) { - intel8x0_t *chip = card->pm_private_data; + struct intel8x0 *chip = card->pm_private_data; int i; for (i = 0; i < chip->pcm_devs; i++) @@ -2355,9 +2406,9 @@ static int intel8x0_suspend(snd_card_t *card, pm_message_t state) /* clear nocache */ if (chip->fix_nocache) { for (i = 0; i < chip->bdbars_count; i++) { - ichdev_t *ichdev = &chip->ichd[i]; + struct ichdev *ichdev = &chip->ichd[i]; if (ichdev->substream && ichdev->page_attr_changed) { - snd_pcm_runtime_t *runtime = ichdev->substream->runtime; + struct snd_pcm_runtime *runtime = ichdev->substream->runtime; if (runtime->dma_area) fill_nocache(runtime->dma_area, runtime->dma_bytes, 0); } @@ -2370,19 +2421,20 @@ static int intel8x0_suspend(snd_card_t *card, pm_message_t state) chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); pci_disable_device(chip->pci); return 0; } -static int intel8x0_resume(snd_card_t *card) +static int intel8x0_resume(struct snd_card *card) { - intel8x0_t *chip = card->pm_private_data; + struct intel8x0 *chip = card->pm_private_data; int i; pci_enable_device(chip->pci); pci_set_master(chip->pci); - request_irq(chip->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip); + request_irq(chip->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, + card->shortname, chip); synchronize_irq(chip->irq); snd_intel8x0_chip_init(chip, 1); @@ -2407,9 +2459,9 @@ static int intel8x0_resume(snd_card_t *card) /* refill nocache */ if (chip->fix_nocache) { for (i = 0; i < chip->bdbars_count; i++) { - ichdev_t *ichdev = &chip->ichd[i]; + struct ichdev *ichdev = &chip->ichd[i]; if (ichdev->substream && ichdev->page_attr_changed) { - snd_pcm_runtime_t *runtime = ichdev->substream->runtime; + struct snd_pcm_runtime *runtime = ichdev->substream->runtime; if (runtime->dma_area) fill_nocache(runtime->dma_area, runtime->dma_bytes, 1); } @@ -2418,7 +2470,7 @@ static int intel8x0_resume(snd_card_t *card) /* resume status */ for (i = 0; i < chip->bdbars_count; i++) { - ichdev_t *ichdev = &chip->ichd[i]; + struct ichdev *ichdev = &chip->ichd[i]; unsigned long port = ichdev->reg_offset; if (! ichdev->substream || ! ichdev->suspended) continue; @@ -2436,10 +2488,10 @@ static int intel8x0_resume(snd_card_t *card) #define INTEL8X0_TESTBUF_SIZE 32768 /* enough large for one shot */ -static void __devinit intel8x0_measure_ac97_clock(intel8x0_t *chip) +static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) { - snd_pcm_substream_t *subs; - ichdev_t *ichdev; + struct snd_pcm_substream *subs; + struct ichdev *ichdev; unsigned long port; unsigned long pos, t; struct timeval start_time, stop_time; @@ -2516,10 +2568,10 @@ static void __devinit intel8x0_measure_ac97_clock(intel8x0_t *chip) printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock); } -static void snd_intel8x0_proc_read(snd_info_entry_t * entry, - snd_info_buffer_t * buffer) +static void snd_intel8x0_proc_read(struct snd_info_entry * entry, + struct snd_info_buffer *buffer) { - intel8x0_t *chip = entry->private_data; + struct intel8x0 *chip = entry->private_data; unsigned int tmp; snd_iprintf(buffer, "Intel8x0\n\n"); @@ -2542,17 +2594,17 @@ static void snd_intel8x0_proc_read(snd_info_entry_t * entry, chip->ac97_sdin[2]); } -static void __devinit snd_intel8x0_proc_init(intel8x0_t * chip) +static void __devinit snd_intel8x0_proc_init(struct intel8x0 * chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "intel8x0", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_intel8x0_proc_read); } -static int snd_intel8x0_dev_free(snd_device_t *device) +static int snd_intel8x0_dev_free(struct snd_device *device) { - intel8x0_t *chip = device->device_data; + struct intel8x0 *chip = device->device_data; return snd_intel8x0_free(chip); } @@ -2561,17 +2613,17 @@ struct ich_reg_info { unsigned int offset; }; -static int __devinit snd_intel8x0_create(snd_card_t * card, +static int __devinit snd_intel8x0_create(struct snd_card *card, struct pci_dev *pci, unsigned long device_type, - intel8x0_t ** r_intel8x0) + struct intel8x0 ** r_intel8x0) { - intel8x0_t *chip; + struct intel8x0 *chip; int err; unsigned int i; unsigned int int_sta_masks; - ichdev_t *ichdev; - static snd_device_ops_t ops = { + struct ichdev *ichdev; + static struct snd_device_ops ops = { .dev_free = snd_intel8x0_dev_free, }; @@ -2734,7 +2786,7 @@ static int __devinit snd_intel8x0_create(snd_card_t * card, /* request irq after initializaing int_sta_mask, etc */ if (request_irq(pci->irq, snd_intel8x0_interrupt, - SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip)) { + SA_INTERRUPT|SA_SHIRQ, card->shortname, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_intel8x0_free(chip); return -EBUSY; @@ -2793,8 +2845,8 @@ static struct shortname_table { static int __devinit snd_intel8x0_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - intel8x0_t *chip; + struct snd_card *card; + struct intel8x0 *chip; int err; struct shortname_table *name; diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 3244df9..3b6724e 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -38,7 +38,8 @@ #include <sound/initval.h> MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>"); -MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; SiS 7013; NVidia MCP/2/2S/3 modems"); +MODULE_DESCRIPTION("Intel 82801AA,82901AB,i810,i820,i830,i840,i845,MX440; " + "SiS 7013; NVidia MCP/2/2S/3 modems"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH}," "{Intel,82901AB-ICH0}," @@ -163,14 +164,14 @@ DEFINE_REGSET(OFF, 0); /* offset */ enum { ICHD_MDMIN, ICHD_MDMOUT, ICHD_MDMLAST = ICHD_MDMOUT }; enum { ALID_MDMIN, ALID_MDMOUT, ALID_MDMLAST = ALID_MDMOUT }; -#define get_ichdev(substream) (ichdev_t *)(substream->runtime->private_data) +#define get_ichdev(substream) (substream->runtime->private_data) -typedef struct { +struct ichdev { unsigned int ichd; /* ich device number */ unsigned long reg_offset; /* offset to bmaddr */ u32 *bdbar; /* CPU address (32bit) */ unsigned int bdbar_addr; /* PCI bus address (32bit) */ - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; unsigned int physbuf; /* physical address (32bit) */ unsigned int size; unsigned int fragsize; @@ -187,12 +188,10 @@ typedef struct { unsigned int roff_picb; unsigned int int_sta_mask; /* interrupt status mask */ unsigned int ali_slot; /* ALI DMA slot */ - ac97_t *ac97; -} ichdev_t; - -typedef struct _snd_intel8x0m intel8x0_t; + struct snd_ac97 *ac97; +}; -struct _snd_intel8x0m { +struct intel8x0m { unsigned int device_type; int irq; @@ -205,16 +204,16 @@ struct _snd_intel8x0m { void __iomem *remap_bmaddr; struct pci_dev *pci; - snd_card_t *card; + struct snd_card *card; int pcm_devs; - snd_pcm_t *pcm[2]; - ichdev_t ichd[2]; + struct snd_pcm *pcm[2]; + struct ichdev ichd[2]; unsigned int in_ac97_init: 1; - ac97_bus_t *ac97_bus; - ac97_t *ac97; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97; spinlock_t reg_lock; @@ -254,7 +253,7 @@ MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids); * Lowlevel I/O - busmaster */ -static u8 igetbyte(intel8x0_t *chip, u32 offset) +static u8 igetbyte(struct intel8x0m *chip, u32 offset) { if (chip->bm_mmio) return readb(chip->remap_bmaddr + offset); @@ -262,7 +261,7 @@ static u8 igetbyte(intel8x0_t *chip, u32 offset) return inb(chip->bmaddr + offset); } -static u16 igetword(intel8x0_t *chip, u32 offset) +static u16 igetword(struct intel8x0m *chip, u32 offset) { if (chip->bm_mmio) return readw(chip->remap_bmaddr + offset); @@ -270,7 +269,7 @@ static u16 igetword(intel8x0_t *chip, u32 offset) return inw(chip->bmaddr + offset); } -static u32 igetdword(intel8x0_t *chip, u32 offset) +static u32 igetdword(struct intel8x0m *chip, u32 offset) { if (chip->bm_mmio) return readl(chip->remap_bmaddr + offset); @@ -278,7 +277,7 @@ static u32 igetdword(intel8x0_t *chip, u32 offset) return inl(chip->bmaddr + offset); } -static void iputbyte(intel8x0_t *chip, u32 offset, u8 val) +static void iputbyte(struct intel8x0m *chip, u32 offset, u8 val) { if (chip->bm_mmio) writeb(val, chip->remap_bmaddr + offset); @@ -286,7 +285,7 @@ static void iputbyte(intel8x0_t *chip, u32 offset, u8 val) outb(val, chip->bmaddr + offset); } -static void iputword(intel8x0_t *chip, u32 offset, u16 val) +static void iputword(struct intel8x0m *chip, u32 offset, u16 val) { if (chip->bm_mmio) writew(val, chip->remap_bmaddr + offset); @@ -294,7 +293,7 @@ static void iputword(intel8x0_t *chip, u32 offset, u16 val) outw(val, chip->bmaddr + offset); } -static void iputdword(intel8x0_t *chip, u32 offset, u32 val) +static void iputdword(struct intel8x0m *chip, u32 offset, u32 val) { if (chip->bm_mmio) writel(val, chip->remap_bmaddr + offset); @@ -306,7 +305,7 @@ static void iputdword(intel8x0_t *chip, u32 offset, u32 val) * Lowlevel I/O - AC'97 registers */ -static u16 iagetword(intel8x0_t *chip, u32 offset) +static u16 iagetword(struct intel8x0m *chip, u32 offset) { if (chip->mmio) return readw(chip->remap_addr + offset); @@ -314,7 +313,7 @@ static u16 iagetword(intel8x0_t *chip, u32 offset) return inw(chip->addr + offset); } -static void iaputword(intel8x0_t *chip, u32 offset, u16 val) +static void iaputword(struct intel8x0m *chip, u32 offset, u16 val) { if (chip->mmio) writew(val, chip->remap_addr + offset); @@ -331,7 +330,7 @@ static void iaputword(intel8x0_t *chip, u32 offset, u16 val) */ /* return the GLOB_STA bit for the corresponding codec */ -static unsigned int get_ich_codec_bit(intel8x0_t *chip, unsigned int codec) +static unsigned int get_ich_codec_bit(struct intel8x0m *chip, unsigned int codec) { static unsigned int codec_bit[3] = { ICH_PCR, ICH_SCR, ICH_TCR @@ -340,7 +339,7 @@ static unsigned int get_ich_codec_bit(intel8x0_t *chip, unsigned int codec) return codec_bit[codec]; } -static int snd_intel8x0m_codec_semaphore(intel8x0_t *chip, unsigned int codec) +static int snd_intel8x0m_codec_semaphore(struct intel8x0m *chip, unsigned int codec) { int time; @@ -370,11 +369,11 @@ static int snd_intel8x0m_codec_semaphore(intel8x0_t *chip, unsigned int codec) return -EBUSY; } -static void snd_intel8x0_codec_write(ac97_t *ac97, +static void snd_intel8x0_codec_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - intel8x0_t *chip = ac97->private_data; + struct intel8x0m *chip = ac97->private_data; if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) { if (! chip->in_ac97_init) @@ -383,10 +382,10 @@ static void snd_intel8x0_codec_write(ac97_t *ac97, iaputword(chip, reg + ac97->num * 0x80, val); } -static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, +static unsigned short snd_intel8x0_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - intel8x0_t *chip = ac97->private_data; + struct intel8x0m *chip = ac97->private_data; unsigned short res; unsigned int tmp; @@ -398,7 +397,8 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, res = iagetword(chip, reg + ac97->num * 0x80); if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) { /* reset RCS and preserve other R/WC bits */ - iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI)); + iputdword(chip, ICHREG(GLOB_STA), + tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI)); if (! chip->in_ac97_init) snd_printk(KERN_ERR "codec_read %d: read timeout for register 0x%x\n", ac97->num, reg); res = 0xffff; @@ -413,7 +413,7 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, /* * DMA I/O */ -static void snd_intel8x0_setup_periods(intel8x0_t *chip, ichdev_t *ichdev) +static void snd_intel8x0_setup_periods(struct intel8x0m *chip, struct ichdev *ichdev) { int idx; u32 *bdbar = ichdev->bdbar; @@ -460,7 +460,7 @@ static void snd_intel8x0_setup_periods(intel8x0_t *chip, ichdev_t *ichdev) * Interrupt handler */ -static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev) +static inline void snd_intel8x0_update(struct intel8x0m *chip, struct ichdev *ichdev) { unsigned long port = ichdev->reg_offset; int civ, i, step; @@ -489,8 +489,15 @@ static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev) for (i = 0; i < step; i++) { ichdev->lvi_frag++; ichdev->lvi_frag %= ichdev->frags; - ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + ichdev->lvi_frag * ichdev->fragsize1); - // printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n", ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), inl(port + 4), inb(port + ICH_REG_OFF_CR)); + ichdev->bdbar[ichdev->lvi * 2] = cpu_to_le32(ichdev->physbuf + + ichdev->lvi_frag * + ichdev->fragsize1); +#if 0 + printk("new: bdbar[%i] = 0x%x [0x%x], prefetch = %i, all = 0x%x, 0x%x\n", + ichdev->lvi * 2, ichdev->bdbar[ichdev->lvi * 2], + ichdev->bdbar[ichdev->lvi * 2 + 1], inb(ICH_REG_OFF_PIV + port), + inl(port + 4), inb(port + ICH_REG_OFF_CR)); +#endif if (--ichdev->ack == 0) { ichdev->ack = ichdev->ack_reload; ack = 1; @@ -506,8 +513,8 @@ static inline void snd_intel8x0_update(intel8x0_t *chip, ichdev_t *ichdev) static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - intel8x0_t *chip = dev_id; - ichdev_t *ichdev; + struct intel8x0m *chip = dev_id; + struct ichdev *ichdev; unsigned int status; unsigned int i; @@ -541,10 +548,10 @@ static irqreturn_t snd_intel8x0_interrupt(int irq, void *dev_id, struct pt_regs * PCM part */ -static int snd_intel8x0_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_intel8x0_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - ichdev_t *ichdev = get_ichdev(substream); + struct intel8x0m *chip = snd_pcm_substream_chip(substream); + struct ichdev *ichdev = get_ichdev(substream); unsigned char val = 0; unsigned long port = ichdev->reg_offset; @@ -576,21 +583,21 @@ static int snd_intel8x0_pcm_trigger(snd_pcm_substream_t *substream, int cmd) return 0; } -static int snd_intel8x0_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_intel8x0_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_intel8x0_hw_free(snd_pcm_substream_t * substream) +static int snd_intel8x0_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - ichdev_t *ichdev = get_ichdev(substream); + struct intel8x0m *chip = snd_pcm_substream_chip(substream); + struct ichdev *ichdev = get_ichdev(substream); size_t ptr1, ptr; ptr1 = igetword(chip, ichdev->reg_offset + ichdev->roff_picb) << chip->pcm_pos_shift; @@ -604,11 +611,11 @@ static snd_pcm_uframes_t snd_intel8x0_pcm_pointer(snd_pcm_substream_t * substrea return bytes_to_frames(substream->runtime, ptr); } -static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream) +static int snd_intel8x0m_pcm_prepare(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - ichdev_t *ichdev = get_ichdev(substream); + struct intel8x0m *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct ichdev *ichdev = get_ichdev(substream); ichdev->physbuf = runtime->dma_addr; ichdev->size = snd_pcm_lib_buffer_bytes(substream); @@ -619,7 +626,7 @@ static int snd_intel8x0m_pcm_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_hardware_t snd_intel8x0m_stream = +static struct snd_pcm_hardware snd_intel8x0m_stream = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -641,58 +648,59 @@ static snd_pcm_hardware_t snd_intel8x0m_stream = }; -static int snd_intel8x0m_pcm_open(snd_pcm_substream_t * substream, ichdev_t *ichdev) +static int snd_intel8x0m_pcm_open(struct snd_pcm_substream *substream, struct ichdev *ichdev) { static unsigned int rates[] = { 8000, 9600, 12000, 16000 }; - static snd_pcm_hw_constraint_list_t hw_constraints_rates = { + static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, }; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; ichdev->substream = substream; runtime->hw = snd_intel8x0m_stream; - err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates); + err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &hw_constraints_rates); if ( err < 0 ) return err; runtime->private_data = ichdev; return 0; } -static int snd_intel8x0m_playback_open(snd_pcm_substream_t * substream) +static int snd_intel8x0m_playback_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0m *chip = snd_pcm_substream_chip(substream); return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMOUT]); } -static int snd_intel8x0m_playback_close(snd_pcm_substream_t * substream) +static int snd_intel8x0m_playback_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0m *chip = snd_pcm_substream_chip(substream); chip->ichd[ICHD_MDMOUT].substream = NULL; return 0; } -static int snd_intel8x0m_capture_open(snd_pcm_substream_t * substream) +static int snd_intel8x0m_capture_open(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0m *chip = snd_pcm_substream_chip(substream); return snd_intel8x0m_pcm_open(substream, &chip->ichd[ICHD_MDMIN]); } -static int snd_intel8x0m_capture_close(snd_pcm_substream_t * substream) +static int snd_intel8x0m_capture_close(struct snd_pcm_substream *substream) { - intel8x0_t *chip = snd_pcm_substream_chip(substream); + struct intel8x0m *chip = snd_pcm_substream_chip(substream); chip->ichd[ICHD_MDMIN].substream = NULL; return 0; } -static snd_pcm_ops_t snd_intel8x0m_playback_ops = { +static struct snd_pcm_ops snd_intel8x0m_playback_ops = { .open = snd_intel8x0m_playback_open, .close = snd_intel8x0m_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -703,7 +711,7 @@ static snd_pcm_ops_t snd_intel8x0m_playback_ops = { .pointer = snd_intel8x0_pcm_pointer, }; -static snd_pcm_ops_t snd_intel8x0m_capture_ops = { +static struct snd_pcm_ops snd_intel8x0m_capture_ops = { .open = snd_intel8x0m_capture_open, .close = snd_intel8x0m_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -717,16 +725,17 @@ static snd_pcm_ops_t snd_intel8x0m_capture_ops = { struct ich_pcm_table { char *suffix; - snd_pcm_ops_t *playback_ops; - snd_pcm_ops_t *capture_ops; + struct snd_pcm_ops *playback_ops; + struct snd_pcm_ops *capture_ops; size_t prealloc_size; size_t prealloc_max_size; int ac97_idx; }; -static int __devinit snd_intel8x0_pcm1(intel8x0_t *chip, int device, struct ich_pcm_table *rec) +static int __devinit snd_intel8x0_pcm1(struct intel8x0m *chip, int device, + struct ich_pcm_table *rec) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; char name[32]; @@ -772,7 +781,7 @@ static struct ich_pcm_table intel_pcms[] __devinitdata = { }, }; -static int __devinit snd_intel8x0_pcm(intel8x0_t *chip) +static int __devinit snd_intel8x0_pcm(struct intel8x0m *chip) { int i, tblsize, device, err; struct ich_pcm_table *tbl, *rec; @@ -819,27 +828,27 @@ static int __devinit snd_intel8x0_pcm(intel8x0_t *chip) * Mixer part */ -static void snd_intel8x0_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_intel8x0_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - intel8x0_t *chip = bus->private_data; + struct intel8x0m *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_intel8x0_mixer_free_ac97(ac97_t *ac97) +static void snd_intel8x0_mixer_free_ac97(struct snd_ac97 *ac97) { - intel8x0_t *chip = ac97->private_data; + struct intel8x0m *chip = ac97->private_data; chip->ac97 = NULL; } -static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock) +static int __devinit snd_intel8x0_mixer(struct intel8x0m *chip, int ac97_clock) { - ac97_bus_t *pbus; - ac97_template_t ac97; - ac97_t *x97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; + struct snd_ac97 *x97; int err; unsigned int glob_sta = 0; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_intel8x0_codec_write, .read = snd_intel8x0_codec_read, }; @@ -880,7 +889,8 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock) __err: /* clear the cold-reset bit for the next chance */ if (chip->device_type != DEVICE_ALI) - iputdword(chip, ICHREG(GLOB_CNT), igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD); + iputdword(chip, ICHREG(GLOB_CNT), + igetdword(chip, ICHREG(GLOB_CNT)) & ~ICH_AC97COLD); return err; } @@ -889,7 +899,7 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock) * */ -static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) +static int snd_intel8x0m_ich_chip_init(struct intel8x0m *chip, int probing) { unsigned long end_time; unsigned int cnt, status, nstatus; @@ -912,7 +922,8 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) goto __ok; schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); - snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", igetdword(chip, ICHREG(GLOB_CNT))); + snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n", + igetdword(chip, ICHREG(GLOB_CNT))); return -EIO; __ok: @@ -923,14 +934,16 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) */ end_time = jiffies + HZ; do { - status = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR); + status = igetdword(chip, ICHREG(GLOB_STA)) & + (ICH_PCR | ICH_SCR | ICH_TCR); if (status) break; schedule_timeout_uninterruptible(1); } while (time_after_eq(end_time, jiffies)); if (! status) { /* no codec is found */ - snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n", igetdword(chip, ICHREG(GLOB_STA))); + snd_printk(KERN_ERR "codec_ready: codec is not ready [0x%x]\n", + igetdword(chip, ICHREG(GLOB_STA))); return -EIO; } @@ -952,7 +965,8 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) /* wait until all the probed codecs are ready */ end_time = jiffies + HZ; do { - nstatus = igetdword(chip, ICHREG(GLOB_STA)) & (ICH_PCR | ICH_SCR | ICH_TCR); + nstatus = igetdword(chip, ICHREG(GLOB_STA)) & + (ICH_PCR | ICH_SCR | ICH_TCR); if (status == nstatus) break; schedule_timeout_uninterruptible(1); @@ -967,7 +981,7 @@ static int snd_intel8x0m_ich_chip_init(intel8x0_t *chip, int probing) return 0; } -static int snd_intel8x0_chip_init(intel8x0_t *chip, int probing) +static int snd_intel8x0_chip_init(struct intel8x0m *chip, int probing) { unsigned int i; int err; @@ -988,7 +1002,7 @@ static int snd_intel8x0_chip_init(intel8x0_t *chip, int probing) return 0; } -static int snd_intel8x0_free(intel8x0_t *chip) +static int snd_intel8x0_free(struct intel8x0m *chip) { unsigned int i; @@ -1010,7 +1024,7 @@ static int snd_intel8x0_free(intel8x0_t *chip) if (chip->remap_bmaddr) iounmap(chip->remap_bmaddr); if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); @@ -1021,9 +1035,9 @@ static int snd_intel8x0_free(intel8x0_t *chip) /* * power management */ -static int intel8x0m_suspend(snd_card_t *card, pm_message_t state) +static int intel8x0m_suspend(struct snd_card *card, pm_message_t state) { - intel8x0_t *chip = card->pm_private_data; + struct intel8x0m *chip = card->pm_private_data; int i; for (i = 0; i < chip->pcm_devs; i++) @@ -1034,9 +1048,9 @@ static int intel8x0m_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int intel8x0m_resume(snd_card_t *card) +static int intel8x0m_resume(struct snd_card *card) { - intel8x0_t *chip = card->pm_private_data; + struct intel8x0m *chip = card->pm_private_data; pci_enable_device(chip->pci); pci_set_master(chip->pci); snd_intel8x0_chip_init(chip, 0); @@ -1047,17 +1061,18 @@ static int intel8x0m_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -static void snd_intel8x0m_proc_read(snd_info_entry_t * entry, - snd_info_buffer_t * buffer) +static void snd_intel8x0m_proc_read(struct snd_info_entry * entry, + struct snd_info_buffer *buffer) { - intel8x0_t *chip = entry->private_data; + struct intel8x0m *chip = entry->private_data; unsigned int tmp; snd_iprintf(buffer, "Intel8x0m\n\n"); if (chip->device_type == DEVICE_ALI) return; tmp = igetdword(chip, ICHREG(GLOB_STA)); - snd_iprintf(buffer, "Global control : 0x%08x\n", igetdword(chip, ICHREG(GLOB_CNT))); + snd_iprintf(buffer, "Global control : 0x%08x\n", + igetdword(chip, ICHREG(GLOB_CNT))); snd_iprintf(buffer, "Global status : 0x%08x\n", tmp); snd_iprintf(buffer, "AC'97 codecs ready :%s%s%s%s\n", tmp & ICH_PCR ? " primary" : "", @@ -1066,17 +1081,17 @@ static void snd_intel8x0m_proc_read(snd_info_entry_t * entry, (tmp & (ICH_PCR | ICH_SCR | ICH_TCR)) == 0 ? " none" : ""); } -static void __devinit snd_intel8x0m_proc_init(intel8x0_t * chip) +static void __devinit snd_intel8x0m_proc_init(struct intel8x0m * chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "intel8x0m", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_intel8x0m_proc_read); } -static int snd_intel8x0_dev_free(snd_device_t *device) +static int snd_intel8x0_dev_free(struct snd_device *device) { - intel8x0_t *chip = device->device_data; + struct intel8x0m *chip = device->device_data; return snd_intel8x0_free(chip); } @@ -1085,17 +1100,17 @@ struct ich_reg_info { unsigned int offset; }; -static int __devinit snd_intel8x0m_create(snd_card_t * card, +static int __devinit snd_intel8x0m_create(struct snd_card *card, struct pci_dev *pci, unsigned long device_type, - intel8x0_t ** r_intel8x0) + struct intel8x0m ** r_intel8x0) { - intel8x0_t *chip; + struct intel8x0m *chip; int err; unsigned int i; unsigned int int_sta_masks; - ichdev_t *ichdev; - static snd_device_ops_t ops = { + struct ichdev *ichdev; + static struct snd_device_ops ops = { .dev_free = snd_intel8x0_dev_free, }; static struct ich_reg_info intel_regs[2] = { @@ -1160,7 +1175,8 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card, } port_inited: - if (request_irq(pci->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, (void *)chip)) { + if (request_irq(pci->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, + card->shortname, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_intel8x0_free(chip); return -EBUSY; @@ -1259,8 +1275,8 @@ static struct shortname_table { static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - intel8x0_t *chip; + struct snd_card *card; + struct intel8x0m *chip; int err; struct shortname_table *name; -- cgit v1.1 From 3470c29dbde2aa8320acb29a654b5a72756ee58b Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:05:09 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI Maestro3 Modules: Maestro3 driver Remove xxx_t typedefs from the PCI Maestro3 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/maestro3.c | 223 +++++++++++++++++++++++++-------------------------- 1 file changed, 111 insertions(+), 112 deletions(-) diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index ede7a75..9878595 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -767,9 +767,6 @@ MODULE_PARM_DESC(amp_gpio, "GPIO pin number for external amp. (default = -1)"); /* */ -typedef struct snd_m3_dma m3_dma_t; -typedef struct snd_m3 m3_t; - /* quirk lists */ struct m3_quirk { const char *name; /* device name */ @@ -791,11 +788,10 @@ struct m3_list { int max; }; -struct snd_m3_dma { +struct m3_dma { int number; - m3_t *chip; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; struct assp_instance { unsigned short code, data; @@ -821,16 +817,16 @@ struct snd_m3_dma { struct snd_m3 { - snd_card_t *card; + struct snd_card *card; unsigned long iobase; int irq; unsigned int allegro_flag : 1; - ac97_t *ac97; + struct snd_ac97 *ac97; - snd_pcm_t *pcm; + struct snd_pcm *pcm; struct pci_dev *pci; struct m3_quirk *quirk; @@ -851,17 +847,17 @@ struct snd_m3 { int amp_gpio; /* midi */ - snd_rawmidi_t *rmidi; + struct snd_rawmidi *rmidi; /* pcm streams */ int num_substreams; - m3_dma_t *substreams; + struct m3_dma *substreams; spinlock_t reg_lock; spinlock_t ac97_lock; - snd_kcontrol_t *master_switch; - snd_kcontrol_t *master_volume; + struct snd_kcontrol *master_switch; + struct snd_kcontrol *master_volume; struct tasklet_struct hwvol_tq; #ifdef CONFIG_PM @@ -1021,22 +1017,22 @@ static struct m3_hv_quirk m3_hv_quirk_list[] = { * lowlevel functions */ -static inline void snd_m3_outw(m3_t *chip, u16 value, unsigned long reg) +static inline void snd_m3_outw(struct snd_m3 *chip, u16 value, unsigned long reg) { outw(value, chip->iobase + reg); } -static inline u16 snd_m3_inw(m3_t *chip, unsigned long reg) +static inline u16 snd_m3_inw(struct snd_m3 *chip, unsigned long reg) { return inw(chip->iobase + reg); } -static inline void snd_m3_outb(m3_t *chip, u8 value, unsigned long reg) +static inline void snd_m3_outb(struct snd_m3 *chip, u8 value, unsigned long reg) { outb(value, chip->iobase + reg); } -static inline u8 snd_m3_inb(m3_t *chip, unsigned long reg) +static inline u8 snd_m3_inb(struct snd_m3 *chip, unsigned long reg) { return inb(chip->iobase + reg); } @@ -1045,28 +1041,28 @@ static inline u8 snd_m3_inb(m3_t *chip, unsigned long reg) * access 16bit words to the code or data regions of the dsp's memory. * index addresses 16bit words. */ -static u16 snd_m3_assp_read(m3_t *chip, u16 region, u16 index) +static u16 snd_m3_assp_read(struct snd_m3 *chip, u16 region, u16 index) { snd_m3_outw(chip, region & MEMTYPE_MASK, DSP_PORT_MEMORY_TYPE); snd_m3_outw(chip, index, DSP_PORT_MEMORY_INDEX); return snd_m3_inw(chip, DSP_PORT_MEMORY_DATA); } -static void snd_m3_assp_write(m3_t *chip, u16 region, u16 index, u16 data) +static void snd_m3_assp_write(struct snd_m3 *chip, u16 region, u16 index, u16 data) { snd_m3_outw(chip, region & MEMTYPE_MASK, DSP_PORT_MEMORY_TYPE); snd_m3_outw(chip, index, DSP_PORT_MEMORY_INDEX); snd_m3_outw(chip, data, DSP_PORT_MEMORY_DATA); } -static void snd_m3_assp_halt(m3_t *chip) +static void snd_m3_assp_halt(struct snd_m3 *chip) { chip->reset_state = snd_m3_inb(chip, DSP_PORT_CONTROL_REG_B) & ~REGB_STOP_CLOCK; msleep(10); snd_m3_outb(chip, chip->reset_state & ~REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B); } -static void snd_m3_assp_continue(m3_t *chip) +static void snd_m3_assp_continue(struct snd_m3 *chip) { snd_m3_outb(chip, chip->reset_state | REGB_ENABLE_RESET, DSP_PORT_CONTROL_REG_B); } @@ -1080,7 +1076,7 @@ static void snd_m3_assp_continue(m3_t *chip) * by the binary code images. */ -static int snd_m3_add_list(m3_t *chip, struct m3_list *list, u16 val) +static int snd_m3_add_list(struct snd_m3 *chip, struct m3_list *list, u16 val) { snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, list->mem_addr + list->curlen, @@ -1088,7 +1084,7 @@ static int snd_m3_add_list(m3_t *chip, struct m3_list *list, u16 val) return list->curlen++; } -static void snd_m3_remove_list(m3_t *chip, struct m3_list *list, int index) +static void snd_m3_remove_list(struct snd_m3 *chip, struct m3_list *list, int index) { u16 val; int lastindex = list->curlen - 1; @@ -1108,7 +1104,7 @@ static void snd_m3_remove_list(m3_t *chip, struct m3_list *list, int index) list->curlen--; } -static void snd_m3_inc_timer_users(m3_t *chip) +static void snd_m3_inc_timer_users(struct snd_m3 *chip) { chip->timer_users++; if (chip->timer_users != 1) @@ -1127,7 +1123,7 @@ static void snd_m3_inc_timer_users(m3_t *chip) HOST_INT_CTRL); } -static void snd_m3_dec_timer_users(m3_t *chip) +static void snd_m3_dec_timer_users(struct snd_m3 *chip) { chip->timer_users--; if (chip->timer_users > 0) @@ -1151,7 +1147,8 @@ static void snd_m3_dec_timer_users(m3_t *chip) */ /* spinlock held! */ -static int snd_m3_pcm_start(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) +static int snd_m3_pcm_start(struct snd_m3 *chip, struct m3_dma *s, + struct snd_pcm_substream *subs) { if (! s || ! subs) return -EINVAL; @@ -1167,7 +1164,7 @@ static int snd_m3_pcm_start(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) chip->dacs_active); break; case SNDRV_PCM_STREAM_CAPTURE: - snd_m3_assp_write(s->chip, MEMTYPE_INTERNAL_DATA, + snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, KDATA_ADC1_REQUEST, 1); snd_m3_assp_write(chip, MEMTYPE_INTERNAL_DATA, s->inst.data + CDATA_INSTANCE_READY, 1); @@ -1177,7 +1174,8 @@ static int snd_m3_pcm_start(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) } /* spinlock held! */ -static int snd_m3_pcm_stop(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) +static int snd_m3_pcm_stop(struct snd_m3 *chip, struct m3_dma *s, + struct snd_pcm_substream *subs) { if (! s || ! subs) return -EINVAL; @@ -1201,10 +1199,10 @@ static int snd_m3_pcm_stop(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) } static int -snd_m3_pcm_trigger(snd_pcm_substream_t *subs, int cmd) +snd_m3_pcm_trigger(struct snd_pcm_substream *subs, int cmd) { - m3_t *chip = snd_pcm_substream_chip(subs); - m3_dma_t *s = (m3_dma_t*)subs->runtime->private_data; + struct snd_m3 *chip = snd_pcm_substream_chip(subs); + struct m3_dma *s = subs->runtime->private_data; int err = -EINVAL; snd_assert(s != NULL, return -ENXIO); @@ -1238,10 +1236,10 @@ snd_m3_pcm_trigger(snd_pcm_substream_t *subs, int cmd) * setup */ static void -snd_m3_pcm_setup1(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) +snd_m3_pcm_setup1(struct snd_m3 *chip, struct m3_dma *s, struct snd_pcm_substream *subs) { int dsp_in_size, dsp_out_size, dsp_in_buffer, dsp_out_buffer; - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (subs->stream == SNDRV_PCM_STREAM_PLAYBACK) { dsp_in_size = MINISRC_IN_BUFFER_SIZE - (0x20 * 2); @@ -1323,7 +1321,8 @@ snd_m3_pcm_setup1(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) dsp_out_buffer); } -static void snd_m3_pcm_setup2(m3_t *chip, m3_dma_t *s, snd_pcm_runtime_t *runtime) +static void snd_m3_pcm_setup2(struct snd_m3 *chip, struct m3_dma *s, + struct snd_pcm_runtime *runtime) { u32 freq; @@ -1389,7 +1388,8 @@ static struct play_vals { /* the mode passed should be already shifted and masked */ static void -snd_m3_playback_setup(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) +snd_m3_playback_setup(struct snd_m3 *chip, struct m3_dma *s, + struct snd_pcm_substream *subs) { unsigned int i; @@ -1455,7 +1455,7 @@ static struct rec_vals { }; static void -snd_m3_capture_setup(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) +snd_m3_capture_setup(struct snd_m3 *chip, struct m3_dma *s, struct snd_pcm_substream *subs) { unsigned int i; @@ -1481,10 +1481,10 @@ snd_m3_capture_setup(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) s->inst.data + rv[i].addr, rv[i].val); } -static int snd_m3_pcm_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_m3_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - m3_dma_t *s = (m3_dma_t*) substream->runtime->private_data; + struct m3_dma *s = substream->runtime->private_data; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) @@ -1498,24 +1498,24 @@ static int snd_m3_pcm_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_m3_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_m3_pcm_hw_free(struct snd_pcm_substream *substream) { - m3_dma_t *s; + struct m3_dma *s; if (substream->runtime->private_data == NULL) return 0; - s = (m3_dma_t*) substream->runtime->private_data; + s = substream->runtime->private_data; snd_pcm_lib_free_pages(substream); s->buffer_addr = 0; return 0; } static int -snd_m3_pcm_prepare(snd_pcm_substream_t *subs) +snd_m3_pcm_prepare(struct snd_pcm_substream *subs) { - m3_t *chip = snd_pcm_substream_chip(subs); - snd_pcm_runtime_t *runtime = subs->runtime; - m3_dma_t *s = (m3_dma_t*)runtime->private_data; + struct snd_m3 *chip = snd_pcm_substream_chip(subs); + struct snd_pcm_runtime *runtime = subs->runtime; + struct m3_dma *s = runtime->private_data; snd_assert(s != NULL, return -ENXIO); @@ -1546,7 +1546,7 @@ snd_m3_pcm_prepare(snd_pcm_substream_t *subs) * get current pointer */ static unsigned int -snd_m3_get_pointer(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) +snd_m3_get_pointer(struct snd_m3 *chip, struct m3_dma *s, struct snd_pcm_substream *subs) { u16 hi = 0, lo = 0; int retry = 10; @@ -1571,11 +1571,11 @@ snd_m3_get_pointer(m3_t *chip, m3_dma_t *s, snd_pcm_substream_t *subs) } static snd_pcm_uframes_t -snd_m3_pcm_pointer(snd_pcm_substream_t * subs) +snd_m3_pcm_pointer(struct snd_pcm_substream *subs) { - m3_t *chip = snd_pcm_substream_chip(subs); + struct snd_m3 *chip = snd_pcm_substream_chip(subs); unsigned int ptr; - m3_dma_t *s = (m3_dma_t*)subs->runtime->private_data; + struct m3_dma *s = subs->runtime->private_data; snd_assert(s != NULL, return 0); spin_lock(&chip->reg_lock); @@ -1587,9 +1587,9 @@ snd_m3_pcm_pointer(snd_pcm_substream_t * subs) /* update pointer */ /* spinlock held! */ -static void snd_m3_update_ptr(m3_t *chip, m3_dma_t *s) +static void snd_m3_update_ptr(struct snd_m3 *chip, struct m3_dma *s) { - snd_pcm_substream_t *subs = s->substream; + struct snd_pcm_substream *subs = s->substream; unsigned int hwptr; int diff; @@ -1610,7 +1610,7 @@ static void snd_m3_update_ptr(m3_t *chip, m3_dma_t *s) static void snd_m3_update_hw_volume(unsigned long private_data) { - m3_t *chip = (m3_t *) private_data; + struct snd_m3 *chip = (struct snd_m3 *) private_data; int x, val; unsigned long flags; @@ -1673,7 +1673,7 @@ static void snd_m3_update_hw_volume(unsigned long private_data) static irqreturn_t snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - m3_t *chip = dev_id; + struct snd_m3 *chip = dev_id; u8 status; int i; @@ -1698,7 +1698,7 @@ snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs) /* update adc/dac info if it was a timer int */ spin_lock(&chip->reg_lock); for (i = 0; i < chip->num_substreams; i++) { - m3_dma_t *s = &chip->substreams[i]; + struct m3_dma *s = &chip->substreams[i]; if (s->running) snd_m3_update_ptr(chip, s); } @@ -1722,7 +1722,7 @@ snd_m3_interrupt(int irq, void *dev_id, struct pt_regs *regs) /* */ -static snd_pcm_hardware_t snd_m3_playback = +static struct snd_pcm_hardware snd_m3_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -1743,7 +1743,7 @@ static snd_pcm_hardware_t snd_m3_playback = .periods_max = 1024, }; -static snd_pcm_hardware_t snd_m3_capture = +static struct snd_pcm_hardware snd_m3_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | @@ -1769,10 +1769,10 @@ static snd_pcm_hardware_t snd_m3_capture = */ static int -snd_m3_substream_open(m3_t *chip, snd_pcm_substream_t *subs) +snd_m3_substream_open(struct snd_m3 *chip, struct snd_pcm_substream *subs) { int i; - m3_dma_t *s; + struct m3_dma *s; spin_lock_irq(&chip->reg_lock); for (i = 0; i < chip->num_substreams; i++) { @@ -1802,9 +1802,9 @@ __found: } static void -snd_m3_substream_close(m3_t *chip, snd_pcm_substream_t *subs) +snd_m3_substream_close(struct snd_m3 *chip, struct snd_pcm_substream *subs) { - m3_dma_t *s = (m3_dma_t*) subs->runtime->private_data; + struct m3_dma *s = subs->runtime->private_data; if (s == NULL) return; /* not opened properly */ @@ -1824,10 +1824,10 @@ snd_m3_substream_close(m3_t *chip, snd_pcm_substream_t *subs) } static int -snd_m3_playback_open(snd_pcm_substream_t *subs) +snd_m3_playback_open(struct snd_pcm_substream *subs) { - m3_t *chip = snd_pcm_substream_chip(subs); - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_m3 *chip = snd_pcm_substream_chip(subs); + struct snd_pcm_runtime *runtime = subs->runtime; int err; if ((err = snd_m3_substream_open(chip, subs)) < 0) @@ -1840,19 +1840,19 @@ snd_m3_playback_open(snd_pcm_substream_t *subs) } static int -snd_m3_playback_close(snd_pcm_substream_t *subs) +snd_m3_playback_close(struct snd_pcm_substream *subs) { - m3_t *chip = snd_pcm_substream_chip(subs); + struct snd_m3 *chip = snd_pcm_substream_chip(subs); snd_m3_substream_close(chip, subs); return 0; } static int -snd_m3_capture_open(snd_pcm_substream_t *subs) +snd_m3_capture_open(struct snd_pcm_substream *subs) { - m3_t *chip = snd_pcm_substream_chip(subs); - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_m3 *chip = snd_pcm_substream_chip(subs); + struct snd_pcm_runtime *runtime = subs->runtime; int err; if ((err = snd_m3_substream_open(chip, subs)) < 0) @@ -1865,9 +1865,9 @@ snd_m3_capture_open(snd_pcm_substream_t *subs) } static int -snd_m3_capture_close(snd_pcm_substream_t *subs) +snd_m3_capture_close(struct snd_pcm_substream *subs) { - m3_t *chip = snd_pcm_substream_chip(subs); + struct snd_m3 *chip = snd_pcm_substream_chip(subs); snd_m3_substream_close(chip, subs); return 0; @@ -1877,7 +1877,7 @@ snd_m3_capture_close(snd_pcm_substream_t *subs) * create pcm instance */ -static snd_pcm_ops_t snd_m3_playback_ops = { +static struct snd_pcm_ops snd_m3_playback_ops = { .open = snd_m3_playback_open, .close = snd_m3_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1888,7 +1888,7 @@ static snd_pcm_ops_t snd_m3_playback_ops = { .pointer = snd_m3_pcm_pointer, }; -static snd_pcm_ops_t snd_m3_capture_ops = { +static struct snd_pcm_ops snd_m3_capture_ops = { .open = snd_m3_capture_open, .close = snd_m3_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1900,9 +1900,9 @@ static snd_pcm_ops_t snd_m3_capture_ops = { }; static int __devinit -snd_m3_pcm(m3_t * chip, int device) +snd_m3_pcm(struct snd_m3 * chip, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; err = snd_pcm_new(chip->card, chip->card->driver, device, @@ -1933,7 +1933,7 @@ snd_m3_pcm(m3_t * chip, int device) * Wait for the ac97 serial bus to be free. * return nonzero if the bus is still busy. */ -static int snd_m3_ac97_wait(m3_t *chip) +static int snd_m3_ac97_wait(struct snd_m3 *chip) { int i = 10000; @@ -1947,9 +1947,9 @@ static int snd_m3_ac97_wait(m3_t *chip) } static unsigned short -snd_m3_ac97_read(ac97_t *ac97, unsigned short reg) +snd_m3_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - m3_t *chip = ac97->private_data; + struct snd_m3 *chip = ac97->private_data; unsigned long flags; unsigned short data; @@ -1965,9 +1965,9 @@ snd_m3_ac97_read(ac97_t *ac97, unsigned short reg) } static void -snd_m3_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +snd_m3_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - m3_t *chip = ac97->private_data; + struct snd_m3 *chip = ac97->private_data; unsigned long flags; if (snd_m3_ac97_wait(chip)) @@ -1994,7 +1994,7 @@ static void snd_m3_remote_codec_config(int io, int isremote) /* * hack, returns non zero on err */ -static int snd_m3_try_read_vendor(m3_t *chip) +static int snd_m3_try_read_vendor(struct snd_m3 *chip) { u16 ret; @@ -2011,7 +2011,7 @@ static int snd_m3_try_read_vendor(m3_t *chip) return (ret == 0) || (ret == 0xffff); } -static void snd_m3_ac97_reset(m3_t *chip) +static void snd_m3_ac97_reset(struct snd_m3 *chip) { u16 dir; int delay1 = 0, delay2 = 0, i; @@ -2078,13 +2078,13 @@ static void snd_m3_ac97_reset(m3_t *chip) #endif } -static int __devinit snd_m3_mixer(m3_t *chip) +static int __devinit snd_m3_mixer(struct snd_m3 *chip) { - ac97_bus_t *pbus; - ac97_template_t ac97; - snd_ctl_elem_id_t id; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; + struct snd_ctl_elem_id id; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_m3_ac97_write, .read = snd_m3_ac97_read, }; @@ -2254,7 +2254,7 @@ static u16 minisrc_lpf[MINISRC_LPF_LEN] __devinitdata = { 0X1023, 0X1AA9, 0X0B60, 0XEFDD, 0X186F }; -static void __devinit snd_m3_assp_init(m3_t *chip) +static void __devinit snd_m3_assp_init(struct snd_m3 *chip) { unsigned int i; @@ -2343,7 +2343,7 @@ static void __devinit snd_m3_assp_init(m3_t *chip) } -static int __devinit snd_m3_assp_client_init(m3_t *chip, m3_dma_t *s, int index) +static int __devinit snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma *s, int index) { int data_bytes = 2 * ( MINISRC_TMP_BUFFER_SIZE / 2 + MINISRC_IN_BUFFER_SIZE / 2 + @@ -2389,7 +2389,7 @@ static int __devinit snd_m3_assp_client_init(m3_t *chip, m3_dma_t *s, int index) * this needs more magic for 4 speaker, but.. */ static void -snd_m3_amp_enable(m3_t *chip, int enable) +snd_m3_amp_enable(struct snd_m3 *chip, int enable) { int io = chip->iobase; u16 gpo, polarity; @@ -2413,7 +2413,7 @@ snd_m3_amp_enable(m3_t *chip, int enable) } static int -snd_m3_chip_init(m3_t *chip) +snd_m3_chip_init(struct snd_m3 *chip) { struct pci_dev *pcidev = chip->pci; unsigned long io = chip->iobase; @@ -2486,7 +2486,7 @@ snd_m3_chip_init(m3_t *chip) } static void -snd_m3_enable_ints(m3_t *chip) +snd_m3_enable_ints(struct snd_m3 *chip) { unsigned long io = chip->iobase; unsigned short val; @@ -2504,9 +2504,9 @@ snd_m3_enable_ints(m3_t *chip) /* */ -static int snd_m3_free(m3_t *chip) +static int snd_m3_free(struct snd_m3 *chip) { - m3_dma_t *s; + struct m3_dma *s; int i; if (chip->substreams) { @@ -2530,7 +2530,7 @@ static int snd_m3_free(m3_t *chip) if (chip->irq >= 0) { synchronize_irq(chip->irq); - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); } if (chip->iobase) @@ -2546,9 +2546,9 @@ static int snd_m3_free(m3_t *chip) * APM support */ #ifdef CONFIG_PM -static int m3_suspend(snd_card_t *card, pm_message_t state) +static int m3_suspend(struct snd_card *card, pm_message_t state) { - m3_t *chip = card->pm_private_data; + struct snd_m3 *chip = card->pm_private_data; int i, index; if (chip->suspend_mem == NULL) @@ -2578,9 +2578,9 @@ static int m3_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int m3_resume(snd_card_t *card) +static int m3_resume(struct snd_card *card) { - m3_t *chip = card->pm_private_data; + struct snd_m3 *chip = card->pm_private_data; int i, index; if (chip->suspend_mem == NULL) @@ -2625,23 +2625,23 @@ static int m3_resume(snd_card_t *card) /* */ -static int snd_m3_dev_free(snd_device_t *device) +static int snd_m3_dev_free(struct snd_device *device) { - m3_t *chip = device->device_data; + struct snd_m3 *chip = device->device_data; return snd_m3_free(chip); } static int __devinit -snd_m3_create(snd_card_t *card, struct pci_dev *pci, +snd_m3_create(struct snd_card *card, struct pci_dev *pci, int enable_amp, int amp_gpio, - m3_t **chip_ret) + struct snd_m3 **chip_ret) { - m3_t *chip; + struct snd_m3 *chip; int i, err; struct m3_quirk *quirk; struct m3_hv_quirk *hv_quirk; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_m3_dev_free, }; @@ -2710,13 +2710,13 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, chip->amp_gpio = GPO_EXT_AMP_M3; chip->num_substreams = NR_DSPS; - chip->substreams = kmalloc(sizeof(m3_dma_t) * chip->num_substreams, GFP_KERNEL); + chip->substreams = kcalloc(chip->num_substreams, sizeof(struct m3_dma), + GFP_KERNEL); if (chip->substreams == NULL) { kfree(chip); pci_disable_device(pci); return -ENOMEM; } - memset(chip->substreams, 0, sizeof(m3_dma_t) * chip->num_substreams); if ((err = pci_request_regions(pci, card->driver)) < 0) { snd_m3_free(chip); @@ -2737,7 +2737,7 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, tasklet_init(&chip->hwvol_tq, snd_m3_update_hw_volume, (unsigned long)chip); if (request_irq(pci->irq, snd_m3_interrupt, SA_INTERRUPT|SA_SHIRQ, - card->driver, (void *)chip)) { + card->driver, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_m3_free(chip); return -ENOMEM; @@ -2761,8 +2761,7 @@ snd_m3_create(snd_card_t *card, struct pci_dev *pci, return err; for (i = 0; i < chip->num_substreams; i++) { - m3_dma_t *s = &chip->substreams[i]; - s->chip = chip; + struct m3_dma *s = &chip->substreams[i]; if ((err = snd_m3_assp_client_init(chip, s, i)) < 0) return err; } @@ -2786,8 +2785,8 @@ static int __devinit snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - m3_t *chip; + struct snd_card *card; + struct snd_m3 *chip; int err; /* don't pick up modems */ -- cgit v1.1 From 017ce80236c28bae9c2573307f1e76724232f287 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:05:25 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI RME32 Modules: RME32 driver Remove xxx_t typedefs from the PCI RME32 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/rme32.c | 332 +++++++++++++++++++++++++++--------------------------- 1 file changed, 166 insertions(+), 166 deletions(-) diff --git a/sound/pci/rme32.c b/sound/pci/rme32.c index 783df76..0cbef5f 100644 --- a/sound/pci/rme32.c +++ b/sound/pci/rme32.c @@ -192,7 +192,7 @@ MODULE_SUPPORTED_DEVICE("{{RME,Digi32}," "{RME,Digi32/8}," "{RME,Digi32 PRO}}"); #define RME32_PRO_REVISION_WITH_8414 150 -typedef struct snd_rme32 { +struct rme32 { spinlock_t lock; int irq; unsigned long port; @@ -205,8 +205,8 @@ typedef struct snd_rme32 { u8 rev; /* card revision number */ - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; int playback_frlog; /* log2 of framesize */ int capture_frlog; @@ -217,15 +217,15 @@ typedef struct snd_rme32 { unsigned int fullduplex_mode; int running; - snd_pcm_indirect_t playback_pcm; - snd_pcm_indirect_t capture_pcm; + struct snd_pcm_indirect playback_pcm; + struct snd_pcm_indirect capture_pcm; - snd_card_t *card; - snd_pcm_t *spdif_pcm; - snd_pcm_t *adat_pcm; + struct snd_card *card; + struct snd_pcm *spdif_pcm; + struct snd_pcm *adat_pcm; struct pci_dev *pci; - snd_kcontrol_t *spdif_ctl; -} rme32_t; + struct snd_kcontrol *spdif_ctl; +}; static struct pci_device_id snd_rme32_ids[] = { {PCI_VENDOR_ID_XILINX_RME, PCI_DEVICE_ID_RME_DIGI32, @@ -242,17 +242,17 @@ MODULE_DEVICE_TABLE(pci, snd_rme32_ids); #define RME32_ISWORKING(rme32) ((rme32)->wcreg & RME32_WCR_START) #define RME32_PRO_WITH_8414(rme32) ((rme32)->pci->device == PCI_DEVICE_ID_RME_DIGI32_PRO && (rme32)->rev == RME32_PRO_REVISION_WITH_8414) -static int snd_rme32_playback_prepare(snd_pcm_substream_t * substream); +static int snd_rme32_playback_prepare(struct snd_pcm_substream *substream); -static int snd_rme32_capture_prepare(snd_pcm_substream_t * substream); +static int snd_rme32_capture_prepare(struct snd_pcm_substream *substream); -static int snd_rme32_pcm_trigger(snd_pcm_substream_t * substream, int cmd); +static int snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd); -static void snd_rme32_proc_init(rme32_t * rme32); +static void snd_rme32_proc_init(struct rme32 * rme32); -static int snd_rme32_create_switches(snd_card_t * card, rme32_t * rme32); +static int snd_rme32_create_switches(struct snd_card *card, struct rme32 * rme32); -static inline unsigned int snd_rme32_pcm_byteptr(rme32_t * rme32) +static inline unsigned int snd_rme32_pcm_byteptr(struct rme32 * rme32) { return (readl(rme32->iobase + RME32_IO_GET_POS) & RME32_RCR_AUDIO_ADDR_MASK); @@ -272,11 +272,11 @@ static int snd_rme32_ratecode(int rate) } /* silence callback for halfduplex mode */ -static int snd_rme32_playback_silence(snd_pcm_substream_t * substream, int channel, /* not used (interleaved data) */ +static int snd_rme32_playback_silence(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); count <<= rme32->playback_frlog; pos <<= rme32->playback_frlog; memset_io(rme32->iobase + RME32_IO_DATA_BUFFER + pos, 0, count); @@ -284,11 +284,11 @@ static int snd_rme32_playback_silence(snd_pcm_substream_t * substream, int chann } /* copy callback for halfduplex mode */ -static int snd_rme32_playback_copy(snd_pcm_substream_t * substream, int channel, /* not used (interleaved data) */ +static int snd_rme32_playback_copy(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); count <<= rme32->playback_frlog; pos <<= rme32->playback_frlog; if (copy_from_user_toio(rme32->iobase + RME32_IO_DATA_BUFFER + pos, @@ -298,11 +298,11 @@ static int snd_rme32_playback_copy(snd_pcm_substream_t * substream, int channel, } /* copy callback for halfduplex mode */ -static int snd_rme32_capture_copy(snd_pcm_substream_t * substream, int channel, /* not used (interleaved data) */ +static int snd_rme32_capture_copy(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); count <<= rme32->capture_frlog; pos <<= rme32->capture_frlog; if (copy_to_user_fromio(dst, @@ -315,7 +315,7 @@ static int snd_rme32_capture_copy(snd_pcm_substream_t * substream, int channel, /* * SPDIF I/O capabilites (half-duplex mode) */ -static snd_pcm_hardware_t snd_rme32_spdif_info = { +static struct snd_pcm_hardware snd_rme32_spdif_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -341,7 +341,7 @@ static snd_pcm_hardware_t snd_rme32_spdif_info = { /* * ADAT I/O capabilites (half-duplex mode) */ -static snd_pcm_hardware_t snd_rme32_adat_info = +static struct snd_pcm_hardware snd_rme32_adat_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -366,7 +366,7 @@ static snd_pcm_hardware_t snd_rme32_adat_info = /* * SPDIF I/O capabilites (full-duplex mode) */ -static snd_pcm_hardware_t snd_rme32_spdif_fd_info = { +static struct snd_pcm_hardware snd_rme32_spdif_fd_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -392,7 +392,7 @@ static snd_pcm_hardware_t snd_rme32_spdif_fd_info = { /* * ADAT I/O capabilites (full-duplex mode) */ -static snd_pcm_hardware_t snd_rme32_adat_fd_info = +static struct snd_pcm_hardware snd_rme32_adat_fd_info = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -414,14 +414,14 @@ static snd_pcm_hardware_t snd_rme32_adat_fd_info = .fifo_size = 0, }; -static void snd_rme32_reset_dac(rme32_t *rme32) +static void snd_rme32_reset_dac(struct rme32 *rme32) { writel(rme32->wcreg | RME32_WCR_PD, rme32->iobase + RME32_IO_CONTROL_REGISTER); writel(rme32->wcreg, rme32->iobase + RME32_IO_CONTROL_REGISTER); } -static int snd_rme32_playback_getrate(rme32_t * rme32) +static int snd_rme32_playback_getrate(struct rme32 * rme32) { int rate; @@ -443,7 +443,7 @@ static int snd_rme32_playback_getrate(rme32_t * rme32) return (rme32->wcreg & RME32_WCR_DS_BM) ? rate << 1 : rate; } -static int snd_rme32_capture_getrate(rme32_t * rme32, int *is_adat) +static int snd_rme32_capture_getrate(struct rme32 * rme32, int *is_adat) { int n; @@ -505,7 +505,7 @@ static int snd_rme32_capture_getrate(rme32_t * rme32, int *is_adat) return -1; } -static int snd_rme32_playback_setrate(rme32_t * rme32, int rate) +static int snd_rme32_playback_setrate(struct rme32 * rme32, int rate) { int ds; @@ -561,7 +561,7 @@ static int snd_rme32_playback_setrate(rme32_t * rme32, int rate) return 0; } -static int snd_rme32_setclockmode(rme32_t * rme32, int mode) +static int snd_rme32_setclockmode(struct rme32 * rme32, int mode) { switch (mode) { case RME32_CLOCKMODE_SLAVE: @@ -591,13 +591,13 @@ static int snd_rme32_setclockmode(rme32_t * rme32, int mode) return 0; } -static int snd_rme32_getclockmode(rme32_t * rme32) +static int snd_rme32_getclockmode(struct rme32 * rme32) { return ((rme32->wcreg >> RME32_WCR_BITPOS_FREQ_0) & 1) + (((rme32->wcreg >> RME32_WCR_BITPOS_FREQ_1) & 1) << 1); } -static int snd_rme32_setinputtype(rme32_t * rme32, int type) +static int snd_rme32_setinputtype(struct rme32 * rme32, int type) { switch (type) { case RME32_INPUT_OPTICAL: @@ -623,14 +623,14 @@ static int snd_rme32_setinputtype(rme32_t * rme32, int type) return 0; } -static int snd_rme32_getinputtype(rme32_t * rme32) +static int snd_rme32_getinputtype(struct rme32 * rme32) { return ((rme32->wcreg >> RME32_WCR_BITPOS_INP_0) & 1) + (((rme32->wcreg >> RME32_WCR_BITPOS_INP_1) & 1) << 1); } static void -snd_rme32_setframelog(rme32_t * rme32, int n_channels, int is_playback) +snd_rme32_setframelog(struct rme32 * rme32, int n_channels, int is_playback) { int frlog; @@ -649,7 +649,7 @@ snd_rme32_setframelog(rme32_t * rme32, int n_channels, int is_playback) } } -static int snd_rme32_setformat(rme32_t * rme32, int format) +static int snd_rme32_setformat(struct rme32 * rme32, int format) { switch (format) { case SNDRV_PCM_FORMAT_S16_LE: @@ -666,12 +666,12 @@ static int snd_rme32_setformat(rme32_t * rme32, int format) } static int -snd_rme32_playback_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * params) +snd_rme32_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { int err, rate, dummy; - rme32_t *rme32 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme32 *rme32 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (rme32->fullduplex_mode) { err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); @@ -721,12 +721,12 @@ snd_rme32_playback_hw_params(snd_pcm_substream_t * substream, } static int -snd_rme32_capture_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * params) +snd_rme32_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { int err, isadat, rate; - rme32_t *rme32 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme32 *rme32 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (rme32->fullduplex_mode) { err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); @@ -782,15 +782,15 @@ snd_rme32_capture_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_rme32_pcm_hw_free(snd_pcm_substream_t * substream) +static int snd_rme32_pcm_hw_free(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); if (! rme32->fullduplex_mode) return 0; return snd_pcm_lib_free_pages(substream); } -static void snd_rme32_pcm_start(rme32_t * rme32, int from_pause) +static void snd_rme32_pcm_start(struct rme32 * rme32, int from_pause) { if (!from_pause) { writel(0, rme32->iobase + RME32_IO_RESET_POS); @@ -800,7 +800,7 @@ static void snd_rme32_pcm_start(rme32_t * rme32, int from_pause) writel(rme32->wcreg, rme32->iobase + RME32_IO_CONTROL_REGISTER); } -static void snd_rme32_pcm_stop(rme32_t * rme32, int to_pause) +static void snd_rme32_pcm_stop(struct rme32 * rme32, int to_pause) { /* * Check if there is an unconfirmed IRQ, if so confirm it, or else @@ -821,7 +821,7 @@ static void snd_rme32_pcm_stop(rme32_t * rme32, int to_pause) static irqreturn_t snd_rme32_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - rme32_t *rme32 = (rme32_t *) dev_id; + struct rme32 *rme32 = (struct rme32 *) dev_id; rme32->rcreg = readl(rme32->iobase + RME32_IO_CONTROL_REGISTER); if (!(rme32->rcreg & RME32_RCR_IRQ)) { @@ -841,13 +841,13 @@ snd_rme32_interrupt(int irq, void *dev_id, struct pt_regs *regs) static unsigned int period_bytes[] = { RME32_BLOCK_SIZE }; -static snd_pcm_hw_constraint_list_t hw_constraints_period_bytes = { +static struct snd_pcm_hw_constraint_list hw_constraints_period_bytes = { .count = ARRAY_SIZE(period_bytes), .list = period_bytes, .mask = 0 }; -static void snd_rme32_set_buffer_constraint(rme32_t *rme32, snd_pcm_runtime_t *runtime) +static void snd_rme32_set_buffer_constraint(struct rme32 *rme32, struct snd_pcm_runtime *runtime) { if (! rme32->fullduplex_mode) { snd_pcm_hw_constraint_minmax(runtime, @@ -859,11 +859,11 @@ static void snd_rme32_set_buffer_constraint(rme32_t *rme32, snd_pcm_runtime_t *r } } -static int snd_rme32_playback_spdif_open(snd_pcm_substream_t * substream) +static int snd_rme32_playback_spdif_open(struct snd_pcm_substream *substream) { int rate, dummy; - rme32_t *rme32 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme32 *rme32 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_set_sync(substream); @@ -902,11 +902,11 @@ static int snd_rme32_playback_spdif_open(snd_pcm_substream_t * substream) return 0; } -static int snd_rme32_capture_spdif_open(snd_pcm_substream_t * substream) +static int snd_rme32_capture_spdif_open(struct snd_pcm_substream *substream) { int isadat, rate; - rme32_t *rme32 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme32 *rme32 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_set_sync(substream); @@ -941,11 +941,11 @@ static int snd_rme32_capture_spdif_open(snd_pcm_substream_t * substream) } static int -snd_rme32_playback_adat_open(snd_pcm_substream_t *substream) +snd_rme32_playback_adat_open(struct snd_pcm_substream *substream) { int rate, dummy; - rme32_t *rme32 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme32 *rme32 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_set_sync(substream); @@ -976,11 +976,11 @@ snd_rme32_playback_adat_open(snd_pcm_substream_t *substream) } static int -snd_rme32_capture_adat_open(snd_pcm_substream_t *substream) +snd_rme32_capture_adat_open(struct snd_pcm_substream *substream) { int isadat, rate; - rme32_t *rme32 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme32 *rme32 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; if (rme32->fullduplex_mode) runtime->hw = snd_rme32_adat_fd_info; @@ -1009,9 +1009,9 @@ snd_rme32_capture_adat_open(snd_pcm_substream_t *substream) return 0; } -static int snd_rme32_playback_close(snd_pcm_substream_t * substream) +static int snd_rme32_playback_close(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); int spdif = 0; spin_lock_irq(&rme32->lock); @@ -1028,9 +1028,9 @@ static int snd_rme32_playback_close(snd_pcm_substream_t * substream) return 0; } -static int snd_rme32_capture_close(snd_pcm_substream_t * substream) +static int snd_rme32_capture_close(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); spin_lock_irq(&rme32->lock); rme32->capture_substream = NULL; @@ -1039,9 +1039,9 @@ static int snd_rme32_capture_close(snd_pcm_substream_t * substream) return 0; } -static int snd_rme32_playback_prepare(snd_pcm_substream_t * substream) +static int snd_rme32_playback_prepare(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); spin_lock_irq(&rme32->lock); if (rme32->fullduplex_mode) { @@ -1058,9 +1058,9 @@ static int snd_rme32_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_rme32_capture_prepare(snd_pcm_substream_t * substream) +static int snd_rme32_capture_prepare(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); spin_lock_irq(&rme32->lock); if (rme32->fullduplex_mode) { @@ -1076,11 +1076,11 @@ static int snd_rme32_capture_prepare(snd_pcm_substream_t * substream) } static int -snd_rme32_pcm_trigger(snd_pcm_substream_t * substream, int cmd) +snd_rme32_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); struct list_head *pos; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; spin_lock(&rme32->lock); snd_pcm_group_for_each(pos, substream) { @@ -1144,33 +1144,33 @@ snd_rme32_pcm_trigger(snd_pcm_substream_t * substream, int cmd) /* pointer callback for halfduplex mode */ static snd_pcm_uframes_t -snd_rme32_playback_pointer(snd_pcm_substream_t * substream) +snd_rme32_playback_pointer(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); return snd_rme32_pcm_byteptr(rme32) >> rme32->playback_frlog; } static snd_pcm_uframes_t -snd_rme32_capture_pointer(snd_pcm_substream_t * substream) +snd_rme32_capture_pointer(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); return snd_rme32_pcm_byteptr(rme32) >> rme32->capture_frlog; } /* ack and pointer callbacks for fullduplex mode */ -static void snd_rme32_pb_trans_copy(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, size_t bytes) +static void snd_rme32_pb_trans_copy(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); memcpy_toio(rme32->iobase + RME32_IO_DATA_BUFFER + rec->hw_data, substream->runtime->dma_area + rec->sw_data, bytes); } -static int snd_rme32_playback_fd_ack(snd_pcm_substream_t *substream) +static int snd_rme32_playback_fd_ack(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); - snd_pcm_indirect_t *rec, *cprec; + struct rme32 *rme32 = snd_pcm_substream_chip(substream); + struct snd_pcm_indirect *rec, *cprec; rec = &rme32->playback_pcm; cprec = &rme32->capture_pcm; @@ -1184,41 +1184,41 @@ static int snd_rme32_playback_fd_ack(snd_pcm_substream_t *substream) return 0; } -static void snd_rme32_cp_trans_copy(snd_pcm_substream_t *substream, - snd_pcm_indirect_t *rec, size_t bytes) +static void snd_rme32_cp_trans_copy(struct snd_pcm_substream *substream, + struct snd_pcm_indirect *rec, size_t bytes) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); memcpy_fromio(substream->runtime->dma_area + rec->sw_data, rme32->iobase + RME32_IO_DATA_BUFFER + rec->hw_data, bytes); } -static int snd_rme32_capture_fd_ack(snd_pcm_substream_t *substream) +static int snd_rme32_capture_fd_ack(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); snd_pcm_indirect_capture_transfer(substream, &rme32->capture_pcm, snd_rme32_cp_trans_copy); return 0; } static snd_pcm_uframes_t -snd_rme32_playback_fd_pointer(snd_pcm_substream_t * substream) +snd_rme32_playback_fd_pointer(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); return snd_pcm_indirect_playback_pointer(substream, &rme32->playback_pcm, snd_rme32_pcm_byteptr(rme32)); } static snd_pcm_uframes_t -snd_rme32_capture_fd_pointer(snd_pcm_substream_t * substream) +snd_rme32_capture_fd_pointer(struct snd_pcm_substream *substream) { - rme32_t *rme32 = snd_pcm_substream_chip(substream); + struct rme32 *rme32 = snd_pcm_substream_chip(substream); return snd_pcm_indirect_capture_pointer(substream, &rme32->capture_pcm, snd_rme32_pcm_byteptr(rme32)); } /* for halfduplex mode */ -static snd_pcm_ops_t snd_rme32_playback_spdif_ops = { +static struct snd_pcm_ops snd_rme32_playback_spdif_ops = { .open = snd_rme32_playback_spdif_open, .close = snd_rme32_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1232,7 +1232,7 @@ static snd_pcm_ops_t snd_rme32_playback_spdif_ops = { .mmap = snd_pcm_lib_mmap_iomem, }; -static snd_pcm_ops_t snd_rme32_capture_spdif_ops = { +static struct snd_pcm_ops snd_rme32_capture_spdif_ops = { .open = snd_rme32_capture_spdif_open, .close = snd_rme32_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1245,7 +1245,7 @@ static snd_pcm_ops_t snd_rme32_capture_spdif_ops = { .mmap = snd_pcm_lib_mmap_iomem, }; -static snd_pcm_ops_t snd_rme32_playback_adat_ops = { +static struct snd_pcm_ops snd_rme32_playback_adat_ops = { .open = snd_rme32_playback_adat_open, .close = snd_rme32_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1258,7 +1258,7 @@ static snd_pcm_ops_t snd_rme32_playback_adat_ops = { .mmap = snd_pcm_lib_mmap_iomem, }; -static snd_pcm_ops_t snd_rme32_capture_adat_ops = { +static struct snd_pcm_ops snd_rme32_capture_adat_ops = { .open = snd_rme32_capture_adat_open, .close = snd_rme32_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1271,7 +1271,7 @@ static snd_pcm_ops_t snd_rme32_capture_adat_ops = { }; /* for fullduplex mode */ -static snd_pcm_ops_t snd_rme32_playback_spdif_fd_ops = { +static struct snd_pcm_ops snd_rme32_playback_spdif_fd_ops = { .open = snd_rme32_playback_spdif_open, .close = snd_rme32_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1283,7 +1283,7 @@ static snd_pcm_ops_t snd_rme32_playback_spdif_fd_ops = { .ack = snd_rme32_playback_fd_ack, }; -static snd_pcm_ops_t snd_rme32_capture_spdif_fd_ops = { +static struct snd_pcm_ops snd_rme32_capture_spdif_fd_ops = { .open = snd_rme32_capture_spdif_open, .close = snd_rme32_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1295,7 +1295,7 @@ static snd_pcm_ops_t snd_rme32_capture_spdif_fd_ops = { .ack = snd_rme32_capture_fd_ack, }; -static snd_pcm_ops_t snd_rme32_playback_adat_fd_ops = { +static struct snd_pcm_ops snd_rme32_playback_adat_fd_ops = { .open = snd_rme32_playback_adat_open, .close = snd_rme32_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1306,7 +1306,7 @@ static snd_pcm_ops_t snd_rme32_playback_adat_fd_ops = { .ack = snd_rme32_playback_fd_ack, }; -static snd_pcm_ops_t snd_rme32_capture_adat_fd_ops = { +static struct snd_pcm_ops snd_rme32_capture_adat_fd_ops = { .open = snd_rme32_capture_adat_open, .close = snd_rme32_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1319,7 +1319,7 @@ static snd_pcm_ops_t snd_rme32_capture_adat_fd_ops = { static void snd_rme32_free(void *private_data) { - rme32_t *rme32 = (rme32_t *) private_data; + struct rme32 *rme32 = (struct rme32 *) private_data; if (rme32 == NULL) { return; @@ -1340,20 +1340,20 @@ static void snd_rme32_free(void *private_data) pci_disable_device(rme32->pci); } -static void snd_rme32_free_spdif_pcm(snd_pcm_t * pcm) +static void snd_rme32_free_spdif_pcm(struct snd_pcm *pcm) { - rme32_t *rme32 = (rme32_t *) pcm->private_data; + struct rme32 *rme32 = (struct rme32 *) pcm->private_data; rme32->spdif_pcm = NULL; } static void -snd_rme32_free_adat_pcm(snd_pcm_t *pcm) +snd_rme32_free_adat_pcm(struct snd_pcm *pcm) { - rme32_t *rme32 = (rme32_t *) pcm->private_data; + struct rme32 *rme32 = (struct rme32 *) pcm->private_data; rme32->adat_pcm = NULL; } -static int __devinit snd_rme32_create(rme32_t * rme32) +static int __devinit snd_rme32_create(struct rme32 * rme32) { struct pci_dev *pci = rme32->pci; int err; @@ -1479,10 +1479,10 @@ static int __devinit snd_rme32_create(rme32_t * rme32) */ static void -snd_rme32_proc_read(snd_info_entry_t * entry, snd_info_buffer_t * buffer) +snd_rme32_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer) { int n; - rme32_t *rme32 = (rme32_t *) entry->private_data; + struct rme32 *rme32 = (struct rme32 *) entry->private_data; rme32->rcreg = readl(rme32->iobase + RME32_IO_CONTROL_REGISTER); @@ -1573,9 +1573,9 @@ snd_rme32_proc_read(snd_info_entry_t * entry, snd_info_buffer_t * buffer) } } -static void __devinit snd_rme32_proc_init(rme32_t * rme32) +static void __devinit snd_rme32_proc_init(struct rme32 * rme32) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(rme32->card, "rme32", &entry)) snd_info_set_text_ops(entry, rme32, 1024, snd_rme32_proc_read); @@ -1586,8 +1586,8 @@ static void __devinit snd_rme32_proc_init(rme32_t * rme32) */ static int -snd_rme32_info_loopback_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +snd_rme32_info_loopback_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1596,10 +1596,10 @@ snd_rme32_info_loopback_control(snd_kcontrol_t * kcontrol, return 0; } static int -snd_rme32_get_loopback_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_rme32_get_loopback_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme32->lock); ucontrol->value.integer.value[0] = @@ -1608,10 +1608,10 @@ snd_rme32_get_loopback_control(snd_kcontrol_t * kcontrol, return 0; } static int -snd_rme32_put_loopback_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_rme32_put_loopback_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1630,10 +1630,10 @@ snd_rme32_put_loopback_control(snd_kcontrol_t * kcontrol, } static int -snd_rme32_info_inputtype_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +snd_rme32_info_inputtype_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); static char *texts[4] = { "Optical", "Coaxial", "Internal", "XLR" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -1660,10 +1660,10 @@ snd_rme32_info_inputtype_control(snd_kcontrol_t * kcontrol, return 0; } static int -snd_rme32_get_inputtype_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_rme32_get_inputtype_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); unsigned int items = 3; spin_lock_irq(&rme32->lock); @@ -1689,10 +1689,10 @@ snd_rme32_get_inputtype_control(snd_kcontrol_t * kcontrol, return 0; } static int -snd_rme32_put_inputtype_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_rme32_put_inputtype_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); unsigned int val; int change, items = 3; @@ -1718,8 +1718,8 @@ snd_rme32_put_inputtype_control(snd_kcontrol_t * kcontrol, } static int -snd_rme32_info_clockmode_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +snd_rme32_info_clockmode_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "AutoSync", "Internal 32.0kHz", @@ -1737,10 +1737,10 @@ snd_rme32_info_clockmode_control(snd_kcontrol_t * kcontrol, return 0; } static int -snd_rme32_get_clockmode_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_rme32_get_clockmode_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme32->lock); ucontrol->value.enumerated.item[0] = snd_rme32_getclockmode(rme32); @@ -1748,10 +1748,10 @@ snd_rme32_get_clockmode_control(snd_kcontrol_t * kcontrol, return 0; } static int -snd_rme32_put_clockmode_control(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +snd_rme32_put_clockmode_control(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1763,7 +1763,7 @@ snd_rme32_put_clockmode_control(snd_kcontrol_t * kcontrol, return change; } -static u32 snd_rme32_convert_from_aes(snd_aes_iec958_t * aes) +static u32 snd_rme32_convert_from_aes(struct snd_aes_iec958 * aes) { u32 val = 0; val |= (aes->status[0] & IEC958_AES0_PROFESSIONAL) ? RME32_WCR_PRO : 0; @@ -1774,7 +1774,7 @@ static u32 snd_rme32_convert_from_aes(snd_aes_iec958_t * aes) return val; } -static void snd_rme32_convert_to_aes(snd_aes_iec958_t * aes, u32 val) +static void snd_rme32_convert_to_aes(struct snd_aes_iec958 * aes, u32 val) { aes->status[0] = ((val & RME32_WCR_PRO) ? IEC958_AES0_PROFESSIONAL : 0); if (val & RME32_WCR_PRO) @@ -1783,28 +1783,28 @@ static void snd_rme32_convert_to_aes(snd_aes_iec958_t * aes, u32 val) aes->status[0] |= (val & RME32_WCR_EMP) ? IEC958_AES0_CON_EMPHASIS_5015 : 0; } -static int snd_rme32_control_spdif_info(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_rme32_control_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme32_control_spdif_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_rme32_control_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); snd_rme32_convert_to_aes(&ucontrol->value.iec958, rme32->wcreg_spdif); return 0; } -static int snd_rme32_control_spdif_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_rme32_control_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); int change; u32 val; @@ -1816,30 +1816,30 @@ static int snd_rme32_control_spdif_put(snd_kcontrol_t * kcontrol, return change; } -static int snd_rme32_control_spdif_stream_info(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_rme32_control_spdif_stream_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme32_control_spdif_stream_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * +static int snd_rme32_control_spdif_stream_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value * ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); snd_rme32_convert_to_aes(&ucontrol->value.iec958, rme32->wcreg_spdif_stream); return 0; } -static int snd_rme32_control_spdif_stream_put(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * +static int snd_rme32_control_spdif_stream_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value * ucontrol) { - rme32_t *rme32 = snd_kcontrol_chip(kcontrol); + struct rme32 *rme32 = snd_kcontrol_chip(kcontrol); int change; u32 val; @@ -1854,23 +1854,23 @@ static int snd_rme32_control_spdif_stream_put(snd_kcontrol_t * kcontrol, return change; } -static int snd_rme32_control_spdif_mask_info(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_rme32_control_spdif_mask_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme32_control_spdif_mask_get(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * +static int snd_rme32_control_spdif_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value * ucontrol) { ucontrol->value.iec958.status[0] = kcontrol->private_value; return 0; } -static snd_kcontrol_new_t snd_rme32_controls[] = { +static struct snd_kcontrol_new snd_rme32_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), @@ -1925,10 +1925,10 @@ static snd_kcontrol_new_t snd_rme32_controls[] = { } }; -static int snd_rme32_create_switches(snd_card_t * card, rme32_t * rme32) +static int snd_rme32_create_switches(struct snd_card *card, struct rme32 * rme32) { int idx, err; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; for (idx = 0; idx < (int)ARRAY_SIZE(snd_rme32_controls); idx++) { if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_rme32_controls[idx], rme32))) < 0) @@ -1944,7 +1944,7 @@ static int snd_rme32_create_switches(snd_card_t * card, rme32_t * rme32) * Card initialisation */ -static void snd_rme32_card_free(snd_card_t * card) +static void snd_rme32_card_free(struct snd_card *card) { snd_rme32_free(card->private_data); } @@ -1953,8 +1953,8 @@ static int __devinit snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - rme32_t *rme32; - snd_card_t *card; + struct rme32 *rme32; + struct snd_card *card; int err; if (dev >= SNDRV_CARDS) { @@ -1966,10 +1966,10 @@ snd_rme32_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) } if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(rme32_t))) == NULL) + sizeof(struct rme32))) == NULL) return -ENOMEM; card->private_free = snd_rme32_card_free; - rme32 = (rme32_t *) card->private_data; + rme32 = (struct rme32 *) card->private_data; rme32->card = card; rme32->pci = pci; snd_card_set_dev(card, &pci->dev); -- cgit v1.1 From a3aefd883dc8c17c2231d763630ffe5cd118d7e8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:05:37 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI RME96 Modules: RME96 driver Remove xxx_t typedefs from the PCI RME96 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/rme96.c | 320 +++++++++++++++++++++++++++--------------------------- 1 file changed, 160 insertions(+), 160 deletions(-) diff --git a/sound/pci/rme96.c b/sound/pci/rme96.c index 6d422ef..0e694b0 100644 --- a/sound/pci/rme96.c +++ b/sound/pci/rme96.c @@ -201,7 +201,7 @@ MODULE_PARM_DESC(enable, "Enable RME Digi96 soundcard."); #define RME96_AD1855_VOL_BITS 10 -typedef struct snd_rme96 { +struct rme96 { spinlock_t lock; int irq; unsigned long port; @@ -216,8 +216,8 @@ typedef struct snd_rme96 { u8 rev; /* card revision number */ - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; int playback_frlog; /* log2 of framesize */ int capture_frlog; @@ -225,12 +225,12 @@ typedef struct snd_rme96 { size_t playback_periodsize; /* in bytes, zero if not used */ size_t capture_periodsize; /* in bytes, zero if not used */ - snd_card_t *card; - snd_pcm_t *spdif_pcm; - snd_pcm_t *adat_pcm; + struct snd_card *card; + struct snd_pcm *spdif_pcm; + struct snd_pcm *adat_pcm; struct pci_dev *pci; - snd_kcontrol_t *spdif_ctl; -} rme96_t; + struct snd_kcontrol *spdif_ctl; +}; static struct pci_device_id snd_rme96_ids[] = { { PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_RME_DIGI96, @@ -257,44 +257,44 @@ MODULE_DEVICE_TABLE(pci, snd_rme96_ids); #define RME96_185X_MAX_OUT(rme96) ((1 << (RME96_DAC_IS_1852(rme96) ? RME96_AD1852_VOL_BITS : RME96_AD1855_VOL_BITS)) - 1) static int -snd_rme96_playback_prepare(snd_pcm_substream_t *substream); +snd_rme96_playback_prepare(struct snd_pcm_substream *substream); static int -snd_rme96_capture_prepare(snd_pcm_substream_t *substream); +snd_rme96_capture_prepare(struct snd_pcm_substream *substream); static int -snd_rme96_playback_trigger(snd_pcm_substream_t *substream, +snd_rme96_playback_trigger(struct snd_pcm_substream *substream, int cmd); static int -snd_rme96_capture_trigger(snd_pcm_substream_t *substream, +snd_rme96_capture_trigger(struct snd_pcm_substream *substream, int cmd); static snd_pcm_uframes_t -snd_rme96_playback_pointer(snd_pcm_substream_t *substream); +snd_rme96_playback_pointer(struct snd_pcm_substream *substream); static snd_pcm_uframes_t -snd_rme96_capture_pointer(snd_pcm_substream_t *substream); +snd_rme96_capture_pointer(struct snd_pcm_substream *substream); static void __devinit -snd_rme96_proc_init(rme96_t *rme96); +snd_rme96_proc_init(struct rme96 *rme96); static int -snd_rme96_create_switches(snd_card_t *card, - rme96_t *rme96); +snd_rme96_create_switches(struct snd_card *card, + struct rme96 *rme96); static int -snd_rme96_getinputtype(rme96_t *rme96); +snd_rme96_getinputtype(struct rme96 *rme96); static inline unsigned int -snd_rme96_playback_ptr(rme96_t *rme96) +snd_rme96_playback_ptr(struct rme96 *rme96) { return (readl(rme96->iobase + RME96_IO_GET_PLAY_POS) & RME96_RCR_AUDIO_ADDR_MASK) >> rme96->playback_frlog; } static inline unsigned int -snd_rme96_capture_ptr(rme96_t *rme96) +snd_rme96_capture_ptr(struct rme96 *rme96) { return (readl(rme96->iobase + RME96_IO_GET_REC_POS) & RME96_RCR_AUDIO_ADDR_MASK) >> rme96->capture_frlog; @@ -315,12 +315,12 @@ snd_rme96_ratecode(int rate) } static int -snd_rme96_playback_silence(snd_pcm_substream_t *substream, +snd_rme96_playback_silence(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, snd_pcm_uframes_t count) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); count <<= rme96->playback_frlog; pos <<= rme96->playback_frlog; memset_io(rme96->iobase + RME96_IO_PLAY_BUFFER + pos, @@ -329,13 +329,13 @@ snd_rme96_playback_silence(snd_pcm_substream_t *substream, } static int -snd_rme96_playback_copy(snd_pcm_substream_t *substream, +snd_rme96_playback_copy(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, void __user *src, snd_pcm_uframes_t count) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); count <<= rme96->playback_frlog; pos <<= rme96->playback_frlog; copy_from_user_toio(rme96->iobase + RME96_IO_PLAY_BUFFER + pos, src, @@ -344,13 +344,13 @@ snd_rme96_playback_copy(snd_pcm_substream_t *substream, } static int -snd_rme96_capture_copy(snd_pcm_substream_t *substream, +snd_rme96_capture_copy(struct snd_pcm_substream *substream, int channel, /* not used (interleaved data) */ snd_pcm_uframes_t pos, void __user *dst, snd_pcm_uframes_t count) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); count <<= rme96->capture_frlog; pos <<= rme96->capture_frlog; copy_to_user_fromio(dst, rme96->iobase + RME96_IO_REC_BUFFER + pos, @@ -361,7 +361,7 @@ snd_rme96_capture_copy(snd_pcm_substream_t *substream, /* * Digital output capabilites (S/PDIF) */ -static snd_pcm_hardware_t snd_rme96_playback_spdif_info = +static struct snd_pcm_hardware snd_rme96_playback_spdif_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -390,7 +390,7 @@ static snd_pcm_hardware_t snd_rme96_playback_spdif_info = /* * Digital input capabilites (S/PDIF) */ -static snd_pcm_hardware_t snd_rme96_capture_spdif_info = +static struct snd_pcm_hardware snd_rme96_capture_spdif_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -419,7 +419,7 @@ static snd_pcm_hardware_t snd_rme96_capture_spdif_info = /* * Digital output capabilites (ADAT) */ -static snd_pcm_hardware_t snd_rme96_playback_adat_info = +static struct snd_pcm_hardware snd_rme96_playback_adat_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -444,7 +444,7 @@ static snd_pcm_hardware_t snd_rme96_playback_adat_info = /* * Digital input capabilites (ADAT) */ -static snd_pcm_hardware_t snd_rme96_capture_adat_info = +static struct snd_pcm_hardware snd_rme96_capture_adat_info = { .info = (SNDRV_PCM_INFO_MMAP_IOMEM | SNDRV_PCM_INFO_MMAP_VALID | @@ -479,7 +479,7 @@ static snd_pcm_hardware_t snd_rme96_capture_adat_info = * the volume. */ static void -snd_rme96_write_SPI(rme96_t *rme96, u16 val) +snd_rme96_write_SPI(struct rme96 *rme96, u16 val) { int i; @@ -506,7 +506,7 @@ snd_rme96_write_SPI(rme96_t *rme96, u16 val) } static void -snd_rme96_apply_dac_volume(rme96_t *rme96) +snd_rme96_apply_dac_volume(struct rme96 *rme96) { if (RME96_DAC_IS_1852(rme96)) { snd_rme96_write_SPI(rme96, (rme96->vol[0] << 2) | 0x0); @@ -518,7 +518,7 @@ snd_rme96_apply_dac_volume(rme96_t *rme96) } static void -snd_rme96_reset_dac(rme96_t *rme96) +snd_rme96_reset_dac(struct rme96 *rme96) { writel(rme96->wcreg | RME96_WCR_PD, rme96->iobase + RME96_IO_CONTROL_REGISTER); @@ -526,14 +526,14 @@ snd_rme96_reset_dac(rme96_t *rme96) } static int -snd_rme96_getmontracks(rme96_t *rme96) +snd_rme96_getmontracks(struct rme96 *rme96) { return ((rme96->wcreg >> RME96_WCR_BITPOS_MONITOR_0) & 1) + (((rme96->wcreg >> RME96_WCR_BITPOS_MONITOR_1) & 1) << 1); } static int -snd_rme96_setmontracks(rme96_t *rme96, +snd_rme96_setmontracks(struct rme96 *rme96, int montracks) { if (montracks & 1) { @@ -551,14 +551,14 @@ snd_rme96_setmontracks(rme96_t *rme96, } static int -snd_rme96_getattenuation(rme96_t *rme96) +snd_rme96_getattenuation(struct rme96 *rme96) { return ((rme96->wcreg >> RME96_WCR_BITPOS_GAIN_0) & 1) + (((rme96->wcreg >> RME96_WCR_BITPOS_GAIN_1) & 1) << 1); } static int -snd_rme96_setattenuation(rme96_t *rme96, +snd_rme96_setattenuation(struct rme96 *rme96, int attenuation) { switch (attenuation) { @@ -586,7 +586,7 @@ snd_rme96_setattenuation(rme96_t *rme96, } static int -snd_rme96_capture_getrate(rme96_t *rme96, +snd_rme96_capture_getrate(struct rme96 *rme96, int *is_adat) { int n, rate; @@ -649,7 +649,7 @@ snd_rme96_capture_getrate(rme96_t *rme96, } static int -snd_rme96_playback_getrate(rme96_t *rme96) +snd_rme96_playback_getrate(struct rme96 *rme96) { int rate, dummy; @@ -679,7 +679,7 @@ snd_rme96_playback_getrate(rme96_t *rme96) } static int -snd_rme96_playback_setrate(rme96_t *rme96, +snd_rme96_playback_setrate(struct rme96 *rme96, int rate) { int ds; @@ -731,7 +731,7 @@ snd_rme96_playback_setrate(rme96_t *rme96, } static int -snd_rme96_capture_analog_setrate(rme96_t *rme96, +snd_rme96_capture_analog_setrate(struct rme96 *rme96, int rate) { switch (rate) { @@ -773,7 +773,7 @@ snd_rme96_capture_analog_setrate(rme96_t *rme96, } static int -snd_rme96_setclockmode(rme96_t *rme96, +snd_rme96_setclockmode(struct rme96 *rme96, int mode) { switch (mode) { @@ -801,7 +801,7 @@ snd_rme96_setclockmode(rme96_t *rme96, } static int -snd_rme96_getclockmode(rme96_t *rme96) +snd_rme96_getclockmode(struct rme96 *rme96) { if (rme96->areg & RME96_AR_WSEL) { return RME96_CLOCKMODE_WORDCLOCK; @@ -811,7 +811,7 @@ snd_rme96_getclockmode(rme96_t *rme96) } static int -snd_rme96_setinputtype(rme96_t *rme96, +snd_rme96_setinputtype(struct rme96 *rme96, int type) { int n; @@ -872,7 +872,7 @@ snd_rme96_setinputtype(rme96_t *rme96, } static int -snd_rme96_getinputtype(rme96_t *rme96) +snd_rme96_getinputtype(struct rme96 *rme96) { if (rme96->areg & RME96_AR_ANALOG) { return RME96_INPUT_ANALOG; @@ -882,7 +882,7 @@ snd_rme96_getinputtype(rme96_t *rme96) } static void -snd_rme96_setframelog(rme96_t *rme96, +snd_rme96_setframelog(struct rme96 *rme96, int n_channels, int is_playback) { @@ -904,7 +904,7 @@ snd_rme96_setframelog(rme96_t *rme96, } static int -snd_rme96_playback_setformat(rme96_t *rme96, +snd_rme96_playback_setformat(struct rme96 *rme96, int format) { switch (format) { @@ -922,7 +922,7 @@ snd_rme96_playback_setformat(rme96_t *rme96, } static int -snd_rme96_capture_setformat(rme96_t *rme96, +snd_rme96_capture_setformat(struct rme96 *rme96, int format) { switch (format) { @@ -940,7 +940,7 @@ snd_rme96_capture_setformat(rme96_t *rme96, } static void -snd_rme96_set_period_properties(rme96_t *rme96, +snd_rme96_set_period_properties(struct rme96 *rme96, size_t period_bytes) { switch (period_bytes) { @@ -959,11 +959,11 @@ snd_rme96_set_period_properties(rme96_t *rme96, } static int -snd_rme96_playback_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +snd_rme96_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme96 *rme96 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err, rate, dummy; runtime->dma_area = (void __force *)(rme96->iobase + @@ -1012,11 +1012,11 @@ snd_rme96_playback_hw_params(snd_pcm_substream_t *substream, } static int -snd_rme96_capture_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +snd_rme96_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme96 *rme96 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err, isadat, rate; runtime->dma_area = (void __force *)(rme96->iobase + @@ -1066,7 +1066,7 @@ snd_rme96_capture_hw_params(snd_pcm_substream_t *substream, } static void -snd_rme96_playback_start(rme96_t *rme96, +snd_rme96_playback_start(struct rme96 *rme96, int from_pause) { if (!from_pause) { @@ -1078,7 +1078,7 @@ snd_rme96_playback_start(rme96_t *rme96, } static void -snd_rme96_capture_start(rme96_t *rme96, +snd_rme96_capture_start(struct rme96 *rme96, int from_pause) { if (!from_pause) { @@ -1090,7 +1090,7 @@ snd_rme96_capture_start(rme96_t *rme96, } static void -snd_rme96_playback_stop(rme96_t *rme96) +snd_rme96_playback_stop(struct rme96 *rme96) { /* * Check if there is an unconfirmed IRQ, if so confirm it, or else @@ -1105,7 +1105,7 @@ snd_rme96_playback_stop(rme96_t *rme96) } static void -snd_rme96_capture_stop(rme96_t *rme96) +snd_rme96_capture_stop(struct rme96 *rme96) { rme96->rcreg = readl(rme96->iobase + RME96_IO_CONTROL_REGISTER); if (rme96->rcreg & RME96_RCR_IRQ_2) { @@ -1120,7 +1120,7 @@ snd_rme96_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - rme96_t *rme96 = (rme96_t *)dev_id; + struct rme96 *rme96 = (struct rme96 *)dev_id; rme96->rcreg = readl(rme96->iobase + RME96_IO_CONTROL_REGISTER); /* fastpath out, to ease interrupt sharing */ @@ -1145,18 +1145,18 @@ snd_rme96_interrupt(int irq, static unsigned int period_bytes[] = { RME96_SMALL_BLOCK_SIZE, RME96_LARGE_BLOCK_SIZE }; -static snd_pcm_hw_constraint_list_t hw_constraints_period_bytes = { +static struct snd_pcm_hw_constraint_list hw_constraints_period_bytes = { .count = ARRAY_SIZE(period_bytes), .list = period_bytes, .mask = 0 }; static int -snd_rme96_playback_spdif_open(snd_pcm_substream_t *substream) +snd_rme96_playback_spdif_open(struct snd_pcm_substream *substream) { int rate, dummy; - rme96_t *rme96 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme96 *rme96 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_set_sync(substream); @@ -1191,11 +1191,11 @@ snd_rme96_playback_spdif_open(snd_pcm_substream_t *substream) } static int -snd_rme96_capture_spdif_open(snd_pcm_substream_t *substream) +snd_rme96_capture_spdif_open(struct snd_pcm_substream *substream) { int isadat, rate; - rme96_t *rme96 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme96 *rme96 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_set_sync(substream); @@ -1226,11 +1226,11 @@ snd_rme96_capture_spdif_open(snd_pcm_substream_t *substream) } static int -snd_rme96_playback_adat_open(snd_pcm_substream_t *substream) +snd_rme96_playback_adat_open(struct snd_pcm_substream *substream) { int rate, dummy; - rme96_t *rme96 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme96 *rme96 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_set_sync(substream); @@ -1260,11 +1260,11 @@ snd_rme96_playback_adat_open(snd_pcm_substream_t *substream) } static int -snd_rme96_capture_adat_open(snd_pcm_substream_t *substream) +snd_rme96_capture_adat_open(struct snd_pcm_substream *substream) { int isadat, rate; - rme96_t *rme96 = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct rme96 *rme96 = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; snd_pcm_set_sync(substream); @@ -1297,9 +1297,9 @@ snd_rme96_capture_adat_open(snd_pcm_substream_t *substream) } static int -snd_rme96_playback_close(snd_pcm_substream_t *substream) +snd_rme96_playback_close(struct snd_pcm_substream *substream) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); int spdif = 0; spin_lock_irq(&rme96->lock); @@ -1319,9 +1319,9 @@ snd_rme96_playback_close(snd_pcm_substream_t *substream) } static int -snd_rme96_capture_close(snd_pcm_substream_t *substream) +snd_rme96_capture_close(struct snd_pcm_substream *substream) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); spin_lock_irq(&rme96->lock); if (RME96_ISRECORDING(rme96)) { @@ -1334,9 +1334,9 @@ snd_rme96_capture_close(snd_pcm_substream_t *substream) } static int -snd_rme96_playback_prepare(snd_pcm_substream_t *substream) +snd_rme96_playback_prepare(struct snd_pcm_substream *substream) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); spin_lock_irq(&rme96->lock); if (RME96_ISPLAYING(rme96)) { @@ -1348,9 +1348,9 @@ snd_rme96_playback_prepare(snd_pcm_substream_t *substream) } static int -snd_rme96_capture_prepare(snd_pcm_substream_t *substream) +snd_rme96_capture_prepare(struct snd_pcm_substream *substream) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); spin_lock_irq(&rme96->lock); if (RME96_ISRECORDING(rme96)) { @@ -1362,10 +1362,10 @@ snd_rme96_capture_prepare(snd_pcm_substream_t *substream) } static int -snd_rme96_playback_trigger(snd_pcm_substream_t *substream, +snd_rme96_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -1405,10 +1405,10 @@ snd_rme96_playback_trigger(snd_pcm_substream_t *substream, } static int -snd_rme96_capture_trigger(snd_pcm_substream_t *substream, +snd_rme96_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -1449,20 +1449,20 @@ snd_rme96_capture_trigger(snd_pcm_substream_t *substream, } static snd_pcm_uframes_t -snd_rme96_playback_pointer(snd_pcm_substream_t *substream) +snd_rme96_playback_pointer(struct snd_pcm_substream *substream) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); return snd_rme96_playback_ptr(rme96); } static snd_pcm_uframes_t -snd_rme96_capture_pointer(snd_pcm_substream_t *substream) +snd_rme96_capture_pointer(struct snd_pcm_substream *substream) { - rme96_t *rme96 = snd_pcm_substream_chip(substream); + struct rme96 *rme96 = snd_pcm_substream_chip(substream); return snd_rme96_capture_ptr(rme96); } -static snd_pcm_ops_t snd_rme96_playback_spdif_ops = { +static struct snd_pcm_ops snd_rme96_playback_spdif_ops = { .open = snd_rme96_playback_spdif_open, .close = snd_rme96_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1475,7 +1475,7 @@ static snd_pcm_ops_t snd_rme96_playback_spdif_ops = { .mmap = snd_pcm_lib_mmap_iomem, }; -static snd_pcm_ops_t snd_rme96_capture_spdif_ops = { +static struct snd_pcm_ops snd_rme96_capture_spdif_ops = { .open = snd_rme96_capture_spdif_open, .close = snd_rme96_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1487,7 +1487,7 @@ static snd_pcm_ops_t snd_rme96_capture_spdif_ops = { .mmap = snd_pcm_lib_mmap_iomem, }; -static snd_pcm_ops_t snd_rme96_playback_adat_ops = { +static struct snd_pcm_ops snd_rme96_playback_adat_ops = { .open = snd_rme96_playback_adat_open, .close = snd_rme96_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1500,7 +1500,7 @@ static snd_pcm_ops_t snd_rme96_playback_adat_ops = { .mmap = snd_pcm_lib_mmap_iomem, }; -static snd_pcm_ops_t snd_rme96_capture_adat_ops = { +static struct snd_pcm_ops snd_rme96_capture_adat_ops = { .open = snd_rme96_capture_adat_open, .close = snd_rme96_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1515,7 +1515,7 @@ static snd_pcm_ops_t snd_rme96_capture_adat_ops = { static void snd_rme96_free(void *private_data) { - rme96_t *rme96 = (rme96_t *)private_data; + struct rme96 *rme96 = (struct rme96 *)private_data; if (rme96 == NULL) { return; @@ -1540,21 +1540,21 @@ snd_rme96_free(void *private_data) } static void -snd_rme96_free_spdif_pcm(snd_pcm_t *pcm) +snd_rme96_free_spdif_pcm(struct snd_pcm *pcm) { - rme96_t *rme96 = (rme96_t *) pcm->private_data; + struct rme96 *rme96 = (struct rme96 *) pcm->private_data; rme96->spdif_pcm = NULL; } static void -snd_rme96_free_adat_pcm(snd_pcm_t *pcm) +snd_rme96_free_adat_pcm(struct snd_pcm *pcm) { - rme96_t *rme96 = (rme96_t *) pcm->private_data; + struct rme96 *rme96 = (struct rme96 *) pcm->private_data; rme96->adat_pcm = NULL; } static int __devinit -snd_rme96_create(rme96_t *rme96) +snd_rme96_create(struct rme96 *rme96) { struct pci_dev *pci = rme96->pci; int err; @@ -1671,10 +1671,10 @@ snd_rme96_create(rme96_t *rme96) */ static void -snd_rme96_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +snd_rme96_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { int n; - rme96_t *rme96 = (rme96_t *)entry->private_data; + struct rme96 *rme96 = (struct rme96 *)entry->private_data; rme96->rcreg = readl(rme96->iobase + RME96_IO_CONTROL_REGISTER); @@ -1800,9 +1800,9 @@ snd_rme96_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) } static void __devinit -snd_rme96_proc_init(rme96_t *rme96) +snd_rme96_proc_init(struct rme96 *rme96) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(rme96->card, "rme96", &entry)) snd_info_set_text_ops(entry, rme96, 1024, snd_rme96_proc_read); @@ -1813,7 +1813,7 @@ snd_rme96_proc_init(rme96_t *rme96) */ static int -snd_rme96_info_loopback_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +snd_rme96_info_loopback_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1822,9 +1822,9 @@ snd_rme96_info_loopback_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } static int -snd_rme96_get_loopback_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_get_loopback_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme96->lock); ucontrol->value.integer.value[0] = rme96->wcreg & RME96_WCR_SEL ? 0 : 1; @@ -1832,9 +1832,9 @@ snd_rme96_get_loopback_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * return 0; } static int -snd_rme96_put_loopback_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_put_loopback_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -1849,10 +1849,10 @@ snd_rme96_put_loopback_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * } static int -snd_rme96_info_inputtype_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +snd_rme96_info_inputtype_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *_texts[5] = { "Optical", "Coaxial", "Internal", "XLR", "Analog" }; - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); char *texts[5] = { _texts[0], _texts[1], _texts[2], _texts[3], _texts[4] }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -1886,9 +1886,9 @@ snd_rme96_info_inputtype_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } static int -snd_rme96_get_inputtype_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_get_inputtype_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); unsigned int items = 3; spin_lock_irq(&rme96->lock); @@ -1925,9 +1925,9 @@ snd_rme96_get_inputtype_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } static int -snd_rme96_put_inputtype_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_put_inputtype_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); unsigned int val; int change, items = 3; @@ -1967,7 +1967,7 @@ snd_rme96_put_inputtype_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t } static int -snd_rme96_info_clockmode_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +snd_rme96_info_clockmode_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[3] = { "AutoSync", "Internal", "Word" }; @@ -1981,9 +1981,9 @@ snd_rme96_info_clockmode_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } static int -snd_rme96_get_clockmode_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_get_clockmode_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme96->lock); ucontrol->value.enumerated.item[0] = snd_rme96_getclockmode(rme96); @@ -1991,9 +1991,9 @@ snd_rme96_get_clockmode_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } static int -snd_rme96_put_clockmode_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_put_clockmode_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -2006,7 +2006,7 @@ snd_rme96_put_clockmode_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t } static int -snd_rme96_info_attenuation_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +snd_rme96_info_attenuation_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "0 dB", "-6 dB", "-12 dB", "-18 dB" }; @@ -2020,9 +2020,9 @@ snd_rme96_info_attenuation_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } static int -snd_rme96_get_attenuation_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_get_attenuation_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme96->lock); ucontrol->value.enumerated.item[0] = snd_rme96_getattenuation(rme96); @@ -2030,9 +2030,9 @@ snd_rme96_get_attenuation_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } static int -snd_rme96_put_attenuation_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_put_attenuation_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -2046,7 +2046,7 @@ snd_rme96_put_attenuation_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ } static int -snd_rme96_info_montracks_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +snd_rme96_info_montracks_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "1+2", "3+4", "5+6", "7+8" }; @@ -2060,9 +2060,9 @@ snd_rme96_info_montracks_control(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * return 0; } static int -snd_rme96_get_montracks_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_get_montracks_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme96->lock); ucontrol->value.enumerated.item[0] = snd_rme96_getmontracks(rme96); @@ -2070,9 +2070,9 @@ snd_rme96_get_montracks_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return 0; } static int -snd_rme96_put_montracks_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +snd_rme96_put_montracks_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); unsigned int val; int change; @@ -2084,7 +2084,7 @@ snd_rme96_put_montracks_control(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t return change; } -static u32 snd_rme96_convert_from_aes(snd_aes_iec958_t *aes) +static u32 snd_rme96_convert_from_aes(struct snd_aes_iec958 *aes) { u32 val = 0; val |= (aes->status[0] & IEC958_AES0_PROFESSIONAL) ? RME96_WCR_PRO : 0; @@ -2096,7 +2096,7 @@ static u32 snd_rme96_convert_from_aes(snd_aes_iec958_t *aes) return val; } -static void snd_rme96_convert_to_aes(snd_aes_iec958_t *aes, u32 val) +static void snd_rme96_convert_to_aes(struct snd_aes_iec958 *aes, u32 val) { aes->status[0] = ((val & RME96_WCR_PRO) ? IEC958_AES0_PROFESSIONAL : 0) | ((val & RME96_WCR_DOLBY) ? IEC958_AES0_NONAUDIO : 0); @@ -2106,24 +2106,24 @@ static void snd_rme96_convert_to_aes(snd_aes_iec958_t *aes, u32 val) aes->status[0] |= (val & RME96_WCR_EMP) ? IEC958_AES0_CON_EMPHASIS_5015 : 0; } -static int snd_rme96_control_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme96_control_spdif_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme96_control_spdif_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme96_control_spdif_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); snd_rme96_convert_to_aes(&ucontrol->value.iec958, rme96->wcreg_spdif); return 0; } -static int snd_rme96_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme96_control_spdif_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); int change; u32 val; @@ -2135,24 +2135,24 @@ static int snd_rme96_control_spdif_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_v return change; } -static int snd_rme96_control_spdif_stream_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme96_control_spdif_stream_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme96_control_spdif_stream_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme96_control_spdif_stream_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); snd_rme96_convert_to_aes(&ucontrol->value.iec958, rme96->wcreg_spdif_stream); return 0; } -static int snd_rme96_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme96_control_spdif_stream_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); int change; u32 val; @@ -2167,23 +2167,23 @@ static int snd_rme96_control_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl return change; } -static int snd_rme96_control_spdif_mask_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_rme96_control_spdif_mask_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; uinfo->count = 1; return 0; } -static int snd_rme96_control_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_rme96_control_spdif_mask_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { ucontrol->value.iec958.status[0] = kcontrol->private_value; return 0; } static int -snd_rme96_dac_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +snd_rme96_dac_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -2193,9 +2193,9 @@ snd_rme96_dac_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) } static int -snd_rme96_dac_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +snd_rme96_dac_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *u) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); spin_lock_irq(&rme96->lock); u->value.integer.value[0] = rme96->vol[0]; @@ -2206,9 +2206,9 @@ snd_rme96_dac_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) } static int -snd_rme96_dac_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) +snd_rme96_dac_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *u) { - rme96_t *rme96 = snd_kcontrol_chip(kcontrol); + struct rme96 *rme96 = snd_kcontrol_chip(kcontrol); int change = 0; if (!RME96_HAS_ANALOG_OUT(rme96)) { @@ -2231,7 +2231,7 @@ snd_rme96_dac_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u) return change; } -static snd_kcontrol_new_t snd_rme96_controls[] = { +static struct snd_kcontrol_new snd_rme96_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), @@ -2312,11 +2312,11 @@ static snd_kcontrol_new_t snd_rme96_controls[] = { }; static int -snd_rme96_create_switches(snd_card_t *card, - rme96_t *rme96) +snd_rme96_create_switches(struct snd_card *card, + struct rme96 *rme96) { int idx, err; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; for (idx = 0; idx < 7; idx++) { if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_rme96_controls[idx], rme96))) < 0) @@ -2338,7 +2338,7 @@ snd_rme96_create_switches(snd_card_t *card, * Card initialisation */ -static void snd_rme96_card_free(snd_card_t *card) +static void snd_rme96_card_free(struct snd_card *card) { snd_rme96_free(card->private_data); } @@ -2348,8 +2348,8 @@ snd_rme96_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - rme96_t *rme96; - snd_card_t *card; + struct rme96 *rme96; + struct snd_card *card; int err; u8 val; @@ -2361,10 +2361,10 @@ snd_rme96_probe(struct pci_dev *pci, return -ENOENT; } if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(rme96_t))) == NULL) + sizeof(struct rme96))) == NULL) return -ENOMEM; card->private_free = snd_rme96_card_free; - rme96 = (rme96_t *)card->private_data; + rme96 = (struct rme96 *)card->private_data; rme96->card = card; rme96->pci = pci; snd_card_set_dev(card, &pci->dev); -- cgit v1.1 From 016e401c2e64ce5c440b1f68eae4a53273aa0bc2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:05:57 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI Sonicvibes Modules: SonicVibes driver Remove xxx_t typedefs from the PCI Sonicvibes driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/sonicvibes.c | 227 ++++++++++++++++++++++++------------------------- 1 file changed, 113 insertions(+), 114 deletions(-) diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index b66459f..7bbea37 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -195,9 +195,7 @@ MODULE_PARM_DESC(dmaio, "DDMA i/o base address for S3 SonicVibes soundcard."); */ -typedef struct _snd_sonicvibes sonicvibes_t; - -struct _snd_sonicvibes { +struct sonicvibes { unsigned long dma1size; unsigned long dma2size; int irq; @@ -224,20 +222,20 @@ struct _snd_sonicvibes { unsigned int mode; struct pci_dev *pci; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; - snd_rawmidi_t *rmidi; - snd_hwdep_t *fmsynth; /* S3FM */ + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; + struct snd_rawmidi *rmidi; + struct snd_hwdep *fmsynth; /* S3FM */ spinlock_t reg_lock; unsigned int p_dma_size; unsigned int c_dma_size; - snd_kcontrol_t *master_mute; - snd_kcontrol_t *master_volume; + struct snd_kcontrol *master_mute; + struct snd_kcontrol *master_volume; #ifdef SUPPORT_JOYSTICK struct gameport *gameport; @@ -251,13 +249,13 @@ static struct pci_device_id snd_sonic_ids[] = { MODULE_DEVICE_TABLE(pci, snd_sonic_ids); -static ratden_t sonicvibes_adc_clock = { +static struct snd_ratden sonicvibes_adc_clock = { .num_min = 4000 * 65536, .num_max = 48000UL * 65536, .num_step = 1, .den = 65536, }; -static snd_pcm_hw_constraint_ratdens_t snd_sonicvibes_hw_constraints_adc_clock = { +static struct snd_pcm_hw_constraint_ratdens snd_sonicvibes_hw_constraints_adc_clock = { .nrats = 1, .rats = &sonicvibes_adc_clock, }; @@ -266,7 +264,7 @@ static snd_pcm_hw_constraint_ratdens_t snd_sonicvibes_hw_constraints_adc_clock = * common I/O routines */ -static inline void snd_sonicvibes_setdmaa(sonicvibes_t * sonic, +static inline void snd_sonicvibes_setdmaa(struct sonicvibes * sonic, unsigned int addr, unsigned int count) { @@ -279,7 +277,7 @@ static inline void snd_sonicvibes_setdmaa(sonicvibes_t * sonic, #endif } -static inline void snd_sonicvibes_setdmac(sonicvibes_t * sonic, +static inline void snd_sonicvibes_setdmac(struct sonicvibes * sonic, unsigned int addr, unsigned int count) { @@ -294,18 +292,18 @@ static inline void snd_sonicvibes_setdmac(sonicvibes_t * sonic, #endif } -static inline unsigned int snd_sonicvibes_getdmaa(sonicvibes_t * sonic) +static inline unsigned int snd_sonicvibes_getdmaa(struct sonicvibes * sonic) { return (inl(sonic->dmaa_port + SV_DMA_COUNT0) & 0xffffff) + 1; } -static inline unsigned int snd_sonicvibes_getdmac(sonicvibes_t * sonic) +static inline unsigned int snd_sonicvibes_getdmac(struct sonicvibes * sonic) { /* note: dmac is working in word mode!!! */ return ((inl(sonic->dmac_port + SV_DMA_COUNT0) & 0xffffff) + 1) << 1; } -static void snd_sonicvibes_out1(sonicvibes_t * sonic, +static void snd_sonicvibes_out1(struct sonicvibes * sonic, unsigned char reg, unsigned char value) { @@ -315,7 +313,7 @@ static void snd_sonicvibes_out1(sonicvibes_t * sonic, udelay(10); } -static void snd_sonicvibes_out(sonicvibes_t * sonic, +static void snd_sonicvibes_out(struct sonicvibes * sonic, unsigned char reg, unsigned char value) { @@ -329,7 +327,7 @@ static void snd_sonicvibes_out(sonicvibes_t * sonic, spin_unlock_irqrestore(&sonic->reg_lock, flags); } -static unsigned char snd_sonicvibes_in1(sonicvibes_t * sonic, unsigned char reg) +static unsigned char snd_sonicvibes_in1(struct sonicvibes * sonic, unsigned char reg) { unsigned char value; @@ -340,7 +338,7 @@ static unsigned char snd_sonicvibes_in1(sonicvibes_t * sonic, unsigned char reg) return value; } -static unsigned char snd_sonicvibes_in(sonicvibes_t * sonic, unsigned char reg) +static unsigned char snd_sonicvibes_in(struct sonicvibes * sonic, unsigned char reg) { unsigned long flags; unsigned char value; @@ -355,7 +353,7 @@ static unsigned char snd_sonicvibes_in(sonicvibes_t * sonic, unsigned char reg) } #if 0 -static void snd_sonicvibes_debug(sonicvibes_t * sonic) +static void snd_sonicvibes_debug(struct sonicvibes * sonic) { printk("SV REGS: INDEX = 0x%02x ", inb(SV_REG(sonic, INDEX))); printk(" STATUS = 0x%02x\n", inb(SV_REG(sonic, STATUS))); @@ -427,7 +425,7 @@ static void snd_sonicvibes_debug(sonicvibes_t * sonic) #endif -static void snd_sonicvibes_setfmt(sonicvibes_t * sonic, +static void snd_sonicvibes_setfmt(struct sonicvibes * sonic, unsigned char mask, unsigned char value) { @@ -483,7 +481,7 @@ static void snd_sonicvibes_pll(unsigned int rate, #endif } -static void snd_sonicvibes_setpll(sonicvibes_t * sonic, +static void snd_sonicvibes_setpll(struct sonicvibes * sonic, unsigned char reg, unsigned int rate) { @@ -499,7 +497,7 @@ static void snd_sonicvibes_setpll(sonicvibes_t * sonic, } } -static void snd_sonicvibes_set_adc_rate(sonicvibes_t * sonic, unsigned int rate) +static void snd_sonicvibes_set_adc_rate(struct sonicvibes * sonic, unsigned int rate) { unsigned long flags; unsigned int div; @@ -520,8 +518,8 @@ static void snd_sonicvibes_set_adc_rate(sonicvibes_t * sonic, unsigned int rate) spin_unlock_irqrestore(&sonic->reg_lock, flags); } -static int snd_sonicvibes_hw_constraint_dac_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_sonicvibes_hw_constraint_dac_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { unsigned int rate, div, r, m, n; @@ -545,7 +543,7 @@ static int snd_sonicvibes_hw_constraint_dac_rate(snd_pcm_hw_params_t *params, return 0; } -static void snd_sonicvibes_set_dac_rate(sonicvibes_t * sonic, unsigned int rate) +static void snd_sonicvibes_set_dac_rate(struct sonicvibes * sonic, unsigned int rate) { unsigned int div; unsigned long flags; @@ -559,7 +557,7 @@ static void snd_sonicvibes_set_dac_rate(sonicvibes_t * sonic, unsigned int rate) spin_unlock_irqrestore(&sonic->reg_lock, flags); } -static int snd_sonicvibes_trigger(sonicvibes_t * sonic, int what, int cmd) +static int snd_sonicvibes_trigger(struct sonicvibes * sonic, int what, int cmd) { int result = 0; @@ -583,7 +581,7 @@ static int snd_sonicvibes_trigger(sonicvibes_t * sonic, int what, int cmd) static irqreturn_t snd_sonicvibes_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - sonicvibes_t *sonic = dev_id; + struct sonicvibes *sonic = dev_id; unsigned char status; status = inb(SV_REG(sonic, STATUS)); @@ -646,35 +644,35 @@ static irqreturn_t snd_sonicvibes_interrupt(int irq, void *dev_id, struct pt_reg * PCM part */ -static int snd_sonicvibes_playback_trigger(snd_pcm_substream_t * substream, +static int snd_sonicvibes_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); return snd_sonicvibes_trigger(sonic, 1, cmd); } -static int snd_sonicvibes_capture_trigger(snd_pcm_substream_t * substream, +static int snd_sonicvibes_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); return snd_sonicvibes_trigger(sonic, 2, cmd); } -static int snd_sonicvibes_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_sonicvibes_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_sonicvibes_hw_free(snd_pcm_substream_t * substream) +static int snd_sonicvibes_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_sonicvibes_playback_prepare(snd_pcm_substream_t * substream) +static int snd_sonicvibes_playback_prepare(struct snd_pcm_substream *substream) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned char fmt = 0; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -695,10 +693,10 @@ static int snd_sonicvibes_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_sonicvibes_capture_prepare(snd_pcm_substream_t * substream) +static int snd_sonicvibes_capture_prepare(struct snd_pcm_substream *substream) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned char fmt = 0; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned int count = snd_pcm_lib_period_bytes(substream); @@ -720,9 +718,9 @@ static int snd_sonicvibes_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_sonicvibes_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sonicvibes_playback_pointer(struct snd_pcm_substream *substream) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); size_t ptr; if (!(sonic->enable & 1)) @@ -731,9 +729,9 @@ static snd_pcm_uframes_t snd_sonicvibes_playback_pointer(snd_pcm_substream_t * s return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_sonicvibes_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sonicvibes_capture_pointer(struct snd_pcm_substream *substream) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); size_t ptr; if (!(sonic->enable & 2)) return 0; @@ -741,7 +739,7 @@ static snd_pcm_uframes_t snd_sonicvibes_capture_pointer(snd_pcm_substream_t * su return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_hardware_t snd_sonicvibes_playback = +static struct snd_pcm_hardware snd_sonicvibes_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -760,7 +758,7 @@ static snd_pcm_hardware_t snd_sonicvibes_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_sonicvibes_capture = +static struct snd_pcm_hardware snd_sonicvibes_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -779,10 +777,10 @@ static snd_pcm_hardware_t snd_sonicvibes_capture = .fifo_size = 0, }; -static int snd_sonicvibes_playback_open(snd_pcm_substream_t * substream) +static int snd_sonicvibes_playback_open(struct snd_pcm_substream *substream) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; sonic->mode |= SV_MODE_PLAY; sonic->playback_substream = substream; @@ -791,10 +789,10 @@ static int snd_sonicvibes_playback_open(snd_pcm_substream_t * substream) return 0; } -static int snd_sonicvibes_capture_open(snd_pcm_substream_t * substream) +static int snd_sonicvibes_capture_open(struct snd_pcm_substream *substream) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; sonic->mode |= SV_MODE_CAPTURE; sonic->capture_substream = substream; @@ -804,25 +802,25 @@ static int snd_sonicvibes_capture_open(snd_pcm_substream_t * substream) return 0; } -static int snd_sonicvibes_playback_close(snd_pcm_substream_t * substream) +static int snd_sonicvibes_playback_close(struct snd_pcm_substream *substream) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); sonic->playback_substream = NULL; sonic->mode &= ~SV_MODE_PLAY; return 0; } -static int snd_sonicvibes_capture_close(snd_pcm_substream_t * substream) +static int snd_sonicvibes_capture_close(struct snd_pcm_substream *substream) { - sonicvibes_t *sonic = snd_pcm_substream_chip(substream); + struct sonicvibes *sonic = snd_pcm_substream_chip(substream); sonic->capture_substream = NULL; sonic->mode &= ~SV_MODE_CAPTURE; return 0; } -static snd_pcm_ops_t snd_sonicvibes_playback_ops = { +static struct snd_pcm_ops snd_sonicvibes_playback_ops = { .open = snd_sonicvibes_playback_open, .close = snd_sonicvibes_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -833,7 +831,7 @@ static snd_pcm_ops_t snd_sonicvibes_playback_ops = { .pointer = snd_sonicvibes_playback_pointer, }; -static snd_pcm_ops_t snd_sonicvibes_capture_ops = { +static struct snd_pcm_ops snd_sonicvibes_capture_ops = { .open = snd_sonicvibes_capture_open, .close = snd_sonicvibes_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -844,9 +842,9 @@ static snd_pcm_ops_t snd_sonicvibes_capture_ops = { .pointer = snd_sonicvibes_capture_pointer, }; -static int __devinit snd_sonicvibes_pcm(sonicvibes_t * sonic, int device, snd_pcm_t ** rpcm) +static int __devinit snd_sonicvibes_pcm(struct sonicvibes * sonic, int device, struct snd_pcm ** rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(sonic->card, "s3_86c617", device, 1, 1, &pcm)) < 0) @@ -878,7 +876,7 @@ static int __devinit snd_sonicvibes_pcm(sonicvibes_t * sonic, int device, snd_pc .info = snd_sonicvibes_info_mux, \ .get = snd_sonicvibes_get_mux, .put = snd_sonicvibes_put_mux } -static int snd_sonicvibes_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sonicvibes_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[7] = { "CD", "PCM", "Aux1", "Line", "Aux0", "Mic", "Mix" @@ -893,9 +891,9 @@ static int snd_sonicvibes_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_sonicvibes_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sonicvibes_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sonicvibes_t *sonic = snd_kcontrol_chip(kcontrol); + struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); spin_lock_irq(&sonic->reg_lock); ucontrol->value.enumerated.item[0] = ((snd_sonicvibes_in1(sonic, SV_IREG_LEFT_ADC) & SV_RECSRC_OUT) >> 5) - 1; @@ -904,9 +902,9 @@ static int snd_sonicvibes_get_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ return 0; } -static int snd_sonicvibes_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sonicvibes_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sonicvibes_t *sonic = snd_kcontrol_chip(kcontrol); + struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); unsigned short left, right, oval1, oval2; int change; @@ -933,7 +931,7 @@ static int snd_sonicvibes_put_mux(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ .get = snd_sonicvibes_get_single, .put = snd_sonicvibes_put_single, \ .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } -static int snd_sonicvibes_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sonicvibes_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -944,9 +942,9 @@ static int snd_sonicvibes_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_sonicvibes_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sonicvibes_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sonicvibes_t *sonic = snd_kcontrol_chip(kcontrol); + struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -960,9 +958,9 @@ static int snd_sonicvibes_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return 0; } -static int snd_sonicvibes_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sonicvibes_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sonicvibes_t *sonic = snd_kcontrol_chip(kcontrol); + struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -989,7 +987,7 @@ static int snd_sonicvibes_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_val .get = snd_sonicvibes_get_double, .put = snd_sonicvibes_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static int snd_sonicvibes_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) +static int snd_sonicvibes_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1000,9 +998,9 @@ static int snd_sonicvibes_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_sonicvibes_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sonicvibes_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sonicvibes_t *sonic = snd_kcontrol_chip(kcontrol); + struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int shift_left = (kcontrol->private_value >> 16) & 0x07; @@ -1021,9 +1019,9 @@ static int snd_sonicvibes_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return 0; } -static int snd_sonicvibes_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) +static int snd_sonicvibes_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - sonicvibes_t *sonic = snd_kcontrol_chip(kcontrol); + struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; int shift_left = (kcontrol->private_value >> 16) & 0x07; @@ -1053,7 +1051,7 @@ static int snd_sonicvibes_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_val return change; } -static snd_kcontrol_new_t snd_sonicvibes_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_sonicvibes_controls[] __devinitdata = { SONICVIBES_DOUBLE("Capture Volume", 0, SV_IREG_LEFT_ADC, SV_IREG_RIGHT_ADC, 0, 0, 15, 0), SONICVIBES_DOUBLE("Aux Playback Switch", 0, SV_IREG_LEFT_AUX1, SV_IREG_RIGHT_AUX1, 7, 7, 1, 1), SONICVIBES_DOUBLE("Aux Playback Volume", 0, SV_IREG_LEFT_AUX1, SV_IREG_RIGHT_AUX1, 0, 0, 31, 1), @@ -1077,17 +1075,17 @@ SONICVIBES_SINGLE("Loopback Capture Volume", 0, SV_IREG_ADC_OUTPUT_CTRL, 2, 63, SONICVIBES_MUX("Capture Source", 0) }; -static void snd_sonicvibes_master_free(snd_kcontrol_t *kcontrol) +static void snd_sonicvibes_master_free(struct snd_kcontrol *kcontrol) { - sonicvibes_t *sonic = snd_kcontrol_chip(kcontrol); + struct sonicvibes *sonic = snd_kcontrol_chip(kcontrol); sonic->master_mute = NULL; sonic->master_volume = NULL; } -static int __devinit snd_sonicvibes_mixer(sonicvibes_t * sonic) +static int __devinit snd_sonicvibes_mixer(struct sonicvibes * sonic) { - snd_card_t *card; - snd_kcontrol_t *kctl; + struct snd_card *card; + struct snd_kcontrol *kctl; unsigned int idx; int err; @@ -1110,10 +1108,10 @@ static int __devinit snd_sonicvibes_mixer(sonicvibes_t * sonic) */ -static void snd_sonicvibes_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t * buffer) +static void snd_sonicvibes_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - sonicvibes_t *sonic = entry->private_data; + struct sonicvibes *sonic = entry->private_data; unsigned char tmp; tmp = sonic->srs_space & 0x0f; @@ -1140,9 +1138,9 @@ static void snd_sonicvibes_proc_read(snd_info_entry_t *entry, snd_iprintf(buffer, "MIDI to ext. Tx : %s\n", tmp & 0x04 ? "on" : "off"); } -static void __devinit snd_sonicvibes_proc_init(sonicvibes_t * sonic) +static void __devinit snd_sonicvibes_proc_init(struct sonicvibes * sonic) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(sonic->card, "sonicvibes", &entry)) snd_info_set_text_ops(entry, sonic, 1024, snd_sonicvibes_proc_read); @@ -1153,10 +1151,10 @@ static void __devinit snd_sonicvibes_proc_init(sonicvibes_t * sonic) */ #ifdef SUPPORT_JOYSTICK -static snd_kcontrol_new_t snd_sonicvibes_game_control __devinitdata = +static struct snd_kcontrol_new snd_sonicvibes_game_control __devinitdata = SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0); -static int __devinit snd_sonicvibes_create_gameport(sonicvibes_t *sonic) +static int __devinit snd_sonicvibes_create_gameport(struct sonicvibes *sonic) { struct gameport *gp; @@ -1178,7 +1176,7 @@ static int __devinit snd_sonicvibes_create_gameport(sonicvibes_t *sonic) return 0; } -static void snd_sonicvibes_free_gameport(sonicvibes_t *sonic) +static void snd_sonicvibes_free_gameport(struct sonicvibes *sonic) { if (sonic->gameport) { gameport_unregister_port(sonic->gameport); @@ -1186,11 +1184,11 @@ static void snd_sonicvibes_free_gameport(sonicvibes_t *sonic) } } #else -static inline int snd_sonicvibes_create_gameport(sonicvibes_t *sonic) { return -ENOSYS; } -static inline void snd_sonicvibes_free_gameport(sonicvibes_t *sonic) { } +static inline int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) { return -ENOSYS; } +static inline void snd_sonicvibes_free_gameport(struct sonicvibes *sonic) { } #endif -static int snd_sonicvibes_free(sonicvibes_t *sonic) +static int snd_sonicvibes_free(struct sonicvibes *sonic) { snd_sonicvibes_free_gameport(sonic); pci_write_config_dword(sonic->pci, 0x40, sonic->dmaa_port); @@ -1205,22 +1203,22 @@ static int snd_sonicvibes_free(sonicvibes_t *sonic) return 0; } -static int snd_sonicvibes_dev_free(snd_device_t *device) +static int snd_sonicvibes_dev_free(struct snd_device *device) { - sonicvibes_t *sonic = device->device_data; + struct sonicvibes *sonic = device->device_data; return snd_sonicvibes_free(sonic); } -static int __devinit snd_sonicvibes_create(snd_card_t * card, +static int __devinit snd_sonicvibes_create(struct snd_card *card, struct pci_dev *pci, int reverb, int mge, - sonicvibes_t ** rsonic) + struct sonicvibes ** rsonic) { - sonicvibes_t *sonic; + struct sonicvibes *sonic; unsigned int dmaa, dmac; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_sonicvibes_dev_free, }; @@ -1365,7 +1363,7 @@ static int __devinit snd_sonicvibes_create(snd_card_t * card, * MIDI section */ -static snd_kcontrol_new_t snd_sonicvibes_midi_controls[] __devinitdata = { +static struct snd_kcontrol_new snd_sonicvibes_midi_controls[] __devinitdata = { SONICVIBES_SINGLE("SonicVibes Wave Source RAM", 0, SV_IREG_WAVE_SOURCE, 0, 1, 0), SONICVIBES_SINGLE("SonicVibes Wave Source RAM+ROM", 0, SV_IREG_WAVE_SOURCE, 1, 1, 0), SONICVIBES_SINGLE("SonicVibes Onboard Synth", 0, SV_IREG_MPU401, 0, 1, 0), @@ -1373,24 +1371,25 @@ SONICVIBES_SINGLE("SonicVibes External Rx to Synth", 0, SV_IREG_MPU401, 1, 1, 0) SONICVIBES_SINGLE("SonicVibes External Tx", 0, SV_IREG_MPU401, 2, 1, 0) }; -static int snd_sonicvibes_midi_input_open(mpu401_t * mpu) +static int snd_sonicvibes_midi_input_open(struct snd_mpu401 * mpu) { - sonicvibes_t *sonic = mpu->private_data; + struct sonicvibes *sonic = mpu->private_data; outb(sonic->irqmask &= ~SV_MIDI_MASK, SV_REG(sonic, IRQMASK)); return 0; } -static void snd_sonicvibes_midi_input_close(mpu401_t * mpu) +static void snd_sonicvibes_midi_input_close(struct snd_mpu401 * mpu) { - sonicvibes_t *sonic = mpu->private_data; + struct sonicvibes *sonic = mpu->private_data; outb(sonic->irqmask |= SV_MIDI_MASK, SV_REG(sonic, IRQMASK)); } -static int __devinit snd_sonicvibes_midi(sonicvibes_t * sonic, snd_rawmidi_t * rmidi) +static int __devinit snd_sonicvibes_midi(struct sonicvibes * sonic, + struct snd_rawmidi *rmidi) { - mpu401_t * mpu = rmidi->private_data; - snd_card_t *card = sonic->card; - snd_rawmidi_str_t *dir; + struct snd_mpu401 * mpu = rmidi->private_data; + struct snd_card *card = sonic->card; + struct snd_rawmidi_str *dir; unsigned int idx; int err; @@ -1408,10 +1407,10 @@ static int __devinit snd_sonic_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - sonicvibes_t *sonic; - snd_rawmidi_t *midi_uart; - opl3_t *opl3; + struct snd_card *card; + struct sonicvibes *sonic; + struct snd_rawmidi *midi_uart; + struct snd_opl3 *opl3; int idx, err; if (dev >= SNDRV_CARDS) -- cgit v1.1 From e437e3d7c7fb656010f8f767d20215e67b847685 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:06:15 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCI VIA82xx Modules: VIA82xx driver,VIA82xx-modem driver Remove xxx_t typedefs from the PCI VIA82xx and modem drivers. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pci/via82xx.c | 390 +++++++++++++++++++++++++--------------------- sound/pci/via82xx_modem.c | 217 ++++++++++++++------------ 2 files changed, 328 insertions(+), 279 deletions(-) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index f0d8c7f..c870001 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -303,12 +303,6 @@ DEFINE_VIA_REGSET(CAPTURE_8233, 0x60); /* - */ - -typedef struct _snd_via82xx via82xx_t; -typedef struct via_dev viadev_t; - -/* * pcm stream */ @@ -319,11 +313,11 @@ struct snd_via_sg_table { #define VIA_TABLE_SIZE 255 -struct via_dev { +struct viadev { unsigned int reg_offset; unsigned long port; int direction; /* playback = 0, capture = 1 */ - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int running; unsigned int tbl_entries; /* # descriptors */ struct snd_dma_buffer table; @@ -350,7 +344,7 @@ struct via_rate_lock { int used; }; -struct _snd_via82xx { +struct via82xx { int irq; unsigned long port; @@ -374,27 +368,27 @@ struct _snd_via82xx { unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */ struct pci_dev *pci; - snd_card_t *card; + struct snd_card *card; unsigned int num_devs; unsigned int playback_devno, multi_devno, capture_devno; - viadev_t devs[VIA_MAX_DEVS]; + struct viadev devs[VIA_MAX_DEVS]; struct via_rate_lock rates[2]; /* playback and capture */ unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ unsigned int dxs_src: 1; /* use full SRC capabilities of DXS */ unsigned int spdif_on: 1; /* only spdif rates work to external DACs */ - snd_pcm_t *pcms[2]; - snd_rawmidi_t *rmidi; + struct snd_pcm *pcms[2]; + struct snd_rawmidi *rmidi; - ac97_bus_t *ac97_bus; - ac97_t *ac97; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97; unsigned int ac97_clock; unsigned int ac97_secondary; /* secondary AC'97 codec is present */ spinlock_t reg_lock; - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; #ifdef SUPPORT_JOYSTICK struct gameport *gameport; @@ -419,12 +413,12 @@ MODULE_DEVICE_TABLE(pci, snd_via82xx_ids); * periods = number of periods * fragsize = period size in bytes */ -static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream, +static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substream, struct pci_dev *pci, unsigned int periods, unsigned int fragsize) { unsigned int i, idx, ofs, rest; - via82xx_t *chip = snd_pcm_substream_chip(substream); + struct via82xx *chip = snd_pcm_substream_chip(substream); struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); if (dev->table.area == NULL) { @@ -487,7 +481,7 @@ static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream, } -static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, +static int clean_via_table(struct viadev *dev, struct snd_pcm_substream *substream, struct pci_dev *pci) { if (dev->table.area) { @@ -503,17 +497,17 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, * Basic I/O */ -static inline unsigned int snd_via82xx_codec_xread(via82xx_t *chip) +static inline unsigned int snd_via82xx_codec_xread(struct via82xx *chip) { return inl(VIAREG(chip, AC97)); } -static inline void snd_via82xx_codec_xwrite(via82xx_t *chip, unsigned int val) +static inline void snd_via82xx_codec_xwrite(struct via82xx *chip, unsigned int val) { outl(val, VIAREG(chip, AC97)); } -static int snd_via82xx_codec_ready(via82xx_t *chip, int secondary) +static int snd_via82xx_codec_ready(struct via82xx *chip, int secondary) { unsigned int timeout = 1000; /* 1ms */ unsigned int val; @@ -523,11 +517,12 @@ static int snd_via82xx_codec_ready(via82xx_t *chip, int secondary) if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) return val & 0xffff; } - snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_via82xx_codec_xread(chip)); + snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", + secondary, snd_via82xx_codec_xread(chip)); return -EIO; } -static int snd_via82xx_codec_valid(via82xx_t *chip, int secondary) +static int snd_via82xx_codec_valid(struct via82xx *chip, int secondary) { unsigned int timeout = 1000; /* 1ms */ unsigned int val, val1; @@ -544,20 +539,20 @@ static int snd_via82xx_codec_valid(via82xx_t *chip, int secondary) return -EIO; } -static void snd_via82xx_codec_wait(ac97_t *ac97) +static void snd_via82xx_codec_wait(struct snd_ac97 *ac97) { - via82xx_t *chip = ac97->private_data; + struct via82xx *chip = ac97->private_data; int err; err = snd_via82xx_codec_ready(chip, ac97->num); /* here we need to wait fairly for long time.. */ msleep(500); } -static void snd_via82xx_codec_write(ac97_t *ac97, +static void snd_via82xx_codec_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - via82xx_t *chip = ac97->private_data; + struct via82xx *chip = ac97->private_data; unsigned int xval; xval = !ac97->num ? VIA_REG_AC97_CODEC_ID_PRIMARY : VIA_REG_AC97_CODEC_ID_SECONDARY; @@ -568,9 +563,9 @@ static void snd_via82xx_codec_write(ac97_t *ac97, snd_via82xx_codec_ready(chip, ac97->num); } -static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - via82xx_t *chip = ac97->private_data; + struct via82xx *chip = ac97->private_data; unsigned int xval, val = 0xffff; int again = 0; @@ -580,7 +575,8 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; while (1) { if (again++ > 3) { - snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", ac97->num, snd_via82xx_codec_xread(chip)); + snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", + ac97->num, snd_via82xx_codec_xread(chip)); return 0xffff; } snd_via82xx_codec_xwrite(chip, xval); @@ -594,7 +590,7 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) return val & 0xffff; } -static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev) +static void snd_via82xx_channel_reset(struct via82xx *chip, struct viadev *viadev) { outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET, VIADEV_REG(viadev, OFFSET_CONTROL)); @@ -617,7 +613,7 @@ static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev) */ static irqreturn_t snd_via686_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - via82xx_t *chip = dev_id; + struct via82xx *chip = dev_id; unsigned int status; unsigned int i; @@ -632,7 +628,7 @@ static irqreturn_t snd_via686_interrupt(int irq, void *dev_id, struct pt_regs *r /* check status for each stream */ spin_lock(&chip->reg_lock); for (i = 0; i < chip->num_devs; i++) { - viadev_t *viadev = &chip->devs[i]; + struct viadev *viadev = &chip->devs[i]; unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); if (! (c_status & (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED))) continue; @@ -663,7 +659,7 @@ static irqreturn_t snd_via686_interrupt(int irq, void *dev_id, struct pt_regs *r */ static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - via82xx_t *chip = dev_id; + struct via82xx *chip = dev_id; unsigned int status; unsigned int i; int irqreturn = 0; @@ -673,8 +669,8 @@ static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id, struct pt_regs * status = inl(VIAREG(chip, SGD_SHADOW)); for (i = 0; i < chip->num_devs; i++) { - viadev_t *viadev = &chip->devs[i]; - snd_pcm_substream_t *substream; + struct viadev *viadev = &chip->devs[i]; + struct snd_pcm_substream *substream; unsigned char c_status, shadow_status; shadow_status = (status >> viadev->shadow_shift) & @@ -719,10 +715,10 @@ static irqreturn_t snd_via8233_interrupt(int irq, void *dev_id, struct pt_regs * /* * trigger callback */ -static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; unsigned char val; if (chip->chip_type != TYPE_VIA686) @@ -766,9 +762,11 @@ static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd) */ #define check_invalid_pos(viadev,pos) \ - ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) + ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\ + viadev->lastpos < viadev->bufsize2)) -static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) +static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx, + unsigned int count) { unsigned int size, base, res; @@ -780,7 +778,8 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u /* check the validity of the calculated position */ if (size < count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", (int)size, (int)count); + snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", + (int)size, (int)count); res = viadev->lastpos; } else { if (! count) { @@ -796,12 +795,18 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u } if (check_invalid_pos(viadev, res)) { #ifdef POINTER_DEBUG - printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, " + "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, " + "count = 0x%x\n", idx, viadev->tbl_entries, + viadev->lastpos, viadev->bufsize2, + viadev->idx_table[idx].offset, + viadev->idx_table[idx].size, count); #endif /* count register returns full size when end of buffer is reached */ res = base + size; if (check_invalid_pos(viadev, res)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); + snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), " + "using last valid pointer\n"); res = viadev->lastpos; } } @@ -812,10 +817,10 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u /* * get the current pointer on via686 */ -static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; unsigned int idx, ptr, count, res; snd_assert(viadev->tbl_entries, return 0); @@ -842,10 +847,10 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream) /* * get the current pointer on via823x */ -static snd_pcm_uframes_t snd_via8233_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_via8233_pcm_pointer(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; unsigned int idx, count, res; int status; @@ -865,7 +870,8 @@ static snd_pcm_uframes_t snd_via8233_pcm_pointer(snd_pcm_substream_t *substream) idx = count >> 24; if (idx >= viadev->tbl_entries) { #ifdef POINTER_DEBUG - printk(KERN_DEBUG "fail: invalid idx = %i/%i\n", idx, viadev->tbl_entries); + printk(KERN_DEBUG "fail: invalid idx = %i/%i\n", idx, + viadev->tbl_entries); #endif res = viadev->lastpos; } else { @@ -895,11 +901,11 @@ unlock: * hw_params callback: * allocate the buffer and build up the buffer description table */ -static int snd_via82xx_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; int err; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); @@ -918,10 +924,10 @@ static int snd_via82xx_hw_params(snd_pcm_substream_t * substream, * hw_free callback: * clean up the buffer description table and release the buffer */ -static int snd_via82xx_hw_free(snd_pcm_substream_t * substream) +static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; clean_via_table(viadev, substream, chip->pci); snd_pcm_lib_free_pages(substream); @@ -932,7 +938,7 @@ static int snd_via82xx_hw_free(snd_pcm_substream_t * substream) /* * set up the table pointer */ -static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev) +static void snd_via82xx_set_table_ptr(struct via82xx *chip, struct viadev *viadev) { snd_via82xx_codec_ready(chip, 0); outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); @@ -943,7 +949,8 @@ static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev) /* * prepare callback for playback and capture on via686 */ -static void via686_setup_format(via82xx_t *chip, viadev_t *viadev, snd_pcm_runtime_t *runtime) +static void via686_setup_format(struct via82xx *chip, struct viadev *viadev, + struct snd_pcm_runtime *runtime) { snd_via82xx_channel_reset(chip, viadev); /* this must be set after channel_reset */ @@ -956,11 +963,11 @@ static void via686_setup_format(via82xx_t *chip, viadev_t *viadev, snd_pcm_runti VIA_REG_TYPE_INT_FLAG, VIADEV_REG(viadev, OFFSET_TYPE)); } -static int snd_via686_playback_prepare(snd_pcm_substream_t *substream) +static int snd_via686_playback_prepare(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; snd_ac97_set_rate(chip->ac97, AC97_PCM_FRONT_DAC_RATE, runtime->rate); snd_ac97_set_rate(chip->ac97, AC97_SPDIF, runtime->rate); @@ -968,11 +975,11 @@ static int snd_via686_playback_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_via686_capture_prepare(snd_pcm_substream_t *substream) +static int snd_via686_capture_prepare(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; snd_ac97_set_rate(chip->ac97, AC97_PCM_LR_ADC_RATE, runtime->rate); via686_setup_format(chip, viadev, runtime); @@ -1002,11 +1009,11 @@ static int via_lock_rate(struct via_rate_lock *rec, int rate) /* * prepare callback for DSX playback on via823x */ -static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream) +static int snd_via8233_playback_prepare(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; int ac97_rate = chip->dxs_src ? 48000 : runtime->rate; int rate_changed; u32 rbits; @@ -1022,12 +1029,15 @@ static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream) if (runtime->rate == 48000) rbits = 0xfffff; else - rbits = (0x100000 / 48000) * runtime->rate + ((0x100000 % 48000) * runtime->rate) / 48000; + rbits = (0x100000 / 48000) * runtime->rate + + ((0x100000 % 48000) * runtime->rate) / 48000; snd_assert((rbits & ~0xfffff) == 0, return -EINVAL); snd_via82xx_channel_reset(chip, viadev); snd_via82xx_set_table_ptr(chip, viadev); - outb(chip->playback_volume[viadev->reg_offset / 0x10][0], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L)); - outb(chip->playback_volume[viadev->reg_offset / 0x10][1], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R)); + outb(chip->playback_volume[viadev->reg_offset / 0x10][0], + VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L)); + outb(chip->playback_volume[viadev->reg_offset / 0x10][1], + VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R)); outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */ (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | /* stereo */ rbits | /* rate */ @@ -1041,11 +1051,11 @@ static int snd_via8233_playback_prepare(snd_pcm_substream_t *substream) /* * prepare callback for multi-channel playback on via823x */ -static int snd_via8233_multi_prepare(snd_pcm_substream_t *substream) +static int snd_via8233_multi_prepare(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int slots; int fmt; @@ -1058,7 +1068,8 @@ static int snd_via8233_multi_prepare(snd_pcm_substream_t *substream) snd_via82xx_channel_reset(chip, viadev); snd_via82xx_set_table_ptr(chip, viadev); - fmt = (runtime->format == SNDRV_PCM_FORMAT_S16_LE) ? VIA_REG_MULTPLAY_FMT_16BIT : VIA_REG_MULTPLAY_FMT_8BIT; + fmt = (runtime->format == SNDRV_PCM_FORMAT_S16_LE) ? + VIA_REG_MULTPLAY_FMT_16BIT : VIA_REG_MULTPLAY_FMT_8BIT; fmt |= runtime->channels << 4; outb(fmt, VIADEV_REG(viadev, OFS_MULTPLAY_FORMAT)); #if 0 @@ -1089,11 +1100,11 @@ static int snd_via8233_multi_prepare(snd_pcm_substream_t *substream) /* * prepare callback for capture on via823x */ -static int snd_via8233_capture_prepare(snd_pcm_substream_t *substream) +static int snd_via8233_capture_prepare(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; if (via_lock_rate(&chip->rates[1], runtime->rate) < 0) return -EINVAL; @@ -1114,7 +1125,7 @@ static int snd_via8233_capture_prepare(snd_pcm_substream_t *substream) /* * pcm hardware definition, identical for both playback and capture */ -static snd_pcm_hardware_t snd_via82xx_hw = +static struct snd_pcm_hardware snd_via82xx_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1139,9 +1150,10 @@ static snd_pcm_hardware_t snd_via82xx_hw = /* * open callback skeleton */ -static int snd_via82xx_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm_substream_t * substream) +static int snd_via82xx_pcm_open(struct via82xx *chip, struct viadev *viadev, + struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; struct via_rate_lock *ratep; @@ -1191,10 +1203,10 @@ static int snd_via82xx_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm_subst /* * open callback for playback on via686 and via823x DSX */ -static int snd_via82xx_playback_open(snd_pcm_substream_t * substream) +static int snd_via82xx_playback_open(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = &chip->devs[chip->playback_devno + substream->number]; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number]; int err; if ((err = snd_via82xx_pcm_open(chip, viadev, substream)) < 0) @@ -1205,10 +1217,10 @@ static int snd_via82xx_playback_open(snd_pcm_substream_t * substream) /* * open callback for playback on via823x multi-channel */ -static int snd_via8233_multi_open(snd_pcm_substream_t * substream) +static int snd_via8233_multi_open(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = &chip->devs[chip->multi_devno]; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = &chip->devs[chip->multi_devno]; int err; /* channels constraint for VIA8233A * 3 and 5 channels are not supported @@ -1216,7 +1228,7 @@ static int snd_via8233_multi_open(snd_pcm_substream_t * substream) static unsigned int channels[] = { 1, 2, 4, 6 }; - static snd_pcm_hw_constraint_list_t hw_constraints_channels = { + static struct snd_pcm_hw_constraint_list hw_constraints_channels = { .count = ARRAY_SIZE(channels), .list = channels, .mask = 0, @@ -1226,17 +1238,19 @@ static int snd_via8233_multi_open(snd_pcm_substream_t * substream) return err; substream->runtime->hw.channels_max = 6; if (chip->revision == VIA_REV_8233A) - snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_channels); + snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + &hw_constraints_channels); return 0; } /* * open callback for capture on via686 and via823x */ -static int snd_via82xx_capture_open(snd_pcm_substream_t * substream) +static int snd_via82xx_capture_open(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; return snd_via82xx_pcm_open(chip, viadev, substream); } @@ -1244,10 +1258,10 @@ static int snd_via82xx_capture_open(snd_pcm_substream_t * substream) /* * close callback */ -static int snd_via82xx_pcm_close(snd_pcm_substream_t * substream) +static int snd_via82xx_pcm_close(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; struct via_rate_lock *ratep; /* release the rate lock */ @@ -1264,7 +1278,7 @@ static int snd_via82xx_pcm_close(snd_pcm_substream_t * substream) /* via686 playback callbacks */ -static snd_pcm_ops_t snd_via686_playback_ops = { +static struct snd_pcm_ops snd_via686_playback_ops = { .open = snd_via82xx_playback_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -1277,7 +1291,7 @@ static snd_pcm_ops_t snd_via686_playback_ops = { }; /* via686 capture callbacks */ -static snd_pcm_ops_t snd_via686_capture_ops = { +static struct snd_pcm_ops snd_via686_capture_ops = { .open = snd_via82xx_capture_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -1290,7 +1304,7 @@ static snd_pcm_ops_t snd_via686_capture_ops = { }; /* via823x DSX playback callbacks */ -static snd_pcm_ops_t snd_via8233_playback_ops = { +static struct snd_pcm_ops snd_via8233_playback_ops = { .open = snd_via82xx_playback_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -1303,7 +1317,7 @@ static snd_pcm_ops_t snd_via8233_playback_ops = { }; /* via823x multi-channel playback callbacks */ -static snd_pcm_ops_t snd_via8233_multi_ops = { +static struct snd_pcm_ops snd_via8233_multi_ops = { .open = snd_via8233_multi_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -1316,7 +1330,7 @@ static snd_pcm_ops_t snd_via8233_multi_ops = { }; /* via823x capture callbacks */ -static snd_pcm_ops_t snd_via8233_capture_ops = { +static struct snd_pcm_ops snd_via8233_capture_ops = { .open = snd_via82xx_capture_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -1329,7 +1343,8 @@ static snd_pcm_ops_t snd_via8233_capture_ops = { }; -static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int shadow_pos, int direction) +static void init_viadev(struct via82xx *chip, int idx, unsigned int reg_offset, + int shadow_pos, int direction) { chip->devs[idx].reg_offset = reg_offset; chip->devs[idx].shadow_shift = shadow_pos * 4; @@ -1340,9 +1355,9 @@ static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int s /* * create pcm instances for VIA8233, 8233C and 8235 (not 8233A) */ -static int __devinit snd_via8233_pcm_new(via82xx_t *chip) +static int __devinit snd_via8233_pcm_new(struct via82xx *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int i, err; chip->playback_devno = 0; /* x 4 */ @@ -1367,7 +1382,8 @@ static int __devinit snd_via8233_pcm_new(via82xx_t *chip) init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024)) < 0) return err; /* PCM #1: multi-channel playback and 2nd capture */ @@ -1385,7 +1401,8 @@ static int __devinit snd_via8233_pcm_new(via82xx_t *chip) init_viadev(chip, chip->capture_devno + 1, VIA_REG_CAPTURE_8233_STATUS + 0x10, 7, 1); if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024)) < 0) return err; return 0; @@ -1394,9 +1411,9 @@ static int __devinit snd_via8233_pcm_new(via82xx_t *chip) /* * create pcm instances for VIA8233A */ -static int __devinit snd_via8233a_pcm_new(via82xx_t *chip) +static int __devinit snd_via8233a_pcm_new(struct via82xx *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; chip->multi_devno = 0; @@ -1420,7 +1437,8 @@ static int __devinit snd_via8233a_pcm_new(via82xx_t *chip) init_viadev(chip, chip->capture_devno, VIA_REG_CAPTURE_8233_STATUS, 6, 1); if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024)) < 0) return err; /* SPDIF supported? */ @@ -1439,7 +1457,8 @@ static int __devinit snd_via8233a_pcm_new(via82xx_t *chip) init_viadev(chip, chip->playback_devno, 0x30, 3, 0); if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024)) < 0) return err; return 0; @@ -1448,9 +1467,9 @@ static int __devinit snd_via8233a_pcm_new(via82xx_t *chip) /* * create a pcm instance for via686a/b */ -static int __devinit snd_via686_pcm_new(via82xx_t *chip) +static int __devinit snd_via686_pcm_new(struct via82xx *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; chip->playback_devno = 0; @@ -1470,7 +1489,8 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip) init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1); if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024)) < 0) return err; return 0; @@ -1481,7 +1501,8 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip) * Mixer part */ -static int snd_via8233_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_via8233_capture_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { /* formerly they were "Line" and "Mic", but it looks like that they * have nothing to do with the actual physical connections... @@ -1498,17 +1519,19 @@ static int snd_via8233_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_via8233_capture_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_via8233_capture_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - via82xx_t *chip = snd_kcontrol_chip(kcontrol); + struct via82xx *chip = snd_kcontrol_chip(kcontrol); unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG_CAPTURE_CHANNEL); ucontrol->value.enumerated.item[0] = inb(port) & VIA_REG_CAPTURE_CHANNEL_MIC ? 1 : 0; return 0; } -static int snd_via8233_capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_via8233_capture_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - via82xx_t *chip = snd_kcontrol_chip(kcontrol); + struct via82xx *chip = snd_kcontrol_chip(kcontrol); unsigned long port = chip->port + (kcontrol->id.index ? (VIA_REG_CAPTURE_CHANNEL + 0x10) : VIA_REG_CAPTURE_CHANNEL); u8 val, oval; @@ -1523,7 +1546,7 @@ static int snd_via8233_capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem return val != oval; } -static snd_kcontrol_new_t snd_via8233_capture_source __devinitdata = { +static struct snd_kcontrol_new snd_via8233_capture_source __devinitdata = { .name = "Input Source Select", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_via8233_capture_source_info, @@ -1531,7 +1554,8 @@ static snd_kcontrol_new_t snd_via8233_capture_source __devinitdata = { .put = snd_via8233_capture_source_put, }; -static int snd_via8233_dxs3_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_via8233_dxs3_spdif_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1540,9 +1564,10 @@ static int snd_via8233_dxs3_spdif_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_in return 0; } -static int snd_via8233_dxs3_spdif_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_via8233_dxs3_spdif_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - via82xx_t *chip = snd_kcontrol_chip(kcontrol); + struct via82xx *chip = snd_kcontrol_chip(kcontrol); u8 val; pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &val); @@ -1550,9 +1575,10 @@ static int snd_via8233_dxs3_spdif_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return 0; } -static int snd_via8233_dxs3_spdif_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_via8233_dxs3_spdif_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - via82xx_t *chip = snd_kcontrol_chip(kcontrol); + struct via82xx *chip = snd_kcontrol_chip(kcontrol); u8 val, oval; pci_read_config_byte(chip->pci, VIA8233_SPDIF_CTRL, &oval); @@ -1568,7 +1594,7 @@ static int snd_via8233_dxs3_spdif_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return 0; } -static snd_kcontrol_new_t snd_via8233_dxs3_spdif_control __devinitdata = { +static struct snd_kcontrol_new snd_via8233_dxs3_spdif_control __devinitdata = { .name = SNDRV_CTL_NAME_IEC958("Output ",NONE,SWITCH), .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_via8233_dxs3_spdif_info, @@ -1576,7 +1602,8 @@ static snd_kcontrol_new_t snd_via8233_dxs3_spdif_control __devinitdata = { .put = snd_via8233_dxs3_spdif_put, }; -static int snd_via8233_dxs_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_via8233_dxs_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -1585,9 +1612,10 @@ static int snd_via8233_dxs_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_in return 0; } -static int snd_via8233_dxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_via8233_dxs_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - via82xx_t *chip = snd_kcontrol_chip(kcontrol); + struct via82xx *chip = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id); ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][0]; @@ -1595,17 +1623,19 @@ static int snd_via8233_dxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return 0; } -static int snd_via8233_pcmdxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_via8233_pcmdxs_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - via82xx_t *chip = snd_kcontrol_chip(kcontrol); + struct via82xx *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[0]; ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume_c[1]; return 0; } -static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_via8233_dxs_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - via82xx_t *chip = snd_kcontrol_chip(kcontrol); + struct via82xx *chip = snd_kcontrol_chip(kcontrol); unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id); unsigned long port = chip->port + 0x10 * idx; unsigned char val; @@ -1625,9 +1655,10 @@ static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_val return change; } -static int snd_via8233_pcmdxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_via8233_pcmdxs_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - via82xx_t *chip = snd_kcontrol_chip(kcontrol); + struct via82xx *chip = snd_kcontrol_chip(kcontrol); unsigned int idx; unsigned char val; int i, change = 0; @@ -1650,7 +1681,7 @@ static int snd_via8233_pcmdxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return change; } -static snd_kcontrol_new_t snd_via8233_pcmdxs_volume_control __devinitdata = { +static struct snd_kcontrol_new snd_via8233_pcmdxs_volume_control __devinitdata = { .name = "PCM Playback Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .info = snd_via8233_dxs_volume_info, @@ -1658,7 +1689,7 @@ static snd_kcontrol_new_t snd_via8233_pcmdxs_volume_control __devinitdata = { .put = snd_via8233_pcmdxs_volume_put, }; -static snd_kcontrol_new_t snd_via8233_dxs_volume_control __devinitdata = { +static struct snd_kcontrol_new snd_via8233_dxs_volume_control __devinitdata = { .name = "VIA DXS Playback Volume", .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .count = 4, @@ -1670,15 +1701,15 @@ static snd_kcontrol_new_t snd_via8233_dxs_volume_control __devinitdata = { /* */ -static void snd_via82xx_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_via82xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - via82xx_t *chip = bus->private_data; + struct via82xx *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_via82xx_mixer_free_ac97(ac97_t *ac97) +static void snd_via82xx_mixer_free_ac97(struct snd_ac97 *ac97) { - via82xx_t *chip = ac97->private_data; + struct via82xx *chip = ac97->private_data; chip->ac97 = NULL; } @@ -1735,11 +1766,11 @@ static struct ac97_quirk ac97_quirks[] = { { } /* terminator */ }; -static int __devinit snd_via82xx_mixer_new(via82xx_t *chip, const char *quirk_override) +static int __devinit snd_via82xx_mixer_new(struct via82xx *chip, const char *quirk_override) { - ac97_template_t ac97; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_via82xx_codec_write, .read = snd_via82xx_codec_read, .wait = snd_via82xx_codec_wait, @@ -1770,7 +1801,7 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip, const char *quirk_ov #ifdef SUPPORT_JOYSTICK #define JOYSTICK_ADDR 0x200 -static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *legacy) +static int __devinit snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy) { struct gameport *gp; struct resource *r; @@ -1780,7 +1811,8 @@ static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char * r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport"); if (!r) { - printk(KERN_WARNING "via82xx: cannot reserve joystick port 0x%#x\n", JOYSTICK_ADDR); + printk(KERN_WARNING "via82xx: cannot reserve joystick port 0x%#x\n", + JOYSTICK_ADDR); return -EBUSY; } @@ -1806,7 +1838,7 @@ static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char * return 0; } -static void snd_via686_free_gameport(via82xx_t *chip) +static void snd_via686_free_gameport(struct via82xx *chip) { if (chip->gameport) { struct resource *r = gameport_get_port_data(chip->gameport); @@ -1817,11 +1849,11 @@ static void snd_via686_free_gameport(via82xx_t *chip) } } #else -static inline int snd_via686_create_gameport(via82xx_t *chip, unsigned char *legacy) +static inline int snd_via686_create_gameport(struct via82xx *chip, unsigned char *legacy) { return -ENOSYS; } -static inline void snd_via686_free_gameport(via82xx_t *chip) { } +static inline void snd_via686_free_gameport(struct via82xx *chip) { } #endif @@ -1829,7 +1861,7 @@ static inline void snd_via686_free_gameport(via82xx_t *chip) { } * */ -static int __devinit snd_via8233_init_misc(via82xx_t *chip) +static int __devinit snd_via8233_init_misc(struct via82xx *chip) { int i, err, caps; unsigned char val; @@ -1850,7 +1882,7 @@ static int __devinit snd_via8233_init_misc(via82xx_t *chip) /* when no h/w PCM volume control is found, use DXS volume control * as the PCM vol control */ - snd_ctl_elem_id_t sid; + struct snd_ctl_elem_id sid; memset(&sid, 0, sizeof(sid)); strcpy(sid.name, "PCM Playback Volume"); sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; @@ -1877,7 +1909,7 @@ static int __devinit snd_via8233_init_misc(via82xx_t *chip) return 0; } -static int __devinit snd_via686_init_misc(via82xx_t *chip) +static int __devinit snd_via686_init_misc(struct via82xx *chip) { unsigned char legacy, legacy_cfg; int rev_h = 0; @@ -1954,9 +1986,10 @@ static int __devinit snd_via686_init_misc(via82xx_t *chip) /* * proc interface */ -static void snd_via82xx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_via82xx_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { - via82xx_t *chip = entry->private_data; + struct via82xx *chip = entry->private_data; int i; snd_iprintf(buffer, "%s\n\n", chip->card->longname); @@ -1965,9 +1998,9 @@ static void snd_via82xx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *bu } } -static void __devinit snd_via82xx_proc_init(via82xx_t *chip) +static void __devinit snd_via82xx_proc_init(struct via82xx *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "via82xx", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_via82xx_proc_read); @@ -1977,7 +2010,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip) * */ -static int snd_via82xx_chip_init(via82xx_t *chip) +static int snd_via82xx_chip_init(struct via82xx *chip) { unsigned int val; unsigned long end_time; @@ -2080,7 +2113,8 @@ static int snd_via82xx_chip_init(via82xx_t *chip) unsigned long port = chip->port + 0x10 * idx; for (i = 0; i < 2; i++) { chip->playback_volume[idx][i]=chip->playback_volume_c[i]; - outb(chip->playback_volume_c[i], port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i); + outb(chip->playback_volume_c[i], + port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i); } } } @@ -2092,9 +2126,9 @@ static int snd_via82xx_chip_init(via82xx_t *chip) /* * power management */ -static int snd_via82xx_suspend(snd_card_t *card, pm_message_t state) +static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state) { - via82xx_t *chip = card->pm_private_data; + struct via82xx *chip = card->pm_private_data; int i; for (i = 0; i < 2; i++) @@ -2117,9 +2151,9 @@ static int snd_via82xx_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_via82xx_resume(snd_card_t *card) +static int snd_via82xx_resume(struct snd_card *card) { - via82xx_t *chip = card->pm_private_data; + struct via82xx *chip = card->pm_private_data; int i; pci_enable_device(chip->pci); @@ -2147,7 +2181,7 @@ static int snd_via82xx_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -static int snd_via82xx_free(via82xx_t *chip) +static int snd_via82xx_free(struct via82xx *chip) { unsigned int i; @@ -2159,7 +2193,7 @@ static int snd_via82xx_free(via82xx_t *chip) synchronize_irq(chip->irq); __end_hw: if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); release_and_free_resource(chip->mpu_res); pci_release_regions(chip->pci); @@ -2173,22 +2207,22 @@ static int snd_via82xx_free(via82xx_t *chip) return 0; } -static int snd_via82xx_dev_free(snd_device_t *device) +static int snd_via82xx_dev_free(struct snd_device *device) { - via82xx_t *chip = device->device_data; + struct via82xx *chip = device->device_data; return snd_via82xx_free(chip); } -static int __devinit snd_via82xx_create(snd_card_t * card, +static int __devinit snd_via82xx_create(struct snd_card *card, struct pci_dev *pci, int chip_type, int revision, unsigned int ac97_clock, - via82xx_t ** r_via) + struct via82xx ** r_via) { - via82xx_t *chip; + struct via82xx *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_via82xx_dev_free, }; @@ -2225,7 +2259,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card, chip_type == TYPE_VIA8233 ? snd_via8233_interrupt : snd_via686_interrupt, SA_INTERRUPT|SA_SHIRQ, - card->driver, (void *)chip)) { + card->driver, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_via82xx_free(chip); return -EBUSY; @@ -2363,8 +2397,8 @@ static int __devinit check_dxs_list(struct pci_dev *pci) static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - via82xx_t *chip; + struct snd_card *card; + struct via82xx *chip; unsigned char revision; int chip_type = 0, card_type; unsigned int i; diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index b83660b..55ef69a 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -206,9 +206,6 @@ DEFINE_VIA_REGSET(MI, 0x50); VIA_MC97_CTRL_SECONDARY) -typedef struct _snd_via82xx_modem via82xx_t; -typedef struct via_dev viadev_t; - /* * pcm stream */ @@ -220,11 +217,11 @@ struct snd_via_sg_table { #define VIA_TABLE_SIZE 255 -struct via_dev { +struct viadev { unsigned int reg_offset; unsigned long port; int direction; /* playback = 0, capture = 1 */ - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; int running; unsigned int tbl_entries; /* # descriptors */ struct snd_dma_buffer table; @@ -239,7 +236,7 @@ enum { TYPE_CARD_VIA82XX_MODEM = 1 }; #define VIA_MAX_MODEM_DEVS 2 -struct _snd_via82xx_modem { +struct via82xx_modem { int irq; unsigned long port; @@ -247,21 +244,21 @@ struct _snd_via82xx_modem { unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */ struct pci_dev *pci; - snd_card_t *card; + struct snd_card *card; unsigned int num_devs; unsigned int playback_devno, capture_devno; - viadev_t devs[VIA_MAX_MODEM_DEVS]; + struct viadev devs[VIA_MAX_MODEM_DEVS]; - snd_pcm_t *pcms[2]; + struct snd_pcm *pcms[2]; - ac97_bus_t *ac97_bus; - ac97_t *ac97; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97; unsigned int ac97_clock; unsigned int ac97_secondary; /* secondary AC'97 codec is present */ spinlock_t reg_lock; - snd_info_entry_t *proc_entry; + struct snd_info_entry *proc_entry; }; static struct pci_device_id snd_via82xx_modem_ids[] = { @@ -279,12 +276,12 @@ MODULE_DEVICE_TABLE(pci, snd_via82xx_modem_ids); * periods = number of periods * fragsize = period size in bytes */ -static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream, +static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substream, struct pci_dev *pci, unsigned int periods, unsigned int fragsize) { unsigned int i, idx, ofs, rest; - via82xx_t *chip = snd_pcm_substream_chip(substream); + struct via82xx_modem *chip = snd_pcm_substream_chip(substream); struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); if (dev->table.area == NULL) { @@ -346,7 +343,7 @@ static int build_via_table(viadev_t *dev, snd_pcm_substream_t *substream, } -static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, +static int clean_via_table(struct viadev *dev, struct snd_pcm_substream *substream, struct pci_dev *pci) { if (dev->table.area) { @@ -362,17 +359,17 @@ static int clean_via_table(viadev_t *dev, snd_pcm_substream_t *substream, * Basic I/O */ -static inline unsigned int snd_via82xx_codec_xread(via82xx_t *chip) +static inline unsigned int snd_via82xx_codec_xread(struct via82xx_modem *chip) { return inl(VIAREG(chip, AC97)); } -static inline void snd_via82xx_codec_xwrite(via82xx_t *chip, unsigned int val) +static inline void snd_via82xx_codec_xwrite(struct via82xx_modem *chip, unsigned int val) { outl(val, VIAREG(chip, AC97)); } -static int snd_via82xx_codec_ready(via82xx_t *chip, int secondary) +static int snd_via82xx_codec_ready(struct via82xx_modem *chip, int secondary) { unsigned int timeout = 1000; /* 1ms */ unsigned int val; @@ -382,11 +379,12 @@ static int snd_via82xx_codec_ready(via82xx_t *chip, int secondary) if (!((val = snd_via82xx_codec_xread(chip)) & VIA_REG_AC97_BUSY)) return val & 0xffff; } - snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", secondary, snd_via82xx_codec_xread(chip)); + snd_printk(KERN_ERR "codec_ready: codec %i is not ready [0x%x]\n", + secondary, snd_via82xx_codec_xread(chip)); return -EIO; } -static int snd_via82xx_codec_valid(via82xx_t *chip, int secondary) +static int snd_via82xx_codec_valid(struct via82xx_modem *chip, int secondary) { unsigned int timeout = 1000; /* 1ms */ unsigned int val, val1; @@ -403,20 +401,20 @@ static int snd_via82xx_codec_valid(via82xx_t *chip, int secondary) return -EIO; } -static void snd_via82xx_codec_wait(ac97_t *ac97) +static void snd_via82xx_codec_wait(struct snd_ac97 *ac97) { - via82xx_t *chip = ac97->private_data; + struct via82xx_modem *chip = ac97->private_data; int err; err = snd_via82xx_codec_ready(chip, ac97->num); /* here we need to wait fairly for long time.. */ msleep(500); } -static void snd_via82xx_codec_write(ac97_t *ac97, +static void snd_via82xx_codec_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - via82xx_t *chip = ac97->private_data; + struct via82xx_modem *chip = ac97->private_data; unsigned int xval; if(reg == AC97_GPIO_STATUS) { outl(val, VIAREG(chip, GPI_STATUS)); @@ -430,9 +428,9 @@ static void snd_via82xx_codec_write(ac97_t *ac97, snd_via82xx_codec_ready(chip, ac97->num); } -static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) +static unsigned short snd_via82xx_codec_read(struct snd_ac97 *ac97, unsigned short reg) { - via82xx_t *chip = ac97->private_data; + struct via82xx_modem *chip = ac97->private_data; unsigned int xval, val = 0xffff; int again = 0; @@ -442,7 +440,8 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; while (1) { if (again++ > 3) { - snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", ac97->num, snd_via82xx_codec_xread(chip)); + snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", + ac97->num, snd_via82xx_codec_xread(chip)); return 0xffff; } snd_via82xx_codec_xwrite(chip, xval); @@ -456,7 +455,7 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) return val & 0xffff; } -static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev) +static void snd_via82xx_channel_reset(struct via82xx_modem *chip, struct viadev *viadev) { outb(VIA_REG_CTRL_PAUSE | VIA_REG_CTRL_TERMINATE | VIA_REG_CTRL_RESET, VIADEV_REG(viadev, OFFSET_CONTROL)); @@ -478,7 +477,7 @@ static void snd_via82xx_channel_reset(via82xx_t *chip, viadev_t *viadev) static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - via82xx_t *chip = dev_id; + struct via82xx_modem *chip = dev_id; unsigned int status; unsigned int i; @@ -491,7 +490,7 @@ static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs * /* check status for each stream */ spin_lock(&chip->reg_lock); for (i = 0; i < chip->num_devs; i++) { - viadev_t *viadev = &chip->devs[i]; + struct viadev *viadev = &chip->devs[i]; unsigned char c_status = inb(VIADEV_REG(viadev, OFFSET_STATUS)); c_status &= (VIA_REG_STAT_EOL|VIA_REG_STAT_FLAG|VIA_REG_STAT_STOPPED); if (! c_status) @@ -514,10 +513,10 @@ static irqreturn_t snd_via82xx_interrupt(int irq, void *dev_id, struct pt_regs * /* * trigger callback */ -static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_via82xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx_modem *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; unsigned char val = 0; switch (cmd) { @@ -555,9 +554,11 @@ static int snd_via82xx_pcm_trigger(snd_pcm_substream_t * substream, int cmd) */ #define check_invalid_pos(viadev,pos) \ - ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 || viadev->lastpos < viadev->bufsize2)) + ((pos) < viadev->lastpos && ((pos) >= viadev->bufsize2 ||\ + viadev->lastpos < viadev->bufsize2)) -static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, unsigned int count) +static inline unsigned int calc_linear_pos(struct viadev *viadev, unsigned int idx, + unsigned int count) { unsigned int size, res; @@ -566,24 +567,33 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u /* check the validity of the calculated position */ if (size < count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", (int)size, (int)count); + snd_printd(KERN_ERR "invalid via82xx_cur_ptr (size = %d, count = %d)\n", + (int)size, (int)count); res = viadev->lastpos; } else if (check_invalid_pos(viadev, res)) { #ifdef POINTER_DEBUG - printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count); + printk(KERN_DEBUG "fail: idx = %i/%i, lastpos = 0x%x, " + "bufsize2 = 0x%x, offsize = 0x%x, size = 0x%x, " + "count = 0x%x\n", idx, viadev->tbl_entries, viadev->lastpos, + viadev->bufsize2, viadev->idx_table[idx].offset, + viadev->idx_table[idx].size, count); #endif if (count && size < count) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr, using last valid pointer\n"); + snd_printd(KERN_ERR "invalid via82xx_cur_ptr, " + "using last valid pointer\n"); res = viadev->lastpos; } else { if (! count) /* bogus count 0 on the DMA boundary? */ res = viadev->idx_table[idx].offset; else - /* count register returns full size when end of buffer is reached */ + /* count register returns full size + * when end of buffer is reached + */ res = viadev->idx_table[idx].offset + size; if (check_invalid_pos(viadev, res)) { - snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), using last valid pointer\n"); + snd_printd(KERN_ERR "invalid via82xx_cur_ptr (2), " + "using last valid pointer\n"); res = viadev->lastpos; } } @@ -597,10 +607,10 @@ static inline unsigned int calc_linear_pos(viadev_t *viadev, unsigned int idx, u /* * get the current pointer on via686 */ -static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_via686_pcm_pointer(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx_modem *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; unsigned int idx, ptr, count, res; snd_assert(viadev->tbl_entries, return 0); @@ -616,7 +626,8 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream) if (ptr <= (unsigned int)viadev->table.addr) idx = 0; else /* CURR_PTR holds the address + 8 */ - idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % viadev->tbl_entries; + idx = ((ptr - (unsigned int)viadev->table.addr) / 8 - 1) % + viadev->tbl_entries; res = calc_linear_pos(viadev, idx, count); spin_unlock(&chip->reg_lock); @@ -627,11 +638,11 @@ static snd_pcm_uframes_t snd_via686_pcm_pointer(snd_pcm_substream_t *substream) * hw_params callback: * allocate the buffer and build up the buffer description table */ -static int snd_via82xx_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_via82xx_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx_modem *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; int err; err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); @@ -653,10 +664,10 @@ static int snd_via82xx_hw_params(snd_pcm_substream_t * substream, * hw_free callback: * clean up the buffer description table and release the buffer */ -static int snd_via82xx_hw_free(snd_pcm_substream_t * substream) +static int snd_via82xx_hw_free(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx_modem *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; clean_via_table(viadev, substream, chip->pci); snd_pcm_lib_free_pages(substream); @@ -667,7 +678,7 @@ static int snd_via82xx_hw_free(snd_pcm_substream_t * substream) /* * set up the table pointer */ -static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev) +static void snd_via82xx_set_table_ptr(struct via82xx_modem *chip, struct viadev *viadev) { snd_via82xx_codec_ready(chip, chip->ac97_secondary); outl((u32)viadev->table.addr, VIADEV_REG(viadev, OFFSET_TABLE_PTR)); @@ -678,10 +689,10 @@ static void snd_via82xx_set_table_ptr(via82xx_t *chip, viadev_t *viadev) /* * prepare callback for playback and capture */ -static int snd_via82xx_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_via82xx_pcm_prepare(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct via82xx_modem *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = substream->runtime->private_data; snd_via82xx_channel_reset(chip, viadev); /* this must be set after channel_reset */ @@ -694,7 +705,7 @@ static int snd_via82xx_pcm_prepare(snd_pcm_substream_t *substream) /* * pcm hardware definition, identical for both playback and capture */ -static snd_pcm_hardware_t snd_via82xx_hw = +static struct snd_pcm_hardware snd_via82xx_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -719,12 +730,13 @@ static snd_pcm_hardware_t snd_via82xx_hw = /* * open callback skeleton */ -static int snd_via82xx_modem_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm_substream_t * substream) +static int snd_via82xx_modem_pcm_open(struct via82xx_modem *chip, struct viadev *viadev, + struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int err; static unsigned int rates[] = { 8000, 9600, 12000, 16000 }; - static snd_pcm_hw_constraint_list_t hw_constraints_rates = { + static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, @@ -732,7 +744,8 @@ static int snd_via82xx_modem_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm runtime->hw = snd_via82xx_hw; - if ((err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates)) < 0) + if ((err = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &hw_constraints_rates)) < 0) return err; /* we may remove following constaint when we modify table entries @@ -750,10 +763,10 @@ static int snd_via82xx_modem_pcm_open(via82xx_t *chip, viadev_t *viadev, snd_pcm /* * open callback for playback */ -static int snd_via82xx_playback_open(snd_pcm_substream_t * substream) +static int snd_via82xx_playback_open(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = &chip->devs[chip->playback_devno + substream->number]; + struct via82xx_modem *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = &chip->devs[chip->playback_devno + substream->number]; return snd_via82xx_modem_pcm_open(chip, viadev, substream); } @@ -761,10 +774,10 @@ static int snd_via82xx_playback_open(snd_pcm_substream_t * substream) /* * open callback for capture */ -static int snd_via82xx_capture_open(snd_pcm_substream_t * substream) +static int snd_via82xx_capture_open(struct snd_pcm_substream *substream) { - via82xx_t *chip = snd_pcm_substream_chip(substream); - viadev_t *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; + struct via82xx_modem *chip = snd_pcm_substream_chip(substream); + struct viadev *viadev = &chip->devs[chip->capture_devno + substream->pcm->device]; return snd_via82xx_modem_pcm_open(chip, viadev, substream); } @@ -772,9 +785,9 @@ static int snd_via82xx_capture_open(snd_pcm_substream_t * substream) /* * close callback */ -static int snd_via82xx_pcm_close(snd_pcm_substream_t * substream) +static int snd_via82xx_pcm_close(struct snd_pcm_substream *substream) { - viadev_t *viadev = (viadev_t *)substream->runtime->private_data; + struct viadev *viadev = substream->runtime->private_data; viadev->substream = NULL; return 0; @@ -782,7 +795,7 @@ static int snd_via82xx_pcm_close(snd_pcm_substream_t * substream) /* via686 playback callbacks */ -static snd_pcm_ops_t snd_via686_playback_ops = { +static struct snd_pcm_ops snd_via686_playback_ops = { .open = snd_via82xx_playback_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -795,7 +808,7 @@ static snd_pcm_ops_t snd_via686_playback_ops = { }; /* via686 capture callbacks */ -static snd_pcm_ops_t snd_via686_capture_ops = { +static struct snd_pcm_ops snd_via686_capture_ops = { .open = snd_via82xx_capture_open, .close = snd_via82xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -808,7 +821,8 @@ static snd_pcm_ops_t snd_via686_capture_ops = { }; -static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int direction) +static void init_viadev(struct via82xx_modem *chip, int idx, unsigned int reg_offset, + int direction) { chip->devs[idx].reg_offset = reg_offset; chip->devs[idx].direction = direction; @@ -818,9 +832,9 @@ static void init_viadev(via82xx_t *chip, int idx, unsigned int reg_offset, int d /* * create a pcm instance for via686a/b */ -static int __devinit snd_via686_pcm_new(via82xx_t *chip) +static int __devinit snd_via686_pcm_new(struct via82xx_modem *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; chip->playback_devno = 0; @@ -841,7 +855,8 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip) init_viadev(chip, 1, VIA_REG_MI_STATUS, 1); if ((err = snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV_SG, - snd_dma_pci_data(chip->pci), 64*1024, 128*1024)) < 0) + snd_dma_pci_data(chip->pci), + 64*1024, 128*1024)) < 0) return err; return 0; @@ -853,24 +868,24 @@ static int __devinit snd_via686_pcm_new(via82xx_t *chip) */ -static void snd_via82xx_mixer_free_ac97_bus(ac97_bus_t *bus) +static void snd_via82xx_mixer_free_ac97_bus(struct snd_ac97_bus *bus) { - via82xx_t *chip = bus->private_data; + struct via82xx_modem *chip = bus->private_data; chip->ac97_bus = NULL; } -static void snd_via82xx_mixer_free_ac97(ac97_t *ac97) +static void snd_via82xx_mixer_free_ac97(struct snd_ac97 *ac97) { - via82xx_t *chip = ac97->private_data; + struct via82xx_modem *chip = ac97->private_data; chip->ac97 = NULL; } -static int __devinit snd_via82xx_mixer_new(via82xx_t *chip) +static int __devinit snd_via82xx_mixer_new(struct via82xx_modem *chip) { - ac97_template_t ac97; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_via82xx_codec_write, .read = snd_via82xx_codec_read, .wait = snd_via82xx_codec_wait, @@ -898,9 +913,9 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip) /* * proc interface */ -static void snd_via82xx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void snd_via82xx_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - via82xx_t *chip = entry->private_data; + struct via82xx_modem *chip = entry->private_data; int i; snd_iprintf(buffer, "%s\n\n", chip->card->longname); @@ -909,9 +924,9 @@ static void snd_via82xx_proc_read(snd_info_entry_t *entry, snd_info_buffer_t *bu } } -static void __devinit snd_via82xx_proc_init(via82xx_t *chip) +static void __devinit snd_via82xx_proc_init(struct via82xx_modem *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "via82xx", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_via82xx_proc_read); @@ -921,7 +936,7 @@ static void __devinit snd_via82xx_proc_init(via82xx_t *chip) * */ -static int snd_via82xx_chip_init(via82xx_t *chip) +static int snd_via82xx_chip_init(struct via82xx_modem *chip) { unsigned int val; unsigned long end_time; @@ -1004,9 +1019,9 @@ static int snd_via82xx_chip_init(via82xx_t *chip) /* * power management */ -static int snd_via82xx_suspend(snd_card_t *card, pm_message_t state) +static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state) { - via82xx_t *chip = card->pm_private_data; + struct via82xx_modem *chip = card->pm_private_data; int i; for (i = 0; i < 2; i++) @@ -1021,9 +1036,9 @@ static int snd_via82xx_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_via82xx_resume(snd_card_t *card) +static int snd_via82xx_resume(struct snd_card *card) { - via82xx_t *chip = card->pm_private_data; + struct via82xx_modem *chip = card->pm_private_data; int i; pci_enable_device(chip->pci); @@ -1041,7 +1056,7 @@ static int snd_via82xx_resume(snd_card_t *card) } #endif /* CONFIG_PM */ -static int snd_via82xx_free(via82xx_t *chip) +static int snd_via82xx_free(struct via82xx_modem *chip) { unsigned int i; @@ -1053,29 +1068,29 @@ static int snd_via82xx_free(via82xx_t *chip) synchronize_irq(chip->irq); __end_hw: if (chip->irq >= 0) - free_irq(chip->irq, (void *)chip); + free_irq(chip->irq, chip); pci_release_regions(chip->pci); pci_disable_device(chip->pci); kfree(chip); return 0; } -static int snd_via82xx_dev_free(snd_device_t *device) +static int snd_via82xx_dev_free(struct snd_device *device) { - via82xx_t *chip = device->device_data; + struct via82xx_modem *chip = device->device_data; return snd_via82xx_free(chip); } -static int __devinit snd_via82xx_create(snd_card_t * card, +static int __devinit snd_via82xx_create(struct snd_card *card, struct pci_dev *pci, int chip_type, int revision, unsigned int ac97_clock, - via82xx_t ** r_via) + struct via82xx_modem ** r_via) { - via82xx_t *chip; + struct via82xx_modem *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_via82xx_dev_free, }; @@ -1099,7 +1114,7 @@ static int __devinit snd_via82xx_create(snd_card_t * card, } chip->port = pci_resource_start(pci, 0); if (request_irq(pci->irq, snd_via82xx_interrupt, SA_INTERRUPT|SA_SHIRQ, - card->driver, (void *)chip)) { + card->driver, chip)) { snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); snd_via82xx_free(chip); return -EBUSY; @@ -1134,8 +1149,8 @@ static int __devinit snd_via82xx_create(snd_card_t * card, static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - snd_card_t *card; - via82xx_t *chip; + struct snd_card *card; + struct via82xx_modem *chip; unsigned char revision; int chip_type = 0, card_type; unsigned int i; -- cgit v1.1 From db13154843cb2c99a93e9feed575e906f6e0e455 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:07:38 +0100 Subject: [ALSA] Remove xxx_t typedefs: PCMCIA PDaudioCF Modules: PDAudioCF driver Remove xxx_t typedefs from the PCMCIA PDaudioCF driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 24 +++++++-------- sound/pcmcia/pdaudiocf/pdaudiocf.h | 30 +++++++++---------- sound/pcmcia/pdaudiocf/pdaudiocf_core.c | 42 +++++++++++++------------- sound/pcmcia/pdaudiocf/pdaudiocf_irq.c | 6 ++-- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 52 ++++++++++++++++----------------- 5 files changed, 77 insertions(+), 77 deletions(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index d6918b4..0ba335d 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -53,7 +53,7 @@ MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); */ static dev_info_t dev_info = "snd-pdaudiocf"; -static snd_card_t *card_list[SNDRV_CARDS]; +static struct snd_card *card_list[SNDRV_CARDS]; static dev_link_t *dev_list; /* @@ -77,7 +77,7 @@ static void pdacf_release(dev_link_t *link) /* * destructor */ -static int snd_pdacf_free(pdacf_t *pdacf) +static int snd_pdacf_free(struct snd_pdacf *pdacf) { dev_link_t *link = &pdacf->link; @@ -94,9 +94,9 @@ static int snd_pdacf_free(pdacf_t *pdacf) return 0; } -static int snd_pdacf_dev_free(snd_device_t *device) +static int snd_pdacf_dev_free(struct snd_device *device) { - pdacf_t *chip = device->device_data; + struct snd_pdacf *chip = device->device_data; return snd_pdacf_free(chip); } @@ -108,9 +108,9 @@ static dev_link_t *snd_pdacf_attach(void) client_reg_t client_reg; /* Register with cardmgr */ dev_link_t *link; /* Info for cardmgr */ int i, ret; - pdacf_t *pdacf; - snd_card_t *card; - static snd_device_ops_t ops = { + struct snd_pdacf *pdacf; + struct snd_card *card; + static struct snd_device_ops ops = { .dev_free = snd_pdacf_dev_free, }; @@ -194,10 +194,10 @@ static dev_link_t *snd_pdacf_attach(void) * * returns 0 if successful, or a negative error code. */ -static int snd_pdacf_assign_resources(pdacf_t *pdacf, int port, int irq) +static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irq) { int err; - snd_card_t *card = pdacf->card; + struct snd_card *card = pdacf->card; snd_printdd(KERN_DEBUG "pdacf assign resources: port = 0x%x, irq = %d\n", port, irq); pdacf->port = port; @@ -231,7 +231,7 @@ static int snd_pdacf_assign_resources(pdacf_t *pdacf, int port, int irq) */ static void snd_pdacf_detach(dev_link_t *link) { - pdacf_t *chip = link->priv; + struct snd_pdacf *chip = link->priv; snd_printdd(KERN_DEBUG "pdacf_detach called\n"); /* Remove the interface data from the linked list */ @@ -261,7 +261,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) static void pdacf_config(dev_link_t *link) { client_handle_t handle = link->handle; - pdacf_t *pdacf = link->priv; + struct snd_pdacf *pdacf = link->priv; tuple_t tuple; cisparse_t *parse = NULL; config_info_t conf; @@ -318,7 +318,7 @@ failed: static int pdacf_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - pdacf_t *chip = link->priv; + struct snd_pdacf *chip = link->priv; switch (event) { case CS_EVENT_CARD_REMOVAL: diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.h b/sound/pcmcia/pdaudiocf/pdaudiocf.h index c7a9628..ad8f32e 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.h +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.h @@ -83,8 +83,8 @@ #define PDAUDIOCF_STAT_IS_CONFIGURED (1<<1) #define PDAUDIOCF_STAT_IS_SUSPENDED (1<<2) -typedef struct { - snd_card_t *card; +struct snd_pdacf { + struct snd_card *card; int index; unsigned long port; @@ -96,12 +96,12 @@ typedef struct { struct tasklet_struct tq; spinlock_t ak4117_lock; - ak4117_t *ak4117; + struct ak4117 *ak4117; unsigned int chip_status; - snd_pcm_t *pcm; - snd_pcm_substream_t *pcm_substream; + struct snd_pcm *pcm; + struct snd_pcm_substream *pcm_substream; unsigned int pcm_running: 1; unsigned int pcm_channels; unsigned int pcm_swab; @@ -118,28 +118,28 @@ typedef struct { /* pcmcia stuff */ dev_link_t link; dev_node_t node; -} pdacf_t; +}; -static inline void pdacf_reg_write(pdacf_t *chip, unsigned char reg, unsigned short val) +static inline void pdacf_reg_write(struct snd_pdacf *chip, unsigned char reg, unsigned short val) { outw(chip->regmap[reg>>1] = val, chip->port + reg); } -static inline unsigned short pdacf_reg_read(pdacf_t *chip, unsigned char reg) +static inline unsigned short pdacf_reg_read(struct snd_pdacf *chip, unsigned char reg) { return inw(chip->port + reg); } -pdacf_t *snd_pdacf_create(snd_card_t *card); -int snd_pdacf_ak4117_create(pdacf_t *pdacf); -void snd_pdacf_powerdown(pdacf_t *chip); +struct snd_pdacf *snd_pdacf_create(struct snd_card *card); +int snd_pdacf_ak4117_create(struct snd_pdacf *pdacf); +void snd_pdacf_powerdown(struct snd_pdacf *chip); #ifdef CONFIG_PM -int snd_pdacf_suspend(snd_card_t *card, pm_message_t state); -int snd_pdacf_resume(snd_card_t *card); +int snd_pdacf_suspend(struct snd_card *card, pm_message_t state); +int snd_pdacf_resume(struct snd_card *card); #endif -int snd_pdacf_pcm_new(pdacf_t *chip); +int snd_pdacf_pcm_new(struct snd_pdacf *chip); irqreturn_t pdacf_interrupt(int irq, void *dev, struct pt_regs *regs); void pdacf_tasklet(unsigned long private_data); -void pdacf_reinit(pdacf_t *chip, int resume); +void pdacf_reinit(struct snd_pdacf *chip, int resume); #endif /* __PDAUDIOCF_H */ diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c index 0208c54..4f89823 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c @@ -30,7 +30,7 @@ */ static unsigned char pdacf_ak4117_read(void *private_data, unsigned char reg) { - pdacf_t *chip = private_data; + struct snd_pdacf *chip = private_data; unsigned long timeout; unsigned long flags; unsigned char res; @@ -62,7 +62,7 @@ static unsigned char pdacf_ak4117_read(void *private_data, unsigned char reg) static void pdacf_ak4117_write(void *private_data, unsigned char reg, unsigned char val) { - pdacf_t *chip = private_data; + struct snd_pdacf *chip = private_data; unsigned long timeout; unsigned long flags; @@ -81,7 +81,7 @@ static void pdacf_ak4117_write(void *private_data, unsigned char reg, unsigned c } #if 0 -void pdacf_dump(pdacf_t *chip) +void pdacf_dump(struct snd_pdacf *chip) { printk("PDAUDIOCF DUMP (0x%lx):\n", chip->port); printk("WPD : 0x%x\n", inw(chip->port + PDAUDIOCF_REG_WDP)); @@ -94,7 +94,7 @@ void pdacf_dump(pdacf_t *chip) } #endif -static int pdacf_reset(pdacf_t *chip, int powerdown) +static int pdacf_reset(struct snd_pdacf *chip, int powerdown) { u16 val; @@ -117,7 +117,7 @@ static int pdacf_reset(pdacf_t *chip, int powerdown) return 0; } -void pdacf_reinit(pdacf_t *chip, int resume) +void pdacf_reinit(struct snd_pdacf *chip, int resume) { pdacf_reset(chip, 0); if (resume) @@ -127,10 +127,10 @@ void pdacf_reinit(pdacf_t *chip, int resume) pdacf_reg_write(chip, PDAUDIOCF_REG_IER, chip->regmap[PDAUDIOCF_REG_IER>>1]); } -static void pdacf_proc_read(snd_info_entry_t * entry, - snd_info_buffer_t * buffer) +static void pdacf_proc_read(struct snd_info_entry * entry, + struct snd_info_buffer *buffer) { - pdacf_t *chip = entry->private_data; + struct snd_pdacf *chip = entry->private_data; u16 tmp; snd_iprintf(buffer, "PDAudioCF\n\n"); @@ -139,17 +139,17 @@ static void pdacf_proc_read(snd_info_entry_t * entry, } -static void pdacf_proc_init(pdacf_t *chip) +static void pdacf_proc_init(struct snd_pdacf *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "pdaudiocf", &entry)) snd_info_set_text_ops(entry, chip, 1024, pdacf_proc_read); } -pdacf_t *snd_pdacf_create(snd_card_t *card) +struct snd_pdacf *snd_pdacf_create(struct snd_card *card) { - pdacf_t *chip; + struct snd_pdacf *chip; chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) @@ -164,9 +164,9 @@ pdacf_t *snd_pdacf_create(snd_card_t *card) return chip; } -static void snd_pdacf_ak4117_change(ak4117_t *ak4117, unsigned char c0, unsigned char c1) +static void snd_pdacf_ak4117_change(struct ak4117 *ak4117, unsigned char c0, unsigned char c1) { - pdacf_t *chip = ak4117->change_callback_private; + struct snd_pdacf *chip = ak4117->change_callback_private; unsigned long flags; u16 val; @@ -182,7 +182,7 @@ static void snd_pdacf_ak4117_change(ak4117_t *ak4117, unsigned char c0, unsigned spin_unlock_irqrestore(&chip->reg_lock, flags); } -int snd_pdacf_ak4117_create(pdacf_t *chip) +int snd_pdacf_ak4117_create(struct snd_pdacf *chip) { int err; u16 val; @@ -238,7 +238,7 @@ int snd_pdacf_ak4117_create(pdacf_t *chip) return 0; } -void snd_pdacf_powerdown(pdacf_t *chip) +void snd_pdacf_powerdown(struct snd_pdacf *chip) { u16 val; @@ -255,9 +255,9 @@ void snd_pdacf_powerdown(pdacf_t *chip) #ifdef CONFIG_PM -int snd_pdacf_suspend(snd_card_t *card, pm_message_t state) +int snd_pdacf_suspend(struct snd_card *card, pm_message_t state) { - pdacf_t *chip = card->pm_private_data; + struct snd_pdacf *chip = card->pm_private_data; u16 val; snd_pcm_suspend_all(chip->pcm); @@ -270,14 +270,14 @@ int snd_pdacf_suspend(snd_card_t *card, pm_message_t state) return 0; } -static inline int check_signal(pdacf_t *chip) +static inline int check_signal(struct snd_pdacf *chip) { return (chip->ak4117->rcs0 & AK4117_UNLCK) == 0; } -int snd_pdacf_resume(snd_card_t *card) +int snd_pdacf_resume(struct snd_card *card) { - pdacf_t *chip = card->pm_private_data; + struct snd_pdacf *chip = card->pm_private_data; int timeout = 40; pdacf_reinit(chip, 1); diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_irq.c b/sound/pcmcia/pdaudiocf/pdaudiocf_irq.c index 255b634..7c5f21e 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_irq.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_irq.c @@ -28,7 +28,7 @@ */ irqreturn_t pdacf_interrupt(int irq, void *dev, struct pt_regs *regs) { - pdacf_t *chip = dev; + struct snd_pdacf *chip = dev; unsigned short stat; if ((chip->chip_status & (PDAUDIOCF_STAT_IS_STALE| @@ -204,7 +204,7 @@ static inline void pdacf_transfer_stereo24be(u8 *dst, u32 xor, unsigned int size } } -static void pdacf_transfer(pdacf_t *chip, unsigned int size, unsigned int off) +static void pdacf_transfer(struct snd_pdacf *chip, unsigned int size, unsigned int off) { unsigned long rdp_port = chip->port + PDAUDIOCF_REG_MD; unsigned int xor = chip->pcm_xor; @@ -258,7 +258,7 @@ static void pdacf_transfer(pdacf_t *chip, unsigned int size, unsigned int off) void pdacf_tasklet(unsigned long private_data) { - pdacf_t *chip = (pdacf_t *) private_data; + struct snd_pdacf *chip = (struct snd_pdacf *) private_data; int size, off, cont, rdp, wdp; if ((chip->chip_status & (PDAUDIOCF_STAT_IS_STALE|PDAUDIOCF_STAT_IS_CONFIGURED)) != PDAUDIOCF_STAT_IS_CONFIGURED) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index d54033e..09cb250 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c @@ -34,7 +34,7 @@ */ /* get the physical page pointer on the given offset */ -static struct page *snd_pcm_get_vmalloc_page(snd_pcm_substream_t *subs, unsigned long offset) +static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, unsigned long offset) { void *pageptr = subs->runtime->dma_area + offset; return vmalloc_to_page(pageptr); @@ -44,9 +44,9 @@ static struct page *snd_pcm_get_vmalloc_page(snd_pcm_substream_t *subs, unsigned * hw_params callback * NOTE: this may be called not only once per pcm open! */ -static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) +static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) { - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (runtime->dma_area) { if (runtime->dma_bytes >= size) return 0; /* already enough large */ @@ -63,9 +63,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) * hw_free callback * NOTE: this may be called not only once per pcm open! */ -static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) +static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (runtime->dma_area) { vfree(runtime->dma_area); runtime->dma_area = NULL; @@ -76,7 +76,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) /* * clear the SRAM contents */ -static int pdacf_pcm_clear_sram(pdacf_t *chip) +static int pdacf_pcm_clear_sram(struct snd_pdacf *chip) { int max_loop = 64 * 1024; @@ -91,10 +91,10 @@ static int pdacf_pcm_clear_sram(pdacf_t *chip) /* * pdacf_pcm_trigger - trigger callback for capture */ -static int pdacf_pcm_trigger(snd_pcm_substream_t *subs, int cmd) +static int pdacf_pcm_trigger(struct snd_pcm_substream *subs, int cmd) { - pdacf_t *chip = snd_pcm_substream_chip(subs); - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pdacf *chip = snd_pcm_substream_chip(subs); + struct snd_pcm_runtime *runtime = subs->runtime; int inc, ret = 0, rate; unsigned short mask, val, tmp; @@ -146,8 +146,8 @@ static int pdacf_pcm_trigger(snd_pcm_substream_t *subs, int cmd) /* * pdacf_pcm_hw_params - hw_params callback for playback and capture */ -static int pdacf_pcm_hw_params(snd_pcm_substream_t *subs, - snd_pcm_hw_params_t *hw_params) +static int pdacf_pcm_hw_params(struct snd_pcm_substream *subs, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_alloc_vmalloc_buffer(subs, params_buffer_bytes(hw_params)); } @@ -155,7 +155,7 @@ static int pdacf_pcm_hw_params(snd_pcm_substream_t *subs, /* * pdacf_pcm_hw_free - hw_free callback for playback and capture */ -static int pdacf_pcm_hw_free(snd_pcm_substream_t *subs) +static int pdacf_pcm_hw_free(struct snd_pcm_substream *subs) { return snd_pcm_free_vmalloc_buffer(subs); } @@ -163,10 +163,10 @@ static int pdacf_pcm_hw_free(snd_pcm_substream_t *subs) /* * pdacf_pcm_prepare - prepare callback for playback and capture */ -static int pdacf_pcm_prepare(snd_pcm_substream_t *subs) +static int pdacf_pcm_prepare(struct snd_pcm_substream *subs) { - pdacf_t *chip = snd_pcm_substream_chip(subs); - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pdacf *chip = snd_pcm_substream_chip(subs); + struct snd_pcm_runtime *runtime = subs->runtime; u16 val, nval, aval; if (chip->chip_status & PDAUDIOCF_STAT_IS_STALE) @@ -239,7 +239,7 @@ static int pdacf_pcm_prepare(snd_pcm_substream_t *subs) * capture hw information */ -static snd_pcm_hardware_t pdacf_pcm_capture_hw = { +static struct snd_pcm_hardware pdacf_pcm_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), @@ -269,10 +269,10 @@ static snd_pcm_hardware_t pdacf_pcm_capture_hw = { /* * pdacf_pcm_capture_open - open callback for capture */ -static int pdacf_pcm_capture_open(snd_pcm_substream_t *subs) +static int pdacf_pcm_capture_open(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; - pdacf_t *chip = snd_pcm_substream_chip(subs); + struct snd_pcm_runtime *runtime = subs->runtime; + struct snd_pdacf *chip = snd_pcm_substream_chip(subs); if (chip->chip_status & PDAUDIOCF_STAT_IS_STALE) return -EBUSY; @@ -287,9 +287,9 @@ static int pdacf_pcm_capture_open(snd_pcm_substream_t *subs) /* * pdacf_pcm_capture_close - close callback for capture */ -static int pdacf_pcm_capture_close(snd_pcm_substream_t *subs) +static int pdacf_pcm_capture_close(struct snd_pcm_substream *subs) { - pdacf_t *chip = snd_pcm_substream_chip(subs); + struct snd_pdacf *chip = snd_pcm_substream_chip(subs); if (!chip) return -EINVAL; @@ -302,16 +302,16 @@ static int pdacf_pcm_capture_close(snd_pcm_substream_t *subs) /* * pdacf_pcm_capture_pointer - pointer callback for capture */ -static snd_pcm_uframes_t pdacf_pcm_capture_pointer(snd_pcm_substream_t *subs) +static snd_pcm_uframes_t pdacf_pcm_capture_pointer(struct snd_pcm_substream *subs) { - pdacf_t *chip = snd_pcm_substream_chip(subs); + struct snd_pdacf *chip = snd_pcm_substream_chip(subs); return chip->pcm_hwptr; } /* * operators for PCM capture */ -static snd_pcm_ops_t pdacf_pcm_capture_ops = { +static struct snd_pcm_ops pdacf_pcm_capture_ops = { .open = pdacf_pcm_capture_open, .close = pdacf_pcm_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -327,9 +327,9 @@ static snd_pcm_ops_t pdacf_pcm_capture_ops = { /* * snd_pdacf_pcm_new - create and initialize a pcm */ -int snd_pdacf_pcm_new(pdacf_t *chip) +int snd_pdacf_pcm_new(struct snd_pdacf *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; err = snd_pcm_new(chip->card, "PDAudioCF", 0, 0, 1, &pcm); -- cgit v1.1 From 86e07d34658bb85b3424f4db64fa28f884edbe8d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:08:02 +0100 Subject: [ALSA] Remove xxx_t typedefs: USB-Audio Modules: USB generic driver Remove xxx_t typedefs from the USB-Audio driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/usb/usbaudio.c | 374 +++++++++++++++++++++++++------------------------- sound/usb/usbaudio.h | 16 +-- sound/usb/usbmidi.c | 211 ++++++++++++++-------------- sound/usb/usbmixer.c | 183 ++++++++++++------------ sound/usb/usbquirks.h | 270 ++++++++++++++++++------------------ 5 files changed, 521 insertions(+), 533 deletions(-) diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 99dae02..e1326704 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -102,10 +102,6 @@ MODULE_PARM_DESC(async_unlink, "Use async unlink mode."); #define SYNC_URBS 4 /* always four urbs for sync */ #define MIN_PACKS_URB 1 /* minimum 1 packet per urb */ -typedef struct snd_usb_substream snd_usb_substream_t; -typedef struct snd_usb_stream snd_usb_stream_t; -typedef struct snd_urb_ctx snd_urb_ctx_t; - struct audioformat { struct list_head list; snd_pcm_format_t format; /* format type */ @@ -125,25 +121,27 @@ struct audioformat { unsigned int *rate_table; /* rate table */ }; +struct snd_usb_substream; + struct snd_urb_ctx { struct urb *urb; unsigned int buffer_size; /* size of data buffer, if data URB */ - snd_usb_substream_t *subs; + struct snd_usb_substream *subs; int index; /* index for urb array */ int packets; /* number of packets per urb */ }; struct snd_urb_ops { - int (*prepare)(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime, struct urb *u); - int (*retire)(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime, struct urb *u); - int (*prepare_sync)(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime, struct urb *u); - int (*retire_sync)(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime, struct urb *u); + int (*prepare)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u); + int (*retire)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u); + int (*prepare_sync)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u); + int (*retire_sync)(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime, struct urb *u); }; struct snd_usb_substream { - snd_usb_stream_t *stream; + struct snd_usb_stream *stream; struct usb_device *dev; - snd_pcm_substream_t *pcm_substream; + struct snd_pcm_substream *pcm_substream; int direction; /* playback or capture */ int interface; /* current interface */ int endpoint; /* assigned endpoint */ @@ -175,8 +173,8 @@ struct snd_usb_substream { unsigned long unlink_mask; /* bitmask of unlinked urbs */ unsigned int nurbs; /* # urbs */ - snd_urb_ctx_t dataurb[MAX_URBS]; /* data urb table */ - snd_urb_ctx_t syncurb[SYNC_URBS]; /* sync urb table */ + struct snd_urb_ctx dataurb[MAX_URBS]; /* data urb table */ + struct snd_urb_ctx syncurb[SYNC_URBS]; /* sync urb table */ char *syncbuf; /* sync buffer for all sync URBs */ dma_addr_t sync_dma; /* DMA address of syncbuf */ @@ -190,11 +188,11 @@ struct snd_usb_substream { struct snd_usb_stream { - snd_usb_audio_t *chip; - snd_pcm_t *pcm; + struct snd_usb_audio *chip; + struct snd_pcm *pcm; int pcm_index; unsigned int fmt_type; /* USB audio format type (1-3) */ - snd_usb_substream_t substream[2]; + struct snd_usb_substream substream[2]; struct list_head list; }; @@ -205,7 +203,7 @@ struct snd_usb_stream { */ static DECLARE_MUTEX(register_mutex); -static snd_usb_audio_t *usb_chip[SNDRV_CARDS]; +static struct snd_usb_audio *usb_chip[SNDRV_CARDS]; /* @@ -245,12 +243,12 @@ static inline unsigned get_high_speed_hz(unsigned int usb_rate) * fill the length and offset of each urb descriptor. * the fixed 10.14 frequency is passed through the pipe. */ -static int prepare_capture_sync_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int prepare_capture_sync_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { unsigned char *cp = urb->transfer_buffer; - snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; + struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context; urb->dev = ctx->subs->dev; /* we need to set this at each time */ urb->iso_frame_desc[0].length = 3; @@ -267,12 +265,12 @@ static int prepare_capture_sync_urb(snd_usb_substream_t *subs, * fill the length and offset of each urb descriptor. * the fixed 12.13 frequency is passed as 16.16 through the pipe. */ -static int prepare_capture_sync_urb_hs(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int prepare_capture_sync_urb_hs(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { unsigned char *cp = urb->transfer_buffer; - snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; + struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context; urb->dev = ctx->subs->dev; /* we need to set this at each time */ urb->iso_frame_desc[0].length = 4; @@ -288,8 +286,8 @@ static int prepare_capture_sync_urb_hs(snd_usb_substream_t *subs, * process after capture sync complete * - nothing to do */ -static int retire_capture_sync_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int retire_capture_sync_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { return 0; @@ -305,12 +303,12 @@ static int retire_capture_sync_urb(snd_usb_substream_t *subs, * write onto the pcm buffer directly... the data is thus copied * later at complete callback to the global buffer. */ -static int prepare_capture_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int prepare_capture_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { int i, offs; - snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; + struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context; offs = 0; urb->dev = ctx->subs->dev; /* we need to set this at each time */ @@ -340,8 +338,8 @@ static int prepare_capture_urb(snd_usb_substream_t *subs, * copy the data from each desctiptor to the pcm buffer, and * update the current position. */ -static int retire_capture_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int retire_capture_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { unsigned long flags; @@ -395,11 +393,11 @@ static int retire_capture_urb(snd_usb_substream_t *subs, * set up the offset and length to receive the current frequency. */ -static int prepare_playback_sync_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int prepare_playback_sync_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { - snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; + struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context; urb->dev = ctx->subs->dev; /* we need to set this at each time */ urb->iso_frame_desc[0].length = 3; @@ -413,11 +411,11 @@ static int prepare_playback_sync_urb(snd_usb_substream_t *subs, * set up the offset and length to receive the current frequency. */ -static int prepare_playback_sync_urb_hs(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int prepare_playback_sync_urb_hs(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { - snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; + struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context; urb->dev = ctx->subs->dev; /* we need to set this at each time */ urb->iso_frame_desc[0].length = 4; @@ -431,8 +429,8 @@ static int prepare_playback_sync_urb_hs(snd_usb_substream_t *subs, * retrieve the current 10.14 frequency from pipe, and set it. * the value is referred in prepare_playback_urb(). */ -static int retire_playback_sync_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int retire_playback_sync_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { unsigned int f; @@ -457,8 +455,8 @@ static int retire_playback_sync_urb(snd_usb_substream_t *subs, * retrieve the current 12.13 frequency from pipe, and set it. * the value is referred in prepare_playback_urb(). */ -static int retire_playback_sync_urb_hs(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int retire_playback_sync_urb_hs(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { unsigned int f; @@ -482,12 +480,12 @@ static int retire_playback_sync_urb_hs(snd_usb_substream_t *subs, * * We don't care about (or have) any data, so we just send a transfer delimiter. */ -static int prepare_startup_playback_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int prepare_startup_playback_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { unsigned int i; - snd_urb_ctx_t *ctx = urb->context; + struct snd_urb_ctx *ctx = urb->context; urb->dev = ctx->subs->dev; urb->number_of_packets = subs->packs_per_ms; @@ -507,15 +505,15 @@ static int prepare_startup_playback_urb(snd_usb_substream_t *subs, * To avoid inconsistencies when updating hwptr_done, we use double buffering * for all URBs. */ -static int prepare_playback_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int prepare_playback_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { int i, stride, offs; unsigned int counts; unsigned long flags; int period_elapsed = 0; - snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; + struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context; stride = runtime->frame_bits >> 3; @@ -597,8 +595,8 @@ static int prepare_playback_urb(snd_usb_substream_t *subs, * process after playback data complete * - nothing to do */ -static int retire_playback_urb(snd_usb_substream_t *subs, - snd_pcm_runtime_t *runtime, +static int retire_playback_urb(struct snd_usb_substream *subs, + struct snd_pcm_runtime *runtime, struct urb *urb) { return 0; @@ -642,9 +640,9 @@ static struct snd_urb_ops audio_urb_ops_high_speed[2] = { */ static void snd_complete_urb(struct urb *urb, struct pt_regs *regs) { - snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; - snd_usb_substream_t *subs = ctx->subs; - snd_pcm_substream_t *substream = ctx->subs->pcm_substream; + struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context; + struct snd_usb_substream *subs = ctx->subs; + struct snd_pcm_substream *substream = ctx->subs->pcm_substream; int err = 0; if ((subs->running && subs->ops.retire(subs, substream->runtime, urb)) || @@ -665,9 +663,9 @@ static void snd_complete_urb(struct urb *urb, struct pt_regs *regs) */ static void snd_complete_sync_urb(struct urb *urb, struct pt_regs *regs) { - snd_urb_ctx_t *ctx = (snd_urb_ctx_t *)urb->context; - snd_usb_substream_t *subs = ctx->subs; - snd_pcm_substream_t *substream = ctx->subs->pcm_substream; + struct snd_urb_ctx *ctx = (struct snd_urb_ctx *)urb->context; + struct snd_usb_substream *subs = ctx->subs; + struct snd_pcm_substream *substream = ctx->subs->pcm_substream; int err = 0; if ((subs->running && subs->ops.retire_sync(subs, substream->runtime, urb)) || @@ -684,7 +682,7 @@ static void snd_complete_sync_urb(struct urb *urb, struct pt_regs *regs) /* get the physical page pointer at the given offset */ -static struct page *snd_pcm_get_vmalloc_page(snd_pcm_substream_t *subs, +static struct page *snd_pcm_get_vmalloc_page(struct snd_pcm_substream *subs, unsigned long offset) { void *pageptr = subs->runtime->dma_area + offset; @@ -692,9 +690,9 @@ static struct page *snd_pcm_get_vmalloc_page(snd_pcm_substream_t *subs, } /* allocate virtual buffer; may be called more than once */ -static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) +static int snd_pcm_alloc_vmalloc_buffer(struct snd_pcm_substream *subs, size_t size) { - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (runtime->dma_area) { if (runtime->dma_bytes >= size) return 0; /* already large enough */ @@ -708,9 +706,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) } /* free virtual buffer; may be called more than once */ -static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) +static int snd_pcm_free_vmalloc_buffer(struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; if (runtime->dma_area) { vfree(runtime->dma_area); runtime->dma_area = NULL; @@ -722,7 +720,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) /* * unlink active urbs. */ -static int deactivate_urbs(snd_usb_substream_t *subs, int force, int can_sleep) +static int deactivate_urbs(struct snd_usb_substream *subs, int force, int can_sleep) { unsigned int i; int async; @@ -768,7 +766,7 @@ static int deactivate_urbs(snd_usb_substream_t *subs, int force, int can_sleep) /* * set up and start data/sync urbs */ -static int start_urbs(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime) +static int start_urbs(struct snd_usb_substream *subs, struct snd_pcm_runtime *runtime) { unsigned int i; int err; @@ -824,7 +822,7 @@ static int start_urbs(snd_usb_substream_t *subs, snd_pcm_runtime_t *runtime) /* * wait until all urbs are processed. */ -static int wait_clear_urbs(snd_usb_substream_t *subs) +static int wait_clear_urbs(struct snd_usb_substream *subs) { unsigned long end_time = jiffies + msecs_to_jiffies(1000); unsigned int i; @@ -855,12 +853,12 @@ static int wait_clear_urbs(snd_usb_substream_t *subs) /* * return the current pcm pointer. just return the hwptr_done value. */ -static snd_pcm_uframes_t snd_usb_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream) { - snd_usb_substream_t *subs; + struct snd_usb_substream *subs; snd_pcm_uframes_t hwptr_done; - subs = (snd_usb_substream_t *)substream->runtime->private_data; + subs = (struct snd_usb_substream *)substream->runtime->private_data; spin_lock(&subs->lock); hwptr_done = subs->hwptr_done; spin_unlock(&subs->lock); @@ -871,10 +869,10 @@ static snd_pcm_uframes_t snd_usb_pcm_pointer(snd_pcm_substream_t *substream) /* * start/stop playback substream */ -static int snd_usb_pcm_playback_trigger(snd_pcm_substream_t *substream, +static int snd_usb_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_usb_substream_t *subs = substream->runtime->private_data; + struct snd_usb_substream *subs = substream->runtime->private_data; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -890,10 +888,10 @@ static int snd_usb_pcm_playback_trigger(snd_pcm_substream_t *substream, /* * start/stop capture substream */ -static int snd_usb_pcm_capture_trigger(snd_pcm_substream_t *substream, +static int snd_usb_pcm_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_usb_substream_t *subs = substream->runtime->private_data; + struct snd_usb_substream *subs = substream->runtime->private_data; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -909,7 +907,7 @@ static int snd_usb_pcm_capture_trigger(snd_pcm_substream_t *substream, /* * release a urb data */ -static void release_urb_ctx(snd_urb_ctx_t *u) +static void release_urb_ctx(struct snd_urb_ctx *u) { if (u->urb) { if (u->buffer_size) @@ -924,7 +922,7 @@ static void release_urb_ctx(snd_urb_ctx_t *u) /* * release a substream */ -static void release_substream_urbs(snd_usb_substream_t *subs, int force) +static void release_substream_urbs(struct snd_usb_substream *subs, int force) { int i; @@ -945,7 +943,7 @@ static void release_substream_urbs(snd_usb_substream_t *subs, int force) /* * initialize a substream for plaback/capture */ -static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_bytes, +static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int period_bytes, unsigned int rate, unsigned int frame_bits) { unsigned int maxsize, n, i; @@ -1045,7 +1043,7 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by /* allocate and initialize data urbs */ for (i = 0; i < subs->nurbs; i++) { - snd_urb_ctx_t *u = &subs->dataurb[i]; + struct snd_urb_ctx *u = &subs->dataurb[i]; u->index = i; u->subs = subs; u->packets = npacks[i]; @@ -1074,7 +1072,7 @@ static int init_substream_urbs(snd_usb_substream_t *subs, unsigned int period_by if (! subs->syncbuf) goto out_of_memory; for (i = 0; i < SYNC_URBS; i++) { - snd_urb_ctx_t *u = &subs->syncurb[i]; + struct snd_urb_ctx *u = &subs->syncurb[i]; u->index = i; u->subs = subs; u->packets = 1; @@ -1104,7 +1102,7 @@ out_of_memory: /* * find a matching audio format */ -static struct audioformat *find_format(snd_usb_substream_t *subs, unsigned int format, +static struct audioformat *find_format(struct snd_usb_substream *subs, unsigned int format, unsigned int rate, unsigned int channels) { struct list_head *p; @@ -1229,7 +1227,7 @@ static int init_usb_sample_rate(struct usb_device *dev, int iface, /* * find a matching format and set up the interface */ -static int set_format(snd_usb_substream_t *subs, struct audioformat *fmt) +static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) { struct usb_device *dev = subs->dev; struct usb_host_interface *alts; @@ -1358,10 +1356,10 @@ static int set_format(snd_usb_substream_t *subs, struct audioformat *fmt) * if sg buffer is supported on the later version of alsa, we'll follow * that. */ -static int snd_usb_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_usb_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_usb_substream_t *subs = (snd_usb_substream_t *)substream->runtime->private_data; + struct snd_usb_substream *subs = (struct snd_usb_substream *)substream->runtime->private_data; struct audioformat *fmt; unsigned int channels, rate, format; int ret, changed; @@ -1415,9 +1413,9 @@ static int snd_usb_hw_params(snd_pcm_substream_t *substream, * * reset the audio format and release the buffer */ -static int snd_usb_hw_free(snd_pcm_substream_t *substream) +static int snd_usb_hw_free(struct snd_pcm_substream *substream) { - snd_usb_substream_t *subs = (snd_usb_substream_t *)substream->runtime->private_data; + struct snd_usb_substream *subs = (struct snd_usb_substream *)substream->runtime->private_data; subs->cur_audiofmt = NULL; subs->cur_rate = 0; @@ -1431,10 +1429,10 @@ static int snd_usb_hw_free(snd_pcm_substream_t *substream) * * only a few subtle things... */ -static int snd_usb_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_usb_substream_t *subs = runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_usb_substream *subs = runtime->private_data; if (! subs->cur_audiofmt) { snd_printk(KERN_ERR "usbaudio: no format is specified!\n"); @@ -1463,7 +1461,7 @@ static int snd_usb_pcm_prepare(snd_pcm_substream_t *substream) return 0; } -static snd_pcm_hardware_t snd_usb_playback = +static struct snd_pcm_hardware snd_usb_playback = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -1477,7 +1475,7 @@ static snd_pcm_hardware_t snd_usb_playback = .periods_max = 1024, }; -static snd_pcm_hardware_t snd_usb_capture = +static struct snd_pcm_hardware snd_usb_capture = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -1501,11 +1499,11 @@ static snd_pcm_hardware_t snd_usb_capture = #define hwc_debug(fmt, args...) /**/ #endif -static int hw_check_valid_format(snd_pcm_hw_params_t *params, struct audioformat *fp) +static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audioformat *fp) { - snd_interval_t *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - snd_interval_t *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - snd_mask_t *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); /* check the format */ if (! snd_mask_test(fmts, fp->format)) { @@ -1529,12 +1527,12 @@ static int hw_check_valid_format(snd_pcm_hw_params_t *params, struct audioformat return 1; } -static int hw_rule_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int hw_rule_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_usb_substream_t *subs = rule->private; + struct snd_usb_substream *subs = rule->private; struct list_head *p; - snd_interval_t *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); unsigned int rmin, rmax; int changed; @@ -1583,12 +1581,12 @@ static int hw_rule_rate(snd_pcm_hw_params_t *params, } -static int hw_rule_channels(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int hw_rule_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_usb_substream_t *subs = rule->private; + struct snd_usb_substream *subs = rule->private; struct list_head *p; - snd_interval_t *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); unsigned int rmin, rmax; int changed; @@ -1636,12 +1634,12 @@ static int hw_rule_channels(snd_pcm_hw_params_t *params, return changed; } -static int hw_rule_format(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int hw_rule_format(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - snd_usb_substream_t *subs = rule->private; + struct snd_usb_substream *subs = rule->private; struct list_head *p; - snd_mask_t *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); u64 fbits; u32 oldbits[2]; int changed; @@ -1674,7 +1672,7 @@ static int hw_rule_format(snd_pcm_hw_params_t *params, /* * check whether the registered audio formats need special hw-constraints */ -static int check_hw_params_convention(snd_usb_substream_t *subs) +static int check_hw_params_convention(struct snd_usb_substream *subs) { int i; u32 *channels; @@ -1758,7 +1756,7 @@ static int check_hw_params_convention(snd_usb_substream_t *subs) * set up the runtime hardware information. */ -static int setup_hw_info(snd_pcm_runtime_t *runtime, snd_usb_substream_t *subs) +static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) { struct list_head *p; int err; @@ -1819,12 +1817,12 @@ static int setup_hw_info(snd_pcm_runtime_t *runtime, snd_usb_substream_t *subs) return 0; } -static int snd_usb_pcm_open(snd_pcm_substream_t *substream, int direction, - snd_pcm_hardware_t *hw) +static int snd_usb_pcm_open(struct snd_pcm_substream *substream, int direction, + struct snd_pcm_hardware *hw) { - snd_usb_stream_t *as = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - snd_usb_substream_t *subs = &as->substream[direction]; + struct snd_usb_stream *as = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_usb_substream *subs = &as->substream[direction]; subs->interface = -1; subs->format = 0; @@ -1834,10 +1832,10 @@ static int snd_usb_pcm_open(snd_pcm_substream_t *substream, int direction, return setup_hw_info(runtime, subs); } -static int snd_usb_pcm_close(snd_pcm_substream_t *substream, int direction) +static int snd_usb_pcm_close(struct snd_pcm_substream *substream, int direction) { - snd_usb_stream_t *as = snd_pcm_substream_chip(substream); - snd_usb_substream_t *subs = &as->substream[direction]; + struct snd_usb_stream *as = snd_pcm_substream_chip(substream); + struct snd_usb_substream *subs = &as->substream[direction]; if (subs->interface >= 0) { usb_set_interface(subs->dev, subs->interface, 0); @@ -1847,27 +1845,27 @@ static int snd_usb_pcm_close(snd_pcm_substream_t *substream, int direction) return 0; } -static int snd_usb_playback_open(snd_pcm_substream_t *substream) +static int snd_usb_playback_open(struct snd_pcm_substream *substream) { return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_PLAYBACK, &snd_usb_playback); } -static int snd_usb_playback_close(snd_pcm_substream_t *substream) +static int snd_usb_playback_close(struct snd_pcm_substream *substream) { return snd_usb_pcm_close(substream, SNDRV_PCM_STREAM_PLAYBACK); } -static int snd_usb_capture_open(snd_pcm_substream_t *substream) +static int snd_usb_capture_open(struct snd_pcm_substream *substream) { return snd_usb_pcm_open(substream, SNDRV_PCM_STREAM_CAPTURE, &snd_usb_capture); } -static int snd_usb_capture_close(snd_pcm_substream_t *substream) +static int snd_usb_capture_close(struct snd_pcm_substream *substream) { return snd_usb_pcm_close(substream, SNDRV_PCM_STREAM_CAPTURE); } -static snd_pcm_ops_t snd_usb_playback_ops = { +static struct snd_pcm_ops snd_usb_playback_ops = { .open = snd_usb_playback_open, .close = snd_usb_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1879,7 +1877,7 @@ static snd_pcm_ops_t snd_usb_playback_ops = { .page = snd_pcm_get_vmalloc_page, }; -static snd_pcm_ops_t snd_usb_capture_ops = { +static struct snd_pcm_ops snd_usb_capture_ops = { .open = snd_usb_capture_open, .close = snd_usb_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -2007,7 +2005,7 @@ static struct usb_driver usb_audio_driver = { /* * proc interface for list the supported pcm formats */ -static void proc_dump_substream_formats(snd_usb_substream_t *subs, snd_info_buffer_t *buffer) +static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct snd_info_buffer *buffer) { struct list_head *p; static char *sync_types[4] = { @@ -2043,7 +2041,7 @@ static void proc_dump_substream_formats(snd_usb_substream_t *subs, snd_info_buff } } -static void proc_dump_substream_status(snd_usb_substream_t *subs, snd_info_buffer_t *buffer) +static void proc_dump_substream_status(struct snd_usb_substream *subs, struct snd_info_buffer *buffer) { if (subs->running) { unsigned int i; @@ -2065,9 +2063,9 @@ static void proc_dump_substream_status(snd_usb_substream_t *subs, snd_info_buffe } } -static void proc_pcm_format_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void proc_pcm_format_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - snd_usb_stream_t *stream = entry->private_data; + struct snd_usb_stream *stream = entry->private_data; snd_iprintf(buffer, "%s : %s\n", stream->chip->card->longname, stream->pcm->name); @@ -2083,11 +2081,11 @@ static void proc_pcm_format_read(snd_info_entry_t *entry, snd_info_buffer_t *buf } } -static void proc_pcm_format_add(snd_usb_stream_t *stream) +static void proc_pcm_format_add(struct snd_usb_stream *stream) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; char name[32]; - snd_card_t *card = stream->chip->card; + struct snd_card *card = stream->chip->card; sprintf(name, "stream%d", stream->pcm_index); if (! snd_card_proc_new(card, name, &entry)) @@ -2099,9 +2097,9 @@ static void proc_pcm_format_add(snd_usb_stream_t *stream) * initialize the substream instance. */ -static void init_substream(snd_usb_stream_t *as, int stream, struct audioformat *fp) +static void init_substream(struct snd_usb_stream *as, int stream, struct audioformat *fp) { - snd_usb_substream_t *subs = &as->substream[stream]; + struct snd_usb_substream *subs = &as->substream[stream]; INIT_LIST_HEAD(&subs->fmt_list); spin_lock_init(&subs->lock); @@ -2128,7 +2126,7 @@ static void init_substream(snd_usb_stream_t *as, int stream, struct audioformat /* * free a substream */ -static void free_substream(snd_usb_substream_t *subs) +static void free_substream(struct snd_usb_substream *subs) { struct list_head *p, *n; @@ -2145,7 +2143,7 @@ static void free_substream(snd_usb_substream_t *subs) /* * free a usb stream instance */ -static void snd_usb_audio_stream_free(snd_usb_stream_t *stream) +static void snd_usb_audio_stream_free(struct snd_usb_stream *stream) { free_substream(&stream->substream[0]); free_substream(&stream->substream[1]); @@ -2153,9 +2151,9 @@ static void snd_usb_audio_stream_free(snd_usb_stream_t *stream) kfree(stream); } -static void snd_usb_audio_pcm_free(snd_pcm_t *pcm) +static void snd_usb_audio_pcm_free(struct snd_pcm *pcm) { - snd_usb_stream_t *stream = pcm->private_data; + struct snd_usb_stream *stream = pcm->private_data; if (stream) { stream->pcm = NULL; snd_usb_audio_stream_free(stream); @@ -2168,16 +2166,16 @@ static void snd_usb_audio_pcm_free(snd_pcm_t *pcm) * if a stream with the same endpoint already exists, append to it. * if not, create a new pcm stream. */ -static int add_audio_endpoint(snd_usb_audio_t *chip, int stream, struct audioformat *fp) +static int add_audio_endpoint(struct snd_usb_audio *chip, int stream, struct audioformat *fp) { struct list_head *p; - snd_usb_stream_t *as; - snd_usb_substream_t *subs; - snd_pcm_t *pcm; + struct snd_usb_stream *as; + struct snd_usb_substream *subs; + struct snd_pcm *pcm; int err; list_for_each(p, &chip->pcm_list) { - as = list_entry(p, snd_usb_stream_t, list); + as = list_entry(p, struct snd_usb_stream, list); if (as->fmt_type != fp->fmt_type) continue; subs = &as->substream[stream]; @@ -2192,7 +2190,7 @@ static int add_audio_endpoint(snd_usb_audio_t *chip, int stream, struct audiofor } /* look for an empty stream */ list_for_each(p, &chip->pcm_list) { - as = list_entry(p, snd_usb_stream_t, list); + as = list_entry(p, struct snd_usb_stream, list); if (as->fmt_type != fp->fmt_type) continue; subs = &as->substream[stream]; @@ -2244,7 +2242,7 @@ static int add_audio_endpoint(snd_usb_audio_t *chip, int stream, struct audiofor /* * check if the device uses big-endian samples */ -static int is_big_endian_format(snd_usb_audio_t *chip, struct audioformat *fp) +static int is_big_endian_format(struct snd_usb_audio *chip, struct audioformat *fp) { switch (chip->usb_id) { case USB_ID(0x0763, 0x2001): /* M-Audio Quattro: captured data only */ @@ -2266,7 +2264,7 @@ static int is_big_endian_format(snd_usb_audio_t *chip, struct audioformat *fp) * @format: the format tag (wFormatTag) * @fmt: the format type descriptor */ -static int parse_audio_format_i_type(snd_usb_audio_t *chip, struct audioformat *fp, +static int parse_audio_format_i_type(struct snd_usb_audio *chip, struct audioformat *fp, int format, unsigned char *fmt) { int pcm_format; @@ -2349,7 +2347,7 @@ static int parse_audio_format_i_type(snd_usb_audio_t *chip, struct audioformat * * @offset: the start offset of descriptor pointing the rate type * (7 for type I and II, 8 for type II) */ -static int parse_audio_format_rates(snd_usb_audio_t *chip, struct audioformat *fp, +static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioformat *fp, unsigned char *fmt, int offset) { int nr_rates = fmt[offset]; @@ -2402,7 +2400,7 @@ static int parse_audio_format_rates(snd_usb_audio_t *chip, struct audioformat *f /* * parse the format type I and III descriptors */ -static int parse_audio_format_i(snd_usb_audio_t *chip, struct audioformat *fp, +static int parse_audio_format_i(struct snd_usb_audio *chip, struct audioformat *fp, int format, unsigned char *fmt) { int pcm_format; @@ -2431,7 +2429,7 @@ static int parse_audio_format_i(snd_usb_audio_t *chip, struct audioformat *fp, /* * prase the format type II descriptor */ -static int parse_audio_format_ii(snd_usb_audio_t *chip, struct audioformat *fp, +static int parse_audio_format_ii(struct snd_usb_audio *chip, struct audioformat *fp, int format, unsigned char *fmt) { int brate, framesize; @@ -2458,7 +2456,7 @@ static int parse_audio_format_ii(snd_usb_audio_t *chip, struct audioformat *fp, return parse_audio_format_rates(chip, fp, fmt, 8); /* fmt[8..] sample rates */ } -static int parse_audio_format(snd_usb_audio_t *chip, struct audioformat *fp, +static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp, int format, unsigned char *fmt, int stream) { int err; @@ -2495,7 +2493,7 @@ static int parse_audio_format(snd_usb_audio_t *chip, struct audioformat *fp, return 0; } -static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) +static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) { struct usb_device *dev; struct usb_interface *iface; @@ -2646,10 +2644,10 @@ static int parse_audio_endpoints(snd_usb_audio_t *chip, int iface_no) static void snd_usb_stream_disconnect(struct list_head *head) { int idx; - snd_usb_stream_t *as; - snd_usb_substream_t *subs; + struct snd_usb_stream *as; + struct snd_usb_substream *subs; - as = list_entry(head, snd_usb_stream_t, list); + as = list_entry(head, struct snd_usb_stream, list); for (idx = 0; idx < 2; idx++) { subs = &as->substream[idx]; if (!subs->num_formats) @@ -2662,7 +2660,7 @@ static void snd_usb_stream_disconnect(struct list_head *head) /* * parse audio control descriptor and create pcm/midi streams */ -static int snd_usb_create_streams(snd_usb_audio_t *chip, int ctrlif) +static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif) { struct usb_device *dev = chip->dev; struct usb_host_interface *host_iface; @@ -2729,9 +2727,9 @@ static int snd_usb_create_streams(snd_usb_audio_t *chip, int ctrlif) /* * create a stream for an endpoint/altsetting without proper descriptors */ -static int create_fixed_stream_quirk(snd_usb_audio_t *chip, +static int create_fixed_stream_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, - const snd_usb_audio_quirk_t *quirk) + const struct snd_usb_audio_quirk *quirk) { struct audioformat *fp; struct usb_host_interface *alts; @@ -2778,9 +2776,9 @@ static int create_fixed_stream_quirk(snd_usb_audio_t *chip, /* * create a stream for an interface with proper descriptors */ -static int create_standard_audio_quirk(snd_usb_audio_t *chip, +static int create_standard_audio_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, - const snd_usb_audio_quirk_t *quirk) + const struct snd_usb_audio_quirk *quirk) { struct usb_host_interface *alts; struct usb_interface_descriptor *altsd; @@ -2803,9 +2801,9 @@ static int create_standard_audio_quirk(snd_usb_audio_t *chip, * Create a stream for an Edirol UA-700/UA-25 interface. The only way * to detect the sample rate is by looking at wMaxPacketSize. */ -static int create_ua700_ua25_quirk(snd_usb_audio_t *chip, +static int create_ua700_ua25_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, - const snd_usb_audio_quirk_t *quirk) + const struct snd_usb_audio_quirk *quirk) { static const struct audioformat ua_format = { .format = SNDRV_PCM_FORMAT_S24_3LE, @@ -2827,19 +2825,19 @@ static int create_ua700_ua25_quirk(snd_usb_audio_t *chip, altsd = get_iface_desc(alts); if (altsd->bNumEndpoints == 2) { - static const snd_usb_midi_endpoint_info_t ua700_ep = { + static const struct snd_usb_midi_endpoint_info ua700_ep = { .out_cables = 0x0003, .in_cables = 0x0003 }; - static const snd_usb_audio_quirk_t ua700_quirk = { + static const struct snd_usb_audio_quirk ua700_quirk = { .type = QUIRK_MIDI_FIXED_ENDPOINT, .data = &ua700_ep }; - static const snd_usb_midi_endpoint_info_t ua25_ep = { + static const struct snd_usb_midi_endpoint_info ua25_ep = { .out_cables = 0x0001, .in_cables = 0x0001 }; - static const snd_usb_audio_quirk_t ua25_quirk = { + static const struct snd_usb_audio_quirk ua25_quirk = { .type = QUIRK_MIDI_FIXED_ENDPOINT, .data = &ua25_ep }; @@ -2896,9 +2894,9 @@ static int create_ua700_ua25_quirk(snd_usb_audio_t *chip, /* * Create a stream for an Edirol UA-1000 interface. */ -static int create_ua1000_quirk(snd_usb_audio_t *chip, +static int create_ua1000_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, - const snd_usb_audio_quirk_t *quirk) + const struct snd_usb_audio_quirk *quirk) { static const struct audioformat ua1000_format = { .format = SNDRV_PCM_FORMAT_S32_LE, @@ -2945,16 +2943,16 @@ static int create_ua1000_quirk(snd_usb_audio_t *chip, return 0; } -static int snd_usb_create_quirk(snd_usb_audio_t *chip, +static int snd_usb_create_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, - const snd_usb_audio_quirk_t *quirk); + const struct snd_usb_audio_quirk *quirk); /* * handle the quirks for the contained interfaces */ -static int create_composite_quirk(snd_usb_audio_t *chip, +static int create_composite_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, - const snd_usb_audio_quirk_t *quirk) + const struct snd_usb_audio_quirk *quirk) { int probed_ifnum = get_iface_desc(iface->altsetting)->bInterfaceNumber; int err; @@ -2975,9 +2973,9 @@ static int create_composite_quirk(snd_usb_audio_t *chip, return 0; } -static int ignore_interface_quirk(snd_usb_audio_t *chip, +static int ignore_interface_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, - const snd_usb_audio_quirk_t *quirk) + const struct snd_usb_audio_quirk *quirk) { return 0; } @@ -3040,12 +3038,12 @@ static int snd_usb_audigy2nx_boot_quirk(struct usb_device *dev) * after this. * returns a negative value at error. */ -static int snd_usb_create_quirk(snd_usb_audio_t *chip, +static int snd_usb_create_quirk(struct snd_usb_audio *chip, struct usb_interface *iface, - const snd_usb_audio_quirk_t *quirk) + const struct snd_usb_audio_quirk *quirk) { - typedef int (*quirk_func_t)(snd_usb_audio_t *, struct usb_interface *, - const snd_usb_audio_quirk_t *); + typedef int (*quirk_func_t)(struct snd_usb_audio *, struct usb_interface *, + const struct snd_usb_audio_quirk *); static const quirk_func_t quirk_funcs[] = { [QUIRK_IGNORE_INTERFACE] = ignore_interface_quirk, [QUIRK_COMPOSITE] = create_composite_quirk, @@ -3075,25 +3073,25 @@ static int snd_usb_create_quirk(snd_usb_audio_t *chip, /* * common proc files to show the usb device info */ -static void proc_audio_usbbus_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void proc_audio_usbbus_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - snd_usb_audio_t *chip = entry->private_data; + struct snd_usb_audio *chip = entry->private_data; if (! chip->shutdown) snd_iprintf(buffer, "%03d/%03d\n", chip->dev->bus->busnum, chip->dev->devnum); } -static void proc_audio_usbid_read(snd_info_entry_t *entry, snd_info_buffer_t *buffer) +static void proc_audio_usbid_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - snd_usb_audio_t *chip = entry->private_data; + struct snd_usb_audio *chip = entry->private_data; if (! chip->shutdown) snd_iprintf(buffer, "%04x:%04x\n", USB_ID_VENDOR(chip->usb_id), USB_ID_PRODUCT(chip->usb_id)); } -static void snd_usb_audio_create_proc(snd_usb_audio_t *chip) +static void snd_usb_audio_create_proc(struct snd_usb_audio *chip) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if (! snd_card_proc_new(chip->card, "usbbus", &entry)) snd_info_set_text_ops(entry, chip, 1024, proc_audio_usbbus_read); if (! snd_card_proc_new(chip->card, "usbid", &entry)) @@ -3107,15 +3105,15 @@ static void snd_usb_audio_create_proc(snd_usb_audio_t *chip) * */ -static int snd_usb_audio_free(snd_usb_audio_t *chip) +static int snd_usb_audio_free(struct snd_usb_audio *chip) { kfree(chip); return 0; } -static int snd_usb_audio_dev_free(snd_device_t *device) +static int snd_usb_audio_dev_free(struct snd_device *device) { - snd_usb_audio_t *chip = device->device_data; + struct snd_usb_audio *chip = device->device_data; return snd_usb_audio_free(chip); } @@ -3124,14 +3122,14 @@ static int snd_usb_audio_dev_free(snd_device_t *device) * create a chip instance and set its names. */ static int snd_usb_audio_create(struct usb_device *dev, int idx, - const snd_usb_audio_quirk_t *quirk, - snd_usb_audio_t **rchip) + const struct snd_usb_audio_quirk *quirk, + struct snd_usb_audio **rchip) { - snd_card_t *card; - snd_usb_audio_t *chip; + struct snd_card *card; + struct snd_usb_audio *chip; int err, len; char component[14]; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_usb_audio_dev_free, }; @@ -3235,9 +3233,9 @@ static void *snd_usb_audio_probe(struct usb_device *dev, struct usb_interface *intf, const struct usb_device_id *usb_id) { - const snd_usb_audio_quirk_t *quirk = (const snd_usb_audio_quirk_t *)usb_id->driver_info; + const struct snd_usb_audio_quirk *quirk = (const struct snd_usb_audio_quirk *)usb_id->driver_info; int i, err; - snd_usb_audio_t *chip; + struct snd_usb_audio *chip; struct usb_host_interface *alts; int ifnum; u32 id; @@ -3338,8 +3336,8 @@ static void *snd_usb_audio_probe(struct usb_device *dev, */ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr) { - snd_usb_audio_t *chip; - snd_card_t *card; + struct snd_usb_audio *chip; + struct snd_card *card; struct list_head *p; if (ptr == (void *)-1L) diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index b580202..ecd724b 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -126,12 +126,10 @@ /* */ -typedef struct snd_usb_audio snd_usb_audio_t; - struct snd_usb_audio { int index; struct usb_device *dev; - snd_card_t *card; + struct snd_card *card; u32 usb_id; int shutdown; int num_interfaces; @@ -172,9 +170,6 @@ enum quirk_type { QUIRK_TYPE_COUNT }; -typedef struct snd_usb_audio_quirk snd_usb_audio_quirk_t; -typedef struct snd_usb_midi_endpoint_info snd_usb_midi_endpoint_info_t; - struct snd_usb_audio_quirk { const char *vendor_name; const char *product_name; @@ -228,12 +223,15 @@ unsigned int snd_usb_combine_bytes(unsigned char *bytes, int size); void *snd_usb_find_desc(void *descstart, int desclen, void *after, u8 dtype); void *snd_usb_find_csint_desc(void *descstart, int desclen, void *after, u8 dsubtype); -int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size, int timeout); +int snd_usb_ctl_msg(struct usb_device *dev, unsigned int pipe, + __u8 request, __u8 requesttype, __u16 value, __u16 index, + void *data, __u16 size, int timeout); -int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif); +int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif); void snd_usb_mixer_disconnect(struct list_head *p); -int snd_usb_create_midi_interface(snd_usb_audio_t *chip, struct usb_interface *iface, const snd_usb_audio_quirk_t *quirk); +int snd_usb_create_midi_interface(struct snd_usb_audio *chip, struct usb_interface *iface, + const struct snd_usb_audio_quirk *quirk); void snd_usbmidi_input_stop(struct list_head* p); void snd_usbmidi_input_start(struct list_head* p); void snd_usbmidi_disconnect(struct list_head *p); diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c index f8aa662..f15b021 100644 --- a/sound/usb/usbmidi.c +++ b/sound/usb/usbmidi.c @@ -84,39 +84,36 @@ struct usb_ms_endpoint_descriptor { __u8 baAssocJackID[0]; } __attribute__ ((packed)); -typedef struct snd_usb_midi snd_usb_midi_t; -typedef struct snd_usb_midi_endpoint snd_usb_midi_endpoint_t; -typedef struct snd_usb_midi_out_endpoint snd_usb_midi_out_endpoint_t; -typedef struct snd_usb_midi_in_endpoint snd_usb_midi_in_endpoint_t; -typedef struct usbmidi_out_port usbmidi_out_port_t; -typedef struct usbmidi_in_port usbmidi_in_port_t; +struct snd_usb_midi_in_endpoint; +struct snd_usb_midi_out_endpoint; +struct snd_usb_midi_endpoint; struct usb_protocol_ops { - void (*input)(snd_usb_midi_in_endpoint_t*, uint8_t*, int); - void (*output)(snd_usb_midi_out_endpoint_t*); + void (*input)(struct snd_usb_midi_in_endpoint*, uint8_t*, int); + void (*output)(struct snd_usb_midi_out_endpoint*); void (*output_packet)(struct urb*, uint8_t, uint8_t, uint8_t, uint8_t); - void (*init_out_endpoint)(snd_usb_midi_out_endpoint_t*); - void (*finish_out_endpoint)(snd_usb_midi_out_endpoint_t*); + void (*init_out_endpoint)(struct snd_usb_midi_out_endpoint*); + void (*finish_out_endpoint)(struct snd_usb_midi_out_endpoint*); }; struct snd_usb_midi { - snd_usb_audio_t *chip; + struct snd_usb_audio *chip; struct usb_interface *iface; - const snd_usb_audio_quirk_t *quirk; - snd_rawmidi_t* rmidi; + const struct snd_usb_audio_quirk *quirk; + struct snd_rawmidi *rmidi; struct usb_protocol_ops* usb_protocol_ops; struct list_head list; struct timer_list error_timer; struct snd_usb_midi_endpoint { - snd_usb_midi_out_endpoint_t *out; - snd_usb_midi_in_endpoint_t *in; + struct snd_usb_midi_out_endpoint *out; + struct snd_usb_midi_in_endpoint *in; } endpoints[MIDI_MAX_ENDPOINTS]; unsigned long input_triggered; }; struct snd_usb_midi_out_endpoint { - snd_usb_midi_t* umidi; + struct snd_usb_midi* umidi; struct urb* urb; int urb_active; int max_transfer; /* size of urb buffer */ @@ -125,8 +122,8 @@ struct snd_usb_midi_out_endpoint { spinlock_t buffer_lock; struct usbmidi_out_port { - snd_usb_midi_out_endpoint_t* ep; - snd_rawmidi_substream_t* substream; + struct snd_usb_midi_out_endpoint* ep; + struct snd_rawmidi_substream *substream; int active; uint8_t cable; /* cable number << 4 */ uint8_t state; @@ -143,17 +140,17 @@ struct snd_usb_midi_out_endpoint { }; struct snd_usb_midi_in_endpoint { - snd_usb_midi_t* umidi; + struct snd_usb_midi* umidi; struct urb* urb; struct usbmidi_in_port { - snd_rawmidi_substream_t* substream; + struct snd_rawmidi_substream *substream; } ports[0x10]; u8 seen_f5; u8 error_resubmit; int current_port; }; -static void snd_usbmidi_do_output(snd_usb_midi_out_endpoint_t* ep); +static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep); static const uint8_t snd_usbmidi_cin_length[] = { 0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1 @@ -196,10 +193,10 @@ static int snd_usbmidi_urb_error(int status) /* * Receives a chunk of MIDI data. */ -static void snd_usbmidi_input_data(snd_usb_midi_in_endpoint_t* ep, int portidx, +static void snd_usbmidi_input_data(struct snd_usb_midi_in_endpoint* ep, int portidx, uint8_t* data, int length) { - usbmidi_in_port_t* port = &ep->ports[portidx]; + struct usbmidi_in_port* port = &ep->ports[portidx]; if (!port->substream) { snd_printd("unexpected port %d!\n", portidx); @@ -227,7 +224,7 @@ static void dump_urb(const char *type, const u8 *data, int length) */ static void snd_usbmidi_in_urb_complete(struct urb* urb, struct pt_regs *regs) { - snd_usb_midi_in_endpoint_t* ep = urb->context; + struct snd_usb_midi_in_endpoint* ep = urb->context; if (urb->status == 0) { dump_urb("received", urb->transfer_buffer, urb->actual_length); @@ -251,7 +248,7 @@ static void snd_usbmidi_in_urb_complete(struct urb* urb, struct pt_regs *regs) static void snd_usbmidi_out_urb_complete(struct urb* urb, struct pt_regs *regs) { - snd_usb_midi_out_endpoint_t* ep = urb->context; + struct snd_usb_midi_out_endpoint* ep = urb->context; spin_lock(&ep->buffer_lock); ep->urb_active = 0; @@ -272,7 +269,7 @@ static void snd_usbmidi_out_urb_complete(struct urb* urb, struct pt_regs *regs) * This is called when some data should be transferred to the device * (from one or more substreams). */ -static void snd_usbmidi_do_output(snd_usb_midi_out_endpoint_t* ep) +static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint* ep) { struct urb* urb = ep->urb; unsigned long flags; @@ -297,7 +294,7 @@ static void snd_usbmidi_do_output(snd_usb_midi_out_endpoint_t* ep) static void snd_usbmidi_out_tasklet(unsigned long data) { - snd_usb_midi_out_endpoint_t* ep = (snd_usb_midi_out_endpoint_t *) data; + struct snd_usb_midi_out_endpoint* ep = (struct snd_usb_midi_out_endpoint *) data; snd_usbmidi_do_output(ep); } @@ -305,11 +302,11 @@ static void snd_usbmidi_out_tasklet(unsigned long data) /* called after transfers had been interrupted due to some USB error */ static void snd_usbmidi_error_timer(unsigned long data) { - snd_usb_midi_t *umidi = (snd_usb_midi_t *)data; + struct snd_usb_midi *umidi = (struct snd_usb_midi *)data; int i; for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { - snd_usb_midi_in_endpoint_t *in = umidi->endpoints[i].in; + struct snd_usb_midi_in_endpoint *in = umidi->endpoints[i].in; if (in && in->error_resubmit) { in->error_resubmit = 0; in->urb->dev = umidi->chip->dev; @@ -321,7 +318,7 @@ static void snd_usbmidi_error_timer(unsigned long data) } /* helper function to send static data that may not DMA-able */ -static int send_bulk_static_data(snd_usb_midi_out_endpoint_t* ep, +static int send_bulk_static_data(struct snd_usb_midi_out_endpoint* ep, const void *data, int len) { int err; @@ -342,7 +339,7 @@ static int send_bulk_static_data(snd_usb_midi_out_endpoint_t* ep, * fourth byte in each packet, and uses length instead of CIN. */ -static void snd_usbmidi_standard_input(snd_usb_midi_in_endpoint_t* ep, +static void snd_usbmidi_standard_input(struct snd_usb_midi_in_endpoint* ep, uint8_t* buffer, int buffer_length) { int i; @@ -355,7 +352,7 @@ static void snd_usbmidi_standard_input(snd_usb_midi_in_endpoint_t* ep, } } -static void snd_usbmidi_midiman_input(snd_usb_midi_in_endpoint_t* ep, +static void snd_usbmidi_midiman_input(struct snd_usb_midi_in_endpoint* ep, uint8_t* buffer, int buffer_length) { int i; @@ -401,7 +398,7 @@ static void snd_usbmidi_output_midiman_packet(struct urb* urb, uint8_t p0, /* * Converts MIDI commands to USB MIDI packets. */ -static void snd_usbmidi_transmit_byte(usbmidi_out_port_t* port, +static void snd_usbmidi_transmit_byte(struct usbmidi_out_port* port, uint8_t b, struct urb* urb) { uint8_t p0 = port->cable; @@ -495,14 +492,14 @@ static void snd_usbmidi_transmit_byte(usbmidi_out_port_t* port, } } -static void snd_usbmidi_standard_output(snd_usb_midi_out_endpoint_t* ep) +static void snd_usbmidi_standard_output(struct snd_usb_midi_out_endpoint* ep) { struct urb* urb = ep->urb; int p; /* FIXME: lower-numbered ports can starve higher-numbered ports */ for (p = 0; p < 0x10; ++p) { - usbmidi_out_port_t* port = &ep->ports[p]; + struct usbmidi_out_port* port = &ep->ports[p]; if (!port->active) continue; while (urb->transfer_buffer_length + 3 < ep->max_transfer) { @@ -534,7 +531,7 @@ static struct usb_protocol_ops snd_usbmidi_midiman_ops = { * at the third byte. */ -static void snd_usbmidi_novation_input(snd_usb_midi_in_endpoint_t* ep, +static void snd_usbmidi_novation_input(struct snd_usb_midi_in_endpoint* ep, uint8_t* buffer, int buffer_length) { if (buffer_length < 2 || !buffer[0] || buffer_length < buffer[0] + 1) @@ -542,7 +539,7 @@ static void snd_usbmidi_novation_input(snd_usb_midi_in_endpoint_t* ep, snd_usbmidi_input_data(ep, 0, &buffer[2], buffer[0] - 1); } -static void snd_usbmidi_novation_output(snd_usb_midi_out_endpoint_t* ep) +static void snd_usbmidi_novation_output(struct snd_usb_midi_out_endpoint* ep) { uint8_t* transfer_buffer; int count; @@ -571,13 +568,13 @@ static struct usb_protocol_ops snd_usbmidi_novation_ops = { * "raw" protocol: used by the MOTU FastLane. */ -static void snd_usbmidi_raw_input(snd_usb_midi_in_endpoint_t* ep, +static void snd_usbmidi_raw_input(struct snd_usb_midi_in_endpoint* ep, uint8_t* buffer, int buffer_length) { snd_usbmidi_input_data(ep, 0, buffer, buffer_length); } -static void snd_usbmidi_raw_output(snd_usb_midi_out_endpoint_t* ep) +static void snd_usbmidi_raw_output(struct snd_usb_midi_out_endpoint* ep) { int count; @@ -602,7 +599,7 @@ static struct usb_protocol_ops snd_usbmidi_raw_ops = { * Emagic USB MIDI protocol: raw MIDI with "F5 xx" port switching. */ -static void snd_usbmidi_emagic_init_out(snd_usb_midi_out_endpoint_t* ep) +static void snd_usbmidi_emagic_init_out(struct snd_usb_midi_out_endpoint* ep) { static const u8 init_data[] = { /* initialization magic: "get version" */ @@ -619,7 +616,7 @@ static void snd_usbmidi_emagic_init_out(snd_usb_midi_out_endpoint_t* ep) send_bulk_static_data(ep, init_data, sizeof(init_data)); } -static void snd_usbmidi_emagic_finish_out(snd_usb_midi_out_endpoint_t* ep) +static void snd_usbmidi_emagic_finish_out(struct snd_usb_midi_out_endpoint* ep) { static const u8 finish_data[] = { /* switch to patch mode with last preset */ @@ -635,7 +632,7 @@ static void snd_usbmidi_emagic_finish_out(snd_usb_midi_out_endpoint_t* ep) send_bulk_static_data(ep, finish_data, sizeof(finish_data)); } -static void snd_usbmidi_emagic_input(snd_usb_midi_in_endpoint_t* ep, +static void snd_usbmidi_emagic_input(struct snd_usb_midi_in_endpoint* ep, uint8_t* buffer, int buffer_length) { int i; @@ -679,7 +676,7 @@ static void snd_usbmidi_emagic_input(snd_usb_midi_in_endpoint_t* ep, } } -static void snd_usbmidi_emagic_output(snd_usb_midi_out_endpoint_t* ep) +static void snd_usbmidi_emagic_output(struct snd_usb_midi_out_endpoint* ep) { int port0 = ep->current_port; uint8_t* buf = ep->urb->transfer_buffer; @@ -689,7 +686,7 @@ static void snd_usbmidi_emagic_output(snd_usb_midi_out_endpoint_t* ep) for (i = 0; i < 0x10; ++i) { /* round-robin, starting at the last current port */ int portnum = (port0 + i) & 15; - usbmidi_out_port_t* port = &ep->ports[portnum]; + struct usbmidi_out_port* port = &ep->ports[portnum]; if (!port->active) continue; @@ -733,10 +730,10 @@ static struct usb_protocol_ops snd_usbmidi_emagic_ops = { }; -static int snd_usbmidi_output_open(snd_rawmidi_substream_t* substream) +static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream) { - snd_usb_midi_t* umidi = substream->rmidi->private_data; - usbmidi_out_port_t* port = NULL; + struct snd_usb_midi* umidi = substream->rmidi->private_data; + struct usbmidi_out_port* port = NULL; int i, j; for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) @@ -755,14 +752,14 @@ static int snd_usbmidi_output_open(snd_rawmidi_substream_t* substream) return 0; } -static int snd_usbmidi_output_close(snd_rawmidi_substream_t* substream) +static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) { return 0; } -static void snd_usbmidi_output_trigger(snd_rawmidi_substream_t* substream, int up) +static void snd_usbmidi_output_trigger(struct snd_rawmidi_substream *substream, int up) { - usbmidi_out_port_t* port = (usbmidi_out_port_t*)substream->runtime->private_data; + struct usbmidi_out_port* port = (struct usbmidi_out_port*)substream->runtime->private_data; port->active = up; if (up) { @@ -777,19 +774,19 @@ static void snd_usbmidi_output_trigger(snd_rawmidi_substream_t* substream, int u } } -static int snd_usbmidi_input_open(snd_rawmidi_substream_t* substream) +static int snd_usbmidi_input_open(struct snd_rawmidi_substream *substream) { return 0; } -static int snd_usbmidi_input_close(snd_rawmidi_substream_t* substream) +static int snd_usbmidi_input_close(struct snd_rawmidi_substream *substream) { return 0; } -static void snd_usbmidi_input_trigger(snd_rawmidi_substream_t* substream, int up) +static void snd_usbmidi_input_trigger(struct snd_rawmidi_substream *substream, int up) { - snd_usb_midi_t* umidi = substream->rmidi->private_data; + struct snd_usb_midi* umidi = substream->rmidi->private_data; if (up) set_bit(substream->number, &umidi->input_triggered); @@ -797,13 +794,13 @@ static void snd_usbmidi_input_trigger(snd_rawmidi_substream_t* substream, int up clear_bit(substream->number, &umidi->input_triggered); } -static snd_rawmidi_ops_t snd_usbmidi_output_ops = { +static struct snd_rawmidi_ops snd_usbmidi_output_ops = { .open = snd_usbmidi_output_open, .close = snd_usbmidi_output_close, .trigger = snd_usbmidi_output_trigger, }; -static snd_rawmidi_ops_t snd_usbmidi_input_ops = { +static struct snd_rawmidi_ops snd_usbmidi_input_ops = { .open = snd_usbmidi_input_open, .close = snd_usbmidi_input_close, .trigger = snd_usbmidi_input_trigger @@ -813,7 +810,7 @@ static snd_rawmidi_ops_t snd_usbmidi_input_ops = { * Frees an input endpoint. * May be called when ep hasn't been initialized completely. */ -static void snd_usbmidi_in_endpoint_delete(snd_usb_midi_in_endpoint_t* ep) +static void snd_usbmidi_in_endpoint_delete(struct snd_usb_midi_in_endpoint* ep) { if (ep->urb) { usb_buffer_free(ep->umidi->chip->dev, @@ -828,11 +825,11 @@ static void snd_usbmidi_in_endpoint_delete(snd_usb_midi_in_endpoint_t* ep) /* * Creates an input endpoint. */ -static int snd_usbmidi_in_endpoint_create(snd_usb_midi_t* umidi, - snd_usb_midi_endpoint_info_t* ep_info, - snd_usb_midi_endpoint_t* rep) +static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi, + struct snd_usb_midi_endpoint_info* ep_info, + struct snd_usb_midi_endpoint* rep) { - snd_usb_midi_in_endpoint_t* ep; + struct snd_usb_midi_in_endpoint* ep; void* buffer; unsigned int pipe; int length; @@ -885,7 +882,7 @@ static unsigned int snd_usbmidi_count_bits(unsigned int x) * Frees an output endpoint. * May be called when ep hasn't been initialized completely. */ -static void snd_usbmidi_out_endpoint_delete(snd_usb_midi_out_endpoint_t* ep) +static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint* ep) { if (ep->urb) { usb_buffer_free(ep->umidi->chip->dev, ep->max_transfer, @@ -899,11 +896,11 @@ static void snd_usbmidi_out_endpoint_delete(snd_usb_midi_out_endpoint_t* ep) /* * Creates an output endpoint, and initializes output ports. */ -static int snd_usbmidi_out_endpoint_create(snd_usb_midi_t* umidi, - snd_usb_midi_endpoint_info_t* ep_info, - snd_usb_midi_endpoint_t* rep) +static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi* umidi, + struct snd_usb_midi_endpoint_info* ep_info, + struct snd_usb_midi_endpoint* rep) { - snd_usb_midi_out_endpoint_t* ep; + struct snd_usb_midi_out_endpoint* ep; int i; unsigned int pipe; void* buffer; @@ -951,12 +948,12 @@ static int snd_usbmidi_out_endpoint_create(snd_usb_midi_t* umidi, /* * Frees everything. */ -static void snd_usbmidi_free(snd_usb_midi_t* umidi) +static void snd_usbmidi_free(struct snd_usb_midi* umidi) { int i; for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { - snd_usb_midi_endpoint_t* ep = &umidi->endpoints[i]; + struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; if (ep->out) snd_usbmidi_out_endpoint_delete(ep->out); if (ep->in) @@ -970,13 +967,13 @@ static void snd_usbmidi_free(snd_usb_midi_t* umidi) */ void snd_usbmidi_disconnect(struct list_head* p) { - snd_usb_midi_t* umidi; + struct snd_usb_midi* umidi; int i; - umidi = list_entry(p, snd_usb_midi_t, list); + umidi = list_entry(p, struct snd_usb_midi, list); del_timer_sync(&umidi->error_timer); for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { - snd_usb_midi_endpoint_t* ep = &umidi->endpoints[i]; + struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; if (ep->out) tasklet_kill(&ep->out->tasklet); if (ep->out && ep->out->urb) { @@ -989,19 +986,19 @@ void snd_usbmidi_disconnect(struct list_head* p) } } -static void snd_usbmidi_rawmidi_free(snd_rawmidi_t* rmidi) +static void snd_usbmidi_rawmidi_free(struct snd_rawmidi *rmidi) { - snd_usb_midi_t* umidi = rmidi->private_data; + struct snd_usb_midi* umidi = rmidi->private_data; snd_usbmidi_free(umidi); } -static snd_rawmidi_substream_t* snd_usbmidi_find_substream(snd_usb_midi_t* umidi, +static struct snd_rawmidi_substream *snd_usbmidi_find_substream(struct snd_usb_midi* umidi, int stream, int number) { struct list_head* list; list_for_each(list, &umidi->rmidi->streams[stream].substreams) { - snd_rawmidi_substream_t* substream = list_entry(list, snd_rawmidi_substream_t, list); + struct snd_rawmidi_substream *substream = list_entry(list, struct snd_rawmidi_substream, list); if (substream->number == number) return substream; } @@ -1097,14 +1094,14 @@ static struct { { USB_ID(0x086a, 0x0003), 4, "%s Broadcast" }, }; -static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, +static void snd_usbmidi_init_substream(struct snd_usb_midi* umidi, int stream, int number, - snd_rawmidi_substream_t** rsubstream) + struct snd_rawmidi_substream ** rsubstream) { int i; const char *name_format; - snd_rawmidi_substream_t* substream = snd_usbmidi_find_substream(umidi, stream, number); + struct snd_rawmidi_substream *substream = snd_usbmidi_find_substream(umidi, stream, number); if (!substream) { snd_printd(KERN_ERR "substream %d:%d not found\n", stream, number); return; @@ -1128,8 +1125,8 @@ static void snd_usbmidi_init_substream(snd_usb_midi_t* umidi, /* * Creates the endpoints and their ports. */ -static int snd_usbmidi_create_endpoints(snd_usb_midi_t* umidi, - snd_usb_midi_endpoint_info_t* endpoints) +static int snd_usbmidi_create_endpoints(struct snd_usb_midi* umidi, + struct snd_usb_midi_endpoint_info* endpoints) { int i, j, err; int out_ports = 0, in_ports = 0; @@ -1169,8 +1166,8 @@ static int snd_usbmidi_create_endpoints(snd_usb_midi_t* umidi, /* * Returns MIDIStreaming device capabilities. */ -static int snd_usbmidi_get_ms_info(snd_usb_midi_t* umidi, - snd_usb_midi_endpoint_info_t* endpoints) +static int snd_usbmidi_get_ms_info(struct snd_usb_midi* umidi, + struct snd_usb_midi_endpoint_info* endpoints) { struct usb_interface* intf; struct usb_host_interface *hostif; @@ -1244,7 +1241,7 @@ static int snd_usbmidi_get_ms_info(snd_usb_midi_t* umidi, * On Roland devices, use the second alternate setting to be able to use * the interrupt input endpoint. */ -static void snd_usbmidi_switch_roland_altsetting(snd_usb_midi_t* umidi) +static void snd_usbmidi_switch_roland_altsetting(struct snd_usb_midi* umidi) { struct usb_interface* intf; struct usb_host_interface *hostif; @@ -1270,8 +1267,8 @@ static void snd_usbmidi_switch_roland_altsetting(snd_usb_midi_t* umidi) /* * Try to find any usable endpoints in the interface. */ -static int snd_usbmidi_detect_endpoints(snd_usb_midi_t* umidi, - snd_usb_midi_endpoint_info_t* endpoint, +static int snd_usbmidi_detect_endpoints(struct snd_usb_midi* umidi, + struct snd_usb_midi_endpoint_info* endpoint, int max_endpoints) { struct usb_interface* intf; @@ -1318,8 +1315,8 @@ static int snd_usbmidi_detect_endpoints(snd_usb_midi_t* umidi, /* * Detects the endpoints for one-port-per-endpoint protocols. */ -static int snd_usbmidi_detect_per_port_endpoints(snd_usb_midi_t* umidi, - snd_usb_midi_endpoint_info_t* endpoints) +static int snd_usbmidi_detect_per_port_endpoints(struct snd_usb_midi* umidi, + struct snd_usb_midi_endpoint_info* endpoints) { int err, i; @@ -1336,8 +1333,8 @@ static int snd_usbmidi_detect_per_port_endpoints(snd_usb_midi_t* umidi, /* * Detects the endpoints and ports of Yamaha devices. */ -static int snd_usbmidi_detect_yamaha(snd_usb_midi_t* umidi, - snd_usb_midi_endpoint_info_t* endpoint) +static int snd_usbmidi_detect_yamaha(struct snd_usb_midi* umidi, + struct snd_usb_midi_endpoint_info* endpoint) { struct usb_interface* intf; struct usb_host_interface *hostif; @@ -1375,10 +1372,10 @@ static int snd_usbmidi_detect_yamaha(snd_usb_midi_t* umidi, /* * Creates the endpoints and their ports for Midiman devices. */ -static int snd_usbmidi_create_endpoints_midiman(snd_usb_midi_t* umidi, - snd_usb_midi_endpoint_info_t* endpoint) +static int snd_usbmidi_create_endpoints_midiman(struct snd_usb_midi* umidi, + struct snd_usb_midi_endpoint_info* endpoint) { - snd_usb_midi_endpoint_info_t ep_info; + struct snd_usb_midi_endpoint_info ep_info; struct usb_interface* intf; struct usb_host_interface *hostif; struct usb_interface_descriptor* intfd; @@ -1458,10 +1455,10 @@ static int snd_usbmidi_create_endpoints_midiman(snd_usb_midi_t* umidi, return 0; } -static int snd_usbmidi_create_rawmidi(snd_usb_midi_t* umidi, +static int snd_usbmidi_create_rawmidi(struct snd_usb_midi* umidi, int out_ports, int in_ports) { - snd_rawmidi_t* rmidi; + struct snd_rawmidi *rmidi; int err; err = snd_rawmidi_new(umidi->chip->card, "USB MIDI", @@ -1487,18 +1484,18 @@ static int snd_usbmidi_create_rawmidi(snd_usb_midi_t* umidi, */ void snd_usbmidi_input_stop(struct list_head* p) { - snd_usb_midi_t* umidi; + struct snd_usb_midi* umidi; int i; - umidi = list_entry(p, snd_usb_midi_t, list); + umidi = list_entry(p, struct snd_usb_midi, list); for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) { - snd_usb_midi_endpoint_t* ep = &umidi->endpoints[i]; + struct snd_usb_midi_endpoint* ep = &umidi->endpoints[i]; if (ep->in) usb_kill_urb(ep->in->urb); } } -static void snd_usbmidi_input_start_ep(snd_usb_midi_in_endpoint_t* ep) +static void snd_usbmidi_input_start_ep(struct snd_usb_midi_in_endpoint* ep) { if (ep) { struct urb* urb = ep->urb; @@ -1512,10 +1509,10 @@ static void snd_usbmidi_input_start_ep(snd_usb_midi_in_endpoint_t* ep) */ void snd_usbmidi_input_start(struct list_head* p) { - snd_usb_midi_t* umidi; + struct snd_usb_midi* umidi; int i; - umidi = list_entry(p, snd_usb_midi_t, list); + umidi = list_entry(p, struct snd_usb_midi, list); for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) snd_usbmidi_input_start_ep(umidi->endpoints[i].in); } @@ -1523,12 +1520,12 @@ void snd_usbmidi_input_start(struct list_head* p) /* * Creates and registers everything needed for a MIDI streaming interface. */ -int snd_usb_create_midi_interface(snd_usb_audio_t* chip, +int snd_usb_create_midi_interface(struct snd_usb_audio* chip, struct usb_interface* iface, - const snd_usb_audio_quirk_t* quirk) + const struct snd_usb_audio_quirk* quirk) { - snd_usb_midi_t* umidi; - snd_usb_midi_endpoint_info_t endpoints[MIDI_MAX_ENDPOINTS]; + struct snd_usb_midi* umidi; + struct snd_usb_midi_endpoint_info endpoints[MIDI_MAX_ENDPOINTS]; int out_ports, in_ports; int i, err; @@ -1551,7 +1548,7 @@ int snd_usb_create_midi_interface(snd_usb_audio_t* chip, break; case QUIRK_MIDI_FIXED_ENDPOINT: memcpy(&endpoints[0], quirk->data, - sizeof(snd_usb_midi_endpoint_info_t)); + sizeof(struct snd_usb_midi_endpoint_info)); err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1); break; case QUIRK_MIDI_YAMAHA: @@ -1560,7 +1557,7 @@ int snd_usb_create_midi_interface(snd_usb_audio_t* chip, case QUIRK_MIDI_MIDIMAN: umidi->usb_protocol_ops = &snd_usbmidi_midiman_ops; memcpy(&endpoints[0], quirk->data, - sizeof(snd_usb_midi_endpoint_info_t)); + sizeof(struct snd_usb_midi_endpoint_info)); err = 0; break; case QUIRK_MIDI_NOVATION: @@ -1574,7 +1571,7 @@ int snd_usb_create_midi_interface(snd_usb_audio_t* chip, case QUIRK_MIDI_EMAGIC: umidi->usb_protocol_ops = &snd_usbmidi_emagic_ops; memcpy(&endpoints[0], quirk->data, - sizeof(snd_usb_midi_endpoint_info_t)); + sizeof(struct snd_usb_midi_endpoint_info)); err = snd_usbmidi_detect_endpoints(umidi, &endpoints[0], 1); break; case QUIRK_MIDI_MIDITECH: diff --git a/sound/usb/usbmixer.c b/sound/usb/usbmixer.c index e570d14..678dac2 100644 --- a/sound/usb/usbmixer.c +++ b/sound/usb/usbmixer.c @@ -46,18 +46,13 @@ /* ignore error from controls - for debugging */ /* #define IGNORE_CTL_ERROR */ -typedef struct usb_mixer_build mixer_build_t; -typedef struct usb_audio_term usb_audio_term_t; -typedef struct usb_mixer_elem_info usb_mixer_elem_info_t; - - struct usb_mixer_interface { - snd_usb_audio_t *chip; + struct snd_usb_audio *chip; unsigned int ctrlif; struct list_head list; unsigned int ignore_ctl_error; struct urb *urb; - usb_mixer_elem_info_t **id_elems; /* array[256], indexed by unit id */ + struct usb_mixer_elem_info **id_elems; /* array[256], indexed by unit id */ /* Sound Blaster remote control stuff */ enum { @@ -86,21 +81,21 @@ struct usb_audio_term { struct usbmix_name_map; -struct usb_mixer_build { - snd_usb_audio_t *chip; +struct mixer_build { + struct snd_usb_audio *chip; struct usb_mixer_interface *mixer; unsigned char *buffer; unsigned int buflen; DECLARE_BITMAP(unitbitmap, 256); - usb_audio_term_t oterm; + struct usb_audio_term oterm; const struct usbmix_name_map *map; const struct usbmix_selector_map *selector_map; }; struct usb_mixer_elem_info { struct usb_mixer_interface *mixer; - usb_mixer_elem_info_t *next_id_elem; /* list of controls with same id */ - snd_ctl_elem_id_t *elem_id; + struct usb_mixer_elem_info *next_id_elem; /* list of controls with same id */ + struct snd_ctl_elem_id *elem_id; unsigned int id; unsigned int control; /* CS or ICN (high byte) */ unsigned int cmask; /* channel mask bitmap: 0 = master */ @@ -179,7 +174,7 @@ enum { #include "usbmixer_maps.c" /* get the mapped name if the unit matches */ -static int check_mapped_name(mixer_build_t *state, int unitid, int control, char *buf, int buflen) +static int check_mapped_name(struct mixer_build *state, int unitid, int control, char *buf, int buflen) { const struct usbmix_name_map *p; @@ -197,7 +192,7 @@ static int check_mapped_name(mixer_build_t *state, int unitid, int control, char } /* check whether the control should be ignored */ -static int check_ignored_ctl(mixer_build_t *state, int unitid, int control) +static int check_ignored_ctl(struct mixer_build *state, int unitid, int control) { const struct usbmix_name_map *p; @@ -214,7 +209,7 @@ static int check_ignored_ctl(mixer_build_t *state, int unitid, int control) } /* get the mapped selector source name */ -static int check_mapped_selector_name(mixer_build_t *state, int unitid, +static int check_mapped_selector_name(struct mixer_build *state, int unitid, int index, char *buf, int buflen) { const struct usbmix_selector_map *p; @@ -231,7 +226,7 @@ static int check_mapped_selector_name(mixer_build_t *state, int unitid, /* * find an audio control unit with the given unit id */ -static void *find_audio_control_unit(mixer_build_t *state, unsigned char unit) +static void *find_audio_control_unit(struct mixer_build *state, unsigned char unit) { unsigned char *p; @@ -248,7 +243,7 @@ static void *find_audio_control_unit(mixer_build_t *state, unsigned char unit) /* * copy a string with the given id */ -static int snd_usb_copy_string_desc(mixer_build_t *state, int index, char *buf, int maxlen) +static int snd_usb_copy_string_desc(struct mixer_build *state, int index, char *buf, int maxlen) { int len = usb_string(state->chip->dev, index, buf, maxlen - 1); buf[len] = 0; @@ -258,7 +253,7 @@ static int snd_usb_copy_string_desc(mixer_build_t *state, int index, char *buf, /* * convert from the byte/word on usb descriptor to the zero-based integer */ -static int convert_signed_value(usb_mixer_elem_info_t *cval, int val) +static int convert_signed_value(struct usb_mixer_elem_info *cval, int val) { switch (cval->val_type) { case USB_MIXER_BOOLEAN: @@ -288,7 +283,7 @@ static int convert_signed_value(usb_mixer_elem_info_t *cval, int val) /* * convert from the zero-based int to the byte/word for usb descriptor */ -static int convert_bytes_value(usb_mixer_elem_info_t *cval, int val) +static int convert_bytes_value(struct usb_mixer_elem_info *cval, int val) { switch (cval->val_type) { case USB_MIXER_BOOLEAN: @@ -305,7 +300,7 @@ static int convert_bytes_value(usb_mixer_elem_info_t *cval, int val) return 0; /* not reached */ } -static int get_relative_value(usb_mixer_elem_info_t *cval, int val) +static int get_relative_value(struct usb_mixer_elem_info *cval, int val) { if (! cval->res) cval->res = 1; @@ -317,7 +312,7 @@ static int get_relative_value(usb_mixer_elem_info_t *cval, int val) return (val - cval->min) / cval->res; } -static int get_abs_value(usb_mixer_elem_info_t *cval, int val) +static int get_abs_value(struct usb_mixer_elem_info *cval, int val) { if (val < 0) return cval->min; @@ -335,7 +330,7 @@ static int get_abs_value(usb_mixer_elem_info_t *cval, int val) * retrieve a mixer value */ -static int get_ctl_value(usb_mixer_elem_info_t *cval, int request, int validx, int *value_ret) +static int get_ctl_value(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) { unsigned char buf[2]; int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; @@ -357,13 +352,13 @@ static int get_ctl_value(usb_mixer_elem_info_t *cval, int request, int validx, i return -EINVAL; } -static int get_cur_ctl_value(usb_mixer_elem_info_t *cval, int validx, int *value) +static int get_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int *value) { return get_ctl_value(cval, GET_CUR, validx, value); } /* channel = 0: master, 1 = first channel */ -static inline int get_cur_mix_value(usb_mixer_elem_info_t *cval, int channel, int *value) +static inline int get_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int *value) { return get_ctl_value(cval, GET_CUR, (cval->control << 8) | channel, value); } @@ -372,7 +367,7 @@ static inline int get_cur_mix_value(usb_mixer_elem_info_t *cval, int channel, in * set a mixer value */ -static int set_ctl_value(usb_mixer_elem_info_t *cval, int request, int validx, int value_set) +static int set_ctl_value(struct usb_mixer_elem_info *cval, int request, int validx, int value_set) { unsigned char buf[2]; int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; @@ -394,12 +389,12 @@ static int set_ctl_value(usb_mixer_elem_info_t *cval, int request, int validx, i return -EINVAL; } -static int set_cur_ctl_value(usb_mixer_elem_info_t *cval, int validx, int value) +static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value) { return set_ctl_value(cval, SET_CUR, validx, value); } -static inline int set_cur_mix_value(usb_mixer_elem_info_t *cval, int channel, int value) +static inline int set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel, int value) { return set_ctl_value(cval, SET_CUR, (cval->control << 8) | channel, value); } @@ -409,7 +404,7 @@ static inline int set_cur_mix_value(usb_mixer_elem_info_t *cval, int channel, in * parser routines begin here... */ -static int parse_audio_unit(mixer_build_t *state, int unitid); +static int parse_audio_unit(struct mixer_build *state, int unitid); /* @@ -430,9 +425,9 @@ static int check_matrix_bitmap(unsigned char *bmap, int ich, int och, int num_ou * if failed, give up and free the control instance. */ -static int add_control_to_empty(mixer_build_t *state, snd_kcontrol_t *kctl) +static int add_control_to_empty(struct mixer_build *state, struct snd_kcontrol *kctl) { - usb_mixer_elem_info_t *cval = kctl->private_data; + struct usb_mixer_elem_info *cval = kctl->private_data; int err; while (snd_ctl_find_id(state->chip->card, &kctl->id)) @@ -496,7 +491,7 @@ static struct iterm_name_combo { { 0 }, }; -static int get_term_name(mixer_build_t *state, usb_audio_term_t *iterm, +static int get_term_name(struct mixer_build *state, struct usb_audio_term *iterm, unsigned char *name, int maxlen, int term_only) { struct iterm_name_combo *names; @@ -546,7 +541,7 @@ static int get_term_name(mixer_build_t *state, usb_audio_term_t *iterm, * parse the source unit recursively until it reaches to a terminal * or a branched unit. */ -static int check_input_term(mixer_build_t *state, int id, usb_audio_term_t *term) +static int check_input_term(struct mixer_build *state, int id, struct usb_audio_term *term) { unsigned char *p1; @@ -621,7 +616,7 @@ static struct usb_feature_control_info audio_feature_info[] = { /* private_free callback */ -static void usb_mixer_elem_free(snd_kcontrol_t *kctl) +static void usb_mixer_elem_free(struct snd_kcontrol *kctl) { kfree(kctl->private_data); kctl->private_data = NULL; @@ -635,7 +630,7 @@ static void usb_mixer_elem_free(snd_kcontrol_t *kctl) /* * retrieve the minimum and maximum values for the specified control */ -static int get_min_max(usb_mixer_elem_info_t *cval, int default_min) +static int get_min_max(struct usb_mixer_elem_info *cval, int default_min) { /* for failsafe */ cval->min = default_min; @@ -683,9 +678,9 @@ static int get_min_max(usb_mixer_elem_info_t *cval, int default_min) /* get a feature/mixer unit info */ -static int mixer_ctl_feature_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - usb_mixer_elem_info_t *cval = kcontrol->private_data; + struct usb_mixer_elem_info *cval = kcontrol->private_data; if (cval->val_type == USB_MIXER_BOOLEAN || cval->val_type == USB_MIXER_INV_BOOLEAN) @@ -707,9 +702,9 @@ static int mixer_ctl_feature_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t } /* get the current value from feature/mixer unit */ -static int mixer_ctl_feature_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - usb_mixer_elem_info_t *cval = kcontrol->private_data; + struct usb_mixer_elem_info *cval = kcontrol->private_data; int c, cnt, val, err; if (cval->cmask) { @@ -748,9 +743,9 @@ static int mixer_ctl_feature_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t } /* put the current value to feature/mixer unit */ -static int mixer_ctl_feature_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - usb_mixer_elem_info_t *cval = kcontrol->private_data; + struct usb_mixer_elem_info *cval = kcontrol->private_data; int c, cnt, val, oval, err; int changed = 0; @@ -791,7 +786,7 @@ static int mixer_ctl_feature_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return changed; } -static snd_kcontrol_new_t usb_feature_unit_ctl = { +static struct snd_kcontrol_new usb_feature_unit_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "", /* will be filled later manually */ .info = mixer_ctl_feature_info, @@ -804,15 +799,15 @@ static snd_kcontrol_new_t usb_feature_unit_ctl = { * build a feature control */ -static void build_feature_ctl(mixer_build_t *state, unsigned char *desc, +static void build_feature_ctl(struct mixer_build *state, unsigned char *desc, unsigned int ctl_mask, int control, - usb_audio_term_t *iterm, int unitid) + struct usb_audio_term *iterm, int unitid) { unsigned int len = 0; int mapped_name = 0; int nameid = desc[desc[0] - 1]; - snd_kcontrol_t *kctl; - usb_mixer_elem_info_t *cval; + struct snd_kcontrol *kctl; + struct usb_mixer_elem_info *cval; control++; /* change from zero-based to 1-based value */ @@ -928,10 +923,10 @@ static void build_feature_ctl(mixer_build_t *state, unsigned char *desc, * * most of controlls are defined here. */ -static int parse_audio_feature_unit(mixer_build_t *state, int unitid, unsigned char *ftr) +static int parse_audio_feature_unit(struct mixer_build *state, int unitid, unsigned char *ftr) { int channels, i, j; - usb_audio_term_t iterm; + struct usb_audio_term iterm; unsigned int master_bits, first_ch_bits; int err, csize; @@ -984,15 +979,15 @@ static int parse_audio_feature_unit(mixer_build_t *state, int unitid, unsigned c * input channel number (zero based) is given in control field instead. */ -static void build_mixer_unit_ctl(mixer_build_t *state, unsigned char *desc, +static void build_mixer_unit_ctl(struct mixer_build *state, unsigned char *desc, int in_pin, int in_ch, int unitid, - usb_audio_term_t *iterm) + struct usb_audio_term *iterm) { - usb_mixer_elem_info_t *cval; + struct usb_mixer_elem_info *cval; unsigned int input_pins = desc[4]; unsigned int num_outs = desc[5 + input_pins]; unsigned int i, len; - snd_kcontrol_t *kctl; + struct snd_kcontrol *kctl; if (check_ignored_ctl(state, unitid, 0)) return; @@ -1039,9 +1034,9 @@ static void build_mixer_unit_ctl(mixer_build_t *state, unsigned char *desc, /* * parse a mixer unit */ -static int parse_audio_mixer_unit(mixer_build_t *state, int unitid, unsigned char *desc) +static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, unsigned char *desc) { - usb_audio_term_t iterm; + struct usb_audio_term iterm; int input_pins, num_ins, num_outs; int pin, ich, err; @@ -1089,9 +1084,9 @@ static int parse_audio_mixer_unit(mixer_build_t *state, int unitid, unsigned cha */ /* get callback for processing/extension unit */ -static int mixer_ctl_procunit_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixer_ctl_procunit_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - usb_mixer_elem_info_t *cval = kcontrol->private_data; + struct usb_mixer_elem_info *cval = kcontrol->private_data; int err, val; err = get_cur_ctl_value(cval, cval->control << 8, &val); @@ -1107,9 +1102,9 @@ static int mixer_ctl_procunit_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t } /* put callback for processing/extension unit */ -static int mixer_ctl_procunit_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixer_ctl_procunit_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - usb_mixer_elem_info_t *cval = kcontrol->private_data; + struct usb_mixer_elem_info *cval = kcontrol->private_data; int val, oval, err; err = get_cur_ctl_value(cval, cval->control << 8, &oval); @@ -1128,7 +1123,7 @@ static int mixer_ctl_procunit_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t } /* alsa control interface for processing/extension unit */ -static snd_kcontrol_new_t mixer_procunit_ctl = { +static struct snd_kcontrol_new mixer_procunit_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "", /* will be filled later */ .info = mixer_ctl_feature_info, @@ -1205,11 +1200,11 @@ static struct procunit_info procunits[] = { /* * build a processing/extension unit */ -static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char *dsc, struct procunit_info *list, char *name) +static int build_audio_procunit(struct mixer_build *state, int unitid, unsigned char *dsc, struct procunit_info *list, char *name) { int num_ins = dsc[6]; - usb_mixer_elem_info_t *cval; - snd_kcontrol_t *kctl; + struct usb_mixer_elem_info *cval; + struct snd_kcontrol *kctl; int i, err, nameid, type, len; struct procunit_info *info; struct procunit_value_info *valinfo; @@ -1297,12 +1292,12 @@ static int build_audio_procunit(mixer_build_t *state, int unitid, unsigned char } -static int parse_audio_processing_unit(mixer_build_t *state, int unitid, unsigned char *desc) +static int parse_audio_processing_unit(struct mixer_build *state, int unitid, unsigned char *desc) { return build_audio_procunit(state, unitid, desc, procunits, "Processing Unit"); } -static int parse_audio_extension_unit(mixer_build_t *state, int unitid, unsigned char *desc) +static int parse_audio_extension_unit(struct mixer_build *state, int unitid, unsigned char *desc) { return build_audio_procunit(state, unitid, desc, NULL, "Extension Unit"); } @@ -1315,9 +1310,9 @@ static int parse_audio_extension_unit(mixer_build_t *state, int unitid, unsigned /* info callback for selector unit * use an enumerator type for routing */ -static int mixer_ctl_selector_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { - usb_mixer_elem_info_t *cval = kcontrol->private_data; + struct usb_mixer_elem_info *cval = kcontrol->private_data; char **itemlist = (char **)kcontrol->private_value; snd_assert(itemlist, return -EINVAL); @@ -1331,9 +1326,9 @@ static int mixer_ctl_selector_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t } /* get callback for selector unit */ -static int mixer_ctl_selector_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixer_ctl_selector_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - usb_mixer_elem_info_t *cval = kcontrol->private_data; + struct usb_mixer_elem_info *cval = kcontrol->private_data; int val, err; err = get_cur_ctl_value(cval, 0, &val); @@ -1350,9 +1345,9 @@ static int mixer_ctl_selector_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t } /* put callback for selector unit */ -static int mixer_ctl_selector_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - usb_mixer_elem_info_t *cval = kcontrol->private_data; + struct usb_mixer_elem_info *cval = kcontrol->private_data; int val, oval, err; err = get_cur_ctl_value(cval, 0, &oval); @@ -1371,7 +1366,7 @@ static int mixer_ctl_selector_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t } /* alsa control interface for selector unit */ -static snd_kcontrol_new_t mixer_selectunit_ctl = { +static struct snd_kcontrol_new mixer_selectunit_ctl = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "", /* will be filled later */ .info = mixer_ctl_selector_info, @@ -1383,12 +1378,12 @@ static snd_kcontrol_new_t mixer_selectunit_ctl = { /* private free callback. * free both private_data and private_value */ -static void usb_mixer_selector_elem_free(snd_kcontrol_t *kctl) +static void usb_mixer_selector_elem_free(struct snd_kcontrol *kctl) { int i, num_ins = 0; if (kctl->private_data) { - usb_mixer_elem_info_t *cval = kctl->private_data; + struct usb_mixer_elem_info *cval = kctl->private_data; num_ins = cval->max; kfree(cval); kctl->private_data = NULL; @@ -1405,13 +1400,13 @@ static void usb_mixer_selector_elem_free(snd_kcontrol_t *kctl) /* * parse a selector unit */ -static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned char *desc) +static int parse_audio_selector_unit(struct mixer_build *state, int unitid, unsigned char *desc) { unsigned int num_ins = desc[4]; unsigned int i, nameid, len; int err; - usb_mixer_elem_info_t *cval; - snd_kcontrol_t *kctl; + struct usb_mixer_elem_info *cval; + struct snd_kcontrol *kctl; char **namelist; if (! num_ins || desc[0] < 6 + num_ins) { @@ -1452,7 +1447,7 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned } #define MAX_ITEM_NAME_LEN 64 for (i = 0; i < num_ins; i++) { - usb_audio_term_t iterm; + struct usb_audio_term iterm; len = 0; namelist[i] = kmalloc(MAX_ITEM_NAME_LEN, GFP_KERNEL); if (! namelist[i]) { @@ -1511,7 +1506,7 @@ static int parse_audio_selector_unit(mixer_build_t *state, int unitid, unsigned * parse an audio unit recursively */ -static int parse_audio_unit(mixer_build_t *state, int unitid) +static int parse_audio_unit(struct mixer_build *state, int unitid) { unsigned char *p1; @@ -1556,7 +1551,7 @@ static void snd_usb_mixer_free(struct usb_mixer_interface *mixer) kfree(mixer); } -static int snd_usb_mixer_dev_free(snd_device_t *device) +static int snd_usb_mixer_dev_free(struct snd_device *device) { struct usb_mixer_interface *mixer = device->device_data; snd_usb_mixer_free(mixer); @@ -1571,7 +1566,7 @@ static int snd_usb_mixer_dev_free(snd_device_t *device) static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) { unsigned char *desc; - mixer_build_t state; + struct mixer_build state; int err; const struct usbmix_ctl_map *map; struct usb_host_interface *hostif; @@ -1611,7 +1606,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer) static void snd_usb_mixer_notify_id(struct usb_mixer_interface *mixer, int unitid) { - usb_mixer_elem_info_t *info; + struct usb_mixer_elem_info *info; for (info = mixer->id_elems[unitid]; info; info = info->next_id_elem) snd_ctl_notify(mixer->chip->card, SNDRV_CTL_EVENT_MASK_VALUE, @@ -1725,7 +1720,7 @@ static void snd_usb_soundblaster_remote_complete(struct urb *urb, wake_up(&mixer->rc_waitq); } -static int snd_usb_sbrc_hwdep_open(snd_hwdep_t *hw, struct file *file) +static int snd_usb_sbrc_hwdep_open(struct snd_hwdep *hw, struct file *file) { struct usb_mixer_interface *mixer = hw->private_data; @@ -1734,7 +1729,7 @@ static int snd_usb_sbrc_hwdep_open(snd_hwdep_t *hw, struct file *file) return 0; } -static int snd_usb_sbrc_hwdep_release(snd_hwdep_t *hw, struct file *file) +static int snd_usb_sbrc_hwdep_release(struct snd_hwdep *hw, struct file *file) { struct usb_mixer_interface *mixer = hw->private_data; @@ -1743,7 +1738,7 @@ static int snd_usb_sbrc_hwdep_release(snd_hwdep_t *hw, struct file *file) return 0; } -static long snd_usb_sbrc_hwdep_read(snd_hwdep_t *hw, char __user *buf, +static long snd_usb_sbrc_hwdep_read(struct snd_hwdep *hw, char __user *buf, long count, loff_t *offset) { struct usb_mixer_interface *mixer = hw->private_data; @@ -1763,7 +1758,7 @@ static long snd_usb_sbrc_hwdep_read(snd_hwdep_t *hw, char __user *buf, return err < 0 ? err : count; } -static unsigned int snd_usb_sbrc_hwdep_poll(snd_hwdep_t *hw, struct file *file, +static unsigned int snd_usb_sbrc_hwdep_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) { struct usb_mixer_interface *mixer = hw->private_data; @@ -1774,7 +1769,7 @@ static unsigned int snd_usb_sbrc_hwdep_poll(snd_hwdep_t *hw, struct file *file, static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) { - snd_hwdep_t *hwdep; + struct snd_hwdep *hwdep; int err, len; switch (mixer->chip->usb_id) { @@ -1825,7 +1820,7 @@ static int snd_usb_soundblaster_remote_init(struct usb_mixer_interface *mixer) return 0; } -static int snd_audigy2nx_led_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_audigy2nx_led_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1834,7 +1829,7 @@ static int snd_audigy2nx_led_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int snd_audigy2nx_led_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_audigy2nx_led_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); int index = kcontrol->private_value; @@ -1843,7 +1838,7 @@ static int snd_audigy2nx_led_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return 0; } -static int snd_audigy2nx_led_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct usb_mixer_interface *mixer = snd_kcontrol_chip(kcontrol); int index = kcontrol->private_value; @@ -1863,7 +1858,7 @@ static int snd_audigy2nx_led_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return changed; } -static snd_kcontrol_new_t snd_audigy2nx_controls[] = { +static struct snd_kcontrol_new snd_audigy2nx_controls[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "CMSS LED Switch", @@ -1904,8 +1899,8 @@ static int snd_audigy2nx_controls_create(struct usb_mixer_interface *mixer) return 0; } -static void snd_audigy2nx_proc_read(snd_info_entry_t *entry, - snd_info_buffer_t *buffer) +static void snd_audigy2nx_proc_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { static const struct { int unitid; @@ -1935,9 +1930,9 @@ static void snd_audigy2nx_proc_read(snd_info_entry_t *entry, } } -int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) +int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif) { - static snd_device_ops_t dev_ops = { + static struct snd_device_ops dev_ops = { .dev_free = snd_usb_mixer_dev_free }; struct usb_mixer_interface *mixer; @@ -1967,7 +1962,7 @@ int snd_usb_create_mixer(snd_usb_audio_t *chip, int ctrlif) goto _error; if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020)) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; if ((err = snd_audigy2nx_controls_create(mixer)) < 0) goto _error; diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h index ba506c3..0e05754 100644 --- a/sound/usb/usbquirks.h +++ b/sound/usb/usbquirks.h @@ -45,7 +45,7 @@ #define YAMAHA_DEVICE(id, name) { \ USB_DEVICE(0x0499, id), \ - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { \ + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \ .vendor_name = "Yamaha", \ .product_name = name, \ .ifnum = QUIRK_ANY_INTERFACE, \ @@ -54,7 +54,7 @@ } #define YAMAHA_INTERFACE(id, intf, name) { \ USB_DEVICE_VENDOR_SPEC(0x0499, id), \ - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { \ + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { \ .vendor_name = "Yamaha", \ .product_name = name, \ .ifnum = intf, \ @@ -149,12 +149,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), */ { USB_DEVICE(0x0582, 0x0000), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "UA-100", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_AUDIO_FIXED_ENDPOINT, @@ -192,7 +192,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0007, .in_cables = 0x0007 } @@ -205,12 +205,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x0582, 0x0002), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UM-4", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -222,7 +222,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x000f, .in_cables = 0x000f } @@ -235,12 +235,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x0582, 0x0003), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "SC-8850", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -252,7 +252,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x003f, .in_cables = 0x003f } @@ -265,12 +265,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x0582, 0x0004), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "U-8", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -282,7 +282,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0005, .in_cables = 0x0005 } @@ -296,12 +296,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* a later revision uses ID 0x0099 */ USB_DEVICE(0x0582, 0x0005), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UM-2", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -313,7 +313,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0003, .in_cables = 0x0003 } @@ -326,12 +326,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x0582, 0x0007), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "SC-8820", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -343,7 +343,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0013, .in_cables = 0x0013 } @@ -356,12 +356,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x0582, 0x0008), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "PC-300", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -373,7 +373,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -387,12 +387,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* a later revision uses ID 0x009d */ USB_DEVICE(0x0582, 0x0009), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UM-1", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -404,7 +404,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -417,12 +417,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x0582, 0x000b), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "SK-500", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -434,7 +434,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0013, .in_cables = 0x0013 } @@ -449,12 +449,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), /* thanks to Emiliano Grilli <emillo@libero.it> * for helping researching this data */ USB_DEVICE(0x0582, 0x000c), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "SC-D70", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_AUDIO_FIXED_ENDPOINT, @@ -492,7 +492,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0007, .in_cables = 0x0007 } @@ -513,12 +513,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * the 96kHz sample rate. */ USB_DEVICE(0x0582, 0x0010), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UA-5", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 1, .type = QUIRK_AUDIO_STANDARD_INTERFACE @@ -536,12 +536,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0013 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0012), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "XV-5050", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -550,12 +550,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0015 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0014), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UM-880", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x01ff, .in_cables = 0x01ff } @@ -564,12 +564,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0017 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0016), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "SD-90", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -581,7 +581,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x000f, .in_cables = 0x000f } @@ -595,12 +595,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x001c when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x001b), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "MMP-2", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -612,7 +612,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 2, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -626,12 +626,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x001e when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x001d), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "V-SYNTH", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -640,12 +640,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0024 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0023), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UM-550", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x003f, .in_cables = 0x003f } @@ -658,12 +658,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * and no MIDI. */ USB_DEVICE(0x0582, 0x0025), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UA-20", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 1, .type = QUIRK_AUDIO_STANDARD_INTERFACE @@ -685,12 +685,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0028 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0027), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "SD-20", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0003, .in_cables = 0x0007 } @@ -699,12 +699,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x002a when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0029), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "SD-80", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x000f, .in_cables = 0x000f } @@ -717,12 +717,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * but offers only 16-bit PCM and no MIDI. */ USB_DEVICE_VENDOR_SPEC(0x0582, 0x002b), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UA-700", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 1, .type = QUIRK_AUDIO_EDIROL_UA700_UA25 @@ -744,12 +744,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x002e when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x002d), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "XV-2020", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -758,12 +758,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0030 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x002f), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "VariOS", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0007, .in_cables = 0x0007 } @@ -772,12 +772,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0034 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0033), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "PCR", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0003, .in_cables = 0x0007 } @@ -790,12 +790,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * later revisions use IDs 0x0054 and 0x00a2. */ USB_DEVICE(0x0582, 0x0037), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "Digital Piano", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -808,12 +808,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * and no MIDI. */ USB_DEVICE_VENDOR_SPEC(0x0582, 0x003b), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "BOSS", .product_name = "GS-10", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = & (const snd_usb_audio_quirk_t[]) { + .data = & (const struct snd_usb_audio_quirk[]) { { .ifnum = 1, .type = QUIRK_AUDIO_STANDARD_INTERFACE @@ -835,12 +835,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0041 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0040), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "GI-20", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -849,12 +849,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0043 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0042), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "RS-70", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -862,12 +862,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x0582, 0x0044), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "UA-1000", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 1, .type = QUIRK_AUDIO_EDIROL_UA1000 @@ -879,7 +879,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 3, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0003, .in_cables = 0x0003 } @@ -893,12 +893,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x004a when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0048), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UR-80", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0003, .in_cables = 0x0007 } @@ -908,12 +908,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x004f when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x004d), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "PCR-A", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0003, .in_cables = 0x0007 } @@ -925,12 +925,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * is standard compliant, but has only 16-bit PCM. */ USB_DEVICE(0x0582, 0x0050), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UA-3FX", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 1, .type = QUIRK_AUDIO_STANDARD_INTERFACE @@ -947,7 +947,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x0582, 0x0052), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UM-1SX", .ifnum = 0, @@ -958,12 +958,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0067 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0065), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "PCR-1", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0003 } @@ -972,12 +972,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x006b when not in "Advanced Driver" mode */ USB_DEVICE_VENDOR_SPEC(0x0582, 0x006a), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "SP-606", .ifnum = 3, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -986,12 +986,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x006e when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x006d), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", .product_name = "FANTOM-X", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1004,12 +1004,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * offers only 16-bit PCM at 44.1 kHz and no MIDI. */ USB_DEVICE_VENDOR_SPEC(0x0582, 0x0074), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "EDIROL", .product_name = "UA-25", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = (const snd_usb_audio_quirk_t[]) { + .data = (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_AUDIO_EDIROL_UA700_UA25 @@ -1031,12 +1031,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x0076 when not in "Advanced Driver" mode */ USB_DEVICE(0x0582, 0x0075), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "BOSS", .product_name = "DR-880", .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1045,12 +1045,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* has ID 0x007b when not in "Advanced Driver" mode */ USB_DEVICE_VENDOR_SPEC(0x0582, 0x007a), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Roland", /* "RD" or "RD-700SX"? */ .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0003, .in_cables = 0x0003 } @@ -1066,12 +1066,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * compliant USB MIDI ports for external MIDI and controls. */ USB_DEVICE_VENDOR_SPEC(0x06f8, 0xb000), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Hercules", .product_name = "DJ Console (WE)", .ifnum = 4, .type = QUIRK_MIDI_FIXED_ENDPOINT, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1090,12 +1090,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), /* Midiman/M-Audio devices */ { USB_DEVICE_VENDOR_SPEC(0x0763, 0x1002), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "MidiSport 2x2", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0003, .in_cables = 0x0003 } @@ -1103,12 +1103,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x1011), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "MidiSport 1x1", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1116,12 +1116,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x1015), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "Keystation", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1129,12 +1129,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x1021), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "MidiSport 4x4", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x000f, .in_cables = 0x000f } @@ -1147,12 +1147,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), * Thanks to Olaf Giesbrecht <Olaf_Giesbrecht@yahoo.de> */ USB_DEVICE_VER(0x0763, 0x1031, 0x0100, 0x0109), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "MidiSport 8x8", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x01ff, .in_cables = 0x01ff } @@ -1160,12 +1160,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x1033), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "MidiSport 8x8", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x01ff, .in_cables = 0x01ff } @@ -1173,12 +1173,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x1041), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "MidiSport 2x4", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x000f, .in_cables = 0x0003 } @@ -1186,12 +1186,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x2001), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "Quattro", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = & (const snd_usb_audio_quirk_t[]) { + .data = & (const struct snd_usb_audio_quirk[]) { /* * Interfaces 0-2 are "Windows-compatible", 16-bit only, * and share endpoints with the other interfaces. @@ -1237,7 +1237,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 9, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1250,12 +1250,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x2003), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "AudioPhile", .ifnum = 6, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1263,12 +1263,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x2008), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "Ozone", .ifnum = 3, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1276,12 +1276,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0763, 0x200d), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "M-Audio", .product_name = "OmniStudio", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = & (const snd_usb_audio_quirk_t[]) { + .data = & (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_IGNORE_INTERFACE @@ -1321,7 +1321,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { .ifnum = 9, .type = QUIRK_MIDI_MIDIMAN, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x0001, .in_cables = 0x0001 } @@ -1342,12 +1342,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), .idVendor = 0x07fd, .idProduct = 0x0001, .bDeviceSubClass = 2, - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "MOTU", .product_name = "Fastlane", .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_COMPOSITE, - .data = & (const snd_usb_audio_quirk_t[]) { + .data = & (const struct snd_usb_audio_quirk[]) { { .ifnum = 0, .type = QUIRK_MIDI_RAW @@ -1366,7 +1366,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { /* Creative Sound Blaster MP3+ */ USB_DEVICE(0x041e, 0x3010), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Creative Labs", .product_name = "Sound Blaster MP3+", .ifnum = QUIRK_NO_INTERFACE @@ -1377,12 +1377,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), /* Emagic devices */ { USB_DEVICE(0x086a, 0x0001), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Emagic", /* .product_name = "Unitor8", */ .ifnum = 2, .type = QUIRK_MIDI_EMAGIC, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x80ff, .in_cables = 0x80ff } @@ -1390,12 +1390,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x086a, 0x0002), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Emagic", /* .product_name = "AMT8", */ .ifnum = 2, .type = QUIRK_MIDI_EMAGIC, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x80ff, .in_cables = 0x80ff } @@ -1403,12 +1403,12 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x086a, 0x0003), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Emagic", /* .product_name = "MT4", */ .ifnum = 2, .type = QUIRK_MIDI_EMAGIC, - .data = & (const snd_usb_midi_endpoint_info_t) { + .data = & (const struct snd_usb_midi_endpoint_info) { .out_cables = 0x800f, .in_cables = 0x8003 } @@ -1418,7 +1418,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), /* TerraTec devices */ { USB_DEVICE_VENDOR_SPEC(0x0ccd, 0x0012), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "TerraTec", .product_name = "PHASE 26", .ifnum = 3, @@ -1427,7 +1427,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x0ccd, 0x0013), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "TerraTec", .product_name = "PHASE 26", .ifnum = 3, @@ -1438,7 +1438,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), /* Novation EMS devices */ { USB_DEVICE_VENDOR_SPEC(0x1235, 0x0001), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Novation", .product_name = "ReMOTE Audio/XStation", .ifnum = 4, @@ -1447,7 +1447,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x1235, 0x0002), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Novation", .product_name = "Speedio", .ifnum = 3, @@ -1456,7 +1456,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE_VENDOR_SPEC(0x1235, 0x4661), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Novation", .product_name = "ReMOTE25", .ifnum = 0, @@ -1466,7 +1466,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), { USB_DEVICE(0x4752, 0x0011), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Miditech", .product_name = "Midistart-2", .ifnum = 0, @@ -1475,7 +1475,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), }, { USB_DEVICE(0x7104, 0x2202), - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .vendor_name = "Miditech", .product_name = "MidiStudio-2", .ifnum = 0, @@ -1492,7 +1492,7 @@ YAMAHA_DEVICE(0x7010, "UB99"), USB_DEVICE_ID_MATCH_INT_SUBCLASS, .bInterfaceClass = USB_CLASS_AUDIO, .bInterfaceSubClass = USB_SUBCLASS_MIDI_STREAMING, - .driver_info = (unsigned long) & (const snd_usb_audio_quirk_t) { + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) { .ifnum = QUIRK_ANY_INTERFACE, .type = QUIRK_MIDI_STANDARD_INTERFACE } -- cgit v1.1 From bbe85bbd02b2220c819ad1e33c9d6327131ad281 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:08:26 +0100 Subject: [ALSA] Remove xxx_t typedefs: USB-USX2Y Modules: USB USX2Y Remove xxx_t typedefs from the USB-USX2Y driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/usb/usx2y/usX2Yhwdep.c | 62 +++++------ sound/usb/usx2y/usX2Yhwdep.h | 2 +- sound/usb/usx2y/usbus428ctldefs.h | 36 +++---- sound/usb/usx2y/usbusx2y.c | 40 ++++---- sound/usb/usx2y/usbusx2y.h | 45 ++++---- sound/usb/usx2y/usbusx2yaudio.c | 209 +++++++++++++++++++++----------------- sound/usb/usx2y/usx2yhwdeppcm.c | 171 +++++++++++++++++-------------- sound/usb/usx2y/usx2yhwdeppcm.h | 1 - 8 files changed, 299 insertions(+), 267 deletions(-) diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c index fc0d534..4b52d18 100644 --- a/sound/usb/usx2y/usX2Yhwdep.c +++ b/sound/usb/usx2y/usX2Yhwdep.c @@ -31,7 +31,7 @@ #include "usbusx2y.h" #include "usX2Yhwdep.h" -int usX2Y_hwdep_pcm_new(snd_card_t* card); +int usX2Y_hwdep_pcm_new(struct snd_card *card); static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsigned long address, int *type) @@ -49,7 +49,7 @@ static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsign offset = area->vm_pgoff << PAGE_SHIFT; offset += address - area->vm_start; snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); - vaddr = (char*)((usX2Ydev_t*)area->vm_private_data)->us428ctls_sharedmem + offset; + vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset; page = virt_to_page(vaddr); get_page(page); snd_printdd( "vaddr=%p made us428ctls_vm_nopage() return %p; offset=%lX\n", vaddr, page, offset); @@ -64,10 +64,10 @@ static struct vm_operations_struct us428ctls_vm_ops = { .nopage = snd_us428ctls_vm_nopage, }; -static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) +static int snd_us428ctls_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area) { unsigned long size = (unsigned long)(area->vm_end - area->vm_start); - usX2Ydev_t *us428 = hw->private_data; + struct usX2Ydev *us428 = hw->private_data; // FIXME this hwdep interface is used twice: fpga download and mmap for controlling Lights etc. Maybe better using 2 hwdep devs? // so as long as the device isn't fully initialised yet we return -EBUSY here. @@ -75,16 +75,16 @@ static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_are return -EBUSY; /* if userspace tries to mmap beyond end of our buffer, fail */ - if (size > PAGE_ALIGN(sizeof(us428ctls_sharedmem_t))) { - snd_printd( "%lu > %lu\n", size, (unsigned long)sizeof(us428ctls_sharedmem_t)); + if (size > PAGE_ALIGN(sizeof(struct us428ctls_sharedmem))) { + snd_printd( "%lu > %lu\n", size, (unsigned long)sizeof(struct us428ctls_sharedmem)); return -EINVAL; } if (!us428->us428ctls_sharedmem) { init_waitqueue_head(&us428->us428ctls_wait_queue_head); - if(!(us428->us428ctls_sharedmem = snd_malloc_pages(sizeof(us428ctls_sharedmem_t), GFP_KERNEL))) + if(!(us428->us428ctls_sharedmem = snd_malloc_pages(sizeof(struct us428ctls_sharedmem), GFP_KERNEL))) return -ENOMEM; - memset(us428->us428ctls_sharedmem, -1, sizeof(us428ctls_sharedmem_t)); + memset(us428->us428ctls_sharedmem, -1, sizeof(struct us428ctls_sharedmem)); us428->us428ctls_sharedmem->CtlSnapShotLast = -2; } area->vm_ops = &us428ctls_vm_ops; @@ -93,11 +93,11 @@ static int snd_us428ctls_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_are return 0; } -static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_table *wait) +static unsigned int snd_us428ctls_poll(struct snd_hwdep *hw, struct file *file, poll_table *wait) { unsigned int mask = 0; - usX2Ydev_t *us428 = hw->private_data; - us428ctls_sharedmem_t *shm = us428->us428ctls_sharedmem; + struct usX2Ydev *us428 = hw->private_data; + struct us428ctls_sharedmem *shm = us428->us428ctls_sharedmem; if (us428->chip_status & USX2Y_STAT_CHIP_HUP) return POLLHUP; @@ -110,24 +110,25 @@ static unsigned int snd_us428ctls_poll(snd_hwdep_t *hw, struct file *file, poll_ } -static int snd_usX2Y_hwdep_open(snd_hwdep_t *hw, struct file *file) +static int snd_usX2Y_hwdep_open(struct snd_hwdep *hw, struct file *file) { return 0; } -static int snd_usX2Y_hwdep_release(snd_hwdep_t *hw, struct file *file) +static int snd_usX2Y_hwdep_release(struct snd_hwdep *hw, struct file *file) { return 0; } -static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *info) +static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, + struct snd_hwdep_dsp_status *info) { static char *type_ids[USX2Y_TYPE_NUMS] = { [USX2Y_TYPE_122] = "us122", [USX2Y_TYPE_224] = "us224", [USX2Y_TYPE_428] = "us428", }; - usX2Ydev_t *us428 = hw->private_data; + struct usX2Ydev *us428 = hw->private_data; int id = -1; switch (le16_to_cpu(us428->chip.dev->descriptor.idProduct)) { @@ -145,35 +146,35 @@ static int snd_usX2Y_hwdep_dsp_status(snd_hwdep_t *hw, snd_hwdep_dsp_status_t *i return -ENODEV; strcpy(info->id, type_ids[id]); info->num_dsps = 2; // 0: Prepad Data, 1: FPGA Code - if (us428->chip_status & USX2Y_STAT_CHIP_INIT) + if (us428->chip_status & USX2Y_STAT_CHIP_INIT) info->chip_ready = 1; info->version = USX2Y_DRIVER_VERSION; return 0; } -static int usX2Y_create_usbmidi(snd_card_t* card ) +static int usX2Y_create_usbmidi(struct snd_card *card) { - static snd_usb_midi_endpoint_info_t quirk_data_1 = { - .out_ep =0x06, + static struct snd_usb_midi_endpoint_info quirk_data_1 = { + .out_ep = 0x06, .in_ep = 0x06, .out_cables = 0x001, .in_cables = 0x001 }; - static snd_usb_audio_quirk_t quirk_1 = { + static struct snd_usb_audio_quirk quirk_1 = { .vendor_name = "TASCAM", .product_name = NAME_ALLCAPS, .ifnum = 0, .type = QUIRK_MIDI_FIXED_ENDPOINT, .data = &quirk_data_1 }; - static snd_usb_midi_endpoint_info_t quirk_data_2 = { - .out_ep =0x06, + static struct snd_usb_midi_endpoint_info quirk_data_2 = { + .out_ep = 0x06, .in_ep = 0x06, .out_cables = 0x003, .in_cables = 0x003 }; - static snd_usb_audio_quirk_t quirk_2 = { + static struct snd_usb_audio_quirk quirk_2 = { .vendor_name = "TASCAM", .product_name = "US428", .ifnum = 0, @@ -182,13 +183,15 @@ static int usX2Y_create_usbmidi(snd_card_t* card ) }; struct usb_device *dev = usX2Y(card)->chip.dev; struct usb_interface *iface = usb_ifnum_to_if(dev, 0); - snd_usb_audio_quirk_t *quirk = le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? &quirk_2 : &quirk_1; + struct snd_usb_audio_quirk *quirk = + le16_to_cpu(dev->descriptor.idProduct) == USB_ID_US428 ? + &quirk_2 : &quirk_1; snd_printdd("usX2Y_create_usbmidi \n"); return snd_usb_create_midi_interface(&usX2Y(card)->chip, iface, quirk); } -static int usX2Y_create_alsa_devices(snd_card_t* card) +static int usX2Y_create_alsa_devices(struct snd_card *card) { int err; @@ -208,9 +211,10 @@ static int usX2Y_create_alsa_devices(snd_card_t* card) return err; } -static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) +static int snd_usX2Y_hwdep_dsp_load(struct snd_hwdep *hw, + struct snd_hwdep_dsp_image *dsp) { - usX2Ydev_t *priv = hw->private_data; + struct usX2Ydev *priv = hw->private_data; int lret, err = -EINVAL; snd_printdd( "dsp_load %s\n", dsp->name); @@ -257,10 +261,10 @@ static int snd_usX2Y_hwdep_dsp_load(snd_hwdep_t *hw, snd_hwdep_dsp_image_t *dsp) } -int usX2Y_hwdep_new(snd_card_t* card, struct usb_device* device) +int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device) { int err; - snd_hwdep_t *hw; + struct snd_hwdep *hw; if ((err = snd_hwdep_new(card, SND_USX2Y_LOADER_ID, 0, &hw)) < 0) return err; diff --git a/sound/usb/usx2y/usX2Yhwdep.h b/sound/usb/usx2y/usX2Yhwdep.h index d612a26..c095d5b 100644 --- a/sound/usb/usx2y/usX2Yhwdep.h +++ b/sound/usb/usx2y/usX2Yhwdep.h @@ -1,6 +1,6 @@ #ifndef USX2YHWDEP_H #define USX2YHWDEP_H -int usX2Y_hwdep_new(snd_card_t* card, struct usb_device* device); +int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device); #endif diff --git a/sound/usb/usx2y/usbus428ctldefs.h b/sound/usb/usx2y/usbus428ctldefs.h index 6af1643..b864e7e 100644 --- a/sound/usb/usx2y/usbus428ctldefs.h +++ b/sound/usb/usx2y/usbus428ctldefs.h @@ -51,7 +51,7 @@ enum E_In84{ #define T_NULL 0x80 -struct us428_ctls{ +struct us428_ctls { unsigned char Fader[9]; unsigned char Transport; unsigned char Modifier; @@ -63,46 +63,42 @@ struct us428_ctls{ unsigned char Wheel[5]; }; -typedef struct us428_ctls us428_ctls_t; - -typedef struct us428_setByte{ +struct us428_setByte { unsigned char Offset, Value; -}us428_setByte_t; +}; enum { eLT_Volume = 0, eLT_Light }; -typedef struct usX2Y_volume { +struct usX2Y_volume { unsigned char Channel, LH, LL, RH, RL; -} usX2Y_volume_t; +}; -struct us428_lights{ - us428_setByte_t Light[7]; +struct us428_lights { + struct us428_setByte Light[7]; }; -typedef struct us428_lights us428_lights_t; -typedef struct { +struct us428_p4out { char type; union { - usX2Y_volume_t vol; - us428_lights_t lights; + struct usX2Y_volume vol; + struct us428_lights lights; } val; -} us428_p4out_t; +}; #define N_us428_ctl_BUFS 16 #define N_us428_p4out_BUFS 16 struct us428ctls_sharedmem{ - us428_ctls_t CtlSnapShot[N_us428_ctl_BUFS]; - int CtlSnapShotDiffersAt[N_us428_ctl_BUFS]; - int CtlSnapShotLast, CtlSnapShotRed; - us428_p4out_t p4out[N_us428_p4out_BUFS]; - int p4outLast, p4outSent; + struct us428_ctls CtlSnapShot[N_us428_ctl_BUFS]; + int CtlSnapShotDiffersAt[N_us428_ctl_BUFS]; + int CtlSnapShotLast, CtlSnapShotRed; + struct us428_p4out p4out[N_us428_p4out_BUFS]; + int p4outLast, p4outSent; }; -typedef struct us428ctls_sharedmem us428ctls_sharedmem_t; diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 412c2e5..9807c3d 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -167,28 +167,28 @@ MODULE_PARM_DESC(enable, "Enable "NAME_ALLCAPS"."); static int snd_usX2Y_card_used[SNDRV_CARDS]; static void usX2Y_usb_disconnect(struct usb_device* usb_device, void* ptr); -static void snd_usX2Y_card_private_free(snd_card_t *card); +static void snd_usX2Y_card_private_free(struct snd_card *card); /* * pipe 4 is used for switching the lamps, setting samplerate, volumes .... */ -static void i_usX2Y_Out04Int(struct urb* urb, struct pt_regs *regs) +static void i_usX2Y_Out04Int(struct urb *urb, struct pt_regs *regs) { #ifdef CONFIG_SND_DEBUG if (urb->status) { int i; - usX2Ydev_t* usX2Y = urb->context; + struct usX2Ydev *usX2Y = urb->context; for (i = 0; i < 10 && usX2Y->AS04.urb[i] != urb; i++); snd_printdd("i_usX2Y_Out04Int() urb %i status=%i\n", i, urb->status); } #endif } -static void i_usX2Y_In04Int(struct urb* urb, struct pt_regs *regs) +static void i_usX2Y_In04Int(struct urb *urb, struct pt_regs *regs) { int err = 0; - usX2Ydev_t *usX2Y = urb->context; - us428ctls_sharedmem_t *us428ctls = usX2Y->us428ctls_sharedmem; + struct usX2Ydev *usX2Y = urb->context; + struct us428ctls_sharedmem *us428ctls = usX2Y->us428ctls_sharedmem; usX2Y->In04IntCalls++; @@ -239,10 +239,10 @@ static void i_usX2Y_In04Int(struct urb* urb, struct pt_regs *regs) send = 0; for (j = 0; j < URBS_AsyncSeq && !err; ++j) if (0 == usX2Y->AS04.urb[j]->status) { - us428_p4out_t *p4out = us428ctls->p4out + send; // FIXME if more then 1 p4out is new, 1 gets lost. + struct us428_p4out *p4out = us428ctls->p4out + send; // FIXME if more then 1 p4out is new, 1 gets lost. usb_fill_bulk_urb(usX2Y->AS04.urb[j], usX2Y->chip.dev, usb_sndbulkpipe(usX2Y->chip.dev, 0x04), &p4out->val.vol, - p4out->type == eLT_Light ? sizeof(us428_lights_t) : 5, + p4out->type == eLT_Light ? sizeof(struct us428_lights) : 5, i_usX2Y_Out04Int, usX2Y); err = usb_submit_urb(usX2Y->AS04.urb[j], GFP_ATOMIC); us428ctls->p4outSent = send; @@ -261,7 +261,7 @@ static void i_usX2Y_In04Int(struct urb* urb, struct pt_regs *regs) /* * Prepare some urbs */ -int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y) +int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y) { int err = 0, i; @@ -283,7 +283,7 @@ int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y) return err; } -int usX2Y_In04_init(usX2Ydev_t* usX2Y) +int usX2Y_In04_init(struct usX2Ydev *usX2Y) { if (! (usX2Y->In04urb = usb_alloc_urb(0, GFP_KERNEL))) return -ENOMEM; @@ -301,7 +301,7 @@ int usX2Y_In04_init(usX2Ydev_t* usX2Y) return usb_submit_urb(usX2Y->In04urb, GFP_KERNEL); } -static void usX2Y_unlinkSeq(snd_usX2Y_AsyncSeq_t* S) +static void usX2Y_unlinkSeq(struct snd_usX2Y_AsyncSeq *S) { int i; for (i = 0; i < URBS_AsyncSeq; ++i) { @@ -334,16 +334,16 @@ static struct usb_device_id snd_usX2Y_usb_id_table[] = { { /* terminator */ } }; -static snd_card_t* usX2Y_create_card(struct usb_device* device) +static struct snd_card *usX2Y_create_card(struct usb_device *device) { int dev; - snd_card_t* card; + struct snd_card * card; for (dev = 0; dev < SNDRV_CARDS; ++dev) if (enable[dev] && !snd_usX2Y_card_used[dev]) break; if (dev >= SNDRV_CARDS) return NULL; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(usX2Ydev_t)); + card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct usX2Ydev)); if (!card) return NULL; snd_usX2Y_card_used[usX2Y(card)->chip.index = dev] = 1; @@ -367,10 +367,10 @@ static snd_card_t* usX2Y_create_card(struct usb_device* device) } -static void* usX2Y_usb_probe(struct usb_device* device, struct usb_interface *intf, const struct usb_device_id* device_id) +static void *usX2Y_usb_probe(struct usb_device *device, struct usb_interface *intf, const struct usb_device_id *device_id) { int err; - snd_card_t* card; + struct snd_card * card; if (le16_to_cpu(device->descriptor.idVendor) != 0x1604 || (le16_to_cpu(device->descriptor.idProduct) != USB_ID_US122 && le16_to_cpu(device->descriptor.idProduct) != USB_ID_US224 && @@ -414,7 +414,7 @@ static struct usb_driver snd_usX2Y_usb_driver = { .id_table = snd_usX2Y_usb_id_table, }; -static void snd_usX2Y_card_private_free(snd_card_t *card) +static void snd_usX2Y_card_private_free(struct snd_card *card) { kfree(usX2Y(card)->In04Buf); usb_free_urb(usX2Y(card)->In04urb); @@ -427,11 +427,11 @@ static void snd_usX2Y_card_private_free(snd_card_t *card) /* * Frees the device. */ -static void usX2Y_usb_disconnect(struct usb_device* device, void* ptr) +static void usX2Y_usb_disconnect(struct usb_device *device, void* ptr) { if (ptr) { - snd_card_t *card = ptr; - usX2Ydev_t* usX2Y = usX2Y(card); + struct snd_card *card = ptr; + struct usX2Ydev *usX2Y = usX2Y(card); struct list_head *p; usX2Y->chip.shutdown = 1; usX2Y->chip_status = USX2Y_STAT_CHIP_HUP; diff --git a/sound/usb/usx2y/usbusx2y.h b/sound/usb/usx2y/usbusx2y.h index f65f3a7..435c1fe 100644 --- a/sound/usb/usx2y/usbusx2y.h +++ b/sound/usb/usx2y/usbusx2y.h @@ -8,47 +8,46 @@ #define URBS_AsyncSeq 10 #define URB_DataLen_AsyncSeq 32 -typedef struct { - struct urb* urb[URBS_AsyncSeq]; - char* buffer; -} snd_usX2Y_AsyncSeq_t; +struct snd_usX2Y_AsyncSeq { + struct urb *urb[URBS_AsyncSeq]; + char *buffer; +}; -typedef struct { +struct snd_usX2Y_urbSeq { int submitted; int len; - struct urb* urb[0]; -} snd_usX2Y_urbSeq_t; + struct urb *urb[0]; +}; -typedef struct snd_usX2Y_substream snd_usX2Y_substream_t; #include "usx2yhwdeppcm.h" -typedef struct { - snd_usb_audio_t chip; +struct usX2Ydev { + struct snd_usb_audio chip; int stride; struct urb *In04urb; void *In04Buf; char In04Last[24]; unsigned In04IntCalls; - snd_usX2Y_urbSeq_t *US04; + struct snd_usX2Y_urbSeq *US04; wait_queue_head_t In04WaitQueue; - snd_usX2Y_AsyncSeq_t AS04; + struct snd_usX2Y_AsyncSeq AS04; unsigned int rate, format; int chip_status; struct semaphore prepare_mutex; - us428ctls_sharedmem_t *us428ctls_sharedmem; + struct us428ctls_sharedmem *us428ctls_sharedmem; int wait_iso_frame; wait_queue_head_t us428ctls_wait_queue_head; - snd_usX2Y_hwdep_pcm_shm_t *hwdep_pcm_shm; - snd_usX2Y_substream_t *subs[4]; - snd_usX2Y_substream_t * volatile prepare_subs; + struct snd_usX2Y_hwdep_pcm_shm *hwdep_pcm_shm; + struct snd_usX2Y_substream *subs[4]; + struct snd_usX2Y_substream * volatile prepare_subs; wait_queue_head_t prepare_wait_queue; -} usX2Ydev_t; +}; struct snd_usX2Y_substream { - usX2Ydev_t *usX2Y; - snd_pcm_substream_t *pcm_substream; + struct usX2Ydev *usX2Y; + struct snd_pcm_substream *pcm_substream; int endpoint; unsigned int maxpacksize; /* max packet size in bytes */ @@ -72,12 +71,12 @@ struct snd_usX2Y_substream { }; -#define usX2Y(c) ((usX2Ydev_t*)(c)->private_data) +#define usX2Y(c) ((struct usX2Ydev *)(c)->private_data) -int usX2Y_audio_create(snd_card_t* card); +int usX2Y_audio_create(struct snd_card *card); -int usX2Y_AsyncSeq04_init(usX2Ydev_t* usX2Y); -int usX2Y_In04_init(usX2Ydev_t* usX2Y); +int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y); +int usX2Y_In04_init(struct usX2Ydev *usX2Y); #define NAME_ALLCAPS "US-X2Y" diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index e1dbfbb..a6bbc7a 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -67,18 +67,20 @@ #endif -static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) +static int usX2Y_urb_capt_retire(struct snd_usX2Y_substream *subs) { struct urb *urb = subs->completed_urb; - snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; + struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; unsigned char *cp; int i, len, lens = 0, hwptr_done = subs->hwptr_done; - usX2Ydev_t *usX2Y = subs->usX2Y; + struct usX2Ydev *usX2Y = subs->usX2Y; for (i = 0; i < nr_of_packs(); i++) { cp = (unsigned char*)urb->transfer_buffer + urb->iso_frame_desc[i].offset; if (urb->iso_frame_desc[i].status) { /* active? hmm, skip this */ - snd_printk(KERN_ERR "activ frame status %i. Most propably some hardware problem.\n", urb->iso_frame_desc[i].status); + snd_printk(KERN_ERR "active frame status %i. " + "Most propably some hardware problem.\n", + urb->iso_frame_desc[i].status); return urb->iso_frame_desc[i].status; } len = urb->iso_frame_desc[i].actual_length / usX2Y->stride; @@ -94,7 +96,8 @@ static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, blen); memcpy(runtime->dma_area, cp + blen, len * usX2Y->stride - blen); } else { - memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, len * usX2Y->stride); + memcpy(runtime->dma_area + hwptr_done * usX2Y->stride, cp, + len * usX2Y->stride); } lens += len; if ((hwptr_done += len) >= runtime->buffer_size) @@ -120,13 +123,13 @@ static int usX2Y_urb_capt_retire(snd_usX2Y_substream_t *subs) * it directly from the buffer. thus the data is once copied to * a temporary buffer and urb points to that. */ -static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, +static int usX2Y_urb_play_prepare(struct snd_usX2Y_substream *subs, struct urb *cap_urb, struct urb *urb) { int count, counts, pack; - usX2Ydev_t* usX2Y = subs->usX2Y; - snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; + struct usX2Ydev *usX2Y = subs->usX2Y; + struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; count = 0; for (pack = 0; pack < nr_of_packs(); pack++) { @@ -139,7 +142,8 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, } /* set up descriptor */ urb->iso_frame_desc[pack].offset = pack ? - urb->iso_frame_desc[pack - 1].offset + urb->iso_frame_desc[pack - 1].length : + urb->iso_frame_desc[pack - 1].offset + + urb->iso_frame_desc[pack - 1].length : 0; urb->iso_frame_desc[pack].length = cap_urb->iso_frame_desc[pack].actual_length; } @@ -151,8 +155,10 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, int len; len = runtime->buffer_size - subs->hwptr; urb->transfer_buffer = subs->tmpbuf; - memcpy(subs->tmpbuf, runtime->dma_area + subs->hwptr * usX2Y->stride, len * usX2Y->stride); - memcpy(subs->tmpbuf + len * usX2Y->stride, runtime->dma_area, (count - len) * usX2Y->stride); + memcpy(subs->tmpbuf, runtime->dma_area + + subs->hwptr * usX2Y->stride, len * usX2Y->stride); + memcpy(subs->tmpbuf + len * usX2Y->stride, + runtime->dma_area, (count - len) * usX2Y->stride); subs->hwptr += count; subs->hwptr -= runtime->buffer_size; } else { @@ -172,9 +178,9 @@ static int usX2Y_urb_play_prepare(snd_usX2Y_substream_t *subs, * * update the current position and call callback if a period is processed. */ -static void usX2Y_urb_play_retire(snd_usX2Y_substream_t *subs, struct urb *urb) +static void usX2Y_urb_play_retire(struct snd_usX2Y_substream *subs, struct urb *urb) { - snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; + struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; int len = urb->actual_length / subs->usX2Y->stride; subs->transfer_done += len; @@ -187,7 +193,7 @@ static void usX2Y_urb_play_retire(snd_usX2Y_substream_t *subs, struct urb *urb) } } -static int usX2Y_urb_submit(snd_usX2Y_substream_t *subs, struct urb *urb, int frame) +static int usX2Y_urb_submit(struct snd_usX2Y_substream *subs, struct urb *urb, int frame) { int err; if (!urb) @@ -202,7 +208,9 @@ static int usX2Y_urb_submit(snd_usX2Y_substream_t *subs, struct urb *urb, int fr return 0; } -static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_usX2Y_substream_t *playbacksubs, int frame) +static inline int usX2Y_usbframe_complete(struct snd_usX2Y_substream *capsubs, + struct snd_usX2Y_substream *playbacksubs, + int frame) { int err, state; struct urb *urb = playbacksubs->completed_urb; @@ -211,9 +219,8 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us if (NULL != urb) { if (state == state_RUNNING) usX2Y_urb_play_retire(playbacksubs, urb); - else - if (state >= state_PRERUNNING) - atomic_inc(&playbacksubs->state); + else if (state >= state_PRERUNNING) + atomic_inc(&playbacksubs->state); } else { switch (state) { case state_STARTING1: @@ -228,8 +235,9 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us } if (urb) { if ((err = usX2Y_urb_play_prepare(playbacksubs, capsubs->completed_urb, urb)) || - (err = usX2Y_urb_submit(playbacksubs, urb, frame))) + (err = usX2Y_urb_submit(playbacksubs, urb, frame))) { return err; + } } playbacksubs->completed_urb = NULL; @@ -249,18 +257,19 @@ static inline int usX2Y_usbframe_complete(snd_usX2Y_substream_t *capsubs, snd_us } -static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) +static void usX2Y_clients_stop(struct usX2Ydev *usX2Y) { int s, u; + for (s = 0; s < 4; s++) { - snd_usX2Y_substream_t *subs = usX2Y->subs[s]; + struct snd_usX2Y_substream *subs = usX2Y->subs[s]; if (subs) { snd_printdd("%i %p state=%i\n", s, subs, atomic_read(&subs->state)); atomic_set(&subs->state, state_STOPPED); } } for (s = 0; s < 4; s++) { - snd_usX2Y_substream_t *subs = usX2Y->subs[s]; + struct snd_usX2Y_substream *subs = usX2Y->subs[s]; if (subs) { if (atomic_read(&subs->state) >= state_PRERUNNING) { snd_pcm_stop(subs->pcm_substream, SNDRV_PCM_STATE_XRUN); @@ -268,7 +277,8 @@ static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) for (u = 0; u < NRURBS; u++) { struct urb *urb = subs->urb[u]; if (NULL != urb) - snd_printdd("%i status=%i start_frame=%i\n", u, urb->status, urb->start_frame); + snd_printdd("%i status=%i start_frame=%i\n", + u, urb->status, urb->start_frame); } } } @@ -276,30 +286,36 @@ static void usX2Y_clients_stop(usX2Ydev_t *usX2Y) wake_up(&usX2Y->prepare_wait_queue); } -static void usX2Y_error_urb_status(usX2Ydev_t *usX2Y, snd_usX2Y_substream_t *subs, struct urb *urb) +static void usX2Y_error_urb_status(struct usX2Ydev *usX2Y, + struct snd_usX2Y_substream *subs, struct urb *urb) { snd_printk(KERN_ERR "ep=%i stalled with status=%i\n", subs->endpoint, urb->status); urb->status = 0; usX2Y_clients_stop(usX2Y); } -static void usX2Y_error_sequence(usX2Ydev_t *usX2Y, snd_usX2Y_substream_t *subs, struct urb *urb) +static void usX2Y_error_sequence(struct usX2Ydev *usX2Y, + struct snd_usX2Y_substream *subs, struct urb *urb) { snd_printk(KERN_ERR "Sequence Error!(hcd_frame=%i ep=%i%s;wait=%i,frame=%i).\n" KERN_ERR "Most propably some urb of usb-frame %i is still missing.\n" KERN_ERR "Cause could be too long delays in usb-hcd interrupt handling.\n", usb_get_current_frame_number(usX2Y->chip.dev), - subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); + subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", + usX2Y->wait_iso_frame, urb->start_frame, usX2Y->wait_iso_frame); usX2Y_clients_stop(usX2Y); } static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) { - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; - usX2Ydev_t *usX2Y = subs->usX2Y; + struct snd_usX2Y_substream *subs = urb->context; + struct usX2Ydev *usX2Y = subs->usX2Y; if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { - snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", usb_get_current_frame_number(usX2Y->chip.dev), subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", urb->status, urb->start_frame); + snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", + usb_get_current_frame_number(usX2Y->chip.dev), + subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", + urb->status, urb->start_frame); return; } if (unlikely(urb->status)) { @@ -313,10 +329,12 @@ static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) return; } { - snd_usX2Y_substream_t *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE], + struct snd_usX2Y_substream *capsubs = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE], *playbacksubs = usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; - if (capsubs->completed_urb && atomic_read(&capsubs->state) >= state_PREPARED && - (playbacksubs->completed_urb || atomic_read(&playbacksubs->state) < state_PREPARED)) { + if (capsubs->completed_urb && + atomic_read(&capsubs->state) >= state_PREPARED && + (playbacksubs->completed_urb || + atomic_read(&playbacksubs->state) < state_PREPARED)) { if (!usX2Y_usbframe_complete(capsubs, playbacksubs, urb->start_frame)) { if (nr_of_packs() <= urb->start_frame && urb->start_frame <= (2 * nr_of_packs() - 1)) // uhci and ohci @@ -331,11 +349,12 @@ static void i_usX2Y_urb_complete(struct urb *urb, struct pt_regs *regs) } } -static void usX2Y_urbs_set_complete(usX2Ydev_t * usX2Y, void (*complete)(struct urb *, struct pt_regs *)) +static void usX2Y_urbs_set_complete(struct usX2Ydev * usX2Y, + void (*complete)(struct urb *, struct pt_regs *)) { int s, u; for (s = 0; s < 4; s++) { - snd_usX2Y_substream_t *subs = usX2Y->subs[s]; + struct snd_usX2Y_substream *subs = usX2Y->subs[s]; if (NULL != subs) for (u = 0; u < NRURBS; u++) { struct urb * urb = subs->urb[u]; @@ -345,7 +364,7 @@ static void usX2Y_urbs_set_complete(usX2Ydev_t * usX2Y, void (*complete)(struct } } -static void usX2Y_subs_startup_finish(usX2Ydev_t * usX2Y) +static void usX2Y_subs_startup_finish(struct usX2Ydev * usX2Y) { usX2Y_urbs_set_complete(usX2Y, i_usX2Y_urb_complete); usX2Y->prepare_subs = NULL; @@ -353,9 +372,9 @@ static void usX2Y_subs_startup_finish(usX2Ydev_t * usX2Y) static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) { - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; - usX2Ydev_t *usX2Y = subs->usX2Y; - snd_usX2Y_substream_t *prepare_subs = usX2Y->prepare_subs; + struct snd_usX2Y_substream *subs = urb->context; + struct usX2Ydev *usX2Y = subs->usX2Y; + struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs; if (NULL != prepare_subs) if (urb->start_frame == prepare_subs->urb[0]->start_frame) { usX2Y_subs_startup_finish(usX2Y); @@ -366,9 +385,10 @@ static void i_usX2Y_subs_startup(struct urb *urb, struct pt_regs *regs) i_usX2Y_urb_complete(urb, regs); } -static void usX2Y_subs_prepare(snd_usX2Y_substream_t *subs) +static void usX2Y_subs_prepare(struct snd_usX2Y_substream *subs) { - snd_printdd("usX2Y_substream_prepare(%p) ep=%i urb0=%p urb1=%p\n", subs, subs->endpoint, subs->urb[0], subs->urb[1]); + snd_printdd("usX2Y_substream_prepare(%p) ep=%i urb0=%p urb1=%p\n", + subs, subs->endpoint, subs->urb[0], subs->urb[1]); /* reset the pointer */ subs->hwptr = 0; subs->hwptr_done = 0; @@ -376,7 +396,7 @@ static void usX2Y_subs_prepare(snd_usX2Y_substream_t *subs) } -static void usX2Y_urb_release(struct urb** urb, int free_tb) +static void usX2Y_urb_release(struct urb **urb, int free_tb) { if (*urb) { usb_kill_urb(*urb); @@ -389,12 +409,13 @@ static void usX2Y_urb_release(struct urb** urb, int free_tb) /* * release a substreams urbs */ -static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs) +static void usX2Y_urbs_release(struct snd_usX2Y_substream *subs) { int i; snd_printdd("usX2Y_urbs_release() %i\n", subs->endpoint); for (i = 0; i < NRURBS; i++) - usX2Y_urb_release(subs->urb + i, subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); + usX2Y_urb_release(subs->urb + i, + subs != subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]); kfree(subs->tmpbuf); subs->tmpbuf = NULL; @@ -402,7 +423,7 @@ static void usX2Y_urbs_release(snd_usX2Y_substream_t *subs) /* * initialize a substream's urbs */ -static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) +static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) { int i; unsigned int pipe; @@ -452,25 +473,25 @@ static int usX2Y_urbs_allocate(snd_usX2Y_substream_t *subs) return 0; } -static void usX2Y_subs_startup(snd_usX2Y_substream_t *subs) +static void usX2Y_subs_startup(struct snd_usX2Y_substream *subs) { - usX2Ydev_t *usX2Y = subs->usX2Y; + struct usX2Ydev *usX2Y = subs->usX2Y; usX2Y->prepare_subs = subs; subs->urb[0]->start_frame = -1; wmb(); usX2Y_urbs_set_complete(usX2Y, i_usX2Y_subs_startup); } -static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs) +static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs) { int i, err; - usX2Ydev_t *usX2Y = subs->usX2Y; + struct usX2Ydev *usX2Y = subs->usX2Y; if ((err = usX2Y_urbs_allocate(subs)) < 0) return err; subs->completed_urb = NULL; for (i = 0; i < 4; i++) { - snd_usX2Y_substream_t *subs = usX2Y->subs[i]; + struct snd_usX2Y_substream *subs = usX2Y->subs[i]; if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) goto start; } @@ -521,17 +542,17 @@ static int usX2Y_urbs_start(snd_usX2Y_substream_t *subs) /* * return the current pcm pointer. just return the hwptr_done value. */ -static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_usX2Y_pcm_pointer(struct snd_pcm_substream *substream) { - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)substream->runtime->private_data; + struct snd_usX2Y_substream *subs = substream->runtime->private_data; return subs->hwptr_done; } /* * start/stop substream */ -static int snd_usX2Y_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_usX2Y_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)substream->runtime->private_data; + struct snd_usX2Y_substream *subs = substream->runtime->private_data; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -642,9 +663,9 @@ static struct s_c2 SetRate48000[] = }; #define NOOF_SETRATE_URBS ARRAY_SIZE(SetRate48000) -static void i_usX2Y_04Int(struct urb* urb, struct pt_regs *regs) +static void i_usX2Y_04Int(struct urb *urb, struct pt_regs *regs) { - usX2Ydev_t* usX2Y = urb->context; + struct usX2Ydev *usX2Y = urb->context; if (urb->status) snd_printk(KERN_ERR "snd_usX2Y_04Int() urb->status=%i\n", urb->status); @@ -652,10 +673,10 @@ static void i_usX2Y_04Int(struct urb* urb, struct pt_regs *regs) wake_up(&usX2Y->In04WaitQueue); } -static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) +static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate) { int err = 0, i; - snd_usX2Y_urbSeq_t *us = NULL; + struct snd_usX2Y_urbSeq *us = NULL; int *usbdata = NULL; struct s_c2 *ra = rate == 48000 ? SetRate48000 : SetRate44100; @@ -714,7 +735,7 @@ static int usX2Y_rate_set(usX2Ydev_t *usX2Y, int rate) } -static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format) +static int usX2Y_format_set(struct usX2Ydev *usX2Y, snd_pcm_format_t format) { int alternate, err; struct list_head* p; @@ -744,27 +765,27 @@ static int usX2Y_format_set(usX2Ydev_t *usX2Y, snd_pcm_format_t format) } -static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_usX2Y_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { int err = 0; unsigned int rate = params_rate(hw_params); snd_pcm_format_t format = params_format(hw_params); - snd_card_t *card = substream->pstr->pcm->card; - struct list_head *list; + struct snd_card *card = substream->pstr->pcm->card; + struct list_head *list; snd_printdd("snd_usX2Y_hw_params(%p, %p)\n", substream, hw_params); // all pcm substreams off one usX2Y have to operate at the same rate & format list_for_each(list, &card->devices) { - snd_device_t *dev; - snd_pcm_t *pcm; + struct snd_device *dev; + struct snd_pcm *pcm; int s; dev = snd_device(list); if (dev->type != SNDRV_DEV_PCM) continue; pcm = dev->device_data; for (s = 0; s < 2; ++s) { - snd_pcm_substream_t *test_substream; + struct snd_pcm_substream *test_substream; test_substream = pcm->streams[s].substream; if (test_substream && test_substream != substream && test_substream->runtime && @@ -776,7 +797,8 @@ static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, } } if (0 > (err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)))) { - snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n", substream, params_buffer_bytes(hw_params), err); + snd_printk(KERN_ERR "snd_pcm_lib_malloc_pages(%p, %i) returned %i\n", + substream, params_buffer_bytes(hw_params), err); return err; } return 0; @@ -785,15 +807,15 @@ static int snd_usX2Y_pcm_hw_params(snd_pcm_substream_t *substream, /* * free the buffer */ -static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) +static int snd_usX2Y_pcm_hw_free(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_usX2Y_substream *subs = runtime->private_data; down(&subs->usX2Y->prepare_mutex); snd_printdd("snd_usX2Y_hw_free(%p)\n", substream); if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { - snd_usX2Y_substream_t *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; + struct snd_usX2Y_substream *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; atomic_set(&subs->state, state_STOPPED); usX2Y_urbs_release(subs); if (!cap_subs->pcm_substream || @@ -804,7 +826,7 @@ static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) usX2Y_urbs_release(cap_subs); } } else { - snd_usX2Y_substream_t *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; + struct snd_usX2Y_substream *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; if (atomic_read(&playback_subs->state) < state_PREPARED) { atomic_set(&subs->state, state_STOPPED); usX2Y_urbs_release(subs); @@ -818,12 +840,12 @@ static int snd_usX2Y_pcm_hw_free(snd_pcm_substream_t *substream) * * set format and initialize urbs */ -static int snd_usX2Y_pcm_prepare(snd_pcm_substream_t *substream) +static int snd_usX2Y_pcm_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; - usX2Ydev_t *usX2Y = subs->usX2Y; - snd_usX2Y_substream_t *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_usX2Y_substream *subs = runtime->private_data; + struct usX2Ydev *usX2Y = subs->usX2Y; + struct snd_usX2Y_substream *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; int err = 0; snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); @@ -851,7 +873,7 @@ static int snd_usX2Y_pcm_prepare(snd_pcm_substream_t *substream) return err; } -static snd_pcm_hardware_t snd_usX2Y_2c = +static struct snd_pcm_hardware snd_usX2Y_2c = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -872,11 +894,11 @@ static snd_pcm_hardware_t snd_usX2Y_2c = -static int snd_usX2Y_pcm_open(snd_pcm_substream_t *substream) +static int snd_usX2Y_pcm_open(struct snd_pcm_substream *substream) { - snd_usX2Y_substream_t *subs = ((snd_usX2Y_substream_t **) + struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **) snd_pcm_substream_chip(substream))[substream->stream]; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS) return -EBUSY; @@ -890,19 +912,18 @@ static int snd_usX2Y_pcm_open(snd_pcm_substream_t *substream) -static int snd_usX2Y_pcm_close(snd_pcm_substream_t *substream) +static int snd_usX2Y_pcm_close(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; - int err = 0; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_usX2Y_substream *subs = runtime->private_data; subs->pcm_substream = NULL; - return err; + return 0; } -static snd_pcm_ops_t snd_usX2Y_pcm_ops = +static struct snd_pcm_ops snd_usX2Y_pcm_ops = { .open = snd_usX2Y_pcm_open, .close = snd_usX2Y_pcm_close, @@ -918,7 +939,7 @@ static snd_pcm_ops_t snd_usX2Y_pcm_ops = /* * free a usb stream instance */ -static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream) +static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream) { if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) { kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]); @@ -928,23 +949,23 @@ static void usX2Y_audio_stream_free(snd_usX2Y_substream_t **usX2Y_substream) usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL; } -static void snd_usX2Y_pcm_private_free(snd_pcm_t *pcm) +static void snd_usX2Y_pcm_private_free(struct snd_pcm *pcm) { - snd_usX2Y_substream_t **usX2Y_stream = pcm->private_data; + struct snd_usX2Y_substream **usX2Y_stream = pcm->private_data; if (usX2Y_stream) usX2Y_audio_stream_free(usX2Y_stream); } -static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int capture_endpoint) +static int usX2Y_audio_stream_new(struct snd_card *card, int playback_endpoint, int capture_endpoint) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err, i; - snd_usX2Y_substream_t **usX2Y_substream = + struct snd_usX2Y_substream **usX2Y_substream = usX2Y(card)->subs + 2 * usX2Y(card)->chip.pcm_devs; for (i = playback_endpoint ? SNDRV_PCM_STREAM_PLAYBACK : SNDRV_PCM_STREAM_CAPTURE; i <= SNDRV_PCM_STREAM_CAPTURE; ++i) { - usX2Y_substream[i] = kzalloc(sizeof(snd_usX2Y_substream_t), GFP_KERNEL); + usX2Y_substream[i] = kzalloc(sizeof(struct snd_usX2Y_substream), GFP_KERNEL); if (NULL == usX2Y_substream[i]) { snd_printk(KERN_ERR "cannot malloc\n"); return -ENOMEM; @@ -994,7 +1015,7 @@ static int usX2Y_audio_stream_new(snd_card_t *card, int playback_endpoint, int c /* * create a chip instance and set its names. */ -int usX2Y_audio_create(snd_card_t* card) +int usX2Y_audio_create(struct snd_card *card) { int err = 0; diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c index c5379280..796a7dce 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.c +++ b/sound/usb/usx2y/usx2yhwdeppcm.c @@ -58,12 +58,12 @@ #include <sound/hwdep.h> -static int usX2Y_usbpcm_urb_capt_retire(snd_usX2Y_substream_t *subs) +static int usX2Y_usbpcm_urb_capt_retire(struct snd_usX2Y_substream *subs) { struct urb *urb = subs->completed_urb; - snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; + struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; int i, lens = 0, hwptr_done = subs->hwptr_done; - usX2Ydev_t *usX2Y = subs->usX2Y; + struct usX2Ydev *usX2Y = subs->usX2Y; if (0 > usX2Y->hwdep_pcm_shm->capture_iso_start) { //FIXME int head = usX2Y->hwdep_pcm_shm->captured_iso_head + 1; if (head >= ARRAY_SIZE(usX2Y->hwdep_pcm_shm->captured_iso)) @@ -90,7 +90,8 @@ static int usX2Y_usbpcm_urb_capt_retire(snd_usX2Y_substream_t *subs) return 0; } -static inline int usX2Y_iso_frames_per_buffer(snd_pcm_runtime_t *runtime, usX2Ydev_t * usX2Y) +static inline int usX2Y_iso_frames_per_buffer(struct snd_pcm_runtime *runtime, + struct usX2Ydev * usX2Y) { return (runtime->buffer_size * 1000) / usX2Y->rate + 1; //FIXME: so far only correct period_size == 2^x ? } @@ -105,13 +106,13 @@ static inline int usX2Y_iso_frames_per_buffer(snd_pcm_runtime_t *runtime, usX2Yd * it directly from the buffer. thus the data is once copied to * a temporary buffer and urb points to that. */ -static int usX2Y_hwdep_urb_play_prepare(snd_usX2Y_substream_t *subs, - struct urb *urb) +static int usX2Y_hwdep_urb_play_prepare(struct snd_usX2Y_substream *subs, + struct urb *urb) { int count, counts, pack; - usX2Ydev_t *usX2Y = subs->usX2Y; + struct usX2Ydev *usX2Y = subs->usX2Y; struct snd_usX2Y_hwdep_pcm_shm *shm = usX2Y->hwdep_pcm_shm; - snd_pcm_runtime_t *runtime = subs->pcm_substream->runtime; + struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime; if (0 > shm->playback_iso_start) { shm->playback_iso_start = shm->captured_iso_head - @@ -144,13 +145,14 @@ static int usX2Y_hwdep_urb_play_prepare(snd_usX2Y_substream_t *subs, } -static inline void usX2Y_usbpcm_urb_capt_iso_advance(snd_usX2Y_substream_t *subs, struct urb *urb) +static inline void usX2Y_usbpcm_urb_capt_iso_advance(struct snd_usX2Y_substream *subs, + struct urb *urb) { int pack; for (pack = 0; pack < nr_of_packs(); ++pack) { struct usb_iso_packet_descriptor *desc = urb->iso_frame_desc + pack; if (NULL != subs) { - snd_usX2Y_hwdep_pcm_shm_t *shm = subs->usX2Y->hwdep_pcm_shm; + struct snd_usX2Y_hwdep_pcm_shm *shm = subs->usX2Y->hwdep_pcm_shm; int head = shm->captured_iso_head + 1; if (head >= ARRAY_SIZE(shm->captured_iso)) head = 0; @@ -166,9 +168,10 @@ static inline void usX2Y_usbpcm_urb_capt_iso_advance(snd_usX2Y_substream_t *subs } } -static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, - snd_usX2Y_substream_t *capsubs2, - snd_usX2Y_substream_t *playbacksubs, int frame) +static inline int usX2Y_usbpcm_usbframe_complete(struct snd_usX2Y_substream *capsubs, + struct snd_usX2Y_substream *capsubs2, + struct snd_usX2Y_substream *playbacksubs, + int frame) { int err, state; struct urb *urb = playbacksubs->completed_urb; @@ -225,12 +228,15 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs, static void i_usX2Y_usbpcm_urb_complete(struct urb *urb, struct pt_regs *regs) { - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; - usX2Ydev_t *usX2Y = subs->usX2Y; - snd_usX2Y_substream_t *capsubs, *capsubs2, *playbacksubs; + struct snd_usX2Y_substream *subs = urb->context; + struct usX2Ydev *usX2Y = subs->usX2Y; + struct snd_usX2Y_substream *capsubs, *capsubs2, *playbacksubs; if (unlikely(atomic_read(&subs->state) < state_PREPARED)) { - snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", usb_get_current_frame_number(usX2Y->chip.dev), subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", urb->status, urb->start_frame); + snd_printdd("hcd_frame=%i ep=%i%s status=%i start_frame=%i\n", + usb_get_current_frame_number(usX2Y->chip.dev), + subs->endpoint, usb_pipein(urb->pipe) ? "in" : "out", + urb->status, urb->start_frame); return; } if (unlikely(urb->status)) { @@ -264,7 +270,7 @@ static void i_usX2Y_usbpcm_urb_complete(struct urb *urb, struct pt_regs *regs) } -static void usX2Y_hwdep_urb_release(struct urb** urb) +static void usX2Y_hwdep_urb_release(struct urb **urb) { usb_kill_urb(*urb); usb_free_urb(*urb); @@ -274,7 +280,7 @@ static void usX2Y_hwdep_urb_release(struct urb** urb) /* * release a substream */ -static void usX2Y_usbpcm_urbs_release(snd_usX2Y_substream_t *subs) +static void usX2Y_usbpcm_urbs_release(struct snd_usX2Y_substream *subs) { int i; snd_printdd("snd_usX2Y_urbs_release() %i\n", subs->endpoint); @@ -282,7 +288,7 @@ static void usX2Y_usbpcm_urbs_release(snd_usX2Y_substream_t *subs) usX2Y_hwdep_urb_release(subs->urb + i); } -static void usX2Y_usbpcm_subs_startup_finish(usX2Ydev_t * usX2Y) +static void usX2Y_usbpcm_subs_startup_finish(struct usX2Ydev * usX2Y) { usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_urb_complete); usX2Y->prepare_subs = NULL; @@ -290,14 +296,14 @@ static void usX2Y_usbpcm_subs_startup_finish(usX2Ydev_t * usX2Y) static void i_usX2Y_usbpcm_subs_startup(struct urb *urb, struct pt_regs *regs) { - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t*)urb->context; - usX2Ydev_t *usX2Y = subs->usX2Y; - snd_usX2Y_substream_t *prepare_subs = usX2Y->prepare_subs; + struct snd_usX2Y_substream *subs = urb->context; + struct usX2Ydev *usX2Y = subs->usX2Y; + struct snd_usX2Y_substream *prepare_subs = usX2Y->prepare_subs; if (NULL != prepare_subs && urb->start_frame == prepare_subs->urb[0]->start_frame) { atomic_inc(&prepare_subs->state); if (prepare_subs == usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]) { - snd_usX2Y_substream_t *cap_subs2 = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; + struct snd_usX2Y_substream *cap_subs2 = usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; if (cap_subs2 != NULL) atomic_inc(&cap_subs2->state); } @@ -311,7 +317,7 @@ static void i_usX2Y_usbpcm_subs_startup(struct urb *urb, struct pt_regs *regs) /* * initialize a substream's urbs */ -static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs) +static int usX2Y_usbpcm_urbs_allocate(struct snd_usX2Y_substream *subs) { int i; unsigned int pipe; @@ -355,16 +361,16 @@ static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs) /* * free the buffer */ -static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream) +static int snd_usX2Y_usbpcm_hw_free(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data, + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_usX2Y_substream *subs = runtime->private_data, *cap_subs2 = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE + 2]; down(&subs->usX2Y->prepare_mutex); snd_printdd("snd_usX2Y_usbpcm_hw_free(%p)\n", substream); if (SNDRV_PCM_STREAM_PLAYBACK == substream->stream) { - snd_usX2Y_substream_t *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; + struct snd_usX2Y_substream *cap_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; atomic_set(&subs->state, state_STOPPED); usX2Y_usbpcm_urbs_release(subs); if (!cap_subs->pcm_substream || @@ -379,7 +385,7 @@ static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream) usX2Y_usbpcm_urbs_release(cap_subs2); } } else { - snd_usX2Y_substream_t *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; + struct snd_usX2Y_substream *playback_subs = subs->usX2Y->subs[SNDRV_PCM_STREAM_PLAYBACK]; if (atomic_read(&playback_subs->state) < state_PREPARED) { atomic_set(&subs->state, state_STOPPED); if (NULL != cap_subs2) @@ -393,20 +399,20 @@ static int snd_usX2Y_usbpcm_hw_free(snd_pcm_substream_t *substream) return snd_pcm_lib_free_pages(substream); } -static void usX2Y_usbpcm_subs_startup(snd_usX2Y_substream_t *subs) +static void usX2Y_usbpcm_subs_startup(struct snd_usX2Y_substream *subs) { - usX2Ydev_t * usX2Y = subs->usX2Y; + struct usX2Ydev * usX2Y = subs->usX2Y; usX2Y->prepare_subs = subs; subs->urb[0]->start_frame = -1; smp_wmb(); // Make shure above modifications are seen by i_usX2Y_subs_startup() usX2Y_urbs_set_complete(usX2Y, i_usX2Y_usbpcm_subs_startup); } -static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) +static int usX2Y_usbpcm_urbs_start(struct snd_usX2Y_substream *subs) { int p, u, err, stream = subs->pcm_substream->stream; - usX2Ydev_t *usX2Y = subs->usX2Y; + struct usX2Ydev *usX2Y = subs->usX2Y; if (SNDRV_PCM_STREAM_CAPTURE == stream) { usX2Y->hwdep_pcm_shm->captured_iso_head = -1; @@ -414,7 +420,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) } for (p = 0; 3 >= (stream + p); p += 2) { - snd_usX2Y_substream_t *subs = usX2Y->subs[stream + p]; + struct snd_usX2Y_substream *subs = usX2Y->subs[stream + p]; if (subs != NULL) { if ((err = usX2Y_usbpcm_urbs_allocate(subs)) < 0) return err; @@ -423,7 +429,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) } for (p = 0; p < 4; p++) { - snd_usX2Y_substream_t *subs = usX2Y->subs[p]; + struct snd_usX2Y_substream *subs = usX2Y->subs[p]; if (subs != NULL && atomic_read(&subs->state) >= state_PREPARED) goto start; } @@ -433,7 +439,7 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) usX2Y_usbpcm_subs_startup(subs); for (u = 0; u < NRURBS; u++) { for (p = 0; 3 >= (stream + p); p += 2) { - snd_usX2Y_substream_t *subs = usX2Y->subs[stream + p]; + struct snd_usX2Y_substream *subs = usX2Y->subs[stream + p]; if (subs != NULL) { struct urb *urb = subs->urb[u]; if (usb_pipein(urb->pipe)) { @@ -482,19 +488,19 @@ static int usX2Y_usbpcm_urbs_start(snd_usX2Y_substream_t *subs) * * set format and initialize urbs */ -static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) +static int snd_usX2Y_usbpcm_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; - usX2Ydev_t *usX2Y = subs->usX2Y; - snd_usX2Y_substream_t *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_usX2Y_substream *subs = runtime->private_data; + struct usX2Ydev *usX2Y = subs->usX2Y; + struct snd_usX2Y_substream *capsubs = subs->usX2Y->subs[SNDRV_PCM_STREAM_CAPTURE]; int err = 0; snd_printdd("snd_usX2Y_pcm_prepare(%p)\n", substream); if (NULL == usX2Y->hwdep_pcm_shm) { - if (NULL == (usX2Y->hwdep_pcm_shm = snd_malloc_pages(sizeof(snd_usX2Y_hwdep_pcm_shm_t), GFP_KERNEL))) + if (NULL == (usX2Y->hwdep_pcm_shm = snd_malloc_pages(sizeof(struct snd_usX2Y_hwdep_pcm_shm), GFP_KERNEL))) return -ENOMEM; - memset(usX2Y->hwdep_pcm_shm, 0, sizeof(snd_usX2Y_hwdep_pcm_shm_t)); + memset(usX2Y->hwdep_pcm_shm, 0, sizeof(struct snd_usX2Y_hwdep_pcm_shm)); } down(&usX2Y->prepare_mutex); @@ -508,7 +514,8 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) if (usX2Y->rate != runtime->rate) if ((err = usX2Y_rate_set(usX2Y, runtime->rate)) < 0) goto up_prepare_mutex; - snd_printdd("starting capture pipe for %s\n", subs == capsubs ? "self" : "playpipe"); + snd_printdd("starting capture pipe for %s\n", subs == capsubs ? + "self" : "playpipe"); if (0 > (err = usX2Y_usbpcm_urbs_start(capsubs))) goto up_prepare_mutex; } @@ -516,8 +523,12 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) if (subs != capsubs) { usX2Y->hwdep_pcm_shm->playback_iso_start = -1; if (atomic_read(&subs->state) < state_PREPARED) { - while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > usX2Y->hwdep_pcm_shm->captured_iso_frames) { - snd_printd("Wait: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames); + while (usX2Y_iso_frames_per_buffer(runtime, usX2Y) > + usX2Y->hwdep_pcm_shm->captured_iso_frames) { + snd_printdd("Wait: iso_frames_per_buffer=%i," + "captured_iso_frames=%i\n", + usX2Y_iso_frames_per_buffer(runtime, usX2Y), + usX2Y->hwdep_pcm_shm->captured_iso_frames); if (msleep_interruptible(10)) { err = -ERESTARTSYS; goto up_prepare_mutex; @@ -526,7 +537,9 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) if (0 > (err = usX2Y_usbpcm_urbs_start(subs))) goto up_prepare_mutex; } - snd_printd("Ready: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", usX2Y_iso_frames_per_buffer(runtime, usX2Y), usX2Y->hwdep_pcm_shm->captured_iso_frames); + snd_printdd("Ready: iso_frames_per_buffer=%i,captured_iso_frames=%i\n", + usX2Y_iso_frames_per_buffer(runtime, usX2Y), + usX2Y->hwdep_pcm_shm->captured_iso_frames); } else usX2Y->hwdep_pcm_shm->capture_iso_start = -1; @@ -535,7 +548,7 @@ static int snd_usX2Y_usbpcm_prepare(snd_pcm_substream_t *substream) return err; } -static snd_pcm_hardware_t snd_usX2Y_4c = +static struct snd_pcm_hardware snd_usX2Y_4c = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -556,11 +569,11 @@ static snd_pcm_hardware_t snd_usX2Y_4c = -static int snd_usX2Y_usbpcm_open(snd_pcm_substream_t *substream) +static int snd_usX2Y_usbpcm_open(struct snd_pcm_substream *substream) { - snd_usX2Y_substream_t *subs = ((snd_usX2Y_substream_t **) + struct snd_usX2Y_substream *subs = ((struct snd_usX2Y_substream **) snd_pcm_substream_chip(substream))[substream->stream]; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; if (!(subs->usX2Y->chip_status & USX2Y_STAT_CHIP_MMAP_PCM_URBS)) return -EBUSY; @@ -574,17 +587,17 @@ static int snd_usX2Y_usbpcm_open(snd_pcm_substream_t *substream) } -static int snd_usX2Y_usbpcm_close(snd_pcm_substream_t *substream) +static int snd_usX2Y_usbpcm_close(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_usX2Y_substream *subs = runtime->private_data; subs->pcm_substream = NULL; return 0; } -static snd_pcm_ops_t snd_usX2Y_usbpcm_ops = +static struct snd_pcm_ops snd_usX2Y_usbpcm_ops = { .open = snd_usX2Y_usbpcm_open, .close = snd_usX2Y_usbpcm_close, @@ -597,11 +610,11 @@ static snd_pcm_ops_t snd_usX2Y_usbpcm_ops = }; -static int usX2Y_pcms_lock_check(snd_card_t *card) +static int usX2Y_pcms_lock_check(struct snd_card *card) { struct list_head *list; - snd_device_t *dev; - snd_pcm_t *pcm; + struct snd_device *dev; + struct snd_pcm *pcm; int err = 0; list_for_each(list, &card->devices) { dev = snd_device(list); @@ -617,7 +630,7 @@ static int usX2Y_pcms_lock_check(snd_card_t *card) continue; pcm = dev->device_data; for (s = 0; s < 2; ++s) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; substream = pcm->streams[s].substream; if (substream && substream->ffile != NULL) err = -EBUSY; @@ -627,11 +640,11 @@ static int usX2Y_pcms_lock_check(snd_card_t *card) } -static void usX2Y_pcms_unlock(snd_card_t *card) +static void usX2Y_pcms_unlock(struct snd_card *card) { struct list_head *list; - snd_device_t *dev; - snd_pcm_t *pcm; + struct snd_device *dev; + struct snd_pcm *pcm; list_for_each(list, &card->devices) { dev = snd_device(list); if (dev->type != SNDRV_DEV_PCM) @@ -642,10 +655,10 @@ static void usX2Y_pcms_unlock(snd_card_t *card) } -static int snd_usX2Y_hwdep_pcm_open(snd_hwdep_t *hw, struct file *file) +static int snd_usX2Y_hwdep_pcm_open(struct snd_hwdep *hw, struct file *file) { // we need to be the first - snd_card_t *card = hw->card; + struct snd_card *card = hw->card; int err = usX2Y_pcms_lock_check(card); if (0 == err) usX2Y(card)->chip_status |= USX2Y_STAT_CHIP_MMAP_PCM_URBS; @@ -654,9 +667,9 @@ static int snd_usX2Y_hwdep_pcm_open(snd_hwdep_t *hw, struct file *file) } -static int snd_usX2Y_hwdep_pcm_release(snd_hwdep_t *hw, struct file *file) +static int snd_usX2Y_hwdep_pcm_release(struct snd_hwdep *hw, struct file *file) { - snd_card_t *card = hw->card; + struct snd_card *card = hw->card; int err = usX2Y_pcms_lock_check(card); if (0 == err) usX2Y(hw->card)->chip_status &= ~USX2Y_STAT_CHIP_MMAP_PCM_URBS; @@ -684,7 +697,7 @@ static struct page * snd_usX2Y_hwdep_pcm_vm_nopage(struct vm_area_struct *area, offset = area->vm_pgoff << PAGE_SHIFT; offset += address - area->vm_start; snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); - vaddr = (char*)((usX2Ydev_t*)area->vm_private_data)->hwdep_pcm_shm + offset; + vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->hwdep_pcm_shm + offset; page = virt_to_page(vaddr); get_page(page); @@ -702,17 +715,17 @@ static struct vm_operations_struct snd_usX2Y_hwdep_pcm_vm_ops = { }; -static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) +static int snd_usX2Y_hwdep_pcm_mmap(struct snd_hwdep * hw, struct file *filp, struct vm_area_struct *area) { unsigned long size = (unsigned long)(area->vm_end - area->vm_start); - usX2Ydev_t *usX2Y = hw->private_data; + struct usX2Ydev *usX2Y = hw->private_data; if (!(usX2Y->chip_status & USX2Y_STAT_CHIP_INIT)) return -EBUSY; /* if userspace tries to mmap beyond end of our buffer, fail */ - if (size > PAGE_ALIGN(sizeof(snd_usX2Y_hwdep_pcm_shm_t))) { - snd_printd("%lu > %lu\n", size, (unsigned long)sizeof(snd_usX2Y_hwdep_pcm_shm_t)); + if (size > PAGE_ALIGN(sizeof(struct snd_usX2Y_hwdep_pcm_shm))) { + snd_printd("%lu > %lu\n", size, (unsigned long)sizeof(struct snd_usX2Y_hwdep_pcm_shm)); return -EINVAL; } @@ -726,19 +739,19 @@ static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct } -static void snd_usX2Y_hwdep_pcm_private_free(snd_hwdep_t *hwdep) +static void snd_usX2Y_hwdep_pcm_private_free(struct snd_hwdep *hwdep) { - usX2Ydev_t *usX2Y = hwdep->private_data; + struct usX2Ydev *usX2Y = hwdep->private_data; if (NULL != usX2Y->hwdep_pcm_shm) - snd_free_pages(usX2Y->hwdep_pcm_shm, sizeof(snd_usX2Y_hwdep_pcm_shm_t)); + snd_free_pages(usX2Y->hwdep_pcm_shm, sizeof(struct snd_usX2Y_hwdep_pcm_shm)); } -int usX2Y_hwdep_pcm_new(snd_card_t* card) +int usX2Y_hwdep_pcm_new(struct snd_card *card) { int err; - snd_hwdep_t *hw; - snd_pcm_t *pcm; + struct snd_hwdep *hw; + struct snd_pcm *pcm; struct usb_device *dev = usX2Y(card)->chip.dev; if (1 != nr_of_packs()) return 0; @@ -783,7 +796,7 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card) #else -int usX2Y_hwdep_pcm_new(snd_card_t* card) +int usX2Y_hwdep_pcm_new(struct snd_card *card) { return 0; } diff --git a/sound/usb/usx2y/usx2yhwdeppcm.h b/sound/usb/usx2y/usx2yhwdeppcm.h index d68f0cb..c3382fd 100644 --- a/sound/usb/usx2y/usx2yhwdeppcm.h +++ b/sound/usb/usx2y/usx2yhwdeppcm.h @@ -18,4 +18,3 @@ struct snd_usX2Y_hwdep_pcm_shm { volatile unsigned captured_iso_frames; int capture_iso_start; }; -typedef struct snd_usX2Y_hwdep_pcm_shm snd_usX2Y_hwdep_pcm_shm_t; -- cgit v1.1 From 65b29f5039b38a5854b5e12238b0688a33e235cc Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:09:46 +0100 Subject: [ALSA] Remove xxx_t typedefs: PowerMac Remove xxx_t typedefs from the PowerMac driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/ppc/awacs.c | 175 ++++++++++++++++++++---------------- sound/ppc/beep.c | 34 +++---- sound/ppc/burgundy.c | 75 +++++++++------- sound/ppc/daca.c | 72 ++++++++------- sound/ppc/keywest.c | 6 +- sound/ppc/pmac.c | 202 +++++++++++++++++++++--------------------- sound/ppc/pmac.h | 93 +++++++++----------- sound/ppc/powermac.c | 6 +- sound/ppc/toonie.c | 32 +++---- sound/ppc/tumbler.c | 244 ++++++++++++++++++++++++++++----------------------- 10 files changed, 503 insertions(+), 436 deletions(-) diff --git a/sound/ppc/awacs.c b/sound/ppc/awacs.c index 758ca1b..82d791b 100644 --- a/sound/ppc/awacs.c +++ b/sound/ppc/awacs.c @@ -35,18 +35,18 @@ #endif #ifdef PMAC_AMP_AVAIL -typedef struct awacs_amp { +struct awacs_amp { unsigned char amp_master; unsigned char amp_vol[2][2]; unsigned char amp_tone[2]; -} awacs_amp_t; +}; #define CHECK_CUDA_AMP() (sys_ctrler == SYS_CTRLER_CUDA) #endif /* PMAC_AMP_AVAIL */ -static void snd_pmac_screamer_wait(pmac_t *chip) +static void snd_pmac_screamer_wait(struct snd_pmac *chip) { long timeout = 2000; while (!(in_le32(&chip->awacs->codec_stat) & MASK_VALID)) { @@ -62,7 +62,7 @@ static void snd_pmac_screamer_wait(pmac_t *chip) * write AWACS register */ static void -snd_pmac_awacs_write(pmac_t *chip, int val) +snd_pmac_awacs_write(struct snd_pmac *chip, int val) { long timeout = 5000000; @@ -78,21 +78,21 @@ snd_pmac_awacs_write(pmac_t *chip, int val) } static void -snd_pmac_awacs_write_reg(pmac_t *chip, int reg, int val) +snd_pmac_awacs_write_reg(struct snd_pmac *chip, int reg, int val) { snd_pmac_awacs_write(chip, val | (reg << 12)); chip->awacs_reg[reg] = val; } static void -snd_pmac_awacs_write_noreg(pmac_t *chip, int reg, int val) +snd_pmac_awacs_write_noreg(struct snd_pmac *chip, int reg, int val) { snd_pmac_awacs_write(chip, val | (reg << 12)); } #ifdef CONFIG_PM /* Recalibrate chip */ -static void screamer_recalibrate(pmac_t *chip) +static void screamer_recalibrate(struct snd_pmac *chip) { if (chip->model != PMAC_SCREAMER) return; @@ -105,7 +105,8 @@ static void screamer_recalibrate(pmac_t *chip) /* delay for broken crystal part */ msleep(750); snd_pmac_awacs_write_noreg(chip, 1, - chip->awacs_reg[1] | MASK_RECALIBRATE | MASK_CMUTE | MASK_AMUTE); + chip->awacs_reg[1] | MASK_RECALIBRATE | + MASK_CMUTE | MASK_AMUTE); snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); snd_pmac_awacs_write_noreg(chip, 6, chip->awacs_reg[6]); } @@ -118,7 +119,7 @@ static void screamer_recalibrate(pmac_t *chip) /* * additional callback to set the pcm format */ -static void snd_pmac_awacs_set_format(pmac_t *chip) +static void snd_pmac_awacs_set_format(struct snd_pmac *chip) { chip->awacs_reg[1] &= ~MASK_SAMPLERATE; chip->awacs_reg[1] |= chip->rate_index << 3; @@ -132,7 +133,8 @@ static void snd_pmac_awacs_set_format(pmac_t *chip) /* * volumes: 0-15 stereo */ -static int snd_pmac_awacs_info_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_awacs_info_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -141,9 +143,10 @@ static int snd_pmac_awacs_info_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int snd_pmac_awacs_get_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_get_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int lshift = (kcontrol->private_value >> 8) & 0xff; int inverted = (kcontrol->private_value >> 16) & 1; @@ -163,9 +166,10 @@ static int snd_pmac_awacs_get_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu return 0; } -static int snd_pmac_awacs_put_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_put_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int lshift = (kcontrol->private_value >> 8) & 0xff; int inverted = (kcontrol->private_value >> 16) & 1; @@ -203,9 +207,10 @@ static int snd_pmac_awacs_put_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu /* * mute master/ogain for AWACS: mono */ -static int snd_pmac_awacs_get_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_get_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int invert = (kcontrol->private_value >> 16) & 1; @@ -221,9 +226,10 @@ static int snd_pmac_awacs_get_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu return 0; } -static int snd_pmac_awacs_put_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_put_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int invert = (kcontrol->private_value >> 16) & 1; @@ -268,7 +274,7 @@ static void awacs_set_cuda(int reg, int val) /* * level = 0 - 14, 7 = 0 dB */ -static void awacs_amp_set_tone(awacs_amp_t *amp, int bass, int treble) +static void awacs_amp_set_tone(struct awacs_amp *amp, int bass, int treble) { amp->amp_tone[0] = bass; amp->amp_tone[1] = treble; @@ -282,7 +288,8 @@ static void awacs_amp_set_tone(awacs_amp_t *amp, int bass, int treble) /* * vol = 0 - 31 (attenuation), 32 = mute bit, stereo */ -static int awacs_amp_set_vol(awacs_amp_t *amp, int index, int lvol, int rvol, int do_check) +static int awacs_amp_set_vol(struct awacs_amp *amp, int index, int lvol, int rvol, + int do_check) { if (do_check && amp->amp_vol[index][0] == lvol && amp->amp_vol[index][1] == rvol) @@ -297,7 +304,7 @@ static int awacs_amp_set_vol(awacs_amp_t *amp, int index, int lvol, int rvol, in /* * 0 = -79 dB, 79 = 0 dB, 99 = +20 dB */ -static void awacs_amp_set_master(awacs_amp_t *amp, int vol) +static void awacs_amp_set_master(struct awacs_amp *amp, int vol) { amp->amp_master = vol; if (vol <= 79) @@ -307,9 +314,9 @@ static void awacs_amp_set_master(awacs_amp_t *amp, int vol) awacs_set_cuda(1, vol); } -static void awacs_amp_free(pmac_t *chip) +static void awacs_amp_free(struct snd_pmac *chip) { - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return); kfree(amp); chip->mixer_data = NULL; @@ -320,7 +327,8 @@ static void awacs_amp_free(pmac_t *chip) /* * mixer controls */ -static int snd_pmac_awacs_info_volume_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_awacs_info_volume_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -329,11 +337,12 @@ static int snd_pmac_awacs_info_volume_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_pmac_awacs_get_volume_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_get_volume_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int index = kcontrol->private_value; - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); snd_assert(index >= 0 && index <= 1, return -EINVAL); ucontrol->value.integer.value[0] = 31 - (amp->amp_vol[index][0] & 31); @@ -341,12 +350,13 @@ static int snd_pmac_awacs_get_volume_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_pmac_awacs_put_volume_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_put_volume_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int index = kcontrol->private_value; int vol[2]; - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); snd_assert(index >= 0 && index <= 1, return -EINVAL); @@ -355,11 +365,12 @@ static int snd_pmac_awacs_put_volume_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1); } -static int snd_pmac_awacs_get_switch_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_get_switch_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int index = kcontrol->private_value; - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); snd_assert(index >= 0 && index <= 1, return -EINVAL); ucontrol->value.integer.value[0] = (amp->amp_vol[index][0] & 32) ? 0 : 1; @@ -367,12 +378,13 @@ static int snd_pmac_awacs_get_switch_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_pmac_awacs_put_switch_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_put_switch_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int index = kcontrol->private_value; int vol[2]; - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); snd_assert(index >= 0 && index <= 1, return -EINVAL); @@ -381,7 +393,8 @@ static int snd_pmac_awacs_put_switch_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return awacs_amp_set_vol(amp, index, vol[0], vol[1], 1); } -static int snd_pmac_awacs_info_tone_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_awacs_info_tone_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -390,22 +403,24 @@ static int snd_pmac_awacs_info_tone_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_pmac_awacs_get_tone_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_get_tone_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int index = kcontrol->private_value; - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); snd_assert(index >= 0 && index <= 1, return -EINVAL); ucontrol->value.integer.value[0] = amp->amp_tone[index]; return 0; } -static int snd_pmac_awacs_put_tone_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_put_tone_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int index = kcontrol->private_value; - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); snd_assert(index >= 0 && index <= 1, return -EINVAL); if (ucontrol->value.integer.value[0] != amp->amp_tone[index]) { @@ -416,7 +431,8 @@ static int snd_pmac_awacs_put_tone_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return 0; } -static int snd_pmac_awacs_info_master_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_awacs_info_master_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -425,19 +441,21 @@ static int snd_pmac_awacs_info_master_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem return 0; } -static int snd_pmac_awacs_get_master_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_get_master_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - awacs_amp_t *amp = chip->mixer_data; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); ucontrol->value.integer.value[0] = amp->amp_master; return 0; } -static int snd_pmac_awacs_put_master_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_awacs_put_master_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - awacs_amp_t *amp = chip->mixer_data; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct awacs_amp *amp = chip->mixer_data; snd_assert(amp, return -EINVAL); if (ucontrol->value.integer.value[0] != amp->amp_master) { amp->amp_master = ucontrol->value.integer.value[0]; @@ -450,7 +468,7 @@ static int snd_pmac_awacs_put_master_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_ #define AMP_CH_SPK 0 #define AMP_CH_HD 1 -static snd_kcontrol_new_t snd_pmac_awacs_amp_vol[] __initdata = { +static struct snd_kcontrol_new snd_pmac_awacs_amp_vol[] __initdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PC Speaker Playback Volume", .info = snd_pmac_awacs_info_volume_amp, @@ -487,7 +505,7 @@ static snd_kcontrol_new_t snd_pmac_awacs_amp_vol[] __initdata = { }, }; -static snd_kcontrol_new_t snd_pmac_awacs_amp_hp_sw __initdata = { +static struct snd_kcontrol_new snd_pmac_awacs_amp_hp_sw __initdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Playback Switch", .info = snd_pmac_boolean_stereo_info, @@ -496,7 +514,7 @@ static snd_kcontrol_new_t snd_pmac_awacs_amp_hp_sw __initdata = { .private_value = AMP_CH_HD, }; -static snd_kcontrol_new_t snd_pmac_awacs_amp_spk_sw __initdata = { +static struct snd_kcontrol_new snd_pmac_awacs_amp_spk_sw __initdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PC Speaker Playback Switch", .info = snd_pmac_boolean_stereo_info, @@ -511,7 +529,8 @@ static snd_kcontrol_new_t snd_pmac_awacs_amp_spk_sw __initdata = { /* * mic boost for screamer */ -static int snd_pmac_screamer_mic_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_screamer_mic_boost_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -520,9 +539,10 @@ static int snd_pmac_screamer_mic_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_pmac_screamer_mic_boost_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_screamer_mic_boost_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int val; unsigned long flags; @@ -538,9 +558,10 @@ static int snd_pmac_screamer_mic_boost_get(snd_kcontrol_t *kcontrol, snd_ctl_ele return 0; } -static int snd_pmac_screamer_mic_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_screamer_mic_boost_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int changed = 0; int val0, val6; unsigned long flags; @@ -568,7 +589,7 @@ static int snd_pmac_screamer_mic_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_ele /* * lists of mixer elements */ -static snd_kcontrol_new_t snd_pmac_awacs_mixers[] __initdata = { +static struct snd_kcontrol_new snd_pmac_awacs_mixers[] __initdata = { AWACS_VOLUME("Master Playback Volume", 2, 6, 1), AWACS_SWITCH("Master Capture Switch", 1, SHIFT_LOOPTHRU, 0), AWACS_VOLUME("Capture Volume", 0, 4, 0), @@ -578,24 +599,24 @@ static snd_kcontrol_new_t snd_pmac_awacs_mixers[] __initdata = { /* FIXME: is this correct order? * screamer (powerbook G3 pismo) seems to have different bits... */ -static snd_kcontrol_new_t snd_pmac_awacs_mixers2[] __initdata = { +static struct snd_kcontrol_new snd_pmac_awacs_mixers2[] __initdata = { AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_LINE, 0), AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_MIC, 0), }; -static snd_kcontrol_new_t snd_pmac_screamer_mixers2[] __initdata = { +static struct snd_kcontrol_new snd_pmac_screamer_mixers2[] __initdata = { AWACS_SWITCH("Line Capture Switch", 0, SHIFT_MUX_MIC, 0), AWACS_SWITCH("Mic Capture Switch", 0, SHIFT_MUX_LINE, 0), }; -static snd_kcontrol_new_t snd_pmac_awacs_master_sw __initdata = +static struct snd_kcontrol_new snd_pmac_awacs_master_sw __initdata = AWACS_SWITCH("Master Playback Switch", 1, SHIFT_HDMUTE, 1); -static snd_kcontrol_new_t snd_pmac_awacs_mic_boost[] __initdata = { +static struct snd_kcontrol_new snd_pmac_awacs_mic_boost[] __initdata = { AWACS_SWITCH("Mic Boost", 0, SHIFT_GAINLINE, 0), }; -static snd_kcontrol_new_t snd_pmac_screamer_mic_boost[] __initdata = { +static struct snd_kcontrol_new snd_pmac_screamer_mic_boost[] __initdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Mic Boost", .info = snd_pmac_screamer_mic_boost_info, @@ -604,17 +625,17 @@ static snd_kcontrol_new_t snd_pmac_screamer_mic_boost[] __initdata = { }, }; -static snd_kcontrol_new_t snd_pmac_awacs_speaker_vol[] __initdata = { +static struct snd_kcontrol_new snd_pmac_awacs_speaker_vol[] __initdata = { AWACS_VOLUME("PC Speaker Playback Volume", 4, 6, 1), }; -static snd_kcontrol_new_t snd_pmac_awacs_speaker_sw __initdata = +static struct snd_kcontrol_new snd_pmac_awacs_speaker_sw __initdata = AWACS_SWITCH("PC Speaker Playback Switch", 1, SHIFT_SPKMUTE, 1); /* * add new mixer elements to the card */ -static int build_mixers(pmac_t *chip, int nums, snd_kcontrol_new_t *mixers) +static int build_mixers(struct snd_pmac *chip, int nums, struct snd_kcontrol_new *mixers) { int i, err; @@ -629,7 +650,7 @@ static int build_mixers(pmac_t *chip, int nums, snd_kcontrol_new_t *mixers) /* * restore all registers */ -static void awacs_restore_all_regs(pmac_t *chip) +static void awacs_restore_all_regs(struct snd_pmac *chip) { snd_pmac_awacs_write_noreg(chip, 0, chip->awacs_reg[0]); snd_pmac_awacs_write_noreg(chip, 1, chip->awacs_reg[1]); @@ -643,13 +664,13 @@ static void awacs_restore_all_regs(pmac_t *chip) } #ifdef CONFIG_PM -static void snd_pmac_awacs_suspend(pmac_t *chip) +static void snd_pmac_awacs_suspend(struct snd_pmac *chip) { snd_pmac_awacs_write_noreg(chip, 1, (chip->awacs_reg[1] | MASK_AMUTE | MASK_CMUTE)); } -static void snd_pmac_awacs_resume(pmac_t *chip) +static void snd_pmac_awacs_resume(struct snd_pmac *chip) { if (machine_is_compatible("PowerBook3,1") || machine_is_compatible("PowerBook3,2")) { @@ -668,7 +689,7 @@ static void snd_pmac_awacs_resume(pmac_t *chip) screamer_recalibrate(chip); #ifdef PMAC_AMP_AVAIL if (chip->mixer_data) { - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; awacs_amp_set_vol(amp, 0, amp->amp_vol[0][0], amp->amp_vol[0][1], 0); awacs_amp_set_vol(amp, 1, amp->amp_vol[1][0], amp->amp_vol[1][1], 0); awacs_amp_set_tone(amp, amp->amp_tone[0], amp->amp_tone[1]); @@ -682,13 +703,13 @@ static void snd_pmac_awacs_resume(pmac_t *chip) /* * auto-mute stuffs */ -static int snd_pmac_awacs_detect_headphone(pmac_t *chip) +static int snd_pmac_awacs_detect_headphone(struct snd_pmac *chip) { return (in_le32(&chip->awacs->codec_stat) & chip->hp_stat_mask) ? 1 : 0; } #ifdef PMAC_AMP_AVAIL -static int toggle_amp_mute(awacs_amp_t *amp, int index, int mute) +static int toggle_amp_mute(struct awacs_amp *amp, int index, int mute) { int vol[2]; vol[0] = amp->amp_vol[index][0] & 31; @@ -701,12 +722,12 @@ static int toggle_amp_mute(awacs_amp_t *amp, int index, int mute) } #endif -static void snd_pmac_awacs_update_automute(pmac_t *chip, int do_notify) +static void snd_pmac_awacs_update_automute(struct snd_pmac *chip, int do_notify) { if (chip->auto_mute) { #ifdef PMAC_AMP_AVAIL if (chip->mixer_data) { - awacs_amp_t *amp = chip->mixer_data; + struct awacs_amp *amp = chip->mixer_data; int changed; if (snd_pmac_awacs_detect_headphone(chip)) { changed = toggle_amp_mute(amp, AMP_CH_HD, 0); @@ -746,7 +767,7 @@ static void snd_pmac_awacs_update_automute(pmac_t *chip, int do_notify) * initialize chip */ int __init -snd_pmac_awacs_init(pmac_t *chip) +snd_pmac_awacs_init(struct snd_pmac *chip) { int err, vol; @@ -780,7 +801,7 @@ snd_pmac_awacs_init(pmac_t *chip) chip->revision = (in_le32(&chip->awacs->codec_stat) >> 12) & 0xf; #ifdef PMAC_AMP_AVAIL if (chip->revision == 3 && chip->has_iic && CHECK_CUDA_AMP()) { - awacs_amp_t *amp = kmalloc(sizeof(*amp), GFP_KERNEL); + struct awacs_amp *amp = kmalloc(sizeof(*amp), GFP_KERNEL); if (! amp) return -ENOMEM; chip->mixer_data = amp; diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c index d4ec6cc..5fec1e5 100644 --- a/sound/ppc/beep.c +++ b/sound/ppc/beep.c @@ -30,7 +30,7 @@ #include <sound/control.h> #include "pmac.h" -struct snd_pmac_beep { +struct pmac_beep { int running; /* boolean */ int volume; /* mixer volume: 0-100 */ int volume_play; /* currently playing volume */ @@ -44,9 +44,9 @@ struct snd_pmac_beep { /* * stop beep if running */ -void snd_pmac_beep_stop(pmac_t *chip) +void snd_pmac_beep_stop(struct snd_pmac *chip) { - pmac_beep_t *beep = chip->beep; + struct pmac_beep *beep = chip->beep; if (beep && beep->running) { beep->running = 0; snd_pmac_beep_dma_stop(chip); @@ -97,10 +97,11 @@ static short beep_wform[256] = { #define BEEP_BUFLEN 512 #define BEEP_VOLUME 15 /* 0 - 100 */ -static int snd_pmac_beep_event(struct input_dev *dev, unsigned int type, unsigned int code, int hz) +static int snd_pmac_beep_event(struct input_dev *dev, unsigned int type, + unsigned int code, int hz) { - pmac_t *chip; - pmac_beep_t *beep; + struct snd_pmac *chip; + struct pmac_beep *beep; unsigned long flags; int beep_speed = 0; int srate; @@ -171,7 +172,8 @@ static int snd_pmac_beep_event(struct input_dev *dev, unsigned int type, unsigne * beep volume mixer */ -static int snd_pmac_info_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_info_beep(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; @@ -180,17 +182,19 @@ static int snd_pmac_info_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uin return 0; } -static int snd_pmac_get_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_get_beep(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); snd_assert(chip->beep, return -ENXIO); ucontrol->value.integer.value[0] = chip->beep->volume; return 0; } -static int snd_pmac_put_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_put_beep(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int oval; snd_assert(chip->beep, return -ENXIO); oval = chip->beep->volume; @@ -198,7 +202,7 @@ static int snd_pmac_put_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uco return oval != chip->beep->volume; } -static snd_kcontrol_new_t snd_pmac_beep_mixer = { +static struct snd_kcontrol_new snd_pmac_beep_mixer = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Beep Playback Volume", .info = snd_pmac_info_beep, @@ -207,9 +211,9 @@ static snd_kcontrol_new_t snd_pmac_beep_mixer = { }; /* Initialize beep stuff */ -int __init snd_pmac_attach_beep(pmac_t *chip) +int __init snd_pmac_attach_beep(struct snd_pmac *chip) { - pmac_beep_t *beep; + struct pmac_beep *beep; struct input_dev *input_dev; void *dmabuf; int err = -ENOMEM; @@ -255,7 +259,7 @@ int __init snd_pmac_attach_beep(pmac_t *chip) return err; } -void snd_pmac_detach_beep(pmac_t *chip) +void snd_pmac_detach_beep(struct snd_pmac *chip) { if (chip->beep) { input_unregister_device(chip->beep->dev); diff --git a/sound/ppc/burgundy.c b/sound/ppc/burgundy.c index edbc048..e02263f 100644 --- a/sound/ppc/burgundy.c +++ b/sound/ppc/burgundy.c @@ -31,7 +31,7 @@ /* Waits for busy flag to clear */ static inline void -snd_pmac_burgundy_busy_wait(pmac_t *chip) +snd_pmac_burgundy_busy_wait(struct snd_pmac *chip) { int timeout = 50; while ((in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) && timeout--) @@ -41,7 +41,7 @@ snd_pmac_burgundy_busy_wait(pmac_t *chip) } static inline void -snd_pmac_burgundy_extend_wait(pmac_t *chip) +snd_pmac_burgundy_extend_wait(struct snd_pmac *chip) { int timeout; timeout = 50; @@ -57,7 +57,7 @@ snd_pmac_burgundy_extend_wait(pmac_t *chip) } static void -snd_pmac_burgundy_wcw(pmac_t *chip, unsigned addr, unsigned val) +snd_pmac_burgundy_wcw(struct snd_pmac *chip, unsigned addr, unsigned val) { out_le32(&chip->awacs->codec_ctrl, addr + 0x200c00 + (val & 0xff)); snd_pmac_burgundy_busy_wait(chip); @@ -70,7 +70,7 @@ snd_pmac_burgundy_wcw(pmac_t *chip, unsigned addr, unsigned val) } static unsigned -snd_pmac_burgundy_rcw(pmac_t *chip, unsigned addr) +snd_pmac_burgundy_rcw(struct snd_pmac *chip, unsigned addr) { unsigned val = 0; unsigned long flags; @@ -103,14 +103,14 @@ snd_pmac_burgundy_rcw(pmac_t *chip, unsigned addr) } static void -snd_pmac_burgundy_wcb(pmac_t *chip, unsigned int addr, unsigned int val) +snd_pmac_burgundy_wcb(struct snd_pmac *chip, unsigned int addr, unsigned int val) { out_le32(&chip->awacs->codec_ctrl, addr + 0x300000 + (val & 0xff)); snd_pmac_burgundy_busy_wait(chip); } static unsigned -snd_pmac_burgundy_rcb(pmac_t *chip, unsigned int addr) +snd_pmac_burgundy_rcb(struct snd_pmac *chip, unsigned int addr) { unsigned val = 0; unsigned long flags; @@ -131,7 +131,8 @@ snd_pmac_burgundy_rcb(pmac_t *chip, unsigned int addr) * Burgundy volume: 0 - 100, stereo */ static void -snd_pmac_burgundy_write_volume(pmac_t *chip, unsigned int address, long *volume, int shift) +snd_pmac_burgundy_write_volume(struct snd_pmac *chip, unsigned int address, + long *volume, int shift) { int hardvolume, lvolume, rvolume; @@ -146,7 +147,8 @@ snd_pmac_burgundy_write_volume(pmac_t *chip, unsigned int address, long *volume, } static void -snd_pmac_burgundy_read_volume(pmac_t *chip, unsigned int address, long *volume, int shift) +snd_pmac_burgundy_read_volume(struct snd_pmac *chip, unsigned int address, + long *volume, int shift) { int wvolume; @@ -171,7 +173,8 @@ snd_pmac_burgundy_read_volume(pmac_t *chip, unsigned int address, long *volume, #define BASE2ADDR(base) ((base) << 12) #define ADDR2BASE(addr) ((addr) >> 12) -static int snd_pmac_burgundy_info_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_burgundy_info_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -180,23 +183,27 @@ static int snd_pmac_burgundy_info_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_pmac_burgundy_get_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_burgundy_get_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); int shift = (kcontrol->private_value >> 8) & 0xff; - snd_pmac_burgundy_read_volume(chip, addr, ucontrol->value.integer.value, shift); + snd_pmac_burgundy_read_volume(chip, addr, ucontrol->value.integer.value, + shift); return 0; } -static int snd_pmac_burgundy_put_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_burgundy_put_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); int shift = (kcontrol->private_value >> 8) & 0xff; long nvoices[2]; - snd_pmac_burgundy_write_volume(chip, addr, ucontrol->value.integer.value, shift); + snd_pmac_burgundy_write_volume(chip, addr, ucontrol->value.integer.value, + shift); snd_pmac_burgundy_read_volume(chip, addr, nvoices, shift); return (nvoices[0] != ucontrol->value.integer.value[0] || nvoices[1] != ucontrol->value.integer.value[1]); @@ -211,7 +218,8 @@ static int snd_pmac_burgundy_put_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_v /* lineout/speaker */ -static int snd_pmac_burgundy_info_switch_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_burgundy_info_switch_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int stereo = (kcontrol->private_value >> 24) & 1; uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; @@ -221,9 +229,10 @@ static int snd_pmac_burgundy_info_switch_out(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_pmac_burgundy_get_switch_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_burgundy_get_switch_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int lmask = kcontrol->private_value & 0xff; int rmask = (kcontrol->private_value >> 8) & 0xff; int stereo = (kcontrol->private_value >> 24) & 1; @@ -234,9 +243,10 @@ static int snd_pmac_burgundy_get_switch_out(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_pmac_burgundy_put_switch_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_burgundy_put_switch_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); int lmask = kcontrol->private_value & 0xff; int rmask = (kcontrol->private_value >> 8) & 0xff; int stereo = (kcontrol->private_value >> 24) & 1; @@ -259,7 +269,8 @@ static int snd_pmac_burgundy_put_switch_out(snd_kcontrol_t *kcontrol, snd_ctl_el .private_value = ((lmask) | ((rmask) << 8) | ((stereo) << 24)) } /* line/speaker output volume */ -static int snd_pmac_burgundy_info_volume_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_pmac_burgundy_info_volume_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int stereo = (kcontrol->private_value >> 24) & 1; uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; @@ -269,9 +280,10 @@ static int snd_pmac_burgundy_info_volume_out(snd_kcontrol_t *kcontrol, snd_ctl_e return 0; } -static int snd_pmac_burgundy_get_volume_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_burgundy_get_volume_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); int stereo = (kcontrol->private_value >> 24) & 1; int oval; @@ -283,9 +295,10 @@ static int snd_pmac_burgundy_get_volume_out(snd_kcontrol_t *kcontrol, snd_ctl_el return 0; } -static int snd_pmac_burgundy_put_volume_out(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_pmac_burgundy_put_volume_out(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff); int stereo = (kcontrol->private_value >> 24) & 1; int oval, val; @@ -308,7 +321,7 @@ static int snd_pmac_burgundy_put_volume_out(snd_kcontrol_t *kcontrol, snd_ctl_el .put = snd_pmac_burgundy_put_volume_out,\ .private_value = (ADDR2BASE(addr) | ((stereo) << 24)) } -static snd_kcontrol_new_t snd_pmac_burgundy_mixers[] __initdata = { +static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = { BURGUNDY_VOLUME("Master Playback Volume", 0, MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8), BURGUNDY_VOLUME("Line Playback Volume", 0, MASK_ADDR_BURGUNDY_VOLLINE, 16), BURGUNDY_VOLUME("CD Playback Volume", 0, MASK_ADDR_BURGUNDY_VOLCD, 16), @@ -317,9 +330,9 @@ static snd_kcontrol_new_t snd_pmac_burgundy_mixers[] __initdata = { /*BURGUNDY_OUTPUT_VOLUME("PCM Playback Volume", 0, MASK_ADDR_BURGUNDY_ATTENLINEOUT, 1),*/ BURGUNDY_OUTPUT_VOLUME("Headphone Playback Volume", 0, MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1), }; -static snd_kcontrol_new_t snd_pmac_burgundy_master_sw __initdata = +static struct snd_kcontrol_new snd_pmac_burgundy_master_sw __initdata = BURGUNDY_OUTPUT_SWITCH("Headphone Playback Switch", 0, BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1); -static snd_kcontrol_new_t snd_pmac_burgundy_speaker_sw __initdata = +static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw __initdata = BURGUNDY_OUTPUT_SWITCH("PC Speaker Playback Switch", 0, BURGUNDY_OUTPUT_INTERN, 0, 0); @@ -327,12 +340,12 @@ BURGUNDY_OUTPUT_SWITCH("PC Speaker Playback Switch", 0, BURGUNDY_OUTPUT_INTERN, /* * auto-mute stuffs */ -static int snd_pmac_burgundy_detect_headphone(pmac_t *chip) +static int snd_pmac_burgundy_detect_headphone(struct snd_pmac *chip) { return (in_le32(&chip->awacs->codec_stat) & chip->hp_stat_mask) ? 1 : 0; } -static void snd_pmac_burgundy_update_automute(pmac_t *chip, int do_notify) +static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) { if (chip->auto_mute) { int reg, oreg; @@ -361,7 +374,7 @@ static void snd_pmac_burgundy_update_automute(pmac_t *chip, int do_notify) /* * initialize burgundy */ -int __init snd_pmac_burgundy_init(pmac_t *chip) +int __init snd_pmac_burgundy_init(struct snd_pmac *chip) { int i, err; diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c index a737f29..08cde51 100644 --- a/sound/ppc/daca.c +++ b/sound/ppc/daca.c @@ -40,18 +40,18 @@ #define DACA_VOL_MAX 0x38 -typedef struct pmac_daca_t { - pmac_keywest_t i2c; +struct pmac_daca { + struct pmac_keywest i2c; int left_vol, right_vol; unsigned int deemphasis : 1; unsigned int amp_on : 1; -} pmac_daca_t; +}; /* * initialize / detect DACA */ -static int daca_init_client(pmac_keywest_t *i2c) +static int daca_init_client(struct pmac_keywest *i2c) { unsigned short wdata = 0x00; /* SR: no swap, 1bit delay, 32-48kHz */ @@ -66,7 +66,7 @@ static int daca_init_client(pmac_keywest_t *i2c) /* * update volume */ -static int daca_set_volume(pmac_daca_t *mix) +static int daca_set_volume(struct pmac_daca *mix) { unsigned char data[2]; @@ -92,7 +92,8 @@ static int daca_set_volume(pmac_daca_t *mix) /* deemphasis switch */ -static int daca_info_deemphasis(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int daca_info_deemphasis(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -101,20 +102,22 @@ static int daca_info_deemphasis(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *u return 0; } -static int daca_get_deemphasis(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int daca_get_deemphasis(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_daca_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_daca *mix; if (! (mix = chip->mixer_data)) return -ENODEV; ucontrol->value.integer.value[0] = mix->deemphasis ? 1 : 0; return 0; } -static int daca_put_deemphasis(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int daca_put_deemphasis(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_daca_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_daca *mix; int change; if (! (mix = chip->mixer_data)) @@ -128,7 +131,8 @@ static int daca_put_deemphasis(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *u } /* output volume */ -static int daca_info_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int daca_info_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -137,10 +141,11 @@ static int daca_info_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo return 0; } -static int daca_get_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int daca_get_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_daca_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_daca *mix; if (! (mix = chip->mixer_data)) return -ENODEV; ucontrol->value.integer.value[0] = mix->left_vol; @@ -148,10 +153,11 @@ static int daca_get_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int daca_put_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int daca_put_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_daca_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_daca *mix; int change; if (! (mix = chip->mixer_data)) @@ -169,20 +175,22 @@ static int daca_put_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont /* amplifier switch */ #define daca_info_amp daca_info_deemphasis -static int daca_get_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int daca_get_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_daca_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_daca *mix; if (! (mix = chip->mixer_data)) return -ENODEV; ucontrol->value.integer.value[0] = mix->amp_on ? 1 : 0; return 0; } -static int daca_put_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int daca_put_amp(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_daca_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_daca *mix; int change; if (! (mix = chip->mixer_data)) @@ -196,7 +204,7 @@ static int daca_put_amp(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol return change; } -static snd_kcontrol_new_t daca_mixers[] = { +static struct snd_kcontrol_new daca_mixers[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Deemphasis Switch", .info = daca_info_deemphasis, @@ -219,9 +227,9 @@ static snd_kcontrol_new_t daca_mixers[] = { #ifdef CONFIG_PM -static void daca_resume(pmac_t *chip) +static void daca_resume(struct snd_pmac *chip) { - pmac_daca_t *mix = chip->mixer_data; + struct pmac_daca *mix = chip->mixer_data; i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_SR, 0x08); i2c_smbus_write_byte_data(mix->i2c.client, DACA_REG_GCFG, mix->amp_on ? 0x05 : 0x04); @@ -230,9 +238,9 @@ static void daca_resume(pmac_t *chip) #endif /* CONFIG_PM */ -static void daca_cleanup(pmac_t *chip) +static void daca_cleanup(struct snd_pmac *chip) { - pmac_daca_t *mix = chip->mixer_data; + struct pmac_daca *mix = chip->mixer_data; if (! mix) return; snd_pmac_keywest_cleanup(&mix->i2c); @@ -241,10 +249,10 @@ static void daca_cleanup(pmac_t *chip) } /* exported */ -int __init snd_pmac_daca_init(pmac_t *chip) +int __init snd_pmac_daca_init(struct snd_pmac *chip) { int i, err; - pmac_daca_t *mix; + struct pmac_daca *mix; #ifdef CONFIG_KMOD if (current->fs->root) diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index df073a0..097fbcf 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -32,7 +32,7 @@ * we have to keep a static variable here since i2c attach_adapter * callback cannot pass a private data. */ -static pmac_keywest_t *keywest_ctx; +static struct pmac_keywest *keywest_ctx; #define I2C_DRIVERID_KEYWEST 0xFEBA @@ -106,7 +106,7 @@ static int keywest_detach_client(struct i2c_client *client) } /* exported */ -void snd_pmac_keywest_cleanup(pmac_keywest_t *i2c) +void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c) { if (keywest_ctx && keywest_ctx == i2c) { i2c_del_driver(&keywest_driver); @@ -126,7 +126,7 @@ int __init snd_pmac_tumbler_post_init(void) } /* exported */ -int __init snd_pmac_keywest_init(pmac_keywest_t *i2c) +int __init snd_pmac_keywest_init(struct pmac_keywest *i2c) { int err; diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index dd28187..222765f 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -37,10 +37,10 @@ #ifdef CONFIG_PM -static int snd_pmac_register_sleep_notifier(pmac_t *chip); -static int snd_pmac_unregister_sleep_notifier(pmac_t *chip); -static int snd_pmac_suspend(snd_card_t *card, pm_message_t state); -static int snd_pmac_resume(snd_card_t *card); +static int snd_pmac_register_sleep_notifier(struct snd_pmac *chip); +static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip); +static int snd_pmac_suspend(struct snd_card *card, pm_message_t state); +static int snd_pmac_resume(struct snd_card *card); #endif @@ -56,7 +56,7 @@ static int tumbler_freqs[1] = { /* * allocate DBDMA command arrays */ -static int snd_pmac_dbdma_alloc(pmac_t *chip, pmac_dbdma_t *rec, int size) +static int snd_pmac_dbdma_alloc(struct snd_pmac *chip, struct pmac_dbdma *rec, int size) { unsigned int rsize = sizeof(struct dbdma_cmd) * (size + 1); @@ -72,7 +72,7 @@ static int snd_pmac_dbdma_alloc(pmac_t *chip, pmac_dbdma_t *rec, int size) return 0; } -static void snd_pmac_dbdma_free(pmac_t *chip, pmac_dbdma_t *rec) +static void snd_pmac_dbdma_free(struct snd_pmac *chip, struct pmac_dbdma *rec) { if (rec) { unsigned int rsize = sizeof(struct dbdma_cmd) * (rec->size + 1); @@ -90,7 +90,7 @@ static void snd_pmac_dbdma_free(pmac_t *chip, pmac_dbdma_t *rec) * look up frequency table */ -unsigned int snd_pmac_rate_index(pmac_t *chip, pmac_stream_t *rec, unsigned int rate) +unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate) { int i, ok, found; @@ -119,8 +119,8 @@ static inline int another_stream(int stream) /* * allocate buffers */ -static int snd_pmac_pcm_hw_params(snd_pcm_substream_t *subs, - snd_pcm_hw_params_t *hw_params) +static int snd_pmac_pcm_hw_params(struct snd_pcm_substream *subs, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw_params)); } @@ -128,7 +128,7 @@ static int snd_pmac_pcm_hw_params(snd_pcm_substream_t *subs, /* * release buffers */ -static int snd_pmac_pcm_hw_free(snd_pcm_substream_t *subs) +static int snd_pmac_pcm_hw_free(struct snd_pcm_substream *subs) { snd_pcm_lib_free_pages(subs); return 0; @@ -137,7 +137,7 @@ static int snd_pmac_pcm_hw_free(snd_pcm_substream_t *subs) /* * get a stream of the opposite direction */ -static pmac_stream_t *snd_pmac_get_stream(pmac_t *chip, int stream) +static struct pmac_stream *snd_pmac_get_stream(struct snd_pmac *chip, int stream) { switch (stream) { case SNDRV_PCM_STREAM_PLAYBACK: @@ -154,7 +154,7 @@ static pmac_stream_t *snd_pmac_get_stream(pmac_t *chip, int stream) * wait while run status is on */ static inline void -snd_pmac_wait_ack(pmac_stream_t *rec) +snd_pmac_wait_ack(struct pmac_stream *rec) { int timeout = 50000; while ((in_le32(&rec->dma->status) & RUN) && timeout-- > 0) @@ -165,7 +165,7 @@ snd_pmac_wait_ack(pmac_stream_t *rec) * set the format and rate to the chip. * call the lowlevel function if defined (e.g. for AWACS). */ -static void snd_pmac_pcm_set_format(pmac_t *chip) +static void snd_pmac_pcm_set_format(struct snd_pmac *chip) { /* set up frequency and format */ out_le32(&chip->awacs->control, chip->control_mask | (chip->rate_index << 8)); @@ -177,7 +177,7 @@ static void snd_pmac_pcm_set_format(pmac_t *chip) /* * stop the DMA transfer */ -static inline void snd_pmac_dma_stop(pmac_stream_t *rec) +static inline void snd_pmac_dma_stop(struct pmac_stream *rec) { out_le32(&rec->dma->control, (RUN|WAKE|FLUSH|PAUSE) << 16); snd_pmac_wait_ack(rec); @@ -186,7 +186,7 @@ static inline void snd_pmac_dma_stop(pmac_stream_t *rec) /* * set the command pointer address */ -static inline void snd_pmac_dma_set_command(pmac_stream_t *rec, pmac_dbdma_t *cmd) +static inline void snd_pmac_dma_set_command(struct pmac_stream *rec, struct pmac_dbdma *cmd) { out_le32(&rec->dma->cmdptr, cmd->addr); } @@ -194,7 +194,7 @@ static inline void snd_pmac_dma_set_command(pmac_stream_t *rec, pmac_dbdma_t *cm /* * start the DMA */ -static inline void snd_pmac_dma_run(pmac_stream_t *rec, int status) +static inline void snd_pmac_dma_run(struct pmac_stream *rec, int status) { out_le32(&rec->dma->control, status | (status << 16)); } @@ -203,14 +203,14 @@ static inline void snd_pmac_dma_run(pmac_stream_t *rec, int status) /* * prepare playback/capture stream */ -static int snd_pmac_pcm_prepare(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substream_t *subs) +static int snd_pmac_pcm_prepare(struct snd_pmac *chip, struct pmac_stream *rec, struct snd_pcm_substream *subs) { int i; volatile struct dbdma_cmd __iomem *cp; - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; int rate_index; long offset; - pmac_stream_t *astr; + struct pmac_stream *astr; rec->dma_size = snd_pcm_lib_buffer_bytes(subs); rec->period_size = snd_pcm_lib_period_bytes(subs); @@ -267,8 +267,8 @@ static int snd_pmac_pcm_prepare(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substr /* * PCM trigger/stop */ -static int snd_pmac_pcm_trigger(pmac_t *chip, pmac_stream_t *rec, - snd_pcm_substream_t *subs, int cmd) +static int snd_pmac_pcm_trigger(struct snd_pmac *chip, struct pmac_stream *rec, + struct snd_pcm_substream *subs, int cmd) { volatile struct dbdma_cmd __iomem *cp; int i, command; @@ -314,8 +314,9 @@ static int snd_pmac_pcm_trigger(pmac_t *chip, pmac_stream_t *rec, * return the current pointer */ inline -static snd_pcm_uframes_t snd_pmac_pcm_pointer(pmac_t *chip, pmac_stream_t *rec, - snd_pcm_substream_t *subs) +static snd_pcm_uframes_t snd_pmac_pcm_pointer(struct snd_pmac *chip, + struct pmac_stream *rec, + struct snd_pcm_substream *subs) { int count = 0; @@ -338,22 +339,22 @@ static snd_pcm_uframes_t snd_pmac_pcm_pointer(pmac_t *chip, pmac_stream_t *rec, * playback */ -static int snd_pmac_playback_prepare(snd_pcm_substream_t *subs) +static int snd_pmac_playback_prepare(struct snd_pcm_substream *subs) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); return snd_pmac_pcm_prepare(chip, &chip->playback, subs); } -static int snd_pmac_playback_trigger(snd_pcm_substream_t *subs, +static int snd_pmac_playback_trigger(struct snd_pcm_substream *subs, int cmd) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); return snd_pmac_pcm_trigger(chip, &chip->playback, subs, cmd); } -static snd_pcm_uframes_t snd_pmac_playback_pointer(snd_pcm_substream_t *subs) +static snd_pcm_uframes_t snd_pmac_playback_pointer(struct snd_pcm_substream *subs) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); return snd_pmac_pcm_pointer(chip, &chip->playback, subs); } @@ -362,22 +363,22 @@ static snd_pcm_uframes_t snd_pmac_playback_pointer(snd_pcm_substream_t *subs) * capture */ -static int snd_pmac_capture_prepare(snd_pcm_substream_t *subs) +static int snd_pmac_capture_prepare(struct snd_pcm_substream *subs) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); return snd_pmac_pcm_prepare(chip, &chip->capture, subs); } -static int snd_pmac_capture_trigger(snd_pcm_substream_t *subs, +static int snd_pmac_capture_trigger(struct snd_pcm_substream *subs, int cmd) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); return snd_pmac_pcm_trigger(chip, &chip->capture, subs, cmd); } -static snd_pcm_uframes_t snd_pmac_capture_pointer(snd_pcm_substream_t *subs) +static snd_pcm_uframes_t snd_pmac_capture_pointer(struct snd_pcm_substream *subs) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); return snd_pmac_pcm_pointer(chip, &chip->capture, subs); } @@ -385,7 +386,7 @@ static snd_pcm_uframes_t snd_pmac_capture_pointer(snd_pcm_substream_t *subs) /* * update playback/capture pointer from interrupts */ -static void snd_pmac_pcm_update(pmac_t *chip, pmac_stream_t *rec) +static void snd_pmac_pcm_update(struct snd_pmac *chip, struct pmac_stream *rec) { volatile struct dbdma_cmd __iomem *cp; int c; @@ -421,7 +422,7 @@ static void snd_pmac_pcm_update(pmac_t *chip, pmac_stream_t *rec) * hw info */ -static snd_pcm_hardware_t snd_pmac_playback = +static struct snd_pcm_hardware snd_pmac_playback = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | @@ -440,7 +441,7 @@ static snd_pcm_hardware_t snd_pmac_playback = .periods_max = PMAC_MAX_FRAGS, }; -static snd_pcm_hardware_t snd_pmac_capture = +static struct snd_pcm_hardware snd_pmac_capture = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP | @@ -461,11 +462,11 @@ static snd_pcm_hardware_t snd_pmac_capture = #if 0 // NYI -static int snd_pmac_hw_rule_rate(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pmac_hw_rule_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - pmac_t *chip = rule->private; - pmac_stream_t *rec = snd_pmac_get_stream(chip, rule->deps[0]); + struct snd_pmac *chip = rule->private; + struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]); int i, freq_table[8], num_freqs; if (! rec) @@ -480,11 +481,11 @@ static int snd_pmac_hw_rule_rate(snd_pcm_hw_params_t *params, num_freqs, freq_table, 0); } -static int snd_pmac_hw_rule_format(snd_pcm_hw_params_t *params, - snd_pcm_hw_rule_t *rule) +static int snd_pmac_hw_rule_format(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) { - pmac_t *chip = rule->private; - pmac_stream_t *rec = snd_pmac_get_stream(chip, rule->deps[0]); + struct snd_pmac *chip = rule->private; + struct pmac_stream *rec = snd_pmac_get_stream(chip, rule->deps[0]); if (! rec) return -EINVAL; @@ -493,9 +494,10 @@ static int snd_pmac_hw_rule_format(snd_pcm_hw_params_t *params, } #endif // NYI -static int snd_pmac_pcm_open(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substream_t *subs) +static int snd_pmac_pcm_open(struct snd_pmac *chip, struct pmac_stream *rec, + struct snd_pcm_substream *subs) { - snd_pcm_runtime_t *runtime = subs->runtime; + struct snd_pcm_runtime *runtime = subs->runtime; int i, j, fflags; static int typical_freqs[] = { 44100, @@ -565,9 +567,10 @@ static int snd_pmac_pcm_open(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substream return 0; } -static int snd_pmac_pcm_close(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substream_t *subs) +static int snd_pmac_pcm_close(struct snd_pmac *chip, struct pmac_stream *rec, + struct snd_pcm_substream *subs) { - pmac_stream_t *astr; + struct pmac_stream *astr; snd_pmac_dma_stop(rec); @@ -582,32 +585,32 @@ static int snd_pmac_pcm_close(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substrea return 0; } -static int snd_pmac_playback_open(snd_pcm_substream_t *subs) +static int snd_pmac_playback_open(struct snd_pcm_substream *subs) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); subs->runtime->hw = snd_pmac_playback; return snd_pmac_pcm_open(chip, &chip->playback, subs); } -static int snd_pmac_capture_open(snd_pcm_substream_t *subs) +static int snd_pmac_capture_open(struct snd_pcm_substream *subs) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); subs->runtime->hw = snd_pmac_capture; return snd_pmac_pcm_open(chip, &chip->capture, subs); } -static int snd_pmac_playback_close(snd_pcm_substream_t *subs) +static int snd_pmac_playback_close(struct snd_pcm_substream *subs) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); return snd_pmac_pcm_close(chip, &chip->playback, subs); } -static int snd_pmac_capture_close(snd_pcm_substream_t *subs) +static int snd_pmac_capture_close(struct snd_pcm_substream *subs) { - pmac_t *chip = snd_pcm_substream_chip(subs); + struct snd_pmac *chip = snd_pcm_substream_chip(subs); return snd_pmac_pcm_close(chip, &chip->capture, subs); } @@ -615,7 +618,7 @@ static int snd_pmac_capture_close(snd_pcm_substream_t *subs) /* */ -static snd_pcm_ops_t snd_pmac_playback_ops = { +static struct snd_pcm_ops snd_pmac_playback_ops = { .open = snd_pmac_playback_open, .close = snd_pmac_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -626,7 +629,7 @@ static snd_pcm_ops_t snd_pmac_playback_ops = { .pointer = snd_pmac_playback_pointer, }; -static snd_pcm_ops_t snd_pmac_capture_ops = { +static struct snd_pcm_ops snd_pmac_capture_ops = { .open = snd_pmac_capture_open, .close = snd_pmac_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -637,9 +640,9 @@ static snd_pcm_ops_t snd_pmac_capture_ops = { .pointer = snd_pmac_capture_pointer, }; -int __init snd_pmac_pcm_new(pmac_t *chip) +int __init snd_pmac_pcm_new(struct snd_pmac *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; int num_captures = 1; @@ -676,7 +679,7 @@ int __init snd_pmac_pcm_new(pmac_t *chip) } -static void snd_pmac_dbdma_reset(pmac_t *chip) +static void snd_pmac_dbdma_reset(struct snd_pmac *chip) { out_le32(&chip->playback.dma->control, (RUN|PAUSE|FLUSH|WAKE|DEAD) << 16); snd_pmac_wait_ack(&chip->playback); @@ -688,9 +691,9 @@ static void snd_pmac_dbdma_reset(pmac_t *chip) /* * handling beep */ -void snd_pmac_beep_dma_start(pmac_t *chip, int bytes, unsigned long addr, int speed) +void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed) { - pmac_stream_t *rec = &chip->playback; + struct pmac_stream *rec = &chip->playback; snd_pmac_dma_stop(rec); st_le16(&chip->extra_dma.cmds->req_count, bytes); @@ -706,7 +709,7 @@ void snd_pmac_beep_dma_start(pmac_t *chip, int bytes, unsigned long addr, int sp snd_pmac_dma_run(rec, RUN); } -void snd_pmac_beep_dma_stop(pmac_t *chip) +void snd_pmac_beep_dma_stop(struct snd_pmac *chip) { snd_pmac_dma_stop(&chip->playback); st_le16(&chip->extra_dma.cmds->command, DBDMA_STOP); @@ -720,7 +723,7 @@ void snd_pmac_beep_dma_stop(pmac_t *chip) static irqreturn_t snd_pmac_tx_intr(int irq, void *devid, struct pt_regs *regs) { - pmac_t *chip = devid; + struct snd_pmac *chip = devid; snd_pmac_pcm_update(chip, &chip->playback); return IRQ_HANDLED; } @@ -729,7 +732,7 @@ snd_pmac_tx_intr(int irq, void *devid, struct pt_regs *regs) static irqreturn_t snd_pmac_rx_intr(int irq, void *devid, struct pt_regs *regs) { - pmac_t *chip = devid; + struct snd_pmac *chip = devid; snd_pmac_pcm_update(chip, &chip->capture); return IRQ_HANDLED; } @@ -738,7 +741,7 @@ snd_pmac_rx_intr(int irq, void *devid, struct pt_regs *regs) static irqreturn_t snd_pmac_ctrl_intr(int irq, void *devid, struct pt_regs *regs) { - pmac_t *chip = devid; + struct snd_pmac *chip = devid; int ctrl = in_le32(&chip->awacs->control); /*printk("pmac: control interrupt.. 0x%x\n", ctrl);*/ @@ -761,7 +764,7 @@ snd_pmac_ctrl_intr(int irq, void *devid, struct pt_regs *regs) /* * a wrapper to feature call for compatibility */ -static void snd_pmac_sound_feature(pmac_t *chip, int enable) +static void snd_pmac_sound_feature(struct snd_pmac *chip, int enable) { if (ppc_md.feature_call) ppc_md.feature_call(PMAC_FTR_SOUND_CHIP_ENABLE, chip->node, 0, enable); @@ -771,7 +774,7 @@ static void snd_pmac_sound_feature(pmac_t *chip, int enable) * release resources */ -static int snd_pmac_free(pmac_t *chip) +static int snd_pmac_free(struct snd_pmac *chip) { /* stop sounds */ if (chip->initialized) { @@ -836,9 +839,9 @@ static int snd_pmac_free(pmac_t *chip) /* * free the device */ -static int snd_pmac_dev_free(snd_device_t *device) +static int snd_pmac_dev_free(struct snd_device *device) { - pmac_t *chip = device->device_data; + struct snd_pmac *chip = device->device_data; return snd_pmac_free(chip); } @@ -847,7 +850,7 @@ static int snd_pmac_dev_free(snd_device_t *device) * check the machine support byteswap (little-endian) */ -static void __init detect_byte_swap(pmac_t *chip) +static void __init detect_byte_swap(struct snd_pmac *chip) { struct device_node *mio; @@ -873,7 +876,7 @@ static void __init detect_byte_swap(pmac_t *chip) /* * detect a sound chip */ -static int __init snd_pmac_detect(pmac_t *chip) +static int __init snd_pmac_detect(struct snd_pmac *chip) { struct device_node *sound = NULL; unsigned int *prop, l; @@ -1061,8 +1064,8 @@ static int __init snd_pmac_detect(pmac_t *chip) /* * exported - boolean info callbacks for ease of programming */ -int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +int snd_pmac_boolean_stereo_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -1071,8 +1074,8 @@ int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, return 0; } -int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol, - snd_ctl_elem_info_t *uinfo) +int snd_pmac_boolean_mono_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -1085,16 +1088,18 @@ int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol, /* * auto-mute */ -static int pmac_auto_mute_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pmac_auto_mute_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); ucontrol->value.integer.value[0] = chip->auto_mute; return 0; } -static int pmac_auto_mute_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pmac_auto_mute_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); if (ucontrol->value.integer.value[0] != chip->auto_mute) { chip->auto_mute = ucontrol->value.integer.value[0]; if (chip->update_automute) @@ -1104,9 +1109,10 @@ static int pmac_auto_mute_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc return 0; } -static int pmac_hp_detect_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int pmac_hp_detect_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); if (chip->detect_headphone) ucontrol->value.integer.value[0] = chip->detect_headphone(chip); else @@ -1114,7 +1120,7 @@ static int pmac_hp_detect_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc return 0; } -static snd_kcontrol_new_t auto_mute_controls[] __initdata = { +static struct snd_kcontrol_new auto_mute_controls[] __initdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Auto Mute Switch", .info = snd_pmac_boolean_mono_info, @@ -1129,7 +1135,7 @@ static snd_kcontrol_new_t auto_mute_controls[] __initdata = { }, }; -int __init snd_pmac_add_automute(pmac_t *chip) +int __init snd_pmac_add_automute(struct snd_pmac *chip) { int err; chip->auto_mute = 1; @@ -1146,13 +1152,13 @@ int __init snd_pmac_add_automute(pmac_t *chip) /* * create and detect a pmac chip record */ -int __init snd_pmac_new(snd_card_t *card, pmac_t **chip_return) +int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) { - pmac_t *chip; + struct snd_pmac *chip; struct device_node *np; int i, err; unsigned long ctrl_addr, txdma_addr, rxdma_addr; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_pmac_dev_free, }; @@ -1322,9 +1328,9 @@ int __init snd_pmac_new(snd_card_t *card, pmac_t **chip_return) * Save state when going to sleep, restore it afterwards. */ -static int snd_pmac_suspend(snd_card_t *card, pm_message_t state) +static int snd_pmac_suspend(struct snd_card *card, pm_message_t state) { - pmac_t *chip = card->pm_private_data; + struct snd_pmac *chip = card->pm_private_data; unsigned long flags; if (chip->suspend) @@ -1343,9 +1349,9 @@ static int snd_pmac_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_pmac_resume(snd_card_t *card) +static int snd_pmac_resume(struct snd_card *card) { - pmac_t *chip = card->pm_private_data; + struct snd_pmac *chip = card->pm_private_data; snd_pmac_sound_feature(chip, 1); if (chip->resume) @@ -1372,11 +1378,11 @@ static int snd_pmac_resume(snd_card_t *card) /* the chip is stored statically by snd_pmac_register_sleep_notifier * because we can't have any private data for notify callback. */ -static pmac_t *sleeping_pmac = NULL; +static struct snd_pmac *sleeping_pmac = NULL; static int snd_pmac_sleep_notify(struct pmu_sleep_notifier *self, int when) { - pmac_t *chip; + struct snd_pmac *chip; chip = sleeping_pmac; if (! chip) @@ -1397,7 +1403,7 @@ static struct pmu_sleep_notifier snd_pmac_sleep_notifier = { snd_pmac_sleep_notify, SLEEP_LEVEL_SOUND, }; -static int __init snd_pmac_register_sleep_notifier(pmac_t *chip) +static int __init snd_pmac_register_sleep_notifier(struct snd_pmac *chip) { /* should be protected here.. */ snd_assert(! sleeping_pmac, return -EBUSY); @@ -1406,7 +1412,7 @@ static int __init snd_pmac_register_sleep_notifier(pmac_t *chip) return 0; } -static int snd_pmac_unregister_sleep_notifier(pmac_t *chip) +static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip) { /* should be protected here.. */ snd_assert(sleeping_pmac == chip, return -ENODEV); diff --git a/sound/ppc/pmac.h b/sound/ppc/pmac.h index bfff788..e223884 100644 --- a/sound/ppc/pmac.h +++ b/sound/ppc/pmac.h @@ -47,18 +47,9 @@ #define PMAC_SUPPORT_AUTOMUTE /* - * typedefs - */ -typedef struct snd_pmac pmac_t; -typedef struct snd_pmac_stream pmac_stream_t; -typedef struct snd_pmac_beep pmac_beep_t; -typedef struct snd_pmac_dbdma pmac_dbdma_t; - - -/* * DBDMA space */ -struct snd_pmac_dbdma { +struct pmac_dbdma { dma_addr_t dma_base; dma_addr_t addr; struct dbdma_cmd __iomem *cmds; @@ -69,7 +60,7 @@ struct snd_pmac_dbdma { /* * playback/capture stream */ -struct snd_pmac_stream { +struct pmac_stream { int running; /* boolean */ int stream; /* PLAYBACK/CAPTURE */ @@ -79,10 +70,10 @@ struct snd_pmac_stream { int buffer_size; /* in kbytes */ int nperiods, cur_period; - pmac_dbdma_t cmd; + struct pmac_dbdma cmd; volatile struct dbdma_regs __iomem *dma; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; unsigned int cur_freqs; /* currently available frequencies */ unsigned int cur_formats; /* currently available formats */ @@ -98,7 +89,7 @@ enum snd_pmac_model { }; struct snd_pmac { - snd_card_t *card; + struct snd_card *card; /* h/w info */ struct device_node *node; @@ -140,75 +131,75 @@ struct snd_pmac { unsigned char __iomem *latch_base; unsigned char __iomem *macio_base; - pmac_stream_t playback; - pmac_stream_t capture; + struct pmac_stream playback; + struct pmac_stream capture; - pmac_dbdma_t extra_dma; + struct pmac_dbdma extra_dma; int irq, tx_irq, rx_irq; - snd_pcm_t *pcm; + struct snd_pcm *pcm; - pmac_beep_t *beep; + struct pmac_beep *beep; unsigned int control_mask; /* control mask */ /* mixer stuffs */ void *mixer_data; - void (*mixer_free)(pmac_t *); - snd_kcontrol_t *master_sw_ctl; - snd_kcontrol_t *speaker_sw_ctl; - snd_kcontrol_t *drc_sw_ctl; /* only used for tumbler -ReneR */ - snd_kcontrol_t *hp_detect_ctl; - snd_kcontrol_t *lineout_sw_ctl; + void (*mixer_free)(struct snd_pmac *); + struct snd_kcontrol *master_sw_ctl; + struct snd_kcontrol *speaker_sw_ctl; + struct snd_kcontrol *drc_sw_ctl; /* only used for tumbler -ReneR */ + struct snd_kcontrol *hp_detect_ctl; + struct snd_kcontrol *lineout_sw_ctl; /* lowlevel callbacks */ - void (*set_format)(pmac_t *chip); - void (*update_automute)(pmac_t *chip, int do_notify); - int (*detect_headphone)(pmac_t *chip); + void (*set_format)(struct snd_pmac *chip); + void (*update_automute)(struct snd_pmac *chip, int do_notify); + int (*detect_headphone)(struct snd_pmac *chip); #ifdef CONFIG_PM - void (*suspend)(pmac_t *chip); - void (*resume)(pmac_t *chip); + void (*suspend)(struct snd_pmac *chip); + void (*resume)(struct snd_pmac *chip); #endif }; /* exported functions */ -int snd_pmac_new(snd_card_t *card, pmac_t **chip_return); -int snd_pmac_pcm_new(pmac_t *chip); -int snd_pmac_attach_beep(pmac_t *chip); -void snd_pmac_detach_beep(pmac_t *chip); -void snd_pmac_beep_stop(pmac_t *chip); -unsigned int snd_pmac_rate_index(pmac_t *chip, pmac_stream_t *rec, unsigned int rate); +int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return); +int snd_pmac_pcm_new(struct snd_pmac *chip); +int snd_pmac_attach_beep(struct snd_pmac *chip); +void snd_pmac_detach_beep(struct snd_pmac *chip); +void snd_pmac_beep_stop(struct snd_pmac *chip); +unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate); -void snd_pmac_beep_dma_start(pmac_t *chip, int bytes, unsigned long addr, int speed); -void snd_pmac_beep_dma_stop(pmac_t *chip); +void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed); +void snd_pmac_beep_dma_stop(struct snd_pmac *chip); /* initialize mixer */ -int snd_pmac_awacs_init(pmac_t *chip); -int snd_pmac_burgundy_init(pmac_t *chip); -int snd_pmac_daca_init(pmac_t *chip); -int snd_pmac_tumbler_init(pmac_t *chip); +int snd_pmac_awacs_init(struct snd_pmac *chip); +int snd_pmac_burgundy_init(struct snd_pmac *chip); +int snd_pmac_daca_init(struct snd_pmac *chip); +int snd_pmac_tumbler_init(struct snd_pmac *chip); int snd_pmac_tumbler_post_init(void); -int snd_pmac_toonie_init(pmac_t *chip); +int snd_pmac_toonie_init(struct snd_pmac *chip); /* i2c functions */ -typedef struct snd_pmac_keywest { +struct pmac_keywest { int addr; struct i2c_client *client; int id; - int (*init_client)(struct snd_pmac_keywest *i2c); + int (*init_client)(struct pmac_keywest *i2c); char *name; -} pmac_keywest_t; +}; -int snd_pmac_keywest_init(pmac_keywest_t *i2c); -void snd_pmac_keywest_cleanup(pmac_keywest_t *i2c); +int snd_pmac_keywest_init(struct pmac_keywest *i2c); +void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c); /* misc */ -int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo); -int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo); +int snd_pmac_boolean_stereo_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); +int snd_pmac_boolean_mono_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo); -int snd_pmac_add_automute(pmac_t *chip); +int snd_pmac_add_automute(struct snd_pmac *chip); #endif /* __PMAC_H */ diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index a6d8cbf..db139cd 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c @@ -49,15 +49,15 @@ MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); * card entry */ -static snd_card_t *snd_pmac_card = NULL; +static struct snd_card *snd_pmac_card = NULL; /* */ static int __init snd_pmac_probe(void) { - snd_card_t *card; - pmac_t *chip; + struct snd_card *card; + struct snd_pmac *chip; char *name_ext; int err; diff --git a/sound/ppc/toonie.c b/sound/ppc/toonie.c index 082bc4b..053b8f2 100644 --- a/sound/ppc/toonie.c +++ b/sound/ppc/toonie.c @@ -101,10 +101,10 @@ static int read_audio_gpio(struct pmac_gpio *gp) enum { TOONIE_MUTE_HP, TOONIE_MUTE_AMP }; -static int toonie_get_mute_switch(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int toonie_get_mute_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct pmac_toonie *mix = chip->mixer_data; struct pmac_gpio *gp; @@ -124,10 +124,10 @@ static int toonie_get_mute_switch(snd_kcontrol_t *kcontrol, return 0; } -static int toonie_put_mute_switch(snd_kcontrol_t *kcontrol, - snd_ctl_elem_value_t *ucontrol) +static int toonie_put_mute_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); struct pmac_toonie *mix = chip->mixer_data; struct pmac_gpio *gp; int val; @@ -156,7 +156,7 @@ static int toonie_put_mute_switch(snd_kcontrol_t *kcontrol, return 0; } -static snd_kcontrol_new_t toonie_hp_sw __initdata = { +static struct snd_kcontrol_new toonie_hp_sw __initdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Playback Switch", .info = snd_pmac_boolean_mono_info, @@ -164,7 +164,7 @@ static snd_kcontrol_new_t toonie_hp_sw __initdata = { .put = toonie_put_mute_switch, .private_value = TOONIE_MUTE_HP, }; -static snd_kcontrol_new_t toonie_speaker_sw __initdata = { +static struct snd_kcontrol_new toonie_speaker_sw __initdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PC Speaker Playback Switch", .info = snd_pmac_boolean_mono_info, @@ -176,7 +176,7 @@ static snd_kcontrol_new_t toonie_speaker_sw __initdata = { /* * auto-mute stuffs */ -static int toonie_detect_headphone(pmac_t *chip) +static int toonie_detect_headphone(struct snd_pmac *chip) { struct pmac_toonie *mix = chip->mixer_data; int detect = 0; @@ -186,8 +186,8 @@ static int toonie_detect_headphone(pmac_t *chip) return detect; } -static void toonie_check_mute(pmac_t *chip, struct pmac_gpio *gp, int val, - int do_notify, snd_kcontrol_t *sw) +static void toonie_check_mute(struct snd_pmac *chip, struct pmac_gpio *gp, int val, + int do_notify, struct snd_kcontrol *sw) { if (check_audio_gpio(gp) != val) { write_audio_gpio(gp, val); @@ -199,7 +199,7 @@ static void toonie_check_mute(pmac_t *chip, struct pmac_gpio *gp, int val, static void toonie_detect_handler(void *self) { - pmac_t *chip = (pmac_t*) self; + struct snd_pmac *chip = (struct snd_pmac *) self; struct pmac_toonie *mix; int headphone; @@ -232,7 +232,7 @@ static void toonie_detect_handler(void *self) } } -static void toonie_update_automute(pmac_t *chip, int do_notify) +static void toonie_update_automute(struct snd_pmac *chip, int do_notify) { if (chip->auto_mute) { struct pmac_toonie *mix; @@ -246,7 +246,7 @@ static void toonie_update_automute(pmac_t *chip, int do_notify) /* interrupt - headphone plug changed */ static irqreturn_t toonie_hp_intr(int irq, void *devid, struct pt_regs *regs) { - pmac_t *chip = devid; + struct snd_pmac *chip = devid; if (chip->update_automute && chip->initialized) { chip->update_automute(chip, 1); @@ -325,7 +325,7 @@ static int find_audio_gpio(const char *name, const char *platform, return (np->n_intrs > 0) ? np->intrs[0].line : 0; } -static void toonie_cleanup(pmac_t *chip) +static void toonie_cleanup(struct snd_pmac *chip) { struct pmac_toonie *mix = chip->mixer_data; if (! mix) @@ -336,7 +336,7 @@ static void toonie_cleanup(pmac_t *chip) chip->mixer_data = NULL; } -int snd_pmac_toonie_init(pmac_t *chip) +int snd_pmac_toonie_init(struct snd_pmac *chip) { struct pmac_toonie *mix; diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c index d74bfab..15c63cb 100644 --- a/sound/ppc/tumbler.c +++ b/sound/ppc/tumbler.c @@ -82,21 +82,21 @@ enum { VOL_IDX_LAST_MIX }; -typedef struct pmac_gpio { +struct pmac_gpio { unsigned int addr; u8 active_val; u8 inactive_val; u8 active_state; -} pmac_gpio_t; - -typedef struct pmac_tumbler_t { - pmac_keywest_t i2c; - pmac_gpio_t audio_reset; - pmac_gpio_t amp_mute; - pmac_gpio_t line_mute; - pmac_gpio_t line_detect; - pmac_gpio_t hp_mute; - pmac_gpio_t hp_detect; +}; + +struct pmac_tumbler { + struct pmac_keywest i2c; + struct pmac_gpio audio_reset; + struct pmac_gpio amp_mute; + struct pmac_gpio line_mute; + struct pmac_gpio line_detect; + struct pmac_gpio hp_mute; + struct pmac_gpio hp_detect; int headphone_irq; int lineout_irq; unsigned int save_master_vol[2]; @@ -112,13 +112,13 @@ typedef struct pmac_tumbler_t { int auto_mute_notify; int reset_on_sleep; u8 acs; -} pmac_tumbler_t; +}; /* */ -static int send_init_client(pmac_keywest_t *i2c, unsigned int *regs) +static int send_init_client(struct pmac_keywest *i2c, unsigned int *regs) { while (*regs > 0) { int err, count = 10; @@ -138,7 +138,7 @@ static int send_init_client(pmac_keywest_t *i2c, unsigned int *regs) } -static int tumbler_init_client(pmac_keywest_t *i2c) +static int tumbler_init_client(struct pmac_keywest *i2c) { static unsigned int regs[] = { /* normal operation, SCLK=64fps, i2s output, i2s input, 16bit width */ @@ -149,7 +149,7 @@ static int tumbler_init_client(pmac_keywest_t *i2c) return send_init_client(i2c, regs); } -static int snapper_init_client(pmac_keywest_t *i2c) +static int snapper_init_client(struct pmac_keywest *i2c) { static unsigned int regs[] = { /* normal operation, SCLK=64fps, i2s output, 16bit width */ @@ -173,7 +173,7 @@ static int snapper_init_client(pmac_keywest_t *i2c) pmac_call_feature(PMAC_FTR_READ_GPIO, NULL, (gp)->addr, 0) #define tumbler_gpio_free(gp) /* NOP */ -static void write_audio_gpio(pmac_gpio_t *gp, int active) +static void write_audio_gpio(struct pmac_gpio *gp, int active) { if (! gp->addr) return; @@ -182,7 +182,7 @@ static void write_audio_gpio(pmac_gpio_t *gp, int active) DBG("(I) gpio %x write %d\n", gp->addr, active); } -static int check_audio_gpio(pmac_gpio_t *gp) +static int check_audio_gpio(struct pmac_gpio *gp) { int ret; @@ -194,7 +194,7 @@ static int check_audio_gpio(pmac_gpio_t *gp) return (ret & 0xd) == (gp->active_val & 0xd); } -static int read_audio_gpio(pmac_gpio_t *gp) +static int read_audio_gpio(struct pmac_gpio *gp) { int ret; if (! gp->addr) @@ -206,7 +206,7 @@ static int read_audio_gpio(pmac_gpio_t *gp) /* * update master volume */ -static int tumbler_set_master_volume(pmac_tumbler_t *mix) +static int tumbler_set_master_volume(struct pmac_tumbler *mix) { unsigned char block[6]; unsigned int left_vol, right_vol; @@ -249,7 +249,8 @@ static int tumbler_set_master_volume(pmac_tumbler_t *mix) /* output volume */ -static int tumbler_info_master_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int tumbler_info_master_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -258,20 +259,22 @@ static int tumbler_info_master_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_inf return 0; } -static int tumbler_get_master_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_get_master_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix = chip->mixer_data; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix = chip->mixer_data; snd_assert(mix, return -ENODEV); ucontrol->value.integer.value[0] = mix->master_vol[0]; ucontrol->value.integer.value[1] = mix->master_vol[1]; return 0; } -static int tumbler_put_master_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_put_master_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix = chip->mixer_data; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix = chip->mixer_data; int change; snd_assert(mix, return -ENODEV); @@ -286,20 +289,22 @@ static int tumbler_put_master_volume(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu } /* output switch */ -static int tumbler_get_master_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_get_master_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix = chip->mixer_data; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix = chip->mixer_data; snd_assert(mix, return -ENODEV); ucontrol->value.integer.value[0] = mix->master_switch[0]; ucontrol->value.integer.value[1] = mix->master_switch[1]; return 0; } -static int tumbler_put_master_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_put_master_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix = chip->mixer_data; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix = chip->mixer_data; int change; snd_assert(mix, return -ENODEV); @@ -320,7 +325,7 @@ static int tumbler_put_master_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_valu #define TAS3001_DRC_MAX 0x5f -static int tumbler_set_drc(pmac_tumbler_t *mix) +static int tumbler_set_drc(struct pmac_tumbler *mix) { unsigned char val[2]; @@ -354,7 +359,7 @@ static int tumbler_set_drc(pmac_tumbler_t *mix) #define TAS3004_DRC_MAX 0xef -static int snapper_set_drc(pmac_tumbler_t *mix) +static int snapper_set_drc(struct pmac_tumbler *mix) { unsigned char val[6]; @@ -384,9 +389,10 @@ static int snapper_set_drc(pmac_tumbler_t *mix) return 0; } -static int tumbler_info_drc_value(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int tumbler_info_drc_value(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 1; uinfo->value.integer.min = 0; @@ -395,20 +401,22 @@ static int tumbler_info_drc_value(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t return 0; } -static int tumbler_get_drc_value(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_get_drc_value(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; if (! (mix = chip->mixer_data)) return -ENODEV; ucontrol->value.integer.value[0] = mix->drc_range; return 0; } -static int tumbler_put_drc_value(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_put_drc_value(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; int change; if (! (mix = chip->mixer_data)) @@ -424,20 +432,22 @@ static int tumbler_put_drc_value(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t return change; } -static int tumbler_get_drc_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_get_drc_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; if (! (mix = chip->mixer_data)) return -ENODEV; ucontrol->value.integer.value[0] = mix->drc_enable; return 0; } -static int tumbler_put_drc_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_put_drc_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; int change; if (! (mix = chip->mixer_data)) @@ -466,7 +476,8 @@ struct tumbler_mono_vol { unsigned int *table; }; -static int tumbler_set_mono_volume(pmac_tumbler_t *mix, struct tumbler_mono_vol *info) +static int tumbler_set_mono_volume(struct pmac_tumbler *mix, + struct tumbler_mono_vol *info) { unsigned char block[4]; unsigned int vol; @@ -489,7 +500,8 @@ static int tumbler_set_mono_volume(pmac_tumbler_t *mix, struct tumbler_mono_vol return 0; } -static int tumbler_info_mono(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int tumbler_info_mono(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { struct tumbler_mono_vol *info = (struct tumbler_mono_vol *)kcontrol->private_value; @@ -500,22 +512,24 @@ static int tumbler_info_mono(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinf return 0; } -static int tumbler_get_mono(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_get_mono(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct tumbler_mono_vol *info = (struct tumbler_mono_vol *)kcontrol->private_value; - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; if (! (mix = chip->mixer_data)) return -ENODEV; ucontrol->value.integer.value[0] = mix->mono_vol[info->index]; return 0; } -static int tumbler_put_mono(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_put_mono(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { struct tumbler_mono_vol *info = (struct tumbler_mono_vol *)kcontrol->private_value; - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; int change; if (! (mix = chip->mixer_data)) @@ -594,7 +608,7 @@ static struct tumbler_mono_vol snapper_treble_vol_info = { * snapper mixer volumes */ -static int snapper_set_mix_vol1(pmac_tumbler_t *mix, int idx, int ch, int reg) +static int snapper_set_mix_vol1(struct pmac_tumbler *mix, int idx, int ch, int reg) { int i, j, vol; unsigned char block[9]; @@ -618,7 +632,7 @@ static int snapper_set_mix_vol1(pmac_tumbler_t *mix, int idx, int ch, int reg) return 0; } -static int snapper_set_mix_vol(pmac_tumbler_t *mix, int idx) +static int snapper_set_mix_vol(struct pmac_tumbler *mix, int idx) { if (! mix->i2c.client) return -ENODEV; @@ -628,7 +642,8 @@ static int snapper_set_mix_vol(pmac_tumbler_t *mix, int idx) return 0; } -static int snapper_info_mix(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snapper_info_mix(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -637,11 +652,12 @@ static int snapper_info_mix(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo return 0; } -static int snapper_get_mix(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snapper_get_mix(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int idx = (int)kcontrol->private_value; - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; if (! (mix = chip->mixer_data)) return -ENODEV; ucontrol->value.integer.value[0] = mix->mix_vol[idx][0]; @@ -649,11 +665,12 @@ static int snapper_get_mix(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont return 0; } -static int snapper_put_mix(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snapper_put_mix(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { int idx = (int)kcontrol->private_value; - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; int change; if (! (mix = chip->mixer_data)) @@ -676,11 +693,12 @@ static int snapper_put_mix(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucont enum { TUMBLER_MUTE_HP, TUMBLER_MUTE_AMP, TUMBLER_MUTE_LINE }; -static int tumbler_get_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_get_mute_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; - pmac_gpio_t *gp; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; + struct pmac_gpio *gp; if (! (mix = chip->mixer_data)) return -ENODEV; switch(kcontrol->private_value) { @@ -699,11 +717,12 @@ static int tumbler_get_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return 0; } -static int tumbler_put_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int tumbler_put_mute_switch(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix; - pmac_gpio_t *gp; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix; + struct pmac_gpio *gp; int val; #ifdef PMAC_SUPPORT_AUTOMUTE if (chip->update_automute && chip->auto_mute) @@ -731,7 +750,7 @@ static int tumbler_put_mute_switch(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_ return 0; } -static int snapper_set_capture_source(pmac_tumbler_t *mix) +static int snapper_set_capture_source(struct pmac_tumbler *mix) { if (! mix->i2c.client) return -ENODEV; @@ -742,7 +761,8 @@ static int snapper_set_capture_source(pmac_tumbler_t *mix) return i2c_smbus_write_byte_data(mix->i2c.client, TAS_REG_ACS, mix->acs); } -static int snapper_info_capture_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snapper_info_capture_source(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "Line", "Mic" @@ -756,20 +776,22 @@ static int snapper_info_capture_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_in return 0; } -static int snapper_get_capture_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snapper_get_capture_source(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix = chip->mixer_data; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix = chip->mixer_data; snd_assert(mix, return -ENODEV); ucontrol->value.integer.value[0] = mix->capture_source; return 0; } -static int snapper_put_capture_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snapper_put_capture_source(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - pmac_t *chip = snd_kcontrol_chip(kcontrol); - pmac_tumbler_t *mix = chip->mixer_data; + struct snd_pmac *chip = snd_kcontrol_chip(kcontrol); + struct pmac_tumbler *mix = chip->mixer_data; int change; snd_assert(mix, return -ENODEV); @@ -794,7 +816,7 @@ static int snapper_put_capture_source(snd_kcontrol_t *kcontrol, snd_ctl_elem_val /* */ -static snd_kcontrol_new_t tumbler_mixers[] __initdata = { +static struct snd_kcontrol_new tumbler_mixers[] __initdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Volume", .info = tumbler_info_master_volume, @@ -818,7 +840,7 @@ static snd_kcontrol_new_t tumbler_mixers[] __initdata = { }, }; -static snd_kcontrol_new_t snapper_mixers[] __initdata = { +static struct snd_kcontrol_new snapper_mixers[] __initdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Master Playback Volume", .info = tumbler_info_master_volume, @@ -850,7 +872,7 @@ static snd_kcontrol_new_t snapper_mixers[] __initdata = { }, }; -static snd_kcontrol_new_t tumbler_hp_sw __initdata = { +static struct snd_kcontrol_new tumbler_hp_sw __initdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Headphone Playback Switch", .info = snd_pmac_boolean_mono_info, @@ -858,7 +880,7 @@ static snd_kcontrol_new_t tumbler_hp_sw __initdata = { .put = tumbler_put_mute_switch, .private_value = TUMBLER_MUTE_HP, }; -static snd_kcontrol_new_t tumbler_speaker_sw __initdata = { +static struct snd_kcontrol_new tumbler_speaker_sw __initdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "PC Speaker Playback Switch", .info = snd_pmac_boolean_mono_info, @@ -866,7 +888,7 @@ static snd_kcontrol_new_t tumbler_speaker_sw __initdata = { .put = tumbler_put_mute_switch, .private_value = TUMBLER_MUTE_AMP, }; -static snd_kcontrol_new_t tumbler_lineout_sw __initdata = { +static struct snd_kcontrol_new tumbler_lineout_sw __initdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Line Out Playback Switch", .info = snd_pmac_boolean_mono_info, @@ -874,7 +896,7 @@ static snd_kcontrol_new_t tumbler_lineout_sw __initdata = { .put = tumbler_put_mute_switch, .private_value = TUMBLER_MUTE_LINE, }; -static snd_kcontrol_new_t tumbler_drc_sw __initdata = { +static struct snd_kcontrol_new tumbler_drc_sw __initdata = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "DRC Switch", .info = snd_pmac_boolean_mono_info, @@ -887,9 +909,9 @@ static snd_kcontrol_new_t tumbler_drc_sw __initdata = { /* * auto-mute stuffs */ -static int tumbler_detect_headphone(pmac_t *chip) +static int tumbler_detect_headphone(struct snd_pmac *chip) { - pmac_tumbler_t *mix = chip->mixer_data; + struct pmac_tumbler *mix = chip->mixer_data; int detect = 0; if (mix->hp_detect.addr) @@ -897,9 +919,9 @@ static int tumbler_detect_headphone(pmac_t *chip) return detect; } -static int tumbler_detect_lineout(pmac_t *chip) +static int tumbler_detect_lineout(struct snd_pmac *chip) { - pmac_tumbler_t *mix = chip->mixer_data; + struct pmac_tumbler *mix = chip->mixer_data; int detect = 0; if (mix->line_detect.addr) @@ -907,7 +929,8 @@ static int tumbler_detect_lineout(pmac_t *chip) return detect; } -static void check_mute(pmac_t *chip, pmac_gpio_t *gp, int val, int do_notify, snd_kcontrol_t *sw) +static void check_mute(struct snd_pmac *chip, struct pmac_gpio *gp, int val, int do_notify, + struct snd_kcontrol *sw) { if (check_audio_gpio(gp) != val) { write_audio_gpio(gp, val); @@ -921,8 +944,8 @@ static struct work_struct device_change; static void device_change_handler(void *self) { - pmac_t *chip = (pmac_t*) self; - pmac_tumbler_t *mix; + struct snd_pmac *chip = self; + struct pmac_tumbler *mix; int headphone, lineout; if (!chip) @@ -979,10 +1002,10 @@ static void device_change_handler(void *self) tumbler_set_master_volume(mix); } -static void tumbler_update_automute(pmac_t *chip, int do_notify) +static void tumbler_update_automute(struct snd_pmac *chip, int do_notify) { if (chip->auto_mute) { - pmac_tumbler_t *mix; + struct pmac_tumbler *mix; mix = chip->mixer_data; snd_assert(mix, return); mix->auto_mute_notify = do_notify; @@ -995,7 +1018,7 @@ static void tumbler_update_automute(pmac_t *chip, int do_notify) /* interrupt - headphone plug changed */ static irqreturn_t headphone_intr(int irq, void *devid, struct pt_regs *regs) { - pmac_t *chip = devid; + struct snd_pmac *chip = devid; if (chip->update_automute && chip->initialized) { chip->update_automute(chip, 1); return IRQ_HANDLED; @@ -1035,7 +1058,8 @@ static struct device_node *find_compatible_audio_device(const char *name) } /* find an audio device and get its address */ -static long tumbler_find_device(const char *device, const char *platform, pmac_gpio_t *gp, int is_compatible) +static long tumbler_find_device(const char *device, const char *platform, + struct pmac_gpio *gp, int is_compatible) { struct device_node *node; u32 *base, addr; @@ -1101,9 +1125,9 @@ static long tumbler_find_device(const char *device, const char *platform, pmac_g } /* reset audio */ -static void tumbler_reset_audio(pmac_t *chip) +static void tumbler_reset_audio(struct snd_pmac *chip) { - pmac_tumbler_t *mix = chip->mixer_data; + struct pmac_tumbler *mix = chip->mixer_data; if (mix->anded_reset) { DBG("(I) codec anded reset !\n"); @@ -1130,9 +1154,9 @@ static void tumbler_reset_audio(pmac_t *chip) #ifdef CONFIG_PM /* suspend mixer */ -static void tumbler_suspend(pmac_t *chip) +static void tumbler_suspend(struct snd_pmac *chip) { - pmac_tumbler_t *mix = chip->mixer_data; + struct pmac_tumbler *mix = chip->mixer_data; if (mix->headphone_irq >= 0) disable_irq(mix->headphone_irq); @@ -1160,9 +1184,9 @@ static void tumbler_suspend(pmac_t *chip) } /* resume mixer */ -static void tumbler_resume(pmac_t *chip) +static void tumbler_resume(struct snd_pmac *chip) { - pmac_tumbler_t *mix = chip->mixer_data; + struct pmac_tumbler *mix = chip->mixer_data; snd_assert(mix, return); @@ -1208,10 +1232,10 @@ static void tumbler_resume(pmac_t *chip) #endif /* initialize tumbler */ -static int __init tumbler_init(pmac_t *chip) +static int __init tumbler_init(struct snd_pmac *chip) { int irq; - pmac_tumbler_t *mix = chip->mixer_data; + struct pmac_tumbler *mix = chip->mixer_data; snd_assert(mix, return -EINVAL); if (tumbler_find_device("audio-hw-reset", @@ -1259,9 +1283,9 @@ static int __init tumbler_init(pmac_t *chip) return 0; } -static void tumbler_cleanup(pmac_t *chip) +static void tumbler_cleanup(struct snd_pmac *chip) { - pmac_tumbler_t *mix = chip->mixer_data; + struct pmac_tumbler *mix = chip->mixer_data; if (! mix) return; @@ -1279,10 +1303,10 @@ static void tumbler_cleanup(pmac_t *chip) } /* exported */ -int __init snd_pmac_tumbler_init(pmac_t *chip) +int __init snd_pmac_tumbler_init(struct snd_pmac *chip) { int i, err; - pmac_tumbler_t *mix; + struct pmac_tumbler *mix; u32 *paddr; struct device_node *tas_node, *np; char *chipname; -- cgit v1.1 From ceb9e476c89f50e9ba7de914bbec2c05e9647915 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:10:16 +0100 Subject: [ALSA] Remove xxx_t typedefs: ARM AACI Modules: ARM AACI PL041 driver,ARM DMA routines Remove xxx_t typedefs from the ARM AACI driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/arm/aaci.c | 72 +++++++++++++++++++++++++++--------------------------- sound/arm/aaci.h | 6 ++--- sound/arm/devdma.c | 12 ++++----- sound/arm/devdma.h | 6 ++--- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 559ead6..691f6dd 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -40,7 +40,7 @@ */ #undef CONFIG_PM -static void aaci_ac97_select_codec(struct aaci *aaci, ac97_t *ac97) +static void aaci_ac97_select_codec(struct aaci *aaci, struct snd_ac97 *ac97) { u32 v, maincr = aaci->maincr | MAINCR_SCRA(ac97->num); @@ -65,7 +65,7 @@ static void aaci_ac97_select_codec(struct aaci *aaci, ac97_t *ac97) * SI1TxEn, SI2TxEn and SI12TxEn bits are set in the AACI_MAINCR * register. */ -static void aaci_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { struct aaci *aaci = ac97->private_data; u32 v; @@ -97,7 +97,7 @@ static void aaci_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val /* * Read an AC'97 register. */ -static unsigned short aaci_ac97_read(ac97_t *ac97, unsigned short reg) +static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { struct aaci *aaci = ac97->private_data; u32 v; @@ -284,11 +284,11 @@ static unsigned int rate_list[] = { * (unimplemented) */ static int -aaci_rule_rate_by_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule) +aaci_rule_rate_by_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule) { struct aaci *aaci = rule->private; unsigned int rate_mask = SNDRV_PCM_RATE_8000_48000|SNDRV_PCM_RATE_5512; - snd_interval_t *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *c = hw_param_interval(p, SNDRV_PCM_HW_PARAM_CHANNELS); switch (c->max) { case 6: @@ -304,7 +304,7 @@ aaci_rule_rate_by_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule) rate_mask); } -static snd_pcm_hardware_t aaci_hw_info = { +static struct snd_pcm_hardware aaci_hw_info = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -330,10 +330,10 @@ static snd_pcm_hardware_t aaci_hw_info = { .periods_max = PAGE_SIZE / 16, }; -static int aaci_pcm_open(struct aaci *aaci, snd_pcm_substream_t *substream, +static int aaci_pcm_open(struct aaci *aaci, struct snd_pcm_substream *substream, struct aaci_runtime *aacirun) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int ret; aacirun->substream = substream; @@ -375,7 +375,7 @@ static int aaci_pcm_open(struct aaci *aaci, snd_pcm_substream_t *substream, /* * Common ALSA stuff */ -static int aaci_pcm_close(snd_pcm_substream_t *substream) +static int aaci_pcm_close(struct snd_pcm_substream *substream) { struct aaci *aaci = substream->private_data; struct aaci_runtime *aacirun = substream->runtime->private_data; @@ -388,7 +388,7 @@ static int aaci_pcm_close(snd_pcm_substream_t *substream) return 0; } -static int aaci_pcm_hw_free(snd_pcm_substream_t *substream) +static int aaci_pcm_hw_free(struct snd_pcm_substream *substream) { struct aaci_runtime *aacirun = substream->runtime->private_data; @@ -409,9 +409,9 @@ static int aaci_pcm_hw_free(snd_pcm_substream_t *substream) return 0; } -static int aaci_pcm_hw_params(snd_pcm_substream_t *substream, +static int aaci_pcm_hw_params(struct snd_pcm_substream *substream, struct aaci_runtime *aacirun, - snd_pcm_hw_params_t *params) + struct snd_pcm_hw_params *params) { int err; @@ -434,9 +434,9 @@ static int aaci_pcm_hw_params(snd_pcm_substream_t *substream, return err; } -static int aaci_pcm_prepare(snd_pcm_substream_t *substream) +static int aaci_pcm_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct aaci_runtime *aacirun = runtime->private_data; aacirun->start = (void *)runtime->dma_area; @@ -448,16 +448,16 @@ static int aaci_pcm_prepare(snd_pcm_substream_t *substream) return 0; } -static snd_pcm_uframes_t aaci_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t aaci_pcm_pointer(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct aaci_runtime *aacirun = runtime->private_data; ssize_t bytes = aacirun->ptr - aacirun->start; return bytes_to_frames(runtime, bytes); } -static int aaci_pcm_mmap(snd_pcm_substream_t *substream, struct vm_area_struct *vma) +static int aaci_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma) { return devdma_mmap(NULL, substream, vma); } @@ -484,7 +484,7 @@ static const u32 channels_to_txmask[] = { static unsigned int channel_list[] = { 2, 4, 6 }; static int -aaci_rule_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule) +aaci_rule_channels(struct snd_pcm_hw_params *p, struct snd_pcm_hw_rule *rule) { struct aaci *aaci = rule->private; unsigned int chan_mask = 1 << 0, slots; @@ -504,7 +504,7 @@ aaci_rule_channels(snd_pcm_hw_params_t *p, snd_pcm_hw_rule_t *rule) chan_mask); } -static int aaci_pcm_playback_open(snd_pcm_substream_t *substream) +static int aaci_pcm_playback_open(struct snd_pcm_substream *substream) { struct aaci *aaci = substream->private_data; int ret; @@ -522,8 +522,8 @@ static int aaci_pcm_playback_open(snd_pcm_substream_t *substream) return aaci_pcm_open(aaci, substream, &aaci->playback); } -static int aaci_pcm_playback_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +static int aaci_pcm_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { struct aaci *aaci = substream->private_data; struct aaci_runtime *aacirun = substream->runtime->private_data; @@ -575,7 +575,7 @@ static void aaci_pcm_playback_start(struct aaci_runtime *aacirun) writel(aacirun->cr, aacirun->base + AACI_TXCR); } -static int aaci_pcm_playback_trigger(snd_pcm_substream_t *substream, int cmd) +static int aaci_pcm_playback_trigger(struct snd_pcm_substream *substream, int cmd) { struct aaci *aaci = substream->private_data; struct aaci_runtime *aacirun = substream->runtime->private_data; @@ -614,7 +614,7 @@ static int aaci_pcm_playback_trigger(snd_pcm_substream_t *substream, int cmd) return ret; } -static snd_pcm_ops_t aaci_playback_ops = { +static struct snd_pcm_ops aaci_playback_ops = { .open = aaci_pcm_playback_open, .close = aaci_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -632,7 +632,7 @@ static snd_pcm_ops_t aaci_playback_ops = { * Power Management. */ #ifdef CONFIG_PM -static int aaci_do_suspend(snd_card_t *card, unsigned int state) +static int aaci_do_suspend(struct snd_card *card, unsigned int state) { struct aaci *aaci = card->private_data; if (aaci->card->power_state != SNDRV_CTL_POWER_D3cold) { @@ -642,7 +642,7 @@ static int aaci_do_suspend(snd_card_t *card, unsigned int state) return 0; } -static int aaci_do_resume(snd_card_t *card, unsigned int state) +static int aaci_do_resume(struct snd_card *card, unsigned int state) { struct aaci *aaci = card->private_data; if (aaci->card->power_state != SNDRV_CTL_POWER_D0) { @@ -653,13 +653,13 @@ static int aaci_do_resume(snd_card_t *card, unsigned int state) static int aaci_suspend(struct amba_device *dev, pm_message_t state) { - snd_card_t *card = amba_get_drvdata(dev); + struct snd_card *card = amba_get_drvdata(dev); return card ? aaci_do_suspend(card) : 0; } static int aaci_resume(struct amba_device *dev) { - snd_card_t *card = amba_get_drvdata(dev); + struct snd_card *card = amba_get_drvdata(dev); return card ? aaci_do_resume(card) : 0; } #else @@ -705,16 +705,16 @@ static struct ac97_pcm ac97_defs[] __devinitdata = { } }; -static ac97_bus_ops_t aaci_bus_ops = { +static struct snd_ac97_bus_ops aaci_bus_ops = { .write = aaci_ac97_write, .read = aaci_ac97_read, }; static int __devinit aaci_probe_ac97(struct aaci *aaci) { - ac97_template_t ac97_template; - ac97_bus_t *ac97_bus; - ac97_t *ac97; + struct snd_ac97_template ac97_template; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97 *ac97; int ret; /* @@ -737,7 +737,7 @@ static int __devinit aaci_probe_ac97(struct aaci *aaci) ac97_bus->clock = 48000; aaci->ac97_bus = ac97_bus; - memset(&ac97_template, 0, sizeof(ac97_template_t)); + memset(&ac97_template, 0, sizeof(struct snd_ac97_template)); ac97_template.private_data = aaci; ac97_template.num = 0; ac97_template.scaps = AC97_SCAP_SKIP_MODEM; @@ -762,7 +762,7 @@ static int __devinit aaci_probe_ac97(struct aaci *aaci) return ret; } -static void aaci_free_card(snd_card_t *card) +static void aaci_free_card(struct snd_card *card) { struct aaci *aaci = card->private_data; if (aaci->base) @@ -772,7 +772,7 @@ static void aaci_free_card(snd_card_t *card) static struct aaci * __devinit aaci_init_card(struct amba_device *dev) { struct aaci *aaci; - snd_card_t *card; + struct snd_card *card; card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, THIS_MODULE, sizeof(struct aaci)); @@ -803,7 +803,7 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev) static int __devinit aaci_init_pcm(struct aaci *aaci) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int ret; ret = snd_pcm_new(aaci->card, "AACI AC'97", 0, 1, 0, &pcm); @@ -920,7 +920,7 @@ static int __devinit aaci_probe(struct amba_device *dev, void *id) static int __devexit aaci_remove(struct amba_device *dev) { - snd_card_t *card = amba_get_drvdata(dev); + struct snd_card *card = amba_get_drvdata(dev); amba_set_drvdata(dev, NULL); diff --git a/sound/arm/aaci.h b/sound/arm/aaci.h index b2f969b..83f73c2 100644 --- a/sound/arm/aaci.h +++ b/sound/arm/aaci.h @@ -207,7 +207,7 @@ struct aaci_runtime { int pcm_open; u32 cr; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; /* * PIO support @@ -222,7 +222,7 @@ struct aaci_runtime { struct aaci { struct amba_device *dev; - snd_card_t *card; + struct snd_card *card; void __iomem *base; unsigned int fifosize; @@ -236,7 +236,7 @@ struct aaci { struct aaci_runtime playback; struct aaci_runtime capture; - snd_pcm_t *pcm; + struct snd_pcm *pcm; }; #define ACSTREAM_FRONT 0 diff --git a/sound/arm/devdma.c b/sound/arm/devdma.c index 60826a5..ca3bf4e 100644 --- a/sound/arm/devdma.c +++ b/sound/arm/devdma.c @@ -18,9 +18,9 @@ #include "devdma.h" -void devdma_hw_free(struct device *dev, snd_pcm_substream_t *substream) +void devdma_hw_free(struct device *dev, struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_dma_buffer *buf = runtime->dma_buffer_p; if (runtime->dma_area == NULL) @@ -34,9 +34,9 @@ void devdma_hw_free(struct device *dev, snd_pcm_substream_t *substream) snd_pcm_set_runtime_buffer(substream, NULL); } -int devdma_hw_alloc(struct device *dev, snd_pcm_substream_t *substream, size_t size) +int devdma_hw_alloc(struct device *dev, struct snd_pcm_substream *substream, size_t size) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct snd_dma_buffer *buf = runtime->dma_buffer_p; int ret = 0; @@ -74,8 +74,8 @@ int devdma_hw_alloc(struct device *dev, snd_pcm_substream_t *substream, size_t s return -ENOMEM; } -int devdma_mmap(struct device *dev, snd_pcm_substream_t *substream, struct vm_area_struct *vma) +int devdma_mmap(struct device *dev, struct snd_pcm_substream *substream, struct vm_area_struct *vma) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; return dma_mmap_coherent(dev, vma, runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); } diff --git a/sound/arm/devdma.h b/sound/arm/devdma.h index 5a33b6b..d025329 100644 --- a/sound/arm/devdma.h +++ b/sound/arm/devdma.h @@ -1,3 +1,3 @@ -void devdma_hw_free(struct device *dev, snd_pcm_substream_t *substream); -int devdma_hw_alloc(struct device *dev, snd_pcm_substream_t *substream, size_t size); -int devdma_mmap(struct device *dev, snd_pcm_substream_t *substream, struct vm_area_struct *vma); +void devdma_hw_free(struct device *dev, struct snd_pcm_substream *substream); +int devdma_hw_alloc(struct device *dev, struct snd_pcm_substream *substream, size_t size); +int devdma_mmap(struct device *dev, struct snd_pcm_substream *substream, struct vm_area_struct *vma); -- cgit v1.1 From d18f83764e376dea9e14a8ac53d1e14004fa9c13 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:10:38 +0100 Subject: [ALSA] Remove xxx_t typedefs: ARM PXA2xx Modules: ARM PXA2XX driver Remove xxx_t typedefs from the ARM PXA2xx driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/arm/pxa2xx-ac97.c | 44 ++++++++++++++++++------------------ sound/arm/pxa2xx-pcm.c | 59 +++++++++++++++++++++++++------------------------ sound/arm/pxa2xx-pcm.h | 20 ++++++++--------- 3 files changed, 62 insertions(+), 61 deletions(-) diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index c96c8a2..d9efc37 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c @@ -37,7 +37,7 @@ static DECLARE_MUTEX(car_mutex); static DECLARE_WAIT_QUEUE_HEAD(gsr_wq); static volatile long gsr_bits; -static unsigned short pxa2xx_ac97_read(ac97_t *ac97, unsigned short reg) +static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { unsigned short val = -1; volatile u32 *reg_addr; @@ -75,7 +75,7 @@ out: up(&car_mutex); return val; } -static void pxa2xx_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { volatile u32 *reg_addr; @@ -99,7 +99,7 @@ static void pxa2xx_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short v out: up(&car_mutex); } -static void pxa2xx_ac97_reset(ac97_t *ac97) +static void pxa2xx_ac97_reset(struct snd_ac97 *ac97) { /* First, try cold reset */ GCR &= GCR_COLD_RST; /* clear everything but nCRST */ @@ -172,13 +172,13 @@ static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id, struct pt_regs *regs) return IRQ_NONE; } -static ac97_bus_ops_t pxa2xx_ac97_ops = { +static struct snd_ac97_bus_ops pxa2xx_ac97_ops = { .read = pxa2xx_ac97_read, .write = pxa2xx_ac97_write, .reset = pxa2xx_ac97_reset, }; -static pxa2xx_pcm_dma_params_t pxa2xx_ac97_pcm_out = { +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_out = { .name = "AC97 PCM out", .dev_addr = __PREG(PCDR), .drcmr = &DRCMRTXPCDR, @@ -186,7 +186,7 @@ static pxa2xx_pcm_dma_params_t pxa2xx_ac97_pcm_out = { DCMD_BURST32 | DCMD_WIDTH4, }; -static pxa2xx_pcm_dma_params_t pxa2xx_ac97_pcm_in = { +static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_in = { .name = "AC97 PCM in", .dev_addr = __PREG(PCDR), .drcmr = &DRCMRRXPCDR, @@ -194,12 +194,12 @@ static pxa2xx_pcm_dma_params_t pxa2xx_ac97_pcm_in = { DCMD_BURST32 | DCMD_WIDTH4, }; -static snd_pcm_t *pxa2xx_ac97_pcm; -static ac97_t *pxa2xx_ac97_ac97; +static struct snd_pcm *pxa2xx_ac97_pcm; +static struct snd_ac97 *pxa2xx_ac97_ac97; -static int pxa2xx_ac97_pcm_startup(snd_pcm_substream_t *substream) +static int pxa2xx_ac97_pcm_startup(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; pxa2xx_audio_ops_t *platform_ops; int r; @@ -218,7 +218,7 @@ static int pxa2xx_ac97_pcm_startup(snd_pcm_substream_t *substream) return 0; } -static void pxa2xx_ac97_pcm_shutdown(snd_pcm_substream_t *substream) +static void pxa2xx_ac97_pcm_shutdown(struct snd_pcm_substream *substream) { pxa2xx_audio_ops_t *platform_ops; @@ -227,15 +227,15 @@ static void pxa2xx_ac97_pcm_shutdown(snd_pcm_substream_t *substream) platform_ops->shutdown(substream, platform_ops->priv); } -static int pxa2xx_ac97_pcm_prepare(snd_pcm_substream_t *substream) +static int pxa2xx_ac97_pcm_prepare(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; return snd_ac97_set_rate(pxa2xx_ac97_ac97, reg, runtime->rate); } -static pxa2xx_pcm_client_t pxa2xx_ac97_pcm_client = { +static struct pxa2xx_pcm_client pxa2xx_ac97_pcm_client = { .playback_params = &pxa2xx_ac97_pcm_out, .capture_params = &pxa2xx_ac97_pcm_in, .startup = pxa2xx_ac97_pcm_startup, @@ -245,7 +245,7 @@ static pxa2xx_pcm_client_t pxa2xx_ac97_pcm_client = { #ifdef CONFIG_PM -static int pxa2xx_ac97_do_suspend(snd_card_t *card, pm_message_t state) +static int pxa2xx_ac97_do_suspend(struct snd_card *card, pm_message_t state) { if (card->power_state != SNDRV_CTL_POWER_D3cold) { pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; @@ -261,7 +261,7 @@ static int pxa2xx_ac97_do_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int pxa2xx_ac97_do_resume(snd_card_t *card) +static int pxa2xx_ac97_do_resume(struct snd_card *card) { if (card->power_state != SNDRV_CTL_POWER_D0) { pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; @@ -277,7 +277,7 @@ static int pxa2xx_ac97_do_resume(snd_card_t *card) static int pxa2xx_ac97_suspend(struct platform_device *dev, pm_message_t state) { - snd_card_t *card = platform_get_drvdata(dev); + struct snd_card *card = platform_get_drvdata(dev); int ret = 0; if (card) @@ -288,7 +288,7 @@ static int pxa2xx_ac97_suspend(struct platform_device *dev, pm_message_t state) static int pxa2xx_ac97_resume(struct platform_device *dev) { - snd_card_t *card = platform_get_drvdata(dev); + struct snd_card *card = platform_get_drvdata(dev); int ret = 0; if (card) @@ -304,9 +304,9 @@ static int pxa2xx_ac97_resume(struct platform_device *dev) static int pxa2xx_ac97_probe(struct platform_device *dev) { - snd_card_t *card; - ac97_bus_t *ac97_bus; - ac97_template_t ac97_template; + struct snd_card *card; + struct snd_ac97_bus *ac97_bus; + struct snd_ac97_template ac97_template; int ret; ret = -ENOMEM; @@ -370,7 +370,7 @@ static int pxa2xx_ac97_probe(struct platform_device *dev) static int pxa2xx_ac97_remove(struct platform_device *dev) { - snd_card_t *card = platform_get_drvdata(dev); + struct snd_card *card = platform_get_drvdata(dev); if (card) { snd_card_free(card); diff --git a/sound/arm/pxa2xx-pcm.c b/sound/arm/pxa2xx-pcm.c index b1eb53b..4938ef1 100644 --- a/sound/arm/pxa2xx-pcm.c +++ b/sound/arm/pxa2xx-pcm.c @@ -28,7 +28,7 @@ #include "pxa2xx-pcm.h" -static const snd_pcm_hardware_t pxa2xx_pcm_hardware = { +static const struct snd_pcm_hardware pxa2xx_pcm_hardware = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_INTERLEAVED | @@ -44,15 +44,15 @@ static const snd_pcm_hardware_t pxa2xx_pcm_hardware = { struct pxa2xx_runtime_data { int dma_ch; - pxa2xx_pcm_dma_params_t *params; + struct pxa2xx_pcm_dma_params *params; pxa_dma_desc *dma_desc_array; dma_addr_t dma_desc_array_phys; }; -static int pxa2xx_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *params) +static int pxa2xx_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct pxa2xx_runtime_data *rtd = runtime->private_data; size_t totsize = params_buffer_bytes(params); size_t period = params_period_bytes(params); @@ -86,7 +86,7 @@ static int pxa2xx_pcm_hw_params(snd_pcm_substream_t *substream, return 0; } -static int pxa2xx_pcm_hw_free(snd_pcm_substream_t *substream) +static int pxa2xx_pcm_hw_free(struct snd_pcm_substream *substream) { struct pxa2xx_runtime_data *rtd = substream->runtime->private_data; @@ -95,10 +95,10 @@ static int pxa2xx_pcm_hw_free(snd_pcm_substream_t *substream) return 0; } -static int pxa2xx_pcm_prepare(snd_pcm_substream_t *substream) +static int pxa2xx_pcm_prepare(struct snd_pcm_substream *substream) { - pxa2xx_pcm_client_t *client = substream->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct pxa2xx_pcm_client *client = substream->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; struct pxa2xx_runtime_data *rtd = runtime->private_data; DCSR(rtd->dma_ch) &= ~DCSR_RUN; @@ -109,7 +109,7 @@ static int pxa2xx_pcm_prepare(snd_pcm_substream_t *substream) return client->prepare(substream); } -static int pxa2xx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) +static int pxa2xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct pxa2xx_runtime_data *rtd = substream->runtime->private_data; int ret = 0; @@ -139,7 +139,7 @@ static int pxa2xx_pcm_trigger(snd_pcm_substream_t *substream, int cmd) static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id, struct pt_regs *regs) { - snd_pcm_substream_t *substream = dev_id; + struct snd_pcm_substream *substream = dev_id; struct pxa2xx_runtime_data *rtd = substream->runtime->private_data; int dcsr; @@ -155,9 +155,9 @@ static void pxa2xx_pcm_dma_irq(int dma_ch, void *dev_id, struct pt_regs *regs) } } -static snd_pcm_uframes_t pxa2xx_pcm_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t pxa2xx_pcm_pointer(struct snd_pcm_substream *substream) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; struct pxa2xx_runtime_data *rtd = runtime->private_data; dma_addr_t ptr = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? DSADR(rtd->dma_ch) : DTADR(rtd->dma_ch); @@ -168,9 +168,9 @@ static snd_pcm_uframes_t pxa2xx_pcm_pointer(snd_pcm_substream_t *substream) } static int -pxa2xx_pcm_hw_rule_mult32(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t *rule) +pxa2xx_pcm_hw_rule_mult32(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { - snd_interval_t *i = hw_param_interval(params, rule->var); + struct snd_interval *i = hw_param_interval(params, rule->var); int changed = 0; if (i->min & 31) { @@ -188,10 +188,10 @@ pxa2xx_pcm_hw_rule_mult32(snd_pcm_hw_params_t *params, snd_pcm_hw_rule_t *rule) return changed; } -static int pxa2xx_pcm_open(snd_pcm_substream_t *substream) +static int pxa2xx_pcm_open(struct snd_pcm_substream *substream) { - pxa2xx_pcm_client_t *client = substream->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct pxa2xx_pcm_client *client = substream->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; struct pxa2xx_runtime_data *rtd; int ret; @@ -246,9 +246,9 @@ static int pxa2xx_pcm_open(snd_pcm_substream_t *substream) return ret; } -static int pxa2xx_pcm_close(snd_pcm_substream_t *substream) +static int pxa2xx_pcm_close(struct snd_pcm_substream *substream) { - pxa2xx_pcm_client_t *client = substream->private_data; + struct pxa2xx_pcm_client *client = substream->private_data; struct pxa2xx_runtime_data *rtd = substream->runtime->private_data; pxa_free_dma(rtd->dma_ch); @@ -260,16 +260,16 @@ static int pxa2xx_pcm_close(snd_pcm_substream_t *substream) } static int -pxa2xx_pcm_mmap(snd_pcm_substream_t *substream, struct vm_area_struct *vma) +pxa2xx_pcm_mmap(struct snd_pcm_substream *substream, struct vm_area_struct *vma) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; return dma_mmap_writecombine(substream->pcm->card->dev, vma, runtime->dma_area, runtime->dma_addr, runtime->dma_bytes); } -static snd_pcm_ops_t pxa2xx_pcm_ops = { +static struct snd_pcm_ops pxa2xx_pcm_ops = { .open = pxa2xx_pcm_open, .close = pxa2xx_pcm_close, .ioctl = snd_pcm_lib_ioctl, @@ -281,9 +281,9 @@ static snd_pcm_ops_t pxa2xx_pcm_ops = { .mmap = pxa2xx_pcm_mmap, }; -static int pxa2xx_pcm_preallocate_dma_buffer(snd_pcm_t *pcm, int stream) +static int pxa2xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) { - snd_pcm_substream_t *substream = pcm->streams[stream].substream; + struct snd_pcm_substream *substream = pcm->streams[stream].substream; struct snd_dma_buffer *buf = &substream->dma_buffer; size_t size = pxa2xx_pcm_hardware.buffer_bytes_max; buf->dev.type = SNDRV_DMA_TYPE_DEV; @@ -297,9 +297,9 @@ static int pxa2xx_pcm_preallocate_dma_buffer(snd_pcm_t *pcm, int stream) return 0; } -static void pxa2xx_pcm_free_dma_buffers(snd_pcm_t *pcm) +static void pxa2xx_pcm_free_dma_buffers(struct snd_pcm *pcm) { - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; struct snd_dma_buffer *buf; int stream; @@ -318,9 +318,10 @@ static void pxa2xx_pcm_free_dma_buffers(snd_pcm_t *pcm) static u64 pxa2xx_pcm_dmamask = 0xffffffff; -int pxa2xx_pcm_new(snd_card_t *card, pxa2xx_pcm_client_t *client, snd_pcm_t **rpcm) +int pxa2xx_pcm_new(struct snd_card *card, struct pxa2xx_pcm_client *client, + struct snd_pcm **rpcm) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int play = client->playback_params ? 1 : 0; int capt = client->capture_params ? 1 : 0; int ret; diff --git a/sound/arm/pxa2xx-pcm.h b/sound/arm/pxa2xx-pcm.h index 4351759..b79f1e8 100644 --- a/sound/arm/pxa2xx-pcm.h +++ b/sound/arm/pxa2xx-pcm.h @@ -10,20 +10,20 @@ * published by the Free Software Foundation. */ -typedef struct { +struct pxa2xx_pcm_dma_params { char *name; /* stream identifier */ u32 dcmd; /* DMA descriptor dcmd field */ volatile u32 *drcmr; /* the DMA request channel to use */ u32 dev_addr; /* device physical address for DMA */ -} pxa2xx_pcm_dma_params_t; +}; -typedef struct { - pxa2xx_pcm_dma_params_t *playback_params; - pxa2xx_pcm_dma_params_t *capture_params; - int (*startup)(snd_pcm_substream_t *); - void (*shutdown)(snd_pcm_substream_t *); - int (*prepare)(snd_pcm_substream_t *); -} pxa2xx_pcm_client_t; +struct pxa2xx_pcm_client { + struct pxa2xx_pcm_dma_params *playback_params; + struct pxa2xx_pcm_dma_params *capture_params; + int (*startup)(struct snd_pcm_substream *); + void (*shutdown)(struct snd_pcm_substream *); + int (*prepare)(struct snd_pcm_substream *); +}; -extern int pxa2xx_pcm_new(snd_card_t *, pxa2xx_pcm_client_t *, snd_pcm_t **); +extern int pxa2xx_pcm_new(struct snd_card *, struct pxa2xx_pcm_client *, struct snd_pcm **); -- cgit v1.1 From af0fbfb58dbb2081ae91789892933321ee95d71f Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:10:58 +0100 Subject: [ALSA] Remove xxx_t typedefs: ARM SA11xx-UDA1341 Modules: SA11xx UDA1341 driver Remove xxx_t typedefs from the ARM SA11xx-UDA1341 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/arm/sa11xx-uda1341.c | 125 ++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 64 deletions(-) diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 97dffcc..785726e 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -21,7 +21,7 @@ * merged HAL layer (patches from Brian) */ -/* $Id: sa11xx-uda1341.c,v 1.24 2005/11/17 10:25:22 tiwai Exp $ */ +/* $Id: sa11xx-uda1341.c,v 1.25 2005/11/17 15:10:58 tiwai Exp $ */ /*************************************************************************************************** * @@ -115,7 +115,7 @@ static char *id = NULL; /* ID for this card */ module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for SA1100/SA1111 + UDA1341TS soundcard."); -typedef struct audio_stream { +struct audio_stream { char *id; /* identification string */ int stream_id; /* numeric identification */ dma_device_t dma_dev; /* device identifier for DMA */ @@ -130,16 +130,16 @@ typedef struct audio_stream { int tx_spin; /* are we recoding - flag used to do DMA trans. for sync */ unsigned int old_offset; spinlock_t dma_lock; /* for locking in DMA operations (see dma-sa1100.c in the kernel) */ - snd_pcm_substream_t *stream; -}audio_stream_t; + struct snd_pcm_substream *stream; +}; -typedef struct snd_card_sa11xx_uda1341 { - snd_card_t *card; +struct sa11xx_uda1341 { + struct snd_card *card; struct l3_client *uda1341; - snd_pcm_t *pcm; + struct snd_pcm *pcm; long samplerate; - audio_stream_t s[2]; /* playback & capture */ -} sa11xx_uda1341_t; + struct audio_stream s[2]; /* playback & capture */ +}; static unsigned int rates[] = { 8000, 10666, 10985, 14647, @@ -147,7 +147,7 @@ static unsigned int rates[] = { 29400, 32000, 44100, 48000, }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = ARRAY_SIZE(rates), .list = rates, .mask = 0, @@ -193,7 +193,7 @@ static void sa11xx_uda1341_set_audio_clock(long val) } } -static void sa11xx_uda1341_set_samplerate(sa11xx_uda1341_t *sa11xx_uda1341, long rate) +static void sa11xx_uda1341_set_samplerate(struct sa11xx_uda1341 *sa11xx_uda1341, long rate) { int clk_div = 0; int clk=0; @@ -278,7 +278,7 @@ static void sa11xx_uda1341_set_samplerate(sa11xx_uda1341_t *sa11xx_uda1341, long /* {{{ HW init and shutdown */ -static void sa11xx_uda1341_audio_init(sa11xx_uda1341_t *sa11xx_uda1341) +static void sa11xx_uda1341_audio_init(struct sa11xx_uda1341 *sa11xx_uda1341) { unsigned long flags; @@ -335,7 +335,7 @@ static void sa11xx_uda1341_audio_init(sa11xx_uda1341_t *sa11xx_uda1341) #endif } -static void sa11xx_uda1341_audio_shutdown(sa11xx_uda1341_t *sa11xx_uda1341) +static void sa11xx_uda1341_audio_shutdown(struct sa11xx_uda1341 *sa11xx_uda1341) { /* mute on */ #ifdef CONFIG_H3600_HAL @@ -376,7 +376,7 @@ static void sa11xx_uda1341_audio_shutdown(sa11xx_uda1341_t *sa11xx_uda1341) #ifdef HH_VERSION -static int audio_dma_request(audio_stream_t *s, void (*callback)(void *, int)) +static int audio_dma_request(struct audio_stream *s, void (*callback)(void *, int)) { int ret; @@ -389,7 +389,7 @@ static int audio_dma_request(audio_stream_t *s, void (*callback)(void *, int)) return 0; } -static inline void audio_dma_free(audio_stream_t *s) +static inline void audio_dma_free(struct audio_stream *s) { sa1100_free_dma(s->dmach); s->dmach = -1; @@ -397,7 +397,7 @@ static inline void audio_dma_free(audio_stream_t *s) #else -static int audio_dma_request(audio_stream_t *s, void (*callback)(void *)) +static int audio_dma_request(struct audio_stream *s, void (*callback)(void *)) { int ret; @@ -407,7 +407,7 @@ static int audio_dma_request(audio_stream_t *s, void (*callback)(void *)) return ret; } -static void audio_dma_free(audio_stream_t *s) +static void audio_dma_free(struct audio_stream *s) { sa1100_free_dma(s->dma_regs); s->dma_regs = 0; @@ -415,10 +415,10 @@ static void audio_dma_free(audio_stream_t *s) #endif -static u_int audio_get_dma_pos(audio_stream_t *s) +static u_int audio_get_dma_pos(struct audio_stream *s) { - snd_pcm_substream_t * substream = s->stream; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_substream *substream = s->stream; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int offset; unsigned long flags; dma_addr_t addr; @@ -443,7 +443,7 @@ static u_int audio_get_dma_pos(audio_stream_t *s) /* * this stops the dma and clears the dma ptrs */ -static void audio_stop_dma(audio_stream_t *s) +static void audio_stop_dma(struct audio_stream *s) { unsigned long flags; @@ -459,10 +459,10 @@ static void audio_stop_dma(audio_stream_t *s) spin_unlock_irqrestore(&s->dma_lock, flags); } -static void audio_process_dma(audio_stream_t *s) +static void audio_process_dma(struct audio_stream *s) { - snd_pcm_substream_t *substream = s->stream; - snd_pcm_runtime_t *runtime; + struct snd_pcm_substream *substream = s->stream; + struct snd_pcm_runtime *runtime; unsigned int dma_size; unsigned int offset; int ret; @@ -525,7 +525,7 @@ static void audio_dma_callback(void *data, int size) static void audio_dma_callback(void *data) #endif { - audio_stream_t *s = data; + struct audio_stream *s = data; /* * If we are getting a callback for an active stream then we inform @@ -547,12 +547,12 @@ static void audio_dma_callback(void *data) /* {{{ trigger & timer */ -static int snd_sa11xx_uda1341_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_sa11xx_uda1341_trigger(struct snd_pcm_substream *substream, int cmd) { - sa11xx_uda1341_t *chip = snd_pcm_substream_chip(substream); + struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream); int stream_id = substream->pstr->stream; - audio_stream_t *s = &chip->s[stream_id]; - audio_stream_t *s1 = &chip->s[stream_id ^ 1]; + struct audio_stream *s = &chip->s[stream_id]; + struct audio_stream *s1 = &chip->s[stream_id ^ 1]; int err = 0; /* note local interrupts are already disabled in the midlevel code */ @@ -681,11 +681,11 @@ static int snd_sa11xx_uda1341_trigger(snd_pcm_substream_t * substream, int cmd) return err; } -static int snd_sa11xx_uda1341_prepare(snd_pcm_substream_t * substream) +static int snd_sa11xx_uda1341_prepare(struct snd_pcm_substream *substream) { - sa11xx_uda1341_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - audio_stream_t *s = &chip->s[substream->pstr->stream]; + struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct audio_stream *s = &chip->s[substream->pstr->stream]; /* set requested samplerate */ sa11xx_uda1341_set_samplerate(chip, runtime->rate); @@ -699,15 +699,15 @@ static int snd_sa11xx_uda1341_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_sa11xx_uda1341_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_sa11xx_uda1341_pointer(struct snd_pcm_substream *substream) { - sa11xx_uda1341_t *chip = snd_pcm_substream_chip(substream); + struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream); return audio_get_dma_pos(&chip->s[substream->pstr->stream]); } /* }}} */ -static snd_pcm_hardware_t snd_sa11xx_uda1341_capture = +static struct snd_pcm_hardware snd_sa11xx_uda1341_capture = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -730,7 +730,7 @@ static snd_pcm_hardware_t snd_sa11xx_uda1341_capture = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_sa11xx_uda1341_playback = +static struct snd_pcm_hardware snd_sa11xx_uda1341_playback = { .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -753,10 +753,10 @@ static snd_pcm_hardware_t snd_sa11xx_uda1341_playback = .fifo_size = 0, }; -static int snd_card_sa11xx_uda1341_open(snd_pcm_substream_t * substream) +static int snd_card_sa11xx_uda1341_open(struct snd_pcm_substream *substream) { - sa11xx_uda1341_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int stream_id = substream->pstr->stream; int err; @@ -774,9 +774,9 @@ static int snd_card_sa11xx_uda1341_open(snd_pcm_substream_t * substream) return 0; } -static int snd_card_sa11xx_uda1341_close(snd_pcm_substream_t * substream) +static int snd_card_sa11xx_uda1341_close(struct snd_pcm_substream *substream) { - sa11xx_uda1341_t *chip = snd_pcm_substream_chip(substream); + struct sa11xx_uda1341 *chip = snd_pcm_substream_chip(substream); chip->s[substream->pstr->stream].stream = NULL; return 0; @@ -784,21 +784,21 @@ static int snd_card_sa11xx_uda1341_close(snd_pcm_substream_t * substream) /* {{{ HW params & free */ -static int snd_sa11xx_uda1341_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_sa11xx_uda1341_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_sa11xx_uda1341_hw_free(snd_pcm_substream_t * substream) +static int snd_sa11xx_uda1341_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } /* }}} */ -static snd_pcm_ops_t snd_card_sa11xx_uda1341_playback_ops = { +static struct snd_pcm_ops snd_card_sa11xx_uda1341_playback_ops = { .open = snd_card_sa11xx_uda1341_open, .close = snd_card_sa11xx_uda1341_close, .ioctl = snd_pcm_lib_ioctl, @@ -809,7 +809,7 @@ static snd_pcm_ops_t snd_card_sa11xx_uda1341_playback_ops = { .pointer = snd_sa11xx_uda1341_pointer, }; -static snd_pcm_ops_t snd_card_sa11xx_uda1341_capture_ops = { +static struct snd_pcm_ops snd_card_sa11xx_uda1341_capture_ops = { .open = snd_card_sa11xx_uda1341_open, .close = snd_card_sa11xx_uda1341_close, .ioctl = snd_pcm_lib_ioctl, @@ -820,9 +820,9 @@ static snd_pcm_ops_t snd_card_sa11xx_uda1341_capture_ops = { .pointer = snd_sa11xx_uda1341_pointer, }; -static int __init snd_card_sa11xx_uda1341_pcm(sa11xx_uda1341_t *sa11xx_uda1341, int device) +static int __init snd_card_sa11xx_uda1341_pcm(struct sa11xx_uda1341 *sa11xx_uda1341, int device) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(sa11xx_uda1341->card, "UDA1341 PCM", device, 1, 1, &pcm)) < 0) @@ -860,9 +860,9 @@ static int __init snd_card_sa11xx_uda1341_pcm(sa11xx_uda1341_t *sa11xx_uda1341, #ifdef CONFIG_PM -static int snd_sa11xx_uda1341_suspend(snd_card_t *card, pm_message_t state) +static int snd_sa11xx_uda1341_suspend(struct snd_card *card, pm_message_t state) { - sa11xx_uda1341_t *chip = card->pm_private_data; + struct sa11xx_uda1341 *chip = card->pm_private_data; snd_pcm_suspend_all(chip->pcm); #ifdef HH_VERSION @@ -876,9 +876,9 @@ static int snd_sa11xx_uda1341_suspend(snd_card_t *card, pm_message_t state) return 0; } -static int snd_sa11xx_uda1341_resume(snd_card_t *card) +static int snd_sa11xx_uda1341_resume(struct snd_card *card) { - sa11xx_uda1341_t *chip = card->pm_private_data; + struct sa11xx_uda1341 *chip = card->pm_private_data; sa11xx_uda1341_audio_init(chip); l3_command(chip->uda1341, CMD_RESUME, NULL); @@ -892,43 +892,40 @@ static int snd_sa11xx_uda1341_resume(snd_card_t *card) } #endif /* COMFIG_PM */ -void snd_sa11xx_uda1341_free(snd_card_t *card) +void snd_sa11xx_uda1341_free(struct snd_card *card) { - sa11xx_uda1341_t *chip = card->private_data; + struct sa11xx_uda1341 *chip = card->private_data; audio_dma_free(&chip->s[SNDRV_PCM_STREAM_PLAYBACK]); audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]); } -static snd_card_t *sa11xx_uda1341_card; +static struct snd_card *sa11xx_uda1341_card; static int __init sa11xx_uda1341_init(void) { int err; - snd_card_t *card; - sa11xx_uda1341_t *chip; + struct snd_card *card; + struct sa11xx_uda1341 *chip; if (!machine_is_h3xxx()) return -ENODEV; /* register the soundcard */ - card = snd_card_new(-1, id, THIS_MODULE, sizeof(sa11xx_uda1341_t)); + card = snd_card_new(-1, id, THIS_MODULE, sizeof(struct sa11xx_uda1341)); if (card == NULL) return -ENOMEM; - sa11xx_uda1341 = kzalloc(sizeof(*sa11xx_uda1341), GFP_KERNEL); - if (sa11xx_uda1341 == NULL) - return -ENOMEM; card->private_free = snd_sa11xx_uda1341_free; chip = card->private_data; spin_lock_init(&chip->s[0].dma_lock); spin_lock_init(&chip->s[1].dma_lock); - + chip->card = card; chip->samplerate = AUDIO_RATE_DEFAULT; // mixer - if ((err = snd_chip_uda1341_mixer_new(chip->card, &sa11xx_uda1341->uda1341))) + if ((err = snd_chip_uda1341_mixer_new(card, &chip->uda1341))) goto nodev; // PCM -- cgit v1.1 From dcc94db78362759931ff538f1579d4a1cec8bd64 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:11:19 +0100 Subject: [ALSA] Remove xxx_t typedefs: SPARC AMD7930 Modules: SPARC AMD7930 driver Remove xxx_t typedefs from the SPARC AMD7930 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/sparc/amd7930.c | 130 +++++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index 7d4b685..c271049 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -311,7 +311,7 @@ struct amd7930_map { #define AMR_PP_PPCR2 0xC8 #define AMR_PP_PPCR3 0xC9 -typedef struct snd_amd7930 { +struct snd_amd7930 { spinlock_t lock; void __iomem *regs; u32 flags; @@ -320,10 +320,10 @@ typedef struct snd_amd7930 { struct amd7930_map map; - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; - snd_pcm_substream_t *capture_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; + struct snd_pcm_substream *capture_substream; /* Playback/Capture buffer state. */ unsigned char *p_orig, *p_cur; @@ -339,12 +339,12 @@ typedef struct snd_amd7930 { unsigned int irq; unsigned int regs_size; struct snd_amd7930 *next; -} amd7930_t; +}; -static amd7930_t *amd7930_list; +static struct snd_amd7930 *amd7930_list; /* Idle the AMD7930 chip. The amd->lock is not held. */ -static __inline__ void amd7930_idle(amd7930_t *amd) +static __inline__ void amd7930_idle(struct snd_amd7930 *amd) { unsigned long flags; @@ -355,7 +355,7 @@ static __inline__ void amd7930_idle(amd7930_t *amd) } /* Enable chip interrupts. The amd->lock is not held. */ -static __inline__ void amd7930_enable_ints(amd7930_t *amd) +static __inline__ void amd7930_enable_ints(struct snd_amd7930 *amd) { unsigned long flags; @@ -366,7 +366,7 @@ static __inline__ void amd7930_enable_ints(amd7930_t *amd) } /* Disable chip interrupts. The amd->lock is not held. */ -static __inline__ void amd7930_disable_ints(amd7930_t *amd) +static __inline__ void amd7930_disable_ints(struct snd_amd7930 *amd) { unsigned long flags; @@ -379,7 +379,7 @@ static __inline__ void amd7930_disable_ints(amd7930_t *amd) /* Commit amd7930_map settings to the hardware. * The amd->lock is held and local interrupts are disabled. */ -static void __amd7930_write_map(amd7930_t *amd) +static void __amd7930_write_map(struct snd_amd7930 *amd) { struct amd7930_map *map = &amd->map; @@ -473,7 +473,7 @@ static __const__ __u16 ger_coeff[] = { /* Update amd7930_map settings and program them into the hardware. * The amd->lock is held and local interrupts are disabled. */ -static void __amd7930_update_map(amd7930_t *amd) +static void __amd7930_update_map(struct snd_amd7930 *amd) { struct amd7930_map *map = &amd->map; int level; @@ -493,7 +493,7 @@ static void __amd7930_update_map(amd7930_t *amd) static irqreturn_t snd_amd7930_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - amd7930_t *amd = dev_id; + struct snd_amd7930 *amd = dev_id; unsigned int elapsed; u8 ir; @@ -534,7 +534,7 @@ static irqreturn_t snd_amd7930_interrupt(int irq, void *dev_id, struct pt_regs * return IRQ_HANDLED; } -static int snd_amd7930_trigger(amd7930_t *amd, unsigned int flag, int cmd) +static int snd_amd7930_trigger(struct snd_amd7930 *amd, unsigned int flag, int cmd) { unsigned long flags; int result = 0; @@ -564,24 +564,24 @@ static int snd_amd7930_trigger(amd7930_t *amd, unsigned int flag, int cmd) return result; } -static int snd_amd7930_playback_trigger(snd_pcm_substream_t * substream, +static int snd_amd7930_playback_trigger(struct snd_pcm_substream *substream, int cmd) { - amd7930_t *amd = snd_pcm_substream_chip(substream); + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); return snd_amd7930_trigger(amd, AMD7930_FLAG_PLAYBACK, cmd); } -static int snd_amd7930_capture_trigger(snd_pcm_substream_t * substream, +static int snd_amd7930_capture_trigger(struct snd_pcm_substream *substream, int cmd) { - amd7930_t *amd = snd_pcm_substream_chip(substream); + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); return snd_amd7930_trigger(amd, AMD7930_FLAG_CAPTURE, cmd); } -static int snd_amd7930_playback_prepare(snd_pcm_substream_t * substream) +static int snd_amd7930_playback_prepare(struct snd_pcm_substream *substream) { - amd7930_t *amd = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned long flags; u8 new_mmr1; @@ -610,10 +610,10 @@ static int snd_amd7930_playback_prepare(snd_pcm_substream_t * substream) return 0; } -static int snd_amd7930_capture_prepare(snd_pcm_substream_t * substream) +static int snd_amd7930_capture_prepare(struct snd_pcm_substream *substream) { - amd7930_t *amd = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned int size = snd_pcm_lib_buffer_bytes(substream); unsigned long flags; u8 new_mmr1; @@ -642,9 +642,9 @@ static int snd_amd7930_capture_prepare(snd_pcm_substream_t * substream) return 0; } -static snd_pcm_uframes_t snd_amd7930_playback_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_amd7930_playback_pointer(struct snd_pcm_substream *substream) { - amd7930_t *amd = snd_pcm_substream_chip(substream); + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); size_t ptr; if (!(amd->flags & AMD7930_FLAG_PLAYBACK)) @@ -653,9 +653,9 @@ static snd_pcm_uframes_t snd_amd7930_playback_pointer(snd_pcm_substream_t * subs return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_amd7930_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_amd7930_capture_pointer(struct snd_pcm_substream *substream) { - amd7930_t *amd = snd_pcm_substream_chip(substream); + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); size_t ptr; if (!(amd->flags & AMD7930_FLAG_CAPTURE)) @@ -666,7 +666,7 @@ static snd_pcm_uframes_t snd_amd7930_capture_pointer(snd_pcm_substream_t * subst } /* Playback and capture have identical properties. */ -static snd_pcm_hardware_t snd_amd7930_pcm_hw = +static struct snd_pcm_hardware snd_amd7930_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | @@ -686,54 +686,54 @@ static snd_pcm_hardware_t snd_amd7930_pcm_hw = .periods_max = 1024, }; -static int snd_amd7930_playback_open(snd_pcm_substream_t * substream) +static int snd_amd7930_playback_open(struct snd_pcm_substream *substream) { - amd7930_t *amd = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; amd->playback_substream = substream; runtime->hw = snd_amd7930_pcm_hw; return 0; } -static int snd_amd7930_capture_open(snd_pcm_substream_t * substream) +static int snd_amd7930_capture_open(struct snd_pcm_substream *substream) { - amd7930_t *amd = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; amd->capture_substream = substream; runtime->hw = snd_amd7930_pcm_hw; return 0; } -static int snd_amd7930_playback_close(snd_pcm_substream_t * substream) +static int snd_amd7930_playback_close(struct snd_pcm_substream *substream) { - amd7930_t *amd = snd_pcm_substream_chip(substream); + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); amd->playback_substream = NULL; return 0; } -static int snd_amd7930_capture_close(snd_pcm_substream_t * substream) +static int snd_amd7930_capture_close(struct snd_pcm_substream *substream) { - amd7930_t *amd = snd_pcm_substream_chip(substream); + struct snd_amd7930 *amd = snd_pcm_substream_chip(substream); amd->capture_substream = NULL; return 0; } -static int snd_amd7930_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_amd7930_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } -static int snd_amd7930_hw_free(snd_pcm_substream_t * substream) +static int snd_amd7930_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static snd_pcm_ops_t snd_amd7930_playback_ops = { +static struct snd_pcm_ops snd_amd7930_playback_ops = { .open = snd_amd7930_playback_open, .close = snd_amd7930_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -744,7 +744,7 @@ static snd_pcm_ops_t snd_amd7930_playback_ops = { .pointer = snd_amd7930_playback_pointer, }; -static snd_pcm_ops_t snd_amd7930_capture_ops = { +static struct snd_pcm_ops snd_amd7930_capture_ops = { .open = snd_amd7930_capture_open, .close = snd_amd7930_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -755,9 +755,9 @@ static snd_pcm_ops_t snd_amd7930_capture_ops = { .pointer = snd_amd7930_capture_pointer, }; -static int __init snd_amd7930_pcm(amd7930_t *amd) +static int __init snd_amd7930_pcm(struct snd_amd7930 *amd) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(amd->card, @@ -787,7 +787,7 @@ static int __init snd_amd7930_pcm(amd7930_t *amd) #define VOLUME_CAPTURE 1 #define VOLUME_PLAYBACK 2 -static int snd_amd7930_info_volume(snd_kcontrol_t *kctl, snd_ctl_elem_info_t *uinfo) +static int snd_amd7930_info_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *uinfo) { int type = kctl->private_value; @@ -804,9 +804,9 @@ static int snd_amd7930_info_volume(snd_kcontrol_t *kctl, snd_ctl_elem_info_t *ui return 0; } -static int snd_amd7930_get_volume(snd_kcontrol_t *kctl, snd_ctl_elem_value_t *ucontrol) +static int snd_amd7930_get_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { - amd7930_t *amd = snd_kcontrol_chip(kctl); + struct snd_amd7930 *amd = snd_kcontrol_chip(kctl); int type = kctl->private_value; int *swval; @@ -832,9 +832,9 @@ static int snd_amd7930_get_volume(snd_kcontrol_t *kctl, snd_ctl_elem_value_t *uc return 0; } -static int snd_amd7930_put_volume(snd_kcontrol_t *kctl, snd_ctl_elem_value_t *ucontrol) +static int snd_amd7930_put_volume(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *ucontrol) { - amd7930_t *amd = snd_kcontrol_chip(kctl); + struct snd_amd7930 *amd = snd_kcontrol_chip(kctl); unsigned long flags; int type = kctl->private_value; int *swval, change; @@ -870,7 +870,7 @@ static int snd_amd7930_put_volume(snd_kcontrol_t *kctl, snd_ctl_elem_value_t *uc return change; } -static snd_kcontrol_new_t amd7930_controls[] __initdata = { +static struct snd_kcontrol_new amd7930_controls[] __initdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Monitor Volume", @@ -900,9 +900,9 @@ static snd_kcontrol_new_t amd7930_controls[] __initdata = { }, }; -static int __init snd_amd7930_mixer(amd7930_t *amd) +static int __init snd_amd7930_mixer(struct snd_amd7930 *amd) { - snd_card_t *card; + struct snd_card *card; int idx, err; snd_assert(amd != NULL && amd->card != NULL, return -EINVAL); @@ -919,7 +919,7 @@ static int __init snd_amd7930_mixer(amd7930_t *amd) return 0; } -static int snd_amd7930_free(amd7930_t *amd) +static int snd_amd7930_free(struct snd_amd7930 *amd) { amd7930_idle(amd); @@ -934,27 +934,27 @@ static int snd_amd7930_free(amd7930_t *amd) return 0; } -static int snd_amd7930_dev_free(snd_device_t *device) +static int snd_amd7930_dev_free(struct snd_device *device) { - amd7930_t *amd = device->device_data; + struct snd_amd7930 *amd = device->device_data; return snd_amd7930_free(amd); } -static snd_device_ops_t snd_amd7930_dev_ops = { +static struct snd_device_ops snd_amd7930_dev_ops = { .dev_free = snd_amd7930_dev_free, }; -static int __init snd_amd7930_create(snd_card_t *card, +static int __init snd_amd7930_create(struct snd_card *card, struct sbus_dev *sdev, struct resource *rp, unsigned int reg_size, struct linux_prom_irqs *irq_prop, int dev, - amd7930_t **ramd) + struct snd_amd7930 **ramd) { unsigned long flags; - amd7930_t *amd; + struct snd_amd7930 *amd; int err; *ramd = NULL; @@ -1023,8 +1023,8 @@ static int __init amd7930_attach(int prom_node, struct sbus_dev *sdev) struct linux_prom_registers reg_prop; struct linux_prom_irqs irq_prop; struct resource res, *rp; - snd_card_t *card; - amd7930_t *amd; + struct snd_card *card; + struct snd_amd7930 *amd; int err; if (dev >= SNDRV_CARDS) @@ -1123,10 +1123,10 @@ static int __init amd7930_init(void) static void __exit amd7930_exit(void) { - amd7930_t *p = amd7930_list; + struct snd_amd7930 *p = amd7930_list; while (p != NULL) { - amd7930_t *next = p->next; + struct snd_amd7930 *next = p->next; snd_card_free(p->card); -- cgit v1.1 From 475675d6931ec03cf9575b26e30800fe64898ee0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:11:51 +0100 Subject: [ALSA] Remove xxx_t typedefs: SPARC DBRI Modules: SPARC DBRI driver Remove xxx_t typedefs from the SPARC DBRI driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/sparc/dbri.c | 218 ++++++++++++++++++++++++++--------------------------- 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 59a77129..012c636 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -299,8 +299,8 @@ struct dbri_desc { }; /* Per stream (playback or record) information */ -typedef struct dbri_streaminfo { - snd_pcm_substream_t *substream; +struct dbri_streaminfo { + struct snd_pcm_substream *substream; u32 dvma_buffer; /* Device view of Alsa DMA buffer */ int left; /* # of bytes left in DMA buffer */ int size; /* Size of DMA buffer */ @@ -309,12 +309,12 @@ typedef struct dbri_streaminfo { int left_gain; /* mixer elements */ int right_gain; int balance; -} dbri_streaminfo_t; +}; /* This structure holds the information for both chips (DBRI & CS4215) */ -typedef struct snd_dbri { - snd_card_t *card; /* ALSA card */ - snd_pcm_t *pcm; +struct snd_dbri { + struct snd_card *card; /* ALSA card */ + struct snd_pcm *pcm; int regs_size, irq; /* Needed for unload */ struct sbus_dev *sdev; /* SBUS device info */ @@ -341,7 +341,7 @@ typedef struct snd_dbri { struct dbri_streaminfo stream_info[DBRI_NO_STREAMS]; struct snd_dbri *next; -} snd_dbri_t; +}; #define DBRI_MAX_VOLUME 63 /* Output volume */ #define DBRI_MAX_GAIN 15 /* Input gain */ @@ -593,7 +593,7 @@ typedef struct snd_dbri { /* Return a pointer to dbri_streaminfo */ #define DBRI_STREAM(dbri, substream) &dbri->stream_info[DBRI_STREAMNO(substream)] -static snd_dbri_t *dbri_list = NULL; /* All DBRI devices */ +static struct snd_dbri *dbri_list = NULL; /* All DBRI devices */ /* * Short data pipes transmit LSB first. The CS4215 receives MSB first. Grrr. @@ -652,12 +652,12 @@ to the DBRI. */ -static void dbri_process_interrupt_buffer(snd_dbri_t * dbri); +static void dbri_process_interrupt_buffer(struct snd_dbri * dbri); -enum dbri_lock_t { NoGetLock, GetLock }; +enum dbri_lock { NoGetLock, GetLock }; #define MAXLOOPS 10 -static volatile s32 *dbri_cmdlock(snd_dbri_t * dbri, enum dbri_lock_t get) +static volatile s32 *dbri_cmdlock(struct snd_dbri * dbri, enum dbri_lock get) { int maxloops = MAXLOOPS; @@ -687,7 +687,7 @@ static volatile s32 *dbri_cmdlock(snd_dbri_t * dbri, enum dbri_lock_t get) return &dbri->dma->cmd[0]; } -static void dbri_cmdsend(snd_dbri_t * dbri, volatile s32 * cmd) +static void dbri_cmdsend(struct snd_dbri * dbri, volatile s32 * cmd) { volatile s32 *ptr; u32 reg; @@ -717,7 +717,7 @@ static void dbri_cmdsend(snd_dbri_t * dbri, volatile s32 * cmd) } /* Lock must be held when calling this */ -static void dbri_reset(snd_dbri_t * dbri) +static void dbri_reset(struct snd_dbri * dbri) { int i; @@ -732,7 +732,7 @@ static void dbri_reset(snd_dbri_t * dbri) } /* Lock must not be held before calling this */ -static void dbri_initialize(snd_dbri_t * dbri) +static void dbri_initialize(struct snd_dbri * dbri) { volatile s32 *cmd; u32 dma_addr, tmp; @@ -795,7 +795,7 @@ list ordering, among other things. The transmit and receive functions here interface closely with the transmit and receive interrupt code. */ -static int pipe_active(snd_dbri_t * dbri, int pipe) +static int pipe_active(struct snd_dbri * dbri, int pipe) { return ((pipe >= 0) && (dbri->pipes[pipe].desc != -1)); } @@ -805,7 +805,7 @@ static int pipe_active(snd_dbri_t * dbri, int pipe) * Called on an in-use pipe to clear anything being transmitted or received * Lock must be held before calling this. */ -static void reset_pipe(snd_dbri_t * dbri, int pipe) +static void reset_pipe(struct snd_dbri * dbri, int pipe) { int sdp; int desc; @@ -838,7 +838,7 @@ static void reset_pipe(snd_dbri_t * dbri, int pipe) } /* FIXME: direction as an argument? */ -static void setup_pipe(snd_dbri_t * dbri, int pipe, int sdp) +static void setup_pipe(struct snd_dbri * dbri, int pipe, int sdp) { if (pipe < 0 || pipe > 31) { printk(KERN_ERR "DBRI: setup_pipe called with illegal pipe number\n"); @@ -869,7 +869,7 @@ static void setup_pipe(snd_dbri_t * dbri, int pipe, int sdp) } /* FIXME: direction not needed */ -static void link_time_slot(snd_dbri_t * dbri, int pipe, +static void link_time_slot(struct snd_dbri * dbri, int pipe, enum in_or_out direction, int basepipe, int length, int cycle) { @@ -959,7 +959,7 @@ static void link_time_slot(snd_dbri_t * dbri, int pipe, dbri_cmdsend(dbri, cmd); } -static void unlink_time_slot(snd_dbri_t * dbri, int pipe, +static void unlink_time_slot(struct snd_dbri * dbri, int pipe, enum in_or_out direction, int prevpipe, int nextpipe) { @@ -1003,7 +1003,7 @@ static void unlink_time_slot(snd_dbri_t * dbri, int pipe, * in the low-order 8 bits, filled either MSB-first or LSB-first, * depending on the settings passed to setup_pipe() */ -static void xmit_fixed(snd_dbri_t * dbri, int pipe, unsigned int data) +static void xmit_fixed(struct snd_dbri * dbri, int pipe, unsigned int data) { volatile s32 *cmd; @@ -1040,7 +1040,7 @@ static void xmit_fixed(snd_dbri_t * dbri, int pipe, unsigned int data) dbri_cmdsend(dbri, cmd); } -static void recv_fixed(snd_dbri_t * dbri, int pipe, volatile __u32 * ptr) +static void recv_fixed(struct snd_dbri * dbri, int pipe, volatile __u32 * ptr) { if (pipe < 16 || pipe > 31) { printk(KERN_ERR "DBRI: recv_fixed called with illegal pipe number\n"); @@ -1072,9 +1072,9 @@ static void recv_fixed(snd_dbri_t * dbri, int pipe, volatile __u32 * ptr) * data buffers. Buffers too large for a single descriptor will * be spread across multiple descriptors. */ -static int setup_descs(snd_dbri_t * dbri, int streamno, unsigned int period) +static int setup_descs(struct snd_dbri * dbri, int streamno, unsigned int period) { - dbri_streaminfo_t *info = &dbri->stream_info[streamno]; + struct dbri_streaminfo *info = &dbri->stream_info[streamno]; __u32 dvma_buffer; int desc = 0; int len; @@ -1207,7 +1207,7 @@ multiplexed serial interface which the DBRI can operate in either master enum master_or_slave { CHImaster, CHIslave }; -static void reset_chi(snd_dbri_t * dbri, enum master_or_slave master_or_slave, +static void reset_chi(struct snd_dbri * dbri, enum master_or_slave master_or_slave, int bits_per_frame) { volatile s32 *cmd; @@ -1308,7 +1308,7 @@ In the standard SPARC audio configuration, the CS4215 codec is attached to the DBRI via the CHI interface and few of the DBRI's PIO pins. */ -static void cs4215_setup_pipes(snd_dbri_t * dbri) +static void cs4215_setup_pipes(struct snd_dbri * dbri) { /* * Data mode: @@ -1369,7 +1369,7 @@ static int cs4215_init_data(struct cs4215 *mm) return 0; } -static void cs4215_setdata(snd_dbri_t * dbri, int muted) +static void cs4215_setdata(struct snd_dbri * dbri, int muted) { if (muted) { dbri->mm.data[0] |= 63; @@ -1378,7 +1378,7 @@ static void cs4215_setdata(snd_dbri_t * dbri, int muted) dbri->mm.data[3] &= ~15; } else { /* Start by setting the playback attenuation. */ - dbri_streaminfo_t *info = &dbri->stream_info[DBRI_PLAY]; + struct dbri_streaminfo *info = &dbri->stream_info[DBRI_PLAY]; int left_gain = info->left_gain % 64; int right_gain = info->right_gain % 64; @@ -1409,7 +1409,7 @@ static void cs4215_setdata(snd_dbri_t * dbri, int muted) /* * Set the CS4215 to data mode. */ -static void cs4215_open(snd_dbri_t * dbri) +static void cs4215_open(struct snd_dbri * dbri) { int data_width; u32 tmp; @@ -1471,7 +1471,7 @@ static void cs4215_open(snd_dbri_t * dbri) /* * Send the control information (i.e. audio format) */ -static int cs4215_setctrl(snd_dbri_t * dbri) +static int cs4215_setctrl(struct snd_dbri * dbri) { int i, val; u32 tmp; @@ -1570,7 +1570,7 @@ static int cs4215_setctrl(snd_dbri_t * dbri) * As part of the process we resend the settings for the data * timeslots as well. */ -static int cs4215_prepare(snd_dbri_t * dbri, unsigned int rate, +static int cs4215_prepare(struct snd_dbri * dbri, unsigned int rate, snd_pcm_format_t format, unsigned int channels) { int freq_idx; @@ -1628,7 +1628,7 @@ static int cs4215_prepare(snd_dbri_t * dbri, unsigned int rate, /* * */ -static int cs4215_init(snd_dbri_t * dbri) +static int cs4215_init(struct snd_dbri * dbri) { u32 reg2 = sbus_readl(dbri->regs + REG2); dprintk(D_MM, "cs4215_init: reg2=0x%x\n", reg2); @@ -1697,8 +1697,8 @@ even if we're running cli'ed. */ static void xmit_descs(unsigned long data) { - snd_dbri_t *dbri = (snd_dbri_t *) data; - dbri_streaminfo_t *info; + struct snd_dbri *dbri = (struct snd_dbri *) data; + struct dbri_streaminfo *info; volatile s32 *cmd; unsigned long flags; int first_td; @@ -1780,9 +1780,9 @@ static DECLARE_TASKLET(xmit_descs_task, xmit_descs, 0); * done by the xmit_descs() tasklet above since that could take longer. */ -static void transmission_complete_intr(snd_dbri_t * dbri, int pipe) +static void transmission_complete_intr(struct snd_dbri * dbri, int pipe) { - dbri_streaminfo_t *info; + struct dbri_streaminfo *info; int td; int status; @@ -1830,9 +1830,9 @@ static void transmission_complete_intr(snd_dbri_t * dbri, int pipe) snd_pcm_period_elapsed(info->substream); } -static void reception_complete_intr(snd_dbri_t * dbri, int pipe) +static void reception_complete_intr(struct snd_dbri * dbri, int pipe) { - dbri_streaminfo_t *info; + struct dbri_streaminfo *info; int rd = dbri->pipes[pipe].desc; s32 status; @@ -1874,7 +1874,7 @@ static void reception_complete_intr(snd_dbri_t * dbri, int pipe) snd_pcm_period_elapsed(info->substream); } -static void dbri_process_one_interrupt(snd_dbri_t * dbri, int x) +static void dbri_process_one_interrupt(struct snd_dbri * dbri, int x) { int val = D_INTR_GETVAL(x); int channel = D_INTR_GETCHAN(x); @@ -1950,7 +1950,7 @@ static void dbri_process_one_interrupt(snd_dbri_t * dbri, int x) * order is important since we might recurse back into this function * and need to make sure the pointer has been advanced first. */ -static void dbri_process_interrupt_buffer(snd_dbri_t * dbri) +static void dbri_process_interrupt_buffer(struct snd_dbri * dbri) { s32 x; @@ -1969,7 +1969,7 @@ static void dbri_process_interrupt_buffer(snd_dbri_t * dbri) static irqreturn_t snd_dbri_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - snd_dbri_t *dbri = dev_id; + struct snd_dbri *dbri = dev_id; static int errcnt = 0; int x; @@ -2030,7 +2030,7 @@ static irqreturn_t snd_dbri_interrupt(int irq, void *dev_id, /**************************************************************************** PCM Interface ****************************************************************************/ -static snd_pcm_hardware_t snd_dbri_pcm_hw = { +static struct snd_pcm_hardware snd_dbri_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -2051,11 +2051,11 @@ static snd_pcm_hardware_t snd_dbri_pcm_hw = { .periods_max = 1024, }; -static int snd_dbri_open(snd_pcm_substream_t * substream) +static int snd_dbri_open(struct snd_pcm_substream *substream) { - snd_dbri_t *dbri = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; - dbri_streaminfo_t *info = DBRI_STREAM(dbri, substream); + struct snd_dbri *dbri = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); unsigned long flags; dprintk(D_USR, "open audio output.\n"); @@ -2074,10 +2074,10 @@ static int snd_dbri_open(snd_pcm_substream_t * substream) return 0; } -static int snd_dbri_close(snd_pcm_substream_t * substream) +static int snd_dbri_close(struct snd_pcm_substream *substream) { - snd_dbri_t *dbri = snd_pcm_substream_chip(substream); - dbri_streaminfo_t *info = DBRI_STREAM(dbri, substream); + struct snd_dbri *dbri = snd_pcm_substream_chip(substream); + struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); dprintk(D_USR, "close audio output.\n"); info->substream = NULL; @@ -2087,12 +2087,12 @@ static int snd_dbri_close(snd_pcm_substream_t * substream) return 0; } -static int snd_dbri_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +static int snd_dbri_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - snd_pcm_runtime_t *runtime = substream->runtime; - snd_dbri_t *dbri = snd_pcm_substream_chip(substream); - dbri_streaminfo_t *info = DBRI_STREAM(dbri, substream); + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_dbri *dbri = snd_pcm_substream_chip(substream); + struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); int direction; int ret; @@ -2129,10 +2129,10 @@ static int snd_dbri_hw_params(snd_pcm_substream_t * substream, return 0; } -static int snd_dbri_hw_free(snd_pcm_substream_t * substream) +static int snd_dbri_hw_free(struct snd_pcm_substream *substream) { - snd_dbri_t *dbri = snd_pcm_substream_chip(substream); - dbri_streaminfo_t *info = DBRI_STREAM(dbri, substream); + struct snd_dbri *dbri = snd_pcm_substream_chip(substream); + struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); int direction; dprintk(D_USR, "hw_free.\n"); @@ -2153,11 +2153,11 @@ static int snd_dbri_hw_free(snd_pcm_substream_t * substream) return snd_pcm_lib_free_pages(substream); } -static int snd_dbri_prepare(snd_pcm_substream_t * substream) +static int snd_dbri_prepare(struct snd_pcm_substream *substream) { - snd_dbri_t *dbri = snd_pcm_substream_chip(substream); - dbri_streaminfo_t *info = DBRI_STREAM(dbri, substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_dbri *dbri = snd_pcm_substream_chip(substream); + struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); + struct snd_pcm_runtime *runtime = substream->runtime; int ret; info->size = snd_pcm_lib_buffer_bytes(substream); @@ -2184,10 +2184,10 @@ static int snd_dbri_prepare(snd_pcm_substream_t * substream) return ret; } -static int snd_dbri_trigger(snd_pcm_substream_t * substream, int cmd) +static int snd_dbri_trigger(struct snd_pcm_substream *substream, int cmd) { - snd_dbri_t *dbri = snd_pcm_substream_chip(substream); - dbri_streaminfo_t *info = DBRI_STREAM(dbri, substream); + struct snd_dbri *dbri = snd_pcm_substream_chip(substream); + struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); int ret = 0; switch (cmd) { @@ -2211,10 +2211,10 @@ static int snd_dbri_trigger(snd_pcm_substream_t * substream, int cmd) return ret; } -static snd_pcm_uframes_t snd_dbri_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_dbri_pointer(struct snd_pcm_substream *substream) { - snd_dbri_t *dbri = snd_pcm_substream_chip(substream); - dbri_streaminfo_t *info = DBRI_STREAM(dbri, substream); + struct snd_dbri *dbri = snd_pcm_substream_chip(substream); + struct dbri_streaminfo *info = DBRI_STREAM(dbri, substream); snd_pcm_uframes_t ret; ret = bytes_to_frames(substream->runtime, info->offset) @@ -2224,7 +2224,7 @@ static snd_pcm_uframes_t snd_dbri_pointer(snd_pcm_substream_t * substream) return ret; } -static snd_pcm_ops_t snd_dbri_ops = { +static struct snd_pcm_ops snd_dbri_ops = { .open = snd_dbri_open, .close = snd_dbri_close, .ioctl = snd_pcm_lib_ioctl, @@ -2235,9 +2235,9 @@ static snd_pcm_ops_t snd_dbri_ops = { .pointer = snd_dbri_pointer, }; -static int __devinit snd_dbri_pcm(snd_dbri_t * dbri) +static int __devinit snd_dbri_pcm(struct snd_dbri * dbri) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(dbri->card, @@ -2270,8 +2270,8 @@ static int __devinit snd_dbri_pcm(snd_dbri_t * dbri) Mixer interface *****************************************************************************/ -static int snd_cs4215_info_volume(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_cs4215_info_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -2284,11 +2284,11 @@ static int snd_cs4215_info_volume(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs4215_get_volume(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs4215_get_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_dbri_t *dbri = snd_kcontrol_chip(kcontrol); - dbri_streaminfo_t *info; + struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); + struct dbri_streaminfo *info; snd_assert(dbri != NULL, return -EINVAL); info = &dbri->stream_info[kcontrol->private_value]; snd_assert(info != NULL, return -EINVAL); @@ -2298,11 +2298,11 @@ static int snd_cs4215_get_volume(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs4215_put_volume(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs4215_put_volume(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_dbri_t *dbri = snd_kcontrol_chip(kcontrol); - dbri_streaminfo_t *info = &dbri->stream_info[kcontrol->private_value]; + struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); + struct dbri_streaminfo *info = &dbri->stream_info[kcontrol->private_value]; unsigned long flags; int changed = 0; @@ -2329,8 +2329,8 @@ static int snd_cs4215_put_volume(snd_kcontrol_t * kcontrol, return changed; } -static int snd_cs4215_info_single(snd_kcontrol_t * kcontrol, - snd_ctl_elem_info_t * uinfo) +static int snd_cs4215_info_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -2342,10 +2342,10 @@ static int snd_cs4215_info_single(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs4215_get_single(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs4215_get_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_dbri_t *dbri = snd_kcontrol_chip(kcontrol); + struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); int elem = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; int mask = (kcontrol->private_value >> 16) & 0xff; @@ -2367,10 +2367,10 @@ static int snd_cs4215_get_single(snd_kcontrol_t * kcontrol, return 0; } -static int snd_cs4215_put_single(snd_kcontrol_t * kcontrol, - snd_ctl_elem_value_t * ucontrol) +static int snd_cs4215_put_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - snd_dbri_t *dbri = snd_kcontrol_chip(kcontrol); + struct snd_dbri *dbri = snd_kcontrol_chip(kcontrol); unsigned long flags; int elem = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -2425,7 +2425,7 @@ static int snd_cs4215_put_single(snd_kcontrol_t * kcontrol, .get = snd_cs4215_get_single, .put = snd_cs4215_put_single, \ .private_value = entry | (shift << 8) | (mask << 16) | (invert << 24) }, -static snd_kcontrol_new_t dbri_controls[] __devinitdata = { +static struct snd_kcontrol_new dbri_controls[] __devinitdata = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Playback Volume", @@ -2452,11 +2452,11 @@ static snd_kcontrol_new_t dbri_controls[] __devinitdata = { CS4215_SINGLE("Mic boost", 4, 4, 1, 1) }; -#define NUM_CS4215_CONTROLS (sizeof(dbri_controls)/sizeof(snd_kcontrol_new_t)) +#define NUM_CS4215_CONTROLS (sizeof(dbri_controls)/sizeof(struct snd_kcontrol_new)) -static int __init snd_dbri_mixer(snd_dbri_t * dbri) +static int __init snd_dbri_mixer(struct snd_dbri * dbri) { - snd_card_t *card; + struct snd_card *card; int idx, err; snd_assert(dbri != NULL && dbri->card != NULL, return -EINVAL); @@ -2482,9 +2482,9 @@ static int __init snd_dbri_mixer(snd_dbri_t * dbri) /**************************************************************************** /proc interface ****************************************************************************/ -static void dbri_regs_read(snd_info_entry_t * entry, snd_info_buffer_t * buffer) +static void dbri_regs_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer) { - snd_dbri_t *dbri = entry->private_data; + struct snd_dbri *dbri = entry->private_data; snd_iprintf(buffer, "REG0: 0x%x\n", sbus_readl(dbri->regs + REG0)); snd_iprintf(buffer, "REG2: 0x%x\n", sbus_readl(dbri->regs + REG2)); @@ -2493,10 +2493,10 @@ static void dbri_regs_read(snd_info_entry_t * entry, snd_info_buffer_t * buffer) } #ifdef DBRI_DEBUG -static void dbri_debug_read(snd_info_entry_t * entry, - snd_info_buffer_t * buffer) +static void dbri_debug_read(struct snd_info_entry * entry, + struct snd_info_buffer *buffer) { - snd_dbri_t *dbri = entry->private_data; + struct snd_dbri *dbri = entry->private_data; int pipe; snd_iprintf(buffer, "debug=%d\n", dbri_debug); @@ -2516,9 +2516,9 @@ static void dbri_debug_read(snd_info_entry_t * entry, } #endif -void snd_dbri_proc(snd_dbri_t * dbri) +void snd_dbri_proc(struct snd_dbri * dbri) { - snd_info_entry_t *entry; + struct snd_info_entry *entry; int err; err = snd_card_proc_new(dbri->card, "regs", &entry); @@ -2536,13 +2536,13 @@ void snd_dbri_proc(snd_dbri_t * dbri) **************************** Initialization ******************************** **************************************************************************** */ -static void snd_dbri_free(snd_dbri_t * dbri); +static void snd_dbri_free(struct snd_dbri * dbri); -static int __init snd_dbri_create(snd_card_t * card, +static int __init snd_dbri_create(struct snd_card *card, struct sbus_dev *sdev, struct linux_prom_irqs *irq, int dev) { - snd_dbri_t *dbri = card->private_data; + struct snd_dbri *dbri = card->private_data; int err; spin_lock_init(&dbri->lock); @@ -2593,7 +2593,7 @@ static int __init snd_dbri_create(snd_card_t * card, return 0; } -static void snd_dbri_free(snd_dbri_t * dbri) +static void snd_dbri_free(struct snd_dbri * dbri) { dprintk(D_GEN, "snd_dbri_free\n"); dbri_reset(dbri); @@ -2611,10 +2611,10 @@ static void snd_dbri_free(snd_dbri_t * dbri) static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) { - snd_dbri_t *dbri; + struct snd_dbri *dbri; struct linux_prom_irqs irq; struct resource *rp; - snd_card_t *card; + struct snd_card *card; static int dev = 0; int err; @@ -2638,7 +2638,7 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) } card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(snd_dbri_t)); + sizeof(struct snd_dbri)); if (card == NULL) return -ENOMEM; @@ -2654,7 +2654,7 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) return err; } - dbri = (snd_dbri_t *) card->private_data; + dbri = card->private_data; if ((err = snd_dbri_pcm(dbri)) < 0) goto _err; @@ -2709,11 +2709,11 @@ static int __init dbri_init(void) static void __exit dbri_exit(void) { - snd_dbri_t *this = dbri_list; + struct snd_dbri *this = dbri_list; while (this != NULL) { - snd_dbri_t *next = this->next; - snd_card_t *card = this->card; + struct snd_dbri *next = this->next; + struct snd_card *card = this->card; snd_dbri_free(this); snd_card_free(card); -- cgit v1.1 From 67b1020d88a77a73bd9ccbc21733c155a4d7d44c Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:12:11 +0100 Subject: [ALSA] Remove xxx_t typedefs: PARISC Harmony Modules: PARISC Harmony driver Remove xxx_t typedefs from the PARIC Harmony driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/parisc/harmony.c | 169 ++++++++++++++++++++++++------------------------- sound/parisc/harmony.h | 14 ++-- 2 files changed, 91 insertions(+), 92 deletions(-) diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index 0513137..ce73f3ea 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c @@ -99,32 +99,32 @@ static unsigned int rate_bits[14] = { HARMONY_SR_44KHZ, HARMONY_SR_48KHZ }; -static snd_pcm_hw_constraint_list_t hw_constraint_rates = { +static struct snd_pcm_hw_constraint_list hw_constraint_rates = { .count = ARRAY_SIZE(snd_harmony_rates), .list = snd_harmony_rates, .mask = 0, }; -inline unsigned long -harmony_read(harmony_t *h, unsigned r) +static inline unsigned long +harmony_read(struct snd_harmony *h, unsigned r) { return __raw_readl(h->iobase + r); } -inline void -harmony_write(harmony_t *h, unsigned r, unsigned long v) +static inline void +harmony_write(struct snd_harmony *h, unsigned r, unsigned long v) { __raw_writel(v, h->iobase + r); } -static void -harmony_wait_for_control(harmony_t *h) +static inline void +harmony_wait_for_control(struct snd_harmony *h) { while (harmony_read(h, HARMONY_CNTL) & HARMONY_CNTL_C) ; } -inline void -harmony_reset(harmony_t *h) +static inline void +harmony_reset(struct snd_harmony *h) { harmony_write(h, HARMONY_RESET, 1); mdelay(50); @@ -132,7 +132,7 @@ harmony_reset(harmony_t *h) } static void -harmony_disable_interrupts(harmony_t *h) +harmony_disable_interrupts(struct snd_harmony *h) { u32 dstatus; harmony_wait_for_control(h); @@ -142,7 +142,7 @@ harmony_disable_interrupts(harmony_t *h) } static void -harmony_enable_interrupts(harmony_t *h) +harmony_enable_interrupts(struct snd_harmony *h) { u32 dstatus; harmony_wait_for_control(h); @@ -152,7 +152,7 @@ harmony_enable_interrupts(harmony_t *h) } static void -harmony_mute(harmony_t *h) +harmony_mute(struct snd_harmony *h) { unsigned long flags; @@ -163,7 +163,7 @@ harmony_mute(harmony_t *h) } static void -harmony_unmute(harmony_t *h) +harmony_unmute(struct snd_harmony *h) { unsigned long flags; @@ -174,7 +174,7 @@ harmony_unmute(harmony_t *h) } static void -harmony_set_control(harmony_t *h) +harmony_set_control(struct snd_harmony *h) { u32 ctrl; unsigned long flags; @@ -196,7 +196,7 @@ static irqreturn_t snd_harmony_interrupt(int irq, void *dev, struct pt_regs *regs) { u32 dstatus; - harmony_t *h = dev; + struct snd_harmony *h = dev; spin_lock(&h->lock); harmony_disable_interrupts(h); @@ -261,7 +261,7 @@ snd_harmony_rate_bits(int rate) return HARMONY_SR_44KHZ; } -static snd_pcm_hardware_t snd_harmony_playback = +static struct snd_pcm_hardware snd_harmony_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | @@ -282,7 +282,7 @@ static snd_pcm_hardware_t snd_harmony_playback = .fifo_size = 0, }; -static snd_pcm_hardware_t snd_harmony_capture = +static struct snd_pcm_hardware snd_harmony_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | @@ -304,9 +304,9 @@ static snd_pcm_hardware_t snd_harmony_capture = }; static int -snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd) +snd_harmony_playback_trigger(struct snd_pcm_substream *ss, int cmd) { - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_harmony *h = snd_pcm_substream_chip(ss); if (h->st.capturing) return -EBUSY; @@ -340,9 +340,9 @@ snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd) } static int -snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd) +snd_harmony_capture_trigger(struct snd_pcm_substream *ss, int cmd) { - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_harmony *h = snd_pcm_substream_chip(ss); if (h->st.playing) return -EBUSY; @@ -376,7 +376,7 @@ snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd) } static int -snd_harmony_set_data_format(harmony_t *h, int fmt, int force) +snd_harmony_set_data_format(struct snd_harmony *h, int fmt, int force) { int o = h->st.format; int n; @@ -406,10 +406,10 @@ snd_harmony_set_data_format(harmony_t *h, int fmt, int force) } static int -snd_harmony_playback_prepare(snd_pcm_substream_t *ss) +snd_harmony_playback_prepare(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; if (h->st.capturing) return -EBUSY; @@ -436,10 +436,10 @@ snd_harmony_playback_prepare(snd_pcm_substream_t *ss) } static int -snd_harmony_capture_prepare(snd_pcm_substream_t *ss) +snd_harmony_capture_prepare(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; if (h->st.playing) return -EBUSY; @@ -466,10 +466,10 @@ snd_harmony_capture_prepare(snd_pcm_substream_t *ss) } static snd_pcm_uframes_t -snd_harmony_playback_pointer(snd_pcm_substream_t *ss) +snd_harmony_playback_pointer(struct snd_pcm_substream *ss) { - snd_pcm_runtime_t *rt = ss->runtime; - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); unsigned long pcuradd; unsigned long played; @@ -495,10 +495,10 @@ snd_harmony_playback_pointer(snd_pcm_substream_t *ss) } static snd_pcm_uframes_t -snd_harmony_capture_pointer(snd_pcm_substream_t *ss) +snd_harmony_capture_pointer(struct snd_pcm_substream *ss) { - snd_pcm_runtime_t *rt = ss->runtime; - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); unsigned long rcuradd; unsigned long caught; @@ -524,10 +524,10 @@ snd_harmony_capture_pointer(snd_pcm_substream_t *ss) } static int -snd_harmony_playback_open(snd_pcm_substream_t *ss) +snd_harmony_playback_open(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; int err; h->psubs = ss; @@ -543,10 +543,10 @@ snd_harmony_playback_open(snd_pcm_substream_t *ss) } static int -snd_harmony_capture_open(snd_pcm_substream_t *ss) +snd_harmony_capture_open(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); - snd_pcm_runtime_t *rt = ss->runtime; + struct snd_harmony *h = snd_pcm_substream_chip(ss); + struct snd_pcm_runtime *rt = ss->runtime; int err; h->csubs = ss; @@ -562,27 +562,27 @@ snd_harmony_capture_open(snd_pcm_substream_t *ss) } static int -snd_harmony_playback_close(snd_pcm_substream_t *ss) +snd_harmony_playback_close(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_harmony *h = snd_pcm_substream_chip(ss); h->psubs = NULL; return 0; } static int -snd_harmony_capture_close(snd_pcm_substream_t *ss) +snd_harmony_capture_close(struct snd_pcm_substream *ss) { - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_harmony *h = snd_pcm_substream_chip(ss); h->csubs = NULL; return 0; } static int -snd_harmony_hw_params(snd_pcm_substream_t *ss, - snd_pcm_hw_params_t *hw) +snd_harmony_hw_params(struct snd_pcm_substream *ss, + struct snd_pcm_hw_params *hw) { int err; - harmony_t *h = snd_pcm_substream_chip(ss); + struct snd_harmony *h = snd_pcm_substream_chip(ss); err = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw)); if (err > 0 && h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) @@ -592,12 +592,12 @@ snd_harmony_hw_params(snd_pcm_substream_t *ss, } static int -snd_harmony_hw_free(snd_pcm_substream_t *ss) +snd_harmony_hw_free(struct snd_pcm_substream *ss) { return snd_pcm_lib_free_pages(ss); } -static snd_pcm_ops_t snd_harmony_playback_ops = { +static struct snd_pcm_ops snd_harmony_playback_ops = { .open = snd_harmony_playback_open, .close = snd_harmony_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -608,7 +608,7 @@ static snd_pcm_ops_t snd_harmony_playback_ops = { .pointer = snd_harmony_playback_pointer, }; -static snd_pcm_ops_t snd_harmony_capture_ops = { +static struct snd_pcm_ops snd_harmony_capture_ops = { .open = snd_harmony_capture_open, .close = snd_harmony_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -620,9 +620,9 @@ static snd_pcm_ops_t snd_harmony_capture_ops = { }; static int -snd_harmony_pcm_init(harmony_t *h) +snd_harmony_pcm_init(struct snd_harmony *h) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; harmony_disable_interrupts(h); @@ -683,15 +683,15 @@ snd_harmony_pcm_init(harmony_t *h) } static void -snd_harmony_set_new_gain(harmony_t *h) +snd_harmony_set_new_gain(struct snd_harmony *h) { harmony_wait_for_control(h); harmony_write(h, HARMONY_GAINCTL, h->st.gain); } static int -snd_harmony_mixercontrol_info(snd_kcontrol_t *kc, - snd_ctl_elem_info_t *uinfo) +snd_harmony_mixercontrol_info(struct snd_kcontrol *kc, + struct snd_ctl_elem_info *uinfo) { int mask = (kc->private_value >> 16) & 0xff; int left_shift = (kc->private_value) & 0xff; @@ -707,10 +707,10 @@ snd_harmony_mixercontrol_info(snd_kcontrol_t *kc, } static int -snd_harmony_volume_get(snd_kcontrol_t *kc, - snd_ctl_elem_value_t *ucontrol) +snd_harmony_volume_get(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) { - harmony_t *h = snd_kcontrol_chip(kc); + struct snd_harmony *h = snd_kcontrol_chip(kc); int shift_left = (kc->private_value) & 0xff; int shift_right = (kc->private_value >> 8) & 0xff; int mask = (kc->private_value >> 16) & 0xff; @@ -736,10 +736,10 @@ snd_harmony_volume_get(snd_kcontrol_t *kc, } static int -snd_harmony_volume_put(snd_kcontrol_t *kc, - snd_ctl_elem_value_t *ucontrol) +snd_harmony_volume_put(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) { - harmony_t *h = snd_kcontrol_chip(kc); + struct snd_harmony *h = snd_kcontrol_chip(kc); int shift_left = (kc->private_value) & 0xff; int shift_right = (kc->private_value >> 8) & 0xff; int mask = (kc->private_value >> 16) & 0xff; @@ -771,8 +771,8 @@ snd_harmony_volume_put(snd_kcontrol_t *kc, } static int -snd_harmony_captureroute_info(snd_kcontrol_t *kc, - snd_ctl_elem_info_t *uinfo) +snd_harmony_captureroute_info(struct snd_kcontrol *kc, + struct snd_ctl_elem_info *uinfo) { static char *texts[2] = { "Line", "Mic" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -786,10 +786,10 @@ snd_harmony_captureroute_info(snd_kcontrol_t *kc, } static int -snd_harmony_captureroute_get(snd_kcontrol_t *kc, - snd_ctl_elem_value_t *ucontrol) +snd_harmony_captureroute_get(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) { - harmony_t *h = snd_kcontrol_chip(kc); + struct snd_harmony *h = snd_kcontrol_chip(kc); int value; spin_lock_irq(&h->mixer_lock); @@ -803,10 +803,10 @@ snd_harmony_captureroute_get(snd_kcontrol_t *kc, } static int -snd_harmony_captureroute_put(snd_kcontrol_t *kc, - snd_ctl_elem_value_t *ucontrol) +snd_harmony_captureroute_put(struct snd_kcontrol *kc, + struct snd_ctl_elem_value *ucontrol) { - harmony_t *h = snd_kcontrol_chip(kc); + struct snd_harmony *h = snd_kcontrol_chip(kc); int value; int old_gain = h->st.gain; @@ -823,8 +823,7 @@ snd_harmony_captureroute_put(snd_kcontrol_t *kc, return h->st.gain != old_gain; } -#define HARMONY_CONTROLS (sizeof(snd_harmony_controls)/ \ - sizeof(snd_kcontrol_new_t)) +#define HARMONY_CONTROLS ARRAY_SIZE(snd_harmony_controls) #define HARMONY_VOLUME(xname, left_shift, right_shift, mask, invert) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ @@ -833,7 +832,7 @@ snd_harmony_captureroute_put(snd_kcontrol_t *kc, .private_value = ((left_shift) | ((right_shift) << 8) | \ ((mask) << 16) | ((invert) << 24)) } -static snd_kcontrol_new_t snd_harmony_controls[] = { +static struct snd_kcontrol_new snd_harmony_controls[] = { HARMONY_VOLUME("Master Playback Volume", HARMONY_GAIN_LO_SHIFT, HARMONY_GAIN_RO_SHIFT, HARMONY_GAIN_OUT, 1), HARMONY_VOLUME("Capture Volume", HARMONY_GAIN_LI_SHIFT, @@ -856,7 +855,7 @@ static snd_kcontrol_new_t snd_harmony_controls[] = { }; static void __init -snd_harmony_mixer_reset(harmony_t *h) +snd_harmony_mixer_reset(struct snd_harmony *h) { harmony_mute(h); harmony_reset(h); @@ -865,9 +864,9 @@ snd_harmony_mixer_reset(harmony_t *h) } static int __init -snd_harmony_mixer_init(harmony_t *h) +snd_harmony_mixer_init(struct snd_harmony *h) { - snd_card_t *card = h->card; + struct snd_card *card = h->card; int idx, err; snd_assert(h != NULL, return -EINVAL); @@ -886,7 +885,7 @@ snd_harmony_mixer_init(harmony_t *h) } static int -snd_harmony_free(harmony_t *h) +snd_harmony_free(struct snd_harmony *h) { if (h->gdma.addr) snd_dma_free_pages(&h->gdma); @@ -906,20 +905,20 @@ snd_harmony_free(harmony_t *h) } static int -snd_harmony_dev_free(snd_device_t *dev) +snd_harmony_dev_free(struct snd_device *dev) { - harmony_t *h = dev->device_data; + struct snd_harmony *h = dev->device_data; return snd_harmony_free(h); } static int __devinit -snd_harmony_create(snd_card_t *card, +snd_harmony_create(struct snd_card *card, struct parisc_device *padev, - harmony_t **rchip) + struct snd_harmony **rchip) { int err; - harmony_t *h; - static snd_device_ops_t ops = { + struct snd_harmony *h; + static struct snd_device_ops ops = { .dev_free = snd_harmony_dev_free, }; @@ -973,8 +972,8 @@ static int __devinit snd_harmony_probe(struct parisc_device *padev) { int err; - snd_card_t *card; - harmony_t *h; + struct snd_card *card; + struct snd_harmony *h; card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) @@ -1033,7 +1032,7 @@ alsa_harmony_init(void) static void __exit alsa_harmony_fini(void) { - return unregister_parisc_driver(&snd_harmony_driver); + unregister_parisc_driver(&snd_harmony_driver); } MODULE_LICENSE("GPL"); diff --git a/sound/parisc/harmony.h b/sound/parisc/harmony.h index 526c523..2e43452 100644 --- a/sound/parisc/harmony.h +++ b/sound/parisc/harmony.h @@ -13,7 +13,7 @@ struct harmony_buffer { int coherent; }; -typedef struct snd_card_harmony { +struct snd_harmony { int irq; unsigned long hpa; /* hard physical address */ @@ -44,15 +44,15 @@ typedef struct snd_card_harmony { unsigned long silence_intr; } stats; - snd_pcm_t *pcm; - snd_card_t *card; - snd_pcm_substream_t *psubs; - snd_pcm_substream_t *csubs; - snd_info_entry_t *proc; + struct snd_pcm *pcm; + struct snd_card *card; + struct snd_pcm_substream *psubs; + struct snd_pcm_substream *csubs; + struct snd_info_entry *proc; spinlock_t lock; spinlock_t mixer_lock; -} harmony_t; +}; #define MAX_PCM_DEVICES 1 #define MAX_PCM_SUBSTREAMS 4 -- cgit v1.1 From a0d6f880faad2ceba3af3b8c34ddefd15119ced1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:12:31 +0100 Subject: [ALSA] Remove xxx_t typedefs: MIPS AU1x00 Modules: MIPS AU1x00 driver Remove xxx_t typedefs from the MIPS AU1x00 driver. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- sound/mips/au1x00.c | 148 ++++++++++++++++++++++++++-------------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index a8f9a3b..f150cced 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -63,16 +63,14 @@ MODULE_SUPPORTED_DEVICE("{{AMD,Au1000 AC'97}}"); #define READ_WAIT 2 #define RW_DONE 3 -typedef struct au1000_period au1000_period_t; struct au1000_period { u32 start; u32 relative_end; /*realtive to start of buffer*/ - au1000_period_t * next; + struct au1000_period * next; }; /*Au1000 AC97 Port Control Reisters*/ -typedef struct au1000_ac97_reg au1000_ac97_reg_t; struct au1000_ac97_reg { u32 volatile config; u32 volatile status; @@ -81,31 +79,30 @@ struct au1000_ac97_reg { u32 volatile cntrl; }; -typedef struct audio_stream audio_stream_t; struct audio_stream { - snd_pcm_substream_t * substream; + struct snd_pcm_substream *substream; int dma; spinlock_t dma_lock; - au1000_period_t * buffer; + struct au1000_period * buffer; unsigned int period_size; unsigned int periods; }; -typedef struct snd_card_au1000 { - snd_card_t *card; - au1000_ac97_reg_t volatile *ac97_ioport; +struct snd_au1000 { + struct snd_card *card; + struct au1000_ac97_reg volatile *ac97_ioport; struct resource *ac97_res_port; spinlock_t ac97_lock; - ac97_t *ac97; + struct snd_ac97 *ac97; - snd_pcm_t *pcm; - audio_stream_t *stream[2]; /* playback & capture */ -} au1000_t; + struct snd_pcm *pcm; + struct audio_stream *stream[2]; /* playback & capture */ +}; /*--------------------------- Local Functions --------------------------------*/ static void -au1000_set_ac97_xmit_slots(au1000_t *au1000, long xmit_slots) +au1000_set_ac97_xmit_slots(struct snd_au1000 *au1000, long xmit_slots) { u32 volatile ac97_config; @@ -118,7 +115,7 @@ au1000_set_ac97_xmit_slots(au1000_t *au1000, long xmit_slots) } static void -au1000_set_ac97_recv_slots(au1000_t *au1000, long recv_slots) +au1000_set_ac97_recv_slots(struct snd_au1000 *au1000, long recv_slots) { u32 volatile ac97_config; @@ -132,10 +129,10 @@ au1000_set_ac97_recv_slots(au1000_t *au1000, long recv_slots) static void -au1000_release_dma_link(audio_stream_t *stream) +au1000_release_dma_link(struct audio_stream *stream) { - au1000_period_t * pointer; - au1000_period_t * pointer_next; + struct au1000_period * pointer; + struct au1000_period * pointer_next; stream->period_size = 0; stream->periods = 0; @@ -151,11 +148,11 @@ au1000_release_dma_link(audio_stream_t *stream) } static int -au1000_setup_dma_link(audio_stream_t *stream, unsigned int period_bytes, +au1000_setup_dma_link(struct audio_stream *stream, unsigned int period_bytes, unsigned int periods) { - snd_pcm_substream_t *substream = stream->substream; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_substream *substream = stream->substream; + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long dma_start; int i; @@ -170,7 +167,7 @@ au1000_setup_dma_link(audio_stream_t *stream, unsigned int period_bytes, stream->period_size = period_bytes; stream->periods = periods; - stream->buffer = kmalloc(sizeof(au1000_period_t), GFP_KERNEL); + stream->buffer = kmalloc(sizeof(struct au1000_period), GFP_KERNEL); if (! stream->buffer) return -ENOMEM; pointer = stream->buffer; @@ -191,14 +188,14 @@ au1000_setup_dma_link(audio_stream_t *stream, unsigned int period_bytes, } static void -au1000_dma_stop(audio_stream_t *stream) +au1000_dma_stop(struct audio_stream *stream) { snd_assert(stream->buffer, return); disable_dma(stream->dma); } static void -au1000_dma_start(audio_stream_t *stream) +au1000_dma_start(struct audio_stream *stream) { snd_assert(stream->buffer, return); @@ -223,8 +220,8 @@ au1000_dma_start(audio_stream_t *stream) static irqreturn_t au1000_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - audio_stream_t *stream = (audio_stream_t *) dev_id; - snd_pcm_substream_t *substream = stream->substream; + struct audio_stream *stream = (struct audio_stream *) dev_id; + struct snd_pcm_substream *substream = stream->substream; spin_lock(&stream->dma_lock); switch (get_dma_buffer_done(stream->dma)) { @@ -258,13 +255,13 @@ au1000_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) /*-------------------------- PCM Audio Streams -------------------------------*/ static unsigned int rates[] = {8000, 11025, 16000, 22050}; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = sizeof(rates) / sizeof(rates[0]), .list = rates, .mask = 0, }; -static snd_pcm_hardware_t snd_au1000_hw = +static struct snd_pcm_hardware snd_au1000_hw = { .info = (SNDRV_PCM_INFO_INTERLEAVED | \ SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID), @@ -284,9 +281,9 @@ static snd_pcm_hardware_t snd_au1000_hw = }; static int -snd_au1000_playback_open(snd_pcm_substream_t * substream) +snd_au1000_playback_open(struct snd_pcm_substream *substream) { - au1000_t *au1000 = substream->pcm->private_data; + struct snd_au1000 *au1000 = substream->pcm->private_data; au1000->stream[PLAYBACK]->substream = substream; au1000->stream[PLAYBACK]->buffer = NULL; @@ -297,9 +294,9 @@ snd_au1000_playback_open(snd_pcm_substream_t * substream) } static int -snd_au1000_capture_open(snd_pcm_substream_t * substream) +snd_au1000_capture_open(struct snd_pcm_substream *substream) { - au1000_t *au1000 = substream->pcm->private_data; + struct snd_au1000 *au1000 = substream->pcm->private_data; au1000->stream[CAPTURE]->substream = substream; au1000->stream[CAPTURE]->buffer = NULL; @@ -307,32 +304,31 @@ snd_au1000_capture_open(snd_pcm_substream_t * substream) substream->runtime->hw = snd_au1000_hw; return (snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_constraints_rates) < 0); - } static int -snd_au1000_playback_close(snd_pcm_substream_t * substream) +snd_au1000_playback_close(struct snd_pcm_substream *substream) { - au1000_t *au1000 = substream->pcm->private_data; + struct snd_au1000 *au1000 = substream->pcm->private_data; au1000->stream[PLAYBACK]->substream = NULL; return 0; } static int -snd_au1000_capture_close(snd_pcm_substream_t * substream) +snd_au1000_capture_close(struct snd_pcm_substream *substream) { - au1000_t *au1000 = substream->pcm->private_data; + struct snd_au1000 *au1000 = substream->pcm->private_data; au1000->stream[CAPTURE]->substream = NULL; return 0; } static int -snd_au1000_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) +snd_au1000_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - audio_stream_t *stream = substream->private_data; + struct audio_stream *stream = substream->private_data; int err; err = snd_pcm_lib_malloc_pages(substream, @@ -345,18 +341,18 @@ snd_au1000_hw_params(snd_pcm_substream_t * substream, } static int -snd_au1000_hw_free(snd_pcm_substream_t * substream) +snd_au1000_hw_free(struct snd_pcm_substream *substream) { - audio_stream_t *stream = substream->private_data; + struct audio_stream *stream = substream->private_data; au1000_release_dma_link(stream); return snd_pcm_lib_free_pages(substream); } static int -snd_au1000_playback_prepare(snd_pcm_substream_t * substream) +snd_au1000_playback_prepare(struct snd_pcm_substream *substream) { - au1000_t *au1000 = substream->pcm->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_au1000 *au1000 = substream->pcm->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->channels == 1) au1000_set_ac97_xmit_slots(au1000, AC97_SLOT_4); @@ -367,10 +363,10 @@ snd_au1000_playback_prepare(snd_pcm_substream_t * substream) } static int -snd_au1000_capture_prepare(snd_pcm_substream_t * substream) +snd_au1000_capture_prepare(struct snd_pcm_substream *substream) { - au1000_t *au1000 = substream->pcm->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_au1000 *au1000 = substream->pcm->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; if (runtime->channels == 1) au1000_set_ac97_recv_slots(au1000, AC97_SLOT_4); @@ -381,9 +377,9 @@ snd_au1000_capture_prepare(snd_pcm_substream_t * substream) } static int -snd_au1000_trigger(snd_pcm_substream_t * substream, int cmd) +snd_au1000_trigger(struct snd_pcm_substream *substream, int cmd) { - audio_stream_t *stream = substream->private_data; + struct audio_stream *stream = substream->private_data; int err = 0; spin_lock(&stream->dma_lock); @@ -403,10 +399,10 @@ snd_au1000_trigger(snd_pcm_substream_t * substream, int cmd) } static snd_pcm_uframes_t -snd_au1000_pointer(snd_pcm_substream_t * substream) +snd_au1000_pointer(struct snd_pcm_substream *substream) { - audio_stream_t *stream = substream->private_data; - snd_pcm_runtime_t *runtime = substream->runtime; + struct audio_stream *stream = substream->private_data; + struct snd_pcm_runtime *runtime = substream->runtime; long location; spin_lock(&stream->dma_lock); @@ -418,7 +414,7 @@ snd_au1000_pointer(snd_pcm_substream_t * substream) return bytes_to_frames(runtime,location); } -static snd_pcm_ops_t snd_card_au1000_playback_ops = { +static struct snd_pcm_ops snd_card_au1000_playback_ops = { .open = snd_au1000_playback_open, .close = snd_au1000_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -429,7 +425,7 @@ static snd_pcm_ops_t snd_card_au1000_playback_ops = { .pointer = snd_au1000_pointer, }; -static snd_pcm_ops_t snd_card_au1000_capture_ops = { +static struct snd_pcm_ops snd_card_au1000_capture_ops = { .open = snd_au1000_capture_open, .close = snd_au1000_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -441,9 +437,9 @@ static snd_pcm_ops_t snd_card_au1000_capture_ops = { }; static int __devinit -snd_au1000_pcm_new(void) +snd_au1000_pcm_new(struct snd_au1000 *au1000) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; unsigned long flags; @@ -492,9 +488,9 @@ snd_au1000_pcm_new(void) /*-------------------------- AC97 CODEC Control ------------------------------*/ static unsigned short -snd_au1000_ac97_read(ac97_t *ac97, unsigned short reg) +snd_au1000_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { - au1000_t *au1000 = ac97->private_data; + struct snd_au1000 *au1000 = ac97->private_data; u32 volatile cmd; u16 volatile data; int i; @@ -530,9 +526,9 @@ get the interupt driven case to work efficiently */ static void -snd_au1000_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) +snd_au1000_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - au1000_t *au1000 = ac97->private_data; + struct snd_au1000 *au1000 = ac97->private_data; u32 cmd; int i; @@ -553,18 +549,22 @@ get the interupt driven case to work efficiently */ } static int __devinit -snd_au1000_ac97_new(au1000_t *au1000) +snd_au1000_ac97_new(struct snd_au1000 *au1000) { int err; - ac97_bus_t bus, *pbus; - ac97_t ac97; + struct snd_ac97_bus *pbus; + struct snd_ac97_template ac97; + static struct snd_ac97_bus_ops ops = { + .write = snd_au1000_ac97_write, + .read = snd_au1000_ac97_read, + }; if ((au1000->ac97_res_port = request_region(AC97C_CONFIG, - sizeof(au1000_ac97_reg_t), "Au1x00 AC97")) == NULL) { + sizeof(struct au1000_ac97_reg), "Au1x00 AC97")) == NULL) { snd_printk(KERN_ERR "ALSA AC97: can't grap AC97 port\n"); return -EBUSY; } - au1000->ac97_ioport = (au1000_ac97_reg_t *) au1000->ac97_res_port->start; + au1000->ac97_ioport = (struct au1000_ac97_reg *) au1000->ac97_res_port->start; spin_lock_init(&au1000->ac97_lock); @@ -599,9 +599,9 @@ snd_au1000_ac97_new(au1000_t *au1000) /*------------------------------ Setup / Destroy ----------------------------*/ void -snd_au1000_free(snd_card_t *card) +snd_au1000_free(struct snd_card *card) { - au1000_t *au1000 = card->private_data; + struct snd_au1000 *au1000 = card->private_data; if (au1000->ac97_res_port) { /* put internal AC97 block into reset */ @@ -621,16 +621,16 @@ snd_au1000_free(snd_card_t *card) } -static snd_card_t *au1000_card; +static struct snd_card *au1000_card; static int __init au1000_init(void) { int err; - snd_card_t *card; - au1000_t *au1000; + struct snd_card *card; + struct snd_au1000 *au1000; - card = snd_card_new(-1, "AC97", THIS_MODULE, sizeof(au1000_t)); + card = snd_card_new(-1, "AC97", THIS_MODULE, sizeof(struct snd_au1000)); if (card == NULL) return -ENOMEM; @@ -641,8 +641,8 @@ au1000_init(void) au1000->stream[PLAYBACK]->dma = -1; au1000->stream[CAPTURE]->dma = -1; au1000->ac97_res_port = NULL; - au1000->stream[PLAYBACK] = kmalloc(sizeof(audio_stream_t), GFP_KERNEL); - au1000->stream[CAPTURE] = kmalloc(sizeof(audio_stream_t), GFP_KERNEL); + au1000->stream[PLAYBACK] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL); + au1000->stream[CAPTURE] = kmalloc(sizeof(struct audio_stream), GFP_KERNEL); if (au1000->stream[PLAYBACK] == NULL || au1000->stream[CAPTURE] == NULL) { snd_card_free(card); -- cgit v1.1 From 446ab5f5039df4209a2e28752bd48c99007d3d82 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@suse.de> Date: Thu, 17 Nov 2005 15:12:54 +0100 Subject: [ALSA] Remove xxx_t typedefs: Documentation Modules: Documentation Remove xxx_t typedefs from documentation. Signed-off-by: Takashi Iwai <tiwai@suse.de> --- .../sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 419 ++++++++++----------- Documentation/sound/alsa/hda_codec.txt | 14 +- 2 files changed, 214 insertions(+), 219 deletions(-) diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index 260334c..f2e59fe 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -403,9 +403,8 @@ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* definition of the chip-specific record */ - typedef struct snd_mychip mychip_t; - struct snd_mychip { - snd_card_t *card; + struct mychip { + struct snd_card *card; // rest of implementation will be in the section // "PCI Resource Managements" }; @@ -413,7 +412,7 @@ /* chip-specific destructor * (see "PCI Resource Managements") */ - static int snd_mychip_free(mychip_t *chip) + static int snd_mychip_free(struct mychip *chip) { .... // will be implemented later... } @@ -421,22 +420,21 @@ /* component-destructor * (see "Management of Cards and Components") */ - static int snd_mychip_dev_free(snd_device_t *device) + static int snd_mychip_dev_free(struct snd_device *device) { - mychip_t *chip = device->device_data; - return snd_mychip_free(chip); + return snd_mychip_free(device->device_data); } /* chip-specific constructor * (see "Management of Cards and Components") */ - static int __devinit snd_mychip_create(snd_card_t *card, + static int __devinit snd_mychip_create(struct snd_card *card, struct pci_dev *pci, - mychip_t **rchip) + struct mychip **rchip) { - mychip_t *chip; + struct mychip *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_mychip_dev_free, }; @@ -474,8 +472,8 @@ const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - mychip_t *chip; + struct snd_card *card; + struct mychip *chip; int err; /* (1) */ @@ -582,7 +580,7 @@ <informalexample> <programlisting> <![CDATA[ - snd_card_t *card; + struct snd_card *card; .... card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); ]]> @@ -605,7 +603,7 @@ <informalexample> <programlisting> <![CDATA[ - mychip_t *chip; + struct mychip *chip; .... if ((err = snd_mychip_create(card, pci, &chip)) < 0) { snd_card_free(card); @@ -806,7 +804,7 @@ <informalexample> <programlisting> <![CDATA[ - snd_card_t *card; + struct snd_card *card; card = snd_card_new(index, id, module, extra_size); ]]> </programlisting> @@ -830,7 +828,7 @@ <para> After the card is created, you can attach the components (devices) to the card instance. On ALSA driver, a component is - represented as a <type>snd_device_t</type> object. + represented as a struct <structname>snd_device</structname> object. A component can be a PCM instance, a control interface, a raw MIDI interface, etc. Each of such instances has one component entry. @@ -891,14 +889,11 @@ The chip-specific information, e.g. the i/o port address, its resource pointer, or the irq number, is stored in the chip-specific record. - Usually, the chip-specific record is typedef'ed as - <type>xxx_t</type> like the following: <informalexample> <programlisting> <![CDATA[ - typedef struct snd_mychip mychip_t; - struct snd_mychip { + struct mychip { .... }; ]]> @@ -918,12 +913,12 @@ <informalexample> <programlisting> <![CDATA[ - card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(mychip_t)); + card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct mychip)); ]]> </programlisting> </informalexample> - whether <type>mychip_t</type> is the type of the chip record. + whether struct <structname>mychip</structname> is the type of the chip record. </para> <para> @@ -932,7 +927,7 @@ <informalexample> <programlisting> <![CDATA[ - mychip_t *chip = (mychip_t *)card->private_data; + struct mychip *chip = (struct mychip *)card->private_data; ]]> </programlisting> </informalexample> @@ -954,8 +949,8 @@ <informalexample> <programlisting> <![CDATA[ - snd_card_t *card; - mychip_t *chip; + struct snd_card *card; + struct mychip *chip; card = snd_card_new(index[dev], id[dev], THIS_MODULE, NULL); ..... chip = kzalloc(sizeof(*chip), GFP_KERNEL); @@ -971,8 +966,8 @@ <informalexample> <programlisting> <![CDATA[ - struct snd_mychip { - snd_card_t *card; + struct mychip { + struct snd_card *card; .... }; ]]> @@ -1000,7 +995,7 @@ <informalexample> <programlisting> <![CDATA[ - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_mychip_dev_free, }; .... @@ -1018,10 +1013,9 @@ <informalexample> <programlisting> <![CDATA[ - static int snd_mychip_dev_free(snd_device_t *device) + static int snd_mychip_dev_free(struct snd_device *device) { - mychip_t *chip = device->device_data; - return snd_mychip_free(chip); + return snd_mychip_free(device->device_data); } ]]> </programlisting> @@ -1087,15 +1081,15 @@ <title>PCI Resource Managements Example port = pci_resource_start(pci, 0); if (request_irq(pci->irq, snd_mychip_interrupt, - SA_INTERRUPT|SA_SHIRQ, "My Chip", - (void *)chip)) { + SA_INTERRUPT|SA_SHIRQ, "My Chip", chip)) { printk(KERN_ERR "cannot grab irq %d\n", pci->irq); snd_mychip_free(chip); return -EBUSY; @@ -1268,14 +1261,14 @@ Now assume that this PCI device has an I/O port with 8 bytes - and an interrupt. Then mychip_t will have the + and an interrupt. Then struct mychip will have the following fields: irq, snd_mychip_interrupt, - SA_INTERRUPT|SA_SHIRQ, "My Chip", - (void *)chip)) { + SA_INTERRUPT|SA_SHIRQ, "My Chip", chip)) { printk(KERN_ERR "cannot grab irq %d\n", pci->irq); snd_mychip_free(chip); return -EBUSY; @@ -1372,7 +1364,7 @@ static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - mychip_t *chip = dev_id; + struct mychip *chip = dev_id; .... return IRQ_HANDLED; } @@ -1487,7 +1479,7 @@ iobase_virt) @@ -1537,7 +1529,7 @@ Registration of Device Struct At some point, typically after calling snd_device_new(), - you need to register the struct device of the chip + you need to register the struct device of the chip you're handling for udev and co. ALSA provides a macro for compatibility with older kernels. Simply call like the following: @@ -1739,7 +1731,7 @@ .... /* hardware definition */ - static snd_pcm_hardware_t snd_mychip_playback_hw = { + static struct snd_pcm_hardware snd_mychip_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1758,7 +1750,7 @@ }; /* hardware definition */ - static snd_pcm_hardware_t snd_mychip_capture_hw = { + static struct snd_pcm_hardware snd_mychip_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -1777,10 +1769,10 @@ }; /* open callback */ - static int snd_mychip_playback_open(snd_pcm_substream_t *substream) + static int snd_mychip_playback_open(struct snd_pcm_substream *substream) { - mychip_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct mychip *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; runtime->hw = snd_mychip_playback_hw; // more hardware-initialization will be done here @@ -1788,19 +1780,19 @@ } /* close callback */ - static int snd_mychip_playback_close(snd_pcm_substream_t *substream) + static int snd_mychip_playback_close(struct snd_pcm_substream *substream) { - mychip_t *chip = snd_pcm_substream_chip(substream); + struct mychip *chip = snd_pcm_substream_chip(substream); // the hardware-specific codes will be here return 0; } /* open callback */ - static int snd_mychip_capture_open(snd_pcm_substream_t *substream) + static int snd_mychip_capture_open(struct snd_pcm_substream *substream) { - mychip_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct mychip *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; runtime->hw = snd_mychip_capture_hw; // more hardware-initialization will be done here @@ -1808,33 +1800,33 @@ } /* close callback */ - static int snd_mychip_capture_close(snd_pcm_substream_t *substream) + static int snd_mychip_capture_close(struct snd_pcm_substream *substream) { - mychip_t *chip = snd_pcm_substream_chip(substream); + struct mychip *chip = snd_pcm_substream_chip(substream); // the hardware-specific codes will be here return 0; } /* hw_params callback */ - static int snd_mychip_pcm_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t * hw_params) + static int snd_mychip_pcm_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } /* hw_free callback */ - static int snd_mychip_pcm_hw_free(snd_pcm_substream_t *substream) + static int snd_mychip_pcm_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } /* prepare callback */ - static int snd_mychip_pcm_prepare(snd_pcm_substream_t *substream) + static int snd_mychip_pcm_prepare(struct snd_pcm_substream *substream) { - mychip_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct mychip *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; /* set up the hardware with the current configuration * for example... @@ -1849,7 +1841,7 @@ } /* trigger callback */ - static int snd_mychip_pcm_trigger(snd_pcm_substream_t *substream, + static int snd_mychip_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { switch (cmd) { @@ -1866,9 +1858,9 @@ /* pointer callback */ static snd_pcm_uframes_t - snd_mychip_pcm_pointer(snd_pcm_substream_t *substream) + snd_mychip_pcm_pointer(struct snd_pcm_substream *substream) { - mychip_t *chip = snd_pcm_substream_chip(substream); + struct mychip *chip = snd_pcm_substream_chip(substream); unsigned int current_ptr; /* get the current hardware pointer */ @@ -1877,7 +1869,7 @@ } /* operators */ - static snd_pcm_ops_t snd_mychip_playback_ops = { + static struct snd_pcm_ops snd_mychip_playback_ops = { .open = snd_mychip_playback_open, .close = snd_mychip_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1889,7 +1881,7 @@ }; /* operators */ - static snd_pcm_ops_t snd_mychip_capture_ops = { + static struct snd_pcm_ops snd_mychip_capture_ops = { .open = snd_mychip_capture_open, .close = snd_mychip_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1905,9 +1897,9 @@ */ /* create a pcm device */ - static int __devinit snd_mychip_new_pcm(mychip_t *chip) + static int __devinit snd_mychip_new_pcm(struct mychip *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "My Chip", 0, 1, 1, @@ -1944,9 +1936,9 @@ card, "My Chip", 0, 1, 1, @@ -1989,13 +1981,13 @@ specify more numbers, but they must be handled properly in open/close, etc. callbacks. When you need to know which substream you are referring to, then it can be obtained from - snd_pcm_substream_t data passed to each callback + struct snd_pcm_substream data passed to each callback as follows: number; ]]> @@ -2024,7 +2016,7 @@ PCM Instance with a Destructor my_private_pcm_data); // do what you like else .... } - static int __devinit snd_mychip_new_pcm(mychip_t *chip) + static int __devinit snd_mychip_new_pcm(struct mychip *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; .... /* allocate your own data */ chip->my_private_pcm_data = kmalloc(...); @@ -2149,7 +2141,7 @@ @@ -2252,7 +2244,7 @@ struct _snd_pcm_runtime {
Hardware Description - The hardware descriptor (snd_pcm_hardware_t) + The hardware descriptor (struct snd_pcm_hardware) contains the definitions of the fundamental hardware configuration. Above all, you'll need to define this in @@ -2267,7 +2259,7 @@ struct _snd_pcm_runtime { runtime; + struct snd_pcm_runtime *runtime = substream->runtime; ... runtime->hw = snd_mychip_playback_hw; /* common definition */ if (chip->model == VERY_OLD_ONE) @@ -2282,7 +2274,7 @@ struct _snd_pcm_runtime { Running Status The running status can be referred via runtime->status. - This is the pointer to snd_pcm_mmap_status_t + This is the pointer to struct snd_pcm_mmap_status record. For example, you can get the current DMA hardware pointer via runtime->status->hw_ptr. @@ -2520,7 +2512,7 @@ struct _snd_pcm_runtime { The DMA application pointer can be referred via runtime->control, which points - snd_pcm_mmap_control_t record. + struct snd_pcm_mmap_control record. However, accessing directly to this value is not recommended.
@@ -2542,9 +2534,9 @@ struct _snd_pcm_runtime { runtime->private_data = data; @@ -2586,7 +2578,7 @@ struct _snd_pcm_runtime { The callback function takes at least the argument with - snd_pcm_substream_t pointer. For retrieving the + snd_pcm_substream pointer. For retrieving the chip record from the given substream instance, you can use the following macro. @@ -2594,7 +2586,7 @@ struct _snd_pcm_runtime { @@ -2616,7 +2608,7 @@ struct _snd_pcm_runtime { @@ -2631,10 +2623,10 @@ struct _snd_pcm_runtime { runtime; + struct mychip *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; runtime->hw = snd_mychip_playback_hw; return 0; @@ -2667,7 +2659,7 @@ struct _snd_pcm_runtime { @@ -2682,7 +2674,7 @@ struct _snd_pcm_runtime { runtime->private_data); @@ -2709,8 +2701,8 @@ struct _snd_pcm_runtime { @@ -2785,7 +2777,7 @@ struct _snd_pcm_runtime { @@ -2820,7 +2812,7 @@ struct _snd_pcm_runtime { @@ -2869,7 +2861,7 @@ struct _snd_pcm_runtime { @@ -2939,7 +2931,7 @@ struct _snd_pcm_runtime { @@ -3067,7 +3059,7 @@ struct _snd_pcm_runtime { static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - mychip_t *chip = dev_id; + struct mychip *chip = dev_id; spin_lock(&chip->lock); .... if (pcm_irq_invoked(chip)) { @@ -3111,7 +3103,7 @@ struct _snd_pcm_runtime { static irqreturn_t snd_mychip_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - mychip_t *chip = dev_id; + struct mychip *chip = dev_id; spin_lock(&chip->lock); .... if (pcm_irq_invoked(chip)) { @@ -3221,13 +3213,13 @@ struct _snd_pcm_runtime { snd_pcm_hardware_t stucture (or in any + specified in the snd_pcm_hardware stucture (or in any other constraint_list). You can build a rule like this: Example of Hardware Constraints for Channels min < 2) { @@ -3298,12 +3291,13 @@ struct _snd_pcm_runtime { Example of Hardware Constraints for Channels bits[0] == SNDRV_PCM_FMTBIT_S16_LE) { @@ -3376,13 +3370,13 @@ struct _snd_pcm_runtime { callbacks: info, get and put. Then, define a - snd_kcontrol_new_t record, such as: + struct snd_kcontrol_new record, such as: Definition of a Control The info callback is used to get the detailed information of this control. This must store the - values of the given snd_ctl_elem_info_t + values of the given struct snd_ctl_elem_info object. For example, for a boolean control with a single element will be: @@ -3607,8 +3601,8 @@ struct _snd_pcm_runtime { Example of info callback type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 1; @@ -3642,8 +3636,8 @@ struct _snd_pcm_runtime { Example of get callback value.integer.value[0] = get_some_value(chip); return 0; } @@ -3717,8 +3711,8 @@ struct _snd_pcm_runtime { private_value & 0xff; int shift = (kcontrol->private_value >> 16) & 0xff; @@ -3754,10 +3748,10 @@ struct _snd_pcm_runtime { Example of put callback current_value != ucontrol->value.integer.value[0]) { @@ -3814,7 +3808,7 @@ struct _snd_pcm_runtime { where my_control is the - snd_kcontrol_new_t object defined above, and chip + struct snd_kcontrol_new object defined above, and chip is the object pointer to be passed to kcontrol->private_data which can be referred in callbacks. @@ -3822,7 +3816,7 @@ struct _snd_pcm_runtime { snd_ctl_new1() allocates a new - snd_kcontrol_t instance (that's why the definition + snd_kcontrol instance (that's why the definition of my_control can be with __devinitdata prefix), and snd_ctl_add assigns the given @@ -3849,7 +3843,7 @@ struct _snd_pcm_runtime { control id pointer for the notification. The event-mask specifies the types of notification, for example, in the above example, the change of control values is notified. - The id pointer is the pointer of snd_ctl_elem_id_t + The id pointer is the pointer of struct snd_ctl_elem_id to be notified. You can find some examples in es1938.c or es1968.c for hardware volume interrupts. @@ -3882,35 +3876,35 @@ struct _snd_pcm_runtime { Example of AC97 Interface private_data; + struct mychip *chip = ac97->private_data; .... // read a register value here from the codec return the_register_value; } - static void snd_mychip_ac97_write(ac97_t *ac97, + static void snd_mychip_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { - mychip_t *chip = ac97->private_data; + struct mychip *chip = ac97->private_data; .... // write the given register value to the codec } - static int snd_mychip_ac97(mychip_t *chip) + static int snd_mychip_ac97(struct mychip *chip) { - ac97_bus_t *bus; - ac97_template_t ac97; + struct snd_ac97_bus *bus; + struct snd_ac97_template ac97; int err; - static ac97_bus_ops_t ops = { + static struct snd_ac97_bus_ops ops = { .write = snd_mychip_ac97_write, .read = snd_mychip_ac97_read, }; @@ -3937,8 +3931,8 @@ struct _snd_pcm_runtime { - And then call snd_ac97_mixer() with an ac97_template_t + And then call snd_ac97_mixer() with an + struct snd_ac97_template record together with the bus pointer created above. private_data; + struct mychip *chip = ac97->private_data; .... return the_register_value; } @@ -4016,7 +4011,7 @@ struct _snd_pcm_runtime { @@ -4163,7 +4158,7 @@ struct _snd_pcm_runtime { Multiple Codecs When there are several codecs on the same card, you need to - call snd_ac97_new() multiple times with + call snd_ac97_mixer() multiple times with ac97.num=1 or greater. The num field specifies the codec number. @@ -4212,7 +4207,7 @@ struct _snd_pcm_runtime { @@ -4253,17 +4248,17 @@ struct _snd_pcm_runtime { Usually, the port address corresponds to the command port and port + 1 corresponds to the data port. If not, you may change the cport field of - mpu401_t manually - afterward. However, mpu401_t pointer is not + struct snd_mpu401 manually + afterward. However, snd_mpu401 pointer is not returned explicitly by snd_mpu401_uart_new(). You need to cast rmidi->private_data to - mpu401_t explicitly, + snd_mpu401 explicitly, private_data; ]]> @@ -4359,7 +4354,7 @@ struct _snd_pcm_runtime { card, "MyMIDI", 0, outs, ins, &rmidi); if (err < 0) return err; @@ -4419,7 +4414,7 @@ struct _snd_pcm_runtime { streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams) { - substream = list_entry(list, snd_rawmidi_substream_t, list); + substream = list_entry(list, struct snd_rawmidi_substream, list); sprintf(substream->name, "My MIDI Port %d", substream->number + 1); } /* same for SNDRV_RAWMIDI_STREAM_INPUT */ @@ -4463,12 +4458,12 @@ struct _snd_pcm_runtime { If there is more than one port, your callbacks can determine the - port index from the snd_rawmidi_substream_t data passed to each + port index from the struct snd_rawmidi_substream data passed to each callback: number; ]]> @@ -4481,7 +4476,7 @@ struct _snd_pcm_runtime { @@ -4499,7 +4494,7 @@ struct _snd_pcm_runtime { @@ -4522,7 +4517,7 @@ struct _snd_pcm_runtime { @@ -4547,7 +4542,7 @@ struct _snd_pcm_runtime { @@ -4603,7 +4598,7 @@ struct _snd_pcm_runtime { @@ -4647,7 +4642,7 @@ struct _snd_pcm_runtime { @@ -4661,7 +4656,7 @@ struct _snd_pcm_runtime { This callback is optional. If you do not set - drain in the snd_rawmidi_ops_t + drain in the struct snd_rawmidi_ops structure, ALSA will simply wait for 50 milliseconds instead. @@ -4703,7 +4698,7 @@ struct _snd_pcm_runtime { @@ -4736,7 +4731,7 @@ struct _snd_pcm_runtime { @@ -4767,7 +4762,7 @@ struct _snd_pcm_runtime { @@ -4804,7 +4799,7 @@ struct _snd_pcm_runtime { @@ -4823,7 +4818,7 @@ struct _snd_pcm_runtime { private_data = p; hw->private_free = mydata_free; ]]> @@ -4835,9 +4830,9 @@ struct _snd_pcm_runtime { private_data; + struct mydata *p = hw->private_data; kfree(p); } ]]> @@ -5061,9 +5056,9 @@ struct _snd_pcm_runtime { @@ -5144,7 +5139,7 @@ struct _snd_pcm_runtime { @@ -5211,7 +5206,7 @@ struct _snd_pcm_runtime { dma_private; + struct snd_sg_buf *sgbuf = (struct snd_sg_buf_t*)substream->dma_private; ]]> @@ -5266,7 +5261,7 @@ struct _snd_pcm_runtime { #include /* get the physical page pointer on the given offset */ - static struct page *mychip_page(snd_pcm_substream_t *substream, + static struct page *mychip_page(struct snd_pcm_substream *substream, unsigned long offset) { void *pageptr = substream->runtime->dma_area + offset; @@ -5301,7 +5296,7 @@ struct _snd_pcm_runtime { @@ -5345,8 +5340,8 @@ struct _snd_pcm_runtime { @@ -5361,10 +5356,10 @@ struct _snd_pcm_runtime { private_data; + struct my_chip *chip = entry->private_data; snd_iprintf(buffer, "This is my chip!\n"); snd_iprintf(buffer, "Port = %ld\n", chip->port); @@ -5453,7 +5448,7 @@ struct _snd_pcm_runtime { pm_private_data; + struct mychip *chip = card->pm_private_data; /* (2) */ snd_pcm_suspend_all(chip->pcm); /* (3) */ @@ -5570,10 +5565,10 @@ struct _snd_pcm_runtime { pm_private_data; + struct mychip *chip = card->pm_private_data; /* (2) */ pci_enable_device(chip->pci); /* (3) */ @@ -5602,8 +5597,8 @@ struct _snd_pcm_runtime { const struct pci_device_id *pci_id) { .... - snd_card_t *card; - mychip_t *chip; + struct snd_card *card; + struct mychip *chip; .... snd_card_set_pm_callback(card, snd_my_suspend, snd_my_resume, chip); .... diff --git a/Documentation/sound/alsa/hda_codec.txt b/Documentation/sound/alsa/hda_codec.txt index e9d07b8..0be57ed 100644 --- a/Documentation/sound/alsa/hda_codec.txt +++ b/Documentation/sound/alsa/hda_codec.txt @@ -63,7 +63,7 @@ The bus instance is created via snd_hda_bus_new(). You need to pass the card instance, the template, and the pointer to store the resultant bus instance. -int snd_hda_bus_new(snd_card_t *card, const struct hda_bus_template *temp, +int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, struct hda_bus **busp); It returns zero if successful. A negative return value means any @@ -166,14 +166,14 @@ The ops field contains the following callback functions: struct hda_pcm_ops { int (*open)(struct hda_pcm_stream *info, struct hda_codec *codec, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); int (*close)(struct hda_pcm_stream *info, struct hda_codec *codec, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); int (*prepare)(struct hda_pcm_stream *info, struct hda_codec *codec, unsigned int stream_tag, unsigned int format, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec, - snd_pcm_substream_t *substream); + struct snd_pcm_substream *substream); }; All are non-NULL, so you can call them safely without NULL check. @@ -284,7 +284,7 @@ parameter, and PCI subsystem IDs. If the matching entry is found, it returns the config field value. snd_hda_add_new_ctls() can be used to create and add control entries. -Pass the zero-terminated array of snd_kcontrol_new_t. The same array +Pass the zero-terminated array of struct snd_kcontrol_new. The same array can be passed to snd_hda_resume_ctls() for resume. Note that this will call control->put callback of these entries. So, put callback should check codec->in_resume and force to restore the @@ -292,7 +292,7 @@ given value if it's non-zero even if the value is identical with the cached value. Macros HDA_CODEC_VOLUME(), HDA_CODEC_MUTE() and their variables can be -used for the entry of snd_kcontrol_new_t. +used for the entry of struct snd_kcontrol_new. The input MUX helper callbacks for such a control are provided, too: snd_hda_input_mux_info() and snd_hda_input_mux_put(). See -- cgit v1.1 From 9398441edaf0dc64eca828e3ce7a0326c8640d4c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 15:30:43 +0100 Subject: [ALSA] ac97-codec - Better ac97_bus name Modules: AC97 Codec Generate a better name string for ac97_bus sysfs interface including the name of ac97 codec chip. Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index bdb6a8c..9faeaef 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -137,7 +137,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = { { 0x43585421, 0xffffffff, "HSD11246", NULL, NULL }, // SmartMC II { 0x43585428, 0xfffffff8, "Cx20468", patch_conexant, NULL }, // SmartAMC fixme: the mask might be different { 0x44543031, 0xfffffff0, "DT0398", NULL, NULL }, -{ 0x454d4328, 0xffffffff, "28028", NULL, NULL }, // same as TR28028? +{ 0x454d4328, 0xffffffff, "EM28028", NULL, NULL }, // same as TR28028? { 0x45838308, 0xffffffff, "ESS1988", NULL, NULL }, { 0x48525300, 0xffffff00, "HMP9701", NULL, NULL }, { 0x49434501, 0xffffffff, "ICE1230", NULL, NULL }, @@ -1816,7 +1816,9 @@ static int snd_ac97_dev_register(struct snd_device *device) ac97->dev.bus = &ac97_bus_type; ac97->dev.parent = ac97->bus->card->dev; ac97->dev.release = ac97_device_release; - snprintf(ac97->dev.bus_id, BUS_ID_SIZE, "card%d-%d", ac97->bus->card->number, ac97->num); + snprintf(ac97->dev.bus_id, BUS_ID_SIZE, "%d-%d:%s", + ac97->bus->card->number, ac97->num, + snd_ac97_get_short_name(ac97)); if ((err = device_register(&ac97->dev)) < 0) { snd_printk(KERN_ERR "Can't register ac97 bus\n"); ac97->dev.bus = NULL; -- cgit v1.1 From fd66e0d0591dd12eb0bea1e9f3aa194bb93cebbd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 15:31:34 +0100 Subject: [ALSA] hda-codec - Add AD1988 support Modules: HDA Codec driver Add AD1988 codec support to hda-codec driver. Still experimental, and no BIOS configuration parser is implemented yet. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 785 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 785 insertions(+) diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 1f371fe..25116a8 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -41,6 +41,7 @@ struct ad198x_spec { * max_channels, dacs must be set * dig_out_nid and hp_nid are optional */ + unsigned int cur_eapd; /* capture */ unsigned int num_adc_nids; @@ -857,11 +858,795 @@ static int patch_ad1981(struct hda_codec *codec) /* + * AD1988 + * + * Output pins and routes + * + * Pin Mix Sel DAC + * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 + * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 + * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a + * port-D 0x12 (mute/hp) <- 0x29 <- 04 + * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a + * port-F 0x16 (mute) <- 0x2a <- 06 + * port-G 0x24 (mute) <- 0x27 <- 05 + * port-H 0x25 (mute) <- 0x28 <- 0a + * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 + * + * + * Input pins and routes + * + * pin boost mix input # / adc input # + * port-A 0x11 -> 0x38 -> mix 2, ADC 0 + * port-B 0x14 -> 0x39 -> mix 0, ADC 1 + * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2 + * port-D 0x12 -> 0x3d -> mix 3, ADC 8 + * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4 + * port-F 0x16 -> 0x3b -> mix 5, ADC 3 + * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6 + * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7 + * + * + * DAC assignment + * front DAC - 04 + * surr DAC - 06 + * CLFE DAC - 05 + * side DAC - 0a + * opt DAC - 03 + * + * Inputs of Analog Mix (0x20) + * 0:Port-B (front mic) + * 1:Port-C/G/H (line-in) + * 2:Port-A + * 3:Port-D (line-in/2) + * 4:Port-E/G/H (mic-in) + * 5:Port-F (mic2-in) + * 6:CD + * 7:Beep + * + * ADC selection + * 0:Port-A + * 1:Port-B (front mic-in) + * 2:Port-C (line-in) + * 3:Port-F (mic2-in) + * 4:Port-E (mic-in) + * 5:CD + * 6:Port-G + * 7:Port-H + * 8:Port-D (line-in/2) + * 9:Mix + * + * Proposed pin assignments by the datasheet + * + * 6-stack + * Port-A front headphone + * B front mic-in + * C rear line-in + * D rear front-out + * E rear mic-in + * F rear surround + * G rear CLFE + * H rear side + * + * 3-stack + * Port-A front headphone + * B front mic + * C rear line-in/surround + * D rear front-out + * E rear mic-in/CLFE + * + * laptop + * Port-A headphone + * B mic-in + * C docking station + * D internal speaker (with EAPD) + * E/F quad mic array + */ + + +/* models */ +enum { + AD1988_6STACK, + AD1988_6STACK_DIG, + AD1988_3STACK, + AD1988_3STACK_DIG, + AD1988_LAPTOP, + AD1988_LAPTOP_DIG, + AD1988_MODEL_LAST, +}; + + +/* + * mixers + */ + +static hda_nid_t ad1988_dac_nids[4] = { + 0x04, 0x06, 0x05, 0x0a +}; + +static hda_nid_t ad1988_adc_nids[3] = { + 0x08, 0x09, 0x0f +}; + +#define AD1988_SPDIF_OUT 0x02 +#define AD1988_SPDIF_IN 0x07 + +static struct hda_input_mux ad1988_6stack_capture_source = { + .num_items = 5, + .items = { + { "Front Mic", 0x0 }, + { "Line", 0x1 }, + { "Mic", 0x4 }, + { "CD", 0x5 }, + { "Mix", 0x9 }, + }, +}; + +static struct hda_input_mux ad1988_laptop_capture_source = { + .num_items = 3, + .items = { + { "Mic/Line", 0x0 }, + { "CD", 0x5 }, + { "Mix", 0x9 }, + }, +}; + +/* + */ +static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct ad198x_spec *spec = codec->spec; + return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode, + spec->num_channel_mode); +} + +static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct ad198x_spec *spec = codec->spec; + return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode, + spec->num_channel_mode, spec->multiout.max_channels); +} + +static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct ad198x_spec *spec = codec->spec; + return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode, + spec->num_channel_mode, &spec->multiout.max_channels); +} + +/* + * EAPD control + */ +static int ad1988_eapd_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int ad1988_eapd_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct ad198x_spec *spec = codec->spec; + ucontrol->value.enumerated.item[0] = ! spec->cur_eapd; + return 0; +} + +static int ad1988_eapd_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct ad198x_spec *spec = codec->spec; + unsigned int eapd; + eapd = ! ucontrol->value.enumerated.item[0]; + if (eapd == spec->cur_eapd && ! codec->in_resume) + return 0; + spec->cur_eapd = eapd; + snd_hda_codec_write(codec, 0x12 /* port-D */, + 0, AC_VERB_SET_EAPD_BTLENABLE, + eapd ? 0x02 : 0x00); + return 0; +} + +/* 6-stack mode */ +static struct snd_kcontrol_new ad1988_6stack_mixers[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT), + + HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), + HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), + HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), + HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), + HDA_BIND_MUTE("Side Playback Switch", 0x28, 2, HDA_INPUT), + HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), + HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), + + HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), + + HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), + + HDA_CODEC_VOLUME("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + + HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), + + { } /* end */ +}; + +/* 3-stack mode */ +static struct snd_kcontrol_new ad1988_3stack_mixers[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), + + HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), + HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), + HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), + HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), + HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), + HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), + + HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x20, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x20, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x4, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x4, HDA_INPUT), + + HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), + + HDA_CODEC_VOLUME("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + + HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Mic Boost", 0x3c, 0x0, HDA_OUTPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Channel Mode", + .info = ad198x_ch_mode_info, + .get = ad198x_ch_mode_get, + .put = ad198x_ch_mode_put, + }, + + { } /* end */ +}; + +/* laptop mode */ +static struct snd_kcontrol_new ad1988_laptop_mixers[] = { + HDA_CODEC_VOLUME("PCM Playback Volume", 0x04, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("PCM Playback Switch", 0x29, 0x0, HDA_INPUT), + HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), + + HDA_CODEC_VOLUME("CD Playback Volume", 0x20, 0x6, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x20, 0x6, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x20, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x20, 0x1, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x20, 0x1, HDA_INPUT), + + HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), + + HDA_CODEC_VOLUME("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + + HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT), + + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "External Amplifier", + .info = ad1988_eapd_info, + .get = ad1988_eapd_get, + .put = ad1988_eapd_put, + }, + + { } /* end */ +}; + +/* capture */ +static struct snd_kcontrol_new ad1988_capture_mixers[] = { + HDA_CODEC_VOLUME("Capture Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Capture Switch", 0x0c, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x0d, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x0d, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x0e, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x0e, 0x0, HDA_OUTPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + * FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 3, + .info = ad198x_mux_enum_info, + .get = ad198x_mux_enum_get, + .put = ad198x_mux_enum_put, + }, + { } /* end */ +}; + +static int ad1988_spdif_playback_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static char *texts[] = { + "PCM", "ADC1", "ADC2", "ADC3" + }; + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 4; + if (uinfo->value.enumerated.item >= 4) + uinfo->value.enumerated.item = 3; + strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]); + return 0; +} + +static int ad1988_spdif_playback_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + unsigned int sel; + + sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); + if (sel > 0) { + sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0); + if (sel <= 3) + sel++; + else + sel = 0; + } + ucontrol->value.enumerated.item[0] = sel; + return 0; +} + +static int ad1988_spdif_playback_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + unsigned int sel; + int change; + + sel = snd_hda_codec_read(codec, 0x02, 0, AC_VERB_GET_CONNECT_SEL, 0); + if (! ucontrol->value.enumerated.item[0]) { + change = sel != 0; + if (change) + snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 0); + } else { + change = sel == 0; + if (change) + snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, 1); + sel = snd_hda_codec_read(codec, 0x0b, 0, AC_VERB_GET_CONNECT_SEL, 0) + 1; + change |= sel == ucontrol->value.enumerated.item[0]; + if (change) + snd_hda_codec_write(codec, 0x02, 0, AC_VERB_SET_CONNECT_SEL, + ucontrol->value.enumerated.item[0] - 1); + } + return change; +} + +static struct snd_kcontrol_new ad1988_spdif_out_mixers[] = { + HDA_CODEC_VOLUME("IEC958 Playback Volume", 0x1b, 0x0, HDA_OUTPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "IEC958 Playback Source", + .info = ad1988_spdif_playback_source_info, + .get = ad1988_spdif_playback_source_get, + .put = ad1988_spdif_playback_source_put, + }, + { } /* end */ +}; + +static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = { + HDA_CODEC_VOLUME("IEC958 Capture Volume", 0x1c, 0x0, HDA_INPUT), + { } /* end */ +}; + + +/* + * initialization verbs + */ + +/* + * for 6-stack (+dig) + */ +static struct hda_verb ad1988_6stack_init_verbs[] = { + /* Front, Surround, CLFE, side DAC; mute as default */ + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + /* Port-A front headphon path */ + {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + /* Port-D line-out path */ + {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + /* Port-F surround path */ + {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x2a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + /* Port-G CLFE path */ + {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x27, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + /* Port-H side path */ + {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x28, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x25, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + /* Mono out path */ + {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ + {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ + /* Port-B front mic-in path */ + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + /* Port-C line-in path */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, + /* Port-E mic-in path */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, + + { } +}; + +static struct hda_verb ad1988_capture_init_verbs[] = { + /* mute analog mix */ + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, + /* select ADCs - front-mic */ + {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, + {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, + {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, + /* ADCs; muted */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + + { } +}; + +static struct hda_verb ad1988_spdif_init_verbs[] = { + /* SPDIF out sel */ + {0x02, AC_VERB_SET_CONNECT_SEL, 0x0}, /* PCM */ + {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0}, /* ADC1 */ + {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + /* SPDIF out pin */ + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE | 0x27}, /* 0dB */ + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) | 0x17}, /* 0dB */ + + { } +}; + +/* + * verbs for 3stack (+dig) + */ +static struct hda_verb ad1988_3stack_ch2_init[] = { + /* set port-C to line-in */ + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, + { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, + /* set port-E to mic-in */ + { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, + { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, + { } /* end */ +}; + +static struct hda_verb ad1988_3stack_ch6_init[] = { + /* set port-C to surround out */ + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, + { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + /* set port-E to CLFE out */ + { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, + { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { } /* end */ +}; + +static struct hda_channel_mode ad1988_3stack_modes[2] = { + { 2, ad1988_3stack_ch2_init }, + { 6, ad1988_3stack_ch6_init }, +}; + +static struct hda_verb ad1988_3stack_init_verbs[] = { + /* Front, Surround, CLFE, side DAC; mute as default */ + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + /* Port-A front headphon path */ + {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + /* Port-D line-out path */ + {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + /* Mono out path */ + {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ + {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ + /* Port-B front mic-in path */ + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + /* Port-C line-in/surround path */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, + /* Port-E mic-in/CLFE path */ + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, + /* mute analog mix */ + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, + /* select ADCs - front-mic */ + {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, + {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, + {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, + /* ADCs; muted */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + { } +}; + +/* + * verbs for laptop mode (+dig) + */ +static struct hda_verb ad1988_laptop_hp_on[] = { + /* unmute port-A and mute port-D */ + { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, + { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, + { } /* end */ +}; +static struct hda_verb ad1988_laptop_hp_off[] = { + /* mute port-A and unmute port-D */ + { 0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE }, + { 0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, + { } /* end */ +}; + +#define AD1988_HP_EVENT 0x01 + +static struct hda_verb ad1988_laptop_init_verbs[] = { + /* Front, Surround, CLFE, side DAC; mute as default */ + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + /* Port-A front headphon path */ + {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + /* unsolicited event for pin-sense */ + {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1988_HP_EVENT }, + /* Port-D line-out path + EAPD */ + {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x29, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x12, AC_VERB_SET_EAPD_BTLENABLE, 0x00}, /* EAPD-off */ + /* Mono out path */ + {0x36, AC_VERB_SET_CONNECT_SEL, 0x1}, /* DAC1:04h */ + {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb01f}, /* unmute, 0dB */ + /* Port-B mic-in path */ + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + /* Port-C docking station - try to output */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, + /* mute analog mix */ + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, + {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, + /* select ADCs - mic */ + {0x0c, AC_VERB_SET_CONNECT_SEL, 0x1}, + {0x0d, AC_VERB_SET_CONNECT_SEL, 0x1}, + {0x0e, AC_VERB_SET_CONNECT_SEL, 0x1}, + /* ADCs; muted */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + { } +}; + +static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) +{ + if ((res >> 26) != AD1988_HP_EVENT) + return; + if (snd_hda_codec_read(codec, 0x11, 0, AC_VERB_GET_PIN_SENSE, 0) & (1 << 31)) + snd_hda_sequence_write(codec, ad1988_laptop_hp_on); + else + snd_hda_sequence_write(codec, ad1988_laptop_hp_off); +} + + +/* + */ + +static struct hda_board_config ad1988_cfg_tbl[] = { + { .modelname = "6stack", .config = AD1988_6STACK }, + { .modelname = "6stack-dig", .config = AD1988_6STACK_DIG }, + { .modelname = "3stack", .config = AD1988_3STACK }, + { .modelname = "3stack-dig", .config = AD1988_3STACK_DIG }, + { .modelname = "laptop", .config = AD1988_LAPTOP }, + { .modelname = "laptop-dig", .config = AD1988_LAPTOP_DIG }, + {} +}; + +static int patch_ad1988(struct hda_codec *codec) +{ + struct ad198x_spec *spec; + int board_config; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + init_MUTEX(&spec->amp_mutex); + codec->spec = spec; + + board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl); + if (board_config < 0 || board_config >= AD1988_MODEL_LAST) { + printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n"); + board_config = AD1988_6STACK; + } + + switch (board_config) { + case AD1988_6STACK: + case AD1988_6STACK_DIG: + spec->multiout.max_channels = 8; + spec->multiout.num_dacs = 4; + spec->multiout.dac_nids = ad1988_dac_nids; + spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); + spec->adc_nids = ad1988_adc_nids; + spec->input_mux = &ad1988_6stack_capture_source; + spec->num_mixers = 1; + spec->mixers[0] = ad1988_6stack_mixers; + spec->num_init_verbs = 1; + spec->init_verbs[0] = ad1988_6stack_init_verbs; + if (board_config == AD1988_6STACK_DIG) { + spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; + spec->dig_in_nid = AD1988_SPDIF_IN; + } + break; + case AD1988_3STACK: + case AD1988_3STACK_DIG: + spec->multiout.max_channels = 6; + spec->multiout.num_dacs = 3; + spec->multiout.dac_nids = ad1988_dac_nids; + spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); + spec->adc_nids = ad1988_adc_nids; + spec->input_mux = &ad1988_6stack_capture_source; + spec->channel_mode = ad1988_3stack_modes; + spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); + spec->num_mixers = 1; + spec->mixers[0] = ad1988_3stack_mixers; + spec->num_init_verbs = 1; + spec->init_verbs[0] = ad1988_3stack_init_verbs; + if (board_config == AD1988_3STACK_DIG) + spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; + break; + case AD1988_LAPTOP: + case AD1988_LAPTOP_DIG: + spec->multiout.max_channels = 2; + spec->multiout.num_dacs = 1; + spec->multiout.dac_nids = ad1988_dac_nids; + spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); + spec->adc_nids = ad1988_adc_nids; + spec->input_mux = &ad1988_laptop_capture_source; + spec->num_mixers = 1; + spec->mixers[0] = ad1988_laptop_mixers; + spec->num_init_verbs = 1; + spec->init_verbs[0] = ad1988_laptop_init_verbs; + if (board_config == AD1988_LAPTOP_DIG) + spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; + break; + } + + spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; + spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; + if (spec->multiout.dig_out_nid) { + spec->mixers[spec->num_mixers++] = ad1988_spdif_out_mixers; + spec->init_verbs[spec->num_init_verbs++] = ad1988_spdif_init_verbs; + } + if (spec->dig_in_nid) + spec->mixers[spec->num_mixers++] = ad1988_spdif_in_mixers; + + codec->patch_ops = ad198x_patch_ops; + switch (board_config) { + case AD1988_LAPTOP: + case AD1988_LAPTOP_DIG: + codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; + break; + } + + return 0; +} + + +/* * patch entries */ struct hda_codec_preset snd_hda_preset_analog[] = { { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 }, { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 }, { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a }, + { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 }, {} /* terminator */ }; -- cgit v1.1 From a381a7a66486f11606eccb8866e29848f995278f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 15:55:49 +0100 Subject: [ALSA] Decentralize PM control Modules: ALSA Core,Control Midlevel,/oss/Makefile Remove the centralized PM control in the sound core. Each driver is responsible to get callbacks from bus/driver now. SND_GENERIC_DRIVER is removed together with this action. Signed-off-by: Takashi Iwai --- include/sound/core.h | 28 ------- sound/core/Kconfig | 4 - sound/core/control.c | 44 +---------- sound/core/init.c | 205 +-------------------------------------------------- sound/core/sound.c | 22 ------ 5 files changed, 3 insertions(+), 300 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index f867433..f00b9c9 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -134,14 +134,8 @@ struct snd_card { wait_queue_head_t shutdown_sleep; struct work_struct free_workq; /* for free in workqueue */ struct device *dev; -#ifdef CONFIG_SND_GENERIC_DRIVER - struct snd_generic_device *generic_dev; -#endif #ifdef CONFIG_PM - int (*pm_suspend)(struct snd_card *card, pm_message_t state); - int (*pm_resume)(struct snd_card *card); - void *pm_private_data; unsigned int power_state; /* power state */ struct semaphore power_lock; /* power lock */ wait_queue_head_t power_sleep; @@ -178,22 +172,6 @@ static inline void snd_power_change_state(struct snd_card *card, unsigned int st /* init.c */ int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file *file); -int snd_card_set_pm_callback(struct snd_card *card, - int (*suspend)(struct snd_card *, pm_message_t), - int (*resume)(struct snd_card *), - void *private_data); -int snd_card_set_generic_pm_callback(struct snd_card *card, - int (*suspend)(struct snd_card *, pm_message_t), - int (*resume)(struct snd_card *), - void *private_data); -#define snd_card_set_isa_pm_callback(card,suspend,resume,data) \ - snd_card_set_generic_pm_callback(card, suspend, resume, data) -struct pci_dev; -int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state); -int snd_card_pci_resume(struct pci_dev *dev); -#define SND_PCI_PM_CALLBACKS \ - .suspend = snd_card_pci_suspend, .resume = snd_card_pci_resume - #else /* ! CONFIG_PM */ #define snd_power_lock(card) do { (void)(card); } while (0) @@ -201,10 +179,6 @@ int snd_card_pci_resume(struct pci_dev *dev); static inline int snd_power_wait(struct snd_card *card, unsigned int state, struct file *file) { return 0; } #define snd_power_get_state(card) SNDRV_CTL_POWER_D0 #define snd_power_change_state(card, state) do { (void)(card); } while (0) -#define snd_card_set_pm_callback(card,suspend,resume,data) -#define snd_card_set_generic_pm_callback(card,suspend,resume,data) -#define snd_card_set_isa_pm_callback(card,suspend,resume,data) -#define SND_PCI_PM_CALLBACKS #endif /* CONFIG_PM */ @@ -280,8 +254,6 @@ int snd_card_file_remove(struct snd_card *card, struct file *file); #ifndef snd_card_set_dev #define snd_card_set_dev(card,devptr) ((card)->dev = (devptr)) #endif -/* register a generic device (for ISA, etc) */ -int snd_card_set_generic_dev(struct snd_card *card); /* device.c */ diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 8271883..b46efff 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -133,7 +133,3 @@ config SND_DEBUG_DETECT help Say Y here to enable extra-verbose log messages printed when detecting devices. - -config SND_GENERIC_DRIVER - bool - depends on SND diff --git a/sound/core/control.c b/sound/core/control.c index 1a14338..03ae9bb 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1023,36 +1023,6 @@ static int snd_ctl_subscribe_events(struct snd_ctl_file *file, int __user *ptr) return 0; } -#ifdef CONFIG_PM -/* - * change the power state - */ -static int snd_ctl_set_power_state(struct snd_card *card, unsigned int power_state) -{ - switch (power_state) { - case SNDRV_CTL_POWER_D0: - if (card->power_state != power_state) { - card->pm_resume(card); - snd_power_change_state(card, power_state); - } - break; - case SNDRV_CTL_POWER_D3hot: - if (card->power_state != power_state) { - card->pm_suspend(card, PMSG_SUSPEND); - snd_power_change_state(card, power_state); - } - break; - case SNDRV_CTL_POWER_D1: - case SNDRV_CTL_POWER_D2: - case SNDRV_CTL_POWER_D3cold: - /* not supported yet */ - default: - return -EINVAL; - } - return 0; -} -#endif - static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct snd_ctl_file *ctl; @@ -1092,19 +1062,7 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg case SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS: return snd_ctl_subscribe_events(ctl, ip); case SNDRV_CTL_IOCTL_POWER: - if (get_user(err, ip)) - return -EFAULT; - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; -#ifdef CONFIG_PM - if (card->pm_suspend && card->pm_resume) { - snd_power_lock(card); - err = snd_ctl_set_power_state(card, err); - snd_power_unlock(card); - } else -#endif - err = -ENOPROTOOPT; - return err; + return -ENOPROTOOPT; case SNDRV_CTL_IOCTL_POWER_STATE: #ifdef CONFIG_PM return put_user(card->power_state, ip) ? -EFAULT : 0; diff --git a/sound/core/init.c b/sound/core/init.c index dca64d1..728bb2c 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -229,12 +228,6 @@ int snd_card_disconnect(struct snd_card *card) return 0; } -#ifdef CONFIG_SND_GENERIC_DRIVER -static void snd_generic_device_unregister(struct snd_card *card); -#else -#define snd_generic_device_unregister(x) /*NOP*/ -#endif - /** * snd_card_free - frees given soundcard structure * @card: soundcard structure @@ -286,7 +279,6 @@ int snd_card_free(struct snd_card *card) snd_printk(KERN_WARNING "unable to free card info\n"); /* Not fatal error */ } - snd_generic_device_unregister(card); while (card->s_f_ops) { s_f_ops = card->s_f_ops; card->s_f_ops = s_f_ops->next; @@ -459,7 +451,8 @@ int snd_card_register(struct snd_card *card) static struct snd_info_entry *snd_card_info_entry = NULL; -static void snd_card_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) +static void snd_card_info_read(struct snd_info_entry *entry, + struct snd_info_buffer *buffer) { int idx, count; struct snd_card *card; @@ -666,97 +659,6 @@ int snd_card_file_remove(struct snd_card *card, struct file *file) return 0; } -#ifdef CONFIG_SND_GENERIC_DRIVER -/* - * generic device without a proper bus using platform_device - * (e.g. ISA) - */ -struct snd_generic_device { - struct platform_device pdev; - struct snd_card *card; -}; - -#define get_snd_generic_card(dev) container_of(dev, struct snd_generic_device, pdev)->card - -#define SND_GENERIC_NAME "snd_generic" - -#ifdef CONFIG_PM -static int snd_generic_suspend(struct platform_device *dev, pm_message_t state); -static int snd_generic_resume(struct platform_device *dev); -#endif - -/* initialized in sound.c */ -struct platform_driver snd_generic_driver = { -#ifdef CONFIG_PM - .suspend = snd_generic_suspend, - .resume = snd_generic_resume, -#endif - .driver = { - .name = SND_GENERIC_NAME, - }, -}; - -void snd_generic_device_release(struct device *dev) -{ -} - -static int snd_generic_device_register(struct snd_card *card) -{ - struct snd_generic_device *dev; - int err; - - if (card->generic_dev) - return 0; /* already registered */ - - dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (! dev) { - snd_printk(KERN_ERR "can't allocate generic_device\n"); - return -ENOMEM; - } - - dev->pdev.name = SND_GENERIC_NAME; - dev->pdev.id = card->number; - dev->pdev.dev.release = snd_generic_device_release; - dev->card = card; - if ((err = platform_device_register(&dev->pdev)) < 0) { - kfree(dev); - return err; - } - card->generic_dev = dev; - return 0; -} - -static void snd_generic_device_unregister(struct snd_card *card) -{ - struct snd_generic_device *dev = card->generic_dev; - if (dev) { - platform_device_unregister(&dev->pdev); - kfree(dev); - card->generic_dev = NULL; - } -} - -/** - * snd_card_set_generic_dev - assign the generic device to the card - * @card: soundcard structure - * - * Assigns a generic device to the card. This function is provided as the - * last resort, for devices without any proper bus. Thus this won't override - * the device already assigned to the card. - * - * Returns zero if successful, or a negative error code. - */ -int snd_card_set_generic_dev(struct snd_card *card) -{ - int err; - if ((err = snd_generic_device_register(card)) < 0) - return err; - if (! card->dev) - snd_card_set_dev(card, &card->generic_dev->pdev.dev); - return 0; -} -#endif /* CONFIG_SND_GENERIC_DRIVER */ - #ifdef CONFIG_PM /** * snd_power_wait - wait until the power-state is changed. @@ -800,107 +702,4 @@ int snd_power_wait(struct snd_card *card, unsigned int power_state, struct file return result; } -/** - * snd_card_set_pm_callback - set the PCI power-management callbacks - * @card: soundcard structure - * @suspend: suspend callback function - * @resume: resume callback function - * @private_data: private data to pass to the callback functions - * - * Sets the power-management callback functions of the card. - * These callbacks are called from ALSA's common PCI suspend/resume - * handler and from the control API. - */ -int snd_card_set_pm_callback(struct snd_card *card, - int (*suspend)(struct snd_card *, pm_message_t), - int (*resume)(struct snd_card *), - void *private_data) -{ - card->pm_suspend = suspend; - card->pm_resume = resume; - card->pm_private_data = private_data; - return 0; -} - -#ifdef CONFIG_SND_GENERIC_DRIVER -/* suspend/resume callbacks for snd_generic platform device */ -static int snd_generic_suspend(struct platform_device *dev, pm_message_t state) -{ - struct snd_card *card; - - card = get_snd_generic_card(dev); - if (card->power_state == SNDRV_CTL_POWER_D3hot) - return 0; - if (card->pm_suspend) - card->pm_suspend(card, PMSG_SUSPEND); - snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); - return 0; -} - -static int snd_generic_resume(struct platform_device *dev) -{ - struct snd_card *card; - - card = get_snd_generic_card(dev); - if (card->power_state == SNDRV_CTL_POWER_D0) - return 0; - if (card->pm_resume) - card->pm_resume(card); - snd_power_change_state(card, SNDRV_CTL_POWER_D0); - return 0; -} - -/** - * snd_card_set_generic_pm_callback - set the generic power-management callbacks - * @card: soundcard structure - * @suspend: suspend callback function - * @resume: resume callback function - * @private_data: private data to pass to the callback functions - * - * Registers the power-management and sets the lowlevel callbacks for - * the given card. These callbacks are called from the ALSA's common - * PM handler and from the control API. - */ -int snd_card_set_generic_pm_callback(struct snd_card *card, - int (*suspend)(struct snd_card *, pm_message_t), - int (*resume)(struct snd_card *), - void *private_data) -{ - int err; - if ((err = snd_generic_device_register(card)) < 0) - return err; - return snd_card_set_pm_callback(card, suspend, resume, private_data); -} -#endif /* CONFIG_SND_GENERIC_DRIVER */ - -#ifdef CONFIG_PCI -int snd_card_pci_suspend(struct pci_dev *dev, pm_message_t state) -{ - struct snd_card *card = pci_get_drvdata(dev); - int err; - if (! card || ! card->pm_suspend) - return 0; - if (card->power_state == SNDRV_CTL_POWER_D3hot) - return 0; - err = card->pm_suspend(card, PMSG_SUSPEND); - pci_save_state(dev); - snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); - return err; -} - -int snd_card_pci_resume(struct pci_dev *dev) -{ - struct snd_card *card = pci_get_drvdata(dev); - if (! card || ! card->pm_resume) - return 0; - if (card->power_state == SNDRV_CTL_POWER_D0) - return 0; - /* restore the PCI config space */ - pci_restore_state(dev); - card->pm_resume(card); - snd_power_change_state(card, SNDRV_CTL_POWER_D0); - return 0; -} -#endif - #endif /* CONFIG_PM */ diff --git a/sound/core/sound.c b/sound/core/sound.c index 04de008..fb236a6 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -32,7 +32,6 @@ #include #include #include -#include #define SNDRV_OS_MINORS 256 @@ -328,10 +327,6 @@ int __exit snd_minor_info_done(void) * INIT PART */ -#ifdef CONFIG_SND_GENERIC_DRIVER -extern struct platform_driver snd_generic_driver; -#endif - static int __init alsa_sound_init(void) { short controlnum; @@ -356,9 +351,6 @@ static int __init alsa_sound_init(void) return -ENOMEM; } snd_info_minor_register(); -#ifdef CONFIG_SND_GENERIC_DRIVER - platform_driver_register(&snd_generic_driver); -#endif for (controlnum = 0; controlnum < cards_limit; controlnum++) devfs_mk_cdev(MKDEV(major, controlnum<<5), S_IFCHR | device_mode, "snd/controlC%d", controlnum); #ifndef MODULE @@ -374,9 +366,6 @@ static void __exit alsa_sound_exit(void) for (controlnum = 0; controlnum < cards_limit; controlnum++) devfs_remove("snd/controlC%d", controlnum); -#ifdef CONFIG_SND_GENERIC_DRIVER - platform_driver_unregister(&snd_generic_driver); -#endif snd_info_minor_unregister(); snd_info_done(); if (unregister_chrdev(major, "alsa") != 0) @@ -415,19 +404,8 @@ EXPORT_SYMBOL(snd_card_register); EXPORT_SYMBOL(snd_component_add); EXPORT_SYMBOL(snd_card_file_add); EXPORT_SYMBOL(snd_card_file_remove); -#ifdef CONFIG_SND_GENERIC_DRIVER -EXPORT_SYMBOL(snd_card_set_generic_dev); -#endif #ifdef CONFIG_PM EXPORT_SYMBOL(snd_power_wait); -EXPORT_SYMBOL(snd_card_set_pm_callback); -#ifdef CONFIG_SND_GENERIC_DRIVER -EXPORT_SYMBOL(snd_card_set_generic_pm_callback); -#endif -#ifdef CONFIG_PCI -EXPORT_SYMBOL(snd_card_pci_suspend); -EXPORT_SYMBOL(snd_card_pci_resume); -#endif #endif /* device.c */ EXPORT_SYMBOL(snd_device_new); -- cgit v1.1 From 603bf524aa4cba95e4fcd64dbfffc41f804c65ab Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 15:59:14 +0100 Subject: [ALSA] pcm - NULL check in snd_pcm_suspend*() Modules: PCM Midlevel Add NULL check in snd_pcm_suspend*() so that the caller doesn't have to do it by itself. Signed-off-by: Takashi Iwai --- sound/core/pcm_native.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 263c01a..7bac1cb 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -1073,6 +1073,9 @@ int snd_pcm_suspend(struct snd_pcm_substream *substream) int err; unsigned long flags; + if (! substream) + return 0; + snd_pcm_stream_lock_irqsave(substream, flags); err = snd_pcm_action(&snd_pcm_action_suspend, substream, 0); snd_pcm_stream_unlock_irqrestore(substream, flags); @@ -1091,6 +1094,9 @@ int snd_pcm_suspend_all(struct snd_pcm *pcm) struct snd_pcm_substream *substream; int stream, err = 0; + if (! pcm) + return 0; + for (stream = 0; stream < 2; stream++) { for (substream = pcm->streams[stream].substream; substream; substream = substream->next) { -- cgit v1.1 From e26e7545e9542425f140cb4c605a7ab5a3b13e00 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:00:01 +0100 Subject: [ALSA] ac97 - NULL check in snd_ac97_suspend/resume Modules: AC97 Codec Add NULL check in snd_ac97_suspend() and snd_ac97_resume() so that the caller doesn't have to do it by itself. Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 9faeaef..abc83fa 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -2186,6 +2186,8 @@ static void snd_ac97_powerdown(struct snd_ac97 *ac97) */ void snd_ac97_suspend(struct snd_ac97 *ac97) { + if (! ac97) + return; if (ac97->build_ops->suspend) ac97->build_ops->suspend(ac97); snd_ac97_powerdown(ac97); @@ -2242,6 +2244,9 @@ void snd_ac97_resume(struct snd_ac97 *ac97) { unsigned long end_time; + if (! ac97) + return; + if (ac97->bus->ops->reset) { ac97->bus->ops->reset(ac97); goto __reset_ready; -- cgit v1.1 From 6e65c1cc4458b2784224759b6137a50d4f65e610 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:01:56 +0100 Subject: [ALSA] dummy - Use platform_device Modules: Generic drivers Rewrite the probe/remove code using platform_device. Added the suspend/resume support, too. Signed-off-by: Takashi Iwai --- sound/drivers/dummy.c | 106 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 9c827b1..a276f7c 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -20,6 +20,8 @@ #include #include +#include +#include #include #include #include @@ -151,6 +153,7 @@ MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver."); struct snd_dummy { struct snd_card *card; + struct snd_pcm *pcm; spinlock_t mixer_lock; int mixer_volume[MIXER_ADDR_LAST+1][2]; int capture_source[MIXER_ADDR_LAST+1][2]; @@ -169,8 +172,6 @@ struct snd_dummy_pcm { struct snd_pcm_substream *substream; }; -static struct snd_card *snd_dummy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - static inline void snd_card_dummy_pcm_timer_start(struct snd_dummy_pcm *dpcm) { @@ -190,15 +191,21 @@ static int snd_card_dummy_pcm_trigger(struct snd_pcm_substream *substream, int c int err = 0; spin_lock(&dpcm->lock); - if (cmd == SNDRV_PCM_TRIGGER_START) { + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: snd_card_dummy_pcm_timer_start(dpcm); - } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: snd_card_dummy_pcm_timer_stop(dpcm); - } else { + break; + default: err = -EINVAL; + break; } spin_unlock(&dpcm->lock); - return err; + return 0; } static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream) @@ -251,7 +258,7 @@ static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *su static struct snd_pcm_hardware snd_card_dummy_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = USE_FORMATS, .rates = USE_RATE, .rate_min = USE_RATE_MIN, @@ -269,7 +276,7 @@ static struct snd_pcm_hardware snd_card_dummy_playback = static struct snd_pcm_hardware snd_card_dummy_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = USE_FORMATS, .rates = USE_RATE, .rate_min = USE_RATE_MIN, @@ -405,6 +412,7 @@ static int __init snd_card_dummy_pcm(struct snd_dummy *dummy, int device, int su if ((err = snd_pcm_new(dummy->card, "Dummy PCM", device, substreams, substreams, &pcm)) < 0) return err; + dummy->pcm = pcm; snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops); snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_dummy_capture_ops); pcm->private_data = dummy; @@ -547,14 +555,13 @@ static int __init snd_card_dummy_new_mixer(struct snd_dummy *dummy) return 0; } -static int __init snd_card_dummy_probe(int dev) +static int __init snd_dummy_probe(struct platform_device *devptr) { struct snd_card *card; struct snd_dummy *dummy; int idx, err; + int dev = devptr->id; - if (!enable[dev]) - return -ENODEV; card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_dummy)); if (card == NULL) @@ -575,11 +582,10 @@ static int __init snd_card_dummy_probe(int dev) strcpy(card->shortname, "Dummy"); sprintf(card->longname, "Dummy %i", dev + 1); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto __nodev; + snd_card_set_dev(card, &devptr->dev); if ((err = snd_card_register(card)) == 0) { - snd_dummy_cards[dev] = card; + platform_set_drvdata(devptr, card); return 0; } __nodev: @@ -587,16 +593,62 @@ static int __init snd_card_dummy_probe(int dev) return err; } -static int __init alsa_card_dummy_init(void) +static int snd_dummy_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_dummy_suspend(struct platform_device *pdev, pm_message_t state) { - int dev, cards; + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_dummy *dummy = card->private_data; - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (snd_card_dummy_probe(dev) < 0) { -#ifdef MODULE - printk(KERN_ERR "Dummy soundcard #%i not found or device busy\n", dev + 1); + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(dummy->pcm); + return 0; +} + +static int snd_dummy_resume(struct platform_device *pdev) +{ + struct snd_card *card = platform_get_drvdata(pdev); + + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + +#define SND_DUMMY_DRIVER "snd_dummy" + +static struct platform_driver snd_dummy_driver = { + .probe = snd_dummy_probe, + .remove = snd_dummy_remove, +#ifdef CONFIG_PM + .suspend = snd_dummy_suspend, + .resume = snd_dummy_resume, #endif - break; + .driver = { + .name = SND_DUMMY_DRIVER + }, +}; + +static int __init alsa_card_dummy_init(void) +{ + int i, cards, err; + + if ((err = platform_driver_register(&snd_dummy_driver)) < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_DUMMY_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; } cards++; } @@ -604,17 +656,19 @@ static int __init alsa_card_dummy_init(void) #ifdef MODULE printk(KERN_ERR "Dummy soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_dummy_driver); + return err; } static void __exit alsa_card_dummy_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_dummy_cards[idx]); + platform_driver_unregister(&snd_dummy_driver); } module_init(alsa_card_dummy_init) -- cgit v1.1 From 077d0ac5b63185abb848ae81e2949a1e9aedc1bb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:02:15 +0100 Subject: [ALSA] mtpav - Use platform_device Modules: Generic drivers Rewrite the probe/remove code using platform_device. Signed-off-by: Takashi Iwai --- sound/drivers/mtpav.c | 268 ++++++++++++++++++++++++-------------------------- 1 file changed, 129 insertions(+), 139 deletions(-) diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index d32d5f6..d9c4e22 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -53,6 +53,8 @@ #include #include #include +#include +#include #include #include #include @@ -125,16 +127,16 @@ MODULE_PARM_DESC(hwports, "Hardware ports # for MotuMTPAV MIDI."); /* */ -typedef struct mtpav_port { +struct mtpav_port { u8 number; u8 hwport; u8 mode; u8 running_status; struct snd_rawmidi_substream *input; struct snd_rawmidi_substream *output; -} mtpav_port_t; +}; -typedef struct mtpav { +struct mtpav { struct snd_card *card; unsigned long port; struct resource *res_port; @@ -145,22 +147,16 @@ typedef struct mtpav { struct timer_list timer; /* timer interrupts for outputs */ struct snd_rawmidi *rmidi; int num_ports; /* number of hw ports (1-8) */ - mtpav_port_t ports[NUMPORTS]; /* all ports including computer, adat and bc */ + struct mtpav_port ports[NUMPORTS]; /* all ports including computer, adat and bc */ u32 inmidiport; /* selected input midi port */ u32 inmidistate; /* during midi command 0xf5 */ u32 outmidihwport; /* selected output midi hw port */ -} mtpav_t; +}; /* - * global instance - * hey, we handle at most only one card.. - */ -static mtpav_t *mtp_card; - -/* * possible hardware ports (selected by 0xf5 port message) * 0x00 all ports * 0x01 .. 0x08 this MTP's ports 1..8 @@ -183,7 +179,7 @@ static mtpav_t *mtp_card; #define MTPAV_PIDX_BROADCAST 2 -static int translate_subdevice_to_hwport(mtpav_t *chip, int subdev) +static int translate_subdevice_to_hwport(struct mtpav *chip, int subdev) { if (subdev < 0) return 0x01; /* invalid - use port 0 as default */ @@ -198,7 +194,7 @@ static int translate_subdevice_to_hwport(mtpav_t *chip, int subdev) return 0; /* all ports */ } -static int translate_hwport_to_subdevice(mtpav_t *chip, int hwport) +static int translate_hwport_to_subdevice(struct mtpav *chip, int hwport) { int p; if (hwport <= 0x00) /* all ports */ @@ -223,7 +219,7 @@ static int translate_hwport_to_subdevice(mtpav_t *chip, int hwport) /* */ -static u8 snd_mtpav_getreg(mtpav_t *chip, u16 reg) +static u8 snd_mtpav_getreg(struct mtpav *chip, u16 reg) { u8 rval = 0; @@ -241,19 +237,16 @@ static u8 snd_mtpav_getreg(mtpav_t *chip, u16 reg) /* */ -static void snd_mtpav_mputreg(mtpav_t *chip, u16 reg, u8 val) +static inline void snd_mtpav_mputreg(struct mtpav *chip, u16 reg, u8 val) { - if (reg == DREG) { - outb(val, chip->port + DREG); - } else if (reg == CREG) { - outb(val, chip->port + CREG); - } + if (reg == DREG || reg == CREG) + outb(val, chip->port + reg); } /* */ -static void snd_mtpav_wait_rfdhi(mtpav_t *chip) +static void snd_mtpav_wait_rfdhi(struct mtpav *chip) { int counts = 10000; u8 sbyte; @@ -265,7 +258,7 @@ static void snd_mtpav_wait_rfdhi(mtpav_t *chip) } } -static void snd_mtpav_send_byte(mtpav_t *chip, u8 byte) +static void snd_mtpav_send_byte(struct mtpav *chip, u8 byte) { u8 tcbyt; u8 clrwrite; @@ -291,7 +284,8 @@ static void snd_mtpav_send_byte(mtpav_t *chip, u8 byte) */ /* call this with spin lock held */ -static void snd_mtpav_output_port_write(mtpav_port_t *port, +static void snd_mtpav_output_port_write(struct mtpav *mtp_card, + struct mtpav_port *portp, struct snd_rawmidi_substream *substream) { u8 outbyte; @@ -303,22 +297,22 @@ static void snd_mtpav_output_port_write(mtpav_port_t *port, // send port change command if necessary - if (port->hwport != mtp_card->outmidihwport) { - mtp_card->outmidihwport = port->hwport; + if (portp->hwport != mtp_card->outmidihwport) { + mtp_card->outmidihwport = portp->hwport; snd_mtpav_send_byte(mtp_card, 0xf5); - snd_mtpav_send_byte(mtp_card, port->hwport); - //snd_printk("new outport: 0x%x\n", (unsigned int) port->hwport); + snd_mtpav_send_byte(mtp_card, portp->hwport); + //snd_printk("new outport: 0x%x\n", (unsigned int) portp->hwport); - if (!(outbyte & 0x80) && port->running_status) - snd_mtpav_send_byte(mtp_card, port->running_status); + if (!(outbyte & 0x80) && portp->running_status) + snd_mtpav_send_byte(mtp_card, portp->running_status); } // send data do { if (outbyte & 0x80) - port->running_status = outbyte; + portp->running_status = outbyte; snd_mtpav_send_byte(mtp_card, outbyte); } while (snd_rawmidi_transmit(substream, &outbyte, 1) == 1); @@ -326,11 +320,12 @@ static void snd_mtpav_output_port_write(mtpav_port_t *port, static void snd_mtpav_output_write(struct snd_rawmidi_substream *substream) { - mtpav_port_t *port = &mtp_card->ports[substream->number]; + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; spin_lock_irqsave(&mtp_card->spinlock, flags); - snd_mtpav_output_port_write(port, substream); + snd_mtpav_output_port_write(mtp_card, portp, substream); spin_unlock_irqrestore(&mtp_card->spinlock, flags); } @@ -339,7 +334,7 @@ static void snd_mtpav_output_write(struct snd_rawmidi_substream *substream) * mtpav control */ -static void snd_mtpav_portscan(mtpav_t *chip) // put mtp into smart routing mode +static void snd_mtpav_portscan(struct mtpav *chip) // put mtp into smart routing mode { u8 p; @@ -355,10 +350,10 @@ static void snd_mtpav_portscan(mtpav_t *chip) // put mtp into smart routing mode static int snd_mtpav_input_open(struct snd_rawmidi_substream *substream) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; - //printk("mtpav port: %d opened\n", (int) substream->number); spin_lock_irqsave(&mtp_card->spinlock, flags); portp->mode |= MTPAV_MODE_INPUT_OPENED; portp->input = substream; @@ -373,18 +368,15 @@ static int snd_mtpav_input_open(struct snd_rawmidi_substream *substream) static int snd_mtpav_input_close(struct snd_rawmidi_substream *substream) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; - - //printk("mtpav port: %d closed\n", (int) portp); spin_lock_irqsave(&mtp_card->spinlock, flags); - - portp->mode &= (~MTPAV_MODE_INPUT_OPENED); + portp->mode &= ~MTPAV_MODE_INPUT_OPENED; portp->input = NULL; if (--mtp_card->share_irq == 0) snd_mtpav_mputreg(mtp_card, CREG, 0); // disable pport interrupts - spin_unlock_irqrestore(&mtp_card->spinlock, flags); return 0; } @@ -394,8 +386,9 @@ static int snd_mtpav_input_close(struct snd_rawmidi_substream *substream) static void snd_mtpav_input_trigger(struct snd_rawmidi_substream *substream, int up) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; spin_lock_irqsave(&mtp_card->spinlock, flags); if (up) @@ -414,7 +407,7 @@ static void snd_mtpav_input_trigger(struct snd_rawmidi_substream *substream, int static void snd_mtpav_output_timer(unsigned long data) { unsigned long flags; - mtpav_t *chip = (mtpav_t *)data; + struct mtpav *chip = (struct mtpav *)data; int p; spin_lock_irqsave(&chip->spinlock, flags); @@ -423,25 +416,22 @@ static void snd_mtpav_output_timer(unsigned long data) add_timer(&chip->timer); /* process each port */ for (p = 0; p <= chip->num_ports * 2 + MTPAV_PIDX_BROADCAST; p++) { - mtpav_port_t *portp = &mtp_card->ports[p]; + struct mtpav_port *portp = &chip->ports[p]; if ((portp->mode & MTPAV_MODE_OUTPUT_TRIGGERED) && portp->output) - snd_mtpav_output_port_write(portp, portp->output); + snd_mtpav_output_port_write(chip, portp, portp->output); } spin_unlock_irqrestore(&chip->spinlock, flags); } /* spinlock held! */ -static void snd_mtpav_add_output_timer(mtpav_t *chip) +static void snd_mtpav_add_output_timer(struct mtpav *chip) { - init_timer(&chip->timer); - chip->timer.function = snd_mtpav_output_timer; - chip->timer.data = (unsigned long) mtp_card; chip->timer.expires = 1 + jiffies; add_timer(&chip->timer); } /* spinlock held! */ -static void snd_mtpav_remove_output_timer(mtpav_t *chip) +static void snd_mtpav_remove_output_timer(struct mtpav *chip) { del_timer(&chip->timer); } @@ -451,8 +441,9 @@ static void snd_mtpav_remove_output_timer(mtpav_t *chip) static int snd_mtpav_output_open(struct snd_rawmidi_substream *substream) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; spin_lock_irqsave(&mtp_card->spinlock, flags); portp->mode |= MTPAV_MODE_OUTPUT_OPENED; @@ -466,11 +457,12 @@ static int snd_mtpav_output_open(struct snd_rawmidi_substream *substream) static int snd_mtpav_output_close(struct snd_rawmidi_substream *substream) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; spin_lock_irqsave(&mtp_card->spinlock, flags); - portp->mode &= (~MTPAV_MODE_OUTPUT_OPENED); + portp->mode &= ~MTPAV_MODE_OUTPUT_OPENED; portp->output = NULL; spin_unlock_irqrestore(&mtp_card->spinlock, flags); return 0; @@ -481,12 +473,13 @@ static int snd_mtpav_output_close(struct snd_rawmidi_substream *substream) static void snd_mtpav_output_trigger(struct snd_rawmidi_substream *substream, int up) { + struct mtpav *mtp_card = substream->rmidi->private_data; + struct mtpav_port *portp = &mtp_card->ports[substream->number]; unsigned long flags; - mtpav_port_t *portp = &mtp_card->ports[substream->number]; spin_lock_irqsave(&mtp_card->spinlock, flags); if (up) { - if (! (portp->mode & MTPAV_MODE_OUTPUT_TRIGGERED)) { + if (! (portp->mode & MTPAV_MODE_OUTPUT_TRIGGERED)) { if (mtp_card->istimer++ == 0) snd_mtpav_add_output_timer(mtp_card); portp->mode |= MTPAV_MODE_OUTPUT_TRIGGERED; @@ -506,23 +499,20 @@ static void snd_mtpav_output_trigger(struct snd_rawmidi_substream *substream, in * midi interrupt for inputs */ -static void snd_mtpav_inmidi_process(mtpav_t *mcrd, u8 inbyte) +static void snd_mtpav_inmidi_process(struct mtpav *mcrd, u8 inbyte) { - mtpav_port_t *portp; + struct mtpav_port *portp; if ((int)mcrd->inmidiport > mcrd->num_ports * 2 + MTPAV_PIDX_BROADCAST) return; portp = &mcrd->ports[mcrd->inmidiport]; - if (portp->mode & MTPAV_MODE_INPUT_TRIGGERED) { + if (portp->mode & MTPAV_MODE_INPUT_TRIGGERED) snd_rawmidi_receive(portp->input, &inbyte, 1); - } } -static void snd_mtpav_inmidi_h(mtpav_t * mcrd, u8 inbyte) +static void snd_mtpav_inmidi_h(struct mtpav *mcrd, u8 inbyte) { - snd_assert(mcrd, return); - if (inbyte >= 0xf8) { /* real-time midi code */ snd_mtpav_inmidi_process(mcrd, inbyte); @@ -540,7 +530,7 @@ static void snd_mtpav_inmidi_h(mtpav_t * mcrd, u8 inbyte) } } -static void snd_mtpav_read_bytes(mtpav_t * mcrd) +static void snd_mtpav_read_bytes(struct mtpav *mcrd) { u8 clrread, setread; u8 mtp_read_byte; @@ -580,9 +570,8 @@ static void snd_mtpav_read_bytes(mtpav_t * mcrd) static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id, struct pt_regs *regs) { - mtpav_t *mcard = dev_id; + struct mtpav *mcard = dev_id; - //printk("irqh()\n"); spin_lock(&mcard->spinlock); snd_mtpav_read_bytes(mcard); spin_unlock(&mcard->spinlock); @@ -592,14 +581,14 @@ static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id, struct pt_regs *regs) /* * get ISA resources */ -static int snd_mtpav_get_ISA(mtpav_t * mcard) +static int __init snd_mtpav_get_ISA(struct mtpav * mcard) { if ((mcard->res_port = request_region(port, 3, "MotuMTPAV MIDI")) == NULL) { snd_printk("MTVAP port 0x%lx is busy\n", port); return -EBUSY; } mcard->port = port; - if (request_irq(irq, snd_mtpav_irqh, SA_INTERRUPT, "MOTU MTPAV", (void *)mcard)) { + if (request_irq(irq, snd_mtpav_irqh, SA_INTERRUPT, "MOTU MTPAV", mcard)) { snd_printk("MTVAP IRQ %d busy\n", irq); return -EBUSY; } @@ -628,7 +617,8 @@ static struct snd_rawmidi_ops snd_mtpav_input = { * get RAWMIDI resources */ -static void snd_mtpav_set_name(mtpav_t *chip, struct snd_rawmidi_substream *substream) +static void __init snd_mtpav_set_name(struct mtpav *chip, + struct snd_rawmidi_substream *substream) { if (substream->number >= 0 && substream->number < chip->num_ports) sprintf(substream->name, "MTP direct %d", (substream->number % chip->num_ports) + 1); @@ -642,21 +632,18 @@ static void snd_mtpav_set_name(mtpav_t *chip, struct snd_rawmidi_substream *subs strcpy(substream->name, "MTP broadcast"); } -static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) +static int __init snd_mtpav_get_RAWMIDI(struct mtpav *mcard) { - int rval = 0; + int rval; struct snd_rawmidi *rawmidi; struct snd_rawmidi_substream *substream; struct list_head *list; - //printk("entering snd_mtpav_get_RAWMIDI\n"); - if (hwports < 1) - mcard->num_ports = 1; + hwports = 1; else if (hwports > 8) - mcard->num_ports = 8; - else - mcard->num_ports = hwports; + hwports = 8; + mcard->num_ports = hwports; if ((rval = snd_rawmidi_new(mcard->card, "MotuMIDI", 0, mcard->num_ports * 2 + MTPAV_PIDX_BROADCAST + 1, @@ -664,6 +651,7 @@ static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) &mcard->rmidi)) < 0) return rval; rawmidi = mcard->rmidi; + rawmidi->private_data = mcard; list_for_each(list, &rawmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT].substreams) { substream = list_entry(list, struct snd_rawmidi_substream, list); @@ -679,36 +667,15 @@ static int snd_mtpav_get_RAWMIDI(mtpav_t * mcard) rawmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | SNDRV_RAWMIDI_INFO_INPUT | SNDRV_RAWMIDI_INFO_DUPLEX; sprintf(rawmidi->name, "MTP AV MIDI"); - //printk("exiting snd_mtpav_get_RAWMIDI() \n"); return 0; } /* */ -static mtpav_t *new_mtpav(void) -{ - mtpav_t *ncrd = kzalloc(sizeof(*ncrd), GFP_KERNEL); - if (ncrd != NULL) { - spin_lock_init(&ncrd->spinlock); - - init_timer(&ncrd->timer); - ncrd->card = NULL; - ncrd->irq = -1; - ncrd->share_irq = 0; - - ncrd->inmidiport = 0xffffffff; - ncrd->inmidistate = 0; - ncrd->outmidihwport = 0xffffffff; - } - return ncrd; -} - -/* - */ - -static void free_mtpav(mtpav_t * crd) +static void snd_mtpav_free(struct snd_card *card) { + struct mtpav *crd = card->private_data; unsigned long flags; spin_lock_irqsave(&crd->spinlock, flags); @@ -718,78 +685,101 @@ static void free_mtpav(mtpav_t * crd) if (crd->irq >= 0) free_irq(crd->irq, (void *)crd); release_and_free_resource(crd->res_port); - kfree(crd); } /* */ - -static int __init alsa_card_mtpav_init(void) +static int __init snd_mtpav_probe(struct platform_device *dev) { - int err = 0; - char longname_buffer[80]; + struct snd_card *card; + int err; + struct mtpav *mtp_card; - mtp_card = new_mtpav(); - if (mtp_card == NULL) + card = snd_card_new(index, id, THIS_MODULE, sizeof(*mtp_card)); + if (! card) return -ENOMEM; - mtp_card->card = snd_card_new(index, id, THIS_MODULE, 0); - if (mtp_card->card == NULL) { - free_mtpav(mtp_card); - return -ENOMEM; - } + mtp_card = card->private_data; + spin_lock_init(&mtp_card->spinlock); + init_timer(&mtp_card->timer); + mtp_card->card = card; + mtp_card->irq = -1; + mtp_card->share_irq = 0; + mtp_card->inmidiport = 0xffffffff; + mtp_card->inmidistate = 0; + mtp_card->outmidihwport = 0xffffffff; + init_timer(&mtp_card->timer); + mtp_card->timer.function = snd_mtpav_output_timer; + mtp_card->timer.data = (unsigned long) mtp_card; + + card->private_free = snd_mtpav_free; err = snd_mtpav_get_ISA(mtp_card); - //printk("snd_mtpav_get_ISA returned: %d\n", err); if (err < 0) goto __error; - strcpy(mtp_card->card->driver, "MTPAV"); - strcpy(mtp_card->card->shortname, "MTPAV on parallel port"); - memset(longname_buffer, 0, sizeof(longname_buffer)); - sprintf(longname_buffer, "MTPAV on parallel port at"); + strcpy(card->driver, "MTPAV"); + strcpy(card->shortname, "MTPAV on parallel port"); + snprintf(card->longname, sizeof(card->longname), + "MTPAV on parallel port at 0x%lx", port); err = snd_mtpav_get_RAWMIDI(mtp_card); - //snd_printk("snd_mtapv_get_RAWMIDI returned: %d\n", err); if (err < 0) goto __error; - if ((err = snd_card_set_generic_dev(mtp_card->card)) < 0) - goto __error; - - err = snd_card_register(mtp_card->card); // don't snd_card_register until AFTER all cards reources done! + snd_mtpav_portscan(mtp_card); - //printk("snd_card_register returned %d\n", err); + snd_card_set_dev(card, &dev->dev); + err = snd_card_register(mtp_card->card); if (err < 0) goto __error; - - snd_mtpav_portscan(mtp_card); - + platform_set_drvdata(dev, card); printk(KERN_INFO "Motu MidiTimePiece on parallel port irq: %d ioport: 0x%lx\n", irq, port); - return 0; - __error: - snd_card_free(mtp_card->card); - free_mtpav(mtp_card); + __error: + snd_card_free(card); return err; } -/* - */ +static int snd_mtpav_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} -static void __exit alsa_card_mtpav_exit(void) +#define SND_MTPAV_DRIVER "snd_mtpav" + +static struct platform_driver snd_mtpav_driver = { + .probe = snd_mtpav_probe, + .remove = snd_mtpav_remove, + .driver = { + .name = SND_MTPAV_DRIVER + }, +}; + +static int __init alsa_card_mtpav_init(void) { - if (mtp_card == NULL) - return; - if (mtp_card->card) - snd_card_free(mtp_card->card); - free_mtpav(mtp_card); + int err; + struct platform_device *device; + + if ((err = platform_driver_register(&snd_mtpav_driver)) < 0) + return err; + + device = platform_device_register_simple(SND_MTPAV_DRIVER, -1, NULL, 0); + if (IS_ERR(device)) { + platform_driver_unregister(&snd_mtpav_driver); + return PTR_ERR(device); + } + return 0; } -/* - */ +static void __exit alsa_card_mtpav_exit(void) +{ + platform_driver_unregister(&snd_mtpav_driver); +} module_init(alsa_card_mtpav_init) module_exit(alsa_card_mtpav_exit) -- cgit v1.1 From 9caf6b5908e1e3b10478e9201ca1be809145253f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:02:30 +0100 Subject: [ALSA] serial-u16550 - Use platform_device Modules: Generic drivers Rewrite the probe/remove code using platform_device. Signed-off-by: Takashi Iwai --- sound/drivers/serial-u16550.c | 68 ++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index ec285872..3381a43 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include #include @@ -166,8 +168,6 @@ typedef struct _snd_uart16550 { } snd_uart16550_t; -static struct snd_card *snd_serial_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - static inline void snd_uart16550_add_timer(snd_uart16550_t *uart) { if (! uart->timer_running) { @@ -869,14 +869,12 @@ static int __init snd_uart16550_rmidi(snd_uart16550_t *uart, int device, int out return 0; } -static int __init snd_serial_probe(int dev) +static int __init snd_serial_probe(struct platform_device *devptr) { struct snd_card *card; snd_uart16550_t *uart; int err; - - if (!enable[dev]) - return -ENOENT; + int dev = devptr->id; switch (adaptor[dev]) { case SNDRV_SERIAL_SOUNDCANVAS: @@ -942,13 +940,12 @@ static int __init snd_serial_probe(int dev) adaptor_names[uart->adaptor], uart->drop_on_full); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &devptr->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_serial_cards[dev] = card; + platform_set_drvdata(devptr, card); return 0; _err: @@ -956,33 +953,58 @@ static int __init snd_serial_probe(int dev) return err; } +static int snd_serial_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define SND_SERIAL_DRIVER "snd_serial_u16550" + +static struct platform_driver snd_serial_driver = { + .probe = snd_serial_probe, + .remove = snd_serial_remove, + .driver = { + .name = SND_SERIAL_DRIVER + }, +}; + static int __init alsa_card_serial_init(void) { - int dev = 0; - int cards = 0; + int i, cards, err; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (snd_serial_probe(dev) == 0) - cards++; - } + if ((err = platform_driver_register(&snd_serial_driver)) < 0) + return err; - if (cards == 0) { + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_SERIAL_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; + } + if (! cards) { #ifdef MODULE printk(KERN_ERR "serial midi soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_serial_driver); + return err; } static void __exit alsa_card_serial_exit(void) { - int dev; - - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (snd_serial_cards[dev] != NULL) - snd_card_free(snd_serial_cards[dev]); - } + platform_driver_unregister(&snd_serial_driver); } module_init(alsa_card_serial_init) -- cgit v1.1 From 3564fbb880f9a62ddbb81b7440c32e0e6619c52d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:03:26 +0100 Subject: [ALSA] virmidi - Use platform_device Modules: Generic drivers Rewrite the probe/remove code using platform_device. Signed-off-by: Takashi Iwai --- sound/drivers/virmidi.c | 64 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index 0d2cc6e..a7b9241 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -45,6 +45,8 @@ #include #include #include +#include +#include #include #include #include @@ -80,17 +82,14 @@ struct snd_card_virmidi { struct snd_rawmidi *midi[MAX_MIDI_DEVICES]; }; -static struct snd_card *snd_virmidi_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - -static int __init snd_card_virmidi_probe(int dev) +static int __init snd_virmidi_probe(struct platform_device *devptr) { struct snd_card *card; struct snd_card_virmidi *vmidi; int idx, err; + int dev = devptr->id; - if (!enable[dev]) - return -ENODEV; card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_virmidi)); if (card == NULL) @@ -117,11 +116,10 @@ static int __init snd_card_virmidi_probe(int dev) strcpy(card->shortname, "VirMIDI"); sprintf(card->longname, "Virtual MIDI Card %i", dev + 1); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto __nodev; + snd_card_set_dev(card, &devptr->dev); if ((err = snd_card_register(card)) == 0) { - snd_virmidi_cards[dev] = card; + platform_set_drvdata(devptr, card); return 0; } __nodev: @@ -129,16 +127,38 @@ static int __init snd_card_virmidi_probe(int dev) return err; } -static int __init alsa_card_virmidi_init(void) +static int snd_virmidi_remove(struct platform_device *devptr) { - int dev, cards; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (snd_card_virmidi_probe(dev) < 0) { -#ifdef MODULE - printk(KERN_ERR "Card-VirMIDI #%i not found or device busy\n", dev + 1); -#endif - break; +#define SND_VIRMIDI_DRIVER "snd_virmidi" + +static struct platform_driver snd_virmidi_driver = { + .probe = snd_virmidi_probe, + .remove = snd_virmidi_remove, + .driver = { + .name = SND_VIRMIDI_DRIVER + }, +}; + +static int __init alsa_card_virmidi_init(void) +{ + int i, cards, err; + + if ((err = platform_driver_register(&snd_virmidi_driver)) < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_VIRMIDI_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; } cards++; } @@ -146,17 +166,19 @@ static int __init alsa_card_virmidi_init(void) #ifdef MODULE printk(KERN_ERR "Card-VirMIDI soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_virmidi_driver); + return err; } static void __exit alsa_card_virmidi_exit(void) { - int dev; - - for (dev = 0; dev < SNDRV_CARDS; dev++) - snd_card_free(snd_virmidi_cards[dev]); + platform_driver_unregister(&snd_virmidi_driver); } module_init(alsa_card_virmidi_init) -- cgit v1.1 From b3fe95123f0db79dd0345d249c312823178c11f5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:03:39 +0100 Subject: [ALSA] mpu401 - Use platform_device Modules: MPU401 UART Rewrite the probe/remove code using platform_device. Signed-off-by: Takashi Iwai --- sound/drivers/mpu401/mpu401.c | 87 +++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index b1242ee..ec817a8 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -56,7 +58,6 @@ MODULE_PARM_DESC(port, "Port # for MPU-401 device."); module_param_array(irq, int, NULL, 0444); MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); -static struct snd_card *snd_mpu401_legacy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; static int pnp_registered = 0; static int snd_mpu401_create(int dev, struct snd_card **rcard) @@ -85,12 +86,6 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard) goto _err; } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - - if ((err = snd_card_register(card)) < 0) - goto _err; - *rcard = card; return 0; @@ -99,8 +94,12 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard) return err; } -static int __devinit snd_mpu401_probe(int dev) +static int __devinit snd_mpu401_probe(struct platform_device *devptr) { + int dev = devptr->id; + int err; + struct snd_card *card; + if (port[dev] == SNDRV_AUTO_PORT) { snd_printk(KERN_ERR "specify port\n"); return -EINVAL; @@ -109,9 +108,36 @@ static int __devinit snd_mpu401_probe(int dev) snd_printk(KERN_ERR "specify or disable IRQ\n"); return -EINVAL; } - return snd_mpu401_create(dev, &snd_mpu401_legacy_cards[dev]); + err = snd_mpu401_create(dev, &card); + if (err < 0) + return err; + snd_card_set_dev(card, &devptr->dev); + if ((err = snd_card_register(card)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(devptr, card); + return 0; } +static int __devexit snd_mpu401_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define SND_MPU401_DRIVER "snd_mpu401" + +static struct platform_driver snd_mpu401_driver = { + .probe = snd_mpu401_probe, + .remove = __devexit_p(snd_mpu401_remove), + .driver = { + .name = SND_MPU401_DRIVER + }, +}; + + #ifdef CONFIG_PNP #define IO_EXTENT 2 @@ -164,6 +190,10 @@ static int __devinit snd_mpu401_pnp_probe(struct pnp_dev *pnp_dev, err = snd_mpu401_create(dev, &card); if (err < 0) return err; + if ((err = snd_card_register(card)) < 0) { + snd_card_free(card); + return err; + } snd_card_set_dev(card, &pnp_dev->dev); pnp_set_drvdata(pnp_dev, card); ++dev; @@ -192,18 +222,25 @@ static struct pnp_driver snd_mpu401_pnp_driver; static int __init alsa_card_mpu401_init(void) { - int dev, devices = 0; - int err; + int i, err, devices; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; + if ((err = platform_driver_register(&snd_mpu401_driver)) < 0) + return err; + + devices = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; #ifdef CONFIG_PNP - if (pnp[dev]) + if (pnp[i]) continue; #endif - if (snd_mpu401_probe(dev) >= 0) - devices++; + device = platform_device_register_simple(SND_MPU401_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + devices++; } if ((err = pnp_register_driver(&snd_mpu401_pnp_driver)) >= 0) { pnp_registered = 1; @@ -214,21 +251,23 @@ static int __init alsa_card_mpu401_init(void) #ifdef MODULE printk(KERN_ERR "MPU-401 device not found or device busy\n"); #endif - if (pnp_registered) - pnp_unregister_driver(&snd_mpu401_pnp_driver); - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + if (pnp_registered) + pnp_unregister_driver(&snd_mpu401_pnp_driver); + platform_driver_unregister(&snd_mpu401_driver); + return err; } static void __exit alsa_card_mpu401_exit(void) { - int idx; - if (pnp_registered) pnp_unregister_driver(&snd_mpu401_pnp_driver); - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_mpu401_legacy_cards[idx]); + platform_driver_unregister(&snd_mpu401_driver); } module_init(alsa_card_mpu401_init) -- cgit v1.1 From 597c3c96691c861e837f9024084b4943fa5fc0fd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:04:14 +0100 Subject: [ALSA] Remove SND_GENERIC_DRIVER from drivers/Kconfig Modules: Generic drivers Remove SND_GENERIC_DRIVER from drivers/Kconfig. Signed-off-by: Takashi Iwai --- sound/drivers/Kconfig | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig index efcb4eb..d008855 100644 --- a/sound/drivers/Kconfig +++ b/sound/drivers/Kconfig @@ -6,7 +6,6 @@ menu "Generic devices" config SND_MPU401_UART tristate - select SND_TIMER select SND_RAWMIDI config SND_OPL3_LIB @@ -29,7 +28,6 @@ config SND_DUMMY tristate "Dummy (/dev/null) soundcard" depends on SND select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include the dummy driver. This driver does nothing, but emulates various mixer controls and PCM devices. @@ -45,7 +43,6 @@ config SND_VIRMIDI depends on SND_SEQUENCER select SND_TIMER select SND_RAWMIDI - select SND_GENERIC_DRIVER help Say Y here to include the virtual MIDI driver. This driver allows to connect applications using raw MIDI devices to @@ -59,9 +56,7 @@ config SND_VIRMIDI config SND_MTPAV tristate "MOTU MidiTimePiece AV multiport MIDI" depends on SND - select SND_TIMER select SND_RAWMIDI - select SND_GENERIC_DRIVER help To use a MOTU MidiTimePiece AV multiport MIDI adapter connected to the parallel port, say Y here and make sure that @@ -73,9 +68,7 @@ config SND_MTPAV config SND_SERIAL_U16550 tristate "UART16550 serial MIDI driver" depends on SND - select SND_TIMER select SND_RAWMIDI - select SND_GENERIC_DRIVER help To include support for MIDI serial port interfaces, say Y here and read . @@ -92,7 +85,6 @@ config SND_MPU401 tristate "Generic MPU-401 UART driver" depends on SND select SND_MPU401_UART - select SND_GENERIC_DRIVER help Say Y here to include support for MIDI ports compatible with the Roland MPU-401 interface in UART mode. -- cgit v1.1 From 0ed1cad172176a4595f82e8cd9055938ad54bd4b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:06:05 +0100 Subject: [ALSA] vx-driver - Fix PM support Fix PM support on VX drivers (vxpocket and vx222). Signed-off-by: Takashi Iwai --- include/sound/vx_core.h | 6 ++++++ sound/drivers/vx/vx_core.c | 18 ++++++++---------- sound/pci/vx222/vx222.c | 33 ++++++++++++++++++++++++++++++++- sound/pcmcia/vx/vxpocket.c | 9 +++++---- 4 files changed, 51 insertions(+), 15 deletions(-) diff --git a/include/sound/vx_core.h b/include/sound/vx_core.h index 0a85c37..5fd6f33 100644 --- a/include/sound/vx_core.h +++ b/include/sound/vx_core.h @@ -347,6 +347,12 @@ int vx_change_frequency(struct vx_core *chip); /* + * PM + */ +int snd_vx_suspend(struct vx_core *card, pm_message_t state); +int snd_vx_resume(struct vx_core *card); + +/* * hardware constants */ diff --git a/sound/drivers/vx/vx_core.c b/sound/drivers/vx/vx_core.c index 5abf423..43f615d 100644 --- a/sound/drivers/vx/vx_core.c +++ b/sound/drivers/vx/vx_core.c @@ -709,13 +709,11 @@ int snd_vx_dsp_load(struct vx_core *chip, const struct firmware *dsp) /* * suspend */ -static int snd_vx_suspend(struct snd_card *card, pm_message_t state) +int snd_vx_suspend(struct vx_core *chip, pm_message_t state) { - struct vx_core *chip = card->pm_private_data; unsigned int i; - snd_assert(chip, return -EINVAL); - + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); chip->chip_status |= VX_STAT_IN_SUSPEND; for (i = 0; i < chip->hw->num_codecs; i++) snd_pcm_suspend_all(chip->pcm[i]); @@ -726,13 +724,10 @@ static int snd_vx_suspend(struct snd_card *card, pm_message_t state) /* * resume */ -static int snd_vx_resume(struct snd_card *card) +int snd_vx_resume(struct vx_core *chip) { - struct vx_core *chip = card->pm_private_data; int i, err; - snd_assert(chip, return -EINVAL); - chip->chip_status &= ~VX_STAT_CHIP_INIT; for (i = 0; i < 4; i++) { @@ -748,6 +743,7 @@ static int snd_vx_resume(struct snd_card *card) chip->chip_status |= VX_STAT_CHIP_INIT; chip->chip_status &= ~VX_STAT_IN_SUSPEND; + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); return 0; } @@ -789,8 +785,6 @@ struct vx_core *snd_vx_create(struct snd_card *card, struct snd_vx_hardware *hw, strcpy(card->driver, hw->name); sprintf(card->shortname, "Digigram %s", hw->name); - snd_card_set_pm_callback(card, snd_vx_suspend, snd_vx_resume, chip); - vx_proc_init(chip); return chip; @@ -822,3 +816,7 @@ EXPORT_SYMBOL(snd_vx_irq_handler); EXPORT_SYMBOL(snd_vx_dsp_boot); EXPORT_SYMBOL(snd_vx_dsp_load); EXPORT_SYMBOL(snd_vx_load_boot_image); +#ifdef CONFIG_PM +EXPORT_SYMBOL(snd_vx_suspend); +EXPORT_SYMBOL(snd_vx_resume); +#endif diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c index 4ebbabe..c816ddf 100644 --- a/sound/pci/vx222/vx222.c +++ b/sound/pci/vx222/vx222.c @@ -218,6 +218,7 @@ static int __devinit snd_vx222_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = vx; vx->core.ibl.size = ibl[dev]; sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %i", @@ -250,12 +251,42 @@ static void __devexit snd_vx222_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } +#ifdef CONFIG_PM +static int snd_vx222_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_vx222 *vx = card->private_data; + int err; + + err = snd_vx_suspend(&vx->core, state); + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return err; +} + +static int snd_vx222_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_vx222 *vx = card->private_data; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + return snd_vx_resume(&vx->core); +} +#endif + static struct pci_driver driver = { .name = "Digigram VX222", .id_table = snd_vx222_ids, .probe = snd_vx222_probe, .remove = __devexit_p(snd_vx222_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_vx222_suspend, + .resume = snd_vx222_resume, +#endif }; static int __init alsa_card_vx222_init(void) diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 0096297..5bb079d 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -342,9 +342,9 @@ static int vxpocket_event(event_t event, int priority, event_callback_args_t *ar case CS_EVENT_PM_SUSPEND: snd_printdd(KERN_DEBUG "SUSPEND\n"); link->state |= DEV_SUSPEND; - if (chip && chip->card->pm_suspend) { + if (chip) { snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); - chip->card->pm_suspend(chip->card, PMSG_SUSPEND); + snd_vx_suspend(chip, PMSG_SUSPEND); } /* Fall through... */ case CS_EVENT_RESET_PHYSICAL: @@ -362,9 +362,9 @@ static int vxpocket_event(event_t event, int priority, event_callback_args_t *ar //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; snd_printdd(KERN_DEBUG "requestconfig...\n"); pcmcia_request_configuration(link->handle, &link->conf); - if (chip && chip->card->pm_resume) { + if (chip) { snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); - chip->card->pm_resume(chip->card); + snd_vx_resume(chip); } } snd_printdd(KERN_DEBUG "resume done!\n"); @@ -407,6 +407,7 @@ static dev_link_t *vxpocket_attach(void) snd_card_free(card); return NULL; } + card->private_data = vxp; vxp->index = i; card_alloc |= 1 << i; -- cgit v1.1 From 92304cc7ecfc87d8336696ab5fe6a1c0eec2ff00 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:07:46 +0100 Subject: [ALSA] atiixp - Fix PM support Modules: ATIIXP driver,ATIIXP-modem driver Fix PM support on ATIIXP and modem drivers. Signed-off-by: Takashi Iwai --- sound/pci/atiixp.c | 38 ++++++++++++++++++++++---------------- sound/pci/atiixp_modem.c | 41 +++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 5ead666..a039284 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1415,11 +1415,13 @@ static int __devinit snd_atiixp_mixer_new(struct atiixp *chip, int clock, /* * power management */ -static int snd_atiixp_suspend(struct snd_card *card, pm_message_t state) +static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state) { - struct atiixp *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct atiixp *chip = card->private_data; int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < NUM_ATI_PCMDEVS; i++) if (chip->pcmdevs[i]) { struct atiixp_dma *dma = &chip->dmas[i]; @@ -1429,31 +1431,32 @@ static int snd_atiixp_suspend(struct snd_card *card, pm_message_t state) snd_pcm_suspend_all(chip->pcmdevs[i]); } for (i = 0; i < NUM_ATI_CODECS; i++) - if (chip->ac97[i]) - snd_ac97_suspend(chip->ac97[i]); + snd_ac97_suspend(chip->ac97[i]); snd_atiixp_aclink_down(chip); snd_atiixp_chip_stop(chip); - pci_set_power_state(chip->pci, PCI_D3hot); - pci_disable_device(chip->pci); + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_atiixp_resume(struct snd_card *card) +static int snd_atiixp_resume(struct pci_dev *pci) { - struct atiixp *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct atiixp *chip = card->private_data; int i; - pci_enable_device(chip->pci); - pci_set_power_state(chip->pci, PCI_D0); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); snd_atiixp_aclink_reset(chip); snd_atiixp_chip_start(chip); for (i = 0; i < NUM_ATI_CODECS; i++) - if (chip->ac97[i]) - snd_ac97_resume(chip->ac97[i]); + snd_ac97_resume(chip->ac97[i]); for (i = 0; i < NUM_ATI_PCMDEVS; i++) if (chip->pcmdevs[i]) { @@ -1468,6 +1471,7 @@ static int snd_atiixp_resume(struct snd_card *card) } } + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1604,6 +1608,7 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, strcpy(card->shortname, "ATI IXP"); if ((err = snd_atiixp_create(card, pci, &chip)) < 0) goto __error; + card->private_data = chip; if ((err = snd_atiixp_aclink_reset(chip)) < 0) goto __error; @@ -1625,8 +1630,6 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, chip->ac97[0] ? snd_ac97_get_short_name(chip->ac97[0]) : "?", chip->addr, chip->irq); - snd_card_set_pm_callback(card, snd_atiixp_suspend, snd_atiixp_resume, chip); - if ((err = snd_card_register(card)) < 0) goto __error; @@ -1649,7 +1652,10 @@ static struct pci_driver driver = { .id_table = snd_atiixp_ids, .probe = snd_atiixp_probe, .remove = __devexit_p(snd_atiixp_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_atiixp_suspend, + .resume = snd_atiixp_resume, +#endif }; diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 15be161..73f1f2b 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1113,41 +1113,44 @@ static int __devinit snd_atiixp_mixer_new(struct atiixp_modem *chip, int clock) /* * power management */ -static int snd_atiixp_suspend(struct snd_card *card, pm_message_t state) +static int snd_atiixp_suspend(struct pci_dev *pci, pm_message_t state) { - struct atiixp_modem *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct atiixp_modem *chip = card->private_data; int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < NUM_ATI_PCMDEVS; i++) - if (chip->pcmdevs[i]) - snd_pcm_suspend_all(chip->pcmdevs[i]); + snd_pcm_suspend_all(chip->pcmdevs[i]); for (i = 0; i < NUM_ATI_CODECS; i++) - if (chip->ac97[i]) - snd_ac97_suspend(chip->ac97[i]); + snd_ac97_suspend(chip->ac97[i]); snd_atiixp_aclink_down(chip); snd_atiixp_chip_stop(chip); - pci_set_power_state(chip->pci, PCI_D3hot); - pci_disable_device(chip->pci); + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_atiixp_resume(struct snd_card *card) +static int snd_atiixp_resume(struct pci_dev *pci) { - struct atiixp_modem *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct atiixp_modem *chip = card->private_data; int i; - pci_enable_device(chip->pci); - pci_set_power_state(chip->pci, PCI_D0); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); snd_atiixp_aclink_reset(chip); snd_atiixp_chip_start(chip); for (i = 0; i < NUM_ATI_CODECS; i++) - if (chip->ac97[i]) - snd_ac97_resume(chip->ac97[i]); + snd_ac97_resume(chip->ac97[i]); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1284,6 +1287,7 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, strcpy(card->shortname, "ATI IXP Modem"); if ((err = snd_atiixp_create(card, pci, &chip)) < 0) goto __error; + card->private_data = chip; if ((err = snd_atiixp_aclink_reset(chip)) < 0) goto __error; @@ -1301,8 +1305,6 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, sprintf(card->longname, "%s rev %x at 0x%lx, irq %i", card->shortname, revision, chip->addr, chip->irq); - snd_card_set_pm_callback(card, snd_atiixp_suspend, snd_atiixp_resume, chip); - if ((err = snd_card_register(card)) < 0) goto __error; @@ -1325,7 +1327,10 @@ static struct pci_driver driver = { .id_table = snd_atiixp_ids, .probe = snd_atiixp_probe, .remove = __devexit_p(snd_atiixp_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_atiixp_suspend, + .resume = snd_atiixp_resume, +#endif }; -- cgit v1.1 From 38c0a158ee23027e6a4fe47311e05d9c34c94da4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:08:11 +0100 Subject: [ALSA] cs4281 - Fix PM support Modules: CS4281 driver Fix PM support on CS4281 driver. Signed-off-by: Takashi Iwai --- sound/pci/cs4281.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index 116cdc1..4f65ec5 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1339,10 +1339,6 @@ static int snd_cs4281_dev_free(struct snd_device *device) } static int snd_cs4281_chip_init(struct cs4281 *chip); /* defined below */ -#ifdef CONFIG_PM -static int cs4281_suspend(struct snd_card *card, pm_message_t state); -static int cs4281_resume(struct snd_card *card); -#endif static int __devinit snd_cs4281_create(struct snd_card *card, struct pci_dev *pci, @@ -1411,8 +1407,6 @@ static int __devinit snd_cs4281_create(struct snd_card *card, snd_cs4281_proc_init(chip); - snd_card_set_pm_callback(card, cs4281_suspend, cs4281_resume, chip); - snd_card_set_dev(card, &pci->dev); *rchip = chip; @@ -1936,6 +1930,7 @@ static int __devinit snd_cs4281_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = chip; if ((err = snd_cs4281_mixer(chip)) < 0) { snd_card_free(card); @@ -2007,18 +2002,18 @@ static int saved_regs[SUSPEND_REGISTERS] = { #define CLKCR1_CKRA 0x00010000L -static int cs4281_suspend(struct snd_card *card, pm_message_t state) +static int cs4281_suspend(struct pci_dev *pci, pm_message_t state) { - struct cs4281 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct cs4281 *chip = card->private_data; u32 ulCLK; unsigned int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); - if (chip->ac97) - snd_ac97_suspend(chip->ac97); - if (chip->ac97_secondary) - snd_ac97_suspend(chip->ac97_secondary); + snd_ac97_suspend(chip->ac97); + snd_ac97_suspend(chip->ac97_secondary); ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); ulCLK |= CLKCR1_CKRA; @@ -2048,18 +2043,21 @@ static int cs4281_suspend(struct snd_card *card, pm_message_t state) ulCLK &= ~CLKCR1_CKRA; snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK); - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int cs4281_resume(struct snd_card *card) +static int cs4281_resume(struct pci_dev *pci) { - struct cs4281 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct cs4281 *chip = card->private_data; unsigned int i; u32 ulCLK; - pci_enable_device(chip->pci); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); ulCLK |= CLKCR1_CKRA; @@ -2072,15 +2070,14 @@ static int cs4281_resume(struct snd_card *card) if (saved_regs[i]) snd_cs4281_pokeBA0(chip, saved_regs[i], chip->suspend_regs[i]); - if (chip->ac97) - snd_ac97_resume(chip->ac97); - if (chip->ac97_secondary) - snd_ac97_resume(chip->ac97_secondary); + snd_ac97_resume(chip->ac97); + snd_ac97_resume(chip->ac97_secondary); ulCLK = snd_cs4281_peekBA0(chip, BA0_CLKCR1); ulCLK &= ~CLKCR1_CKRA; snd_cs4281_pokeBA0(chip, BA0_CLKCR1, ulCLK); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -2090,7 +2087,10 @@ static struct pci_driver driver = { .id_table = snd_cs4281_ids, .probe = snd_cs4281_probe, .remove = __devexit_p(snd_cs4281_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = cs4281_suspend, + .resume = cs4281_resume, +#endif }; static int __init alsa_card_cs4281_init(void) -- cgit v1.1 From b34a580ec5b2eb7d3a7645552821e9dadb42bdab Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:08:27 +0100 Subject: [ALSA] es1938 - Fix PM support Modules: ES1938 driver Fix PM support on ES1938 driver. Signed-off-by: Takashi Iwai --- sound/pci/es1938.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/sound/pci/es1938.c b/sound/pci/es1938.c index 577877d..0d556b0 100644 --- a/sound/pci/es1938.c +++ b/sound/pci/es1938.c @@ -1398,11 +1398,13 @@ static unsigned char saved_regs[SAVED_REG_SIZE+1] = { }; -static int es1938_suspend(struct snd_card *card, pm_message_t state) +static int es1938_suspend(struct pci_dev *pci, pm_message_t state) { - struct es1938 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct es1938 *chip = card->private_data; unsigned char *s, *d; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); /* save mixer-related registers */ @@ -1411,20 +1413,23 @@ static int es1938_suspend(struct snd_card *card, pm_message_t state) outb(0x00, SLIO_REG(chip, IRQCONTROL)); /* disable irqs */ if (chip->irq >= 0) - free_irq(chip->irq, chip); - pci_disable_device(chip->pci); + free_irq(chip->irq, chip); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int es1938_resume(struct snd_card *card) +static int es1938_resume(struct pci_dev *pci) { - struct es1938 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct es1938 *chip = card->private_data; unsigned char *s, *d; - pci_enable_device(chip->pci); - request_irq(chip->pci->irq, snd_es1938_interrupt, + pci_restore_state(pci); + pci_enable_device(pci); + request_irq(pci->irq, snd_es1938_interrupt, SA_INTERRUPT|SA_SHIRQ, "ES1938", chip); - chip->irq = chip->pci->irq; + chip->irq = pci->irq; snd_es1938_chip_init(chip); /* restore mixer-related registers */ @@ -1435,6 +1440,7 @@ static int es1938_resume(struct snd_card *card) snd_es1938_write(chip, *s, *d); } + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1553,8 +1559,6 @@ static int __devinit snd_es1938_create(struct snd_card *card, snd_es1938_chip_init(chip); - snd_card_set_pm_callback(card, es1938_suspend, es1938_resume, chip); - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_es1938_free(chip); return err; @@ -1717,6 +1721,7 @@ static int __devinit snd_es1938_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = chip; strcpy(card->driver, "ES1938"); strcpy(card->shortname, "ESS ES1938 (Solo-1)"); @@ -1781,7 +1786,10 @@ static struct pci_driver driver = { .id_table = snd_es1938_ids, .probe = snd_es1938_probe, .remove = __devexit_p(snd_es1938_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = es1938_suspend, + .resume = es1938_resume, +#endif }; static int __init alsa_card_es1938_init(void) -- cgit v1.1 From 1d4b822be64b119b47c172aaac7ee76949470e28 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:08:43 +0100 Subject: [ALSA] es1968 - Fix PM support Modules: ES1968 driver Fix PM support on ES1968 driver. Signed-off-by: Takashi Iwai --- sound/pci/es1968.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 021862d..240cf2b4 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2378,33 +2378,38 @@ static void snd_es1968_start_irq(struct es1968 *chip) /* * PM support */ -static int es1968_suspend(struct snd_card *card, pm_message_t state) +static int es1968_suspend(struct pci_dev *pci, pm_message_t state) { - struct es1968 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct es1968 *chip = card->private_data; if (! chip->do_pm) return 0; chip->in_suspend = 1; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); snd_es1968_bob_stop(chip); snd_es1968_set_acpi(chip, ACPI_D3); - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int es1968_resume(struct snd_card *card) +static int es1968_resume(struct pci_dev *pci) { - struct es1968 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct es1968 *chip = card->private_data; struct list_head *p; if (! chip->do_pm) return 0; /* restore all our config */ - pci_enable_device(chip->pci); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); snd_es1968_chip_init(chip); /* need to restore the base pointers.. */ @@ -2434,6 +2439,7 @@ static int es1968_resume(struct snd_card *card) if (chip->bobclient) snd_es1968_bob_start(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); chip->in_suspend = 0; return 0; } @@ -2631,9 +2637,6 @@ static int __devinit snd_es1968_create(struct snd_card *card, snd_es1968_chip_init(chip); - if (chip->do_pm) - snd_card_set_pm_callback(card, es1968_suspend, es1968_resume, chip); - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_es1968_free(chip); return err; @@ -2683,6 +2686,7 @@ static int __devinit snd_es1968_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = chip; switch (chip->type) { case TYPE_MAESTRO2E: @@ -2760,7 +2764,10 @@ static struct pci_driver driver = { .id_table = snd_es1968_ids, .probe = snd_es1968_probe, .remove = __devexit_p(snd_es1968_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = es1968_suspend, + .resume = es1968_resume, +#endif }; static int __init alsa_card_es1968_init(void) -- cgit v1.1 From cb28e45ba2aa42393596a364d4f947027db8a1b5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:09:04 +0100 Subject: [ALSA] cs46xx - Fix PM support Modules: CS46xx driver Fix PM support on CS46xx driver. Signed-off-by: Takashi Iwai --- include/sound/cs46xx.h | 2 ++ sound/pci/cs46xx/cs46xx.c | 6 +++++- sound/pci/cs46xx/cs46xx_lib.c | 28 +++++++++++++++------------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/include/sound/cs46xx.h b/include/sound/cs46xx.h index b33ca2a..199b509 100644 --- a/include/sound/cs46xx.h +++ b/include/sound/cs46xx.h @@ -1728,6 +1728,8 @@ int snd_cs46xx_create(struct snd_card *card, struct pci_dev *pci, int external_amp, int thinkpad, struct snd_cs46xx **rcodec); +int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state); +int snd_cs46xx_resume(struct pci_dev *pci); int snd_cs46xx_pcm(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); int snd_cs46xx_pcm_rear(struct snd_cs46xx *chip, int device, struct snd_pcm **rpcm); diff --git a/sound/pci/cs46xx/cs46xx.c b/sound/pci/cs46xx/cs46xx.c index 7d6b29e..c590602 100644 --- a/sound/pci/cs46xx/cs46xx.c +++ b/sound/pci/cs46xx/cs46xx.c @@ -98,6 +98,7 @@ static int __devinit snd_card_cs46xx_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = chip; chip->accept_valid = mmap_valid[dev]; if ((err = snd_cs46xx_pcm(chip, 0, NULL)) < 0) { snd_card_free(card); @@ -166,7 +167,10 @@ static struct pci_driver driver = { .id_table = snd_cs46xx_ids, .probe = snd_card_cs46xx_probe, .remove = __devexit_p(snd_card_cs46xx_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_cs46xx_suspend, + .resume = snd_cs46xx_resume, +#endif }; static int __init alsa_card_cs46xx_init(void) diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 11d91d0..0ec0592 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -3654,18 +3654,19 @@ static struct cs_card_type __devinitdata cards[] = { * APM support */ #ifdef CONFIG_PM -static int snd_cs46xx_suspend(struct snd_card *card, pm_message_t state) +int snd_cs46xx_suspend(struct pci_dev *pci, pm_message_t state) { - struct snd_cs46xx *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_cs46xx *chip = card->private_data; int amp_saved; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); // chip->ac97_powerdown = snd_cs46xx_codec_read(chip, AC97_POWER_CONTROL); // chip->ac97_general_purpose = snd_cs46xx_codec_read(chip, BA0_AC97_GENERAL_PURPOSE); snd_ac97_suspend(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); - if (chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]) - snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); + snd_ac97_suspend(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); amp_saved = chip->amplifier; /* turn off amp */ @@ -3674,17 +3675,20 @@ static int snd_cs46xx_suspend(struct snd_card *card, pm_message_t state) /* disable CLKRUN */ chip->active_ctrl(chip, -chip->amplifier); chip->amplifier = amp_saved; /* restore the status */ - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_cs46xx_resume(struct snd_card *card) +int snd_cs46xx_resume(struct pci_dev *pci) { - struct snd_cs46xx *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_cs46xx *chip = card->private_data; int amp_saved; - pci_enable_device(chip->pci); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); amp_saved = chip->amplifier; chip->amplifier = 0; chip->active_ctrl(chip, 1); /* force to on */ @@ -3703,14 +3707,14 @@ static int snd_cs46xx_resume(struct snd_card *card) #endif snd_ac97_resume(chip->ac97[CS46XX_PRIMARY_CODEC_INDEX]); - if (chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]) - snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); + snd_ac97_resume(chip->ac97[CS46XX_SECONDARY_CODEC_INDEX]); if (amp_saved) chip->amplifier_ctrl(chip, 1); /* turn amp on */ else chip->active_ctrl(chip, -1); /* disable CLKRUN */ chip->amplifier = amp_saved; + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -3870,8 +3874,6 @@ int __devinit snd_cs46xx_create(struct snd_card *card, snd_cs46xx_proc_init(card, chip); - snd_card_set_pm_callback(card, snd_cs46xx_suspend, snd_cs46xx_resume, chip); - chip->active_ctrl(chip, -1); /* disable CLKRUN */ snd_card_set_dev(card, &pci->dev); -- cgit v1.1 From fb0700b4debbf45fb0465b40188bdc5396947bda Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:09:25 +0100 Subject: [ALSA] trident - Fix PM support Modules: Trident driver Fix PM support on Trident driver. Signed-off-by: Takashi Iwai --- include/sound/trident.h | 2 ++ sound/pci/trident/trident.c | 6 +++++- sound/pci/trident/trident_main.c | 41 +++++++++++++++++----------------------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/include/sound/trident.h b/include/sound/trident.h index 2c54569..9752243 100644 --- a/include/sound/trident.h +++ b/include/sound/trident.h @@ -452,6 +452,8 @@ void snd_trident_free_voice(struct snd_trident * trident, struct snd_trident_voi void snd_trident_start_voice(struct snd_trident * trident, unsigned int voice); void snd_trident_stop_voice(struct snd_trident * trident, unsigned int voice); void snd_trident_write_voice_regs(struct snd_trident * trident, struct snd_trident_voice *voice); +int snd_trident_suspend(struct pci_dev *pci, pm_message_t state); +int snd_trident_resume(struct pci_dev *pci); /* TLB memory allocation */ struct snd_util_memblk *snd_trident_alloc_pages(struct snd_trident *trident, diff --git a/sound/pci/trident/trident.c b/sound/pci/trident/trident.c index 0999f1f..2b21df1 100644 --- a/sound/pci/trident/trident.c +++ b/sound/pci/trident/trident.c @@ -100,6 +100,7 @@ static int __devinit snd_trident_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = trident; switch (trident->device) { case TRIDENT_DEVICE_ID_DX: @@ -180,7 +181,10 @@ static struct pci_driver driver = { .id_table = snd_trident_ids, .probe = snd_trident_probe, .remove = __devexit_p(snd_trident_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_trident_suspend, + .resume = snd_trident_resume, +#endif }; static int __init alsa_card_trident_init(void) diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 6277dcc..83b7d8a 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -52,10 +52,6 @@ static int snd_trident_pcm_mixer_free(struct snd_trident *trident, struct snd_pcm_substream *substream); static irqreturn_t snd_trident_interrupt(int irq, void *dev_id, struct pt_regs *regs); -#ifdef CONFIG_PM -static int snd_trident_suspend(struct snd_card *card, pm_message_t state); -static int snd_trident_resume(struct snd_card *card); -#endif static int snd_trident_sis_reset(struct snd_trident *trident); static void snd_trident_clear_voices(struct snd_trident * trident, @@ -3661,8 +3657,6 @@ int __devinit snd_trident_create(struct snd_card *card, snd_trident_enable_eso(trident); - - snd_card_set_pm_callback(card, snd_trident_suspend, snd_trident_resume, trident); snd_trident_proc_init(trident); snd_card_set_dev(card, &pci->dev); *rtrident = trident; @@ -3938,20 +3932,19 @@ static void snd_trident_clear_voices(struct snd_trident * trident, unsigned shor } #ifdef CONFIG_PM -static int snd_trident_suspend(struct snd_card *card, pm_message_t state) +int snd_trident_suspend(struct pci_dev *pci, pm_message_t state) { - struct snd_trident *trident = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_trident *trident = card->private_data; trident->in_suspend = 1; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(trident->pcm); - if (trident->foldback) - snd_pcm_suspend_all(trident->foldback); - if (trident->spdif) - snd_pcm_suspend_all(trident->spdif); + snd_pcm_suspend_all(trident->foldback); + snd_pcm_suspend_all(trident->spdif); snd_ac97_suspend(trident->ac97); - if (trident->ac97_sec) - snd_ac97_suspend(trident->ac97_sec); + snd_ac97_suspend(trident->ac97_sec); switch (trident->device) { case TRIDENT_DEVICE_ID_DX: @@ -3960,19 +3953,19 @@ static int snd_trident_suspend(struct snd_card *card, pm_message_t state) case TRIDENT_DEVICE_ID_SI7018: break; } - pci_disable_device(trident->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_trident_resume(struct snd_card *card) +int snd_trident_resume(struct pci_dev *pci) { - struct snd_trident *trident = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_trident *trident = card->private_data; - pci_enable_device(trident->pci); - if (pci_set_dma_mask(trident->pci, 0x3fffffff) < 0 || - pci_set_consistent_dma_mask(trident->pci, 0x3fffffff) < 0) - snd_printk(KERN_WARNING "trident: can't set the proper DMA mask\n"); - pci_set_master(trident->pci); /* to be sure */ + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); /* to be sure */ switch (trident->device) { case TRIDENT_DEVICE_ID_DX: @@ -3987,14 +3980,14 @@ static int snd_trident_resume(struct snd_card *card) } snd_ac97_resume(trident->ac97); - if (trident->ac97_sec) - snd_ac97_resume(trident->ac97_sec); + snd_ac97_resume(trident->ac97_sec); /* restore some registers */ outl(trident->musicvol_wavevol, TRID_REG(trident, T4D_MUSICVOL_WAVEVOL)); snd_trident_enable_eso(trident); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); trident->in_suspend = 0; return 0; } -- cgit v1.1 From ded462356886e5f80f6a20b227f7e5cf7cfc5159 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:09:43 +0100 Subject: [ALSA] ymfpci - Fix PM support Modules: YMFPCI driver Fix PM support on YMFPCI driver. Signed-off-by: Takashi Iwai --- include/sound/ymfpci.h | 3 +++ sound/pci/ymfpci/ymfpci.c | 7 ++++++- sound/pci/ymfpci/ymfpci_main.c | 23 ++++++++++++++--------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/sound/ymfpci.h b/include/sound/ymfpci.h index ec790a9..d567bfd 100644 --- a/include/sound/ymfpci.h +++ b/include/sound/ymfpci.h @@ -369,6 +369,9 @@ int snd_ymfpci_create(struct snd_card *card, struct snd_ymfpci ** rcodec); void snd_ymfpci_free_gameport(struct snd_ymfpci *chip); +int snd_ymfpci_suspend(struct pci_dev *pci, pm_message_t state); +int snd_ymfpci_resume(struct pci_dev *pci); + int snd_ymfpci_pcm(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); int snd_ymfpci_pcm2(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); int snd_ymfpci_pcm_spdif(struct snd_ymfpci *chip, int device, struct snd_pcm **rpcm); diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 42499a9..9e30e2c 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -271,6 +271,8 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci, } chip->fm_res = fm_res; chip->mpu_res = mpu_res; + card->private_data = chip; + strcpy(card->driver, str); sprintf(card->shortname, "Yamaha DS-XG (%s)", str); sprintf(card->longname, "%s at 0x%lx, irq %i", @@ -347,7 +349,10 @@ static struct pci_driver driver = { .id_table = snd_ymfpci_ids, .probe = snd_card_ymfpci_probe, .remove = __devexit_p(snd_card_ymfpci_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_ymfpci_suspend, + .resume = snd_ymfpci_resume, +#endif }; static int __init alsa_card_ymfpci_init(void) diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 62c9f25..1dfc723 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2175,11 +2175,13 @@ static int saved_regs_index[] = { }; #define YDSXGR_NUM_SAVED_REGS ARRAY_SIZE(saved_regs_index) -static int snd_ymfpci_suspend(struct snd_card *card, pm_message_t state) +int snd_ymfpci_suspend(struct pci_dev *pci, pm_message_t state) { - struct snd_ymfpci *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_ymfpci *chip = card->private_data; unsigned int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); snd_pcm_suspend_all(chip->pcm2); snd_pcm_suspend_all(chip->pcm_spdif); @@ -2190,18 +2192,21 @@ static int snd_ymfpci_suspend(struct snd_card *card, pm_message_t state) chip->saved_ydsxgr_mode = snd_ymfpci_readl(chip, YDSXGR_MODE); snd_ymfpci_writel(chip, YDSXGR_NATIVEDACOUTVOL, 0); snd_ymfpci_disable_dsp(chip); - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_ymfpci_resume(struct snd_card *card) +int snd_ymfpci_resume(struct pci_dev *pci) { - struct snd_ymfpci *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_ymfpci *chip = card->private_data; unsigned int i; - pci_enable_device(chip->pci); - pci_set_master(chip->pci); - snd_ymfpci_aclink_reset(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); + snd_ymfpci_aclink_reset(pci); snd_ymfpci_codec_ready(chip, 0); snd_ymfpci_download_image(chip); udelay(100); @@ -2218,6 +2223,7 @@ static int snd_ymfpci_resume(struct snd_card *card) chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT); spin_unlock_irq(&chip->reg_lock); } + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -2296,7 +2302,6 @@ int __devinit snd_ymfpci_create(struct snd_card *card, snd_ymfpci_free(chip); return -ENOMEM; } - snd_card_set_pm_callback(card, snd_ymfpci_suspend, snd_ymfpci_resume, chip); #endif if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { -- cgit v1.1 From 5809c6c41ae95ce3f45ad14d31503deb1fa8268a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:10:01 +0100 Subject: [ALSA] intel8x0 - Fix PM support Modules: Intel8x0 driver,Intel8x0-modem driver Fix PM support on Intel8x0 and modem drivers. Signed-off-by: Takashi Iwai --- sound/pci/intel8x0.c | 37 ++++++++++++++++++++++--------------- sound/pci/intel8x0m.c | 35 +++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 3ea90f1..c5c4ec6 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2396,11 +2396,13 @@ static int snd_intel8x0_free(struct intel8x0 *chip) /* * power management */ -static int intel8x0_suspend(struct snd_card *card, pm_message_t state) +static int intel8x0_suspend(struct pci_dev *pci, pm_message_t state) { - struct intel8x0 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct intel8x0 *chip = card->private_data; int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < chip->pcm_devs; i++) snd_pcm_suspend_all(chip->pcm[i]); /* clear nocache */ @@ -2415,26 +2417,29 @@ static int intel8x0_suspend(struct snd_card *card, pm_message_t state) } } for (i = 0; i < 3; i++) - if (chip->ac97[i]) - snd_ac97_suspend(chip->ac97[i]); + snd_ac97_suspend(chip->ac97[i]); if (chip->device_type == DEVICE_INTEL_ICH4) chip->sdm_saved = igetbyte(chip, ICHREG(SDM)); if (chip->irq >= 0) free_irq(chip->irq, chip); - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int intel8x0_resume(struct snd_card *card) +static int intel8x0_resume(struct pci_dev *pci) { - struct intel8x0 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct intel8x0 *chip = card->private_data; int i; - pci_enable_device(chip->pci); - pci_set_master(chip->pci); - request_irq(chip->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); + request_irq(pci->irq, snd_intel8x0_interrupt, SA_INTERRUPT|SA_SHIRQ, card->shortname, chip); + chip->irq = pci->irq; synchronize_irq(chip->irq); snd_intel8x0_chip_init(chip, 1); @@ -2453,8 +2458,7 @@ static int intel8x0_resume(struct snd_card *card) fill_nocache(chip->bdbars.area, chip->bdbars.bytes, 1); for (i = 0; i < 3; i++) - if (chip->ac97[i]) - snd_ac97_resume(chip->ac97[i]); + snd_ac97_resume(chip->ac97[i]); /* refill nocache */ if (chip->fix_nocache) { @@ -2482,6 +2486,7 @@ static int intel8x0_resume(struct snd_card *card) iputbyte(chip, port + ichdev->roff_sr, ICH_FIFOE | ICH_BCIS | ICH_LVBCI); } + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -2800,8 +2805,6 @@ static int __devinit snd_intel8x0_create(struct snd_card *card, return err; } - snd_card_set_pm_callback(card, intel8x0_suspend, intel8x0_resume, chip); - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_intel8x0_free(chip); return err; @@ -2889,6 +2892,7 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = chip; if ((err = snd_intel8x0_mixer(chip, ac97_clock, ac97_quirk)) < 0) { snd_card_free(card); @@ -2927,7 +2931,10 @@ static struct pci_driver driver = { .id_table = snd_intel8x0_ids, .probe = snd_intel8x0_probe, .remove = __devexit_p(snd_intel8x0_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = intel8x0_suspend, + .resume = intel8x0_resume, +#endif }; diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 3b6724e..466170e 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1035,28 +1035,33 @@ static int snd_intel8x0_free(struct intel8x0m *chip) /* * power management */ -static int intel8x0m_suspend(struct snd_card *card, pm_message_t state) +static int intel8x0m_suspend(struct pci_dev *pci, pm_message_t state) { - struct intel8x0m *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct intel8x0m *chip = card->private_data; int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < chip->pcm_devs; i++) snd_pcm_suspend_all(chip->pcm[i]); - if (chip->ac97) - snd_ac97_suspend(chip->ac97); - pci_disable_device(chip->pci); + snd_ac97_suspend(chip->ac97); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int intel8x0m_resume(struct snd_card *card) +static int intel8x0m_resume(struct pci_dev *pci) { - struct intel8x0m *chip = card->pm_private_data; - pci_enable_device(chip->pci); - pci_set_master(chip->pci); + struct snd_card *card = pci_get_drvdata(pci); + struct intel8x0m *chip = card->private_data; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); snd_intel8x0_chip_init(chip, 0); - if (chip->ac97) - snd_ac97_resume(chip->ac97); + snd_ac97_resume(chip->ac97); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1233,8 +1238,6 @@ static int __devinit snd_intel8x0m_create(struct snd_card *card, return err; } - snd_card_set_pm_callback(card, intel8x0m_suspend, intel8x0m_resume, chip); - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_intel8x0_free(chip); return err; @@ -1298,6 +1301,7 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = chip; if ((err = snd_intel8x0_mixer(chip, ac97_clock)) < 0) { snd_card_free(card); @@ -1332,7 +1336,10 @@ static struct pci_driver driver = { .id_table = snd_intel8x0m_ids, .probe = snd_intel8x0m_probe, .remove = __devexit_p(snd_intel8x0m_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = intel8x0m_suspend, + .resume = intel8x0m_resume, +#endif }; -- cgit v1.1 From 0e2364a7013688c06d1a9454a2c20567027f6a6e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:10:19 +0100 Subject: [ALSA] maestro3 - Fix PM support Modules: Maestro3 driver Fix PM support on maestro3 driver. Signed-off-by: Takashi Iwai --- sound/pci/maestro3.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 9878595..d3ef0cc 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c @@ -2546,14 +2546,16 @@ static int snd_m3_free(struct snd_m3 *chip) * APM support */ #ifdef CONFIG_PM -static int m3_suspend(struct snd_card *card, pm_message_t state) +static int m3_suspend(struct pci_dev *pci, pm_message_t state) { - struct snd_m3 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_m3 *chip = card->private_data; int i, index; if (chip->suspend_mem == NULL) return 0; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); @@ -2574,20 +2576,23 @@ static int m3_suspend(struct snd_card *card, pm_message_t state) snd_m3_outw(chip, 0xffff, 0x54); snd_m3_outw(chip, 0xffff, 0x56); - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int m3_resume(struct snd_card *card) +static int m3_resume(struct pci_dev *pci) { - struct snd_m3 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_m3 *chip = card->private_data; int i, index; if (chip->suspend_mem == NULL) return 0; - pci_enable_device(chip->pci); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); /* first lets just bring everything back. .*/ snd_m3_outw(chip, 0, 0x54); @@ -2617,6 +2622,7 @@ static int m3_resume(struct snd_card *card) snd_m3_enable_ints(chip); snd_m3_amp_enable(chip, 1); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -2748,8 +2754,6 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH)); if (chip->suspend_mem == NULL) snd_printk(KERN_WARNING "can't allocate apm buffer\n"); - else - snd_card_set_pm_callback(card, m3_suspend, m3_resume, chip); #endif if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { @@ -2825,6 +2829,7 @@ snd_m3_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) snd_card_free(card); return err; } + card->private_data = chip; sprintf(card->shortname, "ESS %s PCI", card->driver); sprintf(card->longname, "%s at 0x%lx, irq %d", @@ -2860,7 +2865,10 @@ static struct pci_driver driver = { .id_table = snd_m3_ids, .probe = snd_m3_probe, .remove = __devexit_p(snd_m3_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = m3_suspend, + .resume = m3_resume, +#endif }; static int __init alsa_card_m3_init(void) -- cgit v1.1 From 57feb83507d598de04e986cfa463acda9f2a67a8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:10:35 +0100 Subject: [ALSA] via82xx - Fix PM support Modules: VIA82xx driver,VIA82xx-modem driver Fix PM support on VIA82xx and modem drivers. Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 33 ++++++++++++++++++++------------- sound/pci/via82xx_modem.c | 35 +++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index c870001..ce4985f 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2126,14 +2126,15 @@ static int snd_via82xx_chip_init(struct via82xx *chip) /* * power management */ -static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state) +static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state) { - struct via82xx *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct via82xx *chip = card->private_data; int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < 2; i++) - if (chip->pcms[i]) - snd_pcm_suspend_all(chip->pcms[i]); + snd_pcm_suspend_all(chip->pcms[i]); for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); synchronize_irq(chip->irq); @@ -2146,18 +2147,21 @@ static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state) chip->capture_src_saved[1] = inb(chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10); } - pci_set_power_state(chip->pci, 3); - pci_disable_device(chip->pci); + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_via82xx_resume(struct snd_card *card) +static int snd_via82xx_resume(struct pci_dev *pci) { - struct via82xx *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct via82xx *chip = card->private_data; int i; - pci_enable_device(chip->pci); - pci_set_power_state(chip->pci, 0); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); snd_via82xx_chip_init(chip); @@ -2177,6 +2181,7 @@ static int snd_via82xx_resume(struct snd_card *card) for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -2453,6 +2458,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock, &chip)) < 0) goto __error; + card->private_data = chip; if ((err = snd_via82xx_mixer_new(chip, ac97_quirk)) < 0) goto __error; @@ -2481,8 +2487,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, goto __error; } - snd_card_set_pm_callback(card, snd_via82xx_suspend, snd_via82xx_resume, chip); - /* disable interrupts */ for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); @@ -2516,7 +2520,10 @@ static struct pci_driver driver = { .id_table = snd_via82xx_ids, .probe = snd_via82xx_probe, .remove = __devexit_p(snd_via82xx_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_via82xx_suspend, + .resume = snd_via82xx_resume, +#endif }; static int __init alsa_card_via82xx_init(void) diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 55ef69a..22ce4d3 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -1019,31 +1019,35 @@ static int snd_via82xx_chip_init(struct via82xx_modem *chip) /* * power management */ -static int snd_via82xx_suspend(struct snd_card *card, pm_message_t state) +static int snd_via82xx_suspend(struct pci_dev *pci, pm_message_t state) { - struct via82xx_modem *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct via82xx_modem *chip = card->private_data; int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < 2; i++) - if (chip->pcms[i]) - snd_pcm_suspend_all(chip->pcms[i]); + snd_pcm_suspend_all(chip->pcms[i]); for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); synchronize_irq(chip->irq); snd_ac97_suspend(chip->ac97); - pci_set_power_state(chip->pci, 3); - pci_disable_device(chip->pci); + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_via82xx_resume(struct snd_card *card) +static int snd_via82xx_resume(struct pci_dev *pci) { - struct via82xx_modem *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct via82xx_modem *chip = card->private_data; int i; - pci_enable_device(chip->pci); - pci_set_power_state(chip->pci, 0); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); snd_via82xx_chip_init(chip); @@ -1052,6 +1056,7 @@ static int snd_via82xx_resume(struct snd_card *card) for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1176,14 +1181,13 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock, &chip)) < 0) goto __error; + card->private_data = chip; if ((err = snd_via82xx_mixer_new(chip)) < 0) goto __error; if ((err = snd_via686_pcm_new(chip)) < 0 ) goto __error; - snd_card_set_pm_callback(card, snd_via82xx_suspend, snd_via82xx_resume, chip); - /* disable interrupts */ for (i = 0; i < chip->num_devs; i++) snd_via82xx_channel_reset(chip, &chip->devs[i]); @@ -1216,7 +1220,10 @@ static struct pci_driver driver = { .id_table = snd_via82xx_modem_ids, .probe = snd_via82xx_probe, .remove = __devexit_p(snd_via82xx_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_via82xx_suspend, + .resume = snd_via82xx_resume, +#endif }; static int __init alsa_card_via82xx_init(void) -- cgit v1.1 From bf53c3b3f368cdc2aa9a59f220337ede854f507d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:10:51 +0100 Subject: [ALSA] ali5451 - Fix PM support Modules: ALI5451 driver Fix PM support on ALI5451 driver. Signed-off-by: Takashi Iwai --- sound/pci/ali5451/ali5451.c | 46 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 2538cda..bc4d1ef 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -1991,9 +1991,10 @@ static int __devinit snd_ali_mixer(struct snd_ali * codec) } #ifdef CONFIG_PM -static int ali_suspend(struct snd_card *card, pm_message_t state) +static int ali_suspend(struct pci_dev *pci, pm_message_t state) { - struct snd_ali *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_ali *chip = card->private_data; struct snd_ali_image *im; int i, j; @@ -2001,11 +2002,10 @@ static int ali_suspend(struct snd_card *card, pm_message_t state) if (! im) return 0; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for(i = 0 ; i < chip->num_of_codecs ; i++) { - if (chip->pcm[i]) - snd_pcm_suspend_all(chip->pcm[i]); - if(chip->ac97[i]) - snd_ac97_suspend(chip->ac97[i]); + snd_pcm_suspend_all(chip->pcm[i]); + snd_ac97_suspend(chip->ac97[i]); } spin_lock_irq(&chip->reg_lock); @@ -2033,13 +2033,15 @@ static int ali_suspend(struct snd_card *card, pm_message_t state) outl(0xffffffff, ALI_REG(chip, ALI_STOP)); spin_unlock_irq(&chip->reg_lock); - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int ali_resume(struct snd_card *card) +static int ali_resume(struct pci_dev *pci) { - struct snd_ali *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct snd_ali *chip = card->private_data; struct snd_ali_image *im; int i, j; @@ -2047,7 +2049,8 @@ static int ali_resume(struct snd_card *card) if (! im) return 0; - pci_enable_device(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); spin_lock_irq(&chip->reg_lock); @@ -2071,9 +2074,9 @@ static int ali_resume(struct snd_card *card) spin_unlock_irq(&chip->reg_lock); for(i = 0 ; i < chip->num_of_codecs ; i++) - if(chip->ac97[i]) - snd_ac97_resume(chip->ac97[i]); + snd_ac97_resume(chip->ac97[i]); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -2204,9 +2207,8 @@ static int __devinit snd_ali_create(struct snd_card *card, { struct snd_ali *codec; int i, err; - unsigned short cmdw = 0; - struct pci_dev *pci_dev = NULL; - static struct snd_device_ops ops = { + unsigned short cmdw; + static struct snd_device_ops ops = { .dev_free = snd_ali_dev_free, }; @@ -2281,16 +2283,14 @@ static int __devinit snd_ali_create(struct snd_card *card, codec->chregs.data.ainten = 0x00; /* M1533: southbridge */ - pci_dev = pci_get_device(0x10b9, 0x1533, NULL); - codec->pci_m1533 = pci_dev; + codec->pci_m1533 = pci_get_device(0x10b9, 0x1533, NULL); if (! codec->pci_m1533) { snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); snd_ali_free(codec); return -ENODEV; } /* M7101: power management */ - pci_dev = pci_get_device(0x10b9, 0x7101, NULL); - codec->pci_m7101 = pci_dev; + codec->pci_m7101 = pci_get_device(0x10b9, 0x7101, NULL); if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); snd_ali_free(codec); @@ -2317,8 +2317,6 @@ static int __devinit snd_ali_create(struct snd_card *card, codec->image = kmalloc(sizeof(*codec->image), GFP_KERNEL); if (! codec->image) snd_printk(KERN_WARNING "can't allocate apm buffer\n"); - else - snd_card_set_pm_callback(card, ali_suspend, ali_resume, codec); #endif snd_ali_enable_address_interrupt(codec); @@ -2346,6 +2344,7 @@ static int __devinit snd_ali_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = codec; snd_ali_printk("mixer building ...\n"); if ((err = snd_ali_mixer(codec)) < 0) { @@ -2387,7 +2386,10 @@ static struct pci_driver driver = { .id_table = snd_ali_ids, .probe = snd_ali_probe, .remove = __devexit_p(snd_ali_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = ali_suspend, + .resume = ali_resume, +#endif }; static int __init alsa_card_ali_init(void) -- cgit v1.1 From 421a12520d4ed4a0c96640fb672ef24ad8019beb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:11:09 +0100 Subject: [ALSA] hda-intel - Fix PM support Modules: HDA Intel driver Fix PM support on HDA-Intel driver. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index abdbd96..3945c44 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -1326,28 +1326,33 @@ static int __devinit azx_init_stream(struct azx *chip) /* * power management */ -static int azx_suspend(struct snd_card *card, pm_message_t state) +static int azx_suspend(struct pci_dev *pci, pm_message_t state) { - struct azx *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct azx *chip = card->private_data; int i; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); for (i = 0; i < chip->pcm_devs; i++) - if (chip->pcm[i]) - snd_pcm_suspend_all(chip->pcm[i]); + snd_pcm_suspend_all(chip->pcm[i]); snd_hda_suspend(chip->bus, state); azx_free_cmd_io(chip); - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int azx_resume(struct snd_card *card) +static int azx_resume(struct pci_dev *pci) { - struct azx *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct azx *chip = card->private_data; - pci_enable_device(chip->pci); - pci_set_master(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); azx_init_chip(chip); snd_hda_resume(chip->bus); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1559,6 +1564,7 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id * snd_card_free(card); return err; } + card->private_data = chip; /* create codec instances */ if ((err = azx_codec_create(chip, model)) < 0) { @@ -1578,7 +1584,6 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id * return err; } - snd_card_set_pm_callback(card, azx_suspend, azx_resume, chip); snd_card_set_dev(card, &pci->dev); if ((err = snd_card_register(card)) < 0) { @@ -1618,7 +1623,10 @@ static struct pci_driver driver = { .id_table = azx_ids, .probe = azx_probe, .remove = __devexit_p(azx_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = azx_suspend, + .resume = azx_resume, +#endif }; static int __init alsa_card_azx_init(void) -- cgit v1.1 From 3fcf7d2cd8e0ebce10e4bf89da175ff9bd6aa2da Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:11:24 +0100 Subject: [ALSA] nm256-intel - Fix PM support Modules: NM256 driver Fix PM support on NM256 driver. Signed-off-by: Takashi Iwai --- sound/pci/nm256/nm256.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 99ec1c1..0d0ff54 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1308,24 +1308,29 @@ snd_nm256_peek_for_sig(struct nm256 *chip) * APM event handler, so the card is properly reinitialized after a power * event. */ -static int nm256_suspend(struct snd_card *card, pm_message_t state) +static int nm256_suspend(struct pci_dev *pci, pm_message_t state) { - struct nm256 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct nm256 *chip = card->private_data; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); snd_ac97_suspend(chip->ac97); chip->coeffs_current = 0; - pci_disable_device(chip->pci); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int nm256_resume(struct snd_card *card) +static int nm256_resume(struct pci_dev *pci) { - struct nm256 *chip = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct nm256 *chip = card->private_data; int i; /* Perform a full reset on the hardware */ - pci_enable_device(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); snd_nm256_init_chip(chip); /* restore ac97 */ @@ -1340,6 +1345,7 @@ static int nm256_resume(struct snd_card *card) } } + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1524,8 +1530,6 @@ snd_nm256_create(struct snd_card *card, struct pci_dev *pci, // pci_set_master(pci); /* needed? */ - snd_card_set_pm_callback(card, nm256_suspend, nm256_resume, chip); - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) goto __error; @@ -1625,6 +1629,7 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = chip; if (reset_workaround) { snd_printdd(KERN_INFO "nm256: reset_workaround activated\n"); @@ -1668,7 +1673,10 @@ static struct pci_driver driver = { .id_table = snd_nm256_ids, .probe = snd_nm256_probe, .remove = __devexit_p(snd_nm256_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = nm256_suspend, + .resume = nm256_resume, +#endif }; -- cgit v1.1 From 11d3824ad7d6240d7ce44bdf1d9e81e62a903f72 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:13:05 +0100 Subject: [ALSA] ak4531 - Add PM support Modules: AK4531 codec Add PM support to AK4531 codec driver. Signed-off-by: Takashi Iwai --- include/sound/ak4531_codec.h | 5 +++++ sound/pci/ac97/ak4531_codec.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/include/sound/ak4531_codec.h b/include/sound/ak4531_codec.h index 4e7c661..edf0407 100644 --- a/include/sound/ak4531_codec.h +++ b/include/sound/ak4531_codec.h @@ -77,4 +77,9 @@ struct snd_ak4531 { int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531, struct snd_ak4531 **rak4531); +#ifdef CONFIG_PM +void snd_ak4531_suspend(struct snd_ak4531 *ak4531); +void snd_ak4531_resume(struct snd_ak4531 *ak4531); +#endif + #endif /* __SOUND_AK4531_CODEC_H */ diff --git a/sound/pci/ac97/ak4531_codec.c b/sound/pci/ac97/ak4531_codec.c index 088d8dc..3eb8855 100644 --- a/sound/pci/ac97/ak4531_codec.c +++ b/sound/pci/ac97/ak4531_codec.c @@ -371,7 +371,7 @@ int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531, ak4531->write(ak4531, AK4531_RESET, 0x03); /* no RST, PD */ udelay(100); ak4531->write(ak4531, AK4531_CLOCK, 0x00); /* CODEC ADC and CODEC DAC use {LR,B}CLK2 and run off LRCLK2 PLL */ - for (idx = 0; idx < 0x19; idx++) { + for (idx = 0; idx <= 0x19; idx++) { if (idx == AK4531_RESET || idx == AK4531_CLOCK) continue; ak4531->write(ak4531, idx, ak4531->regs[idx] = snd_ak4531_initial_map[idx]); /* recording source is mixer */ @@ -396,6 +396,36 @@ int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531, } /* + * power management + */ +#ifdef CONFIG_PM +void snd_ak4531_suspend(struct snd_ak4531 *ak4531) +{ + /* mute */ + ak4531->write(ak4531, AK4531_LMASTER, 0x9f); + ak4531->write(ak4531, AK4531_RMASTER, 0x9f); + /* powerdown */ + ak4531->write(ak4531, AK4531_RESET, 0x01); +} + +void snd_ak4531_resume(struct snd_ak4531 *ak4531) +{ + int idx; + + /* initialize */ + ak4531->write(ak4531, AK4531_RESET, 0x03); + udelay(100); + ak4531->write(ak4531, AK4531_CLOCK, 0x00); + /* restore mixer registers */ + for (idx = 0; idx <= 0x19; idx++) { + if (idx == AK4531_RESET || idx == AK4531_CLOCK) + continue; + ak4531->write(ak4531, idx, ak4531->regs[idx]); + } +} +#endif + +/* */ @@ -420,6 +450,10 @@ static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak453 } EXPORT_SYMBOL(snd_ak4531_mixer); +#ifdef CONFIG_PM +EXPORT_SYMBOL(snd_ak4531_suspend); +EXPORT_SYMBOL(snd_ak4531_resume); +#endif /* * INIT part -- cgit v1.1 From fe8be10786c040bce53c18048d75b1b23aec64ae Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:13:41 +0100 Subject: [ALSA] ens137x - Fix and ADD PM support Modules: ENS1370/1+ driver Fix PM support on ens1371 driver. Add PM support on ens1370 (together with AK4531), too. Signed-off-by: Takashi Iwai --- sound/pci/ens1370.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 2cc0f83..ff86fab 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -2034,40 +2034,45 @@ static void snd_ensoniq_chip_init(struct ensoniq *ensoniq) } #ifdef CONFIG_PM -static int snd_ensoniq_suspend(struct snd_card *card, pm_message_t state) +static int snd_ensoniq_suspend(struct pci_dev *pci, pm_message_t state) { - struct ensoniq *ensoniq = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct ensoniq *ensoniq = card->private_data; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(ensoniq->pcm1); snd_pcm_suspend_all(ensoniq->pcm2); #ifdef CHIP1371 - if (ensoniq->u.es1371.ac97) - snd_ac97_suspend(ensoniq->u.es1371.ac97); + snd_ac97_suspend(ensoniq->u.es1371.ac97); #else - /* FIXME */ + snd_ak4531_suspend(ensoniq->u.es1370.ak4531); #endif - pci_set_power_state(ensoniq->pci, 3); - pci_disable_device(ensoniq->pci); + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); return 0; } -static int snd_ensoniq_resume(struct snd_card *card) +static int snd_ensoniq_resume(struct pci_dev *pci) { - struct ensoniq *ensoniq = card->pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct ensoniq *ensoniq = card->private_data; - pci_enable_device(ensoniq->pci); - pci_set_power_state(ensoniq->pci, 0); - pci_set_master(ensoniq->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); snd_ensoniq_chip_init(ensoniq); #ifdef CHIP1371 - if (ensoniq->u.es1371.ac97) - snd_ac97_resume(ensoniq->u.es1371.ac97); + snd_ac97_resume(ensoniq->u.es1371.ac97); #else - /* FIXME */ + snd_ak4531_resume(ensoniq->u.es1370.ak4531); #endif + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -2165,8 +2170,6 @@ static int __devinit snd_ensoniq_create(struct snd_card *card, snd_ensoniq_proc_init(ensoniq); - snd_card_set_pm_callback(card, snd_ensoniq_suspend, snd_ensoniq_resume, ensoniq); - snd_card_set_dev(card, &pci->dev); *rensoniq = ensoniq; @@ -2436,6 +2439,7 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = ensoniq; pcm_devs[0] = 0; pcm_devs[1] = 1; #ifdef CHIP1370 @@ -2495,7 +2499,10 @@ static struct pci_driver driver = { .id_table = snd_audiopci_ids, .probe = snd_audiopci_probe, .remove = __devexit_p(snd_audiopci_remove), - SND_PCI_PM_CALLBACKS +#ifdef CONFIG_PM + .suspend = snd_ensoniq_suspend, + .resume = snd_ensoniq_resume, +#endif }; static int __init alsa_card_ens137x_init(void) -- cgit v1.1 From 09668b441dacdf4640509b640ad73e24efd5204f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:14:10 +0100 Subject: [ALSA] emu10k1 - Add PM support Modules: EMU10K1/EMU10K2 driver Add PM support to emu10k1 driver. Signed-off-by: Takashi Iwai --- include/sound/emu10k1.h | 31 +++- sound/pci/emu10k1/emu10k1.c | 144 +++++++++++------- sound/pci/emu10k1/emu10k1_main.c | 308 +++++++++++++++++++++++++-------------- sound/pci/emu10k1/emufx.c | 121 ++++++++++++++- sound/pci/emu10k1/emupcm.c | 14 +- sound/pci/emu10k1/p16v.c | 43 +++++- 6 files changed, 491 insertions(+), 170 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index d14c543..3d0496c 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1071,7 +1071,8 @@ struct snd_emu10k1 { unsigned long port; /* I/O port number */ unsigned int tos_link: 1, /* tos link detected */ - rear_ac97: 1; /* rear channels are on AC'97 */ + rear_ac97: 1, /* rear channels are on AC'97 */ + enable_ir: 1; /* Contains profile of card capabilities */ const struct snd_emu_chip_details *card_capabilities; unsigned int audigy; /* is Audigy? */ @@ -1108,6 +1109,7 @@ struct snd_emu10k1 { struct snd_pcm *pcm; struct snd_pcm *pcm_mic; struct snd_pcm *pcm_efx; + struct snd_pcm *pcm_multi; struct snd_pcm *pcm_p16v; spinlock_t synth_lock; @@ -1153,6 +1155,17 @@ struct snd_emu10k1 { unsigned int efx_voices_mask[2]; unsigned int next_free_voice; + +#ifdef CONFIG_PM + unsigned int *saved_ptr; + unsigned int *saved_gpr; + unsigned int *tram_val_saved; + unsigned int *tram_addr_saved; + unsigned int *saved_icode; + unsigned int *p16v_saved; + unsigned int saved_a_iocfg, saved_hcfg; +#endif + }; int snd_emu10k1_create(struct snd_card *card, @@ -1178,11 +1191,11 @@ int snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct snd_hwdep irqreturn_t snd_emu10k1_interrupt(int irq, void *dev_id, struct pt_regs *regs); -/* initialization */ void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int voice); int snd_emu10k1_init_efx(struct snd_emu10k1 *emu); void snd_emu10k1_free_efx(struct snd_emu10k1 *emu); int snd_emu10k1_fx8010_tram_setup(struct snd_emu10k1 *emu, u32 size); +int snd_emu10k1_done(struct snd_emu10k1 * emu); /* I/O functions */ unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn); @@ -1206,6 +1219,20 @@ unsigned short snd_emu10k1_ac97_read(struct snd_ac97 *ac97, unsigned short reg); void snd_emu10k1_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short data); unsigned int snd_emu10k1_rate_to_pitch(unsigned int rate); +#ifdef CONFIG_PM +void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu); +void snd_emu10k1_resume_init(struct snd_emu10k1 *emu); +void snd_emu10k1_resume_regs(struct snd_emu10k1 *emu); +int snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu); +void snd_emu10k1_efx_free_pm_buffer(struct snd_emu10k1 *emu); +void snd_emu10k1_efx_suspend(struct snd_emu10k1 *emu); +void snd_emu10k1_efx_resume(struct snd_emu10k1 *emu); +int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu); +void snd_p16v_free_pm_buffer(struct snd_emu10k1 *emu); +void snd_p16v_suspend(struct snd_emu10k1 *emu); +void snd_p16v_resume(struct snd_emu10k1 *emu); +#endif + /* memory allocation */ struct snd_util_memblk *snd_emu10k1_alloc_pages(struct snd_emu10k1 *emu, struct snd_pcm_substream *substream); int snd_emu10k1_free_pages(struct snd_emu10k1 *emu, struct snd_util_memblk *blk); diff --git a/sound/pci/emu10k1/emu10k1.c b/sound/pci/emu10k1/emu10k1.c index 9be9002..2dfa932 100644 --- a/sound/pci/emu10k1/emu10k1.c +++ b/sound/pci/emu10k1/emu10k1.c @@ -125,65 +125,43 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci, if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev], (long)max_buffer_size[dev] * 1024 * 1024, enable_ir[dev], subsystem[dev], - &emu)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) { - snd_card_free(card); - return err; - } + &emu)) < 0) + goto error; + card->private_data = emu; + if ((err = snd_emu10k1_pcm(emu, 0, NULL)) < 0) + goto error; + if ((err = snd_emu10k1_pcm_mic(emu, 1, NULL)) < 0) + goto error; + if ((err = snd_emu10k1_pcm_efx(emu, 2, NULL)) < 0) + goto error; /* This stores the periods table. */ if (emu->card_capabilities->ca0151_chip) { /* P16V */ - if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &emu->p16v_buffer) < 0) { - snd_p16v_free(emu); - return -ENOMEM; - } + if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), + 1024, &emu->p16v_buffer)) < 0) + goto error; } - if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_emu10k1_mixer(emu, 0, 3)) < 0) + goto error; - if ((err = snd_emu10k1_timer(emu, 0)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_emu10k1_timer(emu, 0)) < 0) + goto error; - if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0) { - snd_card_free(card); - return err; - } - if (emu->card_capabilities->ca0151_chip) { /* P16V */ - if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_emu10k1_pcm_multi(emu, 3, NULL)) < 0) + goto error; + if (emu->card_capabilities->ca0151_chip) { /* P16V */ + if ((err = snd_p16v_pcm(emu, 4, NULL)) < 0) + goto error; } if (emu->audigy) { - if ((err = snd_emu10k1_audigy_midi(emu)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_emu10k1_audigy_midi(emu)) < 0) + goto error; } else { - if ((err = snd_emu10k1_midi(emu)) < 0) { - snd_card_free(card); - return err; - } - } - if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) { - snd_card_free(card); - return err; + if ((err = snd_emu10k1_midi(emu)) < 0) + goto error; } + if ((err = snd_emu10k1_fx8010_new(emu, 0, NULL)) < 0) + goto error; #ifdef ENABLE_SYNTH if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, sizeof(struct snd_emu10k1_synth_arg), &wave) < 0 || @@ -206,13 +184,16 @@ static int __devinit snd_card_emu10k1_probe(struct pci_dev *pci, "%s (rev.%d, serial:0x%x) at 0x%lx, irq %i", card->shortname, emu->revision, emu->serial, emu->port, emu->irq); - if ((err = snd_card_register(card)) < 0) { - snd_card_free(card); - return err; - } + if ((err = snd_card_register(card)) < 0) + goto error; + pci_set_drvdata(pci, card); dev++; return 0; + + error: + snd_card_free(card); + return err; } static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci) @@ -221,11 +202,68 @@ static void __devexit snd_card_emu10k1_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } + +#ifdef CONFIG_PM +static int snd_emu10k1_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_emu10k1 *emu = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + + snd_pcm_suspend_all(emu->pcm); + snd_pcm_suspend_all(emu->pcm_mic); + snd_pcm_suspend_all(emu->pcm_efx); + snd_pcm_suspend_all(emu->pcm_multi); + snd_pcm_suspend_all(emu->pcm_p16v); + + snd_ac97_suspend(emu->ac97); + + snd_emu10k1_efx_suspend(emu); + snd_emu10k1_suspend_regs(emu); + if (emu->card_capabilities->ca0151_chip) + snd_p16v_suspend(emu); + + snd_emu10k1_done(emu); + + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return 0; +} + +int snd_emu10k1_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_emu10k1 *emu = card->private_data; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + + snd_emu10k1_resume_init(emu); + snd_emu10k1_efx_resume(emu); + snd_ac97_resume(emu->ac97); + snd_emu10k1_resume_regs(emu); + + if (emu->card_capabilities->ca0151_chip) + snd_p16v_resume(emu); + + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + static struct pci_driver driver = { .name = "EMU10K1_Audigy", .id_table = snd_emu10k1_ids, .probe = snd_card_emu10k1_probe, .remove = __devexit_p(snd_card_emu10k1_remove), +#ifdef CONFIG_PM + .suspend = snd_emu10k1_suspend, + .resume = snd_emu10k1_resume, +#endif }; static int __init alsa_card_emu10k1_init(void) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index f985507..cc36b74 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -42,12 +42,6 @@ #include "p16v.h" #include "tina2.h" -#if 0 -MODULE_AUTHOR("Jaroslav Kysela , Creative Labs, Inc."); -MODULE_DESCRIPTION("Routines for control of EMU10K1 chips"); -MODULE_LICENSE("GPL"); -#endif - /************************************************************************* * EMU10K1 init / done *************************************************************************/ @@ -97,17 +91,14 @@ void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int ch) } } -static int __devinit snd_emu10k1_init(struct snd_emu10k1 * emu, int enable_ir) +static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) { - int ch, idx, err; unsigned int silent_page; - - emu->fx8010.itram_size = (16 * 1024)/2; - emu->fx8010.etram_pages.area = NULL; - emu->fx8010.etram_pages.bytes = 0; + int ch; /* disable audio and lock cache */ - outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG); + outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, + emu->port + HCFG); /* reset recording buffers */ snd_emu10k1_ptr_write(emu, MICBS, 0, ADCBS_BUFSIZE_NONE); @@ -128,48 +119,17 @@ static int __devinit snd_emu10k1_init(struct snd_emu10k1 * emu, int enable_ir) /* set SPDIF bypass mode */ snd_emu10k1_ptr_write(emu, SPBYPASS, 0, SPBYPASS_FORMAT); /* enable rear left + rear right AC97 slots */ - snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_REAR_RIGHT | AC97SLOT_REAR_LEFT); + snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_REAR_RIGHT | + AC97SLOT_REAR_LEFT); } /* init envelope engine */ - for (ch = 0; ch < NUM_G; ch++) { - emu->voices[ch].emu = emu; - emu->voices[ch].number = ch; + for (ch = 0; ch < NUM_G; ch++) snd_emu10k1_voice_init(emu, ch); - } - /* - * Init to 0x02109204 : - * Clock accuracy = 0 (1000ppm) - * Sample Rate = 2 (48kHz) - * Audio Channel = 1 (Left of 2) - * Source Number = 0 (Unspecified) - * Generation Status = 1 (Original for Cat Code 12) - * Cat Code = 12 (Digital Signal Mixer) - * Mode = 0 (Mode 0) - * Emphasis = 0 (None) - * CP = 1 (Copyright unasserted) - * AN = 0 (Audio data) - * P = 0 (Consumer) - */ - snd_emu10k1_ptr_write(emu, SPCS0, 0, - emu->spdif_bits[0] = - SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | - SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | - SPCS_GENERATIONSTATUS | 0x00001200 | - 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); - snd_emu10k1_ptr_write(emu, SPCS1, 0, - emu->spdif_bits[1] = - SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | - SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | - SPCS_GENERATIONSTATUS | 0x00001200 | - 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); - snd_emu10k1_ptr_write(emu, SPCS2, 0, - emu->spdif_bits[2] = - SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | - SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | - SPCS_GENERATIONSTATUS | 0x00001200 | - 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); + snd_emu10k1_ptr_write(emu, SPCS0, 0, emu->spdif_bits[0]); + snd_emu10k1_ptr_write(emu, SPCS1, 0, emu->spdif_bits[1]); + snd_emu10k1_ptr_write(emu, SPCS2, 0, emu->spdif_bits[2]); if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ /* Hacks for Alice3 to work independent of haP16V driver */ @@ -196,7 +156,7 @@ static int __devinit snd_emu10k1_init(struct snd_emu10k1 * emu, int enable_ir) /* Hacks for Alice3 to work independent of haP16V driver */ u32 tmp; - snd_printk(KERN_ERR "Audigy2 value:Special config.\n"); + snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); //Setup SRCMulti_I2S SamplingRate tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); tmp &= 0xfffff1ff; @@ -221,14 +181,6 @@ static int __devinit snd_emu10k1_init(struct snd_emu10k1 * emu, int enable_ir) outl(tmp, emu->port + A_IOCFG); } - - /* - * Clear page with silence & setup all pointers to this page - */ - memset(emu->silent_page.area, 0, PAGE_SIZE); - silent_page = emu->silent_page.addr << 1; - for (idx = 0; idx < MAXPAGES; idx++) - ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx); snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */ snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */ @@ -287,12 +239,11 @@ static int __devinit snd_emu10k1_init(struct snd_emu10k1 * emu, int enable_ir) outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG); } - /* - * Initialize the effect engine - */ - if ((err = snd_emu10k1_init_efx(emu)) < 0) - return err; + return 0; +} +static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu) +{ /* * Enable the audio bit */ @@ -335,15 +286,9 @@ static int __devinit snd_emu10k1_init(struct snd_emu10k1 * emu, int enable_ir) #endif snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE); - - emu->reserved_page = (struct snd_emu10k1_memblk *)snd_emu10k1_synth_alloc(emu, 4096); - if (emu->reserved_page) - emu->reserved_page->map_locked = 1; - - return 0; } -static int snd_emu10k1_done(struct snd_emu10k1 * emu) +int snd_emu10k1_done(struct snd_emu10k1 * emu) { int ch; @@ -382,18 +327,10 @@ static int snd_emu10k1_done(struct snd_emu10k1 * emu) snd_emu10k1_ptr_write(emu, SOLEL, 0, 0); snd_emu10k1_ptr_write(emu, SOLEH, 0, 0); - /* remove reserved page */ - if (emu->reserved_page != NULL) { - snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page); - emu->reserved_page = NULL; - } - /* disable audio and lock cache */ outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, emu->port + HCFG); snd_emu10k1_ptr_write(emu, PTB, 0, 0); - snd_emu10k1_free_efx(emu); - return 0; } @@ -609,11 +546,22 @@ static int __devinit snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) * Create the EMU10K1 instance */ +#ifdef CONFIG_PM +static int alloc_pm_buffer(struct snd_emu10k1 *emu); +static void free_pm_buffer(struct snd_emu10k1 *emu); +#endif + static int snd_emu10k1_free(struct snd_emu10k1 *emu) { if (emu->port) { /* avoid access to already used hardware */ snd_emu10k1_fx8010_tram_setup(emu, 0); snd_emu10k1_done(emu); + /* remove reserved page */ + if (emu->reserved_page) { + snd_emu10k1_synth_free(emu, (struct snd_util_memblk *)emu->reserved_page); + emu->reserved_page = NULL; + } + snd_emu10k1_free_efx(emu); } if (emu->memhdr) snd_util_memhdr_free(emu->memhdr); @@ -623,13 +571,16 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu) snd_dma_free_pages(&emu->ptb_pages); vfree(emu->page_ptr_table); vfree(emu->page_addr_table); +#ifdef CONFIG_PM + free_pm_buffer(emu); +#endif if (emu->irq >= 0) free_irq(emu->irq, (void *)emu); if (emu->port) pci_release_regions(emu->pci); - pci_disable_device(emu->pci); if (emu->card_capabilities->ca0151_chip) /* P16V */ snd_p16v_free(emu); + pci_disable_device(emu->pci); kfree(emu); return 0; } @@ -900,9 +851,10 @@ int __devinit snd_emu10k1_create(struct snd_card *card, struct snd_emu10k1 ** remu) { struct snd_emu10k1 *emu; - int err; + int idx, err; int is_audigy; unsigned char revision; + unsigned int silent_page; const struct snd_emu_chip_details *c; static struct snd_device_ops ops = { .dev_free = snd_emu10k1_dev_free, @@ -1012,34 +964,34 @@ int __devinit snd_emu10k1_create(struct snd_card *card, emu->port = pci_resource_start(pci, 0); if (request_irq(pci->irq, snd_emu10k1_interrupt, SA_INTERRUPT|SA_SHIRQ, "EMU10K1", (void *)emu)) { - snd_emu10k1_free(emu); - return -EBUSY; + err = -EBUSY; + goto error; } emu->irq = pci->irq; emu->max_cache_pages = max_cache_bytes >> PAGE_SHIFT; if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 32 * 1024, &emu->ptb_pages) < 0) { - snd_emu10k1_free(emu); - return -ENOMEM; + err = -ENOMEM; + goto error; } emu->page_ptr_table = (void **)vmalloc(emu->max_cache_pages * sizeof(void*)); emu->page_addr_table = (unsigned long*)vmalloc(emu->max_cache_pages * sizeof(unsigned long)); if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { - snd_emu10k1_free(emu); - return -ENOMEM; + err = -ENOMEM; + goto error; } if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), EMUPAGESIZE, &emu->silent_page) < 0) { - snd_emu10k1_free(emu); - return -ENOMEM; + err = -ENOMEM; + goto error; } emu->memhdr = snd_util_memhdr_new(emu->max_cache_pages * PAGE_SIZE); if (emu->memhdr == NULL) { - snd_emu10k1_free(emu); - return -ENOMEM; + err = -ENOMEM; + goto error; } emu->memhdr->block_extra_size = sizeof(struct snd_emu10k1_memblk) - sizeof(struct snd_util_memblk); @@ -1053,40 +1005,184 @@ int __devinit snd_emu10k1_create(struct snd_card *card, extout_mask = 0x7fff; emu->fx8010.extin_mask = extin_mask; emu->fx8010.extout_mask = extout_mask; + emu->enable_ir = enable_ir; if (emu->card_capabilities->ecard) { - if ((err = snd_emu10k1_ecard_init(emu)) < 0) { - snd_emu10k1_free(emu); - return err; - } + if ((err = snd_emu10k1_ecard_init(emu)) < 0) + goto error; } else if (emu->card_capabilities->ca_cardbus_chip) { - if ((err = snd_emu10k1_cardbus_init(emu)) < 0) { - snd_emu10k1_free(emu); - return err; - } + if ((err = snd_emu10k1_cardbus_init(emu)) < 0) + goto error; } else { /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version does not support this, it shouldn't do any harm */ snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); } - if ((err = snd_emu10k1_init(emu, enable_ir)) < 0) { - snd_emu10k1_free(emu); - return err; - } + /* initialize TRAM setup */ + emu->fx8010.itram_size = (16 * 1024)/2; + emu->fx8010.etram_pages.area = NULL; + emu->fx8010.etram_pages.bytes = 0; - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) { - snd_emu10k1_free(emu); - return err; + /* + * Init to 0x02109204 : + * Clock accuracy = 0 (1000ppm) + * Sample Rate = 2 (48kHz) + * Audio Channel = 1 (Left of 2) + * Source Number = 0 (Unspecified) + * Generation Status = 1 (Original for Cat Code 12) + * Cat Code = 12 (Digital Signal Mixer) + * Mode = 0 (Mode 0) + * Emphasis = 0 (None) + * CP = 1 (Copyright unasserted) + * AN = 0 (Audio data) + * P = 0 (Consumer) + */ + emu->spdif_bits[0] = emu->spdif_bits[1] = + emu->spdif_bits[2] = SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | + SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | + SPCS_GENERATIONSTATUS | 0x00001200 | + 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT; + + emu->reserved_page = (struct snd_emu10k1_memblk *) + snd_emu10k1_synth_alloc(emu, 4096); + if (emu->reserved_page) + emu->reserved_page->map_locked = 1; + + /* Clear silent pages and set up pointers */ + memset(emu->silent_page.area, 0, PAGE_SIZE); + silent_page = emu->silent_page.addr << 1; + for (idx = 0; idx < MAXPAGES; idx++) + ((u32 *)emu->ptb_pages.area)[idx] = cpu_to_le32(silent_page | idx); + + /* set up voice indices */ + for (idx = 0; idx < NUM_G; idx++) { + emu->voices[idx].emu = emu; + emu->voices[idx].number = idx; } + if ((err = snd_emu10k1_init(emu, enable_ir, 0)) < 0) + goto error; +#ifdef CONFIG_PM + if ((err = alloc_pm_buffer(emu)) < 0) + goto error; +#endif + + /* Initialize the effect engine */ + if ((err = snd_emu10k1_init_efx(emu)) < 0) + goto error; + snd_emu10k1_audio_enable(emu); + + if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) + goto error; + snd_emu10k1_proc_init(emu); snd_card_set_dev(card, &pci->dev); *remu = emu; return 0; + + error: + snd_emu10k1_free(emu); + return err; } +#ifdef CONFIG_PM +static unsigned char saved_regs[] = { + CPF, PTRX, CVCF, VTFT, Z1, Z2, PSST, DSL, CCCA, CCR, CLP, + FXRT, MAPA, MAPB, ENVVOL, ATKHLDV, DCYSUSV, LFOVAL1, ENVVAL, + ATKHLDM, DCYSUSM, LFOVAL2, IP, IFATN, PEFE, FMMOD, TREMFRQ, FM2FRQ2, + TEMPENV, ADCCR, FXWC, MICBA, ADCBA, FXBA, + MICBS, ADCBS, FXBS, CDCS, GPSCS, SPCS0, SPCS1, SPCS2, + SPBYPASS, AC97SLOT, CDSRCS, GPSRCS, ZVSRCS, MICIDX, ADCIDX, FXIDX, + 0xff /* end */ +}; +static unsigned char saved_regs_audigy[] = { + A_ADCIDX, A_MICIDX, A_FXWC1, A_FXWC2, A_SAMPLE_RATE, + A_FXRT2, A_SENDAMOUNTS, A_FXRT1, + 0xff /* end */ +}; + +static int __devinit alloc_pm_buffer(struct snd_emu10k1 *emu) +{ + int size; + + size = ARRAY_SIZE(saved_regs); + if (emu->audigy) + size += ARRAY_SIZE(saved_regs_audigy); + emu->saved_ptr = vmalloc(4 * NUM_G * size); + if (! emu->saved_ptr) + return -ENOMEM; + if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) + return -ENOMEM; + if (emu->card_capabilities->ca0151_chip && + snd_p16v_alloc_pm_buffer(emu) < 0) + return -ENOMEM; + return 0; +} + +static void free_pm_buffer(struct snd_emu10k1 *emu) +{ + vfree(emu->saved_ptr); + snd_emu10k1_efx_free_pm_buffer(emu); + if (emu->card_capabilities->ca0151_chip) + snd_p16v_free_pm_buffer(emu); +} + +void snd_emu10k1_suspend_regs(struct snd_emu10k1 *emu) +{ + int i; + unsigned char *reg; + unsigned int *val; + + val = emu->saved_ptr; + for (reg = saved_regs; *reg != 0xff; reg++) + for (i = 0; i < NUM_G; i++, val++) + *val = snd_emu10k1_ptr_read(emu, *reg, i); + if (emu->audigy) { + for (reg = saved_regs_audigy; *reg != 0xff; reg++) + for (i = 0; i < NUM_G; i++, val++) + *val = snd_emu10k1_ptr_read(emu, *reg, i); + } + if (emu->audigy) + emu->saved_a_iocfg = inl(emu->port + A_IOCFG); + emu->saved_hcfg = inl(emu->port + HCFG); +} + +void snd_emu10k1_resume_init(struct snd_emu10k1 *emu) +{ + if (emu->card_capabilities->ecard) + snd_emu10k1_ecard_init(emu); + else + snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); + snd_emu10k1_init(emu, emu->enable_ir, 1); +} + +void snd_emu10k1_resume_regs(struct snd_emu10k1 *emu) +{ + int i; + unsigned char *reg; + unsigned int *val; + + snd_emu10k1_audio_enable(emu); + + /* resore for spdif */ + if (emu->audigy) + outl(emu->port + A_IOCFG, emu->saved_a_iocfg); + outl(emu->port + HCFG, emu->saved_hcfg); + + val = emu->saved_ptr; + for (reg = saved_regs; *reg != 0xff; reg++) + for (i = 0; i < NUM_G; i++, val++) + snd_emu10k1_ptr_write(emu, *reg, i, *val); + if (emu->audigy) { + for (reg = saved_regs_audigy; *reg != 0xff; reg++) + for (i = 0; i < NUM_G; i++, val++) + snd_emu10k1_ptr_write(emu, *reg, i, *val); + } +} +#endif + /* memory.c */ EXPORT_SYMBOL(snd_emu10k1_synth_alloc); EXPORT_SYMBOL(snd_emu10k1_synth_free); diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index f4452c5..a44e4fd 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -1071,9 +1071,6 @@ static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) u32 *gpr_map; mm_segment_t seg; - spin_lock_init(&emu->fx8010.irq_lock); - INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); - if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || (icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), @@ -1541,9 +1538,6 @@ static int __devinit _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) u32 *gpr_map; mm_segment_t seg; - spin_lock_init(&emu->fx8010.irq_lock); - INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); - if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) return -ENOMEM; if ((icode->gpr_map = (u_int32_t __user *) @@ -2102,6 +2096,8 @@ static int __devinit _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) int __devinit snd_emu10k1_init_efx(struct snd_emu10k1 *emu) { + spin_lock_init(&emu->fx8010.irq_lock); + INIT_LIST_HEAD(&emu->fx8010.gpr_ctl); if (emu->audigy) return _snd_emu10k1_audigy_init_efx(emu); else @@ -2171,7 +2167,7 @@ int snd_emu10k1_fx8010_tram_setup(struct snd_emu10k1 *emu, u32 size) snd_emu10k1_ptr_write(emu, TCBS, 0, size_reg); spin_lock_irq(&emu->emu_lock); outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); - spin_unlock_irq(&emu->emu_lock); + spin_unlock_irq(&emu->emu_lock); } return 0; @@ -2387,3 +2383,114 @@ int __devinit snd_emu10k1_fx8010_new(struct snd_emu10k1 *emu, int device, struct *rhwdep = hw; return 0; } + +#ifdef CONFIG_PM +int __devinit snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu) +{ + int len; + + len = emu->audigy ? 0x200 : 0x100; + emu->saved_gpr = kmalloc(len * 4, GFP_KERNEL); + if (! emu->saved_gpr) + return -ENOMEM; + len = emu->audigy ? 0x100 : 0xa0; + emu->tram_val_saved = kmalloc(len * 4, GFP_KERNEL); + emu->tram_addr_saved = kmalloc(len * 4, GFP_KERNEL); + if (! emu->tram_val_saved || ! emu->tram_addr_saved) + return -ENOMEM; + len = emu->audigy ? 2 * 1024 : 2 * 512; + emu->saved_icode = vmalloc(len * 4); + if (! emu->saved_icode) + return -ENOMEM; + return 0; +} + +void snd_emu10k1_efx_free_pm_buffer(struct snd_emu10k1 *emu) +{ + kfree(emu->saved_gpr); + kfree(emu->tram_val_saved); + kfree(emu->tram_addr_saved); + vfree(emu->saved_icode); +} + +/* + * save/restore GPR, TRAM and codes + */ +void snd_emu10k1_efx_suspend(struct snd_emu10k1 *emu) +{ + int i, len; + + len = emu->audigy ? 0x200 : 0x100; + for (i = 0; i < len; i++) + emu->saved_gpr[i] = snd_emu10k1_ptr_read(emu, emu->gpr_base + i, 0); + + len = emu->audigy ? 0x100 : 0xa0; + for (i = 0; i < len; i++) { + emu->tram_val_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMDATAREGBASE + i, 0); + emu->tram_addr_saved[i] = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + i, 0); + if (emu->audigy) { + emu->tram_addr_saved[i] >>= 12; + emu->tram_addr_saved[i] |= + snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + i, 0) << 20; + } + } + + len = emu->audigy ? 2 * 1024 : 2 * 512; + for (i = 0; i < len; i++) + emu->saved_icode[i] = snd_emu10k1_efx_read(emu, i); +} + +void snd_emu10k1_efx_resume(struct snd_emu10k1 *emu) +{ + int i, len; + + /* set up TRAM */ + if (emu->fx8010.etram_pages.bytes > 0) { + unsigned size, size_reg = 0; + size = emu->fx8010.etram_pages.bytes / 2; + size = (size - 1) >> 13; + while (size) { + size >>= 1; + size_reg++; + } + outl(HCFG_LOCKTANKCACHE_MASK | inl(emu->port + HCFG), emu->port + HCFG); + snd_emu10k1_ptr_write(emu, TCB, 0, emu->fx8010.etram_pages.addr); + snd_emu10k1_ptr_write(emu, TCBS, 0, size_reg); + outl(inl(emu->port + HCFG) & ~HCFG_LOCKTANKCACHE_MASK, emu->port + HCFG); + } + + if (emu->audigy) + snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg | A_DBG_SINGLE_STEP); + else + snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg | EMU10K1_DBG_SINGLE_STEP); + + len = emu->audigy ? 0x200 : 0x100; + for (i = 0; i < len; i++) + snd_emu10k1_ptr_write(emu, emu->gpr_base + i, 0, emu->saved_gpr[i]); + + len = emu->audigy ? 0x100 : 0xa0; + for (i = 0; i < len; i++) { + snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + i, 0, + emu->tram_val_saved[i]); + if (! emu->audigy) + snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, + emu->tram_addr_saved[i]); + else { + snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, + emu->tram_addr_saved[i] << 12); + snd_emu10k1_ptr_write(emu, TANKMEMADDRREGBASE + i, 0, + emu->tram_addr_saved[i] >> 20); + } + } + + len = emu->audigy ? 2 * 1024 : 2 * 512; + for (i = 0; i < len; i++) + snd_emu10k1_efx_write(emu, i, emu->saved_icode[i]); + + /* start FX processor when the DSP code is updated */ + if (emu->audigy) + snd_emu10k1_ptr_write(emu, A_DBG, 0, emu->fx8010.dbg); + else + snd_emu10k1_ptr_write(emu, DBG, 0, emu->fx8010.dbg); +} +#endif diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 8e6caf5..717e92e 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -551,6 +551,7 @@ static struct snd_pcm_hardware snd_emu10k1_efx_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_NONINTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, @@ -739,6 +740,7 @@ static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream, snd_emu10k1_playback_invalidate_cache(emu, 0, epcm->voices[0]); /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: mix = &emu->pcm_mixer[substream->number]; snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 1, 0, mix); snd_emu10k1_playback_prepare_voice(emu, epcm->voices[1], 0, 0, mix); @@ -750,6 +752,7 @@ static int snd_emu10k1_playback_trigger(struct snd_pcm_substream *substream, break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: epcm->running = 0; snd_emu10k1_playback_stop_voice(emu, epcm->voices[0]); snd_emu10k1_playback_stop_voice(emu, epcm->voices[1]); @@ -774,6 +777,7 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream, spin_lock(&emu->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: // hmm this should cause full and half full interrupt to be raised? outl(epcm->capture_ipr, emu->port + IPR); snd_emu10k1_intr_enable(emu, epcm->capture_inte); @@ -797,6 +801,7 @@ static int snd_emu10k1_capture_trigger(struct snd_pcm_substream *substream, epcm->first_ptr = 1; break; case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: epcm->running = 0; snd_emu10k1_intr_disable(emu, epcm->capture_inte); outl(epcm->capture_ipr, emu->port + IPR); @@ -871,6 +876,7 @@ static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream *substream, /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: snd_emu10k1_playback_prepare_voice(emu, epcm->extra, 1, 1, NULL); snd_emu10k1_playback_prepare_voice(emu, epcm->voices[0], 0, 0, &emu->efx_pcm_mixer[0]); @@ -883,6 +889,7 @@ static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream *substream, snd_emu10k1_playback_trigger_voice(emu, epcm->voices[i], 0, 0); epcm->running = 1; break; + case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: epcm->running = 0; @@ -925,6 +932,7 @@ static struct snd_pcm_hardware snd_emu10k1_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_96000, @@ -948,6 +956,7 @@ static struct snd_pcm_hardware snd_emu10k1_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_8000_48000, @@ -1309,7 +1318,7 @@ int __devinit snd_emu10k1_pcm_multi(struct snd_emu10k1 * emu, int device, struct pcm->info_flags = 0; pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; strcpy(pcm->name, "Multichannel Playback"); - emu->pcm = pcm; + emu->pcm_multi = pcm; for (substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; substream = substream->next) if ((err = snd_pcm_lib_preallocate_pages(substream, SNDRV_DMA_TYPE_DEV_SG, snd_dma_pci_data(emu->pci), 64*1024, 64*1024)) < 0) @@ -1556,6 +1565,7 @@ static int snd_emu10k1_fx8010_playback_trigger(struct snd_pcm_substream *substre case SNDRV_PCM_TRIGGER_START: /* follow thru */ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: #ifdef EMU10K1_SET_AC3_IEC958 { int i; @@ -1576,6 +1586,7 @@ static int snd_emu10k1_fx8010_playback_trigger(struct snd_pcm_substream *substre break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: snd_emu10k1_fx8010_unregister_irq_handler(emu, pcm->irq); pcm->irq = NULL; snd_emu10k1_ptr_write(emu, emu->gpr_base + pcm->gpr_trigger, 0, 0); pcm->tram_pos = INITIAL_TRAM_POS(pcm->buffer_size); @@ -1605,6 +1616,7 @@ static snd_pcm_uframes_t snd_emu10k1_fx8010_playback_pointer(struct snd_pcm_subs static struct snd_pcm_hardware snd_emu10k1_fx8010_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_RESUME | /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_48000, diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 90470de..adce6af 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -125,6 +125,7 @@ static struct snd_pcm_hardware snd_p16v_playback_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S32_LE, /* Only supports 24-bit samples padded to 32 bits. */ .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, @@ -144,6 +145,7 @@ static struct snd_pcm_hardware snd_p16v_capture_hw = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S32_LE, .rates = SNDRV_PCM_RATE_192000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_44100, @@ -611,7 +613,7 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) pcm->info_flags = 0; pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; strcpy(pcm->name, "p16v"); - emu->pcm = pcm; + emu->pcm_p16v = pcm; for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; substream; @@ -1030,3 +1032,42 @@ int snd_p16v_mixer(struct snd_emu10k1 *emu) return 0; } +#ifdef CONFIG_PM + +#define NUM_CHS 1 /* up to 4, but only first channel is used */ + +int __devinit snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) +{ + emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80); + if (! emu->p16v_saved) + return -ENOMEM; + return 0; +} + +void snd_p16v_free_pm_buffer(struct snd_emu10k1 *emu) +{ + vfree(emu->p16v_saved); +} + +void snd_p16v_suspend(struct snd_emu10k1 *emu) +{ + int i, ch; + unsigned int *val; + + val = emu->p16v_saved; + for (ch = 0; ch < NUM_CHS; ch++) + for (i = 0; i < 0x80; i++, val++) + *val = snd_emu10k1_ptr20_read(emu, i, ch); +} + +void snd_p16v_resume(struct snd_emu10k1 *emu) +{ + int i, ch; + unsigned int *val; + + val = emu->p16v_saved; + for (ch = 0; ch < NUM_CHS; ch++) + for (i = 0; i < 0x80; i++, val++) + snd_emu10k1_ptr20_write(emu, i, ch, *val); +} +#endif -- cgit v1.1 From b1e9ed26a9e472548a63a59014708fdae013b7a3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:14:33 +0100 Subject: [ALSA] fm801 - Add PM support Modules: FM801 driver Add PM support to fm801 driver. Signed-off-by: Takashi Iwai --- sound/pci/fm801.c | 245 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 158 insertions(+), 87 deletions(-) diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c index a57aca7..6ab4aef 100644 --- a/sound/pci/fm801.c +++ b/sound/pci/fm801.c @@ -103,7 +103,11 @@ MODULE_PARM_DESC(tea575x_tuner, "Enable TEA575x tuner."); #define FM801_OPL3_DATA1 0x6b /* OPL3 Bank 1 Write */ #define FM801_POWERDOWN 0x70 /* Blocks Power Down Control */ -#define FM801_AC97_ADDR_SHIFT 10 +/* codec access */ +#define FM801_AC97_READ (1<<7) /* read=1, write=0 */ +#define FM801_AC97_VALID (1<<8) /* port valid=1 */ +#define FM801_AC97_BUSY (1<<9) /* busy=1 */ +#define FM801_AC97_ADDR_SHIFT 10 /* codec id (2bit) */ /* playback and record control register bits */ #define FM801_BUF1_LAST (1<<1) @@ -189,6 +193,10 @@ struct fm801 { #ifdef TEA575X_RADIO struct snd_tea575x tea; #endif + +#ifdef CONFIG_PM + u16 saved_regs[0x20]; +#endif }; static struct pci_device_id snd_fm801_ids[] = { @@ -231,7 +239,7 @@ static void snd_fm801_codec_write(struct snd_ac97 *ac97, * Wait until the codec interface is not ready.. */ for (idx = 0; idx < 100; idx++) { - if (!(inw(FM801_REG(chip, AC97_CMD)) & (1<<9))) + if (!(inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_BUSY)) goto ok1; udelay(10); } @@ -246,7 +254,7 @@ static void snd_fm801_codec_write(struct snd_ac97 *ac97, * Wait until the write command is not completed.. */ for (idx = 0; idx < 1000; idx++) { - if (!(inw(FM801_REG(chip, AC97_CMD)) & (1<<9))) + if (!(inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_BUSY)) return; udelay(10); } @@ -262,7 +270,7 @@ static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short * Wait until the codec interface is not ready.. */ for (idx = 0; idx < 100; idx++) { - if (!(inw(FM801_REG(chip, AC97_CMD)) & (1<<9))) + if (!(inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_BUSY)) goto ok1; udelay(10); } @@ -271,9 +279,10 @@ static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short ok1: /* read command */ - outw(reg | (ac97->addr << FM801_AC97_ADDR_SHIFT) | (1<<7), FM801_REG(chip, AC97_CMD)); + outw(reg | (ac97->addr << FM801_AC97_ADDR_SHIFT) | FM801_AC97_READ, + FM801_REG(chip, AC97_CMD)); for (idx = 0; idx < 100; idx++) { - if (!(inw(FM801_REG(chip, AC97_CMD)) & (1<<9))) + if (!(inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_BUSY)) goto ok2; udelay(10); } @@ -282,7 +291,7 @@ static unsigned short snd_fm801_codec_read(struct snd_ac97 *ac97, unsigned short ok2: for (idx = 0; idx < 1000; idx++) { - if (inw(FM801_REG(chip, AC97_CMD)) & (1<<8)) + if (inw(FM801_REG(chip, AC97_CMD)) & FM801_AC97_VALID) goto ok3; udelay(10); } @@ -354,9 +363,11 @@ static int snd_fm801_playback_trigger(struct snd_pcm_substream *substream, chip->ply_ctrl &= ~(FM801_START | FM801_PAUSE); break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: chip->ply_ctrl |= FM801_PAUSE; break; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: chip->ply_ctrl &= ~FM801_PAUSE; break; default: @@ -387,9 +398,11 @@ static int snd_fm801_capture_trigger(struct snd_pcm_substream *substream, chip->cap_ctrl &= ~(FM801_START | FM801_PAUSE); break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: chip->cap_ctrl |= FM801_PAUSE; break; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: chip->cap_ctrl &= ~FM801_PAUSE; break; default: @@ -557,7 +570,7 @@ static struct snd_pcm_hardware snd_fm801_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_PAUSE | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, @@ -577,7 +590,7 @@ static struct snd_pcm_hardware snd_fm801_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | - SNDRV_PCM_INFO_PAUSE | + SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_8000_48000, @@ -1218,6 +1231,85 @@ static int __devinit snd_fm801_mixer(struct fm801 *chip) * initialization routines */ +static int wait_for_codec(struct fm801 *chip, unsigned int codec_id, + unsigned short reg, unsigned long waits) +{ + unsigned long timeout = jiffies + waits; + + outw(FM801_AC97_READ | (codec_id << FM801_AC97_ADDR_SHIFT) | reg, + FM801_REG(chip, AC97_CMD)); + udelay(5); + do { + if ((inw(FM801_REG(chip, AC97_CMD)) & (FM801_AC97_VALID|FM801_AC97_BUSY)) + == FM801_AC97_VALID) + return 0; + schedule_timeout_uninterruptible(1); + } while (time_after(timeout, jiffies)); + return -EIO; +} + +static int snd_fm801_chip_init(struct fm801 *chip, int resume) +{ + int id; + unsigned short cmdw; + + /* codec cold reset + AC'97 warm reset */ + outw((1<<5) | (1<<6), FM801_REG(chip, CODEC_CTRL)); + inw(FM801_REG(chip, CODEC_CTRL)); /* flush posting data */ + udelay(100); + outw(0, FM801_REG(chip, CODEC_CTRL)); + + if (wait_for_codec(chip, 0, AC97_RESET, msecs_to_jiffies(750)) < 0) { + snd_printk(KERN_ERR "Primary AC'97 codec not found\n"); + if (! resume) + return -EIO; + } + + if (chip->multichannel) { + if (chip->secondary_addr) { + wait_for_codec(chip, chip->secondary_addr, + AC97_VENDOR_ID1, msecs_to_jiffies(50)); + } else { + /* my card has the secondary codec */ + /* at address #3, so the loop is inverted */ + for (id = 3; id > 0; id--) { + if (! wait_for_codec(chip, id, AC97_VENDOR_ID1, + msecs_to_jiffies(50))) { + cmdw = inw(FM801_REG(chip, AC97_DATA)); + if (cmdw != 0xffff && cmdw != 0) { + chip->secondary = 1; + chip->secondary_addr = id; + break; + } + } + } + } + + /* the recovery phase, it seems that probing for non-existing codec might */ + /* cause timeout problems */ + wait_for_codec(chip, 0, AC97_VENDOR_ID1, msecs_to_jiffies(750)); + } + + /* init volume */ + outw(0x0808, FM801_REG(chip, PCM_VOL)); + outw(0x9f1f, FM801_REG(chip, FM_VOL)); + outw(0x8808, FM801_REG(chip, I2S_VOL)); + + /* I2S control - I2S mode */ + outw(0x0003, FM801_REG(chip, I2S_MODE)); + + /* interrupt setup - unmask MPU, PLAYBACK & CAPTURE */ + cmdw = inw(FM801_REG(chip, IRQ_MASK)); + cmdw &= ~0x0083; + outw(cmdw, FM801_REG(chip, IRQ_MASK)); + + /* interrupt clear */ + outw(FM801_IRQ_PLAYBACK|FM801_IRQ_CAPTURE|FM801_IRQ_MPU, FM801_REG(chip, IRQ_STATUS)); + + return 0; +} + + static int snd_fm801_free(struct fm801 *chip) { unsigned short cmdw; @@ -1255,9 +1347,7 @@ static int __devinit snd_fm801_create(struct snd_card *card, struct fm801 ** rchip) { struct fm801 *chip; - unsigned char rev, id; - unsigned short cmdw; - unsigned long timeout; + unsigned char rev; int err; static struct snd_device_ops ops = { .dev_free = snd_fm801_dev_free, @@ -1294,81 +1384,7 @@ static int __devinit snd_fm801_create(struct snd_card *card, if (rev >= 0xb1) /* FM801-AU */ chip->multichannel = 1; - /* codec cold reset + AC'97 warm reset */ - outw((1<<5)|(1<<6), FM801_REG(chip, CODEC_CTRL)); - inw(FM801_REG(chip, CODEC_CTRL)); /* flush posting data */ - udelay(100); - outw(0, FM801_REG(chip, CODEC_CTRL)); - - timeout = (jiffies + (3 * HZ) / 4) + 1; /* min 750ms */ - - outw((1<<7) | (0 << FM801_AC97_ADDR_SHIFT), FM801_REG(chip, AC97_CMD)); - udelay(5); - do { - if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8)) - goto __ac97_secondary; - schedule_timeout_uninterruptible(1); - } while (time_after(timeout, jiffies)); - snd_printk(KERN_ERR "Primary AC'97 codec not found\n"); - snd_fm801_free(chip); - return -EIO; - - __ac97_secondary: - if (!chip->multichannel) /* lookup is not required */ - goto __ac97_ok; - for (id = 3; id > 0; id--) { /* my card has the secondary codec */ - /* at address #3, so the loop is inverted */ - - timeout = jiffies + HZ / 20; - - outw((1<<7) | (id << FM801_AC97_ADDR_SHIFT) | AC97_VENDOR_ID1, - FM801_REG(chip, AC97_CMD)); - udelay(5); - do { - if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8)) { - cmdw = inw(FM801_REG(chip, AC97_DATA)); - if (cmdw != 0xffff && cmdw != 0) { - chip->secondary = 1; - chip->secondary_addr = id; - goto __ac97_ok; - } - } - schedule_timeout_uninterruptible(1); - } while (time_after(timeout, jiffies)); - } - - /* the recovery phase, it seems that probing for non-existing codec might */ - /* cause timeout problems */ - timeout = (jiffies + (3 * HZ) / 4) + 1; /* min 750ms */ - - outw((1<<7) | (0 << FM801_AC97_ADDR_SHIFT), FM801_REG(chip, AC97_CMD)); - udelay(5); - do { - if ((inw(FM801_REG(chip, AC97_CMD)) & (3<<8)) == (1<<8)) - goto __ac97_ok; - schedule_timeout_uninterruptible(1); - } while (time_after(timeout, jiffies)); - snd_printk(KERN_ERR "Primary AC'97 codec not responding\n"); - snd_fm801_free(chip); - return -EIO; - - __ac97_ok: - - /* init volume */ - outw(0x0808, FM801_REG(chip, PCM_VOL)); - outw(0x9f1f, FM801_REG(chip, FM_VOL)); - outw(0x8808, FM801_REG(chip, I2S_VOL)); - - /* I2S control - I2S mode */ - outw(0x0003, FM801_REG(chip, I2S_MODE)); - - /* interrupt setup - unmask MPU, PLAYBACK & CAPTURE */ - cmdw = inw(FM801_REG(chip, IRQ_MASK)); - cmdw &= ~0x0083; - outw(cmdw, FM801_REG(chip, IRQ_MASK)); - - /* interrupt clear */ - outw(FM801_IRQ_PLAYBACK|FM801_IRQ_CAPTURE|FM801_IRQ_MPU, FM801_REG(chip, IRQ_STATUS)); + snd_fm801_chip_init(chip, 0); if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_fm801_free(chip); @@ -1415,6 +1431,7 @@ static int __devinit snd_card_fm801_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = chip; strcpy(card->driver, "FM801"); strcpy(card->shortname, "ForteMedia FM801-"); @@ -1462,11 +1479,65 @@ static void __devexit snd_card_fm801_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } +#ifdef CONFIG_PM +static unsigned char saved_regs[] = { + FM801_PCM_VOL, FM801_I2S_VOL, FM801_FM_VOL, FM801_REC_SRC, + FM801_PLY_CTRL, FM801_PLY_COUNT, FM801_PLY_BUF1, FM801_PLY_BUF2, + FM801_CAP_CTRL, FM801_CAP_COUNT, FM801_CAP_BUF1, FM801_CAP_BUF2, + FM801_CODEC_CTRL, FM801_I2S_MODE, FM801_VOLUME, FM801_GEN_CTRL, +}; + +static int snd_fm801_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct fm801 *chip = card->private_data; + int i; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_ac97_suspend(chip->ac97); + snd_ac97_suspend(chip->ac97_sec); + for (i = 0; i < ARRAY_SIZE(saved_regs); i++) + chip->saved_regs[i] = inw(chip->port + saved_regs[i]); + /* FIXME: tea575x suspend */ + + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return 0; +} + +static int snd_fm801_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct fm801 *chip = card->private_data; + int i; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + + snd_fm801_chip_init(chip, 1); + snd_ac97_resume(chip->ac97); + snd_ac97_resume(chip->ac97_sec); + for (i = 0; i < ARRAY_SIZE(saved_regs); i++) + outw(chip->saved_regs[i], chip->port + saved_regs[i]); + + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + static struct pci_driver driver = { .name = "FM801", .id_table = snd_fm801_ids, .probe = snd_card_fm801_probe, .remove = __devexit_p(snd_card_fm801_remove), +#ifdef CONFIG_PM + .suspend = snd_fm801_suspend, + .resume = snd_fm801_resume, +#endif }; static int __init alsa_card_fm801_init(void) -- cgit v1.1 From cb60e5f5b2b19284479825cdaa6dd6b7078cf5d2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:14:49 +0100 Subject: [ALSA] cmipci - Add PM support Modules: CMIPCI driver Add PM support to CMIPCI driver. Signed-off-by: Takashi Iwai --- sound/pci/cmipci.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 98 insertions(+), 6 deletions(-) diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index ce156ca..c03b0a0 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -269,6 +269,7 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address."); #define CM_MICGAINZ 0x01 /* mic boost */ #define CM_MICGAINZ_SHIFT 0 +#define CM_REG_MIXER3 0x24 #define CM_REG_AUX_VOL 0x26 #define CM_VAUXL_MASK 0xf0 #define CM_VAUXR_MASK 0x0f @@ -324,6 +325,7 @@ MODULE_PARM_DESC(joystick_port, "Joystick port address."); #define CM_REG_CH0_FRAME2 0x84 #define CM_REG_CH1_FRAME1 0x88 /* 0-15: count of samples at bus master; buffer size */ #define CM_REG_CH1_FRAME2 0x8C /* 16-31: count of samples at codec; fragment size */ +#define CM_REG_EXT_MISC 0x90 #define CM_REG_MISC_CTRL_8768 0x92 /* reg. name the same as 0x18 */ #define CM_CHB3D8C 0x20 /* 7.1 channels support */ #define CM_SPD32FMT 0x10 /* SPDIF/IN 32k */ @@ -453,6 +455,11 @@ struct cmipci { #endif spinlock_t reg_lock; + +#ifdef CONFIG_PM + unsigned int saved_regs[0x20]; + unsigned char saved_mixers[0x20]; +#endif }; @@ -849,10 +856,12 @@ static int snd_cmipci_pcm_trigger(struct cmipci *cm, struct cmipci_pcm *rec, snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl & ~reset); break; case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: cm->ctrl |= pause; snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); break; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: cm->ctrl &= ~pause; snd_cmipci_write(cm, CM_REG_FUNCTRL0, cm->ctrl); break; @@ -1325,7 +1334,7 @@ static struct snd_pcm_hardware snd_cmipci_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_48000, .rate_min = 5512, @@ -1345,7 +1354,7 @@ static struct snd_pcm_hardware snd_cmipci_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_48000, .rate_min = 5512, @@ -1365,7 +1374,7 @@ static struct snd_pcm_hardware snd_cmipci_playback2 = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_48000, .rate_min = 5512, @@ -1385,7 +1394,7 @@ static struct snd_pcm_hardware snd_cmipci_playback_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, .rate_min = 44100, @@ -1405,7 +1414,7 @@ static struct snd_pcm_hardware snd_cmipci_playback_iec958_subframe = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE, .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, .rate_min = 44100, @@ -1425,7 +1434,7 @@ static struct snd_pcm_hardware snd_cmipci_capture_spdif = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | SNDRV_PCM_INFO_PAUSE | - SNDRV_PCM_INFO_MMAP_VALID), + SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), .formats = SNDRV_PCM_FMTBIT_S16_LE, .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000, .rate_min = 44100, @@ -3038,6 +3047,7 @@ static int __devinit snd_cmipci_probe(struct pci_dev *pci, snd_card_free(card); return err; } + card->private_data = cm; sprintf(card->shortname, "C-Media PCI %s", card->driver); sprintf(card->longname, "%s (model %d) at 0x%lx, irq %i", @@ -3065,11 +3075,93 @@ static void __devexit snd_cmipci_remove(struct pci_dev *pci) } +#ifdef CONFIG_PM +/* + * power management + */ +static unsigned char saved_regs[] = { + CM_REG_FUNCTRL1, CM_REG_CHFORMAT, CM_REG_LEGACY_CTRL, CM_REG_MISC_CTRL, + CM_REG_MIXER0, CM_REG_MIXER1, CM_REG_MIXER2, CM_REG_MIXER3, CM_REG_PLL, + CM_REG_CH0_FRAME1, CM_REG_CH0_FRAME2, + CM_REG_CH1_FRAME1, CM_REG_CH1_FRAME2, CM_REG_EXT_MISC, + CM_REG_INT_STATUS, CM_REG_INT_HLDCLR, CM_REG_FUNCTRL0, +}; + +static unsigned char saved_mixers[] = { + SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, + SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1, + SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1, + SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1, + SB_DSP4_LINE_DEV, SB_DSP4_LINE_DEV + 1, + SB_DSP4_MIC_DEV, SB_DSP4_SPEAKER_DEV, + CM_REG_EXTENT_IND, SB_DSP4_OUTPUT_SW, + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, +}; + +static int snd_cmipci_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct cmipci *cm = card->private_data; + int i; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + + snd_pcm_suspend_all(cm->pcm); + snd_pcm_suspend_all(cm->pcm2); + snd_pcm_suspend_all(cm->pcm_spdif); + + /* save registers */ + for (i = 0; i < ARRAY_SIZE(saved_regs); i++) + cm->saved_regs[i] = snd_cmipci_read(cm, saved_regs[i]); + for (i = 0; i < ARRAY_SIZE(saved_mixers); i++) + cm->saved_mixers[i] = snd_cmipci_mixer_read(cm, saved_mixers[i]); + + /* disable ints */ + snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); + + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return 0; +} + +static int snd_cmipci_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct cmipci *cm = card->private_data; + int i; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + + /* reset / initialize to a sane state */ + snd_cmipci_write(cm, CM_REG_INT_HLDCLR, 0); + snd_cmipci_ch_reset(cm, CM_CH_PLAY); + snd_cmipci_ch_reset(cm, CM_CH_CAPT); + snd_cmipci_mixer_write(cm, 0, 0); + + /* restore registers */ + for (i = 0; i < ARRAY_SIZE(saved_regs); i++) + snd_cmipci_write(cm, saved_regs[i], cm->saved_regs[i]); + for (i = 0; i < ARRAY_SIZE(saved_mixers); i++) + snd_cmipci_mixer_write(cm, saved_mixers[i], cm->saved_mixers[i]); + + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif /* CONFIG_PM */ + static struct pci_driver driver = { .name = "C-Media PCI", .id_table = snd_cmipci_ids, .probe = snd_cmipci_probe, .remove = __devexit_p(snd_cmipci_remove), +#ifdef CONFIG_PM + .suspend = snd_cmipci_suspend, + .resume = snd_cmipci_resume, +#endif }; static int __init alsa_card_cmipci_init(void) -- cgit v1.1 From 5bdb6a1629408f657f5f2c42b3c07c689c411499 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:16:10 +0100 Subject: [ALSA] Add PM support to SB-support code Modules: SB drivers,SB16/AWE driver Add PM support to SB-support code. Signed-off-by: Takashi Iwai --- include/sound/sb.h | 8 +++ sound/isa/sb/sb16_main.c | 4 ++ sound/isa/sb/sb_common.c | 4 ++ sound/isa/sb/sb_mixer.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) diff --git a/include/sound/sb.h b/include/sound/sb.h index 8e82460..431d066 100644 --- a/include/sound/sb.h +++ b/include/sound/sb.h @@ -107,6 +107,10 @@ struct snd_sb { spinlock_t midi_input_lock; struct snd_info_entry *proc_entry; + +#ifdef CONFIG_PM + unsigned char saved_regs[0x20]; +#endif }; /* I/O ports */ @@ -290,6 +294,10 @@ int snd_sbdsp_create(struct snd_card *card, void snd_sbmixer_write(struct snd_sb *chip, unsigned char reg, unsigned char data); unsigned char snd_sbmixer_read(struct snd_sb *chip, unsigned char reg); int snd_sbmixer_new(struct snd_sb *chip); +#ifdef CONFIG_PM +void snd_sbmixer_suspend(struct snd_sb *chip); +void snd_sbmixer_resume(struct snd_sb *chip); +#endif /* sb8_init.c */ int snd_sb8dsp_pcm(struct snd_sb *chip, int device, struct snd_pcm ** rpcm); diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c index 97786ed..f183f18 100644 --- a/sound/isa/sb/sb16_main.c +++ b/sound/isa/sb/sb16_main.c @@ -307,10 +307,12 @@ static int snd_sb16_playback_trigger(struct snd_pcm_substream *substream, spin_lock(&chip->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: chip->mode |= SB_RATE_LOCK_PLAYBACK; snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON); break; case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: snd_sbdsp_command(chip, chip->mode & SB_MODE_PLAYBACK_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF); /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */ if (chip->mode & SB_RATE_LOCK_CAPTURE) @@ -374,10 +376,12 @@ static int snd_sb16_capture_trigger(struct snd_pcm_substream *substream, spin_lock(&chip->reg_lock); switch (cmd) { case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: chip->mode |= SB_RATE_LOCK_CAPTURE; snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_ON : SB_DSP_DMA8_ON); break; case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: snd_sbdsp_command(chip, chip->mode & SB_MODE_CAPTURE_16 ? SB_DSP_DMA16_OFF : SB_DSP_DMA8_OFF); /* next two lines are needed for some types of DSP4 (SB AWE 32 - 4.13) */ if (chip->mode & SB_RATE_LOCK_PLAYBACK) diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index eb86b44..f343a82 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -293,6 +293,10 @@ EXPORT_SYMBOL(snd_sbmixer_write); EXPORT_SYMBOL(snd_sbmixer_read); EXPORT_SYMBOL(snd_sbmixer_new); EXPORT_SYMBOL(snd_sbmixer_add_ctl); +#ifdef CONFIG_PM +EXPORT_SYMBOL(snd_sbmixer_suspend); +EXPORT_SYMBOL(snd_sbmixer_resume); +#endif /* * INIT part diff --git a/sound/isa/sb/sb_mixer.c b/sound/isa/sb/sb_mixer.c index 6e0b935..1a6ee34 100644 --- a/sound/isa/sb/sb_mixer.c +++ b/sound/isa/sb/sb_mixer.c @@ -853,3 +853,140 @@ int snd_sbmixer_new(struct snd_sb *chip) } return 0; } + +#ifdef CONFIG_PM +static unsigned char sb20_saved_regs[] = { + SB_DSP20_MASTER_DEV, + SB_DSP20_PCM_DEV, + SB_DSP20_FM_DEV, + SB_DSP20_CD_DEV, +}; + +static unsigned char sbpro_saved_regs[] = { + SB_DSP_MASTER_DEV, + SB_DSP_PCM_DEV, + SB_DSP_PLAYBACK_FILT, + SB_DSP_FM_DEV, + SB_DSP_CD_DEV, + SB_DSP_LINE_DEV, + SB_DSP_MIC_DEV, + SB_DSP_CAPTURE_SOURCE, + SB_DSP_CAPTURE_FILT, +}; + +static unsigned char sb16_saved_regs[] = { + SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, + SB_DSP4_3DSE, + SB_DSP4_BASS_DEV, SB_DSP4_BASS_DEV + 1, + SB_DSP4_TREBLE_DEV, SB_DSP4_TREBLE_DEV + 1, + SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1, + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, + SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1, + SB_DSP4_OUTPUT_SW, + SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1, + SB_DSP4_LINE_DEV, SB_DSP4_LINE_DEV + 1, + SB_DSP4_MIC_DEV, + SB_DSP4_SPEAKER_DEV, + SB_DSP4_IGAIN_DEV, SB_DSP4_IGAIN_DEV + 1, + SB_DSP4_OGAIN_DEV, SB_DSP4_OGAIN_DEV + 1, + SB_DSP4_MIC_AGC +}; + +static unsigned char dt019x_saved_regs[] = { + SB_DT019X_MASTER_DEV, + SB_DT019X_PCM_DEV, + SB_DT019X_SYNTH_DEV, + SB_DT019X_CD_DEV, + SB_DT019X_MIC_DEV, + SB_DT019X_SPKR_DEV, + SB_DT019X_LINE_DEV, + SB_DSP4_OUTPUT_SW, + SB_DT019X_OUTPUT_SW2, + SB_DT019X_CAPTURE_SW, +}; + +static unsigned char als4000_saved_regs[] = { + SB_DSP4_MASTER_DEV, SB_DSP4_MASTER_DEV + 1, + SB_DSP4_OUTPUT_SW, + SB_DSP4_PCM_DEV, SB_DSP4_PCM_DEV + 1, + SB_DSP4_INPUT_LEFT, SB_DSP4_INPUT_RIGHT, + SB_DSP4_SYNTH_DEV, SB_DSP4_SYNTH_DEV + 1, + SB_DSP4_CD_DEV, SB_DSP4_CD_DEV + 1, + SB_DSP4_MIC_AGC, + SB_DSP4_MIC_DEV, + SB_DSP4_SPEAKER_DEV, + SB_DSP4_IGAIN_DEV, SB_DSP4_IGAIN_DEV + 1, + SB_DSP4_OGAIN_DEV, SB_DSP4_OGAIN_DEV + 1, + SB_DT019X_OUTPUT_SW2, + SB_ALS4000_MONO_IO_CTRL, + SB_ALS4000_MIC_IN_GAIN, + SB_ALS4000_3D_SND_FX, + SB_ALS4000_3D_TIME_DELAY, +}; + +static void save_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) +{ + unsigned char *val = chip->saved_regs; + snd_assert(num_regs > ARRAY_SIZE(chip->saved_regs), return); + for (; num_regs; num_regs--) + *val++ = snd_sbmixer_read(chip, *regs++); +} + +static void restore_mixer(struct snd_sb *chip, unsigned char *regs, int num_regs) +{ + unsigned char *val = chip->saved_regs; + snd_assert(num_regs > ARRAY_SIZE(chip->saved_regs), return); + for (; num_regs; num_regs--) + snd_sbmixer_write(chip, *regs++, *val++); +} + +void snd_sbmixer_suspend(struct snd_sb *chip) +{ + switch (chip->hardware) { + case SB_HW_20: + case SB_HW_201: + save_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); + break; + case SB_HW_PRO: + save_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); + break; + case SB_HW_16: + case SB_HW_ALS100: + save_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs)); + break; + case SB_HW_ALS4000: + save_mixer(chip, als4000_saved_regs, ARRAY_SIZE(als4000_saved_regs)); + break; + case SB_HW_DT019X: + save_mixer(chip, dt019x_saved_regs, ARRAY_SIZE(dt019x_saved_regs)); + break; + default: + break; + } +} + +void snd_sbmixer_resume(struct snd_sb *chip) +{ + switch (chip->hardware) { + case SB_HW_20: + case SB_HW_201: + restore_mixer(chip, sb20_saved_regs, ARRAY_SIZE(sb20_saved_regs)); + break; + case SB_HW_PRO: + restore_mixer(chip, sbpro_saved_regs, ARRAY_SIZE(sbpro_saved_regs)); + break; + case SB_HW_16: + case SB_HW_ALS100: + restore_mixer(chip, sb16_saved_regs, ARRAY_SIZE(sb16_saved_regs)); + break; + case SB_HW_ALS4000: + restore_mixer(chip, als4000_saved_regs, ARRAY_SIZE(als4000_saved_regs)); + break; + case SB_HW_DT019X: + restore_mixer(chip, dt019x_saved_regs, ARRAY_SIZE(dt019x_saved_regs)); + break; + default: + break; + } +} +#endif -- cgit v1.1 From 703529140cfb774366b839f38f027f283cb948b4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:16:36 +0100 Subject: [ALSA] als4000 - Add PM support Modules: ALS4000 driver Add PM support to PCI ALS4000 driver. Signed-off-by: Takashi Iwai --- sound/pci/als4000.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 8d0d9c0..7b2ff5f 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -109,6 +109,7 @@ struct snd_card_als4000 { /* most frequent access first */ unsigned long gcr; struct pci_dev *pci; + struct snd_sb *chip; #ifdef SUPPORT_JOYSTICK struct gameport *gameport; #endif @@ -305,14 +306,20 @@ static int snd_als4000_capture_trigger(struct snd_pcm_substream *substream, int int result = 0; spin_lock(&chip->mixer_lock); - if (cmd == SNDRV_PCM_TRIGGER_START) { + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: chip->mode |= SB_RATE_LOCK_CAPTURE; snd_sbmixer_write(chip, 0xde, capture_cmd(chip)); - } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: chip->mode &= ~SB_RATE_LOCK_CAPTURE; snd_sbmixer_write(chip, 0xde, 0); - } else { + break; + default: result = -EINVAL; + break; } spin_unlock(&chip->mixer_lock); return result; @@ -324,14 +331,20 @@ static int snd_als4000_playback_trigger(struct snd_pcm_substream *substream, int int result = 0; spin_lock(&chip->reg_lock); - if (cmd == SNDRV_PCM_TRIGGER_START) { + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: chip->mode |= SB_RATE_LOCK_PLAYBACK; snd_sbdsp_command(chip, playback_cmd(chip).dma_on); - } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: snd_sbdsp_command(chip, playback_cmd(chip).dma_off); chip->mode &= ~SB_RATE_LOCK_PLAYBACK; - } else { + break; + default: result = -EINVAL; + break; } spin_unlock(&chip->reg_lock); return result; @@ -551,7 +564,7 @@ static void snd_als4000_set_addr(unsigned long gcr, snd_als4000_gcr_write_addr(gcr, 0xa9, confB); } -static void __devinit snd_als4000_configure(struct snd_sb *chip) +static void snd_als4000_configure(struct snd_sb *chip) { unsigned tmp; int i; @@ -718,6 +731,7 @@ static int __devinit snd_card_als4000_probe(struct pci_dev *pci, &chip)) < 0) { goto out_err; } + acard->chip = chip; chip->pci = pci; chip->alt_port = gcr; @@ -777,11 +791,59 @@ static void __devexit snd_card_als4000_remove(struct pci_dev *pci) pci_set_drvdata(pci, NULL); } +#ifdef CONFIG_PM +static int snd_als4000_suspend(struct pci_dev *pci, pm_message_t state) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_card_als4000 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + + pci_set_power_state(pci, PCI_D3hot); + pci_disable_device(pci); + pci_save_state(pci); + return 0; +} + +static int snd_als4000_resume(struct pci_dev *pci) +{ + struct snd_card *card = pci_get_drvdata(pci); + struct snd_card_als4000 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_power_state(pci, PCI_D0); + pci_set_master(pci); + + snd_als4000_configure(chip); + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + +#ifdef SUPPORT_JOYSTICK + if (acard->gameport) + snd_als4000_set_addr(acard->gcr, 0, 0, 0, 1); +#endif + + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + + static struct pci_driver driver = { .name = "ALS4000", .id_table = snd_als4000_ids, .probe = snd_card_als4000_probe, .remove = __devexit_p(snd_card_als4000_remove), +#ifdef CONFIG_PM + .suspend = snd_als4000_suspend, + .resume = snd_als4000_resume, +#endif }; static int __init alsa_card_als4000_init(void) -- cgit v1.1 From 6f045616aff91022966b5c37ba6845791dd125dc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:54:56 +0100 Subject: [ALSA] sb16 - Use platform_device and add PnP support Modules: SB16/AWE driver Rewrite the probe/remove with platform_device. Add PM support using PnP suspend/resume callbacks. Signed-off-by: Takashi Iwai --- sound/isa/sb/sb16.c | 327 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 204 insertions(+), 123 deletions(-) diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 96e4013..05816c5 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -32,7 +34,6 @@ #include #include #include -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -129,6 +130,7 @@ MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); struct snd_card_sb16 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ + struct snd_sb *chip; #ifdef CONFIG_PNP int dev_no; struct pnp_dev *dev; @@ -138,8 +140,6 @@ struct snd_card_sb16 { #endif }; -static struct snd_card *snd_sb16_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #ifdef CONFIG_PNP static struct pnp_card_device_id snd_sb16_pnpids[] = { @@ -341,7 +341,7 @@ __wt_error: static void snd_sb16_free(struct snd_card *card) { - struct snd_card_sb16 *acard = (struct snd_card_sb16 *)card->private_data; + struct snd_card_sb16 *acard = card->private_data; if (acard == NULL) return; @@ -354,17 +354,21 @@ static void snd_sb16_free(struct snd_card *card) #define is_isapnp_selected(dev) 0 #endif -static int __init snd_sb16_probe(int dev, - struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_sb16_card_new(int dev) +{ + struct snd_card *card = snd_card_new(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_card_sb16)); + if (card == NULL) + return NULL; + card->private_free = snd_sb16_free; + return card; +} + +static int __init snd_sb16_probe(struct snd_card *card, int dev) { - static int possible_irqs[] = {5, 9, 10, 7, -1}; - static int possible_dmas8[] = {1, 3, 0, -1}; - static int possible_dmas16[] = {5, 6, 7, -1}; int xirq, xdma8, xdma16; struct snd_sb *chip; - struct snd_card *card; - struct snd_card_sb16 *acard; + struct snd_card_sb16 *acard = card->private_data; struct snd_opl3 *opl3; struct snd_hwdep *synth = NULL; #ifdef CONFIG_SND_SB16_CSP @@ -373,54 +377,9 @@ static int __init snd_sb16_probe(int dev, unsigned long flags; int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_card_sb16)); - if (card == NULL) - return -ENOMEM; - acard = (struct snd_card_sb16 *) card->private_data; - card->private_free = snd_sb16_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_card_sb16_pnp(dev, acard, pcard, pid))) - goto _err; - snd_card_set_dev(card, &pcard->card->dev); - } -#endif - xirq = irq[dev]; xdma8 = dma8[dev]; xdma16 = dma16[dev]; - if (! is_isapnp_selected(dev)) { - if (xirq == SNDRV_AUTO_IRQ) { - if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - err = -EBUSY; - goto _err; - } - } - if (xdma8 == SNDRV_AUTO_DMA) { - if ((xdma8 = snd_legacy_find_free_dma(possible_dmas8)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); - err = -EBUSY; - goto _err; - } - } - if (xdma16 == SNDRV_AUTO_DMA) { - if ((xdma16 = snd_legacy_find_free_dma(possible_dmas16)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); - err = -EBUSY; - goto _err; - } - } - /* non-PnP FM port address is hardwired with base port address */ - fm_port[dev] = port[dev]; - /* block the 0x388 port to avoid PnP conflicts */ - acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); -#ifdef SNDRV_SBAWE_EMU8000 - /* non-PnP AWE port address is hardwired with base port address */ - awe_port[dev] = port[dev] + 0x400; -#endif - } if ((err = snd_sbdsp_create(card, port[dev], @@ -430,19 +389,19 @@ static int __init snd_sb16_probe(int dev, xdma16, SB_HW_AUTO, &chip)) < 0) - goto _err; + return err; + acard->chip = chip; if (chip->hardware != SB_HW_16) { snd_printk(KERN_ERR PFX "SB 16 chip was not detected at 0x%lx\n", port[dev]); - err = -ENODEV; - goto _err; + return -ENODEV; } chip->mpu_port = mpu_port[dev]; if (! is_isapnp_selected(dev) && (err = snd_sb16dsp_configure(chip)) < 0) - goto _err; + return err; - if ((err = snd_sb16dsp_pcm(chip, 0, NULL)) < 0) - goto _err; + if ((err = snd_sb16dsp_pcm(chip, 0, &chip->pcm)) < 0) + return err; strcpy(card->driver, #ifdef SNDRV_SBAWE_EMU8000 @@ -464,7 +423,7 @@ static int __init snd_sb16_probe(int dev, if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_SB, chip->mpu_port, 0, xirq, 0, &chip->rmidi)) < 0) - goto _err; + return err; chip->rmidi_callback = snd_mpu401_uart_interrupt; } @@ -487,12 +446,12 @@ static int __init snd_sb16_probe(int dev, int seqdev = 1; #endif if ((err = snd_opl3_hwdep_new(opl3, 0, seqdev, &synth)) < 0) - goto _err; + return err; } } if ((err = snd_sbmixer_new(chip)) < 0) - goto _err; + return err; #ifdef CONFIG_SND_SB16_CSP /* CSP chip on SB16ASP/AWE32 */ @@ -512,7 +471,7 @@ static int __init snd_sb16_probe(int dev, seq_ports[dev], NULL)) < 0) { snd_printk(KERN_ERR PFX "fatal error - EMU-8000 synthesizer not detected at 0x%lx\n", awe_port[dev]); - goto _err; + return err; } } #endif @@ -524,56 +483,168 @@ static int __init snd_sb16_probe(int dev, (mic_agc[dev] ? 0x00 : 0x01)); spin_unlock_irqrestore(&chip->mixer_lock, flags); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - if ((err = snd_card_register(card)) < 0) - goto _err; + return err; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_sb16_legacy[dev] = card; return 0; +} + +#ifdef CONFIG_PM +static int snd_sb16_suspend(struct snd_card *card, pm_message_t state) +{ + struct snd_card_sb16 *acard = card->private_data; + struct snd_sb *chip = acard->chip; - _err: - snd_card_free(card); - return err; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; } -static int __init snd_sb16_probe_legacy_port(unsigned long xport) +static int snd_sb16_resume(struct snd_card *card) { - static int dev; - int res; + struct snd_card_sb16 *acard = card->private_data; + struct snd_sb *chip = acard->chip; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - if (is_isapnp_selected(dev)) - continue; - port[dev] = xport; - res = snd_sb16_probe(dev, NULL, NULL); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + +static int __init snd_sb16_nonpnp_probe1(int dev, struct platform_device *devptr) +{ + struct snd_card_sb16 *acard; + struct snd_card *card; + int err; + + card = snd_sb16_card_new(dev); + if (! card) + return -ENOMEM; + + acard = card->private_data; + /* non-PnP FM port address is hardwired with base port address */ + fm_port[dev] = port[dev]; + /* block the 0x388 port to avoid PnP conflicts */ + acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); +#ifdef SNDRV_SBAWE_EMU8000 + /* non-PnP AWE port address is hardwired with base port address */ + awe_port[dev] = port[dev] + 0x400; +#endif + + snd_card_set_dev(card, &devptr->dev); + if ((err = snd_sb16_probe(card, dev)) < 0) { + snd_card_free(card); + return err; } - return -ENODEV; + platform_set_drvdata(devptr, card); + return 0; } + +static int __init snd_sb16_nonpnp_probe(struct platform_device *pdev) +{ + int dev = pdev->id; + int err; + static int possible_irqs[] = {5, 9, 10, 7, -1}; + static int possible_dmas8[] = {1, 3, 0, -1}; + static int possible_dmas16[] = {5, 6, 7, -1}; + + if (irq[dev] == SNDRV_AUTO_IRQ) { + if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (dma8[dev] == SNDRV_AUTO_DMA) { + if ((dma8[dev] = snd_legacy_find_free_dma(possible_dmas8)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free 8-bit DMA\n"); + return -EBUSY; + } + } + if (dma16[dev] == SNDRV_AUTO_DMA) { + if ((dma16[dev] = snd_legacy_find_free_dma(possible_dmas16)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free 16-bit DMA\n"); + return -EBUSY; + } + } + + if (port[dev] != SNDRV_AUTO_PORT) + return snd_sb16_nonpnp_probe1(dev, pdev); + else { + static int possible_ports[] = {0x220, 0x240, 0x260, 0x280}; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + port[dev] = possible_ports[i]; + err = snd_sb16_nonpnp_probe1(dev, pdev); + if (! err) + return 0; + } + return err; + } +} + +static int __devexit snd_sb16_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_sb16_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_sb16_suspend(platform_get_drvdata(dev), state); +} + +static int snd_sb16_nonpnp_resume(struct platform_device *dev) +{ + return snd_sb16_resume(platform_get_drvdata(dev)); +} +#endif + +#ifdef SNDRV_SBAWE +#define SND_SB16_DRIVER "snd_sbawe" +#else +#define SND_SB16_DRIVER "snd_sb16" +#endif + +static struct platform_driver snd_sb16_nonpnp_driver = { + .probe = snd_sb16_nonpnp_probe, + .remove = __devexit_p(snd_sb16_nonpnp_remove), +#ifdef CONFIG_PM + .suspend = snd_sb16_nonpnp_suspend, + .resume = snd_sb16_nonpnp_resume, +#endif + .driver = { + .name = SND_SB16_DRIVER + }, +}; + + #ifdef CONFIG_PNP -static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { if (!enable[dev] || !isapnp[dev]) continue; - res = snd_sb16_probe(dev, card, id); - if (res < 0) + card = snd_sb16_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_card_sb16_pnp(dev, card->private_data, pcard, pid)) < 0 || + (res = snd_sb16_probe(card, dev)) < 0) { + snd_card_free(card); return res; + } + pnp_set_card_drvdata(pcard, card); dev++; return 0; } @@ -583,50 +654,63 @@ static int __devinit snd_sb16_pnp_detect(struct pnp_card_link *card, static void __devexit snd_sb16_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} - snd_card_disconnect(card); - snd_card_free_in_thread(card); +#ifdef CONFIG_PM +static int snd_sb16_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_sb16_suspend(pnp_get_card_drvdata(pcard), state); } +static int snd_sb16_pnp_resume(struct pnp_card_link *pcard) +{ + return snd_sb16_resume(pnp_get_card_drvdata(pcard)); +} +#endif static struct pnp_card_driver sb16_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, +#ifdef SNDRV_SBAWE + .name = "sbawe", +#else .name = "sb16", +#endif .id_table = snd_sb16_pnpids, .probe = snd_sb16_pnp_detect, .remove = __devexit_p(snd_sb16_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_sb16_pnp_suspend, + .resume = snd_sb16_pnp_resume, +#endif }; #endif /* CONFIG_PNP */ static int __init alsa_card_sb16_init(void) { - int dev, cards = 0, i; - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280, -1}; + int i, err, cards = 0; - /* legacy non-auto cards at first */ - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) - continue; - if (is_isapnp_selected(dev)) - continue; - if (!snd_sb16_probe(dev, NULL, NULL)) { - cards++; + if ((err = platform_driver_register(&snd_sb16_nonpnp_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + if (is_isapnp_selected(i)) continue; + device = platform_device_register_simple(SND_SB16_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + platform_driver_unregister(&snd_sb16_nonpnp_driver); + return err; } -#ifdef MODULE - snd_printk(KERN_ERR "Sound Blaster 16+ soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]); -#endif + cards++; } - /* legacy auto configured cards */ - i = snd_legacy_auto_probe(possible_ports, snd_sb16_probe_legacy_port); - if (i > 0) - cards += i; - #ifdef CONFIG_PNP /* PnP cards at last */ i = pnp_register_card_driver(&sb16_pnpc_driver); - if (i >0) + if (i > 0) cards += i; #endif @@ -634,6 +718,7 @@ static int __init alsa_card_sb16_init(void) #ifdef CONFIG_PNP pnp_unregister_card_driver(&sb16_pnpc_driver); #endif + platform_driver_unregister(&snd_sb16_nonpnp_driver); #ifdef MODULE snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); #ifdef SNDRV_SBAWE_EMU8000 @@ -649,14 +734,10 @@ static int __init alsa_card_sb16_init(void) static void __exit alsa_card_sb16_exit(void) { - int dev; - #ifdef CONFIG_PNP - /* PnP cards first */ pnp_unregister_card_driver(&sb16_pnpc_driver); #endif - for (dev = 0; dev < SNDRV_CARDS; dev++) - snd_card_free(snd_sb16_legacy[dev]); + platform_driver_unregister(&snd_sb16_nonpnp_driver); } module_init(alsa_card_sb16_init) -- cgit v1.1 From 67be445871bb35c450100753b72392ad6ddc0245 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:55:22 +0100 Subject: [ALSA] sb8 - Use platform_device and add PnP support Modules: SB8 driver Rewrite the probe/remove with platform_device. Add PM support, too. Signed-off-by: Takashi Iwai --- sound/isa/sb/sb8.c | 154 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 107 insertions(+), 47 deletions(-) diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 5116038..0a3d55d 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -21,13 +21,14 @@ #include #include +#include +#include #include #include #include #include #include #include -#define SNDRV_LEGACY_AUTO_PROBE #include MODULE_AUTHOR("Jaroslav Kysela "); @@ -57,10 +58,9 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); struct snd_sb8 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ + struct snd_sb *chip; }; -static struct snd_card *snd_sb8_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - static irqreturn_t snd_sb8_interrupt(int irq, void *dev_id, struct pt_regs *regs) { struct snd_sb *chip = dev_id; @@ -81,8 +81,9 @@ static void snd_sb8_free(struct snd_card *card) release_and_free_resource(acard->fm_res); } -static int __init snd_sb8_probe(int dev) +static int __init snd_sb8_probe(struct platform_device *pdev) { + int dev = pdev->id; struct snd_sb *chip; struct snd_card *card; struct snd_sb8 *acard; @@ -93,20 +94,44 @@ static int __init snd_sb8_probe(int dev) sizeof(struct snd_sb8)); if (card == NULL) return -ENOMEM; - acard = (struct snd_sb8 *)card->private_data; + acard = card->private_data; card->private_free = snd_sb8_free; /* block the 0x388 port to avoid PnP conflicts */ acard->fm_res = request_region(0x388, 4, "SoundBlaster FM"); - if ((err = snd_sbdsp_create(card, port[dev], irq[dev], - snd_sb8_interrupt, - dma8[dev], - -1, - SB_HW_AUTO, - &chip)) < 0) - goto _err; - + if (port[dev] != SNDRV_AUTO_PORT) { + if ((err = snd_sbdsp_create(card, port[dev], irq[dev], + snd_sb8_interrupt, + dma8[dev], + -1, + SB_HW_AUTO, + &chip)) < 0) + goto _err; + } else { + /* auto-probe legacy ports */ + static unsigned long possible_ports[] = { + 0x220, 0x240, 0x260, + }; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + err = snd_sbdsp_create(card, possible_ports[i], + irq[dev], + snd_sb8_interrupt, + dma8[dev], + -1, + SB_HW_AUTO, + &chip); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + if (i >= ARRAY_SIZE(possible_ports)) + goto _err; + } + acard->chip = chip; + if (chip->hardware >= SB_HW_16) { if (chip->hardware == SB_HW_ALS100) snd_printk(KERN_WARNING "ALS100 chip detected at 0x%lx, try snd-als100 module\n", @@ -153,13 +178,12 @@ static int __init snd_sb8_probe(int dev) chip->port, irq[dev], dma8[dev]); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_sb8_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -167,53 +191,89 @@ static int __init snd_sb8_probe(int dev) return err; } -static int __init snd_card_sb8_legacy_auto_probe(unsigned long xport) +static int snd_sb8_remove(struct platform_device *pdev) +{ + snd_card_free(platform_get_drvdata(pdev)); + platform_set_drvdata(pdev, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_sb8_suspend(struct platform_device *dev, pm_message_t state) +{ + struct snd_card *card = platform_get_drvdata(dev); + struct snd_sb8 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; +} + +static int snd_sb8_resume(struct platform_device *dev) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_sb8_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + struct snd_card *card = platform_get_drvdata(dev); + struct snd_sb8 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; } +#endif + +#define SND_SB8_DRIVER "snd_sb8" + +static struct platform_driver snd_sb8_driver = { + .probe = snd_sb8_probe, + .remove = snd_sb8_remove, +#ifdef CONFIG_PM + .suspend = snd_sb8_suspend, + .resume = snd_sb8_resume, +#endif + .driver = { + .name = SND_SB8_DRIVER + }, +}; static int __init alsa_card_sb8_init(void) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_sb8_probe(dev) >= 0) - cards++; + int i, cards, err; + + err = platform_driver_register(&snd_sb8_driver); + if (err < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_SB8_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; } - i = snd_legacy_auto_probe(possible_ports, snd_card_sb8_legacy_auto_probe); - if (i > 0) - cards += i; - if (!cards) { #ifdef MODULE snd_printk(KERN_ERR "Sound Blaster soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_sb8_driver); + return err; } static void __exit alsa_card_sb8_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_sb8_cards[idx]); + platform_driver_unregister(&snd_sb8_driver); } module_init(alsa_card_sb8_init) -- cgit v1.1 From 7a8fef1f95e563a93c7d70048b63c1ca20685a1b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:56:11 +0100 Subject: [ALSA] es968 - Add PM support Modules: ES968 driver Add PM support to es968 driver. Signed-off-by: Takashi Iwai --- sound/isa/sb/es968.c | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/sound/isa/sb/es968.c b/sound/isa/sb/es968.c index f7d1afe..9da80bf 100644 --- a/sound/isa/sb/es968.c +++ b/sound/isa/sb/es968.c @@ -58,6 +58,7 @@ MODULE_PARM_DESC(dma8, "8-bit DMA # for es968 driver."); struct snd_card_es968 { struct pnp_dev *dev; + struct snd_sb *chip; }; static struct pnp_card_device_id snd_es968_pnpids[] = { @@ -135,7 +136,7 @@ static int __init snd_card_es968_probe(int dev, if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_es968))) == NULL) return -ENOMEM; - acard = (struct snd_card_es968 *)card->private_data; + acard = card->private_data; if ((error = snd_card_es968_pnp(dev, acard, pcard, pid))) { snd_card_free(card); return error; @@ -151,6 +152,7 @@ static int __init snd_card_es968_probe(int dev, snd_card_free(card); return error; } + acard->chip = chip; if ((error = snd_sb8dsp_pcm(chip, 0, NULL)) < 0) { snd_card_free(card); @@ -200,11 +202,35 @@ static int __devinit snd_es968_pnp_detect(struct pnp_card_link *card, static void __devexit snd_es968_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_es968_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_es968 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; +} + +static int snd_es968_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_es968 *acard = card->private_data; + struct snd_sb *chip = acard->chip; - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; } +#endif static struct pnp_card_driver es968_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, @@ -212,18 +238,23 @@ static struct pnp_card_driver es968_pnpc_driver = { .id_table = snd_es968_pnpids, .probe = snd_es968_pnp_detect, .remove = __devexit_p(snd_es968_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_es968_pnp_suspend, + .resume = snd_es968_pnp_resume, +#endif }; static int __init alsa_card_es968_init(void) { int cards = pnp_register_card_driver(&es968_pnpc_driver); -#ifdef MODULE - if (cards == 0) { + if (cards <= 0) { pnp_unregister_card_driver(&es968_pnpc_driver); +#ifdef MODULE snd_printk(KERN_ERR "no ES968 based soundcards found\n"); - } #endif - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_es968_exit(void) -- cgit v1.1 From c66d7f72569e304acc134b2561b148fe7c23c0f7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:57:48 +0100 Subject: [ALSA] ad1848 - Add PM support Modules: AD1848 driver Add PM support to ad1848 support code. Signed-off-by: Takashi Iwai --- include/sound/ad1848.h | 5 +++++ sound/isa/ad1848/ad1848_lib.c | 28 +++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/include/sound/ad1848.h b/include/sound/ad1848.h index a038070..1a2759f 100644 --- a/include/sound/ad1848.h +++ b/include/sound/ad1848.h @@ -148,6 +148,11 @@ struct snd_ad1848 { int dma_size; int thinkpad_flag; /* Thinkpad CS4248 needs some extra help */ +#ifdef CONFIG_PM + void (*suspend)(struct snd_ad1848 *chip); + void (*resume)(struct snd_ad1848 *chip); +#endif + spinlock_t reg_lock; struct semaphore open_mutex; }; diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c index 55ba32d..83764c9 100644 --- a/sound/isa/ad1848/ad1848_lib.c +++ b/sound/isa/ad1848/ad1848_lib.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -642,29 +641,30 @@ static void snd_ad1848_thinkpad_twiddle(struct snd_ad1848 *chip, int on) { } #ifdef CONFIG_PM -static int snd_ad1848_suspend(struct snd_card *card, pm_message_t state) +static void snd_ad1848_suspend(struct snd_ad1848 *chip) { - struct snd_ad1848 *chip = card->pm_private_data; - snd_pcm_suspend_all(chip->pcm); - /* FIXME: save registers? */ - if (chip->thinkpad_flag) snd_ad1848_thinkpad_twiddle(chip, 0); - - return 0; } -static int snd_ad1848_resume(struct snd_card *card) +static void snd_ad1848_resume(struct snd_ad1848 *chip) { - struct snd_ad1848 *chip = card->pm_private_data; + int i; if (chip->thinkpad_flag) snd_ad1848_thinkpad_twiddle(chip, 1); - /* FIXME: restore registers? */ + /* clear any pendings IRQ */ + inb(AD1848P(chip, STATUS)); + outb(0, AD1848P(chip, STATUS)); + mb(); - return 0; + snd_ad1848_mce_down(chip); + for (i = 0; i < 16; i++) + snd_ad1848_out(chip, i, chip->image[i]); + snd_ad1848_mce_up(chip); + snd_ad1848_mce_down(chip); } #endif /* CONFIG_PM */ @@ -919,7 +919,6 @@ int snd_ad1848_create(struct snd_card *card, chip->thinkpad_flag = 1; chip->hardware = AD1848_HW_DETECT; /* reset */ snd_ad1848_thinkpad_twiddle(chip, 1); - snd_card_set_isa_pm_callback(card, snd_ad1848_suspend, snd_ad1848_resume, chip); } if (snd_ad1848_probe(chip) < 0) { @@ -933,6 +932,9 @@ int snd_ad1848_create(struct snd_card *card, return err; } + chip->suspend = snd_ad1848_suspend; + chip->resume = snd_ad1848_resume; + *rchip = chip; return 0; } -- cgit v1.1 From 686688458e5814ac0aca44fc2033218a848fd2d0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 16:58:26 +0100 Subject: [ALSA] ad1848 - Use platform_device, add PM Modules: AD1848 driver Rewrite the probe/remove with platform_device. Add the PM support, too. Signed-off-by: Takashi Iwai --- sound/isa/ad1848/ad1848.c | 89 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 16 deletions(-) diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index ffc373b..1019e9f 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include #include @@ -60,11 +62,10 @@ MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver."); module_param_array(thinkpad, bool, NULL, 0444); MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); -static struct snd_card *snd_ad1848_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - -static int __init snd_card_ad1848_probe(int dev) +static int __init snd_ad1848_probe(struct platform_device *pdev) { + int dev = pdev->id; struct snd_card *card; struct snd_ad1848 *chip; struct snd_pcm *pcm; @@ -93,6 +94,7 @@ static int __init snd_card_ad1848_probe(int dev) thinkpad[dev] ? AD1848_HW_THINKPAD : AD1848_HW_DETECT, &chip)) < 0) goto _err; + card->private_data = chip; if ((err = snd_ad1848_pcm(chip, 0, &pcm)) < 0) goto _err; @@ -109,13 +111,12 @@ static int __init snd_card_ad1848_probe(int dev) if (thinkpad[dev]) strcat(card->longname, " [Thinkpad]"); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_ad1848_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -123,29 +124,85 @@ static int __init snd_card_ad1848_probe(int dev) return err; } -static int __init alsa_card_ad1848_init(void) +static int __devexit snd_ad1848_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_ad1848_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1848 *chip = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip->suspend(chip); + return 0; +} + +static int snd_ad1848_resume(struct platform_device *pdev) { - int dev, cards; + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1848 *chip = card->private_data; - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) - if (snd_card_ad1848_probe(dev) >= 0) - cards++; + chip->resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + +#define SND_AD1848_DRIVER "snd_ad1848" + +static struct platform_driver snd_ad1848_driver = { + .probe = snd_ad1848_probe, + .remove = __devexit_p(snd_ad1848_remove), +#ifdef CONFIG_PM + .suspend = snd_ad1848_suspend, + .resume = snd_ad1848_resume, +#endif + .driver = { + .name = SND_AD1848_DRIVER + }, +}; +static int __init alsa_card_ad1848_init(void) +{ + int i, cards, err; + + err = platform_driver_register(&snd_ad1848_driver); + if (err < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_AD1848_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "AD1848 soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_ad1848_driver); + return err; } static void __exit alsa_card_ad1848_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_ad1848_cards[idx]); + platform_driver_unregister(&snd_ad1848_driver); } module_init(alsa_card_ad1848_init) -- cgit v1.1 From 7bb35e20e8a00cf9e3f4e9df0457eee9f312a637 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:00:17 +0100 Subject: [ALSA] cs4231 - Fix PM support Modules: CS4231 driver Fix PM support. Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4231_lib.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index ab9075f..ced22fd 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -1294,8 +1294,7 @@ static void snd_cs4231_suspend(struct snd_cs4231 *chip) int reg; unsigned long flags; - if (chip->pcm) - snd_pcm_suspend_all(chip->pcm); + snd_pcm_suspend_all(chip->pcm); spin_lock_irqsave(&chip->reg_lock, flags); for (reg = 0; reg < 32; reg++) chip->image[reg] = snd_cs4231_in(chip, reg); @@ -1343,22 +1342,6 @@ static void snd_cs4231_resume(struct snd_cs4231 *chip) snd_cs4231_busy_wait(chip); #endif } - -static int snd_cs4231_pm_suspend(struct snd_card *card, pm_message_t state) -{ - struct snd_cs4231 *chip = card->pm_private_data; - if (chip->suspend) - chip->suspend(chip); - return 0; -} - -static int snd_cs4231_pm_resume(struct snd_card *card) -{ - struct snd_cs4231 *chip = card->pm_private_data; - if (chip->resume) - chip->resume(chip); - return 0; -} #endif /* CONFIG_PM */ static int snd_cs4231_free(struct snd_cs4231 *chip) @@ -1516,7 +1499,6 @@ int snd_cs4231_create(struct snd_card *card, /* Power Management */ chip->suspend = snd_cs4231_suspend; chip->resume = snd_cs4231_resume; - snd_card_set_isa_pm_callback(card, snd_cs4231_pm_suspend, snd_cs4231_pm_resume, chip); #endif *rchip = chip; -- cgit v1.1 From 8b91375736ca602a5fc0695b53caa89b6ef263c9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:00:41 +0100 Subject: [ALSA] cs4231 - Use platform_device Modules: CS4231 driver Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4231.c | 96 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 19 deletions(-) diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index a8da879..b5252a5 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -22,6 +22,8 @@ #include #include +#include +#include #include #include #include @@ -64,14 +66,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); -static struct snd_card *snd_cs4231_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - -static int __init snd_card_cs4231_probe(int dev) +static int __init snd_cs4231_probe(struct platform_device *pdev) { + int dev = pdev->id; struct snd_card *card; - struct snd_card_cs4231 *acard; - struct snd_pcm *pcm = NULL; + struct snd_pcm *pcm; struct snd_cs4231 *chip; int err; @@ -90,7 +90,6 @@ static int __init snd_card_cs4231_probe(int dev) card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; - acard = (struct snd_card_cs4231 *)card->private_data; if ((err = snd_cs4231_create(card, port[dev], -1, irq[dev], dma1[dev], @@ -98,6 +97,7 @@ static int __init snd_card_cs4231_probe(int dev) CS4231_HW_DETECT, 0, &chip)) < 0) goto _err; + card->private_data = chip; if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) goto _err; @@ -125,12 +125,12 @@ static int __init snd_card_cs4231_probe(int dev) printk(KERN_WARNING "cs4231: MPU401 not detected\n"); } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_cs4231_cards[dev] = card; + + platform_set_drvdata(pdev, card); return 0; _err: @@ -138,29 +138,87 @@ static int __init snd_card_cs4231_probe(int dev) return err; } -static int __init alsa_card_cs4231_init(void) +static int __devexit snd_cs4231_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_cs4231_suspend(struct platform_device *dev, pm_message_t state) { - int dev, cards; + struct snd_card *card; + struct snd_cs4231 *chip; + card = platform_get_drvdata(dev); + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip = card->private_data; + chip->suspend(chip); + return 0; +} - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (snd_card_cs4231_probe(dev) >= 0) - cards++; +static int snd_cs4231_resume(struct platform_device *dev) +{ + struct snd_card *card; + struct snd_cs4231 *chip; + card = platform_get_drvdata(dev); + chip = card->private_data; + chip->resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + +#define SND_CS4231_DRIVER "snd_cs4231" + +static struct platform_driver snd_cs4231_driver = { + .probe = snd_cs4231_probe, + .remove = __devexit_p(snd_cs4231_remove), +#ifdef CONFIG_PM + .suspend = snd_cs4231_suspend, + .resume = snd_cs4231_resume, +#endif + .driver = { + .name = SND_CS4231_DRIVER + }, +}; + +static int __init alsa_card_cs4231_init(void) +{ + int i, cards, err; + + err = platform_driver_register(&snd_cs4231_driver); + if (err < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_CS4231_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; } if (!cards) { #ifdef MODULE printk(KERN_ERR "CS4231 soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_cs4231_driver); + return err; } static void __exit alsa_card_cs4231_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_cs4231_cards[idx]); + platform_driver_unregister(&snd_cs4231_driver); } module_init(alsa_card_cs4231_init) -- cgit v1.1 From 6bba41ac974ad77aa21d112a368ee565b55f303b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:00:53 +0100 Subject: [ALSA] cs4236 - Use platform_device Modules: CS4236+ driver Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4236.c | 269 ++++++++++++++++++++++++++++++---------------- 1 file changed, 176 insertions(+), 93 deletions(-) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index a28f24c..bc10548 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include #include @@ -123,6 +125,7 @@ module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); struct snd_card_cs4236 { + struct snd_cs4231 *chip; struct resource *res_sb_port; #ifdef CONFIG_PNP struct pnp_dev *wss; @@ -131,8 +134,6 @@ struct snd_card_cs4236 { #endif }; -static struct snd_card *snd_cs4236_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #ifdef CONFIG_PNP #define ISAPNP_CS4232(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ @@ -158,6 +159,8 @@ static struct snd_card *snd_cs4236_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CS4232 +#define CS423X_DRIVER "snd_cs4232" +#define CS423X_ISAPNP_DRIVER "cs4232_isapnp" static struct pnp_card_device_id snd_cs423x_pnpids[] = { /* Philips PCA70PS */ { .id = "CSC0d32", .devs = { { "CSC0000" }, { "CSC0010" }, { "PNPb006" } } }, @@ -177,6 +180,8 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = { { .id = "" } /* end */ }; #else /* CS4236 */ +#define CS423X_DRIVER "snd_cs4236" +#define CS423X_ISAPNP_DRIVER "cs4236_isapnp" static struct pnp_card_device_id snd_cs423x_pnpids[] = { /* Intel Marlin Spike Motherboard - CS4235 */ { .id = "CSC0225", .devs = { { "CSC0000" }, { "CSC0010" }, { "CSC0003" } } }, @@ -375,60 +380,44 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, } #endif /* CONFIG_PNP */ -static void snd_card_cs4236_free(struct snd_card *card) -{ - struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data; - - if (acard) - release_and_free_resource(acard->res_sb_port); -} - #ifdef CONFIG_PNP #define is_isapnp_selected(dev) isapnp[dev] #else #define is_isapnp_selected(dev) 0 #endif -static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static void snd_card_cs4236_free(struct snd_card *card) +{ + struct snd_card_cs4236 *acard = card->private_data; + + release_and_free_resource(acard->res_sb_port); +} + +static struct snd_card *snd_cs423x_card_new(int dev) { struct snd_card *card; - struct snd_card_cs4236 *acard; - struct snd_pcm *pcm = NULL; - struct snd_cs4231 *chip; - struct snd_opl3 *opl3; - int err; - if (! is_isapnp_selected(dev)) { - if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR "specify port\n"); - return -EINVAL; - } - if (cport[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR "specify cport\n"); - return -EINVAL; - } - } card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_cs4236)); if (card == NULL) - return -ENOMEM; - acard = (struct snd_card_cs4236 *)card->private_data; + return NULL; card->private_free = snd_card_cs4236_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_card_cs4236_pnp(dev, acard, pcard, pid))<0) { - printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n"); - goto _err; - } - snd_card_set_dev(card, &pcard->card->dev); - } -#endif + return card; +} + +static int __devinit snd_cs423x_probe(struct snd_card *card, int dev) +{ + struct snd_card_cs4236 *acard; + struct snd_pcm *pcm; + struct snd_cs4231 *chip; + struct snd_opl3 *opl3; + int err; + + acard = card->private_data; if (sb_port[dev] > 0 && sb_port[dev] != SNDRV_AUTO_PORT) if ((acard->res_sb_port = request_region(sb_port[dev], 16, IDENT " SB")) == NULL) { printk(KERN_ERR IDENT ": unable to register SB port at 0x%lx\n", sb_port[dev]); - err = -EBUSY; - goto _err; + return -EBUSY; } #ifdef CS4232 @@ -441,13 +430,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, CS4231_HW_DETECT, 0, &chip)) < 0) - goto _err; + return err; + acard->chip = chip; if ((err = snd_cs4231_pcm(chip, 0, &pcm)) < 0) - goto _err; + return err; if ((err = snd_cs4231_mixer(chip)) < 0) - goto _err; + return err; #else /* CS4236 */ if ((err = snd_cs4236_create(card, @@ -459,13 +449,14 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, CS4231_HW_DETECT, 0, &chip)) < 0) - goto _err; + return err; + acard->chip = chip; if ((err = snd_cs4236_pcm(chip, 0, &pcm)) < 0) - goto _err; + return err; if ((err = snd_cs4236_mixer(chip)) < 0) - goto _err; + return err; #endif strcpy(card->driver, pcm->name); strcpy(card->shortname, pcm->name); @@ -478,7 +469,7 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, sprintf(card->longname + strlen(card->longname), "&%d", dma2[dev]); if ((err = snd_cs4231_timer(chip, 0, NULL)) < 0) - goto _err; + return err; if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { if (snd_opl3_create(card, @@ -487,7 +478,7 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, printk(KERN_WARNING IDENT ": OPL3 not detected\n"); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) - goto _err; + return err; } } @@ -501,77 +492,175 @@ static int __devinit snd_card_cs423x_probe(int dev, struct pnp_card_link *pcard, printk(KERN_WARNING IDENT ": MPU401 not detected\n"); } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + return snd_card_register(card); +} - if ((err = snd_card_register(card)) < 0) - goto _err; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_cs4236_legacy[dev] = card; +static int __init snd_cs423x_nonpnp_probe(struct platform_device *pdev) +{ + int dev = pdev->id; + struct snd_card *card; + int err; + + if (port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR "specify port\n"); + return -EINVAL; + } + if (cport[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR "specify cport\n"); + return -EINVAL; + } + + card = snd_cs423x_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_cs423x_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + + platform_set_drvdata(pdev, card); return 0; +} - _err: - snd_card_free(card); - return err; +static int __devexit snd_cs423x_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#ifdef CONFIG_PM +static int snd_cs423x_suspend(struct snd_card *card) +{ + struct snd_card_cs4236 *acard = card->private_data; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + acard->chip->suspend(acard->chip); + return 0; +} + +static int snd_cs423x_resume(struct snd_card *card) +{ + struct snd_card_cs4236 *acard = card->private_data; + acard->chip->resume(acard->chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} + +static int snd_cs423x_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_cs423x_suspend(platform_get_drvdata(dev)); +} + +static int snd_cs423x_nonpnp_resume(struct platform_device *dev) +{ + return snd_cs423x_resume(platform_get_drvdata(dev)); +} +#endif + +static struct platform_driver snd_cs423x_nonpnp_driver = { + .probe = snd_cs423x_nonpnp_probe, + .remove = __devexit_p(snd_cs423x_nonpnp_remove), +#ifdef CONFIG_PM + .suspend = snd_cs423x_nonpnp_suspend, + .resume = snd_cs423x_nonpnp_resume, +#endif + .driver = { + .name = CS423X_DRIVER + }, +}; + + #ifdef CONFIG_PNP -static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_card_cs423x_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_cs423x_card_new(dev); + if (! card) + return -ENOMEM; + if ((res = snd_card_cs4236_pnp(dev, card->private_data, pcard, pid))<0) { + printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n"); + snd_card_free(card); + return res; } - return -ENODEV; + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_cs423x_probe(card, dev)) < 0) { + snd_card_free(card); + return res; + } + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_cs423x_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } +#ifdef CONFIG_PM +static int snd_cs423x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_cs423x_suspend(pnp_get_card_drvdata(pcard)); +} + +static int snd_cs423x_pnp_resume(struct pnp_card_link *pcard) +{ + return snd_cs423x_resume(pnp_get_card_drvdata(pcard)); +} +#endif + static struct pnp_card_driver cs423x_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, - .name = "cs423x", + .name = CS423X_ISAPNP_DRIVER, .id_table = snd_cs423x_pnpids, .probe = snd_cs423x_pnp_detect, .remove = __devexit_p(snd_cs423x_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_cs423x_pnp_suspend, + .resume = snd_cs423x_pnp_resume, +#endif }; #endif /* CONFIG_PNP */ static int __init alsa_card_cs423x_init(void) { - int dev, cards = 0; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; - if (is_isapnp_selected(dev)) + if ((err = platform_driver_register(&snd_cs423x_nonpnp_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + if (is_isapnp_selected(i)) continue; - if (snd_card_cs423x_probe(dev, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(CS423X_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + platform_driver_unregister(&snd_cs423x_nonpnp_driver); + return err; + } + cards++; } -#ifdef CONFIG_PNP - cards += pnp_register_card_driver(&cs423x_pnpc_driver); -#endif + i = pnp_register_card_driver(&cs423x_pnpc_driver); + if (i > 0) + cards += i; if (!cards) { -#ifdef CONFIG_PNP pnp_unregister_card_driver(&cs423x_pnpc_driver); -#endif + platform_driver_unregister(&snd_cs423x_nonpnp_driver); #ifdef MODULE printk(KERN_ERR IDENT " soundcard not found or device busy\n"); #endif @@ -582,14 +671,8 @@ static int __init alsa_card_cs423x_init(void) static void __exit alsa_card_cs423x_exit(void) { - int idx; - -#ifdef CONFIG_PNP - /* PnP cards first */ pnp_unregister_card_driver(&cs423x_pnpc_driver); -#endif - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_cs4236_legacy[idx]); + platform_driver_unregister(&snd_cs423x_nonpnp_driver); } module_init(alsa_card_cs423x_init) -- cgit v1.1 From 480615f33fa48e1a4db33e40b21d4009250f5b23 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:03:53 +0100 Subject: [ALSA] als100 - Add PM support Modules: ALS100 driver Add PM support to als100 driver. Signed-off-by: Takashi Iwai --- sound/isa/als100.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/sound/isa/als100.c b/sound/isa/als100.c index 0d709bc..9b77c17 100644 --- a/sound/isa/als100.c +++ b/sound/isa/als100.c @@ -83,6 +83,7 @@ struct snd_card_als100 { struct pnp_dev *dev; struct pnp_dev *devmpu; struct pnp_dev *devopl; + struct snd_sb *chip; }; static struct pnp_card_device_id snd_als100_pnpids[] = { @@ -211,7 +212,7 @@ static int __init snd_card_als100_probe(int dev, if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_als100))) == NULL) return -ENOMEM; - acard = (struct snd_card_als100 *)card->private_data; + acard = card->private_data; if ((error = snd_card_als100_pnp(dev, acard, pcard, pid))) { snd_card_free(card); @@ -228,6 +229,7 @@ static int __init snd_card_als100_probe(int dev, snd_card_free(card); return error; } + acard->chip = chip; strcpy(card->driver, "ALS100"); strcpy(card->shortname, "Avance Logic ALS100"); @@ -299,11 +301,35 @@ static int __devinit snd_als100_pnp_detect(struct pnp_card_link *card, static void __devexit snd_als100_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_als100_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_als100 *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; +} + +static int snd_als100_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_als100 *acard = card->private_data; + struct snd_sb *chip = acard->chip; - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; } +#endif static struct pnp_card_driver als100_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, @@ -311,20 +337,25 @@ static struct pnp_card_driver als100_pnpc_driver = { .id_table = snd_als100_pnpids, .probe = snd_als100_pnp_detect, .remove = __devexit_p(snd_als100_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_als100_pnp_suspend, + .resume = snd_als100_pnp_resume, +#endif }; static int __init alsa_card_als100_init(void) { - int cards = 0; + int cards; - cards += pnp_register_card_driver(&als100_pnpc_driver); -#ifdef MODULE - if (!cards) { + cards = pnp_register_card_driver(&als100_pnpc_driver); + if (cards <= 0) { pnp_unregister_card_driver(&als100_pnpc_driver); +#ifdef MODULE snd_printk(KERN_ERR "no ALS100 based soundcards found\n"); - } #endif - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_als100_exit(void) -- cgit v1.1 From b6cc25cae365bada36c9f006e314b998eb2c5e7c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:04:12 +0100 Subject: [ALSA] azt2320 - Add PM support Modules: AZT2320 driver Add PM support to azt2320 driver. Signed-off-by: Takashi Iwai --- sound/isa/azt2320.c | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/sound/isa/azt2320.c b/sound/isa/azt2320.c index db4e733..a530691 100644 --- a/sound/isa/azt2320.c +++ b/sound/isa/azt2320.c @@ -93,6 +93,7 @@ struct snd_card_azt2320 { int dev_no; struct pnp_dev *dev; struct pnp_dev *devmpu; + struct snd_cs4231 *chip; }; static struct pnp_card_device_id snd_azt2320_pnpids[] = { @@ -329,11 +330,33 @@ static int __devinit snd_azt2320_pnp_detect(struct pnp_card_link *card, static void __devexit snd_azt2320_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_azt2320_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_azt2320 *acard = card->private_data; + struct snd_cs4231 *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip->suspend(chip); + return 0; +} + +static int snd_azt2320_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_azt2320 *acard = card->private_data; + struct snd_cs4231 *chip = acard->chip; - snd_card_disconnect(card); - snd_card_free_in_thread(card); + chip->resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; } +#endif static struct pnp_card_driver azt2320_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, @@ -341,20 +364,25 @@ static struct pnp_card_driver azt2320_pnpc_driver = { .id_table = snd_azt2320_pnpids, .probe = snd_azt2320_pnp_detect, .remove = __devexit_p(snd_azt2320_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_azt2320_pnp_suspend, + .resume = snd_azt2320_pnp_resume, +#endif }; static int __init alsa_card_azt2320_init(void) { - int cards = 0; + int cards; - cards += pnp_register_card_driver(&azt2320_pnpc_driver); -#ifdef MODULE - if (!cards) { + cards = pnp_register_card_driver(&azt2320_pnpc_driver); + if (cards <= 0) { pnp_unregister_card_driver(&azt2320_pnpc_driver); +#ifdef MODULE snd_printk(KERN_ERR "no AZT2320 based soundcards found\n"); - } #endif - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_azt2320_exit(void) -- cgit v1.1 From e2fa213591518bb1387f6042b8572c76ecdc6c6e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:04:35 +0100 Subject: [ALSA] dt019x - Add PM support Modules: DT019x driver Add PM support to dt019x driver. Signed-off-by: Takashi Iwai --- sound/isa/dt019x.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/sound/isa/dt019x.c b/sound/isa/dt019x.c index 7559956..50e7bc5 100644 --- a/sound/isa/dt019x.c +++ b/sound/isa/dt019x.c @@ -74,6 +74,7 @@ struct snd_card_dt019x { struct pnp_dev *dev; struct pnp_dev *devmpu; struct pnp_dev *devopl; + struct snd_sb *chip; }; static struct pnp_card_device_id snd_dt019x_pnpids[] = { @@ -196,7 +197,7 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_card_dt019x))) == NULL) return -ENOMEM; - acard = (struct snd_card_dt019x *)card->private_data; + acard = card->private_data; snd_card_set_dev(card, &pcard->card->dev); if ((error = snd_card_dt019x_pnp(dev, acard, pcard, pid))) { @@ -214,6 +215,7 @@ static int __devinit snd_card_dt019x_probe(int dev, struct pnp_card_link *pcard, snd_card_free(card); return error; } + acard->chip = chip; strcpy(card->driver, "DT-019X"); strcpy(card->shortname, "Diamond Tech. DT-019X"); @@ -290,10 +292,35 @@ static int __devinit snd_dt019x_pnp_probe(struct pnp_card_link *card, static void __devexit snd_dt019x_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} + +#ifdef CONFIG_PM +static int snd_dt019x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_dt019x *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(chip->pcm); + snd_sbmixer_suspend(chip); + return 0; +} + +static int snd_dt019x_pnp_resume(struct pnp_card_link *pcard) +{ + struct snd_card *card = pnp_get_card_drvdata(pcard); + struct snd_card_dt019x *acard = card->private_data; + struct snd_sb *chip = acard->chip; + + snd_sbdsp_reset(chip); + snd_sbmixer_resume(chip); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; } +#endif static struct pnp_card_driver dt019x_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, @@ -301,21 +328,25 @@ static struct pnp_card_driver dt019x_pnpc_driver = { .id_table = snd_dt019x_pnpids, .probe = snd_dt019x_pnp_probe, .remove = __devexit_p(snd_dt019x_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_dt019x_pnp_suspend, + .resume = snd_dt019x_pnp_resume, +#endif }; static int __init alsa_card_dt019x_init(void) { int cards = 0; - cards += pnp_register_card_driver(&dt019x_pnpc_driver); - -#ifdef MODULE - if (!cards) { + cards = pnp_register_card_driver(&dt019x_pnpc_driver); + if (cards <= 0) { pnp_unregister_card_driver(&dt019x_pnpc_driver); +#ifdef MODULE snd_printk(KERN_ERR "no DT-019X / ALS-007 based soundcards found\n"); - } #endif - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_dt019x_exit(void) -- cgit v1.1 From 175cdcfb113e2a72f9d1a2ced4b80e0ff17fcaae Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:05:02 +0100 Subject: [ALSA] ad1816a - Clean up PnP code Modules: AD1816A driver Clean up PnP code of ad1816a driver. Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/ad1816a.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c index 543a4e2..7051f77 100644 --- a/sound/isa/ad1816a/ad1816a.c +++ b/sound/isa/ad1816a/ad1816a.c @@ -282,10 +282,8 @@ static int __devinit snd_ad1816a_pnp_detect(struct pnp_card_link *card, static void __devexit snd_ad1816a_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } static struct pnp_card_driver ad1816a_pnpc_driver = { @@ -294,20 +292,22 @@ static struct pnp_card_driver ad1816a_pnpc_driver = { .id_table = snd_ad1816a_pnpids, .probe = snd_ad1816a_pnp_detect, .remove = __devexit_p(snd_ad1816a_pnp_remove), + /* FIXME: suspend/resume */ }; static int __init alsa_card_ad1816a_init(void) { - int cards = 0; + int cards; - cards += pnp_register_card_driver(&ad1816a_pnpc_driver); -#ifdef MODULE - if (!cards) { + cards = pnp_register_card_driver(&ad1816a_pnpc_driver); + if (cards <= 0) { pnp_unregister_card_driver(&ad1816a_pnpc_driver); +#ifdef MODULE printk(KERN_ERR "no AD1816A based soundcards found.\n"); - } #endif /* MODULE */ - return cards ? 0 : -ENODEV; + return -ENODEV; + } + return 0; } static void __exit alsa_card_ad1816a_exit(void) -- cgit v1.1 From acdcbc15426b91b0041756a92ea4932c60def189 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:11:35 +0100 Subject: [ALSA] cmi8330 - Use platform_device, add PM support Modules: CMI8330 driver Rewrite the probe/remove with platform_device. Also, add the PM support. Signed-off-by: Takashi Iwai --- sound/isa/cmi8330.c | 241 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 163 insertions(+), 78 deletions(-) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index cf16006..ba0114e 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -45,6 +45,8 @@ #include #include +#include +#include #include #include #include @@ -156,8 +158,6 @@ struct snd_cmi8330 { } streams[2]; }; -static struct snd_card *snd_cmi8330_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #ifdef CONFIG_PNP static struct pnp_card_device_id snd_cmi8330_pnpids[] = { @@ -429,6 +429,31 @@ static int __devinit snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 * } +#ifdef CONFIG_PM +static int snd_cmi8330_suspend(struct snd_card *card) +{ + struct snd_cmi8330 *acard = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + snd_pcm_suspend_all(acard->pcm); + acard->wss->suspend(acard->wss); + snd_sbmixer_suspend(acard->sb); + return 0; +} + +static int snd_cmi8330_resume(struct snd_card *card) +{ + struct snd_cmi8330 *acard = card->private_data; + + snd_sbdsp_reset(acard->sb); + snd_sbmixer_suspend(acard->sb); + acard->wss->resume(acard->wss); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + + /* */ @@ -440,44 +465,28 @@ static int __devinit snd_cmi8330_pcm(struct snd_card *card, struct snd_cmi8330 * #define PFX "cmi8330: " -static int __devinit snd_cmi8330_probe(int dev, - struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_cmi8330_card_new(int dev) { struct snd_card *card; struct snd_cmi8330 *acard; - int i, err; - - if (! is_isapnp_selected(dev)) { - if (wssport[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify wssport\n"); - return -EINVAL; - } - if (sbport[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify sbport\n"); - return -EINVAL; - } - } card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_cmi8330)); if (card == NULL) { snd_printk(KERN_ERR PFX "could not get a new card\n"); - return -ENOMEM; + return NULL; } - acard = (struct snd_cmi8330 *)card->private_data; + acard = card->private_data; acard->card = card; + return card; +} -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_cmi8330_pnp(dev, acard, pcard, pid)) < 0) { - snd_printk(KERN_ERR PFX "PnP detection failed\n"); - goto _err; - } - snd_card_set_dev(card, &pcard->card->dev); - } -#endif +static int __devinit snd_cmi8330_probe(struct snd_card *card, int dev) +{ + struct snd_cmi8330 *acard; + int i, err; + acard = card->private_data; if ((err = snd_ad1848_create(card, wssport[dev] + 4, wssirq[dev], @@ -485,12 +494,11 @@ static int __devinit snd_cmi8330_probe(int dev, AD1848_HW_DETECT, &acard->wss)) < 0) { snd_printk(KERN_ERR PFX "(AD1848) device busy??\n"); - goto _err; + return err; } if (acard->wss->hardware != AD1848_HW_CMI8330) { snd_printk(KERN_ERR PFX "(AD1848) not found during probe\n"); - err = -ENODEV; - goto _err; + return -ENODEV; } if ((err = snd_sbdsp_create(card, sbport[dev], @@ -500,11 +508,11 @@ static int __devinit snd_cmi8330_probe(int dev, sbdma16[dev], SB_HW_AUTO, &acard->sb)) < 0) { snd_printk(KERN_ERR PFX "(SB16) device busy??\n"); - goto _err; + return err; } if (acard->sb->hardware != SB_HW_16) { snd_printk(KERN_ERR PFX "(SB16) not found during probe\n"); - goto _err; + return err; } snd_ad1848_out(acard->wss, AD1848_MISC_INFO, 0x40); /* switch on MODE2 */ @@ -513,12 +521,12 @@ static int __devinit snd_cmi8330_probe(int dev, if ((err = snd_cmi8330_mixer(card, acard)) < 0) { snd_printk(KERN_ERR PFX "failed to create mixers\n"); - goto _err; + return err; } if ((err = snd_cmi8330_pcm(card, acard)) < 0) { snd_printk(KERN_ERR PFX "failed to create pcms\n"); - goto _err; + return err; } strcpy(card->driver, "CMI8330/C3D"); @@ -529,79 +537,162 @@ static int __devinit snd_cmi8330_probe(int dev, wssirq[dev], wssdma[dev]); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + return snd_card_register(card); +} + +static int __init snd_cmi8330_nonpnp_probe(struct platform_device *pdev) +{ + struct snd_card *card; + int err; + int dev = pdev->id; - if ((err = snd_card_register(card)) < 0) - goto _err; + if (wssport[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify wssport\n"); + return -EINVAL; + } + if (sbport[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify sbport\n"); + return -EINVAL; + } - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_cmi8330_legacy[dev] = card; + card = snd_cmi8330_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_cmi8330_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(pdev, card); return 0; +} + +static int snd_cmi8330_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} - _err: - snd_card_free(card); - return err; +#ifdef CONFIG_PM +static int snd_cmi8330_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_cmi8330_suspend(platform_get_drvdata(dev)); } +static int snd_cmi8330_nonpnp_resume(struct platform_device *dev) +{ + return snd_cmi8330_resume(platform_get_drvdata(dev)); +} +#endif + +#define CMI8330_DRIVER "snd_cmi8330" + +static struct platform_driver snd_cmi8330_driver = { + .probe = snd_cmi8330_nonpnp_probe, + .remove = snd_cmi8330_nonpnp_remove, +#ifdef CONFIG_PM + .suspend = snd_cmi8330_nonpnp_suspend, + .resume = snd_cmi8330_nonpnp_resume, +#endif + .driver = { + .name = CMI8330_DRIVER + }, +}; + + #ifdef CONFIG_PNP -static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_cmi8330_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_cmi8330_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_cmi8330_card_new(dev); + if (! card) + return -ENOMEM; + if ((res = snd_cmi8330_pnp(dev, card->private_data, pcard, pid)) < 0) { + snd_printk(KERN_ERR PFX "PnP detection failed\n"); + snd_card_free(card); + return res; + } + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_cmi8330_probe(card, dev)) < 0) { + snd_card_free(card); + return res; } - return -ENODEV; + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_cmi8330_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} - snd_card_disconnect(card); - snd_card_free_in_thread(card); +#ifdef CONFIG_PM +static int snd_cmi8330_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_cmi8330_suspend(pnp_get_card_drvdata(pcard)); } +static int snd_cmi8330_pnp_resume(struct pnp_card_link *pcard) +{ + return snd_cmi8330_resume(pnp_get_card_drvdata(pcard)); +} +#endif + static struct pnp_card_driver cmi8330_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "cmi8330", .id_table = snd_cmi8330_pnpids, .probe = snd_cmi8330_pnp_detect, .remove = __devexit_p(snd_cmi8330_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_cmi8330_pnp_suspend, + .resume = snd_cmi8330_pnp_resume, +#endif }; #endif /* CONFIG_PNP */ static int __init alsa_card_cmi8330_init(void) { - int dev, cards = 0; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; - if (is_isapnp_selected(dev)) + if ((err = platform_driver_register(&snd_cmi8330_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + if (is_isapnp_selected(i)) continue; - if (snd_cmi8330_probe(dev, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(CMI8330_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + platform_driver_unregister(&snd_cmi8330_driver); + return err; + } + cards++; } -#ifdef CONFIG_PNP - cards += pnp_register_card_driver(&cmi8330_pnpc_driver); -#endif + + err = pnp_register_card_driver(&cmi8330_pnpc_driver); + if (err > 0) + cards += err; if (!cards) { -#ifdef CONFIG_PNP pnp_unregister_card_driver(&cmi8330_pnpc_driver); -#endif + platform_driver_unregister(&snd_cmi8330_driver); #ifdef MODULE snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); #endif @@ -612,14 +703,8 @@ static int __init alsa_card_cmi8330_init(void) static void __exit alsa_card_cmi8330_exit(void) { - int i; - -#ifdef CONFIG_PNP - /* PnP cards first */ pnp_unregister_card_driver(&cmi8330_pnpc_driver); -#endif - for (i = 0; i < SNDRV_CARDS; i++) - snd_card_free(snd_cmi8330_legacy[i]); + platform_driver_unregister(&snd_cmi8330_driver); } module_init(alsa_card_cmi8330_init) -- cgit v1.1 From 704e05204c623136ea12411dc4286d1caea6cd7c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:11:53 +0100 Subject: [ALSA] opl3sa2 - Use platform_device Modules: OPL3SA2 driver Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/opl3sa2.c | 428 ++++++++++++++++++++++++++++------------------------ 1 file changed, 228 insertions(+), 200 deletions(-) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index a343af7..b923de9 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include #include @@ -126,21 +128,12 @@ struct snd_opl3sa2 { struct snd_hwdep *synth; struct snd_rawmidi *rmidi; struct snd_cs4231 *cs4231; -#ifdef CONFIG_PNP - struct pnp_dev *dev; -#endif unsigned char ctlregs[0x20]; int ymode; /* SL added */ struct snd_kcontrol *master_switch; struct snd_kcontrol *master_volume; -#ifdef CONFIG_PM - void (*cs4231_suspend)(struct snd_cs4231 *); - void (*cs4231_resume)(struct snd_cs4231 *); -#endif }; -static struct snd_card *snd_opl3sa2_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #define PFX "opl3sa2: " #ifdef CONFIG_PNP @@ -539,11 +532,10 @@ static int __init snd_opl3sa2_mixer(struct snd_opl3sa2 *chip) #ifdef CONFIG_PM static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state) { - struct snd_opl3sa2 *chip = card->pm_private_data; - - snd_pcm_suspend_all(chip->cs4231->pcm); /* stop before saving regs */ - chip->cs4231_suspend(chip->cs4231); + struct snd_opl3sa2 *chip = card->private_data; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip->cs4231->suspend(chip->cs4231); /* power down */ snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3); @@ -552,7 +544,7 @@ static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state) static int snd_opl3sa2_resume(struct snd_card *card) { - struct snd_opl3sa2 *chip = card->pm_private_data; + struct snd_opl3sa2 *chip = card->private_data; int i; /* power up */ @@ -568,23 +560,20 @@ static int snd_opl3sa2_resume(struct snd_card *card) snd_opl3sa2_write(chip, i, chip->ctlregs[i]); } /* restore cs4231 */ - chip->cs4231_resume(chip->cs4231); + chip->cs4231->resume(chip->cs4231); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ #ifdef CONFIG_PNP static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, - struct pnp_dev *pdev, - int isapnp) + struct pnp_dev *pdev) { struct pnp_resource_table * cfg; int err; - if (!isapnp && pnp_device_is_isapnp(pdev)) - return -ENOENT; /* we have another procedure - card */ - cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); if (!cfg) return -ENOMEM; @@ -607,7 +596,7 @@ static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, if (irq[dev] != SNDRV_AUTO_IRQ) pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); err = pnp_manual_config_dev(pdev, cfg, 0); - if (err < 0 && isapnp) + if (err < 0) snd_printk(KERN_ERR "PnP manual resources are invalid, using auto config\n"); err = pnp_activate_dev(pdev); if (err < 0) { @@ -628,111 +617,47 @@ static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, snd_printdd("%sPnP OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n", pnp_device_is_pnpbios(pdev) ? "BIOS" : "ISA", port[dev], dma1[dev], dma2[dev], irq[dev]); kfree(cfg); - chip->dev = pdev; return 0; } - -static int __init snd_opl3sa2_cpnp(int dev, struct snd_opl3sa2 *chip, - struct pnp_card_link *card, - const struct pnp_card_device_id *id) -{ - struct pnp_dev *pdev; - struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); - - if (!cfg) - return -ENOMEM; - pdev = pnp_request_card_device(card, id->devs[0].id, NULL); - if (pdev == NULL) { - kfree(cfg); - return -EBUSY; - } - return snd_opl3sa2_pnp(dev, chip, pdev, 1); -} #endif /* CONFIG_PNP */ -static int snd_opl3sa2_free(struct snd_opl3sa2 *chip) +static void snd_opl3sa2_free(struct snd_card *card) { + struct snd_opl3sa2 *chip = card->private_data; if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); release_and_free_resource(chip->res_port); - kfree(chip); - return 0; } -static int snd_opl3sa2_dev_free(struct snd_device *device) +static struct snd_card *snd_opl3sa2_card_new(int dev) { - struct snd_opl3sa2 *chip = device->device_data; - return snd_opl3sa2_free(chip); -} - -#ifdef CONFIG_PNP -#define is_isapnp_selected(dev) isapnp[dev] -#else -#define is_isapnp_selected(dev) 0 -#endif - -static int __devinit snd_opl3sa2_probe(int dev, - struct pnp_dev *pdev, - struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) -{ - int xirq, xdma1, xdma2; struct snd_card *card; struct snd_opl3sa2 *chip; - struct snd_cs4231 *cs4231; - struct snd_opl3 *opl3; - static struct snd_device_ops ops = { - .dev_free = snd_opl3sa2_dev_free, - }; - int err; - if (! is_isapnp_selected(dev)) { - if (port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify port\n"); - return -EINVAL; - } - if (wss_port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify wss_port\n"); - return -EINVAL; - } - if (fm_port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify fm_port\n"); - return -EINVAL; - } - if (midi_port[dev] == SNDRV_AUTO_PORT) { - snd_printk(KERN_ERR PFX "specify midi_port\n"); - return -EINVAL; - } - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_opl3sa2)); if (card == NULL) - return -ENOMEM; + return NULL; strcpy(card->driver, "OPL3SA2"); strcpy(card->shortname, "Yamaha OPL3-SA2"); - chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (chip == NULL) { - err = -ENOMEM; - goto __error; - } + chip = card->private_data; spin_lock_init(&chip->reg_lock); chip->irq = -1; - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) - goto __error; -#ifdef CONFIG_PNP - if (pdev) { - if ((err = snd_opl3sa2_pnp(dev, chip, pdev, 0)) < 0) - goto __error; - snd_card_set_dev(card, &pdev->dev); - } - if (pcard) { - if ((err = snd_opl3sa2_cpnp(dev, chip, pcard, pid)) < 0) - goto __error; - snd_card_set_dev(card, &pcard->card->dev); - } -#endif - chip->ymode = opl3sa3_ymode[dev] & 0x03 ; /* initialise this card from supplied (or default) parameter*/ chip->card = card; + card->private_free = snd_opl3sa2_free; + return card; +} + +static int __devinit snd_opl3sa2_probe(struct snd_card *card, int dev) +{ + int xirq, xdma1, xdma2; + struct snd_opl3sa2 *chip; + struct snd_cs4231 *cs4231; + struct snd_opl3 *opl3; + int err; + + /* initialise this card from supplied (or default) parameter*/ + chip = card->private_data; + chip->ymode = opl3sa3_ymode[dev] & 0x03 ; chip->port = port[dev]; xirq = irq[dev]; xdma1 = dma1[dev]; @@ -740,11 +665,10 @@ static int __devinit snd_opl3sa2_probe(int dev, if (xdma2 < 0) chip->single_dma = 1; if ((err = snd_opl3sa2_detect(chip)) < 0) - goto __error; - if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", (void *)chip)) { + return err; + if (request_irq(xirq, snd_opl3sa2_interrupt, SA_INTERRUPT, "OPL3-SA2", chip)) { snd_printk(KERN_ERR PFX "can't grab IRQ %d\n", xirq); - err = -ENODEV; - goto __error; + return -ENODEV; } chip->irq = xirq; if ((err = snd_cs4231_create(card, @@ -754,163 +678,273 @@ static int __devinit snd_opl3sa2_probe(int dev, CS4231_HWSHARE_IRQ, &cs4231)) < 0) { snd_printd("Oops, WSS not detected at 0x%lx\n", wss_port[dev] + 4); - goto __error; + return err; } chip->cs4231 = cs4231; if ((err = snd_cs4231_pcm(cs4231, 0, NULL)) < 0) - goto __error; + return err; if ((err = snd_cs4231_mixer(cs4231)) < 0) - goto __error; + return err; if ((err = snd_opl3sa2_mixer(chip)) < 0) - goto __error; + return err; if ((err = snd_cs4231_timer(cs4231, 0, NULL)) < 0) - goto __error; + return err; if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) { if ((err = snd_opl3_create(card, fm_port[dev], fm_port[dev] + 2, OPL3_HW_OPL3, 0, &opl3)) < 0) - goto __error; + return err; if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0) - goto __error; + return err; if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth)) < 0) - goto __error; + return err; } if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) { if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2, midi_port[dev], 0, xirq, 0, &chip->rmidi)) < 0) - goto __error; + return err; } -#ifdef CONFIG_PM - chip->cs4231_suspend = chip->cs4231->suspend; - chip->cs4231_resume = chip->cs4231->resume; - /* now clear callbacks for cs4231 */ - chip->cs4231->suspend = NULL; - chip->cs4231->resume = NULL; - snd_card_set_isa_pm_callback(card, snd_opl3sa2_suspend, snd_opl3sa2_resume, chip); -#endif - sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", card->shortname, chip->port, xirq, xdma1); if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto __error; - - if ((err = snd_card_register(card)) < 0) - goto __error; - - if (pdev) - pnp_set_drvdata(pdev, card); - else if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_opl3sa2_legacy[dev] = card; - return 0; - - __error: - snd_card_free(card); - return err; + return snd_card_register(card); } #ifdef CONFIG_PNP static int __devinit snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, const struct pnp_device_id *id) { - static int dev; - int res; + static int dev; + int err; + struct snd_card *card; + + if (pnp_device_is_isapnp(pdev)) + return -ENOENT; /* we have another procedure - card */ + for (; dev < SNDRV_CARDS; dev++) { + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_opl3sa2_probe(dev, pdev, NULL, NULL); - if (res < 0) - return res; - dev++; - return 0; - } - return -ENODEV; + card = snd_opl3sa2_card_new(dev); + if (! card) + return -ENOMEM; + if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { + snd_card_free(card); + return err; + } + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_opl3sa2_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + pnp_set_drvdata(pdev, card); + dev++; + return 0; } static void __devexit snd_opl3sa2_pnp_remove(struct pnp_dev * pdev) { - struct snd_card *card = (struct snd_card *) pnp_get_drvdata(pdev); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_drvdata(pdev)); + pnp_set_drvdata(pdev, NULL); } +#ifdef CONFIG_PM +static int snd_opl3sa2_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) +{ + return snd_opl3sa2_suspend(pnp_get_drvdata(pdev), state); +} +static int snd_opl3sa2_pnp_resume(struct pnp_dev *pdev) +{ + return snd_opl3sa2_resume(pnp_get_drvdata(pdev)); +} +#endif + static struct pnp_driver opl3sa2_pnp_driver = { .name = "opl3sa2-pnpbios", .id_table = snd_opl3sa2_pnpbiosids, .probe = snd_opl3sa2_pnp_detect, .remove = __devexit_p(snd_opl3sa2_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_opl3sa2_pnp_suspend, + .resume = snd_opl3sa2_pnp_resume, +#endif }; -static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *card, +static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, const struct pnp_card_device_id *id) { - static int dev; - int res; + static int dev; + struct pnp_dev *pdev; + int err; + struct snd_card *card; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; - if (is_isapnp_selected(dev)) - continue; - res = snd_opl3sa2_probe(dev, NULL, card, id); - if (res < 0) - return res; - dev++; - return 0; - } - return -ENODEV; + pdev = pnp_request_card_device(pcard, id->devs[0].id, NULL); + if (pdev == NULL) + return -EBUSY; + for (; dev < SNDRV_CARDS; dev++) { + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_opl3sa2_card_new(dev); + if (! card) + return -ENOMEM; + if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { + snd_card_free(card); + return err; + } + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_opl3sa2_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_opl3sa2_pnp_cremove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } +#ifdef CONFIG_PM +static int snd_opl3sa2_pnp_csuspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_opl3sa2_suspend(pnp_get_card_drvdata(pcard), state); +} +static int snd_opl3sa2_pnp_cresume(struct pnp_card_link *pcard) +{ + return snd_opl3sa2_resume(pnp_get_card_drvdata(pcard)); +} +#endif + static struct pnp_card_driver opl3sa2_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "opl3sa2", .id_table = snd_opl3sa2_pnpids, .probe = snd_opl3sa2_pnp_cdetect, .remove = __devexit_p(snd_opl3sa2_pnp_cremove), +#ifdef CONFIG_PM + .suspend = snd_opl3sa2_pnp_csuspend, + .resume = snd_opl3sa2_pnp_cresume, +#endif }; #endif /* CONFIG_PNP */ +static int __init snd_opl3sa2_nonpnp_probe(struct platform_device *pdev) +{ + struct snd_card *card; + int err; + int dev = pdev->id; + + if (port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify port\n"); + return -EINVAL; + } + if (wss_port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify wss_port\n"); + return -EINVAL; + } + if (fm_port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify fm_port\n"); + return -EINVAL; + } + if (midi_port[dev] == SNDRV_AUTO_PORT) { + snd_printk(KERN_ERR PFX "specify midi_port\n"); + return -EINVAL; + } + + card = snd_opl3sa2_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_opl3sa2_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(pdev, card); + return 0; +} + +static int snd_opl3sa2_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_opl3sa2_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_opl3sa2_suspend(platform_get_drvdata(dev), state); +} + +static int snd_opl3sa2_nonpnp_resume(struct platform_device *dev) +{ + return snd_opl3sa2_resume(platform_get_drvdata(dev)); +} +#endif + +#define OPL3SA2_DRIVER "snd_opl3sa2" + +static struct platform_driver snd_opl3sa2_nonpnp_driver = { + .probe = snd_opl3sa2_nonpnp_probe, + .remove = snd_opl3sa2_nonpnp_remove, +#ifdef CONFIG_PM + .suspend = snd_opl3sa2_nonpnp_suspend, + .resume = snd_opl3sa2_nonpnp_resume, +#endif + .driver = { + .name = OPL3SA2_DRIVER + }, +}; + static int __init alsa_card_opl3sa2_init(void) { - int dev, cards = 0; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; + if ((err = platform_driver_register(&snd_opl3sa2_nonpnp_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; #ifdef CONFIG_PNP - if (isapnp[dev]) + if (isapnp[i]) continue; #endif - if (snd_opl3sa2_probe(dev, NULL, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(OPL3SA2_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); + return err; + } + cards++; } -#ifdef CONFIG_PNP - cards += pnp_register_driver(&opl3sa2_pnp_driver); - cards += pnp_register_card_driver(&opl3sa2_pnpc_driver); -#endif + + err = pnp_register_driver(&opl3sa2_pnp_driver); + if (err > 0) + cards += err; + err = pnp_register_card_driver(&opl3sa2_pnpc_driver); + if (err > 0) + cards += err; + if (!cards) { #ifdef MODULE snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); #endif -#ifdef CONFIG_PNP pnp_unregister_card_driver(&opl3sa2_pnpc_driver); pnp_unregister_driver(&opl3sa2_pnp_driver); -#endif + platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); return -ENODEV; } return 0; @@ -918,15 +952,9 @@ static int __init alsa_card_opl3sa2_init(void) static void __exit alsa_card_opl3sa2_exit(void) { - int idx; - -#ifdef CONFIG_PNP - /* PnP cards first */ pnp_unregister_card_driver(&opl3sa2_pnpc_driver); pnp_unregister_driver(&opl3sa2_pnp_driver); -#endif - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_opl3sa2_legacy[idx]); + platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); } module_init(alsa_card_opl3sa2_init) -- cgit v1.1 From f7e0ba3e440d4aab381dca6d7a7eee8f2faf210b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:12:07 +0100 Subject: [ALSA] es18xx - Use platform_device Modules: ES18xx driver Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/es18xx.c | 328 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 185 insertions(+), 143 deletions(-) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 06c0e77..34d4713 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -65,21 +65,21 @@ #include -#include -#include #include -#include +#include +#include #include #include #include #include +#include +#include #include #include #include #include #include #include -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -128,6 +128,14 @@ struct snd_es18xx { #endif }; +struct snd_audiodrive { + struct snd_es18xx *chip; +#ifdef CONFIG_PNP + struct pnp_dev *dev; + struct pnp_dev *devc; +#endif +}; + #define AUDIO1_IRQ 0x01 #define AUDIO2_IRQ 0x02 #define HWV_IRQ 0x04 @@ -1573,11 +1581,10 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct if (rpcm) *rpcm = NULL; sprintf(str, "ES%x", chip->version); - if (chip->caps & ES18XX_PCM2) { + if (chip->caps & ES18XX_PCM2) err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm); - } else { + else err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); - } if (err < 0) return err; @@ -1608,7 +1615,10 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct #ifdef CONFIG_PM static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) { - struct snd_es18xx *chip = card->pm_private_data; + struct snd_audiodrive *acard = card->private_data; + struct snd_es18xx *chip = acard->chip; + + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); @@ -1623,11 +1633,13 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) static int snd_es18xx_resume(struct snd_card *card) { - struct snd_es18xx *chip = card->pm_private_data; + struct snd_audiodrive *acard = card->private_data; + struct snd_es18xx *chip = acard->chip; /* restore PM register, we won't wake till (not 0x07) i/o activity though */ snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); return 0; } #endif /* CONFIG_PM */ @@ -1865,15 +1877,6 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); -struct snd_audiodrive { -#ifdef CONFIG_PNP - struct pnp_dev *dev; - struct pnp_dev *devc; -#endif -}; - -static struct snd_card *snd_audiodrive_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #ifdef CONFIG_PNP static struct pnp_card_device_id snd_audiodrive_pnpids[] = { @@ -1979,209 +1982,254 @@ static int __devinit snd_audiodrive_pnp(int dev, struct snd_audiodrive *acard, #define is_isapnp_selected(dev) 0 #endif -static int __devinit snd_audiodrive_probe(int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_es18xx_card_new(int dev) { - static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; - static int possible_dmas[] = {1, 0, 3, 5, -1}; - int xirq, xdma1, xdma2; - struct snd_card *card; - struct snd_audiodrive *acard; + return snd_card_new(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_audiodrive)); +} + +static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) +{ + struct snd_audiodrive *acard = card->private_data; struct snd_es18xx *chip; struct snd_opl3 *opl3; int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_audiodrive)); - if (card == NULL) - return -ENOMEM; - acard = (struct snd_audiodrive *)card->private_data; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_audiodrive_pnp(dev, acard, pcard, pid)) < 0) { - snd_card_free(card); - return err; - } - snd_card_set_dev(card, &pcard->card->dev); - } -#endif - - xirq = irq[dev]; - if (xirq == SNDRV_AUTO_IRQ) { - if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - err = -EBUSY; - goto _err; - } - } - xdma1 = dma1[dev]; - if (xdma1 == SNDRV_AUTO_DMA) { - if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); - err = -EBUSY; - goto _err; - } - } - xdma2 = dma2[dev]; - if (xdma2 == SNDRV_AUTO_DMA) { - if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); - err = -EBUSY; - goto _err; - } - } - if ((err = snd_es18xx_new_device(card, port[dev], mpu_port[dev], fm_port[dev], - xirq, xdma1, xdma2, + irq[dev], dma1[dev], dma2[dev], &chip)) < 0) - goto _err; + return err; + acard->chip = chip; sprintf(card->driver, "ES%x", chip->version); + sprintf(card->shortname, "ESS AudioDrive ES%x", chip->version); - if (xdma1 != xdma2) + if (dma1[dev] != dma2[dev]) sprintf(card->longname, "%s at 0x%lx, irq %d, dma1 %d, dma2 %d", card->shortname, chip->port, - xirq, xdma1, xdma2); + irq[dev], dma1[dev], dma2[dev]); else sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", card->shortname, chip->port, - xirq, xdma1); + irq[dev], dma1[dev]); if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) - goto _err; + return err; if ((err = snd_es18xx_mixer(chip)) < 0) - goto _err; + return err; if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { if (snd_opl3_create(card, chip->fm_port, chip->fm_port + 2, OPL3_HW_OPL3, 0, &opl3) < 0) { snd_printk(KERN_WARNING PFX "opl3 not detected at 0x%lx\n", chip->fm_port); } else { if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) - goto _err; + return err; } } if (mpu_port[dev] > 0 && mpu_port[dev] != SNDRV_AUTO_PORT) { if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_ES18XX, chip->mpu_port, 0, - xirq, 0, + irq[dev], 0, &chip->rmidi)) < 0) - goto _err; + return err; } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - - /* Power Management */ - snd_card_set_isa_pm_callback(card, snd_es18xx_suspend, snd_es18xx_resume, chip); + return snd_card_register(card); +} - if ((err = snd_card_register(card)) < 0) - goto _err; +static int __init snd_es18xx_nonpnp_probe1(int dev, struct platform_device *devptr) +{ + struct snd_card *card; + int err; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_audiodrive_legacy[dev] = card; + card = snd_es18xx_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &devptr->dev); + if ((err = snd_audiodrive_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(devptr, card); return 0; - - _err: - snd_card_free(card); - return err; } -static int __devinit snd_audiodrive_probe_legacy_port(unsigned long xport) +static int __init snd_es18xx_nonpnp_probe(struct platform_device *pdev) { - static int dev; - int res; + int dev = pdev->id; + int err; + static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1}; + static int possible_dmas[] = {1, 0, 3, 5, -1}; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - if (is_isapnp_selected(dev)) - continue; - port[dev] = xport; - res = snd_audiodrive_probe(dev, NULL, NULL); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; + if (irq[dev] == SNDRV_AUTO_IRQ) { + if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (dma1[dev] == SNDRV_AUTO_DMA) { + if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + return -EBUSY; + } + } + if (dma2[dev] == SNDRV_AUTO_DMA) { + if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + return -EBUSY; + } + } + + if (port[dev] != SNDRV_AUTO_PORT) { + return snd_es18xx_nonpnp_probe1(dev, pdev); + } else { + static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280}; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + port[dev] = possible_ports[i]; + err = snd_es18xx_nonpnp_probe1(dev, pdev); + if (! err) + return 0; + } + return err; } - return -ENODEV; } +static int __devexit snd_es18xx_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_es18xx_nonpnp_suspend(struct platform_device *dev, pm_message_t state) +{ + return snd_es18xx_suspend(platform_get_drvdata(dev), state); +} + +static int snd_es18xx_nonpnp_resume(struct platform_device *dev) +{ + return snd_es18xx_resume(platform_get_drvdata(dev)); +} +#endif + +#define ES18XX_DRIVER "snd_es18xx" + +static struct platform_driver snd_es18xx_nonpnp_driver = { + .probe = snd_es18xx_nonpnp_probe, + .remove = __devexit_p(snd_es18xx_nonpnp_remove), +#ifdef CONFIG_PM + .suspend = snd_es18xx_nonpnp_suspend, + .resume = snd_es18xx_nonpnp_resume, +#endif + .driver = { + .name = ES18XX_DRIVER + }, +}; + #ifdef CONFIG_PNP -static int __devinit snd_audiodrive_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_audiodrive_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_audiodrive_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; - } + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; - return -ENODEV; + card = snd_es18xx_card_new(dev); + if (! card) + return -ENOMEM; + + if ((res = snd_audiodrive_pnp(dev, card->private_data, pcard, pid)) < 0) { + snd_card_free(card); + return res; + } + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_audiodrive_probe(card, dev)) < 0) { + snd_card_free(card); + return res; + } + + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_audiodrive_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); +} - snd_card_disconnect(card); - snd_card_free_in_thread(card); +#ifdef CONFIG_PM +static int snd_audiodrive_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +{ + return snd_es18xx_suspend(pnp_get_card_drvdata(pcard), state); +} + +static int snd_audiodrive_pnp_resume(struct pnp_card_link *pcard) +{ + return snd_es18xx_resume(pnp_get_card_drvdata(pcard)); } +#endif + static struct pnp_card_driver es18xx_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "es18xx", .id_table = snd_audiodrive_pnpids, .probe = snd_audiodrive_pnp_detect, .remove = __devexit_p(snd_audiodrive_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_audiodrive_pnp_suspend, + .resume = snd_audiodrive_pnp_resume, +#endif }; #endif /* CONFIG_PNP */ static int __init alsa_card_es18xx_init(void) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280, -1}; - int dev, cards = 0, i; + int i, err, cards = 0; - /* legacy non-auto cards at first */ - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) - continue; - if (is_isapnp_selected(dev)) + if ((err = platform_driver_register(&snd_es18xx_nonpnp_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + if (is_isapnp_selected(i)) continue; - if (snd_audiodrive_probe(dev, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(ES18XX_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + platform_driver_unregister(&snd_es18xx_nonpnp_driver); + return err; + } + cards++; } - /* legacy auto configured cards */ - i = snd_legacy_auto_probe(possible_ports, snd_audiodrive_probe_legacy_port); - if (i > 0) - cards += i; -#ifdef CONFIG_PNP - /* ISA PnP cards at last */ i = pnp_register_card_driver(&es18xx_pnpc_driver); if (i > 0) cards += i; -#endif if(!cards) { -#ifdef CONFIG_PNP pnp_unregister_card_driver(&es18xx_pnpc_driver); -#endif + platform_driver_unregister(&snd_es18xx_nonpnp_driver); #ifdef MODULE snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); #endif @@ -2192,14 +2240,8 @@ static int __init alsa_card_es18xx_init(void) static void __exit alsa_card_es18xx_exit(void) { - int idx; - -#ifdef CONFIG_PNP - /* PnP cards first */ pnp_unregister_card_driver(&es18xx_pnpc_driver); -#endif - for(idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_audiodrive_legacy[idx]); + platform_driver_unregister(&snd_es18xx_nonpnp_driver); } module_init(alsa_card_es18xx_init) -- cgit v1.1 From feb158e6ada20b7871f625e1edd429216ac00d3c Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:12:43 +0100 Subject: [ALSA] sgalaxy - Use platform_device, add PM support Modules: Sound Galaxy driver Rewrite the probe/remove with platform_device. Also, add the PM support. Signed-off-by: Takashi Iwai --- sound/isa/sgalaxy.c | 93 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 17 deletions(-) diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index c16b53b..2e1d467 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c @@ -22,12 +22,14 @@ */ #include -#include #include +#include +#include #include #include #include #include +#include #include #include #include @@ -65,8 +67,6 @@ MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); #define SGALAXY_AUXC_LEFT 18 #define SGALAXY_AUXC_RIGHT 19 -static struct snd_card *snd_sgalaxy_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #define PFX "sgalaxy: " /* @@ -216,8 +216,9 @@ static int __init snd_sgalaxy_mixer(struct snd_ad1848 *chip) return 0; } -static int __init snd_sgalaxy_probe(int dev) +static int __init snd_sgalaxy_probe(struct platform_device *devptr) { + int dev = devptr->id; static int possible_irqs[] = {7, 9, 10, 11, -1}; static int possible_dmas[] = {1, 3, 0, -1}; int err, xirq, xdma1; @@ -260,6 +261,7 @@ static int __init snd_sgalaxy_probe(int dev) xirq, xdma1, AD1848_HW_DETECT, &chip)) < 0) goto _err; + card->private_data = chip; if ((err = snd_ad1848_pcm(chip, 0, NULL)) < 0) { snd_printdd(PFX "error creating new ad1848 PCM device\n"); @@ -279,13 +281,12 @@ static int __init snd_sgalaxy_probe(int dev) sprintf(card->longname, "Sound Galaxy at 0x%lx, irq %d, dma %d", wssport[dev], xirq, xdma1); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &devptr->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_sgalaxy_cards[dev] = card; + platform_set_drvdata(devptr, card); return 0; _err: @@ -293,30 +294,88 @@ static int __init snd_sgalaxy_probe(int dev) return err; } +static int __devexit snd_sgalaxy_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_sgalaxy_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1848 *chip = card->private_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + chip->suspend(chip); + return 0; +} + +static int snd_sgalaxy_resume(struct platform_device *pdev) +{ + struct snd_card *card = platform_get_drvdata(pdev); + struct snd_ad1848 *chip = card->private_data; + + chip->resume(chip); + snd_ad1848_out(chip, SGALAXY_AUXC_LEFT, chip->image[SGALAXY_AUXC_LEFT]); + snd_ad1848_out(chip, SGALAXY_AUXC_RIGHT, chip->image[SGALAXY_AUXC_RIGHT]); + + snd_power_change_state(card, SNDRV_CTL_POWER_D0); + return 0; +} +#endif + +#define SND_SGALAXY_DRIVER "snd_sgalaxy" + +static struct platform_driver snd_sgalaxy_driver = { + .probe = snd_sgalaxy_probe, + .remove = __devexit_p(snd_sgalaxy_remove), +#ifdef CONFIG_PM + .suspend = snd_sgalaxy_suspend, + .resume = snd_sgalaxy_resume, +#endif + .driver = { + .name = SND_SGALAXY_DRIVER + }, +}; + static int __init alsa_card_sgalaxy_init(void) { - int dev, cards; + int i, cards, err; - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (snd_sgalaxy_probe(dev) >= 0) - cards++; + err = platform_driver_register(&snd_sgalaxy_driver); + if (err < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(SND_SGALAXY_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; } if (!cards) { #ifdef MODULE snd_printk(KERN_ERR "Sound Galaxy soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } - return 0; + + errout: + platform_driver_unregister(&snd_sgalaxy_driver); + return err; } static void __exit alsa_card_sgalaxy_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_sgalaxy_cards[idx]); + platform_driver_unregister(&snd_sgalaxy_driver); } module_init(alsa_card_sgalaxy_init) -- cgit v1.1 From 277e926c9b2722317a6bf89ed921d97f6784e0cc Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:13:12 +0100 Subject: [ALSA] sscape - Use platform_device Modules: Sound Scape driver Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/sscape.c | 282 +++++++++++++++++++++-------------------------------- 1 file changed, 112 insertions(+), 170 deletions(-) diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index d07963e..6271efe 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include #include @@ -75,8 +77,6 @@ static struct pnp_card_device_id sscape_pnpids[] = { MODULE_DEVICE_TABLE(pnp_card, sscape_pnpids); #endif -static struct snd_card *sscape_card[SNDRV_CARDS]; - #define MPU401_IO(i) ((i) + 0) #define MIDI_DATA_IO(i) ((i) + 0) @@ -1080,48 +1080,18 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port, int irq } -struct params -{ - int index; - const char *id; - unsigned port; - int irq; - int mpu_irq; - int dma1; -}; - - -static inline struct params* -init_params(struct params *params, - int index, - const char *id, - unsigned port, - int irq, - int mpu_irq, - int dma1) -{ - params->index = index; - params->id = id; - params->port = port; - params->irq = irq; - params->mpu_irq = mpu_irq; - params->dma1 = (dma1 & 0x03); - - return params; -} - - /* * Create an ALSA soundcard entry for the SoundScape, using * the given list of port, IRQ and DMA resources. */ -static int __devinit create_sscape(const struct params *params, struct snd_card **rcardp) +static int __devinit create_sscape(int dev, struct snd_card **rcardp) { struct snd_card *card; register struct soundscape *sscape; register unsigned dma_cfg; unsigned irq_cfg; unsigned mpu_irq_cfg; + unsigned xport; struct resource *io_res; unsigned long flags; int err; @@ -1129,32 +1099,33 @@ static int __devinit create_sscape(const struct params *params, struct snd_card /* * Check that the user didn't pass us garbage data ... */ - irq_cfg = get_irq_config(params->irq); + irq_cfg = get_irq_config(irq[dev]); if (irq_cfg == INVALID_IRQ) { - snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", params->irq); + snd_printk(KERN_ERR "sscape: Invalid IRQ %d\n", irq[dev]); return -ENXIO; } - mpu_irq_cfg = get_irq_config(params->mpu_irq); + mpu_irq_cfg = get_irq_config(mpu_irq[dev]); if (mpu_irq_cfg == INVALID_IRQ) { - printk(KERN_ERR "sscape: Invalid IRQ %d\n", params->mpu_irq); + printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]); return -ENXIO; } + xport = port[dev]; /* * Grab IO ports that we will need to probe so that we * can detect and control this hardware ... */ - if ((io_res = request_region(params->port, 8, "SoundScape")) == NULL) { - snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", params->port); + if ((io_res = request_region(xport, 8, "SoundScape")) == NULL) { + snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", xport); return -EBUSY; } /* * Grab both DMA channels (OK, only one for now) ... */ - if ((err = request_dma(params->dma1, "SoundScape")) < 0) { - snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", params->dma1); + if ((err = request_dma(dma[dev], "SoundScape")) < 0) { + snd_printk(KERN_ERR "sscape: can't grab DMA %d\n", dma[dev]); goto _release_region; } @@ -1162,7 +1133,8 @@ static int __devinit create_sscape(const struct params *params, struct snd_card * Create a new ALSA sound card entry, in anticipation * of detecting our hardware ... */ - if ((card = snd_card_new(params->index, params->id, THIS_MODULE, sizeof(struct soundscape))) == NULL) { + if ((card = snd_card_new(index[dev], id[dev], THIS_MODULE, + sizeof(struct soundscape))) == NULL) { err = -ENOMEM; goto _release_dma; } @@ -1171,7 +1143,7 @@ static int __devinit create_sscape(const struct params *params, struct snd_card spin_lock_init(&sscape->lock); spin_lock_init(&sscape->fwlock); sscape->io_res = io_res; - sscape->io_base = params->port; + sscape->io_base = xport; if (!detect_sscape(sscape)) { printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base); @@ -1180,7 +1152,7 @@ static int __devinit create_sscape(const struct params *params, struct snd_card } printk(KERN_INFO "sscape: hardware detected at 0x%x, using IRQ %d, DMA %d\n", - sscape->io_base, params->irq, params->dma1); + sscape->io_base, irq[dev], dma[dev]); /* * Now create the hardware-specific device so that we can @@ -1223,7 +1195,7 @@ static int __devinit create_sscape(const struct params *params, struct snd_card sscape_write_unsafe(sscape->io_base, GA_INTCFG_REG, 0xf0 | (mpu_irq_cfg << 2) | mpu_irq_cfg); sscape_write_unsafe(sscape->io_base, - GA_CDCFG_REG, 0x09 | DMA_8BIT | (params->dma1 << 4) | (irq_cfg << 1)); + GA_CDCFG_REG, 0x09 | DMA_8BIT | (dma[dev] << 4) | (irq_cfg << 1)); spin_unlock_irqrestore(&sscape->lock, flags); @@ -1231,15 +1203,15 @@ static int __devinit create_sscape(const struct params *params, struct snd_card * We have now enabled the codec chip, and so we should * detect the AD1845 device ... */ - if ((err = create_ad1845(card, CODEC_IO(params->port), params->irq, params->dma1)) < 0) { + if ((err = create_ad1845(card, CODEC_IO(xport), irq[dev], dma[dev])) < 0) { printk(KERN_ERR "sscape: No AD1845 device at 0x%x, IRQ %d\n", - CODEC_IO(params->port), params->irq); + CODEC_IO(xport), irq[dev]); goto _release_card; } #define MIDI_DEVNUM 0 - if ((err = create_mpu401(card, MIDI_DEVNUM, MPU401_IO(params->port), params->mpu_irq)) < 0) { + if ((err = create_mpu401(card, MIDI_DEVNUM, MPU401_IO(xport), mpu_irq[dev])) < 0) { printk(KERN_ERR "sscape: Failed to create MPU-401 device at 0x%x\n", - MPU401_IO(params->port)); + MPU401_IO(xport)); goto _release_card; } @@ -1271,7 +1243,7 @@ static int __devinit create_sscape(const struct params *params, struct snd_card snd_card_free(card); _release_dma: - free_dma(params->dma1); + free_dma(dma[dev]); _release_region: release_and_free_resource(io_res); @@ -1280,44 +1252,66 @@ static int __devinit create_sscape(const struct params *params, struct snd_card } -static int sscape_cards __devinitdata; -static struct params sscape_params[SNDRV_CARDS] __devinitdata; +static int __init snd_sscape_probe(struct platform_device *pdev) +{ + int dev = pdev->id; + struct snd_card *card; + int ret; + + dma[dev] &= 0x03; + ret = create_sscape(dev, &card); + if (ret < 0) + return ret; + snd_card_set_dev(card, &pdev->dev); + if ((ret = snd_card_register(card)) < 0) { + printk(KERN_ERR "sscape: Failed to register sound card\n"); + return ret; + } + platform_set_drvdata(pdev, card); + return 0; +} + +static int __devexit snd_sscape_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define SSCAPE_DRIVER "snd_sscape" + +static struct platform_driver snd_sscape_driver = { + .probe = snd_sscape_probe, + .remove = __devexit_p(snd_sscape_remove), + /* FIXME: suspend/resume */ + .driver = { + .name = SSCAPE_DRIVER + }, +}; #ifdef CONFIG_PNP static inline int __devinit get_next_autoindex(int i) { - while ((i < SNDRV_CARDS) && (port[i] != SNDRV_AUTO_PORT)) { + while (i < SNDRV_CARDS && port[i] != SNDRV_AUTO_PORT) ++i; - } /* while */ - return i; } -static inline int __devinit is_port_known(unsigned io, struct params *params, int cards) -{ - while (--cards >= 0) { - if (params[cards].port == io) - return 1; - } /* while */ - - return 0; -} - static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, const struct pnp_card_device_id *pid) { - struct pnp_dev *dev; static int idx = 0; + struct pnp_dev *dev; + struct snd_card *card; int ret; /* * Allow this function to fail *quietly* if all the ISA PnP * devices were configured using module parameters instead. */ - if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) { + if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS) return -ENOSPC; - } /* * We have found a candidate ISA PnP card. Now we @@ -1339,66 +1333,45 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard, /* * Check that we still have room for another sound card ... */ - if (sscape_cards >= SNDRV_CARDS) { - printk(KERN_ERR "sscape: No room for another ALSA device\n"); - return -ENOSPC; - } - - ret = -ENODEV; - dev = pnp_request_card_device(pcard, pid->devs[0].id, NULL); - if (dev) { - struct params *this; - if (!pnp_is_active(dev)) { - if (pnp_activate_dev(dev) < 0) { - printk(KERN_INFO "sscape: device is inactive\n"); - return -EBUSY; - } - } - /* - * Read the correct parameters off the ISA PnP bus ... - */ - this = init_params(&sscape_params[sscape_cards], - index[idx], - id[idx], - pnp_port_start(dev, 0), - pnp_irq(dev, 0), - pnp_irq(dev, 1), - pnp_dma(dev, 0)); + if (! dev) + return -ENODEV; - /* - * Do we know about this sound card already? - */ - if ( !is_port_known(this->port, sscape_params, sscape_cards) ) { - struct snd_card *card; - - ret = create_sscape(this, &card); - if (ret < 0) - return ret; - snd_card_set_dev(card, &pcard->card->dev); - - if ((ret = snd_card_register(card)) < 0) { - printk(KERN_ERR "sscape: Failed to register sound card\n"); - snd_card_free(card); - return ret; - } - - pnp_set_card_drvdata(pcard, card); - ++sscape_cards; - ++idx; + if (!pnp_is_active(dev)) { + if (pnp_activate_dev(dev) < 0) { + printk(KERN_INFO "sscape: device is inactive\n"); + return -EBUSY; } } + /* + * Read the correct parameters off the ISA PnP bus ... + */ + port[idx] = pnp_port_start(dev, 0); + irq[idx] = pnp_irq(dev, 0); + mpu_irq[idx] = pnp_irq(dev, 1); + dma[idx] = pnp_dma(dev, 0) & 0x03; + + ret = create_sscape(idx, &card); + if (ret < 0) + return ret; + snd_card_set_dev(card, &pcard->card->dev); + if ((ret = snd_card_register(card)) < 0) { + printk(KERN_ERR "sscape: Failed to register sound card\n"); + snd_card_free(card); + return ret; + } + + pnp_set_card_drvdata(pcard, card); + ++idx; + return ret; } static void __devexit sscape_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); - + snd_card_free(pnp_get_card_drvdata(pcard)); pnp_set_card_drvdata(pcard, NULL); - snd_card_disconnect(card); - snd_card_free_in_thread(card); } static struct pnp_card_driver sscape_pnpc_driver = { @@ -1411,11 +1384,14 @@ static struct pnp_card_driver sscape_pnpc_driver = { #endif /* CONFIG_PNP */ -static int __init sscape_manual_probe(struct params *params) +static int __init sscape_manual_probe(void) { - int ret; - unsigned i; - struct snd_card *card; + struct platform_device *device; + int i, ret; + + ret = platform_driver_register(&snd_sscape_driver); + if (ret < 0) + return ret; for (i = 0; i < SNDRV_CARDS; ++i) { /* @@ -1430,52 +1406,32 @@ static int __init sscape_manual_probe(struct params *params) /* * Make sure we were given ALL of the other parameters. */ - if ( (irq[i] == SNDRV_AUTO_IRQ) || - (mpu_irq[i] == SNDRV_AUTO_IRQ) || - (dma[i] == SNDRV_AUTO_DMA) ) { + if (irq[i] == SNDRV_AUTO_IRQ || + mpu_irq[i] == SNDRV_AUTO_IRQ || + dma[i] == SNDRV_AUTO_DMA) { printk(KERN_INFO "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); + platform_driver_unregister(&snd_sscape_driver); return -ENXIO; } /* * This cards looks OK ... */ - init_params(params, index[i], id[i], port[i], irq[i], mpu_irq[i], dma[i]); - - ret = create_sscape(params, &card); - if (ret < 0) - return ret; - - if ((ret = snd_card_set_generic_dev(card)) < 0) { - snd_card_free(card); - return ret; - } - if ((ret = snd_card_register(card)) < 0) { - printk(KERN_ERR "sscape: Failed to register sound card\n"); - snd_card_free(card); - return ret; + device = platform_device_register_simple(SSCAPE_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + platform_driver_unregister(&snd_sscape_driver); + return PTR_ERR(device); } - - sscape_card[sscape_cards] = card; - params++; - sscape_cards++; - } /* for */ - + } return 0; } - static void sscape_exit(void) { - unsigned i; - -#ifdef CONFIG_PNP pnp_unregister_card_driver(&sscape_pnpc_driver); -#endif - for (i = 0; i < ARRAY_SIZE(sscape_card); ++i) { - snd_card_free(sscape_card[i]); - } /* for */ + platform_driver_unregister(&snd_sscape_driver); } @@ -1489,24 +1445,10 @@ static int __init sscape_init(void) * of allocating cards, because the operator is * S-P-E-L-L-I-N-G it out for us... */ - ret = sscape_manual_probe(sscape_params); - if (ret < 0) { - int i; - for (i = 0; i < sscape_cards; ++i) - snd_card_free(sscape_card[i]); + ret = sscape_manual_probe(); + if (ret < 0) return ret; - } - -#ifdef CONFIG_PNP - if (sscape_cards < SNDRV_CARDS) { - ret = pnp_register_card_driver(&sscape_pnpc_driver); - if (ret < 0) { - sscape_exit(); - return ret; - } - } -#endif - + pnp_register_card_driver(&sscape_pnpc_driver); return 0; } -- cgit v1.1 From 2a571ed13c853d132433c7e81509351823a7c8c6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:13:30 +0100 Subject: [ALSA] es1688 - Use platform_device Modules: ES1688 driver Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/es1688/es1688.c | 112 ++++++++++++++++++++++++++++------------------ 1 file changed, 69 insertions(+), 43 deletions(-) diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 278511b..68bd40a 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -20,16 +20,17 @@ */ #include -#include #include +#include +#include #include #include #include +#include #include #include #include #include -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -68,12 +69,11 @@ MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); module_param_array(dma8, int, NULL, 0444); MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); -static struct snd_card *snd_audiodrive_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #define PFX "es1688: " -static int __init snd_audiodrive_probe(int dev) +static int __init snd_es1688_probe(struct platform_device *pdev) { + int dev = pdev->id; static int possible_irqs[] = {5, 9, 10, 7, -1}; static int possible_dmas[] = {1, 3, 0, -1}; int xirq, xdma, xmpu_irq; @@ -105,10 +105,30 @@ static int __init snd_audiodrive_probe(int dev) } } - if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], - xirq, xmpu_irq, xdma, - ES1688_HW_AUTO, &chip)) < 0) - goto _err; + if (port[dev] != SNDRV_AUTO_PORT) { + if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], + xirq, xmpu_irq, xdma, + ES1688_HW_AUTO, &chip)) < 0) + goto _err; + } else { + /* auto-probe legacy ports */ + static unsigned long possible_ports[] = { + 0x220, 0x240, 0x260, + }; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + err = snd_es1688_create(card, possible_ports[i], + mpu_port[dev], + xirq, xmpu_irq, xdma, + ES1688_HW_AUTO, &chip); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + if (i >= ARRAY_SIZE(possible_ports)) + goto _err; + } if ((err = snd_es1688_pcm(chip, 0, &pcm)) < 0) goto _err; @@ -136,13 +156,12 @@ static int __init snd_audiodrive_probe(int dev) goto _err; } - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_audiodrive_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -150,53 +169,60 @@ static int __init snd_audiodrive_probe(int dev) return err; } -static int __init snd_audiodrive_legacy_auto_probe(unsigned long xport) +static int snd_es1688_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_audiodrive_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#define ES1688_DRIVER "snd_es1688" + +static struct platform_driver snd_es1688_driver = { + .probe = snd_es1688_probe, + .remove = snd_es1688_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = ES1688_DRIVER + }, +}; + static int __init alsa_card_es1688_init(void) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; - int dev, cards = 0, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_audiodrive_probe(dev) >= 0) - cards++; + int i, cards, err; + + err = platform_driver_register(&snd_es1688_driver); + if (err < 0) + return err; + + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(ES1688_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; } - i = snd_legacy_auto_probe(possible_ports, snd_audiodrive_legacy_auto_probe); - if (i > 0) - cards += i; - if (!cards) { #ifdef MODULE printk(KERN_ERR "ESS AudioDrive ES1688 soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_es1688_driver); + return err; } static void __exit alsa_card_es1688_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_audiodrive_cards[idx]); + platform_driver_unregister(&snd_es1688_driver); } module_init(alsa_card_es1688_init) -- cgit v1.1 From 654aa661779703d3b22ba04a83ddeb1a0dd7a09a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:13:43 +0100 Subject: [ALSA] gus - Use platform_device Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/gus/gusclassic.c | 116 +++++++++++------- sound/isa/gus/gusextreme.c | 116 ++++++++++-------- sound/isa/gus/gusmax.c | 117 +++++++++++------- sound/isa/gus/interwave.c | 292 ++++++++++++++++++++++++--------------------- 4 files changed, 367 insertions(+), 274 deletions(-) diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 6db484f..57beb74 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -20,14 +20,15 @@ */ #include -#include #include +#include +#include #include #include #include +#include #include #include -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -70,7 +71,6 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); -static struct snd_card *snd_gusclassic_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "gusclassic: " @@ -101,20 +101,19 @@ static void __init snd_gusclassic_init(int dev, struct snd_gus_card * gus) gus->joystick_dac = joystick_dac[dev]; } -static int __init snd_gusclassic_probe(int dev) +static int __init snd_gusclassic_probe(struct platform_device *pdev) { + int dev = pdev->id; static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, 4, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2; struct snd_card *card; - struct snd_gusclassic *guscard; struct snd_gus_card *gus = NULL; int err; card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; - guscard = (struct snd_gusclassic *)card->private_data; if (pcm_channels[dev] < 2) pcm_channels[dev] = 2; @@ -143,12 +142,31 @@ static int __init snd_gusclassic_probe(int dev) } } - - if ((err = snd_gus_create(card, - port[dev], - xirq, xdma1, xdma2, - 0, channels[dev], pcm_channels[dev], - 0, &gus)) < 0) + if (port[dev] != SNDRV_AUTO_PORT) { + err = snd_gus_create(card, + port[dev], + xirq, xdma1, xdma2, + 0, channels[dev], pcm_channels[dev], + 0, &gus); + } else { + /* auto-probe legacy ports */ + static unsigned long possible_ports[] = { + 0x220, 0x230, 0x240, 0x250, 0x260, + }; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + err = snd_gus_create(card, + possible_ports[i], + xirq, xdma1, xdma2, + 0, channels[dev], pcm_channels[dev], + 0, &gus); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + } + if (err < 0) goto _err; if ((err = snd_gusclassic_detect(gus)) < 0) @@ -178,13 +196,12 @@ static int __init snd_gusclassic_probe(int dev) if (dma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; - snd_gusclassic_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; _err: @@ -192,53 +209,60 @@ static int __init snd_gusclassic_probe(int dev) return err; } -static int __init snd_gusclassic_legacy_auto_probe(unsigned long xport) +static int snd_gusclassic_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusclassic_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#define GUSCLASSIC_DRIVER "snd_gusclassic" + +static struct platform_driver snd_gusclassic_driver = { + .probe = snd_gusclassic_probe, + .remove = snd_gusclassic_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSCLASSIC_DRIVER + }, +}; + static int __init alsa_card_gusclassic_init(void) { - static unsigned long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev]; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusclassic_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusclassic_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + + err = platform_driver_register(&snd_gusclassic_driver); + if (err < 0) + return err; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSCLASSIC_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS Classic soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_gusclassic_driver); + return err; } static void __exit alsa_card_gusclassic_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_gusclassic_cards[idx]); + platform_driver_unregister(&snd_gusclassic_driver); } module_init(alsa_card_gusclassic_init) diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 9be59d5..6fad973 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -20,11 +20,13 @@ */ #include -#include #include +#include +#include #include #include #include +#include #include #include #include @@ -85,7 +87,6 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); -static struct snd_card *snd_gusextreme_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #define PFX "gusextreme: " @@ -166,15 +167,15 @@ static int __init snd_gusextreme_mixer(struct snd_es1688 *chip) return 0; } -static int __init snd_gusextreme_probe(int dev) +static int __init snd_gusextreme_probe(struct platform_device *pdev) { + int dev = pdev->id; static int possible_ess_irqs[] = {5, 9, 10, 7, -1}; static int possible_ess_dmas[] = {1, 3, 0, -1}; static int possible_gf1_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_gf1_dmas[] = {5, 6, 7, 1, 3, -1}; int xgf1_irq, xgf1_dma, xess_irq, xmpu_irq, xess_dma; struct snd_card *card; - struct snd_gusextreme *acard; struct snd_gus_card *gus; struct snd_es1688 *es1688; struct snd_opl3 *opl3; @@ -183,7 +184,6 @@ static int __init snd_gusextreme_probe(int dev) card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); if (card == NULL) return -ENOMEM; - acard = (struct snd_gusextreme *)card->private_data; xgf1_irq = gf1_irq[dev]; if (xgf1_irq == SNDRV_AUTO_IRQ) { @@ -223,10 +223,29 @@ static int __init snd_gusextreme_probe(int dev) } } - if ((err = snd_es1688_create(card, port[dev], mpu_port[dev], - xess_irq, xmpu_irq, xess_dma, - ES1688_HW_1688, &es1688)) < 0) + if (port[dev] != SNDRV_AUTO_PORT) { + err = snd_es1688_create(card, port[dev], mpu_port[dev], + xess_irq, xmpu_irq, xess_dma, + ES1688_HW_1688, &es1688); + } else { + /* auto-probe legacy ports */ + static unsigned long possible_ports[] = {0x220, 0x240, 0x260}; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + err = snd_es1688_create(card, + possible_ports[i], + mpu_port[dev], + xess_irq, xmpu_irq, xess_dma, + ES1688_HW_1688, &es1688); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + } + if (err < 0) goto out; + if (gf1_port[dev] < 0) gf1_port[dev] = port[dev] + 0x20; if ((err = snd_gus_create(card, @@ -287,13 +306,12 @@ static int __init snd_gusextreme_probe(int dev) sprintf(card->longname, "Gravis UltraSound Extreme at 0x%lx, irq %i&%i, dma %i&%i", es1688->port, xgf1_irq, xess_irq, xgf1_dma, xess_dma); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto out; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto out; - snd_gusextreme_cards[dev] = card; + platform_set_drvdata(pdev, card); return 0; out: @@ -301,60 +319,60 @@ static int __init snd_gusextreme_probe(int dev) return err; } -static int __init snd_gusextreme_legacy_auto_probe(unsigned long xport) +static int snd_gusextreme_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusextreme_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#define GUSEXTREME_DRIVER "snd_gusextreme" + +static struct platform_driver snd_gusextreme_driver = { + .probe = snd_gusextreme_probe, + .remove = snd_gusextreme_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSEXTREME_DRIVER + }, +}; + static int __init alsa_card_gusextreme_init(void) { - static unsigned long possible_ports[] = {0x220, 0x240, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev] > 0; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusextreme_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusextreme_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + + err = platform_driver_register(&snd_gusextreme_driver); + if (err < 0) + return err; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSEXTREME_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS Extreme soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_gusextreme_driver); + return err; } static void __exit alsa_card_gusextreme_exit(void) { - int idx; - struct snd_card *card; - struct snd_gusextreme *acard; - - for (idx = 0; idx < SNDRV_CARDS; idx++) { - card = snd_gusextreme_cards[idx]; - if (card == NULL) - continue; - acard = (struct snd_gusextreme *)card->private_data; - snd_card_free(snd_gusextreme_cards[idx]); - } + platform_driver_unregister(&snd_gusextreme_driver); } module_init(alsa_card_gusextreme_init) diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index 63311cd..d1b70ee 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -20,15 +20,16 @@ */ #include -#include #include +#include +#include #include #include #include +#include #include #include #include -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -80,8 +81,6 @@ struct snd_gusmax { unsigned short pcm_status_reg; }; -static struct snd_card *snd_gusmax_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; - #define PFX "gusmax: " static int __init snd_gusmax_detect(struct snd_gus_card * gus) @@ -203,8 +202,9 @@ static void snd_gusmax_free(struct snd_card *card) free_irq(maxcard->irq, (void *)maxcard); } -static int __init snd_gusmax_probe(int dev) +static int __init snd_gusmax_probe(struct platform_device *pdev) { + int dev = pdev->id; static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; static int possible_dmas[] = {5, 6, 7, 1, 3, -1}; int xirq, xdma1, xdma2, err; @@ -247,12 +247,32 @@ static int __init snd_gusmax_probe(int dev) } } - if ((err = snd_gus_create(card, - port[dev], - -xirq, xdma1, xdma2, - 0, channels[dev], - pcm_channels[dev], - 0, &gus)) < 0) + if (port[dev] != SNDRV_AUTO_PORT) { + err = snd_gus_create(card, + port[dev], + -xirq, xdma1, xdma2, + 0, channels[dev], + pcm_channels[dev], + 0, &gus); + } else { + static unsigned long possible_ports[] = { + 0x220, 0x230, 0x240, 0x250, 0x260 + }; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + err = snd_gus_create(card, + possible_ports[i], + -xirq, xdma1, xdma2, + 0, channels[dev], + pcm_channels[dev], + 0, &gus); + if (err >= 0) { + port[dev] = possible_ports[i]; + break; + } + } + } + if (err < 0) goto _err; if ((err = snd_gusmax_detect(gus)) < 0) @@ -310,15 +330,15 @@ static int __init snd_gusmax_probe(int dev) if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%i", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; + snd_card_set_dev(card, &pdev->dev); if ((err = snd_card_register(card)) < 0) goto _err; maxcard->gus = gus; maxcard->cs4231 = cs4231; - snd_gusmax_cards[dev] = card; + + platform_set_drvdata(pdev, card); return 0; _err: @@ -326,53 +346,60 @@ static int __init snd_gusmax_probe(int dev) return err; } -static int __init snd_gusmax_legacy_auto_probe(unsigned long xport) +static int snd_gusmax_remove(struct platform_device *devptr) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; - port[dev] = xport; - res = snd_gusmax_probe(dev); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; - } - return -ENODEV; + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; } +#define GUSMAX_DRIVER "snd_gusmax" + +static struct platform_driver snd_gusmax_driver = { + .probe = snd_gusmax_probe, + .remove = snd_gusmax_remove, + /* FIXME: suspend/resume */ + .driver = { + .name = GUSMAX_DRIVER + }, +}; + static int __init alsa_card_gusmax_init(void) { - static unsigned long possible_ports[] = {0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev, cards, i; - - for (dev = cards = 0; dev < SNDRV_CARDS && enable[dev] > 0; dev++) { - if (port[dev] == SNDRV_AUTO_PORT) - continue; - if (snd_gusmax_probe(dev) >= 0) - cards++; - } - i = snd_legacy_auto_probe(possible_ports, snd_gusmax_legacy_auto_probe); - if (i > 0) - cards += i; + int i, cards, err; + + err = platform_driver_register(&snd_gusmax_driver); + if (err < 0) + return err; + cards = 0; + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; + device = platform_device_register_simple(GUSMAX_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + goto errout; + } + cards++; + } if (!cards) { #ifdef MODULE printk(KERN_ERR "GUS MAX soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + platform_driver_unregister(&snd_gusmax_driver); + return err; } static void __exit alsa_card_gusmax_exit(void) { - int idx; - - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_gusmax_cards[idx]); + platform_driver_unregister(&snd_gusmax_driver); } module_init(alsa_card_gusmax_init) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index f2e9c50..67a5f74 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -23,19 +23,20 @@ */ #include -#include -#include #include +#include +#include +#include #include #include #include +#include #include #include #include #ifdef SNDRV_STB #include #endif -#define SNDRV_LEGACY_AUTO_PROBE #define SNDRV_LEGACY_FIND_FREE_IRQ #define SNDRV_LEGACY_FIND_FREE_DMA #include @@ -75,8 +76,12 @@ static int effect[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; #ifdef SNDRV_STB #define PFX "interwave-stb: " +#define INTERWAVE_DRIVER "snd_interwave_stb" +#define INTERWAVE_PNP_DRIVER "interwave-stb" #else #define PFX "interwave: " +#define INTERWAVE_DRIVER "snd_interwave" +#define INTERWAVE_PNP_DRIVER "interwave" #endif module_param_array(index, int, NULL, 0444); @@ -128,7 +133,6 @@ struct snd_interwave { #endif }; -static struct snd_card *snd_interwave_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -633,7 +637,7 @@ static int __devinit snd_interwave_pnp(int dev, struct snd_interwave *iwcard, static void snd_interwave_free(struct snd_card *card) { - struct snd_interwave *iwcard = (struct snd_interwave *)card->private_data; + struct snd_interwave *iwcard = card->private_data; if (iwcard == NULL) return; @@ -644,14 +648,26 @@ static void snd_interwave_free(struct snd_card *card) free_irq(iwcard->irq, (void *)iwcard); } -static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_interwave_card_new(int dev) { - static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; - static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; - int xirq, xdma1, xdma2; struct snd_card *card; struct snd_interwave *iwcard; + + card = snd_card_new(index[dev], id[dev], THIS_MODULE, + sizeof(struct snd_interwave)); + if (card == NULL) + return NULL; + iwcard = card->private_data; + iwcard->card = card; + iwcard->irq = -1; + card->private_free = snd_interwave_free; + return card; +} + +static int __devinit snd_interwave_probe(struct snd_card *card, int dev) +{ + int xirq, xdma1, xdma2; + struct snd_interwave *iwcard = card->private_data; struct snd_cs4231 *cs4231; struct snd_gus_card *gus; #ifdef SNDRV_STB @@ -661,59 +677,23 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, char *str; int err; - card = snd_card_new(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_interwave)); - if (card == NULL) - return -ENOMEM; - iwcard = (struct snd_interwave *)card->private_data; - iwcard->card = card; - iwcard->irq = -1; - card->private_free = snd_interwave_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if ((err = snd_interwave_pnp(dev, iwcard, pcard, pid)) < 0) - goto _err; - snd_card_set_dev(card, &pcard->card->dev); - } -#endif xirq = irq[dev]; - if (xirq == SNDRV_AUTO_IRQ) { - if ((xirq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); - err = -EBUSY; - goto _err; - } - } xdma1 = dma1[dev]; - if (xdma1 == SNDRV_AUTO_DMA) { - if ((xdma1 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); - err = -EBUSY; - goto _err; - } - } xdma2 = dma2[dev]; - if (xdma2 == SNDRV_AUTO_DMA) { - if ((xdma2 = snd_legacy_find_free_dma(possible_dmas)) < 0) { - snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); - err = -EBUSY; - goto _err; - } - } if ((err = snd_gus_create(card, port[dev], -xirq, xdma1, xdma2, 0, 32, pcm_channels[dev], effect[dev], &gus)) < 0) - goto _err; + return err; if ((err = snd_interwave_detect(iwcard, gus, dev #ifdef SNDRV_STB , &i2c_bus #endif )) < 0) - goto _err; + return err; iwcard->gus_status_reg = gus->gf1.reg_irqstat; iwcard->pcm_status_reg = gus->gf1.port + 0x10c + 2; @@ -721,12 +701,12 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, snd_interwave_init(dev, gus); snd_interwave_detect_memory(gus); if ((err = snd_gus_initialize(gus)) < 0) - goto _err; + return err; - if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, "InterWave", (void *)iwcard)) { + if (request_irq(xirq, snd_interwave_interrupt, SA_INTERRUPT, + "InterWave", iwcard)) { snd_printk(KERN_ERR PFX "unable to grab IRQ %d\n", xirq); - err = -EBUSY; - goto _err; + return -EBUSY; } iwcard->irq = xirq; @@ -738,26 +718,26 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, CS4231_HWSHARE_DMA1 | CS4231_HWSHARE_DMA2, &cs4231)) < 0) - goto _err; + return err; if ((err = snd_cs4231_pcm(cs4231, 0, &pcm)) < 0) - goto _err; + return err; sprintf(pcm->name + strlen(pcm->name), " rev %c", gus->revision + 'A'); strcat(pcm->name, " (codec)"); if ((err = snd_cs4231_timer(cs4231, 2, NULL)) < 0) - goto _err; + return err; if ((err = snd_cs4231_mixer(cs4231)) < 0) - goto _err; + return err; if (pcm_channels[dev] > 0) { if ((err = snd_gf1_pcm_new(gus, 1, 1, NULL)) < 0) - goto _err; + return err; } if ((err = snd_interwave_mixer(cs4231)) < 0) - goto _err; + return err; #ifdef SNDRV_STB { @@ -769,19 +749,19 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, strcpy(id2.name, id1.name); id2.index = 1; if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) - goto _err; + return err; strcpy(id1.name, "Master Playback Volume"); strcpy(id2.name, id1.name); if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) - goto _err; + return err; if ((err = snd_tea6330t_update_mixer(card, i2c_bus, 0, 1)) < 0) - goto _err; + return err; } #endif gus->uart_enable = midi[dev]; if ((err = snd_gf1_rawmidi_new(gus, 0, NULL)) < 0) - goto _err; + return err; #ifndef SNDRV_STB str = "AMD InterWave"; @@ -800,121 +780,171 @@ static int __devinit snd_interwave_probe(int dev, struct pnp_card_link *pcard, if (xdma2 >= 0) sprintf(card->longname + strlen(card->longname), "&%d", xdma2); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - if ((err = snd_card_register(card)) < 0) - goto _err; + return err; iwcard->cs4231 = cs4231; iwcard->gus = gus; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_interwave_legacy[dev++] = card; return 0; +} - _err: - snd_card_free(card); - return err; +static int __init snd_interwave_nonpnp_probe1(int dev, struct platform_device *devptr) +{ + struct snd_card *card; + int err; + + card = snd_interwave_card_new(dev); + if (! card) + return -ENOMEM; + + snd_card_set_dev(card, &devptr->dev); + if ((err = snd_interwave_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + platform_set_drvdata(devptr, card); + return 0; } -static int __devinit snd_interwave_probe_legacy_port(unsigned long xport) +static int __init snd_interwave_nonpnp_probe(struct platform_device *pdev) { - static int dev; - int res; + int dev = pdev->id; + int err; + static int possible_irqs[] = {5, 11, 12, 9, 7, 15, 3, -1}; + static int possible_dmas[] = {0, 1, 3, 5, 6, 7, -1}; - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] != SNDRV_AUTO_PORT) - continue; -#ifdef CONFIG_PNP - if (isapnp[dev]) - continue; -#endif - port[dev] = xport; - res = snd_interwave_probe(dev, NULL, NULL); - if (res < 0) - port[dev] = SNDRV_AUTO_PORT; - return res; + if (irq[dev] == SNDRV_AUTO_IRQ) { + if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (dma1[dev] == SNDRV_AUTO_DMA) { + if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA1\n"); + return -EBUSY; + } + } + if (dma2[dev] == SNDRV_AUTO_DMA) { + if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) { + snd_printk(KERN_ERR PFX "unable to find a free DMA2\n"); + return -EBUSY; + } + } + + if (port[dev] != SNDRV_AUTO_PORT) + return snd_interwave_nonpnp_probe1(dev, pdev); + else { + static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260}; + int i; + for (i = 0; i < ARRAY_SIZE(possible_ports); i++) { + port[dev] = possible_ports[i]; + err = snd_interwave_nonpnp_probe1(dev, pdev); + if (! err) + return 0; + } + return err; } - return -ENODEV; } +static int __devexit snd_interwave_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +static struct platform_driver snd_interwave_driver = { + .probe = snd_interwave_nonpnp_probe, + .remove = __devexit_p(snd_interwave_nonpnp_remove), + /* FIXME: suspend,resume */ + .driver = { + .name = INTERWAVE_DRIVER + }, +}; + #ifdef CONFIG_PNP -static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_interwave_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; + struct snd_card *card; int res; for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_interwave_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; - } - - return -ENODEV; + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_interwave_card_new(dev); + if (! card) + return -ENOMEM; + + if ((res = snd_interwave_pnp(dev, card->private_data, pcard, pid)) < 0) { + snd_card_free(card); + return res; + } + snd_card_set_dev(card, &pcard->card->dev); + if ((res = snd_interwave_probe(card, dev)) < 0) { + snd_card_free(card); + return res; + } + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_interwave_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } static struct pnp_card_driver interwave_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, - .name = "interwave", + .name = INTERWAVE_PNP_DRIVER, .id_table = snd_interwave_pnpids, .probe = snd_interwave_pnp_detect, .remove = __devexit_p(snd_interwave_pnp_remove), + /* FIXME: suspend,resume */ }; #endif /* CONFIG_PNP */ static int __init alsa_card_interwave_init(void) { - int cards = 0, i; - static long possible_ports[] = {0x210, 0x220, 0x230, 0x240, 0x250, 0x260, -1}; - int dev; + int i, err, cards = 0; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || port[dev] == SNDRV_AUTO_PORT) - continue; + if ((err = platform_driver_register(&snd_interwave_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; #ifdef CONFIG_PNP - if (isapnp[dev]) + if (isapnp[i]) continue; #endif - if (!snd_interwave_probe(dev, NULL, NULL)) { - cards++; - continue; + device = platform_device_register_simple(INTERWAVE_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + err = PTR_ERR(device); + platform_driver_unregister(&snd_interwave_driver); + return err; } -#ifdef MODULE - printk(KERN_ERR "InterWave soundcard #%i not found at 0x%lx or device busy\n", dev, port[dev]); -#endif + cards++; } - /* legacy auto configured cards */ - i = snd_legacy_auto_probe(possible_ports, snd_interwave_probe_legacy_port); - if (i > 0) - cards += i; -#ifdef CONFIG_PNP + /* ISA PnP cards */ i = pnp_register_card_driver(&interwave_pnpc_driver); if (i > 0) cards += i; -#endif if (!cards) { -#ifdef CONFIG_PNP pnp_unregister_card_driver(&interwave_pnpc_driver); -#endif + platform_driver_unregister(&snd_interwave_driver); #ifdef MODULE printk(KERN_ERR "InterWave soundcard not found or device busy\n"); #endif @@ -925,14 +955,8 @@ static int __init alsa_card_interwave_init(void) static void __exit alsa_card_interwave_exit(void) { - int dev; - -#ifdef CONFIG_PNP - /* PnP cards first */ pnp_unregister_card_driver(&interwave_pnpc_driver); -#endif - for (dev = 0; dev < SNDRV_CARDS; dev++) - snd_card_free(snd_interwave_legacy[dev]); + platform_driver_unregister(&snd_interwave_driver); } module_init(alsa_card_interwave_init) -- cgit v1.1 From 99a0b7687ef991a577506a1974be146f02f18d74 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:13:59 +0100 Subject: [ALSA] opti9xx - Use platform_device Modules: Opti9xx drivers Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/opti9xx/opti92x-ad1848.c | 507 +++++++++++++++---------------------- 1 file changed, 209 insertions(+), 298 deletions(-) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index fddf7b9..39211e5 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -24,13 +24,15 @@ #include -#include -#include -#include #include +#include +#include +#include #include #include #include +#include +#include #include #ifdef CS4231 #include @@ -256,8 +258,7 @@ struct snd_opti9xx { #endif /* CONFIG_PNP */ }; -static int snd_opti9xx_first_hit = 1; -static struct snd_card *snd_opti9xx_legacy = SNDRV_DEFAULT_PTR1; +static int snd_opti9xx_pnp_is_probed; #ifdef CONFIG_PNP @@ -292,7 +293,7 @@ static char * snd_opti9xx_names[] = { }; -static long snd_legacy_find_free_ioport(long *port_table, long size) +static long __init snd_legacy_find_free_ioport(long *port_table, long size) { while (*port_table != -1) { if (request_region(*port_table, size, "ALSA test")) { @@ -304,7 +305,7 @@ static long snd_legacy_find_free_ioport(long *port_table, long size) return -1; } -static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) +static int __init snd_opti9xx_init(struct snd_opti9xx *chip, unsigned short hardware) { static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2}; @@ -449,7 +450,7 @@ static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg, (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask))) -static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip) +static int __init snd_opti9xx_configure(struct snd_opti9xx *chip) { unsigned char wss_base_bits; unsigned char irq_bits; @@ -1620,7 +1621,7 @@ static int snd_opti93x_mixer(struct snd_opti93x *chip) #endif /* OPTi93X */ -static int __devinit snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) +static int __init snd_card_opti9xx_detect(struct snd_card *card, struct snd_opti9xx *chip) { int i, err; @@ -1674,8 +1675,8 @@ static int __devinit snd_card_opti9xx_detect(struct snd_card *card, struct snd_o } #ifdef CONFIG_PNP -static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card, - const struct pnp_card_device_id *pid) +static int __init snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_card_link *card, + const struct pnp_card_device_id *pid) { struct pnp_dev *pdev; struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); @@ -1766,128 +1767,19 @@ static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip, struct pnp_c } #endif /* CONFIG_PNP */ -#if 0 -static int __devinit snd_card_opti9xx_resources(struct snd_card_opti9xx *chip, - struct snd_card *card) -{ - int error, i, pnp = 0; - -#ifdef CONFIG_PNP - pnp = chip->dev != NULL; -#endif /* CONFIG_PNP */ - -#ifndef OPTi93X - if (chip->chip->hardware == OPTi9XX_HW_82C928) - mpu_port = -1; -#endif /* OPTi93X */ - error = 0; - if (!pnp && (mpu_port == SNDRV_DEFAULT_PORT1)) { - for (i = 0; possible_mpu_ports[i] != -1; i++) - if (!snd_register_ioport(card, possible_mpu_ports[i], 2, - DRIVER_NAME" - MPU-401", NULL)) { - mpu_port = possible_mpu_ports[i]; - break; - } - if (mpu_port == SNDRV_DEFAULT_PORT1) - error = -EBUSY; - } - else - error = (mpu_port == -1) ? -ENODEV : - snd_register_ioport(card, mpu_port, 2, - DRIVER_NAME" - MPU-401", NULL); - if (error) - chip->chip->mpu_port = -1; - else if (pnp && (irq == mpu_irq)) - chip->chip->mpu_irq = mpu_irq; - else if (!snd_register_interrupt(card, - DRIVER_NAME" - MPU-401", - mpu_irq, SNDRV_IRQ_TYPE_ISA, - snd_card_opti9xx_mpu_interrupt, chip, - pnp ? no_alternatives : possible_mpu_irqs, - &chip->mpuirqptr)) { - chip->chip->mpu_port = mpu_port; - chip->chip->mpu_irq = chip->mpuirqptr->irq; - } - else - chip->chip->mpu_port = -1; - - if (!pnp && (port == SNDRV_DEFAULT_PORT1)) { - for (i = 0; possible_ports[i] != -1; i++) - if (!snd_register_ioport(card, possible_ports[i], 8, - DRIVER_NAME" - WSS", NULL)) { - port = possible_ports[i]; - break; - } - if (port == SNDRV_DEFAULT_PORT1) - return -EBUSY; - } - else if ((error = snd_register_ioport(card, port, 8, - DRIVER_NAME" - WSS", NULL)) < 0) - return error; - chip->chip->wss_base = port; - if ((error = snd_register_interrupt(card, DRIVER_NAME" - WSS", - irq, SNDRV_IRQ_TYPE_ISA, - snd_card_opti9xx_interrupt, chip, - pnp ? no_alternatives : possible_irqs, - &chip->irqptr)) < 0) - return error; - chip->chip->irq = chip->irqptr->irq; - if ((error = snd_register_dma_channel(card, -#if defined(CS4231) || defined(OPTi93X) - DRIVER_NAME" - WSS playback", -#else - DRIVER_NAME" - WSS", -#endif /* CS4231 || OPTi93X */ - dma1, SNDRV_DMA_TYPE_ISA, dma1_size, - pnp ? no_alternatives : possible_dma1s, - &chip->dma1ptr)) < 0) - return error; - chip->chip->dma1 = chip->dma1ptr->dma; -#if defined(CS4231) || defined(OPTi93X) - if ((error = snd_register_dma_channel(card, DRIVER_NAME" - WSS capture", - dma2, SNDRV_DMA_TYPE_ISA, dma2_size, - pnp ? no_alternatives : - possible_dma2s[chip->dma1ptr->dma], - &chip->dma2ptr)) < 0) - return error; - chip->chip->dma2 = chip->dma2ptr->dma; -#endif /* CS4231 || OPTi93X */ - - if (snd_register_ioport(card, - pnp ? fm_port : fm_port = 0x388, 4, - DRIVER_NAME" - OPL", NULL) < 0) - fm_port = -1; - chip->chip->fm_port = fm_port; - - return 0; -} -#endif - static void snd_card_opti9xx_free(struct snd_card *card) { - struct snd_opti9xx *chip = (struct snd_opti9xx *)card->private_data; + struct snd_opti9xx *chip = card->private_data; if (chip) release_and_free_resource(chip->res_mc_base); } -static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static int __init snd_opti9xx_probe(struct snd_card *card) { static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1}; - static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; -#ifdef OPTi93X - static int possible_irqs[] = {5, 9, 10, 11, 7, -1}; -#else - static int possible_irqs[] = {9, 10, 11, 7, -1}; -#endif /* OPTi93X */ - static int possible_mpu_irqs[] = {5, 9, 10, 7, -1}; - static int possible_dma1s[] = {3, 1, 0, -1}; -#if defined(CS4231) || defined(OPTi93X) - static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; -#endif /* CS4231 || OPTi93X */ int error; - struct snd_opti9xx *chip; + struct snd_opti9xx *chip = card->private_data; #if defined(OPTi93X) struct snd_opti93x *codec; #elif defined(CS4231) @@ -1896,65 +1788,14 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, #else struct snd_ad1848 *codec; #endif - struct snd_card *card; struct snd_pcm *pcm; struct snd_rawmidi *rmidi; struct snd_hwdep *synth; -#ifdef CONFIG_PNP - int hw; -#endif /* CONFIG_PNP */ - - if (pcard && !snd_opti9xx_first_hit) - return -EBUSY; - if (!(card = snd_card_new(index, id, THIS_MODULE, - sizeof(struct snd_opti9xx)))) - return -ENOMEM; - card->private_free = snd_card_opti9xx_free; - chip = (struct snd_opti9xx *)card->private_data; - -#ifdef CONFIG_PNP - if (isapnp && pcard && (hw = snd_card_opti9xx_pnp(chip, pcard, pid)) > 0) { - switch (hw) { - case 0x0924: - hw = OPTi9XX_HW_82C924; - break; - case 0x0925: - hw = OPTi9XX_HW_82C925; - break; - case 0x0931: - hw = OPTi9XX_HW_82C931; - break; - default: - snd_card_free(card); - return -ENODEV; - } - - if ((error = snd_opti9xx_init(chip, hw))) { - snd_card_free(card); - return error; - } - if (hw <= OPTi9XX_HW_82C930) - chip->mc_base -= 0x80; - snd_card_set_dev(card, &pcard->card->dev); - } else { -#endif /* CONFIG_PNP */ - if ((error = snd_card_opti9xx_detect(card, chip)) < 0) { - snd_card_free(card); - return error; - } - if ((error = snd_card_set_generic_dev(card)) < 0) { - snd_card_free(card); - return error; - } -#ifdef CONFIG_PNP - } -#endif /* CONFIG_PNP */ if (! chip->res_mc_base && - (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, "OPTi9xx MC")) == NULL) { - snd_card_free(card); + (chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size, + "OPTi9xx MC")) == NULL) return -ENOMEM; - } chip->wss_base = port; chip->fm_port = fm_port; @@ -1968,110 +1809,42 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, if (chip->wss_base == SNDRV_AUTO_PORT) { if ((chip->wss_base = snd_legacy_find_free_ioport(possible_ports, 4)) < 0) { - snd_card_free(card); snd_printk("unable to find a free WSS port\n"); return -EBUSY; } } -#ifdef CONFIG_PNP - if (!isapnp) { -#endif - if (chip->mpu_port == SNDRV_AUTO_PORT) { - if ((chip->mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free MPU401 port\n"); - return -EBUSY; - } - } - if (chip->irq == SNDRV_AUTO_IRQ) { - if ((chip->irq = snd_legacy_find_free_irq(possible_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free IRQ\n"); - return -EBUSY; - } - } - if (chip->mpu_irq == SNDRV_AUTO_IRQ) { - if ((chip->mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free MPU401 IRQ\n"); - return -EBUSY; - } - } - if (chip->dma1 == SNDRV_AUTO_DMA) { - if ((chip->dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA1\n"); - return -EBUSY; - } - } -#if defined(CS4231) || defined(OPTi93X) - if (chip->dma2 == SNDRV_AUTO_DMA) { - if ((chip->dma2 = snd_legacy_find_free_dma(possible_dma2s[chip->dma1 % 4])) < 0) { - snd_card_free(card); - snd_printk("unable to find a free DMA2\n"); - return -EBUSY; - } - } -#endif - -#ifdef CONFIG_PNP - } -#endif - - if ((error = snd_opti9xx_configure(chip))) { - snd_card_free(card); + if ((error = snd_opti9xx_configure(chip))) return error; - } #if defined(OPTi93X) - if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec))) { - snd_card_free(card); + if ((error = snd_opti93x_create(card, chip, chip->dma1, chip->dma2, &codec))) return error; - } - if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0) { - snd_card_free(card); + if ((error = snd_opti93x_pcm(codec, 0, &pcm)) < 0) return error; - } - if ((error = snd_opti93x_mixer(codec)) < 0) { - snd_card_free(card); + if ((error = snd_opti93x_mixer(codec)) < 0) return error; - } #elif defined(CS4231) if ((error = snd_cs4231_create(card, chip->wss_base + 4, -1, chip->irq, chip->dma1, chip->dma2, CS4231_HW_DETECT, 0, - &codec)) < 0) { - snd_card_free(card); + &codec)) < 0) return error; - } - if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0) { - snd_card_free(card); + if ((error = snd_cs4231_pcm(codec, 0, &pcm)) < 0) return error; - } - if ((error = snd_cs4231_mixer(codec)) < 0) { - snd_card_free(card); + if ((error = snd_cs4231_mixer(codec)) < 0) return error; - } - if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0) { - snd_card_free(card); + if ((error = snd_cs4231_timer(codec, 0, &timer)) < 0) return error; - } #else if ((error = snd_ad1848_create(card, chip->wss_base + 4, chip->irq, chip->dma1, - AD1848_HW_DETECT, &codec)) < 0) { - snd_card_free(card); + AD1848_HW_DETECT, &codec)) < 0) return error; - } - if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0) { - snd_card_free(card); + if ((error = snd_ad1848_pcm(codec, 0, &pcm)) < 0) return error; - } - if ((error = snd_ad1848_mixer(codec)) < 0) { - snd_card_free(card); + if ((error = snd_ad1848_mixer(codec)) < 0) return error; - } #endif strcpy(card->driver, chip->name); sprintf(card->shortname, "OPTi %s", card->driver); @@ -2091,7 +1864,8 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, if ((error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, chip->mpu_port, 0, chip->mpu_irq, SA_INTERRUPT, &rmidi))) - snd_printk("no MPU-401 device at 0x%lx?\n", chip->mpu_port); + snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n", + chip->mpu_port); if (chip->fm_port > 0 && chip->fm_port != SNDRV_AUTO_PORT) { struct snd_opl3 *opl3 = NULL; @@ -2117,89 +1891,226 @@ static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, chip->fm_port, chip->fm_port + 2, OPL3_HW_AUTO, 0, &opl3) < 0) { - snd_printk("no OPL device at 0x%lx-0x%lx\n", + snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n", chip->fm_port, chip->fm_port + 4 - 1); } if (opl3) { - if ((error = snd_opl3_timer_new(opl3, #ifdef CS4231 - 1, 2)) < 0) { + const int t1dev = 1; #else - 0, 1)) < 0) { -#endif /* CS4231 */ - snd_card_free(card); + const int t1dev = 0; +#endif + if ((error = snd_opl3_timer_new(opl3, t1dev, t1dev+1)) < 0) return error; - } - if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0) { - snd_card_free(card); + if ((error = snd_opl3_hwdep_new(opl3, 0, 1, &synth)) < 0) return error; - } } } - if ((error = snd_card_register(card))) { + return snd_card_register(card); +} + +static struct snd_card *snd_opti9xx_card_new(void) +{ + struct snd_card *card; + + card = snd_card_new(index, id, THIS_MODULE, sizeof(struct snd_opti9xx)); + if (! card) + return NULL; + card->private_free = snd_card_opti9xx_free; + return card; +} + +static int __init snd_opti9xx_nonpnp_probe(struct platform_device *devptr) +{ + struct snd_card *card; + int error; + static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1}; +#ifdef OPTi93X + static int possible_irqs[] = {5, 9, 10, 11, 7, -1}; +#else + static int possible_irqs[] = {9, 10, 11, 7, -1}; +#endif /* OPTi93X */ + static int possible_mpu_irqs[] = {5, 9, 10, 7, -1}; + static int possible_dma1s[] = {3, 1, 0, -1}; +#if defined(CS4231) || defined(OPTi93X) + static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}}; +#endif /* CS4231 || OPTi93X */ + + if (snd_opti9xx_pnp_is_probed) + return -EBUSY; + + if (mpu_port == SNDRV_AUTO_PORT) { + if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) { + snd_printk(KERN_ERR "unable to find a free MPU401 port\n"); + return -EBUSY; + } + } + if (irq == SNDRV_AUTO_IRQ) { + if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) { + snd_printk(KERN_ERR "unable to find a free IRQ\n"); + return -EBUSY; + } + } + if (mpu_irq == SNDRV_AUTO_IRQ) { + if ((mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) { + snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n"); + return -EBUSY; + } + } + if (dma1 == SNDRV_AUTO_DMA) { + if ((dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) { + snd_printk(KERN_ERR "unable to find a free DMA1\n"); + return -EBUSY; + } + } +#if defined(CS4231) || defined(OPTi93X) + if (dma2 == SNDRV_AUTO_DMA) { + if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) { + snd_printk("unable to find a free DMA2\n"); + return -EBUSY; + } + } +#endif + + card = snd_opti9xx_card_new(); + if (! card) + return -ENOMEM; + + if ((error = snd_card_opti9xx_detect(card, card->private_data)) < 0) { snd_card_free(card); return error; } - snd_opti9xx_first_hit = 0; - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_opti9xx_legacy = card; + snd_card_set_dev(card, &devptr->dev); + if ((error = snd_opti9xx_probe(card)) < 0) { + snd_card_free(card); + return error; + } + platform_set_drvdata(devptr, card); + return 0; +} + +static int __devexit snd_opti9xx_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); return 0; } +static struct platform_driver snd_opti9xx_driver = { + .probe = snd_opti9xx_nonpnp_probe, + .remove = __devexit_p(snd_opti9xx_nonpnp_remove), + /* FIXME: suspend/resume */ + .driver = { + .name = DRIVER_NAME + }, +}; + #ifdef CONFIG_PNP -static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard) +static int __init snd_opti9xx_pnp_probe(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); + struct snd_card *card; + int error, hw; + struct snd_opti9xx *chip; + + if (snd_opti9xx_pnp_is_probed) + return -EBUSY; + if (! isapnp) + return -ENODEV; + card = snd_opti9xx_card_new(); + if (! card) + return -ENOMEM; + chip = card->private_data; - snd_card_disconnect(card); - snd_card_free_in_thread(card); - snd_opti9xx_first_hit = 0; + hw = snd_card_opti9xx_pnp(chip, pcard, pid); + switch (hw) { + case 0x0924: + hw = OPTi9XX_HW_82C924; + break; + case 0x0925: + hw = OPTi9XX_HW_82C925; + break; + case 0x0931: + hw = OPTi9XX_HW_82C931; + break; + default: + snd_card_free(card); + return -ENODEV; + } + + if ((error = snd_opti9xx_init(chip, hw))) { + snd_card_free(card); + return error; + } + if (hw <= OPTi9XX_HW_82C930) + chip->mc_base -= 0x80; + snd_card_set_dev(card, &pcard->card->dev); + if ((error = snd_opti9xx_probe(card)) < 0) { + snd_card_free(card); + return error; + } + pnp_set_card_drvdata(pcard, card); + snd_opti9xx_pnp_is_probed = 1; + return 0; +} + +static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard) +{ + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); + snd_opti9xx_pnp_is_probed = 0; } static struct pnp_card_driver opti9xx_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = "opti9xx", .id_table = snd_opti9xx_pnpids, - .probe = snd_card_opti9xx_probe, + .probe = snd_opti9xx_pnp_probe, .remove = __devexit_p(snd_opti9xx_pnp_remove), }; #endif -static int __init alsa_card_opti9xx_init(void) -{ - int cards, error; - #ifdef CONFIG_PNP - cards = pnp_register_card_driver(&opti9xx_pnpc_driver); +#define is_isapnp_selected() isapnp #else - cards = 0; -#endif - if (cards == 0 && (error = snd_card_opti9xx_probe(NULL, NULL)) < 0) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&opti9xx_pnpc_driver); +#define is_isapnp_selected() 0 #endif -#ifdef MODULE #ifdef OPTi93X - printk(KERN_ERR "no OPTi 82C93x soundcard found\n"); +#define CHIP_NAME "82C93x" #else - printk(KERN_ERR "no OPTi 82C92x soundcard found\n"); -#endif /* OPTi93X */ +#define CHIP_NAME "82C92x" #endif - return error; + +static int __init alsa_card_opti9xx_init(void) +{ + int error; + struct platform_device *device; + + pnp_register_card_driver(&opti9xx_pnpc_driver); + if (snd_opti9xx_pnp_is_probed) + return 0; + if (! is_isapnp_selected()) { + error = platform_driver_register(&snd_opti9xx_driver); + if (error < 0) + return error; + device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); + if (! IS_ERR(device)) + return 0; + platform_driver_unregister(&snd_opti9xx_driver); } - return 0; + pnp_unregister_card_driver(&opti9xx_pnpc_driver); +#ifdef MODULE + printk(KERN_ERR "no OPTi " CHIP_NAME " soundcard found\n"); +#endif + return -ENODEV; } static void __exit alsa_card_opti9xx_exit(void) { -#ifdef CONFIG_PNP + if (! snd_opti9xx_pnp_is_probed) + platform_driver_unregister(&snd_opti9xx_driver); pnp_unregister_card_driver(&opti9xx_pnpc_driver); -#endif - if (snd_opti9xx_legacy) - snd_card_free(snd_opti9xx_legacy); } module_init(alsa_card_opti9xx_init) -- cgit v1.1 From d29b761e6162d3b91079b25334270a2c36f6157d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:14:11 +0100 Subject: [ALSA] wavefront - Use platform_device Modules: Wavefront drivers Rewrite the probe/remove with platform_device. Signed-off-by: Takashi Iwai --- sound/isa/wavefront/wavefront.c | 267 +++++++++++++++++++++------------------- 1 file changed, 142 insertions(+), 125 deletions(-) diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 9e5b571..77a3012 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -81,7 +83,6 @@ MODULE_PARM_DESC(fm_port, "FM port #."); module_param_array(use_cs4232_midi, bool, NULL, 0444); MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); -static struct snd_card *snd_wavefront_legacy[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; #ifdef CONFIG_PNP @@ -240,7 +241,7 @@ snd_wavefront_pnp (int dev, snd_wavefront_card_t *acard, struct pnp_card_link *c cs4232_mpu_irq[dev] = pnp_irq(pdev, 0); } - snd_printk ("CS4232 MPU: port=0x%lx, irq=%i\n", + snd_printk (KERN_INFO "CS4232 MPU: port=0x%lx, irq=%i\n", cs4232_mpu_port[dev], cs4232_mpu_irq[dev]); } @@ -315,7 +316,7 @@ snd_wavefront_new_fx (struct snd_card *card, struct snd_hwdep *fx_processor; if (snd_wavefront_fx_start (&acard->wavefront)) { - snd_printk ("cannot initialize YSS225 FX processor"); + snd_printk (KERN_ERR "cannot initialize YSS225 FX processor"); return NULL; } @@ -347,7 +348,7 @@ snd_wavefront_new_midi (struct snd_card *card, first = 0; acard->wavefront.midi.base = port; if (snd_wavefront_midi_start (acard)) { - snd_printk ("cannot initialize MIDI interface\n"); + snd_printk (KERN_ERR "cannot initialize MIDI interface\n"); return NULL; } } @@ -385,42 +386,17 @@ snd_wavefront_free(struct snd_card *card) } } -static int __devinit -snd_wavefront_probe (int dev, struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +static struct snd_card *snd_wavefront_card_new(int dev) { struct snd_card *card; snd_wavefront_card_t *acard; - struct snd_cs4231 *chip; - struct snd_hwdep *wavefront_synth; - struct snd_rawmidi *ics2115_internal_rmidi = NULL; - struct snd_rawmidi *ics2115_external_rmidi = NULL; - struct snd_hwdep *fx_processor; - int hw_dev = 0, midi_dev = 0, err; -#ifdef CONFIG_PNP - if (!isapnp[dev]) { -#endif - if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify CS4232 port\n"); - return -EINVAL; - } - if (ics2115_port[dev] == SNDRV_AUTO_PORT) { - snd_printk("specify ICS2115 port\n"); - return -ENODEV; - } -#ifdef CONFIG_PNP - } -#endif - card = snd_card_new (index[dev], - id[dev], - THIS_MODULE, + card = snd_card_new (index[dev], id[dev], THIS_MODULE, sizeof(snd_wavefront_card_t)); + if (card == NULL) + return NULL; - if (card == NULL) { - return -ENOMEM; - } - acard = (snd_wavefront_card_t *)card->private_data; + acard = card->private_data; acard->wavefront.irq = -1; spin_lock_init(&acard->wavefront.irq_lock); init_waitqueue_head(&acard->wavefront.interrupt_sleeper); @@ -428,18 +404,19 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, spin_lock_init(&acard->wavefront.midi.virtual); card->private_free = snd_wavefront_free; -#ifdef CONFIG_PNP - if (isapnp[dev]) { - if (snd_wavefront_pnp (dev, acard, pcard, pid) < 0) { - if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { - snd_printk ("isapnp detection failed\n"); - snd_card_free (card); - return -ENODEV; - } - } - snd_card_set_dev(card, &pcard->card->dev); - } -#endif /* CONFIG_PNP */ + return card; +} + +static int __devinit +snd_wavefront_probe (struct snd_card *card, int dev) +{ + snd_wavefront_card_t *acard = card->private_data; + struct snd_cs4231 *chip; + struct snd_hwdep *wavefront_synth; + struct snd_rawmidi *ics2115_internal_rmidi = NULL; + struct snd_rawmidi *ics2115_external_rmidi = NULL; + struct snd_hwdep *fx_processor; + int hw_dev = 0, midi_dev = 0, err; /* --------- PCM --------------- */ @@ -450,19 +427,15 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, dma1[dev], dma2[dev], CS4231_HW_DETECT, 0, &chip)) < 0) { - snd_card_free(card); - snd_printk ("can't allocate CS4231 device\n"); + snd_printk (KERN_ERR "can't allocate CS4231 device\n"); return err; } - if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0) { - snd_card_free(card); + if ((err = snd_cs4231_pcm (chip, 0, NULL)) < 0) return err; - } - if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0) { - snd_card_free(card); + + if ((err = snd_cs4231_timer (chip, 0, NULL)) < 0) return err; - } /* ---------- OPL3 synth --------- */ @@ -474,28 +447,26 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, fm_port[dev] + 2, OPL3_HW_OPL3_CS, 0, &opl3)) < 0) { - snd_printk ("can't allocate or detect OPL3 synth\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't allocate or detect OPL3 synth\n"); return err; } - if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0) { - snd_card_free(card); + if ((err = snd_opl3_hwdep_new(opl3, hw_dev, 1, NULL)) < 0) return err; - } hw_dev++; } /* ------- ICS2115 Wavetable synth ------- */ - if ((acard->wavefront.res_base = request_region(ics2115_port[dev], 16, "ICS2115")) == NULL) { - snd_printk("unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", ics2115_port[dev], ics2115_port[dev] + 16 - 1); - snd_card_free(card); + if ((acard->wavefront.res_base = request_region(ics2115_port[dev], 16, + "ICS2115")) == NULL) { + snd_printk(KERN_ERR "unable to grab ICS2115 i/o region 0x%lx-0x%lx\n", + ics2115_port[dev], ics2115_port[dev] + 16 - 1); return -EBUSY; } - if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt, SA_INTERRUPT, "ICS2115", (void *)acard)) { - snd_printk("unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]); - snd_card_free(card); + if (request_irq(ics2115_irq[dev], snd_wavefront_ics2115_interrupt, + SA_INTERRUPT, "ICS2115", acard)) { + snd_printk(KERN_ERR "unable to use ICS2115 IRQ %d\n", ics2115_irq[dev]); return -EBUSY; } @@ -503,8 +474,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, acard->wavefront.base = ics2115_port[dev]; if ((wavefront_synth = snd_wavefront_new_synth (card, hw_dev, acard)) == NULL) { - snd_printk ("can't create WaveFront synth device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't create WaveFront synth device\n"); return -ENOMEM; } @@ -515,8 +485,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, /* --------- Mixer ------------ */ if ((err = snd_cs4231_mixer(chip)) < 0) { - snd_printk ("can't allocate mixer device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't allocate mixer device\n"); return err; } @@ -528,8 +497,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, cs4232_mpu_irq[dev], SA_INTERRUPT, NULL)) < 0) { - snd_printk ("can't allocate CS4232 MPU-401 device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't allocate CS4232 MPU-401 device\n"); return err; } midi_dev++; @@ -545,8 +513,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, ics2115_port[dev], internal_mpu); if (ics2115_internal_rmidi == NULL) { - snd_printk ("can't setup ICS2115 internal MIDI device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't setup ICS2115 internal MIDI device\n"); return -ENOMEM; } midi_dev++; @@ -562,8 +529,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, ics2115_port[dev], external_mpu); if (ics2115_external_rmidi == NULL) { - snd_printk ("can't setup ICS2115 external MIDI device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't setup ICS2115 external MIDI device\n"); return -ENOMEM; } midi_dev++; @@ -577,8 +543,7 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, acard, ics2115_port[dev]); if (fx_processor == NULL) { - snd_printk ("can't setup FX device\n"); - snd_card_free(card); + snd_printk (KERN_ERR "can't setup FX device\n"); return -ENOMEM; } @@ -619,49 +584,97 @@ snd_wavefront_probe (int dev, struct pnp_card_link *pcard, ics2115_port[dev], ics2115_irq[dev]); - if ((err = snd_card_set_generic_dev(card)) < 0) { - snd_card_free(card); - return err; + return snd_card_register(card); +} + +static int __init snd_wavefront_nonpnp_probe(struct platform_device *pdev) +{ + int dev = pdev->id; + struct snd_card *card; + int err; + + if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { + snd_printk("specify CS4232 port\n"); + return -EINVAL; + } + if (ics2115_port[dev] == SNDRV_AUTO_PORT) { + snd_printk("specify ICS2115 port\n"); + return -ENODEV; } - if ((err = snd_card_register(card)) < 0) { + card = snd_wavefront_card_new(dev); + if (! card) + return -ENOMEM; + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_wavefront_probe(card, dev)) < 0) { snd_card_free(card); return err; } - if (pcard) - pnp_set_card_drvdata(pcard, card); - else - snd_wavefront_legacy[dev] = card; + + platform_set_drvdata(pdev, card); return 0; -} +} + +static int __devexit snd_wavefront_nonpnp_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define WAVEFRONT_DRIVER "snd_wavefront" + +static struct platform_driver snd_wavefront_driver = { + .probe = snd_wavefront_nonpnp_probe, + .remove = __devexit_p(snd_wavefront_nonpnp_remove), + /* FIXME: suspend, resume */ + .driver = { + .name = WAVEFRONT_DRIVER + }, +}; + #ifdef CONFIG_PNP -static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *card, - const struct pnp_card_device_id *id) +static int __devinit snd_wavefront_pnp_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { - static int dev; - int res; - - for ( ; dev < SNDRV_CARDS; dev++) { - if (!enable[dev] || !isapnp[dev]) - continue; - res = snd_wavefront_probe(dev, card, id); - if (res < 0) - return res; - dev++; - return 0; - } - - return -ENODEV; + static int dev; + struct snd_card *card; + int res; + + for ( ; dev < SNDRV_CARDS; dev++) { + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_wavefront_card_new(dev); + if (! card) + return -ENOMEM; + + if (snd_wavefront_pnp (dev, card->private_data, pcard, pid) < 0) { + if (cs4232_pcm_port[dev] == SNDRV_AUTO_PORT) { + snd_printk (KERN_ERR "isapnp detection failed\n"); + snd_card_free (card); + return -ENODEV; + } + } + snd_card_set_dev(card, &pcard->card->dev); + + if ((res = snd_wavefront_probe(card, dev)) < 0) + return res; + + pnp_set_card_drvdata(pcard, card); + dev++; + return 0; } static void __devexit snd_wavefront_pnp_remove(struct pnp_card_link * pcard) { - struct snd_card *card = (struct snd_card *) pnp_get_card_drvdata(pcard); - - snd_card_disconnect(card); - snd_card_free_in_thread(card); + snd_card_free(pnp_get_card_drvdata(pcard)); + pnp_set_card_drvdata(pcard, NULL); } static struct pnp_card_driver wavefront_pnpc_driver = { @@ -670,31 +683,40 @@ static struct pnp_card_driver wavefront_pnpc_driver = { .id_table = snd_wavefront_pnpids, .probe = snd_wavefront_pnp_detect, .remove = __devexit_p(snd_wavefront_pnp_remove), + /* FIXME: suspend,resume */ }; #endif /* CONFIG_PNP */ static int __init alsa_card_wavefront_init(void) { - int cards = 0; - int dev; - for (dev = 0; dev < SNDRV_CARDS; dev++) { - if (!enable[dev]) - continue; + int i, err, cards = 0; + + if ((err = platform_driver_register(&snd_wavefront_driver)) < 0) + return err; + + for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { + struct platform_device *device; #ifdef CONFIG_PNP - if (isapnp[dev]) + if (isapnp[i]) continue; #endif - if (snd_wavefront_probe(dev, NULL, NULL) >= 0) - cards++; + device = platform_device_register_simple(WAVEFRONT_DRIVER, + i, NULL, 0); + if (IS_ERR(device)) { + platform_driver_unregister(&snd_wavefront_driver); + return PTR_ERR(device); + } + cards++; } -#ifdef CONFIG_PNP - cards += pnp_register_card_driver(&wavefront_pnpc_driver); -#endif + + i = pnp_register_card_driver(&wavefront_pnpc_driver); + if (i > 0) + cards += i; + if (!cards) { -#ifdef CONFIG_PNP pnp_unregister_card_driver(&wavefront_pnpc_driver); -#endif + platform_driver_unregister(&snd_wavefront_driver); #ifdef MODULE printk (KERN_ERR "No WaveFront cards found or devices busy\n"); #endif @@ -705,13 +727,8 @@ static int __init alsa_card_wavefront_init(void) static void __exit alsa_card_wavefront_exit(void) { - int idx; - -#ifdef CONFIG_PNP pnp_unregister_card_driver(&wavefront_pnpc_driver); -#endif - for (idx = 0; idx < SNDRV_CARDS; idx++) - snd_card_free(snd_wavefront_legacy[idx]); + platform_driver_unregister(&snd_wavefront_driver); } module_init(alsa_card_wavefront_init) -- cgit v1.1 From 7f52bdb61bdb945b29c2a3b3a6d0f8e6e80b8ec8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:15:20 +0100 Subject: [ALSA] Remove SND_GENERIC_DRIVER from isa/Kconfig Modules: ISA Remove the obsolete SND_GENERIC_DRIVER from isa/Kconfig. Signed-off-by: Takashi Iwai --- sound/isa/Kconfig | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/sound/isa/Kconfig b/sound/isa/Kconfig index 04cafd2..ff8fef9 100644 --- a/sound/isa/Kconfig +++ b/sound/isa/Kconfig @@ -6,12 +6,10 @@ menu "ISA devices" config SND_AD1848_LIB tristate select SND_PCM - select SND_GENERIC_DRIVER config SND_CS4231_LIB tristate select SND_PCM - select SND_GENERIC_DRIVER config SND_AD1816A tristate "Analog Devices SoundPort AD1816A" @@ -150,7 +148,6 @@ config SND_ES1688 select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for ESS AudioDrive ES688 or ES1688 chips. @@ -164,7 +161,6 @@ config SND_ES18XX select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for ESS AudioDrive ES18xx chips. @@ -180,7 +176,6 @@ config SND_GUSCLASSIC select SND_RAWMIDI select SND_PCM select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound Classic soundcards. @@ -195,7 +190,6 @@ config SND_GUSEXTREME select SND_MPU401_UART select SND_PCM select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound Extreme soundcards. @@ -209,7 +203,6 @@ config SND_GUSMAX select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for Gravis UltraSound MAX soundcards. @@ -223,7 +216,6 @@ config SND_INTERWAVE select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for AMD InterWave based soundcards (Gravis UltraSound Plug & Play, STB SoundRage32, @@ -238,7 +230,6 @@ config SND_INTERWAVE_STB select SND_RAWMIDI select SND_CS4231_LIB select SND_GUS_SYNTH - select SND_GENERIC_DRIVER help Say Y here to include support for AMD InterWave based soundcards with a TEA6330T bass and treble regulator @@ -294,7 +285,6 @@ config SND_OPTI93X select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for soundcards based on Opti 82C93x chips. @@ -308,7 +298,6 @@ config SND_SB8 select SND_OPL3_LIB select SND_RAWMIDI select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for Creative Sound Blaster 1.0/ 2.0/Pro (8-bit) or 100% compatible soundcards. @@ -322,7 +311,6 @@ config SND_SB16 select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for Sound Blaster 16 soundcards (including the Plug and Play version). @@ -336,7 +324,6 @@ config SND_SBAWE select SND_OPL3_LIB select SND_MPU401_UART select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for Sound Blaster AWE soundcards (including the Plug and Play version). -- cgit v1.1 From e4f163d96080dda40fd02df725f3672d035e4c5a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:15:58 +0100 Subject: [ALSA] pdaudiocf - Fix PM support Modules: PDAudioCF driver Fix the PM support on pdaudiocf driver. Signed-off-by: Takashi Iwai --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 6 ++---- sound/pcmcia/pdaudiocf/pdaudiocf.h | 4 ++-- sound/pcmcia/pdaudiocf/pdaudiocf_core.c | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 0ba335d..a7cd2d4 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -217,8 +217,6 @@ static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irq if (err < 0) return err; - snd_card_set_pm_callback(card, snd_pdacf_suspend, snd_pdacf_resume, pdacf); - if ((err = snd_card_register(card)) < 0) return err; @@ -339,7 +337,7 @@ static int pdacf_event(event_t event, int priority, event_callback_args_t *args) link->state |= DEV_SUSPEND; if (chip) { snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); - snd_pdacf_suspend(chip->card, PMSG_SUSPEND); + snd_pdacf_suspend(chip, PMSG_SUSPEND); } /* Fall through... */ case CS_EVENT_RESET_PHYSICAL: @@ -358,7 +356,7 @@ static int pdacf_event(event_t event, int priority, event_callback_args_t *args) pcmcia_request_configuration(link->handle, &link->conf); if (chip) { snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); - snd_pdacf_resume(chip->card); + snd_pdacf_resume(chip); } } snd_printdd(KERN_DEBUG "resume done!\n"); diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.h b/sound/pcmcia/pdaudiocf/pdaudiocf.h index ad8f32e..2744f18 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.h +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.h @@ -134,8 +134,8 @@ struct snd_pdacf *snd_pdacf_create(struct snd_card *card); int snd_pdacf_ak4117_create(struct snd_pdacf *pdacf); void snd_pdacf_powerdown(struct snd_pdacf *chip); #ifdef CONFIG_PM -int snd_pdacf_suspend(struct snd_card *card, pm_message_t state); -int snd_pdacf_resume(struct snd_card *card); +int snd_pdacf_suspend(struct snd_pdacf *chip, pm_message_t state); +int snd_pdacf_resume(struct snd_pdacf *chip); #endif int snd_pdacf_pcm_new(struct snd_pdacf *chip); irqreturn_t pdacf_interrupt(int irq, void *dev, struct pt_regs *regs); diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c index 4f89823..bd0d70f 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_core.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_core.c @@ -255,11 +255,11 @@ void snd_pdacf_powerdown(struct snd_pdacf *chip) #ifdef CONFIG_PM -int snd_pdacf_suspend(struct snd_card *card, pm_message_t state) +int snd_pdacf_suspend(struct snd_pdacf *chip, pm_message_t state) { - struct snd_pdacf *chip = card->pm_private_data; u16 val; + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); /* disable interrupts, but use direct write to preserve old register value in chip->regmap */ val = inw(chip->port + PDAUDIOCF_REG_IER); @@ -275,9 +275,8 @@ static inline int check_signal(struct snd_pdacf *chip) return (chip->ak4117->rcs0 & AK4117_UNLCK) == 0; } -int snd_pdacf_resume(struct snd_card *card) +int snd_pdacf_resume(struct snd_pdacf *chip) { - struct snd_pdacf *chip = card->pm_private_data; int timeout = 40; pdacf_reinit(chip, 1); @@ -286,6 +285,7 @@ int snd_pdacf_resume(struct snd_card *card) (snd_ak4117_external_rate(chip->ak4117) <= 0 || !check_signal(chip))) mdelay(1); chip->chip_status &= ~PDAUDIOCF_STAT_IS_SUSPENDED; + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); return 0; } #endif -- cgit v1.1 From 5e12bea0833e47117c31f13b528e31dc8112de57 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:17:08 +0100 Subject: [ALSA] powermac - Use platform_device Modules: PPC,PPC PMAC driver,PPC PowerMac driver Rewrite the probe/remove with platform_device. Move the PM support to platform_device's callbacks. Signed-off-by: Takashi Iwai --- sound/ppc/Kconfig | 1 - sound/ppc/pmac.c | 79 ++++------------------------------------------------ sound/ppc/pmac.h | 5 ++++ sound/ppc/powermac.c | 67 +++++++++++++++++++++++++++++++++----------- 4 files changed, 62 insertions(+), 90 deletions(-) diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig index 206b933..a3fb149 100644 --- a/sound/ppc/Kconfig +++ b/sound/ppc/Kconfig @@ -13,7 +13,6 @@ config SND_POWERMAC tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)" depends on SND && I2C && INPUT && PPC_PMAC select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for the integrated sound device. diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 222765f..4f0a420 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -36,14 +36,6 @@ #include -#ifdef CONFIG_PM -static int snd_pmac_register_sleep_notifier(struct snd_pmac *chip); -static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip); -static int snd_pmac_suspend(struct snd_card *card, pm_message_t state); -static int snd_pmac_resume(struct snd_card *card); -#endif - - /* fixed frequency table for awacs, screamer, burgundy, DACA (44100 max) */ static int awacs_freqs[8] = { 44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350 @@ -784,9 +776,6 @@ static int snd_pmac_free(struct snd_pmac *chip) } snd_pmac_sound_feature(chip, 0); -#ifdef CONFIG_PM - snd_pmac_unregister_sleep_notifier(chip); -#endif /* clean up mixer if any */ if (chip->mixer_free) @@ -1298,12 +1287,6 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) /* Reset dbdma channels */ snd_pmac_dbdma_reset(chip); -#ifdef CONFIG_PM - /* add sleep notifier */ - if (! snd_pmac_register_sleep_notifier(chip)) - snd_card_set_pm_callback(chip->card, snd_pmac_suspend, snd_pmac_resume, chip); -#endif - if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) goto __error; @@ -1328,11 +1311,11 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return) * Save state when going to sleep, restore it afterwards. */ -static int snd_pmac_suspend(struct snd_card *card, pm_message_t state) +void snd_pmac_suspend(struct snd_pmac *chip) { - struct snd_pmac *chip = card->pm_private_data; unsigned long flags; + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); if (chip->suspend) chip->suspend(chip); snd_pcm_suspend_all(chip->pcm); @@ -1346,22 +1329,18 @@ static int snd_pmac_suspend(struct snd_card *card, pm_message_t state) if (chip->rx_irq >= 0) disable_irq(chip->rx_irq); snd_pmac_sound_feature(chip, 0); - return 0; } -static int snd_pmac_resume(struct snd_card *card) +void snd_pmac_resume(struct snd_pmac *chip) { - struct snd_pmac *chip = card->pm_private_data; - snd_pmac_sound_feature(chip, 1); if (chip->resume) chip->resume(chip); /* enable CD sound input */ - if (chip->macio_base && chip->is_pbook_G3) { + if (chip->macio_base && chip->is_pbook_G3) out_8(chip->macio_base + 0x37, 3); - } else if (chip->is_pbook_3400) { + else if (chip->is_pbook_3400) in_8(chip->latch_base + 0x190); - } snd_pmac_pcm_set_format(chip); @@ -1372,53 +1351,7 @@ static int snd_pmac_resume(struct snd_card *card) if (chip->rx_irq >= 0) enable_irq(chip->rx_irq); - return 0; -} - -/* the chip is stored statically by snd_pmac_register_sleep_notifier - * because we can't have any private data for notify callback. - */ -static struct snd_pmac *sleeping_pmac = NULL; - -static int snd_pmac_sleep_notify(struct pmu_sleep_notifier *self, int when) -{ - struct snd_pmac *chip; - - chip = sleeping_pmac; - if (! chip) - return 0; - - switch (when) { - case PBOOK_SLEEP_NOW: - snd_pmac_suspend(chip->card, PMSG_SUSPEND); - break; - case PBOOK_WAKE: - snd_pmac_resume(chip->card); - break; - } - return PBOOK_SLEEP_OK; -} - -static struct pmu_sleep_notifier snd_pmac_sleep_notifier = { - snd_pmac_sleep_notify, SLEEP_LEVEL_SOUND, -}; - -static int __init snd_pmac_register_sleep_notifier(struct snd_pmac *chip) -{ - /* should be protected here.. */ - snd_assert(! sleeping_pmac, return -EBUSY); - sleeping_pmac = chip; - pmu_register_sleep_notifier(&snd_pmac_sleep_notifier); - return 0; -} - -static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip) -{ - /* should be protected here.. */ - snd_assert(sleeping_pmac == chip, return -ENODEV); - pmu_unregister_sleep_notifier(&snd_pmac_sleep_notifier); - sleeping_pmac = NULL; - return 0; + snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); } #endif /* CONFIG_PM */ diff --git a/sound/ppc/pmac.h b/sound/ppc/pmac.h index e223884..086da7a 100644 --- a/sound/ppc/pmac.h +++ b/sound/ppc/pmac.h @@ -176,6 +176,11 @@ unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed); void snd_pmac_beep_dma_stop(struct snd_pmac *chip); +#ifdef CONFIG_PM +void snd_pmac_suspend(struct snd_pmac *chip); +void snd_pmac_resume(struct snd_pmac *chip); +#endif + /* initialize mixer */ int snd_pmac_awacs_init(struct snd_pmac *chip); int snd_pmac_burgundy_init(struct snd_pmac *chip); diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index db139cd..efa06fe 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c @@ -20,6 +20,8 @@ #include #include +#include +#include #include #include #include @@ -46,15 +48,9 @@ MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); /* - * card entry */ -static struct snd_card *snd_pmac_card = NULL; - -/* - */ - -static int __init snd_pmac_probe(void) +static int __init snd_pmac_probe(struct platform_device *devptr) { struct snd_card *card; struct snd_pmac *chip; @@ -67,6 +63,7 @@ static int __init snd_pmac_probe(void) if ((err = snd_pmac_new(card, &chip)) < 0) goto __error; + card->private_data = chip; switch (chip->model) { case PMAC_BURGUNDY: @@ -131,13 +128,12 @@ static int __init snd_pmac_probe(void) if (enable_beep) snd_pmac_attach_beep(chip); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto __error; + snd_card_set_dev(card, &devptr->dev); if ((err = snd_card_register(card)) < 0) goto __error; - snd_pmac_card = card; + platform_set_drvdata(devptr, card); return 0; __error: @@ -146,23 +142,62 @@ __error: } -/* - * MODULE stuff - */ +static int __devexit snd_pmac_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#ifdef CONFIG_PM +static int snd_pmac_driver_suspend(struct platform_device *devptr, pm_message_t state) +{ + struct snd_card *card = platform_get_drvdata(devptr); + snd_pmac_suspend(card->private_data); + return 0; +} + +static int snd_pmac_driver_resume(struct platform_device *devptr) +{ + struct snd_card *card = platform_get_drvdata(devptr); + snd_pmac_resume(card->private_data); + return 0; +} +#endif + +#define SND_PMAC_DRIVER "snd_powermac" + +static struct platform_driver snd_pmac_driver = { + .probe = snd_pmac_probe, + .remove = __devexit_p(snd_pmac_remove), +#ifdef CONFIG_PM + .suspend = snd_pmac_driver_suspend, + .resume = snd_pmac_driver_resume, +#endif + .driver = { + .name = SND_PMAC_DRIVER + }, +}; static int __init alsa_card_pmac_init(void) { int err; - if ((err = snd_pmac_probe()) < 0) + struct platform_device *device; + + if ((err = platform_driver_register(&snd_pmac_driver)) < 0) return err; + device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0); + if (IS_ERR(device)) { + platform_driver_unregister(&snd_pmac_driver); + return PTR_ERR(device); + } return 0; } static void __exit alsa_card_pmac_exit(void) { - if (snd_pmac_card) - snd_card_free(snd_pmac_card); + platform_driver_unregister(&snd_pmac_driver); } module_init(alsa_card_pmac_init) -- cgit v1.1 From 792a6c51875c9d3b4a7b9af553b7fd18e8d84684 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:19:25 +0100 Subject: [ALSA] Fix PM support Modules: ARM AACI PL041 driver,ARM PXA2XX driver Fix PM support of aaci and pxa2xx drivers. Signed-off-by: Takashi Iwai --- sound/arm/aaci.c | 12 +++--------- sound/arm/pxa2xx-ac97.c | 36 ++++++++++++++++-------------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 691f6dd..5e9a81a 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -635,19 +635,14 @@ static struct snd_pcm_ops aaci_playback_ops = { static int aaci_do_suspend(struct snd_card *card, unsigned int state) { struct aaci *aaci = card->private_data; - if (aaci->card->power_state != SNDRV_CTL_POWER_D3cold) { - snd_pcm_suspend_all(aaci->pcm); - snd_power_change_state(aaci->card, SNDRV_CTL_POWER_D3cold); - } + snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); + snd_pcm_suspend_all(aaci->pcm); return 0; } static int aaci_do_resume(struct snd_card *card, unsigned int state) { - struct aaci *aaci = card->private_data; - if (aaci->card->power_state != SNDRV_CTL_POWER_D0) { - snd_power_change_state(aaci->card, SNDRV_CTL_POWER_D0); - } + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } @@ -780,7 +775,6 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev) return ERR_PTR(-ENOMEM); card->private_free = aaci_free_card; - snd_card_set_pm_callback(card, aaci_do_suspend, aaci_do_resume, NULL); strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver)); strlcpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname)); diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index d9efc37..dda64be 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c @@ -247,30 +247,28 @@ static struct pxa2xx_pcm_client pxa2xx_ac97_pcm_client = { static int pxa2xx_ac97_do_suspend(struct snd_card *card, pm_message_t state) { - if (card->power_state != SNDRV_CTL_POWER_D3cold) { - pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; - snd_pcm_suspend_all(pxa2xx_ac97_pcm); - snd_ac97_suspend(pxa2xx_ac97_ac97); - snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); - if (platform_ops && platform_ops->suspend) - platform_ops->suspend(platform_ops->priv); - GCR |= GCR_ACLINK_OFF; - pxa_set_cken(CKEN2_AC97, 0); - } + pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; + + snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); + snd_pcm_suspend_all(pxa2xx_ac97_pcm); + snd_ac97_suspend(pxa2xx_ac97_ac97); + if (platform_ops && platform_ops->suspend) + platform_ops->suspend(platform_ops->priv); + GCR |= GCR_ACLINK_OFF; + pxa_set_cken(CKEN2_AC97, 0); return 0; } static int pxa2xx_ac97_do_resume(struct snd_card *card) { - if (card->power_state != SNDRV_CTL_POWER_D0) { - pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; - pxa_set_cken(CKEN2_AC97, 1); - if (platform_ops && platform_ops->resume) - platform_ops->resume(platform_ops->priv); - snd_ac97_resume(pxa2xx_ac97_ac97); - snd_power_change_state(card, SNDRV_CTL_POWER_D0); - } + pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; + + pxa_set_cken(CKEN2_AC97, 1); + if (platform_ops && platform_ops->resume) + platform_ops->resume(platform_ops->priv); + snd_ac97_resume(pxa2xx_ac97_ac97); + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } @@ -349,8 +347,6 @@ static int pxa2xx_ac97_probe(struct platform_device *dev) snprintf(card->longname, sizeof(card->longname), "%s (%s)", dev->dev.driver->name, card->mixername); - snd_card_set_pm_callback(card, pxa2xx_ac97_do_suspend, - pxa2xx_ac97_do_resume, NULL); ret = snd_card_register(card); if (ret == 0) { platform_set_drvdata(dev, card); -- cgit v1.1 From 2b3f558727244efb6edb0866952331f537da13a4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:19:50 +0100 Subject: [ALSA] Use platform_device Modules: SA11xx UDA1341 driver Rewrite the probe/remove with platform_device. Fix PM support, too. Signed-off-by: Takashi Iwai --- sound/arm/sa11xx-uda1341.c | 78 +++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 785726e..3c342c1 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -21,7 +21,7 @@ * merged HAL layer (patches from Brian) */ -/* $Id: sa11xx-uda1341.c,v 1.25 2005/11/17 15:10:58 tiwai Exp $ */ +/* $Id: sa11xx-uda1341.c,v 1.26 2005/11/17 17:19:50 tiwai Exp $ */ /*************************************************************************************************** * @@ -64,6 +64,8 @@ #include #include #include +#include +#include #include #include #include @@ -860,12 +862,15 @@ static int __init snd_card_sa11xx_uda1341_pcm(struct sa11xx_uda1341 *sa11xx_uda1 #ifdef CONFIG_PM -static int snd_sa11xx_uda1341_suspend(struct snd_card *card, pm_message_t state) +static int snd_sa11xx_uda1341_suspend(struct platform_device *devptr, + pm_message_t state) { - struct sa11xx_uda1341 *chip = card->pm_private_data; + struct snd_card *card = platform_get_drvdata(devptr); + struct sa11xx_uda1341 *chip = card->private_data; + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_pcm_suspend_all(chip->pcm); -#ifdef HH_VERSION +#ifdef HH_VERSION sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_PLAYBACK].dmach); sa1100_dma_sleep(chip->s[SNDRV_PCM_STREAM_CAPTURE].dmach); #else @@ -873,12 +878,14 @@ static int snd_sa11xx_uda1341_suspend(struct snd_card *card, pm_message_t state) #endif l3_command(chip->uda1341, CMD_SUSPEND, NULL); sa11xx_uda1341_audio_shutdown(chip); + return 0; } -static int snd_sa11xx_uda1341_resume(struct snd_card *card) +static int snd_sa11xx_uda1341_resume(struct platform_device *devptr) { - struct sa11xx_uda1341 *chip = card->pm_private_data; + struct snd_card *card = platform_get_drvdata(devptr); + struct sa11xx_uda1341 *chip = card->private_data; sa11xx_uda1341_audio_init(chip); l3_command(chip->uda1341, CMD_RESUME, NULL); @@ -888,6 +895,7 @@ static int snd_sa11xx_uda1341_resume(struct snd_card *card) #else //FIXME #endif + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } #endif /* COMFIG_PM */ @@ -900,27 +908,22 @@ void snd_sa11xx_uda1341_free(struct snd_card *card) audio_dma_free(&chip->s[SNDRV_PCM_STREAM_CAPTURE]); } -static struct snd_card *sa11xx_uda1341_card; - -static int __init sa11xx_uda1341_init(void) +static int __init sa11xx_uda1341_probe(struct platform_device *devptr) { int err; struct snd_card *card; struct sa11xx_uda1341 *chip; - if (!machine_is_h3xxx()) - return -ENODEV; - /* register the soundcard */ card = snd_card_new(-1, id, THIS_MODULE, sizeof(struct sa11xx_uda1341)); if (card == NULL) return -ENOMEM; - card->private_free = snd_sa11xx_uda1341_free; chip = card->private_data; spin_lock_init(&chip->s[0].dma_lock); spin_lock_init(&chip->s[1].dma_lock); + card->private_free = snd_sa11xx_uda1341_free; chip->card = card; chip->samplerate = AUDIO_RATE_DEFAULT; @@ -932,20 +935,15 @@ static int __init sa11xx_uda1341_init(void) if ((err = snd_card_sa11xx_uda1341_pcm(chip, 0)) < 0) goto nodev; - snd_card_set_generic_pm_callback(card, - snd_sa11xx_uda1341_suspend, snd_sa11_uda1341_resume, - chip); - strcpy(card->driver, "UDA1341"); strcpy(card->shortname, "H3600 UDA1341TS"); sprintf(card->longname, "Compaq iPAQ H3600 with Philips UDA1341TS"); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto nodev; + snd_card_set_dev(card, &devptr->dev); if ((err = snd_card_register(card)) == 0) { printk( KERN_INFO "iPAQ audio support initialized\n" ); - sa11xx_uda1341_card = card; + platform_set_drvdata(devptr, card); return 0; } @@ -954,9 +952,47 @@ static int __init sa11xx_uda1341_init(void) return err; } +static int __devexit sa11xx_uda1341_remove(struct platform_device *devptr) +{ + snd_card_free(platform_get_drvdata(devptr)); + platform_set_drvdata(devptr, NULL); + return 0; +} + +#define SA11XX_UDA1341_DRIVER "sa11xx_uda1341" + +static struct platform_driver sa11xx_uda1341_driver = { + .probe = sa11xx_uda1341_probe, + .remove = __devexit_p(sa11xx_uda1341_remove), +#ifdef CONFIG_PM + .suspend = snd_sa11xx_uda1341_suspend, + .resume = snd_sa11xx_uda1341_resume, +#endif + .driver = { + .name = SA11XX_UDA1341_DRIVER, + }, +}; + +static int __init sa11xx_uda1341_init(void) +{ + int err; + struct platform_device *device; + + if (!machine_is_h3xxx()) + return -ENODEV; + if ((err = platform_driver_register(&sa11xx_uda1341_driver)) < 0) + return err; + device = platform_device_register_simple(SA11XX_UDA1341_DRIVER, -1, NULL, 0); + if (IS_ERR(device)) { + platform_driver_unregister(&sa11xx_uda1341_driver); + return PTR_ERR(device); + } + return 0; +} + static void __exit sa11xx_uda1341_exit(void) { - snd_card_free(sa11xx_uda1341_card); + platform_driver_unregister(&sa11xx_uda1341_driver); } module_init(sa11xx_uda1341_init); -- cgit v1.1 From fa8174db0fd032c3d48cc0873946358c68e44d4f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:20:15 +0100 Subject: [ALSA] Remove SND_GENERIC_DRIVER from arm/Kconfig Modules: ARM Remove the obsolete SND_GENERIC_DRIVER from arm/Kconfig. Signed-off-by: Takashi Iwai --- sound/arm/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/arm/Kconfig b/sound/arm/Kconfig index 0864a7c..2e4a5e0 100644 --- a/sound/arm/Kconfig +++ b/sound/arm/Kconfig @@ -7,7 +7,6 @@ config SND_SA11XX_UDA1341 tristate "SA11xx UDA1341TS driver (iPaq H3600)" depends on ARCH_SA1100 && SND && L3 select SND_PCM - select SND_GENERIC_DRIVER help Say Y here if you have a Compaq iPaq H3x00 handheld computer and want to use its Philips UDA 1341 audio chip. -- cgit v1.1 From ebfbd2b83da14c7118da0efd1b59d8b641da08c2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:21:46 +0100 Subject: [ALSA] Remove snd_card_generic_dev() Remove the obsolete snd_card_generic_dev(). CONFIG_SND_GENERIC_DRIVER is also removed from Kconfig. Signed-off-by: Takashi Iwai --- sound/mips/Kconfig | 1 - sound/mips/au1x00.c | 5 ----- sound/sparc/Kconfig | 3 --- sound/sparc/amd7930.c | 3 --- sound/sparc/cs4231.c | 3 --- sound/sparc/dbri.c | 3 --- 6 files changed, 18 deletions(-) diff --git a/sound/mips/Kconfig b/sound/mips/Kconfig index 2433b77..531f8ba 100644 --- a/sound/mips/Kconfig +++ b/sound/mips/Kconfig @@ -8,7 +8,6 @@ config SND_AU1X00 depends on (SOC_AU1000 || SOC_AU1100 || SOC_AU1500) && SND select SND_PCM select SND_AC97_CODEC - select SND_GENERIC_DRIVER help ALSA Sound driver for the Au1x00's AC97 port. diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index f150cced..6d8f8b3e 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -663,11 +663,6 @@ au1000_init(void) strcpy(card->shortname, "AMD Au1000-AC97"); sprintf(card->longname, "AMD Au1000--AC97 ALSA Driver"); - if ((err = snd_card_set_generic_dev(card)) < 0) { - snd_card_free(card); - return err; - } - if ((err = snd_card_register(card)) < 0) { snd_card_free(card); return err; diff --git a/sound/sparc/Kconfig b/sound/sparc/Kconfig index ef022a8..079e22a 100644 --- a/sound/sparc/Kconfig +++ b/sound/sparc/Kconfig @@ -7,7 +7,6 @@ config SND_SUN_AMD7930 tristate "Sun AMD7930" depends on SBUS && SND select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for AMD7930 sound device on Sun. @@ -18,7 +17,6 @@ config SND_SUN_CS4231 tristate "Sun CS4231" depends on SND select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for CS4231 sound device on Sun. @@ -29,7 +27,6 @@ config SND_SUN_DBRI tristate "Sun DBRI" depends on SND && SBUS select SND_PCM - select SND_GENERIC_DRIVER help Say Y here to include support for DBRI sound device on Sun. diff --git a/sound/sparc/amd7930.c b/sound/sparc/amd7930.c index c271049..5549334 100644 --- a/sound/sparc/amd7930.c +++ b/sound/sparc/amd7930.c @@ -1079,9 +1079,6 @@ static int __init amd7930_attach(int prom_node, struct sbus_dev *sdev) if ((err = snd_amd7930_mixer(amd)) < 0) goto out_err; - if ((err = snd_card_set_generic_dev(card)) < 0) - goto out_err; - if ((err = snd_card_register(card)) < 0) goto out_err; diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 0fa482c..14b1277 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -1740,9 +1740,6 @@ static int cs4231_attach_finish(snd_card_t *card, cs4231_t *chip) if ((err = snd_cs4231_timer(chip)) < 0) goto out_err; - if ((err = snd_card_set_generic_dev(card)) < 0) - goto out_err; - if ((err = snd_card_register(card)) < 0) goto out_err; diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 012c636..293108e 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2664,9 +2664,6 @@ static int __init dbri_attach(int prom_node, struct sbus_dev *sdev) /* /proc file handling */ snd_dbri_proc(dbri); - if ((err = snd_card_set_generic_dev(card)) < 0) - goto _err; - if ((err = snd_card_register(card)) < 0) goto _err; -- cgit v1.1 From 27441127b086230cc4c57d6cd9a615272fb47bcd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:22:43 +0100 Subject: [ALSA] Remove snd_legacy_auto_probe() Modules: ALSA Core Remove unsed snd_legacy_auto_probe() function. Signed-off-by: Takashi Iwai --- include/sound/initval.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/include/sound/initval.h b/include/sound/initval.h index 2bf1508..d29e3d3 100644 --- a/include/sound/initval.h +++ b/include/sound/initval.h @@ -50,20 +50,6 @@ #define SNDRV_DEFAULT_DMA_SIZE { [0 ... (SNDRV_CARDS-1)] = SNDRV_AUTO_DMA_SIZE } #define SNDRV_DEFAULT_PTR SNDRV_DEFAULT_STR -#ifdef SNDRV_LEGACY_AUTO_PROBE -static int snd_legacy_auto_probe(unsigned long *ports, int (*probe)(unsigned long port)) -{ - int result = 0; /* number of detected cards */ - - while ((signed long)*ports != -1) { - if (probe(*ports) >= 0) - result++; - ports++; - } - return result; -} -#endif - #ifdef SNDRV_LEGACY_FIND_FREE_IRQ #include -- cgit v1.1 From a4efc230c60ad15584e723755316e67b3c708d67 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:24:26 +0100 Subject: [ALSA] document - Add PM support Modules: Documentation Mark the drivers newly supporting PM in the documentation. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/ALSA-Configuration.txt | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 84068ba..9a58ed9 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -148,6 +148,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards. This module does not support autoprobe thus main port must be specified!!! Other ports are optional. + The power-management is supported. + Module snd-ad1889 ----------------- @@ -186,6 +188,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards, autoprobe and PnP. + The power-management is supported. + Module snd-als4000 ------------------ @@ -196,6 +200,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards, autoprobe and PnP. + The power-management is supported. + Module snd-atiixp ----------------- @@ -213,6 +219,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. implementation depends on the motherboard, and you'll need to choose the correct one via spdif_aclink module option. + The power-management is supported. + Module snd-atiixp-modem ----------------------- @@ -223,6 +231,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Note: The default index value of this module is -2, i.e. the first slot is excluded. + The power-management is supported. + Module snd-au8810, snd-au8820, snd-au8830 ----------------------------------------- @@ -265,6 +275,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards, PnP and autoprobe. + The power-management is supported. + Module snd-azt3328 ------------------ @@ -310,6 +322,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards and autoprobe. + The power-management is supported. + Module snd-cmipci ----------------- @@ -323,6 +337,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports autoprobe and multiple chips (max 8). + The power-management is supported. + Module snd-cs4231 ----------------- @@ -433,6 +449,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards. This module is enabled only with ISA PnP support. + The power-management is supported. + Module snd-dummy ---------------- @@ -440,6 +458,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. or input, but you may use this module for any application which requires a sound card (like RealPlayer). + The power-management is supported. + Module snd-emu10k1 ------------------ @@ -473,6 +493,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. * Creative Card 5.1 (c) 2003 [0x3fc3/0x7cff] * Creative Card all ins and outs [0x3fff/0x7fff] + The power-management is supported. + Module snd-emu10k1x ------------------- @@ -515,6 +537,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards, PnP and autoprobe. + The power-management is supported. + Module snd-es1688 ----------------- @@ -554,6 +578,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards and autoprobe. + The power-management is supported. + Module snd-es1968 ----------------- @@ -586,6 +612,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards and autoprobe. + The power-management is supported. + Module snd-gusclassic --------------------- @@ -695,6 +723,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. (Usually SD_LPLIB register is more accurate than the position buffer.) + The power-management is supported. + Module snd-hdsp --------------- @@ -846,6 +876,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Note: The default index value of this module is -2, i.e. the first slot is excluded. + The power-management is supported. + Module snd-interwave -------------------- @@ -1091,6 +1123,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. For ARM architecture only. + The power-management is supported. + Module snd-rme32 ---------------- @@ -1131,6 +1165,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports only one card. Module has no enable and index options. + The power-management is supported. + Module snd-sb8 -------------- @@ -1144,6 +1180,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards and autoprobe. + The power-management is supported. + Module snd-sb16 and snd-sbawe ----------------------------- @@ -1170,6 +1208,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. half duplex mode through 8-bit DMA channel by disabling their 16-bit DMA channel. + The power-management is supported. + Module snd-sgalaxy ------------------ @@ -1182,6 +1222,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module supports up to 8 cards. + The power-management is supported. + Module snd-sscape ----------------- @@ -1363,6 +1405,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Note: for the MPU401 on VIA823x, use snd-mpu401 driver additionally. The mpu_port option is for VIA686 chips only. + The power-management is supported. + Module snd-via82xx-modem ------------------------ @@ -1375,6 +1419,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Note: The default index value of this module is -2, i.e. the first slot is excluded. + The power-management is supported. + Module snd-virmidi ------------------ @@ -1413,6 +1459,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. size is chosen. The possible IBL values can be found in /proc/asound/cardX/vx-status proc file. + The power-management is supported. + Module snd-vxpocket ------------------- @@ -1441,6 +1489,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Note2: snd-vxp440 driver is merged to snd-vxpocket driver since ALSA 1.0.10. + The power-management is supported. + Module snd-ymfpci ----------------- @@ -1465,6 +1515,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Note: the driver is build only when CONFIG_ISA is set. + The power-management is supported. + AC97 Quirk Option ================= -- cgit v1.1 From 5fe76e4dc60a2c3ff9b1143f5275a953db685e26 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:26:09 +0100 Subject: [ALSA] document - Update PM support Modules: Documentation Update the description about the PCI PM support. Signed-off-by: Takashi Iwai --- .../sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 185 ++++++++++++++++----- 1 file changed, 146 insertions(+), 39 deletions(-) diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index f2e59fe..4963d83 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -18,8 +18,8 @@ - October 6, 2005 - 0.3.5 + November 17, 2005 + 0.3.6 @@ -2329,9 +2329,14 @@ struct _snd_pcm_runtime { PAUSE bit means that the pcm supports the pause operation, while the RESUME bit means that the pcm supports - the suspend/resume operation. If these flags - are set, the trigger callback below - must handle the corresponding commands. + the full suspend/resume operation. + If PAUSE flag is set, + the trigger callback below + must handle the corresponding (pause push/release) commands. + The suspend/resume trigger commands can be defined even without + RESUME flag. See + Power Management section for details. @@ -2903,8 +2908,8 @@ struct _snd_pcm_runtime { - When the pcm supports the suspend/resume operation - (i.e. SNDRV_PCM_INFO_RESUME flag is set), + When the pcm supports the suspend/resume operation, + regardless of full or partial suspend/resume support, SUSPEND and RESUME commands must be handled, too. These commands are issued when the power-management status is @@ -2913,6 +2918,8 @@ struct _snd_pcm_runtime { do suspend and resume of the pcm substream, and usually, they are identical with STOP and START commands, respectively. + See + Power Management section for details. @@ -5483,22 +5490,60 @@ struct _snd_pcm_runtime { CONFIG_PM. + + If the driver supports the suspend/resume + fully, that is, the device can be + properly resumed to the status at the suspend is called, + you can set SNDRV_PCM_INFO_RESUME flag + to pcm info field. Usually, this is possible when the + registers of ths chip can be safely saved and restored to the + RAM. If this is set, the trigger callback is called with + SNDRV_PCM_TRIGGER_RESUME after resume + callback is finished. + + + + Even if the driver doesn't support PM fully but only the + partial suspend/resume is possible, it's still worthy to + implement suspend/resume callbacks. In such a case, applications + would reset the status by calling + snd_pcm_prepare() and restart the stream + appropriately. Hence, you can define suspend/resume callbacks + below but don't set SNDRV_PCM_INFO_RESUME + info flag to the PCM. + + + + Note that the trigger with SUSPEND can be always called when + snd_pcm_suspend_all is called, + regardless of SNDRV_PCM_INFO_RESUME flag. + The RESUME flag affects only the behavior + of snd_pcm_resume(). + (Thus, in theory, + SNDRV_PCM_TRIGGER_RESUME isn't needed + to be handled in the trigger callback when no + SNDRV_PCM_INFO_RESUME flag is set. But, + it's better to keep it for compatibility reason.) + - ALSA provides the common power-management layer. Each card driver - needs to have only low-level suspend and resume callbacks. + In the earlier version of ALSA drivers, a common + power-management layer was provided, but it has been removed. + The driver needs to define the suspend/resume hooks according to + the bus the device is assigned. In the case of PCI driver, the + callbacks look like below: - Retrieve the chip data from pm_private_data field. + Retrieve the card and the chip data. + Call snd_power_change_state() with + SNDRV_CTL_POWER_D3hot to change the + power status. Call snd_pcm_suspend_all() to suspend the running PCM streams. + If AC97 codecs are used, call + snd_ac97_resume() for each codec. Save the register values if necessary. Stop the hardware if necessary. - Disable the PCI device by calling pci_disable_device(). + Disable the PCI device by calling + pci_disable_device(). Then, call + pci_save_state() at last. @@ -5525,18 +5577,24 @@ struct _snd_pcm_runtime { pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct mychip *chip = card->private_data; /* (2) */ - snd_pcm_suspend_all(chip->pcm); + snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); /* (3) */ - snd_mychip_save_registers(chip); + snd_pcm_suspend_all(chip->pcm); /* (4) */ - snd_mychip_stop_hardware(chip); + snd_ac97_suspend(chip->ac97); /* (5) */ - pci_disable_device(chip->pci); + snd_mychip_save_registers(chip); + /* (6) */ + snd_mychip_stop_hardware(chip); + /* (7) */ + pci_disable_device(pci); + pci_save_state(pci); return 0; } ]]> @@ -5548,14 +5606,17 @@ struct _snd_pcm_runtime { The scheme of the real resume job is as following. - Retrieve the chip data from pm_private_data field. - Enable the pci device again by calling - pci_enable_device(). + Retrieve the card and the chip data. + Set up PCI. First, call pci_restore_state(). + Then enable the pci device again by calling pci_enable_device(). + Call pci_set_master() if necessary, too. Re-initialize the chip. Restore the saved registers if necessary. Resume the mixer, e.g. calling snd_ac97_resume(). Restart the hardware (if any). + Call snd_power_change_state() with + SNDRV_CTL_POWER_D0 to notify the processes. @@ -5565,12 +5626,15 @@ struct _snd_pcm_runtime { pm_private_data; + struct snd_card *card = pci_get_drvdata(pci); + struct mychip *chip = card->private_data; /* (2) */ - pci_enable_device(chip->pci); + pci_restore_state(pci); + pci_enable_device(pci); + pci_set_master(pci); /* (3) */ snd_mychip_reinit_chip(chip); /* (4) */ @@ -5579,6 +5643,8 @@ struct _snd_pcm_runtime { snd_ac97_resume(chip->ac97); /* (6) */ snd_mychip_restart_chip(chip); + /* (7) */ + snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; } ]]> @@ -5587,8 +5653,48 @@ struct _snd_pcm_runtime { - OK, we have all callbacks now. Let's set up them now. In the - initialization of the card, add the following: + As shown in the above, it's better to save registers after + suspending the PCM operations via + snd_pcm_suspend_all() or + snd_pcm_suspend(). It means that the PCM + streams are already stoppped when the register snapshot is + taken. But, remind that you don't have to restart the PCM + stream in the resume callback. It'll be restarted via + trigger call with SNDRV_PCM_TRIGGER_RESUME + when necessary. + + + + OK, we have all callbacks now. Let's set them up. In the + initialization of the card, make sure that you can get the chip + data from the card instance, typically via + private_data field, in case you + created the chip data individually. + + + +private_data = chip; + .... + } +]]> + + + + When you created the chip data with + snd_card_new(), it's anyway accessible + via private_data field. @@ -5600,30 +5706,28 @@ struct _snd_pcm_runtime { struct snd_card *card; struct mychip *chip; .... - snd_card_set_pm_callback(card, snd_my_suspend, snd_my_resume, chip); + card = snd_card_new(index[dev], id[dev], THIS_MODULE, + sizeof(struct mychip)); + .... + chip = card->private_data; .... } ]]> - Here you don't have to put ifdef CONFIG_PM around, since it's already - checked in the header and expanded to empty if not needed. - If you need a space for saving the registers, you'll need to - allocate the buffer for it here, too, since it would be fatal + If you need a space for saving the registers, allocate the + buffer for it here, too, since it would be fatal if you cannot allocate a memory in the suspend phase. The allocated buffer should be released in the corresponding destructor. - And next, set suspend/resume callbacks to the pci_driver, - This can be done by passing a macro SND_PCI_PM_CALLBACKS - in the pci_driver struct. This macro is expanded to the correct - (global) callbacks if CONFIG_PM is set. + And next, set suspend/resume callbacks to the pci_driver. @@ -5633,7 +5737,10 @@ struct _snd_pcm_runtime { .id_table = snd_my_ids, .probe = snd_my_probe, .remove = __devexit_p(snd_my_remove), - SND_PCI_PM_CALLBACKS + #ifdef CONFIG_PM + .suspend = snd_my_suspend, + .resume = snd_my_resume, + #endif }; ]]> -- cgit v1.1 From 00a4e3d9f8df8a90966b75d517154718b4a2242a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:41:08 +0100 Subject: [ALSA] Merge ad1816a-lib module to ad1816a Modules: AD1816A driver Merge ad1816a-lib module to ad1816. There is no more reason to split. Signed-off-by: Takashi Iwai --- sound/isa/ad1816a/Makefile | 5 ++--- sound/isa/ad1816a/ad1816a_lib.c | 47 +++++++++-------------------------------- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/sound/isa/ad1816a/Makefile b/sound/isa/ad1816a/Makefile index a42b29c..90e00e8 100644 --- a/sound/isa/ad1816a/Makefile +++ b/sound/isa/ad1816a/Makefile @@ -3,8 +3,7 @@ # Copyright (c) 2001 by Jaroslav Kysela # -snd-ad1816a-lib-objs := ad1816a_lib.o -snd-ad1816a-objs := ad1816a.o +snd-ad1816a-objs := ad1816a.o ad1816a_lib.o # Toplevel Module Dependency -obj-$(CONFIG_SND_AD1816A) += snd-ad1816a.o snd-ad1816a-lib.o +obj-$(CONFIG_SND_AD1816A) += snd-ad1816a.o diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 89d11af..ac0d808 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -30,10 +30,6 @@ #include #include -MODULE_AUTHOR("Massimo Piccioni "); -MODULE_DESCRIPTION("lowlevel code for Analog Devices AD1816A chip"); -MODULE_LICENSE("GPL"); - static inline int snd_ad1816a_busy_wait(struct snd_ad1816a *chip) { int timeout; @@ -496,7 +492,7 @@ static int snd_ad1816a_capture_close(struct snd_pcm_substream *substream) } -static void snd_ad1816a_init(struct snd_ad1816a *chip) +static void __devinit snd_ad1816a_init(struct snd_ad1816a *chip) { unsigned long flags; @@ -516,7 +512,7 @@ static void snd_ad1816a_init(struct snd_ad1816a *chip) spin_unlock_irqrestore(&chip->lock, flags); } -static int snd_ad1816a_probe(struct snd_ad1816a *chip) +static int __devinit snd_ad1816a_probe(struct snd_ad1816a *chip) { unsigned long flags; @@ -563,7 +559,7 @@ static int snd_ad1816a_dev_free(struct snd_device *device) return snd_ad1816a_free(chip); } -static const char *snd_ad1816a_chip_id(struct snd_ad1816a *chip) +static const char __devinit *snd_ad1816a_chip_id(struct snd_ad1816a *chip) { switch (chip->hardware) { case AD1816A_HW_AD1816A: return "AD1816A"; @@ -576,9 +572,9 @@ static const char *snd_ad1816a_chip_id(struct snd_ad1816a *chip) } } -int snd_ad1816a_create(struct snd_card *card, - unsigned long port, int irq, int dma1, int dma2, - struct snd_ad1816a **rchip) +int __devinit snd_ad1816a_create(struct snd_card *card, + unsigned long port, int irq, int dma1, int dma2, + struct snd_ad1816a **rchip) { static struct snd_device_ops ops = { .dev_free = snd_ad1816a_dev_free, @@ -662,7 +658,7 @@ static struct snd_pcm_ops snd_ad1816a_capture_ops = { .pointer = snd_ad1816a_capture_pointer, }; -int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm) +int __devinit snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm) { int error; struct snd_pcm *pcm; @@ -690,13 +686,7 @@ int snd_ad1816a_pcm(struct snd_ad1816a *chip, int device, struct snd_pcm **rpcm) } #if 0 /* not used now */ -static void snd_ad1816a_timer_free(struct snd_timer *timer) -{ - struct snd_ad1816a *chip = timer->private_data; - chip->timer = NULL; -} - -int snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **rtimer) +int __devinit snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **rtimer) { struct snd_timer *timer; struct snd_timer_id tid; @@ -711,7 +701,6 @@ int snd_ad1816a_timer(struct snd_ad1816a *chip, int device, struct snd_timer **r return error; strcpy(timer->name, snd_ad1816a_chip_id(chip)); timer->private_data = chip; - timer->private_free = snd_ad1816a_timer_free; chip->timer = timer; timer->hw = snd_ad1816a_timer_table; if (rtimer) @@ -898,7 +887,7 @@ static int snd_ad1816a_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_ return change; } -static struct snd_kcontrol_new snd_ad1816a_controls[] = { +static struct snd_kcontrol_new snd_ad1816a_controls[] __devinitdata = { AD1816A_DOUBLE("Master Playback Switch", AD1816A_MASTER_ATT, 15, 7, 1, 1), AD1816A_DOUBLE("Master Playback Volume", AD1816A_MASTER_ATT, 8, 0, 31, 1), AD1816A_DOUBLE("PCM Playback Switch", AD1816A_VOICE_ATT, 15, 7, 1, 1), @@ -933,7 +922,7 @@ AD1816A_SINGLE("3D Control - Switch", AD1816A_3D_PHAT_CTRL, 15, 1, 1), AD1816A_SINGLE("3D Control - Level", AD1816A_3D_PHAT_CTRL, 0, 15, 0), }; -int snd_ad1816a_mixer(struct snd_ad1816a *chip) +int __devinit snd_ad1816a_mixer(struct snd_ad1816a *chip) { struct snd_card *card; unsigned int idx; @@ -951,19 +940,3 @@ int snd_ad1816a_mixer(struct snd_ad1816a *chip) } return 0; } - -EXPORT_SYMBOL(snd_ad1816a_create); -EXPORT_SYMBOL(snd_ad1816a_pcm); -EXPORT_SYMBOL(snd_ad1816a_mixer); - -static int __init alsa_ad1816a_init(void) -{ - return 0; -} - -static void __exit alsa_ad1816a_exit(void) -{ -} - -module_init(alsa_ad1816a_init) -module_exit(alsa_ad1816a_exit) -- cgit v1.1 From 73e77ba0235532bd7523ba90883d325f6e095acf Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:44:01 +0100 Subject: [ALSA] Add error messages Add error messages in the critial error path to be more verbose. Signed-off-by: Takashi Iwai --- sound/core/control.c | 8 ++++++-- sound/core/device.c | 5 ++++- sound/core/hwdep.c | 7 ++++--- sound/core/pcm.c | 16 +++++++++++----- sound/core/rawmidi.c | 18 ++++++++++++++---- sound/core/timer.c | 4 +++- sound/drivers/mpu401/mpu401_uart.c | 1 + sound/drivers/opl3/opl3_lib.c | 4 +++- sound/isa/opl3sa2.c | 27 ++++++++++++++++++++------- 9 files changed, 66 insertions(+), 24 deletions(-) diff --git a/sound/core/control.c b/sound/core/control.c index 03ae9bb..f8f98cc 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -195,8 +195,10 @@ struct snd_kcontrol *snd_ctl_new(struct snd_kcontrol *control, unsigned int acce snd_assert(control != NULL, return NULL); snd_assert(control->count > 0, return NULL); kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL); - if (kctl == NULL) + if (kctl == NULL) { + snd_printk(KERN_ERR "Cannot allocate control instance\n"); return NULL; + } *kctl = *control; for (idx = 0; idx < kctl->count; idx++) kctl->vd[idx].access = access; @@ -309,7 +311,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) struct snd_ctl_elem_id id; unsigned int idx; - snd_assert(card != NULL && kcontrol != NULL, return -EINVAL); + snd_assert(card != NULL, return -EINVAL); + if (! kcontrol) + return -EINVAL; snd_assert(kcontrol->info != NULL, return -EINVAL); id = kcontrol->id; down_write(&card->controls_rwsem); diff --git a/sound/core/device.c b/sound/core/device.c index afa8cc7..b1cf6ec 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -50,8 +50,10 @@ int snd_device_new(struct snd_card *card, snd_device_type_t type, snd_assert(device_data != NULL, return -ENXIO); snd_assert(ops != NULL, return -ENXIO); dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (dev == NULL) + if (dev == NULL) { + snd_printk(KERN_ERR "Cannot allocate device\n"); return -ENOMEM; + } dev->card = card; dev->type = type; dev->state = SNDRV_DEV_BUILD; @@ -173,6 +175,7 @@ int snd_device_register(struct snd_card *card, void *device_data) dev->state = SNDRV_DEV_REGISTERED; return 0; } + snd_printd("snd_device_register busy\n"); return -EBUSY; } snd_BUG(); diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index da0fb9f..444e266 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -364,13 +364,14 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device, *rhwdep = NULL; snd_assert(card != NULL, return -ENXIO); hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL); - if (hwdep == NULL) + if (hwdep == NULL) { + snd_printk(KERN_ERR "hwdep: cannot allocate\n"); return -ENOMEM; + } hwdep->card = card; hwdep->device = device; - if (id) { + if (id) strlcpy(hwdep->id, id, sizeof(hwdep->id)); - } #ifdef CONFIG_SND_OSSEMUL hwdep->oss_type = -1; #endif diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 59c995b..9305ac3 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -600,14 +600,18 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) pstr->reg = &snd_pcm_reg[stream]; if (substream_count > 0) { err = snd_pcm_stream_proc_init(pstr); - if (err < 0) + if (err < 0) { + snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n"); return err; + } } prev = NULL; for (idx = 0, prev = NULL; idx < substream_count; idx++) { substream = kzalloc(sizeof(*substream), GFP_KERNEL); - if (substream == NULL) + if (substream == NULL) { + snd_printk(KERN_ERR "Cannot allocate PCM substream\n"); return -ENOMEM; + } substream->pcm = pcm; substream->pstr = pstr; substream->number = idx; @@ -620,6 +624,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) prev->next = substream; err = snd_pcm_substream_proc_init(substream); if (err < 0) { + snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n"); kfree(substream); return err; } @@ -666,13 +671,14 @@ int snd_pcm_new(struct snd_card *card, char *id, int device, *rpcm = NULL; snd_assert(card != NULL, return -ENXIO); pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); - if (pcm == NULL) + if (pcm == NULL) { + snd_printk(KERN_ERR "Cannot allocate PCM\n"); return -ENOMEM; + } pcm->card = card; pcm->device = device; - if (id) { + if (id) strlcpy(pcm->id, id, sizeof(pcm->id)); - } if ((err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK, playback_count)) < 0) { snd_pcm_free(pcm); return err; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index ede0a60..7a86a9a 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1382,8 +1382,10 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, INIT_LIST_HEAD(&stream->substreams); for (idx = 0; idx < count; idx++) { substream = kzalloc(sizeof(*substream), GFP_KERNEL); - if (substream == NULL) + if (substream == NULL) { + snd_printk(KERN_ERR "rawmidi: cannot allocate substream\n"); return -ENOMEM; + } substream->stream = direction; substream->number = idx; substream->rmidi = rmidi; @@ -1425,19 +1427,27 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device, *rrawmidi = NULL; snd_assert(card != NULL, return -ENXIO); rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL); - if (rmidi == NULL) + if (rmidi == NULL) { + snd_printk(KERN_ERR "rawmidi: cannot allocate\n"); return -ENOMEM; + } rmidi->card = card; rmidi->device = device; init_MUTEX(&rmidi->open_mutex); init_waitqueue_head(&rmidi->open_wait); if (id != NULL) strlcpy(rmidi->id, id, sizeof(rmidi->id)); - if ((err = snd_rawmidi_alloc_substreams(rmidi, &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT], SNDRV_RAWMIDI_STREAM_INPUT, input_count)) < 0) { + if ((err = snd_rawmidi_alloc_substreams(rmidi, + &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT], + SNDRV_RAWMIDI_STREAM_INPUT, + input_count)) < 0) { snd_rawmidi_free(rmidi); return err; } - if ((err = snd_rawmidi_alloc_substreams(rmidi, &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT], SNDRV_RAWMIDI_STREAM_OUTPUT, output_count)) < 0) { + if ((err = snd_rawmidi_alloc_substreams(rmidi, + &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT], + SNDRV_RAWMIDI_STREAM_OUTPUT, + output_count)) < 0) { snd_rawmidi_free(rmidi); return err; } diff --git a/sound/core/timer.c b/sound/core/timer.c index 18d43a0..74637ce 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -777,8 +777,10 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid, snd_assert(rtimer != NULL, return -EINVAL); *rtimer = NULL; timer = kzalloc(sizeof(*timer), GFP_KERNEL); - if (timer == NULL) + if (timer == NULL) { + snd_printk(KERN_ERR "timer: cannot allocate\n"); return -ENOMEM; + } timer->tmr_class = tid->dev_class; timer->card = card; timer->tmr_device = tid->device; diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index 16e87f3..ee67b52 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -462,6 +462,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device, return err; mpu = kzalloc(sizeof(*mpu), GFP_KERNEL); if (mpu == NULL) { + snd_printk(KERN_ERR "mpu401_uart: cannot allocate\n"); snd_device_free(card, rmidi); return -ENOMEM; } diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index cbd37e9..650f3b8 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -349,8 +349,10 @@ int snd_opl3_new(struct snd_card *card, *ropl3 = NULL; opl3 = kzalloc(sizeof(*opl3), GFP_KERNEL); - if (opl3 == NULL) + if (opl3 == NULL) { + snd_printk(KERN_ERR "opl3: cannot allocate\n"); return -ENOMEM; + } opl3->card = card; opl3->hardware = hardware; diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index b923de9..aafe556 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -496,21 +496,29 @@ static int __init snd_opl3sa2_mixer(struct snd_opl3sa2 *chip) /* reassign AUX0 to CD */ strcpy(id1.name, "Aux Playback Switch"); strcpy(id2.name, "CD Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } strcpy(id1.name, "Aux Playback Volume"); strcpy(id2.name, "CD Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } /* reassign AUX1 to FM */ strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; strcpy(id2.name, "FM Playback Switch"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } strcpy(id1.name, "Aux Playback Volume"); strcpy(id2.name, "FM Playback Volume"); - if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) + if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { + snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); return err; + } /* add OPL3SA2 controls */ for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) { if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip))) < 0) @@ -575,8 +583,10 @@ static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, int err; cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); - if (!cfg) + if (!cfg) { + snd_printk(KERN_ERR PFX "cannot allocate pnp cfg\n"); return -ENOMEM; + } /* PnP initialization */ pnp_init_resource_table(cfg); if (sb_port[dev] != SNDRV_AUTO_PORT) @@ -597,7 +607,7 @@ static int __init snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, pnp_resource_change(&cfg->irq_resource[0], irq[dev], 1); err = pnp_manual_config_dev(pdev, cfg, 0); if (err < 0) - snd_printk(KERN_ERR "PnP manual resources are invalid, using auto config\n"); + snd_printk(KERN_WARNING "PnP manual resources are invalid, using auto config\n"); err = pnp_activate_dev(pdev); if (err < 0) { kfree(cfg); @@ -784,8 +794,11 @@ static int __devinit snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, struct snd_card *card; pdev = pnp_request_card_device(pcard, id->devs[0].id, NULL); - if (pdev == NULL) + if (pdev == NULL) { + snd_printk(KERN_ERR PFX "can't get pnp device from id '%s'\n", + id->devs[0].id); return -EBUSY; + } for (; dev < SNDRV_CARDS; dev++) { if (enable[dev] && isapnp[dev]) break; -- cgit v1.1 From fa55f837bb1bfc3d9ac9988d6f5450a603fa079a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:48:30 +0100 Subject: [ALSA] Fix resume of cs4231 Modules: CS4231 driver Use mce_down() again in the resume callback. Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4231_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index ced22fd..582cc75 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -1320,7 +1320,7 @@ static void snd_cs4231_resume(struct snd_cs4231 *chip) } } spin_unlock_irqrestore(&chip->reg_lock, flags); -#if 0 +#if 1 snd_cs4231_mce_down(chip); #else /* The following is a workaround to avoid freeze after resume on TP600E. -- cgit v1.1 From a9824c868a2c7e310e6263ea4bc9f35cbbec8227 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 17 Nov 2005 17:51:00 +0100 Subject: [ALSA] Add CS4232 PnP BIOS support Modules: CS4231 driver,CS4236+ driver Add CS4232 PnP BIOS support. Still experimental. Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4231_lib.c | 2 + sound/isa/cs423x/cs4236.c | 323 ++++++++++++++++++++++++++++-------------- 2 files changed, 220 insertions(+), 105 deletions(-) diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 582cc75..05d0d40 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -1484,10 +1484,12 @@ int snd_cs4231_create(struct snd_card *card, } snd_cs4231_init(chip); +#if 0 if (chip->hardware & CS4231_HW_CS4232_MASK) { if (chip->res_cport == NULL) snd_printk("CS4232 control port features are not accessible\n"); } +#endif /* Register device */ if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index bc10548..9e399b6 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -136,27 +136,20 @@ struct snd_card_cs4236 { #ifdef CONFIG_PNP -#define ISAPNP_CS4232(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ - { \ - ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ - .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ - ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \ - ISAPNP_DEVICE_ID(_va, _vb, _vc, _mpu401) } \ - } -#define ISAPNP_CS4232_1(_va, _vb, _vc, _device, _wss, _ctrl, _mpu401) \ - { \ - ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ - .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ - ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl), \ - ISAPNP_DEVICE_ID('P', 'N', 'P', _mpu401) } \ - } -#define ISAPNP_CS4232_WOMPU(_va, _vb, _vc, _device, _wss, _ctrl) \ - { \ - ISAPNP_CARD_ID(_va, _vb, _vc, _device), \ - .devs = { ISAPNP_DEVICE_ID(_va, _vb, _vc, _wss), \ - ISAPNP_DEVICE_ID(_va, _vb, _vc, _ctrl) } \ - } - +#ifdef CS4232 +/* + * PNP BIOS + */ +static const struct pnp_device_id snd_cs4232_pnpbiosids[] = { + { .id = "CSC0100" }, + { .id = "CSC0000" }, + /* Guillemot Turtlebeach something appears to be cs4232 compatible + * (untested) */ + { .id = "GIM0100" }, + { .id = "" } +}; +MODULE_DEVICE_TABLE(pnp, snd_cs4232_pnpbiosids); +#endif /* CS4232 */ #ifdef CS4232 #define CS423X_DRIVER "snd_cs4232" @@ -266,37 +259,12 @@ static struct pnp_card_device_id snd_cs423x_pnpids[] = { MODULE_DEVICE_TABLE(pnp_card, snd_cs423x_pnpids); -static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, - struct pnp_card_link *card, - const struct pnp_card_device_id *id) +/* WSS initialization */ +static int __devinit snd_cs423x_pnp_init_wss(int dev, struct pnp_dev *pdev, + struct pnp_resource_table *cfg) { - struct pnp_dev *pdev; - struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); int err; - if (!cfg) - return -ENOMEM; - - acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL); - if (acard->wss == NULL) { - kfree(cfg); - return -EBUSY; - } - acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL); - if (acard->ctrl == NULL) { - kfree(cfg); - return -EBUSY; - } - if (id->devs[2].id[0]) { - acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); - if (acard->mpu == NULL) { - kfree(cfg); - return -EBUSY; - } - } - - /* WSS initialization */ - pdev = acard->wss; pnp_init_resource_table(cfg); if (port[dev] != SNDRV_AUTO_PORT) pnp_resource_change(&cfg->port_resource[0], port[dev], 4); @@ -315,7 +283,6 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, snd_printk(KERN_ERR IDENT " WSS PnP manual resources are invalid, using auto config\n"); err = pnp_activate_dev(pdev); if (err < 0) { - kfree(cfg); printk(KERN_ERR IDENT " WSS PnP configure failed for WSS (out of resources?)\n"); return -EBUSY; } @@ -330,53 +297,122 @@ static int __devinit snd_card_cs4236_pnp(int dev, struct snd_card_cs4236 *acard, port[dev], fm_port[dev], sb_port[dev]); snd_printdd("isapnp WSS: irq=%i, dma1=%i, dma2=%i\n", irq[dev], dma1[dev], dma2[dev]); + return 0; +} + +/* CTRL initialization */ +static int __devinit snd_cs423x_pnp_init_ctrl(int dev, struct pnp_dev *pdev, + struct pnp_resource_table *cfg) +{ + int err; + + pnp_init_resource_table(cfg); + if (cport[dev] != SNDRV_AUTO_PORT) + pnp_resource_change(&cfg->port_resource[0], cport[dev], 8); + err = pnp_manual_config_dev(pdev, cfg, 0); + if (err < 0) + snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n"); + err = pnp_activate_dev(pdev); + if (err < 0) { + printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n"); + return -EBUSY; + } + cport[dev] = pnp_port_start(pdev, 0); + snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]); + return 0; +} + +/* MPU initialization */ +static int __devinit snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev, + struct pnp_resource_table *cfg) +{ + int err; + + pnp_init_resource_table(cfg); + if (mpu_port[dev] != SNDRV_AUTO_PORT) + pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); + if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0) + pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); + err = pnp_manual_config_dev(pdev, cfg, 0); + if (err < 0) + snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n"); + err = pnp_activate_dev(pdev); + if (err < 0) { + printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n"); + mpu_port[dev] = SNDRV_AUTO_PORT; + mpu_irq[dev] = SNDRV_AUTO_IRQ; + } else { + mpu_port[dev] = pnp_port_start(pdev, 0); + if (mpu_irq[dev] >= 0 && + pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) { + mpu_irq[dev] = pnp_irq(pdev, 0); + } else { + mpu_irq[dev] = -1; /* disable interrupt */ + } + } + snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]); + return 0; +} + +#ifdef CS4232 +static int __devinit snd_card_cs4232_pnp(int dev, struct snd_card_cs4236 *acard, + struct pnp_dev *pdev) +{ + struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); + + if (!cfg) + return -ENOMEM; + if (snd_cs423x_pnp_init_wss(dev, acard->wss, cfg) < 0) { + kfree(cfg); + return -EBUSY; + } + kfree(cfg); + cport[dev] = -1; + return 0; +} +#endif + +static int __devinit snd_card_cs423x_pnpc(int dev, struct snd_card_cs4236 *acard, + struct pnp_card_link *card, + const struct pnp_card_device_id *id) +{ + struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); + + if (!cfg) + return -ENOMEM; + + acard->wss = pnp_request_card_device(card, id->devs[0].id, NULL); + if (acard->wss == NULL) + goto error; + acard->ctrl = pnp_request_card_device(card, id->devs[1].id, NULL); + if (acard->ctrl == NULL) + goto error; + if (id->devs[2].id[0]) { + acard->mpu = pnp_request_card_device(card, id->devs[2].id, NULL); + if (acard->mpu == NULL) + goto error; + } + + /* WSS initialization */ + if (snd_cs423x_pnp_init_wss(dev, acard->wss, cfg) < 0) + goto error; + /* CTRL initialization */ if (acard->ctrl && cport[dev] > 0) { - pdev = acard->ctrl; - pnp_init_resource_table(cfg); - if (cport[dev] != SNDRV_AUTO_PORT) - pnp_resource_change(&cfg->port_resource[0], cport[dev], 8); - err = pnp_manual_config_dev(pdev, cfg, 0); - if (err < 0) - snd_printk(KERN_ERR IDENT " CTRL PnP manual resources are invalid, using auto config\n"); - err = pnp_activate_dev(pdev); - if (err < 0) { - kfree(cfg); - printk(KERN_ERR IDENT " CTRL PnP configure failed for WSS (out of resources?)\n"); - return -EBUSY; - } - cport[dev] = pnp_port_start(pdev, 0); - snd_printdd("isapnp CTRL: control port=0x%lx\n", cport[dev]); + if (snd_cs423x_pnp_init_ctrl(dev, acard->ctrl, cfg) < 0) + goto error; } /* MPU initialization */ if (acard->mpu && mpu_port[dev] > 0) { - pdev = acard->mpu; - pnp_init_resource_table(cfg); - if (mpu_port[dev] != SNDRV_AUTO_PORT) - pnp_resource_change(&cfg->port_resource[0], mpu_port[dev], 2); - if (mpu_irq[dev] != SNDRV_AUTO_IRQ && mpu_irq[dev] >= 0) - pnp_resource_change(&cfg->irq_resource[0], mpu_irq[dev], 1); - err = pnp_manual_config_dev(pdev, cfg, 0); - if (err < 0) - snd_printk(KERN_ERR IDENT " MPU401 PnP manual resources are invalid, using auto config\n"); - err = pnp_activate_dev(pdev); - if (err < 0) { - printk(KERN_ERR IDENT " MPU401 PnP configure failed for WSS (out of resources?)\n"); - mpu_port[dev] = SNDRV_AUTO_PORT; - mpu_irq[dev] = SNDRV_AUTO_IRQ; - } else { - mpu_port[dev] = pnp_port_start(pdev, 0); - if (mpu_irq[dev] >= 0 && - pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) { - mpu_irq[dev] = pnp_irq(pdev, 0); - } else { - mpu_irq[dev] = -1; /* disable interrupt */ - } - } - snd_printdd("isapnp MPU: port=0x%lx, irq=%i\n", mpu_port[dev], mpu_irq[dev]); + if (snd_cs423x_pnp_init_mpu(dev, acard->ctrl, cfg) < 0) + goto error; } kfree(cfg); return 0; + + error: + kfree(cfg); + return -EBUSY; } #endif /* CONFIG_PNP */ @@ -558,7 +594,7 @@ static int snd_cs423x_nonpnp_resume(struct platform_device *dev) } #endif -static struct platform_driver snd_cs423x_nonpnp_driver = { +static struct platform_driver cs423x_nonpnp_driver = { .probe = snd_cs423x_nonpnp_probe, .remove = __devexit_p(snd_cs423x_nonpnp_remove), #ifdef CONFIG_PM @@ -572,8 +608,73 @@ static struct platform_driver snd_cs423x_nonpnp_driver = { #ifdef CONFIG_PNP -static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *pcard, - const struct pnp_card_device_id *pid) +#ifdef CS4232 +static int __devinit snd_cs4232_pnpbios_detect(struct pnp_dev *pdev, + const struct pnp_device_id *id) +{ + static int dev; + int err; + struct snd_card *card; + + if (pnp_device_is_isapnp(pdev)) + return -ENOENT; /* we have another procedure - card */ + for (; dev < SNDRV_CARDS; dev++) { + if (enable[dev] && isapnp[dev]) + break; + } + if (dev >= SNDRV_CARDS) + return -ENODEV; + + card = snd_cs423x_card_new(dev); + if (! card) + return -ENOMEM; + if ((err = snd_card_cs4232_pnp(dev, card->private_data, pdev)) < 0) { + printk(KERN_ERR "PnP BIOS detection failed for " IDENT "\n"); + snd_card_free(card); + return err; + } + snd_card_set_dev(card, &pdev->dev); + if ((err = snd_cs423x_probe(card, dev)) < 0) { + snd_card_free(card); + return err; + } + pnp_set_drvdata(pdev, card); + dev++; + return 0; +} + +static void __devexit snd_cs4232_pnp_remove(struct pnp_dev * pdev) +{ + snd_card_free(pnp_get_drvdata(pdev)); + pnp_set_drvdata(pdev, NULL); +} + +#ifdef CONFIG_PM +static int snd_cs4232_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) +{ + return snd_cs423x_suspend(pnp_get_drvdata(pdev)); +} + +static int snd_cs4232_pnp_resume(struct pnp_dev *pdev) +{ + return snd_cs423x_resume(pnp_get_drvdata(pdev)); +} +#endif + +static struct pnp_driver cs4232_pnp_driver = { + .name = "cs4232-pnpbios", + .id_table = snd_cs4232_pnpbiosids, + .probe = snd_cs4232_pnpbios_detect, + .remove = __devexit_p(snd_cs4232_pnp_remove), +#ifdef CONFIG_PM + .suspend = snd_cs4232_pnp_suspend, + .resume = snd_cs4232_pnp_resume, +#endif +}; +#endif /* CS4232 */ + +static int __devinit snd_cs423x_pnpc_detect(struct pnp_card_link *pcard, + const struct pnp_card_device_id *pid) { static int dev; struct snd_card *card; @@ -589,8 +690,9 @@ static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *pcard, card = snd_cs423x_card_new(dev); if (! card) return -ENOMEM; - if ((res = snd_card_cs4236_pnp(dev, card->private_data, pcard, pid))<0) { - printk(KERN_ERR "isapnp detection failed and probing for " IDENT " is not supported\n"); + if ((res = snd_card_cs423x_pnpc(dev, card->private_data, pcard, pid)) < 0) { + printk(KERN_ERR "isapnp detection failed and probing for " IDENT + " is not supported\n"); snd_card_free(card); return res; } @@ -604,19 +706,19 @@ static int __devinit snd_cs423x_pnp_detect(struct pnp_card_link *pcard, return 0; } -static void __devexit snd_cs423x_pnp_remove(struct pnp_card_link * pcard) +static void __devexit snd_cs423x_pnpc_remove(struct pnp_card_link * pcard) { snd_card_free(pnp_get_card_drvdata(pcard)); pnp_set_card_drvdata(pcard, NULL); } #ifdef CONFIG_PM -static int snd_cs423x_pnp_suspend(struct pnp_card_link *pcard, pm_message_t state) +static int snd_cs423x_pnpc_suspend(struct pnp_card_link *pcard, pm_message_t state) { return snd_cs423x_suspend(pnp_get_card_drvdata(pcard)); } -static int snd_cs423x_pnp_resume(struct pnp_card_link *pcard) +static int snd_cs423x_pnpc_resume(struct pnp_card_link *pcard) { return snd_cs423x_resume(pnp_get_card_drvdata(pcard)); } @@ -626,11 +728,11 @@ static struct pnp_card_driver cs423x_pnpc_driver = { .flags = PNP_DRIVER_RES_DISABLE, .name = CS423X_ISAPNP_DRIVER, .id_table = snd_cs423x_pnpids, - .probe = snd_cs423x_pnp_detect, - .remove = __devexit_p(snd_cs423x_pnp_remove), + .probe = snd_cs423x_pnpc_detect, + .remove = __devexit_p(snd_cs423x_pnpc_remove), #ifdef CONFIG_PM - .suspend = snd_cs423x_pnp_suspend, - .resume = snd_cs423x_pnp_resume, + .suspend = snd_cs423x_pnpc_suspend, + .resume = snd_cs423x_pnpc_resume, #endif }; #endif /* CONFIG_PNP */ @@ -639,7 +741,7 @@ static int __init alsa_card_cs423x_init(void) { int i, err, cards = 0; - if ((err = platform_driver_register(&snd_cs423x_nonpnp_driver)) < 0) + if ((err = platform_driver_register(&cs423x_nonpnp_driver)) < 0) return err; for (i = 0; i < SNDRV_CARDS && enable[i]; i++) { @@ -650,17 +752,25 @@ static int __init alsa_card_cs423x_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_cs423x_nonpnp_driver); + platform_driver_unregister(&cs423x_nonpnp_driver); return err; } cards++; } +#ifdef CS4232 + i = pnp_register_driver(&cs4232_pnp_driver); + if (i > 0) + cards += i; +#endif i = pnp_register_card_driver(&cs423x_pnpc_driver); if (i > 0) cards += i; if (!cards) { +#ifdef CS4232 + pnp_unregister_driver(&cs4232_pnp_driver); +#endif pnp_unregister_card_driver(&cs423x_pnpc_driver); - platform_driver_unregister(&snd_cs423x_nonpnp_driver); + platform_driver_unregister(&cs423x_nonpnp_driver); #ifdef MODULE printk(KERN_ERR IDENT " soundcard not found or device busy\n"); #endif @@ -671,8 +781,11 @@ static int __init alsa_card_cs423x_init(void) static void __exit alsa_card_cs423x_exit(void) { +#ifdef CS4232 + pnp_unregister_driver(&cs4232_pnp_driver); +#endif pnp_unregister_card_driver(&cs423x_pnpc_driver); - platform_driver_unregister(&snd_cs423x_nonpnp_driver); + platform_driver_unregister(&cs423x_nonpnp_driver); } module_init(alsa_card_cs423x_init) -- cgit v1.1 From 2eb061f41cf74f829bfe90a9c79c765172be9f0b Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 18 Nov 2005 07:44:13 +0100 Subject: [ALSA] intel8x0 - Added swap_hp quirk for Fujitsu-Siemens Celsius H320 [0x10cf:0x12f2] Modules: Intel8x0 driver Signed-off-by: Jaroslav Kysela --- sound/pci/intel8x0.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index c5c4ec6..5bbc8a0 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1912,6 +1912,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { .type = AC97_TUNE_HP_ONLY }, { + .subvendor = 0x10cf, + .subdevice = 0x12f2, + .name = "Fujitsu-Siemens Celsius H320", + .type = AC97_TUNE_SWAP_HP + }, + { .subvendor = 0x10f1, .subdevice = 0x2665, .name = "Fujitsu-Siemens Celsius", /* AD1981? */ -- cgit v1.1 From b32425ac93370e1ba5556110e662f896b2e143b3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 18 Nov 2005 18:52:14 +0100 Subject: [ALSA] Fix possible races in timer callbacks Fix possible races in timer callbacks. Signed-off-by: Takashi Iwai --- sound/core/timer.c | 5 +++-- sound/drivers/dummy.c | 10 +++++----- sound/drivers/mpu401/mpu401_uart.c | 5 +++-- sound/drivers/opl3/opl3_midi.c | 5 +++-- sound/pci/korg1212/korg1212.c | 5 +++-- sound/synth/emux/emux_synth.c | 5 +++-- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/sound/core/timer.c b/sound/core/timer.c index 74637ce..6aad411 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -662,12 +662,13 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) struct snd_timer_instance *ti, *ts; unsigned long resolution, ticks; struct list_head *p, *q, *n, *ack_list_head; + unsigned long flags; int use_tasklet = 0; if (timer == NULL) return; - spin_lock(&timer->lock); + spin_lock_irqsave(&timer->lock, flags); /* remember the current resolution */ if (timer->hw.c_resolution) @@ -752,7 +753,7 @@ void snd_timer_interrupt(struct snd_timer * timer, unsigned long ticks_left) /* do we have any slow callbacks? */ use_tasklet = !list_empty(&timer->sack_list_head); - spin_unlock(&timer->lock); + spin_unlock_irqrestore(&timer->lock, flags); if (use_tasklet) tasklet_hi_schedule(&timer->task_queue); diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index a276f7c..1861175 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -231,8 +231,9 @@ static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream) static void snd_card_dummy_pcm_timer_function(unsigned long data) { struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data; + unsigned long flags; - spin_lock(&dpcm->lock); + spin_lock_irqsave(&dpcm->lock, flags); dpcm->timer.expires = 1 + jiffies; add_timer(&dpcm->timer); dpcm->pcm_irq_pos += dpcm->pcm_jiffie; @@ -240,11 +241,10 @@ static void snd_card_dummy_pcm_timer_function(unsigned long data) dpcm->pcm_buf_pos %= dpcm->pcm_size; if (dpcm->pcm_irq_pos >= dpcm->pcm_count) { dpcm->pcm_irq_pos %= dpcm->pcm_count; - spin_unlock(&dpcm->lock); + spin_unlock_irqrestore(&dpcm->lock, flags); snd_pcm_period_elapsed(dpcm->substream); - spin_lock(&dpcm->lock); - } - spin_unlock(&dpcm->lock); + } else + spin_unlock_irqrestore(&dpcm->lock, flags); } static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream) diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index ee67b52..8687ae3 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -133,12 +133,13 @@ irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id, struct pt_regs *reg static void snd_mpu401_uart_timer(unsigned long data) { struct snd_mpu401 *mpu = (struct snd_mpu401 *)data; + unsigned long flags; - spin_lock(&mpu->timer_lock); + spin_lock_irqsave(&mpu->timer_lock, flags); /*mpu->mode |= MPU401_MODE_TIMER;*/ mpu->timer.expires = 1 + jiffies; add_timer(&mpu->timer); - spin_unlock(&mpu->timer_lock); + spin_unlock_irqrestore(&mpu->timer_lock, flags); if (mpu->rmidi) _snd_mpu401_uart_interrupt(mpu); } diff --git a/sound/drivers/opl3/opl3_midi.c b/sound/drivers/opl3/opl3_midi.c index 48c480e..1b6f227 100644 --- a/sound/drivers/opl3/opl3_midi.c +++ b/sound/drivers/opl3/opl3_midi.c @@ -238,10 +238,11 @@ void snd_opl3_timer_func(unsigned long data) { struct snd_opl3 *opl3 = (struct snd_opl3 *)data; + unsigned long flags; int again = 0; int i; - spin_lock(&opl3->sys_timer_lock); + spin_lock_irqsave(&opl3->sys_timer_lock, flags); for (i = 0; i < opl3->max_voices; i++) { struct snd_opl3_voice *vp = &opl3->voices[i]; if (vp->state > 0 && vp->note_off_check) { @@ -257,7 +258,7 @@ void snd_opl3_timer_func(unsigned long data) } else { opl3->sys_timer_status = 0; } - spin_unlock(&opl3->sys_timer_lock); + spin_unlock_irqrestore(&opl3->sys_timer_lock, flags); } /* diff --git a/sound/pci/korg1212/korg1212.c b/sound/pci/korg1212/korg1212.c index a8a6a5c..4eddb51 100644 --- a/sound/pci/korg1212/korg1212.c +++ b/sound/pci/korg1212/korg1212.c @@ -609,8 +609,9 @@ static void snd_korg1212_SendStopAndWait(struct snd_korg1212 *korg1212) static void snd_korg1212_timer_func(unsigned long data) { struct snd_korg1212 *korg1212 = (struct snd_korg1212 *) data; + unsigned long flags; - spin_lock(&korg1212->lock); + spin_lock_irqsave(&korg1212->lock, flags); if (korg1212->sharedBufferPtr->cardCommand == 0) { /* ack'ed */ korg1212->stop_pending_cnt = 0; @@ -632,7 +633,7 @@ static void snd_korg1212_timer_func(unsigned long data) stateName[korg1212->cardState]); } } - spin_unlock(&korg1212->lock); + spin_unlock_irqrestore(&korg1212->lock, flags); } static int snd_korg1212_TurnOnIdleMonitor(struct snd_korg1212 *korg1212) diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c index c387a83..24705d1 100644 --- a/sound/synth/emux/emux_synth.c +++ b/sound/synth/emux/emux_synth.c @@ -205,9 +205,10 @@ void snd_emux_timer_callback(unsigned long data) { struct snd_emux *emu = (struct snd_emux *) data; struct snd_emux_voice *vp; + unsigned long flags; int ch, do_again = 0; - spin_lock(&emu->voice_lock); + spin_lock_irqsave(&emu->voice_lock, flags); for (ch = 0; ch < emu->max_voices; ch++) { vp = &emu->voices[ch]; if (vp->state == SNDRV_EMUX_ST_PENDING) { @@ -225,7 +226,7 @@ void snd_emux_timer_callback(unsigned long data) emu->timer_active = 1; } else emu->timer_active = 0; - spin_unlock(&emu->voice_lock); + spin_unlock_irqrestore(&emu->voice_lock, flags); } /* -- cgit v1.1 From a2c855bbd76e7044c54a9d84ae46f6eead1b8f89 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 18 Nov 2005 18:52:39 +0100 Subject: [ALSA] Fix a compile warning Modules: CS4231 driver Fix a compile warning (unused variable). Signed-off-by: Takashi Iwai --- sound/isa/cs423x/cs4231_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 05d0d40..eab7eb5 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -1306,7 +1306,7 @@ static void snd_cs4231_resume(struct snd_cs4231 *chip) { int reg; unsigned long flags; - int timeout; + /* int timeout; */ snd_cs4231_mce_up(chip); spin_lock_irqsave(&chip->reg_lock, flags); -- cgit v1.1 From ac09a9251d3b7678150ee512de8de1bd98628d11 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 13:58:28 +0100 Subject: [ALSA] cs5535audio: move sound/driver.h to the top Modules: CS5535 driver Move the #include of to the top which is required for compilation on earlier kernels. Signed-off-by: Clemens Ladisch --- sound/pci/cs5535audio/cs5535audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 1899356..202c7cf 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c @@ -21,6 +21,7 @@ * */ +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include -- cgit v1.1 From a106cd3d9e88c8761bd0eac2ce402cc82bd11fea Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 13:59:56 +0100 Subject: [ALSA] rawmidi: protect against invalid device number in snd_rawmidi_info_select() Modules: RawMidi Midlevel In snd_rawmidi_info_select(), check that the device identified by the passed device number actually exists. Signed-off-by: Clemens Ladisch --- sound/core/rawmidi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 7a86a9a..d703545 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -573,6 +573,8 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info if (info->device >= SNDRV_RAWMIDI_DEVICES) return -ENXIO; rmidi = snd_rawmidi_devices[card->number * SNDRV_RAWMIDI_DEVICES + info->device]; + if (!rmidi) + return -ENXIO; if (info->stream < 0 || info->stream > 1) return -EINVAL; pstr = &rmidi->streams[info->stream]; -- cgit v1.1 From 2af677fc884fc6dc79e65c99050ea607ac8bab9b Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 14:03:48 +0100 Subject: [ALSA] dynamic minors (1/6): store device type in struct snd_minor Instead of a comment string, store the device type in the snd_minor structure. This makes snd_minor more flexible, and has the nice side effect that we don't need anymore to create a separate snd_minor template for registering a device but can pass the file_operations directly to snd_register_device(). Signed-off-by: Clemens Ladisch --- include/sound/core.h | 8 ++++--- include/sound/pcm.h | 3 +-- sound/core/control.c | 11 +++------ sound/core/hwdep.c | 11 +++------ sound/core/oss/mixer_oss.c | 8 +------ sound/core/oss/pcm_oss.c | 8 +------ sound/core/pcm.c | 6 +++-- sound/core/pcm_native.c | 53 +++++++++++++++++------------------------- sound/core/rawmidi.c | 14 ++++------- sound/core/seq/oss/seq_oss.c | 9 ++----- sound/core/seq/seq_clientmgr.c | 10 ++------ sound/core/sound.c | 38 ++++++++++++++++++++++++------ sound/core/sound_oss.c | 35 ++++++++++++++++++++++------ sound/core/timer.c | 8 +------ 14 files changed, 108 insertions(+), 114 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index f00b9c9..f557c8a 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -185,8 +185,8 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state, stru struct snd_minor { struct list_head list; /* list of all minors per card */ int number; /* minor number */ + int type; /* SNDRV_DEVICE_TYPE_XXX */ int device; /* device number */ - const char *comment; /* for /proc/asound/devices */ struct file_operations *f_ops; /* file operations */ char name[0]; /* device name (keep at the end of structure) */ @@ -199,11 +199,13 @@ extern int snd_ecards_limit; void snd_request_card(int card); -int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name); +int snd_register_device(int type, struct snd_card *card, int dev, + struct file_operations *f_ops, const char *name); int snd_unregister_device(int type, struct snd_card *card, int dev); #ifdef CONFIG_SND_OSSEMUL -int snd_register_oss_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name); +int snd_register_oss_device(int type, struct snd_card *card, int dev, + struct file_operations *f_ops, const char *name); int snd_unregister_oss_device(int type, struct snd_card *card, int dev); #endif diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 7e77c0a..5e29b0e 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -402,7 +402,6 @@ struct snd_pcm_str { struct snd_pcm_oss_stream oss; #endif struct snd_pcm_file *files; - struct snd_minor *reg; struct snd_info_entry *proc_root; struct snd_info_entry *proc_info_entry; #ifdef CONFIG_SND_DEBUG @@ -441,7 +440,7 @@ struct snd_pcm_notify { */ extern struct snd_pcm *snd_pcm_devices[]; -extern struct snd_minor snd_pcm_reg[2]; +extern struct file_operations snd_pcm_f_ops[2]; int snd_pcm_new(struct snd_card *card, char *id, int device, int playback_count, int capture_count, diff --git a/sound/core/control.c b/sound/core/control.c index f8f98cc..23561e7 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1264,12 +1264,6 @@ static struct file_operations snd_ctl_f_ops = .fasync = snd_ctl_fasync, }; -static struct snd_minor snd_ctl_reg = -{ - .comment = "ctl", - .f_ops = &snd_ctl_f_ops, -}; - /* * registration of the control device */ @@ -1284,7 +1278,7 @@ static int snd_ctl_dev_register(struct snd_device *device) snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); sprintf(name, "controlC%i", cardnum); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, - card, 0, &snd_ctl_reg, name)) < 0) + card, -1, &snd_ctl_f_ops, name)) < 0) return err; return 0; } @@ -1336,7 +1330,8 @@ static int snd_ctl_dev_unregister(struct snd_device *device) snd_assert(card != NULL, return -ENXIO); cardnum = card->number; snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); - if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, 0)) < 0) + if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, + card, -1)) < 0) return err; return snd_ctl_dev_free(device); } diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 444e266..27d5bf7 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -330,12 +330,6 @@ static struct file_operations snd_hwdep_f_ops = .mmap = snd_hwdep_mmap, }; -static struct snd_minor snd_hwdep_reg = -{ - .comment = "hardware dependent", - .f_ops = &snd_hwdep_f_ops, -}; - /** * snd_hwdep_new - create a new hwdep instance * @card: the card instance @@ -416,7 +410,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device, - &snd_hwdep_reg, name)) < 0) { + &snd_hwdep_f_ops, name)) < 0) { snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n", hwdep->card->number, hwdep->device); snd_hwdep_devices[idx] = NULL; @@ -431,7 +425,8 @@ static int snd_hwdep_dev_register(struct snd_device *device) } else { if (snd_register_oss_device(hwdep->oss_type, hwdep->card, hwdep->device, - &snd_hwdep_reg, hwdep->oss_dev) < 0) { + &snd_hwdep_f_ops, + hwdep->oss_dev) < 0) { snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n", hwdep->card->number, hwdep->device); } else diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index e448002c..2dd6bf9b 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -398,12 +398,6 @@ static struct file_operations snd_mixer_oss_f_ops = .compat_ioctl = snd_mixer_oss_ioctl_compat, }; -static struct snd_minor snd_mixer_oss_reg = -{ - .comment = "mixer", - .f_ops = &snd_mixer_oss_f_ops, -}; - /* * utilities */ @@ -1292,7 +1286,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) sprintf(name, "mixer%i%i", card->number, 0); if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, card, 0, - &snd_mixer_oss_reg, + &snd_mixer_oss_f_ops, name)) < 0) { snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n", card->number, 0); diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index ffc13b9..947bf08 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -2444,18 +2444,12 @@ static struct file_operations snd_pcm_oss_f_reg = .mmap = snd_pcm_oss_mmap, }; -static struct snd_minor snd_pcm_oss_reg = -{ - .comment = "digital audio", - .f_ops = &snd_pcm_oss_f_reg, -}; - static void register_oss_dsp(struct snd_pcm *pcm, int index) { char name[128]; sprintf(name, "dsp%i%i", pcm->card->number, pcm->device); if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, - pcm->card, index, &snd_pcm_oss_reg, + pcm->card, index, &snd_pcm_oss_f_reg, name) < 0) { snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n", pcm->card->number, pcm->device); diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 9305ac3..2bc5f69e 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -597,7 +597,6 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) pstr->stream = stream; pstr->pcm = pcm; pstr->substream_count = substream_count; - pstr->reg = &snd_pcm_reg[stream]; if (substream_count > 0) { err = snd_pcm_stream_proc_init(pstr); if (err < 0) { @@ -897,7 +896,10 @@ static int snd_pcm_dev_register(struct snd_device *device) devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; break; } - if ((err = snd_register_device(devtype, pcm->card, pcm->device, pcm->streams[cidx].reg, str)) < 0) { + if ((err = snd_register_device(devtype, pcm->card, + pcm->device, + &snd_pcm_f_ops[cidx], str)) < 0) + { snd_pcm_devices[idx] = NULL; up(®ister_mutex); return err; diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 7bac1cb..bb40c01 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -3370,40 +3370,29 @@ out: * Register section */ -static struct file_operations snd_pcm_f_ops_playback = { - .owner = THIS_MODULE, - .write = snd_pcm_write, - .writev = snd_pcm_writev, - .open = snd_pcm_open, - .release = snd_pcm_release, - .poll = snd_pcm_playback_poll, - .unlocked_ioctl = snd_pcm_playback_ioctl, - .compat_ioctl = snd_pcm_ioctl_compat, - .mmap = snd_pcm_mmap, - .fasync = snd_pcm_fasync, -}; - -static struct file_operations snd_pcm_f_ops_capture = { - .owner = THIS_MODULE, - .read = snd_pcm_read, - .readv = snd_pcm_readv, - .open = snd_pcm_open, - .release = snd_pcm_release, - .poll = snd_pcm_capture_poll, - .unlocked_ioctl = snd_pcm_capture_ioctl, - .compat_ioctl = snd_pcm_ioctl_compat, - .mmap = snd_pcm_mmap, - .fasync = snd_pcm_fasync, -}; - -struct snd_minor snd_pcm_reg[2] = -{ +struct file_operations snd_pcm_f_ops[2] = { { - .comment = "digital audio playback", - .f_ops = &snd_pcm_f_ops_playback, + .owner = THIS_MODULE, + .write = snd_pcm_write, + .writev = snd_pcm_writev, + .open = snd_pcm_open, + .release = snd_pcm_release, + .poll = snd_pcm_playback_poll, + .unlocked_ioctl = snd_pcm_playback_ioctl, + .compat_ioctl = snd_pcm_ioctl_compat, + .mmap = snd_pcm_mmap, + .fasync = snd_pcm_fasync, }, { - .comment = "digital audio capture", - .f_ops = &snd_pcm_f_ops_capture, + .owner = THIS_MODULE, + .read = snd_pcm_read, + .readv = snd_pcm_readv, + .open = snd_pcm_open, + .release = snd_pcm_release, + .poll = snd_pcm_capture_poll, + .unlocked_ioctl = snd_pcm_capture_ioctl, + .compat_ioctl = snd_pcm_ioctl_compat, + .mmap = snd_pcm_mmap, + .fasync = snd_pcm_fasync, } }; diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index d703545..7ac77e5 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1367,12 +1367,6 @@ static struct file_operations snd_rawmidi_f_ops = .compat_ioctl = snd_rawmidi_ioctl_compat, }; -static struct snd_minor snd_rawmidi_reg = -{ - .comment = "raw midi", - .f_ops = &snd_rawmidi_f_ops, -}; - static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi, struct snd_rawmidi_str *stream, int direction, @@ -1516,7 +1510,7 @@ static int snd_rawmidi_dev_register(struct snd_device *device) sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device, - &snd_rawmidi_reg, name)) < 0) { + &snd_rawmidi_f_ops, name)) < 0) { snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); snd_rawmidi_devices[idx] = NULL; up(®ister_mutex); @@ -1533,7 +1527,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) rmidi->ossreg = 0; if ((int)rmidi->device == midi_map[rmidi->card->number]) { if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, - rmidi->card, 0, &snd_rawmidi_reg, name) < 0) { + rmidi->card, 0, + &snd_rawmidi_f_ops, name) < 0) { snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0); } else { rmidi->ossreg++; @@ -1544,7 +1539,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) } if ((int)rmidi->device == amidi_map[rmidi->card->number]) { if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, - rmidi->card, 1, &snd_rawmidi_reg, name) < 0) { + rmidi->card, 1, + &snd_rawmidi_f_ops, name) < 0) { snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1); } else { rmidi->ossreg++; diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 2371e41..61c0a41 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c @@ -217,11 +217,6 @@ static struct file_operations seq_oss_f_ops = .compat_ioctl = odev_ioctl_compat, }; -static struct snd_minor seq_oss_reg = { - .comment = "sequencer", - .f_ops = &seq_oss_f_ops, -}; - static int __init register_device(void) { @@ -230,7 +225,7 @@ register_device(void) down(®ister_mutex); if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0, - &seq_oss_reg, + &seq_oss_f_ops, SNDRV_SEQ_OSS_DEVNAME)) < 0) { snd_printk(KERN_ERR "can't register device seq\n"); up(®ister_mutex); @@ -238,7 +233,7 @@ register_device(void) } if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0, - &seq_oss_reg, + &seq_oss_f_ops, SNDRV_SEQ_OSS_DEVNAME)) < 0) { snd_printk(KERN_ERR "can't register device music\n"); snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 5eab420..087fdf3 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2520,13 +2520,6 @@ static struct file_operations snd_seq_f_ops = .compat_ioctl = snd_seq_ioctl_compat, }; -static struct snd_minor snd_seq_reg = -{ - .comment = "sequencer", - .f_ops = &snd_seq_f_ops, -}; - - /* * register sequencer device */ @@ -2537,7 +2530,8 @@ int __init snd_sequencer_device_init(void) if (down_interruptible(®ister_mutex)) return -ERESTARTSYS; - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, &snd_seq_reg, "seq")) < 0) { + if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, + &snd_seq_f_ops, "seq")) < 0) { up(®ister_mutex); return err; } diff --git a/sound/core/sound.c b/sound/core/sound.c index fb236a6..798c24c 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -195,7 +195,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * @type: the device type, SNDRV_DEVICE_TYPE_XXX * @card: the card instance * @dev: the device index - * @reg: the struct snd_minor record + * @f_ops: the file operations * @name: the device file name * * Registers an ALSA device file for the given card. @@ -203,7 +203,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * * Retrurns zero if successful, or a negative error code on failure. */ -int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor * reg, const char *name) +int snd_register_device(int type, struct snd_card *card, int dev, + struct file_operations *f_ops, const char *name) { int minor = snd_kernel_minor(type, card, dev); struct snd_minor *preg; @@ -212,12 +213,13 @@ int snd_register_device(int type, struct snd_card *card, int dev, struct snd_min if (minor < 0) return minor; snd_assert(name, return -EINVAL); - preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); + preg = kzalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); if (preg == NULL) return -ENOMEM; - *preg = *reg; preg->number = minor; + preg->type = type; preg->device = dev; + preg->f_ops = f_ops; strcpy(preg->name, name); down(&sound_mutex); if (snd_minor_search(minor)) { @@ -276,6 +278,28 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) static struct snd_info_entry *snd_minor_info_entry = NULL; +static const char *snd_device_type_name(int type) +{ + switch (type) { + case SNDRV_DEVICE_TYPE_CONTROL: + return "control"; + case SNDRV_DEVICE_TYPE_HWDEP: + return "hardware dependent"; + case SNDRV_DEVICE_TYPE_RAWMIDI: + return "raw midi"; + case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: + return "digital audio playback"; + case SNDRV_DEVICE_TYPE_PCM_CAPTURE: + return "digital audio capture"; + case SNDRV_DEVICE_TYPE_SEQUENCER: + return "sequencer"; + case SNDRV_DEVICE_TYPE_TIMER: + return "timer"; + default: + return "?"; + } +} + static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { int card, device; @@ -288,11 +312,11 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu mptr = list_entry(list, struct snd_minor, list); if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) { if ((device = mptr->device) >= 0) - snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, mptr->comment); + snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, snd_device_type_name(mptr->type)); else - snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, mptr->comment); + snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, snd_device_type_name(mptr->type)); } else { - snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment); + snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_device_type_name(mptr->type)); } } } diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index ec37604..4d189ff 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -91,7 +91,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) } int snd_register_oss_device(int type, struct snd_card *card, int dev, - struct snd_minor * reg, const char *name) + struct file_operations *f_ops, const char *name) { int minor = snd_oss_kernel_minor(type, card, dev); int minor_unit; @@ -103,12 +103,13 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, if (minor < 0) return minor; - preg = (struct snd_minor *)kmalloc(sizeof(struct snd_minor), GFP_KERNEL); + preg = kzalloc(sizeof(struct snd_minor), GFP_KERNEL); if (preg == NULL) return -ENOMEM; - *preg = *reg; preg->number = minor; + preg->type = type; preg->device = dev; + preg->f_ops = f_ops; down(&sound_oss_mutex); list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]); minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); @@ -125,11 +126,12 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, } if (card) carddev = card->dev; - register1 = register_sound_special_device(reg->f_ops, minor, carddev); + register1 = register_sound_special_device(f_ops, minor, carddev); if (register1 != minor) goto __end; if (track2 >= 0) { - register2 = register_sound_special_device(reg->f_ops, track2, carddev); + register2 = register_sound_special_device(f_ops, track2, + carddev); if (register2 != track2) goto __end; } @@ -190,6 +192,25 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) static struct snd_info_entry *snd_minor_info_oss_entry = NULL; +static const char *snd_oss_device_type_name(int type) +{ + switch (type) { + case SNDRV_OSS_DEVICE_TYPE_MIXER: + return "mixer"; + case SNDRV_OSS_DEVICE_TYPE_SEQUENCER: + case SNDRV_OSS_DEVICE_TYPE_MUSIC: + return "sequencer"; + case SNDRV_OSS_DEVICE_TYPE_PCM: + return "digital audio"; + case SNDRV_OSS_DEVICE_TYPE_MIDI: + return "raw midi"; + case SNDRV_OSS_DEVICE_TYPE_DMFM: + return "hardware dependent"; + default: + return "?"; + } +} + static void snd_minor_info_oss_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { @@ -205,9 +226,9 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry, if (dev != SNDRV_MINOR_OSS_SNDSTAT && dev != SNDRV_MINOR_OSS_SEQUENCER && dev != SNDRV_MINOR_OSS_MUSIC) - snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, mptr->comment); + snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, snd_oss_device_type_name(mptr->type)); else - snd_iprintf(buffer, "%3i: : %s\n", mptr->number, mptr->comment); + snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_oss_device_type_name(mptr->type)); } } up(&sound_oss_mutex); diff --git a/sound/core/timer.c b/sound/core/timer.c index 6aad411..a7bcb04 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1924,12 +1924,6 @@ static struct file_operations snd_timer_f_ops = .fasync = snd_timer_user_fasync, }; -static struct snd_minor snd_timer_reg = -{ - .comment = "timer", - .f_ops = &snd_timer_f_ops, -}; - /* * ENTRY functions */ @@ -1959,7 +1953,7 @@ static int __init alsa_timer_init(void) snd_printk(KERN_ERR "unable to register system timer (%i)\n", err); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, - NULL, 0, &snd_timer_reg, "timer"))<0) + NULL, 0, &snd_timer_f_ops, "timer")) < 0) snd_printk(KERN_ERR "unable to register timer device (%i)\n", err); return 0; -- cgit v1.1 From 6983b7240cd229787c3ee00e663ea94ea649d96a Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 14:05:49 +0100 Subject: [ALSA] dynamic minors (2/6): simplify storage of snd_minor structures Modules: ALSA Core Store the snd_minor structure pointers in one array instead of using a separate list for each card. This simplifies the mapping from device files to minor struct by removing the need to know about the encoding of the card number in the minor number. Signed-off-by: Clemens Ladisch --- include/sound/core.h | 5 +--- sound/core/sound.c | 72 ++++++++++++++++++++------------------------------ sound/core/sound_oss.c | 64 ++++++++++++++------------------------------ 3 files changed, 49 insertions(+), 92 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index f557c8a..67b0a7e 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -183,9 +183,8 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state, stru #endif /* CONFIG_PM */ struct snd_minor { - struct list_head list; /* list of all minors per card */ - int number; /* minor number */ int type; /* SNDRV_DEVICE_TYPE_XXX */ + int card; /* card number */ int device; /* device number */ struct file_operations *f_ops; /* file operations */ char name[0]; /* device name (keep at the end of @@ -217,11 +216,9 @@ int snd_minor_info_done(void); #ifdef CONFIG_SND_OSSEMUL int snd_minor_info_oss_init(void); int snd_minor_info_oss_done(void); -int snd_oss_init_module(void); #else #define snd_minor_info_oss_init() /*NOP*/ #define snd_minor_info_oss_done() /*NOP*/ -#define snd_oss_init_module() 0 #endif /* memory.c */ diff --git a/sound/core/sound.c b/sound/core/sound.c index 798c24c..a509f49 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -59,7 +59,7 @@ MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR); */ int snd_ecards_limit; -static struct list_head snd_minors_hash[SNDRV_CARDS]; +static struct snd_minor *snd_minors[SNDRV_OS_MINORS]; static DECLARE_MUTEX(sound_mutex); @@ -107,19 +107,6 @@ static void snd_request_other(int minor) #endif /* request_module support */ -static struct snd_minor *snd_minor_search(int minor) -{ - struct list_head *list; - struct snd_minor *mptr; - - list_for_each(list, &snd_minors_hash[SNDRV_MINOR_CARD(minor)]) { - mptr = list_entry(list, struct snd_minor, list); - if (mptr->number == minor) - return mptr; - } - return NULL; -} - static int snd_open(struct inode *inode, struct file *file) { int minor = iminor(inode); @@ -139,11 +126,11 @@ static int snd_open(struct inode *inode, struct file *file) } } else { #ifdef CONFIG_KMOD - if ((mptr = snd_minor_search(minor)) == NULL) + if ((mptr = snd_minors[minor]) == NULL) snd_request_other(minor); #endif } - if (mptr == NULL && (mptr = snd_minor_search(minor)) == NULL) + if (mptr == NULL && (mptr = snd_minors[minor]) == NULL) return -ENODEV; old_fops = file->f_op; file->f_op = fops_get(mptr->f_ops); @@ -213,22 +200,22 @@ int snd_register_device(int type, struct snd_card *card, int dev, if (minor < 0) return minor; snd_assert(name, return -EINVAL); - preg = kzalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); + preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); if (preg == NULL) return -ENOMEM; - preg->number = minor; preg->type = type; + preg->card = card ? card->number : -1; preg->device = dev; preg->f_ops = f_ops; strcpy(preg->name, name); down(&sound_mutex); - if (snd_minor_search(minor)) { + if (snd_minors[minor]) { up(&sound_mutex); kfree(preg); return -EBUSY; } - list_add_tail(&preg->list, &snd_minors_hash[SNDRV_MINOR_CARD(minor)]); - if (strncmp(name, "controlC", 8) || card->number >= cards_limit) + snd_minors[minor] = preg; + if (type != SNDRV_DEVICE_TYPE_CONTROL || preg->card >= cards_limit) devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name); if (card) device = card->dev; @@ -257,16 +244,17 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) if (minor < 0) return minor; down(&sound_mutex); - if ((mptr = snd_minor_search(minor)) == NULL) { + if ((mptr = snd_minors[minor]) == NULL) { up(&sound_mutex); return -EINVAL; } - if (strncmp(mptr->name, "controlC", 8) || card->number >= cards_limit) /* created in sound.c */ + if (mptr->type != SNDRV_DEVICE_TYPE_CONTROL || + mptr->card >= cards_limit) /* created in sound.c */ devfs_remove("snd/%s", mptr->name); class_device_destroy(sound_class, MKDEV(major, minor)); - list_del(&mptr->list); + snd_minors[minor] = NULL; up(&sound_mutex); kfree(mptr); return 0; @@ -302,23 +290,25 @@ static const char *snd_device_type_name(int type) static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - int card, device; - struct list_head *list; + int minor; struct snd_minor *mptr; down(&sound_mutex); - for (card = 0; card < SNDRV_CARDS; card++) { - list_for_each(list, &snd_minors_hash[card]) { - mptr = list_entry(list, struct snd_minor, list); - if (SNDRV_MINOR_DEVICE(mptr->number) != SNDRV_MINOR_GLOBAL) { - if ((device = mptr->device) >= 0) - snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, device, snd_device_type_name(mptr->type)); - else - snd_iprintf(buffer, "%3i: [%i] : %s\n", mptr->number, card, snd_device_type_name(mptr->type)); - } else { - snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_device_type_name(mptr->type)); - } - } + for (minor = 0; minor < SNDRV_OS_MINORS; ++minor) { + if (!(mptr = snd_minors[minor])) + continue; + if (mptr->card >= 0) { + if (mptr->device >= 0) + snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", + minor, mptr->card, mptr->device, + snd_device_type_name(mptr->type)); + else + snd_iprintf(buffer, "%3i: [%i] : %s\n", + minor, mptr->card, + snd_device_type_name(mptr->type)); + } else + snd_iprintf(buffer, "%3i: : %s\n", minor, + snd_device_type_name(mptr->type)); } up(&sound_mutex); } @@ -354,15 +344,9 @@ int __exit snd_minor_info_done(void) static int __init alsa_sound_init(void) { short controlnum; - int err; - int card; snd_major = major; snd_ecards_limit = cards_limit; - for (card = 0; card < SNDRV_CARDS; card++) - INIT_LIST_HEAD(&snd_minors_hash[card]); - if ((err = snd_oss_init_module()) < 0) - return err; devfs_mk_dir("snd"); if (register_chrdev(major, "alsa", &snd_fops)) { snd_printk(KERN_ERR "unable to register native major device number %d\n", major); diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index 4d189ff..afbfd8d 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -35,25 +35,12 @@ #include #include -#define SNDRV_OS_MINORS 256 +#define SNDRV_OSS_MINORS 128 -static struct list_head snd_oss_minors_hash[SNDRV_CARDS]; +static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; static DECLARE_MUTEX(sound_oss_mutex); -static struct snd_minor *snd_oss_minor_search(int minor) -{ - struct list_head *list; - struct snd_minor *mptr; - - list_for_each(list, &snd_oss_minors_hash[SNDRV_MINOR_OSS_CARD(minor)]) { - mptr = list_entry(list, struct snd_minor, list); - if (mptr->number == minor) - return mptr; - } - return NULL; -} - static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) { int minor; @@ -86,7 +73,7 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) default: return -EINVAL; } - snd_assert(minor >= 0 && minor < SNDRV_OS_MINORS, return -EINVAL); + snd_assert(minor >= 0 && minor < SNDRV_OSS_MINORS, return -EINVAL); return minor; } @@ -103,15 +90,15 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, if (minor < 0) return minor; - preg = kzalloc(sizeof(struct snd_minor), GFP_KERNEL); + preg = kmalloc(sizeof(struct snd_minor), GFP_KERNEL); if (preg == NULL) return -ENOMEM; - preg->number = minor; preg->type = type; + preg->card = card ? card->number : -1; preg->device = dev; preg->f_ops = f_ops; down(&sound_oss_mutex); - list_add_tail(&preg->list, &snd_oss_minors_hash[cidx]); + snd_oss_minors[minor] = preg; minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); switch (minor_unit) { case SNDRV_MINOR_OSS_PCM: @@ -143,7 +130,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, unregister_sound_special(register2); if (register1 >= 0) unregister_sound_special(register1); - list_del(&preg->list); + snd_oss_minors[minor] = NULL; up(&sound_oss_mutex); kfree(preg); return -EBUSY; @@ -159,7 +146,7 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) if (minor < 0) return minor; down(&sound_oss_mutex); - mptr = snd_oss_minor_search(minor); + mptr = snd_oss_minors[minor]; if (mptr == NULL) { up(&sound_oss_mutex); return -ENOENT; @@ -178,7 +165,7 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) } if (track2 >= 0) unregister_sound_special(track2); - list_del(&mptr->list); + snd_oss_minors[minor] = NULL; up(&sound_oss_mutex); kfree(mptr); return 0; @@ -214,22 +201,20 @@ static const char *snd_oss_device_type_name(int type) static void snd_minor_info_oss_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - int card, dev; - struct list_head *list; + int minor; struct snd_minor *mptr; down(&sound_oss_mutex); - for (card = 0; card < SNDRV_CARDS; card++) { - list_for_each(list, &snd_oss_minors_hash[card]) { - mptr = list_entry(list, struct snd_minor, list); - dev = SNDRV_MINOR_OSS_DEVICE(mptr->number); - if (dev != SNDRV_MINOR_OSS_SNDSTAT && - dev != SNDRV_MINOR_OSS_SEQUENCER && - dev != SNDRV_MINOR_OSS_MUSIC) - snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", mptr->number, card, dev, snd_oss_device_type_name(mptr->type)); - else - snd_iprintf(buffer, "%3i: : %s\n", mptr->number, snd_oss_device_type_name(mptr->type)); - } + for (minor = 0; minor < SNDRV_OSS_MINORS; ++minor) { + if (!(mptr = snd_oss_minors[minor])) + continue; + if (mptr->card >= 0) + snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", minor, + mptr->card, mptr->device, + snd_oss_device_type_name(mptr->type)); + else + snd_iprintf(buffer, "%3i: : %s\n", minor, + snd_oss_device_type_name(mptr->type)); } up(&sound_oss_mutex); } @@ -264,13 +249,4 @@ int __exit snd_minor_info_oss_done(void) return 0; } -int __init snd_oss_init_module(void) -{ - int card; - - for (card = 0; card < SNDRV_CARDS; card++) - INIT_LIST_HEAD(&snd_oss_minors_hash[card]); - return 0; -} - #endif /* CONFIG_SND_OSSEMUL */ -- cgit v1.1 From f87135f56cb266e031f5ec081dfbde7e43f55e80 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 14:06:59 +0100 Subject: [ALSA] dynamic minors (3/6): store device-specific object pointers dynamically Instead of storing the pointers to the device-specific structures in an array, put them into the struct snd_minor, and look them up dynamically. This makes the device type modules independent of the minor number encoding. Signed-off-by: Clemens Ladisch --- include/sound/core.h | 9 +++- include/sound/hwdep.h | 1 + include/sound/pcm.h | 2 +- include/sound/rawmidi.h | 6 +-- sound/core/control.c | 7 ++- sound/core/hwdep.c | 91 +++++++++++++++---------------- sound/core/oss/mixer_oss.c | 7 +-- sound/core/oss/pcm_oss.c | 14 ++--- sound/core/pcm.c | 118 +++++++++++++++++++++++------------------ sound/core/pcm_native.c | 40 +++++++++----- sound/core/rawmidi.c | 87 +++++++++++++++--------------- sound/core/seq/oss/seq_oss.c | 4 +- sound/core/seq/seq_clientmgr.c | 2 +- sound/core/seq/seq_midi.c | 10 +++- sound/core/sound.c | 46 +++++++++++++--- sound/core/sound_oss.c | 27 ++++++++-- sound/core/timer.c | 4 +- 17 files changed, 278 insertions(+), 197 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index 67b0a7e..90ac613 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -187,6 +187,7 @@ struct snd_minor { int card; /* card number */ int device; /* device number */ struct file_operations *f_ops; /* file operations */ + void *private_data; /* private data for f_ops->open */ char name[0]; /* device name (keep at the end of structure) */ }; @@ -199,13 +200,17 @@ extern int snd_ecards_limit; void snd_request_card(int card); int snd_register_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name); + struct file_operations *f_ops, void *private_data, + const char *name); int snd_unregister_device(int type, struct snd_card *card, int dev); +void *snd_lookup_minor_data(unsigned int minor, int type); #ifdef CONFIG_SND_OSSEMUL int snd_register_oss_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name); + struct file_operations *f_ops, void *private_data, + const char *name); int snd_unregister_oss_device(int type, struct snd_card *card, int dev); +void *snd_lookup_oss_minor_data(unsigned int minor, int type); #endif int snd_minor_info_init(void); diff --git a/include/sound/hwdep.h b/include/sound/hwdep.h index 04b20bc..c679e5b 100644 --- a/include/sound/hwdep.h +++ b/include/sound/hwdep.h @@ -43,6 +43,7 @@ struct snd_hwdep_ops { struct snd_hwdep { struct snd_card *card; + struct list_head list; int device; char id[32]; char name[80]; diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 5e29b0e..314268a 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -412,6 +412,7 @@ struct snd_pcm_str { struct snd_pcm { struct snd_card *card; + struct list_head list; unsigned int device; /* device number */ unsigned int info_flags; unsigned short dev_class; @@ -439,7 +440,6 @@ struct snd_pcm_notify { * Registering */ -extern struct snd_pcm *snd_pcm_devices[]; extern struct file_operations snd_pcm_f_ops[2]; int snd_pcm_new(struct snd_card *card, char *id, int device, diff --git a/include/sound/rawmidi.h b/include/sound/rawmidi.h index 9492a32..d19bddf 100644 --- a/include/sound/rawmidi.h +++ b/include/sound/rawmidi.h @@ -113,7 +113,7 @@ struct snd_rawmidi_str { struct snd_rawmidi { struct snd_card *card; - + struct list_head list; unsigned int device; /* device number */ unsigned int info_flags; /* SNDRV_RAWMIDI_INFO_XXXX */ char id[64]; @@ -165,8 +165,8 @@ int snd_rawmidi_transmit(struct snd_rawmidi_substream *substream, /* main midi functions */ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info); -int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, int mode, - struct snd_rawmidi_file *rfile); +int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, + int mode, struct snd_rawmidi_file *rfile); int snd_rawmidi_kernel_release(struct snd_rawmidi_file *rfile); int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, struct snd_rawmidi_params *params); diff --git a/sound/core/control.c b/sound/core/control.c index 23561e7..abd62f9 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -47,13 +47,12 @@ static LIST_HEAD(snd_control_compat_ioctls); static int snd_ctl_open(struct inode *inode, struct file *file) { - int cardnum = SNDRV_MINOR_CARD(iminor(inode)); unsigned long flags; struct snd_card *card; struct snd_ctl_file *ctl; int err; - card = snd_cards[cardnum]; + card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL); if (!card) { err = -ENODEV; goto __error1; @@ -1277,8 +1276,8 @@ static int snd_ctl_dev_register(struct snd_device *device) cardnum = card->number; snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); sprintf(name, "controlC%i", cardnum); - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, - card, -1, &snd_ctl_f_ops, name)) < 0) + if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, + &snd_ctl_f_ops, card, name)) < 0) return err; return 0; } diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index 27d5bf7..b8c0c8c 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -35,8 +35,7 @@ MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Hardware dependent layer"); MODULE_LICENSE("GPL"); -static struct snd_hwdep *snd_hwdep_devices[SNDRV_CARDS * SNDRV_MINOR_HWDEPS]; - +static LIST_HEAD(snd_hwdep_devices); static DECLARE_MUTEX(register_mutex); static int snd_hwdep_free(struct snd_hwdep *hwdep); @@ -44,9 +43,19 @@ static int snd_hwdep_dev_free(struct snd_device *device); static int snd_hwdep_dev_register(struct snd_device *device); static int snd_hwdep_dev_unregister(struct snd_device *device); -/* - */ +static struct snd_hwdep *snd_hwdep_search(struct snd_card *card, int device) +{ + struct list_head *p; + struct snd_hwdep *hwdep; + + list_for_each(p, &snd_hwdep_devices) { + hwdep = list_entry(p, struct snd_hwdep, list); + if (hwdep->card == card && hwdep->device == device) + return hwdep; + } + return NULL; +} static loff_t snd_hwdep_llseek(struct file * file, loff_t offset, int orig) { @@ -77,34 +86,25 @@ static ssize_t snd_hwdep_write(struct file * file, const char __user *buf, static int snd_hwdep_open(struct inode *inode, struct file * file) { int major = imajor(inode); - int cardnum; - int device; struct snd_hwdep *hw; int err; wait_queue_t wait; if (major == snd_major) { - cardnum = SNDRV_MINOR_CARD(iminor(inode)); - device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_HWDEP; + hw = snd_lookup_minor_data(iminor(inode), + SNDRV_DEVICE_TYPE_HWDEP); #ifdef CONFIG_SND_OSSEMUL } else if (major == SOUND_MAJOR) { - cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode)); - device = 0; + hw = snd_lookup_oss_minor_data(iminor(inode), + SNDRV_OSS_DEVICE_TYPE_DMFM); #endif } else return -ENXIO; - cardnum %= SNDRV_CARDS; - device %= SNDRV_MINOR_HWDEPS; - hw = snd_hwdep_devices[(cardnum * SNDRV_MINOR_HWDEPS) + device]; if (hw == NULL) return -ENODEV; if (!hw->ops.open) return -ENXIO; -#ifdef CONFIG_SND_OSSEMUL - if (major == SOUND_MAJOR && hw->oss_type < 0) - return -ENXIO; -#endif if (!try_module_get(hw->card->module)) return -EFAULT; @@ -265,9 +265,6 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, struct snd_ctl_file * control, unsigned int cmd, unsigned long arg) { - unsigned int tmp; - - tmp = card->number * SNDRV_MINOR_HWDEPS; switch (cmd) { case SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE: { @@ -275,14 +272,16 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, if (get_user(device, (int __user *)arg)) return -EFAULT; + down(®ister_mutex); device = device < 0 ? 0 : device + 1; while (device < SNDRV_MINOR_HWDEPS) { - if (snd_hwdep_devices[tmp + device]) + if (snd_hwdep_search(card, device)) break; device++; } if (device >= SNDRV_MINOR_HWDEPS) device = -1; + up(®ister_mutex); if (put_user(device, (int __user *)arg)) return -EFAULT; return 0; @@ -290,17 +289,19 @@ static int snd_hwdep_control_ioctl(struct snd_card *card, case SNDRV_CTL_IOCTL_HWDEP_INFO: { struct snd_hwdep_info __user *info = (struct snd_hwdep_info __user *)arg; - int device; + int device, err; struct snd_hwdep *hwdep; if (get_user(device, &info->device)) return -EFAULT; - if (device < 0 || device >= SNDRV_MINOR_HWDEPS) - return -ENXIO; - hwdep = snd_hwdep_devices[tmp + device]; - if (hwdep == NULL) - return -ENXIO; - return snd_hwdep_info(hwdep, info); + down(®ister_mutex); + hwdep = snd_hwdep_search(card, device); + if (hwdep) + err = snd_hwdep_info(hwdep, info); + else + err = -ENXIO; + up(®ister_mutex); + return err; } } return -ENOIOCTLCMD; @@ -397,23 +398,22 @@ static int snd_hwdep_dev_free(struct snd_device *device) static int snd_hwdep_dev_register(struct snd_device *device) { struct snd_hwdep *hwdep = device->device_data; - int idx, err; + int err; char name[32]; down(®ister_mutex); - idx = (hwdep->card->number * SNDRV_MINOR_HWDEPS) + hwdep->device; - if (snd_hwdep_devices[idx]) { + if (snd_hwdep_search(hwdep->card, hwdep->device)) { up(®ister_mutex); return -EBUSY; } - snd_hwdep_devices[idx] = hwdep; + list_add_tail(&hwdep->list, &snd_hwdep_devices); sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device, - &snd_hwdep_f_ops, name)) < 0) { + &snd_hwdep_f_ops, hwdep, name)) < 0) { snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n", hwdep->card->number, hwdep->device); - snd_hwdep_devices[idx] = NULL; + list_del(&hwdep->list); up(®ister_mutex); return err; } @@ -425,7 +425,7 @@ static int snd_hwdep_dev_register(struct snd_device *device) } else { if (snd_register_oss_device(hwdep->oss_type, hwdep->card, hwdep->device, - &snd_hwdep_f_ops, + &snd_hwdep_f_ops, hwdep, hwdep->oss_dev) < 0) { snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n", hwdep->card->number, hwdep->device); @@ -441,12 +441,10 @@ static int snd_hwdep_dev_register(struct snd_device *device) static int snd_hwdep_dev_unregister(struct snd_device *device) { struct snd_hwdep *hwdep = device->device_data; - int idx; snd_assert(hwdep != NULL, return -ENXIO); down(®ister_mutex); - idx = (hwdep->card->number * SNDRV_MINOR_HWDEPS) + hwdep->device; - if (snd_hwdep_devices[idx] != hwdep) { + if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { up(®ister_mutex); return -EINVAL; } @@ -455,7 +453,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) snd_unregister_oss_device(hwdep->oss_type, hwdep->card, hwdep->device); #endif snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); - snd_hwdep_devices[idx] = NULL; + list_del(&hwdep->list); up(®ister_mutex); return snd_hwdep_free(hwdep); } @@ -467,18 +465,14 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) static void snd_hwdep_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - int idx; + struct list_head *p; struct snd_hwdep *hwdep; down(®ister_mutex); - for (idx = 0; idx < SNDRV_CARDS * SNDRV_MINOR_HWDEPS; idx++) { - hwdep = snd_hwdep_devices[idx]; - if (hwdep == NULL) - continue; + list_for_each(p, &snd_hwdep_devices) { + hwdep = list_entry(p, struct snd_hwdep, list); snd_iprintf(buffer, "%02i-%02i: %s\n", - idx / SNDRV_MINOR_HWDEPS, - idx % SNDRV_MINOR_HWDEPS, - hwdep->name); + hwdep->card->number, hwdep->device, hwdep->name); } up(®ister_mutex); } @@ -493,9 +487,8 @@ static int __init alsa_hwdep_init(void) { struct snd_info_entry *entry; - memset(snd_hwdep_devices, 0, sizeof(snd_hwdep_devices)); if ((entry = snd_info_create_module_entry(THIS_MODULE, "hwdep", NULL)) != NULL) { - entry->c.text.read_size = 512; + entry->c.text.read_size = PAGE_SIZE; entry->c.text.read = snd_hwdep_proc_read; if (snd_info_register(entry) < 0) { snd_info_free_entry(entry); diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 2dd6bf9b..2d7a420 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -41,12 +41,13 @@ MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_MIXER); static int snd_mixer_oss_open(struct inode *inode, struct file *file) { - int cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode)); struct snd_card *card; struct snd_mixer_oss_file *fmixer; int err; - if ((card = snd_cards[cardnum]) == NULL) + card = snd_lookup_oss_minor_data(iminor(inode), + SNDRV_OSS_DEVICE_TYPE_MIXER); + if (card == NULL) return -ENODEV; if (card->mixer_oss == NULL) return -ENODEV; @@ -1286,7 +1287,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) sprintf(name, "mixer%i%i", card->number, 0); if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, card, 0, - &snd_mixer_oss_f_ops, + &snd_mixer_oss_f_ops, card, name)) < 0) { snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n", card->number, 0); diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 947bf08..2ae283c 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -1834,9 +1834,6 @@ static int snd_task_name(struct task_struct *task, char *name, size_t size) static int snd_pcm_oss_open(struct inode *inode, struct file *file) { - int minor = iminor(inode); - int cardnum = SNDRV_MINOR_OSS_CARD(minor); - int device; int err; char task_name[32]; struct snd_pcm *pcm; @@ -1845,11 +1842,8 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) int nonblock; wait_queue_t wait; - snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); - device = SNDRV_MINOR_OSS_DEVICE(minor) == SNDRV_MINOR_OSS_PCM1 ? - adsp_map[cardnum] : dsp_map[cardnum]; - - pcm = snd_pcm_devices[(cardnum * SNDRV_PCM_DEVICES) + device]; + pcm = snd_lookup_oss_minor_data(iminor(inode), + SNDRV_OSS_DEVICE_TYPE_PCM); if (pcm == NULL) { err = -ENODEV; goto __error1; @@ -1890,7 +1884,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file) down(&pcm->open_mutex); while (1) { err = snd_pcm_oss_open_file(file, pcm, &pcm_oss_file, - minor, psetup, csetup); + iminor(inode), psetup, csetup); if (err >= 0) break; if (err == -EAGAIN) { @@ -2450,7 +2444,7 @@ static void register_oss_dsp(struct snd_pcm *pcm, int index) sprintf(name, "dsp%i%i", pcm->card->number, pcm->device); if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_PCM, pcm->card, index, &snd_pcm_oss_f_reg, - name) < 0) { + pcm, name) < 0) { snd_printk(KERN_ERR "unable to register OSS PCM device %i:%i\n", pcm->card->number, pcm->device); } diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 2bc5f69e..95036c8 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -33,7 +33,7 @@ MODULE_AUTHOR("Jaroslav Kysela , Abramo Bagnara card == card && pcm->device == device) + return pcm; + } + return NULL; +} + static int snd_pcm_control_ioctl(struct snd_card *card, struct snd_ctl_file *control, unsigned int cmd, unsigned long arg) { - unsigned int tmp; - - tmp = card->number * SNDRV_PCM_DEVICES; switch (cmd) { case SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE: { @@ -57,14 +67,16 @@ static int snd_pcm_control_ioctl(struct snd_card *card, if (get_user(device, (int __user *)arg)) return -EFAULT; + down(®ister_mutex); device = device < 0 ? 0 : device + 1; while (device < SNDRV_PCM_DEVICES) { - if (snd_pcm_devices[tmp + device]) + if (snd_pcm_search(card, device)) break; device++; } if (device == SNDRV_PCM_DEVICES) device = -1; + up(®ister_mutex); if (put_user(device, (int __user *)arg)) return -EFAULT; return 0; @@ -77,31 +89,44 @@ static int snd_pcm_control_ioctl(struct snd_card *card, struct snd_pcm *pcm; struct snd_pcm_str *pstr; struct snd_pcm_substream *substream; + int err; + info = (struct snd_pcm_info __user *)arg; if (get_user(device, &info->device)) return -EFAULT; - if (device >= SNDRV_PCM_DEVICES) - return -ENXIO; - pcm = snd_pcm_devices[tmp + device]; - if (pcm == NULL) - return -ENXIO; if (get_user(stream, &info->stream)) return -EFAULT; if (stream < 0 || stream > 1) return -EINVAL; - pstr = &pcm->streams[stream]; - if (pstr->substream_count == 0) - return -ENOENT; if (get_user(subdevice, &info->subdevice)) return -EFAULT; - if (subdevice >= pstr->substream_count) - return -ENXIO; - for (substream = pstr->substream; substream; substream = substream->next) + down(®ister_mutex); + pcm = snd_pcm_search(card, device); + if (pcm == NULL) { + err = -ENXIO; + goto _error; + } + pstr = &pcm->streams[stream]; + if (pstr->substream_count == 0) { + err = -ENOENT; + goto _error; + } + if (subdevice >= pstr->substream_count) { + err = -ENXIO; + goto _error; + } + for (substream = pstr->substream; substream; + substream = substream->next) if (substream->number == (int)subdevice) break; - if (substream == NULL) - return -ENXIO; - return snd_pcm_info_user(substream, info); + if (substream == NULL) { + err = -ENXIO; + goto _error; + } + err = snd_pcm_info_user(substream, info); + _error: + up(®ister_mutex); + return err; } case SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE: { @@ -865,8 +890,7 @@ void snd_pcm_release_substream(struct snd_pcm_substream *substream) static int snd_pcm_dev_register(struct snd_device *device) { - int idx, cidx, err; - unsigned short minor; + int cidx, err; struct snd_pcm_substream *substream; struct list_head *list; char str[16]; @@ -874,12 +898,11 @@ static int snd_pcm_dev_register(struct snd_device *device) snd_assert(pcm != NULL && device != NULL, return -ENXIO); down(®ister_mutex); - idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device; - if (snd_pcm_devices[idx]) { + if (snd_pcm_search(pcm->card, pcm->device)) { up(®ister_mutex); return -EBUSY; } - snd_pcm_devices[idx] = pcm; + list_add_tail(&pcm->list, &snd_pcm_devices); for (cidx = 0; cidx < 2; cidx++) { int devtype = -1; if (pcm->streams[cidx].substream == NULL) @@ -887,20 +910,19 @@ static int snd_pcm_dev_register(struct snd_device *device) switch (cidx) { case SNDRV_PCM_STREAM_PLAYBACK: sprintf(str, "pcmC%iD%ip", pcm->card->number, pcm->device); - minor = SNDRV_MINOR_PCM_PLAYBACK + idx; devtype = SNDRV_DEVICE_TYPE_PCM_PLAYBACK; break; case SNDRV_PCM_STREAM_CAPTURE: sprintf(str, "pcmC%iD%ic", pcm->card->number, pcm->device); - minor = SNDRV_MINOR_PCM_CAPTURE + idx; devtype = SNDRV_DEVICE_TYPE_PCM_CAPTURE; break; } if ((err = snd_register_device(devtype, pcm->card, pcm->device, - &snd_pcm_f_ops[cidx], str)) < 0) + &snd_pcm_f_ops[cidx], + pcm, str)) < 0) { - snd_pcm_devices[idx] = NULL; + list_del(&pcm->list); up(®ister_mutex); return err; } @@ -921,11 +943,10 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) struct snd_pcm *pcm = device->device_data; struct list_head *list; struct snd_pcm_substream *substream; - int idx, cidx; + int cidx; down(®ister_mutex); - idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device; - snd_pcm_devices[idx] = NULL; + list_del_init(&pcm->list); for (cidx = 0; cidx < 2; cidx++) for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) if (substream->runtime) @@ -941,15 +962,14 @@ static int snd_pcm_dev_disconnect(struct snd_device *device) static int snd_pcm_dev_unregister(struct snd_device *device) { - int idx, cidx, devtype; + int cidx, devtype; struct snd_pcm_substream *substream; struct list_head *list; struct snd_pcm *pcm = device->device_data; snd_assert(pcm != NULL, return -ENXIO); down(®ister_mutex); - idx = (pcm->card->number * SNDRV_PCM_DEVICES) + pcm->device; - snd_pcm_devices[idx] = NULL; + list_del(&pcm->list); for (cidx = 0; cidx < 2; cidx++) { devtype = -1; switch (cidx) { @@ -975,24 +995,19 @@ static int snd_pcm_dev_unregister(struct snd_device *device) int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) { - int idx; + struct list_head *p; snd_assert(notify != NULL && notify->n_register != NULL && notify->n_unregister != NULL, return -EINVAL); down(®ister_mutex); if (nfree) { list_del(¬ify->list); - for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) { - if (snd_pcm_devices[idx] == NULL) - continue; - notify->n_unregister(snd_pcm_devices[idx]); - } + list_for_each(p, &snd_pcm_devices) + notify->n_unregister(list_entry(p, + struct snd_pcm, list)); } else { list_add_tail(¬ify->list, &snd_pcm_notify_list); - for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) { - if (snd_pcm_devices[idx] == NULL) - continue; - notify->n_register(snd_pcm_devices[idx]); - } + list_for_each(p, &snd_pcm_devices) + notify->n_register(list_entry(p, struct snd_pcm, list)); } up(®ister_mutex); return 0; @@ -1005,16 +1020,14 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) static void snd_pcm_proc_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { - int idx; + struct list_head *p; struct snd_pcm *pcm; down(®ister_mutex); - for (idx = 0; idx < SNDRV_CARDS * SNDRV_PCM_DEVICES; idx++) { - pcm = snd_pcm_devices[idx]; - if (pcm == NULL) - continue; - snd_iprintf(buffer, "%02i-%02i: %s : %s", idx / SNDRV_PCM_DEVICES, - idx % SNDRV_PCM_DEVICES, pcm->id, pcm->name); + list_for_each(p, &snd_pcm_devices) { + pcm = list_entry(p, struct snd_pcm, list); + snd_iprintf(buffer, "%02i-%02i: %s : %s", + pcm->card->number, pcm->device, pcm->id, pcm->name); if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) snd_iprintf(buffer, " : playback %i", pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream_count); @@ -1063,7 +1076,6 @@ static void __exit alsa_pcm_exit(void) module_init(alsa_pcm_init) module_exit(alsa_pcm_exit) -EXPORT_SYMBOL(snd_pcm_devices); EXPORT_SYMBOL(snd_pcm_new); EXPORT_SYMBOL(snd_pcm_new_stream); EXPORT_SYMBOL(snd_pcm_notify); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index bb40c01..9010306 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -62,6 +62,7 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, struct snd_pcm_hw_params_old __user * _oparams); static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, struct snd_pcm_hw_params_old __user * _oparams); +static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream); /* * @@ -1554,7 +1555,8 @@ static struct file *snd_pcm_file_fd(int fd) { struct file *file; struct inode *inode; - unsigned short minor; + unsigned int minor; + file = fget(fd); if (!file) return NULL; @@ -1565,8 +1567,8 @@ static struct file *snd_pcm_file_fd(int fd) return NULL; } minor = iminor(inode); - if (minor >= 256 || - minor % SNDRV_MINOR_DEVICES < SNDRV_MINOR_PCM_PLAYBACK) { + if (!snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_PLAYBACK) && + !snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_CAPTURE)) { fput(file); return NULL; } @@ -2071,18 +2073,30 @@ static int snd_pcm_open_file(struct file *file, return 0; } -static int snd_pcm_open(struct inode *inode, struct file *file) +static int snd_pcm_playback_open(struct inode *inode, struct file *file) +{ + struct snd_pcm *pcm; + + pcm = snd_lookup_minor_data(iminor(inode), + SNDRV_DEVICE_TYPE_PCM_PLAYBACK); + return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); +} + +static int snd_pcm_capture_open(struct inode *inode, struct file *file) { - int cardnum = SNDRV_MINOR_CARD(iminor(inode)); - int device = SNDRV_MINOR_DEVICE(iminor(inode)); - int err; struct snd_pcm *pcm; + + pcm = snd_lookup_minor_data(iminor(inode), + SNDRV_DEVICE_TYPE_PCM_CAPTURE); + return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); +} + +static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) +{ + int err; struct snd_pcm_file *pcm_file; wait_queue_t wait; - if (device < SNDRV_MINOR_PCM_PLAYBACK || device >= SNDRV_MINOR_DEVICES) - return -ENXIO; - pcm = snd_pcm_devices[(cardnum * SNDRV_PCM_DEVICES) + (device % SNDRV_MINOR_PCMS)]; if (pcm == NULL) { err = -ENODEV; goto __error1; @@ -2098,7 +2112,7 @@ static int snd_pcm_open(struct inode *inode, struct file *file) add_wait_queue(&pcm->open_wait, &wait); down(&pcm->open_mutex); while (1) { - err = snd_pcm_open_file(file, pcm, device >= SNDRV_MINOR_PCM_CAPTURE ? SNDRV_PCM_STREAM_CAPTURE : SNDRV_PCM_STREAM_PLAYBACK, &pcm_file); + err = snd_pcm_open_file(file, pcm, stream, &pcm_file); if (err >= 0) break; if (err == -EAGAIN) { @@ -3375,7 +3389,7 @@ struct file_operations snd_pcm_f_ops[2] = { .owner = THIS_MODULE, .write = snd_pcm_write, .writev = snd_pcm_writev, - .open = snd_pcm_open, + .open = snd_pcm_playback_open, .release = snd_pcm_release, .poll = snd_pcm_playback_poll, .unlocked_ioctl = snd_pcm_playback_ioctl, @@ -3387,7 +3401,7 @@ struct file_operations snd_pcm_f_ops[2] = { .owner = THIS_MODULE, .read = snd_pcm_read, .readv = snd_pcm_readv, - .open = snd_pcm_open, + .open = snd_pcm_capture_open, .release = snd_pcm_release, .poll = snd_pcm_capture_poll, .unlocked_ioctl = snd_pcm_capture_ioctl, diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 7ac77e5..e6ee0d8 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -56,10 +56,22 @@ static int snd_rawmidi_dev_register(struct snd_device *device); static int snd_rawmidi_dev_disconnect(struct snd_device *device); static int snd_rawmidi_dev_unregister(struct snd_device *device); -static struct snd_rawmidi *snd_rawmidi_devices[SNDRV_CARDS * SNDRV_RAWMIDI_DEVICES]; - +static LIST_HEAD(snd_rawmidi_devices); static DECLARE_MUTEX(register_mutex); +static struct snd_rawmidi *snd_rawmidi_search(struct snd_card *card, int device) +{ + struct list_head *p; + struct snd_rawmidi *rawmidi; + + list_for_each(p, &snd_rawmidi_devices) { + rawmidi = list_entry(p, struct snd_rawmidi, list); + if (rawmidi->card == card && rawmidi->device == device) + return rawmidi; + } + return NULL; +} + static inline unsigned short snd_rawmidi_file_flags(struct file *file) { switch (file->f_mode & (FMODE_READ | FMODE_WRITE)) { @@ -214,7 +226,7 @@ int snd_rawmidi_drain_input(struct snd_rawmidi_substream *substream) return 0; } -int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, +int snd_rawmidi_kernel_open(struct snd_card *card, int device, int subdevice, int mode, struct snd_rawmidi_file * rfile) { struct snd_rawmidi *rmidi; @@ -225,7 +237,9 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, if (rfile) rfile->input = rfile->output = NULL; - rmidi = snd_rawmidi_devices[(cardnum * SNDRV_RAWMIDI_DEVICES) + device]; + down(®ister_mutex); + rmidi = snd_rawmidi_search(card, device); + up(®ister_mutex); if (rmidi == NULL) { err = -ENODEV; goto __error1; @@ -368,9 +382,8 @@ int snd_rawmidi_kernel_open(int cardnum, int device, int subdevice, static int snd_rawmidi_open(struct inode *inode, struct file *file) { int maj = imajor(inode); - int cardnum; struct snd_card *card; - int device, subdevice; + int subdevice; unsigned short fflags; int err; struct snd_rawmidi *rmidi; @@ -380,27 +393,18 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) struct snd_ctl_file *kctl; if (maj == snd_major) { - cardnum = SNDRV_MINOR_CARD(iminor(inode)); - cardnum %= SNDRV_CARDS; - device = SNDRV_MINOR_DEVICE(iminor(inode)) - SNDRV_MINOR_RAWMIDI; - device %= SNDRV_MINOR_RAWMIDIS; + rmidi = snd_lookup_minor_data(iminor(inode), + SNDRV_DEVICE_TYPE_RAWMIDI); #ifdef CONFIG_SND_OSSEMUL } else if (maj == SOUND_MAJOR) { - cardnum = SNDRV_MINOR_OSS_CARD(iminor(inode)); - cardnum %= SNDRV_CARDS; - device = SNDRV_MINOR_OSS_DEVICE(iminor(inode)) == SNDRV_MINOR_OSS_MIDI ? - midi_map[cardnum] : amidi_map[cardnum]; + rmidi = snd_lookup_oss_minor_data(iminor(inode), + SNDRV_OSS_DEVICE_TYPE_MIDI); #endif } else return -ENXIO; - rmidi = snd_rawmidi_devices[(cardnum * SNDRV_RAWMIDI_DEVICES) + device]; if (rmidi == NULL) return -ENODEV; -#ifdef CONFIG_SND_OSSEMUL - if (maj == SOUND_MAJOR && !rmidi->ossreg) - return -ENXIO; -#endif if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK)) return -EINVAL; /* invalid combination */ card = rmidi->card; @@ -430,7 +434,8 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file) } } up_read(&card->controls_rwsem); - err = snd_rawmidi_kernel_open(cardnum, device, subdevice, fflags, rawmidi_file); + err = snd_rawmidi_kernel_open(rmidi->card, rmidi->device, + subdevice, fflags, rawmidi_file); if (err >= 0) break; if (err == -EAGAIN) { @@ -570,9 +575,10 @@ int snd_rawmidi_info_select(struct snd_card *card, struct snd_rawmidi_info *info struct snd_rawmidi_str *pstr; struct snd_rawmidi_substream *substream; struct list_head *list; - if (info->device >= SNDRV_RAWMIDI_DEVICES) - return -ENXIO; - rmidi = snd_rawmidi_devices[card->number * SNDRV_RAWMIDI_DEVICES + info->device]; + + down(®ister_mutex); + rmidi = snd_rawmidi_search(card, info->device); + up(®ister_mutex); if (!rmidi) return -ENXIO; if (info->stream < 0 || info->stream > 1) @@ -803,9 +809,7 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, unsigned long arg) { void __user *argp = (void __user *)arg; - unsigned int tmp; - tmp = card->number * SNDRV_RAWMIDI_DEVICES; switch (cmd) { case SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE: { @@ -813,14 +817,16 @@ static int snd_rawmidi_control_ioctl(struct snd_card *card, if (get_user(device, (int __user *)argp)) return -EFAULT; + down(®ister_mutex); device = device < 0 ? 0 : device + 1; while (device < SNDRV_RAWMIDI_DEVICES) { - if (snd_rawmidi_devices[tmp + device]) + if (snd_rawmidi_search(card, device)) break; device++; } if (device == SNDRV_RAWMIDI_DEVICES) device = -1; + up(®ister_mutex); if (put_user(device, (int __user *)argp)) return -EFAULT; return 0; @@ -1493,7 +1499,7 @@ static void snd_rawmidi_dev_seq_free(struct snd_seq_device *device) static int snd_rawmidi_dev_register(struct snd_device *device) { - int idx, err; + int err; struct snd_info_entry *entry; char name[16]; struct snd_rawmidi *rmidi = device->device_data; @@ -1501,25 +1507,24 @@ static int snd_rawmidi_dev_register(struct snd_device *device) if (rmidi->device >= SNDRV_RAWMIDI_DEVICES) return -ENOMEM; down(®ister_mutex); - idx = (rmidi->card->number * SNDRV_RAWMIDI_DEVICES) + rmidi->device; - if (snd_rawmidi_devices[idx] != NULL) { + if (snd_rawmidi_search(rmidi->card, rmidi->device)) { up(®ister_mutex); return -EBUSY; } - snd_rawmidi_devices[idx] = rmidi; + list_add_tail(&rmidi->list, &snd_rawmidi_devices); sprintf(name, "midiC%iD%i", rmidi->card->number, rmidi->device); if ((err = snd_register_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device, - &snd_rawmidi_f_ops, name)) < 0) { + &snd_rawmidi_f_ops, rmidi, name)) < 0) { snd_printk(KERN_ERR "unable to register rawmidi device %i:%i\n", rmidi->card->number, rmidi->device); - snd_rawmidi_devices[idx] = NULL; + list_del(&rmidi->list); up(®ister_mutex); return err; } if (rmidi->ops && rmidi->ops->dev_register && (err = rmidi->ops->dev_register(rmidi)) < 0) { snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); - snd_rawmidi_devices[idx] = NULL; + list_del(&rmidi->list); up(®ister_mutex); return err; } @@ -1527,8 +1532,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) rmidi->ossreg = 0; if ((int)rmidi->device == midi_map[rmidi->card->number]) { if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, - rmidi->card, 0, - &snd_rawmidi_f_ops, name) < 0) { + rmidi->card, 0, &snd_rawmidi_f_ops, + rmidi, name) < 0) { snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 0); } else { rmidi->ossreg++; @@ -1539,8 +1544,8 @@ static int snd_rawmidi_dev_register(struct snd_device *device) } if ((int)rmidi->device == amidi_map[rmidi->card->number]) { if (snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIDI, - rmidi->card, 1, - &snd_rawmidi_f_ops, name) < 0) { + rmidi->card, 1, &snd_rawmidi_f_ops, + rmidi, name) < 0) { snd_printk(KERN_ERR "unable to register OSS rawmidi device %i:%i\n", rmidi->card->number, 1); } else { rmidi->ossreg++; @@ -1576,24 +1581,20 @@ static int snd_rawmidi_dev_register(struct snd_device *device) static int snd_rawmidi_dev_disconnect(struct snd_device *device) { struct snd_rawmidi *rmidi = device->device_data; - int idx; down(®ister_mutex); - idx = (rmidi->card->number * SNDRV_RAWMIDI_DEVICES) + rmidi->device; - snd_rawmidi_devices[idx] = NULL; + list_del_init(&rmidi->list); up(®ister_mutex); return 0; } static int snd_rawmidi_dev_unregister(struct snd_device *device) { - int idx; struct snd_rawmidi *rmidi = device->device_data; snd_assert(rmidi != NULL, return -ENXIO); down(®ister_mutex); - idx = (rmidi->card->number * SNDRV_RAWMIDI_DEVICES) + rmidi->device; - snd_rawmidi_devices[idx] = NULL; + list_del(&rmidi->list); if (rmidi->proc_entry) { snd_info_unregister(rmidi->proc_entry); rmidi->proc_entry = NULL; diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 61c0a41..4b51ab5 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c @@ -225,7 +225,7 @@ register_device(void) down(®ister_mutex); if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0, - &seq_oss_f_ops, + &seq_oss_f_ops, NULL, SNDRV_SEQ_OSS_DEVNAME)) < 0) { snd_printk(KERN_ERR "can't register device seq\n"); up(®ister_mutex); @@ -233,7 +233,7 @@ register_device(void) } if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC, NULL, 0, - &seq_oss_f_ops, + &seq_oss_f_ops, NULL, SNDRV_SEQ_OSS_DEVNAME)) < 0) { snd_printk(KERN_ERR "can't register device music\n"); snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0); diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 087fdf3..c8bd37e 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2531,7 +2531,7 @@ int __init snd_sequencer_device_init(void) return -ERESTARTSYS; if ((err = snd_register_device(SNDRV_DEVICE_TYPE_SEQUENCER, NULL, 0, - &snd_seq_f_ops, "seq")) < 0) { + &snd_seq_f_ops, NULL, "seq")) < 0) { up(®ister_mutex); return err; } diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index f88d2e3..0a65eb2 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -183,7 +183,10 @@ static int midisynth_subscribe(void *private_data, struct snd_seq_port_subscribe struct snd_rawmidi_params params; /* open midi port */ - if ((err = snd_rawmidi_kernel_open(msynth->card->number, msynth->device, msynth->subdevice, SNDRV_RAWMIDI_LFLG_INPUT, &msynth->input_rfile)) < 0) { + if ((err = snd_rawmidi_kernel_open(msynth->card, msynth->device, + msynth->subdevice, + SNDRV_RAWMIDI_LFLG_INPUT, + &msynth->input_rfile)) < 0) { snd_printd("midi input open failed!!!\n"); return err; } @@ -221,7 +224,10 @@ static int midisynth_use(void *private_data, struct snd_seq_port_subscribe *info struct snd_rawmidi_params params; /* open midi port */ - if ((err = snd_rawmidi_kernel_open(msynth->card->number, msynth->device, msynth->subdevice, SNDRV_RAWMIDI_LFLG_OUTPUT, &msynth->output_rfile)) < 0) { + if ((err = snd_rawmidi_kernel_open(msynth->card, msynth->device, + msynth->subdevice, + SNDRV_RAWMIDI_LFLG_OUTPUT, + &msynth->output_rfile)) < 0) { snd_printd("midi output open failed!!!\n"); return err; } diff --git a/sound/core/sound.c b/sound/core/sound.c index a509f49..1e5eca5 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -60,7 +60,6 @@ MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR); int snd_ecards_limit; static struct snd_minor *snd_minors[SNDRV_OS_MINORS]; - static DECLARE_MUTEX(sound_mutex); extern struct class *sound_class; @@ -107,6 +106,31 @@ static void snd_request_other(int minor) #endif /* request_module support */ +/** + * snd_lookup_minor_data - get user data of a registered device + * @minor: the minor number + * @type: device type (SNDRV_DEVICE_TYPE_XXX) + * + * Checks that a minor device with the specified type is registered, and returns + * its user data pointer. + */ +void *snd_lookup_minor_data(unsigned int minor, int type) +{ + struct snd_minor *mreg; + void *private_data; + + if (minor > ARRAY_SIZE(snd_minors)) + return NULL; + down(&sound_mutex); + mreg = snd_minors[minor]; + if (mreg && mreg->type == type) + private_data = mreg->private_data; + else + private_data = NULL; + up(&sound_mutex); + return private_data; +} + static int snd_open(struct inode *inode, struct file *file) { int minor = iminor(inode); @@ -183,6 +207,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * @card: the card instance * @dev: the device index * @f_ops: the file operations + * @private_data: user pointer for f_ops->open() * @name: the device file name * * Registers an ALSA device file for the given card. @@ -191,7 +216,8 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) * Retrurns zero if successful, or a negative error code on failure. */ int snd_register_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name) + struct file_operations *f_ops, void *private_data, + const char *name) { int minor = snd_kernel_minor(type, card, dev); struct snd_minor *preg; @@ -207,6 +233,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, preg->card = card ? card->number : -1; preg->device = dev; preg->f_ops = f_ops; + preg->private_data = private_data; strcpy(preg->name, name); down(&sound_mutex); if (snd_minors[minor]) { @@ -238,13 +265,18 @@ int snd_register_device(int type, struct snd_card *card, int dev, */ int snd_unregister_device(int type, struct snd_card *card, int dev) { - int minor = snd_kernel_minor(type, card, dev); + int cardnum, minor; struct snd_minor *mptr; - if (minor < 0) - return minor; + cardnum = card ? card->number : -1; down(&sound_mutex); - if ((mptr = snd_minors[minor]) == NULL) { + for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) + if ((mptr = snd_minors[minor]) != NULL && + mptr->type == type && + mptr->card == cardnum && + mptr->device == dev) + break; + if (minor == ARRAY_SIZE(snd_minors)) { up(&sound_mutex); return -EINVAL; } @@ -392,9 +424,11 @@ EXPORT_SYMBOL(snd_request_card); #endif EXPORT_SYMBOL(snd_register_device); EXPORT_SYMBOL(snd_unregister_device); +EXPORT_SYMBOL(snd_lookup_minor_data); #if defined(CONFIG_SND_OSSEMUL) EXPORT_SYMBOL(snd_register_oss_device); EXPORT_SYMBOL(snd_unregister_oss_device); +EXPORT_SYMBOL(snd_lookup_oss_minor_data); #endif /* memory.c */ EXPORT_SYMBOL(copy_to_user_fromio); diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index afbfd8d..b9e89ca 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -38,9 +38,25 @@ #define SNDRV_OSS_MINORS 128 static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; - static DECLARE_MUTEX(sound_oss_mutex); +void *snd_lookup_oss_minor_data(unsigned int minor, int type) +{ + struct snd_minor *mreg; + void *private_data; + + if (minor > ARRAY_SIZE(snd_oss_minors)) + return NULL; + down(&sound_oss_mutex); + mreg = snd_oss_minors[minor]; + if (mreg && mreg->type == type) + private_data = mreg->private_data; + else + private_data = NULL; + up(&sound_oss_mutex); + return private_data; +} + static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) { int minor; @@ -78,7 +94,8 @@ static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) } int snd_register_oss_device(int type, struct snd_card *card, int dev, - struct file_operations *f_ops, const char *name) + struct file_operations *f_ops, void *private_data, + const char *name) { int minor = snd_oss_kernel_minor(type, card, dev); int minor_unit; @@ -97,6 +114,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, preg->card = card ? card->number : -1; preg->device = dev; preg->f_ops = f_ops; + preg->private_data = private_data; down(&sound_oss_mutex); snd_oss_minors[minor] = preg; minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); @@ -121,6 +139,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, carddev); if (register2 != track2) goto __end; + snd_oss_minors[track2] = preg; } up(&sound_oss_mutex); return 0; @@ -163,8 +182,10 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1); break; } - if (track2 >= 0) + if (track2 >= 0) { unregister_sound_special(track2); + snd_oss_minors[track2] = NULL; + } snd_oss_minors[minor] = NULL; up(&sound_oss_mutex); kfree(mptr); diff --git a/sound/core/timer.c b/sound/core/timer.c index a7bcb04..c62dbac 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1952,8 +1952,8 @@ static int __init alsa_timer_init(void) if ((err = snd_timer_register_system()) < 0) snd_printk(KERN_ERR "unable to register system timer (%i)\n", err); - if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, - NULL, 0, &snd_timer_f_ops, "timer")) < 0) + if ((err = snd_register_device(SNDRV_DEVICE_TYPE_TIMER, NULL, 0, + &snd_timer_f_ops, NULL, "timer")) < 0) snd_printk(KERN_ERR "unable to register timer device (%i)\n", err); return 0; -- cgit v1.1 From 332682b1cd540dd7abbbbfc1905af8139e76e1b7 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 14:07:47 +0100 Subject: [ALSA] dynamic minors (4/6): dynamic minor number allocation Modules: ALSA Core,ALSA Minor Numbers Add an option to allocate device file minor numbers dynamically. Signed-off-by: Clemens Ladisch --- include/sound/minors.h | 29 ++++++++++++++++++---- sound/core/Kconfig | 11 +++++++++ sound/core/sound.c | 65 +++++++++++++++++++++++++++++++++++--------------- 3 files changed, 82 insertions(+), 23 deletions(-) diff --git a/include/sound/minors.h b/include/sound/minors.h index a17b5c9..46bcd20 100644 --- a/include/sound/minors.h +++ b/include/sound/minors.h @@ -26,18 +26,20 @@ #define SNDRV_MINOR_DEVICE(minor) ((minor) & 0x001f) #define SNDRV_MINOR(card, dev) (((card) << 5) | (dev)) -#define SNDRV_MINOR_CONTROL 0 /* 0 - 0 */ +/* these minors can still be used for autoloading devices (/dev/aload*) */ +#define SNDRV_MINOR_CONTROL 0 /* 0 */ #define SNDRV_MINOR_GLOBAL 1 /* 1 */ #define SNDRV_MINOR_SEQUENCER (SNDRV_MINOR_GLOBAL + 0 * 32) #define SNDRV_MINOR_TIMER (SNDRV_MINOR_GLOBAL + 1 * 32) + +#ifndef CONFIG_SND_DYNAMIC_MINORS + /* 2 - 3 (reserved) */ #define SNDRV_MINOR_HWDEP 4 /* 4 - 7 */ -#define SNDRV_MINOR_HWDEPS 4 #define SNDRV_MINOR_RAWMIDI 8 /* 8 - 15 */ -#define SNDRV_MINOR_RAWMIDIS 8 #define SNDRV_MINOR_PCM_PLAYBACK 16 /* 16 - 23 */ #define SNDRV_MINOR_PCM_CAPTURE 24 /* 24 - 31 */ -#define SNDRV_MINOR_PCMS 8 +/* same as first respective minor number to make minor allocation easier */ #define SNDRV_DEVICE_TYPE_CONTROL SNDRV_MINOR_CONTROL #define SNDRV_DEVICE_TYPE_HWDEP SNDRV_MINOR_HWDEP #define SNDRV_DEVICE_TYPE_RAWMIDI SNDRV_MINOR_RAWMIDI @@ -46,6 +48,25 @@ #define SNDRV_DEVICE_TYPE_SEQUENCER SNDRV_MINOR_SEQUENCER #define SNDRV_DEVICE_TYPE_TIMER SNDRV_MINOR_TIMER +#else /* CONFIG_SND_DYNAMIC_MINORS */ + +enum { + SNDRV_DEVICE_TYPE_CONTROL, + SNDRV_DEVICE_TYPE_SEQUENCER, + SNDRV_DEVICE_TYPE_TIMER, + SNDRV_DEVICE_TYPE_HWDEP, + SNDRV_DEVICE_TYPE_RAWMIDI, + SNDRV_DEVICE_TYPE_PCM_PLAYBACK, + SNDRV_DEVICE_TYPE_PCM_CAPTURE, +}; + +#endif /* CONFIG_SND_DYNAMIC_MINORS */ + +#define SNDRV_MINOR_HWDEPS 4 +#define SNDRV_MINOR_RAWMIDIS 8 +#define SNDRV_MINOR_PCMS 8 + + #ifdef CONFIG_SND_OSSEMUL #define SNDRV_MINOR_OSS_DEVICES 16 diff --git a/sound/core/Kconfig b/sound/core/Kconfig index b46efff..83cbe20 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -111,6 +111,17 @@ config SND_SEQ_RTCTIMER_DEFAULT If in doubt, say Y. +config SND_DYNAMIC_MINORS + bool "Dynamic device file minor numbers (EXPERIMENTAL)" + depends on SND && EXPERIMENTAL + help + If you say Y here, the minor numbers of ALSA device files in + /dev/snd/ are allocated dynamically. This allows you to have + more than 8 sound cards, but requires a dynamic device file + system like udev. + + If you are unsure about this, say N here. + config SND_VERBOSE_PRINTK bool "Verbose printk" depends on SND diff --git a/sound/core/sound.c b/sound/core/sound.c index 1e5eca5..5e22283 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -133,29 +133,34 @@ void *snd_lookup_minor_data(unsigned int minor, int type) static int snd_open(struct inode *inode, struct file *file) { - int minor = iminor(inode); - int card = SNDRV_MINOR_CARD(minor); - int dev = SNDRV_MINOR_DEVICE(minor); + unsigned int minor = iminor(inode); struct snd_minor *mptr = NULL; struct file_operations *old_fops; int err = 0; - if (dev != SNDRV_MINOR_GLOBAL) { - if (snd_cards[card] == NULL) { + if (minor > ARRAY_SIZE(snd_minors)) + return -ENODEV; + mptr = snd_minors[minor]; + if (mptr == NULL) { #ifdef CONFIG_KMOD - snd_request_card(card); + int dev = SNDRV_MINOR_DEVICE(minor); + if (dev == SNDRV_MINOR_CONTROL) { + /* /dev/aloadC? */ + int card = SNDRV_MINOR_CARD(minor); if (snd_cards[card] == NULL) -#endif - return -ENODEV; - } - } else { -#ifdef CONFIG_KMOD - if ((mptr = snd_minors[minor]) == NULL) + snd_request_card(card); + } else if (dev == SNDRV_MINOR_GLOBAL) { + /* /dev/aloadSEQ */ snd_request_other(minor); + } +#ifndef CONFIG_SND_DYNAMIC_MINORS + /* /dev/snd/{controlC?,seq} */ + mptr = snd_minors[minor]; + if (mptr == NULL) +#endif #endif + return -ENODEV; } - if (mptr == NULL && (mptr = snd_minors[minor]) == NULL) - return -ENODEV; old_fops = file->f_op; file->f_op = fops_get(mptr->f_ops); if (file->f_op->open) @@ -174,6 +179,22 @@ static struct file_operations snd_fops = .open = snd_open }; +#ifdef CONFIG_SND_DYNAMIC_MINORS +static int snd_find_free_minor(void) +{ + int minor; + + for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) { + /* skip minors still used statically for autoloading devices */ + if (SNDRV_MINOR_DEVICE(minor) == SNDRV_MINOR_CONTROL || + minor == SNDRV_MINOR_SEQUENCER) + continue; + if (!snd_minors[minor]) + return minor; + } + return -EBUSY; +} +#else static int snd_kernel_minor(int type, struct snd_card *card, int dev) { int minor; @@ -200,6 +221,7 @@ static int snd_kernel_minor(int type, struct snd_card *card, int dev) snd_assert(minor >= 0 && minor < SNDRV_OS_MINORS, return -EINVAL); return minor; } +#endif /** * snd_register_device - Register the ALSA device file for the card @@ -219,12 +241,10 @@ int snd_register_device(int type, struct snd_card *card, int dev, struct file_operations *f_ops, void *private_data, const char *name) { - int minor = snd_kernel_minor(type, card, dev); + int minor; struct snd_minor *preg; struct device *device = NULL; - if (minor < 0) - return minor; snd_assert(name, return -EINVAL); preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); if (preg == NULL) @@ -236,10 +256,17 @@ int snd_register_device(int type, struct snd_card *card, int dev, preg->private_data = private_data; strcpy(preg->name, name); down(&sound_mutex); - if (snd_minors[minor]) { +#ifdef CONFIG_SND_DYNAMIC_MINORS + minor = snd_find_free_minor(); +#else + minor = snd_kernel_minor(type, card, dev); + if (minor >= 0 && snd_minors[minor]) + minor = -EBUSY; +#endif + if (minor < 0) { up(&sound_mutex); kfree(preg); - return -EBUSY; + return minor; } snd_minors[minor] = preg; if (type != SNDRV_DEVICE_TYPE_CONTROL || preg->card >= cards_limit) -- cgit v1.1 From 204bdb1b50013c7aa3922d8b66df943123087bd8 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 14:08:28 +0100 Subject: [ALSA] dynamic minors (5/6): reduce maximum number of MIDI devices per card Modules: ALSA sequencer,Generic drivers To allow increasing the maximum number of sound cards, we have to limit the number of sequencer clients per card because client numbers are still allocated statically. Reducing the number of clients to four limits the number of sequencer MIDI ports to 1024 per card. Signed-off-by: Clemens Ladisch --- sound/core/seq/seq_clientmgr.c | 6 +++--- sound/drivers/virmidi.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index c8bd37e..95bd5ae 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -157,7 +157,7 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid) } } } else if (clientid >= 64 && clientid < 128) { - int card = (clientid - 64) / 8; + int card = (clientid - 64) / 4; if (card < snd_ecards_limit) { if (! card_requested[card]) { card_requested[card] = 1; @@ -2208,12 +2208,12 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, if (callback == NULL) return -EINVAL; - if (card && client_index > 7) + if (card && client_index > 3) return -EINVAL; if (card == NULL && client_index > 63) return -EINVAL; if (card) - client_index += 64 + (card->number << 3); + client_index += 64 + (card->number << 2); if (down_interruptible(®ister_mutex)) return -ERESTARTSYS; diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index a7b9241..9f36a64 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -61,7 +61,7 @@ MODULE_DESCRIPTION("Dummy soundcard for virtual rawmidi devices"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{ALSA,Virtual rawmidi device}}"); -#define MAX_MIDI_DEVICES 8 +#define MAX_MIDI_DEVICES 4 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ @@ -75,7 +75,7 @@ MODULE_PARM_DESC(id, "ID string for virmidi soundcard."); module_param_array(enable, bool, NULL, 0444); MODULE_PARM_DESC(enable, "Enable this soundcard."); module_param_array(midi_devs, int, NULL, 0444); -MODULE_PARM_DESC(midi_devs, "MIDI devices # (1-8)"); +MODULE_PARM_DESC(midi_devs, "MIDI devices # (1-4)"); struct snd_card_virmidi { struct snd_card *card; -- cgit v1.1 From d001544ded23ddb1116f945ccc2d89a7f98ab7e8 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Sun, 20 Nov 2005 14:09:05 +0100 Subject: [ALSA] dynamic minors (6/6): increase maximum number of sound cards Modules: ALSA Core,Memalloc module,ALSA sequencer With dynamic minor numbers, we can increase the number of sound cards. This requires that the sequencer client numbers of some kernel drivers are allocated dynamically, too. Signed-off-by: Clemens Ladisch --- include/sound/driver.h | 7 ++++++- sound/core/init.c | 18 +++++++++++------- sound/core/memalloc.c | 4 ---- sound/core/seq/seq_clientmgr.c | 31 +++++++++++++++++++++++++------ sound/core/sound.c | 6 +++--- sound/core/sound_oss.c | 4 ++++ 6 files changed, 49 insertions(+), 21 deletions(-) diff --git a/include/sound/driver.h b/include/sound/driver.h index 3f0416a..89c6a73 100644 --- a/include/sound/driver.h +++ b/include/sound/driver.h @@ -28,7 +28,12 @@ #include -#define SNDRV_CARDS 8 /* number of supported soundcards - don't change - minor numbers */ +/* number of supported soundcards */ +#ifdef CONFIG_SND_DYNAMIC_MINORS +#define SNDRV_CARDS 32 +#else +#define SNDRV_CARDS 8 /* don't change - minor numbers */ +#endif #ifndef CONFIG_SND_MAJOR /* standard configuration */ #define CONFIG_SND_MAJOR 116 diff --git a/sound/core/init.c b/sound/core/init.c index 728bb2c..58e17d3 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -338,7 +338,7 @@ int snd_card_free_in_thread(struct snd_card *card) static void choose_default_id(struct snd_card *card) { - int i, len, idx_flag = 0, loops = 8; + int i, len, idx_flag = 0, loops = SNDRV_CARDS; char *id, *spos; id = spos = card->shortname; @@ -380,9 +380,12 @@ static void choose_default_id(struct snd_card *card) __change: len = strlen(id); - if (idx_flag) - id[len-1]++; - else if ((size_t)len <= sizeof(card->id) - 3) { + if (idx_flag) { + if (id[len-1] != '9') + id[len-1]++; + else + id[len-1] = 'A'; + } else if ((size_t)len <= sizeof(card->id) - 3) { strcat(id, "_1"); idx_flag++; } else { @@ -461,12 +464,12 @@ static void snd_card_info_read(struct snd_info_entry *entry, read_lock(&snd_card_rwlock); if ((card = snd_cards[idx]) != NULL) { count++; - snd_iprintf(buffer, "%i [%-15s]: %s - %s\n", + snd_iprintf(buffer, "%2i [%-15s]: %s - %s\n", idx, card->id, card->driver, card->shortname); - snd_iprintf(buffer, " %s\n", + snd_iprintf(buffer, " %s\n", card->longname); } read_unlock(&snd_card_rwlock); @@ -508,7 +511,8 @@ static void snd_card_module_info_read(struct snd_info_entry *entry, for (idx = 0; idx < SNDRV_CARDS; idx++) { read_lock(&snd_card_rwlock); if ((card = snd_cards[idx]) != NULL) - snd_iprintf(buffer, "%i %s\n", idx, card->module->name); + snd_iprintf(buffer, "%2i %s\n", + idx, card->module->name); read_unlock(&snd_card_rwlock); } } diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index e4b8959..19b3dcb 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -43,10 +43,6 @@ MODULE_DESCRIPTION("Memory allocator for ALSA system."); MODULE_LICENSE("GPL"); -#ifndef SNDRV_CARDS -#define SNDRV_CARDS 8 -#endif - /* */ diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 95bd5ae..2a9c6b3 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -47,6 +47,10 @@ * */ +/* range for dynamically allocated client numbers of kernel drivers */ +#define SNDRV_SEQ_DYNAMIC_CLIENT_BEGIN 16 +#define SNDRV_SEQ_DYNAMIC_CLIENT_END 48 + #define SNDRV_SEQ_LFLG_INPUT 0x0001 #define SNDRV_SEQ_LFLG_OUTPUT 0x0002 #define SNDRV_SEQ_LFLG_OPEN (SNDRV_SEQ_LFLG_INPUT|SNDRV_SEQ_LFLG_OUTPUT) @@ -203,7 +207,8 @@ int __init client_init_data(void) } -static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) +static struct snd_seq_client *seq_create_client1(int client_index, int poolsize, + int kernel_client) { unsigned long flags; int c; @@ -227,7 +232,15 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) /* find free slot in the client table */ spin_lock_irqsave(&clients_lock, flags); if (client_index < 0) { - for (c = 128; c < SNDRV_SEQ_MAX_CLIENTS; c++) { + int cmin, cmax; + if (kernel_client) { + cmin = SNDRV_SEQ_DYNAMIC_CLIENT_BEGIN; + cmax = SNDRV_SEQ_DYNAMIC_CLIENT_END; + } else { + cmin = 128; + cmax = SNDRV_SEQ_MAX_CLIENTS; + } + for (c = cmin; c < cmax; c++) { if (clienttab[c] || clienttablock[c]) continue; clienttab[client->number = c] = client; @@ -306,7 +319,7 @@ static int snd_seq_open(struct inode *inode, struct file *file) if (down_interruptible(®ister_mutex)) return -ERESTARTSYS; - client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); + client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS, 0); if (client == NULL) { up(®ister_mutex); return -ENOMEM; /* failure code */ @@ -2212,13 +2225,19 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, return -EINVAL; if (card == NULL && client_index > 63) return -EINVAL; - if (card) - client_index += 64 + (card->number << 2); if (down_interruptible(®ister_mutex)) return -ERESTARTSYS; + + if (card) { + if (card->number < 16) + client_index += 64 + (card->number << 2); + else + client_index = -1; + } + /* empty write queue as default */ - client = seq_create_client1(client_index, 0); + client = seq_create_client1(client_index, 0, 1); if (client == NULL) { up(®ister_mutex); return -EBUSY; /* failure code */ diff --git a/sound/core/sound.c b/sound/core/sound.c index 5e22283..5febd05 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -358,15 +358,15 @@ static void snd_minor_info_read(struct snd_info_entry *entry, struct snd_info_bu continue; if (mptr->card >= 0) { if (mptr->device >= 0) - snd_iprintf(buffer, "%3i: [%i-%2i]: %s\n", + snd_iprintf(buffer, "%3i: [%2i-%2i]: %s\n", minor, mptr->card, mptr->device, snd_device_type_name(mptr->type)); else - snd_iprintf(buffer, "%3i: [%i] : %s\n", + snd_iprintf(buffer, "%3i: [%2i] : %s\n", minor, mptr->card, snd_device_type_name(mptr->type)); } else - snd_iprintf(buffer, "%3i: : %s\n", minor, + snd_iprintf(buffer, "%3i: : %s\n", minor, snd_device_type_name(mptr->type)); } up(&sound_mutex); diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index b9e89ca..3ae1c0d 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -105,6 +105,8 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev, int register1 = -1, register2 = -1; struct device *carddev = NULL; + if (card && card->number >= 8) + return 0; /* ignore silently */ if (minor < 0) return minor; preg = kmalloc(sizeof(struct snd_minor), GFP_KERNEL); @@ -162,6 +164,8 @@ int snd_unregister_oss_device(int type, struct snd_card *card, int dev) int track2 = -1; struct snd_minor *mptr; + if (card && card->number >= 8) + return 0; if (minor < 0) return minor; down(&sound_oss_mutex); -- cgit v1.1 From 0ef797c5ca8a73853c827cf495caed44676cfe17 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 21 Nov 2005 07:30:20 +0100 Subject: [ALSA] adjust documentation for higher card limit Modules: Documentation Fix all places in the docs where the card number limit is mentioned. Signed-off-by: Clemens Ladisch --- Documentation/sound/alsa/ALSA-Configuration.txt | 128 ++++++++++++------------ 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 9a58ed9..c30fd30 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -105,7 +105,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Each of top level sound card module takes the following options. index - index (slot #) of sound card - - Values: 0 through 7 or negative + - Values: 0 through 31 or negative - If nonnegative, assign that index number - if negative, interpret as a bitmask of permissible indices; the first free permitted index is assigned @@ -134,7 +134,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dma2 - second DMA # for AD1816A chip (PnP setup) clockfreq - Clock frequency for AD1816A chip (default = 0, 33000Hz) - Module supports up to 8 cards, autoprobe and PnP. + This module supports multiple cards, autoprobe and PnP. Module snd-ad1848 ----------------- @@ -145,7 +145,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. irq - IRQ # for AD1848 chip dma1 - DMA # for AD1848 chip (0,1,3) - Module supports up to 8 cards. This module does not support autoprobe + This module supports multiple cards. It does not support autoprobe thus main port must be specified!!! Other ports are optional. The power-management is supported. @@ -158,7 +158,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ac97_quirk - AC'97 workaround for strange hardware See the description of intel8x0 module for details. - This module supports up to 8 cards. + This module supports multiple cards. Module snd-ali5451 ------------------ @@ -186,7 +186,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. mpu_irq - IRQ # for MPU-401 (PnP setup) fm_port - port # for OPL3 FM (PnP setup) - Module supports up to 8 cards, autoprobe and PnP. + This module supports multiple cards, autoprobe and PnP. The power-management is supported. @@ -198,7 +198,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. joystick_port - port # for legacy joystick support. 0 = disabled (default), 1 = auto-detect - Module supports up to 8 cards, autoprobe and PnP. + This module supports multiple cards, autoprobe and PnP. The power-management is supported. @@ -273,7 +273,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dma1 - 1st DMA # for AZT2320 (WSS) chip (PnP setup) dma2 - 2nd DMA # for AZT2320 (WSS) chip (PnP setup) - Module supports up to 8 cards, PnP and autoprobe. + This module supports multiple cards, PnP and autoprobe. The power-management is supported. @@ -284,7 +284,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. joystick - Enable joystick (default off) - Module supports up to 8 cards. + This module supports multiple cards. Module snd-bt87x ---------------- @@ -294,7 +294,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. digital_rate - Override the default digital rate (Hz) load_all - Load the driver even if the card model isn't known - Module supports up to 8 cards. + This module supports multiple cards. Note: The default index value of this module is -2, i.e. the first slot is excluded. @@ -304,7 +304,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for Creative Audigy LS and SB Live 24bit - Module supports up to 8 cards. + This module supports multiple cards. Module snd-cmi8330 @@ -320,7 +320,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. sbdma8 - 8bit DMA # for CMI8330 chip (SB16) sbdma16 - 16bit DMA # for CMI8330 chip (SB16) - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. The power-management is supported. @@ -335,7 +335,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. (default = 1) joystick_port - Joystick port address (0 = disable, 1 = auto-detect) - Module supports autoprobe and multiple chips (max 8). + This module supports autoprobe and multiple cards. The power-management is supported. @@ -351,7 +351,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dma1 - first DMA # for CS4231 chip dma2 - second DMA # for CS4231 chip - Module supports up to 8 cards. This module does not support autoprobe + This module supports multiple cards. This module does not support autoprobe thus main port must be specified!!! Other ports are optional. The power-management is supported. @@ -371,7 +371,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dma2 - second DMA # for Yamaha CS4232 chip (0,1,3), -1 = disable isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) - Module supports up to 8 cards. This module does not support autoprobe + This module supports multiple cards. This module does not support autoprobe thus main port must be specified!!! Other ports are optional. The power-management is supported. @@ -392,7 +392,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dma2 - second DMA # for CS4236 chip (0,1,3), -1 = disable isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) - Module supports up to 8 cards. This module does not support autoprobe + This module supports multiple cards. This module does not support autoprobe (if ISA PnP is not used) thus main port and control port must be specified!!! Other ports are optional. @@ -405,7 +405,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dual_codec - Secondary codec ID (0 = disable, default) - Module supports up to 8 cards. + This module supports multiple cards. The power-management is supported. @@ -419,7 +419,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. thinkpad - Force to enable Thinkpad's CLKRUN control. mmap_valid - Support OSS mmap mode (default = 0). - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. Usually external amp and CLKRUN controls are detected automatically from PCI sub vendor/device ids. If they don't work, give the options above explicitly. @@ -431,7 +431,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for multifunction CS5535 companion PCI device - Module supports up to 8 cards. + This module supports multiple cards. Module snd-dt019x ----------------- @@ -446,7 +446,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. mpu_irq - IRQ # for MPU-401 (PnP setup) dma8 - DMA # (PnP setup) - Module supports up to 8 cards. This module is enabled only with + This module supports multiple cards. This module is enabled only with ISA PnP support. The power-management is supported. @@ -477,7 +477,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. given in MB unit. Default value is 128. enable_ir - enable IR - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. Input & Output configurations [extin/extout] * Creative Card wo/Digital out [0x0003/0x1f03] @@ -500,7 +500,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for Creative Emu10k1X (SB Live Dell OEM version) - Module supports up to 8 cards. + This module supports multiple cards. Module snd-ens1370 ------------------ @@ -511,7 +511,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. joystick - Enable joystick (default off) - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. Module snd-ens1371 ------------------ @@ -524,7 +524,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. joystick_port - port # for joystick (0x200,0x208,0x210,0x218), 0 = disable (default), 1 = auto-detect - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. Module snd-es968 ---------------- @@ -535,7 +535,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. irq - IRQ # for ES968 (SB8) chip (PnP setup) dma1 - DMA # for ES968 (SB8) chip (PnP setup) - Module supports up to 8 cards, PnP and autoprobe. + This module supports multiple cards, PnP and autoprobe. The power-management is supported. @@ -550,7 +550,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. mpu_irq - IRQ # for MPU-401 port (5,7,9,10) dma8 - DMA # for ES-1688 chip (0,1,3) - Module supports up to 8 cards and autoprobe (without MPU-401 port). + This module supports multiple cards and autoprobe (without MPU-401 port). Module snd-es18xx ----------------- @@ -565,8 +565,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dma2 - first DMA # for ES-18xx chip (0,1,3) isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) - Module supports up to 8 cards ISA PnP and autoprobe (without MPU-401 port - if native ISA PnP routines are not used). + This module supports multiple cards, ISA PnP and autoprobe (without MPU-401 + port if native ISA PnP routines are not used). When dma2 is equal with dma1, the driver works as half-duplex. The power-management is supported. @@ -576,7 +576,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for sound cards based on ESS Solo-1 (ES1938,ES1946) chips. - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. The power-management is supported. @@ -594,7 +594,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. enable_mpu - enable MPU401 (0 = off, 1 = on, 2 = auto (default)) joystick - enable joystick (default off) - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. The power-management is supported. @@ -610,7 +610,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. - High 16-bits are video (radio) device number + 1 - example: 0x10002 (MediaForte 256-PCPR, device 1) - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. The power-management is supported. @@ -627,7 +627,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. voices - GF1 voices limit (14-32) pcm_voices - reserved PCM voices - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. Module snd-gusextreme --------------------- @@ -646,7 +646,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. voices - GF1 voices limit (14-32) pcm_voices - reserved PCM voices - Module supports up to 8 cards and autoprobe (without MPU-401 port). + This module supports multiple cards and autoprobe (without MPU-401 port). Module snd-gusmax ----------------- @@ -661,7 +661,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. voices - GF1 voices limit (14-32) pcm_voices - reserved PCM voices - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. Module snd-hda-intel -------------------- @@ -730,7 +730,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for RME Hammerfall DSP audio interface(s) - Module supports up to 8 cards. + This module supports multiple cards. Note: The firmware data can be automatically loaded via hotplug when CONFIG_FW_LOADER is set. Otherwise, you need to load @@ -788,7 +788,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. cs8427_timeout - reset timeout for the CS8427 chip (S/PDIF transciever) in msec resolution, default value is 500 (0.5 sec) - Module supports up to 8 cards and autoprobe. Note: The consumer part + This module supports multiple cards and autoprobe. Note: The consumer part is not used with all Envy24 based cards (for example in the MidiMan Delta serie). @@ -824,7 +824,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. aureon71, universe, k8x800, phase22, phase28, ms300, av710 - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. Note: The supported board is detected by reading EEPROM or PCI SSID (if EEPROM isn't available). You can override the @@ -894,7 +894,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. effect - 1 = InterWave effects enable (default 0); requires 8 voices - Module supports up to 8 cards, autoprobe and ISA PnP. + This module supports multiple cards, autoprobe and ISA PnP. Module snd-interwave-stb ------------------------ @@ -914,14 +914,14 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. effect - 1 = InterWave effects enable (default 0); requires 8 voices - Module supports up to 8 cards, autoprobe and ISA PnP. + This module supports multiple cards, autoprobe and ISA PnP. Module snd-korg1212 ------------------- Module for Korg 1212 IO PCI card - Module supports up to 8 cards. + This module supports multiple cards. Module snd-maestro3 ------------------- @@ -933,7 +933,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. -1 for default pin (8 for allegro, 1 for others) - Module supports autoprobe and multiple chips (max 8). + This module supports autoprobe and multiple chips. Note: the binding of amplifier is dependent on hardware. If there is no sound even though all channels are unmuted, try to @@ -948,7 +948,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for Digigram miXart8 sound cards. - Module supports multiple cards. + This module supports multiple cards. Note: One miXart8 board will be represented as 4 alsa cards. See MIXART.txt for details. @@ -967,7 +967,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. irq - IRQ number or -1 (disable) pnp - PnP detection - 0 = disable, 1 = enable (default) - Module supports multiple devices (max 8) and PnP. + This module supports multiple devices and PnP. Module snd-mtpav ---------------- @@ -1053,7 +1053,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dma2 - second DMA # for Yamaha OPL3-SA chip (0,1,3), -1 = disable isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) - Module supports up to 8 cards and ISA PnP. This module does not support + This module supports multiple cards and ISA PnP. It does not support autoprobe (if ISA PnP is not used) thus all ports must be specified!!! The power-management is supported. @@ -1131,14 +1131,14 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for RME Digi32, Digi32 Pro and Digi32/8 (Sek'd Prodif32, Prodif96 and Prodif Gold) sound cards. - Module supports up to 8 cards. + This module supports multiple cards. Module snd-rme96 ---------------- Module for RME Digi96, Digi96/8 and Digi96/8 PRO/PAD/PST sound cards. - Module supports up to 8 cards. + This module supports multiple cards. Module snd-rme9652 ------------------ @@ -1148,7 +1148,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. precise_ptr - Enable precise pointer (doesn't work reliably). (default = 0) - Module supports up to 8 cards. + This module supports multiple cards. Note: snd-page-alloc module does the job which snd-hammerfall-mem module did formerly. It will allocate the buffers in advance @@ -1178,7 +1178,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. irq - IRQ # for SB DSP chip (5,7,9,10) dma8 - DMA # for SB DSP chip (1,3) - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. The power-management is supported. @@ -1200,7 +1200,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. csp - ASP/CSP chip support - 0 = disable (default), 1 = enable isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) - Module supports up to 8 cards, autoprobe and ISA PnP. + This module supports multiple cards, autoprobe and ISA PnP. Note: To use Vibra16X cards in 16-bit half duplex mode, you must disable 16bit DMA with dma16 = -1 module parameter. @@ -1220,7 +1220,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. irq - IRQ # (7,9,10,11) dma1 - DMA # - Module supports up to 8 cards. + This module supports multiple cards. The power-management is supported. @@ -1234,7 +1234,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. mpu_irq - MPU-401 IRQ # (PnP setup) dma - DMA # (PnP setup) - Module supports up to 8 cards. ISA PnP must be enabled. + This module supports multiple cards. ISA PnP must be enabled. You need sscape_ctl tool in alsa-tools package for loading the microcode. @@ -1243,21 +1243,21 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for AMD7930 sound chips found on Sparcs. - Module supports up to 8 cards. + This module supports multiple cards. Module snd-sun-cs4231 (on sparc only) ------------------------------------- Module for CS4231 sound chips found on Sparcs. - Module supports up to 8 cards. + This module supports multiple cards. Module snd-sun-dbri (on sparc only) ----------------------------------- Module for DBRI sound chips found on Sparcs. - Module supports up to 8 cards. + This module supports multiple cards. Module snd-wavefront -------------------- @@ -1277,7 +1277,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. dma2 - DMA2 # for CS4232 PCM interface. isapnp - ISA PnP detection - 0 = disable, 1 = enable (default) - Module supports up to 8 cards and ISA PnP. + This module supports multiple cards and ISA PnP. Module snd-sonicvibes --------------------- @@ -1289,7 +1289,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. - SoundCard must have onboard SRAM for this. mge - Mic Gain Enable - 1 = enable, 0 = disable (default) - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. Module snd-serial-u16550 ------------------------ @@ -1308,7 +1308,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. 0 = Soundcanvas, 1 = MS-124T, 2 = MS-124W S/A, 3 = MS-124W M/B, 4 = Generic - Module supports up to 8 cards. This module does not support autoprobe + This module supports multiple cards. This module does not support autoprobe thus the main port must be specified!!! Other options are optional. Module snd-trident @@ -1327,7 +1327,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. pcm_channels - max channels (voices) reserved for PCM wavetable_size - max wavetable size in kB (4-?kb) - Module supports up to 8 cards and autoprobe. + This module supports multiple cards and autoprobe. The power-management is supported. @@ -1339,14 +1339,14 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. vid - Vendor ID for the device (optional) pid - Product ID for the device (optional) - This module supports up to 8 cards, autoprobe and hotplugging. + This module supports multiple devices, autoprobe and hotplugging. Module snd-usb-usx2y -------------------- Module for Tascam USB US-122, US-224 and US-428 devices. - This module supports up to 8 cards, autoprobe and hotplugging. + This module supports multiple devices, autoprobe and hotplugging. Note: you need to load the firmware via usx2yloader utility included in alsa-tools and alsa-firmware packages. @@ -1428,9 +1428,9 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. This module creates virtual rawmidi devices which communicate to the corresponding ALSA sequencer ports. - midi_devs - MIDI devices # (1-8, default=4) + midi_devs - MIDI devices # (1-4, default=4) - Module supports up to 8 cards. + This module supports multiple cards. Module snd-vx222 ---------------- @@ -1440,7 +1440,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. mic - Enable Microphone on V222 Mic (NYI) ibl - Capture IBL size. (default = 0, minimum size) - Module supports up to 8 cards. + This module supports multiple cards. When the driver is compiled as a module and the hotplug firmware is supported, the firmware data is loaded via hotplug automatically. @@ -1468,7 +1468,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ibl - Capture IBL size. (default = 0, minimum size) - Module supports up to 8 cards. The module is compiled only when + This module supports multiple cards. The module is compiled only when PCMCIA is supported on kernel. With the older 2.6.x kernel, to activate the driver via the card @@ -1504,7 +1504,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. 1 (auto-detect) rear_switch - enable shared rear/line-in switch (bool) - Module supports autoprobe and multiple chips (max 8). + This module supports autoprobe and multiple chips. The power-management is supported. -- cgit v1.1 From 1b98ea4791892399d8c23c93e117567eeff38887 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 21 Nov 2005 07:31:31 +0100 Subject: [ALSA] rawmidi: adjust runtime->avail when changing output buffer size Modules: RawMidi Midlevel When the output buffer size is changed, runtime->avail must be adjusted to the new size; otherwise, draining of a bigger buffer would appear to fail because avail does not reach buffer_size. Signed-off-by: Clemens Ladisch --- sound/core/rawmidi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index e6ee0d8..587ea1e 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -635,6 +635,7 @@ int snd_rawmidi_output_params(struct snd_rawmidi_substream *substream, kfree(runtime->buffer); runtime->buffer = newbuf; runtime->buffer_size = params->buffer_size; + runtime->avail = runtime->buffer_size; } runtime->avail_min = params->avail_min; substream->active_sensing = !params->no_active_sensing; -- cgit v1.1 From 54d174031576a2855c49611d83d4946bde81b504 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 21 Nov 2005 16:33:22 +0100 Subject: [ALSA] hda-codec - Fix connection list parsing Modules: HDA Codec driver,HDA generic driver - Fix connection list parsing (with ranged flag). - Increase the max number of connections - Introduce widget capabilities cache - Power up/down widgets at init, suspend and resume Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 155 ++++++++++++++++++++++++++++++----------- sound/pci/hda/hda_codec.h | 13 +++- sound/pci/hda/hda_local.h | 14 +++- sound/pci/hda/patch_realtek.c | 3 +- sound/pci/hda/patch_sigmatel.c | 25 +------ 5 files changed, 140 insertions(+), 70 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 7f4e199..402ce00 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -155,8 +155,9 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *conn_list, int max_conns) { unsigned int parm; - int i, j, conn_len, num_tupples, conns; + int i, conn_len, conns; unsigned int shift, num_elems, mask; + hda_nid_t prev_nid; snd_assert(conn_list && max_conns > 0, return -EINVAL); @@ -171,7 +172,6 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, num_elems = 4; } conn_len = parm & AC_CLIST_LENGTH; - num_tupples = num_elems / 2; mask = (1 << (shift-1)) - 1; if (! conn_len) @@ -186,40 +186,38 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid, /* multi connection */ conns = 0; - for (i = 0; i < conn_len; i += num_elems) { - parm = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_LIST, i); - for (j = 0; j < num_tupples; j++) { - int range_val; - hda_nid_t val1, val2, n; - range_val = parm & (1 << (shift-1)); /* ranges */ - val1 = parm & mask; - parm >>= shift; - val2 = parm & mask; - parm >>= shift; - if (range_val) { - /* ranges between val1 and val2 */ - if (val1 > val2) { - snd_printk(KERN_WARNING "hda_codec: invalid dep_range_val %x:%x\n", val1, val2); - continue; - } - for (n = val1; n <= val2; n++) { - if (conns >= max_conns) - return -EINVAL; - conn_list[conns++] = n; - } - } else { - if (! val1) - break; - if (conns >= max_conns) - return -EINVAL; - conn_list[conns++] = val1; - if (! val2) - break; - if (conns >= max_conns) + prev_nid = 0; + for (i = 0; i < conn_len; i++) { + int range_val; + hda_nid_t val, n; + + if (i % num_elems == 0) + parm = snd_hda_codec_read(codec, nid, 0, + AC_VERB_GET_CONNECT_LIST, i); + range_val = !! (parm & (1 << (shift-1))); /* ranges */ + val = parm & mask; + parm >>= shift; + if (range_val) { + /* ranges between the previous and this one */ + if (! prev_nid || prev_nid >= val) { + snd_printk(KERN_WARNING "hda_codec: invalid dep_range_val %x:%x\n", prev_nid, val); + continue; + } + for (n = prev_nid + 1; n <= val; n++) { + if (conns >= max_conns) { + snd_printk(KERN_ERR "Too many connections\n"); return -EINVAL; - conn_list[conns++] = val2; + } + conn_list[conns++] = n; } + } else { + if (conns >= max_conns) { + snd_printk(KERN_ERR "Too many connections\n"); + return -EINVAL; + } + conn_list[conns++] = val; } + prev_nid = val; } return conns; } @@ -456,6 +454,27 @@ static void setup_fg_nodes(struct hda_codec *codec) } /* + * read widget caps for each widget and store in cache + */ +static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node) +{ + int i; + hda_nid_t nid; + + codec->num_nodes = snd_hda_get_sub_nodes(codec, fg_node, + &codec->start_nid); + codec->wcaps = kmalloc(codec->num_nodes * 4, GFP_KERNEL); + if (! codec->wcaps) + return -ENOMEM; + nid = codec->start_nid; + for (i = 0; i < codec->num_nodes; i++, nid++) + codec->wcaps[i] = snd_hda_param_read(codec, nid, + AC_PAR_AUDIO_WIDGET_CAP); + return 0; +} + + +/* * codec destructor */ static void snd_hda_codec_free(struct hda_codec *codec) @@ -467,6 +486,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) if (codec->patch_ops.free) codec->patch_ops.free(codec); kfree(codec->amp_info); + kfree(codec->wcaps); kfree(codec); } @@ -520,6 +540,12 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, return -ENODEV; } + if (read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg) < 0) { + snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); + snd_hda_codec_free(codec); + return -ENOMEM; + } + if (! codec->subsystem_id) { hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; codec->subsystem_id = snd_hda_codec_read(codec, nid, 0, @@ -647,7 +673,7 @@ static u32 query_amp_caps(struct hda_codec *codec, hda_nid_t nid, int direction) if (! info) return 0; if (! (info->status & INFO_AMP_CAPS)) { - if (!(snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP) & AC_WCAP_AMP_OVRD)) + if (! (get_wcaps(codec, nid) & AC_WCAP_AMP_OVRD)) nid = codec->afg; info->amp_caps = snd_hda_param_read(codec, nid, direction == HDA_OUTPUT ? AC_PAR_AMP_OUT_CAP : AC_PAR_AMP_IN_CAP); @@ -1195,6 +1221,31 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid) } +/* + * set power state of the codec + */ +static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg, + unsigned int power_state) +{ + hda_nid_t nid, nid_start; + int nodes; + + snd_hda_codec_write(codec, fg, 0, AC_VERB_SET_POWER_STATE, + power_state); + + nodes = snd_hda_get_sub_nodes(codec, fg, &nid_start); + for (nid = nid_start; nid < nodes + nid_start; nid++) { + if (get_wcaps(codec, nid) & AC_WCAP_POWER) + snd_hda_codec_write(codec, nid, 0, + AC_VERB_SET_POWER_STATE, + power_state); + } + + if (power_state == AC_PWRST_D0) + msleep(10); +} + + /** * snd_hda_build_controls - build mixer controls * @bus: the BUS @@ -1222,6 +1273,9 @@ int snd_hda_build_controls(struct hda_bus *bus) list_for_each(p, &bus->codec_list) { struct hda_codec *codec = list_entry(p, struct hda_codec, list); int err; + hda_set_power_state(codec, + codec->afg ? codec->afg : codec->mfg, + AC_PWRST_D0); if (! codec->patch_ops.init) continue; err = codec->patch_ops.init(codec); @@ -1340,7 +1394,7 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, val = 0; if (nid != codec->afg && - snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP) & AC_WCAP_FORMAT_OVRD) { + (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) { val = snd_hda_param_read(codec, nid, AC_PAR_PCM); if (val == -1) return -EIO; @@ -1362,7 +1416,7 @@ int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid, unsigned int bps; unsigned int wcaps; - wcaps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); + wcaps = get_wcaps(codec, nid); streams = snd_hda_param_read(codec, nid, AC_PAR_STREAM); if (streams == -1) return -EIO; @@ -1432,7 +1486,7 @@ int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid, unsigned int val = 0, rate, stream; if (nid != codec->afg && - snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP) & AC_WCAP_FORMAT_OVRD) { + (get_wcaps(codec, nid) & AC_WCAP_FORMAT_OVRD)) { val = snd_hda_param_read(codec, nid, AC_PAR_PCM); if (val == -1) return 0; @@ -1658,9 +1712,21 @@ int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew) int err; for (; knew->name; knew++) { - err = snd_ctl_add(codec->bus->card, snd_ctl_new1(knew, codec)); - if (err < 0) - return err; + struct snd_kcontrol *kctl; + kctl = snd_ctl_new1(knew, codec); + if (! kctl) + return -ENOMEM; + err = snd_ctl_add(codec->bus->card, kctl); + if (err < 0) { + if (! codec->addr) + return err; + kctl = snd_ctl_new1(knew, codec); + if (! kctl) + return -ENOMEM; + kctl->id.device = codec->addr; + if ((err = snd_ctl_add(codec->bus->card, kctl)) < 0) + return err; + } } return 0; } @@ -1874,8 +1940,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); for (nid = nid_start; nid < nodes + nid_start; nid++) { - unsigned int wid_caps = snd_hda_param_read(codec, nid, - AC_PAR_AUDIO_WIDGET_CAP); + unsigned int wid_caps = get_wcaps(codec, nid); unsigned int wid_type = (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; unsigned int def_conf; short assoc, loc; @@ -1993,6 +2058,9 @@ int snd_hda_suspend(struct hda_bus *bus, pm_message_t state) struct hda_codec *codec = list_entry(p, struct hda_codec, list); if (codec->patch_ops.suspend) codec->patch_ops.suspend(codec, state); + hda_set_power_state(codec, + codec->afg ? codec->afg : codec->mfg, + AC_PWRST_D3); } return 0; } @@ -2010,6 +2078,9 @@ int snd_hda_resume(struct hda_bus *bus) list_for_each(p, &bus->codec_list) { struct hda_codec *codec = list_entry(p, struct hda_codec, list); + hda_set_power_state(codec, + codec->afg ? codec->afg : codec->mfg, + AC_PWRST_D0); if (codec->patch_ops.resume) codec->patch_ops.resume(codec); } diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 0b5c367..63e26c7 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h @@ -214,6 +214,12 @@ enum { #define AC_PWRST_D2SUP (1<<2) #define AC_PWRST_D3SUP (1<<3) +/* Power state values */ +#define AC_PWRST_D0 0x00 +#define AC_PWRST_D1 0x01 +#define AC_PWRST_D2 0x02 +#define AC_PWRST_D3 0x03 + /* Processing capabilies */ #define AC_PCAP_BENIGN (1<<0) #define AC_PCAP_NUM_COEF (0xff<<8) @@ -376,7 +382,7 @@ enum { }; /* max. connections to a widget */ -#define HDA_MAX_CONNECTIONS 16 +#define HDA_MAX_CONNECTIONS 32 /* max. codec address */ #define HDA_MAX_CODEC_ADDRESS 0x0f @@ -542,6 +548,11 @@ struct hda_codec { /* codec specific info */ void *spec; + /* widget capabilities cache */ + unsigned int num_nodes; + hda_nid_t start_nid; + u32 *wcaps; + /* hash for amp access */ u16 amp_hash[32]; int num_amp_entries; diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 5022904..ded3235 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -87,7 +87,7 @@ int snd_hda_create_spdif_in_ctls(struct hda_codec *codec, hda_nid_t nid); /* * input MUX helper */ -#define HDA_MAX_NUM_INPUTS 8 +#define HDA_MAX_NUM_INPUTS 16 struct hda_input_mux_item { const char *label; unsigned int index; @@ -243,4 +243,16 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c #define PIN_HP 0xc0 #define PIN_HP_AMP 0x80 +/* + * get widget capabilities + */ +static inline u32 get_wcaps(struct hda_codec *codec, hda_nid_t nid) +{ + if (nid < codec->start_nid || + nid >= codec->start_nid + codec->num_nodes) + return snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); + return codec->wcaps[nid - codec->start_nid]; +} + + #endif /* __SOUND_HDA_LOCAL_H */ diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 62e6993..77c5f95 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2091,8 +2091,7 @@ static int patch_alc880(struct hda_codec *codec) if (! spec->adc_nids && spec->input_mux) { /* check whether NID 0x07 is valid */ - unsigned int wcap = snd_hda_param_read(codec, alc880_adc_nids[0], - AC_PAR_AUDIO_WIDGET_CAP); + unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ if (wcap != AC_WID_AUD_IN) { spec->adc_nids = alc880_adc_nids_alt; diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index d8d68f5..c8c539c 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -624,7 +624,7 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin if (! pin) return 0; - wid_caps = snd_hda_param_read(codec, pin, AC_PAR_AUDIO_WIDGET_CAP); + wid_caps = get_wcaps(codec, pin); if (wid_caps & AC_WCAP_UNSOL_CAP) /* Enable unsolicited responses on the HP widget */ snd_hda_codec_write(codec, pin, 0, @@ -786,33 +786,10 @@ static int stac9200_parse_auto_config(struct hda_codec *codec) return 1; } -static int stac92xx_init_pstate(struct hda_codec *codec) -{ - hda_nid_t nid, nid_start; - int nodes; - - snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_POWER_STATE, 0x00); - - nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid_start); - for (nid = nid_start; nid < nodes + nid_start; nid++) { - unsigned int wid_caps = snd_hda_param_read(codec, nid, - AC_PAR_AUDIO_WIDGET_CAP); - if (wid_caps & AC_WCAP_POWER) - snd_hda_codec_write(codec, nid, 0, - AC_VERB_SET_POWER_STATE, 0x00); - } - - mdelay(100); - - return 0; -} - static int stac92xx_init(struct hda_codec *codec) { struct sigmatel_spec *spec = codec->spec; - stac92xx_init_pstate(codec); - snd_hda_sequence_write(codec, spec->init); stac92xx_auto_init_multi_out(codec); -- cgit v1.1 From d25695056ff2e1e048cfc8d7dbafaf80c3c46d5d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 21 Nov 2005 16:33:51 +0100 Subject: [ALSA] hda-codec - Allocate connection lists dynamically in generic parser Modules: HDA generic driver Allocate connection lists dynamically in generic parser. Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_generic.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 863e8c6..39edfcf 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c @@ -32,7 +32,8 @@ struct hda_gnode { hda_nid_t nid; /* NID of this widget */ unsigned short nconns; /* number of input connections */ - hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; /* input connections */ + hda_nid_t *conn_list; + hda_nid_t slist[2]; /* temporay list */ unsigned int wid_caps; /* widget capabilities */ unsigned char type; /* widget type */ unsigned char pin_ctl; /* pin controls */ @@ -84,6 +85,8 @@ static void snd_hda_generic_free(struct hda_codec *codec) /* free all widgets */ list_for_each_safe(p, n, &spec->nid_list) { struct hda_gnode *node = list_entry(p, struct hda_gnode, list); + if (node->conn_list != node->slist) + kfree(node->conn_list); kfree(node); } kfree(spec); @@ -97,18 +100,32 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid { struct hda_gnode *node; int nconns; + hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; node = kzalloc(sizeof(*node), GFP_KERNEL); if (node == NULL) return -ENOMEM; node->nid = nid; - nconns = snd_hda_get_connections(codec, nid, node->conn_list, HDA_MAX_CONNECTIONS); + nconns = snd_hda_get_connections(codec, nid, conn_list, + HDA_MAX_CONNECTIONS); if (nconns < 0) { kfree(node); return nconns; } + if (nconns <= ARRAY_SIZE(node->slist)) + node->conn_list = node->slist; + else { + node->conn_list = kmalloc(sizeof(hda_nid_t) * nconns, + GFP_KERNEL); + if (! node->conn_list) { + snd_printk(KERN_ERR "hda-generic: cannot malloc\n"); + kfree(node); + return -ENOMEM; + } + } + memcpy(node->conn_list, conn_list, nconns); node->nconns = nconns; - node->wid_caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); + node->wid_caps = get_wcaps(codec, nid); node->type = (node->wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; if (node->type == AC_WID_PIN) { -- cgit v1.1 From 2e5b9567f7444673a93cbacdcbeb3feacdb4914f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 21 Nov 2005 16:36:15 +0100 Subject: [ALSA] hda-codec - Fix AD1988 support Modules: HDA Codec driver Fix AD1988 support. As default, 6stack model is used. Still no auto-BIOS setup is implemented. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 52 +++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 25116a8..3799d8a 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -50,6 +50,7 @@ struct ad198x_spec { /* capture source */ const struct hda_input_mux *input_mux; + hda_nid_t *capsrc_nids; unsigned int cur_mux[3]; /* channel model */ @@ -91,7 +92,8 @@ static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, - spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]); + spec->capsrc_nids[adc_idx], + &spec->cur_mux[adc_idx]); } /* @@ -536,6 +538,7 @@ static int patch_ad1986a(struct hda_codec *codec) spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT; spec->num_adc_nids = 1; spec->adc_nids = ad1986a_adc_nids; + spec->capsrc_nids = ad1986a_adc_nids; spec->input_mux = &ad1986a_capture_source; spec->num_mixers = 1; spec->mixers[0] = ad1986a_mixers; @@ -699,6 +702,7 @@ static int patch_ad1983(struct hda_codec *codec) spec->multiout.dig_out_nid = AD1983_SPDIF_OUT; spec->num_adc_nids = 1; spec->adc_nids = ad1983_adc_nids; + spec->capsrc_nids = ad1983_adc_nids; spec->input_mux = &ad1983_capture_source; spec->num_mixers = 1; spec->mixers[0] = ad1983_mixers; @@ -844,6 +848,7 @@ static int patch_ad1981(struct hda_codec *codec) spec->multiout.dig_out_nid = AD1981_SPDIF_OUT; spec->num_adc_nids = 1; spec->adc_nids = ad1981_adc_nids; + spec->capsrc_nids = ad1981_adc_nids; spec->input_mux = &ad1981_capture_source; spec->num_mixers = 1; spec->mixers[0] = ad1981_mixers; @@ -968,6 +973,10 @@ static hda_nid_t ad1988_adc_nids[3] = { 0x08, 0x09, 0x0f }; +static hda_nid_t ad1988_capsrc_nids[3] = { + 0x0c, 0x0d, 0x0e +}; + #define AD1988_SPDIF_OUT 0x02 #define AD1988_SPDIF_IN 0x07 @@ -1086,7 +1095,7 @@ static struct snd_kcontrol_new ad1988_6stack_mixers[] = { HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), - HDA_CODEC_VOLUME("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), @@ -1121,7 +1130,7 @@ static struct snd_kcontrol_new ad1988_3stack_mixers[] = { HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), - HDA_CODEC_VOLUME("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Front Mic Boost", 0x39, 0x0, HDA_OUTPUT), @@ -1153,7 +1162,7 @@ static struct snd_kcontrol_new ad1988_laptop_mixers[] = { HDA_CODEC_VOLUME("Beep Playback Volume", 0x10, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Beep Playback Switch", 0x10, 0x0, HDA_OUTPUT), - HDA_CODEC_VOLUME("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Analog Mix Playback Volume", 0x21, 0x0, HDA_OUTPUT), HDA_CODEC_MUTE("Analog Mix Playback Switch", 0x21, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Mic Boost", 0x39, 0x0, HDA_OUTPUT), @@ -1277,11 +1286,11 @@ static struct snd_kcontrol_new ad1988_spdif_in_mixers[] = { * for 6-stack (+dig) */ static struct hda_verb ad1988_6stack_init_verbs[] = { - /* Front, Surround, CLFE, side DAC; mute as default */ - {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + /* Front, Surround, CLFE, side DAC; unmute as default */ + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Port-A front headphon path */ {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, @@ -1396,11 +1405,11 @@ static struct hda_channel_mode ad1988_3stack_modes[2] = { }; static struct hda_verb ad1988_3stack_init_verbs[] = { - /* Front, Surround, CLFE, side DAC; mute as default */ - {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + /* Front, Surround, CLFE, side DAC; unmute as default */ + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Port-A front headphon path */ {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, @@ -1471,11 +1480,11 @@ static struct hda_verb ad1988_laptop_hp_off[] = { #define AD1988_HP_EVENT 0x01 static struct hda_verb ad1988_laptop_init_verbs[] = { - /* Front, Surround, CLFE, side DAC; mute as default */ - {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + /* Front, Surround, CLFE, side DAC; unmute as default */ + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Port-A front headphon path */ {0x37, AC_VERB_SET_CONNECT_SEL, 0x01}, /* DAC1:04h */ {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, @@ -1563,7 +1572,7 @@ static int patch_ad1988(struct hda_codec *codec) board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl); if (board_config < 0 || board_config >= AD1988_MODEL_LAST) { - printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n"); + printk(KERN_INFO "hda_codec: Unknown model for AD1988, using 6stack model...\n"); board_config = AD1988_6STACK; } @@ -1575,6 +1584,7 @@ static int patch_ad1988(struct hda_codec *codec) spec->multiout.dac_nids = ad1988_dac_nids; spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); spec->adc_nids = ad1988_adc_nids; + spec->capsrc_nids = ad1988_capsrc_nids; spec->input_mux = &ad1988_6stack_capture_source; spec->num_mixers = 1; spec->mixers[0] = ad1988_6stack_mixers; @@ -1592,6 +1602,7 @@ static int patch_ad1988(struct hda_codec *codec) spec->multiout.dac_nids = ad1988_dac_nids; spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); spec->adc_nids = ad1988_adc_nids; + spec->capsrc_nids = ad1988_capsrc_nids; spec->input_mux = &ad1988_6stack_capture_source; spec->channel_mode = ad1988_3stack_modes; spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); @@ -1609,6 +1620,7 @@ static int patch_ad1988(struct hda_codec *codec) spec->multiout.dac_nids = ad1988_dac_nids; spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); spec->adc_nids = ad1988_adc_nids; + spec->capsrc_nids = ad1988_capsrc_nids; spec->input_mux = &ad1988_laptop_capture_source; spec->num_mixers = 1; spec->mixers[0] = ad1988_laptop_mixers; -- cgit v1.1 From 1f14a657d87aa0e1a6c08c2e31588fbca34a8844 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 21 Nov 2005 16:40:00 +0100 Subject: [ALSA] usb-audio: fix Edirol UA-20 support Modules: USB generic driver Somebody at Edirol fucked up and released a new revision of the UA-20 without class-specific descriptors, so now we have to hard-code the sample format. Signed-off-by: Clemens Ladisch --- sound/usb/usbquirks.h | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/sound/usb/usbquirks.h b/sound/usb/usbquirks.h index 0e05754..6190ada 100644 --- a/sound/usb/usbquirks.h +++ b/sound/usb/usbquirks.h @@ -665,16 +665,50 @@ YAMAHA_DEVICE(0x7010, "UB99"), .type = QUIRK_COMPOSITE, .data = (const struct snd_usb_audio_quirk[]) { { + .ifnum = 0, + .type = QUIRK_IGNORE_INTERFACE + }, + { .ifnum = 1, - .type = QUIRK_AUDIO_STANDARD_INTERFACE + .type = QUIRK_AUDIO_FIXED_ENDPOINT, + .data = & (const struct audioformat) { + .format = SNDRV_PCM_FORMAT_S24_3LE, + .channels = 2, + .iface = 1, + .altsetting = 1, + .altset_idx = 1, + .attributes = 0, + .endpoint = 0x01, + .ep_attr = 0x01, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 44100, + .rate_max = 44100, + } }, { .ifnum = 2, - .type = QUIRK_AUDIO_STANDARD_INTERFACE + .type = QUIRK_AUDIO_FIXED_ENDPOINT, + .data = & (const struct audioformat) { + .format = SNDRV_PCM_FORMAT_S24_3LE, + .channels = 2, + .iface = 2, + .altsetting = 1, + .altset_idx = 1, + .attributes = 0, + .endpoint = 0x82, + .ep_attr = 0x01, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 44100, + .rate_max = 44100, + } }, { .ifnum = 3, - .type = QUIRK_MIDI_STANDARD_INTERFACE + .type = QUIRK_MIDI_FIXED_ENDPOINT, + .data = & (const struct snd_usb_midi_endpoint_info) { + .out_cables = 0x0001, + .in_cables = 0x0001 + } }, { .ifnum = -1 -- cgit v1.1 From 6a81dbf23df5400e4f8182e9f2eb52fabcf42015 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Nov 2005 14:33:27 +0100 Subject: [ALSA] ice1712 - Fix Front Digital Input of Terratec DMX 6Fire Modules: ICE1712 driver Fix the inverted switch of 'Front Digital Input' of Terratec DMX 6Fire. Signed-off-by: Takashi Iwai --- sound/pci/ice1712/ews.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ice1712/ews.c b/sound/pci/ice1712/ews.c index 2127d57..2c529e7 100644 --- a/sound/pci/ice1712/ews.c +++ b/sound/pci/ice1712/ews.c @@ -917,7 +917,7 @@ static struct snd_kcontrol_new snd_ice1712_6fire_controls[] __devinitdata = { .get = snd_ice1712_6fire_select_input_get, .put = snd_ice1712_6fire_select_input_put, }, - DMX6FIRE_CONTROL("Front Digital Input Switch", 2, 0), + DMX6FIRE_CONTROL("Front Digital Input Switch", 2, 1), // DMX6FIRE_CONTROL("Master Clock Select", 3, 0), DMX6FIRE_CONTROL("Optical Digital Input Switch", 4, 0), DMX6FIRE_CONTROL("Phono Analog Input Switch", 5, 0), -- cgit v1.1 From 9a1a2a1d4eeda00df45ccf7a3a375d1887f1efb3 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 22 Nov 2005 15:46:41 +0100 Subject: [ALSA] Fix a missing include Modules: ALSA Core Fix missing include Signed-off-by: Takashi Iwai --- sound/core/sound.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/core/sound.c b/sound/core/sound.c index 5febd05..3b91f18 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include -- cgit v1.1 From 18612048b3e951f7e0ae9be65efe9e8cfde868a6 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 23 Nov 2005 13:14:50 +0100 Subject: [ALSA] sound/: possible cleanups Modules: RawMidi Midlevel,HDA generic driver This patch contains the following possible cleanups: - pci/hda/hda_proc.c should #include 'hda_local.h' for including the prototype of it's global function snd_hda_codec_proc_new() - core/rawmidi.c: make the needlessly global and EXPORT_SYMBOL'ed function snd_rawmidi_info() static Signed-off-by: Adrian Bunk Signed-off-by: Takashi Iwai --- sound/core/rawmidi.c | 5 ++--- sound/pci/hda/hda_proc.c | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c index 587ea1e..d4d124e 100644 --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -534,8 +534,8 @@ static int snd_rawmidi_release(struct inode *inode, struct file *file) return err; } -int snd_rawmidi_info(struct snd_rawmidi_substream *substream, - struct snd_rawmidi_info *info) +static int snd_rawmidi_info(struct snd_rawmidi_substream *substream, + struct snd_rawmidi_info *info) { struct snd_rawmidi *rmidi; @@ -1694,7 +1694,6 @@ EXPORT_SYMBOL(snd_rawmidi_transmit_ack); EXPORT_SYMBOL(snd_rawmidi_transmit); EXPORT_SYMBOL(snd_rawmidi_new); EXPORT_SYMBOL(snd_rawmidi_set_ops); -EXPORT_SYMBOL(snd_rawmidi_info); EXPORT_SYMBOL(snd_rawmidi_info_select); EXPORT_SYMBOL(snd_rawmidi_kernel_open); EXPORT_SYMBOL(snd_rawmidi_kernel_release); diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 8cc5773..ca514a6 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c @@ -26,6 +26,7 @@ #include #include #include "hda_codec.h" +#include "hda_local.h" static const char *get_wid_type_name(unsigned int wid_value) { -- cgit v1.1 From 5014f193166d14e47525a34d65a1c7d77b0f6f38 Mon Sep 17 00:00:00 2001 From: Libin Yang Date: Wed, 23 Nov 2005 15:48:36 +0100 Subject: [ALSA] hda-codec - Fix auto-probe of ALC880 Modules: HDA Codec driver This patch is to fix the problem of calculating the nid incorrectly when auto-probe for ALC880. The problem to be fixed often behaves with such words when using dmesg, 'num_steps = 0 for NID=0x8' when auto-probe for ALC880. The patch contains: - alsa-kernel/pci/hda/patch_realtek.c: replace 'alc880_dac_to_idx' with 'alc880_idx_to_dac' in function 'alc880_auto_fill_dac_nids()' Signed-off-by: Libin Yang Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 77c5f95..c5fb141 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1760,7 +1760,7 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pi nid = cfg->line_out_pins[i]; if (alc880_is_fixed_pin(nid)) { int idx = alc880_fixed_pin_idx(nid); - spec->multiout.dac_nids[i] = alc880_dac_to_idx(idx); + spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx); assigned[idx] = 1; } } -- cgit v1.1 From 606ad75fb5372c0edb5ee6276c8e29fcb525f3e1 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 24 Nov 2005 16:03:40 +0100 Subject: [ALSA] hda-intel - Use position buffer as default Modules: HDA Intel driver - Use the position buffer for obtaining the current DMA position as default. This seems more stable than others. - Add probe_mask module option (mainly for test boards with multiple codecs). Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 3945c44..8a0a0a7 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -52,6 +52,7 @@ static int index = SNDRV_DEFAULT_IDX1; static char *id = SNDRV_DEFAULT_STR1; static char *model; static int position_fix; +static int probe_mask; module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); @@ -61,6 +62,9 @@ module_param(model, charp, 0444); MODULE_PARM_DESC(model, "Use the given board model."); module_param(position_fix, int, 0444); MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)."); +module_param(probe_mask, int, 0444); +MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); + /* just for backward compatibility */ static int enable; @@ -916,7 +920,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model) codecs = 0; for (c = 0; c < AZX_MAX_CODECS; c++) { - if (chip->codec_mask & (1 << c)) { + if ((chip->codec_mask & (1 << c)) & probe_mask) { err = snd_hda_codec_new(chip->bus, c, NULL); if (err < 0) continue; @@ -1150,31 +1154,6 @@ static snd_pcm_uframes_t azx_pcm_pointer(struct snd_pcm_substream *substream) pos = azx_sd_readl(azx_dev, SD_LPIB); if (chip->position_fix == POS_FIX_FIFO) pos += azx_dev->fifo_size; -#if 0 /* disabled temprarily, auto-correction doesn't work well... */ - else if (chip->position_fix == POS_FIX_AUTO && azx_dev->period_updating) { - /* check the validity of DMA position */ - unsigned int diff = 0; - azx_dev->last_pos += azx_dev->fragsize; - if (azx_dev->last_pos > pos) - diff = azx_dev->last_pos - pos; - if (azx_dev->last_pos >= azx_dev->bufsize) { - if (pos < azx_dev->fragsize) - diff = 0; - azx_dev->last_pos = 0; - } - if (diff > 0 && diff <= azx_dev->fifo_size) - pos += azx_dev->fifo_size; - else { - snd_printdd(KERN_INFO "hda_intel: DMA position fix %d, switching to posbuf\n", diff); - chip->position_fix = POS_FIX_POSBUF; - pos = *azx_dev->posbuf; - } - azx_dev->period_updating = 0; - } -#else - else if (chip->position_fix == POS_FIX_AUTO) - pos += azx_dev->fifo_size; -#endif } if (pos >= azx_dev->bufsize) pos = 0; @@ -1412,7 +1391,7 @@ static int azx_dev_free(struct snd_device *device) * constructor */ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, - int posfix, int driver_type, + int driver_type, struct azx **rchip) { struct azx *chip; @@ -1441,7 +1420,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, chip->irq = -1; chip->driver_type = driver_type; - chip->position_fix = posfix; + chip->position_fix = position_fix ? position_fix : POS_FIX_POSBUF; #if BITS_PER_LONG != 64 /* Fix up base address on ULI M5461 */ @@ -1559,7 +1538,7 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id * return -ENOMEM; } - if ((err = azx_create(card, pci, position_fix, pci_id->driver_data, + if ((err = azx_create(card, pci, pci_id->driver_data, &chip)) < 0) { snd_card_free(card); return err; -- cgit v1.1 From b2ec642362eef10f660e2b857dda12e2d61e0198 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 24 Nov 2005 16:05:04 +0100 Subject: [ALSA] hda-codec - Fix channel mode helper Modules: HDA Codec driver Fix the channel mode helper (for put callback). Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 402ce00..5ead2a3 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1771,7 +1771,7 @@ int snd_hda_ch_mode_put(struct hda_codec *codec, struct snd_ctl_elem_value *ucon mode = ucontrol->value.enumerated.item[0]; snd_assert(mode < num_chmodes, return -EINVAL); - if (*max_channelsp && ! codec->in_resume) + if (*max_channelsp == chmode[mode].channels && ! codec->in_resume) return 0; /* change the current channel setting */ *max_channelsp = chmode[mode].channels; -- cgit v1.1 From d32410b1095cf93e8e31f8919de46f496d7b3ce0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 24 Nov 2005 16:06:23 +0100 Subject: [ALSA] hda-codec - Fix/enhance AD1988 support Modules: HDA Codec driver Fix/enhance AD1988 support code. - Fix for h/w bug of AD1988A rev 2 - The BIOS auto-configuration is added and used as fallback Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 572 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 531 insertions(+), 41 deletions(-) diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index 3799d8a..fabcbcf 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -1,5 +1,5 @@ /* - * HD audio interface patch for AD1981HD, AD1983, AD1986A + * HD audio interface patch for AD1981HD, AD1983, AD1986A, AD1988 * * Copyright (c) 2005 Takashi Iwai * @@ -31,7 +31,7 @@ struct ad198x_spec { struct snd_kcontrol_new *mixers[5]; int num_mixers; - const struct hda_verb *init_verbs[3]; /* initialization verbs + const struct hda_verb *init_verbs[5]; /* initialization verbs * don't forget NULL termination! */ unsigned int num_init_verbs; @@ -62,6 +62,13 @@ struct ad198x_spec { struct semaphore amp_mutex; /* PCM volume/mute control mutex */ unsigned int spdif_route; + + /* dynamic controls, init_verbs and input_mux */ + struct auto_pin_cfg autocfg; + unsigned int num_kctl_alloc, num_kctl_used; + struct snd_kcontrol_new *kctl_alloc; + struct hda_input_mux private_imux; + hda_nid_t private_dac_nids[4]; }; /* @@ -284,6 +291,14 @@ static int ad198x_build_pcms(struct hda_codec *codec) static void ad198x_free(struct hda_codec *codec) { + struct ad198x_spec *spec = codec->spec; + unsigned int i; + + if (spec->kctl_alloc) { + for (i = 0; i < spec->num_kctl_used; i++) + kfree(spec->kctl_alloc[i].name); + kfree(spec->kctl_alloc); + } kfree(codec->spec); } @@ -867,7 +882,7 @@ static int patch_ad1981(struct hda_codec *codec) * * Output pins and routes * - * Pin Mix Sel DAC + * Pin Mix Sel DAC (*) * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06 * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06 * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a @@ -878,6 +893,8 @@ static int patch_ad1981(struct hda_codec *codec) * port-H 0x25 (mute) <- 0x28 <- 0a * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06 * + * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah + * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug. * * Input pins and routes * @@ -893,11 +910,8 @@ static int patch_ad1981(struct hda_codec *codec) * * * DAC assignment - * front DAC - 04 - * surr DAC - 06 - * CLFE DAC - 05 - * side DAC - 0a - * opt DAC - 03 + * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 + * 3stack - front/surr/CLFE/opt DACs - 04/0a/05/03 * * Inputs of Analog Mix (0x20) * 0:Port-B (front mic) @@ -957,18 +971,35 @@ enum { AD1988_3STACK_DIG, AD1988_LAPTOP, AD1988_LAPTOP_DIG, + AD1988_AUTO, AD1988_MODEL_LAST, }; +/* reivision id to check workarounds */ +#define AD1988A_REV2 0x100200 + /* * mixers */ -static hda_nid_t ad1988_dac_nids[4] = { +static hda_nid_t ad1988_6stack_dac_nids[4] = { 0x04, 0x06, 0x05, 0x0a }; +static hda_nid_t ad1988_3stack_dac_nids[3] = { + 0x04, 0x0a, 0x05 +}; + +/* for AD1988A revision-2, DAC2-4 are swapped */ +static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = { + 0x04, 0x05, 0x0a, 0x06 +}; + +static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = { + 0x04, 0x06, 0x0a +}; + static hda_nid_t ad1988_adc_nids[3] = { 0x08, 0x09, 0x0f }; @@ -1068,13 +1099,23 @@ static int ad1988_eapd_put(struct snd_kcontrol *kcontrol, } /* 6-stack mode */ -static struct snd_kcontrol_new ad1988_6stack_mixers[] = { +static struct snd_kcontrol_new ad1988_6stack_mixers1[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME("Side Playback Volume", 0x0a, 0x0, HDA_OUTPUT), +}; + +static struct snd_kcontrol_new ad1988_6stack_mixers1_rev2[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Surround Playback Volume", 0x05, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Side Playback Volume", 0x06, 0x0, HDA_OUTPUT), +}; +static struct snd_kcontrol_new ad1988_6stack_mixers2[] = { HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), @@ -1105,16 +1146,25 @@ static struct snd_kcontrol_new ad1988_6stack_mixers[] = { }; /* 3-stack mode */ -static struct snd_kcontrol_new ad1988_3stack_mixers[] = { +static struct snd_kcontrol_new ad1988_3stack_mixers1[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), - HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x05, 1, 0x0, HDA_OUTPUT), HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x05, 2, 0x0, HDA_OUTPUT), +}; + +static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), +}; +static struct snd_kcontrol_new ad1988_3stack_mixers2[] = { HDA_BIND_MUTE("Front Playback Switch", 0x29, 2, HDA_INPUT), - HDA_BIND_MUTE("Surround Playback Switch", 0x2a, 2, HDA_INPUT), - HDA_BIND_MUTE_MONO("Center Playback Switch", 0x27, 1, 2, HDA_INPUT), - HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x27, 2, 2, HDA_INPUT), + HDA_BIND_MUTE("Surround Playback Switch", 0x2c, 2, HDA_INPUT), + HDA_BIND_MUTE_MONO("Center Playback Switch", 0x26, 1, 2, HDA_INPUT), + HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x26, 2, 2, HDA_INPUT), HDA_BIND_MUTE("Headphone Playback Switch", 0x22, 2, HDA_INPUT), HDA_BIND_MUTE("Mono Playback Switch", 0x1e, 2, HDA_INPUT), @@ -1391,11 +1441,11 @@ static struct hda_verb ad1988_3stack_ch2_init[] = { static struct hda_verb ad1988_3stack_ch6_init[] = { /* set port-C to surround out */ - { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, /* set port-E to CLFE out */ - { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, { } /* end */ }; @@ -1431,15 +1481,17 @@ static struct hda_verb ad1988_3stack_init_verbs[] = { {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, {0x39, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, - /* Port-C line-in/surround path */ - {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + /* Port-C line-in/surround path - 6ch mode as default */ + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, {0x3a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x31, AC_VERB_SET_CONNECT_SEL, 0x0}, /* output sel: DAC 0x05 */ {0x33, AC_VERB_SET_CONNECT_SEL, 0x0}, - /* Port-E mic-in/CLFE path */ - {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, - {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + /* Port-E mic-in/CLFE path - 6ch mode as default */ + {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x06 */ {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mute analog mix */ {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, @@ -1546,6 +1598,420 @@ static void ad1988_laptop_unsol_event(struct hda_codec *codec, unsigned int res) /* + * Automatic parse of I/O pins from the BIOS configuration + */ + +#define NUM_CONTROL_ALLOC 32 +#define NUM_VERB_ALLOC 32 + +enum { + AD_CTL_WIDGET_VOL, + AD_CTL_WIDGET_MUTE, + AD_CTL_BIND_MUTE, +}; +static struct snd_kcontrol_new ad1988_control_templates[] = { + HDA_CODEC_VOLUME(NULL, 0, 0, 0), + HDA_CODEC_MUTE(NULL, 0, 0, 0), + HDA_BIND_MUTE(NULL, 0, 0, 0), +}; + +/* add dynamic controls */ +static int add_control(struct ad198x_spec *spec, int type, const char *name, + unsigned long val) +{ + struct snd_kcontrol_new *knew; + + if (spec->num_kctl_used >= spec->num_kctl_alloc) { + int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC; + + knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */ + if (! knew) + return -ENOMEM; + if (spec->kctl_alloc) { + memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc); + kfree(spec->kctl_alloc); + } + spec->kctl_alloc = knew; + spec->num_kctl_alloc = num; + } + + knew = &spec->kctl_alloc[spec->num_kctl_used]; + *knew = ad1988_control_templates[type]; + knew->name = kstrdup(name, GFP_KERNEL); + if (! knew->name) + return -ENOMEM; + knew->private_value = val; + spec->num_kctl_used++; + return 0; +} + +#define AD1988_PIN_CD_NID 0x18 +#define AD1988_PIN_BEEP_NID 0x10 + +static hda_nid_t ad1988_mixer_nids[8] = { + /* A B C D E F G H */ + 0x22, 0x2b, 0x2c, 0x29, 0x26, 0x2a, 0x27, 0x28 +}; + +static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx) +{ + static hda_nid_t idx_to_dac[8] = { + /* A B C D E F G H */ + 0x04, 0x06, 0x0a, 0x04, 0x05, 0x06, 0x05, 0x0a + }; + static hda_nid_t idx_to_dac_rev2[8] = { + /* A B C D E F G H */ + 0x04, 0x05, 0x06, 0x04, 0x0a, 0x05, 0x0a, 0x06 + }; + if (codec->revision_id == AD1988A_REV2) + return idx_to_dac_rev2[idx]; + else + return idx_to_dac[idx]; +} + +static hda_nid_t ad1988_boost_nids[8] = { + 0x38, 0x39, 0x3a, 0x3d, 0x3c, 0x3b, 0, 0 +}; + +static int ad1988_pin_idx(hda_nid_t nid) +{ + static hda_nid_t ad1988_io_pins[8] = { + 0x11, 0x14, 0x15, 0x12, 0x17, 0x16, 0x24, 0x25 + }; + int i; + for (i = 0; i < ARRAY_SIZE(ad1988_io_pins); i++) + if (ad1988_io_pins[i] == nid) + return i; + return 0; /* should be -1 */ +} + +static int ad1988_pin_to_loopback_idx(hda_nid_t nid) +{ + static int loopback_idx[8] = { + 2, 0, 1, 3, 4, 5, 1, 4 + }; + switch (nid) { + case AD1988_PIN_CD_NID: + return 6; + default: + return loopback_idx[ad1988_pin_idx(nid)]; + } +} + +static int ad1988_pin_to_adc_idx(hda_nid_t nid) +{ + static int adc_idx[8] = { + 0, 1, 2, 8, 4, 3, 6, 7 + }; + switch (nid) { + case AD1988_PIN_CD_NID: + return 5; + default: + return adc_idx[ad1988_pin_idx(nid)]; + } +} + +/* fill in the dac_nids table from the parsed pin configuration */ +static int ad1988_auto_fill_dac_nids(struct hda_codec *codec, + const struct auto_pin_cfg *cfg) +{ + struct ad198x_spec *spec = codec->spec; + int i, idx; + + spec->multiout.dac_nids = spec->private_dac_nids; + + /* check the pins hardwired to audio widget */ + for (i = 0; i < cfg->line_outs; i++) { + idx = ad1988_pin_idx(cfg->line_out_pins[i]); + spec->multiout.dac_nids[i] = ad1988_idx_to_dac(codec, idx); + } + spec->multiout.num_dacs = cfg->line_outs; + return 0; +} + +/* add playback controls from the parsed DAC table */ +static int ad1988_auto_create_multi_out_ctls(struct ad198x_spec *spec, + const struct auto_pin_cfg *cfg) +{ + char name[32]; + static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; + hda_nid_t nid; + int i, err; + + for (i = 0; i < cfg->line_outs; i++) { + hda_nid_t dac = spec->multiout.dac_nids[i]; + if (! dac) + continue; + nid = ad1988_mixer_nids[ad1988_pin_idx(cfg->line_out_pins[i])]; + if (i == 2) { + /* Center/LFE */ + err = add_control(spec, AD_CTL_WIDGET_VOL, + "Center Playback Volume", + HDA_COMPOSE_AMP_VAL(dac, 1, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = add_control(spec, AD_CTL_WIDGET_VOL, + "LFE Playback Volume", + HDA_COMPOSE_AMP_VAL(dac, 2, 0, HDA_OUTPUT)); + if (err < 0) + return err; + err = add_control(spec, AD_CTL_BIND_MUTE, + "Center Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT)); + if (err < 0) + return err; + err = add_control(spec, AD_CTL_BIND_MUTE, + "LFE Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT)); + if (err < 0) + return err; + } else { + sprintf(name, "%s Playback Volume", chname[i]); + err = add_control(spec, AD_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT)); + if (err < 0) + return err; + sprintf(name, "%s Playback Switch", chname[i]); + err = add_control(spec, AD_CTL_BIND_MUTE, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT)); + if (err < 0) + return err; + } + } + return 0; +} + +/* add playback controls for speaker and HP outputs */ +static int ad1988_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, + const char *pfx) +{ + struct ad198x_spec *spec = codec->spec; + hda_nid_t nid; + int idx, err; + char name[32]; + + if (! pin) + return 0; + + idx = ad1988_pin_idx(pin); + nid = ad1988_idx_to_dac(codec, idx); + if (! spec->multiout.dac_nids[0]) { + /* use this as the primary output */ + spec->multiout.dac_nids[0] = nid; + if (! spec->multiout.num_dacs) + spec->multiout.num_dacs = 1; + } else + /* specify the DAC as the extra output */ + spec->multiout.hp_nid = nid; + /* control HP volume/switch on the output mixer amp */ + sprintf(name, "%s Playback Volume", pfx); + if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) + return err; + nid = ad1988_mixer_nids[idx]; + sprintf(name, "%s Playback Switch", pfx); + if ((err = add_control(spec, AD_CTL_BIND_MUTE, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0) + return err; + return 0; +} + +/* create input playback/capture controls for the given pin */ +static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, + const char *ctlname, int boost) +{ + char name[32]; + int err, idx; + + sprintf(name, "%s Playback Volume", ctlname); + idx = ad1988_pin_to_loopback_idx(pin); + if ((err = add_control(spec, AD_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) + return err; + sprintf(name, "%s Playback Switch", ctlname); + if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, name, + HDA_COMPOSE_AMP_VAL(0x20, 3, idx, HDA_INPUT))) < 0) + return err; + if (boost) { + hda_nid_t bnid; + idx = ad1988_pin_idx(pin); + bnid = ad1988_boost_nids[idx]; + if (bnid) { + sprintf(name, "%s Boost", ctlname); + return add_control(spec, AD_CTL_WIDGET_VOL, name, + HDA_COMPOSE_AMP_VAL(bnid, 3, idx, HDA_OUTPUT)); + + } + } + return 0; +} + +/* create playback/capture controls for input pins */ +static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, + const struct auto_pin_cfg *cfg) +{ + static char *labels[AUTO_PIN_LAST] = { + "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" + }; + struct hda_input_mux *imux = &spec->private_imux; + int i, err; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + err = new_analog_input(spec, cfg->input_pins[i], labels[i], + i <= AUTO_PIN_FRONT_MIC); + if (err < 0) + return err; + imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); + imux->num_items++; + } + imux->items[imux->num_items].label = "Mix"; + imux->items[imux->num_items].index = 9; + imux->num_items++; + + if ((err = add_control(spec, AD_CTL_WIDGET_VOL, + "Analog Mix Playback Volume", + HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) + return err; + if ((err = add_control(spec, AD_CTL_WIDGET_MUTE, + "Analog Mix Playback Switch", + HDA_COMPOSE_AMP_VAL(0x21, 3, 0x0, HDA_OUTPUT))) < 0) + return err; + + return 0; +} + +static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, + hda_nid_t nid, int pin_type, + int dac_idx) +{ + /* set as output */ + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); + switch (nid) { + case 0x11: /* port-A - DAC 04 */ + snd_hda_codec_write(codec, 0x37, 0, AC_VERB_SET_CONNECT_SEL, 0x01); + break; + case 0x14: /* port-B - DAC 06 */ + snd_hda_codec_write(codec, 0x30, 0, AC_VERB_SET_CONNECT_SEL, 0x02); + break; + case 0x15: /* port-C - DAC 05 */ + snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00); + break; + case 0x17: /* port-E - DAC 06 */ + snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01); + break; + case 0x13: /* mono - DAC 04 */ + snd_hda_codec_write(codec, 0x36, 0, AC_VERB_SET_CONNECT_SEL, 0x01); + break; + } +} + +static void ad1988_auto_init_multi_out(struct hda_codec *codec) +{ + struct ad198x_spec *spec = codec->spec; + int i; + + for (i = 0; i < spec->autocfg.line_outs; i++) { + hda_nid_t nid = spec->autocfg.line_out_pins[i]; + ad1988_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); + } +} + +static void ad1988_auto_init_extra_out(struct hda_codec *codec) +{ + struct ad198x_spec *spec = codec->spec; + hda_nid_t pin; + + pin = spec->autocfg.speaker_pin; + if (pin) /* connect to front */ + ad1988_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); + pin = spec->autocfg.hp_pin; + if (pin) /* connect to front */ + ad1988_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); +} + +static void ad1988_auto_init_analog_input(struct hda_codec *codec) +{ + struct ad198x_spec *spec = codec->spec; + int i, idx; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + hda_nid_t nid = spec->autocfg.input_pins[i]; + if (! nid) + continue; + switch (nid) { + case 0x15: /* port-C */ + snd_hda_codec_write(codec, 0x33, 0, AC_VERB_SET_CONNECT_SEL, 0x0); + break; + case 0x17: /* port-E */ + snd_hda_codec_write(codec, 0x34, 0, AC_VERB_SET_CONNECT_SEL, 0x0); + break; + } + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, + i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); + if (nid != AD1988_PIN_CD_NID) + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_MUTE); + idx = ad1988_pin_idx(nid); + if (ad1988_boost_nids[idx]) + snd_hda_codec_write(codec, ad1988_boost_nids[idx], 0, + AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_ZERO); + } +} + +/* parse the BIOS configuration and set up the alc_spec */ +/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ +static int ad1988_parse_auto_config(struct hda_codec *codec) +{ + struct ad198x_spec *spec = codec->spec; + int err; + + if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) + return err; + if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) + return err; + if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && + ! spec->autocfg.hp_pin) + return 0; /* can't find valid BIOS pin config */ + if ((err = ad1988_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || + (err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin, + "Speaker")) < 0 || + (err = ad1988_auto_create_extra_out(codec, spec->autocfg.speaker_pin, + "Headphone")) < 0 || + (err = ad1988_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) + return err; + + spec->multiout.max_channels = spec->multiout.num_dacs * 2; + + if (spec->autocfg.dig_out_pin) + spec->multiout.dig_out_nid = AD1988_SPDIF_OUT; + if (spec->autocfg.dig_in_pin) + spec->dig_in_nid = AD1988_SPDIF_IN; + + if (spec->kctl_alloc) + spec->mixers[spec->num_mixers++] = spec->kctl_alloc; + + spec->init_verbs[spec->num_init_verbs++] = ad1988_6stack_init_verbs; + + spec->input_mux = &spec->private_imux; + + return 1; +} + +/* init callback for auto-configuration model -- overriding the default init */ +static int ad1988_auto_init(struct hda_codec *codec) +{ + ad198x_init(codec); + ad1988_auto_init_multi_out(codec); + ad1988_auto_init_extra_out(codec); + ad1988_auto_init_analog_input(codec); + return 0; +} + + +/* */ static struct hda_board_config ad1988_cfg_tbl[] = { @@ -1555,6 +2021,7 @@ static struct hda_board_config ad1988_cfg_tbl[] = { { .modelname = "3stack-dig", .config = AD1988_3STACK_DIG }, { .modelname = "laptop", .config = AD1988_LAPTOP }, { .modelname = "laptop-dig", .config = AD1988_LAPTOP_DIG }, + { .modelname = "auto", .config = AD1988_AUTO }, {} }; @@ -1572,8 +2039,20 @@ static int patch_ad1988(struct hda_codec *codec) board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl); if (board_config < 0 || board_config >= AD1988_MODEL_LAST) { - printk(KERN_INFO "hda_codec: Unknown model for AD1988, using 6stack model...\n"); - board_config = AD1988_6STACK; + printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); + board_config = AD1988_AUTO; + } + + if (board_config == AD1988_AUTO) { + /* automatic parse from the BIOS config */ + int err = ad1988_parse_auto_config(codec); + if (err < 0) { + ad198x_free(codec); + return err; + } else if (! err) { + printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 6-stack mode...\n"); + board_config = AD1988_6STACK; + } } switch (board_config) { @@ -1581,13 +2060,17 @@ static int patch_ad1988(struct hda_codec *codec) case AD1988_6STACK_DIG: spec->multiout.max_channels = 8; spec->multiout.num_dacs = 4; - spec->multiout.dac_nids = ad1988_dac_nids; - spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); - spec->adc_nids = ad1988_adc_nids; - spec->capsrc_nids = ad1988_capsrc_nids; + if (codec->revision_id == AD1988A_REV2) + spec->multiout.dac_nids = ad1988_6stack_dac_nids_rev2; + else + spec->multiout.dac_nids = ad1988_6stack_dac_nids; spec->input_mux = &ad1988_6stack_capture_source; - spec->num_mixers = 1; - spec->mixers[0] = ad1988_6stack_mixers; + spec->num_mixers = 2; + if (codec->revision_id == AD1988A_REV2) + spec->mixers[0] = ad1988_6stack_mixers1_rev2; + else + spec->mixers[0] = ad1988_6stack_mixers1; + spec->mixers[1] = ad1988_6stack_mixers2; spec->num_init_verbs = 1; spec->init_verbs[0] = ad1988_6stack_init_verbs; if (board_config == AD1988_6STACK_DIG) { @@ -1599,15 +2082,19 @@ static int patch_ad1988(struct hda_codec *codec) case AD1988_3STACK_DIG: spec->multiout.max_channels = 6; spec->multiout.num_dacs = 3; - spec->multiout.dac_nids = ad1988_dac_nids; - spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); - spec->adc_nids = ad1988_adc_nids; - spec->capsrc_nids = ad1988_capsrc_nids; + if (codec->revision_id == AD1988A_REV2) + spec->multiout.dac_nids = ad1988_3stack_dac_nids_rev2; + else + spec->multiout.dac_nids = ad1988_3stack_dac_nids; spec->input_mux = &ad1988_6stack_capture_source; spec->channel_mode = ad1988_3stack_modes; spec->num_channel_mode = ARRAY_SIZE(ad1988_3stack_modes); - spec->num_mixers = 1; - spec->mixers[0] = ad1988_3stack_mixers; + spec->num_mixers = 2; + if (codec->revision_id == AD1988A_REV2) + spec->mixers[0] = ad1988_3stack_mixers1_rev2; + else + spec->mixers[0] = ad1988_3stack_mixers1; + spec->mixers[1] = ad1988_3stack_mixers2; spec->num_init_verbs = 1; spec->init_verbs[0] = ad1988_3stack_init_verbs; if (board_config == AD1988_3STACK_DIG) @@ -1617,10 +2104,7 @@ static int patch_ad1988(struct hda_codec *codec) case AD1988_LAPTOP_DIG: spec->multiout.max_channels = 2; spec->multiout.num_dacs = 1; - spec->multiout.dac_nids = ad1988_dac_nids; - spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); - spec->adc_nids = ad1988_adc_nids; - spec->capsrc_nids = ad1988_capsrc_nids; + spec->multiout.dac_nids = ad1988_3stack_dac_nids; spec->input_mux = &ad1988_laptop_capture_source; spec->num_mixers = 1; spec->mixers[0] = ad1988_laptop_mixers; @@ -1631,6 +2115,9 @@ static int patch_ad1988(struct hda_codec *codec) break; } + spec->num_adc_nids = ARRAY_SIZE(ad1988_adc_nids); + spec->adc_nids = ad1988_adc_nids; + spec->capsrc_nids = ad1988_capsrc_nids; spec->mixers[spec->num_mixers++] = ad1988_capture_mixers; spec->init_verbs[spec->num_init_verbs++] = ad1988_capture_init_verbs; if (spec->multiout.dig_out_nid) { @@ -1642,6 +2129,9 @@ static int patch_ad1988(struct hda_codec *codec) codec->patch_ops = ad198x_patch_ops; switch (board_config) { + case AD1988_AUTO: + codec->patch_ops.init = ad1988_auto_init; + break; case AD1988_LAPTOP: case AD1988_LAPTOP_DIG: codec->patch_ops.unsol_event = ad1988_laptop_unsol_event; -- cgit v1.1 From f8c7c7b8dd2828b42c1230c6b0235e7d1dcf57e5 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 24 Nov 2005 16:17:20 +0100 Subject: [ALSA] hda-codec - Fix surrounds on 3stack mode of AD1988 Modules: HDA Codec driver Fixed the swapped surround/CLFE on 3stack mode of AD1988. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_analog.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index fabcbcf..fc14415 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -911,7 +911,7 @@ static int patch_ad1981(struct hda_codec *codec) * * DAC assignment * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03 - * 3stack - front/surr/CLFE/opt DACs - 04/0a/05/03 + * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03 * * Inputs of Analog Mix (0x20) * 0:Port-B (front mic) @@ -988,7 +988,7 @@ static hda_nid_t ad1988_6stack_dac_nids[4] = { }; static hda_nid_t ad1988_3stack_dac_nids[3] = { - 0x04, 0x0a, 0x05 + 0x04, 0x05, 0x0a }; /* for AD1988A revision-2, DAC2-4 are swapped */ @@ -997,7 +997,7 @@ static hda_nid_t ad1988_6stack_dac_nids_rev2[4] = { }; static hda_nid_t ad1988_3stack_dac_nids_rev2[3] = { - 0x04, 0x06, 0x0a + 0x04, 0x0a, 0x06 }; static hda_nid_t ad1988_adc_nids[3] = { @@ -1155,9 +1155,9 @@ static struct snd_kcontrol_new ad1988_3stack_mixers1[] = { static struct snd_kcontrol_new ad1988_3stack_mixers1_rev2[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x04, 0x0, HDA_OUTPUT), - HDA_CODEC_VOLUME("Surround Playback Volume", 0x06, 0x0, HDA_OUTPUT), - HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), - HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0a, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Surround Playback Volume", 0x0a, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x06, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x06, 2, 0x0, HDA_OUTPUT), }; static struct snd_kcontrol_new ad1988_3stack_mixers2[] = { @@ -1491,7 +1491,7 @@ static struct hda_verb ad1988_3stack_init_verbs[] = { {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, {0x3c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, - {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x06 */ + {0x32, AC_VERB_SET_CONNECT_SEL, 0x1}, /* output sel: DAC 0x0a */ {0x34, AC_VERB_SET_CONNECT_SEL, 0x0}, /* mute analog mix */ {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, @@ -1657,11 +1657,11 @@ static inline hda_nid_t ad1988_idx_to_dac(struct hda_codec *codec, int idx) { static hda_nid_t idx_to_dac[8] = { /* A B C D E F G H */ - 0x04, 0x06, 0x0a, 0x04, 0x05, 0x06, 0x05, 0x0a + 0x04, 0x06, 0x05, 0x04, 0x0a, 0x06, 0x05, 0x0a }; static hda_nid_t idx_to_dac_rev2[8] = { /* A B C D E F G H */ - 0x04, 0x05, 0x06, 0x04, 0x0a, 0x05, 0x0a, 0x06 + 0x04, 0x05, 0x0a, 0x04, 0x06, 0x05, 0x0a, 0x06 }; if (codec->revision_id == AD1988A_REV2) return idx_to_dac_rev2[idx]; @@ -1898,7 +1898,7 @@ static void ad1988_auto_set_output_and_unmute(struct hda_codec *codec, case 0x15: /* port-C - DAC 05 */ snd_hda_codec_write(codec, 0x31, 0, AC_VERB_SET_CONNECT_SEL, 0x00); break; - case 0x17: /* port-E - DAC 06 */ + case 0x17: /* port-E - DAC 0a */ snd_hda_codec_write(codec, 0x32, 0, AC_VERB_SET_CONNECT_SEL, 0x01); break; case 0x13: /* mono - DAC 04 */ @@ -2037,6 +2037,9 @@ static int patch_ad1988(struct hda_codec *codec) init_MUTEX(&spec->amp_mutex); codec->spec = spec; + if (codec->revision_id == AD1988A_REV2) + snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); + board_config = snd_hda_check_board_config(codec, ad1988_cfg_tbl); if (board_config < 0 || board_config >= AD1988_MODEL_LAST) { printk(KERN_INFO "hda_codec: Unknown model for AD1988, trying auto-probe from BIOS...\n"); -- cgit v1.1 From 16f47bb66000a917a33a0da67ef2823b239c36f6 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Fri, 25 Nov 2005 12:03:20 +0100 Subject: [ALSA] ac97 - Add extra IDs for headphone autosense Modules: AC97 Codec The following patch adds some extra IDs for the list of hardware which should have headphone line sense enabled by default. Signed-off-by: Matthew Garrett Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_patch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index c68ee0f..1b72bc2 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -1639,8 +1639,12 @@ static void check_ad1981_hp_jack_sense(struct snd_ac97 *ac97) { u32 subid = ((u32)ac97->subsystem_vendor << 16) | ac97->subsystem_device; switch (subid) { + case 0x0e11005a: /* HP nc4000/4010 */ case 0x103c0890: /* HP nc6000 */ + case 0x103c0938: /* HP nc4220 */ case 0x103c099c: /* HP nx6110 */ + case 0x103c0944: /* HP nc6220 */ + case 0x103c0934: /* HP nc8220 */ case 0x103c006d: /* HP nx9105 */ case 0x17340088: /* FSC Scenic-W */ /* enable headphone jack sense */ -- cgit v1.1 From 015b6a198f51d660797b78c6c7ee60d0252ebf40 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 28 Nov 2005 10:50:59 +0100 Subject: [ALSA] ens1371: added spdif and lineio module options Modules: ENS1370/1+ driver - spdif module option: some hardware revisions are without spdif output - lineio module option: force shared line in / rear out jack settings Signed-off-by: Jaroslav Kysela --- sound/pci/ens1370.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index ff86fab..856f7c6 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -86,6 +86,8 @@ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ #ifdef SUPPORT_JOYSTICK #ifdef CHIP1371 static int joystick_port[SNDRV_CARDS]; +static int spdif[SNDRV_CARDS]; +static int lineio[SNDRV_CARDS]; #else static int joystick[SNDRV_CARDS]; #endif @@ -101,6 +103,10 @@ MODULE_PARM_DESC(enable, "Enable Ensoniq AudioPCI soundcard."); #ifdef CHIP1371 module_param_array(joystick_port, int, NULL, 0444); MODULE_PARM_DESC(joystick_port, "Joystick port address."); +module_param_array(spdif, int, NULL, 0444); +MODULE_PARM_DESC(spdif, "S/PDIF output (-1 = none, 0 = auto, 1 = force)."); +module_param_array(lineio, int, NULL, 0444); +MODULE_PARM_DESC(lineio, "Line In to Rear Out (0 = auto, 1 = force)."); #else module_param_array(joystick, bool, NULL, 0444); MODULE_PARM_DESC(joystick, "Enable joystick."); @@ -1608,7 +1614,7 @@ static struct { { .vid = PCI_ANY_ID, .did = PCI_ANY_ID } }; -static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq) +static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq, int has_spdif, int has_line) { struct snd_card *card = ensoniq->card; struct snd_ac97_bus *pbus; @@ -1630,12 +1636,15 @@ static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq) if ((err = snd_ac97_mixer(pbus, &ac97, &ensoniq->u.es1371.ac97)) < 0) return err; for (idx = 0; es1371_spdif_present[idx].vid != (unsigned short)PCI_ANY_ID; idx++) - if (ensoniq->pci->vendor == es1371_spdif_present[idx].vid && - ensoniq->pci->device == es1371_spdif_present[idx].did && - ensoniq->rev == es1371_spdif_present[idx].rev) { + if ((ensoniq->pci->vendor == es1371_spdif_present[idx].vid && + ensoniq->pci->device == es1371_spdif_present[idx].did && + ensoniq->rev == es1371_spdif_present[idx].rev) || has_spdif > 0) { struct snd_kcontrol *kctl; int i, index = 0; + if (has_spdif < 0) + break; + ensoniq->spdif_default = ensoniq->spdif_stream = SNDRV_PCM_DEFAULT_CON_SPDIF; outl(ensoniq->spdif_default, ES_REG(ensoniq, CHANNEL_STATUS)); @@ -1664,7 +1673,8 @@ static int snd_ensoniq_1371_mixer(struct ensoniq * ensoniq) if (((ensoniq->subsystem_vendor_id == 0x1274) && (ensoniq->subsystem_device_id == 0x2000)) || /* GA-7DXR */ ((ensoniq->subsystem_vendor_id == 0x1458) && - (ensoniq->subsystem_device_id == 0xa000))) { /* GA-8IEXP */ + (ensoniq->subsystem_device_id == 0xa000)) || /* GA-8IEXP */ + has_line > 0) { err = snd_ctl_add(card, snd_ctl_new1(&snd_ens1373_line, ensoniq)); if (err < 0) return err; @@ -2449,7 +2459,7 @@ static int __devinit snd_audiopci_probe(struct pci_dev *pci, } #endif #ifdef CHIP1371 - if ((err = snd_ensoniq_1371_mixer(ensoniq)) < 0) { + if ((err = snd_ensoniq_1371_mixer(ensoniq, spdif[dev], lineio[dev])) < 0) { snd_card_free(card); return err; } -- cgit v1.1 From 954fa19ab7a14c3f54044780a90cd6a95149f90b Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Tue, 29 Nov 2005 14:46:01 +0100 Subject: [ALSA] hda-intel - Fix HDA probe_mask default Modules: HDA Intel driver The probe_mask module parameter comment notes that the intended default is -1. Fix it to be so, otherwise all codecs are skipped and init fails. Signed-off-by: Matt Porter Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_intel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 8a0a0a7..a983deb 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -52,7 +52,7 @@ static int index = SNDRV_DEFAULT_IDX1; static char *id = SNDRV_DEFAULT_STR1; static char *model; static int position_fix; -static int probe_mask; +static int probe_mask = -1; module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); -- cgit v1.1 From 9056412f21bb6b76ceb98329409a958198b2d591 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Tue, 29 Nov 2005 14:48:41 +0100 Subject: [ALSA] sound: align device drivers menus Modules: Sound Core,Generic drivers AC97 Kconfig entries broke the ALSA device drivers menu, so move them to a location where that won't happen, enabling all device sub-menus to be presented together. Fixed for the latest ALSA tree by Takashi Iwai . Signed-off-by: Randy Dunlap Signed-off-by: Takashi Iwai --- sound/Kconfig | 8 -------- sound/drivers/Kconfig | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sound/Kconfig b/sound/Kconfig index d8f1140..b65ee47 100644 --- a/sound/Kconfig +++ b/sound/Kconfig @@ -48,14 +48,6 @@ config SND For more information, see -config SND_AC97_CODEC - tristate - select SND_PCM - select SND_AC97_BUS - -config SND_AC97_BUS - tristate - source "sound/core/Kconfig" source "sound/drivers/Kconfig" diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig index d008855..395c4ef 100644 --- a/sound/drivers/Kconfig +++ b/sound/drivers/Kconfig @@ -23,6 +23,14 @@ config SND_VX_LIB select SND_HWDEP select SND_PCM +config SND_AC97_CODEC + tristate + select SND_PCM + select SND_AC97_BUS + +config SND_AC97_BUS + tristate + config SND_DUMMY tristate "Dummy (/dev/null) soundcard" -- cgit v1.1 From 403d19446bd0cabee70110415d2f3bc466f46448 Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Tue, 29 Nov 2005 15:00:51 +0100 Subject: [ALSA] hda-codec - update sigmatel support and bug fixes Modules: HDA Codec driver - Explictly set pin control as input for all input pins - Fix bug in 922x mixer (no mute on adc0vol) - Remove broken ch_mode control - Add support for jack retasking mixer controls to use rear line and mic as surround outputs - Add board tables to support autodetect and pin config defaults for systems with broken bioses - Add support for several Intel mobos - Add support for DFI mobo with reference boards attached (gets rid of compile time switch to use reference boards) Signed-off-by: Matt Porter Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_sigmatel.c | 356 +++++++++++++++++++++++------------------ 1 file changed, 200 insertions(+), 156 deletions(-) diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index c8c539c..78662d3 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -4,7 +4,7 @@ * HD audio interface patch for SigmaTel STAC92xx * * Copyright (c) 2005 Embedded Alley Solutions, Inc. - * + * Matt Porter * * Based on patch_cmedia.c and patch_realtek.c * Copyright (c) 2004 Takashi Iwai @@ -34,17 +34,22 @@ #include "hda_codec.h" #include "hda_local.h" -#undef STAC_TEST - #define NUM_CONTROL_ALLOC 32 #define STAC_HP_EVENT 0x37 #define STAC_UNSOL_ENABLE (AC_USRSP_EN | STAC_HP_EVENT) +#define STAC_REF 0 +#define STAC_D945GTP3 1 +#define STAC_D945GTP5 2 + struct sigmatel_spec { struct snd_kcontrol_new *mixers[4]; unsigned int num_mixers; + int board_config; unsigned int surr_switch: 1; + unsigned int line_switch: 1; + unsigned int mic_switch: 1; /* playback */ struct hda_multi_out multiout; @@ -57,12 +62,10 @@ struct sigmatel_spec { unsigned int num_muxes; hda_nid_t dig_in_nid; -#ifdef STAC_TEST /* pin widgets */ hda_nid_t *pin_nids; unsigned int num_pins; unsigned int *pin_configs; -#endif /* codec specific stuff */ struct hda_verb *init; @@ -72,9 +75,8 @@ struct sigmatel_spec { struct hda_input_mux *input_mux; unsigned int cur_mux[2]; - /* channel mode */ - unsigned int num_ch_modes; - unsigned int cur_ch_mode; + /* i/o switches */ + unsigned int io_switch[2]; struct hda_pcm pcm_rec[2]; /* PCM information */ @@ -105,7 +107,6 @@ static hda_nid_t stac922x_mux_nids[2] = { 0x12, 0x13, }; -#ifdef STAC_TEST static hda_nid_t stac9200_pin_nids[8] = { 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, }; @@ -114,7 +115,6 @@ static hda_nid_t stac922x_pin_nids[10] = { 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x15, 0x1b, }; -#endif static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { @@ -155,49 +155,6 @@ static struct hda_verb stac922x_core_init[] = { {} }; -static int stac922x_channel_modes[3] = {2, 6, 8}; - -static int stac922x_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) -{ - struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - struct sigmatel_spec *spec = codec->spec; - - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; - uinfo->value.enumerated.items = spec->num_ch_modes; - if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) - uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; - sprintf(uinfo->value.enumerated.name, "%dch", - stac922x_channel_modes[uinfo->value.enumerated.item]); - return 0; -} - -static int stac922x_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) -{ - struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - struct sigmatel_spec *spec = codec->spec; - - ucontrol->value.enumerated.item[0] = spec->cur_ch_mode; - return 0; -} - -static int stac922x_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) -{ - struct hda_codec *codec = snd_kcontrol_chip(kcontrol); - struct sigmatel_spec *spec = codec->spec; - - if (ucontrol->value.enumerated.item[0] >= spec->num_ch_modes) - ucontrol->value.enumerated.item[0] = spec->num_ch_modes; - if (ucontrol->value.enumerated.item[0] == spec->cur_ch_mode && - ! codec->in_resume) - return 0; - - spec->cur_ch_mode = ucontrol->value.enumerated.item[0]; - spec->multiout.max_channels = stac922x_channel_modes[spec->cur_ch_mode]; - - return 1; -} - static struct snd_kcontrol_new stac9200_mixer[] = { HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT), HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT), @@ -226,22 +183,10 @@ static struct snd_kcontrol_new stac922x_mixer[] = { .put = stac92xx_mux_enum_put, }, HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT), - HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT), HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT), { } /* end */ }; -static struct snd_kcontrol_new stac922x_ch_mode_mixer[] = { - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Channel Mode", - .info = stac922x_ch_mode_info, - .get = stac922x_ch_mode_get, - .put = stac922x_ch_mode_put, - }, - { } /* end */ -}; - static int stac92xx_build_controls(struct hda_codec *codec) { struct sigmatel_spec *spec = codec->spec; @@ -258,11 +203,6 @@ static int stac92xx_build_controls(struct hda_codec *codec) return err; } - if (spec->surr_switch) { - err = snd_hda_add_new_ctls(codec, stac922x_ch_mode_mixer); - if (err < 0) - return err; - } if (spec->multiout.dig_out_nid) { err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); if (err < 0) @@ -276,18 +216,67 @@ static int stac92xx_build_controls(struct hda_codec *codec) return 0; } -#ifdef STAC_TEST -static unsigned int stac9200_pin_configs[8] = { +static unsigned int ref9200_pin_configs[8] = { 0x01c47010, 0x01447010, 0x0221401f, 0x01114010, 0x02a19020, 0x01a19021, 0x90100140, 0x01813122, }; -static unsigned int stac922x_pin_configs[10] = { - 0x01014010, 0x01014011, 0x01014012, 0x0221401f, - 0x01813122, 0x01014014, 0x01441030, 0x01c41030, +static unsigned int *stac9200_brd_tbl[] = { + ref9200_pin_configs, +}; + +static struct hda_board_config stac9200_cfg_tbl[] = { + { .modelname = "ref", + .pci_subvendor = PCI_VENDOR_ID_INTEL, + .pci_subdevice = 0x2668, /* DFI LanParty */ + .config = STAC_REF }, + {} /* terminator */ +}; + +static unsigned int ref922x_pin_configs[10] = { + 0x01014010, 0x01016011, 0x01012012, 0x0221401f, + 0x01813122, 0x01011014, 0x01441030, 0x01c41030, 0x40000100, 0x40000100, }; +static unsigned int d945gtp3_pin_configs[10] = { + 0x0221401f, 0x01a19022, 0x01813021, 0x01114010, + 0x40000100, 0x40000100, 0x40000100, 0x40000100, + 0x02a19120, 0x40000100, +}; + +static unsigned int d945gtp5_pin_configs[10] = { + 0x0221401f, 0x01111012, 0x01813024, 0x01114010, + 0x01a19021, 0x01116011, 0x01452130, 0x40000100, + 0x02a19320, 0x40000100, +}; + +static unsigned int *stac922x_brd_tbl[] = { + ref922x_pin_configs, + d945gtp3_pin_configs, + d945gtp5_pin_configs, +}; + +static struct hda_board_config stac922x_cfg_tbl[] = { + { .modelname = "ref", + .pci_subvendor = PCI_VENDOR_ID_INTEL, + .pci_subdevice = 0x2668, /* DFI LanParty */ + .config = STAC_REF }, /* SigmaTel reference board */ + { .pci_subvendor = PCI_VENDOR_ID_INTEL, + .pci_subdevice = 0x0101, + .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */ + { .pci_subvendor = PCI_VENDOR_ID_INTEL, + .pci_subdevice = 0x0404, + .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */ + { .pci_subvendor = PCI_VENDOR_ID_INTEL, + .pci_subdevice = 0x0303, + .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */ + { .pci_subvendor = PCI_VENDOR_ID_INTEL, + .pci_subdevice = 0x0013, + .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */ + {} /* terminator */ +}; + static void stac92xx_set_config_regs(struct hda_codec *codec) { int i; @@ -310,10 +299,9 @@ static void stac92xx_set_config_regs(struct hda_codec *codec) pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0, AC_VERB_GET_CONFIG_DEFAULT, 0x00); - printk("pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); + snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg); } } -#endif /* * Analog playback callbacks @@ -326,56 +314,6 @@ static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo, return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream); } -/* - * set up the i/o for analog out - * when the digital out is available, copy the front out to digital out, too. - */ -static int stac92xx_multi_out_analog_prepare(struct hda_codec *codec, struct hda_multi_out *mout, - unsigned int stream_tag, - unsigned int format, - struct snd_pcm_substream *substream) -{ - hda_nid_t *nids = mout->dac_nids; - int chs = substream->runtime->channels; - int i; - - down(&codec->spdif_mutex); - if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { - if (chs == 2 && - snd_hda_is_supported_format(codec, mout->dig_out_nid, format) && - ! (codec->spdif_status & IEC958_AES0_NONAUDIO)) { - mout->dig_out_used = HDA_DIG_ANALOG_DUP; - /* setup digital receiver */ - snd_hda_codec_setup_stream(codec, mout->dig_out_nid, - stream_tag, 0, format); - } else { - mout->dig_out_used = 0; - snd_hda_codec_setup_stream(codec, mout->dig_out_nid, 0, 0, 0); - } - } - up(&codec->spdif_mutex); - - /* front */ - snd_hda_codec_setup_stream(codec, nids[HDA_FRONT], stream_tag, 0, format); - if (mout->hp_nid) - /* headphone out will just decode front left/right (stereo) */ - snd_hda_codec_setup_stream(codec, mout->hp_nid, stream_tag, 0, format); - /* surrounds */ - if (mout->max_channels > 2) - for (i = 1; i < mout->num_dacs; i++) { - if ((mout->max_channels == 6) && (i == 3)) - break; - if (chs >= (i + 1) * 2) /* independent out */ - snd_hda_codec_setup_stream(codec, nids[i], stream_tag, i * 2, - format); - else /* copy front */ - snd_hda_codec_setup_stream(codec, nids[i], stream_tag, 0, - format); - } - return 0; -} - - static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, struct hda_codec *codec, unsigned int stream_tag, @@ -383,8 +321,7 @@ static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo, struct snd_pcm_substream *substream) { struct sigmatel_spec *spec = codec->spec; - return stac92xx_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, - format, substream); + return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream); } static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, @@ -511,14 +448,70 @@ static int stac92xx_build_pcms(struct hda_codec *codec) return 0; } +static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) + +{ + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); +} + +static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 1; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct sigmatel_spec *spec = codec->spec; + int io_idx = kcontrol-> private_value & 0xff; + + ucontrol->value.integer.value[0] = spec->io_switch[io_idx]; + return 0; +} + +static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +{ + struct hda_codec *codec = snd_kcontrol_chip(kcontrol); + struct sigmatel_spec *spec = codec->spec; + hda_nid_t nid = kcontrol->private_value >> 8; + int io_idx = kcontrol-> private_value & 0xff; + unsigned short val = ucontrol->value.integer.value[0]; + + spec->io_switch[io_idx] = val; + + if (val) + stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN); + else + stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_IN_EN); + + return 1; +} + +#define STAC_CODEC_IO_SWITCH(xname, xpval) \ + { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .index = 0, \ + .info = stac92xx_io_switch_info, \ + .get = stac92xx_io_switch_get, \ + .put = stac92xx_io_switch_put, \ + .private_value = xpval, \ + } + + enum { STAC_CTL_WIDGET_VOL, STAC_CTL_WIDGET_MUTE, + STAC_CTL_WIDGET_IO_SWITCH, }; static struct snd_kcontrol_new stac92xx_control_templates[] = { HDA_CODEC_VOLUME(NULL, 0, 0, 0), HDA_CODEC_MUTE(NULL, 0, 0, 0), + STAC_CODEC_IO_SWITCH(NULL, 0), }; /* add dynamic controls */ @@ -550,6 +543,51 @@ static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char return 0; } +/* flag inputs as additional dynamic lineouts */ +static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) +{ + struct sigmatel_spec *spec = codec->spec; + + switch (cfg->line_outs) { + case 3: + /* add line-in as side */ + if (cfg->input_pins[AUTO_PIN_LINE]) { + cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE]; + spec->line_switch = 1; + cfg->line_outs++; + } + break; + case 2: + /* add line-in as clfe and mic as side */ + if (cfg->input_pins[AUTO_PIN_LINE]) { + cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE]; + spec->line_switch = 1; + cfg->line_outs++; + } + if (cfg->input_pins[AUTO_PIN_MIC]) { + cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC]; + spec->mic_switch = 1; + cfg->line_outs++; + } + break; + case 1: + /* add line-in as surr and mic as clfe */ + if (cfg->input_pins[AUTO_PIN_LINE]) { + cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE]; + spec->line_switch = 1; + cfg->line_outs++; + } + if (cfg->input_pins[AUTO_PIN_MIC]) { + cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC]; + spec->mic_switch = 1; + cfg->line_outs++; + } + break; + } + + return 0; +} + /* fill in the dac_nids table from the parsed pin configuration */ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { @@ -578,7 +616,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const int i, err; for (i = 0; i < cfg->line_outs; i++) { - if (! spec->multiout.dac_nids[i]) + if (!spec->multiout.dac_nids[i]) continue; nid = spec->multiout.dac_nids[i]; @@ -609,6 +647,14 @@ static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const } } + if (spec->line_switch) + if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0) + return err; + + if (spec->mic_switch) + if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0) + return err; + return 0; } @@ -666,6 +712,9 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const for (i = 0; i < AUTO_PIN_LAST; i++) { int index = -1; if (cfg->input_pins[i]) { + /* Enable active pin widget as an input */ + stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN); + imux->items[imux->num_items].label = labels[i]; for (j=0; jnum_muxes; j++) { @@ -686,12 +735,6 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const return 0; } -static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) - -{ - snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); -} - static void stac92xx_auto_init_multi_out(struct hda_codec *codec) { struct sigmatel_spec *spec = codec->spec; @@ -720,6 +763,8 @@ static int stac922x_parse_auto_config(struct hda_codec *codec) if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) return err; + if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) + return err; if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) return err; if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin) @@ -731,15 +776,8 @@ static int stac922x_parse_auto_config(struct hda_codec *codec) return err; spec->multiout.max_channels = spec->multiout.num_dacs * 2; - if (spec->multiout.max_channels > 2) { + if (spec->multiout.max_channels > 2) spec->surr_switch = 1; - spec->cur_ch_mode = 1; - spec->num_ch_modes = 2; - if (spec->multiout.max_channels == 8) { - spec->cur_ch_mode++; - spec->num_ch_modes++; - } - } if (spec->autocfg.dig_out_pin) { spec->multiout.dig_out_nid = 0x08; @@ -901,13 +939,16 @@ static int patch_stac9200(struct hda_codec *codec) return -ENOMEM; codec->spec = spec; + spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl); + if (spec->board_config < 0) + snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); + else { + spec->num_pins = 8; + spec->pin_nids = stac9200_pin_nids; + spec->pin_configs = stac9200_brd_tbl[spec->board_config]; + stac92xx_set_config_regs(codec); + } -#ifdef STAC_TEST - spec->pin_nids = stac9200_pin_nids; - spec->num_pins = 8; - spec->pin_configs = stac9200_pin_configs; - stac92xx_set_config_regs(codec); -#endif spec->multiout.max_channels = 2; spec->multiout.num_dacs = 1; spec->multiout.dac_nids = stac9200_dac_nids; @@ -939,13 +980,16 @@ static int patch_stac922x(struct hda_codec *codec) return -ENOMEM; codec->spec = spec; + spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl); + if (spec->board_config < 0) + snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, using BIOS defaults\n"); + else { + spec->num_pins = 10; + spec->pin_nids = stac922x_pin_nids; + spec->pin_configs = stac922x_brd_tbl[spec->board_config]; + stac92xx_set_config_regs(codec); + } -#ifdef STAC_TEST - spec->num_pins = 10; - spec->pin_nids = stac922x_pin_nids; - spec->pin_configs = stac922x_pin_configs; - stac92xx_set_config_regs(codec); -#endif spec->adc_nids = stac922x_adc_nids; spec->mux_nids = stac922x_mux_nids; spec->num_muxes = 2; -- cgit v1.1 From 9d70d91c4663d580bd18317dac3c7dc3bee79480 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 30 Nov 2005 10:12:26 +0100 Subject: [ALSA] ad1848 - Fix compilation without CONFIG_PM Modules: AD1848 driver Fix compilation without CONFIG_PM. Signed-off-by: Takashi Iwai --- sound/isa/ad1848/ad1848_lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c index 83764c9..b78530d 100644 --- a/sound/isa/ad1848/ad1848_lib.c +++ b/sound/isa/ad1848/ad1848_lib.c @@ -932,8 +932,10 @@ int snd_ad1848_create(struct snd_card *card, return err; } +#ifdef CONFIG_PM chip->suspend = snd_ad1848_suspend; chip->resume = snd_ad1848_resume; +#endif *rchip = chip; return 0; -- cgit v1.1 From 7cd01dd840824e7c6023ad1dbfdb94a2183a7adb Mon Sep 17 00:00:00 2001 From: Kyle Moffett Date: Wed, 30 Nov 2005 10:54:28 +0100 Subject: [ALSA] snd_powermac: Add ID for Spring 2005 17' Powerbook Modules: PPC PMAC driver The audio chip in my Spring 2005 17' PowerBook was incorrectly recognized as an AWACS chip. This adds the chip ID to the snd_powermac driver such that it is recognized as a Toonie (I don't know if that's correct, but it's the only one that makes it work at all). and sorts the ID lists numerically. NOTE: This chip is only minimally supported at this point; it has system beep support and very low volume speaker output, and that's about it. Signed-off-by: Kyle Moffett Signed-off-by: Takashi Iwai --- sound/ppc/pmac.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 4f0a420..d70292c 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -973,11 +973,11 @@ static int __init snd_pmac_detect(struct snd_pmac *chip) * single frequency until proper i2s control is implemented */ switch(layout_id) { - case 0x48: - case 0x46: - case 0x33: - case 0x29: case 0x24: + case 0x29: + case 0x33: + case 0x46: + case 0x48: case 0x50: case 0x5c: chip->num_freqs = ARRAY_SIZE(tumbler_freqs); @@ -986,6 +986,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip) chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */ break; case 0x3a: + case 0x40: chip->num_freqs = ARRAY_SIZE(tumbler_freqs); chip->model = PMAC_TOONIE; chip->can_byte_swap = 0; /* FIXME: check this */ -- cgit v1.1 From e28563cceb9f258ebe3c50fc27d8f4ff0ac4bfa4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Dec 2005 10:42:42 +0100 Subject: [ALSA] Optimize for config without PROC_FS Modules: HWDEP Midlevel,ALSA Core,PCM Midlevel,Timer Midlevel Optimize the code when compiled without CONFIG_PROC_FS. Signed-off-by: Takashi Iwai --- include/sound/info.h | 13 ++++-- sound/core/hwdep.c | 33 ++++++++++----- sound/core/info.c | 13 +++--- sound/core/init.c | 59 ++++++++++++++++----------- sound/core/pcm.c | 104 +++++++++++++++++++++++++++++------------------- sound/core/pcm_memory.c | 39 +++++++++++------- sound/core/sound.c | 2 + sound/core/sound_oss.c | 6 +-- sound/core/timer.c | 48 ++++++++++++++-------- 9 files changed, 193 insertions(+), 124 deletions(-) diff --git a/include/sound/info.h b/include/sound/info.h index df03e60..8ea5c74 100644 --- a/include/sound/info.h +++ b/include/sound/info.h @@ -87,8 +87,6 @@ struct snd_info_entry { struct semaphore access; }; -int snd_info_check_reserved_words(const char *str); - #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) int snd_info_minor_register(void); int snd_info_minor_unregister(void); @@ -142,6 +140,7 @@ static inline void snd_info_set_text_ops(struct snd_info_entry *entry, entry->c.text.read = read; } +int snd_info_check_reserved_words(const char *str); #else @@ -164,8 +163,14 @@ static inline int snd_info_card_free(struct snd_card * card) { return 0; } static inline int snd_info_register(struct snd_info_entry * entry) { return 0; } static inline int snd_info_unregister(struct snd_info_entry * entry) { return 0; } -#define snd_card_proc_new(card,name,entryp) 0 /* always success */ -#define snd_info_set_text_ops(entry,private_data,read_size,read) /*NOP*/ +static inline int snd_card_proc_new(struct snd_card *card, const char *name, + struct snd_info_entry **entryp) { return -EINVAL; } +static inline void snd_info_set_text_ops(struct snd_info_entry *entry __attribute__((unused)), + void *private_data, + long read_size, + void (*read)(struct snd_info_entry *, struct snd_info_buffer *)) {} + +static inline int snd_info_check_reserved_words(const char *str) { return 1; } #endif diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index b8c0c8c..618c43b 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -458,6 +458,7 @@ static int snd_hwdep_dev_unregister(struct snd_device *device) return snd_hwdep_free(hwdep); } +#ifdef CONFIG_PROC_FS /* * Info interface */ @@ -477,13 +478,9 @@ static void snd_hwdep_proc_read(struct snd_info_entry *entry, up(®ister_mutex); } -/* - * ENTRY functions - */ +static struct snd_info_entry *snd_hwdep_proc_entry; -static struct snd_info_entry *snd_hwdep_proc_entry = NULL; - -static int __init alsa_hwdep_init(void) +static void __init snd_hwdep_proc_init(void) { struct snd_info_entry *entry; @@ -496,6 +493,25 @@ static int __init alsa_hwdep_init(void) } } snd_hwdep_proc_entry = entry; +} + +static void __exit snd_hwdep_proc_done(void) +{ + snd_info_unregister(snd_hwdep_proc_entry); +} +#else /* !CONFIG_PROC_FS */ +#define snd_hwdep_proc_init() +#define snd_hwdep_proc_done() +#endif /* CONFIG_PROC_FS */ + + +/* + * ENTRY functions + */ + +static int __init alsa_hwdep_init(void) +{ + snd_hwdep_proc_init(); snd_ctl_register_ioctl(snd_hwdep_control_ioctl); snd_ctl_register_ioctl_compat(snd_hwdep_control_ioctl); return 0; @@ -505,10 +521,7 @@ static void __exit alsa_hwdep_exit(void) { snd_ctl_unregister_ioctl(snd_hwdep_control_ioctl); snd_ctl_unregister_ioctl_compat(snd_hwdep_control_ioctl); - if (snd_hwdep_proc_entry) { - snd_info_unregister(snd_hwdep_proc_entry); - snd_hwdep_proc_entry = NULL; - } + snd_hwdep_proc_done(); } module_init(alsa_hwdep_init) diff --git a/sound/core/info.c b/sound/core/info.c index ec3282f..ae88539 100644 --- a/sound/core/info.c +++ b/sound/core/info.c @@ -37,6 +37,8 @@ * */ +#ifdef CONFIG_PROC_FS + int snd_info_check_reserved_words(const char *str) { static char *reserved[] = @@ -66,8 +68,6 @@ int snd_info_check_reserved_words(const char *str) return 1; } -#ifdef CONFIG_PROC_FS - static DECLARE_MUTEX(info_mutex); struct snd_info_private_data { @@ -580,12 +580,10 @@ int __exit snd_info_done(void) snd_info_version_done(); if (snd_proc_root) { #if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE) - if (snd_seq_root) - snd_info_unregister(snd_seq_root); + snd_info_unregister(snd_seq_root); #endif #ifdef CONFIG_SND_OSSEMUL - if (snd_oss_root) - snd_info_unregister(snd_oss_root); + snd_info_unregister(snd_oss_root); #endif snd_remove_proc_entry(&proc_root, snd_proc_root); } @@ -937,7 +935,8 @@ int snd_info_unregister(struct snd_info_entry * entry) { struct proc_dir_entry *root; - snd_assert(entry != NULL, return -ENXIO); + if (! entry) + return 0; snd_assert(entry->p != NULL, return -ENXIO); root = entry->parent == NULL ? snd_proc_root : entry->parent->p; snd_assert(root, return -ENXIO); diff --git a/sound/core/init.c b/sound/core/init.c index 58e17d3..7581668 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -46,12 +46,39 @@ DEFINE_RWLOCK(snd_card_rwlock); int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag); #endif +#ifdef CONFIG_PROC_FS static void snd_card_id_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { snd_iprintf(buffer, "%s\n", entry->card->id); } +static inline int init_info_for_card(struct snd_card *card) +{ + int err; + struct snd_info_entry *entry; + + if ((err = snd_info_card_register(card)) < 0) { + snd_printd("unable to create card info\n"); + return err; + } + if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) { + snd_printd("unable to create card entry\n"); + return err; + } + entry->c.text.read_size = PAGE_SIZE; + entry->c.text.read = snd_card_id_read; + if (snd_info_register(entry) < 0) { + snd_info_free_entry(entry); + entry = NULL; + } + card->proc_id = entry; + return 0; +} +#else /* !CONFIG_PROC_FS */ +#define init_info_for_card(card) +#endif + static void snd_card_free_thread(void * __card); /** @@ -273,8 +300,7 @@ int snd_card_free(struct snd_card *card) } if (card->private_free) card->private_free(card); - if (card->proc_id) - snd_info_unregister(card->proc_id); + snd_info_unregister(card->proc_id); if (snd_info_card_free(card) < 0) { snd_printk(KERN_WARNING "unable to free card info\n"); /* Not fatal error */ @@ -414,7 +440,6 @@ static void choose_default_id(struct snd_card *card) int snd_card_register(struct snd_card *card) { int err; - struct snd_info_entry *entry; snd_assert(card != NULL, return -EINVAL); if ((err = snd_device_register_all(card)) < 0) @@ -429,22 +454,7 @@ int snd_card_register(struct snd_card *card) choose_default_id(card); snd_cards[card->number] = card; write_unlock(&snd_card_rwlock); - if ((err = snd_info_card_register(card)) < 0) { - snd_printd("unable to create card info\n"); - goto __skip_info; - } - if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) { - snd_printd("unable to create card entry\n"); - goto __skip_info; - } - entry->c.text.read_size = PAGE_SIZE; - entry->c.text.read = snd_card_id_read; - if (snd_info_register(entry) < 0) { - snd_info_free_entry(entry); - entry = NULL; - } - card->proc_id = entry; - __skip_info: + init_info_for_card(card); #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) if (snd_mixer_oss_notify_callback) snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); @@ -452,6 +462,7 @@ int snd_card_register(struct snd_card *card) return 0; } +#ifdef CONFIG_PROC_FS static struct snd_info_entry *snd_card_info_entry = NULL; static void snd_card_info_read(struct snd_info_entry *entry, @@ -478,7 +489,7 @@ static void snd_card_info_read(struct snd_info_entry *entry, snd_iprintf(buffer, "--- no soundcards ---\n"); } -#if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS) +#ifdef CONFIG_SND_OSSEMUL void snd_card_info_read_oss(struct snd_info_buffer *buffer) { @@ -550,15 +561,15 @@ int __init snd_card_info_init(void) int __exit snd_card_info_done(void) { - if (snd_card_info_entry) - snd_info_unregister(snd_card_info_entry); + snd_info_unregister(snd_card_info_entry); #ifdef MODULE - if (snd_card_module_info_entry) - snd_info_unregister(snd_card_module_info_entry); + snd_info_unregister(snd_card_module_info_entry); #endif return 0; } +#endif /* CONFIG_PROC_FS */ + /** * snd_component_add - add a component string * @card: soundcard structure diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 95036c8..28ca61eb 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -151,30 +151,6 @@ static int snd_pcm_control_ioctl(struct snd_card *card, #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v -static char *snd_pcm_stream_names[] = { - STREAM(PLAYBACK), - STREAM(CAPTURE), -}; - -static char *snd_pcm_state_names[] = { - STATE(OPEN), - STATE(SETUP), - STATE(PREPARED), - STATE(RUNNING), - STATE(XRUN), - STATE(DRAINING), - STATE(PAUSED), - STATE(SUSPENDED), -}; - -static char *snd_pcm_access_names[] = { - ACCESS(MMAP_INTERLEAVED), - ACCESS(MMAP_NONINTERLEAVED), - ACCESS(MMAP_COMPLEX), - ACCESS(RW_INTERLEAVED), - ACCESS(RW_NONINTERLEAVED), -}; - static char *snd_pcm_format_names[] = { FORMAT(S8), FORMAT(U8), @@ -216,6 +192,36 @@ static char *snd_pcm_format_names[] = { FORMAT(U18_3BE), }; +const char *snd_pcm_format_name(snd_pcm_format_t format) +{ + return snd_pcm_format_names[format]; +} + +#ifdef CONFIG_PROC_FS +static char *snd_pcm_stream_names[] = { + STREAM(PLAYBACK), + STREAM(CAPTURE), +}; + +static char *snd_pcm_state_names[] = { + STATE(OPEN), + STATE(SETUP), + STATE(PREPARED), + STATE(RUNNING), + STATE(XRUN), + STATE(DRAINING), + STATE(PAUSED), + STATE(SUSPENDED), +}; + +static char *snd_pcm_access_names[] = { + ACCESS(MMAP_INTERLEAVED), + ACCESS(MMAP_NONINTERLEAVED), + ACCESS(MMAP_COMPLEX), + ACCESS(RW_INTERLEAVED), + ACCESS(RW_NONINTERLEAVED), +}; + static char *snd_pcm_subformat_names[] = { SUBFORMAT(STD), }; @@ -236,11 +242,6 @@ static const char *snd_pcm_access_name(snd_pcm_access_t access) return snd_pcm_access_names[access]; } -const char *snd_pcm_format_name(snd_pcm_format_t format) -{ - return snd_pcm_format_names[format]; -} - static const char *snd_pcm_subformat_name(snd_pcm_subformat_t subformat) { return snd_pcm_subformat_names[subformat]; @@ -288,7 +289,6 @@ static const char *snd_pcm_oss_format_name(int format) } #endif -#ifdef CONFIG_PROC_FS static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream, struct snd_info_buffer *buffer) { @@ -431,7 +431,6 @@ static void snd_pcm_substream_proc_status_read(struct snd_info_entry *entry, snd_iprintf(buffer, "hw_ptr : %ld\n", runtime->status->hw_ptr); snd_iprintf(buffer, "appl_ptr : %ld\n", runtime->control->appl_ptr); } -#endif #ifdef CONFIG_SND_DEBUG static void snd_pcm_xrun_debug_read(struct snd_info_entry *entry, @@ -596,6 +595,12 @@ static int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) } return 0; } +#else /* !CONFIG_PROC_FS */ +static inline int snd_pcm_stream_proc_init(struct snd_pcm_str *pstr) { return 0; } +static inline int snd_pcm_stream_proc_done(struct snd_pcm_str *pstr) { return 0; } +static inline int snd_pcm_substream_proc_init(struct snd_pcm_substream *substream) { return 0; } +static inline int snd_pcm_substream_proc_done(struct snd_pcm_substream *substream) { return 0; } +#endif /* CONFIG_PROC_FS */ /** * snd_pcm_new_stream - create a new PCM stream @@ -1013,6 +1018,7 @@ int snd_pcm_notify(struct snd_pcm_notify *notify, int nfree) return 0; } +#ifdef CONFIG_PROC_FS /* * Info interface */ @@ -1039,18 +1045,12 @@ static void snd_pcm_proc_read(struct snd_info_entry *entry, up(®ister_mutex); } -/* - * ENTRY functions - */ - static struct snd_info_entry *snd_pcm_proc_entry = NULL; -static int __init alsa_pcm_init(void) +static void snd_pcm_proc_init(void) { struct snd_info_entry *entry; - snd_ctl_register_ioctl(snd_pcm_control_ioctl); - snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl); if ((entry = snd_info_create_module_entry(THIS_MODULE, "pcm", NULL)) != NULL) { snd_info_set_text_ops(entry, NULL, SNDRV_CARDS * SNDRV_PCM_DEVICES * 128, snd_pcm_proc_read); @@ -1060,6 +1060,29 @@ static int __init alsa_pcm_init(void) } } snd_pcm_proc_entry = entry; +} + +static void snd_pcm_proc_done(void) +{ + if (snd_pcm_proc_entry) + snd_info_unregister(snd_pcm_proc_entry); +} + +#else /* !CONFIG_PROC_FS */ +#define snd_pcm_proc_init() +#define snd_pcm_proc_done() +#endif /* CONFIG_PROC_FS */ + + +/* + * ENTRY functions + */ + +static int __init alsa_pcm_init(void) +{ + snd_ctl_register_ioctl(snd_pcm_control_ioctl); + snd_ctl_register_ioctl_compat(snd_pcm_control_ioctl); + snd_pcm_proc_init(); return 0; } @@ -1067,10 +1090,7 @@ static void __exit alsa_pcm_exit(void) { snd_ctl_unregister_ioctl(snd_pcm_control_ioctl); snd_ctl_unregister_ioctl_compat(snd_pcm_control_ioctl); - if (snd_pcm_proc_entry) { - snd_info_unregister(snd_pcm_proc_entry); - snd_pcm_proc_entry = NULL; - } + snd_pcm_proc_done(); } module_init(alsa_pcm_init) diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index d37bcb7..a0119ae 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -100,10 +100,8 @@ static void snd_pcm_lib_preallocate_dma_free(struct snd_pcm_substream *substream int snd_pcm_lib_preallocate_free(struct snd_pcm_substream *substream) { snd_pcm_lib_preallocate_dma_free(substream); - if (substream->proc_prealloc_entry) { - snd_info_unregister(substream->proc_prealloc_entry); - substream->proc_prealloc_entry = NULL; - } + snd_info_unregister(substream->proc_prealloc_entry); + substream->proc_prealloc_entry = NULL; return 0; } @@ -126,6 +124,7 @@ int snd_pcm_lib_preallocate_free_for_all(struct snd_pcm *pcm) return 0; } +#ifdef CONFIG_PROC_FS /* * read callback for prealloc proc file * @@ -185,20 +184,10 @@ static void snd_pcm_lib_preallocate_proc_write(struct snd_info_entry *entry, } } -/* - * pre-allocate the buffer and create a proc file for the substream - */ -static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream, - size_t size, size_t max) +static inline void preallocate_info_init(struct snd_pcm_substream *substream) { struct snd_info_entry *entry; - if (size > 0 && preallocate_dma && substream->number < maximum_substreams) - preallocate_pcm_pages(substream, size); - - if (substream->dma_buffer.bytes > 0) - substream->buffer_bytes_max = substream->dma_buffer.bytes; - substream->dma_max = max; if ((entry = snd_info_create_card_entry(substream->pcm->card, "prealloc", substream->proc_root)) != NULL) { entry->c.text.read_size = 64; entry->c.text.read = snd_pcm_lib_preallocate_proc_read; @@ -212,6 +201,26 @@ static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream, } } substream->proc_prealloc_entry = entry; +} + +#else /* !CONFIG_PROC_FS */ +#define preallocate_info_init(s) +#endif + +/* + * pre-allocate the buffer and create a proc file for the substream + */ +static int snd_pcm_lib_preallocate_pages1(struct snd_pcm_substream *substream, + size_t size, size_t max) +{ + + if (size > 0 && preallocate_dma && substream->number < maximum_substreams) + preallocate_pcm_pages(substream, size); + + if (substream->dma_buffer.bytes > 0) + substream->buffer_bytes_max = substream->dma_buffer.bytes; + substream->dma_max = max; + preallocate_info_init(substream); return 0; } diff --git a/sound/core/sound.c b/sound/core/sound.c index 3b91f18..a8eda02 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -320,6 +320,7 @@ int snd_unregister_device(int type, struct snd_card *card, int dev) return 0; } +#ifdef CONFIG_PROC_FS /* * INFO PART */ @@ -396,6 +397,7 @@ int __exit snd_minor_info_done(void) snd_info_unregister(snd_minor_info_entry); return 0; } +#endif /* CONFIG_PROC_FS */ /* * INIT PART diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c index 3ae1c0d..d0be32b 100644 --- a/sound/core/sound_oss.c +++ b/sound/core/sound_oss.c @@ -244,11 +244,9 @@ static void snd_minor_info_oss_read(struct snd_info_entry *entry, up(&sound_oss_mutex); } -#endif /* CONFIG_PROC_FS */ int __init snd_minor_info_oss_init(void) { -#ifdef CONFIG_PROC_FS struct snd_info_entry *entry; entry = snd_info_create_module_entry(THIS_MODULE, "devices", snd_oss_root); @@ -261,17 +259,15 @@ int __init snd_minor_info_oss_init(void) } } snd_minor_info_oss_entry = entry; -#endif return 0; } int __exit snd_minor_info_oss_done(void) { -#ifdef CONFIG_PROC_FS if (snd_minor_info_oss_entry) snd_info_unregister(snd_minor_info_oss_entry); -#endif return 0; } +#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_SND_OSSEMUL */ diff --git a/sound/core/timer.c b/sound/core/timer.c index c62dbac..2425b97 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -1052,6 +1052,7 @@ static int snd_timer_register_system(void) return snd_timer_global_register(timer); } +#ifdef CONFIG_PROC_FS /* * Info interface */ @@ -1107,6 +1108,33 @@ static void snd_timer_proc_read(struct snd_info_entry *entry, up(®ister_mutex); } +static struct snd_info_entry *snd_timer_proc_entry = NULL; + +static void __init snd_timer_proc_init(void) +{ + struct snd_info_entry *entry; + + entry = snd_info_create_module_entry(THIS_MODULE, "timers", NULL); + if (entry != NULL) { + entry->c.text.read_size = SNDRV_TIMER_DEVICES * 128; + entry->c.text.read = snd_timer_proc_read; + if (snd_info_register(entry) < 0) { + snd_info_free_entry(entry); + entry = NULL; + } + } + snd_timer_proc_entry = entry; +} + +static void __exit snd_timer_proc_done(void) +{ + snd_info_unregister(snd_timer_proc_entry); +} +#else /* !CONFIG_PROC_FS */ +#define snd_timer_proc_init() +#define snd_timer_proc_done() +#endif + /* * USER SPACE interface */ @@ -1928,27 +1956,15 @@ static struct file_operations snd_timer_f_ops = * ENTRY functions */ -static struct snd_info_entry *snd_timer_proc_entry = NULL; - static int __init alsa_timer_init(void) { int err; - struct snd_info_entry *entry; #ifdef SNDRV_OSS_INFO_DEV_TIMERS snd_oss_info_register(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1, "system timer"); #endif - entry = snd_info_create_module_entry(THIS_MODULE, "timers", NULL); - if (entry != NULL) { - entry->c.text.read_size = SNDRV_TIMER_DEVICES * 128; - entry->c.text.read = snd_timer_proc_read; - if (snd_info_register(entry) < 0) { - snd_info_free_entry(entry); - entry = NULL; - } - } - snd_timer_proc_entry = entry; + if ((err = snd_timer_register_system()) < 0) snd_printk(KERN_ERR "unable to register system timer (%i)\n", err); @@ -1956,6 +1972,7 @@ static int __init alsa_timer_init(void) &snd_timer_f_ops, NULL, "timer")) < 0) snd_printk(KERN_ERR "unable to register timer device (%i)\n", err); + snd_timer_proc_init(); return 0; } @@ -1969,10 +1986,7 @@ static void __exit alsa_timer_exit(void) struct snd_timer *timer = list_entry(p, struct snd_timer, device_list); snd_timer_unregister(timer); } - if (snd_timer_proc_entry) { - snd_info_unregister(snd_timer_proc_entry); - snd_timer_proc_entry = NULL; - } + snd_timer_proc_done(); #ifdef SNDRV_OSS_INFO_DEV_TIMERS snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_TIMERS, SNDRV_CARDS - 1); #endif -- cgit v1.1 From 04f141a8800d022981f0405a8d307c98aba55105 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Dec 2005 10:43:51 +0100 Subject: [ALSA] Optimize for config without PROC_FS (seq and oss parts) Modules: ALSA<-OSS emulation,ALSA sequencer,ALSA<-OSS sequencer Optimize the code when compiled without CONFIG_PROC_FS (in seq and oss emulation parts). Signed-off-by: Takashi Iwai --- sound/core/oss/mixer_oss.c | 5 +++++ sound/core/oss/pcm_oss.c | 5 +++++ sound/core/seq/oss/seq_oss.c | 14 ++++++-------- sound/core/seq/oss/seq_oss_init.c | 3 ++- sound/core/seq/oss/seq_oss_midi.c | 3 ++- sound/core/seq/oss/seq_oss_readq.c | 2 ++ sound/core/seq/oss/seq_oss_synth.c | 3 ++- sound/core/seq/seq_clientmgr.c | 3 ++- sound/core/seq/seq_device.c | 8 ++++++++ sound/core/seq/seq_info.c | 13 +++++-------- sound/core/seq/seq_info.h | 6 +++++- sound/core/seq/seq_queue.c | 3 +++ sound/core/seq/seq_timer.c | 3 +++ 13 files changed, 50 insertions(+), 21 deletions(-) diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 2d7a420..f08e65a 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -1053,6 +1053,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mix return 0; } +#ifdef CONFIG_PROC_FS /* */ #define MIXER_VOL(name) [SOUND_MIXER_##name] = #name @@ -1200,6 +1201,10 @@ static void snd_mixer_oss_proc_done(struct snd_mixer_oss *mixer) mixer->proc_entry = NULL; } } +#else /* !CONFIG_PROC_FS */ +#define snd_mixer_oss_proc_init(mix) +#define snd_mixer_oss_proc_done(mix) +#endif /* CONFIG_PROC_FS */ static void snd_mixer_oss_build(struct snd_mixer_oss *mixer) { diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c index 2ae283c..16df124 100644 --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -2269,6 +2269,7 @@ static int snd_pcm_oss_mmap(struct file *file, struct vm_area_struct *area) return 0; } +#ifdef CONFIG_PROC_FS /* * /proc interface */ @@ -2420,6 +2421,10 @@ static void snd_pcm_oss_proc_done(struct snd_pcm *pcm) } } } +#else /* !CONFIG_PROC_FS */ +#define snd_pcm_oss_proc_init(pcm) +#define snd_pcm_oss_proc_done(pcm) +#endif /* CONFIG_PROC_FS */ /* * ENTRY functions diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c index 4b51ab5..c98f0ba 100644 --- a/sound/core/seq/oss/seq_oss.c +++ b/sound/core/seq/oss/seq_oss.c @@ -52,8 +52,13 @@ int seq_oss_debug = 0; */ static int register_device(void); static void unregister_device(void); +#ifdef CONFIG_PROC_FS static int register_proc(void); static void unregister_proc(void); +#else +static inline int register_proc(void) { return 0; } +static inline void unregister_proc(void) {} +#endif static int odev_open(struct inode *inode, struct file *file); static int odev_release(struct inode *inode, struct file *file); @@ -61,9 +66,6 @@ static ssize_t odev_read(struct file *file, char __user *buf, size_t count, loff static ssize_t odev_write(struct file *file, const char __user *buf, size_t count, loff_t *offset); static long odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg); static unsigned int odev_poll(struct file *file, poll_table * wait); -#ifdef CONFIG_PROC_FS -static void info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf); -#endif /* @@ -276,12 +278,10 @@ info_read(struct snd_info_entry *entry, struct snd_info_buffer *buf) up(®ister_mutex); } -#endif /* CONFIG_PROC_FS */ static int __init register_proc(void) { -#ifdef CONFIG_PROC_FS struct snd_info_entry *entry; entry = snd_info_create_module_entry(THIS_MODULE, SNDRV_SEQ_OSS_PROCNAME, snd_seq_root); @@ -297,16 +297,14 @@ register_proc(void) return -ENOMEM; } info_entry = entry; -#endif return 0; } static void unregister_proc(void) { -#ifdef CONFIG_PROC_FS if (info_entry) snd_info_unregister(info_entry); info_entry = NULL; -#endif } +#endif /* CONFIG_PROC_FS */ diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index 1d4473e..97e2493 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c @@ -502,6 +502,7 @@ snd_seq_oss_reset(struct seq_oss_devinfo *dp) } +#ifdef CONFIG_PROC_FS /* * misc. functions for proc interface */ @@ -552,4 +553,4 @@ snd_seq_oss_system_info_read(struct snd_info_buffer *buf) snd_seq_oss_readq_info_read(dp->readq, buf); } } - +#endif /* CONFIG_PROC_FS */ diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c index eb7ae99..0a711d2 100644 --- a/sound/core/seq/oss/seq_oss_midi.c +++ b/sound/core/seq/oss/seq_oss_midi.c @@ -668,6 +668,7 @@ snd_seq_oss_midi_make_info(struct seq_oss_devinfo *dp, int dev, struct midi_info } +#ifdef CONFIG_PROC_FS /* * proc interface */ @@ -707,4 +708,4 @@ snd_seq_oss_midi_info_read(struct snd_info_buffer *buf) snd_use_lock_free(&mdev->use_lock); } } - +#endif /* CONFIG_PROC_FS */ diff --git a/sound/core/seq/oss/seq_oss_readq.c b/sound/core/seq/oss/seq_oss_readq.c index abc7007..f5de79f 100644 --- a/sound/core/seq/oss/seq_oss_readq.c +++ b/sound/core/seq/oss/seq_oss_readq.c @@ -222,6 +222,7 @@ snd_seq_oss_readq_put_timestamp(struct seq_oss_readq *q, unsigned long curt, int } +#ifdef CONFIG_PROC_FS /* * proc interface */ @@ -232,3 +233,4 @@ snd_seq_oss_readq_info_read(struct seq_oss_readq *q, struct snd_info_buffer *buf (waitqueue_active(&q->midi_sleep) ? "sleeping":"running"), q->qlen, q->input_time); } +#endif /* CONFIG_PROC_FS */ diff --git a/sound/core/seq/oss/seq_oss_synth.c b/sound/core/seq/oss/seq_oss_synth.c index 0b6025c..ab570a0 100644 --- a/sound/core/seq/oss/seq_oss_synth.c +++ b/sound/core/seq/oss/seq_oss_synth.c @@ -621,6 +621,7 @@ snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_in } +#ifdef CONFIG_PROC_FS /* * proc interface */ @@ -648,4 +649,4 @@ snd_seq_oss_synth_info_read(struct snd_info_buffer *buf) snd_use_lock_free(&rec->use_lock); } } - +#endif /* CONFIG_PROC_FS */ diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 2a9c6b3..9c32fd2 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2413,6 +2413,7 @@ int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table /*---------------------------------------------------------------------------*/ +#ifdef CONFIG_PROC_FS /* * /proc interface */ @@ -2518,7 +2519,7 @@ void snd_seq_info_clients_read(struct snd_info_entry *entry, snd_seq_client_unlock(client); } } - +#endif /* CONFIG_PROC_FS */ /*---------------------------------------------------------------------------*/ diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c index 3f935a1..9ece443 100644 --- a/sound/core/seq/seq_device.c +++ b/sound/core/seq/seq_device.c @@ -78,7 +78,9 @@ struct ops_list { static LIST_HEAD(opslist); static int num_ops; static DECLARE_MUTEX(ops_mutex); +#ifdef CONFIG_PROC_FS static struct snd_info_entry *info_entry = NULL; +#endif /* * prototypes @@ -100,6 +102,7 @@ static void remove_drivers(void); * show all drivers and their status */ +#ifdef CONFIG_PROC_FS static void snd_seq_device_info(struct snd_info_entry *entry, struct snd_info_buffer *buffer) { @@ -117,6 +120,7 @@ static void snd_seq_device_info(struct snd_info_entry *entry, } up(&ops_mutex); } +#endif /* * load all registered drivers (called from seq_clientmgr.c) @@ -544,6 +548,7 @@ static void unlock_driver(struct ops_list *ops) static int __init alsa_seq_device_init(void) { +#ifdef CONFIG_PROC_FS info_entry = snd_info_create_module_entry(THIS_MODULE, "drivers", snd_seq_root); if (info_entry == NULL) @@ -555,13 +560,16 @@ static int __init alsa_seq_device_init(void) snd_info_free_entry(info_entry); return -ENOMEM; } +#endif return 0; } static void __exit alsa_seq_device_exit(void) { remove_drivers(); +#ifdef CONFIG_PROC_FS snd_info_unregister(info_entry); +#endif if (num_ops) snd_printk(KERN_ERR "drivers not released (%d)\n", num_ops); } diff --git a/sound/core/seq/seq_info.c b/sound/core/seq/seq_info.c index 3257cf4..acce21a 100644 --- a/sound/core/seq/seq_info.c +++ b/sound/core/seq/seq_info.c @@ -27,7 +27,7 @@ #include "seq_clientmgr.h" #include "seq_timer.h" - +#ifdef CONFIG_PROC_FS static struct snd_info_entry *queues_entry; static struct snd_info_entry *clients_entry; static struct snd_info_entry *timer_entry; @@ -52,7 +52,6 @@ create_info_entry(char *name, int size, void (*read)(struct snd_info_entry *, return entry; } - /* create all our /proc entries */ int __init snd_seq_info_init(void) { @@ -66,11 +65,9 @@ int __init snd_seq_info_init(void) int __exit snd_seq_info_done(void) { - if (queues_entry) - snd_info_unregister(queues_entry); - if (clients_entry) - snd_info_unregister(clients_entry); - if (timer_entry) - snd_info_unregister(timer_entry); + snd_info_unregister(queues_entry); + snd_info_unregister(clients_entry); + snd_info_unregister(timer_entry); return 0; } +#endif diff --git a/sound/core/seq/seq_info.h b/sound/core/seq/seq_info.h index 5a91ebc..4892a7f 100644 --- a/sound/core/seq/seq_info.h +++ b/sound/core/seq/seq_info.h @@ -29,8 +29,12 @@ void snd_seq_info_timer_read(struct snd_info_entry *entry, struct snd_info_buffe void snd_seq_info_queues_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer); +#ifdef CONFIG_PROC_FS int snd_seq_info_init( void ); int snd_seq_info_done( void ); - +#else +static inline int snd_seq_info_init(void) { return 0; } +static inline int snd_seq_info_done(void) { return 0; } +#endif #endif diff --git a/sound/core/seq/seq_queue.c b/sound/core/seq/seq_queue.c index b537a71..9cf20f0 100644 --- a/sound/core/seq/seq_queue.c +++ b/sound/core/seq/seq_queue.c @@ -756,6 +756,7 @@ int snd_seq_control_queue(struct snd_seq_event *ev, int atomic, int hop) /*----------------------------------------------------------------*/ +#ifdef CONFIG_PROC_FS /* exported to seq_info.c */ void snd_seq_info_queues_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) @@ -789,3 +790,5 @@ void snd_seq_info_queues_read(struct snd_info_entry *entry, queuefree(q); } } +#endif /* CONFIG_PROC_FS */ + diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c index a1d8bfd..b4b9a13 100644 --- a/sound/core/seq/seq_timer.c +++ b/sound/core/seq/seq_timer.c @@ -425,6 +425,7 @@ snd_seq_tick_time_t snd_seq_timer_get_cur_tick(struct snd_seq_timer *tmr) } +#ifdef CONFIG_PROC_FS /* exported to seq_info.c */ void snd_seq_info_timer_read(struct snd_info_entry *entry, struct snd_info_buffer *buffer) @@ -451,3 +452,5 @@ void snd_seq_info_timer_read(struct snd_info_entry *entry, queuefree(q); } } +#endif /* CONFIG_PROC_FS */ + -- cgit v1.1 From 8cb7b63f5baf7b5e788f0d632d5ebd018856416f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Dec 2005 10:48:37 +0100 Subject: [ALSA] dbri - Don't return errors without CONFIG_PROC_FS Modules: SPARC DBRI driver Don't return errors if the proc file can't be created (for the case without CONFIG_PROC_FS). Signed-off-by: Takashi Iwai --- sound/sparc/dbri.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index 293108e..2164b7d 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -2519,15 +2519,15 @@ static void dbri_debug_read(struct snd_info_entry * entry, void snd_dbri_proc(struct snd_dbri * dbri) { struct snd_info_entry *entry; - int err; - err = snd_card_proc_new(dbri->card, "regs", &entry); - snd_info_set_text_ops(entry, dbri, 1024, dbri_regs_read); + if (! snd_card_proc_new(dbri->card, "regs", &entry)) + snd_info_set_text_ops(entry, dbri, 1024, dbri_regs_read); #ifdef DBRI_DEBUG - err = snd_card_proc_new(dbri->card, "debug", &entry); - snd_info_set_text_ops(entry, dbri, 4096, dbri_debug_read); - entry->mode = S_IFREG | S_IRUGO; /* Readable only. */ + if (! snd_card_proc_new(dbri->card, "debug", &entry)) { + snd_info_set_text_ops(entry, dbri, 4096, dbri_debug_read); + entry->mode = S_IFREG | S_IRUGO; /* Readable only. */ + } #endif } -- cgit v1.1 From adf1b3d25e50dbab48fdd21006bea2dd5a4cb3a8 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Dec 2005 10:49:58 +0100 Subject: [ALSA] Optimize for config without PROC_FS (pci drivers) Optimize the code when compiled without CONFIG_PROC_FS for some pci drivers. Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 38 ++----------------------------------- sound/pci/ac97/ac97_local.h | 1 - sound/pci/ac97/ac97_proc.c | 36 +++++++++++++++++++++++++++++++++++ sound/pci/ac97/ak4531_codec.c | 8 +++++++- sound/pci/atiixp.c | 5 ++++- sound/pci/atiixp_modem.c | 5 ++++- sound/pci/ca0106/ca0106_main.c | 2 ++ sound/pci/ca0106/ca0106_proc.c | 3 +++ sound/pci/cs46xx/cs46xx_lib.c | 5 +++++ sound/pci/cs46xx/cs46xx_lib.h | 10 ++++++++++ sound/pci/cs46xx/dsp_spos.c | 2 ++ sound/pci/cs46xx/dsp_spos_scb_lib.c | 4 ++++ sound/pci/emu10k1/emu10k1_main.c | 2 ++ sound/pci/emu10k1/emuproc.c | 2 ++ sound/pci/intel8x0.c | 4 ++++ sound/pci/intel8x0m.c | 5 +++++ 16 files changed, 92 insertions(+), 40 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index abc83fa..17c3dda 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -184,42 +184,6 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = { { 0, 0, NULL, NULL, NULL } }; -const char *snd_ac97_stereo_enhancements[] = -{ - /* 0 */ "No 3D Stereo Enhancement", - /* 1 */ "Analog Devices Phat Stereo", - /* 2 */ "Creative Stereo Enhancement", - /* 3 */ "National Semi 3D Stereo Enhancement", - /* 4 */ "YAMAHA Ymersion", - /* 5 */ "BBE 3D Stereo Enhancement", - /* 6 */ "Crystal Semi 3D Stereo Enhancement", - /* 7 */ "Qsound QXpander", - /* 8 */ "Spatializer 3D Stereo Enhancement", - /* 9 */ "SRS 3D Stereo Enhancement", - /* 10 */ "Platform Tech 3D Stereo Enhancement", - /* 11 */ "AKM 3D Audio", - /* 12 */ "Aureal Stereo Enhancement", - /* 13 */ "Aztech 3D Enhancement", - /* 14 */ "Binaura 3D Audio Enhancement", - /* 15 */ "ESS Technology Stereo Enhancement", - /* 16 */ "Harman International VMAx", - /* 17 */ "Nvidea/IC Ensemble/KS Waves 3D Stereo Enhancement", - /* 18 */ "Philips Incredible Sound", - /* 19 */ "Texas Instruments 3D Stereo Enhancement", - /* 20 */ "VLSI Technology 3D Stereo Enhancement", - /* 21 */ "TriTech 3D Stereo Enhancement", - /* 22 */ "Realtek 3D Stereo Enhancement", - /* 23 */ "Samsung 3D Stereo Enhancement", - /* 24 */ "Wolfson Microelectronics 3D Enhancement", - /* 25 */ "Delta Integration 3D Enhancement", - /* 26 */ "SigmaTel 3D Enhancement", - /* 27 */ "IC Ensemble/KS Waves", - /* 28 */ "Rockwell 3D Stereo Enhancement", - /* 29 */ "Reserved 29", - /* 30 */ "Reserved 30", - /* 31 */ "Reserved 31" -}; - /* * I/O routines @@ -1895,10 +1859,12 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, init_MUTEX(&ac97->reg_mutex); init_MUTEX(&ac97->page_mutex); +#ifdef CONFIG_PCI if (ac97->pci) { pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_VENDOR_ID, &ac97->subsystem_vendor); pci_read_config_word(ac97->pci, PCI_SUBSYSTEM_ID, &ac97->subsystem_device); } +#endif if (bus->ops->reset) { bus->ops->reset(ac97); goto __access_ok; diff --git a/sound/pci/ac97/ac97_local.h b/sound/pci/ac97/ac97_local.h index e98587e..a6244c7 100644 --- a/sound/pci/ac97/ac97_local.h +++ b/sound/pci/ac97/ac97_local.h @@ -57,7 +57,6 @@ struct ac97_enum { .private_value = (unsigned long)&xenum } /* ac97_codec.c */ -extern const char *snd_ac97_stereo_enhancements[]; extern const struct snd_kcontrol_new snd_ac97_controls_3d[]; extern const struct snd_kcontrol_new snd_ac97_controls_spdif[]; struct snd_kcontrol *snd_ac97_cnew(const struct snd_kcontrol_new *_template, struct snd_ac97 * ac97); diff --git a/sound/pci/ac97/ac97_proc.c b/sound/pci/ac97/ac97_proc.c index 2660732..7134b3f 100644 --- a/sound/pci/ac97/ac97_proc.c +++ b/sound/pci/ac97/ac97_proc.c @@ -68,6 +68,42 @@ static void snd_ac97_proc_read_functions(struct snd_ac97 *ac97, struct snd_info_ } } +static const char *snd_ac97_stereo_enhancements[] = +{ + /* 0 */ "No 3D Stereo Enhancement", + /* 1 */ "Analog Devices Phat Stereo", + /* 2 */ "Creative Stereo Enhancement", + /* 3 */ "National Semi 3D Stereo Enhancement", + /* 4 */ "YAMAHA Ymersion", + /* 5 */ "BBE 3D Stereo Enhancement", + /* 6 */ "Crystal Semi 3D Stereo Enhancement", + /* 7 */ "Qsound QXpander", + /* 8 */ "Spatializer 3D Stereo Enhancement", + /* 9 */ "SRS 3D Stereo Enhancement", + /* 10 */ "Platform Tech 3D Stereo Enhancement", + /* 11 */ "AKM 3D Audio", + /* 12 */ "Aureal Stereo Enhancement", + /* 13 */ "Aztech 3D Enhancement", + /* 14 */ "Binaura 3D Audio Enhancement", + /* 15 */ "ESS Technology Stereo Enhancement", + /* 16 */ "Harman International VMAx", + /* 17 */ "Nvidea/IC Ensemble/KS Waves 3D Stereo Enhancement", + /* 18 */ "Philips Incredible Sound", + /* 19 */ "Texas Instruments 3D Stereo Enhancement", + /* 20 */ "VLSI Technology 3D Stereo Enhancement", + /* 21 */ "TriTech 3D Stereo Enhancement", + /* 22 */ "Realtek 3D Stereo Enhancement", + /* 23 */ "Samsung 3D Stereo Enhancement", + /* 24 */ "Wolfson Microelectronics 3D Enhancement", + /* 25 */ "Delta Integration 3D Enhancement", + /* 26 */ "SigmaTel 3D Enhancement", + /* 27 */ "IC Ensemble/KS Waves", + /* 28 */ "Rockwell 3D Stereo Enhancement", + /* 29 */ "Reserved 29", + /* 30 */ "Reserved 30", + /* 31 */ "Reserved 31" +}; + static void snd_ac97_proc_read_main(struct snd_ac97 *ac97, struct snd_info_buffer *buffer, int subidx) { char name[64]; diff --git a/sound/pci/ac97/ak4531_codec.c b/sound/pci/ac97/ak4531_codec.c index 3eb8855..dcfb503 100644 --- a/sound/pci/ac97/ak4531_codec.c +++ b/sound/pci/ac97/ak4531_codec.c @@ -30,7 +30,11 @@ MODULE_AUTHOR("Jaroslav Kysela "); MODULE_DESCRIPTION("Universal routines for AK4531 codec"); MODULE_LICENSE("GPL"); +#ifdef CONFIG_PROC_FS static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531); +#else +#define snd_ak4531_proc_init(card,ak) +#endif /* * @@ -425,8 +429,9 @@ void snd_ak4531_resume(struct snd_ak4531 *ak4531) } #endif +#ifdef CONFIG_PROC_FS /* - + * /proc interface */ static void snd_ak4531_proc_read(struct snd_info_entry *entry, @@ -448,6 +453,7 @@ static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak453 if (! snd_card_proc_new(card, "ak4531", &entry)) snd_info_set_text_ops(entry, ak4531, 1024, snd_ak4531_proc_read); } +#endif EXPORT_SYMBOL(snd_ak4531_mixer); #ifdef CONFIG_PM diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index a039284..33e0664 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1477,6 +1477,7 @@ static int snd_atiixp_resume(struct pci_dev *pci) #endif /* CONFIG_PM */ +#ifdef CONFIG_PROC_FS /* * proc interface for register dump */ @@ -1498,7 +1499,9 @@ static void __devinit snd_atiixp_proc_init(struct atiixp *chip) if (! snd_card_proc_new(chip->card, "atiixp", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read); } - +#else /* !CONFIG_PROC_FS */ +#define snd_atiixp_proc_init(chip) +#endif /* diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 73f1f2b..8d8fd5a 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -1156,6 +1156,7 @@ static int snd_atiixp_resume(struct pci_dev *pci) #endif /* CONFIG_PM */ +#ifdef CONFIG_PROC_FS /* * proc interface for register dump */ @@ -1177,7 +1178,9 @@ static void __devinit snd_atiixp_proc_init(struct atiixp_modem *chip) if (! snd_card_proc_new(chip->card, "atiixp-modem", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_atiixp_proc_read); } - +#else +#define snd_atiixp_proc_init(chip) +#endif /* diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 744f971..5964cdc 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -1456,7 +1456,9 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, } snd_printdd(" done.\n"); +#ifdef CONFIG_PROC_FS snd_ca0106_proc_init(chip); +#endif if ((err = snd_card_register(card)) < 0) { snd_card_free(card); diff --git a/sound/pci/ca0106/ca0106_proc.c b/sound/pci/ca0106/ca0106_proc.c index 94b6225..6375727 100644 --- a/sound/pci/ca0106/ca0106_proc.c +++ b/sound/pci/ca0106/ca0106_proc.c @@ -77,6 +77,8 @@ #include "ca0106.h" +#ifdef CONFIG_PROC_FS + struct snd_ca0106_category_str { int val; const char *name; @@ -459,3 +461,4 @@ int __devinit snd_ca0106_proc_init(struct snd_ca0106 * emu) return 0; } +#endif /* CONFIG_PROC_FS */ diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 0ec0592..8fb275d 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -2747,6 +2747,7 @@ int __devinit snd_cs46xx_gameport(struct snd_cs46xx *chip) { return -ENOSYS; } static inline void snd_cs46xx_remove_gameport(struct snd_cs46xx *chip) { } #endif /* CONFIG_GAMEPORT */ +#ifdef CONFIG_PROC_FS /* * proc interface */ @@ -2800,6 +2801,10 @@ static int snd_cs46xx_proc_done(struct snd_cs46xx *chip) #endif return 0; } +#else /* !CONFIG_PROC_FS */ +#define snd_cs46xx_proc_init(card, chip) +#define snd_cs46xx_proc_done(chip) +#endif /* * stop the h/w diff --git a/sound/pci/cs46xx/cs46xx_lib.h b/sound/pci/cs46xx/cs46xx_lib.h index 8b4a4ae..f75750c 100644 --- a/sound/pci/cs46xx/cs46xx_lib.h +++ b/sound/pci/cs46xx/cs46xx_lib.h @@ -88,8 +88,13 @@ void cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip); int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * module); struct dsp_symbol_entry *cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, int symbol_type); +#ifdef CONFIG_PROC_FS int cs46xx_dsp_proc_init (struct snd_card *card, struct snd_cs46xx *chip); int cs46xx_dsp_proc_done (struct snd_cs46xx *chip); +#else +#define cs46xx_dsp_proc_init(card, chip) +#define cs46xx_dsp_proc_done(chip) +#endif int cs46xx_dsp_scb_and_task_init (struct snd_cs46xx *chip); int snd_cs46xx_download (struct snd_cs46xx *chip, u32 *src, unsigned long offset, unsigned long len); @@ -106,9 +111,14 @@ int cs46xx_dsp_disable_adc_capture (struct snd_cs46xx *chip); int cs46xx_poke_via_dsp (struct snd_cs46xx *chip, u32 address, u32 data); struct dsp_scb_descriptor * cs46xx_dsp_create_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest); +#ifdef CONFIG_PROC_FS void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb); void cs46xx_dsp_proc_register_scb_desc (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb); +#else +#define cs46xx_dsp_proc_free_scb_desc(scb) +#define cs46xx_dsp_proc_register_scb_desc(chip, scb) +#endif struct dsp_scb_descriptor * cs46xx_dsp_create_timing_master_scb (struct snd_cs46xx *chip); struct dsp_scb_descriptor * cs46xx_dsp_create_codec_out_scb(struct snd_cs46xx * chip, diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index ac98917..445a448 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c @@ -439,6 +439,7 @@ cs46xx_dsp_lookup_symbol (struct snd_cs46xx * chip, char * symbol_name, int symb } +#ifdef CONFIG_PROC_FS static struct dsp_symbol_entry * cs46xx_dsp_lookup_symbol_addr (struct snd_cs46xx * chip, u32 address, int symbol_type) { @@ -912,6 +913,7 @@ int cs46xx_dsp_proc_done (struct snd_cs46xx *chip) return 0; } +#endif /* CONFIG_PROC_FS */ static int debug_tree; static void _dsp_create_task_tree (struct snd_cs46xx *chip, u32 * task_data, diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c index 6e86500..509aa2b 100644 --- a/sound/pci/cs46xx/dsp_spos_scb_lib.c +++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c @@ -64,6 +64,7 @@ static void remove_symbol (struct snd_cs46xx * chip, struct dsp_symbol_entry * s } +#ifdef CONFIG_PROC_FS static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, struct snd_info_buffer *buffer) { @@ -106,6 +107,7 @@ static void cs46xx_dsp_proc_scb_info_read (struct snd_info_entry *entry, snd_iprintf(buffer,"index [%d] ref_count [%d]\n",scb->index,scb->ref_count); up(&chip->spos_mutex); } +#endif static void _dsp_unlink_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * scb) { @@ -220,6 +222,7 @@ void cs46xx_dsp_remove_scb (struct snd_cs46xx *chip, struct dsp_scb_descriptor * } +#ifdef CONFIG_PROC_FS void cs46xx_dsp_proc_free_scb_desc (struct dsp_scb_descriptor * scb) { if (scb->proc_info) { @@ -275,6 +278,7 @@ out: scb->proc_info = entry; } } +#endif /* CONFIG_PROC_FS */ static struct dsp_scb_descriptor * _dsp_create_generic_scb (struct snd_cs46xx *chip, char * name, u32 * scb_data, u32 dest, diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index cc36b74..175f8aa 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -1076,7 +1076,9 @@ int __devinit snd_emu10k1_create(struct snd_card *card, if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) goto error; +#ifdef CONFIG_PROC_FS snd_emu10k1_proc_init(emu); +#endif snd_card_set_dev(card, &pci->dev); *remu = emu; diff --git a/sound/pci/emu10k1/emuproc.c b/sound/pci/emu10k1/emuproc.c index b88137f..90f1c52 100644 --- a/sound/pci/emu10k1/emuproc.c +++ b/sound/pci/emu10k1/emuproc.c @@ -32,6 +32,7 @@ #include #include "p16v.h" +#ifdef CONFIG_PROC_FS static void snd_emu10k1_proc_spdif_status(struct snd_emu10k1 * emu, struct snd_info_buffer *buffer, char *title, @@ -620,3 +621,4 @@ int __devinit snd_emu10k1_proc_init(struct snd_emu10k1 * emu) } return 0; } +#endif /* CONFIG_PROC_FS */ diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 5bbc8a0..d3a4e5e 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -2579,6 +2579,7 @@ static void __devinit intel8x0_measure_ac97_clock(struct intel8x0 *chip) printk(KERN_INFO "intel8x0: clocking to %d\n", chip->ac97_bus->clock); } +#ifdef CONFIG_PROC_FS static void snd_intel8x0_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer) { @@ -2612,6 +2613,9 @@ static void __devinit snd_intel8x0_proc_init(struct intel8x0 * chip) if (! snd_card_proc_new(chip->card, "intel8x0", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_intel8x0_proc_read); } +#else +#define snd_intel8x0_proc_init(x) +#endif static int snd_intel8x0_dev_free(struct snd_device *device) { diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 466170e..47e26aa 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -1066,6 +1066,7 @@ static int intel8x0m_resume(struct pci_dev *pci) } #endif /* CONFIG_PM */ +#ifdef CONFIG_PROC_FS static void snd_intel8x0m_proc_read(struct snd_info_entry * entry, struct snd_info_buffer *buffer) { @@ -1093,6 +1094,10 @@ static void __devinit snd_intel8x0m_proc_init(struct intel8x0m * chip) if (! snd_card_proc_new(chip->card, "intel8x0m", &entry)) snd_info_set_text_ops(entry, chip, 1024, snd_intel8x0m_proc_read); } +#else /* !CONFIG_PROC_FS */ +#define snd_intel8x0m_proc_init(chip) +#endif /* CONFIG_PROC_FS */ + static int snd_intel8x0_dev_free(struct snd_device *device) { -- cgit v1.1 From 59d48582508c6e3ed6f60bdd7d13e3e2893416b4 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Dec 2005 10:51:58 +0100 Subject: [ALSA] pcm - Make the support of old API selectable Modules: ALSA Core,PCM Midlevel Make the support of old API selectable via config option. Signed-off-by: Takashi Iwai --- sound/core/Kconfig | 8 ++++++++ sound/core/pcm_native.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 83cbe20..f79755f 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -122,6 +122,14 @@ config SND_DYNAMIC_MINORS If you are unsure about this, say N here. +config SND_SUPPORT_OLD_API + bool "Support old ALSA API" + depends on SND + default y + help + Say Y here to support the obsolete ALSA PCM API (ver.0.9.0 rc3 + or older). + config SND_VERBOSE_PRINTK bool "Verbose printk" depends on SND diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 9010306..f3d5de7 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -55,6 +55,7 @@ struct snd_pcm_hw_params_old { unsigned char reserved[64]; }; +#ifdef CONFIG_SND_SUPPORT_OLD_API #define SNDRV_PCM_IOCTL_HW_REFINE_OLD _IOWR('A', 0x10, struct snd_pcm_hw_params_old) #define SNDRV_PCM_IOCTL_HW_PARAMS_OLD _IOWR('A', 0x11, struct snd_pcm_hw_params_old) @@ -62,6 +63,7 @@ static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, struct snd_pcm_hw_params_old __user * _oparams); static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, struct snd_pcm_hw_params_old __user * _oparams); +#endif static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream); /* @@ -2527,10 +2529,12 @@ static int snd_pcm_common_ioctl1(struct snd_pcm_substream *substream, return snd_pcm_delay(substream, arg); case SNDRV_PCM_IOCTL_SYNC_PTR: return snd_pcm_sync_ptr(substream, arg); +#ifdef CONFIG_SND_SUPPORT_OLD_API case SNDRV_PCM_IOCTL_HW_REFINE_OLD: return snd_pcm_hw_refine_old_user(substream, arg); case SNDRV_PCM_IOCTL_HW_PARAMS_OLD: return snd_pcm_hw_params_old_user(substream, arg); +#endif case SNDRV_PCM_IOCTL_DRAIN: return snd_pcm_drain(substream); case SNDRV_PCM_IOCTL_DROP: @@ -3270,6 +3274,7 @@ static int snd_pcm_fasync(int fd, struct file * file, int on) * To be removed helpers to keep binary compatibility */ +#ifdef CONFIG_SND_SUPPORT_OLD_API #define __OLD_TO_NEW_MASK(x) ((x&7)|((x&0x07fffff8)<<5)) #define __NEW_TO_OLD_MASK(x) ((x&7)|((x&0xffffff00)>>5)) @@ -3379,6 +3384,7 @@ out: kfree(oparams); return err; } +#endif /* CONFIG_SND_SUPPORT_OLD_API */ /* * Register section -- cgit v1.1 From 58da3a23fe12b1c4730cb85af203950c7707220c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 1 Dec 2005 11:14:00 +0100 Subject: [ALSA] au88x0: Remove unneeded call to pci_dma_supported() Modules: au88x0 driver pci_dma_supported() is called right before pci_set_dma_mask() which already calls pci_dma_supported(). The attached patch removes the unneeded call to pci_dma_supported() Additionally the custom VORTEX_DMA_MASK macro is replaced by DMA_32BIT_MASK from linux/dma-mapping.h Signed-off-by: Tobias Klauser Signed-off-by: Andrew Morton Signed-off-by: Takashi Iwai --- sound/pci/au88x0/au88x0.c | 4 ++-- sound/pci/au88x0/au88x0.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index 7c54785..7d9184f 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -20,6 +20,7 @@ #include #include #include +#include #include // module parameters (see "Module Parameters") @@ -150,11 +151,10 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip) // check PCI availability (DMA). if ((err = pci_enable_device(pci)) < 0) return err; - if (!pci_dma_supported(pci, VORTEX_DMA_MASK)) { + if (pci_set_dma_mask(pci, DMA_32BIT_MASK)) { printk(KERN_ERR "error to set DMA mask\n"); return -ENXIO; } - pci_set_dma_mask(pci, VORTEX_DMA_MASK); chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) diff --git a/sound/pci/au88x0/au88x0.h b/sound/pci/au88x0/au88x0.h index 745f995..c2ad267 100644 --- a/sound/pci/au88x0/au88x0.h +++ b/sound/pci/au88x0/au88x0.h @@ -39,8 +39,6 @@ #include "au88x0_wt.h" #endif -#define VORTEX_DMA_MASK 0xffffffff - #define hwread(x,y) readl((x)+((y)>>2)) #define hwwrite(x,y,z) writel((z),(x)+((y)>>2)) -- cgit v1.1 From 481ba7727fa08deb389b5a2e550e04df24d3f37d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 1 Dec 2005 11:19:41 +0100 Subject: [ALSA] powermac - Revert the last addition for 17' powerbook Modules: PPC PMAC driver The last addition of 17' powerbook support seems buggy (it's not Toonie indeed). Removed again. Signed-off-by: Takashi Iwai --- sound/ppc/pmac.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index d70292c..9b2b00f 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -986,7 +986,6 @@ static int __init snd_pmac_detect(struct snd_pmac *chip) chip->control_mask = MASK_IEPC | 0x11;/* disable IEE */ break; case 0x3a: - case 0x40: chip->num_freqs = ARRAY_SIZE(tumbler_freqs); chip->model = PMAC_TOONIE; chip->can_byte_swap = 0; /* FIXME: check this */ -- cgit v1.1 From 19b99fbaed2e2971b756311435c67e84431d8515 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Sun, 4 Dec 2005 18:03:03 +0100 Subject: [ALSA] emu10k1: Partial support for Creative emu1212m Modules: EMU10K1/EMU10K2 driver Distorted sound now comes from the Audio Out socket. Still more work to do. Signed-off-by: James Courtier-Dutton --- include/sound/emu10k1.h | 1 + sound/pci/emu10k1/emu10k1_main.c | 150 +++++++++++++++++++++++++++++++++++++-- sound/pci/emu10k1/emufx.c | 9 +++ sound/pci/emu10k1/emumixer.c | 4 +- 4 files changed, 159 insertions(+), 5 deletions(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 3d0496c..0d6e68c 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1061,6 +1061,7 @@ struct snd_emu_chip_details { unsigned char spdif_bug; /* Has Spdif phasing bug */ unsigned char ac97_chip; /* Has an AC97 chip: 1 = mandatory, 2 = optional */ unsigned char ecard; /* APS EEPROM */ + unsigned char emu1212m; /* EMU 1212m card */ const char *driver; const char *name; const char *id; /* for backward compatibility - can be NULL if not needed */ diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 175f8aa..f6cf589 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -42,6 +42,7 @@ #include "p16v.h" #include "tina2.h" + /************************************************************************* * EMU10K1 init / done *************************************************************************/ @@ -217,7 +218,9 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); if (enable_ir) { /* enable IR for SB Live */ - if (emu->audigy) { + if ( emu->card_capabilities->emu1212m) { + ; /* Disable all access to A_IOCFG for the emu1212m */ + } else if (emu->audigy) { unsigned int reg = inl(emu->port + A_IOCFG); outl(reg | A_IOCFG_GPOUT2, emu->port + A_IOCFG); udelay(500); @@ -234,7 +237,9 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) } } - if (emu->audigy) { /* enable analog output */ + if ( emu->card_capabilities->emu1212m) { + ; /* Disable all access to A_IOCFG for the emu1212m */ + } else if (emu->audigy) { /* enable analog output */ unsigned int reg = inl(emu->port + A_IOCFG); outl(reg | A_IOCFG_GPOUT0, emu->port + A_IOCFG); } @@ -250,7 +255,9 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu) outl(inl(emu->port + HCFG) | HCFG_AUDIOENABLE, emu->port + HCFG); /* Enable analog/digital outs on audigy */ - if (emu->audigy) { + if ( emu->card_capabilities->emu1212m) { + ; /* Disable all access to A_IOCFG for the emu1212m */ + } else if (emu->audigy) { outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ @@ -542,6 +549,136 @@ static int __devinit snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) return 0; } +static int snd_emu1212m_fpga_write(struct snd_emu10k1 * emu, int reg, int value) +{ + if (reg<0 || reg>0x3f) + return 1; + reg+=0x40; /* 0x40 upwards are registers. */ + if (value<0 || value>0x3f) /* 0 to 0x3f are values */ + return 1; + outl(reg, emu->port + A_IOCFG); + outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + outl(value, emu->port + A_IOCFG); + outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + + return 0; +} + +static int snd_emu1212m_fpga_read(struct snd_emu10k1 * emu, int reg, int *value) +{ + if (reg<0 || reg>0x3f) + return 1; + reg+=0x40; /* 0x40 upwards are registers. */ + outl(reg, emu->port + A_IOCFG); + outl(reg | 0x80, emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */ + *value = inl(emu->port + A_IOCFG); + + return 0; +} + +static int snd_emu1212m_fpga_netlist_write(struct snd_emu10k1 * emu, int reg, int value) +{ + snd_emu1212m_fpga_write(emu, 0x00, ((reg >> 8) & 0x3f) ); + snd_emu1212m_fpga_write(emu, 0x01, (reg & 0x3f) ); + snd_emu1212m_fpga_write(emu, 0x02, ((value >> 8) & 0x3f) ); + snd_emu1212m_fpga_write(emu, 0x03, (value & 0x3f) ); + + return 0; +} + +static int __devinit snd_emu10k1_emu1212m_init(struct snd_emu10k1 * emu) +{ + unsigned int i; + int tmp; + + snd_printk(KERN_ERR "emu1212m: Special config.\n"); + outl(0x0005a00c, emu->port + HCFG); + outl(0x0005a004, emu->port + HCFG); + outl(0x0005a000, emu->port + HCFG); + outl(0x0005a000, emu->port + HCFG); + + snd_emu1212m_fpga_read(emu, 0x22, &tmp ); + snd_emu1212m_fpga_read(emu, 0x23, &tmp ); + snd_emu1212m_fpga_read(emu, 0x24, &tmp ); + snd_emu1212m_fpga_write(emu, 0x04, 0x01 ); + snd_emu1212m_fpga_read(emu, 0x0b, &tmp ); + snd_emu1212m_fpga_write(emu, 0x0b, 0x01 ); + snd_emu1212m_fpga_read(emu, 0x10, &tmp ); + snd_emu1212m_fpga_write(emu, 0x10, 0x00 ); + snd_emu1212m_fpga_read(emu, 0x11, &tmp ); + snd_emu1212m_fpga_write(emu, 0x11, 0x30 ); + snd_emu1212m_fpga_read(emu, 0x13, &tmp ); + snd_emu1212m_fpga_write(emu, 0x13, 0x0f ); + snd_emu1212m_fpga_read(emu, 0x11, &tmp ); + snd_emu1212m_fpga_write(emu, 0x11, 0x30 ); + snd_emu1212m_fpga_read(emu, 0x0a, &tmp ); + snd_emu1212m_fpga_write(emu, 0x0a, 0x10 ); + snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); + snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); + snd_emu1212m_fpga_write(emu, 0x09, 0x0f ); + snd_emu1212m_fpga_write(emu, 0x06, 0x00 ); + snd_emu1212m_fpga_write(emu, 0x05, 0x00 ); + snd_emu1212m_fpga_write(emu, 0x0e, 0x12 ); + snd_emu1212m_fpga_netlist_write(emu, 0x0000, 0x0200); + snd_emu1212m_fpga_netlist_write(emu, 0x0001, 0x0201); + snd_emu1212m_fpga_netlist_write(emu, 0x0002, 0x0500); + snd_emu1212m_fpga_netlist_write(emu, 0x0003, 0x0501); + snd_emu1212m_fpga_netlist_write(emu, 0x0004, 0x0400); + snd_emu1212m_fpga_netlist_write(emu, 0x0005, 0x0401); + snd_emu1212m_fpga_netlist_write(emu, 0x0006, 0x0402); + snd_emu1212m_fpga_netlist_write(emu, 0x0007, 0x0403); + snd_emu1212m_fpga_netlist_write(emu, 0x0008, 0x0404); + snd_emu1212m_fpga_netlist_write(emu, 0x0009, 0x0405); + snd_emu1212m_fpga_netlist_write(emu, 0x000a, 0x0406); + snd_emu1212m_fpga_netlist_write(emu, 0x000b, 0x0407); + snd_emu1212m_fpga_netlist_write(emu, 0x000c, 0x0100); + snd_emu1212m_fpga_netlist_write(emu, 0x000d, 0x0104); + snd_emu1212m_fpga_netlist_write(emu, 0x000e, 0x0200); + snd_emu1212m_fpga_netlist_write(emu, 0x000f, 0x0201); + for (i=0;i < 0x20;i++) { + snd_emu1212m_fpga_netlist_write(emu, 0x0100+i, 0x0000); + } + for (i=0;i < 4;i++) { + snd_emu1212m_fpga_netlist_write(emu, 0x0200+i, 0x0000); + } + for (i=0;i < 7;i++) { + snd_emu1212m_fpga_netlist_write(emu, 0x0300+i, 0x0000); + } + for (i=0;i < 7;i++) { + snd_emu1212m_fpga_netlist_write(emu, 0x0400+i, 0x0000); + } + snd_emu1212m_fpga_netlist_write(emu, 0x0500, 0x0108); + snd_emu1212m_fpga_netlist_write(emu, 0x0501, 0x010c); + snd_emu1212m_fpga_netlist_write(emu, 0x0600, 0x0110); + snd_emu1212m_fpga_netlist_write(emu, 0x0601, 0x0114); + snd_emu1212m_fpga_netlist_write(emu, 0x0700, 0x0118); + snd_emu1212m_fpga_netlist_write(emu, 0x0701, 0x011c); + snd_emu1212m_fpga_write(emu, 0x07, 0x01 ); + + snd_emu1212m_fpga_read(emu, 0x21, &tmp ); + + outl(0x0000a000, emu->port + HCFG); + outl(0x0000a001, emu->port + HCFG); + /* Initial boot complete. Now patches */ + + snd_emu1212m_fpga_read(emu, 0x21, &tmp ); + snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); + snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); + snd_emu1212m_fpga_write(emu, 0x0c, 0x19 ); + snd_emu1212m_fpga_write(emu, 0x12, 0x0c ); + snd_emu1212m_fpga_read(emu, 0x0a, &tmp ); + snd_emu1212m_fpga_write(emu, 0x0a, 0x10 ); + + snd_emu1212m_fpga_read(emu, 0x20, &tmp ); + snd_emu1212m_fpga_read(emu, 0x21, &tmp ); + + snd_emu1212m_fpga_netlist_write(emu, 0x0300, 0x0312); + snd_emu1212m_fpga_netlist_write(emu, 0x0301, 0x0313); + snd_emu1212m_fpga_netlist_write(emu, 0x0200, 0x0302); + snd_emu1212m_fpga_netlist_write(emu, 0x0201, 0x0303); + + return 0; +} /* * Create the EMU10K1 instance */ @@ -623,7 +760,7 @@ static struct snd_emu_chip_details emu_chip_details[] = { .id = "EMU1212m", .emu10k2_chip = 1, .ca0102_chip = 1, - .ecard = 1} , + .emu1212m = 1} , /* Tested by James@superbug.co.uk 3rd July 2005 */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", @@ -1013,6 +1150,11 @@ int __devinit snd_emu10k1_create(struct snd_card *card, } else if (emu->card_capabilities->ca_cardbus_chip) { if ((err = snd_emu10k1_cardbus_init(emu)) < 0) goto error; + } else if (emu->card_capabilities->emu1212m) { + if ((err = snd_emu10k1_emu1212m_init(emu)) < 0) { + snd_emu10k1_free(emu); + return err; + } } else { /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version does not support this, it shouldn't do any harm */ diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index a44e4fd..cd356b0 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -1102,6 +1102,14 @@ static int __devinit _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) /* stop FX processor */ snd_emu10k1_ptr_write(emu, A_DBG, 0, (emu->fx8010.dbg = 0) | A_DBG_SINGLE_STEP); +#if 0 + /* FIX: jcd test */ + for (z = 0; z < 80; z=z+2) { + A_OP(icode, &ptr, iACC3, A_EXTOUT(z), A_FXBUS(FXBUS_PCM_LEFT_FRONT), A_C_00000000, A_C_00000000); /* left */ + A_OP(icode, &ptr, iACC3, A_EXTOUT(z+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT), A_C_00000000, A_C_00000000); /* right */ + } +#endif /* jcd test */ +#if 1 /* PCM front Playback Volume (independent from stereo mix) */ A_OP(icode, &ptr, iMAC0, A_GPR(playback), A_C_00000000, A_GPR(gpr), A_FXBUS(FXBUS_PCM_LEFT_FRONT)); A_OP(icode, &ptr, iMAC0, A_GPR(playback+1), A_C_00000000, A_GPR(gpr+1), A_FXBUS(FXBUS_PCM_RIGHT_FRONT)); @@ -1447,6 +1455,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) A_OP(icode, &ptr, iACC3, A_FXBUS2(z), A_C_00000000, A_C_00000000, A_EXTIN(z)); } +#endif /* JCD test */ /* * ok, set up done.. */ diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 98fb813..306fe4a 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -959,7 +959,9 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu, return err; } - if (emu->audigy) { + if ( emu->card_capabilities->emu1212m) { + ; /* Disable the snd_audigy_spdif_shared_spdif */ + } else if (emu->audigy) { if ((kctl = snd_ctl_new1(&snd_audigy_shared_spdif, emu)) == NULL) return -ENOMEM; if ((err = snd_ctl_add(card, kctl))) -- cgit v1.1 From bd01e7bc9e975d7d3d6fe4eb2f2cf7ae83041c49 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 5 Dec 2005 15:12:20 +0100 Subject: [ALSA] emu10k1 - Fix missing declarations Modules: EMU10K1/EMU10K2 driver sound/pci/emu10k1/emufx.c: In function 'snd_emu10k1_efx_alloc_pm_buffer': sound/pci/emu10k1/emufx.c:2402: error: implicit declaration of function 'vmalloc' sound/pci/emu10k1/emufx.c:2402: warning: assignment makes pointer from integer without a cast sound/pci/emu10k1/emufx.c: In function 'snd_emu10k1_efx_free_pm_buffer': sound/pci/emu10k1/emufx.c:2413: error: implicit declaration of function 'vfree' Signed-off-by: Andreas Schwab Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emufx.c | 1 + sound/pci/emu10k1/p16v.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index cd356b0..1a90339 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index adce6af..76d86ed 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -93,6 +93,7 @@ #include #include #include +#include #include #include #include -- cgit v1.1 From 59acf76e0268e3f0156ef5113e89d838a8c02bb6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Dec 2005 19:22:34 +0100 Subject: [ALSA] ice1724 - Add support of M-Audio Revolution 5.1 Modules: ICE1724 driver Added the basic support of M-Audio Revolution 5.1. Signed-off-by: Takashi Iwai --- sound/pci/ice1712/revo.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- sound/pci/ice1712/revo.h | 4 +++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c index 664b738..b5754b3 100644 --- a/sound/pci/ice1712/revo.c +++ b/sound/pci/ice1712/revo.c @@ -61,7 +61,7 @@ static void revo_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) else dfs = 0; - if (ak->type == SND_AK4355) { + if (ak->type == SND_AK4355 || ak->type == SND_AK4358) { reg = 2; shift = 4; } else { @@ -128,6 +128,26 @@ static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { .mask_flags = 0, }; +static struct snd_akm4xxx akm_revo51 __devinitdata = { + .type = SND_AK4358, + .num_dacs = 6, + .ops = { + .set_rate_val = revo_set_rate_val + } +}; + +static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { + .caddr = 2, + .cif = 0, + .data_mask = VT1724_REVO_CDOUT, + .clk_mask = VT1724_REVO_CCLK, + .cs_mask = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, + .cs_addr = 0, + .cs_none = VT1724_REVO_CS0 | VT1724_REVO_CS1 | VT1724_REVO_CS2, + .add_flags = VT1724_REVO_CCLK, /* high at init */ + .mask_flags = 0, +}; + static int __devinit revo_init(struct snd_ice1712 *ice) { struct snd_akm4xxx *ak; @@ -138,14 +158,17 @@ static int __devinit revo_init(struct snd_ice1712 *ice) case VT1724_SUBDEVICE_REVOLUTION71: ice->num_total_dacs = 8; ice->num_total_adcs = 2; + ice->gpio.i2s_mclk_changed = revo_i2s_mclk_changed; + break; + case VT1724_SUBDEVICE_REVOLUTION51: + ice->num_total_dacs = 6; + ice->num_total_adcs = 2; break; default: snd_BUG(); return -EINVAL; } - ice->gpio.i2s_mclk_changed = revo_i2s_mclk_changed; - /* second stage of initialization, analog parts and others */ ak = ice->akm = kcalloc(2, sizeof(struct snd_akm4xxx), GFP_KERNEL); if (! ak) @@ -153,6 +176,7 @@ static int __devinit revo_init(struct snd_ice1712 *ice) ice->akm_codecs = 2; switch (ice->eeprom.subvendor) { case VT1724_SUBDEVICE_REVOLUTION71: + ice->akm_codecs = 2; if ((err = snd_ice1712_akm4xxx_init(ak, &akm_revo_front, &akm_revo_front_priv, ice)) < 0) return err; if ((err = snd_ice1712_akm4xxx_init(ak + 1, &akm_revo_surround, &akm_revo_surround_priv, ice)) < 0) @@ -160,6 +184,13 @@ static int __devinit revo_init(struct snd_ice1712 *ice) /* unmute all codecs */ snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, VT1724_REVO_MUTE); break; + case VT1724_SUBDEVICE_REVOLUTION51: + ice->akm_codecs = 1; + if ((err = snd_ice1712_akm4xxx_init(ak, &akm_revo51, &akm_revo51_priv, ice)) < 0) + return err; + /* unmute all codecs - needed! */ + snd_ice1712_gpio_write_bits(ice, VT1724_REVO_MUTE, VT1724_REVO_MUTE); + break; } return 0; @@ -172,6 +203,7 @@ static int __devinit revo_add_controls(struct snd_ice1712 *ice) switch (ice->eeprom.subvendor) { case VT1724_SUBDEVICE_REVOLUTION71: + case VT1724_SUBDEVICE_REVOLUTION51: err = snd_ice1712_akm4xxx_build_controls(ice); if (err < 0) return err; @@ -188,5 +220,12 @@ struct snd_ice1712_card_info snd_vt1724_revo_cards[] __devinitdata = { .chip_init = revo_init, .build_controls = revo_add_controls, }, + { + .subvendor = VT1724_SUBDEVICE_REVOLUTION51, + .name = "M Audio Revolution-5.1", + .model = "revo51", + .chip_init = revo_init, + .build_controls = revo_add_controls, + }, { } /* terminator */ }; diff --git a/sound/pci/ice1712/revo.h b/sound/pci/ice1712/revo.h index ca4420b..dea52ea 100644 --- a/sound/pci/ice1712/revo.h +++ b/sound/pci/ice1712/revo.h @@ -25,9 +25,11 @@ */ #define REVO_DEVICE_DESC \ - "{MidiMan M Audio,Revolution 7.1}," + "{MidiMan M Audio,Revolution 7.1},"\ + "{MidiMan M Audio,Revolution 5.1}," #define VT1724_SUBDEVICE_REVOLUTION71 0x12143036 +#define VT1724_SUBDEVICE_REVOLUTION51 0x12143136 /* entry point */ extern struct snd_ice1712_card_info snd_vt1724_revo_cards[]; -- cgit v1.1 From df694daa3c0135202e4702cb2d11e68a43f6c51e Mon Sep 17 00:00:00 2001 From: Kailang Yang Date: Mon, 5 Dec 2005 19:42:22 +0100 Subject: [ALSA] hda-codec - Add the support of ALC262,ALC883,ALC885,ALC861 Modules: HDA Codec driver,HDA generic driver This patch adds the support of ALC262,ALC883,ALC885,ALC861 to driver More models and improvements for ALC880, ALC260 and ALC882 codecs, too. Signed-off-by: Kailang Yang Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 16 +- sound/pci/hda/hda_local.h | 5 +- sound/pci/hda/patch_analog.c | 2 +- sound/pci/hda/patch_cmedia.c | 2 +- sound/pci/hda/patch_realtek.c | 2399 ++++++++++++++++++++++++++++++++++++---- sound/pci/hda/patch_sigmatel.c | 4 +- 6 files changed, 2215 insertions(+), 213 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 5ead2a3..bd375f8 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1926,8 +1926,18 @@ int snd_hda_multi_out_analog_cleanup(struct hda_codec *codec, struct hda_multi_o /* * Helper for automatic ping configuration */ + +static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list) +{ + for (; *list; list++) + if (*list == nid) + return 1; + return 0; +} + /* parse all pin widgets and store the useful pin nids to cfg */ -int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg) +int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, + hda_nid_t *ignore_nids) { hda_nid_t nid, nid_start; int i, j, nodes; @@ -1948,6 +1958,10 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c /* read all default configuration for pin complex */ if (wid_type != AC_WID_PIN) continue; + /* ignore the given nids (e.g. pc-beep returns error) */ + if (ignore_nids && is_in_nid_list(nid, ignore_nids)) + continue; + def_conf = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) continue; diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index ded3235..a9863eb 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -213,7 +213,7 @@ enum { struct auto_pin_cfg { int line_outs; - hda_nid_t line_out_pins[4]; /* sorted in the order of Front/Surr/CLFE/Side */ + hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */ hda_nid_t speaker_pin; hda_nid_t hp_pin; hda_nid_t input_pins[AUTO_PIN_LAST]; @@ -227,7 +227,8 @@ struct auto_pin_cfg { #define get_defcfg_sequence(cfg) (cfg & AC_DEFCFG_SEQUENCE) #define get_defcfg_device(cfg) ((cfg & AC_DEFCFG_DEVICE) >> AC_DEFCFG_DEVICE_SHIFT) -int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg); +int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *cfg, + hda_nid_t *ignore_nids); /* amp values */ #define AMP_IN_MUTE(idx) (0x7080 | ((idx)<<8)) diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index fc14415..d1e1ded 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -1968,7 +1968,7 @@ static int ad1988_parse_auto_config(struct hda_codec *codec) struct ad198x_spec *spec = codec->spec; int err; - if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) + if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) return err; if ((err = ad1988_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) return err; diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index 9a69811..d38ce22 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c @@ -711,7 +711,7 @@ static int patch_cmi9880(struct hda_codec *codec) spec->dig_in_nid = CMI_DIG_IN_NID; spec->multiout.max_channels = 8; } - snd_hda_parse_pin_def_config(codec, &cfg); + snd_hda_parse_pin_def_config(codec, &cfg, NULL); if (cfg.line_outs) { spec->multiout.max_channels = cfg.line_outs * 2; cmi9880_fill_multi_dac_nids(codec, &cfg); diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index c5fb141..a98c0e4 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -3,7 +3,8 @@ * * HD audio interface patch for ALC 260/880/882 codecs * - * Copyright (c) 2004 PeiSen Hou + * Copyright (c) 2004 Kailang Yang + * PeiSen Hou * Takashi Iwai * * This driver is free software; you can redistribute it and/or modify @@ -39,17 +40,20 @@ enum { ALC880_5ST_DIG, ALC880_W810, ALC880_Z71V, - ALC880_AUTO, ALC880_6ST, ALC880_6ST_DIG, ALC880_F1734, ALC880_ASUS, ALC880_ASUS_DIG, ALC880_ASUS_W1V, + ALC880_ASUS_DIG2, ALC880_UNIWILL_DIG, + ALC880_CLEVO, + ALC880_TCL_S700, #ifdef CONFIG_SND_DEBUG ALC880_TEST, #endif + ALC880_AUTO, ALC880_MODEL_LAST /* last tag */ }; @@ -57,16 +61,45 @@ enum { enum { ALC260_BASIC, ALC260_HP, - ALC260_FUJITSU_S702x, + ALC260_HP_3013, + ALC260_FUJITSU_S702X, + ALC260_AUTO, ALC260_MODEL_LAST /* last tag */ }; +/* ALC262 models */ +enum { + ALC262_BASIC, + ALC262_AUTO, + ALC262_MODEL_LAST /* last tag */ +}; + +/* ALC861 models */ +enum { + ALC861_3ST, + ALC861_3ST_DIG, + ALC861_6ST_DIG, + ALC861_AUTO, + ALC861_MODEL_LAST, +}; + +/* ALC882 models */ +enum { + ALC882_3ST_DIG, + ALC882_6ST_DIG, + ALC882_AUTO, + ALC882_MODEL_LAST, +}; + +/* for GPIO Poll */ +#define GPIO_MASK 0x03 + struct alc_spec { /* codec parameterization */ - struct snd_kcontrol_new *mixers[3]; /* mixer arrays */ + struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ unsigned int num_mixers; - const struct hda_verb *init_verbs[3]; /* initialization verbs + const struct hda_verb *init_verbs[5]; /* initialization verbs * don't forget NULL termination! */ unsigned int num_init_verbs; @@ -106,7 +139,25 @@ struct alc_spec { unsigned int num_kctl_alloc, num_kctl_used; struct snd_kcontrol_new *kctl_alloc; struct hda_input_mux private_imux; - hda_nid_t private_dac_nids[4]; + hda_nid_t private_dac_nids[5]; +}; + +/* + * configuration template - to be copied to the spec instance + */ +struct alc_config_preset { + struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */ + const struct hda_verb *init_verbs[5]; + unsigned int num_dacs; + hda_nid_t *dac_nids; + hda_nid_t dig_out_nid; /* optional */ + hda_nid_t hp_nid; /* optional */ + unsigned int num_adc_nids; + hda_nid_t *adc_nids; + hda_nid_t dig_in_nid; + unsigned int num_channel_mode; + const struct hda_channel_mode *channel_mode; + const struct hda_input_mux *input_mux; }; @@ -143,7 +194,7 @@ static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v /* * channel mode setting */ -static int alc880_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -151,7 +202,7 @@ static int alc880_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_ele spec->num_channel_mode); } -static int alc880_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -159,7 +210,7 @@ static int alc880_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem spec->num_channel_mode, spec->multiout.max_channels); } -static int alc880_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct alc_spec *spec = codec->spec; @@ -217,6 +268,36 @@ static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e .put = alc_pinctl_switch_put, \ .private_value = (nid) | (mask<<16) } + +/* + * set up from the preset table + */ +static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++) + spec->mixers[spec->num_mixers++] = preset->mixers[i]; + for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++) + spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; + + spec->channel_mode = preset->channel_mode; + spec->num_channel_mode = preset->num_channel_mode; + + spec->multiout.max_channels = spec->channel_mode[0].channels; + + spec->multiout.num_dacs = preset->num_dacs; + spec->multiout.dac_nids = preset->dac_nids; + spec->multiout.dig_out_nid = preset->dig_out_nid; + spec->multiout.hp_nid = preset->hp_nid; + + spec->input_mux = preset->input_mux; + + spec->num_adc_nids = preset->num_adc_nids; + spec->adc_nids = preset->adc_nids; + spec->dig_in_nid = preset->dig_in_nid; +} + /* * ALC880 3-stack model * @@ -237,6 +318,7 @@ static hda_nid_t alc880_adc_nids[3] = { /* The datasheet says the node 0x07 is connected from inputs, * but it shows zero connection in the real implementation on some devices. + * Note: this is a 915GAV bug, fixed on 915GLV */ static hda_nid_t alc880_adc_nids_alt[2] = { /* ADC1-2 */ @@ -307,9 +389,9 @@ static struct snd_kcontrol_new alc880_three_stack_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Channel Mode", - .info = alc880_ch_mode_info, - .get = alc880_ch_mode_get, - .put = alc880_ch_mode_put, + .info = alc_ch_mode_info, + .get = alc_ch_mode_get, + .put = alc_ch_mode_put, }, { } /* end */ }; @@ -452,9 +534,9 @@ static struct snd_kcontrol_new alc880_six_stack_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Channel Mode", - .info = alc880_ch_mode_info, - .get = alc880_ch_mode_get, - .put = alc880_ch_mode_put, + .info = alc_ch_mode_info, + .get = alc_ch_mode_get, + .put = alc_ch_mode_put, }, { } /* end */ }; @@ -596,9 +678,9 @@ static struct snd_kcontrol_new alc880_asus_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Channel Mode", - .info = alc880_ch_mode_info, - .get = alc880_ch_mode_get, - .put = alc880_ch_mode_put, + .info = alc_ch_mode_info, + .get = alc_ch_mode_get, + .put = alc_ch_mode_put, }, { } /* end */ }; @@ -626,6 +708,33 @@ static struct snd_kcontrol_new alc880_pcbeep_mixer[] = { { } /* end */ }; +/* TCL S700 */ +static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + * FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 1, + .info = alc_mux_enum_info, + .get = alc_mux_enum_get, + .put = alc_mux_enum_put, + }, + { } /* end */ +}; + /* * build control elements */ @@ -925,6 +1034,8 @@ static struct hda_verb alc880_gpio1_init_verbs[] = { {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, + + { } }; /* Enable GPIO mask and set output */ @@ -932,8 +1043,59 @@ static struct hda_verb alc880_gpio2_init_verbs[] = { {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, + + { } +}; + +/* Clevo m520g init */ +static struct hda_verb alc880_pin_clevo_init_verbs[] = { + /* headphone output */ + {0x11, AC_VERB_SET_CONNECT_SEL, 0x01}, + /* line-out */ + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + /* Line-in */ + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + /* CD */ + {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + /* Mic1 (rear panel) */ + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + /* Mic2 (front panel) */ + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + /* headphone */ + {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + /* change to EAPD mode */ + {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, + {0x20, AC_VERB_SET_PROC_COEF, 0x3060}, + + { } }; +static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = { + /* Headphone output */ + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, + /* Front output*/ + {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, + {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, + + /* Line In pin widget for input */ + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + /* CD pin widget for input */ + {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, + /* Mic1 (rear panel) pin widget for input and vref at 80% */ + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, + + /* change to EAPD mode */ + {0x20, AC_VERB_SET_COEF_INDEX, 0x07}, + {0x20, AC_VERB_SET_PROC_COEF, 0x3070}, + + { } +}; /* */ @@ -1344,9 +1506,9 @@ static struct snd_kcontrol_new alc880_test_mixer[] = { { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Channel Mode", - .info = alc880_ch_mode_info, - .get = alc880_ch_mode_get, - .put = alc880_ch_mode_put, + .info = alc_ch_mode_info, + .get = alc_ch_mode_get, + .put = alc_ch_mode_put, }, { } /* end */ }; @@ -1442,6 +1604,8 @@ static struct hda_board_config alc880_cfg_tbl[] = { { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST }, { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST }, { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST }, + /* TCL S700 */ + { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 }, /* Back 3 jack, front 2 jack (Internal add Aux-In) */ { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST }, @@ -1452,6 +1616,8 @@ static struct hda_board_config alc880_cfg_tbl[] = { { .modelname = "3stack-digout", .config = ALC880_3ST_DIG }, { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG }, { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG }, + /* Clevo m520G NB */ + { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO }, /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/ { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG }, @@ -1489,6 +1655,7 @@ static struct hda_board_config alc880_cfg_tbl[] = { { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, { .modelname = "6stack", .config = ALC880_6ST }, + { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ { .modelname = "6stack-digout", .config = ALC880_6ST_DIG }, @@ -1496,6 +1663,10 @@ static struct hda_board_config alc880_cfg_tbl[] = { { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG }, { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG }, { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG }, + { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG }, + { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG }, + { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, + { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, { .modelname = "asus", .config = ALC880_ASUS }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, @@ -1509,37 +1680,26 @@ static struct hda_board_config alc880_cfg_tbl[] = { { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V }, + { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 }, { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG }, { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG }, { .modelname = "F1734", .config = ALC880_F1734 }, { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 }, + { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 }, #ifdef CONFIG_SND_DEBUG { .modelname = "test", .config = ALC880_TEST }, #endif + { .modelname = "auto", .config = ALC880_AUTO }, {} }; /* - * configuration template - to be copied to the spec instance + * ALC880 codec presets */ -struct alc_config_preset { - struct snd_kcontrol_new *mixers[4]; - const struct hda_verb *init_verbs[4]; - unsigned int num_dacs; - hda_nid_t *dac_nids; - hda_nid_t dig_out_nid; /* optional */ - hda_nid_t hp_nid; /* optional */ - unsigned int num_adc_nids; - hda_nid_t *adc_nids; - unsigned int num_channel_mode; - const struct hda_channel_mode *channel_mode; - const struct hda_input_mux *input_mux; -}; - static struct alc_config_preset alc880_presets[] = { [ALC880_3ST] = { .mixers = { alc880_three_stack_mixer }, @@ -1560,6 +1720,18 @@ static struct alc_config_preset alc880_presets[] = { .channel_mode = alc880_threestack_modes, .input_mux = &alc880_capture_source, }, + [ALC880_TCL_S700] = { + .mixers = { alc880_tcl_s700_mixer }, + .init_verbs = { alc880_volume_init_verbs, + alc880_pin_tcl_S700_init_verbs, + alc880_gpio2_init_verbs }, + .num_dacs = ARRAY_SIZE(alc880_dac_nids), + .dac_nids = alc880_dac_nids, + .hp_nid = 0x03, + .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes), + .channel_mode = alc880_2_jack_modes, + .input_mux = &alc880_capture_source, + }, [ALC880_5ST] = { .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer}, .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs }, @@ -1651,6 +1823,17 @@ static struct alc_config_preset alc880_presets[] = { .channel_mode = alc880_asus_modes, .input_mux = &alc880_capture_source, }, + [ALC880_ASUS_DIG2] = { + .mixers = { alc880_asus_mixer }, + .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, + alc880_gpio2_init_verbs }, /* use GPIO2 */ + .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids), + .dac_nids = alc880_asus_dac_nids, + .dig_out_nid = ALC880_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc880_asus_modes), + .channel_mode = alc880_asus_modes, + .input_mux = &alc880_capture_source, + }, [ALC880_ASUS_W1V] = { .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer }, .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs, @@ -1672,6 +1855,17 @@ static struct alc_config_preset alc880_presets[] = { .channel_mode = alc880_asus_modes, .input_mux = &alc880_capture_source, }, + [ALC880_CLEVO] = { + .mixers = { alc880_three_stack_mixer }, + .init_verbs = { alc880_volume_init_verbs, + alc880_pin_clevo_init_verbs }, + .num_dacs = ARRAY_SIZE(alc880_dac_nids), + .dac_nids = alc880_dac_nids, + .hp_nid = 0x03, + .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes), + .channel_mode = alc880_threestack_modes, + .input_mux = &alc880_capture_source, + }, #ifdef CONFIG_SND_DEBUG [ALC880_TEST] = { .mixers = { alc880_test_mixer }, @@ -1783,7 +1977,8 @@ static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pi } /* add playback controls from the parsed DAC table */ -static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) +static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec, + const struct auto_pin_cfg *cfg) { char name[32]; static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; @@ -1871,35 +2066,38 @@ static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin, } /* create input playback/capture controls for the given pin */ -static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname) +static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname, + int idx, hda_nid_t mix_nid) { char name[32]; - int err, idx; + int err; sprintf(name, "%s Playback Volume", ctlname); - idx = alc880_input_pin_idx(pin); if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, - HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0) + HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) return err; sprintf(name, "%s Playback Switch", ctlname); if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, - HDA_COMPOSE_AMP_VAL(0x0b, 3, idx, HDA_INPUT))) < 0) + HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0) return err; return 0; } /* create playback/capture controls for input pins */ -static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) +static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, + const struct auto_pin_cfg *cfg) { static char *labels[AUTO_PIN_LAST] = { "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" }; struct hda_input_mux *imux = &spec->private_imux; - int i, err; + int i, err, idx; for (i = 0; i < AUTO_PIN_LAST; i++) { if (alc880_is_input_pin(cfg->input_pins[i])) { - err = new_analog_input(spec, cfg->input_pins[i], labels[i]); + idx = alc880_input_pin_idx(cfg->input_pins[i]); + err = new_analog_input(spec, cfg->input_pins[i], labels[i], + idx, 0x0b); if (err < 0) return err; imux->items[imux->num_items].label = labels[i]; @@ -1910,7 +2108,8 @@ static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const str return 0; } -static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, int pin_type, +static void alc880_auto_set_output_and_unmute(struct hda_codec *codec, + hda_nid_t nid, int pin_type, int dac_idx) { /* set as output */ @@ -1973,15 +2172,17 @@ static int alc880_parse_auto_config(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; int err; + static hda_nid_t alc880_ignore[] = { 0x1d, 0 }; - if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) - return err; - if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0) + if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, + alc880_ignore)) < 0) return err; if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && ! spec->autocfg.hp_pin) return 0; /* can't find valid BIOS pin config */ - if ((err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || + + if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || + (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, "Speaker")) < 0 || (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin, @@ -2024,7 +2225,7 @@ static int patch_alc880(struct hda_codec *codec) { struct alc_spec *spec; int board_config; - int i, err; + int err; spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) @@ -2050,36 +2251,8 @@ static int patch_alc880(struct hda_codec *codec) } } - if (board_config != ALC880_AUTO) { - /* set up from the preset table */ - const struct alc_config_preset *preset; - - preset = &alc880_presets[board_config]; - - for (i = 0; preset->mixers[i]; i++) { - snd_assert(spec->num_mixers < ARRAY_SIZE(spec->mixers), break); - spec->mixers[spec->num_mixers++] = preset->mixers[i]; - } - for (i = 0; preset->init_verbs[i]; i++) { - snd_assert(spec->num_init_verbs < ARRAY_SIZE(spec->init_verbs), break); - spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i]; - } - - spec->channel_mode = preset->channel_mode; - spec->num_channel_mode = preset->num_channel_mode; - - spec->multiout.max_channels = spec->channel_mode[0].channels; - - spec->multiout.num_dacs = preset->num_dacs; - spec->multiout.dac_nids = preset->dac_nids; - spec->multiout.dig_out_nid = preset->dig_out_nid; - spec->multiout.hp_nid = preset->hp_nid; - - spec->input_mux = preset->input_mux; - - spec->num_adc_nids = preset->num_adc_nids; - spec->adc_nids = preset->adc_nids; - } + if (board_config != ALC880_AUTO) + setup_preset(spec, &alc880_presets[board_config]); spec->stream_name_analog = "ALC880 Analog"; spec->stream_analog_playback = &alc880_pcm_analog_playback; @@ -2128,11 +2301,16 @@ static hda_nid_t alc260_adc_nids[1] = { 0x04, }; -static hda_nid_t alc260_hp_adc_nids[1] = { +static hda_nid_t alc260_adc_nids_alt[1] = { /* ADC1 */ 0x05, }; +static hda_nid_t alc260_hp_adc_nids[2] = { + /* ADC1, 0 */ + 0x05, 0x04 +}; + #define ALC260_DIGOUT_NID 0x03 #define ALC260_DIGIN_NID 0x06 @@ -2167,38 +2345,26 @@ static struct hda_channel_mode alc260_modes[1] = { { 2, NULL }, }; -static struct snd_kcontrol_new alc260_base_mixer[] = { + +/* Mixer combinations + * + * basic: base_output + input + pc_beep + capture + * HP: base_output + input + capture_alt + * HP_3013: hp_3013 + input + capture + * fujitsu: fujitsu + capture + */ + +static struct snd_kcontrol_new alc260_base_output_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), - HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), - HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), - HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), - HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT), - HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT), - HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), - HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), - HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), - HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), - HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), - HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), - HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Capture Source", - .info = alc_mux_enum_info, - .get = alc_mux_enum_get, - .put = alc_mux_enum_put, - }, { } /* end */ -}; +}; -static struct snd_kcontrol_new alc260_hp_mixer[] = { - HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT), - HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT), +static struct snd_kcontrol_new alc260_input_mixer[] = { HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT), HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT), HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT), @@ -2207,19 +2373,24 @@ static struct snd_kcontrol_new alc260_hp_mixer[] = { HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT), HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT), HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT), - HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT), - HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT), - HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), - HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT), - HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), - HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), - { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Capture Source", - .info = alc_mux_enum_info, - .get = alc_mux_enum_get, - .put = alc_mux_enum_put, - }, + { } /* end */ +}; + +static struct snd_kcontrol_new alc260_pc_beep_mixer[] = { + HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT), + HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT), + { } /* end */ +}; + +static struct snd_kcontrol_new alc260_hp_3013_mixer[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT), + HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT), + HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT), { } /* end */ }; @@ -2235,11 +2406,43 @@ static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT), HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT), HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT), + { } /* end */ +}; + +/* capture mixer elements */ +static struct snd_kcontrol_new alc260_capture_mixer[] = { HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT), HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT), { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "Capture Source", + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + * FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 2, + .info = alc_mux_enum_info, + .get = alc_mux_enum_get, + .put = alc_mux_enum_put, + }, + { } /* end */ +}; + +static struct snd_kcontrol_new alc260_capture_alt_mixer[] = { + HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + * FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 1, .info = alc_mux_enum_info, .get = alc_mux_enum_get, .put = alc_mux_enum_put, @@ -2247,6 +2450,9 @@ static struct snd_kcontrol_new alc260_fujitsu_mixer[] = { { } /* end */ }; +/* + * initialization verbs + */ static struct hda_verb alc260_init_verbs[] = { /* Line In pin widget for input */ {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, @@ -2308,6 +2514,100 @@ static struct hda_verb alc260_init_verbs[] = { { } }; +static struct hda_verb alc260_hp_init_verbs[] = { + /* Headphone and output */ + {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, + /* mono output */ + {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + /* Mic1 (rear panel) pin widget for input and vref at 80% */ + {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, + /* Mic2 (front panel) pin widget for input and vref at 80% */ + {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, + /* Line In pin widget for input */ + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, + /* Line-2 pin widget for output */ + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + /* CD pin widget for input */ + {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, + /* unmute amp left and right */ + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, + /* set connection select to line in (default select for this ADC) */ + {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, + /* unmute Line-Out mixer amp left and right (volume = 0) */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, + /* mute pin widget amp left and right (no gain on this amp) */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + /* unmute HP mixer amp left and right (volume = 0) */ + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, + /* mute pin widget amp left and right (no gain on this amp) */ + {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ + /* unmute CD */ + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, + /* unmute Line In */ + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, + /* unmute Mic */ + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ + /* Unmute Front out path */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + /* Unmute Headphone out path */ + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + /* Unmute Mono out path */ + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + { } +}; + +static struct hda_verb alc260_hp_3013_init_verbs[] = { + /* Line out and output */ + {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + /* mono output */ + {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + /* Mic1 (rear panel) pin widget for input and vref at 80% */ + {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, + /* Mic2 (front panel) pin widget for input and vref at 80% */ + {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, + /* Line In pin widget for input */ + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, + /* Headphone pin widget for output */ + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, + /* CD pin widget for input */ + {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, + /* unmute amp left and right */ + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000}, + /* set connection select to line in (default select for this ADC) */ + {0x04, AC_VERB_SET_CONNECT_SEL, 0x02}, + /* unmute Line-Out mixer amp left and right (volume = 0) */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, + /* mute pin widget amp left and right (no gain on this amp) */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + /* unmute HP mixer amp left and right (volume = 0) */ + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000}, + /* mute pin widget amp left and right (no gain on this amp) */ + {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */ + /* unmute CD */ + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, + /* unmute Line In */ + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, + /* unmute Mic */ + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */ + /* Unmute Front out path */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + /* Unmute Headphone out path */ + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + /* Unmute Mono out path */ + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, + { } +}; + /* Initialisation sequence for ALC260 as configured in Fujitsu S702x * laptops. */ @@ -2374,18 +2674,337 @@ static struct hda_pcm_stream alc260_pcm_analog_capture = { .channels_max = 2, }; -static struct hda_board_config alc260_cfg_tbl[] = { - { .modelname = "hp", .config = ALC260_HP }, - { .pci_subvendor = 0x103c, .config = ALC260_HP }, - { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702x }, - { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702x }, - {} -}; +/* + * for BIOS auto-configuration + */ -static int patch_alc260(struct hda_codec *codec) +static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid, + const char *pfx) +{ + hda_nid_t nid_vol; + unsigned long vol_val, sw_val; + char name[32]; + int err; + + if (nid >= 0x0f && nid < 0x11) { + nid_vol = nid - 0x7; + vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); + sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); + } else if (nid == 0x11) { + nid_vol = nid - 0x7; + vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT); + sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT); + } else if (nid >= 0x12 && nid <= 0x15) { + nid_vol = 0x08; + vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT); + sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); + } else + return 0; /* N/A */ + + snprintf(name, sizeof(name), "%s Playback Volume", pfx); + if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0) + return err; + snprintf(name, sizeof(name), "%s Playback Switch", pfx); + if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0) + return err; + return 1; +} + +/* add playback controls from the parsed DAC table */ +static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, + const struct auto_pin_cfg *cfg) +{ + hda_nid_t nid; + int err; + + spec->multiout.num_dacs = 1; + spec->multiout.dac_nids = spec->private_dac_nids; + spec->multiout.dac_nids[0] = 0x02; + + nid = cfg->line_out_pins[0]; + if (nid) { + err = alc260_add_playback_controls(spec, nid, "Front"); + if (err < 0) + return err; + } + + nid = cfg->speaker_pin; + if (nid) { + err = alc260_add_playback_controls(spec, nid, "Speaker"); + if (err < 0) + return err; + } + + nid = cfg->hp_pin; + if (nid) { + err = alc260_add_playback_controls(spec, nid, "Headphone"); + if (err < 0) + return err; + } + return 0; +} + +/* create playback/capture controls for input pins */ +static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, + const struct auto_pin_cfg *cfg) +{ + static char *labels[AUTO_PIN_LAST] = { + "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" + }; + struct hda_input_mux *imux = &spec->private_imux; + int i, err, idx; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + if (cfg->input_pins[i] >= 0x12) { + idx = cfg->input_pins[i] - 0x12; + err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); + if (err < 0) + return err; + imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].index = idx; + imux->num_items++; + } + if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ + idx = cfg->input_pins[i] - 0x09; + err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); + if (err < 0) + return err; + imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].index = idx; + imux->num_items++; + } + } + return 0; +} + +static void alc260_auto_set_output_and_unmute(struct hda_codec *codec, + hda_nid_t nid, int pin_type, + int sel_idx) +{ + /* set as output */ + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); + /* need the manual connection? */ + if (nid >= 0x12) { + int idx = nid - 0x12; + snd_hda_codec_write(codec, idx + 0x0b, 0, + AC_VERB_SET_CONNECT_SEL, sel_idx); + + } +} + +static void alc260_auto_init_multi_out(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + hda_nid_t nid; + + nid = spec->autocfg.line_out_pins[0]; + if (nid) + alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); + + nid = spec->autocfg.speaker_pin; + if (nid) + alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); + + nid = spec->autocfg.hp_pin; + if (nid) + alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0); +} + +#define ALC260_PIN_CD_NID 0x16 +static void alc260_auto_init_analog_input(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int i; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + hda_nid_t nid = spec->autocfg.input_pins[i]; + if (nid >= 0x12) { + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, + i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); + if (nid != ALC260_PIN_CD_NID) + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_MUTE); + } + } +} + +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb alc260_volume_init_verbs[] = { + /* + * Unmute ADC0-1 and set the default input to mic-in + */ + {0x04, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x05, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + + /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback + * mixer widget + * Note: PASD motherboards uses the Line In 2 as the input for front panel + * mic (mic 2) + */ + /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, + + /* + * Set up output mixers (0x08 - 0x0a) + */ + /* set vol=0 to output mixers */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + /* set up input amps for analog loopback */ + /* Amp Indices: DAC = 0, mixer = 1 */ + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + { } +}; + +static int alc260_parse_auto_config(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + unsigned int wcap; + int err; + static hda_nid_t alc260_ignore[] = { 0x17, 0 }; + + if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, + alc260_ignore)) < 0) + return err; + if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && + ! spec->autocfg.hp_pin) + return 0; /* can't find valid BIOS pin config */ + if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || + (err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) + return err; + + spec->multiout.max_channels = 2; + + if (spec->autocfg.dig_out_pin) + spec->multiout.dig_out_nid = ALC260_DIGOUT_NID; + if (spec->kctl_alloc) + spec->mixers[spec->num_mixers++] = spec->kctl_alloc; + + spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs; + + spec->input_mux = &spec->private_imux; + + /* check whether NID 0x04 is valid */ + wcap = snd_hda_param_read(codec, alc260_adc_nids[0], AC_PAR_AUDIO_WIDGET_CAP); + wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ + if (wcap != AC_WID_AUD_IN) { + spec->adc_nids = alc260_adc_nids_alt; + spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); + spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; + spec->num_mixers++; + } else { + spec->adc_nids = alc260_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); + spec->mixers[spec->num_mixers] = alc260_capture_mixer; + spec->num_mixers++; + } + + return 1; +} + +/* init callback for auto-configuration model -- overriding the default init */ +static int alc260_auto_init(struct hda_codec *codec) +{ + alc_init(codec); + alc260_auto_init_multi_out(codec); + alc260_auto_init_analog_input(codec); + return 0; +} + +/* + * ALC260 configurations + */ +static struct hda_board_config alc260_cfg_tbl[] = { + { .modelname = "basic", .config = ALC260_BASIC }, + { .modelname = "hp", .config = ALC260_HP }, + { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP }, + { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP }, + { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP }, + { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 }, + { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP }, + { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP }, + { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP }, + { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X }, + { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X }, + { .modelname = "auto", .config = ALC260_AUTO }, + {} +}; + +static struct alc_config_preset alc260_presets[] = { + [ALC260_BASIC] = { + .mixers = { alc260_base_output_mixer, + alc260_input_mixer, + alc260_pc_beep_mixer, + alc260_capture_mixer }, + .init_verbs = { alc260_init_verbs }, + .num_dacs = ARRAY_SIZE(alc260_dac_nids), + .dac_nids = alc260_dac_nids, + .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), + .adc_nids = alc260_adc_nids, + .num_channel_mode = ARRAY_SIZE(alc260_modes), + .channel_mode = alc260_modes, + .input_mux = &alc260_capture_source, + }, + [ALC260_HP] = { + .mixers = { alc260_base_output_mixer, + alc260_input_mixer, + alc260_capture_alt_mixer }, + .init_verbs = { alc260_hp_init_verbs }, + .num_dacs = ARRAY_SIZE(alc260_dac_nids), + .dac_nids = alc260_dac_nids, + .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), + .adc_nids = alc260_hp_adc_nids, + .num_channel_mode = ARRAY_SIZE(alc260_modes), + .channel_mode = alc260_modes, + .input_mux = &alc260_capture_source, + }, + [ALC260_HP_3013] = { + .mixers = { alc260_hp_3013_mixer, + alc260_input_mixer, + alc260_capture_alt_mixer }, + .init_verbs = { alc260_hp_3013_init_verbs }, + .num_dacs = ARRAY_SIZE(alc260_dac_nids), + .dac_nids = alc260_dac_nids, + .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids), + .adc_nids = alc260_hp_adc_nids, + .num_channel_mode = ARRAY_SIZE(alc260_modes), + .channel_mode = alc260_modes, + .input_mux = &alc260_capture_source, + }, + [ALC260_FUJITSU_S702X] = { + .mixers = { alc260_fujitsu_mixer, + alc260_capture_mixer }, + .init_verbs = { alc260_fujitsu_init_verbs }, + .num_dacs = ARRAY_SIZE(alc260_dac_nids), + .dac_nids = alc260_dac_nids, + .num_adc_nids = ARRAY_SIZE(alc260_adc_nids), + .adc_nids = alc260_adc_nids, + .num_channel_mode = ARRAY_SIZE(alc260_modes), + .channel_mode = alc260_modes, + .input_mux = &alc260_fujitsu_capture_source, + }, +}; + +static int patch_alc260(struct hda_codec *codec) { struct alc_spec *spec; - int board_config; + int err, board_config; spec = kzalloc(sizeof(*spec), GFP_KERNEL); if (spec == NULL) @@ -2396,60 +3015,31 @@ static int patch_alc260(struct hda_codec *codec) board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl); if (board_config < 0 || board_config >= ALC260_MODEL_LAST) { snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n"); - board_config = ALC260_BASIC; - } - - switch (board_config) { - case ALC260_HP: - spec->mixers[spec->num_mixers] = alc260_hp_mixer; - spec->num_mixers++; - break; - case ALC260_FUJITSU_S702x: - spec->mixers[spec->num_mixers] = alc260_fujitsu_mixer; - spec->num_mixers++; - break; - default: - spec->mixers[spec->num_mixers] = alc260_base_mixer; - spec->num_mixers++; - break; + board_config = ALC260_AUTO; } - if (board_config != ALC260_FUJITSU_S702x) { - spec->init_verbs[0] = alc260_init_verbs; - spec->num_init_verbs = 1; - } else { - spec->init_verbs[0] = alc260_fujitsu_init_verbs; - spec->num_init_verbs = 1; + if (board_config == ALC260_AUTO) { + /* automatic parse from the BIOS config */ + err = alc260_parse_auto_config(codec); + if (err < 0) { + alc_free(codec); + return err; + } else if (! err) { + printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); + board_config = ALC260_BASIC; + } } - spec->channel_mode = alc260_modes; - spec->num_channel_mode = ARRAY_SIZE(alc260_modes); + if (board_config != ALC260_AUTO) + setup_preset(spec, &alc260_presets[board_config]); spec->stream_name_analog = "ALC260 Analog"; spec->stream_analog_playback = &alc260_pcm_analog_playback; spec->stream_analog_capture = &alc260_pcm_analog_capture; - spec->multiout.max_channels = spec->channel_mode[0].channels; - spec->multiout.num_dacs = ARRAY_SIZE(alc260_dac_nids); - spec->multiout.dac_nids = alc260_dac_nids; - - if (board_config != ALC260_FUJITSU_S702x) { - spec->input_mux = &alc260_capture_source; - } else { - spec->input_mux = &alc260_fujitsu_capture_source; - } - switch (board_config) { - case ALC260_HP: - spec->num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids); - spec->adc_nids = alc260_hp_adc_nids; - break; - default: - spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); - spec->adc_nids = alc260_adc_nids; - break; - } - codec->patch_ops = alc_patch_ops; + if (board_config == ALC260_AUTO) + codec->patch_ops.init = alc260_auto_init; return 0; } @@ -2466,6 +3056,8 @@ static int patch_alc260(struct hda_codec *codec) * In addition, an independent DAC for the multi-playback (not used in this * driver yet). */ +#define ALC882_DIGOUT_NID 0x06 +#define ALC882_DIGIN_NID 0x0a static struct hda_channel_mode alc882_ch_modes[1] = { { 8, NULL } @@ -2476,10 +3068,9 @@ static hda_nid_t alc882_dac_nids[4] = { 0x02, 0x03, 0x04, 0x05 }; -static hda_nid_t alc882_adc_nids[3] = { - /* ADC0-2 */ - 0x07, 0x08, 0x09, -}; +/* identical with ALC880 */ +#define alc882_adc_nids alc880_adc_nids +#define alc882_adc_nids_alt alc880_adc_nids_alt /* input MUX */ /* FIXME: should be a matrix-type input source selection */ @@ -2522,6 +3113,33 @@ static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele return 1; } +/* + * 6ch mode + */ +static struct hda_verb alc882_sixstack_ch6_init[] = { + { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, + { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { } /* end */ +}; + +/* + * 8ch mode + */ +static struct hda_verb alc882_sixstack_ch8_init[] = { + { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, + { } /* end */ +}; + +static struct hda_channel_mode alc882_sixstack_modes[2] = { + { 6, alc882_sixstack_ch6_init }, + { 8, alc882_sixstack_ch8_init }, +}; + /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b */ @@ -2565,6 +3183,17 @@ static struct snd_kcontrol_new alc882_base_mixer[] = { { } /* end */ }; +static struct snd_kcontrol_new alc882_chmode_mixer[] = { + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Channel Mode", + .info = alc_ch_mode_info, + .get = alc_ch_mode_get, + .put = alc_ch_mode_put, + }, + { } /* end */ +}; + static struct hda_verb alc882_init_verbs[] = { /* Front mixer: unmute input/output amp left and right (volume = 0) */ {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, @@ -2645,45 +3274,1399 @@ static struct hda_verb alc882_init_verbs[] = { { } }; -static int patch_alc882(struct hda_codec *codec) -{ - struct alc_spec *spec; - - spec = kzalloc(sizeof(*spec), GFP_KERNEL); - if (spec == NULL) - return -ENOMEM; - - codec->spec = spec; - - spec->mixers[spec->num_mixers] = alc882_base_mixer; - spec->num_mixers++; +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb alc882_auto_init_verbs[] = { + /* + * Unmute ADC0-2 and set the default input to mic-in + */ + {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, - spec->multiout.dig_out_nid = ALC880_DIGOUT_NID; - spec->dig_in_nid = ALC880_DIGIN_NID; - spec->init_verbs[0] = alc882_init_verbs; - spec->num_init_verbs = 1; + /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback + * mixer widget + * Note: PASD motherboards uses the Line In 2 as the input for front panel + * mic (mic 2) + */ + /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, - spec->channel_mode = alc882_ch_modes; - spec->num_channel_mode = ARRAY_SIZE(alc882_ch_modes); + /* + * Set up output mixers (0x0c - 0x0f) + */ + /* set vol=0 to output mixers */ + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + /* set up input amps for analog loopback */ + /* Amp Indices: DAC = 0, mixer = 1 */ + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + /* FIXME: use matrix-type input source selection */ + /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ + /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + /* Input mixer2 */ + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + /* Input mixer3 */ + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + + { } +}; + +/* capture mixer elements */ +static struct snd_kcontrol_new alc882_capture_alt_mixer[] = { + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + * FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 2, + .info = alc882_mux_enum_info, + .get = alc882_mux_enum_get, + .put = alc882_mux_enum_put, + }, + { } /* end */ +}; + +static struct snd_kcontrol_new alc882_capture_mixer[] = { + HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT), + HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + * FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 3, + .info = alc882_mux_enum_info, + .get = alc882_mux_enum_get, + .put = alc882_mux_enum_put, + }, + { } /* end */ +}; + +/* pcm configuration: identiacal with ALC880 */ +#define alc882_pcm_analog_playback alc880_pcm_analog_playback +#define alc882_pcm_analog_capture alc880_pcm_analog_capture +#define alc882_pcm_digital_playback alc880_pcm_digital_playback +#define alc882_pcm_digital_capture alc880_pcm_digital_capture + +/* + * configuration and preset + */ +static struct hda_board_config alc882_cfg_tbl[] = { + { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, + { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, + { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */ + { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */ + { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */ + { .modelname = "auto", .config = ALC861_AUTO }, + {} +}; + +static struct alc_config_preset alc882_presets[] = { + [ALC882_3ST_DIG] = { + .mixers = { alc882_base_mixer }, + .init_verbs = { alc882_init_verbs }, + .num_dacs = ARRAY_SIZE(alc882_dac_nids), + .dac_nids = alc882_dac_nids, + .dig_out_nid = ALC882_DIGOUT_NID, + .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), + .adc_nids = alc882_adc_nids, + .dig_in_nid = ALC882_DIGIN_NID, + .num_channel_mode = ARRAY_SIZE(alc882_ch_modes), + .channel_mode = alc882_ch_modes, + .input_mux = &alc882_capture_source, + }, + [ALC882_6ST_DIG] = { + .mixers = { alc882_base_mixer, alc882_chmode_mixer }, + .init_verbs = { alc882_init_verbs }, + .num_dacs = ARRAY_SIZE(alc882_dac_nids), + .dac_nids = alc882_dac_nids, + .dig_out_nid = ALC882_DIGOUT_NID, + .num_adc_nids = ARRAY_SIZE(alc882_adc_nids), + .adc_nids = alc882_adc_nids, + .dig_in_nid = ALC882_DIGIN_NID, + .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes), + .channel_mode = alc882_sixstack_modes, + .input_mux = &alc882_capture_source, + }, +}; + + +/* + * BIOS auto configuration + */ +static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, + hda_nid_t nid, int pin_type, + int dac_idx) +{ + /* set as output */ + struct alc_spec *spec = codec->spec; + int idx; + + if (spec->multiout.dac_nids[dac_idx] == 0x25) + idx = 4; + else + idx = spec->multiout.dac_nids[dac_idx] - 2; + + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); + +} + +static void alc882_auto_init_multi_out(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int i; + + for (i = 0; i <= HDA_SIDE; i++) { + hda_nid_t nid = spec->autocfg.line_out_pins[i]; + if (nid) + alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i); + } +} + +static void alc882_auto_init_hp_out(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + hda_nid_t pin; + + pin = spec->autocfg.hp_pin; + if (pin) /* connect to front */ + alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */ +} + +#define alc882_is_input_pin(nid) alc880_is_input_pin(nid) +#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID + +static void alc882_auto_init_analog_input(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int i; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + hda_nid_t nid = spec->autocfg.input_pins[i]; + if (alc882_is_input_pin(nid)) { + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, + i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); + if (nid != ALC882_PIN_CD_NID) + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, + AMP_OUT_MUTE); + } + } +} + +/* almost identical with ALC880 parser... */ +static int alc882_parse_auto_config(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int err = alc880_parse_auto_config(codec); + + if (err < 0) + return err; + /* hack - override the init verbs */ + spec->init_verbs[0] = alc882_auto_init_verbs; + return 0; +} + +/* init callback for auto-configuration model -- overriding the default init */ +static int alc882_auto_init(struct hda_codec *codec) +{ + alc_init(codec); + alc882_auto_init_multi_out(codec); + alc882_auto_init_hp_out(codec); + alc882_auto_init_analog_input(codec); + return 0; +} + +/* + * ALC882 Headphone poll in 3.5.1a or 3.5.2 + */ + +static int patch_alc882(struct hda_codec *codec) +{ + struct alc_spec *spec; + int err, board_config; + + spec = kzalloc(sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + + board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl); + + if (board_config < 0 || board_config >= ALC882_MODEL_LAST) { + printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n"); + board_config = ALC882_AUTO; + } + + if (board_config == ALC882_AUTO) { + /* automatic parse from the BIOS config */ + err = alc882_parse_auto_config(codec); + if (err < 0) { + alc_free(codec); + return err; + } else if (! err) { + printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); + board_config = ALC882_3ST_DIG; + } + } + + if (board_config != ALC882_AUTO) + setup_preset(spec, &alc882_presets[board_config]); spec->stream_name_analog = "ALC882 Analog"; - spec->stream_analog_playback = &alc880_pcm_analog_playback; - spec->stream_analog_capture = &alc880_pcm_analog_capture; + spec->stream_analog_playback = &alc882_pcm_analog_playback; + spec->stream_analog_capture = &alc882_pcm_analog_capture; spec->stream_name_digital = "ALC882 Digital"; - spec->stream_digital_playback = &alc880_pcm_digital_playback; - spec->stream_digital_capture = &alc880_pcm_digital_capture; + spec->stream_digital_playback = &alc882_pcm_digital_playback; + spec->stream_digital_capture = &alc882_pcm_digital_capture; - spec->multiout.max_channels = spec->channel_mode[0].channels; - spec->multiout.num_dacs = ARRAY_SIZE(alc882_dac_nids); - spec->multiout.dac_nids = alc882_dac_nids; - - spec->input_mux = &alc882_capture_source; - spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); - spec->adc_nids = alc882_adc_nids; + if (! spec->adc_nids && spec->input_mux) { + /* check whether NID 0x07 is valid */ + unsigned int wcap = snd_hda_param_read(codec, 0x07, + AC_PAR_AUDIO_WIDGET_CAP); + wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ + if (wcap != AC_WID_AUD_IN) { + spec->adc_nids = alc882_adc_nids_alt; + spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt); + spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer; + spec->num_mixers++; + } else { + spec->adc_nids = alc882_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids); + spec->mixers[spec->num_mixers] = alc882_capture_mixer; + spec->num_mixers++; + } + } codec->patch_ops = alc_patch_ops; + if (board_config == ALC882_AUTO) + codec->patch_ops.init = alc882_auto_init; + + return 0; +} + +/* + * ALC262 support + */ + +#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID +#define ALC262_DIGIN_NID ALC880_DIGIN_NID + +#define alc262_dac_nids alc260_dac_nids +#define alc262_adc_nids alc882_adc_nids +#define alc262_adc_nids_alt alc882_adc_nids_alt + +#define alc262_modes alc260_modes + +static struct snd_kcontrol_new alc262_base_mixer[] = { + HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT), + /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT), + HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */ + HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .count = 1, + .info = alc882_mux_enum_info, + .get = alc882_mux_enum_get, + .put = alc882_mux_enum_put, + }, + { } /* end */ +}; + +#define alc262_capture_mixer alc882_capture_mixer +#define alc262_capture_alt_mixer alc882_capture_alt_mixer + +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb alc262_init_verbs[] = { + /* + * Unmute ADC0-2 and set the default input to mic-in + */ + {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + + /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback + * mixer widget + * Note: PASD motherboards uses the Line In 2 as the input for front panel + * mic (mic 2) + */ + /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, + + /* + * Set up output mixers (0x0c - 0x0e) + */ + /* set vol=0 to output mixers */ + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + /* set up input amps for analog loopback */ + /* Amp Indices: DAC = 0, mixer = 1 */ + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0}, + {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40}, + {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, + {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, + {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20}, + + {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000}, + + {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, + + /* FIXME: use matrix-type input source selection */ + /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ + /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + /* Input mixer2 */ + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + /* Input mixer3 */ + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + + { } +}; +/* add playback controls from the parsed DAC table */ +static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) +{ + hda_nid_t nid; + int err; + + spec->multiout.num_dacs = 1; /* only use one dac */ + spec->multiout.dac_nids = spec->private_dac_nids; + spec->multiout.dac_nids[0] = 2; + + nid = cfg->line_out_pins[0]; + if (nid) { + if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume", + HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) + return err; + if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) + return err; + } + + nid = cfg->speaker_pin; + if (nid) { + if (nid == 0x16) { + if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", + HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) + return err; + if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) + return err; + } else { + if (! cfg->line_out_pins[0]) + if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume", + HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) + return err; + if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) + return err; + } + } + nid = cfg->hp_pin; + if (nid) { + /* spec->multiout.hp_nid = 2; */ + if (nid == 0x16) { + if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", + HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0) + return err; + if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) + return err; + } else { + if (! cfg->line_out_pins[0]) + if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume", + HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0) + return err; + if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) + return err; + } + } + return 0; +} + +/* identical with ALC880 */ +#define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls + +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb alc262_volume_init_verbs[] = { + /* + * Unmute ADC0-2 and set the default input to mic-in + */ + {0x07, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x09, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + + /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback + * mixer widget + * Note: PASD motherboards uses the Line In 2 as the input for front panel + * mic (mic 2) + */ + /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */ + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)}, + + /* + * Set up output mixers (0x0c - 0x0f) + */ + /* set vol=0 to output mixers */ + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, + + /* set up input amps for analog loopback */ + /* Amp Indices: DAC = 0, mixer = 1 */ + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + /* FIXME: use matrix-type input source selection */ + /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */ + /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */ + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + /* Input mixer2 */ + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + /* Input mixer3 */ + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))}, + {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))}, + + { } +}; + +/* pcm configuration: identiacal with ALC880 */ +#define alc262_pcm_analog_playback alc880_pcm_analog_playback +#define alc262_pcm_analog_capture alc880_pcm_analog_capture +#define alc262_pcm_digital_playback alc880_pcm_digital_playback +#define alc262_pcm_digital_capture alc880_pcm_digital_capture + +/* + * BIOS auto configuration + */ +static int alc262_parse_auto_config(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int err; + static hda_nid_t alc262_ignore[] = { 0x1d, 0 }; + + if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, + alc262_ignore)) < 0) + return err; + if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && + ! spec->autocfg.hp_pin) + return 0; /* can't find valid BIOS pin config */ + if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || + (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) + return err; + + spec->multiout.max_channels = spec->multiout.num_dacs * 2; + + if (spec->autocfg.dig_out_pin) + spec->multiout.dig_out_nid = ALC262_DIGOUT_NID; + if (spec->autocfg.dig_in_pin) + spec->dig_in_nid = ALC262_DIGIN_NID; + + if (spec->kctl_alloc) + spec->mixers[spec->num_mixers++] = spec->kctl_alloc; + + spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs; + spec->input_mux = &spec->private_imux; + + return 1; +} + +#define alc262_auto_init_multi_out alc882_auto_init_multi_out +#define alc262_auto_init_hp_out alc882_auto_init_hp_out +#define alc262_auto_init_analog_input alc882_auto_init_analog_input + + +/* init callback for auto-configuration model -- overriding the default init */ +static int alc262_auto_init(struct hda_codec *codec) +{ + alc_init(codec); + alc262_auto_init_multi_out(codec); + alc262_auto_init_hp_out(codec); + alc262_auto_init_analog_input(codec); + return 0; +} + +/* + * configuration and preset + */ +static struct hda_board_config alc262_cfg_tbl[] = { + { .modelname = "basic", .config = ALC262_BASIC }, + { .modelname = "auto", .config = ALC262_AUTO }, + {} +}; + +static struct alc_config_preset alc262_presets[] = { + [ALC262_BASIC] = { + .mixers = { alc262_base_mixer }, + .init_verbs = { alc262_init_verbs }, + .num_dacs = ARRAY_SIZE(alc262_dac_nids), + .dac_nids = alc262_dac_nids, + .hp_nid = 0x03, + .num_channel_mode = ARRAY_SIZE(alc262_modes), + .channel_mode = alc262_modes, + }, +}; + +static int patch_alc262(struct hda_codec *codec) +{ + struct alc_spec *spec; + int board_config; + int err; + + spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; +#if 0 + /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */ + { + int tmp; + snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); + tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); + snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); + snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); + } +#endif + + board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl); + if (board_config < 0 || board_config >= ALC262_MODEL_LAST) { + printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n"); + board_config = ALC262_AUTO; + } + + if (board_config == ALC262_AUTO) { + /* automatic parse from the BIOS config */ + err = alc262_parse_auto_config(codec); + if (err < 0) { + alc_free(codec); + return err; + } else if (! err) { + printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); + board_config = ALC262_BASIC; + } + } + + if (board_config != ALC262_AUTO) + setup_preset(spec, &alc262_presets[board_config]); + + spec->stream_name_analog = "ALC262 Analog"; + spec->stream_analog_playback = &alc262_pcm_analog_playback; + spec->stream_analog_capture = &alc262_pcm_analog_capture; + + spec->stream_name_digital = "ALC262 Digital"; + spec->stream_digital_playback = &alc262_pcm_digital_playback; + spec->stream_digital_capture = &alc262_pcm_digital_capture; + + if (! spec->adc_nids && spec->input_mux) { + /* check whether NID 0x07 is valid */ + unsigned int wcap = snd_hda_param_read(codec, 0x07, + AC_PAR_AUDIO_WIDGET_CAP); + wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ + if (wcap != AC_WID_AUD_IN) { + spec->adc_nids = alc262_adc_nids_alt; + spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt); + spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer; + spec->num_mixers++; + } else { + spec->adc_nids = alc262_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids); + spec->mixers[spec->num_mixers] = alc262_capture_mixer; + spec->num_mixers++; + } + } + + codec->patch_ops = alc_patch_ops; + if (board_config == ALC262_AUTO) + codec->patch_ops.init = alc262_auto_init; + + return 0; +} + + +/* + * ALC861 channel source setting (2/6 channel selection for 3-stack) + */ + +/* + * set the path ways for 2 channel output + * need to set the codec line out and mic 1 pin widgets to inputs + */ +static struct hda_verb alc861_threestack_ch2_init[] = { + /* set pin widget 1Ah (line in) for input */ + { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, + /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */ + { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, + + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in + { } /* end */ +}; +/* + * 6ch mode + * need to set the codec line out and mic 1 pin widgets to outputs + */ +static struct hda_verb alc861_threestack_ch6_init[] = { + /* set pin widget 1Ah (line in) for output (Back Surround)*/ + { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + /* set pin widget 18h (mic1) for output (CLFE)*/ + { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + + { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 }, + { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 }, + + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 }, + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic + { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in + { } /* end */ +}; + +static struct hda_channel_mode alc861_threestack_modes[2] = { + { 2, alc861_threestack_ch2_init }, + { 6, alc861_threestack_ch6_init }, +}; + +/* patch-ALC861 */ + +static struct snd_kcontrol_new alc861_base_mixer[] = { + /* output mixer control */ + HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), + + /*Input mixer control */ + /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ + HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), + + /* Capture mixer control */ + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .count = 1, + .info = alc_mux_enum_info, + .get = alc_mux_enum_get, + .put = alc_mux_enum_put, + }, + { } /* end */ +}; + +static struct snd_kcontrol_new alc861_3ST_mixer[] = { + /* output mixer control */ + HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT), + /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */ + + /* Input mixer control */ + /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT), + HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */ + HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT), + HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT), + HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT), + HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT), + HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT), + HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT), + + /* Capture mixer control */ + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .count = 1, + .info = alc_mux_enum_info, + .get = alc_mux_enum_get, + .put = alc_mux_enum_put, + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Channel Mode", + .info = alc_ch_mode_info, + .get = alc_ch_mode_get, + .put = alc_ch_mode_put, + .private_value = ARRAY_SIZE(alc861_threestack_modes), + }, + { } /* end */ +}; + +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb alc861_base_init_verbs[] = { + /* + * Unmute ADC0 and set the default input to mic-in + */ + /* port-A for surround (rear panel) */ + { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 }, + /* port-B for mic-in (rear panel) with vref */ + { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, + /* port-C for line-in (rear panel) */ + { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, + /* port-D for Front */ + { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, + /* port-E for HP out (front panel) */ + { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, + /* route front PCM to HP */ + { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, + /* port-F for mic-in (front panel) with vref */ + { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, + /* port-G for CLFE (rear panel) */ + { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 }, + /* port-H for side (rear panel) */ + { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 }, + /* CD-in */ + { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, + /* route front mic to ADC1*/ + {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + + /* Unmute DAC0~3 & spdif out*/ + {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + + /* Unmute Mixer 14 (mic) 1c (Line in)*/ + {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + /* Unmute Stereo Mixer 15 */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step + + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + + { } +}; + +static struct hda_verb alc861_threestack_init_verbs[] = { + /* + * Unmute ADC0 and set the default input to mic-in + */ + /* port-A for surround (rear panel) */ + { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, + /* port-B for mic-in (rear panel) with vref */ + { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, + /* port-C for line-in (rear panel) */ + { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, + /* port-D for Front */ + { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 }, + { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 }, + /* port-E for HP out (front panel) */ + { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, + /* route front PCM to HP */ + { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 }, + /* port-F for mic-in (front panel) with vref */ + { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, + /* port-G for CLFE (rear panel) */ + { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, + /* port-H for side (rear panel) */ + { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 }, + /* CD-in */ + { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 }, + /* route front mic to ADC1*/ + {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + /* Unmute DAC0~3 & spdif out*/ + {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + + /* Unmute Mixer 14 (mic) 1c (Line in)*/ + {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + /* Unmute Stereo Mixer 15 */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step + + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front) + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + { } +}; +/* + * generic initialization of ADC, input mixers and output mixers + */ +static struct hda_verb alc861_auto_init_verbs[] = { + /* + * Unmute ADC0 and set the default input to mic-in + */ +// {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, + {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + + /* Unmute DAC0~3 & spdif out*/ + {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, + {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, + + /* Unmute Mixer 14 (mic) 1c (Line in)*/ + {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + /* Unmute Stereo Mixer 15 */ + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, + + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, + {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, + + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)}, + {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, + + {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1 + + { } +}; + +/* pcm configuration: identiacal with ALC880 */ +#define alc861_pcm_analog_playback alc880_pcm_analog_playback +#define alc861_pcm_analog_capture alc880_pcm_analog_capture +#define alc861_pcm_digital_playback alc880_pcm_digital_playback +#define alc861_pcm_digital_capture alc880_pcm_digital_capture + + +#define ALC861_DIGOUT_NID 0x07 + +static struct hda_channel_mode alc861_8ch_modes[1] = { + { 8, NULL } +}; + +static hda_nid_t alc861_dac_nids[4] = { + /* front, surround, clfe, side */ + 0x03, 0x06, 0x05, 0x04 +}; + +static hda_nid_t alc861_adc_nids[1] = { + /* ADC0-2 */ + 0x08, +}; + +static struct hda_input_mux alc861_capture_source = { + .num_items = 5, + .items = { + { "Mic", 0x0 }, + { "Front Mic", 0x3 }, + { "Line", 0x1 }, + { "CD", 0x4 }, + { "Mixer", 0x5 }, + }, +}; + +/* fill in the dac_nids table from the parsed pin configuration */ +static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg) +{ + int i; + hda_nid_t nid; + + spec->multiout.dac_nids = spec->private_dac_nids; + for (i = 0; i < cfg->line_outs; i++) { + nid = cfg->line_out_pins[i]; + if (nid) { + if (i >= ARRAY_SIZE(alc861_dac_nids)) + continue; + spec->multiout.dac_nids[i] = alc861_dac_nids[i]; + } + } + spec->multiout.num_dacs = cfg->line_outs; + return 0; +} + +/* add playback controls from the parsed DAC table */ +static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec, + const struct auto_pin_cfg *cfg) +{ + char name[32]; + static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" }; + hda_nid_t nid; + int i, idx, err; + + for (i = 0; i < cfg->line_outs; i++) { + nid = spec->multiout.dac_nids[i]; + if (! nid) + continue; + if (nid == 0x05) { + /* Center/LFE */ + if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0) + return err; + if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0) + return err; + } else { + for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++) + if (nid == alc861_dac_nids[idx]) + break; + sprintf(name, "%s Playback Switch", chname[idx]); + if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name, + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) + return err; + } + } + return 0; +} + +static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) +{ + int err; + hda_nid_t nid; + + if (! pin) + return 0; + + if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) { + nid = 0x03; + if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch", + HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0) + return err; + spec->multiout.hp_nid = nid; + } + return 0; +} + +/* create playback/capture controls for input pins */ +static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) +{ + static char *labels[AUTO_PIN_LAST] = { + "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" + }; + struct hda_input_mux *imux = &spec->private_imux; + int i, err, idx, idx1; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + switch(cfg->input_pins[i]) { + case 0x0c: + idx1 = 1; + idx = 2; // Line In + break; + case 0x0f: + idx1 = 2; + idx = 2; // Line In + break; + case 0x0d: + idx1 = 0; + idx = 1; // Mic In + break; + case 0x10: + idx1 = 3; + idx = 1; // Mic In + break; + case 0x11: + idx1 = 4; + idx = 0; // CD + break; + default: + continue; + } + + err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x15); + if (err < 0) + return err; + + imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].index = idx1; + imux->num_items++; + } + return 0; +} + +static struct snd_kcontrol_new alc861_capture_mixer[] = { + HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT), + HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT), + + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* The multiple "Capture Source" controls confuse alsamixer + * So call somewhat different.. + *FIXME: the controls appear in the "playback" view! + */ + /* .name = "Capture Source", */ + .name = "Input Source", + .count = 1, + .info = alc_mux_enum_info, + .get = alc_mux_enum_get, + .put = alc_mux_enum_put, + }, + { } /* end */ +}; + +static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid, + int pin_type, int dac_idx) +{ + /* set as output */ + + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); + snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); + +} + +static void alc861_auto_init_multi_out(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int i; + + for (i = 0; i < spec->autocfg.line_outs; i++) { + hda_nid_t nid = spec->autocfg.line_out_pins[i]; + if (nid) + alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]); + } +} + +static void alc861_auto_init_hp_out(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + hda_nid_t pin; + + pin = spec->autocfg.hp_pin; + if (pin) /* connect to front */ + alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]); +} + +static void alc861_auto_init_analog_input(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int i; + + for (i = 0; i < AUTO_PIN_LAST; i++) { + hda_nid_t nid = spec->autocfg.input_pins[i]; + if ((nid>=0x0c) && (nid <=0x11)) { + snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, + i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN); + } + } +} + +/* parse the BIOS configuration and set up the alc_spec */ +/* return 1 if successful, 0 if the proper config is not found, or a negative error code */ +static int alc861_parse_auto_config(struct hda_codec *codec) +{ + struct alc_spec *spec = codec->spec; + int err; + static hda_nid_t alc861_ignore[] = { 0x1d, 0 }; + + if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, + alc861_ignore)) < 0) + return err; + if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && + ! spec->autocfg.hp_pin) + return 0; /* can't find valid BIOS pin config */ + + if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 || + (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || + (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 || + (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) + return err; + + spec->multiout.max_channels = spec->multiout.num_dacs * 2; + + if (spec->autocfg.dig_out_pin) + spec->multiout.dig_out_nid = ALC861_DIGOUT_NID; + + if (spec->kctl_alloc) + spec->mixers[spec->num_mixers++] = spec->kctl_alloc; + + spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs; + + spec->input_mux = &spec->private_imux; + + spec->adc_nids = alc861_adc_nids; + spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); + spec->mixers[spec->num_mixers] = alc861_capture_mixer; + spec->num_mixers++; + + return 1; +} + +/* init callback for auto-configuration model -- overriding the default init */ +static int alc861_auto_init(struct hda_codec *codec) +{ + alc_init(codec); + alc861_auto_init_multi_out(codec); + alc861_auto_init_hp_out(codec); + alc861_auto_init_analog_input(codec); + + return 0; +} + + +/* + * configuration and preset + */ +static struct hda_board_config alc861_cfg_tbl[] = { + { .modelname = "3stack", .config = ALC861_3ST }, + { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST }, + { .modelname = "3stack-dig", .config = ALC861_3ST_DIG }, + { .modelname = "6stack-dig", .config = ALC861_6ST_DIG }, + { .modelname = "auto", .config = ALC861_AUTO }, + {} +}; + +static struct alc_config_preset alc861_presets[] = { + [ALC861_3ST] = { + .mixers = { alc861_3ST_mixer }, + .init_verbs = { alc861_threestack_init_verbs }, + .num_dacs = ARRAY_SIZE(alc861_dac_nids), + .dac_nids = alc861_dac_nids, + .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), + .channel_mode = alc861_threestack_modes, + .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), + .adc_nids = alc861_adc_nids, + .input_mux = &alc861_capture_source, + }, + [ALC861_3ST_DIG] = { + .mixers = { alc861_base_mixer }, + .init_verbs = { alc861_threestack_init_verbs }, + .num_dacs = ARRAY_SIZE(alc861_dac_nids), + .dac_nids = alc861_dac_nids, + .dig_out_nid = ALC861_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes), + .channel_mode = alc861_threestack_modes, + .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), + .adc_nids = alc861_adc_nids, + .input_mux = &alc861_capture_source, + }, + [ALC861_6ST_DIG] = { + .mixers = { alc861_base_mixer }, + .init_verbs = { alc861_base_init_verbs }, + .num_dacs = ARRAY_SIZE(alc861_dac_nids), + .dac_nids = alc861_dac_nids, + .dig_out_nid = ALC861_DIGOUT_NID, + .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes), + .channel_mode = alc861_8ch_modes, + .num_adc_nids = ARRAY_SIZE(alc861_adc_nids), + .adc_nids = alc861_adc_nids, + .input_mux = &alc861_capture_source, + }, +}; + + +static int patch_alc861(struct hda_codec *codec) +{ + struct alc_spec *spec; + int board_config; + int err; + + spec = kcalloc(1, sizeof(*spec), GFP_KERNEL); + if (spec == NULL) + return -ENOMEM; + + codec->spec = spec; + + board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl); + if (board_config < 0 || board_config >= ALC861_MODEL_LAST) { + printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n"); + board_config = ALC861_AUTO; + } + + if (board_config == ALC861_AUTO) { + /* automatic parse from the BIOS config */ + err = alc861_parse_auto_config(codec); + if (err < 0) { + alc_free(codec); + return err; + } else if (! err) { + printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n"); + board_config = ALC861_3ST_DIG; + } + } + + if (board_config != ALC861_AUTO) + setup_preset(spec, &alc861_presets[board_config]); + + spec->stream_name_analog = "ALC861 Analog"; + spec->stream_analog_playback = &alc861_pcm_analog_playback; + spec->stream_analog_capture = &alc861_pcm_analog_capture; + + spec->stream_name_digital = "ALC861 Digital"; + spec->stream_digital_playback = &alc861_pcm_digital_playback; + spec->stream_digital_capture = &alc861_pcm_digital_capture; + + codec->patch_ops = alc_patch_ops; + if (board_config == ALC861_AUTO) + codec->patch_ops.init = alc861_auto_init; + return 0; } @@ -2692,7 +4675,11 @@ static int patch_alc882(struct hda_codec *codec) */ struct hda_codec_preset snd_hda_preset_realtek[] = { { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, + { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, + { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, + { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, + { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, {} /* terminator */ }; diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 78662d3..8311c9f 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -761,7 +761,7 @@ static int stac922x_parse_auto_config(struct hda_codec *codec) struct sigmatel_spec *spec = codec->spec; int err; - if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) + if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) return err; if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) return err; @@ -801,7 +801,7 @@ static int stac9200_parse_auto_config(struct hda_codec *codec) struct sigmatel_spec *spec = codec->spec; int err; - if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg)) < 0) + if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0) return err; if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0) -- cgit v1.1 From 031c95d4338127a9599fcb7d449f4aa6f086786b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Dec 2005 20:51:43 +0100 Subject: [ALSA] ac97 - Small fix for ALC65x codec Modules: AC97 Codec Small fix for ALC65x codec, sync with Realtek's driver codes: - Rename 'IEC958 Playback Route' to 'IEC958 Playback Source' so that mixer can handle it properly Signed-off-by: Takashi Iwai --- sound/pci/ac97/ac97_codec.c | 2 ++ sound/pci/ac97/ac97_patch.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 17c3dda..33d7a1f 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -2411,6 +2411,8 @@ static int tune_alc_jack(struct snd_ac97 *ac97) } snd_ac97_update_bits(ac97, 0x7a, 0x20, 0x20); /* select jack detect function */ snd_ac97_update_bits(ac97, 0x7a, 0x01, 0x01); /* Line-out auto mute */ + if (ac97->id == AC97_ID_ALC658D) + snd_ac97_update_bits(ac97, 0x74, 0x0800, 0x0800); return snd_ctl_add(ac97->bus->card, snd_ac97_cnew(&snd_ac97_alc_jack_detect, ac97)); } diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 1b72bc2..4aa5fdc 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -2116,7 +2116,7 @@ static const struct snd_kcontrol_new snd_ac97_spdif_controls_alc655[] = { /* AC97_PAGE_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 14, 1, 0, 0), */ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Route", + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source", .info = alc655_iec958_route_info, .get = alc655_iec958_route_get, .put = alc655_iec958_route_put, -- cgit v1.1 From 46a1736d7c07687e7456f72b238a68034fd5a624 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 5 Dec 2005 21:16:37 +0100 Subject: [ALSA] via82xx - Add dxs entry for ASRock mobo Modules: VIA82xx driver Added dxs_support entry for ASRock mobo. Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index ce4985f..6e6eff3 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -2366,6 +2366,7 @@ static int __devinit check_dxs_list(struct pci_dev *pci) { .subvendor = 0x1631, .subdevice = 0xe004, .action = VIA_DXS_ENABLE }, /* Easy Note 3174, Packard Bell */ { .subvendor = 0x1695, .subdevice = 0x3005, .action = VIA_DXS_ENABLE }, /* EPoX EP-8K9A */ { .subvendor = 0x1849, .subdevice = 0x3059, .action = VIA_DXS_NO_VRA }, /* ASRock K7VM2 */ + { .subvendor = 0x1849, .subdevice = 0x9761, .action = VIA_DXS_SRC }, /* ASRock mobo(?) */ { .subvendor = 0x1919, .subdevice = 0x200a, .action = VIA_DXS_NO_VRA }, /* Soltek SL-K8Tpro-939 */ { .subvendor = 0x4005, .subdevice = 0x4710, .action = VIA_DXS_SRC }, /* MSI K7T266 Pro2 (MS-6380 V2.0) BIOS 3.7 */ { } /* terminator */ -- cgit v1.1 From e12229b4d2b7863b1baaeca759aa87703bf9fdf8 Mon Sep 17 00:00:00 2001 From: Markus Bollinger Date: Tue, 6 Dec 2005 13:55:26 +0100 Subject: [ALSA] Add PCXHR driver Modules: Documentation,PCI drivers,Digigram PCXHR driver Add Digigram PCXHR driver. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/ALSA-Configuration.txt | 7 + sound/pci/Kconfig | 11 + sound/pci/Makefile | 1 + sound/pci/pcxhr/Makefile | 2 + sound/pci/pcxhr/pcxhr.c | 1367 +++++++++++++++++++++++ sound/pci/pcxhr/pcxhr.h | 188 ++++ sound/pci/pcxhr/pcxhr_core.c | 1214 ++++++++++++++++++++ sound/pci/pcxhr/pcxhr_core.h | 200 ++++ sound/pci/pcxhr/pcxhr_hwdep.c | 438 ++++++++ sound/pci/pcxhr/pcxhr_hwdep.h | 40 + sound/pci/pcxhr/pcxhr_mixer.c | 1020 +++++++++++++++++ sound/pci/pcxhr/pcxhr_mixer.h | 29 + 12 files changed, 4517 insertions(+) create mode 100644 sound/pci/pcxhr/Makefile create mode 100644 sound/pci/pcxhr/pcxhr.c create mode 100644 sound/pci/pcxhr/pcxhr.h create mode 100644 sound/pci/pcxhr/pcxhr_core.c create mode 100644 sound/pci/pcxhr/pcxhr_core.h create mode 100644 sound/pci/pcxhr/pcxhr_hwdep.c create mode 100644 sound/pci/pcxhr/pcxhr_hwdep.h create mode 100644 sound/pci/pcxhr/pcxhr_mixer.c create mode 100644 sound/pci/pcxhr/pcxhr_mixer.h diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index c30fd30..d257801 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -1103,6 +1103,13 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. This module supports only one card, autoprobe and PnP. + Module snd-pcxhr + ---------------- + + Module for Digigram PCXHR boards + + This module supports multiple cards. + Module snd-powermac (on ppc only) --------------------------------- diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index ef7bdc5..1e2e193 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -455,6 +455,17 @@ config SND_NM256 To compile this driver as a module, choose M here: the module will be called snd-nm256. +config SND_PCXHR + tristate "Digigram PCXHR" + depends on SND + select SND_PCM + select SND_HWDEP + help + Say Y here to include support for Digigram PCXHR boards. + + To compile this driver as a module, choose M here: the module + will be called snd-pcxhr. + config SND_RME32 tristate "RME Digi32, 32/8, 32 PRO" depends on SND diff --git a/sound/pci/Makefile b/sound/pci/Makefile index 82a9c73..a6c3cd5 100644 --- a/sound/pci/Makefile +++ b/sound/pci/Makefile @@ -61,6 +61,7 @@ obj-$(CONFIG_SND) += \ korg1212/ \ mixart/ \ nm256/ \ + pcxhr/ \ rme9652/ \ trident/ \ ymfpci/ \ diff --git a/sound/pci/pcxhr/Makefile b/sound/pci/pcxhr/Makefile new file mode 100644 index 0000000..10473c0 --- /dev/null +++ b/sound/pci/pcxhr/Makefile @@ -0,0 +1,2 @@ +snd-pcxhr-objs := pcxhr.o pcxhr_hwdep.o pcxhr_mixer.o pcxhr_core.o +obj-$(CONFIG_SND_PCXHR) += snd-pcxhr.o diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c new file mode 100644 index 0000000..b8c0853 --- /dev/null +++ b/sound/pci/pcxhr/pcxhr.c @@ -0,0 +1,1367 @@ +/* + * Driver for Digigram pcxhr compatible soundcards + * + * main file with alsa callbacks + * + * Copyright (c) 2004 by Digigram + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pcxhr.h" +#include "pcxhr_mixer.h" +#include "pcxhr_hwdep.h" +#include "pcxhr_core.h" + +#define DRIVER_NAME "pcxhr" + +MODULE_AUTHOR("Markus Bollinger "); +MODULE_DESCRIPTION("Digigram " DRIVER_NAME " " PCXHR_DRIVER_VERSION_STRING); +MODULE_LICENSE("GPL"); +MODULE_SUPPORTED_DEVICE("{{Digigram," DRIVER_NAME "}}"); + +static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ +static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ +static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ +static int mono[SNDRV_CARDS]; /* capture in mono only */ + +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "Index value for Digigram " DRIVER_NAME " soundcard"); +module_param_array(id, charp, NULL, 0444); +MODULE_PARM_DESC(id, "ID string for Digigram " DRIVER_NAME " soundcard"); +module_param_array(enable, bool, NULL, 0444); +MODULE_PARM_DESC(enable, "Enable Digigram " DRIVER_NAME " soundcard"); +module_param_array(mono, bool, NULL, 0444); +MODULE_PARM_DESC(mono, "Mono capture mode (default is stereo)"); + +enum { + PCI_ID_VX882HR, + PCI_ID_PCX882HR, + PCI_ID_VX881HR, + PCI_ID_PCX881HR, + PCI_ID_PCX1222HR, + PCI_ID_PCX1221HR, + PCI_ID_LAST +}; + +static struct pci_device_id pcxhr_ids[] = { + { 0x10b5, 0x9656, 0x1369, 0xb001, 0, 0, PCI_ID_VX882HR, }, /* VX882HR */ + { 0x10b5, 0x9656, 0x1369, 0xb101, 0, 0, PCI_ID_PCX882HR, }, /* PCX882HR */ + { 0x10b5, 0x9656, 0x1369, 0xb201, 0, 0, PCI_ID_VX881HR, }, /* VX881HR */ + { 0x10b5, 0x9656, 0x1369, 0xb301, 0, 0, PCI_ID_PCX881HR, }, /* PCX881HR */ + { 0x10b5, 0x9656, 0x1369, 0xb501, 0, 0, PCI_ID_PCX1222HR, }, /* PCX1222HR */ + { 0x10b5, 0x9656, 0x1369, 0xb701, 0, 0, PCI_ID_PCX1221HR, }, /* PCX1221HR */ + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, pcxhr_ids); + +struct board_parameters { + char* board_name; + short playback_chips; + short capture_chips; + short firmware_num; +}; +static struct board_parameters pcxhr_board_params[] = { +[PCI_ID_VX882HR] = { "VX882HR", 4, 4, 41, }, +[PCI_ID_PCX882HR] = { "PCX882HR", 4, 4, 41, }, +[PCI_ID_VX881HR] = { "VX881HR", 4, 4, 41, }, +[PCI_ID_PCX881HR] = { "PCX881HR", 4, 4, 41, }, +[PCI_ID_PCX1222HR] = { "PCX1222HR", 6, 1, 42, }, +[PCI_ID_PCX1221HR] = { "PCX1221HR", 6, 1, 42, }, +}; + + +static int pcxhr_pll_freq_register(unsigned int freq, unsigned int* pllreg, + unsigned int* realfreq) +{ + unsigned int reg; + + if (freq < 6900 || freq > 110250) + return -EINVAL; + reg = (28224000 * 10) / freq; + reg = (reg + 5) / 10; + if (reg < 0x200) + *pllreg = reg + 0x800; + else if (reg < 0x400) + *pllreg = reg & 0x1ff; + else if (reg < 0x800) { + *pllreg = ((reg >> 1) & 0x1ff) + 0x200; + reg &= ~1; + } else { + *pllreg = ((reg >> 2) & 0x1ff) + 0x400; + reg &= ~3; + } + if (realfreq) + *realfreq = ((28224000 * 10) / reg + 5) / 10; + return 0; +} + + +#define PCXHR_FREQ_REG_MASK 0x1f +#define PCXHR_FREQ_QUARTZ_48000 0x00 +#define PCXHR_FREQ_QUARTZ_24000 0x01 +#define PCXHR_FREQ_QUARTZ_12000 0x09 +#define PCXHR_FREQ_QUARTZ_32000 0x08 +#define PCXHR_FREQ_QUARTZ_16000 0x04 +#define PCXHR_FREQ_QUARTZ_8000 0x0c +#define PCXHR_FREQ_QUARTZ_44100 0x02 +#define PCXHR_FREQ_QUARTZ_22050 0x0a +#define PCXHR_FREQ_QUARTZ_11025 0x06 +#define PCXHR_FREQ_PLL 0x05 +#define PCXHR_FREQ_QUARTZ_192000 0x10 +#define PCXHR_FREQ_QUARTZ_96000 0x18 +#define PCXHR_FREQ_QUARTZ_176400 0x14 +#define PCXHR_FREQ_QUARTZ_88200 0x1c +#define PCXHR_FREQ_QUARTZ_128000 0x12 +#define PCXHR_FREQ_QUARTZ_64000 0x1a + +#define PCXHR_FREQ_WORD_CLOCK 0x0f +#define PCXHR_FREQ_SYNC_AES 0x0e +#define PCXHR_FREQ_AES_1 0x07 +#define PCXHR_FREQ_AES_2 0x0b +#define PCXHR_FREQ_AES_3 0x03 +#define PCXHR_FREQ_AES_4 0x0d + +#define PCXHR_MODIFY_CLOCK_S_BIT 0x04 + +#define PCXHR_IRQ_TIMER_FREQ 92000 +#define PCXHR_IRQ_TIMER_PERIOD 48 + +static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate, + unsigned int *reg, unsigned int *freq) +{ + unsigned int val, realfreq, pllreg; + struct pcxhr_rmh rmh; + int err; + + realfreq = rate; + switch (mgr->use_clock_type) { + case PCXHR_CLOCK_TYPE_INTERNAL : /* clock by quartz or pll */ + switch (rate) { + case 48000 : val = PCXHR_FREQ_QUARTZ_48000; break; + case 24000 : val = PCXHR_FREQ_QUARTZ_24000; break; + case 12000 : val = PCXHR_FREQ_QUARTZ_12000; break; + case 32000 : val = PCXHR_FREQ_QUARTZ_32000; break; + case 16000 : val = PCXHR_FREQ_QUARTZ_16000; break; + case 8000 : val = PCXHR_FREQ_QUARTZ_8000; break; + case 44100 : val = PCXHR_FREQ_QUARTZ_44100; break; + case 22050 : val = PCXHR_FREQ_QUARTZ_22050; break; + case 11025 : val = PCXHR_FREQ_QUARTZ_11025; break; + case 192000 : val = PCXHR_FREQ_QUARTZ_192000; break; + case 96000 : val = PCXHR_FREQ_QUARTZ_96000; break; + case 176400 : val = PCXHR_FREQ_QUARTZ_176400; break; + case 88200 : val = PCXHR_FREQ_QUARTZ_88200; break; + case 128000 : val = PCXHR_FREQ_QUARTZ_128000; break; + case 64000 : val = PCXHR_FREQ_QUARTZ_64000; break; + default : + val = PCXHR_FREQ_PLL; + /* get the value for the pll register */ + err = pcxhr_pll_freq_register(rate, &pllreg, &realfreq); + if (err) + return err; + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); + rmh.cmd[0] |= IO_NUM_REG_GENCLK; + rmh.cmd[1] = pllreg & MASK_DSP_WORD; + rmh.cmd[2] = pllreg >> 24; + rmh.cmd_len = 3; + err = pcxhr_send_msg(mgr, &rmh); + if (err < 0) { + snd_printk(KERN_ERR + "error CMD_ACCESS_IO_WRITE for PLL register : %x!\n", + err ); + return err; + } + } + break; + case PCXHR_CLOCK_TYPE_WORD_CLOCK : val = PCXHR_FREQ_WORD_CLOCK; break; + case PCXHR_CLOCK_TYPE_AES_SYNC : val = PCXHR_FREQ_SYNC_AES; break; + case PCXHR_CLOCK_TYPE_AES_1 : val = PCXHR_FREQ_AES_1; break; + case PCXHR_CLOCK_TYPE_AES_2 : val = PCXHR_FREQ_AES_2; break; + case PCXHR_CLOCK_TYPE_AES_3 : val = PCXHR_FREQ_AES_3; break; + case PCXHR_CLOCK_TYPE_AES_4 : val = PCXHR_FREQ_AES_4; break; + default : return -EINVAL; + } + *reg = val; + *freq = realfreq; + return 0; +} + + +int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) +{ + unsigned int val, realfreq, speed; + struct pcxhr_rmh rmh; + int err, changed; + + if (rate == 0) + return 0; /* nothing to do */ + + err = pcxhr_get_clock_reg(mgr, rate, &val, &realfreq); + if (err) + return err; + + /* codec speed modes */ + if (rate < 55000) + speed = 0; /* single speed */ + else if (rate < 100000) + speed = 1; /* dual speed */ + else + speed = 2; /* quad speed */ + if (mgr->codec_speed != speed) { + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); /* mute outputs */ + rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); /* set speed ratio */ + rmh.cmd[0] |= IO_NUM_SPEED_RATIO; + rmh.cmd[1] = speed; + rmh.cmd_len = 2; + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + } + /* set the new frequency */ + snd_printdd("clock register : set %x\n", val); + err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK, val, &changed); + if (err) + return err; + mgr->sample_rate_real = realfreq; + mgr->cur_clock_type = mgr->use_clock_type; + + /* unmute after codec speed modes */ + if (mgr->codec_speed != speed) { + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); /* unmute outputs */ + rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + mgr->codec_speed = speed; /* save new codec speed */ + } + + if (changed) { + pcxhr_init_rmh(&rmh, CMD_MODIFY_CLOCK); + rmh.cmd[0] |= PCXHR_MODIFY_CLOCK_S_BIT; /* resync fifos */ + if (rate < PCXHR_IRQ_TIMER_FREQ) + rmh.cmd[1] = PCXHR_IRQ_TIMER_PERIOD; + else + rmh.cmd[1] = PCXHR_IRQ_TIMER_PERIOD * 2; + rmh.cmd[2] = rate; + rmh.cmd_len = 3; + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + } + snd_printdd("pcxhr_set_clock to %dHz (realfreq=%d)\n", rate, realfreq); + return 0; +} + + +int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_type, + int *sample_rate) +{ + struct pcxhr_rmh rmh; + unsigned char reg; + int err, rate; + + switch (clock_type) { + case PCXHR_CLOCK_TYPE_WORD_CLOCK : reg = REG_STATUS_WORD_CLOCK; break; + case PCXHR_CLOCK_TYPE_AES_SYNC : reg = REG_STATUS_AES_SYNC; break; + case PCXHR_CLOCK_TYPE_AES_1 : reg = REG_STATUS_AES_1; break; + case PCXHR_CLOCK_TYPE_AES_2 : reg = REG_STATUS_AES_2; break; + case PCXHR_CLOCK_TYPE_AES_3 : reg = REG_STATUS_AES_3; break; + case PCXHR_CLOCK_TYPE_AES_4 : reg = REG_STATUS_AES_4; break; + default : return -EINVAL; + } + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); + rmh.cmd_len = 2; + rmh.cmd[0] |= IO_NUM_REG_STATUS; + if (mgr->last_reg_stat != reg) { + rmh.cmd[1] = reg; + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + udelay(100); /* wait minimum 2 sample_frames at 32kHz ! */ + mgr->last_reg_stat = reg; + } + rmh.cmd[1] = REG_STATUS_CURRENT; + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + switch (rmh.stat[1] & 0x0f) { + case REG_STATUS_SYNC_32000 : rate = 32000; break; + case REG_STATUS_SYNC_44100 : rate = 44100; break; + case REG_STATUS_SYNC_48000 : rate = 48000; break; + case REG_STATUS_SYNC_64000 : rate = 64000; break; + case REG_STATUS_SYNC_88200 : rate = 88200; break; + case REG_STATUS_SYNC_96000 : rate = 96000; break; + case REG_STATUS_SYNC_128000 : rate = 128000; break; + case REG_STATUS_SYNC_176400 : rate = 176400; break; + case REG_STATUS_SYNC_192000 : rate = 192000; break; + default: rate = 0; + } + snd_printdd("External clock is at %d Hz\n", rate); + *sample_rate = rate; + return 0; +} + + +/* + * start or stop playback/capture substream + */ +static int pcxhr_set_stream_state(struct pcxhr_stream *stream) +{ + int err; + struct snd_pcxhr *chip; + struct pcxhr_rmh rmh; + int stream_mask, start; + + if (stream->status == PCXHR_STREAM_STATUS_SCHEDULE_RUN) + start = 1; + else { + if (stream->status != PCXHR_STREAM_STATUS_SCHEDULE_STOP) { + snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state CANNOT be stopped\n"); + return -EINVAL; + } + start = 0; + } + if (!stream->substream) + return -EINVAL; + + stream->timer_abs_periods = 0; + stream->timer_period_frag = 0; /* reset theoretical stream pos */ + stream->timer_buf_periods = 0; + stream->timer_is_synced = 0; + + stream_mask = stream->pipe->is_capture ? 1 : 1<substream->number; + + pcxhr_init_rmh(&rmh, start ? CMD_START_STREAM : CMD_STOP_STREAM); + pcxhr_set_pipe_cmd_params(&rmh, stream->pipe->is_capture, + stream->pipe->first_audio, 0, stream_mask); + + chip = snd_pcm_substream_chip(stream->substream); + + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err) + snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state err=%x;\n", err); + stream->status = start ? PCXHR_STREAM_STATUS_STARTED : PCXHR_STREAM_STATUS_STOPPED; + return err; +} + +#define HEADER_FMT_BASE_LIN 0xfed00000 +#define HEADER_FMT_BASE_FLOAT 0xfad00000 +#define HEADER_FMT_INTEL 0x00008000 +#define HEADER_FMT_24BITS 0x00004000 +#define HEADER_FMT_16BITS 0x00002000 +#define HEADER_FMT_UPTO11 0x00000200 +#define HEADER_FMT_UPTO32 0x00000100 +#define HEADER_FMT_MONO 0x00000080 + +static int pcxhr_set_format(struct pcxhr_stream *stream) +{ + int err, is_capture, sample_rate, stream_num; + struct snd_pcxhr *chip; + struct pcxhr_rmh rmh; + unsigned int header; + + switch (stream->format) { + case SNDRV_PCM_FORMAT_U8: + header = HEADER_FMT_BASE_LIN; + break; + case SNDRV_PCM_FORMAT_S16_LE: + header = HEADER_FMT_BASE_LIN | HEADER_FMT_16BITS | HEADER_FMT_INTEL; + break; + case SNDRV_PCM_FORMAT_S16_BE: + header = HEADER_FMT_BASE_LIN | HEADER_FMT_16BITS; + break; + case SNDRV_PCM_FORMAT_S24_3LE: + header = HEADER_FMT_BASE_LIN | HEADER_FMT_24BITS | HEADER_FMT_INTEL; + break; + case SNDRV_PCM_FORMAT_S24_3BE: + header = HEADER_FMT_BASE_LIN | HEADER_FMT_24BITS; + break; + case SNDRV_PCM_FORMAT_FLOAT_LE: + header = HEADER_FMT_BASE_FLOAT | HEADER_FMT_INTEL; + break; + default: + snd_printk(KERN_ERR "error pcxhr_set_format() : unknown format\n"); + return -EINVAL; + } + chip = snd_pcm_substream_chip(stream->substream); + + sample_rate = chip->mgr->sample_rate; + if (sample_rate <= 32000 && sample_rate !=0) { + if (sample_rate <= 11025) + header |= HEADER_FMT_UPTO11; + else + header |= HEADER_FMT_UPTO32; + } + if (stream->channels == 1) + header |= HEADER_FMT_MONO; + + is_capture = stream->pipe->is_capture; + stream_num = is_capture ? 0 : stream->substream->number; + + pcxhr_init_rmh(&rmh, is_capture ? CMD_FORMAT_STREAM_IN : CMD_FORMAT_STREAM_OUT); + pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0); + if (is_capture) + rmh.cmd[0] |= 1<<12; + rmh.cmd[1] = 0; + rmh.cmd[2] = header >> 8; + rmh.cmd[3] = (header & 0xff) << 16; + rmh.cmd_len = 4; + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err) + snd_printk(KERN_ERR "ERROR pcxhr_set_format err=%x;\n", err); + return err; +} + +static int pcxhr_update_r_buffer(struct pcxhr_stream *stream) +{ + int err, is_capture, stream_num; + struct pcxhr_rmh rmh; + struct snd_pcm_substream *subs = stream->substream; + struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); + + is_capture = (subs->stream == SNDRV_PCM_STREAM_CAPTURE); + stream_num = is_capture ? 0 : subs->number; + + snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%x) subs(%d)\n", + is_capture ? 'c' : 'p', + chip->chip_idx, (void*)subs->runtime->dma_addr, + subs->runtime->dma_bytes, subs->number); + + pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); + pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0); + + snd_assert(subs->runtime->dma_bytes < 0x200000); /* max buffer size is 2 MByte */ + rmh.cmd[1] = subs->runtime->dma_bytes * 8; /* size in bits */ + rmh.cmd[2] = subs->runtime->dma_addr >> 24; /* most significant byte */ + rmh.cmd[2] |= 1<<19; /* this is a circular buffer */ + rmh.cmd[3] = subs->runtime->dma_addr & MASK_DSP_WORD; /* least 3 significant bytes */ + rmh.cmd_len = 4; + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err) + snd_printk(KERN_ERR "ERROR CMD_UPDATE_R_BUFFERS err=%x;\n", err); + return err; +} + + +#if 0 +static int pcxhr_pipe_sample_count(struct pcxhr_stream *stream, snd_pcm_uframes_t *sample_count) +{ + struct pcxhr_rmh rmh; + int err; + pcxhr_t *chip = snd_pcm_substream_chip(stream->substream); + pcxhr_init_rmh(&rmh, CMD_PIPE_SAMPLE_COUNT); + pcxhr_set_pipe_cmd_params(&rmh, stream->pipe->is_capture, 0, 0, + 1<pipe->first_audio); + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err == 0) { + *sample_count = ((snd_pcm_uframes_t)rmh.stat[0]) << 24; + *sample_count += (snd_pcm_uframes_t)rmh.stat[1]; + } + snd_printdd("PIPE_SAMPLE_COUNT = %lx\n", *sample_count); + return err; +} +#endif + +static inline int pcxhr_stream_scheduled_get_pipe(struct pcxhr_stream *stream, + struct pcxhr_pipe **pipe) +{ + if (stream->status == PCXHR_STREAM_STATUS_SCHEDULE_RUN) { + *pipe = stream->pipe; + return 1; + } + return 0; +} + +static void pcxhr_trigger_tasklet(unsigned long arg) +{ + unsigned long flags; + int i, j, err; + struct pcxhr_pipe *pipe; + struct snd_pcxhr *chip; + struct pcxhr_mgr *mgr = (struct pcxhr_mgr*)(arg); + int capture_mask = 0; + int playback_mask = 0; + +#ifdef CONFIG_SND_DEBUG_DETECT + struct timeval my_tv1, my_tv2; + do_gettimeofday(&my_tv1); +#endif + down(&mgr->setup_mutex); + + /* check the pipes concerned and build pipe_array */ + for (i = 0; i < mgr->num_cards; i++) { + chip = mgr->chip[i]; + for (j = 0; j < chip->nb_streams_capt; j++) { + if (pcxhr_stream_scheduled_get_pipe(&chip->capture_stream[j], &pipe)) + capture_mask |= (1 << pipe->first_audio); + } + for (j = 0; j < chip->nb_streams_play; j++) { + if (pcxhr_stream_scheduled_get_pipe(&chip->playback_stream[j], &pipe)) { + playback_mask |= (1 << pipe->first_audio); + break; /* add only once, as all playback streams of + * one chip use the same pipe + */ + } + } + } + if (capture_mask == 0 && playback_mask == 0) { + up(&mgr->setup_mutex); + snd_printk(KERN_ERR "pcxhr_trigger_tasklet : no pipes\n"); + return; + } + + snd_printdd("pcxhr_trigger_tasklet : playback_mask=%x capture_mask=%x\n", + playback_mask, capture_mask); + + /* synchronous stop of all the pipes concerned */ + err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); + if (err) { + up(&mgr->setup_mutex); + snd_printk(KERN_ERR "pcxhr_trigger_tasklet : error stop pipes (P%x C%x)\n", + playback_mask, capture_mask); + return; + } + + /* unfortunately the dsp lost format and buffer info with the stop pipe */ + for (i = 0; i < mgr->num_cards; i++) { + struct pcxhr_stream *stream; + chip = mgr->chip[i]; + for (j = 0; j < chip->nb_streams_capt; j++) { + stream = &chip->capture_stream[j]; + if (pcxhr_stream_scheduled_get_pipe(stream, &pipe)) { + err = pcxhr_set_format(stream); + err = pcxhr_update_r_buffer(stream); + } + } + for (j = 0; j < chip->nb_streams_play; j++) { + stream = &chip->playback_stream[j]; + if (pcxhr_stream_scheduled_get_pipe(stream, &pipe)) { + err = pcxhr_set_format(stream); + err = pcxhr_update_r_buffer(stream); + } + } + } + /* start all the streams */ + for (i = 0; i < mgr->num_cards; i++) { + struct pcxhr_stream *stream; + chip = mgr->chip[i]; + for (j = 0; j < chip->nb_streams_capt; j++) { + stream = &chip->capture_stream[j]; + if (pcxhr_stream_scheduled_get_pipe(stream, &pipe)) + err = pcxhr_set_stream_state(stream); + } + for (j = 0; j < chip->nb_streams_play; j++) { + stream = &chip->playback_stream[j]; + if (pcxhr_stream_scheduled_get_pipe(stream, &pipe)) + err = pcxhr_set_stream_state(stream); + } + } + + /* synchronous start of all the pipes concerned */ + err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); + if (err) { + up(&mgr->setup_mutex); + snd_printk(KERN_ERR "pcxhr_trigger_tasklet : error start pipes (P%x C%x)\n", + playback_mask, capture_mask); + return; + } + + /* put the streams into the running state now (increment pointer by interrupt) */ + spin_lock_irqsave(&mgr->lock, flags); + for ( i =0; i < mgr->num_cards; i++) { + struct pcxhr_stream *stream; + chip = mgr->chip[i]; + for(j = 0; j < chip->nb_streams_capt; j++) { + stream = &chip->capture_stream[j]; + if(stream->status == PCXHR_STREAM_STATUS_STARTED) + stream->status = PCXHR_STREAM_STATUS_RUNNING; + } + for (j = 0; j < chip->nb_streams_play; j++) { + stream = &chip->playback_stream[j]; + if (stream->status == PCXHR_STREAM_STATUS_STARTED) { + /* playback will already have advanced ! */ + stream->timer_period_frag += PCXHR_GRANULARITY; + stream->status = PCXHR_STREAM_STATUS_RUNNING; + } + } + } + spin_unlock_irqrestore(&mgr->lock, flags); + + up(&mgr->setup_mutex); + +#ifdef CONFIG_SND_DEBUG_DETECT + do_gettimeofday(&my_tv2); + snd_printdd("***TRIGGER TASKLET*** TIME = %ld (err = %x)\n", + my_tv2.tv_usec - my_tv1.tv_usec, err); +#endif +} + + +/* + * trigger callback + */ +static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) +{ + struct pcxhr_stream *stream; + struct list_head *pos; + struct snd_pcm_substream *s; + int i; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + snd_printdd("SNDRV_PCM_TRIGGER_START\n"); + i = 0; + snd_pcm_group_for_each(pos, subs) { + s = snd_pcm_group_substream_entry(pos); + stream = s->runtime->private_data; + stream->status = PCXHR_STREAM_STATUS_SCHEDULE_RUN; + snd_pcm_trigger_done(s, subs); + i++; + } + if (i==1) { + snd_printdd("Only one Substream %c %d\n", + stream->pipe->is_capture ? 'C' : 'P', + stream->pipe->first_audio); + if (pcxhr_set_format(stream)) + return -EINVAL; + if (pcxhr_update_r_buffer(stream)) + return -EINVAL; + + if (pcxhr_set_stream_state(stream)) + return -EINVAL; + stream->status = PCXHR_STREAM_STATUS_RUNNING; + } else { + struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); + tasklet_hi_schedule(&chip->mgr->trigger_taskq); + } + break; + case SNDRV_PCM_TRIGGER_STOP: + snd_printdd("SNDRV_PCM_TRIGGER_STOP\n"); + snd_pcm_group_for_each(pos, subs) { + s = snd_pcm_group_substream_entry(pos); + stream = s->runtime->private_data; + stream->status = PCXHR_STREAM_STATUS_SCHEDULE_STOP; + if (pcxhr_set_stream_state(stream)) + return -EINVAL; + snd_pcm_trigger_done(s, subs); + } + break; + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + /* TODO */ + default: + return -EINVAL; + } + return 0; +} + + +static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start) +{ + struct pcxhr_rmh rmh; + int err; + + pcxhr_init_rmh(&rmh, CMD_SET_TIMER_INTERRUPT); + if (start) { + mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; /* last dsp time invalid */ + rmh.cmd[0] |= PCXHR_GRANULARITY; + } + err = pcxhr_send_msg(mgr, &rmh); + if (err < 0) + snd_printk(KERN_ERR "error pcxhr_hardware_timer err(%x)\n", err); + return err; +} + +/* + * prepare callback for all pcms + */ +static int pcxhr_prepare(struct snd_pcm_substream *subs) +{ + struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); + struct pcxhr_mgr *mgr = chip->mgr; + /* + struct pcxhr_stream *stream = (pcxhr_stream_t*)subs->runtime->private_data; + */ + int err = 0; + + snd_printdd("pcxhr_prepare : period_size(%lx) periods(%x) buffer_size(%lx)\n", + subs->runtime->period_size, subs->runtime->periods, + subs->runtime->buffer_size); + + /* + if(subs->runtime->period_size <= PCXHR_GRANULARITY) { + snd_printk(KERN_ERR "pcxhr_prepare : error period_size too small (%x)\n", + (unsigned int)subs->runtime->period_size); + return -EINVAL; + } + */ + + down(&mgr->setup_mutex); + + do { + /* if the stream was stopped before, format and buffer were reset */ + /* + if(stream->status == PCXHR_STREAM_STATUS_STOPPED) { + err = pcxhr_set_format(stream); + if(err) break; + err = pcxhr_update_r_buffer(stream); + if(err) break; + } + */ + + /* only the first stream can choose the sample rate */ + /* the further opened streams will be limited to its frequency (see open) */ + /* set the clock only once (first stream) */ + if (mgr->sample_rate == 0) { + err = pcxhr_set_clock(mgr, subs->runtime->rate); + if (err) + break; + mgr->sample_rate = subs->runtime->rate; + + err = pcxhr_hardware_timer(mgr, 1); /* start the DSP-timer */ + } + } while(0); /* do only once (so we can use break instead of goto) */ + + up(&mgr->setup_mutex); + + return err; +} + + +/* + * HW_PARAMS callback for all pcms + */ +static int pcxhr_hw_params(struct snd_pcm_substream *subs, + struct snd_pcm_hw_params *hw) +{ + struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); + struct pcxhr_mgr *mgr = chip->mgr; + struct pcxhr_stream *stream = subs->runtime->private_data; + snd_pcm_format_t format; + int err; + int channels; + + /* set up channels */ + channels = params_channels(hw); + + /* set up format for the stream */ + format = params_format(hw); + + down(&mgr->setup_mutex); + + stream->channels = channels; + stream->format = format; + + /* set the format to the board */ + /* + err = pcxhr_set_format(stream); + if(err) { + up(&mgr->setup_mutex); + return err; + } + */ + /* allocate buffer */ + err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw)); + + /* + if (err > 0) { + err = pcxhr_update_r_buffer(stream); + } + */ + up(&mgr->setup_mutex); + + return err; +} + +static int pcxhr_hw_free(struct snd_pcm_substream *subs) +{ + snd_pcm_lib_free_pages(subs); + return 0; +} + + +/* + * CONFIGURATION SPACE for all pcms, mono pcm must update channels_max + */ +static struct snd_pcm_hardware pcxhr_caps = +{ + .info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | + SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START | + 0 /*SNDRV_PCM_INFO_PAUSE*/), + .formats = ( SNDRV_PCM_FMTBIT_U8 | + SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | + SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | + SNDRV_PCM_FMTBIT_FLOAT_LE ), + .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_192000, + .rate_min = 8000, + .rate_max = 192000, + .channels_min = 1, + .channels_max = 2, + .buffer_bytes_max = (32*1024), + /* 1 byte == 1 frame U8 mono (PCXHR_GRANULARITY is frames!) */ + .period_bytes_min = (2*PCXHR_GRANULARITY), + .period_bytes_max = (16*1024), + .periods_min = 2, + .periods_max = (32*1024/PCXHR_GRANULARITY), +}; + + +static int pcxhr_open(struct snd_pcm_substream *subs) +{ + struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); + struct pcxhr_mgr *mgr = chip->mgr; + struct snd_pcm_runtime *runtime = subs->runtime; + struct pcxhr_stream *stream; + int is_capture; + + down(&mgr->setup_mutex); + + /* copy the struct snd_pcm_hardware struct */ + runtime->hw = pcxhr_caps; + + if( subs->stream == SNDRV_PCM_STREAM_PLAYBACK ) { + snd_printdd("pcxhr_open playback chip%d subs%d\n", + chip->chip_idx, subs->number); + is_capture = 0; + stream = &chip->playback_stream[subs->number]; + } else { + snd_printdd("pcxhr_open capture chip%d subs%d\n", + chip->chip_idx, subs->number); + is_capture = 1; + if (mgr->mono_capture) + runtime->hw.channels_max = 1; + else + runtime->hw.channels_min = 2; + stream = &chip->capture_stream[subs->number]; + } + if (stream->status != PCXHR_STREAM_STATUS_FREE){ + /* streams in use */ + snd_printk(KERN_ERR "pcxhr_open chip%d subs%d in use\n", + chip->chip_idx, subs->number); + up(&mgr->setup_mutex); + return -EBUSY; + } + + /* if a sample rate is already used or fixed by external clock, + * the stream cannot change + */ + if (mgr->sample_rate) + runtime->hw.rate_min = runtime->hw.rate_max = mgr->sample_rate; + else { + if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) { + int external_rate; + if (pcxhr_get_external_clock(mgr, mgr->use_clock_type, + &external_rate) || + external_rate == 0) { + /* cannot detect the external clock rate */ + up(&mgr->setup_mutex); + return -EBUSY; + } + runtime->hw.rate_min = runtime->hw.rate_max = external_rate; + } + } + + stream->status = PCXHR_STREAM_STATUS_OPEN; + stream->substream = subs; + stream->channels = 0; /* not configured yet */ + + runtime->private_data = stream; + + snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 4); + snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 4); + + mgr->ref_count_rate++; + + up(&mgr->setup_mutex); + return 0; +} + + +static int pcxhr_close(struct snd_pcm_substream *subs) +{ + struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); + struct pcxhr_mgr *mgr = chip->mgr; + struct pcxhr_stream *stream = subs->runtime->private_data; + + down(&mgr->setup_mutex); + + snd_printdd("pcxhr_close chip%d subs%d\n", chip->chip_idx, subs->number); + + /* sample rate released */ + if (--mgr->ref_count_rate == 0) { + mgr->sample_rate = 0; /* the sample rate is no more locked */ + pcxhr_hardware_timer(mgr, 0); /* stop the DSP-timer */ + } + + stream->status = PCXHR_STREAM_STATUS_FREE; + stream->substream = NULL; + + up(&mgr->setup_mutex); + + return 0; +} + + +static snd_pcm_uframes_t pcxhr_stream_pointer(struct snd_pcm_substream *subs) +{ + unsigned long flags; + u_int32_t timer_period_frag; + int timer_buf_periods; + struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); + struct snd_pcm_runtime *runtime = subs->runtime; + struct pcxhr_stream *stream = runtime->private_data; + + spin_lock_irqsave(&chip->mgr->lock, flags); + + /* get the period fragment and the nb of periods in the buffer */ + timer_period_frag = stream->timer_period_frag; + timer_buf_periods = stream->timer_buf_periods; + + spin_unlock_irqrestore(&chip->mgr->lock, flags); + + return (snd_pcm_uframes_t)((timer_buf_periods * runtime->period_size) + + timer_period_frag); +} + + +static struct snd_pcm_ops pcxhr_ops = { + .open = pcxhr_open, + .close = pcxhr_close, + .ioctl = snd_pcm_lib_ioctl, + .prepare = pcxhr_prepare, + .hw_params = pcxhr_hw_params, + .hw_free = pcxhr_hw_free, + .trigger = pcxhr_trigger, + .pointer = pcxhr_stream_pointer, +}; + +/* + */ +int pcxhr_create_pcm(struct snd_pcxhr *chip) +{ + int err; + struct snd_pcm *pcm; + char name[32]; + + sprintf(name, "pcxhr %d", chip->chip_idx); + if ((err = snd_pcm_new(chip->card, name, 0, + chip->nb_streams_play, + chip->nb_streams_capt, &pcm)) < 0) { + snd_printk(KERN_ERR "cannot create pcm %s\n", name); + return err; + } + pcm->private_data = chip; + + if (chip->nb_streams_play) + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcxhr_ops); + if (chip->nb_streams_capt) + snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcxhr_ops); + + pcm->info_flags = 0; + strcpy(pcm->name, name); + + snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, + snd_dma_pci_data(chip->mgr->pci), + 32*1024, 32*1024); + chip->pcm = pcm; + return 0; +} + +static int pcxhr_chip_free(struct snd_pcxhr *chip) +{ + kfree(chip); + return 0; +} + +static int pcxhr_chip_dev_free(struct snd_device *device) +{ + struct snd_pcxhr *chip = device->device_data; + return pcxhr_chip_free(chip); +} + + +/* + */ +static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, int idx) +{ + int err; + struct snd_pcxhr *chip; + static struct snd_device_ops ops = { + .dev_free = pcxhr_chip_dev_free, + }; + + mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL); + if (! chip) { + snd_printk(KERN_ERR "cannot allocate chip\n"); + return -ENOMEM; + } + + chip->card = card; + chip->chip_idx = idx; + chip->mgr = mgr; + + if (idx < mgr->playback_chips) + /* stereo or mono streams */ + chip->nb_streams_play = PCXHR_PLAYBACK_STREAMS; + + if (idx < mgr->capture_chips) { + if (mgr->mono_capture) + chip->nb_streams_capt = 2; /* 2 mono streams (left+right) */ + else + chip->nb_streams_capt = 1; /* or 1 stereo stream */ + } + + if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { + pcxhr_chip_free(chip); + return err; + } + + snd_card_set_dev(card, &mgr->pci->dev); + + return 0; +} + +/* proc interface */ +static void pcxhr_proc_info(struct snd_info_entry *entry, struct snd_info_buffer *buffer) +{ + struct snd_pcxhr *chip = entry->private_data; + struct pcxhr_mgr *mgr = chip->mgr; + + snd_iprintf(buffer, "\n%s\n", mgr->longname); + + /* stats available when embedded DSP is running */ + if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { + struct pcxhr_rmh rmh; + short ver_maj = (mgr->dsp_version >> 16) & 0xff; + short ver_min = (mgr->dsp_version >> 8) & 0xff; + short ver_build = mgr->dsp_version & 0xff; + snd_iprintf(buffer, "module version %s\n", PCXHR_DRIVER_VERSION_STRING); + snd_iprintf(buffer, "dsp version %d.%d.%d\n", ver_maj, ver_min, ver_build); + if (mgr->board_has_analog) + snd_iprintf(buffer, "analog io available\n"); + else + snd_iprintf(buffer, "digital only board\n"); + + /* calc cpu load of the dsp */ + pcxhr_init_rmh(&rmh, CMD_GET_DSP_RESOURCES); + if( ! pcxhr_send_msg(mgr, &rmh) ) { + int cur = rmh.stat[0]; + int ref = rmh.stat[1]; + if (ref > 0) { + if (mgr->sample_rate_real != 0 && + mgr->sample_rate_real != 48000) { + ref = (ref * 48000) / mgr->sample_rate_real; + if (mgr->sample_rate_real >= PCXHR_IRQ_TIMER_FREQ) + ref *= 2; + } + cur = 100 - (100 * cur) / ref; + snd_iprintf(buffer, "cpu load %d%%\n", cur); + snd_iprintf(buffer, "buffer pool %d/%d kWords\n", + rmh.stat[2], rmh.stat[3]); + } + } + snd_iprintf(buffer, "dma granularity : %d\n", PCXHR_GRANULARITY); + snd_iprintf(buffer, "dsp time errors : %d\n", mgr->dsp_time_err); + snd_iprintf(buffer, "dsp async pipe xrun errors : %d\n", + mgr->async_err_pipe_xrun); + snd_iprintf(buffer, "dsp async stream xrun errors : %d\n", + mgr->async_err_stream_xrun); + snd_iprintf(buffer, "dsp async last other error : %x\n", + mgr->async_err_other_last); + /* debug zone dsp */ + rmh.cmd[0] = 0x4200 + PCXHR_SIZE_MAX_STATUS; + rmh.cmd_len = 1; + rmh.stat_len = PCXHR_SIZE_MAX_STATUS; + rmh.dsp_stat = 0; + rmh.cmd_idx = CMD_LAST_INDEX; + if( ! pcxhr_send_msg(mgr, &rmh) ) { + int i; + for (i = 0; i < rmh.stat_len; i++) + snd_iprintf(buffer, "debug[%02d] = %06x\n", i, rmh.stat[i]); + } + } else + snd_iprintf(buffer, "no firmware loaded\n"); + snd_iprintf(buffer, "\n"); +} +static void pcxhr_proc_sync(struct snd_info_entry *entry, struct snd_info_buffer *buffer) +{ + struct snd_pcxhr *chip = entry->private_data; + struct pcxhr_mgr *mgr = chip->mgr; + static char *texts[7] = { + "Internal", "Word", "AES Sync", "AES 1", "AES 2", "AES 3", "AES 4" + }; + + snd_iprintf(buffer, "\n%s\n", mgr->longname); + snd_iprintf(buffer, "Current Sample Clock\t: %s\n", texts[mgr->cur_clock_type]); + snd_iprintf(buffer, "Current Sample Rate\t= %d\n", mgr->sample_rate_real); + + /* commands available when embedded DSP is running */ + if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { + int i, err, sample_rate; + for (i = PCXHR_CLOCK_TYPE_WORD_CLOCK; i< (3 + mgr->capture_chips); i++) { + err = pcxhr_get_external_clock(mgr, i, &sample_rate); + if (err) + break; + snd_iprintf(buffer, "%s Clock\t\t= %d\n", texts[i], sample_rate); + } + } else + snd_iprintf(buffer, "no firmware loaded\n"); + snd_iprintf(buffer, "\n"); +} + +static void __devinit pcxhr_proc_init(struct snd_pcxhr *chip) +{ + struct snd_info_entry *entry; + + if (! snd_card_proc_new(chip->card, "info", &entry)) + snd_info_set_text_ops(entry, chip, 1024, pcxhr_proc_info); + if (! snd_card_proc_new(chip->card, "sync", &entry)) + snd_info_set_text_ops(entry, chip, 1024, pcxhr_proc_sync); +} +/* end of proc interface */ + +/* + * release all the cards assigned to a manager instance + */ +static int pcxhr_free(struct pcxhr_mgr *mgr) +{ + unsigned int i; + + for (i = 0; i < mgr->num_cards; i++) { + if (mgr->chip[i]) + snd_card_free(mgr->chip[i]->card); + } + + /* reset board if some firmware was loaded */ + if(mgr->dsp_loaded) { + pcxhr_reset_board(mgr); + snd_printdd("reset pcxhr !\n"); + } + + /* release irq */ + if (mgr->irq >= 0) + free_irq(mgr->irq, mgr); + + pci_release_regions(mgr->pci); + + /* free hostport purgebuffer */ + if (mgr->hostport.area) { + snd_dma_free_pages(&mgr->hostport); + mgr->hostport.area = NULL; + } + + kfree(mgr->prmh); + + pci_disable_device(mgr->pci); + kfree(mgr); + return 0; +} + +/* + * probe function - creates the card manager + */ +static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) +{ + static int dev; + struct pcxhr_mgr *mgr; + unsigned int i; + int err; + size_t size; + char *card_name; + + if (dev >= SNDRV_CARDS) + return -ENODEV; + if (! enable[dev]) { + dev++; + return -ENOENT; + } + + /* enable PCI device */ + if ((err = pci_enable_device(pci)) < 0) + return err; + pci_set_master(pci); + + /* check if we can restrict PCI DMA transfers to 32 bits */ + if (pci_set_dma_mask(pci, 0xffffffff) < 0) { + snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n"); + pci_disable_device(pci); + return -ENXIO; + } + + /* alloc card manager */ + mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); + if (! mgr) { + pci_disable_device(pci); + return -ENOMEM; + } + + snd_assert(pci_id->driver_data < PCI_ID_LAST, return -ENODEV); + card_name = pcxhr_board_params[pci_id->driver_data].board_name; + mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; + mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips; + mgr->firmware_num = pcxhr_board_params[pci_id->driver_data].firmware_num; + mgr->mono_capture = mono[dev]; + + /* resource assignment */ + if ((err = pci_request_regions(pci, card_name)) < 0) { + kfree(mgr); + pci_disable_device(pci); + return err; + } + for (i = 0; i < 3; i++) + mgr->port[i] = pci_resource_start(pci, i); + + mgr->pci = pci; + mgr->irq = -1; + + if (request_irq(pci->irq, pcxhr_interrupt, SA_INTERRUPT|SA_SHIRQ, + card_name, mgr)) { + snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); + pcxhr_free(mgr); + return -EBUSY; + } + mgr->irq = pci->irq; + + sprintf(mgr->shortname, "Digigram %s", card_name); + sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, 0x%lx irq %i", mgr->shortname, + mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq); + + /* ISR spinlock */ + spin_lock_init(&mgr->lock); + spin_lock_init(&mgr->msg_lock); + + /* init setup mutex*/ + init_MUTEX(&mgr->setup_mutex); + + /* init taslket */ + tasklet_init(&mgr->msg_taskq, pcxhr_msg_tasklet, (unsigned long) mgr); + tasklet_init(&mgr->trigger_taskq, pcxhr_trigger_tasklet, (unsigned long) mgr); + mgr->prmh = kmalloc(sizeof(*mgr->prmh) + + sizeof(u32) * (PCXHR_SIZE_MAX_LONG_STATUS - PCXHR_SIZE_MAX_STATUS), + GFP_KERNEL); + if (! mgr->prmh) { + pcxhr_free(mgr); + return -ENOMEM; + } + + for (i=0; i < PCXHR_MAX_CARDS; i++) { + struct snd_card *card; + char tmpid[16]; + int idx; + + if (i >= max(mgr->playback_chips, mgr->capture_chips)) + break; + mgr->num_cards++; + + if (index[dev] < 0) + idx = index[dev]; + else + idx = index[dev] + i; + + snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : card_name, i); + card = snd_card_new(idx, tmpid, THIS_MODULE, 0); + + if (! card) { + snd_printk(KERN_ERR "cannot allocate the card %d\n", i); + pcxhr_free(mgr); + return -ENOMEM; + } + + strcpy(card->driver, DRIVER_NAME); + sprintf(card->shortname, "%s [PCM #%d]", mgr->shortname, i); + sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); + + if ((err = pcxhr_create(mgr, card, i)) < 0) { + pcxhr_free(mgr); + return err; + } + + if (i == 0) + /* init proc interface only for chip0 */ + pcxhr_proc_init(mgr->chip[i]); + + if ((err = snd_card_register(card)) < 0) { + pcxhr_free(mgr); + return err; + } + } + + /* create hostport purgebuffer */ + size = PAGE_ALIGN(sizeof(struct pcxhr_hostport)); + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), + size, &mgr->hostport) < 0) { + pcxhr_free(mgr); + return -ENOMEM; + } + /* init purgebuffer */ + memset(mgr->hostport.area, 0, size); + + /* create a DSP loader */ + err = pcxhr_setup_firmware(mgr); + if (err < 0) { + pcxhr_free(mgr); + return err; + } + + pci_set_drvdata(pci, mgr); + dev++; + return 0; +} + +static void __devexit pcxhr_remove(struct pci_dev *pci) +{ + pcxhr_free(pci_get_drvdata(pci)); + pci_set_drvdata(pci, NULL); +} + +static struct pci_driver driver = { + .name = "Digigram pcxhr", + .id_table = pcxhr_ids, + .probe = pcxhr_probe, + .remove = __devexit_p(pcxhr_remove), +}; + +static int __init pcxhr_module_init(void) +{ + return pci_register_driver(&driver); +} + +static void __exit pcxhr_module_exit(void) +{ + pci_unregister_driver(&driver); +} + +module_init(pcxhr_module_init) +module_exit(pcxhr_module_exit) diff --git a/sound/pci/pcxhr/pcxhr.h b/sound/pci/pcxhr/pcxhr.h new file mode 100644 index 0000000..049f2b3 --- /dev/null +++ b/sound/pci/pcxhr/pcxhr.h @@ -0,0 +1,188 @@ +/* + * Driver for Digigram pcxhr soundcards + * + * main header file + * + * Copyright (c) 2004 by Digigram + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __SOUND_PCXHR_H +#define __SOUND_PCXHR_H + +#include +#include + +#define PCXHR_DRIVER_VERSION 0x000804 /* 0.8.4 */ +#define PCXHR_DRIVER_VERSION_STRING "0.8.4" /* 0.8.4 */ + + +#define PCXHR_MAX_CARDS 6 +#define PCXHR_PLAYBACK_STREAMS 4 + +#define PCXHR_GRANULARITY 96 /* transfer granularity (should be min 96 and multiple of 48) */ +#define PCXHR_GRANULARITY_MIN 96 /* transfer granularity of pipes and the dsp time (MBOX4) */ + +struct snd_pcxhr; +struct pcxhr_mgr; + +struct pcxhr_stream; +struct pcxhr_pipe; + +enum pcxhr_clock_type { + PCXHR_CLOCK_TYPE_INTERNAL = 0, + PCXHR_CLOCK_TYPE_WORD_CLOCK, + PCXHR_CLOCK_TYPE_AES_SYNC, + PCXHR_CLOCK_TYPE_AES_1, + PCXHR_CLOCK_TYPE_AES_2, + PCXHR_CLOCK_TYPE_AES_3, + PCXHR_CLOCK_TYPE_AES_4, +}; + +struct pcxhr_mgr { + unsigned int num_cards; + struct snd_pcxhr *chip[PCXHR_MAX_CARDS]; + + struct pci_dev *pci; + + int irq; + + /* card access with 1 mem bar and 2 io bar's */ + unsigned long port[3]; + + /* share the name */ + char shortname[32]; /* short name of this soundcard */ + char longname[96]; /* name of this soundcard */ + + /* message tasklet */ + struct tasklet_struct msg_taskq; + struct pcxhr_rmh *prmh; + /* trigger tasklet */ + struct tasklet_struct trigger_taskq; + + spinlock_t lock; /* interrupt spinlock */ + spinlock_t msg_lock; /* message spinlock */ + + struct semaphore setup_mutex; /* mutex used in hw_params, open and close */ + struct semaphore mixer_mutex; /* mutex for mixer */ + + /* hardware interface */ + unsigned int dsp_loaded; /* bit flags of loaded dsp indices */ + unsigned int dsp_version; /* read from embedded once firmware is loaded */ + int board_has_analog; /* if 0 the board is digital only */ + int mono_capture; /* if 1 the board does mono capture */ + int playback_chips; /* 4 or 6 */ + int capture_chips; /* 4 or 1 */ + int firmware_num; /* 41 or 42 */ + + struct snd_dma_buffer hostport; + + enum pcxhr_clock_type use_clock_type; /* clock type selected by mixer */ + enum pcxhr_clock_type cur_clock_type; /* current clock type synced */ + int sample_rate; + int ref_count_rate; + int timer_toggle; /* timer interrupt toggles between the two values 0x200 and 0x300 */ + int dsp_time_last; /* the last dsp time (read by interrupt) */ + int dsp_time_err; /* dsp time errors */ + unsigned int src_it_dsp; /* dsp interrupt source */ + unsigned int io_num_reg_cont; /* backup of IO_NUM_REG_CONT */ + unsigned int codec_speed; /* speed mode of the codecs */ + unsigned int sample_rate_real; /* current real sample rate */ + int last_reg_stat; + int async_err_stream_xrun; + int async_err_pipe_xrun; + int async_err_other_last; +}; + + +enum pcxhr_stream_status { + PCXHR_STREAM_STATUS_FREE, + PCXHR_STREAM_STATUS_OPEN, + PCXHR_STREAM_STATUS_SCHEDULE_RUN, + PCXHR_STREAM_STATUS_STARTED, + PCXHR_STREAM_STATUS_RUNNING, + PCXHR_STREAM_STATUS_SCHEDULE_STOP, + PCXHR_STREAM_STATUS_STOPPED, + PCXHR_STREAM_STATUS_PAUSED +}; + +struct pcxhr_stream { + struct snd_pcm_substream *substream; + snd_pcm_format_t format; + struct pcxhr_pipe *pipe; + + enum pcxhr_stream_status status; /* free, open, running, draining, pause */ + + u_int64_t timer_abs_periods; /* timer: samples elapsed since TRIGGER_START (multiple of period_size) */ + u_int32_t timer_period_frag; /* timer: samples elapsed since last call to snd_pcm_period_elapsed (0..period_size) */ + u_int32_t timer_buf_periods; /* nb of periods in the buffer that have already elapsed */ + int timer_is_synced; /* if(0) : timer needs to be resynced with real hardware pointer */ + + int channels; +}; + + +enum pcxhr_pipe_status { + PCXHR_PIPE_UNDEFINED, + PCXHR_PIPE_DEFINED +}; + +struct pcxhr_pipe { + enum pcxhr_pipe_status status; + int is_capture; /* this is a capture pipe */ + int first_audio; /* first audio num */ +}; + + +struct snd_pcxhr { + struct snd_card *card; + struct pcxhr_mgr *mgr; + int chip_idx; /* zero based */ + + struct snd_pcm *pcm; /* PCM */ + + struct pcxhr_pipe playback_pipe; /* 1 stereo pipe only */ + struct pcxhr_pipe capture_pipe[2]; /* 1 stereo pipe or 2 mono pipes */ + + struct pcxhr_stream playback_stream[PCXHR_PLAYBACK_STREAMS]; + struct pcxhr_stream capture_stream[2]; /* 1 stereo stream or 2 mono streams */ + int nb_streams_play; + int nb_streams_capt; + + int analog_playback_active[2]; /* Mixer : Master Playback active (!mute) */ + int analog_playback_volume[2]; /* Mixer : Master Playback Volume */ + int analog_capture_volume[2]; /* Mixer : Master Capture Volume */ + int digital_playback_active[PCXHR_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Active [streams][stereo]*/ + int digital_playback_volume[PCXHR_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Volume [streams][stereo]*/ + int digital_capture_volume[2]; /* Mixer : Digital Capture Volume [stereo] */ + int monitoring_active[2]; /* Mixer : Monitoring Active */ + int monitoring_volume[2]; /* Mixer : Monitoring Volume */ + int audio_capture_source; /* Mixer : Audio Capture Source */ + unsigned char aes_bits[5]; /* Mixer : IEC958_AES bits */ +}; + +struct pcxhr_hostport +{ + char purgebuffer[6]; + char reserved[2]; +}; + +/* exported */ +int pcxhr_create_pcm(struct snd_pcxhr *chip); +int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate); +int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_type, int *sample_rate); + +#endif /* __SOUND_PCXHR_H */ diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c new file mode 100644 index 0000000..fa0d27e --- /dev/null +++ b/sound/pci/pcxhr/pcxhr_core.c @@ -0,0 +1,1214 @@ +/* + * Driver for Digigram pcxhr compatible soundcards + * + * low level interface with interrupt and message handling implementation + * + * Copyright (c) 2004 by Digigram + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include "pcxhr.h" +#include "pcxhr_mixer.h" +#include "pcxhr_hwdep.h" +#include "pcxhr_core.h" + + +/* registers used on the PLX (port 1) */ +#define PCXHR_PLX_OFFSET_MIN 0x40 +#define PCXHR_PLX_MBOX0 0x40 +#define PCXHR_PLX_MBOX1 0x44 +#define PCXHR_PLX_MBOX2 0x48 +#define PCXHR_PLX_MBOX3 0x4C +#define PCXHR_PLX_MBOX4 0x50 +#define PCXHR_PLX_MBOX5 0x54 +#define PCXHR_PLX_MBOX6 0x58 +#define PCXHR_PLX_MBOX7 0x5C +#define PCXHR_PLX_L2PCIDB 0x64 +#define PCXHR_PLX_IRQCS 0x68 +#define PCXHR_PLX_CHIPSC 0x6C + +/* registers used on the DSP (port 2) */ +#define PCXHR_DSP_ICR 0x00 +#define PCXHR_DSP_CVR 0x04 +#define PCXHR_DSP_ISR 0x08 +#define PCXHR_DSP_IVR 0x0C +#define PCXHR_DSP_RXH 0x14 +#define PCXHR_DSP_TXH 0x14 +#define PCXHR_DSP_RXM 0x18 +#define PCXHR_DSP_TXM 0x18 +#define PCXHR_DSP_RXL 0x1C +#define PCXHR_DSP_TXL 0x1C +#define PCXHR_DSP_RESET 0x20 +#define PCXHR_DSP_OFFSET_MAX 0x20 + +/* access to the card */ +#define PCXHR_PLX 1 +#define PCXHR_DSP 2 + +#if (PCXHR_DSP_OFFSET_MAX > PCXHR_PLX_OFFSET_MIN) +#undef PCXHR_REG_TO_PORT(x) +#else +#define PCXHR_REG_TO_PORT(x) ((x)>PCXHR_DSP_OFFSET_MAX ? PCXHR_PLX : PCXHR_DSP) +#endif +#define PCXHR_INPB(mgr,x) inb((mgr)->port[PCXHR_REG_TO_PORT(x)] + (x)) +#define PCXHR_INPL(mgr,x) inl((mgr)->port[PCXHR_REG_TO_PORT(x)] + (x)) +#define PCXHR_OUTPB(mgr,x,data) outb((data), (mgr)->port[PCXHR_REG_TO_PORT(x)] + (x)) +#define PCXHR_OUTPL(mgr,x,data) outl((data), (mgr)->port[PCXHR_REG_TO_PORT(x)] + (x)) +/* attention : access the PCXHR_DSP_* registers with inb and outb only ! */ + +/* params used with PCXHR_PLX_MBOX0 */ +#define PCXHR_MBOX0_HF5 (1 << 0) +#define PCXHR_MBOX0_HF4 (1 << 1) +#define PCXHR_MBOX0_BOOT_HERE (1 << 23) +/* params used with PCXHR_PLX_IRQCS */ +#define PCXHR_IRQCS_ENABLE_PCIIRQ (1 << 8) +#define PCXHR_IRQCS_ENABLE_PCIDB (1 << 9) +#define PCXHR_IRQCS_ACTIVE_PCIDB (1 << 13) +/* params used with PCXHR_PLX_CHIPSC */ +#define PCXHR_CHIPSC_INIT_VALUE 0x100D767E +#define PCXHR_CHIPSC_RESET_XILINX (1 << 16) +#define PCXHR_CHIPSC_GPI_USERI (1 << 17) +#define PCXHR_CHIPSC_DATA_CLK (1 << 24) +#define PCXHR_CHIPSC_DATA_IN (1 << 26) + +/* params used with PCXHR_DSP_ICR */ +#define PCXHR_ICR_HI08_RREQ 0x01 +#define PCXHR_ICR_HI08_TREQ 0x02 +#define PCXHR_ICR_HI08_HDRQ 0x04 +#define PCXHR_ICR_HI08_HF0 0x08 +#define PCXHR_ICR_HI08_HF1 0x10 +#define PCXHR_ICR_HI08_HLEND 0x20 +#define PCXHR_ICR_HI08_INIT 0x80 +/* params used with PCXHR_DSP_CVR */ +#define PCXHR_CVR_HI08_HC 0x80 +/* params used with PCXHR_DSP_ISR */ +#define PCXHR_ISR_HI08_RXDF 0x01 +#define PCXHR_ISR_HI08_TXDE 0x02 +#define PCXHR_ISR_HI08_TRDY 0x04 +#define PCXHR_ISR_HI08_ERR 0x08 +#define PCXHR_ISR_HI08_CHK 0x10 +#define PCXHR_ISR_HI08_HREQ 0x80 + + +/* constants used for delay in msec */ +#define PCXHR_WAIT_DEFAULT 2 +#define PCXHR_WAIT_IT 25 +#define PCXHR_WAIT_IT_EXTRA 65 + +/* + * pcxhr_check_reg_bit - wait for the specified bit is set/reset on a register + * @reg: register to check + * @mask: bit mask + * @bit: resultant bit to be checked + * @time: time-out of loop in msec + * + * returns zero if a bit matches, or a negative error code. + */ +static int pcxhr_check_reg_bit(struct pcxhr_mgr *mgr, unsigned int reg, + unsigned char mask, unsigned char bit, int time, + unsigned char* read) +{ + int i = 0; + unsigned long end_time = jiffies + (time * HZ + 999) / 1000; + do { + *read = PCXHR_INPB(mgr, reg); + if ((*read & mask) == bit) { + if (i > 100) + snd_printdd("ATTENTION! check_reg(%x) loopcount=%d\n", + reg, i); + return 0; + } + i++; + } while (time_after_eq(end_time, jiffies)); + snd_printk(KERN_ERR "pcxhr_check_reg_bit: timeout, reg=%x, mask=0x%x, val=0x%x\n", + reg, mask, *read); + return -EIO; +} + +/* constants used with pcxhr_check_reg_bit() */ +#define PCXHR_TIMEOUT_DSP 200 + + +#define PCXHR_MASK_EXTRA_INFO 0x0000FE +#define PCXHR_MASK_IT_HF0 0x000100 +#define PCXHR_MASK_IT_HF1 0x000200 +#define PCXHR_MASK_IT_NO_HF0_HF1 0x000400 +#define PCXHR_MASK_IT_MANAGE_HF5 0x000800 +#define PCXHR_MASK_IT_WAIT 0x010000 +#define PCXHR_MASK_IT_WAIT_EXTRA 0x020000 + +#define PCXHR_IT_SEND_BYTE_XILINX (0x0000003C | PCXHR_MASK_IT_HF0) +#define PCXHR_IT_TEST_XILINX (0x0000003C | PCXHR_MASK_IT_HF1 | \ + PCXHR_MASK_IT_MANAGE_HF5) +#define PCXHR_IT_DOWNLOAD_BOOT (0x0000000C | PCXHR_MASK_IT_HF1 | \ + PCXHR_MASK_IT_MANAGE_HF5 | PCXHR_MASK_IT_WAIT) +#define PCXHR_IT_RESET_BOARD_FUNC (0x0000000C | PCXHR_MASK_IT_HF0 | \ + PCXHR_MASK_IT_MANAGE_HF5 | PCXHR_MASK_IT_WAIT_EXTRA) +#define PCXHR_IT_DOWNLOAD_DSP (0x0000000C | \ + PCXHR_MASK_IT_MANAGE_HF5 | PCXHR_MASK_IT_WAIT) +#define PCXHR_IT_DEBUG (0x0000005A | PCXHR_MASK_IT_NO_HF0_HF1) +#define PCXHR_IT_RESET_SEMAPHORE (0x0000005C | PCXHR_MASK_IT_NO_HF0_HF1) +#define PCXHR_IT_MESSAGE (0x00000074 | PCXHR_MASK_IT_NO_HF0_HF1) +#define PCXHR_IT_RESET_CHK (0x00000076 | PCXHR_MASK_IT_NO_HF0_HF1) +#define PCXHR_IT_UPDATE_RBUFFER (0x00000078 | PCXHR_MASK_IT_NO_HF0_HF1) + +static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr, unsigned int itdsp, int atomic) +{ + int err; + unsigned char reg; + + if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) { + /* clear hf5 bit */ + PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX0, + PCXHR_INPL(mgr, PCXHR_PLX_MBOX0) & ~PCXHR_MBOX0_HF5); + } + if ((itdsp & PCXHR_MASK_IT_NO_HF0_HF1) == 0) { + reg = PCXHR_ICR_HI08_RREQ | PCXHR_ICR_HI08_TREQ | PCXHR_ICR_HI08_HDRQ; + if (itdsp & PCXHR_MASK_IT_HF0) + reg |= PCXHR_ICR_HI08_HF0; + if (itdsp & PCXHR_MASK_IT_HF1) + reg |= PCXHR_ICR_HI08_HF1; + PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); + } + reg = (unsigned char)(((itdsp & PCXHR_MASK_EXTRA_INFO) >> 1) | PCXHR_CVR_HI08_HC); + PCXHR_OUTPB(mgr, PCXHR_DSP_CVR, reg); + if (itdsp & PCXHR_MASK_IT_WAIT) { + if (atomic) + mdelay(PCXHR_WAIT_IT); + else + msleep(PCXHR_WAIT_IT); + } + if (itdsp & PCXHR_MASK_IT_WAIT_EXTRA) { + if (atomic) + mdelay(PCXHR_WAIT_IT_EXTRA); + else + msleep(PCXHR_WAIT_IT); + } + /* wait for CVR_HI08_HC == 0 */ + err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_CVR, PCXHR_CVR_HI08_HC, 0, + PCXHR_TIMEOUT_DSP, ®); + if (err) { + snd_printk(KERN_ERR "pcxhr_send_it_dsp : TIMEOUT CVR\n"); + return err; + } + if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) { + /* wait for hf5 bit */ + err = pcxhr_check_reg_bit(mgr, PCXHR_PLX_MBOX0, PCXHR_MBOX0_HF5, + PCXHR_MBOX0_HF5, PCXHR_TIMEOUT_DSP, ®); + if (err) { + snd_printk(KERN_ERR "pcxhr_send_it_dsp : TIMEOUT HF5\n"); + return err; + } + } + return 0; /* retry not handled here */ +} + +void pcxhr_reset_xilinx_com(struct pcxhr_mgr *mgr) +{ + /* reset second xilinx */ + PCXHR_OUTPL(mgr, PCXHR_PLX_CHIPSC, + PCXHR_CHIPSC_INIT_VALUE & ~PCXHR_CHIPSC_RESET_XILINX); +} + +static void pcxhr_enable_irq(struct pcxhr_mgr *mgr, int enable) +{ + unsigned int reg = PCXHR_INPL(mgr, PCXHR_PLX_IRQCS); + /* enable/disable interrupts */ + if (enable) + reg |= (PCXHR_IRQCS_ENABLE_PCIIRQ | PCXHR_IRQCS_ENABLE_PCIDB); + else + reg &= ~(PCXHR_IRQCS_ENABLE_PCIIRQ | PCXHR_IRQCS_ENABLE_PCIDB); + PCXHR_OUTPL(mgr, PCXHR_PLX_IRQCS, reg); +} + +void pcxhr_reset_dsp(struct pcxhr_mgr *mgr) +{ + /* disable interrupts */ + pcxhr_enable_irq(mgr, 0); + + /* let's reset the DSP */ + PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, 0); + msleep( PCXHR_WAIT_DEFAULT ); /* wait 2 msec */ + PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, 3); + msleep( PCXHR_WAIT_DEFAULT ); /* wait 2 msec */ + + /* reset mailbox */ + PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX0, 0); +} + +void pcxhr_enable_dsp(struct pcxhr_mgr *mgr) +{ + /* enable interrupts */ + pcxhr_enable_irq(mgr, 1); +} + +/* + * load the xilinx image + */ +int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr, const struct firmware *xilinx, int second) +{ + unsigned int i; + unsigned int chipsc; + unsigned char data; + unsigned char mask; + unsigned char *image; + + /* test first xilinx */ + chipsc = PCXHR_INPL(mgr, PCXHR_PLX_CHIPSC); + if (!second) { + if (chipsc & PCXHR_CHIPSC_GPI_USERI) { + snd_printdd("no need to load first xilinx\n"); + return 0; /* first xilinx is already present and cannot be reset */ + } + } else { + if ((chipsc & PCXHR_CHIPSC_GPI_USERI) == 0) { + snd_printk(KERN_ERR "error loading first xilinx\n"); + return -EINVAL; + } + /* activate second xilinx */ + chipsc |= PCXHR_CHIPSC_RESET_XILINX; + PCXHR_OUTPL(mgr, PCXHR_PLX_CHIPSC, chipsc); + msleep( PCXHR_WAIT_DEFAULT ); /* wait 2 msec */ + } + image = xilinx->data; + for (i = 0; i < xilinx->size; i++, image++) { + data = *image; + mask = 0x80; + while (mask) { + chipsc &= ~(PCXHR_CHIPSC_DATA_CLK | PCXHR_CHIPSC_DATA_IN); + if (data & mask) + chipsc |= PCXHR_CHIPSC_DATA_IN; + PCXHR_OUTPL(mgr, PCXHR_PLX_CHIPSC, chipsc); + chipsc |= PCXHR_CHIPSC_DATA_CLK; + PCXHR_OUTPL(mgr, PCXHR_PLX_CHIPSC, chipsc); + mask >>= 1; + } + /* don't take too much time in this loop... */ + cond_resched(); + } + chipsc &= ~(PCXHR_CHIPSC_DATA_CLK | PCXHR_CHIPSC_DATA_IN); + PCXHR_OUTPL(mgr, PCXHR_PLX_CHIPSC, chipsc); + /* wait 2 msec (time to boot the xilinx before any access) */ + msleep( PCXHR_WAIT_DEFAULT ); + return 0; +} + +/* + * send an executable file to the DSP + */ +static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp) +{ + int err; + unsigned int i; + unsigned int len; + unsigned char *data; + unsigned char dummy; + /* check the length of boot image */ + snd_assert(dsp->size > 0, return -EINVAL); + snd_assert(dsp->size % 3 == 0, return -EINVAL); + snd_assert(dsp->data, return -EINVAL); + /* transfert data buffer from PC to DSP */ + for (i = 0; i < dsp->size; i += 3) { + data = dsp->data + i; + if (i == 0) { + /* test data header consistency */ + len = (unsigned int)((data[0]<<16) + (data[1]<<8) + data[2]); + snd_assert((len==0) || (dsp->size == (len+2)*3), return -EINVAL); + } + /* wait DSP ready for new transfer */ + err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, + PCXHR_ISR_HI08_TRDY, PCXHR_TIMEOUT_DSP, &dummy); + if (err) { + snd_printk(KERN_ERR "dsp loading error at position %d\n", i); + return err; + } + /* send host data */ + PCXHR_OUTPB(mgr, PCXHR_DSP_TXH, data[0]); + PCXHR_OUTPB(mgr, PCXHR_DSP_TXM, data[1]); + PCXHR_OUTPB(mgr, PCXHR_DSP_TXL, data[2]); + + /* don't take too much time in this loop... */ + cond_resched(); + } + /* give some time to boot the DSP */ + msleep(PCXHR_WAIT_DEFAULT); + return 0; +} + +/* + * load the eeprom image + */ +int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr, const struct firmware *eeprom) +{ + int err; + unsigned char reg; + + /* init value of the ICR register */ + reg = PCXHR_ICR_HI08_RREQ | PCXHR_ICR_HI08_TREQ | PCXHR_ICR_HI08_HDRQ; + if (PCXHR_INPL(mgr, PCXHR_PLX_MBOX0) & PCXHR_MBOX0_BOOT_HERE) { + /* no need to load the eeprom binary, but init the HI08 interface */ + PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg | PCXHR_ICR_HI08_INIT); + msleep(PCXHR_WAIT_DEFAULT); + PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); + msleep(PCXHR_WAIT_DEFAULT); + snd_printdd("no need to load eeprom boot\n"); + return 0; + } + PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); + + err = pcxhr_download_dsp(mgr, eeprom); + if (err) + return err; + /* wait for chk bit */ + return pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_CHK, + PCXHR_ISR_HI08_CHK, PCXHR_TIMEOUT_DSP, ®); +} + +/* + * load the boot image + */ +int pcxhr_load_boot_binary(struct pcxhr_mgr *mgr, const struct firmware *boot) +{ + int err; + unsigned int physaddr = mgr->hostport.addr; + unsigned char dummy; + + /* send the hostport address to the DSP (only the upper 24 bit !) */ + snd_assert((physaddr & 0xff) == 0, return -EINVAL); + PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX1, (physaddr >> 8)); + + err = pcxhr_send_it_dsp(mgr, PCXHR_IT_DOWNLOAD_BOOT, 0); + if (err) + return err; + /* clear hf5 bit */ + PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX0, + PCXHR_INPL(mgr, PCXHR_PLX_MBOX0) & ~PCXHR_MBOX0_HF5); + + err = pcxhr_download_dsp(mgr, boot); + if (err) + return err; + /* wait for hf5 bit */ + return pcxhr_check_reg_bit(mgr, PCXHR_PLX_MBOX0, PCXHR_MBOX0_HF5, + PCXHR_MBOX0_HF5, PCXHR_TIMEOUT_DSP, &dummy); +} + +/* + * load the final dsp image + */ +int pcxhr_load_dsp_binary(struct pcxhr_mgr *mgr, const struct firmware *dsp) +{ + int err; + unsigned char dummy; + err = pcxhr_send_it_dsp(mgr, PCXHR_IT_RESET_BOARD_FUNC, 0); + if (err) + return err; + err = pcxhr_send_it_dsp(mgr, PCXHR_IT_DOWNLOAD_DSP, 0); + if (err) + return err; + err = pcxhr_download_dsp(mgr, dsp); + if (err) + return err; + /* wait for chk bit */ + return pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_CHK, + PCXHR_ISR_HI08_CHK, PCXHR_TIMEOUT_DSP, &dummy); +} + + +struct pcxhr_cmd_info { + u32 opcode; /* command word */ + u16 st_length; /* status length */ + u16 st_type; /* status type (RMH_SSIZE_XXX) */ +}; + +/* RMH status type */ +enum { + RMH_SSIZE_FIXED = 0, /* status size fix (st_length = 0..x) */ + RMH_SSIZE_ARG = 1, /* status size given in the LSB byte (used with st_length = 1) */ + RMH_SSIZE_MASK = 2, /* status size given in bitmask (used with st_length = 1) */ +}; + +/* + * Array of DSP commands + */ +static struct pcxhr_cmd_info pcxhr_dsp_cmds[] = { +[CMD_VERSION] = { 0x010000, 1, RMH_SSIZE_FIXED }, +[CMD_SUPPORTED] = { 0x020000, 4, RMH_SSIZE_FIXED }, +[CMD_TEST_IT] = { 0x040000, 1, RMH_SSIZE_FIXED }, +[CMD_SEND_IRQA] = { 0x070001, 0, RMH_SSIZE_FIXED }, +[CMD_ACCESS_IO_WRITE] = { 0x090000, 1, RMH_SSIZE_ARG }, +[CMD_ACCESS_IO_READ] = { 0x094000, 1, RMH_SSIZE_ARG }, +[CMD_ASYNC] = { 0x0a0000, 1, RMH_SSIZE_ARG }, +[CMD_MODIFY_CLOCK] = { 0x0d0000, 0, RMH_SSIZE_FIXED }, +[CMD_RESYNC_AUDIO_INPUTS] = { 0x0e0000, 0, RMH_SSIZE_FIXED }, +[CMD_GET_DSP_RESOURCES] = { 0x100000, 4, RMH_SSIZE_FIXED }, +[CMD_SET_TIMER_INTERRUPT] = { 0x110000, 0, RMH_SSIZE_FIXED }, +[CMD_RES_PIPE] = { 0x400000, 0, RMH_SSIZE_FIXED }, +[CMD_FREE_PIPE] = { 0x410000, 0, RMH_SSIZE_FIXED }, +[CMD_CONF_PIPE] = { 0x422101, 0, RMH_SSIZE_FIXED }, +[CMD_STOP_PIPE] = { 0x470004, 0, RMH_SSIZE_FIXED }, +[CMD_PIPE_SAMPLE_COUNT] = { 0x49a000, 2, RMH_SSIZE_FIXED }, +[CMD_CAN_START_PIPE] = { 0x4b0000, 1, RMH_SSIZE_FIXED }, +[CMD_START_STREAM] = { 0x802000, 0, RMH_SSIZE_FIXED }, +[CMD_STREAM_OUT_LEVEL_ADJUST] = { 0x822000, 0, RMH_SSIZE_FIXED }, +[CMD_STOP_STREAM] = { 0x832000, 0, RMH_SSIZE_FIXED }, +[CMD_UPDATE_R_BUFFERS] = { 0x840000, 0, RMH_SSIZE_FIXED }, +[CMD_FORMAT_STREAM_OUT] = { 0x860000, 0, RMH_SSIZE_FIXED }, +[CMD_FORMAT_STREAM_IN] = { 0x870000, 0, RMH_SSIZE_FIXED }, +[CMD_STREAM_SAMPLE_COUNT] = { 0x902000, 2, RMH_SSIZE_FIXED }, /* stat_len = nb_streams * 2 */ +[CMD_AUDIO_LEVEL_ADJUST] = { 0xc22000, 0, RMH_SSIZE_FIXED }, +}; + +#ifdef CONFIG_SND_DEBUG_DETECT +static char* cmd_names[] = { +[CMD_VERSION] = "CMD_VERSION", +[CMD_SUPPORTED] = "CMD_SUPPORTED", +[CMD_TEST_IT] = "CMD_TEST_IT", +[CMD_SEND_IRQA] = "CMD_SEND_IRQA", +[CMD_ACCESS_IO_WRITE] = "CMD_ACCESS_IO_WRITE", +[CMD_ACCESS_IO_READ] = "CMD_ACCESS_IO_READ", +[CMD_ASYNC] = "CMD_ASYNC", +[CMD_MODIFY_CLOCK] = "CMD_MODIFY_CLOCK", +[CMD_RESYNC_AUDIO_INPUTS] = "CMD_RESYNC_AUDIO_INPUTS", +[CMD_GET_DSP_RESOURCES] = "CMD_GET_DSP_RESOURCES", +[CMD_SET_TIMER_INTERRUPT] = "CMD_SET_TIMER_INTERRUPT", +[CMD_RES_PIPE] = "CMD_RES_PIPE", +[CMD_FREE_PIPE] = "CMD_FREE_PIPE", +[CMD_CONF_PIPE] = "CMD_CONF_PIPE", +[CMD_STOP_PIPE] = "CMD_STOP_PIPE", +[CMD_PIPE_SAMPLE_COUNT] = "CMD_PIPE_SAMPLE_COUNT", +[CMD_CAN_START_PIPE] = "CMD_CAN_START_PIPE", +[CMD_START_STREAM] = "CMD_START_STREAM", +[CMD_STREAM_OUT_LEVEL_ADJUST] = "CMD_STREAM_OUT_LEVEL_ADJUST", +[CMD_STOP_STREAM] = "CMD_STOP_STREAM", +[CMD_UPDATE_R_BUFFERS] = "CMD_UPDATE_R_BUFFERS", +[CMD_FORMAT_STREAM_OUT] = "CMD_FORMAT_STREAM_OUT", +[CMD_FORMAT_STREAM_IN] = "CMD_FORMAT_STREAM_IN", +[CMD_STREAM_SAMPLE_COUNT] = "CMD_STREAM_SAMPLE_COUNT", +[CMD_AUDIO_LEVEL_ADJUST] = "CMD_AUDIO_LEVEL_ADJUST", +}; +#endif + + +static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) +{ + int err; + int i; + u32 data; + u32 size_mask; + unsigned char reg; + int max_stat_len; + + if (rmh->stat_len < PCXHR_SIZE_MAX_STATUS) + max_stat_len = PCXHR_SIZE_MAX_STATUS; + else max_stat_len = rmh->stat_len; + + for (i = 0; i < rmh->stat_len; i++) { + /* wait for receiver full */ + err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_RXDF, + PCXHR_ISR_HI08_RXDF, PCXHR_TIMEOUT_DSP, ®); + if (err) { + snd_printk(KERN_ERR "ERROR RMH stat: ISR:RXDF=1 (ISR = %x; i=%d )\n", + reg, i); + return err; + } + /* read data */ + data = PCXHR_INPB(mgr, PCXHR_DSP_TXH) << 16; + data |= PCXHR_INPB(mgr, PCXHR_DSP_TXM) << 8; + data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL); + + /* need to update rmh->stat_len on the fly ?? */ + if (i==0) { + if (rmh->dsp_stat != RMH_SSIZE_FIXED) { + if (rmh->dsp_stat == RMH_SSIZE_ARG) { + rmh->stat_len = (u16)(data & 0x0000ff) + 1; + data &= 0xffff00; + } else { + /* rmh->dsp_stat == RMH_SSIZE_MASK */ + rmh->stat_len = 1; + size_mask = data; + while (size_mask) { + if (size_mask & 1) + rmh->stat_len++; + size_mask >>= 1; + } + } + } + } +#ifdef CONFIG_SND_DEBUG_DETECT + if (rmh->cmd_idx < CMD_LAST_INDEX) + snd_printdd(" stat[%d]=%x\n", i, data); +#endif + if (i < max_stat_len) + rmh->stat[i] = data; + } + if (rmh->stat_len > max_stat_len) { + snd_printdd("PCXHR : rmh->stat_len=%x too big\n", rmh->stat_len); + rmh->stat_len = max_stat_len; + } + return 0; +} + +static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) +{ + int err; + int i; + u32 data; + unsigned char reg; + + snd_assert(rmh->cmd_lencmd[0]; + + if (rmh->cmd_len > 1) + data |= 0x008000; /* MASK_MORE_THAN_1_WORD_COMMAND */ + else + data &= 0xff7fff; /* MASK_1_WORD_COMMAND */ +#ifdef CONFIG_SND_DEBUG_DETECT + if (rmh->cmd_idx < CMD_LAST_INDEX) + snd_printdd("MSG cmd[0]=%x (%s)\n", data, cmd_names[rmh->cmd_idx]); +#endif + + err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, + PCXHR_ISR_HI08_TRDY, PCXHR_TIMEOUT_DSP, ®); + if (err) + return err; + PCXHR_OUTPB(mgr, PCXHR_DSP_TXH, (data>>16)&0xFF); + PCXHR_OUTPB(mgr, PCXHR_DSP_TXM, (data>>8)&0xFF); + PCXHR_OUTPB(mgr, PCXHR_DSP_TXL, (data&0xFF)); + + if (rmh->cmd_len > 1) { + /* send length */ + data = rmh->cmd_len - 1; + err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, + PCXHR_ISR_HI08_TRDY, PCXHR_TIMEOUT_DSP, ®); + if (err) + return err; + PCXHR_OUTPB(mgr, PCXHR_DSP_TXH, (data>>16)&0xFF); + PCXHR_OUTPB(mgr, PCXHR_DSP_TXM, (data>>8)&0xFF); + PCXHR_OUTPB(mgr, PCXHR_DSP_TXL, (data&0xFF)); + + for (i=1; i < rmh->cmd_len; i++) { + /* send other words */ + data = rmh->cmd[i]; +#ifdef CONFIG_SND_DEBUG_DETECT + if (rmh->cmd_idx < CMD_LAST_INDEX) + snd_printdd(" cmd[%d]=%x\n", i, data); +#endif + err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, + PCXHR_ISR_HI08_TRDY, + PCXHR_ISR_HI08_TRDY, + PCXHR_TIMEOUT_DSP, ®); + if (err) + return err; + PCXHR_OUTPB(mgr, PCXHR_DSP_TXH, (data>>16)&0xFF); + PCXHR_OUTPB(mgr, PCXHR_DSP_TXM, (data>>8)&0xFF); + PCXHR_OUTPB(mgr, PCXHR_DSP_TXL, (data&0xFF)); + } + } + /* wait for chk bit */ + err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_CHK, + PCXHR_ISR_HI08_CHK, PCXHR_TIMEOUT_DSP, ®); + if (err) + return err; + /* test status ISR */ + if (reg & PCXHR_ISR_HI08_ERR) { + /* ERROR, wait for receiver full */ + err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_RXDF, + PCXHR_ISR_HI08_RXDF, PCXHR_TIMEOUT_DSP, ®); + if (err) { + snd_printk(KERN_ERR "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg); + return err; + } + /* read error code */ + data = PCXHR_INPB(mgr, PCXHR_DSP_TXH) << 16; + data |= PCXHR_INPB(mgr, PCXHR_DSP_TXM) << 8; + data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL); + snd_printk(KERN_ERR "ERROR RMH(%d): 0x%x\n", rmh->cmd_idx, data); + err = -EINVAL; + } else { + /* read the response data */ + err = pcxhr_read_rmh_status(mgr, rmh); + } + /* reset semaphore */ + if (pcxhr_send_it_dsp(mgr, PCXHR_IT_RESET_SEMAPHORE, 1) < 0) + return -EIO; + return err; +} + + +/** + * pcxhr_init_rmh - initialize the RMH instance + * @rmh: the rmh pointer to be initialized + * @cmd: the rmh command to be set + */ +void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd) +{ + snd_assert(cmd < CMD_LAST_INDEX, return); + rmh->cmd[0] = pcxhr_dsp_cmds[cmd].opcode; + rmh->cmd_len = 1; + rmh->stat_len = pcxhr_dsp_cmds[cmd].st_length; + rmh->dsp_stat = pcxhr_dsp_cmds[cmd].st_type; + rmh->cmd_idx = cmd; +} + + +void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh *rmh, int capture, + unsigned int param1, unsigned int param2, + unsigned int param3) +{ + snd_assert(param1 <= MASK_FIRST_FIELD); + if (capture) + rmh->cmd[0] |= 0x800; /* COMMAND_RECORD_MASK */ + if (param1) + rmh->cmd[0] |= (param1 << FIELD_SIZE); + if (param2) { + snd_assert(param2 <= MASK_FIRST_FIELD); + rmh->cmd[0] |= param2; + } + if(param3) { + snd_assert(param3 <= MASK_DSP_WORD); + rmh->cmd[1] = param3; + rmh->cmd_len = 2; + } +} + +/* + * pcxhr_send_msg - send a DSP message with spinlock + * @rmh: the rmh record to send and receive + * + * returns 0 if successful, or a negative error code. + */ +int pcxhr_send_msg(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) +{ + unsigned long flags; + int err; + spin_lock_irqsave(&mgr->msg_lock, flags); + err = pcxhr_send_msg_nolock(mgr, rmh); + spin_unlock_irqrestore(&mgr->msg_lock, flags); + return err; +} + +static inline int pcxhr_pipes_running(struct pcxhr_mgr *mgr) +{ + int start_mask = PCXHR_INPL(mgr, PCXHR_PLX_MBOX2); + /* least segnificant 12 bits are the pipe states for the playback audios */ + /* next 12 bits are the pipe states for the capture audios + * (PCXHR_PIPE_STATE_CAPTURE_OFFSET) + */ + start_mask &= 0xffffff; + snd_printdd("CMD_PIPE_STATE MBOX2=0x%06x\n", start_mask); + return start_mask; +} + +#define PCXHR_PIPE_STATE_CAPTURE_OFFSET 12 +#define MAX_WAIT_FOR_DSP 20 + +static int pcxhr_prepair_pipe_start(struct pcxhr_mgr *mgr, int audio_mask, int *retry) +{ + struct pcxhr_rmh rmh; + int err; + int audio = 0; + + *retry = 0; + while (audio_mask) { + if (audio_mask & 1) { + pcxhr_init_rmh(&rmh, CMD_CAN_START_PIPE); + if (audio < PCXHR_PIPE_STATE_CAPTURE_OFFSET) { + /* can start playback pipe */ + pcxhr_set_pipe_cmd_params(&rmh, 0, audio, 0, 0); + } else { + /* can start capture pipe */ + pcxhr_set_pipe_cmd_params(&rmh, 1, audio - + PCXHR_PIPE_STATE_CAPTURE_OFFSET, + 0, 0); + } + err = pcxhr_send_msg(mgr, &rmh); + if (err) { + snd_printk(KERN_ERR + "error pipe start (CMD_CAN_START_PIPE) err=%x!\n", + err); + return err; + } + /* if the pipe couldn't be prepaired for start, retry it later */ + if (rmh.stat[0] == 0) + *retry |= (1<>=1; + audio++; + } + return 0; +} + +static int pcxhr_stop_pipes(struct pcxhr_mgr *mgr, int audio_mask) +{ + struct pcxhr_rmh rmh; + int err; + int audio = 0; + + while (audio_mask) { + if (audio_mask & 1) { + pcxhr_init_rmh(&rmh, CMD_STOP_PIPE); + if (audio < PCXHR_PIPE_STATE_CAPTURE_OFFSET) { + /* stop playback pipe */ + pcxhr_set_pipe_cmd_params(&rmh, 0, audio, 0, 0); + } else { + /* stop capture pipe */ + pcxhr_set_pipe_cmd_params(&rmh, 1, audio - + PCXHR_PIPE_STATE_CAPTURE_OFFSET, + 0, 0); + } + err = pcxhr_send_msg(mgr, &rmh); + if (err) { + snd_printk(KERN_ERR + "error pipe stop (CMD_STOP_PIPE) err=%x!\n", + err); + return err; + } + } + audio_mask>>=1; + audio++; + } + return 0; +} + +static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask) +{ + struct pcxhr_rmh rmh; + int err; + int audio = 0; + + while (audio_mask) { + if (audio_mask & 1) { + pcxhr_init_rmh(&rmh, CMD_CONF_PIPE); + if (audio < PCXHR_PIPE_STATE_CAPTURE_OFFSET) + pcxhr_set_pipe_cmd_params(&rmh, 0, 0, 0, 1 << audio); + else + pcxhr_set_pipe_cmd_params(&rmh, 1, 0, 0, + 1 << (audio - PCXHR_PIPE_STATE_CAPTURE_OFFSET)); + err = pcxhr_send_msg(mgr, &rmh); + if (err) { + snd_printk(KERN_ERR + "error pipe start (CMD_CONF_PIPE) err=%x!\n", + err); + return err; + } + } + audio_mask>>=1; + audio++; + } + /* now fire the interrupt on the card */ + pcxhr_init_rmh(&rmh, CMD_SEND_IRQA); + err = pcxhr_send_msg(mgr, &rmh); + if (err) { + snd_printk(KERN_ERR "error pipe start (CMD_SEND_IRQA) err=%x!\n", err ); + return err; + } + return 0; +} + + + +int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, int capture_mask, int start) +{ + int state, i, err; + int audio_mask; + +#ifdef CONFIG_SND_DEBUG_DETECT + struct timeval my_tv1, my_tv2; + do_gettimeofday(&my_tv1); +#endif + audio_mask = (playback_mask | (capture_mask << PCXHR_PIPE_STATE_CAPTURE_OFFSET)); + /* current pipe state (playback + record) */ + state = pcxhr_pipes_running(mgr); + snd_printdd("pcxhr_set_pipe_state %s (mask %x current %x)\n", + start ? "START" : "STOP", audio_mask, state); + if (start) { + audio_mask &= ~state; /* start only pipes that are not yet started */ + state = audio_mask; + for (i = 0; i < MAX_WAIT_FOR_DSP; i++) { + err = pcxhr_prepair_pipe_start(mgr, state, &state); + if (err) + return err; + if (state == 0) + break; /* success, all pipes prepaired for start */ + mdelay(1); /* otherwise wait 1 millisecond and retry */ + } + } else { + audio_mask &= state; /* stop only pipes that are started */ + } + if (audio_mask == 0) + return 0; + + err = pcxhr_toggle_pipes(mgr, audio_mask); + if (err) + return err; + + i = 0; + while (1) { + state = pcxhr_pipes_running(mgr); + /* have all pipes the new state ? */ + if ((state & audio_mask) == (start ? audio_mask : 0)) + break; + if (++i >= MAX_WAIT_FOR_DSP * 100) { + snd_printk(KERN_ERR "error pipe start/stop (ED_NO_RESPONSE_AT_IRQA)\n"); + return -EBUSY; + } + udelay(10); /* wait 10 microseconds */ + } + if (!start) { + err = pcxhr_stop_pipes(mgr, audio_mask); + if (err) + return err; + } +#ifdef CONFIG_SND_DEBUG_DETECT + do_gettimeofday(&my_tv2); + snd_printdd("***SET PIPE STATE*** TIME = %ld (err = %x)\n", + my_tv2.tv_usec - my_tv1.tv_usec, err); +#endif + return 0; +} + +int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask, + unsigned int value, int *changed) +{ + struct pcxhr_rmh rmh; + unsigned long flags; + int err; + + spin_lock_irqsave(&mgr->msg_lock, flags); + if ((mgr->io_num_reg_cont & mask) == value) { + snd_printdd("IO_NUM_REG_CONT mask %x already is set to %x\n", mask, value); + if (changed) + *changed = 0; + spin_unlock_irqrestore(&mgr->msg_lock, flags); + return 0; /* already programmed */ + } + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); + rmh.cmd[0] |= IO_NUM_REG_CONT; + rmh.cmd[1] = mask; + rmh.cmd[2] = value; + rmh.cmd_len = 3; + err = pcxhr_send_msg_nolock(mgr, &rmh); + if (err == 0) { + mgr->io_num_reg_cont &= ~mask; + mgr->io_num_reg_cont |= value; + if (changed) + *changed = 1; + } + spin_unlock_irqrestore(&mgr->msg_lock, flags); + return err; +} + +#define PCXHR_IRQ_TIMER 0x000300 +#define PCXHR_IRQ_FREQ_CHANGE 0x000800 +#define PCXHR_IRQ_TIME_CODE 0x001000 +#define PCXHR_IRQ_NOTIFY 0x002000 +#define PCXHR_IRQ_ASYNC 0x008000 +#define PCXHR_IRQ_MASK 0x00bb00 +#define PCXHR_FATAL_DSP_ERR 0xff0000 + +enum pcxhr_async_err_src { + PCXHR_ERR_PIPE, + PCXHR_ERR_STREAM, + PCXHR_ERR_AUDIO +}; + +static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err, + enum pcxhr_async_err_src err_src, int pipe, + int is_capture) +{ +#ifdef CONFIG_SND_DEBUG_DETECT + static char* err_src_name[] = { + [PCXHR_ERR_PIPE] = "Pipe", + [PCXHR_ERR_STREAM] = "Stream", + [PCXHR_ERR_AUDIO] = "Audio" + }; +#endif + if (err & 0xfff) + err &= 0xfff; + else + err = ((err >> 12) & 0xfff); + if (!err) + return 0; + snd_printdd("CMD_ASYNC : Error %s %s Pipe %d err=%x\n", err_src_name[err_src], + is_capture ? "Record" : "Play", pipe, err); + if (err == 0xe01) + mgr->async_err_stream_xrun++; + else if (err == 0xe10) + mgr->async_err_pipe_xrun++; + else + mgr->async_err_other_last = (int)err; + return 1; +} + + +void pcxhr_msg_tasklet(unsigned long arg) +{ + struct pcxhr_mgr *mgr = (struct pcxhr_mgr *)(arg); + struct pcxhr_rmh *prmh = mgr->prmh; + int err; + int i, j; + + if (mgr->src_it_dsp & PCXHR_IRQ_FREQ_CHANGE) + snd_printdd("TASKLET : PCXHR_IRQ_FREQ_CHANGE event occured\n"); + if (mgr->src_it_dsp & PCXHR_IRQ_TIME_CODE) + snd_printdd("TASKLET : PCXHR_IRQ_TIME_CODE event occured\n"); + if (mgr->src_it_dsp & PCXHR_IRQ_NOTIFY) + snd_printdd("TASKLET : PCXHR_IRQ_NOTIFY event occured\n"); + if (mgr->src_it_dsp & PCXHR_IRQ_ASYNC) { + snd_printdd("TASKLET : PCXHR_IRQ_ASYNC event occured\n"); + + pcxhr_init_rmh(prmh, CMD_ASYNC); + prmh->cmd[0] |= 1; /* add SEL_ASYNC_EVENTS */ + /* this is the only one extra long response command */ + prmh->stat_len = PCXHR_SIZE_MAX_LONG_STATUS; + err = pcxhr_send_msg(mgr, prmh); + if (err) + snd_printk(KERN_ERR "ERROR pcxhr_msg_tasklet=%x;\n", err); + i = 1; + while (i < prmh->stat_len) { + int nb_audio = (prmh->stat[i] >> FIELD_SIZE) & MASK_FIRST_FIELD; + int nb_stream = (prmh->stat[i] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD; + int pipe = prmh->stat[i] & MASK_FIRST_FIELD; + int is_capture = prmh->stat[i] & 0x400000; + u32 err; + + if (prmh->stat[i] & 0x800000) { /* if BIT_END */ + snd_printdd("TASKLET : End%sPipe %d\n", + is_capture ? "Record" : "Play", pipe); + } + i++; + err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; + if (err) + pcxhr_handle_async_err(mgr, err, PCXHR_ERR_PIPE, + pipe, is_capture); + i += 2; + for (j = 0; j < nb_stream; j++) { + err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; + if (err) + pcxhr_handle_async_err(mgr, err, PCXHR_ERR_STREAM, + pipe, is_capture); + i += 2; + } + for (j = 0; j < nb_audio; j++) { + err = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; + if (err) + pcxhr_handle_async_err(mgr, err, PCXHR_ERR_AUDIO, + pipe, is_capture); + i += 2; + } + } + } +} + +static u_int64_t pcxhr_stream_read_position(struct pcxhr_mgr *mgr, + struct pcxhr_stream *stream) +{ + u_int64_t hw_sample_count; + struct pcxhr_rmh rmh; + int err, stream_mask; + + stream_mask = stream->pipe->is_capture ? 1 : 1<substream->number; + + /* get sample count for one stream */ + pcxhr_init_rmh(&rmh, CMD_STREAM_SAMPLE_COUNT); + pcxhr_set_pipe_cmd_params(&rmh, stream->pipe->is_capture, + stream->pipe->first_audio, 0, stream_mask); + /* rmh.stat_len = 2; */ /* 2 resp data for each stream of the pipe */ + + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return 0; + + hw_sample_count = ((u_int64_t)rmh.stat[0]) << 24; + hw_sample_count += (u_int64_t)rmh.stat[1]; + + snd_printdd("stream %c%d : abs samples real(%ld) timer(%ld)\n", + stream->pipe->is_capture ? 'C':'P', stream->substream->number, + (long unsigned int)hw_sample_count, + (long unsigned int)(stream->timer_abs_periods + + stream->timer_period_frag + PCXHR_GRANULARITY)); + + return hw_sample_count; +} + +static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr, + struct pcxhr_stream *stream, int samples_to_add) +{ + if (stream->substream && (stream->status == PCXHR_STREAM_STATUS_RUNNING)) { + u_int64_t new_sample_count; + int elapsed = 0; + int hardware_read = 0; + struct snd_pcm_runtime *runtime = stream->substream->runtime; + + if (samples_to_add < 0) { + stream->timer_is_synced = 0; + /* add default if no hardware_read possible */ + samples_to_add = PCXHR_GRANULARITY; + } + + if (!stream->timer_is_synced) { + if (stream->timer_abs_periods != 0 || + stream->timer_period_frag + PCXHR_GRANULARITY >= + runtime->period_size) { + new_sample_count = pcxhr_stream_read_position(mgr, stream); + hardware_read = 1; + if (new_sample_count >= PCXHR_GRANULARITY_MIN) { + /* sub security offset because of jitter and + * finer granularity of dsp time (MBOX4) + */ + new_sample_count -= PCXHR_GRANULARITY_MIN; + stream->timer_is_synced = 1; + } + } + } + if (!hardware_read) { + /* if we didn't try to sync the position, increment it + * by PCXHR_GRANULARITY every timer interrupt + */ + new_sample_count = stream->timer_abs_periods + + stream->timer_period_frag + samples_to_add; + } + while (1) { + u_int64_t new_elapse_pos = stream->timer_abs_periods + + runtime->period_size; + if (new_elapse_pos > new_sample_count) + break; + elapsed = 1; + stream->timer_buf_periods++; + if (stream->timer_buf_periods >= runtime->periods) + stream->timer_buf_periods = 0; + stream->timer_abs_periods = new_elapse_pos; + } + if (new_sample_count >= stream->timer_abs_periods) + stream->timer_period_frag = (u_int32_t)(new_sample_count - + stream->timer_abs_periods); + else + snd_printk(KERN_ERR "ERROR new_sample_count too small ??? %lx\n", + (long unsigned int)new_sample_count); + + if (elapsed) { + spin_unlock(&mgr->lock); + snd_pcm_period_elapsed(stream->substream); + spin_lock(&mgr->lock); + } + } +} + + +irqreturn_t pcxhr_interrupt(int irq, void *dev_id, struct pt_regs *regs) +{ + struct pcxhr_mgr *mgr = dev_id; + unsigned int reg; + int i, j; + struct snd_pcxhr *chip; + + spin_lock(&mgr->lock); + + reg = PCXHR_INPL(mgr, PCXHR_PLX_IRQCS); + if (! (reg & PCXHR_IRQCS_ACTIVE_PCIDB)) { + spin_unlock(&mgr->lock); + return IRQ_NONE; /* this device did not cause the interrupt */ + } + + /* clear interrupt */ + reg = PCXHR_INPL(mgr, PCXHR_PLX_L2PCIDB); + PCXHR_OUTPL(mgr, PCXHR_PLX_L2PCIDB, reg); + + /* timer irq occured */ + if (reg & PCXHR_IRQ_TIMER) { + int timer_toggle = reg & PCXHR_IRQ_TIMER; + /* is a 24 bit counter */ + int dsp_time_new = PCXHR_INPL(mgr, PCXHR_PLX_MBOX4) & PCXHR_DSP_TIME_MASK; + int dsp_time_diff = dsp_time_new - mgr->dsp_time_last; + + if (dsp_time_diff < 0 && mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID) { + snd_printdd("ERROR DSP TIME old(%d) new(%d) -> " + "resynchronize all streams\n", + mgr->dsp_time_last, dsp_time_new); + mgr->dsp_time_err++; + } +#ifdef CONFIG_SND_DEBUG_DETECT + if (dsp_time_diff == 0) + snd_printdd("ERROR DSP TIME NO DIFF time(%d)\n", dsp_time_new); + else if (dsp_time_diff >= (2*PCXHR_GRANULARITY)) + snd_printdd("ERROR DSP TIME TOO BIG old(%d) add(%d)\n", + mgr->dsp_time_last, dsp_time_new - mgr->dsp_time_last); +#endif + mgr->dsp_time_last = dsp_time_new; + + if (timer_toggle == mgr->timer_toggle) + snd_printk(KERN_ERR "ERROR TIMER TOGGLE\n"); + mgr->timer_toggle = timer_toggle; + + reg &= ~PCXHR_IRQ_TIMER; + for (i = 0; i < mgr->num_cards; i++) { + chip = mgr->chip[i]; + for (j = 0; j < chip->nb_streams_capt; j++) + pcxhr_update_timer_pos(mgr, &chip->capture_stream[j], + dsp_time_diff); + } + for (i = 0; i < mgr->num_cards; i++) { + chip = mgr->chip[i]; + for (j = 0; j < chip->nb_streams_play; j++) + pcxhr_update_timer_pos(mgr, &chip->playback_stream[j], + dsp_time_diff); + } + } + /* other irq's handled in the tasklet */ + if (reg & PCXHR_IRQ_MASK) { + + /* as we didn't request any notifications, some kind of xrun error + * will probably occured + */ + /* better resynchronize all streams next interrupt : */ + mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; + + mgr->src_it_dsp = reg; + tasklet_hi_schedule(&mgr->msg_taskq); + } +#ifdef CONFIG_SND_DEBUG_DETECT + if (reg & PCXHR_FATAL_DSP_ERR) + snd_printdd("FATAL DSP ERROR : %x\n", reg); +#endif + spin_unlock(&mgr->lock); + return IRQ_HANDLED; /* this device caused the interrupt */ +} diff --git a/sound/pci/pcxhr/pcxhr_core.h b/sound/pci/pcxhr/pcxhr_core.h new file mode 100644 index 0000000..e7415d6 --- /dev/null +++ b/sound/pci/pcxhr/pcxhr_core.h @@ -0,0 +1,200 @@ +/* + * Driver for Digigram pcxhr compatible soundcards + * + * low level interface with interrupt ans message handling + * + * Copyright (c) 2004 by Digigram + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __SOUND_PCXHR_CORE_H +#define __SOUND_PCXHR_CORE_H + +struct firmware; +struct pcxhr_mgr; + +/* init and firmware download commands */ +void pcxhr_reset_xilinx_com(struct pcxhr_mgr *mgr); +void pcxhr_reset_dsp(struct pcxhr_mgr *mgr); +void pcxhr_enable_dsp(struct pcxhr_mgr *mgr); +int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr, const struct firmware *xilinx, int second); +int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr, const struct firmware *eeprom); +int pcxhr_load_boot_binary(struct pcxhr_mgr *mgr, const struct firmware *boot); +int pcxhr_load_dsp_binary(struct pcxhr_mgr *mgr, const struct firmware *dsp); + +/* DSP time available on MailBox4 register : 24 bit time samples() */ +#define PCXHR_DSP_TIME_MASK 0x00ffffff +#define PCXHR_DSP_TIME_INVALID 0x10000000 + + +#define PCXHR_SIZE_MAX_CMD 8 +#define PCXHR_SIZE_MAX_STATUS 16 +#define PCXHR_SIZE_MAX_LONG_STATUS 256 + +struct pcxhr_rmh { + u16 cmd_len; /* length of the command to send (WORDs) */ + u16 stat_len; /* length of the status received (WORDs) */ + u16 dsp_stat; /* status type, RMP_SSIZE_XXX */ + u16 cmd_idx; /* index of the command */ + u32 cmd[PCXHR_SIZE_MAX_CMD]; + u32 stat[PCXHR_SIZE_MAX_STATUS]; +}; + +enum { + CMD_VERSION, /* cmd_len = 2 stat_len = 1 */ + CMD_SUPPORTED, /* cmd_len = 1 stat_len = 4 */ + CMD_TEST_IT, /* cmd_len = 1 stat_len = 1 */ + CMD_SEND_IRQA, /* cmd_len = 1 stat_len = 0 */ + CMD_ACCESS_IO_WRITE, /* cmd_len >= 1 stat_len >= 1 */ + CMD_ACCESS_IO_READ, /* cmd_len >= 1 stat_len >= 1 */ + CMD_ASYNC, /* cmd_len = 1 stat_len = 1 */ + CMD_MODIFY_CLOCK, /* cmd_len = 3 stat_len = 0 */ + CMD_RESYNC_AUDIO_INPUTS, /* cmd_len = 1 stat_len = 0 */ + CMD_GET_DSP_RESOURCES, /* cmd_len = 1 stat_len = 4 */ + CMD_SET_TIMER_INTERRUPT, /* cmd_len = 1 stat_len = 0 */ + CMD_RES_PIPE, /* cmd_len = 2 stat_len = 0 */ + CMD_FREE_PIPE, /* cmd_len = 1 stat_len = 0 */ + CMD_CONF_PIPE, /* cmd_len = 2 stat_len = 0 */ + CMD_STOP_PIPE, /* cmd_len = 1 stat_len = 0 */ + CMD_PIPE_SAMPLE_COUNT, /* cmd_len = 2 stat_len = 2 */ + CMD_CAN_START_PIPE, /* cmd_len >= 1 stat_len = 1 */ + CMD_START_STREAM, /* cmd_len = 2 stat_len = 0 */ + CMD_STREAM_OUT_LEVEL_ADJUST, /* cmd_len >= 1 stat_len = 0 */ + CMD_STOP_STREAM, /* cmd_len = 2 stat_len = 0 */ + CMD_UPDATE_R_BUFFERS, /* cmd_len = 4 stat_len = 0 */ + CMD_FORMAT_STREAM_OUT, /* cmd_len >= 2 stat_len = 0 */ + CMD_FORMAT_STREAM_IN, /* cmd_len >= 4 stat_len = 0 */ + CMD_STREAM_SAMPLE_COUNT, /* cmd_len = 2 stat_len = (2 * nb_stream) */ + CMD_AUDIO_LEVEL_ADJUST, /* cmd_len = 3 stat_len = 0 */ + CMD_LAST_INDEX +}; + +#define MASK_DSP_WORD 0x00ffffff +#define MASK_ALL_STREAM 0x00ffffff +#define MASK_DSP_WORD_LEVEL 0x000001ff +#define MASK_FIRST_FIELD 0x0000001f +#define FIELD_SIZE 5 + +/* + init the rmh struct; by default cmd_len is set to 1 + */ +void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd); + +void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh* rmh, int capture, unsigned int param1, + unsigned int param2, unsigned int param3); + +/* + send the rmh + */ +int pcxhr_send_msg(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh); + + +/* values used for CMD_ACCESS_IO_WRITE and CMD_ACCESS_IO_READ */ +#define IO_NUM_REG_CONT 0 +#define IO_NUM_REG_GENCLK 1 +#define IO_NUM_REG_MUTE_OUT 2 +#define IO_NUM_SPEED_RATIO 4 +#define IO_NUM_REG_STATUS 5 +#define IO_NUM_REG_CUER 10 +#define IO_NUM_UER_CHIP_REG 11 +#define IO_NUM_REG_OUT_ANA_LEVEL 20 +#define IO_NUM_REG_IN_ANA_LEVEL 21 + + +#define REG_CONT_UNMUTE_INPUTS 0x020000 + +/* parameters used with register IO_NUM_REG_STATUS */ +#define REG_STATUS_OPTIONS 0 +#define REG_STATUS_AES_SYNC 8 +#define REG_STATUS_AES_1 9 +#define REG_STATUS_AES_2 10 +#define REG_STATUS_AES_3 11 +#define REG_STATUS_AES_4 12 +#define REG_STATUS_WORD_CLOCK 13 +#define REG_STATUS_INTER_SYNC 14 +#define REG_STATUS_CURRENT 0x80 +/* results */ +#define REG_STATUS_OPT_NO_VIDEO_SIGNAL 0x01 +#define REG_STATUS_OPT_DAUGHTER_MASK 0x1c +#define REG_STATUS_OPT_ANALOG_BOARD 0x00 +#define REG_STATUS_OPT_NO_DAUGHTER 0x1c +#define REG_STATUS_OPT_COMPANION_MASK 0xe0 +#define REG_STATUS_OPT_NO_COMPANION 0xe0 +#define REG_STATUS_SYNC_32000 0x00 +#define REG_STATUS_SYNC_44100 0x01 +#define REG_STATUS_SYNC_48000 0x02 +#define REG_STATUS_SYNC_64000 0x03 +#define REG_STATUS_SYNC_88200 0x04 +#define REG_STATUS_SYNC_96000 0x05 +#define REG_STATUS_SYNC_128000 0x06 +#define REG_STATUS_SYNC_176400 0x07 +#define REG_STATUS_SYNC_192000 0x08 + +int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, int capture_mask, int start); + +int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask, + unsigned int value, int *changed); + +/* codec parameters */ +#define CS8416_RUN 0x200401 +#define CS8416_FORMAT_DETECT 0x200b00 +#define CS8416_CSB0 0x201900 +#define CS8416_CSB1 0x201a00 +#define CS8416_CSB2 0x201b00 +#define CS8416_CSB3 0x201c00 +#define CS8416_CSB4 0x201d00 +#define CS8416_VERSION 0x207f00 + +#define CS8420_DATA_FLOW_CTL 0x200301 +#define CS8420_CLOCK_SRC_CTL 0x200401 +#define CS8420_RECEIVER_ERRORS 0x201000 +#define CS8420_SRC_RATIO 0x201e00 +#define CS8420_CSB0 0x202000 +#define CS8420_CSB1 0x202100 +#define CS8420_CSB2 0x202200 +#define CS8420_CSB3 0x202300 +#define CS8420_CSB4 0x202400 +#define CS8420_VERSION 0x207f00 + +#define CS4271_MODE_CTL_1 0x200101 +#define CS4271_DAC_CTL 0x200201 +#define CS4271_VOLMIX 0x200301 +#define CS4271_VOLMUTE_LEFT 0x200401 +#define CS4271_VOLMUTE_RIGHT 0x200501 +#define CS4271_ADC_CTL 0x200601 +#define CS4271_MODE_CTL_2 0x200701 + +#define CHIP_SIG_AND_MAP_SPI 0xff7f00 + +/* codec selection */ +#define CS4271_01_CS 0x160018 +#define CS4271_23_CS 0x160019 +#define CS4271_45_CS 0x16001a +#define CS4271_67_CS 0x16001b +#define CS4271_89_CS 0x16001c +#define CS4271_AB_CS 0x16001d +#define CS8420_01_CS 0x080090 +#define CS8420_23_CS 0x080092 +#define CS8420_45_CS 0x080094 +#define CS8420_67_CS 0x080096 +#define CS8416_01_CS 0x080098 + + +/* interrupt handling */ +irqreturn_t pcxhr_interrupt(int irq, void *dev_id, struct pt_regs *regs); +void pcxhr_msg_tasklet(unsigned long arg); + +#endif /* __SOUND_PCXHR_CORE_H */ diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c new file mode 100644 index 0000000..03517c1 --- /dev/null +++ b/sound/pci/pcxhr/pcxhr_hwdep.c @@ -0,0 +1,438 @@ +/* + * Driver for Digigram pcxhr compatible soundcards + * + * hwdep device manager + * + * Copyright (c) 2004 by Digigram + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "pcxhr.h" +#include "pcxhr_mixer.h" +#include "pcxhr_hwdep.h" +#include "pcxhr_core.h" + + +#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) +#if !defined(CONFIG_USE_PCXHRLOADER) && !defined(CONFIG_SND_PCXHR) /* built-in kernel */ +#define SND_PCXHR_FW_LOADER /* use the standard firmware loader */ +#endif +#endif + + +/* + * get basic information and init pcxhr card + */ + +static int pcxhr_init_board(struct pcxhr_mgr *mgr) +{ + int err; + struct pcxhr_rmh rmh; + int card_streams; + + /* calc the number of all streams used */ + if (mgr->mono_capture) + card_streams = mgr->capture_chips * 2; + else + card_streams = mgr->capture_chips; + card_streams += mgr->playback_chips * PCXHR_PLAYBACK_STREAMS; + + /* enable interrupts */ + pcxhr_enable_dsp(mgr); + + pcxhr_init_rmh(&rmh, CMD_SUPPORTED); + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + /* test 8 or 12 phys out */ + snd_assert((rmh.stat[0] & MASK_FIRST_FIELD) == mgr->playback_chips*2, + return -EINVAL); + /* test 8 or 2 phys in */ + snd_assert(((rmh.stat[0] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD) == + mgr->capture_chips * 2, return -EINVAL); + /* test max nb substream per board */ + snd_assert((rmh.stat[1] & 0x5F) >= card_streams, return -EINVAL); + /* test max nb substream per pipe */ + snd_assert(((rmh.stat[1]>>7)&0x5F) >= PCXHR_PLAYBACK_STREAMS, return -EINVAL); + + pcxhr_init_rmh(&rmh, CMD_VERSION); + /* firmware num for DSP */ + rmh.cmd[0] |= mgr->firmware_num; + /* transfer granularity in samples (should be multiple of 48) */ + rmh.cmd[1] = (1<<23) + PCXHR_GRANULARITY; + rmh.cmd_len = 2; + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + snd_printdd("PCXHR DSP version is %d.%d.%d\n", + (rmh.stat[0]>>16)&0xff, (rmh.stat[0]>>8)&0xff, rmh.stat[0]&0xff); + mgr->dsp_version = rmh.stat[0]; + + /* get options */ + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); + rmh.cmd[0] |= IO_NUM_REG_STATUS; + rmh.cmd[1] = REG_STATUS_OPTIONS; + rmh.cmd_len = 2; + err = pcxhr_send_msg(mgr, &rmh); + if (err) + return err; + + if ((rmh.stat[1] & REG_STATUS_OPT_DAUGHTER_MASK) == REG_STATUS_OPT_ANALOG_BOARD) + mgr->board_has_analog = 1; /* analog addon board available */ + else + /* analog addon board not available -> no support for instance */ + return -EINVAL; + + /* unmute inputs */ + err = pcxhr_write_io_num_reg_cont(mgr, REG_CONT_UNMUTE_INPUTS, + REG_CONT_UNMUTE_INPUTS, NULL); + if (err) + return err; + /* unmute outputs */ + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); /* a write to IO_NUM_REG_MUTE_OUT mutes! */ + rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; + err = pcxhr_send_msg(mgr, &rmh); + return err; +} + +void pcxhr_reset_board(struct pcxhr_mgr *mgr) +{ + struct pcxhr_rmh rmh; + + if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { + /* mute outputs */ + /* a read to IO_NUM_REG_MUTE_OUT register unmutes! */ + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); + rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; + pcxhr_send_msg(mgr, &rmh); + /* mute inputs */ + pcxhr_write_io_num_reg_cont(mgr, REG_CONT_UNMUTE_INPUTS, 0, NULL); + } + /* reset pcxhr dsp */ + if (mgr->dsp_loaded & ( 1 << PCXHR_FIRMWARE_DSP_EPRM_INDEX)) + pcxhr_reset_dsp(mgr); + /* reset second xilinx */ + if (mgr->dsp_loaded & ( 1 << PCXHR_FIRMWARE_XLX_COM_INDEX)) + pcxhr_reset_xilinx_com(mgr); + return; +} + + +/* + * allocate a playback/capture pipe (pcmp0/pcmc0) + */ +static int pcxhr_dsp_allocate_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe, + int is_capture, int pin) +{ + int stream_count, audio_count; + int err; + struct pcxhr_rmh rmh; + + if (is_capture) { + stream_count = 1; + if (mgr->mono_capture) + audio_count = 1; + else + audio_count = 2; + } else { + stream_count = PCXHR_PLAYBACK_STREAMS; + audio_count = 2; /* always stereo */ + } + snd_printdd("snd_add_ref_pipe pin(%d) pcm%c0\n", pin, is_capture ? 'c' : 'p'); + pipe->is_capture = is_capture; + pipe->first_audio = pin; + /* define pipe (P_PCM_ONLY_MASK (0x020000) is not necessary) */ + pcxhr_init_rmh(&rmh, CMD_RES_PIPE); + pcxhr_set_pipe_cmd_params(&rmh, is_capture, pin, audio_count, stream_count); + err = pcxhr_send_msg(mgr, &rmh); + if (err < 0) { + snd_printk(KERN_ERR "error pipe allocation (CMD_RES_PIPE) err=%x!\n", err ); + return err; + } + pipe->status = PCXHR_PIPE_DEFINED; + + return 0; +} + +/* + * free playback/capture pipe (pcmp0/pcmc0) + */ +#if 0 +static int pcxhr_dsp_free_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe) +{ + struct pcxhr_rmh rmh; + int capture_mask = 0; + int playback_mask = 0; + int err = 0; + + if (pipe->is_capture) + capture_mask = (1 << pipe->first_audio); + else + playback_mask = (1 << pipe->first_audio); + + /* stop one pipe */ + err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); + if (err < 0) + snd_printk(KERN_ERR "error stopping pipe!\n"); + /* release the pipe */ + pcxhr_init_rmh(&rmh, CMD_FREE_PIPE); + pcxhr_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->first_audio, 0, 0); + err = pcxhr_send_msg(mgr, &rmh); + if (err < 0) + snd_printk(KERN_ERR "error pipe release (CMD_FREE_PIPE) err(%x)\n", err); + pipe->status = PCXHR_PIPE_UNDEFINED; + return err; +} +#endif + + +static int pcxhr_config_pipes(struct pcxhr_mgr *mgr) +{ + int err, i, j; + struct snd_pcxhr *chip; + struct pcxhr_pipe *pipe; + + /* allocate the pipes on the dsp */ + for (i = 0; i < mgr->num_cards; i++) { + chip = mgr->chip[i]; + if (chip->nb_streams_play) { + pipe = &chip->playback_pipe; + err = pcxhr_dsp_allocate_pipe( mgr, pipe, 0, i*2); + if (err) + return err; + for(j = 0; j < chip->nb_streams_play; j++) + chip->playback_stream[j].pipe = pipe; + } + for (j = 0; j < chip->nb_streams_capt; j++) { + pipe = &chip->capture_pipe[j]; + err = pcxhr_dsp_allocate_pipe(mgr, pipe, 1, i*2 + j); + if (err) + return err; + chip->capture_stream[j].pipe = pipe; + } + } + return 0; +} + +static int pcxhr_start_pipes(struct pcxhr_mgr *mgr) +{ + int i, j; + struct snd_pcxhr *chip; + int playback_mask = 0; + int capture_mask = 0; + + /* start all the pipes on the dsp */ + for (i = 0; i < mgr->num_cards; i++) { + chip = mgr->chip[i]; + if (chip->nb_streams_play) + playback_mask |= (1 << chip->playback_pipe.first_audio); + for (j = 0; j < chip->nb_streams_capt; j++) + capture_mask |= (1 << chip->capture_pipe[j].first_audio); + } + return pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); +} + + +static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index, const struct firmware *dsp) +{ + int err, card_index; + + snd_printdd("loading dsp [%d] size = %Zd\n", index, dsp->size); + + switch (index) { + case PCXHR_FIRMWARE_XLX_INT_INDEX: + pcxhr_reset_xilinx_com(mgr); + return pcxhr_load_xilinx_binary(mgr, dsp, 0); + + case PCXHR_FIRMWARE_XLX_COM_INDEX: + pcxhr_reset_xilinx_com(mgr); + return pcxhr_load_xilinx_binary(mgr, dsp, 1); + + case PCXHR_FIRMWARE_DSP_EPRM_INDEX: + pcxhr_reset_dsp(mgr); + return pcxhr_load_eeprom_binary(mgr, dsp); + + case PCXHR_FIRMWARE_DSP_BOOT_INDEX: + return pcxhr_load_boot_binary(mgr, dsp); + + case PCXHR_FIRMWARE_DSP_MAIN_INDEX: + err = pcxhr_load_dsp_binary(mgr, dsp); + if (err) + return err; + break; /* continue with first init */ + default: + snd_printk(KERN_ERR "wrong file index\n"); + return -EFAULT; + } /* end of switch file index*/ + + /* first communication with embedded */ + err = pcxhr_init_board(mgr); + if (err < 0) { + snd_printk(KERN_ERR "pcxhr could not be set up\n"); + return err; + } + err = pcxhr_config_pipes(mgr); + if (err < 0) { + snd_printk(KERN_ERR "pcxhr pipes could not be set up\n"); + return err; + } + /* create devices and mixer in accordance with HW options*/ + for (card_index = 0; card_index < mgr->num_cards; card_index++) { + struct snd_pcxhr *chip = mgr->chip[card_index]; + + if ((err = pcxhr_create_pcm(chip)) < 0) + return err; + + if (card_index == 0) { + if ((err = pcxhr_create_mixer(chip->mgr)) < 0) + return err; + } + if ((err = snd_card_register(chip->card)) < 0) + return err; + } + err = pcxhr_start_pipes(mgr); + if (err < 0) { + snd_printk(KERN_ERR "pcxhr pipes could not be started\n"); + return err; + } + snd_printdd("pcxhr firmware downloaded and successfully set up\n"); + + return 0; +} + +/* + * fw loader entry + */ +#ifdef SND_PCXHR_FW_LOADER + +int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) +{ + static char *fw_files[5] = { + "xi_1_882.dat", + "xc_1_882.dat", + "e321_512.e56", + "b321_512.b56", + "d321_512.d56" + }; + char path[32]; + + const struct firmware *fw_entry; + int i, err; + + for (i = 0; i < ARRAY_SIZE(fw_files); i++) { + sprintf(path, "pcxhr/%s", fw_files[i]); + if (request_firmware(&fw_entry, path, &mgr->pci->dev)) { + snd_printk(KERN_ERR "pcxhr: can't load firmware %s\n", path); + return -ENOENT; + } + /* fake hwdep dsp record */ + err = pcxhr_dsp_load(mgr, i, fw_entry); + release_firmware(fw_entry); + if (err < 0) + return err; + mgr->dsp_loaded |= 1 << i; + } + return 0; +} + +#else /* old style firmware loading */ + +/* pcxhr hwdep interface id string */ +#define PCXHR_HWDEP_ID "pcxhr loader" + + +static int pcxhr_hwdep_dsp_status(struct snd_hwdep *hw, + struct snd_hwdep_dsp_status *info) +{ + strcpy(info->id, "pcxhr"); + info->num_dsps = PCXHR_FIRMWARE_FILES_MAX_INDEX; + + if (hw->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) + info->chip_ready = 1; + + info->version = PCXHR_DRIVER_VERSION; + return 0; +} + +static int pcxhr_hwdep_dsp_load(struct snd_hwdep *hw, + struct snd_hwdep_dsp_image *dsp) +{ + struct pcxhr_mgr *mgr = hw->private_data; + int err; + struct firmware fw; + + fw.size = dsp->length; + fw.data = vmalloc(fw.size); + if (! fw.data) { + snd_printk(KERN_ERR "pcxhr: cannot allocate dsp image (%d bytes)\n", + fw.size); + return -ENOMEM; + } + if (copy_from_user(fw.data, dsp->image, dsp->length)) { + vfree(fw.data); + return -EFAULT; + } + err = pcxhr_dsp_load(mgr, dsp->index, &fw); + vfree(fw.data); + if (err < 0) + return err; + mgr->dsp_loaded |= 1 << dsp->index; + return 0; +} + +static int pcxhr_hwdep_open(struct snd_hwdep *hw, struct file *file) +{ + return 0; +} + +static int pcxhr_hwdep_release(struct snd_hwdep *hw, struct file *file) +{ + return 0; +} + +int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) +{ + int err; + struct snd_hwdep *hw; + + /* only create hwdep interface for first cardX (see "index" module parameter)*/ + if ((err = snd_hwdep_new(mgr->chip[0]->card, PCXHR_HWDEP_ID, 0, &hw)) < 0) + return err; + + hw->iface = SNDRV_HWDEP_IFACE_PCXHR; + hw->private_data = mgr; + hw->ops.open = pcxhr_hwdep_open; + hw->ops.release = pcxhr_hwdep_release; + hw->ops.dsp_status = pcxhr_hwdep_dsp_status; + hw->ops.dsp_load = pcxhr_hwdep_dsp_load; + hw->exclusive = 1; + mgr->dsp_loaded = 0; + sprintf(hw->name, PCXHR_HWDEP_ID); + + if ((err = snd_card_register(mgr->chip[0]->card)) < 0) + return err; + return 0; +} + +#endif /* SND_PCXHR_FW_LOADER */ diff --git a/sound/pci/pcxhr/pcxhr_hwdep.h b/sound/pci/pcxhr/pcxhr_hwdep.h new file mode 100644 index 0000000..f561909 --- /dev/null +++ b/sound/pci/pcxhr/pcxhr_hwdep.h @@ -0,0 +1,40 @@ +/* + * Driver for Digigram pcxhr compatible soundcards + * + * definitions and makros for basic card access + * + * Copyright (c) 2004 by Digigram + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __SOUND_PCXHR_HWDEP_H +#define __SOUND_PCXHR_HWDEP_H + + +/* firmware status codes */ +#define PCXHR_FIRMWARE_XLX_INT_INDEX 0 +#define PCXHR_FIRMWARE_XLX_COM_INDEX 1 +#define PCXHR_FIRMWARE_DSP_EPRM_INDEX 2 +#define PCXHR_FIRMWARE_DSP_BOOT_INDEX 3 +#define PCXHR_FIRMWARE_DSP_MAIN_INDEX 4 +#define PCXHR_FIRMWARE_FILES_MAX_INDEX 5 + + +/* exported */ +int pcxhr_setup_firmware(struct pcxhr_mgr *mgr); +void pcxhr_reset_board(struct pcxhr_mgr *mgr); + +#endif /* __SOUND_PCXHR_HWDEP_H */ diff --git a/sound/pci/pcxhr/pcxhr_mixer.c b/sound/pci/pcxhr/pcxhr_mixer.c new file mode 100644 index 0000000..760e733 --- /dev/null +++ b/sound/pci/pcxhr/pcxhr_mixer.c @@ -0,0 +1,1020 @@ +#define __NO_VERSION__ +/* + * Driver for Digigram pcxhr compatible soundcards + * + * mixer callbacks + * + * Copyright (c) 2004 by Digigram + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include "pcxhr.h" +#include "pcxhr_hwdep.h" +#include "pcxhr_core.h" +#include +#include +#include "pcxhr_mixer.h" + + +#define PCXHR_ANALOG_CAPTURE_LEVEL_MIN 0 /* -96.0 dB */ +#define PCXHR_ANALOG_CAPTURE_LEVEL_MAX 255 /* +31.5 dB */ +#define PCXHR_ANALOG_CAPTURE_ZERO_LEVEL 224 /* +16.0 dB ( +31.5 dB - fix level +15.5 dB ) */ + +#define PCXHR_ANALOG_PLAYBACK_LEVEL_MIN 0 /* -128.0 dB */ +#define PCXHR_ANALOG_PLAYBACK_LEVEL_MAX 128 /* 0.0 dB */ +#define PCXHR_ANALOG_PLAYBACK_ZERO_LEVEL 104 /* -24.0 dB ( 0.0 dB - fix level +24.0 dB ) */ + +static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip, int is_capture, int channel) +{ + int err, vol; + struct pcxhr_rmh rmh; + + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); + if (is_capture) { + rmh.cmd[0] |= IO_NUM_REG_IN_ANA_LEVEL; + rmh.cmd[2] = chip->analog_capture_volume[channel]; + } else { + rmh.cmd[0] |= IO_NUM_REG_OUT_ANA_LEVEL; + if (chip->analog_playback_active[channel]) + vol = chip->analog_playback_volume[channel]; + else + vol = PCXHR_ANALOG_PLAYBACK_LEVEL_MIN; + rmh.cmd[2] = PCXHR_ANALOG_PLAYBACK_LEVEL_MAX - vol; /* playback analog levels are inversed */ + } + rmh.cmd[1] = 1 << ((2 * chip->chip_idx) + channel); /* audio mask */ + rmh.cmd_len = 3; + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err < 0) { + snd_printk(KERN_DEBUG "error update_analog_audio_level card(%d) " + "is_capture(%d) err(%x)\n", chip->chip_idx, is_capture, err); + return -EINVAL; + } + return 0; +} + +/* + * analog level control + */ +static int pcxhr_analog_vol_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 2; + if (kcontrol->private_value == 0) { /* playback */ + uinfo->value.integer.min = PCXHR_ANALOG_PLAYBACK_LEVEL_MIN; /* -128 dB */ + uinfo->value.integer.max = PCXHR_ANALOG_PLAYBACK_LEVEL_MAX; /* 0 dB */ + } else { /* capture */ + uinfo->value.integer.min = PCXHR_ANALOG_CAPTURE_LEVEL_MIN; /* -96 dB */ + uinfo->value.integer.max = PCXHR_ANALOG_CAPTURE_LEVEL_MAX; /* 31.5 dB */ + } + return 0; +} + +static int pcxhr_analog_vol_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + down(&chip->mgr->mixer_mutex); + if (kcontrol->private_value == 0) { /* playback */ + ucontrol->value.integer.value[0] = chip->analog_playback_volume[0]; + ucontrol->value.integer.value[1] = chip->analog_playback_volume[1]; + } else { /* capture */ + ucontrol->value.integer.value[0] = chip->analog_capture_volume[0]; + ucontrol->value.integer.value[1] = chip->analog_capture_volume[1]; + } + up(&chip->mgr->mixer_mutex); + return 0; +} + +static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int changed = 0; + int is_capture, i; + + down(&chip->mgr->mixer_mutex); + is_capture = (kcontrol->private_value != 0); + for (i = 0; i < 2; i++) { + int new_volume = ucontrol->value.integer.value[i]; + int* stored_volume = is_capture ? &chip->analog_capture_volume[i] : + &chip->analog_playback_volume[i]; + if (*stored_volume != new_volume) { + *stored_volume = new_volume; + changed = 1; + pcxhr_update_analog_audio_level(chip, is_capture, i); + } + } + up(&chip->mgr->mixer_mutex); + return changed; +} + +static struct snd_kcontrol_new pcxhr_control_analog_level = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* name will be filled later */ + .info = pcxhr_analog_vol_info, + .get = pcxhr_analog_vol_get, + .put = pcxhr_analog_vol_put, +}; + +/* shared */ +static int pcxhr_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; + uinfo->count = 2; + uinfo->value.integer.min = 0; + uinfo->value.integer.max = 1; + return 0; +} + +static int pcxhr_audio_sw_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + + down(&chip->mgr->mixer_mutex); + ucontrol->value.integer.value[0] = chip->analog_playback_active[0]; + ucontrol->value.integer.value[1] = chip->analog_playback_active[1]; + up(&chip->mgr->mixer_mutex); + return 0; +} + +static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int i, changed = 0; + down(&chip->mgr->mixer_mutex); + for(i = 0; i < 2; i++) { + if (chip->analog_playback_active[i] != ucontrol->value.integer.value[i]) { + chip->analog_playback_active[i] = ucontrol->value.integer.value[i]; + changed = 1; + pcxhr_update_analog_audio_level(chip, 0, i); /* update playback levels */ + } + } + up(&chip->mgr->mixer_mutex); + return changed; +} + +static struct snd_kcontrol_new pcxhr_control_output_switch = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Master Playback Switch", + .info = pcxhr_sw_info, /* shared */ + .get = pcxhr_audio_sw_get, + .put = pcxhr_audio_sw_put +}; + + +#define PCXHR_DIGITAL_LEVEL_MIN 0x000 /* -110 dB */ +#define PCXHR_DIGITAL_LEVEL_MAX 0x1ff /* +18 dB */ +#define PCXHR_DIGITAL_ZERO_LEVEL 0x1b7 /* 0 dB */ + + +#define MORE_THAN_ONE_STREAM_LEVEL 0x000001 +#define VALID_STREAM_PAN_LEVEL_MASK 0x800000 +#define VALID_STREAM_LEVEL_MASK 0x400000 +#define VALID_STREAM_LEVEL_1_MASK 0x200000 +#define VALID_STREAM_LEVEL_2_MASK 0x100000 + +static int pcxhr_update_playback_stream_level(struct snd_pcxhr* chip, int idx) +{ + int err; + struct pcxhr_rmh rmh; + struct pcxhr_pipe *pipe = &chip->playback_pipe; + int left, right; + + if (chip->digital_playback_active[idx][0]) + left = chip->digital_playback_volume[idx][0]; + else + left = PCXHR_DIGITAL_LEVEL_MIN; + if (chip->digital_playback_active[idx][1]) + right = chip->digital_playback_volume[idx][1]; + else + right = PCXHR_DIGITAL_LEVEL_MIN; + + pcxhr_init_rmh(&rmh, CMD_STREAM_OUT_LEVEL_ADJUST); + /* add pipe and stream mask */ + pcxhr_set_pipe_cmd_params(&rmh, 0, pipe->first_audio, 0, 1<left / right->right panoramic level */ + rmh.cmd[0] |= MORE_THAN_ONE_STREAM_LEVEL; + rmh.cmd[2] = VALID_STREAM_PAN_LEVEL_MASK | VALID_STREAM_LEVEL_1_MASK; + rmh.cmd[2] |= (left << 10); + rmh.cmd[3] = VALID_STREAM_PAN_LEVEL_MASK | VALID_STREAM_LEVEL_2_MASK; + rmh.cmd[3] |= right; + rmh.cmd_len = 4; + + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err < 0) { + snd_printk(KERN_DEBUG "error update_playback_stream_level " + "card(%d) err(%x)\n", chip->chip_idx, err); + return -EINVAL; + } + return 0; +} + +#define AUDIO_IO_HAS_MUTE_LEVEL 0x400000 +#define AUDIO_IO_HAS_MUTE_MONITOR_1 0x200000 +#define VALID_AUDIO_IO_DIGITAL_LEVEL 0x000001 +#define VALID_AUDIO_IO_MONITOR_LEVEL 0x000002 +#define VALID_AUDIO_IO_MUTE_LEVEL 0x000004 +#define VALID_AUDIO_IO_MUTE_MONITOR_1 0x000008 + +static int pcxhr_update_audio_pipe_level(struct snd_pcxhr* chip, int capture, int channel) +{ + int err; + struct pcxhr_rmh rmh; + struct pcxhr_pipe *pipe; + + if (capture) + pipe = &chip->capture_pipe[0]; + else + pipe = &chip->playback_pipe; + + pcxhr_init_rmh(&rmh, CMD_AUDIO_LEVEL_ADJUST); + /* add channel mask */ + pcxhr_set_pipe_cmd_params(&rmh, capture, 0, 0, 1 << (channel + pipe->first_audio)); + /* TODO : if mask (3 << pipe->first_audio) is used, left and right channel + * will be programmed to the same params + */ + if (capture) { + rmh.cmd[0] |= VALID_AUDIO_IO_DIGITAL_LEVEL; + /* VALID_AUDIO_IO_MUTE_LEVEL not yet handled (capture pipe level) */ + rmh.cmd[2] = chip->digital_capture_volume[channel]; + } else { + rmh.cmd[0] |= VALID_AUDIO_IO_MONITOR_LEVEL | VALID_AUDIO_IO_MUTE_MONITOR_1; + /* VALID_AUDIO_IO_DIGITAL_LEVEL and VALID_AUDIO_IO_MUTE_LEVEL not yet + * handled (playback pipe level) + */ + rmh.cmd[2] = chip->monitoring_volume[channel] << 10; + if (chip->monitoring_active[channel] == 0) + rmh.cmd[2] |= AUDIO_IO_HAS_MUTE_MONITOR_1; + } + rmh.cmd_len = 3; + + err = pcxhr_send_msg(chip->mgr, &rmh); + if(err<0) { + snd_printk(KERN_DEBUG "error update_audio_level card(%d) err(%x)\n", + chip->chip_idx, err); + return -EINVAL; + } + return 0; +} + + +/* shared */ +static int pcxhr_digital_vol_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 2; + uinfo->value.integer.min = PCXHR_DIGITAL_LEVEL_MIN; /* -109.5 dB */ + uinfo->value.integer.max = PCXHR_DIGITAL_LEVEL_MAX; /* 18.0 dB */ + return 0; +} + + +static int pcxhr_pcm_vol_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ + int *stored_volume; + int is_capture = kcontrol->private_value; + + down(&chip->mgr->mixer_mutex); + if (is_capture) + stored_volume = chip->digital_capture_volume; /* digital capture */ + else + stored_volume = chip->digital_playback_volume[idx]; /* digital playback */ + ucontrol->value.integer.value[0] = stored_volume[0]; + ucontrol->value.integer.value[1] = stored_volume[1]; + up(&chip->mgr->mixer_mutex); + return 0; +} + +static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ + int changed = 0; + int is_capture = kcontrol->private_value; + int *stored_volume; + int i; + + down(&chip->mgr->mixer_mutex); + if (is_capture) + stored_volume = chip->digital_capture_volume; /* digital capture */ + else + stored_volume = chip->digital_playback_volume[idx]; /* digital playback */ + for (i = 0; i < 2; i++) { + if (stored_volume[i] != ucontrol->value.integer.value[i]) { + stored_volume[i] = ucontrol->value.integer.value[i]; + changed = 1; + if (is_capture) /* update capture volume */ + pcxhr_update_audio_pipe_level(chip, 1, i); + } + } + if (! is_capture && changed) + pcxhr_update_playback_stream_level(chip, idx); /* update playback volume */ + up(&chip->mgr->mixer_mutex); + return changed; +} + +static struct snd_kcontrol_new snd_pcxhr_pcm_vol = +{ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + /* name will be filled later */ + /* count will be filled later */ + .info = pcxhr_digital_vol_info, /* shared */ + .get = pcxhr_pcm_vol_get, + .put = pcxhr_pcm_vol_put, +}; + + +static int pcxhr_pcm_sw_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ + + down(&chip->mgr->mixer_mutex); + ucontrol->value.integer.value[0] = chip->digital_playback_active[idx][0]; + ucontrol->value.integer.value[1] = chip->digital_playback_active[idx][1]; + up(&chip->mgr->mixer_mutex); + return 0; +} + +static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int changed = 0; + int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ + int i, j; + + down(&chip->mgr->mixer_mutex); + j = idx; + for (i = 0; i < 2; i++) { + if (chip->digital_playback_active[j][i] != ucontrol->value.integer.value[i]) { + chip->digital_playback_active[j][i] = ucontrol->value.integer.value[i]; + changed = 1; + } + } + if (changed) + pcxhr_update_playback_stream_level(chip, idx); + up(&chip->mgr->mixer_mutex); + return changed; +} + +static struct snd_kcontrol_new pcxhr_control_pcm_switch = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "PCM Playback Switch", + .count = PCXHR_PLAYBACK_STREAMS, + .info = pcxhr_sw_info, /* shared */ + .get = pcxhr_pcm_sw_get, + .put = pcxhr_pcm_sw_put +}; + + +/* + * monitoring level control + */ + +static int pcxhr_monitor_vol_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + down(&chip->mgr->mixer_mutex); + ucontrol->value.integer.value[0] = chip->monitoring_volume[0]; + ucontrol->value.integer.value[1] = chip->monitoring_volume[1]; + up(&chip->mgr->mixer_mutex); + return 0; +} + +static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int changed = 0; + int i; + + down(&chip->mgr->mixer_mutex); + for (i = 0; i < 2; i++) { + if (chip->monitoring_volume[i] != ucontrol->value.integer.value[i]) { + chip->monitoring_volume[i] = ucontrol->value.integer.value[i]; + if(chip->monitoring_active[i]) /* do only when monitoring is unmuted */ + /* update monitoring volume and mute */ + pcxhr_update_audio_pipe_level(chip, 0, i); + changed = 1; + } + } + up(&chip->mgr->mixer_mutex); + return changed; +} + +static struct snd_kcontrol_new pcxhr_control_monitor_vol = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Monitoring Volume", + .info = pcxhr_digital_vol_info, /* shared */ + .get = pcxhr_monitor_vol_get, + .put = pcxhr_monitor_vol_put, +}; + +/* + * monitoring switch control + */ + +static int pcxhr_monitor_sw_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + down(&chip->mgr->mixer_mutex); + ucontrol->value.integer.value[0] = chip->monitoring_active[0]; + ucontrol->value.integer.value[1] = chip->monitoring_active[1]; + up(&chip->mgr->mixer_mutex); + return 0; +} + +static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int changed = 0; + int i; + + down(&chip->mgr->mixer_mutex); + for (i = 0; i < 2; i++) { + if (chip->monitoring_active[i] != ucontrol->value.integer.value[i]) { + chip->monitoring_active[i] = ucontrol->value.integer.value[i]; + changed |= (1<mgr->mixer_mutex); + return (changed != 0); +} + +static struct snd_kcontrol_new pcxhr_control_monitor_sw = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Monitoring Switch", + .info = pcxhr_sw_info, /* shared */ + .get = pcxhr_monitor_sw_get, + .put = pcxhr_monitor_sw_put +}; + + + +/* + * audio source select + */ +#define PCXHR_SOURCE_AUDIO01_UER 0x000100 +#define PCXHR_SOURCE_AUDIO01_SYNC 0x000200 +#define PCXHR_SOURCE_AUDIO23_UER 0x000400 +#define PCXHR_SOURCE_AUDIO45_UER 0x001000 +#define PCXHR_SOURCE_AUDIO67_UER 0x040000 + +static int pcxhr_set_audio_source(struct snd_pcxhr* chip) +{ + struct pcxhr_rmh rmh; + unsigned int mask, reg; + unsigned int codec; + int err, use_src, changed; + + switch (chip->chip_idx) { + case 0 : mask = PCXHR_SOURCE_AUDIO01_UER; codec = CS8420_01_CS; break; + case 1 : mask = PCXHR_SOURCE_AUDIO23_UER; codec = CS8420_23_CS; break; + case 2 : mask = PCXHR_SOURCE_AUDIO45_UER; codec = CS8420_45_CS; break; + case 3 : mask = PCXHR_SOURCE_AUDIO67_UER; codec = CS8420_67_CS; break; + default: return -EINVAL; + } + reg = 0; /* audio source from analog plug */ + use_src = 0; /* do not activate codec SRC */ + + if (chip->audio_capture_source != 0) { + reg = mask; /* audio source from digital plug */ + if (chip->audio_capture_source == 2) + use_src = 1; + } + /* set the input source */ + pcxhr_write_io_num_reg_cont(chip->mgr, mask, reg, &changed); + /* resync them (otherwise channel inversion possible) */ + if (changed) { + pcxhr_init_rmh(&rmh, CMD_RESYNC_AUDIO_INPUTS); + rmh.cmd[0] |= (1 << chip->chip_idx); + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err) + return err; + } + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); /* set codec SRC on off */ + rmh.cmd_len = 3; + rmh.cmd[0] |= IO_NUM_UER_CHIP_REG; + rmh.cmd[1] = codec; + rmh.cmd[2] = (CS8420_DATA_FLOW_CTL & CHIP_SIG_AND_MAP_SPI) | (use_src ? 0x41 : 0x54); + err = pcxhr_send_msg(chip->mgr, &rmh); + if(err) + return err; + rmh.cmd[2] = (CS8420_CLOCK_SRC_CTL & CHIP_SIG_AND_MAP_SPI) | (use_src ? 0x41 : 0x49); + err = pcxhr_send_msg(chip->mgr, &rmh); + return err; +} + +static int pcxhr_audio_src_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static char *texts[3] = {"Analog", "Digital", "Digi+SRC"}; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = 3; + if (uinfo->value.enumerated.item > 2) + uinfo->value.enumerated.item = 2; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + return 0; +} + +static int pcxhr_audio_src_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + ucontrol->value.enumerated.item[0] = chip->audio_capture_source; + return 0; +} + +static int pcxhr_audio_src_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int ret = 0; + + down(&chip->mgr->mixer_mutex); + if (chip->audio_capture_source != ucontrol->value.enumerated.item[0]) { + chip->audio_capture_source = ucontrol->value.enumerated.item[0]; + pcxhr_set_audio_source(chip); + ret = 1; + } + up(&chip->mgr->mixer_mutex); + return ret; +} + +static struct snd_kcontrol_new pcxhr_control_audio_src = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Capture Source", + .info = pcxhr_audio_src_info, + .get = pcxhr_audio_src_get, + .put = pcxhr_audio_src_put, +}; + + +/* + * clock type selection + * enum pcxhr_clock_type { + * PCXHR_CLOCK_TYPE_INTERNAL = 0, + * PCXHR_CLOCK_TYPE_WORD_CLOCK, + * PCXHR_CLOCK_TYPE_AES_SYNC, + * PCXHR_CLOCK_TYPE_AES_1, + * PCXHR_CLOCK_TYPE_AES_2, + * PCXHR_CLOCK_TYPE_AES_3, + * PCXHR_CLOCK_TYPE_AES_4, + * }; + */ + +static int pcxhr_clock_type_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + static char *texts[7] = { + "Internal", "WordClock", "AES Sync", "AES 1", "AES 2", "AES 3", "AES 4" + }; + struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); + int clock_items = 3 + mgr->capture_chips; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; + uinfo->count = 1; + uinfo->value.enumerated.items = clock_items; + if (uinfo->value.enumerated.item >= clock_items) + uinfo->value.enumerated.item = clock_items-1; + strcpy(uinfo->value.enumerated.name, + texts[uinfo->value.enumerated.item]); + return 0; +} + +static int pcxhr_clock_type_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); + ucontrol->value.enumerated.item[0] = mgr->use_clock_type; + return 0; +} + +static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); + int rate, ret = 0; + + down(&mgr->mixer_mutex); + if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) { + down(&mgr->setup_mutex); + mgr->use_clock_type = ucontrol->value.enumerated.item[0]; + if (mgr->use_clock_type) + pcxhr_get_external_clock(mgr, mgr->use_clock_type, &rate); + else + rate = mgr->sample_rate; + if (rate) { + pcxhr_set_clock(mgr, rate); + if (mgr->sample_rate) + mgr->sample_rate = rate; + } + up(&mgr->setup_mutex); + ret = 1; /* return 1 even if the set was not done. ok ? */ + } + up(&mgr->mixer_mutex); + return ret; +} + +static struct snd_kcontrol_new pcxhr_control_clock_type = { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "Clock Mode", + .info = pcxhr_clock_type_info, + .get = pcxhr_clock_type_get, + .put = pcxhr_clock_type_put, +}; + +/* + * clock rate control + * specific control that scans the sample rates on the external plugs + */ +static int pcxhr_clock_rate_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = 3 + mgr->capture_chips; + uinfo->value.integer.min = 0; /* clock not present */ + uinfo->value.integer.max = 192000; /* max sample rate 192 kHz */ + return 0; +} + +static int pcxhr_clock_rate_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); + int i, err, rate; + + down(&mgr->mixer_mutex); + for(i = 0; i < 3 + mgr->capture_chips; i++) { + if (i == PCXHR_CLOCK_TYPE_INTERNAL) + rate = mgr->sample_rate_real; + else { + err = pcxhr_get_external_clock(mgr, i, &rate); + if (err) + break; + } + ucontrol->value.integer.value[i] = rate; + } + up(&mgr->mixer_mutex); + return 0; +} + +static struct snd_kcontrol_new pcxhr_control_clock_rate = { + .access = SNDRV_CTL_ELEM_ACCESS_READ, + .iface = SNDRV_CTL_ELEM_IFACE_CARD, + .name = "Clock Rates", + .info = pcxhr_clock_rate_info, + .get = pcxhr_clock_rate_get, +}; + +/* + * IEC958 status bits + */ +static int pcxhr_iec958_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; + uinfo->count = 1; + return 0; +} + +static int pcxhr_iec958_capture_byte(struct snd_pcxhr *chip, int aes_idx, unsigned char* aes_bits) +{ + int i, err; + unsigned char temp; + struct pcxhr_rmh rmh; + + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); + rmh.cmd[0] |= IO_NUM_UER_CHIP_REG; + switch (chip->chip_idx) { + case 0: rmh.cmd[1] = CS8420_01_CS; break; /* use CS8416_01_CS for AES SYNC plug */ + case 1: rmh.cmd[1] = CS8420_23_CS; break; + case 2: rmh.cmd[1] = CS8420_45_CS; break; + case 3: rmh.cmd[1] = CS8420_67_CS; break; + default: return -EINVAL; + } + switch (aes_idx) { + case 0: rmh.cmd[2] = CS8420_CSB0; break; /* use CS8416_CSBx for AES SYNC plug */ + case 1: rmh.cmd[2] = CS8420_CSB1; break; + case 2: rmh.cmd[2] = CS8420_CSB2; break; + case 3: rmh.cmd[2] = CS8420_CSB3; break; + case 4: rmh.cmd[2] = CS8420_CSB4; break; + default: return -EINVAL; + } + rmh.cmd[1] &= 0x0fffff; /* size and code the chip id for the fpga */ + rmh.cmd[2] &= CHIP_SIG_AND_MAP_SPI; /* chip signature + map for spi read */ + rmh.cmd_len = 3; + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err) + return err; + temp = 0; + for (i = 0; i < 8; i++) { + /* attention : reversed bit order (not with CS8416_01_CS) */ + temp <<= 1; + if (rmh.stat[1] & (1 << i)) + temp |= 1; + } + snd_printdd("read iec958 AES %d byte %d = 0x%x\n", chip->chip_idx, aes_idx, temp); + *aes_bits = temp; + return 0; +} + +static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + unsigned char aes_bits; + int i, err; + + down(&chip->mgr->mixer_mutex); + for(i = 0; i < 5; i++) { + if (kcontrol->private_value == 0) /* playback */ + aes_bits = chip->aes_bits[i]; + else { /* capture */ + err = pcxhr_iec958_capture_byte(chip, i, &aes_bits); + if (err) + break; + } + ucontrol->value.iec958.status[i] = aes_bits; + } + up(&chip->mgr->mixer_mutex); + return 0; +} + +static int pcxhr_iec958_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int i; + for (i = 0; i < 5; i++) + ucontrol->value.iec958.status[i] = 0xff; + return 0; +} + +static int pcxhr_iec958_update_byte(struct snd_pcxhr *chip, int aes_idx, unsigned char aes_bits) +{ + int i, err, cmd; + unsigned char new_bits = aes_bits; + unsigned char old_bits = chip->aes_bits[aes_idx]; + struct pcxhr_rmh rmh; + + for (i = 0; i < 8; i++) { + if ((old_bits & 0x01) != (new_bits & 0x01)) { + cmd = chip->chip_idx & 0x03; /* chip index 0..3 */ + if(chip->chip_idx > 3) + /* new bit used if chip_idx>3 (PCX1222HR) */ + cmd |= 1 << 22; + cmd |= ((aes_idx << 3) + i) << 2; /* add bit offset */ + cmd |= (new_bits & 0x01) << 23; /* add bit value */ + pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); + rmh.cmd[0] |= IO_NUM_REG_CUER; + rmh.cmd[1] = cmd; + rmh.cmd_len = 2; + snd_printdd("write iec958 AES %d byte %d bit %d (cmd %x)\n", + chip->chip_idx, aes_idx, i, cmd); + err = pcxhr_send_msg(chip->mgr, &rmh); + if (err) + return err; + } + old_bits >>= 1; + new_bits >>= 1; + } + chip->aes_bits[aes_idx] = aes_bits; + return 0; +} + +static int pcxhr_iec958_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); + int i, changed = 0; + + /* playback */ + down(&chip->mgr->mixer_mutex); + for (i = 0; i < 5; i++) { + if (ucontrol->value.iec958.status[i] != chip->aes_bits[i]) { + pcxhr_iec958_update_byte(chip, i, ucontrol->value.iec958.status[i]); + changed = 1; + } + } + up(&chip->mgr->mixer_mutex); + return changed; +} + +static struct snd_kcontrol_new pcxhr_control_playback_iec958_mask = { + .access = SNDRV_CTL_ELEM_ACCESS_READ, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), + .info = pcxhr_iec958_info, + .get = pcxhr_iec958_mask_get +}; +static struct snd_kcontrol_new pcxhr_control_playback_iec958 = { + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), + .info = pcxhr_iec958_info, + .get = pcxhr_iec958_get, + .put = pcxhr_iec958_put, + .private_value = 0 /* playback */ +}; + +static struct snd_kcontrol_new pcxhr_control_capture_iec958_mask = { + .access = SNDRV_CTL_ELEM_ACCESS_READ, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,MASK), + .info = pcxhr_iec958_info, + .get = pcxhr_iec958_mask_get +}; +static struct snd_kcontrol_new pcxhr_control_capture_iec958 = { + .access = SNDRV_CTL_ELEM_ACCESS_READ, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT), + .info = pcxhr_iec958_info, + .get = pcxhr_iec958_get, + .private_value = 1 /* capture */ +}; + +static void pcxhr_init_audio_levels(struct snd_pcxhr *chip) +{ + int i; + + for (i = 0; i < 2; i++) { + if (chip->nb_streams_play) { + int j; + /* at boot time the digital volumes are unmuted 0dB */ + for (j = 0; j < PCXHR_PLAYBACK_STREAMS; j++) { + chip->digital_playback_active[j][i] = 1; + chip->digital_playback_volume[j][i] = PCXHR_DIGITAL_ZERO_LEVEL; + } + /* after boot, only two bits are set on the uer interface */ + chip->aes_bits[0] = IEC958_AES0_PROFESSIONAL | IEC958_AES0_PRO_FS_48000; +/* only for test purpose, remove later */ +#ifdef CONFIG_SND_DEBUG + /* analog volumes for playback (is LEVEL_MIN after boot) */ + chip->analog_playback_active[i] = 1; + chip->analog_playback_volume[i] = PCXHR_ANALOG_PLAYBACK_ZERO_LEVEL; + pcxhr_update_analog_audio_level(chip, 0, i); +#endif +/* test end */ + } + if (chip->nb_streams_capt) { + /* at boot time the digital volumes are unmuted 0dB */ + chip->digital_capture_volume[i] = PCXHR_DIGITAL_ZERO_LEVEL; +/* only for test purpose, remove later */ +#ifdef CONFIG_SND_DEBUG + /* analog volumes for playback (is LEVEL_MIN after boot) */ + chip->analog_capture_volume[i] = PCXHR_ANALOG_CAPTURE_ZERO_LEVEL; + pcxhr_update_analog_audio_level(chip, 1, i); +#endif +/* test end */ + } + } + + return; +} + + +int pcxhr_create_mixer(struct pcxhr_mgr *mgr) +{ + struct snd_pcxhr *chip; + int err, i; + + init_MUTEX(&mgr->mixer_mutex); /* can be in another place */ + + for (i = 0; i < mgr->num_cards; i++) { + struct snd_kcontrol_new temp; + chip = mgr->chip[i]; + + if (chip->nb_streams_play) { + /* analog output level control */ + temp = pcxhr_control_analog_level; + temp.name = "Master Playback Volume"; + temp.private_value = 0; /* playback */ + if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0) + return err; + /* output mute controls */ + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_output_switch, + chip))) < 0) + return err; + + temp = snd_pcxhr_pcm_vol; + temp.name = "PCM Playback Volume"; + temp.count = PCXHR_PLAYBACK_STREAMS; + temp.private_value = 0; /* playback */ + if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0) + return err; + + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_pcm_switch, + chip))) < 0) + return err; + + /* IEC958 controls */ + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_playback_iec958_mask, + chip))) < 0) + return err; + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_playback_iec958, + chip))) < 0) + return err; + } + if (chip->nb_streams_capt) { + /* analog input level control only on first two chips !*/ + temp = pcxhr_control_analog_level; + temp.name = "Master Capture Volume"; + temp.private_value = 1; /* capture */ + if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0) + return err; + + temp = snd_pcxhr_pcm_vol; + temp.name = "PCM Capture Volume"; + temp.count = 1; + temp.private_value = 1; /* capture */ + if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0) + return err; + /* Audio source */ + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_audio_src, + chip))) < 0) + return err; + /* IEC958 controls */ + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_capture_iec958_mask, + chip))) < 0) + return err; + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_capture_iec958, + chip))) < 0) + return err; + } + /* monitoring only if playback and capture device available */ + if (chip->nb_streams_capt > 0 && chip->nb_streams_play > 0) { + /* monitoring */ + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_monitor_vol, + chip))) < 0) + return err; + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_monitor_sw, + chip))) < 0) + return err; + } + + if (i == 0) { + /* clock mode only one control per pcxhr */ + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_clock_type, + mgr))) < 0) + return err; + /* non standard control used to scan the external clock presence/frequencies */ + if ((err = snd_ctl_add(chip->card, + snd_ctl_new1(&pcxhr_control_clock_rate, + mgr))) < 0) + return err; + } + + /* init values for the mixer data */ + pcxhr_init_audio_levels(chip); + } + + return 0; +} diff --git a/sound/pci/pcxhr/pcxhr_mixer.h b/sound/pci/pcxhr/pcxhr_mixer.h new file mode 100644 index 0000000..4348d0e --- /dev/null +++ b/sound/pci/pcxhr/pcxhr_mixer.h @@ -0,0 +1,29 @@ +/* + * Driver for Digigram pcxhr compatible soundcards + * + * include file for mixer + * + * Copyright (c) 2004 by Digigram + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __SOUND_PCXHR_MIXER_H +#define __SOUND_PCXHR_MIXER_H + +/* exported */ +int pcxhr_create_mixer(struct pcxhr_mgr *mgr); + +#endif /* __SOUND_PCXHR_MIXER_H */ -- cgit v1.1 From a0faefedf7d81b6ead6a33e5576a6439606d7ed5 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Tue, 6 Dec 2005 13:59:12 +0100 Subject: [ALSA] Add a new quirk for mute-LED and HP-only. Modules: AC97 Codec,ATIIXP driver,Intel8x0 driver This patch adds a new quirk for ac97 hardware that combines the existing AC97_TUNE_MUTE_LED and AC97_TUNE_HP_ONLY quirks. This is needed for several current HP laptops. Additionally, it adds the HP nx6125 to the AC97_TUNE_MUTE_LED list. Fixed for the latest version of ALSA by Takashi Iwai . Signed-off-by: Matthew Garrett Signed-off-by: Takashi Iwai --- include/sound/ac97_codec.h | 1 + sound/pci/ac97/ac97_codec.c | 36 ++++++++++++++++++++++++++++++++++++ sound/pci/atiixp.c | 6 ++++++ sound/pci/intel8x0.c | 24 ++++++++++++++++++++++++ 4 files changed, 67 insertions(+) diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h index a1814cd..b0b3ea7 100644 --- a/include/sound/ac97_codec.h +++ b/include/sound/ac97_codec.h @@ -541,6 +541,7 @@ enum { AC97_TUNE_ALC_JACK, /* for Realtek, enable JACK detection */ AC97_TUNE_INV_EAPD, /* inverted EAPD implementation */ AC97_TUNE_MUTE_LED, /* EAPD bit works as mute LED */ + AC97_TUNE_HP_MUTE_LED, /* EAPD bit works as mute LED, use headphone control as master */ }; struct ac97_quirk { diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 33d7a1f..3020ca2 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -2457,6 +2457,41 @@ static int tune_mute_led(struct snd_ac97 *ac97) return 0; } +static int hp_master_mute_sw_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int err = bind_hp_volsw_put(kcontrol, ucontrol); + if (err > 0) { + struct snd_ac97 *ac97 = snd_kcontrol_chip(kcontrol); + int shift = (kcontrol->private_value >> 8) & 0x0f; + int rshift = (kcontrol->private_value >> 12) & 0x0f; + unsigned short mask; + if (shift != rshift) + mask = 0x8080; + else + mask = 0x8000; + snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000, + (ac97->regs[AC97_MASTER] & mask) == mask ? + 0x8000 : 0); + } + return err; +} + +static int tune_hp_mute_led(struct snd_ac97 *ac97) +{ + struct snd_kcontrol *msw = ctl_find(ac97, "Master Playback Switch", NULL); + struct snd_kcontrol *mvol = ctl_find(ac97, "Master Playback Volume", NULL); + if (! msw || ! mvol) + return -ENOENT; + msw->put = hp_master_mute_sw_put; + mvol->put = bind_hp_volsw_put; + snd_ac97_remove_ctl(ac97, "External Amplifier", NULL); + snd_ac97_remove_ctl(ac97, "Headphone Playback", "Switch"); + snd_ac97_remove_ctl(ac97, "Headphone Playback", "Volume"); + snd_ac97_update_bits(ac97, AC97_POWERDOWN, 0x8000, 0x8000); /* mute LED on */ + return 0; +} + struct quirk_table { const char *name; int (*func)(struct snd_ac97 *); @@ -2471,6 +2506,7 @@ static struct quirk_table applicable_quirks[] = { { "alc_jack", tune_alc_jack }, { "inv_eapd", tune_inv_eapd }, { "mute_led", tune_mute_led }, + { "hp_mute_led", tune_hp_mute_led }, }; /* apply the quirk with the given type */ diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 33e0664..b7217ad 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -1353,6 +1353,12 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { .name = "HP Pavilion ZV5030US", .type = AC97_TUNE_MUTE_LED }, + { + .subvendor = 0x103c, + .subdevice = 0x308b, + .name = "HP nx6125", + .type = AC97_TUNE_MUTE_LED + }, { } /* terminator */ }; diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index d3a4e5e..5466b1f 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -1859,6 +1859,30 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = { }, { .subvendor = 0x103c, + .subdevice = 0x0938, + .name = "HP nc4200", + .type = AC97_TUNE_HP_MUTE_LED + }, + { + .subvendor = 0x103c, + .subdevice = 0x099c, + .name = "HP nc6120", + .type = AC97_TUNE_HP_MUTE_LED + }, + { + .subvendor = 0x103c, + .subdevice = 0x0944, + .name = "HP nc6220", + .type = AC97_TUNE_HP_MUTE_LED + }, + { + .subvendor = 0x103c, + .subdevice = 0x0934, + .name = "HP nc8220", + .type = AC97_TUNE_HP_MUTE_LED + }, + { + .subvendor = 0x103c, .subdevice = 0x12f1, .name = "HP xw8200", /* AD1981B*/ .type = AC97_TUNE_HP_ONLY -- cgit v1.1 From a8ee72952bd7bd21df944ef1512a1e582abe0528 Mon Sep 17 00:00:00 2001 From: Gergely Tamas Date: Tue, 6 Dec 2005 14:10:57 +0100 Subject: [ALSA] emu10k1 - Add entry for SB Live 5.1 Digital OEM [SB0220] Modules: EMU10K1/EMU10K2 driver Added the chip-detail entry for SB Live 5.1 Digital OEM [SB0220, (c) 2003]. Signed-off-by: Gergely Tamas Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/emu10k1_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index f6cf589..f8e2ccd 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -883,6 +883,12 @@ static struct snd_emu_chip_details emu_chip_details[] = { .emu10k1_chip = 1, .ac97_chip = 1, .sblive51 = 1} , + {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102, + .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", + .id = "Live", + .emu10k1_chip = 1, + .ac97_chip = 1, + .sblive51 = 1} , {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, .driver = "EMU10K1", .name = "SB Live 5.1", .id = "Live", -- cgit v1.1 From c5f2ea08fbd8911e2c975094780d2b16e65f27e0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 6 Dec 2005 18:54:31 +0100 Subject: [ALSA] hda-codec - Fix ALC codec probing Modules: HDA Codec driver - Fix ALC882 BIOS auto-probe - Fix ALC262 basic model - Add assert for debugging Oops Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index a98c0e4..63aeddb 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1259,6 +1259,8 @@ static int alc_build_pcms(struct hda_codec *codec) codec->num_pcms = 1; codec->pcm_info = info; + snd_assert(spec->stream_analog_playback, return -EINVAL); + snd_assert(spec->stream_analog_capture, return -EINVAL); info->name = spec->stream_name_analog; info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; @@ -1277,10 +1279,12 @@ static int alc_build_pcms(struct hda_codec *codec) info++; info->name = spec->stream_name_digital; if (spec->multiout.dig_out_nid) { + snd_assert(spec->stream_digital_playback, return -EINVAL); info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; } if (spec->dig_in_nid) { + snd_assert(spec->stream_digital_capture, return -EINVAL); info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; } @@ -3508,9 +3512,10 @@ static int alc882_parse_auto_config(struct hda_codec *codec) if (err < 0) return err; - /* hack - override the init verbs */ - spec->init_verbs[0] = alc882_auto_init_verbs; - return 0; + else if (err > 0) + /* hack - override the init verbs */ + spec->init_verbs[0] = alc882_auto_init_verbs; + return err; } /* init callback for auto-configuration model -- overriding the default init */ @@ -3605,6 +3610,7 @@ static int patch_alc882(struct hda_codec *codec) #define alc262_adc_nids_alt alc882_adc_nids_alt #define alc262_modes alc260_modes +#define alc262_capture_source alc882_capture_source static struct snd_kcontrol_new alc262_base_mixer[] = { HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT), @@ -3921,6 +3927,7 @@ static struct alc_config_preset alc262_presets[] = { .hp_nid = 0x03, .num_channel_mode = ARRAY_SIZE(alc262_modes), .channel_mode = alc262_modes, + .input_mux = alc262_capture_source, }, }; -- cgit v1.1 From a3bcba384c2f2448ad204ea52baa15f1227d0d40 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 6 Dec 2005 19:05:29 +0100 Subject: [ALSA] hda-codec - Fix Oops with ALC260 auto-probe Modules: HDA Codec driver - Fix Oops with auto-probing of ALC260 with digital I/O - Fix a typo Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 63aeddb..2a6a480 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2678,6 +2678,9 @@ static struct hda_pcm_stream alc260_pcm_analog_capture = { .channels_max = 2, }; +#define alc260_pcm_digital_playback alc880_pcm_digital_playback +#define alc260_pcm_digital_capture alc880_pcm_digital_capture + /* * for BIOS auto-configuration */ @@ -3041,6 +3044,10 @@ static int patch_alc260(struct hda_codec *codec) spec->stream_analog_playback = &alc260_pcm_analog_playback; spec->stream_analog_capture = &alc260_pcm_analog_capture; + spec->stream_name_digital = "ALC260 Digital"; + spec->stream_digital_playback = &alc260_pcm_digital_playback; + spec->stream_digital_capture = &alc260_pcm_digital_capture; + codec->patch_ops = alc_patch_ops; if (board_config == ALC260_AUTO) codec->patch_ops.init = alc260_auto_init; @@ -3927,7 +3934,7 @@ static struct alc_config_preset alc262_presets[] = { .hp_nid = 0x03, .num_channel_mode = ARRAY_SIZE(alc262_modes), .channel_mode = alc262_modes, - .input_mux = alc262_capture_source, + .input_mux = &alc262_capture_source, }, }; -- cgit v1.1 From 156b2aa3bef17c964006c6448aadd440781d7e7d Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 7 Dec 2005 09:07:25 +0100 Subject: [ALSA] ens1371: fix compilation without SUPPORT_JOYSTICK Modules: ENS1370/1+ driver Move the spdif and lineio parameters around so that they are compiled even when SUPPORT_JOYSTICK isn't set. Signed-off-by: Clemens Ladisch --- sound/pci/ens1370.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c index 856f7c6..55aaf11 100644 --- a/sound/pci/ens1370.c +++ b/sound/pci/ens1370.c @@ -86,12 +86,14 @@ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable switches */ #ifdef SUPPORT_JOYSTICK #ifdef CHIP1371 static int joystick_port[SNDRV_CARDS]; -static int spdif[SNDRV_CARDS]; -static int lineio[SNDRV_CARDS]; #else static int joystick[SNDRV_CARDS]; #endif #endif +#ifdef CHIP1371 +static int spdif[SNDRV_CARDS]; +static int lineio[SNDRV_CARDS]; +#endif module_param_array(index, int, NULL, 0444); MODULE_PARM_DESC(index, "Index value for Ensoniq AudioPCI soundcard."); @@ -103,15 +105,17 @@ MODULE_PARM_DESC(enable, "Enable Ensoniq AudioPCI soundcard."); #ifdef CHIP1371 module_param_array(joystick_port, int, NULL, 0444); MODULE_PARM_DESC(joystick_port, "Joystick port address."); -module_param_array(spdif, int, NULL, 0444); -MODULE_PARM_DESC(spdif, "S/PDIF output (-1 = none, 0 = auto, 1 = force)."); -module_param_array(lineio, int, NULL, 0444); -MODULE_PARM_DESC(lineio, "Line In to Rear Out (0 = auto, 1 = force)."); #else module_param_array(joystick, bool, NULL, 0444); MODULE_PARM_DESC(joystick, "Enable joystick."); #endif #endif /* SUPPORT_JOYSTICK */ +#ifdef CHIP1371 +module_param_array(spdif, int, NULL, 0444); +MODULE_PARM_DESC(spdif, "S/PDIF output (-1 = none, 0 = auto, 1 = force)."); +module_param_array(lineio, int, NULL, 0444); +MODULE_PARM_DESC(lineio, "Line In to Rear Out (0 = auto, 1 = force)."); +#endif /* ES1371 chip ID */ /* This is a little confusing because all ES1371 compatible chips have the -- cgit v1.1 From 416c1079d30f1a52399b96f6772e993274b774ae Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 7 Dec 2005 09:11:05 +0100 Subject: [ALSA] Nest sound devices Modules: ALSA Core Make the control device parent of all other ALSA devices of a card. Signed-off-by: Clemens Ladisch --- include/sound/core.h | 1 + sound/core/device.c | 2 +- sound/core/sound.c | 11 +++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index 90ac613..dbe7a2c 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -134,6 +134,7 @@ struct snd_card { wait_queue_head_t shutdown_sleep; struct work_struct free_workq; /* for free in workqueue */ struct device *dev; + struct class_device *parent_device; #ifdef CONFIG_PM unsigned int power_state; /* power state */ diff --git a/sound/core/device.c b/sound/core/device.c index b1cf6ec..478264c 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -193,7 +193,7 @@ int snd_device_register_all(struct snd_card *card) int err; snd_assert(card != NULL, return -ENXIO); - list_for_each(list, &card->devices) { + list_for_each_prev(list, &card->devices) { dev = snd_device(list); if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { if ((err = dev->ops->dev_register(dev)) < 0) diff --git a/sound/core/sound.c b/sound/core/sound.c index a8eda02..2f6108d 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -245,6 +245,7 @@ int snd_register_device(int type, struct snd_card *card, int dev, int minor; struct snd_minor *preg; struct device *device = NULL; + struct class_device *class_device = NULL; snd_assert(name, return -EINVAL); preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); @@ -272,9 +273,15 @@ int snd_register_device(int type, struct snd_card *card, int dev, snd_minors[minor] = preg; if (type != SNDRV_DEVICE_TYPE_CONTROL || preg->card >= cards_limit) devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name); - if (card) + if (card) { device = card->dev; - class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name); + class_device = card->parent_device; + } + class_device = class_device_create(sound_class, class_device, + MKDEV(major, minor), device, + "%s", name); + if (type == SNDRV_DEVICE_TYPE_CONTROL) + card->parent_device = class_device; up(&sound_mutex); return 0; -- cgit v1.1 From f7a9275d949cb0bf1f259a1546e52a0bf518151c Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Wed, 7 Dec 2005 09:13:42 +0100 Subject: [ALSA] unregister platform devices Call platform_device_unregister() for all platform devices that we've registered. Signed-off-by: Clemens Ladisch --- sound/arm/sa11xx-uda1341.c | 6 +++-- sound/drivers/dummy.c | 16 ++++++++++-- sound/drivers/mpu401/mpu401.c | 21 +++++++++++----- sound/drivers/mtpav.c | 4 ++- sound/drivers/serial-u16550.c | 16 ++++++++++-- sound/drivers/virmidi.c | 16 ++++++++++-- sound/isa/ad1848/ad1848.c | 16 ++++++++++-- sound/isa/cmi8330.c | 34 +++++++++++++++++++------ sound/isa/cs423x/cs4231.c | 16 ++++++++++-- sound/isa/cs423x/cs4236.c | 51 +++++++++++++++++++++++++++----------- sound/isa/es1688/es1688.c | 16 ++++++++++-- sound/isa/es18xx.c | 34 +++++++++++++++++++------ sound/isa/gus/gusclassic.c | 16 ++++++++++-- sound/isa/gus/gusextreme.c | 16 ++++++++++-- sound/isa/gus/gusmax.c | 16 ++++++++++-- sound/isa/gus/interwave.c | 34 +++++++++++++++++++------ sound/isa/opl3sa2.c | 43 ++++++++++++++++++++++++-------- sound/isa/opti9xx/opti92x-ad1848.c | 9 +++++-- sound/isa/sb/sb16.c | 42 ++++++++++++++++++++++--------- sound/isa/sb/sb8.c | 16 ++++++++++-- sound/isa/sgalaxy.c | 16 ++++++++++-- sound/isa/sscape.c | 33 ++++++++++++++++++------ sound/isa/wavefront/wavefront.c | 35 ++++++++++++++++++++------ sound/ppc/powermac.c | 4 ++- 24 files changed, 415 insertions(+), 111 deletions(-) diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c index 3c342c1..13057d9 100644 --- a/sound/arm/sa11xx-uda1341.c +++ b/sound/arm/sa11xx-uda1341.c @@ -21,7 +21,7 @@ * merged HAL layer (patches from Brian) */ -/* $Id: sa11xx-uda1341.c,v 1.26 2005/11/17 17:19:50 tiwai Exp $ */ +/* $Id: sa11xx-uda1341.c,v 1.27 2005/12/07 09:13:42 cladisch Exp $ */ /*************************************************************************************************** * @@ -155,6 +155,8 @@ static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .mask = 0, }; +static struct platform_device *device; + /* }}} */ /* {{{ Clock and sample rate stuff */ @@ -976,7 +978,6 @@ static struct platform_driver sa11xx_uda1341_driver = { static int __init sa11xx_uda1341_init(void) { int err; - struct platform_device *device; if (!machine_is_h3xxx()) return -ENODEV; @@ -992,6 +993,7 @@ static int __init sa11xx_uda1341_init(void) static void __exit sa11xx_uda1341_exit(void) { + platform_device_unregister(device); platform_driver_unregister(&sa11xx_uda1341_driver); } diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 1861175..96d2070 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -144,6 +144,8 @@ MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-16) for dummy driver."); //module_param_array(midi_devs, int, NULL, 0444); //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver."); +static struct platform_device *devices[SNDRV_CARDS]; + #define MIXER_ADDR_MASTER 0 #define MIXER_ADDR_LINE 1 #define MIXER_ADDR_MIC 2 @@ -634,6 +636,15 @@ static struct platform_driver snd_dummy_driver = { }, }; +static void __init_or_module snd_dummy_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_dummy_driver); +} + static int __init alsa_card_dummy_init(void) { int i, cards, err; @@ -650,6 +661,7 @@ static int __init alsa_card_dummy_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -662,13 +674,13 @@ static int __init alsa_card_dummy_init(void) return 0; errout: - platform_driver_unregister(&snd_dummy_driver); + snd_dummy_unregister_all(); return err; } static void __exit alsa_card_dummy_exit(void) { - platform_driver_unregister(&snd_dummy_driver); + snd_dummy_unregister_all(); } module_init(alsa_card_dummy_init) diff --git a/sound/drivers/mpu401/mpu401.c b/sound/drivers/mpu401/mpu401.c index ec817a8..915589a 100644 --- a/sound/drivers/mpu401/mpu401.c +++ b/sound/drivers/mpu401/mpu401.c @@ -58,6 +58,7 @@ MODULE_PARM_DESC(port, "Port # for MPU-401 device."); module_param_array(irq, int, NULL, 0444); MODULE_PARM_DESC(irq, "IRQ # for MPU-401 device."); +static struct platform_device *platform_devices[SNDRV_CARDS]; static int pnp_registered = 0; static int snd_mpu401_create(int dev, struct snd_card **rcard) @@ -220,6 +221,17 @@ static struct pnp_driver snd_mpu401_pnp_driver = { static struct pnp_driver snd_mpu401_pnp_driver; #endif +static void __init_or_module snd_mpu401_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_driver(&snd_mpu401_pnp_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_mpu401_driver); +} + static int __init alsa_card_mpu401_init(void) { int i, err, devices; @@ -240,6 +252,7 @@ static int __init alsa_card_mpu401_init(void) err = PTR_ERR(device); goto errout; } + platform_devices[i] = device; devices++; } if ((err = pnp_register_driver(&snd_mpu401_pnp_driver)) >= 0) { @@ -257,17 +270,13 @@ static int __init alsa_card_mpu401_init(void) return 0; errout: - if (pnp_registered) - pnp_unregister_driver(&snd_mpu401_pnp_driver); - platform_driver_unregister(&snd_mpu401_driver); + snd_mpu401_unregister_all(); return err; } static void __exit alsa_card_mpu401_exit(void) { - if (pnp_registered) - pnp_unregister_driver(&snd_mpu401_pnp_driver); - platform_driver_unregister(&snd_mpu401_driver); + snd_mpu401_unregister_all(); } module_init(alsa_card_mpu401_init) diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index d9c4e22..b7a0b42 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -95,6 +95,8 @@ MODULE_PARM_DESC(irq, "Parallel IRQ # for MotuMTPAV MIDI."); module_param(hwports, int, 0444); MODULE_PARM_DESC(hwports, "Hardware ports # for MotuMTPAV MIDI."); +static struct platform_device *device; + /* * defines */ @@ -763,7 +765,6 @@ static struct platform_driver snd_mtpav_driver = { static int __init alsa_card_mtpav_init(void) { int err; - struct platform_device *device; if ((err = platform_driver_register(&snd_mtpav_driver)) < 0) return err; @@ -778,6 +779,7 @@ static int __init alsa_card_mtpav_init(void) static void __exit alsa_card_mtpav_exit(void) { + platform_device_unregister(device); platform_driver_unregister(&snd_mtpav_driver); } diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 3381a43..29676d8 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -168,6 +168,8 @@ typedef struct _snd_uart16550 { } snd_uart16550_t; +static struct platform_device *devices[SNDRV_CARDS]; + static inline void snd_uart16550_add_timer(snd_uart16550_t *uart) { if (! uart->timer_running) { @@ -970,6 +972,15 @@ static struct platform_driver snd_serial_driver = { }, }; +static void __init_or_module snd_serial_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_serial_driver); +} + static int __init alsa_card_serial_init(void) { int i, cards, err; @@ -986,6 +997,7 @@ static int __init alsa_card_serial_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (! cards) { @@ -998,13 +1010,13 @@ static int __init alsa_card_serial_init(void) return 0; errout: - platform_driver_unregister(&snd_serial_driver); + snd_serial_unregister_all(); return err; } static void __exit alsa_card_serial_exit(void) { - platform_driver_unregister(&snd_serial_driver); + snd_serial_unregister_all(); } module_init(alsa_card_serial_init) diff --git a/sound/drivers/virmidi.c b/sound/drivers/virmidi.c index 9f36a64..4258723 100644 --- a/sound/drivers/virmidi.c +++ b/sound/drivers/virmidi.c @@ -82,6 +82,8 @@ struct snd_card_virmidi { struct snd_rawmidi *midi[MAX_MIDI_DEVICES]; }; +static struct platform_device *devices[SNDRV_CARDS]; + static int __init snd_virmidi_probe(struct platform_device *devptr) { @@ -144,6 +146,15 @@ static struct platform_driver snd_virmidi_driver = { }, }; +static void __init_or_module snd_virmidi_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_virmidi_driver); +} + static int __init alsa_card_virmidi_init(void) { int i, cards, err; @@ -160,6 +171,7 @@ static int __init alsa_card_virmidi_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -172,13 +184,13 @@ static int __init alsa_card_virmidi_init(void) return 0; errout: - platform_driver_unregister(&snd_virmidi_driver); + snd_virmidi_unregister_all(); return err; } static void __exit alsa_card_virmidi_exit(void) { - platform_driver_unregister(&snd_virmidi_driver); + snd_virmidi_unregister_all(); } module_init(alsa_card_virmidi_init) diff --git a/sound/isa/ad1848/ad1848.c b/sound/isa/ad1848/ad1848.c index 1019e9f..e091bbe 100644 --- a/sound/isa/ad1848/ad1848.c +++ b/sound/isa/ad1848/ad1848.c @@ -62,6 +62,8 @@ MODULE_PARM_DESC(dma1, "DMA1 # for AD1848 driver."); module_param_array(thinkpad, bool, NULL, 0444); MODULE_PARM_DESC(thinkpad, "Enable only for the onboard CS4248 of IBM Thinkpad 360/750/755 series."); +static struct platform_device *devices[SNDRV_CARDS]; + static int __init snd_ad1848_probe(struct platform_device *pdev) { @@ -167,6 +169,15 @@ static struct platform_driver snd_ad1848_driver = { }, }; +static void __init_or_module snd_ad1848_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_ad1848_driver); +} + static int __init alsa_card_ad1848_init(void) { int i, cards, err; @@ -184,6 +195,7 @@ static int __init alsa_card_ad1848_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -196,13 +208,13 @@ static int __init alsa_card_ad1848_init(void) return 0; errout: - platform_driver_unregister(&snd_ad1848_driver); + snd_ad1848_unregister_all(); return err; } static void __exit alsa_card_ad1848_exit(void) { - platform_driver_unregister(&snd_ad1848_driver); + snd_ad1848_unregister_all(); } module_init(alsa_card_ad1848_init) diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c index ba0114e..bd8e238 100644 --- a/sound/isa/cmi8330.c +++ b/sound/isa/cmi8330.c @@ -108,6 +108,9 @@ MODULE_PARM_DESC(wssirq, "IRQ # for CMI8330 WSS driver."); module_param_array(wssdma, int, NULL, 0444); MODULE_PARM_DESC(wssdma, "DMA for CMI8330 WSS driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + #define CMI8330_RMUX3D 16 #define CMI8330_MUTEMUX 17 #define CMI8330_OUTPUTVOL 18 @@ -665,6 +668,17 @@ static struct pnp_card_driver cmi8330_pnpc_driver = { }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_cmi8330_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&cmi8330_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_cmi8330_driver); +} + static int __init alsa_card_cmi8330_init(void) { int i, err, cards = 0; @@ -680,31 +694,35 @@ static int __init alsa_card_cmi8330_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_cmi8330_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } err = pnp_register_card_driver(&cmi8330_pnpc_driver); - if (err > 0) + if (err >= 0) { + pnp_registered = 1; cards += err; + } if (!cards) { - pnp_unregister_card_driver(&cmi8330_pnpc_driver); - platform_driver_unregister(&snd_cmi8330_driver); #ifdef MODULE snd_printk(KERN_ERR "CMI8330 not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_cmi8330_unregister_all(); + return err; } static void __exit alsa_card_cmi8330_exit(void) { - pnp_unregister_card_driver(&cmi8330_pnpc_driver); - platform_driver_unregister(&snd_cmi8330_driver); + snd_cmi8330_unregister_all(); } module_init(alsa_card_cmi8330_init) diff --git a/sound/isa/cs423x/cs4231.c b/sound/isa/cs423x/cs4231.c index b5252a5..ab67b5c 100644 --- a/sound/isa/cs423x/cs4231.c +++ b/sound/isa/cs423x/cs4231.c @@ -66,6 +66,8 @@ MODULE_PARM_DESC(dma1, "DMA1 # for CS4231 driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for CS4231 driver."); +static struct platform_device *devices[SNDRV_CARDS]; + static int __init snd_cs4231_probe(struct platform_device *pdev) { @@ -183,6 +185,15 @@ static struct platform_driver snd_cs4231_driver = { }, }; +static void __init_or_module snd_cs4231_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_cs4231_driver); +} + static int __init alsa_card_cs4231_init(void) { int i, cards, err; @@ -200,6 +211,7 @@ static int __init alsa_card_cs4231_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -212,13 +224,13 @@ static int __init alsa_card_cs4231_init(void) return 0; errout: - platform_driver_unregister(&snd_cs4231_driver); + snd_cs4231_unregister_all(); return err; } static void __exit alsa_card_cs4231_exit(void) { - platform_driver_unregister(&snd_cs4231_driver); + snd_cs4231_unregister_all(); } module_init(alsa_card_cs4231_init) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index 9e399b6..e168333 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -124,6 +124,12 @@ MODULE_PARM_DESC(dma1, "DMA1 # for " IDENT " driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA2 # for " IDENT " driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnpc_registered; +#ifdef CS4232 +static int pnp_registered; +#endif + struct snd_card_cs4236 { struct snd_cs4231 *chip; struct resource *res_sb_port; @@ -737,6 +743,21 @@ static struct pnp_card_driver cs423x_pnpc_driver = { }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_cs423x_unregister_all(void) +{ + int i; + + if (pnpc_registered) + pnp_unregister_card_driver(&cs423x_pnpc_driver); +#ifdef CS4232 + if (pnp_registered) + pnp_unregister_driver(&cs4232_pnp_driver); +#endif + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&cs423x_nonpnp_driver); +} + static int __init alsa_card_cs423x_init(void) { int i, err, cards = 0; @@ -752,40 +773,40 @@ static int __init alsa_card_cs423x_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&cs423x_nonpnp_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } #ifdef CS4232 i = pnp_register_driver(&cs4232_pnp_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } #endif i = pnp_register_card_driver(&cs423x_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnpc_registered = 1; cards += i; + } if (!cards) { -#ifdef CS4232 - pnp_unregister_driver(&cs4232_pnp_driver); -#endif - pnp_unregister_card_driver(&cs423x_pnpc_driver); - platform_driver_unregister(&cs423x_nonpnp_driver); #ifdef MODULE printk(KERN_ERR IDENT " soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_cs423x_unregister_all(); + return err; } static void __exit alsa_card_cs423x_exit(void) { -#ifdef CS4232 - pnp_unregister_driver(&cs4232_pnp_driver); -#endif - pnp_unregister_card_driver(&cs423x_pnpc_driver); - platform_driver_unregister(&cs423x_nonpnp_driver); + snd_cs423x_unregister_all(); } module_init(alsa_card_cs423x_init) diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c index 68bd40a..50d23cf 100644 --- a/sound/isa/es1688/es1688.c +++ b/sound/isa/es1688/es1688.c @@ -69,6 +69,8 @@ MODULE_PARM_DESC(mpu_irq, "MPU-401 IRQ # for ESx688 driver."); module_param_array(dma8, int, NULL, 0444); MODULE_PARM_DESC(dma8, "8-bit DMA # for ESx688 driver."); +static struct platform_device *devices[SNDRV_CARDS]; + #define PFX "es1688: " static int __init snd_es1688_probe(struct platform_device *pdev) @@ -187,6 +189,15 @@ static struct platform_driver snd_es1688_driver = { }, }; +static void __init_or_module snd_es1688_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_es1688_driver); +} + static int __init alsa_card_es1688_init(void) { int i, cards, err; @@ -204,6 +215,7 @@ static int __init alsa_card_es1688_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -216,13 +228,13 @@ static int __init alsa_card_es1688_init(void) return 0; errout: - platform_driver_unregister(&snd_es1688_driver); + snd_es1688_unregister_all(); return err; } static void __exit alsa_card_es1688_exit(void) { - platform_driver_unregister(&snd_es1688_driver); + snd_es1688_unregister_all(); } module_init(alsa_card_es1688_init) diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index 34d4713..bf5de07 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1877,6 +1877,9 @@ MODULE_PARM_DESC(dma1, "DMA 1 # for ES18xx driver."); module_param_array(dma2, int, NULL, 0444); MODULE_PARM_DESC(dma2, "DMA 2 # for ES18xx driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + #ifdef CONFIG_PNP static struct pnp_card_device_id snd_audiodrive_pnpids[] = { @@ -2202,6 +2205,17 @@ static struct pnp_card_driver es18xx_pnpc_driver = { }; #endif /* CONFIG_PNP */ +static void __init_or_module snd_es18xx_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&es18xx_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_es18xx_nonpnp_driver); +} + static int __init alsa_card_es18xx_init(void) { int i, err, cards = 0; @@ -2217,31 +2231,35 @@ static int __init alsa_card_es18xx_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_es18xx_nonpnp_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } i = pnp_register_card_driver(&es18xx_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } if(!cards) { - pnp_unregister_card_driver(&es18xx_pnpc_driver); - platform_driver_unregister(&snd_es18xx_nonpnp_driver); #ifdef MODULE snd_printk(KERN_ERR "ESS AudioDrive ES18xx soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_es18xx_unregister_all(); + return err; } static void __exit alsa_card_es18xx_exit(void) { - pnp_unregister_card_driver(&es18xx_pnpc_driver); - platform_driver_unregister(&snd_es18xx_nonpnp_driver); + snd_es18xx_unregister_all(); } module_init(alsa_card_es18xx_init) diff --git a/sound/isa/gus/gusclassic.c b/sound/isa/gus/gusclassic.c index 57beb74..d1165b9 100644 --- a/sound/isa/gus/gusclassic.c +++ b/sound/isa/gus/gusclassic.c @@ -71,6 +71,8 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Classic driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Classic driver."); +static struct platform_device *devices[SNDRV_CARDS]; + #define PFX "gusclassic: " @@ -227,6 +229,15 @@ static struct platform_driver snd_gusclassic_driver = { }, }; +static void __init_or_module snd_gusclassic_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_gusclassic_driver); +} + static int __init alsa_card_gusclassic_init(void) { int i, cards, err; @@ -244,6 +255,7 @@ static int __init alsa_card_gusclassic_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -256,13 +268,13 @@ static int __init alsa_card_gusclassic_init(void) return 0; errout: - platform_driver_unregister(&snd_gusclassic_driver); + snd_gusclassic_unregister_all(); return err; } static void __exit alsa_card_gusclassic_exit(void) { - platform_driver_unregister(&snd_gusclassic_driver); + snd_gusclassic_unregister_all(); } module_init(alsa_card_gusclassic_init) diff --git a/sound/isa/gus/gusextreme.c b/sound/isa/gus/gusextreme.c index 6fad973..239f16e 100644 --- a/sound/isa/gus/gusextreme.c +++ b/sound/isa/gus/gusextreme.c @@ -87,6 +87,8 @@ MODULE_PARM_DESC(channels, "GF1 channels for GUS Extreme driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS Extreme driver."); +struct platform_device *devices[SNDRV_CARDS]; + #define PFX "gusextreme: " @@ -337,6 +339,15 @@ static struct platform_driver snd_gusextreme_driver = { }, }; +static void __init_or_module snd_gusextreme_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_gusextreme_driver); +} + static int __init alsa_card_gusextreme_init(void) { int i, cards, err; @@ -354,6 +365,7 @@ static int __init alsa_card_gusextreme_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -366,13 +378,13 @@ static int __init alsa_card_gusextreme_init(void) return 0; errout: - platform_driver_unregister(&snd_gusextreme_driver); + snd_gusextreme_unregister_all(); return err; } static void __exit alsa_card_gusextreme_exit(void) { - platform_driver_unregister(&snd_gusextreme_driver); + snd_gusextreme_unregister_all(); } module_init(alsa_card_gusextreme_init) diff --git a/sound/isa/gus/gusmax.c b/sound/isa/gus/gusmax.c index d1b70ee..d4d2b2a 100644 --- a/sound/isa/gus/gusmax.c +++ b/sound/isa/gus/gusmax.c @@ -72,6 +72,8 @@ MODULE_PARM_DESC(channels, "Used GF1 channels for GUS MAX driver."); module_param_array(pcm_channels, int, NULL, 0444); MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for GUS MAX driver."); +static struct platform_device *devices[SNDRV_CARDS]; + struct snd_gusmax { int irq; struct snd_card *card; @@ -364,6 +366,15 @@ static struct platform_driver snd_gusmax_driver = { }, }; +static void __init_or_module snd_gusmax_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_gusmax_driver); +} + static int __init alsa_card_gusmax_init(void) { int i, cards, err; @@ -381,6 +392,7 @@ static int __init alsa_card_gusmax_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -393,13 +405,13 @@ static int __init alsa_card_gusmax_init(void) return 0; errout: - platform_driver_unregister(&snd_gusmax_driver); + snd_gusmax_unregister_all(); return err; } static void __exit alsa_card_gusmax_exit(void) { - platform_driver_unregister(&snd_gusmax_driver); + snd_gusmax_unregister_all(); } module_init(alsa_card_gusmax_init) diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 67a5f74..9838d99 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -115,6 +115,9 @@ MODULE_PARM_DESC(pcm_channels, "Reserved PCM channels for InterWave driver."); module_param_array(effect, int, NULL, 0444); MODULE_PARM_DESC(effect, "Effects enable for InterWave driver."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + struct snd_interwave { int irq; struct snd_card *card; @@ -914,6 +917,17 @@ static struct pnp_card_driver interwave_pnpc_driver = { #endif /* CONFIG_PNP */ +static void __init_or_module snd_interwave_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&interwave_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_interwave_driver); +} + static int __init alsa_card_interwave_init(void) { int i, err, cards = 0; @@ -931,32 +945,36 @@ static int __init alsa_card_interwave_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_interwave_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } /* ISA PnP cards */ i = pnp_register_card_driver(&interwave_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } if (!cards) { - pnp_unregister_card_driver(&interwave_pnpc_driver); - platform_driver_unregister(&snd_interwave_driver); #ifdef MODULE printk(KERN_ERR "InterWave soundcard not found or device busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_interwave_unregister_all(); + return err; } static void __exit alsa_card_interwave_exit(void) { - pnp_unregister_card_driver(&interwave_pnpc_driver); - platform_driver_unregister(&snd_interwave_driver); + snd_interwave_unregister_all(); } module_init(alsa_card_interwave_init) diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index aafe556..ca359e0 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -90,6 +90,10 @@ MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver."); module_param_array(opl3sa3_ymode, int, NULL, 0444); MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; +static int pnpc_registered; + /* control ports */ #define OPL3SA2_PM_CTRL 0x01 #define OPL3SA2_SYS_CTRL 0x02 @@ -921,6 +925,19 @@ static struct platform_driver snd_opl3sa2_nonpnp_driver = { }, }; +static void __init_or_module snd_opl3sa2_unregister_all(void) +{ + int i; + + if (pnpc_registered) + pnp_unregister_card_driver(&opl3sa2_pnpc_driver); + if (pnp_registered) + pnp_unregister_driver(&opl3sa2_pnp_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); +} + static int __init alsa_card_opl3sa2_init(void) { int i, err, cards = 0; @@ -938,36 +955,40 @@ static int __init alsa_card_opl3sa2_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } err = pnp_register_driver(&opl3sa2_pnp_driver); - if (err > 0) + if (err >= 0) { + pnp_registered = 1; cards += err; + } err = pnp_register_card_driver(&opl3sa2_pnpc_driver); - if (err > 0) + if (err >= 0) { + pnpc_registered = 1; cards += err; + } if (!cards) { #ifdef MODULE snd_printk(KERN_ERR "Yamaha OPL3-SA soundcard not found or device busy\n"); #endif - pnp_unregister_card_driver(&opl3sa2_pnpc_driver); - pnp_unregister_driver(&opl3sa2_pnp_driver); - platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_opl3sa2_unregister_all(); + return err; } static void __exit alsa_card_opl3sa2_exit(void) { - pnp_unregister_card_driver(&opl3sa2_pnpc_driver); - pnp_unregister_driver(&opl3sa2_pnp_driver); - platform_driver_unregister(&snd_opl3sa2_nonpnp_driver); + snd_opl3sa2_unregister_all(); } module_init(alsa_card_opl3sa2_init) diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 39211e5..1ea3944 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -259,6 +259,7 @@ struct snd_opti9xx { }; static int snd_opti9xx_pnp_is_probed; +static struct platform_device *snd_opti9xx_platform_device; #ifdef CONFIG_PNP @@ -2095,8 +2096,10 @@ static int __init alsa_card_opti9xx_init(void) if (error < 0) return error; device = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); - if (! IS_ERR(device)) + if (!IS_ERR(device)) { + snd_opti9xx_platform_device = device; return 0; + } platform_driver_unregister(&snd_opti9xx_driver); } pnp_unregister_card_driver(&opti9xx_pnpc_driver); @@ -2108,8 +2111,10 @@ static int __init alsa_card_opti9xx_init(void) static void __exit alsa_card_opti9xx_exit(void) { - if (! snd_opti9xx_pnp_is_probed) + if (!snd_opti9xx_pnp_is_probed) { + platform_device_unregister(snd_opti9xx_platform_device); platform_driver_unregister(&snd_opti9xx_driver); + } pnp_unregister_card_driver(&opti9xx_pnpc_driver); } diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 05816c5..c0be7a5 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -128,6 +128,11 @@ module_param_array(seq_ports, int, NULL, 0444); MODULE_PARM_DESC(seq_ports, "Number of sequencer ports for WaveTable synth."); #endif +static struct platform_device *platform_devices[SNDRV_CARDS]; +#ifdef CONFIG_PNP +static int pnp_registered; +#endif + struct snd_card_sb16 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ struct snd_sb *chip; @@ -687,6 +692,19 @@ static struct pnp_card_driver sb16_pnpc_driver = { #endif /* CONFIG_PNP */ +static void __init_or_module snd_sb16_unregister_all(void) +{ + int i; + +#ifdef CONFIG_PNP + if (pnp_registered) + pnp_unregister_card_driver(&sb16_pnpc_driver); +#endif + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_sb16_nonpnp_driver); +} + static int __init alsa_card_sb16_init(void) { int i, err, cards = 0; @@ -702,23 +720,21 @@ static int __init alsa_card_sb16_init(void) i, NULL, 0); if (IS_ERR(device)) { err = PTR_ERR(device); - platform_driver_unregister(&snd_sb16_nonpnp_driver); - return err; + goto errout; } + platform_devices[i] = device; cards++; } #ifdef CONFIG_PNP /* PnP cards at last */ i = pnp_register_card_driver(&sb16_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } #endif if (!cards) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&sb16_pnpc_driver); -#endif - platform_driver_unregister(&snd_sb16_nonpnp_driver); #ifdef MODULE snd_printk(KERN_ERR "Sound Blaster 16 soundcard not found or device busy\n"); #ifdef SNDRV_SBAWE_EMU8000 @@ -727,17 +743,19 @@ static int __init alsa_card_sb16_init(void) snd_printk(KERN_ERR "In case, if you have AWE card, try snd-sbawe module\n"); #endif #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_sb16_unregister_all(); + return err; } static void __exit alsa_card_sb16_exit(void) { -#ifdef CONFIG_PNP - pnp_unregister_card_driver(&sb16_pnpc_driver); -#endif - platform_driver_unregister(&snd_sb16_nonpnp_driver); + snd_sb16_unregister_all(); } module_init(alsa_card_sb16_init) diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index 0a3d55d..60ee79c 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -56,6 +56,8 @@ MODULE_PARM_DESC(irq, "IRQ # for SB8 driver."); module_param_array(dma8, int, NULL, 0444); MODULE_PARM_DESC(dma8, "8-bit DMA # for SB8 driver."); +static struct platform_device *devices[SNDRV_CARDS]; + struct snd_sb8 { struct resource *fm_res; /* used to block FM i/o region for legacy cards */ struct snd_sb *chip; @@ -238,6 +240,15 @@ static struct platform_driver snd_sb8_driver = { }, }; +static void __init_or_module snd_sb8_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_sb8_driver); +} + static int __init alsa_card_sb8_init(void) { int i, cards, err; @@ -255,6 +266,7 @@ static int __init alsa_card_sb8_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -267,13 +279,13 @@ static int __init alsa_card_sb8_init(void) return 0; errout: - platform_driver_unregister(&snd_sb8_driver); + snd_sb8_unregister_all(); return err; } static void __exit alsa_card_sb8_exit(void) { - platform_driver_unregister(&snd_sb8_driver); + snd_sb8_unregister_all(); } module_init(alsa_card_sb8_init) diff --git a/sound/isa/sgalaxy.c b/sound/isa/sgalaxy.c index 2e1d467..0dbbb35 100644 --- a/sound/isa/sgalaxy.c +++ b/sound/isa/sgalaxy.c @@ -64,6 +64,8 @@ MODULE_PARM_DESC(irq, "IRQ # for Sound Galaxy driver."); module_param_array(dma1, int, NULL, 0444); MODULE_PARM_DESC(dma1, "DMA1 # for Sound Galaxy driver."); +static struct platform_device *devices[SNDRV_CARDS]; + #define SGALAXY_AUXC_LEFT 18 #define SGALAXY_AUXC_RIGHT 19 @@ -340,6 +342,15 @@ static struct platform_driver snd_sgalaxy_driver = { }, }; +static void __init_or_module snd_sgalaxy_unregister_all(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(devices); ++i) + platform_device_unregister(devices[i]); + platform_driver_unregister(&snd_sgalaxy_driver); +} + static int __init alsa_card_sgalaxy_init(void) { int i, cards, err; @@ -357,6 +368,7 @@ static int __init alsa_card_sgalaxy_init(void) err = PTR_ERR(device); goto errout; } + devices[i] = device; cards++; } if (!cards) { @@ -369,13 +381,13 @@ static int __init alsa_card_sgalaxy_init(void) return 0; errout: - platform_driver_unregister(&snd_sgalaxy_driver); + snd_sgalaxy_unregister_all(); return err; } static void __exit alsa_card_sgalaxy_exit(void) { - platform_driver_unregister(&snd_sgalaxy_driver); + snd_sgalaxy_unregister_all(); } module_init(alsa_card_sgalaxy_init) diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 6271efe..5fb981c 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -67,6 +67,9 @@ MODULE_PARM_DESC(mpu_irq, "MPU401 IRQ # for SoundScape driver."); module_param_array(dma, int, NULL, 0444); MODULE_PARM_DESC(dma, "DMA # for SoundScape driver."); + +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; #ifdef CONFIG_PNP static struct pnp_card_device_id sscape_pnpids[] = { @@ -1384,6 +1387,17 @@ static struct pnp_card_driver sscape_pnpc_driver = { #endif /* CONFIG_PNP */ +static void __init_or_module sscape_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&sscape_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_sscape_driver); +} + static int __init sscape_manual_probe(void) { struct platform_device *device; @@ -1411,8 +1425,8 @@ static int __init sscape_manual_probe(void) dma[i] == SNDRV_AUTO_DMA) { printk(KERN_INFO "sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n"); - platform_driver_unregister(&snd_sscape_driver); - return -ENXIO; + ret = -ENXIO; + goto errout; } /* @@ -1421,17 +1435,21 @@ static int __init sscape_manual_probe(void) device = platform_device_register_simple(SSCAPE_DRIVER, i, NULL, 0); if (IS_ERR(device)) { - platform_driver_unregister(&snd_sscape_driver); - return PTR_ERR(device); + ret = PTR_ERR(device); + goto errout; } + platform_devices[i] = device; } return 0; + + errout: + sscape_unregister_all(); + return ret; } static void sscape_exit(void) { - pnp_unregister_card_driver(&sscape_pnpc_driver); - platform_driver_unregister(&snd_sscape_driver); + sscape_unregister_all(); } @@ -1448,7 +1466,8 @@ static int __init sscape_init(void) ret = sscape_manual_probe(); if (ret < 0) return ret; - pnp_register_card_driver(&sscape_pnpc_driver); + if (pnp_register_card_driver(&sscape_pnpc_driver) >= 0) + pnp_registered = 1; return 0; } diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 77a3012..a6dcb2f 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -83,6 +83,9 @@ MODULE_PARM_DESC(fm_port, "FM port #."); module_param_array(use_cs4232_midi, bool, NULL, 0444); MODULE_PARM_DESC(use_cs4232_midi, "Use CS4232 MPU-401 interface (inaccessibly located inside your computer)"); +static struct platform_device *platform_devices[SNDRV_CARDS]; +static int pnp_registered; + #ifdef CONFIG_PNP @@ -688,6 +691,17 @@ static struct pnp_card_driver wavefront_pnpc_driver = { #endif /* CONFIG_PNP */ +static void __init_or_module snd_wavefront_unregister_all(void) +{ + int i; + + if (pnp_registered) + pnp_unregister_card_driver(&wavefront_pnpc_driver); + for (i = 0; i < ARRAY_SIZE(platform_devices); ++i) + platform_device_unregister(platform_devices[i]); + platform_driver_unregister(&snd_wavefront_driver); +} + static int __init alsa_card_wavefront_init(void) { int i, err, cards = 0; @@ -704,31 +718,36 @@ static int __init alsa_card_wavefront_init(void) device = platform_device_register_simple(WAVEFRONT_DRIVER, i, NULL, 0); if (IS_ERR(device)) { - platform_driver_unregister(&snd_wavefront_driver); - return PTR_ERR(device); + err = PTR_ERR(device); + goto errout; } + platform_devices[i] = device; cards++; } i = pnp_register_card_driver(&wavefront_pnpc_driver); - if (i > 0) + if (i >= 0) { + pnp_registered = 1; cards += i; + } if (!cards) { - pnp_unregister_card_driver(&wavefront_pnpc_driver); - platform_driver_unregister(&snd_wavefront_driver); #ifdef MODULE printk (KERN_ERR "No WaveFront cards found or devices busy\n"); #endif - return -ENODEV; + err = -ENODEV; + goto errout; } return 0; + + errout: + snd_wavefront_unregister_all(); + return err; } static void __exit alsa_card_wavefront_exit(void) { - pnp_unregister_card_driver(&wavefront_pnpc_driver); - platform_driver_unregister(&snd_wavefront_driver); + snd_wavefront_unregister_all(); } module_init(alsa_card_wavefront_init) diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index efa06fe..f4902a2 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c @@ -46,6 +46,8 @@ MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip."); module_param(enable_beep, bool, 0444); MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); +static struct platform_device *device; + /* */ @@ -182,7 +184,6 @@ static struct platform_driver snd_pmac_driver = { static int __init alsa_card_pmac_init(void) { int err; - struct platform_device *device; if ((err = platform_driver_register(&snd_pmac_driver)) < 0) return err; @@ -197,6 +198,7 @@ static int __init alsa_card_pmac_init(void) static void __exit alsa_card_pmac_exit(void) { + platform_device_unregister(device); platform_driver_unregister(&snd_pmac_driver); } -- cgit v1.1 From 4a471b7ddfe76e39c1633d5a23a687f4b5fc0d8d Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Dec 2005 13:56:29 +0100 Subject: [ALSA] hda-codec - Small clean up and fixes Modules: HDA Codec driver,HDA generic driver - Common labels for input pins - Fix and clean up of Realtek codec parsers Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 6 +++ sound/pci/hda/hda_local.h | 2 + sound/pci/hda/patch_analog.c | 8 ++-- sound/pci/hda/patch_realtek.c | 87 +++++++++++++++++++++--------------------- sound/pci/hda/patch_sigmatel.c | 5 +-- 5 files changed, 56 insertions(+), 52 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index bd375f8..4a6dd97 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2051,6 +2051,12 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, struct auto_pin_cfg *c return 0; } +/* labels for input pins */ +const char *auto_pin_cfg_labels[AUTO_PIN_LAST] = { + "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" +}; + + #ifdef CONFIG_PM /* * power management diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index a9863eb..c82d2a7 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h @@ -211,6 +211,8 @@ enum { AUTO_PIN_LAST }; +extern const char *auto_pin_cfg_labels[AUTO_PIN_LAST]; + struct auto_pin_cfg { int line_outs; hda_nid_t line_out_pins[5]; /* sorted in the order of Front/Surr/CLFE/Side */ diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index d1e1ded..1ada1b0 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c @@ -1850,18 +1850,16 @@ static int new_analog_input(struct ad198x_spec *spec, hda_nid_t pin, static int ad1988_auto_create_analog_input_ctls(struct ad198x_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[AUTO_PIN_LAST] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" - }; struct hda_input_mux *imux = &spec->private_imux; int i, err; for (i = 0; i < AUTO_PIN_LAST; i++) { - err = new_analog_input(spec, cfg->input_pins[i], labels[i], + err = new_analog_input(spec, cfg->input_pins[i], + auto_pin_cfg_labels[i], i <= AUTO_PIN_FRONT_MIC); if (err < 0) return err; - imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; imux->items[imux->num_items].index = ad1988_pin_to_adc_idx(cfg->input_pins[i]); imux->num_items++; } diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 2a6a480..cac1092 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1259,18 +1259,24 @@ static int alc_build_pcms(struct hda_codec *codec) codec->num_pcms = 1; codec->pcm_info = info; - snd_assert(spec->stream_analog_playback, return -EINVAL); - snd_assert(spec->stream_analog_capture, return -EINVAL); info->name = spec->stream_name_analog; - info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); - info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; - info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); - info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; - - info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; - for (i = 0; i < spec->num_channel_mode; i++) { - if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { - info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; + if (spec->stream_analog_playback) { + snd_assert(spec->multiout.dac_nids, return -EINVAL); + info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback); + info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; + } + if (spec->stream_analog_capture) { + snd_assert(spec->adc_nids, return -EINVAL); + info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture); + info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; + } + + if (spec->channel_mode) { + info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; + for (i = 0; i < spec->num_channel_mode; i++) { + if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { + info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; + } } } @@ -1278,13 +1284,13 @@ static int alc_build_pcms(struct hda_codec *codec) codec->num_pcms++; info++; info->name = spec->stream_name_digital; - if (spec->multiout.dig_out_nid) { - snd_assert(spec->stream_digital_playback, return -EINVAL); + if (spec->multiout.dig_out_nid && + spec->stream_digital_playback) { info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback); info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; } - if (spec->dig_in_nid) { - snd_assert(spec->stream_digital_capture, return -EINVAL); + if (spec->dig_in_nid && + spec->stream_digital_capture) { info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture); info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; } @@ -2091,20 +2097,18 @@ static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ct static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[AUTO_PIN_LAST] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" - }; struct hda_input_mux *imux = &spec->private_imux; int i, err, idx; for (i = 0; i < AUTO_PIN_LAST; i++) { if (alc880_is_input_pin(cfg->input_pins[i])) { idx = alc880_input_pin_idx(cfg->input_pins[i]); - err = new_analog_input(spec, cfg->input_pins[i], labels[i], + err = new_analog_input(spec, cfg->input_pins[i], + auto_pin_cfg_labels[i], idx, 0x0b); if (err < 0) return err; - imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]); imux->num_items++; } @@ -2664,6 +2668,8 @@ static struct hda_verb alc260_fujitsu_init_verbs[] = { {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */ {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */ {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */ + + { } }; static struct hda_pcm_stream alc260_pcm_analog_playback = { @@ -2755,28 +2761,27 @@ static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec, static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[AUTO_PIN_LAST] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" - }; struct hda_input_mux *imux = &spec->private_imux; int i, err, idx; for (i = 0; i < AUTO_PIN_LAST; i++) { if (cfg->input_pins[i] >= 0x12) { idx = cfg->input_pins[i] - 0x12; - err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); + err = new_analog_input(spec, cfg->input_pins[i], + auto_pin_cfg_labels[i], idx, 0x07); if (err < 0) return err; - imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; imux->items[imux->num_items].index = idx; imux->num_items++; } if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){ idx = cfg->input_pins[i] - 0x09; - err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x07); + err = new_analog_input(spec, cfg->input_pins[i], + auto_pin_cfg_labels[i], idx, 0x07); if (err < 0) return err; - imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; imux->items[imux->num_items].index = idx; imux->num_items++; } @@ -2889,11 +2894,11 @@ static int alc260_parse_auto_config(struct hda_codec *codec) if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, alc260_ignore)) < 0) return err; - if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin && - ! spec->autocfg.hp_pin) + if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0) + return err; + if (! spec->kctl_alloc) return 0; /* can't find valid BIOS pin config */ - if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 || - (err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) + if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0) return err; spec->multiout.max_channels = 2; @@ -2908,19 +2913,18 @@ static int alc260_parse_auto_config(struct hda_codec *codec) spec->input_mux = &spec->private_imux; /* check whether NID 0x04 is valid */ - wcap = snd_hda_param_read(codec, alc260_adc_nids[0], AC_PAR_AUDIO_WIDGET_CAP); + wcap = get_wcaps(codec, 0x04); wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ if (wcap != AC_WID_AUD_IN) { spec->adc_nids = alc260_adc_nids_alt; spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt); spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer; - spec->num_mixers++; } else { spec->adc_nids = alc260_adc_nids; spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids); spec->mixers[spec->num_mixers] = alc260_capture_mixer; - spec->num_mixers++; } + spec->num_mixers++; return 1; } @@ -3582,8 +3586,7 @@ static int patch_alc882(struct hda_codec *codec) if (! spec->adc_nids && spec->input_mux) { /* check whether NID 0x07 is valid */ - unsigned int wcap = snd_hda_param_read(codec, 0x07, - AC_PAR_AUDIO_WIDGET_CAP); + unsigned int wcap = get_wcaps(codec, 0x07); wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ if (wcap != AC_WID_AUD_IN) { spec->adc_nids = alc882_adc_nids_alt; @@ -3991,8 +3994,8 @@ static int patch_alc262(struct hda_codec *codec) if (! spec->adc_nids && spec->input_mux) { /* check whether NID 0x07 is valid */ - unsigned int wcap = snd_hda_param_read(codec, 0x07, - AC_PAR_AUDIO_WIDGET_CAP); + unsigned int wcap = get_wcaps(codec, 0x07); + wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */ if (wcap != AC_WID_AUD_IN) { spec->adc_nids = alc262_adc_nids_alt; @@ -4423,9 +4426,6 @@ static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin) /* create playback/capture controls for input pins */ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg) { - static char *labels[AUTO_PIN_LAST] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" - }; struct hda_input_mux *imux = &spec->private_imux; int i, err, idx, idx1; @@ -4455,11 +4455,12 @@ static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const str continue; } - err = new_analog_input(spec, cfg->input_pins[i], labels[i], idx, 0x15); + err = new_analog_input(spec, cfg->input_pins[i], + auto_pin_cfg_labels[i], idx, 0x15); if (err < 0) return err; - imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; imux->items[imux->num_items].index = idx1; imux->num_items++; } diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 8311c9f..6190384 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c @@ -702,9 +702,6 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) { struct sigmatel_spec *spec = codec->spec; - static char *labels[AUTO_PIN_LAST] = { - "Mic", "Front Mic", "Line", "Front Line", "CD", "Aux" - }; struct hda_input_mux *imux = &spec->private_imux; hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; int i, j, k; @@ -715,7 +712,7 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const /* Enable active pin widget as an input */ stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN); - imux->items[imux->num_items].label = labels[i]; + imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; for (j=0; jnum_muxes; j++) { int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS); -- cgit v1.1 From 235475cb7715852c42118fd8d8ec67b534ab6e8b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Dec 2005 15:28:07 +0100 Subject: [ALSA] pcm - Fix wrong asserts Modules: PCM Midlevel Fixed wrong or supreflous snd_assert()'s. Signed-off-by: Takashi Iwai --- sound/core/pcm_lib.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index c58ec67..eeba2f0 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -56,9 +56,8 @@ void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_ufram runtime->silence_filled = 0; runtime->silence_start = runtime->control->appl_ptr; } - if (runtime->silence_filled == runtime->buffer_size) + if (runtime->silence_filled >= runtime->buffer_size) return; - snd_assert(runtime->silence_filled <= runtime->buffer_size, return); noise_dist = snd_pcm_playback_hw_avail(runtime) + runtime->silence_filled; if (noise_dist >= (snd_pcm_sframes_t) runtime->silence_threshold) return; @@ -2006,8 +2005,8 @@ void snd_pcm_tick_prepare(struct snd_pcm_substream *substream) runtime->silence_filled < runtime->buffer_size) { snd_pcm_sframes_t noise_dist; noise_dist = snd_pcm_playback_hw_avail(runtime) + runtime->silence_filled; - snd_assert(noise_dist <= (snd_pcm_sframes_t)runtime->silence_threshold, ); - frames = noise_dist - runtime->silence_threshold; + if (noise_dist > (snd_pcm_sframes_t)runtime->silence_threshold) + frames = noise_dist - runtime->silence_threshold; } avail = snd_pcm_playback_avail(runtime); } else { -- cgit v1.1 From 7632c7b4443057e1294208a0d9a55d8558f2f6ca Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 7 Dec 2005 18:25:47 +0100 Subject: [ALSA] hda-codec - Add the model entry for ASUS P5GD1-HVM Modules: HDA Codec driver Add the model entry (ALC880 6stack) for ASUS P5GD1-HVM. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index cac1092..55bda26 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1665,6 +1665,7 @@ static struct hda_board_config alc880_cfg_tbl[] = { { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V }, { .modelname = "6stack", .config = ALC880_6ST }, + { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */ { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST }, { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */ -- cgit v1.1 From 22fb2a708d2f390808f20609213fd6a588bf7612 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Dec 2005 09:27:14 +0100 Subject: [ALSA] ymfpci: show chip model Modules: YMFPCI driver Instead of 'DS-XG', show the correct chip model (DS-1/1L/1S/1E) where possible. Signed-off-by: Clemens Ladisch --- sound/pci/ymfpci/ymfpci.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 9e30e2c..dab9b83 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -31,7 +31,7 @@ #include MODULE_AUTHOR("Jaroslav Kysela "); -MODULE_DESCRIPTION("Yamaha DS-XG PCI"); +MODULE_DESCRIPTION("Yamaha DS-1 PCI"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Yamaha,YMF724}," "{Yamaha,YMF724F}," @@ -51,11 +51,11 @@ static long joystick_port[SNDRV_CARDS]; static int rear_switch[SNDRV_CARDS]; module_param_array(index, int, NULL, 0444); -MODULE_PARM_DESC(index, "Index value for the Yamaha DS-XG PCI soundcard."); +MODULE_PARM_DESC(index, "Index value for the Yamaha DS-1 PCI soundcard."); module_param_array(id, charp, NULL, 0444); -MODULE_PARM_DESC(id, "ID string for the Yamaha DS-XG PCI soundcard."); +MODULE_PARM_DESC(id, "ID string for the Yamaha DS-1 PCI soundcard."); module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable Yamaha DS-XG soundcard."); +MODULE_PARM_DESC(enable, "Enable Yamaha DS-1 soundcard."); module_param_array(mpu_port, long, NULL, 0444); MODULE_PARM_DESC(mpu_port, "MPU-401 Port."); module_param_array(fm_port, long, NULL, 0444); @@ -177,7 +177,7 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci, struct resource *mpu_res = NULL; struct snd_ymfpci *chip; struct snd_opl3 *opl3; - char *str; + const char *str, *model; int err; u16 legacy_ctrl, legacy_ctrl2, old_legacy_ctrl; @@ -193,13 +193,13 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci, return -ENOMEM; switch (pci_id->device) { - case 0x0004: str = "YMF724"; break; - case 0x000d: str = "YMF724F"; break; - case 0x000a: str = "YMF740"; break; - case 0x000c: str = "YMF740C"; break; - case 0x0010: str = "YMF744"; break; - case 0x0012: str = "YMF754"; break; - default: str = "???"; break; + case 0x0004: str = "YMF724"; model = "DS-1"; break; + case 0x000d: str = "YMF724F"; model = "DS-1"; break; + case 0x000a: str = "YMF740"; model = "DS-1L"; break; + case 0x000c: str = "YMF740C"; model = "DS-1L"; break; + case 0x0010: str = "YMF744"; model = "DS-1S"; break; + case 0x0012: str = "YMF754"; model = "DS-1E"; break; + default: model = str = "???"; break; } legacy_ctrl = 0; @@ -274,7 +274,7 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci, card->private_data = chip; strcpy(card->driver, str); - sprintf(card->shortname, "Yamaha DS-XG (%s)", str); + sprintf(card->shortname, "Yamaha %s (%s)", model, str); sprintf(card->longname, "%s at 0x%lx, irq %i", card->shortname, chip->reg_area_phys, @@ -345,7 +345,7 @@ static void __devexit snd_card_ymfpci_remove(struct pci_dev *pci) } static struct pci_driver driver = { - .name = "Yamaha DS-XG PCI", + .name = "Yamaha DS-1 PCI", .id_table = snd_ymfpci_ids, .probe = snd_card_ymfpci_probe, .remove = __devexit_p(snd_card_ymfpci_remove), -- cgit v1.1 From 255bd169ab645970f77d3fd7ac800781f96ddccb Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Dec 2005 09:28:51 +0100 Subject: [ALSA] seq: remove superfluous fields Modules: ALSA sequencer None of the fields of struct snd_seq_kernel_client was actually used, so remove them. Signed-off-by: Clemens Ladisch --- sound/core/seq/seq_clientmgr.c | 3 --- sound/core/seq/seq_clientmgr.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 9c32fd2..79199f5 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2247,9 +2247,6 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, client->accept_input = callback->allow_output; client->accept_output = callback->allow_input; - /* fill client data */ - client->data.kernel.card = card; - client->data.kernel.private_data = callback->private_data; sprintf(client->name, "Client-%d", client->number); client->type = KERNEL_CLIENT; diff --git a/sound/core/seq/seq_clientmgr.h b/sound/core/seq/seq_clientmgr.h index 9df5624..7131d21 100644 --- a/sound/core/seq/seq_clientmgr.h +++ b/sound/core/seq/seq_clientmgr.h @@ -40,9 +40,6 @@ struct snd_seq_user_client { }; struct snd_seq_kernel_client { - struct snd_card *card; - /* pointer to client functions */ - void *private_data; /* private data for client */ /* ... */ }; -- cgit v1.1 From 83e8ad6984dccd6d848ac91ba0df379ff968180b Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Dec 2005 09:30:43 +0100 Subject: [ALSA] seq: remove struct snd_seq_client_callback The fields of struct snd_seq_client_callback either aren't used or are always set to the same value, so we can get rid of it altogether. Signed-off-by: Clemens Ladisch --- include/sound/seq_kernel.h | 12 +----------- sound/core/seq/oss/seq_oss_init.c | 9 +-------- sound/core/seq/seq_clientmgr.c | 9 +++------ sound/core/seq/seq_clientmgr.h | 2 -- sound/core/seq/seq_dummy.c | 6 +----- sound/core/seq/seq_midi.c | 6 +----- sound/core/seq/seq_system.c | 6 +----- sound/core/seq/seq_virmidi.c | 7 +------ sound/drivers/opl3/opl3_seq.c | 6 +----- sound/drivers/opl4/opl4_seq.c | 6 +----- sound/isa/gus/gus_synth.c | 6 +----- sound/pci/trident/trident_synth.c | 6 +----- sound/synth/emux/emux_seq.c | 8 +------- 13 files changed, 14 insertions(+), 75 deletions(-) diff --git a/include/sound/seq_kernel.h b/include/sound/seq_kernel.h index 1b60890..77cf57e 100644 --- a/include/sound/seq_kernel.h +++ b/include/sound/seq_kernel.h @@ -60,15 +60,6 @@ typedef union snd_seq_timestamp snd_seq_timestamp_t; /* max size of event size */ #define SNDRV_SEQ_MAX_EVENT_LEN 0x3fffffff -/* call-backs for kernel client */ - -struct snd_seq_client_callback { - void *private_data; - unsigned allow_input: 1, - allow_output: 1; - /*...*/ -}; - /* call-backs for kernel port */ struct snd_seq_port_callback { struct module *owner; @@ -84,8 +75,7 @@ struct snd_seq_port_callback { }; /* interface for kernel client */ -int snd_seq_create_kernel_client(struct snd_card *card, int client_index, - struct snd_seq_client_callback *callback); +int snd_seq_create_kernel_client(struct snd_card *card, int client_index); int snd_seq_delete_kernel_client(int client); int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop); int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop); diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index 97e2493..cd4139ad 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c @@ -65,7 +65,6 @@ int __init snd_seq_oss_create_client(void) { int rc; - struct snd_seq_client_callback callback; struct snd_seq_client_info *info; struct snd_seq_port_info *port; struct snd_seq_port_callback port_callback; @@ -78,13 +77,7 @@ snd_seq_oss_create_client(void) } /* create ALSA client */ - memset(&callback, 0, sizeof(callback)); - - callback.private_data = NULL; - callback.allow_input = 1; - callback.allow_output = 1; - - rc = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_OSS, &callback); + rc = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_OSS); if (rc < 0) goto __error; diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 79199f5..bd8c098 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2212,15 +2212,12 @@ static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg /* exported to kernel modules */ -int snd_seq_create_kernel_client(struct snd_card *card, int client_index, - struct snd_seq_client_callback *callback) +int snd_seq_create_kernel_client(struct snd_card *card, int client_index) { struct snd_seq_client *client; snd_assert(! in_interrupt(), return -EBUSY); - if (callback == NULL) - return -EINVAL; if (card && client_index > 3) return -EINVAL; if (card == NULL && client_index > 63) @@ -2244,8 +2241,8 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, } usage_alloc(&client_usage, 1); - client->accept_input = callback->allow_output; - client->accept_output = callback->allow_input; + client->accept_input = 1; + client->accept_output = 1; sprintf(client->name, "Client-%d", client->number); diff --git a/sound/core/seq/seq_clientmgr.h b/sound/core/seq/seq_clientmgr.h index 7131d21..450091c 100644 --- a/sound/core/seq/seq_clientmgr.h +++ b/sound/core/seq/seq_clientmgr.h @@ -91,8 +91,6 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid); int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop); /* exported to other modules */ -int snd_seq_register_kernel_client(struct snd_seq_client_callback *callback, void *private_data); -int snd_seq_unregister_kernel_client(int client); int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop); int snd_seq_kernel_client_enqueue_blocking(int client, struct snd_seq_event * ev, struct file *file, int atomic, int hop); diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c index 8101a47..e7344b6 100644 --- a/sound/core/seq/seq_dummy.c +++ b/sound/core/seq/seq_dummy.c @@ -193,7 +193,6 @@ create_port(int idx, int type) static int __init register_client(void) { - struct snd_seq_client_callback cb; struct snd_seq_client_info cinfo; struct snd_seq_dummy_port *rec1, *rec2; int i; @@ -204,10 +203,7 @@ register_client(void) } /* create client */ - memset(&cb, 0, sizeof(cb)); - cb.allow_input = 1; - cb.allow_output = 1; - my_client = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_DUMMY, &cb); + my_client = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_DUMMY); if (my_client < 0) return my_client; diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index 0a65eb2..512ffdd 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -295,7 +295,6 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev) struct snd_rawmidi_info *info; int newclient = 0; unsigned int p, ports; - struct snd_seq_client_callback callbacks; struct snd_seq_port_callback pcallbacks; struct snd_card *card = dev->card; int device = dev->device; @@ -334,10 +333,7 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev) kfree(info); return -ENOMEM; } - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = client; - callbacks.allow_input = callbacks.allow_output = 1; - client->seq_client = snd_seq_create_kernel_client(card, 0, &callbacks); + client->seq_client = snd_seq_create_kernel_client(card, 0); if (client->seq_client < 0) { kfree(client); up(®ister_mutex); diff --git a/sound/core/seq/seq_system.c b/sound/core/seq/seq_system.c index 86b1cba..c87c883 100644 --- a/sound/core/seq/seq_system.c +++ b/sound/core/seq/seq_system.c @@ -120,8 +120,6 @@ static int event_input_timer(struct snd_seq_event * ev, int direct, void *privat /* register our internal client */ int __init snd_seq_system_client_init(void) { - - struct snd_seq_client_callback callbacks; struct snd_seq_port_callback pcallbacks; struct snd_seq_client_info *inf; struct snd_seq_port_info *port; @@ -134,14 +132,12 @@ int __init snd_seq_system_client_init(void) return -ENOMEM; } - memset(&callbacks, 0, sizeof(callbacks)); memset(&pcallbacks, 0, sizeof(pcallbacks)); pcallbacks.owner = THIS_MODULE; pcallbacks.event_input = event_input_timer; /* register client */ - callbacks.allow_input = callbacks.allow_output = 1; - sysclient = snd_seq_create_kernel_client(NULL, 0, &callbacks); + sysclient = snd_seq_create_kernel_client(NULL, 0); /* set our name */ inf->client = 0; diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index ea21139..2739f57 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -359,7 +359,6 @@ static struct snd_rawmidi_ops snd_virmidi_output_ops = { static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev) { int client; - struct snd_seq_client_callback callbacks; struct snd_seq_port_callback pcallbacks; struct snd_seq_client_info *info; struct snd_seq_port_info *pinfo; @@ -375,11 +374,7 @@ static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev) goto __error; } - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = rdev; - callbacks.allow_input = 1; - callbacks.allow_output = 1; - client = snd_seq_create_kernel_client(rdev->card, rdev->device, &callbacks); + client = snd_seq_create_kernel_client(rdev->card, rdev->device); if (client < 0) { err = client; goto __error; diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 1886b29..582ff63 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -219,7 +219,6 @@ static int snd_opl3_seq_new_device(struct snd_seq_device *dev) { struct snd_opl3 *opl3; int client; - struct snd_seq_client_callback callbacks; struct snd_seq_client_info cinfo; int opl_ver; @@ -232,11 +231,8 @@ static int snd_opl3_seq_new_device(struct snd_seq_device *dev) opl3->seq_client = -1; /* allocate new client */ - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = opl3; - callbacks.allow_output = callbacks.allow_input = 1; client = opl3->seq_client = - snd_seq_create_kernel_client(opl3->card, opl3->seq_dev_num, &callbacks); + snd_seq_create_kernel_client(opl3->card, opl3->seq_dev_num); if (client < 0) return client; diff --git a/sound/drivers/opl4/opl4_seq.c b/sound/drivers/opl4/opl4_seq.c index bfd68e4..a69117d 100644 --- a/sound/drivers/opl4/opl4_seq.c +++ b/sound/drivers/opl4/opl4_seq.c @@ -127,7 +127,6 @@ static int snd_opl4_seq_new_device(struct snd_seq_device *dev) { struct snd_opl4 *opl4; int client; - struct snd_seq_client_callback callbacks; struct snd_seq_client_info cinfo; struct snd_seq_port_callback pcallbacks; @@ -144,10 +143,7 @@ static int snd_opl4_seq_new_device(struct snd_seq_device *dev) opl4->chset->private_data = opl4; /* allocate new client */ - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = opl4; - callbacks.allow_output = callbacks.allow_input = 1; - client = snd_seq_create_kernel_client(opl4->card, opl4->seq_dev_num, &callbacks); + client = snd_seq_create_kernel_client(opl4->card, opl4->seq_dev_num); if (client < 0) { snd_midi_channel_free_set(opl4->chset); return client; diff --git a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c index 9c7d698..6464488 100644 --- a/sound/isa/gus/gus_synth.c +++ b/sound/isa/gus/gus_synth.c @@ -214,7 +214,6 @@ static int snd_gus_synth_new_device(struct snd_seq_device *dev) { struct snd_gus_card *gus; int client, i; - struct snd_seq_client_callback callbacks; struct snd_seq_client_info *cinfo; struct snd_seq_port_subscribe sub; struct snd_iwffff_ops *iwops; @@ -233,11 +232,8 @@ static int snd_gus_synth_new_device(struct snd_seq_device *dev) return -ENOMEM; /* allocate new client */ - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = gus; - callbacks.allow_output = callbacks.allow_input = 1; client = gus->gf1.seq_client = - snd_seq_create_kernel_client(gus->card, 1, &callbacks); + snd_seq_create_kernel_client(gus->card, 1); if (client < 0) { kfree(cinfo); return client; diff --git a/sound/pci/trident/trident_synth.c b/sound/pci/trident/trident_synth.c index a49682e..e31055a 100644 --- a/sound/pci/trident/trident_synth.c +++ b/sound/pci/trident/trident_synth.c @@ -934,7 +934,6 @@ static int snd_trident_synth_new_device(struct snd_seq_device *dev) { struct snd_trident *trident; int client, i; - struct snd_seq_client_callback callbacks; struct snd_seq_client_info cinfo; struct snd_seq_port_subscribe sub; struct snd_simple_ops *simpleops; @@ -947,11 +946,8 @@ static int snd_trident_synth_new_device(struct snd_seq_device *dev) trident->synth.seq_client = -1; /* allocate new client */ - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = trident; - callbacks.allow_output = callbacks.allow_input = 1; client = trident->synth.seq_client = - snd_seq_create_kernel_client(trident->card, 1, &callbacks); + snd_seq_create_kernel_client(trident->card, 1); if (client < 0) return client; diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index f5a832f..b7129c5 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -347,17 +347,11 @@ snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info) static int get_client(struct snd_card *card, int index, char *name) { - struct snd_seq_client_callback callbacks; struct snd_seq_client_info cinfo; int client; - memset(&callbacks, 0, sizeof(callbacks)); - callbacks.private_data = NULL; - callbacks.allow_input = 1; - callbacks.allow_output = 1; - /* Find a free client, start from 1 as the MPU expects to use 0 */ - client = snd_seq_create_kernel_client(card, index, &callbacks); + client = snd_seq_create_kernel_client(card, index); if (client < 0) return client; -- cgit v1.1 From 7b6d92451ad5e1136dc347347e888b94638b8ba9 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Dec 2005 09:33:37 +0100 Subject: [ALSA] seq: set client name in snd_seq_create_kernel_client() All users of snd_seq_create_kernel_client() have to set the client name anyway, so we can just pass the name as parameter. This relieves us from having to muck around with a struct snd_seq_client_info in these cases. Signed-off-by: Clemens Ladisch --- include/sound/seq_kernel.h | 4 +++- sound/core/seq/oss/seq_oss_init.c | 16 +++------------- sound/core/seq/seq_clientmgr.c | 8 ++++++-- sound/core/seq/seq_dummy.c | 11 ++--------- sound/core/seq/seq_midi.c | 24 +++++------------------- sound/core/seq/seq_system.c | 16 ++-------------- sound/core/seq/seq_virmidi.c | 17 +++++------------ sound/drivers/opl3/opl3_seq.c | 17 ++++++----------- sound/drivers/opl4/opl4_seq.c | 11 ++--------- sound/isa/gus/gus_synth.c | 20 +++----------------- sound/pci/trident/trident_synth.c | 16 ++++------------ sound/synth/emux/emux_seq.c | 29 ++--------------------------- 12 files changed, 43 insertions(+), 146 deletions(-) diff --git a/include/sound/seq_kernel.h b/include/sound/seq_kernel.h index 77cf57e..f023c1b 100644 --- a/include/sound/seq_kernel.h +++ b/include/sound/seq_kernel.h @@ -75,7 +75,9 @@ struct snd_seq_port_callback { }; /* interface for kernel client */ -int snd_seq_create_kernel_client(struct snd_card *card, int client_index); +int snd_seq_create_kernel_client(struct snd_card *card, int client_index, + const char *name_fmt, ...) + __attribute__ ((format (printf, 3, 4))); int snd_seq_delete_kernel_client(int client); int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop); int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop); diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c index cd4139ad..ca5a2ed 100644 --- a/sound/core/seq/oss/seq_oss_init.c +++ b/sound/core/seq/oss/seq_oss_init.c @@ -65,33 +65,24 @@ int __init snd_seq_oss_create_client(void) { int rc; - struct snd_seq_client_info *info; struct snd_seq_port_info *port; struct snd_seq_port_callback port_callback; - info = kmalloc(sizeof(*info), GFP_KERNEL); port = kmalloc(sizeof(*port), GFP_KERNEL); - if (!info || !port) { + if (!port) { rc = -ENOMEM; goto __error; } /* create ALSA client */ - rc = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_OSS); + rc = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_OSS, + "OSS sequencer"); if (rc < 0) goto __error; system_client = rc; debug_printk(("new client = %d\n", rc)); - /* set client information */ - memset(info, 0, sizeof(*info)); - info->client = system_client; - info->type = KERNEL_CLIENT; - strcpy(info->name, "OSS sequencer"); - - rc = call_ctl(SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, info); - /* look up midi devices */ snd_seq_oss_midi_lookup_ports(system_client); @@ -124,7 +115,6 @@ snd_seq_oss_create_client(void) __error: kfree(port); - kfree(info); return rc; } diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index bd8c098..606d076 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -2212,9 +2212,11 @@ static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg /* exported to kernel modules */ -int snd_seq_create_kernel_client(struct snd_card *card, int client_index) +int snd_seq_create_kernel_client(struct snd_card *card, int client_index, + const char *name_fmt, ...) { struct snd_seq_client *client; + va_list args; snd_assert(! in_interrupt(), return -EBUSY); @@ -2244,7 +2246,9 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index) client->accept_input = 1; client->accept_output = 1; - sprintf(client->name, "Client-%d", client->number); + va_start(args, name_fmt); + vsnprintf(client->name, sizeof(client->name), name_fmt, args); + va_end(args); client->type = KERNEL_CLIENT; up(®ister_mutex); diff --git a/sound/core/seq/seq_dummy.c b/sound/core/seq/seq_dummy.c index e7344b6..2a283a5 100644 --- a/sound/core/seq/seq_dummy.c +++ b/sound/core/seq/seq_dummy.c @@ -193,7 +193,6 @@ create_port(int idx, int type) static int __init register_client(void) { - struct snd_seq_client_info cinfo; struct snd_seq_dummy_port *rec1, *rec2; int i; @@ -203,17 +202,11 @@ register_client(void) } /* create client */ - my_client = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_DUMMY); + my_client = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_DUMMY, + "Midi Through"); if (my_client < 0) return my_client; - /* set client name */ - memset(&cinfo, 0, sizeof(cinfo)); - cinfo.client = my_client; - cinfo.type = KERNEL_CLIENT; - strcpy(cinfo.name, "Midi Through"); - snd_seq_kernel_client_ctl(my_client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo); - /* create ports */ for (i = 0; i < ports; i++) { rec1 = create_port(i, 0); diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index 512ffdd..ce0df86 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -270,21 +270,6 @@ static void snd_seq_midisynth_delete(struct seq_midisynth *msynth) snd_midi_event_free(msynth->parser); } -/* set our client name */ -static int set_client_name(struct seq_midisynth_client *client, struct snd_card *card, - struct snd_rawmidi_info *rmidi) -{ - struct snd_seq_client_info cinfo; - const char *name; - - memset(&cinfo, 0, sizeof(cinfo)); - cinfo.client = client->seq_client; - cinfo.type = KERNEL_CLIENT; - name = rmidi->name[0] ? (const char *)rmidi->name : "External MIDI"; - strlcpy(cinfo.name, name, sizeof(cinfo.name)); - return snd_seq_kernel_client_ctl(client->seq_client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo); -} - /* register new midi synth port */ static int snd_seq_midisynth_register_port(struct snd_seq_device *dev) @@ -333,16 +318,17 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev) kfree(info); return -ENOMEM; } - client->seq_client = snd_seq_create_kernel_client(card, 0); + client->seq_client = + snd_seq_create_kernel_client( + card, 0, "%s", info->name[0] ? + (const char *)info->name : "External MIDI"); if (client->seq_client < 0) { kfree(client); up(®ister_mutex); kfree(info); return -ENOMEM; } - set_client_name(client, card, info); - } else if (device == 0) - set_client_name(client, card, info); /* use the first device's name */ + } msynth = kcalloc(ports, sizeof(struct seq_midisynth), GFP_KERNEL); port = kmalloc(sizeof(*port), GFP_KERNEL); diff --git a/sound/core/seq/seq_system.c b/sound/core/seq/seq_system.c index c87c883..b201b76 100644 --- a/sound/core/seq/seq_system.c +++ b/sound/core/seq/seq_system.c @@ -121,29 +121,18 @@ static int event_input_timer(struct snd_seq_event * ev, int direct, void *privat int __init snd_seq_system_client_init(void) { struct snd_seq_port_callback pcallbacks; - struct snd_seq_client_info *inf; struct snd_seq_port_info *port; - inf = kzalloc(sizeof(*inf), GFP_KERNEL); port = kzalloc(sizeof(*port), GFP_KERNEL); - if (! inf || ! port) { - kfree(inf); - kfree(port); + if (!port) return -ENOMEM; - } memset(&pcallbacks, 0, sizeof(pcallbacks)); pcallbacks.owner = THIS_MODULE; pcallbacks.event_input = event_input_timer; /* register client */ - sysclient = snd_seq_create_kernel_client(NULL, 0); - - /* set our name */ - inf->client = 0; - inf->type = KERNEL_CLIENT; - strcpy(inf->name, "System"); - snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, inf); + sysclient = snd_seq_create_kernel_client(NULL, 0, "System"); /* register timer */ strcpy(port->name, "Timer"); @@ -167,7 +156,6 @@ int __init snd_seq_system_client_init(void) snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, port); announce_port = port->addr.port; - kfree(inf); kfree(port); return 0; } diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c index 2739f57..14fd1a6 100644 --- a/sound/core/seq/seq_virmidi.c +++ b/sound/core/seq/seq_virmidi.c @@ -360,34 +360,28 @@ static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev) { int client; struct snd_seq_port_callback pcallbacks; - struct snd_seq_client_info *info; struct snd_seq_port_info *pinfo; int err; if (rdev->client >= 0) return 0; - info = kmalloc(sizeof(*info), GFP_KERNEL); pinfo = kmalloc(sizeof(*pinfo), GFP_KERNEL); - if (! info || ! pinfo) { + if (!pinfo) { err = -ENOMEM; goto __error; } - client = snd_seq_create_kernel_client(rdev->card, rdev->device); + client = snd_seq_create_kernel_client(rdev->card, rdev->device, + "%s %d-%d", rdev->rmidi->name, + rdev->card->number, + rdev->device); if (client < 0) { err = client; goto __error; } rdev->client = client; - /* set client name */ - memset(info, 0, sizeof(*info)); - info->client = client; - info->type = KERNEL_CLIENT; - sprintf(info->name, "%s %d-%d", rdev->rmidi->name, rdev->card->number, rdev->device); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, info); - /* create a port */ memset(pinfo, 0, sizeof(*pinfo)); pinfo->addr.client = client; @@ -418,7 +412,6 @@ static int snd_virmidi_dev_attach_seq(struct snd_virmidi_dev *rdev) err = 0; /* success */ __error: - kfree(info); kfree(pinfo); return err; } diff --git a/sound/drivers/opl3/opl3_seq.c b/sound/drivers/opl3/opl3_seq.c index 582ff63..c4ead79 100644 --- a/sound/drivers/opl3/opl3_seq.c +++ b/sound/drivers/opl3/opl3_seq.c @@ -219,7 +219,7 @@ static int snd_opl3_seq_new_device(struct snd_seq_device *dev) { struct snd_opl3 *opl3; int client; - struct snd_seq_client_info cinfo; + char name[32]; int opl_ver; opl3 = *(struct snd_opl3 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); @@ -231,19 +231,14 @@ static int snd_opl3_seq_new_device(struct snd_seq_device *dev) opl3->seq_client = -1; /* allocate new client */ + opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; + sprintf(name, "OPL%i FM synth", opl_ver); client = opl3->seq_client = - snd_seq_create_kernel_client(opl3->card, opl3->seq_dev_num); + snd_seq_create_kernel_client(opl3->card, opl3->seq_dev_num, + name); if (client < 0) return client; - /* change name of client */ - memset(&cinfo, 0, sizeof(cinfo)); - cinfo.client = client; - cinfo.type = KERNEL_CLIENT; - opl_ver = (opl3->hardware & OPL3_HW_MASK) >> 8; - sprintf(cinfo.name, "OPL%i FM synth", opl_ver); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo); - snd_opl3_synth_create_port(opl3); /* initialize instrument list */ @@ -264,7 +259,7 @@ static int snd_opl3_seq_new_device(struct snd_seq_device *dev) opl3->sys_timer_status = 0; #ifdef CONFIG_SND_SEQUENCER_OSS - snd_opl3_init_seq_oss(opl3, cinfo.name); + snd_opl3_init_seq_oss(opl3, name); #endif return 0; } diff --git a/sound/drivers/opl4/opl4_seq.c b/sound/drivers/opl4/opl4_seq.c index a69117d..e348032 100644 --- a/sound/drivers/opl4/opl4_seq.c +++ b/sound/drivers/opl4/opl4_seq.c @@ -127,7 +127,6 @@ static int snd_opl4_seq_new_device(struct snd_seq_device *dev) { struct snd_opl4 *opl4; int client; - struct snd_seq_client_info cinfo; struct snd_seq_port_callback pcallbacks; opl4 = *(struct snd_opl4 **)SNDRV_SEQ_DEVICE_ARGPTR(dev); @@ -143,7 +142,8 @@ static int snd_opl4_seq_new_device(struct snd_seq_device *dev) opl4->chset->private_data = opl4; /* allocate new client */ - client = snd_seq_create_kernel_client(opl4->card, opl4->seq_dev_num); + client = snd_seq_create_kernel_client(opl4->card, opl4->seq_dev_num, + "OPL4 Wavetable"); if (client < 0) { snd_midi_channel_free_set(opl4->chset); return client; @@ -151,13 +151,6 @@ static int snd_opl4_seq_new_device(struct snd_seq_device *dev) opl4->seq_client = client; opl4->chset->client = client; - /* change name of client */ - memset(&cinfo, 0, sizeof(cinfo)); - cinfo.client = client; - cinfo.type = KERNEL_CLIENT; - strcpy(cinfo.name, "OPL4 Wavetable"); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo); - /* create new port */ memset(&pcallbacks, 0, sizeof(pcallbacks)); pcallbacks.owner = THIS_MODULE; diff --git a/sound/isa/gus/gus_synth.c b/sound/isa/gus/gus_synth.c index 6464488..85a1b05 100644 --- a/sound/isa/gus/gus_synth.c +++ b/sound/isa/gus/gus_synth.c @@ -214,7 +214,6 @@ static int snd_gus_synth_new_device(struct snd_seq_device *dev) { struct snd_gus_card *gus; int client, i; - struct snd_seq_client_info *cinfo; struct snd_seq_port_subscribe sub; struct snd_iwffff_ops *iwops; struct snd_gf1_ops *gf1ops; @@ -227,25 +226,12 @@ static int snd_gus_synth_new_device(struct snd_seq_device *dev) init_MUTEX(&gus->register_mutex); gus->gf1.seq_client = -1; - cinfo = kmalloc(sizeof(*cinfo), GFP_KERNEL); - if (! cinfo) - return -ENOMEM; - /* allocate new client */ client = gus->gf1.seq_client = - snd_seq_create_kernel_client(gus->card, 1); - if (client < 0) { - kfree(cinfo); + snd_seq_create_kernel_client(gus->card, 1, gus->interwave ? + "AMD InterWave" : "GF1"); + if (client < 0) return client; - } - - /* change name of client */ - memset(cinfo, 0, sizeof(*cinfo)); - cinfo->client = client; - cinfo->type = KERNEL_CLIENT; - sprintf(cinfo->name, gus->interwave ? "AMD InterWave" : "GF1"); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, cinfo); - kfree(cinfo); for (i = 0; i < 4; i++) snd_gus_synth_create_port(gus, i); diff --git a/sound/pci/trident/trident_synth.c b/sound/pci/trident/trident_synth.c index e31055a..cc7af8b 100644 --- a/sound/pci/trident/trident_synth.c +++ b/sound/pci/trident/trident_synth.c @@ -934,7 +934,6 @@ static int snd_trident_synth_new_device(struct snd_seq_device *dev) { struct snd_trident *trident; int client, i; - struct snd_seq_client_info cinfo; struct snd_seq_port_subscribe sub; struct snd_simple_ops *simpleops; char *str; @@ -946,23 +945,16 @@ static int snd_trident_synth_new_device(struct snd_seq_device *dev) trident->synth.seq_client = -1; /* allocate new client */ - client = trident->synth.seq_client = - snd_seq_create_kernel_client(trident->card, 1); - if (client < 0) - return client; - - /* change name of client */ - memset(&cinfo, 0, sizeof(cinfo)); - cinfo.client = client; - cinfo.type = KERNEL_CLIENT; str = "???"; switch (trident->device) { case TRIDENT_DEVICE_ID_DX: str = "Trident 4DWave-DX"; break; case TRIDENT_DEVICE_ID_NX: str = "Trident 4DWave-NX"; break; case TRIDENT_DEVICE_ID_SI7018: str = "SiS 7018"; break; } - sprintf(cinfo.name, str); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo); + client = trident->synth.seq_client = + snd_seq_create_kernel_client(trident->card, 1, str); + if (client < 0) + return client; for (i = 0; i < 4; i++) snd_trident_synth_create_port(trident, i); diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c index b7129c5..1a973d7 100644 --- a/sound/synth/emux/emux_seq.c +++ b/sound/synth/emux/emux_seq.c @@ -28,7 +28,6 @@ static void free_port(void *private); static void snd_emux_init_port(struct snd_emux_port *p); static int snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info); static int snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info); -static int get_client(struct snd_card *card, int index, char *name); /* * MIDI emulation operators @@ -71,8 +70,8 @@ snd_emux_init_seq(struct snd_emux *emu, struct snd_card *card, int index) struct snd_seq_port_callback pinfo; char tmpname[64]; - sprintf(tmpname, "%s WaveTable", emu->name); - emu->client = get_client(card, index, tmpname); + emu->client = snd_seq_create_kernel_client(card, index, + "%s WaveTable", emu->name); if (emu->client < 0) { snd_printk("can't create client\n"); return -ENODEV; @@ -342,30 +341,6 @@ snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info) /* - * Create a sequencer client - */ -static int -get_client(struct snd_card *card, int index, char *name) -{ - struct snd_seq_client_info cinfo; - int client; - - /* Find a free client, start from 1 as the MPU expects to use 0 */ - client = snd_seq_create_kernel_client(card, index); - if (client < 0) - return client; - - memset(&cinfo, 0, sizeof(cinfo)); - cinfo.client = client; - cinfo.type = KERNEL_CLIENT; - strcpy(cinfo.name, name); - snd_seq_kernel_client_ctl(client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo); - - return client; -} - - -/* * attach virtual rawmidi devices */ int snd_emux_init_virmidi(struct snd_emux *emu, struct snd_card *card) -- cgit v1.1 From aa1e77e691025149908f7641e77de93ffd7f1188 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Mon, 12 Dec 2005 09:36:01 +0100 Subject: [ALSA] seq: reorganize sequencer client numbers Modules: ALSA sequencer Reduce the maximum possible number of global clients to 16 to make more numbers available for card clients, and allow dynamically allocated card client numbers to share the same range as application client numbers to make sure that all 32 cards can be used at the same time. Signed-off-by: Clemens Ladisch --- include/sound/asequencer.h | 5 ++-- sound/core/seq/seq.c | 4 +-- sound/core/seq/seq_clientmgr.c | 57 +++++++++++++++++++++++------------------- 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/include/sound/asequencer.h b/include/sound/asequencer.h index 59485be..6691e4a 100644 --- a/include/sound/asequencer.h +++ b/include/sound/asequencer.h @@ -502,8 +502,9 @@ struct snd_seq_running_info { /* known client numbers */ #define SNDRV_SEQ_CLIENT_SYSTEM 0 -#define SNDRV_SEQ_CLIENT_DUMMY 62 /* dummy ports */ -#define SNDRV_SEQ_CLIENT_OSS 63 /* oss sequencer emulator */ + /* internal client numbers */ +#define SNDRV_SEQ_CLIENT_DUMMY 14 /* midi through */ +#define SNDRV_SEQ_CLIENT_OSS 15 /* oss sequencer emulator */ /* client types */ diff --git a/sound/core/seq/seq.c b/sound/core/seq/seq.c index 24644150..20f954b 100644 --- a/sound/core/seq/seq.c +++ b/sound/core/seq/seq.c @@ -36,9 +36,9 @@ #include #if defined(CONFIG_SND_SEQ_DUMMY_MODULE) -int seq_client_load[64] = {[0] = SNDRV_SEQ_CLIENT_DUMMY, [1 ... 63] = -1}; +int seq_client_load[15] = {[0] = SNDRV_SEQ_CLIENT_DUMMY, [1 ... 14] = -1}; #else -int seq_client_load[64] = {[0 ... 63] = -1}; +int seq_client_load[15] = {[0 ... 14] = -1}; #endif int seq_default_timer_class = SNDRV_TIMER_CLASS_GLOBAL; int seq_default_timer_sclass = SNDRV_TIMER_SCLASS_NONE; diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c index 606d076..fd2032e 100644 --- a/sound/core/seq/seq_clientmgr.c +++ b/sound/core/seq/seq_clientmgr.c @@ -47,9 +47,20 @@ * */ -/* range for dynamically allocated client numbers of kernel drivers */ -#define SNDRV_SEQ_DYNAMIC_CLIENT_BEGIN 16 -#define SNDRV_SEQ_DYNAMIC_CLIENT_END 48 +/* + * There are four ranges of client numbers (last two shared): + * 0..15: global clients + * 16..127: statically allocated client numbers for cards 0..27 + * 128..191: dynamically allocated client numbers for cards 28..31 + * 128..191: dynamically allocated client numbers for applications + */ + +/* number of kernel non-card clients */ +#define SNDRV_SEQ_GLOBAL_CLIENTS 16 +/* clients per cards, for static clients */ +#define SNDRV_SEQ_CLIENTS_PER_CARD 4 +/* dynamically allocated client numbers (both kernel drivers and user space) */ +#define SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN 128 #define SNDRV_SEQ_LFLG_INPUT 0x0001 #define SNDRV_SEQ_LFLG_OUTPUT 0x0002 @@ -143,14 +154,14 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid) spin_unlock_irqrestore(&clients_lock, flags); #ifdef CONFIG_KMOD if (!in_interrupt() && current->fs->root) { - static char client_requested[64]; + static char client_requested[SNDRV_SEQ_GLOBAL_CLIENTS]; static char card_requested[SNDRV_CARDS]; - if (clientid < 64) { + if (clientid < SNDRV_SEQ_GLOBAL_CLIENTS) { int idx; if (! client_requested[clientid] && current->fs->root) { client_requested[clientid] = 1; - for (idx = 0; idx < 64; idx++) { + for (idx = 0; idx < 15; idx++) { if (seq_client_load[idx] < 0) break; if (seq_client_load[idx] == clientid) { @@ -160,8 +171,9 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid) } } } - } else if (clientid >= 64 && clientid < 128) { - int card = (clientid - 64) / 4; + } else if (clientid < SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN) { + int card = (clientid - SNDRV_SEQ_GLOBAL_CLIENTS) / + SNDRV_SEQ_CLIENTS_PER_CARD; if (card < snd_ecards_limit) { if (! card_requested[card]) { card_requested[card] = 1; @@ -207,8 +219,7 @@ int __init client_init_data(void) } -static struct snd_seq_client *seq_create_client1(int client_index, int poolsize, - int kernel_client) +static struct snd_seq_client *seq_create_client1(int client_index, int poolsize) { unsigned long flags; int c; @@ -232,15 +243,9 @@ static struct snd_seq_client *seq_create_client1(int client_index, int poolsize, /* find free slot in the client table */ spin_lock_irqsave(&clients_lock, flags); if (client_index < 0) { - int cmin, cmax; - if (kernel_client) { - cmin = SNDRV_SEQ_DYNAMIC_CLIENT_BEGIN; - cmax = SNDRV_SEQ_DYNAMIC_CLIENT_END; - } else { - cmin = 128; - cmax = SNDRV_SEQ_MAX_CLIENTS; - } - for (c = cmin; c < cmax; c++) { + for (c = SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN; + c < SNDRV_SEQ_MAX_CLIENTS; + c++) { if (clienttab[c] || clienttablock[c]) continue; clienttab[client->number = c] = client; @@ -319,7 +324,7 @@ static int snd_seq_open(struct inode *inode, struct file *file) if (down_interruptible(®ister_mutex)) return -ERESTARTSYS; - client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS, 0); + client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS); if (client == NULL) { up(®ister_mutex); return -ENOMEM; /* failure code */ @@ -2220,23 +2225,23 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index, snd_assert(! in_interrupt(), return -EBUSY); - if (card && client_index > 3) + if (card && client_index >= SNDRV_SEQ_CLIENTS_PER_CARD) return -EINVAL; - if (card == NULL && client_index > 63) + if (card == NULL && client_index >= SNDRV_SEQ_GLOBAL_CLIENTS) return -EINVAL; if (down_interruptible(®ister_mutex)) return -ERESTARTSYS; if (card) { - if (card->number < 16) - client_index += 64 + (card->number << 2); - else + client_index += SNDRV_SEQ_GLOBAL_CLIENTS + + card->number * SNDRV_SEQ_CLIENTS_PER_CARD; + if (client_index >= SNDRV_SEQ_DYNAMIC_CLIENTS_BEGIN) client_index = -1; } /* empty write queue as default */ - client = seq_create_client1(client_index, 0, 1); + client = seq_create_client1(client_index, 0); if (client == NULL) { up(®ister_mutex); return -EBUSY; /* failure code */ -- cgit v1.1 From ea265c0a433fda15fb69b9fd733e0ea4215c216e Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Mon, 12 Dec 2005 15:41:47 +0100 Subject: [ALSA] make the pxa2xx-ac97 module more robust against PXA27x bugs Modules: ARM PXA2XX driver The SDONE and CDONE interrupt on the PXA27x might become unusable in some conditions. Let's use an hybrid approach (interrupt with timeout) to have the best possible behavior in all conditions. Also let's not care about CAR_CAIP anymore. This is useless. Signed-off-by: Nicolas Pitre Signed-off-by: Takashi Iwai --- sound/arm/pxa2xx-ac97.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c index dda64be..3acbc60 100644 --- a/sound/arm/pxa2xx-ac97.c +++ b/sound/arm/pxa2xx-ac97.c @@ -37,39 +37,47 @@ static DECLARE_MUTEX(car_mutex); static DECLARE_WAIT_QUEUE_HEAD(gsr_wq); static volatile long gsr_bits; +/* + * Beware PXA27x bugs: + * + * o Slot 12 read from modem space will hang controller. + * o CDONE, SDONE interrupt fails after any slot 12 IO. + * + * We therefore have an hybrid approach for waiting on SDONE (interrupt or + * 1 jiffy timeout if interrupt never comes). + */ + static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97, unsigned short reg) { unsigned short val = -1; volatile u32 *reg_addr; down(&car_mutex); - if (CAR & CAR_CAIP) { - printk(KERN_CRIT"%s: CAR_CAIP already set\n", __FUNCTION__); - goto out; - } /* set up primary or secondary codec space */ reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE; reg_addr += (reg >> 1); /* start read access across the ac97 link */ + GSR = GSR_CDONE | GSR_SDONE; gsr_bits = 0; val = *reg_addr; if (reg == AC97_GPIO_STATUS) goto out; - wait_event_timeout(gsr_wq, gsr_bits & GSR_SDONE, 1); - if (!gsr_bits & GSR_SDONE) { + if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1) <= 0 && + !((GSR | gsr_bits) & GSR_SDONE)) { printk(KERN_ERR "%s: read error (ac97_reg=%d GSR=%#lx)\n", - __FUNCTION__, reg, gsr_bits); + __FUNCTION__, reg, GSR | gsr_bits); val = -1; goto out; } /* valid data now */ + GSR = GSR_CDONE | GSR_SDONE; gsr_bits = 0; val = *reg_addr; /* but we've just started another cycle... */ - wait_event_timeout(gsr_wq, gsr_bits & GSR_SDONE, 1); + wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1); out: up(&car_mutex); return val; @@ -81,22 +89,19 @@ static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigne down(&car_mutex); - if (CAR & CAR_CAIP) { - printk(KERN_CRIT "%s: CAR_CAIP already set\n", __FUNCTION__); - goto out; - } - /* set up primary or secondary codec space */ reg_addr = (ac97->num & 1) ? &SAC_REG_BASE : &PAC_REG_BASE; reg_addr += (reg >> 1); + + GSR = GSR_CDONE | GSR_SDONE; gsr_bits = 0; *reg_addr = val; - wait_event_timeout(gsr_wq, gsr_bits & GSR_CDONE, 1); - if (!gsr_bits & GSR_SDONE) + if (wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1) <= 0 && + !((GSR | gsr_bits) & GSR_CDONE)) printk(KERN_ERR "%s: write error (ac97_reg=%d GSR=%#lx)\n", - __FUNCTION__, reg, gsr_bits); + __FUNCTION__, reg, GSR | gsr_bits); -out: up(&car_mutex); + up(&car_mutex); } static void pxa2xx_ac97_reset(struct snd_ac97 *ac97) -- cgit v1.1 From 607da7f834592a723797b21c2463507a44d9cfa7 Mon Sep 17 00:00:00 2001 From: Rene Herman Date: Wed, 14 Dec 2005 11:57:27 +0100 Subject: [ALSA] es1968 - Fix conflict with ISA boards Modules: ES1968 driver Fix disablement of TDMA and legacy support to prevent confliction of resources with ISA boards. Confirmed with Terratec DMX and CS4236. Signed-off-by: Takashi Iwai --- sound/pci/es1968.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index 240cf2b4..9ffb600 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -176,7 +176,7 @@ MODULE_PARM_DESC(joystick, "Enable joystick."); /* Values for the ESM_LEGACY_AUDIO_CONTROL */ -#define ESS_ENABLE_AUDIO 0x8000 +#define ESS_DISABLE_AUDIO 0x8000 #define ESS_ENABLE_SERIAL_IRQ 0x4000 #define IO_ADRESS_ALIAS 0x0020 #define MPU401_IRQ_ENABLE 0x0010 @@ -195,7 +195,7 @@ MODULE_PARM_DESC(joystick, "Enable joystick."); #define DMA_TDMA 0x0100 #define DMA_PCPCI 0x0200 #define POST_WRITE 0x0080 -#define ISA_TIMING 0x0040 +#define PCI_TIMING 0x0040 #define SWAP_LR 0x0020 #define SUBTR_DECODE 0x0002 @@ -2193,14 +2193,11 @@ static void snd_es1968_chip_init(struct es1968 *chip) /* Config Reg A */ pci_read_config_word(pci, ESM_CONFIG_A, &w); - /* Use TDMA for now. TDMA works on all boards, so while its - * not the most efficient its the simplest. */ w &= ~DMA_CLEAR; /* Clear DMA bits */ - w |= DMA_TDMA; /* TDMA on */ w &= ~(PIC_SNOOP1 | PIC_SNOOP2); /* Clear Pic Snoop Mode Bits */ w &= ~SAFEGUARD; /* Safeguard off */ w |= POST_WRITE; /* Posted write */ - w |= ISA_TIMING; /* ISA timing on */ + w |= PCI_TIMING; /* PCI timing on */ /* XXX huh? claims to be reserved.. */ w &= ~SWAP_LR; /* swap left/right seems to only have effect on SB @@ -2241,7 +2238,7 @@ static void snd_es1968_chip_init(struct es1968 *chip) pci_read_config_word(pci, ESM_LEGACY_AUDIO_CONTROL, &w); - w &= ~ESS_ENABLE_AUDIO; /* Disable Legacy Audio */ + w |= ESS_DISABLE_AUDIO; /* Disable Legacy Audio */ w &= ~ESS_ENABLE_SERIAL_IRQ; /* Disable SIRQ */ w &= ~(0x1f); /* disable mpu irq/io, game port, fm, SB */ -- cgit v1.1 From dac8dddd87b1246d9d6b79352bd6f043eb804cf2 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 14 Dec 2005 12:00:46 +0100 Subject: [ALSA] via82xx - Add a quirk for Targa Traveller 811 Modules: VIA82xx driver Add an ac97 quirk entry for Targa Traveller 811. Signed-off-by: Takashi Iwai --- sound/pci/via82xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 6e6eff3..ed26a15 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1763,6 +1763,12 @@ static struct ac97_quirk ac97_quirks[] = { .name = "Arima Notebook", .type = AC97_TUNE_HP_ONLY, }, + { + .subvendor = 0x161f, + .subdevice = 0x2032, + .name = "Targa Traveller 811", + .type = AC97_TUNE_HP_ONLY, + }, { } /* terminator */ }; -- cgit v1.1 From 39596dc898270fcaaa8a712b63fc033f86d874cf Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Fri, 16 Dec 2005 21:59:59 +0100 Subject: [ALSA] snd-ca0106: update SPDIF to IEC958 in mixer control names. Modules: CA0106 driver Signed-off-by: James Courtier-Dutton --- sound/pci/ca0106/ca0106_mixer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 39100cb..06fe055 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -130,7 +130,7 @@ static int snd_ca0106_capture_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { static char *texts[6] = { - "SPDIF out", "i2s mixer out", "SPDIF in", "i2s in", "AC97 in", "SRC out" + "IEC958 out", "i2s mixer out", "IEC958 in", "i2s in", "AC97 in", "SRC out" }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -349,13 +349,13 @@ static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = { CA_VOLUME("Analog Side Playback Volume", CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME2), - CA_VOLUME("SPDIF Front Playback Volume", + CA_VOLUME("IEC958 Front Playback Volume", CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME1), - CA_VOLUME("SPDIF Rear Playback Volume", + CA_VOLUME("IEC958 Rear Playback Volume", CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME1), - CA_VOLUME("SPDIF Center/LFE Playback Volume", + CA_VOLUME("IEC958 Center/LFE Playback Volume", CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME1), - CA_VOLUME("SPDIF Unknown Playback Volume", + CA_VOLUME("IEC958 Unknown Playback Volume", CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME1), CA_VOLUME("CAPTURE feedback Playback Volume", @@ -371,7 +371,7 @@ static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = { }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "SPDIF Out", + .name = "IEC958 Playback Switch", .info = snd_ca0106_shared_spdif_info, .get = snd_ca0106_shared_spdif_get, .put = snd_ca0106_shared_spdif_put -- cgit v1.1 From a5875159dd6cec0ec743971343aee8dceac281d7 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Tue, 20 Dec 2005 22:30:49 +0100 Subject: [ALSA] snd-ca0106: Fixes sound output for Creative Audigy SE aka.SB0570. Modules: CA0106 driver Fixes ALSA bug#1636 Signed-off-by: James Courtier-Dutton --- sound/pci/ca0106/ca0106.h | 1 + sound/pci/ca0106/ca0106_main.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h index 7088317..c8131ea 100644 --- a/sound/pci/ca0106/ca0106.h +++ b/sound/pci/ca0106/ca0106.h @@ -577,6 +577,7 @@ struct snd_ca0106_details { int ac97; int gpio_type; int i2c_adc; + int spi_dac; }; // definition of the chip-specific record diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 5964cdc..1cf6f1f 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -183,6 +183,17 @@ static struct snd_ca0106_details ca0106_chip_details[] = { .name = "Live! 7.1 24bit [SB0413]", .gpio_type = 1, .i2c_adc = 1 } , + /* New Audigy SE. Has a different DAC. */ + /* SB0570: + * CTRL:CA0106-DAT + * ADC: WM8768GEDS + * DAC: WM8775EDS + */ + { .serial = 0x100a1102, + .name = "Audigy SE [SB0570]", + .gpio_type = 1, + .i2c_adc = 1, + .spi_dac = 1 } , /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ { .serial = 0x10091462, .name = "MSI K8N Diamond MB [SB0438]", @@ -273,6 +284,20 @@ void snd_ca0106_ptr_write(struct snd_ca0106 *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } +int snd_ca0106_spi_write(struct snd_ca0106 *emu, + u32 value) +{ + snd_ca0106_ptr_write(emu, SPI, 0, value); + return 0; +} + +int snd_ca0106_spi_read(struct snd_ca0106 *emu, + u32 *value) +{ + *value = snd_ca0106_ptr_read(emu, SPI, 0); + return 0; +} + int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value) @@ -1304,6 +1329,13 @@ static int __devinit snd_ca0106_create(struct snd_card *card, if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ } + if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */ + u32 tmp; + snd_ca0106_spi_write(chip, 0xf0622); /* Enable speakers output. */ + snd_ca0106_spi_read(chip, &tmp); /* Read the value. */ + snd_ca0106_spi_write(chip, 0xe1400); + snd_ca0106_spi_read(chip, &tmp); /* Read the value. */ + } if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { -- cgit v1.1 From 27fe864ec9e61041fc0b6f680207ae84f359b502 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Wed, 21 Dec 2005 15:06:08 +0100 Subject: [ALSA] snd-emu10k1: Removes some distortion from Audigy 2 ZS Notebook. Modules: EMU10K1/EMU10K2 driver Description: Part way to fix ALSA bug#927 Add support for the SPI interface on the CA0108 chip. This is used to control the registers on the DAC. Headphone output tested. Other outputs and Capture not tested yet. Note: The red LED does not come on, but sound is still OK. Signed-off-by: James Courtier-Dutton --- include/sound/emu10k1.h | 3 +++ sound/pci/emu10k1/emu10k1_main.c | 28 +++++++++++++++++++++++++++- sound/pci/emu10k1/io.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h index 0d6e68c..951e40d 100644 --- a/include/sound/emu10k1.h +++ b/include/sound/emu10k1.h @@ -1062,6 +1062,8 @@ struct snd_emu_chip_details { unsigned char ac97_chip; /* Has an AC97 chip: 1 = mandatory, 2 = optional */ unsigned char ecard; /* APS EEPROM */ unsigned char emu1212m; /* EMU 1212m card */ + unsigned char spi_dac; /* SPI interface for DAC */ + unsigned char i2c_adc; /* I2C interface for ADC */ const char *driver; const char *name; const char *id; /* for backward compatibility - can be NULL if not needed */ @@ -1203,6 +1205,7 @@ unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, un void snd_emu10k1_ptr_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data); unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn); void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data); +int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int data); unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc); void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb); void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb); diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index f8e2ccd..eb09370 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -181,7 +181,32 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) tmp = inl(emu->port + A_IOCFG) & ~0x8; /* Clear bit 3 */ outl(tmp, emu->port + A_IOCFG); } - + if (emu->card_capabilities->spi_dac) { /* Audigy 2 ZS Notebook with DAC Wolfson WM8768/WM8568 */ + u32 tmp; + tmp = snd_emu10k1_spi_write(emu, 0x00ff); + tmp = snd_emu10k1_spi_write(emu, 0x02ff); + tmp = snd_emu10k1_spi_write(emu, 0x0400); + tmp = snd_emu10k1_spi_write(emu, 0x0520); + tmp = snd_emu10k1_spi_write(emu, 0x0600); + tmp = snd_emu10k1_spi_write(emu, 0x08ff); + tmp = snd_emu10k1_spi_write(emu, 0x0aff); + tmp = snd_emu10k1_spi_write(emu, 0x0cff); + tmp = snd_emu10k1_spi_write(emu, 0x0eff); + tmp = snd_emu10k1_spi_write(emu, 0x10ff); + tmp = snd_emu10k1_spi_write(emu, 0x1200); + tmp = snd_emu10k1_spi_write(emu, 0x1400); + tmp = snd_emu10k1_spi_write(emu, 0x1480); + tmp = snd_emu10k1_spi_write(emu, 0x1800); + tmp = snd_emu10k1_spi_write(emu, 0x1aff); + tmp = snd_emu10k1_spi_write(emu, 0x1cff); + tmp = snd_emu10k1_spi_write(emu, 0x1e00); + tmp = snd_emu10k1_spi_write(emu, 0x0530); + tmp = snd_emu10k1_spi_write(emu, 0x0602); + tmp = snd_emu10k1_spi_write(emu, 0x0622); + tmp = snd_emu10k1_spi_write(emu, 0x1400); + snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10); + } + snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */ snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */ @@ -747,6 +772,7 @@ static struct snd_emu_chip_details emu_chip_details[] = { .emu10k2_chip = 1, .ca0108_chip = 1, .ca_cardbus_chip = 1, + .spi_dac = 1, .spk71 = 1} , {.vendor = 0x1102, .device = 0x0008, .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index 5d116dd..7d0cb9d 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -29,6 +29,7 @@ #include #include #include +#include unsigned int snd_emu10k1_ptr_read(struct snd_emu10k1 * emu, unsigned int reg, unsigned int chn) { @@ -123,6 +124,41 @@ void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } +int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, + unsigned int data) +{ + unsigned int reset, set; + unsigned int reg, tmp; + int n, result; + if (emu->card_capabilities->ca0108_chip) { + reg=0x3c; /* PTR20, reg 0x3c */ + } else { + return 1; /* For other cards types the SPI register is currently unknown. */ + } + if (data > 0xffff) return 1; /* Only 16bit values allowed */ + + tmp = snd_emu10k1_ptr20_read(emu, reg, 0); + reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ + set = reset | 0x10000; /* Set xxx1xxxx */ + snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); + tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* write post */ + snd_emu10k1_ptr20_write(emu, reg, 0, set | data); + result = 1; + /* Wait for status bit to return to 0 */ + for (n=0;n<100;n++) { + udelay(10); + tmp = snd_emu10k1_ptr20_read(emu, reg, 0); + if (!(tmp & 0x10000)) { + result=0; + break; + } + } + if (result) return 1; /* Timed out */ + snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); + tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* Write post */ + return 0; +} + void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb) { unsigned long flags; -- cgit v1.1 From ccadc3e38b72629fdfd1290343fdb11813dfecc2 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Wed, 21 Dec 2005 15:31:02 +0100 Subject: [ALSA] snd-emu10k1: Enable speakers on Audigy 2 ZS Notebook. Modules: EMU10K1/EMU10K2 driver Description: This enables the 7.1 speaker output of the Audigy 2 ZS Notebook. Further towards fixing ALSA bug#927 TODO: SPDIF/IEC958 output. (untested, might already work) Sound capture. (untested, might already work.) Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/emu10k1_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index eb09370..e3a1406 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -205,6 +205,18 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) tmp = snd_emu10k1_spi_write(emu, 0x0622); tmp = snd_emu10k1_spi_write(emu, 0x1400); snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10); + /* Enable GPIOs + * GPIO0: Unknown + * GPIO1: Speakers-enabled. + * GPIO2: Unknown + * GPIO3: Unknown + * GPIO4: IEC958 Output on. + * GPIO5: Unknown + * GPIO6: Unknown + * GPIO7: Unknown + */ + outl(0x76, emu->port + A_IOCFG); /* Windows uses 0x3f76 */ + } snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); -- cgit v1.1 From 28bcbdddaffcb2ccf08d06db7cecf047ec66057d Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Wed, 21 Dec 2005 15:41:50 +0100 Subject: [ALSA] snd-emu10k1: Fix whitespace. Modules: EMU10K1/EMU10K2 driver Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/io.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index 7d0cb9d..08a0cb5 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -130,15 +130,18 @@ int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int reset, set; unsigned int reg, tmp; int n, result; - if (emu->card_capabilities->ca0108_chip) { - reg=0x3c; /* PTR20, reg 0x3c */ - } else { - return 1; /* For other cards types the SPI register is currently unknown. */ + if (emu->card_capabilities->ca0108_chip) + reg = 0x3c; /* PTR20, reg 0x3c */ + else { + /* For other chip types the SPI register + * is currently unknown. */ + return 1; } - if (data > 0xffff) return 1; /* Only 16bit values allowed */ + if (data > 0xffff) /* Only 16bit values allowed */ + return 1; tmp = snd_emu10k1_ptr20_read(emu, reg, 0); - reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ + reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ set = reset | 0x10000; /* Set xxx1xxxx */ snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* write post */ -- cgit v1.1 From c6a02ca29388a806df3df73015ee494a6e055309 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Wed, 21 Dec 2005 15:56:01 +0100 Subject: [ALSA] snd-emu10k1: Fix whitespace. Modules: EMU10K1/EMU10K2 driver Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/io.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/pci/emu10k1/io.c b/sound/pci/emu10k1/io.c index 08a0cb5..ef5304d 100644 --- a/sound/pci/emu10k1/io.c +++ b/sound/pci/emu10k1/io.c @@ -148,15 +148,16 @@ int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, snd_emu10k1_ptr20_write(emu, reg, 0, set | data); result = 1; /* Wait for status bit to return to 0 */ - for (n=0;n<100;n++) { + for (n = 0; n < 100; n++) { udelay(10); tmp = snd_emu10k1_ptr20_read(emu, reg, 0); if (!(tmp & 0x10000)) { - result=0; + result = 0; break; } } - if (result) return 1; /* Timed out */ + if (result) /* Timed out */ + return 1; snd_emu10k1_ptr20_write(emu, reg, 0, reset | data); tmp = snd_emu10k1_ptr20_read(emu, reg, 0); /* Write post */ return 0; -- cgit v1.1 From 18f3c59f2b14225bd23c41a87a5eec39439bc8b9 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Wed, 21 Dec 2005 22:05:29 +0100 Subject: [ALSA] snd-emu10k1: Tidy SPI code. Modules: EMU10K1/EMU10K2 driver Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/emu10k1_main.c | 52 +++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index e3a1406..615460f 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -92,6 +92,30 @@ void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int ch) } } +static unsigned int spi_dac_init[] = { + 0x00ff, + 0x02ff, + 0x0400, + 0x0520, + 0x0600, + 0x08ff, + 0x0aff, + 0x0cff, + 0x0eff, + 0x10ff, + 0x1200, + 0x1400, + 0x1480, + 0x1800, + 0x1aff, + 0x1cff, + 0x1e00, + 0x0530, + 0x0602, + 0x0622, + 0x1400, +}; + static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) { unsigned int silent_page; @@ -182,28 +206,12 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) outl(tmp, emu->port + A_IOCFG); } if (emu->card_capabilities->spi_dac) { /* Audigy 2 ZS Notebook with DAC Wolfson WM8768/WM8568 */ - u32 tmp; - tmp = snd_emu10k1_spi_write(emu, 0x00ff); - tmp = snd_emu10k1_spi_write(emu, 0x02ff); - tmp = snd_emu10k1_spi_write(emu, 0x0400); - tmp = snd_emu10k1_spi_write(emu, 0x0520); - tmp = snd_emu10k1_spi_write(emu, 0x0600); - tmp = snd_emu10k1_spi_write(emu, 0x08ff); - tmp = snd_emu10k1_spi_write(emu, 0x0aff); - tmp = snd_emu10k1_spi_write(emu, 0x0cff); - tmp = snd_emu10k1_spi_write(emu, 0x0eff); - tmp = snd_emu10k1_spi_write(emu, 0x10ff); - tmp = snd_emu10k1_spi_write(emu, 0x1200); - tmp = snd_emu10k1_spi_write(emu, 0x1400); - tmp = snd_emu10k1_spi_write(emu, 0x1480); - tmp = snd_emu10k1_spi_write(emu, 0x1800); - tmp = snd_emu10k1_spi_write(emu, 0x1aff); - tmp = snd_emu10k1_spi_write(emu, 0x1cff); - tmp = snd_emu10k1_spi_write(emu, 0x1e00); - tmp = snd_emu10k1_spi_write(emu, 0x0530); - tmp = snd_emu10k1_spi_write(emu, 0x0602); - tmp = snd_emu10k1_spi_write(emu, 0x0622); - tmp = snd_emu10k1_spi_write(emu, 0x1400); + int size, n; + + size = ARRAY_SIZE(spi_dac_init); + for (n=0; n < size; n++) + snd_emu10k1_spi_write(emu, spi_dac_init[n]); + snd_emu10k1_ptr20_write(emu, 0x60, 0, 0x10); /* Enable GPIOs * GPIO0: Unknown -- cgit v1.1 From aad9095322c0c7d9637f29b71167458c36a4cdf6 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Wed, 21 Dec 2005 22:26:26 +0100 Subject: [ALSA] snd-ca0106: Fix SPI driver code. Fixes speaker output. Modules: CA0106 driver Signed-off-by: James Courtier-Dutton --- sound/pci/ca0106/ca0106_main.c | 72 +++++++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index 1cf6f1f..6ed7c0b 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -284,20 +284,38 @@ void snd_ca0106_ptr_write(struct snd_ca0106 *emu, spin_unlock_irqrestore(&emu->emu_lock, flags); } -int snd_ca0106_spi_write(struct snd_ca0106 *emu, - u32 value) +int snd_ca0106_spi_write(struct snd_ca0106 * emu, + unsigned int data) { - snd_ca0106_ptr_write(emu, SPI, 0, value); + unsigned int reset, set; + unsigned int reg, tmp; + int n, result; + reg = SPI; + if (data > 0xffff) /* Only 16bit values allowed */ + return 1; + tmp = snd_ca0106_ptr_read(emu, reg, 0); + reset = (tmp & ~0x3ffff) | 0x20000; /* Set xxx20000 */ + set = reset | 0x10000; /* Set xxx1xxxx */ + snd_ca0106_ptr_write(emu, reg, 0, reset | data); + tmp = snd_ca0106_ptr_read(emu, reg, 0); /* write post */ + snd_ca0106_ptr_write(emu, reg, 0, set | data); + result = 1; + /* Wait for status bit to return to 0 */ + for (n = 0; n < 100; n++) { + udelay(10); + tmp = snd_ca0106_ptr_read(emu, reg, 0); + if (!(tmp & 0x10000)) { + result = 0; + break; + } + } + if (result) /* Timed out */ + return 1; + snd_ca0106_ptr_write(emu, reg, 0, reset | data); + tmp = snd_ca0106_ptr_read(emu, reg, 0); /* Write post */ return 0; } -int snd_ca0106_spi_read(struct snd_ca0106 *emu, - u32 *value) -{ - *value = snd_ca0106_ptr_read(emu, SPI, 0); - return 0; -} - int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value) @@ -1148,6 +1166,30 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s return 0; } +static unsigned int spi_dac_init[] = { + 0x00ff, + 0x02ff, + 0x0400, + 0x0520, + 0x0600, + 0x08ff, + 0x0aff, + 0x0cff, + 0x0eff, + 0x10ff, + 0x1200, + 0x1400, + 0x1480, + 0x1800, + 0x1aff, + 0x1cff, + 0x1e00, + 0x0530, + 0x0602, + 0x0622, + 0x1400, +}; + static int __devinit snd_ca0106_create(struct snd_card *card, struct pci_dev *pci, struct snd_ca0106 **rchip) @@ -1330,11 +1372,11 @@ static int __devinit snd_ca0106_create(struct snd_card *card, snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ } if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */ - u32 tmp; - snd_ca0106_spi_write(chip, 0xf0622); /* Enable speakers output. */ - snd_ca0106_spi_read(chip, &tmp); /* Read the value. */ - snd_ca0106_spi_write(chip, 0xe1400); - snd_ca0106_spi_read(chip, &tmp); /* Read the value. */ + int size, n; + + size = ARRAY_SIZE(spi_dac_init); + for (n=0; n < size; n++) + snd_ca0106_spi_write(chip, spi_dac_init[n]); } if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, -- cgit v1.1 From 54efc96d4a26f1d55be36324e9cc658a581a40ba Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Thu, 22 Dec 2005 12:58:41 +0100 Subject: [ALSA] snd-emu10k1: Add some comments regarding chip types. Modules: EMU10K1/EMU10K2 driver Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/emu10k1_main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 615460f..dfe7458 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -776,6 +776,12 @@ static int snd_emu10k1_dev_free(struct snd_device *device) static struct snd_emu_chip_details emu_chip_details[] = { /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/ /* Tested by James@superbug.co.uk 3rd July 2005 */ + /* DSP: CA0108-IAT + * DAC: CS4382-KQ + * ADC: Philips 1361T + * AC97: STAC9750 + * CA0151: None + */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102, .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]", .id = "Audigy2", @@ -845,6 +851,14 @@ static struct snd_emu_chip_details emu_chip_details[] = { .spk71 = 1, .spdif_bug = 1, .ac97_chip = 1} , + /* Audigy 2 */ + /* Tested by James@superbug.co.uk 3rd July 2005 */ + /* DSP: CA0102-IAT + * DAC: CS4382-KQ + * ADC: Philips 1361T + * AC97: STAC9721 + * CA0151: Yes + */ {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, .driver = "Audigy2", .name = "Audigy 2 [SB0240]", .id = "Audigy2", -- cgit v1.1 From f951fd3cc4b04c338b4fcf94b4844e921337dfaa Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Thu, 22 Dec 2005 13:05:23 +0100 Subject: [ALSA] snd-emu10k1: Add comments regarding chips present on the card. Modules: EMU10K1/EMU10K2 driver Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/emu10k1_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index dfe7458..cec7305 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -790,8 +790,17 @@ static struct snd_emu_chip_details emu_chip_details[] = { .spk71 = 1, .ac97_chip = 1} , /* Audigy 2 ZS Notebook Cardbus card.*/ - /* Tested by James@superbug.co.uk 30th October 2005 */ - /* Not working yet, but progressing. */ + /* Tested by James@superbug.co.uk 22th December 2005 */ + /* Audio output 7.1/Headphones working. + * Digital output working. (AC3 not checked, only PCM) + * Audio inputs not tested. + */ + /* DSP: Tiny2 + * DAC: Wolfson WM8768/WM8568 + * ADC: Wolfson WM8775 + * AC97: None + * CA0151: None + */ {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", .id = "Audigy2", -- cgit v1.1 From eff49137dd432eeae16e4627b8595c71e1362307 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 22 Dec 2005 17:01:20 +0100 Subject: [ALSA] emu10k1 - Clean up p16v code Modules: EMU10K1/EMU10K2 driver Clean up and optimize the codes in p16v.c - Add proper __devinit* tags - Reduce unnecessary functions using a closure - Fix whitespaces - Rename 'Unknown' to 'Side' controls Signed-off-by: Takashi Iwai --- sound/pci/emu10k1/p16v.c | 361 +++++++++++------------------------------------ 1 file changed, 80 insertions(+), 281 deletions(-) diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index 76d86ed..9905651 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c @@ -107,11 +107,11 @@ #define PCM_FRONT_CHANNEL 0 #define PCM_REAR_CHANNEL 1 #define PCM_CENTER_LFE_CHANNEL 2 -#define PCM_UNKNOWN_CHANNEL 3 +#define PCM_SIDE_CHANNEL 3 #define CONTROL_FRONT_CHANNEL 0 #define CONTROL_REAR_CHANNEL 3 #define CONTROL_CENTER_LFE_CHANNEL 1 -#define CONTROL_UNKNOWN_CHANNEL 2 +#define CONTROL_SIDE_CHANNEL 2 /* Card IDs: * Class 0401: 1102:0004 (rev 04) Subsystem: 1102:2002 -> Audigy2 ZS 7.1 Model:SB0350 @@ -590,7 +590,7 @@ int snd_p16v_free(struct snd_emu10k1 *chip) return 0; } -int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) +int __devinit snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) { struct snd_pcm *pcm; struct snd_pcm_substream *substream; @@ -644,7 +644,8 @@ int snd_p16v_pcm(struct snd_emu10k1 *emu, int device, struct snd_pcm **rpcm) return 0; } -static int snd_p16v_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +static int snd_p16v_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -654,240 +655,56 @@ static int snd_p16v_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_el } static int snd_p16v_volume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol, int reg, int high_low) + struct snd_ctl_elem_value *ucontrol) { struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); - u32 value; - - value = snd_emu10k1_ptr20_read(emu, reg, high_low); - if (high_low == 1) { - ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ - ucontrol->value.integer.value[1] = 0xff - ((value >> 16) & 0xff); /* Right */ + int high_low = (kcontrol->private_value >> 8) & 0xff; + int reg = kcontrol->private_value & 0xff; + u32 value; + + value = snd_emu10k1_ptr20_read(emu, reg, high_low); + if (high_low) { + ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ + ucontrol->value.integer.value[1] = 0xff - ((value >> 16) & 0xff); /* Right */ } else { - ucontrol->value.integer.value[0] = 0xff - ((value >> 8) & 0xff); /* Left */ - ucontrol->value.integer.value[1] = 0xff - ((value >> 0) & 0xff); /* Right */ + ucontrol->value.integer.value[0] = 0xff - ((value >> 8) & 0xff); /* Left */ + ucontrol->value.integer.value[1] = 0xff - ((value >> 0) & 0xff); /* Right */ } - return 0; -} - -static int snd_p16v_volume_get_spdif_front(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER7; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_get_spdif_center_lfe(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER7; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} -static int snd_p16v_volume_get_spdif_unknown(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER8; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} -static int snd_p16v_volume_get_spdif_rear(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER8; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_get_analog_front(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER9; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_get_analog_center_lfe(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER9; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} -static int snd_p16v_volume_get_analog_rear(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER10; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_get_analog_unknown(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER10; - return snd_p16v_volume_get(kcontrol, ucontrol, reg, high_low); + return 0; } static int snd_p16v_volume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol, int reg, int high_low) + struct snd_ctl_elem_value *ucontrol) { struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol); - u32 value; - value = snd_emu10k1_ptr20_read(emu, reg, 0); - //value = value & 0xffff; + int high_low = (kcontrol->private_value >> 8) & 0xff; + int reg = kcontrol->private_value & 0xff; + u32 value, oval; + + oval = value = snd_emu10k1_ptr20_read(emu, reg, 0); if (high_low == 1) { value &= 0xffff; - value = value | ((0xff - ucontrol->value.integer.value[0]) << 24) | ((0xff - ucontrol->value.integer.value[1]) << 16); + value |= ((0xff - ucontrol->value.integer.value[0]) << 24) | + ((0xff - ucontrol->value.integer.value[1]) << 16); } else { value &= 0xffff0000; - value = value | ((0xff - ucontrol->value.integer.value[0]) << 8) | ((0xff - ucontrol->value.integer.value[1]) ); + value |= ((0xff - ucontrol->value.integer.value[0]) << 8) | + ((0xff - ucontrol->value.integer.value[1]) ); } - snd_emu10k1_ptr20_write(emu, reg, 0, value); - return 1; -} - -static int snd_p16v_volume_put_spdif_front(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER7; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_spdif_center_lfe(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER7; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_spdif_unknown(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER8; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_spdif_rear(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER8; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_analog_front(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER9; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_analog_center_lfe(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER9; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_analog_rear(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 1; - int reg = PLAYBACK_VOLUME_MIXER10; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); -} - -static int snd_p16v_volume_put_analog_unknown(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - int high_low = 0; - int reg = PLAYBACK_VOLUME_MIXER10; - return snd_p16v_volume_put(kcontrol, ucontrol, reg, high_low); + if (value != oval) { + snd_emu10k1_ptr20_write(emu, reg, 0, value); + return 1; + } + return 0; } -static struct snd_kcontrol_new snd_p16v_volume_control_analog_front = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD Analog Front Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_analog_front, - .put = snd_p16v_volume_put_analog_front -}; - -static struct snd_kcontrol_new snd_p16v_volume_control_analog_center_lfe = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD Analog Center/LFE Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_analog_center_lfe, - .put = snd_p16v_volume_put_analog_center_lfe -}; - -static struct snd_kcontrol_new snd_p16v_volume_control_analog_unknown = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD Analog Unknown Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_analog_unknown, - .put = snd_p16v_volume_put_analog_unknown -}; - -static struct snd_kcontrol_new snd_p16v_volume_control_analog_rear = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD Analog Rear Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_analog_rear, - .put = snd_p16v_volume_put_analog_rear -}; - -static struct snd_kcontrol_new snd_p16v_volume_control_spdif_front = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD SPDIF Front Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_spdif_front, - .put = snd_p16v_volume_put_spdif_front -}; - -static struct snd_kcontrol_new snd_p16v_volume_control_spdif_center_lfe = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD SPDIF Center/LFE Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_spdif_center_lfe, - .put = snd_p16v_volume_put_spdif_center_lfe -}; - -static struct snd_kcontrol_new snd_p16v_volume_control_spdif_unknown = +static int snd_p16v_capture_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD SPDIF Unknown Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_spdif_unknown, - .put = snd_p16v_volume_put_spdif_unknown -}; - -static struct snd_kcontrol_new snd_p16v_volume_control_spdif_rear = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD SPDIF Rear Playback Volume", - .info = snd_p16v_volume_info, - .get = snd_p16v_volume_get_spdif_rear, - .put = snd_p16v_volume_put_spdif_rear -}; - -static int snd_p16v_capture_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) -{ - static char *texts[8] = { "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", "CDIF", "FX", "AC97" }; + static char *texts[8] = { + "SPDIF", "I2S", "SRC48", "SRCMulti_SPDIF", "SRCMulti_I2S", + "CDIF", "FX", "AC97" + }; uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; @@ -927,16 +744,8 @@ static int snd_p16v_capture_source_put(struct snd_kcontrol *kcontrol, return change; } -static struct snd_kcontrol_new snd_p16v_capture_source __devinitdata = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD source Capture", - .info = snd_p16v_capture_source_info, - .get = snd_p16v_capture_source_get, - .put = snd_p16v_capture_source_put -}; - -static int snd_p16v_capture_channel_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) +static int snd_p16v_capture_channel_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "0", "1", "2", "3", }; @@ -976,60 +785,50 @@ static int snd_p16v_capture_channel_put(struct snd_kcontrol *kcontrol, return change; } -static struct snd_kcontrol_new snd_p16v_capture_channel __devinitdata = -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "HD channel Capture", - .info = snd_p16v_capture_channel_info, - .get = snd_p16v_capture_channel_get, - .put = snd_p16v_capture_channel_put +#define P16V_VOL(xname,xreg,xhl) { \ + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = snd_p16v_volume_info, \ + .get = snd_p16v_volume_get, \ + .put = snd_p16v_volume_put, \ + .private_value = ((xreg) | ((xhl) << 8)) \ +} + +static struct snd_kcontrol_new p16v_mixer_controls[] __devinitdata = { + P16V_VOL("HD Analog Front Playback Volume", PLAYBACK_VOLUME_MIXER9, 0), + P16V_VOL("HD Analog Rear Playback Volume", PLAYBACK_VOLUME_MIXER10, 1), + P16V_VOL("HD Analog Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER9, 1), + P16V_VOL("HD Analog Side Playback Volume", PLAYBACK_VOLUME_MIXER10, 0), + P16V_VOL("HD SPDIF Front Playback Volume", PLAYBACK_VOLUME_MIXER7, 0), + P16V_VOL("HD SPDIF Rear Playback Volume", PLAYBACK_VOLUME_MIXER8, 1), + P16V_VOL("HD SPDIF Center/LFE Playback Volume", PLAYBACK_VOLUME_MIXER7, 1), + P16V_VOL("HD SPDIF Side Playback Volume", PLAYBACK_VOLUME_MIXER8, 0), + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "HD source Capture", + .info = snd_p16v_capture_source_info, + .get = snd_p16v_capture_source_get, + .put = snd_p16v_capture_source_put + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, + .name = "HD channel Capture", + .info = snd_p16v_capture_channel_info, + .get = snd_p16v_capture_channel_get, + .put = snd_p16v_capture_channel_put + }, }; -int snd_p16v_mixer(struct snd_emu10k1 *emu) + +int __devinit snd_p16v_mixer(struct snd_emu10k1 *emu) { - int err; - struct snd_kcontrol *kctl; + int i, err; struct snd_card *card = emu->card; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_front, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_rear, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_center_lfe, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_analog_unknown, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_front, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_rear, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_center_lfe, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_volume_control_spdif_unknown, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_capture_source, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; - if ((kctl = snd_ctl_new1(&snd_p16v_capture_channel, emu)) == NULL) - return -ENOMEM; - if ((err = snd_ctl_add(card, kctl))) - return err; + + for (i = 0; i < ARRAY_SIZE(p16v_mixer_controls); i++) { + if ((err = snd_ctl_add(card, snd_ctl_new1(&p16v_mixer_controls[i], + emu))) < 0) + return err; + } return 0; } -- cgit v1.1 From 041dec01736c59df43b0600c0fd154e50d8ccf6e Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 23 Dec 2005 12:27:52 +0100 Subject: [ALSA] hda-codec - Add model entry for Shuttle ST20G5 Modules: HDA Codec driver Added the model entry for Shuttle ST20G5. Signed-off-by: Takashi Iwai --- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 55bda26..ad9e501 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -1678,6 +1678,7 @@ static struct hda_board_config alc880_cfg_tbl[] = { { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG }, { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG }, { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG }, + { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */ { .modelname = "asus", .config = ALC880_ASUS }, { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG }, -- cgit v1.1 From e3b9bc0e78a330d0dc6669ace7925e8c132e08a7 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Sat, 24 Dec 2005 16:54:51 +0100 Subject: [ALSA] snd-emu10k1: Correct control names for Audigy 4 Pro. Modules: EMU10K1/EMU10K2 driver Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/emumixer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index 306fe4a..2e86a90 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -866,7 +866,17 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu, c = emu10k1_rename_ctls; for (; *c; c += 2) rename_ctl(card, c[0], c[1]); - + if (emu->card_capabilities->subsystem == 0x20071102) { /* Audigy 4 Pro */ + rename_ctl(card, "Line2 Capture Volume", "Line1/Mic Capture Volume"); + rename_ctl(card, "Analog Mix Capture Volume", "Line2 Capture Volume"); + rename_ctl(card, "Aux2 Capture Volume", "Line3 Capture Volume"); + rename_ctl(card, "Mic Capture Volume", "Unknown1 Capture Volume"); + remove_ctl(card, "Headphone Playback Switch"); + remove_ctl(card, "Headphone Playback Volume"); + remove_ctl(card, "3D Control - Center"); + remove_ctl(card, "3D Control - Depth"); + remove_ctl(card, "3D Control - Switch"); + } if ((kctl = emu->ctl_send_routing = snd_ctl_new1(&snd_emu10k1_send_routing_control, emu)) == NULL) return -ENOMEM; kctl->id.device = pcm_device; -- cgit v1.1 From 0ba656d0b2319b76fbebd01c1c9ba5ca8eb33fb1 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Mon, 26 Dec 2005 15:30:03 +0100 Subject: [ALSA] snd-emu10k1: Add new SB Live 5.1 PCI-ID. Modules: EMU10K1/EMU10K2 driver Signed-off-by: James Courtier-Dutton --- sound/pci/emu10k1/emu10k1_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index cec7305..3c7043b 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c @@ -945,6 +945,14 @@ static struct snd_emu_chip_details emu_chip_details[] = { .emu10k1_chip = 1, .ac97_chip = 1, .sblive51 = 1} , + /* Tested by ALSA bug#1680 26th December 2005 */ + /* note: It really has SB0220 written on the card. */ + {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, + .driver = "EMU10K1", .name = "SB Live 5.1 Dell OEM [SB0220]", + .id = "Live", + .emu10k1_chip = 1, + .ac97_chip = 1, + .sblive51 = 1} , /* Tested by Thomas Zehetbauer 27th Aug 2005 */ {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", -- cgit v1.1 From 4c98cfef2efa6b6662ac28c4f0069964bbd9fdf9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 29 Nov 2005 09:09:32 +0100 Subject: [ALSA] PATCH] Add PM support to PnP drivers Add suspend/resume callback to pnp_driver and pnp_card_driver. Signed-off-by: Takashi Iwai --- drivers/pnp/card.c | 25 +++++++++++++++++++++++++ drivers/pnp/driver.c | 20 ++++++++++++++++++++ include/linux/pnp.h | 5 +++++ 3 files changed, 50 insertions(+) diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c index bd7c966..0ecbe4e 100644 --- a/drivers/pnp/card.c +++ b/drivers/pnp/card.c @@ -69,6 +69,7 @@ static int card_probe(struct pnp_card * card, struct pnp_card_driver * drv) return 0; clink->card = card; clink->driver = drv; + clink->pm_state = PMSG_ON; if (drv->probe) { if (drv->probe(clink, id)>=0) return 1; @@ -333,6 +334,28 @@ void pnp_release_card_device(struct pnp_dev * dev) up_write(&dev->dev.bus->subsys.rwsem); } +/* + * suspend/resume callbacks + */ +static int card_suspend(struct pnp_dev *dev, pm_message_t state) +{ + struct pnp_card_link *link = dev->card_link; + if (link->pm_state.event == state.event) + return 0; + link->pm_state = state; + return link->driver->suspend(link, state); +} + +static int card_resume(struct pnp_dev *dev) +{ + struct pnp_card_link *link = dev->card_link; + if (link->pm_state.event == PM_EVENT_ON) + return 0; + link->pm_state = PMSG_ON; + link->driver->resume(link); + return 0; +} + /** * pnp_register_card_driver - registers a PnP card driver with the PnP Layer * @drv: pointer to the driver to register @@ -348,6 +371,8 @@ int pnp_register_card_driver(struct pnp_card_driver * drv) drv->link.flags = drv->flags; drv->link.probe = NULL; drv->link.remove = &card_remove_first; + drv->link.suspend = drv->suspend ? card_suspend : NULL; + drv->link.resume = drv->resume ? card_resume : NULL; spin_lock(&pnp_lock); list_add_tail(&drv->global_list, &pnp_card_drivers); diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index d3ccce7..ea2cb9a 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -146,10 +146,30 @@ static int pnp_bus_match(struct device *dev, struct device_driver *drv) return 1; } +static int pnp_bus_suspend(struct device *dev, pm_message_t state) +{ + struct pnp_dev * pnp_dev = to_pnp_dev(dev); + struct pnp_driver * pnp_drv = pnp_dev->driver; + + if (pnp_drv && pnp_drv->suspend) + return pnp_drv->suspend(pnp_dev, state); + return 0; +} + +static void pnp_bus_resume(struct device *dev) +{ + struct pnp_dev * pnp_dev = to_pnp_dev(dev); + struct pnp_driver * pnp_drv = pnp_dev->driver; + + if (pnp_drv && pnp_drv->resume) + pnp_drv->resume(pnp_dev); +} struct bus_type pnp_bus_type = { .name = "pnp", .match = pnp_bus_match, + .suspend = pnp_bus_suspend, + .resume = pnp_bus_resume, }; diff --git a/include/linux/pnp.h b/include/linux/pnp.h index 584d57c..472319f 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -162,6 +162,7 @@ struct pnp_card_link { struct pnp_card * card; struct pnp_card_driver * driver; void * driver_data; + pm_message_t pm_state; }; static inline void *pnp_get_card_drvdata (struct pnp_card_link *pcard) @@ -294,6 +295,8 @@ struct pnp_driver { unsigned int flags; int (*probe) (struct pnp_dev *dev, const struct pnp_device_id *dev_id); void (*remove) (struct pnp_dev *dev); + int (*suspend) (struct pnp_dev *dev, pm_message_t state); + int (*resume) (struct pnp_dev *dev); struct device_driver driver; }; @@ -306,6 +309,8 @@ struct pnp_card_driver { unsigned int flags; int (*probe) (struct pnp_card_link *card, const struct pnp_card_device_id *card_id); void (*remove) (struct pnp_card_link *card); + int (*suspend) (struct pnp_card_link *card, pm_message_t state); + int (*resume) (struct pnp_card_link *card); struct pnp_driver link; }; -- cgit v1.1 From 68094e3251a664ee1389fcf179497237cbf78331 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 29 Nov 2005 09:09:32 +0100 Subject: [ALSA] [PATCH] alsa: Improved PnP suspend support Also use the PnP functions to start/stop the devices during the suspend so that drivers will not have to duplicate this code. Cc: Adam Belay Cc: Jaroslav Kysela Cc: Takashi Iwai Signed-off-by: Pierre Ossman Signed-off-by: Andrew Morton Signed-off-by: Takashi Iwai --- drivers/pnp/driver.c | 37 ++++++++++++++++++++---- drivers/pnp/manager.c | 78 ++++++++++++++++++++++++++++++++++++++------------- include/linux/pnp.h | 4 +++ 3 files changed, 95 insertions(+), 24 deletions(-) diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index ea2cb9a..15fb758 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -150,19 +150,46 @@ static int pnp_bus_suspend(struct device *dev, pm_message_t state) { struct pnp_dev * pnp_dev = to_pnp_dev(dev); struct pnp_driver * pnp_drv = pnp_dev->driver; + int error; + + if (!pnp_drv) + return 0; + + if (pnp_drv->suspend) { + error = pnp_drv->suspend(pnp_dev, state); + if (error) + return error; + } + + if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) && + pnp_can_disable(pnp_dev)) { + error = pnp_stop_dev(pnp_dev); + if (error) + return error; + } - if (pnp_drv && pnp_drv->suspend) - return pnp_drv->suspend(pnp_dev, state); return 0; } -static void pnp_bus_resume(struct device *dev) +static int pnp_bus_resume(struct device *dev) { struct pnp_dev * pnp_dev = to_pnp_dev(dev); struct pnp_driver * pnp_drv = pnp_dev->driver; + int error; + + if (!pnp_drv) + return 0; + + if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) { + error = pnp_start_dev(pnp_dev); + if (error) + return error; + } - if (pnp_drv && pnp_drv->resume) - pnp_drv->resume(pnp_dev); + if (pnp_drv->resume) + return pnp_drv->resume(pnp_dev); + + return 0; } struct bus_type pnp_bus_type = { diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index 2616686..c4256aa 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c @@ -470,6 +470,53 @@ int pnp_auto_config_dev(struct pnp_dev *dev) } /** + * pnp_start_dev - low-level start of the PnP device + * @dev: pointer to the desired device + * + * assumes that resources have alread been allocated + */ + +int pnp_start_dev(struct pnp_dev *dev) +{ + if (!pnp_can_write(dev)) { + pnp_info("Device %s does not supported activation.", dev->dev.bus_id); + return -EINVAL; + } + + if (dev->protocol->set(dev, &dev->res)<0) { + pnp_err("Failed to activate device %s.", dev->dev.bus_id); + return -EIO; + } + + pnp_info("Device %s activated.", dev->dev.bus_id); + + return 0; +} + +/** + * pnp_stop_dev - low-level disable of the PnP device + * @dev: pointer to the desired device + * + * does not free resources + */ + +int pnp_stop_dev(struct pnp_dev *dev) +{ + if (!pnp_can_disable(dev)) { + pnp_info("Device %s does not supported disabling.", dev->dev.bus_id); + return -EINVAL; + } + if (dev->protocol->disable(dev)<0) { + pnp_err("Failed to disable device %s.", dev->dev.bus_id); + return -EIO; + } + + pnp_info("Device %s disabled.", dev->dev.bus_id); + + return 0; +} + +/** * pnp_activate_dev - activates a PnP device for use * @dev: pointer to the desired device * @@ -477,6 +524,8 @@ int pnp_auto_config_dev(struct pnp_dev *dev) */ int pnp_activate_dev(struct pnp_dev *dev) { + int error; + if (!dev) return -EINVAL; if (dev->active) { @@ -487,18 +536,11 @@ int pnp_activate_dev(struct pnp_dev *dev) if (pnp_auto_config_dev(dev)) return -EBUSY; - if (!pnp_can_write(dev)) { - pnp_info("Device %s does not supported activation.", dev->dev.bus_id); - return -EINVAL; - } - - if (dev->protocol->set(dev, &dev->res)<0) { - pnp_err("Failed to activate device %s.", dev->dev.bus_id); - return -EIO; - } + error = pnp_start_dev(dev); + if (error) + return error; dev->active = 1; - pnp_info("Device %s activated.", dev->dev.bus_id); return 1; } @@ -511,23 +553,19 @@ int pnp_activate_dev(struct pnp_dev *dev) */ int pnp_disable_dev(struct pnp_dev *dev) { + int error; + if (!dev) return -EINVAL; if (!dev->active) { return 0; /* the device is already disabled */ } - if (!pnp_can_disable(dev)) { - pnp_info("Device %s does not supported disabling.", dev->dev.bus_id); - return -EINVAL; - } - if (dev->protocol->disable(dev)<0) { - pnp_err("Failed to disable device %s.", dev->dev.bus_id); - return -EIO; - } + error = pnp_stop_dev(dev); + if (error) + return error; dev->active = 0; - pnp_info("Device %s disabled.", dev->dev.bus_id); /* release the resources so that other devices can use them */ down(&pnp_res_mutex); @@ -558,6 +596,8 @@ EXPORT_SYMBOL(pnp_manual_config_dev); #if 0 EXPORT_SYMBOL(pnp_auto_config_dev); #endif +EXPORT_SYMBOL(pnp_start_dev); +EXPORT_SYMBOL(pnp_stop_dev); EXPORT_SYMBOL(pnp_activate_dev); EXPORT_SYMBOL(pnp_disable_dev); EXPORT_SYMBOL(pnp_resource_change); diff --git a/include/linux/pnp.h b/include/linux/pnp.h index 472319f..93b0959 100644 --- a/include/linux/pnp.h +++ b/include/linux/pnp.h @@ -385,6 +385,8 @@ void pnp_init_resource_table(struct pnp_resource_table *table); int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode); int pnp_auto_config_dev(struct pnp_dev *dev); int pnp_validate_config(struct pnp_dev *dev); +int pnp_start_dev(struct pnp_dev *dev); +int pnp_stop_dev(struct pnp_dev *dev); int pnp_activate_dev(struct pnp_dev *dev); int pnp_disable_dev(struct pnp_dev *dev); void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size); @@ -428,6 +430,8 @@ static inline void pnp_init_resource_table(struct pnp_resource_table *table) { } static inline int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, int mode) { return -ENODEV; } static inline int pnp_auto_config_dev(struct pnp_dev *dev) { return -ENODEV; } static inline int pnp_validate_config(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_start_dev(struct pnp_dev *dev) { return -ENODEV; } +static inline int pnp_stop_dev(struct pnp_dev *dev) { return -ENODEV; } static inline int pnp_activate_dev(struct pnp_dev *dev) { return -ENODEV; } static inline int pnp_disable_dev(struct pnp_dev *dev) { return -ENODEV; } static inline void pnp_resource_change(struct resource *resource, unsigned long start, unsigned long size) { } -- cgit v1.1 From 4d399cae3f5ec1f59b9e88084aae09c4f00760c9 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 3 Jan 2006 13:19:13 +0100 Subject: remove pointers to the defunct UDF mailing list This patch removes pointers to the defunct UDF mailing list. Signed-off-by: Adrian Bunk --- MAINTAINERS | 1 - fs/udf/balloc.c | 5 ----- fs/udf/crc.c | 5 ----- fs/udf/dir.c | 5 ----- fs/udf/directory.c | 5 ----- fs/udf/file.c | 5 ----- fs/udf/fsync.c | 5 ----- fs/udf/ialloc.c | 5 ----- fs/udf/inode.c | 5 ----- fs/udf/lowlevel.c | 5 ----- fs/udf/misc.c | 5 ----- fs/udf/namei.c | 5 ----- fs/udf/partition.c | 5 ----- fs/udf/super.c | 5 ----- fs/udf/symlink.c | 5 ----- fs/udf/truncate.c | 5 ----- fs/udf/unicode.c | 5 ----- include/linux/udf_fs.h | 5 ----- include/linux/udf_fs_i.h | 5 ----- include/linux/udf_fs_sb.h | 5 ----- 20 files changed, 96 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 6af6830..bbe5f04 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2587,7 +2587,6 @@ S: Maintained UDF FILESYSTEM P: Ben Fennema M: bfennema@falcon.csc.calpoly.edu -L: linux_udf@hpesjro.fc.hp.com W: http://linux-udf.sourceforge.net S: Maintained diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index b9ded26..6598a50 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c @@ -4,11 +4,6 @@ * PURPOSE * Block allocation handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/crc.c b/fs/udf/crc.c index d95c6e3..1b82a4a 100644 --- a/fs/udf/crc.c +++ b/fs/udf/crc.c @@ -14,11 +14,6 @@ * * AT&T gives permission for the free use of the CRC source code. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/dir.c b/fs/udf/dir.c index 82440b7..f522252 100644 --- a/fs/udf/dir.c +++ b/fs/udf/dir.c @@ -4,11 +4,6 @@ * PURPOSE * Directory handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/directory.c b/fs/udf/directory.c index 9a61ecc..fe751a2 100644 --- a/fs/udf/directory.c +++ b/fs/udf/directory.c @@ -4,11 +4,6 @@ * PURPOSE * Directory related functions * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/file.c b/fs/udf/file.c index 01f520c..8a38828 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -4,11 +4,6 @@ * PURPOSE * File handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/fsync.c b/fs/udf/fsync.c index 2dde6b8..5887d78 100644 --- a/fs/udf/fsync.c +++ b/fs/udf/fsync.c @@ -4,11 +4,6 @@ * PURPOSE * Fsync handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c index a7e5d40..c9b707b 100644 --- a/fs/udf/ialloc.c +++ b/fs/udf/ialloc.c @@ -4,11 +4,6 @@ * PURPOSE * Inode allocation handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/inode.c b/fs/udf/inode.c index b83890b..4014f17 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -4,11 +4,6 @@ * PURPOSE * Inode handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c index 2da5087..0842161 100644 --- a/fs/udf/lowlevel.c +++ b/fs/udf/lowlevel.c @@ -4,11 +4,6 @@ * PURPOSE * Low Level Device Routines for the UDF filesystem * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/misc.c b/fs/udf/misc.c index fd321f9..cc8ca32 100644 --- a/fs/udf/misc.c +++ b/fs/udf/misc.c @@ -4,11 +4,6 @@ * PURPOSE * Miscellaneous routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/namei.c b/fs/udf/namei.c index ac191ed..ca732e7 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -4,11 +4,6 @@ * PURPOSE * Inode name handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/partition.c b/fs/udf/partition.c index 4d36f26..dabf2b8 100644 --- a/fs/udf/partition.c +++ b/fs/udf/partition.c @@ -4,11 +4,6 @@ * PURPOSE * Partition handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/super.c b/fs/udf/super.c index 15bd4f2..4a6f49a 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -14,11 +14,6 @@ * http://www.ecma.ch/ * http://www.iso.org/ * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c index 43f3051..674bb40 100644 --- a/fs/udf/symlink.c +++ b/fs/udf/symlink.c @@ -4,11 +4,6 @@ * PURPOSE * Symlink handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c index 7dc8a55..e1b0e8c 100644 --- a/fs/udf/truncate.c +++ b/fs/udf/truncate.c @@ -4,11 +4,6 @@ * PURPOSE * Truncate handling routines for the OSTA-UDF(tm) filesystem. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c index 5a80efd..706c92e 100644 --- a/fs/udf/unicode.c +++ b/fs/udf/unicode.c @@ -11,11 +11,6 @@ * UTF-8 is explained in the IETF RFC XXXX. * ftp://ftp.internic.net/rfc/rfcxxxx.txt * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team's mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/include/linux/udf_fs.h b/include/linux/udf_fs.h index 46e2bb9..36c684e 100644 --- a/include/linux/udf_fs.h +++ b/include/linux/udf_fs.h @@ -13,11 +13,6 @@ * http://www.osta.org/ * http://www.ecma.ch/ * http://www.iso.org/ * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/include/linux/udf_fs_i.h b/include/linux/udf_fs_i.h index 62b15a4..1e75084 100644 --- a/include/linux/udf_fs_i.h +++ b/include/linux/udf_fs_i.h @@ -3,11 +3,6 @@ * * This file is intended for the Linux kernel/module. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h index 1966a6d..b15ff2e 100644 --- a/include/linux/udf_fs_sb.h +++ b/include/linux/udf_fs_sb.h @@ -3,11 +3,6 @@ * * This include file is for the Linux kernel/module. * - * CONTACTS - * E-mail regarding any portion of the Linux UDF file system should be - * directed to the development team mailing list (run by majordomo): - * linux_udf@hpesjro.fc.hp.com - * * COPYRIGHT * This file is distributed under the terms of the GNU General Public * License (GPL). Copies of the GPL can be obtained from: -- cgit v1.1 From 7a1119b1fc87cc347d3932b8aee051e86b32818f Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 3 Jan 2006 13:21:37 +0100 Subject: fs/qnx4/bitmap.c: #if 0 qnx4_new_block() qnx4_new_block() is neither implemented nor used. Signed-off-by: Adrian Bunk Signed-off-by: Anders Larsen --- fs/qnx4/bitmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c index 9912539..46efbf5 100644 --- a/fs/qnx4/bitmap.c +++ b/fs/qnx4/bitmap.c @@ -23,10 +23,12 @@ #include #include +#if 0 int qnx4_new_block(struct super_block *sb) { return 0; } +#endif /* 0 */ static void count_bits(register const char *bmPart, register int size, int *const tf) -- cgit v1.1 From 4a4efbdee278b2f4ed91aad2db5c006ff754276e Mon Sep 17 00:00:00 2001 From: Matt Mackall Date: Tue, 3 Jan 2006 13:27:11 +0100 Subject: s/retreiv/retriev/g As everyone knows, the rule is: "i before e.. um.. always." Signed-off-by: Matt Mackall Signed-off-by: Adrian Bunk --- drivers/char/n_hdlc.c | 2 +- drivers/net/tlan.c | 4 ++-- drivers/usb/serial/ftdi_sio.h | 2 +- drivers/video/aty/radeon_base.c | 16 ++++++++-------- fs/reiserfs/xattr.c | 4 ++-- net/irda/iriap.c | 2 +- scripts/kconfig/util.c | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c index c3660d8..a133a62 100644 --- a/drivers/char/n_hdlc.c +++ b/drivers/char/n_hdlc.c @@ -562,7 +562,7 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data, } /* end of n_hdlc_tty_receive() */ /** - * n_hdlc_tty_read - Called to retreive one frame of data (if available) + * n_hdlc_tty_read - Called to retrieve one frame of data (if available) * @tty - pointer to tty instance data * @file - pointer to open file object * @buf - pointer to returned data buffer diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c index 942fae0..c2506b5 100644 --- a/drivers/net/tlan.c +++ b/drivers/net/tlan.c @@ -2865,11 +2865,11 @@ void TLan_PhyMonitor( struct net_device *dev ) * for this device. * phy The address of the PHY to be queried. * reg The register whose contents are to be - * retreived. + * retrieved. * val A pointer to a variable to store the * retrieved value. * - * This function uses the TLAN's MII bus to retreive the contents + * This function uses the TLAN's MII bus to retrieve the contents * of a given register on a PHY. It sends the appropriate info * and then reads the 16-bit register value from the MII bus via * the TLAN SIO register. diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 773ea3e..da004dd 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -714,7 +714,7 @@ typedef enum { */ /* FTDI_SIO_GET_MODEM_STATUS */ -/* Retreive the current value of the modem status register */ +/* Retrieve the current value of the modem status register */ #define FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE 0xc0 #define FTDI_SIO_GET_MODEM_STATUS_REQUEST FTDI_SIO_GET_MODEM_STATUS diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index 4f01ccc..156db84 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c @@ -594,7 +594,7 @@ static int __devinit radeon_probe_pll_params(struct radeonfb_info *rinfo) } /* - * Retreive PLL infos by different means (BIOS, Open Firmware, register probing...) + * Retrieve PLL infos by different means (BIOS, Open Firmware, register probing...) */ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo) { @@ -660,17 +660,17 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo) #ifdef CONFIG_PPC_OF /* - * Retreive PLL infos from Open Firmware first + * Retrieve PLL infos from Open Firmware first */ if (!force_measure_pll && radeon_read_xtal_OF(rinfo) == 0) { - printk(KERN_INFO "radeonfb: Retreived PLL infos from Open Firmware\n"); + printk(KERN_INFO "radeonfb: Retrieved PLL infos from Open Firmware\n"); goto found; } #endif /* CONFIG_PPC_OF */ /* * Check out if we have an X86 which gave us some PLL informations - * and if yes, retreive them + * and if yes, retrieve them */ if (!force_measure_pll && rinfo->bios_seg) { u16 pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30); @@ -682,7 +682,7 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo) rinfo->pll.ppll_min = BIOS_IN32(pll_info_block + 0x12); rinfo->pll.ppll_max = BIOS_IN32(pll_info_block + 0x16); - printk(KERN_INFO "radeonfb: Retreived PLL infos from BIOS\n"); + printk(KERN_INFO "radeonfb: Retrieved PLL infos from BIOS\n"); goto found; } @@ -691,7 +691,7 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo) * probe them */ if (radeon_probe_pll_params(rinfo) == 0) { - printk(KERN_INFO "radeonfb: Retreived PLL infos from registers\n"); + printk(KERN_INFO "radeonfb: Retrieved PLL infos from registers\n"); goto found; } @@ -702,7 +702,7 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo) found: /* - * Some methods fail to retreive SCLK and MCLK values, we apply default + * Some methods fail to retrieve SCLK and MCLK values, we apply default * settings in this case (200Mhz). If that really happne often, we could * fetch from registers instead... */ @@ -2393,7 +2393,7 @@ static int radeonfb_pci_register (struct pci_dev *pdev, rinfo->mapped_vram/1024); /* - * Map the BIOS ROM if any and retreive PLL parameters from + * Map the BIOS ROM if any and retrieve PLL parameters from * the BIOS. We skip that on mobility chips as the real panel * values we need aren't in the ROM but in the BIOS image in * memory. This is definitely not the best meacnism though, diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 72e1207..02091ea 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c @@ -115,8 +115,8 @@ static struct dentry *__get_xa_root(struct super_block *s) } /* Returns the dentry (or NULL) referring to the root of the extended - * attribute directory tree. If it has already been retreived, it is used. - * Otherwise, we attempt to retreive it from disk. It may also return + * attribute directory tree. If it has already been retrieved, it is used. + * Otherwise, we attempt to retrieve it from disk. It may also return * a pointer-encoded error. */ static inline struct dentry *get_xa_root(struct super_block *s) diff --git a/net/irda/iriap.c b/net/irda/iriap.c index b8bb78a..254f907 100644 --- a/net/irda/iriap.c +++ b/net/irda/iriap.c @@ -364,7 +364,7 @@ static void iriap_disconnect_request(struct iriap_cb *self) /* * Function iriap_getvaluebyclass (addr, name, attr) * - * Retreive all values from attribute in all objects with given class + * Retrieve all values from attribute in all objects with given class * name */ int iriap_getvaluebyclass_request(struct iriap_cb *self, diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 1fa4c0b..4556014 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -101,7 +101,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...) va_end(ap); } -/* Retreive value of growable string */ +/* Retrieve value of growable string */ const char *str_get(struct gstr *gs) { return gs->s; -- cgit v1.1 From 5e03e2c48fc2952f6a9e986cfa194fe905d0f569 Mon Sep 17 00:00:00 2001 From: "Adam D. Moss" Date: Tue, 3 Jan 2006 13:31:01 +0100 Subject: update for Documentation/sysrq.txt This patch for 2.4.x updates the dead email address for 'Mydraal' and since he no longer wishes to field questions concerning SysRq or this document removes the statement stating otherwise. Signed-off-by: Adrian Bunk --- Documentation/sysrq.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Documentation/sysrq.txt b/Documentation/sysrq.txt index baf17b3..ad0bedf 100644 --- a/Documentation/sysrq.txt +++ b/Documentation/sysrq.txt @@ -202,17 +202,13 @@ you must call __handle_sysrq_nolock instead. * I have more questions, who can I ask? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -You may feel free to send email to myrdraal@deathsdoor.com, and I will -respond as soon as possible. - -Myrdraal - And I'll answer any questions about the registration system you got, also responding as soon as possible. -Crutcher * Credits ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Written by Mydraal +Written by Mydraal Updated by Adam Sulmicki Updated by Jeremy M. Dolan 2001/01/28 10:15:59 Added to by Crutcher Dunnavant -- cgit v1.1 From f62870db3c73683fe566a05efa2a05f3faeb44f5 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Tue, 3 Jan 2006 13:33:31 +0100 Subject: Documentation/SubmittingPatches: update Trivial Patch Monkey information While looking for where to send trivial patches, I found old contact information in Documentation/SubmittingPatches. Signed-off-by: Kees Cook Signed-off-by: Adrian Bunk --- Documentation/SubmittingPatches | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/SubmittingPatches b/Documentation/SubmittingPatches index 237d54c..1d47e6c 100644 --- a/Documentation/SubmittingPatches +++ b/Documentation/SubmittingPatches @@ -158,7 +158,7 @@ Even if the maintainer did not respond in step #4, make sure to ALWAYS copy the maintainer when you change their code. For small patches you may want to CC the Trivial Patch Monkey -trivial@rustcorp.com.au set up by Rusty Russell; which collects "trivial" +trivial@kernel.org managed by Adrian Bunk; which collects "trivial" patches. Trivial patches must qualify for one of the following rules: Spelling fixes in documentation Spelling fixes which could break grep(1). @@ -171,7 +171,7 @@ patches. Trivial patches must qualify for one of the following rules: since people copy, as long as it's trivial) Any fix by the author/maintainer of the file. (ie. patch monkey in re-transmission mode) -URL: +URL: -- cgit v1.1 From e3e1bfe4f28de86d065bc041456161a3f3a9aef7 Mon Sep 17 00:00:00 2001 From: Jim Cromie Date: Tue, 3 Jan 2006 13:35:41 +0100 Subject: Documentation/filesystems/vfs.txt: typo fix This patch removes an extra occurrence of 'generic'. Acked-by: Pekka Enberg Signed-off-by: Adrian Bunk --- Documentation/filesystems/vfs.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index ee4c0a8..e56e842 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -162,9 +162,8 @@ get_sb() method fills in is the "s_op" field. This is a pointer to a "struct super_operations" which describes the next level of the filesystem implementation. -Usually, a filesystem uses generic one of the generic get_sb() -implementations and provides a fill_super() method instead. The -generic methods are: +Usually, a filesystem uses one of the generic get_sb() implementations +and provides a fill_super() method instead. The generic methods are: get_sb_bdev: mount a filesystem residing on a block device -- cgit v1.1 From f4b09ebc8baa51ec8394c4173e3de9d62b2cc97a Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 3 Jan 2006 13:37:51 +0100 Subject: update the email address of Randy Dunlap This patch removes all references to the bouncing address rddunlap@osdl.org and one dead web page from the kernel. Signed-off-by: Adrian Bunk Acked-by: Randy Dunlap --- Documentation/block/biodoc.txt | 2 +- Documentation/scsi/scsi_mid_low_api.txt | 2 +- MAINTAINERS | 3 +-- drivers/usb/class/usblp.c | 2 +- fs/ntfs/ChangeLog | 2 +- kernel/configs.c | 2 +- scripts/binoffset.c | 2 +- scripts/checkversion.pl | 2 +- scripts/patch-kernel | 4 ++-- 9 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt index 0fe01c8..303c57a 100644 --- a/Documentation/block/biodoc.txt +++ b/Documentation/block/biodoc.txt @@ -31,7 +31,7 @@ The following people helped with review comments and inputs for this document: Christoph Hellwig Arjan van de Ven - Randy Dunlap + Randy Dunlap Andre Hedrick The following people helped with fixes/contributions to the bio patches diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt index 66565d4..3209b37e 100644 --- a/Documentation/scsi/scsi_mid_low_api.txt +++ b/Documentation/scsi/scsi_mid_low_api.txt @@ -1433,7 +1433,7 @@ The following people have contributed to this document: Christoph Hellwig Doug Ledford Andries Brouwer - Randy Dunlap + Randy Dunlap Alan Stern diff --git a/MAINTAINERS b/MAINTAINERS index bbe5f04..79f0efa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1465,7 +1465,6 @@ P: Several L: kernel-janitors@osdl.org W: http://www.kerneljanitors.org/ W: http://sf.net/projects/kernel-janitor/ -W: http://developer.osdl.org/rddunlap/kj-patches/ S: Maintained KERNEL NFSD @@ -1486,7 +1485,7 @@ KEXEC P: Eric Biederman P: Randy Dunlap M: ebiederm@xmission.com -M: rddunlap@osdl.org +M: rdunlap@xenotime.net W: http://www.xmission.com/~ebiederm/files/kexec/ L: linux-kernel@vger.kernel.org L: fastboot@osdl.org diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 357e753..38f905d 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -3,7 +3,7 @@ * * Copyright (c) 1999 Michael Gee * Copyright (c) 1999 Pavel Machek - * Copyright (c) 2000 Randy Dunlap + * Copyright (c) 2000 Randy Dunlap * Copyright (c) 2000 Vojtech Pavlik # Copyright (c) 2001 Pete Zaitcev # Copyright (c) 2001 David Paschal diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog index 50a7749..02f4409 100644 --- a/fs/ntfs/ChangeLog +++ b/fs/ntfs/ChangeLog @@ -884,7 +884,7 @@ ToDo/Notes: - Add handling for initialized_size != data_size in compressed files. - Reduce function local stack usage from 0x3d4 bytes to just noise in - fs/ntfs/upcase.c. (Randy Dunlap ) + fs/ntfs/upcase.c. (Randy Dunlap ) - Remove compiler warnings for newer gcc. - Pages are no longer kmapped by mm/filemap.c::generic_file_write() around calls to ->{prepare,commit}_write. Adapt NTFS appropriately diff --git a/kernel/configs.c b/kernel/configs.c index 986f7af..009e1eb 100644 --- a/kernel/configs.c +++ b/kernel/configs.c @@ -3,7 +3,7 @@ * Echo the kernel .config file used to build the kernel * * Copyright (C) 2002 Khalid Aziz - * Copyright (C) 2002 Randy Dunlap + * Copyright (C) 2002 Randy Dunlap * Copyright (C) 2002 Al Stone * Copyright (C) 2002 Hewlett-Packard Company * diff --git a/scripts/binoffset.c b/scripts/binoffset.c index 591309d..1a2e39b 100644 --- a/scripts/binoffset.c +++ b/scripts/binoffset.c @@ -1,6 +1,6 @@ /*************************************************************************** * binoffset.c - * (C) 2002 Randy Dunlap + * (C) 2002 Randy Dunlap # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/scripts/checkversion.pl b/scripts/checkversion.pl index df10db6..9f84e56 100755 --- a/scripts/checkversion.pl +++ b/scripts/checkversion.pl @@ -3,7 +3,7 @@ # checkversion find uses of LINUX_VERSION_CODE, KERNEL_VERSION, or # UTS_RELEASE without including , or cases of # including that don't need it. -# Copyright (C) 2003, Randy Dunlap +# Copyright (C) 2003, Randy Dunlap $| = 1; diff --git a/scripts/patch-kernel b/scripts/patch-kernel index f2d47ca..67e4b18 100755 --- a/scripts/patch-kernel +++ b/scripts/patch-kernel @@ -45,7 +45,7 @@ # update usage message; # fix some whitespace damage; # be smarter about stopping when current version is larger than requested; -# Randy Dunlap , 2004-AUG-18. +# Randy Dunlap , 2004-AUG-18. # # Add better support for (non-incremental) 2.6.x.y patches; # If an ending version number if not specified, the script automatically @@ -56,7 +56,7 @@ # patch-kernel does not normally support reverse patching, but does so when # applying EXTRAVERSION (x.y) patches, so that moving from 2.6.11.y to 2.6.11.z # is easy and handled by the script (reverse 2.6.11.y and apply 2.6.11.z). -# Randy Dunlap , 2005-APR-08. +# Randy Dunlap , 2005-APR-08. PNAME=patch-kernel -- cgit v1.1 From df7b5d13c6c850bc2e3ca6ccfb1038f36bbbcf19 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 3 Jan 2006 13:42:12 +0100 Subject: arch/arm26/nwfpe/fpmodule.c: remove kernel 2.0 #ifdef This patch removes an #ifdef for kernel 2.0 . Signed-off-by: Adrian Bunk --- arch/arm26/nwfpe/fpmodule.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm26/nwfpe/fpmodule.c b/arch/arm26/nwfpe/fpmodule.c index 528fa71..5258c60 100644 --- a/arch/arm26/nwfpe/fpmodule.c +++ b/arch/arm26/nwfpe/fpmodule.c @@ -46,10 +46,9 @@ typedef struct task_struct* PTASK; #ifdef MODULE void fp_send_sig(unsigned long sig, PTASK p, int priv); -#if LINUX_VERSION_CODE > 0x20115 + MODULE_AUTHOR("Scott Bambrough "); MODULE_DESCRIPTION("NWFPE floating point emulator"); -#endif #else #define fp_send_sig send_sig -- cgit v1.1 From be9b7e8c02a5f864e29b17f6d86abcde258ef2fa Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 3 Jan 2006 13:42:38 +0100 Subject: [ALSA] Remove xxx_t typedefs: SPARC CS4231 Remove xxx_t typedefs from the SPARC CS4231 driver. Signed-off-by: Takashi Iwai --- sound/sparc/cs4231.c | 342 +++++++++++++++++++++++++-------------------------- 1 file changed, 168 insertions(+), 174 deletions(-) diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c index 14b1277..e9086e9 100644 --- a/sound/sparc/cs4231.c +++ b/sound/sparc/cs4231.c @@ -62,49 +62,47 @@ MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{Sun,CS4231}}"); #ifdef SBUS_SUPPORT -typedef struct sbus_dma_info { +struct sbus_dma_info { spinlock_t lock; int dir; void __iomem *regs; -} sbus_dma_info_t; +}; #endif -typedef struct snd_cs4231 cs4231_t; - -typedef struct cs4231_dma_control { +struct cs4231_dma_control { void (*prepare)(struct cs4231_dma_control *dma_cont, int dir); void (*enable)(struct cs4231_dma_control *dma_cont, int on); int (*request)(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len); unsigned int (*address)(struct cs4231_dma_control *dma_cont); - void (*reset)(cs4231_t *chip); - void (*preallocate)(cs4231_t *chip, snd_pcm_t *pcm); + void (*reset)(struct snd_cs4231 *chip); + void (*preallocate)(struct snd_cs4231 *chip, struct snd_snd_pcm *pcm); #ifdef EBUS_SUPPORT struct ebus_dma_info ebus_info; #endif #ifdef SBUS_SUPPORT struct sbus_dma_info sbus_info; #endif -} cs4231_dma_control_t; +}; struct snd_cs4231 { spinlock_t lock; void __iomem *port; - cs4231_dma_control_t p_dma; - cs4231_dma_control_t c_dma; + struct cs4231_dma_control p_dma; + struct cs4231_dma_control c_dma; u32 flags; #define CS4231_FLAG_EBUS 0x00000001 #define CS4231_FLAG_PLAYBACK 0x00000002 #define CS4231_FLAG_CAPTURE 0x00000004 - snd_card_t *card; - snd_pcm_t *pcm; - snd_pcm_substream_t *playback_substream; + struct snd_card *card; + struct snd_pcm *pcm; + struct snd_pcm_substream *playback_substream; unsigned int p_periods_sent; - snd_pcm_substream_t *capture_substream; + struct snd_pcm_substream *capture_substream; unsigned int c_periods_sent; - snd_timer_t *timer; + struct snd_timer *timer; unsigned short mode; #define CS4231_MODE_NONE 0x0000 @@ -132,7 +130,7 @@ struct snd_cs4231 { struct snd_cs4231 *next; }; -static cs4231_t *cs4231_list; +static struct snd_cs4231 *cs4231_list; /* Eventually we can use sound/isa/cs423x/cs4231_lib.c directly, but for * now.... -DaveM @@ -341,12 +339,12 @@ static unsigned int rates[14] = { 27042, 32000, 33075, 37800, 44100, 48000 }; -static snd_pcm_hw_constraint_list_t hw_constraints_rates = { +static struct snd_pcm_hw_constraint_list hw_constraints_rates = { .count = 14, .list = rates, }; -static int snd_cs4231_xrate(snd_pcm_runtime_t *runtime) +static int snd_cs4231_xrate(struct snd_pcm_runtime *runtime) { return snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, @@ -389,7 +387,7 @@ static unsigned char snd_cs4231_original_image[32] = 0x00, /* 1f/31 - cbrl */ }; -static u8 __cs4231_readb(cs4231_t *cp, void __iomem *reg_addr) +static u8 __cs4231_readb(struct snd_cs4231 *cp, void __iomem *reg_addr) { #ifdef EBUS_SUPPORT if (cp->flags & CS4231_FLAG_EBUS) { @@ -404,7 +402,7 @@ static u8 __cs4231_readb(cs4231_t *cp, void __iomem *reg_addr) #endif } -static void __cs4231_writeb(cs4231_t *cp, u8 val, void __iomem *reg_addr) +static void __cs4231_writeb(struct snd_cs4231 *cp, u8 val, void __iomem *reg_addr) { #ifdef EBUS_SUPPORT if (cp->flags & CS4231_FLAG_EBUS) { @@ -423,7 +421,7 @@ static void __cs4231_writeb(cs4231_t *cp, u8 val, void __iomem *reg_addr) * Basic I/O functions */ -static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, +static void snd_cs4231_outm(struct snd_cs4231 *chip, unsigned char reg, unsigned char mask, unsigned char value) { int timeout; @@ -450,7 +448,7 @@ static void snd_cs4231_outm(cs4231_t *chip, unsigned char reg, } } -static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char value) +static void snd_cs4231_dout(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) { int timeout; @@ -467,7 +465,7 @@ static void snd_cs4231_dout(cs4231_t *chip, unsigned char reg, unsigned char val mb(); } -static void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char value) +static void snd_cs4231_out(struct snd_cs4231 *chip, unsigned char reg, unsigned char value) { int timeout; @@ -485,7 +483,7 @@ static void snd_cs4231_out(cs4231_t *chip, unsigned char reg, unsigned char valu mb(); } -static unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) +static unsigned char snd_cs4231_in(struct snd_cs4231 *chip, unsigned char reg) { int timeout; unsigned char ret; @@ -508,7 +506,7 @@ static unsigned char snd_cs4231_in(cs4231_t *chip, unsigned char reg) * CS4231 detection / MCE routines */ -static void snd_cs4231_busy_wait(cs4231_t *chip) +static void snd_cs4231_busy_wait(struct snd_cs4231 *chip) { int timeout; @@ -523,7 +521,7 @@ static void snd_cs4231_busy_wait(cs4231_t *chip) udelay(1000); } -static void snd_cs4231_mce_up(cs4231_t *chip) +static void snd_cs4231_mce_up(struct snd_cs4231 *chip) { unsigned long flags; int timeout; @@ -544,7 +542,7 @@ static void snd_cs4231_mce_up(cs4231_t *chip) spin_unlock_irqrestore(&chip->lock, flags); } -static void snd_cs4231_mce_down(cs4231_t *chip) +static void snd_cs4231_mce_down(struct snd_cs4231 *chip) { unsigned long flags; int timeout; @@ -602,9 +600,11 @@ static void snd_cs4231_mce_down(cs4231_t *chip) spin_unlock_irqrestore(&chip->lock, flags); } -static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont, snd_pcm_substream_t *substream, unsigned int *periods_sent) +static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont, + struct snd_pcm_substream *substream, + unsigned int *periods_sent) { - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_pcm_runtime *runtime = substream->runtime; while (1) { unsigned int period_size = snd_pcm_lib_period_bytes(substream); @@ -619,10 +619,11 @@ static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont, snd_pcm_ } } -static void cs4231_dma_trigger(snd_pcm_substream_t *substream, unsigned int what, int on) +static void cs4231_dma_trigger(struct snd_pcm_substream *substream, + unsigned int what, int on) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - cs4231_dma_control_t *dma_cont; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct cs4231_dma_control *dma_cont; if (what & CS4231_PLAYBACK_ENABLE) { dma_cont = &chip->p_dma; @@ -650,9 +651,9 @@ static void cs4231_dma_trigger(snd_pcm_substream_t *substream, unsigned int what } } -static int snd_cs4231_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_cs4231_trigger(struct snd_pcm_substream *substream, int cmd) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); int result = 0; switch (cmd) { @@ -660,7 +661,7 @@ static int snd_cs4231_trigger(snd_pcm_substream_t *substream, int cmd) case SNDRV_PCM_TRIGGER_STOP: { unsigned int what = 0; - snd_pcm_substream_t *s; + struct snd_pcm_substream *s; struct list_head *pos; unsigned long flags; @@ -711,7 +712,7 @@ static unsigned char snd_cs4231_get_rate(unsigned int rate) return freq_bits[13]; } -static unsigned char snd_cs4231_get_format(cs4231_t *chip, int format, int channels) +static unsigned char snd_cs4231_get_format(struct snd_cs4231 *chip, int format, int channels) { unsigned char rformat; @@ -728,7 +729,7 @@ static unsigned char snd_cs4231_get_format(cs4231_t *chip, int format, int chann return rformat; } -static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) +static void snd_cs4231_calibrate_mute(struct snd_cs4231 *chip, int mute) { unsigned long flags; @@ -768,7 +769,7 @@ static void snd_cs4231_calibrate_mute(cs4231_t *chip, int mute) spin_unlock_irqrestore(&chip->lock, flags); } -static void snd_cs4231_playback_format(cs4231_t *chip, snd_pcm_hw_params_t *params, +static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char pdfr) { unsigned long flags; @@ -791,7 +792,7 @@ static void snd_cs4231_playback_format(cs4231_t *chip, snd_pcm_hw_params_t *para up(&chip->mce_mutex); } -static void snd_cs4231_capture_format(cs4231_t *chip, snd_pcm_hw_params_t *params, +static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params, unsigned char cdfr) { unsigned long flags; @@ -824,18 +825,18 @@ static void snd_cs4231_capture_format(cs4231_t *chip, snd_pcm_hw_params_t *param * Timer interface */ -static unsigned long snd_cs4231_timer_resolution(snd_timer_t *timer) +static unsigned long snd_cs4231_timer_resolution(struct snd_timer *timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); return chip->image[CS4231_PLAYBK_FORMAT] & 1 ? 9969 : 9920; } -static int snd_cs4231_timer_start(snd_timer_t *timer) +static int snd_cs4231_timer_start(struct snd_timer *timer) { unsigned long flags; unsigned int ticks; - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->lock, flags); ticks = timer->sticks; @@ -856,10 +857,10 @@ static int snd_cs4231_timer_start(snd_timer_t *timer) return 0; } -static int snd_cs4231_timer_stop(snd_timer_t *timer) +static int snd_cs4231_timer_stop(struct snd_timer *timer) { unsigned long flags; - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); spin_lock_irqsave(&chip->lock, flags); snd_cs4231_out(chip, CS4231_ALT_FEATURE_1, @@ -869,7 +870,7 @@ static int snd_cs4231_timer_stop(snd_timer_t *timer) return 0; } -static void snd_cs4231_init(cs4231_t *chip) +static void __init snd_cs4231_init(struct snd_cs4231 *chip) { unsigned long flags; @@ -927,7 +928,7 @@ static void snd_cs4231_init(cs4231_t *chip) #endif } -static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) +static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode) { unsigned long flags; @@ -962,7 +963,7 @@ static int snd_cs4231_open(cs4231_t *chip, unsigned int mode) return 0; } -static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) +static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode) { unsigned long flags; @@ -1013,21 +1014,21 @@ static void snd_cs4231_close(cs4231_t *chip, unsigned int mode) * timer open/close */ -static int snd_cs4231_timer_open(snd_timer_t *timer) +static int snd_cs4231_timer_open(struct snd_timer *timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); snd_cs4231_open(chip, CS4231_MODE_TIMER); return 0; } -static int snd_cs4231_timer_close(snd_timer_t * timer) +static int snd_cs4231_timer_close(struct snd_timer * timer) { - cs4231_t *chip = snd_timer_chip(timer); + struct snd_cs4231 *chip = snd_timer_chip(timer); snd_cs4231_close(chip, CS4231_MODE_TIMER); return 0; } -static struct _snd_timer_hardware snd_cs4231_timer_table = +static struct snd_timer_hardware snd_cs4231_timer_table = { .flags = SNDRV_TIMER_HW_AUTO, .resolution = 9945, @@ -1043,10 +1044,10 @@ static struct _snd_timer_hardware snd_cs4231_timer_table = * ok.. exported functions.. */ -static int snd_cs4231_playback_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_cs4231_playback_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_pdfr; int err; @@ -1061,15 +1062,15 @@ static int snd_cs4231_playback_hw_params(snd_pcm_substream_t *substream, return 0; } -static int snd_cs4231_playback_hw_free(snd_pcm_substream_t *substream) +static int snd_cs4231_playback_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_cs4231_playback_prepare(snd_pcm_substream_t *substream) +static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -1086,10 +1087,10 @@ static int snd_cs4231_playback_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_cs4231_capture_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_cs4231_capture_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned char new_cdfr; int err; @@ -1104,14 +1105,14 @@ static int snd_cs4231_capture_hw_params(snd_pcm_substream_t *substream, return 0; } -static int snd_cs4231_capture_hw_free(snd_pcm_substream_t *substream) +static int snd_cs4231_capture_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -static int snd_cs4231_capture_prepare(snd_pcm_substream_t *substream) +static int snd_cs4231_capture_prepare(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -1125,7 +1126,7 @@ static int snd_cs4231_capture_prepare(snd_pcm_substream_t *substream) return 0; } -static void snd_cs4231_overrange(cs4231_t *chip) +static void snd_cs4231_overrange(struct snd_cs4231 *chip) { unsigned long flags; unsigned char res; @@ -1138,10 +1139,8 @@ static void snd_cs4231_overrange(cs4231_t *chip) chip->capture_substream->runtime->overrange++; } -static void snd_cs4231_play_callback(cs4231_t *cookie) +static void snd_cs4231_play_callback(struct snd_cs4231 *chip) { - cs4231_t *chip = cookie; - if (chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE) { snd_pcm_period_elapsed(chip->playback_substream); snd_cs4231_advance_dma(&chip->p_dma, chip->playback_substream, @@ -1149,10 +1148,8 @@ static void snd_cs4231_play_callback(cs4231_t *cookie) } } -static void snd_cs4231_capture_callback(cs4231_t *cookie) +static void snd_cs4231_capture_callback(struct snd_cs4231 *chip) { - cs4231_t *chip = cookie; - if (chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE) { snd_pcm_period_elapsed(chip->capture_substream); snd_cs4231_advance_dma(&chip->c_dma, chip->capture_substream, @@ -1160,10 +1157,10 @@ static void snd_cs4231_capture_callback(cs4231_t *cookie) } } -static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_cs4231_playback_pointer(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - cs4231_dma_control_t *dma_cont = &chip->p_dma; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct cs4231_dma_control *dma_cont = &chip->p_dma; size_t ptr; if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_PLAYBACK_ENABLE)) @@ -1175,10 +1172,10 @@ static snd_pcm_uframes_t snd_cs4231_playback_pointer(snd_pcm_substream_t *substr return bytes_to_frames(substream->runtime, ptr); } -static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substream) +static snd_pcm_uframes_t snd_cs4231_capture_pointer(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - cs4231_dma_control_t *dma_cont = &chip->c_dma; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct cs4231_dma_control *dma_cont = &chip->c_dma; size_t ptr; if (!(chip->image[CS4231_IFACE_CTRL] & CS4231_RECORD_ENABLE)) @@ -1194,7 +1191,7 @@ static snd_pcm_uframes_t snd_cs4231_capture_pointer(snd_pcm_substream_t * substr */ -static int snd_cs4231_probe(cs4231_t *chip) +static int __init snd_cs4231_probe(struct snd_cs4231 *chip) { unsigned long flags; int i, id, vers; @@ -1259,7 +1256,7 @@ static int snd_cs4231_probe(cs4231_t *chip) return 0; /* all things are ok.. */ } -static snd_pcm_hardware_t snd_cs4231_playback = +static struct snd_pcm_hardware snd_cs4231_playback = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), @@ -1279,7 +1276,7 @@ static snd_pcm_hardware_t snd_cs4231_playback = .periods_max = 1024, }; -static snd_pcm_hardware_t snd_cs4231_capture = +static struct snd_pcm_hardware snd_cs4231_capture = { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START), @@ -1299,10 +1296,10 @@ static snd_pcm_hardware_t snd_cs4231_capture = .periods_max = 1024, }; -static int snd_cs4231_playback_open(snd_pcm_substream_t *substream) +static int snd_cs4231_playback_open(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; runtime->hw = snd_cs4231_playback; @@ -1319,10 +1316,10 @@ static int snd_cs4231_playback_open(snd_pcm_substream_t *substream) return 0; } -static int snd_cs4231_capture_open(snd_pcm_substream_t *substream) +static int snd_cs4231_capture_open(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; runtime->hw = snd_cs4231_capture; @@ -1339,9 +1336,9 @@ static int snd_cs4231_capture_open(snd_pcm_substream_t *substream) return 0; } -static int snd_cs4231_playback_close(snd_pcm_substream_t *substream) +static int snd_cs4231_playback_close(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); snd_cs4231_close(chip, CS4231_MODE_PLAY); chip->playback_substream = NULL; @@ -1349,9 +1346,9 @@ static int snd_cs4231_playback_close(snd_pcm_substream_t *substream) return 0; } -static int snd_cs4231_capture_close(snd_pcm_substream_t *substream) +static int snd_cs4231_capture_close(struct snd_pcm_substream *substream) { - cs4231_t *chip = snd_pcm_substream_chip(substream); + struct snd_cs4231 *chip = snd_pcm_substream_chip(substream); snd_cs4231_close(chip, CS4231_MODE_RECORD); chip->capture_substream = NULL; @@ -1363,7 +1360,7 @@ static int snd_cs4231_capture_close(snd_pcm_substream_t *substream) * XXX the audio AUXIO register... */ -static snd_pcm_ops_t snd_cs4231_playback_ops = { +static struct snd_pcm_ops snd_cs4231_playback_ops = { .open = snd_cs4231_playback_open, .close = snd_cs4231_playback_close, .ioctl = snd_pcm_lib_ioctl, @@ -1374,7 +1371,7 @@ static snd_pcm_ops_t snd_cs4231_playback_ops = { .pointer = snd_cs4231_playback_pointer, }; -static snd_pcm_ops_t snd_cs4231_capture_ops = { +static struct snd_pcm_ops snd_cs4231_capture_ops = { .open = snd_cs4231_capture_open, .close = snd_cs4231_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -1385,9 +1382,9 @@ static snd_pcm_ops_t snd_cs4231_capture_ops = { .pointer = snd_cs4231_capture_pointer, }; -int snd_cs4231_pcm(cs4231_t *chip) +static int __init snd_cs4231_pcm(struct snd_cs4231 *chip) { - snd_pcm_t *pcm; + struct snd_pcm *pcm; int err; if ((err = snd_pcm_new(chip->card, "CS4231", 0, 1, 1, &pcm)) < 0) @@ -1408,16 +1405,10 @@ int snd_cs4231_pcm(cs4231_t *chip) return 0; } -static void snd_cs4231_timer_free(snd_timer_t *timer) +static int __init snd_cs4231_timer(struct snd_cs4231 *chip) { - cs4231_t *chip = timer->private_data; - chip->timer = NULL; -} - -int snd_cs4231_timer(cs4231_t *chip) -{ - snd_timer_t *timer; - snd_timer_id_t tid; + struct snd_timer *timer; + struct snd_timer_id tid; int err; /* Timer initialization */ @@ -1430,7 +1421,6 @@ int snd_cs4231_timer(cs4231_t *chip) return err; strcpy(timer->name, "CS4231"); timer->private_data = chip; - timer->private_free = snd_cs4231_timer_free; timer->hw = snd_cs4231_timer_table; chip->timer = timer; @@ -1441,12 +1431,13 @@ int snd_cs4231_timer(cs4231_t *chip) * MIXER part */ -static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_cs4231_info_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { static char *texts[4] = { "Line", "CD", "Mic", "Mix" }; - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); snd_assert(chip->card != NULL, return -EINVAL); uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; @@ -1459,9 +1450,10 @@ static int snd_cs4231_info_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *ui return 0; } -static int snd_cs4231_get_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cs4231_get_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; spin_lock_irqsave(&chip->lock, flags); @@ -1474,9 +1466,10 @@ static int snd_cs4231_get_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc return 0; } -static int snd_cs4231_put_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cs4231_put_mux(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; unsigned short left, right; int change; @@ -1501,7 +1494,8 @@ static int snd_cs4231_put_mux(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *uc return change; } -int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_cs4231_info_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 16) & 0xff; @@ -1514,9 +1508,10 @@ int snd_cs4231_info_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -int snd_cs4231_get_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cs4231_get_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1536,9 +1531,10 @@ int snd_cs4231_get_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -int snd_cs4231_put_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cs4231_put_single(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int reg = kcontrol->private_value & 0xff; int shift = (kcontrol->private_value >> 8) & 0xff; @@ -1563,7 +1559,8 @@ int snd_cs4231_put_single(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return change; } -int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) +static int snd_cs4231_info_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) { int mask = (kcontrol->private_value >> 24) & 0xff; @@ -1576,9 +1573,10 @@ int snd_cs4231_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) return 0; } -int snd_cs4231_get_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cs4231_get_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1604,9 +1602,10 @@ int snd_cs4231_get_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr return 0; } -int snd_cs4231_put_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) +static int snd_cs4231_put_double(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) { - cs4231_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_cs4231 *chip = snd_kcontrol_chip(kcontrol); unsigned long flags; int left_reg = kcontrol->private_value & 0xff; int right_reg = (kcontrol->private_value >> 8) & 0xff; @@ -1651,7 +1650,7 @@ int snd_cs4231_put_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontr .get = snd_cs4231_get_double, .put = snd_cs4231_put_double, \ .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } -static snd_kcontrol_new_t snd_cs4231_controls[] = { +static struct snd_kcontrol_new snd_cs4231_controls[] __initdata = { CS4231_DOUBLE("PCM Playback Switch", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 7, 7, 1, 1), CS4231_DOUBLE("PCM Playback Volume", 0, CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 63, 1), CS4231_DOUBLE("Line Playback Switch", 0, CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1), @@ -1680,9 +1679,9 @@ CS4231_SINGLE("Line Out Switch", 0, CS4231_PIN_CTRL, 6, 1, 1), CS4231_SINGLE("Headphone Out Switch", 0, CS4231_PIN_CTRL, 7, 1, 1) }; -int snd_cs4231_mixer(cs4231_t *chip) +static int __init snd_cs4231_mixer(struct snd_cs4231 *chip) { - snd_card_t *card; + struct snd_card *card; int err, idx; snd_assert(chip != NULL && chip->pcm != NULL, return -EINVAL); @@ -1702,9 +1701,9 @@ int snd_cs4231_mixer(cs4231_t *chip) static int dev; -static int cs4231_attach_begin(snd_card_t **rcard) +static int __init cs4231_attach_begin(struct snd_card **rcard) { - snd_card_t *card; + struct snd_card *card; *rcard = NULL; @@ -1727,7 +1726,7 @@ static int cs4231_attach_begin(snd_card_t **rcard) return 0; } -static int cs4231_attach_finish(snd_card_t *card, cs4231_t *chip) +static int __init cs4231_attach_finish(struct snd_card *card, struct snd_cs4231 *chip) { int err; @@ -1761,7 +1760,7 @@ static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id, struct pt_re unsigned long flags; unsigned char status; u32 csr; - cs4231_t *chip = dev_id; + struct snd_cs4231 *chip = dev_id; /*This is IRQ is not raised by the cs4231*/ if (!(__cs4231_readb(chip, CS4231P(chip, STATUS)) & CS4231_GLOBALIRQ)) @@ -1806,12 +1805,12 @@ static irqreturn_t snd_cs4231_sbus_interrupt(int irq, void *dev_id, struct pt_re * SBUS DMA routines */ -int sbus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) +static int sbus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) { unsigned long flags; u32 test, csr; int err; - sbus_dma_info_t *base = &dma_cont->sbus_info; + struct sbus_dma_info *base = &dma_cont->sbus_info; if (len >= (1 << 24)) return -EINVAL; @@ -1838,11 +1837,11 @@ out: return err; } -void sbus_dma_prepare(struct cs4231_dma_control *dma_cont, int d) +static void sbus_dma_prepare(struct cs4231_dma_control *dma_cont, int d) { unsigned long flags; u32 csr, test; - sbus_dma_info_t *base = &dma_cont->sbus_info; + struct sbus_dma_info *base = &dma_cont->sbus_info; spin_lock_irqsave(&base->lock, flags); csr = sbus_readl(base->regs + APCCSR); @@ -1857,11 +1856,11 @@ void sbus_dma_prepare(struct cs4231_dma_control *dma_cont, int d) spin_unlock_irqrestore(&base->lock, flags); } -void sbus_dma_enable(struct cs4231_dma_control *dma_cont, int on) +static void sbus_dma_enable(struct cs4231_dma_control *dma_cont, int on) { unsigned long flags; u32 csr, shift; - sbus_dma_info_t *base = &dma_cont->sbus_info; + struct sbus_dma_info *base = &dma_cont->sbus_info; spin_lock_irqsave(&base->lock, flags); if (!on) { @@ -1894,14 +1893,14 @@ void sbus_dma_enable(struct cs4231_dma_control *dma_cont, int on) spin_unlock_irqrestore(&base->lock, flags); } -unsigned int sbus_dma_addr(struct cs4231_dma_control *dma_cont) +static unsigned int sbus_dma_addr(struct cs4231_dma_control *dma_cont) { - sbus_dma_info_t *base = &dma_cont->sbus_info; + struct sbus_dma_info *base = &dma_cont->sbus_info; return sbus_readl(base->regs + base->dir + APCVA); } -void sbus_dma_reset(cs4231_t *chip) +static void sbus_dma_reset(struct snd_cs4231 *chip) { sbus_writel(APC_CHIP_RESET, chip->port + APCCSR); sbus_writel(0x00, chip->port + APCCSR); @@ -1918,7 +1917,7 @@ void sbus_dma_reset(cs4231_t *chip) chip->port + APCCSR); } -void sbus_dma_preallocate(cs4231_t *chip, snd_pcm_t *pcm) +static void sbus_dma_preallocate(struct snd_cs4231 *chip, struct snd_pcm *pcm) { snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_SBUS, snd_dma_sbus_data(chip->dev_u.sdev), @@ -1929,7 +1928,7 @@ void sbus_dma_preallocate(cs4231_t *chip, snd_pcm_t *pcm) * Init and exit routines */ -static int snd_cs4231_sbus_free(cs4231_t *chip) +static int snd_cs4231_sbus_free(struct snd_cs4231 *chip) { if (chip->irq[0]) free_irq(chip->irq[0], chip); @@ -1937,31 +1936,28 @@ static int snd_cs4231_sbus_free(cs4231_t *chip) if (chip->port) sbus_iounmap(chip->port, chip->regs_size); - if (chip->timer) - snd_device_free(chip->card, chip->timer); - kfree(chip); return 0; } -static int snd_cs4231_sbus_dev_free(snd_device_t *device) +static int snd_cs4231_sbus_dev_free(struct snd_device *device) { - cs4231_t *cp = device->device_data; + struct snd_cs4231 *cp = device->device_data; return snd_cs4231_sbus_free(cp); } -static snd_device_ops_t snd_cs4231_sbus_dev_ops = { +static struct snd_device_ops snd_cs4231_sbus_dev_ops = { .dev_free = snd_cs4231_sbus_dev_free, }; -static int __init snd_cs4231_sbus_create(snd_card_t *card, +static int __init snd_cs4231_sbus_create(struct snd_card *card, struct sbus_dev *sdev, int dev, - cs4231_t **rchip) + struct snd_cs4231 **rchip) { - cs4231_t *chip; + struct snd_cs4231 *chip; int err; *rchip = NULL; @@ -2032,11 +2028,11 @@ static int __init snd_cs4231_sbus_create(snd_card_t *card, return 0; } -static int cs4231_sbus_attach(struct sbus_dev *sdev) +static int __init cs4231_sbus_attach(struct sbus_dev *sdev) { struct resource *rp = &sdev->resource[0]; - cs4231_t *cp; - snd_card_t *card; + struct snd_cs4231 *cp; + struct snd_card *card; int err; err = cs4231_attach_begin(&card); @@ -2062,14 +2058,14 @@ static int cs4231_sbus_attach(struct sbus_dev *sdev) static void snd_cs4231_ebus_play_callback(struct ebus_dma_info *p, int event, void *cookie) { - cs4231_t *chip = cookie; + struct snd_cs4231 *chip = cookie; snd_cs4231_play_callback(chip); } static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, void *cookie) { - cs4231_t *chip = cookie; + struct snd_cs4231 *chip = cookie; snd_cs4231_capture_callback(chip); } @@ -2078,32 +2074,32 @@ static void snd_cs4231_ebus_capture_callback(struct ebus_dma_info *p, int event, * EBUS DMA wrappers */ -int _ebus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) +static int _ebus_dma_request(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len) { return ebus_dma_request(&dma_cont->ebus_info, bus_addr, len); } -void _ebus_dma_enable(struct cs4231_dma_control *dma_cont, int on) +static void _ebus_dma_enable(struct cs4231_dma_control *dma_cont, int on) { ebus_dma_enable(&dma_cont->ebus_info, on); } -void _ebus_dma_prepare(struct cs4231_dma_control *dma_cont, int dir) +static void _ebus_dma_prepare(struct cs4231_dma_control *dma_cont, int dir) { ebus_dma_prepare(&dma_cont->ebus_info, dir); } -unsigned int _ebus_dma_addr(struct cs4231_dma_control *dma_cont) +static unsigned int _ebus_dma_addr(struct cs4231_dma_control *dma_cont) { return ebus_dma_addr(&dma_cont->ebus_info); } -void _ebus_dma_reset(cs4231_t *chip) +static void _ebus_dma_reset(struct snd_cs4231 *chip) { return; } -void _ebus_dma_preallocate(cs4231_t *chip, snd_pcm_t *pcm) +static void _ebus_dma_preallocate(struct snd_cs4231 *chip, struct snd_pcm *pcm) { snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->dev_u.pdev), @@ -2114,7 +2110,7 @@ void _ebus_dma_preallocate(cs4231_t *chip, snd_pcm_t *pcm) * Init and exit routines */ -static int snd_cs4231_ebus_free(cs4231_t *chip) +static int snd_cs4231_ebus_free(struct snd_cs4231 *chip) { if (chip->c_dma.ebus_info.regs) { ebus_dma_unregister(&chip->c_dma.ebus_info); @@ -2127,31 +2123,29 @@ static int snd_cs4231_ebus_free(cs4231_t *chip) if (chip->port) iounmap(chip->port); - if (chip->timer) - snd_device_free(chip->card, chip->timer); kfree(chip); return 0; } -static int snd_cs4231_ebus_dev_free(snd_device_t *device) +static int snd_cs4231_ebus_dev_free(struct snd_device *device) { - cs4231_t *cp = device->device_data; + struct snd_cs4231 *cp = device->device_data; return snd_cs4231_ebus_free(cp); } -static snd_device_ops_t snd_cs4231_ebus_dev_ops = { +static struct snd_device_ops snd_cs4231_ebus_dev_ops = { .dev_free = snd_cs4231_ebus_dev_free, }; -static int __init snd_cs4231_ebus_create(snd_card_t *card, +static int __init snd_cs4231_ebus_create(struct snd_card *card, struct linux_ebus_device *edev, int dev, - cs4231_t **rchip) + struct snd_cs4231 **rchip) { - cs4231_t *chip; + struct snd_cs4231 *chip; int err; *rchip = NULL; @@ -2241,10 +2235,10 @@ static int __init snd_cs4231_ebus_create(snd_card_t *card, return 0; } -static int cs4231_ebus_attach(struct linux_ebus_device *edev) +static int __init cs4231_ebus_attach(struct linux_ebus_device *edev) { - snd_card_t *card; - cs4231_t *chip; + struct snd_card *card; + struct snd_cs4231 *chip; int err; err = cs4231_attach_begin(&card); @@ -2317,10 +2311,10 @@ static int __init cs4231_init(void) static void __exit cs4231_exit(void) { - cs4231_t *p = cs4231_list; + struct snd_cs4231 *p = cs4231_list; while (p != NULL) { - cs4231_t *next = p->next; + struct snd_cs4231 *next = p->next; snd_card_free(p->card); -- cgit v1.1 From 48d727a9f93e617d6d443507acf7d1b849c63366 Mon Sep 17 00:00:00 2001 From: Paolo 'Blaisorblade' Giarrusso Date: Tue, 3 Jan 2006 13:44:23 +0100 Subject: Documentation/filesystems/00-INDEX: remove entry for fat_cvf.txt Remove non-existing entry for fat_cvf.txt (was it ever supported?). Signed-off-by: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Adrian Bunk --- Documentation/filesystems/00-INDEX | 2 -- 1 file changed, 2 deletions(-) diff --git a/Documentation/filesystems/00-INDEX b/Documentation/filesystems/00-INDEX index bcfbab8..7e17712 100644 --- a/Documentation/filesystems/00-INDEX +++ b/Documentation/filesystems/00-INDEX @@ -18,8 +18,6 @@ devfs/ - directory containing devfs documentation. ext2.txt - info, mount options and specifications for the Ext2 filesystem. -fat_cvf.txt - - info on the Compressed Volume Files extension to the FAT filesystem hpfs.txt - info and mount options for the OS/2 HPFS. isofs.txt -- cgit v1.1 From 408045afbdb46e109a1a44e67af688e9ddf7ad66 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Wed, 21 Dec 2005 15:21:36 -0700 Subject: [IA64] incorrect return from ia64_pci_legacy_write() The function ia64_pci_legacy_write() returns 0 for everything except errors. This return value gets sent back to the user from pci_write_legacy_io(), making it look like every write fails. The trivial patch below copies the behavior of the SGI sn machvec and does what would be expected from something implementing a write() function. Signed-off-by: Alex Williamson Signed-off-by: Tony Luck --- arch/ia64/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c index 20d76fa..30dbc98 100644 --- a/arch/ia64/pci/pci.c +++ b/arch/ia64/pci/pci.c @@ -700,7 +700,7 @@ int ia64_pci_legacy_read(struct pci_bus *bus, u16 port, u32 *val, u8 size) */ int ia64_pci_legacy_write(struct pci_dev *bus, u16 port, u32 val, u8 size) { - int ret = 0; + int ret = size; switch (size) { case 1: -- cgit v1.1 From 7063fbf2261194f72ee75afca67b3b38b554b5fa Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Thu, 15 Dec 2005 14:29:43 -0800 Subject: [PATCH] configfs: User-driven configuration filesystem Configfs, a file system for userspace-driven kernel object configuration. The OCFS2 stack makes extensive use of this for propagation of cluster configuration information into kernel. Signed-off-by: Joel Becker --- Documentation/filesystems/00-INDEX | 2 + Documentation/filesystems/configfs/configfs.txt | 434 ++++++++ .../filesystems/configfs/configfs_example.c | 474 +++++++++ MAINTAINERS | 5 + fs/Kconfig | 14 + fs/Makefile | 1 + fs/configfs/Makefile | 7 + fs/configfs/configfs_internal.h | 142 +++ fs/configfs/dir.c | 1102 ++++++++++++++++++++ fs/configfs/file.c | 360 +++++++ fs/configfs/inode.c | 162 +++ fs/configfs/item.c | 227 ++++ fs/configfs/mount.c | 159 +++ fs/configfs/symlink.c | 281 +++++ include/linux/configfs.h | 205 ++++ 15 files changed, 3575 insertions(+) create mode 100644 Documentation/filesystems/configfs/configfs.txt create mode 100644 Documentation/filesystems/configfs/configfs_example.c create mode 100644 fs/configfs/Makefile create mode 100644 fs/configfs/configfs_internal.h create mode 100644 fs/configfs/dir.c create mode 100644 fs/configfs/file.c create mode 100644 fs/configfs/inode.c create mode 100644 fs/configfs/item.c create mode 100644 fs/configfs/mount.c create mode 100644 fs/configfs/symlink.c create mode 100644 include/linux/configfs.h diff --git a/Documentation/filesystems/00-INDEX b/Documentation/filesystems/00-INDEX index bcfbab8..628f8a7 100644 --- a/Documentation/filesystems/00-INDEX +++ b/Documentation/filesystems/00-INDEX @@ -12,6 +12,8 @@ cifs.txt - description of the CIFS filesystem coda.txt - description of the CODA filesystem. +configfs/ + - directory containing configfs documentation and example code. cramfs.txt - info on the cram filesystem for small storage (ROMs etc) devfs/ diff --git a/Documentation/filesystems/configfs/configfs.txt b/Documentation/filesystems/configfs/configfs.txt new file mode 100644 index 0000000..c4ff96b --- /dev/null +++ b/Documentation/filesystems/configfs/configfs.txt @@ -0,0 +1,434 @@ + +configfs - Userspace-driven kernel object configuation. + +Joel Becker + +Updated: 31 March 2005 + +Copyright (c) 2005 Oracle Corporation, + Joel Becker + + +[What is configfs?] + +configfs is a ram-based filesystem that provides the converse of +sysfs's functionality. Where sysfs is a filesystem-based view of +kernel objects, configfs is a filesystem-based manager of kernel +objects, or config_items. + +With sysfs, an object is created in kernel (for example, when a device +is discovered) and it is registered with sysfs. Its attributes then +appear in sysfs, allowing userspace to read the attributes via +readdir(3)/read(2). It may allow some attributes to be modified via +write(2). The important point is that the object is created and +destroyed in kernel, the kernel controls the lifecycle of the sysfs +representation, and sysfs is merely a window on all this. + +A configfs config_item is created via an explicit userspace operation: +mkdir(2). It is destroyed via rmdir(2). The attributes appear at +mkdir(2) time, and can be read or modified via read(2) and write(2). +As with sysfs, readdir(3) queries the list of items and/or attributes. +symlink(2) can be used to group items together. Unlike sysfs, the +lifetime of the representation is completely driven by userspace. The +kernel modules backing the items must respond to this. + +Both sysfs and configfs can and should exist together on the same +system. One is not a replacement for the other. + +[Using configfs] + +configfs can be compiled as a module or into the kernel. You can access +it by doing + + mount -t configfs none /config + +The configfs tree will be empty unless client modules are also loaded. +These are modules that register their item types with configfs as +subsystems. Once a client subsystem is loaded, it will appear as a +subdirectory (or more than one) under /config. Like sysfs, the +configfs tree is always there, whether mounted on /config or not. + +An item is created via mkdir(2). The item's attributes will also +appear at this time. readdir(3) can determine what the attributes are, +read(2) can query their default values, and write(2) can store new +values. Like sysfs, attributes should be ASCII text files, preferably +with only one value per file. The same efficiency caveats from sysfs +apply. Don't mix more than one attribute in one attribute file. + +Like sysfs, configfs expects write(2) to store the entire buffer at +once. When writing to configfs attributes, userspace processes should +first read the entire file, modify the portions they wish to change, and +then write the entire buffer back. Attribute files have a maximum size +of one page (PAGE_SIZE, 4096 on i386). + +When an item needs to be destroyed, remove it with rmdir(2). An +item cannot be destroyed if any other item has a link to it (via +symlink(2)). Links can be removed via unlink(2). + +[Configuring FakeNBD: an Example] + +Imagine there's a Network Block Device (NBD) driver that allows you to +access remote block devices. Call it FakeNBD. FakeNBD uses configfs +for its configuration. Obviously, there will be a nice program that +sysadmins use to configure FakeNBD, but somehow that program has to tell +the driver about it. Here's where configfs comes in. + +When the FakeNBD driver is loaded, it registers itself with configfs. +readdir(3) sees this just fine: + + # ls /config + fakenbd + +A fakenbd connection can be created with mkdir(2). The name is +arbitrary, but likely the tool will make some use of the name. Perhaps +it is a uuid or a disk name: + + # mkdir /config/fakenbd/disk1 + # ls /config/fakenbd/disk1 + target device rw + +The target attribute contains the IP address of the server FakeNBD will +connect to. The device attribute is the device on the server. +Predictably, the rw attribute determines whether the connection is +read-only or read-write. + + # echo 10.0.0.1 > /config/fakenbd/disk1/target + # echo /dev/sda1 > /config/fakenbd/disk1/device + # echo 1 > /config/fakenbd/disk1/rw + +That's it. That's all there is. Now the device is configured, via the +shell no less. + +[Coding With configfs] + +Every object in configfs is a config_item. A config_item reflects an +object in the subsystem. It has attributes that match values on that +object. configfs handles the filesystem representation of that object +and its attributes, allowing the subsystem to ignore all but the +basic show/store interaction. + +Items are created and destroyed inside a config_group. A group is a +collection of items that share the same attributes and operations. +Items are created by mkdir(2) and removed by rmdir(2), but configfs +handles that. The group has a set of operations to perform these tasks + +A subsystem is the top level of a client module. During initialization, +the client module registers the subsystem with configfs, the subsystem +appears as a directory at the top of the configfs filesystem. A +subsystem is also a config_group, and can do everything a config_group +can. + +[struct config_item] + + struct config_item { + char *ci_name; + char ci_namebuf[UOBJ_NAME_LEN]; + struct kref ci_kref; + struct list_head ci_entry; + struct config_item *ci_parent; + struct config_group *ci_group; + struct config_item_type *ci_type; + struct dentry *ci_dentry; + }; + + void config_item_init(struct config_item *); + void config_item_init_type_name(struct config_item *, + const char *name, + struct config_item_type *type); + struct config_item *config_item_get(struct config_item *); + void config_item_put(struct config_item *); + +Generally, struct config_item is embedded in a container structure, a +structure that actually represents what the subsystem is doing. The +config_item portion of that structure is how the object interacts with +configfs. + +Whether statically defined in a source file or created by a parent +config_group, a config_item must have one of the _init() functions +called on it. This initializes the reference count and sets up the +appropriate fields. + +All users of a config_item should have a reference on it via +config_item_get(), and drop the reference when they are done via +config_item_put(). + +By itself, a config_item cannot do much more than appear in configfs. +Usually a subsystem wants the item to display and/or store attributes, +among other things. For that, it needs a type. + +[struct config_item_type] + + struct configfs_item_operations { + void (*release)(struct config_item *); + ssize_t (*show_attribute)(struct config_item *, + struct configfs_attribute *, + char *); + ssize_t (*store_attribute)(struct config_item *, + struct configfs_attribute *, + const char *, size_t); + int (*allow_link)(struct config_item *src, + struct config_item *target); + int (*drop_link)(struct config_item *src, + struct config_item *target); + }; + + struct config_item_type { + struct module *ct_owner; + struct configfs_item_operations *ct_item_ops; + struct configfs_group_operations *ct_group_ops; + struct configfs_attribute **ct_attrs; + }; + +The most basic function of a config_item_type is to define what +operations can be performed on a config_item. All items that have been +allocated dynamically will need to provide the ct_item_ops->release() +method. This method is called when the config_item's reference count +reaches zero. Items that wish to display an attribute need to provide +the ct_item_ops->show_attribute() method. Similarly, storing a new +attribute value uses the store_attribute() method. + +[struct configfs_attribute] + + struct configfs_attribute { + char *ca_name; + struct module *ca_owner; + mode_t ca_mode; + }; + +When a config_item wants an attribute to appear as a file in the item's +configfs directory, it must define a configfs_attribute describing it. +It then adds the attribute to the NULL-terminated array +config_item_type->ct_attrs. When the item appears in configfs, the +attribute file will appear with the configfs_attribute->ca_name +filename. configfs_attribute->ca_mode specifies the file permissions. + +If an attribute is readable and the config_item provides a +ct_item_ops->show_attribute() method, that method will be called +whenever userspace asks for a read(2) on the attribute. The converse +will happen for write(2). + +[struct config_group] + +A config_item cannot live in a vaccum. The only way one can be created +is via mkdir(2) on a config_group. This will trigger creation of a +child item. + + struct config_group { + struct config_item cg_item; + struct list_head cg_children; + struct configfs_subsystem *cg_subsys; + struct config_group **default_groups; + }; + + void config_group_init(struct config_group *group); + void config_group_init_type_name(struct config_group *group, + const char *name, + struct config_item_type *type); + + +The config_group structure contains a config_item. Properly configuring +that item means that a group can behave as an item in its own right. +However, it can do more: it can create child items or groups. This is +accomplished via the group operations specified on the group's +config_item_type. + + struct configfs_group_operations { + struct config_item *(*make_item)(struct config_group *group, + const char *name); + struct config_group *(*make_group)(struct config_group *group, + const char *name); + int (*commit_item)(struct config_item *item); + void (*drop_item)(struct config_group *group, + struct config_item *item); + }; + +A group creates child items by providing the +ct_group_ops->make_item() method. If provided, this method is called from mkdir(2) in the group's directory. The subsystem allocates a new +config_item (or more likely, its container structure), initializes it, +and returns it to configfs. Configfs will then populate the filesystem +tree to reflect the new item. + +If the subsystem wants the child to be a group itself, the subsystem +provides ct_group_ops->make_group(). Everything else behaves the same, +using the group _init() functions on the group. + +Finally, when userspace calls rmdir(2) on the item or group, +ct_group_ops->drop_item() is called. As a config_group is also a +config_item, it is not necessary for a seperate drop_group() method. +The subsystem must config_item_put() the reference that was initialized +upon item allocation. If a subsystem has no work to do, it may omit +the ct_group_ops->drop_item() method, and configfs will call +config_item_put() on the item on behalf of the subsystem. + +IMPORTANT: drop_item() is void, and as such cannot fail. When rmdir(2) +is called, configfs WILL remove the item from the filesystem tree +(assuming that it has no children to keep it busy). The subsystem is +responsible for responding to this. If the subsystem has references to +the item in other threads, the memory is safe. It may take some time +for the item to actually disappear from the subsystem's usage. But it +is gone from configfs. + +A config_group cannot be removed while it still has child items. This +is implemented in the configfs rmdir(2) code. ->drop_item() will not be +called, as the item has not been dropped. rmdir(2) will fail, as the +directory is not empty. + +[struct configfs_subsystem] + +A subsystem must register itself, ususally at module_init time. This +tells configfs to make the subsystem appear in the file tree. + + struct configfs_subsystem { + struct config_group su_group; + struct semaphore su_sem; + }; + + int configfs_register_subsystem(struct configfs_subsystem *subsys); + void configfs_unregister_subsystem(struct configfs_subsystem *subsys); + + A subsystem consists of a toplevel config_group and a semaphore. +The group is where child config_items are created. For a subsystem, +this group is usually defined statically. Before calling +configfs_register_subsystem(), the subsystem must have initialized the +group via the usual group _init() functions, and it must also have +initialized the semaphore. + When the register call returns, the subsystem is live, and it +will be visible via configfs. At that point, mkdir(2) can be called and +the subsystem must be ready for it. + +[An Example] + +The best example of these basic concepts is the simple_children +subsystem/group and the simple_child item in configfs_example.c It +shows a trivial object displaying and storing an attribute, and a simple +group creating and destroying these children. + +[Hierarchy Navigation and the Subsystem Semaphore] + +There is an extra bonus that configfs provides. The config_groups and +config_items are arranged in a hierarchy due to the fact that they +appear in a filesystem. A subsystem is NEVER to touch the filesystem +parts, but the subsystem might be interested in this hierarchy. For +this reason, the hierarchy is mirrored via the config_group->cg_children +and config_item->ci_parent structure members. + +A subsystem can navigate the cg_children list and the ci_parent pointer +to see the tree created by the subsystem. This can race with configfs' +management of the hierarchy, so configfs uses the subsystem semaphore to +protect modifications. Whenever a subsystem wants to navigate the +hierarchy, it must do so under the protection of the subsystem +semaphore. + +A subsystem will be prevented from acquiring the semaphore while a newly +allocated item has not been linked into this hierarchy. Similarly, it +will not be able to acquire the semaphore while a dropping item has not +yet been unlinked. This means that an item's ci_parent pointer will +never be NULL while the item is in configfs, and that an item will only +be in its parent's cg_children list for the same duration. This allows +a subsystem to trust ci_parent and cg_children while they hold the +semaphore. + +[Item Aggregation Via symlink(2)] + +configfs provides a simple group via the group->item parent/child +relationship. Often, however, a larger environment requires aggregation +outside of the parent/child connection. This is implemented via +symlink(2). + +A config_item may provide the ct_item_ops->allow_link() and +ct_item_ops->drop_link() methods. If the ->allow_link() method exists, +symlink(2) may be called with the config_item as the source of the link. +These links are only allowed between configfs config_items. Any +symlink(2) attempt outside the configfs filesystem will be denied. + +When symlink(2) is called, the source config_item's ->allow_link() +method is called with itself and a target item. If the source item +allows linking to target item, it returns 0. A source item may wish to +reject a link if it only wants links to a certain type of object (say, +in its own subsystem). + +When unlink(2) is called on the symbolic link, the source item is +notified via the ->drop_link() method. Like the ->drop_item() method, +this is a void function and cannot return failure. The subsystem is +responsible for responding to the change. + +A config_item cannot be removed while it links to any other item, nor +can it be removed while an item links to it. Dangling symlinks are not +allowed in configfs. + +[Automatically Created Subgroups] + +A new config_group may want to have two types of child config_items. +While this could be codified by magic names in ->make_item(), it is much +more explicit to have a method whereby userspace sees this divergence. + +Rather than have a group where some items behave differently than +others, configfs provides a method whereby one or many subgroups are +automatically created inside the parent at its creation. Thus, +mkdir("parent) results in "parent", "parent/subgroup1", up through +"parent/subgroupN". Items of type 1 can now be created in +"parent/subgroup1", and items of type N can be created in +"parent/subgroupN". + +These automatic subgroups, or default groups, do not preclude other +children of the parent group. If ct_group_ops->make_group() exists, +other child groups can be created on the parent group directly. + +A configfs subsystem specifies default groups by filling in the +NULL-terminated array default_groups on the config_group structure. +Each group in that array is populated in the configfs tree at the same +time as the parent group. Similarly, they are removed at the same time +as the parent. No extra notification is provided. When a ->drop_item() +method call notifies the subsystem the parent group is going away, it +also means every default group child associated with that parent group. + +As a consequence of this, default_groups cannot be removed directly via +rmdir(2). They also are not considered when rmdir(2) on the parent +group is checking for children. + +[Committable Items] + +NOTE: Committable items are currently unimplemented. + +Some config_items cannot have a valid initial state. That is, no +default values can be specified for the item's attributes such that the +item can do its work. Userspace must configure one or more attributes, +after which the subsystem can start whatever entity this item +represents. + +Consider the FakeNBD device from above. Without a target address *and* +a target device, the subsystem has no idea what block device to import. +The simple example assumes that the subsystem merely waits until all the +appropriate attributes are configured, and then connects. This will, +indeed, work, but now every attribute store must check if the attributes +are initialized. Every attribute store must fire off the connection if +that condition is met. + +Far better would be an explicit action notifying the subsystem that the +config_item is ready to go. More importantly, an explicit action allows +the subsystem to provide feedback as to whether the attibutes are +initialized in a way that makes sense. configfs provides this as +committable items. + +configfs still uses only normal filesystem operations. An item is +committed via rename(2). The item is moved from a directory where it +can be modified to a directory where it cannot. + +Any group that provides the ct_group_ops->commit_item() method has +committable items. When this group appears in configfs, mkdir(2) will +not work directly in the group. Instead, the group will have two +subdirectories: "live" and "pending". The "live" directory does not +support mkdir(2) or rmdir(2) either. It only allows rename(2). The +"pending" directory does allow mkdir(2) and rmdir(2). An item is +created in the "pending" directory. Its attributes can be modified at +will. Userspace commits the item by renaming it into the "live" +directory. At this point, the subsystem recieves the ->commit_item() +callback. If all required attributes are filled to satisfaction, the +method returns zero and the item is moved to the "live" directory. + +As rmdir(2) does not work in the "live" directory, an item must be +shutdown, or "uncommitted". Again, this is done via rename(2), this +time from the "live" directory back to the "pending" one. The subsystem +is notified by the ct_group_ops->uncommit_object() method. + + diff --git a/Documentation/filesystems/configfs/configfs_example.c b/Documentation/filesystems/configfs/configfs_example.c new file mode 100644 index 0000000..f3c6e49 --- /dev/null +++ b/Documentation/filesystems/configfs/configfs_example.c @@ -0,0 +1,474 @@ +/* + * vim: noexpandtab ts=8 sts=0 sw=8: + * + * configfs_example.c - This file is a demonstration module containing + * a number of configfs subsystems. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on sysfs: + * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + */ + +#include +#include +#include + +#include + + + +/* + * 01-childless + * + * This first example is a childless subsystem. It cannot create + * any config_items. It just has attributes. + * + * Note that we are enclosing the configfs_subsystem inside a container. + * This is not necessary if a subsystem has no attributes directly + * on the subsystem. See the next example, 02-simple-children, for + * such a subsystem. + */ + +struct childless { + struct configfs_subsystem subsys; + int showme; + int storeme; +}; + +struct childless_attribute { + struct configfs_attribute attr; + ssize_t (*show)(struct childless *, char *); + ssize_t (*store)(struct childless *, const char *, size_t); +}; + +static inline struct childless *to_childless(struct config_item *item) +{ + return item ? container_of(to_configfs_subsystem(to_config_group(item)), struct childless, subsys) : NULL; +} + +static ssize_t childless_showme_read(struct childless *childless, + char *page) +{ + ssize_t pos; + + pos = sprintf(page, "%d\n", childless->showme); + childless->showme++; + + return pos; +} + +static ssize_t childless_storeme_read(struct childless *childless, + char *page) +{ + return sprintf(page, "%d\n", childless->storeme); +} + +static ssize_t childless_storeme_write(struct childless *childless, + const char *page, + size_t count) +{ + unsigned long tmp; + char *p = (char *) page; + + tmp = simple_strtoul(p, &p, 10); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + if (tmp > INT_MAX) + return -ERANGE; + + childless->storeme = tmp; + + return count; +} + +static ssize_t childless_description_read(struct childless *childless, + char *page) +{ + return sprintf(page, +"[01-childless]\n" +"\n" +"The childless subsystem is the simplest possible subsystem in\n" +"configfs. It does not support the creation of child config_items.\n" +"It only has a few attributes. In fact, it isn't much different\n" +"than a directory in /proc.\n"); +} + +static struct childless_attribute childless_attr_showme = { + .attr = { .ca_owner = THIS_MODULE, .ca_name = "showme", .ca_mode = S_IRUGO }, + .show = childless_showme_read, +}; +static struct childless_attribute childless_attr_storeme = { + .attr = { .ca_owner = THIS_MODULE, .ca_name = "storeme", .ca_mode = S_IRUGO | S_IWUSR }, + .show = childless_storeme_read, + .store = childless_storeme_write, +}; +static struct childless_attribute childless_attr_description = { + .attr = { .ca_owner = THIS_MODULE, .ca_name = "description", .ca_mode = S_IRUGO }, + .show = childless_description_read, +}; + +static struct configfs_attribute *childless_attrs[] = { + &childless_attr_showme.attr, + &childless_attr_storeme.attr, + &childless_attr_description.attr, + NULL, +}; + +static ssize_t childless_attr_show(struct config_item *item, + struct configfs_attribute *attr, + char *page) +{ + struct childless *childless = to_childless(item); + struct childless_attribute *childless_attr = + container_of(attr, struct childless_attribute, attr); + ssize_t ret = 0; + + if (childless_attr->show) + ret = childless_attr->show(childless, page); + return ret; +} + +static ssize_t childless_attr_store(struct config_item *item, + struct configfs_attribute *attr, + const char *page, size_t count) +{ + struct childless *childless = to_childless(item); + struct childless_attribute *childless_attr = + container_of(attr, struct childless_attribute, attr); + ssize_t ret = -EINVAL; + + if (childless_attr->store) + ret = childless_attr->store(childless, page, count); + return ret; +} + +static struct configfs_item_operations childless_item_ops = { + .show_attribute = childless_attr_show, + .store_attribute = childless_attr_store, +}; + +static struct config_item_type childless_type = { + .ct_item_ops = &childless_item_ops, + .ct_attrs = childless_attrs, + .ct_owner = THIS_MODULE, +}; + +static struct childless childless_subsys = { + .subsys = { + .su_group = { + .cg_item = { + .ci_namebuf = "01-childless", + .ci_type = &childless_type, + }, + }, + }, +}; + + +/* ----------------------------------------------------------------- */ + +/* + * 02-simple-children + * + * This example merely has a simple one-attribute child. Note that + * there is no extra attribute structure, as the child's attribute is + * known from the get-go. Also, there is no container for the + * subsystem, as it has no attributes of its own. + */ + +struct simple_child { + struct config_item item; + int storeme; +}; + +static inline struct simple_child *to_simple_child(struct config_item *item) +{ + return item ? container_of(item, struct simple_child, item) : NULL; +} + +static struct configfs_attribute simple_child_attr_storeme = { + .ca_owner = THIS_MODULE, + .ca_name = "storeme", + .ca_mode = S_IRUGO | S_IWUSR, +}; + +static struct configfs_attribute *simple_child_attrs[] = { + &simple_child_attr_storeme, + NULL, +}; + +static ssize_t simple_child_attr_show(struct config_item *item, + struct configfs_attribute *attr, + char *page) +{ + ssize_t count; + struct simple_child *simple_child = to_simple_child(item); + + count = sprintf(page, "%d\n", simple_child->storeme); + + return count; +} + +static ssize_t simple_child_attr_store(struct config_item *item, + struct configfs_attribute *attr, + const char *page, size_t count) +{ + struct simple_child *simple_child = to_simple_child(item); + unsigned long tmp; + char *p = (char *) page; + + tmp = simple_strtoul(p, &p, 10); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + if (tmp > INT_MAX) + return -ERANGE; + + simple_child->storeme = tmp; + + return count; +} + +static void simple_child_release(struct config_item *item) +{ + kfree(to_simple_child(item)); +} + +static struct configfs_item_operations simple_child_item_ops = { + .release = simple_child_release, + .show_attribute = simple_child_attr_show, + .store_attribute = simple_child_attr_store, +}; + +static struct config_item_type simple_child_type = { + .ct_item_ops = &simple_child_item_ops, + .ct_attrs = simple_child_attrs, + .ct_owner = THIS_MODULE, +}; + + +static struct config_item *simple_children_make_item(struct config_group *group, const char *name) +{ + struct simple_child *simple_child; + + simple_child = kmalloc(sizeof(struct simple_child), GFP_KERNEL); + if (!simple_child) + return NULL; + + memset(simple_child, 0, sizeof(struct simple_child)); + + config_item_init_type_name(&simple_child->item, name, + &simple_child_type); + + simple_child->storeme = 0; + + return &simple_child->item; +} + +static struct configfs_attribute simple_children_attr_description = { + .ca_owner = THIS_MODULE, + .ca_name = "description", + .ca_mode = S_IRUGO, +}; + +static struct configfs_attribute *simple_children_attrs[] = { + &simple_children_attr_description, + NULL, +}; + +static ssize_t simple_children_attr_show(struct config_item *item, + struct configfs_attribute *attr, + char *page) +{ + return sprintf(page, +"[02-simple-children]\n" +"\n" +"This subsystem allows the creation of child config_items. These\n" +"items have only one attribute that is readable and writeable.\n"); +} + +static struct configfs_item_operations simple_children_item_ops = { + .show_attribute = simple_children_attr_show, +}; + +/* + * Note that, since no extra work is required on ->drop_item(), + * no ->drop_item() is provided. + */ +static struct configfs_group_operations simple_children_group_ops = { + .make_item = simple_children_make_item, +}; + +static struct config_item_type simple_children_type = { + .ct_item_ops = &simple_children_item_ops, + .ct_group_ops = &simple_children_group_ops, + .ct_attrs = simple_children_attrs, +}; + +static struct configfs_subsystem simple_children_subsys = { + .su_group = { + .cg_item = { + .ci_namebuf = "02-simple-children", + .ci_type = &simple_children_type, + }, + }, +}; + + +/* ----------------------------------------------------------------- */ + +/* + * 03-group-children + * + * This example reuses the simple_children group from above. However, + * the simple_children group is not the subsystem itself, it is a + * child of the subsystem. Creation of a group in the subsystem creates + * a new simple_children group. That group can then have simple_child + * children of its own. + */ + +struct simple_children { + struct config_group group; +}; + +static struct config_group *group_children_make_group(struct config_group *group, const char *name) +{ + struct simple_children *simple_children; + + simple_children = kmalloc(sizeof(struct simple_children), + GFP_KERNEL); + if (!simple_children) + return NULL; + + memset(simple_children, 0, sizeof(struct simple_children)); + + config_group_init_type_name(&simple_children->group, name, + &simple_children_type); + + return &simple_children->group; +} + +static struct configfs_attribute group_children_attr_description = { + .ca_owner = THIS_MODULE, + .ca_name = "description", + .ca_mode = S_IRUGO, +}; + +static struct configfs_attribute *group_children_attrs[] = { + &group_children_attr_description, + NULL, +}; + +static ssize_t group_children_attr_show(struct config_item *item, + struct configfs_attribute *attr, + char *page) +{ + return sprintf(page, +"[03-group-children]\n" +"\n" +"This subsystem allows the creation of child config_groups. These\n" +"groups are like the subsystem simple-children.\n"); +} + +static struct configfs_item_operations group_children_item_ops = { + .show_attribute = group_children_attr_show, +}; + +/* + * Note that, since no extra work is required on ->drop_item(), + * no ->drop_item() is provided. + */ +static struct configfs_group_operations group_children_group_ops = { + .make_group = group_children_make_group, +}; + +static struct config_item_type group_children_type = { + .ct_item_ops = &group_children_item_ops, + .ct_group_ops = &group_children_group_ops, + .ct_attrs = group_children_attrs, +}; + +static struct configfs_subsystem group_children_subsys = { + .su_group = { + .cg_item = { + .ci_namebuf = "03-group-children", + .ci_type = &group_children_type, + }, + }, +}; + +/* ----------------------------------------------------------------- */ + +/* + * We're now done with our subsystem definitions. + * For convenience in this module, here's a list of them all. It + * allows the init function to easily register them. Most modules + * will only have one subsystem, and will only call register_subsystem + * on it directly. + */ +static struct configfs_subsystem *example_subsys[] = { + &childless_subsys.subsys, + &simple_children_subsys, + &group_children_subsys, + NULL, +}; + +static int __init configfs_example_init(void) +{ + int ret; + int i; + struct configfs_subsystem *subsys; + + for (i = 0; example_subsys[i]; i++) { + subsys = example_subsys[i]; + + config_group_init(&subsys->su_group); + init_MUTEX(&subsys->su_sem); + ret = configfs_register_subsystem(subsys); + if (ret) { + printk(KERN_ERR "Error %d while registering subsystem %s\n", + ret, + subsys->su_group.cg_item.ci_namebuf); + goto out_unregister; + } + } + + return 0; + +out_unregister: + for (; i >= 0; i--) { + configfs_unregister_subsystem(example_subsys[i]); + } + + return ret; +} + +static void __exit configfs_example_exit(void) +{ + int i; + + for (i = 0; example_subsys[i]; i++) { + configfs_unregister_subsystem(example_subsys[i]); + } +} + +module_init(configfs_example_init); +module_exit(configfs_example_exit); +MODULE_LICENSE("GPL"); diff --git a/MAINTAINERS b/MAINTAINERS index 6af6830..86ee06f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -554,6 +554,11 @@ W: http://us1.samba.org/samba/Linux_CIFS_client.html T: git kernel.org:/pub/scm/linux/kernel/git/sfrench/cifs-2.6.git S: Supported +CONFIGFS +P: Joel Becker +M: Joel Becker +S: Supported + CIRRUS LOGIC GENERIC FBDEV DRIVER P: Jeff Garzik M: jgarzik@pobox.com diff --git a/fs/Kconfig b/fs/Kconfig index d5255e6..ba1dbe2 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -841,6 +841,20 @@ config RELAYFS_FS If unsure, say N. +config CONFIGFS_FS + tristate "Userspace-driven configuration filesystem (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + configfs is a ram-based filesystem that provides the converse + of sysfs's functionality. Where sysfs is a filesystem-based + view of kernel objects, configfs is a filesystem-based manager + of kernel objects, or config_items. + + Both sysfs and configfs can and should exist together on the + same system. One is not a replacement for the other. + + If unsure, say N. + endmenu menu "Miscellaneous filesystems" diff --git a/fs/Makefile b/fs/Makefile index 4c26557..ff3d48a 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -101,3 +101,4 @@ obj-$(CONFIG_BEFS_FS) += befs/ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ obj-$(CONFIG_DEBUG_FS) += debugfs/ +obj-$(CONFIG_CONFIGFS_FS) += configfs/ diff --git a/fs/configfs/Makefile b/fs/configfs/Makefile new file mode 100644 index 0000000..00ffb27 --- /dev/null +++ b/fs/configfs/Makefile @@ -0,0 +1,7 @@ +# +# Makefile for the configfs virtual filesystem +# + +obj-$(CONFIG_CONFIGFS_FS) += configfs.o + +configfs-objs := inode.o file.o dir.o symlink.o mount.o item.o diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h new file mode 100644 index 0000000..8899d9c --- /dev/null +++ b/fs/configfs/configfs_internal.h @@ -0,0 +1,142 @@ +/* -*- mode: c; c-basic-offset:8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * configfs_internal.h - Internal stuff for configfs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on sysfs: + * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + */ + +#include +#include + +struct configfs_dirent { + atomic_t s_count; + struct list_head s_sibling; + struct list_head s_children; + struct list_head s_links; + void * s_element; + int s_type; + umode_t s_mode; + struct dentry * s_dentry; +}; + +#define CONFIGFS_ROOT 0x0001 +#define CONFIGFS_DIR 0x0002 +#define CONFIGFS_ITEM_ATTR 0x0004 +#define CONFIGFS_ITEM_LINK 0x0020 +#define CONFIGFS_USET_DIR 0x0040 +#define CONFIGFS_USET_DEFAULT 0x0080 +#define CONFIGFS_USET_DROPPING 0x0100 +#define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR) + +extern struct vfsmount * configfs_mount; + +extern int configfs_is_root(struct config_item *item); + +extern struct inode * configfs_new_inode(mode_t mode); +extern int configfs_create(struct dentry *, int mode, int (*init)(struct inode *)); + +extern int configfs_create_file(struct config_item *, const struct configfs_attribute *); +extern int configfs_make_dirent(struct configfs_dirent *, + struct dentry *, void *, umode_t, int); + +extern int configfs_add_file(struct dentry *, const struct configfs_attribute *, int); +extern void configfs_hash_and_remove(struct dentry * dir, const char * name); + +extern const unsigned char * configfs_get_name(struct configfs_dirent *sd); +extern void configfs_drop_dentry(struct configfs_dirent *sd, struct dentry *parent); + +extern int configfs_pin_fs(void); +extern void configfs_release_fs(void); + +extern struct rw_semaphore configfs_rename_sem; +extern struct super_block * configfs_sb; +extern struct file_operations configfs_dir_operations; +extern struct file_operations configfs_file_operations; +extern struct file_operations bin_fops; +extern struct inode_operations configfs_dir_inode_operations; +extern struct inode_operations configfs_symlink_inode_operations; + +extern int configfs_symlink(struct inode *dir, struct dentry *dentry, + const char *symname); +extern int configfs_unlink(struct inode *dir, struct dentry *dentry); + +struct configfs_symlink { + struct list_head sl_list; + struct config_item *sl_target; +}; + +extern int configfs_create_link(struct configfs_symlink *sl, + struct dentry *parent, + struct dentry *dentry); + +static inline struct config_item * to_item(struct dentry * dentry) +{ + struct configfs_dirent * sd = dentry->d_fsdata; + return ((struct config_item *) sd->s_element); +} + +static inline struct configfs_attribute * to_attr(struct dentry * dentry) +{ + struct configfs_dirent * sd = dentry->d_fsdata; + return ((struct configfs_attribute *) sd->s_element); +} + +static inline struct config_item *configfs_get_config_item(struct dentry *dentry) +{ + struct config_item * item = NULL; + + spin_lock(&dcache_lock); + if (!d_unhashed(dentry)) { + struct configfs_dirent * sd = dentry->d_fsdata; + if (sd->s_type & CONFIGFS_ITEM_LINK) { + struct configfs_symlink * sl = sd->s_element; + item = config_item_get(sl->sl_target); + } else + item = config_item_get(sd->s_element); + } + spin_unlock(&dcache_lock); + + return item; +} + +static inline void release_configfs_dirent(struct configfs_dirent * sd) +{ + if (!(sd->s_type & CONFIGFS_ROOT)) + kfree(sd); +} + +static inline struct configfs_dirent * configfs_get(struct configfs_dirent * sd) +{ + if (sd) { + WARN_ON(!atomic_read(&sd->s_count)); + atomic_inc(&sd->s_count); + } + return sd; +} + +static inline void configfs_put(struct configfs_dirent * sd) +{ + WARN_ON(!atomic_read(&sd->s_count)); + if (atomic_dec_and_test(&sd->s_count)) + release_configfs_dirent(sd); +} + diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c new file mode 100644 index 0000000..e48b539 --- /dev/null +++ b/fs/configfs/dir.c @@ -0,0 +1,1102 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dir.c - Operations for configfs directories. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on sysfs: + * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + */ + +#undef DEBUG + +#include +#include +#include +#include + +#include +#include "configfs_internal.h" + +DECLARE_RWSEM(configfs_rename_sem); + +static void configfs_d_iput(struct dentry * dentry, + struct inode * inode) +{ + struct configfs_dirent * sd = dentry->d_fsdata; + + if (sd) { + BUG_ON(sd->s_dentry != dentry); + sd->s_dentry = NULL; + configfs_put(sd); + } + iput(inode); +} + +/* + * We _must_ delete our dentries on last dput, as the chain-to-parent + * behavior is required to clear the parents of default_groups. + */ +static int configfs_d_delete(struct dentry *dentry) +{ + return 1; +} + +static struct dentry_operations configfs_dentry_ops = { + .d_iput = configfs_d_iput, + /* simple_delete_dentry() isn't exported */ + .d_delete = configfs_d_delete, +}; + +/* + * Allocates a new configfs_dirent and links it to the parent configfs_dirent + */ +static struct configfs_dirent *configfs_new_dirent(struct configfs_dirent * parent_sd, + void * element) +{ + struct configfs_dirent * sd; + + sd = kmalloc(sizeof(*sd), GFP_KERNEL); + if (!sd) + return NULL; + + memset(sd, 0, sizeof(*sd)); + atomic_set(&sd->s_count, 1); + INIT_LIST_HEAD(&sd->s_links); + INIT_LIST_HEAD(&sd->s_children); + list_add(&sd->s_sibling, &parent_sd->s_children); + sd->s_element = element; + + return sd; +} + +int configfs_make_dirent(struct configfs_dirent * parent_sd, + struct dentry * dentry, void * element, + umode_t mode, int type) +{ + struct configfs_dirent * sd; + + sd = configfs_new_dirent(parent_sd, element); + if (!sd) + return -ENOMEM; + + sd->s_mode = mode; + sd->s_type = type; + sd->s_dentry = dentry; + if (dentry) { + dentry->d_fsdata = configfs_get(sd); + dentry->d_op = &configfs_dentry_ops; + } + + return 0; +} + +static int init_dir(struct inode * inode) +{ + inode->i_op = &configfs_dir_inode_operations; + inode->i_fop = &configfs_dir_operations; + + /* directory inodes start off with i_nlink == 2 (for "." entry) */ + inode->i_nlink++; + return 0; +} + +static int init_file(struct inode * inode) +{ + inode->i_size = PAGE_SIZE; + inode->i_fop = &configfs_file_operations; + return 0; +} + +static int init_symlink(struct inode * inode) +{ + inode->i_op = &configfs_symlink_inode_operations; + return 0; +} + +static int create_dir(struct config_item * k, struct dentry * p, + struct dentry * d) +{ + int error; + umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; + + error = configfs_create(d, mode, init_dir); + if (!error) { + error = configfs_make_dirent(p->d_fsdata, d, k, mode, + CONFIGFS_DIR); + if (!error) { + p->d_inode->i_nlink++; + (d)->d_op = &configfs_dentry_ops; + } + } + return error; +} + + +/** + * configfs_create_dir - create a directory for an config_item. + * @item: config_itemwe're creating directory for. + * @dentry: config_item's dentry. + */ + +static int configfs_create_dir(struct config_item * item, struct dentry *dentry) +{ + struct dentry * parent; + int error = 0; + + BUG_ON(!item); + + if (item->ci_parent) + parent = item->ci_parent->ci_dentry; + else if (configfs_mount && configfs_mount->mnt_sb) + parent = configfs_mount->mnt_sb->s_root; + else + return -EFAULT; + + error = create_dir(item,parent,dentry); + if (!error) + item->ci_dentry = dentry; + return error; +} + +int configfs_create_link(struct configfs_symlink *sl, + struct dentry *parent, + struct dentry *dentry) +{ + int err = 0; + umode_t mode = S_IFLNK | S_IRWXUGO; + + err = configfs_create(dentry, mode, init_symlink); + if (!err) { + err = configfs_make_dirent(parent->d_fsdata, dentry, sl, + mode, CONFIGFS_ITEM_LINK); + if (!err) + dentry->d_op = &configfs_dentry_ops; + } + return err; +} + +static void remove_dir(struct dentry * d) +{ + struct dentry * parent = dget(d->d_parent); + struct configfs_dirent * sd; + + sd = d->d_fsdata; + list_del_init(&sd->s_sibling); + configfs_put(sd); + if (d->d_inode) + simple_rmdir(parent->d_inode,d); + + pr_debug(" o %s removing done (%d)\n",d->d_name.name, + atomic_read(&d->d_count)); + + dput(parent); +} + +/** + * configfs_remove_dir - remove an config_item's directory. + * @item: config_item we're removing. + * + * The only thing special about this is that we remove any files in + * the directory before we remove the directory, and we've inlined + * what used to be configfs_rmdir() below, instead of calling separately. + */ + +static void configfs_remove_dir(struct config_item * item) +{ + struct dentry * dentry = dget(item->ci_dentry); + + if (!dentry) + return; + + remove_dir(dentry); + /** + * Drop reference from dget() on entrance. + */ + dput(dentry); +} + + +/* attaches attribute's configfs_dirent to the dentry corresponding to the + * attribute file + */ +static int configfs_attach_attr(struct configfs_dirent * sd, struct dentry * dentry) +{ + struct configfs_attribute * attr = sd->s_element; + int error; + + error = configfs_create(dentry, (attr->ca_mode & S_IALLUGO) | S_IFREG, init_file); + if (error) + return error; + + dentry->d_op = &configfs_dentry_ops; + dentry->d_fsdata = configfs_get(sd); + sd->s_dentry = dentry; + d_rehash(dentry); + + return 0; +} + +static struct dentry * configfs_lookup(struct inode *dir, + struct dentry *dentry, + struct nameidata *nd) +{ + struct configfs_dirent * parent_sd = dentry->d_parent->d_fsdata; + struct configfs_dirent * sd; + int found = 0; + int err = 0; + + list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { + if (sd->s_type & CONFIGFS_NOT_PINNED) { + const unsigned char * name = configfs_get_name(sd); + + if (strcmp(name, dentry->d_name.name)) + continue; + + found = 1; + err = configfs_attach_attr(sd, dentry); + break; + } + } + + if (!found) { + /* + * If it doesn't exist and it isn't a NOT_PINNED item, + * it must be negative. + */ + return simple_lookup(dir, dentry, nd); + } + + return ERR_PTR(err); +} + +/* + * Only subdirectories count here. Files (CONFIGFS_NOT_PINNED) are + * attributes and are removed by rmdir(). We recurse, taking i_sem + * on all children that are candidates for default detach. If the + * result is clean, then configfs_detach_group() will handle dropping + * i_sem. If there is an error, the caller will clean up the i_sem + * holders via configfs_detach_rollback(). + */ +static int configfs_detach_prep(struct dentry *dentry) +{ + struct configfs_dirent *parent_sd = dentry->d_fsdata; + struct configfs_dirent *sd; + int ret; + + ret = -EBUSY; + if (!list_empty(&parent_sd->s_links)) + goto out; + + ret = 0; + list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { + if (sd->s_type & CONFIGFS_NOT_PINNED) + continue; + if (sd->s_type & CONFIGFS_USET_DEFAULT) { + down(&sd->s_dentry->d_inode->i_sem); + /* Mark that we've taken i_sem */ + sd->s_type |= CONFIGFS_USET_DROPPING; + + ret = configfs_detach_prep(sd->s_dentry); + if (!ret) + continue; + } else + ret = -ENOTEMPTY; + + break; + } + +out: + return ret; +} + +/* + * Walk the tree, dropping i_sem wherever CONFIGFS_USET_DROPPING is + * set. + */ +static void configfs_detach_rollback(struct dentry *dentry) +{ + struct configfs_dirent *parent_sd = dentry->d_fsdata; + struct configfs_dirent *sd; + + list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { + if (sd->s_type & CONFIGFS_USET_DEFAULT) { + configfs_detach_rollback(sd->s_dentry); + + if (sd->s_type & CONFIGFS_USET_DROPPING) { + sd->s_type &= ~CONFIGFS_USET_DROPPING; + up(&sd->s_dentry->d_inode->i_sem); + } + } + } +} + +static void detach_attrs(struct config_item * item) +{ + struct dentry * dentry = dget(item->ci_dentry); + struct configfs_dirent * parent_sd; + struct configfs_dirent * sd, * tmp; + + if (!dentry) + return; + + pr_debug("configfs %s: dropping attrs for dir\n", + dentry->d_name.name); + + parent_sd = dentry->d_fsdata; + list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) { + if (!sd->s_element || !(sd->s_type & CONFIGFS_NOT_PINNED)) + continue; + list_del_init(&sd->s_sibling); + configfs_drop_dentry(sd, dentry); + configfs_put(sd); + } + + /** + * Drop reference from dget() on entrance. + */ + dput(dentry); +} + +static int populate_attrs(struct config_item *item) +{ + struct config_item_type *t = item->ci_type; + struct configfs_attribute *attr; + int error = 0; + int i; + + if (!t) + return -EINVAL; + if (t->ct_attrs) { + for (i = 0; (attr = t->ct_attrs[i]) != NULL; i++) { + if ((error = configfs_create_file(item, attr))) + break; + } + } + + if (error) + detach_attrs(item); + + return error; +} + +static int configfs_attach_group(struct config_item *parent_item, + struct config_item *item, + struct dentry *dentry); +static void configfs_detach_group(struct config_item *item); + +static void detach_groups(struct config_group *group) +{ + struct dentry * dentry = dget(group->cg_item.ci_dentry); + struct dentry *child; + struct configfs_dirent *parent_sd; + struct configfs_dirent *sd, *tmp; + + if (!dentry) + return; + + parent_sd = dentry->d_fsdata; + list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) { + if (!sd->s_element || + !(sd->s_type & CONFIGFS_USET_DEFAULT)) + continue; + + child = sd->s_dentry; + + configfs_detach_group(sd->s_element); + child->d_inode->i_flags |= S_DEAD; + + /* + * From rmdir/unregister, a configfs_detach_prep() pass + * has taken our i_sem for us. Drop it. + * From mkdir/register cleanup, there is no sem held. + */ + if (sd->s_type & CONFIGFS_USET_DROPPING) + up(&child->d_inode->i_sem); + + d_delete(child); + dput(child); + } + + /** + * Drop reference from dget() on entrance. + */ + dput(dentry); +} + +/* + * This fakes mkdir(2) on a default_groups[] entry. It + * creates a dentry, attachs it, and then does fixup + * on the sd->s_type. + * + * We could, perhaps, tweak our parent's ->mkdir for a minute and + * try using vfs_mkdir. Just a thought. + */ +static int create_default_group(struct config_group *parent_group, + struct config_group *group) +{ + int ret; + struct qstr name; + struct configfs_dirent *sd; + /* We trust the caller holds a reference to parent */ + struct dentry *child, *parent = parent_group->cg_item.ci_dentry; + + if (!group->cg_item.ci_name) + group->cg_item.ci_name = group->cg_item.ci_namebuf; + name.name = group->cg_item.ci_name; + name.len = strlen(name.name); + name.hash = full_name_hash(name.name, name.len); + + ret = -ENOMEM; + child = d_alloc(parent, &name); + if (child) { + d_add(child, NULL); + + ret = configfs_attach_group(&parent_group->cg_item, + &group->cg_item, child); + if (!ret) { + sd = child->d_fsdata; + sd->s_type |= CONFIGFS_USET_DEFAULT; + } else { + d_delete(child); + dput(child); + } + } + + return ret; +} + +static int populate_groups(struct config_group *group) +{ + struct config_group *new_group; + struct dentry *dentry = group->cg_item.ci_dentry; + int ret = 0; + int i; + + if (group && group->default_groups) { + /* FYI, we're faking mkdir here + * I'm not sure we need this semaphore, as we're called + * from our parent's mkdir. That holds our parent's + * i_sem, so afaik lookup cannot continue through our + * parent to find us, let alone mess with our tree. + * That said, taking our i_sem is closer to mkdir + * emulation, and shouldn't hurt. */ + down(&dentry->d_inode->i_sem); + + for (i = 0; group->default_groups[i]; i++) { + new_group = group->default_groups[i]; + + ret = create_default_group(group, new_group); + if (ret) + break; + } + + up(&dentry->d_inode->i_sem); + } + + if (ret) + detach_groups(group); + + return ret; +} + +/* + * All of link_obj/unlink_obj/link_group/unlink_group require that + * subsys->su_sem is held. + */ + +static void unlink_obj(struct config_item *item) +{ + struct config_group *group; + + group = item->ci_group; + if (group) { + list_del_init(&item->ci_entry); + + item->ci_group = NULL; + item->ci_parent = NULL; + config_item_put(item); + + config_group_put(group); + } +} + +static void link_obj(struct config_item *parent_item, struct config_item *item) +{ + /* Parent seems redundant with group, but it makes certain + * traversals much nicer. */ + item->ci_parent = parent_item; + item->ci_group = config_group_get(to_config_group(parent_item)); + list_add_tail(&item->ci_entry, &item->ci_group->cg_children); + + config_item_get(item); +} + +static void unlink_group(struct config_group *group) +{ + int i; + struct config_group *new_group; + + if (group->default_groups) { + for (i = 0; group->default_groups[i]; i++) { + new_group = group->default_groups[i]; + unlink_group(new_group); + } + } + + group->cg_subsys = NULL; + unlink_obj(&group->cg_item); +} + +static void link_group(struct config_group *parent_group, struct config_group *group) +{ + int i; + struct config_group *new_group; + struct configfs_subsystem *subsys = NULL; /* gcc is a turd */ + + link_obj(&parent_group->cg_item, &group->cg_item); + + if (parent_group->cg_subsys) + subsys = parent_group->cg_subsys; + else if (configfs_is_root(&parent_group->cg_item)) + subsys = to_configfs_subsystem(group); + else + BUG(); + group->cg_subsys = subsys; + + if (group->default_groups) { + for (i = 0; group->default_groups[i]; i++) { + new_group = group->default_groups[i]; + link_group(group, new_group); + } + } +} + +/* + * The goal is that configfs_attach_item() (and + * configfs_attach_group()) can be called from either the VFS or this + * module. That is, they assume that the items have been created, + * the dentry allocated, and the dcache is all ready to go. + * + * If they fail, they must clean up after themselves as if they + * had never been called. The caller (VFS or local function) will + * handle cleaning up the dcache bits. + * + * configfs_detach_group() and configfs_detach_item() behave similarly on + * the way out. They assume that the proper semaphores are held, they + * clean up the configfs items, and they expect their callers will + * handle the dcache bits. + */ +static int configfs_attach_item(struct config_item *parent_item, + struct config_item *item, + struct dentry *dentry) +{ + int ret; + + ret = configfs_create_dir(item, dentry); + if (!ret) { + ret = populate_attrs(item); + if (ret) { + configfs_remove_dir(item); + d_delete(dentry); + } + } + + return ret; +} + +static void configfs_detach_item(struct config_item *item) +{ + detach_attrs(item); + configfs_remove_dir(item); +} + +static int configfs_attach_group(struct config_item *parent_item, + struct config_item *item, + struct dentry *dentry) +{ + int ret; + struct configfs_dirent *sd; + + ret = configfs_attach_item(parent_item, item, dentry); + if (!ret) { + sd = dentry->d_fsdata; + sd->s_type |= CONFIGFS_USET_DIR; + + ret = populate_groups(to_config_group(item)); + if (ret) { + configfs_detach_item(item); + d_delete(dentry); + } + } + + return ret; +} + +static void configfs_detach_group(struct config_item *item) +{ + detach_groups(to_config_group(item)); + configfs_detach_item(item); +} + +/* + * Drop the initial reference from make_item()/make_group() + * This function assumes that reference is held on item + * and that item holds a valid reference to the parent. Also, it + * assumes the caller has validated ci_type. + */ +static void client_drop_item(struct config_item *parent_item, + struct config_item *item) +{ + struct config_item_type *type; + + type = parent_item->ci_type; + BUG_ON(!type); + + if (type->ct_group_ops && type->ct_group_ops->drop_item) + type->ct_group_ops->drop_item(to_config_group(parent_item), + item); + else + config_item_put(item); +} + + +static int configfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +{ + int ret; + struct config_group *group; + struct config_item *item; + struct config_item *parent_item; + struct configfs_subsystem *subsys; + struct configfs_dirent *sd; + struct config_item_type *type; + struct module *owner; + char *name; + + if (dentry->d_parent == configfs_sb->s_root) + return -EPERM; + + sd = dentry->d_parent->d_fsdata; + if (!(sd->s_type & CONFIGFS_USET_DIR)) + return -EPERM; + + parent_item = configfs_get_config_item(dentry->d_parent); + type = parent_item->ci_type; + subsys = to_config_group(parent_item)->cg_subsys; + BUG_ON(!subsys); + + if (!type || !type->ct_group_ops || + (!type->ct_group_ops->make_group && + !type->ct_group_ops->make_item)) { + config_item_put(parent_item); + return -EPERM; /* What lack-of-mkdir returns */ + } + + name = kmalloc(dentry->d_name.len + 1, GFP_KERNEL); + if (!name) { + config_item_put(parent_item); + return -ENOMEM; + } + snprintf(name, dentry->d_name.len + 1, "%s", dentry->d_name.name); + + down(&subsys->su_sem); + group = NULL; + item = NULL; + if (type->ct_group_ops->make_group) { + group = type->ct_group_ops->make_group(to_config_group(parent_item), name); + if (group) { + link_group(to_config_group(parent_item), group); + item = &group->cg_item; + } + } else { + item = type->ct_group_ops->make_item(to_config_group(parent_item), name); + if (item) + link_obj(parent_item, item); + } + up(&subsys->su_sem); + + kfree(name); + if (!item) { + config_item_put(parent_item); + return -ENOMEM; + } + + ret = -EINVAL; + type = item->ci_type; + if (type) { + owner = type->ct_owner; + if (try_module_get(owner)) { + if (group) { + ret = configfs_attach_group(parent_item, + item, + dentry); + } else { + ret = configfs_attach_item(parent_item, + item, + dentry); + } + + if (ret) { + down(&subsys->su_sem); + if (group) + unlink_group(group); + else + unlink_obj(item); + client_drop_item(parent_item, item); + up(&subsys->su_sem); + + config_item_put(parent_item); + module_put(owner); + } + } + } + + return ret; +} + +static int configfs_rmdir(struct inode *dir, struct dentry *dentry) +{ + struct config_item *parent_item; + struct config_item *item; + struct configfs_subsystem *subsys; + struct configfs_dirent *sd; + struct module *owner = NULL; + int ret; + + if (dentry->d_parent == configfs_sb->s_root) + return -EPERM; + + sd = dentry->d_fsdata; + if (sd->s_type & CONFIGFS_USET_DEFAULT) + return -EPERM; + + parent_item = configfs_get_config_item(dentry->d_parent); + subsys = to_config_group(parent_item)->cg_subsys; + BUG_ON(!subsys); + + if (!parent_item->ci_type) { + config_item_put(parent_item); + return -EINVAL; + } + + ret = configfs_detach_prep(dentry); + if (ret) { + configfs_detach_rollback(dentry); + config_item_put(parent_item); + return ret; + } + + item = configfs_get_config_item(dentry); + + /* Drop reference from above, item already holds one. */ + config_item_put(parent_item); + + if (item->ci_type) + owner = item->ci_type->ct_owner; + + if (sd->s_type & CONFIGFS_USET_DIR) { + configfs_detach_group(item); + + down(&subsys->su_sem); + unlink_group(to_config_group(item)); + } else { + configfs_detach_item(item); + + down(&subsys->su_sem); + unlink_obj(item); + } + + client_drop_item(parent_item, item); + up(&subsys->su_sem); + + /* Drop our reference from above */ + config_item_put(item); + + module_put(owner); + + return 0; +} + +struct inode_operations configfs_dir_inode_operations = { + .mkdir = configfs_mkdir, + .rmdir = configfs_rmdir, + .symlink = configfs_symlink, + .unlink = configfs_unlink, + .lookup = configfs_lookup, +}; + +#if 0 +int configfs_rename_dir(struct config_item * item, const char *new_name) +{ + int error = 0; + struct dentry * new_dentry, * parent; + + if (!strcmp(config_item_name(item), new_name)) + return -EINVAL; + + if (!item->parent) + return -EINVAL; + + down_write(&configfs_rename_sem); + parent = item->parent->dentry; + + down(&parent->d_inode->i_sem); + + new_dentry = lookup_one_len(new_name, parent, strlen(new_name)); + if (!IS_ERR(new_dentry)) { + if (!new_dentry->d_inode) { + error = config_item_set_name(item, "%s", new_name); + if (!error) { + d_add(new_dentry, NULL); + d_move(item->dentry, new_dentry); + } + else + d_delete(new_dentry); + } else + error = -EEXIST; + dput(new_dentry); + } + up(&parent->d_inode->i_sem); + up_write(&configfs_rename_sem); + + return error; +} +#endif + +static int configfs_dir_open(struct inode *inode, struct file *file) +{ + struct dentry * dentry = file->f_dentry; + struct configfs_dirent * parent_sd = dentry->d_fsdata; + + down(&dentry->d_inode->i_sem); + file->private_data = configfs_new_dirent(parent_sd, NULL); + up(&dentry->d_inode->i_sem); + + return file->private_data ? 0 : -ENOMEM; + +} + +static int configfs_dir_close(struct inode *inode, struct file *file) +{ + struct dentry * dentry = file->f_dentry; + struct configfs_dirent * cursor = file->private_data; + + down(&dentry->d_inode->i_sem); + list_del_init(&cursor->s_sibling); + up(&dentry->d_inode->i_sem); + + release_configfs_dirent(cursor); + + return 0; +} + +/* Relationship between s_mode and the DT_xxx types */ +static inline unsigned char dt_type(struct configfs_dirent *sd) +{ + return (sd->s_mode >> 12) & 15; +} + +static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir) +{ + struct dentry *dentry = filp->f_dentry; + struct configfs_dirent * parent_sd = dentry->d_fsdata; + struct configfs_dirent *cursor = filp->private_data; + struct list_head *p, *q = &cursor->s_sibling; + ino_t ino; + int i = filp->f_pos; + + switch (i) { + case 0: + ino = dentry->d_inode->i_ino; + if (filldir(dirent, ".", 1, i, ino, DT_DIR) < 0) + break; + filp->f_pos++; + i++; + /* fallthrough */ + case 1: + ino = parent_ino(dentry); + if (filldir(dirent, "..", 2, i, ino, DT_DIR) < 0) + break; + filp->f_pos++; + i++; + /* fallthrough */ + default: + if (filp->f_pos == 2) { + list_del(q); + list_add(q, &parent_sd->s_children); + } + for (p=q->next; p!= &parent_sd->s_children; p=p->next) { + struct configfs_dirent *next; + const char * name; + int len; + + next = list_entry(p, struct configfs_dirent, + s_sibling); + if (!next->s_element) + continue; + + name = configfs_get_name(next); + len = strlen(name); + if (next->s_dentry) + ino = next->s_dentry->d_inode->i_ino; + else + ino = iunique(configfs_sb, 2); + + if (filldir(dirent, name, len, filp->f_pos, ino, + dt_type(next)) < 0) + return 0; + + list_del(q); + list_add(q, p); + p = q; + filp->f_pos++; + } + } + return 0; +} + +static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin) +{ + struct dentry * dentry = file->f_dentry; + + down(&dentry->d_inode->i_sem); + switch (origin) { + case 1: + offset += file->f_pos; + case 0: + if (offset >= 0) + break; + default: + up(&file->f_dentry->d_inode->i_sem); + return -EINVAL; + } + if (offset != file->f_pos) { + file->f_pos = offset; + if (file->f_pos >= 2) { + struct configfs_dirent *sd = dentry->d_fsdata; + struct configfs_dirent *cursor = file->private_data; + struct list_head *p; + loff_t n = file->f_pos - 2; + + list_del(&cursor->s_sibling); + p = sd->s_children.next; + while (n && p != &sd->s_children) { + struct configfs_dirent *next; + next = list_entry(p, struct configfs_dirent, + s_sibling); + if (next->s_element) + n--; + p = p->next; + } + list_add_tail(&cursor->s_sibling, p); + } + } + up(&dentry->d_inode->i_sem); + return offset; +} + +struct file_operations configfs_dir_operations = { + .open = configfs_dir_open, + .release = configfs_dir_close, + .llseek = configfs_dir_lseek, + .read = generic_read_dir, + .readdir = configfs_readdir, +}; + +int configfs_register_subsystem(struct configfs_subsystem *subsys) +{ + int err; + struct config_group *group = &subsys->su_group; + struct qstr name; + struct dentry *dentry; + struct configfs_dirent *sd; + + err = configfs_pin_fs(); + if (err) + return err; + + if (!group->cg_item.ci_name) + group->cg_item.ci_name = group->cg_item.ci_namebuf; + + sd = configfs_sb->s_root->d_fsdata; + link_group(to_config_group(sd->s_element), group); + + down(&configfs_sb->s_root->d_inode->i_sem); + + name.name = group->cg_item.ci_name; + name.len = strlen(name.name); + name.hash = full_name_hash(name.name, name.len); + + err = -ENOMEM; + dentry = d_alloc(configfs_sb->s_root, &name); + if (!dentry) + goto out_release; + + d_add(dentry, NULL); + + err = configfs_attach_group(sd->s_element, &group->cg_item, + dentry); + if (!err) + dentry = NULL; + else + d_delete(dentry); + + up(&configfs_sb->s_root->d_inode->i_sem); + + if (dentry) { + dput(dentry); +out_release: + unlink_group(group); + configfs_release_fs(); + } + + return err; +} + +void configfs_unregister_subsystem(struct configfs_subsystem *subsys) +{ + struct config_group *group = &subsys->su_group; + struct dentry *dentry = group->cg_item.ci_dentry; + + if (dentry->d_parent != configfs_sb->s_root) { + printk(KERN_ERR "configfs: Tried to unregister non-subsystem!\n"); + return; + } + + down(&configfs_sb->s_root->d_inode->i_sem); + down(&dentry->d_inode->i_sem); + if (configfs_detach_prep(dentry)) { + printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n"); + } + configfs_detach_group(&group->cg_item); + dentry->d_inode->i_flags |= S_DEAD; + up(&dentry->d_inode->i_sem); + + d_delete(dentry); + + up(&configfs_sb->s_root->d_inode->i_sem); + + dput(dentry); + + unlink_group(group); + configfs_release_fs(); +} + +EXPORT_SYMBOL(configfs_register_subsystem); +EXPORT_SYMBOL(configfs_unregister_subsystem); diff --git a/fs/configfs/file.c b/fs/configfs/file.c new file mode 100644 index 0000000..af1ffc9 --- /dev/null +++ b/fs/configfs/file.c @@ -0,0 +1,360 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * file.c - operations for regular (text) files. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on sysfs: + * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include "configfs_internal.h" + + +struct configfs_buffer { + size_t count; + loff_t pos; + char * page; + struct configfs_item_operations * ops; + struct semaphore sem; + int needs_read_fill; +}; + + +/** + * fill_read_buffer - allocate and fill buffer from item. + * @dentry: dentry pointer. + * @buffer: data buffer for file. + * + * Allocate @buffer->page, if it hasn't been already, then call the + * config_item's show() method to fill the buffer with this attribute's + * data. + * This is called only once, on the file's first read. + */ +static int fill_read_buffer(struct dentry * dentry, struct configfs_buffer * buffer) +{ + struct configfs_attribute * attr = to_attr(dentry); + struct config_item * item = to_item(dentry->d_parent); + struct configfs_item_operations * ops = buffer->ops; + int ret = 0; + ssize_t count; + + if (!buffer->page) + buffer->page = (char *) get_zeroed_page(GFP_KERNEL); + if (!buffer->page) + return -ENOMEM; + + count = ops->show_attribute(item,attr,buffer->page); + buffer->needs_read_fill = 0; + BUG_ON(count > (ssize_t)PAGE_SIZE); + if (count >= 0) + buffer->count = count; + else + ret = count; + return ret; +} + + +/** + * flush_read_buffer - push buffer to userspace. + * @buffer: data buffer for file. + * @userbuf: user-passed buffer. + * @count: number of bytes requested. + * @ppos: file position. + * + * Copy the buffer we filled in fill_read_buffer() to userspace. + * This is done at the reader's leisure, copying and advancing + * the amount they specify each time. + * This may be called continuously until the buffer is empty. + */ +static int flush_read_buffer(struct configfs_buffer * buffer, char __user * buf, + size_t count, loff_t * ppos) +{ + int error; + + if (*ppos > buffer->count) + return 0; + + if (count > (buffer->count - *ppos)) + count = buffer->count - *ppos; + + error = copy_to_user(buf,buffer->page + *ppos,count); + if (!error) + *ppos += count; + return error ? -EFAULT : count; +} + +/** + * configfs_read_file - read an attribute. + * @file: file pointer. + * @buf: buffer to fill. + * @count: number of bytes to read. + * @ppos: starting offset in file. + * + * Userspace wants to read an attribute file. The attribute descriptor + * is in the file's ->d_fsdata. The target item is in the directory's + * ->d_fsdata. + * + * We call fill_read_buffer() to allocate and fill the buffer from the + * item's show() method exactly once (if the read is happening from + * the beginning of the file). That should fill the entire buffer with + * all the data the item has to offer for that attribute. + * We then call flush_read_buffer() to copy the buffer to userspace + * in the increments specified. + */ + +static ssize_t +configfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos) +{ + struct configfs_buffer * buffer = file->private_data; + ssize_t retval = 0; + + down(&buffer->sem); + if (buffer->needs_read_fill) { + if ((retval = fill_read_buffer(file->f_dentry,buffer))) + goto out; + } + pr_debug("%s: count = %d, ppos = %lld, buf = %s\n", + __FUNCTION__,count,*ppos,buffer->page); + retval = flush_read_buffer(buffer,buf,count,ppos); +out: + up(&buffer->sem); + return retval; +} + + +/** + * fill_write_buffer - copy buffer from userspace. + * @buffer: data buffer for file. + * @userbuf: data from user. + * @count: number of bytes in @userbuf. + * + * Allocate @buffer->page if it hasn't been already, then + * copy the user-supplied buffer into it. + */ + +static int +fill_write_buffer(struct configfs_buffer * buffer, const char __user * buf, size_t count) +{ + int error; + + if (!buffer->page) + buffer->page = (char *)get_zeroed_page(GFP_KERNEL); + if (!buffer->page) + return -ENOMEM; + + if (count > PAGE_SIZE) + count = PAGE_SIZE; + error = copy_from_user(buffer->page,buf,count); + buffer->needs_read_fill = 1; + return error ? -EFAULT : count; +} + + +/** + * flush_write_buffer - push buffer to config_item. + * @file: file pointer. + * @buffer: data buffer for file. + * + * Get the correct pointers for the config_item and the attribute we're + * dealing with, then call the store() method for the attribute, + * passing the buffer that we acquired in fill_write_buffer(). + */ + +static int +flush_write_buffer(struct dentry * dentry, struct configfs_buffer * buffer, size_t count) +{ + struct configfs_attribute * attr = to_attr(dentry); + struct config_item * item = to_item(dentry->d_parent); + struct configfs_item_operations * ops = buffer->ops; + + return ops->store_attribute(item,attr,buffer->page,count); +} + + +/** + * configfs_write_file - write an attribute. + * @file: file pointer + * @buf: data to write + * @count: number of bytes + * @ppos: starting offset + * + * Similar to configfs_read_file(), though working in the opposite direction. + * We allocate and fill the data from the user in fill_write_buffer(), + * then push it to the config_item in flush_write_buffer(). + * There is no easy way for us to know if userspace is only doing a partial + * write, so we don't support them. We expect the entire buffer to come + * on the first write. + * Hint: if you're writing a value, first read the file, modify only the + * the value you're changing, then write entire buffer back. + */ + +static ssize_t +configfs_write_file(struct file *file, const char __user *buf, size_t count, loff_t *ppos) +{ + struct configfs_buffer * buffer = file->private_data; + + down(&buffer->sem); + count = fill_write_buffer(buffer,buf,count); + if (count > 0) + count = flush_write_buffer(file->f_dentry,buffer,count); + if (count > 0) + *ppos += count; + up(&buffer->sem); + return count; +} + +static int check_perm(struct inode * inode, struct file * file) +{ + struct config_item *item = configfs_get_config_item(file->f_dentry->d_parent); + struct configfs_attribute * attr = to_attr(file->f_dentry); + struct configfs_buffer * buffer; + struct configfs_item_operations * ops = NULL; + int error = 0; + + if (!item || !attr) + goto Einval; + + /* Grab the module reference for this attribute if we have one */ + if (!try_module_get(attr->ca_owner)) { + error = -ENODEV; + goto Done; + } + + if (item->ci_type) + ops = item->ci_type->ct_item_ops; + else + goto Eaccess; + + /* File needs write support. + * The inode's perms must say it's ok, + * and we must have a store method. + */ + if (file->f_mode & FMODE_WRITE) { + + if (!(inode->i_mode & S_IWUGO) || !ops->store_attribute) + goto Eaccess; + + } + + /* File needs read support. + * The inode's perms must say it's ok, and we there + * must be a show method for it. + */ + if (file->f_mode & FMODE_READ) { + if (!(inode->i_mode & S_IRUGO) || !ops->show_attribute) + goto Eaccess; + } + + /* No error? Great, allocate a buffer for the file, and store it + * it in file->private_data for easy access. + */ + buffer = kmalloc(sizeof(struct configfs_buffer),GFP_KERNEL); + if (buffer) { + memset(buffer,0,sizeof(struct configfs_buffer)); + init_MUTEX(&buffer->sem); + buffer->needs_read_fill = 1; + buffer->ops = ops; + file->private_data = buffer; + } else + error = -ENOMEM; + goto Done; + + Einval: + error = -EINVAL; + goto Done; + Eaccess: + error = -EACCES; + module_put(attr->ca_owner); + Done: + if (error && item) + config_item_put(item); + return error; +} + +static int configfs_open_file(struct inode * inode, struct file * filp) +{ + return check_perm(inode,filp); +} + +static int configfs_release(struct inode * inode, struct file * filp) +{ + struct config_item * item = to_item(filp->f_dentry->d_parent); + struct configfs_attribute * attr = to_attr(filp->f_dentry); + struct module * owner = attr->ca_owner; + struct configfs_buffer * buffer = filp->private_data; + + if (item) + config_item_put(item); + /* After this point, attr should not be accessed. */ + module_put(owner); + + if (buffer) { + if (buffer->page) + free_page((unsigned long)buffer->page); + kfree(buffer); + } + return 0; +} + +struct file_operations configfs_file_operations = { + .read = configfs_read_file, + .write = configfs_write_file, + .llseek = generic_file_llseek, + .open = configfs_open_file, + .release = configfs_release, +}; + + +int configfs_add_file(struct dentry * dir, const struct configfs_attribute * attr, int type) +{ + struct configfs_dirent * parent_sd = dir->d_fsdata; + umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG; + int error = 0; + + down(&dir->d_inode->i_sem); + error = configfs_make_dirent(parent_sd, NULL, (void *) attr, mode, type); + up(&dir->d_inode->i_sem); + + return error; +} + + +/** + * configfs_create_file - create an attribute file for an item. + * @item: item we're creating for. + * @attr: atrribute descriptor. + */ + +int configfs_create_file(struct config_item * item, const struct configfs_attribute * attr) +{ + BUG_ON(!item || !item->ci_dentry || !attr); + + return configfs_add_file(item->ci_dentry, attr, + CONFIGFS_ITEM_ATTR); +} + diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c new file mode 100644 index 0000000..6b274c6 --- /dev/null +++ b/fs/configfs/inode.c @@ -0,0 +1,162 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * inode.c - basic inode and dentry operations. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on sysfs: + * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + * + * Please see Documentation/filesystems/configfs.txt for more information. + */ + +#undef DEBUG + +#include +#include +#include + +#include +#include "configfs_internal.h" + +extern struct super_block * configfs_sb; + +static struct address_space_operations configfs_aops = { + .readpage = simple_readpage, + .prepare_write = simple_prepare_write, + .commit_write = simple_commit_write +}; + +static struct backing_dev_info configfs_backing_dev_info = { + .ra_pages = 0, /* No readahead */ + .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, +}; + +struct inode * configfs_new_inode(mode_t mode) +{ + struct inode * inode = new_inode(configfs_sb); + if (inode) { + inode->i_mode = mode; + inode->i_uid = 0; + inode->i_gid = 0; + inode->i_blksize = PAGE_CACHE_SIZE; + inode->i_blocks = 0; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_mapping->a_ops = &configfs_aops; + inode->i_mapping->backing_dev_info = &configfs_backing_dev_info; + } + return inode; +} + +int configfs_create(struct dentry * dentry, int mode, int (*init)(struct inode *)) +{ + int error = 0; + struct inode * inode = NULL; + if (dentry) { + if (!dentry->d_inode) { + if ((inode = configfs_new_inode(mode))) { + if (dentry->d_parent && dentry->d_parent->d_inode) { + struct inode *p_inode = dentry->d_parent->d_inode; + p_inode->i_mtime = p_inode->i_ctime = CURRENT_TIME; + } + goto Proceed; + } + else + error = -ENOMEM; + } else + error = -EEXIST; + } else + error = -ENOENT; + goto Done; + + Proceed: + if (init) + error = init(inode); + if (!error) { + d_instantiate(dentry, inode); + if (S_ISDIR(mode) || S_ISLNK(mode)) + dget(dentry); /* pin link and directory dentries in core */ + } else + iput(inode); + Done: + return error; +} + +/* + * Get the name for corresponding element represented by the given configfs_dirent + */ +const unsigned char * configfs_get_name(struct configfs_dirent *sd) +{ + struct attribute * attr; + + if (!sd || !sd->s_element) + BUG(); + + /* These always have a dentry, so use that */ + if (sd->s_type & (CONFIGFS_DIR | CONFIGFS_ITEM_LINK)) + return sd->s_dentry->d_name.name; + + if (sd->s_type & CONFIGFS_ITEM_ATTR) { + attr = sd->s_element; + return attr->name; + } + return NULL; +} + + +/* + * Unhashes the dentry corresponding to given configfs_dirent + * Called with parent inode's i_sem held. + */ +void configfs_drop_dentry(struct configfs_dirent * sd, struct dentry * parent) +{ + struct dentry * dentry = sd->s_dentry; + + if (dentry) { + spin_lock(&dcache_lock); + if (!(d_unhashed(dentry) && dentry->d_inode)) { + dget_locked(dentry); + __d_drop(dentry); + spin_unlock(&dcache_lock); + simple_unlink(parent->d_inode, dentry); + } else + spin_unlock(&dcache_lock); + } +} + +void configfs_hash_and_remove(struct dentry * dir, const char * name) +{ + struct configfs_dirent * sd; + struct configfs_dirent * parent_sd = dir->d_fsdata; + + down(&dir->d_inode->i_sem); + list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { + if (!sd->s_element) + continue; + if (!strcmp(configfs_get_name(sd), name)) { + list_del_init(&sd->s_sibling); + configfs_drop_dentry(sd, dir); + configfs_put(sd); + break; + } + } + up(&dir->d_inode->i_sem); +} + + diff --git a/fs/configfs/item.c b/fs/configfs/item.c new file mode 100644 index 0000000..e07485a --- /dev/null +++ b/fs/configfs/item.c @@ -0,0 +1,227 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * item.c - library routines for handling generic config items + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on kobject: + * kobject is Copyright (c) 2002-2003 Patrick Mochel + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + * + * Please see the file Documentation/filesystems/configfs.txt for + * critical information about using the config_item interface. + */ + +#include +#include +#include +#include + +#include + + +static inline struct config_item * to_item(struct list_head * entry) +{ + return container_of(entry,struct config_item,ci_entry); +} + +/* Evil kernel */ +static void config_item_release(struct kref *kref); + +/** + * config_item_init - initialize item. + * @item: item in question. + */ +void config_item_init(struct config_item * item) +{ + kref_init(&item->ci_kref); + INIT_LIST_HEAD(&item->ci_entry); +} + +/** + * config_item_set_name - Set the name of an item + * @item: item. + * @name: name. + * + * If strlen(name) >= CONFIGFS_ITEM_NAME_LEN, then use a + * dynamically allocated string that @item->ci_name points to. + * Otherwise, use the static @item->ci_namebuf array. + */ + +int config_item_set_name(struct config_item * item, const char * fmt, ...) +{ + int error = 0; + int limit = CONFIGFS_ITEM_NAME_LEN; + int need; + va_list args; + char * name; + + /* + * First, try the static array + */ + va_start(args,fmt); + need = vsnprintf(item->ci_namebuf,limit,fmt,args); + va_end(args); + if (need < limit) + name = item->ci_namebuf; + else { + /* + * Need more space? Allocate it and try again + */ + limit = need + 1; + name = kmalloc(limit,GFP_KERNEL); + if (!name) { + error = -ENOMEM; + goto Done; + } + va_start(args,fmt); + need = vsnprintf(name,limit,fmt,args); + va_end(args); + + /* Still? Give up. */ + if (need >= limit) { + kfree(name); + error = -EFAULT; + goto Done; + } + } + + /* Free the old name, if necessary. */ + if (item->ci_name && item->ci_name != item->ci_namebuf) + kfree(item->ci_name); + + /* Now, set the new name */ + item->ci_name = name; + Done: + return error; +} + +EXPORT_SYMBOL(config_item_set_name); + +void config_item_init_type_name(struct config_item *item, + const char *name, + struct config_item_type *type) +{ + config_item_set_name(item, name); + item->ci_type = type; + config_item_init(item); +} +EXPORT_SYMBOL(config_item_init_type_name); + +void config_group_init_type_name(struct config_group *group, const char *name, + struct config_item_type *type) +{ + config_item_set_name(&group->cg_item, name); + group->cg_item.ci_type = type; + config_group_init(group); +} +EXPORT_SYMBOL(config_group_init_type_name); + +struct config_item * config_item_get(struct config_item * item) +{ + if (item) + kref_get(&item->ci_kref); + return item; +} + +/** + * config_item_cleanup - free config_item resources. + * @item: item. + */ + +void config_item_cleanup(struct config_item * item) +{ + struct config_item_type * t = item->ci_type; + struct config_group * s = item->ci_group; + struct config_item * parent = item->ci_parent; + + pr_debug("config_item %s: cleaning up\n",config_item_name(item)); + if (item->ci_name != item->ci_namebuf) + kfree(item->ci_name); + item->ci_name = NULL; + if (t && t->ct_item_ops && t->ct_item_ops->release) + t->ct_item_ops->release(item); + if (s) + config_group_put(s); + if (parent) + config_item_put(parent); +} + +static void config_item_release(struct kref *kref) +{ + config_item_cleanup(container_of(kref, struct config_item, ci_kref)); +} + +/** + * config_item_put - decrement refcount for item. + * @item: item. + * + * Decrement the refcount, and if 0, call config_item_cleanup(). + */ +void config_item_put(struct config_item * item) +{ + if (item) + kref_put(&item->ci_kref, config_item_release); +} + + +/** + * config_group_init - initialize a group for use + * @k: group + */ + +void config_group_init(struct config_group *group) +{ + config_item_init(&group->cg_item); + INIT_LIST_HEAD(&group->cg_children); +} + + +/** + * config_group_find_obj - search for item in group. + * @group: group we're looking in. + * @name: item's name. + * + * Lock group via @group->cg_subsys, and iterate over @group->cg_list, + * looking for a matching config_item. If matching item is found + * take a reference and return the item. + */ + +struct config_item * config_group_find_obj(struct config_group * group, const char * name) +{ + struct list_head * entry; + struct config_item * ret = NULL; + + /* XXX LOCKING! */ + list_for_each(entry,&group->cg_children) { + struct config_item * item = to_item(entry); + if (config_item_name(item) && + !strcmp(config_item_name(item), name)) { + ret = config_item_get(item); + break; + } + } + return ret; +} + + +EXPORT_SYMBOL(config_item_init); +EXPORT_SYMBOL(config_group_init); +EXPORT_SYMBOL(config_item_get); +EXPORT_SYMBOL(config_item_put); + diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c new file mode 100644 index 0000000..1a2f6f6 --- /dev/null +++ b/fs/configfs/mount.c @@ -0,0 +1,159 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * mount.c - operations for initializing and mounting configfs. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on sysfs: + * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + */ + +#include +#include +#include +#include +#include + +#include +#include "configfs_internal.h" + +/* Random magic number */ +#define CONFIGFS_MAGIC 0x62656570 + +struct vfsmount * configfs_mount = NULL; +struct super_block * configfs_sb = NULL; +static int configfs_mnt_count = 0; + +static struct super_operations configfs_ops = { + .statfs = simple_statfs, + .drop_inode = generic_delete_inode, +}; + +static struct config_group configfs_root_group = { + .cg_item = { + .ci_namebuf = "root", + .ci_name = configfs_root_group.cg_item.ci_namebuf, + }, +}; + +int configfs_is_root(struct config_item *item) +{ + return item == &configfs_root_group.cg_item; +} + +static struct configfs_dirent configfs_root = { + .s_sibling = LIST_HEAD_INIT(configfs_root.s_sibling), + .s_children = LIST_HEAD_INIT(configfs_root.s_children), + .s_element = &configfs_root_group.cg_item, + .s_type = CONFIGFS_ROOT, +}; + +static int configfs_fill_super(struct super_block *sb, void *data, int silent) +{ + struct inode *inode; + struct dentry *root; + + sb->s_blocksize = PAGE_CACHE_SIZE; + sb->s_blocksize_bits = PAGE_CACHE_SHIFT; + sb->s_magic = CONFIGFS_MAGIC; + sb->s_op = &configfs_ops; + configfs_sb = sb; + + inode = configfs_new_inode(S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO); + if (inode) { + inode->i_op = &configfs_dir_inode_operations; + inode->i_fop = &configfs_dir_operations; + /* directory inodes start off with i_nlink == 2 (for "." entry) */ + inode->i_nlink++; + } else { + pr_debug("configfs: could not get root inode\n"); + return -ENOMEM; + } + + root = d_alloc_root(inode); + if (!root) { + pr_debug("%s: could not get root dentry!\n",__FUNCTION__); + iput(inode); + return -ENOMEM; + } + config_group_init(&configfs_root_group); + configfs_root_group.cg_item.ci_dentry = root; + root->d_fsdata = &configfs_root; + sb->s_root = root; + return 0; +} + +static struct super_block *configfs_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data) +{ + return get_sb_single(fs_type, flags, data, configfs_fill_super); +} + +static struct file_system_type configfs_fs_type = { + .owner = THIS_MODULE, + .name = "configfs", + .get_sb = configfs_get_sb, + .kill_sb = kill_litter_super, +}; + +int configfs_pin_fs(void) +{ + return simple_pin_fs("configfs", &configfs_mount, + &configfs_mnt_count); +} + +void configfs_release_fs(void) +{ + simple_release_fs(&configfs_mount, &configfs_mnt_count); +} + + +static decl_subsys(config, NULL, NULL); + +static int __init configfs_init(void) +{ + int err; + + kset_set_kset_s(&config_subsys, kernel_subsys); + err = subsystem_register(&config_subsys); + if (err) + return err; + + err = register_filesystem(&configfs_fs_type); + if (err) { + printk(KERN_ERR "configfs: Unable to register filesystem!\n"); + subsystem_unregister(&config_subsys); + } + + return err; +} + +static void __exit configfs_exit(void) +{ + unregister_filesystem(&configfs_fs_type); + subsystem_unregister(&config_subsys); +} + +MODULE_AUTHOR("Oracle"); +MODULE_LICENSE("GPL"); +MODULE_VERSION("0.0.1"); +MODULE_DESCRIPTION("Simple RAM filesystem for user driven kernel subsystem configuration."); + +module_init(configfs_init); +module_exit(configfs_exit); diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c new file mode 100644 index 0000000..50f5840 --- /dev/null +++ b/fs/configfs/symlink.c @@ -0,0 +1,281 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * symlink.c - operations for configfs symlinks. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on sysfs: + * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + */ + +#include +#include +#include + +#include +#include "configfs_internal.h" + +static int item_depth(struct config_item * item) +{ + struct config_item * p = item; + int depth = 0; + do { depth++; } while ((p = p->ci_parent) && !configfs_is_root(p)); + return depth; +} + +static int item_path_length(struct config_item * item) +{ + struct config_item * p = item; + int length = 1; + do { + length += strlen(config_item_name(p)) + 1; + p = p->ci_parent; + } while (p && !configfs_is_root(p)); + return length; +} + +static void fill_item_path(struct config_item * item, char * buffer, int length) +{ + struct config_item * p; + + --length; + for (p = item; p && !configfs_is_root(p); p = p->ci_parent) { + int cur = strlen(config_item_name(p)); + + /* back up enough to print this bus id with '/' */ + length -= cur; + strncpy(buffer + length,config_item_name(p),cur); + *(buffer + --length) = '/'; + } +} + +static int create_link(struct config_item *parent_item, + struct config_item *item, + struct dentry *dentry) +{ + struct configfs_dirent *target_sd = item->ci_dentry->d_fsdata; + struct configfs_symlink *sl; + int ret; + + ret = -ENOMEM; + sl = kmalloc(sizeof(struct configfs_symlink), GFP_KERNEL); + if (sl) { + sl->sl_target = config_item_get(item); + /* FIXME: needs a lock, I'd bet */ + list_add(&sl->sl_list, &target_sd->s_links); + ret = configfs_create_link(sl, parent_item->ci_dentry, + dentry); + if (ret) { + list_del_init(&sl->sl_list); + config_item_put(item); + kfree(sl); + } + } + + return ret; +} + + +static int get_target(const char *symname, struct nameidata *nd, + struct config_item **target) +{ + int ret; + + ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, nd); + if (!ret) { + if (nd->dentry->d_sb == configfs_sb) { + *target = configfs_get_config_item(nd->dentry); + if (!*target) { + ret = -ENOENT; + path_release(nd); + } + } else + ret = -EPERM; + } + + return ret; +} + + +int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) +{ + int ret; + struct nameidata nd; + struct config_item *parent_item; + struct config_item *target_item; + struct config_item_type *type; + + ret = -EPERM; /* What lack-of-symlink returns */ + if (dentry->d_parent == configfs_sb->s_root) + goto out; + + parent_item = configfs_get_config_item(dentry->d_parent); + type = parent_item->ci_type; + + if (!type || !type->ct_item_ops || + !type->ct_item_ops->allow_link) + goto out_put; + + ret = get_target(symname, &nd, &target_item); + if (ret) + goto out_put; + + ret = type->ct_item_ops->allow_link(parent_item, target_item); + if (!ret) + ret = create_link(parent_item, target_item, dentry); + + config_item_put(target_item); + path_release(&nd); + +out_put: + config_item_put(parent_item); + +out: + return ret; +} + +int configfs_unlink(struct inode *dir, struct dentry *dentry) +{ + struct configfs_dirent *sd = dentry->d_fsdata; + struct configfs_symlink *sl; + struct config_item *parent_item; + struct config_item_type *type; + int ret; + + ret = -EPERM; /* What lack-of-symlink returns */ + if (!(sd->s_type & CONFIGFS_ITEM_LINK)) + goto out; + + if (dentry->d_parent == configfs_sb->s_root) + BUG(); + + sl = sd->s_element; + + parent_item = configfs_get_config_item(dentry->d_parent); + type = parent_item->ci_type; + + list_del_init(&sd->s_sibling); + configfs_drop_dentry(sd, dentry->d_parent); + dput(dentry); + configfs_put(sd); + + /* + * drop_link() must be called before + * list_del_init(&sl->sl_list), so that the order of + * drop_link(this, target) and drop_item(target) is preserved. + */ + if (type && type->ct_item_ops && + type->ct_item_ops->drop_link) + type->ct_item_ops->drop_link(parent_item, + sl->sl_target); + + /* FIXME: Needs lock */ + list_del_init(&sl->sl_list); + + /* Put reference from create_link() */ + config_item_put(sl->sl_target); + kfree(sl); + + config_item_put(parent_item); + + ret = 0; + +out: + return ret; +} + +static int configfs_get_target_path(struct config_item * item, struct config_item * target, + char *path) +{ + char * s; + int depth, size; + + depth = item_depth(item); + size = item_path_length(target) + depth * 3 - 1; + if (size > PATH_MAX) + return -ENAMETOOLONG; + + pr_debug("%s: depth = %d, size = %d\n", __FUNCTION__, depth, size); + + for (s = path; depth--; s += 3) + strcpy(s,"../"); + + fill_item_path(target, path, size); + pr_debug("%s: path = '%s'\n", __FUNCTION__, path); + + return 0; +} + +static int configfs_getlink(struct dentry *dentry, char * path) +{ + struct config_item *item, *target_item; + int error = 0; + + item = configfs_get_config_item(dentry->d_parent); + if (!item) + return -EINVAL; + + target_item = configfs_get_config_item(dentry); + if (!target_item) { + config_item_put(item); + return -EINVAL; + } + + down_read(&configfs_rename_sem); + error = configfs_get_target_path(item, target_item, path); + up_read(&configfs_rename_sem); + + config_item_put(item); + config_item_put(target_item); + return error; + +} + +static void *configfs_follow_link(struct dentry *dentry, struct nameidata *nd) +{ + int error = -ENOMEM; + unsigned long page = get_zeroed_page(GFP_KERNEL); + + if (page) { + error = configfs_getlink(dentry, (char *)page); + if (!error) { + nd_set_link(nd, (char *)page); + return (void *)page; + } + } + + nd_set_link(nd, ERR_PTR(error)); + return NULL; +} + +static void configfs_put_link(struct dentry *dentry, struct nameidata *nd, + void *cookie) +{ + if (cookie) { + unsigned long page = (unsigned long)cookie; + free_page(page); + } +} + +struct inode_operations configfs_symlink_inode_operations = { + .follow_link = configfs_follow_link, + .readlink = generic_readlink, + .put_link = configfs_put_link, +}; + diff --git a/include/linux/configfs.h b/include/linux/configfs.h new file mode 100644 index 0000000..acffb8c --- /dev/null +++ b/include/linux/configfs.h @@ -0,0 +1,205 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * configfs.h - definitions for the device driver filesystem + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Based on sysfs: + * sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel + * + * Based on kobject.h: + * Copyright (c) 2002-2003 Patrick Mochel + * Copyright (c) 2002-2003 Open Source Development Labs + * + * configfs Copyright (C) 2005 Oracle. All rights reserved. + * + * Please read Documentation/filesystems/configfs.txt before using the + * configfs interface, ESPECIALLY the parts about reference counts and + * item destructors. + */ + +#ifndef _CONFIGFS_H_ +#define _CONFIGFS_H_ + +#ifdef __KERNEL__ + +#include +#include +#include + +#include +#include + +#define CONFIGFS_ITEM_NAME_LEN 20 + +struct module; + +struct configfs_item_operations; +struct configfs_group_operations; +struct configfs_attribute; +struct configfs_subsystem; + +struct config_item { + char *ci_name; + char ci_namebuf[CONFIGFS_ITEM_NAME_LEN]; + struct kref ci_kref; + struct list_head ci_entry; + struct config_item *ci_parent; + struct config_group *ci_group; + struct config_item_type *ci_type; + struct dentry *ci_dentry; +}; + +extern int config_item_set_name(struct config_item *, const char *, ...); + +static inline char *config_item_name(struct config_item * item) +{ + return item->ci_name; +} + +extern void config_item_init(struct config_item *); +extern void config_item_init_type_name(struct config_item *item, + const char *name, + struct config_item_type *type); +extern void config_item_cleanup(struct config_item *); + +extern struct config_item * config_item_get(struct config_item *); +extern void config_item_put(struct config_item *); + +struct config_item_type { + struct module *ct_owner; + struct configfs_item_operations *ct_item_ops; + struct configfs_group_operations *ct_group_ops; + struct configfs_attribute **ct_attrs; +}; + + +/** + * group - a group of config_items of a specific type, belonging + * to a specific subsystem. + */ + +struct config_group { + struct config_item cg_item; + struct list_head cg_children; + struct configfs_subsystem *cg_subsys; + struct config_group **default_groups; +}; + + +extern void config_group_init(struct config_group *group); +extern void config_group_init_type_name(struct config_group *group, + const char *name, + struct config_item_type *type); + + +static inline struct config_group *to_config_group(struct config_item *item) +{ + return item ? container_of(item,struct config_group,cg_item) : NULL; +} + +static inline struct config_group *config_group_get(struct config_group *group) +{ + return group ? to_config_group(config_item_get(&group->cg_item)) : NULL; +} + +static inline void config_group_put(struct config_group *group) +{ + config_item_put(&group->cg_item); +} + +extern struct config_item *config_group_find_obj(struct config_group *, const char *); + + +struct configfs_attribute { + char *ca_name; + struct module *ca_owner; + mode_t ca_mode; +}; + + +/* + * If allow_link() exists, the item can symlink(2) out to other + * items. If the item is a group, it may support mkdir(2). + * Groups supply one of make_group() and make_item(). If the + * group supports make_group(), one can create group children. If it + * supports make_item(), one can create config_item children. If it has + * default_groups on group->default_groups, it has automatically created + * group children. default_groups may coexist alongsize make_group() or + * make_item(), but if the group wishes to have only default_groups + * children (disallowing mkdir(2)), it need not provide either function. + * If the group has commit(), it supports pending and commited (active) + * items. + */ +struct configfs_item_operations { + void (*release)(struct config_item *); + ssize_t (*show_attribute)(struct config_item *, struct configfs_attribute *,char *); + ssize_t (*store_attribute)(struct config_item *,struct configfs_attribute *,const char *, size_t); + int (*allow_link)(struct config_item *src, struct config_item *target); + int (*drop_link)(struct config_item *src, struct config_item *target); +}; + +struct configfs_group_operations { + struct config_item *(*make_item)(struct config_group *group, const char *name); + struct config_group *(*make_group)(struct config_group *group, const char *name); + int (*commit_item)(struct config_item *item); + void (*drop_item)(struct config_group *group, struct config_item *item); +}; + + + +/** + * Use these macros to make defining attributes easier. See include/linux/device.h + * for examples.. + */ + +#if 0 +#define __ATTR(_name,_mode,_show,_store) { \ + .attr = {.ca_name = __stringify(_name), .ca_mode = _mode, .ca_owner = THIS_MODULE }, \ + .show = _show, \ + .store = _store, \ +} + +#define __ATTR_RO(_name) { \ + .attr = { .ca_name = __stringify(_name), .ca_mode = 0444, .ca_owner = THIS_MODULE }, \ + .show = _name##_show, \ +} + +#define __ATTR_NULL { .attr = { .name = NULL } } + +#define attr_name(_attr) (_attr).attr.name +#endif + + +struct configfs_subsystem { + struct config_group su_group; + struct semaphore su_sem; +}; + +static inline struct configfs_subsystem *to_configfs_subsystem(struct config_group *group) +{ + return group ? + container_of(group, struct configfs_subsystem, su_group) : + NULL; +} + +int configfs_register_subsystem(struct configfs_subsystem *subsys); +void configfs_unregister_subsystem(struct configfs_subsystem *subsys); + +#endif /* __KERNEL__ */ + +#endif /* _CONFIGFS_H_ */ -- cgit v1.1 From 994fc28c7b1e697ac56befe4aecabf23f0689f46 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 15 Dec 2005 14:28:17 -0800 Subject: [PATCH] add AOP_TRUNCATED_PAGE, prepend AOP_ to WRITEPAGE_ACTIVATE readpage(), prepare_write(), and commit_write() callers are updated to understand the special return code AOP_TRUNCATED_PAGE in the style of writepage() and WRITEPAGE_ACTIVATE. AOP_TRUNCATED_PAGE tells the caller that the callee has unlocked the page and that the operation should be tried again with a new page. OCFS2 uses this to detect and work around a lock inversion in its aop methods. There should be no change in behaviour for methods that don't return AOP_TRUNCATED_PAGE. WRITEPAGE_ACTIVATE is also prepended with AOP_ for consistency and they are made enums so that kerneldoc can be used to document their semantics. Signed-off-by: Zach Brown --- drivers/block/loop.c | 23 +++++++++++---- drivers/block/rd.c | 4 +-- fs/mpage.c | 2 +- include/linux/fs.h | 31 ++++++++++++++++++++ include/linux/writeback.h | 6 ---- mm/filemap.c | 73 ++++++++++++++++++++++++++++++++--------------- mm/readahead.c | 15 ++++++---- mm/shmem.c | 2 +- mm/vmscan.c | 2 +- 9 files changed, 113 insertions(+), 45 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 96c664a..a452b13 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -213,7 +213,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, struct address_space_operations *aops = mapping->a_ops; pgoff_t index; unsigned offset, bv_offs; - int len, ret = 0; + int len, ret; down(&mapping->host->i_sem); index = pos >> PAGE_CACHE_SHIFT; @@ -232,9 +232,15 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, page = grab_cache_page(mapping, index); if (unlikely(!page)) goto fail; - if (unlikely(aops->prepare_write(file, page, offset, - offset + size))) + ret = aops->prepare_write(file, page, offset, + offset + size); + if (unlikely(ret)) { + if (ret == AOP_TRUNCATED_PAGE) { + page_cache_release(page); + continue; + } goto unlock; + } transfer_result = lo_do_transfer(lo, WRITE, page, offset, bvec->bv_page, bv_offs, size, IV); if (unlikely(transfer_result)) { @@ -251,9 +257,15 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, kunmap_atomic(kaddr, KM_USER0); } flush_dcache_page(page); - if (unlikely(aops->commit_write(file, page, offset, - offset + size))) + ret = aops->commit_write(file, page, offset, + offset + size); + if (unlikely(ret)) { + if (ret == AOP_TRUNCATED_PAGE) { + page_cache_release(page); + continue; + } goto unlock; + } if (unlikely(transfer_result)) goto unlock; bv_offs += size; @@ -264,6 +276,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec, unlock_page(page); page_cache_release(page); } + ret = 0; out: up(&mapping->host->i_sem); return ret; diff --git a/drivers/block/rd.c b/drivers/block/rd.c index 68c60a5..ffd6abd 100644 --- a/drivers/block/rd.c +++ b/drivers/block/rd.c @@ -154,7 +154,7 @@ static int ramdisk_commit_write(struct file *file, struct page *page, /* * ->writepage to the the blockdev's mapping has to redirty the page so that the - * VM doesn't go and steal it. We return WRITEPAGE_ACTIVATE so that the VM + * VM doesn't go and steal it. We return AOP_WRITEPAGE_ACTIVATE so that the VM * won't try to (pointlessly) write the page again for a while. * * Really, these pages should not be on the LRU at all. @@ -165,7 +165,7 @@ static int ramdisk_writepage(struct page *page, struct writeback_control *wbc) make_page_uptodate(page); SetPageDirty(page); if (wbc->for_reclaim) - return WRITEPAGE_ACTIVATE; + return AOP_WRITEPAGE_ACTIVATE; unlock_page(page); return 0; } diff --git a/fs/mpage.c b/fs/mpage.c index c5adcdd..f1d2d02 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -721,7 +721,7 @@ retry: &last_block_in_bio, &ret, wbc, page->mapping->a_ops->writepage); } - if (unlikely(ret == WRITEPAGE_ACTIVATE)) + if (unlikely(ret == AOP_WRITEPAGE_ACTIVATE)) unlock_page(page); if (ret || (--(wbc->nr_to_write) <= 0)) done = 1; diff --git a/include/linux/fs.h b/include/linux/fs.h index cc35b6a..ed9a41a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -302,6 +302,37 @@ struct iattr { */ #include +/** + * enum positive_aop_returns - aop return codes with specific semantics + * + * @AOP_WRITEPAGE_ACTIVATE: Informs the caller that page writeback has + * completed, that the page is still locked, and + * should be considered active. The VM uses this hint + * to return the page to the active list -- it won't + * be a candidate for writeback again in the near + * future. Other callers must be careful to unlock + * the page if they get this return. Returned by + * writepage(); + * + * @AOP_TRUNCATED_PAGE: The AOP method that was handed a locked page has + * unlocked it and the page might have been truncated. + * The caller should back up to acquiring a new page and + * trying again. The aop will be taking reasonable + * precautions not to livelock. If the caller held a page + * reference, it should drop it before retrying. Returned + * by readpage(), prepare_write(), and commit_write(). + * + * address_space_operation functions return these large constants to indicate + * special semantics to the caller. These are much larger than the bytes in a + * page to allow for functions that return the number of bytes operated on in a + * given page. + */ + +enum positive_aop_returns { + AOP_WRITEPAGE_ACTIVATE = 0x80000, + AOP_TRUNCATED_PAGE = 0x80001, +}; + /* * oh the beauties of C type declarations. */ diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 343d883..64a36ba 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -60,12 +60,6 @@ struct writeback_control { }; /* - * ->writepage() return values (make these much larger than a pagesize, in - * case some fs is returning number-of-bytes-written from writepage) - */ -#define WRITEPAGE_ACTIVATE 0x80000 /* IO was not started: activate page */ - -/* * fs/fs-writeback.c */ void writeback_inodes(struct writeback_control *wbc); diff --git a/mm/filemap.c b/mm/filemap.c index 33a28bf..6e1d08a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -831,8 +831,13 @@ readpage: /* Start the actual read. The read will unlock the page. */ error = mapping->a_ops->readpage(filp, page); - if (unlikely(error)) + if (unlikely(error)) { + if (error == AOP_TRUNCATED_PAGE) { + page_cache_release(page); + goto find_page; + } goto readpage_error; + } if (!PageUptodate(page)) { lock_page(page); @@ -1152,26 +1157,24 @@ static int fastcall page_cache_read(struct file * file, unsigned long offset) { struct address_space *mapping = file->f_mapping; struct page *page; - int error; + int ret; - page = page_cache_alloc_cold(mapping); - if (!page) - return -ENOMEM; + do { + page = page_cache_alloc_cold(mapping); + if (!page) + return -ENOMEM; + + ret = add_to_page_cache_lru(page, mapping, offset, GFP_KERNEL); + if (ret == 0) + ret = mapping->a_ops->readpage(file, page); + else if (ret == -EEXIST) + ret = 0; /* losing race to add is OK */ - error = add_to_page_cache_lru(page, mapping, offset, GFP_KERNEL); - if (!error) { - error = mapping->a_ops->readpage(file, page); page_cache_release(page); - return error; - } - /* - * We arrive here in the unlikely event that someone - * raced with us and added our page to the cache first - * or we are out of memory for radix-tree nodes. - */ - page_cache_release(page); - return error == -EEXIST ? 0 : error; + } while (ret == AOP_TRUNCATED_PAGE); + + return ret; } #define MMAP_LOTSAMISS (100) @@ -1331,10 +1334,14 @@ page_not_uptodate: goto success; } - if (!mapping->a_ops->readpage(file, page)) { + error = mapping->a_ops->readpage(file, page); + if (!error) { wait_on_page_locked(page); if (PageUptodate(page)) goto success; + } else if (error == AOP_TRUNCATED_PAGE) { + page_cache_release(page); + goto retry_find; } /* @@ -1358,10 +1365,14 @@ page_not_uptodate: goto success; } ClearPageError(page); - if (!mapping->a_ops->readpage(file, page)) { + error = mapping->a_ops->readpage(file, page); + if (!error) { wait_on_page_locked(page); if (PageUptodate(page)) goto success; + } else if (error == AOP_TRUNCATED_PAGE) { + page_cache_release(page); + goto retry_find; } /* @@ -1444,10 +1455,14 @@ page_not_uptodate: goto success; } - if (!mapping->a_ops->readpage(file, page)) { + error = mapping->a_ops->readpage(file, page); + if (!error) { wait_on_page_locked(page); if (PageUptodate(page)) goto success; + } else if (error == AOP_TRUNCATED_PAGE) { + page_cache_release(page); + goto retry_find; } /* @@ -1470,10 +1485,14 @@ page_not_uptodate: } ClearPageError(page); - if (!mapping->a_ops->readpage(file, page)) { + error = mapping->a_ops->readpage(file, page); + if (!error) { wait_on_page_locked(page); if (PageUptodate(page)) goto success; + } else if (error == AOP_TRUNCATED_PAGE) { + page_cache_release(page); + goto retry_find; } /* @@ -1934,12 +1953,16 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, status = a_ops->prepare_write(file, page, offset, offset+bytes); if (unlikely(status)) { loff_t isize = i_size_read(inode); + + if (status != AOP_TRUNCATED_PAGE) + unlock_page(page); + page_cache_release(page); + if (status == AOP_TRUNCATED_PAGE) + continue; /* * prepare_write() may have instantiated a few blocks * outside i_size. Trim these off again. */ - unlock_page(page); - page_cache_release(page); if (pos + bytes > isize) vmtruncate(inode, isize); break; @@ -1952,6 +1975,10 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, cur_iov, iov_base, bytes); flush_dcache_page(page); status = a_ops->commit_write(file, page, offset, offset+bytes); + if (status == AOP_TRUNCATED_PAGE) { + page_cache_release(page); + continue; + } if (likely(copied > 0)) { if (!status) status = copied; diff --git a/mm/readahead.c b/mm/readahead.c index 72e7adb..8d6eeaa 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -158,7 +158,7 @@ static int read_pages(struct address_space *mapping, struct file *filp, { unsigned page_idx; struct pagevec lru_pvec; - int ret = 0; + int ret; if (mapping->a_ops->readpages) { ret = mapping->a_ops->readpages(filp, mapping, pages, nr_pages); @@ -171,14 +171,17 @@ static int read_pages(struct address_space *mapping, struct file *filp, list_del(&page->lru); if (!add_to_page_cache(page, mapping, page->index, GFP_KERNEL)) { - mapping->a_ops->readpage(filp, page); - if (!pagevec_add(&lru_pvec, page)) - __pagevec_lru_add(&lru_pvec); - } else { - page_cache_release(page); + ret = mapping->a_ops->readpage(filp, page); + if (ret != AOP_TRUNCATED_PAGE) { + if (!pagevec_add(&lru_pvec, page)) + __pagevec_lru_add(&lru_pvec); + continue; + } /* else fall through to release */ } + page_cache_release(page); } pagevec_lru_add(&lru_pvec); + ret = 0; out: return ret; } diff --git a/mm/shmem.c b/mm/shmem.c index dc25565..d9fc277 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -855,7 +855,7 @@ unlock: swap_free(swap); redirty: set_page_dirty(page); - return WRITEPAGE_ACTIVATE; /* Return with the page locked */ + return AOP_WRITEPAGE_ACTIVATE; /* Return with the page locked */ } #ifdef CONFIG_NUMA diff --git a/mm/vmscan.c b/mm/vmscan.c index b0cd81c..795a050 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -367,7 +367,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping) res = mapping->a_ops->writepage(page, &wbc); if (res < 0) handle_write_error(mapping, page, res); - if (res == WRITEPAGE_ACTIVATE) { + if (res == AOP_WRITEPAGE_ACTIVATE) { ClearPageReclaim(page); return PAGE_ACTIVATE; } -- cgit v1.1 From 52fd3d6fea441835fe3a35b7280e5e128bdeca9b Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 15 Dec 2005 14:31:23 -0800 Subject: [PATCH] OCFS2: The Second Oracle Cluster Filesystem Very simple printk wrapper which adds the ability to enable various sets of debug messages at run-time. Signed-off-by: Mark Fasheh Signed-off-by: Kurt Hackel --- fs/ocfs2/cluster/masklog.c | 166 +++++++++++++++++++++++++++ fs/ocfs2/cluster/masklog.h | 275 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 441 insertions(+) create mode 100644 fs/ocfs2/cluster/masklog.c create mode 100644 fs/ocfs2/cluster/masklog.h diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c new file mode 100644 index 0000000..fd741ce --- /dev/null +++ b/fs/ocfs2/cluster/masklog.c @@ -0,0 +1,166 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2004, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include "masklog.h" + +struct mlog_bits mlog_and_bits = MLOG_BITS_RHS(MLOG_INITIAL_AND_MASK); +EXPORT_SYMBOL_GPL(mlog_and_bits); +struct mlog_bits mlog_not_bits = MLOG_BITS_RHS(MLOG_INITIAL_NOT_MASK); +EXPORT_SYMBOL_GPL(mlog_not_bits); + +static ssize_t mlog_mask_show(u64 mask, char *buf) +{ + char *state; + + if (__mlog_test_u64(mask, mlog_and_bits)) + state = "allow"; + else if (__mlog_test_u64(mask, mlog_not_bits)) + state = "deny"; + else + state = "off"; + + return snprintf(buf, PAGE_SIZE, "%s\n", state); +} + +static ssize_t mlog_mask_store(u64 mask, const char *buf, size_t count) +{ + if (!strnicmp(buf, "allow", 5)) { + __mlog_set_u64(mask, mlog_and_bits); + __mlog_clear_u64(mask, mlog_not_bits); + } else if (!strnicmp(buf, "deny", 4)) { + __mlog_set_u64(mask, mlog_not_bits); + __mlog_clear_u64(mask, mlog_and_bits); + } else if (!strnicmp(buf, "off", 3)) { + __mlog_clear_u64(mask, mlog_not_bits); + __mlog_clear_u64(mask, mlog_and_bits); + } else + return -EINVAL; + + return count; +} + +struct mlog_attribute { + struct attribute attr; + u64 mask; +}; + +#define to_mlog_attr(_attr) container_of(_attr, struct mlog_attribute, attr) + +#define define_mask(_name) { \ + .attr = { \ + .name = #_name, \ + .mode = S_IRUGO | S_IWUSR, \ + }, \ + .mask = ML_##_name, \ +} + +static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = { + define_mask(ENTRY), + define_mask(EXIT), + define_mask(TCP), + define_mask(MSG), + define_mask(SOCKET), + define_mask(HEARTBEAT), + define_mask(HB_BIO), + define_mask(DLMFS), + define_mask(DLM), + define_mask(DLM_DOMAIN), + define_mask(DLM_THREAD), + define_mask(DLM_MASTER), + define_mask(DLM_RECOVERY), + define_mask(AIO), + define_mask(JOURNAL), + define_mask(DISK_ALLOC), + define_mask(SUPER), + define_mask(FILE_IO), + define_mask(EXTENT_MAP), + define_mask(DLM_GLUE), + define_mask(BH_IO), + define_mask(UPTODATE), + define_mask(NAMEI), + define_mask(INODE), + define_mask(VOTE), + define_mask(DCACHE), + define_mask(CONN), + define_mask(QUORUM), + define_mask(EXPORT), + define_mask(ERROR), + define_mask(NOTICE), + define_mask(KTHREAD), +}; + +static struct attribute *mlog_attr_ptrs[MLOG_MAX_BITS] = {NULL, }; + +static ssize_t mlog_show(struct kobject *obj, struct attribute *attr, + char *buf) +{ + struct mlog_attribute *mlog_attr = to_mlog_attr(attr); + + return mlog_mask_show(mlog_attr->mask, buf); +} + +static ssize_t mlog_store(struct kobject *obj, struct attribute *attr, + const char *buf, size_t count) +{ + struct mlog_attribute *mlog_attr = to_mlog_attr(attr); + + return mlog_mask_store(mlog_attr->mask, buf, count); +} + +static struct sysfs_ops mlog_attr_ops = { + .show = mlog_show, + .store = mlog_store, +}; + +static struct kobj_type mlog_ktype = { + .default_attrs = mlog_attr_ptrs, + .sysfs_ops = &mlog_attr_ops, +}; + +static struct kset mlog_kset = { + .kobj = {.name = "logmask", .ktype = &mlog_ktype}, +}; + +int mlog_sys_init(struct subsystem *o2cb_subsys) +{ + int i = 0; + + while (mlog_attrs[i].attr.mode) { + mlog_attr_ptrs[i] = &mlog_attrs[i].attr; + i++; + } + mlog_attr_ptrs[i] = NULL; + + mlog_kset.subsys = o2cb_subsys; + return kset_register(&mlog_kset); +} + +void mlog_sys_shutdown(void) +{ + kset_unregister(&mlog_kset); +} diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h new file mode 100644 index 0000000..f5ef5ea --- /dev/null +++ b/fs/ocfs2/cluster/masklog.h @@ -0,0 +1,275 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef O2CLUSTER_MASKLOG_H +#define O2CLUSTER_MASKLOG_H + +/* + * For now this is a trivial wrapper around printk() that gives the critical + * ability to enable sets of debugging output at run-time. In the future this + * will almost certainly be redirected to relayfs so that it can pay a + * substantially lower heisenberg tax. + * + * Callers associate the message with a bitmask and a global bitmask is + * maintained with help from /proc. If any of the bits match the message is + * output. + * + * We must have efficient bit tests on i386 and it seems gcc still emits crazy + * code for the 64bit compare. It emits very good code for the dual unsigned + * long tests, though, completely avoiding tests that can never pass if the + * caller gives a constant bitmask that fills one of the longs with all 0s. So + * the desire is to have almost all of the calls decided on by comparing just + * one of the longs. This leads to having infrequently given bits that are + * frequently matched in the high bits. + * + * _ERROR and _NOTICE are used for messages that always go to the console and + * have appropriate KERN_ prefixes. We wrap these in our function instead of + * just calling printk() so that this can eventually make its way through + * relayfs along with the debugging messages. Everything else gets KERN_DEBUG. + * The inline tests and macro dance give GCC the opportunity to quite cleverly + * only emit the appropriage printk() when the caller passes in a constant + * mask, as is almost always the case. + * + * All this bitmask nonsense is hidden from the /proc interface so that Joel + * doesn't have an aneurism. Reading the file gives a straight forward + * indication of which bits are on or off: + * ENTRY off + * EXIT off + * TCP off + * MSG off + * SOCKET off + * ERROR off + * NOTICE on + * + * Writing changes the state of a given bit and requires a strictly formatted + * single write() call: + * + * write(fd, "ENTRY on", 8); + * + * would turn the entry bit on. "1" is also accepted in the place of "on", and + * "off" and "0" behave as expected. + * + * Some trivial shell can flip all the bits on or off: + * + * log_mask="/proc/fs/ocfs2_nodemanager/log_mask" + * cat $log_mask | ( + * while read bit status; do + * # $1 is "on" or "off", say + * echo "$bit $1" > $log_mask + * done + * ) + */ + +/* for task_struct */ +#include + +/* bits that are frequently given and infrequently matched in the low word */ +/* NOTE: If you add a flag, you need to also update mlog.c! */ +#define ML_ENTRY 0x0000000000000001ULL /* func call entry */ +#define ML_EXIT 0x0000000000000002ULL /* func call exit */ +#define ML_TCP 0x0000000000000004ULL /* net cluster/tcp.c */ +#define ML_MSG 0x0000000000000008ULL /* net network messages */ +#define ML_SOCKET 0x0000000000000010ULL /* net socket lifetime */ +#define ML_HEARTBEAT 0x0000000000000020ULL /* hb all heartbeat tracking */ +#define ML_HB_BIO 0x0000000000000040ULL /* hb io tracing */ +#define ML_DLMFS 0x0000000000000080ULL /* dlm user dlmfs */ +#define ML_DLM 0x0000000000000100ULL /* dlm general debugging */ +#define ML_DLM_DOMAIN 0x0000000000000200ULL /* dlm domain debugging */ +#define ML_DLM_THREAD 0x0000000000000400ULL /* dlm domain thread */ +#define ML_DLM_MASTER 0x0000000000000800ULL /* dlm master functions */ +#define ML_DLM_RECOVERY 0x0000000000001000ULL /* dlm master functions */ +#define ML_AIO 0x0000000000002000ULL /* ocfs2 aio read and write */ +#define ML_JOURNAL 0x0000000000004000ULL /* ocfs2 journalling functions */ +#define ML_DISK_ALLOC 0x0000000000008000ULL /* ocfs2 disk allocation */ +#define ML_SUPER 0x0000000000010000ULL /* ocfs2 mount / umount */ +#define ML_FILE_IO 0x0000000000020000ULL /* ocfs2 file I/O */ +#define ML_EXTENT_MAP 0x0000000000040000ULL /* ocfs2 extent map caching */ +#define ML_DLM_GLUE 0x0000000000080000ULL /* ocfs2 dlm glue layer */ +#define ML_BH_IO 0x0000000000100000ULL /* ocfs2 buffer I/O */ +#define ML_UPTODATE 0x0000000000200000ULL /* ocfs2 caching sequence #'s */ +#define ML_NAMEI 0x0000000000400000ULL /* ocfs2 directory / namespace */ +#define ML_INODE 0x0000000000800000ULL /* ocfs2 inode manipulation */ +#define ML_VOTE 0x0000000001000000ULL /* ocfs2 node messaging */ +#define ML_DCACHE 0x0000000002000000ULL /* ocfs2 dcache operations */ +#define ML_CONN 0x0000000004000000ULL /* net connection management */ +#define ML_QUORUM 0x0000000008000000ULL /* net connection quorum */ +#define ML_EXPORT 0x0000000010000000ULL /* ocfs2 export operations */ +/* bits that are infrequently given and frequently matched in the high word */ +#define ML_ERROR 0x0000000100000000ULL /* sent to KERN_ERR */ +#define ML_NOTICE 0x0000000200000000ULL /* setn to KERN_NOTICE */ +#define ML_KTHREAD 0x0000000400000000ULL /* kernel thread activity */ + +#define MLOG_INITIAL_AND_MASK (ML_ERROR|ML_NOTICE) +#define MLOG_INITIAL_NOT_MASK (ML_ENTRY|ML_EXIT) +#ifndef MLOG_MASK_PREFIX +#define MLOG_MASK_PREFIX 0 +#endif + +#define MLOG_MAX_BITS 64 + +struct mlog_bits { + unsigned long words[MLOG_MAX_BITS / BITS_PER_LONG]; +}; + +extern struct mlog_bits mlog_and_bits, mlog_not_bits; + +#if BITS_PER_LONG == 32 + +#define __mlog_test_u64(mask, bits) \ + ( (u32)(mask & 0xffffffff) & bits.words[0] || \ + ((u64)(mask) >> 32) & bits.words[1] ) +#define __mlog_set_u64(mask, bits) do { \ + bits.words[0] |= (u32)(mask & 0xffffffff); \ + bits.words[1] |= (u64)(mask) >> 32; \ +} while (0) +#define __mlog_clear_u64(mask, bits) do { \ + bits.words[0] &= ~((u32)(mask & 0xffffffff)); \ + bits.words[1] &= ~((u64)(mask) >> 32); \ +} while (0) +#define MLOG_BITS_RHS(mask) { \ + { \ + [0] = (u32)(mask & 0xffffffff), \ + [1] = (u64)(mask) >> 32, \ + } \ +} + +#else /* 32bit long above, 64bit long below */ + +#define __mlog_test_u64(mask, bits) ((mask) & bits.words[0]) +#define __mlog_set_u64(mask, bits) do { \ + bits.words[0] |= (mask); \ +} while (0) +#define __mlog_clear_u64(mask, bits) do { \ + bits.words[0] &= ~(mask); \ +} while (0) +#define MLOG_BITS_RHS(mask) { { (mask) } } + +#endif + +/* + * smp_processor_id() "helpfully" screams when called outside preemptible + * regions in current kernels. sles doesn't have the variants that don't + * scream. just do this instead of trying to guess which we're building + * against.. *sigh*. + */ +#define __mlog_cpu_guess ({ \ + unsigned long _cpu = get_cpu(); \ + put_cpu(); \ + _cpu; \ +}) + +/* In the following two macros, the whitespace after the ',' just + * before ##args is intentional. Otherwise, gcc 2.95 will eat the + * previous token if args expands to nothing. + */ +#define __mlog_printk(level, fmt, args...) \ + printk(level "(%u,%lu):%s:%d " fmt, current->pid, \ + __mlog_cpu_guess, __PRETTY_FUNCTION__, __LINE__ , \ + ##args) + +#define mlog(mask, fmt, args...) do { \ + u64 __m = MLOG_MASK_PREFIX | (mask); \ + if (__mlog_test_u64(__m, mlog_and_bits) && \ + !__mlog_test_u64(__m, mlog_not_bits)) { \ + if (__m & ML_ERROR) \ + __mlog_printk(KERN_ERR, "ERROR: "fmt , ##args); \ + else if (__m & ML_NOTICE) \ + __mlog_printk(KERN_NOTICE, fmt , ##args); \ + else __mlog_printk(KERN_INFO, fmt , ##args); \ + } \ +} while (0) + +#define mlog_errno(st) do { \ + int _st = (st); \ + if (_st != -ERESTARTSYS && _st != -EINTR && \ + _st != AOP_TRUNCATED_PAGE) \ + mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ +} while (0) + +#define mlog_entry(fmt, args...) do { \ + mlog(ML_ENTRY, "ENTRY:" fmt , ##args); \ +} while (0) + +#define mlog_entry_void() do { \ + mlog(ML_ENTRY, "ENTRY:\n"); \ +} while (0) + +/* We disable this for old compilers since they don't have support for + * __builtin_types_compatible_p. + */ +#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) && \ + !defined(__CHECKER__) +#define mlog_exit(st) do { \ + if (__builtin_types_compatible_p(typeof(st), unsigned long)) \ + mlog(ML_EXIT, "EXIT: %lu\n", (unsigned long) (st)); \ + else if (__builtin_types_compatible_p(typeof(st), signed long)) \ + mlog(ML_EXIT, "EXIT: %ld\n", (signed long) (st)); \ + else if (__builtin_types_compatible_p(typeof(st), unsigned int) \ + || __builtin_types_compatible_p(typeof(st), unsigned short) \ + || __builtin_types_compatible_p(typeof(st), unsigned char)) \ + mlog(ML_EXIT, "EXIT: %u\n", (unsigned int) (st)); \ + else if (__builtin_types_compatible_p(typeof(st), signed int) \ + || __builtin_types_compatible_p(typeof(st), signed short) \ + || __builtin_types_compatible_p(typeof(st), signed char)) \ + mlog(ML_EXIT, "EXIT: %d\n", (signed int) (st)); \ + else if (__builtin_types_compatible_p(typeof(st), long long)) \ + mlog(ML_EXIT, "EXIT: %lld\n", (long long) (st)); \ + else \ + mlog(ML_EXIT, "EXIT: %llu\n", (unsigned long long) (st)); \ +} while (0) +#else +#define mlog_exit(st) do { \ + mlog(ML_EXIT, "EXIT: %lld\n", (long long) (st)); \ +} while (0) +#endif + +#define mlog_exit_ptr(ptr) do { \ + mlog(ML_EXIT, "EXIT: %p\n", ptr); \ +} while (0) + +#define mlog_exit_void() do { \ + mlog(ML_EXIT, "EXIT\n"); \ +} while (0) + +#define mlog_bug_on_msg(cond, fmt, args...) do { \ + if (cond) { \ + mlog(ML_ERROR, "bug expression: " #cond "\n"); \ + mlog(ML_ERROR, fmt, ##args); \ + BUG(); \ + } \ +} while (0) + +#if (BITS_PER_LONG == 32) || defined(CONFIG_X86_64) +#define MLFi64 "lld" +#define MLFu64 "llu" +#define MLFx64 "llx" +#else +#define MLFi64 "ld" +#define MLFu64 "lu" +#define MLFx64 "lx" +#endif + +#include +#include +int mlog_sys_init(struct subsystem *o2cb_subsys); +void mlog_sys_shutdown(void); + +#endif /* O2CLUSTER_MASKLOG_H */ -- cgit v1.1 From 0c83ed8eeb28a045cdbd0b216679938aa9e665fe Mon Sep 17 00:00:00 2001 From: Kurt Hackel Date: Thu, 15 Dec 2005 14:31:23 -0800 Subject: [PATCH] OCFS2: The Second Oracle Cluster Filesystem A simple node information service, filled and updated from userspace. The rest of the stack queries this service for simple node information. Signed-off-by: Mark Fasheh Signed-off-by: Kurt Hackel --- fs/ocfs2/cluster/Makefile | 4 + fs/ocfs2/cluster/endian.h | 30 ++ fs/ocfs2/cluster/nodemanager.c | 791 +++++++++++++++++++++++++++++++++++ fs/ocfs2/cluster/nodemanager.h | 64 +++ fs/ocfs2/cluster/ocfs2_nodemanager.h | 39 ++ fs/ocfs2/cluster/ver.c | 42 ++ fs/ocfs2/cluster/ver.h | 31 ++ 7 files changed, 1001 insertions(+) create mode 100644 fs/ocfs2/cluster/Makefile create mode 100644 fs/ocfs2/cluster/endian.h create mode 100644 fs/ocfs2/cluster/nodemanager.c create mode 100644 fs/ocfs2/cluster/nodemanager.h create mode 100644 fs/ocfs2/cluster/ocfs2_nodemanager.h create mode 100644 fs/ocfs2/cluster/ver.c create mode 100644 fs/ocfs2/cluster/ver.h diff --git a/fs/ocfs2/cluster/Makefile b/fs/ocfs2/cluster/Makefile new file mode 100644 index 0000000..cdd162f --- /dev/null +++ b/fs/ocfs2/cluster/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_OCFS2_FS) += ocfs2_nodemanager.o + +ocfs2_nodemanager-objs := heartbeat.o masklog.o sys.o nodemanager.o \ + quorum.o tcp.o ver.o diff --git a/fs/ocfs2/cluster/endian.h b/fs/ocfs2/cluster/endian.h new file mode 100644 index 0000000..2df9082 --- /dev/null +++ b/fs/ocfs2/cluster/endian.h @@ -0,0 +1,30 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_CLUSTER_ENDIAN_H +#define OCFS2_CLUSTER_ENDIAN_H + +static inline void be32_add_cpu(__be32 *var, u32 val) +{ + *var = cpu_to_be32(be32_to_cpu(*var) + val); +} + +#endif /* OCFS2_CLUSTER_ENDIAN_H */ diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c new file mode 100644 index 0000000..5fd60c1 --- /dev/null +++ b/fs/ocfs2/cluster/nodemanager.c @@ -0,0 +1,791 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2004, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#include "endian.h" +#include "tcp.h" +#include "nodemanager.h" +#include "heartbeat.h" +#include "masklog.h" +#include "sys.h" +#include "ver.h" + +/* for now we operate under the assertion that there can be only one + * cluster active at a time. Changing this will require trickling + * cluster references throughout where nodes are looked up */ +static struct o2nm_cluster *o2nm_single_cluster = NULL; + +#define OCFS2_MAX_HB_CTL_PATH 256 +static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; + +static ctl_table ocfs2_nm_table[] = { + { + .ctl_name = 1, + .procname = "hb_ctl_path", + .data = ocfs2_hb_ctl_path, + .maxlen = OCFS2_MAX_HB_CTL_PATH, + .mode = 0644, + .proc_handler = &proc_dostring, + .strategy = &sysctl_string, + }, + { .ctl_name = 0 } +}; + +static ctl_table ocfs2_mod_table[] = { + { + .ctl_name = KERN_OCFS2_NM, + .procname = "nm", + .data = NULL, + .maxlen = 0, + .mode = 0555, + .child = ocfs2_nm_table + }, + { .ctl_name = 0} +}; + +static ctl_table ocfs2_kern_table[] = { + { + .ctl_name = KERN_OCFS2, + .procname = "ocfs2", + .data = NULL, + .maxlen = 0, + .mode = 0555, + .child = ocfs2_mod_table + }, + { .ctl_name = 0} +}; + +static ctl_table ocfs2_root_table[] = { + { + .ctl_name = CTL_FS, + .procname = "fs", + .data = NULL, + .maxlen = 0, + .mode = 0555, + .child = ocfs2_kern_table + }, + { .ctl_name = 0 } +}; + +static struct ctl_table_header *ocfs2_table_header = NULL; + +const char *o2nm_get_hb_ctl_path(void) +{ + return ocfs2_hb_ctl_path; +} +EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path); + +struct o2nm_cluster { + struct config_group cl_group; + unsigned cl_has_local:1; + u8 cl_local_node; + rwlock_t cl_nodes_lock; + struct o2nm_node *cl_nodes[O2NM_MAX_NODES]; + struct rb_root cl_node_ip_tree; + /* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */ + unsigned long cl_nodes_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; +}; + +struct o2nm_node *o2nm_get_node_by_num(u8 node_num) +{ + struct o2nm_node *node = NULL; + + if (node_num >= O2NM_MAX_NODES || o2nm_single_cluster == NULL) + goto out; + + read_lock(&o2nm_single_cluster->cl_nodes_lock); + node = o2nm_single_cluster->cl_nodes[node_num]; + if (node) + config_item_get(&node->nd_item); + read_unlock(&o2nm_single_cluster->cl_nodes_lock); +out: + return node; +} +EXPORT_SYMBOL_GPL(o2nm_get_node_by_num); + +int o2nm_configured_node_map(unsigned long *map, unsigned bytes) +{ + struct o2nm_cluster *cluster = o2nm_single_cluster; + + BUG_ON(bytes < (sizeof(cluster->cl_nodes_bitmap))); + + if (cluster == NULL) + return -EINVAL; + + read_lock(&cluster->cl_nodes_lock); + memcpy(map, cluster->cl_nodes_bitmap, sizeof(cluster->cl_nodes_bitmap)); + read_unlock(&cluster->cl_nodes_lock); + + return 0; +} +EXPORT_SYMBOL_GPL(o2nm_configured_node_map); + +static struct o2nm_node *o2nm_node_ip_tree_lookup(struct o2nm_cluster *cluster, + __be32 ip_needle, + struct rb_node ***ret_p, + struct rb_node **ret_parent) +{ + struct rb_node **p = &cluster->cl_node_ip_tree.rb_node; + struct rb_node *parent = NULL; + struct o2nm_node *node, *ret = NULL; + + while (*p) { + parent = *p; + node = rb_entry(parent, struct o2nm_node, nd_ip_node); + + if (memcmp(&ip_needle, &node->nd_ipv4_address, + sizeof(ip_needle)) < 0) + p = &(*p)->rb_left; + else if (memcmp(&ip_needle, &node->nd_ipv4_address, + sizeof(ip_needle)) > 0) + p = &(*p)->rb_right; + else { + ret = node; + break; + } + } + + if (ret_p != NULL) + *ret_p = p; + if (ret_parent != NULL) + *ret_parent = parent; + + return ret; +} + +struct o2nm_node *o2nm_get_node_by_ip(__be32 addr) +{ + struct o2nm_node *node = NULL; + struct o2nm_cluster *cluster = o2nm_single_cluster; + + if (cluster == NULL) + goto out; + + read_lock(&cluster->cl_nodes_lock); + node = o2nm_node_ip_tree_lookup(cluster, addr, NULL, NULL); + if (node) + config_item_get(&node->nd_item); + read_unlock(&cluster->cl_nodes_lock); + +out: + return node; +} +EXPORT_SYMBOL_GPL(o2nm_get_node_by_ip); + +void o2nm_node_put(struct o2nm_node *node) +{ + config_item_put(&node->nd_item); +} +EXPORT_SYMBOL_GPL(o2nm_node_put); + +void o2nm_node_get(struct o2nm_node *node) +{ + config_item_get(&node->nd_item); +} +EXPORT_SYMBOL_GPL(o2nm_node_get); + +u8 o2nm_this_node(void) +{ + u8 node_num = O2NM_MAX_NODES; + + if (o2nm_single_cluster && o2nm_single_cluster->cl_has_local) + node_num = o2nm_single_cluster->cl_local_node; + + return node_num; +} +EXPORT_SYMBOL_GPL(o2nm_this_node); + +/* node configfs bits */ + +static struct o2nm_cluster *to_o2nm_cluster(struct config_item *item) +{ + return item ? + container_of(to_config_group(item), struct o2nm_cluster, + cl_group) + : NULL; +} + +static struct o2nm_node *to_o2nm_node(struct config_item *item) +{ + return item ? container_of(item, struct o2nm_node, nd_item) : NULL; +} + +static void o2nm_node_release(struct config_item *item) +{ + struct o2nm_node *node = to_o2nm_node(item); + kfree(node); +} + +static ssize_t o2nm_node_num_read(struct o2nm_node *node, char *page) +{ + return sprintf(page, "%d\n", node->nd_num); +} + +static struct o2nm_cluster *to_o2nm_cluster_from_node(struct o2nm_node *node) +{ + /* through the first node_set .parent + * mycluster/nodes/mynode == o2nm_cluster->o2nm_node_group->o2nm_node */ + return to_o2nm_cluster(node->nd_item.ci_parent->ci_parent); +} + +enum { + O2NM_NODE_ATTR_NUM = 0, + O2NM_NODE_ATTR_PORT, + O2NM_NODE_ATTR_ADDRESS, + O2NM_NODE_ATTR_LOCAL, +}; + +static ssize_t o2nm_node_num_write(struct o2nm_node *node, const char *page, + size_t count) +{ + struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); + unsigned long tmp; + char *p = (char *)page; + + tmp = simple_strtoul(p, &p, 0); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + if (tmp >= O2NM_MAX_NODES) + return -ERANGE; + + /* once we're in the cl_nodes tree networking can look us up by + * node number and try to use our address and port attributes + * to connect to this node.. make sure that they've been set + * before writing the node attribute? */ + if (!test_bit(O2NM_NODE_ATTR_ADDRESS, &node->nd_set_attributes) || + !test_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes)) + return -EINVAL; /* XXX */ + + write_lock(&cluster->cl_nodes_lock); + if (cluster->cl_nodes[tmp]) + p = NULL; + else { + cluster->cl_nodes[tmp] = node; + node->nd_num = tmp; + set_bit(tmp, cluster->cl_nodes_bitmap); + } + write_unlock(&cluster->cl_nodes_lock); + if (p == NULL) + return -EEXIST; + + return count; +} +static ssize_t o2nm_node_ipv4_port_read(struct o2nm_node *node, char *page) +{ + return sprintf(page, "%u\n", ntohs(node->nd_ipv4_port)); +} + +static ssize_t o2nm_node_ipv4_port_write(struct o2nm_node *node, + const char *page, size_t count) +{ + unsigned long tmp; + char *p = (char *)page; + + tmp = simple_strtoul(p, &p, 0); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + if (tmp == 0) + return -EINVAL; + if (tmp >= (u16)-1) + return -ERANGE; + + node->nd_ipv4_port = htons(tmp); + + return count; +} + +static ssize_t o2nm_node_ipv4_address_read(struct o2nm_node *node, char *page) +{ + return sprintf(page, "%u.%u.%u.%u\n", NIPQUAD(node->nd_ipv4_address)); +} + +static ssize_t o2nm_node_ipv4_address_write(struct o2nm_node *node, + const char *page, + size_t count) +{ + struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); + int ret, i; + struct rb_node **p, *parent; + unsigned int octets[4]; + __be32 ipv4_addr = 0; + + ret = sscanf(page, "%3u.%3u.%3u.%3u", &octets[3], &octets[2], + &octets[1], &octets[0]); + if (ret != 4) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(octets); i++) { + if (octets[i] > 255) + return -ERANGE; + be32_add_cpu(&ipv4_addr, octets[i] << (i * 8)); + } + + ret = 0; + write_lock(&cluster->cl_nodes_lock); + if (o2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent)) + ret = -EEXIST; + else { + rb_link_node(&node->nd_ip_node, parent, p); + rb_insert_color(&node->nd_ip_node, &cluster->cl_node_ip_tree); + } + write_unlock(&cluster->cl_nodes_lock); + if (ret) + return ret; + + memcpy(&node->nd_ipv4_address, &ipv4_addr, sizeof(ipv4_addr)); + + return count; +} + +static ssize_t o2nm_node_local_read(struct o2nm_node *node, char *page) +{ + return sprintf(page, "%d\n", node->nd_local); +} + +static ssize_t o2nm_node_local_write(struct o2nm_node *node, const char *page, + size_t count) +{ + struct o2nm_cluster *cluster = to_o2nm_cluster_from_node(node); + unsigned long tmp; + char *p = (char *)page; + ssize_t ret; + + tmp = simple_strtoul(p, &p, 0); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + tmp = !!tmp; /* boolean of whether this node wants to be local */ + + /* setting local turns on networking rx for now so we require having + * set everything else first */ + if (!test_bit(O2NM_NODE_ATTR_ADDRESS, &node->nd_set_attributes) || + !test_bit(O2NM_NODE_ATTR_NUM, &node->nd_set_attributes) || + !test_bit(O2NM_NODE_ATTR_PORT, &node->nd_set_attributes)) + return -EINVAL; /* XXX */ + + /* the only failure case is trying to set a new local node + * when a different one is already set */ + if (tmp && tmp == cluster->cl_has_local && + cluster->cl_local_node != node->nd_num) + return -EBUSY; + + /* bring up the rx thread if we're setting the new local node. */ + if (tmp && !cluster->cl_has_local) { + ret = o2net_start_listening(node); + if (ret) + return ret; + } + + if (!tmp && cluster->cl_has_local && + cluster->cl_local_node == node->nd_num) { + o2net_stop_listening(node); + cluster->cl_local_node = O2NM_INVALID_NODE_NUM; + } + + node->nd_local = tmp; + if (node->nd_local) { + cluster->cl_has_local = tmp; + cluster->cl_local_node = node->nd_num; + } + + return count; +} + +struct o2nm_node_attribute { + struct configfs_attribute attr; + ssize_t (*show)(struct o2nm_node *, char *); + ssize_t (*store)(struct o2nm_node *, const char *, size_t); +}; + +static struct o2nm_node_attribute o2nm_node_attr_num = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "num", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2nm_node_num_read, + .store = o2nm_node_num_write, +}; + +static struct o2nm_node_attribute o2nm_node_attr_ipv4_port = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "ipv4_port", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2nm_node_ipv4_port_read, + .store = o2nm_node_ipv4_port_write, +}; + +static struct o2nm_node_attribute o2nm_node_attr_ipv4_address = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "ipv4_address", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2nm_node_ipv4_address_read, + .store = o2nm_node_ipv4_address_write, +}; + +static struct o2nm_node_attribute o2nm_node_attr_local = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "local", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2nm_node_local_read, + .store = o2nm_node_local_write, +}; + +static struct configfs_attribute *o2nm_node_attrs[] = { + [O2NM_NODE_ATTR_NUM] = &o2nm_node_attr_num.attr, + [O2NM_NODE_ATTR_PORT] = &o2nm_node_attr_ipv4_port.attr, + [O2NM_NODE_ATTR_ADDRESS] = &o2nm_node_attr_ipv4_address.attr, + [O2NM_NODE_ATTR_LOCAL] = &o2nm_node_attr_local.attr, + NULL, +}; + +static int o2nm_attr_index(struct configfs_attribute *attr) +{ + int i; + for (i = 0; i < ARRAY_SIZE(o2nm_node_attrs); i++) { + if (attr == o2nm_node_attrs[i]) + return i; + } + BUG(); + return 0; +} + +static ssize_t o2nm_node_show(struct config_item *item, + struct configfs_attribute *attr, + char *page) +{ + struct o2nm_node *node = to_o2nm_node(item); + struct o2nm_node_attribute *o2nm_node_attr = + container_of(attr, struct o2nm_node_attribute, attr); + ssize_t ret = 0; + + if (o2nm_node_attr->show) + ret = o2nm_node_attr->show(node, page); + return ret; +} + +static ssize_t o2nm_node_store(struct config_item *item, + struct configfs_attribute *attr, + const char *page, size_t count) +{ + struct o2nm_node *node = to_o2nm_node(item); + struct o2nm_node_attribute *o2nm_node_attr = + container_of(attr, struct o2nm_node_attribute, attr); + ssize_t ret; + int attr_index = o2nm_attr_index(attr); + + if (o2nm_node_attr->store == NULL) { + ret = -EINVAL; + goto out; + } + + if (test_bit(attr_index, &node->nd_set_attributes)) + return -EBUSY; + + ret = o2nm_node_attr->store(node, page, count); + if (ret < count) + goto out; + + set_bit(attr_index, &node->nd_set_attributes); +out: + return ret; +} + +static struct configfs_item_operations o2nm_node_item_ops = { + .release = o2nm_node_release, + .show_attribute = o2nm_node_show, + .store_attribute = o2nm_node_store, +}; + +static struct config_item_type o2nm_node_type = { + .ct_item_ops = &o2nm_node_item_ops, + .ct_attrs = o2nm_node_attrs, + .ct_owner = THIS_MODULE, +}; + +/* node set */ + +struct o2nm_node_group { + struct config_group ns_group; + /* some stuff? */ +}; + +#if 0 +static struct o2nm_node_group *to_o2nm_node_group(struct config_group *group) +{ + return group ? + container_of(group, struct o2nm_node_group, ns_group) + : NULL; +} +#endif + +static struct config_item *o2nm_node_group_make_item(struct config_group *group, + const char *name) +{ + struct o2nm_node *node = NULL; + struct config_item *ret = NULL; + + if (strlen(name) > O2NM_MAX_NAME_LEN) + goto out; /* ENAMETOOLONG */ + + node = kcalloc(1, sizeof(struct o2nm_node), GFP_KERNEL); + if (node == NULL) + goto out; /* ENOMEM */ + + strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ + config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); + spin_lock_init(&node->nd_lock); + + ret = &node->nd_item; + +out: + if (ret == NULL) + kfree(node); + + return ret; +} + +static void o2nm_node_group_drop_item(struct config_group *group, + struct config_item *item) +{ + struct o2nm_node *node = to_o2nm_node(item); + struct o2nm_cluster *cluster = to_o2nm_cluster(group->cg_item.ci_parent); + + o2net_disconnect_node(node); + + if (cluster->cl_has_local && + (cluster->cl_local_node == node->nd_num)) { + cluster->cl_has_local = 0; + cluster->cl_local_node = O2NM_INVALID_NODE_NUM; + o2net_stop_listening(node); + } + + /* XXX call into net to stop this node from trading messages */ + + write_lock(&cluster->cl_nodes_lock); + + /* XXX sloppy */ + if (node->nd_ipv4_address) + rb_erase(&node->nd_ip_node, &cluster->cl_node_ip_tree); + + /* nd_num might be 0 if the node number hasn't been set.. */ + if (cluster->cl_nodes[node->nd_num] == node) { + cluster->cl_nodes[node->nd_num] = NULL; + clear_bit(node->nd_num, cluster->cl_nodes_bitmap); + } + write_unlock(&cluster->cl_nodes_lock); + + config_item_put(item); +} + +static struct configfs_group_operations o2nm_node_group_group_ops = { + .make_item = o2nm_node_group_make_item, + .drop_item = o2nm_node_group_drop_item, +}; + +static struct config_item_type o2nm_node_group_type = { + .ct_group_ops = &o2nm_node_group_group_ops, + .ct_owner = THIS_MODULE, +}; + +/* cluster */ + +static void o2nm_cluster_release(struct config_item *item) +{ + struct o2nm_cluster *cluster = to_o2nm_cluster(item); + + kfree(cluster->cl_group.default_groups); + kfree(cluster); +} + +static struct configfs_item_operations o2nm_cluster_item_ops = { + .release = o2nm_cluster_release, +}; + +static struct config_item_type o2nm_cluster_type = { + .ct_item_ops = &o2nm_cluster_item_ops, + .ct_owner = THIS_MODULE, +}; + +/* cluster set */ + +struct o2nm_cluster_group { + struct configfs_subsystem cs_subsys; + /* some stuff? */ +}; + +#if 0 +static struct o2nm_cluster_group *to_o2nm_cluster_group(struct config_group *group) +{ + return group ? + container_of(to_configfs_subsystem(group), struct o2nm_cluster_group, cs_subsys) + : NULL; +} +#endif + +static struct config_group *o2nm_cluster_group_make_group(struct config_group *group, + const char *name) +{ + struct o2nm_cluster *cluster = NULL; + struct o2nm_node_group *ns = NULL; + struct config_group *o2hb_group = NULL, *ret = NULL; + void *defs = NULL; + + /* this runs under the parent dir's i_sem; there can be only + * one caller in here at a time */ + if (o2nm_single_cluster) + goto out; /* ENOSPC */ + + cluster = kcalloc(1, sizeof(struct o2nm_cluster), GFP_KERNEL); + ns = kcalloc(1, sizeof(struct o2nm_node_group), GFP_KERNEL); + defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); + o2hb_group = o2hb_alloc_hb_set(); + if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) + goto out; + + config_group_init_type_name(&cluster->cl_group, name, + &o2nm_cluster_type); + config_group_init_type_name(&ns->ns_group, "node", + &o2nm_node_group_type); + + cluster->cl_group.default_groups = defs; + cluster->cl_group.default_groups[0] = &ns->ns_group; + cluster->cl_group.default_groups[1] = o2hb_group; + cluster->cl_group.default_groups[2] = NULL; + rwlock_init(&cluster->cl_nodes_lock); + cluster->cl_node_ip_tree = RB_ROOT; + + ret = &cluster->cl_group; + o2nm_single_cluster = cluster; + +out: + if (ret == NULL) { + kfree(cluster); + kfree(ns); + o2hb_free_hb_set(o2hb_group); + kfree(defs); + } + + return ret; +} + +static void o2nm_cluster_group_drop_item(struct config_group *group, struct config_item *item) +{ + struct o2nm_cluster *cluster = to_o2nm_cluster(item); + int i; + struct config_item *killme; + + BUG_ON(o2nm_single_cluster != cluster); + o2nm_single_cluster = NULL; + + for (i = 0; cluster->cl_group.default_groups[i]; i++) { + killme = &cluster->cl_group.default_groups[i]->cg_item; + cluster->cl_group.default_groups[i] = NULL; + config_item_put(killme); + } + + config_item_put(item); +} + +static struct configfs_group_operations o2nm_cluster_group_group_ops = { + .make_group = o2nm_cluster_group_make_group, + .drop_item = o2nm_cluster_group_drop_item, +}; + +static struct config_item_type o2nm_cluster_group_type = { + .ct_group_ops = &o2nm_cluster_group_group_ops, + .ct_owner = THIS_MODULE, +}; + +static struct o2nm_cluster_group o2nm_cluster_group = { + .cs_subsys = { + .su_group = { + .cg_item = { + .ci_namebuf = "cluster", + .ci_type = &o2nm_cluster_group_type, + }, + }, + }, +}; + +static void __exit exit_o2nm(void) +{ + if (ocfs2_table_header) + unregister_sysctl_table(ocfs2_table_header); + + /* XXX sync with hb callbacks and shut down hb? */ + o2net_unregister_hb_callbacks(); + configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys); + o2cb_sys_shutdown(); + + o2net_exit(); +} + +static int __init init_o2nm(void) +{ + int ret = -1; + + cluster_print_version(); + + o2hb_init(); + o2net_init(); + + ocfs2_table_header = register_sysctl_table(ocfs2_root_table, 0); + if (!ocfs2_table_header) { + printk(KERN_ERR "nodemanager: unable to register sysctl\n"); + ret = -ENOMEM; /* or something. */ + goto out; + } + + ret = o2net_register_hb_callbacks(); + if (ret) + goto out_sysctl; + + config_group_init(&o2nm_cluster_group.cs_subsys.su_group); + init_MUTEX(&o2nm_cluster_group.cs_subsys.su_sem); + ret = configfs_register_subsystem(&o2nm_cluster_group.cs_subsys); + if (ret) { + printk(KERN_ERR "nodemanager: Registration returned %d\n", ret); + goto out_callbacks; + } + + ret = o2cb_sys_init(); + if (!ret) + goto out; + + configfs_unregister_subsystem(&o2nm_cluster_group.cs_subsys); +out_callbacks: + o2net_unregister_hb_callbacks(); +out_sysctl: + unregister_sysctl_table(ocfs2_table_header); +out: + return ret; +} + +MODULE_AUTHOR("Oracle"); +MODULE_LICENSE("GPL"); + +module_init(init_o2nm) +module_exit(exit_o2nm) diff --git a/fs/ocfs2/cluster/nodemanager.h b/fs/ocfs2/cluster/nodemanager.h new file mode 100644 index 0000000..fce8033 --- /dev/null +++ b/fs/ocfs2/cluster/nodemanager.h @@ -0,0 +1,64 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * nodemanager.h + * + * Function prototypes + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef O2CLUSTER_NODEMANAGER_H +#define O2CLUSTER_NODEMANAGER_H + +#include "ocfs2_nodemanager.h" + +/* This totally doesn't belong here. */ +#include +#include + +#define KERN_OCFS2 988 +#define KERN_OCFS2_NM 1 + +const char *o2nm_get_hb_ctl_path(void); + +struct o2nm_node { + spinlock_t nd_lock; + struct config_item nd_item; + char nd_name[O2NM_MAX_NAME_LEN+1]; /* replace? */ + __u8 nd_num; + /* only one address per node, as attributes, for now. */ + __be32 nd_ipv4_address; + __be16 nd_ipv4_port; + struct rb_node nd_ip_node; + /* there can be only one local node for now */ + int nd_local; + + unsigned long nd_set_attributes; +}; + +u8 o2nm_this_node(void); + +int o2nm_configured_node_map(unsigned long *map, unsigned bytes); +struct o2nm_node *o2nm_get_node_by_num(u8 node_num); +struct o2nm_node *o2nm_get_node_by_ip(__be32 addr); +void o2nm_node_get(struct o2nm_node *node); +void o2nm_node_put(struct o2nm_node *node); + +#endif /* O2CLUSTER_NODEMANAGER_H */ diff --git a/fs/ocfs2/cluster/ocfs2_nodemanager.h b/fs/ocfs2/cluster/ocfs2_nodemanager.h new file mode 100644 index 0000000..5b9854b --- /dev/null +++ b/fs/ocfs2/cluster/ocfs2_nodemanager.h @@ -0,0 +1,39 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ocfs2_nodemanager.h + * + * Header describing the interface between userspace and the kernel + * for the ocfs2_nodemanager module. + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef _OCFS2_NODEMANAGER_H +#define _OCFS2_NODEMANAGER_H + +#define O2NM_API_VERSION 5 + +#define O2NM_MAX_NODES 255 +#define O2NM_INVALID_NODE_NUM 255 + +/* host name, group name, cluster name all 64 bytes */ +#define O2NM_MAX_NAME_LEN 64 // __NEW_UTS_LEN + +#endif /* _OCFS2_NODEMANAGER_H */ diff --git a/fs/ocfs2/cluster/ver.c b/fs/ocfs2/cluster/ver.c new file mode 100644 index 0000000..7286c48 --- /dev/null +++ b/fs/ocfs2/cluster/ver.c @@ -0,0 +1,42 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ver.c + * + * version string + * + * Copyright (C) 2002, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include + +#include "ver.h" + +#define CLUSTER_BUILD_VERSION "1.3.3" + +#define VERSION_STR "OCFS2 Node Manager " CLUSTER_BUILD_VERSION + +void cluster_print_version(void) +{ + printk(KERN_INFO "%s\n", VERSION_STR); +} + +MODULE_DESCRIPTION(VERSION_STR); + +MODULE_VERSION(CLUSTER_BUILD_VERSION); diff --git a/fs/ocfs2/cluster/ver.h b/fs/ocfs2/cluster/ver.h new file mode 100644 index 0000000..32554c3 --- /dev/null +++ b/fs/ocfs2/cluster/ver.h @@ -0,0 +1,31 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ver.h + * + * Function prototypes + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef O2CLUSTER_VER_H +#define O2CLUSTER_VER_H + +void cluster_print_version(void); + +#endif /* O2CLUSTER_VER_H */ -- cgit v1.1 From a7f6a5fb4bde142b622706e2006ba33f793e13ed Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 15 Dec 2005 14:31:23 -0800 Subject: [PATCH] OCFS2: The Second Oracle Cluster Filesystem Disk based heartbeat. Configured and started from userspace, the kernel component handles I/O submission and event generation via callback mechanism. Signed-off-by: Mark Fasheh Signed-off-by: Kurt Hackel --- fs/ocfs2/cluster/heartbeat.c | 1797 ++++++++++++++++++++++++++++++++++++ fs/ocfs2/cluster/heartbeat.h | 82 ++ fs/ocfs2/cluster/ocfs2_heartbeat.h | 37 + 3 files changed, 1916 insertions(+) create mode 100644 fs/ocfs2/cluster/heartbeat.c create mode 100644 fs/ocfs2/cluster/heartbeat.h create mode 100644 fs/ocfs2/cluster/ocfs2_heartbeat.h diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c new file mode 100644 index 0000000..7307ba5 --- /dev/null +++ b/fs/ocfs2/cluster/heartbeat.c @@ -0,0 +1,1797 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2004, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "heartbeat.h" +#include "tcp.h" +#include "nodemanager.h" +#include "quorum.h" + +#include "masklog.h" + + +/* + * The first heartbeat pass had one global thread that would serialize all hb + * callback calls. This global serializing sem should only be removed once + * we've made sure that all callees can deal with being called concurrently + * from multiple hb region threads. + */ +static DECLARE_RWSEM(o2hb_callback_sem); + +/* + * multiple hb threads are watching multiple regions. A node is live + * whenever any of the threads sees activity from the node in its region. + */ +static spinlock_t o2hb_live_lock = SPIN_LOCK_UNLOCKED; +static struct list_head o2hb_live_slots[O2NM_MAX_NODES]; +static unsigned long o2hb_live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; +static LIST_HEAD(o2hb_node_events); +static DECLARE_WAIT_QUEUE_HEAD(o2hb_steady_queue); + +static LIST_HEAD(o2hb_all_regions); + +static struct o2hb_callback { + struct list_head list; +} o2hb_callbacks[O2HB_NUM_CB]; + +static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type); + +#define O2HB_DEFAULT_BLOCK_BITS 9 + +unsigned int o2hb_dead_threshold = O2HB_DEFAULT_DEAD_THRESHOLD; + +/* Only sets a new threshold if there are no active regions. + * + * No locking or otherwise interesting code is required for reading + * o2hb_dead_threshold as it can't change once regions are active and + * it's not interesting to anyone until then anyway. */ +static void o2hb_dead_threshold_set(unsigned int threshold) +{ + if (threshold > O2HB_MIN_DEAD_THRESHOLD) { + spin_lock(&o2hb_live_lock); + if (list_empty(&o2hb_all_regions)) + o2hb_dead_threshold = threshold; + spin_unlock(&o2hb_live_lock); + } +} + +struct o2hb_node_event { + struct list_head hn_item; + enum o2hb_callback_type hn_event_type; + struct o2nm_node *hn_node; + int hn_node_num; +}; + +struct o2hb_disk_slot { + struct o2hb_disk_heartbeat_block *ds_raw_block; + u8 ds_node_num; + u64 ds_last_time; + u64 ds_last_generation; + u16 ds_equal_samples; + u16 ds_changed_samples; + struct list_head ds_live_item; +}; + +/* each thread owns a region.. when we're asked to tear down the region + * we ask the thread to stop, who cleans up the region */ +struct o2hb_region { + struct config_item hr_item; + + struct list_head hr_all_item; + unsigned hr_unclean_stop:1; + + /* protected by the hr_callback_sem */ + struct task_struct *hr_task; + + unsigned int hr_blocks; + unsigned long long hr_start_block; + + unsigned int hr_block_bits; + unsigned int hr_block_bytes; + + unsigned int hr_slots_per_page; + unsigned int hr_num_pages; + + struct page **hr_slot_data; + struct block_device *hr_bdev; + struct o2hb_disk_slot *hr_slots; + + /* let the person setting up hb wait for it to return until it + * has reached a 'steady' state. This will be fixed when we have + * a more complete api that doesn't lead to this sort of fragility. */ + atomic_t hr_steady_iterations; + + char hr_dev_name[BDEVNAME_SIZE]; + + unsigned int hr_timeout_ms; + + /* randomized as the region goes up and down so that a node + * recognizes a node going up and down in one iteration */ + u64 hr_generation; + + struct work_struct hr_write_timeout_work; + unsigned long hr_last_timeout_start; + + /* Used during o2hb_check_slot to hold a copy of the block + * being checked because we temporarily have to zero out the + * crc field. */ + struct o2hb_disk_heartbeat_block *hr_tmp_block; +}; + +struct o2hb_bio_wait_ctxt { + atomic_t wc_num_reqs; + struct completion wc_io_complete; +}; + +static void o2hb_write_timeout(void *arg) +{ + struct o2hb_region *reg = arg; + + mlog(ML_ERROR, "Heartbeat write timeout to device %s after %u " + "milliseconds\n", reg->hr_dev_name, + jiffies_to_msecs(jiffies - reg->hr_last_timeout_start)); + o2quo_disk_timeout(); +} + +static void o2hb_arm_write_timeout(struct o2hb_region *reg) +{ + mlog(0, "Queue write timeout for %u ms\n", O2HB_MAX_WRITE_TIMEOUT_MS); + + cancel_delayed_work(®->hr_write_timeout_work); + reg->hr_last_timeout_start = jiffies; + schedule_delayed_work(®->hr_write_timeout_work, + msecs_to_jiffies(O2HB_MAX_WRITE_TIMEOUT_MS)); +} + +static void o2hb_disarm_write_timeout(struct o2hb_region *reg) +{ + cancel_delayed_work(®->hr_write_timeout_work); + flush_scheduled_work(); +} + +static inline void o2hb_bio_wait_init(struct o2hb_bio_wait_ctxt *wc, + unsigned int num_ios) +{ + atomic_set(&wc->wc_num_reqs, num_ios); + init_completion(&wc->wc_io_complete); +} + +/* Used in error paths too */ +static inline void o2hb_bio_wait_dec(struct o2hb_bio_wait_ctxt *wc, + unsigned int num) +{ + /* sadly atomic_sub_and_test() isn't available on all platforms. The + * good news is that the fast path only completes one at a time */ + while(num--) { + if (atomic_dec_and_test(&wc->wc_num_reqs)) { + BUG_ON(num > 0); + complete(&wc->wc_io_complete); + } + } +} + +static void o2hb_wait_on_io(struct o2hb_region *reg, + struct o2hb_bio_wait_ctxt *wc) +{ + struct address_space *mapping = reg->hr_bdev->bd_inode->i_mapping; + + blk_run_address_space(mapping); + + wait_for_completion(&wc->wc_io_complete); +} + +static int o2hb_bio_end_io(struct bio *bio, + unsigned int bytes_done, + int error) +{ + struct o2hb_bio_wait_ctxt *wc = bio->bi_private; + + if (error) + mlog(ML_ERROR, "IO Error %d\n", error); + + if (bio->bi_size) + return 1; + + o2hb_bio_wait_dec(wc, 1); + return 0; +} + +/* Setup a Bio to cover I/O against num_slots slots starting at + * start_slot. */ +static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg, + struct o2hb_bio_wait_ctxt *wc, + unsigned int start_slot, + unsigned int num_slots) +{ + int i, nr_vecs, len, first_page, last_page; + unsigned int vec_len, vec_start; + unsigned int bits = reg->hr_block_bits; + unsigned int spp = reg->hr_slots_per_page; + struct bio *bio; + struct page *page; + + nr_vecs = (num_slots + spp - 1) / spp; + + /* Testing has shown this allocation to take long enough under + * GFP_KERNEL that the local node can get fenced. It would be + * nicest if we could pre-allocate these bios and avoid this + * all together. */ + bio = bio_alloc(GFP_ATOMIC, nr_vecs); + if (!bio) { + mlog(ML_ERROR, "Could not alloc slots BIO!\n"); + bio = ERR_PTR(-ENOMEM); + goto bail; + } + + /* Must put everything in 512 byte sectors for the bio... */ + bio->bi_sector = (reg->hr_start_block + start_slot) << (bits - 9); + bio->bi_bdev = reg->hr_bdev; + bio->bi_private = wc; + bio->bi_end_io = o2hb_bio_end_io; + + first_page = start_slot / spp; + last_page = first_page + nr_vecs; + vec_start = (start_slot << bits) % PAGE_CACHE_SIZE; + for(i = first_page; i < last_page; i++) { + page = reg->hr_slot_data[i]; + + vec_len = PAGE_CACHE_SIZE; + /* last page might be short */ + if (((i + 1) * spp) > (start_slot + num_slots)) + vec_len = ((num_slots + start_slot) % spp) << bits; + vec_len -= vec_start; + + mlog(ML_HB_BIO, "page %d, vec_len = %u, vec_start = %u\n", + i, vec_len, vec_start); + + len = bio_add_page(bio, page, vec_len, vec_start); + if (len != vec_len) { + bio_put(bio); + bio = ERR_PTR(-EIO); + + mlog(ML_ERROR, "Error adding page to bio i = %d, " + "vec_len = %u, len = %d\n, start = %u\n", + i, vec_len, len, vec_start); + goto bail; + } + + vec_start = 0; + } + +bail: + return bio; +} + +/* + * Compute the maximum number of sectors the bdev can handle in one bio, + * as a power of two. + * + * Stolen from oracleasm, thanks Joel! + */ +static int compute_max_sectors(struct block_device *bdev) +{ + int max_pages, max_sectors, pow_two_sectors; + + struct request_queue *q; + + q = bdev_get_queue(bdev); + max_pages = q->max_sectors >> (PAGE_SHIFT - 9); + if (max_pages > BIO_MAX_PAGES) + max_pages = BIO_MAX_PAGES; + if (max_pages > q->max_phys_segments) + max_pages = q->max_phys_segments; + if (max_pages > q->max_hw_segments) + max_pages = q->max_hw_segments; + max_pages--; /* Handle I/Os that straddle a page */ + + max_sectors = max_pages << (PAGE_SHIFT - 9); + + /* Why is fls() 1-based???? */ + pow_two_sectors = 1 << (fls(max_sectors) - 1); + + return pow_two_sectors; +} + +static inline void o2hb_compute_request_limits(struct o2hb_region *reg, + unsigned int num_slots, + unsigned int *num_bios, + unsigned int *slots_per_bio) +{ + unsigned int max_sectors, io_sectors; + + max_sectors = compute_max_sectors(reg->hr_bdev); + + io_sectors = num_slots << (reg->hr_block_bits - 9); + + *num_bios = (io_sectors + max_sectors - 1) / max_sectors; + *slots_per_bio = max_sectors >> (reg->hr_block_bits - 9); + + mlog(ML_HB_BIO, "My io size is %u sectors for %u slots. This " + "device can handle %u sectors of I/O\n", io_sectors, num_slots, + max_sectors); + mlog(ML_HB_BIO, "Will need %u bios holding %u slots each\n", + *num_bios, *slots_per_bio); +} + +static int o2hb_read_slots(struct o2hb_region *reg, + unsigned int max_slots) +{ + unsigned int num_bios, slots_per_bio, start_slot, num_slots; + int i, status; + struct o2hb_bio_wait_ctxt wc; + struct bio **bios; + struct bio *bio; + + o2hb_compute_request_limits(reg, max_slots, &num_bios, &slots_per_bio); + + bios = kcalloc(num_bios, sizeof(struct bio *), GFP_KERNEL); + if (!bios) { + status = -ENOMEM; + mlog_errno(status); + return status; + } + + o2hb_bio_wait_init(&wc, num_bios); + + num_slots = slots_per_bio; + for(i = 0; i < num_bios; i++) { + start_slot = i * slots_per_bio; + + /* adjust num_slots at last bio */ + if (max_slots < (start_slot + num_slots)) + num_slots = max_slots - start_slot; + + bio = o2hb_setup_one_bio(reg, &wc, start_slot, num_slots); + if (IS_ERR(bio)) { + o2hb_bio_wait_dec(&wc, num_bios - i); + + status = PTR_ERR(bio); + mlog_errno(status); + goto bail_and_wait; + } + bios[i] = bio; + + submit_bio(READ, bio); + } + + status = 0; + +bail_and_wait: + o2hb_wait_on_io(reg, &wc); + + if (bios) { + for(i = 0; i < num_bios; i++) + if (bios[i]) + bio_put(bios[i]); + kfree(bios); + } + + return status; +} + +static int o2hb_issue_node_write(struct o2hb_region *reg, + struct bio **write_bio, + struct o2hb_bio_wait_ctxt *write_wc) +{ + int status; + unsigned int slot; + struct bio *bio; + + o2hb_bio_wait_init(write_wc, 1); + + slot = o2nm_this_node(); + + bio = o2hb_setup_one_bio(reg, write_wc, slot, 1); + if (IS_ERR(bio)) { + status = PTR_ERR(bio); + mlog_errno(status); + goto bail; + } + + submit_bio(WRITE, bio); + + *write_bio = bio; + status = 0; +bail: + return status; +} + +static u32 o2hb_compute_block_crc_le(struct o2hb_region *reg, + struct o2hb_disk_heartbeat_block *hb_block) +{ + __le32 old_cksum; + u32 ret; + + /* We want to compute the block crc with a 0 value in the + * hb_cksum field. Save it off here and replace after the + * crc. */ + old_cksum = hb_block->hb_cksum; + hb_block->hb_cksum = 0; + + ret = crc32_le(0, (unsigned char *) hb_block, reg->hr_block_bytes); + + hb_block->hb_cksum = old_cksum; + + return ret; +} + +static void o2hb_dump_slot(struct o2hb_disk_heartbeat_block *hb_block) +{ + mlog(ML_ERROR, "Dump slot information: seq = 0x%"MLFx64", node = %u, " + "cksum = 0x%x, generation 0x%"MLFx64"\n", + le64_to_cpu(hb_block->hb_seq), hb_block->hb_node, + le32_to_cpu(hb_block->hb_cksum), + le64_to_cpu(hb_block->hb_generation)); +} + +static int o2hb_verify_crc(struct o2hb_region *reg, + struct o2hb_disk_heartbeat_block *hb_block) +{ + u32 read, computed; + + read = le32_to_cpu(hb_block->hb_cksum); + computed = o2hb_compute_block_crc_le(reg, hb_block); + + return read == computed; +} + +/* We want to make sure that nobody is heartbeating on top of us -- + * this will help detect an invalid configuration. */ +static int o2hb_check_last_timestamp(struct o2hb_region *reg) +{ + int node_num, ret; + struct o2hb_disk_slot *slot; + struct o2hb_disk_heartbeat_block *hb_block; + + node_num = o2nm_this_node(); + + ret = 1; + slot = ®->hr_slots[node_num]; + /* Don't check on our 1st timestamp */ + if (slot->ds_last_time) { + hb_block = slot->ds_raw_block; + + if (le64_to_cpu(hb_block->hb_seq) != slot->ds_last_time) + ret = 0; + } + + return ret; +} + +static inline void o2hb_prepare_block(struct o2hb_region *reg, + u64 generation) +{ + int node_num; + u64 cputime; + struct o2hb_disk_slot *slot; + struct o2hb_disk_heartbeat_block *hb_block; + + node_num = o2nm_this_node(); + slot = ®->hr_slots[node_num]; + + hb_block = (struct o2hb_disk_heartbeat_block *)slot->ds_raw_block; + memset(hb_block, 0, reg->hr_block_bytes); + /* TODO: time stuff */ + cputime = CURRENT_TIME.tv_sec; + if (!cputime) + cputime = 1; + + hb_block->hb_seq = cpu_to_le64(cputime); + hb_block->hb_node = node_num; + hb_block->hb_generation = cpu_to_le64(generation); + + /* This step must always happen last! */ + hb_block->hb_cksum = cpu_to_le32(o2hb_compute_block_crc_le(reg, + hb_block)); + + mlog(ML_HB_BIO, "our node generation = 0x%"MLFx64", cksum = 0x%x\n", + cpu_to_le64(generation), le32_to_cpu(hb_block->hb_cksum)); +} + +static void o2hb_fire_callbacks(struct o2hb_callback *hbcall, + struct o2nm_node *node, + int idx) +{ + struct list_head *iter; + struct o2hb_callback_func *f; + + list_for_each(iter, &hbcall->list) { + f = list_entry(iter, struct o2hb_callback_func, hc_item); + mlog(ML_HEARTBEAT, "calling funcs %p\n", f); + (f->hc_func)(node, idx, f->hc_data); + } +} + +/* Will run the list in order until we process the passed event */ +static void o2hb_run_event_list(struct o2hb_node_event *queued_event) +{ + int empty; + struct o2hb_callback *hbcall; + struct o2hb_node_event *event; + + spin_lock(&o2hb_live_lock); + empty = list_empty(&queued_event->hn_item); + spin_unlock(&o2hb_live_lock); + if (empty) + return; + + /* Holding callback sem assures we don't alter the callback + * lists when doing this, and serializes ourselves with other + * processes wanting callbacks. */ + down_write(&o2hb_callback_sem); + + spin_lock(&o2hb_live_lock); + while (!list_empty(&o2hb_node_events) + && !list_empty(&queued_event->hn_item)) { + event = list_entry(o2hb_node_events.next, + struct o2hb_node_event, + hn_item); + list_del_init(&event->hn_item); + spin_unlock(&o2hb_live_lock); + + mlog(ML_HEARTBEAT, "Node %s event for %d\n", + event->hn_event_type == O2HB_NODE_UP_CB ? "UP" : "DOWN", + event->hn_node_num); + + hbcall = hbcall_from_type(event->hn_event_type); + + /* We should *never* have gotten on to the list with a + * bad type... This isn't something that we should try + * to recover from. */ + BUG_ON(IS_ERR(hbcall)); + + o2hb_fire_callbacks(hbcall, event->hn_node, event->hn_node_num); + + spin_lock(&o2hb_live_lock); + } + spin_unlock(&o2hb_live_lock); + + up_write(&o2hb_callback_sem); +} + +static void o2hb_queue_node_event(struct o2hb_node_event *event, + enum o2hb_callback_type type, + struct o2nm_node *node, + int node_num) +{ + assert_spin_locked(&o2hb_live_lock); + + event->hn_event_type = type; + event->hn_node = node; + event->hn_node_num = node_num; + + mlog(ML_HEARTBEAT, "Queue node %s event for node %d\n", + type == O2HB_NODE_UP_CB ? "UP" : "DOWN", node_num); + + list_add_tail(&event->hn_item, &o2hb_node_events); +} + +static void o2hb_shutdown_slot(struct o2hb_disk_slot *slot) +{ + struct o2hb_node_event event = + { .hn_item = LIST_HEAD_INIT(event.hn_item), }; + struct o2nm_node *node; + + node = o2nm_get_node_by_num(slot->ds_node_num); + if (!node) + return; + + spin_lock(&o2hb_live_lock); + if (!list_empty(&slot->ds_live_item)) { + mlog(ML_HEARTBEAT, "Shutdown, node %d leaves region\n", + slot->ds_node_num); + + list_del_init(&slot->ds_live_item); + + if (list_empty(&o2hb_live_slots[slot->ds_node_num])) { + clear_bit(slot->ds_node_num, o2hb_live_node_bitmap); + + o2hb_queue_node_event(&event, O2HB_NODE_DOWN_CB, node, + slot->ds_node_num); + } + } + spin_unlock(&o2hb_live_lock); + + o2hb_run_event_list(&event); + + o2nm_node_put(node); +} + +static int o2hb_check_slot(struct o2hb_region *reg, + struct o2hb_disk_slot *slot) +{ + int changed = 0, gen_changed = 0; + struct o2hb_node_event event = + { .hn_item = LIST_HEAD_INIT(event.hn_item), }; + struct o2nm_node *node; + struct o2hb_disk_heartbeat_block *hb_block = reg->hr_tmp_block; + u64 cputime; + + memcpy(hb_block, slot->ds_raw_block, reg->hr_block_bytes); + + /* Is this correct? Do we assume that the node doesn't exist + * if we're not configured for him? */ + node = o2nm_get_node_by_num(slot->ds_node_num); + if (!node) + return 0; + + if (!o2hb_verify_crc(reg, hb_block)) { + /* all paths from here will drop o2hb_live_lock for + * us. */ + spin_lock(&o2hb_live_lock); + + /* Don't print an error on the console in this case - + * a freshly formatted heartbeat area will not have a + * crc set on it. */ + if (list_empty(&slot->ds_live_item)) + goto out; + + /* The node is live but pushed out a bad crc. We + * consider it a transient miss but don't populate any + * other values as they may be junk. */ + mlog(ML_ERROR, "Node %d has written a bad crc to %s\n", + slot->ds_node_num, reg->hr_dev_name); + o2hb_dump_slot(hb_block); + + slot->ds_equal_samples++; + goto fire_callbacks; + } + + /* we don't care if these wrap.. the state transitions below + * clear at the right places */ + cputime = le64_to_cpu(hb_block->hb_seq); + if (slot->ds_last_time != cputime) + slot->ds_changed_samples++; + else + slot->ds_equal_samples++; + slot->ds_last_time = cputime; + + /* The node changed heartbeat generations. We assume this to + * mean it dropped off but came back before we timed out. We + * want to consider it down for the time being but don't want + * to lose any changed_samples state we might build up to + * considering it live again. */ + if (slot->ds_last_generation != le64_to_cpu(hb_block->hb_generation)) { + gen_changed = 1; + slot->ds_equal_samples = 0; + mlog(ML_HEARTBEAT, "Node %d changed generation (0x%"MLFx64" " + "to 0x%"MLFx64")\n", slot->ds_node_num, + slot->ds_last_generation, + le64_to_cpu(hb_block->hb_generation)); + } + + slot->ds_last_generation = le64_to_cpu(hb_block->hb_generation); + + mlog(ML_HEARTBEAT, "Slot %d gen 0x%"MLFx64" cksum 0x%x " + "seq %"MLFu64" last %"MLFu64" changed %u equal %u\n", + slot->ds_node_num, slot->ds_last_generation, + le32_to_cpu(hb_block->hb_cksum), le64_to_cpu(hb_block->hb_seq), + slot->ds_last_time, slot->ds_changed_samples, + slot->ds_equal_samples); + + spin_lock(&o2hb_live_lock); + +fire_callbacks: + /* dead nodes only come to life after some number of + * changes at any time during their dead time */ + if (list_empty(&slot->ds_live_item) && + slot->ds_changed_samples >= O2HB_LIVE_THRESHOLD) { + mlog(ML_HEARTBEAT, "Node %d (id 0x%"MLFx64") joined my " + "region\n", slot->ds_node_num, slot->ds_last_generation); + + /* first on the list generates a callback */ + if (list_empty(&o2hb_live_slots[slot->ds_node_num])) { + set_bit(slot->ds_node_num, o2hb_live_node_bitmap); + + o2hb_queue_node_event(&event, O2HB_NODE_UP_CB, node, + slot->ds_node_num); + + changed = 1; + } + + list_add_tail(&slot->ds_live_item, + &o2hb_live_slots[slot->ds_node_num]); + + slot->ds_equal_samples = 0; + goto out; + } + + /* if the list is dead, we're done.. */ + if (list_empty(&slot->ds_live_item)) + goto out; + + /* live nodes only go dead after enough consequtive missed + * samples.. reset the missed counter whenever we see + * activity */ + if (slot->ds_equal_samples >= o2hb_dead_threshold || gen_changed) { + mlog(ML_HEARTBEAT, "Node %d left my region\n", + slot->ds_node_num); + + /* last off the live_slot generates a callback */ + list_del_init(&slot->ds_live_item); + if (list_empty(&o2hb_live_slots[slot->ds_node_num])) { + clear_bit(slot->ds_node_num, o2hb_live_node_bitmap); + + o2hb_queue_node_event(&event, O2HB_NODE_DOWN_CB, node, + slot->ds_node_num); + + changed = 1; + } + + /* We don't clear this because the node is still + * actually writing new blocks. */ + if (!gen_changed) + slot->ds_changed_samples = 0; + goto out; + } + if (slot->ds_changed_samples) { + slot->ds_changed_samples = 0; + slot->ds_equal_samples = 0; + } +out: + spin_unlock(&o2hb_live_lock); + + o2hb_run_event_list(&event); + + o2nm_node_put(node); + return changed; +} + +/* This could be faster if we just implmented a find_last_bit, but I + * don't think the circumstances warrant it. */ +static int o2hb_highest_node(unsigned long *nodes, + int numbits) +{ + int highest, node; + + highest = numbits; + node = -1; + while ((node = find_next_bit(nodes, numbits, node + 1)) != -1) { + if (node >= numbits) + break; + + highest = node; + } + + return highest; +} + +static void o2hb_do_disk_heartbeat(struct o2hb_region *reg) +{ + int i, ret, highest_node, change = 0; + unsigned long configured_nodes[BITS_TO_LONGS(O2NM_MAX_NODES)]; + struct bio *write_bio; + struct o2hb_bio_wait_ctxt write_wc; + + if (o2nm_configured_node_map(configured_nodes, sizeof(configured_nodes))) + return; + + highest_node = o2hb_highest_node(configured_nodes, O2NM_MAX_NODES); + if (highest_node >= O2NM_MAX_NODES) { + mlog(ML_NOTICE, "ocfs2_heartbeat: no configured nodes found!\n"); + return; + } + + /* No sense in reading the slots of nodes that don't exist + * yet. Of course, if the node definitions have holes in them + * then we're reading an empty slot anyway... Consider this + * best-effort. */ + ret = o2hb_read_slots(reg, highest_node + 1); + if (ret < 0) { + mlog_errno(ret); + return; + } + + /* With an up to date view of the slots, we can check that no + * other node has been improperly configured to heartbeat in + * our slot. */ + if (!o2hb_check_last_timestamp(reg)) + mlog(ML_ERROR, "Device \"%s\": another node is heartbeating " + "in our slot!\n", reg->hr_dev_name); + + /* fill in the proper info for our next heartbeat */ + o2hb_prepare_block(reg, reg->hr_generation); + + /* And fire off the write. Note that we don't wait on this I/O + * until later. */ + ret = o2hb_issue_node_write(reg, &write_bio, &write_wc); + if (ret < 0) { + mlog_errno(ret); + return; + } + + i = -1; + while((i = find_next_bit(configured_nodes, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) { + + change |= o2hb_check_slot(reg, ®->hr_slots[i]); + } + + /* + * We have to be sure we've advertised ourselves on disk + * before we can go to steady state. This ensures that + * people we find in our steady state have seen us. + */ + o2hb_wait_on_io(reg, &write_wc); + bio_put(write_bio); + o2hb_arm_write_timeout(reg); + + /* let the person who launched us know when things are steady */ + if (!change && (atomic_read(®->hr_steady_iterations) != 0)) { + if (atomic_dec_and_test(®->hr_steady_iterations)) + wake_up(&o2hb_steady_queue); + } +} + +/* Subtract b from a, storing the result in a. a *must* have a larger + * value than b. */ +static void o2hb_tv_subtract(struct timeval *a, + struct timeval *b) +{ + /* just return 0 when a is after b */ + if (a->tv_sec < b->tv_sec || + (a->tv_sec == b->tv_sec && a->tv_usec < b->tv_usec)) { + a->tv_sec = 0; + a->tv_usec = 0; + return; + } + + a->tv_sec -= b->tv_sec; + a->tv_usec -= b->tv_usec; + while ( a->tv_usec < 0 ) { + a->tv_sec--; + a->tv_usec += 1000000; + } +} + +static unsigned int o2hb_elapsed_msecs(struct timeval *start, + struct timeval *end) +{ + struct timeval res = *end; + + o2hb_tv_subtract(&res, start); + + return res.tv_sec * 1000 + res.tv_usec / 1000; +} + +/* + * we ride the region ref that the region dir holds. before the region + * dir is removed and drops it ref it will wait to tear down this + * thread. + */ +static int o2hb_thread(void *data) +{ + int i, ret; + struct o2hb_region *reg = data; + struct bio *write_bio; + struct o2hb_bio_wait_ctxt write_wc; + struct timeval before_hb, after_hb; + unsigned int elapsed_msec; + + mlog(ML_HEARTBEAT|ML_KTHREAD, "hb thread running\n"); + + set_user_nice(current, -20); + + while (!kthread_should_stop() && !reg->hr_unclean_stop) { + /* We track the time spent inside + * o2hb_do_disk_heartbeat so that we avoid more then + * hr_timeout_ms between disk writes. On busy systems + * this should result in a heartbeat which is less + * likely to time itself out. */ + do_gettimeofday(&before_hb); + + o2hb_do_disk_heartbeat(reg); + + do_gettimeofday(&after_hb); + elapsed_msec = o2hb_elapsed_msecs(&before_hb, &after_hb); + + mlog(0, "start = %lu.%lu, end = %lu.%lu, msec = %u\n", + before_hb.tv_sec, before_hb.tv_usec, + after_hb.tv_sec, after_hb.tv_usec, elapsed_msec); + + if (elapsed_msec < reg->hr_timeout_ms) { + /* the kthread api has blocked signals for us so no + * need to record the return value. */ + msleep_interruptible(reg->hr_timeout_ms - elapsed_msec); + } + } + + o2hb_disarm_write_timeout(reg); + + /* unclean stop is only used in very bad situation */ + for(i = 0; !reg->hr_unclean_stop && i < reg->hr_blocks; i++) + o2hb_shutdown_slot(®->hr_slots[i]); + + /* Explicit down notification - avoid forcing the other nodes + * to timeout on this region when we could just as easily + * write a clear generation - thus indicating to them that + * this node has left this region. + * + * XXX: Should we skip this on unclean_stop? */ + o2hb_prepare_block(reg, 0); + ret = o2hb_issue_node_write(reg, &write_bio, &write_wc); + if (ret == 0) { + o2hb_wait_on_io(reg, &write_wc); + bio_put(write_bio); + } else { + mlog_errno(ret); + } + + mlog(ML_HEARTBEAT|ML_KTHREAD, "hb thread exiting\n"); + + return 0; +} + +void o2hb_init(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(o2hb_callbacks); i++) + INIT_LIST_HEAD(&o2hb_callbacks[i].list); + + for (i = 0; i < ARRAY_SIZE(o2hb_live_slots); i++) + INIT_LIST_HEAD(&o2hb_live_slots[i]); + + INIT_LIST_HEAD(&o2hb_node_events); + + memset(o2hb_live_node_bitmap, 0, sizeof(o2hb_live_node_bitmap)); +} + +/* if we're already in a callback then we're already serialized by the sem */ +static void o2hb_fill_node_map_from_callback(unsigned long *map, + unsigned bytes) +{ + BUG_ON(bytes < (BITS_TO_LONGS(O2NM_MAX_NODES) * sizeof(unsigned long))); + + memcpy(map, &o2hb_live_node_bitmap, bytes); +} + +/* + * get a map of all nodes that are heartbeating in any regions + */ +void o2hb_fill_node_map(unsigned long *map, unsigned bytes) +{ + /* callers want to serialize this map and callbacks so that they + * can trust that they don't miss nodes coming to the party */ + down_read(&o2hb_callback_sem); + spin_lock(&o2hb_live_lock); + o2hb_fill_node_map_from_callback(map, bytes); + spin_unlock(&o2hb_live_lock); + up_read(&o2hb_callback_sem); +} +EXPORT_SYMBOL_GPL(o2hb_fill_node_map); + +/* + * heartbeat configfs bits. The heartbeat set is a default set under + * the cluster set in nodemanager.c. + */ + +static struct o2hb_region *to_o2hb_region(struct config_item *item) +{ + return item ? container_of(item, struct o2hb_region, hr_item) : NULL; +} + +/* drop_item only drops its ref after killing the thread, nothing should + * be using the region anymore. this has to clean up any state that + * attributes might have built up. */ +static void o2hb_region_release(struct config_item *item) +{ + int i; + struct page *page; + struct o2hb_region *reg = to_o2hb_region(item); + + if (reg->hr_tmp_block) + kfree(reg->hr_tmp_block); + + if (reg->hr_slot_data) { + for (i = 0; i < reg->hr_num_pages; i++) { + page = reg->hr_slot_data[i]; + if (page) + __free_page(page); + } + kfree(reg->hr_slot_data); + } + + if (reg->hr_bdev) + blkdev_put(reg->hr_bdev); + + if (reg->hr_slots) + kfree(reg->hr_slots); + + spin_lock(&o2hb_live_lock); + list_del(®->hr_all_item); + spin_unlock(&o2hb_live_lock); + + kfree(reg); +} + +static int o2hb_read_block_input(struct o2hb_region *reg, + const char *page, + size_t count, + unsigned long *ret_bytes, + unsigned int *ret_bits) +{ + unsigned long bytes; + char *p = (char *)page; + + bytes = simple_strtoul(p, &p, 0); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + /* Heartbeat and fs min / max block sizes are the same. */ + if (bytes > 4096 || bytes < 512) + return -ERANGE; + if (hweight16(bytes) != 1) + return -EINVAL; + + if (ret_bytes) + *ret_bytes = bytes; + if (ret_bits) + *ret_bits = ffs(bytes) - 1; + + return 0; +} + +static ssize_t o2hb_region_block_bytes_read(struct o2hb_region *reg, + char *page) +{ + return sprintf(page, "%u\n", reg->hr_block_bytes); +} + +static ssize_t o2hb_region_block_bytes_write(struct o2hb_region *reg, + const char *page, + size_t count) +{ + int status; + unsigned long block_bytes; + unsigned int block_bits; + + if (reg->hr_bdev) + return -EINVAL; + + status = o2hb_read_block_input(reg, page, count, + &block_bytes, &block_bits); + if (status) + return status; + + reg->hr_block_bytes = (unsigned int)block_bytes; + reg->hr_block_bits = block_bits; + + return count; +} + +static ssize_t o2hb_region_start_block_read(struct o2hb_region *reg, + char *page) +{ + return sprintf(page, "%llu\n", reg->hr_start_block); +} + +static ssize_t o2hb_region_start_block_write(struct o2hb_region *reg, + const char *page, + size_t count) +{ + unsigned long long tmp; + char *p = (char *)page; + + if (reg->hr_bdev) + return -EINVAL; + + tmp = simple_strtoull(p, &p, 0); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + reg->hr_start_block = tmp; + + return count; +} + +static ssize_t o2hb_region_blocks_read(struct o2hb_region *reg, + char *page) +{ + return sprintf(page, "%d\n", reg->hr_blocks); +} + +static ssize_t o2hb_region_blocks_write(struct o2hb_region *reg, + const char *page, + size_t count) +{ + unsigned long tmp; + char *p = (char *)page; + + if (reg->hr_bdev) + return -EINVAL; + + tmp = simple_strtoul(p, &p, 0); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + if (tmp > O2NM_MAX_NODES || tmp == 0) + return -ERANGE; + + reg->hr_blocks = (unsigned int)tmp; + + return count; +} + +static ssize_t o2hb_region_dev_read(struct o2hb_region *reg, + char *page) +{ + unsigned int ret = 0; + + if (reg->hr_bdev) + ret = sprintf(page, "%s\n", reg->hr_dev_name); + + return ret; +} + +static void o2hb_init_region_params(struct o2hb_region *reg) +{ + reg->hr_slots_per_page = PAGE_CACHE_SIZE >> reg->hr_block_bits; + reg->hr_timeout_ms = O2HB_REGION_TIMEOUT_MS; + + mlog(ML_HEARTBEAT, "hr_start_block = %llu, hr_blocks = %u\n", + reg->hr_start_block, reg->hr_blocks); + mlog(ML_HEARTBEAT, "hr_block_bytes = %u, hr_block_bits = %u\n", + reg->hr_block_bytes, reg->hr_block_bits); + mlog(ML_HEARTBEAT, "hr_timeout_ms = %u\n", reg->hr_timeout_ms); + mlog(ML_HEARTBEAT, "dead threshold = %u\n", o2hb_dead_threshold); +} + +static int o2hb_map_slot_data(struct o2hb_region *reg) +{ + int i, j; + unsigned int last_slot; + unsigned int spp = reg->hr_slots_per_page; + struct page *page; + char *raw; + struct o2hb_disk_slot *slot; + + reg->hr_tmp_block = kmalloc(reg->hr_block_bytes, GFP_KERNEL); + if (reg->hr_tmp_block == NULL) { + mlog_errno(-ENOMEM); + return -ENOMEM; + } + + reg->hr_slots = kcalloc(reg->hr_blocks, + sizeof(struct o2hb_disk_slot), GFP_KERNEL); + if (reg->hr_slots == NULL) { + mlog_errno(-ENOMEM); + return -ENOMEM; + } + + for(i = 0; i < reg->hr_blocks; i++) { + slot = ®->hr_slots[i]; + slot->ds_node_num = i; + INIT_LIST_HEAD(&slot->ds_live_item); + slot->ds_raw_block = NULL; + } + + reg->hr_num_pages = (reg->hr_blocks + spp - 1) / spp; + mlog(ML_HEARTBEAT, "Going to require %u pages to cover %u blocks " + "at %u blocks per page\n", + reg->hr_num_pages, reg->hr_blocks, spp); + + reg->hr_slot_data = kcalloc(reg->hr_num_pages, sizeof(struct page *), + GFP_KERNEL); + if (!reg->hr_slot_data) { + mlog_errno(-ENOMEM); + return -ENOMEM; + } + + for(i = 0; i < reg->hr_num_pages; i++) { + page = alloc_page(GFP_KERNEL); + if (!page) { + mlog_errno(-ENOMEM); + return -ENOMEM; + } + + reg->hr_slot_data[i] = page; + + last_slot = i * spp; + raw = page_address(page); + for (j = 0; + (j < spp) && ((j + last_slot) < reg->hr_blocks); + j++) { + BUG_ON((j + last_slot) >= reg->hr_blocks); + + slot = ®->hr_slots[j + last_slot]; + slot->ds_raw_block = + (struct o2hb_disk_heartbeat_block *) raw; + + raw += reg->hr_block_bytes; + } + } + + return 0; +} + +/* Read in all the slots available and populate the tracking + * structures so that we can start with a baseline idea of what's + * there. */ +static int o2hb_populate_slot_data(struct o2hb_region *reg) +{ + int ret, i; + struct o2hb_disk_slot *slot; + struct o2hb_disk_heartbeat_block *hb_block; + + mlog_entry_void(); + + ret = o2hb_read_slots(reg, reg->hr_blocks); + if (ret) { + mlog_errno(ret); + goto out; + } + + /* We only want to get an idea of the values initially in each + * slot, so we do no verification - o2hb_check_slot will + * actually determine if each configured slot is valid and + * whether any values have changed. */ + for(i = 0; i < reg->hr_blocks; i++) { + slot = ®->hr_slots[i]; + hb_block = (struct o2hb_disk_heartbeat_block *) slot->ds_raw_block; + + /* Only fill the values that o2hb_check_slot uses to + * determine changing slots */ + slot->ds_last_time = le64_to_cpu(hb_block->hb_seq); + slot->ds_last_generation = le64_to_cpu(hb_block->hb_generation); + } + +out: + mlog_exit(ret); + return ret; +} + +/* this is acting as commit; we set up all of hr_bdev and hr_task or nothing */ +static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, + const char *page, + size_t count) +{ + long fd; + int sectsize; + char *p = (char *)page; + struct file *filp = NULL; + struct inode *inode = NULL; + ssize_t ret = -EINVAL; + + if (reg->hr_bdev) + goto out; + + /* We can't heartbeat without having had our node number + * configured yet. */ + if (o2nm_this_node() == O2NM_MAX_NODES) + goto out; + + fd = simple_strtol(p, &p, 0); + if (!p || (*p && (*p != '\n'))) + goto out; + + if (fd < 0 || fd >= INT_MAX) + goto out; + + filp = fget(fd); + if (filp == NULL) + goto out; + + if (reg->hr_blocks == 0 || reg->hr_start_block == 0 || + reg->hr_block_bytes == 0) + goto out; + + inode = igrab(filp->f_mapping->host); + if (inode == NULL) + goto out; + + if (!S_ISBLK(inode->i_mode)) + goto out; + + reg->hr_bdev = I_BDEV(filp->f_mapping->host); + ret = blkdev_get(reg->hr_bdev, FMODE_WRITE | FMODE_READ, 0); + if (ret) { + reg->hr_bdev = NULL; + goto out; + } + inode = NULL; + + bdevname(reg->hr_bdev, reg->hr_dev_name); + + sectsize = bdev_hardsect_size(reg->hr_bdev); + if (sectsize != reg->hr_block_bytes) { + mlog(ML_ERROR, + "blocksize %u incorrect for device, expected %d", + reg->hr_block_bytes, sectsize); + ret = -EINVAL; + goto out; + } + + o2hb_init_region_params(reg); + + /* Generation of zero is invalid */ + do { + get_random_bytes(®->hr_generation, + sizeof(reg->hr_generation)); + } while (reg->hr_generation == 0); + + ret = o2hb_map_slot_data(reg); + if (ret) { + mlog_errno(ret); + goto out; + } + + ret = o2hb_populate_slot_data(reg); + if (ret) { + mlog_errno(ret); + goto out; + } + + INIT_WORK(®->hr_write_timeout_work, o2hb_write_timeout, reg); + + /* + * A node is considered live after it has beat LIVE_THRESHOLD + * times. We're not steady until we've given them a chance + * _after_ our first read. + */ + atomic_set(®->hr_steady_iterations, O2HB_LIVE_THRESHOLD + 1); + + reg->hr_task = kthread_run(o2hb_thread, reg, "o2hb-%s", + reg->hr_item.ci_name); + if (IS_ERR(reg->hr_task)) { + ret = PTR_ERR(reg->hr_task); + mlog_errno(ret); + reg->hr_task = NULL; + goto out; + } + + ret = wait_event_interruptible(o2hb_steady_queue, + atomic_read(®->hr_steady_iterations) == 0); + if (ret) { + kthread_stop(reg->hr_task); + reg->hr_task = NULL; + goto out; + } + + ret = count; +out: + if (filp) + fput(filp); + if (inode) + iput(inode); + if (ret < 0) { + if (reg->hr_bdev) { + blkdev_put(reg->hr_bdev); + reg->hr_bdev = NULL; + } + } + return ret; +} + +struct o2hb_region_attribute { + struct configfs_attribute attr; + ssize_t (*show)(struct o2hb_region *, char *); + ssize_t (*store)(struct o2hb_region *, const char *, size_t); +}; + +static struct o2hb_region_attribute o2hb_region_attr_block_bytes = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "block_bytes", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2hb_region_block_bytes_read, + .store = o2hb_region_block_bytes_write, +}; + +static struct o2hb_region_attribute o2hb_region_attr_start_block = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "start_block", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2hb_region_start_block_read, + .store = o2hb_region_start_block_write, +}; + +static struct o2hb_region_attribute o2hb_region_attr_blocks = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "blocks", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2hb_region_blocks_read, + .store = o2hb_region_blocks_write, +}; + +static struct o2hb_region_attribute o2hb_region_attr_dev = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "dev", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2hb_region_dev_read, + .store = o2hb_region_dev_write, +}; + +static struct configfs_attribute *o2hb_region_attrs[] = { + &o2hb_region_attr_block_bytes.attr, + &o2hb_region_attr_start_block.attr, + &o2hb_region_attr_blocks.attr, + &o2hb_region_attr_dev.attr, + NULL, +}; + +static ssize_t o2hb_region_show(struct config_item *item, + struct configfs_attribute *attr, + char *page) +{ + struct o2hb_region *reg = to_o2hb_region(item); + struct o2hb_region_attribute *o2hb_region_attr = + container_of(attr, struct o2hb_region_attribute, attr); + ssize_t ret = 0; + + if (o2hb_region_attr->show) + ret = o2hb_region_attr->show(reg, page); + return ret; +} + +static ssize_t o2hb_region_store(struct config_item *item, + struct configfs_attribute *attr, + const char *page, size_t count) +{ + struct o2hb_region *reg = to_o2hb_region(item); + struct o2hb_region_attribute *o2hb_region_attr = + container_of(attr, struct o2hb_region_attribute, attr); + ssize_t ret = -EINVAL; + + if (o2hb_region_attr->store) + ret = o2hb_region_attr->store(reg, page, count); + return ret; +} + +static struct configfs_item_operations o2hb_region_item_ops = { + .release = o2hb_region_release, + .show_attribute = o2hb_region_show, + .store_attribute = o2hb_region_store, +}; + +static struct config_item_type o2hb_region_type = { + .ct_item_ops = &o2hb_region_item_ops, + .ct_attrs = o2hb_region_attrs, + .ct_owner = THIS_MODULE, +}; + +/* heartbeat set */ + +struct o2hb_heartbeat_group { + struct config_group hs_group; + /* some stuff? */ +}; + +static struct o2hb_heartbeat_group *to_o2hb_heartbeat_group(struct config_group *group) +{ + return group ? + container_of(group, struct o2hb_heartbeat_group, hs_group) + : NULL; +} + +static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *group, + const char *name) +{ + struct o2hb_region *reg = NULL; + struct config_item *ret = NULL; + + reg = kcalloc(1, sizeof(struct o2hb_region), GFP_KERNEL); + if (reg == NULL) + goto out; /* ENOMEM */ + + config_item_init_type_name(®->hr_item, name, &o2hb_region_type); + + ret = ®->hr_item; + + spin_lock(&o2hb_live_lock); + list_add_tail(®->hr_all_item, &o2hb_all_regions); + spin_unlock(&o2hb_live_lock); +out: + if (ret == NULL) + kfree(reg); + + return ret; +} + +static void o2hb_heartbeat_group_drop_item(struct config_group *group, + struct config_item *item) +{ + struct o2hb_region *reg = to_o2hb_region(item); + + /* stop the thread when the user removes the region dir */ + if (reg->hr_task) { + kthread_stop(reg->hr_task); + reg->hr_task = NULL; + } + + config_item_put(item); +} + +struct o2hb_heartbeat_group_attribute { + struct configfs_attribute attr; + ssize_t (*show)(struct o2hb_heartbeat_group *, char *); + ssize_t (*store)(struct o2hb_heartbeat_group *, const char *, size_t); +}; + +static ssize_t o2hb_heartbeat_group_show(struct config_item *item, + struct configfs_attribute *attr, + char *page) +{ + struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item)); + struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr = + container_of(attr, struct o2hb_heartbeat_group_attribute, attr); + ssize_t ret = 0; + + if (o2hb_heartbeat_group_attr->show) + ret = o2hb_heartbeat_group_attr->show(reg, page); + return ret; +} + +static ssize_t o2hb_heartbeat_group_store(struct config_item *item, + struct configfs_attribute *attr, + const char *page, size_t count) +{ + struct o2hb_heartbeat_group *reg = to_o2hb_heartbeat_group(to_config_group(item)); + struct o2hb_heartbeat_group_attribute *o2hb_heartbeat_group_attr = + container_of(attr, struct o2hb_heartbeat_group_attribute, attr); + ssize_t ret = -EINVAL; + + if (o2hb_heartbeat_group_attr->store) + ret = o2hb_heartbeat_group_attr->store(reg, page, count); + return ret; +} + +static ssize_t o2hb_heartbeat_group_threshold_show(struct o2hb_heartbeat_group *group, + char *page) +{ + return sprintf(page, "%u\n", o2hb_dead_threshold); +} + +static ssize_t o2hb_heartbeat_group_threshold_store(struct o2hb_heartbeat_group *group, + const char *page, + size_t count) +{ + unsigned long tmp; + char *p = (char *)page; + + tmp = simple_strtoul(p, &p, 10); + if (!p || (*p && (*p != '\n'))) + return -EINVAL; + + /* this will validate ranges for us. */ + o2hb_dead_threshold_set((unsigned int) tmp); + + return count; +} + +static struct o2hb_heartbeat_group_attribute o2hb_heartbeat_group_attr_threshold = { + .attr = { .ca_owner = THIS_MODULE, + .ca_name = "dead_threshold", + .ca_mode = S_IRUGO | S_IWUSR }, + .show = o2hb_heartbeat_group_threshold_show, + .store = o2hb_heartbeat_group_threshold_store, +}; + +static struct configfs_attribute *o2hb_heartbeat_group_attrs[] = { + &o2hb_heartbeat_group_attr_threshold.attr, + NULL, +}; + +static struct configfs_item_operations o2hb_hearbeat_group_item_ops = { + .show_attribute = o2hb_heartbeat_group_show, + .store_attribute = o2hb_heartbeat_group_store, +}; + +static struct configfs_group_operations o2hb_heartbeat_group_group_ops = { + .make_item = o2hb_heartbeat_group_make_item, + .drop_item = o2hb_heartbeat_group_drop_item, +}; + +static struct config_item_type o2hb_heartbeat_group_type = { + .ct_group_ops = &o2hb_heartbeat_group_group_ops, + .ct_item_ops = &o2hb_hearbeat_group_item_ops, + .ct_attrs = o2hb_heartbeat_group_attrs, + .ct_owner = THIS_MODULE, +}; + +/* this is just here to avoid touching group in heartbeat.h which the + * entire damn world #includes */ +struct config_group *o2hb_alloc_hb_set(void) +{ + struct o2hb_heartbeat_group *hs = NULL; + struct config_group *ret = NULL; + + hs = kcalloc(1, sizeof(struct o2hb_heartbeat_group), GFP_KERNEL); + if (hs == NULL) + goto out; + + config_group_init_type_name(&hs->hs_group, "heartbeat", + &o2hb_heartbeat_group_type); + + ret = &hs->hs_group; +out: + if (ret == NULL) + kfree(hs); + return ret; +} + +void o2hb_free_hb_set(struct config_group *group) +{ + struct o2hb_heartbeat_group *hs = to_o2hb_heartbeat_group(group); + kfree(hs); +} + +/* hb callback registration and issueing */ + +static struct o2hb_callback *hbcall_from_type(enum o2hb_callback_type type) +{ + if (type == O2HB_NUM_CB) + return ERR_PTR(-EINVAL); + + return &o2hb_callbacks[type]; +} + +void o2hb_setup_callback(struct o2hb_callback_func *hc, + enum o2hb_callback_type type, + o2hb_cb_func *func, + void *data, + int priority) +{ + INIT_LIST_HEAD(&hc->hc_item); + hc->hc_func = func; + hc->hc_data = data; + hc->hc_priority = priority; + hc->hc_type = type; + hc->hc_magic = O2HB_CB_MAGIC; +} +EXPORT_SYMBOL_GPL(o2hb_setup_callback); + +int o2hb_register_callback(struct o2hb_callback_func *hc) +{ + struct o2hb_callback_func *tmp; + struct list_head *iter; + struct o2hb_callback *hbcall; + int ret; + + BUG_ON(hc->hc_magic != O2HB_CB_MAGIC); + BUG_ON(!list_empty(&hc->hc_item)); + + hbcall = hbcall_from_type(hc->hc_type); + if (IS_ERR(hbcall)) { + ret = PTR_ERR(hbcall); + goto out; + } + + down_write(&o2hb_callback_sem); + + list_for_each(iter, &hbcall->list) { + tmp = list_entry(iter, struct o2hb_callback_func, hc_item); + if (hc->hc_priority < tmp->hc_priority) { + list_add_tail(&hc->hc_item, iter); + break; + } + } + if (list_empty(&hc->hc_item)) + list_add_tail(&hc->hc_item, &hbcall->list); + + up_write(&o2hb_callback_sem); + ret = 0; +out: + mlog(ML_HEARTBEAT, "returning %d on behalf of %p for funcs %p\n", + ret, __builtin_return_address(0), hc); + return ret; +} +EXPORT_SYMBOL_GPL(o2hb_register_callback); + +int o2hb_unregister_callback(struct o2hb_callback_func *hc) +{ + BUG_ON(hc->hc_magic != O2HB_CB_MAGIC); + + mlog(ML_HEARTBEAT, "on behalf of %p for funcs %p\n", + __builtin_return_address(0), hc); + + if (list_empty(&hc->hc_item)) + return 0; + + down_write(&o2hb_callback_sem); + + list_del_init(&hc->hc_item); + + up_write(&o2hb_callback_sem); + + return 0; +} +EXPORT_SYMBOL_GPL(o2hb_unregister_callback); + +int o2hb_check_node_heartbeating(u8 node_num) +{ + unsigned long testing_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + + o2hb_fill_node_map(testing_map, sizeof(testing_map)); + if (!test_bit(node_num, testing_map)) { + mlog(ML_HEARTBEAT, + "node (%u) does not have heartbeating enabled.\n", + node_num); + return 0; + } + + return 1; +} +EXPORT_SYMBOL_GPL(o2hb_check_node_heartbeating); + +int o2hb_check_node_heartbeating_from_callback(u8 node_num) +{ + unsigned long testing_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + + o2hb_fill_node_map_from_callback(testing_map, sizeof(testing_map)); + if (!test_bit(node_num, testing_map)) { + mlog(ML_HEARTBEAT, + "node (%u) does not have heartbeating enabled.\n", + node_num); + return 0; + } + + return 1; +} +EXPORT_SYMBOL_GPL(o2hb_check_node_heartbeating_from_callback); + +/* Makes sure our local node is configured with a node number, and is + * heartbeating. */ +int o2hb_check_local_node_heartbeating(void) +{ + u8 node_num; + + /* if this node was set then we have networking */ + node_num = o2nm_this_node(); + if (node_num == O2NM_MAX_NODES) { + mlog(ML_HEARTBEAT, "this node has not been configured.\n"); + return 0; + } + + return o2hb_check_node_heartbeating(node_num); +} +EXPORT_SYMBOL_GPL(o2hb_check_local_node_heartbeating); + +/* + * this is just a hack until we get the plumbing which flips file systems + * read only and drops the hb ref instead of killing the node dead. + */ +void o2hb_stop_all_regions(void) +{ + struct o2hb_region *reg; + + mlog(ML_ERROR, "stopping heartbeat on all active regions.\n"); + + spin_lock(&o2hb_live_lock); + + list_for_each_entry(reg, &o2hb_all_regions, hr_all_item) + reg->hr_unclean_stop = 1; + + spin_unlock(&o2hb_live_lock); +} +EXPORT_SYMBOL_GPL(o2hb_stop_all_regions); diff --git a/fs/ocfs2/cluster/heartbeat.h b/fs/ocfs2/cluster/heartbeat.h new file mode 100644 index 0000000..cac6223 --- /dev/null +++ b/fs/ocfs2/cluster/heartbeat.h @@ -0,0 +1,82 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * heartbeat.h + * + * Function prototypes + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef O2CLUSTER_HEARTBEAT_H +#define O2CLUSTER_HEARTBEAT_H + +#include "ocfs2_heartbeat.h" + +#define O2HB_REGION_TIMEOUT_MS 2000 + +/* number of changes to be seen as live */ +#define O2HB_LIVE_THRESHOLD 2 +/* number of equal samples to be seen as dead */ +extern unsigned int o2hb_dead_threshold; +#define O2HB_DEFAULT_DEAD_THRESHOLD 7 +/* Otherwise MAX_WRITE_TIMEOUT will be zero... */ +#define O2HB_MIN_DEAD_THRESHOLD 2 +#define O2HB_MAX_WRITE_TIMEOUT_MS (O2HB_REGION_TIMEOUT_MS * (o2hb_dead_threshold - 1)) + +#define O2HB_CB_MAGIC 0x51d1e4ec + +/* callback stuff */ +enum o2hb_callback_type { + O2HB_NODE_DOWN_CB = 0, + O2HB_NODE_UP_CB, + O2HB_NUM_CB +}; + +struct o2nm_node; +typedef void (o2hb_cb_func)(struct o2nm_node *, int, void *); + +struct o2hb_callback_func { + u32 hc_magic; + struct list_head hc_item; + o2hb_cb_func *hc_func; + void *hc_data; + int hc_priority; + enum o2hb_callback_type hc_type; +}; + +struct config_group *o2hb_alloc_hb_set(void); +void o2hb_free_hb_set(struct config_group *group); + +void o2hb_setup_callback(struct o2hb_callback_func *hc, + enum o2hb_callback_type type, + o2hb_cb_func *func, + void *data, + int priority); +int o2hb_register_callback(struct o2hb_callback_func *hc); +int o2hb_unregister_callback(struct o2hb_callback_func *hc); +void o2hb_fill_node_map(unsigned long *map, + unsigned bytes); +void o2hb_init(void); +int o2hb_check_node_heartbeating(u8 node_num); +int o2hb_check_node_heartbeating_from_callback(u8 node_num); +int o2hb_check_local_node_heartbeating(void); +void o2hb_stop_all_regions(void); + +#endif /* O2CLUSTER_HEARTBEAT_H */ diff --git a/fs/ocfs2/cluster/ocfs2_heartbeat.h b/fs/ocfs2/cluster/ocfs2_heartbeat.h new file mode 100644 index 0000000..9409606 --- /dev/null +++ b/fs/ocfs2/cluster/ocfs2_heartbeat.h @@ -0,0 +1,37 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ocfs2_heartbeat.h + * + * On-disk structures for ocfs2_heartbeat + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef _OCFS2_HEARTBEAT_H +#define _OCFS2_HEARTBEAT_H + +struct o2hb_disk_heartbeat_block { + __le64 hb_seq; + __u8 hb_node; + __u8 hb_pad1[3]; + __le32 hb_cksum; + __le64 hb_generation; +}; + +#endif /* _OCFS2_HEARTBEAT_H */ -- cgit v1.1 From 98211489d4147e41b11703e4245846d60b3acce4 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 15 Dec 2005 14:31:23 -0800 Subject: [PATCH] OCFS2: The Second Oracle Cluster Filesystem Node messaging via tcp. Used by the dlm and the file system for point to point communication between nodes. Signed-off-by: Mark Fasheh Signed-off-by: Kurt Hackel --- fs/ocfs2/cluster/quorum.c | 315 +++++++ fs/ocfs2/cluster/quorum.h | 36 + fs/ocfs2/cluster/sys.c | 124 +++ fs/ocfs2/cluster/sys.h | 33 + fs/ocfs2/cluster/tcp.c | 1829 +++++++++++++++++++++++++++++++++++++++ fs/ocfs2/cluster/tcp.h | 113 +++ fs/ocfs2/cluster/tcp_internal.h | 174 ++++ 7 files changed, 2624 insertions(+) create mode 100644 fs/ocfs2/cluster/quorum.c create mode 100644 fs/ocfs2/cluster/quorum.h create mode 100644 fs/ocfs2/cluster/sys.c create mode 100644 fs/ocfs2/cluster/sys.h create mode 100644 fs/ocfs2/cluster/tcp.c create mode 100644 fs/ocfs2/cluster/tcp.h create mode 100644 fs/ocfs2/cluster/tcp_internal.h diff --git a/fs/ocfs2/cluster/quorum.c b/fs/ocfs2/cluster/quorum.c new file mode 100644 index 0000000..7bba98f --- /dev/null +++ b/fs/ocfs2/cluster/quorum.c @@ -0,0 +1,315 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +/* This quorum hack is only here until we transition to some more rational + * approach that is driven from userspace. Honest. No foolin'. + * + * Imagine two nodes lose network connectivity to each other but they're still + * up and operating in every other way. Presumably a network timeout indicates + * that a node is broken and should be recovered. They can't both recover each + * other and both carry on without serialising their access to the file system. + * They need to decide who is authoritative. Now extend that problem to + * arbitrary groups of nodes losing connectivity between each other. + * + * So we declare that a node which has given up on connecting to a majority + * of nodes who are still heartbeating will fence itself. + * + * There are huge opportunities for races here. After we give up on a node's + * connection we need to wait long enough to give heartbeat an opportunity + * to declare the node as truly dead. We also need to be careful with the + * race between when we see a node start heartbeating and when we connect + * to it. + * + * So nodes that are in this transtion put a hold on the quorum decision + * with a counter. As they fall out of this transition they drop the count + * and if they're the last, they fire off the decision. + */ +#include +#include +#include + +#include "heartbeat.h" +#include "nodemanager.h" +#define MLOG_MASK_PREFIX ML_QUORUM +#include "masklog.h" +#include "quorum.h" + +static struct o2quo_state { + spinlock_t qs_lock; + struct work_struct qs_work; + int qs_pending; + int qs_heartbeating; + unsigned long qs_hb_bm[BITS_TO_LONGS(O2NM_MAX_NODES)]; + int qs_connected; + unsigned long qs_conn_bm[BITS_TO_LONGS(O2NM_MAX_NODES)]; + int qs_holds; + unsigned long qs_hold_bm[BITS_TO_LONGS(O2NM_MAX_NODES)]; +} o2quo_state; + +/* this is horribly heavy-handed. It should instead flip the file + * system RO and call some userspace script. */ +static void o2quo_fence_self(void) +{ + /* panic spins with interrupts enabled. with preempt + * threads can still schedule, etc, etc */ + o2hb_stop_all_regions(); + panic("ocfs2 is very sorry to be fencing this system by panicing\n"); +} + +/* Indicate that a timeout occured on a hearbeat region write. The + * other nodes in the cluster may consider us dead at that time so we + * want to "fence" ourselves so that we don't scribble on the disk + * after they think they've recovered us. This can't solve all + * problems related to writeout after recovery but this hack can at + * least close some of those gaps. When we have real fencing, this can + * go away as our node would be fenced externally before other nodes + * begin recovery. */ +void o2quo_disk_timeout(void) +{ + o2quo_fence_self(); +} + +static void o2quo_make_decision(void *arg) +{ + int quorum; + int lowest_hb, lowest_reachable = 0, fence = 0; + struct o2quo_state *qs = &o2quo_state; + + spin_lock(&qs->qs_lock); + + lowest_hb = find_first_bit(qs->qs_hb_bm, O2NM_MAX_NODES); + if (lowest_hb != O2NM_MAX_NODES) + lowest_reachable = test_bit(lowest_hb, qs->qs_conn_bm); + + mlog(0, "heartbeating: %d, connected: %d, " + "lowest: %d (%sreachable)\n", qs->qs_heartbeating, + qs->qs_connected, lowest_hb, lowest_reachable ? "" : "un"); + + if (!test_bit(o2nm_this_node(), qs->qs_hb_bm) || + qs->qs_heartbeating == 1) + goto out; + + if (qs->qs_heartbeating & 1) { + /* the odd numbered cluster case is straight forward -- + * if we can't talk to the majority we're hosed */ + quorum = (qs->qs_heartbeating + 1)/2; + if (qs->qs_connected < quorum) { + mlog(ML_ERROR, "fencing this node because it is " + "only connected to %u nodes and %u is needed " + "to make a quorum out of %u heartbeating nodes\n", + qs->qs_connected, quorum, + qs->qs_heartbeating); + fence = 1; + } + } else { + /* the even numbered cluster adds the possibility of each half + * of the cluster being able to talk amongst themselves.. in + * that case we're hosed if we can't talk to the group that has + * the lowest numbered node */ + quorum = qs->qs_heartbeating / 2; + if (qs->qs_connected < quorum) { + mlog(ML_ERROR, "fencing this node because it is " + "only connected to %u nodes and %u is needed " + "to make a quorum out of %u heartbeating nodes\n", + qs->qs_connected, quorum, + qs->qs_heartbeating); + fence = 1; + } + else if ((qs->qs_connected == quorum) && + !lowest_reachable) { + mlog(ML_ERROR, "fencing this node because it is " + "connected to a half-quorum of %u out of %u " + "nodes which doesn't include the lowest active " + "node %u\n", quorum, qs->qs_heartbeating, + lowest_hb); + fence = 1; + } + } + +out: + spin_unlock(&qs->qs_lock); + if (fence) + o2quo_fence_self(); +} + +static void o2quo_set_hold(struct o2quo_state *qs, u8 node) +{ + assert_spin_locked(&qs->qs_lock); + + if (!test_and_set_bit(node, qs->qs_hold_bm)) { + qs->qs_holds++; + mlog_bug_on_msg(qs->qs_holds == O2NM_MAX_NODES, + "node %u\n", node); + mlog(0, "node %u, %d total\n", node, qs->qs_holds); + } +} + +static void o2quo_clear_hold(struct o2quo_state *qs, u8 node) +{ + assert_spin_locked(&qs->qs_lock); + + if (test_and_clear_bit(node, qs->qs_hold_bm)) { + mlog(0, "node %u, %d total\n", node, qs->qs_holds - 1); + if (--qs->qs_holds == 0) { + if (qs->qs_pending) { + qs->qs_pending = 0; + schedule_work(&qs->qs_work); + } + } + mlog_bug_on_msg(qs->qs_holds < 0, "node %u, holds %d\n", + node, qs->qs_holds); + } +} + +/* as a node comes up we delay the quorum decision until we know the fate of + * the connection. the hold will be droped in conn_up or hb_down. it might be + * perpetuated by con_err until hb_down. if we already have a conn, we might + * be dropping a hold that conn_up got. */ +void o2quo_hb_up(u8 node) +{ + struct o2quo_state *qs = &o2quo_state; + + spin_lock(&qs->qs_lock); + + qs->qs_heartbeating++; + mlog_bug_on_msg(qs->qs_heartbeating == O2NM_MAX_NODES, + "node %u\n", node); + mlog_bug_on_msg(test_bit(node, qs->qs_hb_bm), "node %u\n", node); + set_bit(node, qs->qs_hb_bm); + + mlog(0, "node %u, %d total\n", node, qs->qs_heartbeating); + + if (!test_bit(node, qs->qs_conn_bm)) + o2quo_set_hold(qs, node); + else + o2quo_clear_hold(qs, node); + + spin_unlock(&qs->qs_lock); +} + +/* hb going down releases any holds we might have had due to this node from + * conn_up, conn_err, or hb_up */ +void o2quo_hb_down(u8 node) +{ + struct o2quo_state *qs = &o2quo_state; + + spin_lock(&qs->qs_lock); + + qs->qs_heartbeating--; + mlog_bug_on_msg(qs->qs_heartbeating < 0, + "node %u, %d heartbeating\n", + node, qs->qs_heartbeating); + mlog_bug_on_msg(!test_bit(node, qs->qs_hb_bm), "node %u\n", node); + clear_bit(node, qs->qs_hb_bm); + + mlog(0, "node %u, %d total\n", node, qs->qs_heartbeating); + + o2quo_clear_hold(qs, node); + + spin_unlock(&qs->qs_lock); +} + +/* this tells us that we've decided that the node is still heartbeating + * even though we've lost it's conn. it must only be called after conn_err + * and indicates that we must now make a quorum decision in the future, + * though we might be doing so after waiting for holds to drain. Here + * we'll be dropping the hold from conn_err. */ +void o2quo_hb_still_up(u8 node) +{ + struct o2quo_state *qs = &o2quo_state; + + spin_lock(&qs->qs_lock); + + mlog(0, "node %u\n", node); + + qs->qs_pending = 1; + o2quo_clear_hold(qs, node); + + spin_unlock(&qs->qs_lock); +} + +/* This is analagous to hb_up. as a node's connection comes up we delay the + * quorum decision until we see it heartbeating. the hold will be droped in + * hb_up or hb_down. it might be perpetuated by con_err until hb_down. if + * it's already heartbeating we we might be dropping a hold that conn_up got. + * */ +void o2quo_conn_up(u8 node) +{ + struct o2quo_state *qs = &o2quo_state; + + spin_lock(&qs->qs_lock); + + qs->qs_connected++; + mlog_bug_on_msg(qs->qs_connected == O2NM_MAX_NODES, + "node %u\n", node); + mlog_bug_on_msg(test_bit(node, qs->qs_conn_bm), "node %u\n", node); + set_bit(node, qs->qs_conn_bm); + + mlog(0, "node %u, %d total\n", node, qs->qs_connected); + + if (!test_bit(node, qs->qs_hb_bm)) + o2quo_set_hold(qs, node); + else + o2quo_clear_hold(qs, node); + + spin_unlock(&qs->qs_lock); +} + +/* we've decided that we won't ever be connecting to the node again. if it's + * still heartbeating we grab a hold that will delay decisions until either the + * node stops heartbeating from hb_down or the caller decides that the node is + * still up and calls still_up */ +void o2quo_conn_err(u8 node) +{ + struct o2quo_state *qs = &o2quo_state; + + spin_lock(&qs->qs_lock); + + if (test_bit(node, qs->qs_conn_bm)) { + qs->qs_connected--; + mlog_bug_on_msg(qs->qs_connected < 0, + "node %u, connected %d\n", + node, qs->qs_connected); + + clear_bit(node, qs->qs_conn_bm); + } + + mlog(0, "node %u, %d total\n", node, qs->qs_connected); + + if (test_bit(node, qs->qs_hb_bm)) + o2quo_set_hold(qs, node); + + spin_unlock(&qs->qs_lock); +} + +void o2quo_init(void) +{ + struct o2quo_state *qs = &o2quo_state; + + spin_lock_init(&qs->qs_lock); + INIT_WORK(&qs->qs_work, o2quo_make_decision, NULL); +} + +void o2quo_exit(void) +{ + flush_scheduled_work(); +} diff --git a/fs/ocfs2/cluster/quorum.h b/fs/ocfs2/cluster/quorum.h new file mode 100644 index 0000000..6649cc6 --- /dev/null +++ b/fs/ocfs2/cluster/quorum.h @@ -0,0 +1,36 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef O2CLUSTER_QUORUM_H +#define O2CLUSTER_QUORUM_H + +void o2quo_init(void); +void o2quo_exit(void); + +void o2quo_hb_up(u8 node); +void o2quo_hb_down(u8 node); +void o2quo_hb_still_up(u8 node); +void o2quo_conn_up(u8 node); +void o2quo_conn_err(u8 node); +void o2quo_disk_timeout(void); + +#endif /* O2CLUSTER_QUORUM_H */ diff --git a/fs/ocfs2/cluster/sys.c b/fs/ocfs2/cluster/sys.c new file mode 100644 index 0000000..f1e9946 --- /dev/null +++ b/fs/ocfs2/cluster/sys.c @@ -0,0 +1,124 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * sys.c + * + * OCFS2 cluster sysfs interface + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, + * version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#include +#include +#include +#include + +#include "ocfs2_nodemanager.h" +#include "masklog.h" +#include "sys.h" + +struct o2cb_attribute { + struct attribute attr; + ssize_t (*show)(char *buf); + ssize_t (*store)(const char *buf, size_t count); +}; + +#define O2CB_ATTR(_name, _mode, _show, _store) \ +struct o2cb_attribute o2cb_attr_##_name = __ATTR(_name, _mode, _show, _store) + +#define to_o2cb_subsys(k) container_of(to_kset(k), struct subsystem, kset) +#define to_o2cb_attr(_attr) container_of(_attr, struct o2cb_attribute, attr) + +static ssize_t o2cb_interface_revision_show(char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%u\n", O2NM_API_VERSION); +} + +O2CB_ATTR(interface_revision, S_IFREG | S_IRUGO, o2cb_interface_revision_show, NULL); + +static struct attribute *o2cb_attrs[] = { + &o2cb_attr_interface_revision.attr, + NULL, +}; + +static ssize_t +o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer); +static ssize_t +o2cb_store(struct kobject * kobj, struct attribute * attr, + const char * buffer, size_t count); +static struct sysfs_ops o2cb_sysfs_ops = { + .show = o2cb_show, + .store = o2cb_store, +}; + +static struct kobj_type o2cb_subsys_type = { + .default_attrs = o2cb_attrs, + .sysfs_ops = &o2cb_sysfs_ops, +}; + +/* gives us o2cb_subsys */ +decl_subsys(o2cb, NULL, NULL); + +static ssize_t +o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer) +{ + struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr); + struct subsystem *sbs = to_o2cb_subsys(kobj); + + BUG_ON(sbs != &o2cb_subsys); + + if (o2cb_attr->show) + return o2cb_attr->show(buffer); + return -EIO; +} + +static ssize_t +o2cb_store(struct kobject * kobj, struct attribute * attr, + const char * buffer, size_t count) +{ + struct o2cb_attribute *o2cb_attr = to_o2cb_attr(attr); + struct subsystem *sbs = to_o2cb_subsys(kobj); + + BUG_ON(sbs != &o2cb_subsys); + + if (o2cb_attr->store) + return o2cb_attr->store(buffer, count); + return -EIO; +} + +void o2cb_sys_shutdown(void) +{ + mlog_sys_shutdown(); + subsystem_unregister(&o2cb_subsys); +} + +int o2cb_sys_init(void) +{ + int ret; + + o2cb_subsys.kset.kobj.ktype = &o2cb_subsys_type; + ret = subsystem_register(&o2cb_subsys); + if (ret) + return ret; + + ret = mlog_sys_init(&o2cb_subsys); + if (ret) + subsystem_unregister(&o2cb_subsys); + return ret; +} diff --git a/fs/ocfs2/cluster/sys.h b/fs/ocfs2/cluster/sys.h new file mode 100644 index 0000000..d66b8ab --- /dev/null +++ b/fs/ocfs2/cluster/sys.h @@ -0,0 +1,33 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * sys.h + * + * Function prototypes for o2cb sysfs interface + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, + * version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef O2CLUSTER_SYS_H +#define O2CLUSTER_SYS_H + +void o2cb_sys_shutdown(void); +int o2cb_sys_init(void); + +#endif /* O2CLUSTER_SYS_H */ diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c new file mode 100644 index 0000000..35d92c0 --- /dev/null +++ b/fs/ocfs2/cluster/tcp.c @@ -0,0 +1,1829 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * ---- + * + * Callers for this were originally written against a very simple synchronus + * API. This implementation reflects those simple callers. Some day I'm sure + * we'll need to move to a more robust posting/callback mechanism. + * + * Transmit calls pass in kernel virtual addresses and block copying this into + * the socket's tx buffers via a usual blocking sendmsg. They'll block waiting + * for a failed socket to timeout. TX callers can also pass in a poniter to an + * 'int' which gets filled with an errno off the wire in response to the + * message they send. + * + * Handlers for unsolicited messages are registered. Each socket has a page + * that incoming data is copied into. First the header, then the data. + * Handlers are called from only one thread with a reference to this per-socket + * page. This page is destroyed after the handler call, so it can't be + * referenced beyond the call. Handlers may block but are discouraged from + * doing so. + * + * Any framing errors (bad magic, large payload lengths) close a connection. + * + * Our sock_container holds the state we associate with a socket. It's current + * framing state is held there as well as the refcounting we do around when it + * is safe to tear down the socket. The socket is only finally torn down from + * the container when the container loses all of its references -- so as long + * as you hold a ref on the container you can trust that the socket is valid + * for use with kernel socket APIs. + * + * Connections are initiated between a pair of nodes when the node with the + * higher node number gets a heartbeat callback which indicates that the lower + * numbered node has started heartbeating. The lower numbered node is passive + * and only accepts the connection if the higher numbered node is heartbeating. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "heartbeat.h" +#include "tcp.h" +#include "nodemanager.h" +#define MLOG_MASK_PREFIX ML_TCP +#include "masklog.h" +#include "quorum.h" + +#include "tcp_internal.h" + +/* + * The linux network stack isn't sparse endian clean.. It has macros like + * ntohs() which perform the endian checks and structs like sockaddr_in + * which aren't annotated. So __force is found here to get the build + * clean. When they emerge from the dark ages and annotate the code + * we can remove these. + */ + +#define SC_NODEF_FMT "node %s (num %u) at %u.%u.%u.%u:%u" +#define SC_NODEF_ARGS(sc) sc->sc_node->nd_name, sc->sc_node->nd_num, \ + NIPQUAD(sc->sc_node->nd_ipv4_address), \ + ntohs(sc->sc_node->nd_ipv4_port) + +/* + * In the following two log macros, the whitespace after the ',' just + * before ##args is intentional. Otherwise, gcc 2.95 will eat the + * previous token if args expands to nothing. + */ +#define msglog(hdr, fmt, args...) do { \ + typeof(hdr) __hdr = (hdr); \ + mlog(ML_MSG, "[mag %u len %u typ %u stat %d sys_stat %d " \ + "key %08x num %u] " fmt, \ + be16_to_cpu(__hdr->magic), be16_to_cpu(__hdr->data_len), \ + be16_to_cpu(__hdr->msg_type), be32_to_cpu(__hdr->status), \ + be32_to_cpu(__hdr->sys_status), be32_to_cpu(__hdr->key), \ + be32_to_cpu(__hdr->msg_num) , ##args); \ +} while (0) + +#define sclog(sc, fmt, args...) do { \ + typeof(sc) __sc = (sc); \ + mlog(ML_SOCKET, "[sc %p refs %d sock %p node %u page %p " \ + "pg_off %zu] " fmt, __sc, \ + atomic_read(&__sc->sc_kref.refcount), __sc->sc_sock, \ + __sc->sc_node->nd_num, __sc->sc_page, __sc->sc_page_off , \ + ##args); \ +} while (0) + +static rwlock_t o2net_handler_lock = RW_LOCK_UNLOCKED; +static struct rb_root o2net_handler_tree = RB_ROOT; + +static struct o2net_node o2net_nodes[O2NM_MAX_NODES]; + +/* XXX someday we'll need better accounting */ +static struct socket *o2net_listen_sock = NULL; + +/* + * listen work is only queued by the listening socket callbacks on the + * o2net_wq. teardown detaches the callbacks before destroying the workqueue. + * quorum work is queued as sock containers are shutdown.. stop_listening + * tears down all the node's sock containers, preventing future shutdowns + * and queued quroum work, before canceling delayed quorum work and + * destroying the work queue. + */ +static struct workqueue_struct *o2net_wq; +static struct work_struct o2net_listen_work; + +static struct o2hb_callback_func o2net_hb_up, o2net_hb_down; +#define O2NET_HB_PRI 0x1 + +static struct o2net_handshake *o2net_hand; +static struct o2net_msg *o2net_keep_req, *o2net_keep_resp; + +static int o2net_sys_err_translations[O2NET_ERR_MAX] = + {[O2NET_ERR_NONE] = 0, + [O2NET_ERR_NO_HNDLR] = -ENOPROTOOPT, + [O2NET_ERR_OVERFLOW] = -EOVERFLOW, + [O2NET_ERR_DIED] = -EHOSTDOWN,}; + +/* can't quite avoid *all* internal declarations :/ */ +static void o2net_sc_connect_completed(void *arg); +static void o2net_rx_until_empty(void *arg); +static void o2net_shutdown_sc(void *arg); +static void o2net_listen_data_ready(struct sock *sk, int bytes); +static void o2net_sc_send_keep_req(void *arg); +static void o2net_idle_timer(unsigned long data); +static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); + +static inline int o2net_sys_err_to_errno(enum o2net_system_error err) +{ + int trans; + BUG_ON(err >= O2NET_ERR_MAX); + trans = o2net_sys_err_translations[err]; + + /* Just in case we mess up the translation table above */ + BUG_ON(err != O2NET_ERR_NONE && trans == 0); + return trans; +} + +static struct o2net_node * o2net_nn_from_num(u8 node_num) +{ + BUG_ON(node_num >= ARRAY_SIZE(o2net_nodes)); + return &o2net_nodes[node_num]; +} + +static u8 o2net_num_from_nn(struct o2net_node *nn) +{ + BUG_ON(nn == NULL); + return nn - o2net_nodes; +} + +/* ------------------------------------------------------------ */ + +static int o2net_prep_nsw(struct o2net_node *nn, struct o2net_status_wait *nsw) +{ + int ret = 0; + + do { + if (!idr_pre_get(&nn->nn_status_idr, GFP_ATOMIC)) { + ret = -EAGAIN; + break; + } + spin_lock(&nn->nn_lock); + ret = idr_get_new(&nn->nn_status_idr, nsw, &nsw->ns_id); + if (ret == 0) + list_add_tail(&nsw->ns_node_item, + &nn->nn_status_list); + spin_unlock(&nn->nn_lock); + } while (ret == -EAGAIN); + + if (ret == 0) { + init_waitqueue_head(&nsw->ns_wq); + nsw->ns_sys_status = O2NET_ERR_NONE; + nsw->ns_status = 0; + } + + return ret; +} + +static void o2net_complete_nsw_locked(struct o2net_node *nn, + struct o2net_status_wait *nsw, + enum o2net_system_error sys_status, + s32 status) +{ + assert_spin_locked(&nn->nn_lock); + + if (!list_empty(&nsw->ns_node_item)) { + list_del_init(&nsw->ns_node_item); + nsw->ns_sys_status = sys_status; + nsw->ns_status = status; + idr_remove(&nn->nn_status_idr, nsw->ns_id); + wake_up(&nsw->ns_wq); + } +} + +static void o2net_complete_nsw(struct o2net_node *nn, + struct o2net_status_wait *nsw, + u64 id, enum o2net_system_error sys_status, + s32 status) +{ + spin_lock(&nn->nn_lock); + if (nsw == NULL) { + if (id > INT_MAX) + goto out; + + nsw = idr_find(&nn->nn_status_idr, id); + if (nsw == NULL) + goto out; + } + + o2net_complete_nsw_locked(nn, nsw, sys_status, status); + +out: + spin_unlock(&nn->nn_lock); + return; +} + +static void o2net_complete_nodes_nsw(struct o2net_node *nn) +{ + struct list_head *iter, *tmp; + unsigned int num_kills = 0; + struct o2net_status_wait *nsw; + + assert_spin_locked(&nn->nn_lock); + + list_for_each_safe(iter, tmp, &nn->nn_status_list) { + nsw = list_entry(iter, struct o2net_status_wait, ns_node_item); + o2net_complete_nsw_locked(nn, nsw, O2NET_ERR_DIED, 0); + num_kills++; + } + + mlog(0, "completed %d messages for node %u\n", num_kills, + o2net_num_from_nn(nn)); +} + +static int o2net_nsw_completed(struct o2net_node *nn, + struct o2net_status_wait *nsw) +{ + int completed; + spin_lock(&nn->nn_lock); + completed = list_empty(&nsw->ns_node_item); + spin_unlock(&nn->nn_lock); + return completed; +} + +/* ------------------------------------------------------------ */ + +static void sc_kref_release(struct kref *kref) +{ + struct o2net_sock_container *sc = container_of(kref, + struct o2net_sock_container, sc_kref); + sclog(sc, "releasing\n"); + + if (sc->sc_sock) { + sock_release(sc->sc_sock); + sc->sc_sock = NULL; + } + + o2nm_node_put(sc->sc_node); + sc->sc_node = NULL; + + kfree(sc); +} + +static void sc_put(struct o2net_sock_container *sc) +{ + sclog(sc, "put\n"); + kref_put(&sc->sc_kref, sc_kref_release); +} +static void sc_get(struct o2net_sock_container *sc) +{ + sclog(sc, "get\n"); + kref_get(&sc->sc_kref); +} +static struct o2net_sock_container *sc_alloc(struct o2nm_node *node) +{ + struct o2net_sock_container *sc, *ret = NULL; + struct page *page = NULL; + + page = alloc_page(GFP_NOFS); + sc = kcalloc(1, sizeof(*sc), GFP_NOFS); + if (sc == NULL || page == NULL) + goto out; + + kref_init(&sc->sc_kref); + o2nm_node_get(node); + sc->sc_node = node; + + INIT_WORK(&sc->sc_connect_work, o2net_sc_connect_completed, sc); + INIT_WORK(&sc->sc_rx_work, o2net_rx_until_empty, sc); + INIT_WORK(&sc->sc_shutdown_work, o2net_shutdown_sc, sc); + INIT_WORK(&sc->sc_keepalive_work, o2net_sc_send_keep_req, sc); + + init_timer(&sc->sc_idle_timeout); + sc->sc_idle_timeout.function = o2net_idle_timer; + sc->sc_idle_timeout.data = (unsigned long)sc; + + sclog(sc, "alloced\n"); + + ret = sc; + sc->sc_page = page; + sc = NULL; + page = NULL; + +out: + if (page) + __free_page(page); + kfree(sc); + + return ret; +} + +/* ------------------------------------------------------------ */ + +static void o2net_sc_queue_work(struct o2net_sock_container *sc, + struct work_struct *work) +{ + sc_get(sc); + if (!queue_work(o2net_wq, work)) + sc_put(sc); +} +static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc, + struct work_struct *work, + int delay) +{ + sc_get(sc); + if (!queue_delayed_work(o2net_wq, work, delay)) + sc_put(sc); +} +static void o2net_sc_cancel_delayed_work(struct o2net_sock_container *sc, + struct work_struct *work) +{ + if (cancel_delayed_work(work)) + sc_put(sc); +} + +static void o2net_set_nn_state(struct o2net_node *nn, + struct o2net_sock_container *sc, + unsigned valid, int err) +{ + int was_valid = nn->nn_sc_valid; + int was_err = nn->nn_persistent_error; + struct o2net_sock_container *old_sc = nn->nn_sc; + + assert_spin_locked(&nn->nn_lock); + + /* the node num comparison and single connect/accept path should stop + * an non-null sc from being overwritten with another */ + BUG_ON(sc && nn->nn_sc && nn->nn_sc != sc); + mlog_bug_on_msg(err && valid, "err %d valid %u\n", err, valid); + mlog_bug_on_msg(valid && !sc, "valid %u sc %p\n", valid, sc); + + /* we won't reconnect after our valid conn goes away for + * this hb iteration.. here so it shows up in the logs */ + if (was_valid && !valid && err == 0) + err = -ENOTCONN; + + mlog(ML_CONN, "node %u sc: %p -> %p, valid %u -> %u, err %d -> %d\n", + o2net_num_from_nn(nn), nn->nn_sc, sc, nn->nn_sc_valid, valid, + nn->nn_persistent_error, err); + + nn->nn_sc = sc; + nn->nn_sc_valid = valid ? 1 : 0; + nn->nn_persistent_error = err; + + /* mirrors o2net_tx_can_proceed() */ + if (nn->nn_persistent_error || nn->nn_sc_valid) + wake_up(&nn->nn_sc_wq); + + if (!was_err && nn->nn_persistent_error) { + o2quo_conn_err(o2net_num_from_nn(nn)); + queue_delayed_work(o2net_wq, &nn->nn_still_up, + msecs_to_jiffies(O2NET_QUORUM_DELAY_MS)); + } + + if (was_valid && !valid) { + mlog(ML_NOTICE, "no longer connected to " SC_NODEF_FMT "\n", + SC_NODEF_ARGS(old_sc)); + o2net_complete_nodes_nsw(nn); + } + + if (!was_valid && valid) { + o2quo_conn_up(o2net_num_from_nn(nn)); + /* this is a bit of a hack. we only try reconnecting + * when heartbeating starts until we get a connection. + * if that connection then dies we don't try reconnecting. + * the only way to start connecting again is to down + * heartbeat and bring it back up. */ + cancel_delayed_work(&nn->nn_connect_expired); + mlog(ML_NOTICE, "%s " SC_NODEF_FMT "\n", + o2nm_this_node() > sc->sc_node->nd_num ? + "connected to" : "accepted connection from", + SC_NODEF_ARGS(sc)); + } + + /* trigger the connecting worker func as long as we're not valid, + * it will back off if it shouldn't connect. This can be called + * from node config teardown and so needs to be careful about + * the work queue actually being up. */ + if (!valid && o2net_wq) { + unsigned long delay; + /* delay if we're withing a RECONNECT_DELAY of the + * last attempt */ + delay = (nn->nn_last_connect_attempt + + msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS)) + - jiffies; + if (delay > msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS)) + delay = 0; + mlog(ML_CONN, "queueing conn attempt in %lu jiffies\n", delay); + queue_delayed_work(o2net_wq, &nn->nn_connect_work, delay); + } + + /* keep track of the nn's sc ref for the caller */ + if ((old_sc == NULL) && sc) + sc_get(sc); + if (old_sc && (old_sc != sc)) { + o2net_sc_queue_work(old_sc, &old_sc->sc_shutdown_work); + sc_put(old_sc); + } +} + +/* see o2net_register_callbacks() */ +static void o2net_data_ready(struct sock *sk, int bytes) +{ + void (*ready)(struct sock *sk, int bytes); + + read_lock(&sk->sk_callback_lock); + if (sk->sk_user_data) { + struct o2net_sock_container *sc = sk->sk_user_data; + sclog(sc, "data_ready hit\n"); + do_gettimeofday(&sc->sc_tv_data_ready); + o2net_sc_queue_work(sc, &sc->sc_rx_work); + ready = sc->sc_data_ready; + } else { + ready = sk->sk_data_ready; + } + read_unlock(&sk->sk_callback_lock); + + ready(sk, bytes); +} + +/* see o2net_register_callbacks() */ +static void o2net_state_change(struct sock *sk) +{ + void (*state_change)(struct sock *sk); + struct o2net_sock_container *sc; + + read_lock(&sk->sk_callback_lock); + sc = sk->sk_user_data; + if (sc == NULL) { + state_change = sk->sk_state_change; + goto out; + } + + sclog(sc, "state_change to %d\n", sk->sk_state); + + state_change = sc->sc_state_change; + + switch(sk->sk_state) { + /* ignore connecting sockets as they make progress */ + case TCP_SYN_SENT: + case TCP_SYN_RECV: + break; + case TCP_ESTABLISHED: + o2net_sc_queue_work(sc, &sc->sc_connect_work); + break; + default: + o2net_sc_queue_work(sc, &sc->sc_shutdown_work); + break; + } +out: + read_unlock(&sk->sk_callback_lock); + state_change(sk); +} + +/* + * we register callbacks so we can queue work on events before calling + * the original callbacks. our callbacks our careful to test user_data + * to discover when they've reaced with o2net_unregister_callbacks(). + */ +static void o2net_register_callbacks(struct sock *sk, + struct o2net_sock_container *sc) +{ + write_lock_bh(&sk->sk_callback_lock); + + /* accepted sockets inherit the old listen socket data ready */ + if (sk->sk_data_ready == o2net_listen_data_ready) { + sk->sk_data_ready = sk->sk_user_data; + sk->sk_user_data = NULL; + } + + BUG_ON(sk->sk_user_data != NULL); + sk->sk_user_data = sc; + sc_get(sc); + + sc->sc_data_ready = sk->sk_data_ready; + sc->sc_state_change = sk->sk_state_change; + sk->sk_data_ready = o2net_data_ready; + sk->sk_state_change = o2net_state_change; + + write_unlock_bh(&sk->sk_callback_lock); +} + +static int o2net_unregister_callbacks(struct sock *sk, + struct o2net_sock_container *sc) +{ + int ret = 0; + + write_lock_bh(&sk->sk_callback_lock); + if (sk->sk_user_data == sc) { + ret = 1; + sk->sk_user_data = NULL; + sk->sk_data_ready = sc->sc_data_ready; + sk->sk_state_change = sc->sc_state_change; + } + write_unlock_bh(&sk->sk_callback_lock); + + return ret; +} + +/* + * this is a little helper that is called by callers who have seen a problem + * with an sc and want to detach it from the nn if someone already hasn't beat + * them to it. if an error is given then the shutdown will be persistent + * and pending transmits will be canceled. + */ +static void o2net_ensure_shutdown(struct o2net_node *nn, + struct o2net_sock_container *sc, + int err) +{ + spin_lock(&nn->nn_lock); + if (nn->nn_sc == sc) + o2net_set_nn_state(nn, NULL, 0, err); + spin_unlock(&nn->nn_lock); +} + +/* + * This work queue function performs the blocking parts of socket shutdown. A + * few paths lead here. set_nn_state will trigger this callback if it sees an + * sc detached from the nn. state_change will also trigger this callback + * directly when it sees errors. In that case we need to call set_nn_state + * ourselves as state_change couldn't get the nn_lock and call set_nn_state + * itself. + */ +static void o2net_shutdown_sc(void *arg) +{ + struct o2net_sock_container *sc = arg; + struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + + sclog(sc, "shutting down\n"); + + /* drop the callbacks ref and call shutdown only once */ + if (o2net_unregister_callbacks(sc->sc_sock->sk, sc)) { + /* we shouldn't flush as we're in the thread, the + * races with pending sc work structs are harmless */ + del_timer_sync(&sc->sc_idle_timeout); + o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); + sc_put(sc); + sc->sc_sock->ops->shutdown(sc->sc_sock, + RCV_SHUTDOWN|SEND_SHUTDOWN); + } + + /* not fatal so failed connects before the other guy has our + * heartbeat can be retried */ + o2net_ensure_shutdown(nn, sc, 0); + sc_put(sc); +} + +/* ------------------------------------------------------------ */ + +static int o2net_handler_cmp(struct o2net_msg_handler *nmh, u32 msg_type, + u32 key) +{ + int ret = memcmp(&nmh->nh_key, &key, sizeof(key)); + + if (ret == 0) + ret = memcmp(&nmh->nh_msg_type, &msg_type, sizeof(msg_type)); + + return ret; +} + +static struct o2net_msg_handler * +o2net_handler_tree_lookup(u32 msg_type, u32 key, struct rb_node ***ret_p, + struct rb_node **ret_parent) +{ + struct rb_node **p = &o2net_handler_tree.rb_node; + struct rb_node *parent = NULL; + struct o2net_msg_handler *nmh, *ret = NULL; + int cmp; + + while (*p) { + parent = *p; + nmh = rb_entry(parent, struct o2net_msg_handler, nh_node); + cmp = o2net_handler_cmp(nmh, msg_type, key); + + if (cmp < 0) + p = &(*p)->rb_left; + else if (cmp > 0) + p = &(*p)->rb_right; + else { + ret = nmh; + break; + } + } + + if (ret_p != NULL) + *ret_p = p; + if (ret_parent != NULL) + *ret_parent = parent; + + return ret; +} + +static void o2net_handler_kref_release(struct kref *kref) +{ + struct o2net_msg_handler *nmh; + nmh = container_of(kref, struct o2net_msg_handler, nh_kref); + + kfree(nmh); +} + +static void o2net_handler_put(struct o2net_msg_handler *nmh) +{ + kref_put(&nmh->nh_kref, o2net_handler_kref_release); +} + +/* max_len is protection for the handler func. incoming messages won't + * be given to the handler if their payload is longer than the max. */ +int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, + o2net_msg_handler_func *func, void *data, + struct list_head *unreg_list) +{ + struct o2net_msg_handler *nmh = NULL; + struct rb_node **p, *parent; + int ret = 0; + + if (max_len > O2NET_MAX_PAYLOAD_BYTES) { + mlog(0, "max_len for message handler out of range: %u\n", + max_len); + ret = -EINVAL; + goto out; + } + + if (!msg_type) { + mlog(0, "no message type provided: %u, %p\n", msg_type, func); + ret = -EINVAL; + goto out; + + } + if (!func) { + mlog(0, "no message handler provided: %u, %p\n", + msg_type, func); + ret = -EINVAL; + goto out; + } + + nmh = kcalloc(1, sizeof(struct o2net_msg_handler), GFP_NOFS); + if (nmh == NULL) { + ret = -ENOMEM; + goto out; + } + + nmh->nh_func = func; + nmh->nh_func_data = data; + nmh->nh_msg_type = msg_type; + nmh->nh_max_len = max_len; + nmh->nh_key = key; + /* the tree and list get this ref.. they're both removed in + * unregister when this ref is dropped */ + kref_init(&nmh->nh_kref); + INIT_LIST_HEAD(&nmh->nh_unregister_item); + + write_lock(&o2net_handler_lock); + if (o2net_handler_tree_lookup(msg_type, key, &p, &parent)) + ret = -EEXIST; + else { + rb_link_node(&nmh->nh_node, parent, p); + rb_insert_color(&nmh->nh_node, &o2net_handler_tree); + list_add_tail(&nmh->nh_unregister_item, unreg_list); + + mlog(ML_TCP, "registered handler func %p type %u key %08x\n", + func, msg_type, key); + /* we've had some trouble with handlers seemingly vanishing. */ + mlog_bug_on_msg(o2net_handler_tree_lookup(msg_type, key, &p, + &parent) == NULL, + "couldn't find handler we *just* registerd " + "for type %u key %08x\n", msg_type, key); + } + write_unlock(&o2net_handler_lock); + if (ret) + goto out; + +out: + if (ret) + kfree(nmh); + + return ret; +} +EXPORT_SYMBOL_GPL(o2net_register_handler); + +void o2net_unregister_handler_list(struct list_head *list) +{ + struct list_head *pos, *n; + struct o2net_msg_handler *nmh; + + write_lock(&o2net_handler_lock); + list_for_each_safe(pos, n, list) { + nmh = list_entry(pos, struct o2net_msg_handler, + nh_unregister_item); + mlog(ML_TCP, "unregistering handler func %p type %u key %08x\n", + nmh->nh_func, nmh->nh_msg_type, nmh->nh_key); + rb_erase(&nmh->nh_node, &o2net_handler_tree); + list_del_init(&nmh->nh_unregister_item); + kref_put(&nmh->nh_kref, o2net_handler_kref_release); + } + write_unlock(&o2net_handler_lock); +} +EXPORT_SYMBOL_GPL(o2net_unregister_handler_list); + +static struct o2net_msg_handler *o2net_handler_get(u32 msg_type, u32 key) +{ + struct o2net_msg_handler *nmh; + + read_lock(&o2net_handler_lock); + nmh = o2net_handler_tree_lookup(msg_type, key, NULL, NULL); + if (nmh) + kref_get(&nmh->nh_kref); + read_unlock(&o2net_handler_lock); + + return nmh; +} + +/* ------------------------------------------------------------ */ + +static int o2net_recv_tcp_msg(struct socket *sock, void *data, size_t len) +{ + int ret; + mm_segment_t oldfs; + struct kvec vec = { + .iov_len = len, + .iov_base = data, + }; + struct msghdr msg = { + .msg_iovlen = 1, + .msg_iov = (struct iovec *)&vec, + .msg_flags = MSG_DONTWAIT, + }; + + oldfs = get_fs(); + set_fs(get_ds()); + ret = sock_recvmsg(sock, &msg, len, msg.msg_flags); + set_fs(oldfs); + + return ret; +} + +static int o2net_send_tcp_msg(struct socket *sock, struct kvec *vec, + size_t veclen, size_t total) +{ + int ret; + mm_segment_t oldfs; + struct msghdr msg = { + .msg_iov = (struct iovec *)vec, + .msg_iovlen = veclen, + }; + + if (sock == NULL) { + ret = -EINVAL; + goto out; + } + + oldfs = get_fs(); + set_fs(get_ds()); + ret = sock_sendmsg(sock, &msg, total); + set_fs(oldfs); + if (ret != total) { + mlog(ML_ERROR, "sendmsg returned %d instead of %zu\n", ret, + total); + if (ret >= 0) + ret = -EPIPE; /* should be smarter, I bet */ + goto out; + } + + ret = 0; +out: + if (ret < 0) + mlog(0, "returning error: %d\n", ret); + return ret; +} + +static void o2net_sendpage(struct o2net_sock_container *sc, + void *kmalloced_virt, + size_t size) +{ + struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + ssize_t ret; + + + ret = sc->sc_sock->ops->sendpage(sc->sc_sock, + virt_to_page(kmalloced_virt), + (long)kmalloced_virt & ~PAGE_MASK, + size, MSG_DONTWAIT); + if (ret != size) { + mlog(ML_ERROR, "sendpage of size %zu to " SC_NODEF_FMT + " failed with %zd\n", size, SC_NODEF_ARGS(sc), ret); + o2net_ensure_shutdown(nn, sc, 0); + } +} + +static void o2net_init_msg(struct o2net_msg *msg, u16 data_len, u16 msg_type, u32 key) +{ + memset(msg, 0, sizeof(struct o2net_msg)); + msg->magic = cpu_to_be16(O2NET_MSG_MAGIC); + msg->data_len = cpu_to_be16(data_len); + msg->msg_type = cpu_to_be16(msg_type); + msg->sys_status = cpu_to_be32(O2NET_ERR_NONE); + msg->status = 0; + msg->key = cpu_to_be32(key); +} + +static int o2net_tx_can_proceed(struct o2net_node *nn, + struct o2net_sock_container **sc_ret, + int *error) +{ + int ret = 0; + + spin_lock(&nn->nn_lock); + if (nn->nn_persistent_error) { + ret = 1; + *sc_ret = NULL; + *error = nn->nn_persistent_error; + } else if (nn->nn_sc_valid) { + kref_get(&nn->nn_sc->sc_kref); + + ret = 1; + *sc_ret = nn->nn_sc; + *error = 0; + } + spin_unlock(&nn->nn_lock); + + return ret; +} + +int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec, + size_t caller_veclen, u8 target_node, int *status) +{ + int ret, error = 0; + struct o2net_msg *msg = NULL; + size_t veclen, caller_bytes = 0; + struct kvec *vec = NULL; + struct o2net_sock_container *sc = NULL; + struct o2net_node *nn = o2net_nn_from_num(target_node); + struct o2net_status_wait nsw = { + .ns_node_item = LIST_HEAD_INIT(nsw.ns_node_item), + }; + + if (o2net_wq == NULL) { + mlog(0, "attempt to tx without o2netd running\n"); + ret = -ESRCH; + goto out; + } + + if (caller_veclen == 0) { + mlog(0, "bad kvec array length\n"); + ret = -EINVAL; + goto out; + } + + caller_bytes = iov_length((struct iovec *)caller_vec, caller_veclen); + if (caller_bytes > O2NET_MAX_PAYLOAD_BYTES) { + mlog(0, "total payload len %zu too large\n", caller_bytes); + ret = -EINVAL; + goto out; + } + + if (target_node == o2nm_this_node()) { + ret = -ELOOP; + goto out; + } + + ret = wait_event_interruptible(nn->nn_sc_wq, + o2net_tx_can_proceed(nn, &sc, &error)); + if (!ret && error) + ret = error; + if (ret) + goto out; + + veclen = caller_veclen + 1; + vec = kmalloc(sizeof(struct kvec) * veclen, GFP_ATOMIC); + if (vec == NULL) { + mlog(0, "failed to %zu element kvec!\n", veclen); + ret = -ENOMEM; + goto out; + } + + msg = kmalloc(sizeof(struct o2net_msg), GFP_ATOMIC); + if (!msg) { + mlog(0, "failed to allocate a o2net_msg!\n"); + ret = -ENOMEM; + goto out; + } + + o2net_init_msg(msg, caller_bytes, msg_type, key); + + vec[0].iov_len = sizeof(struct o2net_msg); + vec[0].iov_base = msg; + memcpy(&vec[1], caller_vec, caller_veclen * sizeof(struct kvec)); + + ret = o2net_prep_nsw(nn, &nsw); + if (ret) + goto out; + + msg->msg_num = cpu_to_be32(nsw.ns_id); + + /* finally, convert the message header to network byte-order + * and send */ + ret = o2net_send_tcp_msg(sc->sc_sock, vec, veclen, + sizeof(struct o2net_msg) + caller_bytes); + msglog(msg, "sending returned %d\n", ret); + if (ret < 0) { + mlog(0, "error returned from o2net_send_tcp_msg=%d\n", ret); + goto out; + } + + /* wait on other node's handler */ + wait_event(nsw.ns_wq, o2net_nsw_completed(nn, &nsw)); + + /* Note that we avoid overwriting the callers status return + * variable if a system error was reported on the other + * side. Callers beware. */ + ret = o2net_sys_err_to_errno(nsw.ns_sys_status); + if (status && !ret) + *status = nsw.ns_status; + + mlog(0, "woken, returning system status %d, user status %d\n", + ret, nsw.ns_status); +out: + if (sc) + sc_put(sc); + if (vec) + kfree(vec); + if (msg) + kfree(msg); + o2net_complete_nsw(nn, &nsw, 0, 0, 0); + return ret; +} +EXPORT_SYMBOL_GPL(o2net_send_message_vec); + +int o2net_send_message(u32 msg_type, u32 key, void *data, u32 len, + u8 target_node, int *status) +{ + struct kvec vec = { + .iov_base = data, + .iov_len = len, + }; + return o2net_send_message_vec(msg_type, key, &vec, 1, + target_node, status); +} +EXPORT_SYMBOL_GPL(o2net_send_message); + +static int o2net_send_status_magic(struct socket *sock, struct o2net_msg *hdr, + enum o2net_system_error syserr, int err) +{ + struct kvec vec = { + .iov_base = hdr, + .iov_len = sizeof(struct o2net_msg), + }; + + BUG_ON(syserr >= O2NET_ERR_MAX); + + /* leave other fields intact from the incoming message, msg_num + * in particular */ + hdr->sys_status = cpu_to_be32(syserr); + hdr->status = cpu_to_be32(err); + hdr->magic = cpu_to_be16(O2NET_MSG_STATUS_MAGIC); // twiddle the magic + hdr->data_len = 0; + + msglog(hdr, "about to send status magic %d\n", err); + /* hdr has been in host byteorder this whole time */ + return o2net_send_tcp_msg(sock, &vec, 1, sizeof(struct o2net_msg)); +} + +/* this returns -errno if the header was unknown or too large, etc. + * after this is called the buffer us reused for the next message */ +static int o2net_process_message(struct o2net_sock_container *sc, + struct o2net_msg *hdr) +{ + struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + int ret = 0, handler_status; + enum o2net_system_error syserr; + struct o2net_msg_handler *nmh = NULL; + + msglog(hdr, "processing message\n"); + + o2net_sc_postpone_idle(sc); + + switch(be16_to_cpu(hdr->magic)) { + case O2NET_MSG_STATUS_MAGIC: + /* special type for returning message status */ + o2net_complete_nsw(nn, NULL, + be32_to_cpu(hdr->msg_num), + be32_to_cpu(hdr->sys_status), + be32_to_cpu(hdr->status)); + goto out; + case O2NET_MSG_KEEP_REQ_MAGIC: + o2net_sendpage(sc, o2net_keep_resp, + sizeof(*o2net_keep_resp)); + goto out; + case O2NET_MSG_KEEP_RESP_MAGIC: + goto out; + case O2NET_MSG_MAGIC: + break; + default: + msglog(hdr, "bad magic\n"); + ret = -EINVAL; + goto out; + break; + } + + /* find a handler for it */ + handler_status = 0; + nmh = o2net_handler_get(be16_to_cpu(hdr->msg_type), + be32_to_cpu(hdr->key)); + if (!nmh) { + mlog(ML_TCP, "couldn't find handler for type %u key %08x\n", + be16_to_cpu(hdr->msg_type), be32_to_cpu(hdr->key)); + syserr = O2NET_ERR_NO_HNDLR; + goto out_respond; + } + + syserr = O2NET_ERR_NONE; + + if (be16_to_cpu(hdr->data_len) > nmh->nh_max_len) + syserr = O2NET_ERR_OVERFLOW; + + if (syserr != O2NET_ERR_NONE) + goto out_respond; + + do_gettimeofday(&sc->sc_tv_func_start); + sc->sc_msg_key = be32_to_cpu(hdr->key); + sc->sc_msg_type = be16_to_cpu(hdr->msg_type); + handler_status = (nmh->nh_func)(hdr, sizeof(struct o2net_msg) + + be16_to_cpu(hdr->data_len), + nmh->nh_func_data); + do_gettimeofday(&sc->sc_tv_func_stop); + +out_respond: + /* this destroys the hdr, so don't use it after this */ + ret = o2net_send_status_magic(sc->sc_sock, hdr, syserr, + handler_status); + hdr = NULL; + mlog(0, "sending handler status %d, syserr %d returned %d\n", + handler_status, syserr, ret); + +out: + if (nmh) + o2net_handler_put(nmh); + return ret; +} + +static int o2net_check_handshake(struct o2net_sock_container *sc) +{ + struct o2net_handshake *hand = page_address(sc->sc_page); + struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + + if (hand->protocol_version != cpu_to_be64(O2NET_PROTOCOL_VERSION)) { + mlog(ML_NOTICE, SC_NODEF_FMT " advertised net protocol " + "version %llu but %llu is required, disconnecting\n", + SC_NODEF_ARGS(sc), + (unsigned long long)be64_to_cpu(hand->protocol_version), + O2NET_PROTOCOL_VERSION); + + /* don't bother reconnecting if its the wrong version. */ + o2net_ensure_shutdown(nn, sc, -ENOTCONN); + return -1; + } + + sc->sc_handshake_ok = 1; + + spin_lock(&nn->nn_lock); + /* set valid and queue the idle timers only if it hasn't been + * shut down already */ + if (nn->nn_sc == sc) { + o2net_sc_postpone_idle(sc); + o2net_set_nn_state(nn, sc, 1, 0); + } + spin_unlock(&nn->nn_lock); + + /* shift everything up as though it wasn't there */ + sc->sc_page_off -= sizeof(struct o2net_handshake); + if (sc->sc_page_off) + memmove(hand, hand + 1, sc->sc_page_off); + + return 0; +} + +/* this demuxes the queued rx bytes into header or payload bits and calls + * handlers as each full message is read off the socket. it returns -error, + * == 0 eof, or > 0 for progress made.*/ +static int o2net_advance_rx(struct o2net_sock_container *sc) +{ + struct o2net_msg *hdr; + int ret = 0; + void *data; + size_t datalen; + + sclog(sc, "receiving\n"); + do_gettimeofday(&sc->sc_tv_advance_start); + + /* do we need more header? */ + if (sc->sc_page_off < sizeof(struct o2net_msg)) { + data = page_address(sc->sc_page) + sc->sc_page_off; + datalen = sizeof(struct o2net_msg) - sc->sc_page_off; + ret = o2net_recv_tcp_msg(sc->sc_sock, data, datalen); + if (ret > 0) { + sc->sc_page_off += ret; + + /* this working relies on the handshake being + * smaller than the normal message header */ + if (sc->sc_page_off >= sizeof(struct o2net_handshake)&& + !sc->sc_handshake_ok && o2net_check_handshake(sc)) { + ret = -EPROTO; + goto out; + } + + /* only swab incoming here.. we can + * only get here once as we cross from + * being under to over */ + if (sc->sc_page_off == sizeof(struct o2net_msg)) { + hdr = page_address(sc->sc_page); + if (be16_to_cpu(hdr->data_len) > + O2NET_MAX_PAYLOAD_BYTES) + ret = -EOVERFLOW; + } + } + if (ret <= 0) + goto out; + } + + if (sc->sc_page_off < sizeof(struct o2net_msg)) { + /* oof, still don't have a header */ + goto out; + } + + /* this was swabbed above when we first read it */ + hdr = page_address(sc->sc_page); + + msglog(hdr, "at page_off %zu\n", sc->sc_page_off); + + /* do we need more payload? */ + if (sc->sc_page_off - sizeof(struct o2net_msg) < be16_to_cpu(hdr->data_len)) { + /* need more payload */ + data = page_address(sc->sc_page) + sc->sc_page_off; + datalen = (sizeof(struct o2net_msg) + be16_to_cpu(hdr->data_len)) - + sc->sc_page_off; + ret = o2net_recv_tcp_msg(sc->sc_sock, data, datalen); + if (ret > 0) + sc->sc_page_off += ret; + if (ret <= 0) + goto out; + } + + if (sc->sc_page_off - sizeof(struct o2net_msg) == be16_to_cpu(hdr->data_len)) { + /* we can only get here once, the first time we read + * the payload.. so set ret to progress if the handler + * works out. after calling this the message is toast */ + ret = o2net_process_message(sc, hdr); + if (ret == 0) + ret = 1; + sc->sc_page_off = 0; + } + +out: + sclog(sc, "ret = %d\n", ret); + do_gettimeofday(&sc->sc_tv_advance_stop); + return ret; +} + +/* this work func is triggerd by data ready. it reads until it can read no + * more. it interprets 0, eof, as fatal. if data_ready hits while we're doing + * our work the work struct will be marked and we'll be called again. */ +static void o2net_rx_until_empty(void *arg) +{ + struct o2net_sock_container *sc = arg; + int ret; + + do { + ret = o2net_advance_rx(sc); + } while (ret > 0); + + if (ret <= 0 && ret != -EAGAIN) { + struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); + sclog(sc, "saw error %d, closing\n", ret); + /* not permanent so read failed handshake can retry */ + o2net_ensure_shutdown(nn, sc, 0); + } + + sc_put(sc); +} + +static int o2net_set_nodelay(struct socket *sock) +{ + int ret, val = 1; + mm_segment_t oldfs; + + oldfs = get_fs(); + set_fs(KERNEL_DS); + + /* + * Dear unsuspecting programmer, + * + * Don't use sock_setsockopt() for SOL_TCP. It doesn't check its level + * argument and assumes SOL_SOCKET so, say, your TCP_NODELAY will + * silently turn into SO_DEBUG. + * + * Yours, + * Keeper of hilariously fragile interfaces. + */ + ret = sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, + (char __user *)&val, sizeof(val)); + + set_fs(oldfs); + return ret; +} + +/* ------------------------------------------------------------ */ + +/* called when a connect completes and after a sock is accepted. the + * rx path will see the response and mark the sc valid */ +static void o2net_sc_connect_completed(void *arg) +{ + struct o2net_sock_container *sc = arg; + + mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n", + (unsigned long long)O2NET_PROTOCOL_VERSION, + (unsigned long long)be64_to_cpu(o2net_hand->connector_id)); + + o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); + sc_put(sc); +} + +/* this is called as a work_struct func. */ +static void o2net_sc_send_keep_req(void *arg) +{ + struct o2net_sock_container *sc = arg; + + o2net_sendpage(sc, o2net_keep_req, sizeof(*o2net_keep_req)); + sc_put(sc); +} + +/* socket shutdown does a del_timer_sync against this as it tears down. + * we can't start this timer until we've got to the point in sc buildup + * where shutdown is going to be involved */ +static void o2net_idle_timer(unsigned long data) +{ + struct o2net_sock_container *sc = (struct o2net_sock_container *)data; + struct timeval now; + + do_gettimeofday(&now); + + mlog(ML_NOTICE, "connection to " SC_NODEF_FMT " has been idle for 10 " + "seconds, shutting it down.\n", SC_NODEF_ARGS(sc)); + mlog(ML_NOTICE, "here are some times that might help debug the " + "situation: (tmr %ld.%ld now %ld.%ld dr %ld.%ld adv " + "%ld.%ld:%ld.%ld func (%08x:%u) %ld.%ld:%ld.%ld)\n", + sc->sc_tv_timer.tv_sec, sc->sc_tv_timer.tv_usec, + now.tv_sec, now.tv_usec, + sc->sc_tv_data_ready.tv_sec, sc->sc_tv_data_ready.tv_usec, + sc->sc_tv_advance_start.tv_sec, sc->sc_tv_advance_start.tv_usec, + sc->sc_tv_advance_stop.tv_sec, sc->sc_tv_advance_stop.tv_usec, + sc->sc_msg_key, sc->sc_msg_type, + sc->sc_tv_func_start.tv_sec, sc->sc_tv_func_start.tv_usec, + sc->sc_tv_func_stop.tv_sec, sc->sc_tv_func_stop.tv_usec); + + o2net_sc_queue_work(sc, &sc->sc_shutdown_work); +} + +static void o2net_sc_postpone_idle(struct o2net_sock_container *sc) +{ + o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); + o2net_sc_queue_delayed_work(sc, &sc->sc_keepalive_work, + O2NET_KEEPALIVE_DELAY_SECS * HZ); + do_gettimeofday(&sc->sc_tv_timer); + mod_timer(&sc->sc_idle_timeout, + jiffies + (O2NET_IDLE_TIMEOUT_SECS * HZ)); +} + +/* this work func is kicked whenever a path sets the nn state which doesn't + * have valid set. This includes seeing hb come up, losing a connection, + * having a connect attempt fail, etc. This centralizes the logic which decides + * if a connect attempt should be made or if we should give up and all future + * transmit attempts should fail */ +static void o2net_start_connect(void *arg) +{ + struct o2net_node *nn = arg; + struct o2net_sock_container *sc = NULL; + struct o2nm_node *node = NULL; + struct socket *sock = NULL; + struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; + int ret = 0; + + /* if we're greater we initiate tx, otherwise we accept */ + if (o2nm_this_node() <= o2net_num_from_nn(nn)) + goto out; + + /* watch for racing with tearing a node down */ + node = o2nm_get_node_by_num(o2net_num_from_nn(nn)); + if (node == NULL) { + ret = 0; + goto out; + } + + spin_lock(&nn->nn_lock); + /* see if we already have one pending or have given up */ + if (nn->nn_sc || nn->nn_persistent_error) + arg = NULL; + spin_unlock(&nn->nn_lock); + if (arg == NULL) /* *shrug*, needed some indicator */ + goto out; + + nn->nn_last_connect_attempt = jiffies; + + sc = sc_alloc(node); + if (sc == NULL) { + mlog(0, "couldn't allocate sc\n"); + ret = -ENOMEM; + goto out; + } + + ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); + if (ret < 0) { + mlog(0, "can't create socket: %d\n", ret); + goto out; + } + sc->sc_sock = sock; /* freed by sc_kref_release */ + + sock->sk->sk_allocation = GFP_ATOMIC; + + myaddr.sin_family = AF_INET; + myaddr.sin_port = (__force u16)htons(0); /* any port */ + + ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr, + sizeof(myaddr)); + if (ret) { + mlog(0, "bind failed: %d\n", ret); + goto out; + } + + ret = o2net_set_nodelay(sc->sc_sock); + if (ret) { + mlog(ML_ERROR, "setting TCP_NODELAY failed with %d\n", ret); + goto out; + } + + o2net_register_callbacks(sc->sc_sock->sk, sc); + + spin_lock(&nn->nn_lock); + /* handshake completion will set nn->nn_sc_valid */ + o2net_set_nn_state(nn, sc, 0, 0); + spin_unlock(&nn->nn_lock); + + remoteaddr.sin_family = AF_INET; + remoteaddr.sin_addr.s_addr = (__force u32)node->nd_ipv4_address; + remoteaddr.sin_port = (__force u16)node->nd_ipv4_port; + + ret = sc->sc_sock->ops->connect(sc->sc_sock, + (struct sockaddr *)&remoteaddr, + sizeof(remoteaddr), + O_NONBLOCK); + if (ret == -EINPROGRESS) + ret = 0; + +out: + if (ret) { + mlog(ML_NOTICE, "connect attempt to " SC_NODEF_FMT " failed " + "with errno %d\n", SC_NODEF_ARGS(sc), ret); + /* 0 err so that another will be queued and attempted + * from set_nn_state */ + if (sc) + o2net_ensure_shutdown(nn, sc, 0); + } + if (sc) + sc_put(sc); + if (node) + o2nm_node_put(node); + + return; +} + +static void o2net_connect_expired(void *arg) +{ + struct o2net_node *nn = arg; + + spin_lock(&nn->nn_lock); + if (!nn->nn_sc_valid) { + mlog(ML_ERROR, "no connection established with node %u after " + "%u seconds, giving up and returning errors.\n", + o2net_num_from_nn(nn), O2NET_IDLE_TIMEOUT_SECS); + + o2net_set_nn_state(nn, NULL, 0, -ENOTCONN); + } + spin_unlock(&nn->nn_lock); +} + +static void o2net_still_up(void *arg) +{ + struct o2net_node *nn = arg; + + o2quo_hb_still_up(o2net_num_from_nn(nn)); +} + +/* ------------------------------------------------------------ */ + +void o2net_disconnect_node(struct o2nm_node *node) +{ + struct o2net_node *nn = o2net_nn_from_num(node->nd_num); + + /* don't reconnect until it's heartbeating again */ + spin_lock(&nn->nn_lock); + o2net_set_nn_state(nn, NULL, 0, -ENOTCONN); + spin_unlock(&nn->nn_lock); + + if (o2net_wq) { + cancel_delayed_work(&nn->nn_connect_expired); + cancel_delayed_work(&nn->nn_connect_work); + cancel_delayed_work(&nn->nn_still_up); + flush_workqueue(o2net_wq); + } +} + +static void o2net_hb_node_down_cb(struct o2nm_node *node, int node_num, + void *data) +{ + o2quo_hb_down(node_num); + + if (node_num != o2nm_this_node()) + o2net_disconnect_node(node); +} + +static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num, + void *data) +{ + struct o2net_node *nn = o2net_nn_from_num(node_num); + + o2quo_hb_up(node_num); + + /* ensure an immediate connect attempt */ + nn->nn_last_connect_attempt = jiffies - + (msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS) + 1); + + if (node_num != o2nm_this_node()) { + /* heartbeat doesn't work unless a local node number is + * configured and doing so brings up the o2net_wq, so we can + * use it.. */ + queue_delayed_work(o2net_wq, &nn->nn_connect_expired, + O2NET_IDLE_TIMEOUT_SECS * HZ); + + /* believe it or not, accept and node hearbeating testing + * can succeed for this node before we got here.. so + * only use set_nn_state to clear the persistent error + * if that hasn't already happened */ + spin_lock(&nn->nn_lock); + if (nn->nn_persistent_error) + o2net_set_nn_state(nn, NULL, 0, 0); + spin_unlock(&nn->nn_lock); + } +} + +void o2net_unregister_hb_callbacks(void) +{ + int ret; + + ret = o2hb_unregister_callback(&o2net_hb_up); + if (ret < 0) + mlog(ML_ERROR, "Status return %d unregistering heartbeat up " + "callback!\n", ret); + + ret = o2hb_unregister_callback(&o2net_hb_down); + if (ret < 0) + mlog(ML_ERROR, "Status return %d unregistering heartbeat down " + "callback!\n", ret); +} + +int o2net_register_hb_callbacks(void) +{ + int ret; + + o2hb_setup_callback(&o2net_hb_down, O2HB_NODE_DOWN_CB, + o2net_hb_node_down_cb, NULL, O2NET_HB_PRI); + o2hb_setup_callback(&o2net_hb_up, O2HB_NODE_UP_CB, + o2net_hb_node_up_cb, NULL, O2NET_HB_PRI); + + ret = o2hb_register_callback(&o2net_hb_up); + if (ret == 0) + ret = o2hb_register_callback(&o2net_hb_down); + + if (ret) + o2net_unregister_hb_callbacks(); + + return ret; +} + +/* ------------------------------------------------------------ */ + +static int o2net_accept_one(struct socket *sock) +{ + int ret, slen; + struct sockaddr_in sin; + struct socket *new_sock = NULL; + struct o2nm_node *node = NULL; + struct o2net_sock_container *sc = NULL; + struct o2net_node *nn; + + BUG_ON(sock == NULL); + ret = sock_create_lite(sock->sk->sk_family, sock->sk->sk_type, + sock->sk->sk_protocol, &new_sock); + if (ret) + goto out; + + new_sock->type = sock->type; + new_sock->ops = sock->ops; + ret = sock->ops->accept(sock, new_sock, O_NONBLOCK); + if (ret < 0) + goto out; + + new_sock->sk->sk_allocation = GFP_ATOMIC; + + ret = o2net_set_nodelay(new_sock); + if (ret) { + mlog(ML_ERROR, "setting TCP_NODELAY failed with %d\n", ret); + goto out; + } + + slen = sizeof(sin); + ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin, + &slen, 1); + if (ret < 0) + goto out; + + node = o2nm_get_node_by_ip((__force __be32)sin.sin_addr.s_addr); + if (node == NULL) { + mlog(ML_NOTICE, "attempt to connect from unknown node at " + "%u.%u.%u.%u:%d\n", NIPQUAD(sin.sin_addr.s_addr), + ntohs((__force __be16)sin.sin_port)); + ret = -EINVAL; + goto out; + } + + if (o2nm_this_node() > node->nd_num) { + mlog(ML_NOTICE, "unexpected connect attempted from a lower " + "numbered node '%s' at " "%u.%u.%u.%u:%d with num %u\n", + node->nd_name, NIPQUAD(sin.sin_addr.s_addr), + ntohs((__force __be16)sin.sin_port), node->nd_num); + ret = -EINVAL; + goto out; + } + + /* this happens all the time when the other node sees our heartbeat + * and tries to connect before we see their heartbeat */ + if (!o2hb_check_node_heartbeating_from_callback(node->nd_num)) { + mlog(ML_CONN, "attempt to connect from node '%s' at " + "%u.%u.%u.%u:%d but it isn't heartbeating\n", + node->nd_name, NIPQUAD(sin.sin_addr.s_addr), + ntohs((__force __be16)sin.sin_port)); + ret = -EINVAL; + goto out; + } + + nn = o2net_nn_from_num(node->nd_num); + + spin_lock(&nn->nn_lock); + if (nn->nn_sc) + ret = -EBUSY; + else + ret = 0; + spin_unlock(&nn->nn_lock); + if (ret) { + mlog(ML_NOTICE, "attempt to connect from node '%s' at " + "%u.%u.%u.%u:%d but it already has an open connection\n", + node->nd_name, NIPQUAD(sin.sin_addr.s_addr), + ntohs((__force __be16)sin.sin_port)); + goto out; + } + + sc = sc_alloc(node); + if (sc == NULL) { + ret = -ENOMEM; + goto out; + } + + sc->sc_sock = new_sock; + new_sock = NULL; + + spin_lock(&nn->nn_lock); + o2net_set_nn_state(nn, sc, 0, 0); + spin_unlock(&nn->nn_lock); + + o2net_register_callbacks(sc->sc_sock->sk, sc); + o2net_sc_queue_work(sc, &sc->sc_rx_work); + + o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); + +out: + if (new_sock) + sock_release(new_sock); + if (node) + o2nm_node_put(node); + if (sc) + sc_put(sc); + return ret; +} + +static void o2net_accept_many(void *arg) +{ + struct socket *sock = arg; + while (o2net_accept_one(sock) == 0) + cond_resched(); +} + +static void o2net_listen_data_ready(struct sock *sk, int bytes) +{ + void (*ready)(struct sock *sk, int bytes); + + read_lock(&sk->sk_callback_lock); + ready = sk->sk_user_data; + if (ready == NULL) { /* check for teardown race */ + ready = sk->sk_data_ready; + goto out; + } + + /* ->sk_data_ready is also called for a newly established child socket + * before it has been accepted and the acceptor has set up their + * data_ready.. we only want to queue listen work for our listening + * socket */ + if (sk->sk_state == TCP_LISTEN) { + mlog(ML_TCP, "bytes: %d\n", bytes); + queue_work(o2net_wq, &o2net_listen_work); + } + +out: + read_unlock(&sk->sk_callback_lock); + ready(sk, bytes); +} + +static int o2net_open_listening_sock(__be16 port) +{ + struct socket *sock = NULL; + int ret; + struct sockaddr_in sin = { + .sin_family = PF_INET, + .sin_addr = { .s_addr = (__force u32)htonl(INADDR_ANY) }, + .sin_port = (__force u16)port, + }; + + ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); + if (ret < 0) { + mlog(ML_ERROR, "unable to create socket, ret=%d\n", ret); + goto out; + } + + sock->sk->sk_allocation = GFP_ATOMIC; + + write_lock_bh(&sock->sk->sk_callback_lock); + sock->sk->sk_user_data = sock->sk->sk_data_ready; + sock->sk->sk_data_ready = o2net_listen_data_ready; + write_unlock_bh(&sock->sk->sk_callback_lock); + + o2net_listen_sock = sock; + INIT_WORK(&o2net_listen_work, o2net_accept_many, sock); + + sock->sk->sk_reuse = 1; + ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); + if (ret < 0) { + mlog(ML_ERROR, "unable to bind socket to port %d, ret=%d\n", + ntohs(port), ret); + goto out; + } + + ret = sock->ops->listen(sock, 64); + if (ret < 0) { + mlog(ML_ERROR, "unable to listen on port %d, ret=%d\n", + ntohs(port), ret); + } + +out: + if (ret) { + o2net_listen_sock = NULL; + if (sock) + sock_release(sock); + } + return ret; +} + +/* + * called from node manager when we should bring up our network listening + * socket. node manager handles all the serialization to only call this + * once and to match it with o2net_stop_listening(). note, + * o2nm_this_node() doesn't work yet as we're being called while it + * is being set up. + */ +int o2net_start_listening(struct o2nm_node *node) +{ + int ret = 0; + + BUG_ON(o2net_wq != NULL); + BUG_ON(o2net_listen_sock != NULL); + + mlog(ML_KTHREAD, "starting o2net thread...\n"); + o2net_wq = create_singlethread_workqueue("o2net"); + if (o2net_wq == NULL) { + mlog(ML_ERROR, "unable to launch o2net thread\n"); + return -ENOMEM; /* ? */ + } + + ret = o2net_open_listening_sock(node->nd_ipv4_port); + if (ret) { + destroy_workqueue(o2net_wq); + o2net_wq = NULL; + } else + o2quo_conn_up(node->nd_num); + + return ret; +} + +/* again, o2nm_this_node() doesn't work here as we're involved in + * tearing it down */ +void o2net_stop_listening(struct o2nm_node *node) +{ + struct socket *sock = o2net_listen_sock; + size_t i; + + BUG_ON(o2net_wq == NULL); + BUG_ON(o2net_listen_sock == NULL); + + /* stop the listening socket from generating work */ + write_lock_bh(&sock->sk->sk_callback_lock); + sock->sk->sk_data_ready = sock->sk->sk_user_data; + sock->sk->sk_user_data = NULL; + write_unlock_bh(&sock->sk->sk_callback_lock); + + for (i = 0; i < ARRAY_SIZE(o2net_nodes); i++) { + struct o2nm_node *node = o2nm_get_node_by_num(i); + if (node) { + o2net_disconnect_node(node); + o2nm_node_put(node); + } + } + + /* finish all work and tear down the work queue */ + mlog(ML_KTHREAD, "waiting for o2net thread to exit....\n"); + destroy_workqueue(o2net_wq); + o2net_wq = NULL; + + sock_release(o2net_listen_sock); + o2net_listen_sock = NULL; + + o2quo_conn_err(node->nd_num); +} + +/* ------------------------------------------------------------ */ + +int o2net_init(void) +{ + unsigned long i; + + o2quo_init(); + + o2net_hand = kcalloc(1, sizeof(struct o2net_handshake), GFP_KERNEL); + o2net_keep_req = kcalloc(1, sizeof(struct o2net_msg), GFP_KERNEL); + o2net_keep_resp = kcalloc(1, sizeof(struct o2net_msg), GFP_KERNEL); + if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) { + kfree(o2net_hand); + kfree(o2net_keep_req); + kfree(o2net_keep_resp); + return -ENOMEM; + } + + o2net_hand->protocol_version = cpu_to_be64(O2NET_PROTOCOL_VERSION); + o2net_hand->connector_id = cpu_to_be64(1); + + o2net_keep_req->magic = cpu_to_be16(O2NET_MSG_KEEP_REQ_MAGIC); + o2net_keep_resp->magic = cpu_to_be16(O2NET_MSG_KEEP_RESP_MAGIC); + + for (i = 0; i < ARRAY_SIZE(o2net_nodes); i++) { + struct o2net_node *nn = o2net_nn_from_num(i); + + spin_lock_init(&nn->nn_lock); + INIT_WORK(&nn->nn_connect_work, o2net_start_connect, nn); + INIT_WORK(&nn->nn_connect_expired, o2net_connect_expired, nn); + INIT_WORK(&nn->nn_still_up, o2net_still_up, nn); + /* until we see hb from a node we'll return einval */ + nn->nn_persistent_error = -ENOTCONN; + init_waitqueue_head(&nn->nn_sc_wq); + idr_init(&nn->nn_status_idr); + INIT_LIST_HEAD(&nn->nn_status_list); + } + + return 0; +} + +void o2net_exit(void) +{ + o2quo_exit(); + kfree(o2net_hand); + kfree(o2net_keep_req); + kfree(o2net_keep_resp); +} diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h new file mode 100644 index 0000000..a6f4585 --- /dev/null +++ b/fs/ocfs2/cluster/tcp.h @@ -0,0 +1,113 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * tcp.h + * + * Function prototypes + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef O2CLUSTER_TCP_H +#define O2CLUSTER_TCP_H + +#include +#ifdef __KERNEL__ +#include +#include +#else +#include +#endif +#include +#include + +struct o2net_msg +{ + __be16 magic; + __be16 data_len; + __be16 msg_type; + __be16 pad1; + __be32 sys_status; + __be32 status; + __be32 key; + __be32 msg_num; + __u8 buf[0]; +}; + +typedef int (o2net_msg_handler_func)(struct o2net_msg *msg, u32 len, void *data); + +#define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg)) + +/* TODO: figure this out.... */ +static inline int o2net_link_down(int err, struct socket *sock) +{ + if (sock) { + if (sock->sk->sk_state != TCP_ESTABLISHED && + sock->sk->sk_state != TCP_CLOSE_WAIT) + return 1; + } + + if (err >= 0) + return 0; + switch (err) { + /* ????????????????????????? */ + case -ERESTARTSYS: + case -EBADF: + /* When the server has died, an ICMP port unreachable + * message prompts ECONNREFUSED. */ + case -ECONNREFUSED: + case -ENOTCONN: + case -ECONNRESET: + case -EPIPE: + return 1; + } + return 0; +} + +enum { + O2NET_DRIVER_UNINITED, + O2NET_DRIVER_READY, +}; + +int o2net_init_tcp_sock(struct inode *inode); +int o2net_send_message(u32 msg_type, u32 key, void *data, u32 len, + u8 target_node, int *status); +int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *vec, + size_t veclen, u8 target_node, int *status); +int o2net_broadcast_message(u32 msg_type, u32 key, void *data, u32 len, + struct inode *group); + +int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, + o2net_msg_handler_func *func, void *data, + struct list_head *unreg_list); +void o2net_unregister_handler_list(struct list_head *list); + +struct o2nm_node; +int o2net_register_hb_callbacks(void); +void o2net_unregister_hb_callbacks(void); +int o2net_start_listening(struct o2nm_node *node); +void o2net_stop_listening(struct o2nm_node *node); +void o2net_disconnect_node(struct o2nm_node *node); + +int o2net_init(void); +void o2net_exit(void); +int o2net_proc_init(struct proc_dir_entry *parent); +void o2net_proc_exit(struct proc_dir_entry *parent); + +#endif /* O2CLUSTER_TCP_H */ diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h new file mode 100644 index 0000000..ff9e2e2 --- /dev/null +++ b/fs/ocfs2/cluster/tcp_internal.h @@ -0,0 +1,174 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef O2CLUSTER_TCP_INTERNAL_H +#define O2CLUSTER_TCP_INTERNAL_H + +#define O2NET_MSG_MAGIC ((u16)0xfa55) +#define O2NET_MSG_STATUS_MAGIC ((u16)0xfa56) +#define O2NET_MSG_KEEP_REQ_MAGIC ((u16)0xfa57) +#define O2NET_MSG_KEEP_RESP_MAGIC ((u16)0xfa58) + +/* same as hb delay, we're waiting for another node to recognize our hb */ +#define O2NET_RECONNECT_DELAY_MS O2HB_REGION_TIMEOUT_MS + +/* we're delaying our quorum decision so that heartbeat will have timed + * out truly dead nodes by the time we come around to making decisions + * on their number */ +#define O2NET_QUORUM_DELAY_MS ((o2hb_dead_threshold + 2) * O2HB_REGION_TIMEOUT_MS) + +#define O2NET_KEEPALIVE_DELAY_SECS 5 +#define O2NET_IDLE_TIMEOUT_SECS 10 + +/* + * This version number represents quite a lot, unfortunately. It not + * only represents the raw network message protocol on the wire but also + * locking semantics of the file system using the protocol. It should + * be somewhere else, I'm sure, but right now it isn't. + * + * New in version 2: + * - full 64 bit i_size in the metadata lock lvbs + * - introduction of "rw" lock and pushing meta/data locking down + */ +#define O2NET_PROTOCOL_VERSION 2ULL +struct o2net_handshake { + __be64 protocol_version; + __be64 connector_id; +}; + +struct o2net_node { + /* this is never called from int/bh */ + spinlock_t nn_lock; + + /* set the moment an sc is allocated and a connect is started */ + struct o2net_sock_container *nn_sc; + /* _valid is only set after the handshake passes and tx can happen */ + unsigned nn_sc_valid:1; + /* if this is set tx just returns it */ + int nn_persistent_error; + + /* threads waiting for an sc to arrive wait on the wq for generation + * to increase. it is increased when a connecting socket succeeds + * or fails or when an accepted socket is attached. */ + wait_queue_head_t nn_sc_wq; + + struct idr nn_status_idr; + struct list_head nn_status_list; + + /* connects are attempted from when heartbeat comes up until either hb + * goes down, the node is unconfigured, no connect attempts succeed + * before O2NET_CONN_IDLE_DELAY, or a connect succeeds. connect_work + * is queued from set_nn_state both from hb up and from itself if a + * connect attempt fails and so can be self-arming. shutdown is + * careful to first mark the nn such that no connects will be attempted + * before canceling delayed connect work and flushing the queue. */ + struct work_struct nn_connect_work; + unsigned long nn_last_connect_attempt; + + /* this is queued as nodes come up and is canceled when a connection is + * established. this expiring gives up on the node and errors out + * transmits */ + struct work_struct nn_connect_expired; + + /* after we give up on a socket we wait a while before deciding + * that it is still heartbeating and that we should do some + * quorum work */ + struct work_struct nn_still_up; +}; + +struct o2net_sock_container { + struct kref sc_kref; + /* the next two are vaild for the life time of the sc */ + struct socket *sc_sock; + struct o2nm_node *sc_node; + + /* all of these sc work structs hold refs on the sc while they are + * queued. they should not be able to ref a freed sc. the teardown + * race is with o2net_wq destruction in o2net_stop_listening() */ + + /* rx and connect work are generated from socket callbacks. sc + * shutdown removes the callbacks and then flushes the work queue */ + struct work_struct sc_rx_work; + struct work_struct sc_connect_work; + /* shutdown work is triggered in two ways. the simple way is + * for a code path calls ensure_shutdown which gets a lock, removes + * the sc from the nn, and queues the work. in this case the + * work is single-shot. the work is also queued from a sock + * callback, though, and in this case the work will find the sc + * still on the nn and will call ensure_shutdown itself.. this + * ends up triggering the shutdown work again, though nothing + * will be done in that second iteration. so work queue teardown + * has to be careful to remove the sc from the nn before waiting + * on the work queue so that the shutdown work doesn't remove the + * sc and rearm itself. + */ + struct work_struct sc_shutdown_work; + + struct timer_list sc_idle_timeout; + struct work_struct sc_keepalive_work; + + unsigned sc_handshake_ok:1; + + struct page *sc_page; + size_t sc_page_off; + + /* original handlers for the sockets */ + void (*sc_state_change)(struct sock *sk); + void (*sc_data_ready)(struct sock *sk, int bytes); + + struct timeval sc_tv_timer; + struct timeval sc_tv_data_ready; + struct timeval sc_tv_advance_start; + struct timeval sc_tv_advance_stop; + struct timeval sc_tv_func_start; + struct timeval sc_tv_func_stop; + u32 sc_msg_key; + u16 sc_msg_type; +}; + +struct o2net_msg_handler { + struct rb_node nh_node; + u32 nh_max_len; + u32 nh_msg_type; + u32 nh_key; + o2net_msg_handler_func *nh_func; + o2net_msg_handler_func *nh_func_data; + struct kref nh_kref; + struct list_head nh_unregister_item; +}; + +enum o2net_system_error { + O2NET_ERR_NONE = 0, + O2NET_ERR_NO_HNDLR, + O2NET_ERR_OVERFLOW, + O2NET_ERR_DIED, + O2NET_ERR_MAX +}; + +struct o2net_status_wait { + enum o2net_system_error ns_sys_status; + s32 ns_status; + int ns_id; + wait_queue_head_t ns_wq; + struct list_head ns_node_item; +}; + +#endif /* O2CLUSTER_TCP_INTERNAL_H */ -- cgit v1.1 From 6714d8e86bf443f6f7af50f9d432025649f091f5 Mon Sep 17 00:00:00 2001 From: Kurt Hackel Date: Thu, 15 Dec 2005 14:31:23 -0800 Subject: [PATCH] OCFS2: The Second Oracle Cluster Filesystem A distributed lock manager built with the cluster file system use case in mind. The OCFS2 dlm exposes a VMS style API, though things have been simplified internally. The only lock levels implemented currently are NLMODE, PRMODE and EXMODE. Signed-off-by: Mark Fasheh Signed-off-by: Kurt Hackel --- fs/ocfs2/dlm/Makefile | 6 + fs/ocfs2/dlm/dlmapi.h | 214 ++++ fs/ocfs2/dlm/dlmast.c | 466 ++++++++ fs/ocfs2/dlm/dlmcommon.h | 884 +++++++++++++++ fs/ocfs2/dlm/dlmconvert.c | 530 +++++++++ fs/ocfs2/dlm/dlmconvert.h | 35 + fs/ocfs2/dlm/dlmdebug.c | 246 ++++ fs/ocfs2/dlm/dlmdebug.h | 30 + fs/ocfs2/dlm/dlmdomain.c | 1469 ++++++++++++++++++++++++ fs/ocfs2/dlm/dlmdomain.h | 36 + fs/ocfs2/dlm/dlmlock.c | 676 +++++++++++ fs/ocfs2/dlm/dlmmaster.c | 2666 ++++++++++++++++++++++++++++++++++++++++++++ fs/ocfs2/dlm/dlmrecovery.c | 2132 +++++++++++++++++++++++++++++++++++ fs/ocfs2/dlm/dlmthread.c | 695 ++++++++++++ fs/ocfs2/dlm/dlmunlock.c | 672 +++++++++++ fs/ocfs2/dlm/dlmver.c | 42 + fs/ocfs2/dlm/dlmver.h | 31 + 17 files changed, 10830 insertions(+) create mode 100644 fs/ocfs2/dlm/Makefile create mode 100644 fs/ocfs2/dlm/dlmapi.h create mode 100644 fs/ocfs2/dlm/dlmast.c create mode 100644 fs/ocfs2/dlm/dlmcommon.h create mode 100644 fs/ocfs2/dlm/dlmconvert.c create mode 100644 fs/ocfs2/dlm/dlmconvert.h create mode 100644 fs/ocfs2/dlm/dlmdebug.c create mode 100644 fs/ocfs2/dlm/dlmdebug.h create mode 100644 fs/ocfs2/dlm/dlmdomain.c create mode 100644 fs/ocfs2/dlm/dlmdomain.h create mode 100644 fs/ocfs2/dlm/dlmlock.c create mode 100644 fs/ocfs2/dlm/dlmmaster.c create mode 100644 fs/ocfs2/dlm/dlmrecovery.c create mode 100644 fs/ocfs2/dlm/dlmthread.c create mode 100644 fs/ocfs2/dlm/dlmunlock.c create mode 100644 fs/ocfs2/dlm/dlmver.c create mode 100644 fs/ocfs2/dlm/dlmver.h diff --git a/fs/ocfs2/dlm/Makefile b/fs/ocfs2/dlm/Makefile new file mode 100644 index 0000000..2a5274b --- /dev/null +++ b/fs/ocfs2/dlm/Makefile @@ -0,0 +1,6 @@ +EXTRA_CFLAGS += -Ifs/ocfs2 + +obj-$(CONFIG_OCFS2_FS) += ocfs2_dlm.o + +ocfs2_dlm-objs := dlmdomain.o dlmdebug.o dlmthread.o dlmrecovery.o \ + dlmmaster.o dlmast.o dlmconvert.o dlmlock.o dlmunlock.o dlmver.o diff --git a/fs/ocfs2/dlm/dlmapi.h b/fs/ocfs2/dlm/dlmapi.h new file mode 100644 index 0000000..53652f5 --- /dev/null +++ b/fs/ocfs2/dlm/dlmapi.h @@ -0,0 +1,214 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmapi.h + * + * externally exported dlm interfaces + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef DLMAPI_H +#define DLMAPI_H + +struct dlm_lock; +struct dlm_ctxt; + +/* NOTE: changes made to this enum should be reflected in dlmdebug.c */ +enum dlm_status { + DLM_NORMAL = 0, /* 0: request in progress */ + DLM_GRANTED, /* 1: request granted */ + DLM_DENIED, /* 2: request denied */ + DLM_DENIED_NOLOCKS, /* 3: request denied, out of system resources */ + DLM_WORKING, /* 4: async request in progress */ + DLM_BLOCKED, /* 5: lock request blocked */ + DLM_BLOCKED_ORPHAN, /* 6: lock request blocked by a orphan lock*/ + DLM_DENIED_GRACE_PERIOD, /* 7: topological change in progress */ + DLM_SYSERR, /* 8: system error */ + DLM_NOSUPPORT, /* 9: unsupported */ + DLM_CANCELGRANT, /* 10: can't cancel convert: already granted */ + DLM_IVLOCKID, /* 11: bad lockid */ + DLM_SYNC, /* 12: synchronous request granted */ + DLM_BADTYPE, /* 13: bad resource type */ + DLM_BADRESOURCE, /* 14: bad resource handle */ + DLM_MAXHANDLES, /* 15: no more resource handles */ + DLM_NOCLINFO, /* 16: can't contact cluster manager */ + DLM_NOLOCKMGR, /* 17: can't contact lock manager */ + DLM_NOPURGED, /* 18: can't contact purge daemon */ + DLM_BADARGS, /* 19: bad api args */ + DLM_VOID, /* 20: no status */ + DLM_NOTQUEUED, /* 21: NOQUEUE was specified and request failed */ + DLM_IVBUFLEN, /* 22: invalid resource name length */ + DLM_CVTUNGRANT, /* 23: attempted to convert ungranted lock */ + DLM_BADPARAM, /* 24: invalid lock mode specified */ + DLM_VALNOTVALID, /* 25: value block has been invalidated */ + DLM_REJECTED, /* 26: request rejected, unrecognized client */ + DLM_ABORT, /* 27: blocked lock request cancelled */ + DLM_CANCEL, /* 28: conversion request cancelled */ + DLM_IVRESHANDLE, /* 29: invalid resource handle */ + DLM_DEADLOCK, /* 30: deadlock recovery refused this request */ + DLM_DENIED_NOASTS, /* 31: failed to allocate AST */ + DLM_FORWARD, /* 32: request must wait for primary's response */ + DLM_TIMEOUT, /* 33: timeout value for lock has expired */ + DLM_IVGROUPID, /* 34: invalid group specification */ + DLM_VERS_CONFLICT, /* 35: version conflicts prevent request handling */ + DLM_BAD_DEVICE_PATH, /* 36: Locks device does not exist or path wrong */ + DLM_NO_DEVICE_PERMISSION, /* 37: Client has insufficient pers for device */ + DLM_NO_CONTROL_DEVICE, /* 38: Cannot set options on opened device */ + + DLM_RECOVERING, /* 39: extension, allows caller to fail a lock + request if it is being recovered */ + DLM_MIGRATING, /* 40: extension, allows caller to fail a lock + request if it is being migrated */ + DLM_MAXSTATS, /* 41: upper limit for return code validation */ +}; + +/* for pretty-printing dlm_status error messages */ +const char *dlm_errmsg(enum dlm_status err); +/* for pretty-printing dlm_status error names */ +const char *dlm_errname(enum dlm_status err); + +/* Eventually the DLM will use standard errno values, but in the + * meantime this lets us track dlm errors as they bubble up. When we + * bring its error reporting into line with the rest of the stack, + * these can just be replaced with calls to mlog_errno. */ +#define dlm_error(st) do { \ + if ((st) != DLM_RECOVERING && \ + (st) != DLM_MIGRATING && \ + (st) != DLM_FORWARD) \ + mlog(ML_ERROR, "dlm status = %s\n", dlm_errname((st))); \ +} while (0) + +#define DLM_LKSB_UNUSED1 0x01 +#define DLM_LKSB_PUT_LVB 0x02 +#define DLM_LKSB_GET_LVB 0x04 +#define DLM_LKSB_UNUSED2 0x08 +#define DLM_LKSB_UNUSED3 0x10 +#define DLM_LKSB_UNUSED4 0x20 +#define DLM_LKSB_UNUSED5 0x40 +#define DLM_LKSB_UNUSED6 0x80 + +#define DLM_LVB_LEN 64 + +/* Callers are only allowed access to the lvb and status members of + * this struct. */ +struct dlm_lockstatus { + enum dlm_status status; + u32 flags; + struct dlm_lock *lockid; + char lvb[DLM_LVB_LEN]; +}; + +/* Valid lock modes. */ +#define LKM_IVMODE (-1) /* invalid mode */ +#define LKM_NLMODE 0 /* null lock */ +#define LKM_CRMODE 1 /* concurrent read unsupported */ +#define LKM_CWMODE 2 /* concurrent write unsupported */ +#define LKM_PRMODE 3 /* protected read */ +#define LKM_PWMODE 4 /* protected write unsupported */ +#define LKM_EXMODE 5 /* exclusive */ +#define LKM_MAXMODE 5 +#define LKM_MODEMASK 0xff + +/* Flags passed to dlmlock and dlmunlock: + * reserved: flags used by the "real" dlm + * only a few are supported by this dlm + * (U) = unsupported by ocfs2 dlm */ +#define LKM_ORPHAN 0x00000010 /* this lock is orphanable (U) */ +#define LKM_PARENTABLE 0x00000020 /* this lock was orphaned (U) */ +#define LKM_BLOCK 0x00000040 /* blocking lock request (U) */ +#define LKM_LOCAL 0x00000080 /* local lock request */ +#define LKM_VALBLK 0x00000100 /* lock value block request */ +#define LKM_NOQUEUE 0x00000200 /* non blocking request */ +#define LKM_CONVERT 0x00000400 /* conversion request */ +#define LKM_NODLCKWT 0x00000800 /* this lock wont deadlock (U) */ +#define LKM_UNLOCK 0x00001000 /* deallocate this lock */ +#define LKM_CANCEL 0x00002000 /* cancel conversion request */ +#define LKM_DEQALL 0x00004000 /* remove all locks held by proc (U) */ +#define LKM_INVVALBLK 0x00008000 /* invalidate lock value block */ +#define LKM_SYNCSTS 0x00010000 /* return synchronous status if poss (U) */ +#define LKM_TIMEOUT 0x00020000 /* lock request contains timeout (U) */ +#define LKM_SNGLDLCK 0x00040000 /* request can self-deadlock (U) */ +#define LKM_FINDLOCAL 0x00080000 /* find local lock request (U) */ +#define LKM_PROC_OWNED 0x00100000 /* owned by process, not group (U) */ +#define LKM_XID 0x00200000 /* use transaction id for deadlock (U) */ +#define LKM_XID_CONFLICT 0x00400000 /* do not allow lock inheritance (U) */ +#define LKM_FORCE 0x00800000 /* force unlock flag */ +#define LKM_REVVALBLK 0x01000000 /* temporary solution: re-validate + lock value block (U) */ +/* unused */ +#define LKM_UNUSED1 0x00000001 /* unused */ +#define LKM_UNUSED2 0x00000002 /* unused */ +#define LKM_UNUSED3 0x00000004 /* unused */ +#define LKM_UNUSED4 0x00000008 /* unused */ +#define LKM_UNUSED5 0x02000000 /* unused */ +#define LKM_UNUSED6 0x04000000 /* unused */ +#define LKM_UNUSED7 0x08000000 /* unused */ + +/* ocfs2 extensions: internal only + * should never be used by caller */ +#define LKM_MIGRATION 0x10000000 /* extension: lockres is to be migrated + to another node */ +#define LKM_PUT_LVB 0x20000000 /* extension: lvb is being passed + should be applied to lockres */ +#define LKM_GET_LVB 0x40000000 /* extension: lvb should be copied + from lockres when lock is granted */ +#define LKM_RECOVERY 0x80000000 /* extension: flag for recovery lock + used to avoid recovery rwsem */ + + +typedef void (dlm_astlockfunc_t)(void *); +typedef void (dlm_bastlockfunc_t)(void *, int); +typedef void (dlm_astunlockfunc_t)(void *, enum dlm_status); + +enum dlm_status dlmlock(struct dlm_ctxt *dlm, + int mode, + struct dlm_lockstatus *lksb, + int flags, + const char *name, + dlm_astlockfunc_t *ast, + void *data, + dlm_bastlockfunc_t *bast); + +enum dlm_status dlmunlock(struct dlm_ctxt *dlm, + struct dlm_lockstatus *lksb, + int flags, + dlm_astunlockfunc_t *unlockast, + void *data); + +struct dlm_ctxt * dlm_register_domain(const char *domain, u32 key); + +void dlm_unregister_domain(struct dlm_ctxt *dlm); + +void dlm_print_one_lock(struct dlm_lock *lockid); + +typedef void (dlm_eviction_func)(int, void *); +struct dlm_eviction_cb { + struct list_head ec_item; + dlm_eviction_func *ec_func; + void *ec_data; +}; +void dlm_setup_eviction_cb(struct dlm_eviction_cb *cb, + dlm_eviction_func *f, + void *data); +void dlm_register_eviction_cb(struct dlm_ctxt *dlm, + struct dlm_eviction_cb *cb); +void dlm_unregister_eviction_cb(struct dlm_eviction_cb *cb); + +#endif /* DLMAPI_H */ diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c new file mode 100644 index 0000000..8d17d28 --- /dev/null +++ b/fs/ocfs2/dlm/dlmast.c @@ -0,0 +1,466 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmast.c + * + * AST and BAST functionality for local and remote nodes + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" +#include "cluster/endian.h" + +#include "dlmapi.h" +#include "dlmcommon.h" + +#define MLOG_MASK_PREFIX ML_DLM +#include "cluster/masklog.h" + +static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + struct dlm_lock *lock); +static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock); + +/* Should be called as an ast gets queued to see if the new + * lock level will obsolete a pending bast. + * For example, if dlm_thread queued a bast for an EX lock that + * was blocking another EX, but before sending the bast the + * lock owner downconverted to NL, the bast is now obsolete. + * Only the ast should be sent. + * This is needed because the lock and convert paths can queue + * asts out-of-band (not waiting for dlm_thread) in order to + * allow for LKM_NOQUEUE to get immediate responses. */ +static int dlm_should_cancel_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) +{ + assert_spin_locked(&dlm->ast_lock); + assert_spin_locked(&lock->spinlock); + + if (lock->ml.highest_blocked == LKM_IVMODE) + return 0; + BUG_ON(lock->ml.highest_blocked == LKM_NLMODE); + + if (lock->bast_pending && + list_empty(&lock->bast_list)) + /* old bast already sent, ok */ + return 0; + + if (lock->ml.type == LKM_EXMODE) + /* EX blocks anything left, any bast still valid */ + return 0; + else if (lock->ml.type == LKM_NLMODE) + /* NL blocks nothing, no reason to send any bast, cancel it */ + return 1; + else if (lock->ml.highest_blocked != LKM_EXMODE) + /* PR only blocks EX */ + return 1; + + return 0; +} + +static void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock) +{ + mlog_entry_void(); + + BUG_ON(!dlm); + BUG_ON(!lock); + + assert_spin_locked(&dlm->ast_lock); + if (!list_empty(&lock->ast_list)) { + mlog(ML_ERROR, "ast list not empty!! pending=%d, newlevel=%d\n", + lock->ast_pending, lock->ml.type); + BUG(); + } + BUG_ON(!list_empty(&lock->ast_list)); + if (lock->ast_pending) + mlog(0, "lock has an ast getting flushed right now\n"); + + /* putting lock on list, add a ref */ + dlm_lock_get(lock); + spin_lock(&lock->spinlock); + + /* check to see if this ast obsoletes the bast */ + if (dlm_should_cancel_bast(dlm, lock)) { + struct dlm_lock_resource *res = lock->lockres; + mlog(0, "%s: cancelling bast for %.*s\n", + dlm->name, res->lockname.len, res->lockname.name); + lock->bast_pending = 0; + list_del_init(&lock->bast_list); + lock->ml.highest_blocked = LKM_IVMODE; + /* removing lock from list, remove a ref. guaranteed + * this won't be the last ref because of the get above, + * so res->spinlock will not be taken here */ + dlm_lock_put(lock); + /* free up the reserved bast that we are cancelling. + * guaranteed that this will not be the last reserved + * ast because *both* an ast and a bast were reserved + * to get to this point. the res->spinlock will not be + * taken here */ + dlm_lockres_release_ast(dlm, res); + } + list_add_tail(&lock->ast_list, &dlm->pending_asts); + lock->ast_pending = 1; + spin_unlock(&lock->spinlock); +} + +void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock) +{ + mlog_entry_void(); + + BUG_ON(!dlm); + BUG_ON(!lock); + + spin_lock(&dlm->ast_lock); + __dlm_queue_ast(dlm, lock); + spin_unlock(&dlm->ast_lock); +} + + +static void __dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) +{ + mlog_entry_void(); + + BUG_ON(!dlm); + BUG_ON(!lock); + assert_spin_locked(&dlm->ast_lock); + + BUG_ON(!list_empty(&lock->bast_list)); + if (lock->bast_pending) + mlog(0, "lock has a bast getting flushed right now\n"); + + /* putting lock on list, add a ref */ + dlm_lock_get(lock); + spin_lock(&lock->spinlock); + list_add_tail(&lock->bast_list, &dlm->pending_basts); + lock->bast_pending = 1; + spin_unlock(&lock->spinlock); +} + +void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock) +{ + mlog_entry_void(); + + BUG_ON(!dlm); + BUG_ON(!lock); + + spin_lock(&dlm->ast_lock); + __dlm_queue_bast(dlm, lock); + spin_unlock(&dlm->ast_lock); +} + +static void dlm_update_lvb(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + struct dlm_lock *lock) +{ + struct dlm_lockstatus *lksb = lock->lksb; + BUG_ON(!lksb); + + /* only updates if this node masters the lockres */ + if (res->owner == dlm->node_num) { + + spin_lock(&res->spinlock); + /* check the lksb flags for the direction */ + if (lksb->flags & DLM_LKSB_GET_LVB) { + mlog(0, "getting lvb from lockres for %s node\n", + lock->ml.node == dlm->node_num ? "master" : + "remote"); + memcpy(lksb->lvb, res->lvb, DLM_LVB_LEN); + } else if (lksb->flags & DLM_LKSB_PUT_LVB) { + mlog(0, "setting lvb from lockres for %s node\n", + lock->ml.node == dlm->node_num ? "master" : + "remote"); + memcpy(res->lvb, lksb->lvb, DLM_LVB_LEN); + } + spin_unlock(&res->spinlock); + } + + /* reset any lvb flags on the lksb */ + lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB); +} + +void dlm_do_local_ast(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + struct dlm_lock *lock) +{ + dlm_astlockfunc_t *fn; + struct dlm_lockstatus *lksb; + + mlog_entry_void(); + + lksb = lock->lksb; + fn = lock->ast; + BUG_ON(lock->ml.node != dlm->node_num); + + dlm_update_lvb(dlm, res, lock); + (*fn)(lock->astdata); +} + + +int dlm_do_remote_ast(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + struct dlm_lock *lock) +{ + int ret; + struct dlm_lockstatus *lksb; + int lksbflags; + + mlog_entry_void(); + + lksb = lock->lksb; + BUG_ON(lock->ml.node == dlm->node_num); + + lksbflags = lksb->flags; + dlm_update_lvb(dlm, res, lock); + + /* lock request came from another node + * go do the ast over there */ + ret = dlm_send_proxy_ast(dlm, res, lock, lksbflags); + return ret; +} + +void dlm_do_local_bast(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + struct dlm_lock *lock, int blocked_type) +{ + dlm_bastlockfunc_t *fn = lock->bast; + + mlog_entry_void(); + BUG_ON(lock->ml.node != dlm->node_num); + + (*fn)(lock->astdata, blocked_type); +} + + + +int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data) +{ + int ret; + unsigned int locklen; + struct dlm_ctxt *dlm = data; + struct dlm_lock_resource *res = NULL; + struct dlm_lock *lock = NULL; + struct dlm_proxy_ast *past = (struct dlm_proxy_ast *) msg->buf; + char *name; + struct list_head *iter, *head=NULL; + u64 cookie; + u32 flags; + + if (!dlm_grab(dlm)) { + dlm_error(DLM_REJECTED); + return DLM_REJECTED; + } + + mlog_bug_on_msg(!dlm_domain_fully_joined(dlm), + "Domain %s not fully joined!\n", dlm->name); + + name = past->name; + locklen = past->namelen; + cookie = be64_to_cpu(past->cookie); + flags = be32_to_cpu(past->flags); + + if (locklen > DLM_LOCKID_NAME_MAX) { + ret = DLM_IVBUFLEN; + mlog(ML_ERROR, "Invalid name length in proxy ast handler!\n"); + goto leave; + } + + if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) == + (LKM_PUT_LVB|LKM_GET_LVB)) { + mlog(ML_ERROR, "both PUT and GET lvb specified\n"); + ret = DLM_BADARGS; + goto leave; + } + + mlog(0, "lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" : + (flags & LKM_GET_LVB ? "get lvb" : "none")); + + mlog(0, "type=%d, blocked_type=%d\n", past->type, past->blocked_type); + + if (past->type != DLM_AST && + past->type != DLM_BAST) { + mlog(ML_ERROR, "Unknown ast type! %d, cookie=%"MLFu64", " + "name=%.*s\n", past->type, cookie, locklen, name); + ret = DLM_IVLOCKID; + goto leave; + } + + res = dlm_lookup_lockres(dlm, name, locklen); + if (!res) { + mlog(ML_ERROR, "got %sast for unknown lockres! " + "cookie=%"MLFu64", name=%.*s, namelen=%u\n", + past->type == DLM_AST ? "" : "b", + cookie, locklen, name, locklen); + ret = DLM_IVLOCKID; + goto leave; + } + + /* cannot get a proxy ast message if this node owns it */ + BUG_ON(res->owner == dlm->node_num); + + mlog(0, "lockres %.*s\n", res->lockname.len, res->lockname.name); + + spin_lock(&res->spinlock); + if (res->state & DLM_LOCK_RES_RECOVERING) { + mlog(0, "responding with DLM_RECOVERING!\n"); + ret = DLM_RECOVERING; + goto unlock_out; + } + if (res->state & DLM_LOCK_RES_MIGRATING) { + mlog(0, "responding with DLM_MIGRATING!\n"); + ret = DLM_MIGRATING; + goto unlock_out; + } + /* try convert queue for both ast/bast */ + head = &res->converting; + lock = NULL; + list_for_each(iter, head) { + lock = list_entry (iter, struct dlm_lock, list); + if (be64_to_cpu(lock->ml.cookie) == cookie) + goto do_ast; + } + + /* if not on convert, try blocked for ast, granted for bast */ + if (past->type == DLM_AST) + head = &res->blocked; + else + head = &res->granted; + + list_for_each(iter, head) { + lock = list_entry (iter, struct dlm_lock, list); + if (be64_to_cpu(lock->ml.cookie) == cookie) + goto do_ast; + } + + mlog(ML_ERROR, "got %sast for unknown lock! cookie=%"MLFu64", " + "name=%.*s, namelen=%u\n", + past->type == DLM_AST ? "" : "b", cookie, locklen, name, locklen); + + ret = DLM_NORMAL; +unlock_out: + spin_unlock(&res->spinlock); + goto leave; + +do_ast: + ret = DLM_NORMAL; + if (past->type == DLM_AST) { + /* do not alter lock refcount. switching lists. */ + list_del_init(&lock->list); + list_add_tail(&lock->list, &res->granted); + mlog(0, "ast: adding to granted list... type=%d, " + "convert_type=%d\n", lock->ml.type, lock->ml.convert_type); + if (lock->ml.convert_type != LKM_IVMODE) { + lock->ml.type = lock->ml.convert_type; + lock->ml.convert_type = LKM_IVMODE; + } else { + // should already be there.... + } + + lock->lksb->status = DLM_NORMAL; + + /* if we requested the lvb, fetch it into our lksb now */ + if (flags & LKM_GET_LVB) { + BUG_ON(!(lock->lksb->flags & DLM_LKSB_GET_LVB)); + memcpy(lock->lksb->lvb, past->lvb, DLM_LVB_LEN); + } + } + spin_unlock(&res->spinlock); + + if (past->type == DLM_AST) + dlm_do_local_ast(dlm, res, lock); + else + dlm_do_local_bast(dlm, res, lock, past->blocked_type); + +leave: + + if (res) + dlm_lockres_put(res); + + dlm_put(dlm); + return ret; +} + + + +int dlm_send_proxy_ast_msg(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + struct dlm_lock *lock, int msg_type, + int blocked_type, int flags) +{ + int ret = 0; + struct dlm_proxy_ast past; + struct kvec vec[2]; + size_t veclen = 1; + int status; + + mlog_entry("res %.*s, to=%u, type=%d, blocked_type=%d\n", + res->lockname.len, res->lockname.name, lock->ml.node, + msg_type, blocked_type); + + memset(&past, 0, sizeof(struct dlm_proxy_ast)); + past.node_idx = dlm->node_num; + past.type = msg_type; + past.blocked_type = blocked_type; + past.namelen = res->lockname.len; + memcpy(past.name, res->lockname.name, past.namelen); + past.cookie = lock->ml.cookie; + + vec[0].iov_len = sizeof(struct dlm_proxy_ast); + vec[0].iov_base = &past; + if (flags & DLM_LKSB_GET_LVB) { + mlog(0, "returning requested LVB data\n"); + be32_add_cpu(&past.flags, LKM_GET_LVB); + vec[1].iov_len = DLM_LVB_LEN; + vec[1].iov_base = lock->lksb->lvb; + veclen++; + } + + ret = o2net_send_message_vec(DLM_PROXY_AST_MSG, dlm->key, vec, veclen, + lock->ml.node, &status); + if (ret < 0) + mlog_errno(ret); + else { + if (status == DLM_RECOVERING) { + mlog(ML_ERROR, "sent AST to node %u, it thinks this " + "node is dead!\n", lock->ml.node); + BUG(); + } else if (status == DLM_MIGRATING) { + mlog(ML_ERROR, "sent AST to node %u, it returned " + "DLM_MIGRATING!\n", lock->ml.node); + BUG(); + } else if (status != DLM_NORMAL) { + mlog(ML_ERROR, "AST to node %u returned %d!\n", + lock->ml.node, status); + /* ignore it */ + } + ret = 0; + } + return ret; +} diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h new file mode 100644 index 0000000..3fecba0 --- /dev/null +++ b/fs/ocfs2/dlm/dlmcommon.h @@ -0,0 +1,884 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmcommon.h + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef DLMCOMMON_H +#define DLMCOMMON_H + +#include + +#define DLM_HB_NODE_DOWN_PRI (0xf000000) +#define DLM_HB_NODE_UP_PRI (0x8000000) + +#define DLM_LOCKID_NAME_MAX 32 + +#define DLM_DOMAIN_NAME_MAX_LEN 255 +#define DLM_LOCK_RES_OWNER_UNKNOWN O2NM_MAX_NODES +#define DLM_THREAD_SHUFFLE_INTERVAL 5 // flush everything every 5 passes +#define DLM_THREAD_MS 200 // flush at least every 200 ms + +#define DLM_HASH_BITS 7 +#define DLM_HASH_SIZE (1 << DLM_HASH_BITS) +#define DLM_HASH_MASK (DLM_HASH_SIZE - 1) + +enum dlm_ast_type { + DLM_AST = 0, + DLM_BAST, + DLM_ASTUNLOCK +}; + + +#define LKM_VALID_FLAGS (LKM_VALBLK | LKM_CONVERT | LKM_UNLOCK | \ + LKM_CANCEL | LKM_INVVALBLK | LKM_FORCE | \ + LKM_RECOVERY | LKM_LOCAL | LKM_NOQUEUE) + +#define DLM_RECOVERY_LOCK_NAME "$RECOVERY" +#define DLM_RECOVERY_LOCK_NAME_LEN 9 + +static inline int dlm_is_recovery_lock(const char *lock_name, int name_len) +{ + if (name_len == DLM_RECOVERY_LOCK_NAME_LEN && + memcmp(lock_name, DLM_RECOVERY_LOCK_NAME, name_len)==0) + return 1; + return 0; +} + +#define DLM_RECO_STATE_ACTIVE 0x0001 + +struct dlm_recovery_ctxt +{ + struct list_head resources; + struct list_head received; + struct list_head node_data; + u8 new_master; + u8 dead_node; + u16 state; + unsigned long node_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + wait_queue_head_t event; +}; + +enum dlm_ctxt_state { + DLM_CTXT_NEW = 0, + DLM_CTXT_JOINED, + DLM_CTXT_IN_SHUTDOWN, + DLM_CTXT_LEAVING, +}; + +struct dlm_ctxt +{ + struct list_head list; + struct list_head *resources; + struct list_head dirty_list; + struct list_head purge_list; + struct list_head pending_asts; + struct list_head pending_basts; + unsigned int purge_count; + spinlock_t spinlock; + spinlock_t ast_lock; + char *name; + u8 node_num; + u32 key; + u8 joining_node; + wait_queue_head_t dlm_join_events; + unsigned long live_nodes_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + unsigned long domain_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + unsigned long recovery_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + struct dlm_recovery_ctxt reco; + spinlock_t master_lock; + struct list_head master_list; + struct list_head mle_hb_events; + + /* these give a really vague idea of the system load */ + atomic_t local_resources; + atomic_t remote_resources; + atomic_t unknown_resources; + + /* NOTE: Next three are protected by dlm_domain_lock */ + struct kref dlm_refs; + enum dlm_ctxt_state dlm_state; + unsigned int num_joins; + + struct o2hb_callback_func dlm_hb_up; + struct o2hb_callback_func dlm_hb_down; + struct task_struct *dlm_thread_task; + struct task_struct *dlm_reco_thread_task; + wait_queue_head_t dlm_thread_wq; + wait_queue_head_t dlm_reco_thread_wq; + wait_queue_head_t ast_wq; + wait_queue_head_t migration_wq; + + struct work_struct dispatched_work; + struct list_head work_list; + spinlock_t work_lock; + struct list_head dlm_domain_handlers; + struct list_head dlm_eviction_callbacks; +}; + +/* these keventd work queue items are for less-frequently + * called functions that cannot be directly called from the + * net message handlers for some reason, usually because + * they need to send net messages of their own. */ +void dlm_dispatch_work(void *data); + +struct dlm_lock_resource; +struct dlm_work_item; + +typedef void (dlm_workfunc_t)(struct dlm_work_item *, void *); + +struct dlm_request_all_locks_priv +{ + u8 reco_master; + u8 dead_node; +}; + +struct dlm_mig_lockres_priv +{ + struct dlm_lock_resource *lockres; + u8 real_master; +}; + +struct dlm_assert_master_priv +{ + struct dlm_lock_resource *lockres; + u8 request_from; + u32 flags; + unsigned ignore_higher:1; +}; + + +struct dlm_work_item +{ + struct list_head list; + dlm_workfunc_t *func; + struct dlm_ctxt *dlm; + void *data; + union { + struct dlm_request_all_locks_priv ral; + struct dlm_mig_lockres_priv ml; + struct dlm_assert_master_priv am; + } u; +}; + +static inline void dlm_init_work_item(struct dlm_ctxt *dlm, + struct dlm_work_item *i, + dlm_workfunc_t *f, void *data) +{ + memset(i, 0, sizeof(*i)); + i->func = f; + INIT_LIST_HEAD(&i->list); + i->data = data; + i->dlm = dlm; /* must have already done a dlm_grab on this! */ +} + + + +static inline void __dlm_set_joining_node(struct dlm_ctxt *dlm, + u8 node) +{ + assert_spin_locked(&dlm->spinlock); + + dlm->joining_node = node; + wake_up(&dlm->dlm_join_events); +} + +#define DLM_LOCK_RES_UNINITED 0x00000001 +#define DLM_LOCK_RES_RECOVERING 0x00000002 +#define DLM_LOCK_RES_READY 0x00000004 +#define DLM_LOCK_RES_DIRTY 0x00000008 +#define DLM_LOCK_RES_IN_PROGRESS 0x00000010 +#define DLM_LOCK_RES_MIGRATING 0x00000020 + +#define DLM_PURGE_INTERVAL_MS (8 * 1000) + +struct dlm_lock_resource +{ + /* WARNING: Please see the comment in dlm_init_lockres before + * adding fields here. */ + struct list_head list; + struct kref refs; + + /* please keep these next 3 in this order + * some funcs want to iterate over all lists */ + struct list_head granted; + struct list_head converting; + struct list_head blocked; + + struct list_head dirty; + struct list_head recovering; // dlm_recovery_ctxt.resources list + + /* unused lock resources have their last_used stamped and are + * put on a list for the dlm thread to run. */ + struct list_head purge; + unsigned long last_used; + + unsigned migration_pending:1; + atomic_t asts_reserved; + spinlock_t spinlock; + wait_queue_head_t wq; + u8 owner; //node which owns the lock resource, or unknown + u16 state; + struct qstr lockname; + char lvb[DLM_LVB_LEN]; +}; + +struct dlm_migratable_lock +{ + __be64 cookie; + + /* these 3 are just padding for the in-memory structure, but + * list and flags are actually used when sent over the wire */ + __be16 pad1; + u8 list; // 0=granted, 1=converting, 2=blocked + u8 flags; + + s8 type; + s8 convert_type; + s8 highest_blocked; + u8 node; +}; // 16 bytes + +struct dlm_lock +{ + struct dlm_migratable_lock ml; + + struct list_head list; + struct list_head ast_list; + struct list_head bast_list; + struct dlm_lock_resource *lockres; + spinlock_t spinlock; + struct kref lock_refs; + + // ast and bast must be callable while holding a spinlock! + dlm_astlockfunc_t *ast; + dlm_bastlockfunc_t *bast; + void *astdata; + struct dlm_lockstatus *lksb; + unsigned ast_pending:1, + bast_pending:1, + convert_pending:1, + lock_pending:1, + cancel_pending:1, + unlock_pending:1, + lksb_kernel_allocated:1; +}; + + +#define DLM_LKSB_UNUSED1 0x01 +#define DLM_LKSB_PUT_LVB 0x02 +#define DLM_LKSB_GET_LVB 0x04 +#define DLM_LKSB_UNUSED2 0x08 +#define DLM_LKSB_UNUSED3 0x10 +#define DLM_LKSB_UNUSED4 0x20 +#define DLM_LKSB_UNUSED5 0x40 +#define DLM_LKSB_UNUSED6 0x80 + + +enum dlm_lockres_list { + DLM_GRANTED_LIST = 0, + DLM_CONVERTING_LIST, + DLM_BLOCKED_LIST +}; + +static inline struct list_head * +dlm_list_idx_to_ptr(struct dlm_lock_resource *res, enum dlm_lockres_list idx) +{ + struct list_head *ret = NULL; + if (idx == DLM_GRANTED_LIST) + ret = &res->granted; + else if (idx == DLM_CONVERTING_LIST) + ret = &res->converting; + else if (idx == DLM_BLOCKED_LIST) + ret = &res->blocked; + else + BUG(); + return ret; +} + + + + +struct dlm_node_iter +{ + unsigned long node_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + int curnode; +}; + + +enum { + DLM_MASTER_REQUEST_MSG = 500, + DLM_UNUSED_MSG1, /* 501 */ + DLM_ASSERT_MASTER_MSG, /* 502 */ + DLM_CREATE_LOCK_MSG, /* 503 */ + DLM_CONVERT_LOCK_MSG, /* 504 */ + DLM_PROXY_AST_MSG, /* 505 */ + DLM_UNLOCK_LOCK_MSG, /* 506 */ + DLM_UNUSED_MSG2, /* 507 */ + DLM_MIGRATE_REQUEST_MSG, /* 508 */ + DLM_MIG_LOCKRES_MSG, /* 509 */ + DLM_QUERY_JOIN_MSG, /* 510 */ + DLM_ASSERT_JOINED_MSG, /* 511 */ + DLM_CANCEL_JOIN_MSG, /* 512 */ + DLM_EXIT_DOMAIN_MSG, /* 513 */ + DLM_MASTER_REQUERY_MSG, /* 514 */ + DLM_LOCK_REQUEST_MSG, /* 515 */ + DLM_RECO_DATA_DONE_MSG, /* 516 */ + DLM_BEGIN_RECO_MSG, /* 517 */ + DLM_FINALIZE_RECO_MSG /* 518 */ +}; + +struct dlm_reco_node_data +{ + int state; + u8 node_num; + struct list_head list; +}; + +enum { + DLM_RECO_NODE_DATA_DEAD = -1, + DLM_RECO_NODE_DATA_INIT = 0, + DLM_RECO_NODE_DATA_REQUESTING, + DLM_RECO_NODE_DATA_REQUESTED, + DLM_RECO_NODE_DATA_RECEIVING, + DLM_RECO_NODE_DATA_DONE, + DLM_RECO_NODE_DATA_FINALIZE_SENT, +}; + + +enum { + DLM_MASTER_RESP_NO = 0, + DLM_MASTER_RESP_YES, + DLM_MASTER_RESP_MAYBE, + DLM_MASTER_RESP_ERROR +}; + + +struct dlm_master_request +{ + u8 node_idx; + u8 namelen; + __be16 pad1; + __be32 flags; + + u8 name[O2NM_MAX_NAME_LEN]; +}; + +#define DLM_ASSERT_MASTER_MLE_CLEANUP 0x00000001 +#define DLM_ASSERT_MASTER_REQUERY 0x00000002 +#define DLM_ASSERT_MASTER_FINISH_MIGRATION 0x00000004 +struct dlm_assert_master +{ + u8 node_idx; + u8 namelen; + __be16 pad1; + __be32 flags; + + u8 name[O2NM_MAX_NAME_LEN]; +}; + +struct dlm_migrate_request +{ + u8 master; + u8 new_master; + u8 namelen; + u8 pad1; + __be32 pad2; + u8 name[O2NM_MAX_NAME_LEN]; +}; + +struct dlm_master_requery +{ + u8 pad1; + u8 pad2; + u8 node_idx; + u8 namelen; + __be32 pad3; + u8 name[O2NM_MAX_NAME_LEN]; +}; + +#define DLM_MRES_RECOVERY 0x01 +#define DLM_MRES_MIGRATION 0x02 +#define DLM_MRES_ALL_DONE 0x04 + +/* + * We would like to get one whole lockres into a single network + * message whenever possible. Generally speaking, there will be + * at most one dlm_lock on a lockres for each node in the cluster, + * plus (infrequently) any additional locks coming in from userdlm. + * + * struct _dlm_lockres_page + * { + * dlm_migratable_lockres mres; + * dlm_migratable_lock ml[DLM_MAX_MIGRATABLE_LOCKS]; + * u8 pad[DLM_MIG_LOCKRES_RESERVED]; + * }; + * + * from ../cluster/tcp.h + * NET_MAX_PAYLOAD_BYTES (4096 - sizeof(net_msg)) + * (roughly 4080 bytes) + * and sizeof(dlm_migratable_lockres) = 112 bytes + * and sizeof(dlm_migratable_lock) = 16 bytes + * + * Choosing DLM_MAX_MIGRATABLE_LOCKS=240 and + * DLM_MIG_LOCKRES_RESERVED=128 means we have this: + * + * (DLM_MAX_MIGRATABLE_LOCKS * sizeof(dlm_migratable_lock)) + + * sizeof(dlm_migratable_lockres) + DLM_MIG_LOCKRES_RESERVED = + * NET_MAX_PAYLOAD_BYTES + * (240 * 16) + 112 + 128 = 4080 + * + * So a lockres would need more than 240 locks before it would + * use more than one network packet to recover. Not too bad. + */ +#define DLM_MAX_MIGRATABLE_LOCKS 240 + +struct dlm_migratable_lockres +{ + u8 master; + u8 lockname_len; + u8 num_locks; // locks sent in this structure + u8 flags; + __be32 total_locks; // locks to be sent for this migration cookie + __be64 mig_cookie; // cookie for this lockres migration + // or zero if not needed + // 16 bytes + u8 lockname[DLM_LOCKID_NAME_MAX]; + // 48 bytes + u8 lvb[DLM_LVB_LEN]; + // 112 bytes + struct dlm_migratable_lock ml[0]; // 16 bytes each, begins at byte 112 +}; +#define DLM_MIG_LOCKRES_MAX_LEN \ + (sizeof(struct dlm_migratable_lockres) + \ + (sizeof(struct dlm_migratable_lock) * \ + DLM_MAX_MIGRATABLE_LOCKS) ) + +/* from above, 128 bytes + * for some undetermined future use */ +#define DLM_MIG_LOCKRES_RESERVED (NET_MAX_PAYLOAD_BYTES - \ + DLM_MIG_LOCKRES_MAX_LEN) + +struct dlm_create_lock +{ + __be64 cookie; + + __be32 flags; + u8 pad1; + u8 node_idx; + s8 requested_type; + u8 namelen; + + u8 name[O2NM_MAX_NAME_LEN]; +}; + +struct dlm_convert_lock +{ + __be64 cookie; + + __be32 flags; + u8 pad1; + u8 node_idx; + s8 requested_type; + u8 namelen; + + u8 name[O2NM_MAX_NAME_LEN]; + + s8 lvb[0]; +}; +#define DLM_CONVERT_LOCK_MAX_LEN (sizeof(struct dlm_convert_lock)+DLM_LVB_LEN) + +struct dlm_unlock_lock +{ + __be64 cookie; + + __be32 flags; + __be16 pad1; + u8 node_idx; + u8 namelen; + + u8 name[O2NM_MAX_NAME_LEN]; + + s8 lvb[0]; +}; +#define DLM_UNLOCK_LOCK_MAX_LEN (sizeof(struct dlm_unlock_lock)+DLM_LVB_LEN) + +struct dlm_proxy_ast +{ + __be64 cookie; + + __be32 flags; + u8 node_idx; + u8 type; + u8 blocked_type; + u8 namelen; + + u8 name[O2NM_MAX_NAME_LEN]; + + s8 lvb[0]; +}; +#define DLM_PROXY_AST_MAX_LEN (sizeof(struct dlm_proxy_ast)+DLM_LVB_LEN) + +#define DLM_MOD_KEY (0x666c6172) +enum dlm_query_join_response { + JOIN_DISALLOW = 0, + JOIN_OK, + JOIN_OK_NO_MAP, +}; + +struct dlm_lock_request +{ + u8 node_idx; + u8 dead_node; + __be16 pad1; + __be32 pad2; +}; + +struct dlm_reco_data_done +{ + u8 node_idx; + u8 dead_node; + __be16 pad1; + __be32 pad2; + + /* unused for now */ + /* eventually we can use this to attempt + * lvb recovery based on each node's info */ + u8 reco_lvb[DLM_LVB_LEN]; +}; + +struct dlm_begin_reco +{ + u8 node_idx; + u8 dead_node; + __be16 pad1; + __be32 pad2; +}; + + +struct dlm_query_join_request +{ + u8 node_idx; + u8 pad1[2]; + u8 name_len; + u8 domain[O2NM_MAX_NAME_LEN]; +}; + +struct dlm_assert_joined +{ + u8 node_idx; + u8 pad1[2]; + u8 name_len; + u8 domain[O2NM_MAX_NAME_LEN]; +}; + +struct dlm_cancel_join +{ + u8 node_idx; + u8 pad1[2]; + u8 name_len; + u8 domain[O2NM_MAX_NAME_LEN]; +}; + +struct dlm_exit_domain +{ + u8 node_idx; + u8 pad1[3]; +}; + +struct dlm_finalize_reco +{ + u8 node_idx; + u8 dead_node; + __be16 pad1; + __be32 pad2; +}; + +static inline enum dlm_status +__dlm_lockres_state_to_status(struct dlm_lock_resource *res) +{ + enum dlm_status status = DLM_NORMAL; + + assert_spin_locked(&res->spinlock); + + if (res->state & DLM_LOCK_RES_RECOVERING) + status = DLM_RECOVERING; + else if (res->state & DLM_LOCK_RES_MIGRATING) + status = DLM_MIGRATING; + else if (res->state & DLM_LOCK_RES_IN_PROGRESS) + status = DLM_FORWARD; + + return status; +} + +struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie, + struct dlm_lockstatus *lksb); +void dlm_lock_get(struct dlm_lock *lock); +void dlm_lock_put(struct dlm_lock *lock); + +void dlm_lock_attach_lockres(struct dlm_lock *lock, + struct dlm_lock_resource *res); + +int dlm_create_lock_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data); + +void dlm_revert_pending_convert(struct dlm_lock_resource *res, + struct dlm_lock *lock); +void dlm_revert_pending_lock(struct dlm_lock_resource *res, + struct dlm_lock *lock); + +int dlm_unlock_lock_handler(struct o2net_msg *msg, u32 len, void *data); +void dlm_commit_pending_cancel(struct dlm_lock_resource *res, + struct dlm_lock *lock); +void dlm_commit_pending_unlock(struct dlm_lock_resource *res, + struct dlm_lock *lock); + +int dlm_launch_thread(struct dlm_ctxt *dlm); +void dlm_complete_thread(struct dlm_ctxt *dlm); +int dlm_launch_recovery_thread(struct dlm_ctxt *dlm); +void dlm_complete_recovery_thread(struct dlm_ctxt *dlm); +void dlm_wait_for_recovery(struct dlm_ctxt *dlm); + +void dlm_put(struct dlm_ctxt *dlm); +struct dlm_ctxt *dlm_grab(struct dlm_ctxt *dlm); +int dlm_domain_fully_joined(struct dlm_ctxt *dlm); + +void __dlm_lockres_calc_usage(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); +void dlm_lockres_calc_usage(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); +void dlm_purge_lockres(struct dlm_ctxt *dlm, + struct dlm_lock_resource *lockres); +void dlm_lockres_get(struct dlm_lock_resource *res); +void dlm_lockres_put(struct dlm_lock_resource *res); +void __dlm_unhash_lockres(struct dlm_lock_resource *res); +void __dlm_insert_lockres(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); +struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, + const char *name, + unsigned int len); +struct dlm_lock_resource * dlm_lookup_lockres(struct dlm_ctxt *dlm, + const char *name, + unsigned int len); + +int dlm_is_host_down(int errno); +void dlm_change_lockres_owner(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 owner); +struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm, + const char *lockid, + int flags); +struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm, + const char *name, + unsigned int namelen); + +void dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock); +void dlm_queue_bast(struct dlm_ctxt *dlm, struct dlm_lock *lock); +void dlm_do_local_ast(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock); +int dlm_do_remote_ast(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock); +void dlm_do_local_bast(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + int blocked_type); +int dlm_send_proxy_ast_msg(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + int msg_type, + int blocked_type, int flags); +static inline int dlm_send_proxy_bast(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + int blocked_type) +{ + return dlm_send_proxy_ast_msg(dlm, res, lock, DLM_BAST, + blocked_type, 0); +} + +static inline int dlm_send_proxy_ast(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + int flags) +{ + return dlm_send_proxy_ast_msg(dlm, res, lock, DLM_AST, + 0, flags); +} + +void dlm_print_one_lock_resource(struct dlm_lock_resource *res); +void __dlm_print_one_lock_resource(struct dlm_lock_resource *res); + +u8 dlm_nm_this_node(struct dlm_ctxt *dlm); +void dlm_kick_thread(struct dlm_ctxt *dlm, struct dlm_lock_resource *res); +void __dlm_dirty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res); + + +int dlm_nm_init(struct dlm_ctxt *dlm); +int dlm_heartbeat_init(struct dlm_ctxt *dlm); +void dlm_hb_node_down_cb(struct o2nm_node *node, int idx, void *data); +void dlm_hb_node_up_cb(struct o2nm_node *node, int idx, void *data); + +int dlm_lockres_is_dirty(struct dlm_ctxt *dlm, struct dlm_lock_resource *res); +int dlm_migrate_lockres(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 target); +int dlm_finish_migration(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 old_master); +void dlm_lockres_release_ast(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); +void __dlm_lockres_reserve_ast(struct dlm_lock_resource *res); + +int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_migrate_request_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_reco_data_done_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_begin_reco_handler(struct o2net_msg *msg, u32 len, void *data); +int dlm_finalize_reco_handler(struct o2net_msg *msg, u32 len, void *data); + +int dlm_dispatch_assert_master(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + int ignore_higher, + u8 request_from, + u32 flags); + + +int dlm_send_one_lockres(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_migratable_lockres *mres, + u8 send_to, + u8 flags); +void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); + +/* will exit holding res->spinlock, but may drop in function */ +void __dlm_wait_on_lockres_flags(struct dlm_lock_resource *res, int flags); +void __dlm_wait_on_lockres_flags_set(struct dlm_lock_resource *res, int flags); + +/* will exit holding res->spinlock, but may drop in function */ +static inline void __dlm_wait_on_lockres(struct dlm_lock_resource *res) +{ + __dlm_wait_on_lockres_flags(res, (DLM_LOCK_RES_IN_PROGRESS| + DLM_LOCK_RES_RECOVERING| + DLM_LOCK_RES_MIGRATING)); +} + + +int dlm_init_mle_cache(void); +void dlm_destroy_mle_cache(void); +void dlm_hb_event_notify_attached(struct dlm_ctxt *dlm, int idx, int node_up); +void dlm_clean_master_list(struct dlm_ctxt *dlm, + u8 dead_node); +int dlm_lock_basts_flushed(struct dlm_ctxt *dlm, struct dlm_lock *lock); + + +static inline const char * dlm_lock_mode_name(int mode) +{ + switch (mode) { + case LKM_EXMODE: + return "EX"; + case LKM_PRMODE: + return "PR"; + case LKM_NLMODE: + return "NL"; + } + return "UNKNOWN"; +} + + +static inline int dlm_lock_compatible(int existing, int request) +{ + /* NO_LOCK compatible with all */ + if (request == LKM_NLMODE || + existing == LKM_NLMODE) + return 1; + + /* EX incompatible with all non-NO_LOCK */ + if (request == LKM_EXMODE) + return 0; + + /* request must be PR, which is compatible with PR */ + if (existing == LKM_PRMODE) + return 1; + + return 0; +} + +static inline int dlm_lock_on_list(struct list_head *head, + struct dlm_lock *lock) +{ + struct list_head *iter; + struct dlm_lock *tmplock; + + list_for_each(iter, head) { + tmplock = list_entry(iter, struct dlm_lock, list); + if (tmplock == lock) + return 1; + } + return 0; +} + + +static inline enum dlm_status dlm_err_to_dlm_status(int err) +{ + enum dlm_status ret; + if (err == -ENOMEM) + ret = DLM_SYSERR; + else if (err == -ETIMEDOUT || o2net_link_down(err, NULL)) + ret = DLM_NOLOCKMGR; + else if (err == -EINVAL) + ret = DLM_BADPARAM; + else if (err == -ENAMETOOLONG) + ret = DLM_IVBUFLEN; + else + ret = DLM_BADARGS; + return ret; +} + + +static inline void dlm_node_iter_init(unsigned long *map, + struct dlm_node_iter *iter) +{ + memcpy(iter->node_map, map, sizeof(iter->node_map)); + iter->curnode = -1; +} + +static inline int dlm_node_iter_next(struct dlm_node_iter *iter) +{ + int bit; + bit = find_next_bit(iter->node_map, O2NM_MAX_NODES, iter->curnode+1); + if (bit >= O2NM_MAX_NODES) { + iter->curnode = O2NM_MAX_NODES; + return -ENOENT; + } + iter->curnode = bit; + return bit; +} + + + +#endif /* DLMCOMMON_H */ diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c new file mode 100644 index 0000000..6001b22 --- /dev/null +++ b/fs/ocfs2/dlm/dlmconvert.c @@ -0,0 +1,530 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmconvert.c + * + * underlying calls for lock conversion + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" +#include "dlmcommon.h" + +#include "dlmconvert.h" + +#define MLOG_MASK_PREFIX ML_DLM +#include "cluster/masklog.h" + +/* NOTE: __dlmconvert_master is the only function in here that + * needs a spinlock held on entry (res->spinlock) and it is the + * only one that holds a lock on exit (res->spinlock). + * All other functions in here need no locks and drop all of + * the locks that they acquire. */ +static enum dlm_status __dlmconvert_master(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags, + int type, int *call_ast, + int *kick_thread); +static enum dlm_status dlm_send_remote_convert_request(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags, int type); + +/* + * this is only called directly by dlmlock(), and only when the + * local node is the owner of the lockres + * locking: + * caller needs: none + * taken: takes and drops res->spinlock + * held on exit: none + * returns: see __dlmconvert_master + */ +enum dlm_status dlmconvert_master(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags, int type) +{ + int call_ast = 0, kick_thread = 0; + enum dlm_status status; + + spin_lock(&res->spinlock); + /* we are not in a network handler, this is fine */ + __dlm_wait_on_lockres(res); + __dlm_lockres_reserve_ast(res); + res->state |= DLM_LOCK_RES_IN_PROGRESS; + + status = __dlmconvert_master(dlm, res, lock, flags, type, + &call_ast, &kick_thread); + + res->state &= ~DLM_LOCK_RES_IN_PROGRESS; + spin_unlock(&res->spinlock); + wake_up(&res->wq); + if (status != DLM_NORMAL && status != DLM_NOTQUEUED) + dlm_error(status); + + /* either queue the ast or release it */ + if (call_ast) + dlm_queue_ast(dlm, lock); + else + dlm_lockres_release_ast(dlm, res); + + if (kick_thread) + dlm_kick_thread(dlm, res); + + return status; +} + +/* performs lock conversion at the lockres master site + * locking: + * caller needs: res->spinlock + * taken: takes and drops lock->spinlock + * held on exit: res->spinlock + * returns: DLM_NORMAL, DLM_NOTQUEUED, DLM_DENIED + * call_ast: whether ast should be called for this lock + * kick_thread: whether dlm_kick_thread should be called + */ +static enum dlm_status __dlmconvert_master(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags, + int type, int *call_ast, + int *kick_thread) +{ + enum dlm_status status = DLM_NORMAL; + struct list_head *iter; + struct dlm_lock *tmplock=NULL; + + assert_spin_locked(&res->spinlock); + + mlog_entry("type=%d, convert_type=%d, new convert_type=%d\n", + lock->ml.type, lock->ml.convert_type, type); + + spin_lock(&lock->spinlock); + + /* already converting? */ + if (lock->ml.convert_type != LKM_IVMODE) { + mlog(ML_ERROR, "attempted to convert a lock with a lock " + "conversion pending\n"); + status = DLM_DENIED; + goto unlock_exit; + } + + /* must be on grant queue to convert */ + if (!dlm_lock_on_list(&res->granted, lock)) { + mlog(ML_ERROR, "attempted to convert a lock not on grant " + "queue\n"); + status = DLM_DENIED; + goto unlock_exit; + } + + if (flags & LKM_VALBLK) { + switch (lock->ml.type) { + case LKM_EXMODE: + /* EX + LKM_VALBLK + convert == set lvb */ + mlog(0, "will set lvb: converting %s->%s\n", + dlm_lock_mode_name(lock->ml.type), + dlm_lock_mode_name(type)); + lock->lksb->flags |= DLM_LKSB_PUT_LVB; + break; + case LKM_PRMODE: + case LKM_NLMODE: + /* refetch if new level is not NL */ + if (type > LKM_NLMODE) { + mlog(0, "will fetch new value into " + "lvb: converting %s->%s\n", + dlm_lock_mode_name(lock->ml.type), + dlm_lock_mode_name(type)); + lock->lksb->flags |= DLM_LKSB_GET_LVB; + } else { + mlog(0, "will NOT fetch new value " + "into lvb: converting %s->%s\n", + dlm_lock_mode_name(lock->ml.type), + dlm_lock_mode_name(type)); + flags &= ~(LKM_VALBLK); + } + break; + } + } + + + /* in-place downconvert? */ + if (type <= lock->ml.type) + goto grant; + + /* upconvert from here on */ + status = DLM_NORMAL; + list_for_each(iter, &res->granted) { + tmplock = list_entry(iter, struct dlm_lock, list); + if (tmplock == lock) + continue; + if (!dlm_lock_compatible(tmplock->ml.type, type)) + goto switch_queues; + } + + list_for_each(iter, &res->converting) { + tmplock = list_entry(iter, struct dlm_lock, list); + if (!dlm_lock_compatible(tmplock->ml.type, type)) + goto switch_queues; + /* existing conversion requests take precedence */ + if (!dlm_lock_compatible(tmplock->ml.convert_type, type)) + goto switch_queues; + } + + /* fall thru to grant */ + +grant: + mlog(0, "res %.*s, granting %s lock\n", res->lockname.len, + res->lockname.name, dlm_lock_mode_name(type)); + /* immediately grant the new lock type */ + lock->lksb->status = DLM_NORMAL; + if (lock->ml.node == dlm->node_num) + mlog(0, "doing in-place convert for nonlocal lock\n"); + lock->ml.type = type; + status = DLM_NORMAL; + *call_ast = 1; + goto unlock_exit; + +switch_queues: + if (flags & LKM_NOQUEUE) { + mlog(0, "failed to convert NOQUEUE lock %.*s from " + "%d to %d...\n", res->lockname.len, res->lockname.name, + lock->ml.type, type); + status = DLM_NOTQUEUED; + goto unlock_exit; + } + mlog(0, "res %.*s, queueing...\n", res->lockname.len, + res->lockname.name); + + lock->ml.convert_type = type; + /* do not alter lock refcount. switching lists. */ + list_del_init(&lock->list); + list_add_tail(&lock->list, &res->converting); + +unlock_exit: + spin_unlock(&lock->spinlock); + if (status == DLM_DENIED) { + __dlm_print_one_lock_resource(res); + } + if (status == DLM_NORMAL) + *kick_thread = 1; + return status; +} + +void dlm_revert_pending_convert(struct dlm_lock_resource *res, + struct dlm_lock *lock) +{ + /* do not alter lock refcount. switching lists. */ + list_del_init(&lock->list); + list_add_tail(&lock->list, &res->granted); + lock->ml.convert_type = LKM_IVMODE; + lock->lksb->flags &= ~(DLM_LKSB_GET_LVB|DLM_LKSB_PUT_LVB); +} + +/* messages the master site to do lock conversion + * locking: + * caller needs: none + * taken: takes and drops res->spinlock, uses DLM_LOCK_RES_IN_PROGRESS + * held on exit: none + * returns: DLM_NORMAL, DLM_RECOVERING, status from remote node + */ +enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags, int type) +{ + enum dlm_status status; + + mlog(0, "type=%d, convert_type=%d, busy=%d\n", lock->ml.type, + lock->ml.convert_type, res->state & DLM_LOCK_RES_IN_PROGRESS); + + spin_lock(&res->spinlock); + if (res->state & DLM_LOCK_RES_RECOVERING) { + mlog(0, "bailing out early since res is RECOVERING " + "on secondary queue\n"); + /* __dlm_print_one_lock_resource(res); */ + status = DLM_RECOVERING; + goto bail; + } + /* will exit this call with spinlock held */ + __dlm_wait_on_lockres(res); + + if (lock->ml.convert_type != LKM_IVMODE) { + __dlm_print_one_lock_resource(res); + mlog(ML_ERROR, "converting a remote lock that is already " + "converting! (cookie=%"MLFu64", conv=%d)\n", + lock->ml.cookie, lock->ml.convert_type); + status = DLM_DENIED; + goto bail; + } + res->state |= DLM_LOCK_RES_IN_PROGRESS; + /* move lock to local convert queue */ + /* do not alter lock refcount. switching lists. */ + list_del_init(&lock->list); + list_add_tail(&lock->list, &res->converting); + lock->convert_pending = 1; + lock->ml.convert_type = type; + + if (flags & LKM_VALBLK) { + if (lock->ml.type == LKM_EXMODE) { + flags |= LKM_PUT_LVB; + lock->lksb->flags |= DLM_LKSB_PUT_LVB; + } else { + if (lock->ml.convert_type == LKM_NLMODE) + flags &= ~LKM_VALBLK; + else { + flags |= LKM_GET_LVB; + lock->lksb->flags |= DLM_LKSB_GET_LVB; + } + } + } + spin_unlock(&res->spinlock); + + /* no locks held here. + * need to wait for a reply as to whether it got queued or not. */ + status = dlm_send_remote_convert_request(dlm, res, lock, flags, type); + + spin_lock(&res->spinlock); + res->state &= ~DLM_LOCK_RES_IN_PROGRESS; + lock->convert_pending = 0; + /* if it failed, move it back to granted queue */ + if (status != DLM_NORMAL) { + if (status != DLM_NOTQUEUED) + dlm_error(status); + dlm_revert_pending_convert(res, lock); + } +bail: + spin_unlock(&res->spinlock); + + /* TODO: should this be a wake_one? */ + /* wake up any IN_PROGRESS waiters */ + wake_up(&res->wq); + + return status; +} + +/* sends DLM_CONVERT_LOCK_MSG to master site + * locking: + * caller needs: none + * taken: none + * held on exit: none + * returns: DLM_NOLOCKMGR, status from remote node + */ +static enum dlm_status dlm_send_remote_convert_request(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags, int type) +{ + struct dlm_convert_lock convert; + int tmpret; + enum dlm_status ret; + int status = 0; + struct kvec vec[2]; + size_t veclen = 1; + + mlog_entry("%.*s\n", res->lockname.len, res->lockname.name); + + memset(&convert, 0, sizeof(struct dlm_convert_lock)); + convert.node_idx = dlm->node_num; + convert.requested_type = type; + convert.cookie = lock->ml.cookie; + convert.namelen = res->lockname.len; + convert.flags = cpu_to_be32(flags); + memcpy(convert.name, res->lockname.name, convert.namelen); + + vec[0].iov_len = sizeof(struct dlm_convert_lock); + vec[0].iov_base = &convert; + + if (flags & LKM_PUT_LVB) { + /* extra data to send if we are updating lvb */ + vec[1].iov_len = DLM_LVB_LEN; + vec[1].iov_base = lock->lksb->lvb; + veclen++; + } + + tmpret = o2net_send_message_vec(DLM_CONVERT_LOCK_MSG, dlm->key, + vec, veclen, res->owner, &status); + if (tmpret >= 0) { + // successfully sent and received + ret = status; // this is already a dlm_status + if (ret == DLM_RECOVERING) { + mlog(0, "node %u returned DLM_RECOVERING from convert " + "message!\n", res->owner); + } else if (ret == DLM_MIGRATING) { + mlog(0, "node %u returned DLM_MIGRATING from convert " + "message!\n", res->owner); + } else if (ret == DLM_FORWARD) { + mlog(0, "node %u returned DLM_FORWARD from convert " + "message!\n", res->owner); + } else if (ret != DLM_NORMAL && ret != DLM_NOTQUEUED) + dlm_error(ret); + } else { + mlog_errno(tmpret); + if (dlm_is_host_down(tmpret)) { + ret = DLM_RECOVERING; + mlog(0, "node %u died so returning DLM_RECOVERING " + "from convert message!\n", res->owner); + } else { + ret = dlm_err_to_dlm_status(tmpret); + } + } + + return ret; +} + +/* handler for DLM_CONVERT_LOCK_MSG on master site + * locking: + * caller needs: none + * taken: takes and drop res->spinlock + * held on exit: none + * returns: DLM_NORMAL, DLM_IVLOCKID, DLM_BADARGS, + * status from __dlmconvert_master + */ +int dlm_convert_lock_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_convert_lock *cnv = (struct dlm_convert_lock *)msg->buf; + struct dlm_lock_resource *res = NULL; + struct list_head *iter; + struct dlm_lock *lock = NULL; + struct dlm_lockstatus *lksb; + enum dlm_status status = DLM_NORMAL; + u32 flags; + int call_ast = 0, kick_thread = 0; + + if (!dlm_grab(dlm)) { + dlm_error(DLM_REJECTED); + return DLM_REJECTED; + } + + mlog_bug_on_msg(!dlm_domain_fully_joined(dlm), + "Domain %s not fully joined!\n", dlm->name); + + if (cnv->namelen > DLM_LOCKID_NAME_MAX) { + status = DLM_IVBUFLEN; + dlm_error(status); + goto leave; + } + + flags = be32_to_cpu(cnv->flags); + + if ((flags & (LKM_PUT_LVB|LKM_GET_LVB)) == + (LKM_PUT_LVB|LKM_GET_LVB)) { + mlog(ML_ERROR, "both PUT and GET lvb specified\n"); + status = DLM_BADARGS; + goto leave; + } + + mlog(0, "lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" : + (flags & LKM_GET_LVB ? "get lvb" : "none")); + + status = DLM_IVLOCKID; + res = dlm_lookup_lockres(dlm, cnv->name, cnv->namelen); + if (!res) { + dlm_error(status); + goto leave; + } + + spin_lock(&res->spinlock); + list_for_each(iter, &res->granted) { + lock = list_entry(iter, struct dlm_lock, list); + if (lock->ml.cookie == cnv->cookie && + lock->ml.node == cnv->node_idx) { + dlm_lock_get(lock); + break; + } + lock = NULL; + } + spin_unlock(&res->spinlock); + if (!lock) { + status = DLM_IVLOCKID; + dlm_error(status); + goto leave; + } + + /* found the lock */ + lksb = lock->lksb; + + /* see if caller needed to get/put lvb */ + if (flags & LKM_PUT_LVB) { + BUG_ON(lksb->flags & (DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB)); + lksb->flags |= DLM_LKSB_PUT_LVB; + memcpy(&lksb->lvb[0], &cnv->lvb[0], DLM_LVB_LEN); + } else if (flags & LKM_GET_LVB) { + BUG_ON(lksb->flags & (DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB)); + lksb->flags |= DLM_LKSB_GET_LVB; + } + + spin_lock(&res->spinlock); + status = __dlm_lockres_state_to_status(res); + if (status == DLM_NORMAL) { + __dlm_lockres_reserve_ast(res); + res->state |= DLM_LOCK_RES_IN_PROGRESS; + status = __dlmconvert_master(dlm, res, lock, flags, + cnv->requested_type, + &call_ast, &kick_thread); + res->state &= ~DLM_LOCK_RES_IN_PROGRESS; + } + spin_unlock(&res->spinlock); + + if (status != DLM_NORMAL) { + if (status != DLM_NOTQUEUED) + dlm_error(status); + lksb->flags &= ~(DLM_LKSB_GET_LVB|DLM_LKSB_PUT_LVB); + } + +leave: + if (!lock) + mlog(ML_ERROR, "did not find lock to convert on grant queue! " + "cookie=%"MLFu64"\n", + cnv->cookie); + else + dlm_lock_put(lock); + + /* either queue the ast or release it */ + if (call_ast) + dlm_queue_ast(dlm, lock); + else + dlm_lockres_release_ast(dlm, res); + + if (kick_thread) + dlm_kick_thread(dlm, res); + + if (res) + dlm_lockres_put(res); + + dlm_put(dlm); + + return status; +} diff --git a/fs/ocfs2/dlm/dlmconvert.h b/fs/ocfs2/dlm/dlmconvert.h new file mode 100644 index 0000000..b2e3677 --- /dev/null +++ b/fs/ocfs2/dlm/dlmconvert.h @@ -0,0 +1,35 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmconvert.h + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef DLMCONVERT_H +#define DLMCONVERT_H + +enum dlm_status dlmconvert_master(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags, int type); +enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags, int type); + +#endif diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c new file mode 100644 index 0000000..f339fe27 --- /dev/null +++ b/fs/ocfs2/dlm/dlmdebug.c @@ -0,0 +1,246 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmdebug.c + * + * debug functionality for the dlm + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#include +#include +#include +#include +#include +#include + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" +#include "dlmcommon.h" +#include "dlmdebug.h" + +#include "dlmdomain.h" +#include "dlmdebug.h" + +#define MLOG_MASK_PREFIX ML_DLM +#include "cluster/masklog.h" + +void dlm_print_one_lock_resource(struct dlm_lock_resource *res) +{ + mlog(ML_NOTICE, "lockres: %.*s, owner=%u, state=%u\n", + res->lockname.len, res->lockname.name, + res->owner, res->state); + spin_lock(&res->spinlock); + __dlm_print_one_lock_resource(res); + spin_unlock(&res->spinlock); +} + +void __dlm_print_one_lock_resource(struct dlm_lock_resource *res) +{ + struct list_head *iter2; + struct dlm_lock *lock; + + assert_spin_locked(&res->spinlock); + + mlog(ML_NOTICE, "lockres: %.*s, owner=%u, state=%u\n", + res->lockname.len, res->lockname.name, + res->owner, res->state); + mlog(ML_NOTICE, " last used: %lu, on purge list: %s\n", + res->last_used, list_empty(&res->purge) ? "no" : "yes"); + mlog(ML_NOTICE, " granted queue: \n"); + list_for_each(iter2, &res->granted) { + lock = list_entry(iter2, struct dlm_lock, list); + spin_lock(&lock->spinlock); + mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " + "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", + lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, + list_empty(&lock->ast_list) ? 'y' : 'n', + lock->ast_pending ? 'y' : 'n', + list_empty(&lock->bast_list) ? 'y' : 'n', + lock->bast_pending ? 'y' : 'n'); + spin_unlock(&lock->spinlock); + } + mlog(ML_NOTICE, " converting queue: \n"); + list_for_each(iter2, &res->converting) { + lock = list_entry(iter2, struct dlm_lock, list); + spin_lock(&lock->spinlock); + mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " + "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", + lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, + list_empty(&lock->ast_list) ? 'y' : 'n', + lock->ast_pending ? 'y' : 'n', + list_empty(&lock->bast_list) ? 'y' : 'n', + lock->bast_pending ? 'y' : 'n'); + spin_unlock(&lock->spinlock); + } + mlog(ML_NOTICE, " blocked queue: \n"); + list_for_each(iter2, &res->blocked) { + lock = list_entry(iter2, struct dlm_lock, list); + spin_lock(&lock->spinlock); + mlog(ML_NOTICE, " type=%d, conv=%d, node=%u, " + "cookie=%"MLFu64", ast=(empty=%c,pend=%c), bast=(empty=%c,pend=%c)\n", + lock->ml.type, lock->ml.convert_type, lock->ml.node, lock->ml.cookie, + list_empty(&lock->ast_list) ? 'y' : 'n', + lock->ast_pending ? 'y' : 'n', + list_empty(&lock->bast_list) ? 'y' : 'n', + lock->bast_pending ? 'y' : 'n'); + spin_unlock(&lock->spinlock); + } +} + +void dlm_print_one_lock(struct dlm_lock *lockid) +{ + dlm_print_one_lock_resource(lockid->lockres); +} +EXPORT_SYMBOL_GPL(dlm_print_one_lock); + +void dlm_dump_lock_resources(struct dlm_ctxt *dlm) +{ + struct dlm_lock_resource *res; + struct list_head *iter; + struct list_head *bucket; + int i; + + mlog(ML_NOTICE, "struct dlm_ctxt: %s, node=%u, key=%u\n", + dlm->name, dlm->node_num, dlm->key); + if (!dlm || !dlm->name) { + mlog(ML_ERROR, "dlm=%p\n", dlm); + return; + } + + spin_lock(&dlm->spinlock); + for (i=0; iresources[i]); + list_for_each(iter, bucket) { + res = list_entry(iter, struct dlm_lock_resource, list); + dlm_print_one_lock_resource(res); + } + } + spin_unlock(&dlm->spinlock); +} + +static const char *dlm_errnames[] = { + [DLM_NORMAL] = "DLM_NORMAL", + [DLM_GRANTED] = "DLM_GRANTED", + [DLM_DENIED] = "DLM_DENIED", + [DLM_DENIED_NOLOCKS] = "DLM_DENIED_NOLOCKS", + [DLM_WORKING] = "DLM_WORKING", + [DLM_BLOCKED] = "DLM_BLOCKED", + [DLM_BLOCKED_ORPHAN] = "DLM_BLOCKED_ORPHAN", + [DLM_DENIED_GRACE_PERIOD] = "DLM_DENIED_GRACE_PERIOD", + [DLM_SYSERR] = "DLM_SYSERR", + [DLM_NOSUPPORT] = "DLM_NOSUPPORT", + [DLM_CANCELGRANT] = "DLM_CANCELGRANT", + [DLM_IVLOCKID] = "DLM_IVLOCKID", + [DLM_SYNC] = "DLM_SYNC", + [DLM_BADTYPE] = "DLM_BADTYPE", + [DLM_BADRESOURCE] = "DLM_BADRESOURCE", + [DLM_MAXHANDLES] = "DLM_MAXHANDLES", + [DLM_NOCLINFO] = "DLM_NOCLINFO", + [DLM_NOLOCKMGR] = "DLM_NOLOCKMGR", + [DLM_NOPURGED] = "DLM_NOPURGED", + [DLM_BADARGS] = "DLM_BADARGS", + [DLM_VOID] = "DLM_VOID", + [DLM_NOTQUEUED] = "DLM_NOTQUEUED", + [DLM_IVBUFLEN] = "DLM_IVBUFLEN", + [DLM_CVTUNGRANT] = "DLM_CVTUNGRANT", + [DLM_BADPARAM] = "DLM_BADPARAM", + [DLM_VALNOTVALID] = "DLM_VALNOTVALID", + [DLM_REJECTED] = "DLM_REJECTED", + [DLM_ABORT] = "DLM_ABORT", + [DLM_CANCEL] = "DLM_CANCEL", + [DLM_IVRESHANDLE] = "DLM_IVRESHANDLE", + [DLM_DEADLOCK] = "DLM_DEADLOCK", + [DLM_DENIED_NOASTS] = "DLM_DENIED_NOASTS", + [DLM_FORWARD] = "DLM_FORWARD", + [DLM_TIMEOUT] = "DLM_TIMEOUT", + [DLM_IVGROUPID] = "DLM_IVGROUPID", + [DLM_VERS_CONFLICT] = "DLM_VERS_CONFLICT", + [DLM_BAD_DEVICE_PATH] = "DLM_BAD_DEVICE_PATH", + [DLM_NO_DEVICE_PERMISSION] = "DLM_NO_DEVICE_PERMISSION", + [DLM_NO_CONTROL_DEVICE ] = "DLM_NO_CONTROL_DEVICE ", + [DLM_RECOVERING] = "DLM_RECOVERING", + [DLM_MIGRATING] = "DLM_MIGRATING", + [DLM_MAXSTATS] = "DLM_MAXSTATS", +}; + +static const char *dlm_errmsgs[] = { + [DLM_NORMAL] = "request in progress", + [DLM_GRANTED] = "request granted", + [DLM_DENIED] = "request denied", + [DLM_DENIED_NOLOCKS] = "request denied, out of system resources", + [DLM_WORKING] = "async request in progress", + [DLM_BLOCKED] = "lock request blocked", + [DLM_BLOCKED_ORPHAN] = "lock request blocked by a orphan lock", + [DLM_DENIED_GRACE_PERIOD] = "topological change in progress", + [DLM_SYSERR] = "system error", + [DLM_NOSUPPORT] = "unsupported", + [DLM_CANCELGRANT] = "can't cancel convert: already granted", + [DLM_IVLOCKID] = "bad lockid", + [DLM_SYNC] = "synchronous request granted", + [DLM_BADTYPE] = "bad resource type", + [DLM_BADRESOURCE] = "bad resource handle", + [DLM_MAXHANDLES] = "no more resource handles", + [DLM_NOCLINFO] = "can't contact cluster manager", + [DLM_NOLOCKMGR] = "can't contact lock manager", + [DLM_NOPURGED] = "can't contact purge daemon", + [DLM_BADARGS] = "bad api args", + [DLM_VOID] = "no status", + [DLM_NOTQUEUED] = "NOQUEUE was specified and request failed", + [DLM_IVBUFLEN] = "invalid resource name length", + [DLM_CVTUNGRANT] = "attempted to convert ungranted lock", + [DLM_BADPARAM] = "invalid lock mode specified", + [DLM_VALNOTVALID] = "value block has been invalidated", + [DLM_REJECTED] = "request rejected, unrecognized client", + [DLM_ABORT] = "blocked lock request cancelled", + [DLM_CANCEL] = "conversion request cancelled", + [DLM_IVRESHANDLE] = "invalid resource handle", + [DLM_DEADLOCK] = "deadlock recovery refused this request", + [DLM_DENIED_NOASTS] = "failed to allocate AST", + [DLM_FORWARD] = "request must wait for primary's response", + [DLM_TIMEOUT] = "timeout value for lock has expired", + [DLM_IVGROUPID] = "invalid group specification", + [DLM_VERS_CONFLICT] = "version conflicts prevent request handling", + [DLM_BAD_DEVICE_PATH] = "Locks device does not exist or path wrong", + [DLM_NO_DEVICE_PERMISSION] = "Client has insufficient perms for device", + [DLM_NO_CONTROL_DEVICE] = "Cannot set options on opened device ", + [DLM_RECOVERING] = "lock resource being recovered", + [DLM_MIGRATING] = "lock resource being migrated", + [DLM_MAXSTATS] = "invalid error number", +}; + +const char *dlm_errmsg(enum dlm_status err) +{ + if (err >= DLM_MAXSTATS || err < 0) + return dlm_errmsgs[DLM_MAXSTATS]; + return dlm_errmsgs[err]; +} +EXPORT_SYMBOL_GPL(dlm_errmsg); + +const char *dlm_errname(enum dlm_status err) +{ + if (err >= DLM_MAXSTATS || err < 0) + return dlm_errnames[DLM_MAXSTATS]; + return dlm_errnames[err]; +} +EXPORT_SYMBOL_GPL(dlm_errname); diff --git a/fs/ocfs2/dlm/dlmdebug.h b/fs/ocfs2/dlm/dlmdebug.h new file mode 100644 index 0000000..6858510 --- /dev/null +++ b/fs/ocfs2/dlm/dlmdebug.h @@ -0,0 +1,30 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmdebug.h + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef DLMDEBUG_H +#define DLMDEBUG_H + +void dlm_dump_lock_resources(struct dlm_ctxt *dlm); + +#endif diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c new file mode 100644 index 0000000..da3c220 --- /dev/null +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -0,0 +1,1469 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmdomain.c + * + * defines domain join / leave apis + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" +#include "dlmcommon.h" + +#include "dlmdebug.h" +#include "dlmdomain.h" + +#include "dlmver.h" + +#define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_DOMAIN) +#include "cluster/masklog.h" + +/* + * + * spinlock lock ordering: if multiple locks are needed, obey this ordering: + * dlm_domain_lock + * struct dlm_ctxt->spinlock + * struct dlm_lock_resource->spinlock + * struct dlm_ctxt->master_lock + * struct dlm_ctxt->ast_lock + * dlm_master_list_entry->spinlock + * dlm_lock->spinlock + * + */ + +spinlock_t dlm_domain_lock = SPIN_LOCK_UNLOCKED; +LIST_HEAD(dlm_domains); +static DECLARE_WAIT_QUEUE_HEAD(dlm_domain_events); + +#define DLM_DOMAIN_BACKOFF_MS 200 + +static int dlm_query_join_handler(struct o2net_msg *msg, u32 len, void *data); +static int dlm_assert_joined_handler(struct o2net_msg *msg, u32 len, void *data); +static int dlm_cancel_join_handler(struct o2net_msg *msg, u32 len, void *data); +static int dlm_exit_domain_handler(struct o2net_msg *msg, u32 len, void *data); + +static void dlm_unregister_domain_handlers(struct dlm_ctxt *dlm); + +void __dlm_unhash_lockres(struct dlm_lock_resource *lockres) +{ + list_del_init(&lockres->list); + dlm_lockres_put(lockres); +} + +void __dlm_insert_lockres(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + struct list_head *bucket; + struct qstr *q; + + assert_spin_locked(&dlm->spinlock); + + q = &res->lockname; + q->hash = full_name_hash(q->name, q->len); + bucket = &(dlm->resources[q->hash & DLM_HASH_MASK]); + + /* get a reference for our hashtable */ + dlm_lockres_get(res); + + list_add_tail(&res->list, bucket); +} + +struct dlm_lock_resource * __dlm_lookup_lockres(struct dlm_ctxt *dlm, + const char *name, + unsigned int len) +{ + unsigned int hash; + struct list_head *iter; + struct dlm_lock_resource *tmpres=NULL; + struct list_head *bucket; + + mlog_entry("%.*s\n", len, name); + + assert_spin_locked(&dlm->spinlock); + + hash = full_name_hash(name, len); + + bucket = &(dlm->resources[hash & DLM_HASH_MASK]); + + /* check for pre-existing lock */ + list_for_each(iter, bucket) { + tmpres = list_entry(iter, struct dlm_lock_resource, list); + if (tmpres->lockname.len == len && + memcmp(tmpres->lockname.name, name, len) == 0) { + dlm_lockres_get(tmpres); + break; + } + + tmpres = NULL; + } + return tmpres; +} + +struct dlm_lock_resource * dlm_lookup_lockres(struct dlm_ctxt *dlm, + const char *name, + unsigned int len) +{ + struct dlm_lock_resource *res; + + spin_lock(&dlm->spinlock); + res = __dlm_lookup_lockres(dlm, name, len); + spin_unlock(&dlm->spinlock); + return res; +} + +static struct dlm_ctxt * __dlm_lookup_domain_full(const char *domain, int len) +{ + struct dlm_ctxt *tmp = NULL; + struct list_head *iter; + + assert_spin_locked(&dlm_domain_lock); + + /* tmp->name here is always NULL terminated, + * but domain may not be! */ + list_for_each(iter, &dlm_domains) { + tmp = list_entry (iter, struct dlm_ctxt, list); + if (strlen(tmp->name) == len && + memcmp(tmp->name, domain, len)==0) + break; + tmp = NULL; + } + + return tmp; +} + +/* For null terminated domain strings ONLY */ +static struct dlm_ctxt * __dlm_lookup_domain(const char *domain) +{ + assert_spin_locked(&dlm_domain_lock); + + return __dlm_lookup_domain_full(domain, strlen(domain)); +} + + +/* returns true on one of two conditions: + * 1) the domain does not exist + * 2) the domain exists and it's state is "joined" */ +static int dlm_wait_on_domain_helper(const char *domain) +{ + int ret = 0; + struct dlm_ctxt *tmp = NULL; + + spin_lock(&dlm_domain_lock); + + tmp = __dlm_lookup_domain(domain); + if (!tmp) + ret = 1; + else if (tmp->dlm_state == DLM_CTXT_JOINED) + ret = 1; + + spin_unlock(&dlm_domain_lock); + return ret; +} + +static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) +{ + if (dlm->resources) + free_page((unsigned long) dlm->resources); + + if (dlm->name) + kfree(dlm->name); + + kfree(dlm); +} + +/* A little strange - this function will be called while holding + * dlm_domain_lock and is expected to be holding it on the way out. We + * will however drop and reacquire it multiple times */ +static void dlm_ctxt_release(struct kref *kref) +{ + struct dlm_ctxt *dlm; + + dlm = container_of(kref, struct dlm_ctxt, dlm_refs); + + BUG_ON(dlm->num_joins); + BUG_ON(dlm->dlm_state == DLM_CTXT_JOINED); + + /* we may still be in the list if we hit an error during join. */ + list_del_init(&dlm->list); + + spin_unlock(&dlm_domain_lock); + + mlog(0, "freeing memory from domain %s\n", dlm->name); + + wake_up(&dlm_domain_events); + + dlm_free_ctxt_mem(dlm); + + spin_lock(&dlm_domain_lock); +} + +void dlm_put(struct dlm_ctxt *dlm) +{ + spin_lock(&dlm_domain_lock); + kref_put(&dlm->dlm_refs, dlm_ctxt_release); + spin_unlock(&dlm_domain_lock); +} + +static void __dlm_get(struct dlm_ctxt *dlm) +{ + kref_get(&dlm->dlm_refs); +} + +/* given a questionable reference to a dlm object, gets a reference if + * it can find it in the list, otherwise returns NULL in which case + * you shouldn't trust your pointer. */ +struct dlm_ctxt *dlm_grab(struct dlm_ctxt *dlm) +{ + struct list_head *iter; + struct dlm_ctxt *target = NULL; + + spin_lock(&dlm_domain_lock); + + list_for_each(iter, &dlm_domains) { + target = list_entry (iter, struct dlm_ctxt, list); + + if (target == dlm) { + __dlm_get(target); + break; + } + + target = NULL; + } + + spin_unlock(&dlm_domain_lock); + + return target; +} + +int dlm_domain_fully_joined(struct dlm_ctxt *dlm) +{ + int ret; + + spin_lock(&dlm_domain_lock); + ret = (dlm->dlm_state == DLM_CTXT_JOINED) || + (dlm->dlm_state == DLM_CTXT_IN_SHUTDOWN); + spin_unlock(&dlm_domain_lock); + + return ret; +} + +static void dlm_complete_dlm_shutdown(struct dlm_ctxt *dlm) +{ + dlm_unregister_domain_handlers(dlm); + dlm_complete_thread(dlm); + dlm_complete_recovery_thread(dlm); + + /* We've left the domain. Now we can take ourselves out of the + * list and allow the kref stuff to help us free the + * memory. */ + spin_lock(&dlm_domain_lock); + list_del_init(&dlm->list); + spin_unlock(&dlm_domain_lock); + + /* Wake up anyone waiting for us to remove this domain */ + wake_up(&dlm_domain_events); +} + +static void dlm_migrate_all_locks(struct dlm_ctxt *dlm) +{ + int i; + struct dlm_lock_resource *res; + + mlog(0, "Migrating locks from domain %s\n", dlm->name); +restart: + spin_lock(&dlm->spinlock); + for (i=0; iresources[i])) { + res = list_entry(dlm->resources[i].next, + struct dlm_lock_resource, list); + /* need reference when manually grabbing lockres */ + dlm_lockres_get(res); + /* this should unhash the lockres + * and exit with dlm->spinlock */ + mlog(0, "purging res=%p\n", res); + if (dlm_lockres_is_dirty(dlm, res)) { + /* HACK! this should absolutely go. + * need to figure out why some empty + * lockreses are still marked dirty */ + mlog(ML_ERROR, "lockres %.*s dirty!\n", + res->lockname.len, res->lockname.name); + + spin_unlock(&dlm->spinlock); + dlm_kick_thread(dlm, res); + wait_event(dlm->ast_wq, !dlm_lockres_is_dirty(dlm, res)); + dlm_lockres_put(res); + goto restart; + } + dlm_purge_lockres(dlm, res); + dlm_lockres_put(res); + } + } + spin_unlock(&dlm->spinlock); + + mlog(0, "DONE Migrating locks from domain %s\n", dlm->name); +} + +static int dlm_no_joining_node(struct dlm_ctxt *dlm) +{ + int ret; + + spin_lock(&dlm->spinlock); + ret = dlm->joining_node == DLM_LOCK_RES_OWNER_UNKNOWN; + spin_unlock(&dlm->spinlock); + + return ret; +} + +static void dlm_mark_domain_leaving(struct dlm_ctxt *dlm) +{ + /* Yikes, a double spinlock! I need domain_lock for the dlm + * state and the dlm spinlock for join state... Sorry! */ +again: + spin_lock(&dlm_domain_lock); + spin_lock(&dlm->spinlock); + + if (dlm->joining_node != DLM_LOCK_RES_OWNER_UNKNOWN) { + mlog(0, "Node %d is joining, we wait on it.\n", + dlm->joining_node); + spin_unlock(&dlm->spinlock); + spin_unlock(&dlm_domain_lock); + + wait_event(dlm->dlm_join_events, dlm_no_joining_node(dlm)); + goto again; + } + + dlm->dlm_state = DLM_CTXT_LEAVING; + spin_unlock(&dlm->spinlock); + spin_unlock(&dlm_domain_lock); +} + +static void __dlm_print_nodes(struct dlm_ctxt *dlm) +{ + int node = -1; + + assert_spin_locked(&dlm->spinlock); + + mlog(ML_NOTICE, "Nodes in my domain (\"%s\"):\n", dlm->name); + + while ((node = find_next_bit(dlm->domain_map, O2NM_MAX_NODES, + node + 1)) < O2NM_MAX_NODES) { + mlog(ML_NOTICE, " node %d\n", node); + } +} + +static int dlm_exit_domain_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + unsigned int node; + struct dlm_exit_domain *exit_msg = (struct dlm_exit_domain *) msg->buf; + + mlog_entry("%p %u %p", msg, len, data); + + if (!dlm_grab(dlm)) + return 0; + + node = exit_msg->node_idx; + + mlog(0, "Node %u leaves domain %s\n", node, dlm->name); + + spin_lock(&dlm->spinlock); + clear_bit(node, dlm->domain_map); + __dlm_print_nodes(dlm); + + /* notify anything attached to the heartbeat events */ + dlm_hb_event_notify_attached(dlm, node, 0); + + spin_unlock(&dlm->spinlock); + + dlm_put(dlm); + + return 0; +} + +static int dlm_send_one_domain_exit(struct dlm_ctxt *dlm, + unsigned int node) +{ + int status; + struct dlm_exit_domain leave_msg; + + mlog(0, "Asking node %u if we can leave the domain %s me = %u\n", + node, dlm->name, dlm->node_num); + + memset(&leave_msg, 0, sizeof(leave_msg)); + leave_msg.node_idx = dlm->node_num; + + status = o2net_send_message(DLM_EXIT_DOMAIN_MSG, dlm->key, + &leave_msg, sizeof(leave_msg), node, + NULL); + + mlog(0, "status return %d from o2net_send_message\n", status); + + return status; +} + + +static void dlm_leave_domain(struct dlm_ctxt *dlm) +{ + int node, clear_node, status; + + /* At this point we've migrated away all our locks and won't + * accept mastership of new ones. The dlm is responsible for + * almost nothing now. We make sure not to confuse any joining + * nodes and then commence shutdown procedure. */ + + spin_lock(&dlm->spinlock); + /* Clear ourselves from the domain map */ + clear_bit(dlm->node_num, dlm->domain_map); + while ((node = find_next_bit(dlm->domain_map, O2NM_MAX_NODES, + 0)) < O2NM_MAX_NODES) { + /* Drop the dlm spinlock. This is safe wrt the domain_map. + * -nodes cannot be added now as the + * query_join_handlers knows to respond with OK_NO_MAP + * -we catch the right network errors if a node is + * removed from the map while we're sending him the + * exit message. */ + spin_unlock(&dlm->spinlock); + + clear_node = 1; + + status = dlm_send_one_domain_exit(dlm, node); + if (status < 0 && + status != -ENOPROTOOPT && + status != -ENOTCONN) { + mlog(ML_NOTICE, "Error %d sending domain exit message " + "to node %d\n", status, node); + + /* Not sure what to do here but lets sleep for + * a bit in case this was a transient + * error... */ + msleep(DLM_DOMAIN_BACKOFF_MS); + clear_node = 0; + } + + spin_lock(&dlm->spinlock); + /* If we're not clearing the node bit then we intend + * to loop back around to try again. */ + if (clear_node) + clear_bit(node, dlm->domain_map); + } + spin_unlock(&dlm->spinlock); +} + +int dlm_joined(struct dlm_ctxt *dlm) +{ + int ret = 0; + + spin_lock(&dlm_domain_lock); + + if (dlm->dlm_state == DLM_CTXT_JOINED) + ret = 1; + + spin_unlock(&dlm_domain_lock); + + return ret; +} + +int dlm_shutting_down(struct dlm_ctxt *dlm) +{ + int ret = 0; + + spin_lock(&dlm_domain_lock); + + if (dlm->dlm_state == DLM_CTXT_IN_SHUTDOWN) + ret = 1; + + spin_unlock(&dlm_domain_lock); + + return ret; +} + +void dlm_unregister_domain(struct dlm_ctxt *dlm) +{ + int leave = 0; + + spin_lock(&dlm_domain_lock); + BUG_ON(dlm->dlm_state != DLM_CTXT_JOINED); + BUG_ON(!dlm->num_joins); + + dlm->num_joins--; + if (!dlm->num_joins) { + /* We mark it "in shutdown" now so new register + * requests wait until we've completely left the + * domain. Don't use DLM_CTXT_LEAVING yet as we still + * want new domain joins to communicate with us at + * least until we've completed migration of our + * resources. */ + dlm->dlm_state = DLM_CTXT_IN_SHUTDOWN; + leave = 1; + } + spin_unlock(&dlm_domain_lock); + + if (leave) { + mlog(0, "shutting down domain %s\n", dlm->name); + + /* We changed dlm state, notify the thread */ + dlm_kick_thread(dlm, NULL); + + dlm_migrate_all_locks(dlm); + dlm_mark_domain_leaving(dlm); + dlm_leave_domain(dlm); + dlm_complete_dlm_shutdown(dlm); + } + dlm_put(dlm); +} +EXPORT_SYMBOL_GPL(dlm_unregister_domain); + +static int dlm_query_join_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_query_join_request *query; + enum dlm_query_join_response response; + struct dlm_ctxt *dlm = NULL; + + query = (struct dlm_query_join_request *) msg->buf; + + mlog(0, "node %u wants to join domain %s\n", query->node_idx, + query->domain); + + /* + * If heartbeat doesn't consider the node live, tell it + * to back off and try again. This gives heartbeat a chance + * to catch up. + */ + if (!o2hb_check_node_heartbeating(query->node_idx)) { + mlog(0, "node %u is not in our live map yet\n", + query->node_idx); + + response = JOIN_DISALLOW; + goto respond; + } + + response = JOIN_OK_NO_MAP; + + spin_lock(&dlm_domain_lock); + dlm = __dlm_lookup_domain_full(query->domain, query->name_len); + /* Once the dlm ctxt is marked as leaving then we don't want + * to be put in someone's domain map. */ + if (dlm && dlm->dlm_state != DLM_CTXT_LEAVING) { + spin_lock(&dlm->spinlock); + + if (dlm->dlm_state == DLM_CTXT_NEW && + dlm->joining_node == DLM_LOCK_RES_OWNER_UNKNOWN) { + /*If this is a brand new context and we + * haven't started our join process yet, then + * the other node won the race. */ + response = JOIN_OK_NO_MAP; + } else if (dlm->joining_node != DLM_LOCK_RES_OWNER_UNKNOWN) { + /* Disallow parallel joins. */ + response = JOIN_DISALLOW; + } else { + /* Alright we're fully a part of this domain + * so we keep some state as to who's joining + * and indicate to him that needs to be fixed + * up. */ + response = JOIN_OK; + __dlm_set_joining_node(dlm, query->node_idx); + } + + spin_unlock(&dlm->spinlock); + } + spin_unlock(&dlm_domain_lock); + +respond: + mlog(0, "We respond with %u\n", response); + + return response; +} + +static int dlm_assert_joined_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_assert_joined *assert; + struct dlm_ctxt *dlm = NULL; + + assert = (struct dlm_assert_joined *) msg->buf; + + mlog(0, "node %u asserts join on domain %s\n", assert->node_idx, + assert->domain); + + spin_lock(&dlm_domain_lock); + dlm = __dlm_lookup_domain_full(assert->domain, assert->name_len); + /* XXX should we consider no dlm ctxt an error? */ + if (dlm) { + spin_lock(&dlm->spinlock); + + /* Alright, this node has officially joined our + * domain. Set him in the map and clean up our + * leftover join state. */ + BUG_ON(dlm->joining_node != assert->node_idx); + set_bit(assert->node_idx, dlm->domain_map); + __dlm_set_joining_node(dlm, DLM_LOCK_RES_OWNER_UNKNOWN); + + __dlm_print_nodes(dlm); + + /* notify anything attached to the heartbeat events */ + dlm_hb_event_notify_attached(dlm, assert->node_idx, 1); + + spin_unlock(&dlm->spinlock); + } + spin_unlock(&dlm_domain_lock); + + return 0; +} + +static int dlm_cancel_join_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_cancel_join *cancel; + struct dlm_ctxt *dlm = NULL; + + cancel = (struct dlm_cancel_join *) msg->buf; + + mlog(0, "node %u cancels join on domain %s\n", cancel->node_idx, + cancel->domain); + + spin_lock(&dlm_domain_lock); + dlm = __dlm_lookup_domain_full(cancel->domain, cancel->name_len); + + if (dlm) { + spin_lock(&dlm->spinlock); + + /* Yikes, this guy wants to cancel his join. No + * problem, we simply cleanup our join state. */ + BUG_ON(dlm->joining_node != cancel->node_idx); + __dlm_set_joining_node(dlm, DLM_LOCK_RES_OWNER_UNKNOWN); + + spin_unlock(&dlm->spinlock); + } + spin_unlock(&dlm_domain_lock); + + return 0; +} + +static int dlm_send_one_join_cancel(struct dlm_ctxt *dlm, + unsigned int node) +{ + int status; + struct dlm_cancel_join cancel_msg; + + memset(&cancel_msg, 0, sizeof(cancel_msg)); + cancel_msg.node_idx = dlm->node_num; + cancel_msg.name_len = strlen(dlm->name); + memcpy(cancel_msg.domain, dlm->name, cancel_msg.name_len); + + status = o2net_send_message(DLM_CANCEL_JOIN_MSG, DLM_MOD_KEY, + &cancel_msg, sizeof(cancel_msg), node, + NULL); + if (status < 0) { + mlog_errno(status); + goto bail; + } + +bail: + return status; +} + +/* map_size should be in bytes. */ +static int dlm_send_join_cancels(struct dlm_ctxt *dlm, + unsigned long *node_map, + unsigned int map_size) +{ + int status, tmpstat; + unsigned int node; + + if (map_size != (BITS_TO_LONGS(O2NM_MAX_NODES) * + sizeof(unsigned long))) { + mlog(ML_ERROR, + "map_size %u != BITS_TO_LONGS(O2NM_MAX_NODES) %u\n", + map_size, BITS_TO_LONGS(O2NM_MAX_NODES)); + return -EINVAL; + } + + status = 0; + node = -1; + while ((node = find_next_bit(node_map, O2NM_MAX_NODES, + node + 1)) < O2NM_MAX_NODES) { + if (node == dlm->node_num) + continue; + + tmpstat = dlm_send_one_join_cancel(dlm, node); + if (tmpstat) { + mlog(ML_ERROR, "Error return %d cancelling join on " + "node %d\n", tmpstat, node); + if (!status) + status = tmpstat; + } + } + + if (status) + mlog_errno(status); + return status; +} + +static int dlm_request_join(struct dlm_ctxt *dlm, + int node, + enum dlm_query_join_response *response) +{ + int status, retval; + struct dlm_query_join_request join_msg; + + mlog(0, "querying node %d\n", node); + + memset(&join_msg, 0, sizeof(join_msg)); + join_msg.node_idx = dlm->node_num; + join_msg.name_len = strlen(dlm->name); + memcpy(join_msg.domain, dlm->name, join_msg.name_len); + + status = o2net_send_message(DLM_QUERY_JOIN_MSG, DLM_MOD_KEY, &join_msg, + sizeof(join_msg), node, &retval); + if (status < 0 && status != -ENOPROTOOPT) { + mlog_errno(status); + goto bail; + } + + /* -ENOPROTOOPT from the net code means the other side isn't + listening for our message type -- that's fine, it means + his dlm isn't up, so we can consider him a 'yes' but not + joined into the domain. */ + if (status == -ENOPROTOOPT) { + status = 0; + *response = JOIN_OK_NO_MAP; + } else if (retval == JOIN_DISALLOW || + retval == JOIN_OK || + retval == JOIN_OK_NO_MAP) { + *response = retval; + } else { + status = -EINVAL; + mlog(ML_ERROR, "invalid response %d from node %u\n", retval, + node); + } + + mlog(0, "status %d, node %d response is %d\n", status, node, + *response); + +bail: + return status; +} + +static int dlm_send_one_join_assert(struct dlm_ctxt *dlm, + unsigned int node) +{ + int status; + struct dlm_assert_joined assert_msg; + + mlog(0, "Sending join assert to node %u\n", node); + + memset(&assert_msg, 0, sizeof(assert_msg)); + assert_msg.node_idx = dlm->node_num; + assert_msg.name_len = strlen(dlm->name); + memcpy(assert_msg.domain, dlm->name, assert_msg.name_len); + + status = o2net_send_message(DLM_ASSERT_JOINED_MSG, DLM_MOD_KEY, + &assert_msg, sizeof(assert_msg), node, + NULL); + if (status < 0) + mlog_errno(status); + + return status; +} + +static void dlm_send_join_asserts(struct dlm_ctxt *dlm, + unsigned long *node_map) +{ + int status, node, live; + + status = 0; + node = -1; + while ((node = find_next_bit(node_map, O2NM_MAX_NODES, + node + 1)) < O2NM_MAX_NODES) { + if (node == dlm->node_num) + continue; + + do { + /* It is very important that this message be + * received so we spin until either the node + * has died or it gets the message. */ + status = dlm_send_one_join_assert(dlm, node); + + spin_lock(&dlm->spinlock); + live = test_bit(node, dlm->live_nodes_map); + spin_unlock(&dlm->spinlock); + + if (status) { + mlog(ML_ERROR, "Error return %d asserting " + "join on node %d\n", status, node); + + /* give us some time between errors... */ + if (live) + msleep(DLM_DOMAIN_BACKOFF_MS); + } + } while (status && live); + } +} + +struct domain_join_ctxt { + unsigned long live_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + unsigned long yes_resp_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; +}; + +static int dlm_should_restart_join(struct dlm_ctxt *dlm, + struct domain_join_ctxt *ctxt, + enum dlm_query_join_response response) +{ + int ret; + + if (response == JOIN_DISALLOW) { + mlog(0, "Latest response of disallow -- should restart\n"); + return 1; + } + + spin_lock(&dlm->spinlock); + /* For now, we restart the process if the node maps have + * changed at all */ + ret = memcmp(ctxt->live_map, dlm->live_nodes_map, + sizeof(dlm->live_nodes_map)); + spin_unlock(&dlm->spinlock); + + if (ret) + mlog(0, "Node maps changed -- should restart\n"); + + return ret; +} + +static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) +{ + int status = 0, tmpstat, node; + struct domain_join_ctxt *ctxt; + enum dlm_query_join_response response; + + mlog_entry("%p", dlm); + + ctxt = kcalloc(1, sizeof(*ctxt), GFP_KERNEL); + if (!ctxt) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + /* group sem locking should work for us here -- we're already + * registered for heartbeat events so filling this should be + * atomic wrt getting those handlers called. */ + o2hb_fill_node_map(dlm->live_nodes_map, sizeof(dlm->live_nodes_map)); + + spin_lock(&dlm->spinlock); + memcpy(ctxt->live_map, dlm->live_nodes_map, sizeof(ctxt->live_map)); + + __dlm_set_joining_node(dlm, dlm->node_num); + + spin_unlock(&dlm->spinlock); + + node = -1; + while ((node = find_next_bit(ctxt->live_map, O2NM_MAX_NODES, + node + 1)) < O2NM_MAX_NODES) { + if (node == dlm->node_num) + continue; + + status = dlm_request_join(dlm, node, &response); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* Ok, either we got a response or the node doesn't have a + * dlm up. */ + if (response == JOIN_OK) + set_bit(node, ctxt->yes_resp_map); + + if (dlm_should_restart_join(dlm, ctxt, response)) { + status = -EAGAIN; + goto bail; + } + } + + mlog(0, "Yay, done querying nodes!\n"); + + /* Yay, everyone agree's we can join the domain. My domain is + * comprised of all nodes who were put in the + * yes_resp_map. Copy that into our domain map and send a join + * assert message to clean up everyone elses state. */ + spin_lock(&dlm->spinlock); + memcpy(dlm->domain_map, ctxt->yes_resp_map, + sizeof(ctxt->yes_resp_map)); + set_bit(dlm->node_num, dlm->domain_map); + spin_unlock(&dlm->spinlock); + + dlm_send_join_asserts(dlm, ctxt->yes_resp_map); + + /* Joined state *must* be set before the joining node + * information, otherwise the query_join handler may read no + * current joiner but a state of NEW and tell joining nodes + * we're not in the domain. */ + spin_lock(&dlm_domain_lock); + dlm->dlm_state = DLM_CTXT_JOINED; + dlm->num_joins++; + spin_unlock(&dlm_domain_lock); + +bail: + spin_lock(&dlm->spinlock); + __dlm_set_joining_node(dlm, DLM_LOCK_RES_OWNER_UNKNOWN); + if (!status) + __dlm_print_nodes(dlm); + spin_unlock(&dlm->spinlock); + + if (ctxt) { + /* Do we need to send a cancel message to any nodes? */ + if (status < 0) { + tmpstat = dlm_send_join_cancels(dlm, + ctxt->yes_resp_map, + sizeof(ctxt->yes_resp_map)); + if (tmpstat < 0) + mlog_errno(tmpstat); + } + kfree(ctxt); + } + + mlog(0, "returning %d\n", status); + return status; +} + +static void dlm_unregister_domain_handlers(struct dlm_ctxt *dlm) +{ + o2hb_unregister_callback(&dlm->dlm_hb_up); + o2hb_unregister_callback(&dlm->dlm_hb_down); + o2net_unregister_handler_list(&dlm->dlm_domain_handlers); +} + +static int dlm_register_domain_handlers(struct dlm_ctxt *dlm) +{ + int status; + + mlog(0, "registering handlers.\n"); + + o2hb_setup_callback(&dlm->dlm_hb_down, O2HB_NODE_DOWN_CB, + dlm_hb_node_down_cb, dlm, DLM_HB_NODE_DOWN_PRI); + status = o2hb_register_callback(&dlm->dlm_hb_down); + if (status) + goto bail; + + o2hb_setup_callback(&dlm->dlm_hb_up, O2HB_NODE_UP_CB, + dlm_hb_node_up_cb, dlm, DLM_HB_NODE_UP_PRI); + status = o2hb_register_callback(&dlm->dlm_hb_up); + if (status) + goto bail; + + status = o2net_register_handler(DLM_MASTER_REQUEST_MSG, dlm->key, + sizeof(struct dlm_master_request), + dlm_master_request_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_ASSERT_MASTER_MSG, dlm->key, + sizeof(struct dlm_assert_master), + dlm_assert_master_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_CREATE_LOCK_MSG, dlm->key, + sizeof(struct dlm_create_lock), + dlm_create_lock_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_CONVERT_LOCK_MSG, dlm->key, + DLM_CONVERT_LOCK_MAX_LEN, + dlm_convert_lock_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_UNLOCK_LOCK_MSG, dlm->key, + DLM_UNLOCK_LOCK_MAX_LEN, + dlm_unlock_lock_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_PROXY_AST_MSG, dlm->key, + DLM_PROXY_AST_MAX_LEN, + dlm_proxy_ast_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_EXIT_DOMAIN_MSG, dlm->key, + sizeof(struct dlm_exit_domain), + dlm_exit_domain_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_MIGRATE_REQUEST_MSG, dlm->key, + sizeof(struct dlm_migrate_request), + dlm_migrate_request_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_MIG_LOCKRES_MSG, dlm->key, + DLM_MIG_LOCKRES_MAX_LEN, + dlm_mig_lockres_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_MASTER_REQUERY_MSG, dlm->key, + sizeof(struct dlm_master_requery), + dlm_master_requery_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_LOCK_REQUEST_MSG, dlm->key, + sizeof(struct dlm_lock_request), + dlm_request_all_locks_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_RECO_DATA_DONE_MSG, dlm->key, + sizeof(struct dlm_reco_data_done), + dlm_reco_data_done_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_BEGIN_RECO_MSG, dlm->key, + sizeof(struct dlm_begin_reco), + dlm_begin_reco_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_FINALIZE_RECO_MSG, dlm->key, + sizeof(struct dlm_finalize_reco), + dlm_finalize_reco_handler, + dlm, &dlm->dlm_domain_handlers); + if (status) + goto bail; + +bail: + if (status) + dlm_unregister_domain_handlers(dlm); + + return status; +} + +static int dlm_join_domain(struct dlm_ctxt *dlm) +{ + int status; + + BUG_ON(!dlm); + + mlog(0, "Join domain %s\n", dlm->name); + + status = dlm_register_domain_handlers(dlm); + if (status) { + mlog_errno(status); + goto bail; + } + + status = dlm_launch_thread(dlm); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = dlm_launch_recovery_thread(dlm); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + do { + unsigned int backoff; + status = dlm_try_to_join_domain(dlm); + + /* If we're racing another node to the join, then we + * need to back off temporarily and let them + * complete. */ + if (status == -EAGAIN) { + if (signal_pending(current)) { + status = -ERESTARTSYS; + goto bail; + } + + /* + * After you! + * No, after you! + * I insist! + * But you first! + * ... + */ + backoff = (unsigned int)(jiffies & 0x3); + backoff *= DLM_DOMAIN_BACKOFF_MS; + mlog(0, "backoff %d\n", backoff); + msleep(backoff); + } + } while (status == -EAGAIN); + + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = 0; +bail: + wake_up(&dlm_domain_events); + + if (status) { + dlm_unregister_domain_handlers(dlm); + dlm_complete_thread(dlm); + dlm_complete_recovery_thread(dlm); + } + + return status; +} + +static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain, + u32 key) +{ + int i; + struct dlm_ctxt *dlm = NULL; + + dlm = kcalloc(1, sizeof(*dlm), GFP_KERNEL); + if (!dlm) { + mlog_errno(-ENOMEM); + goto leave; + } + + dlm->name = kmalloc(strlen(domain) + 1, GFP_KERNEL); + if (dlm->name == NULL) { + mlog_errno(-ENOMEM); + kfree(dlm); + dlm = NULL; + goto leave; + } + + dlm->resources = (struct list_head *) __get_free_page(GFP_KERNEL); + if (!dlm->resources) { + mlog_errno(-ENOMEM); + kfree(dlm->name); + kfree(dlm); + dlm = NULL; + goto leave; + } + memset(dlm->resources, 0, PAGE_SIZE); + + for (i=0; iresources[i]); + + strcpy(dlm->name, domain); + dlm->key = key; + dlm->node_num = o2nm_this_node(); + + spin_lock_init(&dlm->spinlock); + spin_lock_init(&dlm->master_lock); + spin_lock_init(&dlm->ast_lock); + INIT_LIST_HEAD(&dlm->list); + INIT_LIST_HEAD(&dlm->dirty_list); + INIT_LIST_HEAD(&dlm->reco.resources); + INIT_LIST_HEAD(&dlm->reco.received); + INIT_LIST_HEAD(&dlm->reco.node_data); + INIT_LIST_HEAD(&dlm->purge_list); + INIT_LIST_HEAD(&dlm->dlm_domain_handlers); + dlm->reco.state = 0; + + INIT_LIST_HEAD(&dlm->pending_asts); + INIT_LIST_HEAD(&dlm->pending_basts); + + mlog(0, "dlm->recovery_map=%p, &(dlm->recovery_map[0])=%p\n", + dlm->recovery_map, &(dlm->recovery_map[0])); + + memset(dlm->recovery_map, 0, sizeof(dlm->recovery_map)); + memset(dlm->live_nodes_map, 0, sizeof(dlm->live_nodes_map)); + memset(dlm->domain_map, 0, sizeof(dlm->domain_map)); + + dlm->dlm_thread_task = NULL; + dlm->dlm_reco_thread_task = NULL; + init_waitqueue_head(&dlm->dlm_thread_wq); + init_waitqueue_head(&dlm->dlm_reco_thread_wq); + init_waitqueue_head(&dlm->reco.event); + init_waitqueue_head(&dlm->ast_wq); + init_waitqueue_head(&dlm->migration_wq); + INIT_LIST_HEAD(&dlm->master_list); + INIT_LIST_HEAD(&dlm->mle_hb_events); + + dlm->joining_node = DLM_LOCK_RES_OWNER_UNKNOWN; + init_waitqueue_head(&dlm->dlm_join_events); + + dlm->reco.new_master = O2NM_INVALID_NODE_NUM; + dlm->reco.dead_node = O2NM_INVALID_NODE_NUM; + atomic_set(&dlm->local_resources, 0); + atomic_set(&dlm->remote_resources, 0); + atomic_set(&dlm->unknown_resources, 0); + + spin_lock_init(&dlm->work_lock); + INIT_LIST_HEAD(&dlm->work_list); + INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work, dlm); + + kref_init(&dlm->dlm_refs); + dlm->dlm_state = DLM_CTXT_NEW; + + INIT_LIST_HEAD(&dlm->dlm_eviction_callbacks); + + mlog(0, "context init: refcount %u\n", + atomic_read(&dlm->dlm_refs.refcount)); + +leave: + return dlm; +} + +/* + * dlm_register_domain: one-time setup per "domain" + */ +struct dlm_ctxt * dlm_register_domain(const char *domain, + u32 key) +{ + int ret; + struct dlm_ctxt *dlm = NULL; + struct dlm_ctxt *new_ctxt = NULL; + + if (strlen(domain) > O2NM_MAX_NAME_LEN) { + ret = -ENAMETOOLONG; + mlog(ML_ERROR, "domain name length too long\n"); + goto leave; + } + + if (!o2hb_check_local_node_heartbeating()) { + mlog(ML_ERROR, "the local node has not been configured, or is " + "not heartbeating\n"); + ret = -EPROTO; + goto leave; + } + + mlog(0, "register called for domain \"%s\"\n", domain); + +retry: + dlm = NULL; + if (signal_pending(current)) { + ret = -ERESTARTSYS; + mlog_errno(ret); + goto leave; + } + + spin_lock(&dlm_domain_lock); + + dlm = __dlm_lookup_domain(domain); + if (dlm) { + if (dlm->dlm_state != DLM_CTXT_JOINED) { + spin_unlock(&dlm_domain_lock); + + mlog(0, "This ctxt is not joined yet!\n"); + wait_event_interruptible(dlm_domain_events, + dlm_wait_on_domain_helper( + domain)); + goto retry; + } + + __dlm_get(dlm); + dlm->num_joins++; + + spin_unlock(&dlm_domain_lock); + + ret = 0; + goto leave; + } + + /* doesn't exist */ + if (!new_ctxt) { + spin_unlock(&dlm_domain_lock); + + new_ctxt = dlm_alloc_ctxt(domain, key); + if (new_ctxt) + goto retry; + + ret = -ENOMEM; + mlog_errno(ret); + goto leave; + } + + /* a little variable switch-a-roo here... */ + dlm = new_ctxt; + new_ctxt = NULL; + + /* add the new domain */ + list_add_tail(&dlm->list, &dlm_domains); + spin_unlock(&dlm_domain_lock); + + ret = dlm_join_domain(dlm); + if (ret) { + mlog_errno(ret); + dlm_put(dlm); + goto leave; + } + + ret = 0; +leave: + if (new_ctxt) + dlm_free_ctxt_mem(new_ctxt); + + if (ret < 0) + dlm = ERR_PTR(ret); + + return dlm; +} +EXPORT_SYMBOL_GPL(dlm_register_domain); + +static LIST_HEAD(dlm_join_handlers); + +static void dlm_unregister_net_handlers(void) +{ + o2net_unregister_handler_list(&dlm_join_handlers); +} + +static int dlm_register_net_handlers(void) +{ + int status = 0; + + status = o2net_register_handler(DLM_QUERY_JOIN_MSG, DLM_MOD_KEY, + sizeof(struct dlm_query_join_request), + dlm_query_join_handler, + NULL, &dlm_join_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_ASSERT_JOINED_MSG, DLM_MOD_KEY, + sizeof(struct dlm_assert_joined), + dlm_assert_joined_handler, + NULL, &dlm_join_handlers); + if (status) + goto bail; + + status = o2net_register_handler(DLM_CANCEL_JOIN_MSG, DLM_MOD_KEY, + sizeof(struct dlm_cancel_join), + dlm_cancel_join_handler, + NULL, &dlm_join_handlers); + +bail: + if (status < 0) + dlm_unregister_net_handlers(); + + return status; +} + +/* Domain eviction callback handling. + * + * The file system requires notification of node death *before* the + * dlm completes it's recovery work, otherwise it may be able to + * acquire locks on resources requiring recovery. Since the dlm can + * evict a node from it's domain *before* heartbeat fires, a similar + * mechanism is required. */ + +/* Eviction is not expected to happen often, so a per-domain lock is + * not necessary. Eviction callbacks are allowed to sleep for short + * periods of time. */ +static DECLARE_RWSEM(dlm_callback_sem); + +void dlm_fire_domain_eviction_callbacks(struct dlm_ctxt *dlm, + int node_num) +{ + struct list_head *iter; + struct dlm_eviction_cb *cb; + + down_read(&dlm_callback_sem); + list_for_each(iter, &dlm->dlm_eviction_callbacks) { + cb = list_entry(iter, struct dlm_eviction_cb, ec_item); + + cb->ec_func(node_num, cb->ec_data); + } + up_read(&dlm_callback_sem); +} + +void dlm_setup_eviction_cb(struct dlm_eviction_cb *cb, + dlm_eviction_func *f, + void *data) +{ + INIT_LIST_HEAD(&cb->ec_item); + cb->ec_func = f; + cb->ec_data = data; +} +EXPORT_SYMBOL_GPL(dlm_setup_eviction_cb); + +void dlm_register_eviction_cb(struct dlm_ctxt *dlm, + struct dlm_eviction_cb *cb) +{ + down_write(&dlm_callback_sem); + list_add_tail(&cb->ec_item, &dlm->dlm_eviction_callbacks); + up_write(&dlm_callback_sem); +} +EXPORT_SYMBOL_GPL(dlm_register_eviction_cb); + +void dlm_unregister_eviction_cb(struct dlm_eviction_cb *cb) +{ + down_write(&dlm_callback_sem); + list_del_init(&cb->ec_item); + up_write(&dlm_callback_sem); +} +EXPORT_SYMBOL_GPL(dlm_unregister_eviction_cb); + +static int __init dlm_init(void) +{ + int status; + + dlm_print_version(); + + status = dlm_init_mle_cache(); + if (status) + return -1; + + status = dlm_register_net_handlers(); + if (status) { + dlm_destroy_mle_cache(); + return -1; + } + + return 0; +} + +static void __exit dlm_exit (void) +{ + dlm_unregister_net_handlers(); + dlm_destroy_mle_cache(); +} + +MODULE_AUTHOR("Oracle"); +MODULE_LICENSE("GPL"); + +module_init(dlm_init); +module_exit(dlm_exit); diff --git a/fs/ocfs2/dlm/dlmdomain.h b/fs/ocfs2/dlm/dlmdomain.h new file mode 100644 index 0000000..2f7f60b --- /dev/null +++ b/fs/ocfs2/dlm/dlmdomain.h @@ -0,0 +1,36 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmdomain.h + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + +#ifndef DLMDOMAIN_H +#define DLMDOMAIN_H + +extern spinlock_t dlm_domain_lock; +extern struct list_head dlm_domains; + +int dlm_joined(struct dlm_ctxt *dlm); +int dlm_shutting_down(struct dlm_ctxt *dlm); +void dlm_fire_domain_eviction_callbacks(struct dlm_ctxt *dlm, + int node_num); + +#endif diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c new file mode 100644 index 0000000..d1a0038 --- /dev/null +++ b/fs/ocfs2/dlm/dlmlock.c @@ -0,0 +1,676 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmlock.c + * + * underlying calls for lock creation + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" +#include "dlmcommon.h" + +#include "dlmconvert.h" + +#define MLOG_MASK_PREFIX ML_DLM +#include "cluster/masklog.h" + +static spinlock_t dlm_cookie_lock = SPIN_LOCK_UNLOCKED; +static u64 dlm_next_cookie = 1; + +static enum dlm_status dlm_send_remote_lock_request(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags); +static void dlm_init_lock(struct dlm_lock *newlock, int type, + u8 node, u64 cookie); +static void dlm_lock_release(struct kref *kref); +static void dlm_lock_detach_lockres(struct dlm_lock *lock); + +/* Tell us whether we can grant a new lock request. + * locking: + * caller needs: res->spinlock + * taken: none + * held on exit: none + * returns: 1 if the lock can be granted, 0 otherwise. + */ +static int dlm_can_grant_new_lock(struct dlm_lock_resource *res, + struct dlm_lock *lock) +{ + struct list_head *iter; + struct dlm_lock *tmplock; + + list_for_each(iter, &res->granted) { + tmplock = list_entry(iter, struct dlm_lock, list); + + if (!dlm_lock_compatible(tmplock->ml.type, lock->ml.type)) + return 0; + } + + list_for_each(iter, &res->converting) { + tmplock = list_entry(iter, struct dlm_lock, list); + + if (!dlm_lock_compatible(tmplock->ml.type, lock->ml.type)) + return 0; + } + + return 1; +} + +/* performs lock creation at the lockres master site + * locking: + * caller needs: none + * taken: takes and drops res->spinlock + * held on exit: none + * returns: DLM_NORMAL, DLM_NOTQUEUED + */ +static enum dlm_status dlmlock_master(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags) +{ + int call_ast = 0, kick_thread = 0; + enum dlm_status status = DLM_NORMAL; + + mlog_entry("type=%d\n", lock->ml.type); + + spin_lock(&res->spinlock); + /* if called from dlm_create_lock_handler, need to + * ensure it will not sleep in dlm_wait_on_lockres */ + status = __dlm_lockres_state_to_status(res); + if (status != DLM_NORMAL && + lock->ml.node != dlm->node_num) { + /* erf. state changed after lock was dropped. */ + spin_unlock(&res->spinlock); + dlm_error(status); + return status; + } + __dlm_wait_on_lockres(res); + __dlm_lockres_reserve_ast(res); + + if (dlm_can_grant_new_lock(res, lock)) { + mlog(0, "I can grant this lock right away\n"); + /* got it right away */ + lock->lksb->status = DLM_NORMAL; + status = DLM_NORMAL; + dlm_lock_get(lock); + list_add_tail(&lock->list, &res->granted); + + /* for the recovery lock, we can't allow the ast + * to be queued since the dlmthread is already + * frozen. but the recovery lock is always locked + * with LKM_NOQUEUE so we do not need the ast in + * this special case */ + if (!dlm_is_recovery_lock(res->lockname.name, + res->lockname.len)) { + kick_thread = 1; + call_ast = 1; + } + } else { + /* for NOQUEUE request, unless we get the + * lock right away, return DLM_NOTQUEUED */ + if (flags & LKM_NOQUEUE) + status = DLM_NOTQUEUED; + else { + dlm_lock_get(lock); + list_add_tail(&lock->list, &res->blocked); + kick_thread = 1; + } + } + + spin_unlock(&res->spinlock); + wake_up(&res->wq); + + /* either queue the ast or release it */ + if (call_ast) + dlm_queue_ast(dlm, lock); + else + dlm_lockres_release_ast(dlm, res); + + dlm_lockres_calc_usage(dlm, res); + if (kick_thread) + dlm_kick_thread(dlm, res); + + return status; +} + +void dlm_revert_pending_lock(struct dlm_lock_resource *res, + struct dlm_lock *lock) +{ + /* remove from local queue if it failed */ + list_del_init(&lock->list); + lock->lksb->flags &= ~DLM_LKSB_GET_LVB; +} + + +/* + * locking: + * caller needs: none + * taken: takes and drops res->spinlock + * held on exit: none + * returns: DLM_DENIED, DLM_RECOVERING, or net status + */ +static enum dlm_status dlmlock_remote(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags) +{ + enum dlm_status status = DLM_DENIED; + + mlog_entry("type=%d\n", lock->ml.type); + mlog(0, "lockres %.*s, flags = 0x%x\n", res->lockname.len, + res->lockname.name, flags); + + spin_lock(&res->spinlock); + + /* will exit this call with spinlock held */ + __dlm_wait_on_lockres(res); + res->state |= DLM_LOCK_RES_IN_PROGRESS; + + /* add lock to local (secondary) queue */ + dlm_lock_get(lock); + list_add_tail(&lock->list, &res->blocked); + lock->lock_pending = 1; + spin_unlock(&res->spinlock); + + /* spec seems to say that you will get DLM_NORMAL when the lock + * has been queued, meaning we need to wait for a reply here. */ + status = dlm_send_remote_lock_request(dlm, res, lock, flags); + + spin_lock(&res->spinlock); + res->state &= ~DLM_LOCK_RES_IN_PROGRESS; + lock->lock_pending = 0; + if (status != DLM_NORMAL) { + if (status != DLM_NOTQUEUED) + dlm_error(status); + dlm_revert_pending_lock(res, lock); + dlm_lock_put(lock); + } + spin_unlock(&res->spinlock); + + dlm_lockres_calc_usage(dlm, res); + + wake_up(&res->wq); + return status; +} + + +/* for remote lock creation. + * locking: + * caller needs: none, but need res->state & DLM_LOCK_RES_IN_PROGRESS + * taken: none + * held on exit: none + * returns: DLM_NOLOCKMGR, or net status + */ +static enum dlm_status dlm_send_remote_lock_request(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, int flags) +{ + struct dlm_create_lock create; + int tmpret, status = 0; + enum dlm_status ret; + + mlog_entry_void(); + + memset(&create, 0, sizeof(create)); + create.node_idx = dlm->node_num; + create.requested_type = lock->ml.type; + create.cookie = lock->ml.cookie; + create.namelen = res->lockname.len; + create.flags = cpu_to_be32(flags); + memcpy(create.name, res->lockname.name, create.namelen); + + tmpret = o2net_send_message(DLM_CREATE_LOCK_MSG, dlm->key, &create, + sizeof(create), res->owner, &status); + if (tmpret >= 0) { + // successfully sent and received + ret = status; // this is already a dlm_status + } else { + mlog_errno(tmpret); + if (dlm_is_host_down(tmpret)) { + ret = DLM_RECOVERING; + mlog(0, "node %u died so returning DLM_RECOVERING " + "from lock message!\n", res->owner); + } else { + ret = dlm_err_to_dlm_status(tmpret); + } + } + + return ret; +} + +void dlm_lock_get(struct dlm_lock *lock) +{ + kref_get(&lock->lock_refs); +} + +void dlm_lock_put(struct dlm_lock *lock) +{ + kref_put(&lock->lock_refs, dlm_lock_release); +} + +static void dlm_lock_release(struct kref *kref) +{ + struct dlm_lock *lock; + + lock = container_of(kref, struct dlm_lock, lock_refs); + + BUG_ON(!list_empty(&lock->list)); + BUG_ON(!list_empty(&lock->ast_list)); + BUG_ON(!list_empty(&lock->bast_list)); + BUG_ON(lock->ast_pending); + BUG_ON(lock->bast_pending); + + dlm_lock_detach_lockres(lock); + + if (lock->lksb_kernel_allocated) { + mlog(0, "freeing kernel-allocated lksb\n"); + kfree(lock->lksb); + } + kfree(lock); +} + +/* associate a lock with it's lockres, getting a ref on the lockres */ +void dlm_lock_attach_lockres(struct dlm_lock *lock, + struct dlm_lock_resource *res) +{ + dlm_lockres_get(res); + lock->lockres = res; +} + +/* drop ref on lockres, if there is still one associated with lock */ +static void dlm_lock_detach_lockres(struct dlm_lock *lock) +{ + struct dlm_lock_resource *res; + + res = lock->lockres; + if (res) { + lock->lockres = NULL; + mlog(0, "removing lock's lockres reference\n"); + dlm_lockres_put(res); + } +} + +static void dlm_init_lock(struct dlm_lock *newlock, int type, + u8 node, u64 cookie) +{ + INIT_LIST_HEAD(&newlock->list); + INIT_LIST_HEAD(&newlock->ast_list); + INIT_LIST_HEAD(&newlock->bast_list); + spin_lock_init(&newlock->spinlock); + newlock->ml.type = type; + newlock->ml.convert_type = LKM_IVMODE; + newlock->ml.highest_blocked = LKM_IVMODE; + newlock->ml.node = node; + newlock->ml.pad1 = 0; + newlock->ml.list = 0; + newlock->ml.flags = 0; + newlock->ast = NULL; + newlock->bast = NULL; + newlock->astdata = NULL; + newlock->ml.cookie = cpu_to_be64(cookie); + newlock->ast_pending = 0; + newlock->bast_pending = 0; + newlock->convert_pending = 0; + newlock->lock_pending = 0; + newlock->unlock_pending = 0; + newlock->cancel_pending = 0; + newlock->lksb_kernel_allocated = 0; + + kref_init(&newlock->lock_refs); +} + +struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie, + struct dlm_lockstatus *lksb) +{ + struct dlm_lock *lock; + int kernel_allocated = 0; + + lock = kcalloc(1, sizeof(*lock), GFP_KERNEL); + if (!lock) + return NULL; + + if (!lksb) { + /* zero memory only if kernel-allocated */ + lksb = kcalloc(1, sizeof(*lksb), GFP_KERNEL); + if (!lksb) { + kfree(lock); + return NULL; + } + kernel_allocated = 1; + } + + dlm_init_lock(lock, type, node, cookie); + if (kernel_allocated) + lock->lksb_kernel_allocated = 1; + lock->lksb = lksb; + lksb->lockid = lock; + return lock; +} + +/* handler for lock creation net message + * locking: + * caller needs: none + * taken: takes and drops res->spinlock + * held on exit: none + * returns: DLM_NORMAL, DLM_SYSERR, DLM_IVLOCKID, DLM_NOTQUEUED + */ +int dlm_create_lock_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_create_lock *create = (struct dlm_create_lock *)msg->buf; + struct dlm_lock_resource *res = NULL; + struct dlm_lock *newlock = NULL; + struct dlm_lockstatus *lksb = NULL; + enum dlm_status status = DLM_NORMAL; + char *name; + unsigned int namelen; + + BUG_ON(!dlm); + + mlog_entry_void(); + + if (!dlm_grab(dlm)) + return DLM_REJECTED; + + mlog_bug_on_msg(!dlm_domain_fully_joined(dlm), + "Domain %s not fully joined!\n", dlm->name); + + name = create->name; + namelen = create->namelen; + + status = DLM_IVBUFLEN; + if (namelen > DLM_LOCKID_NAME_MAX) { + dlm_error(status); + goto leave; + } + + status = DLM_SYSERR; + newlock = dlm_new_lock(create->requested_type, + create->node_idx, + be64_to_cpu(create->cookie), NULL); + if (!newlock) { + dlm_error(status); + goto leave; + } + + lksb = newlock->lksb; + + if (be32_to_cpu(create->flags) & LKM_GET_LVB) { + lksb->flags |= DLM_LKSB_GET_LVB; + mlog(0, "set DLM_LKSB_GET_LVB flag\n"); + } + + status = DLM_IVLOCKID; + res = dlm_lookup_lockres(dlm, name, namelen); + if (!res) { + dlm_error(status); + goto leave; + } + + spin_lock(&res->spinlock); + status = __dlm_lockres_state_to_status(res); + spin_unlock(&res->spinlock); + + if (status != DLM_NORMAL) { + mlog(0, "lockres recovering/migrating/in-progress\n"); + goto leave; + } + + dlm_lock_attach_lockres(newlock, res); + + status = dlmlock_master(dlm, res, newlock, be32_to_cpu(create->flags)); +leave: + if (status != DLM_NORMAL) + if (newlock) + dlm_lock_put(newlock); + + if (res) + dlm_lockres_put(res); + + dlm_put(dlm); + + return status; +} + + +/* fetch next node-local (u8 nodenum + u56 cookie) into u64 */ +static inline void dlm_get_next_cookie(u8 node_num, u64 *cookie) +{ + u64 tmpnode = node_num; + + /* shift single byte of node num into top 8 bits */ + tmpnode <<= 56; + + spin_lock(&dlm_cookie_lock); + *cookie = (dlm_next_cookie | tmpnode); + if (++dlm_next_cookie & 0xff00000000000000ull) { + mlog(0, "This node's cookie will now wrap!\n"); + dlm_next_cookie = 1; + } + spin_unlock(&dlm_cookie_lock); +} + +enum dlm_status dlmlock(struct dlm_ctxt *dlm, int mode, + struct dlm_lockstatus *lksb, int flags, + const char *name, dlm_astlockfunc_t *ast, void *data, + dlm_bastlockfunc_t *bast) +{ + enum dlm_status status; + struct dlm_lock_resource *res = NULL; + struct dlm_lock *lock = NULL; + int convert = 0, recovery = 0; + + /* yes this function is a mess. + * TODO: clean this up. lots of common code in the + * lock and convert paths, especially in the retry blocks */ + if (!lksb) { + dlm_error(DLM_BADARGS); + return DLM_BADARGS; + } + + status = DLM_BADPARAM; + if (mode != LKM_EXMODE && mode != LKM_PRMODE && mode != LKM_NLMODE) { + dlm_error(status); + goto error; + } + + if (flags & ~LKM_VALID_FLAGS) { + dlm_error(status); + goto error; + } + + convert = (flags & LKM_CONVERT); + recovery = (flags & LKM_RECOVERY); + + if (recovery && + (!dlm_is_recovery_lock(name, strlen(name)) || convert) ) { + dlm_error(status); + goto error; + } + if (convert && (flags & LKM_LOCAL)) { + mlog(ML_ERROR, "strange LOCAL convert request!\n"); + goto error; + } + + if (convert) { + /* CONVERT request */ + + /* if converting, must pass in a valid dlm_lock */ + lock = lksb->lockid; + if (!lock) { + mlog(ML_ERROR, "NULL lock pointer in convert " + "request\n"); + goto error; + } + + res = lock->lockres; + if (!res) { + mlog(ML_ERROR, "NULL lockres pointer in convert " + "request\n"); + goto error; + } + dlm_lockres_get(res); + + /* XXX: for ocfs2 purposes, the ast/bast/astdata/lksb are + * static after the original lock call. convert requests will + * ensure that everything is the same, or return DLM_BADARGS. + * this means that DLM_DENIED_NOASTS will never be returned. + */ + if (lock->lksb != lksb || lock->ast != ast || + lock->bast != bast || lock->astdata != data) { + status = DLM_BADARGS; + mlog(ML_ERROR, "new args: lksb=%p, ast=%p, bast=%p, " + "astdata=%p\n", lksb, ast, bast, data); + mlog(ML_ERROR, "orig args: lksb=%p, ast=%p, bast=%p, " + "astdata=%p\n", lock->lksb, lock->ast, + lock->bast, lock->astdata); + goto error; + } +retry_convert: + dlm_wait_for_recovery(dlm); + + if (res->owner == dlm->node_num) + status = dlmconvert_master(dlm, res, lock, flags, mode); + else + status = dlmconvert_remote(dlm, res, lock, flags, mode); + if (status == DLM_RECOVERING || status == DLM_MIGRATING || + status == DLM_FORWARD) { + /* for now, see how this works without sleeping + * and just retry right away. I suspect the reco + * or migration will complete fast enough that + * no waiting will be necessary */ + mlog(0, "retrying convert with migration/recovery/" + "in-progress\n"); + msleep(100); + goto retry_convert; + } + } else { + u64 tmpcookie; + + /* LOCK request */ + status = DLM_BADARGS; + if (!name) { + dlm_error(status); + goto error; + } + + status = DLM_IVBUFLEN; + if (strlen(name) > DLM_LOCKID_NAME_MAX || strlen(name) < 1) { + dlm_error(status); + goto error; + } + + dlm_get_next_cookie(dlm->node_num, &tmpcookie); + lock = dlm_new_lock(mode, dlm->node_num, tmpcookie, lksb); + if (!lock) { + dlm_error(status); + goto error; + } + + if (!recovery) + dlm_wait_for_recovery(dlm); + + /* find or create the lock resource */ + res = dlm_get_lock_resource(dlm, name, flags); + if (!res) { + status = DLM_IVLOCKID; + dlm_error(status); + goto error; + } + + mlog(0, "type=%d, flags = 0x%x\n", mode, flags); + mlog(0, "creating lock: lock=%p res=%p\n", lock, res); + + dlm_lock_attach_lockres(lock, res); + lock->ast = ast; + lock->bast = bast; + lock->astdata = data; + +retry_lock: + if (flags & LKM_VALBLK) { + mlog(0, "LKM_VALBLK passed by caller\n"); + + /* LVB requests for non PR, PW or EX locks are + * ignored. */ + if (mode < LKM_PRMODE) + flags &= ~LKM_VALBLK; + else { + flags |= LKM_GET_LVB; + lock->lksb->flags |= DLM_LKSB_GET_LVB; + } + } + + if (res->owner == dlm->node_num) + status = dlmlock_master(dlm, res, lock, flags); + else + status = dlmlock_remote(dlm, res, lock, flags); + + if (status == DLM_RECOVERING || status == DLM_MIGRATING || + status == DLM_FORWARD) { + mlog(0, "retrying lock with migration/" + "recovery/in progress\n"); + msleep(100); + dlm_wait_for_recovery(dlm); + goto retry_lock; + } + + if (status != DLM_NORMAL) { + lock->lksb->flags &= ~DLM_LKSB_GET_LVB; + if (status != DLM_NOTQUEUED) + dlm_error(status); + goto error; + } + } + +error: + if (status != DLM_NORMAL) { + if (lock && !convert) + dlm_lock_put(lock); + // this is kind of unnecessary + lksb->status = status; + } + + /* put lockres ref from the convert path + * or from dlm_get_lock_resource */ + if (res) + dlm_lockres_put(res); + + return status; +} +EXPORT_SYMBOL_GPL(dlmlock); diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c new file mode 100644 index 0000000..0472795 --- /dev/null +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -0,0 +1,2666 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmmod.c + * + * standalone DLM module + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" +#include "dlmcommon.h" +#include "dlmdebug.h" + +#define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_MASTER) +#include "cluster/masklog.h" + +enum dlm_mle_type { + DLM_MLE_BLOCK, + DLM_MLE_MASTER, + DLM_MLE_MIGRATION +}; + +struct dlm_lock_name +{ + u8 len; + u8 name[DLM_LOCKID_NAME_MAX]; +}; + +struct dlm_master_list_entry +{ + struct list_head list; + struct list_head hb_events; + struct dlm_ctxt *dlm; + spinlock_t spinlock; + wait_queue_head_t wq; + atomic_t woken; + struct kref mle_refs; + unsigned long maybe_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + unsigned long vote_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + unsigned long response_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + unsigned long node_map[BITS_TO_LONGS(O2NM_MAX_NODES)]; + u8 master; + u8 new_master; + enum dlm_mle_type type; + struct o2hb_callback_func mle_hb_up; + struct o2hb_callback_func mle_hb_down; + union { + struct dlm_lock_resource *res; + struct dlm_lock_name name; + } u; +}; + +static void dlm_mle_node_down(struct dlm_ctxt *dlm, + struct dlm_master_list_entry *mle, + struct o2nm_node *node, + int idx); +static void dlm_mle_node_up(struct dlm_ctxt *dlm, + struct dlm_master_list_entry *mle, + struct o2nm_node *node, + int idx); + +static void dlm_assert_master_worker(struct dlm_work_item *item, void *data); +static int dlm_do_assert_master(struct dlm_ctxt *dlm, const char *lockname, + unsigned int namelen, void *nodemap, + u32 flags); + +static inline int dlm_mle_equal(struct dlm_ctxt *dlm, + struct dlm_master_list_entry *mle, + const char *name, + unsigned int namelen) +{ + struct dlm_lock_resource *res; + + if (dlm != mle->dlm) + return 0; + + if (mle->type == DLM_MLE_BLOCK || + mle->type == DLM_MLE_MIGRATION) { + if (namelen != mle->u.name.len || + memcmp(name, mle->u.name.name, namelen)!=0) + return 0; + } else { + res = mle->u.res; + if (namelen != res->lockname.len || + memcmp(res->lockname.name, name, namelen) != 0) + return 0; + } + return 1; +} + +#if 0 +/* Code here is included but defined out as it aids debugging */ + +void dlm_print_one_mle(struct dlm_master_list_entry *mle) +{ + int i = 0, refs; + char *type; + char attached; + u8 master; + unsigned int namelen; + const char *name; + struct kref *k; + + k = &mle->mle_refs; + if (mle->type == DLM_MLE_BLOCK) + type = "BLK"; + else if (mle->type == DLM_MLE_MASTER) + type = "MAS"; + else + type = "MIG"; + refs = atomic_read(&k->refcount); + master = mle->master; + attached = (list_empty(&mle->hb_events) ? 'N' : 'Y'); + + if (mle->type != DLM_MLE_MASTER) { + namelen = mle->u.name.len; + name = mle->u.name.name; + } else { + namelen = mle->u.res->lockname.len; + name = mle->u.res->lockname.name; + } + + mlog(ML_NOTICE, " #%3d: %3s %3d %3u %3u %c (%d)%.*s\n", + i, type, refs, master, mle->new_master, attached, + namelen, namelen, name); +} + +static void dlm_dump_mles(struct dlm_ctxt *dlm) +{ + struct dlm_master_list_entry *mle; + struct list_head *iter; + + mlog(ML_NOTICE, "dumping all mles for domain %s:\n", dlm->name); + mlog(ML_NOTICE, " ####: type refs owner new events? lockname nodemap votemap respmap maybemap\n"); + spin_lock(&dlm->master_lock); + list_for_each(iter, &dlm->master_list) { + mle = list_entry(iter, struct dlm_master_list_entry, list); + dlm_print_one_mle(mle); + } + spin_unlock(&dlm->master_lock); +} + +extern spinlock_t dlm_domain_lock; +extern struct list_head dlm_domains; + +int dlm_dump_all_mles(const char __user *data, unsigned int len) +{ + struct list_head *iter; + struct dlm_ctxt *dlm; + + spin_lock(&dlm_domain_lock); + list_for_each(iter, &dlm_domains) { + dlm = list_entry (iter, struct dlm_ctxt, list); + mlog(ML_NOTICE, "found dlm: %p, name=%s\n", dlm, dlm->name); + dlm_dump_mles(dlm); + } + spin_unlock(&dlm_domain_lock); + return len; +} +EXPORT_SYMBOL_GPL(dlm_dump_all_mles); + +#endif /* 0 */ + + +static kmem_cache_t *dlm_mle_cache = NULL; + + +static void dlm_mle_release(struct kref *kref); +static void dlm_init_mle(struct dlm_master_list_entry *mle, + enum dlm_mle_type type, + struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + const char *name, + unsigned int namelen); +static void dlm_put_mle(struct dlm_master_list_entry *mle); +static void __dlm_put_mle(struct dlm_master_list_entry *mle); +static int dlm_find_mle(struct dlm_ctxt *dlm, + struct dlm_master_list_entry **mle, + char *name, unsigned int namelen); + +static int dlm_do_master_request(struct dlm_master_list_entry *mle, int to); + + +static int dlm_wait_for_lock_mastery(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_master_list_entry *mle, + int *blocked); +static int dlm_restart_lock_mastery(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_master_list_entry *mle, + int blocked); +static int dlm_add_migration_mle(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_master_list_entry *mle, + struct dlm_master_list_entry **oldmle, + const char *name, unsigned int namelen, + u8 new_master, u8 master); + +static u8 dlm_pick_migration_target(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); +static void dlm_remove_nonlocal_locks(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res); +static int dlm_mark_lockres_migrating(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 target); + + +int dlm_is_host_down(int errno) +{ + switch (errno) { + case -EBADF: + case -ECONNREFUSED: + case -ENOTCONN: + case -ECONNRESET: + case -EPIPE: + case -EHOSTDOWN: + case -EHOSTUNREACH: + case -ETIMEDOUT: + case -ECONNABORTED: + case -ENETDOWN: + case -ENETUNREACH: + case -ENETRESET: + case -ESHUTDOWN: + case -ENOPROTOOPT: + case -EINVAL: /* if returned from our tcp code, + this means there is no socket */ + return 1; + } + return 0; +} + + +/* + * MASTER LIST FUNCTIONS + */ + + +/* + * regarding master list entries and heartbeat callbacks: + * + * in order to avoid sleeping and allocation that occurs in + * heartbeat, master list entries are simply attached to the + * dlm's established heartbeat callbacks. the mle is attached + * when it is created, and since the dlm->spinlock is held at + * that time, any heartbeat event will be properly discovered + * by the mle. the mle needs to be detached from the + * dlm->mle_hb_events list as soon as heartbeat events are no + * longer useful to the mle, and before the mle is freed. + * + * as a general rule, heartbeat events are no longer needed by + * the mle once an "answer" regarding the lock master has been + * received. + */ +static inline void __dlm_mle_attach_hb_events(struct dlm_ctxt *dlm, + struct dlm_master_list_entry *mle) +{ + assert_spin_locked(&dlm->spinlock); + + list_add_tail(&mle->hb_events, &dlm->mle_hb_events); +} + + +static inline void __dlm_mle_detach_hb_events(struct dlm_ctxt *dlm, + struct dlm_master_list_entry *mle) +{ + if (!list_empty(&mle->hb_events)) + list_del_init(&mle->hb_events); +} + + +static inline void dlm_mle_detach_hb_events(struct dlm_ctxt *dlm, + struct dlm_master_list_entry *mle) +{ + spin_lock(&dlm->spinlock); + __dlm_mle_detach_hb_events(dlm, mle); + spin_unlock(&dlm->spinlock); +} + +/* remove from list and free */ +static void __dlm_put_mle(struct dlm_master_list_entry *mle) +{ + struct dlm_ctxt *dlm; + dlm = mle->dlm; + + assert_spin_locked(&dlm->spinlock); + assert_spin_locked(&dlm->master_lock); + BUG_ON(!atomic_read(&mle->mle_refs.refcount)); + + kref_put(&mle->mle_refs, dlm_mle_release); +} + + +/* must not have any spinlocks coming in */ +static void dlm_put_mle(struct dlm_master_list_entry *mle) +{ + struct dlm_ctxt *dlm; + dlm = mle->dlm; + + spin_lock(&dlm->spinlock); + spin_lock(&dlm->master_lock); + __dlm_put_mle(mle); + spin_unlock(&dlm->master_lock); + spin_unlock(&dlm->spinlock); +} + +static inline void dlm_get_mle(struct dlm_master_list_entry *mle) +{ + kref_get(&mle->mle_refs); +} + +static void dlm_init_mle(struct dlm_master_list_entry *mle, + enum dlm_mle_type type, + struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + const char *name, + unsigned int namelen) +{ + assert_spin_locked(&dlm->spinlock); + + mle->dlm = dlm; + mle->type = type; + INIT_LIST_HEAD(&mle->list); + INIT_LIST_HEAD(&mle->hb_events); + memset(mle->maybe_map, 0, sizeof(mle->maybe_map)); + spin_lock_init(&mle->spinlock); + init_waitqueue_head(&mle->wq); + atomic_set(&mle->woken, 0); + kref_init(&mle->mle_refs); + memset(mle->response_map, 0, sizeof(mle->response_map)); + mle->master = O2NM_MAX_NODES; + mle->new_master = O2NM_MAX_NODES; + + if (mle->type == DLM_MLE_MASTER) { + BUG_ON(!res); + mle->u.res = res; + } else if (mle->type == DLM_MLE_BLOCK) { + BUG_ON(!name); + memcpy(mle->u.name.name, name, namelen); + mle->u.name.len = namelen; + } else /* DLM_MLE_MIGRATION */ { + BUG_ON(!name); + memcpy(mle->u.name.name, name, namelen); + mle->u.name.len = namelen; + } + + /* copy off the node_map and register hb callbacks on our copy */ + memcpy(mle->node_map, dlm->domain_map, sizeof(mle->node_map)); + memcpy(mle->vote_map, dlm->domain_map, sizeof(mle->vote_map)); + clear_bit(dlm->node_num, mle->vote_map); + clear_bit(dlm->node_num, mle->node_map); + + /* attach the mle to the domain node up/down events */ + __dlm_mle_attach_hb_events(dlm, mle); +} + + +/* returns 1 if found, 0 if not */ +static int dlm_find_mle(struct dlm_ctxt *dlm, + struct dlm_master_list_entry **mle, + char *name, unsigned int namelen) +{ + struct dlm_master_list_entry *tmpmle; + struct list_head *iter; + + assert_spin_locked(&dlm->master_lock); + + list_for_each(iter, &dlm->master_list) { + tmpmle = list_entry(iter, struct dlm_master_list_entry, list); + if (!dlm_mle_equal(dlm, tmpmle, name, namelen)) + continue; + dlm_get_mle(tmpmle); + *mle = tmpmle; + return 1; + } + return 0; +} + +void dlm_hb_event_notify_attached(struct dlm_ctxt *dlm, int idx, int node_up) +{ + struct dlm_master_list_entry *mle; + struct list_head *iter; + + assert_spin_locked(&dlm->spinlock); + + list_for_each(iter, &dlm->mle_hb_events) { + mle = list_entry(iter, struct dlm_master_list_entry, + hb_events); + if (node_up) + dlm_mle_node_up(dlm, mle, NULL, idx); + else + dlm_mle_node_down(dlm, mle, NULL, idx); + } +} + +static void dlm_mle_node_down(struct dlm_ctxt *dlm, + struct dlm_master_list_entry *mle, + struct o2nm_node *node, int idx) +{ + spin_lock(&mle->spinlock); + + if (!test_bit(idx, mle->node_map)) + mlog(0, "node %u already removed from nodemap!\n", idx); + else + clear_bit(idx, mle->node_map); + + spin_unlock(&mle->spinlock); +} + +static void dlm_mle_node_up(struct dlm_ctxt *dlm, + struct dlm_master_list_entry *mle, + struct o2nm_node *node, int idx) +{ + spin_lock(&mle->spinlock); + + if (test_bit(idx, mle->node_map)) + mlog(0, "node %u already in node map!\n", idx); + else + set_bit(idx, mle->node_map); + + spin_unlock(&mle->spinlock); +} + + +int dlm_init_mle_cache(void) +{ + dlm_mle_cache = kmem_cache_create("dlm_mle_cache", + sizeof(struct dlm_master_list_entry), + 0, SLAB_HWCACHE_ALIGN, + NULL, NULL); + if (dlm_mle_cache == NULL) + return -ENOMEM; + return 0; +} + +void dlm_destroy_mle_cache(void) +{ + if (dlm_mle_cache) + kmem_cache_destroy(dlm_mle_cache); +} + +static void dlm_mle_release(struct kref *kref) +{ + struct dlm_master_list_entry *mle; + struct dlm_ctxt *dlm; + + mlog_entry_void(); + + mle = container_of(kref, struct dlm_master_list_entry, mle_refs); + dlm = mle->dlm; + + if (mle->type != DLM_MLE_MASTER) { + mlog(0, "calling mle_release for %.*s, type %d\n", + mle->u.name.len, mle->u.name.name, mle->type); + } else { + mlog(0, "calling mle_release for %.*s, type %d\n", + mle->u.res->lockname.len, + mle->u.res->lockname.name, mle->type); + } + assert_spin_locked(&dlm->spinlock); + assert_spin_locked(&dlm->master_lock); + + /* remove from list if not already */ + if (!list_empty(&mle->list)) + list_del_init(&mle->list); + + /* detach the mle from the domain node up/down events */ + __dlm_mle_detach_hb_events(dlm, mle); + + /* NOTE: kfree under spinlock here. + * if this is bad, we can move this to a freelist. */ + kmem_cache_free(dlm_mle_cache, mle); +} + + +/* + * LOCK RESOURCE FUNCTIONS + */ + +static void dlm_set_lockres_owner(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 owner) +{ + assert_spin_locked(&res->spinlock); + + mlog_entry("%.*s, %u\n", res->lockname.len, res->lockname.name, owner); + + if (owner == dlm->node_num) + atomic_inc(&dlm->local_resources); + else if (owner == DLM_LOCK_RES_OWNER_UNKNOWN) + atomic_inc(&dlm->unknown_resources); + else + atomic_inc(&dlm->remote_resources); + + res->owner = owner; +} + +void dlm_change_lockres_owner(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, u8 owner) +{ + assert_spin_locked(&res->spinlock); + + if (owner == res->owner) + return; + + if (res->owner == dlm->node_num) + atomic_dec(&dlm->local_resources); + else if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN) + atomic_dec(&dlm->unknown_resources); + else + atomic_dec(&dlm->remote_resources); + + dlm_set_lockres_owner(dlm, res, owner); +} + + +static void dlm_lockres_release(struct kref *kref) +{ + struct dlm_lock_resource *res; + + res = container_of(kref, struct dlm_lock_resource, refs); + + /* This should not happen -- all lockres' have a name + * associated with them at init time. */ + BUG_ON(!res->lockname.name); + + mlog(0, "destroying lockres %.*s\n", res->lockname.len, + res->lockname.name); + + /* By the time we're ready to blow this guy away, we shouldn't + * be on any lists. */ + BUG_ON(!list_empty(&res->list)); + BUG_ON(!list_empty(&res->granted)); + BUG_ON(!list_empty(&res->converting)); + BUG_ON(!list_empty(&res->blocked)); + BUG_ON(!list_empty(&res->dirty)); + BUG_ON(!list_empty(&res->recovering)); + BUG_ON(!list_empty(&res->purge)); + + kfree(res->lockname.name); + + kfree(res); +} + +void dlm_lockres_get(struct dlm_lock_resource *res) +{ + kref_get(&res->refs); +} + +void dlm_lockres_put(struct dlm_lock_resource *res) +{ + kref_put(&res->refs, dlm_lockres_release); +} + +static void dlm_init_lockres(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + const char *name, unsigned int namelen) +{ + char *qname; + + /* If we memset here, we lose our reference to the kmalloc'd + * res->lockname.name, so be sure to init every field + * correctly! */ + + qname = (char *) res->lockname.name; + memcpy(qname, name, namelen); + + res->lockname.len = namelen; + res->lockname.hash = full_name_hash(name, namelen); + + init_waitqueue_head(&res->wq); + spin_lock_init(&res->spinlock); + INIT_LIST_HEAD(&res->list); + INIT_LIST_HEAD(&res->granted); + INIT_LIST_HEAD(&res->converting); + INIT_LIST_HEAD(&res->blocked); + INIT_LIST_HEAD(&res->dirty); + INIT_LIST_HEAD(&res->recovering); + INIT_LIST_HEAD(&res->purge); + atomic_set(&res->asts_reserved, 0); + res->migration_pending = 0; + + kref_init(&res->refs); + + /* just for consistency */ + spin_lock(&res->spinlock); + dlm_set_lockres_owner(dlm, res, DLM_LOCK_RES_OWNER_UNKNOWN); + spin_unlock(&res->spinlock); + + res->state = DLM_LOCK_RES_IN_PROGRESS; + + res->last_used = 0; + + memset(res->lvb, 0, DLM_LVB_LEN); +} + +struct dlm_lock_resource *dlm_new_lockres(struct dlm_ctxt *dlm, + const char *name, + unsigned int namelen) +{ + struct dlm_lock_resource *res; + + res = kmalloc(sizeof(struct dlm_lock_resource), GFP_KERNEL); + if (!res) + return NULL; + + res->lockname.name = kmalloc(namelen, GFP_KERNEL); + if (!res->lockname.name) { + kfree(res); + return NULL; + } + + dlm_init_lockres(dlm, res, name, namelen); + return res; +} + +/* + * lookup a lock resource by name. + * may already exist in the hashtable. + * lockid is null terminated + * + * if not, allocate enough for the lockres and for + * the temporary structure used in doing the mastering. + * + * also, do a lookup in the dlm->master_list to see + * if another node has begun mastering the same lock. + * if so, there should be a block entry in there + * for this name, and we should *not* attempt to master + * the lock here. need to wait around for that node + * to assert_master (or die). + * + */ +struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm, + const char *lockid, + int flags) +{ + struct dlm_lock_resource *tmpres=NULL, *res=NULL; + struct dlm_master_list_entry *mle = NULL; + struct dlm_master_list_entry *alloc_mle = NULL; + int blocked = 0; + int ret, nodenum; + struct dlm_node_iter iter; + unsigned int namelen; + int tries = 0; + + BUG_ON(!lockid); + + namelen = strlen(lockid); + + mlog(0, "get lockres %s (len %d)\n", lockid, namelen); + +lookup: + spin_lock(&dlm->spinlock); + tmpres = __dlm_lookup_lockres(dlm, lockid, namelen); + if (tmpres) { + spin_unlock(&dlm->spinlock); + mlog(0, "found in hash!\n"); + if (res) + dlm_lockres_put(res); + res = tmpres; + goto leave; + } + + if (!res) { + spin_unlock(&dlm->spinlock); + mlog(0, "allocating a new resource\n"); + /* nothing found and we need to allocate one. */ + alloc_mle = (struct dlm_master_list_entry *) + kmem_cache_alloc(dlm_mle_cache, GFP_KERNEL); + if (!alloc_mle) + goto leave; + res = dlm_new_lockres(dlm, lockid, namelen); + if (!res) + goto leave; + goto lookup; + } + + mlog(0, "no lockres found, allocated our own: %p\n", res); + + if (flags & LKM_LOCAL) { + /* caller knows it's safe to assume it's not mastered elsewhere + * DONE! return right away */ + spin_lock(&res->spinlock); + dlm_change_lockres_owner(dlm, res, dlm->node_num); + __dlm_insert_lockres(dlm, res); + spin_unlock(&res->spinlock); + spin_unlock(&dlm->spinlock); + /* lockres still marked IN_PROGRESS */ + goto wake_waiters; + } + + /* check master list to see if another node has started mastering it */ + spin_lock(&dlm->master_lock); + + /* if we found a block, wait for lock to be mastered by another node */ + blocked = dlm_find_mle(dlm, &mle, (char *)lockid, namelen); + if (blocked) { + if (mle->type == DLM_MLE_MASTER) { + mlog(ML_ERROR, "master entry for nonexistent lock!\n"); + BUG(); + } else if (mle->type == DLM_MLE_MIGRATION) { + /* migration is in progress! */ + /* the good news is that we now know the + * "current" master (mle->master). */ + + spin_unlock(&dlm->master_lock); + assert_spin_locked(&dlm->spinlock); + + /* set the lockres owner and hash it */ + spin_lock(&res->spinlock); + dlm_set_lockres_owner(dlm, res, mle->master); + __dlm_insert_lockres(dlm, res); + spin_unlock(&res->spinlock); + spin_unlock(&dlm->spinlock); + + /* master is known, detach */ + dlm_mle_detach_hb_events(dlm, mle); + dlm_put_mle(mle); + mle = NULL; + goto wake_waiters; + } + } else { + /* go ahead and try to master lock on this node */ + mle = alloc_mle; + /* make sure this does not get freed below */ + alloc_mle = NULL; + dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0); + set_bit(dlm->node_num, mle->maybe_map); + list_add(&mle->list, &dlm->master_list); + } + + /* at this point there is either a DLM_MLE_BLOCK or a + * DLM_MLE_MASTER on the master list, so it's safe to add the + * lockres to the hashtable. anyone who finds the lock will + * still have to wait on the IN_PROGRESS. */ + + /* finally add the lockres to its hash bucket */ + __dlm_insert_lockres(dlm, res); + /* get an extra ref on the mle in case this is a BLOCK + * if so, the creator of the BLOCK may try to put the last + * ref at this time in the assert master handler, so we + * need an extra one to keep from a bad ptr deref. */ + dlm_get_mle(mle); + spin_unlock(&dlm->master_lock); + spin_unlock(&dlm->spinlock); + + /* must wait for lock to be mastered elsewhere */ + if (blocked) + goto wait; + +redo_request: + ret = -EINVAL; + dlm_node_iter_init(mle->vote_map, &iter); + while ((nodenum = dlm_node_iter_next(&iter)) >= 0) { + ret = dlm_do_master_request(mle, nodenum); + if (ret < 0) + mlog_errno(ret); + if (mle->master != O2NM_MAX_NODES) { + /* found a master ! */ + break; + } + } + +wait: + /* keep going until the response map includes all nodes */ + ret = dlm_wait_for_lock_mastery(dlm, res, mle, &blocked); + if (ret < 0) { + mlog(0, "%s:%.*s: node map changed, redo the " + "master request now, blocked=%d\n", + dlm->name, res->lockname.len, + res->lockname.name, blocked); + if (++tries > 20) { + mlog(ML_ERROR, "%s:%.*s: spinning on " + "dlm_wait_for_lock_mastery, blocked=%d\n", + dlm->name, res->lockname.len, + res->lockname.name, blocked); + dlm_print_one_lock_resource(res); + /* dlm_print_one_mle(mle); */ + tries = 0; + } + goto redo_request; + } + + mlog(0, "lockres mastered by %u\n", res->owner); + /* make sure we never continue without this */ + BUG_ON(res->owner == O2NM_MAX_NODES); + + /* master is known, detach if not already detached */ + dlm_mle_detach_hb_events(dlm, mle); + dlm_put_mle(mle); + /* put the extra ref */ + dlm_put_mle(mle); + +wake_waiters: + spin_lock(&res->spinlock); + res->state &= ~DLM_LOCK_RES_IN_PROGRESS; + spin_unlock(&res->spinlock); + wake_up(&res->wq); + +leave: + /* need to free the unused mle */ + if (alloc_mle) + kmem_cache_free(dlm_mle_cache, alloc_mle); + + return res; +} + + +#define DLM_MASTERY_TIMEOUT_MS 5000 + +static int dlm_wait_for_lock_mastery(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_master_list_entry *mle, + int *blocked) +{ + u8 m; + int ret, bit; + int map_changed, voting_done; + int assert, sleep; + +recheck: + ret = 0; + assert = 0; + + /* check if another node has already become the owner */ + spin_lock(&res->spinlock); + if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) { + spin_unlock(&res->spinlock); + goto leave; + } + spin_unlock(&res->spinlock); + + spin_lock(&mle->spinlock); + m = mle->master; + map_changed = (memcmp(mle->vote_map, mle->node_map, + sizeof(mle->vote_map)) != 0); + voting_done = (memcmp(mle->vote_map, mle->response_map, + sizeof(mle->vote_map)) == 0); + + /* restart if we hit any errors */ + if (map_changed) { + int b; + mlog(0, "%s: %.*s: node map changed, restarting\n", + dlm->name, res->lockname.len, res->lockname.name); + ret = dlm_restart_lock_mastery(dlm, res, mle, *blocked); + b = (mle->type == DLM_MLE_BLOCK); + if ((*blocked && !b) || (!*blocked && b)) { + mlog(0, "%s:%.*s: status change: old=%d new=%d\n", + dlm->name, res->lockname.len, res->lockname.name, + *blocked, b); + *blocked = b; + } + spin_unlock(&mle->spinlock); + if (ret < 0) { + mlog_errno(ret); + goto leave; + } + mlog(0, "%s:%.*s: restart lock mastery succeeded, " + "rechecking now\n", dlm->name, res->lockname.len, + res->lockname.name); + goto recheck; + } + + if (m != O2NM_MAX_NODES) { + /* another node has done an assert! + * all done! */ + sleep = 0; + } else { + sleep = 1; + /* have all nodes responded? */ + if (voting_done && !*blocked) { + bit = find_next_bit(mle->maybe_map, O2NM_MAX_NODES, 0); + if (dlm->node_num <= bit) { + /* my node number is lowest. + * now tell other nodes that I am + * mastering this. */ + mle->master = dlm->node_num; + assert = 1; + sleep = 0; + } + /* if voting is done, but we have not received + * an assert master yet, we must sleep */ + } + } + + spin_unlock(&mle->spinlock); + + /* sleep if we haven't finished voting yet */ + if (sleep) { + unsigned long timeo = msecs_to_jiffies(DLM_MASTERY_TIMEOUT_MS); + + /* + if (atomic_read(&mle->mle_refs.refcount) < 2) + mlog(ML_ERROR, "mle (%p) refs=%d, name=%.*s\n", mle, + atomic_read(&mle->mle_refs.refcount), + res->lockname.len, res->lockname.name); + */ + atomic_set(&mle->woken, 0); + (void)wait_event_timeout(mle->wq, + (atomic_read(&mle->woken) == 1), + timeo); + if (res->owner == O2NM_MAX_NODES) { + mlog(0, "waiting again\n"); + goto recheck; + } + mlog(0, "done waiting, master is %u\n", res->owner); + ret = 0; + goto leave; + } + + ret = 0; /* done */ + if (assert) { + m = dlm->node_num; + mlog(0, "about to master %.*s here, this=%u\n", + res->lockname.len, res->lockname.name, m); + ret = dlm_do_assert_master(dlm, res->lockname.name, + res->lockname.len, mle->vote_map, 0); + if (ret) { + /* This is a failure in the network path, + * not in the response to the assert_master + * (any nonzero response is a BUG on this node). + * Most likely a socket just got disconnected + * due to node death. */ + mlog_errno(ret); + } + /* no longer need to restart lock mastery. + * all living nodes have been contacted. */ + ret = 0; + } + + /* set the lockres owner */ + spin_lock(&res->spinlock); + dlm_change_lockres_owner(dlm, res, m); + spin_unlock(&res->spinlock); + +leave: + return ret; +} + +struct dlm_bitmap_diff_iter +{ + int curnode; + unsigned long *orig_bm; + unsigned long *cur_bm; + unsigned long diff_bm[BITS_TO_LONGS(O2NM_MAX_NODES)]; +}; + +enum dlm_node_state_change +{ + NODE_DOWN = -1, + NODE_NO_CHANGE = 0, + NODE_UP +}; + +static void dlm_bitmap_diff_iter_init(struct dlm_bitmap_diff_iter *iter, + unsigned long *orig_bm, + unsigned long *cur_bm) +{ + unsigned long p1, p2; + int i; + + iter->curnode = -1; + iter->orig_bm = orig_bm; + iter->cur_bm = cur_bm; + + for (i = 0; i < BITS_TO_LONGS(O2NM_MAX_NODES); i++) { + p1 = *(iter->orig_bm + i); + p2 = *(iter->cur_bm + i); + iter->diff_bm[i] = (p1 & ~p2) | (p2 & ~p1); + } +} + +static int dlm_bitmap_diff_iter_next(struct dlm_bitmap_diff_iter *iter, + enum dlm_node_state_change *state) +{ + int bit; + + if (iter->curnode >= O2NM_MAX_NODES) + return -ENOENT; + + bit = find_next_bit(iter->diff_bm, O2NM_MAX_NODES, + iter->curnode+1); + if (bit >= O2NM_MAX_NODES) { + iter->curnode = O2NM_MAX_NODES; + return -ENOENT; + } + + /* if it was there in the original then this node died */ + if (test_bit(bit, iter->orig_bm)) + *state = NODE_DOWN; + else + *state = NODE_UP; + + iter->curnode = bit; + return bit; +} + + +static int dlm_restart_lock_mastery(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_master_list_entry *mle, + int blocked) +{ + struct dlm_bitmap_diff_iter bdi; + enum dlm_node_state_change sc; + int node; + int ret = 0; + + mlog(0, "something happened such that the " + "master process may need to be restarted!\n"); + + assert_spin_locked(&mle->spinlock); + + dlm_bitmap_diff_iter_init(&bdi, mle->vote_map, mle->node_map); + node = dlm_bitmap_diff_iter_next(&bdi, &sc); + while (node >= 0) { + if (sc == NODE_UP) { + /* a node came up. easy. might not even need + * to talk to it if its node number is higher + * or if we are already blocked. */ + mlog(0, "node up! %d\n", node); + if (blocked) + goto next; + + if (node > dlm->node_num) { + mlog(0, "node > this node. skipping.\n"); + goto next; + } + + /* redo the master request, but only for the new node */ + mlog(0, "sending request to new node\n"); + clear_bit(node, mle->response_map); + set_bit(node, mle->vote_map); + } else { + mlog(ML_ERROR, "node down! %d\n", node); + + /* if the node wasn't involved in mastery skip it, + * but clear it out from the maps so that it will + * not affect mastery of this lockres */ + clear_bit(node, mle->response_map); + clear_bit(node, mle->vote_map); + if (!test_bit(node, mle->maybe_map)) + goto next; + + /* if we're already blocked on lock mastery, and the + * dead node wasn't the expected master, or there is + * another node in the maybe_map, keep waiting */ + if (blocked) { + int lowest = find_next_bit(mle->maybe_map, + O2NM_MAX_NODES, 0); + + /* act like it was never there */ + clear_bit(node, mle->maybe_map); + + if (node != lowest) + goto next; + + mlog(ML_ERROR, "expected master %u died while " + "this node was blocked waiting on it!\n", + node); + lowest = find_next_bit(mle->maybe_map, + O2NM_MAX_NODES, + lowest+1); + if (lowest < O2NM_MAX_NODES) { + mlog(0, "still blocked. waiting " + "on %u now\n", lowest); + goto next; + } + + /* mle is an MLE_BLOCK, but there is now + * nothing left to block on. we need to return + * all the way back out and try again with + * an MLE_MASTER. dlm_do_local_recovery_cleanup + * has already run, so the mle refcount is ok */ + mlog(0, "no longer blocking. we can " + "try to master this here\n"); + mle->type = DLM_MLE_MASTER; + memset(mle->maybe_map, 0, + sizeof(mle->maybe_map)); + memset(mle->response_map, 0, + sizeof(mle->maybe_map)); + memcpy(mle->vote_map, mle->node_map, + sizeof(mle->node_map)); + mle->u.res = res; + set_bit(dlm->node_num, mle->maybe_map); + + ret = -EAGAIN; + goto next; + } + + clear_bit(node, mle->maybe_map); + if (node > dlm->node_num) + goto next; + + mlog(0, "dead node in map!\n"); + /* yuck. go back and re-contact all nodes + * in the vote_map, removing this node. */ + memset(mle->response_map, 0, + sizeof(mle->response_map)); + } + ret = -EAGAIN; +next: + node = dlm_bitmap_diff_iter_next(&bdi, &sc); + } + return ret; +} + + +/* + * DLM_MASTER_REQUEST_MSG + * + * returns: 0 on success, + * -errno on a network error + * + * on error, the caller should assume the target node is "dead" + * + */ + +static int dlm_do_master_request(struct dlm_master_list_entry *mle, int to) +{ + struct dlm_ctxt *dlm = mle->dlm; + struct dlm_master_request request; + int ret, response=0, resend; + + memset(&request, 0, sizeof(request)); + request.node_idx = dlm->node_num; + + BUG_ON(mle->type == DLM_MLE_MIGRATION); + + if (mle->type != DLM_MLE_MASTER) { + request.namelen = mle->u.name.len; + memcpy(request.name, mle->u.name.name, request.namelen); + } else { + request.namelen = mle->u.res->lockname.len; + memcpy(request.name, mle->u.res->lockname.name, + request.namelen); + } + +again: + ret = o2net_send_message(DLM_MASTER_REQUEST_MSG, dlm->key, &request, + sizeof(request), to, &response); + if (ret < 0) { + if (ret == -ESRCH) { + /* should never happen */ + mlog(ML_ERROR, "TCP stack not ready!\n"); + BUG(); + } else if (ret == -EINVAL) { + mlog(ML_ERROR, "bad args passed to o2net!\n"); + BUG(); + } else if (ret == -ENOMEM) { + mlog(ML_ERROR, "out of memory while trying to send " + "network message! retrying\n"); + /* this is totally crude */ + msleep(50); + goto again; + } else if (!dlm_is_host_down(ret)) { + /* not a network error. bad. */ + mlog_errno(ret); + mlog(ML_ERROR, "unhandled error!"); + BUG(); + } + /* all other errors should be network errors, + * and likely indicate node death */ + mlog(ML_ERROR, "link to %d went down!\n", to); + goto out; + } + + ret = 0; + resend = 0; + spin_lock(&mle->spinlock); + switch (response) { + case DLM_MASTER_RESP_YES: + set_bit(to, mle->response_map); + mlog(0, "node %u is the master, response=YES\n", to); + mle->master = to; + break; + case DLM_MASTER_RESP_NO: + mlog(0, "node %u not master, response=NO\n", to); + set_bit(to, mle->response_map); + break; + case DLM_MASTER_RESP_MAYBE: + mlog(0, "node %u not master, response=MAYBE\n", to); + set_bit(to, mle->response_map); + set_bit(to, mle->maybe_map); + break; + case DLM_MASTER_RESP_ERROR: + mlog(0, "node %u hit an error, resending\n", to); + resend = 1; + response = 0; + break; + default: + mlog(ML_ERROR, "bad response! %u\n", response); + BUG(); + } + spin_unlock(&mle->spinlock); + if (resend) { + /* this is also totally crude */ + msleep(50); + goto again; + } + +out: + return ret; +} + +/* + * locks that can be taken here: + * dlm->spinlock + * res->spinlock + * mle->spinlock + * dlm->master_list + * + * if possible, TRIM THIS DOWN!!! + */ +int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data) +{ + u8 response = DLM_MASTER_RESP_MAYBE; + struct dlm_ctxt *dlm = data; + struct dlm_lock_resource *res; + struct dlm_master_request *request = (struct dlm_master_request *) msg->buf; + struct dlm_master_list_entry *mle = NULL, *tmpmle = NULL; + char *name; + unsigned int namelen; + int found, ret; + int set_maybe; + + if (!dlm_grab(dlm)) + return DLM_MASTER_RESP_NO; + + if (!dlm_domain_fully_joined(dlm)) { + response = DLM_MASTER_RESP_NO; + goto send_response; + } + + name = request->name; + namelen = request->namelen; + + if (namelen > DLM_LOCKID_NAME_MAX) { + response = DLM_IVBUFLEN; + goto send_response; + } + +way_up_top: + spin_lock(&dlm->spinlock); + res = __dlm_lookup_lockres(dlm, name, namelen); + if (res) { + spin_unlock(&dlm->spinlock); + + /* take care of the easy cases up front */ + spin_lock(&res->spinlock); + if (res->state & DLM_LOCK_RES_RECOVERING) { + spin_unlock(&res->spinlock); + mlog(0, "returning DLM_MASTER_RESP_ERROR since res is " + "being recovered\n"); + response = DLM_MASTER_RESP_ERROR; + if (mle) + kmem_cache_free(dlm_mle_cache, mle); + goto send_response; + } + + if (res->owner == dlm->node_num) { + u32 flags = DLM_ASSERT_MASTER_MLE_CLEANUP; + spin_unlock(&res->spinlock); + // mlog(0, "this node is the master\n"); + response = DLM_MASTER_RESP_YES; + if (mle) + kmem_cache_free(dlm_mle_cache, mle); + + /* this node is the owner. + * there is some extra work that needs to + * happen now. the requesting node has + * caused all nodes up to this one to + * create mles. this node now needs to + * go back and clean those up. */ + mlog(0, "%u is the owner of %.*s, cleaning everyone else\n", + dlm->node_num, res->lockname.len, res->lockname.name); + ret = dlm_dispatch_assert_master(dlm, res, 1, + request->node_idx, + flags); + if (ret < 0) { + mlog(ML_ERROR, "failed to dispatch assert " + "master work\n"); + response = DLM_MASTER_RESP_ERROR; + } + goto send_response; + } else if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) { + spin_unlock(&res->spinlock); + // mlog(0, "node %u is the master\n", res->owner); + response = DLM_MASTER_RESP_NO; + if (mle) + kmem_cache_free(dlm_mle_cache, mle); + goto send_response; + } + + /* ok, there is no owner. either this node is + * being blocked, or it is actively trying to + * master this lock. */ + if (!(res->state & DLM_LOCK_RES_IN_PROGRESS)) { + mlog(ML_ERROR, "lock with no owner should be " + "in-progress!\n"); + BUG(); + } + + // mlog(0, "lockres is in progress...\n"); + spin_lock(&dlm->master_lock); + found = dlm_find_mle(dlm, &tmpmle, name, namelen); + if (!found) { + mlog(ML_ERROR, "no mle found for this lock!\n"); + BUG(); + } + set_maybe = 1; + spin_lock(&tmpmle->spinlock); + if (tmpmle->type == DLM_MLE_BLOCK) { + // mlog(0, "this node is waiting for " + // "lockres to be mastered\n"); + response = DLM_MASTER_RESP_NO; + } else if (tmpmle->type == DLM_MLE_MIGRATION) { + mlog(0, "node %u is master, but trying to migrate to " + "node %u.\n", tmpmle->master, tmpmle->new_master); + if (tmpmle->master == dlm->node_num) { + response = DLM_MASTER_RESP_YES; + mlog(ML_ERROR, "no owner on lockres, but this " + "node is trying to migrate it to %u?!\n", + tmpmle->new_master); + BUG(); + } else { + /* the real master can respond on its own */ + response = DLM_MASTER_RESP_NO; + } + } else if (tmpmle->master != DLM_LOCK_RES_OWNER_UNKNOWN) { + set_maybe = 0; + if (tmpmle->master == dlm->node_num) + response = DLM_MASTER_RESP_YES; + else + response = DLM_MASTER_RESP_NO; + } else { + // mlog(0, "this node is attempting to " + // "master lockres\n"); + response = DLM_MASTER_RESP_MAYBE; + } + if (set_maybe) + set_bit(request->node_idx, tmpmle->maybe_map); + spin_unlock(&tmpmle->spinlock); + + spin_unlock(&dlm->master_lock); + spin_unlock(&res->spinlock); + + /* keep the mle attached to heartbeat events */ + dlm_put_mle(tmpmle); + if (mle) + kmem_cache_free(dlm_mle_cache, mle); + goto send_response; + } + + /* + * lockres doesn't exist on this node + * if there is an MLE_BLOCK, return NO + * if there is an MLE_MASTER, return MAYBE + * otherwise, add an MLE_BLOCK, return NO + */ + spin_lock(&dlm->master_lock); + found = dlm_find_mle(dlm, &tmpmle, name, namelen); + if (!found) { + /* this lockid has never been seen on this node yet */ + // mlog(0, "no mle found\n"); + if (!mle) { + spin_unlock(&dlm->master_lock); + spin_unlock(&dlm->spinlock); + + mle = (struct dlm_master_list_entry *) + kmem_cache_alloc(dlm_mle_cache, GFP_KERNEL); + if (!mle) { + // bad bad bad... this sucks. + response = DLM_MASTER_RESP_ERROR; + goto send_response; + } + spin_lock(&dlm->spinlock); + dlm_init_mle(mle, DLM_MLE_BLOCK, dlm, NULL, + name, namelen); + spin_unlock(&dlm->spinlock); + goto way_up_top; + } + + // mlog(0, "this is second time thru, already allocated, " + // "add the block.\n"); + set_bit(request->node_idx, mle->maybe_map); + list_add(&mle->list, &dlm->master_list); + response = DLM_MASTER_RESP_NO; + } else { + // mlog(0, "mle was found\n"); + set_maybe = 1; + spin_lock(&tmpmle->spinlock); + if (tmpmle->type == DLM_MLE_BLOCK) + response = DLM_MASTER_RESP_NO; + else if (tmpmle->type == DLM_MLE_MIGRATION) { + mlog(0, "migration mle was found (%u->%u)\n", + tmpmle->master, tmpmle->new_master); + if (tmpmle->master == dlm->node_num) { + mlog(ML_ERROR, "no lockres, but migration mle " + "says that this node is master!\n"); + BUG(); + } + /* real master can respond on its own */ + response = DLM_MASTER_RESP_NO; + } else { + if (tmpmle->master == dlm->node_num) { + response = DLM_MASTER_RESP_YES; + set_maybe = 0; + } else + response = DLM_MASTER_RESP_MAYBE; + } + if (set_maybe) + set_bit(request->node_idx, tmpmle->maybe_map); + spin_unlock(&tmpmle->spinlock); + } + spin_unlock(&dlm->master_lock); + spin_unlock(&dlm->spinlock); + + if (found) { + /* keep the mle attached to heartbeat events */ + dlm_put_mle(tmpmle); + } +send_response: + dlm_put(dlm); + return response; +} + +/* + * DLM_ASSERT_MASTER_MSG + */ + + +/* + * NOTE: this can be used for debugging + * can periodically run all locks owned by this node + * and re-assert across the cluster... + */ +static int dlm_do_assert_master(struct dlm_ctxt *dlm, const char *lockname, + unsigned int namelen, void *nodemap, + u32 flags) +{ + struct dlm_assert_master assert; + int to, tmpret; + struct dlm_node_iter iter; + int ret = 0; + + BUG_ON(namelen > O2NM_MAX_NAME_LEN); + + /* note that if this nodemap is empty, it returns 0 */ + dlm_node_iter_init(nodemap, &iter); + while ((to = dlm_node_iter_next(&iter)) >= 0) { + int r = 0; + mlog(0, "sending assert master to %d (%.*s)\n", to, + namelen, lockname); + memset(&assert, 0, sizeof(assert)); + assert.node_idx = dlm->node_num; + assert.namelen = namelen; + memcpy(assert.name, lockname, namelen); + assert.flags = cpu_to_be32(flags); + + tmpret = o2net_send_message(DLM_ASSERT_MASTER_MSG, dlm->key, + &assert, sizeof(assert), to, &r); + if (tmpret < 0) { + mlog(ML_ERROR, "assert_master returned %d!\n", tmpret); + if (!dlm_is_host_down(tmpret)) { + mlog(ML_ERROR, "unhandled error!\n"); + BUG(); + } + /* a node died. finish out the rest of the nodes. */ + mlog(ML_ERROR, "link to %d went down!\n", to); + /* any nonzero status return will do */ + ret = tmpret; + } else if (r < 0) { + /* ok, something horribly messed. kill thyself. */ + mlog(ML_ERROR,"during assert master of %.*s to %u, " + "got %d.\n", namelen, lockname, to, r); + dlm_dump_lock_resources(dlm); + BUG(); + } + } + + return ret; +} + +/* + * locks that can be taken here: + * dlm->spinlock + * res->spinlock + * mle->spinlock + * dlm->master_list + * + * if possible, TRIM THIS DOWN!!! + */ +int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_master_list_entry *mle = NULL; + struct dlm_assert_master *assert = (struct dlm_assert_master *)msg->buf; + struct dlm_lock_resource *res = NULL; + char *name; + unsigned int namelen; + u32 flags; + + if (!dlm_grab(dlm)) + return 0; + + name = assert->name; + namelen = assert->namelen; + flags = be32_to_cpu(assert->flags); + + if (namelen > DLM_LOCKID_NAME_MAX) { + mlog(ML_ERROR, "Invalid name length!"); + goto done; + } + + spin_lock(&dlm->spinlock); + + if (flags) + mlog(0, "assert_master with flags: %u\n", flags); + + /* find the MLE */ + spin_lock(&dlm->master_lock); + if (!dlm_find_mle(dlm, &mle, name, namelen)) { + /* not an error, could be master just re-asserting */ + mlog(0, "just got an assert_master from %u, but no " + "MLE for it! (%.*s)\n", assert->node_idx, + namelen, name); + } else { + int bit = find_next_bit (mle->maybe_map, O2NM_MAX_NODES, 0); + if (bit >= O2NM_MAX_NODES) { + /* not necessarily an error, though less likely. + * could be master just re-asserting. */ + mlog(ML_ERROR, "no bits set in the maybe_map, but %u " + "is asserting! (%.*s)\n", assert->node_idx, + namelen, name); + } else if (bit != assert->node_idx) { + if (flags & DLM_ASSERT_MASTER_MLE_CLEANUP) { + mlog(0, "master %u was found, %u should " + "back off\n", assert->node_idx, bit); + } else { + /* with the fix for bug 569, a higher node + * number winning the mastery will respond + * YES to mastery requests, but this node + * had no way of knowing. let it pass. */ + mlog(ML_ERROR, "%u is the lowest node, " + "%u is asserting. (%.*s) %u must " + "have begun after %u won.\n", bit, + assert->node_idx, namelen, name, bit, + assert->node_idx); + } + } + } + spin_unlock(&dlm->master_lock); + + /* ok everything checks out with the MLE + * now check to see if there is a lockres */ + res = __dlm_lookup_lockres(dlm, name, namelen); + if (res) { + spin_lock(&res->spinlock); + if (res->state & DLM_LOCK_RES_RECOVERING) { + mlog(ML_ERROR, "%u asserting but %.*s is " + "RECOVERING!\n", assert->node_idx, namelen, name); + goto kill; + } + if (!mle) { + if (res->owner != assert->node_idx) { + mlog(ML_ERROR, "assert_master from " + "%u, but current owner is " + "%u! (%.*s)\n", + assert->node_idx, res->owner, + namelen, name); + goto kill; + } + } else if (mle->type != DLM_MLE_MIGRATION) { + if (res->owner != DLM_LOCK_RES_OWNER_UNKNOWN) { + /* owner is just re-asserting */ + if (res->owner == assert->node_idx) { + mlog(0, "owner %u re-asserting on " + "lock %.*s\n", assert->node_idx, + namelen, name); + goto ok; + } + mlog(ML_ERROR, "got assert_master from " + "node %u, but %u is the owner! " + "(%.*s)\n", assert->node_idx, + res->owner, namelen, name); + goto kill; + } + if (!(res->state & DLM_LOCK_RES_IN_PROGRESS)) { + mlog(ML_ERROR, "got assert from %u, but lock " + "with no owner should be " + "in-progress! (%.*s)\n", + assert->node_idx, + namelen, name); + goto kill; + } + } else /* mle->type == DLM_MLE_MIGRATION */ { + /* should only be getting an assert from new master */ + if (assert->node_idx != mle->new_master) { + mlog(ML_ERROR, "got assert from %u, but " + "new master is %u, and old master " + "was %u (%.*s)\n", + assert->node_idx, mle->new_master, + mle->master, namelen, name); + goto kill; + } + + } +ok: + spin_unlock(&res->spinlock); + } + spin_unlock(&dlm->spinlock); + + // mlog(0, "woo! got an assert_master from node %u!\n", + // assert->node_idx); + if (mle) { + int extra_ref; + + spin_lock(&mle->spinlock); + extra_ref = !!(mle->type == DLM_MLE_BLOCK + || mle->type == DLM_MLE_MIGRATION); + mle->master = assert->node_idx; + atomic_set(&mle->woken, 1); + wake_up(&mle->wq); + spin_unlock(&mle->spinlock); + + if (mle->type == DLM_MLE_MIGRATION && res) { + mlog(0, "finishing off migration of lockres %.*s, " + "from %u to %u\n", + res->lockname.len, res->lockname.name, + dlm->node_num, mle->new_master); + spin_lock(&res->spinlock); + res->state &= ~DLM_LOCK_RES_MIGRATING; + dlm_change_lockres_owner(dlm, res, mle->new_master); + BUG_ON(res->state & DLM_LOCK_RES_DIRTY); + spin_unlock(&res->spinlock); + } + /* master is known, detach if not already detached */ + dlm_mle_detach_hb_events(dlm, mle); + dlm_put_mle(mle); + + if (extra_ref) { + /* the assert master message now balances the extra + * ref given by the master / migration request message. + * if this is the last put, it will be removed + * from the list. */ + dlm_put_mle(mle); + } + } + +done: + if (res) + dlm_lockres_put(res); + dlm_put(dlm); + return 0; + +kill: + /* kill the caller! */ + spin_unlock(&res->spinlock); + spin_unlock(&dlm->spinlock); + dlm_lockres_put(res); + mlog(ML_ERROR, "Bad message received from another node. Dumping state " + "and killing the other node now! This node is OK and can continue.\n"); + dlm_dump_lock_resources(dlm); + dlm_put(dlm); + return -EINVAL; +} + +int dlm_dispatch_assert_master(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + int ignore_higher, u8 request_from, u32 flags) +{ + struct dlm_work_item *item; + item = kcalloc(1, sizeof(*item), GFP_KERNEL); + if (!item) + return -ENOMEM; + + + /* queue up work for dlm_assert_master_worker */ + dlm_grab(dlm); /* get an extra ref for the work item */ + dlm_init_work_item(dlm, item, dlm_assert_master_worker, NULL); + item->u.am.lockres = res; /* already have a ref */ + /* can optionally ignore node numbers higher than this node */ + item->u.am.ignore_higher = ignore_higher; + item->u.am.request_from = request_from; + item->u.am.flags = flags; + + spin_lock(&dlm->work_lock); + list_add_tail(&item->list, &dlm->work_list); + spin_unlock(&dlm->work_lock); + + schedule_work(&dlm->dispatched_work); + return 0; +} + +static void dlm_assert_master_worker(struct dlm_work_item *item, void *data) +{ + struct dlm_ctxt *dlm = data; + int ret = 0; + struct dlm_lock_resource *res; + unsigned long nodemap[BITS_TO_LONGS(O2NM_MAX_NODES)]; + int ignore_higher; + int bit; + u8 request_from; + u32 flags; + + dlm = item->dlm; + res = item->u.am.lockres; + ignore_higher = item->u.am.ignore_higher; + request_from = item->u.am.request_from; + flags = item->u.am.flags; + + spin_lock(&dlm->spinlock); + memcpy(nodemap, dlm->domain_map, sizeof(nodemap)); + spin_unlock(&dlm->spinlock); + + clear_bit(dlm->node_num, nodemap); + if (ignore_higher) { + /* if is this just to clear up mles for nodes below + * this node, do not send the message to the original + * caller or any node number higher than this */ + clear_bit(request_from, nodemap); + bit = dlm->node_num; + while (1) { + bit = find_next_bit(nodemap, O2NM_MAX_NODES, + bit+1); + if (bit >= O2NM_MAX_NODES) + break; + clear_bit(bit, nodemap); + } + } + + /* this call now finishes out the nodemap + * even if one or more nodes die */ + mlog(0, "worker about to master %.*s here, this=%u\n", + res->lockname.len, res->lockname.name, dlm->node_num); + ret = dlm_do_assert_master(dlm, res->lockname.name, + res->lockname.len, + nodemap, flags); + if (ret < 0) { + /* no need to restart, we are done */ + mlog_errno(ret); + } + + dlm_lockres_put(res); + + mlog(0, "finished with dlm_assert_master_worker\n"); +} + + +/* + * DLM_MIGRATE_LOCKRES + */ + + +int dlm_migrate_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + u8 target) +{ + struct dlm_master_list_entry *mle = NULL; + struct dlm_master_list_entry *oldmle = NULL; + struct dlm_migratable_lockres *mres = NULL; + int ret = -EINVAL; + const char *name; + unsigned int namelen; + int mle_added = 0; + struct list_head *queue, *iter; + int i; + struct dlm_lock *lock; + int empty = 1; + + if (!dlm_grab(dlm)) + return -EINVAL; + + name = res->lockname.name; + namelen = res->lockname.len; + + mlog(0, "migrating %.*s to %u\n", namelen, name, target); + + /* + * ensure this lockres is a proper candidate for migration + */ + spin_lock(&res->spinlock); + if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN) { + mlog(0, "cannot migrate lockres with unknown owner!\n"); + spin_unlock(&res->spinlock); + goto leave; + } + if (res->owner != dlm->node_num) { + mlog(0, "cannot migrate lockres this node doesn't own!\n"); + spin_unlock(&res->spinlock); + goto leave; + } + mlog(0, "checking queues...\n"); + queue = &res->granted; + for (i=0; i<3; i++) { + list_for_each(iter, queue) { + lock = list_entry (iter, struct dlm_lock, list); + empty = 0; + if (lock->ml.node == dlm->node_num) { + mlog(0, "found a lock owned by this node " + "still on the %s queue! will not " + "migrate this lockres\n", + i==0 ? "granted" : + (i==1 ? "converting" : "blocked")); + spin_unlock(&res->spinlock); + ret = -ENOTEMPTY; + goto leave; + } + } + queue++; + } + mlog(0, "all locks on this lockres are nonlocal. continuing\n"); + spin_unlock(&res->spinlock); + + /* no work to do */ + if (empty) { + mlog(0, "no locks were found on this lockres! done!\n"); + ret = 0; + goto leave; + } + + /* + * preallocate up front + * if this fails, abort + */ + + ret = -ENOMEM; + mres = (struct dlm_migratable_lockres *) __get_free_page(GFP_KERNEL); + if (!mres) { + mlog_errno(ret); + goto leave; + } + + mle = (struct dlm_master_list_entry *) kmem_cache_alloc(dlm_mle_cache, + GFP_KERNEL); + if (!mle) { + mlog_errno(ret); + goto leave; + } + ret = 0; + + /* + * find a node to migrate the lockres to + */ + + mlog(0, "picking a migration node\n"); + spin_lock(&dlm->spinlock); + /* pick a new node */ + if (!test_bit(target, dlm->domain_map) || + target >= O2NM_MAX_NODES) { + target = dlm_pick_migration_target(dlm, res); + } + mlog(0, "node %u chosen for migration\n", target); + + if (target >= O2NM_MAX_NODES || + !test_bit(target, dlm->domain_map)) { + /* target chosen is not alive */ + ret = -EINVAL; + } + + if (ret) { + spin_unlock(&dlm->spinlock); + goto fail; + } + + mlog(0, "continuing with target = %u\n", target); + + /* + * clear any existing master requests and + * add the migration mle to the list + */ + spin_lock(&dlm->master_lock); + ret = dlm_add_migration_mle(dlm, res, mle, &oldmle, name, + namelen, target, dlm->node_num); + spin_unlock(&dlm->master_lock); + spin_unlock(&dlm->spinlock); + + if (ret == -EEXIST) { + mlog(0, "another process is already migrating it\n"); + goto fail; + } + mle_added = 1; + + /* + * set the MIGRATING flag and flush asts + * if we fail after this we need to re-dirty the lockres + */ + if (dlm_mark_lockres_migrating(dlm, res, target) < 0) { + mlog(ML_ERROR, "tried to migrate %.*s to %u, but " + "the target went down.\n", res->lockname.len, + res->lockname.name, target); + spin_lock(&res->spinlock); + res->state &= ~DLM_LOCK_RES_MIGRATING; + spin_unlock(&res->spinlock); + ret = -EINVAL; + } + +fail: + if (oldmle) { + /* master is known, detach if not already detached */ + dlm_mle_detach_hb_events(dlm, oldmle); + dlm_put_mle(oldmle); + } + + if (ret < 0) { + if (mle_added) { + dlm_mle_detach_hb_events(dlm, mle); + dlm_put_mle(mle); + } else if (mle) { + kmem_cache_free(dlm_mle_cache, mle); + } + goto leave; + } + + /* + * at this point, we have a migration target, an mle + * in the master list, and the MIGRATING flag set on + * the lockres + */ + + + /* get an extra reference on the mle. + * otherwise the assert_master from the new + * master will destroy this. + * also, make sure that all callers of dlm_get_mle + * take both dlm->spinlock and dlm->master_lock */ + spin_lock(&dlm->spinlock); + spin_lock(&dlm->master_lock); + dlm_get_mle(mle); + spin_unlock(&dlm->master_lock); + spin_unlock(&dlm->spinlock); + + /* notify new node and send all lock state */ + /* call send_one_lockres with migration flag. + * this serves as notice to the target node that a + * migration is starting. */ + ret = dlm_send_one_lockres(dlm, res, mres, target, + DLM_MRES_MIGRATION); + + if (ret < 0) { + mlog(0, "migration to node %u failed with %d\n", + target, ret); + /* migration failed, detach and clean up mle */ + dlm_mle_detach_hb_events(dlm, mle); + dlm_put_mle(mle); + dlm_put_mle(mle); + goto leave; + } + + /* at this point, the target sends a message to all nodes, + * (using dlm_do_migrate_request). this node is skipped since + * we had to put an mle in the list to begin the process. this + * node now waits for target to do an assert master. this node + * will be the last one notified, ensuring that the migration + * is complete everywhere. if the target dies while this is + * going on, some nodes could potentially see the target as the + * master, so it is important that my recovery finds the migration + * mle and sets the master to UNKNONWN. */ + + + /* wait for new node to assert master */ + while (1) { + ret = wait_event_interruptible_timeout(mle->wq, + (atomic_read(&mle->woken) == 1), + msecs_to_jiffies(5000)); + + if (ret >= 0) { + if (atomic_read(&mle->woken) == 1 || + res->owner == target) + break; + + mlog(0, "timed out during migration\n"); + } + if (ret == -ERESTARTSYS) { + /* migration failed, detach and clean up mle */ + dlm_mle_detach_hb_events(dlm, mle); + dlm_put_mle(mle); + dlm_put_mle(mle); + goto leave; + } + /* TODO: if node died: stop, clean up, return error */ + } + + /* all done, set the owner, clear the flag */ + spin_lock(&res->spinlock); + dlm_set_lockres_owner(dlm, res, target); + res->state &= ~DLM_LOCK_RES_MIGRATING; + dlm_remove_nonlocal_locks(dlm, res); + spin_unlock(&res->spinlock); + wake_up(&res->wq); + + /* master is known, detach if not already detached */ + dlm_mle_detach_hb_events(dlm, mle); + dlm_put_mle(mle); + ret = 0; + + dlm_lockres_calc_usage(dlm, res); + +leave: + /* re-dirty the lockres if we failed */ + if (ret < 0) + dlm_kick_thread(dlm, res); + + /* TODO: cleanup */ + if (mres) + free_page((unsigned long)mres); + + dlm_put(dlm); + + mlog(0, "returning %d\n", ret); + return ret; +} +EXPORT_SYMBOL_GPL(dlm_migrate_lockres); + +int dlm_lock_basts_flushed(struct dlm_ctxt *dlm, struct dlm_lock *lock) +{ + int ret; + spin_lock(&dlm->ast_lock); + spin_lock(&lock->spinlock); + ret = (list_empty(&lock->bast_list) && !lock->bast_pending); + spin_unlock(&lock->spinlock); + spin_unlock(&dlm->ast_lock); + return ret; +} + +static int dlm_migration_can_proceed(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 mig_target) +{ + int can_proceed; + spin_lock(&res->spinlock); + can_proceed = !!(res->state & DLM_LOCK_RES_MIGRATING); + spin_unlock(&res->spinlock); + + /* target has died, so make the caller break out of the + * wait_event, but caller must recheck the domain_map */ + spin_lock(&dlm->spinlock); + if (!test_bit(mig_target, dlm->domain_map)) + can_proceed = 1; + spin_unlock(&dlm->spinlock); + return can_proceed; +} + +int dlm_lockres_is_dirty(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) +{ + int ret; + spin_lock(&res->spinlock); + ret = !!(res->state & DLM_LOCK_RES_DIRTY); + spin_unlock(&res->spinlock); + return ret; +} + + +static int dlm_mark_lockres_migrating(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 target) +{ + int ret = 0; + + mlog(0, "dlm_mark_lockres_migrating: %.*s, from %u to %u\n", + res->lockname.len, res->lockname.name, dlm->node_num, + target); + /* need to set MIGRATING flag on lockres. this is done by + * ensuring that all asts have been flushed for this lockres. */ + spin_lock(&res->spinlock); + BUG_ON(res->migration_pending); + res->migration_pending = 1; + /* strategy is to reserve an extra ast then release + * it below, letting the release do all of the work */ + __dlm_lockres_reserve_ast(res); + spin_unlock(&res->spinlock); + + /* now flush all the pending asts.. hang out for a bit */ + dlm_kick_thread(dlm, res); + wait_event(dlm->ast_wq, !dlm_lockres_is_dirty(dlm, res)); + dlm_lockres_release_ast(dlm, res); + + mlog(0, "about to wait on migration_wq, dirty=%s\n", + res->state & DLM_LOCK_RES_DIRTY ? "yes" : "no"); + /* if the extra ref we just put was the final one, this + * will pass thru immediately. otherwise, we need to wait + * for the last ast to finish. */ +again: + ret = wait_event_interruptible_timeout(dlm->migration_wq, + dlm_migration_can_proceed(dlm, res, target), + msecs_to_jiffies(1000)); + if (ret < 0) { + mlog(0, "woken again: migrating? %s, dead? %s\n", + res->state & DLM_LOCK_RES_MIGRATING ? "yes":"no", + test_bit(target, dlm->domain_map) ? "no":"yes"); + } else { + mlog(0, "all is well: migrating? %s, dead? %s\n", + res->state & DLM_LOCK_RES_MIGRATING ? "yes":"no", + test_bit(target, dlm->domain_map) ? "no":"yes"); + } + if (!dlm_migration_can_proceed(dlm, res, target)) { + mlog(0, "trying again...\n"); + goto again; + } + + /* did the target go down or die? */ + spin_lock(&dlm->spinlock); + if (!test_bit(target, dlm->domain_map)) { + mlog(ML_ERROR, "aha. migration target %u just went down\n", + target); + ret = -EHOSTDOWN; + } + spin_unlock(&dlm->spinlock); + + /* + * at this point: + * + * o the DLM_LOCK_RES_MIGRATING flag is set + * o there are no pending asts on this lockres + * o all processes trying to reserve an ast on this + * lockres must wait for the MIGRATING flag to clear + */ + return ret; +} + +/* last step in the migration process. + * original master calls this to free all of the dlm_lock + * structures that used to be for other nodes. */ +static void dlm_remove_nonlocal_locks(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + struct list_head *iter, *iter2; + struct list_head *queue = &res->granted; + int i; + struct dlm_lock *lock; + + assert_spin_locked(&res->spinlock); + + BUG_ON(res->owner == dlm->node_num); + + for (i=0; i<3; i++) { + list_for_each_safe(iter, iter2, queue) { + lock = list_entry (iter, struct dlm_lock, list); + if (lock->ml.node != dlm->node_num) { + mlog(0, "putting lock for node %u\n", + lock->ml.node); + /* be extra careful */ + BUG_ON(!list_empty(&lock->ast_list)); + BUG_ON(!list_empty(&lock->bast_list)); + BUG_ON(lock->ast_pending); + BUG_ON(lock->bast_pending); + list_del_init(&lock->list); + dlm_lock_put(lock); + } + } + queue++; + } +} + +/* for now this is not too intelligent. we will + * need stats to make this do the right thing. + * this just finds the first lock on one of the + * queues and uses that node as the target. */ +static u8 dlm_pick_migration_target(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + int i; + struct list_head *queue = &res->granted; + struct list_head *iter; + struct dlm_lock *lock; + int nodenum; + + assert_spin_locked(&dlm->spinlock); + + spin_lock(&res->spinlock); + for (i=0; i<3; i++) { + list_for_each(iter, queue) { + /* up to the caller to make sure this node + * is alive */ + lock = list_entry (iter, struct dlm_lock, list); + if (lock->ml.node != dlm->node_num) { + spin_unlock(&res->spinlock); + return lock->ml.node; + } + } + queue++; + } + spin_unlock(&res->spinlock); + mlog(0, "have not found a suitable target yet! checking domain map\n"); + + /* ok now we're getting desperate. pick anyone alive. */ + nodenum = -1; + while (1) { + nodenum = find_next_bit(dlm->domain_map, + O2NM_MAX_NODES, nodenum+1); + mlog(0, "found %d in domain map\n", nodenum); + if (nodenum >= O2NM_MAX_NODES) + break; + if (nodenum != dlm->node_num) { + mlog(0, "picking %d\n", nodenum); + return nodenum; + } + } + + mlog(0, "giving up. no master to migrate to\n"); + return DLM_LOCK_RES_OWNER_UNKNOWN; +} + + + +/* this is called by the new master once all lockres + * data has been received */ +static int dlm_do_migrate_request(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 master, u8 new_master, + struct dlm_node_iter *iter) +{ + struct dlm_migrate_request migrate; + int ret, status = 0; + int nodenum; + + memset(&migrate, 0, sizeof(migrate)); + migrate.namelen = res->lockname.len; + memcpy(migrate.name, res->lockname.name, migrate.namelen); + migrate.new_master = new_master; + migrate.master = master; + + ret = 0; + + /* send message to all nodes, except the master and myself */ + while ((nodenum = dlm_node_iter_next(iter)) >= 0) { + if (nodenum == master || + nodenum == new_master) + continue; + + ret = o2net_send_message(DLM_MIGRATE_REQUEST_MSG, dlm->key, + &migrate, sizeof(migrate), nodenum, + &status); + if (ret < 0) + mlog_errno(ret); + else if (status < 0) { + mlog(0, "migrate request (node %u) returned %d!\n", + nodenum, status); + ret = status; + } + } + + if (ret < 0) + mlog_errno(ret); + + mlog(0, "returning ret=%d\n", ret); + return ret; +} + + +/* if there is an existing mle for this lockres, we now know who the master is. + * (the one who sent us *this* message) we can clear it up right away. + * since the process that put the mle on the list still has a reference to it, + * we can unhash it now, set the master and wake the process. as a result, + * we will have no mle in the list to start with. now we can add an mle for + * the migration and this should be the only one found for those scanning the + * list. */ +int dlm_migrate_request_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_lock_resource *res = NULL; + struct dlm_migrate_request *migrate = (struct dlm_migrate_request *) msg->buf; + struct dlm_master_list_entry *mle = NULL, *oldmle = NULL; + const char *name; + unsigned int namelen; + int ret = 0; + + if (!dlm_grab(dlm)) + return -EINVAL; + + name = migrate->name; + namelen = migrate->namelen; + + /* preallocate.. if this fails, abort */ + mle = (struct dlm_master_list_entry *) kmem_cache_alloc(dlm_mle_cache, + GFP_KERNEL); + + if (!mle) { + ret = -ENOMEM; + goto leave; + } + + /* check for pre-existing lock */ + spin_lock(&dlm->spinlock); + res = __dlm_lookup_lockres(dlm, name, namelen); + spin_lock(&dlm->master_lock); + + if (res) { + spin_lock(&res->spinlock); + if (res->state & DLM_LOCK_RES_RECOVERING) { + /* if all is working ok, this can only mean that we got + * a migrate request from a node that we now see as + * dead. what can we do here? drop it to the floor? */ + spin_unlock(&res->spinlock); + mlog(ML_ERROR, "Got a migrate request, but the " + "lockres is marked as recovering!"); + kmem_cache_free(dlm_mle_cache, mle); + ret = -EINVAL; /* need a better solution */ + goto unlock; + } + res->state |= DLM_LOCK_RES_MIGRATING; + spin_unlock(&res->spinlock); + } + + /* ignore status. only nonzero status would BUG. */ + ret = dlm_add_migration_mle(dlm, res, mle, &oldmle, + name, namelen, + migrate->new_master, + migrate->master); + +unlock: + spin_unlock(&dlm->master_lock); + spin_unlock(&dlm->spinlock); + + if (oldmle) { + /* master is known, detach if not already detached */ + dlm_mle_detach_hb_events(dlm, oldmle); + dlm_put_mle(oldmle); + } + + if (res) + dlm_lockres_put(res); +leave: + dlm_put(dlm); + return ret; +} + +/* must be holding dlm->spinlock and dlm->master_lock + * when adding a migration mle, we can clear any other mles + * in the master list because we know with certainty that + * the master is "master". so we remove any old mle from + * the list after setting it's master field, and then add + * the new migration mle. this way we can hold with the rule + * of having only one mle for a given lock name at all times. */ +static int dlm_add_migration_mle(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_master_list_entry *mle, + struct dlm_master_list_entry **oldmle, + const char *name, unsigned int namelen, + u8 new_master, u8 master) +{ + int found; + int ret = 0; + + *oldmle = NULL; + + mlog_entry_void(); + + assert_spin_locked(&dlm->spinlock); + assert_spin_locked(&dlm->master_lock); + + /* caller is responsible for any ref taken here on oldmle */ + found = dlm_find_mle(dlm, oldmle, (char *)name, namelen); + if (found) { + struct dlm_master_list_entry *tmp = *oldmle; + spin_lock(&tmp->spinlock); + if (tmp->type == DLM_MLE_MIGRATION) { + if (master == dlm->node_num) { + /* ah another process raced me to it */ + mlog(0, "tried to migrate %.*s, but some " + "process beat me to it\n", + namelen, name); + ret = -EEXIST; + } else { + /* bad. 2 NODES are trying to migrate! */ + mlog(ML_ERROR, "migration error mle: " + "master=%u new_master=%u // request: " + "master=%u new_master=%u // " + "lockres=%.*s\n", + tmp->master, tmp->new_master, + master, new_master, + namelen, name); + BUG(); + } + } else { + /* this is essentially what assert_master does */ + tmp->master = master; + atomic_set(&tmp->woken, 1); + wake_up(&tmp->wq); + /* remove it from the list so that only one + * mle will be found */ + list_del_init(&tmp->list); + } + spin_unlock(&tmp->spinlock); + } + + /* now add a migration mle to the tail of the list */ + dlm_init_mle(mle, DLM_MLE_MIGRATION, dlm, res, name, namelen); + mle->new_master = new_master; + mle->master = master; + /* do this for consistency with other mle types */ + set_bit(new_master, mle->maybe_map); + list_add(&mle->list, &dlm->master_list); + + return ret; +} + + +void dlm_clean_master_list(struct dlm_ctxt *dlm, u8 dead_node) +{ + struct list_head *iter, *iter2; + struct dlm_master_list_entry *mle; + struct dlm_lock_resource *res; + + mlog_entry("dlm=%s, dead node=%u\n", dlm->name, dead_node); +top: + assert_spin_locked(&dlm->spinlock); + + /* clean the master list */ + spin_lock(&dlm->master_lock); + list_for_each_safe(iter, iter2, &dlm->master_list) { + mle = list_entry(iter, struct dlm_master_list_entry, list); + + BUG_ON(mle->type != DLM_MLE_BLOCK && + mle->type != DLM_MLE_MASTER && + mle->type != DLM_MLE_MIGRATION); + + /* MASTER mles are initiated locally. the waiting + * process will notice the node map change + * shortly. let that happen as normal. */ + if (mle->type == DLM_MLE_MASTER) + continue; + + + /* BLOCK mles are initiated by other nodes. + * need to clean up if the dead node would have + * been the master. */ + if (mle->type == DLM_MLE_BLOCK) { + int bit; + + spin_lock(&mle->spinlock); + bit = find_next_bit(mle->maybe_map, O2NM_MAX_NODES, 0); + if (bit != dead_node) { + mlog(0, "mle found, but dead node %u would " + "not have been master\n", dead_node); + spin_unlock(&mle->spinlock); + } else { + /* must drop the refcount by one since the + * assert_master will never arrive. this + * may result in the mle being unlinked and + * freed, but there may still be a process + * waiting in the dlmlock path which is fine. */ + mlog(ML_ERROR, "node %u was expected master\n", + dead_node); + atomic_set(&mle->woken, 1); + spin_unlock(&mle->spinlock); + wake_up(&mle->wq); + /* final put will take care of list removal */ + __dlm_put_mle(mle); + } + continue; + } + + /* everything else is a MIGRATION mle */ + + /* the rule for MIGRATION mles is that the master + * becomes UNKNOWN if *either* the original or + * the new master dies. all UNKNOWN lockreses + * are sent to whichever node becomes the recovery + * master. the new master is responsible for + * determining if there is still a master for + * this lockres, or if he needs to take over + * mastery. either way, this node should expect + * another message to resolve this. */ + if (mle->master != dead_node && + mle->new_master != dead_node) + continue; + + /* if we have reached this point, this mle needs to + * be removed from the list and freed. */ + + /* remove from the list early. NOTE: unlinking + * list_head while in list_for_each_safe */ + spin_lock(&mle->spinlock); + list_del_init(&mle->list); + atomic_set(&mle->woken, 1); + spin_unlock(&mle->spinlock); + wake_up(&mle->wq); + + mlog(0, "node %u died during migration from " + "%u to %u!\n", dead_node, + mle->master, mle->new_master); + /* if there is a lockres associated with this + * mle, find it and set its owner to UNKNOWN */ + res = __dlm_lookup_lockres(dlm, mle->u.name.name, + mle->u.name.len); + if (res) { + /* unfortunately if we hit this rare case, our + * lock ordering is messed. we need to drop + * the master lock so that we can take the + * lockres lock, meaning that we will have to + * restart from the head of list. */ + spin_unlock(&dlm->master_lock); + + /* move lockres onto recovery list */ + spin_lock(&res->spinlock); + dlm_set_lockres_owner(dlm, res, + DLM_LOCK_RES_OWNER_UNKNOWN); + dlm_move_lockres_to_recovery_list(dlm, res); + spin_unlock(&res->spinlock); + dlm_lockres_put(res); + + /* dump the mle */ + spin_lock(&dlm->master_lock); + __dlm_put_mle(mle); + spin_unlock(&dlm->master_lock); + + /* restart */ + goto top; + } + + /* this may be the last reference */ + __dlm_put_mle(mle); + } + spin_unlock(&dlm->master_lock); +} + + +int dlm_finish_migration(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + u8 old_master) +{ + struct dlm_node_iter iter; + int ret = 0; + + spin_lock(&dlm->spinlock); + dlm_node_iter_init(dlm->domain_map, &iter); + clear_bit(old_master, iter.node_map); + clear_bit(dlm->node_num, iter.node_map); + spin_unlock(&dlm->spinlock); + + mlog(0, "now time to do a migrate request to other nodes\n"); + ret = dlm_do_migrate_request(dlm, res, old_master, + dlm->node_num, &iter); + if (ret < 0) { + mlog_errno(ret); + goto leave; + } + + mlog(0, "doing assert master of %.*s to all except the original node\n", + res->lockname.len, res->lockname.name); + /* this call now finishes out the nodemap + * even if one or more nodes die */ + ret = dlm_do_assert_master(dlm, res->lockname.name, + res->lockname.len, iter.node_map, + DLM_ASSERT_MASTER_FINISH_MIGRATION); + if (ret < 0) { + /* no longer need to retry. all living nodes contacted. */ + mlog_errno(ret); + ret = 0; + } + + memset(iter.node_map, 0, sizeof(iter.node_map)); + set_bit(old_master, iter.node_map); + mlog(0, "doing assert master of %.*s back to %u\n", + res->lockname.len, res->lockname.name, old_master); + ret = dlm_do_assert_master(dlm, res->lockname.name, + res->lockname.len, iter.node_map, + DLM_ASSERT_MASTER_FINISH_MIGRATION); + if (ret < 0) { + mlog(0, "assert master to original master failed " + "with %d.\n", ret); + /* the only nonzero status here would be because of + * a dead original node. we're done. */ + ret = 0; + } + + /* all done, set the owner, clear the flag */ + spin_lock(&res->spinlock); + dlm_set_lockres_owner(dlm, res, dlm->node_num); + res->state &= ~DLM_LOCK_RES_MIGRATING; + spin_unlock(&res->spinlock); + /* re-dirty it on the new master */ + dlm_kick_thread(dlm, res); + wake_up(&res->wq); +leave: + return ret; +} + +/* + * LOCKRES AST REFCOUNT + * this is integral to migration + */ + +/* for future intent to call an ast, reserve one ahead of time. + * this should be called only after waiting on the lockres + * with dlm_wait_on_lockres, and while still holding the + * spinlock after the call. */ +void __dlm_lockres_reserve_ast(struct dlm_lock_resource *res) +{ + assert_spin_locked(&res->spinlock); + if (res->state & DLM_LOCK_RES_MIGRATING) { + __dlm_print_one_lock_resource(res); + } + BUG_ON(res->state & DLM_LOCK_RES_MIGRATING); + + atomic_inc(&res->asts_reserved); +} + +/* + * used to drop the reserved ast, either because it went unused, + * or because the ast/bast was actually called. + * + * also, if there is a pending migration on this lockres, + * and this was the last pending ast on the lockres, + * atomically set the MIGRATING flag before we drop the lock. + * this is how we ensure that migration can proceed with no + * asts in progress. note that it is ok if the state of the + * queues is such that a lock should be granted in the future + * or that a bast should be fired, because the new master will + * shuffle the lists on this lockres as soon as it is migrated. + */ +void dlm_lockres_release_ast(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + if (!atomic_dec_and_lock(&res->asts_reserved, &res->spinlock)) + return; + + if (!res->migration_pending) { + spin_unlock(&res->spinlock); + return; + } + + BUG_ON(res->state & DLM_LOCK_RES_MIGRATING); + res->migration_pending = 0; + res->state |= DLM_LOCK_RES_MIGRATING; + spin_unlock(&res->spinlock); + wake_up(&res->wq); + wake_up(&dlm->migration_wq); +} diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c new file mode 100644 index 0000000..0c8eb10 --- /dev/null +++ b/fs/ocfs2/dlm/dlmrecovery.c @@ -0,0 +1,2132 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmrecovery.c + * + * recovery stuff + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" +#include "dlmcommon.h" +#include "dlmdomain.h" + +#define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_RECOVERY) +#include "cluster/masklog.h" + +static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node); + +static int dlm_recovery_thread(void *data); +void dlm_complete_recovery_thread(struct dlm_ctxt *dlm); +int dlm_launch_recovery_thread(struct dlm_ctxt *dlm); +static void dlm_kick_recovery_thread(struct dlm_ctxt *dlm); +static int dlm_do_recovery(struct dlm_ctxt *dlm); + +static int dlm_pick_recovery_master(struct dlm_ctxt *dlm); +static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node); +static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node); +static int dlm_request_all_locks(struct dlm_ctxt *dlm, + u8 request_from, u8 dead_node); +static void dlm_destroy_recovery_area(struct dlm_ctxt *dlm, u8 dead_node); + +static inline int dlm_num_locks_in_lockres(struct dlm_lock_resource *res); +static void dlm_init_migratable_lockres(struct dlm_migratable_lockres *mres, + const char *lockname, int namelen, + int total_locks, u64 cookie, + u8 flags, u8 master); +static int dlm_send_mig_lockres_msg(struct dlm_ctxt *dlm, + struct dlm_migratable_lockres *mres, + u8 send_to, + struct dlm_lock_resource *res, + int total_locks); +static int dlm_lockres_master_requery(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 *real_master); +static int dlm_process_recovery_data(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_migratable_lockres *mres); +static int dlm_do_master_requery(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 nodenum, u8 *real_master); +static int dlm_send_finalize_reco_message(struct dlm_ctxt *dlm); +static int dlm_send_all_done_msg(struct dlm_ctxt *dlm, + u8 dead_node, u8 send_to); +static int dlm_send_begin_reco_message(struct dlm_ctxt *dlm, u8 dead_node); +static void dlm_move_reco_locks_to_list(struct dlm_ctxt *dlm, + struct list_head *list, u8 dead_node); +static void dlm_finish_local_lockres_recovery(struct dlm_ctxt *dlm, + u8 dead_node, u8 new_master); +static void dlm_reco_ast(void *astdata); +static void dlm_reco_bast(void *astdata, int blocked_type); +static void dlm_reco_unlock_ast(void *astdata, enum dlm_status st); +static void dlm_request_all_locks_worker(struct dlm_work_item *item, + void *data); +static void dlm_mig_lockres_worker(struct dlm_work_item *item, void *data); + +static u64 dlm_get_next_mig_cookie(void); + +static spinlock_t dlm_reco_state_lock = SPIN_LOCK_UNLOCKED; +static spinlock_t dlm_mig_cookie_lock = SPIN_LOCK_UNLOCKED; +static u64 dlm_mig_cookie = 1; + +static u64 dlm_get_next_mig_cookie(void) +{ + u64 c; + spin_lock(&dlm_mig_cookie_lock); + c = dlm_mig_cookie; + if (dlm_mig_cookie == (~0ULL)) + dlm_mig_cookie = 1; + else + dlm_mig_cookie++; + spin_unlock(&dlm_mig_cookie_lock); + return c; +} + +static inline void dlm_reset_recovery(struct dlm_ctxt *dlm) +{ + spin_lock(&dlm->spinlock); + clear_bit(dlm->reco.dead_node, dlm->recovery_map); + dlm->reco.dead_node = O2NM_INVALID_NODE_NUM; + dlm->reco.new_master = O2NM_INVALID_NODE_NUM; + spin_unlock(&dlm->spinlock); +} + +/* Worker function used during recovery. */ +void dlm_dispatch_work(void *data) +{ + struct dlm_ctxt *dlm = (struct dlm_ctxt *)data; + LIST_HEAD(tmp_list); + struct list_head *iter, *iter2; + struct dlm_work_item *item; + dlm_workfunc_t *workfunc; + + spin_lock(&dlm->work_lock); + list_splice_init(&dlm->work_list, &tmp_list); + spin_unlock(&dlm->work_lock); + + list_for_each_safe(iter, iter2, &tmp_list) { + item = list_entry(iter, struct dlm_work_item, list); + workfunc = item->func; + list_del_init(&item->list); + + /* already have ref on dlm to avoid having + * it disappear. just double-check. */ + BUG_ON(item->dlm != dlm); + + /* this is allowed to sleep and + * call network stuff */ + workfunc(item, item->data); + + dlm_put(dlm); + kfree(item); + } +} + +/* + * RECOVERY THREAD + */ + +static void dlm_kick_recovery_thread(struct dlm_ctxt *dlm) +{ + /* wake the recovery thread + * this will wake the reco thread in one of three places + * 1) sleeping with no recovery happening + * 2) sleeping with recovery mastered elsewhere + * 3) recovery mastered here, waiting on reco data */ + + wake_up(&dlm->dlm_reco_thread_wq); +} + +/* Launch the recovery thread */ +int dlm_launch_recovery_thread(struct dlm_ctxt *dlm) +{ + mlog(0, "starting dlm recovery thread...\n"); + + dlm->dlm_reco_thread_task = kthread_run(dlm_recovery_thread, dlm, + "dlm_reco_thread"); + if (IS_ERR(dlm->dlm_reco_thread_task)) { + mlog_errno(PTR_ERR(dlm->dlm_reco_thread_task)); + dlm->dlm_reco_thread_task = NULL; + return -EINVAL; + } + + return 0; +} + +void dlm_complete_recovery_thread(struct dlm_ctxt *dlm) +{ + if (dlm->dlm_reco_thread_task) { + mlog(0, "waiting for dlm recovery thread to exit\n"); + kthread_stop(dlm->dlm_reco_thread_task); + dlm->dlm_reco_thread_task = NULL; + } +} + + + +/* + * this is lame, but here's how recovery works... + * 1) all recovery threads cluster wide will work on recovering + * ONE node at a time + * 2) negotiate who will take over all the locks for the dead node. + * thats right... ALL the locks. + * 3) once a new master is chosen, everyone scans all locks + * and moves aside those mastered by the dead guy + * 4) each of these locks should be locked until recovery is done + * 5) the new master collects up all of secondary lock queue info + * one lock at a time, forcing each node to communicate back + * before continuing + * 6) each secondary lock queue responds with the full known lock info + * 7) once the new master has run all its locks, it sends a ALLDONE! + * message to everyone + * 8) upon receiving this message, the secondary queue node unlocks + * and responds to the ALLDONE + * 9) once the new master gets responses from everyone, he unlocks + * everything and recovery for this dead node is done + *10) go back to 2) while there are still dead nodes + * + */ + + +#define DLM_RECO_THREAD_TIMEOUT_MS (5 * 1000) + +static int dlm_recovery_thread(void *data) +{ + int status; + struct dlm_ctxt *dlm = data; + unsigned long timeout = msecs_to_jiffies(DLM_RECO_THREAD_TIMEOUT_MS); + + mlog(0, "dlm thread running for %s...\n", dlm->name); + + while (!kthread_should_stop()) { + if (dlm_joined(dlm)) { + status = dlm_do_recovery(dlm); + if (status == -EAGAIN) { + /* do not sleep, recheck immediately. */ + continue; + } + if (status < 0) + mlog_errno(status); + } + + wait_event_interruptible_timeout(dlm->dlm_reco_thread_wq, + kthread_should_stop(), + timeout); + } + + mlog(0, "quitting DLM recovery thread\n"); + return 0; +} + +/* callers of the top-level api calls (dlmlock/dlmunlock) should + * block on the dlm->reco.event when recovery is in progress. + * the dlm recovery thread will set this state when it begins + * recovering a dead node (as the new master or not) and clear + * the state and wake as soon as all affected lock resources have + * been marked with the RECOVERY flag */ +static int dlm_in_recovery(struct dlm_ctxt *dlm) +{ + int in_recovery; + spin_lock(&dlm->spinlock); + in_recovery = !!(dlm->reco.state & DLM_RECO_STATE_ACTIVE); + spin_unlock(&dlm->spinlock); + return in_recovery; +} + + +void dlm_wait_for_recovery(struct dlm_ctxt *dlm) +{ + wait_event(dlm->reco.event, !dlm_in_recovery(dlm)); +} + +static void dlm_begin_recovery(struct dlm_ctxt *dlm) +{ + spin_lock(&dlm->spinlock); + BUG_ON(dlm->reco.state & DLM_RECO_STATE_ACTIVE); + dlm->reco.state |= DLM_RECO_STATE_ACTIVE; + spin_unlock(&dlm->spinlock); +} + +static void dlm_end_recovery(struct dlm_ctxt *dlm) +{ + spin_lock(&dlm->spinlock); + BUG_ON(!(dlm->reco.state & DLM_RECO_STATE_ACTIVE)); + dlm->reco.state &= ~DLM_RECO_STATE_ACTIVE; + spin_unlock(&dlm->spinlock); + wake_up(&dlm->reco.event); +} + +static int dlm_do_recovery(struct dlm_ctxt *dlm) +{ + int status = 0; + + spin_lock(&dlm->spinlock); + + /* check to see if the new master has died */ + if (dlm->reco.new_master != O2NM_INVALID_NODE_NUM && + test_bit(dlm->reco.new_master, dlm->recovery_map)) { + mlog(0, "new master %u died while recovering %u!\n", + dlm->reco.new_master, dlm->reco.dead_node); + /* unset the new_master, leave dead_node */ + dlm->reco.new_master = O2NM_INVALID_NODE_NUM; + } + + /* select a target to recover */ + if (dlm->reco.dead_node == O2NM_INVALID_NODE_NUM) { + int bit; + + bit = find_next_bit (dlm->recovery_map, O2NM_MAX_NODES+1, 0); + if (bit >= O2NM_MAX_NODES || bit < 0) + dlm->reco.dead_node = O2NM_INVALID_NODE_NUM; + else + dlm->reco.dead_node = bit; + } else if (!test_bit(dlm->reco.dead_node, dlm->recovery_map)) { + /* BUG? */ + mlog(ML_ERROR, "dead_node %u no longer in recovery map!\n", + dlm->reco.dead_node); + dlm->reco.dead_node = O2NM_INVALID_NODE_NUM; + } + + if (dlm->reco.dead_node == O2NM_INVALID_NODE_NUM) { + // mlog(0, "nothing to recover! sleeping now!\n"); + spin_unlock(&dlm->spinlock); + /* return to main thread loop and sleep. */ + return 0; + } + mlog(0, "recovery thread found node %u in the recovery map!\n", + dlm->reco.dead_node); + spin_unlock(&dlm->spinlock); + + /* take write barrier */ + /* (stops the list reshuffling thread, proxy ast handling) */ + dlm_begin_recovery(dlm); + + if (dlm->reco.new_master == dlm->node_num) + goto master_here; + + if (dlm->reco.new_master == O2NM_INVALID_NODE_NUM) { + /* choose a new master */ + if (!dlm_pick_recovery_master(dlm)) { + /* already notified everyone. go. */ + dlm->reco.new_master = dlm->node_num; + goto master_here; + } + mlog(0, "another node will master this recovery session.\n"); + } + mlog(0, "dlm=%s, new_master=%u, this node=%u, dead_node=%u\n", + dlm->name, dlm->reco.new_master, + dlm->node_num, dlm->reco.dead_node); + + /* it is safe to start everything back up here + * because all of the dead node's lock resources + * have been marked as in-recovery */ + dlm_end_recovery(dlm); + + /* sleep out in main dlm_recovery_thread loop. */ + return 0; + +master_here: + mlog(0, "mastering recovery of %s:%u here(this=%u)!\n", + dlm->name, dlm->reco.dead_node, dlm->node_num); + + status = dlm_remaster_locks(dlm, dlm->reco.dead_node); + if (status < 0) { + mlog(ML_ERROR, "error %d remastering locks for node %u, " + "retrying.\n", status, dlm->reco.dead_node); + } else { + /* success! see if any other nodes need recovery */ + dlm_reset_recovery(dlm); + } + dlm_end_recovery(dlm); + + /* continue and look for another dead node */ + return -EAGAIN; +} + +static int dlm_remaster_locks(struct dlm_ctxt *dlm, u8 dead_node) +{ + int status = 0; + struct dlm_reco_node_data *ndata; + struct list_head *iter; + int all_nodes_done; + int destroy = 0; + int pass = 0; + + status = dlm_init_recovery_area(dlm, dead_node); + if (status < 0) + goto leave; + + /* safe to access the node data list without a lock, since this + * process is the only one to change the list */ + list_for_each(iter, &dlm->reco.node_data) { + ndata = list_entry (iter, struct dlm_reco_node_data, list); + BUG_ON(ndata->state != DLM_RECO_NODE_DATA_INIT); + ndata->state = DLM_RECO_NODE_DATA_REQUESTING; + + mlog(0, "requesting lock info from node %u\n", + ndata->node_num); + + if (ndata->node_num == dlm->node_num) { + ndata->state = DLM_RECO_NODE_DATA_DONE; + continue; + } + + status = dlm_request_all_locks(dlm, ndata->node_num, dead_node); + if (status < 0) { + mlog_errno(status); + if (dlm_is_host_down(status)) + ndata->state = DLM_RECO_NODE_DATA_DEAD; + else { + destroy = 1; + goto leave; + } + } + + switch (ndata->state) { + case DLM_RECO_NODE_DATA_INIT: + case DLM_RECO_NODE_DATA_FINALIZE_SENT: + case DLM_RECO_NODE_DATA_REQUESTED: + BUG(); + break; + case DLM_RECO_NODE_DATA_DEAD: + mlog(0, "node %u died after requesting " + "recovery info for node %u\n", + ndata->node_num, dead_node); + // start all over + destroy = 1; + status = -EAGAIN; + goto leave; + case DLM_RECO_NODE_DATA_REQUESTING: + ndata->state = DLM_RECO_NODE_DATA_REQUESTED; + mlog(0, "now receiving recovery data from " + "node %u for dead node %u\n", + ndata->node_num, dead_node); + break; + case DLM_RECO_NODE_DATA_RECEIVING: + mlog(0, "already receiving recovery data from " + "node %u for dead node %u\n", + ndata->node_num, dead_node); + break; + case DLM_RECO_NODE_DATA_DONE: + mlog(0, "already DONE receiving recovery data " + "from node %u for dead node %u\n", + ndata->node_num, dead_node); + break; + } + } + + mlog(0, "done requesting all lock info\n"); + + /* nodes should be sending reco data now + * just need to wait */ + + while (1) { + /* check all the nodes now to see if we are + * done, or if anyone died */ + all_nodes_done = 1; + spin_lock(&dlm_reco_state_lock); + list_for_each(iter, &dlm->reco.node_data) { + ndata = list_entry (iter, struct dlm_reco_node_data, list); + + mlog(0, "checking recovery state of node %u\n", + ndata->node_num); + switch (ndata->state) { + case DLM_RECO_NODE_DATA_INIT: + case DLM_RECO_NODE_DATA_REQUESTING: + mlog(ML_ERROR, "bad ndata state for " + "node %u: state=%d\n", + ndata->node_num, ndata->state); + BUG(); + break; + case DLM_RECO_NODE_DATA_DEAD: + mlog(0, "node %u died after " + "requesting recovery info for " + "node %u\n", ndata->node_num, + dead_node); + spin_unlock(&dlm_reco_state_lock); + // start all over + destroy = 1; + status = -EAGAIN; + goto leave; + case DLM_RECO_NODE_DATA_RECEIVING: + case DLM_RECO_NODE_DATA_REQUESTED: + all_nodes_done = 0; + break; + case DLM_RECO_NODE_DATA_DONE: + break; + case DLM_RECO_NODE_DATA_FINALIZE_SENT: + break; + } + } + spin_unlock(&dlm_reco_state_lock); + + mlog(0, "pass #%d, all_nodes_done?: %s\n", ++pass, + all_nodes_done?"yes":"no"); + if (all_nodes_done) { + int ret; + + /* all nodes are now in DLM_RECO_NODE_DATA_DONE state + * just send a finalize message to everyone and + * clean up */ + mlog(0, "all nodes are done! send finalize\n"); + ret = dlm_send_finalize_reco_message(dlm); + if (ret < 0) + mlog_errno(ret); + + spin_lock(&dlm->spinlock); + dlm_finish_local_lockres_recovery(dlm, dead_node, + dlm->node_num); + spin_unlock(&dlm->spinlock); + mlog(0, "should be done with recovery!\n"); + + mlog(0, "finishing recovery of %s at %lu, " + "dead=%u, this=%u, new=%u\n", dlm->name, + jiffies, dlm->reco.dead_node, + dlm->node_num, dlm->reco.new_master); + destroy = 1; + status = ret; + /* rescan everything marked dirty along the way */ + dlm_kick_thread(dlm, NULL); + break; + } + /* wait to be signalled, with periodic timeout + * to check for node death */ + wait_event_interruptible_timeout(dlm->dlm_reco_thread_wq, + kthread_should_stop(), + msecs_to_jiffies(DLM_RECO_THREAD_TIMEOUT_MS)); + + } + +leave: + if (destroy) + dlm_destroy_recovery_area(dlm, dead_node); + + mlog_exit(status); + return status; +} + +static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node) +{ + int num=0; + struct dlm_reco_node_data *ndata; + + spin_lock(&dlm->spinlock); + memcpy(dlm->reco.node_map, dlm->domain_map, sizeof(dlm->domain_map)); + /* nodes can only be removed (by dying) after dropping + * this lock, and death will be trapped later, so this should do */ + spin_unlock(&dlm->spinlock); + + while (1) { + num = find_next_bit (dlm->reco.node_map, O2NM_MAX_NODES, num); + if (num >= O2NM_MAX_NODES) { + break; + } + BUG_ON(num == dead_node); + + ndata = kcalloc(1, sizeof(*ndata), GFP_KERNEL); + if (!ndata) { + dlm_destroy_recovery_area(dlm, dead_node); + return -ENOMEM; + } + ndata->node_num = num; + ndata->state = DLM_RECO_NODE_DATA_INIT; + spin_lock(&dlm_reco_state_lock); + list_add_tail(&ndata->list, &dlm->reco.node_data); + spin_unlock(&dlm_reco_state_lock); + num++; + } + + return 0; +} + +static void dlm_destroy_recovery_area(struct dlm_ctxt *dlm, u8 dead_node) +{ + struct list_head *iter, *iter2; + struct dlm_reco_node_data *ndata; + LIST_HEAD(tmplist); + + spin_lock(&dlm_reco_state_lock); + list_splice_init(&dlm->reco.node_data, &tmplist); + spin_unlock(&dlm_reco_state_lock); + + list_for_each_safe(iter, iter2, &tmplist) { + ndata = list_entry (iter, struct dlm_reco_node_data, list); + list_del_init(&ndata->list); + kfree(ndata); + } +} + +static int dlm_request_all_locks(struct dlm_ctxt *dlm, u8 request_from, + u8 dead_node) +{ + struct dlm_lock_request lr; + enum dlm_status ret; + + mlog(0, "\n"); + + + mlog(0, "dlm_request_all_locks: dead node is %u, sending request " + "to %u\n", dead_node, request_from); + + memset(&lr, 0, sizeof(lr)); + lr.node_idx = dlm->node_num; + lr.dead_node = dead_node; + + // send message + ret = DLM_NOLOCKMGR; + ret = o2net_send_message(DLM_LOCK_REQUEST_MSG, dlm->key, + &lr, sizeof(lr), request_from, NULL); + + /* negative status is handled by caller */ + if (ret < 0) + mlog_errno(ret); + + // return from here, then + // sleep until all received or error + return ret; + +} + +int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_lock_request *lr = (struct dlm_lock_request *)msg->buf; + char *buf = NULL; + struct dlm_work_item *item = NULL; + + if (!dlm_grab(dlm)) + return -EINVAL; + + BUG_ON(lr->dead_node != dlm->reco.dead_node); + + item = kcalloc(1, sizeof(*item), GFP_KERNEL); + if (!item) { + dlm_put(dlm); + return -ENOMEM; + } + + /* this will get freed by dlm_request_all_locks_worker */ + buf = (char *) __get_free_page(GFP_KERNEL); + if (!buf) { + kfree(item); + dlm_put(dlm); + return -ENOMEM; + } + + /* queue up work for dlm_request_all_locks_worker */ + dlm_grab(dlm); /* get an extra ref for the work item */ + dlm_init_work_item(dlm, item, dlm_request_all_locks_worker, buf); + item->u.ral.reco_master = lr->node_idx; + item->u.ral.dead_node = lr->dead_node; + spin_lock(&dlm->work_lock); + list_add_tail(&item->list, &dlm->work_list); + spin_unlock(&dlm->work_lock); + schedule_work(&dlm->dispatched_work); + + dlm_put(dlm); + return 0; +} + +static void dlm_request_all_locks_worker(struct dlm_work_item *item, void *data) +{ + struct dlm_migratable_lockres *mres; + struct dlm_lock_resource *res; + struct dlm_ctxt *dlm; + LIST_HEAD(resources); + struct list_head *iter; + int ret; + u8 dead_node, reco_master; + + dlm = item->dlm; + dead_node = item->u.ral.dead_node; + reco_master = item->u.ral.reco_master; + BUG_ON(dead_node != dlm->reco.dead_node); + BUG_ON(reco_master != dlm->reco.new_master); + + mres = (struct dlm_migratable_lockres *)data; + + /* lock resources should have already been moved to the + * dlm->reco.resources list. now move items from that list + * to a temp list if the dead owner matches. note that the + * whole cluster recovers only one node at a time, so we + * can safely move UNKNOWN lock resources for each recovery + * session. */ + dlm_move_reco_locks_to_list(dlm, &resources, dead_node); + + /* now we can begin blasting lockreses without the dlm lock */ + list_for_each(iter, &resources) { + res = list_entry (iter, struct dlm_lock_resource, recovering); + ret = dlm_send_one_lockres(dlm, res, mres, reco_master, + DLM_MRES_RECOVERY); + if (ret < 0) + mlog_errno(ret); + } + + /* move the resources back to the list */ + spin_lock(&dlm->spinlock); + list_splice_init(&resources, &dlm->reco.resources); + spin_unlock(&dlm->spinlock); + + ret = dlm_send_all_done_msg(dlm, dead_node, reco_master); + if (ret < 0) + mlog_errno(ret); + + free_page((unsigned long)data); +} + + +static int dlm_send_all_done_msg(struct dlm_ctxt *dlm, u8 dead_node, u8 send_to) +{ + int ret, tmpret; + struct dlm_reco_data_done done_msg; + + memset(&done_msg, 0, sizeof(done_msg)); + done_msg.node_idx = dlm->node_num; + done_msg.dead_node = dead_node; + mlog(0, "sending DATA DONE message to %u, " + "my node=%u, dead node=%u\n", send_to, done_msg.node_idx, + done_msg.dead_node); + + ret = o2net_send_message(DLM_RECO_DATA_DONE_MSG, dlm->key, &done_msg, + sizeof(done_msg), send_to, &tmpret); + /* negative status is ignored by the caller */ + if (ret >= 0) + ret = tmpret; + return ret; +} + + +int dlm_reco_data_done_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_reco_data_done *done = (struct dlm_reco_data_done *)msg->buf; + struct list_head *iter; + struct dlm_reco_node_data *ndata = NULL; + int ret = -EINVAL; + + if (!dlm_grab(dlm)) + return -EINVAL; + + mlog(0, "got DATA DONE: dead_node=%u, reco.dead_node=%u, " + "node_idx=%u, this node=%u\n", done->dead_node, + dlm->reco.dead_node, done->node_idx, dlm->node_num); + BUG_ON(done->dead_node != dlm->reco.dead_node); + + spin_lock(&dlm_reco_state_lock); + list_for_each(iter, &dlm->reco.node_data) { + ndata = list_entry (iter, struct dlm_reco_node_data, list); + if (ndata->node_num != done->node_idx) + continue; + + switch (ndata->state) { + case DLM_RECO_NODE_DATA_INIT: + case DLM_RECO_NODE_DATA_DEAD: + case DLM_RECO_NODE_DATA_DONE: + case DLM_RECO_NODE_DATA_FINALIZE_SENT: + mlog(ML_ERROR, "bad ndata state for node %u:" + " state=%d\n", ndata->node_num, + ndata->state); + BUG(); + break; + case DLM_RECO_NODE_DATA_RECEIVING: + case DLM_RECO_NODE_DATA_REQUESTED: + case DLM_RECO_NODE_DATA_REQUESTING: + mlog(0, "node %u is DONE sending " + "recovery data!\n", + ndata->node_num); + + ndata->state = DLM_RECO_NODE_DATA_DONE; + ret = 0; + break; + } + } + spin_unlock(&dlm_reco_state_lock); + + /* wake the recovery thread, some node is done */ + if (!ret) + dlm_kick_recovery_thread(dlm); + + if (ret < 0) + mlog(ML_ERROR, "failed to find recovery node data for node " + "%u\n", done->node_idx); + dlm_put(dlm); + + mlog(0, "leaving reco data done handler, ret=%d\n", ret); + return ret; +} + +static void dlm_move_reco_locks_to_list(struct dlm_ctxt *dlm, + struct list_head *list, + u8 dead_node) +{ + struct dlm_lock_resource *res; + struct list_head *iter, *iter2; + + spin_lock(&dlm->spinlock); + list_for_each_safe(iter, iter2, &dlm->reco.resources) { + res = list_entry (iter, struct dlm_lock_resource, recovering); + if (dlm_is_recovery_lock(res->lockname.name, + res->lockname.len)) + continue; + if (res->owner == dead_node) { + mlog(0, "found lockres owned by dead node while " + "doing recovery for node %u. sending it.\n", + dead_node); + list_del_init(&res->recovering); + list_add_tail(&res->recovering, list); + } else if (res->owner == DLM_LOCK_RES_OWNER_UNKNOWN) { + mlog(0, "found UNKNOWN owner while doing recovery " + "for node %u. sending it.\n", dead_node); + list_del_init(&res->recovering); + list_add_tail(&res->recovering, list); + } + } + spin_unlock(&dlm->spinlock); +} + +static inline int dlm_num_locks_in_lockres(struct dlm_lock_resource *res) +{ + int total_locks = 0; + struct list_head *iter, *queue = &res->granted; + int i; + + for (i=0; i<3; i++) { + list_for_each(iter, queue) + total_locks++; + queue++; + } + return total_locks; +} + + +static int dlm_send_mig_lockres_msg(struct dlm_ctxt *dlm, + struct dlm_migratable_lockres *mres, + u8 send_to, + struct dlm_lock_resource *res, + int total_locks) +{ + u64 mig_cookie = be64_to_cpu(mres->mig_cookie); + int mres_total_locks = be32_to_cpu(mres->total_locks); + int sz, ret = 0, status = 0; + u8 orig_flags = mres->flags, + orig_master = mres->master; + + BUG_ON(mres->num_locks > DLM_MAX_MIGRATABLE_LOCKS); + if (!mres->num_locks) + return 0; + + sz = sizeof(struct dlm_migratable_lockres) + + (mres->num_locks * sizeof(struct dlm_migratable_lock)); + + /* add an all-done flag if we reached the last lock */ + orig_flags = mres->flags; + BUG_ON(total_locks > mres_total_locks); + if (total_locks == mres_total_locks) + mres->flags |= DLM_MRES_ALL_DONE; + + /* send it */ + ret = o2net_send_message(DLM_MIG_LOCKRES_MSG, dlm->key, mres, + sz, send_to, &status); + if (ret < 0) { + /* XXX: negative status is not handled. + * this will end up killing this node. */ + mlog_errno(ret); + } else { + /* might get an -ENOMEM back here */ + ret = status; + if (ret < 0) { + mlog_errno(ret); + + if (ret == -EFAULT) { + mlog(ML_ERROR, "node %u told me to kill " + "myself!\n", send_to); + BUG(); + } + } + } + + /* zero and reinit the message buffer */ + dlm_init_migratable_lockres(mres, res->lockname.name, + res->lockname.len, mres_total_locks, + mig_cookie, orig_flags, orig_master); + return ret; +} + +static void dlm_init_migratable_lockres(struct dlm_migratable_lockres *mres, + const char *lockname, int namelen, + int total_locks, u64 cookie, + u8 flags, u8 master) +{ + /* mres here is one full page */ + memset(mres, 0, PAGE_SIZE); + mres->lockname_len = namelen; + memcpy(mres->lockname, lockname, namelen); + mres->num_locks = 0; + mres->total_locks = cpu_to_be32(total_locks); + mres->mig_cookie = cpu_to_be64(cookie); + mres->flags = flags; + mres->master = master; +} + + +/* returns 1 if this lock fills the network structure, + * 0 otherwise */ +static int dlm_add_lock_to_array(struct dlm_lock *lock, + struct dlm_migratable_lockres *mres, int queue) +{ + struct dlm_migratable_lock *ml; + int lock_num = mres->num_locks; + + ml = &(mres->ml[lock_num]); + ml->cookie = lock->ml.cookie; + ml->type = lock->ml.type; + ml->convert_type = lock->ml.convert_type; + ml->highest_blocked = lock->ml.highest_blocked; + ml->list = queue; + if (lock->lksb) { + ml->flags = lock->lksb->flags; + /* send our current lvb */ + if (ml->type == LKM_EXMODE || + ml->type == LKM_PRMODE) { + /* if it is already set, this had better be a PR + * and it has to match */ + if (mres->lvb[0] && (ml->type == LKM_EXMODE || + memcmp(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN))) { + mlog(ML_ERROR, "mismatched lvbs!\n"); + __dlm_print_one_lock_resource(lock->lockres); + BUG(); + } + memcpy(mres->lvb, lock->lksb->lvb, DLM_LVB_LEN); + } + } + ml->node = lock->ml.node; + mres->num_locks++; + /* we reached the max, send this network message */ + if (mres->num_locks == DLM_MAX_MIGRATABLE_LOCKS) + return 1; + return 0; +} + + +int dlm_send_one_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res, + struct dlm_migratable_lockres *mres, + u8 send_to, u8 flags) +{ + struct list_head *queue, *iter; + int total_locks, i; + u64 mig_cookie = 0; + struct dlm_lock *lock; + int ret = 0; + + BUG_ON(!(flags & (DLM_MRES_RECOVERY|DLM_MRES_MIGRATION))); + + mlog(0, "sending to %u\n", send_to); + + total_locks = dlm_num_locks_in_lockres(res); + if (total_locks > DLM_MAX_MIGRATABLE_LOCKS) { + /* rare, but possible */ + mlog(0, "argh. lockres has %d locks. this will " + "require more than one network packet to " + "migrate\n", total_locks); + mig_cookie = dlm_get_next_mig_cookie(); + } + + dlm_init_migratable_lockres(mres, res->lockname.name, + res->lockname.len, total_locks, + mig_cookie, flags, res->owner); + + total_locks = 0; + for (i=DLM_GRANTED_LIST; i<=DLM_BLOCKED_LIST; i++) { + queue = dlm_list_idx_to_ptr(res, i); + list_for_each(iter, queue) { + lock = list_entry (iter, struct dlm_lock, list); + + /* add another lock. */ + total_locks++; + if (!dlm_add_lock_to_array(lock, mres, i)) + continue; + + /* this filled the lock message, + * we must send it immediately. */ + ret = dlm_send_mig_lockres_msg(dlm, mres, send_to, + res, total_locks); + if (ret < 0) { + // TODO + mlog(ML_ERROR, "dlm_send_mig_lockres_msg " + "returned %d, TODO\n", ret); + BUG(); + } + } + } + /* flush any remaining locks */ + ret = dlm_send_mig_lockres_msg(dlm, mres, send_to, res, total_locks); + if (ret < 0) { + // TODO + mlog(ML_ERROR, "dlm_send_mig_lockres_msg returned %d, " + "TODO\n", ret); + BUG(); + } + return ret; +} + + + +/* + * this message will contain no more than one page worth of + * recovery data, and it will work on only one lockres. + * there may be many locks in this page, and we may need to wait + * for additional packets to complete all the locks (rare, but + * possible). + */ +/* + * NOTE: the allocation error cases here are scary + * we really cannot afford to fail an alloc in recovery + * do we spin? returning an error only delays the problem really + */ + +int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_migratable_lockres *mres = + (struct dlm_migratable_lockres *)msg->buf; + int ret = 0; + u8 real_master; + char *buf = NULL; + struct dlm_work_item *item = NULL; + struct dlm_lock_resource *res = NULL; + + if (!dlm_grab(dlm)) + return -EINVAL; + + BUG_ON(!(mres->flags & (DLM_MRES_RECOVERY|DLM_MRES_MIGRATION))); + + real_master = mres->master; + if (real_master == DLM_LOCK_RES_OWNER_UNKNOWN) { + /* cannot migrate a lockres with no master */ + BUG_ON(!(mres->flags & DLM_MRES_RECOVERY)); + } + + mlog(0, "%s message received from node %u\n", + (mres->flags & DLM_MRES_RECOVERY) ? + "recovery" : "migration", mres->master); + if (mres->flags & DLM_MRES_ALL_DONE) + mlog(0, "all done flag. all lockres data received!\n"); + + ret = -ENOMEM; + buf = kmalloc(be16_to_cpu(msg->data_len), GFP_KERNEL); + item = kcalloc(1, sizeof(*item), GFP_KERNEL); + if (!buf || !item) + goto leave; + + /* lookup the lock to see if we have a secondary queue for this + * already... just add the locks in and this will have its owner + * and RECOVERY flag changed when it completes. */ + res = dlm_lookup_lockres(dlm, mres->lockname, mres->lockname_len); + if (res) { + /* this will get a ref on res */ + /* mark it as recovering/migrating and hash it */ + spin_lock(&res->spinlock); + if (mres->flags & DLM_MRES_RECOVERY) { + res->state |= DLM_LOCK_RES_RECOVERING; + } else { + if (res->state & DLM_LOCK_RES_MIGRATING) { + /* this is at least the second + * lockres message */ + mlog(0, "lock %.*s is already migrating\n", + mres->lockname_len, + mres->lockname); + } else if (res->state & DLM_LOCK_RES_RECOVERING) { + /* caller should BUG */ + mlog(ML_ERROR, "node is attempting to migrate " + "lock %.*s, but marked as recovering!\n", + mres->lockname_len, mres->lockname); + ret = -EFAULT; + spin_unlock(&res->spinlock); + goto leave; + } + res->state |= DLM_LOCK_RES_MIGRATING; + } + spin_unlock(&res->spinlock); + } else { + /* need to allocate, just like if it was + * mastered here normally */ + res = dlm_new_lockres(dlm, mres->lockname, mres->lockname_len); + if (!res) + goto leave; + + /* to match the ref that we would have gotten if + * dlm_lookup_lockres had succeeded */ + dlm_lockres_get(res); + + /* mark it as recovering/migrating and hash it */ + if (mres->flags & DLM_MRES_RECOVERY) + res->state |= DLM_LOCK_RES_RECOVERING; + else + res->state |= DLM_LOCK_RES_MIGRATING; + + spin_lock(&dlm->spinlock); + __dlm_insert_lockres(dlm, res); + spin_unlock(&dlm->spinlock); + + /* now that the new lockres is inserted, + * make it usable by other processes */ + spin_lock(&res->spinlock); + res->state &= ~DLM_LOCK_RES_IN_PROGRESS; + spin_unlock(&res->spinlock); + + /* add an extra ref for just-allocated lockres + * otherwise the lockres will be purged immediately */ + dlm_lockres_get(res); + + } + + /* at this point we have allocated everything we need, + * and we have a hashed lockres with an extra ref and + * the proper res->state flags. */ + ret = 0; + if (mres->master == DLM_LOCK_RES_OWNER_UNKNOWN) { + /* migration cannot have an unknown master */ + BUG_ON(!(mres->flags & DLM_MRES_RECOVERY)); + mlog(0, "recovery has passed me a lockres with an " + "unknown owner.. will need to requery: " + "%.*s\n", mres->lockname_len, mres->lockname); + } else { + spin_lock(&res->spinlock); + dlm_change_lockres_owner(dlm, res, dlm->node_num); + spin_unlock(&res->spinlock); + } + + /* queue up work for dlm_mig_lockres_worker */ + dlm_grab(dlm); /* get an extra ref for the work item */ + memcpy(buf, msg->buf, be16_to_cpu(msg->data_len)); /* copy the whole message */ + dlm_init_work_item(dlm, item, dlm_mig_lockres_worker, buf); + item->u.ml.lockres = res; /* already have a ref */ + item->u.ml.real_master = real_master; + spin_lock(&dlm->work_lock); + list_add_tail(&item->list, &dlm->work_list); + spin_unlock(&dlm->work_lock); + schedule_work(&dlm->dispatched_work); + +leave: + dlm_put(dlm); + if (ret < 0) { + if (buf) + kfree(buf); + if (item) + kfree(item); + } + + mlog_exit(ret); + return ret; +} + + +static void dlm_mig_lockres_worker(struct dlm_work_item *item, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_migratable_lockres *mres; + int ret = 0; + struct dlm_lock_resource *res; + u8 real_master; + + dlm = item->dlm; + mres = (struct dlm_migratable_lockres *)data; + + res = item->u.ml.lockres; + real_master = item->u.ml.real_master; + + if (real_master == DLM_LOCK_RES_OWNER_UNKNOWN) { + /* this case is super-rare. only occurs if + * node death happens during migration. */ +again: + ret = dlm_lockres_master_requery(dlm, res, &real_master); + if (ret < 0) { + mlog(0, "dlm_lockres_master_requery failure: %d\n", + ret); + goto again; + } + if (real_master == DLM_LOCK_RES_OWNER_UNKNOWN) { + mlog(0, "lockres %.*s not claimed. " + "this node will take it.\n", + res->lockname.len, res->lockname.name); + } else { + mlog(0, "master needs to respond to sender " + "that node %u still owns %.*s\n", + real_master, res->lockname.len, + res->lockname.name); + /* cannot touch this lockres */ + goto leave; + } + } + + ret = dlm_process_recovery_data(dlm, res, mres); + if (ret < 0) + mlog(0, "dlm_process_recovery_data returned %d\n", ret); + else + mlog(0, "dlm_process_recovery_data succeeded\n"); + + if ((mres->flags & (DLM_MRES_MIGRATION|DLM_MRES_ALL_DONE)) == + (DLM_MRES_MIGRATION|DLM_MRES_ALL_DONE)) { + ret = dlm_finish_migration(dlm, res, mres->master); + if (ret < 0) + mlog_errno(ret); + } + +leave: + kfree(data); + mlog_exit(ret); +} + + + +static int dlm_lockres_master_requery(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 *real_master) +{ + struct dlm_node_iter iter; + int nodenum; + int ret = 0; + + *real_master = DLM_LOCK_RES_OWNER_UNKNOWN; + + /* we only reach here if one of the two nodes in a + * migration died while the migration was in progress. + * at this point we need to requery the master. we + * know that the new_master got as far as creating + * an mle on at least one node, but we do not know + * if any nodes had actually cleared the mle and set + * the master to the new_master. the old master + * is supposed to set the owner to UNKNOWN in the + * event of a new_master death, so the only possible + * responses that we can get from nodes here are + * that the master is new_master, or that the master + * is UNKNOWN. + * if all nodes come back with UNKNOWN then we know + * the lock needs remastering here. + * if any node comes back with a valid master, check + * to see if that master is the one that we are + * recovering. if so, then the new_master died and + * we need to remaster this lock. if not, then the + * new_master survived and that node will respond to + * other nodes about the owner. + * if there is an owner, this node needs to dump this + * lockres and alert the sender that this lockres + * was rejected. */ + spin_lock(&dlm->spinlock); + dlm_node_iter_init(dlm->domain_map, &iter); + spin_unlock(&dlm->spinlock); + + while ((nodenum = dlm_node_iter_next(&iter)) >= 0) { + /* do not send to self */ + if (nodenum == dlm->node_num) + continue; + ret = dlm_do_master_requery(dlm, res, nodenum, real_master); + if (ret < 0) { + mlog_errno(ret); + BUG(); + /* TODO: need to figure a way to restart this */ + } + if (*real_master != DLM_LOCK_RES_OWNER_UNKNOWN) { + mlog(0, "lock master is %u\n", *real_master); + break; + } + } + return ret; +} + + +static int dlm_do_master_requery(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + u8 nodenum, u8 *real_master) +{ + int ret = -EINVAL; + struct dlm_master_requery req; + int status = DLM_LOCK_RES_OWNER_UNKNOWN; + + memset(&req, 0, sizeof(req)); + req.node_idx = dlm->node_num; + req.namelen = res->lockname.len; + memcpy(req.name, res->lockname.name, res->lockname.len); + + ret = o2net_send_message(DLM_MASTER_REQUERY_MSG, dlm->key, + &req, sizeof(req), nodenum, &status); + /* XXX: negative status not handled properly here. */ + if (ret < 0) + mlog_errno(ret); + else { + BUG_ON(status < 0); + BUG_ON(status > DLM_LOCK_RES_OWNER_UNKNOWN); + *real_master = (u8) (status & 0xff); + mlog(0, "node %u responded to master requery with %u\n", + nodenum, *real_master); + ret = 0; + } + return ret; +} + + +/* this function cannot error, so unless the sending + * or receiving of the message failed, the owner can + * be trusted */ +int dlm_master_requery_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_master_requery *req = (struct dlm_master_requery *)msg->buf; + struct dlm_lock_resource *res = NULL; + int master = DLM_LOCK_RES_OWNER_UNKNOWN; + u32 flags = DLM_ASSERT_MASTER_REQUERY; + + if (!dlm_grab(dlm)) { + /* since the domain has gone away on this + * node, the proper response is UNKNOWN */ + return master; + } + + spin_lock(&dlm->spinlock); + res = __dlm_lookup_lockres(dlm, req->name, req->namelen); + if (res) { + spin_lock(&res->spinlock); + master = res->owner; + if (master == dlm->node_num) { + int ret = dlm_dispatch_assert_master(dlm, res, + 0, 0, flags); + if (ret < 0) { + mlog_errno(-ENOMEM); + /* retry!? */ + BUG(); + } + } + spin_unlock(&res->spinlock); + } + spin_unlock(&dlm->spinlock); + + dlm_put(dlm); + return master; +} + +static inline struct list_head * +dlm_list_num_to_pointer(struct dlm_lock_resource *res, int list_num) +{ + struct list_head *ret; + BUG_ON(list_num < 0); + BUG_ON(list_num > 2); + ret = &(res->granted); + ret += list_num; + return ret; +} +/* TODO: do ast flush business + * TODO: do MIGRATING and RECOVERING spinning + */ + +/* +* NOTE about in-flight requests during migration: +* +* Before attempting the migrate, the master has marked the lockres as +* MIGRATING and then flushed all of its pending ASTS. So any in-flight +* requests either got queued before the MIGRATING flag got set, in which +* case the lock data will reflect the change and a return message is on +* the way, or the request failed to get in before MIGRATING got set. In +* this case, the caller will be told to spin and wait for the MIGRATING +* flag to be dropped, then recheck the master. +* This holds true for the convert, cancel and unlock cases, and since lvb +* updates are tied to these same messages, it applies to lvb updates as +* well. For the lock case, there is no way a lock can be on the master +* queue and not be on the secondary queue since the lock is always added +* locally first. This means that the new target node will never be sent +* a lock that he doesn't already have on the list. +* In total, this means that the local lock is correct and should not be +* updated to match the one sent by the master. Any messages sent back +* from the master before the MIGRATING flag will bring the lock properly +* up-to-date, and the change will be ordered properly for the waiter. +* We will *not* attempt to modify the lock underneath the waiter. +*/ + +static int dlm_process_recovery_data(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_migratable_lockres *mres) +{ + struct dlm_migratable_lock *ml; + struct list_head *queue; + struct dlm_lock *newlock = NULL; + struct dlm_lockstatus *lksb = NULL; + int ret = 0; + int i; + struct list_head *iter; + struct dlm_lock *lock = NULL; + + mlog(0, "running %d locks for this lockres\n", mres->num_locks); + for (i=0; inum_locks; i++) { + ml = &(mres->ml[i]); + BUG_ON(ml->highest_blocked != LKM_IVMODE); + newlock = NULL; + lksb = NULL; + + queue = dlm_list_num_to_pointer(res, ml->list); + + /* if the lock is for the local node it needs to + * be moved to the proper location within the queue. + * do not allocate a new lock structure. */ + if (ml->node == dlm->node_num) { + /* MIGRATION ONLY! */ + BUG_ON(!(mres->flags & DLM_MRES_MIGRATION)); + + spin_lock(&res->spinlock); + list_for_each(iter, queue) { + lock = list_entry (iter, struct dlm_lock, list); + if (lock->ml.cookie != ml->cookie) + lock = NULL; + else + break; + } + + /* lock is always created locally first, and + * destroyed locally last. it must be on the list */ + if (!lock) { + mlog(ML_ERROR, "could not find local lock " + "with cookie %"MLFu64"!\n", + ml->cookie); + BUG(); + } + BUG_ON(lock->ml.node != ml->node); + + /* see NOTE above about why we do not update + * to match the master here */ + + /* move the lock to its proper place */ + /* do not alter lock refcount. switching lists. */ + list_del_init(&lock->list); + list_add_tail(&lock->list, queue); + spin_unlock(&res->spinlock); + + mlog(0, "just reordered a local lock!\n"); + continue; + } + + /* lock is for another node. */ + newlock = dlm_new_lock(ml->type, ml->node, + be64_to_cpu(ml->cookie), NULL); + if (!newlock) { + ret = -ENOMEM; + goto leave; + } + lksb = newlock->lksb; + dlm_lock_attach_lockres(newlock, res); + + if (ml->convert_type != LKM_IVMODE) { + BUG_ON(queue != &res->converting); + newlock->ml.convert_type = ml->convert_type; + } + lksb->flags |= (ml->flags & + (DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB)); + + if (mres->lvb[0]) { + if (lksb->flags & DLM_LKSB_PUT_LVB) { + /* other node was trying to update + * lvb when node died. recreate the + * lksb with the updated lvb. */ + memcpy(lksb->lvb, mres->lvb, DLM_LVB_LEN); + } else { + /* otherwise, the node is sending its + * most recent valid lvb info */ + BUG_ON(ml->type != LKM_EXMODE && + ml->type != LKM_PRMODE); + if (res->lvb[0] && (ml->type == LKM_EXMODE || + memcmp(res->lvb, mres->lvb, DLM_LVB_LEN))) { + mlog(ML_ERROR, "received bad lvb!\n"); + __dlm_print_one_lock_resource(res); + BUG(); + } + memcpy(res->lvb, mres->lvb, DLM_LVB_LEN); + } + } + + + /* NOTE: + * wrt lock queue ordering and recovery: + * 1. order of locks on granted queue is + * meaningless. + * 2. order of locks on converting queue is + * LOST with the node death. sorry charlie. + * 3. order of locks on the blocked queue is + * also LOST. + * order of locks does not affect integrity, it + * just means that a lock request may get pushed + * back in line as a result of the node death. + * also note that for a given node the lock order + * for its secondary queue locks is preserved + * relative to each other, but clearly *not* + * preserved relative to locks from other nodes. + */ + spin_lock(&res->spinlock); + dlm_lock_get(newlock); + list_add_tail(&newlock->list, queue); + spin_unlock(&res->spinlock); + } + mlog(0, "done running all the locks\n"); + +leave: + if (ret < 0) { + mlog_errno(ret); + if (newlock) + dlm_lock_put(newlock); + } + + mlog_exit(ret); + return ret; +} + +void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + int i; + struct list_head *queue, *iter, *iter2; + struct dlm_lock *lock; + + res->state |= DLM_LOCK_RES_RECOVERING; + if (!list_empty(&res->recovering)) + list_del_init(&res->recovering); + list_add_tail(&res->recovering, &dlm->reco.resources); + + /* find any pending locks and put them back on proper list */ + for (i=DLM_BLOCKED_LIST; i>=DLM_GRANTED_LIST; i--) { + queue = dlm_list_idx_to_ptr(res, i); + list_for_each_safe(iter, iter2, queue) { + lock = list_entry (iter, struct dlm_lock, list); + dlm_lock_get(lock); + if (lock->convert_pending) { + /* move converting lock back to granted */ + BUG_ON(i != DLM_CONVERTING_LIST); + mlog(0, "node died with convert pending " + "on %.*s. move back to granted list.\n", + res->lockname.len, res->lockname.name); + dlm_revert_pending_convert(res, lock); + lock->convert_pending = 0; + } else if (lock->lock_pending) { + /* remove pending lock requests completely */ + BUG_ON(i != DLM_BLOCKED_LIST); + mlog(0, "node died with lock pending " + "on %.*s. remove from blocked list and skip.\n", + res->lockname.len, res->lockname.name); + /* lock will be floating until ref in + * dlmlock_remote is freed after the network + * call returns. ok for it to not be on any + * list since no ast can be called + * (the master is dead). */ + dlm_revert_pending_lock(res, lock); + lock->lock_pending = 0; + } else if (lock->unlock_pending) { + /* if an unlock was in progress, treat as + * if this had completed successfully + * before sending this lock state to the + * new master. note that the dlm_unlock + * call is still responsible for calling + * the unlockast. that will happen after + * the network call times out. for now, + * just move lists to prepare the new + * recovery master. */ + BUG_ON(i != DLM_GRANTED_LIST); + mlog(0, "node died with unlock pending " + "on %.*s. remove from blocked list and skip.\n", + res->lockname.len, res->lockname.name); + dlm_commit_pending_unlock(res, lock); + lock->unlock_pending = 0; + } else if (lock->cancel_pending) { + /* if a cancel was in progress, treat as + * if this had completed successfully + * before sending this lock state to the + * new master */ + BUG_ON(i != DLM_CONVERTING_LIST); + mlog(0, "node died with cancel pending " + "on %.*s. move back to granted list.\n", + res->lockname.len, res->lockname.name); + dlm_commit_pending_cancel(res, lock); + lock->cancel_pending = 0; + } + dlm_lock_put(lock); + } + } +} + + + +/* removes all recovered locks from the recovery list. + * sets the res->owner to the new master. + * unsets the RECOVERY flag and wakes waiters. */ +static void dlm_finish_local_lockres_recovery(struct dlm_ctxt *dlm, + u8 dead_node, u8 new_master) +{ + int i; + struct list_head *iter, *iter2, *bucket; + struct dlm_lock_resource *res; + + mlog_entry_void(); + + assert_spin_locked(&dlm->spinlock); + + list_for_each_safe(iter, iter2, &dlm->reco.resources) { + res = list_entry (iter, struct dlm_lock_resource, recovering); + if (res->owner == dead_node) { + list_del_init(&res->recovering); + spin_lock(&res->spinlock); + dlm_change_lockres_owner(dlm, res, new_master); + res->state &= ~DLM_LOCK_RES_RECOVERING; + __dlm_dirty_lockres(dlm, res); + spin_unlock(&res->spinlock); + wake_up(&res->wq); + } + } + + /* this will become unnecessary eventually, but + * for now we need to run the whole hash, clear + * the RECOVERING state and set the owner + * if necessary */ + for (i=0; iresources[i]); + list_for_each(iter, bucket) { + res = list_entry (iter, struct dlm_lock_resource, list); + if (res->state & DLM_LOCK_RES_RECOVERING) { + if (res->owner == dead_node) { + mlog(0, "(this=%u) res %.*s owner=%u " + "was not on recovering list, but " + "clearing state anyway\n", + dlm->node_num, res->lockname.len, + res->lockname.name, new_master); + } else if (res->owner == dlm->node_num) { + mlog(0, "(this=%u) res %.*s owner=%u " + "was not on recovering list, " + "owner is THIS node, clearing\n", + dlm->node_num, res->lockname.len, + res->lockname.name, new_master); + } else + continue; + + spin_lock(&res->spinlock); + dlm_change_lockres_owner(dlm, res, new_master); + res->state &= ~DLM_LOCK_RES_RECOVERING; + __dlm_dirty_lockres(dlm, res); + spin_unlock(&res->spinlock); + wake_up(&res->wq); + } + } + } +} + +static inline int dlm_lvb_needs_invalidation(struct dlm_lock *lock, int local) +{ + if (local) { + if (lock->ml.type != LKM_EXMODE && + lock->ml.type != LKM_PRMODE) + return 1; + } else if (lock->ml.type == LKM_EXMODE) + return 1; + return 0; +} + +static void dlm_revalidate_lvb(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, u8 dead_node) +{ + struct list_head *iter, *queue; + struct dlm_lock *lock; + int blank_lvb = 0, local = 0; + int i; + u8 search_node; + + assert_spin_locked(&dlm->spinlock); + assert_spin_locked(&res->spinlock); + + if (res->owner == dlm->node_num) + /* if this node owned the lockres, and if the dead node + * had an EX when he died, blank out the lvb */ + search_node = dead_node; + else { + /* if this is a secondary lockres, and we had no EX or PR + * locks granted, we can no longer trust the lvb */ + search_node = dlm->node_num; + local = 1; /* check local state for valid lvb */ + } + + for (i=DLM_GRANTED_LIST; i<=DLM_CONVERTING_LIST; i++) { + queue = dlm_list_idx_to_ptr(res, i); + list_for_each(iter, queue) { + lock = list_entry (iter, struct dlm_lock, list); + if (lock->ml.node == search_node) { + if (dlm_lvb_needs_invalidation(lock, local)) { + /* zero the lksb lvb and lockres lvb */ + blank_lvb = 1; + memset(lock->lksb->lvb, 0, DLM_LVB_LEN); + } + } + } + } + + if (blank_lvb) { + mlog(0, "clearing %.*s lvb, dead node %u had EX\n", + res->lockname.len, res->lockname.name, dead_node); + memset(res->lvb, 0, DLM_LVB_LEN); + } +} + +static void dlm_free_dead_locks(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, u8 dead_node) +{ + struct list_head *iter, *tmpiter; + struct dlm_lock *lock; + + /* this node is the lockres master: + * 1) remove any stale locks for the dead node + * 2) if the dead node had an EX when he died, blank out the lvb + */ + assert_spin_locked(&dlm->spinlock); + assert_spin_locked(&res->spinlock); + + /* TODO: check pending_asts, pending_basts here */ + list_for_each_safe(iter, tmpiter, &res->granted) { + lock = list_entry (iter, struct dlm_lock, list); + if (lock->ml.node == dead_node) { + list_del_init(&lock->list); + dlm_lock_put(lock); + } + } + list_for_each_safe(iter, tmpiter, &res->converting) { + lock = list_entry (iter, struct dlm_lock, list); + if (lock->ml.node == dead_node) { + list_del_init(&lock->list); + dlm_lock_put(lock); + } + } + list_for_each_safe(iter, tmpiter, &res->blocked) { + lock = list_entry (iter, struct dlm_lock, list); + if (lock->ml.node == dead_node) { + list_del_init(&lock->list); + dlm_lock_put(lock); + } + } + + /* do not kick thread yet */ + __dlm_dirty_lockres(dlm, res); +} + +/* if this node is the recovery master, and there are no + * locks for a given lockres owned by this node that are in + * either PR or EX mode, zero out the lvb before requesting. + * + */ + + +static void dlm_do_local_recovery_cleanup(struct dlm_ctxt *dlm, u8 dead_node) +{ + struct list_head *iter; + struct dlm_lock_resource *res; + int i; + struct list_head *bucket; + + + /* purge any stale mles */ + dlm_clean_master_list(dlm, dead_node); + + /* + * now clean up all lock resources. there are two rules: + * + * 1) if the dead node was the master, move the lockres + * to the recovering list. set the RECOVERING flag. + * this lockres needs to be cleaned up before it can + * be used further. + * + * 2) if this node was the master, remove all locks from + * each of the lockres queues that were owned by the + * dead node. once recovery finishes, the dlm thread + * can be kicked again to see if any ASTs or BASTs + * need to be fired as a result. + */ + for (i=0; iresources[i]); + list_for_each(iter, bucket) { + res = list_entry (iter, struct dlm_lock_resource, list); + if (dlm_is_recovery_lock(res->lockname.name, + res->lockname.len)) + continue; + + spin_lock(&res->spinlock); + /* zero the lvb if necessary */ + dlm_revalidate_lvb(dlm, res, dead_node); + if (res->owner == dead_node) + dlm_move_lockres_to_recovery_list(dlm, res); + else if (res->owner == dlm->node_num) { + dlm_free_dead_locks(dlm, res, dead_node); + __dlm_lockres_calc_usage(dlm, res); + } + spin_unlock(&res->spinlock); + } + } + +} + +static void __dlm_hb_node_down(struct dlm_ctxt *dlm, int idx) +{ + assert_spin_locked(&dlm->spinlock); + + /* check to see if the node is already considered dead */ + if (!test_bit(idx, dlm->live_nodes_map)) { + mlog(0, "for domain %s, node %d is already dead. " + "another node likely did recovery already.\n", + dlm->name, idx); + return; + } + + /* check to see if we do not care about this node */ + if (!test_bit(idx, dlm->domain_map)) { + /* This also catches the case that we get a node down + * but haven't joined the domain yet. */ + mlog(0, "node %u already removed from domain!\n", idx); + return; + } + + clear_bit(idx, dlm->live_nodes_map); + + /* Clean up join state on node death. */ + if (dlm->joining_node == idx) { + mlog(0, "Clearing join state for node %u\n", idx); + __dlm_set_joining_node(dlm, DLM_LOCK_RES_OWNER_UNKNOWN); + } + + /* make sure local cleanup occurs before the heartbeat events */ + if (!test_bit(idx, dlm->recovery_map)) + dlm_do_local_recovery_cleanup(dlm, idx); + + /* notify anything attached to the heartbeat events */ + dlm_hb_event_notify_attached(dlm, idx, 0); + + mlog(0, "node %u being removed from domain map!\n", idx); + clear_bit(idx, dlm->domain_map); + /* wake up migration waiters if a node goes down. + * perhaps later we can genericize this for other waiters. */ + wake_up(&dlm->migration_wq); + + if (test_bit(idx, dlm->recovery_map)) + mlog(0, "domain %s, node %u already added " + "to recovery map!\n", dlm->name, idx); + else + set_bit(idx, dlm->recovery_map); +} + +void dlm_hb_node_down_cb(struct o2nm_node *node, int idx, void *data) +{ + struct dlm_ctxt *dlm = data; + + if (!dlm_grab(dlm)) + return; + + spin_lock(&dlm->spinlock); + __dlm_hb_node_down(dlm, idx); + spin_unlock(&dlm->spinlock); + + dlm_put(dlm); +} + +void dlm_hb_node_up_cb(struct o2nm_node *node, int idx, void *data) +{ + struct dlm_ctxt *dlm = data; + + if (!dlm_grab(dlm)) + return; + + spin_lock(&dlm->spinlock); + + set_bit(idx, dlm->live_nodes_map); + + /* notify any mles attached to the heartbeat events */ + dlm_hb_event_notify_attached(dlm, idx, 1); + + spin_unlock(&dlm->spinlock); + + dlm_put(dlm); +} + +static void dlm_reco_ast(void *astdata) +{ + struct dlm_ctxt *dlm = astdata; + mlog(0, "ast for recovery lock fired!, this=%u, dlm=%s\n", + dlm->node_num, dlm->name); +} +static void dlm_reco_bast(void *astdata, int blocked_type) +{ + struct dlm_ctxt *dlm = astdata; + mlog(0, "bast for recovery lock fired!, this=%u, dlm=%s\n", + dlm->node_num, dlm->name); +} +static void dlm_reco_unlock_ast(void *astdata, enum dlm_status st) +{ + mlog(0, "unlockast for recovery lock fired!\n"); +} + + +static int dlm_pick_recovery_master(struct dlm_ctxt *dlm) +{ + enum dlm_status ret; + struct dlm_lockstatus lksb; + int status = -EINVAL; + + mlog(0, "starting recovery of %s at %lu, dead=%u, this=%u\n", + dlm->name, jiffies, dlm->reco.dead_node, dlm->node_num); +retry: + memset(&lksb, 0, sizeof(lksb)); + + ret = dlmlock(dlm, LKM_EXMODE, &lksb, LKM_NOQUEUE|LKM_RECOVERY, + DLM_RECOVERY_LOCK_NAME, dlm_reco_ast, dlm, dlm_reco_bast); + + if (ret == DLM_NORMAL) { + mlog(0, "dlm=%s dlmlock says I got it (this=%u)\n", + dlm->name, dlm->node_num); + /* I am master, send message to all nodes saying + * that I am beginning a recovery session */ + status = dlm_send_begin_reco_message(dlm, + dlm->reco.dead_node); + + /* recovery lock is a special case. ast will not get fired, + * so just go ahead and unlock it. */ + ret = dlmunlock(dlm, &lksb, 0, dlm_reco_unlock_ast, dlm); + if (ret != DLM_NORMAL) { + /* this would really suck. this could only happen + * if there was a network error during the unlock + * because of node death. this means the unlock + * is actually "done" and the lock structure is + * even freed. we can continue, but only + * because this specific lock name is special. */ + mlog(0, "dlmunlock returned %d\n", ret); + } + + if (status < 0) { + mlog(0, "failed to send recovery message. " + "must retry with new node map.\n"); + goto retry; + } + } else if (ret == DLM_NOTQUEUED) { + mlog(0, "dlm=%s dlmlock says another node got it (this=%u)\n", + dlm->name, dlm->node_num); + /* another node is master. wait on + * reco.new_master != O2NM_INVALID_NODE_NUM */ + status = -EEXIST; + } + + return status; +} + +static int dlm_send_begin_reco_message(struct dlm_ctxt *dlm, u8 dead_node) +{ + struct dlm_begin_reco br; + int ret = 0; + struct dlm_node_iter iter; + int nodenum; + int status; + + mlog_entry("%u\n", dead_node); + + mlog(0, "dead node is %u\n", dead_node); + + spin_lock(&dlm->spinlock); + dlm_node_iter_init(dlm->domain_map, &iter); + spin_unlock(&dlm->spinlock); + + clear_bit(dead_node, iter.node_map); + + memset(&br, 0, sizeof(br)); + br.node_idx = dlm->node_num; + br.dead_node = dead_node; + + while ((nodenum = dlm_node_iter_next(&iter)) >= 0) { + ret = 0; + if (nodenum == dead_node) { + mlog(0, "not sending begin reco to dead node " + "%u\n", dead_node); + continue; + } + if (nodenum == dlm->node_num) { + mlog(0, "not sending begin reco to self\n"); + continue; + } + + ret = -EINVAL; + mlog(0, "attempting to send begin reco msg to %d\n", + nodenum); + ret = o2net_send_message(DLM_BEGIN_RECO_MSG, dlm->key, + &br, sizeof(br), nodenum, &status); + /* negative status is handled ok by caller here */ + if (ret >= 0) + ret = status; + if (ret < 0) { + struct dlm_lock_resource *res; + mlog_errno(ret); + mlog(ML_ERROR, "begin reco of dlm %s to node %u " + " returned %d\n", dlm->name, nodenum, ret); + res = dlm_lookup_lockres(dlm, DLM_RECOVERY_LOCK_NAME, + DLM_RECOVERY_LOCK_NAME_LEN); + if (res) { + dlm_print_one_lock_resource(res); + dlm_lockres_put(res); + } else { + mlog(ML_ERROR, "recovery lock not found\n"); + } + break; + } + } + + return ret; +} + +int dlm_begin_reco_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_begin_reco *br = (struct dlm_begin_reco *)msg->buf; + + /* ok to return 0, domain has gone away */ + if (!dlm_grab(dlm)) + return 0; + + mlog(0, "node %u wants to recover node %u\n", + br->node_idx, br->dead_node); + + dlm_fire_domain_eviction_callbacks(dlm, br->dead_node); + + spin_lock(&dlm->spinlock); + if (dlm->reco.new_master != O2NM_INVALID_NODE_NUM) { + mlog(0, "new_master already set to %u!\n", + dlm->reco.new_master); + } + if (dlm->reco.dead_node != O2NM_INVALID_NODE_NUM) { + mlog(0, "dead_node already set to %u!\n", + dlm->reco.dead_node); + } + dlm->reco.new_master = br->node_idx; + dlm->reco.dead_node = br->dead_node; + if (!test_bit(br->dead_node, dlm->recovery_map)) { + mlog(ML_ERROR, "recovery master %u sees %u as dead, but this " + "node has not yet. marking %u as dead\n", + br->node_idx, br->dead_node, br->dead_node); + __dlm_hb_node_down(dlm, br->dead_node); + } + spin_unlock(&dlm->spinlock); + + dlm_kick_recovery_thread(dlm); + dlm_put(dlm); + return 0; +} + +static int dlm_send_finalize_reco_message(struct dlm_ctxt *dlm) +{ + int ret = 0; + struct dlm_finalize_reco fr; + struct dlm_node_iter iter; + int nodenum; + int status; + + mlog(0, "finishing recovery for node %s:%u\n", + dlm->name, dlm->reco.dead_node); + + spin_lock(&dlm->spinlock); + dlm_node_iter_init(dlm->domain_map, &iter); + spin_unlock(&dlm->spinlock); + + memset(&fr, 0, sizeof(fr)); + fr.node_idx = dlm->node_num; + fr.dead_node = dlm->reco.dead_node; + + while ((nodenum = dlm_node_iter_next(&iter)) >= 0) { + if (nodenum == dlm->node_num) + continue; + ret = o2net_send_message(DLM_FINALIZE_RECO_MSG, dlm->key, + &fr, sizeof(fr), nodenum, &status); + if (ret >= 0) { + ret = status; + if (dlm_is_host_down(ret)) { + /* this has no effect on this recovery + * session, so set the status to zero to + * finish out the last recovery */ + mlog(ML_ERROR, "node %u went down after this " + "node finished recovery.\n", nodenum); + ret = 0; + } + } + if (ret < 0) { + mlog_errno(ret); + break; + } + } + + return ret; +} + +int dlm_finalize_reco_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_finalize_reco *fr = (struct dlm_finalize_reco *)msg->buf; + + /* ok to return 0, domain has gone away */ + if (!dlm_grab(dlm)) + return 0; + + mlog(0, "node %u finalizing recovery of node %u\n", + fr->node_idx, fr->dead_node); + + spin_lock(&dlm->spinlock); + + if (dlm->reco.new_master != fr->node_idx) { + mlog(ML_ERROR, "node %u sent recovery finalize msg, but node " + "%u is supposed to be the new master, dead=%u\n", + fr->node_idx, dlm->reco.new_master, fr->dead_node); + BUG(); + } + if (dlm->reco.dead_node != fr->dead_node) { + mlog(ML_ERROR, "node %u sent recovery finalize msg for dead " + "node %u, but node %u is supposed to be dead\n", + fr->node_idx, fr->dead_node, dlm->reco.dead_node); + BUG(); + } + + dlm_finish_local_lockres_recovery(dlm, fr->dead_node, fr->node_idx); + + spin_unlock(&dlm->spinlock); + + dlm_reset_recovery(dlm); + + dlm_kick_recovery_thread(dlm); + dlm_put(dlm); + return 0; +} diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c new file mode 100644 index 0000000..92cd5cd --- /dev/null +++ b/fs/ocfs2/dlm/dlmthread.c @@ -0,0 +1,695 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmthread.c + * + * standalone DLM module + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" +#include "dlmcommon.h" +#include "dlmdomain.h" + +#define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_THREAD) +#include "cluster/masklog.h" + +extern spinlock_t dlm_domain_lock; +extern struct list_head dlm_domains; + +static int dlm_thread(void *data); + +static void dlm_flush_asts(struct dlm_ctxt *dlm); + +#define dlm_lock_is_remote(dlm, lock) ((lock)->ml.node != (dlm)->node_num) + +/* will exit holding res->spinlock, but may drop in function */ +/* waits until flags are cleared on res->state */ +void __dlm_wait_on_lockres_flags(struct dlm_lock_resource *res, int flags) +{ + DECLARE_WAITQUEUE(wait, current); + + assert_spin_locked(&res->spinlock); + + add_wait_queue(&res->wq, &wait); +repeat: + set_current_state(TASK_UNINTERRUPTIBLE); + if (res->state & flags) { + spin_unlock(&res->spinlock); + schedule(); + spin_lock(&res->spinlock); + goto repeat; + } + remove_wait_queue(&res->wq, &wait); + current->state = TASK_RUNNING; +} + + +static int __dlm_lockres_unused(struct dlm_lock_resource *res) +{ + if (list_empty(&res->granted) && + list_empty(&res->converting) && + list_empty(&res->blocked) && + list_empty(&res->dirty)) + return 1; + return 0; +} + + +/* Call whenever you may have added or deleted something from one of + * the lockres queue's. This will figure out whether it belongs on the + * unused list or not and does the appropriate thing. */ +void __dlm_lockres_calc_usage(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + mlog_entry("%.*s\n", res->lockname.len, res->lockname.name); + + assert_spin_locked(&dlm->spinlock); + assert_spin_locked(&res->spinlock); + + if (__dlm_lockres_unused(res)){ + if (list_empty(&res->purge)) { + mlog(0, "putting lockres %.*s from purge list\n", + res->lockname.len, res->lockname.name); + + res->last_used = jiffies; + list_add_tail(&res->purge, &dlm->purge_list); + dlm->purge_count++; + } + } else if (!list_empty(&res->purge)) { + mlog(0, "removing lockres %.*s from purge list\n", + res->lockname.len, res->lockname.name); + + list_del_init(&res->purge); + dlm->purge_count--; + } +} + +void dlm_lockres_calc_usage(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + mlog_entry("%.*s\n", res->lockname.len, res->lockname.name); + spin_lock(&dlm->spinlock); + spin_lock(&res->spinlock); + + __dlm_lockres_calc_usage(dlm, res); + + spin_unlock(&res->spinlock); + spin_unlock(&dlm->spinlock); +} + +/* TODO: Eventual API: Called with the dlm spinlock held, may drop it + * to do migration, but will re-acquire before exit. */ +void dlm_purge_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *lockres) +{ + int master; + int ret; + + spin_lock(&lockres->spinlock); + master = lockres->owner == dlm->node_num; + spin_unlock(&lockres->spinlock); + + mlog(0, "purging lockres %.*s, master = %d\n", lockres->lockname.len, + lockres->lockname.name, master); + + /* Non master is the easy case -- no migration required, just + * quit. */ + if (!master) + goto finish; + + /* Wheee! Migrate lockres here! */ + spin_unlock(&dlm->spinlock); +again: + + ret = dlm_migrate_lockres(dlm, lockres, O2NM_MAX_NODES); + if (ret == -ENOTEMPTY) { + mlog(ML_ERROR, "lockres %.*s still has local locks!\n", + lockres->lockname.len, lockres->lockname.name); + + BUG(); + } else if (ret < 0) { + mlog(ML_NOTICE, "lockres %.*s: migrate failed, retrying\n", + lockres->lockname.len, lockres->lockname.name); + goto again; + } + + spin_lock(&dlm->spinlock); + +finish: + if (!list_empty(&lockres->purge)) { + list_del_init(&lockres->purge); + dlm->purge_count--; + } + __dlm_unhash_lockres(lockres); +} + +static void dlm_run_purge_list(struct dlm_ctxt *dlm, + int purge_now) +{ + unsigned int run_max, unused; + unsigned long purge_jiffies; + struct dlm_lock_resource *lockres; + + spin_lock(&dlm->spinlock); + run_max = dlm->purge_count; + + while(run_max && !list_empty(&dlm->purge_list)) { + run_max--; + + lockres = list_entry(dlm->purge_list.next, + struct dlm_lock_resource, purge); + + /* Status of the lockres *might* change so double + * check. If the lockres is unused, holding the dlm + * spinlock will prevent people from getting and more + * refs on it -- there's no need to keep the lockres + * spinlock. */ + spin_lock(&lockres->spinlock); + unused = __dlm_lockres_unused(lockres); + spin_unlock(&lockres->spinlock); + + if (!unused) + continue; + + purge_jiffies = lockres->last_used + + msecs_to_jiffies(DLM_PURGE_INTERVAL_MS); + + /* Make sure that we want to be processing this guy at + * this time. */ + if (!purge_now && time_after(purge_jiffies, jiffies)) { + /* Since resources are added to the purge list + * in tail order, we can stop at the first + * unpurgable resource -- anyone added after + * him will have a greater last_used value */ + break; + } + + list_del_init(&lockres->purge); + dlm->purge_count--; + + /* This may drop and reacquire the dlm spinlock if it + * has to do migration. */ + mlog(0, "calling dlm_purge_lockres!\n"); + dlm_purge_lockres(dlm, lockres); + mlog(0, "DONE calling dlm_purge_lockres!\n"); + + /* Avoid adding any scheduling latencies */ + cond_resched_lock(&dlm->spinlock); + } + + spin_unlock(&dlm->spinlock); +} + +static void dlm_shuffle_lists(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res) +{ + struct dlm_lock *lock, *target; + struct list_head *iter; + struct list_head *head; + int can_grant = 1; + + //mlog(0, "res->lockname.len=%d\n", res->lockname.len); + //mlog(0, "res->lockname.name=%p\n", res->lockname.name); + //mlog(0, "shuffle res %.*s\n", res->lockname.len, + // res->lockname.name); + + /* because this function is called with the lockres + * spinlock, and because we know that it is not migrating/ + * recovering/in-progress, it is fine to reserve asts and + * basts right before queueing them all throughout */ + assert_spin_locked(&res->spinlock); + BUG_ON((res->state & (DLM_LOCK_RES_MIGRATING| + DLM_LOCK_RES_RECOVERING| + DLM_LOCK_RES_IN_PROGRESS))); + +converting: + if (list_empty(&res->converting)) + goto blocked; + mlog(0, "res %.*s has locks on a convert queue\n", res->lockname.len, + res->lockname.name); + + target = list_entry(res->converting.next, struct dlm_lock, list); + if (target->ml.convert_type == LKM_IVMODE) { + mlog(ML_ERROR, "%.*s: converting a lock with no " + "convert_type!\n", res->lockname.len, res->lockname.name); + BUG(); + } + head = &res->granted; + list_for_each(iter, head) { + lock = list_entry(iter, struct dlm_lock, list); + if (lock==target) + continue; + if (!dlm_lock_compatible(lock->ml.type, + target->ml.convert_type)) { + can_grant = 0; + /* queue the BAST if not already */ + if (lock->ml.highest_blocked == LKM_IVMODE) { + __dlm_lockres_reserve_ast(res); + dlm_queue_bast(dlm, lock); + } + /* update the highest_blocked if needed */ + if (lock->ml.highest_blocked < target->ml.convert_type) + lock->ml.highest_blocked = + target->ml.convert_type; + } + } + head = &res->converting; + list_for_each(iter, head) { + lock = list_entry(iter, struct dlm_lock, list); + if (lock==target) + continue; + if (!dlm_lock_compatible(lock->ml.type, + target->ml.convert_type)) { + can_grant = 0; + if (lock->ml.highest_blocked == LKM_IVMODE) { + __dlm_lockres_reserve_ast(res); + dlm_queue_bast(dlm, lock); + } + if (lock->ml.highest_blocked < target->ml.convert_type) + lock->ml.highest_blocked = + target->ml.convert_type; + } + } + + /* we can convert the lock */ + if (can_grant) { + spin_lock(&target->spinlock); + BUG_ON(target->ml.highest_blocked != LKM_IVMODE); + + mlog(0, "calling ast for converting lock: %.*s, have: %d, " + "granting: %d, node: %u\n", res->lockname.len, + res->lockname.name, target->ml.type, + target->ml.convert_type, target->ml.node); + + target->ml.type = target->ml.convert_type; + target->ml.convert_type = LKM_IVMODE; + list_del_init(&target->list); + list_add_tail(&target->list, &res->granted); + + BUG_ON(!target->lksb); + target->lksb->status = DLM_NORMAL; + + spin_unlock(&target->spinlock); + + __dlm_lockres_reserve_ast(res); + dlm_queue_ast(dlm, target); + /* go back and check for more */ + goto converting; + } + +blocked: + if (list_empty(&res->blocked)) + goto leave; + target = list_entry(res->blocked.next, struct dlm_lock, list); + + head = &res->granted; + list_for_each(iter, head) { + lock = list_entry(iter, struct dlm_lock, list); + if (lock==target) + continue; + if (!dlm_lock_compatible(lock->ml.type, target->ml.type)) { + can_grant = 0; + if (lock->ml.highest_blocked == LKM_IVMODE) { + __dlm_lockres_reserve_ast(res); + dlm_queue_bast(dlm, lock); + } + if (lock->ml.highest_blocked < target->ml.type) + lock->ml.highest_blocked = target->ml.type; + } + } + + head = &res->converting; + list_for_each(iter, head) { + lock = list_entry(iter, struct dlm_lock, list); + if (lock==target) + continue; + if (!dlm_lock_compatible(lock->ml.type, target->ml.type)) { + can_grant = 0; + if (lock->ml.highest_blocked == LKM_IVMODE) { + __dlm_lockres_reserve_ast(res); + dlm_queue_bast(dlm, lock); + } + if (lock->ml.highest_blocked < target->ml.type) + lock->ml.highest_blocked = target->ml.type; + } + } + + /* we can grant the blocked lock (only + * possible if converting list empty) */ + if (can_grant) { + spin_lock(&target->spinlock); + BUG_ON(target->ml.highest_blocked != LKM_IVMODE); + + mlog(0, "calling ast for blocked lock: %.*s, granting: %d, " + "node: %u\n", res->lockname.len, res->lockname.name, + target->ml.type, target->ml.node); + + // target->ml.type is already correct + list_del_init(&target->list); + list_add_tail(&target->list, &res->granted); + + BUG_ON(!target->lksb); + target->lksb->status = DLM_NORMAL; + + spin_unlock(&target->spinlock); + + __dlm_lockres_reserve_ast(res); + dlm_queue_ast(dlm, target); + /* go back and check for more */ + goto converting; + } + +leave: + return; +} + +/* must have NO locks when calling this with res !=NULL * */ +void dlm_kick_thread(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) +{ + mlog_entry("dlm=%p, res=%p\n", dlm, res); + if (res) { + spin_lock(&dlm->spinlock); + spin_lock(&res->spinlock); + __dlm_dirty_lockres(dlm, res); + spin_unlock(&res->spinlock); + spin_unlock(&dlm->spinlock); + } + wake_up(&dlm->dlm_thread_wq); +} + +void __dlm_dirty_lockres(struct dlm_ctxt *dlm, struct dlm_lock_resource *res) +{ + mlog_entry("dlm=%p, res=%p\n", dlm, res); + + assert_spin_locked(&dlm->spinlock); + assert_spin_locked(&res->spinlock); + + /* don't shuffle secondary queues */ + if ((res->owner == dlm->node_num) && + !(res->state & DLM_LOCK_RES_DIRTY)) { + list_add_tail(&res->dirty, &dlm->dirty_list); + res->state |= DLM_LOCK_RES_DIRTY; + } +} + + +/* Launch the NM thread for the mounted volume */ +int dlm_launch_thread(struct dlm_ctxt *dlm) +{ + mlog(0, "starting dlm thread...\n"); + + dlm->dlm_thread_task = kthread_run(dlm_thread, dlm, "dlm_thread"); + if (IS_ERR(dlm->dlm_thread_task)) { + mlog_errno(PTR_ERR(dlm->dlm_thread_task)); + dlm->dlm_thread_task = NULL; + return -EINVAL; + } + + return 0; +} + +void dlm_complete_thread(struct dlm_ctxt *dlm) +{ + if (dlm->dlm_thread_task) { + mlog(ML_KTHREAD, "waiting for dlm thread to exit\n"); + kthread_stop(dlm->dlm_thread_task); + dlm->dlm_thread_task = NULL; + } +} + +static int dlm_dirty_list_empty(struct dlm_ctxt *dlm) +{ + int empty; + + spin_lock(&dlm->spinlock); + empty = list_empty(&dlm->dirty_list); + spin_unlock(&dlm->spinlock); + + return empty; +} + +static void dlm_flush_asts(struct dlm_ctxt *dlm) +{ + int ret; + struct dlm_lock *lock; + struct dlm_lock_resource *res; + u8 hi; + + spin_lock(&dlm->ast_lock); + while (!list_empty(&dlm->pending_asts)) { + lock = list_entry(dlm->pending_asts.next, + struct dlm_lock, ast_list); + /* get an extra ref on lock */ + dlm_lock_get(lock); + res = lock->lockres; + mlog(0, "delivering an ast for this lockres\n"); + + BUG_ON(!lock->ast_pending); + + /* remove from list (including ref) */ + list_del_init(&lock->ast_list); + dlm_lock_put(lock); + spin_unlock(&dlm->ast_lock); + + if (lock->ml.node != dlm->node_num) { + ret = dlm_do_remote_ast(dlm, res, lock); + if (ret < 0) + mlog_errno(ret); + } else + dlm_do_local_ast(dlm, res, lock); + + spin_lock(&dlm->ast_lock); + + /* possible that another ast was queued while + * we were delivering the last one */ + if (!list_empty(&lock->ast_list)) { + mlog(0, "aha another ast got queued while " + "we were finishing the last one. will " + "keep the ast_pending flag set.\n"); + } else + lock->ast_pending = 0; + + /* drop the extra ref. + * this may drop it completely. */ + dlm_lock_put(lock); + dlm_lockres_release_ast(dlm, res); + } + + while (!list_empty(&dlm->pending_basts)) { + lock = list_entry(dlm->pending_basts.next, + struct dlm_lock, bast_list); + /* get an extra ref on lock */ + dlm_lock_get(lock); + res = lock->lockres; + + BUG_ON(!lock->bast_pending); + + /* get the highest blocked lock, and reset */ + spin_lock(&lock->spinlock); + BUG_ON(lock->ml.highest_blocked <= LKM_IVMODE); + hi = lock->ml.highest_blocked; + lock->ml.highest_blocked = LKM_IVMODE; + spin_unlock(&lock->spinlock); + + /* remove from list (including ref) */ + list_del_init(&lock->bast_list); + dlm_lock_put(lock); + spin_unlock(&dlm->ast_lock); + + mlog(0, "delivering a bast for this lockres " + "(blocked = %d\n", hi); + + if (lock->ml.node != dlm->node_num) { + ret = dlm_send_proxy_bast(dlm, res, lock, hi); + if (ret < 0) + mlog_errno(ret); + } else + dlm_do_local_bast(dlm, res, lock, hi); + + spin_lock(&dlm->ast_lock); + + /* possible that another bast was queued while + * we were delivering the last one */ + if (!list_empty(&lock->bast_list)) { + mlog(0, "aha another bast got queued while " + "we were finishing the last one. will " + "keep the bast_pending flag set.\n"); + } else + lock->bast_pending = 0; + + /* drop the extra ref. + * this may drop it completely. */ + dlm_lock_put(lock); + dlm_lockres_release_ast(dlm, res); + } + wake_up(&dlm->ast_wq); + spin_unlock(&dlm->ast_lock); +} + + +#define DLM_THREAD_TIMEOUT_MS (4 * 1000) +#define DLM_THREAD_MAX_DIRTY 100 +#define DLM_THREAD_MAX_ASTS 10 + +static int dlm_thread(void *data) +{ + struct dlm_lock_resource *res; + struct dlm_ctxt *dlm = data; + unsigned long timeout = msecs_to_jiffies(DLM_THREAD_TIMEOUT_MS); + + mlog(0, "dlm thread running for %s...\n", dlm->name); + + while (!kthread_should_stop()) { + int n = DLM_THREAD_MAX_DIRTY; + + /* dlm_shutting_down is very point-in-time, but that + * doesn't matter as we'll just loop back around if we + * get false on the leading edge of a state + * transition. */ + dlm_run_purge_list(dlm, dlm_shutting_down(dlm)); + + /* We really don't want to hold dlm->spinlock while + * calling dlm_shuffle_lists on each lockres that + * needs to have its queues adjusted and AST/BASTs + * run. So let's pull each entry off the dirty_list + * and drop dlm->spinlock ASAP. Once off the list, + * res->spinlock needs to be taken again to protect + * the queues while calling dlm_shuffle_lists. */ + spin_lock(&dlm->spinlock); + while (!list_empty(&dlm->dirty_list)) { + int delay = 0; + res = list_entry(dlm->dirty_list.next, + struct dlm_lock_resource, dirty); + + /* peel a lockres off, remove it from the list, + * unset the dirty flag and drop the dlm lock */ + BUG_ON(!res); + dlm_lockres_get(res); + + spin_lock(&res->spinlock); + res->state &= ~DLM_LOCK_RES_DIRTY; + list_del_init(&res->dirty); + spin_unlock(&res->spinlock); + spin_unlock(&dlm->spinlock); + + /* lockres can be re-dirtied/re-added to the + * dirty_list in this gap, but that is ok */ + + spin_lock(&res->spinlock); + if (res->owner != dlm->node_num) { + __dlm_print_one_lock_resource(res); + mlog(ML_ERROR, "inprog:%s, mig:%s, reco:%s, dirty:%s\n", + res->state & DLM_LOCK_RES_IN_PROGRESS ? "yes" : "no", + res->state & DLM_LOCK_RES_MIGRATING ? "yes" : "no", + res->state & DLM_LOCK_RES_RECOVERING ? "yes" : "no", + res->state & DLM_LOCK_RES_DIRTY ? "yes" : "no"); + } + BUG_ON(res->owner != dlm->node_num); + + /* it is now ok to move lockreses in these states + * to the dirty list, assuming that they will only be + * dirty for a short while. */ + if (res->state & (DLM_LOCK_RES_IN_PROGRESS | + DLM_LOCK_RES_MIGRATING | + DLM_LOCK_RES_RECOVERING)) { + /* move it to the tail and keep going */ + spin_unlock(&res->spinlock); + mlog(0, "delaying list shuffling for in-" + "progress lockres %.*s, state=%d\n", + res->lockname.len, res->lockname.name, + res->state); + delay = 1; + goto in_progress; + } + + /* at this point the lockres is not migrating/ + * recovering/in-progress. we have the lockres + * spinlock and do NOT have the dlm lock. + * safe to reserve/queue asts and run the lists. */ + + mlog(0, "calling dlm_shuffle_lists with dlm=%p, " + "res=%p\n", dlm, res); + + /* called while holding lockres lock */ + dlm_shuffle_lists(dlm, res); + spin_unlock(&res->spinlock); + + dlm_lockres_calc_usage(dlm, res); + +in_progress: + + spin_lock(&dlm->spinlock); + /* if the lock was in-progress, stick + * it on the back of the list */ + if (delay) { + spin_lock(&res->spinlock); + list_add_tail(&res->dirty, &dlm->dirty_list); + res->state |= DLM_LOCK_RES_DIRTY; + spin_unlock(&res->spinlock); + } + dlm_lockres_put(res); + + /* unlikely, but we may need to give time to + * other tasks */ + if (!--n) { + mlog(0, "throttling dlm_thread\n"); + break; + } + } + + spin_unlock(&dlm->spinlock); + dlm_flush_asts(dlm); + + /* yield and continue right away if there is more work to do */ + if (!n) { + yield(); + continue; + } + + wait_event_interruptible_timeout(dlm->dlm_thread_wq, + !dlm_dirty_list_empty(dlm) || + kthread_should_stop(), + timeout); + } + + mlog(0, "quitting DLM thread\n"); + return 0; +} diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c new file mode 100644 index 0000000..cec2ce1 --- /dev/null +++ b/fs/ocfs2/dlm/dlmunlock.c @@ -0,0 +1,672 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmunlock.c + * + * underlying calls for unlocking locks + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cluster/heartbeat.h" +#include "cluster/nodemanager.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" +#include "dlmcommon.h" + +#define MLOG_MASK_PREFIX ML_DLM +#include "cluster/masklog.h" + +#define DLM_UNLOCK_FREE_LOCK 0x00000001 +#define DLM_UNLOCK_CALL_AST 0x00000002 +#define DLM_UNLOCK_REMOVE_LOCK 0x00000004 +#define DLM_UNLOCK_REGRANT_LOCK 0x00000008 +#define DLM_UNLOCK_CLEAR_CONVERT_TYPE 0x00000010 + + +static enum dlm_status dlm_get_cancel_actions(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int *actions); +static enum dlm_status dlm_get_unlock_actions(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int *actions); + +static enum dlm_status dlm_send_remote_unlock_request(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int flags, + u8 owner); + + +/* + * according to the spec: + * http://opendlm.sourceforge.net/cvsmirror/opendlm/docs/dlmbook_final.pdf + * + * flags & LKM_CANCEL != 0: must be converting or blocked + * flags & LKM_CANCEL == 0: must be granted + * + * So to unlock a converting lock, you must first cancel the + * convert (passing LKM_CANCEL in flags), then call the unlock + * again (with no LKM_CANCEL in flags). + */ + + +/* + * locking: + * caller needs: none + * taken: res->spinlock and lock->spinlock taken and dropped + * held on exit: none + * returns: DLM_NORMAL, DLM_NOLOCKMGR, status from network + * all callers should have taken an extra ref on lock coming in + */ +static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int flags, int *call_ast, + int master_node) +{ + enum dlm_status status; + int actions = 0; + int in_use; + u8 owner; + + mlog(0, "master_node = %d, valblk = %d\n", master_node, + flags & LKM_VALBLK); + + if (master_node) + BUG_ON(res->owner != dlm->node_num); + else + BUG_ON(res->owner == dlm->node_num); + + spin_lock(&dlm->spinlock); + /* We want to be sure that we're not freeing a lock + * that still has AST's pending... */ + in_use = !list_empty(&lock->ast_list); + spin_unlock(&dlm->spinlock); + if (in_use) { + mlog(ML_ERROR, "lockres %.*s: Someone is calling dlmunlock " + "while waiting for an ast!", res->lockname.len, + res->lockname.name); + return DLM_BADPARAM; + } + + spin_lock(&res->spinlock); + if (res->state & DLM_LOCK_RES_IN_PROGRESS) { + if (master_node) { + mlog(ML_ERROR, "lockres in progress!\n"); + spin_unlock(&res->spinlock); + return DLM_FORWARD; + } + /* ok for this to sleep if not in a network handler */ + __dlm_wait_on_lockres(res); + res->state |= DLM_LOCK_RES_IN_PROGRESS; + } + spin_lock(&lock->spinlock); + + if (res->state & DLM_LOCK_RES_RECOVERING) { + status = DLM_RECOVERING; + goto leave; + } + + + /* see above for what the spec says about + * LKM_CANCEL and the lock queue state */ + if (flags & LKM_CANCEL) + status = dlm_get_cancel_actions(dlm, res, lock, lksb, &actions); + else + status = dlm_get_unlock_actions(dlm, res, lock, lksb, &actions); + + if (status != DLM_NORMAL) + goto leave; + + /* By now this has been masked out of cancel requests. */ + if (flags & LKM_VALBLK) { + /* make the final update to the lvb */ + if (master_node) + memcpy(res->lvb, lksb->lvb, DLM_LVB_LEN); + else + flags |= LKM_PUT_LVB; /* let the send function + * handle it. */ + } + + if (!master_node) { + owner = res->owner; + /* drop locks and send message */ + if (flags & LKM_CANCEL) + lock->cancel_pending = 1; + else + lock->unlock_pending = 1; + spin_unlock(&lock->spinlock); + spin_unlock(&res->spinlock); + status = dlm_send_remote_unlock_request(dlm, res, lock, lksb, + flags, owner); + spin_lock(&res->spinlock); + spin_lock(&lock->spinlock); + /* if the master told us the lock was already granted, + * let the ast handle all of these actions */ + if (status == DLM_NORMAL && + lksb->status == DLM_CANCELGRANT) { + actions &= ~(DLM_UNLOCK_REMOVE_LOCK| + DLM_UNLOCK_REGRANT_LOCK| + DLM_UNLOCK_CLEAR_CONVERT_TYPE); + } + if (flags & LKM_CANCEL) + lock->cancel_pending = 0; + else + lock->unlock_pending = 0; + + } + + /* get an extra ref on lock. if we are just switching + * lists here, we dont want the lock to go away. */ + dlm_lock_get(lock); + + if (actions & DLM_UNLOCK_REMOVE_LOCK) { + list_del_init(&lock->list); + dlm_lock_put(lock); + } + if (actions & DLM_UNLOCK_REGRANT_LOCK) { + dlm_lock_get(lock); + list_add_tail(&lock->list, &res->granted); + } + if (actions & DLM_UNLOCK_CLEAR_CONVERT_TYPE) { + mlog(0, "clearing convert_type at %smaster node\n", + master_node ? "" : "non-"); + lock->ml.convert_type = LKM_IVMODE; + } + + /* remove the extra ref on lock */ + dlm_lock_put(lock); + +leave: + res->state &= ~DLM_LOCK_RES_IN_PROGRESS; + if (!dlm_lock_on_list(&res->converting, lock)) + BUG_ON(lock->ml.convert_type != LKM_IVMODE); + else + BUG_ON(lock->ml.convert_type == LKM_IVMODE); + spin_unlock(&lock->spinlock); + spin_unlock(&res->spinlock); + wake_up(&res->wq); + + /* let the caller's final dlm_lock_put handle the actual kfree */ + if (actions & DLM_UNLOCK_FREE_LOCK) { + /* this should always be coupled with list removal */ + BUG_ON(!(actions & DLM_UNLOCK_REMOVE_LOCK)); + mlog(0, "lock %"MLFu64" should be gone now! refs=%d\n", + lock->ml.cookie, atomic_read(&lock->lock_refs.refcount)-1); + dlm_lock_put(lock); + } + if (actions & DLM_UNLOCK_CALL_AST) + *call_ast = 1; + + /* if cancel or unlock succeeded, lvb work is done */ + if (status == DLM_NORMAL) + lksb->flags &= ~(DLM_LKSB_PUT_LVB|DLM_LKSB_GET_LVB); + + return status; +} + +void dlm_commit_pending_unlock(struct dlm_lock_resource *res, + struct dlm_lock *lock) +{ + /* leave DLM_LKSB_PUT_LVB on the lksb so any final + * update of the lvb will be sent to the new master */ + list_del_init(&lock->list); +} + +void dlm_commit_pending_cancel(struct dlm_lock_resource *res, + struct dlm_lock *lock) +{ + list_del_init(&lock->list); + list_add_tail(&lock->list, &res->granted); + lock->ml.convert_type = LKM_IVMODE; +} + + +static inline enum dlm_status dlmunlock_master(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int flags, + int *call_ast) +{ + return dlmunlock_common(dlm, res, lock, lksb, flags, call_ast, 1); +} + +static inline enum dlm_status dlmunlock_remote(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int flags, int *call_ast) +{ + return dlmunlock_common(dlm, res, lock, lksb, flags, call_ast, 0); +} + +/* + * locking: + * caller needs: none + * taken: none + * held on exit: none + * returns: DLM_NORMAL, DLM_NOLOCKMGR, status from network + */ +static enum dlm_status dlm_send_remote_unlock_request(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int flags, + u8 owner) +{ + struct dlm_unlock_lock unlock; + int tmpret; + enum dlm_status ret; + int status = 0; + struct kvec vec[2]; + size_t veclen = 1; + + mlog_entry("%.*s\n", res->lockname.len, res->lockname.name); + + memset(&unlock, 0, sizeof(unlock)); + unlock.node_idx = dlm->node_num; + unlock.flags = cpu_to_be32(flags); + unlock.cookie = lock->ml.cookie; + unlock.namelen = res->lockname.len; + memcpy(unlock.name, res->lockname.name, unlock.namelen); + + vec[0].iov_len = sizeof(struct dlm_unlock_lock); + vec[0].iov_base = &unlock; + + if (flags & LKM_PUT_LVB) { + /* extra data to send if we are updating lvb */ + vec[1].iov_len = DLM_LVB_LEN; + vec[1].iov_base = lock->lksb->lvb; + veclen++; + } + + tmpret = o2net_send_message_vec(DLM_UNLOCK_LOCK_MSG, dlm->key, + vec, veclen, owner, &status); + if (tmpret >= 0) { + // successfully sent and received + if (status == DLM_CANCELGRANT) + ret = DLM_NORMAL; + else if (status == DLM_FORWARD) { + mlog(0, "master was in-progress. retry\n"); + ret = DLM_FORWARD; + } else + ret = status; + lksb->status = status; + } else { + mlog_errno(tmpret); + if (dlm_is_host_down(tmpret)) { + /* NOTE: this seems strange, but it is what we want. + * when the master goes down during a cancel or + * unlock, the recovery code completes the operation + * as if the master had not died, then passes the + * updated state to the recovery master. this thread + * just needs to finish out the operation and call + * the unlockast. */ + ret = DLM_NORMAL; + } else { + /* something bad. this will BUG in ocfs2 */ + ret = dlm_err_to_dlm_status(tmpret); + } + lksb->status = ret; + } + + return ret; +} + +/* + * locking: + * caller needs: none + * taken: takes and drops res->spinlock + * held on exit: none + * returns: DLM_NORMAL, DLM_BADARGS, DLM_IVLOCKID, + * return value from dlmunlock_master + */ +int dlm_unlock_lock_handler(struct o2net_msg *msg, u32 len, void *data) +{ + struct dlm_ctxt *dlm = data; + struct dlm_unlock_lock *unlock = (struct dlm_unlock_lock *)msg->buf; + struct dlm_lock_resource *res = NULL; + struct list_head *iter; + struct dlm_lock *lock = NULL; + enum dlm_status status = DLM_NORMAL; + int found = 0, i; + struct dlm_lockstatus *lksb = NULL; + int ignore; + u32 flags; + struct list_head *queue; + + flags = be32_to_cpu(unlock->flags); + + if (flags & LKM_GET_LVB) { + mlog(ML_ERROR, "bad args! GET_LVB specified on unlock!\n"); + return DLM_BADARGS; + } + + if ((flags & (LKM_PUT_LVB|LKM_CANCEL)) == (LKM_PUT_LVB|LKM_CANCEL)) { + mlog(ML_ERROR, "bad args! cannot modify lvb on a CANCEL " + "request!\n"); + return DLM_BADARGS; + } + + if (unlock->namelen > DLM_LOCKID_NAME_MAX) { + mlog(ML_ERROR, "Invalid name length in unlock handler!\n"); + return DLM_IVBUFLEN; + } + + if (!dlm_grab(dlm)) + return DLM_REJECTED; + + mlog_bug_on_msg(!dlm_domain_fully_joined(dlm), + "Domain %s not fully joined!\n", dlm->name); + + mlog(0, "lvb: %s\n", flags & LKM_PUT_LVB ? "put lvb" : "none"); + + res = dlm_lookup_lockres(dlm, unlock->name, unlock->namelen); + if (!res) { + /* We assume here that a no lock resource simply means + * it was migrated away and destroyed before the other + * node could detect it. */ + mlog(0, "returning DLM_FORWARD -- res no longer exists\n"); + status = DLM_FORWARD; + goto not_found; + } + + queue=&res->granted; + found = 0; + spin_lock(&res->spinlock); + if (res->state & DLM_LOCK_RES_RECOVERING) { + spin_unlock(&res->spinlock); + mlog(0, "returning DLM_RECOVERING\n"); + status = DLM_RECOVERING; + goto leave; + } + + if (res->state & DLM_LOCK_RES_MIGRATING) { + spin_unlock(&res->spinlock); + mlog(0, "returning DLM_MIGRATING\n"); + status = DLM_MIGRATING; + goto leave; + } + + if (res->owner != dlm->node_num) { + spin_unlock(&res->spinlock); + mlog(0, "returning DLM_FORWARD -- not master\n"); + status = DLM_FORWARD; + goto leave; + } + + for (i=0; i<3; i++) { + list_for_each(iter, queue) { + lock = list_entry(iter, struct dlm_lock, list); + if (lock->ml.cookie == unlock->cookie && + lock->ml.node == unlock->node_idx) { + dlm_lock_get(lock); + found = 1; + break; + } + } + if (found) + break; + /* scan granted -> converting -> blocked queues */ + queue++; + } + spin_unlock(&res->spinlock); + if (!found) { + status = DLM_IVLOCKID; + goto not_found; + } + + /* lock was found on queue */ + lksb = lock->lksb; + /* unlockast only called on originating node */ + if (flags & LKM_PUT_LVB) { + lksb->flags |= DLM_LKSB_PUT_LVB; + memcpy(&lksb->lvb[0], &unlock->lvb[0], DLM_LVB_LEN); + } + + /* if this is in-progress, propagate the DLM_FORWARD + * all the way back out */ + status = dlmunlock_master(dlm, res, lock, lksb, flags, &ignore); + if (status == DLM_FORWARD) + mlog(0, "lockres is in progress\n"); + + if (flags & LKM_PUT_LVB) + lksb->flags &= ~DLM_LKSB_PUT_LVB; + + dlm_lockres_calc_usage(dlm, res); + dlm_kick_thread(dlm, res); + +not_found: + if (!found) + mlog(ML_ERROR, "failed to find lock to unlock! " + "cookie=%"MLFu64"\n", + unlock->cookie); + else { + /* send the lksb->status back to the other node */ + status = lksb->status; + dlm_lock_put(lock); + } + +leave: + if (res) + dlm_lockres_put(res); + + dlm_put(dlm); + + return status; +} + + +static enum dlm_status dlm_get_cancel_actions(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int *actions) +{ + enum dlm_status status; + + if (dlm_lock_on_list(&res->blocked, lock)) { + /* cancel this outright */ + lksb->status = DLM_NORMAL; + status = DLM_NORMAL; + *actions = (DLM_UNLOCK_CALL_AST | + DLM_UNLOCK_REMOVE_LOCK); + } else if (dlm_lock_on_list(&res->converting, lock)) { + /* cancel the request, put back on granted */ + lksb->status = DLM_NORMAL; + status = DLM_NORMAL; + *actions = (DLM_UNLOCK_CALL_AST | + DLM_UNLOCK_REMOVE_LOCK | + DLM_UNLOCK_REGRANT_LOCK | + DLM_UNLOCK_CLEAR_CONVERT_TYPE); + } else if (dlm_lock_on_list(&res->granted, lock)) { + /* too late, already granted. DLM_CANCELGRANT */ + lksb->status = DLM_CANCELGRANT; + status = DLM_NORMAL; + *actions = DLM_UNLOCK_CALL_AST; + } else { + mlog(ML_ERROR, "lock to cancel is not on any list!\n"); + lksb->status = DLM_IVLOCKID; + status = DLM_IVLOCKID; + *actions = 0; + } + return status; +} + +static enum dlm_status dlm_get_unlock_actions(struct dlm_ctxt *dlm, + struct dlm_lock_resource *res, + struct dlm_lock *lock, + struct dlm_lockstatus *lksb, + int *actions) +{ + enum dlm_status status; + + /* unlock request */ + if (!dlm_lock_on_list(&res->granted, lock)) { + lksb->status = DLM_DENIED; + status = DLM_DENIED; + dlm_error(status); + *actions = 0; + } else { + /* unlock granted lock */ + lksb->status = DLM_NORMAL; + status = DLM_NORMAL; + *actions = (DLM_UNLOCK_FREE_LOCK | + DLM_UNLOCK_CALL_AST | + DLM_UNLOCK_REMOVE_LOCK); + } + return status; +} + +/* there seems to be no point in doing this async + * since (even for the remote case) there is really + * no work to queue up... so just do it and fire the + * unlockast by hand when done... */ +enum dlm_status dlmunlock(struct dlm_ctxt *dlm, struct dlm_lockstatus *lksb, + int flags, dlm_astunlockfunc_t *unlockast, void *data) +{ + enum dlm_status status; + struct dlm_lock_resource *res; + struct dlm_lock *lock = NULL; + int call_ast, is_master; + + mlog_entry_void(); + + if (!lksb) { + dlm_error(DLM_BADARGS); + return DLM_BADARGS; + } + + if (flags & ~(LKM_CANCEL | LKM_VALBLK | LKM_INVVALBLK)) { + dlm_error(DLM_BADPARAM); + return DLM_BADPARAM; + } + + if ((flags & (LKM_VALBLK | LKM_CANCEL)) == (LKM_VALBLK | LKM_CANCEL)) { + mlog(0, "VALBLK given with CANCEL: ignoring VALBLK\n"); + flags &= ~LKM_VALBLK; + } + + if (!lksb->lockid || !lksb->lockid->lockres) { + dlm_error(DLM_BADPARAM); + return DLM_BADPARAM; + } + + lock = lksb->lockid; + BUG_ON(!lock); + dlm_lock_get(lock); + + res = lock->lockres; + BUG_ON(!res); + dlm_lockres_get(res); +retry: + call_ast = 0; + /* need to retry up here because owner may have changed */ + mlog(0, "lock=%p res=%p\n", lock, res); + + spin_lock(&res->spinlock); + is_master = (res->owner == dlm->node_num); + spin_unlock(&res->spinlock); + + if (is_master) { + status = dlmunlock_master(dlm, res, lock, lksb, flags, + &call_ast); + mlog(0, "done calling dlmunlock_master: returned %d, " + "call_ast is %d\n", status, call_ast); + } else { + status = dlmunlock_remote(dlm, res, lock, lksb, flags, + &call_ast); + mlog(0, "done calling dlmunlock_remote: returned %d, " + "call_ast is %d\n", status, call_ast); + } + + if (status == DLM_RECOVERING || + status == DLM_MIGRATING || + status == DLM_FORWARD) { + /* We want to go away for a tiny bit to allow recovery + * / migration to complete on this resource. I don't + * know of any wait queue we could sleep on as this + * may be happening on another node. Perhaps the + * proper solution is to queue up requests on the + * other end? */ + + /* do we want to yield(); ?? */ + msleep(50); + + mlog(0, "retrying unlock due to pending recovery/" + "migration/in-progress\n"); + goto retry; + } + + if (call_ast) { + mlog(0, "calling unlockast(%p, %d)\n", data, lksb->status); + if (is_master) { + /* it is possible that there is one last bast + * pending. make sure it is flushed, then + * call the unlockast. + * not an issue if this is a mastered remotely, + * since this lock has been removed from the + * lockres queues and cannot be found. */ + dlm_kick_thread(dlm, NULL); + wait_event(dlm->ast_wq, + dlm_lock_basts_flushed(dlm, lock)); + } + (*unlockast)(data, lksb->status); + } + + if (status == DLM_NORMAL) { + mlog(0, "kicking the thread\n"); + dlm_kick_thread(dlm, res); + } else + dlm_error(status); + + dlm_lockres_calc_usage(dlm, res); + dlm_lockres_put(res); + dlm_lock_put(lock); + + mlog(0, "returning status=%d!\n", status); + return status; +} +EXPORT_SYMBOL_GPL(dlmunlock); + diff --git a/fs/ocfs2/dlm/dlmver.c b/fs/ocfs2/dlm/dlmver.c new file mode 100644 index 0000000..7ef2653 --- /dev/null +++ b/fs/ocfs2/dlm/dlmver.c @@ -0,0 +1,42 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmver.c + * + * version string + * + * Copyright (C) 2002, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include + +#include "dlmver.h" + +#define DLM_BUILD_VERSION "1.3.3" + +#define VERSION_STR "OCFS2 DLM " DLM_BUILD_VERSION + +void dlm_print_version(void) +{ + printk(KERN_INFO "%s\n", VERSION_STR); +} + +MODULE_DESCRIPTION(VERSION_STR); + +MODULE_VERSION(DLM_BUILD_VERSION); diff --git a/fs/ocfs2/dlm/dlmver.h b/fs/ocfs2/dlm/dlmver.h new file mode 100644 index 0000000..f674aee --- /dev/null +++ b/fs/ocfs2/dlm/dlmver.h @@ -0,0 +1,31 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmfsver.h + * + * Function prototypes + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef DLM_VER_H +#define DLM_VER_H + +void dlm_print_version(void); + +#endif /* DLM_VER_H */ -- cgit v1.1 From 8df08c89c668e1bd922a053fdb5ba1fadbecbb38 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 15 Dec 2005 14:31:23 -0800 Subject: [PATCH] OCFS2: The Second Oracle Cluster Filesystem dlmfs: A minimal dlm userspace interface implemented via a virtual file system. Most of the OCFS2 tools make use of this to take cluster locks when doing operations on the file system. Signed-off-by: Mark Fasheh Signed-off-by: Kurt Hackel --- Documentation/filesystems/00-INDEX | 2 + Documentation/filesystems/dlmfs.txt | 130 +++++++ fs/ocfs2/dlm/Makefile | 4 +- fs/ocfs2/dlm/dlmfs.c | 640 +++++++++++++++++++++++++++++++++++ fs/ocfs2/dlm/dlmfsver.c | 42 +++ fs/ocfs2/dlm/dlmfsver.h | 31 ++ fs/ocfs2/dlm/userdlm.c | 658 ++++++++++++++++++++++++++++++++++++ fs/ocfs2/dlm/userdlm.h | 111 ++++++ 8 files changed, 1617 insertions(+), 1 deletion(-) create mode 100644 Documentation/filesystems/dlmfs.txt create mode 100644 fs/ocfs2/dlm/dlmfs.c create mode 100644 fs/ocfs2/dlm/dlmfsver.c create mode 100644 fs/ocfs2/dlm/dlmfsver.h create mode 100644 fs/ocfs2/dlm/userdlm.c create mode 100644 fs/ocfs2/dlm/userdlm.h diff --git a/Documentation/filesystems/00-INDEX b/Documentation/filesystems/00-INDEX index 628f8a7..d9b0a06 100644 --- a/Documentation/filesystems/00-INDEX +++ b/Documentation/filesystems/00-INDEX @@ -18,6 +18,8 @@ cramfs.txt - info on the cram filesystem for small storage (ROMs etc) devfs/ - directory containing devfs documentation. +dlmfs.txt + - info on the userspace interface to the OCFS2 DLM. ext2.txt - info, mount options and specifications for the Ext2 filesystem. fat_cvf.txt diff --git a/Documentation/filesystems/dlmfs.txt b/Documentation/filesystems/dlmfs.txt new file mode 100644 index 0000000..9afab84 --- /dev/null +++ b/Documentation/filesystems/dlmfs.txt @@ -0,0 +1,130 @@ +dlmfs +================== +A minimal DLM userspace interface implemented via a virtual file +system. + +dlmfs is built with OCFS2 as it requires most of its infrastructure. + +Project web page: http://oss.oracle.com/projects/ocfs2 +Tools web page: http://oss.oracle.com/projects/ocfs2-tools +OCFS2 mailing lists: http://oss.oracle.com/projects/ocfs2/mailman/ + +All code copyright 2005 Oracle except when otherwise noted. + +CREDITS +======= + +Some code taken from ramfs which is Copyright (C) 2000 Linus Torvalds +and Transmeta Corp. + +Mark Fasheh + +Caveats +======= +- Right now it only works with the OCFS2 DLM, though support for other + DLM implementations should not be a major issue. + +Mount options +============= +None + +Usage +===== + +If you're just interested in OCFS2, then please see ocfs2.txt. The +rest of this document will be geared towards those who want to use +dlmfs for easy to setup and easy to use clustered locking in +userspace. + +Setup +===== + +dlmfs requires that the OCFS2 cluster infrastructure be in +place. Please download ocfs2-tools from the above url and configure a +cluster. + +You'll want to start heartbeating on a volume which all the nodes in +your lockspace can access. The easiest way to do this is via +ocfs2_hb_ctl (distributed with ocfs2-tools). Right now it requires +that an OCFS2 file system be in place so that it can automatically +find it's heartbeat area, though it will eventually support heartbeat +against raw disks. + +Please see the ocfs2_hb_ctl and mkfs.ocfs2 manual pages distributed +with ocfs2-tools. + +Once you're heartbeating, DLM lock 'domains' can be easily created / +destroyed and locks within them accessed. + +Locking +======= + +Users may access dlmfs via standard file system calls, or they can use +'libo2dlm' (distributed with ocfs2-tools) which abstracts the file +system calls and presents a more traditional locking api. + +dlmfs handles lock caching automatically for the user, so a lock +request for an already acquired lock will not generate another DLM +call. Userspace programs are assumed to handle their own local +locking. + +Two levels of locks are supported - Shared Read, and Exlcusive. +Also supported is a Trylock operation. + +For information on the libo2dlm interface, please see o2dlm.h, +distributed with ocfs2-tools. + +Lock value blocks can be read and written to a resource via read(2) +and write(2) against the fd obtained via your open(2) call. The +maximum currently supported LVB length is 64 bytes (though that is an +OCFS2 DLM limitation). Through this mechanism, users of dlmfs can share +small amounts of data amongst their nodes. + +mkdir(2) signals dlmfs to join a domain (which will have the same name +as the resulting directory) + +rmdir(2) signals dlmfs to leave the domain + +Locks for a given domain are represented by regular inodes inside the +domain directory. Locking against them is done via the open(2) system +call. + +The open(2) call will not return until your lock has been granted or +an error has occurred, unless it has been instructed to do a trylock +operation. If the lock succeeds, you'll get an fd. + +open(2) with O_CREAT to ensure the resource inode is created - dlmfs does +not automatically create inodes for existing lock resources. + +Open Flag Lock Request Type +--------- ----------------- +O_RDONLY Shared Read +O_RDWR Exclusive + +Open Flag Resulting Locking Behavior +--------- -------------------------- +O_NONBLOCK Trylock operation + +You must provide exactly one of O_RDONLY or O_RDWR. + +If O_NONBLOCK is also provided and the trylock operation was valid but +could not lock the resource then open(2) will return ETXTBUSY. + +close(2) drops the lock associated with your fd. + +Modes passed to mkdir(2) or open(2) are adhered to locally. Chown is +supported locally as well. This means you can use them to restrict +access to the resources via dlmfs on your local node only. + +The resource LVB may be read from the fd in either Shared Read or +Exclusive modes via the read(2) system call. It can be written via +write(2) only when open in Exclusive mode. + +Once written, an LVB will be visible to other nodes who obtain Read +Only or higher level locks on the resource. + +See Also +======== +http://opendlm.sourceforge.net/cvsmirror/opendlm/docs/dlmbook_final.pdf + +For more information on the VMS distributed locking API. diff --git a/fs/ocfs2/dlm/Makefile b/fs/ocfs2/dlm/Makefile index 2a5274b..ce3f7c2 100644 --- a/fs/ocfs2/dlm/Makefile +++ b/fs/ocfs2/dlm/Makefile @@ -1,6 +1,8 @@ EXTRA_CFLAGS += -Ifs/ocfs2 -obj-$(CONFIG_OCFS2_FS) += ocfs2_dlm.o +obj-$(CONFIG_OCFS2_FS) += ocfs2_dlm.o ocfs2_dlmfs.o ocfs2_dlm-objs := dlmdomain.o dlmdebug.o dlmthread.o dlmrecovery.o \ dlmmaster.o dlmast.o dlmconvert.o dlmlock.o dlmunlock.o dlmver.o + +ocfs2_dlmfs-objs := userdlm.o dlmfs.o dlmfsver.o diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c new file mode 100644 index 0000000..dd2d24d --- /dev/null +++ b/fs/ocfs2/dlm/dlmfs.c @@ -0,0 +1,640 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmfs.c + * + * Code which implements the kernel side of a minimal userspace + * interface to our DLM. This file handles the virtual file system + * used for communication with userspace. Credit should go to ramfs, + * which was a template for the fs side of this module. + * + * Copyright (C) 2003, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +/* Simple VFS hooks based on: */ +/* + * Resizable simple ram filesystem for Linux. + * + * Copyright (C) 2000 Linus Torvalds. + * 2000 Transmeta Corp. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +#include "cluster/nodemanager.h" +#include "cluster/heartbeat.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" + +#include "userdlm.h" + +#include "dlmfsver.h" + +#define MLOG_MASK_PREFIX ML_DLMFS +#include "cluster/masklog.h" + +static struct super_operations dlmfs_ops; +static struct file_operations dlmfs_file_operations; +static struct inode_operations dlmfs_dir_inode_operations; +static struct inode_operations dlmfs_root_inode_operations; +static struct inode_operations dlmfs_file_inode_operations; +static kmem_cache_t *dlmfs_inode_cache; + +struct workqueue_struct *user_dlm_worker; + +/* + * decodes a set of open flags into a valid lock level and a set of flags. + * returns < 0 if we have invalid flags + * flags which mean something to us: + * O_RDONLY -> PRMODE level + * O_WRONLY -> EXMODE level + * + * O_NONBLOCK -> LKM_NOQUEUE + */ +static int dlmfs_decode_open_flags(int open_flags, + int *level, + int *flags) +{ + if (open_flags & (O_WRONLY|O_RDWR)) + *level = LKM_EXMODE; + else + *level = LKM_PRMODE; + + *flags = 0; + if (open_flags & O_NONBLOCK) + *flags |= LKM_NOQUEUE; + + return 0; +} + +static int dlmfs_file_open(struct inode *inode, + struct file *file) +{ + int status, level, flags; + struct dlmfs_filp_private *fp = NULL; + struct dlmfs_inode_private *ip; + + if (S_ISDIR(inode->i_mode)) + BUG(); + + mlog(0, "open called on inode %lu, flags 0x%x\n", inode->i_ino, + file->f_flags); + + status = dlmfs_decode_open_flags(file->f_flags, &level, &flags); + if (status < 0) + goto bail; + + /* We don't want to honor O_APPEND at read/write time as it + * doesn't make sense for LVB writes. */ + file->f_flags &= ~O_APPEND; + + fp = kmalloc(sizeof(*fp), GFP_KERNEL); + if (!fp) { + status = -ENOMEM; + goto bail; + } + fp->fp_lock_level = level; + + ip = DLMFS_I(inode); + + status = user_dlm_cluster_lock(&ip->ip_lockres, level, flags); + if (status < 0) { + /* this is a strange error to return here but I want + * to be able userspace to be able to distinguish a + * valid lock request from one that simply couldn't be + * granted. */ + if (flags & LKM_NOQUEUE && status == -EAGAIN) + status = -ETXTBSY; + kfree(fp); + goto bail; + } + + file->private_data = fp; +bail: + return status; +} + +static int dlmfs_file_release(struct inode *inode, + struct file *file) +{ + int level, status; + struct dlmfs_inode_private *ip = DLMFS_I(inode); + struct dlmfs_filp_private *fp = + (struct dlmfs_filp_private *) file->private_data; + + if (S_ISDIR(inode->i_mode)) + BUG(); + + mlog(0, "close called on inode %lu\n", inode->i_ino); + + status = 0; + if (fp) { + level = fp->fp_lock_level; + if (level != LKM_IVMODE) + user_dlm_cluster_unlock(&ip->ip_lockres, level); + + kfree(fp); + file->private_data = NULL; + } + + return 0; +} + +static ssize_t dlmfs_file_read(struct file *filp, + char __user *buf, + size_t count, + loff_t *ppos) +{ + int bytes_left; + ssize_t readlen; + char *lvb_buf; + struct inode *inode = filp->f_dentry->d_inode; + + mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", + inode->i_ino, count, *ppos); + + if (*ppos >= i_size_read(inode)) + return 0; + + if (!count) + return 0; + + if (!access_ok(VERIFY_WRITE, buf, count)) + return -EFAULT; + + /* don't read past the lvb */ + if ((count + *ppos) > i_size_read(inode)) + readlen = i_size_read(inode) - *ppos; + else + readlen = count - *ppos; + + lvb_buf = kmalloc(readlen, GFP_KERNEL); + if (!lvb_buf) + return -ENOMEM; + + user_dlm_read_lvb(inode, lvb_buf, readlen); + bytes_left = __copy_to_user(buf, lvb_buf, readlen); + readlen -= bytes_left; + + kfree(lvb_buf); + + *ppos = *ppos + readlen; + + mlog(0, "read %zd bytes\n", readlen); + return readlen; +} + +static ssize_t dlmfs_file_write(struct file *filp, + const char __user *buf, + size_t count, + loff_t *ppos) +{ + int bytes_left; + ssize_t writelen; + char *lvb_buf; + struct inode *inode = filp->f_dentry->d_inode; + + mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", + inode->i_ino, count, *ppos); + + if (*ppos >= i_size_read(inode)) + return -ENOSPC; + + if (!count) + return 0; + + if (!access_ok(VERIFY_READ, buf, count)) + return -EFAULT; + + /* don't write past the lvb */ + if ((count + *ppos) > i_size_read(inode)) + writelen = i_size_read(inode) - *ppos; + else + writelen = count - *ppos; + + lvb_buf = kmalloc(writelen, GFP_KERNEL); + if (!lvb_buf) + return -ENOMEM; + + bytes_left = copy_from_user(lvb_buf, buf, writelen); + writelen -= bytes_left; + if (writelen) + user_dlm_write_lvb(inode, lvb_buf, writelen); + + kfree(lvb_buf); + + *ppos = *ppos + writelen; + mlog(0, "wrote %zd bytes\n", writelen); + return writelen; +} + +static void dlmfs_init_once(void *foo, + kmem_cache_t *cachep, + unsigned long flags) +{ + struct dlmfs_inode_private *ip = + (struct dlmfs_inode_private *) foo; + + if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == + SLAB_CTOR_CONSTRUCTOR) { + ip->ip_dlm = NULL; + ip->ip_parent = NULL; + + inode_init_once(&ip->ip_vfs_inode); + } +} + +static struct inode *dlmfs_alloc_inode(struct super_block *sb) +{ + struct dlmfs_inode_private *ip; + + ip = kmem_cache_alloc(dlmfs_inode_cache, SLAB_NOFS); + if (!ip) + return NULL; + + return &ip->ip_vfs_inode; +} + +static void dlmfs_destroy_inode(struct inode *inode) +{ + kmem_cache_free(dlmfs_inode_cache, DLMFS_I(inode)); +} + +static void dlmfs_clear_inode(struct inode *inode) +{ + int status; + struct dlmfs_inode_private *ip; + + if (!inode) + return; + + mlog(0, "inode %lu\n", inode->i_ino); + + ip = DLMFS_I(inode); + + if (S_ISREG(inode->i_mode)) { + status = user_dlm_destroy_lock(&ip->ip_lockres); + if (status < 0) + mlog_errno(status); + iput(ip->ip_parent); + goto clear_fields; + } + + mlog(0, "we're a directory, ip->ip_dlm = 0x%p\n", ip->ip_dlm); + /* we must be a directory. If required, lets unregister the + * dlm context now. */ + if (ip->ip_dlm) + user_dlm_unregister_context(ip->ip_dlm); +clear_fields: + ip->ip_parent = NULL; + ip->ip_dlm = NULL; +} + +static struct backing_dev_info dlmfs_backing_dev_info = { + .ra_pages = 0, /* No readahead */ + .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, +}; + +static struct inode *dlmfs_get_root_inode(struct super_block *sb) +{ + struct inode *inode = new_inode(sb); + int mode = S_IFDIR | 0755; + struct dlmfs_inode_private *ip; + + if (inode) { + ip = DLMFS_I(inode); + + inode->i_mode = mode; + inode->i_uid = current->fsuid; + inode->i_gid = current->fsgid; + inode->i_blksize = PAGE_CACHE_SIZE; + inode->i_blocks = 0; + inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + inode->i_nlink++; + + inode->i_fop = &simple_dir_operations; + inode->i_op = &dlmfs_root_inode_operations; + } + + return inode; +} + +static struct inode *dlmfs_get_inode(struct inode *parent, + struct dentry *dentry, + int mode) +{ + struct super_block *sb = parent->i_sb; + struct inode * inode = new_inode(sb); + struct dlmfs_inode_private *ip; + + if (!inode) + return NULL; + + inode->i_mode = mode; + inode->i_uid = current->fsuid; + inode->i_gid = current->fsgid; + inode->i_blksize = PAGE_CACHE_SIZE; + inode->i_blocks = 0; + inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; + inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + + ip = DLMFS_I(inode); + ip->ip_dlm = DLMFS_I(parent)->ip_dlm; + + switch (mode & S_IFMT) { + default: + /* for now we don't support anything other than + * directories and regular files. */ + BUG(); + break; + case S_IFREG: + inode->i_op = &dlmfs_file_inode_operations; + inode->i_fop = &dlmfs_file_operations; + + i_size_write(inode, DLM_LVB_LEN); + + user_dlm_lock_res_init(&ip->ip_lockres, dentry); + + /* released at clear_inode time, this insures that we + * get to drop the dlm reference on each lock *before* + * we call the unregister code for releasing parent + * directories. */ + ip->ip_parent = igrab(parent); + BUG_ON(!ip->ip_parent); + break; + case S_IFDIR: + inode->i_op = &dlmfs_dir_inode_operations; + inode->i_fop = &simple_dir_operations; + + /* directory inodes start off with i_nlink == + * 2 (for "." entry) */ + inode->i_nlink++; + break; + } + + if (parent->i_mode & S_ISGID) { + inode->i_gid = parent->i_gid; + if (S_ISDIR(mode)) + inode->i_mode |= S_ISGID; + } + + return inode; +} + +/* + * File creation. Allocate an inode, and we're done.. + */ +/* SMP-safe */ +static int dlmfs_mkdir(struct inode * dir, + struct dentry * dentry, + int mode) +{ + int status; + struct inode *inode = NULL; + struct qstr *domain = &dentry->d_name; + struct dlmfs_inode_private *ip; + struct dlm_ctxt *dlm; + + mlog(0, "mkdir %.*s\n", domain->len, domain->name); + + /* verify that we have a proper domain */ + if (domain->len >= O2NM_MAX_NAME_LEN) { + status = -EINVAL; + mlog(ML_ERROR, "invalid domain name for directory.\n"); + goto bail; + } + + inode = dlmfs_get_inode(dir, dentry, mode | S_IFDIR); + if (!inode) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + ip = DLMFS_I(inode); + + dlm = user_dlm_register_context(domain); + if (IS_ERR(dlm)) { + status = PTR_ERR(dlm); + mlog(ML_ERROR, "Error %d could not register domain \"%.*s\"\n", + status, domain->len, domain->name); + goto bail; + } + ip->ip_dlm = dlm; + + dir->i_nlink++; + d_instantiate(dentry, inode); + dget(dentry); /* Extra count - pin the dentry in core */ + + status = 0; +bail: + if (status < 0) + iput(inode); + return status; +} + +static int dlmfs_create(struct inode *dir, + struct dentry *dentry, + int mode, + struct nameidata *nd) +{ + int status = 0; + struct inode *inode; + struct qstr *name = &dentry->d_name; + + mlog(0, "create %.*s\n", name->len, name->name); + + /* verify name is valid and doesn't contain any dlm reserved + * characters */ + if (name->len >= USER_DLM_LOCK_ID_MAX_LEN || + name->name[0] == '$') { + status = -EINVAL; + mlog(ML_ERROR, "invalid lock name, %.*s\n", name->len, + name->name); + goto bail; + } + + inode = dlmfs_get_inode(dir, dentry, mode | S_IFREG); + if (!inode) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + d_instantiate(dentry, inode); + dget(dentry); /* Extra count - pin the dentry in core */ +bail: + return status; +} + +static int dlmfs_unlink(struct inode *dir, + struct dentry *dentry) +{ + int status; + struct inode *inode = dentry->d_inode; + + mlog(0, "unlink inode %lu\n", inode->i_ino); + + /* if there are no current holders, or none that are waiting + * to acquire a lock, this basically destroys our lockres. */ + status = user_dlm_destroy_lock(&DLMFS_I(inode)->ip_lockres); + if (status < 0) { + mlog(ML_ERROR, "unlink %.*s, error %d from destroy\n", + dentry->d_name.len, dentry->d_name.name, status); + goto bail; + } + status = simple_unlink(dir, dentry); +bail: + return status; +} + +static int dlmfs_fill_super(struct super_block * sb, + void * data, + int silent) +{ + struct inode * inode; + struct dentry * root; + + sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_blocksize = PAGE_CACHE_SIZE; + sb->s_blocksize_bits = PAGE_CACHE_SHIFT; + sb->s_magic = DLMFS_MAGIC; + sb->s_op = &dlmfs_ops; + inode = dlmfs_get_root_inode(sb); + if (!inode) + return -ENOMEM; + + root = d_alloc_root(inode); + if (!root) { + iput(inode); + return -ENOMEM; + } + sb->s_root = root; + return 0; +} + +static struct file_operations dlmfs_file_operations = { + .open = dlmfs_file_open, + .release = dlmfs_file_release, + .read = dlmfs_file_read, + .write = dlmfs_file_write, +}; + +static struct inode_operations dlmfs_dir_inode_operations = { + .create = dlmfs_create, + .lookup = simple_lookup, + .unlink = dlmfs_unlink, +}; + +/* this way we can restrict mkdir to only the toplevel of the fs. */ +static struct inode_operations dlmfs_root_inode_operations = { + .lookup = simple_lookup, + .mkdir = dlmfs_mkdir, + .rmdir = simple_rmdir, +}; + +static struct super_operations dlmfs_ops = { + .statfs = simple_statfs, + .alloc_inode = dlmfs_alloc_inode, + .destroy_inode = dlmfs_destroy_inode, + .clear_inode = dlmfs_clear_inode, + .drop_inode = generic_delete_inode, +}; + +static struct inode_operations dlmfs_file_inode_operations = { + .getattr = simple_getattr, +}; + +static struct super_block *dlmfs_get_sb(struct file_system_type *fs_type, + int flags, const char *dev_name, void *data) +{ + return get_sb_nodev(fs_type, flags, data, dlmfs_fill_super); +} + +static struct file_system_type dlmfs_fs_type = { + .owner = THIS_MODULE, + .name = "ocfs2_dlmfs", + .get_sb = dlmfs_get_sb, + .kill_sb = kill_litter_super, +}; + +static int __init init_dlmfs_fs(void) +{ + int status; + int cleanup_inode = 0, cleanup_worker = 0; + + dlmfs_print_version(); + + dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache", + sizeof(struct dlmfs_inode_private), + 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, + dlmfs_init_once, NULL); + if (!dlmfs_inode_cache) + return -ENOMEM; + cleanup_inode = 1; + + user_dlm_worker = create_singlethread_workqueue("user_dlm"); + if (!user_dlm_worker) { + status = -ENOMEM; + goto bail; + } + cleanup_worker = 1; + + status = register_filesystem(&dlmfs_fs_type); +bail: + if (status) { + if (cleanup_inode) + kmem_cache_destroy(dlmfs_inode_cache); + if (cleanup_worker) + destroy_workqueue(user_dlm_worker); + } else + printk("OCFS2 User DLM kernel interface loaded\n"); + return status; +} + +static void __exit exit_dlmfs_fs(void) +{ + unregister_filesystem(&dlmfs_fs_type); + + flush_workqueue(user_dlm_worker); + destroy_workqueue(user_dlm_worker); + + if (kmem_cache_destroy(dlmfs_inode_cache)) + printk(KERN_INFO "dlmfs_inode_cache: not all structures " + "were freed\n"); +} + +MODULE_AUTHOR("Oracle"); +MODULE_LICENSE("GPL"); + +module_init(init_dlmfs_fs) +module_exit(exit_dlmfs_fs) diff --git a/fs/ocfs2/dlm/dlmfsver.c b/fs/ocfs2/dlm/dlmfsver.c new file mode 100644 index 0000000..d2be3ad --- /dev/null +++ b/fs/ocfs2/dlm/dlmfsver.c @@ -0,0 +1,42 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmfsver.c + * + * version string + * + * Copyright (C) 2002, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include + +#include "dlmfsver.h" + +#define DLM_BUILD_VERSION "1.3.3" + +#define VERSION_STR "OCFS2 DLMFS " DLM_BUILD_VERSION + +void dlmfs_print_version(void) +{ + printk(KERN_INFO "%s\n", VERSION_STR); +} + +MODULE_DESCRIPTION(VERSION_STR); + +MODULE_VERSION(DLM_BUILD_VERSION); diff --git a/fs/ocfs2/dlm/dlmfsver.h b/fs/ocfs2/dlm/dlmfsver.h new file mode 100644 index 0000000..f35eadb --- /dev/null +++ b/fs/ocfs2/dlm/dlmfsver.h @@ -0,0 +1,31 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmver.h + * + * Function prototypes + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef DLMFS_VER_H +#define DLMFS_VER_H + +void dlmfs_print_version(void); + +#endif /* DLMFS_VER_H */ diff --git a/fs/ocfs2/dlm/userdlm.c b/fs/ocfs2/dlm/userdlm.c new file mode 100644 index 0000000..e1fdd28 --- /dev/null +++ b/fs/ocfs2/dlm/userdlm.c @@ -0,0 +1,658 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * userdlm.c + * + * Code which implements the kernel side of a minimal userspace + * interface to our DLM. + * + * Many of the functions here are pared down versions of dlmglue.c + * functions. + * + * Copyright (C) 2003, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include + +#include +#include +#include +#include + + +#include "cluster/nodemanager.h" +#include "cluster/heartbeat.h" +#include "cluster/tcp.h" + +#include "dlmapi.h" + +#include "userdlm.h" + +#define MLOG_MASK_PREFIX ML_DLMFS +#include "cluster/masklog.h" + +static inline int user_check_wait_flag(struct user_lock_res *lockres, + int flag) +{ + int ret; + + spin_lock(&lockres->l_lock); + ret = lockres->l_flags & flag; + spin_unlock(&lockres->l_lock); + + return ret; +} + +static inline void user_wait_on_busy_lock(struct user_lock_res *lockres) + +{ + wait_event(lockres->l_event, + !user_check_wait_flag(lockres, USER_LOCK_BUSY)); +} + +static inline void user_wait_on_blocked_lock(struct user_lock_res *lockres) + +{ + wait_event(lockres->l_event, + !user_check_wait_flag(lockres, USER_LOCK_BLOCKED)); +} + +/* I heart container_of... */ +static inline struct dlm_ctxt * +dlm_ctxt_from_user_lockres(struct user_lock_res *lockres) +{ + struct dlmfs_inode_private *ip; + + ip = container_of(lockres, + struct dlmfs_inode_private, + ip_lockres); + return ip->ip_dlm; +} + +static struct inode * +user_dlm_inode_from_user_lockres(struct user_lock_res *lockres) +{ + struct dlmfs_inode_private *ip; + + ip = container_of(lockres, + struct dlmfs_inode_private, + ip_lockres); + return &ip->ip_vfs_inode; +} + +static inline void user_recover_from_dlm_error(struct user_lock_res *lockres) +{ + spin_lock(&lockres->l_lock); + lockres->l_flags &= ~USER_LOCK_BUSY; + spin_unlock(&lockres->l_lock); +} + +#define user_log_dlm_error(_func, _stat, _lockres) do { \ + mlog(ML_ERROR, "Dlm error \"%s\" while calling %s on " \ + "resource %s: %s\n", dlm_errname(_stat), _func, \ + _lockres->l_name, dlm_errmsg(_stat)); \ +} while (0) + +/* WARNING: This function lives in a world where the only three lock + * levels are EX, PR, and NL. It *will* have to be adjusted when more + * lock types are added. */ +static inline int user_highest_compat_lock_level(int level) +{ + int new_level = LKM_EXMODE; + + if (level == LKM_EXMODE) + new_level = LKM_NLMODE; + else if (level == LKM_PRMODE) + new_level = LKM_PRMODE; + return new_level; +} + +static void user_ast(void *opaque) +{ + struct user_lock_res *lockres = opaque; + struct dlm_lockstatus *lksb; + + mlog(0, "AST fired for lockres %s\n", lockres->l_name); + + spin_lock(&lockres->l_lock); + + lksb = &(lockres->l_lksb); + if (lksb->status != DLM_NORMAL) { + mlog(ML_ERROR, "lksb status value of %u on lockres %s\n", + lksb->status, lockres->l_name); + spin_unlock(&lockres->l_lock); + return; + } + + /* we're downconverting. */ + if (lockres->l_requested < lockres->l_level) { + if (lockres->l_requested <= + user_highest_compat_lock_level(lockres->l_blocking)) { + lockres->l_blocking = LKM_NLMODE; + lockres->l_flags &= ~USER_LOCK_BLOCKED; + } + } + + lockres->l_level = lockres->l_requested; + lockres->l_requested = LKM_IVMODE; + lockres->l_flags |= USER_LOCK_ATTACHED; + lockres->l_flags &= ~USER_LOCK_BUSY; + + spin_unlock(&lockres->l_lock); + + wake_up(&lockres->l_event); +} + +static inline void user_dlm_grab_inode_ref(struct user_lock_res *lockres) +{ + struct inode *inode; + inode = user_dlm_inode_from_user_lockres(lockres); + if (!igrab(inode)) + BUG(); +} + +static void user_dlm_unblock_lock(void *opaque); + +static void __user_dlm_queue_lockres(struct user_lock_res *lockres) +{ + if (!(lockres->l_flags & USER_LOCK_QUEUED)) { + user_dlm_grab_inode_ref(lockres); + + INIT_WORK(&lockres->l_work, user_dlm_unblock_lock, + lockres); + + queue_work(user_dlm_worker, &lockres->l_work); + lockres->l_flags |= USER_LOCK_QUEUED; + } +} + +static void __user_dlm_cond_queue_lockres(struct user_lock_res *lockres) +{ + int queue = 0; + + if (!(lockres->l_flags & USER_LOCK_BLOCKED)) + return; + + switch (lockres->l_blocking) { + case LKM_EXMODE: + if (!lockres->l_ex_holders && !lockres->l_ro_holders) + queue = 1; + break; + case LKM_PRMODE: + if (!lockres->l_ex_holders) + queue = 1; + break; + default: + BUG(); + } + + if (queue) + __user_dlm_queue_lockres(lockres); +} + +static void user_bast(void *opaque, int level) +{ + struct user_lock_res *lockres = opaque; + + mlog(0, "Blocking AST fired for lockres %s. Blocking level %d\n", + lockres->l_name, level); + + spin_lock(&lockres->l_lock); + lockres->l_flags |= USER_LOCK_BLOCKED; + if (level > lockres->l_blocking) + lockres->l_blocking = level; + + __user_dlm_queue_lockres(lockres); + spin_unlock(&lockres->l_lock); + + wake_up(&lockres->l_event); +} + +static void user_unlock_ast(void *opaque, enum dlm_status status) +{ + struct user_lock_res *lockres = opaque; + + mlog(0, "UNLOCK AST called on lock %s\n", lockres->l_name); + + if (status != DLM_NORMAL) + mlog(ML_ERROR, "Dlm returns status %d\n", status); + + spin_lock(&lockres->l_lock); + if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) + lockres->l_level = LKM_IVMODE; + else { + lockres->l_requested = LKM_IVMODE; /* cancel an + * upconvert + * request. */ + lockres->l_flags &= ~USER_LOCK_IN_CANCEL; + /* we want the unblock thread to look at it again + * now. */ + __user_dlm_queue_lockres(lockres); + } + + lockres->l_flags &= ~USER_LOCK_BUSY; + spin_unlock(&lockres->l_lock); + + wake_up(&lockres->l_event); +} + +static inline void user_dlm_drop_inode_ref(struct user_lock_res *lockres) +{ + struct inode *inode; + inode = user_dlm_inode_from_user_lockres(lockres); + iput(inode); +} + +static void user_dlm_unblock_lock(void *opaque) +{ + int new_level, status; + struct user_lock_res *lockres = (struct user_lock_res *) opaque; + struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); + + mlog(0, "processing lockres %s\n", lockres->l_name); + + spin_lock(&lockres->l_lock); + + BUG_ON(!(lockres->l_flags & USER_LOCK_BLOCKED)); + BUG_ON(!(lockres->l_flags & USER_LOCK_QUEUED)); + + /* notice that we don't clear USER_LOCK_BLOCKED here. That's + * for user_ast to do. */ + lockres->l_flags &= ~USER_LOCK_QUEUED; + + if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) { + mlog(0, "lock is in teardown so we do nothing\n"); + spin_unlock(&lockres->l_lock); + goto drop_ref; + } + + if (lockres->l_flags & USER_LOCK_BUSY) { + mlog(0, "BUSY flag detected...\n"); + if (lockres->l_flags & USER_LOCK_IN_CANCEL) { + spin_unlock(&lockres->l_lock); + goto drop_ref; + } + + lockres->l_flags |= USER_LOCK_IN_CANCEL; + spin_unlock(&lockres->l_lock); + + status = dlmunlock(dlm, + &lockres->l_lksb, + LKM_CANCEL, + user_unlock_ast, + lockres); + if (status == DLM_CANCELGRANT) { + /* If we got this, then the ast was fired + * before we could cancel. We cleanup our + * state, and restart the function. */ + spin_lock(&lockres->l_lock); + lockres->l_flags &= ~USER_LOCK_IN_CANCEL; + spin_unlock(&lockres->l_lock); + } else if (status != DLM_NORMAL) + user_log_dlm_error("dlmunlock", status, lockres); + goto drop_ref; + } + + /* If there are still incompat holders, we can exit safely + * without worrying about re-queueing this lock as that will + * happen on the last call to user_cluster_unlock. */ + if ((lockres->l_blocking == LKM_EXMODE) + && (lockres->l_ex_holders || lockres->l_ro_holders)) { + spin_unlock(&lockres->l_lock); + mlog(0, "can't downconvert for ex: ro = %u, ex = %u\n", + lockres->l_ro_holders, lockres->l_ex_holders); + goto drop_ref; + } + + if ((lockres->l_blocking == LKM_PRMODE) + && lockres->l_ex_holders) { + spin_unlock(&lockres->l_lock); + mlog(0, "can't downconvert for pr: ex = %u\n", + lockres->l_ex_holders); + goto drop_ref; + } + + /* yay, we can downconvert now. */ + new_level = user_highest_compat_lock_level(lockres->l_blocking); + lockres->l_requested = new_level; + lockres->l_flags |= USER_LOCK_BUSY; + mlog(0, "Downconvert lock from %d to %d\n", + lockres->l_level, new_level); + spin_unlock(&lockres->l_lock); + + /* need lock downconvert request now... */ + status = dlmlock(dlm, + new_level, + &lockres->l_lksb, + LKM_CONVERT|LKM_VALBLK, + lockres->l_name, + user_ast, + lockres, + user_bast); + if (status != DLM_NORMAL) { + user_log_dlm_error("dlmlock", status, lockres); + user_recover_from_dlm_error(lockres); + } + +drop_ref: + user_dlm_drop_inode_ref(lockres); +} + +static inline void user_dlm_inc_holders(struct user_lock_res *lockres, + int level) +{ + switch(level) { + case LKM_EXMODE: + lockres->l_ex_holders++; + break; + case LKM_PRMODE: + lockres->l_ro_holders++; + break; + default: + BUG(); + } +} + +/* predict what lock level we'll be dropping down to on behalf + * of another node, and return true if the currently wanted + * level will be compatible with it. */ +static inline int +user_may_continue_on_blocked_lock(struct user_lock_res *lockres, + int wanted) +{ + BUG_ON(!(lockres->l_flags & USER_LOCK_BLOCKED)); + + return wanted <= user_highest_compat_lock_level(lockres->l_blocking); +} + +int user_dlm_cluster_lock(struct user_lock_res *lockres, + int level, + int lkm_flags) +{ + int status, local_flags; + struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); + + if (level != LKM_EXMODE && + level != LKM_PRMODE) { + mlog(ML_ERROR, "lockres %s: invalid request!\n", + lockres->l_name); + status = -EINVAL; + goto bail; + } + + mlog(0, "lockres %s: asking for %s lock, passed flags = 0x%x\n", + lockres->l_name, + (level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE", + lkm_flags); + +again: + if (signal_pending(current)) { + status = -ERESTARTSYS; + goto bail; + } + + spin_lock(&lockres->l_lock); + + /* We only compare against the currently granted level + * here. If the lock is blocked waiting on a downconvert, + * we'll get caught below. */ + if ((lockres->l_flags & USER_LOCK_BUSY) && + (level > lockres->l_level)) { + /* is someone sitting in dlm_lock? If so, wait on + * them. */ + spin_unlock(&lockres->l_lock); + + user_wait_on_busy_lock(lockres); + goto again; + } + + if ((lockres->l_flags & USER_LOCK_BLOCKED) && + (!user_may_continue_on_blocked_lock(lockres, level))) { + /* is the lock is currently blocked on behalf of + * another node */ + spin_unlock(&lockres->l_lock); + + user_wait_on_blocked_lock(lockres); + goto again; + } + + if (level > lockres->l_level) { + local_flags = lkm_flags | LKM_VALBLK; + if (lockres->l_level != LKM_IVMODE) + local_flags |= LKM_CONVERT; + + lockres->l_requested = level; + lockres->l_flags |= USER_LOCK_BUSY; + spin_unlock(&lockres->l_lock); + + BUG_ON(level == LKM_IVMODE); + BUG_ON(level == LKM_NLMODE); + + mlog(0, "lock %s, get lock from %d to level = %d\n", + lockres->l_name, lockres->l_level, level); + + /* call dlm_lock to upgrade lock now */ + status = dlmlock(dlm, + level, + &lockres->l_lksb, + local_flags, + lockres->l_name, + user_ast, + lockres, + user_bast); + if (status != DLM_NORMAL) { + if ((lkm_flags & LKM_NOQUEUE) && + (status == DLM_NOTQUEUED)) + status = -EAGAIN; + else { + user_log_dlm_error("dlmlock", status, lockres); + status = -EINVAL; + } + user_recover_from_dlm_error(lockres); + goto bail; + } + + mlog(0, "lock %s, successfull return from dlmlock\n", + lockres->l_name); + + user_wait_on_busy_lock(lockres); + goto again; + } + + user_dlm_inc_holders(lockres, level); + spin_unlock(&lockres->l_lock); + + mlog(0, "lockres %s: Got %s lock!\n", lockres->l_name, + (level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE"); + + status = 0; +bail: + return status; +} + +static inline void user_dlm_dec_holders(struct user_lock_res *lockres, + int level) +{ + switch(level) { + case LKM_EXMODE: + BUG_ON(!lockres->l_ex_holders); + lockres->l_ex_holders--; + break; + case LKM_PRMODE: + BUG_ON(!lockres->l_ro_holders); + lockres->l_ro_holders--; + break; + default: + BUG(); + } +} + +void user_dlm_cluster_unlock(struct user_lock_res *lockres, + int level) +{ + if (level != LKM_EXMODE && + level != LKM_PRMODE) { + mlog(ML_ERROR, "lockres %s: invalid request!\n", lockres->l_name); + return; + } + + mlog(0, "lockres %s: dropping %s lock\n", lockres->l_name, + (level == LKM_EXMODE) ? "LKM_EXMODE" : "LKM_PRMODE"); + + spin_lock(&lockres->l_lock); + user_dlm_dec_holders(lockres, level); + __user_dlm_cond_queue_lockres(lockres); + spin_unlock(&lockres->l_lock); +} + +void user_dlm_write_lvb(struct inode *inode, + const char *val, + unsigned int len) +{ + struct user_lock_res *lockres = &DLMFS_I(inode)->ip_lockres; + char *lvb = lockres->l_lksb.lvb; + + BUG_ON(len > DLM_LVB_LEN); + + spin_lock(&lockres->l_lock); + + BUG_ON(lockres->l_level < LKM_EXMODE); + memcpy(lvb, val, len); + + spin_unlock(&lockres->l_lock); +} + +void user_dlm_read_lvb(struct inode *inode, + char *val, + unsigned int len) +{ + struct user_lock_res *lockres = &DLMFS_I(inode)->ip_lockres; + char *lvb = lockres->l_lksb.lvb; + + BUG_ON(len > DLM_LVB_LEN); + + spin_lock(&lockres->l_lock); + + BUG_ON(lockres->l_level < LKM_PRMODE); + memcpy(val, lvb, len); + + spin_unlock(&lockres->l_lock); +} + +void user_dlm_lock_res_init(struct user_lock_res *lockres, + struct dentry *dentry) +{ + memset(lockres, 0, sizeof(*lockres)); + + spin_lock_init(&lockres->l_lock); + init_waitqueue_head(&lockres->l_event); + lockres->l_level = LKM_IVMODE; + lockres->l_requested = LKM_IVMODE; + lockres->l_blocking = LKM_IVMODE; + + /* should have been checked before getting here. */ + BUG_ON(dentry->d_name.len >= USER_DLM_LOCK_ID_MAX_LEN); + + memcpy(lockres->l_name, + dentry->d_name.name, + dentry->d_name.len); +} + +int user_dlm_destroy_lock(struct user_lock_res *lockres) +{ + int status = -EBUSY; + struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); + + mlog(0, "asked to destroy %s\n", lockres->l_name); + + spin_lock(&lockres->l_lock); + while (lockres->l_flags & USER_LOCK_BUSY) { + spin_unlock(&lockres->l_lock); + + mlog(0, "lock %s is busy\n", lockres->l_name); + + user_wait_on_busy_lock(lockres); + + spin_lock(&lockres->l_lock); + } + + if (lockres->l_ro_holders || lockres->l_ex_holders) { + spin_unlock(&lockres->l_lock); + mlog(0, "lock %s has holders\n", lockres->l_name); + goto bail; + } + + status = 0; + if (!(lockres->l_flags & USER_LOCK_ATTACHED)) { + spin_unlock(&lockres->l_lock); + mlog(0, "lock %s is not attached\n", lockres->l_name); + goto bail; + } + + lockres->l_flags &= ~USER_LOCK_ATTACHED; + lockres->l_flags |= USER_LOCK_BUSY; + lockres->l_flags |= USER_LOCK_IN_TEARDOWN; + spin_unlock(&lockres->l_lock); + + mlog(0, "unlocking lockres %s\n", lockres->l_name); + status = dlmunlock(dlm, + &lockres->l_lksb, + LKM_VALBLK, + user_unlock_ast, + lockres); + if (status != DLM_NORMAL) { + user_log_dlm_error("dlmunlock", status, lockres); + status = -EINVAL; + goto bail; + } + + user_wait_on_busy_lock(lockres); + + status = 0; +bail: + return status; +} + +struct dlm_ctxt *user_dlm_register_context(struct qstr *name) +{ + struct dlm_ctxt *dlm; + u32 dlm_key; + char *domain; + + domain = kmalloc(name->len + 1, GFP_KERNEL); + if (!domain) { + mlog_errno(-ENOMEM); + return ERR_PTR(-ENOMEM); + } + + dlm_key = crc32_le(0, name->name, name->len); + + snprintf(domain, name->len + 1, "%.*s", name->len, name->name); + + dlm = dlm_register_domain(domain, dlm_key); + if (IS_ERR(dlm)) + mlog_errno(PTR_ERR(dlm)); + + kfree(domain); + return dlm; +} + +void user_dlm_unregister_context(struct dlm_ctxt *dlm) +{ + dlm_unregister_domain(dlm); +} diff --git a/fs/ocfs2/dlm/userdlm.h b/fs/ocfs2/dlm/userdlm.h new file mode 100644 index 0000000..04178bc --- /dev/null +++ b/fs/ocfs2/dlm/userdlm.h @@ -0,0 +1,111 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * userdlm.h + * + * Userspace dlm defines + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + + +#ifndef USERDLM_H +#define USERDLM_H + +#include +#include +#include +#include + +/* user_lock_res->l_flags flags. */ +#define USER_LOCK_ATTACHED (0x00000001) /* have we initialized + * the lvb */ +#define USER_LOCK_BUSY (0x00000002) /* we are currently in + * dlm_lock */ +#define USER_LOCK_BLOCKED (0x00000004) /* blocked waiting to + * downconvert*/ +#define USER_LOCK_IN_TEARDOWN (0x00000008) /* we're currently + * destroying this + * lock. */ +#define USER_LOCK_QUEUED (0x00000010) /* lock is on the + * workqueue */ +#define USER_LOCK_IN_CANCEL (0x00000020) + +struct user_lock_res { + spinlock_t l_lock; + + int l_flags; + +#define USER_DLM_LOCK_ID_MAX_LEN 32 + char l_name[USER_DLM_LOCK_ID_MAX_LEN]; + int l_level; + unsigned int l_ro_holders; + unsigned int l_ex_holders; + struct dlm_lockstatus l_lksb; + + int l_requested; + int l_blocking; + + wait_queue_head_t l_event; + + struct work_struct l_work; +}; + +extern struct workqueue_struct *user_dlm_worker; + +void user_dlm_lock_res_init(struct user_lock_res *lockres, + struct dentry *dentry); +int user_dlm_destroy_lock(struct user_lock_res *lockres); +int user_dlm_cluster_lock(struct user_lock_res *lockres, + int level, + int lkm_flags); +void user_dlm_cluster_unlock(struct user_lock_res *lockres, + int level); +void user_dlm_write_lvb(struct inode *inode, + const char *val, + unsigned int len); +void user_dlm_read_lvb(struct inode *inode, + char *val, + unsigned int len); +struct dlm_ctxt *user_dlm_register_context(struct qstr *name); +void user_dlm_unregister_context(struct dlm_ctxt *dlm); + +struct dlmfs_inode_private { + struct dlm_ctxt *ip_dlm; + + struct user_lock_res ip_lockres; /* unused for directories. */ + struct inode *ip_parent; + + struct inode ip_vfs_inode; +}; + +static inline struct dlmfs_inode_private * +DLMFS_I(struct inode *inode) +{ + return container_of(inode, + struct dlmfs_inode_private, + ip_vfs_inode); +} + +struct dlmfs_filp_private { + int fp_lock_level; +}; + +#define DLMFS_MAGIC 0x76a9f425 + +#endif /* USERDLM_H */ -- cgit v1.1 From ccd979bdbce9fba8412beb3f1de68a9d0171b12c Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 15 Dec 2005 14:31:24 -0800 Subject: [PATCH] OCFS2: The Second Oracle Cluster Filesystem The OCFS2 file system module. Signed-off-by: Mark Fasheh Signed-off-by: Kurt Hackel --- Documentation/filesystems/00-INDEX | 2 + Documentation/filesystems/ocfs2.txt | 55 + MAINTAINERS | 9 + fs/ocfs2/Makefile | 33 + fs/ocfs2/alloc.c | 2040 ++++++++++++++++++++++++ fs/ocfs2/alloc.h | 82 + fs/ocfs2/aops.c | 643 ++++++++ fs/ocfs2/aops.h | 41 + fs/ocfs2/buffer_head_io.c | 232 +++ fs/ocfs2/buffer_head_io.h | 73 + fs/ocfs2/dcache.c | 91 ++ fs/ocfs2/dcache.h | 31 + fs/ocfs2/dir.c | 618 ++++++++ fs/ocfs2/dir.h | 54 + fs/ocfs2/dlmglue.c | 2904 +++++++++++++++++++++++++++++++++++ fs/ocfs2/dlmglue.h | 111 ++ fs/ocfs2/endian.h | 45 + fs/ocfs2/export.c | 248 +++ fs/ocfs2/export.h | 31 + fs/ocfs2/extent_map.c | 994 ++++++++++++ fs/ocfs2/extent_map.h | 46 + fs/ocfs2/file.c | 1237 +++++++++++++++ fs/ocfs2/file.h | 57 + fs/ocfs2/heartbeat.c | 378 +++++ fs/ocfs2/heartbeat.h | 67 + fs/ocfs2/inode.c | 1140 ++++++++++++++ fs/ocfs2/inode.h | 145 ++ fs/ocfs2/journal.c | 1652 ++++++++++++++++++++ fs/ocfs2/journal.h | 457 ++++++ fs/ocfs2/localalloc.c | 983 ++++++++++++ fs/ocfs2/localalloc.h | 56 + fs/ocfs2/mmap.c | 102 ++ fs/ocfs2/mmap.h | 6 + fs/ocfs2/namei.c | 2264 +++++++++++++++++++++++++++ fs/ocfs2/namei.h | 58 + fs/ocfs2/ocfs1_fs_compat.h | 109 ++ fs/ocfs2/ocfs2.h | 464 ++++++ fs/ocfs2/ocfs2_fs.h | 638 ++++++++ fs/ocfs2/ocfs2_lockid.h | 73 + fs/ocfs2/slot_map.c | 303 ++++ fs/ocfs2/slot_map.h | 66 + fs/ocfs2/suballoc.c | 1651 ++++++++++++++++++++ fs/ocfs2/suballoc.h | 132 ++ fs/ocfs2/super.c | 1733 +++++++++++++++++++++ fs/ocfs2/super.h | 44 + fs/ocfs2/symlink.c | 180 +++ fs/ocfs2/symlink.h | 42 + fs/ocfs2/sysfile.c | 131 ++ fs/ocfs2/sysfile.h | 33 + fs/ocfs2/uptodate.c | 544 +++++++ fs/ocfs2/uptodate.h | 44 + fs/ocfs2/ver.c | 43 + fs/ocfs2/ver.h | 31 + fs/ocfs2/vote.c | 1202 +++++++++++++++ fs/ocfs2/vote.h | 56 + 55 files changed, 24504 insertions(+) create mode 100644 Documentation/filesystems/ocfs2.txt create mode 100644 fs/ocfs2/Makefile create mode 100644 fs/ocfs2/alloc.c create mode 100644 fs/ocfs2/alloc.h create mode 100644 fs/ocfs2/aops.c create mode 100644 fs/ocfs2/aops.h create mode 100644 fs/ocfs2/buffer_head_io.c create mode 100644 fs/ocfs2/buffer_head_io.h create mode 100644 fs/ocfs2/dcache.c create mode 100644 fs/ocfs2/dcache.h create mode 100644 fs/ocfs2/dir.c create mode 100644 fs/ocfs2/dir.h create mode 100644 fs/ocfs2/dlmglue.c create mode 100644 fs/ocfs2/dlmglue.h create mode 100644 fs/ocfs2/endian.h create mode 100644 fs/ocfs2/export.c create mode 100644 fs/ocfs2/export.h create mode 100644 fs/ocfs2/extent_map.c create mode 100644 fs/ocfs2/extent_map.h create mode 100644 fs/ocfs2/file.c create mode 100644 fs/ocfs2/file.h create mode 100644 fs/ocfs2/heartbeat.c create mode 100644 fs/ocfs2/heartbeat.h create mode 100644 fs/ocfs2/inode.c create mode 100644 fs/ocfs2/inode.h create mode 100644 fs/ocfs2/journal.c create mode 100644 fs/ocfs2/journal.h create mode 100644 fs/ocfs2/localalloc.c create mode 100644 fs/ocfs2/localalloc.h create mode 100644 fs/ocfs2/mmap.c create mode 100644 fs/ocfs2/mmap.h create mode 100644 fs/ocfs2/namei.c create mode 100644 fs/ocfs2/namei.h create mode 100644 fs/ocfs2/ocfs1_fs_compat.h create mode 100644 fs/ocfs2/ocfs2.h create mode 100644 fs/ocfs2/ocfs2_fs.h create mode 100644 fs/ocfs2/ocfs2_lockid.h create mode 100644 fs/ocfs2/slot_map.c create mode 100644 fs/ocfs2/slot_map.h create mode 100644 fs/ocfs2/suballoc.c create mode 100644 fs/ocfs2/suballoc.h create mode 100644 fs/ocfs2/super.c create mode 100644 fs/ocfs2/super.h create mode 100644 fs/ocfs2/symlink.c create mode 100644 fs/ocfs2/symlink.h create mode 100644 fs/ocfs2/sysfile.c create mode 100644 fs/ocfs2/sysfile.h create mode 100644 fs/ocfs2/uptodate.c create mode 100644 fs/ocfs2/uptodate.h create mode 100644 fs/ocfs2/ver.c create mode 100644 fs/ocfs2/ver.h create mode 100644 fs/ocfs2/vote.c create mode 100644 fs/ocfs2/vote.h diff --git a/Documentation/filesystems/00-INDEX b/Documentation/filesystems/00-INDEX index d9b0a06..2580ada 100644 --- a/Documentation/filesystems/00-INDEX +++ b/Documentation/filesystems/00-INDEX @@ -36,6 +36,8 @@ ntfs.txt - info and mount options for the NTFS filesystem (Windows NT). proc.txt - info on Linux's /proc filesystem. +ocfs2.txt + - info and mount options for the OCFS2 clustered filesystem. romfs.txt - Description of the ROMFS filesystem. smbfs.txt diff --git a/Documentation/filesystems/ocfs2.txt b/Documentation/filesystems/ocfs2.txt new file mode 100644 index 0000000..f2595ca --- /dev/null +++ b/Documentation/filesystems/ocfs2.txt @@ -0,0 +1,55 @@ +OCFS2 filesystem +================== +OCFS2 is a general purpose extent based shared disk cluster file +system with many similarities to ext3. It supports 64 bit inode +numbers, and has automatically extending metadata groups which may +also make it attractive for non-clustered use. + +You'll want to install the ocfs2-tools package in order to at least +get "mount.ocfs2" and "ocfs2_hb_ctl". + +Project web page: http://oss.oracle.com/projects/ocfs2 +Tools web page: http://oss.oracle.com/projects/ocfs2-tools +OCFS2 mailing lists: http://oss.oracle.com/projects/ocfs2/mailman/ + +All code copyright 2005 Oracle except when otherwise noted. + +CREDITS: +Lots of code taken from ext3 and other projects. + +Authors in alphabetical order: +Joel Becker +Zach Brown +Mark Fasheh +Kurt Hackel +Sunil Mushran +Manish Singh + +Caveats +======= +Features which OCFS2 does not support yet: + - sparse files + - extended attributes + - shared writeable mmap + - loopback is supported, but data written will not + be cluster coherent. + - quotas + - cluster aware flock + - Directory change notification (F_NOTIFY) + - Distributed Caching (F_SETLEASE/F_GETLEASE/break_lease) + - POSIX ACLs + - readpages / writepages (not user visible) + +Mount options +============= + +OCFS2 supports the following mount options: +(*) == default + +barrier=1 This enables/disables barriers. barrier=0 disables it, + barrier=1 enables it. +errors=remount-ro(*) Remount the filesystem read-only on an error. +errors=panic Panic and halt the machine if an error occurs. +intr (*) Allow signals to interrupt cluster operations. +nointr Do not allow signals to interrupt cluster + operations. diff --git a/MAINTAINERS b/MAINTAINERS index 86ee06f..1588830 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1905,6 +1905,15 @@ M: ajoshi@shell.unixbox.com L: linux-nvidia@lists.surfsouth.com S: Maintained +ORACLE CLUSTER FILESYSTEM 2 (OCFS2) +P: Mark Fasheh +M: mark.fasheh@oracle.com +P: Kurt Hackel +M: kurt.hackel@oracle.com +L: ocfs2-devel@oss.oracle.com +W: http://oss.oracle.com/projects/ocfs2/ +S: Supported + OLYMPIC NETWORK DRIVER P: Peter De Shrijver M: p2@ace.ulyssis.student.kuleuven.ac.be diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile new file mode 100644 index 0000000..7d3be84 --- /dev/null +++ b/fs/ocfs2/Makefile @@ -0,0 +1,33 @@ +EXTRA_CFLAGS += -Ifs/ocfs2 + +EXTRA_CFLAGS += -DCATCH_BH_JBD_RACES + +obj-$(CONFIG_OCFS2_FS) += ocfs2.o + +ocfs2-objs := \ + alloc.o \ + aops.o \ + buffer_head_io.o \ + dcache.o \ + dir.o \ + dlmglue.o \ + export.o \ + extent_map.o \ + file.o \ + heartbeat.o \ + inode.o \ + journal.o \ + localalloc.o \ + mmap.o \ + namei.o \ + slot_map.o \ + suballoc.o \ + super.o \ + symlink.o \ + sysfile.o \ + uptodate.o \ + ver.o \ + vote.o + +obj-$(CONFIG_OCFS2_FS) += cluster/ +obj-$(CONFIG_OCFS2_FS) += dlm/ diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c new file mode 100644 index 0000000..465f797 --- /dev/null +++ b/fs/ocfs2/alloc.c @@ -0,0 +1,2040 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * alloc.c + * + * Extent allocs and frees + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_DISK_ALLOC +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "inode.h" +#include "journal.h" +#include "localalloc.h" +#include "suballoc.h" +#include "sysfile.h" +#include "file.h" +#include "super.h" +#include "uptodate.h" + +#include "buffer_head_io.h" + +static int ocfs2_extent_contig(struct inode *inode, + struct ocfs2_extent_rec *ext, + u64 blkno); + +static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + int wanted, + struct ocfs2_alloc_context *meta_ac, + struct buffer_head *bhs[]); + +static int ocfs2_add_branch(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + struct buffer_head *eb_bh, + struct buffer_head *last_eb_bh, + struct ocfs2_alloc_context *meta_ac); + +static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + struct ocfs2_alloc_context *meta_ac, + struct buffer_head **ret_new_eb_bh); + +static int ocfs2_do_insert_extent(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + u64 blkno, + u32 new_clusters); + +static int ocfs2_find_branch_target(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh, + struct buffer_head **target_bh); + +static int ocfs2_find_new_last_ext_blk(struct ocfs2_super *osb, + struct inode *inode, + struct ocfs2_dinode *fe, + unsigned int new_i_clusters, + struct buffer_head *old_last_eb, + struct buffer_head **new_last_eb); + +static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc); + +static int ocfs2_extent_contig(struct inode *inode, + struct ocfs2_extent_rec *ext, + u64 blkno) +{ + return blkno == (le64_to_cpu(ext->e_blkno) + + ocfs2_clusters_to_blocks(inode->i_sb, + le32_to_cpu(ext->e_clusters))); +} + +/* + * How many free extents have we got before we need more meta data? + */ +int ocfs2_num_free_extents(struct ocfs2_super *osb, + struct inode *inode, + struct ocfs2_dinode *fe) +{ + int retval; + struct ocfs2_extent_list *el; + struct ocfs2_extent_block *eb; + struct buffer_head *eb_bh = NULL; + + mlog_entry_void(); + + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); + retval = -EIO; + goto bail; + } + + if (fe->i_last_eb_blk) { + retval = ocfs2_read_block(osb, le64_to_cpu(fe->i_last_eb_blk), + &eb_bh, OCFS2_BH_CACHED, inode); + if (retval < 0) { + mlog_errno(retval); + goto bail; + } + eb = (struct ocfs2_extent_block *) eb_bh->b_data; + el = &eb->h_list; + } else + el = &fe->id2.i_list; + + BUG_ON(el->l_tree_depth != 0); + + retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec); +bail: + if (eb_bh) + brelse(eb_bh); + + mlog_exit(retval); + return retval; +} + +/* expects array to already be allocated + * + * sets h_signature, h_blkno, h_suballoc_bit, h_suballoc_slot, and + * l_count for you + */ +static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + int wanted, + struct ocfs2_alloc_context *meta_ac, + struct buffer_head *bhs[]) +{ + int count, status, i; + u16 suballoc_bit_start; + u32 num_got; + u64 first_blkno; + struct ocfs2_extent_block *eb; + + mlog_entry_void(); + + count = 0; + while (count < wanted) { + status = ocfs2_claim_metadata(osb, + handle, + meta_ac, + wanted - count, + &suballoc_bit_start, + &num_got, + &first_blkno); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + for(i = count; i < (num_got + count); i++) { + bhs[i] = sb_getblk(osb->sb, first_blkno); + if (bhs[i] == NULL) { + status = -EIO; + mlog_errno(status); + goto bail; + } + ocfs2_set_new_buffer_uptodate(inode, bhs[i]); + + status = ocfs2_journal_access(handle, inode, bhs[i], + OCFS2_JOURNAL_ACCESS_CREATE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + memset(bhs[i]->b_data, 0, osb->sb->s_blocksize); + eb = (struct ocfs2_extent_block *) bhs[i]->b_data; + /* Ok, setup the minimal stuff here. */ + strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE); + eb->h_blkno = cpu_to_le64(first_blkno); + eb->h_fs_generation = cpu_to_le32(osb->fs_generation); + +#ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS + /* we always use slot zero's suballocator */ + eb->h_suballoc_slot = 0; +#else + eb->h_suballoc_slot = cpu_to_le16(osb->slot_num); +#endif + eb->h_suballoc_bit = cpu_to_le16(suballoc_bit_start); + eb->h_list.l_count = + cpu_to_le16(ocfs2_extent_recs_per_eb(osb->sb)); + + suballoc_bit_start++; + first_blkno++; + + /* We'll also be dirtied by the caller, so + * this isn't absolutely necessary. */ + status = ocfs2_journal_dirty(handle, bhs[i]); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + count += num_got; + } + + status = 0; +bail: + if (status < 0) { + for(i = 0; i < wanted; i++) { + if (bhs[i]) + brelse(bhs[i]); + bhs[i] = NULL; + } + } + mlog_exit(status); + return status; +} + +/* + * Add an entire tree branch to our inode. eb_bh is the extent block + * to start at, if we don't want to start the branch at the dinode + * structure. + * + * last_eb_bh is required as we have to update it's next_leaf pointer + * for the new last extent block. + * + * the new branch will be 'empty' in the sense that every block will + * contain a single record with e_clusters == 0. + */ +static int ocfs2_add_branch(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + struct buffer_head *eb_bh, + struct buffer_head *last_eb_bh, + struct ocfs2_alloc_context *meta_ac) +{ + int status, new_blocks, i; + u64 next_blkno, new_last_eb_blk; + struct buffer_head *bh; + struct buffer_head **new_eb_bhs = NULL; + struct ocfs2_dinode *fe; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *eb_el; + struct ocfs2_extent_list *el; + + mlog_entry_void(); + + BUG_ON(!last_eb_bh); + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + + if (eb_bh) { + eb = (struct ocfs2_extent_block *) eb_bh->b_data; + el = &eb->h_list; + } else + el = &fe->id2.i_list; + + /* we never add a branch to a leaf. */ + BUG_ON(!el->l_tree_depth); + + new_blocks = le16_to_cpu(el->l_tree_depth); + + /* allocate the number of new eb blocks we need */ + new_eb_bhs = kcalloc(new_blocks, sizeof(struct buffer_head *), + GFP_KERNEL); + if (!new_eb_bhs) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + status = ocfs2_create_new_meta_bhs(osb, handle, inode, new_blocks, + meta_ac, new_eb_bhs); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* Note: new_eb_bhs[new_blocks - 1] is the guy which will be + * linked with the rest of the tree. + * conversly, new_eb_bhs[0] is the new bottommost leaf. + * + * when we leave the loop, new_last_eb_blk will point to the + * newest leaf, and next_blkno will point to the topmost extent + * block. */ + next_blkno = new_last_eb_blk = 0; + for(i = 0; i < new_blocks; i++) { + bh = new_eb_bhs[i]; + eb = (struct ocfs2_extent_block *) bh->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + status = -EIO; + goto bail; + } + eb_el = &eb->h_list; + + status = ocfs2_journal_access(handle, inode, bh, + OCFS2_JOURNAL_ACCESS_CREATE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + eb->h_next_leaf_blk = 0; + eb_el->l_tree_depth = cpu_to_le16(i); + eb_el->l_next_free_rec = cpu_to_le16(1); + eb_el->l_recs[0].e_cpos = fe->i_clusters; + eb_el->l_recs[0].e_blkno = cpu_to_le64(next_blkno); + eb_el->l_recs[0].e_clusters = cpu_to_le32(0); + if (!eb_el->l_tree_depth) + new_last_eb_blk = le64_to_cpu(eb->h_blkno); + + status = ocfs2_journal_dirty(handle, bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + next_blkno = le64_to_cpu(eb->h_blkno); + } + + /* This is a bit hairy. We want to update up to three blocks + * here without leaving any of them in an inconsistent state + * in case of error. We don't have to worry about + * journal_dirty erroring as it won't unless we've aborted the + * handle (in which case we would never be here) so reserving + * the write with journal_access is all we need to do. */ + status = ocfs2_journal_access(handle, inode, last_eb_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + status = ocfs2_journal_access(handle, inode, fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + if (eb_bh) { + status = ocfs2_journal_access(handle, inode, eb_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + /* Link the new branch into the rest of the tree (el will + * either be on the fe, or the extent block passed in. */ + i = le16_to_cpu(el->l_next_free_rec); + el->l_recs[i].e_blkno = cpu_to_le64(next_blkno); + el->l_recs[i].e_cpos = fe->i_clusters; + el->l_recs[i].e_clusters = 0; + le16_add_cpu(&el->l_next_free_rec, 1); + + /* fe needs a new last extent block pointer, as does the + * next_leaf on the previously last-extent-block. */ + fe->i_last_eb_blk = cpu_to_le64(new_last_eb_blk); + + eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; + eb->h_next_leaf_blk = cpu_to_le64(new_last_eb_blk); + + status = ocfs2_journal_dirty(handle, last_eb_bh); + if (status < 0) + mlog_errno(status); + status = ocfs2_journal_dirty(handle, fe_bh); + if (status < 0) + mlog_errno(status); + if (eb_bh) { + status = ocfs2_journal_dirty(handle, eb_bh); + if (status < 0) + mlog_errno(status); + } + + status = 0; +bail: + if (new_eb_bhs) { + for (i = 0; i < new_blocks; i++) + if (new_eb_bhs[i]) + brelse(new_eb_bhs[i]); + kfree(new_eb_bhs); + } + + mlog_exit(status); + return status; +} + +/* + * adds another level to the allocation tree. + * returns back the new extent block so you can add a branch to it + * after this call. + */ +static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + struct ocfs2_alloc_context *meta_ac, + struct buffer_head **ret_new_eb_bh) +{ + int status, i; + struct buffer_head *new_eb_bh = NULL; + struct ocfs2_dinode *fe; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *fe_el; + struct ocfs2_extent_list *eb_el; + + mlog_entry_void(); + + status = ocfs2_create_new_meta_bhs(osb, handle, inode, 1, meta_ac, + &new_eb_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + eb = (struct ocfs2_extent_block *) new_eb_bh->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + status = -EIO; + goto bail; + } + + eb_el = &eb->h_list; + fe = (struct ocfs2_dinode *) fe_bh->b_data; + fe_el = &fe->id2.i_list; + + status = ocfs2_journal_access(handle, inode, new_eb_bh, + OCFS2_JOURNAL_ACCESS_CREATE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* copy the fe data into the new extent block */ + eb_el->l_tree_depth = fe_el->l_tree_depth; + eb_el->l_next_free_rec = fe_el->l_next_free_rec; + for(i = 0; i < le16_to_cpu(fe_el->l_next_free_rec); i++) { + eb_el->l_recs[i].e_cpos = fe_el->l_recs[i].e_cpos; + eb_el->l_recs[i].e_clusters = fe_el->l_recs[i].e_clusters; + eb_el->l_recs[i].e_blkno = fe_el->l_recs[i].e_blkno; + } + + status = ocfs2_journal_dirty(handle, new_eb_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_journal_access(handle, inode, fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* update fe now */ + le16_add_cpu(&fe_el->l_tree_depth, 1); + fe_el->l_recs[0].e_cpos = 0; + fe_el->l_recs[0].e_blkno = eb->h_blkno; + fe_el->l_recs[0].e_clusters = fe->i_clusters; + for(i = 1; i < le16_to_cpu(fe_el->l_next_free_rec); i++) { + fe_el->l_recs[i].e_cpos = 0; + fe_el->l_recs[i].e_clusters = 0; + fe_el->l_recs[i].e_blkno = 0; + } + fe_el->l_next_free_rec = cpu_to_le16(1); + + /* If this is our 1st tree depth shift, then last_eb_blk + * becomes the allocated extent block */ + if (fe_el->l_tree_depth == cpu_to_le16(1)) + fe->i_last_eb_blk = eb->h_blkno; + + status = ocfs2_journal_dirty(handle, fe_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + *ret_new_eb_bh = new_eb_bh; + new_eb_bh = NULL; + status = 0; +bail: + if (new_eb_bh) + brelse(new_eb_bh); + + mlog_exit(status); + return status; +} + +/* + * Expects the tree to already have room in the rightmost leaf for the + * extent. Updates all the extent blocks (and the dinode) on the way + * down. + */ +static int ocfs2_do_insert_extent(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + u64 start_blk, + u32 new_clusters) +{ + int status, i, num_bhs = 0; + u64 next_blkno; + u16 next_free; + struct buffer_head **eb_bhs = NULL; + struct ocfs2_dinode *fe; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *el; + + mlog_entry_void(); + + status = ocfs2_journal_access(handle, inode, fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + el = &fe->id2.i_list; + if (el->l_tree_depth) { + /* This is another operation where we want to be + * careful about our tree updates. An error here means + * none of the previous changes we made should roll + * forward. As a result, we have to record the buffers + * for this part of the tree in an array and reserve a + * journal write to them before making any changes. */ + num_bhs = le16_to_cpu(fe->id2.i_list.l_tree_depth); + eb_bhs = kcalloc(num_bhs, sizeof(struct buffer_head *), + GFP_KERNEL); + if (!eb_bhs) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + i = 0; + while(el->l_tree_depth) { + next_free = le16_to_cpu(el->l_next_free_rec); + if (next_free == 0) { + ocfs2_error(inode->i_sb, + "Dinode %"MLFu64" has a bad " + "extent list", + OCFS2_I(inode)->ip_blkno); + status = -EIO; + goto bail; + } + next_blkno = le64_to_cpu(el->l_recs[next_free - 1].e_blkno); + + BUG_ON(i >= num_bhs); + status = ocfs2_read_block(osb, next_blkno, &eb_bhs[i], + OCFS2_BH_CACHED, inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + eb = (struct ocfs2_extent_block *) eb_bhs[i]->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, + eb); + status = -EIO; + goto bail; + } + + status = ocfs2_journal_access(handle, inode, eb_bhs[i], + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + el = &eb->h_list; + i++; + /* When we leave this loop, eb_bhs[num_bhs - 1] will + * hold the bottom-most leaf extent block. */ + } + BUG_ON(el->l_tree_depth); + + el = &fe->id2.i_list; + /* If we have tree depth, then the fe update is + * trivial, and we want to switch el out for the + * bottom-most leaf in order to update it with the + * actual extent data below. */ + next_free = le16_to_cpu(el->l_next_free_rec); + if (next_free == 0) { + ocfs2_error(inode->i_sb, + "Dinode %"MLFu64" has a bad " + "extent list", + OCFS2_I(inode)->ip_blkno); + status = -EIO; + goto bail; + } + le32_add_cpu(&el->l_recs[next_free - 1].e_clusters, + new_clusters); + /* (num_bhs - 1) to avoid the leaf */ + for(i = 0; i < (num_bhs - 1); i++) { + eb = (struct ocfs2_extent_block *) eb_bhs[i]->b_data; + el = &eb->h_list; + + /* finally, make our actual change to the + * intermediate extent blocks. */ + next_free = le16_to_cpu(el->l_next_free_rec); + le32_add_cpu(&el->l_recs[next_free - 1].e_clusters, + new_clusters); + + status = ocfs2_journal_dirty(handle, eb_bhs[i]); + if (status < 0) + mlog_errno(status); + } + BUG_ON(i != (num_bhs - 1)); + /* note that the leaf block wasn't touched in + * the loop above */ + eb = (struct ocfs2_extent_block *) eb_bhs[num_bhs - 1]->b_data; + el = &eb->h_list; + BUG_ON(el->l_tree_depth); + } + + /* yay, we can finally add the actual extent now! */ + i = le16_to_cpu(el->l_next_free_rec) - 1; + if (le16_to_cpu(el->l_next_free_rec) && + ocfs2_extent_contig(inode, &el->l_recs[i], start_blk)) { + le32_add_cpu(&el->l_recs[i].e_clusters, new_clusters); + } else if (le16_to_cpu(el->l_next_free_rec) && + (le32_to_cpu(el->l_recs[i].e_clusters) == 0)) { + /* having an empty extent at eof is legal. */ + if (el->l_recs[i].e_cpos != fe->i_clusters) { + ocfs2_error(inode->i_sb, + "Dinode %"MLFu64" trailing extent is bad: " + "cpos (%u) != number of clusters (%u)", + le32_to_cpu(el->l_recs[i].e_cpos), + le32_to_cpu(fe->i_clusters)); + status = -EIO; + goto bail; + } + el->l_recs[i].e_blkno = cpu_to_le64(start_blk); + el->l_recs[i].e_clusters = cpu_to_le32(new_clusters); + } else { + /* No contiguous record, or no empty record at eof, so + * we add a new one. */ + + BUG_ON(le16_to_cpu(el->l_next_free_rec) >= + le16_to_cpu(el->l_count)); + i = le16_to_cpu(el->l_next_free_rec); + + el->l_recs[i].e_blkno = cpu_to_le64(start_blk); + el->l_recs[i].e_clusters = cpu_to_le32(new_clusters); + el->l_recs[i].e_cpos = fe->i_clusters; + le16_add_cpu(&el->l_next_free_rec, 1); + } + + /* + * extent_map errors are not fatal, so they are ignored outside + * of flushing the thing. + */ + status = ocfs2_extent_map_append(inode, &el->l_recs[i], + new_clusters); + if (status) { + mlog_errno(status); + ocfs2_extent_map_drop(inode, le32_to_cpu(fe->i_clusters)); + } + + status = ocfs2_journal_dirty(handle, fe_bh); + if (status < 0) + mlog_errno(status); + if (fe->id2.i_list.l_tree_depth) { + status = ocfs2_journal_dirty(handle, eb_bhs[num_bhs - 1]); + if (status < 0) + mlog_errno(status); + } + + status = 0; +bail: + if (eb_bhs) { + for (i = 0; i < num_bhs; i++) + if (eb_bhs[i]) + brelse(eb_bhs[i]); + kfree(eb_bhs); + } + + mlog_exit(status); + return status; +} + +/* + * Should only be called when there is no space left in any of the + * leaf nodes. What we want to do is find the lowest tree depth + * non-leaf extent block with room for new records. There are three + * valid results of this search: + * + * 1) a lowest extent block is found, then we pass it back in + * *lowest_eb_bh and return '0' + * + * 2) the search fails to find anything, but the dinode has room. We + * pass NULL back in *lowest_eb_bh, but still return '0' + * + * 3) the search fails to find anything AND the dinode is full, in + * which case we return > 0 + * + * return status < 0 indicates an error. + */ +static int ocfs2_find_branch_target(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh, + struct buffer_head **target_bh) +{ + int status = 0, i; + u64 blkno; + struct ocfs2_dinode *fe; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *el; + struct buffer_head *bh = NULL; + struct buffer_head *lowest_bh = NULL; + + mlog_entry_void(); + + *target_bh = NULL; + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + el = &fe->id2.i_list; + + while(le16_to_cpu(el->l_tree_depth) > 1) { + if (le16_to_cpu(el->l_next_free_rec) == 0) { + ocfs2_error(inode->i_sb, "Dinode %"MLFu64" has empty " + "extent list (next_free_rec == 0)", + OCFS2_I(inode)->ip_blkno); + status = -EIO; + goto bail; + } + i = le16_to_cpu(el->l_next_free_rec) - 1; + blkno = le64_to_cpu(el->l_recs[i].e_blkno); + if (!blkno) { + ocfs2_error(inode->i_sb, "Dinode %"MLFu64" has extent " + "list where extent # %d has no physical " + "block start", + OCFS2_I(inode)->ip_blkno, i); + status = -EIO; + goto bail; + } + + if (bh) { + brelse(bh); + bh = NULL; + } + + status = ocfs2_read_block(osb, blkno, &bh, OCFS2_BH_CACHED, + inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + eb = (struct ocfs2_extent_block *) bh->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + status = -EIO; + goto bail; + } + el = &eb->h_list; + + if (le16_to_cpu(el->l_next_free_rec) < + le16_to_cpu(el->l_count)) { + if (lowest_bh) + brelse(lowest_bh); + lowest_bh = bh; + get_bh(lowest_bh); + } + } + + /* If we didn't find one and the fe doesn't have any room, + * then return '1' */ + if (!lowest_bh + && (fe->id2.i_list.l_next_free_rec == fe->id2.i_list.l_count)) + status = 1; + + *target_bh = lowest_bh; +bail: + if (bh) + brelse(bh); + + mlog_exit(status); + return status; +} + +/* the caller needs to update fe->i_clusters */ +int ocfs2_insert_extent(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + u64 start_blk, + u32 new_clusters, + struct ocfs2_alloc_context *meta_ac) +{ + int status, i, shift; + struct buffer_head *last_eb_bh = NULL; + struct buffer_head *bh = NULL; + struct ocfs2_dinode *fe; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *el; + + mlog_entry_void(); + + mlog(0, "add %u clusters starting at block %"MLFu64" to " + "inode %"MLFu64"\n", + new_clusters, start_blk, OCFS2_I(inode)->ip_blkno); + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + el = &fe->id2.i_list; + + if (el->l_tree_depth) { + /* jump to end of tree */ + status = ocfs2_read_block(osb, le64_to_cpu(fe->i_last_eb_blk), + &last_eb_bh, OCFS2_BH_CACHED, inode); + if (status < 0) { + mlog_exit(status); + goto bail; + } + eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; + el = &eb->h_list; + } + + /* Can we allocate without adding/shifting tree bits? */ + i = le16_to_cpu(el->l_next_free_rec) - 1; + if (le16_to_cpu(el->l_next_free_rec) == 0 + || (le16_to_cpu(el->l_next_free_rec) < le16_to_cpu(el->l_count)) + || le32_to_cpu(el->l_recs[i].e_clusters) == 0 + || ocfs2_extent_contig(inode, &el->l_recs[i], start_blk)) + goto out_add; + + mlog(0, "ocfs2_allocate_extent: couldn't do a simple add, traversing " + "tree now.\n"); + + shift = ocfs2_find_branch_target(osb, inode, fe_bh, &bh); + if (shift < 0) { + status = shift; + mlog_errno(status); + goto bail; + } + + /* We traveled all the way to the bottom of the allocation tree + * and didn't find room for any more extents - we need to add + * another tree level */ + if (shift) { + /* if we hit a leaf, we'd better be empty :) */ + BUG_ON(le16_to_cpu(el->l_next_free_rec) != + le16_to_cpu(el->l_count)); + BUG_ON(bh); + mlog(0, "ocfs2_allocate_extent: need to shift tree depth " + "(current = %u)\n", + le16_to_cpu(fe->id2.i_list.l_tree_depth)); + + /* ocfs2_shift_tree_depth will return us a buffer with + * the new extent block (so we can pass that to + * ocfs2_add_branch). */ + status = ocfs2_shift_tree_depth(osb, handle, inode, fe_bh, + meta_ac, &bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + /* Special case: we have room now if we shifted from + * tree_depth 0 */ + if (fe->id2.i_list.l_tree_depth == cpu_to_le16(1)) + goto out_add; + } + + /* call ocfs2_add_branch to add the final part of the tree with + * the new data. */ + mlog(0, "ocfs2_allocate_extent: add branch. bh = %p\n", bh); + status = ocfs2_add_branch(osb, handle, inode, fe_bh, bh, last_eb_bh, + meta_ac); + if (status < 0) { + mlog_errno(status); + goto bail; + } + +out_add: + /* Finally, we can add clusters. */ + status = ocfs2_do_insert_extent(osb, handle, inode, fe_bh, + start_blk, new_clusters); + if (status < 0) + mlog_errno(status); + +bail: + if (bh) + brelse(bh); + + if (last_eb_bh) + brelse(last_eb_bh); + + mlog_exit(status); + return status; +} + +static inline int ocfs2_truncate_log_needs_flush(struct ocfs2_super *osb) +{ + struct buffer_head *tl_bh = osb->osb_tl_bh; + struct ocfs2_dinode *di; + struct ocfs2_truncate_log *tl; + + di = (struct ocfs2_dinode *) tl_bh->b_data; + tl = &di->id2.i_dealloc; + + mlog_bug_on_msg(le16_to_cpu(tl->tl_used) > le16_to_cpu(tl->tl_count), + "slot %d, invalid truncate log parameters: used = " + "%u, count = %u\n", osb->slot_num, + le16_to_cpu(tl->tl_used), le16_to_cpu(tl->tl_count)); + return le16_to_cpu(tl->tl_used) == le16_to_cpu(tl->tl_count); +} + +static int ocfs2_truncate_log_can_coalesce(struct ocfs2_truncate_log *tl, + unsigned int new_start) +{ + unsigned int tail_index; + unsigned int current_tail; + + /* No records, nothing to coalesce */ + if (!le16_to_cpu(tl->tl_used)) + return 0; + + tail_index = le16_to_cpu(tl->tl_used) - 1; + current_tail = le32_to_cpu(tl->tl_recs[tail_index].t_start); + current_tail += le32_to_cpu(tl->tl_recs[tail_index].t_clusters); + + return current_tail == new_start; +} + +static int ocfs2_truncate_log_append(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + u64 start_blk, + unsigned int num_clusters) +{ + int status, index; + unsigned int start_cluster, tl_count; + struct inode *tl_inode = osb->osb_tl_inode; + struct buffer_head *tl_bh = osb->osb_tl_bh; + struct ocfs2_dinode *di; + struct ocfs2_truncate_log *tl; + + mlog_entry("start_blk = %"MLFu64", num_clusters = %u\n", start_blk, + num_clusters); + + BUG_ON(!down_trylock(&tl_inode->i_sem)); + + start_cluster = ocfs2_blocks_to_clusters(osb->sb, start_blk); + + di = (struct ocfs2_dinode *) tl_bh->b_data; + tl = &di->id2.i_dealloc; + if (!OCFS2_IS_VALID_DINODE(di)) { + OCFS2_RO_ON_INVALID_DINODE(osb->sb, di); + status = -EIO; + goto bail; + } + + tl_count = le16_to_cpu(tl->tl_count); + mlog_bug_on_msg(tl_count > ocfs2_truncate_recs_per_inode(osb->sb) || + tl_count == 0, + "Truncate record count on #%"MLFu64" invalid (" + "wanted %u, actual %u\n", OCFS2_I(tl_inode)->ip_blkno, + ocfs2_truncate_recs_per_inode(osb->sb), + le16_to_cpu(tl->tl_count)); + + /* Caller should have known to flush before calling us. */ + index = le16_to_cpu(tl->tl_used); + if (index >= tl_count) { + status = -ENOSPC; + mlog_errno(status); + goto bail; + } + + status = ocfs2_journal_access(handle, tl_inode, tl_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + mlog(0, "Log truncate of %u clusters starting at cluster %u to " + "%"MLFu64" (index = %d)\n", num_clusters, start_cluster, + OCFS2_I(tl_inode)->ip_blkno, index); + + if (ocfs2_truncate_log_can_coalesce(tl, start_cluster)) { + /* + * Move index back to the record we are coalescing with. + * ocfs2_truncate_log_can_coalesce() guarantees nonzero + */ + index--; + + num_clusters += le32_to_cpu(tl->tl_recs[index].t_clusters); + mlog(0, "Coalesce with index %u (start = %u, clusters = %u)\n", + index, le32_to_cpu(tl->tl_recs[index].t_start), + num_clusters); + } else { + tl->tl_recs[index].t_start = cpu_to_le32(start_cluster); + tl->tl_used = cpu_to_le16(index + 1); + } + tl->tl_recs[index].t_clusters = cpu_to_le32(num_clusters); + + status = ocfs2_journal_dirty(handle, tl_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *data_alloc_inode, + struct buffer_head *data_alloc_bh) +{ + int status = 0; + int i; + unsigned int num_clusters; + u64 start_blk; + struct ocfs2_truncate_rec rec; + struct ocfs2_dinode *di; + struct ocfs2_truncate_log *tl; + struct inode *tl_inode = osb->osb_tl_inode; + struct buffer_head *tl_bh = osb->osb_tl_bh; + + mlog_entry_void(); + + di = (struct ocfs2_dinode *) tl_bh->b_data; + tl = &di->id2.i_dealloc; + i = le16_to_cpu(tl->tl_used) - 1; + while (i >= 0) { + /* Caller has given us at least enough credits to + * update the truncate log dinode */ + status = ocfs2_journal_access(handle, tl_inode, tl_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + tl->tl_used = cpu_to_le16(i); + + status = ocfs2_journal_dirty(handle, tl_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* TODO: Perhaps we can calculate the bulk of the + * credits up front rather than extending like + * this. */ + status = ocfs2_extend_trans(handle, + OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + rec = tl->tl_recs[i]; + start_blk = ocfs2_clusters_to_blocks(data_alloc_inode->i_sb, + le32_to_cpu(rec.t_start)); + num_clusters = le32_to_cpu(rec.t_clusters); + + /* if start_blk is not set, we ignore the record as + * invalid. */ + if (start_blk) { + mlog(0, "free record %d, start = %u, clusters = %u\n", + i, le32_to_cpu(rec.t_start), num_clusters); + + status = ocfs2_free_clusters(handle, data_alloc_inode, + data_alloc_bh, start_blk, + num_clusters); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + i--; + } + +bail: + mlog_exit(status); + return status; +} + +/* Expects you to already be holding tl_inode->i_sem */ +static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) +{ + int status; + unsigned int num_to_flush; + struct ocfs2_journal_handle *handle = NULL; + struct inode *tl_inode = osb->osb_tl_inode; + struct inode *data_alloc_inode = NULL; + struct buffer_head *tl_bh = osb->osb_tl_bh; + struct buffer_head *data_alloc_bh = NULL; + struct ocfs2_dinode *di; + struct ocfs2_truncate_log *tl; + + mlog_entry_void(); + + BUG_ON(!down_trylock(&tl_inode->i_sem)); + + di = (struct ocfs2_dinode *) tl_bh->b_data; + tl = &di->id2.i_dealloc; + if (!OCFS2_IS_VALID_DINODE(di)) { + OCFS2_RO_ON_INVALID_DINODE(osb->sb, di); + status = -EIO; + goto bail; + } + + num_to_flush = le16_to_cpu(tl->tl_used); + mlog(0, "Flush %u records from truncate log #%"MLFu64"\n", + num_to_flush, OCFS2_I(tl_inode)->ip_blkno); + if (!num_to_flush) { + status = 0; + goto bail; + } + + handle = ocfs2_alloc_handle(osb); + if (!handle) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + data_alloc_inode = ocfs2_get_system_file_inode(osb, + GLOBAL_BITMAP_SYSTEM_INODE, + OCFS2_INVALID_SLOT); + if (!data_alloc_inode) { + status = -EINVAL; + mlog(ML_ERROR, "Could not get bitmap inode!\n"); + goto bail; + } + + ocfs2_handle_add_inode(handle, data_alloc_inode); + status = ocfs2_meta_lock(data_alloc_inode, handle, &data_alloc_bh, 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + handle = ocfs2_start_trans(osb, handle, OCFS2_TRUNCATE_LOG_UPDATE); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + status = ocfs2_replay_truncate_records(osb, handle, data_alloc_inode, + data_alloc_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + +bail: + if (handle) + ocfs2_commit_trans(handle); + + if (data_alloc_inode) + iput(data_alloc_inode); + + if (data_alloc_bh) + brelse(data_alloc_bh); + + mlog_exit(status); + return status; +} + +int ocfs2_flush_truncate_log(struct ocfs2_super *osb) +{ + int status; + struct inode *tl_inode = osb->osb_tl_inode; + + down(&tl_inode->i_sem); + status = __ocfs2_flush_truncate_log(osb); + up(&tl_inode->i_sem); + + return status; +} + +static void ocfs2_truncate_log_worker(void *data) +{ + int status; + struct ocfs2_super *osb = data; + + mlog_entry_void(); + + status = ocfs2_flush_truncate_log(osb); + if (status < 0) + mlog_errno(status); + + mlog_exit(status); +} + +#define OCFS2_TRUNCATE_LOG_FLUSH_INTERVAL (2 * HZ) +void ocfs2_schedule_truncate_log_flush(struct ocfs2_super *osb, + int cancel) +{ + if (osb->osb_tl_inode) { + /* We want to push off log flushes while truncates are + * still running. */ + if (cancel) + cancel_delayed_work(&osb->osb_truncate_log_wq); + + queue_delayed_work(ocfs2_wq, &osb->osb_truncate_log_wq, + OCFS2_TRUNCATE_LOG_FLUSH_INTERVAL); + } +} + +static int ocfs2_get_truncate_log_info(struct ocfs2_super *osb, + int slot_num, + struct inode **tl_inode, + struct buffer_head **tl_bh) +{ + int status; + struct inode *inode = NULL; + struct buffer_head *bh = NULL; + + inode = ocfs2_get_system_file_inode(osb, + TRUNCATE_LOG_SYSTEM_INODE, + slot_num); + if (!inode) { + status = -EINVAL; + mlog(ML_ERROR, "Could not get load truncate log inode!\n"); + goto bail; + } + + status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &bh, + OCFS2_BH_CACHED, inode); + if (status < 0) { + iput(inode); + mlog_errno(status); + goto bail; + } + + *tl_inode = inode; + *tl_bh = bh; +bail: + mlog_exit(status); + return status; +} + +/* called during the 1st stage of node recovery. we stamp a clean + * truncate log and pass back a copy for processing later. if the + * truncate log does not require processing, a *tl_copy is set to + * NULL. */ +int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, + int slot_num, + struct ocfs2_dinode **tl_copy) +{ + int status; + struct inode *tl_inode = NULL; + struct buffer_head *tl_bh = NULL; + struct ocfs2_dinode *di; + struct ocfs2_truncate_log *tl; + + *tl_copy = NULL; + + mlog(0, "recover truncate log from slot %d\n", slot_num); + + status = ocfs2_get_truncate_log_info(osb, slot_num, &tl_inode, &tl_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + di = (struct ocfs2_dinode *) tl_bh->b_data; + tl = &di->id2.i_dealloc; + if (!OCFS2_IS_VALID_DINODE(di)) { + OCFS2_RO_ON_INVALID_DINODE(tl_inode->i_sb, di); + status = -EIO; + goto bail; + } + + if (le16_to_cpu(tl->tl_used)) { + mlog(0, "We'll have %u logs to recover\n", + le16_to_cpu(tl->tl_used)); + + *tl_copy = kmalloc(tl_bh->b_size, GFP_KERNEL); + if (!(*tl_copy)) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + /* Assuming the write-out below goes well, this copy + * will be passed back to recovery for processing. */ + memcpy(*tl_copy, tl_bh->b_data, tl_bh->b_size); + + /* All we need to do to clear the truncate log is set + * tl_used. */ + tl->tl_used = 0; + + status = ocfs2_write_block(osb, tl_bh, tl_inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + +bail: + if (tl_inode) + iput(tl_inode); + if (tl_bh) + brelse(tl_bh); + + if (status < 0 && (*tl_copy)) { + kfree(*tl_copy); + *tl_copy = NULL; + } + + mlog_exit(status); + return status; +} + +int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, + struct ocfs2_dinode *tl_copy) +{ + int status = 0; + int i; + unsigned int clusters, num_recs, start_cluster; + u64 start_blk; + struct ocfs2_journal_handle *handle; + struct inode *tl_inode = osb->osb_tl_inode; + struct ocfs2_truncate_log *tl; + + mlog_entry_void(); + + if (OCFS2_I(tl_inode)->ip_blkno == le64_to_cpu(tl_copy->i_blkno)) { + mlog(ML_ERROR, "Asked to recover my own truncate log!\n"); + return -EINVAL; + } + + tl = &tl_copy->id2.i_dealloc; + num_recs = le16_to_cpu(tl->tl_used); + mlog(0, "cleanup %u records from %"MLFu64"\n", num_recs, + tl_copy->i_blkno); + + down(&tl_inode->i_sem); + for(i = 0; i < num_recs; i++) { + if (ocfs2_truncate_log_needs_flush(osb)) { + status = __ocfs2_flush_truncate_log(osb); + if (status < 0) { + mlog_errno(status); + goto bail_up; + } + } + + handle = ocfs2_start_trans(osb, NULL, + OCFS2_TRUNCATE_LOG_UPDATE); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + mlog_errno(status); + goto bail_up; + } + + clusters = le32_to_cpu(tl->tl_recs[i].t_clusters); + start_cluster = le32_to_cpu(tl->tl_recs[i].t_start); + start_blk = ocfs2_clusters_to_blocks(osb->sb, start_cluster); + + status = ocfs2_truncate_log_append(osb, handle, + start_blk, clusters); + ocfs2_commit_trans(handle); + if (status < 0) { + mlog_errno(status); + goto bail_up; + } + } + +bail_up: + up(&tl_inode->i_sem); + + mlog_exit(status); + return status; +} + +void ocfs2_truncate_log_shutdown(struct ocfs2_super *osb) +{ + int status; + struct inode *tl_inode = osb->osb_tl_inode; + + mlog_entry_void(); + + if (tl_inode) { + cancel_delayed_work(&osb->osb_truncate_log_wq); + flush_workqueue(ocfs2_wq); + + status = ocfs2_flush_truncate_log(osb); + if (status < 0) + mlog_errno(status); + + brelse(osb->osb_tl_bh); + iput(osb->osb_tl_inode); + } + + mlog_exit_void(); +} + +int ocfs2_truncate_log_init(struct ocfs2_super *osb) +{ + int status; + struct inode *tl_inode = NULL; + struct buffer_head *tl_bh = NULL; + + mlog_entry_void(); + + status = ocfs2_get_truncate_log_info(osb, + osb->slot_num, + &tl_inode, + &tl_bh); + if (status < 0) + mlog_errno(status); + + /* ocfs2_truncate_log_shutdown keys on the existence of + * osb->osb_tl_inode so we don't set any of the osb variables + * until we're sure all is well. */ + INIT_WORK(&osb->osb_truncate_log_wq, ocfs2_truncate_log_worker, osb); + osb->osb_tl_bh = tl_bh; + osb->osb_tl_inode = tl_inode; + + mlog_exit(status); + return status; +} + +/* This function will figure out whether the currently last extent + * block will be deleted, and if it will, what the new last extent + * block will be so we can update his h_next_leaf_blk field, as well + * as the dinodes i_last_eb_blk */ +static int ocfs2_find_new_last_ext_blk(struct ocfs2_super *osb, + struct inode *inode, + struct ocfs2_dinode *fe, + u32 new_i_clusters, + struct buffer_head *old_last_eb, + struct buffer_head **new_last_eb) +{ + int i, status = 0; + u64 block = 0; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *el; + struct buffer_head *bh = NULL; + + *new_last_eb = NULL; + + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); + status = -EIO; + goto bail; + } + + /* we have no tree, so of course, no last_eb. */ + if (!fe->id2.i_list.l_tree_depth) + goto bail; + + /* trunc to zero special case - this makes tree_depth = 0 + * regardless of what it is. */ + if (!new_i_clusters) + goto bail; + + eb = (struct ocfs2_extent_block *) old_last_eb->b_data; + el = &(eb->h_list); + BUG_ON(!el->l_next_free_rec); + + /* Make sure that this guy will actually be empty after we + * clear away the data. */ + if (le32_to_cpu(el->l_recs[0].e_cpos) < new_i_clusters) + goto bail; + + /* Ok, at this point, we know that last_eb will definitely + * change, so lets traverse the tree and find the second to + * last extent block. */ + el = &(fe->id2.i_list); + /* go down the tree, */ + do { + for(i = (le16_to_cpu(el->l_next_free_rec) - 1); i >= 0; i--) { + if (le32_to_cpu(el->l_recs[i].e_cpos) < + new_i_clusters) { + block = le64_to_cpu(el->l_recs[i].e_blkno); + break; + } + } + BUG_ON(i < 0); + + if (bh) { + brelse(bh); + bh = NULL; + } + + status = ocfs2_read_block(osb, block, &bh, OCFS2_BH_CACHED, + inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + eb = (struct ocfs2_extent_block *) bh->b_data; + el = &eb->h_list; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + status = -EIO; + goto bail; + } + } while (el->l_tree_depth); + + *new_last_eb = bh; + get_bh(*new_last_eb); + mlog(0, "returning block %"MLFu64"\n", le64_to_cpu(eb->h_blkno)); +bail: + if (bh) + brelse(bh); + + return status; +} + +static int ocfs2_do_truncate(struct ocfs2_super *osb, + unsigned int clusters_to_del, + struct inode *inode, + struct buffer_head *fe_bh, + struct buffer_head *old_last_eb_bh, + struct ocfs2_journal_handle *handle, + struct ocfs2_truncate_context *tc) +{ + int status, i, depth; + struct ocfs2_dinode *fe; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_block *last_eb = NULL; + struct ocfs2_extent_list *el; + struct buffer_head *eb_bh = NULL; + struct buffer_head *last_eb_bh = NULL; + u64 next_eb = 0; + u64 delete_blk = 0; + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + + status = ocfs2_find_new_last_ext_blk(osb, + inode, + fe, + le32_to_cpu(fe->i_clusters) - + clusters_to_del, + old_last_eb_bh, + &last_eb_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + if (last_eb_bh) + last_eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; + + status = ocfs2_journal_access(handle, inode, fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + el = &(fe->id2.i_list); + + spin_lock(&OCFS2_I(inode)->ip_lock); + OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters) - + clusters_to_del; + spin_unlock(&OCFS2_I(inode)->ip_lock); + le32_add_cpu(&fe->i_clusters, -clusters_to_del); + fe->i_mtime = cpu_to_le64(CURRENT_TIME.tv_sec); + fe->i_mtime_nsec = cpu_to_le32(CURRENT_TIME.tv_nsec); + + i = le16_to_cpu(el->l_next_free_rec) - 1; + + BUG_ON(le32_to_cpu(el->l_recs[i].e_clusters) < clusters_to_del); + le32_add_cpu(&el->l_recs[i].e_clusters, -clusters_to_del); + /* tree depth zero, we can just delete the clusters, otherwise + * we need to record the offset of the next level extent block + * as we may overwrite it. */ + if (!el->l_tree_depth) + delete_blk = le64_to_cpu(el->l_recs[i].e_blkno) + + ocfs2_clusters_to_blocks(osb->sb, + le32_to_cpu(el->l_recs[i].e_clusters)); + else + next_eb = le64_to_cpu(el->l_recs[i].e_blkno); + + if (!el->l_recs[i].e_clusters) { + /* if we deleted the whole extent record, then clear + * out the other fields and update the extent + * list. For depth > 0 trees, we've already recorded + * the extent block in 'next_eb' */ + el->l_recs[i].e_cpos = 0; + el->l_recs[i].e_blkno = 0; + BUG_ON(!el->l_next_free_rec); + le16_add_cpu(&el->l_next_free_rec, -1); + } + + depth = le16_to_cpu(el->l_tree_depth); + if (!fe->i_clusters) { + /* trunc to zero is a special case. */ + el->l_tree_depth = 0; + fe->i_last_eb_blk = 0; + } else if (last_eb) + fe->i_last_eb_blk = last_eb->h_blkno; + + status = ocfs2_journal_dirty(handle, fe_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (last_eb) { + /* If there will be a new last extent block, then by + * definition, there cannot be any leaves to the right of + * him. */ + status = ocfs2_journal_access(handle, inode, last_eb_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + last_eb->h_next_leaf_blk = 0; + status = ocfs2_journal_dirty(handle, last_eb_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + /* if our tree depth > 0, update all the tree blocks below us. */ + while (depth) { + mlog(0, "traveling tree (depth = %d, next_eb = %"MLFu64")\n", + depth, next_eb); + status = ocfs2_read_block(osb, next_eb, &eb_bh, + OCFS2_BH_CACHED, inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + eb = (struct ocfs2_extent_block *)eb_bh->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + status = -EIO; + goto bail; + } + el = &(eb->h_list); + + status = ocfs2_journal_access(handle, inode, eb_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + BUG_ON(le16_to_cpu(el->l_next_free_rec) == 0); + BUG_ON(depth != (le16_to_cpu(el->l_tree_depth) + 1)); + + i = le16_to_cpu(el->l_next_free_rec) - 1; + + mlog(0, "extent block %"MLFu64", before: record %d: " + "(%u, %u, %"MLFu64"), next = %u\n", + le64_to_cpu(eb->h_blkno), i, + le32_to_cpu(el->l_recs[i].e_cpos), + le32_to_cpu(el->l_recs[i].e_clusters), + le64_to_cpu(el->l_recs[i].e_blkno), + le16_to_cpu(el->l_next_free_rec)); + + BUG_ON(le32_to_cpu(el->l_recs[i].e_clusters) < clusters_to_del); + le32_add_cpu(&el->l_recs[i].e_clusters, -clusters_to_del); + + next_eb = le64_to_cpu(el->l_recs[i].e_blkno); + /* bottom-most block requires us to delete data.*/ + if (!el->l_tree_depth) + delete_blk = le64_to_cpu(el->l_recs[i].e_blkno) + + ocfs2_clusters_to_blocks(osb->sb, + le32_to_cpu(el->l_recs[i].e_clusters)); + if (!el->l_recs[i].e_clusters) { + el->l_recs[i].e_cpos = 0; + el->l_recs[i].e_blkno = 0; + BUG_ON(!el->l_next_free_rec); + le16_add_cpu(&el->l_next_free_rec, -1); + } + mlog(0, "extent block %"MLFu64", after: record %d: " + "(%u, %u, %"MLFu64"), next = %u\n", + le64_to_cpu(eb->h_blkno), i, + le32_to_cpu(el->l_recs[i].e_cpos), + le32_to_cpu(el->l_recs[i].e_clusters), + le64_to_cpu(el->l_recs[i].e_blkno), + le16_to_cpu(el->l_next_free_rec)); + + status = ocfs2_journal_dirty(handle, eb_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (!el->l_next_free_rec) { + mlog(0, "deleting this extent block.\n"); + + ocfs2_remove_from_cache(inode, eb_bh); + + BUG_ON(eb->h_suballoc_slot); + BUG_ON(el->l_recs[0].e_clusters); + BUG_ON(el->l_recs[0].e_cpos); + BUG_ON(el->l_recs[0].e_blkno); + status = ocfs2_free_extent_block(handle, + tc->tc_ext_alloc_inode, + tc->tc_ext_alloc_bh, + eb); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + brelse(eb_bh); + eb_bh = NULL; + depth--; + } + + BUG_ON(!delete_blk); + status = ocfs2_truncate_log_append(osb, handle, delete_blk, + clusters_to_del); + if (status < 0) { + mlog_errno(status); + goto bail; + } + status = 0; +bail: + if (!status) + ocfs2_extent_map_trunc(inode, le32_to_cpu(fe->i_clusters)); + else + ocfs2_extent_map_drop(inode, 0); + mlog_exit(status); + return status; +} + +/* + * It is expected, that by the time you call this function, + * inode->i_size and fe->i_size have been adjusted. + * + * WARNING: This will kfree the truncate context + */ +int ocfs2_commit_truncate(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh, + struct ocfs2_truncate_context *tc) +{ + int status, i, credits, tl_sem = 0; + u32 clusters_to_del, target_i_clusters; + u64 last_eb = 0; + struct ocfs2_dinode *fe; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *el; + struct buffer_head *last_eb_bh; + struct ocfs2_journal_handle *handle = NULL; + struct inode *tl_inode = osb->osb_tl_inode; + + mlog_entry_void(); + + down_write(&OCFS2_I(inode)->ip_alloc_sem); + + target_i_clusters = ocfs2_clusters_for_bytes(osb->sb, + i_size_read(inode)); + + last_eb_bh = tc->tc_last_eb_bh; + tc->tc_last_eb_bh = NULL; + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + + if (fe->id2.i_list.l_tree_depth) { + eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; + el = &eb->h_list; + } else + el = &fe->id2.i_list; + last_eb = le64_to_cpu(fe->i_last_eb_blk); +start: + mlog(0, "ocfs2_commit_truncate: fe->i_clusters = %u, " + "last_eb = %"MLFu64", fe->i_last_eb_blk = %"MLFu64", " + "fe->id2.i_list.l_tree_depth = %u last_eb_bh = %p\n", + le32_to_cpu(fe->i_clusters), last_eb, + le64_to_cpu(fe->i_last_eb_blk), + le16_to_cpu(fe->id2.i_list.l_tree_depth), last_eb_bh); + + if (last_eb != le64_to_cpu(fe->i_last_eb_blk)) { + mlog(0, "last_eb changed!\n"); + BUG_ON(!fe->id2.i_list.l_tree_depth); + last_eb = le64_to_cpu(fe->i_last_eb_blk); + /* i_last_eb_blk may have changed, read it if + * necessary. We don't have to worry about the + * truncate to zero case here (where there becomes no + * last_eb) because we never loop back after our work + * is done. */ + if (last_eb_bh) { + brelse(last_eb_bh); + last_eb_bh = NULL; + } + + status = ocfs2_read_block(osb, last_eb, + &last_eb_bh, OCFS2_BH_CACHED, + inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + status = -EIO; + goto bail; + } + el = &(eb->h_list); + } + + /* by now, el will point to the extent list on the bottom most + * portion of this tree. */ + i = le16_to_cpu(el->l_next_free_rec) - 1; + if (le32_to_cpu(el->l_recs[i].e_cpos) >= target_i_clusters) + clusters_to_del = le32_to_cpu(el->l_recs[i].e_clusters); + else + clusters_to_del = (le32_to_cpu(el->l_recs[i].e_clusters) + + le32_to_cpu(el->l_recs[i].e_cpos)) - + target_i_clusters; + + mlog(0, "clusters_to_del = %u in this pass\n", clusters_to_del); + + down(&tl_inode->i_sem); + tl_sem = 1; + /* ocfs2_truncate_log_needs_flush guarantees us at least one + * record is free for use. If there isn't any, we flush to get + * an empty truncate log. */ + if (ocfs2_truncate_log_needs_flush(osb)) { + status = __ocfs2_flush_truncate_log(osb); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, + fe, el); + handle = ocfs2_start_trans(osb, NULL, credits); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + inode->i_ctime = inode->i_mtime = CURRENT_TIME; + status = ocfs2_mark_inode_dirty(handle, inode, fe_bh); + if (status < 0) + mlog_errno(status); + + status = ocfs2_do_truncate(osb, clusters_to_del, inode, fe_bh, + last_eb_bh, handle, tc); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + up(&tl_inode->i_sem); + tl_sem = 0; + + ocfs2_commit_trans(handle); + handle = NULL; + + BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters); + if (le32_to_cpu(fe->i_clusters) > target_i_clusters) + goto start; +bail: + up_write(&OCFS2_I(inode)->ip_alloc_sem); + + ocfs2_schedule_truncate_log_flush(osb, 1); + + if (tl_sem) + up(&tl_inode->i_sem); + + if (handle) + ocfs2_commit_trans(handle); + + if (last_eb_bh) + brelse(last_eb_bh); + + /* This will drop the ext_alloc cluster lock for us */ + ocfs2_free_truncate_context(tc); + + mlog_exit(status); + return status; +} + + +/* + * Expects the inode to already be locked. This will figure out which + * inodes need to be locked and will put them on the returned truncate + * context. + */ +int ocfs2_prepare_truncate(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh, + struct ocfs2_truncate_context **tc) +{ + int status, metadata_delete; + unsigned int new_i_clusters; + struct ocfs2_dinode *fe; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_list *el; + struct buffer_head *last_eb_bh = NULL; + struct inode *ext_alloc_inode = NULL; + struct buffer_head *ext_alloc_bh = NULL; + + mlog_entry_void(); + + *tc = NULL; + + new_i_clusters = ocfs2_clusters_for_bytes(osb->sb, + i_size_read(inode)); + fe = (struct ocfs2_dinode *) fe_bh->b_data; + + mlog(0, "fe->i_clusters = %u, new_i_clusters = %u, fe->i_size =" + "%"MLFu64"\n", fe->i_clusters, new_i_clusters, fe->i_size); + + if (le32_to_cpu(fe->i_clusters) <= new_i_clusters) { + ocfs2_error(inode->i_sb, "Dinode %"MLFu64" has cluster count " + "%u and size %"MLFu64" whereas struct inode has " + "cluster count %u and size %llu which caused an " + "invalid truncate to %u clusters.", + le64_to_cpu(fe->i_blkno), + le32_to_cpu(fe->i_clusters), + le64_to_cpu(fe->i_size), + OCFS2_I(inode)->ip_clusters, i_size_read(inode), + new_i_clusters); + mlog_meta_lvb(ML_ERROR, &OCFS2_I(inode)->ip_meta_lockres); + status = -EIO; + goto bail; + } + + *tc = kcalloc(1, sizeof(struct ocfs2_truncate_context), GFP_KERNEL); + if (!(*tc)) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + metadata_delete = 0; + if (fe->id2.i_list.l_tree_depth) { + /* If we have a tree, then the truncate may result in + * metadata deletes. Figure this out from the + * rightmost leaf block.*/ + status = ocfs2_read_block(osb, le64_to_cpu(fe->i_last_eb_blk), + &last_eb_bh, OCFS2_BH_CACHED, inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + eb = (struct ocfs2_extent_block *) last_eb_bh->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + + brelse(last_eb_bh); + status = -EIO; + goto bail; + } + el = &(eb->h_list); + if (le32_to_cpu(el->l_recs[0].e_cpos) >= new_i_clusters) + metadata_delete = 1; + } + + (*tc)->tc_last_eb_bh = last_eb_bh; + + if (metadata_delete) { + mlog(0, "Will have to delete metadata for this trunc. " + "locking allocator.\n"); + ext_alloc_inode = ocfs2_get_system_file_inode(osb, EXTENT_ALLOC_SYSTEM_INODE, 0); + if (!ext_alloc_inode) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + down(&ext_alloc_inode->i_sem); + (*tc)->tc_ext_alloc_inode = ext_alloc_inode; + + status = ocfs2_meta_lock(ext_alloc_inode, + NULL, + &ext_alloc_bh, + 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + (*tc)->tc_ext_alloc_bh = ext_alloc_bh; + (*tc)->tc_ext_alloc_locked = 1; + } + + status = 0; +bail: + if (status < 0) { + if (*tc) + ocfs2_free_truncate_context(*tc); + *tc = NULL; + } + mlog_exit_void(); + return status; +} + +static void ocfs2_free_truncate_context(struct ocfs2_truncate_context *tc) +{ + if (tc->tc_ext_alloc_inode) { + if (tc->tc_ext_alloc_locked) + ocfs2_meta_unlock(tc->tc_ext_alloc_inode, 1); + + up(&tc->tc_ext_alloc_inode->i_sem); + iput(tc->tc_ext_alloc_inode); + } + + if (tc->tc_ext_alloc_bh) + brelse(tc->tc_ext_alloc_bh); + + if (tc->tc_last_eb_bh) + brelse(tc->tc_last_eb_bh); + + kfree(tc); +} diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h new file mode 100644 index 0000000..12ba897 --- /dev/null +++ b/fs/ocfs2/alloc.h @@ -0,0 +1,82 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * alloc.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_ALLOC_H +#define OCFS2_ALLOC_H + +struct ocfs2_alloc_context; +int ocfs2_insert_extent(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + u64 blkno, + u32 new_clusters, + struct ocfs2_alloc_context *meta_ac); +int ocfs2_num_free_extents(struct ocfs2_super *osb, + struct inode *inode, + struct ocfs2_dinode *fe); +/* how many new metadata chunks would an allocation need at maximum? */ +static inline int ocfs2_extend_meta_needed(struct ocfs2_dinode *fe) +{ + /* + * Rather than do all the work of determining how much we need + * (involves a ton of reads and locks), just ask for the + * maximal limit. That's a tree depth shift. So, one block for + * level of the tree (current l_tree_depth), one block for the + * new tree_depth==0 extent_block, and one block at the new + * top-of-the tree. + */ + return le16_to_cpu(fe->id2.i_list.l_tree_depth) + 2; +} + +int ocfs2_truncate_log_init(struct ocfs2_super *osb); +void ocfs2_truncate_log_shutdown(struct ocfs2_super *osb); +void ocfs2_schedule_truncate_log_flush(struct ocfs2_super *osb, + int cancel); +int ocfs2_flush_truncate_log(struct ocfs2_super *osb); +int ocfs2_begin_truncate_log_recovery(struct ocfs2_super *osb, + int slot_num, + struct ocfs2_dinode **tl_copy); +int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, + struct ocfs2_dinode *tl_copy); + +struct ocfs2_truncate_context { + struct inode *tc_ext_alloc_inode; + struct buffer_head *tc_ext_alloc_bh; + int tc_ext_alloc_locked; /* is it cluster locked? */ + /* these get destroyed once it's passed to ocfs2_commit_truncate. */ + struct buffer_head *tc_last_eb_bh; +}; + +int ocfs2_prepare_truncate(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh, + struct ocfs2_truncate_context **tc); +int ocfs2_commit_truncate(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh, + struct ocfs2_truncate_context *tc); + +#endif /* OCFS2_ALLOC_H */ diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c new file mode 100644 index 0000000..8f4467a --- /dev/null +++ b/fs/ocfs2/aops.c @@ -0,0 +1,643 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_FILE_IO +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "aops.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "file.h" +#include "inode.h" +#include "journal.h" +#include "super.h" +#include "symlink.h" + +#include "buffer_head_io.h" + +static int ocfs2_symlink_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) +{ + int err = -EIO; + int status; + struct ocfs2_dinode *fe = NULL; + struct buffer_head *bh = NULL; + struct buffer_head *buffer_cache_bh = NULL; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + void *kaddr; + + mlog_entry("(0x%p, %llu, 0x%p, %d)\n", inode, + (unsigned long long)iblock, bh_result, create); + + BUG_ON(ocfs2_inode_is_fast_symlink(inode)); + + if ((iblock << inode->i_sb->s_blocksize_bits) > PATH_MAX + 1) { + mlog(ML_ERROR, "block offset > PATH_MAX: %llu", + (unsigned long long)iblock); + goto bail; + } + + status = ocfs2_read_block(OCFS2_SB(inode->i_sb), + OCFS2_I(inode)->ip_blkno, + &bh, OCFS2_BH_CACHED, inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + fe = (struct ocfs2_dinode *) bh->b_data; + + if (!OCFS2_IS_VALID_DINODE(fe)) { + mlog(ML_ERROR, "Invalid dinode #%"MLFu64": signature = %.*s\n", + fe->i_blkno, 7, fe->i_signature); + goto bail; + } + + if ((u64)iblock >= ocfs2_clusters_to_blocks(inode->i_sb, + le32_to_cpu(fe->i_clusters))) { + mlog(ML_ERROR, "block offset is outside the allocated size: " + "%llu\n", (unsigned long long)iblock); + goto bail; + } + + /* We don't use the page cache to create symlink data, so if + * need be, copy it over from the buffer cache. */ + if (!buffer_uptodate(bh_result) && ocfs2_inode_is_new(inode)) { + u64 blkno = le64_to_cpu(fe->id2.i_list.l_recs[0].e_blkno) + + iblock; + buffer_cache_bh = sb_getblk(osb->sb, blkno); + if (!buffer_cache_bh) { + mlog(ML_ERROR, "couldn't getblock for symlink!\n"); + goto bail; + } + + /* we haven't locked out transactions, so a commit + * could've happened. Since we've got a reference on + * the bh, even if it commits while we're doing the + * copy, the data is still good. */ + if (buffer_jbd(buffer_cache_bh) + && ocfs2_inode_is_new(inode)) { + kaddr = kmap_atomic(bh_result->b_page, KM_USER0); + if (!kaddr) { + mlog(ML_ERROR, "couldn't kmap!\n"); + goto bail; + } + memcpy(kaddr + (bh_result->b_size * iblock), + buffer_cache_bh->b_data, + bh_result->b_size); + kunmap_atomic(kaddr, KM_USER0); + set_buffer_uptodate(bh_result); + } + brelse(buffer_cache_bh); + } + + map_bh(bh_result, inode->i_sb, + le64_to_cpu(fe->id2.i_list.l_recs[0].e_blkno) + iblock); + + err = 0; + +bail: + if (bh) + brelse(bh); + + mlog_exit(err); + return err; +} + +static int ocfs2_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create) +{ + int err = 0; + u64 p_blkno, past_eof; + + mlog_entry("(0x%p, %llu, 0x%p, %d)\n", inode, + (unsigned long long)iblock, bh_result, create); + + if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE) + mlog(ML_NOTICE, "get_block on system inode 0x%p (%lu)\n", + inode, inode->i_ino); + + if (S_ISLNK(inode->i_mode)) { + /* this always does I/O for some reason. */ + err = ocfs2_symlink_get_block(inode, iblock, bh_result, create); + goto bail; + } + + /* this can happen if another node truncs after our extend! */ + spin_lock(&OCFS2_I(inode)->ip_lock); + if (iblock >= ocfs2_clusters_to_blocks(inode->i_sb, + OCFS2_I(inode)->ip_clusters)) + err = -EIO; + spin_unlock(&OCFS2_I(inode)->ip_lock); + if (err) + goto bail; + + err = ocfs2_extent_map_get_blocks(inode, iblock, 1, &p_blkno, + NULL); + if (err) { + mlog(ML_ERROR, "Error %d from get_blocks(0x%p, %llu, 1, " + "%"MLFu64", NULL)\n", err, inode, + (unsigned long long)iblock, p_blkno); + goto bail; + } + + map_bh(bh_result, inode->i_sb, p_blkno); + + if (bh_result->b_blocknr == 0) { + err = -EIO; + mlog(ML_ERROR, "iblock = %llu p_blkno = %"MLFu64" " + "blkno=(%"MLFu64")\n", (unsigned long long)iblock, + p_blkno, OCFS2_I(inode)->ip_blkno); + } + + past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); + mlog(0, "Inode %lu, past_eof = %"MLFu64"\n", inode->i_ino, past_eof); + + if (create && (iblock >= past_eof)) + set_buffer_new(bh_result); + +bail: + if (err < 0) + err = -EIO; + + mlog_exit(err); + return err; +} + +static int ocfs2_readpage(struct file *file, struct page *page) +{ + struct inode *inode = page->mapping->host; + loff_t start = (loff_t)page->index << PAGE_CACHE_SHIFT; + int ret, unlock = 1; + + mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0)); + + ret = ocfs2_meta_lock_with_page(inode, NULL, NULL, 0, page); + if (ret != 0) { + if (ret == AOP_TRUNCATED_PAGE) + unlock = 0; + mlog_errno(ret); + goto out; + } + + down_read(&OCFS2_I(inode)->ip_alloc_sem); + + /* + * i_size might have just been updated as we grabed the meta lock. We + * might now be discovering a truncate that hit on another node. + * block_read_full_page->get_block freaks out if it is asked to read + * beyond the end of a file, so we check here. Callers + * (generic_file_read, fault->nopage) are clever enough to check i_size + * and notice that the page they just read isn't needed. + * + * XXX sys_readahead() seems to get that wrong? + */ + if (start >= i_size_read(inode)) { + char *addr = kmap(page); + memset(addr, 0, PAGE_SIZE); + flush_dcache_page(page); + kunmap(page); + SetPageUptodate(page); + ret = 0; + goto out_alloc; + } + + ret = ocfs2_data_lock_with_page(inode, 0, page); + if (ret != 0) { + if (ret == AOP_TRUNCATED_PAGE) + unlock = 0; + mlog_errno(ret); + goto out_alloc; + } + + ret = block_read_full_page(page, ocfs2_get_block); + unlock = 0; + + ocfs2_data_unlock(inode, 0); +out_alloc: + up_read(&OCFS2_I(inode)->ip_alloc_sem); + ocfs2_meta_unlock(inode, 0); +out: + if (unlock) + unlock_page(page); + mlog_exit(ret); + return ret; +} + +/* Note: Because we don't support holes, our allocation has + * already happened (allocation writes zeros to the file data) + * so we don't have to worry about ordered writes in + * ocfs2_writepage. + * + * ->writepage is called during the process of invalidating the page cache + * during blocked lock processing. It can't block on any cluster locks + * to during block mapping. It's relying on the fact that the block + * mapping can't have disappeared under the dirty pages that it is + * being asked to write back. + */ +static int ocfs2_writepage(struct page *page, struct writeback_control *wbc) +{ + int ret; + + mlog_entry("(0x%p)\n", page); + + ret = block_write_full_page(page, ocfs2_get_block, wbc); + + mlog_exit(ret); + + return ret; +} + +/* + * ocfs2_prepare_write() can be an outer-most ocfs2 call when it is called + * from loopback. It must be able to perform its own locking around + * ocfs2_get_block(). + */ +int ocfs2_prepare_write(struct file *file, struct page *page, + unsigned from, unsigned to) +{ + struct inode *inode = page->mapping->host; + int ret; + + mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); + + ret = ocfs2_meta_lock_with_page(inode, NULL, NULL, 0, page); + if (ret != 0) { + mlog_errno(ret); + goto out; + } + + down_read(&OCFS2_I(inode)->ip_alloc_sem); + + ret = block_prepare_write(page, from, to, ocfs2_get_block); + + up_read(&OCFS2_I(inode)->ip_alloc_sem); + + ocfs2_meta_unlock(inode, 0); +out: + mlog_exit(ret); + return ret; +} + +/* Taken from ext3. We don't necessarily need the full blown + * functionality yet, but IMHO it's better to cut and paste the whole + * thing so we can avoid introducing our own bugs (and easily pick up + * their fixes when they happen) --Mark */ +static int walk_page_buffers( handle_t *handle, + struct buffer_head *head, + unsigned from, + unsigned to, + int *partial, + int (*fn)( handle_t *handle, + struct buffer_head *bh)) +{ + struct buffer_head *bh; + unsigned block_start, block_end; + unsigned blocksize = head->b_size; + int err, ret = 0; + struct buffer_head *next; + + for ( bh = head, block_start = 0; + ret == 0 && (bh != head || !block_start); + block_start = block_end, bh = next) + { + next = bh->b_this_page; + block_end = block_start + blocksize; + if (block_end <= from || block_start >= to) { + if (partial && !buffer_uptodate(bh)) + *partial = 1; + continue; + } + err = (*fn)(handle, bh); + if (!ret) + ret = err; + } + return ret; +} + +struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, + struct page *page, + unsigned from, + unsigned to) +{ + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_journal_handle *handle = NULL; + int ret = 0; + + handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); + if (!handle) { + ret = -ENOMEM; + mlog_errno(ret); + goto out; + } + + if (ocfs2_should_order_data(inode)) { + ret = walk_page_buffers(handle->k_handle, + page_buffers(page), + from, to, NULL, + ocfs2_journal_dirty_data); + if (ret < 0) + mlog_errno(ret); + } +out: + if (ret) { + if (handle) + ocfs2_commit_trans(handle); + handle = ERR_PTR(ret); + } + return handle; +} + +static int ocfs2_commit_write(struct file *file, struct page *page, + unsigned from, unsigned to) +{ + int ret, extending = 0, locklevel = 0; + loff_t new_i_size; + struct buffer_head *di_bh = NULL; + struct inode *inode = page->mapping->host; + struct ocfs2_journal_handle *handle = NULL; + + mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); + + /* NOTE: ocfs2_file_aio_write has ensured that it's safe for + * us to sample inode->i_size here without the metadata lock: + * + * 1) We're currently holding the inode alloc lock, so no + * nodes can change it underneath us. + * + * 2) We've had to take the metadata lock at least once + * already to check for extending writes, hence insuring + * that our current copy is also up to date. + */ + new_i_size = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to; + if (new_i_size > i_size_read(inode)) { + extending = 1; + locklevel = 1; + } + + ret = ocfs2_meta_lock_with_page(inode, NULL, &di_bh, locklevel, page); + if (ret != 0) { + mlog_errno(ret); + goto out; + } + + ret = ocfs2_data_lock_with_page(inode, 1, page); + if (ret != 0) { + mlog_errno(ret); + goto out_unlock_meta; + } + + if (extending) { + handle = ocfs2_start_walk_page_trans(inode, page, from, to); + if (IS_ERR(handle)) { + ret = PTR_ERR(handle); + handle = NULL; + goto out_unlock_data; + } + + /* Mark our buffer early. We'd rather catch this error up here + * as opposed to after a successful commit_write which would + * require us to set back inode->i_size. */ + ret = ocfs2_journal_access(handle, inode, di_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (ret < 0) { + mlog_errno(ret); + goto out_commit; + } + } + + /* might update i_size */ + ret = generic_commit_write(file, page, from, to); + if (ret < 0) { + mlog_errno(ret); + goto out_commit; + } + + if (extending) { + loff_t size = (u64) i_size_read(inode); + struct ocfs2_dinode *di = + (struct ocfs2_dinode *)di_bh->b_data; + + /* ocfs2_mark_inode_dirty is too heavy to use here. */ + inode->i_blocks = ocfs2_align_bytes_to_sectors(size); + inode->i_ctime = inode->i_mtime = CURRENT_TIME; + + di->i_size = cpu_to_le64(size); + di->i_ctime = di->i_mtime = + cpu_to_le64(inode->i_mtime.tv_sec); + di->i_ctime_nsec = di->i_mtime_nsec = + cpu_to_le32(inode->i_mtime.tv_nsec); + + ret = ocfs2_journal_dirty(handle, di_bh); + if (ret < 0) { + mlog_errno(ret); + goto out_commit; + } + } + + BUG_ON(extending && (i_size_read(inode) != new_i_size)); + +out_commit: + if (handle) + ocfs2_commit_trans(handle); +out_unlock_data: + ocfs2_data_unlock(inode, 1); +out_unlock_meta: + ocfs2_meta_unlock(inode, locklevel); +out: + if (di_bh) + brelse(di_bh); + + mlog_exit(ret); + return ret; +} + +static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) +{ + sector_t status; + u64 p_blkno = 0; + int err = 0; + struct inode *inode = mapping->host; + + mlog_entry("(block = %llu)\n", (unsigned long long)block); + + /* We don't need to lock journal system files, since they aren't + * accessed concurrently from multiple nodes. + */ + if (!INODE_JOURNAL(inode)) { + err = ocfs2_meta_lock(inode, NULL, NULL, 0); + if (err) { + if (err != -ENOENT) + mlog_errno(err); + goto bail; + } + down_read(&OCFS2_I(inode)->ip_alloc_sem); + } + + err = ocfs2_extent_map_get_blocks(inode, block, 1, &p_blkno, + NULL); + + if (!INODE_JOURNAL(inode)) { + up_read(&OCFS2_I(inode)->ip_alloc_sem); + ocfs2_meta_unlock(inode, 0); + } + + if (err) { + mlog(ML_ERROR, "get_blocks() failed, block = %llu\n", + (unsigned long long)block); + mlog_errno(err); + goto bail; + } + + +bail: + status = err ? 0 : p_blkno; + + mlog_exit((int)status); + + return status; +} + +/* + * TODO: Make this into a generic get_blocks function. + * + * From do_direct_io in direct-io.c: + * "So what we do is to permit the ->get_blocks function to populate + * bh.b_size with the size of IO which is permitted at this offset and + * this i_blkbits." + * + * This function is called directly from get_more_blocks in direct-io.c. + * + * called like this: dio->get_blocks(dio->inode, fs_startblk, + * fs_count, map_bh, dio->rw == WRITE); + */ +static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, + unsigned long max_blocks, + struct buffer_head *bh_result, int create) +{ + int ret; + u64 vbo_max; /* file offset, max_blocks from iblock */ + u64 p_blkno; + int contig_blocks; + unsigned char blocksize_bits; + + if (!inode || !bh_result) { + mlog(ML_ERROR, "inode or bh_result is null\n"); + return -EIO; + } + + blocksize_bits = inode->i_sb->s_blocksize_bits; + + /* This function won't even be called if the request isn't all + * nicely aligned and of the right size, so there's no need + * for us to check any of that. */ + + vbo_max = ((u64)iblock + max_blocks) << blocksize_bits; + + spin_lock(&OCFS2_I(inode)->ip_lock); + if ((iblock + max_blocks) > + ocfs2_clusters_to_blocks(inode->i_sb, + OCFS2_I(inode)->ip_clusters)) { + spin_unlock(&OCFS2_I(inode)->ip_lock); + ret = -EIO; + goto bail; + } + spin_unlock(&OCFS2_I(inode)->ip_lock); + + /* This figures out the size of the next contiguous block, and + * our logical offset */ + ret = ocfs2_extent_map_get_blocks(inode, iblock, 1, &p_blkno, + &contig_blocks); + if (ret) { + mlog(ML_ERROR, "get_blocks() failed iblock=%llu\n", + (unsigned long long)iblock); + ret = -EIO; + goto bail; + } + + map_bh(bh_result, inode->i_sb, p_blkno); + + /* make sure we don't map more than max_blocks blocks here as + that's all the kernel will handle at this point. */ + if (max_blocks < contig_blocks) + contig_blocks = max_blocks; + bh_result->b_size = contig_blocks << blocksize_bits; +bail: + return ret; +} + +/* + * ocfs2_dio_end_io is called by the dio core when a dio is finished. We're + * particularly interested in the aio/dio case. Like the core uses + * i_alloc_sem, we use the rw_lock DLM lock to protect io on one node from + * truncation on another. + */ +static void ocfs2_dio_end_io(struct kiocb *iocb, + loff_t offset, + ssize_t bytes, + void *private) +{ + struct inode *inode = iocb->ki_filp->f_dentry->d_inode; + + /* this io's submitter should not have unlocked this before we could */ + BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); + ocfs2_iocb_clear_rw_locked(iocb); + up_read(&inode->i_alloc_sem); + ocfs2_rw_unlock(inode, 0); +} + +static ssize_t ocfs2_direct_IO(int rw, + struct kiocb *iocb, + const struct iovec *iov, + loff_t offset, + unsigned long nr_segs) +{ + struct file *file = iocb->ki_filp; + struct inode *inode = file->f_dentry->d_inode->i_mapping->host; + int ret; + + mlog_entry_void(); + ret = blockdev_direct_IO_no_locking(rw, iocb, inode, + inode->i_sb->s_bdev, iov, offset, + nr_segs, + ocfs2_direct_IO_get_blocks, + ocfs2_dio_end_io); + mlog_exit(ret); + return ret; +} + +struct address_space_operations ocfs2_aops = { + .readpage = ocfs2_readpage, + .writepage = ocfs2_writepage, + .prepare_write = ocfs2_prepare_write, + .commit_write = ocfs2_commit_write, + .bmap = ocfs2_bmap, + .sync_page = block_sync_page, + .direct_IO = ocfs2_direct_IO +}; diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h new file mode 100644 index 0000000..d40456d --- /dev/null +++ b/fs/ocfs2/aops.h @@ -0,0 +1,41 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2002, 2004, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_AOPS_H +#define OCFS2_AOPS_H + +int ocfs2_prepare_write(struct file *file, struct page *page, + unsigned from, unsigned to); + +struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, + struct page *page, + unsigned from, + unsigned to); + +/* all ocfs2_dio_end_io()'s fault */ +#define ocfs2_iocb_is_rw_locked(iocb) \ + test_bit(0, (unsigned long *)&iocb->private) +#define ocfs2_iocb_set_rw_locked(iocb) \ + set_bit(0, (unsigned long *)&iocb->private) +#define ocfs2_iocb_clear_rw_locked(iocb) \ + clear_bit(0, (unsigned long *)&iocb->private) + +#endif /* OCFS2_FILE_H */ diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c new file mode 100644 index 0000000..d424041 --- /dev/null +++ b/fs/ocfs2/buffer_head_io.c @@ -0,0 +1,232 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * io.c + * + * Buffer cache handling + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "inode.h" +#include "journal.h" +#include "uptodate.h" + +#include "buffer_head_io.h" + +int ocfs2_write_block(struct ocfs2_super *osb, struct buffer_head *bh, + struct inode *inode) +{ + int ret = 0; + + mlog_entry("(bh->b_blocknr = %llu, inode=%p)\n", + (unsigned long long)bh->b_blocknr, inode); + + BUG_ON(bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO); + BUG_ON(buffer_jbd(bh)); + + /* No need to check for a soft readonly file system here. non + * journalled writes are only ever done on system files which + * can get modified during recovery even if read-only. */ + if (ocfs2_is_hard_readonly(osb)) { + ret = -EROFS; + goto out; + } + + down(&OCFS2_I(inode)->ip_io_sem); + + lock_buffer(bh); + set_buffer_uptodate(bh); + + /* remove from dirty list before I/O. */ + clear_buffer_dirty(bh); + + get_bh(bh); /* for end_buffer_write_sync() */ + bh->b_end_io = end_buffer_write_sync; + submit_bh(WRITE, bh); + + wait_on_buffer(bh); + + if (buffer_uptodate(bh)) { + ocfs2_set_buffer_uptodate(inode, bh); + } else { + /* We don't need to remove the clustered uptodate + * information for this bh as it's not marked locally + * uptodate. */ + ret = -EIO; + brelse(bh); + } + + up(&OCFS2_I(inode)->ip_io_sem); +out: + mlog_exit(ret); + return ret; +} + +int ocfs2_read_blocks(struct ocfs2_super *osb, u64 block, int nr, + struct buffer_head *bhs[], int flags, + struct inode *inode) +{ + int status = 0; + struct super_block *sb; + int i, ignore_cache = 0; + struct buffer_head *bh; + + mlog_entry("(block=(%"MLFu64"), nr=(%d), flags=%d, inode=%p)\n", + block, nr, flags, inode); + + if (osb == NULL || osb->sb == NULL || bhs == NULL) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + if (nr < 0) { + mlog(ML_ERROR, "asked to read %d blocks!\n", nr); + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + if (nr == 0) { + mlog(ML_BH_IO, "No buffers will be read!\n"); + status = 0; + goto bail; + } + + sb = osb->sb; + + if (flags & OCFS2_BH_CACHED && !inode) + flags &= ~OCFS2_BH_CACHED; + + if (inode) + down(&OCFS2_I(inode)->ip_io_sem); + for (i = 0 ; i < nr ; i++) { + if (bhs[i] == NULL) { + bhs[i] = sb_getblk(sb, block++); + if (bhs[i] == NULL) { + if (inode) + up(&OCFS2_I(inode)->ip_io_sem); + status = -EIO; + mlog_errno(status); + goto bail; + } + } + bh = bhs[i]; + ignore_cache = 0; + + if (flags & OCFS2_BH_CACHED && + !ocfs2_buffer_uptodate(inode, bh)) { + mlog(ML_UPTODATE, + "bh (%llu), inode %"MLFu64" not uptodate\n", + (unsigned long long)bh->b_blocknr, + OCFS2_I(inode)->ip_blkno); + ignore_cache = 1; + } + + /* XXX: Can we ever get this and *not* have the cached + * flag set? */ + if (buffer_jbd(bh)) { + if (!(flags & OCFS2_BH_CACHED) || ignore_cache) + mlog(ML_BH_IO, "trying to sync read a jbd " + "managed bh (blocknr = %llu)\n", + (unsigned long long)bh->b_blocknr); + continue; + } + + if (!(flags & OCFS2_BH_CACHED) || ignore_cache) { + if (buffer_dirty(bh)) { + /* This should probably be a BUG, or + * at least return an error. */ + mlog(ML_BH_IO, "asking me to sync read a dirty " + "buffer! (blocknr = %llu)\n", + (unsigned long long)bh->b_blocknr); + continue; + } + + lock_buffer(bh); + if (buffer_jbd(bh)) { +#ifdef CATCH_BH_JBD_RACES + mlog(ML_ERROR, "block %llu had the JBD bit set " + "while I was in lock_buffer!", + (unsigned long long)bh->b_blocknr); + BUG(); +#else + unlock_buffer(bh); + continue; +#endif + } + clear_buffer_uptodate(bh); + get_bh(bh); /* for end_buffer_read_sync() */ + bh->b_end_io = end_buffer_read_sync; + if (flags & OCFS2_BH_READAHEAD) + submit_bh(READA, bh); + else + submit_bh(READ, bh); + continue; + } + } + + status = 0; + + for (i = (nr - 1); i >= 0; i--) { + bh = bhs[i]; + + /* We know this can't have changed as we hold the + * inode sem. Avoid doing any work on the bh if the + * journal has it. */ + if (!buffer_jbd(bh)) + wait_on_buffer(bh); + + if (!buffer_uptodate(bh)) { + /* Status won't be cleared from here on out, + * so we can safely record this and loop back + * to cleanup the other buffers. Don't need to + * remove the clustered uptodate information + * for this bh as it's not marked locally + * uptodate. */ + status = -EIO; + brelse(bh); + bhs[i] = NULL; + continue; + } + + if (inode) + ocfs2_set_buffer_uptodate(inode, bh); + } + if (inode) + up(&OCFS2_I(inode)->ip_io_sem); + + mlog(ML_BH_IO, "block=(%"MLFu64"), nr=(%d), cached=%s\n", block, nr, + (!(flags & OCFS2_BH_CACHED) || ignore_cache) ? "no" : "yes"); + +bail: + + mlog_exit(status); + return status; +} diff --git a/fs/ocfs2/buffer_head_io.h b/fs/ocfs2/buffer_head_io.h new file mode 100644 index 0000000..6ecb909 --- /dev/null +++ b/fs/ocfs2/buffer_head_io.h @@ -0,0 +1,73 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ocfs2_buffer_head.h + * + * Buffer cache handling functions defined + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_BUFFER_HEAD_IO_H +#define OCFS2_BUFFER_HEAD_IO_H + +#include + +void ocfs2_end_buffer_io_sync(struct buffer_head *bh, + int uptodate); + +static inline int ocfs2_read_block(struct ocfs2_super *osb, + u64 off, + struct buffer_head **bh, + int flags, + struct inode *inode); + +int ocfs2_write_block(struct ocfs2_super *osb, + struct buffer_head *bh, + struct inode *inode); +int ocfs2_read_blocks(struct ocfs2_super *osb, + u64 block, + int nr, + struct buffer_head *bhs[], + int flags, + struct inode *inode); + + +#define OCFS2_BH_CACHED 1 +#define OCFS2_BH_READAHEAD 8 /* use this to pass READA down to submit_bh */ + +static inline int ocfs2_read_block(struct ocfs2_super * osb, u64 off, + struct buffer_head **bh, int flags, + struct inode *inode) +{ + int status = 0; + + if (bh == NULL) { + printk("ocfs2: bh == NULL\n"); + status = -EINVAL; + goto bail; + } + + status = ocfs2_read_blocks(osb, off, 1, bh, + flags, inode); + +bail: + return status; +} + +#endif /* OCFS2_BUFFER_HEAD_IO_H */ diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c new file mode 100644 index 0000000..bd85182 --- /dev/null +++ b/fs/ocfs2/dcache.c @@ -0,0 +1,91 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dcache.c + * + * dentry cache handling code + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_DCACHE +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dcache.h" +#include "file.h" +#include "inode.h" + +static int ocfs2_dentry_revalidate(struct dentry *dentry, + struct nameidata *nd) +{ + struct inode *inode = dentry->d_inode; + int ret = 0; /* if all else fails, just return false */ + struct ocfs2_super *osb; + + mlog_entry("(0x%p, '%.*s')\n", dentry, + dentry->d_name.len, dentry->d_name.name); + + /* Never trust a negative dentry - force a new lookup. */ + if (inode == NULL) { + mlog(0, "negative dentry: %.*s\n", dentry->d_name.len, + dentry->d_name.name); + goto bail; + } + + osb = OCFS2_SB(inode->i_sb); + + BUG_ON(!osb); + + if (inode != osb->root_inode) { + spin_lock(&OCFS2_I(inode)->ip_lock); + /* did we or someone else delete this inode? */ + if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { + spin_unlock(&OCFS2_I(inode)->ip_lock); + mlog(0, "inode (%"MLFu64") deleted, returning false\n", + OCFS2_I(inode)->ip_blkno); + goto bail; + } + spin_unlock(&OCFS2_I(inode)->ip_lock); + + if (!inode->i_nlink) { + mlog(0, "Inode %"MLFu64" orphaned, returning false " + "dir = %d\n", OCFS2_I(inode)->ip_blkno, + S_ISDIR(inode->i_mode)); + goto bail; + } + } + + ret = 1; + +bail: + mlog_exit(ret); + + return ret; +} + +struct dentry_operations ocfs2_dentry_ops = { + .d_revalidate = ocfs2_dentry_revalidate, +}; diff --git a/fs/ocfs2/dcache.h b/fs/ocfs2/dcache.h new file mode 100644 index 0000000..9007277 --- /dev/null +++ b/fs/ocfs2/dcache.h @@ -0,0 +1,31 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dcache.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_DCACHE_H +#define OCFS2_DCACHE_H + +extern struct dentry_operations ocfs2_dentry_ops; + +#endif /* OCFS2_DCACHE_H */ diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c new file mode 100644 index 0000000..856e20a --- /dev/null +++ b/fs/ocfs2/dir.c @@ -0,0 +1,618 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dir.c + * + * Creates, reads, walks and deletes directory-nodes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * Portions of this code from linux/fs/ext3/dir.c + * + * Copyright (C) 1992, 1993, 1994, 1995 + * Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * from + * + * linux/fs/minix/dir.c + * + * Copyright (C) 1991, 1992 Linux Torvalds + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_NAMEI +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dir.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "file.h" +#include "inode.h" +#include "journal.h" +#include "namei.h" +#include "suballoc.h" +#include "uptodate.h" + +#include "buffer_head_io.h" + +static unsigned char ocfs2_filetype_table[] = { + DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK +}; + +static int ocfs2_extend_dir(struct ocfs2_super *osb, + struct inode *dir, + struct buffer_head *parent_fe_bh, + struct buffer_head **new_de_bh); +/* + * ocfs2_readdir() + * + */ +int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir) +{ + int error = 0; + unsigned long offset, blk; + int i, num, stored; + struct buffer_head * bh, * tmp; + struct ocfs2_dir_entry * de; + int err; + struct inode *inode = filp->f_dentry->d_inode; + struct super_block * sb = inode->i_sb; + int have_disk_lock = 0; + + mlog_entry("dirino=%"MLFu64"\n", OCFS2_I(inode)->ip_blkno); + + stored = 0; + bh = NULL; + + error = ocfs2_meta_lock(inode, NULL, NULL, 0); + if (error < 0) { + if (error != -ENOENT) + mlog_errno(error); + /* we haven't got any yet, so propagate the error. */ + stored = error; + goto bail; + } + have_disk_lock = 1; + + offset = filp->f_pos & (sb->s_blocksize - 1); + + while (!error && !stored && filp->f_pos < i_size_read(inode)) { + blk = (filp->f_pos) >> sb->s_blocksize_bits; + bh = ocfs2_bread(inode, blk, &err, 0); + if (!bh) { + mlog(ML_ERROR, "directory #%"MLFu64" contains a hole " + "at offset %lld\n", + OCFS2_I(inode)->ip_blkno, + filp->f_pos); + filp->f_pos += sb->s_blocksize - offset; + continue; + } + + /* + * Do the readahead (8k) + */ + if (!offset) { + for (i = 16 >> (sb->s_blocksize_bits - 9), num = 0; + i > 0; i--) { + tmp = ocfs2_bread(inode, ++blk, &err, 1); + if (tmp) + brelse(tmp); + } + } + +revalidate: + /* If the dir block has changed since the last call to + * readdir(2), then we might be pointing to an invalid + * dirent right now. Scan from the start of the block + * to make sure. */ + if (filp->f_version != inode->i_version) { + for (i = 0; i < sb->s_blocksize && i < offset; ) { + de = (struct ocfs2_dir_entry *) (bh->b_data + i); + /* It's too expensive to do a full + * dirent test each time round this + * loop, but we do have to test at + * least that it is non-zero. A + * failure will be detected in the + * dirent test below. */ + if (le16_to_cpu(de->rec_len) < + OCFS2_DIR_REC_LEN(1)) + break; + i += le16_to_cpu(de->rec_len); + } + offset = i; + filp->f_pos = (filp->f_pos & ~(sb->s_blocksize - 1)) + | offset; + filp->f_version = inode->i_version; + } + + while (!error && filp->f_pos < i_size_read(inode) + && offset < sb->s_blocksize) { + de = (struct ocfs2_dir_entry *) (bh->b_data + offset); + if (!ocfs2_check_dir_entry(inode, de, bh, offset)) { + /* On error, skip the f_pos to the + next block. */ + filp->f_pos = (filp->f_pos | + (sb->s_blocksize - 1)) + 1; + brelse(bh); + goto bail; + } + offset += le16_to_cpu(de->rec_len); + if (le64_to_cpu(de->inode)) { + /* We might block in the next section + * if the data destination is + * currently swapped out. So, use a + * version stamp to detect whether or + * not the directory has been modified + * during the copy operation. + */ + unsigned long version = filp->f_version; + unsigned char d_type = DT_UNKNOWN; + + if (de->file_type < OCFS2_FT_MAX) + d_type = ocfs2_filetype_table[de->file_type]; + error = filldir(dirent, de->name, + de->name_len, + filp->f_pos, + ino_from_blkno(sb, le64_to_cpu(de->inode)), + d_type); + if (error) + break; + if (version != filp->f_version) + goto revalidate; + stored ++; + } + filp->f_pos += le16_to_cpu(de->rec_len); + } + offset = 0; + brelse(bh); + } + + stored = 0; +bail: + if (have_disk_lock) + ocfs2_meta_unlock(inode, 0); + + mlog_exit(stored); + + return stored; +} + +/* + * NOTE: this should always be called with parent dir i_sem taken. + */ +int ocfs2_find_files_on_disk(const char *name, + int namelen, + u64 *blkno, + struct inode *inode, + struct buffer_head **dirent_bh, + struct ocfs2_dir_entry **dirent) +{ + int status = -ENOENT; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + mlog_entry("(osb=%p, parent=%"MLFu64", name='%.*s', blkno=%p, " + "inode=%p)\n", + osb, OCFS2_I(inode)->ip_blkno, namelen, name, blkno, inode); + + *dirent_bh = ocfs2_find_entry(name, namelen, inode, dirent); + if (!*dirent_bh || !*dirent) { + status = -ENOENT; + goto leave; + } + + *blkno = le64_to_cpu((*dirent)->inode); + + status = 0; +leave: + if (status < 0) { + *dirent = NULL; + if (*dirent_bh) { + brelse(*dirent_bh); + *dirent_bh = NULL; + } + } + + mlog_exit(status); + return status; +} + +/* Check for a name within a directory. + * + * Return 0 if the name does not exist + * Return -EEXIST if the directory contains the name + * + * Callers should have i_sem + a cluster lock on dir + */ +int ocfs2_check_dir_for_entry(struct inode *dir, + const char *name, + int namelen) +{ + int ret; + struct buffer_head *dirent_bh = NULL; + struct ocfs2_dir_entry *dirent = NULL; + + mlog_entry("dir %"MLFu64", name '%.*s'\n", OCFS2_I(dir)->ip_blkno, + namelen, name); + + ret = -EEXIST; + dirent_bh = ocfs2_find_entry(name, namelen, dir, &dirent); + if (dirent_bh) + goto bail; + + ret = 0; +bail: + if (dirent_bh) + brelse(dirent_bh); + + mlog_exit(ret); + return ret; +} + +/* + * routine to check that the specified directory is empty (for rmdir) + */ +int ocfs2_empty_dir(struct inode *inode) +{ + unsigned long offset; + struct buffer_head * bh; + struct ocfs2_dir_entry * de, * de1; + struct super_block * sb; + int err; + + sb = inode->i_sb; + if ((i_size_read(inode) < + (OCFS2_DIR_REC_LEN(1) + OCFS2_DIR_REC_LEN(2))) || + !(bh = ocfs2_bread(inode, 0, &err, 0))) { + mlog(ML_ERROR, "bad directory (dir #%"MLFu64") - " + "no data block\n", + OCFS2_I(inode)->ip_blkno); + return 1; + } + + de = (struct ocfs2_dir_entry *) bh->b_data; + de1 = (struct ocfs2_dir_entry *) + ((char *)de + le16_to_cpu(de->rec_len)); + if ((le64_to_cpu(de->inode) != OCFS2_I(inode)->ip_blkno) || + !le64_to_cpu(de1->inode) || + strcmp(".", de->name) || + strcmp("..", de1->name)) { + mlog(ML_ERROR, "bad directory (dir #%"MLFu64") - " + "no `.' or `..'\n", + OCFS2_I(inode)->ip_blkno); + brelse(bh); + return 1; + } + offset = le16_to_cpu(de->rec_len) + le16_to_cpu(de1->rec_len); + de = (struct ocfs2_dir_entry *)((char *)de1 + le16_to_cpu(de1->rec_len)); + while (offset < i_size_read(inode) ) { + if (!bh || (void *)de >= (void *)(bh->b_data + sb->s_blocksize)) { + brelse(bh); + bh = ocfs2_bread(inode, + offset >> sb->s_blocksize_bits, &err, 0); + if (!bh) { + mlog(ML_ERROR, "directory #%"MLFu64" contains " + "a hole at offset %lu\n", + OCFS2_I(inode)->ip_blkno, offset); + offset += sb->s_blocksize; + continue; + } + de = (struct ocfs2_dir_entry *) bh->b_data; + } + if (!ocfs2_check_dir_entry(inode, de, bh, offset)) { + brelse(bh); + return 1; + } + if (le64_to_cpu(de->inode)) { + brelse(bh); + return 0; + } + offset += le16_to_cpu(de->rec_len); + de = (struct ocfs2_dir_entry *) + ((char *)de + le16_to_cpu(de->rec_len)); + } + brelse(bh); + return 1; +} + +/* returns a bh of the 1st new block in the allocation. */ +int ocfs2_do_extend_dir(struct super_block *sb, + struct ocfs2_journal_handle *handle, + struct inode *dir, + struct buffer_head *parent_fe_bh, + struct ocfs2_alloc_context *data_ac, + struct ocfs2_alloc_context *meta_ac, + struct buffer_head **new_bh) +{ + int status; + int extend; + u64 p_blkno; + + spin_lock(&OCFS2_I(dir)->ip_lock); + extend = (i_size_read(dir) == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)); + spin_unlock(&OCFS2_I(dir)->ip_lock); + + if (extend) { + status = ocfs2_do_extend_allocation(OCFS2_SB(sb), dir, 1, + parent_fe_bh, handle, + data_ac, meta_ac, NULL); + BUG_ON(status == -EAGAIN); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + status = ocfs2_extent_map_get_blocks(dir, (dir->i_blocks >> + (sb->s_blocksize_bits - 9)), + 1, &p_blkno, NULL); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + *new_bh = sb_getblk(sb, p_blkno); + if (!*new_bh) { + status = -EIO; + mlog_errno(status); + goto bail; + } + status = 0; +bail: + mlog_exit(status); + return status; +} + +/* assumes you already have a cluster lock on the directory. */ +static int ocfs2_extend_dir(struct ocfs2_super *osb, + struct inode *dir, + struct buffer_head *parent_fe_bh, + struct buffer_head **new_de_bh) +{ + int status = 0; + int credits, num_free_extents; + loff_t dir_i_size; + struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data; + struct ocfs2_alloc_context *data_ac = NULL; + struct ocfs2_alloc_context *meta_ac = NULL; + struct ocfs2_journal_handle *handle = NULL; + struct buffer_head *new_bh = NULL; + struct ocfs2_dir_entry * de; + struct super_block *sb = osb->sb; + + mlog_entry_void(); + + dir_i_size = i_size_read(dir); + mlog(0, "extending dir %"MLFu64" (i_size = %lld)\n", + OCFS2_I(dir)->ip_blkno, dir_i_size); + + handle = ocfs2_alloc_handle(osb); + if (handle == NULL) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + /* dir->i_size is always block aligned. */ + spin_lock(&OCFS2_I(dir)->ip_lock); + if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { + spin_unlock(&OCFS2_I(dir)->ip_lock); + num_free_extents = ocfs2_num_free_extents(osb, dir, fe); + if (num_free_extents < 0) { + status = num_free_extents; + mlog_errno(status); + goto bail; + } + + if (!num_free_extents) { + status = ocfs2_reserve_new_metadata(osb, handle, + fe, &meta_ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + } + + status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + credits = ocfs2_calc_extend_credits(sb, fe, 1); + } else { + spin_unlock(&OCFS2_I(dir)->ip_lock); + credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS; + } + + handle = ocfs2_start_trans(osb, handle, credits); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + status = ocfs2_do_extend_dir(osb->sb, handle, dir, parent_fe_bh, + data_ac, meta_ac, &new_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + ocfs2_set_new_buffer_uptodate(dir, new_bh); + + status = ocfs2_journal_access(handle, dir, new_bh, + OCFS2_JOURNAL_ACCESS_CREATE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + memset(new_bh->b_data, 0, sb->s_blocksize); + de = (struct ocfs2_dir_entry *) new_bh->b_data; + de->inode = 0; + de->rec_len = cpu_to_le16(sb->s_blocksize); + status = ocfs2_journal_dirty(handle, new_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + dir_i_size += dir->i_sb->s_blocksize; + i_size_write(dir, dir_i_size); + dir->i_blocks = ocfs2_align_bytes_to_sectors(dir_i_size); + status = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + *new_de_bh = new_bh; + get_bh(*new_de_bh); +bail: + if (handle) + ocfs2_commit_trans(handle); + + if (data_ac) + ocfs2_free_alloc_context(data_ac); + if (meta_ac) + ocfs2_free_alloc_context(meta_ac); + + if (new_bh) + brelse(new_bh); + + mlog_exit(status); + return status; +} + +/* + * Search the dir for a good spot, extending it if necessary. The + * block containing an appropriate record is returned in ret_de_bh. + */ +int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, + struct inode *dir, + struct buffer_head *parent_fe_bh, + const char *name, + int namelen, + struct buffer_head **ret_de_bh) +{ + unsigned long offset; + struct buffer_head * bh = NULL; + unsigned short rec_len; + struct ocfs2_dinode *fe; + struct ocfs2_dir_entry *de; + struct super_block *sb; + int status; + + mlog_entry_void(); + + mlog(0, "getting ready to insert namelen %d into dir %"MLFu64"\n", + namelen, OCFS2_I(dir)->ip_blkno); + + BUG_ON(!S_ISDIR(dir->i_mode)); + fe = (struct ocfs2_dinode *) parent_fe_bh->b_data; + BUG_ON(le64_to_cpu(fe->i_size) != i_size_read(dir)); + + sb = dir->i_sb; + + if (!namelen) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + bh = ocfs2_bread(dir, 0, &status, 0); + if (!bh) { + mlog_errno(status); + goto bail; + } + + rec_len = OCFS2_DIR_REC_LEN(namelen); + offset = 0; + de = (struct ocfs2_dir_entry *) bh->b_data; + while (1) { + if ((char *)de >= sb->s_blocksize + bh->b_data) { + brelse(bh); + bh = NULL; + + if (i_size_read(dir) <= offset) { + status = ocfs2_extend_dir(osb, + dir, + parent_fe_bh, + &bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + BUG_ON(!bh); + *ret_de_bh = bh; + get_bh(*ret_de_bh); + goto bail; + } + bh = ocfs2_bread(dir, + offset >> sb->s_blocksize_bits, + &status, + 0); + if (!bh) { + mlog_errno(status); + goto bail; + } + /* move to next block */ + de = (struct ocfs2_dir_entry *) bh->b_data; + } + if (!ocfs2_check_dir_entry(dir, de, bh, offset)) { + status = -ENOENT; + goto bail; + } + if (ocfs2_match(namelen, name, de)) { + status = -EEXIST; + goto bail; + } + if (((le64_to_cpu(de->inode) == 0) && + (le16_to_cpu(de->rec_len) >= rec_len)) || + (le16_to_cpu(de->rec_len) >= + (OCFS2_DIR_REC_LEN(de->name_len) + rec_len))) { + /* Ok, we found a spot. Return this bh and let + * the caller actually fill it in. */ + *ret_de_bh = bh; + get_bh(*ret_de_bh); + status = 0; + goto bail; + } + offset += le16_to_cpu(de->rec_len); + de = (struct ocfs2_dir_entry *)((char *) de + le16_to_cpu(de->rec_len)); + } + + status = 0; +bail: + if (bh) + brelse(bh); + + mlog_exit(status); + return status; +} diff --git a/fs/ocfs2/dir.h b/fs/ocfs2/dir.h new file mode 100644 index 0000000..5f614ec --- /dev/null +++ b/fs/ocfs2/dir.h @@ -0,0 +1,54 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dir.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_DIR_H +#define OCFS2_DIR_H + +int ocfs2_check_dir_for_entry(struct inode *dir, + const char *name, + int namelen); +int ocfs2_empty_dir(struct inode *inode); /* FIXME: to namei.c */ +int ocfs2_find_files_on_disk(const char *name, + int namelen, + u64 *blkno, + struct inode *inode, + struct buffer_head **dirent_bh, + struct ocfs2_dir_entry **dirent); +int ocfs2_readdir(struct file *filp, void *dirent, filldir_t filldir); +int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, + struct inode *dir, + struct buffer_head *parent_fe_bh, + const char *name, + int namelen, + struct buffer_head **ret_de_bh); +struct ocfs2_alloc_context; +int ocfs2_do_extend_dir(struct super_block *sb, + struct ocfs2_journal_handle *handle, + struct inode *dir, + struct buffer_head *parent_fe_bh, + struct ocfs2_alloc_context *data_ac, + struct ocfs2_alloc_context *meta_ac, + struct buffer_head **new_bh); +#endif /* OCFS2_DIR_H */ diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c new file mode 100644 index 0000000..e971ec2 --- /dev/null +++ b/fs/ocfs2/dlmglue.c @@ -0,0 +1,2904 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmglue.c + * + * Code which implements an OCFS2 specific interface to our DLM. + * + * Copyright (C) 2003, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#define MLOG_MASK_PREFIX ML_DLM_GLUE +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "heartbeat.h" +#include "inode.h" +#include "journal.h" +#include "slot_map.h" +#include "super.h" +#include "uptodate.h" +#include "vote.h" + +#include "buffer_head_io.h" + +struct ocfs2_mask_waiter { + struct list_head mw_item; + int mw_status; + struct completion mw_complete; + unsigned long mw_mask; + unsigned long mw_goal; +}; + +static void ocfs2_inode_ast_func(void *opaque); +static void ocfs2_inode_bast_func(void *opaque, + int level); +static void ocfs2_super_ast_func(void *opaque); +static void ocfs2_super_bast_func(void *opaque, + int level); +static void ocfs2_rename_ast_func(void *opaque); +static void ocfs2_rename_bast_func(void *opaque, + int level); + +/* so far, all locks have gotten along with the same unlock ast */ +static void ocfs2_unlock_ast_func(void *opaque, + enum dlm_status status); +static int ocfs2_do_unblock_meta(struct inode *inode, + int *requeue); +static int ocfs2_unblock_meta(struct ocfs2_lock_res *lockres, + int *requeue); +static int ocfs2_unblock_data(struct ocfs2_lock_res *lockres, + int *requeue); +static int ocfs2_unblock_inode_lock(struct ocfs2_lock_res *lockres, + int *requeue); +static int ocfs2_unblock_osb_lock(struct ocfs2_lock_res *lockres, + int *requeue); +typedef void (ocfs2_convert_worker_t)(struct ocfs2_lock_res *, int); +static int ocfs2_generic_unblock_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int *requeue, + ocfs2_convert_worker_t *worker); + +struct ocfs2_lock_res_ops { + void (*ast)(void *); + void (*bast)(void *, int); + void (*unlock_ast)(void *, enum dlm_status); + int (*unblock)(struct ocfs2_lock_res *, int *); +}; + +static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { + .ast = ocfs2_inode_ast_func, + .bast = ocfs2_inode_bast_func, + .unlock_ast = ocfs2_unlock_ast_func, + .unblock = ocfs2_unblock_inode_lock, +}; + +static struct ocfs2_lock_res_ops ocfs2_inode_meta_lops = { + .ast = ocfs2_inode_ast_func, + .bast = ocfs2_inode_bast_func, + .unlock_ast = ocfs2_unlock_ast_func, + .unblock = ocfs2_unblock_meta, +}; + +static void ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres, + int blocking); + +static struct ocfs2_lock_res_ops ocfs2_inode_data_lops = { + .ast = ocfs2_inode_ast_func, + .bast = ocfs2_inode_bast_func, + .unlock_ast = ocfs2_unlock_ast_func, + .unblock = ocfs2_unblock_data, +}; + +static struct ocfs2_lock_res_ops ocfs2_super_lops = { + .ast = ocfs2_super_ast_func, + .bast = ocfs2_super_bast_func, + .unlock_ast = ocfs2_unlock_ast_func, + .unblock = ocfs2_unblock_osb_lock, +}; + +static struct ocfs2_lock_res_ops ocfs2_rename_lops = { + .ast = ocfs2_rename_ast_func, + .bast = ocfs2_rename_bast_func, + .unlock_ast = ocfs2_unlock_ast_func, + .unblock = ocfs2_unblock_osb_lock, +}; + +static inline int ocfs2_is_inode_lock(struct ocfs2_lock_res *lockres) +{ + return lockres->l_type == OCFS2_LOCK_TYPE_META || + lockres->l_type == OCFS2_LOCK_TYPE_DATA || + lockres->l_type == OCFS2_LOCK_TYPE_RW; +} + +static inline int ocfs2_is_super_lock(struct ocfs2_lock_res *lockres) +{ + return lockres->l_type == OCFS2_LOCK_TYPE_SUPER; +} + +static inline int ocfs2_is_rename_lock(struct ocfs2_lock_res *lockres) +{ + return lockres->l_type == OCFS2_LOCK_TYPE_RENAME; +} + +static inline struct ocfs2_super *ocfs2_lock_res_super(struct ocfs2_lock_res *lockres) +{ + BUG_ON(!ocfs2_is_super_lock(lockres) + && !ocfs2_is_rename_lock(lockres)); + + return (struct ocfs2_super *) lockres->l_priv; +} + +static inline struct inode *ocfs2_lock_res_inode(struct ocfs2_lock_res *lockres) +{ + BUG_ON(!ocfs2_is_inode_lock(lockres)); + + return (struct inode *) lockres->l_priv; +} + +static int ocfs2_lock_create(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int level, + int dlm_flags); +static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres, + int wanted); +static void ocfs2_cluster_unlock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int level); +static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres); +static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres); +static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres); +static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, int level); +static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres); +static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, + int convert); +#define ocfs2_log_dlm_error(_func, _stat, _lockres) do { \ + mlog(ML_ERROR, "Dlm error \"%s\" while calling %s on " \ + "resource %s: %s\n", dlm_errname(_stat), _func, \ + _lockres->l_name, dlm_errmsg(_stat)); \ +} while (0) +static void ocfs2_vote_on_unlock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres); +static int ocfs2_meta_lock_update(struct inode *inode, + struct buffer_head **bh); +static void ocfs2_drop_osb_locks(struct ocfs2_super *osb); +static inline int ocfs2_highest_compat_lock_level(int level); +static inline int ocfs2_can_downconvert_meta_lock(struct inode *inode, + struct ocfs2_lock_res *lockres, + int new_level); + +static char *ocfs2_lock_type_strings[] = { + [OCFS2_LOCK_TYPE_META] = "Meta", + [OCFS2_LOCK_TYPE_DATA] = "Data", + [OCFS2_LOCK_TYPE_SUPER] = "Super", + [OCFS2_LOCK_TYPE_RENAME] = "Rename", + /* Need to differntiate from [R]ename.. serializing writes is the + * important job it does, anyway. */ + [OCFS2_LOCK_TYPE_RW] = "Write/Read", +}; + +static char *ocfs2_lock_type_string(enum ocfs2_lock_type type) +{ + mlog_bug_on_msg(type >= OCFS2_NUM_LOCK_TYPES, "%d\n", type); + return ocfs2_lock_type_strings[type]; +} + +static void ocfs2_build_lock_name(enum ocfs2_lock_type type, + u64 blkno, + u32 generation, + char *name) +{ + int len; + + mlog_entry_void(); + + BUG_ON(type >= OCFS2_NUM_LOCK_TYPES); + + len = snprintf(name, OCFS2_LOCK_ID_MAX_LEN, "%c%s%016"MLFx64"%08x", + ocfs2_lock_type_char(type), OCFS2_LOCK_ID_PAD, blkno, + generation); + + BUG_ON(len != (OCFS2_LOCK_ID_MAX_LEN - 1)); + + mlog(0, "built lock resource with name: %s\n", name); + + mlog_exit_void(); +} + +static spinlock_t ocfs2_dlm_tracking_lock = SPIN_LOCK_UNLOCKED; + +static void ocfs2_add_lockres_tracking(struct ocfs2_lock_res *res, + struct ocfs2_dlm_debug *dlm_debug) +{ + mlog(0, "Add tracking for lockres %s\n", res->l_name); + + spin_lock(&ocfs2_dlm_tracking_lock); + list_add(&res->l_debug_list, &dlm_debug->d_lockres_tracking); + spin_unlock(&ocfs2_dlm_tracking_lock); +} + +static void ocfs2_remove_lockres_tracking(struct ocfs2_lock_res *res) +{ + spin_lock(&ocfs2_dlm_tracking_lock); + if (!list_empty(&res->l_debug_list)) + list_del_init(&res->l_debug_list); + spin_unlock(&ocfs2_dlm_tracking_lock); +} + +static void ocfs2_lock_res_init_common(struct ocfs2_super *osb, + struct ocfs2_lock_res *res, + enum ocfs2_lock_type type, + u64 blkno, + u32 generation, + struct ocfs2_lock_res_ops *ops, + void *priv) +{ + ocfs2_build_lock_name(type, blkno, generation, res->l_name); + + res->l_type = type; + res->l_ops = ops; + res->l_priv = priv; + + res->l_level = LKM_IVMODE; + res->l_requested = LKM_IVMODE; + res->l_blocking = LKM_IVMODE; + res->l_action = OCFS2_AST_INVALID; + res->l_unlock_action = OCFS2_UNLOCK_INVALID; + + res->l_flags = OCFS2_LOCK_INITIALIZED; + + ocfs2_add_lockres_tracking(res, osb->osb_dlm_debug); +} + +void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res) +{ + /* This also clears out the lock status block */ + memset(res, 0, sizeof(struct ocfs2_lock_res)); + spin_lock_init(&res->l_lock); + init_waitqueue_head(&res->l_event); + INIT_LIST_HEAD(&res->l_blocked_list); + INIT_LIST_HEAD(&res->l_mask_waiters); +} + +void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res, + enum ocfs2_lock_type type, + struct inode *inode) +{ + struct ocfs2_lock_res_ops *ops; + + switch(type) { + case OCFS2_LOCK_TYPE_RW: + ops = &ocfs2_inode_rw_lops; + break; + case OCFS2_LOCK_TYPE_META: + ops = &ocfs2_inode_meta_lops; + break; + case OCFS2_LOCK_TYPE_DATA: + ops = &ocfs2_inode_data_lops; + break; + default: + mlog_bug_on_msg(1, "type: %d\n", type); + ops = NULL; /* thanks, gcc */ + break; + }; + + ocfs2_lock_res_init_common(OCFS2_SB(inode->i_sb), res, type, + OCFS2_I(inode)->ip_blkno, + inode->i_generation, ops, inode); +} + +static void ocfs2_super_lock_res_init(struct ocfs2_lock_res *res, + struct ocfs2_super *osb) +{ + /* Superblock lockres doesn't come from a slab so we call init + * once on it manually. */ + ocfs2_lock_res_init_once(res); + ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_SUPER, + OCFS2_SUPER_BLOCK_BLKNO, 0, + &ocfs2_super_lops, osb); +} + +static void ocfs2_rename_lock_res_init(struct ocfs2_lock_res *res, + struct ocfs2_super *osb) +{ + /* Rename lockres doesn't come from a slab so we call init + * once on it manually. */ + ocfs2_lock_res_init_once(res); + ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_RENAME, 0, 0, + &ocfs2_rename_lops, osb); +} + +void ocfs2_lock_res_free(struct ocfs2_lock_res *res) +{ + mlog_entry_void(); + + if (!(res->l_flags & OCFS2_LOCK_INITIALIZED)) + return; + + ocfs2_remove_lockres_tracking(res); + + mlog_bug_on_msg(!list_empty(&res->l_blocked_list), + "Lockres %s is on the blocked list\n", + res->l_name); + mlog_bug_on_msg(!list_empty(&res->l_mask_waiters), + "Lockres %s has mask waiters pending\n", + res->l_name); + mlog_bug_on_msg(spin_is_locked(&res->l_lock), + "Lockres %s is locked\n", + res->l_name); + mlog_bug_on_msg(res->l_ro_holders, + "Lockres %s has %u ro holders\n", + res->l_name, res->l_ro_holders); + mlog_bug_on_msg(res->l_ex_holders, + "Lockres %s has %u ex holders\n", + res->l_name, res->l_ex_holders); + + /* Need to clear out the lock status block for the dlm */ + memset(&res->l_lksb, 0, sizeof(res->l_lksb)); + + res->l_flags = 0UL; + mlog_exit_void(); +} + +static inline void ocfs2_inc_holders(struct ocfs2_lock_res *lockres, + int level) +{ + mlog_entry_void(); + + BUG_ON(!lockres); + + switch(level) { + case LKM_EXMODE: + lockres->l_ex_holders++; + break; + case LKM_PRMODE: + lockres->l_ro_holders++; + break; + default: + BUG(); + } + + mlog_exit_void(); +} + +static inline void ocfs2_dec_holders(struct ocfs2_lock_res *lockres, + int level) +{ + mlog_entry_void(); + + BUG_ON(!lockres); + + switch(level) { + case LKM_EXMODE: + BUG_ON(!lockres->l_ex_holders); + lockres->l_ex_holders--; + break; + case LKM_PRMODE: + BUG_ON(!lockres->l_ro_holders); + lockres->l_ro_holders--; + break; + default: + BUG(); + } + mlog_exit_void(); +} + +/* WARNING: This function lives in a world where the only three lock + * levels are EX, PR, and NL. It *will* have to be adjusted when more + * lock types are added. */ +static inline int ocfs2_highest_compat_lock_level(int level) +{ + int new_level = LKM_EXMODE; + + if (level == LKM_EXMODE) + new_level = LKM_NLMODE; + else if (level == LKM_PRMODE) + new_level = LKM_PRMODE; + return new_level; +} + +static void lockres_set_flags(struct ocfs2_lock_res *lockres, + unsigned long newflags) +{ + struct list_head *pos, *tmp; + struct ocfs2_mask_waiter *mw; + + assert_spin_locked(&lockres->l_lock); + + lockres->l_flags = newflags; + + list_for_each_safe(pos, tmp, &lockres->l_mask_waiters) { + mw = list_entry(pos, struct ocfs2_mask_waiter, mw_item); + if ((lockres->l_flags & mw->mw_mask) != mw->mw_goal) + continue; + + list_del_init(&mw->mw_item); + mw->mw_status = 0; + complete(&mw->mw_complete); + } +} +static void lockres_or_flags(struct ocfs2_lock_res *lockres, unsigned long or) +{ + lockres_set_flags(lockres, lockres->l_flags | or); +} +static void lockres_clear_flags(struct ocfs2_lock_res *lockres, + unsigned long clear) +{ + lockres_set_flags(lockres, lockres->l_flags & ~clear); +} + +static inline void ocfs2_generic_handle_downconvert_action(struct ocfs2_lock_res *lockres) +{ + mlog_entry_void(); + + BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); + BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); + BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); + BUG_ON(lockres->l_blocking <= LKM_NLMODE); + + lockres->l_level = lockres->l_requested; + if (lockres->l_level <= + ocfs2_highest_compat_lock_level(lockres->l_blocking)) { + lockres->l_blocking = LKM_NLMODE; + lockres_clear_flags(lockres, OCFS2_LOCK_BLOCKED); + } + lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); + + mlog_exit_void(); +} + +static inline void ocfs2_generic_handle_convert_action(struct ocfs2_lock_res *lockres) +{ + mlog_entry_void(); + + BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BUSY)); + BUG_ON(!(lockres->l_flags & OCFS2_LOCK_ATTACHED)); + + /* Convert from RO to EX doesn't really need anything as our + * information is already up to data. Convert from NL to + * *anything* however should mark ourselves as needing an + * update */ + if (lockres->l_level == LKM_NLMODE) + lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); + + lockres->l_level = lockres->l_requested; + lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); + + mlog_exit_void(); +} + +static inline void ocfs2_generic_handle_attach_action(struct ocfs2_lock_res *lockres) +{ + mlog_entry_void(); + + BUG_ON((!lockres->l_flags & OCFS2_LOCK_BUSY)); + BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); + + if (lockres->l_requested > LKM_NLMODE && + !(lockres->l_flags & OCFS2_LOCK_LOCAL)) + lockres_or_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); + + lockres->l_level = lockres->l_requested; + lockres_or_flags(lockres, OCFS2_LOCK_ATTACHED); + lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); + + mlog_exit_void(); +} + +static void ocfs2_inode_ast_func(void *opaque) +{ + struct ocfs2_lock_res *lockres = opaque; + struct inode *inode; + struct dlm_lockstatus *lksb; + unsigned long flags; + + mlog_entry_void(); + + inode = ocfs2_lock_res_inode(lockres); + + mlog(0, "AST fired for inode %"MLFu64", l_action = %u, type = %s\n", + OCFS2_I(inode)->ip_blkno, lockres->l_action, + ocfs2_lock_type_string(lockres->l_type)); + + BUG_ON(!ocfs2_is_inode_lock(lockres)); + + spin_lock_irqsave(&lockres->l_lock, flags); + + lksb = &(lockres->l_lksb); + if (lksb->status != DLM_NORMAL) { + mlog(ML_ERROR, "ocfs2_inode_ast_func: lksb status value of %u " + "on inode %"MLFu64"\n", lksb->status, + OCFS2_I(inode)->ip_blkno); + spin_unlock_irqrestore(&lockres->l_lock, flags); + mlog_exit_void(); + return; + } + + switch(lockres->l_action) { + case OCFS2_AST_ATTACH: + ocfs2_generic_handle_attach_action(lockres); + lockres_clear_flags(lockres, OCFS2_LOCK_LOCAL); + break; + case OCFS2_AST_CONVERT: + ocfs2_generic_handle_convert_action(lockres); + break; + case OCFS2_AST_DOWNCONVERT: + ocfs2_generic_handle_downconvert_action(lockres); + break; + default: + mlog(ML_ERROR, "lockres %s: ast fired with invalid action: %u " + "lockres flags = 0x%lx, unlock action: %u\n", + lockres->l_name, lockres->l_action, lockres->l_flags, + lockres->l_unlock_action); + + BUG(); + } + + /* data and rw locking ignores refresh flag for now. */ + if (lockres->l_type != OCFS2_LOCK_TYPE_META) + lockres_clear_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); + + /* set it to something invalid so if we get called again we + * can catch it. */ + lockres->l_action = OCFS2_AST_INVALID; + spin_unlock_irqrestore(&lockres->l_lock, flags); + wake_up(&lockres->l_event); + + mlog_exit_void(); +} + +static int ocfs2_generic_handle_bast(struct ocfs2_lock_res *lockres, + int level) +{ + int needs_downconvert = 0; + mlog_entry_void(); + + assert_spin_locked(&lockres->l_lock); + + lockres_or_flags(lockres, OCFS2_LOCK_BLOCKED); + + if (level > lockres->l_blocking) { + /* only schedule a downconvert if we haven't already scheduled + * one that goes low enough to satisfy the level we're + * blocking. this also catches the case where we get + * duplicate BASTs */ + if (ocfs2_highest_compat_lock_level(level) < + ocfs2_highest_compat_lock_level(lockres->l_blocking)) + needs_downconvert = 1; + + lockres->l_blocking = level; + } + + mlog_exit(needs_downconvert); + return needs_downconvert; +} + +static void ocfs2_generic_bast_func(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int level) +{ + int needs_downconvert; + unsigned long flags; + + mlog_entry_void(); + + BUG_ON(level <= LKM_NLMODE); + + spin_lock_irqsave(&lockres->l_lock, flags); + needs_downconvert = ocfs2_generic_handle_bast(lockres, level); + if (needs_downconvert) + ocfs2_schedule_blocked_lock(osb, lockres); + spin_unlock_irqrestore(&lockres->l_lock, flags); + + ocfs2_kick_vote_thread(osb); + + wake_up(&lockres->l_event); + mlog_exit_void(); +} + +static void ocfs2_inode_bast_func(void *opaque, int level) +{ + struct ocfs2_lock_res *lockres = opaque; + struct inode *inode; + struct ocfs2_super *osb; + + mlog_entry_void(); + + BUG_ON(!ocfs2_is_inode_lock(lockres)); + + inode = ocfs2_lock_res_inode(lockres); + osb = OCFS2_SB(inode->i_sb); + + mlog(0, "BAST fired for inode %"MLFu64", blocking = %d, level = %d " + "type = %s\n", OCFS2_I(inode)->ip_blkno, level, + lockres->l_level, + ocfs2_lock_type_string(lockres->l_type)); + + ocfs2_generic_bast_func(osb, lockres, level); + + mlog_exit_void(); +} + +static void ocfs2_generic_ast_func(struct ocfs2_lock_res *lockres, + int ignore_refresh) +{ + struct dlm_lockstatus *lksb = &lockres->l_lksb; + unsigned long flags; + + spin_lock_irqsave(&lockres->l_lock, flags); + + if (lksb->status != DLM_NORMAL) { + mlog(ML_ERROR, "lockres %s: lksb status value of %u!\n", + lockres->l_name, lksb->status); + spin_unlock_irqrestore(&lockres->l_lock, flags); + return; + } + + switch(lockres->l_action) { + case OCFS2_AST_ATTACH: + ocfs2_generic_handle_attach_action(lockres); + break; + case OCFS2_AST_CONVERT: + ocfs2_generic_handle_convert_action(lockres); + break; + case OCFS2_AST_DOWNCONVERT: + ocfs2_generic_handle_downconvert_action(lockres); + break; + default: + BUG(); + } + + if (ignore_refresh) + lockres_clear_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); + + /* set it to something invalid so if we get called again we + * can catch it. */ + lockres->l_action = OCFS2_AST_INVALID; + spin_unlock_irqrestore(&lockres->l_lock, flags); + + wake_up(&lockres->l_event); +} + +static void ocfs2_super_ast_func(void *opaque) +{ + struct ocfs2_lock_res *lockres = opaque; + + mlog_entry_void(); + mlog(0, "Superblock AST fired\n"); + + BUG_ON(!ocfs2_is_super_lock(lockres)); + ocfs2_generic_ast_func(lockres, 0); + + mlog_exit_void(); +} + +static void ocfs2_super_bast_func(void *opaque, + int level) +{ + struct ocfs2_lock_res *lockres = opaque; + struct ocfs2_super *osb; + + mlog_entry_void(); + mlog(0, "Superblock BAST fired\n"); + + BUG_ON(!ocfs2_is_super_lock(lockres)); + osb = ocfs2_lock_res_super(lockres); + ocfs2_generic_bast_func(osb, lockres, level); + + mlog_exit_void(); +} + +static void ocfs2_rename_ast_func(void *opaque) +{ + struct ocfs2_lock_res *lockres = opaque; + + mlog_entry_void(); + + mlog(0, "Rename AST fired\n"); + + BUG_ON(!ocfs2_is_rename_lock(lockres)); + + ocfs2_generic_ast_func(lockres, 1); + + mlog_exit_void(); +} + +static void ocfs2_rename_bast_func(void *opaque, + int level) +{ + struct ocfs2_lock_res *lockres = opaque; + struct ocfs2_super *osb; + + mlog_entry_void(); + + mlog(0, "Rename BAST fired\n"); + + BUG_ON(!ocfs2_is_rename_lock(lockres)); + + osb = ocfs2_lock_res_super(lockres); + ocfs2_generic_bast_func(osb, lockres, level); + + mlog_exit_void(); +} + +static inline void ocfs2_recover_from_dlm_error(struct ocfs2_lock_res *lockres, + int convert) +{ + unsigned long flags; + + mlog_entry_void(); + spin_lock_irqsave(&lockres->l_lock, flags); + lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); + if (convert) + lockres->l_action = OCFS2_AST_INVALID; + else + lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; + spin_unlock_irqrestore(&lockres->l_lock, flags); + + wake_up(&lockres->l_event); + mlog_exit_void(); +} + +/* Note: If we detect another process working on the lock (i.e., + * OCFS2_LOCK_BUSY), we'll bail out returning 0. It's up to the caller + * to do the right thing in that case. + */ +static int ocfs2_lock_create(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int level, + int dlm_flags) +{ + int ret = 0; + enum dlm_status status; + unsigned long flags; + + mlog_entry_void(); + + mlog(0, "lock %s, level = %d, flags = %d\n", lockres->l_name, level, + dlm_flags); + + spin_lock_irqsave(&lockres->l_lock, flags); + if ((lockres->l_flags & OCFS2_LOCK_ATTACHED) || + (lockres->l_flags & OCFS2_LOCK_BUSY)) { + spin_unlock_irqrestore(&lockres->l_lock, flags); + goto bail; + } + + lockres->l_action = OCFS2_AST_ATTACH; + lockres->l_requested = level; + lockres_or_flags(lockres, OCFS2_LOCK_BUSY); + spin_unlock_irqrestore(&lockres->l_lock, flags); + + status = dlmlock(osb->dlm, + level, + &lockres->l_lksb, + dlm_flags, + lockres->l_name, + lockres->l_ops->ast, + lockres, + lockres->l_ops->bast); + if (status != DLM_NORMAL) { + ocfs2_log_dlm_error("dlmlock", status, lockres); + ret = -EINVAL; + ocfs2_recover_from_dlm_error(lockres, 1); + } + + mlog(0, "lock %s, successfull return from dlmlock\n", lockres->l_name); + +bail: + mlog_exit(ret); + return ret; +} + +static inline int ocfs2_check_wait_flag(struct ocfs2_lock_res *lockres, + int flag) +{ + unsigned long flags; + int ret; + + spin_lock_irqsave(&lockres->l_lock, flags); + ret = lockres->l_flags & flag; + spin_unlock_irqrestore(&lockres->l_lock, flags); + + return ret; +} + +static inline void ocfs2_wait_on_busy_lock(struct ocfs2_lock_res *lockres) + +{ + wait_event(lockres->l_event, + !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_BUSY)); +} + +static inline void ocfs2_wait_on_refreshing_lock(struct ocfs2_lock_res *lockres) + +{ + wait_event(lockres->l_event, + !ocfs2_check_wait_flag(lockres, OCFS2_LOCK_REFRESHING)); +} + +/* predict what lock level we'll be dropping down to on behalf + * of another node, and return true if the currently wanted + * level will be compatible with it. */ +static inline int ocfs2_may_continue_on_blocked_lock(struct ocfs2_lock_res *lockres, + int wanted) +{ + BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); + + return wanted <= ocfs2_highest_compat_lock_level(lockres->l_blocking); +} + +static void ocfs2_init_mask_waiter(struct ocfs2_mask_waiter *mw) +{ + INIT_LIST_HEAD(&mw->mw_item); + init_completion(&mw->mw_complete); +} + +static int ocfs2_wait_for_mask(struct ocfs2_mask_waiter *mw) +{ + wait_for_completion(&mw->mw_complete); + /* Re-arm the completion in case we want to wait on it again */ + INIT_COMPLETION(mw->mw_complete); + return mw->mw_status; +} + +static void lockres_add_mask_waiter(struct ocfs2_lock_res *lockres, + struct ocfs2_mask_waiter *mw, + unsigned long mask, + unsigned long goal) +{ + BUG_ON(!list_empty(&mw->mw_item)); + + assert_spin_locked(&lockres->l_lock); + + list_add_tail(&mw->mw_item, &lockres->l_mask_waiters); + mw->mw_mask = mask; + mw->mw_goal = goal; +} + +/* returns 0 if the mw that was removed was already satisfied, -EBUSY + * if the mask still hadn't reached its goal */ +static int lockres_remove_mask_waiter(struct ocfs2_lock_res *lockres, + struct ocfs2_mask_waiter *mw) +{ + unsigned long flags; + int ret = 0; + + spin_lock_irqsave(&lockres->l_lock, flags); + if (!list_empty(&mw->mw_item)) { + if ((lockres->l_flags & mw->mw_mask) != mw->mw_goal) + ret = -EBUSY; + + list_del_init(&mw->mw_item); + init_completion(&mw->mw_complete); + } + spin_unlock_irqrestore(&lockres->l_lock, flags); + + return ret; + +} + +static int ocfs2_cluster_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int level, + int lkm_flags, + int arg_flags) +{ + struct ocfs2_mask_waiter mw; + enum dlm_status status; + int wait, catch_signals = !(osb->s_mount_opt & OCFS2_MOUNT_NOINTR); + int ret = 0; /* gcc doesn't realize wait = 1 guarantees ret is set */ + unsigned long flags; + + mlog_entry_void(); + + ocfs2_init_mask_waiter(&mw); + +again: + wait = 0; + + if (catch_signals && signal_pending(current)) { + ret = -ERESTARTSYS; + goto out; + } + + spin_lock_irqsave(&lockres->l_lock, flags); + + mlog_bug_on_msg(lockres->l_flags & OCFS2_LOCK_FREEING, + "Cluster lock called on freeing lockres %s! flags " + "0x%lx\n", lockres->l_name, lockres->l_flags); + + /* We only compare against the currently granted level + * here. If the lock is blocked waiting on a downconvert, + * we'll get caught below. */ + if (lockres->l_flags & OCFS2_LOCK_BUSY && + level > lockres->l_level) { + /* is someone sitting in dlm_lock? If so, wait on + * them. */ + lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BUSY, 0); + wait = 1; + goto unlock; + } + + if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { + /* lock has not been created yet. */ + spin_unlock_irqrestore(&lockres->l_lock, flags); + + ret = ocfs2_lock_create(osb, lockres, LKM_NLMODE, 0); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + goto again; + } + + if (lockres->l_flags & OCFS2_LOCK_BLOCKED && + !ocfs2_may_continue_on_blocked_lock(lockres, level)) { + /* is the lock is currently blocked on behalf of + * another node */ + lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_BLOCKED, 0); + wait = 1; + goto unlock; + } + + if (level > lockres->l_level) { + if (lockres->l_action != OCFS2_AST_INVALID) + mlog(ML_ERROR, "lockres %s has action %u pending\n", + lockres->l_name, lockres->l_action); + + lockres->l_action = OCFS2_AST_CONVERT; + lockres->l_requested = level; + lockres_or_flags(lockres, OCFS2_LOCK_BUSY); + spin_unlock_irqrestore(&lockres->l_lock, flags); + + BUG_ON(level == LKM_IVMODE); + BUG_ON(level == LKM_NLMODE); + + mlog(0, "lock %s, convert from %d to level = %d\n", + lockres->l_name, lockres->l_level, level); + + /* call dlm_lock to upgrade lock now */ + status = dlmlock(osb->dlm, + level, + &lockres->l_lksb, + lkm_flags|LKM_CONVERT|LKM_VALBLK, + lockres->l_name, + lockres->l_ops->ast, + lockres, + lockres->l_ops->bast); + if (status != DLM_NORMAL) { + if ((lkm_flags & LKM_NOQUEUE) && + (status == DLM_NOTQUEUED)) + ret = -EAGAIN; + else { + ocfs2_log_dlm_error("dlmlock", status, + lockres); + ret = -EINVAL; + } + ocfs2_recover_from_dlm_error(lockres, 1); + goto out; + } + + mlog(0, "lock %s, successfull return from dlmlock\n", + lockres->l_name); + + /* At this point we've gone inside the dlm and need to + * complete our work regardless. */ + catch_signals = 0; + + /* wait for busy to clear and carry on */ + goto again; + } + + /* Ok, if we get here then we're good to go. */ + ocfs2_inc_holders(lockres, level); + + ret = 0; +unlock: + spin_unlock_irqrestore(&lockres->l_lock, flags); +out: + /* + * This is helping work around a lock inversion between the page lock + * and dlm locks. One path holds the page lock while calling aops + * which block acquiring dlm locks. The voting thread holds dlm + * locks while acquiring page locks while down converting data locks. + * This block is helping an aop path notice the inversion and back + * off to unlock its page lock before trying the dlm lock again. + */ + if (wait && arg_flags & OCFS2_LOCK_NONBLOCK && + mw.mw_mask & (OCFS2_LOCK_BUSY|OCFS2_LOCK_BLOCKED)) { + wait = 0; + if (lockres_remove_mask_waiter(lockres, &mw)) + ret = -EAGAIN; + else + goto again; + } + if (wait) { + ret = ocfs2_wait_for_mask(&mw); + if (ret == 0) + goto again; + mlog_errno(ret); + } + + mlog_exit(ret); + return ret; +} + +static void ocfs2_cluster_unlock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int level) +{ + unsigned long flags; + + mlog_entry_void(); + spin_lock_irqsave(&lockres->l_lock, flags); + ocfs2_dec_holders(lockres, level); + ocfs2_vote_on_unlock(osb, lockres); + spin_unlock_irqrestore(&lockres->l_lock, flags); + mlog_exit_void(); +} + +static int ocfs2_create_new_inode_lock(struct inode *inode, + struct ocfs2_lock_res *lockres) +{ + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + unsigned long flags; + + spin_lock_irqsave(&lockres->l_lock, flags); + BUG_ON(lockres->l_flags & OCFS2_LOCK_ATTACHED); + lockres_or_flags(lockres, OCFS2_LOCK_LOCAL); + spin_unlock_irqrestore(&lockres->l_lock, flags); + + return ocfs2_lock_create(osb, lockres, LKM_EXMODE, LKM_LOCAL); +} + +/* Grants us an EX lock on the data and metadata resources, skipping + * the normal cluster directory lookup. Use this ONLY on newly created + * inodes which other nodes can't possibly see, and which haven't been + * hashed in the inode hash yet. This can give us a good performance + * increase as it'll skip the network broadcast normally associated + * with creating a new lock resource. */ +int ocfs2_create_new_inode_locks(struct inode *inode) +{ + int ret; + + BUG_ON(!inode); + BUG_ON(!ocfs2_inode_is_new(inode)); + + mlog_entry_void(); + + mlog(0, "Inode %"MLFu64"\n", OCFS2_I(inode)->ip_blkno); + + /* NOTE: That we don't increment any of the holder counts, nor + * do we add anything to a journal handle. Since this is + * supposed to be a new inode which the cluster doesn't know + * about yet, there is no need to. As far as the LVB handling + * is concerned, this is basically like acquiring an EX lock + * on a resource which has an invalid one -- we'll set it + * valid when we release the EX. */ + + ret = ocfs2_create_new_inode_lock(inode, + &OCFS2_I(inode)->ip_rw_lockres); + if (ret) { + mlog_errno(ret); + goto bail; + } + + ret = ocfs2_create_new_inode_lock(inode, + &OCFS2_I(inode)->ip_meta_lockres); + if (ret) { + mlog_errno(ret); + goto bail; + } + + ret = ocfs2_create_new_inode_lock(inode, + &OCFS2_I(inode)->ip_data_lockres); + if (ret) { + mlog_errno(ret); + goto bail; + } + +bail: + mlog_exit(ret); + return ret; +} + +int ocfs2_rw_lock(struct inode *inode, int write) +{ + int status, level; + struct ocfs2_lock_res *lockres; + + BUG_ON(!inode); + + mlog_entry_void(); + + mlog(0, "inode %"MLFu64" take %s RW lock\n", + OCFS2_I(inode)->ip_blkno, + write ? "EXMODE" : "PRMODE"); + + lockres = &OCFS2_I(inode)->ip_rw_lockres; + + level = write ? LKM_EXMODE : LKM_PRMODE; + + status = ocfs2_cluster_lock(OCFS2_SB(inode->i_sb), lockres, level, 0, + 0); + if (status < 0) + mlog_errno(status); + + mlog_exit(status); + return status; +} + +void ocfs2_rw_unlock(struct inode *inode, int write) +{ + int level = write ? LKM_EXMODE : LKM_PRMODE; + struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; + + mlog_entry_void(); + + mlog(0, "inode %"MLFu64" drop %s RW lock\n", + OCFS2_I(inode)->ip_blkno, + write ? "EXMODE" : "PRMODE"); + + ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); + + mlog_exit_void(); +} + +int ocfs2_data_lock_full(struct inode *inode, + int write, + int arg_flags) +{ + int status = 0, level; + struct ocfs2_lock_res *lockres; + + BUG_ON(!inode); + + mlog_entry_void(); + + mlog(0, "inode %"MLFu64" take %s DATA lock\n", + OCFS2_I(inode)->ip_blkno, + write ? "EXMODE" : "PRMODE"); + + /* We'll allow faking a readonly data lock for + * rodevices. */ + if (ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) { + if (write) { + status = -EROFS; + mlog_errno(status); + } + goto out; + } + + lockres = &OCFS2_I(inode)->ip_data_lockres; + + level = write ? LKM_EXMODE : LKM_PRMODE; + + status = ocfs2_cluster_lock(OCFS2_SB(inode->i_sb), lockres, level, + 0, arg_flags); + if (status < 0 && status != -EAGAIN) + mlog_errno(status); + +out: + mlog_exit(status); + return status; +} + +/* see ocfs2_meta_lock_with_page() */ +int ocfs2_data_lock_with_page(struct inode *inode, + int write, + struct page *page) +{ + int ret; + + ret = ocfs2_data_lock_full(inode, write, OCFS2_LOCK_NONBLOCK); + if (ret == -EAGAIN) { + unlock_page(page); + if (ocfs2_data_lock(inode, write) == 0) + ocfs2_data_unlock(inode, write); + ret = AOP_TRUNCATED_PAGE; + } + + return ret; +} + +static void ocfs2_vote_on_unlock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres) +{ + int kick = 0; + + mlog_entry_void(); + + /* If we know that another node is waiting on our lock, kick + * the vote thread * pre-emptively when we reach a release + * condition. */ + if (lockres->l_flags & OCFS2_LOCK_BLOCKED) { + switch(lockres->l_blocking) { + case LKM_EXMODE: + if (!lockres->l_ex_holders && !lockres->l_ro_holders) + kick = 1; + break; + case LKM_PRMODE: + if (!lockres->l_ex_holders) + kick = 1; + break; + default: + BUG(); + } + } + + if (kick) + ocfs2_kick_vote_thread(osb); + + mlog_exit_void(); +} + +void ocfs2_data_unlock(struct inode *inode, + int write) +{ + int level = write ? LKM_EXMODE : LKM_PRMODE; + struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres; + + mlog_entry_void(); + + mlog(0, "inode %"MLFu64" drop %s DATA lock\n", + OCFS2_I(inode)->ip_blkno, + write ? "EXMODE" : "PRMODE"); + + if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) + ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); + + mlog_exit_void(); +} + +#define OCFS2_SEC_BITS 34 +#define OCFS2_SEC_SHIFT (64 - 34) +#define OCFS2_NSEC_MASK ((1ULL << OCFS2_SEC_SHIFT) - 1) + +/* LVB only has room for 64 bits of time here so we pack it for + * now. */ +static u64 ocfs2_pack_timespec(struct timespec *spec) +{ + u64 res; + u64 sec = spec->tv_sec; + u32 nsec = spec->tv_nsec; + + res = (sec << OCFS2_SEC_SHIFT) | (nsec & OCFS2_NSEC_MASK); + + return res; +} + +/* Call this with the lockres locked. I am reasonably sure we don't + * need ip_lock in this function as anyone who would be changing those + * values is supposed to be blocked in ocfs2_meta_lock right now. */ +static void __ocfs2_stuff_meta_lvb(struct inode *inode) +{ + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_lock_res *lockres = &oi->ip_meta_lockres; + struct ocfs2_meta_lvb *lvb; + + mlog_entry_void(); + + lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; + + lvb->lvb_version = cpu_to_be32(OCFS2_LVB_VERSION); + lvb->lvb_isize = cpu_to_be64(i_size_read(inode)); + lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters); + lvb->lvb_iuid = cpu_to_be32(inode->i_uid); + lvb->lvb_igid = cpu_to_be32(inode->i_gid); + lvb->lvb_imode = cpu_to_be16(inode->i_mode); + lvb->lvb_inlink = cpu_to_be16(inode->i_nlink); + lvb->lvb_iatime_packed = + cpu_to_be64(ocfs2_pack_timespec(&inode->i_atime)); + lvb->lvb_ictime_packed = + cpu_to_be64(ocfs2_pack_timespec(&inode->i_ctime)); + lvb->lvb_imtime_packed = + cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime)); + + mlog_meta_lvb(0, lockres); + + mlog_exit_void(); +} + +static void ocfs2_unpack_timespec(struct timespec *spec, + u64 packed_time) +{ + spec->tv_sec = packed_time >> OCFS2_SEC_SHIFT; + spec->tv_nsec = packed_time & OCFS2_NSEC_MASK; +} + +static void ocfs2_refresh_inode_from_lvb(struct inode *inode) +{ + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_lock_res *lockres = &oi->ip_meta_lockres; + struct ocfs2_meta_lvb *lvb; + + mlog_entry_void(); + + mlog_meta_lvb(0, lockres); + + lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; + + /* We're safe here without the lockres lock... */ + spin_lock(&oi->ip_lock); + oi->ip_clusters = be32_to_cpu(lvb->lvb_iclusters); + i_size_write(inode, be64_to_cpu(lvb->lvb_isize)); + + /* fast-symlinks are a special case */ + if (S_ISLNK(inode->i_mode) && !oi->ip_clusters) + inode->i_blocks = 0; + else + inode->i_blocks = + ocfs2_align_bytes_to_sectors(i_size_read(inode)); + + inode->i_uid = be32_to_cpu(lvb->lvb_iuid); + inode->i_gid = be32_to_cpu(lvb->lvb_igid); + inode->i_mode = be16_to_cpu(lvb->lvb_imode); + inode->i_nlink = be16_to_cpu(lvb->lvb_inlink); + ocfs2_unpack_timespec(&inode->i_atime, + be64_to_cpu(lvb->lvb_iatime_packed)); + ocfs2_unpack_timespec(&inode->i_mtime, + be64_to_cpu(lvb->lvb_imtime_packed)); + ocfs2_unpack_timespec(&inode->i_ctime, + be64_to_cpu(lvb->lvb_ictime_packed)); + spin_unlock(&oi->ip_lock); + + mlog_exit_void(); +} + +static inline int ocfs2_meta_lvb_is_trustable(struct ocfs2_lock_res *lockres) +{ + struct ocfs2_meta_lvb *lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; + + if (be32_to_cpu(lvb->lvb_version) == OCFS2_LVB_VERSION) + return 1; + return 0; +} + +/* Determine whether a lock resource needs to be refreshed, and + * arbitrate who gets to refresh it. + * + * 0 means no refresh needed. + * + * > 0 means you need to refresh this and you MUST call + * ocfs2_complete_lock_res_refresh afterwards. */ +static int ocfs2_should_refresh_lock_res(struct ocfs2_lock_res *lockres) +{ + unsigned long flags; + int status = 0; + + mlog_entry_void(); + +refresh_check: + spin_lock_irqsave(&lockres->l_lock, flags); + if (!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) { + spin_unlock_irqrestore(&lockres->l_lock, flags); + goto bail; + } + + if (lockres->l_flags & OCFS2_LOCK_REFRESHING) { + spin_unlock_irqrestore(&lockres->l_lock, flags); + + ocfs2_wait_on_refreshing_lock(lockres); + goto refresh_check; + } + + /* Ok, I'll be the one to refresh this lock. */ + lockres_or_flags(lockres, OCFS2_LOCK_REFRESHING); + spin_unlock_irqrestore(&lockres->l_lock, flags); + + status = 1; +bail: + mlog_exit(status); + return status; +} + +/* If status is non zero, I'll mark it as not being in refresh + * anymroe, but i won't clear the needs refresh flag. */ +static inline void ocfs2_complete_lock_res_refresh(struct ocfs2_lock_res *lockres, + int status) +{ + unsigned long flags; + mlog_entry_void(); + + spin_lock_irqsave(&lockres->l_lock, flags); + lockres_clear_flags(lockres, OCFS2_LOCK_REFRESHING); + if (!status) + lockres_clear_flags(lockres, OCFS2_LOCK_NEEDS_REFRESH); + spin_unlock_irqrestore(&lockres->l_lock, flags); + + wake_up(&lockres->l_event); + + mlog_exit_void(); +} + +/* may or may not return a bh if it went to disk. */ +static int ocfs2_meta_lock_update(struct inode *inode, + struct buffer_head **bh) +{ + int status = 0; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_lock_res *lockres; + struct ocfs2_dinode *fe; + + mlog_entry_void(); + + spin_lock(&oi->ip_lock); + if (oi->ip_flags & OCFS2_INODE_DELETED) { + mlog(0, "Orphaned inode %"MLFu64" was deleted while we " + "were waiting on a lock. ip_flags = 0x%x\n", + oi->ip_blkno, oi->ip_flags); + spin_unlock(&oi->ip_lock); + status = -ENOENT; + goto bail; + } + spin_unlock(&oi->ip_lock); + + lockres = &oi->ip_meta_lockres; + + if (!ocfs2_should_refresh_lock_res(lockres)) + goto bail; + + /* This will discard any caching information we might have had + * for the inode metadata. */ + ocfs2_metadata_cache_purge(inode); + + /* will do nothing for inode types that don't use the extent + * map (directories, bitmap files, etc) */ + ocfs2_extent_map_trunc(inode, 0); + + if (ocfs2_meta_lvb_is_trustable(lockres)) { + mlog(0, "Trusting LVB on inode %"MLFu64"\n", + oi->ip_blkno); + ocfs2_refresh_inode_from_lvb(inode); + } else { + /* Boo, we have to go to disk. */ + /* read bh, cast, ocfs2_refresh_inode */ + status = ocfs2_read_block(OCFS2_SB(inode->i_sb), oi->ip_blkno, + bh, OCFS2_BH_CACHED, inode); + if (status < 0) { + mlog_errno(status); + goto bail_refresh; + } + fe = (struct ocfs2_dinode *) (*bh)->b_data; + + /* This is a good chance to make sure we're not + * locking an invalid object. + * + * We bug on a stale inode here because we checked + * above whether it was wiped from disk. The wiping + * node provides a guarantee that we receive that + * message and can mark the inode before dropping any + * locks associated with it. */ + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); + status = -EIO; + goto bail_refresh; + } + mlog_bug_on_msg(inode->i_generation != + le32_to_cpu(fe->i_generation), + "Invalid dinode %"MLFu64" disk generation: %u " + "inode->i_generation: %u\n", + oi->ip_blkno, le32_to_cpu(fe->i_generation), + inode->i_generation); + mlog_bug_on_msg(le64_to_cpu(fe->i_dtime) || + !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL)), + "Stale dinode %"MLFu64" dtime: %"MLFu64" " + "flags: 0x%x\n", oi->ip_blkno, + le64_to_cpu(fe->i_dtime), + le32_to_cpu(fe->i_flags)); + + ocfs2_refresh_inode(inode, fe); + } + + status = 0; +bail_refresh: + ocfs2_complete_lock_res_refresh(lockres, status); +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_assign_bh(struct inode *inode, + struct buffer_head **ret_bh, + struct buffer_head *passed_bh) +{ + int status; + + if (passed_bh) { + /* Ok, the update went to disk for us, use the + * returned bh. */ + *ret_bh = passed_bh; + get_bh(*ret_bh); + + return 0; + } + + status = ocfs2_read_block(OCFS2_SB(inode->i_sb), + OCFS2_I(inode)->ip_blkno, + ret_bh, + OCFS2_BH_CACHED, + inode); + if (status < 0) + mlog_errno(status); + + return status; +} + +/* + * returns < 0 error if the callback will never be called, otherwise + * the result of the lock will be communicated via the callback. + */ +int ocfs2_meta_lock_full(struct inode *inode, + struct ocfs2_journal_handle *handle, + struct buffer_head **ret_bh, + int ex, + int arg_flags) +{ + int status, level, dlm_flags, acquired; + struct ocfs2_lock_res *lockres; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct buffer_head *local_bh = NULL; + + BUG_ON(!inode); + + mlog_entry_void(); + + mlog(0, "inode %"MLFu64", take %s META lock\n", + OCFS2_I(inode)->ip_blkno, + ex ? "EXMODE" : "PRMODE"); + + status = 0; + acquired = 0; + /* We'll allow faking a readonly metadata lock for + * rodevices. */ + if (ocfs2_is_hard_readonly(osb)) { + if (ex) + status = -EROFS; + goto bail; + } + + if (!(arg_flags & OCFS2_META_LOCK_RECOVERY)) + wait_event(osb->recovery_event, + ocfs2_node_map_is_empty(osb, &osb->recovery_map)); + + acquired = 0; + lockres = &OCFS2_I(inode)->ip_meta_lockres; + level = ex ? LKM_EXMODE : LKM_PRMODE; + dlm_flags = 0; + if (arg_flags & OCFS2_META_LOCK_NOQUEUE) + dlm_flags |= LKM_NOQUEUE; + + status = ocfs2_cluster_lock(osb, lockres, level, dlm_flags, arg_flags); + if (status < 0) { + if (status != -EAGAIN && status != -EIOCBRETRY) + mlog_errno(status); + goto bail; + } + + /* Notify the error cleanup path to drop the cluster lock. */ + acquired = 1; + + /* We wait twice because a node may have died while we were in + * the lower dlm layers. The second time though, we've + * committed to owning this lock so we don't allow signals to + * abort the operation. */ + if (!(arg_flags & OCFS2_META_LOCK_RECOVERY)) + wait_event(osb->recovery_event, + ocfs2_node_map_is_empty(osb, &osb->recovery_map)); + + /* This is fun. The caller may want a bh back, or it may + * not. ocfs2_meta_lock_update definitely wants one in, but + * may or may not read one, depending on what's in the + * LVB. The result of all of this is that we've *only* gone to + * disk if we have to, so the complexity is worthwhile. */ + status = ocfs2_meta_lock_update(inode, &local_bh); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto bail; + } + + if (ret_bh) { + status = ocfs2_assign_bh(inode, ret_bh, local_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + if (handle) { + status = ocfs2_handle_add_lock(handle, inode); + if (status < 0) + mlog_errno(status); + } + +bail: + if (status < 0) { + if (ret_bh && (*ret_bh)) { + brelse(*ret_bh); + *ret_bh = NULL; + } + if (acquired) + ocfs2_meta_unlock(inode, ex); + } + + if (local_bh) + brelse(local_bh); + + mlog_exit(status); + return status; +} + +/* + * This is working around a lock inversion between tasks acquiring DLM locks + * while holding a page lock and the vote thread which blocks dlm lock acquiry + * while acquiring page locks. + * + * ** These _with_page variantes are only intended to be called from aop + * methods that hold page locks and return a very specific *positive* error + * code that aop methods pass up to the VFS -- test for errors with != 0. ** + * + * The DLM is called such that it returns -EAGAIN if it would have blocked + * waiting for the vote thread. In that case we unlock our page so the vote + * thread can make progress. Once we've done this we have to return + * AOP_TRUNCATED_PAGE so the aop method that called us can bubble that back up + * into the VFS who will then immediately retry the aop call. + * + * We do a blocking lock and immediate unlock before returning, though, so that + * the lock has a great chance of being cached on this node by the time the VFS + * calls back to retry the aop. This has a potential to livelock as nodes + * ping locks back and forth, but that's a risk we're willing to take to avoid + * the lock inversion simply. + */ +int ocfs2_meta_lock_with_page(struct inode *inode, + struct ocfs2_journal_handle *handle, + struct buffer_head **ret_bh, + int ex, + struct page *page) +{ + int ret; + + ret = ocfs2_meta_lock_full(inode, handle, ret_bh, ex, + OCFS2_LOCK_NONBLOCK); + if (ret == -EAGAIN) { + unlock_page(page); + if (ocfs2_meta_lock(inode, handle, ret_bh, ex) == 0) + ocfs2_meta_unlock(inode, ex); + ret = AOP_TRUNCATED_PAGE; + } + + return ret; +} + +void ocfs2_meta_unlock(struct inode *inode, + int ex) +{ + int level = ex ? LKM_EXMODE : LKM_PRMODE; + struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres; + + mlog_entry_void(); + + mlog(0, "inode %"MLFu64" drop %s META lock\n", + OCFS2_I(inode)->ip_blkno, + ex ? "EXMODE" : "PRMODE"); + + if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) + ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); + + mlog_exit_void(); +} + +int ocfs2_super_lock(struct ocfs2_super *osb, + int ex) +{ + int status; + int level = ex ? LKM_EXMODE : LKM_PRMODE; + struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; + struct buffer_head *bh; + struct ocfs2_slot_info *si = osb->slot_info; + + mlog_entry_void(); + + if (ocfs2_is_hard_readonly(osb)) + return -EROFS; + + status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* The super block lock path is really in the best position to + * know when resources covered by the lock need to be + * refreshed, so we do it here. Of course, making sense of + * everything is up to the caller :) */ + status = ocfs2_should_refresh_lock_res(lockres); + if (status < 0) { + mlog_errno(status); + goto bail; + } + if (status) { + bh = si->si_bh; + status = ocfs2_read_block(osb, bh->b_blocknr, &bh, 0, + si->si_inode); + if (status == 0) + ocfs2_update_slot_info(si); + + ocfs2_complete_lock_res_refresh(lockres, status); + + if (status < 0) + mlog_errno(status); + } +bail: + mlog_exit(status); + return status; +} + +void ocfs2_super_unlock(struct ocfs2_super *osb, + int ex) +{ + int level = ex ? LKM_EXMODE : LKM_PRMODE; + struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; + + ocfs2_cluster_unlock(osb, lockres, level); +} + +int ocfs2_rename_lock(struct ocfs2_super *osb) +{ + int status; + struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; + + if (ocfs2_is_hard_readonly(osb)) + return -EROFS; + + status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0); + if (status < 0) + mlog_errno(status); + + return status; +} + +void ocfs2_rename_unlock(struct ocfs2_super *osb) +{ + struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; + + ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE); +} + +/* Reference counting of the dlm debug structure. We want this because + * open references on the debug inodes can live on after a mount, so + * we can't rely on the ocfs2_super to always exist. */ +static void ocfs2_dlm_debug_free(struct kref *kref) +{ + struct ocfs2_dlm_debug *dlm_debug; + + dlm_debug = container_of(kref, struct ocfs2_dlm_debug, d_refcnt); + + kfree(dlm_debug); +} + +void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug) +{ + if (dlm_debug) + kref_put(&dlm_debug->d_refcnt, ocfs2_dlm_debug_free); +} + +static void ocfs2_get_dlm_debug(struct ocfs2_dlm_debug *debug) +{ + kref_get(&debug->d_refcnt); +} + +struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void) +{ + struct ocfs2_dlm_debug *dlm_debug; + + dlm_debug = kmalloc(sizeof(struct ocfs2_dlm_debug), GFP_KERNEL); + if (!dlm_debug) { + mlog_errno(-ENOMEM); + goto out; + } + + kref_init(&dlm_debug->d_refcnt); + INIT_LIST_HEAD(&dlm_debug->d_lockres_tracking); + dlm_debug->d_locking_state = NULL; +out: + return dlm_debug; +} + +/* Access to this is arbitrated for us via seq_file->sem. */ +struct ocfs2_dlm_seq_priv { + struct ocfs2_dlm_debug *p_dlm_debug; + struct ocfs2_lock_res p_iter_res; + struct ocfs2_lock_res p_tmp_res; +}; + +static struct ocfs2_lock_res *ocfs2_dlm_next_res(struct ocfs2_lock_res *start, + struct ocfs2_dlm_seq_priv *priv) +{ + struct ocfs2_lock_res *iter, *ret = NULL; + struct ocfs2_dlm_debug *dlm_debug = priv->p_dlm_debug; + + assert_spin_locked(&ocfs2_dlm_tracking_lock); + + list_for_each_entry(iter, &start->l_debug_list, l_debug_list) { + /* discover the head of the list */ + if (&iter->l_debug_list == &dlm_debug->d_lockres_tracking) { + mlog(0, "End of list found, %p\n", ret); + break; + } + + /* We track our "dummy" iteration lockres' by a NULL + * l_ops field. */ + if (iter->l_ops != NULL) { + ret = iter; + break; + } + } + + return ret; +} + +static void *ocfs2_dlm_seq_start(struct seq_file *m, loff_t *pos) +{ + struct ocfs2_dlm_seq_priv *priv = m->private; + struct ocfs2_lock_res *iter; + + spin_lock(&ocfs2_dlm_tracking_lock); + iter = ocfs2_dlm_next_res(&priv->p_iter_res, priv); + if (iter) { + /* Since lockres' have the lifetime of their container + * (which can be inodes, ocfs2_supers, etc) we want to + * copy this out to a temporary lockres while still + * under the spinlock. Obviously after this we can't + * trust any pointers on the copy returned, but that's + * ok as the information we want isn't typically held + * in them. */ + priv->p_tmp_res = *iter; + iter = &priv->p_tmp_res; + } + spin_unlock(&ocfs2_dlm_tracking_lock); + + return iter; +} + +static void ocfs2_dlm_seq_stop(struct seq_file *m, void *v) +{ +} + +static void *ocfs2_dlm_seq_next(struct seq_file *m, void *v, loff_t *pos) +{ + struct ocfs2_dlm_seq_priv *priv = m->private; + struct ocfs2_lock_res *iter = v; + struct ocfs2_lock_res *dummy = &priv->p_iter_res; + + spin_lock(&ocfs2_dlm_tracking_lock); + iter = ocfs2_dlm_next_res(iter, priv); + list_del_init(&dummy->l_debug_list); + if (iter) { + list_add(&dummy->l_debug_list, &iter->l_debug_list); + priv->p_tmp_res = *iter; + iter = &priv->p_tmp_res; + } + spin_unlock(&ocfs2_dlm_tracking_lock); + + return iter; +} + +/* So that debugfs.ocfs2 can determine which format is being used */ +#define OCFS2_DLM_DEBUG_STR_VERSION 1 +static int ocfs2_dlm_seq_show(struct seq_file *m, void *v) +{ + int i; + char *lvb; + struct ocfs2_lock_res *lockres = v; + + if (!lockres) + return -EINVAL; + + seq_printf(m, "0x%x\t" + "%.*s\t" + "%d\t" + "0x%lx\t" + "0x%x\t" + "0x%x\t" + "%u\t" + "%u\t" + "%d\t" + "%d\t", + OCFS2_DLM_DEBUG_STR_VERSION, + OCFS2_LOCK_ID_MAX_LEN, lockres->l_name, + lockres->l_level, + lockres->l_flags, + lockres->l_action, + lockres->l_unlock_action, + lockres->l_ro_holders, + lockres->l_ex_holders, + lockres->l_requested, + lockres->l_blocking); + + /* Dump the raw LVB */ + lvb = lockres->l_lksb.lvb; + for(i = 0; i < DLM_LVB_LEN; i++) + seq_printf(m, "0x%x\t", lvb[i]); + + /* End the line */ + seq_printf(m, "\n"); + return 0; +} + +static struct seq_operations ocfs2_dlm_seq_ops = { + .start = ocfs2_dlm_seq_start, + .stop = ocfs2_dlm_seq_stop, + .next = ocfs2_dlm_seq_next, + .show = ocfs2_dlm_seq_show, +}; + +static int ocfs2_dlm_debug_release(struct inode *inode, struct file *file) +{ + struct seq_file *seq = (struct seq_file *) file->private_data; + struct ocfs2_dlm_seq_priv *priv = seq->private; + struct ocfs2_lock_res *res = &priv->p_iter_res; + + ocfs2_remove_lockres_tracking(res); + ocfs2_put_dlm_debug(priv->p_dlm_debug); + return seq_release_private(inode, file); +} + +static int ocfs2_dlm_debug_open(struct inode *inode, struct file *file) +{ + int ret; + struct ocfs2_dlm_seq_priv *priv; + struct seq_file *seq; + struct ocfs2_super *osb; + + priv = kzalloc(sizeof(struct ocfs2_dlm_seq_priv), GFP_KERNEL); + if (!priv) { + ret = -ENOMEM; + mlog_errno(ret); + goto out; + } + osb = (struct ocfs2_super *) inode->u.generic_ip; + ocfs2_get_dlm_debug(osb->osb_dlm_debug); + priv->p_dlm_debug = osb->osb_dlm_debug; + INIT_LIST_HEAD(&priv->p_iter_res.l_debug_list); + + ret = seq_open(file, &ocfs2_dlm_seq_ops); + if (ret) { + kfree(priv); + mlog_errno(ret); + goto out; + } + + seq = (struct seq_file *) file->private_data; + seq->private = priv; + + ocfs2_add_lockres_tracking(&priv->p_iter_res, + priv->p_dlm_debug); + +out: + return ret; +} + +static struct file_operations ocfs2_dlm_debug_fops = { + .open = ocfs2_dlm_debug_open, + .release = ocfs2_dlm_debug_release, + .read = seq_read, + .llseek = seq_lseek, +}; + +static int ocfs2_dlm_init_debug(struct ocfs2_super *osb) +{ + int ret = 0; + struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug; + + dlm_debug->d_locking_state = debugfs_create_file("locking_state", + S_IFREG|S_IRUSR, + osb->osb_debug_root, + osb, + &ocfs2_dlm_debug_fops); + if (!dlm_debug->d_locking_state) { + ret = -EINVAL; + mlog(ML_ERROR, + "Unable to create locking state debugfs file.\n"); + goto out; + } + + ocfs2_get_dlm_debug(dlm_debug); +out: + return ret; +} + +static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb) +{ + struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug; + + if (dlm_debug) { + debugfs_remove(dlm_debug->d_locking_state); + ocfs2_put_dlm_debug(dlm_debug); + } +} + +int ocfs2_dlm_init(struct ocfs2_super *osb) +{ + int status; + u32 dlm_key; + struct dlm_ctxt *dlm; + + mlog_entry_void(); + + status = ocfs2_dlm_init_debug(osb); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* launch vote thread */ + osb->vote_task = kthread_run(ocfs2_vote_thread, osb, "ocfs2vote-%d", + osb->osb_id); + if (IS_ERR(osb->vote_task)) { + status = PTR_ERR(osb->vote_task); + osb->vote_task = NULL; + mlog_errno(status); + goto bail; + } + + /* used by the dlm code to make message headers unique, each + * node in this domain must agree on this. */ + dlm_key = crc32_le(0, osb->uuid_str, strlen(osb->uuid_str)); + + /* for now, uuid == domain */ + dlm = dlm_register_domain(osb->uuid_str, dlm_key); + if (IS_ERR(dlm)) { + status = PTR_ERR(dlm); + mlog_errno(status); + goto bail; + } + + ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); + ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); + + dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb); + + osb->dlm = dlm; + + status = 0; +bail: + if (status < 0) { + ocfs2_dlm_shutdown_debug(osb); + if (osb->vote_task) + kthread_stop(osb->vote_task); + } + + mlog_exit(status); + return status; +} + +void ocfs2_dlm_shutdown(struct ocfs2_super *osb) +{ + mlog_entry_void(); + + dlm_unregister_eviction_cb(&osb->osb_eviction_cb); + + ocfs2_drop_osb_locks(osb); + + if (osb->vote_task) { + kthread_stop(osb->vote_task); + osb->vote_task = NULL; + } + + ocfs2_lock_res_free(&osb->osb_super_lockres); + ocfs2_lock_res_free(&osb->osb_rename_lockres); + + dlm_unregister_domain(osb->dlm); + osb->dlm = NULL; + + ocfs2_dlm_shutdown_debug(osb); + + mlog_exit_void(); +} + +static void ocfs2_unlock_ast_func(void *opaque, enum dlm_status status) +{ + struct ocfs2_lock_res *lockres = opaque; + unsigned long flags; + + mlog_entry_void(); + + mlog(0, "UNLOCK AST called on lock %s, action = %d\n", lockres->l_name, + lockres->l_unlock_action); + + spin_lock_irqsave(&lockres->l_lock, flags); + /* We tried to cancel a convert request, but it was already + * granted. All we want to do here is clear our unlock + * state. The wake_up call done at the bottom is redundant + * (ocfs2_prepare_cancel_convert doesn't sleep on this) but doesn't + * hurt anything anyway */ + if (status == DLM_CANCELGRANT && + lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { + mlog(0, "Got cancelgrant for %s\n", lockres->l_name); + + /* We don't clear the busy flag in this case as it + * should have been cleared by the ast which the dlm + * has called. */ + goto complete_unlock; + } + + if (status != DLM_NORMAL) { + mlog(ML_ERROR, "Dlm passes status %d for lock %s, " + "unlock_action %d\n", status, lockres->l_name, + lockres->l_unlock_action); + spin_unlock_irqrestore(&lockres->l_lock, flags); + return; + } + + switch(lockres->l_unlock_action) { + case OCFS2_UNLOCK_CANCEL_CONVERT: + mlog(0, "Cancel convert success for %s\n", lockres->l_name); + lockres->l_action = OCFS2_AST_INVALID; + break; + case OCFS2_UNLOCK_DROP_LOCK: + lockres->l_level = LKM_IVMODE; + break; + default: + BUG(); + } + + lockres_clear_flags(lockres, OCFS2_LOCK_BUSY); +complete_unlock: + lockres->l_unlock_action = OCFS2_UNLOCK_INVALID; + spin_unlock_irqrestore(&lockres->l_lock, flags); + + wake_up(&lockres->l_event); + + mlog_exit_void(); +} + +typedef void (ocfs2_pre_drop_cb_t)(struct ocfs2_lock_res *, void *); + +struct drop_lock_cb { + ocfs2_pre_drop_cb_t *drop_func; + void *drop_data; +}; + +static int ocfs2_drop_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + struct drop_lock_cb *dcb) +{ + enum dlm_status status; + unsigned long flags; + + /* We didn't get anywhere near actually using this lockres. */ + if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) + goto out; + + spin_lock_irqsave(&lockres->l_lock, flags); + + mlog_bug_on_msg(!(lockres->l_flags & OCFS2_LOCK_FREEING), + "lockres %s, flags 0x%lx\n", + lockres->l_name, lockres->l_flags); + + while (lockres->l_flags & OCFS2_LOCK_BUSY) { + mlog(0, "waiting on busy lock \"%s\": flags = %lx, action = " + "%u, unlock_action = %u\n", + lockres->l_name, lockres->l_flags, lockres->l_action, + lockres->l_unlock_action); + + spin_unlock_irqrestore(&lockres->l_lock, flags); + + /* XXX: Today we just wait on any busy + * locks... Perhaps we need to cancel converts in the + * future? */ + ocfs2_wait_on_busy_lock(lockres); + + spin_lock_irqsave(&lockres->l_lock, flags); + } + + if (dcb) + dcb->drop_func(lockres, dcb->drop_data); + + if (lockres->l_flags & OCFS2_LOCK_BUSY) + mlog(ML_ERROR, "destroying busy lock: \"%s\"\n", + lockres->l_name); + if (lockres->l_flags & OCFS2_LOCK_BLOCKED) + mlog(0, "destroying blocked lock: \"%s\"\n", lockres->l_name); + + if (!(lockres->l_flags & OCFS2_LOCK_ATTACHED)) { + spin_unlock_irqrestore(&lockres->l_lock, flags); + goto out; + } + + lockres_clear_flags(lockres, OCFS2_LOCK_ATTACHED); + + /* make sure we never get here while waiting for an ast to + * fire. */ + BUG_ON(lockres->l_action != OCFS2_AST_INVALID); + + /* is this necessary? */ + lockres_or_flags(lockres, OCFS2_LOCK_BUSY); + lockres->l_unlock_action = OCFS2_UNLOCK_DROP_LOCK; + spin_unlock_irqrestore(&lockres->l_lock, flags); + + mlog(0, "lock %s\n", lockres->l_name); + + status = dlmunlock(osb->dlm, &lockres->l_lksb, LKM_VALBLK, + lockres->l_ops->unlock_ast, lockres); + if (status != DLM_NORMAL) { + ocfs2_log_dlm_error("dlmunlock", status, lockres); + mlog(ML_ERROR, "lockres flags: %lu\n", lockres->l_flags); + dlm_print_one_lock(lockres->l_lksb.lockid); + BUG(); + } + mlog(0, "lock %s, successfull return from dlmunlock\n", + lockres->l_name); + + ocfs2_wait_on_busy_lock(lockres); +out: + mlog_exit(0); + return 0; +} + +/* Mark the lockres as being dropped. It will no longer be + * queued if blocking, but we still may have to wait on it + * being dequeued from the vote thread before we can consider + * it safe to drop. + * + * You can *not* attempt to call cluster_lock on this lockres anymore. */ +void ocfs2_mark_lockres_freeing(struct ocfs2_lock_res *lockres) +{ + int status; + struct ocfs2_mask_waiter mw; + unsigned long flags; + + ocfs2_init_mask_waiter(&mw); + + spin_lock_irqsave(&lockres->l_lock, flags); + lockres->l_flags |= OCFS2_LOCK_FREEING; + while (lockres->l_flags & OCFS2_LOCK_QUEUED) { + lockres_add_mask_waiter(lockres, &mw, OCFS2_LOCK_QUEUED, 0); + spin_unlock_irqrestore(&lockres->l_lock, flags); + + mlog(0, "Waiting on lockres %s\n", lockres->l_name); + + status = ocfs2_wait_for_mask(&mw); + if (status) + mlog_errno(status); + + spin_lock_irqsave(&lockres->l_lock, flags); + } + spin_unlock_irqrestore(&lockres->l_lock, flags); +} + +static void ocfs2_drop_osb_locks(struct ocfs2_super *osb) +{ + int status; + + mlog_entry_void(); + + ocfs2_mark_lockres_freeing(&osb->osb_super_lockres); + + status = ocfs2_drop_lock(osb, &osb->osb_super_lockres, NULL); + if (status < 0) + mlog_errno(status); + + ocfs2_mark_lockres_freeing(&osb->osb_rename_lockres); + + status = ocfs2_drop_lock(osb, &osb->osb_rename_lockres, NULL); + if (status < 0) + mlog_errno(status); + + mlog_exit(status); +} + +static void ocfs2_meta_pre_drop(struct ocfs2_lock_res *lockres, void *data) +{ + struct inode *inode = data; + + /* the metadata lock requires a bit more work as we have an + * LVB to worry about. */ + if (lockres->l_flags & OCFS2_LOCK_ATTACHED && + lockres->l_level == LKM_EXMODE && + !(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) + __ocfs2_stuff_meta_lvb(inode); +} + +int ocfs2_drop_inode_locks(struct inode *inode) +{ + int status, err; + struct drop_lock_cb meta_dcb = { ocfs2_meta_pre_drop, inode, }; + + mlog_entry_void(); + + /* No need to call ocfs2_mark_lockres_freeing here - + * ocfs2_clear_inode has done it for us. */ + + err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb), + &OCFS2_I(inode)->ip_data_lockres, + NULL); + if (err < 0) + mlog_errno(err); + + status = err; + + err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb), + &OCFS2_I(inode)->ip_meta_lockres, + &meta_dcb); + if (err < 0) + mlog_errno(err); + if (err < 0 && !status) + status = err; + + err = ocfs2_drop_lock(OCFS2_SB(inode->i_sb), + &OCFS2_I(inode)->ip_rw_lockres, + NULL); + if (err < 0) + mlog_errno(err); + if (err < 0 && !status) + status = err; + + mlog_exit(status); + return status; +} + +static void ocfs2_prepare_downconvert(struct ocfs2_lock_res *lockres, + int new_level) +{ + assert_spin_locked(&lockres->l_lock); + + BUG_ON(lockres->l_blocking <= LKM_NLMODE); + + if (lockres->l_level <= new_level) { + mlog(ML_ERROR, "lockres->l_level (%u) <= new_level (%u)\n", + lockres->l_level, new_level); + BUG(); + } + + mlog(0, "lock %s, new_level = %d, l_blocking = %d\n", + lockres->l_name, new_level, lockres->l_blocking); + + lockres->l_action = OCFS2_AST_DOWNCONVERT; + lockres->l_requested = new_level; + lockres_or_flags(lockres, OCFS2_LOCK_BUSY); +} + +static int ocfs2_downconvert_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int new_level, + int lvb) +{ + int ret, dlm_flags = LKM_CONVERT; + enum dlm_status status; + + mlog_entry_void(); + + if (lvb) + dlm_flags |= LKM_VALBLK; + + status = dlmlock(osb->dlm, + new_level, + &lockres->l_lksb, + dlm_flags, + lockres->l_name, + lockres->l_ops->ast, + lockres, + lockres->l_ops->bast); + if (status != DLM_NORMAL) { + ocfs2_log_dlm_error("dlmlock", status, lockres); + ret = -EINVAL; + ocfs2_recover_from_dlm_error(lockres, 1); + goto bail; + } + + ret = 0; +bail: + mlog_exit(ret); + return ret; +} + +/* returns 1 when the caller should unlock and call dlmunlock */ +static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres) +{ + assert_spin_locked(&lockres->l_lock); + + mlog_entry_void(); + mlog(0, "lock %s\n", lockres->l_name); + + if (lockres->l_unlock_action == OCFS2_UNLOCK_CANCEL_CONVERT) { + /* If we're already trying to cancel a lock conversion + * then just drop the spinlock and allow the caller to + * requeue this lock. */ + + mlog(0, "Lockres %s, skip convert\n", lockres->l_name); + return 0; + } + + /* were we in a convert when we got the bast fire? */ + BUG_ON(lockres->l_action != OCFS2_AST_CONVERT && + lockres->l_action != OCFS2_AST_DOWNCONVERT); + /* set things up for the unlockast to know to just + * clear out the ast_action and unset busy, etc. */ + lockres->l_unlock_action = OCFS2_UNLOCK_CANCEL_CONVERT; + + mlog_bug_on_msg(!(lockres->l_flags & OCFS2_LOCK_BUSY), + "lock %s, invalid flags: 0x%lx\n", + lockres->l_name, lockres->l_flags); + + return 1; +} + +static int ocfs2_cancel_convert(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres) +{ + int ret; + enum dlm_status status; + + mlog_entry_void(); + mlog(0, "lock %s\n", lockres->l_name); + + ret = 0; + status = dlmunlock(osb->dlm, + &lockres->l_lksb, + LKM_CANCEL, + lockres->l_ops->unlock_ast, + lockres); + if (status != DLM_NORMAL) { + ocfs2_log_dlm_error("dlmunlock", status, lockres); + ret = -EINVAL; + ocfs2_recover_from_dlm_error(lockres, 0); + } + + mlog(0, "lock %s return from dlmunlock\n", lockres->l_name); + + mlog_exit(ret); + return ret; +} + +static inline int ocfs2_can_downconvert_meta_lock(struct inode *inode, + struct ocfs2_lock_res *lockres, + int new_level) +{ + int ret; + + mlog_entry_void(); + + BUG_ON(new_level != LKM_NLMODE && new_level != LKM_PRMODE); + + if (lockres->l_flags & OCFS2_LOCK_REFRESHING) { + ret = 0; + mlog(0, "lockres %s currently being refreshed -- backing " + "off!\n", lockres->l_name); + } else if (new_level == LKM_PRMODE) + ret = !lockres->l_ex_holders && + ocfs2_inode_fully_checkpointed(inode); + else /* Must be NLMODE we're converting to. */ + ret = !lockres->l_ro_holders && !lockres->l_ex_holders && + ocfs2_inode_fully_checkpointed(inode); + + mlog_exit(ret); + return ret; +} + +static int ocfs2_do_unblock_meta(struct inode *inode, + int *requeue) +{ + int new_level; + int set_lvb = 0; + int ret = 0; + struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres; + unsigned long flags; + + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + mlog_entry_void(); + + spin_lock_irqsave(&lockres->l_lock, flags); + + BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); + + mlog(0, "l_level=%d, l_blocking=%d\n", lockres->l_level, + lockres->l_blocking); + + BUG_ON(lockres->l_level != LKM_EXMODE && + lockres->l_level != LKM_PRMODE); + + if (lockres->l_flags & OCFS2_LOCK_BUSY) { + *requeue = 1; + ret = ocfs2_prepare_cancel_convert(osb, lockres); + spin_unlock_irqrestore(&lockres->l_lock, flags); + if (ret) { + ret = ocfs2_cancel_convert(osb, lockres); + if (ret < 0) + mlog_errno(ret); + } + goto leave; + } + + new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking); + + mlog(0, "l_level=%d, l_blocking=%d, new_level=%d\n", + lockres->l_level, lockres->l_blocking, new_level); + + if (ocfs2_can_downconvert_meta_lock(inode, lockres, new_level)) { + if (lockres->l_level == LKM_EXMODE) + set_lvb = 1; + + /* If the lock hasn't been refreshed yet (rare), then + * our memory inode values are old and we skip + * stuffing the lvb. There's no need to actually clear + * out the lvb here as it's value is still valid. */ + if (!(lockres->l_flags & OCFS2_LOCK_NEEDS_REFRESH)) { + if (set_lvb) + __ocfs2_stuff_meta_lvb(inode); + } else + mlog(0, "lockres %s: downconverting stale lock!\n", + lockres->l_name); + + mlog(0, "calling ocfs2_downconvert_lock with l_level=%d, " + "l_blocking=%d, new_level=%d\n", + lockres->l_level, lockres->l_blocking, new_level); + + ocfs2_prepare_downconvert(lockres, new_level); + spin_unlock_irqrestore(&lockres->l_lock, flags); + ret = ocfs2_downconvert_lock(osb, lockres, new_level, set_lvb); + goto leave; + } + if (!ocfs2_inode_fully_checkpointed(inode)) + ocfs2_start_checkpoint(osb); + + *requeue = 1; + spin_unlock_irqrestore(&lockres->l_lock, flags); + ret = 0; +leave: + mlog_exit(ret); + return ret; +} + +static int ocfs2_generic_unblock_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres, + int *requeue, + ocfs2_convert_worker_t *worker) +{ + unsigned long flags; + int blocking; + int new_level; + int ret = 0; + + mlog_entry_void(); + + spin_lock_irqsave(&lockres->l_lock, flags); + + BUG_ON(!(lockres->l_flags & OCFS2_LOCK_BLOCKED)); + +recheck: + if (lockres->l_flags & OCFS2_LOCK_BUSY) { + *requeue = 1; + ret = ocfs2_prepare_cancel_convert(osb, lockres); + spin_unlock_irqrestore(&lockres->l_lock, flags); + if (ret) { + ret = ocfs2_cancel_convert(osb, lockres); + if (ret < 0) + mlog_errno(ret); + } + goto leave; + } + + /* if we're blocking an exclusive and we have *any* holders, + * then requeue. */ + if ((lockres->l_blocking == LKM_EXMODE) + && (lockres->l_ex_holders || lockres->l_ro_holders)) { + spin_unlock_irqrestore(&lockres->l_lock, flags); + *requeue = 1; + ret = 0; + goto leave; + } + + /* If it's a PR we're blocking, then only + * requeue if we've got any EX holders */ + if (lockres->l_blocking == LKM_PRMODE && + lockres->l_ex_holders) { + spin_unlock_irqrestore(&lockres->l_lock, flags); + *requeue = 1; + ret = 0; + goto leave; + } + + /* If we get here, then we know that there are no more + * incompatible holders (and anyone asking for an incompatible + * lock is blocked). We can now downconvert the lock */ + if (!worker) + goto downconvert; + + /* Some lockres types want to do a bit of work before + * downconverting a lock. Allow that here. The worker function + * may sleep, so we save off a copy of what we're blocking as + * it may change while we're not holding the spin lock. */ + blocking = lockres->l_blocking; + spin_unlock_irqrestore(&lockres->l_lock, flags); + + worker(lockres, blocking); + + spin_lock_irqsave(&lockres->l_lock, flags); + if (blocking != lockres->l_blocking) { + /* If this changed underneath us, then we can't drop + * it just yet. */ + goto recheck; + } + +downconvert: + *requeue = 0; + new_level = ocfs2_highest_compat_lock_level(lockres->l_blocking); + + ocfs2_prepare_downconvert(lockres, new_level); + spin_unlock_irqrestore(&lockres->l_lock, flags); + ret = ocfs2_downconvert_lock(osb, lockres, new_level, 0); +leave: + mlog_exit(ret); + return ret; +} + +static void ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres, + int blocking) +{ + struct inode *inode; + struct address_space *mapping; + + mlog_entry_void(); + + inode = ocfs2_lock_res_inode(lockres); + mapping = inode->i_mapping; + + if (filemap_fdatawrite(mapping)) { + mlog(ML_ERROR, "Could not sync inode %"MLFu64" for downconvert!", + OCFS2_I(inode)->ip_blkno); + } + sync_mapping_buffers(mapping); + if (blocking == LKM_EXMODE) { + truncate_inode_pages(mapping, 0); + unmap_mapping_range(mapping, 0, 0, 0); + } else { + /* We only need to wait on the I/O if we're not also + * truncating pages because truncate_inode_pages waits + * for us above. We don't truncate pages if we're + * blocking anything < EXMODE because we want to keep + * them around in that case. */ + filemap_fdatawait(mapping); + } + + mlog_exit_void(); +} + +int ocfs2_unblock_data(struct ocfs2_lock_res *lockres, + int *requeue) +{ + int status; + struct inode *inode; + struct ocfs2_super *osb; + + mlog_entry_void(); + + inode = ocfs2_lock_res_inode(lockres); + osb = OCFS2_SB(inode->i_sb); + + mlog(0, "unblock inode %"MLFu64"\n", OCFS2_I(inode)->ip_blkno); + + status = ocfs2_generic_unblock_lock(osb, + lockres, + requeue, + ocfs2_data_convert_worker); + if (status < 0) + mlog_errno(status); + + mlog(0, "inode %"MLFu64", requeue = %d\n", + OCFS2_I(inode)->ip_blkno, *requeue); + + mlog_exit(status); + return status; +} + +static int ocfs2_unblock_inode_lock(struct ocfs2_lock_res *lockres, + int *requeue) +{ + int status; + struct inode *inode; + + mlog_entry_void(); + + mlog(0, "Unblock lockres %s\n", lockres->l_name); + + inode = ocfs2_lock_res_inode(lockres); + + status = ocfs2_generic_unblock_lock(OCFS2_SB(inode->i_sb), + lockres, + requeue, + NULL); + if (status < 0) + mlog_errno(status); + + mlog_exit(status); + return status; +} + + +int ocfs2_unblock_meta(struct ocfs2_lock_res *lockres, + int *requeue) +{ + int status; + struct inode *inode; + + mlog_entry_void(); + + inode = ocfs2_lock_res_inode(lockres); + + mlog(0, "unblock inode %"MLFu64"\n", OCFS2_I(inode)->ip_blkno); + + status = ocfs2_do_unblock_meta(inode, requeue); + if (status < 0) + mlog_errno(status); + + mlog(0, "inode %"MLFu64", requeue = %d\n", + OCFS2_I(inode)->ip_blkno, *requeue); + + mlog_exit(status); + return status; +} + +/* Generic unblock function for any lockres whose private data is an + * ocfs2_super pointer. */ +static int ocfs2_unblock_osb_lock(struct ocfs2_lock_res *lockres, + int *requeue) +{ + int status; + struct ocfs2_super *osb; + + mlog_entry_void(); + + mlog(0, "Unblock lockres %s\n", lockres->l_name); + + osb = ocfs2_lock_res_super(lockres); + + status = ocfs2_generic_unblock_lock(osb, + lockres, + requeue, + NULL); + if (status < 0) + mlog_errno(status); + + mlog_exit(status); + return status; +} + +void ocfs2_process_blocked_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres) +{ + int status; + int requeue = 0; + unsigned long flags; + + /* Our reference to the lockres in this function can be + * considered valid until we remove the OCFS2_LOCK_QUEUED + * flag. */ + + mlog_entry_void(); + + BUG_ON(!lockres); + BUG_ON(!lockres->l_ops); + BUG_ON(!lockres->l_ops->unblock); + + mlog(0, "lockres %s blocked.\n", lockres->l_name); + + /* Detect whether a lock has been marked as going away while + * the vote thread was processing other things. A lock can + * still be marked with OCFS2_LOCK_FREEING after this check, + * but short circuiting here will still save us some + * performance. */ + spin_lock_irqsave(&lockres->l_lock, flags); + if (lockres->l_flags & OCFS2_LOCK_FREEING) + goto unqueue; + spin_unlock_irqrestore(&lockres->l_lock, flags); + + status = lockres->l_ops->unblock(lockres, &requeue); + if (status < 0) + mlog_errno(status); + + spin_lock_irqsave(&lockres->l_lock, flags); +unqueue: + if (lockres->l_flags & OCFS2_LOCK_FREEING || !requeue) { + lockres_clear_flags(lockres, OCFS2_LOCK_QUEUED); + } else + ocfs2_schedule_blocked_lock(osb, lockres); + + mlog(0, "lockres %s, requeue = %s.\n", lockres->l_name, + requeue ? "yes" : "no"); + spin_unlock_irqrestore(&lockres->l_lock, flags); + + mlog_exit_void(); +} + +static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres) +{ + mlog_entry_void(); + + assert_spin_locked(&lockres->l_lock); + + if (lockres->l_flags & OCFS2_LOCK_FREEING) { + /* Do not schedule a lock for downconvert when it's on + * the way to destruction - any nodes wanting access + * to the resource will get it soon. */ + mlog(0, "Lockres %s won't be scheduled: flags 0x%lx\n", + lockres->l_name, lockres->l_flags); + return; + } + + lockres_or_flags(lockres, OCFS2_LOCK_QUEUED); + + spin_lock(&osb->vote_task_lock); + if (list_empty(&lockres->l_blocked_list)) { + list_add_tail(&lockres->l_blocked_list, + &osb->blocked_lock_list); + osb->blocked_lock_count++; + } + spin_unlock(&osb->vote_task_lock); + + mlog_exit_void(); +} + +/* This aids in debugging situations where a bad LVB might be involved. */ +void ocfs2_dump_meta_lvb_info(u64 level, + const char *function, + unsigned int line, + struct ocfs2_lock_res *lockres) +{ + struct ocfs2_meta_lvb *lvb = (struct ocfs2_meta_lvb *) lockres->l_lksb.lvb; + + mlog(level, "LVB information for %s (called from %s:%u):\n", + lockres->l_name, function, line); + mlog(level, "version: %u, clusters: %u\n", + be32_to_cpu(lvb->lvb_version), be32_to_cpu(lvb->lvb_iclusters)); + mlog(level, "size: %"MLFu64", uid %u, gid %u, mode 0x%x\n", + be64_to_cpu(lvb->lvb_isize), be32_to_cpu(lvb->lvb_iuid), + be32_to_cpu(lvb->lvb_igid), be16_to_cpu(lvb->lvb_imode)); + mlog(level, "nlink %u, atime_packed 0x%"MLFx64", " + "ctime_packed 0x%"MLFx64", mtime_packed 0x%"MLFx64"\n", + be16_to_cpu(lvb->lvb_inlink), be64_to_cpu(lvb->lvb_iatime_packed), + be64_to_cpu(lvb->lvb_ictime_packed), + be64_to_cpu(lvb->lvb_imtime_packed)); +} diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h new file mode 100644 index 0000000..8f2d1db --- /dev/null +++ b/fs/ocfs2/dlmglue.h @@ -0,0 +1,111 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * dlmglue.h + * + * description here + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + + +#ifndef DLMGLUE_H +#define DLMGLUE_H + +#define OCFS2_LVB_VERSION 2 + +struct ocfs2_meta_lvb { + __be32 lvb_version; + __be32 lvb_iclusters; + __be32 lvb_iuid; + __be32 lvb_igid; + __be64 lvb_iatime_packed; + __be64 lvb_ictime_packed; + __be64 lvb_imtime_packed; + __be64 lvb_isize; + __be16 lvb_imode; + __be16 lvb_inlink; + __be32 lvb_reserved[3]; +}; + +/* ocfs2_meta_lock_full() and ocfs2_data_lock_full() 'arg_flags' flags */ +/* don't wait on recovery. */ +#define OCFS2_META_LOCK_RECOVERY (0x01) +/* Instruct the dlm not to queue ourselves on the other node. */ +#define OCFS2_META_LOCK_NOQUEUE (0x02) +/* don't block waiting for the vote thread, instead return -EAGAIN */ +#define OCFS2_LOCK_NONBLOCK (0x04) + +int ocfs2_dlm_init(struct ocfs2_super *osb); +void ocfs2_dlm_shutdown(struct ocfs2_super *osb); +void ocfs2_lock_res_init_once(struct ocfs2_lock_res *res); +void ocfs2_inode_lock_res_init(struct ocfs2_lock_res *res, + enum ocfs2_lock_type type, + struct inode *inode); +void ocfs2_lock_res_free(struct ocfs2_lock_res *res); +int ocfs2_create_new_inode_locks(struct inode *inode); +int ocfs2_drop_inode_locks(struct inode *inode); +int ocfs2_data_lock_full(struct inode *inode, + int write, + int arg_flags); +#define ocfs2_data_lock(inode, write) ocfs2_data_lock_full(inode, write, 0) +int ocfs2_data_lock_with_page(struct inode *inode, + int write, + struct page *page); +void ocfs2_data_unlock(struct inode *inode, + int write); +int ocfs2_rw_lock(struct inode *inode, int write); +void ocfs2_rw_unlock(struct inode *inode, int write); +int ocfs2_meta_lock_full(struct inode *inode, + struct ocfs2_journal_handle *handle, + struct buffer_head **ret_bh, + int ex, + int arg_flags); +int ocfs2_meta_lock_with_page(struct inode *inode, + struct ocfs2_journal_handle *handle, + struct buffer_head **ret_bh, + int ex, + struct page *page); +/* 99% of the time we don't want to supply any additional flags -- + * those are for very specific cases only. */ +#define ocfs2_meta_lock(i, h, b, e) ocfs2_meta_lock_full(i, h, b, e, 0) +void ocfs2_meta_unlock(struct inode *inode, + int ex); +int ocfs2_super_lock(struct ocfs2_super *osb, + int ex); +void ocfs2_super_unlock(struct ocfs2_super *osb, + int ex); +int ocfs2_rename_lock(struct ocfs2_super *osb); +void ocfs2_rename_unlock(struct ocfs2_super *osb); +void ocfs2_mark_lockres_freeing(struct ocfs2_lock_res *lockres); + +/* for the vote thread */ +void ocfs2_process_blocked_lock(struct ocfs2_super *osb, + struct ocfs2_lock_res *lockres); + +struct ocfs2_dlm_debug *ocfs2_new_dlm_debug(void); +void ocfs2_put_dlm_debug(struct ocfs2_dlm_debug *dlm_debug); + +/* aids in debugging and tracking lvbs */ +void ocfs2_dump_meta_lvb_info(u64 level, + const char *function, + unsigned int line, + struct ocfs2_lock_res *lockres); +#define mlog_meta_lvb(__level, __lockres) ocfs2_dump_meta_lvb_info(__level, __PRETTY_FUNCTION__, __LINE__, __lockres) + +#endif /* DLMGLUE_H */ diff --git a/fs/ocfs2/endian.h b/fs/ocfs2/endian.h new file mode 100644 index 0000000..f226b22 --- /dev/null +++ b/fs/ocfs2/endian.h @@ -0,0 +1,45 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * Copyright (C) 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_ENDIAN_H +#define OCFS2_ENDIAN_H + +static inline void le16_add_cpu(__le16 *var, u16 val) +{ + *var = cpu_to_le16(le16_to_cpu(*var) + val); +} + +static inline void le32_add_cpu(__le32 *var, u32 val) +{ + *var = cpu_to_le32(le32_to_cpu(*var) + val); +} + +static inline void le32_and_cpu(__le32 *var, u32 val) +{ + *var = cpu_to_le32(le32_to_cpu(*var) & val); +} + +static inline void be32_add_cpu(__be32 *var, u32 val) +{ + *var = cpu_to_be32(be32_to_cpu(*var) + val); +} + +#endif /* OCFS2_ENDIAN_H */ diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c new file mode 100644 index 0000000..5810160 --- /dev/null +++ b/fs/ocfs2/export.c @@ -0,0 +1,248 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * export.c + * + * Functions to facilitate NFS exporting + * + * Copyright (C) 2002, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include + +#define MLOG_MASK_PREFIX ML_EXPORT +#include + +#include "ocfs2.h" + +#include "dir.h" +#include "dlmglue.h" +#include "export.h" +#include "inode.h" + +#include "buffer_head_io.h" + +struct ocfs2_inode_handle +{ + u64 ih_blkno; + u32 ih_generation; +}; + +static struct dentry *ocfs2_get_dentry(struct super_block *sb, void *vobjp) +{ + struct ocfs2_inode_handle *handle = vobjp; + struct inode *inode; + struct dentry *result; + + mlog_entry("(0x%p, 0x%p)\n", sb, handle); + + if (handle->ih_blkno == 0) { + mlog_errno(-ESTALE); + return ERR_PTR(-ESTALE); + } + + inode = ocfs2_iget(OCFS2_SB(sb), handle->ih_blkno); + + if (IS_ERR(inode)) { + mlog_errno(PTR_ERR(inode)); + return (void *)inode; + } + + if (handle->ih_generation != inode->i_generation) { + iput(inode); + mlog_errno(-ESTALE); + return ERR_PTR(-ESTALE); + } + + result = d_alloc_anon(inode); + + if (!result) { + iput(inode); + mlog_errno(-ENOMEM); + return ERR_PTR(-ENOMEM); + } + + mlog_exit_ptr(result); + return result; +} + +static struct dentry *ocfs2_get_parent(struct dentry *child) +{ + int status; + u64 blkno; + struct dentry *parent; + struct inode *inode; + struct inode *dir = child->d_inode; + struct buffer_head *dirent_bh = NULL; + struct ocfs2_dir_entry *dirent; + + mlog_entry("(0x%p, '%.*s')\n", child, + child->d_name.len, child->d_name.name); + + mlog(0, "find parent of directory %"MLFu64"\n", + OCFS2_I(dir)->ip_blkno); + + status = ocfs2_meta_lock(dir, NULL, NULL, 0); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + parent = ERR_PTR(status); + goto bail; + } + + status = ocfs2_find_files_on_disk("..", 2, &blkno, dir, &dirent_bh, + &dirent); + if (status < 0) { + parent = ERR_PTR(-ENOENT); + goto bail_unlock; + } + + inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno); + if (IS_ERR(inode)) { + mlog(ML_ERROR, "Unable to create inode %"MLFu64"\n", blkno); + parent = ERR_PTR(-EACCES); + goto bail_unlock; + } + + parent = d_alloc_anon(inode); + if (!parent) { + iput(inode); + parent = ERR_PTR(-ENOMEM); + } + +bail_unlock: + ocfs2_meta_unlock(dir, 0); + + if (dirent_bh) + brelse(dirent_bh); + +bail: + mlog_exit_ptr(parent); + + return parent; +} + +static int ocfs2_encode_fh(struct dentry *dentry, __be32 *fh, int *max_len, + int connectable) +{ + struct inode *inode = dentry->d_inode; + int len = *max_len; + int type = 1; + u64 blkno; + u32 generation; + + mlog_entry("(0x%p, '%.*s', 0x%p, %d, %d)\n", dentry, + dentry->d_name.len, dentry->d_name.name, + fh, len, connectable); + + if (len < 3 || (connectable && len < 6)) { + mlog(ML_ERROR, "fh buffer is too small for encoding\n"); + type = 255; + goto bail; + } + + blkno = OCFS2_I(inode)->ip_blkno; + generation = inode->i_generation; + + mlog(0, "Encoding fh: blkno: %"MLFu64", generation: %u\n", + blkno, generation); + + len = 3; + fh[0] = cpu_to_le32((u32)(blkno >> 32)); + fh[1] = cpu_to_le32((u32)(blkno & 0xffffffff)); + fh[2] = cpu_to_le32(generation); + + if (connectable && !S_ISDIR(inode->i_mode)) { + struct inode *parent; + + spin_lock(&dentry->d_lock); + + parent = dentry->d_parent->d_inode; + blkno = OCFS2_I(parent)->ip_blkno; + generation = parent->i_generation; + + fh[3] = cpu_to_le32((u32)(blkno >> 32)); + fh[4] = cpu_to_le32((u32)(blkno & 0xffffffff)); + fh[5] = cpu_to_le32(generation); + + spin_unlock(&dentry->d_lock); + + len = 6; + type = 2; + + mlog(0, "Encoding parent: blkno: %"MLFu64", generation: %u\n", + blkno, generation); + } + + *max_len = len; + +bail: + mlog_exit(type); + return type; +} + +static struct dentry *ocfs2_decode_fh(struct super_block *sb, __be32 *fh, + int fh_len, int fileid_type, + int (*acceptable)(void *context, + struct dentry *de), + void *context) +{ + struct ocfs2_inode_handle handle, parent; + struct dentry *ret = NULL; + + mlog_entry("(0x%p, 0x%p, %d, %d, 0x%p, 0x%p)\n", + sb, fh, fh_len, fileid_type, acceptable, context); + + if (fh_len < 3 || fileid_type > 2) + goto bail; + + if (fileid_type == 2) { + if (fh_len < 6) + goto bail; + + parent.ih_blkno = (u64)le32_to_cpu(fh[3]) << 32; + parent.ih_blkno |= (u64)le32_to_cpu(fh[4]); + parent.ih_generation = le32_to_cpu(fh[5]); + + mlog(0, "Decoding parent: blkno: %"MLFu64", generation: %u\n", + parent.ih_blkno, parent.ih_generation); + } + + handle.ih_blkno = (u64)le32_to_cpu(fh[0]) << 32; + handle.ih_blkno |= (u64)le32_to_cpu(fh[1]); + handle.ih_generation = le32_to_cpu(fh[2]); + + mlog(0, "Encoding fh: blkno: %"MLFu64", generation: %u\n", + handle.ih_blkno, handle.ih_generation); + + ret = ocfs2_export_ops.find_exported_dentry(sb, &handle, &parent, + acceptable, context); + +bail: + mlog_exit_ptr(ret); + return ret; +} + +struct export_operations ocfs2_export_ops = { + .decode_fh = ocfs2_decode_fh, + .encode_fh = ocfs2_encode_fh, + + .get_parent = ocfs2_get_parent, + .get_dentry = ocfs2_get_dentry, +}; diff --git a/fs/ocfs2/export.h b/fs/ocfs2/export.h new file mode 100644 index 0000000..5b77ee7 --- /dev/null +++ b/fs/ocfs2/export.h @@ -0,0 +1,31 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * export.h + * + * Function prototypes + * + * Copyright (C) 2002, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_EXPORT_H +#define OCFS2_EXPORT_H + +extern struct export_operations ocfs2_export_ops; + +#endif /* OCFS2_EXPORT_H */ diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c new file mode 100644 index 0000000..f2fb40c --- /dev/null +++ b/fs/ocfs2/extent_map.c @@ -0,0 +1,994 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * extent_map.c + * + * In-memory extent map for OCFS2. Man, this code was prettier in + * the library. + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_EXTENT_MAP +#include + +#include "ocfs2.h" + +#include "extent_map.h" +#include "inode.h" +#include "super.h" + +#include "buffer_head_io.h" + + +/* + * SUCK SUCK SUCK + * Our headers are so bad that struct ocfs2_extent_map is in ocfs.h + */ + +struct ocfs2_extent_map_entry { + struct rb_node e_node; + int e_tree_depth; + struct ocfs2_extent_rec e_rec; +}; + +struct ocfs2_em_insert_context { + int need_left; + int need_right; + struct ocfs2_extent_map_entry *new_ent; + struct ocfs2_extent_map_entry *old_ent; + struct ocfs2_extent_map_entry *left_ent; + struct ocfs2_extent_map_entry *right_ent; +}; + +static kmem_cache_t *ocfs2_em_ent_cachep = NULL; + + +static struct ocfs2_extent_map_entry * +ocfs2_extent_map_lookup(struct ocfs2_extent_map *em, + u32 cpos, u32 clusters, + struct rb_node ***ret_p, + struct rb_node **ret_parent); +static int ocfs2_extent_map_insert(struct inode *inode, + struct ocfs2_extent_rec *rec, + int tree_depth); +static int ocfs2_extent_map_insert_entry(struct ocfs2_extent_map *em, + struct ocfs2_extent_map_entry *ent); +static int ocfs2_extent_map_find_leaf(struct inode *inode, + u32 cpos, u32 clusters, + struct ocfs2_extent_list *el); +static int ocfs2_extent_map_lookup_read(struct inode *inode, + u32 cpos, u32 clusters, + struct ocfs2_extent_map_entry **ret_ent); +static int ocfs2_extent_map_try_insert(struct inode *inode, + struct ocfs2_extent_rec *rec, + int tree_depth, + struct ocfs2_em_insert_context *ctxt); + +/* returns 1 only if the rec contains all the given clusters -- that is that + * rec's cpos is <= the cluster cpos and that the rec endpoint (cpos + + * clusters) is >= the argument's endpoint */ +static int ocfs2_extent_rec_contains_clusters(struct ocfs2_extent_rec *rec, + u32 cpos, u32 clusters) +{ + if (le32_to_cpu(rec->e_cpos) > cpos) + return 0; + if (cpos + clusters > le32_to_cpu(rec->e_cpos) + + le32_to_cpu(rec->e_clusters)) + return 0; + return 1; +} + + +/* + * Find an entry in the tree that intersects the region passed in. + * Note that this will find straddled intervals, it is up to the + * callers to enforce any boundary conditions. + * + * Callers must hold ip_lock. This lookup is not guaranteed to return + * a tree_depth 0 match, and as such can race inserts if the lock + * were not held. + * + * The rb_node garbage lets insertion share the search. Trivial + * callers pass NULL. + */ +static struct ocfs2_extent_map_entry * +ocfs2_extent_map_lookup(struct ocfs2_extent_map *em, + u32 cpos, u32 clusters, + struct rb_node ***ret_p, + struct rb_node **ret_parent) +{ + struct rb_node **p = &em->em_extents.rb_node; + struct rb_node *parent = NULL; + struct ocfs2_extent_map_entry *ent = NULL; + + while (*p) + { + parent = *p; + ent = rb_entry(parent, struct ocfs2_extent_map_entry, + e_node); + if ((cpos + clusters) <= le32_to_cpu(ent->e_rec.e_cpos)) { + p = &(*p)->rb_left; + ent = NULL; + } else if (cpos >= (le32_to_cpu(ent->e_rec.e_cpos) + + le32_to_cpu(ent->e_rec.e_clusters))) { + p = &(*p)->rb_right; + ent = NULL; + } else + break; + } + + if (ret_p != NULL) + *ret_p = p; + if (ret_parent != NULL) + *ret_parent = parent; + return ent; +} + +/* + * Find the leaf containing the interval we want. While we're on our + * way down the tree, fill in every record we see at any depth, because + * we might want it later. + * + * Note that this code is run without ip_lock. That's because it + * sleeps while reading. If someone is also filling the extent list at + * the same time we are, we might have to restart. + */ +static int ocfs2_extent_map_find_leaf(struct inode *inode, + u32 cpos, u32 clusters, + struct ocfs2_extent_list *el) +{ + int i, ret; + struct buffer_head *eb_bh = NULL; + u64 blkno; + u32 rec_end; + struct ocfs2_extent_block *eb; + struct ocfs2_extent_rec *rec; + + /* + * The bh data containing the el cannot change here, because + * we hold alloc_sem. So we can do this without other + * locks. + */ + while (el->l_tree_depth) + { + blkno = 0; + for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { + rec = &el->l_recs[i]; + rec_end = (le32_to_cpu(rec->e_cpos) + + le32_to_cpu(rec->e_clusters)); + + ret = -EBADR; + if (rec_end > OCFS2_I(inode)->ip_clusters) { + mlog_errno(ret); + goto out_free; + } + + if (rec_end <= cpos) { + ret = ocfs2_extent_map_insert(inode, rec, + le16_to_cpu(el->l_tree_depth)); + if (ret && (ret != -EEXIST)) { + mlog_errno(ret); + goto out_free; + } + continue; + } + if ((cpos + clusters) <= le32_to_cpu(rec->e_cpos)) { + ret = ocfs2_extent_map_insert(inode, rec, + le16_to_cpu(el->l_tree_depth)); + if (ret && (ret != -EEXIST)) { + mlog_errno(ret); + goto out_free; + } + continue; + } + + /* + * We've found a record that matches our + * interval. We don't insert it because we're + * about to traverse it. + */ + + /* Check to see if we're stradling */ + ret = -ESRCH; + if (!ocfs2_extent_rec_contains_clusters(rec, + cpos, + clusters)) { + mlog_errno(ret); + goto out_free; + } + + /* + * If we've already found a record, the el has + * two records covering the same interval. + * EEEK! + */ + ret = -EBADR; + if (blkno) { + mlog_errno(ret); + goto out_free; + } + + blkno = le64_to_cpu(rec->e_blkno); + } + + /* + * We don't support holes, and we're still up + * in the branches, so we'd better have found someone + */ + ret = -EBADR; + if (!blkno) { + mlog_errno(ret); + goto out_free; + } + + if (eb_bh) { + brelse(eb_bh); + eb_bh = NULL; + } + ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + blkno, &eb_bh, OCFS2_BH_CACHED, + inode); + if (ret) { + mlog_errno(ret); + goto out_free; + } + eb = (struct ocfs2_extent_block *)eb_bh->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + ret = -EIO; + goto out_free; + } + el = &eb->h_list; + } + + if (el->l_tree_depth) + BUG(); + + for (i = 0; i < le16_to_cpu(el->l_next_free_rec); i++) { + rec = &el->l_recs[i]; + ret = ocfs2_extent_map_insert(inode, rec, + le16_to_cpu(el->l_tree_depth)); + if (ret) { + mlog_errno(ret); + goto out_free; + } + } + + ret = 0; + +out_free: + if (eb_bh) + brelse(eb_bh); + + return ret; +} + +/* + * This lookup actually will read from disk. It has one invariant: + * It will never re-traverse blocks. This means that all inserts should + * be new regions or more granular regions (both allowed by insert). + */ +static int ocfs2_extent_map_lookup_read(struct inode *inode, + u32 cpos, + u32 clusters, + struct ocfs2_extent_map_entry **ret_ent) +{ + int ret; + u64 blkno; + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + struct ocfs2_extent_map_entry *ent; + struct buffer_head *bh = NULL; + struct ocfs2_extent_block *eb; + struct ocfs2_dinode *di; + struct ocfs2_extent_list *el; + + spin_lock(&OCFS2_I(inode)->ip_lock); + ent = ocfs2_extent_map_lookup(em, cpos, clusters, NULL, NULL); + if (ent) { + if (!ent->e_tree_depth) { + spin_unlock(&OCFS2_I(inode)->ip_lock); + *ret_ent = ent; + return 0; + } + blkno = le64_to_cpu(ent->e_rec.e_blkno); + spin_unlock(&OCFS2_I(inode)->ip_lock); + + ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), blkno, &bh, + OCFS2_BH_CACHED, inode); + if (ret) { + mlog_errno(ret); + if (bh) + brelse(bh); + return ret; + } + eb = (struct ocfs2_extent_block *)bh->b_data; + if (!OCFS2_IS_VALID_EXTENT_BLOCK(eb)) { + OCFS2_RO_ON_INVALID_EXTENT_BLOCK(inode->i_sb, eb); + brelse(bh); + return -EIO; + } + el = &eb->h_list; + } else { + spin_unlock(&OCFS2_I(inode)->ip_lock); + + ret = ocfs2_read_block(OCFS2_SB(inode->i_sb), + OCFS2_I(inode)->ip_blkno, &bh, + OCFS2_BH_CACHED, inode); + if (ret) { + mlog_errno(ret); + if (bh) + brelse(bh); + return ret; + } + di = (struct ocfs2_dinode *)bh->b_data; + if (!OCFS2_IS_VALID_DINODE(di)) { + brelse(bh); + OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, di); + return -EIO; + } + el = &di->id2.i_list; + } + + ret = ocfs2_extent_map_find_leaf(inode, cpos, clusters, el); + brelse(bh); + if (ret) { + mlog_errno(ret); + return ret; + } + + ent = ocfs2_extent_map_lookup(em, cpos, clusters, NULL, NULL); + if (!ent) { + ret = -ESRCH; + mlog_errno(ret); + return ret; + } + + if (ent->e_tree_depth) + BUG(); /* FIXME: Make sure this isn't a corruption */ + + *ret_ent = ent; + + return 0; +} + +/* + * Callers must hold ip_lock. This can insert pieces of the tree, + * thus racing lookup if the lock weren't held. + */ +static int ocfs2_extent_map_insert_entry(struct ocfs2_extent_map *em, + struct ocfs2_extent_map_entry *ent) +{ + struct rb_node **p, *parent; + struct ocfs2_extent_map_entry *old_ent; + + old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(ent->e_rec.e_cpos), + le32_to_cpu(ent->e_rec.e_clusters), + &p, &parent); + if (old_ent) + return -EEXIST; + + rb_link_node(&ent->e_node, parent, p); + rb_insert_color(&ent->e_node, &em->em_extents); + + return 0; +} + + +/* + * Simple rule: on any return code other than -EAGAIN, anything left + * in the insert_context will be freed. + */ +static int ocfs2_extent_map_try_insert(struct inode *inode, + struct ocfs2_extent_rec *rec, + int tree_depth, + struct ocfs2_em_insert_context *ctxt) +{ + int ret; + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + struct ocfs2_extent_map_entry *old_ent; + + ctxt->need_left = 0; + ctxt->need_right = 0; + ctxt->old_ent = NULL; + + spin_lock(&OCFS2_I(inode)->ip_lock); + ret = ocfs2_extent_map_insert_entry(em, ctxt->new_ent); + if (!ret) { + ctxt->new_ent = NULL; + goto out_unlock; + } + + old_ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos), + le32_to_cpu(rec->e_clusters), NULL, + NULL); + + if (!old_ent) + BUG(); + + ret = -EEXIST; + if (old_ent->e_tree_depth < tree_depth) + goto out_unlock; + + if (old_ent->e_tree_depth == tree_depth) { + if (!memcmp(rec, &old_ent->e_rec, + sizeof(struct ocfs2_extent_rec))) + ret = 0; + + /* FIXME: Should this be ESRCH/EBADR??? */ + goto out_unlock; + } + + /* + * We do it in this order specifically so that no actual tree + * changes occur until we have all the pieces we need. We + * don't want malloc failures to leave an inconsistent tree. + * Whenever we drop the lock, another process could be + * inserting. Also note that, if another process just beat us + * to an insert, we might not need the same pieces we needed + * the first go round. In the end, the pieces we need will + * be used, and the pieces we don't will be freed. + */ + ctxt->need_left = !!(le32_to_cpu(rec->e_cpos) > + le32_to_cpu(old_ent->e_rec.e_cpos)); + ctxt->need_right = !!((le32_to_cpu(old_ent->e_rec.e_cpos) + + le32_to_cpu(old_ent->e_rec.e_clusters)) > + (le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters))); + ret = -EAGAIN; + if (ctxt->need_left) { + if (!ctxt->left_ent) + goto out_unlock; + *(ctxt->left_ent) = *old_ent; + ctxt->left_ent->e_rec.e_clusters = + cpu_to_le32(le32_to_cpu(rec->e_cpos) - + le32_to_cpu(ctxt->left_ent->e_rec.e_cpos)); + } + if (ctxt->need_right) { + if (!ctxt->right_ent) + goto out_unlock; + *(ctxt->right_ent) = *old_ent; + ctxt->right_ent->e_rec.e_cpos = + cpu_to_le32(le32_to_cpu(rec->e_cpos) + + le32_to_cpu(rec->e_clusters)); + ctxt->right_ent->e_rec.e_clusters = + cpu_to_le32((le32_to_cpu(old_ent->e_rec.e_cpos) + + le32_to_cpu(old_ent->e_rec.e_clusters)) - + le32_to_cpu(ctxt->right_ent->e_rec.e_cpos)); + } + + rb_erase(&old_ent->e_node, &em->em_extents); + /* Now that he's erased, set him up for deletion */ + ctxt->old_ent = old_ent; + + if (ctxt->need_left) { + ret = ocfs2_extent_map_insert_entry(em, + ctxt->left_ent); + if (ret) + goto out_unlock; + ctxt->left_ent = NULL; + } + + if (ctxt->need_right) { + ret = ocfs2_extent_map_insert_entry(em, + ctxt->right_ent); + if (ret) + goto out_unlock; + ctxt->right_ent = NULL; + } + + ret = ocfs2_extent_map_insert_entry(em, ctxt->new_ent); + + if (!ret) + ctxt->new_ent = NULL; + +out_unlock: + spin_unlock(&OCFS2_I(inode)->ip_lock); + + return ret; +} + + +static int ocfs2_extent_map_insert(struct inode *inode, + struct ocfs2_extent_rec *rec, + int tree_depth) +{ + int ret; + struct ocfs2_em_insert_context ctxt = {0, }; + + if ((le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters)) > + OCFS2_I(inode)->ip_map.em_clusters) { + ret = -EBADR; + mlog_errno(ret); + return ret; + } + + /* Zero e_clusters means a truncated tail record. It better be EOF */ + if (!rec->e_clusters) { + if ((le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters)) != + OCFS2_I(inode)->ip_map.em_clusters) { + ret = -EBADR; + mlog_errno(ret); + return ret; + } + + /* Ignore the truncated tail */ + return 0; + } + + ret = -ENOMEM; + ctxt.new_ent = kmem_cache_alloc(ocfs2_em_ent_cachep, + GFP_KERNEL); + if (!ctxt.new_ent) { + mlog_errno(ret); + return ret; + } + + ctxt.new_ent->e_rec = *rec; + ctxt.new_ent->e_tree_depth = tree_depth; + + do { + ret = -ENOMEM; + if (ctxt.need_left && !ctxt.left_ent) { + ctxt.left_ent = + kmem_cache_alloc(ocfs2_em_ent_cachep, + GFP_KERNEL); + if (!ctxt.left_ent) + break; + } + if (ctxt.need_right && !ctxt.right_ent) { + ctxt.right_ent = + kmem_cache_alloc(ocfs2_em_ent_cachep, + GFP_KERNEL); + if (!ctxt.right_ent) + break; + } + + ret = ocfs2_extent_map_try_insert(inode, rec, + tree_depth, &ctxt); + } while (ret == -EAGAIN); + + if (ret < 0) + mlog_errno(ret); + + if (ctxt.left_ent) + kmem_cache_free(ocfs2_em_ent_cachep, ctxt.left_ent); + if (ctxt.right_ent) + kmem_cache_free(ocfs2_em_ent_cachep, ctxt.right_ent); + if (ctxt.old_ent) + kmem_cache_free(ocfs2_em_ent_cachep, ctxt.old_ent); + if (ctxt.new_ent) + kmem_cache_free(ocfs2_em_ent_cachep, ctxt.new_ent); + + return ret; +} + +/* + * Append this record to the tail of the extent map. It must be + * tree_depth 0. The record might be an extension of an existing + * record, and as such that needs to be handled. eg: + * + * Existing record in the extent map: + * + * cpos = 10, len = 10 + * |---------| + * + * New Record: + * + * cpos = 10, len = 20 + * |------------------| + * + * The passed record is the new on-disk record. The new_clusters value + * is how many clusters were added to the file. If the append is a + * contiguous append, the new_clusters has been added to + * rec->e_clusters. If the append is an entirely new extent, then + * rec->e_clusters is == new_clusters. + */ +int ocfs2_extent_map_append(struct inode *inode, + struct ocfs2_extent_rec *rec, + u32 new_clusters) +{ + int ret; + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + struct ocfs2_extent_map_entry *ent; + struct ocfs2_extent_rec *old; + + BUG_ON(!new_clusters); + BUG_ON(le32_to_cpu(rec->e_clusters) < new_clusters); + + if (em->em_clusters < OCFS2_I(inode)->ip_clusters) { + /* + * Size changed underneath us on disk. Drop any + * straddling records and update our idea of + * i_clusters + */ + ocfs2_extent_map_drop(inode, em->em_clusters - 1); + em->em_clusters = OCFS2_I(inode)->ip_clusters; + } + + mlog_bug_on_msg((le32_to_cpu(rec->e_cpos) + + le32_to_cpu(rec->e_clusters)) != + (em->em_clusters + new_clusters), + "Inode %"MLFu64":\n" + "rec->e_cpos = %u + rec->e_clusters = %u = %u\n" + "em->em_clusters = %u + new_clusters = %u = %u\n", + OCFS2_I(inode)->ip_blkno, + le32_to_cpu(rec->e_cpos), le32_to_cpu(rec->e_clusters), + le32_to_cpu(rec->e_cpos) + le32_to_cpu(rec->e_clusters), + em->em_clusters, new_clusters, + em->em_clusters + new_clusters); + + em->em_clusters += new_clusters; + + ret = -ENOENT; + if (le32_to_cpu(rec->e_clusters) > new_clusters) { + /* This is a contiguous append */ + ent = ocfs2_extent_map_lookup(em, le32_to_cpu(rec->e_cpos), 1, + NULL, NULL); + if (ent) { + old = &ent->e_rec; + BUG_ON((le32_to_cpu(rec->e_cpos) + + le32_to_cpu(rec->e_clusters)) != + (le32_to_cpu(old->e_cpos) + + le32_to_cpu(old->e_clusters) + + new_clusters)); + if (ent->e_tree_depth == 0) { + BUG_ON(le32_to_cpu(old->e_cpos) != + le32_to_cpu(rec->e_cpos)); + BUG_ON(le64_to_cpu(old->e_blkno) != + le64_to_cpu(rec->e_blkno)); + ret = 0; + } + /* + * Let non-leafs fall through as -ENOENT to + * force insertion of the new leaf. + */ + le32_add_cpu(&old->e_clusters, new_clusters); + } + } + + if (ret == -ENOENT) + ret = ocfs2_extent_map_insert(inode, rec, 0); + if (ret < 0) + mlog_errno(ret); + return ret; +} + +#if 0 +/* Code here is included but defined out as it completes the extent + * map api and may be used in the future. */ + +/* + * Look up the record containing this cluster offset. This record is + * part of the extent map. Do not free it. Any changes you make to + * it will reflect in the extent map. So, if your last extent + * is (cpos = 10, clusters = 10) and you truncate the file by 5 + * clusters, you can do: + * + * ret = ocfs2_extent_map_get_rec(em, orig_size - 5, &rec); + * rec->e_clusters -= 5; + * + * The lookup does not read from disk. If the map isn't filled in for + * an entry, you won't find it. + * + * Also note that the returned record is valid until alloc_sem is + * dropped. After that, truncate and extend can happen. Caveat Emptor. + */ +int ocfs2_extent_map_get_rec(struct inode *inode, u32 cpos, + struct ocfs2_extent_rec **rec, + int *tree_depth) +{ + int ret = -ENOENT; + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + struct ocfs2_extent_map_entry *ent; + + *rec = NULL; + + if (cpos >= OCFS2_I(inode)->ip_clusters) + return -EINVAL; + + if (cpos >= em->em_clusters) { + /* + * Size changed underneath us on disk. Drop any + * straddling records and update our idea of + * i_clusters + */ + ocfs2_extent_map_drop(inode, em->em_clusters - 1); + em->em_clusters = OCFS2_I(inode)->ip_clusters ; + } + + ent = ocfs2_extent_map_lookup(&OCFS2_I(inode)->ip_map, cpos, 1, + NULL, NULL); + + if (ent) { + *rec = &ent->e_rec; + if (tree_depth) + *tree_depth = ent->e_tree_depth; + ret = 0; + } + + return ret; +} + +int ocfs2_extent_map_get_clusters(struct inode *inode, + u32 v_cpos, int count, + u32 *p_cpos, int *ret_count) +{ + int ret; + u32 coff, ccount; + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + struct ocfs2_extent_map_entry *ent = NULL; + + *p_cpos = ccount = 0; + + if ((v_cpos + count) > OCFS2_I(inode)->ip_clusters) + return -EINVAL; + + if ((v_cpos + count) > em->em_clusters) { + /* + * Size changed underneath us on disk. Drop any + * straddling records and update our idea of + * i_clusters + */ + ocfs2_extent_map_drop(inode, em->em_clusters - 1); + em->em_clusters = OCFS2_I(inode)->ip_clusters; + } + + + ret = ocfs2_extent_map_lookup_read(inode, v_cpos, count, &ent); + if (ret) + return ret; + + if (ent) { + /* We should never find ourselves straddling an interval */ + if (!ocfs2_extent_rec_contains_clusters(&ent->e_rec, + v_cpos, + count)) + return -ESRCH; + + coff = v_cpos - le32_to_cpu(ent->e_rec.e_cpos); + *p_cpos = ocfs2_blocks_to_clusters(inode->i_sb, + le64_to_cpu(ent->e_rec.e_blkno)) + + coff; + + if (ret_count) + *ret_count = le32_to_cpu(ent->e_rec.e_clusters) - coff; + + return 0; + } + + + return -ENOENT; +} + +#endif /* 0 */ + +int ocfs2_extent_map_get_blocks(struct inode *inode, + u64 v_blkno, int count, + u64 *p_blkno, int *ret_count) +{ + int ret; + u64 boff; + u32 cpos, clusters; + int bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1); + struct ocfs2_extent_map_entry *ent = NULL; + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + struct ocfs2_extent_rec *rec; + + *p_blkno = 0; + + cpos = ocfs2_blocks_to_clusters(inode->i_sb, v_blkno); + clusters = ocfs2_blocks_to_clusters(inode->i_sb, + (u64)count + bpc - 1); + if ((cpos + clusters) > OCFS2_I(inode)->ip_clusters) { + ret = -EINVAL; + mlog_errno(ret); + return ret; + } + + if ((cpos + clusters) > em->em_clusters) { + /* + * Size changed underneath us on disk. Drop any + * straddling records and update our idea of + * i_clusters + */ + ocfs2_extent_map_drop(inode, em->em_clusters - 1); + em->em_clusters = OCFS2_I(inode)->ip_clusters; + } + + ret = ocfs2_extent_map_lookup_read(inode, cpos, clusters, &ent); + if (ret) { + mlog_errno(ret); + return ret; + } + + if (ent) + { + rec = &ent->e_rec; + + /* We should never find ourselves straddling an interval */ + if (!ocfs2_extent_rec_contains_clusters(rec, cpos, clusters)) { + ret = -ESRCH; + mlog_errno(ret); + return ret; + } + + boff = ocfs2_clusters_to_blocks(inode->i_sb, cpos - + le32_to_cpu(rec->e_cpos)); + boff += (v_blkno & (u64)(bpc - 1)); + *p_blkno = le64_to_cpu(rec->e_blkno) + boff; + + if (ret_count) { + *ret_count = ocfs2_clusters_to_blocks(inode->i_sb, + le32_to_cpu(rec->e_clusters)) - boff; + } + + return 0; + } + + return -ENOENT; +} + +int ocfs2_extent_map_init(struct inode *inode) +{ + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + + em->em_extents = RB_ROOT; + em->em_clusters = 0; + + return 0; +} + +/* Needs the lock */ +static void __ocfs2_extent_map_drop(struct inode *inode, + u32 new_clusters, + struct rb_node **free_head, + struct ocfs2_extent_map_entry **tail_ent) +{ + struct rb_node *node, *next; + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + struct ocfs2_extent_map_entry *ent; + + *free_head = NULL; + + ent = NULL; + node = rb_last(&em->em_extents); + while (node) + { + next = rb_prev(node); + + ent = rb_entry(node, struct ocfs2_extent_map_entry, + e_node); + if (le32_to_cpu(ent->e_rec.e_cpos) < new_clusters) + break; + + rb_erase(&ent->e_node, &em->em_extents); + + node->rb_right = *free_head; + *free_head = node; + + ent = NULL; + node = next; + } + + /* Do we have an entry straddling new_clusters? */ + if (tail_ent) { + if (ent && + ((le32_to_cpu(ent->e_rec.e_cpos) + + le32_to_cpu(ent->e_rec.e_clusters)) > new_clusters)) + *tail_ent = ent; + else + *tail_ent = NULL; + } +} + +static void __ocfs2_extent_map_drop_cleanup(struct rb_node *free_head) +{ + struct rb_node *node; + struct ocfs2_extent_map_entry *ent; + + while (free_head) { + node = free_head; + free_head = node->rb_right; + + ent = rb_entry(node, struct ocfs2_extent_map_entry, + e_node); + kmem_cache_free(ocfs2_em_ent_cachep, ent); + } +} + +/* + * Remove all entries past new_clusters, inclusive of an entry that + * contains new_clusters. This is effectively a cache forget. + * + * If you want to also clip the last extent by some number of clusters, + * you need to call ocfs2_extent_map_trunc(). + * This code does not check or modify ip_clusters. + */ +int ocfs2_extent_map_drop(struct inode *inode, u32 new_clusters) +{ + struct rb_node *free_head = NULL; + struct ocfs2_extent_map *em = &OCFS2_I(inode)->ip_map; + struct ocfs2_extent_map_entry *ent; + + spin_lock(&OCFS2_I(inode)->ip_lock); + + __ocfs2_extent_map_drop(inode, new_clusters, &free_head, &ent); + + if (ent) { + rb_erase(&ent->e_node, &em->em_extents); + ent->e_node.rb_right = free_head; + free_head = &ent->e_node; + } + + spin_unlock(&OCFS2_I(inode)->ip_lock); + + if (free_head) + __ocfs2_extent_map_drop_cleanup(free_head); + + return 0; +} + +/* + * Remove all entries past new_clusters and also clip any extent + * straddling new_clusters, if there is one. This does not check + * or modify ip_clusters + */ +int ocfs2_extent_map_trunc(struct inode *inode, u32 new_clusters) +{ + struct rb_node *free_head = NULL; + struct ocfs2_extent_map_entry *ent = NULL; + + spin_lock(&OCFS2_I(inode)->ip_lock); + + __ocfs2_extent_map_drop(inode, new_clusters, &free_head, &ent); + + if (ent) + ent->e_rec.e_clusters = cpu_to_le32(new_clusters - + le32_to_cpu(ent->e_rec.e_cpos)); + + OCFS2_I(inode)->ip_map.em_clusters = new_clusters; + + spin_unlock(&OCFS2_I(inode)->ip_lock); + + if (free_head) + __ocfs2_extent_map_drop_cleanup(free_head); + + return 0; +} + +int __init init_ocfs2_extent_maps(void) +{ + ocfs2_em_ent_cachep = + kmem_cache_create("ocfs2_em_ent", + sizeof(struct ocfs2_extent_map_entry), + 0, SLAB_HWCACHE_ALIGN, NULL, NULL); + if (!ocfs2_em_ent_cachep) + return -ENOMEM; + + return 0; +} + +void __exit exit_ocfs2_extent_maps(void) +{ + kmem_cache_destroy(ocfs2_em_ent_cachep); +} diff --git a/fs/ocfs2/extent_map.h b/fs/ocfs2/extent_map.h new file mode 100644 index 0000000..fa3745e --- /dev/null +++ b/fs/ocfs2/extent_map.h @@ -0,0 +1,46 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * extent_map.h + * + * In-memory file extent mappings for OCFS2. + * + * Copyright (C) 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef _EXTENT_MAP_H +#define _EXTENT_MAP_H + +int init_ocfs2_extent_maps(void); +void exit_ocfs2_extent_maps(void); + +/* + * EVERY CALL here except _init, _trunc, and _drop expects alloc_sem + * to be held. The allocation cannot change at all while the map is + * in the process of being updated. + */ +int ocfs2_extent_map_init(struct inode *inode); +int ocfs2_extent_map_append(struct inode *inode, + struct ocfs2_extent_rec *rec, + u32 new_clusters); +int ocfs2_extent_map_get_blocks(struct inode *inode, + u64 v_blkno, int count, + u64 *p_blkno, int *ret_count); +int ocfs2_extent_map_drop(struct inode *inode, u32 new_clusters); +int ocfs2_extent_map_trunc(struct inode *inode, u32 new_clusters); + +#endif /* _EXTENT_MAP_H */ diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c new file mode 100644 index 0000000..72ae9e3 --- /dev/null +++ b/fs/ocfs2/file.c @@ -0,0 +1,1237 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * file.c + * + * File open, close, extend, truncate + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_INODE +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "aops.h" +#include "dir.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "file.h" +#include "sysfile.h" +#include "inode.h" +#include "journal.h" +#include "mmap.h" +#include "suballoc.h" +#include "super.h" + +#include "buffer_head_io.h" + +static int ocfs2_sync_inode(struct inode *inode) +{ + filemap_fdatawrite(inode->i_mapping); + return sync_mapping_buffers(inode->i_mapping); +} + +static int ocfs2_file_open(struct inode *inode, struct file *file) +{ + int status; + int mode = file->f_flags; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + + mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, + file->f_dentry->d_name.len, file->f_dentry->d_name.name); + + spin_lock(&oi->ip_lock); + + /* Check that the inode hasn't been wiped from disk by another + * node. If it hasn't then we're safe as long as we hold the + * spin lock until our increment of open count. */ + if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { + spin_unlock(&oi->ip_lock); + + status = -ENOENT; + goto leave; + } + + if (mode & O_DIRECT) + oi->ip_flags |= OCFS2_INODE_OPEN_DIRECT; + + oi->ip_open_count++; + spin_unlock(&oi->ip_lock); + status = 0; +leave: + mlog_exit(status); + return status; +} + +static int ocfs2_file_release(struct inode *inode, struct file *file) +{ + struct ocfs2_inode_info *oi = OCFS2_I(inode); + + mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, + file->f_dentry->d_name.len, + file->f_dentry->d_name.name); + + spin_lock(&oi->ip_lock); + if (!--oi->ip_open_count) + oi->ip_flags &= ~OCFS2_INODE_OPEN_DIRECT; + spin_unlock(&oi->ip_lock); + + mlog_exit(0); + + return 0; +} + +static int ocfs2_sync_file(struct file *file, + struct dentry *dentry, + int datasync) +{ + int err = 0; + journal_t *journal; + struct inode *inode = dentry->d_inode; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", file, dentry, datasync, + dentry->d_name.len, dentry->d_name.name); + + err = ocfs2_sync_inode(dentry->d_inode); + if (err) + goto bail; + + journal = osb->journal->j_journal; + err = journal_force_commit(journal); + +bail: + mlog_exit(err); + + return (err < 0) ? -EIO : 0; +} + +int ocfs2_set_inode_size(struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + u64 new_i_size) +{ + int status; + + mlog_entry_void(); + i_size_write(inode, new_i_size); + inode->i_blocks = ocfs2_align_bytes_to_sectors(new_i_size); + inode->i_ctime = inode->i_mtime = CURRENT_TIME; + + status = ocfs2_mark_inode_dirty(handle, inode, fe_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_simple_size_update(struct inode *inode, + struct buffer_head *di_bh, + u64 new_i_size) +{ + int ret; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_journal_handle *handle = NULL; + + handle = ocfs2_start_trans(osb, NULL, + OCFS2_INODE_UPDATE_CREDITS); + if (handle == NULL) { + ret = -ENOMEM; + mlog_errno(ret); + goto out; + } + + ret = ocfs2_set_inode_size(handle, inode, di_bh, + new_i_size); + if (ret < 0) + mlog_errno(ret); + + ocfs2_commit_trans(handle); +out: + return ret; +} + +static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh, + u64 new_i_size) +{ + int status; + struct ocfs2_journal_handle *handle; + + mlog_entry_void(); + + /* TODO: This needs to actually orphan the inode in this + * transaction. */ + + handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + mlog_errno(status); + goto out; + } + + status = ocfs2_set_inode_size(handle, inode, fe_bh, new_i_size); + if (status < 0) + mlog_errno(status); + + ocfs2_commit_trans(handle); +out: + mlog_exit(status); + return status; +} + +static int ocfs2_truncate_file(struct inode *inode, + struct buffer_head *di_bh, + u64 new_i_size) +{ + int status = 0; + struct ocfs2_dinode *fe = NULL; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_truncate_context *tc = NULL; + + mlog_entry("(inode = %"MLFu64", new_i_size = %"MLFu64"\n", + OCFS2_I(inode)->ip_blkno, new_i_size); + + truncate_inode_pages(inode->i_mapping, new_i_size); + + fe = (struct ocfs2_dinode *) di_bh->b_data; + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); + status = -EIO; + goto bail; + } + + mlog_bug_on_msg(le64_to_cpu(fe->i_size) != i_size_read(inode), + "Inode %"MLFu64", inode i_size = %lld != di " + "i_size = %"MLFu64", i_flags = 0x%x\n", + OCFS2_I(inode)->ip_blkno, + i_size_read(inode), + le64_to_cpu(fe->i_size), le32_to_cpu(fe->i_flags)); + + if (new_i_size > le64_to_cpu(fe->i_size)) { + mlog(0, "asked to truncate file with size (%"MLFu64") " + "to size (%"MLFu64")!\n", + le64_to_cpu(fe->i_size), new_i_size); + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + mlog(0, "inode %"MLFu64", i_size = %"MLFu64", new_i_size = %"MLFu64"\n", + le64_to_cpu(fe->i_blkno), le64_to_cpu(fe->i_size), new_i_size); + + /* lets handle the simple truncate cases before doing any more + * cluster locking. */ + if (new_i_size == le64_to_cpu(fe->i_size)) + goto bail; + + if (le32_to_cpu(fe->i_clusters) == + ocfs2_clusters_for_bytes(osb->sb, new_i_size)) { + mlog(0, "fe->i_clusters = %u, so we do a simple truncate\n", + fe->i_clusters); + /* No allocation change is required, so lets fast path + * this truncate. */ + status = ocfs2_simple_size_update(inode, di_bh, new_i_size); + if (status < 0) + mlog_errno(status); + goto bail; + } + + /* This forces other nodes to sync and drop their pages */ + status = ocfs2_data_lock(inode, 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + ocfs2_data_unlock(inode, 1); + + /* alright, we're going to need to do a full blown alloc size + * change. Orphan the inode so that recovery can complete the + * truncate if necessary. This does the task of marking + * i_size. */ + status = ocfs2_orphan_for_truncate(osb, inode, di_bh, new_i_size); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_prepare_truncate(osb, inode, di_bh, &tc); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_commit_truncate(osb, inode, di_bh, tc); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* TODO: orphan dir cleanup here. */ +bail: + + mlog_exit(status); + return status; +} + +/* + * extend allocation only here. + * we'll update all the disk stuff, and oip->alloc_size + * + * expect stuff to be locked, a transaction started and enough data / + * metadata reservations in the contexts. + * + * Will return -EAGAIN, and a reason if a restart is needed. + * If passed in, *reason will always be set, even in error. + */ +int ocfs2_do_extend_allocation(struct ocfs2_super *osb, + struct inode *inode, + u32 clusters_to_add, + struct buffer_head *fe_bh, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *data_ac, + struct ocfs2_alloc_context *meta_ac, + enum ocfs2_alloc_restarted *reason_ret) +{ + int status = 0; + int free_extents; + struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data; + enum ocfs2_alloc_restarted reason = RESTART_NONE; + u32 bit_off, num_bits; + u64 block; + + BUG_ON(!clusters_to_add); + + free_extents = ocfs2_num_free_extents(osb, inode, fe); + if (free_extents < 0) { + status = free_extents; + mlog_errno(status); + goto leave; + } + + /* there are two cases which could cause us to EAGAIN in the + * we-need-more-metadata case: + * 1) we haven't reserved *any* + * 2) we are so fragmented, we've needed to add metadata too + * many times. */ + if (!free_extents && !meta_ac) { + mlog(0, "we haven't reserved any metadata!\n"); + status = -EAGAIN; + reason = RESTART_META; + goto leave; + } else if ((!free_extents) + && (ocfs2_alloc_context_bits_left(meta_ac) + < ocfs2_extend_meta_needed(fe))) { + mlog(0, "filesystem is really fragmented...\n"); + status = -EAGAIN; + reason = RESTART_META; + goto leave; + } + + status = ocfs2_claim_clusters(osb, handle, data_ac, 1, + &bit_off, &num_bits); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto leave; + } + + BUG_ON(num_bits > clusters_to_add); + + /* reserve our write early -- insert_extent may update the inode */ + status = ocfs2_journal_access(handle, inode, fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + block = ocfs2_clusters_to_blocks(osb->sb, bit_off); + mlog(0, "Allocating %u clusters at block %u for inode %"MLFu64"\n", + num_bits, bit_off, OCFS2_I(inode)->ip_blkno); + status = ocfs2_insert_extent(osb, handle, inode, fe_bh, block, + num_bits, meta_ac); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + le32_add_cpu(&fe->i_clusters, num_bits); + spin_lock(&OCFS2_I(inode)->ip_lock); + OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters); + spin_unlock(&OCFS2_I(inode)->ip_lock); + + status = ocfs2_journal_dirty(handle, fe_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + clusters_to_add -= num_bits; + + if (clusters_to_add) { + mlog(0, "need to alloc once more, clusters = %u, wanted = " + "%u\n", fe->i_clusters, clusters_to_add); + status = -EAGAIN; + reason = RESTART_TRANS; + } + +leave: + mlog_exit(status); + if (reason_ret) + *reason_ret = reason; + return status; +} + +static int ocfs2_extend_allocation(struct inode *inode, + u32 clusters_to_add) +{ + int status = 0; + int restart_func = 0; + int drop_alloc_sem = 0; + int credits, num_free_extents; + u32 prev_clusters; + struct buffer_head *bh = NULL; + struct ocfs2_dinode *fe = NULL; + struct ocfs2_journal_handle *handle = NULL; + struct ocfs2_alloc_context *data_ac = NULL; + struct ocfs2_alloc_context *meta_ac = NULL; + enum ocfs2_alloc_restarted why; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + mlog_entry("(clusters_to_add = %u)\n", clusters_to_add); + + status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, &bh, + OCFS2_BH_CACHED, inode); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + fe = (struct ocfs2_dinode *) bh->b_data; + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(inode->i_sb, fe); + status = -EIO; + goto leave; + } + +restart_all: + BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters); + + mlog(0, "extend inode %"MLFu64", i_size = %lld, fe->i_clusters = %u, " + "clusters_to_add = %u\n", + OCFS2_I(inode)->ip_blkno, i_size_read(inode), + fe->i_clusters, clusters_to_add); + + handle = ocfs2_alloc_handle(osb); + if (handle == NULL) { + status = -ENOMEM; + mlog_errno(status); + goto leave; + } + + num_free_extents = ocfs2_num_free_extents(osb, + inode, + fe); + if (num_free_extents < 0) { + status = num_free_extents; + mlog_errno(status); + goto leave; + } + + if (!num_free_extents) { + status = ocfs2_reserve_new_metadata(osb, + handle, + fe, + &meta_ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto leave; + } + } + + status = ocfs2_reserve_clusters(osb, + handle, + clusters_to_add, + &data_ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto leave; + } + + /* blocks peope in read/write from reading our allocation + * until we're done changing it. We depend on i_sem to block + * other extend/truncate calls while we're here. Ordering wrt + * start_trans is important here -- always do it before! */ + down_write(&OCFS2_I(inode)->ip_alloc_sem); + drop_alloc_sem = 1; + + credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add); + handle = ocfs2_start_trans(osb, handle, credits); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto leave; + } + +restarted_transaction: + /* reserve a write to the file entry early on - that we if we + * run out of credits in the allocation path, we can still + * update i_size. */ + status = ocfs2_journal_access(handle, inode, bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + prev_clusters = OCFS2_I(inode)->ip_clusters; + + status = ocfs2_do_extend_allocation(osb, + inode, + clusters_to_add, + bh, + handle, + data_ac, + meta_ac, + &why); + if ((status < 0) && (status != -EAGAIN)) { + if (status != -ENOSPC) + mlog_errno(status); + goto leave; + } + + status = ocfs2_journal_dirty(handle, bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + spin_lock(&OCFS2_I(inode)->ip_lock); + clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters); + spin_unlock(&OCFS2_I(inode)->ip_lock); + + if (why != RESTART_NONE && clusters_to_add) { + if (why == RESTART_META) { + mlog(0, "restarting function.\n"); + restart_func = 1; + } else { + BUG_ON(why != RESTART_TRANS); + + mlog(0, "restarting transaction.\n"); + /* TODO: This can be more intelligent. */ + credits = ocfs2_calc_extend_credits(osb->sb, + fe, + clusters_to_add); + status = ocfs2_extend_trans(handle, credits); + if (status < 0) { + /* handle still has to be committed at + * this point. */ + status = -ENOMEM; + mlog_errno(status); + goto leave; + } + goto restarted_transaction; + } + } + + mlog(0, "fe: i_clusters = %u, i_size=%"MLFu64"\n", + fe->i_clusters, fe->i_size); + mlog(0, "inode: ip_clusters=%u, i_size=%lld\n", + OCFS2_I(inode)->ip_clusters, i_size_read(inode)); + +leave: + if (drop_alloc_sem) { + up_write(&OCFS2_I(inode)->ip_alloc_sem); + drop_alloc_sem = 0; + } + if (handle) { + ocfs2_commit_trans(handle); + handle = NULL; + } + if (data_ac) { + ocfs2_free_alloc_context(data_ac); + data_ac = NULL; + } + if (meta_ac) { + ocfs2_free_alloc_context(meta_ac); + meta_ac = NULL; + } + if ((!status) && restart_func) { + restart_func = 0; + goto restart_all; + } + if (bh) { + brelse(bh); + bh = NULL; + } + + mlog_exit(status); + return status; +} + +/* Some parts of this taken from generic_cont_expand, which turned out + * to be too fragile to do exactly what we need without us having to + * worry about recursive locking in ->commit_write(). */ +static int ocfs2_write_zero_page(struct inode *inode, + u64 size) +{ + struct address_space *mapping = inode->i_mapping; + struct page *page; + unsigned long index; + unsigned int offset; + struct ocfs2_journal_handle *handle = NULL; + int ret; + + offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */ + /* ugh. in prepare/commit_write, if from==to==start of block, we + ** skip the prepare. make sure we never send an offset for the start + ** of a block + */ + if ((offset & (inode->i_sb->s_blocksize - 1)) == 0) { + offset++; + } + index = size >> PAGE_CACHE_SHIFT; + + page = grab_cache_page(mapping, index); + if (!page) { + ret = -ENOMEM; + mlog_errno(ret); + goto out; + } + + ret = ocfs2_prepare_write(NULL, page, offset, offset); + if (ret < 0) { + mlog_errno(ret); + goto out_unlock; + } + + if (ocfs2_should_order_data(inode)) { + handle = ocfs2_start_walk_page_trans(inode, page, offset, + offset); + if (IS_ERR(handle)) { + ret = PTR_ERR(handle); + handle = NULL; + goto out_unlock; + } + } + + /* must not update i_size! */ + ret = block_commit_write(page, offset, offset); + if (ret < 0) + mlog_errno(ret); + else + ret = 0; + + if (handle) + ocfs2_commit_trans(handle); +out_unlock: + unlock_page(page); + page_cache_release(page); +out: + return ret; +} + +static int ocfs2_zero_extend(struct inode *inode, + u64 zero_to_size) +{ + int ret = 0; + u64 start_off; + struct super_block *sb = inode->i_sb; + + start_off = ocfs2_align_bytes_to_blocks(sb, i_size_read(inode)); + while (start_off < zero_to_size) { + ret = ocfs2_write_zero_page(inode, start_off); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + + start_off += sb->s_blocksize; + } + +out: + return ret; +} + +static int ocfs2_extend_file(struct inode *inode, + struct buffer_head *di_bh, + u64 new_i_size) +{ + int ret = 0; + u32 clusters_to_add; + + /* setattr sometimes calls us like this. */ + if (new_i_size == 0) + goto out; + + if (i_size_read(inode) == new_i_size) + goto out; + BUG_ON(new_i_size < i_size_read(inode)); + + clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size) - + OCFS2_I(inode)->ip_clusters; + + if (clusters_to_add) { + ret = ocfs2_extend_allocation(inode, clusters_to_add); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + + ret = ocfs2_zero_extend(inode, new_i_size); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + } + + /* No allocation required, we just use this helper to + * do a trivial update of i_size. */ + ret = ocfs2_simple_size_update(inode, di_bh, new_i_size); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + +out: + return ret; +} + +int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) +{ + int status = 0, size_change; + struct inode *inode = dentry->d_inode; + struct super_block *sb = inode->i_sb; + struct ocfs2_super *osb = OCFS2_SB(sb); + struct buffer_head *bh = NULL; + struct ocfs2_journal_handle *handle = NULL; + + mlog_entry("(0x%p, '%.*s')\n", dentry, + dentry->d_name.len, dentry->d_name.name); + + if (attr->ia_valid & ATTR_MODE) + mlog(0, "mode change: %d\n", attr->ia_mode); + if (attr->ia_valid & ATTR_UID) + mlog(0, "uid change: %d\n", attr->ia_uid); + if (attr->ia_valid & ATTR_GID) + mlog(0, "gid change: %d\n", attr->ia_gid); + if (attr->ia_valid & ATTR_SIZE) + mlog(0, "size change...\n"); + if (attr->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME)) + mlog(0, "time change...\n"); + +#define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \ + | ATTR_GID | ATTR_UID | ATTR_MODE) + if (!(attr->ia_valid & OCFS2_VALID_ATTRS)) { + mlog(0, "can't handle attrs: 0x%x\n", attr->ia_valid); + return 0; + } + + status = inode_change_ok(inode, attr); + if (status) + return status; + + size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE; + if (size_change) { + status = ocfs2_rw_lock(inode, 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + status = ocfs2_meta_lock(inode, NULL, &bh, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto bail_unlock_rw; + } + + if (size_change && attr->ia_size != i_size_read(inode)) { + if (i_size_read(inode) > attr->ia_size) + status = ocfs2_truncate_file(inode, bh, attr->ia_size); + else + status = ocfs2_extend_file(inode, bh, attr->ia_size); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + status = -ENOSPC; + goto bail_unlock; + } + } + + handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + mlog_errno(status); + goto bail_unlock; + } + + status = inode_setattr(inode, attr); + if (status < 0) { + mlog_errno(status); + goto bail_commit; + } + + status = ocfs2_mark_inode_dirty(handle, inode, bh); + if (status < 0) + mlog_errno(status); + +bail_commit: + ocfs2_commit_trans(handle); +bail_unlock: + ocfs2_meta_unlock(inode, 1); +bail_unlock_rw: + if (size_change) + ocfs2_rw_unlock(inode, 1); +bail: + if (bh) + brelse(bh); + + mlog_exit(status); + return status; +} + +int ocfs2_getattr(struct vfsmount *mnt, + struct dentry *dentry, + struct kstat *stat) +{ + struct inode *inode = dentry->d_inode; + struct super_block *sb = dentry->d_inode->i_sb; + struct ocfs2_super *osb = sb->s_fs_info; + int err; + + mlog_entry_void(); + + err = ocfs2_inode_revalidate(dentry); + if (err) { + if (err != -ENOENT) + mlog_errno(err); + goto bail; + } + + generic_fillattr(inode, stat); + + /* We set the blksize from the cluster size for performance */ + stat->blksize = osb->s_clustersize; + +bail: + mlog_exit(err); + + return err; +} + +static int ocfs2_write_remove_suid(struct inode *inode) +{ + int ret; + struct buffer_head *bh = NULL; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_journal_handle *handle; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_dinode *di; + + mlog_entry("(Inode %"MLFu64", mode 0%o)\n", oi->ip_blkno, + inode->i_mode); + + handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); + if (handle == NULL) { + ret = -ENOMEM; + mlog_errno(ret); + goto out; + } + + ret = ocfs2_read_block(osb, oi->ip_blkno, &bh, OCFS2_BH_CACHED, inode); + if (ret < 0) { + mlog_errno(ret); + goto out_trans; + } + + ret = ocfs2_journal_access(handle, inode, bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (ret < 0) { + mlog_errno(ret); + goto out_bh; + } + + inode->i_mode &= ~S_ISUID; + if ((inode->i_mode & S_ISGID) && (inode->i_mode & S_IXGRP)) + inode->i_mode &= ~S_ISGID; + + di = (struct ocfs2_dinode *) bh->b_data; + di->i_mode = cpu_to_le16(inode->i_mode); + + ret = ocfs2_journal_dirty(handle, bh); + if (ret < 0) + mlog_errno(ret); +out_bh: + brelse(bh); +out_trans: + ocfs2_commit_trans(handle); +out: + mlog_exit(ret); + return ret; +} + +static inline int ocfs2_write_should_remove_suid(struct inode *inode) +{ + mode_t mode = inode->i_mode; + + if (!capable(CAP_FSETID)) { + if (unlikely(mode & S_ISUID)) + return 1; + + if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) + return 1; + } + return 0; +} + +static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, + const char __user *buf, + size_t count, + loff_t pos) +{ + struct iovec local_iov = { .iov_base = (void __user *)buf, + .iov_len = count }; + int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0; + u32 clusters; + struct file *filp = iocb->ki_filp; + struct inode *inode = filp->f_dentry->d_inode; + loff_t newsize, saved_pos; +#ifdef OCFS2_ORACORE_WORKAROUNDS + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); +#endif + + mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, + (unsigned int)count, + filp->f_dentry->d_name.len, + filp->f_dentry->d_name.name); + + /* happy write of zero bytes */ + if (count == 0) + return 0; + + if (!inode) { + mlog(0, "bad inode\n"); + return -EIO; + } + +#ifdef OCFS2_ORACORE_WORKAROUNDS + /* ugh, work around some applications which open everything O_DIRECT + + * O_APPEND and really don't mean to use O_DIRECT. */ + if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS && + (filp->f_flags & O_APPEND) && (filp->f_flags & O_DIRECT)) + filp->f_flags &= ~O_DIRECT; +#endif + + down(&inode->i_sem); + /* to match setattr's i_sem -> i_alloc_sem -> rw_lock ordering */ + if (filp->f_flags & O_DIRECT) { + have_alloc_sem = 1; + down_read(&inode->i_alloc_sem); + } + + /* concurrent O_DIRECT writes are allowed */ + rw_level = (filp->f_flags & O_DIRECT) ? 0 : 1; + ret = ocfs2_rw_lock(inode, rw_level); + if (ret < 0) { + rw_level = -1; + mlog_errno(ret); + goto out; + } + + /* + * We sample i_size under a read level meta lock to see if our write + * is extending the file, if it is we back off and get a write level + * meta lock. + */ + meta_level = (filp->f_flags & O_APPEND) ? 1 : 0; + for(;;) { + ret = ocfs2_meta_lock(inode, NULL, NULL, meta_level); + if (ret < 0) { + meta_level = -1; + mlog_errno(ret); + goto out; + } + + /* Clear suid / sgid if necessary. We do this here + * instead of later in the write path because + * remove_suid() calls ->setattr without any hint that + * we may have already done our cluster locking. Since + * ocfs2_setattr() *must* take cluster locks to + * proceeed, this will lead us to recursively lock the + * inode. There's also the dinode i_size state which + * can be lost via setattr during extending writes (we + * set inode->i_size at the end of a write. */ + if (ocfs2_write_should_remove_suid(inode)) { + if (meta_level == 0) { + ocfs2_meta_unlock(inode, meta_level); + meta_level = 1; + continue; + } + + ret = ocfs2_write_remove_suid(inode); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + } + + /* work on a copy of ppos until we're sure that we won't have + * to recalculate it due to relocking. */ + if (filp->f_flags & O_APPEND) { + saved_pos = i_size_read(inode); + mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos); + } else { + saved_pos = iocb->ki_pos; + } + newsize = count + saved_pos; + + mlog(0, "pos=%lld newsize=%"MLFu64" cursize=%lld\n", + saved_pos, newsize, i_size_read(inode)); + + /* No need for a higher level metadata lock if we're + * never going past i_size. */ + if (newsize <= i_size_read(inode)) + break; + + if (meta_level == 0) { + ocfs2_meta_unlock(inode, meta_level); + meta_level = 1; + continue; + } + + spin_lock(&OCFS2_I(inode)->ip_lock); + clusters = ocfs2_clusters_for_bytes(inode->i_sb, newsize) - + OCFS2_I(inode)->ip_clusters; + spin_unlock(&OCFS2_I(inode)->ip_lock); + + mlog(0, "Writing at EOF, may need more allocation: " + "i_size = %lld, newsize = %"MLFu64", need %u clusters\n", + i_size_read(inode), newsize, clusters); + + /* We only want to continue the rest of this loop if + * our extend will actually require more + * allocation. */ + if (!clusters) + break; + + ret = ocfs2_extend_allocation(inode, clusters); + if (ret < 0) { + if (ret != -ENOSPC) + mlog_errno(ret); + goto out; + } + + /* Fill any holes which would've been created by this + * write. If we're O_APPEND, this will wind up + * (correctly) being a noop. */ + ret = ocfs2_zero_extend(inode, (u64) newsize - count); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + break; + } + + /* ok, we're done with i_size and alloc work */ + iocb->ki_pos = saved_pos; + ocfs2_meta_unlock(inode, meta_level); + meta_level = -1; + + /* communicate with ocfs2_dio_end_io */ + ocfs2_iocb_set_rw_locked(iocb); + +#ifdef OCFS2_ORACORE_WORKAROUNDS + if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS && + filp->f_flags & O_DIRECT) { + unsigned int saved_flags = filp->f_flags; + int sector_size = 1 << osb->s_sectsize_bits; + + if ((saved_pos & (sector_size - 1)) || + (count & (sector_size - 1)) || + ((unsigned long)buf & (sector_size - 1))) { + filp->f_flags |= O_SYNC; + filp->f_flags &= ~O_DIRECT; + } + + ret = generic_file_aio_write_nolock(iocb, &local_iov, 1, + &iocb->ki_pos); + + filp->f_flags = saved_flags; + } else +#endif + ret = generic_file_aio_write_nolock(iocb, &local_iov, 1, + &iocb->ki_pos); + + /* buffered aio wouldn't have proper lock coverage today */ + BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); + + /* + * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io + * function pointer which is called when o_direct io completes so that + * it can unlock our rw lock. (it's the clustered equivalent of + * i_alloc_sem; protects truncate from racing with pending ios). + * Unfortunately there are error cases which call end_io and others + * that don't. so we don't have to unlock the rw_lock if either an + * async dio is going to do it in the future or an end_io after an + * error has already done it. + */ + if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb)) { + rw_level = -1; + have_alloc_sem = 0; + } + +out: + if (meta_level != -1) + ocfs2_meta_unlock(inode, meta_level); + if (have_alloc_sem) + up_read(&inode->i_alloc_sem); + if (rw_level != -1) + ocfs2_rw_unlock(inode, rw_level); + up(&inode->i_sem); + + mlog_exit(ret); + return ret; +} + +static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, + char __user *buf, + size_t count, + loff_t pos) +{ + int ret = 0, rw_level = -1, have_alloc_sem = 0; + struct file *filp = iocb->ki_filp; + struct inode *inode = filp->f_dentry->d_inode; +#ifdef OCFS2_ORACORE_WORKAROUNDS + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); +#endif + + mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, + (unsigned int)count, + filp->f_dentry->d_name.len, + filp->f_dentry->d_name.name); + + if (!inode) { + ret = -EINVAL; + mlog_errno(ret); + goto bail; + } + +#ifdef OCFS2_ORACORE_WORKAROUNDS + if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS) { + if (filp->f_flags & O_DIRECT) { + int sector_size = 1 << osb->s_sectsize_bits; + + if ((pos & (sector_size - 1)) || + (count & (sector_size - 1)) || + ((unsigned long)buf & (sector_size - 1)) || + (i_size_read(inode) & (sector_size -1))) { + filp->f_flags &= ~O_DIRECT; + } + } + } +#endif + + /* + * buffered reads protect themselves in ->readpage(). O_DIRECT reads + * need locks to protect pending reads from racing with truncate. + */ + if (filp->f_flags & O_DIRECT) { + down_read(&inode->i_alloc_sem); + have_alloc_sem = 1; + + ret = ocfs2_rw_lock(inode, 0); + if (ret < 0) { + mlog_errno(ret); + goto bail; + } + rw_level = 0; + /* communicate with ocfs2_dio_end_io */ + ocfs2_iocb_set_rw_locked(iocb); + } + + ret = generic_file_aio_read(iocb, buf, count, iocb->ki_pos); + if (ret == -EINVAL) + mlog(ML_ERROR, "generic_file_aio_read returned -EINVAL\n"); + + /* buffered aio wouldn't have proper lock coverage today */ + BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); + + /* see ocfs2_file_aio_write */ + if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb)) { + rw_level = -1; + have_alloc_sem = 0; + } + +bail: + if (have_alloc_sem) + up_read(&inode->i_alloc_sem); + if (rw_level != -1) + ocfs2_rw_unlock(inode, rw_level); + mlog_exit(ret); + + return ret; +} + +struct inode_operations ocfs2_file_iops = { + .setattr = ocfs2_setattr, + .getattr = ocfs2_getattr, +}; + +struct inode_operations ocfs2_special_file_iops = { + .setattr = ocfs2_setattr, + .getattr = ocfs2_getattr, +}; + +struct file_operations ocfs2_fops = { + .read = do_sync_read, + .write = do_sync_write, + .sendfile = generic_file_sendfile, + .mmap = ocfs2_mmap, + .fsync = ocfs2_sync_file, + .release = ocfs2_file_release, + .open = ocfs2_file_open, + .aio_read = ocfs2_file_aio_read, + .aio_write = ocfs2_file_aio_write, +}; + +struct file_operations ocfs2_dops = { + .read = generic_read_dir, + .readdir = ocfs2_readdir, + .fsync = ocfs2_sync_file, +}; diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h new file mode 100644 index 0000000..a5ea33b --- /dev/null +++ b/fs/ocfs2/file.h @@ -0,0 +1,57 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * file.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_FILE_H +#define OCFS2_FILE_H + +extern struct file_operations ocfs2_fops; +extern struct file_operations ocfs2_dops; +extern struct inode_operations ocfs2_file_iops; +extern struct inode_operations ocfs2_special_file_iops; +struct ocfs2_alloc_context; + +enum ocfs2_alloc_restarted { + RESTART_NONE = 0, + RESTART_TRANS, + RESTART_META +}; +int ocfs2_do_extend_allocation(struct ocfs2_super *osb, + struct inode *inode, + u32 clusters_to_add, + struct buffer_head *fe_bh, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *data_ac, + struct ocfs2_alloc_context *meta_ac, + enum ocfs2_alloc_restarted *reason); +int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); +int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, + struct kstat *stat); + +int ocfs2_set_inode_size(struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *fe_bh, + u64 new_i_size); + +#endif /* OCFS2_FILE_H */ diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c new file mode 100644 index 0000000..0bbd22f --- /dev/null +++ b/fs/ocfs2/heartbeat.c @@ -0,0 +1,378 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * heartbeat.c + * + * Register ourselves with the heartbaet service, keep our node maps + * up to date, and fire off recovery when needed. + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define MLOG_MASK_PREFIX ML_SUPER +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "heartbeat.h" +#include "inode.h" +#include "journal.h" +#include "vote.h" + +#include "buffer_head_io.h" + +#define OCFS2_HB_NODE_DOWN_PRI (0x0000002) +#define OCFS2_HB_NODE_UP_PRI OCFS2_HB_NODE_DOWN_PRI + +static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map *map, + int bit); +static inline void __ocfs2_node_map_clear_bit(struct ocfs2_node_map *map, + int bit); +static inline int __ocfs2_node_map_is_empty(struct ocfs2_node_map *map); +static void __ocfs2_node_map_dup(struct ocfs2_node_map *target, + struct ocfs2_node_map *from); +static void __ocfs2_node_map_set(struct ocfs2_node_map *target, + struct ocfs2_node_map *from); + +void ocfs2_init_node_maps(struct ocfs2_super *osb) +{ + spin_lock_init(&osb->node_map_lock); + ocfs2_node_map_init(&osb->mounted_map); + ocfs2_node_map_init(&osb->recovery_map); + ocfs2_node_map_init(&osb->umount_map); +} + +static void ocfs2_do_node_down(int node_num, + struct ocfs2_super *osb) +{ + BUG_ON(osb->node_num == node_num); + + mlog(0, "ocfs2: node down event for %d\n", node_num); + + if (!osb->dlm) { + /* + * No DLM means we're not even ready to participate yet. + * We check the slots after the DLM comes up, so we will + * notice the node death then. We can safely ignore it + * here. + */ + return; + } + + if (ocfs2_node_map_test_bit(osb, &osb->umount_map, node_num)) { + /* If a node is in the umount map, then we've been + * expecting him to go down and we know ahead of time + * that recovery is not necessary. */ + ocfs2_node_map_clear_bit(osb, &osb->umount_map, node_num); + return; + } + + ocfs2_recovery_thread(osb, node_num); + + ocfs2_remove_node_from_vote_queues(osb, node_num); +} + +static void ocfs2_hb_node_down_cb(struct o2nm_node *node, + int node_num, + void *data) +{ + ocfs2_do_node_down(node_num, (struct ocfs2_super *) data); +} + +/* Called from the dlm when it's about to evict a node. We may also + * get a heartbeat callback later. */ +static void ocfs2_dlm_eviction_cb(int node_num, + void *data) +{ + struct ocfs2_super *osb = (struct ocfs2_super *) data; + struct super_block *sb = osb->sb; + + mlog(ML_NOTICE, "device (%u,%u): dlm has evicted node %d\n", + MAJOR(sb->s_dev), MINOR(sb->s_dev), node_num); + + ocfs2_do_node_down(node_num, osb); +} + +static void ocfs2_hb_node_up_cb(struct o2nm_node *node, + int node_num, + void *data) +{ + struct ocfs2_super *osb = data; + + BUG_ON(osb->node_num == node_num); + + mlog(0, "node up event for %d\n", node_num); + ocfs2_node_map_clear_bit(osb, &osb->umount_map, node_num); +} + +void ocfs2_setup_hb_callbacks(struct ocfs2_super *osb) +{ + o2hb_setup_callback(&osb->osb_hb_down, O2HB_NODE_DOWN_CB, + ocfs2_hb_node_down_cb, osb, + OCFS2_HB_NODE_DOWN_PRI); + + o2hb_setup_callback(&osb->osb_hb_up, O2HB_NODE_UP_CB, + ocfs2_hb_node_up_cb, osb, OCFS2_HB_NODE_UP_PRI); + + /* Not exactly a heartbeat callback, but leads to essentially + * the same path so we set it up here. */ + dlm_setup_eviction_cb(&osb->osb_eviction_cb, + ocfs2_dlm_eviction_cb, + osb); +} + +/* Most functions here are just stubs for now... */ +int ocfs2_register_hb_callbacks(struct ocfs2_super *osb) +{ + int status; + + status = o2hb_register_callback(&osb->osb_hb_down); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = o2hb_register_callback(&osb->osb_hb_up); + if (status < 0) + mlog_errno(status); + +bail: + return status; +} + +void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb) +{ + int status; + + status = o2hb_unregister_callback(&osb->osb_hb_down); + if (status < 0) + mlog_errno(status); + + status = o2hb_unregister_callback(&osb->osb_hb_up); + if (status < 0) + mlog_errno(status); +} + +void ocfs2_stop_heartbeat(struct ocfs2_super *osb) +{ + int ret; + char *argv[5], *envp[3]; + + if (!osb->uuid_str) { + /* This can happen if we don't get far enough in mount... */ + mlog(0, "No UUID with which to stop heartbeat!\n\n"); + return; + } + + argv[0] = (char *)o2nm_get_hb_ctl_path(); + argv[1] = "-K"; + argv[2] = "-u"; + argv[3] = osb->uuid_str; + argv[4] = NULL; + + mlog(0, "Run: %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3]); + + /* minimal command environment taken from cpu_run_sbin_hotplug */ + envp[0] = "HOME=/"; + envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; + envp[2] = NULL; + + ret = call_usermodehelper(argv[0], argv, envp, 1); + if (ret < 0) + mlog_errno(ret); +} + +/* special case -1 for now + * TODO: should *really* make sure the calling func never passes -1!! */ +void ocfs2_node_map_init(struct ocfs2_node_map *map) +{ + map->num_nodes = OCFS2_NODE_MAP_MAX_NODES; + memset(map->map, 0, BITS_TO_LONGS(OCFS2_NODE_MAP_MAX_NODES) * + sizeof(unsigned long)); +} + +static inline void __ocfs2_node_map_set_bit(struct ocfs2_node_map *map, + int bit) +{ + set_bit(bit, map->map); +} + +void ocfs2_node_map_set_bit(struct ocfs2_super *osb, + struct ocfs2_node_map *map, + int bit) +{ + if (bit==-1) + return; + BUG_ON(bit >= map->num_nodes); + spin_lock(&osb->node_map_lock); + __ocfs2_node_map_set_bit(map, bit); + spin_unlock(&osb->node_map_lock); +} + +static inline void __ocfs2_node_map_clear_bit(struct ocfs2_node_map *map, + int bit) +{ + clear_bit(bit, map->map); +} + +void ocfs2_node_map_clear_bit(struct ocfs2_super *osb, + struct ocfs2_node_map *map, + int bit) +{ + if (bit==-1) + return; + BUG_ON(bit >= map->num_nodes); + spin_lock(&osb->node_map_lock); + __ocfs2_node_map_clear_bit(map, bit); + spin_unlock(&osb->node_map_lock); +} + +int ocfs2_node_map_test_bit(struct ocfs2_super *osb, + struct ocfs2_node_map *map, + int bit) +{ + int ret; + if (bit >= map->num_nodes) { + mlog(ML_ERROR, "bit=%d map->num_nodes=%d\n", bit, map->num_nodes); + BUG(); + } + spin_lock(&osb->node_map_lock); + ret = test_bit(bit, map->map); + spin_unlock(&osb->node_map_lock); + return ret; +} + +static inline int __ocfs2_node_map_is_empty(struct ocfs2_node_map *map) +{ + int bit; + bit = find_next_bit(map->map, map->num_nodes, 0); + if (bit < map->num_nodes) + return 0; + return 1; +} + +int ocfs2_node_map_is_empty(struct ocfs2_super *osb, + struct ocfs2_node_map *map) +{ + int ret; + BUG_ON(map->num_nodes == 0); + spin_lock(&osb->node_map_lock); + ret = __ocfs2_node_map_is_empty(map); + spin_unlock(&osb->node_map_lock); + return ret; +} + +static void __ocfs2_node_map_dup(struct ocfs2_node_map *target, + struct ocfs2_node_map *from) +{ + BUG_ON(from->num_nodes == 0); + ocfs2_node_map_init(target); + __ocfs2_node_map_set(target, from); +} + +/* returns 1 if bit is the only bit set in target, 0 otherwise */ +int ocfs2_node_map_is_only(struct ocfs2_super *osb, + struct ocfs2_node_map *target, + int bit) +{ + struct ocfs2_node_map temp; + int ret; + + spin_lock(&osb->node_map_lock); + __ocfs2_node_map_dup(&temp, target); + __ocfs2_node_map_clear_bit(&temp, bit); + ret = __ocfs2_node_map_is_empty(&temp); + spin_unlock(&osb->node_map_lock); + + return ret; +} + +static void __ocfs2_node_map_set(struct ocfs2_node_map *target, + struct ocfs2_node_map *from) +{ + int num_longs, i; + + BUG_ON(target->num_nodes != from->num_nodes); + BUG_ON(target->num_nodes == 0); + + num_longs = BITS_TO_LONGS(target->num_nodes); + for (i = 0; i < num_longs; i++) + target->map[i] = from->map[i]; +} + +/* Returns whether the recovery bit was actually set - it may not be + * if a node is still marked as needing recovery */ +int ocfs2_recovery_map_set(struct ocfs2_super *osb, + int num) +{ + int set = 0; + + spin_lock(&osb->node_map_lock); + + __ocfs2_node_map_clear_bit(&osb->mounted_map, num); + + if (!test_bit(num, osb->recovery_map.map)) { + __ocfs2_node_map_set_bit(&osb->recovery_map, num); + set = 1; + } + + spin_unlock(&osb->node_map_lock); + + return set; +} + +void ocfs2_recovery_map_clear(struct ocfs2_super *osb, + int num) +{ + ocfs2_node_map_clear_bit(osb, &osb->recovery_map, num); +} + +int ocfs2_node_map_iterate(struct ocfs2_super *osb, + struct ocfs2_node_map *map, + int idx) +{ + int i = idx; + + idx = O2NM_INVALID_NODE_NUM; + spin_lock(&osb->node_map_lock); + if ((i != O2NM_INVALID_NODE_NUM) && + (i >= 0) && + (i < map->num_nodes)) { + while(i < map->num_nodes) { + if (test_bit(i, map->map)) { + idx = i; + break; + } + i++; + } + } + spin_unlock(&osb->node_map_lock); + return idx; +} diff --git a/fs/ocfs2/heartbeat.h b/fs/ocfs2/heartbeat.h new file mode 100644 index 0000000..e8fb079 --- /dev/null +++ b/fs/ocfs2/heartbeat.h @@ -0,0 +1,67 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * heartbeat.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_HEARTBEAT_H +#define OCFS2_HEARTBEAT_H + +void ocfs2_init_node_maps(struct ocfs2_super *osb); + +void ocfs2_setup_hb_callbacks(struct ocfs2_super *osb); +int ocfs2_register_hb_callbacks(struct ocfs2_super *osb); +void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb); +void ocfs2_stop_heartbeat(struct ocfs2_super *osb); + +/* node map functions - used to keep track of mounted and in-recovery + * nodes. */ +void ocfs2_node_map_init(struct ocfs2_node_map *map); +int ocfs2_node_map_is_empty(struct ocfs2_super *osb, + struct ocfs2_node_map *map); +void ocfs2_node_map_set_bit(struct ocfs2_super *osb, + struct ocfs2_node_map *map, + int bit); +void ocfs2_node_map_clear_bit(struct ocfs2_super *osb, + struct ocfs2_node_map *map, + int bit); +int ocfs2_node_map_test_bit(struct ocfs2_super *osb, + struct ocfs2_node_map *map, + int bit); +int ocfs2_node_map_iterate(struct ocfs2_super *osb, + struct ocfs2_node_map *map, + int idx); +static inline int ocfs2_node_map_first_set_bit(struct ocfs2_super *osb, + struct ocfs2_node_map *map) +{ + return ocfs2_node_map_iterate(osb, map, 0); +} +int ocfs2_recovery_map_set(struct ocfs2_super *osb, + int num); +void ocfs2_recovery_map_clear(struct ocfs2_super *osb, + int num); +/* returns 1 if bit is the only bit set in target, 0 otherwise */ +int ocfs2_node_map_is_only(struct ocfs2_super *osb, + struct ocfs2_node_map *target, + int bit); + +#endif /* OCFS2_HEARTBEAT_H */ diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c new file mode 100644 index 0000000..a91ba4d --- /dev/null +++ b/fs/ocfs2/inode.c @@ -0,0 +1,1140 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * inode.c + * + * vfs' aops, fops, dops and iops + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#define MLOG_MASK_PREFIX ML_INODE +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "file.h" +#include "inode.h" +#include "journal.h" +#include "namei.h" +#include "suballoc.h" +#include "super.h" +#include "symlink.h" +#include "sysfile.h" +#include "uptodate.h" +#include "vote.h" + +#include "buffer_head_io.h" + +#define OCFS2_FI_FLAG_NOWAIT 0x1 +#define OCFS2_FI_FLAG_DELETE 0x2 +struct ocfs2_find_inode_args +{ + u64 fi_blkno; + unsigned long fi_ino; + unsigned int fi_flags; +}; + +static int ocfs2_read_locked_inode(struct inode *inode, + struct ocfs2_find_inode_args *args); +static int ocfs2_init_locked_inode(struct inode *inode, void *opaque); +static int ocfs2_find_actor(struct inode *inode, void *opaque); +static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh); + +struct inode *ocfs2_ilookup_for_vote(struct ocfs2_super *osb, + u64 blkno, + int delete_vote) +{ + struct ocfs2_find_inode_args args; + + /* ocfs2_ilookup_for_vote should *only* be called from the + * vote thread */ + BUG_ON(current != osb->vote_task); + + args.fi_blkno = blkno; + args.fi_flags = OCFS2_FI_FLAG_NOWAIT; + if (delete_vote) + args.fi_flags |= OCFS2_FI_FLAG_DELETE; + args.fi_ino = ino_from_blkno(osb->sb, blkno); + return ilookup5(osb->sb, args.fi_ino, ocfs2_find_actor, &args); +} + +struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno) +{ + struct inode *inode = NULL; + struct super_block *sb = osb->sb; + struct ocfs2_find_inode_args args; + + mlog_entry("(blkno = %"MLFu64")\n", blkno); + + /* Ok. By now we've either got the offsets passed to us by the + * caller, or we just pulled them off the bh. Lets do some + * sanity checks to make sure they're OK. */ + if (blkno == 0) { + inode = ERR_PTR(-EINVAL); + mlog_errno(PTR_ERR(inode)); + goto bail; + } + + args.fi_blkno = blkno; + args.fi_flags = 0; + args.fi_ino = ino_from_blkno(sb, blkno); + + inode = iget5_locked(sb, args.fi_ino, ocfs2_find_actor, + ocfs2_init_locked_inode, &args); + /* inode was *not* in the inode cache. 2.6.x requires + * us to do our own read_inode call and unlock it + * afterwards. */ + if (inode && inode->i_state & I_NEW) { + mlog(0, "Inode was not in inode cache, reading it.\n"); + ocfs2_read_locked_inode(inode, &args); + unlock_new_inode(inode); + } + if (inode == NULL) { + inode = ERR_PTR(-ENOMEM); + mlog_errno(PTR_ERR(inode)); + goto bail; + } + if (is_bad_inode(inode)) { + iput(inode); + inode = ERR_PTR(-ESTALE); + mlog_errno(PTR_ERR(inode)); + goto bail; + } + +bail: + if (!IS_ERR(inode)) { + mlog(0, "returning inode with number %"MLFu64"\n", + OCFS2_I(inode)->ip_blkno); + mlog_exit_ptr(inode); + } else + mlog_errno(PTR_ERR(inode)); + + return inode; +} + + +/* + * here's how inodes get read from disk: + * iget5_locked -> find_actor -> OCFS2_FIND_ACTOR + * found? : return the in-memory inode + * not found? : get_new_inode -> OCFS2_INIT_LOCKED_INODE + */ + +static int ocfs2_find_actor(struct inode *inode, void *opaque) +{ + struct ocfs2_find_inode_args *args = NULL; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + int ret = 0; + + mlog_entry("(0x%p, %lu, 0x%p)\n", inode, inode->i_ino, opaque); + + args = opaque; + + mlog_bug_on_msg(!inode, "No inode in find actor!\n"); + + if (oi->ip_blkno != args->fi_blkno) + goto bail; + + /* OCFS2_FI_FLAG_NOWAIT is *only* set from + * ocfs2_ilookup_for_vote which won't create an inode for one + * that isn't found. The vote thread which doesn't want to get + * an inode which is in the process of going away - otherwise + * the call to __wait_on_freeing_inode in find_inode_fast will + * cause it to deadlock on an inode which may be waiting on a + * vote (or lock release) in delete_inode */ + if ((args->fi_flags & OCFS2_FI_FLAG_NOWAIT) && + (inode->i_state & (I_FREEING|I_CLEAR))) { + /* As stated above, we're not going to return an + * inode. In the case of a delete vote, the voting + * code is going to signal the other node to go + * ahead. Mark that state here, so this freeing inode + * has the state when it gets to delete_inode. */ + if (args->fi_flags & OCFS2_FI_FLAG_DELETE) { + spin_lock(&oi->ip_lock); + ocfs2_mark_inode_remotely_deleted(inode); + spin_unlock(&oi->ip_lock); + } + goto bail; + } + + ret = 1; +bail: + mlog_exit(ret); + return ret; +} + +/* + * initialize the new inode, but don't do anything that would cause + * us to sleep. + * return 0 on success, 1 on failure + */ +static int ocfs2_init_locked_inode(struct inode *inode, void *opaque) +{ + struct ocfs2_find_inode_args *args = opaque; + + mlog_entry("inode = %p, opaque = %p\n", inode, opaque); + + inode->i_ino = args->fi_ino; + OCFS2_I(inode)->ip_blkno = args->fi_blkno; + + mlog_exit(0); + return 0; +} + +int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, + int create_ino) +{ + struct super_block *sb; + struct ocfs2_super *osb; + int status = -EINVAL; + + mlog_entry("(0x%p, size:%"MLFu64")\n", inode, fe->i_size); + + sb = inode->i_sb; + osb = OCFS2_SB(sb); + + /* this means that read_inode cannot create a superblock inode + * today. change if needed. */ + if (!OCFS2_IS_VALID_DINODE(fe) || + !(fe->i_flags & cpu_to_le32(OCFS2_VALID_FL))) { + mlog(ML_ERROR, "Invalid dinode: i_ino=%lu, i_blkno=%"MLFu64", " + "signature = %.*s, flags = 0x%x\n", + inode->i_ino, le64_to_cpu(fe->i_blkno), 7, + fe->i_signature, le32_to_cpu(fe->i_flags)); + goto bail; + } + + if (le32_to_cpu(fe->i_fs_generation) != osb->fs_generation) { + mlog(ML_ERROR, "file entry generation does not match " + "superblock! osb->fs_generation=%x, " + "fe->i_fs_generation=%x\n", + osb->fs_generation, le32_to_cpu(fe->i_fs_generation)); + goto bail; + } + + inode->i_version = 1; + inode->i_generation = le32_to_cpu(fe->i_generation); + inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev)); + inode->i_mode = le16_to_cpu(fe->i_mode); + inode->i_uid = le32_to_cpu(fe->i_uid); + inode->i_gid = le32_to_cpu(fe->i_gid); + inode->i_blksize = (u32)osb->s_clustersize; + + /* Fast symlinks will have i_size but no allocated clusters. */ + if (S_ISLNK(inode->i_mode) && !fe->i_clusters) + inode->i_blocks = 0; + else + inode->i_blocks = + ocfs2_align_bytes_to_sectors(le64_to_cpu(fe->i_size)); + inode->i_mapping->a_ops = &ocfs2_aops; + inode->i_flags |= S_NOATIME; + inode->i_atime.tv_sec = le64_to_cpu(fe->i_atime); + inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec); + inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime); + inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec); + inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime); + inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec); + + if (OCFS2_I(inode)->ip_blkno != le64_to_cpu(fe->i_blkno)) + mlog(ML_ERROR, + "ip_blkno %"MLFu64" != i_blkno %"MLFu64"!\n", + OCFS2_I(inode)->ip_blkno, fe->i_blkno); + + OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters); + OCFS2_I(inode)->ip_orphaned_slot = OCFS2_INVALID_SLOT; + + if (create_ino) + inode->i_ino = ino_from_blkno(inode->i_sb, + le64_to_cpu(fe->i_blkno)); + + mlog(0, "blkno = %"MLFu64", ino = %lu, create_ino = %s\n", + fe->i_blkno, inode->i_ino, create_ino ? "true" : "false"); + + inode->i_nlink = le16_to_cpu(fe->i_links_count); + + if (fe->i_flags & cpu_to_le32(OCFS2_LOCAL_ALLOC_FL)) { + OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP; + mlog(0, "local alloc inode: i_ino=%lu\n", inode->i_ino); + } else if (fe->i_flags & cpu_to_le32(OCFS2_BITMAP_FL)) { + OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP; + } else if (fe->i_flags & cpu_to_le32(OCFS2_SUPER_BLOCK_FL)) { + mlog(0, "superblock inode: i_ino=%lu\n", inode->i_ino); + /* we can't actually hit this as read_inode can't + * handle superblocks today ;-) */ + BUG(); + } + + switch (inode->i_mode & S_IFMT) { + case S_IFREG: + inode->i_fop = &ocfs2_fops; + inode->i_op = &ocfs2_file_iops; + i_size_write(inode, le64_to_cpu(fe->i_size)); + break; + case S_IFDIR: + inode->i_op = &ocfs2_dir_iops; + inode->i_fop = &ocfs2_dops; + i_size_write(inode, le64_to_cpu(fe->i_size)); + break; + case S_IFLNK: + if (ocfs2_inode_is_fast_symlink(inode)) + inode->i_op = &ocfs2_fast_symlink_inode_operations; + else + inode->i_op = &ocfs2_symlink_inode_operations; + i_size_write(inode, le64_to_cpu(fe->i_size)); + break; + default: + inode->i_op = &ocfs2_special_file_iops; + init_special_inode(inode, inode->i_mode, + inode->i_rdev); + break; + } + + ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_rw_lockres, + OCFS2_LOCK_TYPE_RW, inode); + ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_meta_lockres, + OCFS2_LOCK_TYPE_META, inode); + ocfs2_inode_lock_res_init(&OCFS2_I(inode)->ip_data_lockres, + OCFS2_LOCK_TYPE_DATA, inode); + + status = 0; +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_read_locked_inode(struct inode *inode, + struct ocfs2_find_inode_args *args) +{ + struct super_block *sb; + struct ocfs2_super *osb; + struct ocfs2_dinode *fe; + struct buffer_head *bh = NULL; + int status; + int sysfile = 0; + + mlog_entry("(0x%p, 0x%p)\n", inode, args); + + status = -EINVAL; + if (inode == NULL || inode->i_sb == NULL) { + mlog(ML_ERROR, "bad inode\n"); + goto bail; + } + sb = inode->i_sb; + osb = OCFS2_SB(sb); + + if (!args) { + mlog(ML_ERROR, "bad inode args\n"); + make_bad_inode(inode); + goto bail; + } + + /* Read the FE off disk. This is safe because the kernel only + * does one read_inode2 for a new inode, and if it doesn't + * exist yet then nobody can be working on it! */ + status = ocfs2_read_block(osb, args->fi_blkno, &bh, 0, NULL); + if (status < 0) { + mlog_errno(status); + make_bad_inode(inode); + goto bail; + } + + fe = (struct ocfs2_dinode *) bh->b_data; + if (!OCFS2_IS_VALID_DINODE(fe)) { + mlog(ML_ERROR, "Invalid dinode #%"MLFu64": signature = %.*s\n", + fe->i_blkno, 7, fe->i_signature); + make_bad_inode(inode); + goto bail; + } + + if (fe->i_flags & cpu_to_le32(OCFS2_SYSTEM_FL)) + sysfile = 1; + + if (S_ISCHR(le16_to_cpu(fe->i_mode)) || + S_ISBLK(le16_to_cpu(fe->i_mode))) + inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev)); + + status = -EINVAL; + if (ocfs2_populate_inode(inode, fe, 0) < 0) { + mlog(ML_ERROR, "populate inode failed! i_blkno=%"MLFu64", " + "i_ino=%lu\n", fe->i_blkno, inode->i_ino); + make_bad_inode(inode); + goto bail; + } + + BUG_ON(args->fi_blkno != le64_to_cpu(fe->i_blkno)); + + if (sysfile) + OCFS2_I(inode)->ip_flags |= OCFS2_INODE_SYSTEM_FILE; + + status = 0; + +bail: + if (args && bh) + brelse(bh); + + mlog_exit(status); + return status; +} + +void ocfs2_sync_blockdev(struct super_block *sb) +{ + sync_blockdev(sb->s_bdev); +} + +static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, + struct inode *inode, + struct buffer_head *fe_bh) +{ + int status = 0; + struct ocfs2_journal_handle *handle = NULL; + struct ocfs2_truncate_context *tc = NULL; + struct ocfs2_dinode *fe; + + mlog_entry_void(); + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + + /* zero allocation, zero truncate :) */ + if (!fe->i_clusters) + goto bail; + + handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + status = ocfs2_set_inode_size(handle, inode, fe_bh, 0ULL); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + ocfs2_commit_trans(handle); + handle = NULL; + + status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_commit_truncate(osb, inode, fe_bh, tc); + if (status < 0) { + mlog_errno(status); + goto bail; + } +bail: + if (handle) + ocfs2_commit_trans(handle); + + mlog_exit(status); + return status; +} + +static int ocfs2_remove_inode(struct inode *inode, + struct buffer_head *di_bh, + struct inode *orphan_dir_inode, + struct buffer_head *orphan_dir_bh) +{ + int status; + struct inode *inode_alloc_inode = NULL; + struct buffer_head *inode_alloc_bh = NULL; + struct ocfs2_journal_handle *handle; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; + + inode_alloc_inode = + ocfs2_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE, + le16_to_cpu(di->i_suballoc_slot)); + if (!inode_alloc_inode) { + status = -EEXIST; + mlog_errno(status); + goto bail; + } + + down(&inode_alloc_inode->i_sem); + status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1); + if (status < 0) { + up(&inode_alloc_inode->i_sem); + + mlog_errno(status); + goto bail; + } + + handle = ocfs2_start_trans(osb, NULL, OCFS2_DELETE_INODE_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + mlog_errno(status); + goto bail_unlock; + } + + status = ocfs2_orphan_del(osb, handle, orphan_dir_inode, inode, + orphan_dir_bh); + if (status < 0) { + mlog_errno(status); + goto bail_commit; + } + + /* set the inodes dtime */ + status = ocfs2_journal_access(handle, inode, di_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail_commit; + } + + di->i_dtime = cpu_to_le64(CURRENT_TIME.tv_sec); + le32_and_cpu(&di->i_flags, ~(OCFS2_VALID_FL | OCFS2_ORPHANED_FL)); + + status = ocfs2_journal_dirty(handle, di_bh); + if (status < 0) { + mlog_errno(status); + goto bail_commit; + } + + ocfs2_remove_from_cache(inode, di_bh); + + status = ocfs2_free_dinode(handle, inode_alloc_inode, + inode_alloc_bh, di); + if (status < 0) + mlog_errno(status); + +bail_commit: + ocfs2_commit_trans(handle); +bail_unlock: + ocfs2_meta_unlock(inode_alloc_inode, 1); + up(&inode_alloc_inode->i_sem); + brelse(inode_alloc_bh); +bail: + iput(inode_alloc_inode); + + return status; +} + +static int ocfs2_wipe_inode(struct inode *inode, + struct buffer_head *di_bh) +{ + int status, orphaned_slot; + struct inode *orphan_dir_inode = NULL; + struct buffer_head *orphan_dir_bh = NULL; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + /* We've already voted on this so it should be readonly - no + * spinlock needed. */ + orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot; + orphan_dir_inode = ocfs2_get_system_file_inode(osb, + ORPHAN_DIR_SYSTEM_INODE, + orphaned_slot); + if (!orphan_dir_inode) { + status = -EEXIST; + mlog_errno(status); + goto bail; + } + + /* Lock the orphan dir. The lock will be held for the entire + * delete_inode operation. We do this now to avoid races with + * recovery completion on other nodes. */ + down(&orphan_dir_inode->i_sem); + status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1); + if (status < 0) { + up(&orphan_dir_inode->i_sem); + + mlog_errno(status); + goto bail; + } + + /* we do this while holding the orphan dir lock because we + * don't want recovery being run from another node to vote for + * an inode delete on us -- this will result in two nodes + * truncating the same file! */ + status = ocfs2_truncate_for_delete(osb, inode, di_bh); + if (status < 0) { + mlog_errno(status); + goto bail_unlock_dir; + } + + status = ocfs2_remove_inode(inode, di_bh, orphan_dir_inode, + orphan_dir_bh); + if (status < 0) + mlog_errno(status); + +bail_unlock_dir: + ocfs2_meta_unlock(orphan_dir_inode, 1); + up(&orphan_dir_inode->i_sem); + brelse(orphan_dir_bh); +bail: + iput(orphan_dir_inode); + + return status; +} + +/* There is a series of simple checks that should be done before a + * vote is even considered. Encapsulate those in this function. */ +static int ocfs2_inode_is_valid_to_delete(struct inode *inode) +{ + int ret = 0; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + /* We shouldn't be getting here for the root directory + * inode.. */ + if (inode == osb->root_inode) { + mlog(ML_ERROR, "Skipping delete of root inode.\n"); + goto bail; + } + + /* If we're coming from process_vote we can't go into our own + * voting [hello, deadlock city!], so unforuntately we just + * have to skip deleting this guy. That's OK though because + * the node who's doing the actual deleting should handle it + * anyway. */ + if (current == osb->vote_task) { + mlog(0, "Skipping delete of %lu because we're currently " + "in process_vote\n", inode->i_ino); + goto bail; + } + + spin_lock(&oi->ip_lock); + /* OCFS2 *never* deletes system files. This should technically + * never get here as system file inodes should always have a + * positive link count. */ + if (oi->ip_flags & OCFS2_INODE_SYSTEM_FILE) { + mlog(ML_ERROR, "Skipping delete of system file %"MLFu64".\n", + oi->ip_blkno); + goto bail_unlock; + } + + /* If we have voted "yes" on the wipe of this inode for + * another node, it will be marked here so we can safely skip + * it. Recovery will cleanup any inodes we might inadvertantly + * skip here. */ + if (oi->ip_flags & OCFS2_INODE_SKIP_DELETE) { + mlog(0, "Skipping delete of %lu because another node " + "has done this for us.\n", inode->i_ino); + goto bail_unlock; + } + + ret = 1; +bail_unlock: + spin_unlock(&oi->ip_lock); +bail: + return ret; +} + +/* Query the cluster to determine whether we should wipe an inode from + * disk or not. + * + * Requires the inode to have the cluster lock. */ +static int ocfs2_query_inode_wipe(struct inode *inode, + struct buffer_head *di_bh, + int *wipe) +{ + int status = 0; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_dinode *di; + + *wipe = 0; + + /* While we were waiting for the cluster lock in + * ocfs2_delete_inode, another node might have asked to delete + * the inode. Recheck our flags to catch this. */ + if (!ocfs2_inode_is_valid_to_delete(inode)) { + mlog(0, "Skipping delete of %"MLFu64" because flags changed\n", + oi->ip_blkno); + goto bail; + } + + /* Now that we have an up to date inode, we can double check + * the link count. */ + if (inode->i_nlink) { + mlog(0, "Skipping delete of %"MLFu64" because nlink = %u\n", + oi->ip_blkno, inode->i_nlink); + goto bail; + } + + /* Do some basic inode verification... */ + di = (struct ocfs2_dinode *) di_bh->b_data; + if (!(di->i_flags & cpu_to_le32(OCFS2_ORPHANED_FL))) { + /* for lack of a better error? */ + status = -EEXIST; + mlog(ML_ERROR, + "Inode %"MLFu64" (on-disk %"MLFu64") not orphaned! " + "Disk flags 0x%x, inode flags 0x%x\n", + oi->ip_blkno, di->i_blkno, di->i_flags, oi->ip_flags); + goto bail; + } + + /* has someone already deleted us?! baaad... */ + if (di->i_dtime) { + status = -EEXIST; + mlog_errno(status); + goto bail; + } + + status = ocfs2_request_delete_vote(inode); + /* -EBUSY means that other nodes are still using the + * inode. We're done here though, so avoid doing anything on + * disk and let them worry about deleting it. */ + if (status == -EBUSY) { + status = 0; + mlog(0, "Skipping delete of %"MLFu64" because it is in use on" + "other nodes\n", oi->ip_blkno); + goto bail; + } + if (status < 0) { + mlog_errno(status); + goto bail; + } + + spin_lock(&oi->ip_lock); + if (oi->ip_orphaned_slot == OCFS2_INVALID_SLOT) { + /* Nobody knew which slot this inode was orphaned + * into. This may happen during node death and + * recovery knows how to clean it up so we can safely + * ignore this inode for now on. */ + mlog(0, "Nobody knew where inode %"MLFu64" was orphaned!\n", + oi->ip_blkno); + } else { + *wipe = 1; + + mlog(0, "Inode %"MLFu64" is ok to wipe from orphan dir %d\n", + oi->ip_blkno, oi->ip_orphaned_slot); + } + spin_unlock(&oi->ip_lock); + +bail: + return status; +} + +/* Support function for ocfs2_delete_inode. Will help us keep the + * inode data in a consistent state for clear_inode. Always truncates + * pages, optionally sync's them first. */ +static void ocfs2_cleanup_delete_inode(struct inode *inode, + int sync_data) +{ + mlog(0, "Cleanup inode %"MLFu64", sync = %d\n", + OCFS2_I(inode)->ip_blkno, sync_data); + if (sync_data) + write_inode_now(inode, 1); + truncate_inode_pages(&inode->i_data, 0); +} + +void ocfs2_delete_inode(struct inode *inode) +{ + int wipe, status; + sigset_t blocked, oldset; + struct buffer_head *di_bh = NULL; + + mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); + + if (is_bad_inode(inode)) { + mlog(0, "Skipping delete of bad inode\n"); + goto bail; + } + + if (!ocfs2_inode_is_valid_to_delete(inode)) { + /* It's probably not necessary to truncate_inode_pages + * here but we do it for safety anyway (it will most + * likely be a no-op anyway) */ + ocfs2_cleanup_delete_inode(inode, 0); + goto bail; + } + + /* We want to block signals in delete_inode as the lock and + * messaging paths may return us -ERESTARTSYS. Which would + * cause us to exit early, resulting in inodes being orphaned + * forever. */ + sigfillset(&blocked); + status = sigprocmask(SIG_BLOCK, &blocked, &oldset); + if (status < 0) { + mlog_errno(status); + ocfs2_cleanup_delete_inode(inode, 1); + goto bail; + } + + /* Lock down the inode. This gives us an up to date view of + * it's metadata (for verification), and allows us to + * serialize delete_inode votes. + * + * Even though we might be doing a truncate, we don't take the + * allocation lock here as it won't be needed - nobody will + * have the file open. + */ + status = ocfs2_meta_lock(inode, NULL, &di_bh, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + ocfs2_cleanup_delete_inode(inode, 0); + goto bail_unblock; + } + + /* Query the cluster. This will be the final decision made + * before we go ahead and wipe the inode. */ + status = ocfs2_query_inode_wipe(inode, di_bh, &wipe); + if (!wipe || status < 0) { + /* Error and inode busy vote both mean we won't be + * removing the inode, so they take almost the same + * path. */ + if (status < 0) + mlog_errno(status); + + /* Someone in the cluster has voted to not wipe this + * inode, or it was never completely orphaned. Write + * out the pages and exit now. */ + ocfs2_cleanup_delete_inode(inode, 1); + goto bail_unlock_inode; + } + + ocfs2_cleanup_delete_inode(inode, 0); + + status = ocfs2_wipe_inode(inode, di_bh); + if (status < 0) { + mlog_errno(status); + goto bail_unlock_inode; + } + + /* Mark the inode as successfully deleted. This is important + * for ocfs2_clear_inode as it will check this flag and skip + * any checkpointing work */ + OCFS2_I(inode)->ip_flags |= OCFS2_INODE_DELETED; + +bail_unlock_inode: + ocfs2_meta_unlock(inode, 1); + brelse(di_bh); +bail_unblock: + status = sigprocmask(SIG_SETMASK, &oldset, NULL); + if (status < 0) + mlog_errno(status); +bail: + clear_inode(inode); + mlog_exit_void(); +} + +void ocfs2_clear_inode(struct inode *inode) +{ + int status; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + + mlog_entry_void(); + + if (!inode) + goto bail; + + mlog(0, "Clearing inode: %"MLFu64", nlink = %u\n", + OCFS2_I(inode)->ip_blkno, inode->i_nlink); + + mlog_bug_on_msg(OCFS2_SB(inode->i_sb) == NULL, + "Inode=%lu\n", inode->i_ino); + + /* Do these before all the other work so that we don't bounce + * the vote thread while waiting to destroy the locks. */ + ocfs2_mark_lockres_freeing(&oi->ip_rw_lockres); + ocfs2_mark_lockres_freeing(&oi->ip_meta_lockres); + ocfs2_mark_lockres_freeing(&oi->ip_data_lockres); + + /* We very well may get a clear_inode before all an inodes + * metadata has hit disk. Of course, we can't drop any cluster + * locks until the journal has finished with it. The only + * exception here are successfully wiped inodes - their + * metadata can now be considered to be part of the system + * inodes from which it came. */ + if (!(OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED)) + ocfs2_checkpoint_inode(inode); + + mlog_bug_on_msg(!list_empty(&oi->ip_io_markers), + "Clear inode of %"MLFu64", inode has io markers\n", + oi->ip_blkno); + + ocfs2_extent_map_drop(inode, 0); + ocfs2_extent_map_init(inode); + + status = ocfs2_drop_inode_locks(inode); + if (status < 0) + mlog_errno(status); + + ocfs2_lock_res_free(&oi->ip_rw_lockres); + ocfs2_lock_res_free(&oi->ip_meta_lockres); + ocfs2_lock_res_free(&oi->ip_data_lockres); + + ocfs2_metadata_cache_purge(inode); + + mlog_bug_on_msg(oi->ip_metadata_cache.ci_num_cached, + "Clear inode of %"MLFu64", inode has %u cache items\n", + oi->ip_blkno, oi->ip_metadata_cache.ci_num_cached); + + mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE), + "Clear inode of %"MLFu64", inode has a bad flag\n", + oi->ip_blkno); + + mlog_bug_on_msg(spin_is_locked(&oi->ip_lock), + "Clear inode of %"MLFu64", inode is locked\n", + oi->ip_blkno); + + mlog_bug_on_msg(down_trylock(&oi->ip_io_sem), + "Clear inode of %"MLFu64", io_sem is locked\n", + oi->ip_blkno); + up(&oi->ip_io_sem); + + /* + * down_trylock() returns 0, down_write_trylock() returns 1 + * kernel 1, world 0 + */ + mlog_bug_on_msg(!down_write_trylock(&oi->ip_alloc_sem), + "Clear inode of %"MLFu64", alloc_sem is locked\n", + oi->ip_blkno); + up_write(&oi->ip_alloc_sem); + + mlog_bug_on_msg(oi->ip_open_count, + "Clear inode of %"MLFu64" has open count %d\n", + oi->ip_blkno, oi->ip_open_count); + mlog_bug_on_msg(!list_empty(&oi->ip_handle_list), + "Clear inode of %"MLFu64" has non empty handle list\n", + oi->ip_blkno); + mlog_bug_on_msg(oi->ip_handle, + "Clear inode of %"MLFu64" has non empty handle pointer\n", + oi->ip_blkno); + + /* Clear all other flags. */ + oi->ip_flags = OCFS2_INODE_CACHE_INLINE; + oi->ip_created_trans = 0; + oi->ip_last_trans = 0; + oi->ip_dir_start_lookup = 0; + oi->ip_blkno = 0ULL; + +bail: + mlog_exit_void(); +} + +/* Called under inode_lock, with no more references on the + * struct inode, so it's safe here to check the flags field + * and to manipulate i_nlink without any other locks. */ +void ocfs2_drop_inode(struct inode *inode) +{ + struct ocfs2_inode_info *oi = OCFS2_I(inode); + + mlog_entry_void(); + + mlog(0, "Drop inode %"MLFu64", nlink = %u, ip_flags = 0x%x\n", + oi->ip_blkno, inode->i_nlink, oi->ip_flags); + + /* Testing ip_orphaned_slot here wouldn't work because we may + * not have gotten a delete_inode vote from any other nodes + * yet. */ + if (oi->ip_flags & OCFS2_INODE_MAYBE_ORPHANED) { + mlog(0, "Inode was orphaned on another node, clearing nlink.\n"); + inode->i_nlink = 0; + } + + generic_drop_inode(inode); + + mlog_exit_void(); +} + +/* + * TODO: this should probably be merged into ocfs2_get_block + * + * However, you now need to pay attention to the cont_prepare_write() + * stuff in ocfs2_get_block (that is, ocfs2_get_block pretty much + * expects never to extend). + */ +struct buffer_head *ocfs2_bread(struct inode *inode, + int block, int *err, int reada) +{ + struct buffer_head *bh = NULL; + int tmperr; + u64 p_blkno; + int readflags = OCFS2_BH_CACHED; + +#if 0 + /* only turn this on if we know we can deal with read_block + * returning nothing */ + if (reada) + readflags |= OCFS2_BH_READAHEAD; +#endif + + if (((u64)block << inode->i_sb->s_blocksize_bits) >= + i_size_read(inode)) { + BUG_ON(!reada); + return NULL; + } + + tmperr = ocfs2_extent_map_get_blocks(inode, block, 1, + &p_blkno, NULL); + if (tmperr < 0) { + mlog_errno(tmperr); + goto fail; + } + + tmperr = ocfs2_read_block(OCFS2_SB(inode->i_sb), p_blkno, &bh, + readflags, inode); + if (tmperr < 0) + goto fail; + + tmperr = 0; + + *err = 0; + return bh; + +fail: + if (bh) { + brelse(bh); + bh = NULL; + } + *err = -EIO; + return NULL; +} + +/* + * This is called from our getattr. + */ +int ocfs2_inode_revalidate(struct dentry *dentry) +{ + struct inode *inode = dentry->d_inode; + int status = 0; + + mlog_entry("(inode = 0x%p, ino = %"MLFu64")\n", inode, + inode ? OCFS2_I(inode)->ip_blkno : 0ULL); + + if (!inode) { + mlog(0, "eep, no inode!\n"); + status = -ENOENT; + goto bail; + } + + spin_lock(&OCFS2_I(inode)->ip_lock); + if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) { + spin_unlock(&OCFS2_I(inode)->ip_lock); + mlog(0, "inode deleted!\n"); + status = -ENOENT; + goto bail; + } + spin_unlock(&OCFS2_I(inode)->ip_lock); + + /* Let ocfs2_meta_lock do the work of updating our struct + * inode for us. */ + status = ocfs2_meta_lock(inode, NULL, NULL, 0); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto bail; + } + ocfs2_meta_unlock(inode, 0); +bail: + mlog_exit(status); + + return status; +} + +/* + * Updates a disk inode from a + * struct inode. + * Only takes ip_lock. + */ +int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *bh) +{ + int status; + struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; + + mlog_entry("(inode %"MLFu64")\n", OCFS2_I(inode)->ip_blkno); + + status = ocfs2_journal_access(handle, inode, bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + spin_lock(&OCFS2_I(inode)->ip_lock); + fe->i_clusters = cpu_to_le32(OCFS2_I(inode)->ip_clusters); + spin_unlock(&OCFS2_I(inode)->ip_lock); + + fe->i_size = cpu_to_le64(i_size_read(inode)); + fe->i_links_count = cpu_to_le16(inode->i_nlink); + fe->i_uid = cpu_to_le32(inode->i_uid); + fe->i_gid = cpu_to_le32(inode->i_gid); + fe->i_mode = cpu_to_le16(inode->i_mode); + fe->i_atime = cpu_to_le64(inode->i_atime.tv_sec); + fe->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec); + fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); + fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); + fe->i_mtime = cpu_to_le64(inode->i_mtime.tv_sec); + fe->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec); + + status = ocfs2_journal_dirty(handle, bh); + if (status < 0) + mlog_errno(status); + + status = 0; +leave: + + mlog_exit(status); + return status; +} + +/* + * + * Updates a struct inode from a disk inode. + * does no i/o, only takes ip_lock. + */ +void ocfs2_refresh_inode(struct inode *inode, + struct ocfs2_dinode *fe) +{ + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + spin_lock(&OCFS2_I(inode)->ip_lock); + + OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters); + i_size_write(inode, le64_to_cpu(fe->i_size)); + inode->i_nlink = le16_to_cpu(fe->i_links_count); + inode->i_uid = le32_to_cpu(fe->i_uid); + inode->i_gid = le32_to_cpu(fe->i_gid); + inode->i_mode = le16_to_cpu(fe->i_mode); + inode->i_blksize = (u32) osb->s_clustersize; + if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0) + inode->i_blocks = 0; + else + inode->i_blocks = ocfs2_align_bytes_to_sectors(i_size_read(inode)); + inode->i_atime.tv_sec = le64_to_cpu(fe->i_atime); + inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec); + inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime); + inode->i_mtime.tv_nsec = le32_to_cpu(fe->i_mtime_nsec); + inode->i_ctime.tv_sec = le64_to_cpu(fe->i_ctime); + inode->i_ctime.tv_nsec = le32_to_cpu(fe->i_ctime_nsec); + + spin_unlock(&OCFS2_I(inode)->ip_lock); +} diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h new file mode 100644 index 0000000..9b01774 --- /dev/null +++ b/fs/ocfs2/inode.h @@ -0,0 +1,145 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * inode.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_INODE_H +#define OCFS2_INODE_H + +/* OCFS2 Inode Private Data */ +struct ocfs2_inode_info +{ + u64 ip_blkno; + + struct ocfs2_lock_res ip_rw_lockres; + struct ocfs2_lock_res ip_meta_lockres; + struct ocfs2_lock_res ip_data_lockres; + + /* protects allocation changes on this inode. */ + struct rw_semaphore ip_alloc_sem; + + /* These fields are protected by ip_lock */ + spinlock_t ip_lock; + u32 ip_open_count; + u32 ip_clusters; + struct ocfs2_extent_map ip_map; + struct list_head ip_io_markers; + int ip_orphaned_slot; + + struct semaphore ip_io_sem; + + /* Used by the journalling code to attach an inode to a + * handle. These are protected by ip_io_sem in order to lock + * out other I/O to the inode until we either commit or + * abort. */ + struct list_head ip_handle_list; + struct ocfs2_journal_handle *ip_handle; + + u32 ip_flags; /* see below */ + + /* protected by recovery_lock. */ + struct inode *ip_next_orphan; + + u32 ip_dir_start_lookup; + + /* next two are protected by trans_inc_lock */ + /* which transaction were we created on? Zero if none. */ + unsigned long ip_created_trans; + /* last transaction we were a part of. */ + unsigned long ip_last_trans; + + struct ocfs2_caching_info ip_metadata_cache; + + struct inode vfs_inode; +}; + +/* + * Flags for the ip_flags field + */ +/* System file inodes */ +#define OCFS2_INODE_SYSTEM_FILE 0x00000001 +#define OCFS2_INODE_JOURNAL 0x00000002 +#define OCFS2_INODE_BITMAP 0x00000004 +/* This inode has been wiped from disk */ +#define OCFS2_INODE_DELETED 0x00000008 +/* Another node is deleting, so our delete is a nop */ +#define OCFS2_INODE_SKIP_DELETE 0x00000010 +/* Has the inode been orphaned on another node? + * + * This hints to ocfs2_drop_inode that it should clear i_nlink before + * continuing. + * + * We *only* set this on unlink vote from another node. If the inode + * was locally orphaned, then we're sure of the state and don't need + * to twiddle i_nlink later - it's either zero or not depending on + * whether our unlink succeeded. Otherwise we got this from a node + * whose intention was to orphan the inode, however he may have + * crashed, failed etc, so we let ocfs2_drop_inode zero the value and + * rely on ocfs2_delete_inode to sort things out under the proper + * cluster locks. + */ +#define OCFS2_INODE_MAYBE_ORPHANED 0x00000020 +/* Does someone have the file open O_DIRECT */ +#define OCFS2_INODE_OPEN_DIRECT 0x00000040 +/* Indicates that the metadata cache should be used as an array. */ +#define OCFS2_INODE_CACHE_INLINE 0x00000080 + +static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode) +{ + return container_of(inode, struct ocfs2_inode_info, vfs_inode); +} + +#define INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags & OCFS2_INODE_JOURNAL) +#define SET_INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags |= OCFS2_INODE_JOURNAL) + +extern kmem_cache_t *ocfs2_inode_cache; + +extern struct address_space_operations ocfs2_aops; + +struct buffer_head *ocfs2_bread(struct inode *inode, int block, + int *err, int reada); +void ocfs2_clear_inode(struct inode *inode); +void ocfs2_delete_inode(struct inode *inode); +void ocfs2_drop_inode(struct inode *inode); +struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 feoff); +struct inode *ocfs2_ilookup_for_vote(struct ocfs2_super *osb, + u64 blkno, + int delete_vote); +int ocfs2_inode_init_private(struct inode *inode); +int ocfs2_inode_revalidate(struct dentry *dentry); +int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, + int create_ino); +void ocfs2_read_inode(struct inode *inode); +void ocfs2_read_inode2(struct inode *inode, void *opaque); +ssize_t ocfs2_rw_direct(int rw, struct file *filp, char *buf, + size_t size, loff_t *offp); +void ocfs2_sync_blockdev(struct super_block *sb); +void ocfs2_refresh_inode(struct inode *inode, + struct ocfs2_dinode *fe); +int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *bh); +int ocfs2_aio_read(struct file *file, struct kiocb *req, struct iocb *iocb); +int ocfs2_aio_write(struct file *file, struct kiocb *req, struct iocb *iocb); + +#endif /* OCFS2_INODE_H */ diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c new file mode 100644 index 0000000..0442804 --- /dev/null +++ b/fs/ocfs2/journal.c @@ -0,0 +1,1652 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * journal.c + * + * Defines functions of journalling api + * + * Copyright (C) 2003, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_JOURNAL +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "heartbeat.h" +#include "inode.h" +#include "journal.h" +#include "localalloc.h" +#include "namei.h" +#include "slot_map.h" +#include "super.h" +#include "vote.h" +#include "sysfile.h" + +#include "buffer_head_io.h" + +spinlock_t trans_inc_lock = SPIN_LOCK_UNLOCKED; + +static int ocfs2_force_read_journal(struct inode *inode); +static int ocfs2_recover_node(struct ocfs2_super *osb, + int node_num); +static int __ocfs2_recovery_thread(void *arg); +static int ocfs2_commit_cache(struct ocfs2_super *osb); +static int ocfs2_wait_on_mount(struct ocfs2_super *osb); +static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal, + struct ocfs2_journal_handle *handle); +static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle); +static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, + int dirty); +static int ocfs2_trylock_journal(struct ocfs2_super *osb, + int slot_num); +static int ocfs2_recover_orphans(struct ocfs2_super *osb, + int slot); +static int ocfs2_commit_thread(void *arg); + +static int ocfs2_commit_cache(struct ocfs2_super *osb) +{ + int status = 0; + unsigned int flushed; + unsigned long old_id; + struct ocfs2_journal *journal = NULL; + + mlog_entry_void(); + + journal = osb->journal; + + /* Flush all pending commits and checkpoint the journal. */ + down_write(&journal->j_trans_barrier); + + if (atomic_read(&journal->j_num_trans) == 0) { + up_write(&journal->j_trans_barrier); + mlog(0, "No transactions for me to flush!\n"); + goto finally; + } + + journal_lock_updates(journal->j_journal); + status = journal_flush(journal->j_journal); + journal_unlock_updates(journal->j_journal); + if (status < 0) { + up_write(&journal->j_trans_barrier); + mlog_errno(status); + goto finally; + } + + old_id = ocfs2_inc_trans_id(journal); + + flushed = atomic_read(&journal->j_num_trans); + atomic_set(&journal->j_num_trans, 0); + up_write(&journal->j_trans_barrier); + + mlog(0, "commit_thread: flushed transaction %lu (%u handles)\n", + journal->j_trans_id, flushed); + + ocfs2_kick_vote_thread(osb); + wake_up(&journal->j_checkpointed); +finally: + mlog_exit(status); + return status; +} + +struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) +{ + struct ocfs2_journal_handle *retval = NULL; + + retval = kcalloc(1, sizeof(*retval), GFP_KERNEL); + if (!retval) { + mlog(ML_ERROR, "Failed to allocate memory for journal " + "handle!\n"); + return NULL; + } + + retval->max_buffs = 0; + retval->num_locks = 0; + retval->k_handle = NULL; + + INIT_LIST_HEAD(&retval->locks); + INIT_LIST_HEAD(&retval->inode_list); + retval->journal = osb->journal; + + return retval; +} + +/* pass it NULL and it will allocate a new handle object for you. If + * you pass it a handle however, it may still return error, in which + * case it has free'd the passed handle for you. */ +struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + int max_buffs) +{ + int ret; + journal_t *journal = osb->journal->j_journal; + + mlog_entry("(max_buffs = %d)\n", max_buffs); + + if (!osb || !osb->journal->j_journal) + BUG(); + + if (ocfs2_is_hard_readonly(osb)) { + ret = -EROFS; + goto done_free; + } + + BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE); + BUG_ON(max_buffs <= 0); + + /* JBD might support this, but our journalling code doesn't yet. */ + if (journal_current_handle()) { + mlog(ML_ERROR, "Recursive transaction attempted!\n"); + BUG(); + } + + if (!handle) + handle = ocfs2_alloc_handle(osb); + if (!handle) { + ret = -ENOMEM; + mlog(ML_ERROR, "Failed to allocate memory for journal " + "handle!\n"); + goto done_free; + } + + handle->max_buffs = max_buffs; + + down_read(&osb->journal->j_trans_barrier); + + /* actually start the transaction now */ + handle->k_handle = journal_start(journal, max_buffs); + if (IS_ERR(handle->k_handle)) { + up_read(&osb->journal->j_trans_barrier); + + ret = PTR_ERR(handle->k_handle); + handle->k_handle = NULL; + mlog_errno(ret); + + if (is_journal_aborted(journal)) { + ocfs2_abort(osb->sb, "Detected aborted journal"); + ret = -EROFS; + } + goto done_free; + } + + atomic_inc(&(osb->journal->j_num_trans)); + handle->flags |= OCFS2_HANDLE_STARTED; + + mlog_exit_ptr(handle); + return handle; + +done_free: + if (handle) + ocfs2_commit_unstarted_handle(handle); /* will kfree handle */ + + mlog_exit(ret); + return ERR_PTR(ret); +} + +void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle, + struct inode *inode) +{ + BUG_ON(!handle); + BUG_ON(!inode); + + atomic_inc(&inode->i_count); + + /* we're obviously changing it... */ + down(&inode->i_sem); + + /* sanity check */ + BUG_ON(OCFS2_I(inode)->ip_handle); + BUG_ON(!list_empty(&OCFS2_I(inode)->ip_handle_list)); + + OCFS2_I(inode)->ip_handle = handle; + list_del(&(OCFS2_I(inode)->ip_handle_list)); + list_add_tail(&(OCFS2_I(inode)->ip_handle_list), &(handle->inode_list)); +} + +static void ocfs2_handle_unlock_inodes(struct ocfs2_journal_handle *handle) +{ + struct list_head *p, *n; + struct inode *inode; + struct ocfs2_inode_info *oi; + + list_for_each_safe(p, n, &handle->inode_list) { + oi = list_entry(p, struct ocfs2_inode_info, + ip_handle_list); + inode = &oi->vfs_inode; + + OCFS2_I(inode)->ip_handle = NULL; + list_del_init(&OCFS2_I(inode)->ip_handle_list); + + up(&inode->i_sem); + iput(inode); + } +} + +/* This is trivial so we do it out of the main commit + * paths. Beware, it can be called from start_trans too! */ +static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle) +{ + mlog_entry_void(); + + BUG_ON(handle->flags & OCFS2_HANDLE_STARTED); + + ocfs2_handle_unlock_inodes(handle); + /* You are allowed to add journal locks before the transaction + * has started. */ + ocfs2_handle_cleanup_locks(handle->journal, handle); + + kfree(handle); + + mlog_exit_void(); +} + +void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) +{ + handle_t *jbd_handle; + int retval; + struct ocfs2_journal *journal = handle->journal; + + mlog_entry_void(); + + BUG_ON(!handle); + + if (!(handle->flags & OCFS2_HANDLE_STARTED)) { + ocfs2_commit_unstarted_handle(handle); + mlog_exit_void(); + return; + } + + /* release inode semaphores we took during this transaction */ + ocfs2_handle_unlock_inodes(handle); + + /* ocfs2_extend_trans may have had to call journal_restart + * which will always commit the transaction, but may return + * error for any number of reasons. If this is the case, we + * clear k_handle as it's not valid any more. */ + if (handle->k_handle) { + jbd_handle = handle->k_handle; + + if (handle->flags & OCFS2_HANDLE_SYNC) + jbd_handle->h_sync = 1; + else + jbd_handle->h_sync = 0; + + /* actually stop the transaction. if we've set h_sync, + * it'll have been committed when we return */ + retval = journal_stop(jbd_handle); + if (retval < 0) { + mlog_errno(retval); + mlog(ML_ERROR, "Could not commit transaction\n"); + BUG(); + } + + handle->k_handle = NULL; /* it's been free'd in journal_stop */ + } + + ocfs2_handle_cleanup_locks(journal, handle); + + up_read(&journal->j_trans_barrier); + + kfree(handle); + mlog_exit_void(); +} + +/* + * 'nblocks' is what you want to add to the current + * transaction. extend_trans will either extend the current handle by + * nblocks, or commit it and start a new one with nblocks credits. + * + * WARNING: This will not release any semaphores or disk locks taken + * during the transaction, so make sure they were taken *before* + * start_trans or we'll have ordering deadlocks. + * + * WARNING2: Note that we do *not* drop j_trans_barrier here. This is + * good because transaction ids haven't yet been recorded on the + * cluster locks associated with this handle. + */ +int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, + int nblocks) +{ + int status; + + BUG_ON(!handle); + BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); + BUG_ON(!nblocks); + + mlog_entry_void(); + + mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); + + status = journal_extend(handle->k_handle, nblocks); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (status > 0) { + mlog(0, "journal_extend failed, trying journal_restart\n"); + status = journal_restart(handle->k_handle, nblocks); + if (status < 0) { + handle->k_handle = NULL; + mlog_errno(status); + goto bail; + } + handle->max_buffs = nblocks; + } else + handle->max_buffs += nblocks; + + status = 0; +bail: + + mlog_exit(status); + return status; +} + +int ocfs2_journal_access(struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *bh, + int type) +{ + int status; + + BUG_ON(!inode); + BUG_ON(!handle); + BUG_ON(!bh); + BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); + + mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %hu\n", + (unsigned long long)bh->b_blocknr, type, + (type == OCFS2_JOURNAL_ACCESS_CREATE) ? + "OCFS2_JOURNAL_ACCESS_CREATE" : + "OCFS2_JOURNAL_ACCESS_WRITE", + bh->b_size); + + /* we can safely remove this assertion after testing. */ + if (!buffer_uptodate(bh)) { + mlog(ML_ERROR, "giving me a buffer that's not uptodate!\n"); + mlog(ML_ERROR, "b_blocknr=%llu\n", + (unsigned long long)bh->b_blocknr); + BUG(); + } + + /* Set the current transaction information on the inode so + * that the locking code knows whether it can drop it's locks + * on this inode or not. We're protected from the commit + * thread updating the current transaction id until + * ocfs2_commit_trans() because ocfs2_start_trans() took + * j_trans_barrier for us. */ + ocfs2_set_inode_lock_trans(OCFS2_SB(inode->i_sb)->journal, inode); + + down(&OCFS2_I(inode)->ip_io_sem); + switch (type) { + case OCFS2_JOURNAL_ACCESS_CREATE: + case OCFS2_JOURNAL_ACCESS_WRITE: + status = journal_get_write_access(handle->k_handle, bh); + break; + + case OCFS2_JOURNAL_ACCESS_UNDO: + status = journal_get_undo_access(handle->k_handle, bh); + break; + + default: + status = -EINVAL; + mlog(ML_ERROR, "Uknown access type!\n"); + } + up(&OCFS2_I(inode)->ip_io_sem); + + if (status < 0) + mlog(ML_ERROR, "Error %d getting %d access to buffer!\n", + status, type); + + mlog_exit(status); + return status; +} + +int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, + struct buffer_head *bh) +{ + int status; + + BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); + + mlog_entry("(bh->b_blocknr=%llu)\n", + (unsigned long long)bh->b_blocknr); + + status = journal_dirty_metadata(handle->k_handle, bh); + if (status < 0) + mlog(ML_ERROR, "Could not dirty metadata buffer. " + "(bh->b_blocknr=%llu)\n", + (unsigned long long)bh->b_blocknr); + + mlog_exit(status); + return status; +} + +int ocfs2_journal_dirty_data(handle_t *handle, + struct buffer_head *bh) +{ + int err = journal_dirty_data(handle, bh); + if (err) + mlog_errno(err); + /* TODO: When we can handle it, abort the handle and go RO on + * error here. */ + + return err; +} + +/* We always assume you're adding a metadata lock at level 'ex' */ +int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle, + struct inode *inode) +{ + int status; + struct ocfs2_journal_lock *lock; + + BUG_ON(!inode); + + lock = kmem_cache_alloc(ocfs2_lock_cache, GFP_NOFS); + if (!lock) { + status = -ENOMEM; + mlog_errno(-ENOMEM); + goto bail; + } + + if (!igrab(inode)) + BUG(); + lock->jl_inode = inode; + + list_add_tail(&(lock->jl_lock_list), &(handle->locks)); + handle->num_locks++; + + status = 0; +bail: + mlog_exit(status); + return status; +} + +static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal, + struct ocfs2_journal_handle *handle) +{ + struct list_head *p, *n; + struct ocfs2_journal_lock *lock; + struct inode *inode; + + list_for_each_safe(p, n, &(handle->locks)) { + lock = list_entry(p, struct ocfs2_journal_lock, + jl_lock_list); + list_del(&lock->jl_lock_list); + handle->num_locks--; + + inode = lock->jl_inode; + ocfs2_meta_unlock(inode, 1); + if (atomic_read(&inode->i_count) == 1) + mlog(ML_ERROR, + "Inode %"MLFu64", I'm doing a last iput for!", + OCFS2_I(inode)->ip_blkno); + iput(inode); + kmem_cache_free(ocfs2_lock_cache, lock); + } +} + +#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) + +void ocfs2_set_journal_params(struct ocfs2_super *osb) +{ + journal_t *journal = osb->journal->j_journal; + + spin_lock(&journal->j_state_lock); + journal->j_commit_interval = OCFS2_DEFAULT_COMMIT_INTERVAL; + if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER) + journal->j_flags |= JFS_BARRIER; + else + journal->j_flags &= ~JFS_BARRIER; + spin_unlock(&journal->j_state_lock); +} + +int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty) +{ + int status = -1; + struct inode *inode = NULL; /* the journal inode */ + journal_t *j_journal = NULL; + struct ocfs2_dinode *di = NULL; + struct buffer_head *bh = NULL; + struct ocfs2_super *osb; + int meta_lock = 0; + + mlog_entry_void(); + + BUG_ON(!journal); + + osb = journal->j_osb; + + /* already have the inode for our journal */ + inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE, + osb->slot_num); + if (inode == NULL) { + status = -EACCES; + mlog_errno(status); + goto done; + } + if (is_bad_inode(inode)) { + mlog(ML_ERROR, "access error (bad inode)\n"); + iput(inode); + inode = NULL; + status = -EACCES; + goto done; + } + + SET_INODE_JOURNAL(inode); + OCFS2_I(inode)->ip_open_count++; + + status = ocfs2_meta_lock(inode, NULL, &bh, 1); + if (status < 0) { + if (status != -ERESTARTSYS) + mlog(ML_ERROR, "Could not get lock on journal!\n"); + goto done; + } + + meta_lock = 1; + di = (struct ocfs2_dinode *)bh->b_data; + + if (inode->i_size < OCFS2_MIN_JOURNAL_SIZE) { + mlog(ML_ERROR, "Journal file size (%lld) is too small!\n", + inode->i_size); + status = -EINVAL; + goto done; + } + + mlog(0, "inode->i_size = %lld\n", inode->i_size); + mlog(0, "inode->i_blocks = %lu\n", inode->i_blocks); + mlog(0, "inode->ip_clusters = %u\n", OCFS2_I(inode)->ip_clusters); + + /* call the kernels journal init function now */ + j_journal = journal_init_inode(inode); + if (j_journal == NULL) { + mlog(ML_ERROR, "Linux journal layer error\n"); + status = -EINVAL; + goto done; + } + + mlog(0, "Returned from journal_init_inode\n"); + mlog(0, "j_journal->j_maxlen = %u\n", j_journal->j_maxlen); + + *dirty = (le32_to_cpu(di->id1.journal1.ij_flags) & + OCFS2_JOURNAL_DIRTY_FL); + + journal->j_journal = j_journal; + journal->j_inode = inode; + journal->j_bh = bh; + + ocfs2_set_journal_params(osb); + + journal->j_state = OCFS2_JOURNAL_LOADED; + + status = 0; +done: + if (status < 0) { + if (meta_lock) + ocfs2_meta_unlock(inode, 1); + if (bh != NULL) + brelse(bh); + if (inode) { + OCFS2_I(inode)->ip_open_count--; + iput(inode); + } + } + + mlog_exit(status); + return status; +} + +static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, + int dirty) +{ + int status; + unsigned int flags; + struct ocfs2_journal *journal = osb->journal; + struct buffer_head *bh = journal->j_bh; + struct ocfs2_dinode *fe; + + mlog_entry_void(); + + fe = (struct ocfs2_dinode *)bh->b_data; + if (!OCFS2_IS_VALID_DINODE(fe)) { + /* This is called from startup/shutdown which will + * handle the errors in a specific manner, so no need + * to call ocfs2_error() here. */ + mlog(ML_ERROR, "Journal dinode %"MLFu64" has invalid " + "signature: %.*s", fe->i_blkno, 7, fe->i_signature); + status = -EIO; + goto out; + } + + flags = le32_to_cpu(fe->id1.journal1.ij_flags); + if (dirty) + flags |= OCFS2_JOURNAL_DIRTY_FL; + else + flags &= ~OCFS2_JOURNAL_DIRTY_FL; + fe->id1.journal1.ij_flags = cpu_to_le32(flags); + + status = ocfs2_write_block(osb, bh, journal->j_inode); + if (status < 0) + mlog_errno(status); + +out: + mlog_exit(status); + return status; +} + +/* + * If the journal has been kmalloc'd it needs to be freed after this + * call. + */ +void ocfs2_journal_shutdown(struct ocfs2_super *osb) +{ + struct ocfs2_journal *journal = NULL; + int status = 0; + struct inode *inode = NULL; + int num_running_trans = 0; + + mlog_entry_void(); + + if (!osb) + BUG(); + + journal = osb->journal; + if (!journal) + goto done; + + inode = journal->j_inode; + + if (journal->j_state != OCFS2_JOURNAL_LOADED) + goto done; + + /* need to inc inode use count as journal_destroy will iput. */ + if (!igrab(inode)) + BUG(); + + num_running_trans = atomic_read(&(osb->journal->j_num_trans)); + if (num_running_trans > 0) + mlog(0, "Shutting down journal: must wait on %d " + "running transactions!\n", + num_running_trans); + + /* Do a commit_cache here. It will flush our journal, *and* + * release any locks that are still held. + * set the SHUTDOWN flag and release the trans lock. + * the commit thread will take the trans lock for us below. */ + journal->j_state = OCFS2_JOURNAL_IN_SHUTDOWN; + + /* The OCFS2_JOURNAL_IN_SHUTDOWN will signal to commit_cache to not + * drop the trans_lock (which we want to hold until we + * completely destroy the journal. */ + if (osb->commit_task) { + /* Wait for the commit thread */ + mlog(0, "Waiting for ocfs2commit to exit....\n"); + kthread_stop(osb->commit_task); + osb->commit_task = NULL; + } + + BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); + + status = ocfs2_journal_toggle_dirty(osb, 0); + if (status < 0) + mlog_errno(status); + + /* Shutdown the kernel journal system */ + journal_destroy(journal->j_journal); + + OCFS2_I(inode)->ip_open_count--; + + /* unlock our journal */ + ocfs2_meta_unlock(inode, 1); + + brelse(journal->j_bh); + journal->j_bh = NULL; + + journal->j_state = OCFS2_JOURNAL_FREE; + +// up_write(&journal->j_trans_barrier); +done: + if (inode) + iput(inode); + mlog_exit_void(); +} + +static void ocfs2_clear_journal_error(struct super_block *sb, + journal_t *journal, + int slot) +{ + int olderr; + + olderr = journal_errno(journal); + if (olderr) { + mlog(ML_ERROR, "File system error %d recorded in " + "journal %u.\n", olderr, slot); + mlog(ML_ERROR, "File system on device %s needs checking.\n", + sb->s_id); + + journal_ack_err(journal); + journal_clear_err(journal); + } +} + +int ocfs2_journal_load(struct ocfs2_journal *journal) +{ + int status = 0; + struct ocfs2_super *osb; + + mlog_entry_void(); + + if (!journal) + BUG(); + + osb = journal->j_osb; + + status = journal_load(journal->j_journal); + if (status < 0) { + mlog(ML_ERROR, "Failed to load journal!\n"); + goto done; + } + + ocfs2_clear_journal_error(osb->sb, journal->j_journal, osb->slot_num); + + status = ocfs2_journal_toggle_dirty(osb, 1); + if (status < 0) { + mlog_errno(status); + goto done; + } + + /* Launch the commit thread */ + osb->commit_task = kthread_run(ocfs2_commit_thread, osb, "ocfs2cmt-%d", + osb->osb_id); + if (IS_ERR(osb->commit_task)) { + status = PTR_ERR(osb->commit_task); + osb->commit_task = NULL; + mlog(ML_ERROR, "unable to launch ocfs2commit thread, error=%d", + status); + goto done; + } + +done: + mlog_exit(status); + return status; +} + + +/* 'full' flag tells us whether we clear out all blocks or if we just + * mark the journal clean */ +int ocfs2_journal_wipe(struct ocfs2_journal *journal, int full) +{ + int status; + + mlog_entry_void(); + + if (!journal) + BUG(); + + status = journal_wipe(journal->j_journal, full); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_journal_toggle_dirty(journal->j_osb, 0); + if (status < 0) + mlog_errno(status); + +bail: + mlog_exit(status); + return status; +} + +/* + * JBD Might read a cached version of another nodes journal file. We + * don't want this as this file changes often and we get no + * notification on those changes. The only way to be sure that we've + * got the most up to date version of those blocks then is to force + * read them off disk. Just searching through the buffer cache won't + * work as there may be pages backing this file which are still marked + * up to date. We know things can't change on this file underneath us + * as we have the lock by now :) + */ +static int ocfs2_force_read_journal(struct inode *inode) +{ + int status = 0; + int i, p_blocks; + u64 v_blkno, p_blkno; +#define CONCURRENT_JOURNAL_FILL 32 + struct buffer_head *bhs[CONCURRENT_JOURNAL_FILL]; + + mlog_entry_void(); + + BUG_ON(inode->i_blocks != + ocfs2_align_bytes_to_sectors(i_size_read(inode))); + + memset(bhs, 0, sizeof(struct buffer_head *) * CONCURRENT_JOURNAL_FILL); + + mlog(0, "Force reading %lu blocks\n", + (inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9))); + + v_blkno = 0; + while (v_blkno < + (inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9))) { + + status = ocfs2_extent_map_get_blocks(inode, v_blkno, + 1, &p_blkno, + &p_blocks); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (p_blocks > CONCURRENT_JOURNAL_FILL) + p_blocks = CONCURRENT_JOURNAL_FILL; + + status = ocfs2_read_blocks(OCFS2_SB(inode->i_sb), + p_blkno, p_blocks, bhs, 0, + inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + for(i = 0; i < p_blocks; i++) { + brelse(bhs[i]); + bhs[i] = NULL; + } + + v_blkno += p_blocks; + } + +bail: + for(i = 0; i < CONCURRENT_JOURNAL_FILL; i++) + if (bhs[i]) + brelse(bhs[i]); + mlog_exit(status); + return status; +} + +struct ocfs2_la_recovery_item { + struct list_head lri_list; + int lri_slot; + struct ocfs2_dinode *lri_la_dinode; + struct ocfs2_dinode *lri_tl_dinode; +}; + +/* Does the second half of the recovery process. By this point, the + * node is marked clean and can actually be considered recovered, + * hence it's no longer in the recovery map, but there's still some + * cleanup we can do which shouldn't happen within the recovery thread + * as locking in that context becomes very difficult if we are to take + * recovering nodes into account. + * + * NOTE: This function can and will sleep on recovery of other nodes + * during cluster locking, just like any other ocfs2 process. + */ +void ocfs2_complete_recovery(void *data) +{ + int ret; + struct ocfs2_super *osb = data; + struct ocfs2_journal *journal = osb->journal; + struct ocfs2_dinode *la_dinode, *tl_dinode; + struct ocfs2_la_recovery_item *item; + struct list_head *p, *n; + LIST_HEAD(tmp_la_list); + + mlog_entry_void(); + + mlog(0, "completing recovery from keventd\n"); + + spin_lock(&journal->j_lock); + list_splice_init(&journal->j_la_cleanups, &tmp_la_list); + spin_unlock(&journal->j_lock); + + list_for_each_safe(p, n, &tmp_la_list) { + item = list_entry(p, struct ocfs2_la_recovery_item, lri_list); + list_del_init(&item->lri_list); + + mlog(0, "Complete recovery for slot %d\n", item->lri_slot); + + la_dinode = item->lri_la_dinode; + if (la_dinode) { + mlog(0, "Clean up local alloc %"MLFu64"\n", + la_dinode->i_blkno); + + ret = ocfs2_complete_local_alloc_recovery(osb, + la_dinode); + if (ret < 0) + mlog_errno(ret); + + kfree(la_dinode); + } + + tl_dinode = item->lri_tl_dinode; + if (tl_dinode) { + mlog(0, "Clean up truncate log %"MLFu64"\n", + tl_dinode->i_blkno); + + ret = ocfs2_complete_truncate_log_recovery(osb, + tl_dinode); + if (ret < 0) + mlog_errno(ret); + + kfree(tl_dinode); + } + + ret = ocfs2_recover_orphans(osb, item->lri_slot); + if (ret < 0) + mlog_errno(ret); + + kfree(item); + } + + mlog(0, "Recovery completion\n"); + mlog_exit_void(); +} + +/* NOTE: This function always eats your references to la_dinode and + * tl_dinode, either manually on error, or by passing them to + * ocfs2_complete_recovery */ +static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal, + int slot_num, + struct ocfs2_dinode *la_dinode, + struct ocfs2_dinode *tl_dinode) +{ + struct ocfs2_la_recovery_item *item; + + item = kmalloc(sizeof(struct ocfs2_la_recovery_item), GFP_KERNEL); + if (!item) { + /* Though we wish to avoid it, we are in fact safe in + * skipping local alloc cleanup as fsck.ocfs2 is more + * than capable of reclaiming unused space. */ + if (la_dinode) + kfree(la_dinode); + + if (tl_dinode) + kfree(tl_dinode); + + mlog_errno(-ENOMEM); + return; + } + + INIT_LIST_HEAD(&item->lri_list); + item->lri_la_dinode = la_dinode; + item->lri_slot = slot_num; + item->lri_tl_dinode = tl_dinode; + + spin_lock(&journal->j_lock); + list_add_tail(&item->lri_list, &journal->j_la_cleanups); + queue_work(ocfs2_wq, &journal->j_recovery_work); + spin_unlock(&journal->j_lock); +} + +/* Called by the mount code to queue recovery the last part of + * recovery for it's own slot. */ +void ocfs2_complete_mount_recovery(struct ocfs2_super *osb) +{ + struct ocfs2_journal *journal = osb->journal; + + if (osb->dirty) { + /* No need to queue up our truncate_log as regular + * cleanup will catch that. */ + ocfs2_queue_recovery_completion(journal, + osb->slot_num, + osb->local_alloc_copy, + NULL); + ocfs2_schedule_truncate_log_flush(osb, 0); + + osb->local_alloc_copy = NULL; + osb->dirty = 0; + } +} + +static int __ocfs2_recovery_thread(void *arg) +{ + int status, node_num; + struct ocfs2_super *osb = arg; + + mlog_entry_void(); + + status = ocfs2_wait_on_mount(osb); + if (status < 0) { + goto bail; + } + +restart: + status = ocfs2_super_lock(osb, 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + while(!ocfs2_node_map_is_empty(osb, &osb->recovery_map)) { + node_num = ocfs2_node_map_first_set_bit(osb, + &osb->recovery_map); + if (node_num == O2NM_INVALID_NODE_NUM) { + mlog(0, "Out of nodes to recover.\n"); + break; + } + + status = ocfs2_recover_node(osb, node_num); + if (status < 0) { + mlog(ML_ERROR, + "Error %d recovering node %d on device (%u,%u)!\n", + status, node_num, + MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); + mlog(ML_ERROR, "Volume requires unmount.\n"); + continue; + } + + ocfs2_recovery_map_clear(osb, node_num); + } + ocfs2_super_unlock(osb, 1); + + /* We always run recovery on our own orphan dir - the dead + * node(s) may have voted "no" on an inode delete earlier. A + * revote is therefore required. */ + ocfs2_queue_recovery_completion(osb->journal, osb->slot_num, NULL, + NULL); + +bail: + down(&osb->recovery_lock); + if (!status && + !ocfs2_node_map_is_empty(osb, &osb->recovery_map)) { + up(&osb->recovery_lock); + goto restart; + } + + osb->recovery_thread_task = NULL; + mb(); /* sync with ocfs2_recovery_thread_running */ + wake_up(&osb->recovery_event); + + up(&osb->recovery_lock); + + mlog_exit(status); + /* no one is callint kthread_stop() for us so the kthread() api + * requires that we call do_exit(). And it isn't exported, but + * complete_and_exit() seems to be a minimal wrapper around it. */ + complete_and_exit(NULL, status); + return status; +} + +void ocfs2_recovery_thread(struct ocfs2_super *osb, int node_num) +{ + mlog_entry("(node_num=%d, osb->node_num = %d)\n", + node_num, osb->node_num); + + down(&osb->recovery_lock); + if (osb->disable_recovery) + goto out; + + /* People waiting on recovery will wait on + * the recovery map to empty. */ + if (!ocfs2_recovery_map_set(osb, node_num)) + mlog(0, "node %d already be in recovery.\n", node_num); + + mlog(0, "starting recovery thread...\n"); + + if (osb->recovery_thread_task) + goto out; + + osb->recovery_thread_task = kthread_run(__ocfs2_recovery_thread, osb, + "ocfs2rec-%d", osb->osb_id); + if (IS_ERR(osb->recovery_thread_task)) { + mlog_errno((int)PTR_ERR(osb->recovery_thread_task)); + osb->recovery_thread_task = NULL; + } + +out: + up(&osb->recovery_lock); + wake_up(&osb->recovery_event); + + mlog_exit_void(); +} + +/* Does the actual journal replay and marks the journal inode as + * clean. Will only replay if the journal inode is marked dirty. */ +static int ocfs2_replay_journal(struct ocfs2_super *osb, + int node_num, + int slot_num) +{ + int status; + int got_lock = 0; + unsigned int flags; + struct inode *inode = NULL; + struct ocfs2_dinode *fe; + journal_t *journal = NULL; + struct buffer_head *bh = NULL; + + inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE, + slot_num); + if (inode == NULL) { + status = -EACCES; + mlog_errno(status); + goto done; + } + if (is_bad_inode(inode)) { + status = -EACCES; + iput(inode); + inode = NULL; + mlog_errno(status); + goto done; + } + SET_INODE_JOURNAL(inode); + + status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, + OCFS2_META_LOCK_RECOVERY); + if (status < 0) { + mlog(0, "status returned from ocfs2_meta_lock=%d\n", status); + if (status != -ERESTARTSYS) + mlog(ML_ERROR, "Could not lock journal!\n"); + goto done; + } + got_lock = 1; + + fe = (struct ocfs2_dinode *) bh->b_data; + + flags = le32_to_cpu(fe->id1.journal1.ij_flags); + + if (!(flags & OCFS2_JOURNAL_DIRTY_FL)) { + mlog(0, "No recovery required for node %d\n", node_num); + goto done; + } + + mlog(ML_NOTICE, "Recovering node %d from slot %d on device (%u,%u)\n", + node_num, slot_num, + MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); + + OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters); + + status = ocfs2_force_read_journal(inode); + if (status < 0) { + mlog_errno(status); + goto done; + } + + mlog(0, "calling journal_init_inode\n"); + journal = journal_init_inode(inode); + if (journal == NULL) { + mlog(ML_ERROR, "Linux journal layer error\n"); + status = -EIO; + goto done; + } + + status = journal_load(journal); + if (status < 0) { + mlog_errno(status); + if (!igrab(inode)) + BUG(); + journal_destroy(journal); + goto done; + } + + ocfs2_clear_journal_error(osb->sb, journal, slot_num); + + /* wipe the journal */ + mlog(0, "flushing the journal.\n"); + journal_lock_updates(journal); + status = journal_flush(journal); + journal_unlock_updates(journal); + if (status < 0) + mlog_errno(status); + + /* This will mark the node clean */ + flags = le32_to_cpu(fe->id1.journal1.ij_flags); + flags &= ~OCFS2_JOURNAL_DIRTY_FL; + fe->id1.journal1.ij_flags = cpu_to_le32(flags); + + status = ocfs2_write_block(osb, bh, inode); + if (status < 0) + mlog_errno(status); + + if (!igrab(inode)) + BUG(); + + journal_destroy(journal); + +done: + /* drop the lock on this nodes journal */ + if (got_lock) + ocfs2_meta_unlock(inode, 1); + + if (inode) + iput(inode); + + if (bh) + brelse(bh); + + mlog_exit(status); + return status; +} + +/* + * Do the most important parts of node recovery: + * - Replay it's journal + * - Stamp a clean local allocator file + * - Stamp a clean truncate log + * - Mark the node clean + * + * If this function completes without error, a node in OCFS2 can be + * said to have been safely recovered. As a result, failure during the + * second part of a nodes recovery process (local alloc recovery) is + * far less concerning. + */ +static int ocfs2_recover_node(struct ocfs2_super *osb, + int node_num) +{ + int status = 0; + int slot_num; + struct ocfs2_slot_info *si = osb->slot_info; + struct ocfs2_dinode *la_copy = NULL; + struct ocfs2_dinode *tl_copy = NULL; + + mlog_entry("(node_num=%d, osb->node_num = %d)\n", + node_num, osb->node_num); + + mlog(0, "checking node %d\n", node_num); + + /* Should not ever be called to recover ourselves -- in that + * case we should've called ocfs2_journal_load instead. */ + if (osb->node_num == node_num) + BUG(); + + slot_num = ocfs2_node_num_to_slot(si, node_num); + if (slot_num == OCFS2_INVALID_SLOT) { + status = 0; + mlog(0, "no slot for this node, so no recovery required.\n"); + goto done; + } + + mlog(0, "node %d was using slot %d\n", node_num, slot_num); + + status = ocfs2_replay_journal(osb, node_num, slot_num); + if (status < 0) { + mlog_errno(status); + goto done; + } + + /* Stamp a clean local alloc file AFTER recovering the journal... */ + status = ocfs2_begin_local_alloc_recovery(osb, slot_num, &la_copy); + if (status < 0) { + mlog_errno(status); + goto done; + } + + /* An error from begin_truncate_log_recovery is not + * serious enough to warrant halting the rest of + * recovery. */ + status = ocfs2_begin_truncate_log_recovery(osb, slot_num, &tl_copy); + if (status < 0) + mlog_errno(status); + + /* Likewise, this would be a strange but ultimately not so + * harmful place to get an error... */ + ocfs2_clear_slot(si, slot_num); + status = ocfs2_update_disk_slots(osb, si); + if (status < 0) + mlog_errno(status); + + /* This will kfree the memory pointed to by la_copy and tl_copy */ + ocfs2_queue_recovery_completion(osb->journal, slot_num, la_copy, + tl_copy); + + status = 0; +done: + + mlog_exit(status); + return status; +} + +/* Test node liveness by trylocking his journal. If we get the lock, + * we drop it here. Return 0 if we got the lock, -EAGAIN if node is + * still alive (we couldn't get the lock) and < 0 on error. */ +static int ocfs2_trylock_journal(struct ocfs2_super *osb, + int slot_num) +{ + int status, flags; + struct inode *inode = NULL; + + inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE, + slot_num); + if (inode == NULL) { + mlog(ML_ERROR, "access error\n"); + status = -EACCES; + goto bail; + } + if (is_bad_inode(inode)) { + mlog(ML_ERROR, "access error (bad inode)\n"); + iput(inode); + inode = NULL; + status = -EACCES; + goto bail; + } + SET_INODE_JOURNAL(inode); + + flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE; + status = ocfs2_meta_lock_full(inode, NULL, NULL, 1, flags); + if (status < 0) { + if (status != -EAGAIN) + mlog_errno(status); + goto bail; + } + + ocfs2_meta_unlock(inode, 1); +bail: + if (inode) + iput(inode); + + return status; +} + +/* Call this underneath ocfs2_super_lock. It also assumes that the + * slot info struct has been updated from disk. */ +int ocfs2_mark_dead_nodes(struct ocfs2_super *osb) +{ + int status, i, node_num; + struct ocfs2_slot_info *si = osb->slot_info; + + /* This is called with the super block cluster lock, so we + * know that the slot map can't change underneath us. */ + + spin_lock(&si->si_lock); + for(i = 0; i < si->si_num_slots; i++) { + if (i == osb->slot_num) + continue; + if (ocfs2_is_empty_slot(si, i)) + continue; + + node_num = si->si_global_node_nums[i]; + if (ocfs2_node_map_test_bit(osb, &osb->recovery_map, node_num)) + continue; + spin_unlock(&si->si_lock); + + /* Ok, we have a slot occupied by another node which + * is not in the recovery map. We trylock his journal + * file here to test if he's alive. */ + status = ocfs2_trylock_journal(osb, i); + if (!status) { + /* Since we're called from mount, we know that + * the recovery thread can't race us on + * setting / checking the recovery bits. */ + ocfs2_recovery_thread(osb, node_num); + } else if ((status < 0) && (status != -EAGAIN)) { + mlog_errno(status); + goto bail; + } + + spin_lock(&si->si_lock); + } + spin_unlock(&si->si_lock); + + status = 0; +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_recover_orphans(struct ocfs2_super *osb, + int slot) +{ + int status = 0; + int have_disk_lock = 0; + struct inode *inode = NULL; + struct inode *iter; + struct inode *orphan_dir_inode = NULL; + unsigned long offset, blk, local; + struct buffer_head *bh = NULL; + struct ocfs2_dir_entry *de; + struct super_block *sb = osb->sb; + struct ocfs2_inode_info *oi; + + mlog(0, "Recover inodes from orphan dir in slot %d\n", slot); + + orphan_dir_inode = ocfs2_get_system_file_inode(osb, + ORPHAN_DIR_SYSTEM_INODE, + slot); + if (!orphan_dir_inode) { + status = -ENOENT; + mlog_errno(status); + goto out; + } + + down(&orphan_dir_inode->i_sem); + status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); + if (status < 0) { + up(&orphan_dir_inode->i_sem); + mlog_errno(status); + goto out; + } + have_disk_lock = 1; + + offset = 0; + iter = NULL; + while(offset < i_size_read(orphan_dir_inode)) { + blk = offset >> sb->s_blocksize_bits; + + bh = ocfs2_bread(orphan_dir_inode, blk, &status, 0); + if (!bh) + status = -EINVAL; + if (status < 0) { + up(&orphan_dir_inode->i_sem); + if (bh) + brelse(bh); + mlog_errno(status); + goto out; + } + + local = 0; + while(offset < i_size_read(orphan_dir_inode) + && local < sb->s_blocksize) { + de = (struct ocfs2_dir_entry *) (bh->b_data + local); + + if (!ocfs2_check_dir_entry(orphan_dir_inode, + de, bh, local)) { + up(&orphan_dir_inode->i_sem); + status = -EINVAL; + mlog_errno(status); + brelse(bh); + goto out; + } + + local += le16_to_cpu(de->rec_len); + offset += le16_to_cpu(de->rec_len); + + /* I guess we silently fail on no inode? */ + if (!le64_to_cpu(de->inode)) + continue; + if (de->file_type > OCFS2_FT_MAX) { + mlog(ML_ERROR, + "block %llu contains invalid de: " + "inode = %"MLFu64", rec_len = %u, " + "name_len = %u, file_type = %u, " + "name='%.*s'\n", + (unsigned long long)bh->b_blocknr, + le64_to_cpu(de->inode), + le16_to_cpu(de->rec_len), + de->name_len, + de->file_type, + de->name_len, + de->name); + continue; + } + if (de->name_len == 1 && !strncmp(".", de->name, 1)) + continue; + if (de->name_len == 2 && !strncmp("..", de->name, 2)) + continue; + + iter = ocfs2_iget(osb, le64_to_cpu(de->inode)); + if (IS_ERR(iter)) + continue; + + mlog(0, "queue orphan %"MLFu64"\n", + OCFS2_I(iter)->ip_blkno); + OCFS2_I(iter)->ip_next_orphan = inode; + inode = iter; + } + brelse(bh); + } + up(&orphan_dir_inode->i_sem); + + ocfs2_meta_unlock(orphan_dir_inode, 0); + have_disk_lock = 0; + + iput(orphan_dir_inode); + orphan_dir_inode = NULL; + + while (inode) { + oi = OCFS2_I(inode); + mlog(0, "iput orphan %"MLFu64"\n", oi->ip_blkno); + + iter = oi->ip_next_orphan; + + spin_lock(&oi->ip_lock); + /* Delete voting may have set these on the assumption + * that the other node would wipe them successfully. + * If they are still in the node's orphan dir, we need + * to reset that state. */ + oi->ip_flags &= ~(OCFS2_INODE_DELETED|OCFS2_INODE_SKIP_DELETE); + + /* Set the proper information to get us going into + * ocfs2_delete_inode. */ + oi->ip_flags |= OCFS2_INODE_MAYBE_ORPHANED; + oi->ip_orphaned_slot = slot; + spin_unlock(&oi->ip_lock); + + iput(inode); + + inode = iter; + } + +out: + if (have_disk_lock) + ocfs2_meta_unlock(orphan_dir_inode, 0); + + if (orphan_dir_inode) + iput(orphan_dir_inode); + + return status; +} + +static int ocfs2_wait_on_mount(struct ocfs2_super *osb) +{ + /* This check is good because ocfs2 will wait on our recovery + * thread before changing it to something other than MOUNTED + * or DISABLED. */ + wait_event(osb->osb_mount_event, + atomic_read(&osb->vol_state) == VOLUME_MOUNTED || + atomic_read(&osb->vol_state) == VOLUME_DISABLED); + + /* If there's an error on mount, then we may never get to the + * MOUNTED flag, but this is set right before + * dismount_volume() so we can trust it. */ + if (atomic_read(&osb->vol_state) == VOLUME_DISABLED) { + mlog(0, "mount error, exiting!\n"); + return -EBUSY; + } + + return 0; +} + +static int ocfs2_commit_thread(void *arg) +{ + int status; + struct ocfs2_super *osb = arg; + struct ocfs2_journal *journal = osb->journal; + + /* we can trust j_num_trans here because _should_stop() is only set in + * shutdown and nobody other than ourselves should be able to start + * transactions. committing on shutdown might take a few iterations + * as final transactions put deleted inodes on the list */ + while (!(kthread_should_stop() && + atomic_read(&journal->j_num_trans) == 0)) { + + wait_event_interruptible_timeout(osb->checkpoint_event, + atomic_read(&journal->j_num_trans) + || kthread_should_stop(), + OCFS2_CHECKPOINT_INTERVAL); + + status = ocfs2_commit_cache(osb); + if (status < 0) + mlog_errno(status); + + if (kthread_should_stop() && atomic_read(&journal->j_num_trans)){ + mlog(ML_KTHREAD, + "commit_thread: %u transactions pending on " + "shutdown\n", + atomic_read(&journal->j_num_trans)); + } + } + + return 0; +} + +/* Look for a dirty journal without taking any cluster locks. Used for + * hard readonly access to determine whether the file system journals + * require recovery. */ +int ocfs2_check_journals_nolocks(struct ocfs2_super *osb) +{ + int ret = 0; + unsigned int slot; + struct buffer_head *di_bh; + struct ocfs2_dinode *di; + struct inode *journal = NULL; + + for(slot = 0; slot < osb->max_slots; slot++) { + journal = ocfs2_get_system_file_inode(osb, + JOURNAL_SYSTEM_INODE, + slot); + if (!journal || is_bad_inode(journal)) { + ret = -EACCES; + mlog_errno(ret); + goto out; + } + + di_bh = NULL; + ret = ocfs2_read_block(osb, OCFS2_I(journal)->ip_blkno, &di_bh, + 0, journal); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + + di = (struct ocfs2_dinode *) di_bh->b_data; + + if (le32_to_cpu(di->id1.journal1.ij_flags) & + OCFS2_JOURNAL_DIRTY_FL) + ret = -EROFS; + + brelse(di_bh); + if (ret) + break; + } + +out: + if (journal) + iput(journal); + + return ret; +} diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h new file mode 100644 index 0000000..7d0a816 --- /dev/null +++ b/fs/ocfs2/journal.h @@ -0,0 +1,457 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * journal.h + * + * Defines journalling api and structures. + * + * Copyright (C) 2003, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_JOURNAL_H +#define OCFS2_JOURNAL_H + +#include +#include + +#define OCFS2_CHECKPOINT_INTERVAL (8 * HZ) + +enum ocfs2_journal_state { + OCFS2_JOURNAL_FREE = 0, + OCFS2_JOURNAL_LOADED, + OCFS2_JOURNAL_IN_SHUTDOWN, +}; + +struct ocfs2_super; +struct ocfs2_dinode; +struct ocfs2_journal_handle; + +struct ocfs2_journal { + enum ocfs2_journal_state j_state; /* Journals current state */ + + journal_t *j_journal; /* The kernels journal type */ + struct inode *j_inode; /* Kernel inode pointing to + * this journal */ + struct ocfs2_super *j_osb; /* pointer to the super + * block for the node + * we're currently + * running on -- not + * necessarily the super + * block from the node + * which we usually run + * from (recovery, + * etc) */ + struct buffer_head *j_bh; /* Journal disk inode block */ + atomic_t j_num_trans; /* Number of transactions + * currently in the system. */ + unsigned long j_trans_id; + struct rw_semaphore j_trans_barrier; + wait_queue_head_t j_checkpointed; + + spinlock_t j_lock; + struct list_head j_la_cleanups; + struct work_struct j_recovery_work; +}; + +extern spinlock_t trans_inc_lock; + +/* wrap j_trans_id so we never have it equal to zero. */ +static inline unsigned long ocfs2_inc_trans_id(struct ocfs2_journal *j) +{ + unsigned long old_id; + spin_lock(&trans_inc_lock); + old_id = j->j_trans_id++; + if (unlikely(!j->j_trans_id)) + j->j_trans_id = 1; + spin_unlock(&trans_inc_lock); + return old_id; +} + +static inline void ocfs2_set_inode_lock_trans(struct ocfs2_journal *journal, + struct inode *inode) +{ + spin_lock(&trans_inc_lock); + OCFS2_I(inode)->ip_last_trans = journal->j_trans_id; + spin_unlock(&trans_inc_lock); +} + +/* Used to figure out whether it's safe to drop a metadata lock on an + * inode. Returns true if all the inodes changes have been + * checkpointed to disk. You should be holding the spinlock on the + * metadata lock while calling this to be sure that nobody can take + * the lock and put it on another transaction. */ +static inline int ocfs2_inode_fully_checkpointed(struct inode *inode) +{ + int ret; + struct ocfs2_journal *journal = OCFS2_SB(inode->i_sb)->journal; + + spin_lock(&trans_inc_lock); + ret = time_after(journal->j_trans_id, OCFS2_I(inode)->ip_last_trans); + spin_unlock(&trans_inc_lock); + return ret; +} + +/* convenience function to check if an inode is still new (has never + * hit disk) Will do you a favor and set created_trans = 0 when you've + * been checkpointed. returns '1' if the inode is still new. */ +static inline int ocfs2_inode_is_new(struct inode *inode) +{ + int ret; + + /* System files are never "new" as they're written out by + * mkfs. This helps us early during mount, before we have the + * journal open and j_trans_id could be junk. */ + if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE) + return 0; + spin_lock(&trans_inc_lock); + ret = !(time_after(OCFS2_SB(inode->i_sb)->journal->j_trans_id, + OCFS2_I(inode)->ip_created_trans)); + if (!ret) + OCFS2_I(inode)->ip_created_trans = 0; + spin_unlock(&trans_inc_lock); + return ret; +} + +static inline void ocfs2_inode_set_new(struct ocfs2_super *osb, + struct inode *inode) +{ + spin_lock(&trans_inc_lock); + OCFS2_I(inode)->ip_created_trans = osb->journal->j_trans_id; + spin_unlock(&trans_inc_lock); +} + +extern kmem_cache_t *ocfs2_lock_cache; + +struct ocfs2_journal_lock { + struct inode *jl_inode; + struct list_head jl_lock_list; +}; + +struct ocfs2_journal_handle { + handle_t *k_handle; /* kernel handle. */ + struct ocfs2_journal *journal; + u32 flags; /* see flags below. */ + int max_buffs; /* Buffs reserved by this handle */ + + /* The following two fields are for ocfs2_handle_add_lock */ + int num_locks; + struct list_head locks; /* A bunch of locks to + * release on commit. This + * should be a list_head */ + + struct list_head inode_list; +}; + +#define OCFS2_HANDLE_STARTED 1 +/* should we sync-commit this handle? */ +#define OCFS2_HANDLE_SYNC 2 +static inline int ocfs2_handle_started(struct ocfs2_journal_handle *handle) +{ + return handle->flags & OCFS2_HANDLE_STARTED; +} + +static inline void ocfs2_handle_set_sync(struct ocfs2_journal_handle *handle, int sync) +{ + if (sync) + handle->flags |= OCFS2_HANDLE_SYNC; + else + handle->flags &= ~OCFS2_HANDLE_SYNC; +} + +/* Exported only for the journal struct init code in super.c. Do not call. */ +void ocfs2_complete_recovery(void *data); + +/* + * Journal Control: + * Initialize, Load, Shutdown, Wipe a journal. + * + * ocfs2_journal_init - Initialize journal structures in the OSB. + * ocfs2_journal_load - Load the given journal off disk. Replay it if + * there's transactions still in there. + * ocfs2_journal_shutdown - Shutdown a journal, this will flush all + * uncommitted, uncheckpointed transactions. + * ocfs2_journal_wipe - Wipe transactions from a journal. Optionally + * zero out each block. + * ocfs2_recovery_thread - Perform recovery on a node. osb is our own osb. + * ocfs2_mark_dead_nodes - Start recovery on nodes we won't get a heartbeat + * event on. + * ocfs2_start_checkpoint - Kick the commit thread to do a checkpoint. + */ +void ocfs2_set_journal_params(struct ocfs2_super *osb); +int ocfs2_journal_init(struct ocfs2_journal *journal, + int *dirty); +void ocfs2_journal_shutdown(struct ocfs2_super *osb); +int ocfs2_journal_wipe(struct ocfs2_journal *journal, + int full); +int ocfs2_journal_load(struct ocfs2_journal *journal); +int ocfs2_check_journals_nolocks(struct ocfs2_super *osb); +void ocfs2_recovery_thread(struct ocfs2_super *osb, + int node_num); +int ocfs2_mark_dead_nodes(struct ocfs2_super *osb); +void ocfs2_complete_mount_recovery(struct ocfs2_super *osb); + +static inline void ocfs2_start_checkpoint(struct ocfs2_super *osb) +{ + atomic_set(&osb->needs_checkpoint, 1); + wake_up(&osb->checkpoint_event); +} + +static inline void ocfs2_checkpoint_inode(struct inode *inode) +{ + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + if (!ocfs2_inode_fully_checkpointed(inode)) { + /* WARNING: This only kicks off a single + * checkpoint. If someone races you and adds more + * metadata to the journal, you won't know, and will + * wind up waiting *alot* longer than necessary. Right + * now we only use this in clear_inode so that's + * OK. */ + ocfs2_start_checkpoint(osb); + + wait_event(osb->journal->j_checkpointed, + ocfs2_inode_fully_checkpointed(inode)); + } +} + +/* + * Transaction Handling: + * Manage the lifetime of a transaction handle. + * + * ocfs2_alloc_handle - Only allocate a handle so we can start putting + * cluster locks on it. To actually change blocks, + * call ocfs2_start_trans with the handle returned + * from this function. You may call ocfs2_commit_trans + * at any time in the lifetime of a handle. + * ocfs2_start_trans - Begin a transaction. Give it an upper estimate of + * the number of blocks that will be changed during + * this handle. + * ocfs2_commit_trans - Complete a handle. + * ocfs2_extend_trans - Extend a handle by nblocks credits. This may + * commit the handle to disk in the process, but will + * not release any locks taken during the transaction. + * ocfs2_journal_access - Notify the handle that we want to journal this + * buffer. Will have to call ocfs2_journal_dirty once + * we've actually dirtied it. Type is one of . or . + * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. + * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before + * the current handle commits. + * ocfs2_handle_add_lock - Sometimes we need to delay lock release + * until after a transaction has been completed. Use + * ocfs2_handle_add_lock to indicate that a lock needs + * to be released at the end of that handle. Locks + * will be released in the order that they are added. + * ocfs2_handle_add_inode - Add a locked inode to a transaction. + */ + +/* You must always start_trans with a number of buffs > 0, but it's + * perfectly legal to go through an entire transaction without having + * dirtied any buffers. */ +struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb); +struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + int max_buffs); +void ocfs2_commit_trans(struct ocfs2_journal_handle *handle); +int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, + int nblocks); + +/* + * Create access is for when we get a newly created buffer and we're + * not gonna read it off disk, but rather fill it ourselves. Right + * now, we don't do anything special with this (it turns into a write + * request), but this is a good placeholder in case we do... + * + * Write access is for when we read a block off disk and are going to + * modify it. This way the journalling layer knows it may need to make + * a copy of that block (if it's part of another, uncommitted + * transaction) before we do so. + */ +#define OCFS2_JOURNAL_ACCESS_CREATE 0 +#define OCFS2_JOURNAL_ACCESS_WRITE 1 +#define OCFS2_JOURNAL_ACCESS_UNDO 2 + +int ocfs2_journal_access(struct ocfs2_journal_handle *handle, + struct inode *inode, + struct buffer_head *bh, + int type); +/* + * A word about the journal_access/journal_dirty "dance". It is + * entirely legal to journal_access a buffer more than once (as long + * as the access type is the same -- I'm not sure what will happen if + * access type is different but this should never happen anyway) It is + * also legal to journal_dirty a buffer more than once. In fact, you + * can even journal_access a buffer after you've done a + * journal_access/journal_dirty pair. The only thing you cannot do + * however, is journal_dirty a buffer which you haven't yet passed to + * journal_access at least once. + * + * That said, 99% of the time this doesn't matter and this is what the + * path looks like: + * + * + * ocfs2_journal_access(handle, bh, OCFS2_JOURNAL_ACCESS_WRITE); + * + * ocfs2_journal_dirty(handle, bh); + */ +int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, + struct buffer_head *bh); +int ocfs2_journal_dirty_data(handle_t *handle, + struct buffer_head *bh); +int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle, + struct inode *inode); +/* + * Use this to protect from other processes reading buffer state while + * it's in flight. + */ +void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle, + struct inode *inode); + +/* + * Credit Macros: + * Convenience macros to calculate number of credits needed. + * + * For convenience sake, I have a set of macros here which calculate + * the *maximum* number of sectors which will be changed for various + * metadata updates. + */ + +/* simple file updates like chmod, etc. */ +#define OCFS2_INODE_UPDATE_CREDITS 1 + +/* get one bit out of a suballocator: dinode + group descriptor + + * prev. group desc. if we relink. */ +#define OCFS2_SUBALLOC_ALLOC (3) + +/* dinode + group descriptor update. We don't relink on free yet. */ +#define OCFS2_SUBALLOC_FREE (2) + +#define OCFS2_TRUNCATE_LOG_UPDATE OCFS2_INODE_UPDATE_CREDITS +#define OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC (OCFS2_SUBALLOC_FREE \ + + OCFS2_TRUNCATE_LOG_UPDATE) + +/* data block for new dir/symlink, 2 for bitmap updates (bitmap fe + + * bitmap block for the new bit) */ +#define OCFS2_DIR_LINK_ADDITIONAL_CREDITS (1 + 2) + +/* parent fe, parent block, new file entry, inode alloc fe, inode alloc + * group descriptor + mkdir/symlink blocks */ +#define OCFS2_MKNOD_CREDITS (3 + OCFS2_SUBALLOC_ALLOC \ + + OCFS2_DIR_LINK_ADDITIONAL_CREDITS) + +/* local alloc metadata change + main bitmap updates */ +#define OCFS2_WINDOW_MOVE_CREDITS (OCFS2_INODE_UPDATE_CREDITS \ + + OCFS2_SUBALLOC_ALLOC + OCFS2_SUBALLOC_FREE) + +/* used when we don't need an allocation change for a dir extend. One + * for the dinode, one for the new block. */ +#define OCFS2_SIMPLE_DIR_EXTEND_CREDITS (2) + +/* file update (nlink, etc) + dir entry block */ +#define OCFS2_LINK_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) + +/* inode + dir inode (if we unlink a dir), + dir entry block + orphan + * dir inode link */ +#define OCFS2_UNLINK_CREDITS (2 * OCFS2_INODE_UPDATE_CREDITS + 1 \ + + OCFS2_LINK_CREDITS) + +/* dinode + orphan dir dinode + inode alloc dinode + orphan dir entry + + * inode alloc group descriptor */ +#define OCFS2_DELETE_INODE_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 1 + 1) + +/* dinode update, old dir dinode update, new dir dinode update, old + * dir dir entry, new dir dir entry, dir entry update for renaming + * directory + target unlink */ +#define OCFS2_RENAME_CREDITS (3 * OCFS2_INODE_UPDATE_CREDITS + 3 \ + + OCFS2_UNLINK_CREDITS) + +static inline int ocfs2_calc_extend_credits(struct super_block *sb, + struct ocfs2_dinode *fe, + u32 bits_wanted) +{ + int bitmap_blocks, sysfile_bitmap_blocks, dinode_blocks; + + /* bitmap dinode, group desc. + relinked group. */ + bitmap_blocks = OCFS2_SUBALLOC_ALLOC; + + /* we might need to shift tree depth so lets assume an + * absolute worst case of complete fragmentation. Even with + * that, we only need one update for the dinode, and then + * however many metadata chunks needed * a remaining suballoc + * alloc. */ + sysfile_bitmap_blocks = 1 + + (OCFS2_SUBALLOC_ALLOC - 1) * ocfs2_extend_meta_needed(fe); + + /* this does not include *new* metadata blocks, which are + * accounted for in sysfile_bitmap_blocks. fe + + * prev. last_eb_blk + blocks along edge of tree. + * calc_symlink_credits passes because we just need 1 + * credit for the dinode there. */ + dinode_blocks = 1 + 1 + le16_to_cpu(fe->id2.i_list.l_tree_depth); + + return bitmap_blocks + sysfile_bitmap_blocks + dinode_blocks; +} + +static inline int ocfs2_calc_symlink_credits(struct super_block *sb) +{ + int blocks = OCFS2_MKNOD_CREDITS; + + /* links can be longer than one block so we may update many + * within our single allocated extent. */ + blocks += ocfs2_clusters_to_blocks(sb, 1); + + return blocks; +} + +static inline int ocfs2_calc_group_alloc_credits(struct super_block *sb, + unsigned int cpg) +{ + int blocks; + int bitmap_blocks = OCFS2_SUBALLOC_ALLOC + 1; + /* parent inode update + new block group header + bitmap inode update + + bitmap blocks affected */ + blocks = 1 + 1 + 1 + bitmap_blocks; + return blocks; +} + +static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb, + unsigned int clusters_to_del, + struct ocfs2_dinode *fe, + struct ocfs2_extent_list *last_el) +{ + /* for dinode + all headers in this pass + update to next leaf */ + u16 next_free = le16_to_cpu(last_el->l_next_free_rec); + u16 tree_depth = le16_to_cpu(fe->id2.i_list.l_tree_depth); + int credits = 1 + tree_depth + 1; + int i; + + i = next_free - 1; + BUG_ON(i < 0); + + /* We may be deleting metadata blocks, so metadata alloc dinode + + one desc. block for each possible delete. */ + if (tree_depth && next_free == 1 && + le32_to_cpu(last_el->l_recs[i].e_clusters) == clusters_to_del) + credits += 1 + tree_depth; + + /* update to the truncate log. */ + credits += OCFS2_TRUNCATE_LOG_UPDATE; + + return credits; +} + +#endif /* OCFS2_JOURNAL_H */ diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c new file mode 100644 index 0000000..fe373a2 --- /dev/null +++ b/fs/ocfs2/localalloc.c @@ -0,0 +1,983 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * localalloc.c + * + * Node local data allocation + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_DISK_ALLOC +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dlmglue.h" +#include "inode.h" +#include "journal.h" +#include "localalloc.h" +#include "suballoc.h" +#include "super.h" +#include "sysfile.h" + +#include "buffer_head_io.h" + +#define OCFS2_LOCAL_ALLOC(dinode) (&((dinode)->id2.i_lab)) + +static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb); + +static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc); + +static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, + struct ocfs2_dinode *alloc, + u32 numbits); + +static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc); + +static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_dinode *alloc, + struct inode *main_bm_inode, + struct buffer_head *main_bm_bh); + +static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context **ac, + struct inode **bitmap_inode, + struct buffer_head **bitmap_bh); + +static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac); + +static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, + struct inode *local_alloc_inode); + +/* + * Determine how large our local alloc window should be, in bits. + * + * These values (and the behavior in ocfs2_alloc_should_use_local) have + * been chosen so that most allocations, including new block groups go + * through local alloc. + */ +static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb) +{ + BUG_ON(osb->s_clustersize_bits < 12); + + return 2048 >> (osb->s_clustersize_bits - 12); +} + +/* + * Tell us whether a given allocation should use the local alloc + * file. Otherwise, it has to go to the main bitmap. + */ +int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) +{ + int la_bits = ocfs2_local_alloc_window_bits(osb); + + if (osb->local_alloc_state != OCFS2_LA_ENABLED) + return 0; + + /* la_bits should be at least twice the size (in clusters) of + * a new block group. We want to be sure block group + * allocations go through the local alloc, so allow an + * allocation to take up to half the bitmap. */ + if (bits > (la_bits / 2)) + return 0; + + return 1; +} + +int ocfs2_load_local_alloc(struct ocfs2_super *osb) +{ + int status = 0; + struct ocfs2_dinode *alloc = NULL; + struct buffer_head *alloc_bh = NULL; + u32 num_used; + struct inode *inode = NULL; + struct ocfs2_local_alloc *la; + + mlog_entry_void(); + + /* read the alloc off disk */ + inode = ocfs2_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, + osb->slot_num); + if (!inode) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, + &alloc_bh, 0, inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + alloc = (struct ocfs2_dinode *) alloc_bh->b_data; + la = OCFS2_LOCAL_ALLOC(alloc); + + if (!(le32_to_cpu(alloc->i_flags) & + (OCFS2_LOCAL_ALLOC_FL|OCFS2_BITMAP_FL))) { + mlog(ML_ERROR, "Invalid local alloc inode, %"MLFu64"\n", + OCFS2_I(inode)->ip_blkno); + status = -EINVAL; + goto bail; + } + + if ((la->la_size == 0) || + (le16_to_cpu(la->la_size) > ocfs2_local_alloc_size(inode->i_sb))) { + mlog(ML_ERROR, "Local alloc size is invalid (la_size = %u)\n", + le16_to_cpu(la->la_size)); + status = -EINVAL; + goto bail; + } + + /* do a little verification. */ + num_used = ocfs2_local_alloc_count_bits(alloc); + + /* hopefully the local alloc has always been recovered before + * we load it. */ + if (num_used + || alloc->id1.bitmap1.i_used + || alloc->id1.bitmap1.i_total + || la->la_bm_off) + mlog(ML_ERROR, "Local alloc hasn't been recovered!\n" + "found = %u, set = %u, taken = %u, off = %u\n", + num_used, le32_to_cpu(alloc->id1.bitmap1.i_used), + le32_to_cpu(alloc->id1.bitmap1.i_total), + OCFS2_LOCAL_ALLOC(alloc)->la_bm_off); + + osb->local_alloc_bh = alloc_bh; + osb->local_alloc_state = OCFS2_LA_ENABLED; + +bail: + if (status < 0) + if (alloc_bh) + brelse(alloc_bh); + if (inode) + iput(inode); + + mlog_exit(status); + return status; +} + +/* + * return any unused bits to the bitmap and write out a clean + * local_alloc. + * + * local_alloc_bh is optional. If not passed, we will simply use the + * one off osb. If you do pass it however, be warned that it *will* be + * returned brelse'd and NULL'd out.*/ +void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) +{ + int status; + struct ocfs2_journal_handle *handle = NULL; + struct inode *local_alloc_inode = NULL; + struct buffer_head *bh = NULL; + struct buffer_head *main_bm_bh = NULL; + struct inode *main_bm_inode = NULL; + struct ocfs2_dinode *alloc_copy = NULL; + struct ocfs2_dinode *alloc = NULL; + + mlog_entry_void(); + + if (osb->local_alloc_state == OCFS2_LA_UNUSED) + goto bail; + + local_alloc_inode = + ocfs2_get_system_file_inode(osb, + LOCAL_ALLOC_SYSTEM_INODE, + osb->slot_num); + if (!local_alloc_inode) { + status = -ENOENT; + mlog_errno(status); + goto bail; + } + + osb->local_alloc_state = OCFS2_LA_DISABLED; + + handle = ocfs2_alloc_handle(osb); + if (!handle) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + main_bm_inode = ocfs2_get_system_file_inode(osb, + GLOBAL_BITMAP_SYSTEM_INODE, + OCFS2_INVALID_SLOT); + if (!main_bm_inode) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + ocfs2_handle_add_inode(handle, main_bm_inode); + status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* WINDOW_MOVE_CREDITS is a bit heavy... */ + handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); + if (IS_ERR(handle)) { + mlog_errno(PTR_ERR(handle)); + handle = NULL; + goto bail; + } + + bh = osb->local_alloc_bh; + alloc = (struct ocfs2_dinode *) bh->b_data; + + alloc_copy = kmalloc(bh->b_size, GFP_KERNEL); + if (!alloc_copy) { + status = -ENOMEM; + goto bail; + } + memcpy(alloc_copy, alloc, bh->b_size); + + status = ocfs2_journal_access(handle, local_alloc_inode, bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + ocfs2_clear_local_alloc(alloc); + + status = ocfs2_journal_dirty(handle, bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + brelse(bh); + osb->local_alloc_bh = NULL; + osb->local_alloc_state = OCFS2_LA_UNUSED; + + status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, + main_bm_inode, main_bm_bh); + if (status < 0) + mlog_errno(status); + +bail: + if (handle) + ocfs2_commit_trans(handle); + + if (main_bm_bh) + brelse(main_bm_bh); + + if (main_bm_inode) + iput(main_bm_inode); + + if (local_alloc_inode) + iput(local_alloc_inode); + + if (alloc_copy) + kfree(alloc_copy); + + mlog_exit_void(); +} + +/* + * We want to free the bitmap bits outside of any recovery context as + * we'll need a cluster lock to do so, but we must clear the local + * alloc before giving up the recovered nodes journal. To solve this, + * we kmalloc a copy of the local alloc before it's change for the + * caller to process with ocfs2_complete_local_alloc_recovery + */ +int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, + int slot_num, + struct ocfs2_dinode **alloc_copy) +{ + int status = 0; + struct buffer_head *alloc_bh = NULL; + struct inode *inode = NULL; + struct ocfs2_dinode *alloc; + + mlog_entry("(slot_num = %d)\n", slot_num); + + *alloc_copy = NULL; + + inode = ocfs2_get_system_file_inode(osb, + LOCAL_ALLOC_SYSTEM_INODE, + slot_num); + if (!inode) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + down(&inode->i_sem); + + status = ocfs2_read_block(osb, OCFS2_I(inode)->ip_blkno, + &alloc_bh, 0, inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + *alloc_copy = kmalloc(alloc_bh->b_size, GFP_KERNEL); + if (!(*alloc_copy)) { + status = -ENOMEM; + goto bail; + } + memcpy((*alloc_copy), alloc_bh->b_data, alloc_bh->b_size); + + alloc = (struct ocfs2_dinode *) alloc_bh->b_data; + ocfs2_clear_local_alloc(alloc); + + status = ocfs2_write_block(osb, alloc_bh, inode); + if (status < 0) + mlog_errno(status); + +bail: + if ((status < 0) && (*alloc_copy)) { + kfree(*alloc_copy); + *alloc_copy = NULL; + } + + if (alloc_bh) + brelse(alloc_bh); + + if (inode) { + up(&inode->i_sem); + iput(inode); + } + + mlog_exit(status); + return status; +} + +/* + * Step 2: By now, we've completed the journal recovery, we've stamped + * a clean local alloc on disk and dropped the node out of the + * recovery map. Dlm locks will no longer stall, so lets clear out the + * main bitmap. + */ +int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb, + struct ocfs2_dinode *alloc) +{ + int status; + struct ocfs2_journal_handle *handle = NULL; + struct buffer_head *main_bm_bh = NULL; + struct inode *main_bm_inode = NULL; + + mlog_entry_void(); + + handle = ocfs2_alloc_handle(osb); + if (!handle) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + main_bm_inode = ocfs2_get_system_file_inode(osb, + GLOBAL_BITMAP_SYSTEM_INODE, + OCFS2_INVALID_SLOT); + if (!main_bm_inode) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + ocfs2_handle_add_inode(handle, main_bm_inode); + status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + /* we want the bitmap change to be recorded on disk asap */ + ocfs2_handle_set_sync(handle, 1); + + status = ocfs2_sync_local_to_main(osb, handle, alloc, + main_bm_inode, main_bm_bh); + if (status < 0) + mlog_errno(status); + +bail: + if (handle) + ocfs2_commit_trans(handle); + + if (main_bm_bh) + brelse(main_bm_bh); + + if (main_bm_inode) + iput(main_bm_inode); + + mlog_exit(status); + return status; +} + +/* + * make sure we've got at least bitswanted contiguous bits in the + * local alloc. You lose them when you drop i_sem. + * + * We will add ourselves to the transaction passed in, but may start + * our own in order to shift windows. + */ +int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, + struct ocfs2_journal_handle *passed_handle, + u32 bits_wanted, + struct ocfs2_alloc_context *ac) +{ + int status; + struct ocfs2_dinode *alloc; + struct inode *local_alloc_inode; + unsigned int free_bits; + + mlog_entry_void(); + + BUG_ON(!passed_handle); + BUG_ON(!ac); + BUG_ON(passed_handle->flags & OCFS2_HANDLE_STARTED); + + local_alloc_inode = + ocfs2_get_system_file_inode(osb, + LOCAL_ALLOC_SYSTEM_INODE, + osb->slot_num); + if (!local_alloc_inode) { + status = -ENOENT; + mlog_errno(status); + goto bail; + } + ocfs2_handle_add_inode(passed_handle, local_alloc_inode); + + if (osb->local_alloc_state != OCFS2_LA_ENABLED) { + status = -ENOSPC; + goto bail; + } + + if (bits_wanted > ocfs2_local_alloc_window_bits(osb)) { + mlog(0, "Asking for more than my max window size!\n"); + status = -ENOSPC; + goto bail; + } + + alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; + + if (le32_to_cpu(alloc->id1.bitmap1.i_used) != + ocfs2_local_alloc_count_bits(alloc)) { + ocfs2_error(osb->sb, "local alloc inode %"MLFu64" says it has " + "%u free bits, but a count shows %u", + le64_to_cpu(alloc->i_blkno), + le32_to_cpu(alloc->id1.bitmap1.i_used), + ocfs2_local_alloc_count_bits(alloc)); + status = -EIO; + goto bail; + } + + free_bits = le32_to_cpu(alloc->id1.bitmap1.i_total) - + le32_to_cpu(alloc->id1.bitmap1.i_used); + if (bits_wanted > free_bits) { + /* uhoh, window change time. */ + status = + ocfs2_local_alloc_slide_window(osb, local_alloc_inode); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + } + + ac->ac_inode = igrab(local_alloc_inode); + get_bh(osb->local_alloc_bh); + ac->ac_bh = osb->local_alloc_bh; + ac->ac_which = OCFS2_AC_USE_LOCAL; + status = 0; +bail: + if (local_alloc_inode) + iput(local_alloc_inode); + + mlog_exit(status); + return status; +} + +int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac, + u32 min_bits, + u32 *bit_off, + u32 *num_bits) +{ + int status, start; + struct inode *local_alloc_inode; + u32 bits_wanted; + void *bitmap; + struct ocfs2_dinode *alloc; + struct ocfs2_local_alloc *la; + + mlog_entry_void(); + BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL); + + bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; + local_alloc_inode = ac->ac_inode; + alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; + la = OCFS2_LOCAL_ALLOC(alloc); + + start = ocfs2_local_alloc_find_clear_bits(osb, alloc, bits_wanted); + if (start == -1) { + /* TODO: Shouldn't we just BUG here? */ + status = -ENOSPC; + mlog_errno(status); + goto bail; + } + + bitmap = la->la_bitmap; + *bit_off = le32_to_cpu(la->la_bm_off) + start; + /* local alloc is always contiguous by nature -- we never + * delete bits from it! */ + *num_bits = bits_wanted; + + status = ocfs2_journal_access(handle, local_alloc_inode, + osb->local_alloc_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + while(bits_wanted--) + ocfs2_set_bit(start++, bitmap); + + alloc->id1.bitmap1.i_used = cpu_to_le32(*num_bits + + le32_to_cpu(alloc->id1.bitmap1.i_used)); + + status = ocfs2_journal_dirty(handle, osb->local_alloc_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = 0; +bail: + mlog_exit(status); + return status; +} + +static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc) +{ + int i; + u8 *buffer; + u32 count = 0; + struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); + + mlog_entry_void(); + + buffer = la->la_bitmap; + for (i = 0; i < le16_to_cpu(la->la_size); i++) + count += hweight8(buffer[i]); + + mlog_exit(count); + return count; +} + +static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, + struct ocfs2_dinode *alloc, + u32 numbits) +{ + int numfound, bitoff, left, startoff, lastzero; + void *bitmap = NULL; + + mlog_entry("(numbits wanted = %u)\n", numbits); + + if (!alloc->id1.bitmap1.i_total) { + mlog(0, "No bits in my window!\n"); + bitoff = -1; + goto bail; + } + + bitmap = OCFS2_LOCAL_ALLOC(alloc)->la_bitmap; + + numfound = bitoff = startoff = 0; + lastzero = -1; + left = le32_to_cpu(alloc->id1.bitmap1.i_total); + while ((bitoff = ocfs2_find_next_zero_bit(bitmap, left, startoff)) != -1) { + if (bitoff == left) { + /* mlog(0, "bitoff (%d) == left", bitoff); */ + break; + } + /* mlog(0, "Found a zero: bitoff = %d, startoff = %d, " + "numfound = %d\n", bitoff, startoff, numfound);*/ + + /* Ok, we found a zero bit... is it contig. or do we + * start over?*/ + if (bitoff == startoff) { + /* we found a zero */ + numfound++; + startoff++; + } else { + /* got a zero after some ones */ + numfound = 1; + startoff = bitoff+1; + } + /* we got everything we needed */ + if (numfound == numbits) { + /* mlog(0, "Found it all!\n"); */ + break; + } + } + + mlog(0, "Exiting loop, bitoff = %d, numfound = %d\n", bitoff, + numfound); + + if (numfound == numbits) + bitoff = startoff - numfound; + else + bitoff = -1; + +bail: + mlog_exit(bitoff); + return bitoff; +} + +static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc) +{ + struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); + int i; + mlog_entry_void(); + + alloc->id1.bitmap1.i_total = 0; + alloc->id1.bitmap1.i_used = 0; + la->la_bm_off = 0; + for(i = 0; i < le16_to_cpu(la->la_size); i++) + la->la_bitmap[i] = 0; + + mlog_exit_void(); +} + +#if 0 +/* turn this on and uncomment below to aid debugging window shifts. */ +static void ocfs2_verify_zero_bits(unsigned long *bitmap, + unsigned int start, + unsigned int count) +{ + unsigned int tmp = count; + while(tmp--) { + if (ocfs2_test_bit(start + tmp, bitmap)) { + printk("ocfs2_verify_zero_bits: start = %u, count = " + "%u\n", start, count); + printk("ocfs2_verify_zero_bits: bit %u is set!", + start + tmp); + BUG(); + } + } +} +#endif + +/* + * sync the local alloc to main bitmap. + * + * assumes you've already locked the main bitmap -- the bitmap inode + * passed is used for caching. + */ +static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_dinode *alloc, + struct inode *main_bm_inode, + struct buffer_head *main_bm_bh) +{ + int status = 0; + int bit_off, left, count, start; + u64 la_start_blk; + u64 blkno; + void *bitmap; + struct ocfs2_local_alloc *la = OCFS2_LOCAL_ALLOC(alloc); + + mlog_entry("total = %u, COUNT = %u, used = %u\n", + le32_to_cpu(alloc->id1.bitmap1.i_total), + ocfs2_local_alloc_count_bits(alloc), + le32_to_cpu(alloc->id1.bitmap1.i_used)); + + if (!alloc->id1.bitmap1.i_total) { + mlog(0, "nothing to sync!\n"); + goto bail; + } + + if (le32_to_cpu(alloc->id1.bitmap1.i_used) == + le32_to_cpu(alloc->id1.bitmap1.i_total)) { + mlog(0, "all bits were taken!\n"); + goto bail; + } + + la_start_blk = ocfs2_clusters_to_blocks(osb->sb, + le32_to_cpu(la->la_bm_off)); + bitmap = la->la_bitmap; + start = count = bit_off = 0; + left = le32_to_cpu(alloc->id1.bitmap1.i_total); + + while ((bit_off = ocfs2_find_next_zero_bit(bitmap, left, start)) + != -1) { + if ((bit_off < left) && (bit_off == start)) { + count++; + start++; + continue; + } + if (count) { + blkno = la_start_blk + + ocfs2_clusters_to_blocks(osb->sb, + start - count); + + mlog(0, "freeing %u bits starting at local " + "alloc bit %u (la_start_blk = %"MLFu64", " + "blkno = %"MLFu64")\n", count, start - count, + la_start_blk, blkno); + + status = ocfs2_free_clusters(handle, main_bm_inode, + main_bm_bh, blkno, count); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + if (bit_off >= left) + break; + count = 1; + start = bit_off + 1; + } + +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context **ac, + struct inode **bitmap_inode, + struct buffer_head **bitmap_bh) +{ + int status; + + *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); + if (!(*ac)) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + (*ac)->ac_handle = handle; + (*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb); + + status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + *bitmap_inode = (*ac)->ac_inode; + igrab(*bitmap_inode); + *bitmap_bh = (*ac)->ac_bh; + get_bh(*bitmap_bh); + status = 0; +bail: + if ((status < 0) && *ac) { + ocfs2_free_alloc_context(*ac); + *ac = NULL; + } + + mlog_exit(status); + return status; +} + +/* + * pass it the bitmap lock in lock_bh if you have it. + */ +static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac) +{ + int status = 0; + u32 cluster_off, cluster_count; + struct ocfs2_dinode *alloc = NULL; + struct ocfs2_local_alloc *la; + + mlog_entry_void(); + + alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; + la = OCFS2_LOCAL_ALLOC(alloc); + + if (alloc->id1.bitmap1.i_total) + mlog(0, "asking me to alloc a new window over a non-empty " + "one\n"); + + mlog(0, "Allocating %u clusters for a new window.\n", + ocfs2_local_alloc_window_bits(osb)); + /* we used the generic suballoc reserve function, but we set + * everything up nicely, so there's no reason why we can't use + * the more specific cluster api to claim bits. */ + status = ocfs2_claim_clusters(osb, handle, ac, + ocfs2_local_alloc_window_bits(osb), + &cluster_off, &cluster_count); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + la->la_bm_off = cpu_to_le32(cluster_off); + alloc->id1.bitmap1.i_total = cpu_to_le32(cluster_count); + /* just in case... In the future when we find space ourselves, + * we don't have to get all contiguous -- but we'll have to + * set all previously used bits in bitmap and update + * la_bits_set before setting the bits in the main bitmap. */ + alloc->id1.bitmap1.i_used = 0; + memset(OCFS2_LOCAL_ALLOC(alloc)->la_bitmap, 0, + le16_to_cpu(la->la_size)); + + mlog(0, "New window allocated:\n"); + mlog(0, "window la_bm_off = %u\n", + OCFS2_LOCAL_ALLOC(alloc)->la_bm_off); + mlog(0, "window bits = %u\n", le32_to_cpu(alloc->id1.bitmap1.i_total)); + +bail: + mlog_exit(status); + return status; +} + +/* Note that we do *NOT* lock the local alloc inode here as + * it's been locked already for us. */ +static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, + struct inode *local_alloc_inode) +{ + int status = 0; + struct buffer_head *main_bm_bh = NULL; + struct inode *main_bm_inode = NULL; + struct ocfs2_journal_handle *handle = NULL; + struct ocfs2_dinode *alloc; + struct ocfs2_dinode *alloc_copy = NULL; + struct ocfs2_alloc_context *ac = NULL; + + mlog_entry_void(); + + handle = ocfs2_alloc_handle(osb); + if (!handle) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + /* This will lock the main bitmap for us. */ + status = ocfs2_local_alloc_reserve_for_window(osb, + handle, + &ac, + &main_bm_inode, + &main_bm_bh); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; + + /* We want to clear the local alloc before doing anything + * else, so that if we error later during this operation, + * local alloc shutdown won't try to double free main bitmap + * bits. Make a copy so the sync function knows which bits to + * free. */ + alloc_copy = kmalloc(osb->local_alloc_bh->b_size, GFP_KERNEL); + if (!alloc_copy) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size); + + status = ocfs2_journal_access(handle, local_alloc_inode, + osb->local_alloc_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + ocfs2_clear_local_alloc(alloc); + + status = ocfs2_journal_dirty(handle, osb->local_alloc_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, + main_bm_inode, main_bm_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_local_alloc_new_window(osb, handle, ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + atomic_inc(&osb->alloc_stats.moves); + + status = 0; +bail: + if (handle) + ocfs2_commit_trans(handle); + + if (main_bm_bh) + brelse(main_bm_bh); + + if (main_bm_inode) + iput(main_bm_inode); + + if (alloc_copy) + kfree(alloc_copy); + + if (ac) + ocfs2_free_alloc_context(ac); + + mlog_exit(status); + return status; +} + diff --git a/fs/ocfs2/localalloc.h b/fs/ocfs2/localalloc.h new file mode 100644 index 0000000..30f88ce --- /dev/null +++ b/fs/ocfs2/localalloc.h @@ -0,0 +1,56 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * localalloc.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_LOCALALLOC_H +#define OCFS2_LOCALALLOC_H + +int ocfs2_load_local_alloc(struct ocfs2_super *osb); + +void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb); + +int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, + int node_num, + struct ocfs2_dinode **alloc_copy); + +int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb, + struct ocfs2_dinode *alloc); + +int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, + u64 bits); + +struct ocfs2_alloc_context; +int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, + struct ocfs2_journal_handle *passed_handle, + u32 bits_wanted, + struct ocfs2_alloc_context *ac); + +int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac, + u32 min_bits, + u32 *bit_off, + u32 *num_bits); + +#endif /* OCFS2_LOCALALLOC_H */ diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c new file mode 100644 index 0000000..afdeec4 --- /dev/null +++ b/fs/ocfs2/mmap.c @@ -0,0 +1,102 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * mmap.c + * + * Code to deal with the mess that is clustered mmap. + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_FILE_IO +#include + +#include "ocfs2.h" + +#include "dlmglue.h" +#include "file.h" +#include "inode.h" +#include "mmap.h" + +static struct page *ocfs2_nopage(struct vm_area_struct * area, + unsigned long address, + int *type) +{ + struct inode *inode = area->vm_file->f_dentry->d_inode; + struct page *page = NOPAGE_SIGBUS; + sigset_t blocked, oldset; + int ret; + + mlog_entry("(inode %lu, address %lu)\n", inode->i_ino, address); + + /* The best way to deal with signals in this path is + * to block them upfront, rather than allowing the + * locking paths to return -ERESTARTSYS. */ + sigfillset(&blocked); + + /* We should technically never get a bad ret return + * from sigprocmask */ + ret = sigprocmask(SIG_BLOCK, &blocked, &oldset); + if (ret < 0) { + mlog_errno(ret); + goto out; + } + + page = filemap_nopage(area, address, type); + + ret = sigprocmask(SIG_SETMASK, &oldset, NULL); + if (ret < 0) + mlog_errno(ret); +out: + mlog_exit_ptr(page); + return page; +} + +static struct vm_operations_struct ocfs2_file_vm_ops = { + .nopage = ocfs2_nopage, +}; + +int ocfs2_mmap(struct file *file, + struct vm_area_struct *vma) +{ + struct address_space *mapping = file->f_dentry->d_inode->i_mapping; + struct inode *inode = mapping->host; + + /* We don't want to support shared writable mappings yet. */ + if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) + && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { + mlog(0, "disallow shared writable mmaps %lx\n", vma->vm_flags); + /* This is -EINVAL because generic_file_readonly_mmap + * returns it in a similar situation. */ + return -EINVAL; + } + + update_atime(inode); + vma->vm_ops = &ocfs2_file_vm_ops; + return 0; +} + diff --git a/fs/ocfs2/mmap.h b/fs/ocfs2/mmap.h new file mode 100644 index 0000000..1274ee0f --- /dev/null +++ b/fs/ocfs2/mmap.h @@ -0,0 +1,6 @@ +#ifndef OCFS2_MMAP_H +#define OCFS2_MMAP_H + +int ocfs2_mmap(struct file *file, struct vm_area_struct *vma); + +#endif /* OCFS2_MMAP_H */ diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c new file mode 100644 index 0000000..f6b77ff1 --- /dev/null +++ b/fs/ocfs2/namei.c @@ -0,0 +1,2264 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * namei.c + * + * Create and rename file, directory, symlinks + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * Portions of this code from linux/fs/ext3/dir.c + * + * Copyright (C) 1992, 1993, 1994, 1995 + * Remy Card (card@masi.ibp.fr) + * Laboratoire MASI - Institut Blaise pascal + * Universite Pierre et Marie Curie (Paris VI) + * + * from + * + * linux/fs/minix/dir.c + * + * Copyright (C) 1991, 1992 Linux Torvalds + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_NAMEI +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dcache.h" +#include "dir.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "file.h" +#include "inode.h" +#include "journal.h" +#include "namei.h" +#include "suballoc.h" +#include "symlink.h" +#include "sysfile.h" +#include "uptodate.h" +#include "vote.h" + +#include "buffer_head_io.h" + +#define NAMEI_RA_CHUNKS 2 +#define NAMEI_RA_BLOCKS 4 +#define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS) +#define NAMEI_RA_INDEX(c,b) (((c) * NAMEI_RA_BLOCKS) + (b)) + +static int inline ocfs2_search_dirblock(struct buffer_head *bh, + struct inode *dir, + const char *name, int namelen, + unsigned long offset, + struct ocfs2_dir_entry **res_dir); + +static int ocfs2_delete_entry(struct ocfs2_journal_handle *handle, + struct inode *dir, + struct ocfs2_dir_entry *de_del, + struct buffer_head *bh); + +static int __ocfs2_add_entry(struct ocfs2_journal_handle *handle, + struct inode *dir, + const char *name, int namelen, + struct inode *inode, u64 blkno, + struct buffer_head *parent_fe_bh, + struct buffer_head *insert_bh); + +static int ocfs2_mknod_locked(struct ocfs2_super *osb, + struct inode *dir, + struct dentry *dentry, int mode, + dev_t dev, + struct buffer_head **new_fe_bh, + struct buffer_head *parent_fe_bh, + struct ocfs2_journal_handle *handle, + struct inode **ret_inode, + struct ocfs2_alloc_context *inode_ac); + +static int ocfs2_fill_new_dir(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *parent, + struct inode *inode, + struct buffer_head *fe_bh, + struct ocfs2_alloc_context *data_ac); + +static int ocfs2_double_lock(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct buffer_head **bh1, + struct inode *inode1, + struct buffer_head **bh2, + struct inode *inode2); + +static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + char *name, + struct buffer_head **de_bh); + +static int ocfs2_orphan_add(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct ocfs2_dinode *fe, + char *name, + struct buffer_head *de_bh); + +static int ocfs2_create_symlink_data(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + const char *symname); + +static inline int ocfs2_add_entry(struct ocfs2_journal_handle *handle, + struct dentry *dentry, + struct inode *inode, u64 blkno, + struct buffer_head *parent_fe_bh, + struct buffer_head *insert_bh) +{ + return __ocfs2_add_entry(handle, dentry->d_parent->d_inode, + dentry->d_name.name, dentry->d_name.len, + inode, blkno, parent_fe_bh, insert_bh); +} + +/* An orphan dir name is an 8 byte value, printed as a hex string */ +#define OCFS2_ORPHAN_NAMELEN ((int)(2 * sizeof(u64))) + +static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry, + struct nameidata *nd) +{ + int status; + u64 blkno; + struct buffer_head *dirent_bh = NULL; + struct inode *inode = NULL; + struct dentry *ret; + struct ocfs2_dir_entry *dirent; + struct ocfs2_inode_info *oi; + + mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry, + dentry->d_name.len, dentry->d_name.name); + + if (dentry->d_name.len > OCFS2_MAX_FILENAME_LEN) { + ret = ERR_PTR(-ENAMETOOLONG); + goto bail; + } + + mlog(0, "find name %.*s in directory %"MLFu64"\n", dentry->d_name.len, + dentry->d_name.name, OCFS2_I(dir)->ip_blkno); + + status = ocfs2_meta_lock(dir, NULL, NULL, 0); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + ret = ERR_PTR(status); + goto bail; + } + + status = ocfs2_find_files_on_disk(dentry->d_name.name, + dentry->d_name.len, &blkno, + dir, &dirent_bh, &dirent); + if (status < 0) + goto bail_add; + + inode = ocfs2_iget(OCFS2_SB(dir->i_sb), blkno); + if (IS_ERR(inode)) { + mlog(ML_ERROR, "Unable to create inode %"MLFu64"\n", blkno); + ret = ERR_PTR(-EACCES); + goto bail_unlock; + } + + oi = OCFS2_I(inode); + /* Clear any orphaned state... If we were able to look up the + * inode from a directory, it certainly can't be orphaned. We + * might have the bad state from a node which intended to + * orphan this inode but crashed before it could commit the + * unlink. */ + spin_lock(&oi->ip_lock); + oi->ip_flags &= ~OCFS2_INODE_MAYBE_ORPHANED; + oi->ip_orphaned_slot = OCFS2_INVALID_SLOT; + spin_unlock(&oi->ip_lock); + +bail_add: + + dentry->d_op = &ocfs2_dentry_ops; + ret = d_splice_alias(inode, dentry); + +bail_unlock: + /* Don't drop the cluster lock until *after* the d_add -- + * unlink on another node will message us to remove that + * dentry under this lock so otherwise we can race this with + * the vote thread and have a stale dentry. */ + ocfs2_meta_unlock(dir, 0); + +bail: + if (dirent_bh) + brelse(dirent_bh); + + mlog_exit_ptr(ret); + + return ret; +} + +static int ocfs2_fill_new_dir(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *parent, + struct inode *inode, + struct buffer_head *fe_bh, + struct ocfs2_alloc_context *data_ac) +{ + int status; + struct buffer_head *new_bh = NULL; + struct ocfs2_dir_entry *de = NULL; + + mlog_entry_void(); + + status = ocfs2_do_extend_dir(osb->sb, handle, inode, fe_bh, + data_ac, NULL, &new_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + ocfs2_set_new_buffer_uptodate(inode, new_bh); + + status = ocfs2_journal_access(handle, inode, new_bh, + OCFS2_JOURNAL_ACCESS_CREATE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + memset(new_bh->b_data, 0, osb->sb->s_blocksize); + + de = (struct ocfs2_dir_entry *) new_bh->b_data; + de->inode = cpu_to_le64(OCFS2_I(inode)->ip_blkno); + de->name_len = 1; + de->rec_len = + cpu_to_le16(OCFS2_DIR_REC_LEN(de->name_len)); + strcpy(de->name, "."); + ocfs2_set_de_type(de, S_IFDIR); + de = (struct ocfs2_dir_entry *) ((char *)de + le16_to_cpu(de->rec_len)); + de->inode = cpu_to_le64(OCFS2_I(parent)->ip_blkno); + de->rec_len = cpu_to_le16(inode->i_sb->s_blocksize - + OCFS2_DIR_REC_LEN(1)); + de->name_len = 2; + strcpy(de->name, ".."); + ocfs2_set_de_type(de, S_IFDIR); + + status = ocfs2_journal_dirty(handle, new_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + i_size_write(inode, inode->i_sb->s_blocksize); + inode->i_nlink = 2; + inode->i_blocks = ocfs2_align_bytes_to_sectors(inode->i_sb->s_blocksize); + status = ocfs2_mark_inode_dirty(handle, inode, fe_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = 0; +bail: + if (new_bh) + brelse(new_bh); + + mlog_exit(status); + return status; +} + +static int ocfs2_mknod(struct inode *dir, + struct dentry *dentry, + int mode, + dev_t dev) +{ + int status = 0; + struct buffer_head *parent_fe_bh = NULL; + struct ocfs2_journal_handle *handle = NULL; + struct ocfs2_super *osb; + struct ocfs2_dinode *dirfe; + struct buffer_head *new_fe_bh = NULL; + struct buffer_head *de_bh = NULL; + struct inode *inode = NULL; + struct ocfs2_alloc_context *inode_ac = NULL; + struct ocfs2_alloc_context *data_ac = NULL; + + mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, + (unsigned long)dev, dentry->d_name.len, + dentry->d_name.name); + + /* get our super block */ + osb = OCFS2_SB(dir->i_sb); + + if (S_ISDIR(mode) && (dir->i_nlink >= OCFS2_LINK_MAX)) { + mlog(ML_ERROR, "inode %"MLFu64" has i_nlink of %u\n", + OCFS2_I(dir)->ip_blkno, dir->i_nlink); + status = -EMLINK; + goto leave; + } + + handle = ocfs2_alloc_handle(osb); + if (handle == NULL) { + status = -ENOMEM; + mlog_errno(status); + goto leave; + } + + status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto leave; + } + + dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data; + if (!dirfe->i_links_count) { + /* can't make a file in a deleted directory. */ + status = -ENOENT; + goto leave; + } + + status = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, + dentry->d_name.len); + if (status) + goto leave; + + /* get a spot inside the dir. */ + status = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, + dentry->d_name.name, + dentry->d_name.len, &de_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + /* reserve an inode spot */ + status = ocfs2_reserve_new_inode(osb, handle, &inode_ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto leave; + } + + /* are we making a directory? If so, reserve a cluster for his + * 1st extent. */ + if (S_ISDIR(mode)) { + status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto leave; + } + } + + handle = ocfs2_start_trans(osb, handle, OCFS2_MKNOD_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto leave; + } + + /* do the real work now. */ + status = ocfs2_mknod_locked(osb, dir, dentry, mode, dev, + &new_fe_bh, parent_fe_bh, handle, + &inode, inode_ac); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + if (S_ISDIR(mode)) { + status = ocfs2_fill_new_dir(osb, handle, dir, inode, + new_fe_bh, data_ac); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_journal_access(handle, dir, parent_fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + le16_add_cpu(&dirfe->i_links_count, 1); + status = ocfs2_journal_dirty(handle, parent_fe_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + dir->i_nlink++; + } + + status = ocfs2_add_entry(handle, dentry, inode, + OCFS2_I(inode)->ip_blkno, parent_fe_bh, + de_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + insert_inode_hash(inode); + dentry->d_op = &ocfs2_dentry_ops; + d_instantiate(dentry, inode); + status = 0; +leave: + if (handle) + ocfs2_commit_trans(handle); + + if (status == -ENOSPC) + mlog(0, "Disk is full\n"); + + if (new_fe_bh) + brelse(new_fe_bh); + + if (de_bh) + brelse(de_bh); + + if (parent_fe_bh) + brelse(parent_fe_bh); + + if ((status < 0) && inode) + iput(inode); + + if (inode_ac) + ocfs2_free_alloc_context(inode_ac); + + if (data_ac) + ocfs2_free_alloc_context(data_ac); + + mlog_exit(status); + + return status; +} + +static int ocfs2_mknod_locked(struct ocfs2_super *osb, + struct inode *dir, + struct dentry *dentry, int mode, + dev_t dev, + struct buffer_head **new_fe_bh, + struct buffer_head *parent_fe_bh, + struct ocfs2_journal_handle *handle, + struct inode **ret_inode, + struct ocfs2_alloc_context *inode_ac) +{ + int status = 0; + struct ocfs2_dinode *fe = NULL; + struct ocfs2_extent_list *fel; + u64 fe_blkno = 0; + u16 suballoc_bit; + struct inode *inode = NULL; + + mlog_entry("(0x%p, 0x%p, %d, %lu, '%.*s')\n", dir, dentry, mode, + (unsigned long)dev, dentry->d_name.len, + dentry->d_name.name); + + *new_fe_bh = NULL; + *ret_inode = NULL; + + status = ocfs2_claim_new_inode(osb, handle, inode_ac, &suballoc_bit, + &fe_blkno); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + inode = new_inode(dir->i_sb); + if (IS_ERR(inode)) { + status = PTR_ERR(inode); + mlog(ML_ERROR, "new_inode failed!\n"); + goto leave; + } + + /* populate as many fields early on as possible - many of + * these are used by the support functions here and in + * callers. */ + inode->i_ino = ino_from_blkno(osb->sb, fe_blkno); + OCFS2_I(inode)->ip_blkno = fe_blkno; + if (S_ISDIR(mode)) + inode->i_nlink = 2; + else + inode->i_nlink = 1; + inode->i_mode = mode; + spin_lock(&osb->osb_lock); + inode->i_generation = osb->s_next_generation++; + spin_unlock(&osb->osb_lock); + + *new_fe_bh = sb_getblk(osb->sb, fe_blkno); + if (!*new_fe_bh) { + status = -EIO; + mlog_errno(status); + goto leave; + } + ocfs2_set_new_buffer_uptodate(inode, *new_fe_bh); + + status = ocfs2_journal_access(handle, inode, *new_fe_bh, + OCFS2_JOURNAL_ACCESS_CREATE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + fe = (struct ocfs2_dinode *) (*new_fe_bh)->b_data; + memset(fe, 0, osb->sb->s_blocksize); + + fe->i_generation = cpu_to_le32(inode->i_generation); + fe->i_fs_generation = cpu_to_le32(osb->fs_generation); + fe->i_blkno = cpu_to_le64(fe_blkno); + fe->i_suballoc_bit = cpu_to_le16(suballoc_bit); + fe->i_suballoc_slot = cpu_to_le16(osb->slot_num); + fe->i_uid = cpu_to_le32(current->fsuid); + if (dir->i_mode & S_ISGID) { + fe->i_gid = cpu_to_le32(dir->i_gid); + if (S_ISDIR(mode)) + mode |= S_ISGID; + } else + fe->i_gid = cpu_to_le32(current->fsgid); + fe->i_mode = cpu_to_le16(mode); + if (S_ISCHR(mode) || S_ISBLK(mode)) + fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev)); + + fe->i_links_count = cpu_to_le16(inode->i_nlink); + + fe->i_last_eb_blk = 0; + strcpy(fe->i_signature, OCFS2_INODE_SIGNATURE); + le32_add_cpu(&fe->i_flags, OCFS2_VALID_FL); + fe->i_atime = fe->i_ctime = fe->i_mtime = + cpu_to_le64(CURRENT_TIME.tv_sec); + fe->i_mtime_nsec = fe->i_ctime_nsec = fe->i_atime_nsec = + cpu_to_le32(CURRENT_TIME.tv_nsec); + fe->i_dtime = 0; + + fel = &fe->id2.i_list; + fel->l_tree_depth = 0; + fel->l_next_free_rec = 0; + fel->l_count = cpu_to_le16(ocfs2_extent_recs_per_inode(osb->sb)); + + status = ocfs2_journal_dirty(handle, *new_fe_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + if (ocfs2_populate_inode(inode, fe, 1) < 0) { + mlog(ML_ERROR, "populate inode failed! bh->b_blocknr=%llu, " + "i_blkno=%"MLFu64", i_ino=%lu\n", + (unsigned long long) (*new_fe_bh)->b_blocknr, + fe->i_blkno, inode->i_ino); + BUG(); + } + + ocfs2_inode_set_new(osb, inode); + status = ocfs2_create_new_inode_locks(inode); + if (status < 0) + mlog_errno(status); + + status = 0; /* error in ocfs2_create_new_inode_locks is not + * critical */ + + *ret_inode = inode; +leave: + if (status < 0) { + if (*new_fe_bh) { + brelse(*new_fe_bh); + *new_fe_bh = NULL; + } + if (inode) + iput(inode); + } + + mlog_exit(status); + return status; +} + +static int ocfs2_mkdir(struct inode *dir, + struct dentry *dentry, + int mode) +{ + int ret; + + mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, mode, + dentry->d_name.len, dentry->d_name.name); + ret = ocfs2_mknod(dir, dentry, mode | S_IFDIR, 0); + mlog_exit(ret); + + return ret; +} + +static int ocfs2_create(struct inode *dir, + struct dentry *dentry, + int mode, + struct nameidata *nd) +{ + int ret; + + mlog_entry("(0x%p, 0x%p, %d, '%.*s')\n", dir, dentry, mode, + dentry->d_name.len, dentry->d_name.name); + ret = ocfs2_mknod(dir, dentry, mode | S_IFREG, 0); + mlog_exit(ret); + + return ret; +} + +static int ocfs2_link(struct dentry *old_dentry, + struct inode *dir, + struct dentry *dentry) +{ + struct ocfs2_journal_handle *handle = NULL; + struct inode *inode = old_dentry->d_inode; + int err; + struct buffer_head *fe_bh = NULL; + struct buffer_head *parent_fe_bh = NULL; + struct buffer_head *de_bh = NULL; + struct ocfs2_dinode *fe = NULL; + struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); + + mlog_entry("(inode=%lu, old='%.*s' new='%.*s')\n", inode->i_ino, + old_dentry->d_name.len, old_dentry->d_name.name, + dentry->d_name.len, dentry->d_name.name); + + if (S_ISDIR(inode->i_mode)) { + err = -EPERM; + goto bail; + } + + if (inode->i_nlink >= OCFS2_LINK_MAX) { + err = -EMLINK; + goto bail; + } + + handle = ocfs2_alloc_handle(osb); + if (handle == NULL) { + err = -ENOMEM; + goto bail; + } + + err = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); + if (err < 0) { + if (err != -ENOENT) + mlog_errno(err); + goto bail; + } + + err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, + dentry->d_name.len); + if (err) + goto bail; + + err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, + dentry->d_name.name, + dentry->d_name.len, &de_bh); + if (err < 0) { + mlog_errno(err); + goto bail; + } + + err = ocfs2_meta_lock(inode, handle, &fe_bh, 1); + if (err < 0) { + if (err != -ENOENT) + mlog_errno(err); + goto bail; + } + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) { + err = -EMLINK; + goto bail; + } + + handle = ocfs2_start_trans(osb, handle, OCFS2_LINK_CREDITS); + if (IS_ERR(handle)) { + err = PTR_ERR(handle); + handle = NULL; + mlog_errno(err); + goto bail; + } + + err = ocfs2_journal_access(handle, inode, fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (err < 0) { + mlog_errno(err); + goto bail; + } + + inode->i_nlink++; + inode->i_ctime = CURRENT_TIME; + fe->i_links_count = cpu_to_le16(inode->i_nlink); + fe->i_ctime = cpu_to_le64(inode->i_ctime.tv_sec); + fe->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec); + + err = ocfs2_journal_dirty(handle, fe_bh); + if (err < 0) { + le16_add_cpu(&fe->i_links_count, -1); + inode->i_nlink--; + mlog_errno(err); + goto bail; + } + + err = ocfs2_add_entry(handle, dentry, inode, + OCFS2_I(inode)->ip_blkno, + parent_fe_bh, de_bh); + if (err) { + le16_add_cpu(&fe->i_links_count, -1); + inode->i_nlink--; + mlog_errno(err); + goto bail; + } + + atomic_inc(&inode->i_count); + dentry->d_op = &ocfs2_dentry_ops; + d_instantiate(dentry, inode); +bail: + if (handle) + ocfs2_commit_trans(handle); + if (de_bh) + brelse(de_bh); + if (fe_bh) + brelse(fe_bh); + if (parent_fe_bh) + brelse(parent_fe_bh); + + mlog_exit(err); + + return err; +} + +static int ocfs2_unlink(struct inode *dir, + struct dentry *dentry) +{ + int status; + unsigned int saved_nlink = 0; + struct inode *inode = dentry->d_inode; + struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); + u64 blkno; + struct ocfs2_dinode *fe = NULL; + struct buffer_head *fe_bh = NULL; + struct buffer_head *parent_node_bh = NULL; + struct ocfs2_journal_handle *handle = NULL; + struct ocfs2_dir_entry *dirent = NULL; + struct buffer_head *dirent_bh = NULL; + char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; + struct buffer_head *orphan_entry_bh = NULL; + + mlog_entry("(0x%p, 0x%p, '%.*s')\n", dir, dentry, + dentry->d_name.len, dentry->d_name.name); + + BUG_ON(dentry->d_parent->d_inode != dir); + + mlog(0, "ino = %"MLFu64"\n", OCFS2_I(inode)->ip_blkno); + + if (inode == osb->root_inode) { + mlog(0, "Cannot delete the root directory\n"); + status = -EPERM; + goto leave; + } + + handle = ocfs2_alloc_handle(osb); + if (handle == NULL) { + status = -ENOMEM; + mlog_errno(status); + goto leave; + } + + status = ocfs2_meta_lock(dir, handle, &parent_node_bh, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto leave; + } + + status = ocfs2_find_files_on_disk(dentry->d_name.name, + dentry->d_name.len, &blkno, + dir, &dirent_bh, &dirent); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto leave; + } + + if (OCFS2_I(inode)->ip_blkno != blkno) { + status = -ENOENT; + + mlog(0, "ip_blkno (%"MLFu64") != dirent blkno (%"MLFu64") " + "ip_flags = %x\n", OCFS2_I(inode)->ip_blkno, blkno, + OCFS2_I(inode)->ip_flags); + goto leave; + } + + status = ocfs2_meta_lock(inode, handle, &fe_bh, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto leave; + } + + if (S_ISDIR(inode->i_mode)) { + if (!ocfs2_empty_dir(inode)) { + status = -ENOTEMPTY; + goto leave; + } else if (inode->i_nlink != 2) { + status = -ENOTEMPTY; + goto leave; + } + } + + /* There are still a few steps left until we can consider the + * unlink to have succeeded. Save off nlink here before + * modification so we can set it back in case we hit an issue + * before commit. */ + saved_nlink = inode->i_nlink; + if (S_ISDIR(inode->i_mode)) + inode->i_nlink = 0; + else + inode->i_nlink--; + + status = ocfs2_request_unlink_vote(inode, dentry, + (unsigned int) inode->i_nlink); + if (status < 0) { + /* This vote should succeed under all normal + * circumstances. */ + mlog_errno(status); + goto leave; + } + + if (!inode->i_nlink) { + status = ocfs2_prepare_orphan_dir(osb, handle, inode, + orphan_name, + &orphan_entry_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + } + + handle = ocfs2_start_trans(osb, handle, OCFS2_UNLINK_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto leave; + } + + status = ocfs2_journal_access(handle, inode, fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + fe = (struct ocfs2_dinode *) fe_bh->b_data; + + if (!inode->i_nlink) { + status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, + orphan_entry_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + } + + /* delete the name from the parent dir */ + status = ocfs2_delete_entry(handle, dir, dirent, dirent_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + /* We can set nlink on the dinode now. clear the saved version + * so that it doesn't get set later. */ + fe->i_links_count = cpu_to_le16(inode->i_nlink); + saved_nlink = 0; + + status = ocfs2_journal_dirty(handle, fe_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + if (S_ISDIR(inode->i_mode)) { + dir->i_nlink--; + status = ocfs2_mark_inode_dirty(handle, dir, + parent_node_bh); + if (status < 0) { + mlog_errno(status); + dir->i_nlink++; + } + } + +leave: + if (status < 0 && saved_nlink) + inode->i_nlink = saved_nlink; + + if (handle) + ocfs2_commit_trans(handle); + + if (fe_bh) + brelse(fe_bh); + + if (dirent_bh) + brelse(dirent_bh); + + if (parent_node_bh) + brelse(parent_node_bh); + + if (orphan_entry_bh) + brelse(orphan_entry_bh); + + mlog_exit(status); + + return status; +} + +/* + * The only place this should be used is rename! + * if they have the same id, then the 1st one is the only one locked. + */ +static int ocfs2_double_lock(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct buffer_head **bh1, + struct inode *inode1, + struct buffer_head **bh2, + struct inode *inode2) +{ + int status; + struct ocfs2_inode_info *oi1 = OCFS2_I(inode1); + struct ocfs2_inode_info *oi2 = OCFS2_I(inode2); + struct buffer_head **tmpbh; + struct inode *tmpinode; + + mlog_entry("(inode1 = %"MLFu64", inode2 = %"MLFu64")\n", + oi1->ip_blkno, oi2->ip_blkno); + + BUG_ON(!handle); + + if (*bh1) + *bh1 = NULL; + if (*bh2) + *bh2 = NULL; + + /* we always want to lock the one with the lower lockid first. */ + if (oi1->ip_blkno != oi2->ip_blkno) { + if (oi1->ip_blkno < oi2->ip_blkno) { + /* switch id1 and id2 around */ + mlog(0, "switching them around...\n"); + tmpbh = bh2; + bh2 = bh1; + bh1 = tmpbh; + + tmpinode = inode2; + inode2 = inode1; + inode1 = tmpinode; + } + /* lock id2 */ + status = ocfs2_meta_lock(inode2, handle, bh2, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto bail; + } + } + /* lock id1 */ + status = ocfs2_meta_lock(inode1, handle, bh1, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto bail; + } +bail: + mlog_exit(status); + return status; +} + +#define PARENT_INO(buffer) \ + ((struct ocfs2_dir_entry *) \ + ((char *)buffer + \ + le16_to_cpu(((struct ocfs2_dir_entry *)buffer)->rec_len)))->inode + +static int ocfs2_rename(struct inode *old_dir, + struct dentry *old_dentry, + struct inode *new_dir, + struct dentry *new_dentry) +{ + int status = 0, rename_lock = 0; + struct inode *old_inode = old_dentry->d_inode; + struct inode *new_inode = new_dentry->d_inode; + struct ocfs2_dinode *newfe = NULL; + char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; + struct buffer_head *orphan_entry_bh = NULL; + struct buffer_head *newfe_bh = NULL; + struct buffer_head *insert_entry_bh = NULL; + struct ocfs2_super *osb = NULL; + u64 newfe_blkno; + struct ocfs2_journal_handle *handle = NULL; + struct buffer_head *old_dir_bh = NULL; + struct buffer_head *new_dir_bh = NULL; + struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry + // and new_dentry + struct buffer_head *new_de_bh = NULL, *old_de_bh = NULL; // bhs for above + struct buffer_head *old_inode_de_bh = NULL; // if old_dentry is a dir, + // this is the 1st dirent bh + nlink_t old_dir_nlink = old_dir->i_nlink, new_dir_nlink = new_dir->i_nlink; + unsigned int links_count; + + /* At some point it might be nice to break this function up a + * bit. */ + + mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p, from='%.*s' to='%.*s')\n", + old_dir, old_dentry, new_dir, new_dentry, + old_dentry->d_name.len, old_dentry->d_name.name, + new_dentry->d_name.len, new_dentry->d_name.name); + + osb = OCFS2_SB(old_dir->i_sb); + + if (new_inode) { + if (!igrab(new_inode)) + BUG(); + } + + if (atomic_read(&old_dentry->d_count) > 2) { + shrink_dcache_parent(old_dentry); + if (atomic_read(&old_dentry->d_count) > 2) { + status = -EBUSY; + goto bail; + } + } + + /* Assume a directory heirarchy thusly: + * a/b/c + * a/d + * a,b,c, and d are all directories. + * + * from cwd of 'a' on both nodes: + * node1: mv b/c d + * node2: mv d b/c + * + * And that's why, just like the VFS, we need a file system + * rename lock. */ + if (old_dentry != new_dentry) { + status = ocfs2_rename_lock(osb); + if (status < 0) { + mlog_errno(status); + goto bail; + } + rename_lock = 1; + } + + handle = ocfs2_alloc_handle(osb); + if (handle == NULL) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + /* if old and new are the same, this'll just do one lock. */ + status = ocfs2_double_lock(osb, handle, + &old_dir_bh, old_dir, + &new_dir_bh, new_dir); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* make sure both dirs have bhs + * get an extra ref on old_dir_bh if old==new */ + if (!new_dir_bh) { + if (old_dir_bh) { + new_dir_bh = old_dir_bh; + get_bh(new_dir_bh); + } else { + mlog(ML_ERROR, "no old_dir_bh!\n"); + status = -EIO; + goto bail; + } + } + + if (S_ISDIR(old_inode->i_mode)) { + /* Directories actually require metadata updates to + * the directory info so we can't get away with not + * doing node locking on it. */ + status = ocfs2_meta_lock(old_inode, handle, NULL, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto bail; + } + + status = ocfs2_request_rename_vote(old_inode, old_dentry); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = -EIO; + old_inode_de_bh = ocfs2_bread(old_inode, 0, &status, 0); + if (!old_inode_de_bh) + goto bail; + + status = -EIO; + if (le64_to_cpu(PARENT_INO(old_inode_de_bh->b_data)) != + OCFS2_I(old_dir)->ip_blkno) + goto bail; + status = -EMLINK; + if (!new_inode && new_dir!=old_dir && + new_dir->i_nlink >= OCFS2_LINK_MAX) + goto bail; + } else { + /* Ah, the simple case - we're a file so just send a + * message. */ + status = ocfs2_request_rename_vote(old_inode, old_dentry); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + status = -ENOENT; + old_de_bh = ocfs2_find_entry(old_dentry->d_name.name, + old_dentry->d_name.len, + old_dir, &old_de); + if (!old_de_bh) + goto bail; + + /* + * Check for inode number is _not_ due to possible IO errors. + * We might rmdir the source, keep it as pwd of some process + * and merrily kill the link to whatever was created under the + * same name. Goodbye sticky bit ;-< + */ + if (le64_to_cpu(old_de->inode) != OCFS2_I(old_inode)->ip_blkno) + goto bail; + + /* check if the target already exists (in which case we need + * to delete it */ + status = ocfs2_find_files_on_disk(new_dentry->d_name.name, + new_dentry->d_name.len, + &newfe_blkno, new_dir, &new_de_bh, + &new_de); + /* The only error we allow here is -ENOENT because the new + * file not existing is perfectly valid. */ + if ((status < 0) && (status != -ENOENT)) { + /* If we cannot find the file specified we should just */ + /* return the error... */ + mlog_errno(status); + goto bail; + } + + if (!new_de && new_inode) + mlog(ML_ERROR, "inode %lu does not exist in it's parent " + "directory!", new_inode->i_ino); + + /* In case we need to overwrite an existing file, we blow it + * away first */ + if (new_de) { + /* VFS didn't think there existed an inode here, but + * someone else in the cluster must have raced our + * rename to create one. Today we error cleanly, in + * the future we should consider calling iget to build + * a new struct inode for this entry. */ + if (!new_inode) { + status = -EACCES; + + mlog(0, "We found an inode for name %.*s but VFS " + "didn't give us one.\n", new_dentry->d_name.len, + new_dentry->d_name.name); + goto bail; + } + + if (OCFS2_I(new_inode)->ip_blkno != newfe_blkno) { + status = -EACCES; + + mlog(0, "Inode blkno (%"MLFu64") and dir (%"MLFu64") " + "disagree. ip_flags = %x\n", + OCFS2_I(new_inode)->ip_blkno, newfe_blkno, + OCFS2_I(new_inode)->ip_flags); + goto bail; + } + + status = ocfs2_meta_lock(new_inode, handle, &newfe_bh, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto bail; + } + + if (S_ISDIR(new_inode->i_mode)) + links_count = 0; + else + links_count = (unsigned int) (new_inode->i_nlink - 1); + + status = ocfs2_request_unlink_vote(new_inode, new_dentry, + links_count); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + newfe = (struct ocfs2_dinode *) newfe_bh->b_data; + + mlog(0, "aha rename over existing... new_de=%p " + "new_blkno=%"MLFu64" newfebh=%p bhblocknr=%llu\n", + new_de, newfe_blkno, newfe_bh, newfe_bh ? + (unsigned long long)newfe_bh->b_blocknr : 0ULL); + + if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) { + status = ocfs2_prepare_orphan_dir(osb, handle, + new_inode, + orphan_name, + &orphan_entry_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + } else { + BUG_ON(new_dentry->d_parent->d_inode != new_dir); + + status = ocfs2_check_dir_for_entry(new_dir, + new_dentry->d_name.name, + new_dentry->d_name.len); + if (status) + goto bail; + + status = ocfs2_prepare_dir_for_insert(osb, new_dir, new_dir_bh, + new_dentry->d_name.name, + new_dentry->d_name.len, + &insert_entry_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + handle = ocfs2_start_trans(osb, handle, OCFS2_RENAME_CREDITS); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + if (new_de) { + if (S_ISDIR(new_inode->i_mode)) { + if (!ocfs2_empty_dir(new_inode) || + new_inode->i_nlink != 2) { + status = -ENOTEMPTY; + goto bail; + } + } + status = ocfs2_journal_access(handle, new_inode, newfe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (S_ISDIR(new_inode->i_mode) || + (newfe->i_links_count == cpu_to_le16(1))){ + status = ocfs2_orphan_add(osb, handle, new_inode, + newfe, orphan_name, + orphan_entry_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + /* change the dirent to point to the correct inode */ + status = ocfs2_journal_access(handle, new_dir, new_de_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + new_de->inode = cpu_to_le64(OCFS2_I(old_inode)->ip_blkno); + new_de->file_type = old_de->file_type; + new_dir->i_version++; + status = ocfs2_journal_dirty(handle, new_de_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (S_ISDIR(new_inode->i_mode)) + newfe->i_links_count = 0; + else + le16_add_cpu(&newfe->i_links_count, -1); + + status = ocfs2_journal_dirty(handle, newfe_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } else { + /* if the name was not found in new_dir, add it now */ + status = ocfs2_add_entry(handle, new_dentry, old_inode, + OCFS2_I(old_inode)->ip_blkno, + new_dir_bh, insert_entry_bh); + } + + old_inode->i_ctime = CURRENT_TIME; + mark_inode_dirty(old_inode); + + /* now that the name has been added to new_dir, remove the old name */ + status = ocfs2_delete_entry(handle, old_dir, old_de, old_de_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (new_inode) { + new_inode->i_nlink--; + new_inode->i_ctime = CURRENT_TIME; + } + old_dir->i_ctime = old_dir->i_mtime = CURRENT_TIME; + if (old_inode_de_bh) { + status = ocfs2_journal_access(handle, old_inode, + old_inode_de_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + PARENT_INO(old_inode_de_bh->b_data) = + cpu_to_le64(OCFS2_I(new_dir)->ip_blkno); + status = ocfs2_journal_dirty(handle, old_inode_de_bh); + old_dir->i_nlink--; + if (new_inode) { + new_inode->i_nlink--; + } else { + new_dir->i_nlink++; + mark_inode_dirty(new_dir); + } + } + mark_inode_dirty(old_dir); + if (new_inode) + mark_inode_dirty(new_inode); + + if (old_dir != new_dir) + if (new_dir_nlink != new_dir->i_nlink) { + if (!new_dir_bh) { + mlog(ML_ERROR, "need to change nlink for new " + "dir %"MLFu64" from %d to %d but bh is " + "NULL\n", OCFS2_I(new_dir)->ip_blkno, + (int)new_dir_nlink, new_dir->i_nlink); + } else { + struct ocfs2_dinode *fe; + status = ocfs2_journal_access(handle, + new_dir, + new_dir_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + fe = (struct ocfs2_dinode *) new_dir_bh->b_data; + fe->i_links_count = cpu_to_le16(new_dir->i_nlink); + status = ocfs2_journal_dirty(handle, new_dir_bh); + } + } + + if (old_dir_nlink != old_dir->i_nlink) { + if (!old_dir_bh) { + mlog(ML_ERROR, "need to change nlink for old dir " + "%"MLFu64" from %d to %d but bh is NULL!\n", + OCFS2_I(old_dir)->ip_blkno, + (int)old_dir_nlink, + old_dir->i_nlink); + } else { + struct ocfs2_dinode *fe; + status = ocfs2_journal_access(handle, old_dir, + old_dir_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + fe = (struct ocfs2_dinode *) old_dir_bh->b_data; + fe->i_links_count = cpu_to_le16(old_dir->i_nlink); + status = ocfs2_journal_dirty(handle, old_dir_bh); + } + } + + status = 0; +bail: + if (rename_lock) + ocfs2_rename_unlock(osb); + + if (handle) + ocfs2_commit_trans(handle); + + if (new_inode) + sync_mapping_buffers(old_inode->i_mapping); + + if (new_inode) + iput(new_inode); + if (newfe_bh) + brelse(newfe_bh); + if (old_dir_bh) + brelse(old_dir_bh); + if (new_dir_bh) + brelse(new_dir_bh); + if (new_de_bh) + brelse(new_de_bh); + if (old_de_bh) + brelse(old_de_bh); + if (old_inode_de_bh) + brelse(old_inode_de_bh); + if (orphan_entry_bh) + brelse(orphan_entry_bh); + if (insert_entry_bh) + brelse(insert_entry_bh); + + mlog_exit(status); + + return status; +} + +/* + * we expect i_size = strlen(symname). Copy symname into the file + * data, including the null terminator. + */ +static int ocfs2_create_symlink_data(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + const char *symname) +{ + struct buffer_head **bhs = NULL; + const char *c; + struct super_block *sb = osb->sb; + u64 p_blkno; + int p_blocks; + int virtual, blocks, status, i, bytes_left; + + bytes_left = i_size_read(inode) + 1; + /* we can't trust i_blocks because we're actually going to + * write i_size + 1 bytes. */ + blocks = (bytes_left + sb->s_blocksize - 1) >> sb->s_blocksize_bits; + + mlog_entry("i_blocks = %lu, i_size = %llu, blocks = %d\n", + inode->i_blocks, i_size_read(inode), blocks); + + /* Sanity check -- make sure we're going to fit. */ + if (bytes_left > + ocfs2_clusters_to_bytes(sb, OCFS2_I(inode)->ip_clusters)) { + status = -EIO; + mlog_errno(status); + goto bail; + } + + bhs = kcalloc(blocks, sizeof(struct buffer_head *), GFP_KERNEL); + if (!bhs) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + status = ocfs2_extent_map_get_blocks(inode, 0, 1, &p_blkno, + &p_blocks); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* links can never be larger than one cluster so we know this + * is all going to be contiguous, but do a sanity check + * anyway. */ + if ((p_blocks << sb->s_blocksize_bits) < bytes_left) { + status = -EIO; + mlog_errno(status); + goto bail; + } + + virtual = 0; + while(bytes_left > 0) { + c = &symname[virtual * sb->s_blocksize]; + + bhs[virtual] = sb_getblk(sb, p_blkno); + if (!bhs[virtual]) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + ocfs2_set_new_buffer_uptodate(inode, bhs[virtual]); + + status = ocfs2_journal_access(handle, inode, bhs[virtual], + OCFS2_JOURNAL_ACCESS_CREATE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + memset(bhs[virtual]->b_data, 0, sb->s_blocksize); + + memcpy(bhs[virtual]->b_data, c, + (bytes_left > sb->s_blocksize) ? sb->s_blocksize : + bytes_left); + + status = ocfs2_journal_dirty(handle, bhs[virtual]); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + virtual++; + p_blkno++; + bytes_left -= sb->s_blocksize; + } + + status = 0; +bail: + + if (bhs) { + for(i = 0; i < blocks; i++) + if (bhs[i]) + brelse(bhs[i]); + kfree(bhs); + } + + mlog_exit(status); + return status; +} + +static int ocfs2_symlink(struct inode *dir, + struct dentry *dentry, + const char *symname) +{ + int status, l, credits; + u64 newsize; + struct ocfs2_super *osb = NULL; + struct inode *inode = NULL; + struct super_block *sb; + struct buffer_head *new_fe_bh = NULL; + struct buffer_head *de_bh = NULL; + struct buffer_head *parent_fe_bh = NULL; + struct ocfs2_dinode *fe = NULL; + struct ocfs2_dinode *dirfe; + struct ocfs2_journal_handle *handle = NULL; + struct ocfs2_alloc_context *inode_ac = NULL; + struct ocfs2_alloc_context *data_ac = NULL; + + mlog_entry("(0x%p, 0x%p, symname='%s' actual='%.*s')\n", dir, + dentry, symname, dentry->d_name.len, dentry->d_name.name); + + sb = dir->i_sb; + osb = OCFS2_SB(sb); + + l = strlen(symname) + 1; + + credits = ocfs2_calc_symlink_credits(sb); + + handle = ocfs2_alloc_handle(osb); + if (handle == NULL) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + /* lock the parent directory */ + status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + goto bail; + } + + dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data; + if (!dirfe->i_links_count) { + /* can't make a file in a deleted directory. */ + status = -ENOENT; + goto bail; + } + + status = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, + dentry->d_name.len); + if (status) + goto bail; + + status = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, + dentry->d_name.name, + dentry->d_name.len, &de_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_reserve_new_inode(osb, handle, &inode_ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + /* don't reserve bitmap space for fast symlinks. */ + if (l > ocfs2_fast_symlink_chars(sb)) { + status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + } + + handle = ocfs2_start_trans(osb, handle, credits); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + status = ocfs2_mknod_locked(osb, dir, dentry, + S_IFLNK | S_IRWXUGO, 0, + &new_fe_bh, parent_fe_bh, handle, + &inode, inode_ac); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + fe = (struct ocfs2_dinode *) new_fe_bh->b_data; + inode->i_rdev = 0; + newsize = l - 1; + if (l > ocfs2_fast_symlink_chars(sb)) { + inode->i_op = &ocfs2_symlink_inode_operations; + status = ocfs2_do_extend_allocation(osb, inode, 1, new_fe_bh, + handle, data_ac, NULL, + NULL); + if (status < 0) { + if (status != -ENOSPC && status != -EINTR) { + mlog(ML_ERROR, "Failed to extend file to " + "%"MLFu64"\n", + newsize); + mlog_errno(status); + status = -ENOSPC; + } + goto bail; + } + i_size_write(inode, newsize); + inode->i_blocks = ocfs2_align_bytes_to_sectors(newsize); + } else { + inode->i_op = &ocfs2_fast_symlink_inode_operations; + memcpy((char *) fe->id2.i_symlink, symname, l); + i_size_write(inode, newsize); + inode->i_blocks = 0; + } + + status = ocfs2_mark_inode_dirty(handle, inode, new_fe_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (!ocfs2_inode_is_fast_symlink(inode)) { + status = ocfs2_create_symlink_data(osb, handle, inode, + symname); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + status = ocfs2_add_entry(handle, dentry, inode, + le64_to_cpu(fe->i_blkno), parent_fe_bh, + de_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + insert_inode_hash(inode); + dentry->d_op = &ocfs2_dentry_ops; + d_instantiate(dentry, inode); +bail: + if (handle) + ocfs2_commit_trans(handle); + if (new_fe_bh) + brelse(new_fe_bh); + if (parent_fe_bh) + brelse(parent_fe_bh); + if (de_bh) + brelse(de_bh); + if (inode_ac) + ocfs2_free_alloc_context(inode_ac); + if (data_ac) + ocfs2_free_alloc_context(data_ac); + if ((status < 0) && inode) + iput(inode); + + mlog_exit(status); + + return status; +} + +int ocfs2_check_dir_entry(struct inode * dir, + struct ocfs2_dir_entry * de, + struct buffer_head * bh, + unsigned long offset) +{ + const char *error_msg = NULL; + const int rlen = le16_to_cpu(de->rec_len); + + if (rlen < OCFS2_DIR_REC_LEN(1)) + error_msg = "rec_len is smaller than minimal"; + else if (rlen % 4 != 0) + error_msg = "rec_len % 4 != 0"; + else if (rlen < OCFS2_DIR_REC_LEN(de->name_len)) + error_msg = "rec_len is too small for name_len"; + else if (((char *) de - bh->b_data) + rlen > dir->i_sb->s_blocksize) + error_msg = "directory entry across blocks"; + + if (error_msg != NULL) + mlog(ML_ERROR, "bad entry in directory #%"MLFu64": %s - " + "offset=%lu, inode=%"MLFu64", rec_len=%d, name_len=%d\n", + OCFS2_I(dir)->ip_blkno, error_msg, offset, + le64_to_cpu(de->inode), rlen, de->name_len); + return error_msg == NULL ? 1 : 0; +} + +/* we don't always have a dentry for what we want to add, so people + * like orphan dir can call this instead. + * + * If you pass me insert_bh, I'll skip the search of the other dir + * blocks and put the record in there. + */ +static int __ocfs2_add_entry(struct ocfs2_journal_handle *handle, + struct inode *dir, + const char *name, int namelen, + struct inode *inode, u64 blkno, + struct buffer_head *parent_fe_bh, + struct buffer_head *insert_bh) +{ + unsigned long offset; + unsigned short rec_len; + struct ocfs2_dir_entry *de, *de1; + struct super_block *sb; + int retval, status; + + mlog_entry_void(); + + sb = dir->i_sb; + + if (!namelen) + return -EINVAL; + + rec_len = OCFS2_DIR_REC_LEN(namelen); + offset = 0; + de = (struct ocfs2_dir_entry *) insert_bh->b_data; + while (1) { + BUG_ON((char *)de >= sb->s_blocksize + insert_bh->b_data); + /* These checks should've already been passed by the + * prepare function, but I guess we can leave them + * here anyway. */ + if (!ocfs2_check_dir_entry(dir, de, insert_bh, offset)) { + retval = -ENOENT; + goto bail; + } + if (ocfs2_match(namelen, name, de)) { + retval = -EEXIST; + goto bail; + } + if (((le64_to_cpu(de->inode) == 0) && + (le16_to_cpu(de->rec_len) >= rec_len)) || + (le16_to_cpu(de->rec_len) >= + (OCFS2_DIR_REC_LEN(de->name_len) + rec_len))) { + status = ocfs2_journal_access(handle, dir, insert_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + /* By now the buffer is marked for journaling */ + offset += le16_to_cpu(de->rec_len); + if (le64_to_cpu(de->inode)) { + de1 = (struct ocfs2_dir_entry *)((char *) de + + OCFS2_DIR_REC_LEN(de->name_len)); + de1->rec_len = + cpu_to_le16(le16_to_cpu(de->rec_len) - + OCFS2_DIR_REC_LEN(de->name_len)); + de->rec_len = cpu_to_le16(OCFS2_DIR_REC_LEN(de->name_len)); + de = de1; + } + de->file_type = OCFS2_FT_UNKNOWN; + if (blkno) { + de->inode = cpu_to_le64(blkno); + ocfs2_set_de_type(de, inode->i_mode); + } else + de->inode = 0; + de->name_len = namelen; + memcpy(de->name, name, namelen); + + dir->i_mtime = dir->i_ctime = CURRENT_TIME; + dir->i_version++; + status = ocfs2_journal_dirty(handle, insert_bh); + retval = 0; + goto bail; + } + offset += le16_to_cpu(de->rec_len); + de = (struct ocfs2_dir_entry *) ((char *) de + le16_to_cpu(de->rec_len)); + } + + /* when you think about it, the assert above should prevent us + * from ever getting here. */ + retval = -ENOSPC; +bail: + + mlog_exit(retval); + return retval; +} + + +/* + * ocfs2_delete_entry deletes a directory entry by merging it with the + * previous entry + */ +static int ocfs2_delete_entry(struct ocfs2_journal_handle *handle, + struct inode *dir, + struct ocfs2_dir_entry *de_del, + struct buffer_head *bh) +{ + struct ocfs2_dir_entry *de, *pde; + int i, status = -ENOENT; + + mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p)\n", handle, dir, de_del, bh); + + i = 0; + pde = NULL; + de = (struct ocfs2_dir_entry *) bh->b_data; + while (i < bh->b_size) { + if (!ocfs2_check_dir_entry(dir, de, bh, i)) { + status = -EIO; + mlog_errno(status); + goto bail; + } + if (de == de_del) { + status = ocfs2_journal_access(handle, dir, bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + status = -EIO; + mlog_errno(status); + goto bail; + } + if (pde) + pde->rec_len = + cpu_to_le16(le16_to_cpu(pde->rec_len) + + le16_to_cpu(de->rec_len)); + else + de->inode = 0; + dir->i_version++; + status = ocfs2_journal_dirty(handle, bh); + goto bail; + } + i += le16_to_cpu(de->rec_len); + pde = de; + de = (struct ocfs2_dir_entry *)((char *)de + le16_to_cpu(de->rec_len)); + } +bail: + mlog_exit(status); + return status; +} + +/* + * Returns 0 if not found, -1 on failure, and 1 on success + */ +static int inline ocfs2_search_dirblock(struct buffer_head *bh, + struct inode *dir, + const char *name, int namelen, + unsigned long offset, + struct ocfs2_dir_entry **res_dir) +{ + struct ocfs2_dir_entry *de; + char *dlimit, *de_buf; + int de_len; + int ret = 0; + + mlog_entry_void(); + + de_buf = bh->b_data; + dlimit = de_buf + dir->i_sb->s_blocksize; + + while (de_buf < dlimit) { + /* this code is executed quadratically often */ + /* do minimal checking `by hand' */ + + de = (struct ocfs2_dir_entry *) de_buf; + + if (de_buf + namelen <= dlimit && + ocfs2_match(namelen, name, de)) { + /* found a match - just to be sure, do a full check */ + if (!ocfs2_check_dir_entry(dir, de, bh, offset)) { + ret = -1; + goto bail; + } + *res_dir = de; + ret = 1; + goto bail; + } + + /* prevent looping on a bad block */ + de_len = le16_to_cpu(de->rec_len); + if (de_len <= 0) { + ret = -1; + goto bail; + } + + de_buf += de_len; + offset += de_len; + } + +bail: + mlog_exit(ret); + return ret; +} + +struct buffer_head *ocfs2_find_entry(const char *name, int namelen, + struct inode *dir, + struct ocfs2_dir_entry **res_dir) +{ + struct super_block *sb; + struct buffer_head *bh_use[NAMEI_RA_SIZE]; + struct buffer_head *bh, *ret = NULL; + unsigned long start, block, b; + int ra_max = 0; /* Number of bh's in the readahead + buffer, bh_use[] */ + int ra_ptr = 0; /* Current index into readahead + buffer */ + int num = 0; + int nblocks, i, err; + + mlog_entry_void(); + + *res_dir = NULL; + sb = dir->i_sb; + + nblocks = i_size_read(dir) >> sb->s_blocksize_bits; + start = OCFS2_I(dir)->ip_dir_start_lookup; + if (start >= nblocks) + start = 0; + block = start; + +restart: + do { + /* + * We deal with the read-ahead logic here. + */ + if (ra_ptr >= ra_max) { + /* Refill the readahead buffer */ + ra_ptr = 0; + b = block; + for (ra_max = 0; ra_max < NAMEI_RA_SIZE; ra_max++) { + /* + * Terminate if we reach the end of the + * directory and must wrap, or if our + * search has finished at this block. + */ + if (b >= nblocks || (num && block == start)) { + bh_use[ra_max] = NULL; + break; + } + num++; + + /* XXX: questionable readahead stuff here */ + bh = ocfs2_bread(dir, b++, &err, 1); + bh_use[ra_max] = bh; +#if 0 // ??? + if (bh) + ll_rw_block(READ, 1, &bh); +#endif + } + } + if ((bh = bh_use[ra_ptr++]) == NULL) + goto next; + wait_on_buffer(bh); + if (!buffer_uptodate(bh)) { + /* read error, skip block & hope for the best */ + brelse(bh); + goto next; + } + i = ocfs2_search_dirblock(bh, dir, name, namelen, + block << sb->s_blocksize_bits, + res_dir); + if (i == 1) { + OCFS2_I(dir)->ip_dir_start_lookup = block; + ret = bh; + goto cleanup_and_exit; + } else { + brelse(bh); + if (i < 0) + goto cleanup_and_exit; + } + next: + if (++block >= nblocks) + block = 0; + } while (block != start); + + /* + * If the directory has grown while we were searching, then + * search the last part of the directory before giving up. + */ + block = nblocks; + nblocks = i_size_read(dir) >> sb->s_blocksize_bits; + if (block < nblocks) { + start = 0; + goto restart; + } + +cleanup_and_exit: + /* Clean up the read-ahead blocks */ + for (; ra_ptr < ra_max; ra_ptr++) + brelse(bh_use[ra_ptr]); + + mlog_exit_ptr(ret); + return ret; +} + +static int ocfs2_blkno_stringify(u64 blkno, char *name) +{ + int status, namelen; + + mlog_entry_void(); + + namelen = snprintf(name, OCFS2_ORPHAN_NAMELEN + 1, "%016"MLFx64, + blkno); + if (namelen <= 0) { + if (namelen) + status = namelen; + else + status = -EINVAL; + mlog_errno(status); + goto bail; + } + if (namelen != OCFS2_ORPHAN_NAMELEN) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + mlog(0, "built filename '%s' for orphan dir (len=%d)\n", name, + namelen); + + status = 0; +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + char *name, + struct buffer_head **de_bh) +{ + struct inode *orphan_dir_inode = NULL; + struct buffer_head *orphan_dir_bh = NULL; + int status = 0; + + status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + orphan_dir_inode = ocfs2_get_system_file_inode(osb, + ORPHAN_DIR_SYSTEM_INODE, + osb->slot_num); + if (!orphan_dir_inode) { + status = -ENOENT; + mlog_errno(status); + goto leave; + } + + ocfs2_handle_add_inode(handle, orphan_dir_inode); + status = ocfs2_meta_lock(orphan_dir_inode, handle, &orphan_dir_bh, 1); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_prepare_dir_for_insert(osb, orphan_dir_inode, + orphan_dir_bh, name, + OCFS2_ORPHAN_NAMELEN, de_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + +leave: + if (orphan_dir_inode) + iput(orphan_dir_inode); + + if (orphan_dir_bh) + brelse(orphan_dir_bh); + + mlog_exit(status); + return status; +} + +static int ocfs2_orphan_add(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *inode, + struct ocfs2_dinode *fe, + char *name, + struct buffer_head *de_bh) +{ + struct inode *orphan_dir_inode = NULL; + struct buffer_head *orphan_dir_bh = NULL; + int status = 0; + struct ocfs2_dinode *orphan_fe; + + mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); + + orphan_dir_inode = ocfs2_get_system_file_inode(osb, + ORPHAN_DIR_SYSTEM_INODE, + osb->slot_num); + if (!orphan_dir_inode) { + status = -ENOENT; + mlog_errno(status); + goto leave; + } + + status = ocfs2_read_block(osb, + OCFS2_I(orphan_dir_inode)->ip_blkno, + &orphan_dir_bh, OCFS2_BH_CACHED, + orphan_dir_inode); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_journal_access(handle, orphan_dir_inode, orphan_dir_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + /* we're a cluster, and nlink can change on disk from + * underneath us... */ + orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data; + if (S_ISDIR(inode->i_mode)) + le16_add_cpu(&orphan_fe->i_links_count, 1); + orphan_dir_inode->i_nlink = le16_to_cpu(orphan_fe->i_links_count); + + status = ocfs2_journal_dirty(handle, orphan_dir_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = __ocfs2_add_entry(handle, orphan_dir_inode, name, + OCFS2_ORPHAN_NAMELEN, inode, + OCFS2_I(inode)->ip_blkno, + orphan_dir_bh, de_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + le32_add_cpu(&fe->i_flags, OCFS2_ORPHANED_FL); + + /* Record which orphan dir our inode now resides + * in. delete_inode will use this to determine which orphan + * dir to lock. */ + spin_lock(&OCFS2_I(inode)->ip_lock); + OCFS2_I(inode)->ip_orphaned_slot = osb->slot_num; + spin_unlock(&OCFS2_I(inode)->ip_lock); + + mlog(0, "Inode %"MLFu64" orphaned in slot %d\n", + OCFS2_I(inode)->ip_blkno, osb->slot_num); + +leave: + if (orphan_dir_inode) + iput(orphan_dir_inode); + + if (orphan_dir_bh) + brelse(orphan_dir_bh); + + mlog_exit(status); + return status; +} + +/* unlike orphan_add, we expect the orphan dir to already be locked here. */ +int ocfs2_orphan_del(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *orphan_dir_inode, + struct inode *inode, + struct buffer_head *orphan_dir_bh) +{ + char name[OCFS2_ORPHAN_NAMELEN + 1]; + struct ocfs2_dinode *orphan_fe; + int status = 0; + struct buffer_head *target_de_bh = NULL; + struct ocfs2_dir_entry *target_de = NULL; + + mlog_entry_void(); + + status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + mlog(0, "removing '%s' from orphan dir %"MLFu64" (namelen=%d)\n", + name, OCFS2_I(orphan_dir_inode)->ip_blkno, OCFS2_ORPHAN_NAMELEN); + + /* find it's spot in the orphan directory */ + target_de_bh = ocfs2_find_entry(name, OCFS2_ORPHAN_NAMELEN, + orphan_dir_inode, &target_de); + if (!target_de_bh) { + status = -ENOENT; + mlog_errno(status); + goto leave; + } + + /* remove it from the orphan directory */ + status = ocfs2_delete_entry(handle, orphan_dir_inode, target_de, + target_de_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_journal_access(handle,orphan_dir_inode, orphan_dir_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + /* do the i_nlink dance! :) */ + orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data; + if (S_ISDIR(inode->i_mode)) + le16_add_cpu(&orphan_fe->i_links_count, -1); + orphan_dir_inode->i_nlink = le16_to_cpu(orphan_fe->i_links_count); + + status = ocfs2_journal_dirty(handle, orphan_dir_bh); + if (status < 0) { + mlog_errno(status); + goto leave; + } + +leave: + if (target_de_bh) + brelse(target_de_bh); + + mlog_exit(status); + return status; +} + +struct inode_operations ocfs2_dir_iops = { + .create = ocfs2_create, + .lookup = ocfs2_lookup, + .link = ocfs2_link, + .unlink = ocfs2_unlink, + .rmdir = ocfs2_unlink, + .symlink = ocfs2_symlink, + .mkdir = ocfs2_mkdir, + .mknod = ocfs2_mknod, + .rename = ocfs2_rename, + .setattr = ocfs2_setattr, + .getattr = ocfs2_getattr, +}; diff --git a/fs/ocfs2/namei.h b/fs/ocfs2/namei.h new file mode 100644 index 0000000..deaaa97 --- /dev/null +++ b/fs/ocfs2/namei.h @@ -0,0 +1,58 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * namei.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_NAMEI_H +#define OCFS2_NAMEI_H + +extern struct inode_operations ocfs2_dir_iops; + +struct dentry *ocfs2_get_parent(struct dentry *child); + +int ocfs2_check_dir_entry (struct inode *dir, + struct ocfs2_dir_entry *de, + struct buffer_head *bh, + unsigned long offset); +struct buffer_head *ocfs2_find_entry(const char *name, + int namelen, + struct inode *dir, + struct ocfs2_dir_entry **res_dir); +int ocfs2_orphan_del(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct inode *orphan_dir_inode, + struct inode *inode, + struct buffer_head *orphan_dir_bh); + +static inline int ocfs2_match(int len, + const char * const name, + struct ocfs2_dir_entry *de) +{ + if (len != de->name_len) + return 0; + if (!de->inode) + return 0; + return !memcmp(name, de->name, len); +} + +#endif /* OCFS2_NAMEI_H */ diff --git a/fs/ocfs2/ocfs1_fs_compat.h b/fs/ocfs2/ocfs1_fs_compat.h new file mode 100644 index 0000000..0b499bc --- /dev/null +++ b/fs/ocfs2/ocfs1_fs_compat.h @@ -0,0 +1,109 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ocfs1_fs_compat.h + * + * OCFS1 volume header definitions. OCFS2 creates valid but unmountable + * OCFS1 volume headers on the first two sectors of an OCFS2 volume. + * This allows an OCFS1 volume to see the partition and cleanly fail to + * mount it. + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef _OCFS1_FS_COMPAT_H +#define _OCFS1_FS_COMPAT_H + +#define OCFS1_MAX_VOL_SIGNATURE_LEN 128 +#define OCFS1_MAX_MOUNT_POINT_LEN 128 +#define OCFS1_MAX_VOL_ID_LENGTH 16 +#define OCFS1_MAX_VOL_LABEL_LEN 64 +#define OCFS1_MAX_CLUSTER_NAME_LEN 64 + +#define OCFS1_MAJOR_VERSION (2) +#define OCFS1_MINOR_VERSION (0) +#define OCFS1_VOLUME_SIGNATURE "OracleCFS" + +/* + * OCFS1 superblock. Lives at sector 0. + */ +struct ocfs1_vol_disk_hdr +{ +/*00*/ __u32 minor_version; + __u32 major_version; +/*08*/ __u8 signature[OCFS1_MAX_VOL_SIGNATURE_LEN]; +/*88*/ __u8 mount_point[OCFS1_MAX_MOUNT_POINT_LEN]; +/*108*/ __u64 serial_num; +/*110*/ __u64 device_size; + __u64 start_off; +/*120*/ __u64 bitmap_off; + __u64 publ_off; +/*130*/ __u64 vote_off; + __u64 root_bitmap_off; +/*140*/ __u64 data_start_off; + __u64 root_bitmap_size; +/*150*/ __u64 root_off; + __u64 root_size; +/*160*/ __u64 cluster_size; + __u64 num_nodes; +/*170*/ __u64 num_clusters; + __u64 dir_node_size; +/*180*/ __u64 file_node_size; + __u64 internal_off; +/*190*/ __u64 node_cfg_off; + __u64 node_cfg_size; +/*1A0*/ __u64 new_cfg_off; + __u32 prot_bits; + __s32 excl_mount; +/*1B0*/ +}; + + +struct ocfs1_disk_lock +{ +/*00*/ __u32 curr_master; + __u8 file_lock; + __u8 compat_pad[3]; /* Not in orignal definition. Used to + make the already existing alignment + explicit */ + __u64 last_write_time; +/*10*/ __u64 last_read_time; + __u32 writer_node_num; + __u32 reader_node_num; +/*20*/ __u64 oin_node_map; + __u64 dlock_seq_num; +/*30*/ +}; + +/* + * OCFS1 volume label. Lives at sector 1. + */ +struct ocfs1_vol_label +{ +/*00*/ struct ocfs1_disk_lock disk_lock; +/*30*/ __u8 label[OCFS1_MAX_VOL_LABEL_LEN]; +/*70*/ __u16 label_len; +/*72*/ __u8 vol_id[OCFS1_MAX_VOL_ID_LENGTH]; +/*82*/ __u16 vol_id_len; +/*84*/ __u8 cluster_name[OCFS1_MAX_CLUSTER_NAME_LEN]; +/*A4*/ __u16 cluster_name_len; +/*A6*/ +}; + + +#endif /* _OCFS1_FS_COMPAT_H */ + diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h new file mode 100644 index 0000000..f468c60 --- /dev/null +++ b/fs/ocfs2/ocfs2.h @@ -0,0 +1,464 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ocfs2.h + * + * Defines macros and structures used in OCFS2 + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_H +#define OCFS2_H + +#include +#include +#include +#include +#include +#include +#include + +#include "cluster/nodemanager.h" +#include "cluster/heartbeat.h" +#include "cluster/tcp.h" + +#include "dlm/dlmapi.h" + +#include "ocfs2_fs.h" +#include "endian.h" +#include "ocfs2_lockid.h" + +struct ocfs2_extent_map { + u32 em_clusters; + struct rb_root em_extents; +}; + +/* Most user visible OCFS2 inodes will have very few pieces of + * metadata, but larger files (including bitmaps, etc) must be taken + * into account when designing an access scheme. We allow a small + * amount of inlined blocks to be stored on an array and grow the + * structure into a rb tree when necessary. */ +#define OCFS2_INODE_MAX_CACHE_ARRAY 2 + +struct ocfs2_caching_info { + unsigned int ci_num_cached; + union { + sector_t ci_array[OCFS2_INODE_MAX_CACHE_ARRAY]; + struct rb_root ci_tree; + } ci_cache; +}; + +/* this limits us to 256 nodes + * if we need more, we can do a kmalloc for the map */ +#define OCFS2_NODE_MAP_MAX_NODES 256 +struct ocfs2_node_map { + u16 num_nodes; + unsigned long map[BITS_TO_LONGS(OCFS2_NODE_MAP_MAX_NODES)]; +}; + +enum ocfs2_ast_action { + OCFS2_AST_INVALID = 0, + OCFS2_AST_ATTACH, + OCFS2_AST_CONVERT, + OCFS2_AST_DOWNCONVERT, +}; + +/* actions for an unlockast function to take. */ +enum ocfs2_unlock_action { + OCFS2_UNLOCK_INVALID = 0, + OCFS2_UNLOCK_CANCEL_CONVERT, + OCFS2_UNLOCK_DROP_LOCK, +}; + +/* ocfs2_lock_res->l_flags flags. */ +#define OCFS2_LOCK_ATTACHED (0x00000001) /* have we initialized + * the lvb */ +#define OCFS2_LOCK_BUSY (0x00000002) /* we are currently in + * dlm_lock */ +#define OCFS2_LOCK_BLOCKED (0x00000004) /* blocked waiting to + * downconvert*/ +#define OCFS2_LOCK_LOCAL (0x00000008) /* newly created inode */ +#define OCFS2_LOCK_NEEDS_REFRESH (0x00000010) +#define OCFS2_LOCK_REFRESHING (0x00000020) +#define OCFS2_LOCK_INITIALIZED (0x00000040) /* track initialization + * for shutdown paths */ +#define OCFS2_LOCK_FREEING (0x00000080) /* help dlmglue track + * when to skip queueing + * a lock because it's + * about to be + * dropped. */ +#define OCFS2_LOCK_QUEUED (0x00000100) /* queued for downconvert */ + +struct ocfs2_lock_res_ops; + +typedef void (*ocfs2_lock_callback)(int status, unsigned long data); + +struct ocfs2_lock_res { + void *l_priv; + struct ocfs2_lock_res_ops *l_ops; + spinlock_t l_lock; + + struct list_head l_blocked_list; + struct list_head l_mask_waiters; + + enum ocfs2_lock_type l_type; + unsigned long l_flags; + char l_name[OCFS2_LOCK_ID_MAX_LEN]; + int l_level; + unsigned int l_ro_holders; + unsigned int l_ex_holders; + struct dlm_lockstatus l_lksb; + + /* used from AST/BAST funcs. */ + enum ocfs2_ast_action l_action; + enum ocfs2_unlock_action l_unlock_action; + int l_requested; + int l_blocking; + + wait_queue_head_t l_event; + + struct list_head l_debug_list; +}; + +struct ocfs2_dlm_debug { + struct kref d_refcnt; + struct dentry *d_locking_state; + struct list_head d_lockres_tracking; +}; + +enum ocfs2_vol_state +{ + VOLUME_INIT = 0, + VOLUME_MOUNTED, + VOLUME_DISMOUNTED, + VOLUME_DISABLED +}; + +struct ocfs2_alloc_stats +{ + atomic_t moves; + atomic_t local_data; + atomic_t bitmap_data; + atomic_t bg_allocs; + atomic_t bg_extends; +}; + +enum ocfs2_local_alloc_state +{ + OCFS2_LA_UNUSED = 0, + OCFS2_LA_ENABLED, + OCFS2_LA_DISABLED +}; + +enum ocfs2_mount_options +{ + OCFS2_MOUNT_HB_LOCAL = 1 << 0, /* Heartbeat started in local mode */ + OCFS2_MOUNT_BARRIER = 1 << 1, /* Use block barriers */ + OCFS2_MOUNT_NOINTR = 1 << 2, /* Don't catch signals */ + OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */ + OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */ +#ifdef OCFS2_ORACORE_WORKAROUNDS + OCFS2_MOUNT_COMPAT_OCFS = 1 << 30, /* ocfs1 compatibility mode */ +#endif +}; + +#define OCFS2_OSB_SOFT_RO 0x0001 +#define OCFS2_OSB_HARD_RO 0x0002 +#define OCFS2_OSB_ERROR_FS 0x0004 + +struct ocfs2_journal; +struct ocfs2_journal_handle; +struct ocfs2_super +{ + u32 osb_id; /* id used by the proc interface */ + struct task_struct *commit_task; + struct super_block *sb; + struct inode *root_inode; + struct inode *sys_root_inode; + struct inode *system_inodes[NUM_SYSTEM_INODES]; + + struct ocfs2_slot_info *slot_info; + + spinlock_t node_map_lock; + struct ocfs2_node_map mounted_map; + struct ocfs2_node_map recovery_map; + struct ocfs2_node_map umount_map; + + u32 num_clusters; + u64 root_blkno; + u64 system_dir_blkno; + u64 bitmap_blkno; + u32 bitmap_cpg; + u8 *uuid; + char *uuid_str; + u8 *vol_label; + u64 first_cluster_group_blkno; + u32 fs_generation; + + u32 s_feature_compat; + u32 s_feature_incompat; + u32 s_feature_ro_compat; + + /* Protects s_next_generaion, osb_flags. Could protect more on + * osb as it's very short lived. */ + spinlock_t osb_lock; + u32 s_next_generation; + unsigned long osb_flags; + + unsigned long s_mount_opt; + + u16 max_slots; + u16 num_nodes; + s16 node_num; + s16 slot_num; + int s_sectsize_bits; + int s_clustersize; + int s_clustersize_bits; + struct proc_dir_entry *proc_sub_dir; /* points to /proc/fs/ocfs2/ */ + + atomic_t vol_state; + struct semaphore recovery_lock; + struct task_struct *recovery_thread_task; + int disable_recovery; + wait_queue_head_t checkpoint_event; + atomic_t needs_checkpoint; + struct ocfs2_journal *journal; + + enum ocfs2_local_alloc_state local_alloc_state; + struct buffer_head *local_alloc_bh; + + /* Next two fields are for local node slot recovery during + * mount. */ + int dirty; + struct ocfs2_dinode *local_alloc_copy; + + struct ocfs2_alloc_stats alloc_stats; + char dev_str[20]; /* "major,minor" of the device */ + + struct dlm_ctxt *dlm; + struct ocfs2_lock_res osb_super_lockres; + struct ocfs2_lock_res osb_rename_lockres; + struct dlm_eviction_cb osb_eviction_cb; + struct ocfs2_dlm_debug *osb_dlm_debug; + + struct dentry *osb_debug_root; + + wait_queue_head_t recovery_event; + + spinlock_t vote_task_lock; + struct task_struct *vote_task; + wait_queue_head_t vote_event; + unsigned long vote_wake_sequence; + unsigned long vote_work_sequence; + + struct list_head blocked_lock_list; + unsigned long blocked_lock_count; + + struct list_head vote_list; + int vote_count; + + u32 net_key; + spinlock_t net_response_lock; + unsigned int net_response_ids; + struct list_head net_response_list; + + struct o2hb_callback_func osb_hb_up; + struct o2hb_callback_func osb_hb_down; + + struct list_head osb_net_handlers; + + wait_queue_head_t osb_mount_event; + + /* Truncate log info */ + struct inode *osb_tl_inode; + struct buffer_head *osb_tl_bh; + struct work_struct osb_truncate_log_wq; +}; + +#define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info) +#define OCFS2_MAX_OSB_ID 65536 + +static inline int ocfs2_should_order_data(struct inode *inode) +{ + if (!S_ISREG(inode->i_mode)) + return 0; + if (OCFS2_SB(inode->i_sb)->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK) + return 0; + return 1; +} + +/* set / clear functions because cluster events can make these happen + * in parallel so we want the transitions to be atomic. this also + * means that any future flags osb_flags must be protected by spinlock + * too! */ +static inline void ocfs2_set_osb_flag(struct ocfs2_super *osb, + unsigned long flag) +{ + spin_lock(&osb->osb_lock); + osb->osb_flags |= flag; + spin_unlock(&osb->osb_lock); +} + +static inline void ocfs2_set_ro_flag(struct ocfs2_super *osb, + int hard) +{ + spin_lock(&osb->osb_lock); + osb->osb_flags &= ~(OCFS2_OSB_SOFT_RO|OCFS2_OSB_HARD_RO); + if (hard) + osb->osb_flags |= OCFS2_OSB_HARD_RO; + else + osb->osb_flags |= OCFS2_OSB_SOFT_RO; + spin_unlock(&osb->osb_lock); +} + +static inline int ocfs2_is_hard_readonly(struct ocfs2_super *osb) +{ + int ret; + + spin_lock(&osb->osb_lock); + ret = osb->osb_flags & OCFS2_OSB_HARD_RO; + spin_unlock(&osb->osb_lock); + + return ret; +} + +static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb) +{ + int ret; + + spin_lock(&osb->osb_lock); + ret = osb->osb_flags & OCFS2_OSB_SOFT_RO; + spin_unlock(&osb->osb_lock); + + return ret; +} + +#define OCFS2_IS_VALID_DINODE(ptr) \ + (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE)) + +#define OCFS2_RO_ON_INVALID_DINODE(__sb, __di) do { \ + typeof(__di) ____di = (__di); \ + ocfs2_error((__sb), \ + "Dinode # %"MLFu64" has bad signature %.*s", \ + (____di)->i_blkno, 7, \ + (____di)->i_signature); \ +} while (0); + +#define OCFS2_IS_VALID_EXTENT_BLOCK(ptr) \ + (!strcmp((ptr)->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE)) + +#define OCFS2_RO_ON_INVALID_EXTENT_BLOCK(__sb, __eb) do { \ + typeof(__eb) ____eb = (__eb); \ + ocfs2_error((__sb), \ + "Extent Block # %"MLFu64" has bad signature %.*s", \ + (____eb)->h_blkno, 7, \ + (____eb)->h_signature); \ +} while (0); + +#define OCFS2_IS_VALID_GROUP_DESC(ptr) \ + (!strcmp((ptr)->bg_signature, OCFS2_GROUP_DESC_SIGNATURE)) + +#define OCFS2_RO_ON_INVALID_GROUP_DESC(__sb, __gd) do { \ + typeof(__gd) ____gd = (__gd); \ + ocfs2_error((__sb), \ + "Group Descriptor # %"MLFu64" has bad signature %.*s", \ + (____gd)->bg_blkno, 7, \ + (____gd)->bg_signature); \ +} while (0); + +static inline unsigned long ino_from_blkno(struct super_block *sb, + u64 blkno) +{ + return (unsigned long)(blkno & (u64)ULONG_MAX); +} + +static inline u64 ocfs2_clusters_to_blocks(struct super_block *sb, + u32 clusters) +{ + int c_to_b_bits = OCFS2_SB(sb)->s_clustersize_bits - + sb->s_blocksize_bits; + + return (u64)clusters << c_to_b_bits; +} + +static inline u32 ocfs2_blocks_to_clusters(struct super_block *sb, + u64 blocks) +{ + int b_to_c_bits = OCFS2_SB(sb)->s_clustersize_bits - + sb->s_blocksize_bits; + + return (u32)(blocks >> b_to_c_bits); +} + +static inline unsigned int ocfs2_clusters_for_bytes(struct super_block *sb, + u64 bytes) +{ + int cl_bits = OCFS2_SB(sb)->s_clustersize_bits; + unsigned int clusters; + + bytes += OCFS2_SB(sb)->s_clustersize - 1; + /* OCFS2 just cannot have enough clusters to overflow this */ + clusters = (unsigned int)(bytes >> cl_bits); + + return clusters; +} + +static inline u64 ocfs2_blocks_for_bytes(struct super_block *sb, + u64 bytes) +{ + bytes += sb->s_blocksize - 1; + return bytes >> sb->s_blocksize_bits; +} + +static inline u64 ocfs2_clusters_to_bytes(struct super_block *sb, + u32 clusters) +{ + return (u64)clusters << OCFS2_SB(sb)->s_clustersize_bits; +} + +static inline u64 ocfs2_align_bytes_to_clusters(struct super_block *sb, + u64 bytes) +{ + int cl_bits = OCFS2_SB(sb)->s_clustersize_bits; + unsigned int clusters; + + clusters = ocfs2_clusters_for_bytes(sb, bytes); + return (u64)clusters << cl_bits; +} + +static inline u64 ocfs2_align_bytes_to_blocks(struct super_block *sb, + u64 bytes) +{ + u64 blocks; + + blocks = ocfs2_blocks_for_bytes(sb, bytes); + return blocks << sb->s_blocksize_bits; +} + +static inline unsigned long ocfs2_align_bytes_to_sectors(u64 bytes) +{ + return (unsigned long)((bytes + 511) >> 9); +} + +#define ocfs2_set_bit ext2_set_bit +#define ocfs2_clear_bit ext2_clear_bit +#define ocfs2_test_bit ext2_test_bit +#define ocfs2_find_next_zero_bit ext2_find_next_zero_bit +#endif /* OCFS2_H */ + diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h new file mode 100644 index 0000000..dfb8a5b --- /dev/null +++ b/fs/ocfs2/ocfs2_fs.h @@ -0,0 +1,638 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ocfs2_fs.h + * + * On-disk structures for OCFS2. + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef _OCFS2_FS_H +#define _OCFS2_FS_H + +/* Version */ +#define OCFS2_MAJOR_REV_LEVEL 0 +#define OCFS2_MINOR_REV_LEVEL 90 + +/* + * An OCFS2 volume starts this way: + * Sector 0: Valid ocfs1_vol_disk_hdr that cleanly fails to mount OCFS. + * Sector 1: Valid ocfs1_vol_label that cleanly fails to mount OCFS. + * Block OCFS2_SUPER_BLOCK_BLKNO: OCFS2 superblock. + * + * All other structures are found from the superblock information. + * + * OCFS2_SUPER_BLOCK_BLKNO is in blocks, not sectors. eg, for a + * blocksize of 2K, it is 4096 bytes into disk. + */ +#define OCFS2_SUPER_BLOCK_BLKNO 2 + +/* + * Cluster size limits. The maximum is kept arbitrarily at 1 MB, and could + * grow if needed. + */ +#define OCFS2_MIN_CLUSTERSIZE 4096 +#define OCFS2_MAX_CLUSTERSIZE 1048576 + +/* + * Blocks cannot be bigger than clusters, so the maximum blocksize is the + * minimum cluster size. + */ +#define OCFS2_MIN_BLOCKSIZE 512 +#define OCFS2_MAX_BLOCKSIZE OCFS2_MIN_CLUSTERSIZE + +/* Filesystem magic number */ +#define OCFS2_SUPER_MAGIC 0x7461636f + +/* Object signatures */ +#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2" +#define OCFS2_INODE_SIGNATURE "INODE01" +#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01" +#define OCFS2_GROUP_DESC_SIGNATURE "GROUP01" + +/* Compatibility flags */ +#define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \ + ( OCFS2_SB(sb)->s_feature_compat & (mask) ) +#define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \ + ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) ) +#define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \ + ( OCFS2_SB(sb)->s_feature_incompat & (mask) ) +#define OCFS2_SET_COMPAT_FEATURE(sb,mask) \ + OCFS2_SB(sb)->s_feature_compat |= (mask) +#define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \ + OCFS2_SB(sb)->s_feature_ro_compat |= (mask) +#define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \ + OCFS2_SB(sb)->s_feature_incompat |= (mask) +#define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \ + OCFS2_SB(sb)->s_feature_compat &= ~(mask) +#define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \ + OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask) +#define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \ + OCFS2_SB(sb)->s_feature_incompat &= ~(mask) + +#define OCFS2_FEATURE_COMPAT_SUPP 0 +#define OCFS2_FEATURE_INCOMPAT_SUPP 0 +#define OCFS2_FEATURE_RO_COMPAT_SUPP 0 + +/* + * Heartbeat-only devices are missing journals and other files. The + * filesystem driver can't load them, but the library can. Never put + * this in OCFS2_FEATURE_INCOMPAT_SUPP, *ever*. + */ +#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002 + + +/* + * Flags on ocfs2_dinode.i_flags + */ +#define OCFS2_VALID_FL (0x00000001) /* Inode is valid */ +#define OCFS2_UNUSED2_FL (0x00000002) +#define OCFS2_ORPHANED_FL (0x00000004) /* On the orphan list */ +#define OCFS2_UNUSED3_FL (0x00000008) +/* System inode flags */ +#define OCFS2_SYSTEM_FL (0x00000010) /* System inode */ +#define OCFS2_SUPER_BLOCK_FL (0x00000020) /* Super block */ +#define OCFS2_LOCAL_ALLOC_FL (0x00000040) /* Slot local alloc bitmap */ +#define OCFS2_BITMAP_FL (0x00000080) /* Allocation bitmap */ +#define OCFS2_JOURNAL_FL (0x00000100) /* Slot local journal */ +#define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */ +#define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */ +#define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */ + +/* + * Journal Flags (ocfs2_dinode.id1.journal1.i_flags) + */ +#define OCFS2_JOURNAL_DIRTY_FL (0x00000001) /* Journal needs recovery */ + +/* + * superblock s_state flags + */ +#define OCFS2_ERROR_FS (0x00000001) /* FS saw errors */ + +/* Limit of space in ocfs2_dir_entry */ +#define OCFS2_MAX_FILENAME_LEN 255 + +/* Maximum slots on an ocfs2 file system */ +#define OCFS2_MAX_SLOTS 255 + +/* Slot map indicator for an empty slot */ +#define OCFS2_INVALID_SLOT -1 + +#define OCFS2_VOL_UUID_LEN 16 +#define OCFS2_MAX_VOL_LABEL_LEN 64 + +/* Journal limits (in bytes) */ +#define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) +#define OCFS2_MAX_JOURNAL_SIZE (500 * 1024 * 1024) + +struct ocfs2_system_inode_info { + char *si_name; + int si_iflags; + int si_mode; +}; + +/* System file index */ +enum { + BAD_BLOCK_SYSTEM_INODE = 0, + GLOBAL_INODE_ALLOC_SYSTEM_INODE, + SLOT_MAP_SYSTEM_INODE, +#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE + HEARTBEAT_SYSTEM_INODE, + GLOBAL_BITMAP_SYSTEM_INODE, +#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE + ORPHAN_DIR_SYSTEM_INODE, + EXTENT_ALLOC_SYSTEM_INODE, + INODE_ALLOC_SYSTEM_INODE, + JOURNAL_SYSTEM_INODE, + LOCAL_ALLOC_SYSTEM_INODE, + TRUNCATE_LOG_SYSTEM_INODE, + NUM_SYSTEM_INODES +}; + +static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = { + /* Global system inodes (single copy) */ + /* The first two are only used from userspace mfks/tunefs */ + [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 }, + [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, + + /* These are used by the running filesystem */ + [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 }, + [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 }, + [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 }, + + /* Slot-specific system inodes (one copy per slot) */ + [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 }, + [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, + [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 }, + [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 }, + [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 }, + [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 } +}; + +/* Parameter passed from mount.ocfs2 to module */ +#define OCFS2_HB_NONE "heartbeat=none" +#define OCFS2_HB_LOCAL "heartbeat=local" + +/* + * OCFS2 directory file types. Only the low 3 bits are used. The + * other bits are reserved for now. + */ +#define OCFS2_FT_UNKNOWN 0 +#define OCFS2_FT_REG_FILE 1 +#define OCFS2_FT_DIR 2 +#define OCFS2_FT_CHRDEV 3 +#define OCFS2_FT_BLKDEV 4 +#define OCFS2_FT_FIFO 5 +#define OCFS2_FT_SOCK 6 +#define OCFS2_FT_SYMLINK 7 + +#define OCFS2_FT_MAX 8 + +/* + * OCFS2_DIR_PAD defines the directory entries boundaries + * + * NOTE: It must be a multiple of 4 + */ +#define OCFS2_DIR_PAD 4 +#define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1) +#define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name) +#define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \ + OCFS2_DIR_ROUND) & \ + ~OCFS2_DIR_ROUND) + +#define OCFS2_LINK_MAX 32000 + +#define S_SHIFT 12 +static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = { + [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE, + [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR, + [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV, + [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV, + [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO, + [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK, + [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK, +}; + + +/* + * Convenience casts + */ +#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super)) + +/* + * On disk extent record for OCFS2 + * It describes a range of clusters on disk. + */ +struct ocfs2_extent_rec { +/*00*/ __le32 e_cpos; /* Offset into the file, in clusters */ + __le32 e_clusters; /* Clusters covered by this extent */ + __le64 e_blkno; /* Physical disk offset, in blocks */ +/*10*/ +}; + +struct ocfs2_chain_rec { + __le32 c_free; /* Number of free bits in this chain. */ + __le32 c_total; /* Number of total bits in this chain */ + __le64 c_blkno; /* Physical disk offset (blocks) of 1st group */ +}; + +struct ocfs2_truncate_rec { + __le32 t_start; /* 1st cluster in this log */ + __le32 t_clusters; /* Number of total clusters covered */ +}; + +/* + * On disk extent list for OCFS2 (node in the tree). Note that this + * is contained inside ocfs2_dinode or ocfs2_extent_block, so the + * offsets are relative to ocfs2_dinode.id2.i_list or + * ocfs2_extent_block.h_list, respectively. + */ +struct ocfs2_extent_list { +/*00*/ __le16 l_tree_depth; /* Extent tree depth from this + point. 0 means data extents + hang directly off this + header (a leaf) */ + __le16 l_count; /* Number of extent records */ + __le16 l_next_free_rec; /* Next unused extent slot */ + __le16 l_reserved1; + __le64 l_reserved2; /* Pad to + sizeof(ocfs2_extent_rec) */ +/*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */ +}; + +/* + * On disk allocation chain list for OCFS2. Note that this is + * contained inside ocfs2_dinode, so the offsets are relative to + * ocfs2_dinode.id2.i_chain. + */ +struct ocfs2_chain_list { +/*00*/ __le16 cl_cpg; /* Clusters per Block Group */ + __le16 cl_bpc; /* Bits per cluster */ + __le16 cl_count; /* Total chains in this list */ + __le16 cl_next_free_rec; /* Next unused chain slot */ + __le64 cl_reserved1; +/*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */ +}; + +/* + * On disk deallocation log for OCFS2. Note that this is + * contained inside ocfs2_dinode, so the offsets are relative to + * ocfs2_dinode.id2.i_dealloc. + */ +struct ocfs2_truncate_log { +/*00*/ __le16 tl_count; /* Total records in this log */ + __le16 tl_used; /* Number of records in use */ + __le32 tl_reserved1; +/*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */ +}; + +/* + * On disk extent block (indirect block) for OCFS2 + */ +struct ocfs2_extent_block +{ +/*00*/ __u8 h_signature[8]; /* Signature for verification */ + __le64 h_reserved1; +/*10*/ __le16 h_suballoc_slot; /* Slot suballocator this + extent_header belongs to */ + __le16 h_suballoc_bit; /* Bit offset in suballocator + block group */ + __le32 h_fs_generation; /* Must match super block */ + __le64 h_blkno; /* Offset on disk, in blocks */ +/*20*/ __le64 h_reserved3; + __le64 h_next_leaf_blk; /* Offset on disk, in blocks, + of next leaf header pointing + to data */ +/*30*/ struct ocfs2_extent_list h_list; /* Extent record list */ +/* Actual on-disk size is one block */ +}; + +/* + * On disk superblock for OCFS2 + * Note that it is contained inside an ocfs2_dinode, so all offsets + * are relative to the start of ocfs2_dinode.id2. + */ +struct ocfs2_super_block { +/*00*/ __le16 s_major_rev_level; + __le16 s_minor_rev_level; + __le16 s_mnt_count; + __le16 s_max_mnt_count; + __le16 s_state; /* File system state */ + __le16 s_errors; /* Behaviour when detecting errors */ + __le32 s_checkinterval; /* Max time between checks */ +/*10*/ __le64 s_lastcheck; /* Time of last check */ + __le32 s_creator_os; /* OS */ + __le32 s_feature_compat; /* Compatible feature set */ +/*20*/ __le32 s_feature_incompat; /* Incompatible feature set */ + __le32 s_feature_ro_compat; /* Readonly-compatible feature set */ + __le64 s_root_blkno; /* Offset, in blocks, of root directory + dinode */ +/*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system + directory dinode */ + __le32 s_blocksize_bits; /* Blocksize for this fs */ + __le32 s_clustersize_bits; /* Clustersize for this fs */ +/*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts + before tunefs required */ + __le16 s_reserved1; + __le32 s_reserved2; + __le64 s_first_cluster_group; /* Block offset of 1st cluster + * group header */ +/*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. */ +/*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid */ +/*A0*/ +}; + +/* + * Local allocation bitmap for OCFS2 slots + * Note that it exists inside an ocfs2_dinode, so all offsets are + * relative to the start of ocfs2_dinode.id2. + */ +struct ocfs2_local_alloc +{ +/*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */ + __le16 la_size; /* Size of included bitmap, in bytes */ + __le16 la_reserved1; + __le64 la_reserved2; +/*10*/ __u8 la_bitmap[0]; +}; + +/* + * On disk inode for OCFS2 + */ +struct ocfs2_dinode { +/*00*/ __u8 i_signature[8]; /* Signature for validation */ + __le32 i_generation; /* Generation number */ + __le16 i_suballoc_slot; /* Slot suballocator this inode + belongs to */ + __le16 i_suballoc_bit; /* Bit offset in suballocator + block group */ +/*10*/ __le32 i_reserved0; + __le32 i_clusters; /* Cluster count */ + __le32 i_uid; /* Owner UID */ + __le32 i_gid; /* Owning GID */ +/*20*/ __le64 i_size; /* Size in bytes */ + __le16 i_mode; /* File mode */ + __le16 i_links_count; /* Links count */ + __le32 i_flags; /* File flags */ +/*30*/ __le64 i_atime; /* Access time */ + __le64 i_ctime; /* Creation time */ +/*40*/ __le64 i_mtime; /* Modification time */ + __le64 i_dtime; /* Deletion time */ +/*50*/ __le64 i_blkno; /* Offset on disk, in blocks */ + __le64 i_last_eb_blk; /* Pointer to last extent + block */ +/*60*/ __le32 i_fs_generation; /* Generation per fs-instance */ + __le32 i_atime_nsec; + __le32 i_ctime_nsec; + __le32 i_mtime_nsec; +/*70*/ __le64 i_reserved1[9]; +/*B8*/ union { + __le64 i_pad1; /* Generic way to refer to this + 64bit union */ + struct { + __le64 i_rdev; /* Device number */ + } dev1; + struct { /* Info for bitmap system + inodes */ + __le32 i_used; /* Bits (ie, clusters) used */ + __le32 i_total; /* Total bits (clusters) + available */ + } bitmap1; + struct { /* Info for journal system + inodes */ + __le32 ij_flags; /* Mounted, version, etc. */ + __le32 ij_pad; + } journal1; + } id1; /* Inode type dependant 1 */ +/*C0*/ union { + struct ocfs2_super_block i_super; + struct ocfs2_local_alloc i_lab; + struct ocfs2_chain_list i_chain; + struct ocfs2_extent_list i_list; + struct ocfs2_truncate_log i_dealloc; + __u8 i_symlink[0]; + } id2; +/* Actual on-disk size is one block */ +}; + +/* + * On-disk directory entry structure for OCFS2 + * + * Packed as this structure could be accessed unaligned on 64-bit platforms + */ +struct ocfs2_dir_entry { +/*00*/ __le64 inode; /* Inode number */ + __le16 rec_len; /* Directory entry length */ + __u8 name_len; /* Name length */ + __u8 file_type; +/*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name */ +/* Actual on-disk length specified by rec_len */ +} __attribute__ ((packed)); + +/* + * On disk allocator group structure for OCFS2 + */ +struct ocfs2_group_desc +{ +/*00*/ __u8 bg_signature[8]; /* Signature for validation */ + __le16 bg_size; /* Size of included bitmap in + bytes. */ + __le16 bg_bits; /* Bits represented by this + group. */ + __le16 bg_free_bits_count; /* Free bits count */ + __le16 bg_chain; /* What chain I am in. */ +/*10*/ __le32 bg_generation; + __le32 bg_reserved1; + __le64 bg_next_group; /* Next group in my list, in + blocks */ +/*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in + blocks */ + __le64 bg_blkno; /* Offset on disk, in blocks */ +/*30*/ __le64 bg_reserved2[2]; +/*40*/ __u8 bg_bitmap[0]; +}; + +#ifdef __KERNEL__ +static inline int ocfs2_fast_symlink_chars(struct super_block *sb) +{ + return sb->s_blocksize - + offsetof(struct ocfs2_dinode, id2.i_symlink); +} + +static inline int ocfs2_extent_recs_per_inode(struct super_block *sb) +{ + int size; + + size = sb->s_blocksize - + offsetof(struct ocfs2_dinode, id2.i_list.l_recs); + + return size / sizeof(struct ocfs2_extent_rec); +} + +static inline int ocfs2_chain_recs_per_inode(struct super_block *sb) +{ + int size; + + size = sb->s_blocksize - + offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); + + return size / sizeof(struct ocfs2_chain_rec); +} + +static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb) +{ + int size; + + size = sb->s_blocksize - + offsetof(struct ocfs2_extent_block, h_list.l_recs); + + return size / sizeof(struct ocfs2_extent_rec); +} + +static inline u16 ocfs2_local_alloc_size(struct super_block *sb) +{ + u16 size; + + size = sb->s_blocksize - + offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); + + return size; +} + +static inline int ocfs2_group_bitmap_size(struct super_block *sb) +{ + int size; + + size = sb->s_blocksize - + offsetof(struct ocfs2_group_desc, bg_bitmap); + + return size; +} + +static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb) +{ + int size; + + size = sb->s_blocksize - + offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); + + return size / sizeof(struct ocfs2_truncate_rec); +} +#else +static inline int ocfs2_fast_symlink_chars(int blocksize) +{ + return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink); +} + +static inline int ocfs2_extent_recs_per_inode(int blocksize) +{ + int size; + + size = blocksize - + offsetof(struct ocfs2_dinode, id2.i_list.l_recs); + + return size / sizeof(struct ocfs2_extent_rec); +} + +static inline int ocfs2_chain_recs_per_inode(int blocksize) +{ + int size; + + size = blocksize - + offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); + + return size / sizeof(struct ocfs2_chain_rec); +} + +static inline int ocfs2_extent_recs_per_eb(int blocksize) +{ + int size; + + size = blocksize - + offsetof(struct ocfs2_extent_block, h_list.l_recs); + + return size / sizeof(struct ocfs2_extent_rec); +} + +static inline int ocfs2_local_alloc_size(int blocksize) +{ + int size; + + size = blocksize - + offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); + + return size; +} + +static inline int ocfs2_group_bitmap_size(int blocksize) +{ + int size; + + size = blocksize - + offsetof(struct ocfs2_group_desc, bg_bitmap); + + return size; +} + +static inline int ocfs2_truncate_recs_per_inode(int blocksize) +{ + int size; + + size = blocksize - + offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); + + return size / sizeof(struct ocfs2_truncate_rec); +} +#endif /* __KERNEL__ */ + + +static inline int ocfs2_system_inode_is_global(int type) +{ + return ((type >= 0) && + (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)); +} + +static inline int ocfs2_sprintf_system_inode_name(char *buf, int len, + int type, int slot) +{ + int chars; + + /* + * Global system inodes can only have one copy. Everything + * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode + * list has a copy per slot. + */ + if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE) + chars = snprintf(buf, len, + ocfs2_system_inodes[type].si_name); + else + chars = snprintf(buf, len, + ocfs2_system_inodes[type].si_name, + slot); + + return chars; +} + +static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de, + umode_t mode) +{ + de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; +} + +#endif /* _OCFS2_FS_H */ + diff --git a/fs/ocfs2/ocfs2_lockid.h b/fs/ocfs2/ocfs2_lockid.h new file mode 100644 index 0000000..7dd9e1e --- /dev/null +++ b/fs/ocfs2/ocfs2_lockid.h @@ -0,0 +1,73 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ocfs2_lockid.h + * + * Defines OCFS2 lockid bits. + * + * Copyright (C) 2002, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_LOCKID_H +#define OCFS2_LOCKID_H + +/* lock ids are made up in the following manner: + * name[0] --> type + * name[1-6] --> 6 pad characters, reserved for now + * name[7-22] --> block number, expressed in hex as 16 chars + * name[23-30] --> i_generation, expressed in hex 8 chars + * name[31] --> '\0' */ +#define OCFS2_LOCK_ID_MAX_LEN 32 +#define OCFS2_LOCK_ID_PAD "000000" + +enum ocfs2_lock_type { + OCFS2_LOCK_TYPE_META = 0, + OCFS2_LOCK_TYPE_DATA, + OCFS2_LOCK_TYPE_SUPER, + OCFS2_LOCK_TYPE_RENAME, + OCFS2_LOCK_TYPE_RW, + OCFS2_NUM_LOCK_TYPES +}; + +static inline char ocfs2_lock_type_char(enum ocfs2_lock_type type) +{ + char c; + switch (type) { + case OCFS2_LOCK_TYPE_META: + c = 'M'; + break; + case OCFS2_LOCK_TYPE_DATA: + c = 'D'; + break; + case OCFS2_LOCK_TYPE_SUPER: + c = 'S'; + break; + case OCFS2_LOCK_TYPE_RENAME: + c = 'R'; + break; + case OCFS2_LOCK_TYPE_RW: + c = 'W'; + break; + default: + c = '\0'; + } + + return c; +} + +#endif /* OCFS2_LOCKID_H */ diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c new file mode 100644 index 0000000..8716279 --- /dev/null +++ b/fs/ocfs2/slot_map.c @@ -0,0 +1,303 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * slot_map.c + * + * + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_SUPER +#include + +#include "ocfs2.h" + +#include "dlmglue.h" +#include "extent_map.h" +#include "heartbeat.h" +#include "inode.h" +#include "slot_map.h" +#include "super.h" +#include "sysfile.h" + +#include "buffer_head_io.h" + +static s16 __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si, + s16 global); +static void __ocfs2_fill_slot(struct ocfs2_slot_info *si, + s16 slot_num, + s16 node_num); + +/* Use the slot information we've collected to create a map of mounted + * nodes. Should be holding an EX on super block. assumes slot info is + * up to date. Note that we call this *after* we find a slot, so our + * own node should be set in the map too... */ +void ocfs2_populate_mounted_map(struct ocfs2_super *osb) +{ + int i; + struct ocfs2_slot_info *si = osb->slot_info; + + spin_lock(&si->si_lock); + + for (i = 0; i < si->si_size; i++) + if (si->si_global_node_nums[i] != OCFS2_INVALID_SLOT) + ocfs2_node_map_set_bit(osb, &osb->mounted_map, + si->si_global_node_nums[i]); + + spin_unlock(&si->si_lock); +} + +/* post the slot information on disk into our slot_info struct. */ +void ocfs2_update_slot_info(struct ocfs2_slot_info *si) +{ + int i; + __le16 *disk_info; + + /* we don't read the slot block here as ocfs2_super_lock + * should've made sure we have the most recent copy. */ + spin_lock(&si->si_lock); + disk_info = (__le16 *) si->si_bh->b_data; + + for (i = 0; i < si->si_size; i++) + si->si_global_node_nums[i] = le16_to_cpu(disk_info[i]); + + spin_unlock(&si->si_lock); +} + +/* post the our slot info stuff into it's destination bh and write it + * out. */ +int ocfs2_update_disk_slots(struct ocfs2_super *osb, + struct ocfs2_slot_info *si) +{ + int status, i; + __le16 *disk_info = (__le16 *) si->si_bh->b_data; + + spin_lock(&si->si_lock); + for (i = 0; i < si->si_size; i++) + disk_info[i] = cpu_to_le16(si->si_global_node_nums[i]); + spin_unlock(&si->si_lock); + + status = ocfs2_write_block(osb, si->si_bh, si->si_inode); + if (status < 0) + mlog_errno(status); + + return status; +} + +/* try to find global node in the slot info. Returns + * OCFS2_INVALID_SLOT if nothing is found. */ +static s16 __ocfs2_node_num_to_slot(struct ocfs2_slot_info *si, + s16 global) +{ + int i; + s16 ret = OCFS2_INVALID_SLOT; + + for(i = 0; i < si->si_num_slots; i++) { + if (global == si->si_global_node_nums[i]) { + ret = (s16) i; + break; + } + } + return ret; +} + +static s16 __ocfs2_find_empty_slot(struct ocfs2_slot_info *si) +{ + int i; + s16 ret = OCFS2_INVALID_SLOT; + + for(i = 0; i < si->si_num_slots; i++) { + if (OCFS2_INVALID_SLOT == si->si_global_node_nums[i]) { + ret = (s16) i; + break; + } + } + return ret; +} + +s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si, + s16 global) +{ + s16 ret; + + spin_lock(&si->si_lock); + ret = __ocfs2_node_num_to_slot(si, global); + spin_unlock(&si->si_lock); + return ret; +} + +static void __ocfs2_fill_slot(struct ocfs2_slot_info *si, + s16 slot_num, + s16 node_num) +{ + BUG_ON(slot_num == OCFS2_INVALID_SLOT); + BUG_ON(slot_num >= si->si_num_slots); + BUG_ON((node_num != O2NM_INVALID_NODE_NUM) && + (node_num >= O2NM_MAX_NODES)); + + si->si_global_node_nums[slot_num] = node_num; +} + +void ocfs2_clear_slot(struct ocfs2_slot_info *si, + s16 slot_num) +{ + spin_lock(&si->si_lock); + __ocfs2_fill_slot(si, slot_num, OCFS2_INVALID_SLOT); + spin_unlock(&si->si_lock); +} + +int ocfs2_init_slot_info(struct ocfs2_super *osb) +{ + int status, i; + u64 blkno; + struct inode *inode = NULL; + struct buffer_head *bh = NULL; + struct ocfs2_slot_info *si; + + si = kcalloc(1, sizeof(struct ocfs2_slot_info), GFP_KERNEL); + if (!si) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + spin_lock_init(&si->si_lock); + si->si_num_slots = osb->max_slots; + si->si_size = OCFS2_MAX_SLOTS; + + for(i = 0; i < si->si_num_slots; i++) + si->si_global_node_nums[i] = OCFS2_INVALID_SLOT; + + inode = ocfs2_get_system_file_inode(osb, SLOT_MAP_SYSTEM_INODE, + OCFS2_INVALID_SLOT); + if (!inode) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + status = ocfs2_extent_map_get_blocks(inode, 0ULL, 1, &blkno, NULL); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_read_block(osb, blkno, &bh, 0, inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + si->si_inode = inode; + si->si_bh = bh; + osb->slot_info = si; +bail: + if (status < 0 && si) + ocfs2_free_slot_info(si); + + return status; +} + +void ocfs2_free_slot_info(struct ocfs2_slot_info *si) +{ + if (si->si_inode) + iput(si->si_inode); + if (si->si_bh) + brelse(si->si_bh); + kfree(si); +} + +int ocfs2_find_slot(struct ocfs2_super *osb) +{ + int status; + s16 slot; + struct ocfs2_slot_info *si; + + mlog_entry_void(); + + si = osb->slot_info; + + ocfs2_update_slot_info(si); + + spin_lock(&si->si_lock); + /* search for ourselves first and take the slot if it already + * exists. Perhaps we need to mark this in a variable for our + * own journal recovery? Possibly not, though we certainly + * need to warn to the user */ + slot = __ocfs2_node_num_to_slot(si, osb->node_num); + if (slot == OCFS2_INVALID_SLOT) { + /* if no slot yet, then just take 1st available + * one. */ + slot = __ocfs2_find_empty_slot(si); + if (slot == OCFS2_INVALID_SLOT) { + spin_unlock(&si->si_lock); + mlog(ML_ERROR, "no free slots available!\n"); + status = -EINVAL; + goto bail; + } + } else + mlog(ML_NOTICE, "slot %d is already allocated to this node!\n", + slot); + + __ocfs2_fill_slot(si, slot, osb->node_num); + osb->slot_num = slot; + spin_unlock(&si->si_lock); + + mlog(ML_NOTICE, "taking node slot %d\n", osb->slot_num); + + status = ocfs2_update_disk_slots(osb, si); + if (status < 0) + mlog_errno(status); + +bail: + mlog_exit(status); + return status; +} + +void ocfs2_put_slot(struct ocfs2_super *osb) +{ + int status; + struct ocfs2_slot_info *si = osb->slot_info; + + if (!si) + return; + + ocfs2_update_slot_info(si); + + spin_lock(&si->si_lock); + __ocfs2_fill_slot(si, osb->slot_num, OCFS2_INVALID_SLOT); + osb->slot_num = OCFS2_INVALID_SLOT; + spin_unlock(&si->si_lock); + + status = ocfs2_update_disk_slots(osb, si); + if (status < 0) { + mlog_errno(status); + goto bail; + } + +bail: + osb->slot_info = NULL; + ocfs2_free_slot_info(si); +} + diff --git a/fs/ocfs2/slot_map.h b/fs/ocfs2/slot_map.h new file mode 100644 index 0000000..d8c8cee --- /dev/null +++ b/fs/ocfs2/slot_map.h @@ -0,0 +1,66 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * slotmap.h + * + * description here + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + + +#ifndef SLOTMAP_H +#define SLOTMAP_H + +struct ocfs2_slot_info { + spinlock_t si_lock; + + struct inode *si_inode; + struct buffer_head *si_bh; + unsigned int si_num_slots; + unsigned int si_size; + s16 si_global_node_nums[OCFS2_MAX_SLOTS]; +}; + +int ocfs2_init_slot_info(struct ocfs2_super *osb); +void ocfs2_free_slot_info(struct ocfs2_slot_info *si); + +int ocfs2_find_slot(struct ocfs2_super *osb); +void ocfs2_put_slot(struct ocfs2_super *osb); + +void ocfs2_update_slot_info(struct ocfs2_slot_info *si); +int ocfs2_update_disk_slots(struct ocfs2_super *osb, + struct ocfs2_slot_info *si); + +s16 ocfs2_node_num_to_slot(struct ocfs2_slot_info *si, + s16 global); +void ocfs2_clear_slot(struct ocfs2_slot_info *si, + s16 slot_num); + +void ocfs2_populate_mounted_map(struct ocfs2_super *osb); + +static inline int ocfs2_is_empty_slot(struct ocfs2_slot_info *si, + int slot_num) +{ + BUG_ON(slot_num == OCFS2_INVALID_SLOT); + assert_spin_locked(&si->si_lock); + + return si->si_global_node_nums[slot_num] == OCFS2_INVALID_SLOT; +} + +#endif diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c new file mode 100644 index 0000000..c46c164 --- /dev/null +++ b/fs/ocfs2/suballoc.c @@ -0,0 +1,1651 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * suballoc.c + * + * metadata alloc and free + * Inspired by ext3 block groups. + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_DISK_ALLOC +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dlmglue.h" +#include "inode.h" +#include "journal.h" +#include "localalloc.h" +#include "suballoc.h" +#include "super.h" +#include "sysfile.h" +#include "uptodate.h" + +#include "buffer_head_io.h" + +static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); +static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); +static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl); +static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct buffer_head *bg_bh, + u64 group_blkno, + u16 my_chain, + struct ocfs2_chain_list *cl); +static int ocfs2_block_group_alloc(struct ocfs2_super *osb, + struct inode *alloc_inode, + struct buffer_head *bh); + +static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, + struct ocfs2_alloc_context *ac); + +static int ocfs2_cluster_group_search(struct inode *inode, + struct buffer_head *group_bh, + u32 bits_wanted, u32 min_bits, + u16 *bit_off, u16 *bits_found); +static int ocfs2_block_group_search(struct inode *inode, + struct buffer_head *group_bh, + u32 bits_wanted, u32 min_bits, + u16 *bit_off, u16 *bits_found); +static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, + u32 bits_wanted, + u32 min_bits, + u16 *bit_off, + unsigned int *num_bits, + u64 *bg_blkno); +static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, + struct ocfs2_alloc_context *ac, + u32 bits_wanted, + u32 min_bits, + u16 *bit_off, + unsigned int *num_bits, + u64 *bg_blkno); +static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, + int nr); +static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb, + struct buffer_head *bg_bh, + unsigned int bits_wanted, + u16 *bit_off, + u16 *bits_found); +static inline int ocfs2_block_group_set_bits(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct ocfs2_group_desc *bg, + struct buffer_head *group_bh, + unsigned int bit_off, + unsigned int num_bits); +static inline int ocfs2_block_group_clear_bits(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct ocfs2_group_desc *bg, + struct buffer_head *group_bh, + unsigned int bit_off, + unsigned int num_bits); + +static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct buffer_head *fe_bh, + struct buffer_head *bg_bh, + struct buffer_head *prev_bg_bh, + u16 chain); +static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg, + u32 wanted); +static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct buffer_head *alloc_bh, + unsigned int start_bit, + u64 bg_blkno, + unsigned int count); +static inline u64 ocfs2_which_suballoc_group(u64 block, + unsigned int bit); +static inline u32 ocfs2_desc_bitmap_to_cluster_off(struct inode *inode, + u64 bg_blkno, + u16 bg_bit_off); +static inline u64 ocfs2_which_cluster_group(struct inode *inode, + u32 cluster); +static inline void ocfs2_block_to_cluster_group(struct inode *inode, + u64 data_blkno, + u64 *bg_blkno, + u16 *bg_bit_off); + +void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) +{ + if (ac->ac_inode) + iput(ac->ac_inode); + if (ac->ac_bh) + brelse(ac->ac_bh); + kfree(ac); +} + +static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl) +{ + return (u32)le16_to_cpu(cl->cl_cpg) * (u32)le16_to_cpu(cl->cl_bpc); +} + +static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct buffer_head *bg_bh, + u64 group_blkno, + u16 my_chain, + struct ocfs2_chain_list *cl) +{ + int status = 0; + struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; + struct super_block * sb = alloc_inode->i_sb; + + mlog_entry_void(); + + if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) { + ocfs2_error(alloc_inode->i_sb, "group block (%"MLFu64") " + "!= b_blocknr (%llu)", group_blkno, + (unsigned long long) bg_bh->b_blocknr); + status = -EIO; + goto bail; + } + + status = ocfs2_journal_access(handle, + alloc_inode, + bg_bh, + OCFS2_JOURNAL_ACCESS_CREATE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + memset(bg, 0, sb->s_blocksize); + strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); + bg->bg_generation = cpu_to_le32(OCFS2_SB(sb)->fs_generation); + bg->bg_size = cpu_to_le16(ocfs2_group_bitmap_size(sb)); + bg->bg_bits = cpu_to_le16(ocfs2_bits_per_group(cl)); + bg->bg_chain = cpu_to_le16(my_chain); + bg->bg_next_group = cl->cl_recs[my_chain].c_blkno; + bg->bg_parent_dinode = cpu_to_le64(OCFS2_I(alloc_inode)->ip_blkno); + bg->bg_blkno = cpu_to_le64(group_blkno); + /* set the 1st bit in the bitmap to account for the descriptor block */ + ocfs2_set_bit(0, (unsigned long *)bg->bg_bitmap); + bg->bg_free_bits_count = cpu_to_le16(le16_to_cpu(bg->bg_bits) - 1); + + status = ocfs2_journal_dirty(handle, bg_bh); + if (status < 0) + mlog_errno(status); + + /* There is no need to zero out or otherwise initialize the + * other blocks in a group - All valid FS metadata in a block + * group stores the superblock fs_generation value at + * allocation time. */ + +bail: + mlog_exit(status); + return status; +} + +static inline u16 ocfs2_find_smallest_chain(struct ocfs2_chain_list *cl) +{ + u16 curr, best; + + best = curr = 0; + while (curr < le16_to_cpu(cl->cl_count)) { + if (le32_to_cpu(cl->cl_recs[best].c_total) > + le32_to_cpu(cl->cl_recs[curr].c_total)) + best = curr; + curr++; + } + return best; +} + +/* + * We expect the block group allocator to already be locked. + */ +static int ocfs2_block_group_alloc(struct ocfs2_super *osb, + struct inode *alloc_inode, + struct buffer_head *bh) +{ + int status, credits; + struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; + struct ocfs2_chain_list *cl; + struct ocfs2_alloc_context *ac = NULL; + struct ocfs2_journal_handle *handle = NULL; + u32 bit_off, num_bits; + u16 alloc_rec; + u64 bg_blkno; + struct buffer_head *bg_bh = NULL; + struct ocfs2_group_desc *bg; + + BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode)); + + mlog_entry_void(); + + handle = ocfs2_alloc_handle(osb); + if (!handle) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + cl = &fe->id2.i_chain; + status = ocfs2_reserve_clusters(osb, + handle, + le16_to_cpu(cl->cl_cpg), + &ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + credits = ocfs2_calc_group_alloc_credits(osb->sb, + le16_to_cpu(cl->cl_cpg)); + handle = ocfs2_start_trans(osb, handle, credits); + if (IS_ERR(handle)) { + status = PTR_ERR(handle); + handle = NULL; + mlog_errno(status); + goto bail; + } + + status = ocfs2_claim_clusters(osb, + handle, + ac, + le16_to_cpu(cl->cl_cpg), + &bit_off, + &num_bits); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + alloc_rec = ocfs2_find_smallest_chain(cl); + + /* setup the group */ + bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off); + mlog(0, "new descriptor, record %u, at block %"MLFu64"\n", + alloc_rec, bg_blkno); + + bg_bh = sb_getblk(osb->sb, bg_blkno); + if (!bg_bh) { + status = -EIO; + mlog_errno(status); + goto bail; + } + ocfs2_set_new_buffer_uptodate(alloc_inode, bg_bh); + + status = ocfs2_block_group_fill(handle, + alloc_inode, + bg_bh, + bg_blkno, + alloc_rec, + cl); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + bg = (struct ocfs2_group_desc *) bg_bh->b_data; + + status = ocfs2_journal_access(handle, alloc_inode, + bh, OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + le32_add_cpu(&cl->cl_recs[alloc_rec].c_free, + le16_to_cpu(bg->bg_free_bits_count)); + le32_add_cpu(&cl->cl_recs[alloc_rec].c_total, le16_to_cpu(bg->bg_bits)); + cl->cl_recs[alloc_rec].c_blkno = cpu_to_le64(bg_blkno); + if (le16_to_cpu(cl->cl_next_free_rec) < le16_to_cpu(cl->cl_count)) + le16_add_cpu(&cl->cl_next_free_rec, 1); + + le32_add_cpu(&fe->id1.bitmap1.i_used, le16_to_cpu(bg->bg_bits) - + le16_to_cpu(bg->bg_free_bits_count)); + le32_add_cpu(&fe->id1.bitmap1.i_total, le16_to_cpu(bg->bg_bits)); + le32_add_cpu(&fe->i_clusters, le16_to_cpu(cl->cl_cpg)); + + status = ocfs2_journal_dirty(handle, bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + spin_lock(&OCFS2_I(alloc_inode)->ip_lock); + OCFS2_I(alloc_inode)->ip_clusters = le32_to_cpu(fe->i_clusters); + fe->i_size = cpu_to_le64(ocfs2_clusters_to_bytes(alloc_inode->i_sb, + le32_to_cpu(fe->i_clusters))); + spin_unlock(&OCFS2_I(alloc_inode)->ip_lock); + i_size_write(alloc_inode, le64_to_cpu(fe->i_size)); + alloc_inode->i_blocks = + ocfs2_align_bytes_to_sectors(i_size_read(alloc_inode)); + + status = 0; +bail: + if (handle) + ocfs2_commit_trans(handle); + + if (ac) + ocfs2_free_alloc_context(ac); + + if (bg_bh) + brelse(bg_bh); + + mlog_exit(status); + return status; +} + +static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, + struct ocfs2_alloc_context *ac) +{ + int status; + u32 bits_wanted = ac->ac_bits_wanted; + struct inode *alloc_inode = ac->ac_inode; + struct buffer_head *bh = NULL; + struct ocfs2_journal_handle *handle = ac->ac_handle; + struct ocfs2_dinode *fe; + u32 free_bits; + + mlog_entry_void(); + + BUG_ON(handle->flags & OCFS2_HANDLE_STARTED); + + ocfs2_handle_add_inode(handle, alloc_inode); + status = ocfs2_meta_lock(alloc_inode, handle, &bh, 1); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + fe = (struct ocfs2_dinode *) bh->b_data; + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); + status = -EIO; + goto bail; + } + if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) { + ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator " + "# %"MLFu64, le64_to_cpu(fe->i_blkno)); + status = -EIO; + goto bail; + } + + free_bits = le32_to_cpu(fe->id1.bitmap1.i_total) - + le32_to_cpu(fe->id1.bitmap1.i_used); + + if (bits_wanted > free_bits) { + /* cluster bitmap never grows */ + if (ocfs2_is_cluster_bitmap(alloc_inode)) { + mlog(0, "Disk Full: wanted=%u, free_bits=%u\n", + bits_wanted, free_bits); + status = -ENOSPC; + goto bail; + } + + status = ocfs2_block_group_alloc(osb, alloc_inode, bh); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + atomic_inc(&osb->alloc_stats.bg_extends); + + /* You should never ask for this much metadata */ + BUG_ON(bits_wanted > + (le32_to_cpu(fe->id1.bitmap1.i_total) + - le32_to_cpu(fe->id1.bitmap1.i_used))); + } + + get_bh(bh); + ac->ac_bh = bh; +bail: + if (bh) + brelse(bh); + + mlog_exit(status); + return status; +} + +int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_dinode *fe, + struct ocfs2_alloc_context **ac) +{ + int status; + struct inode *alloc_inode = NULL; + + *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); + if (!(*ac)) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe); + (*ac)->ac_handle = handle; + (*ac)->ac_which = OCFS2_AC_USE_META; + +#ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS + alloc_inode = ocfs2_get_system_file_inode(osb, + EXTENT_ALLOC_SYSTEM_INODE, + 0); +#else + alloc_inode = ocfs2_get_system_file_inode(osb, + EXTENT_ALLOC_SYSTEM_INODE, + osb->slot_num); +#endif + if (!alloc_inode) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + (*ac)->ac_inode = igrab(alloc_inode); + (*ac)->ac_group_search = ocfs2_block_group_search; + + status = ocfs2_reserve_suballoc_bits(osb, (*ac)); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + status = 0; +bail: + if ((status < 0) && *ac) { + ocfs2_free_alloc_context(*ac); + *ac = NULL; + } + + if (alloc_inode) + iput(alloc_inode); + + mlog_exit(status); + return status; +} + +int ocfs2_reserve_new_inode(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context **ac) +{ + int status; + struct inode *alloc_inode = NULL; + + *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); + if (!(*ac)) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + (*ac)->ac_bits_wanted = 1; + (*ac)->ac_handle = handle; + (*ac)->ac_which = OCFS2_AC_USE_INODE; + + alloc_inode = ocfs2_get_system_file_inode(osb, + INODE_ALLOC_SYSTEM_INODE, + osb->slot_num); + if (!alloc_inode) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + (*ac)->ac_inode = igrab(alloc_inode); + (*ac)->ac_group_search = ocfs2_block_group_search; + + status = ocfs2_reserve_suballoc_bits(osb, *ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + status = 0; +bail: + if ((status < 0) && *ac) { + ocfs2_free_alloc_context(*ac); + *ac = NULL; + } + + if (alloc_inode) + iput(alloc_inode); + + mlog_exit(status); + return status; +} + +/* local alloc code has to do the same thing, so rather than do this + * twice.. */ +int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb, + struct ocfs2_alloc_context *ac) +{ + int status; + + ac->ac_inode = ocfs2_get_system_file_inode(osb, + GLOBAL_BITMAP_SYSTEM_INODE, + OCFS2_INVALID_SLOT); + if (!ac->ac_inode) { + status = -EINVAL; + mlog(ML_ERROR, "Could not get bitmap inode!\n"); + goto bail; + } + ac->ac_which = OCFS2_AC_USE_MAIN; + ac->ac_group_search = ocfs2_cluster_group_search; + + status = ocfs2_reserve_suballoc_bits(osb, ac); + if (status < 0 && status != -ENOSPC) + mlog_errno(status); +bail: + return status; +} + +/* Callers don't need to care which bitmap (local alloc or main) to + * use so we figure it out for them, but unfortunately this clutters + * things a bit. */ +int ocfs2_reserve_clusters(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + u32 bits_wanted, + struct ocfs2_alloc_context **ac) +{ + int status; + + mlog_entry_void(); + + BUG_ON(!handle); + + *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); + if (!(*ac)) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + (*ac)->ac_bits_wanted = bits_wanted; + (*ac)->ac_handle = handle; + + status = -ENOSPC; + if (ocfs2_alloc_should_use_local(osb, bits_wanted)) { + status = ocfs2_reserve_local_alloc_bits(osb, + handle, + bits_wanted, + *ac); + if ((status < 0) && (status != -ENOSPC)) { + mlog_errno(status); + goto bail; + } else if (status == -ENOSPC) { + /* reserve_local_bits will return enospc with + * the local alloc inode still locked, so we + * can change this safely here. */ + mlog(0, "Disabling local alloc\n"); + /* We set to OCFS2_LA_DISABLED so that umount + * can clean up what's left of the local + * allocation */ + osb->local_alloc_state = OCFS2_LA_DISABLED; + } + } + + if (status == -ENOSPC) { + status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + } + + status = 0; +bail: + if ((status < 0) && *ac) { + ocfs2_free_alloc_context(*ac); + *ac = NULL; + } + + mlog_exit(status); + return status; +} + +/* + * More or less lifted from ext3. I'll leave their description below: + * + * "For ext3 allocations, we must not reuse any blocks which are + * allocated in the bitmap buffer's "last committed data" copy. This + * prevents deletes from freeing up the page for reuse until we have + * committed the delete transaction. + * + * If we didn't do this, then deleting something and reallocating it as + * data would allow the old block to be overwritten before the + * transaction committed (because we force data to disk before commit). + * This would lead to corruption if we crashed between overwriting the + * data and committing the delete. + * + * @@@ We may want to make this allocation behaviour conditional on + * data-writes at some point, and disable it for metadata allocations or + * sync-data inodes." + * + * Note: OCFS2 already does this differently for metadata vs data + * allocations, as those bitmaps are seperate and undo access is never + * called on a metadata group descriptor. + */ +static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, + int nr) +{ + struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; + + if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap)) + return 0; + if (!buffer_jbd(bg_bh) || !bh2jh(bg_bh)->b_committed_data) + return 1; + + bg = (struct ocfs2_group_desc *) bh2jh(bg_bh)->b_committed_data; + return !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap); +} + +static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb, + struct buffer_head *bg_bh, + unsigned int bits_wanted, + u16 *bit_off, + u16 *bits_found) +{ + void *bitmap; + u16 best_offset, best_size; + int offset, start, found, status = 0; + struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; + + if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { + OCFS2_RO_ON_INVALID_GROUP_DESC(osb->sb, bg); + return -EIO; + } + + found = start = best_offset = best_size = 0; + bitmap = bg->bg_bitmap; + + while((offset = ocfs2_find_next_zero_bit(bitmap, + le16_to_cpu(bg->bg_bits), + start)) != -1) { + if (offset == le16_to_cpu(bg->bg_bits)) + break; + + if (!ocfs2_test_bg_bit_allocatable(bg_bh, offset)) { + /* We found a zero, but we can't use it as it + * hasn't been put to disk yet! */ + found = 0; + start = offset + 1; + } else if (offset == start) { + /* we found a zero */ + found++; + /* move start to the next bit to test */ + start++; + } else { + /* got a zero after some ones */ + found = 1; + start = offset + 1; + } + if (found > best_size) { + best_size = found; + best_offset = start - found; + } + /* we got everything we needed */ + if (found == bits_wanted) { + /* mlog(0, "Found it all!\n"); */ + break; + } + } + + /* XXX: I think the first clause is equivalent to the second + * - jlbec */ + if (found == bits_wanted) { + *bit_off = start - found; + *bits_found = found; + } else if (best_size) { + *bit_off = best_offset; + *bits_found = best_size; + } else { + status = -ENOSPC; + /* No error log here -- see the comment above + * ocfs2_test_bg_bit_allocatable */ + } + + return status; +} + +static inline int ocfs2_block_group_set_bits(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct ocfs2_group_desc *bg, + struct buffer_head *group_bh, + unsigned int bit_off, + unsigned int num_bits) +{ + int status; + void *bitmap = bg->bg_bitmap; + int journal_type = OCFS2_JOURNAL_ACCESS_WRITE; + + mlog_entry_void(); + + if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { + OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg); + status = -EIO; + goto bail; + } + BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); + + mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off, + num_bits); + + if (ocfs2_is_cluster_bitmap(alloc_inode)) + journal_type = OCFS2_JOURNAL_ACCESS_UNDO; + + status = ocfs2_journal_access(handle, + alloc_inode, + group_bh, + journal_type); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + le16_add_cpu(&bg->bg_free_bits_count, -num_bits); + + while(num_bits--) + ocfs2_set_bit(bit_off++, bitmap); + + status = ocfs2_journal_dirty(handle, + group_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + +bail: + mlog_exit(status); + return status; +} + +/* find the one with the most empty bits */ +static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl) +{ + u16 curr, best; + + BUG_ON(!cl->cl_next_free_rec); + + best = curr = 0; + while (curr < le16_to_cpu(cl->cl_next_free_rec)) { + if (le32_to_cpu(cl->cl_recs[curr].c_free) > + le32_to_cpu(cl->cl_recs[best].c_free)) + best = curr; + curr++; + } + + BUG_ON(best >= le16_to_cpu(cl->cl_next_free_rec)); + return best; +} + +static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct buffer_head *fe_bh, + struct buffer_head *bg_bh, + struct buffer_head *prev_bg_bh, + u16 chain) +{ + int status; + /* there is a really tiny chance the journal calls could fail, + * but we wouldn't want inconsistent blocks in *any* case. */ + u64 fe_ptr, bg_ptr, prev_bg_ptr; + struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data; + struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; + struct ocfs2_group_desc *prev_bg = (struct ocfs2_group_desc *) prev_bg_bh->b_data; + + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); + status = -EIO; + goto out; + } + if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { + OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg); + status = -EIO; + goto out; + } + if (!OCFS2_IS_VALID_GROUP_DESC(prev_bg)) { + OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, prev_bg); + status = -EIO; + goto out; + } + + mlog(0, "In suballoc %"MLFu64", chain %u, move group %"MLFu64" to " + "top, prev = %"MLFu64"\n", + fe->i_blkno, chain, bg->bg_blkno, prev_bg->bg_blkno); + + fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); + bg_ptr = le64_to_cpu(bg->bg_next_group); + prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group); + + status = ocfs2_journal_access(handle, alloc_inode, prev_bg_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto out_rollback; + } + + prev_bg->bg_next_group = bg->bg_next_group; + + status = ocfs2_journal_dirty(handle, prev_bg_bh); + if (status < 0) { + mlog_errno(status); + goto out_rollback; + } + + status = ocfs2_journal_access(handle, alloc_inode, bg_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto out_rollback; + } + + bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno; + + status = ocfs2_journal_dirty(handle, bg_bh); + if (status < 0) { + mlog_errno(status); + goto out_rollback; + } + + status = ocfs2_journal_access(handle, alloc_inode, fe_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto out_rollback; + } + + fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno; + + status = ocfs2_journal_dirty(handle, fe_bh); + if (status < 0) { + mlog_errno(status); + goto out_rollback; + } + + status = 0; +out_rollback: + if (status < 0) { + fe->id2.i_chain.cl_recs[chain].c_blkno = cpu_to_le64(fe_ptr); + bg->bg_next_group = cpu_to_le64(bg_ptr); + prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr); + } +out: + mlog_exit(status); + return status; +} + +static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg, + u32 wanted) +{ + return le16_to_cpu(bg->bg_free_bits_count) > wanted; +} + +/* return 0 on success, -ENOSPC to keep searching and any other < 0 + * value on error. */ +static int ocfs2_cluster_group_search(struct inode *inode, + struct buffer_head *group_bh, + u32 bits_wanted, u32 min_bits, + u16 *bit_off, u16 *bits_found) +{ + int search = -ENOSPC; + int ret; + struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) group_bh->b_data; + u16 tmp_off, tmp_found; + + BUG_ON(!ocfs2_is_cluster_bitmap(inode)); + + if (bg->bg_free_bits_count) { + ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb), + group_bh, bits_wanted, + &tmp_off, &tmp_found); + if (ret) + return ret; + + /* ocfs2_block_group_find_clear_bits() might + * return success, but we still want to return + * -ENOSPC unless it found the minimum number + * of bits. */ + if (min_bits <= tmp_found) { + *bit_off = tmp_off; + *bits_found = tmp_found; + search = 0; /* success */ + } + } + + return search; +} + +static int ocfs2_block_group_search(struct inode *inode, + struct buffer_head *group_bh, + u32 bits_wanted, u32 min_bits, + u16 *bit_off, u16 *bits_found) +{ + int ret = -ENOSPC; + struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) group_bh->b_data; + + BUG_ON(min_bits != 1); + BUG_ON(ocfs2_is_cluster_bitmap(inode)); + + if (bg->bg_free_bits_count) + ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb), + group_bh, bits_wanted, + bit_off, bits_found); + + return ret; +} + +static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, + u32 bits_wanted, + u32 min_bits, + u16 *bit_off, + unsigned int *num_bits, + u64 *bg_blkno) +{ + int status; + u16 chain, tmp_bits; + u32 tmp_used; + u64 next_group; + struct ocfs2_journal_handle *handle = ac->ac_handle; + struct inode *alloc_inode = ac->ac_inode; + struct buffer_head *group_bh = NULL; + struct buffer_head *prev_group_bh = NULL; + struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; + struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &fe->id2.i_chain; + struct ocfs2_group_desc *bg; + + chain = ac->ac_chain; + mlog(0, "trying to alloc %u bits from chain %u, inode %"MLFu64"\n", + bits_wanted, chain, OCFS2_I(alloc_inode)->ip_blkno); + + status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), + le64_to_cpu(cl->cl_recs[chain].c_blkno), + &group_bh, OCFS2_BH_CACHED, alloc_inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + bg = (struct ocfs2_group_desc *) group_bh->b_data; + if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { + OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg); + status = -EIO; + goto bail; + } + + status = -ENOSPC; + /* for now, the chain search is a bit simplistic. We just use + * the 1st group with any empty bits. */ + while ((status = ac->ac_group_search(alloc_inode, group_bh, + bits_wanted, min_bits, bit_off, + &tmp_bits)) == -ENOSPC) { + if (!bg->bg_next_group) + break; + + if (prev_group_bh) { + brelse(prev_group_bh); + prev_group_bh = NULL; + } + next_group = le64_to_cpu(bg->bg_next_group); + prev_group_bh = group_bh; + group_bh = NULL; + status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), + next_group, &group_bh, + OCFS2_BH_CACHED, alloc_inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + bg = (struct ocfs2_group_desc *) group_bh->b_data; + if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { + OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg); + status = -EIO; + goto bail; + } + } + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + mlog(0, "alloc succeeds: we give %u bits from block group %"MLFu64"\n", + tmp_bits, bg->bg_blkno); + + *num_bits = tmp_bits; + + BUG_ON(*num_bits == 0); + + /* + * Keep track of previous block descriptor read. When + * we find a target, if we have read more than X + * number of descriptors, and the target is reasonably + * empty, relink him to top of his chain. + * + * We've read 0 extra blocks and only send one more to + * the transaction, yet the next guy to search has a + * much easier time. + * + * Do this *after* figuring out how many bits we're taking out + * of our target group. + */ + if (ac->ac_allow_chain_relink && + (prev_group_bh) && + (ocfs2_block_group_reasonably_empty(bg, *num_bits))) { + status = ocfs2_relink_block_group(handle, alloc_inode, + ac->ac_bh, group_bh, + prev_group_bh, chain); + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + + /* Ok, claim our bits now: set the info on dinode, chainlist + * and then the group */ + status = ocfs2_journal_access(handle, + alloc_inode, + ac->ac_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used); + fe->id1.bitmap1.i_used = cpu_to_le32(*num_bits + tmp_used); + le32_add_cpu(&cl->cl_recs[chain].c_free, -(*num_bits)); + + status = ocfs2_journal_dirty(handle, + ac->ac_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_block_group_set_bits(handle, + alloc_inode, + bg, + group_bh, + *bit_off, + *num_bits); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + mlog(0, "Allocated %u bits from suballocator %"MLFu64"\n", + *num_bits, fe->i_blkno); + + *bg_blkno = le64_to_cpu(bg->bg_blkno); +bail: + if (group_bh) + brelse(group_bh); + if (prev_group_bh) + brelse(prev_group_bh); + + mlog_exit(status); + return status; +} + +/* will give out up to bits_wanted contiguous bits. */ +static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, + struct ocfs2_alloc_context *ac, + u32 bits_wanted, + u32 min_bits, + u16 *bit_off, + unsigned int *num_bits, + u64 *bg_blkno) +{ + int status; + u16 victim, i; + struct ocfs2_chain_list *cl; + struct ocfs2_dinode *fe; + + mlog_entry_void(); + + BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); + BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); + BUG_ON(!ac->ac_bh); + + fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(osb->sb, fe); + status = -EIO; + goto bail; + } + if (le32_to_cpu(fe->id1.bitmap1.i_used) >= + le32_to_cpu(fe->id1.bitmap1.i_total)) { + ocfs2_error(osb->sb, "Chain allocator dinode %"MLFu64" has %u" + "used bits but only %u total.", + le64_to_cpu(fe->i_blkno), + le32_to_cpu(fe->id1.bitmap1.i_used), + le32_to_cpu(fe->id1.bitmap1.i_total)); + status = -EIO; + goto bail; + } + + cl = (struct ocfs2_chain_list *) &fe->id2.i_chain; + + victim = ocfs2_find_victim_chain(cl); + ac->ac_chain = victim; + ac->ac_allow_chain_relink = 1; + + status = ocfs2_search_chain(ac, bits_wanted, min_bits, bit_off, + num_bits, bg_blkno); + if (!status) + goto bail; + if (status < 0 && status != -ENOSPC) { + mlog_errno(status); + goto bail; + } + + mlog(0, "Search of victim chain %u came up with nothing, " + "trying all chains now.\n", victim); + + /* If we didn't pick a good victim, then just default to + * searching each chain in order. Don't allow chain relinking + * because we only calculate enough journal credits for one + * relink per alloc. */ + ac->ac_allow_chain_relink = 0; + for (i = 0; i < le16_to_cpu(cl->cl_next_free_rec); i ++) { + if (i == victim) + continue; + if (!cl->cl_recs[i].c_free) + continue; + + ac->ac_chain = i; + status = ocfs2_search_chain(ac, bits_wanted, min_bits, + bit_off, num_bits, + bg_blkno); + if (!status) + break; + if (status < 0 && status != -ENOSPC) { + mlog_errno(status); + goto bail; + } + } +bail: + + mlog_exit(status); + return status; +} + +int ocfs2_claim_metadata(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac, + u32 bits_wanted, + u16 *suballoc_bit_start, + unsigned int *num_bits, + u64 *blkno_start) +{ + int status; + u64 bg_blkno; + + BUG_ON(!ac); + BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); + BUG_ON(ac->ac_which != OCFS2_AC_USE_META); + BUG_ON(ac->ac_handle != handle); + + status = ocfs2_claim_suballoc_bits(osb, + ac, + bits_wanted, + 1, + suballoc_bit_start, + num_bits, + &bg_blkno); + if (status < 0) { + mlog_errno(status); + goto bail; + } + atomic_inc(&osb->alloc_stats.bg_allocs); + + *blkno_start = bg_blkno + (u64) *suballoc_bit_start; + ac->ac_bits_given += (*num_bits); + status = 0; +bail: + mlog_exit(status); + return status; +} + +int ocfs2_claim_new_inode(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac, + u16 *suballoc_bit, + u64 *fe_blkno) +{ + int status; + unsigned int num_bits; + u64 bg_blkno; + + mlog_entry_void(); + + BUG_ON(!ac); + BUG_ON(ac->ac_bits_given != 0); + BUG_ON(ac->ac_bits_wanted != 1); + BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); + BUG_ON(ac->ac_handle != handle); + + status = ocfs2_claim_suballoc_bits(osb, + ac, + 1, + 1, + suballoc_bit, + &num_bits, + &bg_blkno); + if (status < 0) { + mlog_errno(status); + goto bail; + } + atomic_inc(&osb->alloc_stats.bg_allocs); + + BUG_ON(num_bits != 1); + + *fe_blkno = bg_blkno + (u64) (*suballoc_bit); + ac->ac_bits_given++; + status = 0; +bail: + mlog_exit(status); + return status; +} + +/* translate a group desc. blkno and it's bitmap offset into + * disk cluster offset. */ +static inline u32 ocfs2_desc_bitmap_to_cluster_off(struct inode *inode, + u64 bg_blkno, + u16 bg_bit_off) +{ + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + u32 cluster = 0; + + BUG_ON(!ocfs2_is_cluster_bitmap(inode)); + + if (bg_blkno != osb->first_cluster_group_blkno) + cluster = ocfs2_blocks_to_clusters(inode->i_sb, bg_blkno); + cluster += (u32) bg_bit_off; + return cluster; +} + +/* given a cluster offset, calculate which block group it belongs to + * and return that block offset. */ +static inline u64 ocfs2_which_cluster_group(struct inode *inode, + u32 cluster) +{ + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + u32 group_no; + + BUG_ON(!ocfs2_is_cluster_bitmap(inode)); + + group_no = cluster / osb->bitmap_cpg; + if (!group_no) + return osb->first_cluster_group_blkno; + return ocfs2_clusters_to_blocks(inode->i_sb, + group_no * osb->bitmap_cpg); +} + +/* given the block number of a cluster start, calculate which cluster + * group and descriptor bitmap offset that corresponds to. */ +static inline void ocfs2_block_to_cluster_group(struct inode *inode, + u64 data_blkno, + u64 *bg_blkno, + u16 *bg_bit_off) +{ + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + u32 data_cluster = ocfs2_blocks_to_clusters(osb->sb, data_blkno); + + BUG_ON(!ocfs2_is_cluster_bitmap(inode)); + + *bg_blkno = ocfs2_which_cluster_group(inode, + data_cluster); + + if (*bg_blkno == osb->first_cluster_group_blkno) + *bg_bit_off = (u16) data_cluster; + else + *bg_bit_off = (u16) ocfs2_blocks_to_clusters(osb->sb, + data_blkno - *bg_blkno); +} + +/* + * min_bits - minimum contiguous chunk from this total allocation we + * can handle. set to what we asked for originally for a full + * contig. allocation, set to '1' to indicate we can deal with extents + * of any size. + */ +int ocfs2_claim_clusters(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac, + u32 min_clusters, + u32 *cluster_start, + u32 *num_clusters) +{ + int status; + unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; + u64 bg_blkno; + u16 bg_bit_off; + + mlog_entry_void(); + + BUG_ON(!ac); + BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); + + BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL + && ac->ac_which != OCFS2_AC_USE_MAIN); + BUG_ON(ac->ac_handle != handle); + + if (ac->ac_which == OCFS2_AC_USE_LOCAL) { + status = ocfs2_claim_local_alloc_bits(osb, + handle, + ac, + bits_wanted, + cluster_start, + num_clusters); + if (!status) + atomic_inc(&osb->alloc_stats.local_data); + } else { + if (min_clusters > (osb->bitmap_cpg - 1)) { + /* The only paths asking for contiguousness + * should know about this already. */ + mlog(ML_ERROR, "minimum allocation requested exceeds " + "group bitmap size!"); + status = -ENOSPC; + goto bail; + } + /* clamp the current request down to a realistic size. */ + if (bits_wanted > (osb->bitmap_cpg - 1)) + bits_wanted = osb->bitmap_cpg - 1; + + status = ocfs2_claim_suballoc_bits(osb, + ac, + bits_wanted, + min_clusters, + &bg_bit_off, + num_clusters, + &bg_blkno); + if (!status) { + *cluster_start = + ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode, + bg_blkno, + bg_bit_off); + atomic_inc(&osb->alloc_stats.bitmap_data); + } + } + if (status < 0) { + if (status != -ENOSPC) + mlog_errno(status); + goto bail; + } + + ac->ac_bits_given += *num_clusters; + +bail: + mlog_exit(status); + return status; +} + +static inline int ocfs2_block_group_clear_bits(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct ocfs2_group_desc *bg, + struct buffer_head *group_bh, + unsigned int bit_off, + unsigned int num_bits) +{ + int status; + unsigned int tmp; + int journal_type = OCFS2_JOURNAL_ACCESS_WRITE; + struct ocfs2_group_desc *undo_bg = NULL; + + mlog_entry_void(); + + if (!OCFS2_IS_VALID_GROUP_DESC(bg)) { + OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg); + status = -EIO; + goto bail; + } + + mlog(0, "off = %u, num = %u\n", bit_off, num_bits); + + if (ocfs2_is_cluster_bitmap(alloc_inode)) + journal_type = OCFS2_JOURNAL_ACCESS_UNDO; + + status = ocfs2_journal_access(handle, alloc_inode, group_bh, + journal_type); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + if (ocfs2_is_cluster_bitmap(alloc_inode)) + undo_bg = (struct ocfs2_group_desc *) bh2jh(group_bh)->b_committed_data; + + tmp = num_bits; + while(tmp--) { + ocfs2_clear_bit((bit_off + tmp), + (unsigned long *) bg->bg_bitmap); + if (ocfs2_is_cluster_bitmap(alloc_inode)) + ocfs2_set_bit(bit_off + tmp, + (unsigned long *) undo_bg->bg_bitmap); + } + le16_add_cpu(&bg->bg_free_bits_count, num_bits); + + status = ocfs2_journal_dirty(handle, group_bh); + if (status < 0) + mlog_errno(status); +bail: + return status; +} + +/* + * expects the suballoc inode to already be locked. + */ +static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle, + struct inode *alloc_inode, + struct buffer_head *alloc_bh, + unsigned int start_bit, + u64 bg_blkno, + unsigned int count) +{ + int status = 0; + u32 tmp_used; + struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb); + struct ocfs2_dinode *fe = (struct ocfs2_dinode *) alloc_bh->b_data; + struct ocfs2_chain_list *cl = &fe->id2.i_chain; + struct buffer_head *group_bh = NULL; + struct ocfs2_group_desc *group; + + mlog_entry_void(); + + if (!OCFS2_IS_VALID_DINODE(fe)) { + OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); + status = -EIO; + goto bail; + } + BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl)); + + mlog(0, "suballocator %"MLFu64": freeing %u bits from group %"MLFu64 + ", starting at %u\n", + OCFS2_I(alloc_inode)->ip_blkno, count, bg_blkno, + start_bit); + + status = ocfs2_read_block(osb, bg_blkno, &group_bh, OCFS2_BH_CACHED, + alloc_inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + group = (struct ocfs2_group_desc *) group_bh->b_data; + if (!OCFS2_IS_VALID_GROUP_DESC(group)) { + OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, group); + status = -EIO; + goto bail; + } + BUG_ON((count + start_bit) > le16_to_cpu(group->bg_bits)); + + status = ocfs2_block_group_clear_bits(handle, alloc_inode, + group, group_bh, + start_bit, count); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = ocfs2_journal_access(handle, alloc_inode, alloc_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + le32_add_cpu(&cl->cl_recs[le16_to_cpu(group->bg_chain)].c_free, + count); + tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used); + fe->id1.bitmap1.i_used = cpu_to_le32(tmp_used - count); + + status = ocfs2_journal_dirty(handle, alloc_bh); + if (status < 0) { + mlog_errno(status); + goto bail; + } + +bail: + if (group_bh) + brelse(group_bh); + + mlog_exit(status); + return status; +} + +static inline u64 ocfs2_which_suballoc_group(u64 block, unsigned int bit) +{ + u64 group = block - (u64) bit; + + return group; +} + +int ocfs2_free_dinode(struct ocfs2_journal_handle *handle, + struct inode *inode_alloc_inode, + struct buffer_head *inode_alloc_bh, + struct ocfs2_dinode *di) +{ + u64 blk = le64_to_cpu(di->i_blkno); + u16 bit = le16_to_cpu(di->i_suballoc_bit); + u64 bg_blkno = ocfs2_which_suballoc_group(blk, bit); + + return ocfs2_free_suballoc_bits(handle, inode_alloc_inode, + inode_alloc_bh, bit, bg_blkno, 1); +} + +int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle, + struct inode *eb_alloc_inode, + struct buffer_head *eb_alloc_bh, + struct ocfs2_extent_block *eb) +{ + u64 blk = le64_to_cpu(eb->h_blkno); + u16 bit = le16_to_cpu(eb->h_suballoc_bit); + u64 bg_blkno = ocfs2_which_suballoc_group(blk, bit); + + return ocfs2_free_suballoc_bits(handle, eb_alloc_inode, eb_alloc_bh, + bit, bg_blkno, 1); +} + +int ocfs2_free_clusters(struct ocfs2_journal_handle *handle, + struct inode *bitmap_inode, + struct buffer_head *bitmap_bh, + u64 start_blk, + unsigned int num_clusters) +{ + int status; + u16 bg_start_bit; + u64 bg_blkno; + struct ocfs2_dinode *fe; + + /* You can't ever have a contiguous set of clusters + * bigger than a block group bitmap so we never have to worry + * about looping on them. */ + + mlog_entry_void(); + + /* This is expensive. We can safely remove once this stuff has + * gotten tested really well. */ + BUG_ON(start_blk != ocfs2_clusters_to_blocks(bitmap_inode->i_sb, ocfs2_blocks_to_clusters(bitmap_inode->i_sb, start_blk))); + + fe = (struct ocfs2_dinode *) bitmap_bh->b_data; + + ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno, + &bg_start_bit); + + mlog(0, "want to free %u clusters starting at block %"MLFu64"\n", + num_clusters, start_blk); + mlog(0, "bg_blkno = %"MLFu64", bg_start_bit = %u\n", + bg_blkno, bg_start_bit); + + status = ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh, + bg_start_bit, bg_blkno, + num_clusters); + if (status < 0) + mlog_errno(status); + + mlog_exit(status); + return status; +} + +static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg) +{ + printk("Block Group:\n"); + printk("bg_signature: %s\n", bg->bg_signature); + printk("bg_size: %u\n", bg->bg_size); + printk("bg_bits: %u\n", bg->bg_bits); + printk("bg_free_bits_count: %u\n", bg->bg_free_bits_count); + printk("bg_chain: %u\n", bg->bg_chain); + printk("bg_generation: %u\n", le32_to_cpu(bg->bg_generation)); + printk("bg_next_group: %"MLFu64"\n", bg->bg_next_group); + printk("bg_parent_dinode: %"MLFu64"\n", bg->bg_parent_dinode); + printk("bg_blkno: %"MLFu64"\n", bg->bg_blkno); +} + +static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe) +{ + int i; + + printk("Suballoc Inode %"MLFu64":\n", fe->i_blkno); + printk("i_signature: %s\n", fe->i_signature); + printk("i_size: %"MLFu64"\n", fe->i_size); + printk("i_clusters: %u\n", fe->i_clusters); + printk("i_generation: %u\n", + le32_to_cpu(fe->i_generation)); + printk("id1.bitmap1.i_used: %u\n", + le32_to_cpu(fe->id1.bitmap1.i_used)); + printk("id1.bitmap1.i_total: %u\n", + le32_to_cpu(fe->id1.bitmap1.i_total)); + printk("id2.i_chain.cl_cpg: %u\n", fe->id2.i_chain.cl_cpg); + printk("id2.i_chain.cl_bpc: %u\n", fe->id2.i_chain.cl_bpc); + printk("id2.i_chain.cl_count: %u\n", fe->id2.i_chain.cl_count); + printk("id2.i_chain.cl_next_free_rec: %u\n", + fe->id2.i_chain.cl_next_free_rec); + for(i = 0; i < fe->id2.i_chain.cl_next_free_rec; i++) { + printk("fe->id2.i_chain.cl_recs[%d].c_free: %u\n", i, + fe->id2.i_chain.cl_recs[i].c_free); + printk("fe->id2.i_chain.cl_recs[%d].c_total: %u\n", i, + fe->id2.i_chain.cl_recs[i].c_total); + printk("fe->id2.i_chain.cl_recs[%d].c_blkno: %"MLFu64"\n", i, + fe->id2.i_chain.cl_recs[i].c_blkno); + } +} diff --git a/fs/ocfs2/suballoc.h b/fs/ocfs2/suballoc.h new file mode 100644 index 0000000..a76c82a --- /dev/null +++ b/fs/ocfs2/suballoc.h @@ -0,0 +1,132 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * suballoc.h + * + * Defines sub allocator api + * + * Copyright (C) 2003, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef _CHAINALLOC_H_ +#define _CHAINALLOC_H_ + +typedef int (group_search_t)(struct inode *, + struct buffer_head *, + u32, + u32, + u16 *, + u16 *); + +struct ocfs2_alloc_context { + struct inode *ac_inode; /* which bitmap are we allocating from? */ + struct buffer_head *ac_bh; /* file entry bh */ + u32 ac_bits_wanted; + u32 ac_bits_given; +#define OCFS2_AC_USE_LOCAL 1 +#define OCFS2_AC_USE_MAIN 2 +#define OCFS2_AC_USE_INODE 3 +#define OCFS2_AC_USE_META 4 + u32 ac_which; + struct ocfs2_journal_handle *ac_handle; + + /* these are used by the chain search */ + u16 ac_chain; + int ac_allow_chain_relink; + group_search_t *ac_group_search; +}; + +void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac); +static inline int ocfs2_alloc_context_bits_left(struct ocfs2_alloc_context *ac) +{ + return ac->ac_bits_wanted - ac->ac_bits_given; +} + +int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_dinode *fe, + struct ocfs2_alloc_context **ac); +int ocfs2_reserve_new_inode(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context **ac); +int ocfs2_reserve_clusters(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + u32 bits_wanted, + struct ocfs2_alloc_context **ac); + +int ocfs2_claim_metadata(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac, + u32 bits_wanted, + u16 *suballoc_bit_start, + u32 *num_bits, + u64 *blkno_start); +int ocfs2_claim_new_inode(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac, + u16 *suballoc_bit, + u64 *fe_blkno); +int ocfs2_claim_clusters(struct ocfs2_super *osb, + struct ocfs2_journal_handle *handle, + struct ocfs2_alloc_context *ac, + u32 min_clusters, + u32 *cluster_start, + u32 *num_clusters); + +int ocfs2_free_dinode(struct ocfs2_journal_handle *handle, + struct inode *inode_alloc_inode, + struct buffer_head *inode_alloc_bh, + struct ocfs2_dinode *di); +int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle, + struct inode *eb_alloc_inode, + struct buffer_head *eb_alloc_bh, + struct ocfs2_extent_block *eb); +int ocfs2_free_clusters(struct ocfs2_journal_handle *handle, + struct inode *bitmap_inode, + struct buffer_head *bitmap_bh, + u64 start_blk, + unsigned int num_clusters); + +static inline u32 ocfs2_cluster_from_desc(struct ocfs2_super *osb, + u64 bg_blkno) +{ + /* This should work for all block group descriptors as only + * the 1st group descriptor of the cluster bitmap is + * different. */ + + if (bg_blkno == osb->first_cluster_group_blkno) + return 0; + + /* the rest of the block groups are located at the beginning + * of their 1st cluster, so a direct translation just + * works. */ + return ocfs2_blocks_to_clusters(osb->sb, bg_blkno); +} + +static inline int ocfs2_is_cluster_bitmap(struct inode *inode) +{ + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + return osb->bitmap_blkno == OCFS2_I(inode)->ip_blkno; +} + +/* This is for local alloc ONLY. Others should use the task-specific + * apis above. */ +int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb, + struct ocfs2_alloc_context *ac); + +#endif /* _CHAINALLOC_H_ */ diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c new file mode 100644 index 0000000..48bf7f0 --- /dev/null +++ b/fs/ocfs2/super.c @@ -0,0 +1,1733 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * super.c + * + * load/unload driver, mount/dismount volumes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define MLOG_MASK_PREFIX ML_SUPER +#include + +#include "ocfs2.h" + +/* this should be the only file to include a version 1 header */ +#include "ocfs1_fs_compat.h" + +#include "alloc.h" +#include "dlmglue.h" +#include "export.h" +#include "extent_map.h" +#include "heartbeat.h" +#include "inode.h" +#include "journal.h" +#include "localalloc.h" +#include "namei.h" +#include "slot_map.h" +#include "super.h" +#include "sysfile.h" +#include "uptodate.h" +#include "ver.h" +#include "vote.h" + +#include "buffer_head_io.h" + +/* + * Globals + */ +static spinlock_t ocfs2_globals_lock = SPIN_LOCK_UNLOCKED; + +static u32 osb_id; /* Keeps track of next available OSB Id */ + +static kmem_cache_t *ocfs2_inode_cachep = NULL; + +kmem_cache_t *ocfs2_lock_cache = NULL; + +/* OCFS2 needs to schedule several differnt types of work which + * require cluster locking, disk I/O, recovery waits, etc. Since these + * types of work tend to be heavy we avoid using the kernel events + * workqueue and schedule on our own. */ +struct workqueue_struct *ocfs2_wq = NULL; + +static struct dentry *ocfs2_debugfs_root = NULL; + +MODULE_AUTHOR("Oracle"); +MODULE_LICENSE("GPL"); + +static int ocfs2_parse_options(struct super_block *sb, char *options, + unsigned long *mount_opt, int is_remount); +static void ocfs2_put_super(struct super_block *sb); +static int ocfs2_mount_volume(struct super_block *sb); +static int ocfs2_remount(struct super_block *sb, int *flags, char *data); +static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err); +static int ocfs2_initialize_mem_caches(void); +static void ocfs2_free_mem_caches(void); +static void ocfs2_delete_osb(struct ocfs2_super *osb); + +static int ocfs2_statfs(struct super_block *sb, struct kstatfs *buf); + +static int ocfs2_sync_fs(struct super_block *sb, int wait); + +static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb); +static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb); +static int ocfs2_release_system_inodes(struct ocfs2_super *osb); +static int ocfs2_fill_local_node_info(struct ocfs2_super *osb); +static int ocfs2_check_volume(struct ocfs2_super *osb); +static int ocfs2_verify_volume(struct ocfs2_dinode *di, + struct buffer_head *bh, + u32 sectsize); +static int ocfs2_initialize_super(struct super_block *sb, + struct buffer_head *bh, + int sector_size); +static int ocfs2_get_sector(struct super_block *sb, + struct buffer_head **bh, + int block, + int sect_size); +static void ocfs2_write_super(struct super_block *sb); +static struct inode *ocfs2_alloc_inode(struct super_block *sb); +static void ocfs2_destroy_inode(struct inode *inode); + +static unsigned long long ocfs2_max_file_offset(unsigned int blockshift); + +static struct super_operations ocfs2_sops = { + .statfs = ocfs2_statfs, + .alloc_inode = ocfs2_alloc_inode, + .destroy_inode = ocfs2_destroy_inode, + .drop_inode = ocfs2_drop_inode, + .clear_inode = ocfs2_clear_inode, + .delete_inode = ocfs2_delete_inode, + .sync_fs = ocfs2_sync_fs, + .write_super = ocfs2_write_super, + .put_super = ocfs2_put_super, + .remount_fs = ocfs2_remount, +}; + +enum { + Opt_barrier, + Opt_err_panic, + Opt_err_ro, + Opt_intr, + Opt_nointr, + Opt_hb_none, + Opt_hb_local, + Opt_data_ordered, + Opt_data_writeback, + Opt_err, +}; + +static match_table_t tokens = { + {Opt_barrier, "barrier=%u"}, + {Opt_err_panic, "errors=panic"}, + {Opt_err_ro, "errors=remount-ro"}, + {Opt_intr, "intr"}, + {Opt_nointr, "nointr"}, + {Opt_hb_none, OCFS2_HB_NONE}, + {Opt_hb_local, OCFS2_HB_LOCAL}, + {Opt_data_ordered, "data=ordered"}, + {Opt_data_writeback, "data=writeback"}, + {Opt_err, NULL} +}; + +/* + * write_super and sync_fs ripped right out of ext3. + */ +static void ocfs2_write_super(struct super_block *sb) +{ + if (down_trylock(&sb->s_lock) == 0) + BUG(); + sb->s_dirt = 0; +} + +static int ocfs2_sync_fs(struct super_block *sb, int wait) +{ + int status = 0; + tid_t target; + struct ocfs2_super *osb = OCFS2_SB(sb); + + sb->s_dirt = 0; + + if (ocfs2_is_hard_readonly(osb)) + return -EROFS; + + if (wait) { + status = ocfs2_flush_truncate_log(osb); + if (status < 0) + mlog_errno(status); + } else { + ocfs2_schedule_truncate_log_flush(osb, 0); + } + + if (journal_start_commit(OCFS2_SB(sb)->journal->j_journal, &target)) { + if (wait) + log_wait_commit(OCFS2_SB(sb)->journal->j_journal, + target); + } + return 0; +} + +static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) +{ + struct inode *new = NULL; + int status = 0; + int i; + + mlog_entry_void(); + + new = ocfs2_iget(osb, osb->root_blkno); + if (IS_ERR(new)) { + status = PTR_ERR(new); + mlog_errno(status); + goto bail; + } + osb->root_inode = new; + + new = ocfs2_iget(osb, osb->system_dir_blkno); + if (IS_ERR(new)) { + status = PTR_ERR(new); + mlog_errno(status); + goto bail; + } + osb->sys_root_inode = new; + + for (i = OCFS2_FIRST_ONLINE_SYSTEM_INODE; + i <= OCFS2_LAST_GLOBAL_SYSTEM_INODE; i++) { + new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); + if (!new) { + ocfs2_release_system_inodes(osb); + status = -EINVAL; + mlog_errno(status); + /* FIXME: Should ERROR_RO_FS */ + mlog(ML_ERROR, "Unable to load system inode %d, " + "possibly corrupt fs?", i); + goto bail; + } + // the array now has one ref, so drop this one + iput(new); + } + +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb) +{ + struct inode *new = NULL; + int status = 0; + int i; + + mlog_entry_void(); + + for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1; + i < NUM_SYSTEM_INODES; + i++) { + new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); + if (!new) { + ocfs2_release_system_inodes(osb); + status = -EINVAL; + mlog(ML_ERROR, "status=%d, sysfile=%d, slot=%d\n", + status, i, osb->slot_num); + goto bail; + } + /* the array now has one ref, so drop this one */ + iput(new); + } + +bail: + mlog_exit(status); + return status; +} + +static int ocfs2_release_system_inodes(struct ocfs2_super *osb) +{ + int status = 0, i; + struct inode *inode; + + mlog_entry_void(); + + for (i = 0; i < NUM_SYSTEM_INODES; i++) { + inode = osb->system_inodes[i]; + if (inode) { + iput(inode); + osb->system_inodes[i] = NULL; + } + } + + inode = osb->sys_root_inode; + if (inode) { + iput(inode); + osb->sys_root_inode = NULL; + } + + inode = osb->root_inode; + if (inode) { + iput(inode); + osb->root_inode = NULL; + } + + mlog_exit(status); + return status; +} + +/* We're allocating fs objects, use GFP_NOFS */ +static struct inode *ocfs2_alloc_inode(struct super_block *sb) +{ + struct ocfs2_inode_info *oi; + + oi = kmem_cache_alloc(ocfs2_inode_cachep, SLAB_NOFS); + if (!oi) + return NULL; + + return &oi->vfs_inode; +} + +static void ocfs2_destroy_inode(struct inode *inode) +{ + kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode)); +} + +/* From xfs_super.c:xfs_max_file_offset + * Copyright (c) 2000-2004 Silicon Graphics, Inc. + */ +static unsigned long long ocfs2_max_file_offset(unsigned int blockshift) +{ + unsigned int pagefactor = 1; + unsigned int bitshift = BITS_PER_LONG - 1; + + /* Figure out maximum filesize, on Linux this can depend on + * the filesystem blocksize (on 32 bit platforms). + * __block_prepare_write does this in an [unsigned] long... + * page->index << (PAGE_CACHE_SHIFT - bbits) + * So, for page sized blocks (4K on 32 bit platforms), + * this wraps at around 8Tb (hence MAX_LFS_FILESIZE which is + * (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) + * but for smaller blocksizes it is less (bbits = log2 bsize). + * Note1: get_block_t takes a long (implicit cast from above) + * Note2: The Large Block Device (LBD and HAVE_SECTOR_T) patch + * can optionally convert the [unsigned] long from above into + * an [unsigned] long long. + */ + +#if BITS_PER_LONG == 32 +# if defined(CONFIG_LBD) + BUG_ON(sizeof(sector_t) != 8); + pagefactor = PAGE_CACHE_SIZE; + bitshift = BITS_PER_LONG; +# else + pagefactor = PAGE_CACHE_SIZE >> (PAGE_CACHE_SHIFT - blockshift); +# endif +#endif + + return (((unsigned long long)pagefactor) << bitshift) - 1; +} + +static int ocfs2_remount(struct super_block *sb, int *flags, char *data) +{ + int incompat_features; + int ret = 0; + unsigned long parsed_options; + struct ocfs2_super *osb = OCFS2_SB(sb); + + if (!ocfs2_parse_options(sb, data, &parsed_options, 1)) { + ret = -EINVAL; + goto out; + } + + if ((osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) != + (parsed_options & OCFS2_MOUNT_HB_LOCAL)) { + ret = -EINVAL; + mlog(ML_ERROR, "Cannot change heartbeat mode on remount\n"); + goto out; + } + + if ((osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK) != + (parsed_options & OCFS2_MOUNT_DATA_WRITEBACK)) { + ret = -EINVAL; + mlog(ML_ERROR, "Cannot change data mode on remount\n"); + goto out; + } + + /* We're going to/from readonly mode. */ + if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) { + /* Lock here so the check of HARD_RO and the potential + * setting of SOFT_RO is atomic. */ + spin_lock(&osb->osb_lock); + if (osb->osb_flags & OCFS2_OSB_HARD_RO) { + mlog(ML_ERROR, "Remount on readonly device is forbidden.\n"); + ret = -EROFS; + goto unlock_osb; + } + + if (*flags & MS_RDONLY) { + mlog(0, "Going to ro mode.\n"); + sb->s_flags |= MS_RDONLY; + osb->osb_flags |= OCFS2_OSB_SOFT_RO; + } else { + mlog(0, "Making ro filesystem writeable.\n"); + + if (osb->osb_flags & OCFS2_OSB_ERROR_FS) { + mlog(ML_ERROR, "Cannot remount RDWR " + "filesystem due to previous errors.\n"); + ret = -EROFS; + goto unlock_osb; + } + incompat_features = OCFS2_HAS_RO_COMPAT_FEATURE(sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP); + if (incompat_features) { + mlog(ML_ERROR, "Cannot remount RDWR because " + "of unsupported optional features " + "(%x).\n", incompat_features); + ret = -EINVAL; + goto unlock_osb; + } + sb->s_flags &= ~MS_RDONLY; + osb->osb_flags &= ~OCFS2_OSB_SOFT_RO; + } +unlock_osb: + spin_unlock(&osb->osb_lock); + } + + if (!ret) { + if (!ocfs2_is_hard_readonly(osb)) + ocfs2_set_journal_params(osb); + + /* Only save off the new mount options in case of a successful + * remount. */ + osb->s_mount_opt = parsed_options; + } +out: + return ret; +} + +static int ocfs2_sb_probe(struct super_block *sb, + struct buffer_head **bh, + int *sector_size) +{ + int status = 0, tmpstat; + struct ocfs1_vol_disk_hdr *hdr; + struct ocfs2_dinode *di; + int blksize; + + *bh = NULL; + + /* may be > 512 */ + *sector_size = bdev_hardsect_size(sb->s_bdev); + if (*sector_size > OCFS2_MAX_BLOCKSIZE) { + mlog(ML_ERROR, "Hardware sector size too large: %d (max=%d)\n", + *sector_size, OCFS2_MAX_BLOCKSIZE); + status = -EINVAL; + goto bail; + } + + /* Can this really happen? */ + if (*sector_size < OCFS2_MIN_BLOCKSIZE) + *sector_size = OCFS2_MIN_BLOCKSIZE; + + /* check block zero for old format */ + status = ocfs2_get_sector(sb, bh, 0, *sector_size); + if (status < 0) { + mlog_errno(status); + goto bail; + } + hdr = (struct ocfs1_vol_disk_hdr *) (*bh)->b_data; + if (hdr->major_version == OCFS1_MAJOR_VERSION) { + mlog(ML_ERROR, "incompatible version: %u.%u\n", + hdr->major_version, hdr->minor_version); + status = -EINVAL; + } + if (memcmp(hdr->signature, OCFS1_VOLUME_SIGNATURE, + strlen(OCFS1_VOLUME_SIGNATURE)) == 0) { + mlog(ML_ERROR, "incompatible volume signature: %8s\n", + hdr->signature); + status = -EINVAL; + } + brelse(*bh); + *bh = NULL; + if (status < 0) { + mlog(ML_ERROR, "This is an ocfs v1 filesystem which must be " + "upgraded before mounting with ocfs v2\n"); + goto bail; + } + + /* + * Now check at magic offset for 512, 1024, 2048, 4096 + * blocksizes. 4096 is the maximum blocksize because it is + * the minimum clustersize. + */ + status = -EINVAL; + for (blksize = *sector_size; + blksize <= OCFS2_MAX_BLOCKSIZE; + blksize <<= 1) { + tmpstat = ocfs2_get_sector(sb, bh, + OCFS2_SUPER_BLOCK_BLKNO, + blksize); + if (tmpstat < 0) { + status = tmpstat; + mlog_errno(status); + goto bail; + } + di = (struct ocfs2_dinode *) (*bh)->b_data; + status = ocfs2_verify_volume(di, *bh, blksize); + if (status >= 0) + goto bail; + brelse(*bh); + *bh = NULL; + if (status != -EAGAIN) + break; + } + +bail: + return status; +} + +static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) +{ + struct dentry *root; + int status, sector_size; + unsigned long parsed_opt; + struct inode *inode = NULL; + struct ocfs2_super *osb = NULL; + struct buffer_head *bh = NULL; + + mlog_entry("%p, %p, %i", sb, data, silent); + + /* for now we only have one cluster/node, make sure we see it + * in the heartbeat universe */ + if (!o2hb_check_local_node_heartbeating()) { + status = -EINVAL; + goto read_super_error; + } + + /* probe for superblock */ + status = ocfs2_sb_probe(sb, &bh, §or_size); + if (status < 0) { + mlog(ML_ERROR, "superblock probe failed!\n"); + goto read_super_error; + } + + status = ocfs2_initialize_super(sb, bh, sector_size); + osb = OCFS2_SB(sb); + if (status < 0) { + mlog_errno(status); + goto read_super_error; + } + brelse(bh); + bh = NULL; + + if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) { + status = -EINVAL; + goto read_super_error; + } + osb->s_mount_opt = parsed_opt; + + sb->s_magic = OCFS2_SUPER_MAGIC; + + /* Hard readonly mode only if: bdev_read_only, MS_RDONLY, + * heartbeat=none */ + if (bdev_read_only(sb->s_bdev)) { + if (!(sb->s_flags & MS_RDONLY)) { + status = -EACCES; + mlog(ML_ERROR, "Readonly device detected but readonly " + "mount was not specified.\n"); + goto read_super_error; + } + + /* You should not be able to start a local heartbeat + * on a readonly device. */ + if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) { + status = -EROFS; + mlog(ML_ERROR, "Local heartbeat specified on readonly " + "device.\n"); + goto read_super_error; + } + + status = ocfs2_check_journals_nolocks(osb); + if (status < 0) { + if (status == -EROFS) + mlog(ML_ERROR, "Recovery required on readonly " + "file system, but write access is " + "unavailable.\n"); + else + mlog_errno(status); + goto read_super_error; + } + + ocfs2_set_ro_flag(osb, 1); + + printk(KERN_NOTICE "Readonly device detected. No cluster " + "services will be utilized for this mount. Recovery " + "will be skipped.\n"); + } + + if (!ocfs2_is_hard_readonly(osb)) { + /* If this isn't a hard readonly mount, then we need + * to make sure that heartbeat is in a valid state, + * and that we mark ourselves soft readonly is -oro + * was specified. */ + if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) { + mlog(ML_ERROR, "No heartbeat for device (%s)\n", + sb->s_id); + status = -EINVAL; + goto read_super_error; + } + + if (sb->s_flags & MS_RDONLY) + ocfs2_set_ro_flag(osb, 0); + } + + osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, + ocfs2_debugfs_root); + if (!osb->osb_debug_root) { + status = -EINVAL; + mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n"); + goto read_super_error; + } + + status = ocfs2_mount_volume(sb); + if (osb->root_inode) + inode = igrab(osb->root_inode); + + if (status < 0) + goto read_super_error; + + if (!inode) { + status = -EIO; + mlog_errno(status); + goto read_super_error; + } + + root = d_alloc_root(inode); + if (!root) { + status = -ENOMEM; + mlog_errno(status); + goto read_super_error; + } + + sb->s_root = root; + + ocfs2_complete_mount_recovery(osb); + + printk("ocfs2: Mounting device (%u,%u) on (node %d, slot %d) with %s " + "data mode.\n", + MAJOR(sb->s_dev), MINOR(sb->s_dev), osb->node_num, + osb->slot_num, + osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : + "ordered"); + + atomic_set(&osb->vol_state, VOLUME_MOUNTED); + wake_up(&osb->osb_mount_event); + + mlog_exit(status); + return status; + +read_super_error: + if (bh != NULL) + brelse(bh); + + if (inode) + iput(inode); + + if (osb) { + atomic_set(&osb->vol_state, VOLUME_DISABLED); + wake_up(&osb->osb_mount_event); + ocfs2_dismount_volume(sb, 1); + } + + mlog_exit(status); + return status; +} + +static struct super_block *ocfs2_get_sb(struct file_system_type *fs_type, + int flags, + const char *dev_name, + void *data) +{ + return get_sb_bdev(fs_type, flags, dev_name, data, ocfs2_fill_super); +} + +static struct file_system_type ocfs2_fs_type = { + .owner = THIS_MODULE, + .name = "ocfs2", + .get_sb = ocfs2_get_sb, /* is this called when we mount + * the fs? */ + .kill_sb = kill_block_super, /* set to the generic one + * right now, but do we + * need to change that? */ + .fs_flags = FS_REQUIRES_DEV, + .next = NULL +}; + +static int ocfs2_parse_options(struct super_block *sb, + char *options, + unsigned long *mount_opt, + int is_remount) +{ + int status; + char *p; + + mlog_entry("remount: %d, options: \"%s\"\n", is_remount, + options ? options : "(none)"); + + *mount_opt = 0; + + if (!options) { + status = 1; + goto bail; + } + + while ((p = strsep(&options, ",")) != NULL) { + int token, option; + substring_t args[MAX_OPT_ARGS]; + + if (!*p) + continue; + + token = match_token(p, tokens, args); + switch (token) { + case Opt_hb_local: + *mount_opt |= OCFS2_MOUNT_HB_LOCAL; + break; + case Opt_hb_none: + *mount_opt &= ~OCFS2_MOUNT_HB_LOCAL; + break; + case Opt_barrier: + if (match_int(&args[0], &option)) { + status = 0; + goto bail; + } + if (option) + *mount_opt |= OCFS2_MOUNT_BARRIER; + else + *mount_opt &= ~OCFS2_MOUNT_BARRIER; + break; + case Opt_intr: + *mount_opt &= ~OCFS2_MOUNT_NOINTR; + break; + case Opt_nointr: + *mount_opt |= OCFS2_MOUNT_NOINTR; + break; + case Opt_err_panic: + *mount_opt |= OCFS2_MOUNT_ERRORS_PANIC; + break; + case Opt_err_ro: + *mount_opt &= ~OCFS2_MOUNT_ERRORS_PANIC; + break; + case Opt_data_ordered: + *mount_opt &= ~OCFS2_MOUNT_DATA_WRITEBACK; + break; + case Opt_data_writeback: + *mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; + break; + default: + mlog(ML_ERROR, + "Unrecognized mount option \"%s\" " + "or missing value\n", p); + status = 0; + goto bail; + } + } + + status = 1; + +bail: + mlog_exit(status); + return status; +} + +static int __init ocfs2_init(void) +{ + int status; + + mlog_entry_void(); + + ocfs2_print_version(); + + if (init_ocfs2_extent_maps()) + return -ENOMEM; + + status = init_ocfs2_uptodate_cache(); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_initialize_mem_caches(); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + ocfs2_wq = create_singlethread_workqueue("ocfs2_wq"); + if (!ocfs2_wq) { + status = -ENOMEM; + goto leave; + } + + spin_lock(&ocfs2_globals_lock); + osb_id = 0; + spin_unlock(&ocfs2_globals_lock); + + ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL); + if (!ocfs2_debugfs_root) { + status = -EFAULT; + mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n"); + } + +leave: + if (status < 0) { + ocfs2_free_mem_caches(); + exit_ocfs2_uptodate_cache(); + exit_ocfs2_extent_maps(); + } + + mlog_exit(status); + + if (status >= 0) { + return register_filesystem(&ocfs2_fs_type); + } else + return -1; +} + +static void __exit ocfs2_exit(void) +{ + mlog_entry_void(); + + if (ocfs2_wq) { + flush_workqueue(ocfs2_wq); + destroy_workqueue(ocfs2_wq); + } + + debugfs_remove(ocfs2_debugfs_root); + + ocfs2_free_mem_caches(); + + unregister_filesystem(&ocfs2_fs_type); + + exit_ocfs2_extent_maps(); + + exit_ocfs2_uptodate_cache(); + + mlog_exit_void(); +} + +static void ocfs2_put_super(struct super_block *sb) +{ + mlog_entry("(0x%p)\n", sb); + + ocfs2_sync_blockdev(sb); + ocfs2_dismount_volume(sb, 0); + + mlog_exit_void(); +} + +static int ocfs2_statfs(struct super_block *sb, struct kstatfs *buf) +{ + struct ocfs2_super *osb; + u32 numbits, freebits; + int status; + struct ocfs2_dinode *bm_lock; + struct buffer_head *bh = NULL; + struct inode *inode = NULL; + + mlog_entry("(%p, %p)\n", sb, buf); + + osb = OCFS2_SB(sb); + + inode = ocfs2_get_system_file_inode(osb, + GLOBAL_BITMAP_SYSTEM_INODE, + OCFS2_INVALID_SLOT); + if (!inode) { + mlog(ML_ERROR, "failed to get bitmap inode\n"); + status = -EIO; + goto bail; + } + + status = ocfs2_meta_lock(inode, NULL, &bh, 0); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + bm_lock = (struct ocfs2_dinode *) bh->b_data; + + numbits = le32_to_cpu(bm_lock->id1.bitmap1.i_total); + freebits = numbits - le32_to_cpu(bm_lock->id1.bitmap1.i_used); + + buf->f_type = OCFS2_SUPER_MAGIC; + buf->f_bsize = sb->s_blocksize; + buf->f_namelen = OCFS2_MAX_FILENAME_LEN; + buf->f_blocks = ((sector_t) numbits) * + (osb->s_clustersize >> osb->sb->s_blocksize_bits); + buf->f_bfree = ((sector_t) freebits) * + (osb->s_clustersize >> osb->sb->s_blocksize_bits); + buf->f_bavail = buf->f_bfree; + buf->f_files = numbits; + buf->f_ffree = freebits; + + brelse(bh); + + ocfs2_meta_unlock(inode, 0); + status = 0; +bail: + if (inode) + iput(inode); + + mlog_exit(status); + + return status; +} + +static void ocfs2_inode_init_once(void *data, + kmem_cache_t *cachep, + unsigned long flags) +{ + struct ocfs2_inode_info *oi = data; + + if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == + SLAB_CTOR_CONSTRUCTOR) { + oi->ip_flags = 0; + oi->ip_open_count = 0; + spin_lock_init(&oi->ip_lock); + ocfs2_extent_map_init(&oi->vfs_inode); + INIT_LIST_HEAD(&oi->ip_handle_list); + INIT_LIST_HEAD(&oi->ip_io_markers); + oi->ip_handle = NULL; + oi->ip_created_trans = 0; + oi->ip_last_trans = 0; + oi->ip_dir_start_lookup = 0; + + init_rwsem(&oi->ip_alloc_sem); + init_MUTEX(&(oi->ip_io_sem)); + + oi->ip_blkno = 0ULL; + oi->ip_clusters = 0; + + ocfs2_lock_res_init_once(&oi->ip_rw_lockres); + ocfs2_lock_res_init_once(&oi->ip_meta_lockres); + ocfs2_lock_res_init_once(&oi->ip_data_lockres); + + ocfs2_metadata_cache_init(&oi->vfs_inode); + + inode_init_once(&oi->vfs_inode); + } +} + +static int ocfs2_initialize_mem_caches(void) +{ + ocfs2_inode_cachep = kmem_cache_create("ocfs2_inode_cache", + sizeof(struct ocfs2_inode_info), + 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT, + ocfs2_inode_init_once, NULL); + if (!ocfs2_inode_cachep) + return -ENOMEM; + + ocfs2_lock_cache = kmem_cache_create("ocfs2_lock", + sizeof(struct ocfs2_journal_lock), + 0, + SLAB_NO_REAP|SLAB_HWCACHE_ALIGN, + NULL, NULL); + if (!ocfs2_lock_cache) + return -ENOMEM; + + return 0; +} + +static void ocfs2_free_mem_caches(void) +{ + if (ocfs2_inode_cachep) + kmem_cache_destroy(ocfs2_inode_cachep); + if (ocfs2_lock_cache) + kmem_cache_destroy(ocfs2_lock_cache); + + ocfs2_inode_cachep = NULL; + ocfs2_lock_cache = NULL; +} + +static int ocfs2_get_sector(struct super_block *sb, + struct buffer_head **bh, + int block, + int sect_size) +{ + if (!sb_set_blocksize(sb, sect_size)) { + mlog(ML_ERROR, "unable to set blocksize\n"); + return -EIO; + } + + *bh = sb_getblk(sb, block); + if (!*bh) { + mlog_errno(-EIO); + return -EIO; + } + lock_buffer(*bh); + if (!buffer_dirty(*bh)) + clear_buffer_uptodate(*bh); + unlock_buffer(*bh); + ll_rw_block(READ, 1, bh); + wait_on_buffer(*bh); + return 0; +} + +/* ocfs2 1.0 only allows one cluster and node identity per kernel image. */ +static int ocfs2_fill_local_node_info(struct ocfs2_super *osb) +{ + int status; + + /* XXX hold a ref on the node while mounte? easy enough, if + * desirable. */ + osb->node_num = o2nm_this_node(); + if (osb->node_num == O2NM_MAX_NODES) { + mlog(ML_ERROR, "could not find this host's node number\n"); + status = -ENOENT; + goto bail; + } + + mlog(ML_NOTICE, "I am node %d\n", osb->node_num); + + status = 0; +bail: + return status; +} + +static int ocfs2_mount_volume(struct super_block *sb) +{ + int status = 0; + int unlock_super = 0; + struct ocfs2_super *osb = OCFS2_SB(sb); + + mlog_entry_void(); + + if (ocfs2_is_hard_readonly(osb)) + goto leave; + + status = ocfs2_fill_local_node_info(osb); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_register_hb_callbacks(osb); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_dlm_init(osb); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + /* requires vote_thread to be running. */ + status = ocfs2_register_net_handlers(osb); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_super_lock(osb, 1); + if (status < 0) { + mlog_errno(status); + goto leave; + } + unlock_super = 1; + + /* This will load up the node map and add ourselves to it. */ + status = ocfs2_find_slot(osb); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + ocfs2_populate_mounted_map(osb); + + /* load all node-local system inodes */ + status = ocfs2_init_local_system_inodes(osb); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_check_volume(osb); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + status = ocfs2_truncate_log_init(osb); + if (status < 0) { + mlog_errno(status); + goto leave; + } + + /* This should be sent *after* we recovered our journal as it + * will cause other nodes to unmark us as needing + * recovery. However, we need to send it *before* dropping the + * super block lock as otherwise their recovery threads might + * try to clean us up while we're live! */ + status = ocfs2_request_mount_vote(osb); + if (status < 0) + mlog_errno(status); + +leave: + if (unlock_super) + ocfs2_super_unlock(osb, 1); + + mlog_exit(status); + return status; +} + +/* we can't grab the goofy sem lock from inside wait_event, so we use + * memory barriers to make sure that we'll see the null task before + * being woken up */ +static int ocfs2_recovery_thread_running(struct ocfs2_super *osb) +{ + mb(); + return osb->recovery_thread_task != NULL; +} + +static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) +{ + int tmp; + struct ocfs2_super *osb = NULL; + + mlog_entry("(0x%p)\n", sb); + + BUG_ON(!sb); + osb = OCFS2_SB(sb); + BUG_ON(!osb); + + ocfs2_shutdown_local_alloc(osb); + + ocfs2_truncate_log_shutdown(osb); + + /* disable any new recovery threads and wait for any currently + * running ones to exit. Do this before setting the vol_state. */ + down(&osb->recovery_lock); + osb->disable_recovery = 1; + up(&osb->recovery_lock); + wait_event(osb->recovery_event, !ocfs2_recovery_thread_running(osb)); + + /* At this point, we know that no more recovery threads can be + * launched, so wait for any recovery completion work to + * complete. */ + flush_workqueue(ocfs2_wq); + + ocfs2_journal_shutdown(osb); + + ocfs2_sync_blockdev(sb); + + /* No dlm means we've failed during mount, so skip all the + * steps which depended on that to complete. */ + if (osb->dlm) { + tmp = ocfs2_super_lock(osb, 1); + if (tmp < 0) { + mlog_errno(tmp); + return; + } + + tmp = ocfs2_request_umount_vote(osb); + if (tmp < 0) + mlog_errno(tmp); + + if (osb->slot_num != OCFS2_INVALID_SLOT) + ocfs2_put_slot(osb); + + ocfs2_super_unlock(osb, 1); + } + + ocfs2_release_system_inodes(osb); + + if (osb->dlm) { + ocfs2_unregister_net_handlers(osb); + + ocfs2_dlm_shutdown(osb); + } + + ocfs2_clear_hb_callbacks(osb); + + debugfs_remove(osb->osb_debug_root); + + if (!mnt_err) + ocfs2_stop_heartbeat(osb); + + atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); + + printk("ocfs2: Unmounting device (%u,%u) on (node %d)\n", + MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev), osb->node_num); + + ocfs2_delete_osb(osb); + kfree(osb); + sb->s_dev = 0; + sb->s_fs_info = NULL; +} + +static int ocfs2_setup_osb_uuid(struct ocfs2_super *osb, const unsigned char *uuid, + unsigned uuid_bytes) +{ + int i, ret; + char *ptr; + + BUG_ON(uuid_bytes != OCFS2_VOL_UUID_LEN); + + osb->uuid_str = kcalloc(1, OCFS2_VOL_UUID_LEN * 2 + 1, GFP_KERNEL); + if (osb->uuid_str == NULL) + return -ENOMEM; + + memcpy(osb->uuid, uuid, OCFS2_VOL_UUID_LEN); + + for (i = 0, ptr = osb->uuid_str; i < OCFS2_VOL_UUID_LEN; i++) { + /* print with null */ + ret = snprintf(ptr, 3, "%02X", uuid[i]); + if (ret != 2) /* drop super cleans up */ + return -EINVAL; + /* then only advance past the last char */ + ptr += 2; + } + + return 0; +} + +static int ocfs2_initialize_super(struct super_block *sb, + struct buffer_head *bh, + int sector_size) +{ + int status = 0; + int i; + struct ocfs2_dinode *di = NULL; + struct inode *inode = NULL; + struct buffer_head *bitmap_bh = NULL; + struct ocfs2_journal *journal; + __le32 uuid_net_key; + struct ocfs2_super *osb; + + mlog_entry_void(); + + osb = kcalloc(1, sizeof(struct ocfs2_super), GFP_KERNEL); + if (!osb) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + sb->s_fs_info = osb; + sb->s_op = &ocfs2_sops; + sb->s_export_op = &ocfs2_export_ops; + sb->s_flags |= MS_NOATIME; + /* this is needed to support O_LARGEFILE */ + sb->s_maxbytes = ocfs2_max_file_offset(sb->s_blocksize_bits); + + osb->sb = sb; + /* Save off for ocfs2_rw_direct */ + osb->s_sectsize_bits = blksize_bits(sector_size); + if (!osb->s_sectsize_bits) + BUG(); + + osb->net_response_ids = 0; + spin_lock_init(&osb->net_response_lock); + INIT_LIST_HEAD(&osb->net_response_list); + + INIT_LIST_HEAD(&osb->osb_net_handlers); + init_waitqueue_head(&osb->recovery_event); + spin_lock_init(&osb->vote_task_lock); + init_waitqueue_head(&osb->vote_event); + osb->vote_work_sequence = 0; + osb->vote_wake_sequence = 0; + INIT_LIST_HEAD(&osb->blocked_lock_list); + osb->blocked_lock_count = 0; + INIT_LIST_HEAD(&osb->vote_list); + spin_lock_init(&osb->osb_lock); + + atomic_set(&osb->alloc_stats.moves, 0); + atomic_set(&osb->alloc_stats.local_data, 0); + atomic_set(&osb->alloc_stats.bitmap_data, 0); + atomic_set(&osb->alloc_stats.bg_allocs, 0); + atomic_set(&osb->alloc_stats.bg_extends, 0); + + ocfs2_init_node_maps(osb); + + snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u", + MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); + + init_MUTEX(&osb->recovery_lock); + + osb->disable_recovery = 0; + osb->recovery_thread_task = NULL; + + init_waitqueue_head(&osb->checkpoint_event); + atomic_set(&osb->needs_checkpoint, 0); + + osb->node_num = O2NM_INVALID_NODE_NUM; + osb->slot_num = OCFS2_INVALID_SLOT; + + osb->local_alloc_state = OCFS2_LA_UNUSED; + osb->local_alloc_bh = NULL; + + ocfs2_setup_hb_callbacks(osb); + + init_waitqueue_head(&osb->osb_mount_event); + + osb->vol_label = kmalloc(OCFS2_MAX_VOL_LABEL_LEN, GFP_KERNEL); + if (!osb->vol_label) { + mlog(ML_ERROR, "unable to alloc vol label\n"); + status = -ENOMEM; + goto bail; + } + + osb->uuid = kmalloc(OCFS2_VOL_UUID_LEN, GFP_KERNEL); + if (!osb->uuid) { + mlog(ML_ERROR, "unable to alloc uuid\n"); + status = -ENOMEM; + goto bail; + } + + di = (struct ocfs2_dinode *)bh->b_data; + + osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots); + if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) { + mlog(ML_ERROR, "Invalid number of node slots (%u)\n", + osb->max_slots); + status = -EINVAL; + goto bail; + } + mlog(ML_NOTICE, "max_slots for this device: %u\n", osb->max_slots); + + osb->s_feature_compat = + le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_compat); + osb->s_feature_ro_compat = + le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_ro_compat); + osb->s_feature_incompat = + le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_incompat); + + if ((i = OCFS2_HAS_INCOMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_INCOMPAT_SUPP))) { + mlog(ML_ERROR, "couldn't mount because of unsupported " + "optional features (%x).\n", i); + status = -EINVAL; + goto bail; + } + if (!(osb->sb->s_flags & MS_RDONLY) && + (i = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP))) { + mlog(ML_ERROR, "couldn't mount RDWR because of " + "unsupported optional features (%x).\n", i); + status = -EINVAL; + goto bail; + } + + get_random_bytes(&osb->s_next_generation, sizeof(u32)); + + /* FIXME + * This should be done in ocfs2_journal_init(), but unknown + * ordering issues will cause the filesystem to crash. + * If anyone wants to figure out what part of the code + * refers to osb->journal before ocfs2_journal_init() is run, + * be my guest. + */ + /* initialize our journal structure */ + + journal = kcalloc(1, sizeof(struct ocfs2_journal), GFP_KERNEL); + if (!journal) { + mlog(ML_ERROR, "unable to alloc journal\n"); + status = -ENOMEM; + goto bail; + } + osb->journal = journal; + journal->j_osb = osb; + + atomic_set(&journal->j_num_trans, 0); + init_rwsem(&journal->j_trans_barrier); + init_waitqueue_head(&journal->j_checkpointed); + spin_lock_init(&journal->j_lock); + journal->j_trans_id = (unsigned long) 1; + INIT_LIST_HEAD(&journal->j_la_cleanups); + INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery, osb); + journal->j_state = OCFS2_JOURNAL_FREE; + + /* get some pseudo constants for clustersize bits */ + osb->s_clustersize_bits = + le32_to_cpu(di->id2.i_super.s_clustersize_bits); + osb->s_clustersize = 1 << osb->s_clustersize_bits; + mlog(0, "clusterbits=%d\n", osb->s_clustersize_bits); + + if (osb->s_clustersize < OCFS2_MIN_CLUSTERSIZE || + osb->s_clustersize > OCFS2_MAX_CLUSTERSIZE) { + mlog(ML_ERROR, "Volume has invalid cluster size (%d)\n", + osb->s_clustersize); + status = -EINVAL; + goto bail; + } + + if (ocfs2_clusters_to_blocks(osb->sb, le32_to_cpu(di->i_clusters) - 1) + > (u32)~0UL) { + mlog(ML_ERROR, "Volume might try to write to blocks beyond " + "what jbd can address in 32 bits.\n"); + status = -EINVAL; + goto bail; + } + + if (ocfs2_setup_osb_uuid(osb, di->id2.i_super.s_uuid, + sizeof(di->id2.i_super.s_uuid))) { + mlog(ML_ERROR, "Out of memory trying to setup our uuid.\n"); + status = -ENOMEM; + goto bail; + } + + memcpy(&uuid_net_key, &osb->uuid[i], sizeof(osb->net_key)); + osb->net_key = le32_to_cpu(uuid_net_key); + + strncpy(osb->vol_label, di->id2.i_super.s_label, 63); + osb->vol_label[63] = '\0'; + osb->root_blkno = le64_to_cpu(di->id2.i_super.s_root_blkno); + osb->system_dir_blkno = le64_to_cpu(di->id2.i_super.s_system_dir_blkno); + osb->first_cluster_group_blkno = + le64_to_cpu(di->id2.i_super.s_first_cluster_group); + osb->fs_generation = le32_to_cpu(di->i_fs_generation); + mlog(0, "vol_label: %s\n", osb->vol_label); + mlog(0, "uuid: %s\n", osb->uuid_str); + mlog(0, "root_blkno=%"MLFu64", system_dir_blkno=%"MLFu64"\n", + osb->root_blkno, osb->system_dir_blkno); + + osb->osb_dlm_debug = ocfs2_new_dlm_debug(); + if (!osb->osb_dlm_debug) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + atomic_set(&osb->vol_state, VOLUME_INIT); + + /* load root, system_dir, and all global system inodes */ + status = ocfs2_init_global_system_inodes(osb); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* + * global bitmap + */ + inode = ocfs2_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, + OCFS2_INVALID_SLOT); + if (!inode) { + status = -EINVAL; + mlog_errno(status); + goto bail; + } + + osb->bitmap_blkno = OCFS2_I(inode)->ip_blkno; + + status = ocfs2_read_block(osb, osb->bitmap_blkno, &bitmap_bh, 0, + inode); + iput(inode); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + di = (struct ocfs2_dinode *) bitmap_bh->b_data; + osb->bitmap_cpg = le16_to_cpu(di->id2.i_chain.cl_cpg); + osb->num_clusters = le32_to_cpu(di->id1.bitmap1.i_total); + brelse(bitmap_bh); + mlog(0, "cluster bitmap inode: %"MLFu64", clusters per group: %u\n", + osb->bitmap_blkno, osb->bitmap_cpg); + + status = ocfs2_init_slot_info(osb); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + /* Link this osb onto the global linked list of all osb structures. */ + /* The Global Link List is mainted for the whole driver . */ + spin_lock(&ocfs2_globals_lock); + osb->osb_id = osb_id; + if (osb_id < OCFS2_MAX_OSB_ID) + osb_id++; + else { + mlog(ML_ERROR, "Too many volumes mounted\n"); + status = -ENOMEM; + } + spin_unlock(&ocfs2_globals_lock); + +bail: + mlog_exit(status); + return status; +} + +/* + * will return: -EAGAIN if it is ok to keep searching for superblocks + * -EINVAL if there is a bad superblock + * 0 on success + */ +static int ocfs2_verify_volume(struct ocfs2_dinode *di, + struct buffer_head *bh, + u32 blksz) +{ + int status = -EAGAIN; + + mlog_entry_void(); + + if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE, + strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) { + status = -EINVAL; + if ((1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits)) != blksz) { + mlog(ML_ERROR, "found superblock with incorrect block " + "size: found %u, should be %u\n", + 1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits), + blksz); + } else if (le16_to_cpu(di->id2.i_super.s_major_rev_level) != + OCFS2_MAJOR_REV_LEVEL || + le16_to_cpu(di->id2.i_super.s_minor_rev_level) != + OCFS2_MINOR_REV_LEVEL) { + mlog(ML_ERROR, "found superblock with bad version: " + "found %u.%u, should be %u.%u\n", + le16_to_cpu(di->id2.i_super.s_major_rev_level), + le16_to_cpu(di->id2.i_super.s_minor_rev_level), + OCFS2_MAJOR_REV_LEVEL, + OCFS2_MINOR_REV_LEVEL); + } else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) { + mlog(ML_ERROR, "bad block number on superblock: " + "found %"MLFu64", should be %llu\n", + di->i_blkno, (unsigned long long)bh->b_blocknr); + } else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 || + le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) { + mlog(ML_ERROR, "bad cluster size found: %u\n", + 1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits)); + } else if (!le64_to_cpu(di->id2.i_super.s_root_blkno)) { + mlog(ML_ERROR, "bad root_blkno: 0\n"); + } else if (!le64_to_cpu(di->id2.i_super.s_system_dir_blkno)) { + mlog(ML_ERROR, "bad system_dir_blkno: 0\n"); + } else if (le16_to_cpu(di->id2.i_super.s_max_slots) > OCFS2_MAX_SLOTS) { + mlog(ML_ERROR, + "Superblock slots found greater than file system " + "maximum: found %u, max %u\n", + le16_to_cpu(di->id2.i_super.s_max_slots), + OCFS2_MAX_SLOTS); + } else { + /* found it! */ + status = 0; + } + } + + mlog_exit(status); + return status; +} + +static int ocfs2_check_volume(struct ocfs2_super *osb) +{ + int status = 0; + int dirty; + struct ocfs2_dinode *local_alloc = NULL; /* only used if we + * recover + * ourselves. */ + + mlog_entry_void(); + + /* Init our journal object. */ + status = ocfs2_journal_init(osb->journal, &dirty); + if (status < 0) { + mlog(ML_ERROR, "Could not initialize journal!\n"); + goto finally; + } + + /* If the journal was unmounted cleanly then we don't want to + * recover anything. Otherwise, journal_load will do that + * dirty work for us :) */ + if (!dirty) { + status = ocfs2_journal_wipe(osb->journal, 0); + if (status < 0) { + mlog_errno(status); + goto finally; + } + } else { + mlog(ML_NOTICE, "File system was not unmounted cleanly, " + "recovering volume.\n"); + } + + /* will play back anything left in the journal. */ + ocfs2_journal_load(osb->journal); + + if (dirty) { + /* recover my local alloc if we didn't unmount cleanly. */ + status = ocfs2_begin_local_alloc_recovery(osb, + osb->slot_num, + &local_alloc); + if (status < 0) { + mlog_errno(status); + goto finally; + } + /* we complete the recovery process after we've marked + * ourselves as mounted. */ + } + + mlog(0, "Journal loaded.\n"); + + status = ocfs2_load_local_alloc(osb); + if (status < 0) { + mlog_errno(status); + goto finally; + } + + if (dirty) { + /* Recovery will be completed after we've mounted the + * rest of the volume. */ + osb->dirty = 1; + osb->local_alloc_copy = local_alloc; + local_alloc = NULL; + } + + /* go through each journal, trylock it and if you get the + * lock, and it's marked as dirty, set the bit in the recover + * map and launch a recovery thread for it. */ + status = ocfs2_mark_dead_nodes(osb); + if (status < 0) + mlog_errno(status); + +finally: + if (local_alloc) + kfree(local_alloc); + + mlog_exit(status); + return status; +} + +/* + * The routine gets called from dismount or close whenever a dismount on + * volume is requested and the osb open count becomes 1. + * It will remove the osb from the global list and also free up all the + * initialized resources and fileobject. + */ +static void ocfs2_delete_osb(struct ocfs2_super *osb) +{ + mlog_entry_void(); + + /* This function assumes that the caller has the main osb resource */ + + if (osb->slot_info) + ocfs2_free_slot_info(osb->slot_info); + + /* FIXME + * This belongs in journal shutdown, but because we have to + * allocate osb->journal at the start of ocfs2_initalize_osb(), + * we free it here. + */ + kfree(osb->journal); + if (osb->local_alloc_copy) + kfree(osb->local_alloc_copy); + kfree(osb->uuid_str); + ocfs2_put_dlm_debug(osb->osb_dlm_debug); + memset(osb, 0, sizeof(struct ocfs2_super)); + + mlog_exit_void(); +} + +/* Put OCFS2 into a readonly state, or (if the user specifies it), + * panic(). We do not support continue-on-error operation. */ +static void ocfs2_handle_error(struct super_block *sb) +{ + struct ocfs2_super *osb = OCFS2_SB(sb); + + if (osb->s_mount_opt & OCFS2_MOUNT_ERRORS_PANIC) + panic("OCFS2: (device %s): panic forced after error\n", + sb->s_id); + + ocfs2_set_osb_flag(osb, OCFS2_OSB_ERROR_FS); + + if (sb->s_flags & MS_RDONLY && + (ocfs2_is_soft_readonly(osb) || + ocfs2_is_hard_readonly(osb))) + return; + + printk(KERN_CRIT "File system is now read-only due to the potential " + "of on-disk corruption. Please run fsck.ocfs2 once the file " + "system is unmounted.\n"); + sb->s_flags |= MS_RDONLY; + ocfs2_set_ro_flag(osb, 0); +} + +static char error_buf[1024]; + +void __ocfs2_error(struct super_block *sb, + const char *function, + const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vsprintf(error_buf, fmt, args); + va_end(args); + + /* Not using mlog here because we want to show the actual + * function the error came from. */ + printk(KERN_CRIT "OCFS2: ERROR (device %s): %s: %s\n", + sb->s_id, function, error_buf); + + ocfs2_handle_error(sb); +} + +/* Handle critical errors. This is intentionally more drastic than + * ocfs2_handle_error, so we only use for things like journal errors, + * etc. */ +void __ocfs2_abort(struct super_block* sb, + const char *function, + const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vsprintf(error_buf, fmt, args); + va_end(args); + + printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n", + sb->s_id, function, error_buf); + + /* We don't have the cluster support yet to go straight to + * hard readonly in here. Until then, we want to keep + * ocfs2_abort() so that we can at least mark critical + * errors. + * + * TODO: This should abort the journal and alert other nodes + * that our slot needs recovery. */ + + /* Force a panic(). This stinks, but it's better than letting + * things continue without having a proper hard readonly + * here. */ + OCFS2_SB(sb)->s_mount_opt |= OCFS2_MOUNT_ERRORS_PANIC; + ocfs2_handle_error(sb); +} + +module_init(ocfs2_init); +module_exit(ocfs2_exit); diff --git a/fs/ocfs2/super.h b/fs/ocfs2/super.h new file mode 100644 index 0000000..c564177 --- /dev/null +++ b/fs/ocfs2/super.h @@ -0,0 +1,44 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * super.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_SUPER_H +#define OCFS2_SUPER_H + +extern struct workqueue_struct *ocfs2_wq; + +int ocfs2_publish_get_mount_state(struct ocfs2_super *osb, + int node_num); + +void __ocfs2_error(struct super_block *sb, + const char *function, + const char *fmt, ...); +#define ocfs2_error(sb, fmt, args...) __ocfs2_error(sb, __PRETTY_FUNCTION__, fmt, ##args) + +void __ocfs2_abort(struct super_block *sb, + const char *function, + const char *fmt, ...); +#define ocfs2_abort(sb, fmt, args...) __ocfs2_abort(sb, __PRETTY_FUNCTION__, fmt, ##args) + +#endif /* OCFS2_SUPER_H */ diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c new file mode 100644 index 0000000..f6986bd --- /dev/null +++ b/fs/ocfs2/symlink.c @@ -0,0 +1,180 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * linux/cluster/ssi/cfs/symlink.c + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE + * or NON INFRINGEMENT. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Questions/Comments/Bugfixes to ssic-linux-devel@lists.sourceforge.net + * + * Copyright (C) 1992 Rick Sladkey + * + * Optimization changes Copyright (C) 1994 Florian La Roche + * + * Jun 7 1999, cache symlink lookups in the page cache. -DaveM + * + * Portions Copyright (C) 2001 Compaq Computer Corporation + * + * ocfs2 symlink handling code. + * + * Copyright (C) 2004, 2005 Oracle. + * + */ + +#include +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_NAMEI +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "file.h" +#include "inode.h" +#include "journal.h" +#include "symlink.h" + +#include "buffer_head_io.h" + +static char *ocfs2_page_getlink(struct dentry * dentry, + struct page **ppage); +static char *ocfs2_fast_symlink_getlink(struct inode *inode, + struct buffer_head **bh); + +/* get the link contents into pagecache */ +static char *ocfs2_page_getlink(struct dentry * dentry, + struct page **ppage) +{ + struct page * page; + struct address_space *mapping = dentry->d_inode->i_mapping; + page = read_cache_page(mapping, 0, + (filler_t *)mapping->a_ops->readpage, NULL); + if (IS_ERR(page)) + goto sync_fail; + wait_on_page_locked(page); + if (!PageUptodate(page)) + goto async_fail; + *ppage = page; + return kmap(page); + +async_fail: + page_cache_release(page); + return ERR_PTR(-EIO); + +sync_fail: + return (char*)page; +} + +static char *ocfs2_fast_symlink_getlink(struct inode *inode, + struct buffer_head **bh) +{ + int status; + char *link = NULL; + struct ocfs2_dinode *fe; + + mlog_entry_void(); + + status = ocfs2_read_block(OCFS2_SB(inode->i_sb), + OCFS2_I(inode)->ip_blkno, + bh, + OCFS2_BH_CACHED, + inode); + if (status < 0) { + mlog_errno(status); + link = ERR_PTR(status); + goto bail; + } + + fe = (struct ocfs2_dinode *) (*bh)->b_data; + link = (char *) fe->id2.i_symlink; +bail: + mlog_exit(status); + + return link; +} + +static int ocfs2_readlink(struct dentry *dentry, + char __user *buffer, + int buflen) +{ + int ret; + char *link; + struct buffer_head *bh = NULL; + struct inode *inode = dentry->d_inode; + + mlog_entry_void(); + + link = ocfs2_fast_symlink_getlink(inode, &bh); + if (IS_ERR(link)) { + ret = PTR_ERR(link); + goto out; + } + + ret = vfs_readlink(dentry, buffer, buflen, link); + + brelse(bh); +out: + mlog_exit(ret); + return ret; +} + +static void *ocfs2_follow_link(struct dentry *dentry, + struct nameidata *nd) +{ + int status; + char *link; + struct inode *inode = dentry->d_inode; + struct page *page = NULL; + struct buffer_head *bh = NULL; + + if (ocfs2_inode_is_fast_symlink(inode)) + link = ocfs2_fast_symlink_getlink(inode, &bh); + else + link = ocfs2_page_getlink(dentry, &page); + if (IS_ERR(link)) { + status = PTR_ERR(link); + mlog_errno(status); + goto bail; + } + + status = vfs_follow_link(nd, link); + if (status) + mlog_errno(status); +bail: + if (page) { + kunmap(page); + page_cache_release(page); + } + if (bh) + brelse(bh); + + return ERR_PTR(status); +} + +struct inode_operations ocfs2_symlink_inode_operations = { + .readlink = page_readlink, + .follow_link = ocfs2_follow_link, + .getattr = ocfs2_getattr, +}; +struct inode_operations ocfs2_fast_symlink_inode_operations = { + .readlink = ocfs2_readlink, + .follow_link = ocfs2_follow_link, + .getattr = ocfs2_getattr, +}; diff --git a/fs/ocfs2/symlink.h b/fs/ocfs2/symlink.h new file mode 100644 index 0000000..1ea9e4d --- /dev/null +++ b/fs/ocfs2/symlink.h @@ -0,0 +1,42 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * symlink.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_SYMLINK_H +#define OCFS2_SYMLINK_H + +extern struct inode_operations ocfs2_symlink_inode_operations; +extern struct inode_operations ocfs2_fast_symlink_inode_operations; + +/* + * Test whether an inode is a fast symlink. + */ +static inline int ocfs2_inode_is_fast_symlink(struct inode *inode) +{ + return (S_ISLNK(inode->i_mode) && + inode->i_blocks == 0); +} + + +#endif /* OCFS2_SYMLINK_H */ diff --git a/fs/ocfs2/sysfile.c b/fs/ocfs2/sysfile.c new file mode 100644 index 0000000..600a8bc5 --- /dev/null +++ b/fs/ocfs2/sysfile.c @@ -0,0 +1,131 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * sysfile.c + * + * Initialize, read, write, etc. system files. + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include + +#include "ocfs2.h" + +#define MLOG_MASK_PREFIX ML_INODE +#include + +#include "alloc.h" +#include "dir.h" +#include "inode.h" +#include "journal.h" +#include "sysfile.h" + +#include "buffer_head_io.h" + +static struct inode * _ocfs2_get_system_file_inode(struct ocfs2_super *osb, + int type, + u32 slot); + +static inline int is_global_system_inode(int type); +static inline int is_in_system_inode_array(struct ocfs2_super *osb, + int type, + u32 slot); + +static inline int is_global_system_inode(int type) +{ + return type >= OCFS2_FIRST_ONLINE_SYSTEM_INODE && + type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE; +} + +static inline int is_in_system_inode_array(struct ocfs2_super *osb, + int type, + u32 slot) +{ + return slot == osb->slot_num || is_global_system_inode(type); +} + +struct inode *ocfs2_get_system_file_inode(struct ocfs2_super *osb, + int type, + u32 slot) +{ + struct inode *inode = NULL; + struct inode **arr = NULL; + + /* avoid the lookup if cached in local system file array */ + if (is_in_system_inode_array(osb, type, slot)) + arr = &(osb->system_inodes[type]); + + if (arr && ((inode = *arr) != NULL)) { + /* get a ref in addition to the array ref */ + inode = igrab(inode); + if (!inode) + BUG(); + + return inode; + } + + /* this gets one ref thru iget */ + inode = _ocfs2_get_system_file_inode(osb, type, slot); + + /* add one more if putting into array for first time */ + if (arr && inode) { + *arr = igrab(inode); + if (!*arr) + BUG(); + } + return inode; +} + +static struct inode * _ocfs2_get_system_file_inode(struct ocfs2_super *osb, + int type, + u32 slot) +{ + char namebuf[40]; + struct inode *inode = NULL; + u64 blkno; + struct buffer_head *dirent_bh = NULL; + struct ocfs2_dir_entry *de = NULL; + int status = 0; + + ocfs2_sprintf_system_inode_name(namebuf, + sizeof(namebuf), + type, slot); + + status = ocfs2_find_files_on_disk(namebuf, strlen(namebuf), + &blkno, osb->sys_root_inode, + &dirent_bh, &de); + if (status < 0) { + goto bail; + } + + inode = ocfs2_iget(osb, blkno); + if (IS_ERR(inode)) { + mlog_errno(PTR_ERR(inode)); + inode = NULL; + goto bail; + } +bail: + if (dirent_bh) + brelse(dirent_bh); + return inode; +} + diff --git a/fs/ocfs2/sysfile.h b/fs/ocfs2/sysfile.h new file mode 100644 index 0000000..cc9ea66 --- /dev/null +++ b/fs/ocfs2/sysfile.h @@ -0,0 +1,33 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * sysfile.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_SYSFILE_H +#define OCFS2_SYSFILE_H + +struct inode * ocfs2_get_system_file_inode(struct ocfs2_super *osb, + int type, + u32 slot); + +#endif /* OCFS2_SYSFILE_H */ diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c new file mode 100644 index 0000000..3a0458f --- /dev/null +++ b/fs/ocfs2/uptodate.c @@ -0,0 +1,544 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * uptodate.c + * + * Tracking the up-to-date-ness of a local buffer_head with respect to + * the cluster. + * + * Copyright (C) 2002, 2004, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + * + * Standard buffer head caching flags (uptodate, etc) are insufficient + * in a clustered environment - a buffer may be marked up to date on + * our local node but could have been modified by another cluster + * member. As a result an additional (and performant) caching scheme + * is required. A further requirement is that we consume as little + * memory as possible - we never pin buffer_head structures in order + * to cache them. + * + * We track the existence of up to date buffers on the inodes which + * are associated with them. Because we don't want to pin + * buffer_heads, this is only a (strong) hint and several other checks + * are made in the I/O path to ensure that we don't use a stale or + * invalid buffer without going to disk: + * - buffer_jbd is used liberally - if a bh is in the journal on + * this node then it *must* be up to date. + * - the standard buffer_uptodate() macro is used to detect buffers + * which may be invalid (even if we have an up to date tracking + * item for them) + * + * For a full understanding of how this code works together, one + * should read the callers in dlmglue.c, the I/O functions in + * buffer_head_io.c and ocfs2_journal_access in journal.c + */ + +#include +#include +#include +#include +#include +#include +#include + +#define MLOG_MASK_PREFIX ML_UPTODATE + +#include + +#include "ocfs2.h" + +#include "inode.h" +#include "uptodate.h" + +struct ocfs2_meta_cache_item { + struct rb_node c_node; + sector_t c_block; +}; + +static kmem_cache_t *ocfs2_uptodate_cachep = NULL; + +void ocfs2_metadata_cache_init(struct inode *inode) +{ + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; + + oi->ip_flags |= OCFS2_INODE_CACHE_INLINE; + ci->ci_num_cached = 0; +} + +/* No lock taken here as 'root' is not expected to be visible to other + * processes. */ +static unsigned int ocfs2_purge_copied_metadata_tree(struct rb_root *root) +{ + unsigned int purged = 0; + struct rb_node *node; + struct ocfs2_meta_cache_item *item; + + while ((node = rb_last(root)) != NULL) { + item = rb_entry(node, struct ocfs2_meta_cache_item, c_node); + + mlog(0, "Purge item %llu\n", + (unsigned long long) item->c_block); + + rb_erase(&item->c_node, root); + kmem_cache_free(ocfs2_uptodate_cachep, item); + + purged++; + } + return purged; +} + +/* Called from locking and called from ocfs2_clear_inode. Dump the + * cache for a given inode. + * + * This function is a few more lines longer than necessary due to some + * accounting done here, but I think it's worth tracking down those + * bugs sooner -- Mark */ +void ocfs2_metadata_cache_purge(struct inode *inode) +{ + struct ocfs2_inode_info *oi = OCFS2_I(inode); + unsigned int tree, to_purge, purged; + struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; + struct rb_root root = RB_ROOT; + + spin_lock(&oi->ip_lock); + tree = !(oi->ip_flags & OCFS2_INODE_CACHE_INLINE); + to_purge = ci->ci_num_cached; + + mlog(0, "Purge %u %s items from Inode %"MLFu64"\n", to_purge, + tree ? "array" : "tree", oi->ip_blkno); + + /* If we're a tree, save off the root so that we can safely + * initialize the cache. We do the work to free tree members + * without the spinlock. */ + if (tree) + root = ci->ci_cache.ci_tree; + + ocfs2_metadata_cache_init(inode); + spin_unlock(&oi->ip_lock); + + purged = ocfs2_purge_copied_metadata_tree(&root); + /* If possible, track the number wiped so that we can more + * easily detect counting errors. Unfortunately, this is only + * meaningful for trees. */ + if (tree && purged != to_purge) + mlog(ML_ERROR, "Inode %"MLFu64", count = %u, purged = %u\n", + oi->ip_blkno, to_purge, purged); +} + +/* Returns the index in the cache array, -1 if not found. + * Requires ip_lock. */ +static int ocfs2_search_cache_array(struct ocfs2_caching_info *ci, + sector_t item) +{ + int i; + + for (i = 0; i < ci->ci_num_cached; i++) { + if (item == ci->ci_cache.ci_array[i]) + return i; + } + + return -1; +} + +/* Returns the cache item if found, otherwise NULL. + * Requires ip_lock. */ +static struct ocfs2_meta_cache_item * +ocfs2_search_cache_tree(struct ocfs2_caching_info *ci, + sector_t block) +{ + struct rb_node * n = ci->ci_cache.ci_tree.rb_node; + struct ocfs2_meta_cache_item *item = NULL; + + while (n) { + item = rb_entry(n, struct ocfs2_meta_cache_item, c_node); + + if (block < item->c_block) + n = n->rb_left; + else if (block > item->c_block) + n = n->rb_right; + else + return item; + } + + return NULL; +} + +static int ocfs2_buffer_cached(struct ocfs2_inode_info *oi, + struct buffer_head *bh) +{ + int index = -1; + struct ocfs2_meta_cache_item *item = NULL; + + spin_lock(&oi->ip_lock); + + mlog(0, "Inode %"MLFu64", query block %llu (inline = %u)\n", + oi->ip_blkno, (unsigned long long) bh->b_blocknr, + !!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE)); + + if (oi->ip_flags & OCFS2_INODE_CACHE_INLINE) + index = ocfs2_search_cache_array(&oi->ip_metadata_cache, + bh->b_blocknr); + else + item = ocfs2_search_cache_tree(&oi->ip_metadata_cache, + bh->b_blocknr); + + spin_unlock(&oi->ip_lock); + + mlog(0, "index = %d, item = %p\n", index, item); + + return (index != -1) || (item != NULL); +} + +/* Warning: even if it returns true, this does *not* guarantee that + * the block is stored in our inode metadata cache. */ +int ocfs2_buffer_uptodate(struct inode *inode, + struct buffer_head *bh) +{ + /* Doesn't matter if the bh is in our cache or not -- if it's + * not marked uptodate then we know it can't have correct + * data. */ + if (!buffer_uptodate(bh)) + return 0; + + /* OCFS2 does not allow multiple nodes to be changing the same + * block at the same time. */ + if (buffer_jbd(bh)) + return 1; + + /* Ok, locally the buffer is marked as up to date, now search + * our cache to see if we can trust that. */ + return ocfs2_buffer_cached(OCFS2_I(inode), bh); +} + +/* Requires ip_lock */ +static void ocfs2_append_cache_array(struct ocfs2_caching_info *ci, + sector_t block) +{ + BUG_ON(ci->ci_num_cached >= OCFS2_INODE_MAX_CACHE_ARRAY); + + mlog(0, "block %llu takes position %u\n", (unsigned long long) block, + ci->ci_num_cached); + + ci->ci_cache.ci_array[ci->ci_num_cached] = block; + ci->ci_num_cached++; +} + +/* By now the caller should have checked that the item does *not* + * exist in the tree. + * Requires ip_lock. */ +static void __ocfs2_insert_cache_tree(struct ocfs2_caching_info *ci, + struct ocfs2_meta_cache_item *new) +{ + sector_t block = new->c_block; + struct rb_node *parent = NULL; + struct rb_node **p = &ci->ci_cache.ci_tree.rb_node; + struct ocfs2_meta_cache_item *tmp; + + mlog(0, "Insert block %llu num = %u\n", (unsigned long long) block, + ci->ci_num_cached); + + while(*p) { + parent = *p; + + tmp = rb_entry(parent, struct ocfs2_meta_cache_item, c_node); + + if (block < tmp->c_block) + p = &(*p)->rb_left; + else if (block > tmp->c_block) + p = &(*p)->rb_right; + else { + /* This should never happen! */ + mlog(ML_ERROR, "Duplicate block %llu cached!\n", + (unsigned long long) block); + BUG(); + } + } + + rb_link_node(&new->c_node, parent, p); + rb_insert_color(&new->c_node, &ci->ci_cache.ci_tree); + ci->ci_num_cached++; +} + +static inline int ocfs2_insert_can_use_array(struct ocfs2_inode_info *oi, + struct ocfs2_caching_info *ci) +{ + assert_spin_locked(&oi->ip_lock); + + return (oi->ip_flags & OCFS2_INODE_CACHE_INLINE) && + (ci->ci_num_cached < OCFS2_INODE_MAX_CACHE_ARRAY); +} + +/* tree should be exactly OCFS2_INODE_MAX_CACHE_ARRAY wide. NULL the + * pointers in tree after we use them - this allows caller to detect + * when to free in case of error. */ +static void ocfs2_expand_cache(struct ocfs2_inode_info *oi, + struct ocfs2_meta_cache_item **tree) +{ + int i; + struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; + + mlog_bug_on_msg(ci->ci_num_cached != OCFS2_INODE_MAX_CACHE_ARRAY, + "Inode %"MLFu64", num cached = %u, should be %u\n", + oi->ip_blkno, ci->ci_num_cached, + OCFS2_INODE_MAX_CACHE_ARRAY); + mlog_bug_on_msg(!(oi->ip_flags & OCFS2_INODE_CACHE_INLINE), + "Inode %"MLFu64" not marked as inline anymore!\n", + oi->ip_blkno); + assert_spin_locked(&oi->ip_lock); + + /* Be careful to initialize the tree members *first* because + * once the ci_tree is used, the array is junk... */ + for(i = 0; i < OCFS2_INODE_MAX_CACHE_ARRAY; i++) + tree[i]->c_block = ci->ci_cache.ci_array[i]; + + oi->ip_flags &= ~OCFS2_INODE_CACHE_INLINE; + ci->ci_cache.ci_tree = RB_ROOT; + /* this will be set again by __ocfs2_insert_cache_tree */ + ci->ci_num_cached = 0; + + for(i = 0; i < OCFS2_INODE_MAX_CACHE_ARRAY; i++) { + __ocfs2_insert_cache_tree(ci, tree[i]); + tree[i] = NULL; + } + + mlog(0, "Expanded %"MLFu64" to a tree cache: flags 0x%x, num = %u\n", + oi->ip_blkno, oi->ip_flags, ci->ci_num_cached); +} + +/* Slow path function - memory allocation is necessary. See the + * comment above ocfs2_set_buffer_uptodate for more information. */ +static void __ocfs2_set_buffer_uptodate(struct ocfs2_inode_info *oi, + sector_t block, + int expand_tree) +{ + int i; + struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; + struct ocfs2_meta_cache_item *new = NULL; + struct ocfs2_meta_cache_item *tree[OCFS2_INODE_MAX_CACHE_ARRAY] = + { NULL, }; + + mlog(0, "Inode %"MLFu64", block %llu, expand = %d\n", + oi->ip_blkno, (unsigned long long) block, expand_tree); + + new = kmem_cache_alloc(ocfs2_uptodate_cachep, GFP_KERNEL); + if (!new) { + mlog_errno(-ENOMEM); + return; + } + new->c_block = block; + + if (expand_tree) { + /* Do *not* allocate an array here - the removal code + * has no way of tracking that. */ + for(i = 0; i < OCFS2_INODE_MAX_CACHE_ARRAY; i++) { + tree[i] = kmem_cache_alloc(ocfs2_uptodate_cachep, + GFP_KERNEL); + if (!tree[i]) { + mlog_errno(-ENOMEM); + goto out_free; + } + + /* These are initialized in ocfs2_expand_cache! */ + } + } + + spin_lock(&oi->ip_lock); + if (ocfs2_insert_can_use_array(oi, ci)) { + mlog(0, "Someone cleared the tree underneath us\n"); + /* Ok, items were removed from the cache in between + * locks. Detect this and revert back to the fast path */ + ocfs2_append_cache_array(ci, block); + spin_unlock(&oi->ip_lock); + goto out_free; + } + + if (expand_tree) + ocfs2_expand_cache(oi, tree); + + __ocfs2_insert_cache_tree(ci, new); + spin_unlock(&oi->ip_lock); + + new = NULL; +out_free: + if (new) + kmem_cache_free(ocfs2_uptodate_cachep, new); + + /* If these were used, then ocfs2_expand_cache re-set them to + * NULL for us. */ + if (tree[0]) { + for(i = 0; i < OCFS2_INODE_MAX_CACHE_ARRAY; i++) + if (tree[i]) + kmem_cache_free(ocfs2_uptodate_cachep, + tree[i]); + } +} + +/* Item insertion is guarded by ip_io_sem, so the insertion path takes + * advantage of this by not rechecking for a duplicate insert during + * the slow case. Additionally, if the cache needs to be bumped up to + * a tree, the code will not recheck after acquiring the lock -- + * multiple paths cannot be expanding to a tree at the same time. + * + * The slow path takes into account that items can be removed + * (including the whole tree wiped and reset) when this process it out + * allocating memory. In those cases, it reverts back to the fast + * path. + * + * Note that this function may actually fail to insert the block if + * memory cannot be allocated. This is not fatal however (but may + * result in a performance penalty) */ +void ocfs2_set_buffer_uptodate(struct inode *inode, + struct buffer_head *bh) +{ + int expand; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; + + /* The block may very well exist in our cache already, so avoid + * doing any more work in that case. */ + if (ocfs2_buffer_cached(oi, bh)) + return; + + mlog(0, "Inode %"MLFu64", inserting block %llu\n", oi->ip_blkno, + (unsigned long long) bh->b_blocknr); + + /* No need to recheck under spinlock - insertion is guarded by + * ip_io_sem */ + spin_lock(&oi->ip_lock); + if (ocfs2_insert_can_use_array(oi, ci)) { + /* Fast case - it's an array and there's a free + * spot. */ + ocfs2_append_cache_array(ci, bh->b_blocknr); + spin_unlock(&oi->ip_lock); + return; + } + + expand = 0; + if (oi->ip_flags & OCFS2_INODE_CACHE_INLINE) { + /* We need to bump things up to a tree. */ + expand = 1; + } + spin_unlock(&oi->ip_lock); + + __ocfs2_set_buffer_uptodate(oi, bh->b_blocknr, expand); +} + +/* Called against a newly allocated buffer. Most likely nobody should + * be able to read this sort of metadata while it's still being + * allocated, but this is careful to take ip_io_sem anyway. */ +void ocfs2_set_new_buffer_uptodate(struct inode *inode, + struct buffer_head *bh) +{ + struct ocfs2_inode_info *oi = OCFS2_I(inode); + + /* This should definitely *not* exist in our cache */ + BUG_ON(ocfs2_buffer_cached(oi, bh)); + + set_buffer_uptodate(bh); + + down(&oi->ip_io_sem); + ocfs2_set_buffer_uptodate(inode, bh); + up(&oi->ip_io_sem); +} + +/* Requires ip_lock. */ +static void ocfs2_remove_metadata_array(struct ocfs2_caching_info *ci, + int index) +{ + sector_t *array = ci->ci_cache.ci_array; + int bytes; + + BUG_ON(index < 0 || index >= OCFS2_INODE_MAX_CACHE_ARRAY); + BUG_ON(index >= ci->ci_num_cached); + BUG_ON(!ci->ci_num_cached); + + mlog(0, "remove index %d (num_cached = %u\n", index, + ci->ci_num_cached); + + ci->ci_num_cached--; + + /* don't need to copy if the array is now empty, or if we + * removed at the tail */ + if (ci->ci_num_cached && index < ci->ci_num_cached) { + bytes = sizeof(sector_t) * (ci->ci_num_cached - index); + memmove(&array[index], &array[index + 1], bytes); + } +} + +/* Requires ip_lock. */ +static void ocfs2_remove_metadata_tree(struct ocfs2_caching_info *ci, + struct ocfs2_meta_cache_item *item) +{ + mlog(0, "remove block %llu from tree\n", + (unsigned long long) item->c_block); + + rb_erase(&item->c_node, &ci->ci_cache.ci_tree); + ci->ci_num_cached--; +} + +/* Called when we remove a chunk of metadata from an inode. We don't + * bother reverting things to an inlined array in the case of a remove + * which moves us back under the limit. */ +void ocfs2_remove_from_cache(struct inode *inode, + struct buffer_head *bh) +{ + int index; + sector_t block = bh->b_blocknr; + struct ocfs2_meta_cache_item *item = NULL; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + struct ocfs2_caching_info *ci = &oi->ip_metadata_cache; + + spin_lock(&oi->ip_lock); + mlog(0, "Inode %"MLFu64", remove %llu, items = %u, array = %u\n", + oi->ip_blkno, (unsigned long long) block, ci->ci_num_cached, + oi->ip_flags & OCFS2_INODE_CACHE_INLINE); + + if (oi->ip_flags & OCFS2_INODE_CACHE_INLINE) { + index = ocfs2_search_cache_array(ci, block); + if (index != -1) + ocfs2_remove_metadata_array(ci, index); + } else { + item = ocfs2_search_cache_tree(ci, block); + if (item) + ocfs2_remove_metadata_tree(ci, item); + } + spin_unlock(&oi->ip_lock); + + if (item) + kmem_cache_free(ocfs2_uptodate_cachep, item); +} + +int __init init_ocfs2_uptodate_cache(void) +{ + ocfs2_uptodate_cachep = kmem_cache_create("ocfs2_uptodate", + sizeof(struct ocfs2_meta_cache_item), + 0, SLAB_HWCACHE_ALIGN, NULL, NULL); + if (!ocfs2_uptodate_cachep) + return -ENOMEM; + + mlog(0, "%u inlined cache items per inode.\n", + OCFS2_INODE_MAX_CACHE_ARRAY); + + return 0; +} + +void __exit exit_ocfs2_uptodate_cache(void) +{ + if (ocfs2_uptodate_cachep) + kmem_cache_destroy(ocfs2_uptodate_cachep); +} diff --git a/fs/ocfs2/uptodate.h b/fs/ocfs2/uptodate.h new file mode 100644 index 0000000..e5aacdf --- /dev/null +++ b/fs/ocfs2/uptodate.h @@ -0,0 +1,44 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * uptodate.h + * + * Cluster uptodate tracking + * + * Copyright (C) 2002, 2004, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_UPTODATE_H +#define OCFS2_UPTODATE_H + +int __init init_ocfs2_uptodate_cache(void); +void __exit exit_ocfs2_uptodate_cache(void); + +void ocfs2_metadata_cache_init(struct inode *inode); +void ocfs2_metadata_cache_purge(struct inode *inode); + +int ocfs2_buffer_uptodate(struct inode *inode, + struct buffer_head *bh); +void ocfs2_set_buffer_uptodate(struct inode *inode, + struct buffer_head *bh); +void ocfs2_set_new_buffer_uptodate(struct inode *inode, + struct buffer_head *bh); +void ocfs2_remove_from_cache(struct inode *inode, + struct buffer_head *bh); + +#endif /* OCFS2_UPTODATE_H */ diff --git a/fs/ocfs2/ver.c b/fs/ocfs2/ver.c new file mode 100644 index 0000000..5405ce1 --- /dev/null +++ b/fs/ocfs2/ver.c @@ -0,0 +1,43 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ver.c + * + * version string + * + * Copyright (C) 2002, 2005 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include + +#include "ver.h" + +#define OCFS2_BUILD_VERSION "1.3.3" + +#define VERSION_STR "OCFS2 " OCFS2_BUILD_VERSION + +void ocfs2_print_version(void) +{ + printk(KERN_INFO "%s\n", VERSION_STR); +} + +MODULE_DESCRIPTION(VERSION_STR); + +MODULE_VERSION(OCFS2_BUILD_VERSION); diff --git a/fs/ocfs2/ver.h b/fs/ocfs2/ver.h new file mode 100644 index 0000000..d7395cb --- /dev/null +++ b/fs/ocfs2/ver.h @@ -0,0 +1,31 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * ver.h + * + * Function prototypes + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef OCFS2_VER_H +#define OCFS2_VER_H + +void ocfs2_print_version(void); + +#endif /* OCFS2_VER_H */ diff --git a/fs/ocfs2/vote.c b/fs/ocfs2/vote.c new file mode 100644 index 0000000..021978e --- /dev/null +++ b/fs/ocfs2/vote.c @@ -0,0 +1,1202 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * vote.c + * + * description here + * + * Copyright (C) 2003, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#define MLOG_MASK_PREFIX ML_VOTE +#include + +#include "ocfs2.h" + +#include "alloc.h" +#include "dlmglue.h" +#include "extent_map.h" +#include "heartbeat.h" +#include "inode.h" +#include "journal.h" +#include "slot_map.h" +#include "vote.h" + +#include "buffer_head_io.h" + +#define OCFS2_MESSAGE_TYPE_VOTE (0x1) +#define OCFS2_MESSAGE_TYPE_RESPONSE (0x2) +struct ocfs2_msg_hdr +{ + __be32 h_response_id; /* used to lookup message handle on sending + * node. */ + __be32 h_request; + __be64 h_blkno; + __be32 h_generation; + __be32 h_node_num; /* node sending this particular message. */ +}; + +/* OCFS2_MAX_FILENAME_LEN is 255 characters, but we want to align this + * for the network. */ +#define OCFS2_VOTE_FILENAME_LEN 256 +struct ocfs2_vote_msg +{ + struct ocfs2_msg_hdr v_hdr; + union { + __be32 v_generic1; + __be32 v_orphaned_slot; /* Used during delete votes */ + __be32 v_nlink; /* Used during unlink votes */ + } md1; /* Message type dependant 1 */ + __be32 v_unlink_namelen; + __be64 v_unlink_parent; + u8 v_unlink_dirent[OCFS2_VOTE_FILENAME_LEN]; +}; + +/* Responses are given these values to maintain backwards + * compatibility with older ocfs2 versions */ +#define OCFS2_RESPONSE_OK (0) +#define OCFS2_RESPONSE_BUSY (-16) +#define OCFS2_RESPONSE_BAD_MSG (-22) + +struct ocfs2_response_msg +{ + struct ocfs2_msg_hdr r_hdr; + __be32 r_response; + __be32 r_orphaned_slot; +}; + +struct ocfs2_vote_work { + struct list_head w_list; + struct ocfs2_vote_msg w_msg; +}; + +enum ocfs2_vote_request { + OCFS2_VOTE_REQ_INVALID = 0, + OCFS2_VOTE_REQ_DELETE, + OCFS2_VOTE_REQ_UNLINK, + OCFS2_VOTE_REQ_RENAME, + OCFS2_VOTE_REQ_MOUNT, + OCFS2_VOTE_REQ_UMOUNT, + OCFS2_VOTE_REQ_LAST +}; + +static inline int ocfs2_is_valid_vote_request(int request) +{ + return OCFS2_VOTE_REQ_INVALID < request && + request < OCFS2_VOTE_REQ_LAST; +} + +typedef void (*ocfs2_net_response_callback)(void *priv, + struct ocfs2_response_msg *resp); +struct ocfs2_net_response_cb { + ocfs2_net_response_callback rc_cb; + void *rc_priv; +}; + +struct ocfs2_net_wait_ctxt { + struct list_head n_list; + u32 n_response_id; + wait_queue_head_t n_event; + struct ocfs2_node_map n_node_map; + int n_response; /* an agreggate response. 0 if + * all nodes are go, < 0 on any + * negative response from any + * node or network error. */ + struct ocfs2_net_response_cb *n_callback; +}; + +static void ocfs2_process_mount_request(struct ocfs2_super *osb, + unsigned int node_num) +{ + mlog(0, "MOUNT vote from node %u\n", node_num); + /* The other node only sends us this message when he has an EX + * on the superblock, so our recovery threads (if having been + * launched) are waiting on it.*/ + ocfs2_recovery_map_clear(osb, node_num); + ocfs2_node_map_set_bit(osb, &osb->mounted_map, node_num); + + /* We clear the umount map here because a node may have been + * previously mounted, safely unmounted but never stopped + * heartbeating - in which case we'd have a stale entry. */ + ocfs2_node_map_clear_bit(osb, &osb->umount_map, node_num); +} + +static void ocfs2_process_umount_request(struct ocfs2_super *osb, + unsigned int node_num) +{ + mlog(0, "UMOUNT vote from node %u\n", node_num); + ocfs2_node_map_clear_bit(osb, &osb->mounted_map, node_num); + ocfs2_node_map_set_bit(osb, &osb->umount_map, node_num); +} + +void ocfs2_mark_inode_remotely_deleted(struct inode *inode) +{ + struct ocfs2_inode_info *oi = OCFS2_I(inode); + + assert_spin_locked(&oi->ip_lock); + /* We set the SKIP_DELETE flag on the inode so we don't try to + * delete it in delete_inode ourselves, thus avoiding + * unecessary lock pinging. If the other node failed to wipe + * the inode as a result of a crash, then recovery will pick + * up the slack. */ + oi->ip_flags |= OCFS2_INODE_DELETED|OCFS2_INODE_SKIP_DELETE; +} + +static int ocfs2_process_delete_request(struct inode *inode, + int *orphaned_slot) +{ + int response = OCFS2_RESPONSE_BUSY; + + mlog(0, "DELETE vote on inode %lu, read lnk_cnt = %u, slot = %d\n", + inode->i_ino, inode->i_nlink, *orphaned_slot); + + spin_lock(&OCFS2_I(inode)->ip_lock); + + /* Whatever our vote response is, we want to make sure that + * the orphaned slot is recorded properly on this node *and* + * on the requesting node. Technically, if the requesting node + * did not know which slot the inode is orphaned in but we + * respond with BUSY he doesn't actually need the orphaned + * slot, but it doesn't hurt to do it here anyway. */ + if ((*orphaned_slot) != OCFS2_INVALID_SLOT) { + mlog_bug_on_msg(OCFS2_I(inode)->ip_orphaned_slot != + OCFS2_INVALID_SLOT && + OCFS2_I(inode)->ip_orphaned_slot != + (*orphaned_slot), + "Inode %"MLFu64": This node thinks it's " + "orphaned in slot %d, messaged it's in %d\n", + OCFS2_I(inode)->ip_blkno, + OCFS2_I(inode)->ip_orphaned_slot, + *orphaned_slot); + + mlog(0, "Setting orphaned slot for inode %"MLFu64" to %d\n", + OCFS2_I(inode)->ip_blkno, *orphaned_slot); + + OCFS2_I(inode)->ip_orphaned_slot = *orphaned_slot; + } else { + mlog(0, "Sending back orphaned slot %d for inode %"MLFu64"\n", + OCFS2_I(inode)->ip_orphaned_slot, + OCFS2_I(inode)->ip_blkno); + + *orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot; + } + + /* vote no if the file is still open. */ + if (OCFS2_I(inode)->ip_open_count) { + mlog(0, "open count = %u\n", + OCFS2_I(inode)->ip_open_count); + spin_unlock(&OCFS2_I(inode)->ip_lock); + goto done; + } + spin_unlock(&OCFS2_I(inode)->ip_lock); + + /* directories are a bit ugly... What if someone is sitting in + * it? We want to make sure the inode is removed completely as + * a result of the iput in process_vote. */ + if (S_ISDIR(inode->i_mode) && (atomic_read(&inode->i_count) != 1)) { + mlog(0, "i_count = %u\n", atomic_read(&inode->i_count)); + goto done; + } + + if (filemap_fdatawrite(inode->i_mapping)) { + mlog(ML_ERROR, "Could not sync inode %"MLFu64" for delete!\n", + OCFS2_I(inode)->ip_blkno); + goto done; + } + sync_mapping_buffers(inode->i_mapping); + truncate_inode_pages(inode->i_mapping, 0); + ocfs2_extent_map_trunc(inode, 0); + + spin_lock(&OCFS2_I(inode)->ip_lock); + /* double check open count - someone might have raced this + * thread into ocfs2_file_open while we were writing out + * data. If we're to allow a wipe of this inode now, we *must* + * hold the spinlock until we've marked it. */ + if (OCFS2_I(inode)->ip_open_count) { + mlog(0, "Raced to wipe! open count = %u\n", + OCFS2_I(inode)->ip_open_count); + spin_unlock(&OCFS2_I(inode)->ip_lock); + goto done; + } + + /* Mark the inode as being wiped from disk. */ + ocfs2_mark_inode_remotely_deleted(inode); + spin_unlock(&OCFS2_I(inode)->ip_lock); + + /* Not sure this is necessary anymore. */ + d_prune_aliases(inode); + + /* If we get here, then we're voting 'yes', so commit the + * delete on our side. */ + response = OCFS2_RESPONSE_OK; +done: + return response; +} + +static int ocfs2_match_dentry(struct dentry *dentry, + u64 parent_blkno, + unsigned int namelen, + const char *name) +{ + struct inode *parent; + + if (!dentry->d_parent) { + mlog(0, "Detached from parent.\n"); + return 0; + } + + parent = dentry->d_parent->d_inode; + /* Negative parent dentry? */ + if (!parent) + return 0; + + /* Name is in a different directory. */ + if (OCFS2_I(parent)->ip_blkno != parent_blkno) + return 0; + + if (dentry->d_name.len != namelen) + return 0; + + /* comparison above guarantees this is safe. */ + if (memcmp(dentry->d_name.name, name, namelen)) + return 0; + + return 1; +} + +static void ocfs2_process_dentry_request(struct inode *inode, + int rename, + unsigned int new_nlink, + u64 parent_blkno, + unsigned int namelen, + const char *name) +{ + struct dentry *dentry = NULL; + struct list_head *p; + struct ocfs2_inode_info *oi = OCFS2_I(inode); + + mlog(0, "parent %"MLFu64", namelen = %u, name = %.*s\n", parent_blkno, + namelen, namelen, name); + + spin_lock(&dcache_lock); + + /* Another node is removing this name from the system. It is + * up to us to find the corresponding dentry and if it exists, + * unhash it from the dcache. */ + list_for_each(p, &inode->i_dentry) { + dentry = list_entry(p, struct dentry, d_alias); + + if (ocfs2_match_dentry(dentry, parent_blkno, namelen, name)) { + mlog(0, "dentry found: %.*s\n", + dentry->d_name.len, dentry->d_name.name); + + dget_locked(dentry); + break; + } + + dentry = NULL; + } + + spin_unlock(&dcache_lock); + + if (dentry) { + d_delete(dentry); + dput(dentry); + } + + /* rename votes don't send link counts */ + if (!rename) { + mlog(0, "new_nlink = %u\n", new_nlink); + + /* We don't have the proper locks here to directly + * change i_nlink and besides, the vote is sent + * *before* the operation so it may have failed on the + * other node. This passes a hint to ocfs2_drop_inode + * to force ocfs2_delete_inode, who will take the + * proper cluster locks to sort things out. */ + if (new_nlink == 0) { + spin_lock(&oi->ip_lock); + oi->ip_flags |= OCFS2_INODE_MAYBE_ORPHANED; + spin_unlock(&OCFS2_I(inode)->ip_lock); + } + } +} + +static void ocfs2_process_vote(struct ocfs2_super *osb, + struct ocfs2_vote_msg *msg) +{ + int net_status, vote_response; + int orphaned_slot = 0; + int rename = 0; + unsigned int node_num, generation, new_nlink, namelen; + u64 blkno, parent_blkno; + enum ocfs2_vote_request request; + struct inode *inode = NULL; + struct ocfs2_msg_hdr *hdr = &msg->v_hdr; + struct ocfs2_response_msg response; + + /* decode the network mumbo jumbo into local variables. */ + request = be32_to_cpu(hdr->h_request); + blkno = be64_to_cpu(hdr->h_blkno); + generation = be32_to_cpu(hdr->h_generation); + node_num = be32_to_cpu(hdr->h_node_num); + if (request == OCFS2_VOTE_REQ_DELETE) + orphaned_slot = be32_to_cpu(msg->md1.v_orphaned_slot); + + mlog(0, "processing vote: request = %u, blkno = %"MLFu64", " + "generation = %u, node_num = %u, priv1 = %u\n", request, + blkno, generation, node_num, be32_to_cpu(msg->md1.v_generic1)); + + if (!ocfs2_is_valid_vote_request(request)) { + mlog(ML_ERROR, "Invalid vote request %d from node %u\n", + request, node_num); + vote_response = OCFS2_RESPONSE_BAD_MSG; + goto respond; + } + + vote_response = OCFS2_RESPONSE_OK; + + switch (request) { + case OCFS2_VOTE_REQ_UMOUNT: + ocfs2_process_umount_request(osb, node_num); + goto respond; + case OCFS2_VOTE_REQ_MOUNT: + ocfs2_process_mount_request(osb, node_num); + goto respond; + default: + /* avoids a gcc warning */ + break; + } + + /* We cannot process the remaining message types before we're + * fully mounted. It's perfectly safe however to send a 'yes' + * response as we can't possibly have any of the state they're + * asking us to modify yet. */ + if (atomic_read(&osb->vol_state) == VOLUME_INIT) + goto respond; + + /* If we get here, then the request is against an inode. */ + inode = ocfs2_ilookup_for_vote(osb, blkno, + request == OCFS2_VOTE_REQ_DELETE); + + /* Not finding the inode is perfectly valid - it means we're + * not interested in what the other node is about to do to it + * so in those cases we automatically respond with an + * affirmative. Cluster locking ensures that we won't race + * interest in the inode with this vote request. */ + if (!inode) + goto respond; + + /* Check generation values. It's possible for us to get a + * request against a stale inode. If so then we proceed as if + * we had not found an inode in the first place. */ + if (inode->i_generation != generation) { + mlog(0, "generation passed %u != inode generation = %u, " + "ip_flags = %x, ip_blkno = %"MLFu64", msg %"MLFu64", " + "i_count = %u, message type = %u\n", + generation, inode->i_generation, OCFS2_I(inode)->ip_flags, + OCFS2_I(inode)->ip_blkno, blkno, + atomic_read(&inode->i_count), request); + iput(inode); + inode = NULL; + goto respond; + } + + switch (request) { + case OCFS2_VOTE_REQ_DELETE: + vote_response = ocfs2_process_delete_request(inode, + &orphaned_slot); + break; + case OCFS2_VOTE_REQ_RENAME: + rename = 1; + /* fall through */ + case OCFS2_VOTE_REQ_UNLINK: + parent_blkno = be64_to_cpu(msg->v_unlink_parent); + namelen = be32_to_cpu(msg->v_unlink_namelen); + /* new_nlink will be ignored in case of a rename vote */ + new_nlink = be32_to_cpu(msg->md1.v_nlink); + ocfs2_process_dentry_request(inode, rename, new_nlink, + parent_blkno, namelen, + msg->v_unlink_dirent); + break; + default: + mlog(ML_ERROR, "node %u, invalid request: %u\n", + node_num, request); + vote_response = OCFS2_RESPONSE_BAD_MSG; + } + +respond: + /* Response struture is small so we just put it on the stack + * and stuff it inline. */ + memset(&response, 0, sizeof(struct ocfs2_response_msg)); + response.r_hdr.h_response_id = hdr->h_response_id; + response.r_hdr.h_blkno = hdr->h_blkno; + response.r_hdr.h_generation = hdr->h_generation; + response.r_hdr.h_node_num = cpu_to_be32(osb->node_num); + response.r_response = cpu_to_be32(vote_response); + response.r_orphaned_slot = cpu_to_be32(orphaned_slot); + + net_status = o2net_send_message(OCFS2_MESSAGE_TYPE_RESPONSE, + osb->net_key, + &response, + sizeof(struct ocfs2_response_msg), + node_num, + NULL); + /* We still want to error print for ENOPROTOOPT here. The + * sending node shouldn't have unregistered his net handler + * without sending an unmount vote 1st */ + if (net_status < 0 + && net_status != -ETIMEDOUT + && net_status != -ENOTCONN) + mlog(ML_ERROR, "message to node %u fails with error %d!\n", + node_num, net_status); + + if (inode) + iput(inode); +} + +static void ocfs2_vote_thread_do_work(struct ocfs2_super *osb) +{ + unsigned long processed; + struct ocfs2_lock_res *lockres; + struct ocfs2_vote_work *work; + + mlog_entry_void(); + + spin_lock(&osb->vote_task_lock); + /* grab this early so we know to try again if a state change and + * wake happens part-way through our work */ + osb->vote_work_sequence = osb->vote_wake_sequence; + + processed = osb->blocked_lock_count; + while (processed) { + BUG_ON(list_empty(&osb->blocked_lock_list)); + + lockres = list_entry(osb->blocked_lock_list.next, + struct ocfs2_lock_res, l_blocked_list); + list_del_init(&lockres->l_blocked_list); + osb->blocked_lock_count--; + spin_unlock(&osb->vote_task_lock); + + BUG_ON(!processed); + processed--; + + ocfs2_process_blocked_lock(osb, lockres); + + spin_lock(&osb->vote_task_lock); + } + + while (osb->vote_count) { + BUG_ON(list_empty(&osb->vote_list)); + work = list_entry(osb->vote_list.next, + struct ocfs2_vote_work, w_list); + list_del(&work->w_list); + osb->vote_count--; + spin_unlock(&osb->vote_task_lock); + + ocfs2_process_vote(osb, &work->w_msg); + kfree(work); + + spin_lock(&osb->vote_task_lock); + } + spin_unlock(&osb->vote_task_lock); + + mlog_exit_void(); +} + +static int ocfs2_vote_thread_lists_empty(struct ocfs2_super *osb) +{ + int empty = 0; + + spin_lock(&osb->vote_task_lock); + if (list_empty(&osb->blocked_lock_list) && + list_empty(&osb->vote_list)) + empty = 1; + + spin_unlock(&osb->vote_task_lock); + return empty; +} + +static int ocfs2_vote_thread_should_wake(struct ocfs2_super *osb) +{ + int should_wake = 0; + + spin_lock(&osb->vote_task_lock); + if (osb->vote_work_sequence != osb->vote_wake_sequence) + should_wake = 1; + spin_unlock(&osb->vote_task_lock); + + return should_wake; +} + +int ocfs2_vote_thread(void *arg) +{ + int status = 0; + struct ocfs2_super *osb = arg; + + /* only quit once we've been asked to stop and there is no more + * work available */ + while (!(kthread_should_stop() && + ocfs2_vote_thread_lists_empty(osb))) { + + wait_event_interruptible(osb->vote_event, + ocfs2_vote_thread_should_wake(osb) || + kthread_should_stop()); + + mlog(0, "vote_thread: awoken\n"); + + ocfs2_vote_thread_do_work(osb); + } + + osb->vote_task = NULL; + return status; +} + +static struct ocfs2_net_wait_ctxt *ocfs2_new_net_wait_ctxt(unsigned int response_id) +{ + struct ocfs2_net_wait_ctxt *w; + + w = kcalloc(1, sizeof(*w), GFP_KERNEL); + if (!w) { + mlog_errno(-ENOMEM); + goto bail; + } + + INIT_LIST_HEAD(&w->n_list); + init_waitqueue_head(&w->n_event); + ocfs2_node_map_init(&w->n_node_map); + w->n_response_id = response_id; + w->n_callback = NULL; +bail: + return w; +} + +static unsigned int ocfs2_new_response_id(struct ocfs2_super *osb) +{ + unsigned int ret; + + spin_lock(&osb->net_response_lock); + ret = ++osb->net_response_ids; + spin_unlock(&osb->net_response_lock); + + return ret; +} + +static void ocfs2_dequeue_net_wait_ctxt(struct ocfs2_super *osb, + struct ocfs2_net_wait_ctxt *w) +{ + spin_lock(&osb->net_response_lock); + list_del(&w->n_list); + spin_unlock(&osb->net_response_lock); +} + +static void ocfs2_queue_net_wait_ctxt(struct ocfs2_super *osb, + struct ocfs2_net_wait_ctxt *w) +{ + spin_lock(&osb->net_response_lock); + list_add_tail(&w->n_list, + &osb->net_response_list); + spin_unlock(&osb->net_response_lock); +} + +static void __ocfs2_mark_node_responded(struct ocfs2_super *osb, + struct ocfs2_net_wait_ctxt *w, + int node_num) +{ + assert_spin_locked(&osb->net_response_lock); + + ocfs2_node_map_clear_bit(osb, &w->n_node_map, node_num); + if (ocfs2_node_map_is_empty(osb, &w->n_node_map)) + wake_up(&w->n_event); +} + +/* Intended to be called from the node down callback, we fake remove + * the node from all our response contexts */ +void ocfs2_remove_node_from_vote_queues(struct ocfs2_super *osb, + int node_num) +{ + struct list_head *p; + struct ocfs2_net_wait_ctxt *w = NULL; + + spin_lock(&osb->net_response_lock); + + list_for_each(p, &osb->net_response_list) { + w = list_entry(p, struct ocfs2_net_wait_ctxt, n_list); + + __ocfs2_mark_node_responded(osb, w, node_num); + } + + spin_unlock(&osb->net_response_lock); +} + +static int ocfs2_broadcast_vote(struct ocfs2_super *osb, + struct ocfs2_vote_msg *request, + unsigned int response_id, + int *response, + struct ocfs2_net_response_cb *callback) +{ + int status, i, remote_err; + struct ocfs2_net_wait_ctxt *w = NULL; + int dequeued = 0; + + mlog_entry_void(); + + w = ocfs2_new_net_wait_ctxt(response_id); + if (!w) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + w->n_callback = callback; + + /* we're pretty much ready to go at this point, and this fills + * in n_response which we need anyway... */ + ocfs2_queue_net_wait_ctxt(osb, w); + + i = ocfs2_node_map_iterate(osb, &osb->mounted_map, 0); + + while (i != O2NM_INVALID_NODE_NUM) { + if (i != osb->node_num) { + mlog(0, "trying to send request to node %i\n", i); + ocfs2_node_map_set_bit(osb, &w->n_node_map, i); + + remote_err = 0; + status = o2net_send_message(OCFS2_MESSAGE_TYPE_VOTE, + osb->net_key, + request, + sizeof(*request), + i, + &remote_err); + if (status == -ETIMEDOUT) { + mlog(0, "remote node %d timed out!\n", i); + status = -EAGAIN; + goto bail; + } + if (remote_err < 0) { + status = remote_err; + mlog(0, "remote error %d on node %d!\n", + remote_err, i); + mlog_errno(status); + goto bail; + } + if (status < 0) { + mlog_errno(status); + goto bail; + } + } + i++; + i = ocfs2_node_map_iterate(osb, &osb->mounted_map, i); + mlog(0, "next is %d, i am %d\n", i, osb->node_num); + } + mlog(0, "done sending, now waiting on responses...\n"); + + wait_event(w->n_event, ocfs2_node_map_is_empty(osb, &w->n_node_map)); + + ocfs2_dequeue_net_wait_ctxt(osb, w); + dequeued = 1; + + *response = w->n_response; + status = 0; +bail: + if (w) { + if (!dequeued) + ocfs2_dequeue_net_wait_ctxt(osb, w); + kfree(w); + } + + mlog_exit(status); + return status; +} + +static struct ocfs2_vote_msg * ocfs2_new_vote_request(struct ocfs2_super *osb, + u64 blkno, + unsigned int generation, + enum ocfs2_vote_request type, + u32 priv) +{ + struct ocfs2_vote_msg *request; + struct ocfs2_msg_hdr *hdr; + + BUG_ON(!ocfs2_is_valid_vote_request(type)); + + request = kcalloc(1, sizeof(*request), GFP_KERNEL); + if (!request) { + mlog_errno(-ENOMEM); + } else { + hdr = &request->v_hdr; + hdr->h_node_num = cpu_to_be32(osb->node_num); + hdr->h_request = cpu_to_be32(type); + hdr->h_blkno = cpu_to_be64(blkno); + hdr->h_generation = cpu_to_be32(generation); + + request->md1.v_generic1 = cpu_to_be32(priv); + } + + return request; +} + +/* Complete the buildup of a new vote request and process the + * broadcast return value. */ +static int ocfs2_do_request_vote(struct ocfs2_super *osb, + struct ocfs2_vote_msg *request, + struct ocfs2_net_response_cb *callback) +{ + int status, response; + unsigned int response_id; + struct ocfs2_msg_hdr *hdr; + + response_id = ocfs2_new_response_id(osb); + + hdr = &request->v_hdr; + hdr->h_response_id = cpu_to_be32(response_id); + + status = ocfs2_broadcast_vote(osb, request, response_id, &response, + callback); + if (status < 0) { + mlog_errno(status); + goto bail; + } + + status = response; +bail: + + return status; +} + +static int ocfs2_request_vote(struct inode *inode, + struct ocfs2_vote_msg *request, + struct ocfs2_net_response_cb *callback) +{ + int status; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + if (ocfs2_inode_is_new(inode)) + return 0; + + status = -EAGAIN; + while (status == -EAGAIN) { + if (!(osb->s_mount_opt & OCFS2_MOUNT_NOINTR) && + signal_pending(current)) + return -ERESTARTSYS; + + status = ocfs2_super_lock(osb, 0); + if (status < 0) { + mlog_errno(status); + break; + } + + status = 0; + if (!ocfs2_node_map_is_only(osb, &osb->mounted_map, + osb->node_num)) + status = ocfs2_do_request_vote(osb, request, callback); + + ocfs2_super_unlock(osb, 0); + } + return status; +} + +static void ocfs2_delete_response_cb(void *priv, + struct ocfs2_response_msg *resp) +{ + int orphaned_slot, node; + struct inode *inode = priv; + + orphaned_slot = be32_to_cpu(resp->r_orphaned_slot); + node = be32_to_cpu(resp->r_hdr.h_node_num); + mlog(0, "node %d tells us that inode %"MLFu64" is orphaned in slot " + "%d\n", node, OCFS2_I(inode)->ip_blkno, orphaned_slot); + + /* The other node may not actually know which slot the inode + * is orphaned in. */ + if (orphaned_slot == OCFS2_INVALID_SLOT) + return; + + /* Ok, the responding node knows which slot this inode is + * orphaned in. We verify that the information is correct and + * then record this in the inode. ocfs2_delete_inode will use + * this information to determine which lock to take. */ + spin_lock(&OCFS2_I(inode)->ip_lock); + mlog_bug_on_msg(OCFS2_I(inode)->ip_orphaned_slot != orphaned_slot && + OCFS2_I(inode)->ip_orphaned_slot + != OCFS2_INVALID_SLOT, "Inode %"MLFu64": Node %d " + "says it's orphaned in slot %d, we think it's in %d\n", + OCFS2_I(inode)->ip_blkno, + be32_to_cpu(resp->r_hdr.h_node_num), + orphaned_slot, OCFS2_I(inode)->ip_orphaned_slot); + + OCFS2_I(inode)->ip_orphaned_slot = orphaned_slot; + spin_unlock(&OCFS2_I(inode)->ip_lock); +} + +int ocfs2_request_delete_vote(struct inode *inode) +{ + int orphaned_slot, status; + struct ocfs2_net_response_cb delete_cb; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_vote_msg *request; + + spin_lock(&OCFS2_I(inode)->ip_lock); + orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot; + spin_unlock(&OCFS2_I(inode)->ip_lock); + + delete_cb.rc_cb = ocfs2_delete_response_cb; + delete_cb.rc_priv = inode; + + mlog(0, "Inode %"MLFu64", we start thinking orphaned slot is %d\n", + OCFS2_I(inode)->ip_blkno, orphaned_slot); + + status = -ENOMEM; + request = ocfs2_new_vote_request(osb, OCFS2_I(inode)->ip_blkno, + inode->i_generation, + OCFS2_VOTE_REQ_DELETE, orphaned_slot); + if (request) { + status = ocfs2_request_vote(inode, request, &delete_cb); + + kfree(request); + } + + return status; +} + +static void ocfs2_setup_unlink_vote(struct ocfs2_vote_msg *request, + struct dentry *dentry) +{ + struct inode *parent = dentry->d_parent->d_inode; + + /* We need some values which will uniquely identify a dentry + * on the other nodes so that they can find it and run + * d_delete against it. Parent directory block and full name + * should suffice. */ + + mlog(0, "unlink/rename request: parent: %"MLFu64" name: %.*s\n", + OCFS2_I(parent)->ip_blkno, dentry->d_name.len, + dentry->d_name.name); + + request->v_unlink_parent = cpu_to_be64(OCFS2_I(parent)->ip_blkno); + request->v_unlink_namelen = cpu_to_be32(dentry->d_name.len); + memcpy(request->v_unlink_dirent, dentry->d_name.name, + dentry->d_name.len); +} + +int ocfs2_request_unlink_vote(struct inode *inode, + struct dentry *dentry, + unsigned int nlink) +{ + int status; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_vote_msg *request; + + if (dentry->d_name.len > OCFS2_VOTE_FILENAME_LEN) + return -ENAMETOOLONG; + + status = -ENOMEM; + request = ocfs2_new_vote_request(osb, OCFS2_I(inode)->ip_blkno, + inode->i_generation, + OCFS2_VOTE_REQ_UNLINK, nlink); + if (request) { + ocfs2_setup_unlink_vote(request, dentry); + + status = ocfs2_request_vote(inode, request, NULL); + + kfree(request); + } + return status; +} + +int ocfs2_request_rename_vote(struct inode *inode, + struct dentry *dentry) +{ + int status; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + struct ocfs2_vote_msg *request; + + if (dentry->d_name.len > OCFS2_VOTE_FILENAME_LEN) + return -ENAMETOOLONG; + + status = -ENOMEM; + request = ocfs2_new_vote_request(osb, OCFS2_I(inode)->ip_blkno, + inode->i_generation, + OCFS2_VOTE_REQ_RENAME, 0); + if (request) { + ocfs2_setup_unlink_vote(request, dentry); + + status = ocfs2_request_vote(inode, request, NULL); + + kfree(request); + } + return status; +} + +int ocfs2_request_mount_vote(struct ocfs2_super *osb) +{ + int status; + struct ocfs2_vote_msg *request = NULL; + + request = ocfs2_new_vote_request(osb, 0ULL, 0, + OCFS2_VOTE_REQ_MOUNT, 0); + if (!request) { + status = -ENOMEM; + goto bail; + } + + status = -EAGAIN; + while (status == -EAGAIN) { + if (!(osb->s_mount_opt & OCFS2_MOUNT_NOINTR) && + signal_pending(current)) { + status = -ERESTARTSYS; + goto bail; + } + + if (ocfs2_node_map_is_only(osb, &osb->mounted_map, + osb->node_num)) { + status = 0; + goto bail; + } + + status = ocfs2_do_request_vote(osb, request, NULL); + } + +bail: + if (request) + kfree(request); + + return status; +} + +int ocfs2_request_umount_vote(struct ocfs2_super *osb) +{ + int status; + struct ocfs2_vote_msg *request = NULL; + + request = ocfs2_new_vote_request(osb, 0ULL, 0, + OCFS2_VOTE_REQ_UMOUNT, 0); + if (!request) { + status = -ENOMEM; + goto bail; + } + + status = -EAGAIN; + while (status == -EAGAIN) { + /* Do not check signals on this vote... We really want + * this one to go all the way through. */ + + if (ocfs2_node_map_is_only(osb, &osb->mounted_map, + osb->node_num)) { + status = 0; + goto bail; + } + + status = ocfs2_do_request_vote(osb, request, NULL); + } + +bail: + if (request) + kfree(request); + + return status; +} + +/* TODO: This should eventually be a hash table! */ +static struct ocfs2_net_wait_ctxt * __ocfs2_find_net_wait_ctxt(struct ocfs2_super *osb, + u32 response_id) +{ + struct list_head *p; + struct ocfs2_net_wait_ctxt *w = NULL; + + list_for_each(p, &osb->net_response_list) { + w = list_entry(p, struct ocfs2_net_wait_ctxt, n_list); + if (response_id == w->n_response_id) + break; + w = NULL; + } + + return w; +} + +/* Translate response codes into local node errno values */ +static inline int ocfs2_translate_response(int response) +{ + int ret; + + switch (response) { + case OCFS2_RESPONSE_OK: + ret = 0; + break; + + case OCFS2_RESPONSE_BUSY: + ret = -EBUSY; + break; + + default: + ret = -EINVAL; + } + + return ret; +} + +static int ocfs2_handle_response_message(struct o2net_msg *msg, + u32 len, + void *data) +{ + unsigned int response_id, node_num; + int response_status; + struct ocfs2_super *osb = data; + struct ocfs2_response_msg *resp; + struct ocfs2_net_wait_ctxt * w; + struct ocfs2_net_response_cb *resp_cb; + + resp = (struct ocfs2_response_msg *) msg->buf; + + response_id = be32_to_cpu(resp->r_hdr.h_response_id); + node_num = be32_to_cpu(resp->r_hdr.h_node_num); + response_status = + ocfs2_translate_response(be32_to_cpu(resp->r_response)); + + mlog(0, "received response message:\n"); + mlog(0, "h_response_id = %u\n", response_id); + mlog(0, "h_request = %u\n", be32_to_cpu(resp->r_hdr.h_request)); + mlog(0, "h_blkno = %"MLFu64"\n", be64_to_cpu(resp->r_hdr.h_blkno)); + mlog(0, "h_generation = %u\n", be32_to_cpu(resp->r_hdr.h_generation)); + mlog(0, "h_node_num = %u\n", node_num); + mlog(0, "r_response = %d\n", response_status); + + spin_lock(&osb->net_response_lock); + w = __ocfs2_find_net_wait_ctxt(osb, response_id); + if (!w) { + mlog(0, "request not found!\n"); + goto bail; + } + resp_cb = w->n_callback; + + if (response_status && (!w->n_response)) { + /* we only really need one negative response so don't + * set it twice. */ + w->n_response = response_status; + } + + if (resp_cb) { + spin_unlock(&osb->net_response_lock); + + resp_cb->rc_cb(resp_cb->rc_priv, resp); + + spin_lock(&osb->net_response_lock); + } + + __ocfs2_mark_node_responded(osb, w, node_num); +bail: + spin_unlock(&osb->net_response_lock); + + return 0; +} + +static int ocfs2_handle_vote_message(struct o2net_msg *msg, + u32 len, + void *data) +{ + int status; + struct ocfs2_super *osb = data; + struct ocfs2_vote_work *work; + + work = kmalloc(sizeof(struct ocfs2_vote_work), GFP_KERNEL); + if (!work) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + INIT_LIST_HEAD(&work->w_list); + memcpy(&work->w_msg, msg->buf, sizeof(struct ocfs2_vote_msg)); + + mlog(0, "scheduling vote request:\n"); + mlog(0, "h_response_id = %u\n", + be32_to_cpu(work->w_msg.v_hdr.h_response_id)); + mlog(0, "h_request = %u\n", be32_to_cpu(work->w_msg.v_hdr.h_request)); + mlog(0, "h_blkno = %"MLFu64"\n", + be64_to_cpu(work->w_msg.v_hdr.h_blkno)); + mlog(0, "h_generation = %u\n", + be32_to_cpu(work->w_msg.v_hdr.h_generation)); + mlog(0, "h_node_num = %u\n", + be32_to_cpu(work->w_msg.v_hdr.h_node_num)); + mlog(0, "v_generic1 = %u\n", be32_to_cpu(work->w_msg.md1.v_generic1)); + + spin_lock(&osb->vote_task_lock); + list_add_tail(&work->w_list, &osb->vote_list); + osb->vote_count++; + spin_unlock(&osb->vote_task_lock); + + ocfs2_kick_vote_thread(osb); + + status = 0; +bail: + return status; +} + +void ocfs2_unregister_net_handlers(struct ocfs2_super *osb) +{ + if (!osb->net_key) + return; + + o2net_unregister_handler_list(&osb->osb_net_handlers); + + if (!list_empty(&osb->net_response_list)) + mlog(ML_ERROR, "net response list not empty!\n"); + + osb->net_key = 0; +} + +int ocfs2_register_net_handlers(struct ocfs2_super *osb) +{ + int status = 0; + + status = o2net_register_handler(OCFS2_MESSAGE_TYPE_RESPONSE, + osb->net_key, + sizeof(struct ocfs2_response_msg), + ocfs2_handle_response_message, + osb, &osb->osb_net_handlers); + if (status) { + mlog_errno(status); + goto bail; + } + + status = o2net_register_handler(OCFS2_MESSAGE_TYPE_VOTE, + osb->net_key, + sizeof(struct ocfs2_vote_msg), + ocfs2_handle_vote_message, + osb, &osb->osb_net_handlers); + if (status) { + mlog_errno(status); + goto bail; + } +bail: + if (status < 0) + ocfs2_unregister_net_handlers(osb); + + return status; +} diff --git a/fs/ocfs2/vote.h b/fs/ocfs2/vote.h new file mode 100644 index 0000000..9cce607 --- /dev/null +++ b/fs/ocfs2/vote.h @@ -0,0 +1,56 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * vote.h + * + * description here + * + * Copyright (C) 2002, 2004 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + + +#ifndef VOTE_H +#define VOTE_H + +int ocfs2_vote_thread(void *arg); +static inline void ocfs2_kick_vote_thread(struct ocfs2_super *osb) +{ + spin_lock(&osb->vote_task_lock); + /* make sure the voting thread gets a swipe at whatever changes + * the caller may have made to the voting state */ + osb->vote_wake_sequence++; + spin_unlock(&osb->vote_task_lock); + wake_up(&osb->vote_event); +} + +int ocfs2_request_delete_vote(struct inode *inode); +int ocfs2_request_unlink_vote(struct inode *inode, + struct dentry *dentry, + unsigned int nlink); +int ocfs2_request_rename_vote(struct inode *inode, + struct dentry *dentry); +int ocfs2_request_mount_vote(struct ocfs2_super *osb); +int ocfs2_request_umount_vote(struct ocfs2_super *osb); +int ocfs2_register_net_handlers(struct ocfs2_super *osb); +void ocfs2_unregister_net_handlers(struct ocfs2_super *osb); + +void ocfs2_mark_inode_remotely_deleted(struct inode *inode); + +void ocfs2_remove_node_from_vote_queues(struct ocfs2_super *osb, + int node_num); +#endif -- cgit v1.1 From b4e40a51881931bfcbc78a585e875bb2784d6d10 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 15 Dec 2005 14:31:24 -0800 Subject: [PATCH] OCFS2: The Second Oracle Cluster Filesystem Link the code into the kernel build system. OCFS2 is marked as experimental. Signed-off-by: Mark Fasheh Signed-off-by: Kurt Hackel --- fs/Kconfig | 53 ++++++++++++++++++++++++++++++++++++++++++----------- fs/Makefile | 1 + 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/fs/Kconfig b/fs/Kconfig index ba1dbe2..59b1795 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -70,6 +70,7 @@ config FS_XIP config EXT3_FS tristate "Ext3 journalling file system support" + select JBD help This is the journaling version of the Second extended file system (often called ext3), the de facto standard Linux file system @@ -138,23 +139,20 @@ config EXT3_FS_SECURITY extended attributes for file security labels, say N. config JBD -# CONFIG_JBD could be its own option (even modular), but until there are -# other users than ext3, we will simply make it be the same as CONFIG_EXT3_FS -# dep_tristate ' Journal Block Device support (JBD for ext3)' CONFIG_JBD $CONFIG_EXT3_FS tristate - default EXT3_FS help This is a generic journaling layer for block devices. It is - currently used by the ext3 file system, but it could also be used to - add journal support to other file systems or block devices such as - RAID or LVM. + currently used by the ext3 and OCFS2 file systems, but it could + also be used to add journal support to other file systems or block + devices such as RAID or LVM. - If you are using the ext3 file system, you need to say Y here. If - you are not using ext3 then you will probably want to say N. + If you are using the ext3 or OCFS2 file systems, you need to + say Y here. If you are not using ext3 OCFS2 then you will probably + want to say N. To compile this device as a module, choose M here: the module will be - called jbd. If you are compiling ext3 into the kernel, you cannot - compile this code as a module. + called jbd. If you are compiling ext3 or OCFS2 into the kernel, + you cannot compile this code as a module. config JBD_DEBUG bool "JBD (ext3) debugging support" @@ -326,6 +324,39 @@ config FS_POSIX_ACL source "fs/xfs/Kconfig" +config OCFS2_FS + tristate "OCFS2 file system support (EXPERIMENTAL)" + depends on NET && EXPERIMENTAL + select CONFIGFS_FS + select JBD + select CRC32 + select INET + help + OCFS2 is a general purpose extent based shared disk cluster file + system with many similarities to ext3. It supports 64 bit inode + numbers, and has automatically extending metadata groups which may + also make it attractive for non-clustered use. + + You'll want to install the ocfs2-tools package in order to at least + get "mount.ocfs2". + + Project web page: http://oss.oracle.com/projects/ocfs2 + Tools web page: http://oss.oracle.com/projects/ocfs2-tools + OCFS2 mailing lists: http://oss.oracle.com/projects/ocfs2/mailman/ + + Note: Features which OCFS2 does not support yet: + - extended attributes + - readonly mount + - shared writeable mmap + - loopback is supported, but data written will not + be cluster coherent. + - quotas + - cluster aware flock + - Directory change notification (F_NOTIFY) + - Distributed Caching (F_SETLEASE/F_GETLEASE/break_lease) + - POSIX ACLs + - readpages / writepages (not user visible) + config MINIX_FS tristate "Minix fs support" help diff --git a/fs/Makefile b/fs/Makefile index ff3d48a..7367611 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -102,3 +102,4 @@ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ obj-$(CONFIG_DEBUG_FS) += debugfs/ obj-$(CONFIG_CONFIGFS_FS) += configfs/ +obj-$(CONFIG_OCFS2_FS) += ocfs2/ -- cgit v1.1 From 82353b594c784deabb8d9764b477e65c2b3726f9 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 19 Dec 2005 11:16:07 -0800 Subject: [PATCH] This patch contains the following cleanups: - cluster/sys.c: make needlessly global code static - dlm/: "extern" declarations for variables belong into header files (and in this case, they are already in dlmdomain.h) Signed-off-by: Adrian Bunk Signed-off-by: Mark Fasheh --- fs/ocfs2/cluster/sys.c | 4 ++-- fs/ocfs2/dlm/dlmmaster.c | 4 +--- fs/ocfs2/dlm/dlmthread.c | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/ocfs2/cluster/sys.c b/fs/ocfs2/cluster/sys.c index f1e9946..1d9f6ac 100644 --- a/fs/ocfs2/cluster/sys.c +++ b/fs/ocfs2/cluster/sys.c @@ -50,7 +50,7 @@ static ssize_t o2cb_interface_revision_show(char *buf) return snprintf(buf, PAGE_SIZE, "%u\n", O2NM_API_VERSION); } -O2CB_ATTR(interface_revision, S_IFREG | S_IRUGO, o2cb_interface_revision_show, NULL); +static O2CB_ATTR(interface_revision, S_IFREG | S_IRUGO, o2cb_interface_revision_show, NULL); static struct attribute *o2cb_attrs[] = { &o2cb_attr_interface_revision.attr, @@ -73,7 +73,7 @@ static struct kobj_type o2cb_subsys_type = { }; /* gives us o2cb_subsys */ -decl_subsys(o2cb, NULL, NULL); +static decl_subsys(o2cb, NULL, NULL); static ssize_t o2cb_show(struct kobject * kobj, struct attribute * attr, char * buffer) diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 0472795..27e984f 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -48,6 +48,7 @@ #include "dlmapi.h" #include "dlmcommon.h" #include "dlmdebug.h" +#include "dlmdomain.h" #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_MASTER) #include "cluster/masklog.h" @@ -178,9 +179,6 @@ static void dlm_dump_mles(struct dlm_ctxt *dlm) spin_unlock(&dlm->master_lock); } -extern spinlock_t dlm_domain_lock; -extern struct list_head dlm_domains; - int dlm_dump_all_mles(const char __user *data, unsigned int len) { struct list_head *iter; diff --git a/fs/ocfs2/dlm/dlmthread.c b/fs/ocfs2/dlm/dlmthread.c index 92cd5cd..5be9d14 100644 --- a/fs/ocfs2/dlm/dlmthread.c +++ b/fs/ocfs2/dlm/dlmthread.c @@ -52,9 +52,6 @@ #define MLOG_MASK_PREFIX (ML_DLM|ML_DLM_THREAD) #include "cluster/masklog.h" -extern spinlock_t dlm_domain_lock; -extern struct list_head dlm_domains; - static int dlm_thread(void *data); static void dlm_flush_asts(struct dlm_ctxt *dlm); -- cgit v1.1 From 51e7a5987058c6b4d0c1337587f2ec0c34ffa708 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Mon, 19 Dec 2005 11:21:42 -0800 Subject: [PATCH] o Update Kconfig documentation to reflect support for readonly mounts. Signed-off-by: Mark Fasheh --- fs/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/Kconfig b/fs/Kconfig index 59b1795..382e3b2 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -346,7 +346,6 @@ config OCFS2_FS Note: Features which OCFS2 does not support yet: - extended attributes - - readonly mount - shared writeable mmap - loopback is supported, but data written will not be cluster coherent. -- cgit v1.1 From df71837d5024e2524cd51c93621e558aa7dd9f3f Mon Sep 17 00:00:00 2001 From: Trent Jaeger Date: Tue, 13 Dec 2005 23:12:27 -0800 Subject: [LSM-IPSec]: Security association restriction. This patch series implements per packet access control via the extension of the Linux Security Modules (LSM) interface by hooks in the XFRM and pfkey subsystems that leverage IPSec security associations to label packets. Extensions to the SELinux LSM are included that leverage the patch for this purpose. This patch implements the changes necessary to the XFRM subsystem, pfkey interface, ipv4/ipv6, and xfrm_user interface to restrict a socket to use only authorized security associations (or no security association) to send/receive network packets. Patch purpose: The patch is designed to enable access control per packets based on the strongly authenticated IPSec security association. Such access controls augment the existing ones based on network interface and IP address. The former are very coarse-grained, and the latter can be spoofed. By using IPSec, the system can control access to remote hosts based on cryptographic keys generated using the IPSec mechanism. This enables access control on a per-machine basis or per-application if the remote machine is running the same mechanism and trusted to enforce the access control policy. Patch design approach: The overall approach is that policy (xfrm_policy) entries set by user-level programs (e.g., setkey for ipsec-tools) are extended with a security context that is used at policy selection time in the XFRM subsystem to restrict the sockets that can send/receive packets via security associations (xfrm_states) that are built from those policies. A presentation available at www.selinux-symposium.org/2005/presentations/session2/2-3-jaeger.pdf from the SELinux symposium describes the overall approach. Patch implementation details: On output, the policy retrieved (via xfrm_policy_lookup or xfrm_sk_policy_lookup) must be authorized for the security context of the socket and the same security context is required for resultant security association (retrieved or negotiated via racoon in ipsec-tools). This is enforced in xfrm_state_find. On input, the policy retrieved must also be authorized for the socket (at __xfrm_policy_check), and the security context of the policy must also match the security association being used. The patch has virtually no impact on packets that do not use IPSec. The existing Netfilter (outgoing) and LSM rcv_skb hooks are used as before. Also, if IPSec is used without security contexts, the impact is minimal. The LSM must allow such policies to be selected for the combination of socket and remote machine, but subsequent IPSec processing proceeds as in the original case. Testing: The pfkey interface is tested using the ipsec-tools. ipsec-tools have been modified (a separate ipsec-tools patch is available for version 0.5) that supports assignment of xfrm_policy entries and security associations with security contexts via setkey and the negotiation using the security contexts via racoon. The xfrm_user interface is tested via ad hoc programs that set security contexts. These programs are also available from me, and contain programs for setting, getting, and deleting policy for testing this interface. Testing of sa functions was done by tracing kernel behavior. Signed-off-by: Trent Jaeger Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- include/linux/pfkeyv2.h | 13 +++- include/linux/security.h | 132 +++++++++++++++++++++++++++++++ include/linux/xfrm.h | 29 +++++++ include/net/flow.h | 7 +- include/net/xfrm.h | 27 ++++++- net/core/flow.c | 8 +- net/key/af_key.c | 197 +++++++++++++++++++++++++++++++++++++++++++++-- net/xfrm/xfrm_policy.c | 88 +++++++++++++-------- net/xfrm/xfrm_state.c | 9 ++- net/xfrm/xfrm_user.c | 148 +++++++++++++++++++++++++++++++++-- security/Kconfig | 13 ++++ security/dummy.c | 45 ++++++++++- 12 files changed, 655 insertions(+), 61 deletions(-) diff --git a/include/linux/pfkeyv2.h b/include/linux/pfkeyv2.h index 7240667..6351c40 100644 --- a/include/linux/pfkeyv2.h +++ b/include/linux/pfkeyv2.h @@ -216,6 +216,16 @@ struct sadb_x_nat_t_port { } __attribute__((packed)); /* sizeof(struct sadb_x_nat_t_port) == 8 */ +/* Generic LSM security context */ +struct sadb_x_sec_ctx { + uint16_t sadb_x_sec_len; + uint16_t sadb_x_sec_exttype; + uint8_t sadb_x_ctx_alg; /* LSMs: e.g., selinux == 1 */ + uint8_t sadb_x_ctx_doi; + uint16_t sadb_x_ctx_len; +} __attribute__((packed)); +/* sizeof(struct sadb_sec_ctx) = 8 */ + /* Message types */ #define SADB_RESERVED 0 #define SADB_GETSPI 1 @@ -325,7 +335,8 @@ struct sadb_x_nat_t_port { #define SADB_X_EXT_NAT_T_SPORT 21 #define SADB_X_EXT_NAT_T_DPORT 22 #define SADB_X_EXT_NAT_T_OA 23 -#define SADB_EXT_MAX 23 +#define SADB_X_EXT_SEC_CTX 24 +#define SADB_EXT_MAX 24 /* Identity Extension values */ #define SADB_IDENTTYPE_RESERVED 0 diff --git a/include/linux/security.h b/include/linux/security.h index f7e0ae0..ef75365 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -59,6 +59,12 @@ struct sk_buff; struct sock; struct sockaddr; struct socket; +struct flowi; +struct dst_entry; +struct xfrm_selector; +struct xfrm_policy; +struct xfrm_state; +struct xfrm_user_sec_ctx; extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb); extern int cap_netlink_recv(struct sk_buff *skb); @@ -788,6 +794,52 @@ struct swap_info_struct; * which is used to copy security attributes between local stream sockets. * @sk_free_security: * Deallocate security structure. + * @sk_getsid: + * Retrieve the LSM-specific sid for the sock to enable caching of network + * authorizations. + * + * Security hooks for XFRM operations. + * + * @xfrm_policy_alloc_security: + * @xp contains the xfrm_policy being added to Security Policy Database + * used by the XFRM system. + * @sec_ctx contains the security context information being provided by + * the user-level policy update program (e.g., setkey). + * Allocate a security structure to the xp->selector.security field. + * The security field is initialized to NULL when the xfrm_policy is + * allocated. + * Return 0 if operation was successful (memory to allocate, legal context) + * @xfrm_policy_clone_security: + * @old contains an existing xfrm_policy in the SPD. + * @new contains a new xfrm_policy being cloned from old. + * Allocate a security structure to the new->selector.security field + * that contains the information from the old->selector.security field. + * Return 0 if operation was successful (memory to allocate). + * @xfrm_policy_free_security: + * @xp contains the xfrm_policy + * Deallocate xp->selector.security. + * @xfrm_state_alloc_security: + * @x contains the xfrm_state being added to the Security Association + * Database by the XFRM system. + * @sec_ctx contains the security context information being provided by + * the user-level SA generation program (e.g., setkey or racoon). + * Allocate a security structure to the x->sel.security field. The + * security field is initialized to NULL when the xfrm_state is + * allocated. + * Return 0 if operation was successful (memory to allocate, legal context). + * @xfrm_state_free_security: + * @x contains the xfrm_state. + * Deallocate x>sel.security. + * @xfrm_policy_lookup: + * @xp contains the xfrm_policy for which the access control is being + * checked. + * @sk_sid contains the sock security label that is used to authorize + * access to the policy xp. + * @dir contains the direction of the flow (input or output). + * Check permission when a sock selects a xfrm_policy for processing + * XFRMs on a packet. The hook is called when selecting either a + * per-socket policy or a generic xfrm policy. + * Return 0 if permission is granted. * * Security hooks affecting all Key Management operations * @@ -1237,8 +1289,18 @@ struct security_operations { int (*socket_getpeersec) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len); int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority); void (*sk_free_security) (struct sock *sk); + unsigned int (*sk_getsid) (struct sock *sk, struct flowi *fl, u8 dir); #endif /* CONFIG_SECURITY_NETWORK */ +#ifdef CONFIG_SECURITY_NETWORK_XFRM + int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx); + int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new); + void (*xfrm_policy_free_security) (struct xfrm_policy *xp); + int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); + void (*xfrm_state_free_security) (struct xfrm_state *x); + int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir); +#endif /* CONFIG_SECURITY_NETWORK_XFRM */ + /* key management security hooks */ #ifdef CONFIG_KEYS int (*key_alloc)(struct key *key); @@ -2679,6 +2741,11 @@ static inline void security_sk_free(struct sock *sk) { return security_ops->sk_free_security(sk); } + +static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir) +{ + return security_ops->sk_getsid(sk, fl, dir); +} #else /* CONFIG_SECURITY_NETWORK */ static inline int security_unix_stream_connect(struct socket * sock, struct socket * other, @@ -2795,8 +2862,73 @@ static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority) static inline void security_sk_free(struct sock *sk) { } + +static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir) +{ + return 0; +} #endif /* CONFIG_SECURITY_NETWORK */ +#ifdef CONFIG_SECURITY_NETWORK_XFRM +static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) +{ + return security_ops->xfrm_policy_alloc_security(xp, sec_ctx); +} + +static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) +{ + return security_ops->xfrm_policy_clone_security(old, new); +} + +static inline void security_xfrm_policy_free(struct xfrm_policy *xp) +{ + security_ops->xfrm_policy_free_security(xp); +} + +static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) +{ + return security_ops->xfrm_state_alloc_security(x, sec_ctx); +} + +static inline void security_xfrm_state_free(struct xfrm_state *x) +{ + security_ops->xfrm_state_free_security(x); +} + +static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir) +{ + return security_ops->xfrm_policy_lookup(xp, sk_sid, dir); +} +#else /* CONFIG_SECURITY_NETWORK_XFRM */ +static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) +{ + return 0; +} + +static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) +{ + return 0; +} + +static inline void security_xfrm_policy_free(struct xfrm_policy *xp) +{ +} + +static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) +{ + return 0; +} + +static inline void security_xfrm_state_free(struct xfrm_state *x) +{ +} + +static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir) +{ + return 0; +} +#endif /* CONFIG_SECURITY_NETWORK_XFRM */ + #ifdef CONFIG_KEYS #ifdef CONFIG_SECURITY static inline int security_key_alloc(struct key *key) diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h index 0fb077d..82fbb75 100644 --- a/include/linux/xfrm.h +++ b/include/linux/xfrm.h @@ -27,6 +27,22 @@ struct xfrm_id __u8 proto; }; +struct xfrm_sec_ctx { + __u8 ctx_doi; + __u8 ctx_alg; + __u16 ctx_len; + __u32 ctx_sid; + char ctx_str[0]; +}; + +/* Security Context Domains of Interpretation */ +#define XFRM_SC_DOI_RESERVED 0 +#define XFRM_SC_DOI_LSM 1 + +/* Security Context Algorithms */ +#define XFRM_SC_ALG_RESERVED 0 +#define XFRM_SC_ALG_SELINUX 1 + /* Selector, used as selector both on policy rules (SPD) and SAs. */ struct xfrm_selector @@ -146,6 +162,18 @@ enum { #define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE) +/* + * Generic LSM security context for comunicating to user space + * NOTE: Same format as sadb_x_sec_ctx + */ +struct xfrm_user_sec_ctx { + __u16 len; + __u16 exttype; + __u8 ctx_alg; /* LSMs: e.g., selinux == 1 */ + __u8 ctx_doi; + __u16 ctx_len; +}; + struct xfrm_user_tmpl { struct xfrm_id id; __u16 family; @@ -176,6 +204,7 @@ enum xfrm_attr_type_t { XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */ XFRMA_SA, XFRMA_POLICY, + XFRMA_SEC_CTX, /* struct xfrm_sec_ctx */ __XFRMA_MAX #define XFRMA_MAX (__XFRMA_MAX - 1) diff --git a/include/net/flow.h b/include/net/flow.h index 9a5c94b..ec7eb86 100644 --- a/include/net/flow.h +++ b/include/net/flow.h @@ -84,11 +84,12 @@ struct flowi { #define FLOW_DIR_OUT 1 #define FLOW_DIR_FWD 2 -typedef void (*flow_resolve_t)(struct flowi *key, u16 family, u8 dir, +struct sock; +typedef void (*flow_resolve_t)(struct flowi *key, u32 sk_sid, u16 family, u8 dir, void **objp, atomic_t **obj_refp); -extern void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir, - flow_resolve_t resolver); +extern void *flow_cache_lookup(struct flowi *key, u32 sk_sid, u16 family, u8 dir, + flow_resolve_t resolver); extern void flow_cache_flush(void); extern atomic_t flow_cache_genid; diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 1cdb879..487abca 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -144,6 +144,9 @@ struct xfrm_state * transformer. */ struct xfrm_type *type; + /* Security context */ + struct xfrm_sec_ctx *security; + /* Private data of this transformer, format is opaque, * interpreted by xfrm_type methods. */ void *data; @@ -298,6 +301,7 @@ struct xfrm_policy __u8 flags; __u8 dead; __u8 xfrm_nr; + struct xfrm_sec_ctx *security; struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; }; @@ -510,6 +514,25 @@ xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl, return 0; } +#ifdef CONFIG_SECURITY_NETWORK_XFRM +/* If neither has a context --> match + * Otherwise, both must have a context and the sids, doi, alg must match + */ +static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2) +{ + return ((!s1 && !s2) || + (s1 && s2 && + (s1->ctx_sid == s2->ctx_sid) && + (s1->ctx_doi == s2->ctx_doi) && + (s1->ctx_alg == s2->ctx_alg))); +} +#else +static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2) +{ + return 1; +} +#endif + /* A struct encoding bundle of transformations to apply to some set of flow. * * dst->child points to the next element of bundle. @@ -878,8 +901,8 @@ static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsig struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); extern int xfrm_policy_walk(int (*func)(struct xfrm_policy *, int, int, void*), void *); int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); -struct xfrm_policy *xfrm_policy_bysel(int dir, struct xfrm_selector *sel, - int delete); +struct xfrm_policy *xfrm_policy_bysel_ctx(int dir, struct xfrm_selector *sel, + struct xfrm_sec_ctx *ctx, int delete); struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete); void xfrm_policy_flush(void); u32 xfrm_get_acqseq(void); diff --git a/net/core/flow.c b/net/core/flow.c index 7e95b39..c4f2538 100644 --- a/net/core/flow.c +++ b/net/core/flow.c @@ -23,6 +23,7 @@ #include #include #include +#include struct flow_cache_entry { struct flow_cache_entry *next; @@ -30,6 +31,7 @@ struct flow_cache_entry { u8 dir; struct flowi key; u32 genid; + u32 sk_sid; void *object; atomic_t *object_ref; }; @@ -162,7 +164,7 @@ static int flow_key_compare(struct flowi *key1, struct flowi *key2) return 0; } -void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir, +void *flow_cache_lookup(struct flowi *key, u32 sk_sid, u16 family, u8 dir, flow_resolve_t resolver) { struct flow_cache_entry *fle, **head; @@ -186,6 +188,7 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir, for (fle = *head; fle; fle = fle->next) { if (fle->family == family && fle->dir == dir && + fle->sk_sid == sk_sid && flow_key_compare(key, &fle->key) == 0) { if (fle->genid == atomic_read(&flow_cache_genid)) { void *ret = fle->object; @@ -210,6 +213,7 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir, *head = fle; fle->family = family; fle->dir = dir; + fle->sk_sid = sk_sid; memcpy(&fle->key, key, sizeof(*key)); fle->object = NULL; flow_count(cpu)++; @@ -221,7 +225,7 @@ nocache: void *obj; atomic_t *obj_ref; - resolver(key, family, dir, &obj, &obj_ref); + resolver(key, sk_sid, family, dir, &obj, &obj_ref); if (fle) { fle->genid = atomic_read(&flow_cache_genid); diff --git a/net/key/af_key.c b/net/key/af_key.c index 3903168..d32f779 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -336,6 +336,7 @@ static u8 sadb_ext_min_len[] = { [SADB_X_EXT_NAT_T_SPORT] = (u8) sizeof(struct sadb_x_nat_t_port), [SADB_X_EXT_NAT_T_DPORT] = (u8) sizeof(struct sadb_x_nat_t_port), [SADB_X_EXT_NAT_T_OA] = (u8) sizeof(struct sadb_address), + [SADB_X_EXT_SEC_CTX] = (u8) sizeof(struct sadb_x_sec_ctx), }; /* Verify sadb_address_{len,prefixlen} against sa_family. */ @@ -383,6 +384,55 @@ static int verify_address_len(void *p) return 0; } +static inline int pfkey_sec_ctx_len(struct sadb_x_sec_ctx *sec_ctx) +{ + int len = 0; + + len += sizeof(struct sadb_x_sec_ctx); + len += sec_ctx->sadb_x_ctx_len; + len += sizeof(uint64_t) - 1; + len /= sizeof(uint64_t); + + return len; +} + +static inline int verify_sec_ctx_len(void *p) +{ + struct sadb_x_sec_ctx *sec_ctx = (struct sadb_x_sec_ctx *)p; + int len; + + if (sec_ctx->sadb_x_ctx_len > PAGE_SIZE) + return -EINVAL; + + len = pfkey_sec_ctx_len(sec_ctx); + + if (sec_ctx->sadb_x_sec_len != len) + return -EINVAL; + + return 0; +} + +static inline struct xfrm_user_sec_ctx *pfkey_sadb2xfrm_user_sec_ctx(struct sadb_x_sec_ctx *sec_ctx) +{ + struct xfrm_user_sec_ctx *uctx = NULL; + int ctx_size = sec_ctx->sadb_x_ctx_len; + + uctx = kmalloc((sizeof(*uctx)+ctx_size), GFP_KERNEL); + + if (!uctx) + return NULL; + + uctx->len = pfkey_sec_ctx_len(sec_ctx); + uctx->exttype = sec_ctx->sadb_x_sec_exttype; + uctx->ctx_doi = sec_ctx->sadb_x_ctx_doi; + uctx->ctx_alg = sec_ctx->sadb_x_ctx_alg; + uctx->ctx_len = sec_ctx->sadb_x_ctx_len; + memcpy(uctx + 1, sec_ctx + 1, + uctx->ctx_len); + + return uctx; +} + static int present_and_same_family(struct sadb_address *src, struct sadb_address *dst) { @@ -438,6 +488,10 @@ static int parse_exthdrs(struct sk_buff *skb, struct sadb_msg *hdr, void **ext_h if (verify_address_len(p)) return -EINVAL; } + if (ext_type == SADB_X_EXT_SEC_CTX) { + if (verify_sec_ctx_len(p)) + return -EINVAL; + } ext_hdrs[ext_type-1] = p; } p += ext_len; @@ -586,6 +640,9 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys, struct sadb_key *key; struct sadb_x_sa2 *sa2; struct sockaddr_in *sin; + struct sadb_x_sec_ctx *sec_ctx; + struct xfrm_sec_ctx *xfrm_ctx; + int ctx_size = 0; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) struct sockaddr_in6 *sin6; #endif @@ -609,6 +666,12 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys, sizeof(struct sadb_address)*2 + sockaddr_size*2 + sizeof(struct sadb_x_sa2); + + if ((xfrm_ctx = x->security)) { + ctx_size = PFKEY_ALIGN8(xfrm_ctx->ctx_len); + size += sizeof(struct sadb_x_sec_ctx) + ctx_size; + } + /* identity & sensitivity */ if ((x->props.family == AF_INET && @@ -899,6 +962,20 @@ static struct sk_buff * pfkey_xfrm_state2msg(struct xfrm_state *x, int add_keys, n_port->sadb_x_nat_t_port_reserved = 0; } + /* security context */ + if (xfrm_ctx) { + sec_ctx = (struct sadb_x_sec_ctx *) skb_put(skb, + sizeof(struct sadb_x_sec_ctx) + ctx_size); + sec_ctx->sadb_x_sec_len = + (sizeof(struct sadb_x_sec_ctx) + ctx_size) / sizeof(uint64_t); + sec_ctx->sadb_x_sec_exttype = SADB_X_EXT_SEC_CTX; + sec_ctx->sadb_x_ctx_doi = xfrm_ctx->ctx_doi; + sec_ctx->sadb_x_ctx_alg = xfrm_ctx->ctx_alg; + sec_ctx->sadb_x_ctx_len = xfrm_ctx->ctx_len; + memcpy(sec_ctx + 1, xfrm_ctx->ctx_str, + xfrm_ctx->ctx_len); + } + return skb; } @@ -909,6 +986,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr, struct sadb_lifetime *lifetime; struct sadb_sa *sa; struct sadb_key *key; + struct sadb_x_sec_ctx *sec_ctx; uint16_t proto; int err; @@ -993,6 +1071,21 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct sadb_msg *hdr, x->lft.soft_add_expires_seconds = lifetime->sadb_lifetime_addtime; x->lft.soft_use_expires_seconds = lifetime->sadb_lifetime_usetime; } + + sec_ctx = (struct sadb_x_sec_ctx *) ext_hdrs[SADB_X_EXT_SEC_CTX-1]; + if (sec_ctx != NULL) { + struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); + + if (!uctx) + goto out; + + err = security_xfrm_state_alloc(x, uctx); + kfree(uctx); + + if (err) + goto out; + } + key = (struct sadb_key*) ext_hdrs[SADB_EXT_KEY_AUTH-1]; if (sa->sadb_sa_auth) { int keysize = 0; @@ -1720,6 +1813,18 @@ parse_ipsecrequests(struct xfrm_policy *xp, struct sadb_x_policy *pol) return 0; } +static inline int pfkey_xfrm_policy2sec_ctx_size(struct xfrm_policy *xp) +{ + struct xfrm_sec_ctx *xfrm_ctx = xp->security; + + if (xfrm_ctx) { + int len = sizeof(struct sadb_x_sec_ctx); + len += xfrm_ctx->ctx_len; + return PFKEY_ALIGN8(len); + } + return 0; +} + static int pfkey_xfrm_policy2msg_size(struct xfrm_policy *xp) { int sockaddr_size = pfkey_sockaddr_size(xp->family); @@ -1733,7 +1838,8 @@ static int pfkey_xfrm_policy2msg_size(struct xfrm_policy *xp) (sockaddr_size * 2) + sizeof(struct sadb_x_policy) + (xp->xfrm_nr * (sizeof(struct sadb_x_ipsecrequest) + - (socklen * 2))); + (socklen * 2))) + + pfkey_xfrm_policy2sec_ctx_size(xp); } static struct sk_buff * pfkey_xfrm_policy2msg_prep(struct xfrm_policy *xp) @@ -1757,6 +1863,8 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i struct sadb_lifetime *lifetime; struct sadb_x_policy *pol; struct sockaddr_in *sin; + struct sadb_x_sec_ctx *sec_ctx; + struct xfrm_sec_ctx *xfrm_ctx; #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) struct sockaddr_in6 *sin6; #endif @@ -1941,6 +2049,21 @@ static void pfkey_xfrm_policy2msg(struct sk_buff *skb, struct xfrm_policy *xp, i } } } + + /* security context */ + if ((xfrm_ctx = xp->security)) { + int ctx_size = pfkey_xfrm_policy2sec_ctx_size(xp); + + sec_ctx = (struct sadb_x_sec_ctx *) skb_put(skb, ctx_size); + sec_ctx->sadb_x_sec_len = ctx_size / sizeof(uint64_t); + sec_ctx->sadb_x_sec_exttype = SADB_X_EXT_SEC_CTX; + sec_ctx->sadb_x_ctx_doi = xfrm_ctx->ctx_doi; + sec_ctx->sadb_x_ctx_alg = xfrm_ctx->ctx_alg; + sec_ctx->sadb_x_ctx_len = xfrm_ctx->ctx_len; + memcpy(sec_ctx + 1, xfrm_ctx->ctx_str, + xfrm_ctx->ctx_len); + } + hdr->sadb_msg_len = size / sizeof(uint64_t); hdr->sadb_msg_reserved = atomic_read(&xp->refcnt); } @@ -1976,12 +2099,13 @@ out: static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs) { - int err; + int err = 0; struct sadb_lifetime *lifetime; struct sadb_address *sa; struct sadb_x_policy *pol; struct xfrm_policy *xp; struct km_event c; + struct sadb_x_sec_ctx *sec_ctx; if (!present_and_same_family(ext_hdrs[SADB_EXT_ADDRESS_SRC-1], ext_hdrs[SADB_EXT_ADDRESS_DST-1]) || @@ -2028,6 +2152,22 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h if (xp->selector.dport) xp->selector.dport_mask = ~0; + sec_ctx = (struct sadb_x_sec_ctx *) ext_hdrs[SADB_X_EXT_SEC_CTX-1]; + if (sec_ctx != NULL) { + struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); + + if (!uctx) { + err = -ENOBUFS; + goto out; + } + + err = security_xfrm_policy_alloc(xp, uctx); + kfree(uctx); + + if (err) + goto out; + } + xp->lft.soft_byte_limit = XFRM_INF; xp->lft.hard_byte_limit = XFRM_INF; xp->lft.soft_packet_limit = XFRM_INF; @@ -2051,10 +2191,9 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h err = xfrm_policy_insert(pol->sadb_x_policy_dir-1, xp, hdr->sadb_msg_type != SADB_X_SPDUPDATE); - if (err) { - kfree(xp); - return err; - } + + if (err) + goto out; if (hdr->sadb_msg_type == SADB_X_SPDUPDATE) c.event = XFRM_MSG_UPDPOLICY; @@ -2069,6 +2208,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h return 0; out: + security_xfrm_policy_free(xp); kfree(xp); return err; } @@ -2078,9 +2218,10 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg int err; struct sadb_address *sa; struct sadb_x_policy *pol; - struct xfrm_policy *xp; + struct xfrm_policy *xp, tmp; struct xfrm_selector sel; struct km_event c; + struct sadb_x_sec_ctx *sec_ctx; if (!present_and_same_family(ext_hdrs[SADB_EXT_ADDRESS_SRC-1], ext_hdrs[SADB_EXT_ADDRESS_DST-1]) || @@ -2109,7 +2250,24 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg if (sel.dport) sel.dport_mask = ~0; - xp = xfrm_policy_bysel(pol->sadb_x_policy_dir-1, &sel, 1); + sec_ctx = (struct sadb_x_sec_ctx *) ext_hdrs[SADB_X_EXT_SEC_CTX-1]; + memset(&tmp, 0, sizeof(struct xfrm_policy)); + + if (sec_ctx != NULL) { + struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); + + if (!uctx) + return -ENOMEM; + + err = security_xfrm_policy_alloc(&tmp, uctx); + kfree(uctx); + + if (err) + return err; + } + + xp = xfrm_policy_bysel_ctx(pol->sadb_x_policy_dir-1, &sel, tmp.security, 1); + security_xfrm_policy_free(&tmp); if (xp == NULL) return -ENOENT; @@ -2660,6 +2818,7 @@ static struct xfrm_policy *pfkey_compile_policy(u16 family, int opt, { struct xfrm_policy *xp; struct sadb_x_policy *pol = (struct sadb_x_policy*)data; + struct sadb_x_sec_ctx *sec_ctx; switch (family) { case AF_INET: @@ -2709,10 +2868,32 @@ static struct xfrm_policy *pfkey_compile_policy(u16 family, int opt, (*dir = parse_ipsecrequests(xp, pol)) < 0) goto out; + /* security context too */ + if (len >= (pol->sadb_x_policy_len*8 + + sizeof(struct sadb_x_sec_ctx))) { + char *p = (char *)pol; + struct xfrm_user_sec_ctx *uctx; + + p += pol->sadb_x_policy_len*8; + sec_ctx = (struct sadb_x_sec_ctx *)p; + if (len < pol->sadb_x_policy_len*8 + + sec_ctx->sadb_x_sec_len) + goto out; + if ((*dir = verify_sec_ctx_len(p))) + goto out; + uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); + *dir = security_xfrm_policy_alloc(xp, uctx); + kfree(uctx); + + if (*dir) + goto out; + } + *dir = pol->sadb_x_policy_dir-1; return xp; out: + security_xfrm_policy_free(xp); kfree(xp); return NULL; } diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index d19e274..64a4473 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -10,7 +10,7 @@ * YOSHIFUJI Hideaki * Split up af-specific portion * Derek Atkins Add the post_input processor - * + * */ #include @@ -256,6 +256,7 @@ void __xfrm_policy_destroy(struct xfrm_policy *policy) if (del_timer(&policy->timer)) BUG(); + security_xfrm_policy_free(policy); kfree(policy); } EXPORT_SYMBOL(__xfrm_policy_destroy); @@ -350,7 +351,8 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) write_lock_bh(&xfrm_policy_lock); for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL;) { - if (!delpol && memcmp(&policy->selector, &pol->selector, sizeof(pol->selector)) == 0) { + if (!delpol && memcmp(&policy->selector, &pol->selector, sizeof(pol->selector)) == 0 && + xfrm_sec_ctx_match(pol->security, policy->security)) { if (excl) { write_unlock_bh(&xfrm_policy_lock); return -EEXIST; @@ -416,14 +418,15 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl) } EXPORT_SYMBOL(xfrm_policy_insert); -struct xfrm_policy *xfrm_policy_bysel(int dir, struct xfrm_selector *sel, - int delete) +struct xfrm_policy *xfrm_policy_bysel_ctx(int dir, struct xfrm_selector *sel, + struct xfrm_sec_ctx *ctx, int delete) { struct xfrm_policy *pol, **p; write_lock_bh(&xfrm_policy_lock); for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL; p = &pol->next) { - if (memcmp(sel, &pol->selector, sizeof(*sel)) == 0) { + if ((memcmp(sel, &pol->selector, sizeof(*sel)) == 0) && + (xfrm_sec_ctx_match(ctx, pol->security))) { xfrm_pol_hold(pol); if (delete) *p = pol->next; @@ -438,7 +441,7 @@ struct xfrm_policy *xfrm_policy_bysel(int dir, struct xfrm_selector *sel, } return pol; } -EXPORT_SYMBOL(xfrm_policy_bysel); +EXPORT_SYMBOL(xfrm_policy_bysel_ctx); struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete) { @@ -519,7 +522,7 @@ EXPORT_SYMBOL(xfrm_policy_walk); /* Find policy to apply to this flow. */ -static void xfrm_policy_lookup(struct flowi *fl, u16 family, u8 dir, +static void xfrm_policy_lookup(struct flowi *fl, u32 sk_sid, u16 family, u8 dir, void **objp, atomic_t **obj_refp) { struct xfrm_policy *pol; @@ -533,9 +536,12 @@ static void xfrm_policy_lookup(struct flowi *fl, u16 family, u8 dir, continue; match = xfrm_selector_match(sel, fl, family); + if (match) { - xfrm_pol_hold(pol); - break; + if (!security_xfrm_policy_lookup(pol, sk_sid, dir)) { + xfrm_pol_hold(pol); + break; + } } } read_unlock_bh(&xfrm_policy_lock); @@ -543,15 +549,37 @@ static void xfrm_policy_lookup(struct flowi *fl, u16 family, u8 dir, *obj_refp = &pol->refcnt; } -static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struct flowi *fl) +static inline int policy_to_flow_dir(int dir) +{ + if (XFRM_POLICY_IN == FLOW_DIR_IN && + XFRM_POLICY_OUT == FLOW_DIR_OUT && + XFRM_POLICY_FWD == FLOW_DIR_FWD) + return dir; + switch (dir) { + default: + case XFRM_POLICY_IN: + return FLOW_DIR_IN; + case XFRM_POLICY_OUT: + return FLOW_DIR_OUT; + case XFRM_POLICY_FWD: + return FLOW_DIR_FWD; + }; +} + +static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struct flowi *fl, u32 sk_sid) { struct xfrm_policy *pol; read_lock_bh(&xfrm_policy_lock); if ((pol = sk->sk_policy[dir]) != NULL) { - int match = xfrm_selector_match(&pol->selector, fl, + int match = xfrm_selector_match(&pol->selector, fl, sk->sk_family); + int err = 0; + if (match) + err = security_xfrm_policy_lookup(pol, sk_sid, policy_to_flow_dir(dir)); + + if (match && !err) xfrm_pol_hold(pol); else pol = NULL; @@ -624,6 +652,10 @@ static struct xfrm_policy *clone_policy(struct xfrm_policy *old, int dir) if (newp) { newp->selector = old->selector; + if (security_xfrm_policy_clone(old, newp)) { + kfree(newp); + return NULL; /* ENOMEM */ + } newp->lft = old->lft; newp->curlft = old->curlft; newp->action = old->action; @@ -735,22 +767,6 @@ xfrm_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int nx, return err; } -static inline int policy_to_flow_dir(int dir) -{ - if (XFRM_POLICY_IN == FLOW_DIR_IN && - XFRM_POLICY_OUT == FLOW_DIR_OUT && - XFRM_POLICY_FWD == FLOW_DIR_FWD) - return dir; - switch (dir) { - default: - case XFRM_POLICY_IN: - return FLOW_DIR_IN; - case XFRM_POLICY_OUT: - return FLOW_DIR_OUT; - case XFRM_POLICY_FWD: - return FLOW_DIR_FWD; - }; -} static int stale_bundle(struct dst_entry *dst); @@ -769,19 +785,20 @@ int xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl, int err; u32 genid; u16 family = dst_orig->ops->family; + u8 dir = policy_to_flow_dir(XFRM_POLICY_OUT); + u32 sk_sid = security_sk_sid(sk, fl, dir); restart: genid = atomic_read(&flow_cache_genid); policy = NULL; if (sk && sk->sk_policy[1]) - policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl); + policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl, sk_sid); if (!policy) { /* To accelerate a bit... */ if ((dst_orig->flags & DST_NOXFRM) || !xfrm_policy_list[XFRM_POLICY_OUT]) return 0; - policy = flow_cache_lookup(fl, family, - policy_to_flow_dir(XFRM_POLICY_OUT), + policy = flow_cache_lookup(fl, sk_sid, family, dir, xfrm_policy_lookup); } @@ -962,16 +979,20 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, { struct xfrm_policy *pol; struct flowi fl; + u8 fl_dir = policy_to_flow_dir(dir); + u32 sk_sid; if (_decode_session(skb, &fl, family) < 0) return 0; + sk_sid = security_sk_sid(sk, &fl, fl_dir); + /* First, check used SA against their selectors. */ if (skb->sp) { int i; for (i=skb->sp->len-1; i>=0; i--) { - struct sec_decap_state *xvec = &(skb->sp->x[i]); + struct sec_decap_state *xvec = &(skb->sp->x[i]); if (!xfrm_selector_match(&xvec->xvec->sel, &fl, family)) return 0; @@ -986,11 +1007,10 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, pol = NULL; if (sk && sk->sk_policy[dir]) - pol = xfrm_sk_policy_lookup(sk, dir, &fl); + pol = xfrm_sk_policy_lookup(sk, dir, &fl, sk_sid); if (!pol) - pol = flow_cache_lookup(&fl, family, - policy_to_flow_dir(dir), + pol = flow_cache_lookup(&fl, sk_sid, family, fl_dir, xfrm_policy_lookup); if (!pol) diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 479effc..e12d0be 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -10,7 +10,7 @@ * Split up af-specific functions * Derek Atkins * Add UDP Encapsulation - * + * */ #include @@ -70,6 +70,7 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x) x->type->destructor(x); xfrm_put_type(x->type); } + security_xfrm_state_free(x); kfree(x); } @@ -343,7 +344,8 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, selector. */ if (x->km.state == XFRM_STATE_VALID) { - if (!xfrm_selector_match(&x->sel, fl, family)) + if (!xfrm_selector_match(&x->sel, fl, family) || + !xfrm_sec_ctx_match(pol->security, x->security)) continue; if (!best || best->km.dying > x->km.dying || @@ -354,7 +356,8 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, acquire_in_progress = 1; } else if (x->km.state == XFRM_STATE_ERROR || x->km.state == XFRM_STATE_EXPIRED) { - if (xfrm_selector_match(&x->sel, fl, family)) + if (xfrm_selector_match(&x->sel, fl, family) && + xfrm_sec_ctx_match(pol->security, x->security)) error = -ESRCH; } } diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 0cdd9a0..92e2b80 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -7,7 +7,7 @@ * Kazunori MIYAZAWA @USAGI * Kunihiro Ishiguro * IPv6 support - * + * */ #include @@ -88,6 +88,34 @@ static int verify_encap_tmpl(struct rtattr **xfrma) return 0; } + +static inline int verify_sec_ctx_len(struct rtattr **xfrma) +{ + struct rtattr *rt = xfrma[XFRMA_SEC_CTX - 1]; + struct xfrm_user_sec_ctx *uctx; + int len = 0; + + if (!rt) + return 0; + + if (rt->rta_len < sizeof(*uctx)) + return -EINVAL; + + uctx = RTA_DATA(rt); + + if (uctx->ctx_len > PAGE_SIZE) + return -EINVAL; + + len += sizeof(struct xfrm_user_sec_ctx); + len += uctx->ctx_len; + + if (uctx->len != len) + return -EINVAL; + + return 0; +} + + static int verify_newsa_info(struct xfrm_usersa_info *p, struct rtattr **xfrma) { @@ -145,6 +173,8 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, goto out; if ((err = verify_encap_tmpl(xfrma))) goto out; + if ((err = verify_sec_ctx_len(xfrma))) + goto out; err = -EINVAL; switch (p->mode) { @@ -209,6 +239,30 @@ static int attach_encap_tmpl(struct xfrm_encap_tmpl **encapp, struct rtattr *u_a return 0; } + +static inline int xfrm_user_sec_ctx_size(struct xfrm_policy *xp) +{ + struct xfrm_sec_ctx *xfrm_ctx = xp->security; + int len = 0; + + if (xfrm_ctx) { + len += sizeof(struct xfrm_user_sec_ctx); + len += xfrm_ctx->ctx_len; + } + return len; +} + +static int attach_sec_ctx(struct xfrm_state *x, struct rtattr *u_arg) +{ + struct xfrm_user_sec_ctx *uctx; + + if (!u_arg) + return 0; + + uctx = RTA_DATA(u_arg); + return security_xfrm_state_alloc(x, uctx); +} + static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *p) { memcpy(&x->id, &p->id, sizeof(x->id)); @@ -253,6 +307,9 @@ static struct xfrm_state *xfrm_state_construct(struct xfrm_usersa_info *p, if (err) goto error; + if ((err = attach_sec_ctx(x, xfrma[XFRMA_SEC_CTX-1]))) + goto error; + x->km.seq = p->seq; return x; @@ -272,11 +329,11 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma) int err; struct km_event c; - err = verify_newsa_info(p, (struct rtattr **) xfrma); + err = verify_newsa_info(p, (struct rtattr **)xfrma); if (err) return err; - x = xfrm_state_construct(p, (struct rtattr **) xfrma, &err); + x = xfrm_state_construct(p, (struct rtattr **)xfrma, &err); if (!x) return err; @@ -390,6 +447,19 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr) if (x->encap) RTA_PUT(skb, XFRMA_ENCAP, sizeof(*x->encap), x->encap); + if (x->security) { + int ctx_size = sizeof(struct xfrm_sec_ctx) + + x->security->ctx_len; + struct rtattr *rt = __RTA_PUT(skb, XFRMA_SEC_CTX, ctx_size); + struct xfrm_user_sec_ctx *uctx = RTA_DATA(rt); + + uctx->exttype = XFRMA_SEC_CTX; + uctx->len = ctx_size; + uctx->ctx_doi = x->security->ctx_doi; + uctx->ctx_alg = x->security->ctx_alg; + uctx->ctx_len = x->security->ctx_len; + memcpy(uctx + 1, x->security->ctx_str, x->security->ctx_len); + } nlh->nlmsg_len = skb->tail - b; out: sp->this_idx++; @@ -603,6 +673,18 @@ static int verify_newpolicy_info(struct xfrm_userpolicy_info *p) return verify_policy_dir(p->dir); } +static int copy_from_user_sec_ctx(struct xfrm_policy *pol, struct rtattr **xfrma) +{ + struct rtattr *rt = xfrma[XFRMA_SEC_CTX-1]; + struct xfrm_user_sec_ctx *uctx; + + if (!rt) + return 0; + + uctx = RTA_DATA(rt); + return security_xfrm_policy_alloc(pol, uctx); +} + static void copy_templates(struct xfrm_policy *xp, struct xfrm_user_tmpl *ut, int nr) { @@ -681,7 +763,10 @@ static struct xfrm_policy *xfrm_policy_construct(struct xfrm_userpolicy_info *p, } copy_from_user_policy(xp, p); - err = copy_from_user_tmpl(xp, xfrma); + + if (!(err = copy_from_user_tmpl(xp, xfrma))) + err = copy_from_user_sec_ctx(xp, xfrma); + if (err) { *errp = err; kfree(xp); @@ -702,8 +787,11 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr err = verify_newpolicy_info(p); if (err) return err; + err = verify_sec_ctx_len((struct rtattr **)xfrma); + if (err) + return err; - xp = xfrm_policy_construct(p, (struct rtattr **) xfrma, &err); + xp = xfrm_policy_construct(p, (struct rtattr **)xfrma, &err); if (!xp) return err; @@ -761,6 +849,27 @@ rtattr_failure: return -1; } +static int copy_to_user_sec_ctx(struct xfrm_policy *xp, struct sk_buff *skb) +{ + if (xp->security) { + int ctx_size = sizeof(struct xfrm_sec_ctx) + + xp->security->ctx_len; + struct rtattr *rt = __RTA_PUT(skb, XFRMA_SEC_CTX, ctx_size); + struct xfrm_user_sec_ctx *uctx = RTA_DATA(rt); + + uctx->exttype = XFRMA_SEC_CTX; + uctx->len = ctx_size; + uctx->ctx_doi = xp->security->ctx_doi; + uctx->ctx_alg = xp->security->ctx_alg; + uctx->ctx_len = xp->security->ctx_len; + memcpy(uctx + 1, xp->security->ctx_str, xp->security->ctx_len); + } + return 0; + + rtattr_failure: + return -1; +} + static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr) { struct xfrm_dump_info *sp = ptr; @@ -782,6 +891,8 @@ static int dump_one_policy(struct xfrm_policy *xp, int dir, int count, void *ptr copy_to_user_policy(xp, p, dir); if (copy_to_user_tmpl(xp, skb) < 0) goto nlmsg_failure; + if (copy_to_user_sec_ctx(xp, skb)) + goto nlmsg_failure; nlh->nlmsg_len = skb->tail - b; out: @@ -852,8 +963,25 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr if (p->index) xp = xfrm_policy_byid(p->dir, p->index, delete); - else - xp = xfrm_policy_bysel(p->dir, &p->sel, delete); + else { + struct rtattr **rtattrs = (struct rtattr **)xfrma; + struct rtattr *rt = rtattrs[XFRMA_SEC_CTX-1]; + struct xfrm_policy tmp; + + err = verify_sec_ctx_len(rtattrs); + if (err) + return err; + + memset(&tmp, 0, sizeof(struct xfrm_policy)); + if (rt) { + struct xfrm_user_sec_ctx *uctx = RTA_DATA(rt); + + if ((err = security_xfrm_policy_alloc(&tmp, uctx))) + return err; + } + xp = xfrm_policy_bysel_ctx(p->dir, &p->sel, tmp.security, delete); + security_xfrm_policy_free(&tmp); + } if (xp == NULL) return -ENOENT; @@ -1224,6 +1352,8 @@ static int build_acquire(struct sk_buff *skb, struct xfrm_state *x, if (copy_to_user_tmpl(xp, skb) < 0) goto nlmsg_failure; + if (copy_to_user_sec_ctx(xp, skb)) + goto nlmsg_failure; nlh->nlmsg_len = skb->tail - b; return skb->len; @@ -1241,6 +1371,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire)); + len += RTA_SPACE(xfrm_user_sec_ctx_size(xp)); skb = alloc_skb(len, GFP_ATOMIC); if (skb == NULL) return -ENOMEM; @@ -1324,6 +1455,8 @@ static int build_polexpire(struct sk_buff *skb, struct xfrm_policy *xp, copy_to_user_policy(xp, &upe->pol, dir); if (copy_to_user_tmpl(xp, skb) < 0) goto nlmsg_failure; + if (copy_to_user_sec_ctx(xp, skb)) + goto nlmsg_failure; upe->hard = !!hard; nlh->nlmsg_len = skb->tail - b; @@ -1341,6 +1474,7 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, struct km_eve len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire)); + len += RTA_SPACE(xfrm_user_sec_ctx_size(xp)); skb = alloc_skb(len, GFP_ATOMIC); if (skb == NULL) return -ENOMEM; diff --git a/security/Kconfig b/security/Kconfig index 64d3f1e..34f5934 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -54,6 +54,19 @@ config SECURITY_NETWORK implement socket and networking access controls. If you are unsure how to answer this question, answer N. +config SECURITY_NETWORK_XFRM + bool "XFRM (IPSec) Networking Security Hooks" + depends on XFRM && SECURITY_NETWORK + help + This enables the XFRM (IPSec) networking security hooks. + If enabled, a security module can use these hooks to + implement per-packet access controls based on labels + derived from IPSec policy. Non-IPSec communications are + designated as unlabelled, and only sockets authorized + to communicate unlabelled data can send without using + IPSec. + If you are unsure how to answer this question, answer N. + config SECURITY_CAPABILITIES tristate "Default Linux Capabilities" depends on SECURITY diff --git a/security/dummy.c b/security/dummy.c index 3ca5f2b..a15c547 100644 --- a/security/dummy.c +++ b/security/dummy.c @@ -776,8 +776,42 @@ static inline int dummy_sk_alloc_security (struct sock *sk, int family, gfp_t pr static inline void dummy_sk_free_security (struct sock *sk) { } + +static unsigned int dummy_sk_getsid(struct sock *sk, struct flowi *fl, u8 dir) +{ + return 0; +} #endif /* CONFIG_SECURITY_NETWORK */ +#ifdef CONFIG_SECURITY_NETWORK_XFRM +static int dummy_xfrm_policy_alloc_security(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx) +{ + return 0; +} + +static inline int dummy_xfrm_policy_clone_security(struct xfrm_policy *old, struct xfrm_policy *new) +{ + return 0; +} + +static void dummy_xfrm_policy_free_security(struct xfrm_policy *xp) +{ +} + +static int dummy_xfrm_state_alloc_security(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx) +{ + return 0; +} + +static void dummy_xfrm_state_free_security(struct xfrm_state *x) +{ +} + +static int dummy_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir) +{ + return 0; +} +#endif /* CONFIG_SECURITY_NETWORK_XFRM */ static int dummy_register_security (const char *name, struct security_operations *ops) { return -EINVAL; @@ -970,7 +1004,16 @@ void security_fixup_ops (struct security_operations *ops) set_to_dummy_if_null(ops, socket_getpeersec); set_to_dummy_if_null(ops, sk_alloc_security); set_to_dummy_if_null(ops, sk_free_security); -#endif /* CONFIG_SECURITY_NETWORK */ + set_to_dummy_if_null(ops, sk_getsid); + #endif /* CONFIG_SECURITY_NETWORK */ +#ifdef CONFIG_SECURITY_NETWORK_XFRM + set_to_dummy_if_null(ops, xfrm_policy_alloc_security); + set_to_dummy_if_null(ops, xfrm_policy_clone_security); + set_to_dummy_if_null(ops, xfrm_policy_free_security); + set_to_dummy_if_null(ops, xfrm_state_alloc_security); + set_to_dummy_if_null(ops, xfrm_state_free_security); + set_to_dummy_if_null(ops, xfrm_policy_lookup); +#endif /* CONFIG_SECURITY_NETWORK_XFRM */ #ifdef CONFIG_KEYS set_to_dummy_if_null(ops, key_alloc); set_to_dummy_if_null(ops, key_free); -- cgit v1.1 From d28d1e080132f28ab773291f10ad6acca4c8bba2 Mon Sep 17 00:00:00 2001 From: Trent Jaeger Date: Tue, 13 Dec 2005 23:12:40 -0800 Subject: [LSM-IPSec]: Per-packet access control. This patch series implements per packet access control via the extension of the Linux Security Modules (LSM) interface by hooks in the XFRM and pfkey subsystems that leverage IPSec security associations to label packets. Extensions to the SELinux LSM are included that leverage the patch for this purpose. This patch implements the changes necessary to the SELinux LSM to create, deallocate, and use security contexts for policies (xfrm_policy) and security associations (xfrm_state) that enable control of a socket's ability to send and receive packets. Patch purpose: The patch is designed to enable the SELinux LSM to implement access control on individual packets based on the strongly authenticated IPSec security association. Such access controls augment the existing ones in SELinux based on network interface and IP address. The former are very coarse-grained, and the latter can be spoofed. By using IPSec, the SELinux can control access to remote hosts based on cryptographic keys generated using the IPSec mechanism. This enables access control on a per-machine basis or per-application if the remote machine is running the same mechanism and trusted to enforce the access control policy. Patch design approach: The patch's main function is to authorize a socket's access to a IPSec policy based on their security contexts. Since the communication is implemented by a security association, the patch ensures that the security association's negotiated and used have the same security context. The patch enables allocation and deallocation of such security contexts for policies and security associations. It also enables copying of the security context when policies are cloned. Lastly, the patch ensures that packets that are sent without using a IPSec security assocation with a security context are allowed to be sent in that manner. A presentation available at www.selinux-symposium.org/2005/presentations/session2/2-3-jaeger.pdf from the SELinux symposium describes the overall approach. Patch implementation details: The function which authorizes a socket to perform a requested operation (send/receive) on a IPSec policy (xfrm_policy) is selinux_xfrm_policy_lookup. The Netfilter and rcv_skb hooks ensure that if a IPSec SA with a securit y association has not been used, then the socket is allowed to send or receive the packet, respectively. The patch implements SELinux function for allocating security contexts when policies (xfrm_policy) are created via the pfkey or xfrm_user interfaces via selinux_xfrm_policy_alloc. When a security association is built, SELinux allocates the security context designated by the XFRM subsystem which is based on that of the authorized policy via selinux_xfrm_state_alloc. When a xfrm_policy is cloned, the security context of that policy, if any, is copied to the clone via selinux_xfrm_policy_clone. When a xfrm_policy or xfrm_state is freed, its security context, if any is also freed at selinux_xfrm_policy_free or selinux_xfrm_state_free. Testing: The SELinux authorization function is tested using ipsec-tools. We created policies and security associations with particular security contexts and added SELinux access control policy entries to verify the authorization decision. We also made sure that packets for which no security context was supplied (which either did or did not use security associations) were authorized using an unlabelled context. Signed-off-by: Trent Jaeger Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- security/selinux/Makefile | 2 + security/selinux/hooks.c | 39 ++++ security/selinux/include/av_perm_to_string.h | 2 + security/selinux/include/av_permissions.h | 2 + security/selinux/include/xfrm.h | 54 +++++ security/selinux/xfrm.c | 311 +++++++++++++++++++++++++++ 6 files changed, 410 insertions(+) create mode 100644 security/selinux/include/xfrm.h create mode 100644 security/selinux/xfrm.c diff --git a/security/selinux/Makefile b/security/selinux/Makefile index b038cd0..06d54d9 100644 --- a/security/selinux/Makefile +++ b/security/selinux/Makefile @@ -8,5 +8,7 @@ selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o selinux-$(CONFIG_SECURITY_NETWORK) += netif.o +selinux-$(CONFIG_SECURITY_NETWORK_XFRM) += xfrm.o + EXTRA_CFLAGS += -Isecurity/selinux/include diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index fc77443..3d496ea 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -73,6 +73,7 @@ #include "avc.h" #include "objsec.h" #include "netif.h" +#include "xfrm.h" #define XATTR_SELINUX_SUFFIX "selinux" #define XATTR_NAME_SELINUX XATTR_SECURITY_PREFIX XATTR_SELINUX_SUFFIX @@ -3349,6 +3350,10 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) err = avc_has_perm(sock_sid, port_sid, sock_class, recv_perm, &ad); } + + if (!err) + err = selinux_xfrm_sock_rcv_skb(sock_sid, skb); + out: return err; } @@ -3401,6 +3406,24 @@ static void selinux_sk_free_security(struct sock *sk) sk_free_security(sk); } +static unsigned int selinux_sk_getsid_security(struct sock *sk, struct flowi *fl, u8 dir) +{ + struct inode_security_struct *isec; + u32 sock_sid = SECINITSID_ANY_SOCKET; + + if (!sk) + return selinux_no_sk_sid(fl); + + read_lock_bh(&sk->sk_callback_lock); + isec = get_sock_isec(sk); + + if (isec) + sock_sid = isec->sid; + + read_unlock_bh(&sk->sk_callback_lock); + return sock_sid; +} + static int selinux_nlmsg_perm(struct sock *sk, struct sk_buff *skb) { int err = 0; @@ -3536,6 +3559,11 @@ static unsigned int selinux_ip_postroute_last(unsigned int hooknum, send_perm, &ad) ? NF_DROP : NF_ACCEPT; } + if (err != NF_ACCEPT) + goto out; + + err = selinux_xfrm_postroute_last(isec->sid, skb); + out: return err; } @@ -4380,6 +4408,16 @@ static struct security_operations selinux_ops = { .socket_getpeersec = selinux_socket_getpeersec, .sk_alloc_security = selinux_sk_alloc_security, .sk_free_security = selinux_sk_free_security, + .sk_getsid = selinux_sk_getsid_security, +#endif + +#ifdef CONFIG_SECURITY_NETWORK_XFRM + .xfrm_policy_alloc_security = selinux_xfrm_policy_alloc, + .xfrm_policy_clone_security = selinux_xfrm_policy_clone, + .xfrm_policy_free_security = selinux_xfrm_policy_free, + .xfrm_state_alloc_security = selinux_xfrm_state_alloc, + .xfrm_state_free_security = selinux_xfrm_state_free, + .xfrm_policy_lookup = selinux_xfrm_policy_lookup, #endif }; @@ -4491,6 +4529,7 @@ static int __init selinux_nf_ip_init(void) panic("SELinux: nf_register_hook for IPv6: error %d\n", err); #endif /* IPV6 */ + out: return err; } diff --git a/security/selinux/include/av_perm_to_string.h b/security/selinux/include/av_perm_to_string.h index 1deb59e..71aeb12 100644 --- a/security/selinux/include/av_perm_to_string.h +++ b/security/selinux/include/av_perm_to_string.h @@ -238,3 +238,5 @@ S_(SECCLASS_NSCD, NSCD__SHMEMHOST, "shmemhost") S_(SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO, "sendto") S_(SECCLASS_ASSOCIATION, ASSOCIATION__RECVFROM, "recvfrom") + S_(SECCLASS_ASSOCIATION, ASSOCIATION__RELABELFROM, "relabelfrom") + S_(SECCLASS_ASSOCIATION, ASSOCIATION__RELABELTO, "relabelto") diff --git a/security/selinux/include/av_permissions.h b/security/selinux/include/av_permissions.h index a78b5d5..d1d0996 100644 --- a/security/selinux/include/av_permissions.h +++ b/security/selinux/include/av_permissions.h @@ -908,6 +908,8 @@ #define ASSOCIATION__SENDTO 0x00000001UL #define ASSOCIATION__RECVFROM 0x00000002UL +#define ASSOCIATION__RELABELFROM 0x00000004UL +#define ASSOCIATION__RELABELTO 0x00000008UL #define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL 0x00000001UL #define NETLINK_KOBJECT_UEVENT_SOCKET__READ 0x00000002UL diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h new file mode 100644 index 0000000..8e87996 --- /dev/null +++ b/security/selinux/include/xfrm.h @@ -0,0 +1,54 @@ +/* + * SELinux support for the XFRM LSM hooks + * + * Author : Trent Jaeger, + */ +#ifndef _SELINUX_XFRM_H_ +#define _SELINUX_XFRM_H_ + +int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx); +int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new); +void selinux_xfrm_policy_free(struct xfrm_policy *xp); +int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx); +void selinux_xfrm_state_free(struct xfrm_state *x); +int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir); + +/* + * Extract the security blob from the sock (it's actually on the socket) + */ +static inline struct inode_security_struct *get_sock_isec(struct sock *sk) +{ + if (!sk->sk_socket) + return NULL; + + return SOCK_INODE(sk->sk_socket)->i_security; +} + + +static inline u32 selinux_no_sk_sid(struct flowi *fl) +{ + /* NOTE: no sock occurs on ICMP reply, forwards, ... */ + /* icmp_reply: authorize as kernel packet */ + if (fl && fl->proto == IPPROTO_ICMP) { + return SECINITSID_KERNEL; + } + + return SECINITSID_ANY_SOCKET; +} + +#ifdef CONFIG_SECURITY_NETWORK_XFRM +int selinux_xfrm_sock_rcv_skb(u32 sid, struct sk_buff *skb); +int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb); +#else +static inline int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb) +{ + return 0; +} + +static inline int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb) +{ + return NF_ACCEPT; +} +#endif + +#endif /* _SELINUX_XFRM_H_ */ diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c new file mode 100644 index 0000000..c4d87d4 --- /dev/null +++ b/security/selinux/xfrm.c @@ -0,0 +1,311 @@ +/* + * NSA Security-Enhanced Linux (SELinux) security module + * + * This file contains the SELinux XFRM hook function implementations. + * + * Authors: Serge Hallyn + * Trent Jaeger + * + * Copyright (C) 2005 International Business Machines Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + */ + +/* + * USAGE: + * NOTES: + * 1. Make sure to enable the following options in your kernel config: + * CONFIG_SECURITY=y + * CONFIG_SECURITY_NETWORK=y + * CONFIG_SECURITY_NETWORK_XFRM=y + * CONFIG_SECURITY_SELINUX=m/y + * ISSUES: + * 1. Caching packets, so they are not dropped during negotiation + * 2. Emulating a reasonable SO_PEERSEC across machines + * 3. Testing addition of sk_policy's with security context via setsockopt + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "avc.h" +#include "objsec.h" +#include "xfrm.h" + + +/* + * Returns true if an LSM/SELinux context + */ +static inline int selinux_authorizable_ctx(struct xfrm_sec_ctx *ctx) +{ + return (ctx && + (ctx->ctx_doi == XFRM_SC_DOI_LSM) && + (ctx->ctx_alg == XFRM_SC_ALG_SELINUX)); +} + +/* + * Returns true if the xfrm contains a security blob for SELinux + */ +static inline int selinux_authorizable_xfrm(struct xfrm_state *x) +{ + return selinux_authorizable_ctx(x->security); +} + +/* + * LSM hook implementation that authorizes that a socket can be used + * with the corresponding xfrm_sec_ctx and direction. + */ +int selinux_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir) +{ + int rc = 0; + u32 sel_sid = SECINITSID_UNLABELED; + struct xfrm_sec_ctx *ctx; + + /* Context sid is either set to label or ANY_ASSOC */ + if ((ctx = xp->security)) { + if (!selinux_authorizable_ctx(ctx)) + return -EINVAL; + + sel_sid = ctx->ctx_sid; + } + + rc = avc_has_perm(sk_sid, sel_sid, SECCLASS_ASSOCIATION, + ((dir == FLOW_DIR_IN) ? ASSOCIATION__RECVFROM : + ((dir == FLOW_DIR_OUT) ? ASSOCIATION__SENDTO : + (ASSOCIATION__SENDTO | ASSOCIATION__RECVFROM))), + NULL); + + return rc; +} + +/* + * Security blob allocation for xfrm_policy and xfrm_state + * CTX does not have a meaningful value on input + */ +static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *uctx) +{ + int rc = 0; + struct task_security_struct *tsec = current->security; + struct xfrm_sec_ctx *ctx; + + BUG_ON(!uctx); + BUG_ON(uctx->ctx_doi != XFRM_SC_ALG_SELINUX); + + if (uctx->ctx_len >= PAGE_SIZE) + return -ENOMEM; + + *ctxp = ctx = kmalloc(sizeof(*ctx) + + uctx->ctx_len, + GFP_KERNEL); + + if (!ctx) + return -ENOMEM; + + ctx->ctx_doi = uctx->ctx_doi; + ctx->ctx_len = uctx->ctx_len; + ctx->ctx_alg = uctx->ctx_alg; + + memcpy(ctx->ctx_str, + uctx+1, + ctx->ctx_len); + rc = security_context_to_sid(ctx->ctx_str, + ctx->ctx_len, + &ctx->ctx_sid); + + if (rc) + goto out; + + /* + * Does the subject have permission to set security or permission to + * do the relabel? + * Must be permitted to relabel from default socket type (process type) + * to specified context + */ + rc = avc_has_perm(tsec->sid, tsec->sid, + SECCLASS_ASSOCIATION, + ASSOCIATION__RELABELFROM, NULL); + if (rc) + goto out; + + rc = avc_has_perm(tsec->sid, ctx->ctx_sid, + SECCLASS_ASSOCIATION, + ASSOCIATION__RELABELTO, NULL); + if (rc) + goto out; + + return rc; + +out: + *ctxp = 0; + kfree(ctx); + return rc; +} + +/* + * LSM hook implementation that allocs and transfers uctx spec to + * xfrm_policy. + */ +int selinux_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *uctx) +{ + int err; + + BUG_ON(!xp); + + err = selinux_xfrm_sec_ctx_alloc(&xp->security, uctx); + return err; +} + + +/* + * LSM hook implementation that copies security data structure from old to + * new for policy cloning. + */ +int selinux_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new) +{ + struct xfrm_sec_ctx *old_ctx, *new_ctx; + + old_ctx = old->security; + + if (old_ctx) { + new_ctx = new->security = kmalloc(sizeof(*new_ctx) + + old_ctx->ctx_len, + GFP_KERNEL); + + if (!new_ctx) + return -ENOMEM; + + memcpy(new_ctx, old_ctx, sizeof(*new_ctx)); + memcpy(new_ctx->ctx_str, old_ctx->ctx_str, new_ctx->ctx_len); + } + return 0; +} + +/* + * LSM hook implementation that frees xfrm_policy security information. + */ +void selinux_xfrm_policy_free(struct xfrm_policy *xp) +{ + struct xfrm_sec_ctx *ctx = xp->security; + if (ctx) + kfree(ctx); +} + +/* + * LSM hook implementation that allocs and transfers sec_ctx spec to + * xfrm_state. + */ +int selinux_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *uctx) +{ + int err; + + BUG_ON(!x); + + err = selinux_xfrm_sec_ctx_alloc(&x->security, uctx); + return err; +} + +/* + * LSM hook implementation that frees xfrm_state security information. + */ +void selinux_xfrm_state_free(struct xfrm_state *x) +{ + struct xfrm_sec_ctx *ctx = x->security; + if (ctx) + kfree(ctx); +} + +/* + * LSM hook that controls access to unlabelled packets. If + * a xfrm_state is authorizable (defined by macro) then it was + * already authorized by the IPSec process. If not, then + * we need to check for unlabelled access since this may not have + * gone thru the IPSec process. + */ +int selinux_xfrm_sock_rcv_skb(u32 isec_sid, struct sk_buff *skb) +{ + int i, rc = 0; + struct sec_path *sp; + + sp = skb->sp; + + if (sp) { + /* + * __xfrm_policy_check does not approve unless xfrm_policy_ok + * says that spi's match for policy and the socket. + * + * Only need to verify the existence of an authorizable sp. + */ + for (i = 0; i < sp->len; i++) { + struct xfrm_state *x = sp->x[i].xvec; + + if (x && selinux_authorizable_xfrm(x)) + goto accept; + } + } + + /* check SELinux sock for unlabelled access */ + rc = avc_has_perm(isec_sid, SECINITSID_UNLABELED, SECCLASS_ASSOCIATION, + ASSOCIATION__RECVFROM, NULL); + if (rc) + goto drop; + +accept: + return 0; + +drop: + return rc; +} + +/* + * POSTROUTE_LAST hook's XFRM processing: + * If we have no security association, then we need to determine + * whether the socket is allowed to send to an unlabelled destination. + * If we do have a authorizable security association, then it has already been + * checked in xfrm_policy_lookup hook. + */ +int selinux_xfrm_postroute_last(u32 isec_sid, struct sk_buff *skb) +{ + struct dst_entry *dst; + int rc = 0; + + dst = skb->dst; + + if (dst) { + struct dst_entry *dst_test; + + for (dst_test = dst; dst_test != 0; + dst_test = dst_test->child) { + struct xfrm_state *x = dst_test->xfrm; + + if (x && selinux_authorizable_xfrm(x)) + goto accept; + } + } + + rc = avc_has_perm(isec_sid, SECINITSID_UNLABELED, SECCLASS_ASSOCIATION, + ASSOCIATION__SENDTO, NULL); + if (rc) + goto drop; + +accept: + return NF_ACCEPT; + +drop: + return NF_DROP; +} -- cgit v1.1 From 018da8f44c066d5fc390011b8c953135f973b3a9 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 13 Dec 2005 23:13:00 -0800 Subject: [TCP] BIC: remove low utilization code. The latest BICTCP patch at: http://www.csc.ncsu.edu:8080/faculty/rhee/export/bitcp/index_files/Page546.htm disables the low_utilization feature of BICTCP because it doesn't work in some cases. This patch removes it. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/tcp_bic.c | 81 +----------------------------------------------------- 1 file changed, 1 insertion(+), 80 deletions(-) diff --git a/net/ipv4/tcp_bic.c b/net/ipv4/tcp_bic.c index 1d0cd86..cf8c75f 100644 --- a/net/ipv4/tcp_bic.c +++ b/net/ipv4/tcp_bic.c @@ -30,8 +30,6 @@ static int fast_convergence = 1; static int max_increment = 16; static int low_window = 14; static int beta = 819; /* = 819/1024 (BICTCP_BETA_SCALE) */ -static int low_utilization_threshold = 153; -static int low_utilization_period = 2; static int initial_ssthresh = 100; static int smooth_part = 20; @@ -43,10 +41,6 @@ module_param(low_window, int, 0644); MODULE_PARM_DESC(low_window, "lower bound on congestion window (for TCP friendliness)"); module_param(beta, int, 0644); MODULE_PARM_DESC(beta, "beta for multiplicative increase"); -module_param(low_utilization_threshold, int, 0644); -MODULE_PARM_DESC(low_utilization_threshold, "percent (scaled by 1024) for low utilization mode"); -module_param(low_utilization_period, int, 0644); -MODULE_PARM_DESC(low_utilization_period, "if average delay exceeds then goto to low utilization mode (seconds)"); module_param(initial_ssthresh, int, 0644); MODULE_PARM_DESC(initial_ssthresh, "initial value of slow start threshold"); module_param(smooth_part, int, 0644); @@ -60,11 +54,6 @@ struct bictcp { u32 loss_cwnd; /* congestion window at last loss */ u32 last_cwnd; /* the last snd_cwnd */ u32 last_time; /* time when updated last_cwnd */ - u32 delay_min; /* min delay */ - u32 delay_max; /* max delay */ - u32 last_delay; - u8 low_utilization;/* 0: high; 1: low */ - u32 low_utilization_start; /* starting time of low utilization detection*/ u32 epoch_start; /* beginning of an epoch */ #define ACK_RATIO_SHIFT 4 u32 delayed_ack; /* estimate the ratio of Packets/ACKs << 4 */ @@ -77,11 +66,6 @@ static inline void bictcp_reset(struct bictcp *ca) ca->loss_cwnd = 0; ca->last_cwnd = 0; ca->last_time = 0; - ca->delay_min = 0; - ca->delay_max = 0; - ca->last_delay = 0; - ca->low_utilization = 0; - ca->low_utilization_start = 0; ca->epoch_start = 0; ca->delayed_ack = 2 << ACK_RATIO_SHIFT; } @@ -143,8 +127,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) } /* if in slow start or link utilization is very low */ - if ( ca->loss_cwnd == 0 || - (cwnd > ca->loss_cwnd && ca->low_utilization)) { + if (ca->loss_cwnd == 0) { if (ca->cnt > 20) /* increase cwnd 5% per RTT */ ca->cnt = 20; } @@ -154,69 +137,12 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) ca->cnt = 1; } - -/* Detect low utilization in congestion avoidance */ -static inline void bictcp_low_utilization(struct sock *sk, int flag) -{ - const struct tcp_sock *tp = tcp_sk(sk); - struct bictcp *ca = inet_csk_ca(sk); - u32 dist, delay; - - /* No time stamp */ - if (!(tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr) || - /* Discard delay samples right after fast recovery */ - tcp_time_stamp < ca->epoch_start + HZ || - /* this delay samples may not be accurate */ - flag == 0) { - ca->last_delay = 0; - goto notlow; - } - - delay = ca->last_delay<<3; /* use the same scale as tp->srtt*/ - ca->last_delay = tcp_time_stamp - tp->rx_opt.rcv_tsecr; - if (delay == 0) /* no previous delay sample */ - goto notlow; - - /* first time call or link delay decreases */ - if (ca->delay_min == 0 || ca->delay_min > delay) { - ca->delay_min = ca->delay_max = delay; - goto notlow; - } - - if (ca->delay_max < delay) - ca->delay_max = delay; - - /* utilization is low, if avg delay < dist*threshold - for checking_period time */ - dist = ca->delay_max - ca->delay_min; - if (dist <= ca->delay_min>>6 || - tp->srtt - ca->delay_min >= (dist*low_utilization_threshold)>>10) - goto notlow; - - if (ca->low_utilization_start == 0) { - ca->low_utilization = 0; - ca->low_utilization_start = tcp_time_stamp; - } else if ((s32)(tcp_time_stamp - ca->low_utilization_start) - > low_utilization_period*HZ) { - ca->low_utilization = 1; - } - - return; - - notlow: - ca->low_utilization = 0; - ca->low_utilization_start = 0; - -} - static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 seq_rtt, u32 in_flight, int data_acked) { struct tcp_sock *tp = tcp_sk(sk); struct bictcp *ca = inet_csk_ca(sk); - bictcp_low_utilization(sk, data_acked); - if (!tcp_is_cwnd_limited(sk, in_flight)) return; @@ -249,11 +175,6 @@ static u32 bictcp_recalc_ssthresh(struct sock *sk) ca->epoch_start = 0; /* end of epoch */ - /* in case of wrong delay_max*/ - if (ca->delay_min > 0 && ca->delay_max > ca->delay_min) - ca->delay_max = ca->delay_min - + ((ca->delay_max - ca->delay_min)* 90) / 100; - /* Wmax and fast convergence */ if (tp->snd_cwnd < ca->last_max_cwnd && fast_convergence) ca->last_max_cwnd = (tp->snd_cwnd * (BICTCP_BETA_SCALE + beta)) -- cgit v1.1 From 05d054503a9c4652212b8730150608787547ecc3 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 13 Dec 2005 23:13:13 -0800 Subject: [TCP] BIC: spelling and whitespace Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/tcp_bic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_bic.c b/net/ipv4/tcp_bic.c index cf8c75f..035f209 100644 --- a/net/ipv4/tcp_bic.c +++ b/net/ipv4/tcp_bic.c @@ -210,14 +210,14 @@ static void bictcp_state(struct sock *sk, u8 new_state) bictcp_reset(inet_csk_ca(sk)); } -/* Track delayed acknowledgement ratio using sliding window +/* Track delayed acknowledgment ratio using sliding window * ratio = (15*ratio + sample) / 16 */ static void bictcp_acked(struct sock *sk, u32 cnt) { const struct inet_connection_sock *icsk = inet_csk(sk); - if (cnt > 0 && icsk->icsk_ca_state == TCP_CA_Open) { + if (cnt > 0 && icsk->icsk_ca_state == TCP_CA_Open) { struct bictcp *ca = inet_csk_ca(sk); cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT; ca->delayed_ack += cnt; -- cgit v1.1 From df3271f3361b61ce02da0026b4a53e63bc2720cb Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 13 Dec 2005 23:13:28 -0800 Subject: [TCP] BIC: CUBIC window growth (2.0) Replace existing BIC version 1.1 with new version 2.0. The main change is to replace the window growth function with a cubic function as described in: http://www.csc.ncsu.edu/faculty/rhee/export/bitcp/cubic-paper.pdf Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/Kconfig | 8 + net/ipv4/Makefile | 1 + net/ipv4/tcp_cubic.c | 445 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 454 insertions(+) create mode 100644 net/ipv4/tcp_cubic.c diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index e55136a..011cca7 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig @@ -456,6 +456,14 @@ config TCP_CONG_BIC increase provides TCP friendliness. See http://www.csc.ncsu.edu/faculty/rhee/export/bitcp/ +config TCP_CONG_CUBIC + tristate "CUBIC TCP" + default m + ---help--- + This is version 2.0 of BIC-TCP which uses a cubic growth function + among other techniques. + See http://www.csc.ncsu.edu/faculty/rhee/export/bitcp/cubic-paper.pdf + config TCP_CONG_WESTWOOD tristate "TCP Westwood+" default m diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile index f0435d0..c54edd7 100644 --- a/net/ipv4/Makefile +++ b/net/ipv4/Makefile @@ -34,6 +34,7 @@ obj-$(CONFIG_INET_DIAG) += inet_diag.o obj-$(CONFIG_IP_ROUTE_MULTIPATH_CACHED) += multipath.o obj-$(CONFIG_INET_TCP_DIAG) += tcp_diag.o obj-$(CONFIG_TCP_CONG_BIC) += tcp_bic.o +obj-$(CONFIG_TCP_CONG_CUBIC) += tcp_cubic.o obj-$(CONFIG_TCP_CONG_WESTWOOD) += tcp_westwood.o obj-$(CONFIG_TCP_CONG_HSTCP) += tcp_highspeed.o obj-$(CONFIG_TCP_CONG_HYBLA) += tcp_hybla.o diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c new file mode 100644 index 0000000..bb5dc4b --- /dev/null +++ b/net/ipv4/tcp_cubic.c @@ -0,0 +1,445 @@ +/* + * TCP CUBIC: Binary Increase Congestion control for TCP v2.0 + * + * This is from the implementation of CUBIC TCP in + * Injong Rhee, Lisong Xu. + * "CUBIC: A New TCP-Friendly High-Speed TCP Variant + * in PFLDnet 2005 + * Available from: + * http://www.csc.ncsu.edu/faculty/rhee/export/bitcp/cubic-paper.pdf + * + * Unless CUBIC is enabled and congestion window is large + * this behaves the same as the original Reno. + */ + +#include +#include +#include +#include + + +#define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation + * max_cwnd = snd_cwnd * beta + */ +#define BICTCP_B 4 /* + * In binary search, + * go to point (max+min)/N + */ +#define BICTCP_HZ 10 /* BIC HZ 2^10 = 1024 */ + +static int fast_convergence = 1; +static int max_increment = 16; +static int beta = 819; /* = 819/1024 (BICTCP_BETA_SCALE) */ +static int initial_ssthresh = 100; +static int bic_scale = 41; +static int tcp_friendliness = 1; + +module_param(fast_convergence, int, 0644); +MODULE_PARM_DESC(fast_convergence, "turn on/off fast convergence"); +module_param(max_increment, int, 0644); +MODULE_PARM_DESC(max_increment, "Limit on increment allowed during binary search"); +module_param(beta, int, 0644); +MODULE_PARM_DESC(beta, "beta for multiplicative increase"); +module_param(initial_ssthresh, int, 0644); +MODULE_PARM_DESC(initial_ssthresh, "initial value of slow start threshold"); +module_param(bic_scale, int, 0644); +MODULE_PARM_DESC(bic_scale, "scale (scaled by 1024) value for bic function (bic_scale/1024)"); +module_param(tcp_friendliness, int, 0644); +MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness"); + + +/* BIC TCP Parameters */ +struct bictcp { + u32 cnt; /* increase cwnd by 1 after ACKs */ + u32 last_max_cwnd; /* last maximum snd_cwnd */ + u32 loss_cwnd; /* congestion window at last loss */ + u32 last_cwnd; /* the last snd_cwnd */ + u32 last_time; /* time when updated last_cwnd */ + u32 bic_origin_point;/* origin point of bic function */ + u32 bic_K; /* time to origin point from the beginning of the current epoch */ + u32 delay_min; /* min delay */ + u32 epoch_start; /* beginning of an epoch */ + u32 ack_cnt; /* number of acks */ + u32 tcp_cwnd; /* estimated tcp cwnd */ +#define ACK_RATIO_SHIFT 4 + u32 delayed_ack; /* estimate the ratio of Packets/ACKs << 4 */ +}; + +static inline void bictcp_reset(struct bictcp *ca) +{ + ca->cnt = 0; + ca->last_max_cwnd = 0; + ca->loss_cwnd = 0; + ca->last_cwnd = 0; + ca->last_time = 0; + ca->bic_origin_point = 0; + ca->bic_K = 0; + ca->delay_min = 0; + ca->epoch_start = 0; + ca->delayed_ack = 2 << ACK_RATIO_SHIFT; + ca->ack_cnt = 0; + ca->tcp_cwnd = 0; +} + +static void bictcp_init(struct sock *sk) +{ + bictcp_reset(inet_csk_ca(sk)); + if (initial_ssthresh) + tcp_sk(sk)->snd_ssthresh = initial_ssthresh; +} + +/* 65536 times the cubic root */ +static const u64 cubic_table[8] + = {0, 65536, 82570, 94519, 104030, 112063, 119087, 125367}; + +/* + * calculate the cubic root of x + * the basic idea is that x can be expressed as i*8^j + * so cubic_root(x) = cubic_root(i)*2^j + * in the following code, x is i, and y is 2^j + * because of integer calculation, there are errors in calculation + * so finally use binary search to find out the exact solution + */ +static u32 cubic_root(u64 x) +{ + u64 y, app, target, start, end, mid, start_diff, end_diff; + + if (x == 0) + return 0; + + target = x; + + /* first estimate lower and upper bound */ + y = 1; + while (x >= 8){ + x = (x >> 3); + y = (y << 1); + } + start = (y*cubic_table[x])>>16; + if (x==7) + end = (y<<1); + else + end = (y*cubic_table[x+1]+65535)>>16; + + /* binary search for more accurate one */ + while (start < end-1) { + mid = (start+end) >> 1; + app = mid*mid*mid; + if (app < target) + start = mid; + else if (app > target) + end = mid; + else + return mid; + } + + /* find the most accurate one from start and end */ + app = start*start*start; + if (app < target) + start_diff = target - app; + else + start_diff = app - target; + app = end*end*end; + if (app < target) + end_diff = target - app; + else + end_diff = app - target; + + if (start_diff < end_diff) + return (u32)start; + else + return (u32)end; +} + +static inline u32 bictcp_K(u32 dist, u32 srtt) +{ + u64 d64; + u32 d32; + u32 count; + u32 result; + + /* calculate the "K" for (wmax-cwnd) = c/rtt * K^3 + so K = cubic_root( (wmax-cwnd)*rtt/c ) + the unit of K is bictcp_HZ=2^10, not HZ + + c = bic_scale >> 10 + rtt = (tp->srtt >> 3 ) / HZ + + the following code has been designed and tested for + cwnd < 1 million packets + RTT < 100 seconds + HZ < 1,000,00 (corresponding to 10 nano-second) + + */ + + /* 1/c * 2^2*bictcp_HZ */ + d32 = (1 << (10+2*BICTCP_HZ)) / bic_scale; + d64 = (__u64)d32; + + /* srtt * 2^count / HZ + 1) to get a better accuracy of the following d32, + the larger the "count", the better the accuracy + 2) and avoid overflow of the following d64 + the larger the "count", the high possibility of overflow + 3) so find a "count" between bictcp_hz-3 and bictcp_hz + "count" may be less than bictcp_HZ, + then d64 becomes 0. that is OK + */ + d32 = srtt; + count = 0; + while (((d32 & 0x80000000)==0) && (count < BICTCP_HZ)){ + d32 = d32 << 1; + count++; + } + d32 = d32 / HZ; + + /* (wmax-cwnd) * (srtt>>3 / HZ) / c * 2^(3*bictcp_HZ) */ + d64 = (d64 * dist * d32) >> (count+3-BICTCP_HZ); + + /* cubic root */ + d64 = cubic_root(d64); + + result = (u32)d64; + return result; +} + +/* + * Compute congestion window to use. + */ +static inline void bictcp_update(struct bictcp *ca, u32 cwnd) +{ + u64 d64; + u32 d32, t, srtt, bic_target, min_cnt, max_cnt; + + ca->ack_cnt++; /* count the number of ACKs */ + + if (ca->last_cwnd == cwnd && + (s32)(tcp_time_stamp - ca->last_time) <= HZ / 32) + return; + + ca->last_cwnd = cwnd; + ca->last_time = tcp_time_stamp; + + srtt = (HZ << 3)/10; /* use real time-based growth function */ + + if (ca->epoch_start == 0) { + ca->epoch_start = tcp_time_stamp; /* record the beginning of an epoch */ + ca->ack_cnt = 1; /* start counting */ + ca->tcp_cwnd = cwnd; /* syn with cubic */ + + if (ca->last_max_cwnd <= cwnd) { + ca->bic_K = 0; + ca->bic_origin_point = cwnd; + } else { + ca->bic_K = bictcp_K(ca->last_max_cwnd-cwnd, srtt); + ca->bic_origin_point = ca->last_max_cwnd; + } + } + + /* cubic function - calc*/ + /* calculate c * time^3 / rtt, + * while considering overflow in calculation of time^3 + * (so time^3 is done by using d64) + * and without the support of division of 64bit numbers + * (so all divisions are done by using d32) + * also NOTE the unit of those veriables + * time = (t - K) / 2^bictcp_HZ + * c = bic_scale >> 10 + * rtt = (srtt >> 3) / HZ + * !!! The following code does not have overflow problems, + * if the cwnd < 1 million packets !!! + */ + + /* change the unit from HZ to bictcp_HZ */ + t = ((tcp_time_stamp + ca->delay_min - ca->epoch_start) + << BICTCP_HZ) / HZ; + + if (t < ca->bic_K) /* t - K */ + d32 = ca->bic_K - t; + else + d32 = t - ca->bic_K; + + d64 = (u64)d32; + d32 = (bic_scale << 3) * HZ / srtt; /* 1024*c/rtt */ + d64 = (d32 * d64 * d64 * d64) >> (10+3*BICTCP_HZ); /* c/rtt * (t-K)^3 */ + d32 = (u32)d64; + if (t < ca->bic_K) /* below origin*/ + bic_target = ca->bic_origin_point - d32; + else /* above origin*/ + bic_target = ca->bic_origin_point + d32; + + /* cubic function - calc bictcp_cnt*/ + if (bic_target > cwnd) { + ca->cnt = cwnd / (bic_target - cwnd); + } else { + ca->cnt = 100 * cwnd; /* very small increment*/ + } + + if (ca->delay_min > 0) { + /* max increment = Smax * rtt / 0.1 */ + min_cnt = (cwnd * HZ * 8)/(10 * max_increment * ca->delay_min); + if (ca->cnt < min_cnt) + ca->cnt = min_cnt; + } + + /* slow start and low utilization */ + if (ca->loss_cwnd == 0) /* could be aggressive in slow start */ + ca->cnt = 50; + + /* TCP Friendly */ + if (tcp_friendliness) { + u32 scale = 8*(BICTCP_BETA_SCALE+beta)/3/(BICTCP_BETA_SCALE-beta); + d32 = (cwnd * scale) >> 3; + while (ca->ack_cnt > d32) { /* update tcp cwnd */ + ca->ack_cnt -= d32; + ca->tcp_cwnd++; + } + + if (ca->tcp_cwnd > cwnd){ /* if bic is slower than tcp */ + d32 = ca->tcp_cwnd - cwnd; + max_cnt = cwnd / d32; + if (ca->cnt > max_cnt) + ca->cnt = max_cnt; + } + } + + ca->cnt = (ca->cnt << ACK_RATIO_SHIFT) / ca->delayed_ack; + if (ca->cnt == 0) /* cannot be zero */ + ca->cnt = 1; +} + + +/* Keep track of minimum rtt */ +static inline void measure_delay(struct sock *sk) +{ + const struct tcp_sock *tp = tcp_sk(sk); + struct bictcp *ca = inet_csk_ca(sk); + u32 delay; + + /* No time stamp */ + if (!(tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr) || + /* Discard delay samples right after fast recovery */ + (s32)(tcp_time_stamp - ca->epoch_start) < HZ) + return; + + delay = tcp_time_stamp - tp->rx_opt.rcv_tsecr; + if (delay == 0) + delay = 1; + + /* first time call or link delay decreases */ + if (ca->delay_min == 0 || ca->delay_min > delay) + ca->delay_min = delay; +} + +static void bictcp_cong_avoid(struct sock *sk, u32 ack, + u32 seq_rtt, u32 in_flight, int data_acked) +{ + struct tcp_sock *tp = tcp_sk(sk); + struct bictcp *ca = inet_csk_ca(sk); + + if (data_acked) + measure_delay(sk); + + if (!tcp_is_cwnd_limited(sk, in_flight)) + return; + + if (tp->snd_cwnd <= tp->snd_ssthresh) + tcp_slow_start(tp); + else { + bictcp_update(ca, tp->snd_cwnd); + + /* In dangerous area, increase slowly. + * In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd + */ + if (tp->snd_cwnd_cnt >= ca->cnt) { + if (tp->snd_cwnd < tp->snd_cwnd_clamp) + tp->snd_cwnd++; + tp->snd_cwnd_cnt = 0; + } else + tp->snd_cwnd_cnt++; + } + +} + +static u32 bictcp_recalc_ssthresh(struct sock *sk) +{ + const struct tcp_sock *tp = tcp_sk(sk); + struct bictcp *ca = inet_csk_ca(sk); + + ca->epoch_start = 0; /* end of epoch */ + + /* Wmax and fast convergence */ + if (tp->snd_cwnd < ca->last_max_cwnd && fast_convergence) + ca->last_max_cwnd = (tp->snd_cwnd * (BICTCP_BETA_SCALE + beta)) + / (2 * BICTCP_BETA_SCALE); + else + ca->last_max_cwnd = tp->snd_cwnd; + + ca->loss_cwnd = tp->snd_cwnd; + + return max((tp->snd_cwnd * beta) / BICTCP_BETA_SCALE, 2U); +} + +static u32 bictcp_undo_cwnd(struct sock *sk) +{ + struct bictcp *ca = inet_csk_ca(sk); + + return max(tcp_sk(sk)->snd_cwnd, ca->last_max_cwnd); +} + +static u32 bictcp_min_cwnd(struct sock *sk) +{ + return tcp_sk(sk)->snd_ssthresh; +} + +static void bictcp_state(struct sock *sk, u8 new_state) +{ + if (new_state == TCP_CA_Loss) + bictcp_reset(inet_csk_ca(sk)); +} + +/* Track delayed acknowledgment ratio using sliding window + * ratio = (15*ratio + sample) / 16 + */ +static void bictcp_acked(struct sock *sk, u32 cnt) +{ + const struct inet_connection_sock *icsk = inet_csk(sk); + + if (cnt > 0 && icsk->icsk_ca_state == TCP_CA_Open) { + struct bictcp *ca = inet_csk_ca(sk); + cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT; + ca->delayed_ack += cnt; + } +} + + +static struct tcp_congestion_ops cubictcp = { + .init = bictcp_init, + .ssthresh = bictcp_recalc_ssthresh, + .cong_avoid = bictcp_cong_avoid, + .set_state = bictcp_state, + .undo_cwnd = bictcp_undo_cwnd, + .min_cwnd = bictcp_min_cwnd, + .pkts_acked = bictcp_acked, + .owner = THIS_MODULE, + .name = "cubic", +}; + +static int __init cubictcp_register(void) +{ + BUG_ON(sizeof(struct bictcp) > ICSK_CA_PRIV_SIZE); + return tcp_register_congestion_control(&cubictcp); +} + +static void __exit cubictcp_unregister(void) +{ + tcp_unregister_congestion_control(&cubictcp); +} + +module_init(cubictcp_register); +module_exit(cubictcp_unregister); + +MODULE_AUTHOR("Sangtae Ha, Stephen Hemminger"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("CUBIC TCP"); +MODULE_VERSION("2.0"); -- cgit v1.1 From 318360646941d6f3d4c6e4ee99107392728a4079 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 13 Dec 2005 23:13:48 -0800 Subject: [NETFILTER] ip_tables: NUMA-aware allocation Part of a performance problem with ip_tables is that memory allocation is not NUMA aware, but 'only' SMP aware (ie each CPU normally touch separate cache lines) Even with small iptables rules, the cost of this misplacement can be high on common workloads. Instead of using one vmalloc() area (located in the node of the iptables process), we now allocate an area for each possible CPU, using vmalloc_node() so that memory should be allocated in the CPU's node if possible. Port to arp_tables and ip6_tables by Harald Welte. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- net/ipv4/netfilter/arp_tables.c | 175 ++++++++++++++++++++++++----------- net/ipv4/netfilter/ip_tables.c | 199 +++++++++++++++++++++++++++------------- net/ipv6/netfilter/ip6_tables.c | 190 +++++++++++++++++++++++++------------- 3 files changed, 382 insertions(+), 182 deletions(-) diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 3c2e963..bba1563 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -68,19 +68,14 @@ struct arpt_table_info { unsigned int initial_entries; unsigned int hook_entry[NF_ARP_NUMHOOKS]; unsigned int underflow[NF_ARP_NUMHOOKS]; - char entries[0] __attribute__((aligned(SMP_CACHE_BYTES))); + void *entries[NR_CPUS]; }; static LIST_HEAD(arpt_target); static LIST_HEAD(arpt_tables); +#define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0) #define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0) -#ifdef CONFIG_SMP -#define TABLE_OFFSET(t,p) (SMP_ALIGN((t)->size)*(p)) -#else -#define TABLE_OFFSET(t,p) 0 -#endif - static inline int arp_devaddr_compare(const struct arpt_devaddr_info *ap, char *hdr_addr, int len) { @@ -269,9 +264,7 @@ unsigned int arpt_do_table(struct sk_buff **pskb, outdev = out ? out->name : nulldevname; read_lock_bh(&table->lock); - table_base = (void *)table->private->entries - + TABLE_OFFSET(table->private, - smp_processor_id()); + table_base = (void *)table->private->entries[smp_processor_id()]; e = get_entry(table_base, table->private->hook_entry[hook]); back = get_entry(table_base, table->private->underflow[hook]); @@ -462,7 +455,8 @@ static inline int unconditional(const struct arpt_arp *arp) /* Figures out from what hook each rule can be called: returns 0 if * there are loops. Puts hook bitmask in comefrom. */ -static int mark_source_chains(struct arpt_table_info *newinfo, unsigned int valid_hooks) +static int mark_source_chains(struct arpt_table_info *newinfo, + unsigned int valid_hooks, void *entry0) { unsigned int hook; @@ -472,7 +466,7 @@ static int mark_source_chains(struct arpt_table_info *newinfo, unsigned int vali for (hook = 0; hook < NF_ARP_NUMHOOKS; hook++) { unsigned int pos = newinfo->hook_entry[hook]; struct arpt_entry *e - = (struct arpt_entry *)(newinfo->entries + pos); + = (struct arpt_entry *)(entry0 + pos); if (!(valid_hooks & (1 << hook))) continue; @@ -514,13 +508,13 @@ static int mark_source_chains(struct arpt_table_info *newinfo, unsigned int vali goto next; e = (struct arpt_entry *) - (newinfo->entries + pos); + (entry0 + pos); } while (oldpos == pos + e->next_offset); /* Move along one */ size = e->next_offset; e = (struct arpt_entry *) - (newinfo->entries + pos + size); + (entry0 + pos + size); e->counters.pcnt = pos; pos += size; } else { @@ -537,7 +531,7 @@ static int mark_source_chains(struct arpt_table_info *newinfo, unsigned int vali newpos = pos + e->next_offset; } e = (struct arpt_entry *) - (newinfo->entries + newpos); + (entry0 + newpos); e->counters.pcnt = pos; pos = newpos; } @@ -689,6 +683,7 @@ static inline int cleanup_entry(struct arpt_entry *e, unsigned int *i) static int translate_table(const char *name, unsigned int valid_hooks, struct arpt_table_info *newinfo, + void *entry0, unsigned int size, unsigned int number, const unsigned int *hook_entries, @@ -710,11 +705,11 @@ static int translate_table(const char *name, i = 0; /* Walk through entries, checking offsets. */ - ret = ARPT_ENTRY_ITERATE(newinfo->entries, newinfo->size, + ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size, check_entry_size_and_hooks, newinfo, - newinfo->entries, - newinfo->entries + size, + entry0, + entry0 + size, hook_entries, underflows, &i); duprintf("translate_table: ARPT_ENTRY_ITERATE gives %d\n", ret); if (ret != 0) @@ -743,29 +738,26 @@ static int translate_table(const char *name, } } - if (!mark_source_chains(newinfo, valid_hooks)) { + if (!mark_source_chains(newinfo, valid_hooks, entry0)) { duprintf("Looping hook\n"); return -ELOOP; } /* Finally, each sanity check must pass */ i = 0; - ret = ARPT_ENTRY_ITERATE(newinfo->entries, newinfo->size, + ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size, check_entry, name, size, &i); if (ret != 0) { - ARPT_ENTRY_ITERATE(newinfo->entries, newinfo->size, + ARPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i); return ret; } /* And one copy for every other CPU */ for_each_cpu(i) { - if (i == 0) - continue; - memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i, - newinfo->entries, - SMP_ALIGN(newinfo->size)); + if (newinfo->entries[i] && newinfo->entries[i] != entry0) + memcpy(newinfo->entries[i], entry0, newinfo->size); } return ret; @@ -807,15 +799,42 @@ static inline int add_entry_to_counter(const struct arpt_entry *e, return 0; } +static inline int set_entry_to_counter(const struct arpt_entry *e, + struct arpt_counters total[], + unsigned int *i) +{ + SET_COUNTER(total[*i], e->counters.bcnt, e->counters.pcnt); + + (*i)++; + return 0; +} + static void get_counters(const struct arpt_table_info *t, struct arpt_counters counters[]) { unsigned int cpu; unsigned int i; + unsigned int curcpu; + + /* Instead of clearing (by a previous call to memset()) + * the counters and using adds, we set the counters + * with data used by 'current' CPU + * We dont care about preemption here. + */ + curcpu = raw_smp_processor_id(); + + i = 0; + ARPT_ENTRY_ITERATE(t->entries[curcpu], + t->size, + set_entry_to_counter, + counters, + &i); for_each_cpu(cpu) { + if (cpu == curcpu) + continue; i = 0; - ARPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), + ARPT_ENTRY_ITERATE(t->entries[cpu], t->size, add_entry_to_counter, counters, @@ -831,6 +850,7 @@ static int copy_entries_to_user(unsigned int total_size, struct arpt_entry *e; struct arpt_counters *counters; int ret = 0; + void *loc_cpu_entry; /* We need atomic snapshot of counters: rest doesn't change * (other than comefrom, which userspace doesn't care @@ -843,13 +863,13 @@ static int copy_entries_to_user(unsigned int total_size, return -ENOMEM; /* First, sum counters... */ - memset(counters, 0, countersize); write_lock_bh(&table->lock); get_counters(table->private, counters); write_unlock_bh(&table->lock); - /* ... then copy entire thing from CPU 0... */ - if (copy_to_user(userptr, table->private->entries, total_size) != 0) { + loc_cpu_entry = table->private->entries[raw_smp_processor_id()]; + /* ... then copy entire thing ... */ + if (copy_to_user(userptr, loc_cpu_entry, total_size) != 0) { ret = -EFAULT; goto free_counters; } @@ -859,7 +879,7 @@ static int copy_entries_to_user(unsigned int total_size, for (off = 0, num = 0; off < total_size; off += e->next_offset, num++){ struct arpt_entry_target *t; - e = (struct arpt_entry *)(table->private->entries + off); + e = (struct arpt_entry *)(loc_cpu_entry + off); if (copy_to_user(userptr + off + offsetof(struct arpt_entry, counters), &counters[num], @@ -911,6 +931,47 @@ static int get_entries(const struct arpt_get_entries *entries, return ret; } +static void free_table_info(struct arpt_table_info *info) +{ + int cpu; + for_each_cpu(cpu) { + if (info->size <= PAGE_SIZE) + kfree(info->entries[cpu]); + else + vfree(info->entries[cpu]); + } + kfree(info); +} + +static struct arpt_table_info *alloc_table_info(unsigned int size) +{ + struct arpt_table_info *newinfo; + int cpu; + + newinfo = kzalloc(sizeof(struct arpt_table_info), GFP_KERNEL); + if (!newinfo) + return NULL; + + newinfo->size = size; + + for_each_cpu(cpu) { + if (size <= PAGE_SIZE) + newinfo->entries[cpu] = kmalloc_node(size, + GFP_KERNEL, + cpu_to_node(cpu)); + else + newinfo->entries[cpu] = vmalloc_node(size, + cpu_to_node(cpu)); + + if (newinfo->entries[cpu] == NULL) { + free_table_info(newinfo); + return NULL; + } + } + + return newinfo; +} + static int do_replace(void __user *user, unsigned int len) { int ret; @@ -918,6 +979,7 @@ static int do_replace(void __user *user, unsigned int len) struct arpt_table *t; struct arpt_table_info *newinfo, *oldinfo; struct arpt_counters *counters; + void *loc_cpu_entry, *loc_cpu_old_entry; if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) return -EFAULT; @@ -930,13 +992,13 @@ static int do_replace(void __user *user, unsigned int len) if ((SMP_ALIGN(tmp.size) >> PAGE_SHIFT) + 2 > num_physpages) return -ENOMEM; - newinfo = vmalloc(sizeof(struct arpt_table_info) - + SMP_ALIGN(tmp.size) * - (highest_possible_processor_id()+1)); + newinfo = alloc_table_info(tmp.size); if (!newinfo) return -ENOMEM; - if (copy_from_user(newinfo->entries, user + sizeof(tmp), + /* choose the copy that is on our node/cpu */ + loc_cpu_entry = newinfo->entries[raw_smp_processor_id()]; + if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; @@ -947,10 +1009,9 @@ static int do_replace(void __user *user, unsigned int len) ret = -ENOMEM; goto free_newinfo; } - memset(counters, 0, tmp.num_counters * sizeof(struct arpt_counters)); ret = translate_table(tmp.name, tmp.valid_hooks, - newinfo, tmp.size, tmp.num_entries, + newinfo, loc_cpu_entry, tmp.size, tmp.num_entries, tmp.hook_entry, tmp.underflow); if (ret != 0) goto free_newinfo_counters; @@ -989,8 +1050,10 @@ static int do_replace(void __user *user, unsigned int len) /* Get the old counters. */ get_counters(oldinfo, counters); /* Decrease module usage counts and free resource */ - ARPT_ENTRY_ITERATE(oldinfo->entries, oldinfo->size, cleanup_entry,NULL); - vfree(oldinfo); + loc_cpu_old_entry = oldinfo->entries[raw_smp_processor_id()]; + ARPT_ENTRY_ITERATE(loc_cpu_old_entry, oldinfo->size, cleanup_entry,NULL); + + free_table_info(oldinfo); if (copy_to_user(tmp.counters, counters, sizeof(struct arpt_counters) * tmp.num_counters) != 0) ret = -EFAULT; @@ -1002,11 +1065,11 @@ static int do_replace(void __user *user, unsigned int len) module_put(t->me); up(&arpt_mutex); free_newinfo_counters_untrans: - ARPT_ENTRY_ITERATE(newinfo->entries, newinfo->size, cleanup_entry, NULL); + ARPT_ENTRY_ITERATE(loc_cpu_entry, newinfo->size, cleanup_entry, NULL); free_newinfo_counters: vfree(counters); free_newinfo: - vfree(newinfo); + free_table_info(newinfo); return ret; } @@ -1030,6 +1093,7 @@ static int do_add_counters(void __user *user, unsigned int len) struct arpt_counters_info tmp, *paddc; struct arpt_table *t; int ret = 0; + void *loc_cpu_entry; if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) return -EFAULT; @@ -1059,7 +1123,9 @@ static int do_add_counters(void __user *user, unsigned int len) } i = 0; - ARPT_ENTRY_ITERATE(t->private->entries, + /* Choose the copy that is on our node */ + loc_cpu_entry = t->private->entries[smp_processor_id()]; + ARPT_ENTRY_ITERATE(loc_cpu_entry, t->private->size, add_counter_to_entry, paddc->counters, @@ -1220,30 +1286,32 @@ int arpt_register_table(struct arpt_table *table, struct arpt_table_info *newinfo; static struct arpt_table_info bootstrap = { 0, 0, 0, { 0 }, { 0 }, { } }; + void *loc_cpu_entry; - newinfo = vmalloc(sizeof(struct arpt_table_info) - + SMP_ALIGN(repl->size) * - (highest_possible_processor_id()+1)); + newinfo = alloc_table_info(repl->size); if (!newinfo) { ret = -ENOMEM; return ret; } - memcpy(newinfo->entries, repl->entries, repl->size); + + /* choose the copy on our node/cpu */ + loc_cpu_entry = newinfo->entries[raw_smp_processor_id()]; + memcpy(loc_cpu_entry, repl->entries, repl->size); ret = translate_table(table->name, table->valid_hooks, - newinfo, repl->size, + newinfo, loc_cpu_entry, repl->size, repl->num_entries, repl->hook_entry, repl->underflow); duprintf("arpt_register_table: translate table gives %d\n", ret); if (ret != 0) { - vfree(newinfo); + free_table_info(newinfo); return ret; } ret = down_interruptible(&arpt_mutex); if (ret != 0) { - vfree(newinfo); + free_table_info(newinfo); return ret; } @@ -1272,20 +1340,23 @@ int arpt_register_table(struct arpt_table *table, return ret; free_unlock: - vfree(newinfo); + free_table_info(newinfo); goto unlock; } void arpt_unregister_table(struct arpt_table *table) { + void *loc_cpu_entry; + down(&arpt_mutex); LIST_DELETE(&arpt_tables, table); up(&arpt_mutex); /* Decrease module usage counts and free resources */ - ARPT_ENTRY_ITERATE(table->private->entries, table->private->size, + loc_cpu_entry = table->private->entries[raw_smp_processor_id()]; + ARPT_ENTRY_ITERATE(loc_cpu_entry, table->private->size, cleanup_entry, NULL); - vfree(table->private); + free_table_info(table->private); } /* The built-in targets: standard (NULL) and error. */ diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index 45886c8..2a26d16 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -83,11 +83,6 @@ static DECLARE_MUTEX(ipt_mutex); context stops packets coming through and allows user context to read the counters or update the rules. - To be cache friendly on SMP, we arrange them like so: - [ n-entries ] - ... cache-align padding ... - [ n-entries ] - Hence the start of any table is given by get_table() below. */ /* The table itself */ @@ -105,20 +100,15 @@ struct ipt_table_info unsigned int underflow[NF_IP_NUMHOOKS]; /* ipt_entry tables: one per CPU */ - char entries[0] ____cacheline_aligned; + void *entries[NR_CPUS]; }; static LIST_HEAD(ipt_target); static LIST_HEAD(ipt_match); static LIST_HEAD(ipt_tables); +#define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0) #define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0) -#ifdef CONFIG_SMP -#define TABLE_OFFSET(t,p) (SMP_ALIGN((t)->size)*(p)) -#else -#define TABLE_OFFSET(t,p) 0 -#endif - #if 0 #define down(x) do { printk("DOWN:%u:" #x "\n", __LINE__); down(x); } while(0) #define down_interruptible(x) ({ int __r; printk("DOWNi:%u:" #x "\n", __LINE__); __r = down_interruptible(x); if (__r != 0) printk("ABORT-DOWNi:%u\n", __LINE__); __r; }) @@ -290,8 +280,7 @@ ipt_do_table(struct sk_buff **pskb, read_lock_bh(&table->lock); IP_NF_ASSERT(table->valid_hooks & (1 << hook)); - table_base = (void *)table->private->entries - + TABLE_OFFSET(table->private, smp_processor_id()); + table_base = (void *)table->private->entries[smp_processor_id()]; e = get_entry(table_base, table->private->hook_entry[hook]); #ifdef CONFIG_NETFILTER_DEBUG @@ -563,7 +552,8 @@ unconditional(const struct ipt_ip *ip) /* Figures out from what hook each rule can be called: returns 0 if there are loops. Puts hook bitmask in comefrom. */ static int -mark_source_chains(struct ipt_table_info *newinfo, unsigned int valid_hooks) +mark_source_chains(struct ipt_table_info *newinfo, + unsigned int valid_hooks, void *entry0) { unsigned int hook; @@ -572,7 +562,7 @@ mark_source_chains(struct ipt_table_info *newinfo, unsigned int valid_hooks) for (hook = 0; hook < NF_IP_NUMHOOKS; hook++) { unsigned int pos = newinfo->hook_entry[hook]; struct ipt_entry *e - = (struct ipt_entry *)(newinfo->entries + pos); + = (struct ipt_entry *)(entry0 + pos); if (!(valid_hooks & (1 << hook))) continue; @@ -622,13 +612,13 @@ mark_source_chains(struct ipt_table_info *newinfo, unsigned int valid_hooks) goto next; e = (struct ipt_entry *) - (newinfo->entries + pos); + (entry0 + pos); } while (oldpos == pos + e->next_offset); /* Move along one */ size = e->next_offset; e = (struct ipt_entry *) - (newinfo->entries + pos + size); + (entry0 + pos + size); e->counters.pcnt = pos; pos += size; } else { @@ -645,7 +635,7 @@ mark_source_chains(struct ipt_table_info *newinfo, unsigned int valid_hooks) newpos = pos + e->next_offset; } e = (struct ipt_entry *) - (newinfo->entries + newpos); + (entry0 + newpos); e->counters.pcnt = pos; pos = newpos; } @@ -855,6 +845,7 @@ static int translate_table(const char *name, unsigned int valid_hooks, struct ipt_table_info *newinfo, + void *entry0, unsigned int size, unsigned int number, const unsigned int *hook_entries, @@ -875,11 +866,11 @@ translate_table(const char *name, duprintf("translate_table: size %u\n", newinfo->size); i = 0; /* Walk through entries, checking offsets. */ - ret = IPT_ENTRY_ITERATE(newinfo->entries, newinfo->size, + ret = IPT_ENTRY_ITERATE(entry0, newinfo->size, check_entry_size_and_hooks, newinfo, - newinfo->entries, - newinfo->entries + size, + entry0, + entry0 + size, hook_entries, underflows, &i); if (ret != 0) return ret; @@ -907,27 +898,24 @@ translate_table(const char *name, } } - if (!mark_source_chains(newinfo, valid_hooks)) + if (!mark_source_chains(newinfo, valid_hooks, entry0)) return -ELOOP; /* Finally, each sanity check must pass */ i = 0; - ret = IPT_ENTRY_ITERATE(newinfo->entries, newinfo->size, + ret = IPT_ENTRY_ITERATE(entry0, newinfo->size, check_entry, name, size, &i); if (ret != 0) { - IPT_ENTRY_ITERATE(newinfo->entries, newinfo->size, + IPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i); return ret; } /* And one copy for every other CPU */ for_each_cpu(i) { - if (i == 0) - continue; - memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i, - newinfo->entries, - SMP_ALIGN(newinfo->size)); + if (newinfo->entries[i] && newinfo->entries[i] != entry0) + memcpy(newinfo->entries[i], entry0, newinfo->size); } return ret; @@ -943,15 +931,12 @@ replace_table(struct ipt_table *table, #ifdef CONFIG_NETFILTER_DEBUG { - struct ipt_entry *table_base; - unsigned int i; + int cpu; - for_each_cpu(i) { - table_base = - (void *)newinfo->entries - + TABLE_OFFSET(newinfo, i); - - table_base->comefrom = 0xdead57ac; + for_each_cpu(cpu) { + struct ipt_entry *table_base = newinfo->entries[cpu]; + if (table_base) + table_base->comefrom = 0xdead57ac; } } #endif @@ -986,16 +971,44 @@ add_entry_to_counter(const struct ipt_entry *e, return 0; } +static inline int +set_entry_to_counter(const struct ipt_entry *e, + struct ipt_counters total[], + unsigned int *i) +{ + SET_COUNTER(total[*i], e->counters.bcnt, e->counters.pcnt); + + (*i)++; + return 0; +} + static void get_counters(const struct ipt_table_info *t, struct ipt_counters counters[]) { unsigned int cpu; unsigned int i; + unsigned int curcpu; + + /* Instead of clearing (by a previous call to memset()) + * the counters and using adds, we set the counters + * with data used by 'current' CPU + * We dont care about preemption here. + */ + curcpu = raw_smp_processor_id(); + + i = 0; + IPT_ENTRY_ITERATE(t->entries[curcpu], + t->size, + set_entry_to_counter, + counters, + &i); for_each_cpu(cpu) { + if (cpu == curcpu) + continue; i = 0; - IPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), + IPT_ENTRY_ITERATE(t->entries[cpu], t->size, add_entry_to_counter, counters, @@ -1012,24 +1025,29 @@ copy_entries_to_user(unsigned int total_size, struct ipt_entry *e; struct ipt_counters *counters; int ret = 0; + void *loc_cpu_entry; /* We need atomic snapshot of counters: rest doesn't change (other than comefrom, which userspace doesn't care about). */ countersize = sizeof(struct ipt_counters) * table->private->number; - counters = vmalloc(countersize); + counters = vmalloc_node(countersize, numa_node_id()); if (counters == NULL) return -ENOMEM; /* First, sum counters... */ - memset(counters, 0, countersize); write_lock_bh(&table->lock); get_counters(table->private, counters); write_unlock_bh(&table->lock); - /* ... then copy entire thing from CPU 0... */ - if (copy_to_user(userptr, table->private->entries, total_size) != 0) { + /* choose the copy that is on our node/cpu, ... + * This choice is lazy (because current thread is + * allowed to migrate to another cpu) + */ + loc_cpu_entry = table->private->entries[raw_smp_processor_id()]; + /* ... then copy entire thing ... */ + if (copy_to_user(userptr, loc_cpu_entry, total_size) != 0) { ret = -EFAULT; goto free_counters; } @@ -1041,7 +1059,7 @@ copy_entries_to_user(unsigned int total_size, struct ipt_entry_match *m; struct ipt_entry_target *t; - e = (struct ipt_entry *)(table->private->entries + off); + e = (struct ipt_entry *)(loc_cpu_entry + off); if (copy_to_user(userptr + off + offsetof(struct ipt_entry, counters), &counters[num], @@ -1110,6 +1128,45 @@ get_entries(const struct ipt_get_entries *entries, return ret; } +static void free_table_info(struct ipt_table_info *info) +{ + int cpu; + for_each_cpu(cpu) { + if (info->size <= PAGE_SIZE) + kfree(info->entries[cpu]); + else + vfree(info->entries[cpu]); + } + kfree(info); +} + +static struct ipt_table_info *alloc_table_info(unsigned int size) +{ + struct ipt_table_info *newinfo; + int cpu; + + newinfo = kzalloc(sizeof(struct ipt_table_info), GFP_KERNEL); + if (!newinfo) + return NULL; + + newinfo->size = size; + + for_each_cpu(cpu) { + if (size <= PAGE_SIZE) + newinfo->entries[cpu] = kmalloc_node(size, + GFP_KERNEL, + cpu_to_node(cpu)); + else + newinfo->entries[cpu] = vmalloc_node(size, cpu_to_node(cpu)); + if (newinfo->entries[cpu] == 0) { + free_table_info(newinfo); + return NULL; + } + } + + return newinfo; +} + static int do_replace(void __user *user, unsigned int len) { @@ -1118,6 +1175,7 @@ do_replace(void __user *user, unsigned int len) struct ipt_table *t; struct ipt_table_info *newinfo, *oldinfo; struct ipt_counters *counters; + void *loc_cpu_entry, *loc_cpu_old_entry; if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) return -EFAULT; @@ -1130,13 +1188,13 @@ do_replace(void __user *user, unsigned int len) if ((SMP_ALIGN(tmp.size) >> PAGE_SHIFT) + 2 > num_physpages) return -ENOMEM; - newinfo = vmalloc(sizeof(struct ipt_table_info) - + SMP_ALIGN(tmp.size) * - (highest_possible_processor_id()+1)); + newinfo = alloc_table_info(tmp.size); if (!newinfo) return -ENOMEM; - if (copy_from_user(newinfo->entries, user + sizeof(tmp), + /* choose the copy that is our node/cpu */ + loc_cpu_entry = newinfo->entries[raw_smp_processor_id()]; + if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; @@ -1147,10 +1205,9 @@ do_replace(void __user *user, unsigned int len) ret = -ENOMEM; goto free_newinfo; } - memset(counters, 0, tmp.num_counters * sizeof(struct ipt_counters)); ret = translate_table(tmp.name, tmp.valid_hooks, - newinfo, tmp.size, tmp.num_entries, + newinfo, loc_cpu_entry, tmp.size, tmp.num_entries, tmp.hook_entry, tmp.underflow); if (ret != 0) goto free_newinfo_counters; @@ -1189,8 +1246,9 @@ do_replace(void __user *user, unsigned int len) /* Get the old counters. */ get_counters(oldinfo, counters); /* Decrease module usage counts and free resource */ - IPT_ENTRY_ITERATE(oldinfo->entries, oldinfo->size, cleanup_entry,NULL); - vfree(oldinfo); + loc_cpu_old_entry = oldinfo->entries[raw_smp_processor_id()]; + IPT_ENTRY_ITERATE(loc_cpu_old_entry, oldinfo->size, cleanup_entry,NULL); + free_table_info(oldinfo); if (copy_to_user(tmp.counters, counters, sizeof(struct ipt_counters) * tmp.num_counters) != 0) ret = -EFAULT; @@ -1202,11 +1260,11 @@ do_replace(void __user *user, unsigned int len) module_put(t->me); up(&ipt_mutex); free_newinfo_counters_untrans: - IPT_ENTRY_ITERATE(newinfo->entries, newinfo->size, cleanup_entry,NULL); + IPT_ENTRY_ITERATE(loc_cpu_entry, newinfo->size, cleanup_entry,NULL); free_newinfo_counters: vfree(counters); free_newinfo: - vfree(newinfo); + free_table_info(newinfo); return ret; } @@ -1239,6 +1297,7 @@ do_add_counters(void __user *user, unsigned int len) struct ipt_counters_info tmp, *paddc; struct ipt_table *t; int ret = 0; + void *loc_cpu_entry; if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) return -EFAULT; @@ -1246,7 +1305,7 @@ do_add_counters(void __user *user, unsigned int len) if (len != sizeof(tmp) + tmp.num_counters*sizeof(struct ipt_counters)) return -EINVAL; - paddc = vmalloc(len); + paddc = vmalloc_node(len, numa_node_id()); if (!paddc) return -ENOMEM; @@ -1268,7 +1327,9 @@ do_add_counters(void __user *user, unsigned int len) } i = 0; - IPT_ENTRY_ITERATE(t->private->entries, + /* Choose the copy that is on our node */ + loc_cpu_entry = t->private->entries[raw_smp_processor_id()]; + IPT_ENTRY_ITERATE(loc_cpu_entry, t->private->size, add_counter_to_entry, paddc->counters, @@ -1460,28 +1521,31 @@ int ipt_register_table(struct ipt_table *table, const struct ipt_replace *repl) struct ipt_table_info *newinfo; static struct ipt_table_info bootstrap = { 0, 0, 0, { 0 }, { 0 }, { } }; + void *loc_cpu_entry; - newinfo = vmalloc(sizeof(struct ipt_table_info) - + SMP_ALIGN(repl->size) * - (highest_possible_processor_id()+1)); + newinfo = alloc_table_info(repl->size); if (!newinfo) return -ENOMEM; - memcpy(newinfo->entries, repl->entries, repl->size); + /* choose the copy on our node/cpu + * but dont care of preemption + */ + loc_cpu_entry = newinfo->entries[raw_smp_processor_id()]; + memcpy(loc_cpu_entry, repl->entries, repl->size); ret = translate_table(table->name, table->valid_hooks, - newinfo, repl->size, + newinfo, loc_cpu_entry, repl->size, repl->num_entries, repl->hook_entry, repl->underflow); if (ret != 0) { - vfree(newinfo); + free_table_info(newinfo); return ret; } ret = down_interruptible(&ipt_mutex); if (ret != 0) { - vfree(newinfo); + free_table_info(newinfo); return ret; } @@ -1510,20 +1574,23 @@ int ipt_register_table(struct ipt_table *table, const struct ipt_replace *repl) return ret; free_unlock: - vfree(newinfo); + free_table_info(newinfo); goto unlock; } void ipt_unregister_table(struct ipt_table *table) { + void *loc_cpu_entry; + down(&ipt_mutex); LIST_DELETE(&ipt_tables, table); up(&ipt_mutex); /* Decrease module usage counts and free resources */ - IPT_ENTRY_ITERATE(table->private->entries, table->private->size, + loc_cpu_entry = table->private->entries[raw_smp_processor_id()]; + IPT_ENTRY_ITERATE(loc_cpu_entry, table->private->size, cleanup_entry, NULL); - vfree(table->private); + free_table_info(table->private); } /* Returns 1 if the port is matched by the range, 0 otherwise */ diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 95d4692..dd80020 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -86,11 +86,6 @@ static DECLARE_MUTEX(ip6t_mutex); context stops packets coming through and allows user context to read the counters or update the rules. - To be cache friendly on SMP, we arrange them like so: - [ n-entries ] - ... cache-align padding ... - [ n-entries ] - Hence the start of any table is given by get_table() below. */ /* The table itself */ @@ -108,20 +103,15 @@ struct ip6t_table_info unsigned int underflow[NF_IP6_NUMHOOKS]; /* ip6t_entry tables: one per CPU */ - char entries[0] ____cacheline_aligned; + void *entries[NR_CPUS]; }; static LIST_HEAD(ip6t_target); static LIST_HEAD(ip6t_match); static LIST_HEAD(ip6t_tables); +#define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0) #define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0) -#ifdef CONFIG_SMP -#define TABLE_OFFSET(t,p) (SMP_ALIGN((t)->size)*(p)) -#else -#define TABLE_OFFSET(t,p) 0 -#endif - #if 0 #define down(x) do { printk("DOWN:%u:" #x "\n", __LINE__); down(x); } while(0) #define down_interruptible(x) ({ int __r; printk("DOWNi:%u:" #x "\n", __LINE__); __r = down_interruptible(x); if (__r != 0) printk("ABORT-DOWNi:%u\n", __LINE__); __r; }) @@ -376,8 +366,7 @@ ip6t_do_table(struct sk_buff **pskb, read_lock_bh(&table->lock); IP_NF_ASSERT(table->valid_hooks & (1 << hook)); - table_base = (void *)table->private->entries - + TABLE_OFFSET(table->private, smp_processor_id()); + table_base = (void *)table->private->entries[smp_processor_id()]; e = get_entry(table_base, table->private->hook_entry[hook]); #ifdef CONFIG_NETFILTER_DEBUG @@ -649,7 +638,8 @@ unconditional(const struct ip6t_ip6 *ipv6) /* Figures out from what hook each rule can be called: returns 0 if there are loops. Puts hook bitmask in comefrom. */ static int -mark_source_chains(struct ip6t_table_info *newinfo, unsigned int valid_hooks) +mark_source_chains(struct ip6t_table_info *newinfo, + unsigned int valid_hooks, void *entry0) { unsigned int hook; @@ -658,7 +648,7 @@ mark_source_chains(struct ip6t_table_info *newinfo, unsigned int valid_hooks) for (hook = 0; hook < NF_IP6_NUMHOOKS; hook++) { unsigned int pos = newinfo->hook_entry[hook]; struct ip6t_entry *e - = (struct ip6t_entry *)(newinfo->entries + pos); + = (struct ip6t_entry *)(entry0 + pos); if (!(valid_hooks & (1 << hook))) continue; @@ -708,13 +698,13 @@ mark_source_chains(struct ip6t_table_info *newinfo, unsigned int valid_hooks) goto next; e = (struct ip6t_entry *) - (newinfo->entries + pos); + (entry0 + pos); } while (oldpos == pos + e->next_offset); /* Move along one */ size = e->next_offset; e = (struct ip6t_entry *) - (newinfo->entries + pos + size); + (entry0 + pos + size); e->counters.pcnt = pos; pos += size; } else { @@ -731,7 +721,7 @@ mark_source_chains(struct ip6t_table_info *newinfo, unsigned int valid_hooks) newpos = pos + e->next_offset; } e = (struct ip6t_entry *) - (newinfo->entries + newpos); + (entry0 + newpos); e->counters.pcnt = pos; pos = newpos; } @@ -941,6 +931,7 @@ static int translate_table(const char *name, unsigned int valid_hooks, struct ip6t_table_info *newinfo, + void *entry0, unsigned int size, unsigned int number, const unsigned int *hook_entries, @@ -961,11 +952,11 @@ translate_table(const char *name, duprintf("translate_table: size %u\n", newinfo->size); i = 0; /* Walk through entries, checking offsets. */ - ret = IP6T_ENTRY_ITERATE(newinfo->entries, newinfo->size, + ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size, check_entry_size_and_hooks, newinfo, - newinfo->entries, - newinfo->entries + size, + entry0, + entry0 + size, hook_entries, underflows, &i); if (ret != 0) return ret; @@ -993,27 +984,24 @@ translate_table(const char *name, } } - if (!mark_source_chains(newinfo, valid_hooks)) + if (!mark_source_chains(newinfo, valid_hooks, entry0)) return -ELOOP; /* Finally, each sanity check must pass */ i = 0; - ret = IP6T_ENTRY_ITERATE(newinfo->entries, newinfo->size, + ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size, check_entry, name, size, &i); if (ret != 0) { - IP6T_ENTRY_ITERATE(newinfo->entries, newinfo->size, + IP6T_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i); return ret; } /* And one copy for every other CPU */ for_each_cpu(i) { - if (i == 0) - continue; - memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i, - newinfo->entries, - SMP_ALIGN(newinfo->size)); + if (newinfo->entries[i] && newinfo->entries[i] != entry0) + memcpy(newinfo->entries[i], entry0, newinfo->size); } return ret; @@ -1029,15 +1017,12 @@ replace_table(struct ip6t_table *table, #ifdef CONFIG_NETFILTER_DEBUG { - struct ip6t_entry *table_base; - unsigned int i; + int cpu; - for_each_cpu(i) { - table_base = - (void *)newinfo->entries - + TABLE_OFFSET(newinfo, i); - - table_base->comefrom = 0xdead57ac; + for_each_cpu(cpu) { + struct ip6t_entry *table_base = newinfo->entries[cpu]; + if (table_base) + table_base->comefrom = 0xdead57ac; } } #endif @@ -1072,16 +1057,44 @@ add_entry_to_counter(const struct ip6t_entry *e, return 0; } +static inline int +set_entry_to_counter(const struct ip6t_entry *e, + struct ip6t_counters total[], + unsigned int *i) +{ + SET_COUNTER(total[*i], e->counters.bcnt, e->counters.pcnt); + + (*i)++; + return 0; +} + static void get_counters(const struct ip6t_table_info *t, struct ip6t_counters counters[]) { unsigned int cpu; unsigned int i; + unsigned int curcpu; + + /* Instead of clearing (by a previous call to memset()) + * the counters and using adds, we set the counters + * with data used by 'current' CPU + * We dont care about preemption here. + */ + curcpu = raw_smp_processor_id(); + + i = 0; + IP6T_ENTRY_ITERATE(t->entries[curcpu], + t->size, + set_entry_to_counter, + counters, + &i); for_each_cpu(cpu) { + if (cpu == curcpu) + continue; i = 0; - IP6T_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), + IP6T_ENTRY_ITERATE(t->entries[cpu], t->size, add_entry_to_counter, counters, @@ -1098,6 +1111,7 @@ copy_entries_to_user(unsigned int total_size, struct ip6t_entry *e; struct ip6t_counters *counters; int ret = 0; + void *loc_cpu_entry; /* We need atomic snapshot of counters: rest doesn't change (other than comefrom, which userspace doesn't care @@ -1109,13 +1123,13 @@ copy_entries_to_user(unsigned int total_size, return -ENOMEM; /* First, sum counters... */ - memset(counters, 0, countersize); write_lock_bh(&table->lock); get_counters(table->private, counters); write_unlock_bh(&table->lock); - /* ... then copy entire thing from CPU 0... */ - if (copy_to_user(userptr, table->private->entries, total_size) != 0) { + /* choose the copy that is on ourc node/cpu */ + loc_cpu_entry = table->private->entries[raw_smp_processor_id()]; + if (copy_to_user(userptr, loc_cpu_entry, total_size) != 0) { ret = -EFAULT; goto free_counters; } @@ -1127,7 +1141,7 @@ copy_entries_to_user(unsigned int total_size, struct ip6t_entry_match *m; struct ip6t_entry_target *t; - e = (struct ip6t_entry *)(table->private->entries + off); + e = (struct ip6t_entry *)(loc_cpu_entry + off); if (copy_to_user(userptr + off + offsetof(struct ip6t_entry, counters), &counters[num], @@ -1196,6 +1210,46 @@ get_entries(const struct ip6t_get_entries *entries, return ret; } +static void free_table_info(struct ip6t_table_info *info) +{ + int cpu; + for_each_cpu(cpu) { + if (info->size <= PAGE_SIZE) + kfree(info->entries[cpu]); + else + vfree(info->entries[cpu]); + } + kfree(info); +} + +static struct ip6t_table_info *alloc_table_info(unsigned int size) +{ + struct ip6t_table_info *newinfo; + int cpu; + + newinfo = kzalloc(sizeof(struct ip6t_table_info), GFP_KERNEL); + if (!newinfo) + return NULL; + + newinfo->size = size; + + for_each_cpu(cpu) { + if (size <= PAGE_SIZE) + newinfo->entries[cpu] = kmalloc_node(size, + GFP_KERNEL, + cpu_to_node(cpu)); + else + newinfo->entries[cpu] = vmalloc_node(size, + cpu_to_node(cpu)); + if (newinfo->entries[cpu] == NULL) { + free_table_info(newinfo); + return NULL; + } + } + + return newinfo; +} + static int do_replace(void __user *user, unsigned int len) { @@ -1204,6 +1258,7 @@ do_replace(void __user *user, unsigned int len) struct ip6t_table *t; struct ip6t_table_info *newinfo, *oldinfo; struct ip6t_counters *counters; + void *loc_cpu_entry, *loc_cpu_old_entry; if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) return -EFAULT; @@ -1212,13 +1267,13 @@ do_replace(void __user *user, unsigned int len) if ((SMP_ALIGN(tmp.size) >> PAGE_SHIFT) + 2 > num_physpages) return -ENOMEM; - newinfo = vmalloc(sizeof(struct ip6t_table_info) - + SMP_ALIGN(tmp.size) * - (highest_possible_processor_id()+1)); + newinfo = alloc_table_info(tmp.size); if (!newinfo) return -ENOMEM; - if (copy_from_user(newinfo->entries, user + sizeof(tmp), + /* choose the copy that is on our node/cpu */ + loc_cpu_entry = newinfo->entries[raw_smp_processor_id()]; + if (copy_from_user(loc_cpu_entry, user + sizeof(tmp), tmp.size) != 0) { ret = -EFAULT; goto free_newinfo; @@ -1229,10 +1284,9 @@ do_replace(void __user *user, unsigned int len) ret = -ENOMEM; goto free_newinfo; } - memset(counters, 0, tmp.num_counters * sizeof(struct ip6t_counters)); ret = translate_table(tmp.name, tmp.valid_hooks, - newinfo, tmp.size, tmp.num_entries, + newinfo, loc_cpu_entry, tmp.size, tmp.num_entries, tmp.hook_entry, tmp.underflow); if (ret != 0) goto free_newinfo_counters; @@ -1271,8 +1325,9 @@ do_replace(void __user *user, unsigned int len) /* Get the old counters. */ get_counters(oldinfo, counters); /* Decrease module usage counts and free resource */ - IP6T_ENTRY_ITERATE(oldinfo->entries, oldinfo->size, cleanup_entry,NULL); - vfree(oldinfo); + loc_cpu_old_entry = oldinfo->entries[raw_smp_processor_id()]; + IP6T_ENTRY_ITERATE(loc_cpu_old_entry, oldinfo->size, cleanup_entry,NULL); + free_table_info(oldinfo); if (copy_to_user(tmp.counters, counters, sizeof(struct ip6t_counters) * tmp.num_counters) != 0) ret = -EFAULT; @@ -1284,11 +1339,11 @@ do_replace(void __user *user, unsigned int len) module_put(t->me); up(&ip6t_mutex); free_newinfo_counters_untrans: - IP6T_ENTRY_ITERATE(newinfo->entries, newinfo->size, cleanup_entry,NULL); + IP6T_ENTRY_ITERATE(loc_cpu_entry, newinfo->size, cleanup_entry,NULL); free_newinfo_counters: vfree(counters); free_newinfo: - vfree(newinfo); + free_table_info(newinfo); return ret; } @@ -1321,6 +1376,7 @@ do_add_counters(void __user *user, unsigned int len) struct ip6t_counters_info tmp, *paddc; struct ip6t_table *t; int ret = 0; + void *loc_cpu_entry; if (copy_from_user(&tmp, user, sizeof(tmp)) != 0) return -EFAULT; @@ -1350,7 +1406,9 @@ do_add_counters(void __user *user, unsigned int len) } i = 0; - IP6T_ENTRY_ITERATE(t->private->entries, + /* Choose the copy that is on our node */ + loc_cpu_entry = t->private->entries[smp_processor_id()]; + IP6T_ENTRY_ITERATE(loc_cpu_entry, t->private->size, add_counter_to_entry, paddc->counters, @@ -1543,28 +1601,29 @@ int ip6t_register_table(struct ip6t_table *table, struct ip6t_table_info *newinfo; static struct ip6t_table_info bootstrap = { 0, 0, 0, { 0 }, { 0 }, { } }; + void *loc_cpu_entry; - newinfo = vmalloc(sizeof(struct ip6t_table_info) - + SMP_ALIGN(repl->size) * - (highest_possible_processor_id()+1)); + newinfo = alloc_table_info(repl->size); if (!newinfo) return -ENOMEM; - memcpy(newinfo->entries, repl->entries, repl->size); + /* choose the copy on our node/cpu */ + loc_cpu_entry = newinfo->entries[raw_smp_processor_id()]; + memcpy(loc_cpu_entry, repl->entries, repl->size); ret = translate_table(table->name, table->valid_hooks, - newinfo, repl->size, + newinfo, loc_cpu_entry, repl->size, repl->num_entries, repl->hook_entry, repl->underflow); if (ret != 0) { - vfree(newinfo); + free_table_info(newinfo); return ret; } ret = down_interruptible(&ip6t_mutex); if (ret != 0) { - vfree(newinfo); + free_table_info(newinfo); return ret; } @@ -1593,20 +1652,23 @@ int ip6t_register_table(struct ip6t_table *table, return ret; free_unlock: - vfree(newinfo); + free_table_info(newinfo); goto unlock; } void ip6t_unregister_table(struct ip6t_table *table) { + void *loc_cpu_entry; + down(&ip6t_mutex); LIST_DELETE(&ip6t_tables, table); up(&ip6t_mutex); /* Decrease module usage counts and free resources */ - IP6T_ENTRY_ITERATE(table->private->entries, table->private->size, + loc_cpu_entry = table->private->entries[raw_smp_processor_id()]; + IP6T_ENTRY_ITERATE(loc_cpu_entry, table->private->size, cleanup_entry, NULL); - vfree(table->private); + free_table_info(table->private); } /* Returns 1 if the port is matched by the range, 0 otherwise */ -- cgit v1.1 From d5228a4f49db32d22a39c653281b527ef371129c Mon Sep 17 00:00:00 2001 From: Bart De Schuymer Date: Tue, 13 Dec 2005 23:14:08 -0800 Subject: [NETFILTER] ebtables: Support nf_log API from ebt_log and ebt_ulog This makes ebt_log and ebt_ulog use the new nf_log api. This enables the bridging packet filter to log packets e.g. via nfnetlink_log. Signed-off-by: Bart De Schuymer Signed-off-by: Harald Welte Signed-off-by: David S. Miller --- net/bridge/netfilter/Kconfig | 6 +++- net/bridge/netfilter/ebt_log.c | 72 +++++++++++++++++++++++++++++++---------- net/bridge/netfilter/ebt_ulog.c | 53 ++++++++++++++++++++++++++++-- 3 files changed, 110 insertions(+), 21 deletions(-) diff --git a/net/bridge/netfilter/Kconfig b/net/bridge/netfilter/Kconfig index c70b3be..b84fc60 100644 --- a/net/bridge/netfilter/Kconfig +++ b/net/bridge/netfilter/Kconfig @@ -196,9 +196,13 @@ config BRIDGE_EBT_LOG To compile it as a module, choose M here. If unsure, say N. config BRIDGE_EBT_ULOG - tristate "ebt: ulog support" + tristate "ebt: ulog support (OBSOLETE)" depends on BRIDGE_NF_EBTABLES help + This option enables the old bridge-specific "ebt_ulog" implementation + which has been obsoleted by the new "nfnetlink_log" code (see + CONFIG_NETFILTER_NETLINK_LOG). + This option adds the ulog watcher, that you can use in any rule in any ebtables table. The packet is passed to a userspace logging daemon using netlink multicast sockets. This differs diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c index 662975b..c436e6c 100644 --- a/net/bridge/netfilter/ebt_log.c +++ b/net/bridge/netfilter/ebt_log.c @@ -3,6 +3,7 @@ * * Authors: * Bart De Schuymer + * Harald Welte * * April, 2002 * @@ -10,6 +11,7 @@ #include #include +#include #include #include #include @@ -55,27 +57,30 @@ static void print_MAC(unsigned char *p) } #define myNIPQUAD(a) a[0], a[1], a[2], a[3] -static void ebt_log(const struct sk_buff *skb, unsigned int hooknr, - const struct net_device *in, const struct net_device *out, - const void *data, unsigned int datalen) +static void +ebt_log_packet(unsigned int pf, unsigned int hooknum, + const struct sk_buff *skb, const struct net_device *in, + const struct net_device *out, const struct nf_loginfo *loginfo, + const char *prefix) { - struct ebt_log_info *info = (struct ebt_log_info *)data; - char level_string[4] = "< >"; + unsigned int bitmask; - level_string[1] = '0' + info->loglevel; spin_lock_bh(&ebt_log_lock); - printk(level_string); - printk("%s IN=%s OUT=%s ", info->prefix, in ? in->name : "", - out ? out->name : ""); + printk("<%c>%s IN=%s OUT=%s MAC source = ", '0' + loginfo->u.log.level, + prefix, in ? in->name : "", out ? out->name : ""); - printk("MAC source = "); print_MAC(eth_hdr(skb)->h_source); printk("MAC dest = "); print_MAC(eth_hdr(skb)->h_dest); printk("proto = 0x%04x", ntohs(eth_hdr(skb)->h_proto)); - if ((info->bitmask & EBT_LOG_IP) && eth_hdr(skb)->h_proto == + if (loginfo->type == NF_LOG_TYPE_LOG) + bitmask = loginfo->u.log.logflags; + else + bitmask = NF_LOG_MASK; + + if ((bitmask & EBT_LOG_IP) && eth_hdr(skb)->h_proto == htons(ETH_P_IP)){ struct iphdr _iph, *ih; @@ -84,10 +89,9 @@ static void ebt_log(const struct sk_buff *skb, unsigned int hooknr, printk(" INCOMPLETE IP header"); goto out; } - printk(" IP SRC=%u.%u.%u.%u IP DST=%u.%u.%u.%u,", - NIPQUAD(ih->saddr), NIPQUAD(ih->daddr)); - printk(" IP tos=0x%02X, IP proto=%d", ih->tos, - ih->protocol); + printk(" IP SRC=%u.%u.%u.%u IP DST=%u.%u.%u.%u, IP " + "tos=0x%02X, IP proto=%d", NIPQUAD(ih->saddr), + NIPQUAD(ih->daddr), ih->tos, ih->protocol); if (ih->protocol == IPPROTO_TCP || ih->protocol == IPPROTO_UDP) { struct tcpudphdr _ports, *pptr; @@ -104,7 +108,7 @@ static void ebt_log(const struct sk_buff *skb, unsigned int hooknr, goto out; } - if ((info->bitmask & EBT_LOG_ARP) && + if ((bitmask & EBT_LOG_ARP) && ((eth_hdr(skb)->h_proto == htons(ETH_P_ARP)) || (eth_hdr(skb)->h_proto == htons(ETH_P_RARP)))) { struct arphdr _arph, *ah; @@ -144,6 +148,21 @@ static void ebt_log(const struct sk_buff *skb, unsigned int hooknr, out: printk("\n"); spin_unlock_bh(&ebt_log_lock); + +} + +static void ebt_log(const struct sk_buff *skb, unsigned int hooknr, + const struct net_device *in, const struct net_device *out, + const void *data, unsigned int datalen) +{ + struct ebt_log_info *info = (struct ebt_log_info *)data; + struct nf_loginfo li; + + li.type = NF_LOG_TYPE_LOG; + li.u.log.level = info->loglevel; + li.u.log.logflags = info->bitmask; + + nf_log_packet(PF_BRIDGE, hooknr, skb, in, out, &li, info->prefix); } static struct ebt_watcher log = @@ -154,13 +173,32 @@ static struct ebt_watcher log = .me = THIS_MODULE, }; +static struct nf_logger ebt_log_logger = { + .name = "ebt_log", + .logfn = &ebt_log_packet, + .me = THIS_MODULE, +}; + static int __init init(void) { - return ebt_register_watcher(&log); + int ret; + + ret = ebt_register_watcher(&log); + if (ret < 0) + return ret; + if (nf_log_register(PF_BRIDGE, &ebt_log_logger) < 0) { + printk(KERN_WARNING "ebt_log: not logging via system console " + "since somebody else already registered for PF_INET\n"); + /* we cannot make module load fail here, since otherwise + * ebtables userspace would abort */ + } + + return 0; } static void __exit fini(void) { + nf_log_unregister_logger(&ebt_log_logger); ebt_unregister_watcher(&log); } diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c index aae26ae..ce617b3 100644 --- a/net/bridge/netfilter/ebt_ulog.c +++ b/net/bridge/netfilter/ebt_ulog.c @@ -3,6 +3,7 @@ * * Authors: * Bart De Schuymer + * Harald Welte * * November, 2004 * @@ -115,14 +116,13 @@ static struct sk_buff *ulog_alloc_skb(unsigned int size) return skb; } -static void ebt_ulog(const struct sk_buff *skb, unsigned int hooknr, +static void ebt_ulog_packet(unsigned int hooknr, const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, - const void *data, unsigned int datalen) + const struct ebt_ulog_info *uloginfo, const char *prefix) { ebt_ulog_packet_msg_t *pm; size_t size, copy_len; struct nlmsghdr *nlh; - struct ebt_ulog_info *uloginfo = (struct ebt_ulog_info *)data; unsigned int group = uloginfo->nlgroup; ebt_ulog_buff_t *ub = &ulog_buffers[group]; spinlock_t *lock = &ub->lock; @@ -216,6 +216,39 @@ alloc_failure: goto unlock; } +/* this function is registered with the netfilter core */ +static void ebt_log_packet(unsigned int pf, unsigned int hooknum, + const struct sk_buff *skb, const struct net_device *in, + const struct net_device *out, const struct nf_loginfo *li, + const char *prefix) +{ + struct ebt_ulog_info loginfo; + + if (!li || li->type != NF_LOG_TYPE_ULOG) { + loginfo.nlgroup = EBT_ULOG_DEFAULT_NLGROUP; + loginfo.cprange = 0; + loginfo.qthreshold = EBT_ULOG_DEFAULT_QTHRESHOLD; + loginfo.prefix[0] = '\0'; + } else { + loginfo.nlgroup = li->u.ulog.group; + loginfo.cprange = li->u.ulog.copy_len; + loginfo.qthreshold = li->u.ulog.qthreshold; + strlcpy(loginfo.prefix, prefix, sizeof(loginfo.prefix)); + } + + ebt_ulog_packet(hooknum, skb, in, out, &loginfo, prefix); +} + +static void ebt_ulog(const struct sk_buff *skb, unsigned int hooknr, + const struct net_device *in, const struct net_device *out, + const void *data, unsigned int datalen) +{ + struct ebt_ulog_info *uloginfo = (struct ebt_ulog_info *)data; + + ebt_ulog_packet(hooknr, skb, in, out, uloginfo, NULL); +} + + static int ebt_ulog_check(const char *tablename, unsigned int hookmask, const struct ebt_entry *e, void *data, unsigned int datalen) { @@ -240,6 +273,12 @@ static struct ebt_watcher ulog = { .me = THIS_MODULE, }; +static struct nf_logger ebt_ulog_logger = { + .name = EBT_ULOG_WATCHER, + .logfn = &ebt_log_packet, + .me = THIS_MODULE, +}; + static int __init init(void) { int i, ret = 0; @@ -265,6 +304,13 @@ static int __init init(void) else if ((ret = ebt_register_watcher(&ulog))) sock_release(ebtulognl->sk_socket); + if (nf_log_register(PF_BRIDGE, &ebt_ulog_logger) < 0) { + printk(KERN_WARNING "ebt_ulog: not logging via ulog " + "since somebody else already registered for PF_BRIDGE\n"); + /* we cannot make module load fail here, since otherwise + * ebtables userspace would abort */ + } + return ret; } @@ -273,6 +319,7 @@ static void __exit fini(void) ebt_ulog_buff_t *ub; int i; + nf_log_unregister_logger(&ebt_ulog_logger); ebt_unregister_watcher(&ulog); for (i = 0; i < EBT_ULOG_MAXNLGROUPS; i++) { ub = &ulog_buffers[i]; -- cgit v1.1 From 89cee8b1cbb9dac40c92ef1968aea2b45f82fd18 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 13 Dec 2005 23:14:27 -0800 Subject: [IPV4]: Safer reassembly Another spin of Herbert Xu's "safer ip reassembly" patch for 2.6.16. (The original patch is here: http://marc.theaimsgroup.com/?l=linux-netdev&m=112281936522415&w=2 and my only contribution is to have tested it.) This patch (optionally) does additional checks before accepting IP fragments, which can greatly reduce the possibility of reassembling fragments which originated from different IP datagrams. Signed-off-by: Herbert Xu Signed-off-by: Arthur Kepner Signed-off-by: David S. Miller --- Documentation/networking/ip-sysctl.txt | 23 ++++++++++++ include/linux/sysctl.h | 1 + include/net/inetpeer.h | 1 + include/net/ip.h | 2 + net/ipv4/inetpeer.c | 1 + net/ipv4/ip_fragment.c | 68 +++++++++++++++++++++++++++++++++- net/ipv4/ip_output.c | 1 + net/ipv4/sysctl_net_ipv4.c | 10 +++++ 8 files changed, 106 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt index ebc09a1..2b7cf19 100644 --- a/Documentation/networking/ip-sysctl.txt +++ b/Documentation/networking/ip-sysctl.txt @@ -46,6 +46,29 @@ ipfrag_secret_interval - INTEGER for the hash secret) for IP fragments. Default: 600 +ipfrag_max_dist - INTEGER + ipfrag_max_dist is a non-negative integer value which defines the + maximum "disorder" which is allowed among fragments which share a + common IP source address. Note that reordering of packets is + not unusual, but if a large number of fragments arrive from a source + IP address while a particular fragment queue remains incomplete, it + probably indicates that one or more fragments belonging to that queue + have been lost. When ipfrag_max_dist is positive, an additional check + is done on fragments before they are added to a reassembly queue - if + ipfrag_max_dist (or more) fragments have arrived from a particular IP + address between additions to any IP fragment queue using that source + address, it's presumed that one or more fragments in the queue are + lost. The existing fragment queue will be dropped, and a new one + started. An ipfrag_max_dist value of zero disables this check. + + Using a very small value, e.g. 1 or 2, for ipfrag_max_dist can + result in unnecessarily dropping fragment queues when normal + reordering of packets occurs, which could lead to poor application + performance. Using a very large value, e.g. 50000, increases the + likelihood of incorrectly reassembling IP fragments that originate + from different IP datagrams, which could result in data corruption. + Default: 64 + INET peer storage: inet_peer_threshold - INTEGER diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 4be34ef..93fa765 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -390,6 +390,7 @@ enum NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR=109, NET_TCP_CONG_CONTROL=110, NET_TCP_ABC=111, + NET_IPV4_IPFRAG_MAX_DIST=112, }; enum { diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h index 7fda471..0965515 100644 --- a/include/net/inetpeer.h +++ b/include/net/inetpeer.h @@ -25,6 +25,7 @@ struct inet_peer __u32 v4daddr; /* peer's address */ __u16 avl_height; __u16 ip_id_count; /* IP ID for the next packet */ + atomic_t rid; /* Frag reception counter */ __u32 tcp_ts; unsigned long tcp_ts_stamp; }; diff --git a/include/net/ip.h b/include/net/ip.h index e4563bb..4d6294ba 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -45,6 +45,7 @@ struct inet_skb_parm #define IPSKB_TRANSLATED 2 #define IPSKB_FORWARDED 4 #define IPSKB_XFRM_TUNNEL_SIZE 8 +#define IPSKB_FRAG_COMPLETE 16 }; struct ipcm_cookie @@ -168,6 +169,7 @@ extern int sysctl_ipfrag_high_thresh; extern int sysctl_ipfrag_low_thresh; extern int sysctl_ipfrag_time; extern int sysctl_ipfrag_secret_interval; +extern int sysctl_ipfrag_max_dist; /* From inetpeer.c */ extern int inet_peer_threshold; diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c index 2fc3fd3..ce5fe3f 100644 --- a/net/ipv4/inetpeer.c +++ b/net/ipv4/inetpeer.c @@ -401,6 +401,7 @@ struct inet_peer *inet_getpeer(__u32 daddr, int create) return NULL; n->v4daddr = daddr; atomic_set(&n->refcnt, 1); + atomic_set(&n->rid, 0); n->ip_id_count = secure_ip_id(daddr); n->tcp_ts_stamp = 0; diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 8ce0ce2..ce2b70c 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -22,6 +22,7 @@ * Patrick McHardy : LRU queue of frag heads for evictor. */ +#include #include #include #include @@ -38,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +58,8 @@ int sysctl_ipfrag_high_thresh = 256*1024; int sysctl_ipfrag_low_thresh = 192*1024; +int sysctl_ipfrag_max_dist = 64; + /* Important NOTE! Fragment queue must be destroyed before MSL expires. * RFC791 is wrong proposing to prolongate timer each fragment arrival by TTL. */ @@ -89,8 +93,10 @@ struct ipq { spinlock_t lock; atomic_t refcnt; struct timer_list timer; /* when will this queue expire? */ - int iif; struct timeval stamp; + int iif; + unsigned int rid; + struct inet_peer *peer; }; /* Hash table. */ @@ -195,6 +201,9 @@ static void ip_frag_destroy(struct ipq *qp, int *work) BUG_TRAP(qp->last_in&COMPLETE); BUG_TRAP(del_timer(&qp->timer) == 0); + if (qp->peer) + inet_putpeer(qp->peer); + /* Release all fragment data. */ fp = qp->fragments; while (fp) { @@ -353,6 +362,7 @@ static struct ipq *ip_frag_create(unsigned hash, struct iphdr *iph, u32 user) qp->meat = 0; qp->fragments = NULL; qp->iif = 0; + qp->peer = sysctl_ipfrag_max_dist ? inet_getpeer(iph->saddr, 1) : NULL; /* Initialize a timer for this entry. */ init_timer(&qp->timer); @@ -398,6 +408,56 @@ static inline struct ipq *ip_find(struct iphdr *iph, u32 user) return ip_frag_create(hash, iph, user); } +/* Is the fragment too far ahead to be part of ipq? */ +static inline int ip_frag_too_far(struct ipq *qp) +{ + struct inet_peer *peer = qp->peer; + unsigned int max = sysctl_ipfrag_max_dist; + unsigned int start, end; + + int rc; + + if (!peer || !max) + return 0; + + start = qp->rid; + end = atomic_inc_return(&peer->rid); + qp->rid = end; + + rc = qp->fragments && (end - start) > max; + + if (rc) { + IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); + } + + return rc; +} + +static int ip_frag_reinit(struct ipq *qp) +{ + struct sk_buff *fp; + + if (!mod_timer(&qp->timer, jiffies + sysctl_ipfrag_time)) { + atomic_inc(&qp->refcnt); + return -ETIMEDOUT; + } + + fp = qp->fragments; + do { + struct sk_buff *xp = fp->next; + frag_kfree_skb(fp, NULL); + fp = xp; + } while (fp); + + qp->last_in = 0; + qp->len = 0; + qp->meat = 0; + qp->fragments = NULL; + qp->iif = 0; + + return 0; +} + /* Add new segment to existing queue. */ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb) { @@ -408,6 +468,12 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb) if (qp->last_in & COMPLETE) goto err; + if (!(IPCB(skb)->flags & IPSKB_FRAG_COMPLETE) && + unlikely(ip_frag_too_far(qp)) && unlikely(ip_frag_reinit(qp))) { + ipq_kill(qp); + goto err; + } + offset = ntohs(skb->nh.iph->frag_off); flags = offset & ~IP_OFFSET; offset &= IP_OFFSET; diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index eba64e2..2a830de 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -445,6 +445,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) hlen = iph->ihl * 4; mtu = dst_mtu(&rt->u.dst) - hlen; /* Size of data space */ + IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE; /* When frag_list is given, use it. First, check its validity: * some transformers could create wrong frag_list or break existing diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 01444a0..dbf8295 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -22,6 +22,7 @@ extern int sysctl_ip_nonlocal_bind; #ifdef CONFIG_SYSCTL +static int zero; static int tcp_retr1_max = 255; static int ip_local_port_range_min[] = { 1, 1 }; static int ip_local_port_range_max[] = { 65535, 65535 }; @@ -614,6 +615,15 @@ ctl_table ipv4_table[] = { .strategy = &sysctl_jiffies }, { + .ctl_name = NET_IPV4_IPFRAG_MAX_DIST, + .procname = "ipfrag_max_dist", + .data = &sysctl_ipfrag_max_dist, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_minmax, + .extra1 = &zero + }, + { .ctl_name = NET_TCP_NO_METRICS_SAVE, .procname = "tcp_no_metrics_save", .data = &sysctl_tcp_nometrics_save, -- cgit v1.1 From 971af18bbfabb7b7c9c548da34a51e30869c08fc Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:14:47 -0800 Subject: [IPV6]: Reuse inet_csk_get_port in tcp_v6_get_port Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/net/inet_connection_sock.h | 6 ++- net/dccp/ipv4.c | 3 +- net/ipv4/inet_connection_sock.c | 11 +++-- net/ipv4/tcp_ipv4.c | 3 +- net/ipv6/tcp_ipv6.c | 95 ++------------------------------------ 5 files changed, 21 insertions(+), 97 deletions(-) diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index b0c9906..edc68e8 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -192,8 +192,12 @@ extern struct request_sock *inet_csk_search_req(const struct sock *sk, const __u16 rport, const __u32 raddr, const __u32 laddr); +extern int inet_csk_bind_conflict(const struct sock *sk, + const struct inet_bind_bucket *tb); extern int inet_csk_get_port(struct inet_hashinfo *hashinfo, - struct sock *sk, unsigned short snum); + struct sock *sk, unsigned short snum, + int (*bind_conflict)(const struct sock *sk, + const struct inet_bind_bucket *tb)); extern struct dst_entry* inet_csk_route_req(struct sock *sk, const struct request_sock *req); diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 656e13e..1ac3e30 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -37,7 +37,8 @@ EXPORT_SYMBOL_GPL(dccp_hashinfo); static int dccp_v4_get_port(struct sock *sk, const unsigned short snum) { - return inet_csk_get_port(&dccp_hashinfo, sk, snum); + return inet_csk_get_port(&dccp_hashinfo, sk, snum, + inet_csk_bind_conflict); } static void dccp_v4_hash(struct sock *sk) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 3fe021f..f05b6e7 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -37,7 +37,8 @@ EXPORT_SYMBOL(inet_csk_timer_bug_msg); */ int sysctl_local_port_range[2] = { 1024, 4999 }; -static inline int inet_csk_bind_conflict(struct sock *sk, struct inet_bind_bucket *tb) +int inet_csk_bind_conflict(const struct sock *sk, + const struct inet_bind_bucket *tb) { const u32 sk_rcv_saddr = inet_rcv_saddr(sk); struct sock *sk2; @@ -62,11 +63,15 @@ static inline int inet_csk_bind_conflict(struct sock *sk, struct inet_bind_bucke return node != NULL; } +EXPORT_SYMBOL_GPL(inet_csk_bind_conflict); + /* Obtain a reference to a local port for the given sock, * if snum is zero it means select any available local port. */ int inet_csk_get_port(struct inet_hashinfo *hashinfo, - struct sock *sk, unsigned short snum) + struct sock *sk, unsigned short snum, + int (*bind_conflict)(const struct sock *sk, + const struct inet_bind_bucket *tb)) { struct inet_bind_hashbucket *head; struct hlist_node *node; @@ -125,7 +130,7 @@ tb_found: goto success; } else { ret = 1; - if (inet_csk_bind_conflict(sk, tb)) + if (bind_conflict(sk, tb)) goto fail_unlock; } } diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 4d5021e..2aa19c8 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -97,7 +97,8 @@ struct inet_hashinfo __cacheline_aligned tcp_hashinfo = { static int tcp_v4_get_port(struct sock *sk, unsigned short snum) { - return inet_csk_get_port(&tcp_hashinfo, sk, snum); + return inet_csk_get_port(&tcp_hashinfo, sk, snum, + inet_csk_bind_conflict); } static void tcp_v4_hash(struct sock *sk) diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 8827389..76c8f5a 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -76,8 +76,8 @@ static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok); static struct tcp_func ipv6_mapped; static struct tcp_func ipv6_specific; -static inline int tcp_v6_bind_conflict(const struct sock *sk, - const struct inet_bind_bucket *tb) +int inet6_csk_bind_conflict(const struct sock *sk, + const struct inet_bind_bucket *tb) { const struct sock *sk2; const struct hlist_node *node; @@ -97,97 +97,10 @@ static inline int tcp_v6_bind_conflict(const struct sock *sk, return node != NULL; } -/* Grrr, addr_type already calculated by caller, but I don't want - * to add some silly "cookie" argument to this method just for that. - * But it doesn't matter, the recalculation is in the rarest path - * this function ever takes. - */ static int tcp_v6_get_port(struct sock *sk, unsigned short snum) { - struct inet_bind_hashbucket *head; - struct inet_bind_bucket *tb; - struct hlist_node *node; - int ret; - - local_bh_disable(); - if (snum == 0) { - int low = sysctl_local_port_range[0]; - int high = sysctl_local_port_range[1]; - int remaining = (high - low) + 1; - int rover = net_random() % (high - low) + low; - - do { - head = &tcp_hashinfo.bhash[inet_bhashfn(rover, tcp_hashinfo.bhash_size)]; - spin_lock(&head->lock); - inet_bind_bucket_for_each(tb, node, &head->chain) - if (tb->port == rover) - goto next; - break; - next: - spin_unlock(&head->lock); - if (++rover > high) - rover = low; - } while (--remaining > 0); - - /* Exhausted local port range during search? It is not - * possible for us to be holding one of the bind hash - * locks if this test triggers, because if 'remaining' - * drops to zero, we broke out of the do/while loop at - * the top level, not from the 'break;' statement. - */ - ret = 1; - if (unlikely(remaining <= 0)) - goto fail; - - /* OK, here is the one we will use. */ - snum = rover; - } else { - head = &tcp_hashinfo.bhash[inet_bhashfn(snum, tcp_hashinfo.bhash_size)]; - spin_lock(&head->lock); - inet_bind_bucket_for_each(tb, node, &head->chain) - if (tb->port == snum) - goto tb_found; - } - tb = NULL; - goto tb_not_found; -tb_found: - if (tb && !hlist_empty(&tb->owners)) { - if (tb->fastreuse > 0 && sk->sk_reuse && - sk->sk_state != TCP_LISTEN) { - goto success; - } else { - ret = 1; - if (tcp_v6_bind_conflict(sk, tb)) - goto fail_unlock; - } - } -tb_not_found: - ret = 1; - if (tb == NULL) { - tb = inet_bind_bucket_create(tcp_hashinfo.bind_bucket_cachep, head, snum); - if (tb == NULL) - goto fail_unlock; - } - if (hlist_empty(&tb->owners)) { - if (sk->sk_reuse && sk->sk_state != TCP_LISTEN) - tb->fastreuse = 1; - else - tb->fastreuse = 0; - } else if (tb->fastreuse && - (!sk->sk_reuse || sk->sk_state == TCP_LISTEN)) - tb->fastreuse = 0; - -success: - if (!inet_csk(sk)->icsk_bind_hash) - inet_bind_hash(sk, tb, snum); - BUG_TRAP(inet_csk(sk)->icsk_bind_hash == tb); - ret = 0; - -fail_unlock: - spin_unlock(&head->lock); -fail: - local_bh_enable(); - return ret; + return inet_csk_get_port(&tcp_hashinfo, sk, snum, + inet6_csk_bind_conflict); } static __inline__ void __tcp_v6_hash(struct sock *sk) -- cgit v1.1 From 90b19d31695371bd3ed256d4c9e280861cd6ae7e Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:15:01 -0800 Subject: [IPV6]: Generalise __tcp_v6_hash, renaming it to __inet6_hash Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/net/inet6_hashtables.h | 26 ++++++++++++++++++++++++++ net/ipv6/tcp_ipv6.c | 34 ++++------------------------------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 5a2beed..a4a204f 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h @@ -48,6 +48,32 @@ static inline int inet6_sk_ehashfn(const struct sock *sk) return inet6_ehashfn(laddr, lport, faddr, fport); } +static inline void __inet6_hash(struct inet_hashinfo *hashinfo, + struct sock *sk) +{ + struct hlist_head *list; + rwlock_t *lock; + + BUG_TRAP(sk_unhashed(sk)); + + if (sk->sk_state == TCP_LISTEN) { + list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; + lock = &hashinfo->lhash_lock; + inet_listen_wlock(hashinfo); + } else { + unsigned int hash; + sk->sk_hash = hash = inet6_sk_ehashfn(sk); + hash &= (hashinfo->ehash_size - 1); + list = &hashinfo->ehash[hash].chain; + lock = &hashinfo->ehash[hash].lock; + write_lock(lock); + } + + __sk_add_node(sk, list); + sock_prot_inc_use(sk->sk_prot); + write_unlock(lock); +} + /* * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so * we need not check it for TCP lookups anymore, thanks Alexey. -DaveM diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 76c8f5a..bf41f84 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -103,32 +103,6 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum) inet6_csk_bind_conflict); } -static __inline__ void __tcp_v6_hash(struct sock *sk) -{ - struct hlist_head *list; - rwlock_t *lock; - - BUG_TRAP(sk_unhashed(sk)); - - if (sk->sk_state == TCP_LISTEN) { - list = &tcp_hashinfo.listening_hash[inet_sk_listen_hashfn(sk)]; - lock = &tcp_hashinfo.lhash_lock; - inet_listen_wlock(&tcp_hashinfo); - } else { - unsigned int hash; - sk->sk_hash = hash = inet6_sk_ehashfn(sk); - hash &= (tcp_hashinfo.ehash_size - 1); - list = &tcp_hashinfo.ehash[hash].chain; - lock = &tcp_hashinfo.ehash[hash].lock; - write_lock(lock); - } - - __sk_add_node(sk, list); - sock_prot_inc_use(sk->sk_prot); - write_unlock(lock); -} - - static void tcp_v6_hash(struct sock *sk) { if (sk->sk_state != TCP_CLOSE) { @@ -139,7 +113,7 @@ static void tcp_v6_hash(struct sock *sk) return; } local_bh_disable(); - __tcp_v6_hash(sk); + __inet6_hash(&tcp_hashinfo, sk); local_bh_enable(); } } @@ -374,7 +348,7 @@ ok: inet_bind_hash(sk, tb, port); if (sk_unhashed(sk)) { inet_sk(sk)->sport = htons(port); - __tcp_v6_hash(sk); + __inet6_hash(&tcp_hashinfo, sk); } spin_unlock(&head->lock); @@ -392,7 +366,7 @@ ok: spin_lock_bh(&head->lock); if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { - __tcp_v6_hash(sk); + __inet6_hash(&tcp_hashinfo, sk); spin_unlock_bh(&head->lock); return 0; } else { @@ -1295,7 +1269,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, newinet->daddr = newinet->saddr = newinet->rcv_saddr = LOOPBACK4_IPV6; - __tcp_v6_hash(newsk); + __inet6_hash(&tcp_hashinfo, newsk); inet_inherit_port(&tcp_hashinfo, sk, newsk); return newsk; -- cgit v1.1 From c2977c2213993bff51911f4117281b31c4612591 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:15:12 -0800 Subject: [ICSK]: make inet_csk_reqsk_queue_hash_add timeout arg unsigned long Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/net/inet_connection_sock.h | 2 +- net/ipv4/inet_connection_sock.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index edc68e8..ccc81a1 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -211,7 +211,7 @@ static inline void inet_csk_reqsk_queue_add(struct sock *sk, extern void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req, - const unsigned timeout); + unsigned long timeout); static inline void inet_csk_reqsk_queue_removed(struct sock *sk, struct request_sock *req) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index f05b6e7..e2bf508 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -385,7 +385,7 @@ struct request_sock *inet_csk_search_req(const struct sock *sk, EXPORT_SYMBOL_GPL(inet_csk_search_req); void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req, - const unsigned timeout) + unsigned long timeout) { struct inet_connection_sock *icsk = inet_csk(sk); struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt; -- cgit v1.1 From 8129765ac07c2455c927051e3a8b048b619b56ee Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:15:24 -0800 Subject: [IPV6]: Generalise tcp_v6_search_req & tcp_v6_synq_add More work is needed tho to introduce inet6_request_sock from tcp6_request_sock, in the same layout considerations as ipv6_pinfo in inet_sock, next changeset will do that. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/net/inet6_connection_sock.h | 31 ++++++++++++ include/net/request_sock.h | 2 +- net/ipv6/Makefile | 3 +- net/ipv6/inet6_connection_sock.c | 96 +++++++++++++++++++++++++++++++++++++ net/ipv6/tcp_ipv6.c | 78 +++--------------------------- 5 files changed, 137 insertions(+), 73 deletions(-) create mode 100644 include/net/inet6_connection_sock.h create mode 100644 net/ipv6/inet6_connection_sock.c diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h new file mode 100644 index 0000000..aa30ebd --- /dev/null +++ b/include/net/inet6_connection_sock.h @@ -0,0 +1,31 @@ +/* + * NET Generic infrastructure for INET6 connection oriented protocols. + * + * Authors: Many people, see the TCPv6 sources + * + * From code originally in TCPv6 + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#ifndef _INET6_CONNECTION_SOCK_H +#define _INET6_CONNECTION_SOCK_H + +#include + +struct sock; +struct request_sock; + +extern struct request_sock *inet6_csk_search_req(const struct sock *sk, + struct request_sock ***prevp, + const __u16 rport, + const struct in6_addr *raddr, + const struct in6_addr *laddr, + const int iif); + +extern void inet6_csk_reqsk_queue_hash_add(struct sock *sk, + struct request_sock *req, + const unsigned long timeout); +#endif /* _INET6_CONNECTION_SOCK_H */ diff --git a/include/net/request_sock.h b/include/net/request_sock.h index b52cc52..11641c9 100644 --- a/include/net/request_sock.h +++ b/include/net/request_sock.h @@ -244,7 +244,7 @@ static inline int reqsk_queue_is_full(const struct request_sock_queue *queue) static inline void reqsk_queue_hash_req(struct request_sock_queue *queue, u32 hash, struct request_sock *req, - unsigned timeout) + unsigned long timeout) { struct listen_sock *lopt = queue->listen_opt; diff --git a/net/ipv6/Makefile b/net/ipv6/Makefile index 6460eec..9601fd7 100644 --- a/net/ipv6/Makefile +++ b/net/ipv6/Makefile @@ -8,7 +8,8 @@ ipv6-objs := af_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o sit.o \ route.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o raw.o \ protocol.o icmp.o mcast.o reassembly.o tcp_ipv6.o \ exthdrs.o sysctl_net_ipv6.o datagram.o proc.o \ - ip6_flowlabel.o ipv6_syms.o netfilter.o + ip6_flowlabel.o ipv6_syms.o netfilter.o \ + inet6_connection_sock.o ipv6-$(CONFIG_XFRM) += xfrm6_policy.o xfrm6_state.o xfrm6_input.o \ xfrm6_output.o diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c new file mode 100644 index 0000000..04ff443 --- /dev/null +++ b/net/ipv6/inet6_connection_sock.c @@ -0,0 +1,96 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Support for INET6 connection oriented protocols. + * + * Authors: See the TCPv6 sources + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or(at your option) any later version. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +/* + * request_sock (formerly open request) hash tables. + */ +static u32 inet6_synq_hash(const struct in6_addr *raddr, const u16 rport, + const u32 rnd, const u16 synq_hsize) +{ + u32 a = raddr->s6_addr32[0]; + u32 b = raddr->s6_addr32[1]; + u32 c = raddr->s6_addr32[2]; + + a += JHASH_GOLDEN_RATIO; + b += JHASH_GOLDEN_RATIO; + c += rnd; + __jhash_mix(a, b, c); + + a += raddr->s6_addr32[3]; + b += (u32)rport; + __jhash_mix(a, b, c); + + return c & (synq_hsize - 1); +} + +struct request_sock *inet6_csk_search_req(const struct sock *sk, + struct request_sock ***prevp, + const __u16 rport, + const struct in6_addr *raddr, + const struct in6_addr *laddr, + const int iif) +{ + const struct inet_connection_sock *icsk = inet_csk(sk); + struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt; + struct request_sock *req, **prev; + + for (prev = &lopt->syn_table[inet6_synq_hash(raddr, rport, + lopt->hash_rnd, + lopt->nr_table_entries)]; + (req = *prev) != NULL; + prev = &req->dl_next) { + const struct tcp6_request_sock *treq = tcp6_rsk(req); + + if (inet_rsk(req)->rmt_port == rport && + req->rsk_ops->family == AF_INET6 && + ipv6_addr_equal(&treq->rmt_addr, raddr) && + ipv6_addr_equal(&treq->loc_addr, laddr) && + (!treq->iif || treq->iif == iif)) { + BUG_TRAP(req->sk == NULL); + *prevp = prev; + return req; + } + } + + return NULL; +} + +EXPORT_SYMBOL_GPL(inet6_csk_search_req); + +void inet6_csk_reqsk_queue_hash_add(struct sock *sk, + struct request_sock *req, + const unsigned long timeout) +{ + struct inet_connection_sock *icsk = inet_csk(sk); + struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt; + const u32 h = inet6_synq_hash(&tcp6_rsk(req)->rmt_addr, + inet_rsk(req)->rmt_port, + lopt->hash_rnd, lopt->nr_table_entries); + + reqsk_queue_hash_req(&icsk->icsk_accept_queue, h, req, timeout); + inet_csk_reqsk_queue_added(sk, timeout); +} + +EXPORT_SYMBOL_GPL(inet6_csk_reqsk_queue_hash_add); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index bf41f84..5a10d30 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -118,60 +119,6 @@ static void tcp_v6_hash(struct sock *sk) } } -/* - * Open request hash tables. - */ - -static u32 tcp_v6_synq_hash(const struct in6_addr *raddr, const u16 rport, const u32 rnd) -{ - u32 a, b, c; - - a = raddr->s6_addr32[0]; - b = raddr->s6_addr32[1]; - c = raddr->s6_addr32[2]; - - a += JHASH_GOLDEN_RATIO; - b += JHASH_GOLDEN_RATIO; - c += rnd; - __jhash_mix(a, b, c); - - a += raddr->s6_addr32[3]; - b += (u32) rport; - __jhash_mix(a, b, c); - - return c & (TCP_SYNQ_HSIZE - 1); -} - -static struct request_sock *tcp_v6_search_req(const struct sock *sk, - struct request_sock ***prevp, - __u16 rport, - struct in6_addr *raddr, - struct in6_addr *laddr, - int iif) -{ - const struct inet_connection_sock *icsk = inet_csk(sk); - struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt; - struct request_sock *req, **prev; - - for (prev = &lopt->syn_table[tcp_v6_synq_hash(raddr, rport, lopt->hash_rnd)]; - (req = *prev) != NULL; - prev = &req->dl_next) { - const struct tcp6_request_sock *treq = tcp6_rsk(req); - - if (inet_rsk(req)->rmt_port == rport && - req->rsk_ops->family == AF_INET6 && - ipv6_addr_equal(&treq->rmt_addr, raddr) && - ipv6_addr_equal(&treq->loc_addr, laddr) && - (!treq->iif || treq->iif == iif)) { - BUG_TRAP(req->sk == NULL); - *prevp = prev; - return req; - } - } - - return NULL; -} - static __inline__ u16 tcp_v6_check(struct tcphdr *th, int len, struct in6_addr *saddr, struct in6_addr *daddr, @@ -662,8 +609,8 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, if (sock_owned_by_user(sk)) goto out; - req = tcp_v6_search_req(sk, &prev, th->dest, &hdr->daddr, - &hdr->saddr, inet6_iif(skb)); + req = inet6_csk_search_req(sk, &prev, th->dest, &hdr->daddr, + &hdr->saddr, inet6_iif(skb)); if (!req) goto out; @@ -978,8 +925,9 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) struct sock *nsk; /* Find possible connection requests. */ - req = tcp_v6_search_req(sk, &prev, th->source, &skb->nh.ipv6h->saddr, - &skb->nh.ipv6h->daddr, inet6_iif(skb)); + req = inet6_csk_search_req(sk, &prev, th->source, + &skb->nh.ipv6h->saddr, + &skb->nh.ipv6h->daddr, inet6_iif(skb)); if (req) return tcp_check_req(sk, skb, req, prev); @@ -1003,17 +951,6 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) return sk; } -static void tcp_v6_synq_add(struct sock *sk, struct request_sock *req) -{ - struct inet_connection_sock *icsk = inet_csk(sk); - struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt; - const u32 h = tcp_v6_synq_hash(&tcp6_rsk(req)->rmt_addr, inet_rsk(req)->rmt_port, lopt->hash_rnd); - - reqsk_queue_hash_req(&icsk->icsk_accept_queue, h, req, TCP_TIMEOUT_INIT); - inet_csk_reqsk_queue_added(sk, TCP_TIMEOUT_INIT); -} - - /* FIXME: this is substantially similar to the ipv4 code. * Can some kind of merge be done? -- erics */ @@ -1083,8 +1020,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) if (tcp_v6_send_synack(sk, req, NULL)) goto drop; - tcp_v6_synq_add(sk, req); - + inet6_csk_reqsk_queue_hash_add(sk, req, TCP_TIMEOUT_INIT); return 0; drop: -- cgit v1.1 From ca304b6104ffdd120bb6687a88a0625e58bc71cd Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:15:40 -0800 Subject: [IPV6]: Introduce inet6_rsk() And inet6_rsk_offset in inet_request_sock, for the same reasons as inet_sock's pinfo6 member. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/linux/ip.h | 4 ++++ include/linux/ipv6.h | 39 +++++++++++++++++++++++++++++++++------ net/ipv4/inet_diag.c | 8 ++++---- net/ipv6/inet6_connection_sock.c | 4 ++-- net/ipv6/tcp_ipv6.c | 19 +++++++++---------- 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/include/linux/ip.h b/include/linux/ip.h index 33e8a19..5a560da 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -110,6 +110,10 @@ struct ip_options { struct inet_request_sock { struct request_sock req; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + u16 inet6_rsk_offset; + /* 2 bytes hole, try to pack */ +#endif u32 loc_addr; u32 rmt_addr; u16 rmt_port; diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index e0b9227..7d3e86d 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -199,18 +199,17 @@ static inline int inet6_iif(const struct sk_buff *skb) return IP6CB(skb)->iif; } -struct tcp6_request_sock { - struct tcp_request_sock req; +struct inet6_request_sock { struct in6_addr loc_addr; struct in6_addr rmt_addr; struct sk_buff *pktopts; int iif; }; -static inline struct tcp6_request_sock *tcp6_rsk(const struct request_sock *sk) -{ - return (struct tcp6_request_sock *)sk; -} +struct tcp6_request_sock { + struct tcp_request_sock tcp6rsk_tcp; + struct inet6_request_sock tcp6rsk_inet6; +}; /** * struct ipv6_pinfo - ipv6 private area @@ -304,6 +303,28 @@ static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) return inet_sk(__sk)->pinet6; } +static inline struct inet6_request_sock * + inet6_rsk(const struct request_sock *rsk) +{ + return (struct inet6_request_sock *)(((u8 *)rsk) + + inet_rsk(rsk)->inet6_rsk_offset); +} + +static inline u32 inet6_rsk_offset(struct request_sock *rsk) +{ + return rsk->rsk_ops->obj_size - sizeof(struct inet6_request_sock); +} + +static inline struct request_sock *inet6_reqsk_alloc(struct request_sock_ops *ops) +{ + struct request_sock *req = reqsk_alloc(ops); + + if (req != NULL) + inet_rsk(req)->inet6_rsk_offset = inet6_rsk_offset(req); + + return req; +} + static inline struct raw6_sock *raw6_sk(const struct sock *sk) { return (struct raw6_sock *)sk; @@ -361,6 +382,12 @@ static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) return NULL; } +static inline struct inet6_request_sock * + inet6_rsk(const struct request_sock *rsk) +{ + return NULL; +} + static inline struct raw6_sock *raw6_sk(const struct sock *sk) { return NULL; diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 39061ed..3ce73b1 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -489,9 +489,9 @@ static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk, #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) if (r->idiag_family == AF_INET6) { ipv6_addr_copy((struct in6_addr *)r->id.idiag_src, - &tcp6_rsk(req)->loc_addr); + &inet6_rsk(req)->loc_addr); ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, - &tcp6_rsk(req)->rmt_addr); + &inet6_rsk(req)->rmt_addr); } #endif nlh->nlmsg_len = skb->tail - b; @@ -553,13 +553,13 @@ static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, entry.saddr = #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) (entry.family == AF_INET6) ? - tcp6_rsk(req)->loc_addr.s6_addr32 : + inet6_rsk(req)->loc_addr.s6_addr32 : #endif &ireq->loc_addr; entry.daddr = #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) (entry.family == AF_INET6) ? - tcp6_rsk(req)->rmt_addr.s6_addr32 : + inet6_rsk(req)->rmt_addr.s6_addr32 : #endif &ireq->rmt_addr; entry.dport = ntohs(ireq->rmt_port); diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c index 04ff443..fe874ee 100644 --- a/net/ipv6/inet6_connection_sock.c +++ b/net/ipv6/inet6_connection_sock.c @@ -61,7 +61,7 @@ struct request_sock *inet6_csk_search_req(const struct sock *sk, lopt->nr_table_entries)]; (req = *prev) != NULL; prev = &req->dl_next) { - const struct tcp6_request_sock *treq = tcp6_rsk(req); + const struct inet6_request_sock *treq = inet6_rsk(req); if (inet_rsk(req)->rmt_port == rport && req->rsk_ops->family == AF_INET6 && @@ -85,7 +85,7 @@ void inet6_csk_reqsk_queue_hash_add(struct sock *sk, { struct inet_connection_sock *icsk = inet_csk(sk); struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt; - const u32 h = inet6_synq_hash(&tcp6_rsk(req)->rmt_addr, + const u32 h = inet6_synq_hash(&inet6_rsk(req)->rmt_addr, inet_rsk(req)->rmt_port, lopt->hash_rnd, lopt->nr_table_entries); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 5a10d30..c2472d7 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -656,7 +656,7 @@ out: static int tcp_v6_send_synack(struct sock *sk, struct request_sock *req, struct dst_entry *dst) { - struct tcp6_request_sock *treq = tcp6_rsk(req); + struct inet6_request_sock *treq = inet6_rsk(req); struct ipv6_pinfo *np = inet6_sk(sk); struct sk_buff * skb; struct ipv6_txoptions *opt = NULL; @@ -722,8 +722,8 @@ done: static void tcp_v6_reqsk_destructor(struct request_sock *req) { - if (tcp6_rsk(req)->pktopts) - kfree_skb(tcp6_rsk(req)->pktopts); + if (inet6_rsk(req)->pktopts) + kfree_skb(inet6_rsk(req)->pktopts); } static struct request_sock_ops tcp6_request_sock_ops = { @@ -956,7 +956,7 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) */ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) { - struct tcp6_request_sock *treq; + struct inet6_request_sock *treq; struct ipv6_pinfo *np = inet6_sk(sk); struct tcp_options_received tmp_opt; struct tcp_sock *tp = tcp_sk(sk); @@ -981,7 +981,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) goto drop; - req = reqsk_alloc(&tcp6_request_sock_ops); + req = inet6_reqsk_alloc(&tcp6_request_sock_ops); if (req == NULL) goto drop; @@ -994,7 +994,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; tcp_openreq_init(req, &tmp_opt, skb); - treq = tcp6_rsk(req); + treq = inet6_rsk(req); ipv6_addr_copy(&treq->rmt_addr, &skb->nh.ipv6h->saddr); ipv6_addr_copy(&treq->loc_addr, &skb->nh.ipv6h->daddr); TCP_ECN_create_request(req, skb->h.th); @@ -1035,7 +1035,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, struct request_sock *req, struct dst_entry *dst) { - struct tcp6_request_sock *treq = tcp6_rsk(req); + struct inet6_request_sock *treq = inet6_rsk(req); struct ipv6_pinfo *newnp, *np = inet6_sk(sk); struct tcp6_sock *newtcp6sk; struct inet_sock *newinet; @@ -1723,14 +1723,13 @@ static int tcp_v6_destroy_sock(struct sock *sk) static void get_openreq6(struct seq_file *seq, struct sock *sk, struct request_sock *req, int i, int uid) { - struct in6_addr *dest, *src; int ttd = req->expires - jiffies; + struct in6_addr *src = &inet6_rsk(req)->loc_addr; + struct in6_addr *dest = &inet6_rsk(req)->rmt_addr; if (ttd < 0) ttd = 0; - src = &tcp6_rsk(req)->loc_addr; - dest = &tcp6_rsk(req)->rmt_addr; seq_printf(seq, "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X " "%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p\n", -- cgit v1.1 From 8292a17a399ffb7c5c8b083db4ad994e090055f7 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:15:52 -0800 Subject: [ICSK]: Rename struct tcp_func to struct inet_connection_sock_af_ops And move it to struct inet_connection_sock. DCCP will use it in the upcoming changesets. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/linux/tcp.h | 2 -- include/net/inet_connection_sock.h | 26 ++++++++++++++++++++ include/net/tcp.h | 50 +------------------------------------- include/net/transp_v6.h | 2 +- net/ipv4/syncookies.c | 4 +-- net/ipv4/tcp.c | 8 +++--- net/ipv4/tcp_input.c | 11 +++++---- net/ipv4/tcp_ipv4.c | 11 ++++----- net/ipv4/tcp_minisocks.c | 8 +++--- net/ipv4/tcp_output.c | 17 ++++++------- net/ipv6/ipv6_sockglue.c | 2 +- net/ipv6/tcp_ipv6.c | 28 ++++++++++----------- 12 files changed, 71 insertions(+), 98 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 0e1da66..4e14340 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -295,8 +295,6 @@ struct tcp_sock { struct sk_buff_head out_of_order_queue; /* Out of order segments go here */ - struct tcp_func *af_specific; /* Operations which are AF_INET{4,6} specific */ - __u32 rcv_wnd; /* Current receiver window */ __u32 rcv_wup; /* rcv_nxt on last window update sent */ __u32 write_seq; /* Tail(+1) of data held in tcp send buffer */ diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index ccc81a1..9e20d20 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -15,6 +15,7 @@ #ifndef _INET_CONNECTION_SOCK_H #define _INET_CONNECTION_SOCK_H +#include #include #include #include @@ -29,6 +30,29 @@ struct inet_bind_bucket; struct inet_hashinfo; struct tcp_congestion_ops; +/* + * Pointers to address related TCP functions + * (i.e. things that depend on the address family) + */ +struct inet_connection_sock_af_ops { + int (*queue_xmit)(struct sk_buff *skb, int ipfragok); + void (*send_check)(struct sock *sk, int len, + struct sk_buff *skb); + int (*rebuild_header)(struct sock *sk); + int (*conn_request)(struct sock *sk, struct sk_buff *skb); + struct sock *(*syn_recv_sock)(struct sock *sk, struct sk_buff *skb, + struct request_sock *req, + struct dst_entry *dst); + int (*remember_stamp)(struct sock *sk); + __u16 net_header_len; + int (*setsockopt)(struct sock *sk, int level, int optname, + char __user *optval, int optlen); + int (*getsockopt)(struct sock *sk, int level, int optname, + char __user *optval, int __user *optlen); + void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); + int sockaddr_len; +}; + /** inet_connection_sock - INET connection oriented sock * * @icsk_accept_queue: FIFO of established children @@ -37,6 +61,7 @@ struct tcp_congestion_ops; * @icsk_retransmit_timer: Resend (no ack) * @icsk_rto: Retransmit timeout * @icsk_ca_ops Pluggable congestion control hook + * @icsk_af_ops Operations which are AF_INET{4,6} specific * @icsk_ca_state: Congestion control state * @icsk_retransmits: Number of unrecovered [RTO] timeouts * @icsk_pending: Scheduled timer event @@ -55,6 +80,7 @@ struct inet_connection_sock { struct timer_list icsk_delack_timer; __u32 icsk_rto; struct tcp_congestion_ops *icsk_ca_ops; + struct inet_connection_sock_af_ops *icsk_af_ops; __u8 icsk_ca_state; __u8 icsk_retransmits; __u8 icsk_pending; diff --git a/include/net/tcp.h b/include/net/tcp.h index d78025f..83b117a 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -225,53 +225,6 @@ extern atomic_t tcp_sockets_allocated; extern int tcp_memory_pressure; /* - * Pointers to address related TCP functions - * (i.e. things that depend on the address family) - */ - -struct tcp_func { - int (*queue_xmit) (struct sk_buff *skb, - int ipfragok); - - void (*send_check) (struct sock *sk, - struct tcphdr *th, - int len, - struct sk_buff *skb); - - int (*rebuild_header) (struct sock *sk); - - int (*conn_request) (struct sock *sk, - struct sk_buff *skb); - - struct sock * (*syn_recv_sock) (struct sock *sk, - struct sk_buff *skb, - struct request_sock *req, - struct dst_entry *dst); - - int (*remember_stamp) (struct sock *sk); - - __u16 net_header_len; - - int (*setsockopt) (struct sock *sk, - int level, - int optname, - char __user *optval, - int optlen); - - int (*getsockopt) (struct sock *sk, - int level, - int optname, - char __user *optval, - int __user *optlen); - - - void (*addr2sockaddr) (struct sock *sk, - struct sockaddr *); - - int sockaddr_len; -}; - -/* * The next routines deal with comparing 32 bit unsigned ints * and worry about wraparound (automatic with unsigned arithmetic). */ @@ -405,8 +358,7 @@ extern void tcp_parse_options(struct sk_buff *skb, * TCP v4 functions exported for the inet6 API */ -extern void tcp_v4_send_check(struct sock *sk, - struct tcphdr *th, int len, +extern void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb); extern int tcp_v4_conn_request(struct sock *sk, diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h index 4e86f2d..61f724c 100644 --- a/include/net/transp_v6.h +++ b/include/net/transp_v6.h @@ -44,7 +44,7 @@ extern int datagram_send_ctl(struct msghdr *msg, /* * address family specific functions */ -extern struct tcp_func ipv4_specific; +extern struct inet_connection_sock_af_ops ipv4_specific; extern int inet6_destroy_sock(struct sock *sk); diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index a34e60e..e20be33 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c @@ -173,10 +173,10 @@ static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb, struct request_sock *req, struct dst_entry *dst) { - struct tcp_sock *tp = tcp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); struct sock *child; - child = tp->af_specific->syn_recv_sock(sk, skb, req, dst); + child = icsk->icsk_af_ops->syn_recv_sock(sk, skb, req, dst); if (child) inet_csk_reqsk_queue_add(sk, req, child); else diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index ef98b14..eacfe6a 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1696,8 +1696,8 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, int err = 0; if (level != SOL_TCP) - return tp->af_specific->setsockopt(sk, level, optname, - optval, optlen); + return icsk->icsk_af_ops->setsockopt(sk, level, optname, + optval, optlen); /* This is a string value all the others are int's */ if (optname == TCP_CONGESTION) { @@ -1939,8 +1939,8 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int val, len; if (level != SOL_TCP) - return tp->af_specific->getsockopt(sk, level, optname, - optval, optlen); + return icsk->icsk_af_ops->getsockopt(sk, level, optname, + optval, optlen); if (get_user(len, optlen)) return -EFAULT; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index bf2e230..7de6184 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -4071,8 +4071,10 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, mb(); tcp_set_state(sk, TCP_ESTABLISHED); + icsk = inet_csk(sk); + /* Make sure socket is routed, for correct metrics. */ - tp->af_specific->rebuild_header(sk); + icsk->icsk_af_ops->rebuild_header(sk); tcp_init_metrics(sk); @@ -4098,8 +4100,6 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, sk_wake_async(sk, 0, POLL_OUT); } - icsk = inet_csk(sk); - if (sk->sk_write_pending || icsk->icsk_accept_queue.rskq_defer_accept || icsk->icsk_ack.pingpong) { @@ -4220,6 +4220,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, struct tcphdr *th, unsigned len) { struct tcp_sock *tp = tcp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); int queued = 0; tp->rx_opt.saw_tstamp = 0; @@ -4236,7 +4237,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, goto discard; if(th->syn) { - if(tp->af_specific->conn_request(sk, skb) < 0) + if (icsk->icsk_af_ops->conn_request(sk, skb) < 0) return 1; /* Now we have several options: In theory there is @@ -4349,7 +4350,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, /* Make sure socket is routed, for * correct metrics. */ - tp->af_specific->rebuild_header(sk); + icsk->icsk_af_ops->rebuild_header(sk); tcp_init_metrics(sk); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 2aa19c8..704cf21 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -86,8 +86,7 @@ int sysctl_tcp_low_latency; /* Socket used for sending RSTs */ static struct socket *tcp_socket; -void tcp_v4_send_check(struct sock *sk, struct tcphdr *th, int len, - struct sk_buff *skb); +void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb); struct inet_hashinfo __cacheline_aligned tcp_hashinfo = { .lhash_lock = RW_LOCK_UNLOCKED, @@ -645,10 +644,10 @@ out: } /* This routine computes an IPv4 TCP checksum. */ -void tcp_v4_send_check(struct sock *sk, struct tcphdr *th, int len, - struct sk_buff *skb) +void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) { struct inet_sock *inet = inet_sk(sk); + struct tcphdr *th = skb->h.th; if (skb->ip_summed == CHECKSUM_HW) { th->check = ~tcp_v4_check(th, len, inet->saddr, inet->daddr, 0); @@ -1383,7 +1382,7 @@ int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw) return 0; } -struct tcp_func ipv4_specific = { +struct inet_connection_sock_af_ops ipv4_specific = { .queue_xmit = ip_queue_xmit, .send_check = tcp_v4_send_check, .rebuild_header = inet_sk_rebuild_header, @@ -1434,7 +1433,7 @@ static int tcp_v4_init_sock(struct sock *sk) sk->sk_write_space = sk_stream_write_space; sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); - tp->af_specific = &ipv4_specific; + icsk->icsk_af_ops = &ipv4_specific; sk->sk_sndbuf = sysctl_tcp_wmem[1]; sk->sk_rcvbuf = sysctl_tcp_rmem[1]; diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 1b66a2a..9c02968 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -274,18 +274,18 @@ kill: void tcp_time_wait(struct sock *sk, int state, int timeo) { struct inet_timewait_sock *tw = NULL; + const struct inet_connection_sock *icsk = inet_csk(sk); const struct tcp_sock *tp = tcp_sk(sk); int recycle_ok = 0; if (tcp_death_row.sysctl_tw_recycle && tp->rx_opt.ts_recent_stamp) - recycle_ok = tp->af_specific->remember_stamp(sk); + recycle_ok = icsk->icsk_af_ops->remember_stamp(sk); if (tcp_death_row.tw_count < tcp_death_row.sysctl_max_tw_buckets) tw = inet_twsk_alloc(sk, state); if (tw != NULL) { struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); - const struct inet_connection_sock *icsk = inet_csk(sk); const int rto = (icsk->icsk_rto << 2) - (icsk->icsk_rto >> 1); tw->tw_rcv_wscale = tp->rx_opt.rcv_wscale; @@ -456,7 +456,6 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, struct request_sock **prev) { struct tcphdr *th = skb->h.th; - struct tcp_sock *tp = tcp_sk(sk); u32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); int paws_reject = 0; struct tcp_options_received tmp_opt; @@ -613,7 +612,8 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, * ESTABLISHED STATE. If it will be dropped after * socket is created, wait for troubles. */ - child = tp->af_specific->syn_recv_sock(sk, skb, req, NULL); + child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, + req, NULL); if (child == NULL) goto listen_overflow; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index b7325e0..af1946c 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -371,7 +371,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, TCP_ECN_send(sk, tp, skb, tcp_header_size); } - tp->af_specific->send_check(sk, th, skb->len, skb); + icsk->icsk_af_ops->send_check(sk, skb->len, skb); if (likely(tcb->flags & TCPCB_FLAG_ACK)) tcp_event_ack_sent(sk, tcp_skb_pcount(skb)); @@ -381,7 +381,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, TCP_INC_STATS(TCP_MIB_OUTSEGS); - err = tp->af_specific->queue_xmit(skb, 0); + err = icsk->icsk_af_ops->queue_xmit(skb, 0); if (unlikely(err <= 0)) return err; @@ -638,12 +638,11 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) { struct tcp_sock *tp = tcp_sk(sk); - int mss_now; - /* Calculate base mss without TCP options: It is MMS_S - sizeof(tcphdr) of rfc1122 */ - mss_now = pmtu - tp->af_specific->net_header_len - sizeof(struct tcphdr); + int mss_now = (pmtu - inet_csk(sk)->icsk_af_ops->net_header_len - + sizeof(struct tcphdr)); /* Clamp it (mss_clamp does not include tcp options) */ if (mss_now > tp->rx_opt.mss_clamp) @@ -705,9 +704,9 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) xmit_size_goal = mss_now; if (doing_tso) { - xmit_size_goal = 65535 - - tp->af_specific->net_header_len - - tp->ext_header_len - tp->tcp_header_len; + xmit_size_goal = (65535 - + inet_csk(sk)->icsk_af_ops->net_header_len - + tp->ext_header_len - tp->tcp_header_len); if (tp->max_window && (xmit_size_goal > (tp->max_window >> 1))) @@ -1422,7 +1421,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) (sysctl_tcp_retrans_collapse != 0)) tcp_retrans_try_collapse(sk, skb, cur_mss); - if(tp->af_specific->rebuild_header(sk)) + if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk)) return -EHOSTUNREACH; /* Routing failure or similar. */ /* Some Solaris stacks overoptimize and ignore the FIN on a diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 3620718..b6b63fa 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -170,7 +170,7 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, sock_prot_inc_use(&tcp_prot); local_bh_enable(); sk->sk_prot = &tcp_prot; - tp->af_specific = &ipv4_specific; + inet_csk(sk)->icsk_af_ops = &ipv4_specific; sk->sk_socket->ops = &inet_stream_ops; sk->sk_family = PF_INET; tcp_sync_mss(sk, tp->pmtu_cookie); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index c2472d7..8ce8a13 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -68,14 +68,14 @@ static void tcp_v6_send_reset(struct sk_buff *skb); static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); -static void tcp_v6_send_check(struct sock *sk, struct tcphdr *th, int len, +static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb); static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb); static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok); -static struct tcp_func ipv6_mapped; -static struct tcp_func ipv6_specific; +static struct inet_connection_sock_af_ops ipv6_mapped; +static struct inet_connection_sock_af_ops ipv6_specific; int inet6_csk_bind_conflict(const struct sock *sk, const struct inet_bind_bucket *tb) @@ -107,9 +107,7 @@ static int tcp_v6_get_port(struct sock *sk, unsigned short snum) static void tcp_v6_hash(struct sock *sk) { if (sk->sk_state != TCP_CLOSE) { - struct tcp_sock *tp = tcp_sk(sk); - - if (tp->af_specific == &ipv6_mapped) { + if (inet_csk(sk)->icsk_af_ops == &ipv6_mapped) { tcp_prot.hash(sk); return; } @@ -417,14 +415,14 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, sin.sin_port = usin->sin6_port; sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3]; - tp->af_specific = &ipv6_mapped; + inet_csk(sk)->icsk_af_ops = &ipv6_mapped; sk->sk_backlog_rcv = tcp_v4_do_rcv; err = tcp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); if (err) { tp->ext_header_len = exthdrlen; - tp->af_specific = &ipv6_specific; + inet_csk(sk)->icsk_af_ops = &ipv6_specific; sk->sk_backlog_rcv = tcp_v6_do_rcv; goto failure; } else { @@ -751,10 +749,10 @@ static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) } -static void tcp_v6_send_check(struct sock *sk, struct tcphdr *th, int len, - struct sk_buff *skb) +static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb) { struct ipv6_pinfo *np = inet6_sk(sk); + struct tcphdr *th = skb->h.th; if (skb->ip_summed == CHECKSUM_HW) { th->check = ~csum_ipv6_magic(&np->saddr, &np->daddr, len, IPPROTO_TCP, 0); @@ -1070,7 +1068,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr); - newtp->af_specific = &ipv6_mapped; + inet_csk(newsk)->icsk_af_ops = &ipv6_mapped; newsk->sk_backlog_rcv = tcp_v4_do_rcv; newnp->pktoptions = NULL; newnp->opt = NULL; @@ -1084,7 +1082,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, */ /* It is tricky place. Until this moment IPv4 tcp - worked with IPv6 af_tcp.af_specific. + worked with IPv6 icsk.icsk_af_ops. Sync it now. */ tcp_sync_mss(newsk, newtp->pmtu_cookie); @@ -1631,7 +1629,7 @@ static int tcp_v6_remember_stamp(struct sock *sk) return 0; } -static struct tcp_func ipv6_specific = { +static struct inet_connection_sock_af_ops ipv6_specific = { .queue_xmit = tcp_v6_xmit, .send_check = tcp_v6_send_check, .rebuild_header = tcp_v6_rebuild_header, @@ -1650,7 +1648,7 @@ static struct tcp_func ipv6_specific = { * TCP over IPv4 via INET6 API */ -static struct tcp_func ipv6_mapped = { +static struct inet_connection_sock_af_ops ipv6_mapped = { .queue_xmit = ip_queue_xmit, .send_check = tcp_v4_send_check, .rebuild_header = inet_sk_rebuild_header, @@ -1700,7 +1698,7 @@ static int tcp_v6_init_sock(struct sock *sk) sk->sk_state = TCP_CLOSE; - tp->af_specific = &ipv6_specific; + icsk->icsk_af_ops = &ipv6_specific; icsk->icsk_ca_ops = &tcp_init_congestion_ops; sk->sk_write_space = sk_stream_write_space; sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); -- cgit v1.1 From af05dc9394feb193d221bc9d4c6db768facb4b40 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:16:04 -0800 Subject: [ICSK]: Move v4_addr2sockaddr from TCP to icsk Renaming it to inet_csk_addr2sockaddr. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/net/inet_connection_sock.h | 2 ++ net/ipv4/inet_connection_sock.c | 12 ++++++++++++ net/ipv4/tcp_ipv4.c | 12 +----------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 9e20d20..e50e2b8 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -303,4 +303,6 @@ static inline unsigned int inet_csk_listen_poll(const struct sock *sk) extern int inet_csk_listen_start(struct sock *sk, const int nr_table_entries); extern void inet_csk_listen_stop(struct sock *sk); +extern void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); + #endif /* _INET_CONNECTION_SOCK_H */ diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index e2bf508..ae20281 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -636,3 +636,15 @@ void inet_csk_listen_stop(struct sock *sk) } EXPORT_SYMBOL_GPL(inet_csk_listen_stop); + +void inet_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr) +{ + struct sockaddr_in *sin = (struct sockaddr_in *)uaddr; + const struct inet_sock *inet = inet_sk(sk); + + sin->sin_family = AF_INET; + sin->sin_addr.s_addr = inet->daddr; + sin->sin_port = inet->dport; +} + +EXPORT_SYMBOL_GPL(inet_csk_addr2sockaddr); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 704cf21..0b5ab04 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1314,16 +1314,6 @@ do_time_wait: goto discard_it; } -static void v4_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr) -{ - struct sockaddr_in *sin = (struct sockaddr_in *) uaddr; - struct inet_sock *inet = inet_sk(sk); - - sin->sin_family = AF_INET; - sin->sin_addr.s_addr = inet->daddr; - sin->sin_port = inet->dport; -} - /* VJ's idea. Save last timestamp seen from this destination * and hold it at least for normal timewait interval to use for duplicate * segment detection in subsequent connections, before they enter synchronized @@ -1392,7 +1382,7 @@ struct inet_connection_sock_af_ops ipv4_specific = { .net_header_len = sizeof(struct iphdr), .setsockopt = ip_setsockopt, .getsockopt = ip_getsockopt, - .addr2sockaddr = v4_addr2sockaddr, + .addr2sockaddr = inet_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in), }; -- cgit v1.1 From 57cca05af1e20fdc65b55be52c042c234f86c866 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:16:16 -0800 Subject: [DCCP]: Introduce dccp_ipv4_af_ops And make the core DCCP code AF agnostic, just like TCP, now its time to work on net/dccp/ipv6.c, we are close to the end! Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/input.c | 5 +++-- net/dccp/ipv4.c | 23 +++++++++++++++++++++++ net/dccp/minisocks.c | 2 +- net/dccp/output.c | 14 ++++++-------- net/dccp/proto.c | 9 ++++++--- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/net/dccp/input.c b/net/dccp/input.c index 3454d59..c81488f 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c @@ -329,7 +329,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, dccp_set_state(sk, DCCP_PARTOPEN); /* Make sure socket is routed, for correct metrics. */ - inet_sk_rebuild_header(sk); + icsk->icsk_af_ops->rebuild_header(sk); if (!sock_flag(sk, SOCK_DEAD)) { sk->sk_state_change(sk); @@ -444,7 +444,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, */ if (sk->sk_state == DCCP_LISTEN) { if (dh->dccph_type == DCCP_PKT_REQUEST) { - if (dccp_v4_conn_request(sk, skb) < 0) + if (inet_csk(sk)->icsk_af_ops->conn_request(sk, + skb) < 0) return 1; /* FIXME: do congestion control initialization */ diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 1ac3e30..0ce7d0f 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -607,6 +607,15 @@ out: sock_put(sk); } +/* This routine computes an IPv4 DCCP checksum. */ +static void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) +{ + const struct inet_sock *inet = inet_sk(sk); + struct dccp_hdr *dh = dccp_hdr(skb); + + dh->dccph_checksum = dccp_v4_checksum(skb, inet->saddr, inet->daddr); +} + int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code) { struct sk_buff *skb; @@ -1195,6 +1204,19 @@ do_time_wait: goto no_dccp_socket; } +struct inet_connection_sock_af_ops dccp_ipv4_af_ops = { + .queue_xmit = ip_queue_xmit, + .send_check = dccp_v4_send_check, + .rebuild_header = inet_sk_rebuild_header, + .conn_request = dccp_v4_conn_request, + .syn_recv_sock = dccp_v4_request_recv_sock, + .net_header_len = sizeof(struct iphdr), + .setsockopt = ip_setsockopt, + .getsockopt = ip_getsockopt, + .addr2sockaddr = inet_csk_addr2sockaddr, + .sockaddr_len = sizeof(struct sockaddr_in), +}; + static int dccp_v4_init_sock(struct sock *sk) { struct dccp_sock *dp = dccp_sk(sk); @@ -1240,6 +1262,7 @@ static int dccp_v4_init_sock(struct sock *sk) inet_csk(sk)->icsk_rto = DCCP_TIMEOUT_INIT; sk->sk_state = DCCP_CLOSED; sk->sk_write_space = dccp_write_space; + inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops; dp->dccps_mss_cache = 536; dp->dccps_role = DCCP_ROLE_UNDEFINED; dp->dccps_service = DCCP_SERVICE_INVALID_VALUE; diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index 1393461..c7ff80c 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c @@ -214,7 +214,7 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb, goto drop; } - child = dccp_v4_request_recv_sock(sk, skb, req, NULL); + child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL); if (child == NULL) goto listen_overflow; diff --git a/net/dccp/output.c b/net/dccp/output.c index 74ff870..f358805 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c @@ -43,6 +43,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) { if (likely(skb != NULL)) { const struct inet_sock *inet = inet_sk(sk); + const struct inet_connection_sock *icsk = inet_csk(sk); struct dccp_sock *dp = dccp_sk(sk); struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); struct dccp_hdr *dh; @@ -108,8 +109,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) break; } - dh->dccph_checksum = dccp_v4_checksum(skb, inet->saddr, - inet->daddr); + icsk->icsk_af_ops->send_check(sk, skb->len, skb); if (set_ack) dccp_event_ack_sent(sk); @@ -117,7 +117,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) DCCP_INC_STATS(DCCP_MIB_OUTSEGS); memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); - err = ip_queue_xmit(skb, 0); + err = icsk->icsk_af_ops->queue_xmit(skb, 0); if (err <= 0) return err; @@ -135,16 +135,14 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) { struct dccp_sock *dp = dccp_sk(sk); - int mss_now; - /* * FIXME: we really should be using the af_specific thing to support * IPv6. * mss_now = pmtu - tp->af_specific->net_header_len - * sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext); */ - mss_now = pmtu - sizeof(struct iphdr) - sizeof(struct dccp_hdr) - - sizeof(struct dccp_hdr_ext); + int mss_now = (pmtu - inet_csk(sk)->icsk_af_ops->net_header_len - + sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext)); /* Now subtract optional transport overhead */ mss_now -= dp->dccps_ext_header_len; @@ -266,7 +264,7 @@ int dccp_write_xmit(struct sock *sk, struct sk_buff *skb, long *timeo) int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb) { - if (inet_sk_rebuild_header(sk) != 0) + if (inet_csk(sk)->icsk_af_ops->rebuild_header(sk) != 0) return -EHOSTUNREACH; /* Routing failure or similar. */ return dccp_transmit_skb(sk, (skb_cloned(skb) ? diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 8a6b2a9..7b30c12 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -254,7 +254,9 @@ int dccp_setsockopt(struct sock *sk, int level, int optname, int val; if (level != SOL_DCCP) - return ip_setsockopt(sk, level, optname, optval, optlen); + return inet_csk(sk)->icsk_af_ops->setsockopt(sk, level, + optname, optval, + optlen); if (optlen < sizeof(int)) return -EINVAL; @@ -320,8 +322,9 @@ int dccp_getsockopt(struct sock *sk, int level, int optname, int val, len; if (level != SOL_DCCP) - return ip_getsockopt(sk, level, optname, optval, optlen); - + return inet_csk(sk)->icsk_af_ops->getsockopt(sk, level, + optname, optval, + optlen); if (get_user(len, optlen)) return -EFAULT; -- cgit v1.1 From 3305b80c214c642b89cd5c21af83bc91ec13f8bd Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Tue, 13 Dec 2005 23:16:37 -0800 Subject: [IP]: Simplify and consolidate MSG_PEEK error handling When a packet is obtained from skb_recv_datagram with MSG_PEEK enabled it is left on the socket receive queue. This means that when we detect a checksum error we have to be careful when trying to free the packet as someone could have dequeued it in the time being. Currently this delicate logic is duplicated three times between UDPv4, UDPv6 and RAWv6. This patch moves them into a one place and simplifies the code somewhat. This is based on a suggestion by Eric Dumazet. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller --- include/linux/skbuff.h | 2 ++ net/core/datagram.c | 36 ++++++++++++++++++++++++++++++++++++ net/ipv4/udp.c | 15 +-------------- net/ipv6/raw.c | 16 +++------------- net/ipv6/udp.c | 16 ++-------------- 5 files changed, 44 insertions(+), 41 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 8c5d600..97f6580 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1239,6 +1239,8 @@ extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, int hlen, struct iovec *iov); extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb); +extern void skb_kill_datagram(struct sock *sk, struct sk_buff *skb, + unsigned int flags); extern unsigned int skb_checksum(const struct sk_buff *skb, int offset, int len, unsigned int csum); extern int skb_copy_bits(const struct sk_buff *skb, int offset, diff --git a/net/core/datagram.c b/net/core/datagram.c index 1bcfef5..f8d322e 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -200,6 +201,41 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb) } /** + * skb_kill_datagram - Free a datagram skbuff forcibly + * @sk: socket + * @skb: datagram skbuff + * @flags: MSG_ flags + * + * This function frees a datagram skbuff that was received by + * skb_recv_datagram. The flags argument must match the one + * used for skb_recv_datagram. + * + * If the MSG_PEEK flag is set, and the packet is still on the + * receive queue of the socket, it will be taken off the queue + * before it is freed. + * + * This function currently only disables BH when acquiring the + * sk_receive_queue lock. Therefore it must not be used in a + * context where that lock is acquired in an IRQ context. + */ + +void skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags) +{ + if (flags & MSG_PEEK) { + spin_lock_bh(&sk->sk_receive_queue.lock); + if (skb == skb_peek(&sk->sk_receive_queue)) { + __skb_unlink(skb, &sk->sk_receive_queue); + atomic_dec(&skb->users); + } + spin_unlock_bh(&sk->sk_receive_queue.lock); + } + + kfree_skb(skb); +} + +EXPORT_SYMBOL(skb_kill_datagram); + +/** * skb_copy_datagram_iovec - Copy a datagram to an iovec. * @skb: buffer to copy * @offset: offset in the buffer to start copying from diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 2422a5f..012c462 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -846,20 +846,7 @@ out: csum_copy_err: UDP_INC_STATS_BH(UDP_MIB_INERRORS); - /* Clear queue. */ - if (flags&MSG_PEEK) { - int clear = 0; - spin_lock_bh(&sk->sk_receive_queue.lock); - if (skb == skb_peek(&sk->sk_receive_queue)) { - __skb_unlink(skb, &sk->sk_receive_queue); - clear = 1; - } - spin_unlock_bh(&sk->sk_receive_queue.lock); - if (clear) - kfree_skb(skb); - } - - skb_free_datagram(sk, skb); + skb_kill_datagram(sk, skb, flags); if (noblock) return -EAGAIN; diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index a66900c..66f1d12 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -433,25 +434,14 @@ out: return err; csum_copy_err: - /* Clear queue. */ - if (flags&MSG_PEEK) { - int clear = 0; - spin_lock_bh(&sk->sk_receive_queue.lock); - if (skb == skb_peek(&sk->sk_receive_queue)) { - __skb_unlink(skb, &sk->sk_receive_queue); - clear = 1; - } - spin_unlock_bh(&sk->sk_receive_queue.lock); - if (clear) - kfree_skb(skb); - } + skb_kill_datagram(sk, skb, flags); /* Error for blocking case is chosen to masquerade as some normal condition. */ err = (flags&MSG_DONTWAIT) ? -EAGAIN : -EHOSTUNREACH; /* FIXME: increment a raw6 drops counter here */ - goto out_free; + goto out; } static int rawv6_push_pending_frames(struct sock *sk, struct flowi *fl, diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 5cc8731..d8538dc 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -300,20 +301,7 @@ out: return err; csum_copy_err: - /* Clear queue. */ - if (flags&MSG_PEEK) { - int clear = 0; - spin_lock_bh(&sk->sk_receive_queue.lock); - if (skb == skb_peek(&sk->sk_receive_queue)) { - __skb_unlink(skb, &sk->sk_receive_queue); - clear = 1; - } - spin_unlock_bh(&sk->sk_receive_queue.lock); - if (clear) - kfree_skb(skb); - } - - skb_free_datagram(sk, skb); + skb_kill_datagram(sk, skb, flags); if (flags & MSG_DONTWAIT) { UDP6_INC_STATS_USER(UDP_MIB_INERRORS); -- cgit v1.1 From 65a45441d7e91ef6107fadbc55f775db4ba23874 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 13 Dec 2005 23:17:02 -0800 Subject: [UDP]: udp_checksum_init return value Since udp_checksum_init always returns 0 there is no point in having it return a value. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/udp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 012c462..67c0363 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1081,7 +1081,7 @@ static int udp_v4_mcast_deliver(struct sk_buff *skb, struct udphdr *uh, * Otherwise, csum completion requires chacksumming packet body, * including udp header and folding it to skb->csum. */ -static int udp_checksum_init(struct sk_buff *skb, struct udphdr *uh, +static void udp_checksum_init(struct sk_buff *skb, struct udphdr *uh, unsigned short ulen, u32 saddr, u32 daddr) { if (uh->check == 0) { @@ -1095,7 +1095,6 @@ static int udp_checksum_init(struct sk_buff *skb, struct udphdr *uh, /* Probably, we should checksum udp header (it should be in cache * in any case) and data in tiny packets (< rx copybreak). */ - return 0; } /* @@ -1128,8 +1127,7 @@ int udp_rcv(struct sk_buff *skb) if (pskb_trim_rcsum(skb, ulen)) goto short_packet; - if (udp_checksum_init(skb, uh, ulen, saddr, daddr) < 0) - goto csum_error; + udp_checksum_init(skb, uh, ulen, saddr, daddr); if(rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST)) return udp_v4_mcast_deliver(skb, uh, saddr, daddr); -- cgit v1.1 From f1f71e03b17db3b9edb0264a8be7719bd5c35582 Mon Sep 17 00:00:00 2001 From: Roberto Nibali Date: Tue, 13 Dec 2005 23:17:20 -0800 Subject: [IPVS]: remove dead code This patch removes dead code. I don't see the reason to keep this cruft around, besides cluttering the nice and functionally working code. Signed-off-by: Roberto Nibali Signed-off-by: Horms Signed-off-by: David S. Miller --- net/ipv4/ipvs/ip_vs_app.c | 28 ---------------------------- net/ipv4/ipvs/ip_vs_lblc.c | 27 --------------------------- net/ipv4/ipvs/ip_vs_lblcr.c | 27 --------------------------- net/ipv4/ipvs/ip_vs_proto_tcp.c | 22 ---------------------- 4 files changed, 104 deletions(-) diff --git a/net/ipv4/ipvs/ip_vs_app.c b/net/ipv4/ipvs/ip_vs_app.c index d7eb680..9b176a9 100644 --- a/net/ipv4/ipvs/ip_vs_app.c +++ b/net/ipv4/ipvs/ip_vs_app.c @@ -224,34 +224,6 @@ void unregister_ip_vs_app(struct ip_vs_app *app) } -#if 0000 -/* - * Get reference to app by name (called from user context) - */ -struct ip_vs_app *ip_vs_app_get_by_name(char *appname) -{ - struct ip_vs_app *app, *a = NULL; - - down(&__ip_vs_app_mutex); - - list_for_each_entry(ent, &ip_vs_app_list, a_list) { - if (strcmp(app->name, appname)) - continue; - - /* softirq may call ip_vs_app_get too, so the caller - must disable softirq on the current CPU */ - if (ip_vs_app_get(app)) - a = app; - break; - } - - up(&__ip_vs_app_mutex); - - return a; -} -#endif - - /* * Bind ip_vs_conn to its ip_vs_app (called by cp constructor) */ diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c index 561cda3..b6dad7e 100644 --- a/net/ipv4/ipvs/ip_vs_lblc.c +++ b/net/ipv4/ipvs/ip_vs_lblc.c @@ -228,33 +228,6 @@ ip_vs_lblc_hash(struct ip_vs_lblc_table *tbl, struct ip_vs_lblc_entry *en) } -#if 0000 -/* - * Unhash ip_vs_lblc_entry from ip_vs_lblc_table. - * returns bool success. - */ -static int ip_vs_lblc_unhash(struct ip_vs_lblc_table *tbl, - struct ip_vs_lblc_entry *en) -{ - if (list_empty(&en->list)) { - IP_VS_ERR("ip_vs_lblc_unhash(): request for not hashed entry, " - "called from %p\n", __builtin_return_address(0)); - return 0; - } - - /* - * Remove it from the table - */ - write_lock(&tbl->lock); - list_del(&en->list); - INIT_LIST_HEAD(&en->list); - write_unlock(&tbl->lock); - - return 1; -} -#endif - - /* * Get ip_vs_lblc_entry associated with supplied parameters. */ diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c index ce456db..8c78ef7 100644 --- a/net/ipv4/ipvs/ip_vs_lblcr.c +++ b/net/ipv4/ipvs/ip_vs_lblcr.c @@ -414,33 +414,6 @@ ip_vs_lblcr_hash(struct ip_vs_lblcr_table *tbl, struct ip_vs_lblcr_entry *en) } -#if 0000 -/* - * Unhash ip_vs_lblcr_entry from ip_vs_lblcr_table. - * returns bool success. - */ -static int ip_vs_lblcr_unhash(struct ip_vs_lblcr_table *tbl, - struct ip_vs_lblcr_entry *en) -{ - if (list_empty(&en->list)) { - IP_VS_ERR("ip_vs_lblcr_unhash(): request for not hashed entry, " - "called from %p\n", __builtin_return_address(0)); - return 0; - } - - /* - * Remove it from the table - */ - write_lock(&tbl->lock); - list_del(&en->list); - INIT_LIST_HEAD(&en->list); - write_unlock(&tbl->lock); - - return 1; -} -#endif - - /* * Get ip_vs_lblcr_entry associated with supplied parameters. */ diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c index 0e878fd..638ba8c 100644 --- a/net/ipv4/ipvs/ip_vs_proto_tcp.c +++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c @@ -275,28 +275,6 @@ static int tcp_timeouts[IP_VS_TCP_S_LAST+1] = { [IP_VS_TCP_S_LAST] = 2*HZ, }; - -#if 0 - -/* FIXME: This is going to die */ - -static int tcp_timeouts_dos[IP_VS_TCP_S_LAST+1] = { - [IP_VS_TCP_S_NONE] = 2*HZ, - [IP_VS_TCP_S_ESTABLISHED] = 8*60*HZ, - [IP_VS_TCP_S_SYN_SENT] = 60*HZ, - [IP_VS_TCP_S_SYN_RECV] = 10*HZ, - [IP_VS_TCP_S_FIN_WAIT] = 60*HZ, - [IP_VS_TCP_S_TIME_WAIT] = 60*HZ, - [IP_VS_TCP_S_CLOSE] = 10*HZ, - [IP_VS_TCP_S_CLOSE_WAIT] = 60*HZ, - [IP_VS_TCP_S_LAST_ACK] = 30*HZ, - [IP_VS_TCP_S_LISTEN] = 2*60*HZ, - [IP_VS_TCP_S_SYNACK] = 100*HZ, - [IP_VS_TCP_S_LAST] = 2*HZ, -}; - -#endif - static char * tcp_state_name_table[IP_VS_TCP_S_LAST+1] = { [IP_VS_TCP_S_NONE] = "NONE", [IP_VS_TCP_S_ESTABLISHED] = "ESTABLISHED", -- cgit v1.1 From c1cbe4b7ad0bc4b1d98ea708a3fecb7362aa4088 Mon Sep 17 00:00:00 2001 From: Benjamin LaHaise Date: Tue, 13 Dec 2005 23:22:19 -0800 Subject: [NET]: Avoid atomic xchg() for non-error case It also looks like there were 2 places where the test on sk_err was missing from the event wait logic (in sk_stream_wait_connect and sk_stream_wait_memory), while the rest of the sock_error() users look to be doing the right thing. This version of the patch fixes those, and cleans up a few places that were testing ->sk_err directly. Signed-off-by: Benjamin LaHaise Signed-off-by: David S. Miller --- include/net/sock.h | 5 ++++- net/bluetooth/af_bluetooth.c | 5 ++--- net/bluetooth/l2cap.c | 5 +++-- net/bluetooth/sco.c | 5 +++-- net/core/stream.c | 10 +++++++--- net/irda/af_irda.c | 5 +++-- net/llc/af_llc.c | 5 ++--- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index 982b4ec..0fbae85 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1166,7 +1166,10 @@ static inline int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb) static inline int sock_error(struct sock *sk) { - int err = xchg(&sk->sk_err, 0); + int err; + if (likely(!sk->sk_err)) + return 0; + err = xchg(&sk->sk_err, 0); return -err; } diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index ea616e3..fb031fe 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -287,10 +287,9 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo) timeo = schedule_timeout(timeo); lock_sock(sk); - if (sk->sk_err) { - err = sock_error(sk); + err = sock_error(sk); + if (err) break; - } } set_current_state(TASK_RUNNING); remove_wait_queue(sk->sk_sleep, &wait); diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index e3bb11c..95f33cc 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c @@ -767,8 +767,9 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms BT_DBG("sock %p, sk %p", sock, sk); - if (sk->sk_err) - return sock_error(sk); + err = sock_error(sk); + if (err) + return err; if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 9cb00dc..6481814 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -637,8 +637,9 @@ static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock, BT_DBG("sock %p, sk %p", sock, sk); - if (sk->sk_err) - return sock_error(sk); + err = sock_error(sk); + if (err) + return err; if (msg->msg_flags & MSG_OOB) return -EOPNOTSUPP; diff --git a/net/core/stream.c b/net/core/stream.c index 15bfd03..35e2525 100644 --- a/net/core/stream.c +++ b/net/core/stream.c @@ -55,8 +55,9 @@ int sk_stream_wait_connect(struct sock *sk, long *timeo_p) int done; do { - if (sk->sk_err) - return sock_error(sk); + int err = sock_error(sk); + if (err) + return err; if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) return -EPIPE; if (!*timeo_p) @@ -67,6 +68,7 @@ int sk_stream_wait_connect(struct sock *sk, long *timeo_p) prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); sk->sk_write_pending++; done = sk_wait_event(sk, timeo_p, + !sk->sk_err && !((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT))); finish_wait(sk->sk_sleep, &wait); @@ -137,7 +139,9 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p) set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); sk->sk_write_pending++; - sk_wait_event(sk, ¤t_timeo, sk_stream_memory_free(sk) && + sk_wait_event(sk, ¤t_timeo, !sk->sk_err && + !(sk->sk_shutdown & SEND_SHUTDOWN) && + sk_stream_memory_free(sk) && vm_wait); sk->sk_write_pending--; diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index 6f92f9c..f121f7d 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c @@ -1438,8 +1438,9 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, /* * POSIX 1003.1g mandates this order. */ - if (sk->sk_err) - ret = sock_error(sk); + ret = sock_error(sk); + if (ret) + break; else if (sk->sk_shutdown & RCV_SHUTDOWN) ; else if (noblock) diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index c3f0b07..b6d3df5 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -566,10 +566,9 @@ static int llc_wait_data(struct sock *sk, long timeo) /* * POSIX 1003.1g mandates this order. */ - if (sk->sk_err) { - rc = sock_error(sk); + rc = sock_error(sk); + if (rc) break; - } rc = 0; if (sk->sk_shutdown & RCV_SHUTDOWN) break; -- cgit v1.1 From 830a1e5c212fb3fdc83b66359c780c3b3a294897 Mon Sep 17 00:00:00 2001 From: Benjamin LaHaise Date: Tue, 13 Dec 2005 23:22:32 -0800 Subject: [AF_UNIX]: Remove superfluous reference counting in unix_stream_sendmsg AF_UNIX stream socket performance on P4 CPUs tends to suffer due to a lot of pipeline flushes from atomic operations. The patch below removes the sock_hold() and sock_put() in unix_stream_sendmsg(). This should be safe as the socket still holds a reference to its peer which is only released after the file descriptor's final user invokes unix_release_sock(). The only consideration is that we must add a memory barrier before setting the peer initially. Signed-off-by: Benjamin LaHaise Signed-off-by: David S. Miller --- net/unix/af_unix.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index acc73ba..1dc3685 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1063,10 +1063,12 @@ restart: /* Set credentials */ sk->sk_peercred = other->sk_peercred; - sock_hold(newsk); - unix_peer(sk) = newsk; sock->state = SS_CONNECTED; sk->sk_state = TCP_ESTABLISHED; + sock_hold(newsk); + + smp_mb__after_atomic_inc(); /* sock_hold() does an atomic_inc() */ + unix_peer(sk) = newsk; unix_state_wunlock(sk); @@ -1414,7 +1416,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, } else { sunaddr = NULL; err = -ENOTCONN; - other = unix_peer_get(sk); + other = unix_peer(sk); if (!other) goto out_err; } @@ -1476,7 +1478,6 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, other->sk_data_ready(other, size); sent+=size; } - sock_put(other); scm_destroy(siocb->scm); siocb->scm = NULL; @@ -1491,8 +1492,6 @@ pipe_err: send_sig(SIGPIPE,current,0); err = -EPIPE; out_err: - if (other) - sock_put(other); scm_destroy(siocb->scm); siocb->scm = NULL; return sent ? : err; -- cgit v1.1 From b9750ce13c08aa8a71a9b138d741f3046aefd991 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:22:54 -0800 Subject: [IPV6]: Generalise some functions Using sk->sk_protocol instead of IPPROTO_TCP. Will be used by DCCPv6 in the next changesets. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/linux/ipv6.h | 2 + include/net/inet6_connection_sock.h | 13 ++- net/ipv6/af_inet6.c | 52 ++++++++++++ net/ipv6/inet6_connection_sock.c | 103 ++++++++++++++++++++++++ net/ipv6/tcp_ipv6.c | 153 +----------------------------------- 5 files changed, 173 insertions(+), 150 deletions(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 7d3e86d..69a0dec 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -297,6 +297,8 @@ struct tcp6_sock { struct ipv6_pinfo inet6; }; +extern int inet6_sk_rebuild_header(struct sock *sk); + #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) static inline struct ipv6_pinfo * inet6_sk(const struct sock *__sk) { diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h index aa30ebd..b33b438 100644 --- a/include/net/inet6_connection_sock.h +++ b/include/net/inet6_connection_sock.h @@ -15,8 +15,15 @@ #include -struct sock; +struct in6_addr; +struct inet_bind_bucket; struct request_sock; +struct sk_buff; +struct sock; +struct sockaddr; + +extern int inet6_csk_bind_conflict(const struct sock *sk, + const struct inet_bind_bucket *tb); extern struct request_sock *inet6_csk_search_req(const struct sock *sk, struct request_sock ***prevp, @@ -28,4 +35,8 @@ extern struct request_sock *inet6_csk_search_req(const struct sock *sk, extern void inet6_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req, const unsigned long timeout); + +extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); + +extern int inet6_csk_xmit(struct sk_buff *skb, int ipfragok); #endif /* _INET6_CONNECTION_SOCK_H */ diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index d954638..fd040e9 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -609,6 +609,58 @@ inet6_unregister_protosw(struct inet_protosw *p) } } +int inet6_sk_rebuild_header(struct sock *sk) +{ + int err; + struct dst_entry *dst; + struct ipv6_pinfo *np = inet6_sk(sk); + + dst = __sk_dst_check(sk, np->dst_cookie); + + if (dst == NULL) { + struct inet_sock *inet = inet_sk(sk); + struct in6_addr *final_p = NULL, final; + struct flowi fl; + + memset(&fl, 0, sizeof(fl)); + fl.proto = sk->sk_protocol; + ipv6_addr_copy(&fl.fl6_dst, &np->daddr); + ipv6_addr_copy(&fl.fl6_src, &np->saddr); + fl.fl6_flowlabel = np->flow_label; + fl.oif = sk->sk_bound_dev_if; + fl.fl_ip_dport = inet->dport; + fl.fl_ip_sport = inet->sport; + + if (np->opt && np->opt->srcrt) { + struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt; + ipv6_addr_copy(&final, &fl.fl6_dst); + ipv6_addr_copy(&fl.fl6_dst, rt0->addr); + final_p = &final; + } + + err = ip6_dst_lookup(sk, &dst, &fl); + if (err) { + sk->sk_route_caps = 0; + return err; + } + if (final_p) + ipv6_addr_copy(&fl.fl6_dst, final_p); + + if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { + sk->sk_err_soft = -err; + return err; + } + + ip6_dst_store(sk, dst, NULL); + sk->sk_route_caps = dst->dev->features & + ~(NETIF_F_IP_CSUM | NETIF_F_TSO); + } + + return 0; +} + +EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header); + int snmp6_mib_init(void *ptr[2], size_t mibsize, size_t mibalign) { diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c index fe874ee..792f90f 100644 --- a/net/ipv6/inet6_connection_sock.c +++ b/net/ipv6/inet6_connection_sock.c @@ -21,8 +21,34 @@ #include #include +#include +#include +#include #include +int inet6_csk_bind_conflict(const struct sock *sk, + const struct inet_bind_bucket *tb) +{ + const struct sock *sk2; + const struct hlist_node *node; + + /* We must walk the whole port owner list in this case. -DaveM */ + sk_for_each_bound(sk2, node, &tb->owners) { + if (sk != sk2 && + (!sk->sk_bound_dev_if || + !sk2->sk_bound_dev_if || + sk->sk_bound_dev_if == sk2->sk_bound_dev_if) && + (!sk->sk_reuse || !sk2->sk_reuse || + sk2->sk_state == TCP_LISTEN) && + ipv6_rcv_saddr_equal(sk, sk2)) + break; + } + + return node != NULL; +} + +EXPORT_SYMBOL_GPL(inet6_csk_bind_conflict); + /* * request_sock (formerly open request) hash tables. */ @@ -94,3 +120,80 @@ void inet6_csk_reqsk_queue_hash_add(struct sock *sk, } EXPORT_SYMBOL_GPL(inet6_csk_reqsk_queue_hash_add); + +void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) uaddr; + + sin6->sin6_family = AF_INET6; + ipv6_addr_copy(&sin6->sin6_addr, &np->daddr); + sin6->sin6_port = inet_sk(sk)->dport; + /* We do not store received flowlabel for TCP */ + sin6->sin6_flowinfo = 0; + sin6->sin6_scope_id = 0; + if (sk->sk_bound_dev_if && + ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) + sin6->sin6_scope_id = sk->sk_bound_dev_if; +} + +EXPORT_SYMBOL_GPL(inet6_csk_addr2sockaddr); + +int inet6_csk_xmit(struct sk_buff *skb, int ipfragok) +{ + struct sock *sk = skb->sk; + struct inet_sock *inet = inet_sk(sk); + struct ipv6_pinfo *np = inet6_sk(sk); + struct flowi fl; + struct dst_entry *dst; + struct in6_addr *final_p = NULL, final; + + memset(&fl, 0, sizeof(fl)); + fl.proto = sk->sk_protocol; + ipv6_addr_copy(&fl.fl6_dst, &np->daddr); + ipv6_addr_copy(&fl.fl6_src, &np->saddr); + fl.fl6_flowlabel = np->flow_label; + IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel); + fl.oif = sk->sk_bound_dev_if; + fl.fl_ip_sport = inet->sport; + fl.fl_ip_dport = inet->dport; + + if (np->opt && np->opt->srcrt) { + struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt; + ipv6_addr_copy(&final, &fl.fl6_dst); + ipv6_addr_copy(&fl.fl6_dst, rt0->addr); + final_p = &final; + } + + dst = __sk_dst_check(sk, np->dst_cookie); + + if (dst == NULL) { + int err = ip6_dst_lookup(sk, &dst, &fl); + + if (err) { + sk->sk_err_soft = -err; + return err; + } + + if (final_p) + ipv6_addr_copy(&fl.fl6_dst, final_p); + + if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { + sk->sk_route_caps = 0; + return err; + } + + ip6_dst_store(sk, dst, NULL); + sk->sk_route_caps = dst->dev->features & + ~(NETIF_F_IP_CSUM | NETIF_F_TSO); + } + + skb->dst = dst_clone(dst); + + /* Restore final destination back after routing done */ + ipv6_addr_copy(&fl.fl6_dst, &np->daddr); + + return ip6_xmit(sk, skb, &fl, np->opt, 0); +} + +EXPORT_SYMBOL_GPL(inet6_csk_xmit); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 8ce8a13..2f932ce 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -72,32 +72,10 @@ static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb); static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb); -static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok); static struct inet_connection_sock_af_ops ipv6_mapped; static struct inet_connection_sock_af_ops ipv6_specific; -int inet6_csk_bind_conflict(const struct sock *sk, - const struct inet_bind_bucket *tb) -{ - const struct sock *sk2; - const struct hlist_node *node; - - /* We must walk the whole port owner list in this case. -DaveM */ - sk_for_each_bound(sk2, node, &tb->owners) { - if (sk != sk2 && - (!sk->sk_bound_dev_if || - !sk2->sk_bound_dev_if || - sk->sk_bound_dev_if == sk2->sk_bound_dev_if) && - (!sk->sk_reuse || !sk2->sk_reuse || - sk2->sk_state == TCP_LISTEN) && - ipv6_rcv_saddr_equal(sk, sk2)) - break; - } - - return node != NULL; -} - static int tcp_v6_get_port(struct sock *sk, unsigned short snum) { return inet_csk_get_port(&tcp_hashinfo, sk, snum, @@ -1500,129 +1478,6 @@ do_time_wait: goto discard_it; } -static int tcp_v6_rebuild_header(struct sock *sk) -{ - int err; - struct dst_entry *dst; - struct ipv6_pinfo *np = inet6_sk(sk); - - dst = __sk_dst_check(sk, np->dst_cookie); - - if (dst == NULL) { - struct inet_sock *inet = inet_sk(sk); - struct in6_addr *final_p = NULL, final; - struct flowi fl; - - memset(&fl, 0, sizeof(fl)); - fl.proto = IPPROTO_TCP; - ipv6_addr_copy(&fl.fl6_dst, &np->daddr); - ipv6_addr_copy(&fl.fl6_src, &np->saddr); - fl.fl6_flowlabel = np->flow_label; - fl.oif = sk->sk_bound_dev_if; - fl.fl_ip_dport = inet->dport; - fl.fl_ip_sport = inet->sport; - - if (np->opt && np->opt->srcrt) { - struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt; - ipv6_addr_copy(&final, &fl.fl6_dst); - ipv6_addr_copy(&fl.fl6_dst, rt0->addr); - final_p = &final; - } - - err = ip6_dst_lookup(sk, &dst, &fl); - if (err) { - sk->sk_route_caps = 0; - return err; - } - if (final_p) - ipv6_addr_copy(&fl.fl6_dst, final_p); - - if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { - sk->sk_err_soft = -err; - return err; - } - - ip6_dst_store(sk, dst, NULL); - sk->sk_route_caps = dst->dev->features & - ~(NETIF_F_IP_CSUM | NETIF_F_TSO); - } - - return 0; -} - -static int tcp_v6_xmit(struct sk_buff *skb, int ipfragok) -{ - struct sock *sk = skb->sk; - struct inet_sock *inet = inet_sk(sk); - struct ipv6_pinfo *np = inet6_sk(sk); - struct flowi fl; - struct dst_entry *dst; - struct in6_addr *final_p = NULL, final; - - memset(&fl, 0, sizeof(fl)); - fl.proto = IPPROTO_TCP; - ipv6_addr_copy(&fl.fl6_dst, &np->daddr); - ipv6_addr_copy(&fl.fl6_src, &np->saddr); - fl.fl6_flowlabel = np->flow_label; - IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel); - fl.oif = sk->sk_bound_dev_if; - fl.fl_ip_sport = inet->sport; - fl.fl_ip_dport = inet->dport; - - if (np->opt && np->opt->srcrt) { - struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt; - ipv6_addr_copy(&final, &fl.fl6_dst); - ipv6_addr_copy(&fl.fl6_dst, rt0->addr); - final_p = &final; - } - - dst = __sk_dst_check(sk, np->dst_cookie); - - if (dst == NULL) { - int err = ip6_dst_lookup(sk, &dst, &fl); - - if (err) { - sk->sk_err_soft = -err; - return err; - } - - if (final_p) - ipv6_addr_copy(&fl.fl6_dst, final_p); - - if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { - sk->sk_route_caps = 0; - return err; - } - - ip6_dst_store(sk, dst, NULL); - sk->sk_route_caps = dst->dev->features & - ~(NETIF_F_IP_CSUM | NETIF_F_TSO); - } - - skb->dst = dst_clone(dst); - - /* Restore final destination back after routing done */ - ipv6_addr_copy(&fl.fl6_dst, &np->daddr); - - return ip6_xmit(sk, skb, &fl, np->opt, 0); -} - -static void v6_addr2sockaddr(struct sock *sk, struct sockaddr * uaddr) -{ - struct ipv6_pinfo *np = inet6_sk(sk); - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) uaddr; - - sin6->sin6_family = AF_INET6; - ipv6_addr_copy(&sin6->sin6_addr, &np->daddr); - sin6->sin6_port = inet_sk(sk)->dport; - /* We do not store received flowlabel for TCP */ - sin6->sin6_flowinfo = 0; - sin6->sin6_scope_id = 0; - if (sk->sk_bound_dev_if && - ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) - sin6->sin6_scope_id = sk->sk_bound_dev_if; -} - static int tcp_v6_remember_stamp(struct sock *sk) { /* Alas, not yet... */ @@ -1630,9 +1485,9 @@ static int tcp_v6_remember_stamp(struct sock *sk) } static struct inet_connection_sock_af_ops ipv6_specific = { - .queue_xmit = tcp_v6_xmit, + .queue_xmit = inet6_csk_xmit, .send_check = tcp_v6_send_check, - .rebuild_header = tcp_v6_rebuild_header, + .rebuild_header = inet6_sk_rebuild_header, .conn_request = tcp_v6_conn_request, .syn_recv_sock = tcp_v6_syn_recv_sock, .remember_stamp = tcp_v6_remember_stamp, @@ -1640,7 +1495,7 @@ static struct inet_connection_sock_af_ops ipv6_specific = { .setsockopt = ipv6_setsockopt, .getsockopt = ipv6_getsockopt, - .addr2sockaddr = v6_addr2sockaddr, + .addr2sockaddr = inet6_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in6) }; @@ -1659,7 +1514,7 @@ static struct inet_connection_sock_af_ops ipv6_mapped = { .setsockopt = ipv6_setsockopt, .getsockopt = ipv6_getsockopt, - .addr2sockaddr = v6_addr2sockaddr, + .addr2sockaddr = inet6_csk_addr2sockaddr, .sockaddr_len = sizeof(struct sockaddr_in6) }; -- cgit v1.1 From 0fa1a53e1f055a6c790f40e7728f42a825b29248 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:23:09 -0800 Subject: [IPV6]: Introduce inet6_timewait_sock Out of tcp6_timewait_sock, that now is just an aggregation of inet_timewait_sock and inet6_timewait_sock, using tw_ipv6_offset in struct inet_timewait_sock, that is common to the IPv6 transport protocols that use timewait sockets, like DCCP and TCP. tw_ipv6_offset plays the struct inet_sock pinfo6 role, i.e. for the generic code to find the IPv6 area in a timewait sock. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/linux/ipv6.h | 32 +++++++++++++++++++++----------- include/net/inet6_hashtables.h | 6 +++--- include/net/inet_timewait_sock.h | 3 ++- net/ipv4/inet_diag.c | 6 +++--- net/ipv4/tcp_minisocks.c | 8 +++++--- net/ipv6/addrconf.c | 2 +- net/ipv6/tcp_ipv6.c | 12 ++++++------ 7 files changed, 41 insertions(+), 28 deletions(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 69a0dec..7d39085 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -348,26 +348,36 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to, #include +struct inet6_timewait_sock { + struct in6_addr tw_v6_daddr; + struct in6_addr tw_v6_rcv_saddr; +}; + struct tcp6_timewait_sock { - struct tcp_timewait_sock tw_v6_sk; - struct in6_addr tw_v6_daddr; - struct in6_addr tw_v6_rcv_saddr; + struct tcp_timewait_sock tcp6tw_tcp; + struct inet6_timewait_sock tcp6tw_inet6; }; -static inline struct tcp6_timewait_sock *tcp6_twsk(const struct sock *sk) +static inline u16 inet6_tw_offset(const struct proto *prot) +{ + return prot->twsk_obj_size - sizeof(struct inet6_timewait_sock); +} + +static inline struct inet6_timewait_sock *inet6_twsk(const struct sock *sk) { - return (struct tcp6_timewait_sock *)sk; + return (struct inet6_timewait_sock *)(((u8 *)sk) + + inet_twsk(sk)->tw_ipv6_offset); } -static inline struct in6_addr *__tcp_v6_rcv_saddr(const struct sock *sk) +static inline struct in6_addr *__inet6_rcv_saddr(const struct sock *sk) { return likely(sk->sk_state != TCP_TIME_WAIT) ? - &inet6_sk(sk)->rcv_saddr : &tcp6_twsk(sk)->tw_v6_rcv_saddr; + &inet6_sk(sk)->rcv_saddr : &inet6_twsk(sk)->tw_v6_rcv_saddr; } -static inline struct in6_addr *tcp_v6_rcv_saddr(const struct sock *sk) +static inline struct in6_addr *inet6_rcv_saddr(const struct sock *sk) { - return sk->sk_family == AF_INET6 ? __tcp_v6_rcv_saddr(sk) : NULL; + return sk->sk_family == AF_INET6 ? __inet6_rcv_saddr(sk) : NULL; } static inline int inet_v6_ipv6only(const struct sock *sk) @@ -395,8 +405,8 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk) return NULL; } -#define __tcp_v6_rcv_saddr(__sk) NULL -#define tcp_v6_rcv_saddr(__sk) NULL +#define __inet6_rcv_saddr(__sk) NULL +#define inet6_rcv_saddr(__sk) NULL #define tcp_twsk_ipv6only(__sk) 0 #define inet_v6_ipv6only(__sk) 0 #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index a4a204f..25f708f 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h @@ -110,10 +110,10 @@ static inline struct sock * if(*((__u32 *)&(tw->tw_dport)) == ports && sk->sk_family == PF_INET6) { - const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk); + const struct inet6_timewait_sock *tw6 = inet6_twsk(sk); - if (ipv6_addr_equal(&tcp6tw->tw_v6_daddr, saddr) && - ipv6_addr_equal(&tcp6tw->tw_v6_rcv_saddr, daddr) && + if (ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && + ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif)) goto hit; } diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 28f7b21..ca240f8 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h @@ -127,7 +127,8 @@ struct inet_timewait_sock { __u16 tw_num; /* And these are ours. */ __u8 tw_ipv6only:1; - /* 31 bits hole, try to pack */ + /* 15 bits hole, try to pack */ + __u16 tw_ipv6_offset; int tw_timeout; unsigned long tw_ttd; struct inet_bind_bucket *tw_tb; diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 3ce73b1..c499081 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -112,12 +112,12 @@ static int inet_diag_fill(struct sk_buff *skb, struct sock *sk, r->idiag_inode = 0; #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) if (r->idiag_family == AF_INET6) { - const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk); + const struct inet6_timewait_sock *tw6 = inet6_twsk(sk); ipv6_addr_copy((struct in6_addr *)r->id.idiag_src, - &tcp6tw->tw_v6_rcv_saddr); + &tw6->tw_v6_rcv_saddr); ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, - &tcp6tw->tw_v6_daddr); + &tw6->tw_v6_daddr); } #endif nlh->nlmsg_len = skb->tail - b; diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 9c02968..2b9b7f6 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c @@ -298,10 +298,12 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) if (tw->tw_family == PF_INET6) { struct ipv6_pinfo *np = inet6_sk(sk); - struct tcp6_timewait_sock *tcp6tw = tcp6_twsk((struct sock *)tw); + struct inet6_timewait_sock *tw6; - ipv6_addr_copy(&tcp6tw->tw_v6_daddr, &np->daddr); - ipv6_addr_copy(&tcp6tw->tw_v6_rcv_saddr, &np->rcv_saddr); + tw->tw_ipv6_offset = inet6_tw_offset(sk->sk_prot); + tw6 = inet6_twsk((struct sock *)tw); + ipv6_addr_copy(&tw6->tw_v6_daddr, &np->daddr); + ipv6_addr_copy(&tw6->tw_v6_rcv_saddr, &np->rcv_saddr); tw->tw_ipv6only = np->ipv6only; } #endif diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index a60585f..704fb73 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -1195,7 +1195,7 @@ struct inet6_ifaddr * ipv6_get_ifaddr(struct in6_addr *addr, struct net_device * int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2) { const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr; - const struct in6_addr *sk2_rcv_saddr6 = tcp_v6_rcv_saddr(sk2); + const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2); u32 sk_rcv_saddr = inet_sk(sk)->rcv_saddr; u32 sk2_rcv_saddr = inet_rcv_saddr(sk2); int sk_ipv6only = ipv6_only_sock(sk); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 2f932ce..cb88007 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -138,14 +138,14 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport, /* Check TIME-WAIT sockets first. */ sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) { - const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk2); + const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2); tw = inet_twsk(sk2); if(*((__u32 *)&(tw->tw_dport)) == ports && sk2->sk_family == PF_INET6 && - ipv6_addr_equal(&tcp6tw->tw_v6_daddr, saddr) && - ipv6_addr_equal(&tcp6tw->tw_v6_rcv_saddr, daddr) && + ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && + ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && sk2->sk_bound_dev_if == sk->sk_bound_dev_if) { const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2); struct tcp_sock *tp = tcp_sk(sk); @@ -1663,14 +1663,14 @@ static void get_timewait6_sock(struct seq_file *seq, { struct in6_addr *dest, *src; __u16 destp, srcp; - struct tcp6_timewait_sock *tcp6tw = tcp6_twsk((struct sock *)tw); + struct inet6_timewait_sock *tw6 = inet6_twsk((struct sock *)tw); int ttd = tw->tw_ttd - jiffies; if (ttd < 0) ttd = 0; - dest = &tcp6tw->tw_v6_daddr; - src = &tcp6tw->tw_v6_rcv_saddr; + dest = &tw6->tw_v6_daddr; + src = &tw6->tw_v6_rcv_saddr; destp = ntohs(tw->tw_dport); srcp = ntohs(tw->tw_sport); -- cgit v1.1 From 3cf3dc6c2e05e67b12e522f547c0b71d509a516c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:23:20 -0800 Subject: [IPV6]: Export some symbols for DCCPv6 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/ipv6/af_inet6.c | 2 ++ net/ipv6/exthdrs.c | 4 ++++ net/ipv6/ip6_flowlabel.c | 2 ++ net/ipv6/ip6_output.c | 2 ++ 4 files changed, 10 insertions(+) diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index fd040e9..23675ef 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -389,6 +389,8 @@ int inet6_destroy_sock(struct sock *sk) return 0; } +EXPORT_SYMBOL_GPL(inet6_destroy_sock); + /* * This does both peername and sockname. */ diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index be6faf3..113374d 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c @@ -413,6 +413,8 @@ ipv6_invert_rthdr(struct sock *sk, struct ipv6_rt_hdr *hdr) return opt; } +EXPORT_SYMBOL_GPL(ipv6_invert_rthdr); + /********************************** Hop-by-hop options. **********************************/ @@ -579,6 +581,8 @@ ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt) return opt2; } +EXPORT_SYMBOL_GPL(ipv6_dup_options); + static int ipv6_renew_option(void *ohdr, struct ipv6_opt_hdr __user *newopt, int newoptlen, int inherit, diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c index 1cf0276..89d12b4 100644 --- a/net/ipv6/ip6_flowlabel.c +++ b/net/ipv6/ip6_flowlabel.c @@ -200,6 +200,8 @@ struct ip6_flowlabel * fl6_sock_lookup(struct sock *sk, u32 label) return NULL; } +EXPORT_SYMBOL_GPL(fl6_sock_lookup); + void fl6_free_socklist(struct sock *sk) { struct ipv6_pinfo *np = inet6_sk(sk); diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 8523c76..b4c4beb 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -775,6 +775,8 @@ out_err_release: return err; } +EXPORT_SYMBOL_GPL(ip6_dst_lookup); + static inline int ip6_ufo_append_data(struct sock *sk, int getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb), -- cgit v1.1 From 34ca6860810342441f801226b19ae6c9e0ecb34f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:23:32 -0800 Subject: [DCCP]: Just rename dccp_v4_prot to dccp_prot To match TCP equivalent. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/dccp.h | 2 +- net/dccp/ipv4.c | 2 +- net/dccp/proto.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index f97b85d..e711f85 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -59,7 +59,7 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo); #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */ -extern struct proto dccp_v4_prot; +extern struct proto dccp_prot; /* is seq1 < seq2 ? */ static inline int before48(const u64 seq1, const u64 seq2) diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 0ce7d0f..9f69a67 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -1317,7 +1317,7 @@ static struct request_sock_ops dccp_request_sock_ops = { .send_reset = dccp_v4_ctl_send_reset, }; -struct proto dccp_v4_prot = { +struct proto dccp_prot = { .name = "DCCP", .owner = THIS_MODULE, .close = dccp_close, diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 7b30c12..9cb2989 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -684,7 +684,7 @@ extern struct net_proto_family inet_family_ops; static struct inet_protosw dccp_v4_protosw = { .type = SOCK_DCCP, .protocol = IPPROTO_DCCP, - .prot = &dccp_v4_prot, + .prot = &dccp_prot, .ops = &inet_dccp_ops, .capability = -1, .no_check = 0, @@ -769,7 +769,7 @@ static int __init dccp_init(void) { unsigned long goal; int ehash_order, bhash_order, i; - int rc = proto_register(&dccp_v4_prot, 1); + int rc = proto_register(&dccp_prot, 1); if (rc) goto out; @@ -872,7 +872,7 @@ out_free_bind_bucket_cachep: kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); dccp_hashinfo.bind_bucket_cachep = NULL; out_proto_unregister: - proto_unregister(&dccp_v4_prot); + proto_unregister(&dccp_prot); goto out; } @@ -895,7 +895,7 @@ static void __exit dccp_fini(void) get_order(dccp_hashinfo.ehash_size * sizeof(struct inet_ehash_bucket))); kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); - proto_unregister(&dccp_v4_prot); + proto_unregister(&dccp_prot); } module_init(dccp_init); -- cgit v1.1 From f21e68caa0ddffddf98a1e729e734a470957b6ec Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:24:16 -0800 Subject: [DCCP]: Prepare the AF agnostic core for the introduction of DCCPv6 Basically exports a similar set of functions as the one exported by the non-AF specific TCP code. In the process moved some non-AF specific code from dccp_v4_connect to dccp_connect_init and moved the checksum verification from dccp_invalid_packet to dccp_v4_rcv, so as to use it in dccp_v6_rcv too. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/dccp.h | 22 ++++++++++++++++ net/dccp/input.c | 4 +++ net/dccp/ipv4.c | 73 ++++++++++++++++++++++++---------------------------- net/dccp/minisocks.c | 8 ++++++ net/dccp/output.c | 27 ++++++++++++------- net/dccp/proto.c | 32 ++++++++++++++++++++--- 6 files changed, 114 insertions(+), 52 deletions(-) diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index e711f85..93f26dd 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -228,6 +228,9 @@ extern int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, extern int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, const struct dccp_hdr *dh, const unsigned len); +extern int dccp_v4_init_sock(struct sock *sk); +extern int dccp_v4_destroy_sock(struct sock *sk); + extern void dccp_close(struct sock *sk, long timeout); extern struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst, @@ -238,6 +241,7 @@ extern struct sk_buff *dccp_make_reset(struct sock *sk, extern int dccp_connect(struct sock *sk); extern int dccp_disconnect(struct sock *sk, int flags); +extern void dccp_unhash(struct sock *sk); extern int dccp_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen); extern int dccp_setsockopt(struct sock *sk, int level, int optname, @@ -249,6 +253,13 @@ extern int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len, int nonblock, int flags, int *addr_len); extern void dccp_shutdown(struct sock *sk, int how); +extern int inet_dccp_listen(struct socket *sock, int backlog); +extern unsigned int dccp_poll(struct file *file, struct socket *sock, + poll_table *wait); +extern void dccp_v4_send_check(struct sock *sk, int len, + struct sk_buff *skb); +extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, + int addr_len); extern int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, const u32 daddr); @@ -256,6 +267,17 @@ extern int dccp_v4_checksum(const struct sk_buff *skb, extern int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code); extern void dccp_send_close(struct sock *sk, const int active); +extern int dccp_invalid_packet(struct sk_buff *skb); + +static inline int dccp_bad_service_code(const struct sock *sk, + const __u32 service) +{ + const struct dccp_sock *dp = dccp_sk(sk); + + if (dp->dccps_service == service) + return 0; + return !dccp_list_has_service(dp->dccps_service_list, service); +} struct dccp_skb_cb { __u8 dccpd_type:4; diff --git a/net/dccp/input.c b/net/dccp/input.c index c81488f..9a724ff 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c @@ -250,6 +250,8 @@ discard: return 0; } +EXPORT_SYMBOL_GPL(dccp_rcv_established); + static int dccp_rcv_request_sent_state_process(struct sock *sk, struct sk_buff *skb, const struct dccp_hdr *dh, @@ -567,3 +569,5 @@ discard: } return 0; } + +EXPORT_SYMBOL_GPL(dccp_rcv_state_process); diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 9f69a67..3108c9d 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -46,11 +46,13 @@ static void dccp_v4_hash(struct sock *sk) inet_hash(&dccp_hashinfo, sk); } -static void dccp_v4_unhash(struct sock *sk) +void dccp_unhash(struct sock *sk) { inet_unhash(&dccp_hashinfo, sk); } +EXPORT_SYMBOL_GPL(dccp_unhash); + /* called with local bh disabled */ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport, struct inet_timewait_sock **twp) @@ -209,8 +211,7 @@ out: } } -static int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, - int addr_len) +int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct inet_sock *inet = inet_sk(sk); struct dccp_sock *dp = dccp_sk(sk); @@ -288,16 +289,6 @@ static int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, usin->sin_port); dccp_update_gss(sk, dp->dccps_iss); - /* - * SWL and AWL are initially adjusted so that they are not less than - * the initial Sequence Numbers received and sent, respectively: - * SWL := max(GSR + 1 - floor(W/4), ISR), - * AWL := max(GSS - W' + 1, ISS). - * These adjustments MUST be applied only at the beginning of the - * connection. - */ - dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss)); - inet->id = dp->dccps_iss ^ jiffies; err = dccp_connect(sk); @@ -317,6 +308,8 @@ failure: goto out; } +EXPORT_SYMBOL_GPL(dccp_v4_connect); + /* * This routine does path mtu discovery as defined in RFC1191. */ @@ -608,7 +601,7 @@ out: } /* This routine computes an IPv4 DCCP checksum. */ -static void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) +void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) { const struct inet_sock *inet = inet_sk(sk); struct dccp_hdr *dh = dccp_hdr(skb); @@ -616,6 +609,8 @@ static void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) dh->dccph_checksum = dccp_v4_checksum(skb, inet->saddr, inet->daddr); } +EXPORT_SYMBOL_GPL(dccp_v4_send_check); + int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code) { struct sk_buff *skb; @@ -651,16 +646,6 @@ static inline u64 dccp_v4_init_sequence(const struct sock *sk, dccp_hdr(skb)->dccph_sport); } -static inline int dccp_bad_service_code(const struct sock *sk, - const __u32 service) -{ - const struct dccp_sock *dp = dccp_sk(sk); - - if (dp->dccps_service == service) - return 0; - return !dccp_list_has_service(dp->dccps_service_list, service); -} - int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) { struct inet_request_sock *ireq; @@ -672,7 +657,6 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) const __u32 service = dccp_hdr_request(skb)->dccph_req_service; struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY; - struct dst_entry *dst = NULL; /* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */ if (((struct rtable *)skb->dst)->rt_flags & @@ -713,7 +697,6 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) ireq = inet_rsk(req); ireq->loc_addr = daddr; ireq->rmt_addr = saddr; - /* FIXME: Merge Aristeu's option parsing code when ready */ req->rcv_wnd = 100; /* Fake, option parsing will get the right value */ ireq->opt = NULL; @@ -731,7 +714,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) dreq->dreq_iss = dccp_v4_init_sequence(sk, skb); dreq->dreq_service = service; - if (dccp_v4_send_response(sk, req, dst)) + if (dccp_v4_send_response(sk, req, NULL)) goto drop_and_free; inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT); @@ -748,6 +731,8 @@ drop: return -1; } +EXPORT_SYMBOL_GPL(dccp_v4_conn_request); + /* * The three way handshake has completed - we got a valid ACK or DATAACK - * now create the new socket. @@ -802,6 +787,8 @@ exit: return NULL; } +EXPORT_SYMBOL_GPL(dccp_v4_request_recv_sock); + static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb) { const struct dccp_hdr *dh = dccp_hdr(skb); @@ -1021,7 +1008,9 @@ discard: return 0; } -static inline int dccp_invalid_packet(struct sk_buff *skb) +EXPORT_SYMBOL_GPL(dccp_v4_do_rcv); + +int dccp_invalid_packet(struct sk_buff *skb) { const struct dccp_hdr *dh; @@ -1075,17 +1064,11 @@ static inline int dccp_invalid_packet(struct sk_buff *skb) return 1; } - /* If the header checksum is incorrect, drop packet and return */ - if (dccp_v4_verify_checksum(skb, skb->nh.iph->saddr, - skb->nh.iph->daddr) < 0) { - LIMIT_NETDEBUG(KERN_WARNING "DCCP: header checksum is " - "incorrect\n"); - return 1; - } - return 0; } +EXPORT_SYMBOL_GPL(dccp_invalid_packet); + /* this is called when real data arrives */ int dccp_v4_rcv(struct sk_buff *skb) { @@ -1098,6 +1081,14 @@ int dccp_v4_rcv(struct sk_buff *skb) if (dccp_invalid_packet(skb)) goto discard_it; + /* If the header checksum is incorrect, drop packet and return */ + if (dccp_v4_verify_checksum(skb, skb->nh.iph->saddr, + skb->nh.iph->daddr) < 0) { + LIMIT_NETDEBUG(KERN_WARNING "%s: incorrect header checksum\n", + __FUNCTION__); + goto discard_it; + } + dh = dccp_hdr(skb); DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb); @@ -1217,7 +1208,7 @@ struct inet_connection_sock_af_ops dccp_ipv4_af_ops = { .sockaddr_len = sizeof(struct sockaddr_in), }; -static int dccp_v4_init_sock(struct sock *sk) +int dccp_v4_init_sock(struct sock *sk) { struct dccp_sock *dp = dccp_sk(sk); static int dccp_ctl_socket_init = 1; @@ -1270,7 +1261,9 @@ static int dccp_v4_init_sock(struct sock *sk) return 0; } -static int dccp_v4_destroy_sock(struct sock *sk) +EXPORT_SYMBOL_GPL(dccp_v4_init_sock); + +int dccp_v4_destroy_sock(struct sock *sk) { struct dccp_sock *dp = dccp_sk(sk); @@ -1303,6 +1296,8 @@ static int dccp_v4_destroy_sock(struct sock *sk) return 0; } +EXPORT_SYMBOL_GPL(dccp_v4_destroy_sock); + static void dccp_v4_reqsk_destructor(struct request_sock *req) { kfree(inet_rsk(req)->opt); @@ -1331,7 +1326,7 @@ struct proto dccp_prot = { .recvmsg = dccp_recvmsg, .backlog_rcv = dccp_v4_do_rcv, .hash = dccp_v4_hash, - .unhash = dccp_v4_unhash, + .unhash = dccp_unhash, .accept = inet_csk_accept, .get_port = dccp_v4_get_port, .shutdown = dccp_shutdown, diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index c7ff80c..5c767b5 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c @@ -40,6 +40,8 @@ struct inet_timewait_death_row dccp_death_row = { (unsigned long)&dccp_death_row), }; +EXPORT_SYMBOL_GPL(dccp_death_row); + void dccp_time_wait(struct sock *sk, int state, int timeo) { struct inet_timewait_sock *tw = NULL; @@ -170,6 +172,8 @@ out_free: return newsk; } +EXPORT_SYMBOL_GPL(dccp_create_openreq_child); + /* * Process an incoming packet for RESPOND sockets represented * as an request_sock. @@ -236,6 +240,8 @@ drop: goto out; } +EXPORT_SYMBOL_GPL(dccp_check_req); + /* * Queue segment on the new socket if the new socket is active, * otherwise we just shortcircuit this and continue with @@ -266,3 +272,5 @@ int dccp_child_process(struct sock *parent, struct sock *child, sock_put(child); return ret; } + +EXPORT_SYMBOL_GPL(dccp_child_process); diff --git a/net/dccp/output.c b/net/dccp/output.c index f358805..c40f7f8 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c @@ -135,12 +135,6 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) { struct dccp_sock *dp = dccp_sk(sk); - /* - * FIXME: we really should be using the af_specific thing to support - * IPv6. - * mss_now = pmtu - tp->af_specific->net_header_len - - * sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext); - */ int mss_now = (pmtu - inet_csk(sk)->icsk_af_ops->net_header_len - sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext)); @@ -164,6 +158,8 @@ unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) return mss_now; } +EXPORT_SYMBOL_GPL(dccp_sync_mss); + void dccp_write_space(struct sock *sk) { read_lock(&sk->sk_callback_lock); @@ -319,6 +315,8 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst, return skb; } +EXPORT_SYMBOL_GPL(dccp_make_response); + struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst, const enum dccp_reset_codes code) @@ -375,6 +373,7 @@ struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst, */ static inline void dccp_connect_init(struct sock *sk) { + struct dccp_sock *dp = dccp_sk(sk); struct dst_entry *dst = __sk_dst_get(sk); struct inet_connection_sock *icsk = inet_csk(sk); @@ -383,10 +382,16 @@ static inline void dccp_connect_init(struct sock *sk) dccp_sync_mss(sk, dst_mtu(dst)); - /* - * FIXME: set dp->{dccps_swh,dccps_swl}, with - * something like dccp_inc_seq - */ + dccp_update_gss(sk, dp->dccps_iss); + /* + * SWL and AWL are initially adjusted so that they are not less than + * the initial Sequence Numbers received and sent, respectively: + * SWL := max(GSR + 1 - floor(W/4), ISR), + * AWL := max(GSS - W' + 1, ISS). + * These adjustments MUST be applied only at the beginning of the + * connection. + */ + dccp_set_seqno(&dp->dccps_awl, max48(dp->dccps_awl, dp->dccps_iss)); icsk->icsk_retransmits = 0; } @@ -418,6 +423,8 @@ int dccp_connect(struct sock *sk) return 0; } +EXPORT_SYMBOL_GPL(dccp_connect); + void dccp_send_ack(struct sock *sk) { /* If we have been reset, we may not send again. */ diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 9cb2989..51dfacd2 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -41,8 +41,12 @@ DEFINE_SNMP_STAT(struct dccp_mib, dccp_statistics) __read_mostly; +EXPORT_SYMBOL_GPL(dccp_statistics); + atomic_t dccp_orphan_count = ATOMIC_INIT(0); +EXPORT_SYMBOL_GPL(dccp_orphan_count); + static struct net_protocol dccp_protocol = { .handler = dccp_v4_rcv, .err_handler = dccp_v4_err, @@ -149,6 +153,8 @@ int dccp_disconnect(struct sock *sk, int flags) return err; } +EXPORT_SYMBOL_GPL(dccp_disconnect); + /* * Wait for a DCCP event. * @@ -156,8 +162,8 @@ int dccp_disconnect(struct sock *sk, int flags) * take care of normal races (between the test and the event) and we don't * go look at any of the socket buffers directly. */ -static unsigned int dccp_poll(struct file *file, struct socket *sock, - poll_table *wait) +unsigned int dccp_poll(struct file *file, struct socket *sock, + poll_table *wait) { unsigned int mask; struct sock *sk = sock->sk; @@ -205,12 +211,16 @@ static unsigned int dccp_poll(struct file *file, struct socket *sock, return mask; } +EXPORT_SYMBOL_GPL(dccp_poll); + int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg) { dccp_pr_debug("entry\n"); return -ENOIOCTLCMD; } +EXPORT_SYMBOL_GPL(dccp_ioctl); + static int dccp_setsockopt_service(struct sock *sk, const u32 service, char __user *optval, int optlen) { @@ -284,6 +294,8 @@ int dccp_setsockopt(struct sock *sk, int level, int optname, return err; } +EXPORT_SYMBOL_GPL(dccp_setsockopt); + static int dccp_getsockopt_service(struct sock *sk, int len, u32 __user *optval, int __user *optlen) @@ -357,6 +369,8 @@ int dccp_getsockopt(struct sock *sk, int level, int optname, return 0; } +EXPORT_SYMBOL_GPL(dccp_getsockopt); + int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len) { @@ -413,6 +427,8 @@ out_discard: goto out_release; } +EXPORT_SYMBOL_GPL(dccp_sendmsg); + int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, size_t len, int nonblock, int flags, int *addr_len) { @@ -510,7 +526,9 @@ out: return len; } -static int inet_dccp_listen(struct socket *sock, int backlog) +EXPORT_SYMBOL_GPL(dccp_recvmsg); + +int inet_dccp_listen(struct socket *sock, int backlog) { struct sock *sk = sock->sk; unsigned char old_state; @@ -546,6 +564,8 @@ out: return err; } +EXPORT_SYMBOL_GPL(inet_dccp_listen); + static const unsigned char dccp_new_state[] = { /* current state: new state: action: */ [0] = DCCP_CLOSED, @@ -651,11 +671,15 @@ adjudge_to_death: sock_put(sk); } +EXPORT_SYMBOL_GPL(dccp_close); + void dccp_shutdown(struct sock *sk, int how) { dccp_pr_debug("entry\n"); } +EXPORT_SYMBOL_GPL(dccp_shutdown); + static struct proto_ops inet_dccp_ops = { .family = PF_INET, .owner = THIS_MODULE, @@ -763,6 +787,8 @@ MODULE_PARM_DESC(thash_entries, "Number of ehash buckets"); int dccp_debug; module_param(dccp_debug, int, 0444); MODULE_PARM_DESC(dccp_debug, "Enable debug messages"); + +EXPORT_SYMBOL_GPL(dccp_debug); #endif static int __init dccp_init(void) -- cgit v1.1 From 399c07def62a77678d633f5b3005431423a424a8 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:24:28 -0800 Subject: [IPV6]: Export ipv6_opt_accepted It was already non-TCP specific, will be used by DCCPv6. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/net/ipv6.h | 2 ++ net/ipv6/af_inet6.c | 21 +++++++++++++++++++++ net/ipv6/tcp_ipv6.c | 16 ---------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 0a2ad51..8513761 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -240,6 +240,8 @@ extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_t struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, struct ipv6_txoptions *opt); +extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb); + extern int ip6_frag_nqueues; extern atomic_t ip6_frag_mem; diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 23675ef..bf17aab 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -663,6 +663,27 @@ int inet6_sk_rebuild_header(struct sock *sk) EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header); +int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + struct inet6_skb_parm *opt = IP6CB(skb); + + if (np->rxopt.all) { + if ((opt->hop && (np->rxopt.bits.hopopts || + np->rxopt.bits.ohopopts)) || + ((IPV6_FLOWINFO_MASK & *(u32*)skb->nh.raw) && + np->rxopt.bits.rxflow) || + (opt->srcrt && (np->rxopt.bits.srcrt || + np->rxopt.bits.osrcrt)) || + ((opt->dst1 || opt->dst0) && + (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts))) + return 1; + } + return 0; +} + +EXPORT_SYMBOL_GPL(ipv6_opt_accepted); + int snmp6_mib_init(void *ptr[2], size_t mibsize, size_t mibalign) { diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index cb88007..e5c8a66 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -711,22 +711,6 @@ static struct request_sock_ops tcp6_request_sock_ops = { .send_reset = tcp_v6_send_reset }; -static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) -{ - struct ipv6_pinfo *np = inet6_sk(sk); - struct inet6_skb_parm *opt = IP6CB(skb); - - if (np->rxopt.all) { - if ((opt->hop && (np->rxopt.bits.hopopts || np->rxopt.bits.ohopopts)) || - ((IPV6_FLOWINFO_MASK & *(u32*)skb->nh.raw) && np->rxopt.bits.rxflow) || - (opt->srcrt && (np->rxopt.bits.srcrt || np->rxopt.bits.osrcrt)) || - ((opt->dst1 || opt->dst0) && (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts))) - return 1; - } - return 0; -} - - static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb) { struct ipv6_pinfo *np = inet6_sk(sk); -- cgit v1.1 From 3df80d9320bcaea72b1b4761a319c79cb3fdaf5f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:24:53 -0800 Subject: [DCCP]: Introduce DCCPv6 Still needs mucho polishing, specially in the checksum code, but works just fine, inet_diag/iproute2 and all 8) Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/Makefile | 4 + net/dccp/ipv6.c | 1438 ++++++++++++++++++++++++++++++++++++++++++++++++++ net/dccp/ipv6.h | 37 ++ net/dccp/minisocks.c | 13 +- 4 files changed, 1491 insertions(+), 1 deletion(-) create mode 100644 net/dccp/ipv6.c create mode 100644 net/dccp/ipv6.h diff --git a/net/dccp/Makefile b/net/dccp/Makefile index 344a8da..87b27ff 100644 --- a/net/dccp/Makefile +++ b/net/dccp/Makefile @@ -1,3 +1,7 @@ +obj-$(CONFIG_IPV6) += dccp_ipv6.o + +dccp_ipv6-y := ipv6.o + obj-$(CONFIG_IP_DCCP) += dccp.o dccp-y := ccid.o input.o ipv4.o minisocks.o options.o output.o proto.o \ diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c new file mode 100644 index 0000000..a7d2aee --- /dev/null +++ b/net/dccp/ipv6.c @@ -0,0 +1,1438 @@ +/* + * DCCP over IPv6 + * Linux INET6 implementation + * + * Based on net/dccp6/ipv6.c + * + * Arnaldo Carvalho de Melo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dccp.h" +#include "ipv6.h" + +static void dccp_v6_ctl_send_reset(struct sk_buff *skb); +static void dccp_v6_reqsk_send_ack(struct sk_buff *skb, + struct request_sock *req); +static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb); + +static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb); + +static struct inet_connection_sock_af_ops dccp_ipv6_mapped; +static struct inet_connection_sock_af_ops dccp_ipv6_af_ops; + +static int dccp_v6_get_port(struct sock *sk, unsigned short snum) +{ + return inet_csk_get_port(&dccp_hashinfo, sk, snum, + inet6_csk_bind_conflict); +} + +static void dccp_v6_hash(struct sock *sk) +{ + if (sk->sk_state != DCCP_CLOSED) { + if (inet_csk(sk)->icsk_af_ops == &dccp_ipv6_mapped) { + dccp_prot.hash(sk); + return; + } + local_bh_disable(); + __inet6_hash(&dccp_hashinfo, sk); + local_bh_enable(); + } +} + +static inline u16 dccp_v6_check(struct dccp_hdr *dh, int len, + struct in6_addr *saddr, + struct in6_addr *daddr, + unsigned long base) +{ + return csum_ipv6_magic(saddr, daddr, len, IPPROTO_DCCP, base); +} + +static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb) +{ + const struct dccp_hdr *dh = dccp_hdr(skb); + + if (skb->protocol == htons(ETH_P_IPV6)) + return secure_tcpv6_sequence_number(skb->nh.ipv6h->daddr.s6_addr32, + skb->nh.ipv6h->saddr.s6_addr32, + dh->dccph_dport, + dh->dccph_sport); + else + return secure_dccp_sequence_number(skb->nh.iph->daddr, + skb->nh.iph->saddr, + dh->dccph_dport, + dh->dccph_sport); +} + +static int __dccp_v6_check_established(struct sock *sk, const __u16 lport, + struct inet_timewait_sock **twp) +{ + struct inet_sock *inet = inet_sk(sk); + const struct ipv6_pinfo *np = inet6_sk(sk); + const struct in6_addr *daddr = &np->rcv_saddr; + const struct in6_addr *saddr = &np->daddr; + const int dif = sk->sk_bound_dev_if; + const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); + const unsigned int hash = inet6_ehashfn(daddr, inet->num, + saddr, inet->dport); + struct inet_ehash_bucket *head = inet_ehash_bucket(&dccp_hashinfo, hash); + struct sock *sk2; + const struct hlist_node *node; + struct inet_timewait_sock *tw; + + prefetch(head->chain.first); + write_lock(&head->lock); + + /* Check TIME-WAIT sockets first. */ + sk_for_each(sk2, node, &(head + dccp_hashinfo.ehash_size)->chain) { + const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2); + + tw = inet_twsk(sk2); + + if(*((__u32 *)&(tw->tw_dport)) == ports && + sk2->sk_family == PF_INET6 && + ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && + ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && + sk2->sk_bound_dev_if == sk->sk_bound_dev_if) + goto not_unique; + } + tw = NULL; + + /* And established part... */ + sk_for_each(sk2, node, &head->chain) { + if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif)) + goto not_unique; + } + + BUG_TRAP(sk_unhashed(sk)); + __sk_add_node(sk, &head->chain); + sk->sk_hash = hash; + sock_prot_inc_use(sk->sk_prot); + write_unlock(&head->lock); + + if (twp) { + *twp = tw; + NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); + } else if (tw) { + /* Silly. Should hash-dance instead... */ + inet_twsk_deschedule(tw, &dccp_death_row); + NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); + + inet_twsk_put(tw); + } + return 0; + +not_unique: + write_unlock(&head->lock); + return -EADDRNOTAVAIL; +} + +static inline u32 dccp_v6_port_offset(const struct sock *sk) +{ + const struct inet_sock *inet = inet_sk(sk); + const struct ipv6_pinfo *np = inet6_sk(sk); + + return secure_tcpv6_port_ephemeral(np->rcv_saddr.s6_addr32, + np->daddr.s6_addr32, + inet->dport); +} + +static int dccp_v6_hash_connect(struct sock *sk) +{ + const unsigned short snum = inet_sk(sk)->num; + struct inet_bind_hashbucket *head; + struct inet_bind_bucket *tb; + int ret; + + if (snum == 0) { + int low = sysctl_local_port_range[0]; + int high = sysctl_local_port_range[1]; + int range = high - low; + int i; + int port; + static u32 hint; + u32 offset = hint + dccp_v6_port_offset(sk); + struct hlist_node *node; + struct inet_timewait_sock *tw = NULL; + + local_bh_disable(); + for (i = 1; i <= range; i++) { + port = low + (i + offset) % range; + head = &dccp_hashinfo.bhash[inet_bhashfn(port, + dccp_hashinfo.bhash_size)]; + spin_lock(&head->lock); + + /* Does not bother with rcv_saddr checks, + * because the established check is already + * unique enough. + */ + inet_bind_bucket_for_each(tb, node, &head->chain) { + if (tb->port == port) { + BUG_TRAP(!hlist_empty(&tb->owners)); + if (tb->fastreuse >= 0) + goto next_port; + if (!__dccp_v6_check_established(sk, + port, + &tw)) + goto ok; + goto next_port; + } + } + + tb = inet_bind_bucket_create(dccp_hashinfo.bind_bucket_cachep, + head, port); + if (!tb) { + spin_unlock(&head->lock); + break; + } + tb->fastreuse = -1; + goto ok; + + next_port: + spin_unlock(&head->lock); + } + local_bh_enable(); + + return -EADDRNOTAVAIL; +ok: + hint += i; + + /* Head lock still held and bh's disabled */ + inet_bind_hash(sk, tb, port); + if (sk_unhashed(sk)) { + inet_sk(sk)->sport = htons(port); + __inet6_hash(&dccp_hashinfo, sk); + } + spin_unlock(&head->lock); + + if (tw) { + inet_twsk_deschedule(tw, &dccp_death_row); + inet_twsk_put(tw); + } + + ret = 0; + goto out; + } + + head = &dccp_hashinfo.bhash[inet_bhashfn(snum, + dccp_hashinfo.bhash_size)]; + tb = inet_csk(sk)->icsk_bind_hash; + spin_lock_bh(&head->lock); + + if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { + __inet6_hash(&dccp_hashinfo, sk); + spin_unlock_bh(&head->lock); + return 0; + } else { + spin_unlock(&head->lock); + /* No definite answer... Walk to established hash table */ + ret = __dccp_v6_check_established(sk, snum, NULL); +out: + local_bh_enable(); + return ret; + } +} + +static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, + int addr_len) +{ + struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; + struct inet_sock *inet = inet_sk(sk); + struct ipv6_pinfo *np = inet6_sk(sk); + struct dccp_sock *dp = dccp_sk(sk); + struct in6_addr *saddr = NULL, *final_p = NULL, final; + struct flowi fl; + struct dst_entry *dst; + int addr_type; + int err; + + dp->dccps_role = DCCP_ROLE_CLIENT; + + if (addr_len < SIN6_LEN_RFC2133) + return -EINVAL; + + if (usin->sin6_family != AF_INET6) + return -EAFNOSUPPORT; + + memset(&fl, 0, sizeof(fl)); + + if (np->sndflow) { + fl.fl6_flowlabel = usin->sin6_flowinfo & IPV6_FLOWINFO_MASK; + IP6_ECN_flow_init(fl.fl6_flowlabel); + if (fl.fl6_flowlabel & IPV6_FLOWLABEL_MASK) { + struct ip6_flowlabel *flowlabel; + flowlabel = fl6_sock_lookup(sk, fl.fl6_flowlabel); + if (flowlabel == NULL) + return -EINVAL; + ipv6_addr_copy(&usin->sin6_addr, &flowlabel->dst); + fl6_sock_release(flowlabel); + } + } + + /* + * connect() to INADDR_ANY means loopback (BSD'ism). + */ + + if (ipv6_addr_any(&usin->sin6_addr)) + usin->sin6_addr.s6_addr[15] = 0x1; + + addr_type = ipv6_addr_type(&usin->sin6_addr); + + if(addr_type & IPV6_ADDR_MULTICAST) + return -ENETUNREACH; + + if (addr_type & IPV6_ADDR_LINKLOCAL) { + if (addr_len >= sizeof(struct sockaddr_in6) && + usin->sin6_scope_id) { + /* If interface is set while binding, indices + * must coincide. + */ + if (sk->sk_bound_dev_if && + sk->sk_bound_dev_if != usin->sin6_scope_id) + return -EINVAL; + + sk->sk_bound_dev_if = usin->sin6_scope_id; + } + + /* Connect to link-local address requires an interface */ + if (!sk->sk_bound_dev_if) + return -EINVAL; + } + + ipv6_addr_copy(&np->daddr, &usin->sin6_addr); + np->flow_label = fl.fl6_flowlabel; + + /* + * DCCP over IPv4 + */ + + if (addr_type == IPV6_ADDR_MAPPED) { + u32 exthdrlen = dp->dccps_ext_header_len; + struct sockaddr_in sin; + + SOCK_DEBUG(sk, "connect: ipv4 mapped\n"); + + if (__ipv6_only_sock(sk)) + return -ENETUNREACH; + + sin.sin_family = AF_INET; + sin.sin_port = usin->sin6_port; + sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3]; + + inet_csk(sk)->icsk_af_ops = &dccp_ipv6_mapped; + sk->sk_backlog_rcv = dccp_v4_do_rcv; + + err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); + + if (err) { + dp->dccps_ext_header_len = exthdrlen; + inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops; + sk->sk_backlog_rcv = dccp_v6_do_rcv; + goto failure; + } else { + ipv6_addr_set(&np->saddr, 0, 0, htonl(0x0000FFFF), + inet->saddr); + ipv6_addr_set(&np->rcv_saddr, 0, 0, htonl(0x0000FFFF), + inet->rcv_saddr); + } + + return err; + } + + if (!ipv6_addr_any(&np->rcv_saddr)) + saddr = &np->rcv_saddr; + + fl.proto = IPPROTO_DCCP; + ipv6_addr_copy(&fl.fl6_dst, &np->daddr); + ipv6_addr_copy(&fl.fl6_src, saddr ? saddr : &np->saddr); + fl.oif = sk->sk_bound_dev_if; + fl.fl_ip_dport = usin->sin6_port; + fl.fl_ip_sport = inet->sport; + + if (np->opt && np->opt->srcrt) { + struct rt0_hdr *rt0 = (struct rt0_hdr *)np->opt->srcrt; + ipv6_addr_copy(&final, &fl.fl6_dst); + ipv6_addr_copy(&fl.fl6_dst, rt0->addr); + final_p = &final; + } + + err = ip6_dst_lookup(sk, &dst, &fl); + if (err) + goto failure; + if (final_p) + ipv6_addr_copy(&fl.fl6_dst, final_p); + + if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) + goto failure; + + if (saddr == NULL) { + saddr = &fl.fl6_src; + ipv6_addr_copy(&np->rcv_saddr, saddr); + } + + /* set the source address */ + ipv6_addr_copy(&np->saddr, saddr); + inet->rcv_saddr = LOOPBACK4_IPV6; + + ip6_dst_store(sk, dst, NULL); + + dp->dccps_ext_header_len = 0; + if (np->opt) + dp->dccps_ext_header_len = np->opt->opt_flen + np->opt->opt_nflen; + + inet->dport = usin->sin6_port; + + dccp_set_state(sk, DCCP_REQUESTING); + err = dccp_v6_hash_connect(sk); + if (err) + goto late_failure; + /* FIXME */ +#if 0 + dp->dccps_gar = secure_dccp_v6_sequence_number(np->saddr.s6_addr32, + np->daddr.s6_addr32, + inet->sport, + inet->dport); +#endif + err = dccp_connect(sk); + if (err) + goto late_failure; + + return 0; + +late_failure: + dccp_set_state(sk, DCCP_CLOSED); + __sk_dst_reset(sk); +failure: + inet->dport = 0; + sk->sk_route_caps = 0; + return err; +} + +static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, + int type, int code, int offset, __u32 info) +{ + struct ipv6hdr *hdr = (struct ipv6hdr *)skb->data; + const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset); + struct ipv6_pinfo *np; + struct sock *sk; + int err; + __u64 seq; + + sk = inet6_lookup(&dccp_hashinfo, &hdr->daddr, dh->dccph_dport, + &hdr->saddr, dh->dccph_sport, skb->dev->ifindex); + + if (sk == NULL) { + ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS); + return; + } + + if (sk->sk_state == DCCP_TIME_WAIT) { + inet_twsk_put((struct inet_timewait_sock *)sk); + return; + } + + bh_lock_sock(sk); + if (sock_owned_by_user(sk)) + NET_INC_STATS_BH(LINUX_MIB_LOCKDROPPEDICMPS); + + if (sk->sk_state == DCCP_CLOSED) + goto out; + + np = inet6_sk(sk); + + if (type == ICMPV6_PKT_TOOBIG) { + struct dccp_sock *dp = dccp_sk(sk); + struct dst_entry *dst = NULL; + + if (sock_owned_by_user(sk)) + goto out; + if ((1 << sk->sk_state) & (DCCPF_LISTEN | DCCPF_CLOSED)) + goto out; + + /* icmp should have updated the destination cache entry */ + dst = __sk_dst_check(sk, np->dst_cookie); + + if (dst == NULL) { + struct inet_sock *inet = inet_sk(sk); + struct flowi fl; + + /* BUGGG_FUTURE: Again, it is not clear how + to handle rthdr case. Ignore this complexity + for now. + */ + memset(&fl, 0, sizeof(fl)); + fl.proto = IPPROTO_DCCP; + ipv6_addr_copy(&fl.fl6_dst, &np->daddr); + ipv6_addr_copy(&fl.fl6_src, &np->saddr); + fl.oif = sk->sk_bound_dev_if; + fl.fl_ip_dport = inet->dport; + fl.fl_ip_sport = inet->sport; + + if ((err = ip6_dst_lookup(sk, &dst, &fl))) { + sk->sk_err_soft = -err; + goto out; + } + + if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) { + sk->sk_err_soft = -err; + goto out; + } + + } else + dst_hold(dst); + + if (dp->dccps_pmtu_cookie > dst_mtu(dst)) { + dccp_sync_mss(sk, dst_mtu(dst)); + } /* else let the usual retransmit timer handle it */ + dst_release(dst); + goto out; + } + + icmpv6_err_convert(type, code, &err); + + seq = DCCP_SKB_CB(skb)->dccpd_seq; + /* Might be for an request_sock */ + switch (sk->sk_state) { + struct request_sock *req, **prev; + case DCCP_LISTEN: + if (sock_owned_by_user(sk)) + goto out; + + req = inet6_csk_search_req(sk, &prev, dh->dccph_dport, + &hdr->daddr, &hdr->saddr, + inet6_iif(skb)); + if (!req) + goto out; + + /* ICMPs are not backlogged, hence we cannot get + * an established socket here. + */ + BUG_TRAP(req->sk == NULL); + + if (seq != dccp_rsk(req)->dreq_iss) { + NET_INC_STATS_BH(LINUX_MIB_OUTOFWINDOWICMPS); + goto out; + } + + inet_csk_reqsk_queue_drop(sk, req, prev); + goto out; + + case DCCP_REQUESTING: + case DCCP_RESPOND: /* Cannot happen. + It can, it SYNs are crossed. --ANK */ + if (!sock_owned_by_user(sk)) { + DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS); + sk->sk_err = err; + /* + * Wake people up to see the error + * (see connect in sock.c) + */ + sk->sk_error_report(sk); + + dccp_done(sk); + } else + sk->sk_err_soft = err; + goto out; + } + + if (!sock_owned_by_user(sk) && np->recverr) { + sk->sk_err = err; + sk->sk_error_report(sk); + } else + sk->sk_err_soft = err; + +out: + bh_unlock_sock(sk); + sock_put(sk); +} + + +static int dccp_v6_send_response(struct sock *sk, struct request_sock *req, + struct dst_entry *dst) +{ + struct inet6_request_sock *ireq6 = inet6_rsk(req); + struct ipv6_pinfo *np = inet6_sk(sk); + struct sk_buff *skb; + struct ipv6_txoptions *opt = NULL; + struct in6_addr *final_p = NULL, final; + struct flowi fl; + int err = -1; + + memset(&fl, 0, sizeof(fl)); + fl.proto = IPPROTO_DCCP; + ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr); + ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr); + fl.fl6_flowlabel = 0; + fl.oif = ireq6->iif; + fl.fl_ip_dport = inet_rsk(req)->rmt_port; + fl.fl_ip_sport = inet_sk(sk)->sport; + + if (dst == NULL) { + opt = np->opt; + if (opt == NULL && + np->rxopt.bits.osrcrt == 2 && + ireq6->pktopts) { + struct sk_buff *pktopts = ireq6->pktopts; + struct inet6_skb_parm *rxopt = IP6CB(pktopts); + if (rxopt->srcrt) + opt = ipv6_invert_rthdr(sk, + (struct ipv6_rt_hdr *)(pktopts->nh.raw + + rxopt->srcrt)); + } + + if (opt && opt->srcrt) { + struct rt0_hdr *rt0 = (struct rt0_hdr *)opt->srcrt; + ipv6_addr_copy(&final, &fl.fl6_dst); + ipv6_addr_copy(&fl.fl6_dst, rt0->addr); + final_p = &final; + } + + err = ip6_dst_lookup(sk, &dst, &fl); + if (err) + goto done; + if (final_p) + ipv6_addr_copy(&fl.fl6_dst, final_p); + if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) + goto done; + } + + skb = dccp_make_response(sk, dst, req); + if (skb != NULL) { + struct dccp_hdr *dh = dccp_hdr(skb); + dh->dccph_checksum = dccp_v6_check(dh, skb->len, + &ireq6->loc_addr, + &ireq6->rmt_addr, + csum_partial((char *)dh, + skb->len, + skb->csum)); + ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr); + err = ip6_xmit(sk, skb, &fl, opt, 0); + if (err == NET_XMIT_CN) + err = 0; + } + +done: + if (opt && opt != np->opt) + sock_kfree_s(sk, opt, opt->tot_len); + return err; +} + +static void dccp_v6_reqsk_destructor(struct request_sock *req) +{ + if (inet6_rsk(req)->pktopts != NULL) + kfree_skb(inet6_rsk(req)->pktopts); +} + +static struct request_sock_ops dccp6_request_sock_ops = { + .family = AF_INET6, + .obj_size = sizeof(struct dccp6_request_sock), + .rtx_syn_ack = dccp_v6_send_response, + .send_ack = dccp_v6_reqsk_send_ack, + .destructor = dccp_v6_reqsk_destructor, + .send_reset = dccp_v6_ctl_send_reset, +}; + +static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + struct dccp_hdr *dh = dccp_hdr(skb); + + dh->dccph_checksum = csum_ipv6_magic(&np->saddr, &np->daddr, + len, IPPROTO_DCCP, + csum_partial((char *)dh, + dh->dccph_doff << 2, + skb->csum)); +} + +static void dccp_v6_ctl_send_reset(struct sk_buff *rxskb) +{ + struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh; + const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) + + sizeof(struct dccp_hdr_ext) + + sizeof(struct dccp_hdr_reset); + struct sk_buff *skb; + struct flowi fl; + u64 seqno; + + if (rxdh->dccph_type == DCCP_PKT_RESET) + return; + + if (!ipv6_unicast_destination(rxskb)) + return; + + /* + * We need to grab some memory, and put together an RST, + * and then put it into the queue to be sent. + */ + + skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + + dccp_hdr_reset_len, GFP_ATOMIC); + if (skb == NULL) + return; + + skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) + + dccp_hdr_reset_len); + + skb->h.raw = skb_push(skb, dccp_hdr_reset_len); + dh = dccp_hdr(skb); + memset(dh, 0, dccp_hdr_reset_len); + + /* Swap the send and the receive. */ + dh->dccph_type = DCCP_PKT_RESET; + dh->dccph_sport = rxdh->dccph_dport; + dh->dccph_dport = rxdh->dccph_sport; + dh->dccph_doff = dccp_hdr_reset_len / 4; + dh->dccph_x = 1; + dccp_hdr_reset(skb)->dccph_reset_code = + DCCP_SKB_CB(rxskb)->dccpd_reset_code; + + /* See "8.3.1. Abnormal Termination" in draft-ietf-dccp-spec-11 */ + seqno = 0; + if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) + dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1); + + dccp_hdr_set_seq(dh, seqno); + dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), + DCCP_SKB_CB(rxskb)->dccpd_seq); + + memset(&fl, 0, sizeof(fl)); + ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr); + ipv6_addr_copy(&fl.fl6_src, &rxskb->nh.ipv6h->daddr); + dh->dccph_checksum = csum_ipv6_magic(&fl.fl6_src, &fl.fl6_dst, + sizeof(*dh), IPPROTO_DCCP, + skb->csum); + fl.proto = IPPROTO_DCCP; + fl.oif = inet6_iif(rxskb); + fl.fl_ip_dport = dh->dccph_dport; + fl.fl_ip_sport = dh->dccph_sport; + + /* sk = NULL, but it is safe for now. RST socket required. */ + if (!ip6_dst_lookup(NULL, &skb->dst, &fl)) { + if (xfrm_lookup(&skb->dst, &fl, NULL, 0) >= 0) { + ip6_xmit(NULL, skb, &fl, NULL, 0); + DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS); + DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS); + return; + } + } + + kfree_skb(skb); +} + +static void dccp_v6_ctl_send_ack(struct sk_buff *rxskb) +{ + struct flowi fl; + struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh; + const int dccp_hdr_ack_len = sizeof(struct dccp_hdr) + + sizeof(struct dccp_hdr_ext) + + sizeof(struct dccp_hdr_ack_bits); + struct sk_buff *skb; + + skb = alloc_skb(MAX_HEADER + sizeof(struct ipv6hdr) + + dccp_hdr_ack_len, GFP_ATOMIC); + if (skb == NULL) + return; + + skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr) + + dccp_hdr_ack_len); + + skb->h.raw = skb_push(skb, dccp_hdr_ack_len); + dh = dccp_hdr(skb); + memset(dh, 0, dccp_hdr_ack_len); + + /* Build DCCP header and checksum it. */ + dh->dccph_type = DCCP_PKT_ACK; + dh->dccph_sport = rxdh->dccph_dport; + dh->dccph_dport = rxdh->dccph_sport; + dh->dccph_doff = dccp_hdr_ack_len / 4; + dh->dccph_x = 1; + + dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq); + dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), + DCCP_SKB_CB(rxskb)->dccpd_seq); + + memset(&fl, 0, sizeof(fl)); + ipv6_addr_copy(&fl.fl6_dst, &rxskb->nh.ipv6h->saddr); + ipv6_addr_copy(&fl.fl6_src, &rxskb->nh.ipv6h->daddr); + + /* FIXME: calculate checksum, IPv4 also should... */ + + fl.proto = IPPROTO_DCCP; + fl.oif = inet6_iif(rxskb); + fl.fl_ip_dport = dh->dccph_dport; + fl.fl_ip_sport = dh->dccph_sport; + + if (!ip6_dst_lookup(NULL, &skb->dst, &fl)) { + if (xfrm_lookup(&skb->dst, &fl, NULL, 0) >= 0) { + ip6_xmit(NULL, skb, &fl, NULL, 0); + DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS); + return; + } + } + + kfree_skb(skb); +} + +static void dccp_v6_reqsk_send_ack(struct sk_buff *skb, + struct request_sock *req) +{ + dccp_v6_ctl_send_ack(skb); +} + +static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) +{ + const struct dccp_hdr *dh = dccp_hdr(skb); + const struct ipv6hdr *iph = skb->nh.ipv6h; + struct sock *nsk; + struct request_sock **prev; + /* Find possible connection requests. */ + struct request_sock *req = inet6_csk_search_req(sk, &prev, + dh->dccph_sport, + &iph->saddr, + &iph->daddr, + inet6_iif(skb)); + if (req != NULL) + return dccp_check_req(sk, skb, req, prev); + + nsk = __inet6_lookup_established(&dccp_hashinfo, + &iph->saddr, dh->dccph_sport, + &iph->daddr, ntohs(dh->dccph_dport), + inet6_iif(skb)); + + if (nsk != NULL) { + if (nsk->sk_state != DCCP_TIME_WAIT) { + bh_lock_sock(nsk); + return nsk; + } + inet_twsk_put((struct inet_timewait_sock *)nsk); + return NULL; + } + + return sk; +} + +static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) +{ + struct inet_request_sock *ireq; + struct dccp_sock dp; + struct request_sock *req; + struct dccp_request_sock *dreq; + struct inet6_request_sock *ireq6; + struct ipv6_pinfo *np = inet6_sk(sk); + const __u32 service = dccp_hdr_request(skb)->dccph_req_service; + struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb); + __u8 reset_code = DCCP_RESET_CODE_TOO_BUSY; + + if (skb->protocol == htons(ETH_P_IP)) + return dccp_v4_conn_request(sk, skb); + + if (!ipv6_unicast_destination(skb)) + goto drop; + + if (dccp_bad_service_code(sk, service)) { + reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE; + goto drop; + } + /* + * There are no SYN attacks on IPv6, yet... + */ + if (inet_csk_reqsk_queue_is_full(sk)) + goto drop; + + if (sk_acceptq_is_full(sk) && inet_csk_reqsk_queue_young(sk) > 1) + goto drop; + + req = inet6_reqsk_alloc(sk->sk_prot->rsk_prot); + if (req == NULL) + goto drop; + + /* FIXME: process options */ + + dccp_openreq_init(req, &dp, skb); + + ireq6 = inet6_rsk(req); + ireq = inet_rsk(req); + ipv6_addr_copy(&ireq6->rmt_addr, &skb->nh.ipv6h->saddr); + ipv6_addr_copy(&ireq6->loc_addr, &skb->nh.ipv6h->daddr); + req->rcv_wnd = 100; /* Fake, option parsing will get the + right value */ + ireq6->pktopts = NULL; + + if (ipv6_opt_accepted(sk, skb) || + np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo || + np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) { + atomic_inc(&skb->users); + ireq6->pktopts = skb; + } + ireq6->iif = sk->sk_bound_dev_if; + + /* So that link locals have meaning */ + if (!sk->sk_bound_dev_if && + ipv6_addr_type(&ireq6->rmt_addr) & IPV6_ADDR_LINKLOCAL) + ireq6->iif = inet6_iif(skb); + + /* + * Step 3: Process LISTEN state + * + * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie + * + * In fact we defer setting S.GSR, S.SWL, S.SWH to + * dccp_create_openreq_child. + */ + dreq = dccp_rsk(req); + dreq->dreq_isr = dcb->dccpd_seq; + dreq->dreq_iss = dccp_v6_init_sequence(sk, skb); + dreq->dreq_service = service; + + if (dccp_v6_send_response(sk, req, NULL)) + goto drop_and_free; + + inet6_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT); + return 0; + +drop_and_free: + reqsk_free(req); +drop: + DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS); + dcb->dccpd_reset_code = reset_code; + return -1; +} + +static struct sock *dccp_v6_request_recv_sock(struct sock *sk, + struct sk_buff *skb, + struct request_sock *req, + struct dst_entry *dst) +{ + struct inet6_request_sock *ireq6 = inet6_rsk(req); + struct ipv6_pinfo *newnp, *np = inet6_sk(sk); + struct inet_sock *newinet; + struct dccp_sock *newdp; + struct dccp6_sock *newdp6; + struct sock *newsk; + struct ipv6_txoptions *opt; + + if (skb->protocol == htons(ETH_P_IP)) { + /* + * v6 mapped + */ + + newsk = dccp_v4_request_recv_sock(sk, skb, req, dst); + if (newsk == NULL) + return NULL; + + newdp6 = (struct dccp6_sock *)newsk; + newdp = dccp_sk(newsk); + newinet = inet_sk(newsk); + newinet->pinet6 = &newdp6->inet6; + newnp = inet6_sk(newsk); + + memcpy(newnp, np, sizeof(struct ipv6_pinfo)); + + ipv6_addr_set(&newnp->daddr, 0, 0, htonl(0x0000FFFF), + newinet->daddr); + + ipv6_addr_set(&newnp->saddr, 0, 0, htonl(0x0000FFFF), + newinet->saddr); + + ipv6_addr_copy(&newnp->rcv_saddr, &newnp->saddr); + + inet_csk(newsk)->icsk_af_ops = &dccp_ipv6_mapped; + newsk->sk_backlog_rcv = dccp_v4_do_rcv; + newnp->pktoptions = NULL; + newnp->opt = NULL; + newnp->mcast_oif = inet6_iif(skb); + newnp->mcast_hops = skb->nh.ipv6h->hop_limit; + + /* + * No need to charge this sock to the relevant IPv6 refcnt debug socks count + * here, dccp_create_openreq_child now does this for us, see the comment in + * that function for the gory details. -acme + */ + + /* It is tricky place. Until this moment IPv4 tcp + worked with IPv6 icsk.icsk_af_ops. + Sync it now. + */ + dccp_sync_mss(newsk, newdp->dccps_pmtu_cookie); + + return newsk; + } + + opt = np->opt; + + if (sk_acceptq_is_full(sk)) + goto out_overflow; + + if (np->rxopt.bits.osrcrt == 2 && + opt == NULL && ireq6->pktopts) { + struct inet6_skb_parm *rxopt = IP6CB(ireq6->pktopts); + if (rxopt->srcrt) + opt = ipv6_invert_rthdr(sk, + (struct ipv6_rt_hdr *)(ireq6->pktopts->nh.raw + + rxopt->srcrt)); + } + + if (dst == NULL) { + struct in6_addr *final_p = NULL, final; + struct flowi fl; + + memset(&fl, 0, sizeof(fl)); + fl.proto = IPPROTO_DCCP; + ipv6_addr_copy(&fl.fl6_dst, &ireq6->rmt_addr); + if (opt && opt->srcrt) { + struct rt0_hdr *rt0 = (struct rt0_hdr *) opt->srcrt; + ipv6_addr_copy(&final, &fl.fl6_dst); + ipv6_addr_copy(&fl.fl6_dst, rt0->addr); + final_p = &final; + } + ipv6_addr_copy(&fl.fl6_src, &ireq6->loc_addr); + fl.oif = sk->sk_bound_dev_if; + fl.fl_ip_dport = inet_rsk(req)->rmt_port; + fl.fl_ip_sport = inet_sk(sk)->sport; + + if (ip6_dst_lookup(sk, &dst, &fl)) + goto out; + + if (final_p) + ipv6_addr_copy(&fl.fl6_dst, final_p); + + if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0) + goto out; + } + + newsk = dccp_create_openreq_child(sk, req, skb); + if (newsk == NULL) + goto out; + + /* + * No need to charge this sock to the relevant IPv6 refcnt debug socks + * count here, dccp_create_openreq_child now does this for us, see the + * comment in that function for the gory details. -acme + */ + + ip6_dst_store(newsk, dst, NULL); + newsk->sk_route_caps = dst->dev->features & + ~(NETIF_F_IP_CSUM | NETIF_F_TSO); + + newdp6 = (struct dccp6_sock *)newsk; + newinet = inet_sk(newsk); + newinet->pinet6 = &newdp6->inet6; + newdp = dccp_sk(newsk); + newnp = inet6_sk(newsk); + + memcpy(newnp, np, sizeof(struct ipv6_pinfo)); + + ipv6_addr_copy(&newnp->daddr, &ireq6->rmt_addr); + ipv6_addr_copy(&newnp->saddr, &ireq6->loc_addr); + ipv6_addr_copy(&newnp->rcv_saddr, &ireq6->loc_addr); + newsk->sk_bound_dev_if = ireq6->iif; + + /* Now IPv6 options... + + First: no IPv4 options. + */ + newinet->opt = NULL; + + /* Clone RX bits */ + newnp->rxopt.all = np->rxopt.all; + + /* Clone pktoptions received with SYN */ + newnp->pktoptions = NULL; + if (ireq6->pktopts != NULL) { + newnp->pktoptions = skb_clone(ireq6->pktopts, GFP_ATOMIC); + kfree_skb(ireq6->pktopts); + ireq6->pktopts = NULL; + if (newnp->pktoptions) + skb_set_owner_r(newnp->pktoptions, newsk); + } + newnp->opt = NULL; + newnp->mcast_oif = inet6_iif(skb); + newnp->mcast_hops = skb->nh.ipv6h->hop_limit; + + /* Clone native IPv6 options from listening socket (if any) + + Yes, keeping reference count would be much more clever, + but we make one more one thing there: reattach optmem + to newsk. + */ + if (opt) { + newnp->opt = ipv6_dup_options(newsk, opt); + if (opt != np->opt) + sock_kfree_s(sk, opt, opt->tot_len); + } + + newdp->dccps_ext_header_len = 0; + if (newnp->opt) + newdp->dccps_ext_header_len = newnp->opt->opt_nflen + + newnp->opt->opt_flen; + + dccp_sync_mss(newsk, dst_mtu(dst)); + + newinet->daddr = newinet->saddr = newinet->rcv_saddr = LOOPBACK4_IPV6; + + __inet6_hash(&dccp_hashinfo, newsk); + inet_inherit_port(&dccp_hashinfo, sk, newsk); + + return newsk; + +out_overflow: + NET_INC_STATS_BH(LINUX_MIB_LISTENOVERFLOWS); +out: + NET_INC_STATS_BH(LINUX_MIB_LISTENDROPS); + if (opt && opt != np->opt) + sock_kfree_s(sk, opt, opt->tot_len); + dst_release(dst); + return NULL; +} + +/* The socket must have it's spinlock held when we get + * here. + * + * We have a potential double-lock case here, so even when + * doing backlog processing we use the BH locking scheme. + * This is because we cannot sleep with the original spinlock + * held. + */ +static int dccp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) +{ + struct ipv6_pinfo *np = inet6_sk(sk); + struct sk_buff *opt_skb = NULL; + + /* Imagine: socket is IPv6. IPv4 packet arrives, + goes to IPv4 receive handler and backlogged. + From backlog it always goes here. Kerboom... + Fortunately, dccp_rcv_established and rcv_established + handle them correctly, but it is not case with + dccp_v6_hnd_req and dccp_v6_ctl_send_reset(). --ANK + */ + + if (skb->protocol == htons(ETH_P_IP)) + return dccp_v4_do_rcv(sk, skb); + + if (sk_filter(sk, skb, 0)) + goto discard; + + /* + * socket locking is here for SMP purposes as backlog rcv + * is currently called with bh processing disabled. + */ + + /* Do Stevens' IPV6_PKTOPTIONS. + + Yes, guys, it is the only place in our code, where we + may make it not affecting IPv4. + The rest of code is protocol independent, + and I do not like idea to uglify IPv4. + + Actually, all the idea behind IPV6_PKTOPTIONS + looks not very well thought. For now we latch + options, received in the last packet, enqueued + by tcp. Feel free to propose better solution. + --ANK (980728) + */ + if (np->rxopt.all) + opt_skb = skb_clone(skb, GFP_ATOMIC); + + if (sk->sk_state == DCCP_OPEN) { /* Fast path */ + if (dccp_rcv_established(sk, skb, dccp_hdr(skb), skb->len)) + goto reset; + return 0; + } + + if (sk->sk_state == DCCP_LISTEN) { + struct sock *nsk = dccp_v6_hnd_req(sk, skb); + if (!nsk) + goto discard; + + /* + * Queue it on the new socket if the new socket is active, + * otherwise we just shortcircuit this and continue with + * the new socket.. + */ + if(nsk != sk) { + if (dccp_child_process(sk, nsk, skb)) + goto reset; + if (opt_skb) + __kfree_skb(opt_skb); + return 0; + } + } + + if (dccp_rcv_state_process(sk, skb, dccp_hdr(skb), skb->len)) + goto reset; + return 0; + +reset: + dccp_v6_ctl_send_reset(skb); +discard: + if (opt_skb) + __kfree_skb(opt_skb); + kfree_skb(skb); + return 0; +} + +static int dccp_v6_rcv(struct sk_buff **pskb, unsigned int *nhoffp) +{ + const struct dccp_hdr *dh; + struct sk_buff *skb = *pskb; + struct sock *sk; + int rc; + + /* Step 1: Check header basics: */ + + if (dccp_invalid_packet(skb)) + goto discard_it; + + dh = dccp_hdr(skb); + + DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb); + DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type; + + if (dccp_packet_without_ack(skb)) + DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ; + else + DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb); + + /* Step 2: + * Look up flow ID in table and get corresponding socket */ + sk = __inet6_lookup(&dccp_hashinfo, &skb->nh.ipv6h->saddr, + dh->dccph_sport, + &skb->nh.ipv6h->daddr, ntohs(dh->dccph_dport), + inet6_iif(skb)); + /* + * Step 2: + * If no socket ... + * Generate Reset(No Connection) unless P.type == Reset + * Drop packet and return + */ + if (sk == NULL) + goto no_dccp_socket; + + /* + * Step 2: + * ... or S.state == TIMEWAIT, + * Generate Reset(No Connection) unless P.type == Reset + * Drop packet and return + */ + + if (sk->sk_state == DCCP_TIME_WAIT) + goto do_time_wait; + + if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) + goto discard_and_relse; + + if (sk_filter(sk, skb, 0)) + goto discard_and_relse; + + skb->dev = NULL; + + bh_lock_sock(sk); + rc = 0; + if (!sock_owned_by_user(sk)) + rc = dccp_v6_do_rcv(sk, skb); + else + sk_add_backlog(sk, skb); + bh_unlock_sock(sk); + + sock_put(sk); + return rc ? -1 : 0; + +no_dccp_socket: + if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) + goto discard_it; + /* + * Step 2: + * Generate Reset(No Connection) unless P.type == Reset + * Drop packet and return + */ + if (dh->dccph_type != DCCP_PKT_RESET) { + DCCP_SKB_CB(skb)->dccpd_reset_code = + DCCP_RESET_CODE_NO_CONNECTION; + dccp_v6_ctl_send_reset(skb); + } +discard_it: + + /* + * Discard frame + */ + + kfree_skb(skb); + return 0; + +discard_and_relse: + sock_put(sk); + goto discard_it; + +do_time_wait: + inet_twsk_put((struct inet_timewait_sock *)sk); + goto no_dccp_socket; +} + +static struct inet_connection_sock_af_ops dccp_ipv6_af_ops = { + .queue_xmit = inet6_csk_xmit, + .send_check = dccp_v6_send_check, + .rebuild_header = inet6_sk_rebuild_header, + .conn_request = dccp_v6_conn_request, + .syn_recv_sock = dccp_v6_request_recv_sock, + .net_header_len = sizeof(struct ipv6hdr), + .setsockopt = ipv6_setsockopt, + .getsockopt = ipv6_getsockopt, + .addr2sockaddr = inet6_csk_addr2sockaddr, + .sockaddr_len = sizeof(struct sockaddr_in6) +}; + +/* + * DCCP over IPv4 via INET6 API + */ +static struct inet_connection_sock_af_ops dccp_ipv6_mapped = { + .queue_xmit = ip_queue_xmit, + .send_check = dccp_v4_send_check, + .rebuild_header = inet_sk_rebuild_header, + .conn_request = dccp_v6_conn_request, + .syn_recv_sock = dccp_v6_request_recv_sock, + .net_header_len = sizeof(struct iphdr), + .setsockopt = ipv6_setsockopt, + .getsockopt = ipv6_getsockopt, + .addr2sockaddr = inet6_csk_addr2sockaddr, + .sockaddr_len = sizeof(struct sockaddr_in6) +}; + +/* NOTE: A lot of things set to zero explicitly by call to + * sk_alloc() so need not be done here. + */ +static int dccp_v6_init_sock(struct sock *sk) +{ + int err = dccp_v4_init_sock(sk); + + if (err == 0) + inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops; + + return err; +} + +static int dccp_v6_destroy_sock(struct sock *sk) +{ + dccp_v4_destroy_sock(sk); + return inet6_destroy_sock(sk); +} + +static struct proto dccp_v6_prot = { + .name = "DCCPv6", + .owner = THIS_MODULE, + .close = dccp_close, + .connect = dccp_v6_connect, + .disconnect = dccp_disconnect, + .ioctl = dccp_ioctl, + .init = dccp_v6_init_sock, + .setsockopt = dccp_setsockopt, + .getsockopt = dccp_getsockopt, + .sendmsg = dccp_sendmsg, + .recvmsg = dccp_recvmsg, + .backlog_rcv = dccp_v6_do_rcv, + .hash = dccp_v6_hash, + .unhash = dccp_unhash, + .accept = inet_csk_accept, + .get_port = dccp_v6_get_port, + .shutdown = dccp_shutdown, + .destroy = dccp_v6_destroy_sock, + .orphan_count = &dccp_orphan_count, + .max_header = MAX_DCCP_HEADER, + .obj_size = sizeof(struct dccp6_sock), + .rsk_prot = &dccp6_request_sock_ops, + .twsk_obj_size = sizeof(struct dccp6_timewait_sock), +}; + +static struct inet6_protocol dccp_v6_protocol = { + .handler = dccp_v6_rcv, + .err_handler = dccp_v6_err, + .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, +}; + +static struct proto_ops inet6_dccp_ops = { + .family = PF_INET6, + .owner = THIS_MODULE, + .release = inet6_release, + .bind = inet6_bind, + .connect = inet_stream_connect, + .socketpair = sock_no_socketpair, + .accept = inet_accept, + .getname = inet6_getname, + .poll = dccp_poll, + .ioctl = inet6_ioctl, + .listen = inet_dccp_listen, + .shutdown = inet_shutdown, + .setsockopt = sock_common_setsockopt, + .getsockopt = sock_common_getsockopt, + .sendmsg = inet_sendmsg, + .recvmsg = sock_common_recvmsg, + .mmap = sock_no_mmap, + .sendpage = sock_no_sendpage, +}; + +static struct inet_protosw dccp_v6_protosw = { + .type = SOCK_DCCP, + .protocol = IPPROTO_DCCP, + .prot = &dccp_v6_prot, + .ops = &inet6_dccp_ops, + .capability = -1, +}; + +static int __init dccp_v6_init(void) +{ + int err = proto_register(&dccp_v6_prot, 1); + + if (err != 0) + goto out; + + err = inet6_add_protocol(&dccp_v6_protocol, IPPROTO_DCCP); + if (err != 0) + goto out_unregister_proto; + + inet6_register_protosw(&dccp_v6_protosw); +out: + return err; +out_unregister_proto: + proto_unregister(&dccp_v6_prot); + goto out; +} + +static void __exit dccp_v6_exit(void) +{ + inet6_del_protocol(&dccp_v6_protocol, IPPROTO_DCCP); + inet6_unregister_protosw(&dccp_v6_protosw); + proto_unregister(&dccp_v6_prot); +} + +module_init(dccp_v6_init); +module_exit(dccp_v6_exit); + +/* + * __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33) + * values directly, Also cover the case where the protocol is not specified, + * i.e. net-pf-PF_INET6-proto-0-type-SOCK_DCCP + */ +MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-33-type-6"); +MODULE_ALIAS("net-pf-" __stringify(PF_INET6) "-proto-0-type-6"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Arnaldo Carvalho de Melo "); +MODULE_DESCRIPTION("DCCPv6 - Datagram Congestion Controlled Protocol"); diff --git a/net/dccp/ipv6.h b/net/dccp/ipv6.h new file mode 100644 index 0000000..e4d4e93 --- /dev/null +++ b/net/dccp/ipv6.h @@ -0,0 +1,37 @@ +#ifndef _DCCP_IPV6_H +#define _DCCP_IPV6_H +/* + * net/dccp/ipv6.h + * + * An implementation of the DCCP protocol + * Copyright (c) 2005 Arnaldo Carvalho de Melo + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include + +struct dccp6_sock { + struct dccp_sock dccp; + /* + * ipv6_pinfo has to be the last member of dccp6_sock, + * see inet6_sk_generic. + */ + struct ipv6_pinfo inet6; +}; + +struct dccp6_request_sock { + struct dccp_request_sock dccp; + struct inet6_request_sock inet6; +}; + +struct dccp6_timewait_sock { + struct inet_timewait_sock inet; + struct inet6_timewait_sock tw6; +}; + +#endif /* _DCCP_IPV6_H */ diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index 5c767b5..29261fc 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c @@ -52,7 +52,18 @@ void dccp_time_wait(struct sock *sk, int state, int timeo) if (tw != NULL) { const struct inet_connection_sock *icsk = inet_csk(sk); const int rto = (icsk->icsk_rto << 2) - (icsk->icsk_rto >> 1); - +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + if (tw->tw_family == PF_INET6) { + const struct ipv6_pinfo *np = inet6_sk(sk); + struct inet6_timewait_sock *tw6; + + tw->tw_ipv6_offset = inet6_tw_offset(sk->sk_prot); + tw6 = inet6_twsk((struct sock *)tw); + ipv6_addr_copy(&tw6->tw_v6_daddr, &np->daddr); + ipv6_addr_copy(&tw6->tw_v6_rcv_saddr, &np->rcv_saddr); + tw->tw_ipv6only = np->ipv6only; + } +#endif /* Linkage updates. */ __inet_twsk_hashdance(tw, sk, &dccp_hashinfo); -- cgit v1.1 From fc44b9805324c0ad2733ea2feea9935cc056709d Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:25:06 -0800 Subject: [DCCP]: Use reqsk_free in dccp_v4_conn_request Now we have the destructor (dccp_v4_reqsk_destructor) in our request_sock_ops vtable. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/ipv4.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 3108c9d..bc28d71 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -721,10 +721,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) return 0; drop_and_free: - /* - * FIXME: should be reqsk_free after implementing req->rsk_ops - */ - __reqsk_free(req); + reqsk_free(req); drop: DCCP_INC_STATS_BH(DCCP_MIB_ATTEMPTFAILS); dcb->dccpd_reset_code = reset_code; -- cgit v1.1 From 6d6ee43e0b8b8d4847627fd43739b98ec2b9404f Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:25:19 -0800 Subject: [TWSK]: Introduce struct timewait_sock_ops So that we can share several timewait sockets related functions and make the timewait mini sockets infrastructure closer to the request mini sockets one. Next changesets will take advantage of this, moving more code out of TCP and DCCP v4 and v6 to common infrastructure. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/linux/ipv6.h | 3 +- include/net/inet_timewait_sock.h | 3 +- include/net/sock.h | 4 +-- include/net/tcp.h | 3 ++ include/net/timewait_sock.h | 31 ++++++++++++++++++ net/core/sock.c | 21 ++++++------ net/dccp/ipv4.c | 9 ++++- net/dccp/ipv6.c | 6 +++- net/ipv4/inet_timewait_sock.c | 5 +-- net/ipv4/tcp_ipv4.c | 71 ++++++++++++++++++++++++---------------- net/ipv6/tcp_ipv6.c | 25 +++++--------- 11 files changed, 118 insertions(+), 63 deletions(-) create mode 100644 include/net/timewait_sock.h diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 7d39085..a0d0489 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -360,7 +360,8 @@ struct tcp6_timewait_sock { static inline u16 inet6_tw_offset(const struct proto *prot) { - return prot->twsk_obj_size - sizeof(struct inet6_timewait_sock); + return prot->twsk_prot->twsk_obj_size - + sizeof(struct inet6_timewait_sock); } static inline struct inet6_timewait_sock *inet6_twsk(const struct sock *sk) diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index ca240f8..e396a65 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h @@ -26,6 +26,7 @@ #include #include +#include #include @@ -200,7 +201,7 @@ static inline void inet_twsk_put(struct inet_timewait_sock *tw) printk(KERN_DEBUG "%s timewait_sock %p released\n", tw->tw_prot->name, tw); #endif - kmem_cache_free(tw->tw_prot->twsk_slab, tw); + kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw); module_put(owner); } } diff --git a/include/net/sock.h b/include/net/sock.h index 0fbae85..91d2895 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -493,6 +493,7 @@ extern void sk_stream_kill_queues(struct sock *sk); extern int sk_wait_data(struct sock *sk, long *timeo); struct request_sock_ops; +struct timewait_sock_ops; /* Networking protocol blocks we attach to sockets. * socket layer -> transport layer interface @@ -557,11 +558,10 @@ struct proto { kmem_cache_t *slab; unsigned int obj_size; - kmem_cache_t *twsk_slab; - unsigned int twsk_obj_size; atomic_t *orphan_count; struct request_sock_ops *rsk_prot; + struct timewait_sock_ops *twsk_prot; struct module *owner; diff --git a/include/net/tcp.h b/include/net/tcp.h index 83b117a..176221c 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -287,6 +287,9 @@ extern int tcp_rcv_established(struct sock *sk, extern void tcp_rcv_space_adjust(struct sock *sk); +extern int tcp_twsk_unique(struct sock *sk, + struct sock *sktw, void *twp); + static inline void tcp_dec_quickack_mode(struct sock *sk, const unsigned int pkts) { diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h new file mode 100644 index 0000000..2544281 --- /dev/null +++ b/include/net/timewait_sock.h @@ -0,0 +1,31 @@ +/* + * NET Generic infrastructure for Network protocols. + * + * Authors: Arnaldo Carvalho de Melo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#ifndef _TIMEWAIT_SOCK_H +#define _TIMEWAIT_SOCK_H + +#include +#include + +struct timewait_sock_ops { + kmem_cache_t *twsk_slab; + unsigned int twsk_obj_size; + int (*twsk_unique)(struct sock *sk, + struct sock *sktw, void *twp); +}; + +static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp) +{ + if (sk->sk_prot->twsk_prot->twsk_unique != NULL) + return sk->sk_prot->twsk_prot->twsk_unique(sk, sktw, twp); + return 0; +} + +#endif /* _TIMEWAIT_SOCK_H */ diff --git a/net/core/sock.c b/net/core/sock.c index 13cc3be..6465b0e 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1488,7 +1488,7 @@ int proto_register(struct proto *prot, int alloc_slab) } } - if (prot->twsk_obj_size) { + if (prot->twsk_prot != NULL) { static const char mask[] = "tw_sock_%s"; timewait_sock_slab_name = kmalloc(strlen(prot->name) + sizeof(mask) - 1, GFP_KERNEL); @@ -1497,11 +1497,12 @@ int proto_register(struct proto *prot, int alloc_slab) goto out_free_request_sock_slab; sprintf(timewait_sock_slab_name, mask, prot->name); - prot->twsk_slab = kmem_cache_create(timewait_sock_slab_name, - prot->twsk_obj_size, - 0, SLAB_HWCACHE_ALIGN, - NULL, NULL); - if (prot->twsk_slab == NULL) + prot->twsk_prot->twsk_slab = + kmem_cache_create(timewait_sock_slab_name, + prot->twsk_prot->twsk_obj_size, + 0, SLAB_HWCACHE_ALIGN, + NULL, NULL); + if (prot->twsk_prot->twsk_slab == NULL) goto out_free_timewait_sock_slab_name; } } @@ -1548,12 +1549,12 @@ void proto_unregister(struct proto *prot) prot->rsk_prot->slab = NULL; } - if (prot->twsk_slab != NULL) { - const char *name = kmem_cache_name(prot->twsk_slab); + if (prot->twsk_prot != NULL && prot->twsk_prot->twsk_slab != NULL) { + const char *name = kmem_cache_name(prot->twsk_prot->twsk_slab); - kmem_cache_destroy(prot->twsk_slab); + kmem_cache_destroy(prot->twsk_prot->twsk_slab); kfree(name); - prot->twsk_slab = NULL; + prot->twsk_prot->twsk_slab = NULL; } } diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index bc28d71..e11cda0 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -1309,6 +1310,10 @@ static struct request_sock_ops dccp_request_sock_ops = { .send_reset = dccp_v4_ctl_send_reset, }; +static struct timewait_sock_ops dccp_timewait_sock_ops = { + .twsk_obj_size = sizeof(struct inet_timewait_sock), +}; + struct proto dccp_prot = { .name = "DCCP", .owner = THIS_MODULE, @@ -1332,5 +1337,7 @@ struct proto dccp_prot = { .max_header = MAX_DCCP_HEADER, .obj_size = sizeof(struct dccp_sock), .rsk_prot = &dccp_request_sock_ops, - .twsk_obj_size = sizeof(struct inet_timewait_sock), + .twsk_prot = &dccp_timewait_sock_ops, }; + +EXPORT_SYMBOL_GPL(dccp_prot); diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index a7d2aee..4d078f5 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -652,6 +652,10 @@ static struct request_sock_ops dccp6_request_sock_ops = { .send_reset = dccp_v6_ctl_send_reset, }; +static struct timewait_sock_ops dccp6_timewait_sock_ops = { + .twsk_obj_size = sizeof(struct dccp6_timewait_sock), +}; + static void dccp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb) { struct ipv6_pinfo *np = inet6_sk(sk); @@ -1359,7 +1363,7 @@ static struct proto dccp_v6_prot = { .max_header = MAX_DCCP_HEADER, .obj_size = sizeof(struct dccp6_sock), .rsk_prot = &dccp6_request_sock_ops, - .twsk_obj_size = sizeof(struct dccp6_timewait_sock), + .twsk_prot = &dccp6_timewait_sock_ops, }; static struct inet6_protocol dccp_v6_protocol = { diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index a010e9a..417f126 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c @@ -90,8 +90,9 @@ EXPORT_SYMBOL_GPL(__inet_twsk_hashdance); struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int state) { - struct inet_timewait_sock *tw = kmem_cache_alloc(sk->sk_prot_creator->twsk_slab, - SLAB_ATOMIC); + struct inet_timewait_sock *tw = + kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab, + SLAB_ATOMIC); if (tw != NULL) { const struct inet_sock *inet = inet_sk(sk); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 0b5ab04..6728772 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include @@ -118,6 +119,39 @@ static inline __u32 tcp_v4_init_sequence(struct sock *sk, struct sk_buff *skb) skb->h.th->source); } +int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp) +{ + const struct tcp_timewait_sock *tcptw = tcp_twsk(sktw); + struct tcp_sock *tp = tcp_sk(sk); + + /* With PAWS, it is safe from the viewpoint + of data integrity. Even without PAWS it is safe provided sequence + spaces do not overlap i.e. at data rates <= 80Mbit/sec. + + Actually, the idea is close to VJ's one, only timestamp cache is + held not per host, but per port pair and TW bucket is used as state + holder. + + If TW bucket has been already destroyed we fall back to VJ's scheme + and use initial timestamp retrieved from peer table. + */ + if (tcptw->tw_ts_recent_stamp && + (twp == NULL || (sysctl_tcp_tw_reuse && + xtime.tv_sec - tcptw->tw_ts_recent_stamp > 1))) { + tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2; + if (tp->write_seq == 0) + tp->write_seq = 1; + tp->rx_opt.ts_recent = tcptw->tw_ts_recent; + tp->rx_opt.ts_recent_stamp = tcptw->tw_ts_recent_stamp; + sock_hold(sktw); + return 1; + } + + return 0; +} + +EXPORT_SYMBOL_GPL(tcp_twsk_unique); + /* called with local bh disabled */ static int __tcp_v4_check_established(struct sock *sk, __u16 lport, struct inet_timewait_sock **twp) @@ -142,35 +176,9 @@ static int __tcp_v4_check_established(struct sock *sk, __u16 lport, tw = inet_twsk(sk2); if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) { - const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2); - struct tcp_sock *tp = tcp_sk(sk); - - /* With PAWS, it is safe from the viewpoint - of data integrity. Even without PAWS it - is safe provided sequence spaces do not - overlap i.e. at data rates <= 80Mbit/sec. - - Actually, the idea is close to VJ's one, - only timestamp cache is held not per host, - but per port pair and TW bucket is used - as state holder. - - If TW bucket has been already destroyed we - fall back to VJ's scheme and use initial - timestamp retrieved from peer table. - */ - if (tcptw->tw_ts_recent_stamp && - (!twp || (sysctl_tcp_tw_reuse && - xtime.tv_sec - - tcptw->tw_ts_recent_stamp > 1))) { - tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2; - if (tp->write_seq == 0) - tp->write_seq = 1; - tp->rx_opt.ts_recent = tcptw->tw_ts_recent; - tp->rx_opt.ts_recent_stamp = tcptw->tw_ts_recent_stamp; - sock_hold(sk2); + if (twsk_unique(sk, sk2, twp)) goto unique; - } else + else goto not_unique; } } @@ -869,6 +877,11 @@ struct request_sock_ops tcp_request_sock_ops = { .send_reset = tcp_v4_send_reset, }; +static struct timewait_sock_ops tcp_timewait_sock_ops = { + .twsk_obj_size = sizeof(struct tcp_timewait_sock), + .twsk_unique = tcp_twsk_unique, +}; + int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) { struct inet_request_sock *ireq; @@ -1979,7 +1992,7 @@ struct proto tcp_prot = { .sysctl_rmem = sysctl_tcp_rmem, .max_header = MAX_TCP_HEADER, .obj_size = sizeof(struct tcp_sock), - .twsk_obj_size = sizeof(struct tcp_timewait_sock), + .twsk_prot = &tcp_timewait_sock_ops, .rsk_prot = &tcp_request_sock_ops, }; diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index e5c8a66..514b57b 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -60,6 +60,7 @@ #include #include #include +#include #include @@ -147,22 +148,9 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport, ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && sk2->sk_bound_dev_if == sk->sk_bound_dev_if) { - const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2); - struct tcp_sock *tp = tcp_sk(sk); - - if (tcptw->tw_ts_recent_stamp && - (!twp || - (sysctl_tcp_tw_reuse && - xtime.tv_sec - tcptw->tw_ts_recent_stamp > 1))) { - /* See comment in tcp_ipv4.c */ - tp->write_seq = tcptw->tw_snd_nxt + 65535 + 2; - if (!tp->write_seq) - tp->write_seq = 1; - tp->rx_opt.ts_recent = tcptw->tw_ts_recent; - tp->rx_opt.ts_recent_stamp = tcptw->tw_ts_recent_stamp; - sock_hold(sk2); + if (twsk_unique(sk, sk2, twp)) goto unique; - } else + else goto not_unique; } } @@ -711,6 +699,11 @@ static struct request_sock_ops tcp6_request_sock_ops = { .send_reset = tcp_v6_send_reset }; +static struct timewait_sock_ops tcp6_timewait_sock_ops = { + .twsk_obj_size = sizeof(struct tcp6_timewait_sock), + .twsk_unique = tcp_twsk_unique, +}; + static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb) { struct ipv6_pinfo *np = inet6_sk(sk); @@ -1752,7 +1745,7 @@ struct proto tcpv6_prot = { .sysctl_rmem = sysctl_tcp_rmem, .max_header = MAX_TCP_HEADER, .obj_size = sizeof(struct tcp6_sock), - .twsk_obj_size = sizeof(struct tcp6_timewait_sock), + .twsk_prot = &tcp6_timewait_sock_ops, .rsk_prot = &tcp6_request_sock_ops, }; -- cgit v1.1 From a7f5e7f164788a22eb5d3de8e2d3cee1bf58fdca Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:25:31 -0800 Subject: [INET]: Generalise tcp_v4_hash_connect Renaming it to inet_hash_connect, making it possible to ditch dccp_v4_hash_connect and share the same code with TCP instead. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- drivers/char/random.c | 6 +- include/linux/random.h | 2 +- include/net/inet_hashtables.h | 3 + net/dccp/ipv4.c | 160 +------------------------------------ net/ipv4/inet_hashtables.c | 178 ++++++++++++++++++++++++++++++++++++++++++ net/ipv4/tcp_ipv4.c | 173 +--------------------------------------- 6 files changed, 186 insertions(+), 336 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 7999da2..79b59d9 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1554,10 +1554,8 @@ __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr, EXPORT_SYMBOL(secure_tcp_sequence_number); - - -/* Generate secure starting point for ephemeral TCP port search */ -u32 secure_tcp_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport) +/* Generate secure starting point for ephemeral IPV4 transport port search */ +u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport) { struct keydata *keyptr = get_keyptr(); u32 hash[4]; diff --git a/include/linux/random.h b/include/linux/random.h index 7b2adb3..01424a8 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -52,7 +52,7 @@ extern void get_random_bytes(void *buf, int nbytes); void generate_random_uuid(unsigned char uuid_out[16]); extern __u32 secure_ip_id(__u32 daddr); -extern u32 secure_tcp_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport); +extern u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport); extern u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dport); extern __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr, diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 07840ba..c83baa7 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -434,4 +434,7 @@ static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo, return sk; } + +extern int inet_hash_connect(struct inet_timewait_death_row *death_row, + struct sock *sk); #endif /* _INET_HASHTABLES_H */ diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index e11cda0..671fbf3 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -54,164 +54,6 @@ void dccp_unhash(struct sock *sk) EXPORT_SYMBOL_GPL(dccp_unhash); -/* called with local bh disabled */ -static int __dccp_v4_check_established(struct sock *sk, const __u16 lport, - struct inet_timewait_sock **twp) -{ - struct inet_sock *inet = inet_sk(sk); - const u32 daddr = inet->rcv_saddr; - const u32 saddr = inet->daddr; - const int dif = sk->sk_bound_dev_if; - INET_ADDR_COOKIE(acookie, saddr, daddr) - const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); - unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); - struct inet_ehash_bucket *head = inet_ehash_bucket(&dccp_hashinfo, hash); - const struct sock *sk2; - const struct hlist_node *node; - struct inet_timewait_sock *tw; - - prefetch(head->chain.first); - write_lock(&head->lock); - - /* Check TIME-WAIT sockets first. */ - sk_for_each(sk2, node, &(head + dccp_hashinfo.ehash_size)->chain) { - tw = inet_twsk(sk2); - - if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) - goto not_unique; - } - tw = NULL; - - /* And established part... */ - sk_for_each(sk2, node, &head->chain) { - if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) - goto not_unique; - } - - /* Must record num and sport now. Otherwise we will see - * in hash table socket with a funny identity. */ - inet->num = lport; - inet->sport = htons(lport); - sk->sk_hash = hash; - BUG_TRAP(sk_unhashed(sk)); - __sk_add_node(sk, &head->chain); - sock_prot_inc_use(sk->sk_prot); - write_unlock(&head->lock); - - if (twp != NULL) { - *twp = tw; - NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); - } else if (tw != NULL) { - /* Silly. Should hash-dance instead... */ - inet_twsk_deschedule(tw, &dccp_death_row); - NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); - - inet_twsk_put(tw); - } - - return 0; - -not_unique: - write_unlock(&head->lock); - return -EADDRNOTAVAIL; -} - -/* - * Bind a port for a connect operation and hash it. - */ -static int dccp_v4_hash_connect(struct sock *sk) -{ - const unsigned short snum = inet_sk(sk)->num; - struct inet_bind_hashbucket *head; - struct inet_bind_bucket *tb; - int ret; - - if (snum == 0) { - int low = sysctl_local_port_range[0]; - int high = sysctl_local_port_range[1]; - int remaining = (high - low) + 1; - int rover = net_random() % (high - low) + low; - struct hlist_node *node; - struct inet_timewait_sock *tw = NULL; - - local_bh_disable(); - do { - head = &dccp_hashinfo.bhash[inet_bhashfn(rover, - dccp_hashinfo.bhash_size)]; - spin_lock(&head->lock); - - /* Does not bother with rcv_saddr checks, - * because the established check is already - * unique enough. - */ - inet_bind_bucket_for_each(tb, node, &head->chain) { - if (tb->port == rover) { - BUG_TRAP(!hlist_empty(&tb->owners)); - if (tb->fastreuse >= 0) - goto next_port; - if (!__dccp_v4_check_established(sk, - rover, - &tw)) - goto ok; - goto next_port; - } - } - - tb = inet_bind_bucket_create(dccp_hashinfo.bind_bucket_cachep, - head, rover); - if (tb == NULL) { - spin_unlock(&head->lock); - break; - } - tb->fastreuse = -1; - goto ok; - - next_port: - spin_unlock(&head->lock); - if (++rover > high) - rover = low; - } while (--remaining > 0); - - local_bh_enable(); - - return -EADDRNOTAVAIL; - -ok: - /* All locks still held and bhs disabled */ - inet_bind_hash(sk, tb, rover); - if (sk_unhashed(sk)) { - inet_sk(sk)->sport = htons(rover); - __inet_hash(&dccp_hashinfo, sk, 0); - } - spin_unlock(&head->lock); - - if (tw != NULL) { - inet_twsk_deschedule(tw, &dccp_death_row); - inet_twsk_put(tw); - } - - ret = 0; - goto out; - } - - head = &dccp_hashinfo.bhash[inet_bhashfn(snum, - dccp_hashinfo.bhash_size)]; - tb = inet_csk(sk)->icsk_bind_hash; - spin_lock_bh(&head->lock); - if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) { - __inet_hash(&dccp_hashinfo, sk, 0); - spin_unlock_bh(&head->lock); - return 0; - } else { - spin_unlock(&head->lock); - /* No definite answer... Walk to established hash table */ - ret = __dccp_v4_check_established(sk, snum, NULL); -out: - local_bh_enable(); - return ret; - } -} - int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct inet_sock *inet = inet_sk(sk); @@ -272,7 +114,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) * complete initialization after this. */ dccp_set_state(sk, DCCP_REQUESTING); - err = dccp_v4_hash_connect(sk); + err = inet_hash_connect(&dccp_death_row, sk); if (err != 0) goto failure; diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index e8d29fe..3322811 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -15,12 +15,14 @@ #include #include +#include #include #include #include #include #include +#include /* * Allocate and initialize a new local port bind bucket. @@ -163,3 +165,179 @@ struct sock *__inet_lookup_listener(const struct hlist_head *head, const u32 dad } EXPORT_SYMBOL_GPL(__inet_lookup_listener); + +/* called with local bh disabled */ +static int __inet_check_established(struct inet_timewait_death_row *death_row, + struct sock *sk, __u16 lport, + struct inet_timewait_sock **twp) +{ + struct inet_hashinfo *hinfo = death_row->hashinfo; + struct inet_sock *inet = inet_sk(sk); + u32 daddr = inet->rcv_saddr; + u32 saddr = inet->daddr; + int dif = sk->sk_bound_dev_if; + INET_ADDR_COOKIE(acookie, saddr, daddr) + const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); + unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); + struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); + struct sock *sk2; + const struct hlist_node *node; + struct inet_timewait_sock *tw; + + prefetch(head->chain.first); + write_lock(&head->lock); + + /* Check TIME-WAIT sockets first. */ + sk_for_each(sk2, node, &(head + hinfo->ehash_size)->chain) { + tw = inet_twsk(sk2); + + if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) { + if (twsk_unique(sk, sk2, twp)) + goto unique; + else + goto not_unique; + } + } + tw = NULL; + + /* And established part... */ + sk_for_each(sk2, node, &head->chain) { + if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) + goto not_unique; + } + +unique: + /* Must record num and sport now. Otherwise we will see + * in hash table socket with a funny identity. */ + inet->num = lport; + inet->sport = htons(lport); + sk->sk_hash = hash; + BUG_TRAP(sk_unhashed(sk)); + __sk_add_node(sk, &head->chain); + sock_prot_inc_use(sk->sk_prot); + write_unlock(&head->lock); + + if (twp) { + *twp = tw; + NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); + } else if (tw) { + /* Silly. Should hash-dance instead... */ + inet_twsk_deschedule(tw, death_row); + NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); + + inet_twsk_put(tw); + } + + return 0; + +not_unique: + write_unlock(&head->lock); + return -EADDRNOTAVAIL; +} + +static inline u32 inet_sk_port_offset(const struct sock *sk) +{ + const struct inet_sock *inet = inet_sk(sk); + return secure_ipv4_port_ephemeral(inet->rcv_saddr, inet->daddr, + inet->dport); +} + +/* + * Bind a port for a connect operation and hash it. + */ +int inet_hash_connect(struct inet_timewait_death_row *death_row, + struct sock *sk) +{ + struct inet_hashinfo *hinfo = death_row->hashinfo; + const unsigned short snum = inet_sk(sk)->num; + struct inet_bind_hashbucket *head; + struct inet_bind_bucket *tb; + int ret; + + if (!snum) { + int low = sysctl_local_port_range[0]; + int high = sysctl_local_port_range[1]; + int range = high - low; + int i; + int port; + static u32 hint; + u32 offset = hint + inet_sk_port_offset(sk); + struct hlist_node *node; + struct inet_timewait_sock *tw = NULL; + + local_bh_disable(); + for (i = 1; i <= range; i++) { + port = low + (i + offset) % range; + head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; + spin_lock(&head->lock); + + /* Does not bother with rcv_saddr checks, + * because the established check is already + * unique enough. + */ + inet_bind_bucket_for_each(tb, node, &head->chain) { + if (tb->port == port) { + BUG_TRAP(!hlist_empty(&tb->owners)); + if (tb->fastreuse >= 0) + goto next_port; + if (!__inet_check_established(death_row, + sk, port, + &tw)) + goto ok; + goto next_port; + } + } + + tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, head, port); + if (!tb) { + spin_unlock(&head->lock); + break; + } + tb->fastreuse = -1; + goto ok; + + next_port: + spin_unlock(&head->lock); + } + local_bh_enable(); + + return -EADDRNOTAVAIL; + +ok: + hint += i; + + /* Head lock still held and bh's disabled */ + inet_bind_hash(sk, tb, port); + if (sk_unhashed(sk)) { + inet_sk(sk)->sport = htons(port); + __inet_hash(hinfo, sk, 0); + } + spin_unlock(&head->lock); + + if (tw) { + inet_twsk_deschedule(tw, death_row);; + inet_twsk_put(tw); + } + + ret = 0; + goto out; + } + + head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)]; + tb = inet_csk(sk)->icsk_bind_hash; + spin_lock_bh(&head->lock); + if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { + __inet_hash(hinfo, sk, 0); + spin_unlock_bh(&head->lock); + return 0; + } else { + spin_unlock(&head->lock); + /* No definite answer... Walk to established hash table */ + ret = __inet_check_established(death_row, sk, snum, NULL); +out: + local_bh_enable(); + return ret; + } +} + +EXPORT_SYMBOL_GPL(inet_hash_connect); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 6728772..c2fe61b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -152,177 +152,6 @@ int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp) EXPORT_SYMBOL_GPL(tcp_twsk_unique); -/* called with local bh disabled */ -static int __tcp_v4_check_established(struct sock *sk, __u16 lport, - struct inet_timewait_sock **twp) -{ - struct inet_sock *inet = inet_sk(sk); - u32 daddr = inet->rcv_saddr; - u32 saddr = inet->daddr; - int dif = sk->sk_bound_dev_if; - INET_ADDR_COOKIE(acookie, saddr, daddr) - const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); - unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); - struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash); - struct sock *sk2; - const struct hlist_node *node; - struct inet_timewait_sock *tw; - - prefetch(head->chain.first); - write_lock(&head->lock); - - /* Check TIME-WAIT sockets first. */ - sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) { - tw = inet_twsk(sk2); - - if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) { - if (twsk_unique(sk, sk2, twp)) - goto unique; - else - goto not_unique; - } - } - tw = NULL; - - /* And established part... */ - sk_for_each(sk2, node, &head->chain) { - if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) - goto not_unique; - } - -unique: - /* Must record num and sport now. Otherwise we will see - * in hash table socket with a funny identity. */ - inet->num = lport; - inet->sport = htons(lport); - sk->sk_hash = hash; - BUG_TRAP(sk_unhashed(sk)); - __sk_add_node(sk, &head->chain); - sock_prot_inc_use(sk->sk_prot); - write_unlock(&head->lock); - - if (twp) { - *twp = tw; - NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); - } else if (tw) { - /* Silly. Should hash-dance instead... */ - inet_twsk_deschedule(tw, &tcp_death_row); - NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); - - inet_twsk_put(tw); - } - - return 0; - -not_unique: - write_unlock(&head->lock); - return -EADDRNOTAVAIL; -} - -static inline u32 connect_port_offset(const struct sock *sk) -{ - const struct inet_sock *inet = inet_sk(sk); - - return secure_tcp_port_ephemeral(inet->rcv_saddr, inet->daddr, - inet->dport); -} - -/* - * Bind a port for a connect operation and hash it. - */ -static inline int tcp_v4_hash_connect(struct sock *sk) -{ - const unsigned short snum = inet_sk(sk)->num; - struct inet_bind_hashbucket *head; - struct inet_bind_bucket *tb; - int ret; - - if (!snum) { - int low = sysctl_local_port_range[0]; - int high = sysctl_local_port_range[1]; - int range = high - low; - int i; - int port; - static u32 hint; - u32 offset = hint + connect_port_offset(sk); - struct hlist_node *node; - struct inet_timewait_sock *tw = NULL; - - local_bh_disable(); - for (i = 1; i <= range; i++) { - port = low + (i + offset) % range; - head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)]; - spin_lock(&head->lock); - - /* Does not bother with rcv_saddr checks, - * because the established check is already - * unique enough. - */ - inet_bind_bucket_for_each(tb, node, &head->chain) { - if (tb->port == port) { - BUG_TRAP(!hlist_empty(&tb->owners)); - if (tb->fastreuse >= 0) - goto next_port; - if (!__tcp_v4_check_established(sk, - port, - &tw)) - goto ok; - goto next_port; - } - } - - tb = inet_bind_bucket_create(tcp_hashinfo.bind_bucket_cachep, head, port); - if (!tb) { - spin_unlock(&head->lock); - break; - } - tb->fastreuse = -1; - goto ok; - - next_port: - spin_unlock(&head->lock); - } - local_bh_enable(); - - return -EADDRNOTAVAIL; - -ok: - hint += i; - - /* Head lock still held and bh's disabled */ - inet_bind_hash(sk, tb, port); - if (sk_unhashed(sk)) { - inet_sk(sk)->sport = htons(port); - __inet_hash(&tcp_hashinfo, sk, 0); - } - spin_unlock(&head->lock); - - if (tw) { - inet_twsk_deschedule(tw, &tcp_death_row);; - inet_twsk_put(tw); - } - - ret = 0; - goto out; - } - - head = &tcp_hashinfo.bhash[inet_bhashfn(snum, tcp_hashinfo.bhash_size)]; - tb = inet_csk(sk)->icsk_bind_hash; - spin_lock_bh(&head->lock); - if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { - __inet_hash(&tcp_hashinfo, sk, 0); - spin_unlock_bh(&head->lock); - return 0; - } else { - spin_unlock(&head->lock); - /* No definite answer... Walk to established hash table */ - ret = __tcp_v4_check_established(sk, snum, NULL); -out: - local_bh_enable(); - return ret; - } -} - /* This will initiate an outgoing connection. */ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { @@ -403,7 +232,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) * complete initialization after this. */ tcp_set_state(sk, TCP_SYN_SENT); - err = tcp_v4_hash_connect(sk); + err = inet_hash_connect(&tcp_death_row, sk); if (err) goto failure; -- cgit v1.1 From d8313f5ca2b1f86b7df6c99fc4b3fffa1f84e92b Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:25:44 -0800 Subject: [INET6]: Generalise tcp_v6_hash_connect Renaming it to inet6_hash_connect, making it possible to ditch dccp_v6_hash_connect and share the same code with TCP instead. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- drivers/char/random.c | 4 +- include/linux/random.h | 4 +- include/net/ipv6.h | 3 + net/dccp/ipv6.c | 171 +---------------------------------------- net/ipv6/inet6_hashtables.c | 183 +++++++++++++++++++++++++++++++++++++++++++- net/ipv6/tcp_ipv6.c | 173 +---------------------------------------- 6 files changed, 190 insertions(+), 348 deletions(-) diff --git a/drivers/char/random.c b/drivers/char/random.c index 79b59d9..bdfdfd2 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -1573,7 +1573,7 @@ u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport) } #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) -u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dport) +u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dport) { struct keydata *keyptr = get_keyptr(); u32 hash[12]; @@ -1584,7 +1584,7 @@ u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dp return twothirdsMD4Transform(daddr, hash); } -EXPORT_SYMBOL(secure_tcpv6_port_ephemeral); +EXPORT_SYMBOL(secure_ipv6_port_ephemeral); #endif #if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE) diff --git a/include/linux/random.h b/include/linux/random.h index 01424a8..5d6456b 100644 --- a/include/linux/random.h +++ b/include/linux/random.h @@ -53,8 +53,8 @@ void generate_random_uuid(unsigned char uuid_out[16]); extern __u32 secure_ip_id(__u32 daddr); extern u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport); -extern u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, - __u16 dport); +extern u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, + __u16 dport); extern __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport); extern __u32 secure_tcpv6_sequence_number(__u32 *saddr, __u32 *daddr, diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 8513761..e3d5d7b 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -527,6 +527,9 @@ extern int inet6_getname(struct socket *sock, struct sockaddr *uaddr, extern int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); +extern int inet6_hash_connect(struct inet_timewait_death_row *death_row, + struct sock *sk); + /* * reassembly.c */ diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 4d078f5..71bf04e 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -84,175 +84,6 @@ static __u32 dccp_v6_init_sequence(struct sock *sk, struct sk_buff *skb) dh->dccph_sport); } -static int __dccp_v6_check_established(struct sock *sk, const __u16 lport, - struct inet_timewait_sock **twp) -{ - struct inet_sock *inet = inet_sk(sk); - const struct ipv6_pinfo *np = inet6_sk(sk); - const struct in6_addr *daddr = &np->rcv_saddr; - const struct in6_addr *saddr = &np->daddr; - const int dif = sk->sk_bound_dev_if; - const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); - const unsigned int hash = inet6_ehashfn(daddr, inet->num, - saddr, inet->dport); - struct inet_ehash_bucket *head = inet_ehash_bucket(&dccp_hashinfo, hash); - struct sock *sk2; - const struct hlist_node *node; - struct inet_timewait_sock *tw; - - prefetch(head->chain.first); - write_lock(&head->lock); - - /* Check TIME-WAIT sockets first. */ - sk_for_each(sk2, node, &(head + dccp_hashinfo.ehash_size)->chain) { - const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2); - - tw = inet_twsk(sk2); - - if(*((__u32 *)&(tw->tw_dport)) == ports && - sk2->sk_family == PF_INET6 && - ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && - ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && - sk2->sk_bound_dev_if == sk->sk_bound_dev_if) - goto not_unique; - } - tw = NULL; - - /* And established part... */ - sk_for_each(sk2, node, &head->chain) { - if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif)) - goto not_unique; - } - - BUG_TRAP(sk_unhashed(sk)); - __sk_add_node(sk, &head->chain); - sk->sk_hash = hash; - sock_prot_inc_use(sk->sk_prot); - write_unlock(&head->lock); - - if (twp) { - *twp = tw; - NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); - } else if (tw) { - /* Silly. Should hash-dance instead... */ - inet_twsk_deschedule(tw, &dccp_death_row); - NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); - - inet_twsk_put(tw); - } - return 0; - -not_unique: - write_unlock(&head->lock); - return -EADDRNOTAVAIL; -} - -static inline u32 dccp_v6_port_offset(const struct sock *sk) -{ - const struct inet_sock *inet = inet_sk(sk); - const struct ipv6_pinfo *np = inet6_sk(sk); - - return secure_tcpv6_port_ephemeral(np->rcv_saddr.s6_addr32, - np->daddr.s6_addr32, - inet->dport); -} - -static int dccp_v6_hash_connect(struct sock *sk) -{ - const unsigned short snum = inet_sk(sk)->num; - struct inet_bind_hashbucket *head; - struct inet_bind_bucket *tb; - int ret; - - if (snum == 0) { - int low = sysctl_local_port_range[0]; - int high = sysctl_local_port_range[1]; - int range = high - low; - int i; - int port; - static u32 hint; - u32 offset = hint + dccp_v6_port_offset(sk); - struct hlist_node *node; - struct inet_timewait_sock *tw = NULL; - - local_bh_disable(); - for (i = 1; i <= range; i++) { - port = low + (i + offset) % range; - head = &dccp_hashinfo.bhash[inet_bhashfn(port, - dccp_hashinfo.bhash_size)]; - spin_lock(&head->lock); - - /* Does not bother with rcv_saddr checks, - * because the established check is already - * unique enough. - */ - inet_bind_bucket_for_each(tb, node, &head->chain) { - if (tb->port == port) { - BUG_TRAP(!hlist_empty(&tb->owners)); - if (tb->fastreuse >= 0) - goto next_port; - if (!__dccp_v6_check_established(sk, - port, - &tw)) - goto ok; - goto next_port; - } - } - - tb = inet_bind_bucket_create(dccp_hashinfo.bind_bucket_cachep, - head, port); - if (!tb) { - spin_unlock(&head->lock); - break; - } - tb->fastreuse = -1; - goto ok; - - next_port: - spin_unlock(&head->lock); - } - local_bh_enable(); - - return -EADDRNOTAVAIL; -ok: - hint += i; - - /* Head lock still held and bh's disabled */ - inet_bind_hash(sk, tb, port); - if (sk_unhashed(sk)) { - inet_sk(sk)->sport = htons(port); - __inet6_hash(&dccp_hashinfo, sk); - } - spin_unlock(&head->lock); - - if (tw) { - inet_twsk_deschedule(tw, &dccp_death_row); - inet_twsk_put(tw); - } - - ret = 0; - goto out; - } - - head = &dccp_hashinfo.bhash[inet_bhashfn(snum, - dccp_hashinfo.bhash_size)]; - tb = inet_csk(sk)->icsk_bind_hash; - spin_lock_bh(&head->lock); - - if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { - __inet6_hash(&dccp_hashinfo, sk); - spin_unlock_bh(&head->lock); - return 0; - } else { - spin_unlock(&head->lock); - /* No definite answer... Walk to established hash table */ - ret = __dccp_v6_check_established(sk, snum, NULL); -out: - local_bh_enable(); - return ret; - } -} - static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { @@ -403,7 +234,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, inet->dport = usin->sin6_port; dccp_set_state(sk, DCCP_REQUESTING); - err = dccp_v6_hash_connect(sk); + err = inet6_hash_connect(&dccp_death_row, sk); if (err) goto late_failure; /* FIXME */ diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 01d5f46..4154f3a 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c @@ -5,7 +5,8 @@ * * Generic INET6 transport hashtables * - * Authors: Lotsa people, from code originally in tcp + * Authors: Lotsa people, from code originally in tcp, generalised here + * by Arnaldo Carvalho de Melo * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -14,12 +15,13 @@ */ #include - #include +#include #include #include #include +#include struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, const struct in6_addr *daddr, @@ -79,3 +81,180 @@ struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, } EXPORT_SYMBOL_GPL(inet6_lookup); + +static int __inet6_check_established(struct inet_timewait_death_row *death_row, + struct sock *sk, const __u16 lport, + struct inet_timewait_sock **twp) +{ + struct inet_hashinfo *hinfo = death_row->hashinfo; + const struct inet_sock *inet = inet_sk(sk); + const struct ipv6_pinfo *np = inet6_sk(sk); + const struct in6_addr *daddr = &np->rcv_saddr; + const struct in6_addr *saddr = &np->daddr; + const int dif = sk->sk_bound_dev_if; + const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); + const unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, + inet->dport); + struct inet_ehash_bucket *head = inet_ehash_bucket(hinfo, hash); + struct sock *sk2; + const struct hlist_node *node; + struct inet_timewait_sock *tw; + + prefetch(head->chain.first); + write_lock(&head->lock); + + /* Check TIME-WAIT sockets first. */ + sk_for_each(sk2, node, &(head + hinfo->ehash_size)->chain) { + const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2); + + tw = inet_twsk(sk2); + + if(*((__u32 *)&(tw->tw_dport)) == ports && + sk2->sk_family == PF_INET6 && + ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && + ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && + sk2->sk_bound_dev_if == sk->sk_bound_dev_if) { + if (twsk_unique(sk, sk2, twp)) + goto unique; + else + goto not_unique; + } + } + tw = NULL; + + /* And established part... */ + sk_for_each(sk2, node, &head->chain) { + if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif)) + goto not_unique; + } + +unique: + BUG_TRAP(sk_unhashed(sk)); + __sk_add_node(sk, &head->chain); + sk->sk_hash = hash; + sock_prot_inc_use(sk->sk_prot); + write_unlock(&head->lock); + + if (twp != NULL) { + *twp = tw; + NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); + } else if (tw != NULL) { + /* Silly. Should hash-dance instead... */ + inet_twsk_deschedule(tw, death_row); + NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); + + inet_twsk_put(tw); + } + return 0; + +not_unique: + write_unlock(&head->lock); + return -EADDRNOTAVAIL; +} + +static inline u32 inet6_sk_port_offset(const struct sock *sk) +{ + const struct inet_sock *inet = inet_sk(sk); + const struct ipv6_pinfo *np = inet6_sk(sk); + return secure_ipv6_port_ephemeral(np->rcv_saddr.s6_addr32, + np->daddr.s6_addr32, + inet->dport); +} + +int inet6_hash_connect(struct inet_timewait_death_row *death_row, + struct sock *sk) +{ + struct inet_hashinfo *hinfo = death_row->hashinfo; + const unsigned short snum = inet_sk(sk)->num; + struct inet_bind_hashbucket *head; + struct inet_bind_bucket *tb; + int ret; + + if (snum == 0) { + const int low = sysctl_local_port_range[0]; + const int high = sysctl_local_port_range[1]; + const int range = high - low; + int i, port; + static u32 hint; + const u32 offset = hint + inet6_sk_port_offset(sk); + struct hlist_node *node; + struct inet_timewait_sock *tw = NULL; + + local_bh_disable(); + for (i = 1; i <= range; i++) { + port = low + (i + offset) % range; + head = &hinfo->bhash[inet_bhashfn(port, hinfo->bhash_size)]; + spin_lock(&head->lock); + + /* Does not bother with rcv_saddr checks, + * because the established check is already + * unique enough. + */ + inet_bind_bucket_for_each(tb, node, &head->chain) { + if (tb->port == port) { + BUG_TRAP(!hlist_empty(&tb->owners)); + if (tb->fastreuse >= 0) + goto next_port; + if (!__inet6_check_established(death_row, + sk, port, + &tw)) + goto ok; + goto next_port; + } + } + + tb = inet_bind_bucket_create(hinfo->bind_bucket_cachep, + head, port); + if (!tb) { + spin_unlock(&head->lock); + break; + } + tb->fastreuse = -1; + goto ok; + + next_port: + spin_unlock(&head->lock); + } + local_bh_enable(); + + return -EADDRNOTAVAIL; + +ok: + hint += i; + + /* Head lock still held and bh's disabled */ + inet_bind_hash(sk, tb, port); + if (sk_unhashed(sk)) { + inet_sk(sk)->sport = htons(port); + __inet6_hash(hinfo, sk); + } + spin_unlock(&head->lock); + + if (tw) { + inet_twsk_deschedule(tw, death_row); + inet_twsk_put(tw); + } + + ret = 0; + goto out; + } + + head = &hinfo->bhash[inet_bhashfn(snum, hinfo->bhash_size)]; + tb = inet_csk(sk)->icsk_bind_hash; + spin_lock_bh(&head->lock); + + if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) { + __inet6_hash(hinfo, sk); + spin_unlock_bh(&head->lock); + return 0; + } else { + spin_unlock(&head->lock); + /* No definite answer... Walk to established hash table */ + ret = __inet6_check_established(death_row, sk, snum, NULL); +out: + local_bh_enable(); + return ret; + } +} + +EXPORT_SYMBOL_GPL(inet6_hash_connect); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 514b57b..a682eb9 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -119,177 +119,6 @@ static __u32 tcp_v6_init_sequence(struct sock *sk, struct sk_buff *skb) } } -static int __tcp_v6_check_established(struct sock *sk, const __u16 lport, - struct inet_timewait_sock **twp) -{ - struct inet_sock *inet = inet_sk(sk); - const struct ipv6_pinfo *np = inet6_sk(sk); - const struct in6_addr *daddr = &np->rcv_saddr; - const struct in6_addr *saddr = &np->daddr; - const int dif = sk->sk_bound_dev_if; - const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); - unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport); - struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash); - struct sock *sk2; - const struct hlist_node *node; - struct inet_timewait_sock *tw; - - prefetch(head->chain.first); - write_lock(&head->lock); - - /* Check TIME-WAIT sockets first. */ - sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) { - const struct inet6_timewait_sock *tw6 = inet6_twsk(sk2); - - tw = inet_twsk(sk2); - - if(*((__u32 *)&(tw->tw_dport)) == ports && - sk2->sk_family == PF_INET6 && - ipv6_addr_equal(&tw6->tw_v6_daddr, saddr) && - ipv6_addr_equal(&tw6->tw_v6_rcv_saddr, daddr) && - sk2->sk_bound_dev_if == sk->sk_bound_dev_if) { - if (twsk_unique(sk, sk2, twp)) - goto unique; - else - goto not_unique; - } - } - tw = NULL; - - /* And established part... */ - sk_for_each(sk2, node, &head->chain) { - if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif)) - goto not_unique; - } - -unique: - BUG_TRAP(sk_unhashed(sk)); - __sk_add_node(sk, &head->chain); - sk->sk_hash = hash; - sock_prot_inc_use(sk->sk_prot); - write_unlock(&head->lock); - - if (twp) { - *twp = tw; - NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); - } else if (tw) { - /* Silly. Should hash-dance instead... */ - inet_twsk_deschedule(tw, &tcp_death_row); - NET_INC_STATS_BH(LINUX_MIB_TIMEWAITRECYCLED); - - inet_twsk_put(tw); - } - return 0; - -not_unique: - write_unlock(&head->lock); - return -EADDRNOTAVAIL; -} - -static inline u32 tcpv6_port_offset(const struct sock *sk) -{ - const struct inet_sock *inet = inet_sk(sk); - const struct ipv6_pinfo *np = inet6_sk(sk); - - return secure_tcpv6_port_ephemeral(np->rcv_saddr.s6_addr32, - np->daddr.s6_addr32, - inet->dport); -} - -static int tcp_v6_hash_connect(struct sock *sk) -{ - unsigned short snum = inet_sk(sk)->num; - struct inet_bind_hashbucket *head; - struct inet_bind_bucket *tb; - int ret; - - if (!snum) { - int low = sysctl_local_port_range[0]; - int high = sysctl_local_port_range[1]; - int range = high - low; - int i; - int port; - static u32 hint; - u32 offset = hint + tcpv6_port_offset(sk); - struct hlist_node *node; - struct inet_timewait_sock *tw = NULL; - - local_bh_disable(); - for (i = 1; i <= range; i++) { - port = low + (i + offset) % range; - head = &tcp_hashinfo.bhash[inet_bhashfn(port, tcp_hashinfo.bhash_size)]; - spin_lock(&head->lock); - - /* Does not bother with rcv_saddr checks, - * because the established check is already - * unique enough. - */ - inet_bind_bucket_for_each(tb, node, &head->chain) { - if (tb->port == port) { - BUG_TRAP(!hlist_empty(&tb->owners)); - if (tb->fastreuse >= 0) - goto next_port; - if (!__tcp_v6_check_established(sk, - port, - &tw)) - goto ok; - goto next_port; - } - } - - tb = inet_bind_bucket_create(tcp_hashinfo.bind_bucket_cachep, head, port); - if (!tb) { - spin_unlock(&head->lock); - break; - } - tb->fastreuse = -1; - goto ok; - - next_port: - spin_unlock(&head->lock); - } - local_bh_enable(); - - return -EADDRNOTAVAIL; - -ok: - hint += i; - - /* Head lock still held and bh's disabled */ - inet_bind_hash(sk, tb, port); - if (sk_unhashed(sk)) { - inet_sk(sk)->sport = htons(port); - __inet6_hash(&tcp_hashinfo, sk); - } - spin_unlock(&head->lock); - - if (tw) { - inet_twsk_deschedule(tw, &tcp_death_row); - inet_twsk_put(tw); - } - - ret = 0; - goto out; - } - - head = &tcp_hashinfo.bhash[inet_bhashfn(snum, tcp_hashinfo.bhash_size)]; - tb = inet_csk(sk)->icsk_bind_hash; - spin_lock_bh(&head->lock); - - if (sk_head(&tb->owners) == sk && !sk->sk_bind_node.next) { - __inet6_hash(&tcp_hashinfo, sk); - spin_unlock_bh(&head->lock); - return 0; - } else { - spin_unlock(&head->lock); - /* No definite answer... Walk to established hash table */ - ret = __tcp_v6_check_established(sk, snum, NULL); -out: - local_bh_enable(); - return ret; - } -} - static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { @@ -450,7 +279,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, inet->dport = usin->sin6_port; tcp_set_state(sk, TCP_SYN_SENT); - err = tcp_v6_hash_connect(sk); + err = inet6_hash_connect(&tcp_death_row, sk); if (err) goto late_failure; -- cgit v1.1 From 22712813620fa8e682dbfb253a60ca0131da1e07 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:25:56 -0800 Subject: [TCP]: Move the TCPF_ enum to tcp_states.h Upcoming patches will make, for instance, ip_sockglue.c need just this enum and not all of tcp.h. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/linux/tcp.h | 16 ---------------- include/net/tcp_states.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 4e14340..da38eea 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -55,22 +55,6 @@ struct tcphdr { __u16 urg_ptr; }; -#define TCP_ACTION_FIN (1 << 7) - -enum { - TCPF_ESTABLISHED = (1 << 1), - TCPF_SYN_SENT = (1 << 2), - TCPF_SYN_RECV = (1 << 3), - TCPF_FIN_WAIT1 = (1 << 4), - TCPF_FIN_WAIT2 = (1 << 5), - TCPF_TIME_WAIT = (1 << 6), - TCPF_CLOSE = (1 << 7), - TCPF_CLOSE_WAIT = (1 << 8), - TCPF_LAST_ACK = (1 << 9), - TCPF_LISTEN = (1 << 10), - TCPF_CLOSING = (1 << 11) -}; - /* * The union cast uses a gcc extension to avoid aliasing problems * (union is compatible to any of its members) diff --git a/include/net/tcp_states.h b/include/net/tcp_states.h index b9d4176..b0b6459 100644 --- a/include/net/tcp_states.h +++ b/include/net/tcp_states.h @@ -31,4 +31,20 @@ enum { #define TCP_STATE_MASK 0xF +#define TCP_ACTION_FIN (1 << 7) + +enum { + TCPF_ESTABLISHED = (1 << 1), + TCPF_SYN_SENT = (1 << 2), + TCPF_SYN_RECV = (1 << 3), + TCPF_FIN_WAIT1 = (1 << 4), + TCPF_FIN_WAIT2 = (1 << 5), + TCPF_TIME_WAIT = (1 << 6), + TCPF_CLOSE = (1 << 7), + TCPF_CLOSE_WAIT = (1 << 8), + TCPF_LAST_ACK = (1 << 9), + TCPF_LISTEN = (1 << 10), + TCPF_CLOSING = (1 << 11) +}; + #endif /* _LINUX_TCP_STATES_H */ -- cgit v1.1 From d83d8461f902c672bc1bd8fbc6a94e19f092da97 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 13 Dec 2005 23:26:10 -0800 Subject: [IP_SOCKGLUE]: Remove most of the tcp specific calls As DCCP needs to be called in the same spots. Now we have a member in inet_sock (is_icsk), set at sock creation time from struct inet_protosw->flags (if INET_PROTOSW_ICSK is set, like for TCP and DCCP) to see if a struct sock instance is a inet_connection_sock for places like the ones in ip_sockglue.c (v4 and v6) where we previously were looking if sk_type was SOCK_STREAM, that is insufficient because we now use the same code for DCCP, that has sk_type SOCK_DCCP. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/linux/dccp.h | 4 ---- include/linux/ip.h | 1 + include/linux/tcp.h | 3 +-- include/net/inet_connection_sock.h | 6 +++++- include/net/protocol.h | 1 + net/dccp/diag.c | 2 +- net/dccp/input.c | 2 +- net/dccp/ipv4.c | 12 +++++++----- net/dccp/ipv6.c | 26 ++++++++++++++------------ net/dccp/output.c | 7 ++++--- net/dccp/proto.c | 2 +- net/ipv4/af_inet.c | 4 +++- net/ipv4/ip_sockglue.c | 13 ++++++------- net/ipv4/tcp.c | 2 +- net/ipv4/tcp_input.c | 10 ++++------ net/ipv4/tcp_ipv4.c | 12 ++++++------ net/ipv4/tcp_output.c | 18 ++++++++++-------- net/ipv6/af_inet6.c | 1 + net/ipv6/ipv6_sockglue.c | 24 +++++++++++++----------- net/ipv6/tcp_ipv6.c | 30 +++++++++++++++++------------- 20 files changed, 97 insertions(+), 83 deletions(-) diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 71fab43..d0bdb49 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -408,8 +408,6 @@ struct dccp_ackvec; * @dccps_gar - greatest valid ack number received on a non-Sync; initialized to %dccps_iss * @dccps_timestamp_time - time of latest TIMESTAMP option * @dccps_timestamp_echo - latest timestamp received on a TIMESTAMP option - * @dccps_ext_header_len - network protocol overhead (IP/IPv6 options) - * @dccps_pmtu_cookie - Last pmtu seen by socket * @dccps_packet_size - Set thru setsockopt * @dccps_role - Role of this sock, one of %dccp_role * @dccps_ndp_count - number of Non Data Packets since last data packet @@ -434,8 +432,6 @@ struct dccp_sock { __u32 dccps_timestamp_echo; __u32 dccps_packet_size; unsigned long dccps_ndp_count; - __u16 dccps_ext_header_len; - __u32 dccps_pmtu_cookie; __u32 dccps_mss_cache; struct dccp_options dccps_options; struct dccp_ackvec *dccps_hc_rx_ackvec; diff --git a/include/linux/ip.h b/include/linux/ip.h index 5a560da..6ccc596 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -155,6 +155,7 @@ struct inet_sock { __u8 mc_ttl; /* Multicasting TTL */ __u8 pmtudisc; unsigned recverr : 1, + is_icsk : 1, /* inet_connection_sock? */ freebind : 1, hdrincl : 1, mc_loop : 1; diff --git a/include/linux/tcp.h b/include/linux/tcp.h index da38eea..f2bb239 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -238,10 +238,9 @@ struct tcp_sock { __u32 snd_wl1; /* Sequence for window update */ __u32 snd_wnd; /* The window we expect to receive */ __u32 max_window; /* Maximal window ever seen from peer */ - __u32 pmtu_cookie; /* Last pmtu seen by socket */ __u32 mss_cache; /* Cached effective mss, not including SACKS */ __u16 xmit_size_goal; /* Goal for segmenting output packets */ - __u16 ext_header_len; /* Network protocol overhead (IP/IPv6 options) */ + /* XXX Two bytes hole, try to pack */ __u32 window_clamp; /* Maximal window to advertise */ __u32 rcv_ssthresh; /* Current window clamp */ diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index e50e2b8..9188896 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -60,6 +60,7 @@ struct inet_connection_sock_af_ops { * @icsk_timeout: Timeout * @icsk_retransmit_timer: Resend (no ack) * @icsk_rto: Retransmit timeout + * @icsk_pmtu_cookie Last pmtu seen by socket * @icsk_ca_ops Pluggable congestion control hook * @icsk_af_ops Operations which are AF_INET{4,6} specific * @icsk_ca_state: Congestion control state @@ -68,6 +69,7 @@ struct inet_connection_sock_af_ops { * @icsk_backoff: Backoff * @icsk_syn_retries: Number of allowed SYN (or equivalent) retries * @icsk_probes_out: unanswered 0 window probes + * @icsk_ext_hdr_len: Network protocol overhead (IP/IPv6 options) * @icsk_ack: Delayed ACK control data */ struct inet_connection_sock { @@ -79,15 +81,17 @@ struct inet_connection_sock { struct timer_list icsk_retransmit_timer; struct timer_list icsk_delack_timer; __u32 icsk_rto; + __u32 icsk_pmtu_cookie; struct tcp_congestion_ops *icsk_ca_ops; struct inet_connection_sock_af_ops *icsk_af_ops; + unsigned int (*icsk_sync_mss)(struct sock *sk, u32 pmtu); __u8 icsk_ca_state; __u8 icsk_retransmits; __u8 icsk_pending; __u8 icsk_backoff; __u8 icsk_syn_retries; __u8 icsk_probes_out; - /* 2 BYTES HOLE, TRY TO PACK! */ + __u16 icsk_ext_hdr_len; struct { __u8 pending; /* ACK is pending */ __u8 quick; /* Scheduled number of quick acks */ diff --git a/include/net/protocol.h b/include/net/protocol.h index 357691f..a29cb29 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h @@ -76,6 +76,7 @@ struct inet_protosw { }; #define INET_PROTOSW_REUSE 0x01 /* Are ports automatically reusable? */ #define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */ +#define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ extern struct net_protocol *inet_protocol_base; extern struct net_protocol *inet_protos[MAX_INET_PROTOS]; diff --git a/net/dccp/diag.c b/net/dccp/diag.c index f675d8e6..3f78c00 100644 --- a/net/dccp/diag.c +++ b/net/dccp/diag.c @@ -28,7 +28,7 @@ static void dccp_get_info(struct sock *sk, struct tcp_info *info) info->tcpi_retransmits = icsk->icsk_retransmits; info->tcpi_probes = icsk->icsk_probes_out; info->tcpi_backoff = icsk->icsk_backoff; - info->tcpi_pmtu = dp->dccps_pmtu_cookie; + info->tcpi_pmtu = icsk->icsk_pmtu_cookie; if (dp->dccps_options.dccpo_send_ack_vector) info->tcpi_options |= TCPI_OPT_SACK; diff --git a/net/dccp/input.c b/net/dccp/input.c index 9a724ff..55e921b 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c @@ -311,7 +311,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, goto out_invalid_packet; } - dccp_sync_mss(sk, dp->dccps_pmtu_cookie); + dccp_sync_mss(sk, icsk->icsk_pmtu_cookie); /* * Step 10: Process REQUEST state (second part) diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 671fbf3..c363051 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -104,9 +104,9 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) inet->dport = usin->sin_port; inet->daddr = daddr; - dp->dccps_ext_header_len = 0; + inet_csk(sk)->icsk_ext_hdr_len = 0; if (inet->opt != NULL) - dp->dccps_ext_header_len = inet->opt->optlen; + inet_csk(sk)->icsk_ext_hdr_len = inet->opt->optlen; /* * Socket identity is still unknown (sport may be zero). * However we set state to DCCP_REQUESTING and not releasing socket @@ -191,7 +191,7 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk, mtu = dst_mtu(dst); if (inet->pmtudisc != IP_PMTUDISC_DONT && - dp->dccps_pmtu_cookie > mtu) { + inet_csk(sk)->icsk_pmtu_cookie > mtu) { dccp_sync_mss(sk, mtu); /* @@ -1051,6 +1051,7 @@ struct inet_connection_sock_af_ops dccp_ipv4_af_ops = { int dccp_v4_init_sock(struct sock *sk) { struct dccp_sock *dp = dccp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); static int dccp_ctl_socket_init = 1; dccp_options_init(&dp->dccps_options); @@ -1090,10 +1091,11 @@ int dccp_v4_init_sock(struct sock *sk) dccp_ctl_socket_init = 0; dccp_init_xmit_timers(sk); - inet_csk(sk)->icsk_rto = DCCP_TIMEOUT_INIT; + icsk->icsk_rto = DCCP_TIMEOUT_INIT; sk->sk_state = DCCP_CLOSED; sk->sk_write_space = dccp_write_space; - inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops; + icsk->icsk_af_ops = &dccp_ipv4_af_ops; + icsk->icsk_sync_mss = dccp_sync_mss; dp->dccps_mss_cache = 536; dp->dccps_role = DCCP_ROLE_UNDEFINED; dp->dccps_service = DCCP_SERVICE_INVALID_VALUE; diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 71bf04e..599b0be 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -88,6 +88,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; + struct inet_connection_sock *icsk = inet_csk(sk); struct inet_sock *inet = inet_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk); struct dccp_sock *dp = dccp_sk(sk); @@ -158,7 +159,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, */ if (addr_type == IPV6_ADDR_MAPPED) { - u32 exthdrlen = dp->dccps_ext_header_len; + u32 exthdrlen = icsk->icsk_ext_hdr_len; struct sockaddr_in sin; SOCK_DEBUG(sk, "connect: ipv4 mapped\n"); @@ -170,14 +171,14 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, sin.sin_port = usin->sin6_port; sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3]; - inet_csk(sk)->icsk_af_ops = &dccp_ipv6_mapped; + icsk->icsk_af_ops = &dccp_ipv6_mapped; sk->sk_backlog_rcv = dccp_v4_do_rcv; err = dccp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); if (err) { - dp->dccps_ext_header_len = exthdrlen; - inet_csk(sk)->icsk_af_ops = &dccp_ipv6_af_ops; + icsk->icsk_ext_hdr_len = exthdrlen; + icsk->icsk_af_ops = &dccp_ipv6_af_ops; sk->sk_backlog_rcv = dccp_v6_do_rcv; goto failure; } else { @@ -227,9 +228,10 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ip6_dst_store(sk, dst, NULL); - dp->dccps_ext_header_len = 0; + icsk->icsk_ext_hdr_len = 0; if (np->opt) - dp->dccps_ext_header_len = np->opt->opt_flen + np->opt->opt_nflen; + icsk->icsk_ext_hdr_len = (np->opt->opt_flen + + np->opt->opt_nflen); inet->dport = usin->sin6_port; @@ -292,7 +294,6 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, np = inet6_sk(sk); if (type == ICMPV6_PKT_TOOBIG) { - struct dccp_sock *dp = dccp_sk(sk); struct dst_entry *dst = NULL; if (sock_owned_by_user(sk)) @@ -332,7 +333,7 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, } else dst_hold(dst); - if (dp->dccps_pmtu_cookie > dst_mtu(dst)) { + if (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst)) { dccp_sync_mss(sk, dst_mtu(dst)); } /* else let the usual retransmit timer handle it */ dst_release(dst); @@ -808,7 +809,7 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, worked with IPv6 icsk.icsk_af_ops. Sync it now. */ - dccp_sync_mss(newsk, newdp->dccps_pmtu_cookie); + dccp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie); return newsk; } @@ -916,10 +917,10 @@ static struct sock *dccp_v6_request_recv_sock(struct sock *sk, sock_kfree_s(sk, opt, opt->tot_len); } - newdp->dccps_ext_header_len = 0; + inet_csk(newsk)->icsk_ext_hdr_len = 0; if (newnp->opt) - newdp->dccps_ext_header_len = newnp->opt->opt_nflen + - newnp->opt->opt_flen; + inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + + newnp->opt->opt_flen); dccp_sync_mss(newsk, dst_mtu(dst)); @@ -1230,6 +1231,7 @@ static struct inet_protosw dccp_v6_protosw = { .prot = &dccp_v6_prot, .ops = &inet6_dccp_ops, .capability = -1, + .flags = INET_PROTOSW_ICSK, }; static int __init dccp_v6_init(void) diff --git a/net/dccp/output.c b/net/dccp/output.c index c40f7f8..95a3c2c 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c @@ -134,12 +134,13 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) { + struct inet_connection_sock *icsk = inet_csk(sk); struct dccp_sock *dp = dccp_sk(sk); - int mss_now = (pmtu - inet_csk(sk)->icsk_af_ops->net_header_len - + int mss_now = (pmtu - icsk->icsk_af_ops->net_header_len - sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext)); /* Now subtract optional transport overhead */ - mss_now -= dp->dccps_ext_header_len; + mss_now -= icsk->icsk_ext_hdr_len; /* * FIXME: this should come from the CCID infrastructure, where, say, @@ -152,7 +153,7 @@ unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) mss_now -= ((5 + 6 + 10 + 6 + 6 + 6 + 3) / 4) * 4; /* And store cached results */ - dp->dccps_pmtu_cookie = pmtu; + icsk->icsk_pmtu_cookie = pmtu; dp->dccps_mss_cache = mss_now; return mss_now; diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 51dfacd2..40a4c68 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -712,7 +712,7 @@ static struct inet_protosw dccp_v4_protosw = { .ops = &inet_dccp_ops, .capability = -1, .no_check = 0, - .flags = 0, + .flags = INET_PROTOSW_ICSK, }; /* diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index d368cf2..617e858 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -302,6 +302,7 @@ lookup_protocol: sk->sk_reuse = 1; inet = inet_sk(sk); + inet->is_icsk = INET_PROTOSW_ICSK & answer_flags; if (SOCK_RAW == sock->type) { inet->num = protocol; @@ -869,7 +870,8 @@ static struct inet_protosw inetsw_array[] = .ops = &inet_stream_ops, .capability = -1, .no_check = 0, - .flags = INET_PROTOSW_PERMANENT, + .flags = INET_PROTOSW_PERMANENT | + INET_PROTOSW_ICSK, }, { diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 4f2d872..add019c 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -29,8 +29,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -427,8 +426,8 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, err = ip_options_get_from_user(&opt, optval, optlen); if (err) break; - if (sk->sk_type == SOCK_STREAM) { - struct tcp_sock *tp = tcp_sk(sk); + if (inet->is_icsk) { + struct inet_connection_sock *icsk = inet_csk(sk); #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) if (sk->sk_family == PF_INET || (!((1 << sk->sk_state) & @@ -436,10 +435,10 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, inet->daddr != LOOPBACK4_IPV6)) { #endif if (inet->opt) - tp->ext_header_len -= inet->opt->optlen; + icsk->icsk_ext_hdr_len -= inet->opt->optlen; if (opt) - tp->ext_header_len += opt->optlen; - tcp_sync_mss(sk, tp->pmtu_cookie); + icsk->icsk_ext_hdr_len += opt->optlen; + icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie); #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) } #endif diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index eacfe6a..00aa80e 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1914,7 +1914,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) info->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime); info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp); - info->tcpi_pmtu = tp->pmtu_cookie; + info->tcpi_pmtu = icsk->icsk_pmtu_cookie; info->tcpi_rcv_ssthresh = tp->rcv_ssthresh; info->tcpi_rtt = jiffies_to_usecs(tp->srtt)>>3; info->tcpi_rttvar = jiffies_to_usecs(tp->mdev)>>2; diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 7de6184..981d120 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -2342,7 +2342,7 @@ static int tcp_ack_update_window(struct sock *sk, struct tcp_sock *tp, if (nwin > tp->max_window) { tp->max_window = nwin; - tcp_sync_mss(sk, tp->pmtu_cookie); + tcp_sync_mss(sk, inet_csk(sk)->icsk_pmtu_cookie); } } } @@ -3967,12 +3967,12 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, struct tcphdr *th, unsigned len) { struct tcp_sock *tp = tcp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); int saved_clamp = tp->rx_opt.mss_clamp; tcp_parse_options(skb, &tp->rx_opt, 0); if (th->ack) { - struct inet_connection_sock *icsk; /* rfc793: * "If the state is SYN-SENT then * first check the ACK bit @@ -4061,7 +4061,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, if (tp->rx_opt.sack_ok && sysctl_tcp_fack) tp->rx_opt.sack_ok |= 2; - tcp_sync_mss(sk, tp->pmtu_cookie); + tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); tcp_initialize_rcv_mss(sk); /* Remember, tcp_poll() does not lock socket! @@ -4071,8 +4071,6 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, mb(); tcp_set_state(sk, TCP_ESTABLISHED); - icsk = inet_csk(sk); - /* Make sure socket is routed, for correct metrics. */ icsk->icsk_af_ops->rebuild_header(sk); @@ -4173,7 +4171,7 @@ discard: if (tp->ecn_flags&TCP_ECN_OK) sock_set_flag(sk, SOCK_NO_LARGESEND); - tcp_sync_mss(sk, tp->pmtu_cookie); + tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); tcp_initialize_rcv_mss(sk); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index c2fe61b..9b62d80 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -220,9 +220,9 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) inet->dport = usin->sin_port; inet->daddr = daddr; - tp->ext_header_len = 0; + inet_csk(sk)->icsk_ext_hdr_len = 0; if (inet->opt) - tp->ext_header_len = inet->opt->optlen; + inet_csk(sk)->icsk_ext_hdr_len = inet->opt->optlen; tp->rx_opt.mss_clamp = 536; @@ -275,7 +275,6 @@ static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *iph, { struct dst_entry *dst; struct inet_sock *inet = inet_sk(sk); - struct tcp_sock *tp = tcp_sk(sk); /* We are not interested in TCP_LISTEN and open_requests (SYN-ACKs * send out by Linux are always <576bytes so they should go through @@ -304,7 +303,7 @@ static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *iph, mtu = dst_mtu(dst); if (inet->pmtudisc != IP_PMTUDISC_DONT && - tp->pmtu_cookie > mtu) { + inet_csk(sk)->icsk_pmtu_cookie > mtu) { tcp_sync_mss(sk, mtu); /* Resend the TCP packet because it's @@ -895,9 +894,9 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, ireq->opt = NULL; newinet->mc_index = inet_iif(skb); newinet->mc_ttl = skb->nh.iph->ttl; - newtp->ext_header_len = 0; + inet_csk(newsk)->icsk_ext_hdr_len = 0; if (newinet->opt) - newtp->ext_header_len = newinet->opt->optlen; + inet_csk(newsk)->icsk_ext_hdr_len = newinet->opt->optlen; newinet->id = newtp->write_seq ^ jiffies; tcp_sync_mss(newsk, dst_mtu(dst)); @@ -1266,6 +1265,7 @@ static int tcp_v4_init_sock(struct sock *sk) sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); icsk->icsk_af_ops = &ipv4_specific; + icsk->icsk_sync_mss = tcp_sync_mss; sk->sk_sndbuf = sysctl_tcp_wmem[1]; sk->sk_rcvbuf = sysctl_tcp_rmem[1]; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index af1946c..3a0a914 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -621,7 +621,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) It is minimum of user_mss and mss received with SYN. It also does not include TCP options. - tp->pmtu_cookie is last pmtu, seen by this function. + inet_csk(sk)->icsk_pmtu_cookie is last pmtu, seen by this function. tp->mss_cache is current effective sending mss, including all tcp options except for SACKs. It is evaluated, @@ -631,17 +631,18 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) NOTE1. rfc1122 clearly states that advertised MSS DOES NOT include either tcp or ip options. - NOTE2. tp->pmtu_cookie and tp->mss_cache are READ ONLY outside - this function. --ANK (980731) + NOTE2. inet_csk(sk)->icsk_pmtu_cookie and tp->mss_cache + are READ ONLY outside this function. --ANK (980731) */ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) { struct tcp_sock *tp = tcp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); /* Calculate base mss without TCP options: It is MMS_S - sizeof(tcphdr) of rfc1122 */ - int mss_now = (pmtu - inet_csk(sk)->icsk_af_ops->net_header_len - + int mss_now = (pmtu - icsk->icsk_af_ops->net_header_len - sizeof(struct tcphdr)); /* Clamp it (mss_clamp does not include tcp options) */ @@ -649,7 +650,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) mss_now = tp->rx_opt.mss_clamp; /* Now subtract optional transport overhead */ - mss_now -= tp->ext_header_len; + mss_now -= icsk->icsk_ext_hdr_len; /* Then reserve room for full set of TCP options and 8 bytes of data */ if (mss_now < 48) @@ -663,7 +664,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) mss_now = max((tp->max_window>>1), 68U - tp->tcp_header_len); /* And store cached results */ - tp->pmtu_cookie = pmtu; + icsk->icsk_pmtu_cookie = pmtu; tp->mss_cache = mss_now; return mss_now; @@ -693,7 +694,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) if (dst) { u32 mtu = dst_mtu(dst); - if (mtu != tp->pmtu_cookie) + if (mtu != inet_csk(sk)->icsk_pmtu_cookie) mss_now = tcp_sync_mss(sk, mtu); } @@ -706,7 +707,8 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) if (doing_tso) { xmit_size_goal = (65535 - inet_csk(sk)->icsk_af_ops->net_header_len - - tp->ext_header_len - tp->tcp_header_len); + inet_csk(sk)->icsk_ext_hdr_len - + tp->tcp_header_len); if (tp->max_window && (xmit_size_goal > (tp->max_window >> 1))) diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index bf17aab..70a510f 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -167,6 +167,7 @@ lookup_protocol: sk->sk_reuse = 1; inet = inet_sk(sk); + inet->is_icsk = INET_PROTOSW_ICSK & answer_flags; if (SOCK_RAW == sock->type) { inet->num = protocol; diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index b6b63fa..c63868d 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c @@ -163,17 +163,17 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, sk_refcnt_debug_dec(sk); if (sk->sk_protocol == IPPROTO_TCP) { - struct tcp_sock *tp = tcp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); local_bh_disable(); sock_prot_dec_use(sk->sk_prot); sock_prot_inc_use(&tcp_prot); local_bh_enable(); sk->sk_prot = &tcp_prot; - inet_csk(sk)->icsk_af_ops = &ipv4_specific; + icsk->icsk_af_ops = &ipv4_specific; sk->sk_socket->ops = &inet_stream_ops; sk->sk_family = PF_INET; - tcp_sync_mss(sk, tp->pmtu_cookie); + tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); } else { local_bh_disable(); sock_prot_dec_use(sk->sk_prot); @@ -317,14 +317,15 @@ int ipv6_setsockopt(struct sock *sk, int level, int optname, } retv = 0; - if (sk->sk_type == SOCK_STREAM) { + if (inet_sk(sk)->is_icsk) { if (opt) { - struct tcp_sock *tp = tcp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); if (!((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE)) && inet_sk(sk)->daddr != LOOPBACK4_IPV6) { - tp->ext_header_len = opt->opt_flen + opt->opt_nflen; - tcp_sync_mss(sk, tp->pmtu_cookie); + icsk->icsk_ext_hdr_len = + opt->opt_flen + opt->opt_nflen; + icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie); } } opt = xchg(&np->opt, opt); @@ -380,14 +381,15 @@ sticky_done: goto done; update: retv = 0; - if (sk->sk_type == SOCK_STREAM) { + if (inet_sk(sk)->is_icsk) { if (opt) { - struct tcp_sock *tp = tcp_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); if (!((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE)) && inet_sk(sk)->daddr != LOOPBACK4_IPV6) { - tp->ext_header_len = opt->opt_flen + opt->opt_nflen; - tcp_sync_mss(sk, tp->pmtu_cookie); + icsk->icsk_ext_hdr_len = + opt->opt_flen + opt->opt_nflen; + icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie); } } opt = xchg(&np->opt, opt); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index a682eb9..2947bc5 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -123,7 +123,8 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; - struct inet_sock *inet = inet_sk(sk); + struct inet_sock *inet = inet_sk(sk); + struct inet_connection_sock *icsk = inet_csk(sk); struct ipv6_pinfo *np = inet6_sk(sk); struct tcp_sock *tp = tcp_sk(sk); struct in6_addr *saddr = NULL, *final_p = NULL, final; @@ -198,7 +199,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, */ if (addr_type == IPV6_ADDR_MAPPED) { - u32 exthdrlen = tp->ext_header_len; + u32 exthdrlen = icsk->icsk_ext_hdr_len; struct sockaddr_in sin; SOCK_DEBUG(sk, "connect: ipv4 mapped\n"); @@ -210,14 +211,14 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, sin.sin_port = usin->sin6_port; sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3]; - inet_csk(sk)->icsk_af_ops = &ipv6_mapped; + icsk->icsk_af_ops = &ipv6_mapped; sk->sk_backlog_rcv = tcp_v4_do_rcv; err = tcp_v4_connect(sk, (struct sockaddr *)&sin, sizeof(sin)); if (err) { - tp->ext_header_len = exthdrlen; - inet_csk(sk)->icsk_af_ops = &ipv6_specific; + icsk->icsk_ext_hdr_len = exthdrlen; + icsk->icsk_af_ops = &ipv6_specific; sk->sk_backlog_rcv = tcp_v6_do_rcv; goto failure; } else { @@ -270,9 +271,10 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, sk->sk_route_caps = dst->dev->features & ~(NETIF_F_IP_CSUM | NETIF_F_TSO); - tp->ext_header_len = 0; + icsk->icsk_ext_hdr_len = 0; if (np->opt) - tp->ext_header_len = np->opt->opt_flen + np->opt->opt_nflen; + icsk->icsk_ext_hdr_len = (np->opt->opt_flen + + np->opt->opt_nflen); tp->rx_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - sizeof(struct ipv6hdr); @@ -385,7 +387,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, } else dst_hold(dst); - if (tp->pmtu_cookie > dst_mtu(dst)) { + if (inet_csk(sk)->icsk_pmtu_cookie > dst_mtu(dst)) { tcp_sync_mss(sk, dst_mtu(dst)); tcp_simple_retransmit(sk); } /* else let the usual retransmit timer handle it */ @@ -869,7 +871,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, worked with IPv6 icsk.icsk_af_ops. Sync it now. */ - tcp_sync_mss(newsk, newtp->pmtu_cookie); + tcp_sync_mss(newsk, inet_csk(newsk)->icsk_pmtu_cookie); return newsk; } @@ -976,10 +978,10 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb, sock_kfree_s(sk, opt, opt->tot_len); } - newtp->ext_header_len = 0; + inet_csk(newsk)->icsk_ext_hdr_len = 0; if (newnp->opt) - newtp->ext_header_len = newnp->opt->opt_nflen + - newnp->opt->opt_flen; + inet_csk(newsk)->icsk_ext_hdr_len = (newnp->opt->opt_nflen + + newnp->opt->opt_flen); tcp_sync_mss(newsk, dst_mtu(dst)); newtp->advmss = dst_metric(dst, RTAX_ADVMSS); @@ -1361,6 +1363,7 @@ static int tcp_v6_init_sock(struct sock *sk) icsk->icsk_af_ops = &ipv6_specific; icsk->icsk_ca_ops = &tcp_init_congestion_ops; + icsk->icsk_sync_mss = tcp_sync_mss; sk->sk_write_space = sk_stream_write_space; sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); @@ -1591,7 +1594,8 @@ static struct inet_protosw tcpv6_protosw = { .ops = &inet6_stream_ops, .capability = -1, .no_check = 0, - .flags = INET_PROTOSW_PERMANENT, + .flags = INET_PROTOSW_PERMANENT | + INET_PROTOSW_ICSK, }; void __init tcpv6_init(void) -- cgit v1.1 From fbe9cc4a87030d5cad5f944ffaef6af7efd119e4 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 13 Dec 2005 23:26:29 -0800 Subject: [AF_UNIX]: Use spinlock for unix_table_lock This lock is actually taken mostly as a writer, so using a rwlock actually just makes performance worse especially on chips like the Intel P4. Signed-off-by: David S. Miller --- include/net/af_unix.h | 2 +- net/unix/af_unix.c | 34 +++++++++++++++++----------------- net/unix/garbage.c | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/net/af_unix.h b/include/net/af_unix.h index b5d785a..3f302ae 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -13,7 +13,7 @@ extern void unix_gc(void); #define UNIX_HASH_SIZE 256 extern struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; -extern rwlock_t unix_table_lock; +extern spinlock_t unix_table_lock; extern atomic_t unix_tot_inflight; diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 1dc3685..04e850e 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -121,7 +121,7 @@ int sysctl_unix_max_dgram_qlen = 10; struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1]; -DEFINE_RWLOCK(unix_table_lock); +DEFINE_SPINLOCK(unix_table_lock); static atomic_t unix_nr_socks = ATOMIC_INIT(0); #define unix_sockets_unbound (&unix_socket_table[UNIX_HASH_SIZE]) @@ -130,7 +130,7 @@ static atomic_t unix_nr_socks = ATOMIC_INIT(0); /* * SMP locking strategy: - * hash table is protected with rwlock unix_table_lock + * hash table is protected with spinlock unix_table_lock * each socket state is protected by separate rwlock. */ @@ -214,16 +214,16 @@ static void __unix_insert_socket(struct hlist_head *list, struct sock *sk) static inline void unix_remove_socket(struct sock *sk) { - write_lock(&unix_table_lock); + spin_lock(&unix_table_lock); __unix_remove_socket(sk); - write_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); } static inline void unix_insert_socket(struct hlist_head *list, struct sock *sk) { - write_lock(&unix_table_lock); + spin_lock(&unix_table_lock); __unix_insert_socket(list, sk); - write_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); } static struct sock *__unix_find_socket_byname(struct sockaddr_un *sunname, @@ -250,11 +250,11 @@ static inline struct sock *unix_find_socket_byname(struct sockaddr_un *sunname, { struct sock *s; - read_lock(&unix_table_lock); + spin_lock(&unix_table_lock); s = __unix_find_socket_byname(sunname, len, type, hash); if (s) sock_hold(s); - read_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); return s; } @@ -263,7 +263,7 @@ static struct sock *unix_find_socket_byinode(struct inode *i) struct sock *s; struct hlist_node *node; - read_lock(&unix_table_lock); + spin_lock(&unix_table_lock); sk_for_each(s, node, &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) { struct dentry *dentry = unix_sk(s)->dentry; @@ -276,7 +276,7 @@ static struct sock *unix_find_socket_byinode(struct inode *i) } s = NULL; found: - read_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); return s; } @@ -642,12 +642,12 @@ retry: addr->len = sprintf(addr->name->sun_path+1, "%05x", ordernum) + 1 + sizeof(short); addr->hash = unix_hash_fold(csum_partial((void*)addr->name, addr->len, 0)); - write_lock(&unix_table_lock); + spin_lock(&unix_table_lock); ordernum = (ordernum+1)&0xFFFFF; if (__unix_find_socket_byname(addr->name, addr->len, sock->type, addr->hash)) { - write_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); /* Sanity yield. It is unusual case, but yet... */ if (!(ordernum&0xFF)) yield(); @@ -658,7 +658,7 @@ retry: __unix_remove_socket(sk); u->addr = addr; __unix_insert_socket(&unix_socket_table[addr->hash], sk); - write_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); err = 0; out: up(&u->readsem); @@ -791,7 +791,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) addr->hash = UNIX_HASH_SIZE; } - write_lock(&unix_table_lock); + spin_lock(&unix_table_lock); if (!sunaddr->sun_path[0]) { err = -EADDRINUSE; @@ -814,7 +814,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) __unix_insert_socket(list, sk); out_unlock: - write_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); out_up: up(&u->readsem); out: @@ -1916,7 +1916,7 @@ static struct sock *unix_seq_idx(int *iter, loff_t pos) static void *unix_seq_start(struct seq_file *seq, loff_t *pos) { - read_lock(&unix_table_lock); + spin_lock(&unix_table_lock); return *pos ? unix_seq_idx(seq->private, *pos - 1) : ((void *) 1); } @@ -1931,7 +1931,7 @@ static void *unix_seq_next(struct seq_file *seq, void *v, loff_t *pos) static void unix_seq_stop(struct seq_file *seq, void *v) { - read_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); } static int unix_seq_show(struct seq_file *seq, void *v) diff --git a/net/unix/garbage.c b/net/unix/garbage.c index 6ffc64e..411802b 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c @@ -182,7 +182,7 @@ void unix_gc(void) if (down_trylock(&unix_gc_sem)) return; - read_lock(&unix_table_lock); + spin_lock(&unix_table_lock); forall_unix_sockets(i, s) { @@ -301,7 +301,7 @@ void unix_gc(void) } u->gc_tree = GC_ORPHAN; } - read_unlock(&unix_table_lock); + spin_unlock(&unix_table_lock); /* * Here we are. Hitlist is filled. Die. -- cgit v1.1 From 4505a3ef720845b5db3ddb440de13cd4800fd508 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 21 Dec 2005 18:51:49 -0800 Subject: [BRIDGE]: allow setting hardware address of bridge pseudo-dev Some people are using bridging to hide multiple machines from an ISP that restricts by MAC address. So in that case allow the bridge mac address to be set to any of the existing interfaces. I don't want to allow any arbitrary value and confuse STP. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_device.c | 28 ++++++++++++++++++++++++++-- net/bridge/br_private.h | 1 + net/bridge/br_stp_if.c | 3 +-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index f564ee9..f7a66ab 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -15,7 +15,8 @@ #include #include -#include +#include + #include #include "br_private.h" @@ -82,6 +83,29 @@ static int br_change_mtu(struct net_device *dev, int new_mtu) return 0; } +/* Allow setting mac address of pseudo-bridge to be same as + * any of the bound interfaces + */ +static int br_set_mac_address(struct net_device *dev, void *p) +{ + struct net_bridge *br = netdev_priv(dev); + struct sockaddr *addr = p; + struct net_bridge_port *port; + int err = -EADDRNOTAVAIL; + + spin_lock_bh(&br->lock); + list_for_each_entry(port, &br->port_list, list) { + if (!compare_ether_addr(port->dev->dev_addr, addr->sa_data)) { + br_stp_change_bridge_id(br, addr->sa_data); + err = 0; + break; + } + } + spin_unlock_bh(&br->lock); + + return err; +} + void br_dev_setup(struct net_device *dev) { memset(dev->dev_addr, 0, ETH_ALEN); @@ -98,6 +122,6 @@ void br_dev_setup(struct net_device *dev) SET_MODULE_OWNER(dev); dev->stop = br_dev_stop; dev->tx_queue_len = 0; - dev->set_mac_address = NULL; + dev->set_mac_address = br_set_mac_address; dev->priv_flags = IFF_EBRIDGE; } diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index bdf95a7..2c24948 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -201,6 +201,7 @@ extern void br_stp_disable_bridge(struct net_bridge *br); extern void br_stp_enable_port(struct net_bridge_port *p); extern void br_stp_disable_port(struct net_bridge_port *p); extern void br_stp_recalculate_bridge_id(struct net_bridge *br); +extern void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *a); extern void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio); extern void br_stp_set_port_priority(struct net_bridge_port *p, diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c index ac09b6a..2d2e969 100644 --- a/net/bridge/br_stp_if.c +++ b/net/bridge/br_stp_if.c @@ -120,8 +120,7 @@ void br_stp_disable_port(struct net_bridge_port *p) } /* called under bridge lock */ -static void br_stp_change_bridge_id(struct net_bridge *br, - const unsigned char *addr) +void br_stp_change_bridge_id(struct net_bridge *br, const unsigned char *addr) { unsigned char oldaddr[6]; struct net_bridge_port *p; -- cgit v1.1 From 4433f420e57afae0ab308b1e2b979f09c86bc115 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 20 Dec 2005 15:19:51 -0800 Subject: [BRIDGE]: handle speed detection after carrier changes Speed of a interface may not be available until carrier is detected in the case of autonegotiation. To get the correct value we need to recheck speed after carrier event. But the check needs to be done in a context that is similar to normal ethtool interface (can sleep). Also, delay check for 1ms to try avoid any carrier bounce transitions. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_if.c | 49 ++++++++++++++++++++++++++++++++++++++----------- net/bridge/br_notify.c | 14 +++----------- net/bridge/br_private.h | 3 +++ 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 975abe2..e6b8bb5 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -32,9 +32,8 @@ * ethtool, use ethtool_ops. Also, since driver might sleep need to * not be holding any locks. */ -static int br_initial_port_cost(struct net_device *dev) +static int port_cost(struct net_device *dev) { - struct ethtool_cmd ecmd = { ETHTOOL_GSET }; struct ifreq ifr; mm_segment_t old_fs; @@ -58,10 +57,6 @@ static int br_initial_port_cost(struct net_device *dev) return 2; case SPEED_10: return 100; - default: - pr_info("bridge: can't decode speed from %s: %d\n", - dev->name, ecmd.speed); - return 100; } } @@ -75,6 +70,35 @@ static int br_initial_port_cost(struct net_device *dev) return 100; /* assume old 10Mbps */ } + +/* + * Check for port carrier transistions. + * Called from work queue to allow for calling functions that + * might sleep (such as speed check), and to debounce. + */ +static void port_carrier_check(void *arg) +{ + struct net_bridge_port *p = arg; + + rtnl_lock(); + if (netif_carrier_ok(p->dev)) { + u32 cost = port_cost(p->dev); + + spin_lock_bh(&p->br->lock); + if (p->state == BR_STATE_DISABLED) { + p->path_cost = cost; + br_stp_enable_port(p); + } + spin_unlock_bh(&p->br->lock); + } else { + spin_lock_bh(&p->br->lock); + if (p->state != BR_STATE_DISABLED) + br_stp_disable_port(p); + spin_unlock_bh(&p->br->lock); + } + rtnl_unlock(); +} + static void destroy_nbp(struct net_bridge_port *p) { struct net_device *dev = p->dev; @@ -102,6 +126,9 @@ static void del_nbp(struct net_bridge_port *p) dev->br_port = NULL; dev_set_promiscuity(dev, -1); + cancel_delayed_work(&p->carrier_check); + flush_scheduled_work(); + spin_lock_bh(&br->lock); br_stp_disable_port(p); spin_unlock_bh(&br->lock); @@ -195,10 +222,9 @@ static int find_portno(struct net_bridge *br) return (index >= BR_MAX_PORTS) ? -EXFULL : index; } -/* called with RTNL */ +/* called with RTNL but without bridge lock */ static struct net_bridge_port *new_nbp(struct net_bridge *br, - struct net_device *dev, - unsigned long cost) + struct net_device *dev) { int index; struct net_bridge_port *p; @@ -215,12 +241,13 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br, p->br = br; dev_hold(dev); p->dev = dev; - p->path_cost = cost; + p->path_cost = port_cost(dev); p->priority = 0x8000 >> BR_PORT_BITS; dev->br_port = p; p->port_no = index; br_init_port(p); p->state = BR_STATE_DISABLED; + INIT_WORK(&p->carrier_check, port_carrier_check, p); kobject_init(&p->kobj); return p; @@ -351,7 +378,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) if (dev->br_port != NULL) return -EBUSY; - if (IS_ERR(p = new_nbp(br, dev, br_initial_port_cost(dev)))) + if (IS_ERR(p = new_nbp(br, dev))) return PTR_ERR(p); if ((err = br_fdb_insert(br, p, dev->dev_addr))) diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c index 917311c..a43a9c1 100644 --- a/net/bridge/br_notify.c +++ b/net/bridge/br_notify.c @@ -52,17 +52,9 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v br_stp_recalculate_bridge_id(br); break; - case NETDEV_CHANGE: /* device is up but carrier changed */ - if (!(br->dev->flags & IFF_UP)) - break; - - if (netif_carrier_ok(dev)) { - if (p->state == BR_STATE_DISABLED) - br_stp_enable_port(p); - } else { - if (p->state != BR_STATE_DISABLED) - br_stp_disable_port(p); - } + case NETDEV_CHANGE: + if (br->dev->flags & IFF_UP) + schedule_delayed_work(&p->carrier_check, BR_PORT_DEBOUNCE); break; case NETDEV_FEAT_CHANGE: diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 2c24948..7ad53c2 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -27,6 +27,8 @@ #define BR_PORT_BITS 10 #define BR_MAX_PORTS (1< Date: Wed, 21 Dec 2005 19:00:18 -0800 Subject: [BRIDGE]: filter packets in learning state While in the learning state, run filters but drop the result. This prevents us from acquiring bad fdb entries in learning state. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_input.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index b88220a..c387852 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -53,6 +53,11 @@ int br_handle_frame_finish(struct sk_buff *skb) /* insert into forwarding database after filtering to avoid spoofing */ br_fdb_update(p->br, p, eth_hdr(skb)->h_source); + if (p->state == BR_STATE_LEARNING) { + kfree_skb(skb); + goto out; + } + if (br->dev->flags & IFF_PROMISC) { struct sk_buff *skb2; @@ -107,9 +112,6 @@ int br_handle_frame(struct net_bridge_port *p, struct sk_buff **pskb) if (!is_valid_ether_addr(eth_hdr(skb)->h_source)) goto err; - if (p->state == BR_STATE_LEARNING) - br_fdb_update(p->br, p, eth_hdr(skb)->h_source); - if (p->br->stp_enabled && !memcmp(dest, bridge_ula, 5) && !(dest[5] & 0xF0)) { @@ -118,9 +120,10 @@ int br_handle_frame(struct net_bridge_port *p, struct sk_buff **pskb) NULL, br_stp_handle_bpdu); return 1; } + goto err; } - else if (p->state == BR_STATE_FORWARDING) { + if (p->state == BR_STATE_FORWARDING || p->state == BR_STATE_LEARNING) { if (br_should_route_hook) { if (br_should_route_hook(pskb)) return 0; -- cgit v1.1 From edb5e46fc03d0a45f2b41e3717631f7af7e9fc19 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 21 Dec 2005 19:00:58 -0800 Subject: [BRIDGE]: limited ethtool support Add limited ethtool support to bridge to allow disabling features. Note: if underlying device does not support a feature (like checksum offload), then the bridge device won't inherit it. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_device.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ net/bridge/br_if.c | 6 ++--- net/bridge/br_private.h | 1 + 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index f7a66ab..0b33a7b 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "br_private.h" @@ -106,6 +107,64 @@ static int br_set_mac_address(struct net_device *dev, void *p) return err; } +static void br_getinfo(struct net_device *dev, struct ethtool_drvinfo *info) +{ + strcpy(info->driver, "bridge"); + strcpy(info->version, BR_VERSION); + strcpy(info->fw_version, "N/A"); + strcpy(info->bus_info, "N/A"); +} + +static int br_set_sg(struct net_device *dev, u32 data) +{ + struct net_bridge *br = netdev_priv(dev); + + if (data) + br->feature_mask |= NETIF_F_SG; + else + br->feature_mask &= ~NETIF_F_SG; + + br_features_recompute(br); + return 0; +} + +static int br_set_tso(struct net_device *dev, u32 data) +{ + struct net_bridge *br = netdev_priv(dev); + + if (data) + br->feature_mask |= NETIF_F_TSO; + else + br->feature_mask &= ~NETIF_F_TSO; + + br_features_recompute(br); + return 0; +} + +static int br_set_tx_csum(struct net_device *dev, u32 data) +{ + struct net_bridge *br = netdev_priv(dev); + + if (data) + br->feature_mask |= NETIF_F_IP_CSUM; + else + br->feature_mask &= ~NETIF_F_IP_CSUM; + + br_features_recompute(br); + return 0; +} + +static struct ethtool_ops br_ethtool_ops = { + .get_drvinfo = br_getinfo, + .get_link = ethtool_op_get_link, + .get_sg = ethtool_op_get_sg, + .set_sg = br_set_sg, + .get_tx_csum = ethtool_op_get_tx_csum, + .set_tx_csum = br_set_tx_csum, + .get_tso = ethtool_op_get_tso, + .set_tso = br_set_tso, +}; + void br_dev_setup(struct net_device *dev) { memset(dev->dev_addr, 0, ETH_ALEN); @@ -120,8 +179,12 @@ void br_dev_setup(struct net_device *dev) dev->change_mtu = br_change_mtu; dev->destructor = free_netdev; SET_MODULE_OWNER(dev); + SET_ETHTOOL_OPS(dev, &br_ethtool_ops); dev->stop = br_dev_stop; dev->tx_queue_len = 0; dev->set_mac_address = br_set_mac_address; dev->priv_flags = IFF_EBRIDGE; + + dev->features = NETIF_F_SG | NETIF_F_FRAGLIST + | NETIF_F_HIGHDMA | NETIF_F_TSO | NETIF_F_IP_CSUM; } diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index e6b8bb5..1132119 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -182,6 +182,7 @@ static struct net_device *new_bridge_dev(const char *name) br->bridge_id.prio[1] = 0x00; memset(br->bridge_id.addr, 0, ETH_ALEN); + br->feature_mask = dev->features; br->stp_enabled = 0; br->designated_root = br->bridge_id; br->root_path_cost = 0; @@ -349,9 +350,8 @@ void br_features_recompute(struct net_bridge *br) struct net_bridge_port *p; unsigned long features, checksum; - features = NETIF_F_SG | NETIF_F_FRAGLIST - | NETIF_F_HIGHDMA | NETIF_F_TSO; - checksum = NETIF_F_IP_CSUM; /* least commmon subset */ + features = br->feature_mask &~ NETIF_F_IP_CSUM; + checksum = br->feature_mask & NETIF_F_IP_CSUM; list_for_each_entry(p, &br->port_list, list) { if (!(p->dev->features diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 7ad53c2..db7b26b 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -93,6 +93,7 @@ struct net_bridge spinlock_t hash_lock; struct hlist_head hash[BR_HASH_SIZE]; struct list_head age_list; + unsigned long feature_mask; /* STP */ bridge_id designated_root; -- cgit v1.1 From 8cbb512e50fb702b5b1d444f76ebcdb53577b2ec Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 21 Dec 2005 19:01:30 -0800 Subject: [BRIDGE]: add version number Add version info to bridge module. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br.c | 1 + net/bridge/br_private.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/net/bridge/br.c b/net/bridge/br.c index f8f1849..188cc1a 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c @@ -67,3 +67,4 @@ EXPORT_SYMBOL(br_should_route_hook); module_init(br_init) module_exit(br_deinit) MODULE_LICENSE("GPL"); +MODULE_VERSION(BR_VERSION); diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index db7b26b..c5bd631 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -29,6 +29,8 @@ #define BR_PORT_DEBOUNCE (HZ/10) +#define BR_VERSION "2.1" + typedef struct bridge_id bridge_id; typedef struct mac_addr mac_addr; typedef __u16 port_id; -- cgit v1.1 From c865e5d99e25a171e8262fc0f7ba608568633c64 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 21 Dec 2005 19:03:44 -0800 Subject: [PKT_SCHED] netem: packet corruption option Here is a new feature for netem in 2.6.16. It adds the ability to randomly corrupt packets with netem. A version was done by Hagen Paul Pfeifer, but I redid it to handle the cases of backwards compatibility with netlink interface and presence of hardware checksum offload. It is useful for testing hardware offload in devices. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- include/linux/pkt_sched.h | 7 +++++++ net/sched/sch_netem.c | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h index e87b233..d10f353 100644 --- a/include/linux/pkt_sched.h +++ b/include/linux/pkt_sched.h @@ -429,6 +429,7 @@ enum TCA_NETEM_CORR, TCA_NETEM_DELAY_DIST, TCA_NETEM_REORDER, + TCA_NETEM_CORRUPT, __TCA_NETEM_MAX, }; @@ -457,6 +458,12 @@ struct tc_netem_reorder __u32 correlation; }; +struct tc_netem_corrupt +{ + __u32 probability; + __u32 correlation; +}; + #define NETEM_DIST_SCALE 8192 #endif diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 82fb07a..ba52832 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -25,7 +25,7 @@ #include -#define VERSION "1.1" +#define VERSION "1.2" /* Network Emulation Queuing algorithm. ==================================== @@ -65,11 +65,12 @@ struct netem_sched_data { u32 jitter; u32 duplicate; u32 reorder; + u32 corrupt; struct crndstate { unsigned long last; unsigned long rho; - } delay_cor, loss_cor, dup_cor, reorder_cor; + } delay_cor, loss_cor, dup_cor, reorder_cor, corrupt_cor; struct disttable { u32 size; @@ -183,6 +184,23 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) q->duplicate = dupsave; } + /* + * Randomized packet corruption. + * Make copy if needed since we are modifying + * If packet is going to be hardware checksummed, then + * do it now in software before we mangle it. + */ + if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) { + if (!(skb = skb_unshare(skb, GFP_ATOMIC)) + || (skb->ip_summed == CHECKSUM_HW + && skb_checksum_help(skb, 0))) { + sch->qstats.drops++; + return NET_XMIT_DROP; + } + + skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8); + } + if (q->gap == 0 /* not doing reordering */ || q->counter < q->gap /* inside last reordering gap */ || q->reorder < get_crandom(&q->reorder_cor)) { @@ -382,6 +400,20 @@ static int get_reorder(struct Qdisc *sch, const struct rtattr *attr) return 0; } +static int get_corrupt(struct Qdisc *sch, const struct rtattr *attr) +{ + struct netem_sched_data *q = qdisc_priv(sch); + const struct tc_netem_corrupt *r = RTA_DATA(attr); + + if (RTA_PAYLOAD(attr) != sizeof(*r)) + return -EINVAL; + + q->corrupt = r->probability; + init_crandom(&q->corrupt_cor, r->correlation); + return 0; +} + +/* Parse netlink message to set options */ static int netem_change(struct Qdisc *sch, struct rtattr *opt) { struct netem_sched_data *q = qdisc_priv(sch); @@ -432,13 +464,19 @@ static int netem_change(struct Qdisc *sch, struct rtattr *opt) if (ret) return ret; } + if (tb[TCA_NETEM_REORDER-1]) { ret = get_reorder(sch, tb[TCA_NETEM_REORDER-1]); if (ret) return ret; } - } + if (tb[TCA_NETEM_CORRUPT-1]) { + ret = get_corrupt(sch, tb[TCA_NETEM_CORRUPT-1]); + if (ret) + return ret; + } + } return 0; } @@ -564,6 +602,7 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb) struct tc_netem_qopt qopt; struct tc_netem_corr cor; struct tc_netem_reorder reorder; + struct tc_netem_corrupt corrupt; qopt.latency = q->latency; qopt.jitter = q->jitter; @@ -582,6 +621,10 @@ static int netem_dump(struct Qdisc *sch, struct sk_buff *skb) reorder.correlation = q->reorder_cor.rho; RTA_PUT(skb, TCA_NETEM_REORDER, sizeof(reorder), &reorder); + corrupt.probability = q->corrupt; + corrupt.correlation = q->corrupt_cor.rho; + RTA_PUT(skb, TCA_NETEM_CORRUPT, sizeof(corrupt), &corrupt); + rta->rta_len = skb->tail - b; return skb->len; -- cgit v1.1 From 3821af2fe13700cab6fd67367128fa180e43f8b8 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 21 Dec 2005 19:30:53 -0800 Subject: [FLS64]: generic version Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- include/asm-alpha/bitops.h | 1 + include/asm-arm/bitops.h | 2 ++ include/asm-arm26/bitops.h | 1 + include/asm-cris/bitops.h | 1 + include/asm-frv/bitops.h | 1 + include/asm-generic/bitops.h | 1 + include/asm-h8300/bitops.h | 1 + include/asm-i386/bitops.h | 1 + include/asm-ia64/bitops.h | 1 + include/asm-m32r/bitops.h | 1 + include/asm-m68k/bitops.h | 1 + include/asm-m68knommu/bitops.h | 1 + include/asm-mips/bitops.h | 2 +- include/asm-parisc/bitops.h | 1 + include/asm-powerpc/bitops.h | 1 + include/asm-s390/bitops.h | 1 + include/asm-sh/bitops.h | 1 + include/asm-sh64/bitops.h | 1 + include/asm-sparc/bitops.h | 1 + include/asm-sparc64/bitops.h | 1 + include/asm-v850/bitops.h | 1 + include/asm-x86_64/bitops.h | 1 + include/asm-xtensa/bitops.h | 1 + include/linux/bitops.h | 9 +++++++++ 24 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/asm-alpha/bitops.h b/include/asm-alpha/bitops.h index 578ed3f..302201f 100644 --- a/include/asm-alpha/bitops.h +++ b/include/asm-alpha/bitops.h @@ -321,6 +321,7 @@ static inline int fls(int word) #else #define fls generic_fls #endif +#define fls64 generic_fls64 /* Compute powers of two for the given integer. */ static inline long floor_log2(unsigned long word) diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h index 7399d43..d02de72 100644 --- a/include/asm-arm/bitops.h +++ b/include/asm-arm/bitops.h @@ -332,6 +332,7 @@ static inline unsigned long __ffs(unsigned long word) */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) /* * ffs: find first bit set. This is defined the same way as @@ -351,6 +352,7 @@ static inline unsigned long __ffs(unsigned long word) #define fls(x) \ ( __builtin_constant_p(x) ? generic_fls(x) : \ ({ int __r; asm("clz\t%0, %1" : "=r"(__r) : "r"(x) : "cc"); 32-__r; }) ) +#define fls64(x) generic_fls64(x) #define ffs(x) ({ unsigned long __t = (x); fls(__t & -__t); }) #define __ffs(x) (ffs(x) - 1) #define ffz(x) __ffs( ~(x) ) diff --git a/include/asm-arm26/bitops.h b/include/asm-arm26/bitops.h index 7d062fb..15cc6f2 100644 --- a/include/asm-arm26/bitops.h +++ b/include/asm-arm26/bitops.h @@ -259,6 +259,7 @@ static inline unsigned long __ffs(unsigned long word) */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) /* * ffs: find first bit set. This is defined the same way as diff --git a/include/asm-cris/bitops.h b/include/asm-cris/bitops.h index 1bddb3f..d3eb0f1 100644 --- a/include/asm-cris/bitops.h +++ b/include/asm-cris/bitops.h @@ -240,6 +240,7 @@ static inline int test_bit(int nr, const volatile unsigned long *addr) */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) /* * hweightN - returns the hamming weight of a N-bit word diff --git a/include/asm-frv/bitops.h b/include/asm-frv/bitops.h index b664bd5..02be7b3 100644 --- a/include/asm-frv/bitops.h +++ b/include/asm-frv/bitops.h @@ -228,6 +228,7 @@ found_middle: \ bit ? 33 - bit : bit; \ }) +#define fls64(x) generic_fls64(x) /* * Every architecture must define this function. It's the fastest diff --git a/include/asm-generic/bitops.h b/include/asm-generic/bitops.h index ce31b73..0e6d985 100644 --- a/include/asm-generic/bitops.h +++ b/include/asm-generic/bitops.h @@ -56,6 +56,7 @@ extern __inline__ int test_bit(int nr, const unsigned long * addr) */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #ifdef __KERNEL__ diff --git a/include/asm-h8300/bitops.h b/include/asm-h8300/bitops.h index 5036f59..c0411ec 100644 --- a/include/asm-h8300/bitops.h +++ b/include/asm-h8300/bitops.h @@ -406,5 +406,6 @@ found_middle: #endif /* __KERNEL__ */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #endif /* _H8300_BITOPS_H */ diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index ddf1739..4807aa1 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -372,6 +372,7 @@ static inline unsigned long ffz(unsigned long word) */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #ifdef __KERNEL__ diff --git a/include/asm-ia64/bitops.h b/include/asm-ia64/bitops.h index 7232528..36d0fb9 100644 --- a/include/asm-ia64/bitops.h +++ b/include/asm-ia64/bitops.h @@ -345,6 +345,7 @@ fls (int t) x |= x >> 16; return ia64_popcnt(x); } +#define fls64(x) generic_fls64(x) /* * ffs: find first bit set. This is defined the same way as the libc and compiler builtin diff --git a/include/asm-m32r/bitops.h b/include/asm-m32r/bitops.h index e784439..abea2fd 100644 --- a/include/asm-m32r/bitops.h +++ b/include/asm-m32r/bitops.h @@ -465,6 +465,7 @@ static __inline__ unsigned long __ffs(unsigned long word) * fls: find last bit set. */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #ifdef __KERNEL__ diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h index b1bcf7c66..13f4c00 100644 --- a/include/asm-m68k/bitops.h +++ b/include/asm-m68k/bitops.h @@ -310,6 +310,7 @@ static inline int fls(int x) return 32 - cnt; } +#define fls64(x) generic_fls64(x) /* * Every architecture must define this function. It's the fastest diff --git a/include/asm-m68knommu/bitops.h b/include/asm-m68knommu/bitops.h index c42f88a..4058dd0 100644 --- a/include/asm-m68knommu/bitops.h +++ b/include/asm-m68knommu/bitops.h @@ -499,5 +499,6 @@ found_middle: * fls: find last bit set. */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #endif /* _M68KNOMMU_BITOPS_H */ diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h index 5496f90..3b0c8aa 100644 --- a/include/asm-mips/bitops.h +++ b/include/asm-mips/bitops.h @@ -695,7 +695,7 @@ static inline unsigned long fls(unsigned long word) return flz(~word) + 1; } - +#define fls64(x) generic_fls64(x) /* * find_next_zero_bit - find the first zero bit in a memory region diff --git a/include/asm-parisc/bitops.h b/include/asm-parisc/bitops.h index 55b98c6..15d8c2b 100644 --- a/include/asm-parisc/bitops.h +++ b/include/asm-parisc/bitops.h @@ -263,6 +263,7 @@ static __inline__ int fls(int x) return ret; } +#define fls64(x) generic_fls64(x) /* * hweightN: returns the hamming weight (i.e. the number diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h index 5727229..1996eaa 100644 --- a/include/asm-powerpc/bitops.h +++ b/include/asm-powerpc/bitops.h @@ -310,6 +310,7 @@ static __inline__ int fls(unsigned int x) asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x)); return 32 - lz; } +#define fls64(x) generic_fls64(x) /* * hweightN: returns the hamming weight (i.e. the number diff --git a/include/asm-s390/bitops.h b/include/asm-s390/bitops.h index b07c578..6123276 100644 --- a/include/asm-s390/bitops.h +++ b/include/asm-s390/bitops.h @@ -839,6 +839,7 @@ static inline int sched_find_first_bit(unsigned long *b) * fls: find last bit set. */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) /* * hweightN: returns the hamming weight (i.e. the number diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h index 5163d1f..1c52608 100644 --- a/include/asm-sh/bitops.h +++ b/include/asm-sh/bitops.h @@ -470,6 +470,7 @@ found_middle: */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #endif /* __KERNEL__ */ diff --git a/include/asm-sh64/bitops.h b/include/asm-sh64/bitops.h index e1ff63e..ce9c3ad 100644 --- a/include/asm-sh64/bitops.h +++ b/include/asm-sh64/bitops.h @@ -510,6 +510,7 @@ found_middle: #define ffs(x) generic_ffs(x) #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #endif /* __KERNEL__ */ diff --git a/include/asm-sparc/bitops.h b/include/asm-sparc/bitops.h index bfbd795..41722b5 100644 --- a/include/asm-sparc/bitops.h +++ b/include/asm-sparc/bitops.h @@ -298,6 +298,7 @@ static inline int ffs(int x) * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) /* * hweightN: returns the hamming weight (i.e. the number diff --git a/include/asm-sparc64/bitops.h b/include/asm-sparc64/bitops.h index 6388b83..6efc016 100644 --- a/include/asm-sparc64/bitops.h +++ b/include/asm-sparc64/bitops.h @@ -119,6 +119,7 @@ static inline unsigned long __ffs(unsigned long word) */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #ifdef __KERNEL__ diff --git a/include/asm-v850/bitops.h b/include/asm-v850/bitops.h index b91e799..8955d23 100644 --- a/include/asm-v850/bitops.h +++ b/include/asm-v850/bitops.h @@ -276,6 +276,7 @@ found_middle: #define ffs(x) generic_ffs (x) #define fls(x) generic_fls (x) +#define fls64(x) generic_fls64(x) #define __ffs(x) ffs(x) diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h index 05a0d37..94b52c8 100644 --- a/include/asm-x86_64/bitops.h +++ b/include/asm-x86_64/bitops.h @@ -409,6 +409,7 @@ static __inline__ int ffs(int x) /* find last set bit */ #define fls(x) generic_fls(x) +#define fls64(x) generic_fls64(x) #endif /* __KERNEL__ */ diff --git a/include/asm-xtensa/bitops.h b/include/asm-xtensa/bitops.h index e76ee88..0a2065f 100644 --- a/include/asm-xtensa/bitops.h +++ b/include/asm-xtensa/bitops.h @@ -245,6 +245,7 @@ static __inline__ int fls (unsigned int x) { return __cntlz(x); } +#define fls64(x) generic_fls64(x) static __inline__ int find_next_bit(const unsigned long *addr, int size, int offset) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 38c2fb7..6a2a19f 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -76,6 +76,15 @@ static __inline__ int generic_fls(int x) */ #include + +static inline int generic_fls64(__u64 x) +{ + __u32 h = x >> 32; + if (h) + return fls(x) + 32; + return fls(x); +} + static __inline__ int get_bitmask_order(unsigned int count) { int order; -- cgit v1.1 From 90933fc8ba5cc9034e3c04ee19938a22b0b4fe4e Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 21 Dec 2005 19:31:36 -0800 Subject: [FLS64]: x86_64 version Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- include/asm-x86_64/bitops.h | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h index 94b52c8..a4d5d09 100644 --- a/include/asm-x86_64/bitops.h +++ b/include/asm-x86_64/bitops.h @@ -340,6 +340,20 @@ static __inline__ unsigned long __ffs(unsigned long word) return word; } +/* + * __fls: find last bit set. + * @word: The word to search + * + * Undefined if no zero exists, so code should check against ~0UL first. + */ +static __inline__ unsigned long __fls(unsigned long word) +{ + __asm__("bsrq %1,%0" + :"=r" (word) + :"rm" (word)); + return word; +} + #ifdef __KERNEL__ static inline int sched_find_first_bit(const unsigned long *b) @@ -370,6 +384,19 @@ static __inline__ int ffs(int x) } /** + * fls64 - find last bit set in 64 bit word + * @x: the word to search + * + * This is defined the same way as fls. + */ +static __inline__ int fls64(__u64 x) +{ + if (x == 0) + return 0; + return __fls(x) + 1; +} + +/** * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh * @@ -409,7 +436,6 @@ static __inline__ int ffs(int x) /* find last set bit */ #define fls(x) generic_fls(x) -#define fls64(x) generic_fls64(x) #endif /* __KERNEL__ */ -- cgit v1.1 From 89b3d9aaf46791177c5a5fa07a3ed38a035b5ef5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 21 Dec 2005 19:32:08 -0800 Subject: [TCP] cubic: precompute constants Revised version of patch to pre-compute values for TCP cubic. * d32,d64 replaced with descriptive names * cube_factor replaces srtt[scaled by count] / HZ * ((1 << (10+2*BICTCP_HZ)) / bic_scale) * beta_scale replaces 8*(BICTCP_BETA_SCALE+beta)/3/(BICTCP_BETA_SCALE-beta); Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/tcp_cubic.c | 133 ++++++++++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 76 deletions(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index bb5dc4b..44fd408 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c @@ -16,7 +16,7 @@ #include #include #include - +#include #define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation * max_cwnd = snd_cwnd * beta @@ -34,15 +34,20 @@ static int initial_ssthresh = 100; static int bic_scale = 41; static int tcp_friendliness = 1; +static u32 cube_rtt_scale; +static u32 beta_scale; +static u64 cube_factor; + +/* Note parameters that are used for precomputing scale factors are read-only */ module_param(fast_convergence, int, 0644); MODULE_PARM_DESC(fast_convergence, "turn on/off fast convergence"); module_param(max_increment, int, 0644); MODULE_PARM_DESC(max_increment, "Limit on increment allowed during binary search"); -module_param(beta, int, 0644); +module_param(beta, int, 0444); MODULE_PARM_DESC(beta, "beta for multiplicative increase"); module_param(initial_ssthresh, int, 0644); MODULE_PARM_DESC(initial_ssthresh, "initial value of slow start threshold"); -module_param(bic_scale, int, 0644); +module_param(bic_scale, int, 0444); MODULE_PARM_DESC(bic_scale, "scale (scaled by 1024) value for bic function (bic_scale/1024)"); module_param(tcp_friendliness, int, 0644); MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness"); @@ -151,65 +156,13 @@ static u32 cubic_root(u64 x) return (u32)end; } -static inline u32 bictcp_K(u32 dist, u32 srtt) -{ - u64 d64; - u32 d32; - u32 count; - u32 result; - - /* calculate the "K" for (wmax-cwnd) = c/rtt * K^3 - so K = cubic_root( (wmax-cwnd)*rtt/c ) - the unit of K is bictcp_HZ=2^10, not HZ - - c = bic_scale >> 10 - rtt = (tp->srtt >> 3 ) / HZ - - the following code has been designed and tested for - cwnd < 1 million packets - RTT < 100 seconds - HZ < 1,000,00 (corresponding to 10 nano-second) - - */ - - /* 1/c * 2^2*bictcp_HZ */ - d32 = (1 << (10+2*BICTCP_HZ)) / bic_scale; - d64 = (__u64)d32; - - /* srtt * 2^count / HZ - 1) to get a better accuracy of the following d32, - the larger the "count", the better the accuracy - 2) and avoid overflow of the following d64 - the larger the "count", the high possibility of overflow - 3) so find a "count" between bictcp_hz-3 and bictcp_hz - "count" may be less than bictcp_HZ, - then d64 becomes 0. that is OK - */ - d32 = srtt; - count = 0; - while (((d32 & 0x80000000)==0) && (count < BICTCP_HZ)){ - d32 = d32 << 1; - count++; - } - d32 = d32 / HZ; - - /* (wmax-cwnd) * (srtt>>3 / HZ) / c * 2^(3*bictcp_HZ) */ - d64 = (d64 * dist * d32) >> (count+3-BICTCP_HZ); - - /* cubic root */ - d64 = cubic_root(d64); - - result = (u32)d64; - return result; -} - /* * Compute congestion window to use. */ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) { - u64 d64; - u32 d32, t, srtt, bic_target, min_cnt, max_cnt; + u64 offs; + u32 delta, t, bic_target, min_cnt, max_cnt; ca->ack_cnt++; /* count the number of ACKs */ @@ -220,8 +173,6 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) ca->last_cwnd = cwnd; ca->last_time = tcp_time_stamp; - srtt = (HZ << 3)/10; /* use real time-based growth function */ - if (ca->epoch_start == 0) { ca->epoch_start = tcp_time_stamp; /* record the beginning of an epoch */ ca->ack_cnt = 1; /* start counting */ @@ -231,7 +182,11 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) ca->bic_K = 0; ca->bic_origin_point = cwnd; } else { - ca->bic_K = bictcp_K(ca->last_max_cwnd-cwnd, srtt); + /* Compute new K based on + * (wmax-cwnd) * (srtt>>3 / HZ) / c * 2^(3*bictcp_HZ) + */ + ca->bic_K = cubic_root(cube_factor + * (ca->last_max_cwnd - cwnd)); ca->bic_origin_point = ca->last_max_cwnd; } } @@ -239,9 +194,9 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) /* cubic function - calc*/ /* calculate c * time^3 / rtt, * while considering overflow in calculation of time^3 - * (so time^3 is done by using d64) + * (so time^3 is done by using 64 bit) * and without the support of division of 64bit numbers - * (so all divisions are done by using d32) + * (so all divisions are done by using 32 bit) * also NOTE the unit of those veriables * time = (t - K) / 2^bictcp_HZ * c = bic_scale >> 10 @@ -255,18 +210,16 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) << BICTCP_HZ) / HZ; if (t < ca->bic_K) /* t - K */ - d32 = ca->bic_K - t; + offs = ca->bic_K - t; else - d32 = t - ca->bic_K; + offs = t - ca->bic_K; - d64 = (u64)d32; - d32 = (bic_scale << 3) * HZ / srtt; /* 1024*c/rtt */ - d64 = (d32 * d64 * d64 * d64) >> (10+3*BICTCP_HZ); /* c/rtt * (t-K)^3 */ - d32 = (u32)d64; + /* c/rtt * (t-K)^3 */ + delta = (cube_rtt_scale * offs * offs * offs) >> (10+3*BICTCP_HZ); if (t < ca->bic_K) /* below origin*/ - bic_target = ca->bic_origin_point - d32; + bic_target = ca->bic_origin_point - delta; else /* above origin*/ - bic_target = ca->bic_origin_point + d32; + bic_target = ca->bic_origin_point + delta; /* cubic function - calc bictcp_cnt*/ if (bic_target > cwnd) { @@ -288,16 +241,16 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) /* TCP Friendly */ if (tcp_friendliness) { - u32 scale = 8*(BICTCP_BETA_SCALE+beta)/3/(BICTCP_BETA_SCALE-beta); - d32 = (cwnd * scale) >> 3; - while (ca->ack_cnt > d32) { /* update tcp cwnd */ - ca->ack_cnt -= d32; + u32 scale = beta_scale; + delta = (cwnd * scale) >> 3; + while (ca->ack_cnt > delta) { /* update tcp cwnd */ + ca->ack_cnt -= delta; ca->tcp_cwnd++; } if (ca->tcp_cwnd > cwnd){ /* if bic is slower than tcp */ - d32 = ca->tcp_cwnd - cwnd; - max_cnt = cwnd / d32; + delta = ca->tcp_cwnd - cwnd; + max_cnt = cwnd / delta; if (ca->cnt > max_cnt) ca->cnt = max_cnt; } @@ -428,6 +381,34 @@ static struct tcp_congestion_ops cubictcp = { static int __init cubictcp_register(void) { BUG_ON(sizeof(struct bictcp) > ICSK_CA_PRIV_SIZE); + + /* Precompute a bunch of the scaling factors that are used per-packet + * based on SRTT of 100ms + */ + + beta_scale = 8*(BICTCP_BETA_SCALE+beta)/ 3 / (BICTCP_BETA_SCALE - beta); + + cube_rtt_scale = (bic_scale << 3) / 10; /* 1024*c/rtt */ + + /* calculate the "K" for (wmax-cwnd) = c/rtt * K^3 + * so K = cubic_root( (wmax-cwnd)*rtt/c ) + * the unit of K is bictcp_HZ=2^10, not HZ + * + * c = bic_scale >> 10 + * rtt = 100ms + * + * the following code has been designed and tested for + * cwnd < 1 million packets + * RTT < 100 seconds + * HZ < 1,000,00 (corresponding to 10 nano-second) + */ + + /* 1/c * 2^2*bictcp_HZ * srtt */ + cube_factor = 1ull << (10+3*BICTCP_HZ); /* 2^40 */ + + /* divide by bic_scale and by constant Srtt (100ms) */ + do_div(cube_factor, bic_scale * 10); + return tcp_register_congestion_control(&cubictcp); } -- cgit v1.1 From 9eb2d627190a8afe4b9276b24615a9559504fa60 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 21 Dec 2005 19:32:36 -0800 Subject: [TCP] cubic: use Newton-Raphson Replace cube root algorithim with a faster version using Newton-Raphson. Surprisingly, doing the scaled div64_64 is faster than a true 64 bit division on 64 bit CPU's. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/tcp_cubic.c | 93 ++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 54 deletions(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index 44fd408..31a4986 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c @@ -52,6 +52,7 @@ MODULE_PARM_DESC(bic_scale, "scale (scaled by 1024) value for bic function (bic_ module_param(tcp_friendliness, int, 0644); MODULE_PARM_DESC(tcp_friendliness, "turn on/off tcp friendliness"); +#include /* BIC TCP Parameters */ struct bictcp { @@ -93,67 +94,51 @@ static void bictcp_init(struct sock *sk) tcp_sk(sk)->snd_ssthresh = initial_ssthresh; } -/* 65536 times the cubic root */ -static const u64 cubic_table[8] - = {0, 65536, 82570, 94519, 104030, 112063, 119087, 125367}; +/* 64bit divisor, dividend and result. dynamic precision */ +static inline u_int64_t div64_64(u_int64_t dividend, u_int64_t divisor) +{ + u_int32_t d = divisor; + + if (divisor > 0xffffffffULL) { + unsigned int shift = fls(divisor >> 32); + + d = divisor >> shift; + dividend >>= shift; + } + + /* avoid 64 bit division if possible */ + if (dividend >> 32) + do_div(dividend, d); + else + dividend = (uint32_t) dividend / d; + + return dividend; +} /* - * calculate the cubic root of x - * the basic idea is that x can be expressed as i*8^j - * so cubic_root(x) = cubic_root(i)*2^j - * in the following code, x is i, and y is 2^j - * because of integer calculation, there are errors in calculation - * so finally use binary search to find out the exact solution + * calculate the cubic root of x using Newton-Raphson */ -static u32 cubic_root(u64 x) +static u32 cubic_root(u64 a) { - u64 y, app, target, start, end, mid, start_diff, end_diff; - - if (x == 0) - return 0; + u32 x, x1; - target = x; - - /* first estimate lower and upper bound */ - y = 1; - while (x >= 8){ - x = (x >> 3); - y = (y << 1); - } - start = (y*cubic_table[x])>>16; - if (x==7) - end = (y<<1); - else - end = (y*cubic_table[x+1]+65535)>>16; - - /* binary search for more accurate one */ - while (start < end-1) { - mid = (start+end) >> 1; - app = mid*mid*mid; - if (app < target) - start = mid; - else if (app > target) - end = mid; - else - return mid; - } + /* Initial estimate is based on: + * cbrt(x) = exp(log(x) / 3) + */ + x = 1u << (fls64(a)/3); - /* find the most accurate one from start and end */ - app = start*start*start; - if (app < target) - start_diff = target - app; - else - start_diff = app - target; - app = end*end*end; - if (app < target) - end_diff = target - app; - else - end_diff = app - target; + /* + * Iteration based on: + * 2 + * x = ( 2 * x + a / x ) / 3 + * k+1 k k + */ + do { + x1 = x; + x = (2 * x + (uint32_t) div64_64(a, x*x)) / 3; + } while (abs(x1 - x) > 1); - if (start_diff < end_diff) - return (u32)start; - else - return (u32)end; + return x; } /* -- cgit v1.1 From fd9662555cc35f8bf9242cd7bba8b44ae168a68b Mon Sep 17 00:00:00 2001 From: Robert Olsson Date: Thu, 22 Dec 2005 11:25:10 -0800 Subject: [IPV4] fib_trie: Add credits. Signed-off-by: Robert Olsson Signed-off-by: David S. Miller --- net/ipv4/fib_trie.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 705e3ce..a3ed7e1 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -41,6 +41,13 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. + * + * Substantial contributions to this work comes from: + * + * David S. Miller, + * Stephen Hemminger + * Paul E. McKenney + * Patrick McHardy */ #define VERSION "0.404" -- cgit v1.1 From 52ccb8e90c0ace233b8b740f2fc5de0dbd706b27 Mon Sep 17 00:00:00 2001 From: Frank Filz Date: Thu, 22 Dec 2005 11:36:46 -0800 Subject: [SCTP]: Update SCTP_PEER_ADDR_PARAMS socket option to the latest api draft. This patch adds support to set/get heartbeat interval, maximum number of retransmissions, pathmtu, sackdelay time for a particular transport/ association/socket as per the latest SCTP sockets api draft11. Signed-off-by: Frank Filz Signed-off-by: Sridhar Samudrala Signed-off-by: David S. Miller --- include/net/sctp/structs.h | 76 +++++-- include/net/sctp/user.h | 16 ++ net/sctp/associola.c | 81 ++++--- net/sctp/input.c | 36 +++- net/sctp/output.c | 17 +- net/sctp/sm_sideeffect.c | 26 ++- net/sctp/sm_statefuns.c | 20 +- net/sctp/socket.c | 511 ++++++++++++++++++++++++++++++++++----------- net/sctp/transport.c | 32 +-- 9 files changed, 595 insertions(+), 220 deletions(-) diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 8e7794e..f5c22d7 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -277,6 +277,24 @@ struct sctp_sock { __u32 default_context; __u32 default_timetolive; + /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to + * the destination address every heartbeat interval. This value + * will be inherited by all new associations. + */ + __u32 hbinterval; + + /* This is the max_retrans value for new associations. */ + __u16 pathmaxrxt; + + /* The initial Path MTU to use for new associations. */ + __u32 pathmtu; + + /* The default SACK delay timeout for new associations. */ + __u32 sackdelay; + + /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ + __u32 param_flags; + struct sctp_initmsg initmsg; struct sctp_rtoinfo rtoinfo; struct sctp_paddrparams paddrparam; @@ -845,9 +863,6 @@ struct sctp_transport { /* Data that has been sent, but not acknowledged. */ __u32 flight_size; - /* PMTU : The current known path MTU. */ - __u32 pmtu; - /* Destination */ struct dst_entry *dst; /* Source address. */ @@ -862,7 +877,22 @@ struct sctp_transport { /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to * the destination address every heartbeat interval. */ - int hb_interval; + __u32 hbinterval; + + /* This is the max_retrans value for the transport and will + * be initialized from the assocs value. This can be changed + * using SCTP_SET_PEER_ADDR_PARAMS socket option. + */ + __u16 pathmaxrxt; + + /* PMTU : The current known path MTU. */ + __u32 pathmtu; + + /* SACK delay timeout */ + __u32 sackdelay; + + /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ + __u32 param_flags; /* When was the last time (in jiffies) that we heard from this * transport? We use this to pick new active and retran paths. @@ -882,22 +912,11 @@ struct sctp_transport { */ int state; - /* hb_allowed : The current heartbeat state of this destination, - * : i.e. ALLOW-HB, NO-HEARTBEAT, etc. - */ - int hb_allowed; - /* These are the error stats for this destination. */ /* Error count : The current error count for this destination. */ unsigned short error_count; - /* This is the max_retrans value for the transport and will - * be initialized to proto.max_retrans.path. This can be changed - * using SCTP_SET_PEER_ADDR_PARAMS socket option. - */ - int max_retrans; - /* Per : A timer used by each destination. * Destination : * Timer : @@ -1502,6 +1521,28 @@ struct sctp_association { /* The largest timeout or RTO value to use in attempting an INIT */ __u16 max_init_timeo; + /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to + * the destination address every heartbeat interval. This value + * will be inherited by all new transports. + */ + __u32 hbinterval; + + /* This is the max_retrans value for new transports in the + * association. + */ + __u16 pathmaxrxt; + + /* Association : The smallest PMTU discovered for all of the + * PMTU : peer's transport addresses. + */ + __u32 pathmtu; + + /* SACK delay timeout */ + __u32 sackdelay; + + /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ + __u32 param_flags; + int timeouts[SCTP_NUM_TIMEOUT_TYPES]; struct timer_list timers[SCTP_NUM_TIMEOUT_TYPES]; @@ -1571,11 +1612,6 @@ struct sctp_association { */ wait_queue_head_t wait; - /* Association : The smallest PMTU discovered for all of the - * PMTU : peer's transport addresses. - */ - __u32 pmtu; - /* The message size at which SCTP fragmentation will occur. */ __u32 frag_point; diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h index f1c3bc5..b9052864 100644 --- a/include/net/sctp/user.h +++ b/include/net/sctp/user.h @@ -503,11 +503,27 @@ struct sctp_setadaption { * unreachable. The following structure is used to access and modify an * address's parameters: */ +enum sctp_spp_flags { + SPP_HB_ENABLE = 1, /*Enable heartbeats*/ + SPP_HB_DISABLE = 2, /*Disable heartbeats*/ + SPP_HB = SPP_HB_ENABLE | SPP_HB_DISABLE, + SPP_HB_DEMAND = 4, /*Send heartbeat immediately*/ + SPP_PMTUD_ENABLE = 8, /*Enable PMTU discovery*/ + SPP_PMTUD_DISABLE = 16, /*Disable PMTU discovery*/ + SPP_PMTUD = SPP_PMTUD_ENABLE | SPP_PMTUD_DISABLE, + SPP_SACKDELAY_ENABLE = 32, /*Enable SACK*/ + SPP_SACKDELAY_DISABLE = 64, /*Disable SACK*/ + SPP_SACKDELAY = SPP_SACKDELAY_ENABLE | SPP_SACKDELAY_DISABLE, +}; + struct sctp_paddrparams { sctp_assoc_t spp_assoc_id; struct sockaddr_storage spp_address; __u32 spp_hbinterval; __u16 spp_pathmaxrxt; + __u32 spp_pathmtu; + __u32 spp_sackdelay; + __u32 spp_flags; } __attribute__((packed, aligned(4))); /* diff --git a/net/sctp/associola.c b/net/sctp/associola.c index dec68a6..9d05e13 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -110,7 +110,6 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a asoc->cookie_life.tv_sec = sp->assocparams.sasoc_cookie_life / 1000; asoc->cookie_life.tv_usec = (sp->assocparams.sasoc_cookie_life % 1000) * 1000; - asoc->pmtu = 0; asoc->frag_point = 0; /* Set the association max_retrans and RTO values from the @@ -123,6 +122,25 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a asoc->overall_error_count = 0; + /* Initialize the association's heartbeat interval based on the + * sock configured value. + */ + asoc->hbinterval = msecs_to_jiffies(sp->hbinterval); + + /* Initialize path max retrans value. */ + asoc->pathmaxrxt = sp->pathmaxrxt; + + /* Initialize default path MTU. */ + asoc->pathmtu = sp->pathmtu; + + /* Set association default SACK delay */ + asoc->sackdelay = msecs_to_jiffies(sp->sackdelay); + + /* Set the association default flags controlling + * Heartbeat, SACK delay, and Path MTU Discovery. + */ + asoc->param_flags = sp->param_flags; + /* Initialize the maximum mumber of new data packets that can be sent * in a burst. */ @@ -144,8 +162,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a = 5 * asoc->rto_max; asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0; - asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = - SCTP_DEFAULT_TIMEOUT_SACK; + asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay; asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = sp->autoclose * HZ; @@ -540,23 +557,46 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, sctp_transport_set_owner(peer, asoc); + /* Initialize the peer's heartbeat interval based on the + * association configured value. + */ + peer->hbinterval = asoc->hbinterval; + + /* Set the path max_retrans. */ + peer->pathmaxrxt = asoc->pathmaxrxt; + + /* Initialize the peer's SACK delay timeout based on the + * association configured value. + */ + peer->sackdelay = asoc->sackdelay; + + /* Enable/disable heartbeat, SACK delay, and path MTU discovery + * based on association setting. + */ + peer->param_flags = asoc->param_flags; + /* Initialize the pmtu of the transport. */ - sctp_transport_pmtu(peer); + if (peer->param_flags & SPP_PMTUD_ENABLE) + sctp_transport_pmtu(peer); + else if (asoc->pathmtu) + peer->pathmtu = asoc->pathmtu; + else + peer->pathmtu = SCTP_DEFAULT_MAXSEGMENT; /* If this is the first transport addr on this association, * initialize the association PMTU to the peer's PMTU. * If not and the current association PMTU is higher than the new * peer's PMTU, reset the association PMTU to the new peer's PMTU. */ - if (asoc->pmtu) - asoc->pmtu = min_t(int, peer->pmtu, asoc->pmtu); + if (asoc->pathmtu) + asoc->pathmtu = min_t(int, peer->pathmtu, asoc->pathmtu); else - asoc->pmtu = peer->pmtu; + asoc->pathmtu = peer->pathmtu; SCTP_DEBUG_PRINTK("sctp_assoc_add_peer:association %p PMTU set to " - "%d\n", asoc, asoc->pmtu); + "%d\n", asoc, asoc->pathmtu); - asoc->frag_point = sctp_frag_point(sp, asoc->pmtu); + asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu); /* The asoc->peer.port might not be meaningful yet, but * initialize the packet structure anyway. @@ -574,7 +614,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, * (for example, implementations MAY use the size of the * receiver advertised window). */ - peer->cwnd = min(4*asoc->pmtu, max_t(__u32, 2*asoc->pmtu, 4380)); + peer->cwnd = min(4*asoc->pathmtu, max_t(__u32, 2*asoc->pathmtu, 4380)); /* At this point, we may not have the receiver's advertised window, * so initialize ssthresh to the default value and it will be set @@ -585,17 +625,6 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, peer->partial_bytes_acked = 0; peer->flight_size = 0; - /* By default, enable heartbeat for peer address. */ - peer->hb_allowed = 1; - - /* Initialize the peer's heartbeat interval based on the - * sock configured value. - */ - peer->hb_interval = msecs_to_jiffies(sp->paddrparam.spp_hbinterval); - - /* Set the path max_retrans. */ - peer->max_retrans = sp->paddrparam.spp_pathmaxrxt; - /* Set the transport's RTO.initial value */ peer->rto = asoc->rto_initial; @@ -1155,18 +1184,18 @@ void sctp_assoc_sync_pmtu(struct sctp_association *asoc) /* Get the lowest pmtu of all the transports. */ list_for_each(pos, &asoc->peer.transport_addr_list) { t = list_entry(pos, struct sctp_transport, transports); - if (!pmtu || (t->pmtu < pmtu)) - pmtu = t->pmtu; + if (!pmtu || (t->pathmtu < pmtu)) + pmtu = t->pathmtu; } if (pmtu) { struct sctp_sock *sp = sctp_sk(asoc->base.sk); - asoc->pmtu = pmtu; + asoc->pathmtu = pmtu; asoc->frag_point = sctp_frag_point(sp, pmtu); } SCTP_DEBUG_PRINTK("%s: asoc:%p, pmtu:%d, frag_point:%d\n", - __FUNCTION__, asoc, asoc->pmtu, asoc->frag_point); + __FUNCTION__, asoc, asoc->pathmtu, asoc->frag_point); } /* Should we send a SACK to update our peer? */ @@ -1179,7 +1208,7 @@ static inline int sctp_peer_needs_update(struct sctp_association *asoc) case SCTP_STATE_SHUTDOWN_SENT: if ((asoc->rwnd > asoc->a_rwnd) && ((asoc->rwnd - asoc->a_rwnd) >= - min_t(__u32, (asoc->base.sk->sk_rcvbuf >> 1), asoc->pmtu))) + min_t(__u32, (asoc->base.sk->sk_rcvbuf >> 1), asoc->pathmtu))) return 1; break; default: diff --git a/net/sctp/input.c b/net/sctp/input.c index b24ff2c..238f1bf 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -305,18 +305,36 @@ int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb) void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc, struct sctp_transport *t, __u32 pmtu) { - if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) { - printk(KERN_WARNING "%s: Reported pmtu %d too low, " - "using default minimum of %d\n", __FUNCTION__, pmtu, - SCTP_DEFAULT_MINSEGMENT); - pmtu = SCTP_DEFAULT_MINSEGMENT; - } + if (sock_owned_by_user(sk) || !t || (t->pathmtu == pmtu)) + return; - if (!sock_owned_by_user(sk) && t && (t->pmtu != pmtu)) { - t->pmtu = pmtu; + if (t->param_flags & SPP_PMTUD_ENABLE) { + if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) { + printk(KERN_WARNING "%s: Reported pmtu %d too low, " + "using default minimum of %d\n", + __FUNCTION__, pmtu, + SCTP_DEFAULT_MINSEGMENT); + /* Use default minimum segment size and disable + * pmtu discovery on this transport. + */ + t->pathmtu = SCTP_DEFAULT_MINSEGMENT; + t->param_flags = (t->param_flags & ~SPP_HB) | + SPP_PMTUD_DISABLE; + } else { + t->pathmtu = pmtu; + } + + /* Update association pmtu. */ sctp_assoc_sync_pmtu(asoc); - sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD); } + + /* Retransmit with the new pmtu setting. + * Normally, if PMTU discovery is disabled, an ICMP Fragmentation + * Needed will never be sent, but if a message was sent before + * PMTU discovery was disabled that was larger than the PMTU, it + * would not be fragmented, so it must be re-transmitted fragmented. + */ + sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD); } /* diff --git a/net/sctp/output.c b/net/sctp/output.c index 9313716..a40991e 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c @@ -234,8 +234,8 @@ sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *packet, goto finish; pmtu = ((packet->transport->asoc) ? - (packet->transport->asoc->pmtu) : - (packet->transport->pmtu)); + (packet->transport->asoc->pathmtu) : + (packet->transport->pathmtu)); too_big = (psize + chunk_len > pmtu); @@ -482,7 +482,9 @@ int sctp_packet_transmit(struct sctp_packet *packet) if (!dst || (dst->obsolete > 1)) { dst_release(dst); sctp_transport_route(tp, NULL, sctp_sk(sk)); - sctp_assoc_sync_pmtu(asoc); + if (asoc->param_flags & SPP_PMTUD_ENABLE) { + sctp_assoc_sync_pmtu(asoc); + } } nskb->dst = dst_clone(tp->dst); @@ -492,7 +494,10 @@ int sctp_packet_transmit(struct sctp_packet *packet) SCTP_DEBUG_PRINTK("***sctp_transmit_packet*** skb len %d\n", nskb->len); - (*tp->af_specific->sctp_xmit)(nskb, tp, packet->ipfragok); + if (tp->param_flags & SPP_PMTUD_ENABLE) + (*tp->af_specific->sctp_xmit)(nskb, tp, packet->ipfragok); + else + (*tp->af_specific->sctp_xmit)(nskb, tp, 1); out: packet->size = packet->overhead; @@ -577,7 +582,7 @@ static sctp_xmit_t sctp_packet_append_data(struct sctp_packet *packet, * if ((flightsize + Max.Burst * MTU) < cwnd) * cwnd = flightsize + Max.Burst * MTU */ - max_burst_bytes = asoc->max_burst * asoc->pmtu; + max_burst_bytes = asoc->max_burst * asoc->pathmtu; if ((transport->flight_size + max_burst_bytes) < transport->cwnd) { transport->cwnd = transport->flight_size + max_burst_bytes; SCTP_DEBUG_PRINTK("%s: cwnd limited by max_burst: " @@ -622,7 +627,7 @@ static sctp_xmit_t sctp_packet_append_data(struct sctp_packet *packet, * data will fit or delay in hopes of bundling a full * sized packet. */ - if (len < asoc->pmtu - packet->overhead) { + if (len < asoc->pathmtu - packet->overhead) { retval = SCTP_XMIT_NAGLE_DELAY; goto finish; } diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 8239471..2d7d8a5 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c @@ -157,9 +157,12 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force, { __u32 ctsn, max_tsn_seen; struct sctp_chunk *sack; + struct sctp_transport *trans = asoc->peer.last_data_from; int error = 0; - if (force) + if (force || + (!trans && (asoc->param_flags & SPP_SACKDELAY_DISABLE)) || + (trans && (trans->param_flags & SPP_SACKDELAY_DISABLE))) asoc->peer.sack_needed = 1; ctsn = sctp_tsnmap_get_ctsn(&asoc->peer.tsn_map); @@ -189,7 +192,22 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force, if (!asoc->peer.sack_needed) { /* We will need a SACK for the next packet. */ asoc->peer.sack_needed = 1; - goto out; + + /* Set the SACK delay timeout based on the + * SACK delay for the last transport + * data was received from, or the default + * for the association. + */ + if (trans) + asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = + trans->sackdelay; + else + asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = + asoc->sackdelay; + + /* Restart the SACK timer. */ + sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, + SCTP_TO(SCTP_EVENT_TIMEOUT_SACK)); } else { if (asoc->a_rwnd > asoc->rwnd) asoc->a_rwnd = asoc->rwnd; @@ -205,7 +223,7 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force, sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, SCTP_TO(SCTP_EVENT_TIMEOUT_SACK)); } -out: + return error; nomem: error = -ENOMEM; @@ -415,7 +433,7 @@ static void sctp_do_8_2_transport_strike(struct sctp_association *asoc, asoc->overall_error_count++; if (transport->state != SCTP_INACTIVE && - (transport->error_count++ >= transport->max_retrans)) { + (transport->error_count++ >= transport->pathmaxrxt)) { SCTP_DEBUG_PRINTK_IPADDR("transport_strike:association %p", " transport IP: port:%d failed.\n", asoc, diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 475bfb4..557a7d9 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -900,7 +900,7 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep, * HEARTBEAT is sent (see Section 8.3). */ - if (transport->hb_allowed) { + if (transport->param_flags & SPP_HB_ENABLE) { if (SCTP_DISPOSITION_NOMEM == sctp_sf_heartbeat(ep, asoc, type, arg, commands)) @@ -1051,7 +1051,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, return SCTP_DISPOSITION_DISCARD; } - max_interval = link->hb_interval + link->rto; + max_interval = link->hbinterval + link->rto; /* Check if the timestamp looks valid. */ if (time_after(hbinfo->sent_at, jiffies) || @@ -2691,14 +2691,9 @@ sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep, * document allow. However, an SCTP transmitter MUST NOT be * more aggressive than the following algorithms allow. */ - if (chunk->end_of_packet) { + if (chunk->end_of_packet) sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_NOFORCE()); - /* Start the SACK timer. */ - sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, - SCTP_TO(SCTP_EVENT_TIMEOUT_SACK)); - } - return SCTP_DISPOSITION_CONSUME; discard_force: @@ -2721,13 +2716,9 @@ discard_force: return SCTP_DISPOSITION_DISCARD; discard_noforce: - if (chunk->end_of_packet) { + if (chunk->end_of_packet) sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_NOFORCE()); - /* Start the SACK timer. */ - sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, - SCTP_TO(SCTP_EVENT_TIMEOUT_SACK)); - } return SCTP_DISPOSITION_DISCARD; consume: return SCTP_DISPOSITION_CONSUME; @@ -3442,9 +3433,6 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn(const struct sctp_endpoint *ep, * send another. */ sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_NOFORCE()); - /* Start the SACK timer. */ - sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, - SCTP_TO(SCTP_EVENT_TIMEOUT_SACK)); return SCTP_DISPOSITION_CONSUME; diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 9df888e..adb5ee6 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -1941,106 +1941,275 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval, * address's parameters: * * struct sctp_paddrparams { - * sctp_assoc_t spp_assoc_id; - * struct sockaddr_storage spp_address; - * uint32_t spp_hbinterval; - * uint16_t spp_pathmaxrxt; - * }; - * - * spp_assoc_id - (UDP style socket) This is filled in the application, - * and identifies the association for this query. + * sctp_assoc_t spp_assoc_id; + * struct sockaddr_storage spp_address; + * uint32_t spp_hbinterval; + * uint16_t spp_pathmaxrxt; + * uint32_t spp_pathmtu; + * uint32_t spp_sackdelay; + * uint32_t spp_flags; + * }; + * + * spp_assoc_id - (one-to-many style socket) This is filled in the + * application, and identifies the association for + * this query. * spp_address - This specifies which address is of interest. * spp_hbinterval - This contains the value of the heartbeat interval, - * in milliseconds. A value of 0, when modifying the - * parameter, specifies that the heartbeat on this - * address should be disabled. A value of UINT32_MAX - * (4294967295), when modifying the parameter, - * specifies that a heartbeat should be sent - * immediately to the peer address, and the current - * interval should remain unchanged. + * in milliseconds. If a value of zero + * is present in this field then no changes are to + * be made to this parameter. * spp_pathmaxrxt - This contains the maximum number of * retransmissions before this address shall be - * considered unreachable. + * considered unreachable. If a value of zero + * is present in this field then no changes are to + * be made to this parameter. + * spp_pathmtu - When Path MTU discovery is disabled the value + * specified here will be the "fixed" path mtu. + * Note that if the spp_address field is empty + * then all associations on this address will + * have this fixed path mtu set upon them. + * + * spp_sackdelay - When delayed sack is enabled, this value specifies + * the number of milliseconds that sacks will be delayed + * for. This value will apply to all addresses of an + * association if the spp_address field is empty. Note + * also, that if delayed sack is enabled and this + * value is set to 0, no change is made to the last + * recorded delayed sack timer value. + * + * spp_flags - These flags are used to control various features + * on an association. The flag field may contain + * zero or more of the following options. + * + * SPP_HB_ENABLE - Enable heartbeats on the + * specified address. Note that if the address + * field is empty all addresses for the association + * have heartbeats enabled upon them. + * + * SPP_HB_DISABLE - Disable heartbeats on the + * speicifed address. Note that if the address + * field is empty all addresses for the association + * will have their heartbeats disabled. Note also + * that SPP_HB_ENABLE and SPP_HB_DISABLE are + * mutually exclusive, only one of these two should + * be specified. Enabling both fields will have + * undetermined results. + * + * SPP_HB_DEMAND - Request a user initiated heartbeat + * to be made immediately. + * + * SPP_PMTUD_ENABLE - This field will enable PMTU + * discovery upon the specified address. Note that + * if the address feild is empty then all addresses + * on the association are effected. + * + * SPP_PMTUD_DISABLE - This field will disable PMTU + * discovery upon the specified address. Note that + * if the address feild is empty then all addresses + * on the association are effected. Not also that + * SPP_PMTUD_ENABLE and SPP_PMTUD_DISABLE are mutually + * exclusive. Enabling both will have undetermined + * results. + * + * SPP_SACKDELAY_ENABLE - Setting this flag turns + * on delayed sack. The time specified in spp_sackdelay + * is used to specify the sack delay for this address. Note + * that if spp_address is empty then all addresses will + * enable delayed sack and take on the sack delay + * value specified in spp_sackdelay. + * SPP_SACKDELAY_DISABLE - Setting this flag turns + * off delayed sack. If the spp_address field is blank then + * delayed sack is disabled for the entire association. Note + * also that this field is mutually exclusive to + * SPP_SACKDELAY_ENABLE, setting both will have undefined + * results. */ +int sctp_apply_peer_addr_params(struct sctp_paddrparams *params, + struct sctp_transport *trans, + struct sctp_association *asoc, + struct sctp_sock *sp, + int hb_change, + int pmtud_change, + int sackdelay_change) +{ + int error; + + if (params->spp_flags & SPP_HB_DEMAND && trans) { + error = sctp_primitive_REQUESTHEARTBEAT (trans->asoc, trans); + if (error) + return error; + } + + if (params->spp_hbinterval) { + if (trans) { + trans->hbinterval = msecs_to_jiffies(params->spp_hbinterval); + } else if (asoc) { + asoc->hbinterval = msecs_to_jiffies(params->spp_hbinterval); + } else { + sp->hbinterval = params->spp_hbinterval; + } + } + + if (hb_change) { + if (trans) { + trans->param_flags = + (trans->param_flags & ~SPP_HB) | hb_change; + } else if (asoc) { + asoc->param_flags = + (asoc->param_flags & ~SPP_HB) | hb_change; + } else { + sp->param_flags = + (sp->param_flags & ~SPP_HB) | hb_change; + } + } + + if (params->spp_pathmtu) { + if (trans) { + trans->pathmtu = params->spp_pathmtu; + sctp_assoc_sync_pmtu(asoc); + } else if (asoc) { + asoc->pathmtu = params->spp_pathmtu; + sctp_frag_point(sp, params->spp_pathmtu); + } else { + sp->pathmtu = params->spp_pathmtu; + } + } + + if (pmtud_change) { + if (trans) { + int update = (trans->param_flags & SPP_PMTUD_DISABLE) && + (params->spp_flags & SPP_PMTUD_ENABLE); + trans->param_flags = + (trans->param_flags & ~SPP_PMTUD) | pmtud_change; + if (update) { + sctp_transport_pmtu(trans); + sctp_assoc_sync_pmtu(asoc); + } + } else if (asoc) { + asoc->param_flags = + (asoc->param_flags & ~SPP_PMTUD) | pmtud_change; + } else { + sp->param_flags = + (sp->param_flags & ~SPP_PMTUD) | pmtud_change; + } + } + + if (params->spp_sackdelay) { + if (trans) { + trans->sackdelay = + msecs_to_jiffies(params->spp_sackdelay); + } else if (asoc) { + asoc->sackdelay = + msecs_to_jiffies(params->spp_sackdelay); + } else { + sp->sackdelay = params->spp_sackdelay; + } + } + + if (sackdelay_change) { + if (trans) { + trans->param_flags = + (trans->param_flags & ~SPP_SACKDELAY) | + sackdelay_change; + } else if (asoc) { + asoc->param_flags = + (asoc->param_flags & ~SPP_SACKDELAY) | + sackdelay_change; + } else { + sp->param_flags = + (sp->param_flags & ~SPP_SACKDELAY) | + sackdelay_change; + } + } + + if (params->spp_pathmaxrxt) { + if (trans) { + trans->pathmaxrxt = params->spp_pathmaxrxt; + } else if (asoc) { + asoc->pathmaxrxt = params->spp_pathmaxrxt; + } else { + sp->pathmaxrxt = params->spp_pathmaxrxt; + } + } + + return 0; +} + static int sctp_setsockopt_peer_addr_params(struct sock *sk, char __user *optval, int optlen) { - struct sctp_paddrparams params; - struct sctp_transport *trans; + struct sctp_paddrparams params; + struct sctp_transport *trans = NULL; + struct sctp_association *asoc = NULL; + struct sctp_sock *sp = sctp_sk(sk); int error; + int hb_change, pmtud_change, sackdelay_change; if (optlen != sizeof(struct sctp_paddrparams)) - return -EINVAL; + return - EINVAL; + if (copy_from_user(¶ms, optval, optlen)) return -EFAULT; - /* - * API 7. Socket Options (setting the default value for the endpoint) - * All options that support specific settings on an association by - * filling in either an association id variable or a sockaddr_storage - * SHOULD also support setting of the same value for the entire endpoint - * (i.e. future associations). To accomplish this the following logic is - * used when setting one of these options: - - * c) If neither the sockaddr_storage or association identification is - * set i.e. the sockaddr_storage is set to all 0's (INADDR_ANY) and - * the association identification is 0, the settings are a default - * and to be applied to the endpoint (all future associations). - */ + /* Validate flags and value parameters. */ + hb_change = params.spp_flags & SPP_HB; + pmtud_change = params.spp_flags & SPP_PMTUD; + sackdelay_change = params.spp_flags & SPP_SACKDELAY; + + if (hb_change == SPP_HB || + pmtud_change == SPP_PMTUD || + sackdelay_change == SPP_SACKDELAY || + params.spp_sackdelay > 500 || + (params.spp_pathmtu + && params.spp_pathmtu < SCTP_DEFAULT_MINSEGMENT)) + return -EINVAL; - /* update default value for endpoint (all future associations) */ - if (!params.spp_assoc_id && - sctp_is_any(( union sctp_addr *)¶ms.spp_address)) { - /* Manual heartbeat on an endpoint is invalid. */ - if (0xffffffff == params.spp_hbinterval) + /* If an address other than INADDR_ANY is specified, and + * no transport is found, then the request is invalid. + */ + if (!sctp_is_any(( union sctp_addr *)¶ms.spp_address)) { + trans = sctp_addr_id2transport(sk, ¶ms.spp_address, + params.spp_assoc_id); + if (!trans) return -EINVAL; - else if (params.spp_hbinterval) - sctp_sk(sk)->paddrparam.spp_hbinterval = - params.spp_hbinterval; - if (params.spp_pathmaxrxt) - sctp_sk(sk)->paddrparam.spp_pathmaxrxt = - params.spp_pathmaxrxt; - return 0; } - trans = sctp_addr_id2transport(sk, ¶ms.spp_address, - params.spp_assoc_id); - if (!trans) + /* Get association, if assoc_id != 0 and the socket is a one + * to many style socket, and an association was not found, then + * the id was invalid. + */ + asoc = sctp_id2assoc(sk, params.spp_assoc_id); + if (!asoc && params.spp_assoc_id && sctp_style(sk, UDP)) return -EINVAL; - /* Applications can enable or disable heartbeats for any peer address - * of an association, modify an address's heartbeat interval, force a - * heartbeat to be sent immediately, and adjust the address's maximum - * number of retransmissions sent before an address is considered - * unreachable. - * - * The value of the heartbeat interval, in milliseconds. A value of - * UINT32_MAX (4294967295), when modifying the parameter, specifies - * that a heartbeat should be sent immediately to the peer address, - * and the current interval should remain unchanged. - */ - if (0xffffffff == params.spp_hbinterval) { - error = sctp_primitive_REQUESTHEARTBEAT (trans->asoc, trans); - if (error) - return error; - } else { - /* The value of the heartbeat interval, in milliseconds. A value of 0, - * when modifying the parameter, specifies that the heartbeat on this - * address should be disabled. + /* Heartbeat demand can only be sent on a transport or + * association, but not a socket. */ - if (params.spp_hbinterval) { - trans->hb_allowed = 1; - trans->hb_interval = - msecs_to_jiffies(params.spp_hbinterval); - } else - trans->hb_allowed = 0; - } + if (params.spp_flags & SPP_HB_DEMAND && !trans && !asoc) + return -EINVAL; + + /* Process parameters. */ + error = sctp_apply_peer_addr_params(¶ms, trans, asoc, sp, + hb_change, pmtud_change, + sackdelay_change); - /* spp_pathmaxrxt contains the maximum number of retransmissions - * before this address shall be considered unreachable. + if (error) + return error; + + /* If changes are for association, also apply parameters to each + * transport. */ - if (params.spp_pathmaxrxt) - trans->max_retrans = params.spp_pathmaxrxt; + if (!trans && asoc) { + struct list_head *pos; + + list_for_each(pos, &asoc->peer.transport_addr_list) { + trans = list_entry(pos, struct sctp_transport, + transports); + sctp_apply_peer_addr_params(¶ms, trans, asoc, sp, + hb_change, pmtud_change, + sackdelay_change); + } + } return 0; } @@ -2334,7 +2503,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optl /* Update the frag_point of the existing associations. */ list_for_each(pos, &(sp->ep->asocs)) { asoc = list_entry(pos, struct sctp_association, asocs); - asoc->frag_point = sctp_frag_point(sp, asoc->pmtu); + asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu); } return 0; @@ -2715,8 +2884,13 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) /* Default Peer Address Parameters. These defaults can * be modified via SCTP_PEER_ADDR_PARAMS */ - sp->paddrparam.spp_hbinterval = jiffies_to_msecs(sctp_hb_interval); - sp->paddrparam.spp_pathmaxrxt = sctp_max_retrans_path; + sp->hbinterval = jiffies_to_msecs(sctp_hb_interval); + sp->pathmaxrxt = sctp_max_retrans_path; + sp->pathmtu = 0; // allow default discovery + sp->sackdelay = sctp_sack_timeout; + sp->param_flags = SPP_HB_ENABLE | + SPP_PMTUD_ENABLE | + SPP_SACKDELAY_ENABLE; /* If enabled no SCTP message fragmentation will be performed. * Configure through SCTP_DISABLE_FRAGMENTS socket option. @@ -2865,7 +3039,7 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len, status.sstat_primary.spinfo_cwnd = transport->cwnd; status.sstat_primary.spinfo_srtt = transport->srtt; status.sstat_primary.spinfo_rto = jiffies_to_msecs(transport->rto); - status.sstat_primary.spinfo_mtu = transport->pmtu; + status.sstat_primary.spinfo_mtu = transport->pathmtu; if (status.sstat_primary.spinfo_state == SCTP_UNKNOWN) status.sstat_primary.spinfo_state = SCTP_ACTIVE; @@ -2924,7 +3098,7 @@ static int sctp_getsockopt_peer_addr_info(struct sock *sk, int len, pinfo.spinfo_cwnd = transport->cwnd; pinfo.spinfo_srtt = transport->srtt; pinfo.spinfo_rto = jiffies_to_msecs(transport->rto); - pinfo.spinfo_mtu = transport->pmtu; + pinfo.spinfo_mtu = transport->pathmtu; if (pinfo.spinfo_state == SCTP_UNKNOWN) pinfo.spinfo_state = SCTP_ACTIVE; @@ -3086,69 +3260,154 @@ out: * address's parameters: * * struct sctp_paddrparams { - * sctp_assoc_t spp_assoc_id; - * struct sockaddr_storage spp_address; - * uint32_t spp_hbinterval; - * uint16_t spp_pathmaxrxt; - * }; - * - * spp_assoc_id - (UDP style socket) This is filled in the application, - * and identifies the association for this query. + * sctp_assoc_t spp_assoc_id; + * struct sockaddr_storage spp_address; + * uint32_t spp_hbinterval; + * uint16_t spp_pathmaxrxt; + * uint32_t spp_pathmtu; + * uint32_t spp_sackdelay; + * uint32_t spp_flags; + * }; + * + * spp_assoc_id - (one-to-many style socket) This is filled in the + * application, and identifies the association for + * this query. * spp_address - This specifies which address is of interest. * spp_hbinterval - This contains the value of the heartbeat interval, - * in milliseconds. A value of 0, when modifying the - * parameter, specifies that the heartbeat on this - * address should be disabled. A value of UINT32_MAX - * (4294967295), when modifying the parameter, - * specifies that a heartbeat should be sent - * immediately to the peer address, and the current - * interval should remain unchanged. + * in milliseconds. If a value of zero + * is present in this field then no changes are to + * be made to this parameter. * spp_pathmaxrxt - This contains the maximum number of * retransmissions before this address shall be - * considered unreachable. + * considered unreachable. If a value of zero + * is present in this field then no changes are to + * be made to this parameter. + * spp_pathmtu - When Path MTU discovery is disabled the value + * specified here will be the "fixed" path mtu. + * Note that if the spp_address field is empty + * then all associations on this address will + * have this fixed path mtu set upon them. + * + * spp_sackdelay - When delayed sack is enabled, this value specifies + * the number of milliseconds that sacks will be delayed + * for. This value will apply to all addresses of an + * association if the spp_address field is empty. Note + * also, that if delayed sack is enabled and this + * value is set to 0, no change is made to the last + * recorded delayed sack timer value. + * + * spp_flags - These flags are used to control various features + * on an association. The flag field may contain + * zero or more of the following options. + * + * SPP_HB_ENABLE - Enable heartbeats on the + * specified address. Note that if the address + * field is empty all addresses for the association + * have heartbeats enabled upon them. + * + * SPP_HB_DISABLE - Disable heartbeats on the + * speicifed address. Note that if the address + * field is empty all addresses for the association + * will have their heartbeats disabled. Note also + * that SPP_HB_ENABLE and SPP_HB_DISABLE are + * mutually exclusive, only one of these two should + * be specified. Enabling both fields will have + * undetermined results. + * + * SPP_HB_DEMAND - Request a user initiated heartbeat + * to be made immediately. + * + * SPP_PMTUD_ENABLE - This field will enable PMTU + * discovery upon the specified address. Note that + * if the address feild is empty then all addresses + * on the association are effected. + * + * SPP_PMTUD_DISABLE - This field will disable PMTU + * discovery upon the specified address. Note that + * if the address feild is empty then all addresses + * on the association are effected. Not also that + * SPP_PMTUD_ENABLE and SPP_PMTUD_DISABLE are mutually + * exclusive. Enabling both will have undetermined + * results. + * + * SPP_SACKDELAY_ENABLE - Setting this flag turns + * on delayed sack. The time specified in spp_sackdelay + * is used to specify the sack delay for this address. Note + * that if spp_address is empty then all addresses will + * enable delayed sack and take on the sack delay + * value specified in spp_sackdelay. + * SPP_SACKDELAY_DISABLE - Setting this flag turns + * off delayed sack. If the spp_address field is blank then + * delayed sack is disabled for the entire association. Note + * also that this field is mutually exclusive to + * SPP_SACKDELAY_ENABLE, setting both will have undefined + * results. */ static int sctp_getsockopt_peer_addr_params(struct sock *sk, int len, - char __user *optval, int __user *optlen) + char __user *optval, int __user *optlen) { - struct sctp_paddrparams params; - struct sctp_transport *trans; + struct sctp_paddrparams params; + struct sctp_transport *trans = NULL; + struct sctp_association *asoc = NULL; + struct sctp_sock *sp = sctp_sk(sk); if (len != sizeof(struct sctp_paddrparams)) return -EINVAL; + if (copy_from_user(¶ms, optval, len)) return -EFAULT; - /* If no association id is specified retrieve the default value - * for the endpoint that will be used for all future associations + /* If an address other than INADDR_ANY is specified, and + * no transport is found, then the request is invalid. */ - if (!params.spp_assoc_id && - sctp_is_any(( union sctp_addr *)¶ms.spp_address)) { - params.spp_hbinterval = sctp_sk(sk)->paddrparam.spp_hbinterval; - params.spp_pathmaxrxt = sctp_sk(sk)->paddrparam.spp_pathmaxrxt; - - goto done; + if (!sctp_is_any(( union sctp_addr *)¶ms.spp_address)) { + trans = sctp_addr_id2transport(sk, ¶ms.spp_address, + params.spp_assoc_id); + if (!trans) { + SCTP_DEBUG_PRINTK("Failed no transport\n"); + return -EINVAL; + } } - trans = sctp_addr_id2transport(sk, ¶ms.spp_address, - params.spp_assoc_id); - if (!trans) - return -EINVAL; - - /* The value of the heartbeat interval, in milliseconds. A value of 0, - * when modifying the parameter, specifies that the heartbeat on this - * address should be disabled. + /* Get association, if assoc_id != 0 and the socket is a one + * to many style socket, and an association was not found, then + * the id was invalid. */ - if (!trans->hb_allowed) - params.spp_hbinterval = 0; - else - params.spp_hbinterval = jiffies_to_msecs(trans->hb_interval); + asoc = sctp_id2assoc(sk, params.spp_assoc_id); + if (!asoc && params.spp_assoc_id && sctp_style(sk, UDP)) { + SCTP_DEBUG_PRINTK("Failed no association\n"); + return -EINVAL; + } - /* spp_pathmaxrxt contains the maximum number of retransmissions - * before this address shall be considered unreachable. - */ - params.spp_pathmaxrxt = trans->max_retrans; + if (trans) { + /* Fetch transport values. */ + params.spp_hbinterval = jiffies_to_msecs(trans->hbinterval); + params.spp_pathmtu = trans->pathmtu; + params.spp_pathmaxrxt = trans->pathmaxrxt; + params.spp_sackdelay = jiffies_to_msecs(trans->sackdelay); + + /*draft-11 doesn't say what to return in spp_flags*/ + params.spp_flags = trans->param_flags; + } else if (asoc) { + /* Fetch association values. */ + params.spp_hbinterval = jiffies_to_msecs(asoc->hbinterval); + params.spp_pathmtu = asoc->pathmtu; + params.spp_pathmaxrxt = asoc->pathmaxrxt; + params.spp_sackdelay = jiffies_to_msecs(asoc->sackdelay); + + /*draft-11 doesn't say what to return in spp_flags*/ + params.spp_flags = asoc->param_flags; + } else { + /* Fetch socket values. */ + params.spp_hbinterval = sp->hbinterval; + params.spp_pathmtu = sp->pathmtu; + params.spp_sackdelay = sp->sackdelay; + params.spp_pathmaxrxt = sp->pathmaxrxt; + + /*draft-11 doesn't say what to return in spp_flags*/ + params.spp_flags = sp->param_flags; + } -done: if (copy_to_user(optval, ¶ms, len)) return -EFAULT; diff --git a/net/sctp/transport.c b/net/sctp/transport.c index 268ddaf..68d73e2 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c @@ -86,10 +86,13 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, peer->init_sent_count = 0; peer->state = SCTP_ACTIVE; - peer->hb_allowed = 0; + peer->param_flags = SPP_HB_DISABLE | + SPP_PMTUD_ENABLE | + SPP_SACKDELAY_ENABLE; + peer->hbinterval = 0; /* Initialize the default path max_retrans. */ - peer->max_retrans = sctp_max_retrans_path; + peer->pathmaxrxt = sctp_max_retrans_path; peer->error_count = 0; INIT_LIST_HEAD(&peer->transmitted); @@ -229,10 +232,10 @@ void sctp_transport_pmtu(struct sctp_transport *transport) dst = transport->af_specific->get_dst(NULL, &transport->ipaddr, NULL); if (dst) { - transport->pmtu = dst_mtu(dst); + transport->pathmtu = dst_mtu(dst); dst_release(dst); } else - transport->pmtu = SCTP_DEFAULT_MAXSEGMENT; + transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; } /* Caches the dst entry and source address for a transport's destination @@ -254,8 +257,11 @@ void sctp_transport_route(struct sctp_transport *transport, af->get_saddr(asoc, dst, daddr, &transport->saddr); transport->dst = dst; + if ((transport->param_flags & SPP_PMTUD_DISABLE) && transport->pathmtu) { + return; + } if (dst) { - transport->pmtu = dst_mtu(dst); + transport->pathmtu = dst_mtu(dst); /* Initialize sk->sk_rcv_saddr, if the transport is the * association's active path for getsockname(). @@ -264,7 +270,7 @@ void sctp_transport_route(struct sctp_transport *transport, opt->pf->af->to_sk_saddr(&transport->saddr, asoc->base.sk); } else - transport->pmtu = SCTP_DEFAULT_MAXSEGMENT; + transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; } /* Hold a reference to a transport. */ @@ -369,7 +375,7 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport, ssthresh = transport->ssthresh; pba = transport->partial_bytes_acked; - pmtu = transport->asoc->pmtu; + pmtu = transport->asoc->pathmtu; if (cwnd <= ssthresh) { /* RFC 2960 7.2.1, sctpimpguide-05 2.14.2 When cwnd is less @@ -441,8 +447,8 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, * partial_bytes_acked = 0 */ transport->ssthresh = max(transport->cwnd/2, - 4*transport->asoc->pmtu); - transport->cwnd = transport->asoc->pmtu; + 4*transport->asoc->pathmtu); + transport->cwnd = transport->asoc->pathmtu; break; case SCTP_LOWER_CWND_FAST_RTX: @@ -459,7 +465,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, * partial_bytes_acked = 0 */ transport->ssthresh = max(transport->cwnd/2, - 4*transport->asoc->pmtu); + 4*transport->asoc->pathmtu); transport->cwnd = transport->ssthresh; break; @@ -479,7 +485,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, if ((jiffies - transport->last_time_ecne_reduced) > transport->rtt) { transport->ssthresh = max(transport->cwnd/2, - 4*transport->asoc->pmtu); + 4*transport->asoc->pathmtu); transport->cwnd = transport->ssthresh; transport->last_time_ecne_reduced = jiffies; } @@ -496,7 +502,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, */ if ((jiffies - transport->last_time_used) > transport->rto) transport->cwnd = max(transport->cwnd/2, - 4*transport->asoc->pmtu); + 4*transport->asoc->pathmtu); break; }; @@ -511,7 +517,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, unsigned long sctp_transport_timeout(struct sctp_transport *t) { unsigned long timeout; - timeout = t->hb_interval + t->rto + sctp_jitter(t->rto); + timeout = t->hbinterval + t->rto + sctp_jitter(t->rto); timeout += jiffies; return timeout; } -- cgit v1.1 From 7708610b1bff4a0ba8a73733d3c7c4bda9f94b21 Mon Sep 17 00:00:00 2001 From: Frank Filz Date: Thu, 22 Dec 2005 11:37:30 -0800 Subject: [SCTP]: Add support for SCTP_DELAYED_ACK_TIME socket option. Signed-off-by: Frank Filz Signed-off-by: Sridhar Samudrala Signed-off-by: David S. Miller --- include/net/sctp/user.h | 14 ++++ net/sctp/socket.c | 184 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h index b9052864..8a6bef6 100644 --- a/include/net/sctp/user.h +++ b/include/net/sctp/user.h @@ -93,6 +93,8 @@ enum sctp_optname { #define SCTP_STATUS SCTP_STATUS SCTP_GET_PEER_ADDR_INFO, #define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO + SCTP_DELAYED_ACK_TIME, +#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME /* Internal Socket Options. Some of the sctp library functions are * implemented using these socket options. @@ -526,6 +528,18 @@ struct sctp_paddrparams { __u32 spp_flags; } __attribute__((packed, aligned(4))); +/* 7.1.24. Delayed Ack Timer (SCTP_DELAYED_ACK_TIME) + * + * This options will get or set the delayed ack timer. The time is set + * in milliseconds. If the assoc_id is 0, then this sets or gets the + * endpoints default delayed ack timer value. If the assoc_id field is + * non-zero, then the set or get effects the specified association. + */ +struct sctp_assoc_value { + sctp_assoc_t assoc_id; + uint32_t assoc_value; +}; + /* * 7.2.2 Peer Address Information * diff --git a/net/sctp/socket.c b/net/sctp/socket.c index adb5ee6..fc04d18 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -2214,6 +2214,109 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, return 0; } +/* 7.1.24. Delayed Ack Timer (SCTP_DELAYED_ACK_TIME) + * + * This options will get or set the delayed ack timer. The time is set + * in milliseconds. If the assoc_id is 0, then this sets or gets the + * endpoints default delayed ack timer value. If the assoc_id field is + * non-zero, then the set or get effects the specified association. + * + * struct sctp_assoc_value { + * sctp_assoc_t assoc_id; + * uint32_t assoc_value; + * }; + * + * assoc_id - This parameter, indicates which association the + * user is preforming an action upon. Note that if + * this field's value is zero then the endpoints + * default value is changed (effecting future + * associations only). + * + * assoc_value - This parameter contains the number of milliseconds + * that the user is requesting the delayed ACK timer + * be set to. Note that this value is defined in + * the standard to be between 200 and 500 milliseconds. + * + * Note: a value of zero will leave the value alone, + * but disable SACK delay. A non-zero value will also + * enable SACK delay. + */ + +static int sctp_setsockopt_delayed_ack_time(struct sock *sk, + char __user *optval, int optlen) +{ + struct sctp_assoc_value params; + struct sctp_transport *trans = NULL; + struct sctp_association *asoc = NULL; + struct sctp_sock *sp = sctp_sk(sk); + + if (optlen != sizeof(struct sctp_assoc_value)) + return - EINVAL; + + if (copy_from_user(¶ms, optval, optlen)) + return -EFAULT; + + /* Validate value parameter. */ + if (params.assoc_value > 500) + return -EINVAL; + + /* Get association, if assoc_id != 0 and the socket is a one + * to many style socket, and an association was not found, then + * the id was invalid. + */ + asoc = sctp_id2assoc(sk, params.assoc_id); + if (!asoc && params.assoc_id && sctp_style(sk, UDP)) + return -EINVAL; + + if (params.assoc_value) { + if (asoc) { + asoc->sackdelay = + msecs_to_jiffies(params.assoc_value); + asoc->param_flags = + (asoc->param_flags & ~SPP_SACKDELAY) | + SPP_SACKDELAY_ENABLE; + } else { + sp->sackdelay = params.assoc_value; + sp->param_flags = + (sp->param_flags & ~SPP_SACKDELAY) | + SPP_SACKDELAY_ENABLE; + } + } else { + if (asoc) { + asoc->param_flags = + (asoc->param_flags & ~SPP_SACKDELAY) | + SPP_SACKDELAY_DISABLE; + } else { + sp->param_flags = + (sp->param_flags & ~SPP_SACKDELAY) | + SPP_SACKDELAY_DISABLE; + } + } + + /* If change is for association, also apply to each transport. */ + if (asoc) { + struct list_head *pos; + + list_for_each(pos, &asoc->peer.transport_addr_list) { + trans = list_entry(pos, struct sctp_transport, + transports); + if (params.assoc_value) { + trans->sackdelay = + msecs_to_jiffies(params.assoc_value); + trans->param_flags = + (trans->param_flags & ~SPP_SACKDELAY) | + SPP_SACKDELAY_ENABLE; + } else { + trans->param_flags = + (trans->param_flags & ~SPP_SACKDELAY) | + SPP_SACKDELAY_DISABLE; + } + } + } + + return 0; +} + /* 7.1.3 Initialization Parameters (SCTP_INITMSG) * * Applications can specify protocol parameters for the default association @@ -2660,6 +2763,10 @@ SCTP_STATIC int sctp_setsockopt(struct sock *sk, int level, int optname, retval = sctp_setsockopt_peer_addr_params(sk, optval, optlen); break; + case SCTP_DELAYED_ACK_TIME: + retval = sctp_setsockopt_delayed_ack_time(sk, optval, optlen); + break; + case SCTP_INITMSG: retval = sctp_setsockopt_initmsg(sk, optval, optlen); break; @@ -3417,6 +3524,79 @@ static int sctp_getsockopt_peer_addr_params(struct sock *sk, int len, return 0; } +/* 7.1.24. Delayed Ack Timer (SCTP_DELAYED_ACK_TIME) + * + * This options will get or set the delayed ack timer. The time is set + * in milliseconds. If the assoc_id is 0, then this sets or gets the + * endpoints default delayed ack timer value. If the assoc_id field is + * non-zero, then the set or get effects the specified association. + * + * struct sctp_assoc_value { + * sctp_assoc_t assoc_id; + * uint32_t assoc_value; + * }; + * + * assoc_id - This parameter, indicates which association the + * user is preforming an action upon. Note that if + * this field's value is zero then the endpoints + * default value is changed (effecting future + * associations only). + * + * assoc_value - This parameter contains the number of milliseconds + * that the user is requesting the delayed ACK timer + * be set to. Note that this value is defined in + * the standard to be between 200 and 500 milliseconds. + * + * Note: a value of zero will leave the value alone, + * but disable SACK delay. A non-zero value will also + * enable SACK delay. + */ +static int sctp_getsockopt_delayed_ack_time(struct sock *sk, int len, + char __user *optval, + int __user *optlen) +{ + struct sctp_assoc_value params; + struct sctp_association *asoc = NULL; + struct sctp_sock *sp = sctp_sk(sk); + + if (len != sizeof(struct sctp_assoc_value)) + return - EINVAL; + + if (copy_from_user(¶ms, optval, len)) + return -EFAULT; + + /* Get association, if assoc_id != 0 and the socket is a one + * to many style socket, and an association was not found, then + * the id was invalid. + */ + asoc = sctp_id2assoc(sk, params.assoc_id); + if (!asoc && params.assoc_id && sctp_style(sk, UDP)) + return -EINVAL; + + if (asoc) { + /* Fetch association values. */ + if (asoc->param_flags & SPP_SACKDELAY_ENABLE) + params.assoc_value = jiffies_to_msecs( + asoc->sackdelay); + else + params.assoc_value = 0; + } else { + /* Fetch socket values. */ + if (sp->param_flags & SPP_SACKDELAY_ENABLE) + params.assoc_value = sp->sackdelay; + else + params.assoc_value = 0; + } + + if (copy_to_user(optval, ¶ms, len)) + return -EFAULT; + + if (put_user(len, optlen)) + return -EFAULT; + + return 0; +} + /* 7.1.3 Initialization Parameters (SCTP_INITMSG) * * Applications can specify protocol parameters for the default association @@ -4274,6 +4454,10 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, retval = sctp_getsockopt_peer_addr_params(sk, len, optval, optlen); break; + case SCTP_DELAYED_ACK_TIME: + retval = sctp_getsockopt_delayed_ack_time(sk, len, optval, + optlen); + break; case SCTP_INITMSG: retval = sctp_getsockopt_initmsg(sk, len, optval, optlen); break; -- cgit v1.1 From 77d76ea310b50a9c8ff15bd290fcb4ed4961adf2 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Thu, 22 Dec 2005 12:43:42 -0800 Subject: [NET]: Small cleanup to socket initialization sock_init can be done as a core_initcall instead of calling it directly in init/main.c Also I removed an out of date #ifdef. Signed-off-by: Andi Kleen Signed-off-by: David S. Miller --- include/linux/skbuff.h | 1 - include/linux/socket.h | 1 - init/main.c | 4 ---- net/socket.c | 10 +++++----- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 97f6580..9716771 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -32,7 +32,6 @@ #define HAVE_ALLOC_SKB /* For the drivers to know */ #define HAVE_ALIGNABLE_SKB /* Ditto 8) */ -#define SLAB_SKB /* Slabified skbuffs */ #define CHECKSUM_NONE 0 #define CHECKSUM_HW 1 diff --git a/include/linux/socket.h b/include/linux/socket.h index 1739c2d..9f40191 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -27,7 +27,6 @@ struct __kernel_sockaddr_storage { #include /* __user */ extern int sysctl_somaxconn; -extern void sock_init(void); #ifdef CONFIG_PROC_FS struct seq_file; extern void socket_seq_show(struct seq_file *seq); diff --git a/init/main.c b/init/main.c index 27f97f9..54aaf56 100644 --- a/init/main.c +++ b/init/main.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -614,9 +613,6 @@ static void __init do_basic_setup(void) sysctl_init(); #endif - /* Networking initialization needs a process context */ - sock_init(); - do_initcalls(); } diff --git a/net/socket.c b/net/socket.c index 3145103..98be7ef 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2036,7 +2036,7 @@ int sock_unregister(int family) return 0; } -void __init sock_init(void) +static int __init sock_init(void) { /* * Initialize sock SLAB cache. @@ -2044,12 +2044,10 @@ void __init sock_init(void) sk_init(); -#ifdef SLAB_SKB /* * Initialize skbuff SLAB cache */ skb_init(); -#endif /* * Initialize the protocols module. @@ -2058,8 +2056,8 @@ void __init sock_init(void) init_inodecache(); register_filesystem(&sock_fs_type); sock_mnt = kern_mount(&sock_fs_type); - /* The real protocol initialization is performed when - * do_initcalls is run. + + /* The real protocol initialization is performed in later initcalls. */ #ifdef CONFIG_NETFILTER @@ -2067,6 +2065,8 @@ void __init sock_init(void) #endif } +core_initcall(sock_init); /* early initcall */ + #ifdef CONFIG_PROC_FS void socket_seq_show(struct seq_file *seq) { -- cgit v1.1 From 90ddc4f0470427df306f308ad03db6b6b21644b8 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Thu, 22 Dec 2005 12:49:22 -0800 Subject: [NET]: move struct proto_ops to const I noticed that some of 'struct proto_ops' used in the kernel may share a cache line used by locks or other heavily modified data. (default linker alignement is 32 bytes, and L1_CACHE_LINE is 64 or 128 at least) This patch makes sure a 'struct proto_ops' can be declared as const, so that all cpus can share all parts of it without false sharing. This is not mandatory : a driver can still use a read/write structure if it needs to (and eventually a __read_mostly) I made a global stubstitute to change all existing occurences to make them const. This should reduce the possibility of false sharing on SMP, and speedup some socket system calls. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller --- include/linux/net.h | 4 ++-- include/net/inet_common.h | 4 ++-- include/net/ipv6.h | 4 ++-- include/net/protocol.h | 2 +- net/appletalk/ddp.c | 4 ++-- net/atm/pvc.c | 2 +- net/atm/svc.c | 2 +- net/ax25/af_ax25.c | 4 ++-- net/bluetooth/bnep/sock.c | 2 +- net/bluetooth/cmtp/sock.c | 2 +- net/bluetooth/hci_sock.c | 2 +- net/bluetooth/hidp/sock.c | 2 +- net/bluetooth/l2cap.c | 4 ++-- net/bluetooth/rfcomm/sock.c | 4 ++-- net/bluetooth/sco.c | 4 ++-- net/dccp/proto.c | 2 +- net/decnet/af_decnet.c | 4 ++-- net/econet/af_econet.c | 4 ++-- net/ipv4/af_inet.c | 6 +++--- net/ipv6/af_inet6.c | 6 +++--- net/ipx/af_ipx.c | 4 ++-- net/irda/af_irda.c | 16 ++++++++-------- net/key/af_key.c | 4 ++-- net/llc/af_llc.c | 4 ++-- net/netlink/af_netlink.c | 4 ++-- net/netrom/af_netrom.c | 4 ++-- net/packet/af_packet.c | 8 ++++---- net/sctp/ipv6.c | 2 +- net/sctp/protocol.c | 2 +- net/sunrpc/svcsock.c | 2 +- net/unix/af_unix.c | 6 +++--- net/wanrouter/af_wanpipe.c | 4 ++-- net/x25/af_x25.c | 4 ++-- 33 files changed, 66 insertions(+), 66 deletions(-) diff --git a/include/linux/net.h b/include/linux/net.h index d6a41e6..28195a2 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -107,7 +107,7 @@ enum sock_type { struct socket { socket_state state; unsigned long flags; - struct proto_ops *ops; + const struct proto_ops *ops; struct fasync_struct *fasync_list; struct file *file; struct sock *sk; @@ -260,7 +260,7 @@ SOCKCALL_WRAP(name, recvmsg, (struct kiocb *iocb, struct socket *sock, struct ms SOCKCALL_WRAP(name, mmap, (struct file *file, struct socket *sock, struct vm_area_struct *vma), \ (file, sock, vma)) \ \ -static struct proto_ops name##_ops = { \ +static const struct proto_ops name##_ops = { \ .family = fam, \ .owner = THIS_MODULE, \ .release = __lock_##name##_release, \ diff --git a/include/net/inet_common.h b/include/net/inet_common.h index f943306..227adcb 100644 --- a/include/net/inet_common.h +++ b/include/net/inet_common.h @@ -1,8 +1,8 @@ #ifndef _INET_COMMON_H #define _INET_COMMON_H -extern struct proto_ops inet_stream_ops; -extern struct proto_ops inet_dgram_ops; +extern const struct proto_ops inet_stream_ops; +extern const struct proto_ops inet_dgram_ops; /* * INET4 prototypes used by INET6 diff --git a/include/net/ipv6.h b/include/net/ipv6.h index e3d5d7b..11a7256 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -538,8 +538,8 @@ extern int sysctl_ip6frag_low_thresh; extern int sysctl_ip6frag_time; extern int sysctl_ip6frag_secret_interval; -extern struct proto_ops inet6_stream_ops; -extern struct proto_ops inet6_dgram_ops; +extern const struct proto_ops inet6_stream_ops; +extern const struct proto_ops inet6_dgram_ops; extern int ip6_mc_source(int add, int omode, struct sock *sk, struct group_source_req *pgsr); diff --git a/include/net/protocol.h b/include/net/protocol.h index a29cb29..63f7db9 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h @@ -65,7 +65,7 @@ struct inet_protosw { int protocol; /* This is the L4 protocol number. */ struct proto *prot; - struct proto_ops *ops; + const struct proto_ops *ops; int capability; /* Which (if any) capability do * we need to use this socket diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 7982656..296f186 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -63,7 +63,7 @@ #include struct datalink_proto *ddp_dl, *aarp_dl; -static struct proto_ops atalk_dgram_ops; +static const struct proto_ops atalk_dgram_ops; /**************************************************************************\ * * @@ -1841,7 +1841,7 @@ static struct net_proto_family atalk_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops) = { +static const struct proto_ops SOCKOPS_WRAPPED(atalk_dgram_ops) = { .family = PF_APPLETALK, .owner = THIS_MODULE, .release = atalk_release, diff --git a/net/atm/pvc.c b/net/atm/pvc.c index 2684a92..f2c5417 100644 --- a/net/atm/pvc.c +++ b/net/atm/pvc.c @@ -102,7 +102,7 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr, } -static struct proto_ops pvc_proto_ops = { +static const struct proto_ops pvc_proto_ops = { .family = PF_ATMPVC, .owner = THIS_MODULE, diff --git a/net/atm/svc.c b/net/atm/svc.c index d7b2661..3a180cfd 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c @@ -613,7 +613,7 @@ static int svc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return error; } -static struct proto_ops svc_proto_ops = { +static const struct proto_ops svc_proto_ops = { .family = PF_ATMSVC, .owner = THIS_MODULE, diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 1b683f3..8b5d10a 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -54,7 +54,7 @@ HLIST_HEAD(ax25_list); DEFINE_SPINLOCK(ax25_list_lock); -static struct proto_ops ax25_proto_ops; +static const struct proto_ops ax25_proto_ops; static void ax25_free_sock(struct sock *sk) { @@ -1944,7 +1944,7 @@ static struct net_proto_family ax25_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops ax25_proto_ops = { +static const struct proto_ops ax25_proto_ops = { .family = PF_AX25, .owner = THIS_MODULE, .release = ax25_release, diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c index 9778c6a..ccbaf69 100644 --- a/net/bluetooth/bnep/sock.c +++ b/net/bluetooth/bnep/sock.c @@ -146,7 +146,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long return 0; } -static struct proto_ops bnep_sock_ops = { +static const struct proto_ops bnep_sock_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .release = bnep_sock_release, diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c index beb045b..5e22343 100644 --- a/net/bluetooth/cmtp/sock.c +++ b/net/bluetooth/cmtp/sock.c @@ -137,7 +137,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long return -EINVAL; } -static struct proto_ops cmtp_sock_ops = { +static const struct proto_ops cmtp_sock_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .release = cmtp_sock_release, diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 1d6d0a1..84e6c93 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c @@ -575,7 +575,7 @@ static int hci_sock_getsockopt(struct socket *sock, int level, int optname, char return 0; } -static struct proto_ops hci_sock_ops = { +static const struct proto_ops hci_sock_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .release = hci_sock_release, diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c index f8986f8..8f8dd93 100644 --- a/net/bluetooth/hidp/sock.c +++ b/net/bluetooth/hidp/sock.c @@ -143,7 +143,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long return -EINVAL; } -static struct proto_ops hidp_sock_ops = { +static const struct proto_ops hidp_sock_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .release = hidp_sock_release, diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index 95f33cc..7f0781e 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c @@ -57,7 +57,7 @@ #define VERSION "2.8" -static struct proto_ops l2cap_sock_ops; +static const struct proto_ops l2cap_sock_ops; static struct bt_sock_list l2cap_sk_list = { .lock = RW_LOCK_UNLOCKED @@ -2161,7 +2161,7 @@ static ssize_t l2cap_sysfs_show(struct class *dev, char *buf) static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); -static struct proto_ops l2cap_sock_ops = { +static const struct proto_ops l2cap_sock_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .release = l2cap_sock_release, diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 6c34261..757d2dd 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c @@ -58,7 +58,7 @@ #define BT_DBG(D...) #endif -static struct proto_ops rfcomm_sock_ops; +static const struct proto_ops rfcomm_sock_ops; static struct bt_sock_list rfcomm_sk_list = { .lock = RW_LOCK_UNLOCKED @@ -907,7 +907,7 @@ static ssize_t rfcomm_sock_sysfs_show(struct class *dev, char *buf) static CLASS_ATTR(rfcomm, S_IRUGO, rfcomm_sock_sysfs_show, NULL); -static struct proto_ops rfcomm_sock_ops = { +static const struct proto_ops rfcomm_sock_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .release = rfcomm_sock_release, diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 6481814..6b61323 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -56,7 +56,7 @@ #define VERSION "0.5" -static struct proto_ops sco_sock_ops; +static const struct proto_ops sco_sock_ops; static struct bt_sock_list sco_sk_list = { .lock = RW_LOCK_UNLOCKED @@ -914,7 +914,7 @@ static ssize_t sco_sysfs_show(struct class *dev, char *buf) static CLASS_ATTR(sco, S_IRUGO, sco_sysfs_show, NULL); -static struct proto_ops sco_sock_ops = { +static const struct proto_ops sco_sock_ops = { .family = PF_BLUETOOTH, .owner = THIS_MODULE, .release = sco_sock_release, diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 40a4c68..e4e629e 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -680,7 +680,7 @@ void dccp_shutdown(struct sock *sk, int how) EXPORT_SYMBOL_GPL(dccp_shutdown); -static struct proto_ops inet_dccp_ops = { +static const struct proto_ops inet_dccp_ops = { .family = PF_INET, .owner = THIS_MODULE, .release = inet_release, diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index d402e90..65e3bae 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -149,7 +149,7 @@ static void dn_keepalive(struct sock *sk); #define DN_SK_HASH_MASK (DN_SK_HASH_SIZE - 1) -static struct proto_ops dn_proto_ops; +static const struct proto_ops dn_proto_ops; static DEFINE_RWLOCK(dn_hash_lock); static struct hlist_head dn_sk_hash[DN_SK_HASH_SIZE]; static struct hlist_head dn_wild_sk; @@ -2342,7 +2342,7 @@ static struct net_proto_family dn_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops dn_proto_ops = { +static const struct proto_ops dn_proto_ops = { .family = AF_DECnet, .owner = THIS_MODULE, .release = dn_release, diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 34fdac5..ff58f49 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c @@ -45,7 +45,7 @@ #include #include -static struct proto_ops econet_ops; +static const struct proto_ops econet_ops; static struct hlist_head econet_sklist; static DEFINE_RWLOCK(econet_lock); @@ -698,7 +698,7 @@ static struct net_proto_family econet_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops SOCKOPS_WRAPPED(econet_ops) = { +static const struct proto_ops SOCKOPS_WRAPPED(econet_ops) = { .family = PF_ECONET, .owner = THIS_MODULE, .release = econet_release, diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 617e858..4ed8a81 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -785,7 +785,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return err; } -struct proto_ops inet_stream_ops = { +const struct proto_ops inet_stream_ops = { .family = PF_INET, .owner = THIS_MODULE, .release = inet_release, @@ -806,7 +806,7 @@ struct proto_ops inet_stream_ops = { .sendpage = tcp_sendpage }; -struct proto_ops inet_dgram_ops = { +const struct proto_ops inet_dgram_ops = { .family = PF_INET, .owner = THIS_MODULE, .release = inet_release, @@ -831,7 +831,7 @@ struct proto_ops inet_dgram_ops = { * For SOCK_RAW sockets; should be the same as inet_dgram_ops but without * udp_poll */ -static struct proto_ops inet_sockraw_ops = { +static const struct proto_ops inet_sockraw_ops = { .family = PF_INET, .owner = THIS_MODULE, .release = inet_release, diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 70a510f..7c9f192 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -462,7 +462,7 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return(0); } -struct proto_ops inet6_stream_ops = { +const struct proto_ops inet6_stream_ops = { .family = PF_INET6, .owner = THIS_MODULE, .release = inet6_release, @@ -483,7 +483,7 @@ struct proto_ops inet6_stream_ops = { .sendpage = tcp_sendpage }; -struct proto_ops inet6_dgram_ops = { +const struct proto_ops inet6_dgram_ops = { .family = PF_INET6, .owner = THIS_MODULE, .release = inet6_release, @@ -511,7 +511,7 @@ static struct net_proto_family inet6_family_ops = { }; /* Same as inet6_dgram_ops, sans udp_poll. */ -static struct proto_ops inet6_sockraw_ops = { +static const struct proto_ops inet6_sockraw_ops = { .family = PF_INET6, .owner = THIS_MODULE, .release = inet6_release, diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index 34b3bb8..6c464c1 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -75,7 +75,7 @@ static struct datalink_proto *pEII_datalink; static struct datalink_proto *p8023_datalink; static struct datalink_proto *pSNAP_datalink; -static struct proto_ops ipx_dgram_ops; +static const struct proto_ops ipx_dgram_ops; LIST_HEAD(ipx_interfaces); DEFINE_SPINLOCK(ipx_interfaces_lock); @@ -1901,7 +1901,7 @@ static struct net_proto_family ipx_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops SOCKOPS_WRAPPED(ipx_dgram_ops) = { +static const struct proto_ops SOCKOPS_WRAPPED(ipx_dgram_ops) = { .family = PF_IPX, .owner = THIS_MODULE, .release = ipx_release, diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index f121f7d..e57683d 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c @@ -62,12 +62,12 @@ static int irda_create(struct socket *sock, int protocol); -static struct proto_ops irda_stream_ops; -static struct proto_ops irda_seqpacket_ops; -static struct proto_ops irda_dgram_ops; +static const struct proto_ops irda_stream_ops; +static const struct proto_ops irda_seqpacket_ops; +static const struct proto_ops irda_dgram_ops; #ifdef CONFIG_IRDA_ULTRA -static struct proto_ops irda_ultra_ops; +static const struct proto_ops irda_ultra_ops; #define ULTRA_MAX_DATA 382 #endif /* CONFIG_IRDA_ULTRA */ @@ -2464,7 +2464,7 @@ static struct net_proto_family irda_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = { +static const struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = { .family = PF_IRDA, .owner = THIS_MODULE, .release = irda_release, @@ -2485,7 +2485,7 @@ static struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = { .sendpage = sock_no_sendpage, }; -static struct proto_ops SOCKOPS_WRAPPED(irda_seqpacket_ops) = { +static const struct proto_ops SOCKOPS_WRAPPED(irda_seqpacket_ops) = { .family = PF_IRDA, .owner = THIS_MODULE, .release = irda_release, @@ -2506,7 +2506,7 @@ static struct proto_ops SOCKOPS_WRAPPED(irda_seqpacket_ops) = { .sendpage = sock_no_sendpage, }; -static struct proto_ops SOCKOPS_WRAPPED(irda_dgram_ops) = { +static const struct proto_ops SOCKOPS_WRAPPED(irda_dgram_ops) = { .family = PF_IRDA, .owner = THIS_MODULE, .release = irda_release, @@ -2528,7 +2528,7 @@ static struct proto_ops SOCKOPS_WRAPPED(irda_dgram_ops) = { }; #ifdef CONFIG_IRDA_ULTRA -static struct proto_ops SOCKOPS_WRAPPED(irda_ultra_ops) = { +static const struct proto_ops SOCKOPS_WRAPPED(irda_ultra_ops) = { .family = PF_IRDA, .owner = THIS_MODULE, .release = irda_release, diff --git a/net/key/af_key.c b/net/key/af_key.c index d32f779..52efd04 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -113,7 +113,7 @@ static __inline__ void pfkey_unlock_table(void) } -static struct proto_ops pfkey_ops; +static const struct proto_ops pfkey_ops; static void pfkey_insert(struct sock *sk) { @@ -3127,7 +3127,7 @@ out: return err; } -static struct proto_ops pfkey_ops = { +static const struct proto_ops pfkey_ops = { .family = PF_KEY, .owner = THIS_MODULE, /* Operations that make no sense on pfkey sockets. */ diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index b6d3df5..9cf65f9 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -36,7 +36,7 @@ static u16 llc_ui_sap_last_autoport = LLC_SAP_DYN_START; static u16 llc_ui_sap_link_no_max[256]; static struct sockaddr_llc llc_ui_addrnull; -static struct proto_ops llc_ui_ops; +static const struct proto_ops llc_ui_ops; static int llc_ui_wait_for_conn(struct sock *sk, long timeout); static int llc_ui_wait_for_disc(struct sock *sk, long timeout); @@ -1098,7 +1098,7 @@ static struct net_proto_family llc_ui_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops llc_ui_ops = { +static const struct proto_ops llc_ui_ops = { .family = PF_LLC, .owner = THIS_MODULE, .release = llc_ui_release, diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 96020d7..7849cac 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -293,7 +293,7 @@ static inline int nl_pid_hash_dilute(struct nl_pid_hash *hash, int len) return 0; } -static struct proto_ops netlink_ops; +static const struct proto_ops netlink_ops; static int netlink_insert(struct sock *sk, u32 pid) { @@ -1656,7 +1656,7 @@ int netlink_unregister_notifier(struct notifier_block *nb) return notifier_chain_unregister(&netlink_chain, nb); } -static struct proto_ops netlink_ops = { +static const struct proto_ops netlink_ops = { .family = PF_NETLINK, .owner = THIS_MODULE, .release = netlink_release, diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index e5d82d7..05b653c 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -63,7 +63,7 @@ static unsigned short circuit = 0x101; static HLIST_HEAD(nr_list); static DEFINE_SPINLOCK(nr_list_lock); -static struct proto_ops nr_proto_ops; +static const struct proto_ops nr_proto_ops; /* * Socket removal during an interrupt is now safe. @@ -1337,7 +1337,7 @@ static struct net_proto_family nr_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops nr_proto_ops = { +static const struct proto_ops nr_proto_ops = { .family = PF_NETROM, .owner = THIS_MODULE, .release = nr_release, diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 3e24627..deda6fd 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -251,10 +251,10 @@ static void packet_sock_destruct(struct sock *sk) } -static struct proto_ops packet_ops; +static const struct proto_ops packet_ops; #ifdef CONFIG_SOCK_PACKET -static struct proto_ops packet_ops_spkt; +static const struct proto_ops packet_ops_spkt; static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { @@ -1784,7 +1784,7 @@ out: #ifdef CONFIG_SOCK_PACKET -static struct proto_ops packet_ops_spkt = { +static const struct proto_ops packet_ops_spkt = { .family = PF_PACKET, .owner = THIS_MODULE, .release = packet_release, @@ -1806,7 +1806,7 @@ static struct proto_ops packet_ops_spkt = { }; #endif -static struct proto_ops packet_ops = { +static const struct proto_ops packet_ops = { .family = PF_PACKET, .owner = THIS_MODULE, .release = packet_release, diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index fa3be2b..15c0516 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -866,7 +866,7 @@ static int sctp_inet6_supported_addrs(const struct sctp_sock *opt, return 2; } -static struct proto_ops inet6_seqpacket_ops = { +static const struct proto_ops inet6_seqpacket_ops = { .family = PF_INET6, .owner = THIS_MODULE, .release = inet6_release, diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index f775d78..d1b0747 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -829,7 +829,7 @@ static struct notifier_block sctp_inetaddr_notifier = { }; /* Socket operations. */ -static struct proto_ops inet_seqpacket_ops = { +static const struct proto_ops inet_seqpacket_ops = { .family = PF_INET, .owner = THIS_MODULE, .release = inet_release, /* Needs to be wrapped... */ diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index c6a5191..d68eba4 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -758,7 +758,7 @@ svc_tcp_accept(struct svc_sock *svsk) struct svc_serv *serv = svsk->sk_server; struct socket *sock = svsk->sk_sock; struct socket *newsock; - struct proto_ops *ops; + const struct proto_ops *ops; struct svc_sock *newsvsk; int err, slen; diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 04e850e..7d3fe6a 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -473,7 +473,7 @@ static int unix_dgram_connect(struct socket *, struct sockaddr *, static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *, struct msghdr *, size_t); -static struct proto_ops unix_stream_ops = { +static const struct proto_ops unix_stream_ops = { .family = PF_UNIX, .owner = THIS_MODULE, .release = unix_release, @@ -494,7 +494,7 @@ static struct proto_ops unix_stream_ops = { .sendpage = sock_no_sendpage, }; -static struct proto_ops unix_dgram_ops = { +static const struct proto_ops unix_dgram_ops = { .family = PF_UNIX, .owner = THIS_MODULE, .release = unix_release, @@ -515,7 +515,7 @@ static struct proto_ops unix_dgram_ops = { .sendpage = sock_no_sendpage, }; -static struct proto_ops unix_seqpacket_ops = { +static const struct proto_ops unix_seqpacket_ops = { .family = PF_UNIX, .owner = THIS_MODULE, .release = unix_release, diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c index 59fec59..67948bf 100644 --- a/net/wanrouter/af_wanpipe.c +++ b/net/wanrouter/af_wanpipe.c @@ -181,7 +181,7 @@ struct wanpipe_opt #endif static int sk_count; -extern struct proto_ops wanpipe_ops; +extern const struct proto_ops wanpipe_ops; static unsigned long find_free_critical; static void wanpipe_unlink_driver(struct sock *sk); @@ -2546,7 +2546,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr return 0; } -struct proto_ops wanpipe_ops = { +const struct proto_ops wanpipe_ops = { .family = PF_WANPIPE, .owner = THIS_MODULE, .release = wanpipe_release, diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 020d73c..ca8b3b0 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -64,7 +64,7 @@ int sysctl_x25_ack_holdback_timeout = X25_DEFAULT_T2; HLIST_HEAD(x25_list); DEFINE_RWLOCK(x25_list_lock); -static struct proto_ops x25_proto_ops; +static const struct proto_ops x25_proto_ops; static struct x25_address null_x25_address = {" "}; @@ -1391,7 +1391,7 @@ static struct net_proto_family x25_family_ops = { .owner = THIS_MODULE, }; -static struct proto_ops SOCKOPS_WRAPPED(x25_proto_ops) = { +static const struct proto_ops SOCKOPS_WRAPPED(x25_proto_ops) = { .family = AF_X25, .owner = THIS_MODULE, .release = x25_release, -- cgit v1.1 From f34fbb971368c20f757f8758833a534590b16518 Mon Sep 17 00:00:00 2001 From: Jaco Kroon Date: Thu, 22 Dec 2005 12:51:46 -0800 Subject: [PKTGEN]: Deinitialise static variables. static variables should not be explicitly initialised to 0. This causes them to be placed in .data instead of .bss. This patch de-initialises 3 static variables in net/core/pktgen.c. There are approximately 800 more such variables in the source tree (2.6.15rc5). If there is more interrest I'd be willing to track down the rest of these as well and de-initialise them as well. Signed-off-by: David S. Miller --- net/core/pktgen.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 7fc3e9e..06cad2d 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -487,9 +487,9 @@ static unsigned int fmt_ip6(char *s,const char ip[16]); /* Module parameters, defaults. */ static int pg_count_d = 1000; /* 1000 pkts by default */ -static int pg_delay_d = 0; -static int pg_clone_skb_d = 0; -static int debug = 0; +static int pg_delay_d; +static int pg_clone_skb_d; +static int debug; static DECLARE_MUTEX(pktgen_sem); static struct pktgen_thread *pktgen_threads = NULL; -- cgit v1.1 From cbeb321a64af5437fbde249605b191ff0fdfa21c Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 22 Dec 2005 12:58:55 -0800 Subject: [NET]: Fix sock_init() return value. It needs to return zero now that it is an initcall. Also, net/nonet.c no longer needs a dummy sock_init(). Signed-off-by: David S. Miller --- net/nonet.c | 5 ----- net/socket.c | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/net/nonet.c b/net/nonet.c index e5241dce..1230f0a 100644 --- a/net/nonet.c +++ b/net/nonet.c @@ -14,11 +14,6 @@ #include #include -void __init sock_init(void) -{ - printk(KERN_INFO "Linux NoNET1.0 for Linux 2.6\n"); -} - static int sock_no_open(struct inode *irrelevant, struct file *dontcare) { return -ENXIO; diff --git a/net/socket.c b/net/socket.c index 98be7ef..f40957a 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2063,6 +2063,8 @@ static int __init sock_init(void) #ifdef CONFIG_NETFILTER netfilter_init(); #endif + + return 0; } core_initcall(sock_init); /* early initcall */ -- cgit v1.1 From ce1d4d3e88b3a69d23c3feb436a0b36b6ca0642b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 22 Dec 2005 21:08:46 -0800 Subject: [NET]: restructure sock_aio_{read,write} / sock_{readv,writev} Mid-term I plan to restructure the file_operations so that we don't need to have all these duplicate aio and vectored versions. This patch is a small step in that direction but also a worthwile cleanup on it's own: (1) introduce a alloc_sock_iocb helper that encapsulates allocating a proper sock_iocb (2) add do_sock_read and do_sock_write helpers for common read/write code Signed-off-by: Christoph Hellwig Signed-off-by: David S. Miller --- net/socket.c | 224 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 110 insertions(+), 114 deletions(-) diff --git a/net/socket.c b/net/socket.c index f40957a..0dde6da 100644 --- a/net/socket.c +++ b/net/socket.c @@ -640,154 +640,150 @@ static void sock_aio_dtor(struct kiocb *iocb) kfree(iocb->private); } -/* - * Read data from a socket. ubuf is a user mode pointer. We make sure the user - * area ubuf...ubuf+size-1 is writable before asking the protocol. - */ - -static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, - size_t size, loff_t pos) +static ssize_t sock_sendpage(struct file *file, struct page *page, + int offset, size_t size, loff_t *ppos, int more) { - struct sock_iocb *x, siocb; struct socket *sock; int flags; - if (pos != 0) - return -ESPIPE; - if (size==0) /* Match SYS5 behaviour */ - return 0; + sock = file->private_data; - if (is_sync_kiocb(iocb)) - x = &siocb; - else { - x = kmalloc(sizeof(struct sock_iocb), GFP_KERNEL); - if (!x) - return -ENOMEM; + flags = !(file->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT; + if (more) + flags |= MSG_MORE; + + return sock->ops->sendpage(sock, page, offset, size, flags); +} + +static struct sock_iocb *alloc_sock_iocb(struct kiocb *iocb, + char __user *ubuf, size_t size, struct sock_iocb *siocb) +{ + if (!is_sync_kiocb(iocb)) { + siocb = kmalloc(sizeof(*siocb), GFP_KERNEL); + if (!siocb) + return NULL; iocb->ki_dtor = sock_aio_dtor; } - iocb->private = x; - x->kiocb = iocb; - sock = iocb->ki_filp->private_data; - x->async_msg.msg_name = NULL; - x->async_msg.msg_namelen = 0; - x->async_msg.msg_iov = &x->async_iov; - x->async_msg.msg_iovlen = 1; - x->async_msg.msg_control = NULL; - x->async_msg.msg_controllen = 0; - x->async_iov.iov_base = ubuf; - x->async_iov.iov_len = size; - flags = !(iocb->ki_filp->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT; + siocb->kiocb = iocb; + siocb->async_iov.iov_base = ubuf; + siocb->async_iov.iov_len = size; - return __sock_recvmsg(iocb, sock, &x->async_msg, size, flags); + iocb->private = siocb; + return siocb; } +static ssize_t do_sock_read(struct msghdr *msg, struct kiocb *iocb, + struct file *file, struct iovec *iov, unsigned long nr_segs) +{ + struct socket *sock = file->private_data; + size_t size = 0; + int i; -/* - * Write data to a socket. We verify that the user area ubuf..ubuf+size-1 - * is readable by the user process. - */ + for (i = 0 ; i < nr_segs ; i++) + size += iov[i].iov_len; -static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, - size_t size, loff_t pos) + msg->msg_name = NULL; + msg->msg_namelen = 0; + msg->msg_control = NULL; + msg->msg_controllen = 0; + msg->msg_iov = (struct iovec *) iov; + msg->msg_iovlen = nr_segs; + msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; + + return __sock_recvmsg(iocb, sock, msg, size, msg->msg_flags); +} + +static ssize_t sock_readv(struct file *file, const struct iovec *iov, + unsigned long nr_segs, loff_t *ppos) { - struct sock_iocb *x, siocb; - struct socket *sock; - + struct kiocb iocb; + struct sock_iocb siocb; + struct msghdr msg; + int ret; + + init_sync_kiocb(&iocb, NULL); + iocb.private = &siocb; + + ret = do_sock_read(&msg, &iocb, file, (struct iovec *)iov, nr_segs); + if (-EIOCBQUEUED == ret) + ret = wait_on_sync_kiocb(&iocb); + return ret; +} + +static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, + size_t count, loff_t pos) +{ + struct sock_iocb siocb, *x; + if (pos != 0) return -ESPIPE; - if(size==0) /* Match SYS5 behaviour */ + if (count == 0) /* Match SYS5 behaviour */ return 0; - if (is_sync_kiocb(iocb)) - x = &siocb; - else { - x = kmalloc(sizeof(struct sock_iocb), GFP_KERNEL); - if (!x) - return -ENOMEM; - iocb->ki_dtor = sock_aio_dtor; - } - iocb->private = x; - x->kiocb = iocb; - sock = iocb->ki_filp->private_data; - - x->async_msg.msg_name = NULL; - x->async_msg.msg_namelen = 0; - x->async_msg.msg_iov = &x->async_iov; - x->async_msg.msg_iovlen = 1; - x->async_msg.msg_control = NULL; - x->async_msg.msg_controllen = 0; - x->async_msg.msg_flags = !(iocb->ki_filp->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT; - if (sock->type == SOCK_SEQPACKET) - x->async_msg.msg_flags |= MSG_EOR; - x->async_iov.iov_base = (void __user *)ubuf; - x->async_iov.iov_len = size; - - return __sock_sendmsg(iocb, sock, &x->async_msg, size); + x = alloc_sock_iocb(iocb, ubuf, count, &siocb); + if (!x) + return -ENOMEM; + return do_sock_read(&x->async_msg, iocb, iocb->ki_filp, + &x->async_iov, 1); } -static ssize_t sock_sendpage(struct file *file, struct page *page, - int offset, size_t size, loff_t *ppos, int more) +static ssize_t do_sock_write(struct msghdr *msg, struct kiocb *iocb, + struct file *file, struct iovec *iov, unsigned long nr_segs) { - struct socket *sock; - int flags; + struct socket *sock = file->private_data; + size_t size = 0; + int i; - sock = file->private_data; + for (i = 0 ; i < nr_segs ; i++) + size += iov[i].iov_len; - flags = !(file->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT; - if (more) - flags |= MSG_MORE; + msg->msg_name = NULL; + msg->msg_namelen = 0; + msg->msg_control = NULL; + msg->msg_controllen = 0; + msg->msg_iov = (struct iovec *) iov; + msg->msg_iovlen = nr_segs; + msg->msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; + if (sock->type == SOCK_SEQPACKET) + msg->msg_flags |= MSG_EOR; - return sock->ops->sendpage(sock, page, offset, size, flags); + return __sock_sendmsg(iocb, sock, msg, size); } -static int sock_readv_writev(int type, - struct file * file, const struct iovec * iov, - long count, size_t size) +static ssize_t sock_writev(struct file *file, const struct iovec *iov, + unsigned long nr_segs, loff_t *ppos) { struct msghdr msg; - struct socket *sock; + struct kiocb iocb; + struct sock_iocb siocb; + int ret; - sock = file->private_data; + init_sync_kiocb(&iocb, NULL); + iocb.private = &siocb; - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_control = NULL; - msg.msg_controllen = 0; - msg.msg_iov = (struct iovec *) iov; - msg.msg_iovlen = count; - msg.msg_flags = (file->f_flags & O_NONBLOCK) ? MSG_DONTWAIT : 0; + ret = do_sock_write(&msg, &iocb, file, (struct iovec *)iov, nr_segs); + if (-EIOCBQUEUED == ret) + ret = wait_on_sync_kiocb(&iocb); + return ret; +} - /* read() does a VERIFY_WRITE */ - if (type == VERIFY_WRITE) - return sock_recvmsg(sock, &msg, size, msg.msg_flags); +static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, + size_t count, loff_t pos) +{ + struct sock_iocb siocb, *x; - if (sock->type == SOCK_SEQPACKET) - msg.msg_flags |= MSG_EOR; + if (pos != 0) + return -ESPIPE; + if (count == 0) /* Match SYS5 behaviour */ + return 0; - return sock_sendmsg(sock, &msg, size); -} + x = alloc_sock_iocb(iocb, (void __user *)ubuf, count, &siocb); + if (!x) + return -ENOMEM; -static ssize_t sock_readv(struct file *file, const struct iovec *vector, - unsigned long count, loff_t *ppos) -{ - size_t tot_len = 0; - int i; - for (i = 0 ; i < count ; i++) - tot_len += vector[i].iov_len; - return sock_readv_writev(VERIFY_WRITE, - file, vector, count, tot_len); -} - -static ssize_t sock_writev(struct file *file, const struct iovec *vector, - unsigned long count, loff_t *ppos) -{ - size_t tot_len = 0; - int i; - for (i = 0 ; i < count ; i++) - tot_len += vector[i].iov_len; - return sock_readv_writev(VERIFY_READ, - file, vector, count, tot_len); + return do_sock_write(&x->async_msg, iocb, iocb->ki_filp, + &x->async_iov, 1); } -- cgit v1.1 From 25995ff577675b58dbd848b7758e7bad87411947 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 27 Dec 2005 02:42:22 -0200 Subject: [SOCK]: Introduce sk_receive_skb Its common enough to to justify that, TCP still can't use it as it has the prequeueing stuff, still to be made generic in the not so distant future :-) Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- drivers/net/pppoe.c | 22 ++-------------------- include/net/sock.h | 23 +++++++++++++++++++++++ net/dccp/ipv4.c | 23 ++--------------------- net/dccp/ipv6.c | 17 +---------------- net/decnet/dn_nsp_in.c | 17 +---------------- 5 files changed, 29 insertions(+), 73 deletions(-) diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index a842ecc..71e303b 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -383,8 +383,6 @@ static int pppoe_rcv(struct sk_buff *skb, { struct pppoe_hdr *ph; struct pppox_sock *po; - struct sock *sk; - int ret; if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr))) goto drop; @@ -395,24 +393,8 @@ static int pppoe_rcv(struct sk_buff *skb, ph = (struct pppoe_hdr *) skb->nh.raw; po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source); - if (!po) - goto drop; - - sk = sk_pppox(po); - bh_lock_sock(sk); - - /* Socket state is unknown, must put skb into backlog. */ - if (sock_owned_by_user(sk) != 0) { - sk_add_backlog(sk, skb); - ret = NET_RX_SUCCESS; - } else { - ret = pppoe_rcv_core(sk, skb); - } - - bh_unlock_sock(sk); - sock_put(sk); - - return ret; + if (po != NULL) + return sk_receive_skb(sk_pppox(po), skb); drop: kfree_skb(skb); out: diff --git a/include/net/sock.h b/include/net/sock.h index 91d2895..6961700 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -926,6 +926,29 @@ static inline void sock_put(struct sock *sk) sk_free(sk); } +static inline int sk_receive_skb(struct sock *sk, struct sk_buff *skb) +{ + int rc = NET_RX_SUCCESS; + + if (sk_filter(sk, skb, 0)) + goto discard_and_relse; + + skb->dev = NULL; + + bh_lock_sock(sk); + if (!sock_owned_by_user(sk)) + rc = sk->sk_backlog_rcv(sk, skb); + else + sk_add_backlog(sk, skb); + bh_unlock_sock(sk); +out: + sock_put(sk); + return rc; +discard_and_relse: + kfree_skb(skb); + goto out; +} + /* Detach socket from process context. * Announce socket dead, detach it from wait queue and inode. * Note that parent inode held reference count on this struct sock, diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index c363051..99e8afa 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -914,7 +914,6 @@ int dccp_v4_rcv(struct sk_buff *skb) { const struct dccp_hdr *dh; struct sock *sk; - int rc; /* Step 1: Check header basics: */ @@ -984,28 +983,10 @@ int dccp_v4_rcv(struct sk_buff *skb) goto do_time_wait; } - if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) { - dccp_pr_debug("xfrm4_policy_check failed\n"); + if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) goto discard_and_relse; - } - - if (sk_filter(sk, skb, 0)) { - dccp_pr_debug("sk_filter failed\n"); - goto discard_and_relse; - } - - skb->dev = NULL; - bh_lock_sock(sk); - rc = 0; - if (!sock_owned_by_user(sk)) - rc = dccp_v4_do_rcv(sk, skb); - else - sk_add_backlog(sk, skb); - bh_unlock_sock(sk); - - sock_put(sk); - return rc; + return sk_receive_skb(sk, skb); no_dccp_socket: if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 599b0be..2e194c8 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -1032,7 +1032,6 @@ static int dccp_v6_rcv(struct sk_buff **pskb, unsigned int *nhoffp) const struct dccp_hdr *dh; struct sk_buff *skb = *pskb; struct sock *sk; - int rc; /* Step 1: Check header basics: */ @@ -1077,21 +1076,7 @@ static int dccp_v6_rcv(struct sk_buff **pskb, unsigned int *nhoffp) if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) goto discard_and_relse; - if (sk_filter(sk, skb, 0)) - goto discard_and_relse; - - skb->dev = NULL; - - bh_lock_sock(sk); - rc = 0; - if (!sock_owned_by_user(sk)) - rc = dccp_v6_do_rcv(sk, skb); - else - sk_add_backlog(sk, skb); - bh_unlock_sock(sk); - - sock_put(sk); - return rc ? -1 : 0; + return sk_receive_skb(sk, skb) ? -1 : 0; no_dccp_socket: if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) diff --git a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c index 369f25b..44bda85 100644 --- a/net/decnet/dn_nsp_in.c +++ b/net/decnet/dn_nsp_in.c @@ -793,7 +793,6 @@ static int dn_nsp_rx_packet(struct sk_buff *skb) got_it: if (sk != NULL) { struct dn_scp *scp = DN_SK(sk); - int ret; /* Reset backoff */ scp->nsp_rxtshift = 0; @@ -807,21 +806,7 @@ got_it: goto free_out; } - bh_lock_sock(sk); - ret = NET_RX_SUCCESS; - if (decnet_debug_level & 8) - printk(KERN_DEBUG "NSP: 0x%02x 0x%02x 0x%04x 0x%04x %d\n", - (int)cb->rt_flags, (int)cb->nsp_flags, - (int)cb->src_port, (int)cb->dst_port, - !!sock_owned_by_user(sk)); - if (!sock_owned_by_user(sk)) - ret = dn_nsp_backlog_rcv(sk, skb); - else - sk_add_backlog(sk, skb); - bh_unlock_sock(sk); - sock_put(sk); - - return ret; + return sk_receive_skb(sk, skb); } return dn_nsp_no_socket(skb, reason); -- cgit v1.1 From 14c850212ed8f8cbb5972ad6b8812e08a0bc901c Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 27 Dec 2005 02:43:12 -0200 Subject: [INET_SOCK]: Move struct inet_sock & helper functions to net/inet_sock.h To help in reducing the number of include dependencies, several files were touched as they were getting needed headers indirectly for stuff they use. Thanks also to Alan Menegotto for pointing out that net/dccp/proto.c had linux/dccp.h include twice. Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 + drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 2 + drivers/net/ns83820.c | 1 + drivers/net/sk98lin/skge.c | 1 + drivers/net/skge.c | 1 + drivers/net/tg3.c | 1 + fs/9p/trans_sock.c | 1 + fs/nfs/callback.c | 3 + include/linux/dccp.h | 3 +- include/linux/ip.h | 126 +--------------- include/linux/ipv6.h | 7 +- include/linux/udp.h | 6 +- include/net/atmclip.h | 2 +- include/net/dst.h | 1 + include/net/icmp.h | 9 +- include/net/ieee80211_crypt.h | 9 +- include/net/inet_connection_sock.h | 3 +- include/net/inet_ecn.h | 2 + include/net/inet_hashtables.h | 21 +-- include/net/inet_sock.h | 193 +++++++++++++++++++++++++ include/net/inet_timewait_sock.h | 2 +- include/net/ip.h | 17 ++- include/net/ip_fib.h | 2 + include/net/ip_vs.h | 12 +- include/net/ipv6.h | 3 + include/net/ndisc.h | 17 ++- include/net/neighbour.h | 2 +- include/net/pkt_act.h | 1 - include/net/raw.h | 2 + include/net/udp.h | 4 +- include/net/xfrm.h | 3 +- net/bridge/br_netfilter.c | 4 + net/bridge/netfilter/ebt_log.c | 1 + net/core/netpoll.c | 1 + net/dccp/ccid.h | 2 + net/dccp/ipv4.c | 1 + net/dccp/ipv6.c | 1 + net/dccp/output.c | 1 + net/dccp/proto.c | 3 +- net/econet/af_econet.c | 1 + net/ipv4/af_inet.c | 1 + net/ipv4/ah4.c | 1 + net/ipv4/arp.c | 1 + net/ipv4/devinet.c | 1 + net/ipv4/esp4.c | 1 + net/ipv4/fib_frontend.c | 1 + net/ipv4/fib_hash.c | 1 + net/ipv4/fib_rules.c | 1 + net/ipv4/fib_semantics.c | 2 + net/ipv4/icmp.c | 1 + net/ipv4/igmp.c | 2 + net/ipv4/ip_input.c | 1 + net/ipv4/ip_options.c | 1 + net/ipv4/ip_sockglue.c | 1 + net/ipv4/ipcomp.c | 1 + net/ipv4/ipconfig.c | 2 + net/ipv4/ipmr.c | 1 + net/ipv4/ipvs/ip_vs_conn.c | 2 + net/ipv4/ipvs/ip_vs_ctl.c | 1 + net/ipv4/ipvs/ip_vs_dh.c | 2 + net/ipv4/ipvs/ip_vs_est.c | 3 + net/ipv4/ipvs/ip_vs_lblc.c | 2 + net/ipv4/ipvs/ip_vs_lblcr.c | 2 + net/ipv4/ipvs/ip_vs_proto_ah.c | 2 + net/ipv4/ipvs/ip_vs_proto_esp.c | 2 + net/ipv4/ipvs/ip_vs_proto_udp.c | 3 + net/ipv4/ipvs/ip_vs_sh.c | 2 + net/ipv4/ipvs/ip_vs_sync.c | 2 + net/ipv4/netfilter/ip_conntrack_amanda.c | 2 + net/ipv4/netfilter/ip_conntrack_proto_gre.c | 1 + net/ipv4/netfilter/ip_conntrack_proto_udp.c | 1 + net/ipv4/netfilter/ip_conntrack_standalone.c | 1 + net/ipv4/netfilter/ip_nat_snmp_basic.c | 2 + net/ipv4/netfilter/ipt_MASQUERADE.c | 2 + net/ipv4/netfilter/ipt_physdev.c | 1 + net/ipv4/proc.c | 1 + net/ipv4/sysctl_net_ipv4.c | 1 + net/ipv4/udp.c | 1 + net/ipv6/ah6.c | 1 + net/ipv6/esp6.c | 1 + net/ipv6/ipcomp6.c | 1 + net/ipv6/netfilter/ip6_tables.c | 1 + net/ipv6/netfilter/ip6t_LOG.c | 1 + net/ipv6/netfilter/ip6t_ah.c | 1 + net/ipv6/netfilter/ip6t_esp.c | 1 + net/sched/sch_teql.c | 1 + net/sctp/protocol.c | 1 + 87 files changed, 355 insertions(+), 184 deletions(-) create mode 100644 include/net/inet_sock.h diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 475d98f..780009c 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c @@ -47,6 +47,8 @@ #include #include +#include + MODULE_AUTHOR("Roland Dreier"); MODULE_DESCRIPTION("IP-over-InfiniBand net driver"); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c index ef3ee03..ed0c2ea 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c @@ -43,6 +43,8 @@ #include #include +#include + #include "ipoib.h" #ifdef CONFIG_INFINIBAND_IPOIB_DEBUG diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c index f857ae9..b0c3b6a 100644 --- a/drivers/net/ns83820.c +++ b/drivers/net/ns83820.c @@ -115,6 +115,7 @@ #include #include #include +#include #include #include diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index ae73439..e1a2d52 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c @@ -107,6 +107,7 @@ #include "h/skversion.h" +#include #include #include #include diff --git a/drivers/net/skge.c b/drivers/net/skge.c index 00d6830..d8cc3ae 100644 --- a/drivers/net/skge.c +++ b/drivers/net/skge.c @@ -25,6 +25,7 @@ */ #include +#include #include #include #include diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 2fc9893..59d916c 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c index a93c2bf..6a9a75d 100644 --- a/fs/9p/trans_sock.c +++ b/fs/9p/trans_sock.c @@ -26,6 +26,7 @@ */ #include +#include #include #include #include diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index f2ca782..30cae36 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -14,6 +14,9 @@ #include #include #include + +#include + #include "nfs4_fs.h" #include "callback.h" diff --git a/include/linux/dccp.h b/include/linux/dccp.h index d0bdb49..088529f 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h @@ -192,10 +192,9 @@ enum { #include #include +#include #include -#include #include -#include enum dccp_state { DCCP_OPEN = TCP_ESTABLISHED, diff --git a/include/linux/ip.h b/include/linux/ip.h index 6ccc596..9e2eb9a 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -16,6 +16,7 @@ */ #ifndef _LINUX_IP_H #define _LINUX_IP_H +#include #include #define IPTOS_TOS_MASK 0x1E @@ -78,131 +79,6 @@ #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ #define IPOPT_TS_PRESPEC 3 /* specified modules only */ -#ifdef __KERNEL__ -#include -#include -#include -#include -#include -#include - -struct ip_options { - __u32 faddr; /* Saved first hop address */ - unsigned char optlen; - unsigned char srr; - unsigned char rr; - unsigned char ts; - unsigned char is_setbyuser:1, /* Set by setsockopt? */ - is_data:1, /* Options in __data, rather than skb */ - is_strictroute:1, /* Strict source route */ - srr_is_hit:1, /* Packet destination addr was our one */ - is_changed:1, /* IP checksum more not valid */ - rr_needaddr:1, /* Need to record addr of outgoing dev */ - ts_needtime:1, /* Need to record timestamp */ - ts_needaddr:1; /* Need to record addr of outgoing dev */ - unsigned char router_alert; - unsigned char __pad1; - unsigned char __pad2; - unsigned char __data[0]; -}; - -#define optlength(opt) (sizeof(struct ip_options) + opt->optlen) - -struct inet_request_sock { - struct request_sock req; -#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) - u16 inet6_rsk_offset; - /* 2 bytes hole, try to pack */ -#endif - u32 loc_addr; - u32 rmt_addr; - u16 rmt_port; - u16 snd_wscale : 4, - rcv_wscale : 4, - tstamp_ok : 1, - sack_ok : 1, - wscale_ok : 1, - ecn_ok : 1, - acked : 1; - struct ip_options *opt; -}; - -static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk) -{ - return (struct inet_request_sock *)sk; -} - -struct ipv6_pinfo; - -struct inet_sock { - /* sk and pinet6 has to be the first two members of inet_sock */ - struct sock sk; -#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) - struct ipv6_pinfo *pinet6; -#endif - /* Socket demultiplex comparisons on incoming packets. */ - __u32 daddr; /* Foreign IPv4 addr */ - __u32 rcv_saddr; /* Bound local IPv4 addr */ - __u16 dport; /* Destination port */ - __u16 num; /* Local port */ - __u32 saddr; /* Sending source */ - __s16 uc_ttl; /* Unicast TTL */ - __u16 cmsg_flags; - struct ip_options *opt; - __u16 sport; /* Source port */ - __u16 id; /* ID counter for DF pkts */ - __u8 tos; /* TOS */ - __u8 mc_ttl; /* Multicasting TTL */ - __u8 pmtudisc; - unsigned recverr : 1, - is_icsk : 1, /* inet_connection_sock? */ - freebind : 1, - hdrincl : 1, - mc_loop : 1; - int mc_index; /* Multicast device index */ - __u32 mc_addr; - struct ip_mc_socklist *mc_list; /* Group array */ - /* - * Following members are used to retain the infomation to build - * an ip header on each ip fragmentation while the socket is corked. - */ - struct { - unsigned int flags; - unsigned int fragsize; - struct ip_options *opt; - struct rtable *rt; - int length; /* Total length of all frames */ - u32 addr; - struct flowi fl; - } cork; -}; - -#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */ -#define IPCORK_ALLFRAG 2 /* always fragment (for ipv6 for now) */ - -static inline struct inet_sock *inet_sk(const struct sock *sk) -{ - return (struct inet_sock *)sk; -} - -static inline void __inet_sk_copy_descendant(struct sock *sk_to, - const struct sock *sk_from, - const int ancestor_size) -{ - memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1, - sk_from->sk_prot->obj_size - ancestor_size); -} -#if !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) -static inline void inet_sk_copy_descendant(struct sock *sk_to, - const struct sock *sk_from) -{ - __inet_sk_copy_descendant(sk_to, sk_from, sizeof(struct inet_sock)); -} -#endif -#endif - -extern int inet_sk_rebuild_header(struct sock *sk); - struct iphdr { #if defined(__LITTLE_ENDIAN_BITFIELD) __u8 ihl:4, diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index a0d0489..93bbed5 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -171,12 +171,13 @@ enum { }; #ifdef __KERNEL__ -#include /* struct sockaddr_in6 */ #include -#include /* struct ipv6_mc_socklist */ #include #include +#include /* struct ipv6_mc_socklist */ +#include + /* This structure contains results of exthdrs parsing as offsets from skb->nh. @@ -346,8 +347,6 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to, #define __ipv6_only_sock(sk) (inet6_sk(sk)->ipv6only) #define ipv6_only_sock(sk) ((sk)->sk_family == PF_INET6 && __ipv6_only_sock(sk)) -#include - struct inet6_timewait_sock { struct in6_addr tw_v6_daddr; struct in6_addr tw_v6_rcv_saddr; diff --git a/include/linux/udp.h b/include/linux/udp.h index b60e0b4..85a5565 100644 --- a/include/linux/udp.h +++ b/include/linux/udp.h @@ -35,10 +35,10 @@ struct udphdr { #define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */ #ifdef __KERNEL__ - #include -#include -#include +#include + +#include struct udp_sock { /* inet_sock has to be the first member */ diff --git a/include/net/atmclip.h b/include/net/atmclip.h index 47048b1..90fcc98 100644 --- a/include/net/atmclip.h +++ b/include/net/atmclip.h @@ -7,7 +7,6 @@ #define _ATMCLIP_H #include -#include #include #include #include @@ -18,6 +17,7 @@ #define CLIP_VCC(vcc) ((struct clip_vcc *) ((vcc)->user_back)) #define NEIGH2ENTRY(neigh) ((struct atmarp_entry *) (neigh)->primary_key) +struct sk_buff; struct clip_vcc { struct atm_vcc *vcc; /* VCC descriptor */ diff --git a/include/net/dst.h b/include/net/dst.h index 6c196a5..bee8b84d 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -9,6 +9,7 @@ #define _NET_DST_H #include +#include #include #include #include diff --git a/include/net/icmp.h b/include/net/icmp.h index 6cdebee..e7c3f20 100644 --- a/include/net/icmp.h +++ b/include/net/icmp.h @@ -20,12 +20,9 @@ #include #include -#include -#include -#include +#include #include -#include struct icmp_err { int errno; @@ -38,6 +35,10 @@ DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics); #define ICMP_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmp_statistics, field) #define ICMP_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmp_statistics, field) +struct dst_entry; +struct net_proto_family; +struct sk_buff; + extern void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info); extern int icmp_rcv(struct sk_buff *skb); extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg); diff --git a/include/net/ieee80211_crypt.h b/include/net/ieee80211_crypt.h index 225fc751..03b766a 100644 --- a/include/net/ieee80211_crypt.h +++ b/include/net/ieee80211_crypt.h @@ -23,12 +23,17 @@ #ifndef IEEE80211_CRYPT_H #define IEEE80211_CRYPT_H -#include +#include +#include +#include enum { IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), }; +struct sk_buff; +struct module; + struct ieee80211_crypto_ops { const char *name; struct list_head list; @@ -87,6 +92,8 @@ struct ieee80211_crypt_data { atomic_t refcnt; }; +struct ieee80211_device; + int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name); diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 9188896..50234fa 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h @@ -16,9 +16,10 @@ #define _INET_CONNECTION_SOCK_H #include -#include #include #include + +#include #include #define INET_CSK_DEBUG 1 diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h index b0c47e2..d599c6b 100644 --- a/include/net/inet_ecn.h +++ b/include/net/inet_ecn.h @@ -3,6 +3,8 @@ #include #include + +#include #include enum { diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index c83baa7..135d80f 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -128,26 +129,6 @@ struct inet_hashinfo { kmem_cache_t *bind_bucket_cachep; }; -static inline unsigned int inet_ehashfn(const __u32 laddr, const __u16 lport, - const __u32 faddr, const __u16 fport) -{ - unsigned int h = (laddr ^ lport) ^ (faddr ^ fport); - h ^= h >> 16; - h ^= h >> 8; - return h; -} - -static inline int inet_sk_ehashfn(const struct sock *sk) -{ - const struct inet_sock *inet = inet_sk(sk); - const __u32 laddr = inet->rcv_saddr; - const __u16 lport = inet->num; - const __u32 faddr = inet->daddr; - const __u16 fport = inet->dport; - - return inet_ehashfn(laddr, lport, faddr, fport); -} - static inline struct inet_ehash_bucket *inet_ehash_bucket( struct inet_hashinfo *hashinfo, unsigned int hash) diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h new file mode 100644 index 0000000..883eb52 --- /dev/null +++ b/include/net/inet_sock.h @@ -0,0 +1,193 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Definitions for inet_sock + * + * Authors: Many, reorganised here by + * Arnaldo Carvalho de Melo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#ifndef _INET_SOCK_H +#define _INET_SOCK_H + +#include + +#include +#include + +#include +#include +#include + +/** struct ip_options - IP Options + * + * @faddr - Saved first hop address + * @is_setbyuser - Set by setsockopt? + * @is_data - Options in __data, rather than skb + * @is_strictroute - Strict source route + * @srr_is_hit - Packet destination addr was our one + * @is_changed - IP checksum more not valid + * @rr_needaddr - Need to record addr of outgoing dev + * @ts_needtime - Need to record timestamp + * @ts_needaddr - Need to record addr of outgoing dev + */ +struct ip_options { + __u32 faddr; + unsigned char optlen; + unsigned char srr; + unsigned char rr; + unsigned char ts; + unsigned char is_setbyuser:1, + is_data:1, + is_strictroute:1, + srr_is_hit:1, + is_changed:1, + rr_needaddr:1, + ts_needtime:1, + ts_needaddr:1; + unsigned char router_alert; + unsigned char __pad1; + unsigned char __pad2; + unsigned char __data[0]; +}; + +#define optlength(opt) (sizeof(struct ip_options) + opt->optlen) + +struct inet_request_sock { + struct request_sock req; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + u16 inet6_rsk_offset; + /* 2 bytes hole, try to pack */ +#endif + u32 loc_addr; + u32 rmt_addr; + u16 rmt_port; + u16 snd_wscale : 4, + rcv_wscale : 4, + tstamp_ok : 1, + sack_ok : 1, + wscale_ok : 1, + ecn_ok : 1, + acked : 1; + struct ip_options *opt; +}; + +static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk) +{ + return (struct inet_request_sock *)sk; +} + +struct ip_mc_socklist; +struct ipv6_pinfo; +struct rtable; + +/** struct inet_sock - representation of INET sockets + * + * @sk - ancestor class + * @pinet6 - pointer to IPv6 control block + * @daddr - Foreign IPv4 addr + * @rcv_saddr - Bound local IPv4 addr + * @dport - Destination port + * @num - Local port + * @saddr - Sending source + * @uc_ttl - Unicast TTL + * @sport - Source port + * @id - ID counter for DF pkts + * @tos - TOS + * @mc_ttl - Multicasting TTL + * @is_icsk - is this an inet_connection_sock? + * @mc_index - Multicast device index + * @mc_list - Group array + * @cork - info to build ip hdr on each ip frag while socket is corked + */ +struct inet_sock { + /* sk and pinet6 has to be the first two members of inet_sock */ + struct sock sk; +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) + struct ipv6_pinfo *pinet6; +#endif + /* Socket demultiplex comparisons on incoming packets. */ + __u32 daddr; + __u32 rcv_saddr; + __u16 dport; + __u16 num; + __u32 saddr; + __s16 uc_ttl; + __u16 cmsg_flags; + struct ip_options *opt; + __u16 sport; + __u16 id; + __u8 tos; + __u8 mc_ttl; + __u8 pmtudisc; + __u8 recverr:1, + is_icsk:1, + freebind:1, + hdrincl:1, + mc_loop:1; + int mc_index; + __u32 mc_addr; + struct ip_mc_socklist *mc_list; + struct { + unsigned int flags; + unsigned int fragsize; + struct ip_options *opt; + struct rtable *rt; + int length; /* Total length of all frames */ + u32 addr; + struct flowi fl; + } cork; +}; + +#define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */ +#define IPCORK_ALLFRAG 2 /* always fragment (for ipv6 for now) */ + +static inline struct inet_sock *inet_sk(const struct sock *sk) +{ + return (struct inet_sock *)sk; +} + +static inline void __inet_sk_copy_descendant(struct sock *sk_to, + const struct sock *sk_from, + const int ancestor_size) +{ + memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1, + sk_from->sk_prot->obj_size - ancestor_size); +} +#if !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) +static inline void inet_sk_copy_descendant(struct sock *sk_to, + const struct sock *sk_from) +{ + __inet_sk_copy_descendant(sk_to, sk_from, sizeof(struct inet_sock)); +} +#endif + +extern int inet_sk_rebuild_header(struct sock *sk); + +static inline unsigned int inet_ehashfn(const __u32 laddr, const __u16 lport, + const __u32 faddr, const __u16 fport) +{ + unsigned int h = (laddr ^ lport) ^ (faddr ^ fport); + h ^= h >> 16; + h ^= h >> 8; + return h; +} + +static inline int inet_sk_ehashfn(const struct sock *sk) +{ + const struct inet_sock *inet = inet_sk(sk); + const __u32 laddr = inet->rcv_saddr; + const __u16 lport = inet->num; + const __u32 faddr = inet->daddr; + const __u16 fport = inet->dport; + + return inet_ehashfn(laddr, lport, faddr, fport); +} + +#endif /* _INET_SOCK_H */ diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index e396a65..1da294c 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h @@ -17,13 +17,13 @@ #include -#include #include #include #include #include #include +#include #include #include #include diff --git a/include/net/ip.h b/include/net/ip.h index 4d6294ba..f7e7fd7 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -24,14 +24,10 @@ #include #include -#include #include #include -#include -#include -#include -#include -#include + +#include #include struct sock; @@ -75,6 +71,13 @@ extern rwlock_t ip_ra_lock; #define IP_FRAG_TIME (30 * HZ) /* fragment lifetime */ +struct msghdr; +struct net_device; +struct packet_type; +struct rtable; +struct sk_buff; +struct sockaddr; + extern void ip_mc_dropsocket(struct sock *); extern void ip_mc_dropdevice(struct net_device *dev); extern int igmp_mc_proc_init(void); @@ -184,6 +187,8 @@ extern int sysctl_ip_dynaddr; extern void ipfrag_init(void); #ifdef CONFIG_INET +#include + /* The function in 2.2 was invalid, producing wrong result for * check=0xFEFF. It was noticed by Arthur Skawina _year_ ago. --ANK(000625) */ static inline diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index 14de4eb..e000fa2 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -238,6 +238,8 @@ extern int fib_validate_source(u32 src, u32 dst, u8 tos, int oif, struct net_device *dev, u32 *spec_dst, u32 *itag); extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res); +struct rtentry; + /* Exported by fib_semantics.c */ extern int ip_fib_check_default(u32 gw, struct net_device *dev); extern int fib_sync_down(u32 local, struct net_device *dev, int force); diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 3b5559a..7d2674f 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h @@ -251,16 +251,15 @@ struct ip_vs_daemon_user { #include #include /* for struct list_head */ #include /* for struct rwlock_t */ -#include /* for struct sk_buff */ -#include /* for struct iphdr */ #include /* for struct atomic_t */ -#include /* for struct neighbour */ -#include /* for struct dst_entry */ -#include #include +#include +#include #ifdef CONFIG_IP_VS_DEBUG +#include + extern int ip_vs_get_debug_level(void); #define IP_VS_DBG(level, msg...) \ do { \ @@ -429,8 +428,11 @@ struct ip_vs_stats spinlock_t lock; /* spin lock */ }; +struct dst_entry; +struct iphdr; struct ip_vs_conn; struct ip_vs_app; +struct sk_buff; struct ip_vs_protocol { struct ip_vs_protocol *next; diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 11a7256..860bbac 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -541,6 +541,9 @@ extern int sysctl_ip6frag_secret_interval; extern const struct proto_ops inet6_stream_ops; extern const struct proto_ops inet6_dgram_ops; +struct group_source_req; +struct group_filter; + extern int ip6_mc_source(int add, int omode, struct sock *sk, struct group_source_req *pgsr); extern int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf); diff --git a/include/net/ndisc.h b/include/net/ndisc.h index f85d6e4..bbac87e 100644 --- a/include/net/ndisc.h +++ b/include/net/ndisc.h @@ -35,11 +35,20 @@ enum { #ifdef __KERNEL__ -#include -#include +#include +#include #include +#include +#include + #include -#include + +struct ctl_table; +struct file; +struct inet6_dev; +struct net_device; +struct net_proto_family; +struct sk_buff; extern struct neigh_table nd_tbl; @@ -108,7 +117,7 @@ extern int igmp6_event_report(struct sk_buff *skb); extern void igmp6_cleanup(void); #ifdef CONFIG_SYSCTL -extern int ndisc_ifinfo_sysctl_change(ctl_table *ctl, +extern int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, struct file * filp, void __user *buffer, diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 34c0773..6fa9ae1 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -49,8 +49,8 @@ #ifdef __KERNEL__ #include -#include #include +#include #include #include diff --git a/include/net/pkt_act.h b/include/net/pkt_act.h index bd08964..b225d84 100644 --- a/include/net/pkt_act.h +++ b/include/net/pkt_act.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/include/net/raw.h b/include/net/raw.h index f479174..e67b28a 100644 --- a/include/net/raw.h +++ b/include/net/raw.h @@ -19,6 +19,8 @@ #include +#include + extern struct proto raw_prot; extern void raw_err(struct sock *, struct sk_buff *, u32 info); diff --git a/include/net/udp.h b/include/net/udp.h index 107b9d7..766fba1 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -22,9 +22,8 @@ #ifndef _UDP_H #define _UDP_H -#include -#include #include +#include #include #include #include @@ -62,6 +61,7 @@ static inline int udp_lport_inuse(u16 num) extern struct proto udp_prot; +struct sk_buff; extern void udp_err(struct sk_buff *, u32); diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 487abca..07d7b50 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -2,11 +2,12 @@ #define _NET_XFRM_H #include +#include #include #include #include #include -#include +#include #include #include #include diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index 23422bd..223f827 100644 --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -33,8 +34,11 @@ #include #include #include + #include #include +#include + #include #include #include "br_private.h" diff --git a/net/bridge/netfilter/ebt_log.c b/net/bridge/netfilter/ebt_log.c index c436e6c..9f6e019 100644 --- a/net/bridge/netfilter/ebt_log.c +++ b/net/bridge/netfilter/ebt_log.c @@ -9,6 +9,7 @@ * */ +#include #include #include #include diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 49424a4..281a632 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h index c37eeea..de681c6 100644 --- a/net/dccp/ccid.h +++ b/net/dccp/ccid.h @@ -21,6 +21,8 @@ #define CCID_MAX 255 +struct tcp_info; + struct ccid { unsigned char ccid_id; const char *ccid_name; diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 99e8afa..3f24467 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 2e194c8..c609dc7 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/net/dccp/output.c b/net/dccp/output.c index 95a3c2c..efd7ffb 100644 --- a/net/dccp/output.c +++ b/net/dccp/output.c @@ -15,6 +15,7 @@ #include #include +#include #include #include "ackvec.h" diff --git a/net/dccp/proto.c b/net/dccp/proto.c index e4e629e..65b11ea 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -34,7 +34,6 @@ #include #include #include -#include #include "ccid.h" #include "dccp.h" diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index ff58f49..70fb2b8 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 4ed8a81..36a6306 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -93,6 +93,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index 035ad2c..aed537f 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c @@ -6,6 +6,7 @@ #include #include #include +#include #include diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index b425748..3743208 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -86,6 +86,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 04a6fe3..7b9bb28 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -58,6 +58,7 @@ #endif #include +#include #include #include #include diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 1b18ce6..73bfcae 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -9,6 +9,7 @@ #include #include #include +#include #include /* decapsulation data for use when post-processing */ diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 19b1b98..18f5e50 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c index 7ea0209c..e2890ec 100644 --- a/net/ipv4/fib_hash.c +++ b/net/ipv4/fib_hash.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c index 0b298bb..0dd4d06 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 6d2a6ac..ef4724d 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ #include #include +#include #include #include #include diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 92e23b2..be5a519 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 4a195c7..3475811 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c @@ -91,6 +91,8 @@ #include #include #include + +#include #include #include #include diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 473d0f2..e45846a 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c @@ -128,6 +128,7 @@ #include #include #include +#include #include #include diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index dbe12da..d3f6c46 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -22,6 +22,7 @@ #include #include #include +#include /* * Write options to IP header, record destination address to diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index add019c..6986e11d 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index fc718df..d64e2ec 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c @@ -28,6 +28,7 @@ #include #include #include +#include struct ipcomp_tfms { struct list_head list; diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index e8674ba..bb3613e 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ #include #include #include +#include #include #include diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 302b7eb..caa3b7d 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c index 2a3a8c5..d35cea3 100644 --- a/net/ipv4/ipvs/ip_vs_conn.c +++ b/net/ipv4/ipvs/ip_vs_conn.c @@ -24,7 +24,9 @@ * */ +#include #include +#include #include #include /* for proc_net_* */ #include diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c index 9bdcf31..fe2c39d 100644 --- a/net/ipv4/ipvs/ip_vs_ctl.c +++ b/net/ipv4/ipvs/ip_vs_ctl.c @@ -35,6 +35,7 @@ #include #include +#include #include #include diff --git a/net/ipv4/ipvs/ip_vs_dh.c b/net/ipv4/ipvs/ip_vs_dh.c index f3bc320..9fee19c 100644 --- a/net/ipv4/ipvs/ip_vs_dh.c +++ b/net/ipv4/ipvs/ip_vs_dh.c @@ -37,8 +37,10 @@ * */ +#include #include #include +#include #include diff --git a/net/ipv4/ipvs/ip_vs_est.c b/net/ipv4/ipvs/ip_vs_est.c index 67b3e2f..e700474 100644 --- a/net/ipv4/ipvs/ip_vs_est.c +++ b/net/ipv4/ipvs/ip_vs_est.c @@ -13,7 +13,10 @@ * Changes: * */ +#include #include +#include +#include #include #include diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c index b6dad7e..6e5cb92 100644 --- a/net/ipv4/ipvs/ip_vs_lblc.c +++ b/net/ipv4/ipvs/ip_vs_lblc.c @@ -41,8 +41,10 @@ * me to write this module. */ +#include #include #include +#include /* for sysctl */ #include diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c index 8c78ef7..32ba37b 100644 --- a/net/ipv4/ipvs/ip_vs_lblcr.c +++ b/net/ipv4/ipvs/ip_vs_lblcr.c @@ -39,8 +39,10 @@ * */ +#include #include #include +#include /* for sysctl */ #include diff --git a/net/ipv4/ipvs/ip_vs_proto_ah.c b/net/ipv4/ipvs/ip_vs_proto_ah.c index 453e94a..8b0505b 100644 --- a/net/ipv4/ipvs/ip_vs_proto_ah.c +++ b/net/ipv4/ipvs/ip_vs_proto_ah.c @@ -12,6 +12,8 @@ * */ +#include +#include #include #include #include diff --git a/net/ipv4/ipvs/ip_vs_proto_esp.c b/net/ipv4/ipvs/ip_vs_proto_esp.c index 478e5c7..c36ccf0 100644 --- a/net/ipv4/ipvs/ip_vs_proto_esp.c +++ b/net/ipv4/ipvs/ip_vs_proto_esp.c @@ -12,6 +12,8 @@ * */ +#include +#include #include #include #include diff --git a/net/ipv4/ipvs/ip_vs_proto_udp.c b/net/ipv4/ipvs/ip_vs_proto_udp.c index 8ae5f2e..89d9175 100644 --- a/net/ipv4/ipvs/ip_vs_proto_udp.c +++ b/net/ipv4/ipvs/ip_vs_proto_udp.c @@ -15,8 +15,11 @@ * */ +#include +#include #include #include +#include #include diff --git a/net/ipv4/ipvs/ip_vs_sh.c b/net/ipv4/ipvs/ip_vs_sh.c index 6f7c50e..7775e6c 100644 --- a/net/ipv4/ipvs/ip_vs_sh.c +++ b/net/ipv4/ipvs/ip_vs_sh.c @@ -34,8 +34,10 @@ * */ +#include #include #include +#include #include diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c index 2e5ced3..1bca714 100644 --- a/net/ipv4/ipvs/ip_vs_sync.c +++ b/net/ipv4/ipvs/ip_vs_sync.c @@ -21,12 +21,14 @@ #include #include +#include #include #include #include #include #include #include /* for ip_mc_join_group */ +#include #include #include diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c index e52847f..0366eed 100644 --- a/net/ipv4/netfilter/ip_conntrack_amanda.c +++ b/net/ipv4/netfilter/ip_conntrack_amanda.c @@ -18,11 +18,13 @@ * */ +#include #include #include #include #include #include +#include #include #include diff --git a/net/ipv4/netfilter/ip_conntrack_proto_gre.c b/net/ipv4/netfilter/ip_conntrack_proto_gre.c index 744abb9..57956de 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_gre.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_gre.c @@ -31,6 +31,7 @@ #include #include #include +#include static DEFINE_RWLOCK(ip_ct_gre_lock); #define ASSERT_READ_LOCK(x) diff --git a/net/ipv4/netfilter/ip_conntrack_proto_udp.c b/net/ipv4/netfilter/ip_conntrack_proto_udp.c index f2dcac7..46becbe 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_udp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_udp.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c index dd476b1..a88bcc5 100644 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c @@ -27,6 +27,7 @@ #endif #include #include +#include #define ASSERT_READ_LOCK(x) #define ASSERT_WRITE_LOCK(x) diff --git a/net/ipv4/netfilter/ip_nat_snmp_basic.c b/net/ipv4/netfilter/ip_nat_snmp_basic.c index 8acb7ed..4f95d47 100644 --- a/net/ipv4/netfilter/ip_nat_snmp_basic.c +++ b/net/ipv4/netfilter/ip_nat_snmp_basic.c @@ -44,6 +44,7 @@ * */ #include +#include #include #include #include @@ -53,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/netfilter/ipt_MASQUERADE.c b/net/ipv4/netfilter/ipt_MASQUERADE.c index 275a174..2786051 100644 --- a/net/ipv4/netfilter/ipt_MASQUERADE.c +++ b/net/ipv4/netfilter/ipt_MASQUERADE.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/netfilter/ipt_physdev.c b/net/ipv4/netfilter/ipt_physdev.c index 1a53924..03f5548 100644 --- a/net/ipv4/netfilter/ipt_physdev.c +++ b/net/ipv4/netfilter/ipt_physdev.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 0d7dc66..39d49dc 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index dbf8295..16984d4 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 67c0363..223abaa 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -86,6 +86,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index f362973..13cc7f8 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 8bfbe99..6de8ee1 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c @@ -36,6 +36,7 @@ #include #include #include +#include #include static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 55917fb..626dd39 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index dd80020..ea43ef1 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -15,6 +15,7 @@ * - new extension header parser code */ #include +#include #include #include #include diff --git a/net/ipv6/netfilter/ip6t_LOG.c b/net/ipv6/netfilter/ip6t_LOG.c index 0cd1d1b..ae4653b 100644 --- a/net/ipv6/netfilter/ip6t_LOG.c +++ b/net/ipv6/netfilter/ip6t_LOG.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c index dde3779..268918d 100644 --- a/net/ipv6/netfilter/ip6t_ah.c +++ b/net/ipv6/netfilter/ip6t_ah.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff --git a/net/ipv6/netfilter/ip6t_esp.c b/net/ipv6/netfilter/ip6t_esp.c index 24bc0cd..65937de 100644 --- a/net/ipv6/netfilter/ip6t_esp.c +++ b/net/ipv6/netfilter/ip6t_esp.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c index 6cf0342..c4a2a8c 100644 --- a/net/sched/sch_teql.c +++ b/net/sched/sch_teql.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index d1b0747..de693b4 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include -- cgit v1.1 From 8639a11e23d9eb0a6ceac2feed27acdfbb158f95 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 27 Dec 2005 15:17:57 -0200 Subject: [TCP]: Don't use __constant_htonl for a non const arg Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- include/net/tcp.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 176221c..3699304 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -994,11 +994,11 @@ static __inline__ void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock struct tcp_sack_block *sp = tp->rx_opt.dsack ? tp->duplicate_sack : tp->selective_acks; int this_sack; - *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | - (TCPOPT_NOP << 16) | - (TCPOPT_SACK << 8) | - (TCPOLEN_SACK_BASE + - (tp->rx_opt.eff_sacks * TCPOLEN_SACK_PERBLOCK))); + *ptr++ = htonl((TCPOPT_NOP << 24) | + (TCPOPT_NOP << 16) | + (TCPOPT_SACK << 8) | + (TCPOLEN_SACK_BASE + (tp->rx_opt.eff_sacks * + TCPOLEN_SACK_PERBLOCK))); for(this_sack = 0; this_sack < tp->rx_opt.eff_sacks; this_sack++) { *ptr++ = htonl(sp[this_sack].start_seq); *ptr++ = htonl(sp[this_sack].end_seq); -- cgit v1.1 From 17ba15fb6264f27374bc87f4c3f8519b80289d85 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Tue, 27 Dec 2005 20:57:40 -0800 Subject: [PPPOX]: Fix assignment into const proto_ops. And actually, with this, the whole pppox layer can basically be removed and subsumed into pppoe.c, no other pppox sub-protocol implementation exists and we've had this thing for at least 4 years. Signed-off-by: David S. Miller --- drivers/net/pppoe.c | 9 ++++----- drivers/net/pppox.c | 10 +++------- include/linux/if_pppox.h | 3 +-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 71e303b..9369f81 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -85,7 +85,7 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb); static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb); -static struct proto_ops pppoe_ops; +static const struct proto_ops pppoe_ops; static DEFINE_RWLOCK(pppoe_hash_lock); static struct ppp_channel_ops pppoe_chan_ops; @@ -1063,9 +1063,7 @@ static int __init pppoe_proc_init(void) static inline int pppoe_proc_init(void) { return 0; } #endif /* CONFIG_PROC_FS */ -/* ->ioctl are set at pppox_create */ - -static struct proto_ops pppoe_ops = { +static const struct proto_ops pppoe_ops = { .family = AF_PPPOX, .owner = THIS_MODULE, .release = pppoe_release, @@ -1081,7 +1079,8 @@ static struct proto_ops pppoe_ops = { .getsockopt = sock_no_getsockopt, .sendmsg = pppoe_sendmsg, .recvmsg = pppoe_recvmsg, - .mmap = sock_no_mmap + .mmap = sock_no_mmap, + .ioctl = pppox_ioctl, }; static struct pppox_proto pppoe_proto = { diff --git a/drivers/net/pppox.c b/drivers/net/pppox.c index 0c1e114..9315046 100644 --- a/drivers/net/pppox.c +++ b/drivers/net/pppox.c @@ -68,8 +68,7 @@ EXPORT_SYMBOL(register_pppox_proto); EXPORT_SYMBOL(unregister_pppox_proto); EXPORT_SYMBOL(pppox_unbind_sock); -static int pppox_ioctl(struct socket* sock, unsigned int cmd, - unsigned long arg) +int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; struct pppox_sock *po = pppox_sk(sk); @@ -105,6 +104,7 @@ static int pppox_ioctl(struct socket* sock, unsigned int cmd, return rc; } +EXPORT_SYMBOL(pppox_ioctl); static int pppox_create(struct socket *sock, int protocol) { @@ -119,11 +119,7 @@ static int pppox_create(struct socket *sock, int protocol) goto out; rc = pppox_protos[protocol]->create(sock); - if (!rc) { - /* We get to set the ioctl handler. */ - /* For everything else, pppox is just a shell. */ - sock->ops->ioctl = pppox_ioctl; - } + module_put(pppox_protos[protocol]->owner); out: return rc; diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h index e677f73..4fab3d0 100644 --- a/include/linux/if_pppox.h +++ b/include/linux/if_pppox.h @@ -157,8 +157,7 @@ struct pppox_proto { extern int register_pppox_proto(int proto_num, struct pppox_proto *pp); extern void unregister_pppox_proto(int proto_num); extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */ -extern int pppox_channel_ioctl(struct ppp_channel *pc, unsigned int cmd, - unsigned long arg); +extern int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); /* PPPoX socket states */ enum { -- cgit v1.1 From 4947d3ef8de7b4f42aed6ea9ba689dc8fb45b5a5 Mon Sep 17 00:00:00 2001 From: Benjamin LaHaise Date: Tue, 3 Jan 2006 14:06:50 -0800 Subject: [NET]: Speed up __alloc_skb() From: Benjamin LaHaise In __alloc_skb(), the use of skb_shinfo() which casts a u8 * to the shared info structure results in gcc being forced to do a reload of the pointer since it has no information on possible aliasing. Fix this by using a pointer to refer to skb_shared_info. By initializing skb_shared_info sequentially, the write combining buffers can reduce the number of memory transactions to a single write. Reorder the initialization in __alloc_skb() to match the structure definition. There is also an alignment issue on 64 bit systems with skb_shared_info by converting nr_frags to a short everything packs up nicely. Also, pass the slab cache pointer according to the fclone flag instead of using two almost identical function calls. This raises bw_unix performance up to a peak of 707KB/s when combined with the spinlock patch. It should help other networking protocols, too. Signed-off-by: David S. Miller --- include/linux/skbuff.h | 2 +- net/core/skbuff.c | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 9716771..483cfc4 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -133,7 +133,7 @@ struct skb_frag_struct { */ struct skb_shared_info { atomic_t dataref; - unsigned int nr_frags; + unsigned short nr_frags; unsigned short tso_size; unsigned short tso_segs; unsigned short ufo_size; diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 83fee37..070f91c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -135,17 +135,13 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here) struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, int fclone) { + struct skb_shared_info *shinfo; struct sk_buff *skb; u8 *data; /* Get the HEAD */ - if (fclone) - skb = kmem_cache_alloc(skbuff_fclone_cache, - gfp_mask & ~__GFP_DMA); - else - skb = kmem_cache_alloc(skbuff_head_cache, - gfp_mask & ~__GFP_DMA); - + skb = kmem_cache_alloc(fclone ? skbuff_fclone_cache : skbuff_head_cache, + gfp_mask & ~__GFP_DMA); if (!skb) goto out; @@ -162,6 +158,16 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, skb->data = data; skb->tail = data; skb->end = data + size; + /* make sure we initialize shinfo sequentially */ + shinfo = skb_shinfo(skb); + atomic_set(&shinfo->dataref, 1); + shinfo->nr_frags = 0; + shinfo->tso_size = 0; + shinfo->tso_segs = 0; + shinfo->ufo_size = 0; + shinfo->ip6_frag_id = 0; + shinfo->frag_list = NULL; + if (fclone) { struct sk_buff *child = skb + 1; atomic_t *fclone_ref = (atomic_t *) (child + 1); @@ -171,13 +177,6 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, child->fclone = SKB_FCLONE_UNAVAILABLE; } - atomic_set(&(skb_shinfo(skb)->dataref), 1); - skb_shinfo(skb)->nr_frags = 0; - skb_shinfo(skb)->tso_size = 0; - skb_shinfo(skb)->tso_segs = 0; - skb_shinfo(skb)->frag_list = NULL; - skb_shinfo(skb)->ufo_size = 0; - skb_shinfo(skb)->ip6_frag_id = 0; out: return skb; nodata: -- cgit v1.1 From fd19f329a32bdc4eb07885e0b3889567cfe00aa7 Mon Sep 17 00:00:00 2001 From: Benjamin LaHaise Date: Tue, 3 Jan 2006 14:10:46 -0800 Subject: [AF_UNIX]: Convert to use a spinlock instead of rwlock From: Benjamin LaHaise In af_unix, a rwlock is used to protect internal state. At least on my P4 with HT it is faster to use a spinlock due to the simpler memory barrier used to unlock. This patch raises bw_unix to ~690K/s. Signed-off-by: David S. Miller --- include/net/af_unix.h | 10 +++++----- net/unix/af_unix.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 3f302ae..bfc1779 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -58,10 +58,10 @@ struct unix_skb_parms { #define UNIXCB(skb) (*(struct unix_skb_parms*)&((skb)->cb)) #define UNIXCREDS(skb) (&UNIXCB((skb)).creds) -#define unix_state_rlock(s) read_lock(&unix_sk(s)->lock) -#define unix_state_runlock(s) read_unlock(&unix_sk(s)->lock) -#define unix_state_wlock(s) write_lock(&unix_sk(s)->lock) -#define unix_state_wunlock(s) write_unlock(&unix_sk(s)->lock) +#define unix_state_rlock(s) spin_lock(&unix_sk(s)->lock) +#define unix_state_runlock(s) spin_unlock(&unix_sk(s)->lock) +#define unix_state_wlock(s) spin_lock(&unix_sk(s)->lock) +#define unix_state_wunlock(s) spin_unlock(&unix_sk(s)->lock) #ifdef __KERNEL__ /* The AF_UNIX socket */ @@ -76,7 +76,7 @@ struct unix_sock { struct sock *other; struct sock *gc_tree; atomic_t inflight; - rwlock_t lock; + spinlock_t lock; wait_queue_head_t peer_wait; }; #define unix_sk(__sk) ((struct unix_sock *)__sk) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 7d3fe6a..1ddd36d 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -564,7 +564,7 @@ static struct sock * unix_create1(struct socket *sock) u = unix_sk(sk); u->dentry = NULL; u->mnt = NULL; - rwlock_init(&u->lock); + spin_lock_init(&u->lock); atomic_set(&u->inflight, sock ? 0 : -1); init_MUTEX(&u->readsem); /* single task reading lock */ init_waitqueue_head(&u->peer_wait); -- cgit v1.1 From b461d2f2188c1c578ed651e4cdf608be7a993cd4 Mon Sep 17 00:00:00 2001 From: Per Liden Date: Tue, 3 Jan 2006 14:13:29 -0800 Subject: [NETLINK] genetlink: fix cmd type in genl_ops to be consistent to u8 Signed-off-by: Per Liden ACKed-by: Jamal Hadi Salim Signed-off-by: David S. Miller --- include/net/genetlink.h | 2 +- net/netlink/genetlink.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/net/genetlink.h b/include/net/genetlink.h index 52d8b1a..c5b96b2 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h @@ -60,7 +60,7 @@ struct genl_info */ struct genl_ops { - unsigned int cmd; + u8 cmd; unsigned int flags; struct nla_policy *policy; int (*doit)(struct sk_buff *skb, diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 287cfcc..3b13784 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -441,7 +441,7 @@ errout: } static struct sk_buff *ctrl_build_msg(struct genl_family *family, u32 pid, - int seq, int cmd) + int seq, u8 cmd) { struct sk_buff *skb; int err; -- cgit v1.1 From 5ff7630e4aa6c3969094dc30ff1cdaa6f52b0ed0 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 3 Jan 2006 14:14:46 -0800 Subject: [NETROM]: Remove unessecary lock_sock calls in netrom_ioctl() lock_sock is needed only in very few cases, so do it there instead of around the switch statement. Signed-off-by: Christoph Hellwig Signed-off-by: David S. Miller --- net/netrom/af_netrom.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 05b653c..9ee672e 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -1166,10 +1166,11 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) void __user *argp = (void __user *)arg; int ret; - lock_sock(sk); switch (cmd) { case TIOCOUTQ: { long amount; + + lock_sock(sk); amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); if (amount < 0) amount = 0; @@ -1180,6 +1181,8 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) case TIOCINQ: { struct sk_buff *skb; long amount = 0L; + + lock_sock(sk); /* These two are safe on a single CPU system as only user tasks fiddle here */ if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) amount = skb->len; @@ -1188,6 +1191,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } case SIOCGSTAMP: + lock_sock(sk); ret = sock_get_timestamp(sk, argp); release_sock(sk); return ret; @@ -1202,21 +1206,17 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) case SIOCSIFNETMASK: case SIOCGIFMETRIC: case SIOCSIFMETRIC: - release_sock(sk); return -EINVAL; case SIOCADDRT: case SIOCDELRT: case SIOCNRDECOBS: - release_sock(sk); if (!capable(CAP_NET_ADMIN)) return -EPERM; return nr_rt_ioctl(cmd, argp); default: - release_sock(sk); return dev_ioctl(cmd, argp); } - release_sock(sk); return 0; } -- cgit v1.1 From b5e5fa5e093e42cab4ee3d6dcbc4f450ad29a723 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 3 Jan 2006 14:18:33 -0800 Subject: [NET]: Add a dev_ioctl() fallback to sock_ioctl() Currently all network protocols need to call dev_ioctl as the default fallback in their ioctl implementations. This patch adds a fallback to dev_ioctl to sock_ioctl if the protocol returned -ENOIOCTLCMD. This way all the procotol ioctl handlers can be simplified and we don't need to export dev_ioctl. Signed-off-by: Christoph Hellwig Signed-off-by: David S. Miller --- net/appletalk/ddp.c | 19 +------------------ net/ax25/af_ax25.c | 2 +- net/core/dev.c | 1 - net/decnet/af_decnet.c | 2 +- net/econet/af_econet.c | 2 +- net/ipv4/af_inet.c | 8 ++++---- net/ipv6/af_inet6.c | 8 +++----- net/ipx/af_ipx.c | 2 +- net/irda/af_irda.c | 2 +- net/llc/af_llc.c | 2 +- net/netrom/af_netrom.c | 2 +- net/packet/af_packet.c | 2 +- net/rose/af_rose.c | 2 +- net/socket.c | 7 +++++++ net/unix/af_unix.c | 2 +- net/wanrouter/af_wanpipe.c | 2 +- net/x25/af_x25.c | 2 +- 17 files changed, 27 insertions(+), 40 deletions(-) diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 296f186..a5144e4 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -1763,7 +1763,7 @@ static int atalk_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr */ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { - int rc = -EINVAL; + int rc = -ENOIOCTLCMD; struct sock *sk = sock->sk; void __user *argp = (void __user *)arg; @@ -1813,23 +1813,6 @@ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) rc = atif_ioctl(cmd, argp); rtnl_unlock(); break; - /* Physical layer ioctl calls */ - case SIOCSIFLINK: - case SIOCGIFHWADDR: - case SIOCSIFHWADDR: - case SIOCGIFFLAGS: - case SIOCSIFFLAGS: - case SIOCGIFTXQLEN: - case SIOCSIFTXQLEN: - case SIOCGIFMTU: - case SIOCGIFCONF: - case SIOCADDMULTI: - case SIOCDELMULTI: - case SIOCGIFCOUNT: - case SIOCGIFINDEX: - case SIOCGIFNAME: - rc = dev_ioctl(cmd, argp); - break; } return rc; diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 8b5d10a..e8753c7 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1827,7 +1827,7 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) break; default: - res = dev_ioctl(cmd, argp); + res = -ENOIOCTLCMD; break; } release_sock(sk); diff --git a/net/core/dev.c b/net/core/dev.c index a5efc9a..29ba109 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3276,7 +3276,6 @@ EXPORT_SYMBOL(dev_close); EXPORT_SYMBOL(dev_get_by_flags); EXPORT_SYMBOL(dev_get_by_index); EXPORT_SYMBOL(dev_get_by_name); -EXPORT_SYMBOL(dev_ioctl); EXPORT_SYMBOL(dev_open); EXPORT_SYMBOL(dev_queue_xmit); EXPORT_SYMBOL(dev_remove_pack); diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index 65e3bae..78ec534 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -1252,7 +1252,7 @@ static int dn_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) break; default: - err = dev_ioctl(cmd, (void __user *)arg); + err = -ENOIOCTLCMD; break; } diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 70fb2b8..4fc2452 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c @@ -687,7 +687,7 @@ static int econet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg break; default: - return dev_ioctl(cmd, argp); + return -ENOIOCTLCMD; } /*NOTREACHED*/ return 0; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 36a6306..966a071 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -777,10 +777,10 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) err = devinet_ioctl(cmd, (void __user *)arg); break; default: - if (!sk->sk_prot->ioctl || - (err = sk->sk_prot->ioctl(sk, cmd, arg)) == - -ENOIOCTLCMD) - err = dev_ioctl(cmd, (void __user *)arg); + if (sk->sk_prot->ioctl) + err = sk->sk_prot->ioctl(sk, cmd, arg); + else + err = -ENOIOCTLCMD; break; } return err; diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 7c9f192..68afc53 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -434,7 +434,6 @@ int inet6_getname(struct socket *sock, struct sockaddr *uaddr, int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { struct sock *sk = sock->sk; - int err = -EINVAL; switch(cmd) { @@ -453,10 +452,9 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) case SIOCSIFDSTADDR: return addrconf_set_dstaddr((void __user *) arg); default: - if (!sk->sk_prot->ioctl || - (err = sk->sk_prot->ioctl(sk, cmd, arg)) == -ENOIOCTLCMD) - return(dev_ioctl(cmd,(void __user *) arg)); - return err; + if (!sk->sk_prot->ioctl) + return -ENOIOCTLCMD; + return sk->sk_prot->ioctl(sk, cmd, arg); } /*NOTREACHED*/ return(0); diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index 6c464c1..0dc519b 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -1884,7 +1884,7 @@ static int ipx_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) rc = -EINVAL; break; default: - rc = dev_ioctl(cmd, argp); + rc = -ENOIOCTLCMD; break; } diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c index e57683d..fbfa967 100644 --- a/net/irda/af_irda.c +++ b/net/irda/af_irda.c @@ -1822,7 +1822,7 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return -EINVAL; default: IRDA_DEBUG(1, "%s(), doing device ioctl!\n", __FUNCTION__); - return dev_ioctl(cmd, (void __user *) arg); + return -ENOIOCTLCMD; } /*NOTREACHED*/ diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 9cf65f9..8171c53 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c @@ -959,7 +959,7 @@ out: static int llc_ui_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { - return dev_ioctl(cmd, (void __user *)arg); + return -ENOIOCTLCMD; } /** diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 9ee672e..63b0e4a 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -1215,7 +1215,7 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return nr_rt_ioctl(cmd, argp); default: - return dev_ioctl(cmd, argp); + return -ENOIOCTLCMD; } return 0; diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index deda6fd..f69e5ed 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -1521,7 +1521,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd, #endif default: - return dev_ioctl(cmd, (void __user *)arg); + return -ENOIOCTLCMD; } return 0; } diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 829fdbc..63090be 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c @@ -1320,7 +1320,7 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return 0; default: - return dev_ioctl(cmd, argp); + return -ENOIOCTLCMD; } return 0; diff --git a/net/socket.c b/net/socket.c index 0dde6da..06fa217 100644 --- a/net/socket.c +++ b/net/socket.c @@ -900,6 +900,13 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) break; default: err = sock->ops->ioctl(sock, cmd, arg); + + /* + * If this ioctl is unknown try to hand it down + * to the NIC driver. + */ + if (err == -ENOIOCTLCMD) + err = dev_ioctl(cmd, argp); break; } return err; diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 1ddd36d..5f6ae79 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1859,7 +1859,7 @@ static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } default: - err = dev_ioctl(cmd, (void __user *)arg); + err = -ENOIOCTLCMD; break; } return err; diff --git a/net/wanrouter/af_wanpipe.c b/net/wanrouter/af_wanpipe.c index 67948bf..7a43ae4 100644 --- a/net/wanrouter/af_wanpipe.c +++ b/net/wanrouter/af_wanpipe.c @@ -1839,7 +1839,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar #endif default: - return dev_ioctl(cmd,(void __user *) arg); + return -ENOIOCTLCMD; } /*NOTREACHED*/ } diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index ca8b3b0..16459c7 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -1378,7 +1378,7 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) } default: - rc = dev_ioctl(cmd, argp); + rc = -ENOIOCTLCMD; break; } -- cgit v1.1 From fd30333d0fab9e870af89e112454996c188655e9 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Tue, 3 Jan 2006 14:19:25 -0800 Subject: [TG3]: fixup tot_len calculation Turning struct iphdr::tot_len into __be16 added sparse warning. Signed-off-by: Alexey Dobriyan Signed-off-by: David S. Miller --- drivers/net/tg3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 59d916c..eb86b05 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c @@ -3651,7 +3651,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev) TXD_FLAG_CPU_POST_DMA); skb->nh.iph->check = 0; - skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len); + skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len); if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { skb->h.th->check = 0; base_flags &= ~TXD_FLAG_TCPUDP_CSUM; -- cgit v1.1 From 4b5bdf5cc3695dc5caba011b9c616b40e6299638 Mon Sep 17 00:00:00 2001 From: Roberto Nibali Date: Tue, 3 Jan 2006 14:22:59 -0800 Subject: [IPVS]: Cleanup IP_VS_DBG statements. From: Roberto Nibali The attached patch (against current -GIT) is a cleanup patch which does following: o lookup debug messages shifted back to 9 o added more informational value to flags and refcnt since those entries can be in multiple referenced structures o cleanup 80 char violation It's the prepatch to the session pool implementation and helps very much to debug and monitor important variables and structures regarding the threshold limitation and persistency without the thousands of lookup messages which noone is interested in. Signed-off-by: Horms Signed-off-by: David S. Miller --- net/ipv4/ipvs/ip_vs_conn.c | 18 ++++++++++-------- net/ipv4/ipvs/ip_vs_core.c | 2 +- net/ipv4/ipvs/ip_vs_ctl.c | 9 +++++---- net/ipv4/ipvs/ip_vs_proto_tcp.c | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c index d35cea3..ed5bd56 100644 --- a/net/ipv4/ipvs/ip_vs_conn.c +++ b/net/ipv4/ipvs/ip_vs_conn.c @@ -221,7 +221,7 @@ struct ip_vs_conn *ip_vs_conn_in_get if (!cp && atomic_read(&ip_vs_conn_no_cport_cnt)) cp = __ip_vs_conn_in_get(protocol, s_addr, 0, d_addr, d_port); - IP_VS_DBG(7, "lookup/in %s %u.%u.%u.%u:%d->%u.%u.%u.%u:%d %s\n", + IP_VS_DBG(9, "lookup/in %s %u.%u.%u.%u:%d->%u.%u.%u.%u:%d %s\n", ip_vs_proto_name(protocol), NIPQUAD(s_addr), ntohs(s_port), NIPQUAD(d_addr), ntohs(d_port), @@ -256,7 +256,7 @@ struct ip_vs_conn *ip_vs_ct_in_get out: ct_read_unlock(hash); - IP_VS_DBG(7, "template lookup/in %s %u.%u.%u.%u:%d->%u.%u.%u.%u:%d %s\n", + IP_VS_DBG(9, "template lookup/in %s %u.%u.%u.%u:%d->%u.%u.%u.%u:%d %s\n", ip_vs_proto_name(protocol), NIPQUAD(s_addr), ntohs(s_port), NIPQUAD(d_addr), ntohs(d_port), @@ -297,7 +297,7 @@ struct ip_vs_conn *ip_vs_conn_out_get ct_read_unlock(hash); - IP_VS_DBG(7, "lookup/out %s %u.%u.%u.%u:%d->%u.%u.%u.%u:%d %s\n", + IP_VS_DBG(9, "lookup/out %s %u.%u.%u.%u:%d->%u.%u.%u.%u:%d %s\n", ip_vs_proto_name(protocol), NIPQUAD(s_addr), ntohs(s_port), NIPQUAD(d_addr), ntohs(d_port), @@ -393,8 +393,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) cp->flags |= atomic_read(&dest->conn_flags); cp->dest = dest; - IP_VS_DBG(9, "Bind-dest %s c:%u.%u.%u.%u:%d v:%u.%u.%u.%u:%d " - "d:%u.%u.%u.%u:%d fwd:%c s:%u flg:%X cnt:%d destcnt:%d\n", + IP_VS_DBG(7, "Bind-dest %s c:%u.%u.%u.%u:%d v:%u.%u.%u.%u:%d " + "d:%u.%u.%u.%u:%d fwd:%c s:%u conn->flags:%X conn->refcnt:%d " + "dest->refcnt:%d\n", ip_vs_proto_name(cp->protocol), NIPQUAD(cp->caddr), ntohs(cp->cport), NIPQUAD(cp->vaddr), ntohs(cp->vport), @@ -432,8 +433,9 @@ static inline void ip_vs_unbind_dest(struct ip_vs_conn *cp) if (!dest) return; - IP_VS_DBG(9, "Unbind-dest %s c:%u.%u.%u.%u:%d v:%u.%u.%u.%u:%d " - "d:%u.%u.%u.%u:%d fwd:%c s:%u flg:%X cnt:%d destcnt:%d\n", + IP_VS_DBG(7, "Unbind-dest %s c:%u.%u.%u.%u:%d v:%u.%u.%u.%u:%d " + "d:%u.%u.%u.%u:%d fwd:%c s:%u conn->flags:%X conn->refcnt:%d " + "dest->refcnt:%d\n", ip_vs_proto_name(cp->protocol), NIPQUAD(cp->caddr), ntohs(cp->cport), NIPQUAD(cp->vaddr), ntohs(cp->vport), @@ -573,7 +575,7 @@ static void ip_vs_conn_expire(unsigned long data) ip_vs_conn_hash(cp); expire_later: - IP_VS_DBG(7, "delayed: refcnt-1=%d conn.n_control=%d\n", + IP_VS_DBG(7, "delayed: conn->refcnt-1=%d conn->n_control=%d\n", atomic_read(&cp->refcnt)-1, atomic_read(&cp->n_control)); diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c index 1a0843c..1aca94a 100644 --- a/net/ipv4/ipvs/ip_vs_core.c +++ b/net/ipv4/ipvs/ip_vs_core.c @@ -426,7 +426,7 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb) return NULL; IP_VS_DBG(6, "Schedule fwd:%c c:%u.%u.%u.%u:%u v:%u.%u.%u.%u:%u " - "d:%u.%u.%u.%u:%u flg:%X cnt:%d\n", + "d:%u.%u.%u.%u:%u conn->flags:%X conn->refcnt:%d\n", ip_vs_fwd_tag(cp), NIPQUAD(cp->caddr), ntohs(cp->cport), NIPQUAD(cp->vaddr), ntohs(cp->vport), diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c index fe2c39d..c935c50 100644 --- a/net/ipv4/ipvs/ip_vs_ctl.c +++ b/net/ipv4/ipvs/ip_vs_ctl.c @@ -448,7 +448,7 @@ ip_vs_service_get(__u32 fwmark, __u16 protocol, __u32 vaddr, __u16 vport) out: read_unlock(&__ip_vs_svc_lock); - IP_VS_DBG(6, "lookup service: fwm %u %s %u.%u.%u.%u:%u %s\n", + IP_VS_DBG(9, "lookup service: fwm %u %s %u.%u.%u.%u:%u %s\n", fwmark, ip_vs_proto_name(protocol), NIPQUAD(vaddr), ntohs(vport), svc?"hit":"not hit"); @@ -598,7 +598,7 @@ ip_vs_trash_get_dest(struct ip_vs_service *svc, __u32 daddr, __u16 dport) */ list_for_each_entry_safe(dest, nxt, &ip_vs_dest_trash, n_list) { IP_VS_DBG(3, "Destination %u/%u.%u.%u.%u:%u still in trash, " - "refcnt=%d\n", + "dest->refcnt=%d\n", dest->vfwmark, NIPQUAD(dest->addr), ntohs(dest->port), atomic_read(&dest->refcnt)); @@ -805,7 +805,7 @@ ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest) dest = ip_vs_trash_get_dest(svc, daddr, dport); if (dest != NULL) { IP_VS_DBG(3, "Get destination %u.%u.%u.%u:%u from trash, " - "refcnt=%d, service %u/%u.%u.%u.%u:%u\n", + "dest->refcnt=%d, service %u/%u.%u.%u.%u:%u\n", NIPQUAD(daddr), ntohs(dport), atomic_read(&dest->refcnt), dest->vfwmark, @@ -950,7 +950,8 @@ static void __ip_vs_del_dest(struct ip_vs_dest *dest) atomic_dec(&dest->svc->refcnt); kfree(dest); } else { - IP_VS_DBG(3, "Moving dest %u.%u.%u.%u:%u into trash, refcnt=%d\n", + IP_VS_DBG(3, "Moving dest %u.%u.%u.%u:%u into trash, " + "dest->refcnt=%d\n", NIPQUAD(dest->addr), ntohs(dest->port), atomic_read(&dest->refcnt)); list_add(&dest->n_list, &ip_vs_dest_trash); diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c index 638ba8c..bc28b11 100644 --- a/net/ipv4/ipvs/ip_vs_proto_tcp.c +++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c @@ -426,7 +426,7 @@ set_tcp_state(struct ip_vs_protocol *pp, struct ip_vs_conn *cp, struct ip_vs_dest *dest = cp->dest; IP_VS_DBG(8, "%s %s [%c%c%c%c] %u.%u.%u.%u:%d->" - "%u.%u.%u.%u:%d state: %s->%s cnt:%d\n", + "%u.%u.%u.%u:%d state: %s->%s conn->refcnt:%d\n", pp->name, (state_off==TCP_DIR_OUTPUT)?"output ":"input ", th->syn? 'S' : '.', -- cgit v1.1 From 5062430c5cc526655e3d10c670fc9c263656f66c Mon Sep 17 00:00:00 2001 From: Patrick Caulfield Date: Tue, 3 Jan 2006 14:24:02 -0800 Subject: [DECNET]: Only use local routers The attached patch makes DECnet routing only use routers from the same area - rather than the highest rated router seen. In theory there should not be an out-of-area router on a local network but some networks are bridged rather than properly routed. VMS seems to behave similarly: if I bring up a VMS node with no router then it can't see anything else on the global network. Signed-off-by: Patrick Caulfield Signed-off-by: David S. Miller --- net/decnet/dn_neigh.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/decnet/dn_neigh.c b/net/decnet/dn_neigh.c index 8d0cc3c..33ab256 100644 --- a/net/decnet/dn_neigh.c +++ b/net/decnet/dn_neigh.c @@ -408,11 +408,14 @@ int dn_neigh_router_hello(struct sk_buff *skb) } } - if (!dn_db->router) { - dn_db->router = neigh_clone(neigh); - } else { - if (msg->priority > ((struct dn_neigh *)dn_db->router)->priority) - neigh_release(xchg(&dn_db->router, neigh_clone(neigh))); + /* Only use routers in our area */ + if ((dn_ntohs(src)>>10) == dn_ntohs((decnet_address)>>10)) { + if (!dn_db->router) { + dn_db->router = neigh_clone(neigh); + } else { + if (msg->priority > ((struct dn_neigh *)dn_db->router)->priority) + neigh_release(xchg(&dn_db->router, neigh_clone(neigh))); + } } write_unlock(&neigh->lock); neigh_release(neigh); -- cgit v1.1 From 709dd3aaf5304993083c2297c73f5531c36fba5a Mon Sep 17 00:00:00 2001 From: Andrea Bittau Date: Tue, 3 Jan 2006 14:25:17 -0800 Subject: [DCCP]: Do not process a packet twice when it's not in state DCCP_OPEN. When packets are received, the connection is either in DCCP_OPEN [fast-path] or it isn't. If it's not [e.g. DCCP_PARTOPEN] upper layers will perform sanity checks and parse options. If it is in DCCP_OPEN, dccp_rcv_established() will do it. It is important not to re-parse options in dccp_rcv_established() when it is not called from the fast-path. Else, fore example, the ack vector will be added twice and the CCID will see the packet twice. The solution is to always enfore sanity checks from the upper layers. When packets arrive in the fast-path, sanity checks will be performed before calling dccp_rcv_established(). Note(acme): I rewrote the patch to achieve the same result but keeping dccp_rcv_established with the previous semantics and having it split into __dccp_rcv_established, that doesn't does do any sanity check, code in state != DCCP_OPEN use this lighter version as they already do the sanity checks. Signed-off-by: Andrea Bittau Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/input.c | 56 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/net/dccp/input.c b/net/dccp/input.c index 55e921b..5e312b0 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c @@ -151,29 +151,12 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb) return 0; } -int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, - const struct dccp_hdr *dh, const unsigned len) +static inline int __dccp_rcv_established(struct sock *sk, struct sk_buff *skb, + const struct dccp_hdr *dh, + const unsigned len) { struct dccp_sock *dp = dccp_sk(sk); - if (dccp_check_seqno(sk, skb)) - goto discard; - - if (dccp_parse_options(sk, skb)) - goto discard; - - if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) - dccp_event_ack_recv(sk, skb); - - if (dp->dccps_options.dccpo_send_ack_vector && - dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, - DCCP_SKB_CB(skb)->dccpd_seq, - DCCP_ACKVEC_STATE_RECEIVED)) - goto discard; - - ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); - ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); - switch (dccp_hdr(skb)->dccph_type) { case DCCP_PKT_DATAACK: case DCCP_PKT_DATA: @@ -250,6 +233,35 @@ discard: return 0; } +int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, + const struct dccp_hdr *dh, const unsigned len) +{ + struct dccp_sock *dp = dccp_sk(sk); + + if (dccp_check_seqno(sk, skb)) + goto discard; + + if (dccp_parse_options(sk, skb)) + goto discard; + + if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) + dccp_event_ack_recv(sk, skb); + + if (dp->dccps_options.dccpo_send_ack_vector && + dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, + DCCP_SKB_CB(skb)->dccpd_seq, + DCCP_ACKVEC_STATE_RECEIVED)) + goto discard; + + ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); + ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); + + return __dccp_rcv_established(sk, skb, dh, len); +discard: + __kfree_skb(skb); + return 0; +} + EXPORT_SYMBOL_GPL(dccp_rcv_established); static int dccp_rcv_request_sent_state_process(struct sock *sk, @@ -400,9 +412,9 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk, if (dh->dccph_type == DCCP_PKT_DATAACK || dh->dccph_type == DCCP_PKT_DATA) { - dccp_rcv_established(sk, skb, dh, len); + __dccp_rcv_established(sk, skb, dh, len); queued = 1; /* packet was queued - (by dccp_rcv_established) */ + (by __dccp_rcv_established) */ } break; } -- cgit v1.1 From 9e377202d2c968dde8efd6121d94c7f0a77787aa Mon Sep 17 00:00:00 2001 From: Andrea Bittau Date: Tue, 3 Jan 2006 14:25:49 -0800 Subject: [DCCP]: Send an ACK vector when ACKing a response packet If ACK vectors are used, each packet with an ACK should contain an ACK vector. The only exception currently is response packets. It probably is not a good idea to store ACK vector state before the connection is completed (to help protect from syn floods). Signed-off-by: Andrea Bittau Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/input.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/dccp/input.c b/net/dccp/input.c index 5e312b0..cb0f5c9 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c @@ -300,6 +300,12 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, goto out_invalid_packet; } + if (dp->dccps_options.dccpo_send_ack_vector && + dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, + DCCP_SKB_CB(skb)->dccpd_seq, + DCCP_ACKVEC_STATE_RECEIVED)) + goto out_invalid_packet; /* FIXME: change error code */ + dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq; dccp_update_gsr(sk, dp->dccps_isr); /* -- cgit v1.1 From e84a9f5e9cd2b229dda24002334bc3cd36c1109d Mon Sep 17 00:00:00 2001 From: Andrea Bittau Date: Tue, 3 Jan 2006 14:26:15 -0800 Subject: [DCCP]: Notify CCID only after ACK vectors have been processed. The CCID should be notified of packet reception only when a packet is valid. Therefore, the ACK vector needs to be processed before notifying the CCID. Also, the CCID might need information provided by the ACK vector. Signed-off-by: Andrea Bittau Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/dccp/input.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/dccp/input.c b/net/dccp/input.c index cb0f5c9..b6cba72 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c @@ -492,14 +492,14 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, if (dcb->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) dccp_event_ack_recv(sk, skb); - ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); - ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); - if (dp->dccps_options.dccpo_send_ack_vector && dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, DCCP_SKB_CB(skb)->dccpd_seq, DCCP_ACKVEC_STATE_RECEIVED)) goto discard; + + ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); + ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb); } /* -- cgit v1.1 From 554c9a8ec37729bff69951cb740074abbae21afa Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 3 Jan 2006 14:35:54 -0800 Subject: [BRIDGE]: Fix faulty check in br_stp_recalculate_bridge_id() One of the conversions from memcmp to compare_ether_addr is incorrect. We need to do relative comparison to determine min MAC address to use in bridge id. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_stp_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c index 2d2e969..cc047f7 100644 --- a/net/bridge/br_stp_if.c +++ b/net/bridge/br_stp_if.c @@ -157,7 +157,7 @@ void br_stp_recalculate_bridge_id(struct net_bridge *br) list_for_each_entry(p, &br->port_list, list) { if (addr == br_mac_zero || - compare_ether_addr(p->dev->dev_addr, addr) < 0) + memcmp(p->dev->dev_addr, addr, ETH_ALEN) < 0) addr = p->dev->dev_addr; } -- cgit v1.1 From cd8787ab04d23f925f440b712b43a6fd5cb31ece Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 3 Jan 2006 14:38:34 -0800 Subject: [IPV4] fib_trie: build fix Need this to fix build of fib_trie in net-2.6.16 (rebased) tree. The code needs the new inet_make_mask inline. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/ipv4/fib_trie.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index a3ed7e1..e320b32 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #include #include -- cgit v1.1 From 88df8ef59a3eb54b1e2412765ff2736d2376d1ca Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 3 Jan 2006 15:25:45 -0800 Subject: [NET]: Don't exclude broadcast addresses from is_multicast_ether_addr() The check for multicast shouldn't exclude broadcast type addresses. This reverts the incorrect change done in 2.6.13. The broadcast address is a multicast address and should be excluded from being a valid_ether_address for use in bridging or device address. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- include/linux/etherdevice.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index 5f49a30..745c988 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -63,10 +63,11 @@ static inline int is_zero_ether_addr(const u8 *addr) * @addr: Pointer to a six-byte array containing the Ethernet address * * Return true if the address is a multicast address. + * By definition the broadcast address is also a multicast address. */ static inline int is_multicast_ether_addr(const u8 *addr) { - return ((addr[0] != 0xff) && (0x01 & addr[0])); + return (0x01 & addr[0]); } /** -- cgit v1.1 From 3c19065a1e2c862becc576bc65e54f2bc1cbffe6 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 3 Jan 2006 15:27:38 -0800 Subject: [IEEE80211] ipw2200: Simplify multicast checks. From: Stephen Hemminger is_multicast_ether_addr() accepts broadcast too, so the is_broadcast_ether_addr() calls are redundant. Signed-off-by: David S. Miller --- drivers/net/wireless/ipw2200.c | 15 +++++---------- net/ieee80211/ieee80211_rx.c | 5 ++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index 5e7c7e9..64f6d1f 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -7456,8 +7456,7 @@ static void ipw_handle_data_packet(struct ipw_priv *priv, /* HW decrypt will not clear the WEP bit, MIC, PN, etc. */ hdr = (struct ieee80211_hdr_4addr *)rxb->skb->data; if (priv->ieee->iw_mode != IW_MODE_MONITOR && - ((is_multicast_ether_addr(hdr->addr1) || - is_broadcast_ether_addr(hdr->addr1)) ? + (is_multicast_ether_addr(hdr->addr1) ? !priv->ieee->host_mc_decrypt : !priv->ieee->host_decrypt)) ipw_rebuild_decrypted_skb(priv, rxb->skb); @@ -7648,8 +7647,7 @@ static inline int is_network_packet(struct ipw_priv *priv, return 0; /* {broad,multi}cast packets to our BSSID go through */ - if (is_multicast_ether_addr(header->addr1) || - is_broadcast_ether_addr(header->addr1)) + if (is_multicast_ether_addr(header->addr1)) return !memcmp(header->addr3, priv->bssid, ETH_ALEN); /* packets to our adapter go through */ @@ -7662,8 +7660,7 @@ static inline int is_network_packet(struct ipw_priv *priv, return 0; /* {broad,multi}cast packets to our BSS go through */ - if (is_multicast_ether_addr(header->addr1) || - is_broadcast_ether_addr(header->addr1)) + if (is_multicast_ether_addr(header->addr1)) return !memcmp(header->addr2, priv->bssid, ETH_ALEN); /* packets to our adapter go through */ @@ -9657,8 +9654,7 @@ static inline int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb, switch (priv->ieee->iw_mode) { case IW_MODE_ADHOC: hdr_len = IEEE80211_3ADDR_LEN; - unicast = !(is_multicast_ether_addr(hdr->addr1) || - is_broadcast_ether_addr(hdr->addr1)); + unicast = !is_multicast_ether_addr(hdr->addr1); id = ipw_find_station(priv, hdr->addr1); if (id == IPW_INVALID_STATION) { id = ipw_add_station(priv, hdr->addr1); @@ -9673,8 +9669,7 @@ static inline int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb, case IW_MODE_INFRA: default: - unicast = !(is_multicast_ether_addr(hdr->addr3) || - is_broadcast_ether_addr(hdr->addr3)); + unicast = !is_multicast_ether_addr(hdr->addr3); hdr_len = IEEE80211_3ADDR_LEN; id = 0; break; diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c index 03efaac..4cc6f41 100644 --- a/net/ieee80211/ieee80211_rx.c +++ b/net/ieee80211/ieee80211_rx.c @@ -410,9 +410,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, return 1; } - if ((is_multicast_ether_addr(hdr->addr1) || - is_broadcast_ether_addr(hdr->addr2)) ? ieee->host_mc_decrypt : - ieee->host_decrypt) { + if (is_multicast_ether_addr(hdr->addr1) + ? ieee->host_mc_decrypt : ieee->host_decrypt) { int idx = 0; if (skb->len >= hdrlen + 3) idx = skb->data[hdrlen + 3] >> 6; -- cgit v1.1 From 40efc6fa179f440a008333ea98f701bc35a1f97f Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 3 Jan 2006 16:03:49 -0800 Subject: [TCP]: less inline's TCP inline usage cleanup: * get rid of inline in several places * replace __inline__ with inline where possible * move functions used in one file out of tcp.h * let compiler decide on used once cases On x86_64: text data bss dec hex filename 3594701 648348 567400 4810449 4966d1 vmlinux.orig 3593133 648580 567400 4809113 496199 vmlinux On sparc64: text data bss dec hex filename 2538278 406152 530392 3474822 350586 vmlinux.ORIG 2536382 406384 530392 3473158 34ff06 vmlinux Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- include/net/tcp.h | 193 +++++++------------------------------------------- net/ipv4/tcp_cong.c | 28 ++++++++ net/ipv4/tcp_input.c | 82 +++++++++++++++------ net/ipv4/tcp_ipv4.c | 9 ++- net/ipv4/tcp_output.c | 87 ++++++++++++++++++++--- 5 files changed, 198 insertions(+), 201 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index 3699304..77f21c6 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -445,34 +445,16 @@ typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, extern int tcp_read_sock(struct sock *sk, read_descriptor_t *desc, sk_read_actor_t recv_actor); -/* Initialize RCV_MSS value. - * RCV_MSS is an our guess about MSS used by the peer. - * We haven't any direct information about the MSS. - * It's better to underestimate the RCV_MSS rather than overestimate. - * Overestimations make us ACKing less frequently than needed. - * Underestimations are more easy to detect and fix by tcp_measure_rcv_mss(). - */ +extern void tcp_initialize_rcv_mss(struct sock *sk); -static inline void tcp_initialize_rcv_mss(struct sock *sk) -{ - struct tcp_sock *tp = tcp_sk(sk); - unsigned int hint = min_t(unsigned int, tp->advmss, tp->mss_cache); - - hint = min(hint, tp->rcv_wnd/2); - hint = min(hint, TCP_MIN_RCVMSS); - hint = max(hint, TCP_MIN_MSS); - - inet_csk(sk)->icsk_ack.rcv_mss = hint; -} - -static __inline__ void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd) +static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd) { tp->pred_flags = htonl((tp->tcp_header_len << 26) | ntohl(TCP_FLAG_ACK) | snd_wnd); } -static __inline__ void tcp_fast_path_on(struct tcp_sock *tp) +static inline void tcp_fast_path_on(struct tcp_sock *tp) { __tcp_fast_path_on(tp, tp->snd_wnd >> tp->rx_opt.snd_wscale); } @@ -490,7 +472,7 @@ static inline void tcp_fast_path_check(struct sock *sk, struct tcp_sock *tp) * Rcv_nxt can be after the window if our peer push more data * than the offered window. */ -static __inline__ u32 tcp_receive_window(const struct tcp_sock *tp) +static inline u32 tcp_receive_window(const struct tcp_sock *tp) { s32 win = tp->rcv_wup + tp->rcv_wnd - tp->rcv_nxt; @@ -662,6 +644,7 @@ extern void tcp_cleanup_congestion_control(struct sock *sk); extern int tcp_set_default_congestion_control(const char *name); extern void tcp_get_default_congestion_control(char *name); extern int tcp_set_congestion_control(struct sock *sk, const char *name); +extern void tcp_slow_start(struct tcp_sock *tp); extern struct tcp_congestion_ops tcp_init_congestion_ops; extern u32 tcp_reno_ssthresh(struct sock *sk); @@ -701,7 +684,7 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event) * "Packets left network, but not honestly ACKed yet" PLUS * "Packets fast retransmitted" */ -static __inline__ unsigned int tcp_packets_in_flight(const struct tcp_sock *tp) +static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp) { return (tp->packets_out - tp->left_out + tp->retrans_out); } @@ -721,33 +704,6 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk) (tp->snd_cwnd >> 2))); } -/* - * Linear increase during slow start - */ -static inline void tcp_slow_start(struct tcp_sock *tp) -{ - if (sysctl_tcp_abc) { - /* RFC3465: Slow Start - * TCP sender SHOULD increase cwnd by the number of - * previously unacknowledged bytes ACKed by each incoming - * acknowledgment, provided the increase is not more than L - */ - if (tp->bytes_acked < tp->mss_cache) - return; - - /* We MAY increase by 2 if discovered delayed ack */ - if (sysctl_tcp_abc > 1 && tp->bytes_acked > 2*tp->mss_cache) { - if (tp->snd_cwnd < tp->snd_cwnd_clamp) - tp->snd_cwnd++; - } - } - tp->bytes_acked = 0; - - if (tp->snd_cwnd < tp->snd_cwnd_clamp) - tp->snd_cwnd++; -} - - static inline void tcp_sync_left_out(struct tcp_sock *tp) { if (tp->rx_opt.sack_ok && @@ -756,34 +712,7 @@ static inline void tcp_sync_left_out(struct tcp_sock *tp) tp->left_out = tp->sacked_out + tp->lost_out; } -/* Set slow start threshold and cwnd not falling to slow start */ -static inline void __tcp_enter_cwr(struct sock *sk) -{ - const struct inet_connection_sock *icsk = inet_csk(sk); - struct tcp_sock *tp = tcp_sk(sk); - - tp->undo_marker = 0; - tp->snd_ssthresh = icsk->icsk_ca_ops->ssthresh(sk); - tp->snd_cwnd = min(tp->snd_cwnd, - tcp_packets_in_flight(tp) + 1U); - tp->snd_cwnd_cnt = 0; - tp->high_seq = tp->snd_nxt; - tp->snd_cwnd_stamp = tcp_time_stamp; - TCP_ECN_queue_cwr(tp); -} - -static inline void tcp_enter_cwr(struct sock *sk) -{ - struct tcp_sock *tp = tcp_sk(sk); - - tp->prior_ssthresh = 0; - tp->bytes_acked = 0; - if (inet_csk(sk)->icsk_ca_state < TCP_CA_CWR) { - __tcp_enter_cwr(sk); - tcp_set_ca_state(sk, TCP_CA_CWR); - } -} - +extern void tcp_enter_cwr(struct sock *sk); extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); /* Slow start with delack produces 3 packets of burst, so that @@ -815,14 +744,14 @@ static inline int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight) return left <= tcp_max_burst(tp); } -static __inline__ void tcp_minshall_update(struct tcp_sock *tp, int mss, - const struct sk_buff *skb) +static inline void tcp_minshall_update(struct tcp_sock *tp, int mss, + const struct sk_buff *skb) { if (skb->len < mss) tp->snd_sml = TCP_SKB_CB(skb)->end_seq; } -static __inline__ void tcp_check_probe_timer(struct sock *sk, struct tcp_sock *tp) +static inline void tcp_check_probe_timer(struct sock *sk, struct tcp_sock *tp) { const struct inet_connection_sock *icsk = inet_csk(sk); if (!tp->packets_out && !icsk->icsk_pending) @@ -830,18 +759,18 @@ static __inline__ void tcp_check_probe_timer(struct sock *sk, struct tcp_sock *t icsk->icsk_rto, TCP_RTO_MAX); } -static __inline__ void tcp_push_pending_frames(struct sock *sk, - struct tcp_sock *tp) +static inline void tcp_push_pending_frames(struct sock *sk, + struct tcp_sock *tp) { __tcp_push_pending_frames(sk, tp, tcp_current_mss(sk, 1), tp->nonagle); } -static __inline__ void tcp_init_wl(struct tcp_sock *tp, u32 ack, u32 seq) +static inline void tcp_init_wl(struct tcp_sock *tp, u32 ack, u32 seq) { tp->snd_wl1 = seq; } -static __inline__ void tcp_update_wl(struct tcp_sock *tp, u32 ack, u32 seq) +static inline void tcp_update_wl(struct tcp_sock *tp, u32 ack, u32 seq) { tp->snd_wl1 = seq; } @@ -849,19 +778,19 @@ static __inline__ void tcp_update_wl(struct tcp_sock *tp, u32 ack, u32 seq) /* * Calculate(/check) TCP checksum */ -static __inline__ u16 tcp_v4_check(struct tcphdr *th, int len, - unsigned long saddr, unsigned long daddr, - unsigned long base) +static inline u16 tcp_v4_check(struct tcphdr *th, int len, + unsigned long saddr, unsigned long daddr, + unsigned long base) { return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base); } -static __inline__ int __tcp_checksum_complete(struct sk_buff *skb) +static inline int __tcp_checksum_complete(struct sk_buff *skb) { return __skb_checksum_complete(skb); } -static __inline__ int tcp_checksum_complete(struct sk_buff *skb) +static inline int tcp_checksum_complete(struct sk_buff *skb) { return skb->ip_summed != CHECKSUM_UNNECESSARY && __tcp_checksum_complete(skb); @@ -869,7 +798,7 @@ static __inline__ int tcp_checksum_complete(struct sk_buff *skb) /* Prequeue for VJ style copy to user, combined with checksumming. */ -static __inline__ void tcp_prequeue_init(struct tcp_sock *tp) +static inline void tcp_prequeue_init(struct tcp_sock *tp) { tp->ucopy.task = NULL; tp->ucopy.len = 0; @@ -885,7 +814,7 @@ static __inline__ void tcp_prequeue_init(struct tcp_sock *tp) * * NOTE: is this not too big to inline? */ -static __inline__ int tcp_prequeue(struct sock *sk, struct sk_buff *skb) +static inline int tcp_prequeue(struct sock *sk, struct sk_buff *skb) { struct tcp_sock *tp = tcp_sk(sk); @@ -926,7 +855,7 @@ static const char *statename[]={ }; #endif -static __inline__ void tcp_set_state(struct sock *sk, int state) +static inline void tcp_set_state(struct sock *sk, int state) { int oldstate = sk->sk_state; @@ -960,7 +889,7 @@ static __inline__ void tcp_set_state(struct sock *sk, int state) #endif } -static __inline__ void tcp_done(struct sock *sk) +static inline void tcp_done(struct sock *sk) { tcp_set_state(sk, TCP_CLOSE); tcp_clear_xmit_timers(sk); @@ -973,81 +902,13 @@ static __inline__ void tcp_done(struct sock *sk) inet_csk_destroy_sock(sk); } -static __inline__ void tcp_sack_reset(struct tcp_options_received *rx_opt) +static inline void tcp_sack_reset(struct tcp_options_received *rx_opt) { rx_opt->dsack = 0; rx_opt->eff_sacks = 0; rx_opt->num_sacks = 0; } -static __inline__ void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp, __u32 tstamp) -{ - if (tp->rx_opt.tstamp_ok) { - *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | - (TCPOPT_NOP << 16) | - (TCPOPT_TIMESTAMP << 8) | - TCPOLEN_TIMESTAMP); - *ptr++ = htonl(tstamp); - *ptr++ = htonl(tp->rx_opt.ts_recent); - } - if (tp->rx_opt.eff_sacks) { - struct tcp_sack_block *sp = tp->rx_opt.dsack ? tp->duplicate_sack : tp->selective_acks; - int this_sack; - - *ptr++ = htonl((TCPOPT_NOP << 24) | - (TCPOPT_NOP << 16) | - (TCPOPT_SACK << 8) | - (TCPOLEN_SACK_BASE + (tp->rx_opt.eff_sacks * - TCPOLEN_SACK_PERBLOCK))); - for(this_sack = 0; this_sack < tp->rx_opt.eff_sacks; this_sack++) { - *ptr++ = htonl(sp[this_sack].start_seq); - *ptr++ = htonl(sp[this_sack].end_seq); - } - if (tp->rx_opt.dsack) { - tp->rx_opt.dsack = 0; - tp->rx_opt.eff_sacks--; - } - } -} - -/* Construct a tcp options header for a SYN or SYN_ACK packet. - * If this is every changed make sure to change the definition of - * MAX_SYN_SIZE to match the new maximum number of options that you - * can generate. - */ -static inline void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sack, - int offer_wscale, int wscale, __u32 tstamp, __u32 ts_recent) -{ - /* We always get an MSS option. - * The option bytes which will be seen in normal data - * packets should timestamps be used, must be in the MSS - * advertised. But we subtract them from tp->mss_cache so - * that calculations in tcp_sendmsg are simpler etc. - * So account for this fact here if necessary. If we - * don't do this correctly, as a receiver we won't - * recognize data packets as being full sized when we - * should, and thus we won't abide by the delayed ACK - * rules correctly. - * SACKs don't matter, we never delay an ACK when we - * have any of those going out. - */ - *ptr++ = htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) | mss); - if (ts) { - if(sack) - *ptr++ = __constant_htonl((TCPOPT_SACK_PERM << 24) | (TCPOLEN_SACK_PERM << 16) | - (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); - else - *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | - (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); - *ptr++ = htonl(tstamp); /* TSVAL */ - *ptr++ = htonl(ts_recent); /* TSECR */ - } else if(sack) - *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | - (TCPOPT_SACK_PERM << 8) | TCPOLEN_SACK_PERM); - if (offer_wscale) - *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_WINDOW << 16) | (TCPOLEN_WINDOW << 8) | (wscale)); -} - /* Determine a window scaling and initial window to offer. */ extern void tcp_select_initial_window(int __space, __u32 mss, __u32 *rcv_wnd, __u32 *window_clamp, @@ -1072,9 +933,9 @@ static inline int tcp_full_space(const struct sock *sk) return tcp_win_from_space(sk->sk_rcvbuf); } -static __inline__ void tcp_openreq_init(struct request_sock *req, - struct tcp_options_received *rx_opt, - struct sk_buff *skb) +static inline void tcp_openreq_init(struct request_sock *req, + struct tcp_options_received *rx_opt, + struct sk_buff *skb) { struct inet_request_sock *ireq = inet_rsk(req); diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c index c7cc62c..e688c68 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c @@ -174,6 +174,34 @@ int tcp_set_congestion_control(struct sock *sk, const char *name) return err; } + +/* + * Linear increase during slow start + */ +void tcp_slow_start(struct tcp_sock *tp) +{ + if (sysctl_tcp_abc) { + /* RFC3465: Slow Start + * TCP sender SHOULD increase cwnd by the number of + * previously unacknowledged bytes ACKed by each incoming + * acknowledgment, provided the increase is not more than L + */ + if (tp->bytes_acked < tp->mss_cache) + return; + + /* We MAY increase by 2 if discovered delayed ack */ + if (sysctl_tcp_abc > 1 && tp->bytes_acked > 2*tp->mss_cache) { + if (tp->snd_cwnd < tp->snd_cwnd_clamp) + tp->snd_cwnd++; + } + } + tp->bytes_acked = 0; + + if (tp->snd_cwnd < tp->snd_cwnd_clamp) + tp->snd_cwnd++; +} +EXPORT_SYMBOL_GPL(tcp_slow_start); + /* * TCP Reno congestion control * This is special case used for fallback as well. diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 981d120..0a46123 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -115,8 +115,8 @@ int sysctl_tcp_abc = 1; /* Adapt the MSS value used to make delayed ack decision to the * real world. */ -static inline void tcp_measure_rcv_mss(struct sock *sk, - const struct sk_buff *skb) +static void tcp_measure_rcv_mss(struct sock *sk, + const struct sk_buff *skb) { struct inet_connection_sock *icsk = inet_csk(sk); const unsigned int lss = icsk->icsk_ack.last_seg_size; @@ -246,8 +246,8 @@ static int __tcp_grow_window(const struct sock *sk, struct tcp_sock *tp, return 0; } -static inline void tcp_grow_window(struct sock *sk, struct tcp_sock *tp, - struct sk_buff *skb) +static void tcp_grow_window(struct sock *sk, struct tcp_sock *tp, + struct sk_buff *skb) { /* Check #1 */ if (tp->rcv_ssthresh < tp->window_clamp && @@ -341,6 +341,26 @@ static void tcp_clamp_window(struct sock *sk, struct tcp_sock *tp) tp->rcv_ssthresh = min(tp->window_clamp, 2U*tp->advmss); } + +/* Initialize RCV_MSS value. + * RCV_MSS is an our guess about MSS used by the peer. + * We haven't any direct information about the MSS. + * It's better to underestimate the RCV_MSS rather than overestimate. + * Overestimations make us ACKing less frequently than needed. + * Underestimations are more easy to detect and fix by tcp_measure_rcv_mss(). + */ +void tcp_initialize_rcv_mss(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + unsigned int hint = min_t(unsigned int, tp->advmss, tp->mss_cache); + + hint = min(hint, tp->rcv_wnd/2); + hint = min(hint, TCP_MIN_RCVMSS); + hint = max(hint, TCP_MIN_MSS); + + inet_csk(sk)->icsk_ack.rcv_mss = hint; +} + /* Receiver "autotuning" code. * * The algorithm for RTT estimation w/o timestamps is based on @@ -735,6 +755,27 @@ __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst) return min_t(__u32, cwnd, tp->snd_cwnd_clamp); } +/* Set slow start threshold and cwnd not falling to slow start */ +void tcp_enter_cwr(struct sock *sk) +{ + struct tcp_sock *tp = tcp_sk(sk); + + tp->prior_ssthresh = 0; + tp->bytes_acked = 0; + if (inet_csk(sk)->icsk_ca_state < TCP_CA_CWR) { + tp->undo_marker = 0; + tp->snd_ssthresh = inet_csk(sk)->icsk_ca_ops->ssthresh(sk); + tp->snd_cwnd = min(tp->snd_cwnd, + tcp_packets_in_flight(tp) + 1U); + tp->snd_cwnd_cnt = 0; + tp->high_seq = tp->snd_nxt; + tp->snd_cwnd_stamp = tcp_time_stamp; + TCP_ECN_queue_cwr(tp); + + tcp_set_ca_state(sk, TCP_CA_CWR); + } +} + /* Initialize metrics on socket. */ static void tcp_init_metrics(struct sock *sk) @@ -2070,8 +2111,8 @@ static inline void tcp_ack_update_rtt(struct sock *sk, const int flag, tcp_ack_no_tstamp(sk, seq_rtt, flag); } -static inline void tcp_cong_avoid(struct sock *sk, u32 ack, u32 rtt, - u32 in_flight, int good) +static void tcp_cong_avoid(struct sock *sk, u32 ack, u32 rtt, + u32 in_flight, int good) { const struct inet_connection_sock *icsk = inet_csk(sk); icsk->icsk_ca_ops->cong_avoid(sk, ack, rtt, in_flight, good); @@ -2082,7 +2123,7 @@ static inline void tcp_cong_avoid(struct sock *sk, u32 ack, u32 rtt, * RFC2988 recommends to restart timer to now+rto. */ -static inline void tcp_ack_packets_out(struct sock *sk, struct tcp_sock *tp) +static void tcp_ack_packets_out(struct sock *sk, struct tcp_sock *tp) { if (!tp->packets_out) { inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); @@ -2147,7 +2188,7 @@ static int tcp_tso_acked(struct sock *sk, struct sk_buff *skb, return acked; } -static inline u32 tcp_usrtt(const struct sk_buff *skb) +static u32 tcp_usrtt(const struct sk_buff *skb) { struct timeval tv, now; @@ -2583,8 +2624,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, /* Fast parse options. This hopes to only see timestamps. * If it is wrong it falls back on tcp_parse_options(). */ -static inline int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th, - struct tcp_sock *tp) +static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th, + struct tcp_sock *tp) { if (th->doff == sizeof(struct tcphdr)>>2) { tp->rx_opt.saw_tstamp = 0; @@ -2804,8 +2845,7 @@ static void tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th) } } -static __inline__ int -tcp_sack_extend(struct tcp_sack_block *sp, u32 seq, u32 end_seq) +static inline int tcp_sack_extend(struct tcp_sack_block *sp, u32 seq, u32 end_seq) { if (!after(seq, sp->end_seq) && !after(sp->start_seq, end_seq)) { if (before(seq, sp->start_seq)) @@ -2817,7 +2857,7 @@ tcp_sack_extend(struct tcp_sack_block *sp, u32 seq, u32 end_seq) return 0; } -static inline void tcp_dsack_set(struct tcp_sock *tp, u32 seq, u32 end_seq) +static void tcp_dsack_set(struct tcp_sock *tp, u32 seq, u32 end_seq) { if (tp->rx_opt.sack_ok && sysctl_tcp_dsack) { if (before(seq, tp->rcv_nxt)) @@ -2832,7 +2872,7 @@ static inline void tcp_dsack_set(struct tcp_sock *tp, u32 seq, u32 end_seq) } } -static inline void tcp_dsack_extend(struct tcp_sock *tp, u32 seq, u32 end_seq) +static void tcp_dsack_extend(struct tcp_sock *tp, u32 seq, u32 end_seq) { if (!tp->rx_opt.dsack) tcp_dsack_set(tp, seq, end_seq); @@ -2890,7 +2930,7 @@ static void tcp_sack_maybe_coalesce(struct tcp_sock *tp) } } -static __inline__ void tcp_sack_swap(struct tcp_sack_block *sack1, struct tcp_sack_block *sack2) +static inline void tcp_sack_swap(struct tcp_sack_block *sack1, struct tcp_sack_block *sack2) { __u32 tmp; @@ -3455,7 +3495,7 @@ void tcp_cwnd_application_limited(struct sock *sk) tp->snd_cwnd_stamp = tcp_time_stamp; } -static inline int tcp_should_expand_sndbuf(struct sock *sk, struct tcp_sock *tp) +static int tcp_should_expand_sndbuf(struct sock *sk, struct tcp_sock *tp) { /* If the user specified a specific send buffer setting, do * not modify it. @@ -3502,7 +3542,7 @@ static void tcp_new_space(struct sock *sk) sk->sk_write_space(sk); } -static inline void tcp_check_space(struct sock *sk) +static void tcp_check_space(struct sock *sk) { if (sock_flag(sk, SOCK_QUEUE_SHRUNK)) { sock_reset_flag(sk, SOCK_QUEUE_SHRUNK); @@ -3512,7 +3552,7 @@ static inline void tcp_check_space(struct sock *sk) } } -static __inline__ void tcp_data_snd_check(struct sock *sk, struct tcp_sock *tp) +static inline void tcp_data_snd_check(struct sock *sk, struct tcp_sock *tp) { tcp_push_pending_frames(sk, tp); tcp_check_space(sk); @@ -3544,7 +3584,7 @@ static void __tcp_ack_snd_check(struct sock *sk, int ofo_possible) } } -static __inline__ void tcp_ack_snd_check(struct sock *sk) +static inline void tcp_ack_snd_check(struct sock *sk) { if (!inet_csk_ack_scheduled(sk)) { /* We sent a data segment already. */ @@ -3692,8 +3732,7 @@ static int __tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb) return result; } -static __inline__ int -tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb) +static inline int tcp_checksum_complete_user(struct sock *sk, struct sk_buff *skb) { return skb->ip_summed != CHECKSUM_UNNECESSARY && __tcp_checksum_complete_user(sk, skb); @@ -4474,3 +4513,4 @@ EXPORT_SYMBOL(sysctl_tcp_abc); EXPORT_SYMBOL(tcp_parse_options); EXPORT_SYMBOL(tcp_rcv_established); EXPORT_SYMBOL(tcp_rcv_state_process); +EXPORT_SYMBOL(tcp_initialize_rcv_mss); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 9b62d80..5c70493 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -270,8 +270,7 @@ failure: /* * This routine does path mtu discovery as defined in RFC1191. */ -static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *iph, - u32 mtu) +static void do_pmtu_discovery(struct sock *sk, struct iphdr *iph, u32 mtu) { struct dst_entry *dst; struct inet_sock *inet = inet_sk(sk); @@ -662,7 +661,7 @@ static void tcp_v4_reqsk_destructor(struct request_sock *req) kfree(inet_rsk(req)->opt); } -static inline void syn_flood_warning(struct sk_buff *skb) +static void syn_flood_warning(struct sk_buff *skb) { static unsigned long warntime; @@ -677,8 +676,8 @@ static inline void syn_flood_warning(struct sk_buff *skb) /* * Save and compile IPv4 options into the request_sock if needed. */ -static inline struct ip_options *tcp_v4_save_options(struct sock *sk, - struct sk_buff *skb) +static struct ip_options *tcp_v4_save_options(struct sock *sk, + struct sk_buff *skb) { struct ip_options *opt = &(IPCB(skb)->opt); struct ip_options *dopt = NULL; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 3a0a914..a7623ea 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -51,8 +51,8 @@ int sysctl_tcp_retrans_collapse = 1; */ int sysctl_tcp_tso_win_divisor = 3; -static inline void update_send_head(struct sock *sk, struct tcp_sock *tp, - struct sk_buff *skb) +static void update_send_head(struct sock *sk, struct tcp_sock *tp, + struct sk_buff *skb) { sk->sk_send_head = skb->next; if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue) @@ -124,8 +124,8 @@ static void tcp_cwnd_restart(struct sock *sk, struct dst_entry *dst) tp->snd_cwnd_used = 0; } -static inline void tcp_event_data_sent(struct tcp_sock *tp, - struct sk_buff *skb, struct sock *sk) +static void tcp_event_data_sent(struct tcp_sock *tp, + struct sk_buff *skb, struct sock *sk) { struct inet_connection_sock *icsk = inet_csk(sk); const u32 now = tcp_time_stamp; @@ -142,7 +142,7 @@ static inline void tcp_event_data_sent(struct tcp_sock *tp, icsk->icsk_ack.pingpong = 1; } -static __inline__ void tcp_event_ack_sent(struct sock *sk, unsigned int pkts) +static inline void tcp_event_ack_sent(struct sock *sk, unsigned int pkts) { tcp_dec_quickack_mode(sk, pkts); inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); @@ -212,7 +212,7 @@ void tcp_select_initial_window(int __space, __u32 mss, * value can be stuffed directly into th->window for an outgoing * frame. */ -static __inline__ u16 tcp_select_window(struct sock *sk) +static u16 tcp_select_window(struct sock *sk) { struct tcp_sock *tp = tcp_sk(sk); u32 cur_win = tcp_receive_window(tp); @@ -250,6 +250,75 @@ static __inline__ u16 tcp_select_window(struct sock *sk) return new_win; } +static void tcp_build_and_update_options(__u32 *ptr, struct tcp_sock *tp, + __u32 tstamp) +{ + if (tp->rx_opt.tstamp_ok) { + *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | + (TCPOPT_NOP << 16) | + (TCPOPT_TIMESTAMP << 8) | + TCPOLEN_TIMESTAMP); + *ptr++ = htonl(tstamp); + *ptr++ = htonl(tp->rx_opt.ts_recent); + } + if (tp->rx_opt.eff_sacks) { + struct tcp_sack_block *sp = tp->rx_opt.dsack ? tp->duplicate_sack : tp->selective_acks; + int this_sack; + + *ptr++ = htonl((TCPOPT_NOP << 24) | + (TCPOPT_NOP << 16) | + (TCPOPT_SACK << 8) | + (TCPOLEN_SACK_BASE + (tp->rx_opt.eff_sacks * + TCPOLEN_SACK_PERBLOCK))); + for(this_sack = 0; this_sack < tp->rx_opt.eff_sacks; this_sack++) { + *ptr++ = htonl(sp[this_sack].start_seq); + *ptr++ = htonl(sp[this_sack].end_seq); + } + if (tp->rx_opt.dsack) { + tp->rx_opt.dsack = 0; + tp->rx_opt.eff_sacks--; + } + } +} + +/* Construct a tcp options header for a SYN or SYN_ACK packet. + * If this is every changed make sure to change the definition of + * MAX_SYN_SIZE to match the new maximum number of options that you + * can generate. + */ +static void tcp_syn_build_options(__u32 *ptr, int mss, int ts, int sack, + int offer_wscale, int wscale, __u32 tstamp, + __u32 ts_recent) +{ + /* We always get an MSS option. + * The option bytes which will be seen in normal data + * packets should timestamps be used, must be in the MSS + * advertised. But we subtract them from tp->mss_cache so + * that calculations in tcp_sendmsg are simpler etc. + * So account for this fact here if necessary. If we + * don't do this correctly, as a receiver we won't + * recognize data packets as being full sized when we + * should, and thus we won't abide by the delayed ACK + * rules correctly. + * SACKs don't matter, we never delay an ACK when we + * have any of those going out. + */ + *ptr++ = htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) | mss); + if (ts) { + if(sack) + *ptr++ = __constant_htonl((TCPOPT_SACK_PERM << 24) | (TCPOLEN_SACK_PERM << 16) | + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); + else + *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); + *ptr++ = htonl(tstamp); /* TSVAL */ + *ptr++ = htonl(ts_recent); /* TSECR */ + } else if(sack) + *ptr++ = __constant_htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | + (TCPOPT_SACK_PERM << 8) | TCPOLEN_SACK_PERM); + if (offer_wscale) + *ptr++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_WINDOW << 16) | (TCPOLEN_WINDOW << 8) | (wscale)); +} /* This routine actually transmits TCP packets queued in by * tcp_do_sendmsg(). This is used by both the initial @@ -724,7 +793,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) /* Congestion window validation. (RFC2861) */ -static inline void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp) +static void tcp_cwnd_validate(struct sock *sk, struct tcp_sock *tp) { __u32 packets_out = tp->packets_out; @@ -773,7 +842,7 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, struct sk_buff *sk /* This must be invoked the first time we consider transmitting * SKB onto the wire. */ -static inline int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now) +static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned int mss_now) { int tso_segs = tcp_skb_pcount(skb); @@ -1794,7 +1863,7 @@ struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, /* * Do all connect socket setups that can be done AF independent. */ -static inline void tcp_connect_init(struct sock *sk) +static void tcp_connect_init(struct sock *sk) { struct dst_entry *dst = __sk_dst_get(sk); struct tcp_sock *tp = tcp_sk(sk); -- cgit v1.1 From 6742bbcbb8a0959e1dff0ce055768e3217d9967a Mon Sep 17 00:00:00 2001 From: Andrea Bittau Date: Wed, 4 Jan 2006 01:45:17 -0200 Subject: [DCCP] ackvec: Fix spelling of "throw" Signed-off-by: Andrea Bittau Signed-off-by: Arnaldo Carvalho de Melo --- net/dccp/ackvec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c index c9a62cc..a979f4e 100644 --- a/net/dccp/ackvec.c +++ b/net/dccp/ackvec.c @@ -291,7 +291,7 @@ void dccp_ackvec_print(const struct dccp_ackvec *av) } #endif -static void dccp_ackvec_trow_away_ack_record(struct dccp_ackvec *av) +static void dccp_ackvec_throw_away_ack_record(struct dccp_ackvec *av) { /* * As we're keeping track of the ack vector size (dccpav_vec_len) and @@ -326,7 +326,7 @@ void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, struct sock *sk, debug_prefix, 1, (unsigned long long)av->dccpav_ack_seqno, (unsigned long long)av->dccpav_ack_ackno); - dccp_ackvec_trow_away_ack_record(av); + dccp_ackvec_throw_away_ack_record(av); av->dccpav_ack_seqno = DCCP_MAX_SEQNO + 1; } } @@ -389,7 +389,7 @@ static void dccp_ackvec_check_rcv_ackvector(struct dccp_ackvec *av, av->dccpav_ack_seqno, (unsigned long long) av->dccpav_ack_ackno); - dccp_ackvec_trow_away_ack_record(av); + dccp_ackvec_throw_away_ack_record(av); } /* * If dccpav_ack_seqno was not received, no problem -- cgit v1.1 From e4dfd449c80a41bb615b23d0fc198ba08360a1f8 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 4 Jan 2006 01:46:34 -0200 Subject: [DCCP] ackvec: use u8 for the buf offsets Signed-off-by: Arnaldo Carvalho de Melo --- net/dccp/ackvec.c | 27 +++++++++++++++++---------- net/dccp/ackvec.h | 12 ++++++------ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c index a979f4e..ce9cb77 100644 --- a/net/dccp/ackvec.c +++ b/net/dccp/ackvec.c @@ -55,8 +55,8 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb) from = av->dccpav_buf + av->dccpav_buf_head; /* Check if buf_head wraps */ - if (av->dccpav_buf_head + len > av->dccpav_vec_len) { - const u32 tailsize = (av->dccpav_vec_len - av->dccpav_buf_head); + if ((int)av->dccpav_buf_head + len > av->dccpav_vec_len) { + const u32 tailsize = av->dccpav_vec_len - av->dccpav_buf_head; memcpy(to, from, tailsize); to += tailsize; @@ -93,8 +93,14 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb) struct dccp_ackvec *dccp_ackvec_alloc(const unsigned int len, const gfp_t priority) { - struct dccp_ackvec *av = kmalloc(sizeof(*av) + len, priority); + struct dccp_ackvec *av; + BUG_ON(len == 0); + + if (len > DCCP_MAX_ACKVEC_LEN) + return NULL; + + av = kmalloc(sizeof(*av) + len, priority); if (av != NULL) { av->dccpav_buf_len = len; av->dccpav_buf_head = @@ -117,13 +123,13 @@ void dccp_ackvec_free(struct dccp_ackvec *av) } static inline u8 dccp_ackvec_state(const struct dccp_ackvec *av, - const unsigned int index) + const u8 index) { return av->dccpav_buf[index] & DCCP_ACKVEC_STATE_MASK; } static inline u8 dccp_ackvec_len(const struct dccp_ackvec *av, - const unsigned int index) + const u8 index) { return av->dccpav_buf[index] & DCCP_ACKVEC_LEN_MASK; } @@ -135,7 +141,7 @@ static inline u8 dccp_ackvec_len(const struct dccp_ackvec *av, */ static inline int dccp_ackvec_set_buf_head_state(struct dccp_ackvec *av, const unsigned int packets, - const unsigned char state) + const unsigned char state) { unsigned int gap; signed long new_head; @@ -223,7 +229,7 @@ int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, * could reduce the complexity of this scan.) */ u64 delta = dccp_delta_seqno(ackno, av->dccpav_buf_ackno); - unsigned int index = av->dccpav_buf_head; + u8 index = av->dccpav_buf_head; while (1) { const u8 len = dccp_ackvec_len(av, index); @@ -301,9 +307,10 @@ static void dccp_ackvec_throw_away_ack_record(struct dccp_ackvec *av) * draft-ietf-dccp-spec-11.txt Appendix A. -acme */ #if 0 - av->dccpav_buf_tail = av->dccpav_ack_ptr + 1; - if (av->dccpav_buf_tail >= av->dccpav_vec_len) - av->dccpav_buf_tail -= av->dccpav_vec_len; + u32 new_buf_tail = av->dccpav_ack_ptr + 1; + if (new_buf_tail >= av->dccpav_vec_len) + new_buf_tail -= av->dccpav_vec_len; + av->dccpav_buf_tail = new_buf_tail; #endif av->dccpav_vec_len -= av->dccpav_sent_len; } diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h index d0fd6c6..f7dfb5f 100644 --- a/net/dccp/ackvec.h +++ b/net/dccp/ackvec.h @@ -54,16 +54,16 @@ * @dccpav_buf - circular buffer of acknowledgeable packets */ struct dccp_ackvec { - unsigned int dccpav_buf_head; - unsigned int dccpav_buf_tail; u64 dccpav_buf_ackno; u64 dccpav_ack_seqno; u64 dccpav_ack_ackno; - unsigned int dccpav_ack_ptr; - unsigned int dccpav_sent_len; - unsigned int dccpav_vec_len; - unsigned int dccpav_buf_len; struct timeval dccpav_time; + u8 dccpav_buf_head; + u8 dccpav_buf_tail; + u8 dccpav_ack_ptr; + u8 dccpav_sent_len; + u8 dccpav_vec_len; + u8 dccpav_buf_len; u8 dccpav_buf_nonce; u8 dccpav_ack_nonce; u8 dccpav_buf[0]; -- cgit v1.1 From 80e40daa4797a156781d1594642b654eb1c461df Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 4 Jan 2006 01:58:06 -0200 Subject: [TCP]: syn_flood_warning is only needed if CONFIG_SYN_COOKIES is selected CC net/ipv4/tcp_ipv4.o /pub/scm/linux/kernel/git/acme/net-2.6/net/ipv4/tcp_ipv4.c:665: warning: 'syn_flood_warning' defined but not used Signed-off-by: Arnaldo Carvalho de Melo --- net/ipv4/tcp_ipv4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 5c70493..e9f83e5 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -661,6 +661,7 @@ static void tcp_v4_reqsk_destructor(struct request_sock *req) kfree(inet_rsk(req)->opt); } +#ifdef CONFIG_SYN_COOKIES static void syn_flood_warning(struct sk_buff *skb) { static unsigned long warntime; @@ -672,6 +673,7 @@ static void syn_flood_warning(struct sk_buff *skb) ntohs(skb->h.th->dest)); } } +#endif /* * Save and compile IPv4 options into the request_sock if needed. -- cgit v1.1 From f190055ff5c08a877d3e1ac2e0300fd92c264b06 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Wed, 4 Jan 2006 02:02:20 -0200 Subject: [IPVS]: Add missing include CC [M] net/ipv4/ipvs/ip_vs_conn.o /pub/scm/linux/kernel/git/acme/net-2.6/net/ipv4/ipvs/ip_vs_conn.c: In function 'ip_vs_conn_new': /pub/scm/linux/kernel/git/acme/net-2.6/net/ipv4/ipvs/ip_vs_conn.c:606: warning: implicit declaration of function 'net_ratelimit' /pub/scm/linux/kernel/git/acme/net-2.6/net/ipv4/ipvs/ip_vs_conn.c: In function 'ip_vs_random_dropentry': /pub/scm/linux/kernel/git/acme/net-2.6/net/ipv4/ipvs/ip_vs_conn.c:810: warning: implicit declaration of function 'net_random' Signed-off-by: Arnaldo Carvalho de Melo --- net/ipv4/ipvs/ip_vs_conn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c index ed5bd56..81d90354 100644 --- a/net/ipv4/ipvs/ip_vs_conn.c +++ b/net/ipv4/ipvs/ip_vs_conn.c @@ -25,6 +25,7 @@ */ #include +#include #include #include #include -- cgit v1.1 From 7790db18be736c87b0cdfa8da8aca11627fc5e54 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 4 Jan 2006 10:13:22 +0100 Subject: [ALSA] version 1.0.11rc2 --- include/sound/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sound/version.h b/include/sound/version.h index d1bd3b7..919da0d 100644 --- a/include/sound/version.h +++ b/include/sound/version.h @@ -1,3 +1,3 @@ /* include/version.h. Generated by configure. */ -#define CONFIG_SND_VERSION "1.0.10rc3" -#define CONFIG_SND_DATE " (Mon Nov 07 13:30:21 2005 UTC)" +#define CONFIG_SND_VERSION "1.0.11rc2" +#define CONFIG_SND_DATE " (Wed Jan 04 08:57:20 2006 UTC)" -- cgit v1.1 From 2ad5dd8dc31137a050f205525a5cd1a4be76c3f1 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 3 Jan 2006 14:27:21 +0100 Subject: [ALSA] dummy driver - added CA0106 emulation defines Modules: Generic drivers Signed-off-by: Jaroslav Kysela --- sound/drivers/dummy.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c index 96d2070..14e1a67 100644 --- a/sound/drivers/dummy.c +++ b/sound/drivers/dummy.c @@ -92,11 +92,27 @@ static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime) #define USE_RATE_MAX 48000 #endif +#if 0 /* CA0106 */ +#define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE +#define USE_CHANNELS_MIN 2 +#define USE_CHANNELS_MAX 2 +#define USE_RATE (SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000) +#define USE_RATE_MIN 48000 +#define USE_RATE_MAX 192000 +#define MAX_BUFFER_SIZE ((65536-64)*8) +#define MAX_PERIOD_SIZE (65536-64) +#define USE_PERIODS_MIN 2 +#define USE_PERIODS_MAX 8 +#endif + /* defaults */ #ifndef MAX_BUFFER_SIZE #define MAX_BUFFER_SIZE (64*1024) #endif +#ifndef MAX_PERIOD_SIZE +#define MAX_PERIOD_SIZE MAX_BUFFER_SIZE +#endif #ifndef USE_FORMATS #define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE) #endif @@ -287,7 +303,7 @@ static struct snd_pcm_hardware snd_card_dummy_capture = .channels_max = USE_CHANNELS_MAX, .buffer_bytes_max = MAX_BUFFER_SIZE, .period_bytes_min = 64, - .period_bytes_max = MAX_BUFFER_SIZE, + .period_bytes_max = MAX_PERIOD_SIZE, .periods_min = USE_PERIODS_MIN, .periods_max = USE_PERIODS_MAX, .fifo_size = 0, -- cgit v1.1 From 3e23c658833f135508127c955d40d7c9387f71dd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 3 Jan 2006 19:54:44 +0100 Subject: [ALSA] Revert the nested-device patch Modules: ALSA Core Revert the nested-device patch to keep the compatibility with the current HAL configuration. Signed-off-by: Takashi Iwai --- include/sound/core.h | 1 - sound/core/device.c | 2 +- sound/core/sound.c | 11 ++--------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index dbe7a2c..90ac613 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -134,7 +134,6 @@ struct snd_card { wait_queue_head_t shutdown_sleep; struct work_struct free_workq; /* for free in workqueue */ struct device *dev; - struct class_device *parent_device; #ifdef CONFIG_PM unsigned int power_state; /* power state */ diff --git a/sound/core/device.c b/sound/core/device.c index 478264c..b1cf6ec 100644 --- a/sound/core/device.c +++ b/sound/core/device.c @@ -193,7 +193,7 @@ int snd_device_register_all(struct snd_card *card) int err; snd_assert(card != NULL, return -ENXIO); - list_for_each_prev(list, &card->devices) { + list_for_each(list, &card->devices) { dev = snd_device(list); if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { if ((err = dev->ops->dev_register(dev)) < 0) diff --git a/sound/core/sound.c b/sound/core/sound.c index 2f6108d..a8eda02 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -245,7 +245,6 @@ int snd_register_device(int type, struct snd_card *card, int dev, int minor; struct snd_minor *preg; struct device *device = NULL; - struct class_device *class_device = NULL; snd_assert(name, return -EINVAL); preg = kmalloc(sizeof(struct snd_minor) + strlen(name) + 1, GFP_KERNEL); @@ -273,15 +272,9 @@ int snd_register_device(int type, struct snd_card *card, int dev, snd_minors[minor] = preg; if (type != SNDRV_DEVICE_TYPE_CONTROL || preg->card >= cards_limit) devfs_mk_cdev(MKDEV(major, minor), S_IFCHR | device_mode, "snd/%s", name); - if (card) { + if (card) device = card->dev; - class_device = card->parent_device; - } - class_device = class_device_create(sound_class, class_device, - MKDEV(major, minor), device, - "%s", name); - if (type == SNDRV_DEVICE_TYPE_CONTROL) - card->parent_device = class_device; + class_device_create(sound_class, NULL, MKDEV(major, minor), device, "%s", name); up(&sound_mutex); return 0; -- cgit v1.1 From 676338a1623ee9b60a6efb19ef8f743ab3b2eecb Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Tue, 3 Jan 2006 19:56:55 +0100 Subject: [ALSA] opl3 - Fix the unreleased resources Modules: OPL3 Fix the unreleased resources in the error path of snd_opl3_create(). Signed-off-by: Takashi Iwai --- sound/drivers/opl3/opl3_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index 650f3b8..1e0c76b 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -409,13 +409,13 @@ int snd_opl3_create(struct snd_card *card, if (! integrated) { if ((opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)")) == NULL) { snd_printk(KERN_ERR "opl3: can't grab left port 0x%lx\n", l_port); - snd_opl3_free(opl3); + snd_device_free(card, opl3); return -EBUSY; } if (r_port != 0 && (opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)")) == NULL) { snd_printk(KERN_ERR "opl3: can't grab right port 0x%lx\n", r_port); - snd_opl3_free(opl3); + snd_device_free(card, opl3); return -EBUSY; } } @@ -434,7 +434,7 @@ int snd_opl3_create(struct snd_card *card, if ((err = snd_opl3_detect(opl3)) < 0) { snd_printd("OPL2/3 chip not detected at 0x%lx/0x%lx\n", opl3->l_port, opl3->r_port); - snd_opl3_free(opl3); + snd_device_free(card, opl3); return err; } /* detect routine returns correct hardware type */ -- cgit v1.1 From c6f43290ae687c11cdcd150d8bfeb57ec29cfa5b Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 4 Jan 2006 10:26:16 +0100 Subject: [ALSA] ad1889 - remove CVS ID from the driver identification Signed-off-by: Jaroslav Kysela --- sound/pci/ad1889.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 61d6d52..a208075 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c @@ -50,7 +50,7 @@ #include "ad1889.h" #include "ac97/ac97_id.h" -#define AD1889_DRVVER "$Revision: 1.4 $" +#define AD1889_DRVVER "Version: 1.7" MODULE_AUTHOR("Kyle McMartin , Thibaut Varene "); MODULE_DESCRIPTION("Analog Devices AD1889 ALSA sound driver"); -- cgit v1.1 From 81f280e22f14d6d976620acaa1b346a90f4e1adc Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 12 Nov 2005 14:22:11 +0000 Subject: [PATCH] USB: pxa27x OHCI - Separate platform code from main driver To allow multiple platforms to use the PXA27x OHCI driver, the platform code needs to be moved into the board specific files in arch/arm/mach-pxa. This patch does this for mainstone and adds preliminary hooks to allow other boards to use the driver. This has been compile tested for mainstone and successfully run on Spitz (Sharp Zaurus SL-C3000) with the addition of an appropriate board support file. Signed-off-by: Richard Purdie Signed-off-by: Nicolas Pitre Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-pxa/mainstone.c | 21 ++++++++++ arch/arm/mach-pxa/pxa27x.c | 6 +++ drivers/usb/host/ohci-pxa27x.c | 85 +++++++++++++++++++++-------------------- include/asm-arm/arch-pxa/ohci.h | 18 +++++++++ 4 files changed, 88 insertions(+), 42 deletions(-) create mode 100644 include/asm-arm/arch-pxa/ohci.h diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c index 07892f4..277498a 100644 --- a/arch/arm/mach-pxa/mainstone.c +++ b/arch/arm/mach-pxa/mainstone.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "generic.h" @@ -393,6 +394,25 @@ static struct platform_device *platform_devices[] __initdata = { &mst_flash_device[1], }; +static int mainstone_ohci_init(struct device *dev) +{ + /* setup Port1 GPIO pin. */ + pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN); /* USBHPWR1 */ + pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */ + + /* Set the Power Control Polarity Low and Power Sense + Polarity Low to active low. */ + UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) & + ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); + + return 0; +} + +static struct pxaohci_platform_data mainstone_ohci_platform_data = { + .port_mode = PMM_PERPORT_MODE, + .init = mainstone_ohci_init, +}; + static void __init mainstone_init(void) { int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */ @@ -424,6 +444,7 @@ static void __init mainstone_init(void) pxa_set_mci_info(&mainstone_mci_platform_data); pxa_set_ficp_info(&mainstone_ficp_platform_data); + pxa_set_ohci_info(&mainstone_ohci_platform_data); } diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c index c722a9a..b41b1ef 100644 --- a/arch/arm/mach-pxa/pxa27x.c +++ b/arch/arm/mach-pxa/pxa27x.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "generic.h" @@ -194,6 +195,11 @@ static struct platform_device ohci_device = { .resource = pxa27x_ohci_resources, }; +void __init pxa_set_ohci_info(struct pxaohci_platform_data *info) +{ + ohci_device.dev.platform_data = info; +} + static struct platform_device *devices[] __initdata = { &ohci_device, }; diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 9d65ec3..c165d1e 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c @@ -26,18 +26,12 @@ #include #include #include - - -#define PMM_NPS_MODE 1 -#define PMM_GLOBAL_MODE 2 -#define PMM_PERPORT_MODE 3 +#include #define PXA_UHC_MAX_PORTNUM 3 #define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 ) -static int pxa27x_ohci_pmm_state; - /* PMM_NPS_MODE -- PMM Non-power switching mode Ports are powered continuously. @@ -50,8 +44,6 @@ static int pxa27x_ohci_pmm_state; */ static int pxa27x_ohci_select_pmm( int mode ) { - pxa27x_ohci_pmm_state = mode; - switch ( mode ) { case PMM_NPS_MODE: UHCRHDA |= RH_A_NPS; @@ -71,7 +63,6 @@ static int pxa27x_ohci_select_pmm( int mode ) "Invalid mode %d, set to non-power switch mode.\n", mode ); - pxa27x_ohci_pmm_state = PMM_NPS_MODE; UHCRHDA |= RH_A_NPS; } @@ -82,8 +73,13 @@ extern int usb_disabled(void); /*-------------------------------------------------------------------------*/ -static void pxa27x_start_hc(struct platform_device *dev) +static int pxa27x_start_hc(struct device *dev) { + int retval = 0; + struct pxaohci_platform_data *inf; + + inf = dev->platform_data; + pxa_set_cken(CKEN10_USBHOST, 1); UHCHR |= UHCHR_FHR; @@ -94,21 +90,11 @@ static void pxa27x_start_hc(struct platform_device *dev) while (UHCHR & UHCHR_FSBIR) cpu_relax(); - /* This could be properly abstracted away through the - device data the day more machines are supported and - their differences can be figured out correctly. */ - if (machine_is_mainstone()) { - /* setup Port1 GPIO pin. */ - pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN); /* USBHPWR1 */ - pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */ - - /* Set the Power Control Polarity Low and Power Sense - Polarity Low to active low. Supply power to USB ports. */ - UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) & - ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); + if (inf->init) + retval = inf->init(dev); - pxa27x_ohci_pmm_state = PMM_PERPORT_MODE; - } + if (retval < 0) + return retval; UHCHR &= ~UHCHR_SSE; @@ -117,10 +103,19 @@ static void pxa27x_start_hc(struct platform_device *dev) /* Clear any OTG Pin Hold */ if (PSSR & PSSR_OTGPH) PSSR |= PSSR_OTGPH; + + return 0; } -static void pxa27x_stop_hc(struct platform_device *dev) +static void pxa27x_stop_hc(struct device *dev) { + struct pxaohci_platform_data *inf; + + inf = dev->platform_data; + + if (inf->exit) + inf->exit(dev); + UHCHR |= UHCHR_FHR; udelay(11); UHCHR &= ~UHCHR_FHR; @@ -147,22 +142,27 @@ static void pxa27x_stop_hc(struct platform_device *dev) * through the hotplug entry's driver_data. * */ -int usb_hcd_pxa27x_probe (const struct hc_driver *driver, - struct platform_device *dev) +int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev) { int retval; struct usb_hcd *hcd; + struct pxaohci_platform_data *inf; + + inf = pdev->dev.platform_data; - if (dev->resource[1].flags != IORESOURCE_IRQ) { + if (!inf) + return -ENODEV; + + if (pdev->resource[1].flags != IORESOURCE_IRQ) { pr_debug ("resource[1] is not IORESOURCE_IRQ"); return -ENOMEM; } - hcd = usb_create_hcd (driver, &dev->dev, "pxa27x"); + hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); if (!hcd) return -ENOMEM; - hcd->rsrc_start = dev->resource[0].start; - hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; + hcd->rsrc_start = pdev->resource[0].start; + hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { pr_debug("request_mem_region failed"); @@ -177,18 +177,22 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, goto err2; } - pxa27x_start_hc(dev); + if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) { + pr_debug("pxa27x_start_hc failed"); + goto err3; + } /* Select Power Management Mode */ - pxa27x_ohci_select_pmm(pxa27x_ohci_pmm_state); + pxa27x_ohci_select_pmm(inf->port_mode); ohci_hcd_init(hcd_to_ohci(hcd)); - retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT); + retval = usb_add_hcd(hcd, pdev->resource[1].start, SA_INTERRUPT); if (retval == 0) return retval; - pxa27x_stop_hc(dev); + pxa27x_stop_hc(&pdev->dev); + err3: iounmap(hcd->regs); err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); @@ -211,10 +215,10 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, * context, normally "rmmod", "apmd", or something similar. * */ -void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *dev) +void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev) { usb_remove_hcd(hcd); - pxa27x_stop_hc(dev); + pxa27x_stop_hc(&pdev->dev); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); usb_put_hcd(hcd); @@ -292,15 +296,12 @@ static const struct hc_driver ohci_pxa27x_hc_driver = { static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev) { - int ret; - pr_debug ("In ohci_hcd_pxa27x_drv_probe"); if (usb_disabled()) return -ENODEV; - ret = usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev); - return ret; + return usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev); } static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) diff --git a/include/asm-arm/arch-pxa/ohci.h b/include/asm-arm/arch-pxa/ohci.h new file mode 100644 index 0000000..7da8956 --- /dev/null +++ b/include/asm-arm/arch-pxa/ohci.h @@ -0,0 +1,18 @@ +#ifndef ASMARM_ARCH_OHCI_H +#define ASMARM_ARCH_OHCI_H + +struct device; + +struct pxaohci_platform_data { + int (*init)(struct device *); + void (*exit)(struct device *); + + int port_mode; +#define PMM_NPS_MODE 1 +#define PMM_GLOBAL_MODE 2 +#define PMM_PERPORT_MODE 3 +}; + +extern void pxa_set_ohci_info(struct pxaohci_platform_data *info); + +#endif -- cgit v1.1 From 2e1dcc1600c1d83b26479edd076866595bbd3523 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 12 Nov 2005 14:22:14 +0000 Subject: [PATCH] USB: Add pxa27x OHCI PM functions Add power management functions for the pxa27x USB OHCI host controller. This is a totally rewritten version of the patch by Nicolas Pitre and Todd Poynor which accounts for recent USB changes. Signed-off-by: Richard Purdie Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-pxa27x.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index c165d1e..3b1cfe9 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c @@ -312,28 +312,49 @@ static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) return 0; } -static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *dev, pm_message_t state) +#ifdef CONFIG_PM +static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state) { -// struct usb_hcd *hcd = platform_get_drvdata(dev); - printk("%s: not implemented yet\n", __FUNCTION__); + struct ohci_hcd *ohci = platform_get_drvdata(pdev); + + if (time_before(jiffies, ohci->next_statechange)) + msleep(5); + ohci->next_statechange = jiffies; + + pxa27x_stop_hc(&pdev->dev); + ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; + pdev->dev.power.power_state = PMSG_SUSPEND; return 0; } -static int ohci_hcd_pxa27x_drv_resume(struct platform_device *dev) +static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) { -// struct usb_hcd *hcd = platform_get_drvdata(dev); - printk("%s: not implemented yet\n", __FUNCTION__); + struct ohci_hcd *ohci = platform_get_drvdata(pdev); + int status; + + if (time_before(jiffies, ohci->next_statechange)) + msleep(5); + ohci->next_statechange = jiffies; + + if ((status = pxa27x_start_hc(&pdev->dev)) < 0) + return status; + + pdev->dev.power.power_state = PMSG_ON; + usb_hcd_resume_root_hub(platform_get_drvdata(pdev)); return 0; } +#endif static struct platform_driver ohci_hcd_pxa27x_driver = { .probe = ohci_hcd_pxa27x_drv_probe, .remove = ohci_hcd_pxa27x_drv_remove, +#ifdef CONFIG_PM .suspend = ohci_hcd_pxa27x_drv_suspend, .resume = ohci_hcd_pxa27x_drv_resume, +#endif .driver = { .name = "pxa27x-ohci", }, -- cgit v1.1 From 61a87adf2e7b410da8e41799c61c21a7b8c8b001 Mon Sep 17 00:00:00 2001 From: David Kubicek Date: Tue, 1 Nov 2005 18:51:34 +0100 Subject: [PATCH] USB: Converting cdc acm to a ring queue this patch by David converts the sending queue of the CDC ACM driver to a queue of URBs. This is needed for quicker devices. Please apply. Signed-Off-By: Oliver Neukum Signed-off-by: Greg Kroah-Hartman drivers/usb/class/cdc-acm.c | 229 ++++++++++++++++++++++++++++++-------------- drivers/usb/class/cdc-acm.h | 33 +++++- 2 files changed, 185 insertions(+), 77 deletions(-) --- drivers/usb/class/cdc-acm.c | 227 ++++++++++++++++++++++++++++++-------------- drivers/usb/class/cdc-acm.h | 33 ++++++- 2 files changed, 184 insertions(+), 76 deletions(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 1b47514..72936dc 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -6,6 +6,7 @@ * Copyright (c) 1999 Johannes Erdfelt * Copyright (c) 2000 Vojtech Pavlik * Copyright (c) 2004 Oliver Neukum + * Copyright (c) 2005 David Kubicek * * USB Abstract Control Model driver for USB modems and ISDN adapters * @@ -29,6 +30,7 @@ * config we want, sysadmin changes bConfigurationValue in sysfs. * v0.23 - use softirq for rx processing, as needed by tty layer * v0.24 - change probe method to evaluate CDC union descriptor + * v0.25 - downstream tasks paralelized to maximize throughput */ /* @@ -63,14 +65,15 @@ #include #include #include +#include #include "cdc-acm.h" /* * Version Information */ -#define DRIVER_VERSION "v0.23" -#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik" +#define DRIVER_VERSION "v0.25" +#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek" #define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters" static struct usb_driver acm_driver; @@ -284,7 +287,9 @@ exit: /* data interface returns incoming bytes, or we got unthrottled */ static void acm_read_bulk(struct urb *urb, struct pt_regs *regs) { - struct acm *acm = urb->context; + struct acm_rb *buf; + struct acm_ru *rcv = urb->context; + struct acm *acm = rcv->instance; dbg("Entering acm_read_bulk with status %d\n", urb->status); if (!ACM_READY(acm)) @@ -293,49 +298,109 @@ static void acm_read_bulk(struct urb *urb, struct pt_regs *regs) if (urb->status) dev_dbg(&acm->data->dev, "bulk rx status %d\n", urb->status); - /* calling tty_flip_buffer_push() in_irq() isn't allowed */ - tasklet_schedule(&acm->bh); + buf = rcv->buffer; + buf->size = urb->actual_length; + + spin_lock(&acm->read_lock); + list_add_tail(&rcv->list, &acm->spare_read_urbs); + list_add_tail(&buf->list, &acm->filled_read_bufs); + spin_unlock(&acm->read_lock); + + tasklet_schedule(&acm->urb_task); } static void acm_rx_tasklet(unsigned long _acm) { struct acm *acm = (void *)_acm; - struct urb *urb = acm->readurb; + struct acm_rb *buf; struct tty_struct *tty = acm->tty; - unsigned char *data = urb->transfer_buffer; + struct acm_ru *rcv; + //unsigned long flags; int i = 0; dbg("Entering acm_rx_tasklet"); - if (urb->actual_length > 0 && !acm->throttle) { - for (i = 0; i < urb->actual_length && !acm->throttle; i++) { - /* if we insert more than TTY_FLIPBUF_SIZE characters, - * we drop them. */ - if (tty->flip.count >= TTY_FLIPBUF_SIZE) { - tty_flip_buffer_push(tty); - } - tty_insert_flip_char(tty, data[i], 0); - } - dbg("Handed %d bytes to tty layer", i+1); - tty_flip_buffer_push(tty); + if (!ACM_READY(acm) || acm->throttle) + return; + +next_buffer: + spin_lock(&acm->read_lock); + if (list_empty(&acm->filled_read_bufs)) { + spin_unlock(&acm->read_lock); + goto urbs; } + buf = list_entry(acm->filled_read_bufs.next, + struct acm_rb, list); + list_del(&buf->list); + spin_unlock(&acm->read_lock); + + dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d\n", buf, buf->size); + + for (i = 0; i < buf->size && !acm->throttle; i++) { + /* if we insert more than TTY_FLIPBUF_SIZE characters, + we drop them. */ + if (tty->flip.count >= TTY_FLIPBUF_SIZE) { + tty_flip_buffer_push(tty); + } + tty_insert_flip_char(tty, buf->base[i], 0); + } + tty_flip_buffer_push(tty); spin_lock(&acm->throttle_lock); if (acm->throttle) { dbg("Throtteling noticed"); - memmove(data, data + i, urb->actual_length - i); - urb->actual_length -= i; - acm->resubmit_to_unthrottle = 1; + memmove(buf->base, buf->base + i, buf->size - i); + buf->size -= i; spin_unlock(&acm->throttle_lock); + spin_lock(&acm->read_lock); + list_add(&buf->list, &acm->filled_read_bufs); + spin_unlock(&acm->read_lock); return; } spin_unlock(&acm->throttle_lock); - urb->actual_length = 0; - urb->dev = acm->dev; - - i = usb_submit_urb(urb, GFP_ATOMIC); - if (i) - dev_dbg(&acm->data->dev, "bulk rx resubmit %d\n", i); + spin_lock(&acm->read_lock); + list_add(&buf->list, &acm->spare_read_bufs); + spin_unlock(&acm->read_lock); + goto next_buffer; + +urbs: + while (!list_empty(&acm->spare_read_bufs)) { + spin_lock(&acm->read_lock); + if (list_empty(&acm->spare_read_urbs)) { + spin_unlock(&acm->read_lock); + return; + } + rcv = list_entry(acm->spare_read_urbs.next, + struct acm_ru, list); + list_del(&rcv->list); + spin_unlock(&acm->read_lock); + + buf = list_entry(acm->spare_read_bufs.next, + struct acm_rb, list); + list_del(&buf->list); + + rcv->buffer = buf; + + usb_fill_bulk_urb(rcv->urb, acm->dev, + acm->rx_endpoint, + buf->base, + acm->readsize, + acm_read_bulk, rcv); + rcv->urb->transfer_dma = buf->dma; + rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + + dbg("acm_rx_tasklet: sending urb 0x%p, rcv 0x%p, buf 0x%p\n", rcv->urb, rcv, buf); + + /* This shouldn't kill the driver as unsuccessful URBs are returned to the + free-urbs-pool and resubmited ASAP */ + if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) { + list_add(&buf->list, &acm->spare_read_bufs); + spin_lock(&acm->read_lock); + list_add(&rcv->list, &acm->spare_read_urbs); + spin_unlock(&acm->read_lock); + return; + } + } } /* data interface wrote those outgoing bytes */ @@ -369,6 +434,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) { struct acm *acm; int rv = -EINVAL; + int i; dbg("Entering acm_tty_open.\n"); down(&open_sem); @@ -382,7 +448,9 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) tty->driver_data = acm; acm->tty = tty; - + /* force low_latency on so that our tty_push actually forces the data through, + otherwise it is scheduled, and with high data rates data can get lost. */ + tty->low_latency = 1; if (acm->used++) { goto done; @@ -394,18 +462,20 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) goto bail_out; } - acm->readurb->dev = acm->dev; - if (usb_submit_urb(acm->readurb, GFP_KERNEL)) { - dbg("usb_submit_urb(read bulk) failed"); - goto bail_out_and_unlink; - } - if (0 > acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS)) goto full_bailout; - /* force low_latency on so that our tty_push actually forces the data through, - otherwise it is scheduled, and with high data rates data can get lost. */ - tty->low_latency = 1; + INIT_LIST_HEAD(&acm->spare_read_urbs); + INIT_LIST_HEAD(&acm->spare_read_bufs); + INIT_LIST_HEAD(&acm->filled_read_bufs); + for (i = 0; i < ACM_NRU; i++) { + list_add(&(acm->ru[i].list), &acm->spare_read_urbs); + } + for (i = 0; i < ACM_NRB; i++) { + list_add(&(acm->rb[i].list), &acm->spare_read_bufs); + } + + tasklet_schedule(&acm->urb_task); done: err_out: @@ -413,8 +483,6 @@ err_out: return rv; full_bailout: - usb_kill_urb(acm->readurb); -bail_out_and_unlink: usb_kill_urb(acm->ctrlurb); bail_out: acm->used--; @@ -424,18 +492,22 @@ bail_out: static void acm_tty_unregister(struct acm *acm) { + int i; + tty_unregister_device(acm_tty_driver, acm->minor); usb_put_intf(acm->control); acm_table[acm->minor] = NULL; usb_free_urb(acm->ctrlurb); - usb_free_urb(acm->readurb); usb_free_urb(acm->writeurb); + for (i = 0; i < ACM_NRU; i++) + usb_free_urb(acm->ru[i].urb); kfree(acm); } static void acm_tty_close(struct tty_struct *tty, struct file *filp) { struct acm *acm = tty->driver_data; + int i; if (!acm || !acm->used) return; @@ -446,7 +518,8 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) acm_set_control(acm, acm->ctrlout = 0); usb_kill_urb(acm->ctrlurb); usb_kill_urb(acm->writeurb); - usb_kill_urb(acm->readurb); + for (i = 0; i < ACM_NRU; i++) + usb_kill_urb(acm->ru[i].urb); } else acm_tty_unregister(acm); } @@ -528,10 +601,7 @@ static void acm_tty_unthrottle(struct tty_struct *tty) spin_lock_bh(&acm->throttle_lock); acm->throttle = 0; spin_unlock_bh(&acm->throttle_lock); - if (acm->resubmit_to_unthrottle) { - acm->resubmit_to_unthrottle = 0; - acm_read_bulk(acm->readurb, NULL); - } + tasklet_schedule(&acm->urb_task); } static void acm_tty_break_ctl(struct tty_struct *tty, int state) @@ -694,6 +764,7 @@ static int acm_probe (struct usb_interface *intf, int call_interface_num = -1; int data_interface_num; unsigned long quirks; + int i; /* handle quirks deadly to normal probing*/ quirks = (unsigned long)id->driver_info; @@ -833,7 +904,7 @@ skip_normal_probe: } ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); - readsize = le16_to_cpu(epread->wMaxPacketSize); + readsize = le16_to_cpu(epread->wMaxPacketSize)*2; acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize); acm->control = control_interface; acm->data = data_interface; @@ -842,12 +913,14 @@ skip_normal_probe: acm->ctrl_caps = ac_management_function; acm->ctrlsize = ctrlsize; acm->readsize = readsize; - acm->bh.func = acm_rx_tasklet; - acm->bh.data = (unsigned long) acm; + acm->urb_task.func = acm_rx_tasklet; + acm->urb_task.data = (unsigned long) acm; INIT_WORK(&acm->work, acm_softint, acm); spin_lock_init(&acm->throttle_lock); spin_lock_init(&acm->write_lock); + spin_lock_init(&acm->read_lock); acm->write_ready = 1; + acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress); buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma); if (!buf) { @@ -856,13 +929,6 @@ skip_normal_probe: } acm->ctrl_buffer = buf; - buf = usb_buffer_alloc(usb_dev, readsize, GFP_KERNEL, &acm->read_dma); - if (!buf) { - dev_dbg(&intf->dev, "out of memory (read buffer alloc)\n"); - goto alloc_fail3; - } - acm->read_buffer = buf; - if (acm_write_buffers_alloc(acm) < 0) { dev_dbg(&intf->dev, "out of memory (write buffer alloc)\n"); goto alloc_fail4; @@ -873,10 +939,25 @@ skip_normal_probe: dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n"); goto alloc_fail5; } - acm->readurb = usb_alloc_urb(0, GFP_KERNEL); - if (!acm->readurb) { - dev_dbg(&intf->dev, "out of memory (readurb kmalloc)\n"); - goto alloc_fail6; + for (i = 0; i < ACM_NRU; i++) { + struct acm_ru *rcv = &(acm->ru[i]); + + if (!(rcv->urb = usb_alloc_urb(0, GFP_KERNEL))) { + dev_dbg(&intf->dev, "out of memory (read urbs usb_alloc_urb)\n"); + goto alloc_fail7; + } + + rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + rcv->instance = acm; + } + for (i = 0; i < ACM_NRB; i++) { + struct acm_rb *buf = &(acm->rb[i]); + + // Using usb_buffer_alloc instead of kmalloc as Oliver suggested + if (!(buf->base = usb_buffer_alloc(acm->dev, readsize, GFP_KERNEL, &buf->dma))) { + dev_dbg(&intf->dev, "out of memory (read bufs usb_buffer_alloc)\n"); + goto alloc_fail7; + } } acm->writeurb = usb_alloc_urb(0, GFP_KERNEL); if (!acm->writeurb) { @@ -889,15 +970,9 @@ skip_normal_probe: acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; acm->ctrlurb->transfer_dma = acm->ctrl_dma; - usb_fill_bulk_urb(acm->readurb, usb_dev, usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress), - acm->read_buffer, readsize, acm_read_bulk, acm); - acm->readurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP; - acm->readurb->transfer_dma = acm->read_dma; - usb_fill_bulk_urb(acm->writeurb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), NULL, acm->writesize, acm_write_bulk, acm); acm->writeurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP; - /* acm->writeurb->transfer_dma = 0; */ dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor); @@ -917,14 +992,14 @@ skip_normal_probe: return 0; alloc_fail7: - usb_free_urb(acm->readurb); -alloc_fail6: + for (i = 0; i < ACM_NRB; i++) + usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma); + for (i = 0; i < ACM_NRU; i++) + usb_free_urb(acm->ru[i].urb); usb_free_urb(acm->ctrlurb); alloc_fail5: acm_write_buffers_free(acm); alloc_fail4: - usb_buffer_free(usb_dev, readsize, acm->read_buffer, acm->read_dma); -alloc_fail3: usb_buffer_free(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); alloc_fail2: kfree(acm); @@ -936,6 +1011,7 @@ static void acm_disconnect(struct usb_interface *intf) { struct acm *acm = usb_get_intfdata (intf); struct usb_device *usb_dev = interface_to_usbdev(intf); + int i; if (!acm || !acm->dev) { dbg("disconnect on nonexisting interface"); @@ -946,15 +1022,24 @@ static void acm_disconnect(struct usb_interface *intf) acm->dev = NULL; usb_set_intfdata (intf, NULL); + tasklet_disable(&acm->urb_task); + usb_kill_urb(acm->ctrlurb); - usb_kill_urb(acm->readurb); usb_kill_urb(acm->writeurb); + for (i = 0; i < ACM_NRU; i++) + usb_kill_urb(acm->ru[i].urb); + + INIT_LIST_HEAD(&acm->filled_read_bufs); + INIT_LIST_HEAD(&acm->spare_read_bufs); + + tasklet_enable(&acm->urb_task); flush_scheduled_work(); /* wait for acm_softint */ acm_write_buffers_free(acm); - usb_buffer_free(usb_dev, acm->readsize, acm->read_buffer, acm->read_dma); usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); + for (i = 0; i < ACM_NRB; i++) + usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma); usb_driver_release_interface(&acm_driver, acm->data); diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h index 963a5df..fd2aaccd 100644 --- a/drivers/usb/class/cdc-acm.h +++ b/drivers/usb/class/cdc-acm.h @@ -59,6 +59,9 @@ * when processing onlcr, so we only need 2 buffers. */ #define ACM_NWB 2 +#define ACM_NRU 16 +#define ACM_NRB 16 + struct acm_wb { unsigned char *buf; dma_addr_t dmah; @@ -66,22 +69,43 @@ struct acm_wb { int use; }; +struct acm_rb { + struct list_head list; + int size; + unsigned char *base; + dma_addr_t dma; +}; + +struct acm_ru { + struct list_head list; + struct acm_rb *buffer; + struct urb *urb; + struct acm *instance; +}; + struct acm { struct usb_device *dev; /* the corresponding usb device */ struct usb_interface *control; /* control interface */ struct usb_interface *data; /* data interface */ struct tty_struct *tty; /* the corresponding tty */ - struct urb *ctrlurb, *readurb, *writeurb; /* urbs */ - u8 *ctrl_buffer, *read_buffer; /* buffers of urbs */ - dma_addr_t ctrl_dma, read_dma; /* dma handles of buffers */ + struct urb *ctrlurb, *writeurb; /* urbs */ + u8 *ctrl_buffer; /* buffers of urbs */ + dma_addr_t ctrl_dma; /* dma handles of buffers */ struct acm_wb wb[ACM_NWB]; + struct acm_ru ru[ACM_NRU]; + struct acm_rb rb[ACM_NRB]; + int rx_endpoint; + spinlock_t read_lock; + struct list_head spare_read_urbs; + struct list_head spare_read_bufs; + struct list_head filled_read_bufs; int write_current; /* current write buffer */ int write_used; /* number of non-empty write buffers */ int write_ready; /* write urb is not running */ spinlock_t write_lock; struct usb_cdc_line_coding line; /* bits, stop, parity */ struct work_struct work; /* work queue entry for line discipline waking up */ - struct tasklet_struct bh; /* rx processing */ + struct tasklet_struct urb_task; /* rx processing */ spinlock_t throttle_lock; /* synchronize throtteling and read callback */ unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ unsigned int ctrlout; /* output control lines (DTR, RTS) */ @@ -91,7 +115,6 @@ struct acm { unsigned int minor; /* acm minor number */ unsigned char throttle; /* throttled by tty layer */ unsigned char clocal; /* termios CLOCAL */ - unsigned char resubmit_to_unthrottle; /* throtteling has disabled the read urb */ unsigned int ctrl_caps; /* control capabilities from the class specific header */ }; -- cgit v1.1 From 535488fcf1e4b2331e1c4a1eb67ca09468c13507 Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Fri, 28 Oct 2005 15:04:45 +0300 Subject: [PATCH] USB: isp116x-hcd: support reiniting HC on resume Until now the isp116x-hcd had no support to reinitialize the HC on resume, if the controller lost its state during suspend. This patch, generated against your Oct 26 git tree, adds that support. The patch is basically the same as the one tested by Ivan Kalatchev, who reported the problem, on 2.6.13. Please apply, Support reinitializing the isp116x host controller from scratch on resume, if the controller has lost its state. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/isp116x-hcd.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 82f6498..5f56c4a 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1201,11 +1201,14 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd) return ret; } +/* Get rid of these declarations later in cleanup */ +static int isp116x_reset(struct usb_hcd *hcd); +static int isp116x_start(struct usb_hcd *hcd); + static int isp116x_bus_resume(struct usb_hcd *hcd) { struct isp116x *isp116x = hcd_to_isp116x(hcd); u32 val; - int ret = -EINPROGRESS; msleep(5); spin_lock_irq(&isp116x->lock); @@ -1219,20 +1222,27 @@ static int isp116x_bus_resume(struct usb_hcd *hcd) case HCCONTROL_USB_RESUME: break; case HCCONTROL_USB_OPER: + spin_unlock_irq(&isp116x->lock); /* Without setting power_state here the SUSPENDED state won't be removed from sysfs/usbN/power.state as a response to remote wakeup. Maybe in the future. */ hcd->self.root_hub->dev.power.power_state = PMSG_ON; - ret = 0; - break; + return 0; default: - ret = -EBUSY; - } - - if (ret != -EINPROGRESS) { + /* HCCONTROL_USB_RESET: this may happen, when during + suspension the HC lost power. Reinitialize completely */ spin_unlock_irq(&isp116x->lock); - return ret; + DBG("Chip has been reset while suspended. Reinit from scratch.\n"); + isp116x_reset(hcd); + isp116x_start(hcd); + isp116x_hub_control(hcd, SetPortFeature, + USB_PORT_FEAT_POWER, 1, NULL, 0); + if ((isp116x->rhdesca & RH_A_NDP) == 2) + isp116x_hub_control(hcd, SetPortFeature, + USB_PORT_FEAT_POWER, 2, NULL, 0); + hcd->self.root_hub->dev.power.power_state = PMSG_ON; + return 0; } val = isp116x->rhdesca & RH_A_NDP; -- cgit v1.1 From 959eea2191e8d74b16ef019b0f4bf875c14f4547 Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Thu, 3 Nov 2005 17:38:14 +0200 Subject: [PATCH] USB: isp116x-hcd: cleanup The attached patch makes a cleanup of isp116x-hcd. Most of the volume of the patch comes from 2 sources: moving the code around to get rid of a few function prototypes and reworking register dumping functions/macros. Among other things, switched over from using procfs to debugfs. Cleanup. The following changes were made: - Rework register dumping code so it can be used for dumping to both syslog and debugfs. - Switch from procfs to debugfs.. - Die gracefully on Unrecoverable Error interrupt. - Fix memory leak in isp116x_urb_enqueue(), if HC happens to die in a narrow time window. - Fix a 'sparce' warning (unnecessary cast). - Report Devices Removable for root hub ports by default (was Devices Permanently Attached). - Move bus suspend/resume functions down in code to get rid of a few function prototypes. - A number of one-line cleanups. - Add an entry to MAINTAINERS. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman MAINTAINERS | 6 drivers/usb/host/isp116x-hcd.c | 429 ++++++++++++++++------------------------- drivers/usb/host/isp116x.h | 83 +++++-- 3 files changed, 230 insertions(+), 288 deletions(-) --- MAINTAINERS | 6 + drivers/usb/host/isp116x-hcd.c | 429 ++++++++++++++++------------------------- drivers/usb/host/isp116x.h | 83 +++++--- 3 files changed, 230 insertions(+), 288 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 6af6830..861d297 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2640,6 +2640,12 @@ L: linux-usb-users@lists.sourceforge.net L: linux-usb-devel@lists.sourceforge.net S: Maintained +USB ISP116X DRIVER +P: Olav Kongas +M: ok@artecdesign.ee +L: linux-usb-devel@lists.sourceforge.net +S: Maintained + USB KAWASAKI LSI DRIVER P: Oliver Neukum M: oliver@neukum.name diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 5f56c4a..342cfad 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -55,19 +55,13 @@ /* enqueuing/finishing log of urbs */ //#define URB_TRACE -#include #include -#include -#include #include -#include -#include -#include -#include +#include +#include #include #include #include -#include #include #include #include @@ -77,14 +71,10 @@ #include #include -#ifndef DEBUG -# define STUB_DEBUG_FILE -#endif - #include "../core/hcd.h" #include "isp116x.h" -#define DRIVER_VERSION "05 Aug 2005" +#define DRIVER_VERSION "03 Nov 2005" #define DRIVER_DESC "ISP116x USB Host Controller Driver" MODULE_DESCRIPTION(DRIVER_DESC); @@ -305,9 +295,8 @@ static void postproc_atl_queue(struct isp116x *isp116x) udev = urb->dev; ptd = &ep->ptd; cc = PTD_GET_CC(ptd); - - spin_lock(&urb->lock); short_not_ok = 1; + spin_lock(&urb->lock); /* Data underrun is special. For allowed underrun we clear the error and continue as normal. For @@ -420,7 +409,7 @@ static void postproc_atl_queue(struct isp116x *isp116x) ep->nextpid = 0; break; default: - BUG_ON(1); + BUG(); } spin_unlock(&urb->lock); } @@ -628,8 +617,12 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs) u32 intstat = isp116x_read_reg32(isp116x, HCINTSTAT); isp116x_write_reg32(isp116x, HCINTSTAT, intstat); if (intstat & HCINT_UE) { - ERR("Unrecoverable error\n"); - /* What should we do here? Reset? */ + ERR("Unrecoverable error, HC is dead!\n"); + /* IRQ's are off, we do no DMA, + perfectly ready to die ... */ + hcd->state = HC_STATE_HALT; + ret = IRQ_HANDLED; + goto done; } if (intstat & HCINT_RHSC) /* When root hub or any of its ports is going @@ -640,7 +633,6 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs) if (intstat & HCINT_RD) { DBG("---- remote wakeup\n"); usb_hcd_resume_root_hub(hcd); - ret = IRQ_HANDLED; } irqstat &= ~HCuPINT_OPR; ret = IRQ_HANDLED; @@ -651,6 +643,7 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs) } isp116x_write_reg16(isp116x, HCuPINTENB, isp116x->irqenb); + done: spin_unlock(&isp116x->lock); return ret; } @@ -724,6 +717,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd, spin_lock_irqsave(&isp116x->lock, flags); if (!HC_IS_RUNNING(hcd->state)) { + kfree(ep); ret = -ENODEV; goto fail; } @@ -888,7 +882,7 @@ static void isp116x_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep) { int i; - struct isp116x_ep *ep = hep->hcpriv;; + struct isp116x_ep *ep = hep->hcpriv; if (!ep) return; @@ -916,8 +910,6 @@ static int isp116x_get_frame(struct usb_hcd *hcd) return (int)fmnum; } -/*----------------------------------------------------------------*/ - /* Adapted from ohci-hub.c. Currently we don't support autosuspend. */ @@ -968,11 +960,10 @@ static void isp116x_hub_descriptor(struct isp116x *isp116x, desc->bHubContrCurrent = 0; desc->bNbrPorts = (u8) (reg & 0x3); /* Power switching, device type, overcurrent. */ - desc->wHubCharacteristics = - (__force __u16) cpu_to_le16((u16) ((reg >> 8) & 0x1f)); + desc->wHubCharacteristics = cpu_to_le16((u16) ((reg >> 8) & 0x1f)); desc->bPwrOn2PwrGood = (u8) ((reg >> 24) & 0xff); /* two bitmaps: ports removable, and legacy PortPwrCtrlMask */ - desc->bitmap[0] = desc->bNbrPorts == 1 ? 1 << 1 : 3 << 1; + desc->bitmap[0] = 0; desc->bitmap[1] = ~0; } @@ -1159,145 +1150,9 @@ static int isp116x_hub_control(struct usb_hcd *hcd, return ret; } -#ifdef CONFIG_PM - -static int isp116x_bus_suspend(struct usb_hcd *hcd) -{ - struct isp116x *isp116x = hcd_to_isp116x(hcd); - unsigned long flags; - u32 val; - int ret = 0; - - spin_lock_irqsave(&isp116x->lock, flags); - - val = isp116x_read_reg32(isp116x, HCCONTROL); - switch (val & HCCONTROL_HCFS) { - case HCCONTROL_USB_OPER: - hcd->state = HC_STATE_QUIESCING; - val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); - val |= HCCONTROL_USB_SUSPEND; - if (hcd->remote_wakeup) - val |= HCCONTROL_RWE; - /* Wait for usb transfers to finish */ - mdelay(2); - isp116x_write_reg32(isp116x, HCCONTROL, val); - hcd->state = HC_STATE_SUSPENDED; - /* Wait for devices to suspend */ - mdelay(5); - case HCCONTROL_USB_SUSPEND: - break; - case HCCONTROL_USB_RESUME: - isp116x_write_reg32(isp116x, HCCONTROL, - (val & ~HCCONTROL_HCFS) | - HCCONTROL_USB_RESET); - case HCCONTROL_USB_RESET: - ret = -EBUSY; - break; - default: - ret = -EINVAL; - } - - spin_unlock_irqrestore(&isp116x->lock, flags); - return ret; -} - -/* Get rid of these declarations later in cleanup */ -static int isp116x_reset(struct usb_hcd *hcd); -static int isp116x_start(struct usb_hcd *hcd); - -static int isp116x_bus_resume(struct usb_hcd *hcd) -{ - struct isp116x *isp116x = hcd_to_isp116x(hcd); - u32 val; - - msleep(5); - spin_lock_irq(&isp116x->lock); - - val = isp116x_read_reg32(isp116x, HCCONTROL); - switch (val & HCCONTROL_HCFS) { - case HCCONTROL_USB_SUSPEND: - val &= ~HCCONTROL_HCFS; - val |= HCCONTROL_USB_RESUME; - isp116x_write_reg32(isp116x, HCCONTROL, val); - case HCCONTROL_USB_RESUME: - break; - case HCCONTROL_USB_OPER: - spin_unlock_irq(&isp116x->lock); - /* Without setting power_state here the - SUSPENDED state won't be removed from - sysfs/usbN/power.state as a response to remote - wakeup. Maybe in the future. */ - hcd->self.root_hub->dev.power.power_state = PMSG_ON; - return 0; - default: - /* HCCONTROL_USB_RESET: this may happen, when during - suspension the HC lost power. Reinitialize completely */ - spin_unlock_irq(&isp116x->lock); - DBG("Chip has been reset while suspended. Reinit from scratch.\n"); - isp116x_reset(hcd); - isp116x_start(hcd); - isp116x_hub_control(hcd, SetPortFeature, - USB_PORT_FEAT_POWER, 1, NULL, 0); - if ((isp116x->rhdesca & RH_A_NDP) == 2) - isp116x_hub_control(hcd, SetPortFeature, - USB_PORT_FEAT_POWER, 2, NULL, 0); - hcd->self.root_hub->dev.power.power_state = PMSG_ON; - return 0; - } - - val = isp116x->rhdesca & RH_A_NDP; - while (val--) { - u32 stat = - isp116x_read_reg32(isp116x, val ? HCRHPORT2 : HCRHPORT1); - /* force global, not selective, resume */ - if (!(stat & RH_PS_PSS)) - continue; - DBG("%s: Resuming port %d\n", __func__, val); - isp116x_write_reg32(isp116x, RH_PS_POCI, val - ? HCRHPORT2 : HCRHPORT1); - } - spin_unlock_irq(&isp116x->lock); - - hcd->state = HC_STATE_RESUMING; - mdelay(20); - - /* Go operational */ - spin_lock_irq(&isp116x->lock); - val = isp116x_read_reg32(isp116x, HCCONTROL); - isp116x_write_reg32(isp116x, HCCONTROL, - (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER); - spin_unlock_irq(&isp116x->lock); - /* see analogous comment above */ - hcd->self.root_hub->dev.power.power_state = PMSG_ON; - hcd->state = HC_STATE_RUNNING; - - return 0; -} - - -#else - -#define isp116x_bus_suspend NULL -#define isp116x_bus_resume NULL - -#endif - /*-----------------------------------------------------------------*/ -#ifdef STUB_DEBUG_FILE - -static inline void create_debug_file(struct isp116x *isp116x) -{ -} - -static inline void remove_debug_file(struct isp116x *isp116x) -{ -} - -#else - -#include -#include +#ifdef CONFIG_DEBUG_FS static void dump_irq(struct seq_file *s, char *label, u16 mask) { @@ -1321,13 +1176,9 @@ static void dump_int(struct seq_file *s, char *label, u32 mask) mask & HCINT_SF ? " sof" : "", mask & HCINT_SO ? " so" : ""); } -static int proc_isp116x_show(struct seq_file *s, void *unused) +static int isp116x_show_dbg(struct seq_file *s, void *unused) { struct isp116x *isp116x = s->private; - struct isp116x_ep *ep; - struct urb *urb; - unsigned i; - char *str; seq_printf(s, "%s\n%s version %s\n", isp116x_to_hcd(isp116x)->product_desc, hcd_name, @@ -1343,105 +1194,50 @@ static int proc_isp116x_show(struct seq_file *s, void *unused) } spin_lock_irq(&isp116x->lock); - dump_irq(s, "hc_irq_enable", isp116x_read_reg16(isp116x, HCuPINTENB)); dump_irq(s, "hc_irq_status", isp116x_read_reg16(isp116x, HCuPINT)); dump_int(s, "hc_int_enable", isp116x_read_reg32(isp116x, HCINTENB)); dump_int(s, "hc_int_status", isp116x_read_reg32(isp116x, HCINTSTAT)); - - list_for_each_entry(ep, &isp116x->async, schedule) { - - switch (ep->nextpid) { - case USB_PID_IN: - str = "in"; - break; - case USB_PID_OUT: - str = "out"; - break; - case USB_PID_SETUP: - str = "setup"; - break; - case USB_PID_ACK: - str = "status"; - break; - default: - str = "?"; - break; - }; - seq_printf(s, "%p, ep%d%s, maxpacket %d:\n", ep, - ep->epnum, str, ep->maxpacket); - list_for_each_entry(urb, &ep->hep->urb_list, urb_list) { - seq_printf(s, " urb%p, %d/%d\n", urb, - urb->actual_length, - urb->transfer_buffer_length); - } - } - if (!list_empty(&isp116x->async)) - seq_printf(s, "\n"); - - seq_printf(s, "periodic size= %d\n", PERIODIC_SIZE); - - for (i = 0; i < PERIODIC_SIZE; i++) { - ep = isp116x->periodic[i]; - if (!ep) - continue; - seq_printf(s, "%2d [%3d]:\n", i, isp116x->load[i]); - - /* DUMB: prints shared entries multiple times */ - do { - seq_printf(s, " %d/%p (%sdev%d ep%d%s max %d)\n", - ep->period, ep, - (ep->udev->speed == - USB_SPEED_FULL) ? "" : "ls ", - ep->udev->devnum, ep->epnum, - (ep->epnum == - 0) ? "" : ((ep->nextpid == - USB_PID_IN) ? "in" : "out"), - ep->maxpacket); - ep = ep->next; - } while (ep); - } + isp116x_show_regs_seq(isp116x, s); spin_unlock_irq(&isp116x->lock); seq_printf(s, "\n"); return 0; } -static int proc_isp116x_open(struct inode *inode, struct file *file) +static int isp116x_open_seq(struct inode *inode, struct file *file) { - return single_open(file, proc_isp116x_show, PDE(inode)->data); + return single_open(file, isp116x_show_dbg, inode->u.generic_ip); } -static struct file_operations proc_ops = { - .open = proc_isp116x_open, +static struct file_operations isp116x_debug_fops = { + .open = isp116x_open_seq, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; -/* expect just one isp116x per system */ -static const char proc_filename[] = "driver/isp116x"; - -static void create_debug_file(struct isp116x *isp116x) +static int create_debug_file(struct isp116x *isp116x) { - struct proc_dir_entry *pde; - - pde = create_proc_entry(proc_filename, 0, NULL); - if (pde == NULL) - return; - - pde->proc_fops = &proc_ops; - pde->data = isp116x; - isp116x->pde = pde; + isp116x->dentry = debugfs_create_file(hcd_name, + S_IRUGO, NULL, isp116x, + &isp116x_debug_fops); + if (!isp116x->dentry) + return -ENOMEM; + return 0; } static void remove_debug_file(struct isp116x *isp116x) { - if (isp116x->pde) - remove_proc_entry(proc_filename, NULL); + debugfs_remove(isp116x->dentry); } -#endif +#else + +#define create_debug_file(d) 0 +#define remove_debug_file(d) do{}while(0) + +#endif /* CONFIG_DEBUG_FS */ /*-----------------------------------------------------------------*/ @@ -1476,7 +1272,7 @@ static int isp116x_reset(struct usb_hcd *hcd) struct isp116x *isp116x = hcd_to_isp116x(hcd); unsigned long t; u16 clkrdy = 0; - int ret = 0, timeout = 15 /* ms */ ; + int ret, timeout = 15 /* ms */ ; ret = isp116x_sw_reset(isp116x); if (ret) @@ -1492,7 +1288,7 @@ static int isp116x_reset(struct usb_hcd *hcd) break; } if (!clkrdy) { - ERR("Clock not ready after 20ms\n"); + ERR("Clock not ready after %dms\n", timeout); /* After sw_reset the clock won't report to be ready, if H_WAKEUP pin is high. */ ERR("Please make sure that the H_WAKEUP pin is pulled low!\n"); @@ -1610,12 +1406,128 @@ static int isp116x_start(struct usb_hcd *hcd) isp116x_write_reg32(isp116x, HCRHPORT1, RH_PS_CCS); isp116x_write_reg32(isp116x, HCRHPORT2, RH_PS_CCS); - isp116x_show_regs(isp116x); + isp116x_show_regs_log(isp116x); spin_unlock_irqrestore(&isp116x->lock, flags); return 0; } -/*-----------------------------------------------------------------*/ +#ifdef CONFIG_PM + +static int isp116x_bus_suspend(struct usb_hcd *hcd) +{ + struct isp116x *isp116x = hcd_to_isp116x(hcd); + unsigned long flags; + u32 val; + int ret = 0; + + spin_lock_irqsave(&isp116x->lock, flags); + + val = isp116x_read_reg32(isp116x, HCCONTROL); + switch (val & HCCONTROL_HCFS) { + case HCCONTROL_USB_OPER: + hcd->state = HC_STATE_QUIESCING; + val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); + val |= HCCONTROL_USB_SUSPEND; + if (hcd->remote_wakeup) + val |= HCCONTROL_RWE; + /* Wait for usb transfers to finish */ + mdelay(2); + isp116x_write_reg32(isp116x, HCCONTROL, val); + hcd->state = HC_STATE_SUSPENDED; + /* Wait for devices to suspend */ + mdelay(5); + case HCCONTROL_USB_SUSPEND: + break; + case HCCONTROL_USB_RESUME: + isp116x_write_reg32(isp116x, HCCONTROL, + (val & ~HCCONTROL_HCFS) | + HCCONTROL_USB_RESET); + case HCCONTROL_USB_RESET: + ret = -EBUSY; + break; + default: + ret = -EINVAL; + } + + spin_unlock_irqrestore(&isp116x->lock, flags); + return ret; +} + +static int isp116x_bus_resume(struct usb_hcd *hcd) +{ + struct isp116x *isp116x = hcd_to_isp116x(hcd); + u32 val; + + msleep(5); + spin_lock_irq(&isp116x->lock); + + val = isp116x_read_reg32(isp116x, HCCONTROL); + switch (val & HCCONTROL_HCFS) { + case HCCONTROL_USB_SUSPEND: + val &= ~HCCONTROL_HCFS; + val |= HCCONTROL_USB_RESUME; + isp116x_write_reg32(isp116x, HCCONTROL, val); + case HCCONTROL_USB_RESUME: + break; + case HCCONTROL_USB_OPER: + spin_unlock_irq(&isp116x->lock); + /* Without setting power_state here the + SUSPENDED state won't be removed from + sysfs/usbN/power.state as a response to remote + wakeup. Maybe in the future. */ + hcd->self.root_hub->dev.power.power_state = PMSG_ON; + return 0; + default: + /* HCCONTROL_USB_RESET: this may happen, when during + suspension the HC lost power. Reinitialize completely */ + spin_unlock_irq(&isp116x->lock); + DBG("Chip has been reset while suspended. Reinit from scratch.\n"); + isp116x_reset(hcd); + isp116x_start(hcd); + isp116x_hub_control(hcd, SetPortFeature, + USB_PORT_FEAT_POWER, 1, NULL, 0); + if ((isp116x->rhdesca & RH_A_NDP) == 2) + isp116x_hub_control(hcd, SetPortFeature, + USB_PORT_FEAT_POWER, 2, NULL, 0); + hcd->self.root_hub->dev.power.power_state = PMSG_ON; + return 0; + } + + val = isp116x->rhdesca & RH_A_NDP; + while (val--) { + u32 stat = + isp116x_read_reg32(isp116x, val ? HCRHPORT2 : HCRHPORT1); + /* force global, not selective, resume */ + if (!(stat & RH_PS_PSS)) + continue; + DBG("%s: Resuming port %d\n", __func__, val); + isp116x_write_reg32(isp116x, RH_PS_POCI, val + ? HCRHPORT2 : HCRHPORT1); + } + spin_unlock_irq(&isp116x->lock); + + hcd->state = HC_STATE_RESUMING; + msleep(20); + + /* Go operational */ + spin_lock_irq(&isp116x->lock); + val = isp116x_read_reg32(isp116x, HCCONTROL); + isp116x_write_reg32(isp116x, HCCONTROL, + (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER); + spin_unlock_irq(&isp116x->lock); + /* see analogous comment above */ + hcd->self.root_hub->dev.power.power_state = PMSG_ON; + hcd->state = HC_STATE_RUNNING; + + return 0; +} + +#else + +#define isp116x_bus_suspend NULL +#define isp116x_bus_resume NULL + +#endif static struct hc_driver isp116x_hc_driver = { .description = hcd_name, @@ -1745,12 +1657,19 @@ static int __init isp116x_probe(struct platform_device *pdev) } ret = usb_add_hcd(hcd, irq, SA_INTERRUPT); - if (ret != 0) + if (ret) goto err6; - create_debug_file(isp116x); + ret = create_debug_file(isp116x); + if (ret) { + ERR("Couldn't create debugfs entry\n"); + goto err7; + } + return 0; + err7: + usb_remove_hcd(hcd); err6: usb_put_hcd(hcd); err5: @@ -1772,13 +1691,9 @@ static int __init isp116x_probe(struct platform_device *pdev) */ static int isp116x_suspend(struct platform_device *dev, pm_message_t state) { - int ret = 0; - - VDBG("%s: state %x\n", __func__, state); - + VDBG("%s: state %x\n", __func__, state.event); dev->dev.power.power_state = state; - - return ret; + return 0; } /* @@ -1786,13 +1701,9 @@ static int isp116x_suspend(struct platform_device *dev, pm_message_t state) */ static int isp116x_resume(struct platform_device *dev) { - int ret = 0; - - VDBG("%s: state %x\n", __func__, dev->dev.power.power_state); - + VDBG("%s: state %x\n", __func__, dev->power.power_state.event); dev->dev.power.power_state = PMSG_ON; - - return ret; + return 0; } #else diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h index c6fec96..a1b7c38 100644 --- a/drivers/usb/host/isp116x.h +++ b/drivers/usb/host/isp116x.h @@ -259,7 +259,7 @@ struct isp116x { struct isp116x_platform_data *board; - struct proc_dir_entry *pde; + struct dentry *dentry; unsigned long stat1, stat2, stat4, stat8, stat16; /* HC registers */ @@ -450,7 +450,7 @@ static void isp116x_write_reg32(struct isp116x *isp116x, unsigned reg, isp116x_write_data32(isp116x, (u32) val); } -#define isp116x_show_reg(d,r) { \ +#define isp116x_show_reg_log(d,r,s) { \ if ((r) < 0x20) { \ DBG("%-12s[%02x]: %08x\n", #r, \ r, isp116x_read_reg32(d, r)); \ @@ -459,35 +459,60 @@ static void isp116x_write_reg32(struct isp116x *isp116x, unsigned reg, r, isp116x_read_reg16(d, r)); \ } \ } +#define isp116x_show_reg_seq(d,r,s) { \ + if ((r) < 0x20) { \ + seq_printf(s, "%-12s[%02x]: %08x\n", #r, \ + r, isp116x_read_reg32(d, r)); \ + } else { \ + seq_printf(s, "%-12s[%02x]: %04x\n", #r, \ + r, isp116x_read_reg16(d, r)); \ + } \ +} -static inline void isp116x_show_regs(struct isp116x *isp116x) +#define isp116x_show_regs(d,type,s) { \ + isp116x_show_reg_##type(d, HCREVISION, s); \ + isp116x_show_reg_##type(d, HCCONTROL, s); \ + isp116x_show_reg_##type(d, HCCMDSTAT, s); \ + isp116x_show_reg_##type(d, HCINTSTAT, s); \ + isp116x_show_reg_##type(d, HCINTENB, s); \ + isp116x_show_reg_##type(d, HCFMINTVL, s); \ + isp116x_show_reg_##type(d, HCFMREM, s); \ + isp116x_show_reg_##type(d, HCFMNUM, s); \ + isp116x_show_reg_##type(d, HCLSTHRESH, s); \ + isp116x_show_reg_##type(d, HCRHDESCA, s); \ + isp116x_show_reg_##type(d, HCRHDESCB, s); \ + isp116x_show_reg_##type(d, HCRHSTATUS, s); \ + isp116x_show_reg_##type(d, HCRHPORT1, s); \ + isp116x_show_reg_##type(d, HCRHPORT2, s); \ + isp116x_show_reg_##type(d, HCHWCFG, s); \ + isp116x_show_reg_##type(d, HCDMACFG, s); \ + isp116x_show_reg_##type(d, HCXFERCTR, s); \ + isp116x_show_reg_##type(d, HCuPINT, s); \ + isp116x_show_reg_##type(d, HCuPINTENB, s); \ + isp116x_show_reg_##type(d, HCCHIPID, s); \ + isp116x_show_reg_##type(d, HCSCRATCH, s); \ + isp116x_show_reg_##type(d, HCITLBUFLEN, s); \ + isp116x_show_reg_##type(d, HCATLBUFLEN, s); \ + isp116x_show_reg_##type(d, HCBUFSTAT, s); \ + isp116x_show_reg_##type(d, HCRDITL0LEN, s); \ + isp116x_show_reg_##type(d, HCRDITL1LEN, s); \ +} + +/* + Dump registers for debugfs. +*/ +static inline void isp116x_show_regs_seq(struct isp116x *isp116x, + struct seq_file *s) +{ + isp116x_show_regs(isp116x, seq, s); +} + +/* + Dump registers to syslog. +*/ +static inline void isp116x_show_regs_log(struct isp116x *isp116x) { - isp116x_show_reg(isp116x, HCREVISION); - isp116x_show_reg(isp116x, HCCONTROL); - isp116x_show_reg(isp116x, HCCMDSTAT); - isp116x_show_reg(isp116x, HCINTSTAT); - isp116x_show_reg(isp116x, HCINTENB); - isp116x_show_reg(isp116x, HCFMINTVL); - isp116x_show_reg(isp116x, HCFMREM); - isp116x_show_reg(isp116x, HCFMNUM); - isp116x_show_reg(isp116x, HCLSTHRESH); - isp116x_show_reg(isp116x, HCRHDESCA); - isp116x_show_reg(isp116x, HCRHDESCB); - isp116x_show_reg(isp116x, HCRHSTATUS); - isp116x_show_reg(isp116x, HCRHPORT1); - isp116x_show_reg(isp116x, HCRHPORT2); - isp116x_show_reg(isp116x, HCHWCFG); - isp116x_show_reg(isp116x, HCDMACFG); - isp116x_show_reg(isp116x, HCXFERCTR); - isp116x_show_reg(isp116x, HCuPINT); - isp116x_show_reg(isp116x, HCuPINTENB); - isp116x_show_reg(isp116x, HCCHIPID); - isp116x_show_reg(isp116x, HCSCRATCH); - isp116x_show_reg(isp116x, HCITLBUFLEN); - isp116x_show_reg(isp116x, HCATLBUFLEN); - isp116x_show_reg(isp116x, HCBUFSTAT); - isp116x_show_reg(isp116x, HCRDITL0LEN); - isp116x_show_reg(isp116x, HCRDITL1LEN); + isp116x_show_regs(isp116x, log, NULL); } #if defined(URB_TRACE) -- cgit v1.1 From 6912354a895fcd234155273fe8838a0d83259a9b Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 3 Nov 2005 11:44:49 -0500 Subject: [PATCH] USB: EHCI: fix conflation of buf == 0 with len == 0 When the ehci-hcd driver prepares a control URB, it tests for a zero-length data stage by looking at the transfer_dma value instead of the transfer_buffer_length. (In fact it does this even for non-control URBs, which is an additional aspect of the same bug.) However, under certain circumstances it's possible for transfer_dma to be 0 while transfer_buffer_length is non-zero. This can happen when a freshly allocated page (mapped to address 0 and marked Copy-On-Write, but never written to) is used as the source buffer for an OUT transfer. This patch (as598) fixes the problem. Signed-off-by: Alan Stern Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-q.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index bf03ec0..9b13bf2 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c @@ -514,18 +514,18 @@ qh_urb_transaction ( qtd->urb = urb; qtd_prev->hw_next = QTD_NEXT (qtd->qtd_dma); list_add_tail (&qtd->qtd_list, head); + + /* for zero length DATA stages, STATUS is always IN */ + if (len == 0) + token |= (1 /* "in" */ << 8); } /* * data transfer stage: buffer setup */ - if (likely (len > 0)) - buf = urb->transfer_dma; - else - buf = 0; + buf = urb->transfer_dma; - /* for zero length DATA stages, STATUS is always IN */ - if (!buf || is_input) + if (is_input) token |= (1 /* "in" */ << 8); /* else it's already initted to "out" pid (0 << 8) */ @@ -572,7 +572,7 @@ qh_urb_transaction ( * control requests may need a terminating data "status" ack; * bulk ones may need a terminating short packet (zero length). */ - if (likely (buf != 0)) { + if (likely (urb->transfer_buffer_length != 0)) { int one_more = 0; if (usb_pipecontrol (urb->pipe)) { -- cgit v1.1 From b72458a80c75cab832248f536412f386e20a93a0 Mon Sep 17 00:00:00 2001 From: matthieu castet Date: Mon, 7 Nov 2005 23:27:13 +0100 Subject: [PATCH] USB: Eagle and ADI 930 usb adsl modem driver A driver for USB ADSL modems based on the ADI eagle chipset using the usb_atm infrastructure. The managing part was taken from bsd ueagle driver, other parts were written from scratch. The driver uses the in-kernel firmware loader : - to load a first usb firmware when the modem is in pre-firmware state - to load the dsp firmware that are swapped in host memory. - to load CMV (configuration and management variables) when the modem boot. (We can't use options or sysfs for this as there many possible values. See https://mail.gna.org/public/eagleusb-dev/2005-04/msg00031.html for a description of some) - to load fpga code for 930 chipset. The device had 4 endpoints : * 2 for data (use by usbatm). The incoming endpoint could be iso or bulk. The modem seems buggy and produce lot's of atm errors when using it in bulk mode for speed > 3Mbps, so iso endpoint is need for speed > 3Mbps. At the moment iso endpoint need a patched usbatm library and for this reason is not included in this patch. * One bulk endpoint for uploading dsp firmware * One irq endpoint that notices the driver - if we need to upload a page of the dsp firmware - an ack for read or write CMV and the value (for the read case). If order to make the driver cleaner, we design synchronous (read|write)_cmv : -send a synchronous control message to the modem -wait for an ack or a timeout -return the value if needed. In order to run these synchronous usb messages we need a kernel thread. The driver has been tested with sagem fast 800 modems with different eagle chipset revision and with ADI 930 since April 2005. Signed-off-by: Matthieu CASTET Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/Kconfig | 13 + drivers/usb/atm/Makefile | 1 + drivers/usb/atm/ueagle-atm.c | 1813 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1827 insertions(+) create mode 100644 drivers/usb/atm/ueagle-atm.c diff --git a/drivers/usb/atm/Kconfig b/drivers/usb/atm/Kconfig index f429862..550ddfa7 100644 --- a/drivers/usb/atm/Kconfig +++ b/drivers/usb/atm/Kconfig @@ -44,6 +44,19 @@ config USB_CXACRU To compile this driver as a module, choose M here: the module will be called cxacru. +config USB_UEAGLEATM + tristate "ADI 930 and eagle USB DSL modem" + depends on USB_ATM + select FW_LOADER + help + Say Y here if you have an ADSL USB modem based on the ADI 930 + or eagle chipset. In order to use your modem you will need to + install firmwares and CMV (Command Management Variables); see + for details. + + To compile this driver as a module, choose M here: the + module will be called ueagle-atm. + config USB_XUSBATM tristate "Other USB DSL modem support" depends on USB_ATM diff --git a/drivers/usb/atm/Makefile b/drivers/usb/atm/Makefile index 8509971..4c4a776 100644 --- a/drivers/usb/atm/Makefile +++ b/drivers/usb/atm/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_USB_CXACRU) += cxacru.o obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o +obj-$(CONFIG_USB_UEAGLEATM) += ueagle-atm.o obj-$(CONFIG_USB_ATM) += usbatm.o obj-$(CONFIG_USB_XUSBATM) += xusbatm.o diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c new file mode 100644 index 0000000..3e2475c --- /dev/null +++ b/drivers/usb/atm/ueagle-atm.c @@ -0,0 +1,1813 @@ +/*- + * Copyright (c) 2003, 2004 + * Damien Bergamini . All rights reserved. + * + * Copyright (c) 2005 Matthieu Castet + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * BSD license below: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * GPL license : + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + * HISTORY : some part of the code was base on ueagle 1.3 BSD driver, + * Damien Bergamini agree to put his code under a DUAL GPL/BSD license. + * + * The rest of the code was was rewritten from scratch. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "usbatm.h" + +#define EAGLEUSBVERSION "ueagle 1.1" + + +/* + * Debug macros + */ +#define uea_dbg(usb_dev, format, args...) \ + do { \ + if (debug >= 1) \ + dev_dbg(&(usb_dev)->dev, \ + "[ueagle-atm dbg] %s: " format, \ + __FUNCTION__, ##args); \ + } while (0) + +#define uea_vdbg(usb_dev, format, args...) \ + do { \ + if (debug >= 2) \ + dev_dbg(&(usb_dev)->dev, \ + "[ueagle-atm vdbg] " format, ##args); \ + } while (0) + +#define uea_enters(usb_dev) \ + uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__) + +#define uea_leaves(usb_dev) \ + uea_vdbg(usb_dev, "leaving %s\n", __FUNCTION__) + +#define uea_err(usb_dev, format,args...) \ + dev_err(&(usb_dev)->dev ,"[UEAGLE-ATM] " format , ##args) + +#define uea_warn(usb_dev, format,args...) \ + dev_warn(&(usb_dev)->dev ,"[Ueagle-atm] " format, ##args) + +#define uea_info(usb_dev, format,args...) \ + dev_info(&(usb_dev)->dev ,"[ueagle-atm] " format, ##args) + +struct uea_cmvs { + u32 address; + u16 offset; + u32 data; +} __attribute__ ((packed)); + +struct uea_softc { + struct usb_device *usb_dev; + struct usbatm_data *usbatm; + + int modem_index; + unsigned int driver_info; + + int booting; + int reset; + + wait_queue_head_t sync_q; + + struct task_struct *kthread; + u32 data; + wait_queue_head_t cmv_ack_wait; + int cmv_ack; + + struct work_struct task; + u16 pageno; + u16 ovl; + + const struct firmware *dsp_firm; + struct urb *urb_int; + + u8 cmv_function; + u16 cmv_idx; + u32 cmv_address; + u16 cmv_offset; + + /* keep in sync with eaglectl */ + struct uea_stats { + struct { + u32 state; + u32 flags; + u32 mflags; + u32 vidcpe; + u32 vidco; + u32 dsrate; + u32 usrate; + u32 dsunc; + u32 usunc; + u32 dscorr; + u32 uscorr; + u32 txflow; + u32 rxflow; + u32 usattenuation; + u32 dsattenuation; + u32 dsmargin; + u32 usmargin; + u32 firmid; + } phy; + } stats; +}; + +/* + * Elsa IDs + */ +#define ELSA_VID 0x05CC +#define ELSA_PID_PSTFIRM 0x3350 +#define ELSA_PID_PREFIRM 0x3351 + +/* + * Sagem USB IDs + */ +#define EAGLE_VID 0x1110 +#define EAGLE_I_PID_PREFIRM 0x9010 /* Eagle I */ +#define EAGLE_I_PID_PSTFIRM 0x900F /* Eagle I */ + +#define EAGLE_IIC_PID_PREFIRM 0x9024 /* Eagle IIC */ +#define EAGLE_IIC_PID_PSTFIRM 0x9023 /* Eagle IIC */ + +#define EAGLE_II_PID_PREFIRM 0x9022 /* Eagle II */ +#define EAGLE_II_PID_PSTFIRM 0x9021 /* Eagle II */ + +/* + * Eagle III Pid + */ +#define EAGLE_III_PID_PREFIRM 0x9032 /* Eagle III */ +#define EAGLE_III_PID_PSTFIRM 0x9031 /* Eagle III */ + +/* + * USR USB IDs + */ +#define USR_VID 0x0BAF +#define MILLER_A_PID_PREFIRM 0x00F2 +#define MILLER_A_PID_PSTFIRM 0x00F1 +#define MILLER_B_PID_PREFIRM 0x00FA +#define MILLER_B_PID_PSTFIRM 0x00F9 +#define HEINEKEN_A_PID_PREFIRM 0x00F6 +#define HEINEKEN_A_PID_PSTFIRM 0x00F5 +#define HEINEKEN_B_PID_PREFIRM 0x00F8 +#define HEINEKEN_B_PID_PSTFIRM 0x00F7 + +#define PREFIRM 0 +#define PSTFIRM (1<<7) +enum { + ADI930 = 0, + EAGLE_I, + EAGLE_II, + EAGLE_III +}; + +/* macros for both struct usb_device_id and struct uea_softc */ +#define UEA_IS_PREFIRM(x) \ + (!((x)->driver_info & PSTFIRM)) +#define UEA_CHIP_VERSION(x) \ + ((x)->driver_info & 0xf) + +#define IS_ISDN(sc) \ + (le16_to_cpu(sc->usb_dev->descriptor.bcdDevice) & 0x80) + +#define INS_TO_USBDEV(ins) ins->usb_dev + +#define GET_STATUS(data) \ + ((data >> 8) & 0xf) +#define IS_OPERATIONAL(sc) \ + (GET_STATUS(sc->stats.phy.state) == 2) + +/* + * Set of macros to handle unaligned data in the firmware blob. + * The FW_GET_BYTE() macro is provided only for consistency. + */ + +#define FW_GET_BYTE(p) *((__u8 *) (p)) +#define FW_GET_WORD(p) le16_to_cpu(get_unaligned((__le16 *) (p))) +#define FW_GET_LONG(p) le32_to_cpu(get_unaligned((__le32 *) (p))) + +#define FW_DIR "ueagle-atm/" +#define NB_MODEM 4 + +#define BULK_TIMEOUT 300 +#define CTRL_TIMEOUT 1000 + +#define ACK_TIMEOUT msecs_to_jiffies(1500) + +#define UEA_INTR_IFACE_NO 0 +#define UEA_US_IFACE_NO 1 +#define UEA_DS_IFACE_NO 2 + +#define FASTEST_ISO_INTF 8 + +#define UEA_BULK_DATA_PIPE 0x02 +#define UEA_IDMA_PIPE 0x04 +#define UEA_INTR_PIPE 0x04 +#define UEA_ISO_DATA_PIPE 0x08 + +#define UEA_SET_BLOCK 0x0001 +#define UEA_SET_MODE 0x0003 +#define UEA_SET_2183_DATA 0x0004 +#define UEA_SET_TIMEOUT 0x0011 + +#define UEA_LOOPBACK_OFF 0x0002 +#define UEA_LOOPBACK_ON 0x0003 +#define UEA_BOOT_IDMA 0x0006 +#define UEA_START_RESET 0x0007 +#define UEA_END_RESET 0x0008 + +#define UEA_SWAP_MAILBOX (0x3fcd | 0x4000) +#define UEA_MPTX_START (0x3fce | 0x4000) +#define UEA_MPTX_MAILBOX (0x3fd6 | 0x4000) +#define UEA_MPRX_MAILBOX (0x3fdf | 0x4000) + +/* structure describing a block within a DSP page */ +struct block_info { + __le16 wHdr; +#define UEA_BIHDR 0xabcd + __le16 wAddress; + __le16 wSize; + __le16 wOvlOffset; + __le16 wOvl; /* overlay */ + __le16 wLast; +} __attribute__ ((packed)); +#define BLOCK_INFO_SIZE 12 + +/* structure representing a CMV (Configuration and Management Variable) */ +struct cmv { + __le16 wPreamble; +#define PREAMBLE 0x535c + __u8 bDirection; +#define MODEMTOHOST 0x01 +#define HOSTTOMODEM 0x10 + __u8 bFunction; +#define FUNCTION_TYPE(f) ((f) >> 4) +#define MEMACCESS 0x1 +#define ADSLDIRECTIVE 0x7 + +#define FUNCTION_SUBTYPE(f) ((f) & 0x0f) +/* for MEMACCESS */ +#define REQUESTREAD 0x0 +#define REQUESTWRITE 0x1 +#define REPLYREAD 0x2 +#define REPLYWRITE 0x3 +/* for ADSLDIRECTIVE */ +#define KERNELREADY 0x0 +#define MODEMREADY 0x1 + +#define MAKEFUNCTION(t, s) (((t) & 0xf) << 4 | ((s) & 0xf)) + __le16 wIndex; + __le32 dwSymbolicAddress; +#define MAKESA(a, b, c, d) \ + (((c) & 0xff) << 24 | \ + ((d) & 0xff) << 16 | \ + ((a) & 0xff) << 8 | \ + ((b) & 0xff)) + +#define SA_CNTL MAKESA('C', 'N', 'T', 'L') +#define SA_DIAG MAKESA('D', 'I', 'A', 'G') +#define SA_INFO MAKESA('I', 'N', 'F', 'O') +#define SA_OPTN MAKESA('O', 'P', 'T', 'N') +#define SA_RATE MAKESA('R', 'A', 'T', 'E') +#define SA_STAT MAKESA('S', 'T', 'A', 'T') + __le16 wOffsetAddress; + __le32 dwData; +} __attribute__ ((packed)); +#define CMV_SIZE 16 + +/* structure representing swap information */ +struct swap_info { + __u8 bSwapPageNo; + __u8 bOvl; /* overlay */ +} __attribute__ ((packed)); + +/* structure representing interrupt data */ +struct intr_pkt { + __u8 bType; + __u8 bNotification; + __le16 wValue; + __le16 wIndex; + __le16 wLength; + __le16 wInterrupt; +#define INT_LOADSWAPPAGE 0x0001 +#define INT_INCOMINGCMV 0x0002 + union { + struct { + struct swap_info swapinfo; + __le16 wDataSize; + } __attribute__ ((packed)) s1; + + struct { + struct cmv cmv; + __le16 wDataSize; + } __attribute__ ((packed)) s2; + } __attribute__ ((packed)) u; +#define bSwapPageNo u.s1.swapinfo.bSwapPageNo +#define bOvl u.s1.swapinfo.bOvl +} __attribute__ ((packed)); +#define INTR_PKT_SIZE 28 + +static struct usb_driver uea_driver; +static DECLARE_MUTEX(uea_semaphore); +static const char *chip_name[] = {"ADI930", "Eagle I", "Eagle II", "Eagle III"}; + +static int modem_index; +static unsigned int debug; +static int sync_wait[NB_MODEM]; +static char *cmv_file[NB_MODEM]; + +module_param(debug, uint, 0644); +MODULE_PARM_DESC(debug, "module debug level (0=off,1=on,2=verbose)"); +module_param_array(sync_wait, bool, NULL, 0644); +MODULE_PARM_DESC(sync_wait, "wait the synchronisation before starting ATM"); +module_param_array(cmv_file, charp, NULL, 0644); +MODULE_PARM_DESC(cmv_file, + "file name with configuration and management variables"); + +#define UPDATE_ATM_STAT(type, val) \ + do { \ + if (sc->usbatm->atm_dev) \ + sc->usbatm->atm_dev->type = val; \ + } while (0) + +/* Firmware loading */ +#define LOAD_INTERNAL 0xA0 +#define F8051_USBCS 0x7f92 + +/** + * uea_send_modem_cmd - Send a command for pre-firmware devices. + */ +static int uea_send_modem_cmd(struct usb_device *usb, + u16 addr, u16 size, u8 * buff) +{ + int ret = -ENOMEM; + u8 *xfer_buff; + + xfer_buff = kmalloc(size, GFP_KERNEL); + if (xfer_buff) { + memcpy(xfer_buff, buff, size); + ret = usb_control_msg(usb, + usb_sndctrlpipe(usb, 0), + LOAD_INTERNAL, + USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_DEVICE, addr, 0, xfer_buff, + size, CTRL_TIMEOUT); + kfree(xfer_buff); + } + + if (ret < 0) + return ret; + + return (ret == size) ? 0 : -EIO; +} + +static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *context) +{ + struct usb_device *usb = context; + u8 *pfw, value; + u32 crc = 0; + int ret, size; + + uea_enters(usb); + if (!fw_entry) { + uea_err(usb, "firmware is not available\n"); + goto err; + } + + pfw = fw_entry->data; + size = fw_entry->size; + + crc = FW_GET_LONG(pfw); + pfw += 4; + size -= 4; + if (crc32_be(0, pfw, size) != crc) { + uea_err(usb, "firmware is corrupted\n"); + goto err; + } + + /* + * Start to upload formware : send reset + */ + value = 1; + ret = uea_send_modem_cmd(usb, F8051_USBCS, sizeof(value), &value); + + if (ret < 0) { + uea_err(usb, "modem reset failed with error %d\n", ret); + goto err; + } + + while (size > 0) { + u8 len = FW_GET_BYTE(pfw); + u16 add = FW_GET_WORD(pfw + 1); + ret = uea_send_modem_cmd(usb, add, len, pfw + 3); + if (ret < 0) { + uea_err(usb, "uploading firmware data failed " + "with error %d\n", ret); + goto err; + } + pfw += len + 3; + size -= len + 3; + } + + /* + * Tell the modem we finish : de-assert reset + */ + value = 0; + ret = uea_send_modem_cmd(usb, F8051_USBCS, 1, &value); + if (ret < 0) + uea_err(usb, "modem de-assert failed with error %d\n", ret); + else + uea_info(usb, "firmware uploaded\n"); + +err: + uea_leaves(usb); +} + +/** + * uea_load_firmware - Load usb firmware for pre-firmware devices. + */ +static int uea_load_firmware(struct usb_device *usb, unsigned int ver) +{ + int ret; + char *fw_name = FW_DIR "eagle.fw"; + + uea_enters(usb); + uea_info(usb, "pre-firmware device, uploading firmware\n"); + + switch (ver) { + case ADI930: + fw_name = FW_DIR "adi930.fw"; + break; + case EAGLE_I: + fw_name = FW_DIR "eagleI.fw"; + break; + case EAGLE_II: + fw_name = FW_DIR "eagleII.fw"; + break; + case EAGLE_III: + fw_name = FW_DIR "eagleIII.fw"; + break; + } + + ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev, usb, uea_upload_pre_firmware); + if (ret) + uea_err(usb, "firmware %s is not available\n", fw_name); + else + uea_info(usb, "loading firmware %s\n", fw_name); + + uea_leaves(usb); + return ret; +} + +/* modem management : dsp firmware, send/read CMV, monitoring statistic + */ + +/* + * Make sure that the DSP code provided is safe to use. + */ +static int check_dsp(u8 *dsp, unsigned int len) +{ + u8 pagecount, blockcount; + u16 blocksize; + u32 pageoffset; + unsigned int i, j, p, pp; + + /* enough space for pagecount? */ + if (len < 1) + return 1; + + pagecount = FW_GET_BYTE(dsp); + p = 1; + + /* enough space for page offsets? */ + if (p + 4 * pagecount > len) + return 1; + + for (i = 0; i < pagecount; i++) { + + pageoffset = FW_GET_LONG(dsp + p); + p += 4; + + if (pageoffset == 0) + continue; + + /* enough space for blockcount? */ + if (pageoffset >= len) + return 1; + + pp = pageoffset; + blockcount = FW_GET_BYTE(dsp + pp); + pp += 1; + + for (j = 0; j < blockcount; j++) { + + /* enough space for block header? */ + if (pp + 4 > len) + return 1; + + pp += 2; /* skip blockaddr */ + blocksize = FW_GET_WORD(dsp + pp); + pp += 2; + + /* enough space for block data? */ + if (pp + blocksize > len) + return 1; + + pp += blocksize; + } + } + + return 0; +} + +/* + * send data to the idma pipe + * */ +static int uea_idma_write(struct uea_softc *sc, void *data, u32 size) +{ + int ret = -ENOMEM; + u8 *xfer_buff; + int bytes_read; + + xfer_buff = kmalloc(size, GFP_KERNEL); + if (!xfer_buff) { + uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); + return ret; + } + + memcpy(xfer_buff, data, size); + + ret = usb_bulk_msg(sc->usb_dev, + usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE), + xfer_buff, size, &bytes_read, BULK_TIMEOUT); + + kfree(xfer_buff); + if (ret < 0) + return ret; + if (size != bytes_read) { + uea_err(INS_TO_USBDEV(sc), "size != bytes_read %d %d\n", size, + bytes_read); + return -EIO; + } + + return 0; +} + +static int request_dsp(struct uea_softc *sc) +{ + int ret; + char *dsp_name; + + if (UEA_CHIP_VERSION(sc) == ADI930) { + if (IS_ISDN(sc)) + dsp_name = FW_DIR "DSP9i.bin"; + else + dsp_name = FW_DIR "DSP9p.bin"; + } else { + if (IS_ISDN(sc)) + dsp_name = FW_DIR "DSPei.bin"; + else + dsp_name = FW_DIR "DSPep.bin"; + } + + ret = request_firmware(&sc->dsp_firm, + dsp_name, &sc->usb_dev->dev); + if (ret < 0) { + uea_err(INS_TO_USBDEV(sc), + "requesting firmware %s failed with error %d\n", + dsp_name, ret); + return ret; + } + + if (check_dsp(sc->dsp_firm->data, sc->dsp_firm->size)) { + uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", + dsp_name); + release_firmware(sc->dsp_firm); + sc->dsp_firm = NULL; + return -EILSEQ; + } + + return 0; +} + +/* + * The uea_load_page() function must be called within a process context + */ +static void uea_load_page(void *xsc) +{ + struct uea_softc *sc = xsc; + u16 pageno = sc->pageno; + u16 ovl = sc->ovl; + struct block_info bi; + + u8 *p; + u8 pagecount, blockcount; + u16 blockaddr, blocksize; + u32 pageoffset; + int i; + + /* reload firmware when reboot start and it's loaded already */ + if (ovl == 0 && pageno == 0 && sc->dsp_firm) { + release_firmware(sc->dsp_firm); + sc->dsp_firm = NULL; + } + + if (sc->dsp_firm == NULL && request_dsp(sc) < 0) + return; + + p = sc->dsp_firm->data; + pagecount = FW_GET_BYTE(p); + p += 1; + + if (pageno >= pagecount) + goto bad1; + + p += 4 * pageno; + pageoffset = FW_GET_LONG(p); + + if (pageoffset == 0) + goto bad1; + + p = sc->dsp_firm->data + pageoffset; + blockcount = FW_GET_BYTE(p); + p += 1; + + uea_dbg(INS_TO_USBDEV(sc), + "sending %u blocks for DSP page %u\n", blockcount, pageno); + + bi.wHdr = cpu_to_le16(UEA_BIHDR); + bi.wOvl = cpu_to_le16(ovl); + bi.wOvlOffset = cpu_to_le16(ovl | 0x8000); + + for (i = 0; i < blockcount; i++) { + blockaddr = FW_GET_WORD(p); + p += 2; + + blocksize = FW_GET_WORD(p); + p += 2; + + bi.wSize = cpu_to_le16(blocksize); + bi.wAddress = cpu_to_le16(blockaddr); + bi.wLast = cpu_to_le16((i == blockcount - 1) ? 1 : 0); + + /* send block info through the IDMA pipe */ + if (uea_idma_write(sc, &bi, BLOCK_INFO_SIZE)) + goto bad2; + + /* send block data through the IDMA pipe */ + if (uea_idma_write(sc, p, blocksize)) + goto bad2; + + p += blocksize; + } + + return; + +bad2: + uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i); + return; +bad1: + uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n",pageno); +} + +static inline void wake_up_cmv_ack(struct uea_softc *sc) +{ + sc->cmv_ack = 1; + wake_up(&sc->cmv_ack_wait); +} + +static inline int wait_cmv_ack(struct uea_softc *sc) +{ + int ret = wait_event_timeout(sc->cmv_ack_wait, + sc->cmv_ack, ACK_TIMEOUT); + sc->cmv_ack = 0; + + if (ret < 0) + return ret; + + return (ret == 0) ? -ETIMEDOUT : 0; + +} + +#define UCDC_SEND_ENCAPSULATED_COMMAND 0x00 + +static int uea_request(struct uea_softc *sc, + u16 value, u16 index, u16 size, void *data) +{ + u8 *xfer_buff; + int ret = -ENOMEM; + + xfer_buff = kmalloc(size, GFP_KERNEL); + if (!xfer_buff) { + uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n"); + return ret; + } + memcpy(xfer_buff, data, size); + + ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0), + UCDC_SEND_ENCAPSULATED_COMMAND, + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + value, index, xfer_buff, size, CTRL_TIMEOUT); + + kfree(xfer_buff); + if (ret < 0) { + uea_err(INS_TO_USBDEV(sc), "usb_control_msg error %d\n", ret); + return ret; + } + + if (ret != size) { + uea_err(INS_TO_USBDEV(sc), + "usb_control_msg send only %d bytes (instead of %d)\n", + ret, size); + return -EIO; + } + + return 0; +} + +static int uea_cmv(struct uea_softc *sc, + u8 function, u32 address, u16 offset, u32 data) +{ + struct cmv cmv; + int ret; + + /* we send a request, but we expect a reply */ + sc->cmv_function = function | 0x2; + sc->cmv_idx++; + sc->cmv_address = address; + sc->cmv_offset = offset; + + cmv.wPreamble = cpu_to_le16(PREAMBLE); + cmv.bDirection = HOSTTOMODEM; + cmv.bFunction = function; + cmv.wIndex = cpu_to_le16(sc->cmv_idx); + put_unaligned(cpu_to_le32(address), &cmv.dwSymbolicAddress); + cmv.wOffsetAddress = cpu_to_le16(offset); + put_unaligned(cpu_to_le32(data >> 16 | data << 16), &cmv.dwData); + + ret = uea_request(sc, UEA_SET_BLOCK, UEA_MPTX_START, CMV_SIZE, &cmv); + if (ret < 0) + return ret; + return wait_cmv_ack(sc); +} + +static inline int uea_read_cmv(struct uea_softc *sc, + u32 address, u16 offset, u32 *data) +{ + int ret = uea_cmv(sc, MAKEFUNCTION(MEMACCESS, REQUESTREAD), + address, offset, 0); + if (ret < 0) + uea_err(INS_TO_USBDEV(sc), + "reading cmv failed with error %d\n", ret); + else + *data = sc->data; + + return ret; +} + +static inline int uea_write_cmv(struct uea_softc *sc, + u32 address, u16 offset, u32 data) +{ + int ret = uea_cmv(sc, MAKEFUNCTION(MEMACCESS, REQUESTWRITE), + address, offset, data); + if (ret < 0) + uea_err(INS_TO_USBDEV(sc), + "writing cmv failed with error %d\n", ret); + + return ret; +} + +/* + * Monitor the modem and update the stat + * return 0 if everything is ok + * return < 0 if an error occurs (-EAGAIN reboot needed) + */ +static int uea_stat(struct uea_softc *sc) +{ + u32 data; + int ret; + + uea_enters(INS_TO_USBDEV(sc)); + data = sc->stats.phy.state; + + ret = uea_read_cmv(sc, SA_STAT, 0, &sc->stats.phy.state); + if (ret < 0) + return ret; + + switch (GET_STATUS(sc->stats.phy.state)) { + case 0: /* not yet synchronized */ + uea_dbg(INS_TO_USBDEV(sc), + "modem not yet synchronized\n"); + return 0; + + case 1: /* initialization */ + uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n"); + return 0; + + case 2: /* operational */ + uea_vdbg(INS_TO_USBDEV(sc), "modem operational\n"); + break; + + case 3: /* fail ... */ + uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n"); + return -EAGAIN; + + case 4 ... 6: /* test state */ + uea_warn(INS_TO_USBDEV(sc), + "modem in test mode - not supported\n"); + return -EAGAIN; + + case 7: /* fast-retain ... */ + uea_info(INS_TO_USBDEV(sc), "modem in fast-retain mode\n"); + return 0; + default: + uea_err(INS_TO_USBDEV(sc), "modem invalid SW mode %d\n", + GET_STATUS(sc->stats.phy.state)); + return -EAGAIN; + } + + if (GET_STATUS(data) != 2) { + uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL); + uea_info(INS_TO_USBDEV(sc), "modem operational\n"); + + /* release the dsp firmware as it is not needed until + * the next failure + */ + if (sc->dsp_firm) { + release_firmware(sc->dsp_firm); + sc->dsp_firm = NULL; + } + + ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid); + if (ret < 0) + return ret; + uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n", + sc->stats.phy.firmid); + } + + /* always update it as atm layer could not be init when we switch to + * operational state + */ + UPDATE_ATM_STAT(signal, ATM_PHY_SIG_FOUND); + + /* wake up processes waiting for synchronization */ + wake_up(&sc->sync_q); + + ret = uea_read_cmv(sc, SA_DIAG, 2, &sc->stats.phy.flags); + if (ret < 0) + return ret; + sc->stats.phy.mflags |= sc->stats.phy.flags; + + /* in case of a flags ( for example delineation LOSS (& 0x10)), + * we check the status again in order to detect the failure earlier + */ + if (sc->stats.phy.flags) { + uea_dbg(INS_TO_USBDEV(sc), "Stat flag = %d\n", + sc->stats.phy.flags); + return 0; + } + + ret = uea_read_cmv(sc, SA_RATE, 0, &data); + if (ret < 0) + return ret; + + /* in bulk mode the modem have problem with high rate + * changing internal timing could improve things, but the + * value is misterious. + * ADI930 don't support it (-EPIPE error). + */ + if (UEA_CHIP_VERSION(sc) != ADI930 + && sc->stats.phy.dsrate != (data >> 16) * 32) { + /* Original timming from ADI(used in windows driver) + * 0x20ffff>>16 * 32 = 32 * 32 = 1Mbits + */ + u16 timeout = (data <= 0x20ffff) ? 0 : 1; + ret = uea_request(sc, UEA_SET_TIMEOUT, timeout, 0, NULL); + uea_info(INS_TO_USBDEV(sc), + "setting new timeout %d%s\n", timeout, + ret < 0?" failed":""); + } + sc->stats.phy.dsrate = (data >> 16) * 32; + sc->stats.phy.usrate = (data & 0xffff) * 32; + UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424); + + ret = uea_read_cmv(sc, SA_DIAG, 23, &data); + if (ret < 0) + return ret; + sc->stats.phy.dsattenuation = (data & 0xff) / 2; + + ret = uea_read_cmv(sc, SA_DIAG, 47, &data); + if (ret < 0) + return ret; + sc->stats.phy.usattenuation = (data & 0xff) / 2; + + ret = uea_read_cmv(sc, SA_DIAG, 25, &sc->stats.phy.dsmargin); + if (ret < 0) + return ret; + + ret = uea_read_cmv(sc, SA_DIAG, 49, &sc->stats.phy.usmargin); + if (ret < 0) + return ret; + + ret = uea_read_cmv(sc, SA_DIAG, 51, &sc->stats.phy.rxflow); + if (ret < 0) + return ret; + + ret = uea_read_cmv(sc, SA_DIAG, 52, &sc->stats.phy.txflow); + if (ret < 0) + return ret; + + ret = uea_read_cmv(sc, SA_DIAG, 54, &sc->stats.phy.dsunc); + if (ret < 0) + return ret; + + /* only for atu-c */ + ret = uea_read_cmv(sc, SA_DIAG, 58, &sc->stats.phy.usunc); + if (ret < 0) + return ret; + + ret = uea_read_cmv(sc, SA_DIAG, 53, &sc->stats.phy.dscorr); + if (ret < 0) + return ret; + + /* only for atu-c */ + ret = uea_read_cmv(sc, SA_DIAG, 57, &sc->stats.phy.uscorr); + if (ret < 0) + return ret; + + ret = uea_read_cmv(sc, SA_INFO, 8, &sc->stats.phy.vidco); + if (ret < 0) + return ret; + + ret = uea_read_cmv(sc, SA_INFO, 13, &sc->stats.phy.vidcpe); + if (ret < 0) + return ret; + + return 0; +} + +static int request_cmvs(struct uea_softc *sc, + struct uea_cmvs **cmvs, const struct firmware **fw) +{ + int ret, size; + u8 *data; + char *file; + static char cmv_name[256] = FW_DIR; + + if (cmv_file[sc->modem_index] == NULL) { + if (UEA_CHIP_VERSION(sc) == ADI930) + file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin"; + else + file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin"; + } else + file = cmv_file[sc->modem_index]; + + strcpy(cmv_name, FW_DIR); + strlcat(cmv_name, file, sizeof(cmv_name)); + + ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev); + if (ret < 0) { + uea_err(INS_TO_USBDEV(sc), + "requesting firmware %s failed with error %d\n", + cmv_name, ret); + return ret; + } + + data = (u8 *) (*fw)->data; + size = *data * sizeof(struct uea_cmvs) + 1; + if (size != (*fw)->size) { + uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", + cmv_name); + release_firmware(*fw); + return -EILSEQ; + } + + *cmvs = (struct uea_cmvs *)(data + 1); + return *data; +} + +/* Start boot post firmware modem: + * - send reset commands through usb control pipe + * - start workqueue for DSP loading + * - send CMV options to modem + */ + +static int uea_start_reset(struct uea_softc *sc) +{ + u16 zero = 0; /* ;-) */ + int i, len, ret; + struct uea_cmvs *cmvs; + const struct firmware *cmvs_fw; + + uea_enters(INS_TO_USBDEV(sc)); + uea_info(INS_TO_USBDEV(sc), "(re)booting started\n"); + + sc->booting = 1; + UPDATE_ATM_STAT(signal, ATM_PHY_SIG_LOST); + + /* reset statistics */ + memset(&sc->stats, 0, sizeof(struct uea_stats)); + + /* tell the modem that we want to boot in IDMA mode */ + uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL); + uea_request(sc, UEA_SET_MODE, UEA_BOOT_IDMA, 0, NULL); + + /* enter reset mode */ + uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL); + + /* original driver use 200ms, but windows driver use 100ms */ + msleep(100); + + /* leave reset mode */ + uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL); + + /* clear tx and rx mailboxes */ + uea_request(sc, UEA_SET_2183_DATA, UEA_MPTX_MAILBOX, 2, &zero); + uea_request(sc, UEA_SET_2183_DATA, UEA_MPRX_MAILBOX, 2, &zero); + uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero); + + msleep(1000); + sc->cmv_function = MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY); + sc->booting = 0; + + /* start loading DSP */ + sc->pageno = 0; + sc->ovl = 0; + schedule_work(&sc->task); + + /* wait for modem ready CMV */ + ret = wait_cmv_ack(sc); + if (ret < 0) + return ret; + + /* Enter in R-IDLE (cmv) until instructed otherwise */ + ret = uea_write_cmv(sc, SA_CNTL, 0, 1); + if (ret < 0) + return ret; + + /* get options */ + ret = len = request_cmvs(sc, &cmvs, &cmvs_fw); + if (ret < 0) + return ret; + + /* send options */ + for (i = 0; i < len; i++) { + ret = uea_write_cmv(sc, FW_GET_LONG(&cmvs[i].address), + FW_GET_WORD(&cmvs[i].offset), + FW_GET_LONG(&cmvs[i].data)); + if (ret < 0) + goto out; + } + /* Enter in R-ACT-REQ */ + ret = uea_write_cmv(sc, SA_CNTL, 0, 2); +out: + release_firmware(cmvs_fw); + sc->reset = 0; + uea_leaves(INS_TO_USBDEV(sc)); + return ret; +} + +/* + * In case of an error wait 1s before rebooting the modem + * if the modem don't request reboot (-EAGAIN). + * Monitor the modem every 1s. + */ + +static int uea_kthread(void *data) +{ + struct uea_softc *sc = data; + int ret = -EAGAIN; + + uea_enters(INS_TO_USBDEV(sc)); + while (!kthread_should_stop()) { + if (ret < 0 || sc->reset) + ret = uea_start_reset(sc); + if (!ret) + ret = uea_stat(sc); + if (ret != -EAGAIN) + msleep(1000); + } + uea_leaves(INS_TO_USBDEV(sc)); + return ret; +} + +/* Load second usb firmware for ADI930 chip */ +static int load_XILINX_firmware(struct uea_softc *sc) +{ + const struct firmware *fw_entry; + int ret, size, u, ln; + u8 *pfw, value; + char *fw_name = FW_DIR "930-fpga.bin"; + + uea_enters(INS_TO_USBDEV(sc)); + + ret = request_firmware(&fw_entry, fw_name, &sc->usb_dev->dev); + if (ret) { + uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n", + fw_name); + goto err0; + } + + pfw = fw_entry->data; + size = fw_entry->size; + if (size != 0x577B) { + uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n", + fw_name); + ret = -EILSEQ; + goto err1; + } + for (u = 0; u < size; u += ln) { + ln = min(size - u, 64); + ret = uea_request(sc, 0xe, 0, ln, pfw + u); + if (ret < 0) { + uea_err(INS_TO_USBDEV(sc), + "elsa download data failed (%d)\n", ret); + goto err1; + } + } + + /* finish to send the fpga + */ + ret = uea_request(sc, 0xe, 1, 0, NULL); + if (ret < 0) { + uea_err(INS_TO_USBDEV(sc), + "elsa download data failed (%d)\n", ret); + goto err1; + } + + /* + * Tell the modem we finish : de-assert reset + */ + value = 0; + ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value); + if (ret < 0) + uea_err(sc->usb_dev, "elsa de-assert failed with error %d\n", ret); + + +err1: + release_firmware(fw_entry); +err0: + uea_leaves(INS_TO_USBDEV(sc)); + return ret; +} + +static void uea_dispatch_cmv(struct uea_softc *sc, struct cmv* cmv) +{ + uea_enters(INS_TO_USBDEV(sc)); + if (le16_to_cpu(cmv->wPreamble) != PREAMBLE) + goto bad1; + + if (cmv->bDirection != MODEMTOHOST) + goto bad1; + + /* FIXME : ADI930 reply wrong preambule (func = 2, sub = 2) to + * the first MEMACESS cmv. Ignore it... + */ + if (cmv->bFunction != sc->cmv_function) { + if (UEA_CHIP_VERSION(sc) == ADI930 + && cmv->bFunction == MAKEFUNCTION(2, 2)) { + cmv->wIndex = cpu_to_le16(sc->cmv_idx); + put_unaligned(cpu_to_le32(sc->cmv_address), &cmv->dwSymbolicAddress); + cmv->wOffsetAddress = cpu_to_le16(sc->cmv_offset); + } + else + goto bad2; + } + + if (cmv->bFunction == MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY)) { + wake_up_cmv_ack(sc); + return; + } + + /* in case of MEMACCESS */ + if (le16_to_cpu(cmv->wIndex) != sc->cmv_idx || + le32_to_cpu(get_unaligned(&cmv->dwSymbolicAddress)) != + sc->cmv_address + || le16_to_cpu(cmv->wOffsetAddress) != sc->cmv_offset) + goto bad2; + + sc->data = le32_to_cpu(get_unaligned(&cmv->dwData)); + sc->data = sc->data << 16 | sc->data >> 16; + + wake_up_cmv_ack(sc); + return; + +bad2: + uea_err(INS_TO_USBDEV(sc), "unexpected cmv received," + "Function : %d, Subfunction : %d\n", + FUNCTION_TYPE(cmv->bFunction), + FUNCTION_SUBTYPE(cmv->bFunction)); + return; + +bad1: + uea_err(INS_TO_USBDEV(sc), "invalid cmv received, " + "wPreamble %d, bDirection %d\n", + le16_to_cpu(cmv->wPreamble), cmv->bDirection); +} + +/* + * interrupt handler + */ +static void uea_intr(struct urb *urb, struct pt_regs *regs) +{ + struct uea_softc *sc = (struct uea_softc *)urb->context; + struct intr_pkt *intr; + uea_enters(INS_TO_USBDEV(sc)); + + if (urb->status < 0) { + uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n", + urb->status); + return; + } + + intr = (struct intr_pkt *) urb->transfer_buffer; + + /* device-to-host interrupt */ + if (intr->bType != 0x08 || sc->booting) { + uea_err(INS_TO_USBDEV(sc), "wrong intr\n"); + // rebooting ? + // sc->reset = 1; + goto resubmit; + } + + switch (le16_to_cpu(intr->wInterrupt)) { + case INT_LOADSWAPPAGE: + sc->pageno = intr->bSwapPageNo; + sc->ovl = intr->bOvl >> 4 | intr->bOvl << 4; + schedule_work(&sc->task); + break; + + case INT_INCOMINGCMV: + uea_dispatch_cmv(sc, &intr->u.s2.cmv); + break; + + default: + uea_err(INS_TO_USBDEV(sc), "unknown intr %u\n", + le16_to_cpu(intr->wInterrupt)); + } + +resubmit: + usb_submit_urb(sc->urb_int, GFP_ATOMIC); +} + +/* + * Start the modem : init the data and start kernel thread + */ +static int uea_boot(struct uea_softc *sc) +{ + int ret; + struct intr_pkt *intr; + + uea_enters(INS_TO_USBDEV(sc)); + + INIT_WORK(&sc->task, uea_load_page, sc); + init_waitqueue_head(&sc->sync_q); + init_waitqueue_head(&sc->cmv_ack_wait); + + if (UEA_CHIP_VERSION(sc) == ADI930) + load_XILINX_firmware(sc); + + intr = kmalloc(INTR_PKT_SIZE, GFP_KERNEL); + if (!intr) { + uea_err(INS_TO_USBDEV(sc), + "cannot allocate interrupt package\n"); + uea_leaves(INS_TO_USBDEV(sc)); + return -ENOMEM; + } + + sc->urb_int = usb_alloc_urb(0, GFP_KERNEL); + if (!sc->urb_int) { + uea_err(INS_TO_USBDEV(sc), "cannot allocate interrupt URB\n"); + goto err; + } + + usb_fill_int_urb(sc->urb_int, sc->usb_dev, + usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE), + intr, INTR_PKT_SIZE, uea_intr, sc, + sc->usb_dev->actconfig->interface[0]->altsetting[0]. + endpoint[0].desc.bInterval); + + ret = usb_submit_urb(sc->urb_int, GFP_KERNEL); + if (ret < 0) { + uea_err(INS_TO_USBDEV(sc), + "urb submition failed with error %d\n", ret); + goto err1; + } + + sc->kthread = kthread_run(uea_kthread, sc, "ueagle-atm"); + if (sc->kthread == ERR_PTR(-ENOMEM)) { + uea_err(INS_TO_USBDEV(sc), "failed to create thread\n"); + goto err2; + } + + uea_leaves(INS_TO_USBDEV(sc)); + return 0; + +err2: + usb_kill_urb(sc->urb_int); +err1: + kfree(intr); +err: + usb_free_urb(sc->urb_int); + uea_leaves(INS_TO_USBDEV(sc)); + return -ENOMEM; +} + +/* + * Stop the modem : kill kernel thread and free data + */ +static void uea_stop(struct uea_softc *sc) +{ + int ret; + uea_enters(INS_TO_USBDEV(sc)); + ret = kthread_stop(sc->kthread); + uea_info(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret); + + /* stop any pending boot process */ + flush_scheduled_work(); + + uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL); + + usb_kill_urb(sc->urb_int); + kfree(sc->urb_int->transfer_buffer); + usb_free_urb(sc->urb_int); + + if (sc->dsp_firm) + release_firmware(sc->dsp_firm); + uea_leaves(INS_TO_USBDEV(sc)); +} + +/* syfs interface */ +static struct uea_softc *dev_to_uea(struct device *dev) +{ + struct usb_interface *intf; + struct usbatm_data *usbatm; + + intf = to_usb_interface(dev); + if (!intf) + return NULL; + + usbatm = usb_get_intfdata(intf); + if (!usbatm) + return NULL; + + return usbatm->driver_data; +} + +static ssize_t read_status(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int ret = -ENODEV; + struct uea_softc *sc; + + down(&uea_semaphore); + sc = dev_to_uea(dev); + if (!sc) + goto out; + ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state); +out: + up(&uea_semaphore); + return ret; +} + +static ssize_t reboot(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + int ret = -ENODEV; + struct uea_softc *sc; + + down(&uea_semaphore); + sc = dev_to_uea(dev); + if (!sc) + goto out; + sc->reset = 1; + ret = count; +out: + up(&uea_semaphore); + return ret; +} + +static DEVICE_ATTR(stat_status, S_IWUGO | S_IRUGO, read_status, reboot); + +static ssize_t read_human_status(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int ret = -ENODEV; + struct uea_softc *sc; + + down(&uea_semaphore); + sc = dev_to_uea(dev); + if (!sc) + goto out; + + switch (GET_STATUS(sc->stats.phy.state)) { + case 0: + ret = sprintf(buf, "Modem is booting\n"); + break; + case 1: + ret = sprintf(buf, "Modem is initializing\n"); + break; + case 2: + ret = sprintf(buf, "Modem is operational\n"); + break; + default: + ret = sprintf(buf, "Modem synchronization failed\n"); + break; + } +out: + up(&uea_semaphore); + return ret; +} + +static DEVICE_ATTR(stat_human_status, S_IWUGO | S_IRUGO, read_human_status, NULL); + +static ssize_t read_delin(struct device *dev, struct device_attribute *attr, + char *buf) +{ + int ret = -ENODEV; + struct uea_softc *sc; + + down(&uea_semaphore); + sc = dev_to_uea(dev); + if (!sc) + goto out; + + if (sc->stats.phy.flags & 0x0C00) + ret = sprintf(buf, "ERROR\n"); + else if (sc->stats.phy.flags & 0x0030) + ret = sprintf(buf, "LOSS\n"); + else + ret = sprintf(buf, "GOOD\n"); +out: + up(&uea_semaphore); + return ret; +} + +static DEVICE_ATTR(stat_delin, S_IWUGO | S_IRUGO, read_delin, NULL); + +#define UEA_ATTR(name, reset) \ + \ +static ssize_t read_##name(struct device *dev, \ + struct device_attribute *attr, char *buf) \ +{ \ + int ret = -ENODEV; \ + struct uea_softc *sc; \ + \ + down(&uea_semaphore); \ + sc = dev_to_uea(dev); \ + if (!sc) \ + goto out; \ + ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \ + if (reset) \ + sc->stats.phy.name = 0; \ +out: \ + up(&uea_semaphore); \ + return ret; \ +} \ + \ +static DEVICE_ATTR(stat_##name, S_IRUGO, read_##name, NULL) + +UEA_ATTR(mflags, 1); +UEA_ATTR(vidcpe, 0); +UEA_ATTR(usrate, 0); +UEA_ATTR(dsrate, 0); +UEA_ATTR(usattenuation, 0); +UEA_ATTR(dsattenuation, 0); +UEA_ATTR(usmargin, 0); +UEA_ATTR(dsmargin, 0); +UEA_ATTR(txflow, 0); +UEA_ATTR(rxflow, 0); +UEA_ATTR(uscorr, 0); +UEA_ATTR(dscorr, 0); +UEA_ATTR(usunc, 0); +UEA_ATTR(dsunc, 0); + +/* Retrieve the device End System Identifier (MAC) */ + +#define htoi(x) (isdigit(x) ? x-'0' : toupper(x)-'A'+10) +static int uea_getesi(struct uea_softc *sc, u_char * esi) +{ + unsigned char mac_str[2 * ETH_ALEN + 1]; + int i; + if (usb_string + (sc->usb_dev, sc->usb_dev->descriptor.iSerialNumber, mac_str, + sizeof(mac_str)) != 2 * ETH_ALEN) + return 1; + + for (i = 0; i < ETH_ALEN; i++) + esi[i] = htoi(mac_str[2 * i]) * 16 + htoi(mac_str[2 * i + 1]); + + return 0; +} + +/* ATM stuff */ +static int uea_atm_open(struct usbatm_data *usbatm, struct atm_dev *atm_dev) +{ + struct uea_softc *sc = usbatm->driver_data; + + return uea_getesi(sc, atm_dev->esi); +} + +static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf) +{ + struct uea_softc *sc = usbatm->driver_data; + + wait_event(sc->sync_q, IS_OPERATIONAL(sc)); + + return 0; + +} + +static int claim_interface(struct usb_device *usb_dev, + struct usbatm_data *usbatm, int ifnum) +{ + int ret; + struct usb_interface *intf = usb_ifnum_to_if(usb_dev, ifnum); + + if (!intf) { + uea_err(usb_dev, "interface %d not found\n", ifnum); + return -ENODEV; + } + + ret = usb_driver_claim_interface(&uea_driver, intf, usbatm); + if (ret != 0) + uea_err(usb_dev, "can't claim interface %d, error %d\n", ifnum, + ret); + return ret; +} + +static void create_fs_entries(struct uea_softc *sc, struct usb_interface *intf) +{ + /* sysfs interface */ + device_create_file(&intf->dev, &dev_attr_stat_status); + device_create_file(&intf->dev, &dev_attr_stat_mflags); + device_create_file(&intf->dev, &dev_attr_stat_human_status); + device_create_file(&intf->dev, &dev_attr_stat_delin); + device_create_file(&intf->dev, &dev_attr_stat_vidcpe); + device_create_file(&intf->dev, &dev_attr_stat_usrate); + device_create_file(&intf->dev, &dev_attr_stat_dsrate); + device_create_file(&intf->dev, &dev_attr_stat_usattenuation); + device_create_file(&intf->dev, &dev_attr_stat_dsattenuation); + device_create_file(&intf->dev, &dev_attr_stat_usmargin); + device_create_file(&intf->dev, &dev_attr_stat_dsmargin); + device_create_file(&intf->dev, &dev_attr_stat_txflow); + device_create_file(&intf->dev, &dev_attr_stat_rxflow); + device_create_file(&intf->dev, &dev_attr_stat_uscorr); + device_create_file(&intf->dev, &dev_attr_stat_dscorr); + device_create_file(&intf->dev, &dev_attr_stat_usunc); + device_create_file(&intf->dev, &dev_attr_stat_dsunc); +} + +static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, + const struct usb_device_id *id, int *heavy) +{ + struct usb_device *usb = interface_to_usbdev(intf); + struct uea_softc *sc; + int ret, ifnum = intf->altsetting->desc.bInterfaceNumber; + + uea_enters(usb); + + /* interface 0 is for firmware/monitoring */ + if (ifnum != UEA_INTR_IFACE_NO) + return -ENODEV; + + *heavy = sync_wait[modem_index]; + + /* interface 1 is for outbound traffic */ + ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO); + if (ret < 0) + return ret; + + /* ADI930 has only 2 interfaces and inbound traffic + * is on interface 1 + */ + if (UEA_CHIP_VERSION(id) != ADI930) { + /* interface 2 is for inbound traffic */ + ret = claim_interface(usb, usbatm, UEA_DS_IFACE_NO); + if (ret < 0) + return ret; + } + + sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL); + if (!sc) { + uea_err(INS_TO_USBDEV(sc), "uea_init: not enough memory !\n"); + return -ENOMEM; + } + + sc->usb_dev = usb; + usbatm->driver_data = sc; + sc->usbatm = usbatm; + sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0; + sc->driver_info = id->driver_info; + + ret = uea_boot(sc); + if (ret < 0) { + kfree(sc); + return ret; + } + + create_fs_entries(sc, intf); + return 0; +} + +static void destroy_fs_entries(struct uea_softc *sc, struct usb_interface *intf) +{ + /* sysfs interface */ + device_remove_file(&intf->dev, &dev_attr_stat_status); + device_remove_file(&intf->dev, &dev_attr_stat_mflags); + device_remove_file(&intf->dev, &dev_attr_stat_human_status); + device_remove_file(&intf->dev, &dev_attr_stat_delin); + device_remove_file(&intf->dev, &dev_attr_stat_vidcpe); + device_remove_file(&intf->dev, &dev_attr_stat_usrate); + device_remove_file(&intf->dev, &dev_attr_stat_dsrate); + device_remove_file(&intf->dev, &dev_attr_stat_usattenuation); + device_remove_file(&intf->dev, &dev_attr_stat_dsattenuation); + device_remove_file(&intf->dev, &dev_attr_stat_usmargin); + device_remove_file(&intf->dev, &dev_attr_stat_dsmargin); + device_remove_file(&intf->dev, &dev_attr_stat_txflow); + device_remove_file(&intf->dev, &dev_attr_stat_rxflow); + device_remove_file(&intf->dev, &dev_attr_stat_uscorr); + device_remove_file(&intf->dev, &dev_attr_stat_dscorr); + device_remove_file(&intf->dev, &dev_attr_stat_usunc); + device_remove_file(&intf->dev, &dev_attr_stat_dsunc); +} + +static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) +{ + struct uea_softc *sc = usbatm->driver_data; + + destroy_fs_entries(sc, intf); + uea_stop(sc); + kfree(sc); +} + +static struct usbatm_driver uea_usbatm_driver = { + .driver_name = "ueagle-atm", + .owner = THIS_MODULE, + .bind = uea_bind, + .atm_start = uea_atm_open, + .unbind = uea_unbind, + .heavy_init = uea_heavy, + .in = UEA_BULK_DATA_PIPE, + .out = UEA_BULK_DATA_PIPE, +}; + +static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + struct usb_device *usb = interface_to_usbdev(intf); + + uea_enters(usb); + uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s\n", + le16_to_cpu(usb->descriptor.idVendor), + le16_to_cpu(usb->descriptor.idProduct), + chip_name[UEA_CHIP_VERSION(id)]); + + usb_reset_device(usb); + + if (UEA_IS_PREFIRM(id)) + return uea_load_firmware(usb, UEA_CHIP_VERSION(id)); + + return usbatm_usb_probe(intf, id, &uea_usbatm_driver); +} + +static void uea_disconnect(struct usb_interface *intf) +{ + struct usb_device *usb = interface_to_usbdev(intf); + int ifnum = intf->altsetting->desc.bInterfaceNumber; + uea_enters(usb); + + /* ADI930 has 2 interfaces and eagle 3 interfaces. + * Pre-firmware device has one interface + */ + if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) { + down(&uea_semaphore); + usbatm_usb_disconnect(intf); + up(&uea_semaphore); + uea_info(usb, "ADSL device removed\n"); + } + + uea_leaves(usb); +} + +/* + * List of supported VID/PID + */ +static const struct usb_device_id uea_ids[] = { + {USB_DEVICE(ELSA_VID, ELSA_PID_PREFIRM), .driver_info = ADI930 | PREFIRM}, + {USB_DEVICE(ELSA_VID, ELSA_PID_PSTFIRM), .driver_info = ADI930 | PSTFIRM}, + {USB_DEVICE(EAGLE_VID, EAGLE_I_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM}, + {USB_DEVICE(EAGLE_VID, EAGLE_I_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM}, + {USB_DEVICE(EAGLE_VID, EAGLE_II_PID_PREFIRM), .driver_info = EAGLE_II | PREFIRM}, + {USB_DEVICE(EAGLE_VID, EAGLE_II_PID_PSTFIRM), .driver_info = EAGLE_II | PSTFIRM}, + {USB_DEVICE(EAGLE_VID, EAGLE_IIC_PID_PREFIRM), .driver_info = EAGLE_II | PREFIRM}, + {USB_DEVICE(EAGLE_VID, EAGLE_IIC_PID_PSTFIRM), .driver_info = EAGLE_II | PSTFIRM}, + {USB_DEVICE(EAGLE_VID, EAGLE_III_PID_PREFIRM), .driver_info = EAGLE_III | PREFIRM}, + {USB_DEVICE(EAGLE_VID, EAGLE_III_PID_PSTFIRM), .driver_info = EAGLE_III | PSTFIRM}, + {USB_DEVICE(USR_VID, MILLER_A_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM}, + {USB_DEVICE(USR_VID, MILLER_A_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM}, + {USB_DEVICE(USR_VID, MILLER_B_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM}, + {USB_DEVICE(USR_VID, MILLER_B_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM}, + {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PREFIRM),.driver_info = EAGLE_I | PREFIRM}, + {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PSTFIRM),.driver_info = EAGLE_I | PSTFIRM}, + {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PREFIRM),.driver_info = EAGLE_I | PREFIRM}, + {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PSTFIRM),.driver_info = EAGLE_I | PSTFIRM}, + {} +}; + +/* + * USB driver descriptor + */ +static struct usb_driver uea_driver = { + .owner = THIS_MODULE, + .name = "ueagle-atm", + .id_table = uea_ids, + .probe = uea_probe, + .disconnect = uea_disconnect, +}; + +MODULE_DEVICE_TABLE(usb, uea_ids); + +/** + * uea_init - Initialize the module. + * Register to USB subsystem + */ +static int __init uea_init(void) +{ + printk(KERN_INFO "[ueagle-atm] driver " EAGLEUSBVERSION " loaded\n"); + + usb_register(&uea_driver); + + return 0; +} + +module_init(uea_init); + +/** + * uea_exit - Destroy module + * Deregister with USB subsystem + */ +static void __exit uea_exit(void) +{ + /* + * This calls automatically the uea_disconnect method if necessary: + */ + usb_deregister(&uea_driver); + + printk(KERN_INFO "[ueagle-atm] driver unloaded\n"); +} + +module_exit(uea_exit); + +MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka"); +MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver"); +MODULE_LICENSE("Dual BSD/GPL"); -- cgit v1.1 From 8d7802ed3c617120863f84346638d1cf1c96137b Mon Sep 17 00:00:00 2001 From: matthieu castet Date: Tue, 8 Nov 2005 00:02:30 +0100 Subject: [PATCH] USB: Eagle and ADI 930 usb adsl modem driver fix More care on loading firmware, take into account fw->size can't be zero. Signed-off-by: Matthieu CASTET Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/ueagle-atm.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 3e2475c..be08e16 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -426,14 +426,14 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte pfw = fw_entry->data; size = fw_entry->size; + if (size < 4) + goto err_fw_corrupted; crc = FW_GET_LONG(pfw); pfw += 4; size -= 4; - if (crc32_be(0, pfw, size) != crc) { - uea_err(usb, "firmware is corrupted\n"); - goto err; - } + if (crc32_be(0, pfw, size) != crc) + goto err_fw_corrupted; /* * Start to upload formware : send reset @@ -446,9 +446,14 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte goto err; } - while (size > 0) { + while (size > 3) { u8 len = FW_GET_BYTE(pfw); u16 add = FW_GET_WORD(pfw + 1); + + size -= len + 3; + if (size < 0) + goto err_fw_corrupted; + ret = uea_send_modem_cmd(usb, add, len, pfw + 3); if (ret < 0) { uea_err(usb, "uploading firmware data failed " @@ -456,9 +461,11 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte goto err; } pfw += len + 3; - size -= len + 3; } + if (size != 0) + goto err_fw_corrupted; + /* * Tell the modem we finish : de-assert reset */ @@ -469,6 +476,11 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte else uea_info(usb, "firmware uploaded\n"); + uea_leaves(usb); + return; + +err_fw_corrupted: + uea_err(usb, "firmware is corrupted\n"); err: uea_leaves(usb); } @@ -522,10 +534,6 @@ static int check_dsp(u8 *dsp, unsigned int len) u32 pageoffset; unsigned int i, j, p, pp; - /* enough space for pagecount? */ - if (len < 1) - return 1; - pagecount = FW_GET_BYTE(dsp); p = 1; -- cgit v1.1 From 2c1c3c4cd5f796b1912c65aaf3bf48c0ddf11f5e Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 7 Nov 2005 15:24:46 -0800 Subject: [PATCH] USB: EHCI updates (4/4) driver model wakeup flags This teaches the EHCI driver to use the new driver model wakeup flags, replacing the similar ones in the HCD glue. It also adds a workaround for the current glitch whereby PCI init doesn't init the wakeup flags from the PCI PM capabilities. (EHCI controllers don't worry about legacy mode; the PCI PM capability would always do the job.) Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-hcd.c | 2 +- drivers/usb/host/ehci-hub.c | 4 ++-- drivers/usb/host/ehci-pci.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 29f52a4..dd87102 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -624,7 +624,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) } /* remote wakeup [4.3.1] */ - if ((status & STS_PCD) && hcd->remote_wakeup) { + if ((status & STS_PCD) && device_may_wakeup(&hcd->self.root_hub->dev)) { unsigned i = HCS_N_PORTS (ehci->hcs_params); /* resume root hub? */ diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 82caf33..69b0b9b 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c @@ -59,7 +59,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) if ((t1 & PORT_PE) && !(t1 & PORT_OWNER)) t2 |= PORT_SUSPEND; - if (hcd->remote_wakeup) + if (device_may_wakeup(&hcd->self.root_hub->dev)) t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; else t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E); @@ -517,7 +517,7 @@ static int ehci_hub_control ( if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) goto error; - if (hcd->remote_wakeup) + if (device_may_wakeup(&hcd->self.root_hub->dev)) temp |= PORT_WAKE_BITS; writel (temp | PORT_SUSPEND, &ehci->regs->port_status [wIndex]); diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 13f73a8..ac088bc 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -210,7 +210,16 @@ static int ehci_pci_setup(struct usb_hcd *hcd) /* Serial Bus Release Number is at PCI 0x60 offset */ pci_read_config_byte(pdev, 0x60, &ehci->sbrn); - /* REVISIT: per-port wake capability (PCI 0x62) currently unused */ + /* Workaround current PCI init glitch: wakeup bits aren't + * being set from PCI PM capability. + */ + if (!device_can_wakeup(&pdev->dev)) { + u16 port_wake; + + pci_read_config_word(pdev, 0x62, &port_wake); + if (port_wake & 0x0001) + device_init_wakeup(&pdev->dev, 1); + } retval = ehci_pci_reinit(ehci, pdev); done: -- cgit v1.1 From d97cc2f2e938547a47daef29bc10ab38600a3310 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Thu, 22 Dec 2005 17:05:18 -0800 Subject: [PATCH] USB: ehci fix driver model wakeup flags On some systems, EHCI seems to be getting IRQs too early during driver setup ... before the root hub is allocated, in particular, making trouble for any code chasing down root hub pointers! In this case, it seems to be safe to just ignore the root hub setting. Thanks to Rafael J. Wysocki for getting this properly tested. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index dd87102..b5b57e9 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -624,7 +624,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) } /* remote wakeup [4.3.1] */ - if ((status & STS_PCD) && device_may_wakeup(&hcd->self.root_hub->dev)) { + if (status & STS_PCD) { unsigned i = HCS_N_PORTS (ehci->hcs_params); /* resume root hub? */ -- cgit v1.1 From 0c8624f91d91df7cdeb9b2dace3269b8788c845f Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 7 Nov 2005 15:31:25 -0800 Subject: [PATCH] USB: wakeup flag updates (1/3) sl811-hcd This makes the SL811 HCD use the driver model wakeup flags for its controller, not the flags in the HCD glue (which will be removed). From: David Brownell Signed-off-by: Greg Kroah-Hartman drivers/usb/host/sl811-hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- drivers/usb/host/sl811-hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index a7722a6..5a28e611 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -1581,7 +1581,9 @@ sl811h_start(struct usb_hcd *hcd) hcd->state = HC_STATE_RUNNING; if (sl811->board) { - hcd->can_wakeup = sl811->board->can_wakeup; + if (!device_can_wakeup(hcd->self.controller)) + device_init_wakeup(hcd->self.controller, + sl811->board->can_wakeup); hcd->power_budget = sl811->board->power * 2; } @@ -1805,7 +1807,7 @@ sl811h_resume(struct platform_device *dev) * let's assume it'd only be powered to enable remote wakeup. */ if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND - || !hcd->can_wakeup) { + || !device_can_wakeup(&hcd->self.root_hub->dev)) { sl811->port1 = 0; port_power(sl811, 1); return 0; -- cgit v1.1 From baefbc39d8e23942cc10db92f5bc42e3476f6bc1 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 7 Nov 2005 15:34:41 -0800 Subject: [PATCH] USB: wakeup flag updates (2/3) uhci-hcd This makes UHCI stop using the HCD glue wakeup flags to report whether the controller can wake the system. The existing code was wrong anyway; having a PCI PM capability doesn't imply it reports PME# is supported. I skimmed Intel's ICH7 datasheet and that basically says the wakeup signaling gets routed only through ACPI registers. (On the other hand, many VIA chips provide the PCI PM capabilities...) I think that doing this correctly with UHCI is going to require the ACPI folk to associate the /proc/acpi/wakeup identifiers (and wakeup enable/disable flags) with the relevant /sys/devices/pci*/... devices. From: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/uhci-hcd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 79efaf7..5589d401 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -478,8 +478,6 @@ static int uhci_start(struct usb_hcd *hcd) struct dentry *dentry; hcd->uses_new_polling = 1; - if (pci_find_capability(to_pci_dev(uhci_dev(uhci)), PCI_CAP_ID_PM)) - hcd->can_wakeup = 1; /* Assume it supports PME# */ dentry = debugfs_create_file(hcd->self.bus_name, S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, uhci, -- cgit v1.1 From 704aa0b7a9744d5f2b5c1fa68b826fcca73a2104 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 7 Nov 2005 15:38:24 -0800 Subject: [PATCH] USB: wakeup flag updates (3/3) isp116x-hcd This makes the ISP116x HCD use the driver model wakeup flags for its controller, not the flags in the HCD glue (which will be removed). Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/isp116x-hcd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 342cfad..c95af11 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1378,7 +1378,8 @@ static int isp116x_start(struct usb_hcd *hcd) val = 0; if (board->remote_wakeup_enable) { - hcd->can_wakeup = 1; + if (!device_can_wakeup(hcd->self.controller)) + device_init_wakeup(hcd->self.controller, 1); val |= RH_HS_DRWE; } isp116x_write_reg32(isp116x, HCRHSTATUS, val); @@ -1428,7 +1429,7 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd) hcd->state = HC_STATE_QUIESCING; val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); val |= HCCONTROL_USB_SUSPEND; - if (hcd->remote_wakeup) + if (device_may_wakeup(&hcd->self.root_hub->dev)) val |= HCCONTROL_RWE; /* Wait for usb transfers to finish */ mdelay(2); -- cgit v1.1 From c9a50cc9318772e62d56f2a9172bdfda72bdacbe Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 7 Nov 2005 20:45:20 -0800 Subject: [PATCH] USB: hcd uses EXTRA_CFLAGS for -DDEBUG This modifies the HCD builds to automatically "-DDEBUG" if CONFIG_USB_DEBUG is selected. It's just a minor source code cleanup, guaranteeing consistency. Signed-off-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/Makefile | 4 ++++ drivers/usb/host/ehci-hcd.c | 7 ------- drivers/usb/host/ohci-hcd.c | 7 ------- drivers/usb/host/pci-quirks.c | 6 ------ drivers/usb/host/sl811-hcd.c | 7 ------- drivers/usb/host/sl811_cs.c | 5 +++-- drivers/usb/host/uhci-hcd.c | 5 ----- 7 files changed, 7 insertions(+), 34 deletions(-) diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 58321d3..e3020f4b 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -2,6 +2,10 @@ # Makefile for USB Host Controller Drivers # +ifeq ($(CONFIG_USB_DEBUG),y) + EXTRA_CFLAGS += -DDEBUG +endif + obj-$(CONFIG_PCI) += pci-quirks.o obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index b5b57e9..9dd3d14 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -17,13 +17,6 @@ */ #include - -#ifdef CONFIG_USB_DEBUG - #define DEBUG -#else - #undef DEBUG -#endif - #include #include #include diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index bf1d9ab..e3af3ac 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -75,13 +75,6 @@ */ #include - -#ifdef CONFIG_USB_DEBUG -# define DEBUG -#else -# undef DEBUG -#endif - #include #include #include diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index e46528c..3ef2c0c 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -9,12 +9,6 @@ */ #include -#ifdef CONFIG_USB_DEBUG -#define DEBUG -#else -#undef DEBUG -#endif - #include #include #include diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 5a28e611..3a9cd46 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -32,13 +32,6 @@ #undef PACKET_TRACE #include - -#ifdef CONFIG_USB_DEBUG -# define DEBUG -#else -# undef DEBUG -#endif - #include #include #include diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index e73faf8..5056b74 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -38,7 +38,7 @@ MODULE_LICENSE("GPL"); /* MACROS */ /*====================================================================*/ -#if defined(DEBUG) || defined(CONFIG_USB_DEBUG) || defined(PCMCIA_DEBUG) +#if defined(DEBUG) || defined(PCMCIA_DEBUG) static int pc_debug = 0; module_param(pc_debug, int, 0644); @@ -129,7 +129,8 @@ static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) resources[2].end = base_addr + 1; /* The driver core will probe for us. We know sl811-hcd has been - * initialized already because of the link order dependency. + * initialized already because of the link order dependency created + * by referencing "sl811h_driver". */ platform_dev.name = sl811h_driver.name; return platform_device_register(&platform_dev); diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 5589d401..1c0394c 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -23,11 +23,6 @@ */ #include -#ifdef CONFIG_USB_DEBUG -#define DEBUG -#else -#undef DEBUG -#endif #include #include #include -- cgit v1.1 From 87c4252a35310fdbb2aabb880a39b83f83cadf62 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 9 Nov 2005 16:59:56 -0500 Subject: [PATCH] USB: file-storage gadget: Add reference count for children This patch (as601) adds a proper reference count to the file-storage gadget's main data structure, to keep track of references held by child devices (LUNs in this case). Before this, the driver would wait for each child to be released before unbinding. While there's nothing really wrong with that (you can't create a hang by doing "rmmod g_file_storage Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/file_storage.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index ea09aaa..f6f0b2a 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -224,6 +224,7 @@ #include #include #include +#include #include #include #include @@ -631,6 +632,9 @@ struct fsg_dev { /* filesem protects: backing files in use */ struct rw_semaphore filesem; + /* reference counting: wait until all LUNs are released */ + struct kref ref; + struct usb_ep *ep0; // Handy copy of gadget->ep0 struct usb_request *ep0req; // For control responses volatile unsigned int ep0_req_tag; @@ -694,7 +698,6 @@ struct fsg_dev { unsigned int nluns; struct lun *luns; struct lun *curlun; - struct completion lun_released; }; typedef void (*fsg_routine_t)(struct fsg_dev *); @@ -3642,11 +3645,19 @@ static DEVICE_ATTR(file, 0444, show_file, NULL); /*-------------------------------------------------------------------------*/ +static void fsg_release(struct kref *ref) +{ + struct fsg_dev *fsg = container_of(ref, struct fsg_dev, ref); + + kfree(fsg->luns); + kfree(fsg); +} + static void lun_release(struct device *dev) { struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); - complete(&fsg->lun_released); + kref_put(&fsg->ref, fsg_release); } static void fsg_unbind(struct usb_gadget *gadget) @@ -3660,14 +3671,12 @@ static void fsg_unbind(struct usb_gadget *gadget) clear_bit(REGISTERED, &fsg->atomic_bitflags); /* Unregister the sysfs attribute files and the LUNs */ - init_completion(&fsg->lun_released); for (i = 0; i < fsg->nluns; ++i) { curlun = &fsg->luns[i]; if (curlun->registered) { device_remove_file(&curlun->dev, &dev_attr_ro); device_remove_file(&curlun->dev, &dev_attr_file); device_unregister(&curlun->dev); - wait_for_completion(&fsg->lun_released); curlun->registered = 0; } } @@ -3846,6 +3855,7 @@ static int __init fsg_bind(struct usb_gadget *gadget) curlun->dev.release = lun_release; device_create_file(&curlun->dev, &dev_attr_ro); device_create_file(&curlun->dev, &dev_attr_file); + kref_get(&fsg->ref); } if (file[i] && *file[i]) { @@ -4061,6 +4071,7 @@ static int __init fsg_alloc(void) return -ENOMEM; spin_lock_init(&fsg->lock); init_rwsem(&fsg->filesem); + kref_init(&fsg->ref); init_waitqueue_head(&fsg->thread_wqh); init_completion(&fsg->thread_notifier); @@ -4069,13 +4080,6 @@ static int __init fsg_alloc(void) } -static void fsg_free(struct fsg_dev *fsg) -{ - kfree(fsg->luns); - kfree(fsg); -} - - static int __init fsg_init(void) { int rc; @@ -4085,7 +4089,7 @@ static int __init fsg_init(void) return rc; fsg = the_fsg; if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0) - fsg_free(fsg); + kref_put(&fsg->ref, fsg_release); return rc; } module_init(fsg_init); @@ -4103,6 +4107,6 @@ static void __exit fsg_cleanup(void) wait_for_completion(&fsg->thread_notifier); close_all_backing_files(fsg); - fsg_free(fsg); + kref_put(&fsg->ref, fsg_release); } module_exit(fsg_cleanup); -- cgit v1.1 From 4a1728a28a193aa388900714bbb1f375e08a6d8e Mon Sep 17 00:00:00 2001 From: Petko Manolov Date: Tue, 15 Nov 2005 09:48:23 +0200 Subject: [PATCH] USB: usb-net: removes redundant return removes all redundant collecting of the return value from get/set_registers() and suchlike. can't remember who put all of those some time ago, but they doesn't make any sense to me. where needed only a few references remained; Signed-off-by: Petko Manolov Signed-off-by: Greg Kroah-Hartman --- drivers/usb/net/pegasus.c | 106 ++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 55 deletions(-) diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c index 683e3df..d8c7ada 100644 --- a/drivers/usb/net/pegasus.c +++ b/drivers/usb/net/pegasus.c @@ -45,7 +45,7 @@ /* * Version Information */ -#define DRIVER_VERSION "v0.6.12 (2005/01/13)" +#define DRIVER_VERSION "v0.6.13 (2005/11/13)" #define DRIVER_AUTHOR "Petko Manolov " #define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver" @@ -113,7 +113,7 @@ static void ctrl_callback(struct urb *urb, struct pt_regs *regs) break; default: if (netif_msg_drv(pegasus)) - dev_err(&pegasus->intf->dev, "%s, status %d\n", + dev_dbg(&pegasus->intf->dev, "%s, status %d\n", __FUNCTION__, urb->status); } pegasus->flags &= ~ETH_REGS_CHANGED; @@ -308,9 +308,9 @@ static int read_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 * regd) __le16 regdi; int ret; - ret = set_register(pegasus, PhyCtrl, 0); - ret = set_registers(pegasus, PhyAddr, sizeof (data), data); - ret = set_register(pegasus, PhyCtrl, (indx | PHY_READ)); + set_register(pegasus, PhyCtrl, 0); + set_registers(pegasus, PhyAddr, sizeof (data), data); + set_register(pegasus, PhyCtrl, (indx | PHY_READ)); for (i = 0; i < REG_TIMEOUT; i++) { ret = get_registers(pegasus, PhyCtrl, 1, data); if (data[0] & PHY_DONE) @@ -319,12 +319,12 @@ static int read_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 * regd) if (i < REG_TIMEOUT) { ret = get_registers(pegasus, PhyData, 2, ®di); *regd = le16_to_cpu(regdi); - return 1; + return ret; } if (netif_msg_drv(pegasus)) dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); - return 0; + return ret; } static int mdio_read(struct net_device *dev, int phy_id, int loc) @@ -344,20 +344,20 @@ static int write_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 regd) data[1] = (u8) regd; data[2] = (u8) (regd >> 8); - ret = set_register(pegasus, PhyCtrl, 0); - ret = set_registers(pegasus, PhyAddr, sizeof(data), data); - ret = set_register(pegasus, PhyCtrl, (indx | PHY_WRITE)); + set_register(pegasus, PhyCtrl, 0); + set_registers(pegasus, PhyAddr, sizeof(data), data); + set_register(pegasus, PhyCtrl, (indx | PHY_WRITE)); for (i = 0; i < REG_TIMEOUT; i++) { ret = get_registers(pegasus, PhyCtrl, 1, data); if (data[0] & PHY_DONE) break; } if (i < REG_TIMEOUT) - return 0; + return ret; if (netif_msg_drv(pegasus)) dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); - return 1; + return -ETIMEDOUT; } static void mdio_write(struct net_device *dev, int phy_id, int loc, int val) @@ -374,9 +374,9 @@ static int read_eprom_word(pegasus_t * pegasus, __u8 index, __u16 * retdata) __le16 retdatai; int ret; - ret = set_register(pegasus, EpromCtrl, 0); - ret = set_register(pegasus, EpromOffset, index); - ret = set_register(pegasus, EpromCtrl, EPROM_READ); + set_register(pegasus, EpromCtrl, 0); + set_register(pegasus, EpromOffset, index); + set_register(pegasus, EpromCtrl, EPROM_READ); for (i = 0; i < REG_TIMEOUT; i++) { ret = get_registers(pegasus, EpromCtrl, 1, &tmp); @@ -386,12 +386,12 @@ static int read_eprom_word(pegasus_t * pegasus, __u8 index, __u16 * retdata) if (i < REG_TIMEOUT) { ret = get_registers(pegasus, EpromData, 2, &retdatai); *retdata = le16_to_cpu(retdatai); - return 0; + return ret; } if (netif_msg_drv(pegasus)) dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); - return -1; + return -ETIMEDOUT; } #ifdef PEGASUS_WRITE_EEPROM @@ -400,8 +400,8 @@ static inline void enable_eprom_write(pegasus_t * pegasus) __u8 tmp; int ret; - ret = get_registers(pegasus, EthCtrl2, 1, &tmp); - ret = set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE); + get_registers(pegasus, EthCtrl2, 1, &tmp); + set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE); } static inline void disable_eprom_write(pegasus_t * pegasus) @@ -409,9 +409,9 @@ static inline void disable_eprom_write(pegasus_t * pegasus) __u8 tmp; int ret; - ret = get_registers(pegasus, EthCtrl2, 1, &tmp); - ret = set_register(pegasus, EpromCtrl, 0); - ret = set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE); + get_registers(pegasus, EthCtrl2, 1, &tmp); + set_register(pegasus, EpromCtrl, 0); + set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE); } static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data) @@ -420,11 +420,11 @@ static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data) __u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE }; int ret; - ret = set_registers(pegasus, EpromOffset, 4, d); + set_registers(pegasus, EpromOffset, 4, d); enable_eprom_write(pegasus); - ret = set_register(pegasus, EpromOffset, index); - ret = set_registers(pegasus, EpromData, 2, &data); - ret = set_register(pegasus, EpromCtrl, EPROM_WRITE); + set_register(pegasus, EpromOffset, index); + set_registers(pegasus, EpromData, 2, &data); + set_register(pegasus, EpromCtrl, EPROM_WRITE); for (i = 0; i < REG_TIMEOUT; i++) { ret = get_registers(pegasus, EpromCtrl, 1, &tmp); @@ -433,10 +433,10 @@ static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data) } disable_eprom_write(pegasus); if (i < REG_TIMEOUT) - return 0; + return ret; if (netif_msg_drv(pegasus)) dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); - return -1; + return -ETIMEDOUT; } #endif /* PEGASUS_WRITE_EEPROM */ @@ -454,10 +454,9 @@ static inline void get_node_id(pegasus_t * pegasus, __u8 * id) static void set_ethernet_addr(pegasus_t * pegasus) { __u8 node_id[6]; - int ret; get_node_id(pegasus, node_id); - ret = set_registers(pegasus, EthID, sizeof (node_id), node_id); + set_registers(pegasus, EthID, sizeof (node_id), node_id); memcpy(pegasus->net->dev_addr, node_id, sizeof (node_id)); } @@ -465,30 +464,29 @@ static inline int reset_mac(pegasus_t * pegasus) { __u8 data = 0x8; int i; - int ret; - ret = set_register(pegasus, EthCtrl1, data); + set_register(pegasus, EthCtrl1, data); for (i = 0; i < REG_TIMEOUT; i++) { - ret = get_registers(pegasus, EthCtrl1, 1, &data); + get_registers(pegasus, EthCtrl1, 1, &data); if (~data & 0x08) { if (loopback & 1) break; if (mii_mode && (pegasus->features & HAS_HOME_PNA)) - ret = set_register(pegasus, Gpio1, 0x34); + set_register(pegasus, Gpio1, 0x34); else - ret = set_register(pegasus, Gpio1, 0x26); - ret = set_register(pegasus, Gpio0, pegasus->features); - ret = set_register(pegasus, Gpio0, DEFAULT_GPIO_SET); + set_register(pegasus, Gpio1, 0x26); + set_register(pegasus, Gpio0, pegasus->features); + set_register(pegasus, Gpio0, DEFAULT_GPIO_SET); break; } } if (i == REG_TIMEOUT) - return 1; + return -ETIMEDOUT; if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS || usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) { - ret = set_register(pegasus, Gpio0, 0x24); - ret = set_register(pegasus, Gpio0, 0x26); + set_register(pegasus, Gpio0, 0x24); + set_register(pegasus, Gpio0, 0x26); } if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_ELCON) { __u16 auxmode; @@ -527,7 +525,7 @@ static int enable_net_traffic(struct net_device *dev, struct usb_device *usb) write_mii_word(pegasus, 0, 0x1b, auxmode | 4); } - return 0; + return ret; } static void fill_skb_pool(pegasus_t * pegasus) @@ -881,9 +879,8 @@ static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev) static inline void disable_net_traffic(pegasus_t * pegasus) { int tmp = 0; - int ret; - ret = set_registers(pegasus, EthCtrl0, 2, &tmp); + set_registers(pegasus, EthCtrl0, 2, &tmp); } static inline void get_interrupt_interval(pegasus_t * pegasus) @@ -1206,18 +1203,17 @@ static __u8 mii_phy_probe(pegasus_t * pegasus) static inline void setup_pegasus_II(pegasus_t * pegasus) { __u8 data = 0xa5; - int ret; - ret = set_register(pegasus, Reg1d, 0); - ret = set_register(pegasus, Reg7b, 1); + set_register(pegasus, Reg1d, 0); + set_register(pegasus, Reg7b, 1); mdelay(100); if ((pegasus->features & HAS_HOME_PNA) && mii_mode) - ret = set_register(pegasus, Reg7b, 0); + set_register(pegasus, Reg7b, 0); else - ret = set_register(pegasus, Reg7b, 2); + set_register(pegasus, Reg7b, 2); - ret = set_register(pegasus, 0x83, data); - ret = get_registers(pegasus, 0x83, 1, &data); + set_register(pegasus, 0x83, data); + get_registers(pegasus, 0x83, 1, &data); if (data == 0xa5) { pegasus->chip = 0x8513; @@ -1225,14 +1221,14 @@ static inline void setup_pegasus_II(pegasus_t * pegasus) pegasus->chip = 0; } - ret = set_register(pegasus, 0x80, 0xc0); - ret = set_register(pegasus, 0x83, 0xff); - ret = set_register(pegasus, 0x84, 0x01); + set_register(pegasus, 0x80, 0xc0); + set_register(pegasus, 0x83, 0xff); + set_register(pegasus, 0x84, 0x01); if (pegasus->features & HAS_HOME_PNA && mii_mode) - ret = set_register(pegasus, Reg81, 6); + set_register(pegasus, Reg81, 6); else - ret = set_register(pegasus, Reg81, 2); + set_register(pegasus, Reg81, 2); } -- cgit v1.1 From a4f81a61ebba5953cba1e76f66423a7eca4a5ee4 Mon Sep 17 00:00:00 2001 From: "A.YOSHIYAMA" Date: Tue, 15 Nov 2005 09:55:18 +0200 Subject: [PATCH] USB: usb-net: new device ID passed through module parameter adds new module parameter "devid" that points to a string with format "device_name:vendor_id:device_id:flags". if provided at module load time, this string is being parsed and a new entry is created in usb_dev_id[] and pegasus_ids[] so the new device can later be recognized by the probe routine. this might be helpful for someone who don't know/wish to build new module/kernel, but want to use his new usb-to-eth device that is not yet listed in pegasus.h Signed-off-by: Petko Manolov Signed-off-by: Greg Kroah-Hartman --- drivers/usb/net/pegasus.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c index d8c7ada..156a2f1 100644 --- a/drivers/usb/net/pegasus.c +++ b/drivers/usb/net/pegasus.c @@ -57,12 +57,14 @@ static const char driver_name[] = "pegasus"; static int loopback = 0; static int mii_mode = 0; +static char *devid=NULL; static struct usb_eth_dev usb_dev_id[] = { #define PEGASUS_DEV(pn, vid, pid, flags) \ {.name = pn, .vendor = vid, .device = pid, .private = flags}, #include "pegasus.h" #undef PEGASUS_DEV + {NULL, 0, 0, 0}, {NULL, 0, 0, 0} }; @@ -71,6 +73,7 @@ static struct usb_device_id pegasus_ids[] = { {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid}, #include "pegasus.h" #undef PEGASUS_DEV + {}, {} }; @@ -79,8 +82,10 @@ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); module_param(loopback, bool, 0); module_param(mii_mode, bool, 0); +module_param(devid, charp, 0); MODULE_PARM_DESC(loopback, "Enable MAC loopback mode (bit 0)"); MODULE_PARM_DESC(mii_mode, "Enable HomePNA mode (bit 0),default=MII mode = 0"); +MODULE_PARM_DESC(devid, "The format is: 'DEV_name:VendorID:DeviceID:Flags'"); /* use ethtool to change the level for any given device */ static int msg_level = -1; @@ -1410,9 +1415,42 @@ static struct usb_driver pegasus_driver = { .resume = pegasus_resume, }; +static void parse_id(char *id) +{ + unsigned int vendor_id=0, device_id=0, flags=0, i=0; + char *token, *name=NULL; + + if ((token = strsep(&id, ":")) != NULL) + name = token; + /* name now points to a null terminated string*/ + if ((token = strsep(&id, ":")) != NULL) + vendor_id = simple_strtoul(token, NULL, 16); + if ((token = strsep(&id, ":")) != NULL) + device_id = simple_strtoul(token, NULL, 16); + flags = simple_strtoul(id, NULL, 16); + pr_info("%s: new device %s, vendor ID 0x%04x, device ID 0x%04x, flags: 0x%x\n", + driver_name, name, vendor_id, device_id, flags); + + if (vendor_id > 0x10000 || vendor_id == 0) + return; + if (device_id > 0x10000 || device_id == 0) + return; + + for (i=0; usb_dev_id[i].name; i++); + usb_dev_id[i].name = name; + usb_dev_id[i].vendor = vendor_id; + usb_dev_id[i].device = device_id; + usb_dev_id[i].private = flags; + pegasus_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE; + pegasus_ids[i].idVendor = vendor_id; + pegasus_ids[i].idProduct = device_id; +} + static int __init pegasus_init(void) { pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION); + if (devid) + parse_id(devid); pegasus_workqueue = create_singlethread_workqueue("pegasus"); if (!pegasus_workqueue) return -ENOMEM; -- cgit v1.1 From 8364d6b0be2dbbf162c6aea79615b5025a0d67c2 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Mon, 14 Nov 2005 12:16:30 -0500 Subject: [PATCH] USB: dummy_hcd: rename variables The recent platform_device update has reintroduced into dummy_hcd.c the dreaded dev->dev syndrome. This harkens back to when an earlier version of that driver included the unforgettable line: dev->dev.dev.driver_data = dev; This patch (as602) renames the platform_device variables to "pdev", in the hope of reducing confusion. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/dummy_hcd.c | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index c655d46..4932b07 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -896,7 +896,7 @@ dummy_gadget_release (struct device *dev) #endif } -static int dummy_udc_probe (struct platform_device *dev) +static int dummy_udc_probe (struct platform_device *pdev) { struct dummy *dum = the_controller; int rc; @@ -909,7 +909,7 @@ static int dummy_udc_probe (struct platform_device *dev) dum->gadget.is_otg = (dummy_to_hcd(dum)->self.otg_port != 0); strcpy (dum->gadget.dev.bus_id, "gadget"); - dum->gadget.dev.parent = &dev->dev; + dum->gadget.dev.parent = &pdev->dev; dum->gadget.dev.release = dummy_gadget_release; rc = device_register (&dum->gadget.dev); if (rc < 0) @@ -919,47 +919,47 @@ static int dummy_udc_probe (struct platform_device *dev) usb_bus_get (&dummy_to_hcd (dum)->self); #endif - platform_set_drvdata (dev, dum); + platform_set_drvdata (pdev, dum); device_create_file (&dum->gadget.dev, &dev_attr_function); return rc; } -static int dummy_udc_remove (struct platform_device *dev) +static int dummy_udc_remove (struct platform_device *pdev) { - struct dummy *dum = platform_get_drvdata (dev); + struct dummy *dum = platform_get_drvdata (pdev); - platform_set_drvdata (dev, NULL); + platform_set_drvdata (pdev, NULL); device_remove_file (&dum->gadget.dev, &dev_attr_function); device_unregister (&dum->gadget.dev); return 0; } -static int dummy_udc_suspend (struct platform_device *dev, pm_message_t state) +static int dummy_udc_suspend (struct platform_device *pdev, pm_message_t state) { - struct dummy *dum = platform_get_drvdata(dev); + struct dummy *dum = platform_get_drvdata(pdev); - dev_dbg (&dev->dev, "%s\n", __FUNCTION__); + dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); spin_lock_irq (&dum->lock); dum->udc_suspended = 1; set_link_state (dum); spin_unlock_irq (&dum->lock); - dev->dev.power.power_state = state; + pdev->dev.power.power_state = state; usb_hcd_poll_rh_status (dummy_to_hcd (dum)); return 0; } -static int dummy_udc_resume (struct platform_device *dev) +static int dummy_udc_resume (struct platform_device *pdev) { - struct dummy *dum = platform_get_drvdata(dev); + struct dummy *dum = platform_get_drvdata(pdev); - dev_dbg (&dev->dev, "%s\n", __FUNCTION__); + dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); spin_lock_irq (&dum->lock); dum->udc_suspended = 0; set_link_state (dum); spin_unlock_irq (&dum->lock); - dev->dev.power.power_state = PMSG_ON; + pdev->dev.power.power_state = PMSG_ON; usb_hcd_poll_rh_status (dummy_to_hcd (dum)); return 0; } @@ -1899,14 +1899,14 @@ static const struct hc_driver dummy_hcd = { .bus_resume = dummy_bus_resume, }; -static int dummy_hcd_probe (struct platform_device *dev) +static int dummy_hcd_probe(struct platform_device *pdev) { struct usb_hcd *hcd; int retval; - dev_info(&dev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); + dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); - hcd = usb_create_hcd (&dummy_hcd, &dev->dev, dev->dev.bus_id); + hcd = usb_create_hcd(&dummy_hcd, &pdev->dev, pdev->dev.bus_id); if (!hcd) return -ENOMEM; the_controller = hcd_to_dummy (hcd); @@ -1919,34 +1919,34 @@ static int dummy_hcd_probe (struct platform_device *dev) return retval; } -static int dummy_hcd_remove (struct platform_device *dev) +static int dummy_hcd_remove (struct platform_device *pdev) { struct usb_hcd *hcd; - hcd = platform_get_drvdata (dev); + hcd = platform_get_drvdata (pdev); usb_remove_hcd (hcd); usb_put_hcd (hcd); the_controller = NULL; return 0; } -static int dummy_hcd_suspend (struct platform_device *dev, pm_message_t state) +static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state) { struct usb_hcd *hcd; - dev_dbg (&dev->dev, "%s\n", __FUNCTION__); - hcd = platform_get_drvdata (dev); + dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); + hcd = platform_get_drvdata (pdev); hcd->state = HC_STATE_SUSPENDED; return 0; } -static int dummy_hcd_resume (struct platform_device *dev) +static int dummy_hcd_resume (struct platform_device *pdev) { struct usb_hcd *hcd; - dev_dbg (&dev->dev, "%s\n", __FUNCTION__); - hcd = platform_get_drvdata (dev); + dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); + hcd = platform_get_drvdata (pdev); hcd->state = HC_STATE_RUNNING; usb_hcd_poll_rh_status (hcd); -- cgit v1.1 From 1c50c317e2e7f15427149cbc216a63366468710e Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Mon, 14 Nov 2005 11:45:38 -0500 Subject: [PATCH] USB: central handling for host controllers that were reset during suspend/resume This patch (as515b) adds a routine to usbcore to simplify handling of host controllers that lost power or were reset during suspend/resume. The new core routine marks all the child devices of the root hub as NOTATTACHED and tells khubd to disconnect the device structures as soon as possible. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd.h | 1 + drivers/usb/core/hub.c | 33 +++++++++++++++++++++++++++++++++ drivers/usb/host/ehci-pci.c | 9 +-------- drivers/usb/host/ohci-hcd.c | 7 +------ drivers/usb/host/sl811-hcd.c | 1 + drivers/usb/host/uhci-hcd.c | 6 +++++- 6 files changed, 42 insertions(+), 15 deletions(-) diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h index c8a1b35..591b5aa 100644 --- a/drivers/usb/core/hcd.h +++ b/drivers/usb/core/hcd.h @@ -380,6 +380,7 @@ extern int usb_find_interface_driver (struct usb_device *dev, #ifdef CONFIG_PM extern void usb_hcd_suspend_root_hub (struct usb_hcd *hcd); extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); +extern void usb_root_hub_lost_power (struct usb_device *rhdev); extern int hcd_bus_suspend (struct usb_bus *bus); extern int hcd_bus_resume (struct usb_bus *bus); #else diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index f78bd12..5faf7ed 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1039,6 +1039,39 @@ void usb_set_device_state(struct usb_device *udev, EXPORT_SYMBOL(usb_set_device_state); +#ifdef CONFIG_PM + +/** + * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power + * @rhdev: struct usb_device for the root hub + * + * The USB host controller driver calls this function when its root hub + * is resumed and Vbus power has been interrupted or the controller + * has been reset. The routine marks all the children of the root hub + * as NOTATTACHED and marks logical connect-change events on their ports. + */ +void usb_root_hub_lost_power(struct usb_device *rhdev) +{ + struct usb_hub *hub; + int port1; + unsigned long flags; + + dev_warn(&rhdev->dev, "root hub lost power or was reset\n"); + spin_lock_irqsave(&device_state_lock, flags); + hub = hdev_to_hub(rhdev); + for (port1 = 1; port1 <= rhdev->maxchild; ++port1) { + if (rhdev->children[port1 - 1]) { + recursively_mark_NOTATTACHED( + rhdev->children[port1 - 1]); + set_bit(port1, hub->change_bits); + } + } + spin_unlock_irqrestore(&device_state_lock, flags); +} +EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); + +#endif + static void choose_address(struct usb_device *udev) { int devnum; diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index ac088bc..08ca0f8 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c @@ -278,7 +278,6 @@ static int ehci_pci_resume(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); unsigned port; - struct usb_device *root = hcd->self.root_hub; struct pci_dev *pdev = to_pci_dev(hcd->self.controller); int retval = -EINVAL; @@ -312,13 +311,7 @@ static int ehci_pci_resume(struct usb_hcd *hcd) restart: ehci_dbg(ehci, "lost power, restarting\n"); - for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { - port--; - if (!root->children [port]) - continue; - usb_set_device_state(root->children[port], - USB_STATE_NOTATTACHED); - } + usb_root_hub_lost_power(hcd->self.root_hub); /* Else reset, to cope with power loss or flush-to-storage * style "resume" having let BIOS kick in during reboot. diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index e3af3ac..a4b1240 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -795,7 +795,6 @@ static int ohci_restart (struct ohci_hcd *ohci) int temp; int i; struct urb_priv *priv; - struct usb_device *root = ohci_to_hcd(ohci)->self.root_hub; /* mark any devices gone, so they do nothing till khubd disconnects. * recycle any "live" eds/tds (and urbs) right away. @@ -804,11 +803,7 @@ static int ohci_restart (struct ohci_hcd *ohci) */ spin_lock_irq(&ohci->lock); disable (ohci); - for (i = 0; i < root->maxchild; i++) { - if (root->children [i]) - usb_set_device_state (root->children[i], - USB_STATE_NOTATTACHED); - } + usb_root_hub_lost_power(ohci_to_hcd(ohci)->self.root_hub); if (!list_empty (&ohci->pending)) ohci_dbg(ohci, "abort schedule...\n"); list_for_each_entry (priv, &ohci->pending, pending) { diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 3a9cd46..517360b 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -1803,6 +1803,7 @@ sl811h_resume(struct platform_device *dev) || !device_can_wakeup(&hcd->self.root_hub->dev)) { sl811->port1 = 0; port_power(sl811, 1); + usb_root_hub_lost_power(hcd->self.root_hub); return 0; } diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 1c0394c..071fab6 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -748,8 +748,12 @@ static int uhci_resume(struct usb_hcd *hcd) check_and_reset_hc(uhci); configure_hc(uhci); - if (uhci->rh_state == UHCI_RH_RESET) + if (uhci->rh_state == UHCI_RH_RESET) { + + /* The controller had to be reset */ + usb_root_hub_lost_power(hcd->self.root_hub); suspend_rh(uhci, UHCI_RH_SUSPENDED); + } spin_unlock_irq(&uhci->lock); -- cgit v1.1 From a00828e9ac62caed7b830d631914d7748817ccd1 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sat, 22 Oct 2005 20:15:09 -0700 Subject: [PATCH] USB: drivers/usb/storage/libusual This patch adds a shim driver libusual, which routes devices between usb-storage and ub according to the common table, based on unusual_devs.h. The help and example syntax is in Kconfig. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/block/Kconfig | 3 +- drivers/block/ub.c | 23 ++-- drivers/usb/Makefile | 1 + drivers/usb/storage/Kconfig | 14 ++ drivers/usb/storage/Makefile | 4 + drivers/usb/storage/libusual.c | 266 +++++++++++++++++++++++++++++++++++++ drivers/usb/storage/protocol.h | 14 -- drivers/usb/storage/transport.h | 31 ----- drivers/usb/storage/unusual_devs.h | 24 ++++ drivers/usb/storage/usb.c | 119 ++++++----------- drivers/usb/storage/usb.h | 31 +---- include/linux/usb_usual.h | 123 +++++++++++++++++ 12 files changed, 486 insertions(+), 167 deletions(-) create mode 100644 drivers/usb/storage/libusual.c create mode 100644 include/linux/usb_usual.h diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 7b1cd93..c4b9d2a 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -358,7 +358,8 @@ config BLK_DEV_UB This driver supports certain USB attached storage devices such as flash keys. - Warning: Enabling this cripples the usb-storage driver. + If you enable this driver, it is recommended to avoid conflicts + with usb-storage by enabling USB_LIBUSUAL. If unsure, say N. diff --git a/drivers/block/ub.c b/drivers/block/ub.c index bfb23d5..06d741d 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -107,16 +108,6 @@ */ /* - * Definitions which have to be scattered once we understand the layout better. - */ - -/* Transport (despite PR in the name) */ -#define US_PR_BULK 0x50 /* bulk only */ - -/* Protocol */ -#define US_SC_SCSI 0x06 /* Transparent */ - -/* * This many LUNs per USB device. * Every one of them takes a host, see UB_MAX_HOSTS. */ @@ -422,13 +413,18 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum); /* */ +#ifdef CONFIG_USB_LIBUSUAL + +#define ub_usb_ids storage_usb_ids +#else + static struct usb_device_id ub_usb_ids[] = { - // { USB_DEVICE_VER(0x0781, 0x0002, 0x0009, 0x0009) }, /* SDDR-31 */ { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) }, { } }; MODULE_DEVICE_TABLE(usb, ub_usb_ids); +#endif /* CONFIG_USB_LIBUSUAL */ /* * Find me a way to identify "next free minor" for add_disk(), @@ -2172,6 +2168,9 @@ static int ub_probe(struct usb_interface *intf, int rc; int i; + if (usb_usual_check_type(dev_id, USB_US_TYPE_UB)) + return -ENXIO; + rc = -ENOMEM; if ((sc = kmalloc(sizeof(struct ub_dev), GFP_KERNEL)) == NULL) goto err_core; @@ -2479,6 +2478,7 @@ static int __init ub_init(void) if ((rc = usb_register(&ub_driver)) != 0) goto err_register; + usb_usual_set_present(USB_US_TYPE_UB); return 0; err_register: @@ -2494,6 +2494,7 @@ static void __exit ub_exit(void) devfs_remove(DEVFS_NAME); unregister_blkdev(UB_MAJOR, DRV_NAME); + usb_usual_clear_present(USB_US_TYPE_UB); } module_init(ub_init); diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile index a50c2bc..3639c3f 100644 --- a/drivers/usb/Makefile +++ b/drivers/usb/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_USB_MIDI) += class/ obj-$(CONFIG_USB_PRINTER) += class/ obj-$(CONFIG_USB_STORAGE) += storage/ +obj-$(CONFIG_USB) += storage/ obj-$(CONFIG_USB_AIPTEK) += input/ obj-$(CONFIG_USB_ATI_REMOTE) += input/ diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index c41d64d..bdfcb95 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig @@ -124,3 +124,17 @@ config USB_STORAGE_ONETOUCH hard drive's as an input device. An action can be associated with this input in any keybinding software. (e.g. gnome's keyboard short- cuts) + +config USB_LIBUSUAL + bool "The shared table of common (or usual) storage devices" + depends on USB + help + This module contains a table of common (or usual) devices + for usb-storage and ub drivers, and allows to switch binding + of these devices without rebuilding modules. + + Typical syntax of /etc/modprobe.conf is: + + options libusual bias="ub" + + If unsure, say N. diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index 44ab8f9..2d416e9 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile @@ -22,3 +22,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ initializers.o $(usb-storage-obj-y) + +ifneq ($(CONFIG_USB_LIBUSUAL),) + obj-$(CONFIG_USB) += libusual.o +endif diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c new file mode 100644 index 0000000..61f73d8 --- /dev/null +++ b/drivers/usb/storage/libusual.c @@ -0,0 +1,266 @@ +/* + * libusual + * + * The libusual contains the table of devices common for ub and usb-storage. + */ +#include +#include +#include +#include +#include + +/* + */ +#define USU_MOD_FL_THREAD 1 /* Thread is running */ +#define USU_MOD_FL_PRESENT 2 /* The module is loaded */ + +struct mod_status { + unsigned long fls; +}; + +static struct mod_status stat[3]; +static DEFINE_SPINLOCK(usu_lock); + +/* + */ +#define USB_US_DEFAULT_BIAS USB_US_TYPE_STOR + +#define BIAS_NAME_SIZE (sizeof("usb-storage")) +static char bias[BIAS_NAME_SIZE]; +static int usb_usual_bias; +static const char *bias_names[3] = { "none", "usb-storage", "ub" }; + +static DECLARE_MUTEX_LOCKED(usu_init_notify); +static DECLARE_COMPLETION(usu_end_notify); +static atomic_t total_threads = ATOMIC_INIT(0); + +static int usu_probe_thread(void *arg); +static int parse_bias(const char *bias_s); + +/* + * The table. + */ +#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ + vendorName, productName,useProtocol, useTransport, \ + initFunction, flags) \ +{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \ + .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } + +#define USUAL_DEV(useProto, useTrans, useType) \ +{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \ + .driver_info = ((useType)<<24) } + +struct usb_device_id storage_usb_ids [] = { +# include "unusual_devs.h" + { } /* Terminating entry */ +}; + +#undef USUAL_DEV +#undef UNUSUAL_DEV + +MODULE_DEVICE_TABLE(usb, storage_usb_ids); +EXPORT_SYMBOL_GPL(storage_usb_ids); + +/* + * @type: the module type as an integer + */ +void usb_usual_set_present(int type) +{ + struct mod_status *st; + unsigned long flags; + + if (type <= 0 || type >= 3) + return; + st = &stat[type]; + spin_lock_irqsave(&usu_lock, flags); + st->fls |= USU_MOD_FL_PRESENT; + spin_unlock_irqrestore(&usu_lock, flags); +} +EXPORT_SYMBOL_GPL(usb_usual_set_present); + +void usb_usual_clear_present(int type) +{ + struct mod_status *st; + unsigned long flags; + + if (type <= 0 || type >= 3) + return; + st = &stat[type]; + spin_lock_irqsave(&usu_lock, flags); + st->fls &= ~USU_MOD_FL_PRESENT; + spin_unlock_irqrestore(&usu_lock, flags); +} +EXPORT_SYMBOL_GPL(usb_usual_clear_present); + +/* + * Match the calling driver type against the table. + * Returns: 0 if the device matches. + */ +int usb_usual_check_type(const struct usb_device_id *id, int caller_type) +{ + int id_type = USB_US_TYPE(id->driver_info); + + if (caller_type <= 0 || caller_type >= 3) + return -EINVAL; + + /* Drivers grab fixed assignment devices */ + if (id_type == caller_type) + return 0; + /* Drivers grab devices biased to them */ + if (id_type == USB_US_TYPE_NONE && caller_type == usb_usual_bias) + return 0; + return -ENODEV; +} +EXPORT_SYMBOL_GPL(usb_usual_check_type); + +/* + */ +static int usu_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + int type; + int rc; + unsigned long flags; + + type = USB_US_TYPE(id->driver_info); + if (type == 0) + type = usb_usual_bias; + + spin_lock_irqsave(&usu_lock, flags); + if ((stat[type].fls & (USU_MOD_FL_THREAD|USU_MOD_FL_PRESENT)) != 0) { + spin_unlock_irqrestore(&usu_lock, flags); + return -ENXIO; + } + stat[type].fls |= USU_MOD_FL_THREAD; + spin_unlock_irqrestore(&usu_lock, flags); + + rc = kernel_thread(usu_probe_thread, (void*)type, CLONE_VM); + if (rc < 0) { + printk(KERN_WARNING "libusual: " + "Unable to start the thread for %s: %d\n", + bias_names[type], rc); + spin_lock_irqsave(&usu_lock, flags); + stat[type].fls &= ~USU_MOD_FL_THREAD; + spin_unlock_irqrestore(&usu_lock, flags); + return rc; /* Not being -ENXIO causes a message printed */ + } + atomic_inc(&total_threads); + + return -ENXIO; +} + +static void usu_disconnect(struct usb_interface *intf) +{ + ; /* We should not be here. */ +} + +static struct usb_driver usu_driver = { + .owner = THIS_MODULE, + .name = "libusual", + .probe = usu_probe, + .disconnect = usu_disconnect, + .id_table = storage_usb_ids, +}; + +/* + * A whole new thread for a purpose of request_module seems quite stupid. + * The request_module forks once inside again. However, if we attempt + * to load a storage module from our own modprobe thread, that module + * references our symbols, which cannot be resolved until our module is + * initialized. I wish there was a way to wait for the end of initialization. + * The module notifier reports MODULE_STATE_COMING only. + * So, we wait until module->init ends as the next best thing. + */ +static int usu_probe_thread(void *arg) +{ + int type = (unsigned long) arg; + struct mod_status *st = &stat[type]; + int rc; + unsigned long flags; + + daemonize("libusual_%d", type); /* "usb-storage" is kinda too long */ + + /* A completion does not work here because it's counted. */ + down(&usu_init_notify); + up(&usu_init_notify); + + rc = request_module(bias_names[type]); + spin_lock_irqsave(&usu_lock, flags); + if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) { + /* + * This should not happen, but let us keep tabs on it. + */ + printk(KERN_NOTICE "libusual: " + "modprobe for %s succeeded, but module is not present\n", + bias_names[type]); + } + st->fls &= ~USU_MOD_FL_THREAD; + spin_unlock_irqrestore(&usu_lock, flags); + + complete_and_exit(&usu_end_notify, 0); +} + +/* + */ +static int __init usb_usual_init(void) +{ + int rc; + + bias[BIAS_NAME_SIZE-1] = 0; + usb_usual_bias = parse_bias(bias); + + rc = usb_register(&usu_driver); + up(&usu_init_notify); + return rc; +} + +static void __exit usb_usual_exit(void) +{ + /* + * We do not check for any drivers present, because + * they keep us pinned with symbol references. + */ + + usb_deregister(&usu_driver); + + while (atomic_read(&total_threads) > 0) { + wait_for_completion(&usu_end_notify); + atomic_dec(&total_threads); + } +} + +/* + * Validate and accept the bias parameter. + * Maybe make an sysfs method later. XXX + */ +static int parse_bias(const char *bias_s) +{ + int i; + int bias_n = 0; + + if (bias_s[0] == 0 || bias_s[0] == ' ') { + bias_n = USB_US_DEFAULT_BIAS; + } else { + for (i = 1; i < 3; i++) { + if (strcmp(bias_s, bias_names[i]) == 0) { + bias_n = i; + break; + } + } + if (bias_n == 0) { + bias_n = USB_US_DEFAULT_BIAS; + printk(KERN_INFO + "libusual: unknown bias \"%s\", using \"%s\"\n", + bias_s, bias_names[bias_n]); + } + } + return bias_n; +} + +module_init(usb_usual_init); +module_exit(usb_usual_exit); + +module_param_string(bias, bias, BIAS_NAME_SIZE, S_IRUGO|S_IWUSR); +MODULE_PARM_DESC(bias, "Bias to usb-storage or ub"); + +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h index 02bff01..845bed4 100644 --- a/drivers/usb/storage/protocol.h +++ b/drivers/usb/storage/protocol.h @@ -41,20 +41,6 @@ #ifndef _PROTOCOL_H_ #define _PROTOCOL_H_ -/* Sub Classes */ - -#define US_SC_RBC 0x01 /* Typically, flash devices */ -#define US_SC_8020 0x02 /* CD-ROM */ -#define US_SC_QIC 0x03 /* QIC-157 Tapes */ -#define US_SC_UFI 0x04 /* Floppy */ -#define US_SC_8070 0x05 /* Removable media */ -#define US_SC_SCSI 0x06 /* Transparent */ -#define US_SC_ISD200 0x07 /* ISD200 ATA */ -#define US_SC_MIN US_SC_RBC -#define US_SC_MAX US_SC_ISD200 - -#define US_SC_DEVICE 0xff /* Use device's value */ - /* Protocol handling routines */ extern void usb_stor_ATAPI_command(struct scsi_cmnd*, struct us_data*); extern void usb_stor_qic157_command(struct scsi_cmnd*, struct us_data*); diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h index 0a362cc..633a7158 100644 --- a/drivers/usb/storage/transport.h +++ b/drivers/usb/storage/transport.h @@ -41,39 +41,8 @@ #ifndef _TRANSPORT_H_ #define _TRANSPORT_H_ -#include #include -/* Protocols */ - -#define US_PR_CBI 0x00 /* Control/Bulk/Interrupt */ -#define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */ -#define US_PR_BULK 0x50 /* bulk only */ -#ifdef CONFIG_USB_STORAGE_USBAT -#define US_PR_USBAT 0x80 /* SCM-ATAPI bridge */ -#endif -#ifdef CONFIG_USB_STORAGE_SDDR09 -#define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */ -#endif -#ifdef CONFIG_USB_STORAGE_SDDR55 -#define US_PR_SDDR55 0x82 /* SDDR-55 (made up) */ -#endif -#define US_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */ - -#ifdef CONFIG_USB_STORAGE_FREECOM -#define US_PR_FREECOM 0xf1 /* Freecom */ -#endif - -#ifdef CONFIG_USB_STORAGE_DATAFAB -#define US_PR_DATAFAB 0xf2 /* Datafab chipsets */ -#endif - -#ifdef CONFIG_USB_STORAGE_JUMPSHOT -#define US_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */ -#endif - -#define US_PR_DEVICE 0xff /* Use device's value */ - /* * Bulk only data structures */ diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index f5f47a3..76904ad 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -1134,3 +1134,27 @@ UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999, US_SC_SCSI, US_PR_SDDR55, NULL, US_FL_SINGLE_LUN), #endif + +/* Control/Bulk transport for all SubClass values */ +USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_QIC, US_PR_CB, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_UFI, US_PR_CB, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_8070, US_PR_CB, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_SCSI, US_PR_CB, USB_US_TYPE_STOR), + +/* Control/Bulk/Interrupt transport for all SubClass values */ +USUAL_DEV(US_SC_RBC, US_PR_CBI, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_8020, US_PR_CBI, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_QIC, US_PR_CBI, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_UFI, US_PR_CBI, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_8070, US_PR_CBI, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_SCSI, US_PR_CBI, USB_US_TYPE_STOR), + +/* Bulk-only transport for all SubClass values */ +USUAL_DEV(US_SC_RBC, US_PR_BULK, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_8020, US_PR_BULK, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_QIC, US_PR_BULK, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_UFI, US_PR_BULK, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_8070, US_PR_BULK, USB_US_TYPE_STOR), +USUAL_DEV(US_SC_SCSI, US_PR_BULK, 0), diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 3847ebe..c8375aa 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -112,49 +112,33 @@ static atomic_t total_threads = ATOMIC_INIT(0); static DECLARE_COMPLETION(threads_gone); -/* The entries in this table, except for final ones here - * (USB_MASS_STORAGE_CLASS and the empty entry), correspond, - * line for line with the entries of us_unsuaul_dev_list[]. +/* + * The entries in this table correspond, line for line, + * with the entries of us_unusual_dev_list[]. */ +#ifndef CONFIG_USB_LIBUSUAL #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ vendorName, productName,useProtocol, useTransport, \ initFunction, flags) \ -{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax) } +{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \ + .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } + +#define USUAL_DEV(useProto, useTrans, useType) \ +{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \ + .driver_info = (USB_US_TYPE_STOR<<24) } static struct usb_device_id storage_usb_ids [] = { # include "unusual_devs.h" #undef UNUSUAL_DEV - /* Control/Bulk transport for all SubClass values */ - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_CB) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_CB) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_CB) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_CB) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_CB) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_CB) }, - - /* Control/Bulk/Interrupt transport for all SubClass values */ - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_CBI) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_CBI) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_CBI) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_CBI) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_CBI) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_CBI) }, - - /* Bulk-only transport for all SubClass values */ - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_BULK) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_BULK) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_BULK) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_BULK) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_BULK) }, - { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) }, - +#undef USUAL_DEV /* Terminating entry */ { } }; MODULE_DEVICE_TABLE (usb, storage_usb_ids); +#endif /* CONFIG_USB_LIBUSUAL */ /* This is the list of devices we recognize, along with their flag data */ @@ -167,7 +151,6 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids); * are free to use as many characters as you like. */ -#undef UNUSUAL_DEV #define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \ vendor_name, product_name, use_protocol, use_transport, \ init_function, Flags) \ @@ -177,53 +160,18 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids); .useProtocol = use_protocol, \ .useTransport = use_transport, \ .initFunction = init_function, \ - .flags = Flags, \ +} + +#define USUAL_DEV(use_protocol, use_transport, use_type) \ +{ \ + .useProtocol = use_protocol, \ + .useTransport = use_transport, \ } static struct us_unusual_dev us_unusual_dev_list[] = { # include "unusual_devs.h" # undef UNUSUAL_DEV - /* Control/Bulk transport for all SubClass values */ - { .useProtocol = US_SC_RBC, - .useTransport = US_PR_CB}, - { .useProtocol = US_SC_8020, - .useTransport = US_PR_CB}, - { .useProtocol = US_SC_QIC, - .useTransport = US_PR_CB}, - { .useProtocol = US_SC_UFI, - .useTransport = US_PR_CB}, - { .useProtocol = US_SC_8070, - .useTransport = US_PR_CB}, - { .useProtocol = US_SC_SCSI, - .useTransport = US_PR_CB}, - - /* Control/Bulk/Interrupt transport for all SubClass values */ - { .useProtocol = US_SC_RBC, - .useTransport = US_PR_CBI}, - { .useProtocol = US_SC_8020, - .useTransport = US_PR_CBI}, - { .useProtocol = US_SC_QIC, - .useTransport = US_PR_CBI}, - { .useProtocol = US_SC_UFI, - .useTransport = US_PR_CBI}, - { .useProtocol = US_SC_8070, - .useTransport = US_PR_CBI}, - { .useProtocol = US_SC_SCSI, - .useTransport = US_PR_CBI}, - - /* Bulk-only transport for all SubClass values */ - { .useProtocol = US_SC_RBC, - .useTransport = US_PR_BULK}, - { .useProtocol = US_SC_8020, - .useTransport = US_PR_BULK}, - { .useProtocol = US_SC_QIC, - .useTransport = US_PR_BULK}, - { .useProtocol = US_SC_UFI, - .useTransport = US_PR_BULK}, - { .useProtocol = US_SC_8070, - .useTransport = US_PR_BULK}, - { .useProtocol = US_SC_SCSI, - .useTransport = US_PR_BULK}, +# undef USUAL_DEV /* Terminating entry */ { NULL } @@ -484,14 +432,20 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf) return 0; } +/* Find an unusual_dev descriptor (always succeeds in the current code) */ +static struct us_unusual_dev *find_unusual(const struct usb_device_id *id) +{ + const int id_index = id - storage_usb_ids; + return &us_unusual_dev_list[id_index]; +} + /* Get the unusual_devs entries and the string descriptors */ -static void get_device_info(struct us_data *us, int id_index) +static void get_device_info(struct us_data *us, const struct usb_device_id *id) { struct usb_device *dev = us->pusb_dev; struct usb_interface_descriptor *idesc = &us->pusb_intf->cur_altsetting->desc; - struct us_unusual_dev *unusual_dev = &us_unusual_dev_list[id_index]; - struct usb_device_id *id = &storage_usb_ids[id_index]; + struct us_unusual_dev *unusual_dev = find_unusual(id); /* Store the entries */ us->unusual_dev = unusual_dev; @@ -501,7 +455,7 @@ static void get_device_info(struct us_data *us, int id_index) us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ? idesc->bInterfaceProtocol : unusual_dev->useTransport; - us->flags = unusual_dev->flags; + us->flags = USB_US_ORIG_FLAGS(id->driver_info); /* * This flag is only needed when we're in high-speed, so let's @@ -529,7 +483,7 @@ static void get_device_info(struct us_data *us, int id_index) if (unusual_dev->useTransport != US_PR_DEVICE && us->protocol == idesc->bInterfaceProtocol) msg += 2; - if (msg >= 0 && !(unusual_dev->flags & US_FL_NEED_OVERRIDE)) + if (msg >= 0 && !(us->flags & US_FL_NEED_OVERRIDE)) printk(KERN_NOTICE USB_STORAGE "This device " "(%04x,%04x,%04x S %02x P %02x)" " has %s in unusual_devs.h\n" @@ -921,10 +875,12 @@ static int storage_probe(struct usb_interface *intf, { struct Scsi_Host *host; struct us_data *us; - const int id_index = id - storage_usb_ids; int result; struct task_struct *th; + if (usb_usual_check_type(id, USB_US_TYPE_STOR)) + return -ENXIO; + US_DEBUGP("USB Mass Storage device detected\n"); /* @@ -957,7 +913,7 @@ static int storage_probe(struct usb_interface *intf, * of the match from the usb_device_id table, so we can find the * corresponding entry in the private table. */ - get_device_info(us, id_index); + get_device_info(us, id); #ifdef CONFIG_USB_STORAGE_SDDR09 if (us->protocol == US_PR_EUSB_SDDR09 || @@ -1062,9 +1018,10 @@ static int __init usb_stor_init(void) /* register the driver, return usb_register return code if error */ retval = usb_register(&usb_storage_driver); - if (retval == 0) + if (retval == 0) { printk(KERN_INFO "USB Mass Storage support registered.\n"); - + usb_usual_set_present(USB_US_TYPE_STOR); + } return retval; } @@ -1088,6 +1045,8 @@ static void __exit usb_stor_exit(void) wait_for_completion(&threads_gone); atomic_dec(&total_threads); } + + usb_usual_clear_present(USB_US_TYPE_STOR); } module_init(usb_stor_init); diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 98b0971..0cd1eeb 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -45,6 +45,7 @@ #define _USB_H_ #include +#include #include #include #include @@ -63,38 +64,8 @@ struct us_unusual_dev { __u8 useProtocol; __u8 useTransport; int (*initFunction)(struct us_data *); - unsigned int flags; }; -/* - * Static flag definitions. We use this roundabout technique so that the - * proc_info() routine can automatically display a message for each flag. - */ -#define US_DO_ALL_FLAGS \ - US_FLAG(SINGLE_LUN, 0x00000001) \ - /* allow access to only LUN 0 */ \ - US_FLAG(NEED_OVERRIDE, 0x00000002) \ - /* unusual_devs entry is necessary */ \ - US_FLAG(SCM_MULT_TARG, 0x00000004) \ - /* supports multiple targets */ \ - US_FLAG(FIX_INQUIRY, 0x00000008) \ - /* INQUIRY response needs faking */ \ - US_FLAG(FIX_CAPACITY, 0x00000010) \ - /* READ CAPACITY response too big */ \ - US_FLAG(IGNORE_RESIDUE, 0x00000020) \ - /* reported residue is wrong */ \ - US_FLAG(BULK32, 0x00000040) \ - /* Uses 32-byte CBW length */ \ - US_FLAG(NOT_LOCKABLE, 0x00000080) \ - /* PREVENT/ALLOW not supported */ \ - US_FLAG(GO_SLOW, 0x00000100) \ - /* Need delay after Command phase */ \ - US_FLAG(NO_WP_DETECT, 0x00000200) \ - /* Don't check for write-protect */ \ - -#define US_FLAG(name, value) US_FL_##name = value , -enum { US_DO_ALL_FLAGS }; -#undef US_FLAG /* Dynamic flag definitions: used in set_bit() etc. */ #define US_FLIDX_URB_ACTIVE 18 /* 0x00040000 current_urb is in use */ diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h new file mode 100644 index 0000000..f9c058f --- /dev/null +++ b/include/linux/usb_usual.h @@ -0,0 +1,123 @@ +/* + * Interface to the libusual. + * + * Copyright (c) 2005 Pete Zaitcev + * Copyright (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net) + * Copyright (c) 1999 Michael Gee (michael@linuxspecific.com) + */ + +#ifndef __LINUX_USB_USUAL_H +#define __LINUX_USB_USUAL_H + +#include + +/* We should do this for cleanliness... But other usb_foo.h do not do this. */ +/* #include */ + +/* + * The flags field, which we store in usb_device_id.driver_info. + * It is compatible with the old usb-storage flags in lower 24 bits. + */ + +/* + * Static flag definitions. We use this roundabout technique so that the + * proc_info() routine can automatically display a message for each flag. + */ +#define US_DO_ALL_FLAGS \ + US_FLAG(SINGLE_LUN, 0x00000001) \ + /* allow access to only LUN 0 */ \ + US_FLAG(NEED_OVERRIDE, 0x00000002) \ + /* unusual_devs entry is necessary */ \ + US_FLAG(SCM_MULT_TARG, 0x00000004) \ + /* supports multiple targets */ \ + US_FLAG(FIX_INQUIRY, 0x00000008) \ + /* INQUIRY response needs faking */ \ + US_FLAG(FIX_CAPACITY, 0x00000010) \ + /* READ CAPACITY response too big */ \ + US_FLAG(IGNORE_RESIDUE, 0x00000020) \ + /* reported residue is wrong */ \ + US_FLAG(BULK32, 0x00000040) \ + /* Uses 32-byte CBW length */ \ + US_FLAG(NOT_LOCKABLE, 0x00000080) \ + /* PREVENT/ALLOW not supported */ \ + US_FLAG(GO_SLOW, 0x00000100) \ + /* Need delay after Command phase */ \ + US_FLAG(NO_WP_DETECT, 0x00000200) \ + /* Don't check for write-protect */ \ + +#define US_FLAG(name, value) US_FL_##name = value , +enum { US_DO_ALL_FLAGS }; +#undef US_FLAG + +/* + * The bias field for libusual and friends. + */ +#define USB_US_TYPE_NONE 0 +#define USB_US_TYPE_STOR 1 /* usb-storage */ +#define USB_US_TYPE_UB 2 /* ub */ + +#define USB_US_TYPE(flags) (((flags) >> 24) & 0xFF) +#define USB_US_ORIG_FLAGS(flags) ((flags) & 0x00FFFFFF) + +/* + * This is probably not the best place to keep these constants, conceptually. + * But it's the only header included into all places which need them. + */ + +/* Sub Classes */ + +#define US_SC_RBC 0x01 /* Typically, flash devices */ +#define US_SC_8020 0x02 /* CD-ROM */ +#define US_SC_QIC 0x03 /* QIC-157 Tapes */ +#define US_SC_UFI 0x04 /* Floppy */ +#define US_SC_8070 0x05 /* Removable media */ +#define US_SC_SCSI 0x06 /* Transparent */ +#define US_SC_ISD200 0x07 /* ISD200 ATA */ +#define US_SC_MIN US_SC_RBC +#define US_SC_MAX US_SC_ISD200 + +#define US_SC_DEVICE 0xff /* Use device's value */ + +/* Protocols */ + +#define US_PR_CBI 0x00 /* Control/Bulk/Interrupt */ +#define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */ +#define US_PR_BULK 0x50 /* bulk only */ +#ifdef CONFIG_USB_STORAGE_USBAT +#define US_PR_USBAT 0x80 /* SCM-ATAPI bridge */ +#endif +#ifdef CONFIG_USB_STORAGE_SDDR09 +#define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */ +#endif +#ifdef CONFIG_USB_STORAGE_SDDR55 +#define US_PR_SDDR55 0x82 /* SDDR-55 (made up) */ +#endif +#define US_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */ +#ifdef CONFIG_USB_STORAGE_FREECOM +#define US_PR_FREECOM 0xf1 /* Freecom */ +#endif +#ifdef CONFIG_USB_STORAGE_DATAFAB +#define US_PR_DATAFAB 0xf2 /* Datafab chipsets */ +#endif +#ifdef CONFIG_USB_STORAGE_JUMPSHOT +#define US_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */ +#endif + +#define US_PR_DEVICE 0xff /* Use device's value */ + +/* + */ +#ifdef CONFIG_USB_LIBUSUAL + +extern struct usb_device_id storage_usb_ids[]; +extern void usb_usual_set_present(int type); +extern void usb_usual_clear_present(int type); +extern int usb_usual_check_type(const struct usb_device_id *, int type); +#else + +#define usb_usual_set_present(t) do { } while(0) +#define usb_usual_clear_present(t) do { } while(0) +#define usb_usual_check_type(id, t) (0) +#endif /* CONFIG_USB_LIBUSUAL */ + +#endif /* __LINUX_USB_USUAL_H */ -- cgit v1.1 From 5ba35bd8f9a4fa6b92ef707826c47a1466ece460 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Fri, 16 Dec 2005 00:39:36 -0800 Subject: [PATCH] USB: make bias writeable in libusual Make the bias parameter writeable. Writing the parameter does not trigger a rebind of currently attached storage devices. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/libusual.c | 53 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c index 61f73d8..2680c69 100644 --- a/drivers/usb/storage/libusual.c +++ b/drivers/usb/storage/libusual.c @@ -24,10 +24,9 @@ static DEFINE_SPINLOCK(usu_lock); /* */ #define USB_US_DEFAULT_BIAS USB_US_TYPE_STOR +static atomic_t usu_bias = ATOMIC_INIT(USB_US_DEFAULT_BIAS); #define BIAS_NAME_SIZE (sizeof("usb-storage")) -static char bias[BIAS_NAME_SIZE]; -static int usb_usual_bias; static const char *bias_names[3] = { "none", "usb-storage", "ub" }; static DECLARE_MUTEX_LOCKED(usu_init_notify); @@ -35,7 +34,6 @@ static DECLARE_COMPLETION(usu_end_notify); static atomic_t total_threads = ATOMIC_INIT(0); static int usu_probe_thread(void *arg); -static int parse_bias(const char *bias_s); /* * The table. @@ -107,7 +105,7 @@ int usb_usual_check_type(const struct usb_device_id *id, int caller_type) if (id_type == caller_type) return 0; /* Drivers grab devices biased to them */ - if (id_type == USB_US_TYPE_NONE && caller_type == usb_usual_bias) + if (id_type == USB_US_TYPE_NONE && caller_type == atomic_read(&usu_bias)) return 0; return -ENODEV; } @@ -124,7 +122,7 @@ static int usu_probe(struct usb_interface *intf, type = USB_US_TYPE(id->driver_info); if (type == 0) - type = usb_usual_bias; + type = atomic_read(&usu_bias); spin_lock_irqsave(&usu_lock, flags); if ((stat[type].fls & (USU_MOD_FL_THREAD|USU_MOD_FL_PRESENT)) != 0) { @@ -206,9 +204,6 @@ static int __init usb_usual_init(void) { int rc; - bias[BIAS_NAME_SIZE-1] = 0; - usb_usual_bias = parse_bias(bias); - rc = usb_register(&usu_driver); up(&usu_init_notify); return rc; @@ -231,36 +226,42 @@ static void __exit usb_usual_exit(void) /* * Validate and accept the bias parameter. - * Maybe make an sysfs method later. XXX */ -static int parse_bias(const char *bias_s) +static int usu_set_bias(const char *bias_s, struct kernel_param *kp) { int i; + int len; int bias_n = 0; - if (bias_s[0] == 0 || bias_s[0] == ' ') { - bias_n = USB_US_DEFAULT_BIAS; - } else { - for (i = 1; i < 3; i++) { - if (strcmp(bias_s, bias_names[i]) == 0) { - bias_n = i; - break; - } - } - if (bias_n == 0) { - bias_n = USB_US_DEFAULT_BIAS; - printk(KERN_INFO - "libusual: unknown bias \"%s\", using \"%s\"\n", - bias_s, bias_names[bias_n]); + len = strlen(bias_s); + if (len == 0) + return -EDOM; + if (bias_s[len-1] == '\n') + --len; + + for (i = 1; i < 3; i++) { + if (strncmp(bias_s, bias_names[i], len) == 0) { + bias_n = i; + break; } } - return bias_n; + if (bias_n == 0) + return -EINVAL; + + atomic_set(&usu_bias, bias_n); + return 0; +} + +static int usu_get_bias(char *buffer, struct kernel_param *kp) +{ + return strlen(strcpy(buffer, bias_names[atomic_read(&usu_bias)])); } module_init(usb_usual_init); module_exit(usb_usual_exit); -module_param_string(bias, bias, BIAS_NAME_SIZE, S_IRUGO|S_IWUSR); +module_param_call(bias, usu_set_bias, usu_get_bias, NULL, S_IRUGO|S_IWUSR); +__MODULE_PARM_TYPE(bias, "string"); MODULE_PARM_DESC(bias, "Bias to usb-storage or ub"); MODULE_LICENSE("GPL"); -- cgit v1.1 From ddae41be6145f5f9cb4e6df35661a09121b90672 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 16 Nov 2005 13:41:28 -0800 Subject: [PATCH] USB: reorg some functions out of the main usb.c file This will make the dynamic-id stuff easier to do, as it will be self-contained. No logic was changed at all. Signed-off-by: Greg Kroah-Hartman --- Documentation/DocBook/usb.tmpl | 1 + drivers/usb/core/Makefile | 2 +- drivers/usb/core/driver.c | 338 +++++++++++++++++++++++++++++++++++++++++ drivers/usb/core/usb.c | 311 ------------------------------------- drivers/usb/core/usb.h | 3 + 5 files changed, 343 insertions(+), 312 deletions(-) create mode 100644 drivers/usb/core/driver.c diff --git a/Documentation/DocBook/usb.tmpl b/Documentation/DocBook/usb.tmpl index 15ce0f2..320af25 100644 --- a/Documentation/DocBook/usb.tmpl +++ b/Documentation/DocBook/usb.tmpl @@ -253,6 +253,7 @@ !Edrivers/usb/core/urb.c !Edrivers/usb/core/message.c !Edrivers/usb/core/file.c +!Edrivers/usb/core/driver.c !Edrivers/usb/core/usb.c !Edrivers/usb/core/hub.c diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile index 86d5c38..28329dd 100644 --- a/drivers/usb/core/Makefile +++ b/drivers/usb/core/Makefile @@ -2,7 +2,7 @@ # Makefile for USB Core files and filesystem # -usbcore-objs := usb.o hub.o hcd.o urb.o message.o \ +usbcore-objs := usb.o hub.o hcd.o urb.o message.o driver.o \ config.o file.o buffer.o sysfs.o devio.o notify.o ifeq ($(CONFIG_PCI),y) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c new file mode 100644 index 0000000..921a21b --- /dev/null +++ b/drivers/usb/core/driver.c @@ -0,0 +1,338 @@ +/* + * drivers/usb/driver.c - most of the driver model stuff for usb + * + * (C) Copyright 2005 Greg Kroah-Hartman + * + * based on drivers/usb/usb.c which had the following copyrights: + * (C) Copyright Linus Torvalds 1999 + * (C) Copyright Johannes Erdfelt 1999-2001 + * (C) Copyright Andreas Gal 1999 + * (C) Copyright Gregory P. Smith 1999 + * (C) Copyright Deti Fliegl 1999 (new USB architecture) + * (C) Copyright Randy Dunlap 2000 + * (C) Copyright David Brownell 2000-2004 + * (C) Copyright Yggdrasil Computing, Inc. 2000 + * (usb_device_id matching changes by Adam J. Richter) + * (C) Copyright Greg Kroah-Hartman 2002-2003 + * + * NOTE! This is not actually a driver at all, rather this is + * just a collection of helper routines that implement the + * generic USB things that the real drivers can use.. + * + */ + +#include +#include +#include +#include "hcd.h" +#include "usb.h" + +static int generic_probe(struct device *dev) +{ + return 0; +} +static int generic_remove(struct device *dev) +{ + struct usb_device *udev = to_usb_device(dev); + + /* if this is only an unbind, not a physical disconnect, then + * unconfigure the device */ + if (udev->state == USB_STATE_CONFIGURED) + usb_set_configuration(udev, 0); + + /* in case the call failed or the device was suspended */ + if (udev->state >= USB_STATE_CONFIGURED) + usb_disable_device(udev, 0); + return 0; +} + +struct device_driver usb_generic_driver = { + .owner = THIS_MODULE, + .name = "usb", + .bus = &usb_bus_type, + .probe = generic_probe, + .remove = generic_remove, +}; + +/* Fun hack to determine if the struct device is a + * usb device or a usb interface. */ +int usb_generic_driver_data; + +/* called from driver core with usb_bus_type.subsys writelock */ +static int usb_probe_interface(struct device *dev) +{ + struct usb_interface * intf = to_usb_interface(dev); + struct usb_driver * driver = to_usb_driver(dev->driver); + const struct usb_device_id *id; + int error = -ENODEV; + + dev_dbg(dev, "%s\n", __FUNCTION__); + + if (!driver->probe) + return error; + /* FIXME we'd much prefer to just resume it ... */ + if (interface_to_usbdev(intf)->state == USB_STATE_SUSPENDED) + return -EHOSTUNREACH; + + id = usb_match_id(intf, driver->id_table); + if (id) { + dev_dbg(dev, "%s - got id\n", __FUNCTION__); + + /* Interface "power state" doesn't correspond to any hardware + * state whatsoever. We use it to record when it's bound to + * a driver that may start I/0: it's not frozen/quiesced. + */ + mark_active(intf); + intf->condition = USB_INTERFACE_BINDING; + error = driver->probe(intf, id); + if (error) { + mark_quiesced(intf); + intf->condition = USB_INTERFACE_UNBOUND; + } else + intf->condition = USB_INTERFACE_BOUND; + } + + return error; +} + +/* called from driver core with usb_bus_type.subsys writelock */ +static int usb_unbind_interface(struct device *dev) +{ + struct usb_interface *intf = to_usb_interface(dev); + struct usb_driver *driver = to_usb_driver(intf->dev.driver); + + intf->condition = USB_INTERFACE_UNBINDING; + + /* release all urbs for this interface */ + usb_disable_interface(interface_to_usbdev(intf), intf); + + if (driver && driver->disconnect) + driver->disconnect(intf); + + /* reset other interface state */ + usb_set_interface(interface_to_usbdev(intf), + intf->altsetting[0].desc.bInterfaceNumber, + 0); + usb_set_intfdata(intf, NULL); + intf->condition = USB_INTERFACE_UNBOUND; + mark_quiesced(intf); + + return 0; +} + +/** + * usb_match_id - find first usb_device_id matching device or interface + * @interface: the interface of interest + * @id: array of usb_device_id structures, terminated by zero entry + * + * usb_match_id searches an array of usb_device_id's and returns + * the first one matching the device or interface, or null. + * This is used when binding (or rebinding) a driver to an interface. + * Most USB device drivers will use this indirectly, through the usb core, + * but some layered driver frameworks use it directly. + * These device tables are exported with MODULE_DEVICE_TABLE, through + * modutils, to support the driver loading functionality of USB hotplugging. + * + * What Matches: + * + * The "match_flags" element in a usb_device_id controls which + * members are used. If the corresponding bit is set, the + * value in the device_id must match its corresponding member + * in the device or interface descriptor, or else the device_id + * does not match. + * + * "driver_info" is normally used only by device drivers, + * but you can create a wildcard "matches anything" usb_device_id + * as a driver's "modules.usbmap" entry if you provide an id with + * only a nonzero "driver_info" field. If you do this, the USB device + * driver's probe() routine should use additional intelligence to + * decide whether to bind to the specified interface. + * + * What Makes Good usb_device_id Tables: + * + * The match algorithm is very simple, so that intelligence in + * driver selection must come from smart driver id records. + * Unless you have good reasons to use another selection policy, + * provide match elements only in related groups, and order match + * specifiers from specific to general. Use the macros provided + * for that purpose if you can. + * + * The most specific match specifiers use device descriptor + * data. These are commonly used with product-specific matches; + * the USB_DEVICE macro lets you provide vendor and product IDs, + * and you can also match against ranges of product revisions. + * These are widely used for devices with application or vendor + * specific bDeviceClass values. + * + * Matches based on device class/subclass/protocol specifications + * are slightly more general; use the USB_DEVICE_INFO macro, or + * its siblings. These are used with single-function devices + * where bDeviceClass doesn't specify that each interface has + * its own class. + * + * Matches based on interface class/subclass/protocol are the + * most general; they let drivers bind to any interface on a + * multiple-function device. Use the USB_INTERFACE_INFO + * macro, or its siblings, to match class-per-interface style + * devices (as recorded in bDeviceClass). + * + * Within those groups, remember that not all combinations are + * meaningful. For example, don't give a product version range + * without vendor and product IDs; or specify a protocol without + * its associated class and subclass. + */ +const struct usb_device_id *usb_match_id(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct usb_host_interface *intf; + struct usb_device *dev; + + /* proc_connectinfo in devio.c may call us with id == NULL. */ + if (id == NULL) + return NULL; + + intf = interface->cur_altsetting; + dev = interface_to_usbdev(interface); + + /* It is important to check that id->driver_info is nonzero, + since an entry that is all zeroes except for a nonzero + id->driver_info is the way to create an entry that + indicates that the driver want to examine every + device and interface. */ + for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass || + id->driver_info; id++) { + + if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && + id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && + id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) + continue; + + /* No need to test id->bcdDevice_lo != 0, since 0 is never + greater than any unsigned number. */ + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && + (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && + (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && + (id->bDeviceClass != dev->descriptor.bDeviceClass)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && + (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && + (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && + (id->bInterfaceClass != intf->desc.bInterfaceClass)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) && + (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass)) + continue; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) && + (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol)) + continue; + + return id; + } + + return NULL; +} +EXPORT_SYMBOL_GPL(usb_match_id); + +int usb_device_match(struct device *dev, struct device_driver *drv) +{ + struct usb_interface *intf; + struct usb_driver *usb_drv; + const struct usb_device_id *id; + + /* check for generic driver, which we don't match any device with */ + if (drv == &usb_generic_driver) + return 0; + + intf = to_usb_interface(dev); + usb_drv = to_usb_driver(drv); + + id = usb_match_id(intf, usb_drv->id_table); + if (id) + return 1; + + return 0; +} + +/** + * usb_register - register a USB driver + * @new_driver: USB operations for the driver + * + * Registers a USB driver with the USB core. The list of unattached + * interfaces will be rescanned whenever a new driver is added, allowing + * the new driver to attach to any recognized devices. + * Returns a negative error code on failure and 0 on success. + * + * NOTE: if you want your driver to use the USB major number, you must call + * usb_register_dev() to enable that functionality. This function no longer + * takes care of that. + */ +int usb_register(struct usb_driver *new_driver) +{ + int retval = 0; + + if (usb_disabled()) + return -ENODEV; + + new_driver->driver.name = (char *)new_driver->name; + new_driver->driver.bus = &usb_bus_type; + new_driver->driver.probe = usb_probe_interface; + new_driver->driver.remove = usb_unbind_interface; + new_driver->driver.owner = new_driver->owner; + + usb_lock_all_devices(); + retval = driver_register(&new_driver->driver); + usb_unlock_all_devices(); + + if (!retval) { + pr_info("%s: registered new driver %s\n", + usbcore_name, new_driver->name); + usbfs_update_special(); + } else { + printk(KERN_ERR "%s: error %d registering driver %s\n", + usbcore_name, retval, new_driver->name); + } + + return retval; +} +EXPORT_SYMBOL_GPL(usb_register); + +/** + * usb_deregister - unregister a USB driver + * @driver: USB operations of the driver to unregister + * Context: must be able to sleep + * + * Unlinks the specified driver from the internal USB driver list. + * + * NOTE: If you called usb_register_dev(), you still need to call + * usb_deregister_dev() to clean up your driver's allocated minor numbers, + * this * call will no longer do it for you. + */ +void usb_deregister(struct usb_driver *driver) +{ + pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name); + + usb_lock_all_devices(); + driver_unregister(&driver->driver); + usb_unlock_all_devices(); + + usbfs_update_special(); +} +EXPORT_SYMBOL_GPL(usb_deregister); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index e80ef94..294e9f1 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -52,161 +52,6 @@ static int nousb; /* Disable USB when built into kernel image */ static DECLARE_RWSEM(usb_all_devices_rwsem); -static int generic_probe (struct device *dev) -{ - return 0; -} -static int generic_remove (struct device *dev) -{ - struct usb_device *udev = to_usb_device(dev); - - /* if this is only an unbind, not a physical disconnect, then - * unconfigure the device */ - if (udev->state == USB_STATE_CONFIGURED) - usb_set_configuration(udev, 0); - - /* in case the call failed or the device was suspended */ - if (udev->state >= USB_STATE_CONFIGURED) - usb_disable_device(udev, 0); - return 0; -} - -static struct device_driver usb_generic_driver = { - .owner = THIS_MODULE, - .name = "usb", - .bus = &usb_bus_type, - .probe = generic_probe, - .remove = generic_remove, -}; - -static int usb_generic_driver_data; - -/* called from driver core with usb_bus_type.subsys writelock */ -static int usb_probe_interface(struct device *dev) -{ - struct usb_interface * intf = to_usb_interface(dev); - struct usb_driver * driver = to_usb_driver(dev->driver); - const struct usb_device_id *id; - int error = -ENODEV; - - dev_dbg(dev, "%s\n", __FUNCTION__); - - if (!driver->probe) - return error; - /* FIXME we'd much prefer to just resume it ... */ - if (interface_to_usbdev(intf)->state == USB_STATE_SUSPENDED) - return -EHOSTUNREACH; - - id = usb_match_id (intf, driver->id_table); - if (id) { - dev_dbg (dev, "%s - got id\n", __FUNCTION__); - - /* Interface "power state" doesn't correspond to any hardware - * state whatsoever. We use it to record when it's bound to - * a driver that may start I/0: it's not frozen/quiesced. - */ - mark_active(intf); - intf->condition = USB_INTERFACE_BINDING; - error = driver->probe (intf, id); - if (error) { - mark_quiesced(intf); - intf->condition = USB_INTERFACE_UNBOUND; - } else - intf->condition = USB_INTERFACE_BOUND; - } - - return error; -} - -/* called from driver core with usb_bus_type.subsys writelock */ -static int usb_unbind_interface(struct device *dev) -{ - struct usb_interface *intf = to_usb_interface(dev); - struct usb_driver *driver = to_usb_driver(intf->dev.driver); - - intf->condition = USB_INTERFACE_UNBINDING; - - /* release all urbs for this interface */ - usb_disable_interface(interface_to_usbdev(intf), intf); - - if (driver && driver->disconnect) - driver->disconnect(intf); - - /* reset other interface state */ - usb_set_interface(interface_to_usbdev(intf), - intf->altsetting[0].desc.bInterfaceNumber, - 0); - usb_set_intfdata(intf, NULL); - intf->condition = USB_INTERFACE_UNBOUND; - mark_quiesced(intf); - - return 0; -} - -/** - * usb_register - register a USB driver - * @new_driver: USB operations for the driver - * - * Registers a USB driver with the USB core. The list of unattached - * interfaces will be rescanned whenever a new driver is added, allowing - * the new driver to attach to any recognized devices. - * Returns a negative error code on failure and 0 on success. - * - * NOTE: if you want your driver to use the USB major number, you must call - * usb_register_dev() to enable that functionality. This function no longer - * takes care of that. - */ -int usb_register(struct usb_driver *new_driver) -{ - int retval = 0; - - if (nousb) - return -ENODEV; - - new_driver->driver.name = (char *)new_driver->name; - new_driver->driver.bus = &usb_bus_type; - new_driver->driver.probe = usb_probe_interface; - new_driver->driver.remove = usb_unbind_interface; - new_driver->driver.owner = new_driver->owner; - - usb_lock_all_devices(); - retval = driver_register(&new_driver->driver); - usb_unlock_all_devices(); - - if (!retval) { - pr_info("%s: registered new driver %s\n", - usbcore_name, new_driver->name); - usbfs_update_special(); - } else { - printk(KERN_ERR "%s: error %d registering driver %s\n", - usbcore_name, retval, new_driver->name); - } - - return retval; -} - -/** - * usb_deregister - unregister a USB driver - * @driver: USB operations of the driver to unregister - * Context: must be able to sleep - * - * Unlinks the specified driver from the internal USB driver list. - * - * NOTE: If you called usb_register_dev(), you still need to call - * usb_deregister_dev() to clean up your driver's allocated minor numbers, - * this * call will no longer do it for you. - */ -void usb_deregister(struct usb_driver *driver) -{ - pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name); - - usb_lock_all_devices(); - driver_unregister (&driver->driver); - usb_unlock_all_devices(); - - usbfs_update_special(); -} - /** * usb_ifnum_to_if - get the interface object with a given interface number * @dev: the device whose current configuration is considered @@ -352,138 +197,6 @@ void usb_driver_release_interface(struct usb_driver *driver, mark_quiesced(iface); } -/** - * usb_match_id - find first usb_device_id matching device or interface - * @interface: the interface of interest - * @id: array of usb_device_id structures, terminated by zero entry - * - * usb_match_id searches an array of usb_device_id's and returns - * the first one matching the device or interface, or null. - * This is used when binding (or rebinding) a driver to an interface. - * Most USB device drivers will use this indirectly, through the usb core, - * but some layered driver frameworks use it directly. - * These device tables are exported with MODULE_DEVICE_TABLE, through - * modutils and "modules.usbmap", to support the driver loading - * functionality of USB hotplugging. - * - * What Matches: - * - * The "match_flags" element in a usb_device_id controls which - * members are used. If the corresponding bit is set, the - * value in the device_id must match its corresponding member - * in the device or interface descriptor, or else the device_id - * does not match. - * - * "driver_info" is normally used only by device drivers, - * but you can create a wildcard "matches anything" usb_device_id - * as a driver's "modules.usbmap" entry if you provide an id with - * only a nonzero "driver_info" field. If you do this, the USB device - * driver's probe() routine should use additional intelligence to - * decide whether to bind to the specified interface. - * - * What Makes Good usb_device_id Tables: - * - * The match algorithm is very simple, so that intelligence in - * driver selection must come from smart driver id records. - * Unless you have good reasons to use another selection policy, - * provide match elements only in related groups, and order match - * specifiers from specific to general. Use the macros provided - * for that purpose if you can. - * - * The most specific match specifiers use device descriptor - * data. These are commonly used with product-specific matches; - * the USB_DEVICE macro lets you provide vendor and product IDs, - * and you can also match against ranges of product revisions. - * These are widely used for devices with application or vendor - * specific bDeviceClass values. - * - * Matches based on device class/subclass/protocol specifications - * are slightly more general; use the USB_DEVICE_INFO macro, or - * its siblings. These are used with single-function devices - * where bDeviceClass doesn't specify that each interface has - * its own class. - * - * Matches based on interface class/subclass/protocol are the - * most general; they let drivers bind to any interface on a - * multiple-function device. Use the USB_INTERFACE_INFO - * macro, or its siblings, to match class-per-interface style - * devices (as recorded in bDeviceClass). - * - * Within those groups, remember that not all combinations are - * meaningful. For example, don't give a product version range - * without vendor and product IDs; or specify a protocol without - * its associated class and subclass. - */ -const struct usb_device_id * -usb_match_id(struct usb_interface *interface, const struct usb_device_id *id) -{ - struct usb_host_interface *intf; - struct usb_device *dev; - - /* proc_connectinfo in devio.c may call us with id == NULL. */ - if (id == NULL) - return NULL; - - intf = interface->cur_altsetting; - dev = interface_to_usbdev(interface); - - /* It is important to check that id->driver_info is nonzero, - since an entry that is all zeroes except for a nonzero - id->driver_info is the way to create an entry that - indicates that the driver want to examine every - device and interface. */ - for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass || - id->driver_info; id++) { - - if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && - id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && - id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) - continue; - - /* No need to test id->bcdDevice_lo != 0, since 0 is never - greater than any unsigned number. */ - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && - (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && - (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && - (id->bDeviceClass != dev->descriptor.bDeviceClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && - (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && - (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && - (id->bInterfaceClass != intf->desc.bInterfaceClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) && - (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) && - (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol)) - continue; - - return id; - } - - return NULL; -} - - static int __find_interface(struct device * dev, void * data) { struct usb_interface ** ret = (struct usb_interface **)data; @@ -521,27 +234,6 @@ struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) return ret ? intf : NULL; } -static int usb_device_match (struct device *dev, struct device_driver *drv) -{ - struct usb_interface *intf; - struct usb_driver *usb_drv; - const struct usb_device_id *id; - - /* check for generic driver, which we don't match any device with */ - if (drv == &usb_generic_driver) - return 0; - - intf = to_usb_interface(dev); - usb_drv = to_usb_driver(drv); - - id = usb_match_id (intf, usb_drv->id_table); - if (id) - return 1; - - return 0; -} - - #ifdef CONFIG_HOTPLUG /* @@ -1598,8 +1290,6 @@ module_exit(usb_exit); * driver modules to use. */ -EXPORT_SYMBOL(usb_register); -EXPORT_SYMBOL(usb_deregister); EXPORT_SYMBOL(usb_disabled); EXPORT_SYMBOL_GPL(usb_get_intf); @@ -1617,7 +1307,6 @@ EXPORT_SYMBOL(usb_unlock_device); EXPORT_SYMBOL(usb_driver_claim_interface); EXPORT_SYMBOL(usb_driver_release_interface); -EXPORT_SYMBOL(usb_match_id); EXPORT_SYMBOL(usb_find_interface); EXPORT_SYMBOL(usb_ifnum_to_if); EXPORT_SYMBOL(usb_altnum_to_altsetting); diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 1c4a684..98e85fb 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -33,6 +33,9 @@ extern void usb_host_cleanup(void); extern int usb_suspend_device(struct usb_device *dev); extern int usb_resume_device(struct usb_device *dev); +extern struct device_driver usb_generic_driver; +extern int usb_generic_driver_data; +extern int usb_device_match(struct device *dev, struct device_driver *drv); /* Interfaces and their "power state" are owned by usbcore */ -- cgit v1.1 From 733260ff9c45bd4db60f45d17e8560a4a68dff4d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 16 Nov 2005 13:41:28 -0800 Subject: [PATCH] USB: add dynamic id functionality to USB core Echo the usb vendor and product id to the "new_id" file in the driver's sysfs directory, and then that driver will be able to bind to a device with those ids if it is present. Example: echo 0557 2008 > /sys/bus/usb/drivers/foo_driver/new_id adds the hex values 0557 and 2008 to the device id table for the foo_driver. Note, usb-serial drivers do not currently work with this capability yet. usb-storage also might have some oddities. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/driver.c | 218 +++++++++++++++++++++++++++++++++++----------- include/linux/usb.h | 8 ++ 2 files changed, 176 insertions(+), 50 deletions(-) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 921a21b..1c06110 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -27,6 +27,15 @@ #include "hcd.h" #include "usb.h" +static int usb_match_one_id(struct usb_interface *interface, + const struct usb_device_id *id); + +struct usb_dynid { + struct list_head node; + struct usb_device_id id; +}; + + static int generic_probe(struct device *dev) { return 0; @@ -58,6 +67,96 @@ struct device_driver usb_generic_driver = { * usb device or a usb interface. */ int usb_generic_driver_data; +#ifdef CONFIG_HOTPLUG + +/* + * Adds a new dynamic USBdevice ID to this driver, + * and cause the driver to probe for all devices again. + */ +static ssize_t store_new_id(struct device_driver *driver, + const char *buf, size_t count) +{ + struct usb_driver *usb_drv = to_usb_driver(driver); + struct usb_dynid *dynid; + u32 idVendor = 0; + u32 idProduct = 0; + int fields = 0; + + fields = sscanf(buf, "%x %x", &idVendor, &idProduct); + if (fields < 2) + return -EINVAL; + + dynid = kzalloc(sizeof(*dynid), GFP_KERNEL); + if (!dynid) + return -ENOMEM; + + INIT_LIST_HEAD(&dynid->node); + dynid->id.idVendor = idVendor; + dynid->id.idProduct = idProduct; + dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE; + + spin_lock(&usb_drv->dynids.lock); + list_add_tail(&usb_drv->dynids.list, &dynid->node); + spin_unlock(&usb_drv->dynids.lock); + + if (get_driver(driver)) { + driver_attach(driver); + put_driver(driver); + } + + return count; +} +static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); + +static int usb_create_newid_file(struct usb_driver *usb_drv) +{ + int error = 0; + + if (usb_drv->probe != NULL) + error = sysfs_create_file(&usb_drv->driver.kobj, + &driver_attr_new_id.attr); + return error; +} + +static void usb_free_dynids(struct usb_driver *usb_drv) +{ + struct usb_dynid *dynid, *n; + + spin_lock(&usb_drv->dynids.lock); + list_for_each_entry_safe(dynid, n, &usb_drv->dynids.list, node) { + list_del(&dynid->node); + kfree(dynid); + } + spin_unlock(&usb_drv->dynids.lock); +} +#else +static inline int usb_create_newid_file(struct usb_driver *usb_drv) +{ + return 0; +} + +static inline void usb_free_dynids(struct usb_driver *usb_drv) +{ +} +#endif + +static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf, + struct usb_driver *drv) +{ + struct usb_dynid *dynid; + + spin_lock(&drv->dynids.lock); + list_for_each_entry(dynid, &drv->dynids.list, node) { + if (usb_match_one_id(intf, &dynid->id)) { + spin_unlock(&drv->dynids.lock); + return &dynid->id; + } + } + spin_unlock(&drv->dynids.lock); + return NULL; +} + + /* called from driver core with usb_bus_type.subsys writelock */ static int usb_probe_interface(struct device *dev) { @@ -75,6 +174,8 @@ static int usb_probe_interface(struct device *dev) return -EHOSTUNREACH; id = usb_match_id(intf, driver->id_table); + if (!id) + id = usb_match_dynamic_id(intf, driver); if (id) { dev_dbg(dev, "%s - got id\n", __FUNCTION__); @@ -120,6 +221,64 @@ static int usb_unbind_interface(struct device *dev) return 0; } +/* returns 0 if no match, 1 if match */ +static int usb_match_one_id(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct usb_host_interface *intf; + struct usb_device *dev; + + /* proc_connectinfo in devio.c may call us with id == NULL. */ + if (id == NULL) + return 0; + + intf = interface->cur_altsetting; + dev = interface_to_usbdev(interface); + + if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && + id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && + id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) + return 0; + + /* No need to test id->bcdDevice_lo != 0, since 0 is never + greater than any unsigned number. */ + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && + (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && + (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && + (id->bDeviceClass != dev->descriptor.bDeviceClass)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && + (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && + (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && + (id->bInterfaceClass != intf->desc.bInterfaceClass)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) && + (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass)) + return 0; + + if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) && + (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol)) + return 0; + + return 1; +} /** * usb_match_id - find first usb_device_id matching device or interface * @interface: the interface of interest @@ -184,16 +343,10 @@ static int usb_unbind_interface(struct device *dev) const struct usb_device_id *usb_match_id(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_host_interface *intf; - struct usb_device *dev; - /* proc_connectinfo in devio.c may call us with id == NULL. */ if (id == NULL) return NULL; - intf = interface->cur_altsetting; - dev = interface_to_usbdev(interface); - /* It is important to check that id->driver_info is nonzero, since an entry that is all zeroes except for a nonzero id->driver_info is the way to create an entry that @@ -201,50 +354,8 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface, device and interface. */ for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass || id->driver_info; id++) { - - if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && - id->idVendor != le16_to_cpu(dev->descriptor.idVendor)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) && - id->idProduct != le16_to_cpu(dev->descriptor.idProduct)) - continue; - - /* No need to test id->bcdDevice_lo != 0, since 0 is never - greater than any unsigned number. */ - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) && - (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice))) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) && - (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice))) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) && - (id->bDeviceClass != dev->descriptor.bDeviceClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) && - (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) && - (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && - (id->bInterfaceClass != intf->desc.bInterfaceClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) && - (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass)) - continue; - - if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) && - (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol)) - continue; - - return id; + if (usb_match_one_id(interface, id)) + return id; } return NULL; @@ -268,6 +379,9 @@ int usb_device_match(struct device *dev, struct device_driver *drv) if (id) return 1; + id = usb_match_dynamic_id(intf, usb_drv); + if (id) + return 1; return 0; } @@ -296,6 +410,8 @@ int usb_register(struct usb_driver *new_driver) new_driver->driver.probe = usb_probe_interface; new_driver->driver.remove = usb_unbind_interface; new_driver->driver.owner = new_driver->owner; + spin_lock_init(&new_driver->dynids.lock); + INIT_LIST_HEAD(&new_driver->dynids.list); usb_lock_all_devices(); retval = driver_register(&new_driver->driver); @@ -305,6 +421,7 @@ int usb_register(struct usb_driver *new_driver) pr_info("%s: registered new driver %s\n", usbcore_name, new_driver->name); usbfs_update_special(); + usb_create_newid_file(new_driver); } else { printk(KERN_ERR "%s: error %d registering driver %s\n", usbcore_name, retval, new_driver->name); @@ -330,6 +447,7 @@ void usb_deregister(struct usb_driver *driver) pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name); usb_lock_all_devices(); + usb_free_dynids(driver); driver_unregister(&driver->driver); usb_unlock_all_devices(); diff --git a/include/linux/usb.h b/include/linux/usb.h index d81b050..0dd96ef 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -529,6 +529,11 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, /* ----------------------------------------------------------------------- */ +struct usb_dynids { + spinlock_t lock; + struct list_head list; +}; + /** * struct usb_driver - identifies USB driver to usbcore * @owner: Pointer to the module owner of this driver; initialize @@ -553,6 +558,8 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, * @id_table: USB drivers use ID table to support hotplugging. * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set * or your driver's probe function will never get called. + * @dynids: used internally to hold the list of dynamically added device + * ids for this driver. * @driver: the driver model core driver structure. * * USB drivers must provide a name, probe() and disconnect() methods, @@ -588,6 +595,7 @@ struct usb_driver { const struct usb_device_id *id_table; + struct usb_dynids dynids; struct device_driver driver; }; #define to_usb_driver(d) container_of(d, struct usb_driver, driver) -- cgit v1.1 From ba9dc657af86d05d2971633e57d1f6f94ed60472 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 16 Nov 2005 13:41:28 -0800 Subject: [PATCH] USB: allow usb drivers to disable dynamic ids This lets drivers, like the usb-serial ones, disable the ability to add ids from sysfs. The usb-serial drivers are "odd" in that they are really usb-serial bus drivers, not usb bus drivers, so the dynamic id logic will have to go into the usb-serial bus core for those drivers to get that ability. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/driver.c | 19 +++++++++++++++++++ drivers/usb/serial/airprime.c | 1 + drivers/usb/serial/anydata.c | 1 + drivers/usb/serial/belkin_sa.c | 1 + drivers/usb/serial/cp2101.c | 1 + drivers/usb/serial/cyberjack.c | 1 + drivers/usb/serial/cypress_m8.c | 1 + drivers/usb/serial/digi_acceleport.c | 1 + drivers/usb/serial/empeg.c | 1 + drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/garmin_gps.c | 1 + drivers/usb/serial/generic.c | 1 + drivers/usb/serial/hp4x.c | 1 + drivers/usb/serial/io_edgeport.c | 1 + drivers/usb/serial/io_ti.c | 1 + drivers/usb/serial/ipaq.c | 1 + drivers/usb/serial/ipw.c | 1 + drivers/usb/serial/ir-usb.c | 1 + drivers/usb/serial/keyspan.h | 1 + drivers/usb/serial/keyspan_pda.c | 1 + drivers/usb/serial/kl5kusb105.c | 1 + drivers/usb/serial/kobil_sct.c | 1 + drivers/usb/serial/mct_u232.c | 1 + drivers/usb/serial/omninet.c | 1 + drivers/usb/serial/option.c | 1 + drivers/usb/serial/pl2303.c | 1 + drivers/usb/serial/safe_serial.c | 1 + drivers/usb/serial/ti_usb_3410_5052.c | 1 + drivers/usb/serial/usb-serial.c | 1 + drivers/usb/serial/visor.c | 1 + drivers/usb/serial/whiteheat.c | 1 + include/linux/usb.h | 3 +++ 32 files changed, 52 insertions(+) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 1c06110..5e65bc2 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -112,12 +112,26 @@ static int usb_create_newid_file(struct usb_driver *usb_drv) { int error = 0; + if (usb_drv->no_dynamic_id) + goto exit; + if (usb_drv->probe != NULL) error = sysfs_create_file(&usb_drv->driver.kobj, &driver_attr_new_id.attr); +exit: return error; } +static void usb_remove_newid_file(struct usb_driver *usb_drv) +{ + if (usb_drv->no_dynamic_id) + return; + + if (usb_drv->probe != NULL) + sysfs_remove_file(&usb_drv->driver.kobj, + &driver_attr_new_id.attr); +} + static void usb_free_dynids(struct usb_driver *usb_drv) { struct usb_dynid *dynid, *n; @@ -135,6 +149,10 @@ static inline int usb_create_newid_file(struct usb_driver *usb_drv) return 0; } +static void usb_remove_newid_file(struct usb_driver *usb_drv) +{ +} + static inline void usb_free_dynids(struct usb_driver *usb_drv) { } @@ -447,6 +465,7 @@ void usb_deregister(struct usb_driver *driver) pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name); usb_lock_all_devices(); + usb_remove_newid_file(driver); usb_free_dynids(driver); driver_unregister(&driver->driver); usb_unlock_all_devices(); diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index 1f29d88..2ef9945 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c @@ -28,6 +28,7 @@ static struct usb_driver airprime_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; static struct usb_serial_driver airprime_device = { diff --git a/drivers/usb/serial/anydata.c b/drivers/usb/serial/anydata.c index 18022a7..7a171e0 100644 --- a/drivers/usb/serial/anydata.c +++ b/drivers/usb/serial/anydata.c @@ -32,6 +32,7 @@ static struct usb_driver anydata_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; static int anydata_open(struct usb_serial_port *port, struct file *filp) diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 84bc0ee..69039bd 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -118,6 +118,7 @@ static struct usb_driver belkin_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; /* All of the device info needed for the serial converters */ diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index c978700..813bab3 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -72,6 +72,7 @@ static struct usb_driver cp2101_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; static struct usb_serial_driver cp2101_device = { diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index e581e4a..8c10e40 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -81,6 +81,7 @@ static struct usb_driver cyberjack_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; static struct usb_serial_driver cyberjack_device = { diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index af9290e..af18355 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -112,6 +112,7 @@ static struct usb_driver cypress_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; struct cypress_private { diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index dc74644..c50cec9 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -498,6 +498,7 @@ static struct usb_driver digi_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 0b0546d..e5e40064 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -110,6 +110,7 @@ static struct usb_driver empeg_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; static struct usb_serial_driver empeg_device = { diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 06e04b4..857fe79 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -488,6 +488,7 @@ static struct usb_driver ftdi_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; static char *ftdi_chip_name[] = { diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 35820bd..198a3222 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -227,6 +227,7 @@ static struct usb_driver garmin_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 53a47c3..c00a440 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -73,6 +73,7 @@ static struct usb_driver generic_driver = { .probe = generic_probe, .disconnect = usb_serial_disconnect, .id_table = generic_serial_ids, + .no_dynamic_id = 1, }; #endif diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index 8eadfb7..e588c3f 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c @@ -42,6 +42,7 @@ static struct usb_driver hp49gp_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; static struct usb_serial_driver hp49gp_device = { diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index dc4c498..276bd42 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -247,6 +247,7 @@ static struct usb_driver io_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; /* function prototypes for all of our local functions */ diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 832b6d6..8b2e4c7 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -221,6 +221,7 @@ static struct usb_driver io_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index d5d0664..efb568b 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -547,6 +547,7 @@ static struct usb_driver ipaq_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = ipaq_id_table, + .no_dynamic_id = 1, }; diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 7744b81..64e2cda 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -157,6 +157,7 @@ static struct usb_driver usb_ipw_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = usb_ipw_ids, + .no_dynamic_id = 1, }; static int debug; diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 19f329e..647431c 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -130,6 +130,7 @@ static struct usb_driver ir_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index 5cfc13b..4e6f626 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h @@ -525,6 +525,7 @@ static struct usb_driver keyspan_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = keyspan_ids_combined, + .no_dynamic_id = 1, }; /* usb_device_id table for the pre-firmware download keyspan devices */ diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index cd4f48b..0d1f152 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -155,6 +155,7 @@ static struct usb_driver keyspan_pda_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; static struct usb_device_id id_table_std [] = { diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index a8951c0..bd68638 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -121,6 +121,7 @@ static struct usb_driver kl5kusb105d_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; static struct usb_serial_driver kl5kusb105d_device = { diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 9456dd9..4c853af 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -102,6 +102,7 @@ static struct usb_driver kobil_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index ca5dbad..b0415e7 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -130,6 +130,7 @@ static struct usb_driver mct_u232_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; static struct usb_serial_driver mct_u232_device = { diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 3caf970..b595bef 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -85,6 +85,7 @@ static struct usb_driver omninet_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 7716000..4ee657e 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -100,6 +100,7 @@ static struct usb_driver option_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = option_ids, + .no_dynamic_id = 1, }; /* The card has three separate interfaces, wich the serial driver diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 41a45a5..e302a32 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -87,6 +87,7 @@ static struct usb_driver pl2303_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; #define SET_LINE_REQUEST_TYPE 0x21 diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index c22bdc0..f8241c1 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -165,6 +165,7 @@ static struct usb_driver safe_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table, + .no_dynamic_id = 1, }; static __u16 crc10_table[256] = { diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 205dbf7..17a1f09 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -253,6 +253,7 @@ static struct usb_driver ti_usb_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = ti_id_table_combined, + .no_dynamic_id = 1, }; static struct usb_serial_driver ti_1port_device = { diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 0c4881d..2ac37b5 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -46,6 +46,7 @@ static struct usb_driver usb_serial_driver = { .name = "usbserial", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, + .no_dynamic_id = 1, }; /* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index a473c1c..2973f55 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c @@ -178,6 +178,7 @@ static struct usb_driver visor_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; /* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 18c3183..19c6386 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -132,6 +132,7 @@ static struct usb_driver whiteheat_driver = { .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, .id_table = id_table_combined, + .no_dynamic_id = 1, }; /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */ diff --git a/include/linux/usb.h b/include/linux/usb.h index 0dd96ef..8d58299 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -561,6 +561,8 @@ struct usb_dynids { * @dynids: used internally to hold the list of dynamically added device * ids for this driver. * @driver: the driver model core driver structure. + * @no_dynamic_id: if set to 1, the USB core will not allow dynamic ids to be + * added to this driver by preventing the sysfs file from being created. * * USB drivers must provide a name, probe() and disconnect() methods, * and an id_table. Other driver fields are optional. @@ -597,6 +599,7 @@ struct usb_driver { struct usb_dynids dynids; struct device_driver driver; + unsigned int no_dynamic_id:1; }; #define to_usb_driver(d) container_of(d, struct usb_driver, driver) -- cgit v1.1 From 2143acc6dc79bdbff812f02a7dc5ab9d4fc81fc8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 21 Nov 2005 14:53:03 -0800 Subject: [PATCH] USB: make registering a usb driver automatically set the module owner This fixes the driver that forgot to set the module owner up. Now we can remove the unneeded pointer from the usb driver structure. The idea for how to do this was from Al Viro, who did this for the PCI drivers. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/driver.c | 9 +++++---- include/linux/usb.h | 6 +++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 5e65bc2..bb139f0 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -404,8 +404,9 @@ int usb_device_match(struct device *dev, struct device_driver *drv) } /** - * usb_register - register a USB driver + * usb_register_driver - register a USB driver * @new_driver: USB operations for the driver + * @owner: module owner of this driver. * * Registers a USB driver with the USB core. The list of unattached * interfaces will be rescanned whenever a new driver is added, allowing @@ -416,7 +417,7 @@ int usb_device_match(struct device *dev, struct device_driver *drv) * usb_register_dev() to enable that functionality. This function no longer * takes care of that. */ -int usb_register(struct usb_driver *new_driver) +int usb_register_driver(struct usb_driver *new_driver, struct module *owner) { int retval = 0; @@ -427,7 +428,7 @@ int usb_register(struct usb_driver *new_driver) new_driver->driver.bus = &usb_bus_type; new_driver->driver.probe = usb_probe_interface; new_driver->driver.remove = usb_unbind_interface; - new_driver->driver.owner = new_driver->owner; + new_driver->driver.owner = owner; spin_lock_init(&new_driver->dynids.lock); INIT_LIST_HEAD(&new_driver->dynids.list); @@ -447,7 +448,7 @@ int usb_register(struct usb_driver *new_driver) return retval; } -EXPORT_SYMBOL_GPL(usb_register); +EXPORT_SYMBOL_GPL(usb_register_driver); /** * usb_deregister - unregister a USB driver diff --git a/include/linux/usb.h b/include/linux/usb.h index 8d58299..3d05c63 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -625,7 +625,11 @@ struct usb_class_driver { * use these in module_init()/module_exit() * and don't forget MODULE_DEVICE_TABLE(usb, ...) */ -extern int usb_register(struct usb_driver *); +int usb_register_driver(struct usb_driver *, struct module *); +static inline int usb_register(struct usb_driver *driver) +{ + return usb_register_driver(driver, THIS_MODULE); +} extern void usb_deregister(struct usb_driver *); extern int usb_register_dev(struct usb_interface *intf, -- cgit v1.1 From 75318d2d7cab77b14c5d3dbd5e69f2680a769e16 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 21 Nov 2005 14:53:03 -0800 Subject: [PATCH] USB: remove .owner field from struct usb_driver It is no longer needed, so let's remove it, saving a bit of memory. Signed-off-by: Greg Kroah-Hartman --- drivers/block/ub.c | 1 - drivers/bluetooth/bcm203x.c | 1 - drivers/bluetooth/bfusb.c | 1 - drivers/bluetooth/bpa10x.c | 1 - drivers/bluetooth/hci_usb.c | 1 - drivers/char/watchdog/pcwd_usb.c | 1 - drivers/input/joystick/iforce/iforce-usb.c | 1 - drivers/isdn/hisax/hfc_usb.c | 1 - drivers/isdn/hisax/st5481_init.c | 1 - drivers/media/dvb/b2c2/flexcop-usb.c | 1 - drivers/media/dvb/cinergyT2/cinergyT2.c | 1 - drivers/media/dvb/dvb-usb/a800.c | 1 - drivers/media/dvb/dvb-usb/cxusb.c | 1 - drivers/media/dvb/dvb-usb/dibusb-mb.c | 1 - drivers/media/dvb/dvb-usb/dibusb-mc.c | 1 - drivers/media/dvb/dvb-usb/digitv.c | 1 - drivers/media/dvb/dvb-usb/dtt200u.c | 1 - drivers/media/dvb/dvb-usb/nova-t-usb2.c | 1 - drivers/media/dvb/dvb-usb/umt-010.c | 1 - drivers/media/dvb/dvb-usb/vp702x.c | 1 - drivers/media/dvb/dvb-usb/vp7045.c | 1 - drivers/media/video/cpia_usb.c | 1 - drivers/media/video/em28xx/em28xx-video.c | 1 - drivers/net/irda/irda-usb.c | 1 - drivers/net/irda/stir4200.c | 1 - drivers/usb/atm/cxacru.c | 1 - drivers/usb/atm/speedtch.c | 1 - drivers/usb/atm/ueagle-atm.c | 1 - drivers/usb/atm/xusbatm.c | 1 - drivers/usb/class/audio.c | 1 - drivers/usb/class/cdc-acm.c | 1 - drivers/usb/class/usb-midi.c | 1 - drivers/usb/class/usblp.c | 1 - drivers/usb/core/devio.c | 1 - drivers/usb/core/hub.c | 1 - drivers/usb/image/mdc800.c | 1 - drivers/usb/image/microtek.c | 1 - drivers/usb/input/acecad.c | 1 - drivers/usb/input/aiptek.c | 1 - drivers/usb/input/appletouch.c | 1 - drivers/usb/input/ati_remote.c | 1 - drivers/usb/input/hid-core.c | 1 - drivers/usb/input/hiddev.c | 1 - drivers/usb/input/itmtouch.c | 1 - drivers/usb/input/kbtab.c | 1 - drivers/usb/input/keyspan_remote.c | 1 - drivers/usb/input/mtouchusb.c | 1 - drivers/usb/input/powermate.c | 1 - drivers/usb/input/touchkitusb.c | 1 - drivers/usb/input/usbkbd.c | 1 - drivers/usb/input/usbmouse.c | 1 - drivers/usb/input/wacom.c | 1 - drivers/usb/input/xpad.c | 1 - drivers/usb/input/yealink.c | 1 - drivers/usb/media/dabusb.c | 1 - drivers/usb/media/dsbr100.c | 1 - drivers/usb/media/ov511.c | 1 - drivers/usb/media/pwc/pwc-if.c | 1 - drivers/usb/media/se401.c | 1 - drivers/usb/media/sn9c102_core.c | 1 - drivers/usb/media/stv680.c | 1 - drivers/usb/media/vicam.c | 1 - drivers/usb/media/w9968cf.c | 1 - drivers/usb/misc/auerswald.c | 1 - drivers/usb/misc/cytherm.c | 1 - drivers/usb/misc/emi26.c | 1 - drivers/usb/misc/emi62.c | 1 - drivers/usb/misc/idmouse.c | 1 - drivers/usb/misc/ldusb.c | 1 - drivers/usb/misc/legousbtower.c | 1 - drivers/usb/misc/phidgetkit.c | 1 - drivers/usb/misc/phidgetservo.c | 1 - drivers/usb/misc/rio500.c | 1 - drivers/usb/misc/sisusbvga/sisusb.c | 1 - drivers/usb/misc/usblcd.c | 1 - drivers/usb/misc/usbled.c | 1 - drivers/usb/misc/usbtest.c | 1 - drivers/usb/misc/uss720.c | 1 - drivers/usb/net/asix.c | 1 - drivers/usb/net/catc.c | 1 - drivers/usb/net/cdc_ether.c | 1 - drivers/usb/net/cdc_subset.c | 1 - drivers/usb/net/gl620a.c | 1 - drivers/usb/net/kaweth.c | 1 - drivers/usb/net/net1080.c | 1 - drivers/usb/net/plusb.c | 1 - drivers/usb/net/rndis_host.c | 1 - drivers/usb/net/rtl8150.c | 1 - drivers/usb/net/zaurus.c | 1 - drivers/usb/net/zd1201.c | 1 - drivers/usb/serial/airprime.c | 1 - drivers/usb/serial/anydata.c | 1 - drivers/usb/serial/belkin_sa.c | 1 - drivers/usb/serial/cp2101.c | 1 - drivers/usb/serial/cyberjack.c | 1 - drivers/usb/serial/digi_acceleport.c | 1 - drivers/usb/serial/empeg.c | 1 - drivers/usb/serial/garmin_gps.c | 1 - drivers/usb/serial/generic.c | 1 - drivers/usb/serial/hp4x.c | 1 - drivers/usb/serial/io_edgeport.c | 1 - drivers/usb/serial/io_ti.c | 1 - drivers/usb/serial/ipaq.c | 1 - drivers/usb/serial/ipw.c | 1 - drivers/usb/serial/ir-usb.c | 1 - drivers/usb/serial/keyspan.h | 1 - drivers/usb/serial/keyspan_pda.c | 1 - drivers/usb/serial/kl5kusb105.c | 1 - drivers/usb/serial/kobil_sct.c | 1 - drivers/usb/serial/mct_u232.c | 1 - drivers/usb/serial/omninet.c | 1 - drivers/usb/serial/option.c | 1 - drivers/usb/serial/pl2303.c | 1 - drivers/usb/serial/safe_serial.c | 1 - drivers/usb/serial/ti_usb_3410_5052.c | 1 - drivers/usb/serial/usb-serial.c | 1 - drivers/usb/serial/visor.c | 1 - drivers/usb/serial/whiteheat.c | 1 - drivers/usb/storage/libusual.c | 1 - drivers/usb/storage/usb.c | 1 - drivers/usb/usb-skeleton.c | 1 - drivers/w1/dscore.c | 1 - include/linux/usb.h | 4 ---- sound/usb/usbaudio.c | 1 - sound/usb/usx2y/usbusx2y.c | 1 - 125 files changed, 128 deletions(-) diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 06d741d..c7a28f5 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -2460,7 +2460,6 @@ static void ub_disconnect(struct usb_interface *intf) } static struct usb_driver ub_driver = { - .owner = THIS_MODULE, .name = "ub", .probe = ub_probe, .disconnect = ub_disconnect, diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index 8e7fb35..3e7a067 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c @@ -275,7 +275,6 @@ static void bcm203x_disconnect(struct usb_interface *intf) } static struct usb_driver bcm203x_driver = { - .owner = THIS_MODULE, .name = "bcm203x", .probe = bcm203x_probe, .disconnect = bcm203x_disconnect, diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 067e278..8947c88 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -768,7 +768,6 @@ static void bfusb_disconnect(struct usb_interface *intf) } static struct usb_driver bfusb_driver = { - .owner = THIS_MODULE, .name = "bfusb", .probe = bfusb_probe, .disconnect = bfusb_disconnect, diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 3947963..9446960 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c @@ -619,7 +619,6 @@ static void bpa10x_disconnect(struct usb_interface *intf) } static struct usb_driver bpa10x_driver = { - .owner = THIS_MODULE, .name = "bpa10x", .probe = bpa10x_probe, .disconnect = bpa10x_disconnect, diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index 057cb2b..92382e8 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c @@ -1044,7 +1044,6 @@ static void hci_usb_disconnect(struct usb_interface *intf) } static struct usb_driver hci_usb_driver = { - .owner = THIS_MODULE, .name = "hci_usb", .probe = hci_usb_probe, .disconnect = hci_usb_disconnect, diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c index 092e9b1..1533f56 100644 --- a/drivers/char/watchdog/pcwd_usb.c +++ b/drivers/char/watchdog/pcwd_usb.c @@ -151,7 +151,6 @@ static void usb_pcwd_disconnect (struct usb_interface *interface); /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver usb_pcwd_driver = { - .owner = THIS_MODULE, .name = DRIVER_NAME, .probe = usb_pcwd_probe, .disconnect = usb_pcwd_disconnect, diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index 64b4a30..bc2fce6 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c @@ -235,7 +235,6 @@ static struct usb_device_id iforce_usb_ids [] = { MODULE_DEVICE_TABLE (usb, iforce_usb_ids); struct usb_driver iforce_usb_driver = { - .owner = THIS_MODULE, .name = "iforce", .probe = iforce_usb_probe, .disconnect = iforce_usb_disconnect, diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c index f8457ef..ca5b4a3 100644 --- a/drivers/isdn/hisax/hfc_usb.c +++ b/drivers/isdn/hisax/hfc_usb.c @@ -1715,7 +1715,6 @@ hfc_usb_disconnect(struct usb_interface /* our driver information structure */ /************************************/ static struct usb_driver hfc_drv = { - .owner = THIS_MODULE, .name = "hfc_usb", .id_table = hfcusb_idtab, .probe = hfc_usb_probe, diff --git a/drivers/isdn/hisax/st5481_init.c b/drivers/isdn/hisax/st5481_init.c index 8e192a3..99cb0f3 100644 --- a/drivers/isdn/hisax/st5481_init.c +++ b/drivers/isdn/hisax/st5481_init.c @@ -180,7 +180,6 @@ static struct usb_device_id st5481_ids[] = { MODULE_DEVICE_TABLE (usb, st5481_ids); static struct usb_driver st5481_usb_driver = { - .owner = THIS_MODULE, .name = "st5481_usb", .probe = probe_st5481, .disconnect = disconnect_st5481, diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c index 0a78ba3..a6c91db 100644 --- a/drivers/media/dvb/b2c2/flexcop-usb.c +++ b/drivers/media/dvb/b2c2/flexcop-usb.c @@ -544,7 +544,6 @@ static struct usb_device_id flexcop_usb_table [] = { /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver flexcop_usb_driver = { - .owner = THIS_MODULE, .name = "b2c2_flexcop_usb", .probe = flexcop_usb_probe, .disconnect = flexcop_usb_disconnect, diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index 336fc28..b996fb5 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -986,7 +986,6 @@ static const struct usb_device_id cinergyt2_table [] __devinitdata = { MODULE_DEVICE_TABLE(usb, cinergyt2_table); static struct usb_driver cinergyt2_driver = { - .owner = THIS_MODULE, .name = "cinergyT2", .probe = cinergyt2_probe, .disconnect = cinergyt2_disconnect, diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index 8c7beff..ce44aa6 100644 --- a/drivers/media/dvb/dvb-usb/a800.c +++ b/drivers/media/dvb/dvb-usb/a800.c @@ -144,7 +144,6 @@ static struct dvb_usb_properties a800_properties = { }; static struct usb_driver a800_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_a800", .probe = a800_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 3fe383f..d05fab0 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c @@ -241,7 +241,6 @@ static struct dvb_usb_properties cxusb_properties = { }; static struct usb_driver cxusb_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_cxusb", .probe = cxusb_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index aa271a2..52ac3e5 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c @@ -373,7 +373,6 @@ static struct dvb_usb_properties artec_t1_usb2_properties = { }; static struct usb_driver dibusb_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_dibusb_mb", .probe = dibusb_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c index 6a0912e..55802fb 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c @@ -82,7 +82,6 @@ static struct dvb_usb_properties dibusb_mc_properties = { }; static struct usb_driver dibusb_mc_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_dibusb_mc", .probe = dibusb_mc_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index f98e306..450417a 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c @@ -233,7 +233,6 @@ static struct dvb_usb_properties digitv_properties = { }; static struct usb_driver digitv_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_digitv", .probe = digitv_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index b595476..6e2bac8 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c @@ -198,7 +198,6 @@ static struct dvb_usb_properties wt220u_properties = { /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver dtt200u_usb_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_dtt200u", .probe = dtt200u_usb_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c index 1841a66..fac48fc 100644 --- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c +++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c @@ -202,7 +202,6 @@ static struct dvb_usb_properties nova_t_properties = { }; static struct usb_driver nova_t_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_nova_t_usb2", .probe = nova_t_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 6fd6765..14f1911 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c @@ -128,7 +128,6 @@ static struct dvb_usb_properties umt_properties = { }; static struct usb_driver umt_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_umt_010", .probe = umt_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index de13c04..afa00fd 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c @@ -256,7 +256,6 @@ static struct dvb_usb_properties vp702x_properties = { /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver vp702x_usb_driver = { - .owner = THIS_MODULE, .name = "dvb-usb-vp702x", .probe = vp702x_usb_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index 75765e3..3835235 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c @@ -253,7 +253,6 @@ static struct dvb_usb_properties vp7045_properties = { /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver vp7045_usb_driver = { - .owner = THIS_MODULE, .name = "dvb_usb_vp7045", .probe = vp7045_usb_probe, .disconnect = dvb_usb_device_exit, diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c index 9774e94..1439cb7 100644 --- a/drivers/media/video/cpia_usb.c +++ b/drivers/media/video/cpia_usb.c @@ -582,7 +582,6 @@ MODULE_LICENSE("GPL"); static struct usb_driver cpia_driver = { - .owner = THIS_MODULE, .name = "cpia", .probe = cpia_probe, .disconnect = cpia_disconnect, diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 06d7687..3a56120 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c @@ -1884,7 +1884,6 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) } static struct usb_driver em28xx_usb_driver = { - .owner = THIS_MODULE, .name = "em28xx", .probe = em28xx_usb_probe, .disconnect = em28xx_usb_disconnect, diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index c22c051..fa176ff 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c @@ -1539,7 +1539,6 @@ static void irda_usb_disconnect(struct usb_interface *intf) * USB device callbacks */ static struct usb_driver irda_driver = { - .owner = THIS_MODULE, .name = "irda-usb", .probe = irda_usb_probe, .disconnect = irda_usb_disconnect, diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c index 3961a75..31867e4 100644 --- a/drivers/net/irda/stir4200.c +++ b/drivers/net/irda/stir4200.c @@ -1152,7 +1152,6 @@ static int stir_resume(struct usb_interface *intf) * USB device callbacks */ static struct usb_driver irda_driver = { - .owner = THIS_MODULE, .name = "stir4200", .probe = stir_probe, .disconnect = stir_disconnect, diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index 9d59dc6..af0a41e 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -853,7 +853,6 @@ static int cxacru_usb_probe(struct usb_interface *intf, const struct usb_device_ } static struct usb_driver cxacru_usb_driver = { - .owner = THIS_MODULE, .name = cxacru_driver_name, .probe = cxacru_usb_probe, .disconnect = usbatm_usb_disconnect, diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c index d0cbbb7..b283361 100644 --- a/drivers/usb/atm/speedtch.c +++ b/drivers/usb/atm/speedtch.c @@ -659,7 +659,6 @@ MODULE_DEVICE_TABLE(usb, speedtch_usb_ids); static int speedtch_usb_probe(struct usb_interface *, const struct usb_device_id *); static struct usb_driver speedtch_usb_driver = { - .owner = THIS_MODULE, .name = speedtch_driver_name, .probe = speedtch_usb_probe, .disconnect = usbatm_usb_disconnect, diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index be08e16..7d2a679 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -1776,7 +1776,6 @@ static const struct usb_device_id uea_ids[] = { * USB driver descriptor */ static struct usb_driver uea_driver = { - .owner = THIS_MODULE, .name = "ueagle-atm", .id_table = uea_ids, .probe = uea_probe, diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c index 7fe7fb4..5c76e3a 100644 --- a/drivers/usb/atm/xusbatm.c +++ b/drivers/usb/atm/xusbatm.c @@ -140,7 +140,6 @@ static int xusbatm_usb_probe(struct usb_interface *intf, } static struct usb_driver xusbatm_usb_driver = { - .owner = THIS_MODULE, .name = xusbatm_driver_name, .probe = xusbatm_usb_probe, .disconnect = usbatm_usb_disconnect, diff --git a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c index 5085827..3ad9ee8 100644 --- a/drivers/usb/class/audio.c +++ b/drivers/usb/class/audio.c @@ -2732,7 +2732,6 @@ static struct usb_device_id usb_audio_ids [] = { MODULE_DEVICE_TABLE (usb, usb_audio_ids); static struct usb_driver usb_audio_driver = { - .owner = THIS_MODULE, .name = "audio", .probe = usb_audio_probe, .disconnect = usb_audio_disconnect, diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 72936dc..93de121 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1088,7 +1088,6 @@ static struct usb_device_id acm_ids[] = { MODULE_DEVICE_TABLE (usb, acm_ids); static struct usb_driver acm_driver = { - .owner = THIS_MODULE, .name = "cdc_acm", .probe = acm_probe, .disconnect = acm_disconnect, diff --git a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c index 5f8af35..f13f004 100644 --- a/drivers/usb/class/usb-midi.c +++ b/drivers/usb/class/usb-midi.c @@ -2027,7 +2027,6 @@ static struct usb_device_id id_table[] = { }; static struct usb_driver usb_midi_driver = { - .owner = THIS_MODULE, .name = "midi", .probe = usb_midi_probe, .disconnect = usb_midi_disconnect, diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 357e753..10406b8 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -1186,7 +1186,6 @@ static struct usb_device_id usblp_ids [] = { MODULE_DEVICE_TABLE (usb, usblp_ids); static struct usb_driver usblp_driver = { - .owner = THIS_MODULE, .name = "usblp", .probe = usblp_probe, .disconnect = usblp_disconnect, diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index b1d6e9a..3a73170 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -402,7 +402,6 @@ static void driver_disconnect(struct usb_interface *intf) } struct usb_driver usbfs_driver = { - .owner = THIS_MODULE, .name = "usbfs", .probe = driver_probe, .disconnect = driver_disconnect, diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 5faf7ed..40c6c50 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2865,7 +2865,6 @@ static struct usb_device_id hub_id_table [] = { MODULE_DEVICE_TABLE (usb, hub_id_table); static struct usb_driver hub_driver = { - .owner = THIS_MODULE, .name = "hub", .probe = hub_probe, .disconnect = hub_disconnect, diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c index 1d973bc..0498711 100644 --- a/drivers/usb/image/mdc800.c +++ b/drivers/usb/image/mdc800.c @@ -962,7 +962,6 @@ MODULE_DEVICE_TABLE (usb, mdc800_table); */ static struct usb_driver mdc800_usb_driver = { - .owner = THIS_MODULE, .name = "mdc800", .probe = mdc800_usb_probe, .disconnect = mdc800_usb_disconnect, diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c index 950543a..458f2ac 100644 --- a/drivers/usb/image/microtek.c +++ b/drivers/usb/image/microtek.c @@ -160,7 +160,6 @@ static void mts_usb_disconnect(struct usb_interface *intf); static struct usb_device_id mts_usb_ids []; static struct usb_driver mts_usb_driver = { - .owner = THIS_MODULE, .name = "microtekX6", .probe = mts_usb_probe, .disconnect = mts_usb_disconnect, diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c index a32558b..df29b80 100644 --- a/drivers/usb/input/acecad.c +++ b/drivers/usb/input/acecad.c @@ -261,7 +261,6 @@ static struct usb_device_id usb_acecad_id_table [] = { MODULE_DEVICE_TABLE(usb, usb_acecad_id_table); static struct usb_driver usb_acecad_driver = { - .owner = THIS_MODULE, .name = "usb_acecad", .probe = usb_acecad_probe, .disconnect = usb_acecad_disconnect, diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index 0e2505c..356284c 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c @@ -2190,7 +2190,6 @@ fail1: input_free_device(inputdev); static void aiptek_disconnect(struct usb_interface *intf); static struct usb_driver aiptek_driver = { - .owner = THIS_MODULE, .name = "aiptek", .probe = aiptek_probe, .disconnect = aiptek_disconnect, diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c index 15840db..1949b54 100644 --- a/drivers/usb/input/appletouch.c +++ b/drivers/usb/input/appletouch.c @@ -452,7 +452,6 @@ static int atp_resume(struct usb_interface *iface) } static struct usb_driver atp_driver = { - .owner = THIS_MODULE, .name = "appletouch", .probe = atp_probe, .disconnect = atp_disconnect, diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index 9a2a47d..8948e5c 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c @@ -295,7 +295,6 @@ static void ati_remote_disconnect (struct usb_interface *interface); /* usb specific object to register with the usb subsystem */ static struct usb_driver ati_remote_driver = { - .owner = THIS_MODULE, .name = "ati_remote", .probe = ati_remote_probe, .disconnect = ati_remote_disconnect, diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c index a3e44ef..256d732 100644 --- a/drivers/usb/input/hid-core.c +++ b/drivers/usb/input/hid-core.c @@ -1930,7 +1930,6 @@ static struct usb_device_id hid_usb_ids [] = { MODULE_DEVICE_TABLE (usb, hid_usb_ids); static struct usb_driver hid_driver = { - .owner = THIS_MODULE, .name = "usbhid", .probe = hid_probe, .disconnect = hid_disconnect, diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c index 440377c..4dff847 100644 --- a/drivers/usb/input/hiddev.c +++ b/drivers/usb/input/hiddev.c @@ -826,7 +826,6 @@ static int hiddev_usbd_probe(struct usb_interface *intf, static /* const */ struct usb_driver hiddev_driver = { - .owner = THIS_MODULE, .name = "hiddev", .probe = hiddev_usbd_probe, }; diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c index 4a50acb..7618ae5 100644 --- a/drivers/usb/input/itmtouch.c +++ b/drivers/usb/input/itmtouch.c @@ -250,7 +250,6 @@ static void itmtouch_disconnect(struct usb_interface *intf) MODULE_DEVICE_TABLE(usb, itmtouch_ids); static struct usb_driver itmtouch_driver = { - .owner = THIS_MODULE, .name = "itmtouch", .probe = itmtouch_probe, .disconnect = itmtouch_disconnect, diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c index fd48e74e..f6d5cea 100644 --- a/drivers/usb/input/kbtab.c +++ b/drivers/usb/input/kbtab.c @@ -197,7 +197,6 @@ static void kbtab_disconnect(struct usb_interface *intf) } static struct usb_driver kbtab_driver = { - .owner = THIS_MODULE, .name = "kbtab", .probe = kbtab_probe, .disconnect = kbtab_disconnect, diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c index a32cfe5..5ae5201 100644 --- a/drivers/usb/input/keyspan_remote.c +++ b/drivers/usb/input/keyspan_remote.c @@ -559,7 +559,6 @@ static void keyspan_disconnect(struct usb_interface *interface) */ static struct usb_driver keyspan_driver = { - .owner = THIS_MODULE, .name = "keyspan_remote", .probe = keyspan_probe, .disconnect = keyspan_disconnect, diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c index 52cc18c..f018953 100644 --- a/drivers/usb/input/mtouchusb.c +++ b/drivers/usb/input/mtouchusb.c @@ -310,7 +310,6 @@ static void mtouchusb_disconnect(struct usb_interface *intf) MODULE_DEVICE_TABLE(usb, mtouchusb_devices); static struct usb_driver mtouchusb_driver = { - .owner = THIS_MODULE, .name = "mtouchusb", .probe = mtouchusb_probe, .disconnect = mtouchusb_disconnect, diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c index b747623..fdf0f78 100644 --- a/drivers/usb/input/powermate.c +++ b/drivers/usb/input/powermate.c @@ -441,7 +441,6 @@ static struct usb_device_id powermate_devices [] = { MODULE_DEVICE_TABLE (usb, powermate_devices); static struct usb_driver powermate_driver = { - .owner = THIS_MODULE, .name = "powermate", .probe = powermate_probe, .disconnect = powermate_disconnect, diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c index 7420c6b..75e7c12 100644 --- a/drivers/usb/input/touchkitusb.c +++ b/drivers/usb/input/touchkitusb.c @@ -267,7 +267,6 @@ static void touchkit_disconnect(struct usb_interface *intf) MODULE_DEVICE_TABLE(usb, touchkit_devices); static struct usb_driver touchkit_driver = { - .owner = THIS_MODULE, .name = "touchkitusb", .probe = touchkit_probe, .disconnect = touchkit_disconnect, diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c index 226b6f9..2f3edc2 100644 --- a/drivers/usb/input/usbkbd.c +++ b/drivers/usb/input/usbkbd.c @@ -345,7 +345,6 @@ static struct usb_device_id usb_kbd_id_table [] = { MODULE_DEVICE_TABLE (usb, usb_kbd_id_table); static struct usb_driver usb_kbd_driver = { - .owner = THIS_MODULE, .name = "usbkbd", .probe = usb_kbd_probe, .disconnect = usb_kbd_disconnect, diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c index 230f6b1..af52613 100644 --- a/drivers/usb/input/usbmouse.c +++ b/drivers/usb/input/usbmouse.c @@ -226,7 +226,6 @@ static struct usb_device_id usb_mouse_id_table [] = { MODULE_DEVICE_TABLE (usb, usb_mouse_id_table); static struct usb_driver usb_mouse_driver = { - .owner = THIS_MODULE, .name = "usbmouse", .probe = usb_mouse_probe, .disconnect = usb_mouse_disconnect, diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c index dc099bb..48df4cf 100644 --- a/drivers/usb/input/wacom.c +++ b/drivers/usb/input/wacom.c @@ -945,7 +945,6 @@ static void wacom_disconnect(struct usb_interface *intf) } static struct usb_driver wacom_driver = { - .owner = THIS_MODULE, .name = "wacom", .probe = wacom_probe, .disconnect = wacom_disconnect, diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c index 43112f0..e421328 100644 --- a/drivers/usb/input/xpad.c +++ b/drivers/usb/input/xpad.c @@ -316,7 +316,6 @@ static void xpad_disconnect(struct usb_interface *intf) } static struct usb_driver xpad_driver = { - .owner = THIS_MODULE, .name = "xpad", .probe = xpad_probe, .disconnect = xpad_disconnect, diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c index f526aeb..1bfc105 100644 --- a/drivers/usb/input/yealink.c +++ b/drivers/usb/input/yealink.c @@ -987,7 +987,6 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) } static struct usb_driver yealink_driver = { - .owner = THIS_MODULE, .name = "yealink", .probe = usb_probe, .disconnect = usb_disconnect, diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c index 27b23c5..18d8eaf 100644 --- a/drivers/usb/media/dabusb.c +++ b/drivers/usb/media/dabusb.c @@ -812,7 +812,6 @@ static struct usb_device_id dabusb_ids [] = { MODULE_DEVICE_TABLE (usb, dabusb_ids); static struct usb_driver dabusb_driver = { - .owner = THIS_MODULE, .name = "dabusb", .probe = dabusb_probe, .disconnect = dabusb_disconnect, diff --git a/drivers/usb/media/dsbr100.c b/drivers/usb/media/dsbr100.c index 7503f5b..6a5700e 100644 --- a/drivers/usb/media/dsbr100.c +++ b/drivers/usb/media/dsbr100.c @@ -150,7 +150,6 @@ MODULE_DEVICE_TABLE (usb, usb_dsbr100_device_table); /* USB subsystem interface */ static struct usb_driver usb_dsbr100_driver = { - .owner = THIS_MODULE, .name = "dsbr100", .probe = usb_dsbr100_probe, .disconnect = usb_dsbr100_disconnect, diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c index 036c485..8df4f9d 100644 --- a/drivers/usb/media/ov511.c +++ b/drivers/usb/media/ov511.c @@ -6008,7 +6008,6 @@ ov51x_disconnect(struct usb_interface *intf) } static struct usb_driver ov511_driver = { - .owner = THIS_MODULE, .name = "ov511", .id_table = device_table, .probe = ov51x_probe, diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c index 5524fd7..09ca612 100644 --- a/drivers/usb/media/pwc/pwc-if.c +++ b/drivers/usb/media/pwc/pwc-if.c @@ -111,7 +111,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id static void usb_pwc_disconnect(struct usb_interface *intf); static struct usb_driver pwc_driver = { - .owner = THIS_MODULE, .name = "Philips webcam", /* name */ .id_table = pwc_device_table, .probe = usb_pwc_probe, /* probe() */ diff --git a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c index f69e443..b2ae29a 100644 --- a/drivers/usb/media/se401.c +++ b/drivers/usb/media/se401.c @@ -1401,7 +1401,6 @@ static void se401_disconnect(struct usb_interface *intf) } static struct usb_driver se401_driver = { - .owner = THIS_MODULE, .name = "se401", .id_table = device_table, .probe = se401_probe, diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c index b2e66e3..0872345 100644 --- a/drivers/usb/media/sn9c102_core.c +++ b/drivers/usb/media/sn9c102_core.c @@ -2711,7 +2711,6 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf) static struct usb_driver sn9c102_usb_driver = { - .owner = THIS_MODULE, .name = "sn9c102", .id_table = sn9c102_id_table, .probe = sn9c102_usb_probe, diff --git a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c index 0fd0fa9..774038b 100644 --- a/drivers/usb/media/stv680.c +++ b/drivers/usb/media/stv680.c @@ -1477,7 +1477,6 @@ static void stv680_disconnect (struct usb_interface *intf) } static struct usb_driver stv680_driver = { - .owner = THIS_MODULE, .name = "stv680", .probe = stv680_probe, .disconnect = stv680_disconnect, diff --git a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c index 0bc0b12..1c73155 100644 --- a/drivers/usb/media/vicam.c +++ b/drivers/usb/media/vicam.c @@ -1257,7 +1257,6 @@ static struct usb_device_id vicam_table[] = { MODULE_DEVICE_TABLE(usb, vicam_table); static struct usb_driver vicam_driver = { - .owner = THIS_MODULE, .name = "vicam", .probe = vicam_probe, .disconnect = vicam_disconnect, diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 67612c8..52b90d5 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -3668,7 +3668,6 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf) static struct usb_driver w9968cf_usb_driver = { - .owner = THIS_MODULE, .name = "w9968cf", .id_table = winbond_id_table, .probe = w9968cf_usb_probe, diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index b293db3..fad387f 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -2103,7 +2103,6 @@ MODULE_DEVICE_TABLE (usb, auerswald_ids); /* Standard usb driver struct */ static struct usb_driver auerswald_driver = { - .owner = THIS_MODULE, .name = "auerswald", .probe = auerswald_probe, .disconnect = auerswald_disconnect, diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index b33044d..6671317 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c @@ -50,7 +50,6 @@ static void cytherm_disconnect(struct usb_interface *interface); /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver cytherm_driver = { - .owner = THIS_MODULE, .name = "cytherm", .probe = cytherm_probe, .disconnect = cytherm_disconnect, diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index c815520..3824df3 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c @@ -227,7 +227,6 @@ static void emi26_disconnect(struct usb_interface *intf) } static struct usb_driver emi26_driver = { - .owner = THIS_MODULE, .name = "emi26 - firmware loader", .probe = emi26_probe, .disconnect = emi26_disconnect, diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 189986a..52fea2e 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c @@ -266,7 +266,6 @@ static void emi62_disconnect(struct usb_interface *intf) } static struct usb_driver emi62_driver = { - .owner = THIS_MODULE, .name = "emi62 - firmware loader", .probe = emi62_probe, .disconnect = emi62_disconnect, diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index 1dc3e0f..d8cde10 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -114,7 +114,6 @@ static struct usb_class_driver idmouse_class = { /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver idmouse_driver = { - .owner = THIS_MODULE, .name = DRIVER_SHORT, .probe = idmouse_probe, .disconnect = idmouse_disconnect, diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 7e93ac9..981d8a5 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -763,7 +763,6 @@ static void ld_usb_disconnect(struct usb_interface *intf) /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver ld_usb_driver = { - .owner = THIS_MODULE, .name = "ldusb", .probe = ld_usb_probe, .disconnect = ld_usb_disconnect, diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 2703e20..1336745 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -282,7 +282,6 @@ static struct usb_class_driver tower_class = { /* usb specific object needed to register this driver with the usb subsystem */ static struct usb_driver tower_driver = { - .owner = THIS_MODULE, .name = "legousbtower", .probe = tower_probe, .disconnect = tower_disconnect, diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c index 067a814..605a3c8 100644 --- a/drivers/usb/misc/phidgetkit.c +++ b/drivers/usb/misc/phidgetkit.c @@ -555,7 +555,6 @@ static void interfacekit_disconnect(struct usb_interface *interface) } static struct usb_driver interfacekit_driver = { - .owner = THIS_MODULE, .name = "phidgetkit", .probe = interfacekit_probe, .disconnect = interfacekit_disconnect, diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c index a30d4a6..b3418d2 100644 --- a/drivers/usb/misc/phidgetservo.c +++ b/drivers/usb/misc/phidgetservo.c @@ -306,7 +306,6 @@ servo_disconnect(struct usb_interface *interface) } static struct usb_driver servo_driver = { - .owner = THIS_MODULE, .name = "phidgetservo", .probe = servo_probe, .disconnect = servo_disconnect, diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index 9590dba..b9d6607 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c @@ -522,7 +522,6 @@ static struct usb_device_id rio_table [] = { MODULE_DEVICE_TABLE (usb, rio_table); static struct usb_driver rio_driver = { - .owner = THIS_MODULE, .name = "rio500", .probe = probe_rio, .disconnect = disconnect_rio, diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 41ef2b6..44350d4 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -3489,7 +3489,6 @@ static struct usb_device_id sisusb_table [] = { MODULE_DEVICE_TABLE (usb, sisusb_table); static struct usb_driver sisusb_driver = { - .owner = THIS_MODULE, .name = "sisusb", .probe = sisusb_probe, .disconnect = sisusb_disconnect, diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 85f3725..cc3dae3 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c @@ -371,7 +371,6 @@ static void lcd_disconnect(struct usb_interface *interface) } static struct usb_driver lcd_driver = { - .owner = THIS_MODULE, .name = "usblcd", .probe = lcd_probe, .disconnect = lcd_disconnect, diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c index 3c93921..877b081 100644 --- a/drivers/usb/misc/usbled.c +++ b/drivers/usb/misc/usbled.c @@ -148,7 +148,6 @@ static void led_disconnect(struct usb_interface *interface) } static struct usb_driver led_driver = { - .owner = THIS_MODULE, .name = "usbled", .probe = led_probe, .disconnect = led_disconnect, diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 605a2af..84fa172 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -2134,7 +2134,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver usbtest_driver = { - .owner = THIS_MODULE, .name = "usbtest", .id_table = id_table, .probe = usbtest_probe, diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c index 1cabe7e..4081990 100644 --- a/drivers/usb/misc/uss720.c +++ b/drivers/usb/misc/uss720.c @@ -780,7 +780,6 @@ MODULE_DEVICE_TABLE (usb, uss720_table); static struct usb_driver uss720_driver = { - .owner = THIS_MODULE, .name = "uss720", .probe = uss720_probe, .disconnect = uss720_disconnect, diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c index 542120e..2faf2f2 100644 --- a/drivers/usb/net/asix.c +++ b/drivers/usb/net/asix.c @@ -918,7 +918,6 @@ static const struct usb_device_id products [] = { MODULE_DEVICE_TABLE(usb, products); static struct usb_driver asix_driver = { - .owner = THIS_MODULE, .name = "asix", .id_table = products, .probe = usbnet_probe, diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c index 37ef365..be5f5e1 100644 --- a/drivers/usb/net/catc.c +++ b/drivers/usb/net/catc.c @@ -934,7 +934,6 @@ static struct usb_device_id catc_id_table [] = { MODULE_DEVICE_TABLE(usb, catc_id_table); static struct usb_driver catc_driver = { - .owner = THIS_MODULE, .name = driver_name, .probe = catc_probe, .disconnect = catc_disconnect, diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c index c008c98..63f1f3b 100644 --- a/drivers/usb/net/cdc_ether.c +++ b/drivers/usb/net/cdc_ether.c @@ -476,7 +476,6 @@ static const struct usb_device_id products [] = { MODULE_DEVICE_TABLE(usb, products); static struct usb_driver cdc_driver = { - .owner = THIS_MODULE, .name = "cdc_ether", .id_table = products, .probe = usbnet_probe, diff --git a/drivers/usb/net/cdc_subset.c b/drivers/usb/net/cdc_subset.c index f05cfb8..ec801e8 100644 --- a/drivers/usb/net/cdc_subset.c +++ b/drivers/usb/net/cdc_subset.c @@ -306,7 +306,6 @@ MODULE_DEVICE_TABLE(usb, products); /*-------------------------------------------------------------------------*/ static struct usb_driver cdc_subset_driver = { - .owner = THIS_MODULE, .name = "cdc_subset", .probe = usbnet_probe, .suspend = usbnet_suspend, diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c index 2455e9a..faf1e86 100644 --- a/drivers/usb/net/gl620a.c +++ b/drivers/usb/net/gl620a.c @@ -377,7 +377,6 @@ static const struct usb_device_id products [] = { MODULE_DEVICE_TABLE(usb, products); static struct usb_driver gl620a_driver = { - .owner = THIS_MODULE, .name = "gl620a", .id_table = products, .probe = usbnet_probe, diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c index b577651..def3bb8 100644 --- a/drivers/usb/net/kaweth.c +++ b/drivers/usb/net/kaweth.c @@ -175,7 +175,6 @@ MODULE_DEVICE_TABLE (usb, usb_klsi_table); * kaweth_driver ****************************************************************/ static struct usb_driver kaweth_driver = { - .owner = THIS_MODULE, .name = driver_name, .probe = kaweth_probe, .disconnect = kaweth_disconnect, diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c index b3799b1..78e6a43 100644 --- a/drivers/usb/net/net1080.c +++ b/drivers/usb/net/net1080.c @@ -593,7 +593,6 @@ static const struct usb_device_id products [] = { MODULE_DEVICE_TABLE(usb, products); static struct usb_driver net1080_driver = { - .owner = THIS_MODULE, .name = "net1080", .id_table = products, .probe = usbnet_probe, diff --git a/drivers/usb/net/plusb.c b/drivers/usb/net/plusb.c index 89856aa..4fe8633 100644 --- a/drivers/usb/net/plusb.c +++ b/drivers/usb/net/plusb.c @@ -127,7 +127,6 @@ static const struct usb_device_id products [] = { MODULE_DEVICE_TABLE(usb, products); static struct usb_driver plusb_driver = { - .owner = THIS_MODULE, .name = "plusb", .id_table = products, .probe = usbnet_probe, diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c index c0ecbab..49991ac 100644 --- a/drivers/usb/net/rndis_host.c +++ b/drivers/usb/net/rndis_host.c @@ -586,7 +586,6 @@ static const struct usb_device_id products [] = { MODULE_DEVICE_TABLE(usb, products); static struct usb_driver rndis_driver = { - .owner = THIS_MODULE, .name = "rndis_host", .id_table = products, .probe = usbnet_probe, diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c index 787dd35..8ca52be 100644 --- a/drivers/usb/net/rtl8150.c +++ b/drivers/usb/net/rtl8150.c @@ -177,7 +177,6 @@ static int rtl8150_probe(struct usb_interface *intf, static const char driver_name [] = "rtl8150"; static struct usb_driver rtl8150_driver = { - .owner = THIS_MODULE, .name = driver_name, .probe = rtl8150_probe, .disconnect = rtl8150_disconnect, diff --git a/drivers/usb/net/zaurus.c b/drivers/usb/net/zaurus.c index 680d139..9c5ab25 100644 --- a/drivers/usb/net/zaurus.c +++ b/drivers/usb/net/zaurus.c @@ -357,7 +357,6 @@ static const struct usb_device_id products [] = { MODULE_DEVICE_TABLE(usb, products); static struct usb_driver zaurus_driver = { - .owner = THIS_MODULE, .name = "zaurus", .id_table = products, .probe = usbnet_probe, diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index 2f52261..4d6673a 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c @@ -1923,7 +1923,6 @@ static int zd1201_resume(struct usb_interface *interface) #endif static struct usb_driver zd1201_usb = { - .owner = THIS_MODULE, .name = "zd1201", .probe = zd1201_probe, .disconnect = zd1201_disconnect, diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c index 2ef9945..dbf1f063 100644 --- a/drivers/usb/serial/airprime.c +++ b/drivers/usb/serial/airprime.c @@ -23,7 +23,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver airprime_driver = { - .owner = THIS_MODULE, .name = "airprime", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/anydata.c b/drivers/usb/serial/anydata.c index 7a171e0..343f6f2 100644 --- a/drivers/usb/serial/anydata.c +++ b/drivers/usb/serial/anydata.c @@ -27,7 +27,6 @@ static int buffer_size; static int debug; static struct usb_driver anydata_driver = { - .owner = THIS_MODULE, .name = "anydata", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 69039bd..4144777 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -113,7 +113,6 @@ static struct usb_device_id id_table_combined [] = { MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_driver belkin_driver = { - .owner = THIS_MODULE, .name = "belkin", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c index 813bab3..da46b35 100644 --- a/drivers/usb/serial/cp2101.c +++ b/drivers/usb/serial/cp2101.c @@ -67,7 +67,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver cp2101_driver = { - .owner = THIS_MODULE, .name = "cp2101", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 8c10e40..6d18d4e 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -76,7 +76,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver cyberjack_driver = { - .owner = THIS_MODULE, .name = "cyberjack", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index c50cec9..8fc414b 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c @@ -493,7 +493,6 @@ static struct usb_device_id id_table_4 [] = { MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_driver digi_driver = { - .owner = THIS_MODULE, .name = "digi_acceleport", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index e5e40064..79a766e 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c @@ -105,7 +105,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver empeg_driver = { - .owner = THIS_MODULE, .name = "empeg", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 198a3222..452efce 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -222,7 +222,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver garmin_driver = { - .owner = THIS_MODULE, .name = "garmin_gps", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index c00a440..4ddac62 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c @@ -68,7 +68,6 @@ static int generic_probe(struct usb_interface *interface, } static struct usb_driver generic_driver = { - .owner = THIS_MODULE, .name = "usbserial_generic", .probe = generic_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index e588c3f..e9719da 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c @@ -37,7 +37,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE(usb, id_table); static struct usb_driver hp49gp_driver = { - .owner = THIS_MODULE, .name = "hp4X", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 276bd42..4e2b599 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -242,7 +242,6 @@ static void edge_shutdown (struct usb_serial *serial); #include "io_tables.h" /* all of the devices that this driver supports */ static struct usb_driver io_driver = { - .owner = THIS_MODULE, .name = "io_edgeport", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 8b2e4c7..22ad1a5 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -216,7 +216,6 @@ static struct usb_device_id id_table_combined [] = { MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_driver io_driver = { - .owner = THIS_MODULE, .name = "io_ti", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index efb568b..06d07ce 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -542,7 +542,6 @@ static struct usb_device_id ipaq_id_table [] = { MODULE_DEVICE_TABLE (usb, ipaq_id_table); static struct usb_driver ipaq_driver = { - .owner = THIS_MODULE, .name = "ipaq", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 64e2cda..2dd191f 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -152,7 +152,6 @@ static struct usb_device_id usb_ipw_ids[] = { MODULE_DEVICE_TABLE(usb, usb_ipw_ids); static struct usb_driver usb_ipw_driver = { - .owner = THIS_MODULE, .name = "ipwtty", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 647431c..a590104 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c @@ -125,7 +125,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver ir_driver = { - .owner = THIS_MODULE, .name = "ir-usb", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index 4e6f626..7472ed6 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h @@ -520,7 +520,6 @@ static struct usb_device_id keyspan_ids_combined[] = { MODULE_DEVICE_TABLE(usb, keyspan_ids_combined); static struct usb_driver keyspan_driver = { - .owner = THIS_MODULE, .name = "keyspan", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 0d1f152..b0441c3 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -150,7 +150,6 @@ static struct usb_device_id id_table_combined [] = { MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_driver keyspan_pda_driver = { - .owner = THIS_MODULE, .name = "keyspan_pda", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index bd68638..4e2f7df 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -116,7 +116,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver kl5kusb105d_driver = { - .owner = THIS_MODULE, .name = "kl5kusb105d", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index 4c853af..d9c21e2 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c @@ -97,7 +97,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver kobil_driver = { - .owner = THIS_MODULE, .name = "kobil", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index b0415e7..b6d6cab 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c @@ -125,7 +125,6 @@ static struct usb_device_id id_table_combined [] = { MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_driver mct_u232_driver = { - .owner = THIS_MODULE, .name = "mct_u232", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index b595bef..762d8ff 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c @@ -80,7 +80,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver omninet_driver = { - .owner = THIS_MODULE, .name = "omninet", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 4ee657e..3fd2405 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c @@ -95,7 +95,6 @@ static struct usb_device_id option_ids[] = { MODULE_DEVICE_TABLE(usb, option_ids); static struct usb_driver option_driver = { - .owner = THIS_MODULE, .name = "option", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index e302a32..c96ba9f 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -82,7 +82,6 @@ static struct usb_device_id id_table [] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver pl2303_driver = { - .owner = THIS_MODULE, .name = "pl2303", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index f8241c1..3ea284c 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -160,7 +160,6 @@ static struct usb_device_id id_table[] = { MODULE_DEVICE_TABLE (usb, id_table); static struct usb_driver safe_driver = { - .owner = THIS_MODULE, .name = "safe_serial", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 17a1f09..9e53ec7 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -248,7 +248,6 @@ static struct usb_device_id ti_id_table_combined[] = { }; static struct usb_driver ti_usb_driver = { - .owner = THIS_MODULE, .name = "ti_usb_3410_5052", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 2ac37b5..12aaf18 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -42,7 +42,6 @@ /* Driver structure we register with the USB core */ static struct usb_driver usb_serial_driver = { - .owner = THIS_MODULE, .name = "usbserial", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 2973f55..49b1fbe 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c @@ -173,7 +173,6 @@ static struct usb_device_id id_table_combined [] = { MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_driver visor_driver = { - .owner = THIS_MODULE, .name = "visor", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 19c6386..a7c3c47 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c @@ -127,7 +127,6 @@ static struct usb_device_id id_table_combined [] = { MODULE_DEVICE_TABLE (usb, id_table_combined); static struct usb_driver whiteheat_driver = { - .owner = THIS_MODULE, .name = "whiteheat", .probe = usb_serial_probe, .disconnect = usb_serial_disconnect, diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c index 2680c69..b28151d 100644 --- a/drivers/usb/storage/libusual.c +++ b/drivers/usb/storage/libusual.c @@ -153,7 +153,6 @@ static void usu_disconnect(struct usb_interface *intf) } static struct usb_driver usu_driver = { - .owner = THIS_MODULE, .name = "libusual", .probe = usu_probe, .disconnect = usu_disconnect, diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index c8375aa..484ed29 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -1000,7 +1000,6 @@ static void storage_disconnect(struct usb_interface *intf) ***********************************************************************/ static struct usb_driver usb_storage_driver = { - .owner = THIS_MODULE, .name = "usb-storage", .probe = storage_probe, .disconnect = storage_disconnect, diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 6c3a53f..60c458e 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -330,7 +330,6 @@ static void skel_disconnect(struct usb_interface *interface) } static struct usb_driver skel_driver = { - .owner = THIS_MODULE, .name = "skeleton", .probe = skel_probe, .disconnect = skel_disconnect, diff --git a/drivers/w1/dscore.c b/drivers/w1/dscore.c index 15fb250..b914630 100644 --- a/drivers/w1/dscore.c +++ b/drivers/w1/dscore.c @@ -52,7 +52,6 @@ static int ds_send_control_cmd(struct ds_device *, u16, u16); static struct usb_driver ds_driver = { - .owner = THIS_MODULE, .name = "DS9490R", .probe = ds_probe, .disconnect = ds_disconnect, diff --git a/include/linux/usb.h b/include/linux/usb.h index 3d05c63..2714814 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -536,8 +536,6 @@ struct usb_dynids { /** * struct usb_driver - identifies USB driver to usbcore - * @owner: Pointer to the module owner of this driver; initialize - * it using THIS_MODULE. * @name: The driver name should be unique among USB drivers, * and should normally be the same as the module name. * @probe: Called to see if the driver is willing to manage a particular @@ -580,8 +578,6 @@ struct usb_dynids { * them as necessary, and blocking until the unlinks complete). */ struct usb_driver { - struct module *owner; - const char *name; int (*probe) (struct usb_interface *intf, diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 99dae02..22f8bb6 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -1996,7 +1996,6 @@ static struct usb_device_id usb_audio_ids [] = { MODULE_DEVICE_TABLE (usb, usb_audio_ids); static struct usb_driver usb_audio_driver = { - .owner = THIS_MODULE, .name = "snd-usb-audio", .probe = usb_audio_probe, .disconnect = usb_audio_disconnect, diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index cf77313..a3967f7 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c @@ -409,7 +409,6 @@ static void snd_usX2Y_disconnect(struct usb_interface *intf) MODULE_DEVICE_TABLE(usb, snd_usX2Y_usb_id_table); static struct usb_driver snd_usX2Y_usb_driver = { - .owner = THIS_MODULE, .name = "snd-usb-usx2y", .probe = snd_usX2Y_probe, .disconnect = snd_usX2Y_disconnect, -- cgit v1.1 From 9ad3d6ccf5eee285e233dbaf186369b8d477a666 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 17 Nov 2005 17:10:32 -0500 Subject: [PATCH] USB: Remove USB private semaphore This patch (as605) removes the private udev->serialize semaphore, relying instead on the locking provided by the embedded struct device's semaphore. The changes are confined to the core, except that the usb_trylock_device routine now uses the return convention of down_trylock rather than down_read_trylock (they return opposite values for no good reason). A couple of other associated changes are included as well: Now that we aren't concerned about HCDs that avoid using the hcd glue layer, usb_disconnect no longer needs to acquire the usb_bus_lock -- that can be done by usb_remove_hcd where it belongs. Devices aren't locked over the same scope of code in usb_new_device and hub_port_connect_change as they used to be. This shouldn't cause any trouble. Along with the preceding driver core patch, this needs a lot of testing. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/devices.c | 4 +- drivers/usb/core/devio.c | 2 - drivers/usb/core/driver.c | 4 -- drivers/usb/core/hcd.c | 5 +- drivers/usb/core/hub.c | 48 +++++++------------ drivers/usb/core/usb.c | 114 ++++---------------------------------------- drivers/usb/core/usb.h | 3 -- drivers/usb/host/ohci-hub.c | 2 +- include/linux/usb.h | 9 ++-- 9 files changed, 37 insertions(+), 154 deletions(-) diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 83e815d..55bc563 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -545,10 +545,10 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski struct usb_device *childdev = usbdev->children[chix]; if (childdev) { - down(&childdev->serialize); + usb_lock_device(childdev); ret = usb_device_dump(buffer, nbytes, skip_bytes, file_offset, childdev, bus, level + 1, chix, ++cnt); - up(&childdev->serialize); + usb_unlock_device(childdev); if (ret == -EFAULT) return total_written; total_written += ret; diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 3a73170..2b68998 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1349,9 +1349,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl) /* let kernel drivers try to (re)bind to the interface */ case USBDEVFS_CONNECT: usb_unlock_device(ps->dev); - usb_lock_all_devices(); bus_rescan_devices(intf->dev.bus); - usb_unlock_all_devices(); usb_lock_device(ps->dev); break; diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index bb139f0..076462c 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -432,9 +432,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner) spin_lock_init(&new_driver->dynids.lock); INIT_LIST_HEAD(&new_driver->dynids.list); - usb_lock_all_devices(); retval = driver_register(&new_driver->driver); - usb_unlock_all_devices(); if (!retval) { pr_info("%s: registered new driver %s\n", @@ -465,11 +463,9 @@ void usb_deregister(struct usb_driver *driver) { pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name); - usb_lock_all_devices(); usb_remove_newid_file(driver); usb_free_dynids(driver); driver_unregister(&driver->driver); - usb_unlock_all_devices(); usbfs_update_special(); } diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index da24c31..d16a0e8 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -857,9 +857,7 @@ static int register_root_hub (struct usb_device *usb_dev, return (retval < 0) ? retval : -EMSGSIZE; } - usb_lock_device (usb_dev); retval = usb_new_device (usb_dev); - usb_unlock_device (usb_dev); if (retval) { usb_dev->bus->root_hub = NULL; dev_err (parent_dev, "can't register root hub for %s, %d\n", @@ -1891,7 +1889,10 @@ void usb_remove_hcd(struct usb_hcd *hcd) spin_lock_irq (&hcd_root_hub_lock); hcd->rh_registered = 0; spin_unlock_irq (&hcd_root_hub_lock); + + down(&usb_bus_list_lock); usb_disconnect(&hcd->self.root_hub); + up(&usb_bus_list_lock); hcd->poll_rh = 0; del_timer_sync(&hcd->rh_timer); diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 40c6c50..dd3bcfb 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -32,7 +32,7 @@ #include "hub.h" /* Protect struct usb_device->state and ->children members - * Note: Both are also protected by ->serialize, except that ->state can + * Note: Both are also protected by ->dev.sem, except that ->state can * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ static DEFINE_SPINLOCK(device_state_lock); @@ -975,8 +975,8 @@ static int locktree(struct usb_device *udev) /* when everyone grabs locks top->bottom, * non-overlapping work may be concurrent */ - down(&udev->serialize); - up(&hdev->serialize); + usb_lock_device(udev); + usb_unlock_device(hdev); return t + 1; } } @@ -1132,16 +1132,10 @@ void usb_disconnect(struct usb_device **pdev) * this quiesces everyting except pending urbs. */ usb_set_device_state(udev, USB_STATE_NOTATTACHED); - - /* lock the bus list on behalf of HCDs unregistering their root hubs */ - if (!udev->parent) { - down(&usb_bus_list_lock); - usb_lock_device(udev); - } else - down(&udev->serialize); - dev_info (&udev->dev, "USB disconnect, address %d\n", udev->devnum); + usb_lock_device(udev); + /* Free up all the children before we remove this device */ for (i = 0; i < USB_MAXCHILDREN; i++) { if (udev->children[i]) @@ -1169,11 +1163,7 @@ void usb_disconnect(struct usb_device **pdev) *pdev = NULL; spin_unlock_irq(&device_state_lock); - if (!udev->parent) { - usb_unlock_device(udev); - up(&usb_bus_list_lock); - } else - up(&udev->serialize); + usb_unlock_device(udev); device_unregister(&udev->dev); } @@ -1243,8 +1233,8 @@ static inline void show_string(struct usb_device *udev, char *id, char *string) * * This is called with devices which have been enumerated, but not yet * configured. The device descriptor is available, but not descriptors - * for any device configuration. The caller must have locked udev and - * either the parent hub (if udev is a normal device) or else the + * for any device configuration. The caller must have locked either + * the parent hub (if udev is a normal device) or else the * usb_bus_list_lock (if udev is a root hub). The parent's pointer to * udev has already been installed, but udev is not yet visible through * sysfs or other filesystem code. @@ -1254,8 +1244,7 @@ static inline void show_string(struct usb_device *udev, char *id, char *string) * * This call is synchronous, and may not be used in an interrupt context. * - * Only the hub driver should ever call this; root hub registration - * uses it indirectly. + * Only the hub driver or root-hub registrar should ever call this. */ int usb_new_device(struct usb_device *udev) { @@ -1364,6 +1353,8 @@ int usb_new_device(struct usb_device *udev) } usb_create_sysfs_dev_files (udev); + usb_lock_device(udev); + /* choose and set the configuration. that registers the interfaces * with the driver core, and lets usb device drivers bind to them. */ @@ -1385,6 +1376,8 @@ int usb_new_device(struct usb_device *udev) /* USB device state == configured ... usable */ usb_notify_add_device(udev); + usb_unlock_device(udev); + return 0; fail: @@ -1872,11 +1865,8 @@ int usb_resume_device(struct usb_device *udev) usb_unlock_device(udev); /* rebind drivers that had no suspend() */ - if (status == 0) { - usb_lock_all_devices(); + if (status == 0) bus_rescan_devices(&usb_bus_type); - usb_unlock_all_devices(); - } return status; } @@ -1889,14 +1879,14 @@ static int remote_wakeup(struct usb_device *udev) /* don't repeat RESUME sequence if this device * was already woken up by some other task */ - down(&udev->serialize); + usb_lock_device(udev); if (udev->state == USB_STATE_SUSPENDED) { dev_dbg(&udev->dev, "RESUME (wakeup)\n"); /* TRSMRCY = 10 msec */ msleep(10); status = finish_device_resume(udev); } - up(&udev->serialize); + usb_unlock_device(udev); #endif return status; } @@ -1997,7 +1987,7 @@ static int hub_resume(struct usb_interface *intf) if (!udev || status < 0) continue; - down (&udev->serialize); + usb_lock_device(udev); if (portstat & USB_PORT_STAT_SUSPEND) status = hub_port_resume(hub, port1, udev); else { @@ -2008,7 +1998,7 @@ static int hub_resume(struct usb_interface *intf) hub_port_logical_disconnect(hub, port1); } } - up(&udev->serialize); + usb_unlock_device(udev); } } #endif @@ -2573,7 +2563,6 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, * udev becomes globally accessible, although presumably * no one will look at it until hdev is unlocked. */ - down (&udev->serialize); status = 0; /* We mustn't add new devices if the parent hub has @@ -2597,7 +2586,6 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, } } - up (&udev->serialize); if (status) goto loop_disable; diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 294e9f1..fcfda21 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -49,8 +48,6 @@ const char *usbcore_name = "usbcore"; static int nousb; /* Disable USB when built into kernel image */ /* Not honored on modular build */ -static DECLARE_RWSEM(usb_all_devices_rwsem); - /** * usb_ifnum_to_if - get the interface object with a given interface number @@ -446,8 +443,6 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) dev->parent = parent; INIT_LIST_HEAD(&dev->filelist); - init_MUTEX(&dev->serialize); - return dev; } @@ -520,76 +515,21 @@ void usb_put_intf(struct usb_interface *intf) /* USB device locking * - * Although locking USB devices should be straightforward, it is - * complicated by the way the driver-model core works. When a new USB - * driver is registered or unregistered, the core will automatically - * probe or disconnect all matching interfaces on all USB devices while - * holding the USB subsystem writelock. There's no good way for us to - * tell which devices will be used or to lock them beforehand; our only - * option is to effectively lock all the USB devices. - * - * We do that by using a private rw-semaphore, usb_all_devices_rwsem. - * When locking an individual device you must first acquire the rwsem's - * readlock. When a driver is registered or unregistered the writelock - * must be held. These actions are encapsulated in the subroutines - * below, so all a driver needs to do is call usb_lock_device() and - * usb_unlock_device(). + * USB devices and interfaces are locked using the semaphore in their + * embedded struct device. The hub driver guarantees that whenever a + * device is connected or disconnected, drivers are called with the + * USB device locked as well as their particular interface. * * Complications arise when several devices are to be locked at the same * time. Only hub-aware drivers that are part of usbcore ever have to - * do this; nobody else needs to worry about it. The problem is that - * usb_lock_device() must not be called to lock a second device since it - * would acquire the rwsem's readlock reentrantly, leading to deadlock if - * another thread was waiting for the writelock. The solution is simple: - * - * When locking more than one device, call usb_lock_device() - * to lock the first one. Lock the others by calling - * down(&udev->serialize) directly. - * - * When unlocking multiple devices, use up(&udev->serialize) - * to unlock all but the last one. Unlock the last one by - * calling usb_unlock_device(). + * do this; nobody else needs to worry about it. The rule for locking + * is simple: * * When locking both a device and its parent, always lock the * the parent first. */ /** - * usb_lock_device - acquire the lock for a usb device structure - * @udev: device that's being locked - * - * Use this routine when you don't hold any other device locks; - * to acquire nested inner locks call down(&udev->serialize) directly. - * This is necessary for proper interaction with usb_lock_all_devices(). - */ -void usb_lock_device(struct usb_device *udev) -{ - down_read(&usb_all_devices_rwsem); - down(&udev->serialize); -} - -/** - * usb_trylock_device - attempt to acquire the lock for a usb device structure - * @udev: device that's being locked - * - * Don't use this routine if you already hold a device lock; - * use down_trylock(&udev->serialize) instead. - * This is necessary for proper interaction with usb_lock_all_devices(). - * - * Returns 1 if successful, 0 if contention. - */ -int usb_trylock_device(struct usb_device *udev) -{ - if (!down_read_trylock(&usb_all_devices_rwsem)) - return 0; - if (down_trylock(&udev->serialize)) { - up_read(&usb_all_devices_rwsem); - return 0; - } - return 1; -} - -/** * usb_lock_device_for_reset - cautiously acquire the lock for a * usb device structure * @udev: device that's being locked @@ -627,7 +567,7 @@ int usb_lock_device_for_reset(struct usb_device *udev, } } - while (!usb_trylock_device(udev)) { + while (usb_trylock_device(udev) != 0) { /* If we can't acquire the lock after waiting one second, * we're probably deadlocked */ @@ -645,39 +585,6 @@ int usb_lock_device_for_reset(struct usb_device *udev, return 1; } -/** - * usb_unlock_device - release the lock for a usb device structure - * @udev: device that's being unlocked - * - * Use this routine when releasing the only device lock you hold; - * to release inner nested locks call up(&udev->serialize) directly. - * This is necessary for proper interaction with usb_lock_all_devices(). - */ -void usb_unlock_device(struct usb_device *udev) -{ - up(&udev->serialize); - up_read(&usb_all_devices_rwsem); -} - -/** - * usb_lock_all_devices - acquire the lock for all usb device structures - * - * This is necessary when registering a new driver or probing a bus, - * since the driver-model core may try to use any usb_device. - */ -void usb_lock_all_devices(void) -{ - down_write(&usb_all_devices_rwsem); -} - -/** - * usb_unlock_all_devices - release the lock for all usb device structures - */ -void usb_unlock_all_devices(void) -{ - up_write(&usb_all_devices_rwsem); -} - static struct usb_device *match_device(struct usb_device *dev, u16 vendor_id, u16 product_id) @@ -700,10 +607,10 @@ static struct usb_device *match_device(struct usb_device *dev, /* look through all of the children of this device */ for (child = 0; child < dev->maxchild; ++child) { if (dev->children[child]) { - down(&dev->children[child]->serialize); + usb_lock_device(dev->children[child]); ret_dev = match_device(dev->children[child], vendor_id, product_id); - up(&dev->children[child]->serialize); + usb_unlock_device(dev->children[child]); if (ret_dev) goto exit; } @@ -1300,10 +1207,7 @@ EXPORT_SYMBOL(usb_put_dev); EXPORT_SYMBOL(usb_get_dev); EXPORT_SYMBOL(usb_hub_tt_clear_buffer); -EXPORT_SYMBOL(usb_lock_device); -EXPORT_SYMBOL(usb_trylock_device); EXPORT_SYMBOL(usb_lock_device_for_reset); -EXPORT_SYMBOL(usb_unlock_device); EXPORT_SYMBOL(usb_driver_claim_interface); EXPORT_SYMBOL(usb_driver_release_interface); diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 98e85fb..4647e1e 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -16,9 +16,6 @@ extern int usb_get_device_descriptor(struct usb_device *dev, extern char *usb_cache_string(struct usb_device *udev, int index); extern int usb_set_configuration(struct usb_device *dev, int configuration); -extern void usb_lock_all_devices(void); -extern void usb_unlock_all_devices(void); - extern void usb_kick_khubd(struct usb_device *dev); extern void usb_suspend_root_hub(struct usb_device *hdev); extern void usb_resume_root_hub(struct usb_device *dev); diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 72e3b12..4b2226d 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c @@ -372,7 +372,7 @@ done: & ohci->hc_control) == OHCI_USB_OPER && time_after (jiffies, ohci->next_statechange) - && usb_trylock_device (hcd->self.root_hub) + && usb_trylock_device (hcd->self.root_hub) == 0 ) { ohci_vdbg (ohci, "autosuspend\n"); (void) ohci_bus_suspend (hcd); diff --git a/include/linux/usb.h b/include/linux/usb.h index 2714814..46dc042 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -329,8 +329,6 @@ struct usb_device { struct usb_tt *tt; /* low/full speed dev, highspeed hub */ int ttport; /* device port on that tt hub */ - struct semaphore serialize; - unsigned int toggle[2]; /* one bit for each endpoint * ([0] = IN, [1] = OUT) */ @@ -377,11 +375,12 @@ struct usb_device { extern struct usb_device *usb_get_dev(struct usb_device *dev); extern void usb_put_dev(struct usb_device *dev); -extern void usb_lock_device(struct usb_device *udev); -extern int usb_trylock_device(struct usb_device *udev); +/* USB device locking */ +#define usb_lock_device(udev) down(&(udev)->dev.sem) +#define usb_unlock_device(udev) up(&(udev)->dev.sem) +#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) extern int usb_lock_device_for_reset(struct usb_device *udev, struct usb_interface *iface); -extern void usb_unlock_device(struct usb_device *udev); /* USB port reset for device reinitialization */ extern int usb_reset_device(struct usb_device *dev); -- cgit v1.1 From 7d069b7d80933004282c48edbe62526e4cb0aecc Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Fri, 18 Nov 2005 12:06:34 -0500 Subject: [PATCH] USB: Disconnect children during hub unbind This patch (as606b) is an updated version of my earlier patch to disconnect children from a hub device when the hub driver is unbound. Thanks to the changes in the driver core locking, we now know that the entire hub device (and not just the interface) is locked whenever the hub driver's disconnect method runs. Hence it is safe to disconnect the child device structures immediately instead of deferring the job. The earlier version of the patch neglected to disable the hub's ports. We don't want to forget that; otherwise we'd end up with live devices using addresses that have been recycled. This update adds the necessary code. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 94 +++++++++++++++++--------------------------------- 1 file changed, 31 insertions(+), 63 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index dd3bcfb..02601f4 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -515,6 +515,31 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) return ret; } + +/* caller has locked the hub device */ +static void hub_pre_reset(struct usb_hub *hub, int disable_ports) +{ + struct usb_device *hdev = hub->hdev; + int port1; + + for (port1 = 1; port1 <= hdev->maxchild; ++port1) { + if (hdev->children[port1 - 1]) { + usb_disconnect(&hdev->children[port1 - 1]); + if (disable_ports) + hub_port_disable(hub, port1, 0); + } + } + hub_quiesce(hub); +} + +/* caller has locked the hub device */ +static void hub_post_reset(struct usb_hub *hub) +{ + hub_activate(hub); + hub_power_on(hub); +} + + static int hub_configure(struct usb_hub *hub, struct usb_endpoint_descriptor *endpoint) { @@ -750,29 +775,10 @@ fail: static unsigned highspeed_hubs; -/* Called after the hub driver is unbound from a hub with children */ -static void hub_remove_children_work(void *__hub) -{ - struct usb_hub *hub = __hub; - struct usb_device *hdev = hub->hdev; - int i; - - kfree(hub); - - usb_lock_device(hdev); - for (i = 0; i < hdev->maxchild; ++i) { - if (hdev->children[i]) - usb_disconnect(&hdev->children[i]); - } - usb_unlock_device(hdev); - usb_put_dev(hdev); -} - static void hub_disconnect(struct usb_interface *intf) { struct usb_hub *hub = usb_get_intfdata (intf); struct usb_device *hdev; - int n, port1; usb_set_intfdata (intf, NULL); hdev = hub->hdev; @@ -780,7 +786,9 @@ static void hub_disconnect(struct usb_interface *intf) if (hdev->speed == USB_SPEED_HIGH) highspeed_hubs--; - hub_quiesce(hub); + /* Disconnect all children and quiesce the hub */ + hub_pre_reset(hub, 1); + usb_free_urb(hub->urb); hub->urb = NULL; @@ -800,27 +808,7 @@ static void hub_disconnect(struct usb_interface *intf) hub->buffer = NULL; } - /* If there are any children then this is an unbind only, not a - * physical disconnection. The active ports must be disabled - * and later on we must call usb_disconnect(). We can't call - * it now because we may not hold the hub's device lock. - */ - n = 0; - for (port1 = 1; port1 <= hdev->maxchild; ++port1) { - if (hdev->children[port1 - 1]) { - ++n; - hub_port_disable(hub, port1, 1); - } - } - - if (n == 0) - kfree(hub); - else { - /* Reuse the hub->leds work_struct for our own purposes */ - INIT_WORK(&hub->leds, hub_remove_children_work, hub); - schedule_work(&hub->leds); - usb_get_dev(hdev); - } + kfree(hub); } static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) @@ -917,26 +905,6 @@ hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data) } } -/* caller has locked the hub device */ -static void hub_pre_reset(struct usb_hub *hub) -{ - struct usb_device *hdev = hub->hdev; - int i; - - for (i = 0; i < hdev->maxchild; ++i) { - if (hdev->children[i]) - usb_disconnect(&hdev->children[i]); - } - hub_quiesce(hub); -} - -/* caller has locked the hub device */ -static void hub_post_reset(struct usb_hub *hub) -{ - hub_activate(hub); - hub_power_on(hub); -} - /* grab device/port lock, returning index of that port (zero based). * protects the upstream link used by this device from concurrent @@ -2682,7 +2650,7 @@ static void hub_events(void) /* If the hub has died, clean up after it */ if (hdev->state == USB_STATE_NOTATTACHED) { - hub_pre_reset(hub); + hub_pre_reset(hub, 0); goto loop; } @@ -2997,7 +2965,7 @@ int usb_reset_device(struct usb_device *udev) udev->actconfig->interface[0]->dev.driver == &hub_driver.driver && (hub = hdev_to_hub(udev)) != NULL) { - hub_pre_reset(hub); + hub_pre_reset(hub, 0); } set_bit(port1, parent_hub->busy_bits); -- cgit v1.1 From 4bf0ba861442d289eebfad8ea9ce365ab04fd582 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Mon, 21 Nov 2005 11:58:07 -0500 Subject: [PATCH] USB: Fix locking for USB suspend/resume The earlier USB locking updates didn't touch the suspend/resume routines. They need updating as well, since now the caller holds the device semaphore. This patch (as608) makes the necessary changes. It also adds a line to store the correct power state when a device is resumed, something which was unaccountably missing. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 54 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 02601f4..895ac82 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1648,15 +1648,22 @@ static int __usb_suspend_device (struct usb_device *udev, int port1) int usb_suspend_device(struct usb_device *udev) { #ifdef CONFIG_USB_SUSPEND - int port1, status; + int port1; - port1 = locktree(udev); - if (port1 < 0) - return port1; + if (udev->state == USB_STATE_NOTATTACHED) + return -ENODEV; + if (!udev->parent) + port1 = 0; + else { + for (port1 = udev->parent->maxchild; port1 > 0; --port1) { + if (udev->parent->children[port1-1] == udev) + break; + } + if (port1 == 0) + return -ENODEV; + } - status = __usb_suspend_device(udev, port1); - usb_unlock_device(udev); - return status; + return __usb_suspend_device(udev, port1); #else /* NOTE: udev->state unchanged, it's not lying ... */ udev->dev.power.power_state = PMSG_SUSPEND; @@ -1688,6 +1695,7 @@ static int finish_device_resume(struct usb_device *udev) usb_set_device_state(udev, udev->actconfig ? USB_STATE_CONFIGURED : USB_STATE_ADDRESS); + udev->dev.power.power_state = PMSG_ON; /* 10.5.4.5 says be sure devices in the tree are still there. * For now let's assume the device didn't go crazy on resume, @@ -1723,8 +1731,14 @@ static int finish_device_resume(struct usb_device *udev) * may have a child resume event to deal with soon */ resume = udev->dev.bus->resume; - for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) - (void) resume(&udev->actconfig->interface[i]->dev); + for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { + struct device *dev = + &udev->actconfig->interface[i]->dev; + + down(&dev->sem); + (void) resume(dev); + up(&dev->sem); + } status = 0; } else if (udev->devnum <= 0) { @@ -1809,9 +1823,18 @@ int usb_resume_device(struct usb_device *udev) { int port1, status; - port1 = locktree(udev); - if (port1 < 0) - return port1; + if (udev->state == USB_STATE_NOTATTACHED) + return -ENODEV; + if (!udev->parent) + port1 = 0; + else { + for (port1 = udev->parent->maxchild; port1 > 0; --port1) { + if (udev->parent->children[port1-1] == udev) + break; + } + if (port1 == 0) + return -ENODEV; + } #ifdef CONFIG_USB_SUSPEND /* selective resume of one downstream hub-to-device port */ @@ -1830,11 +1853,12 @@ int usb_resume_device(struct usb_device *udev) dev_dbg(&udev->dev, "can't resume, status %d\n", status); - usb_unlock_device(udev); - /* rebind drivers that had no suspend() */ - if (status == 0) + if (status == 0) { + usb_unlock_device(udev); bus_rescan_devices(&usb_bus_type); + usb_lock_device(udev); + } return status; } -- cgit v1.1 From 3d48586cfa2e197515605ccf74527983d35638e3 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 20 Nov 2005 23:56:11 +0100 Subject: [PATCH] USB: small cleanups This patch contains the following cleanups: - make needlessly global functions static - every file should #include the headers containing the prototypes for it's global functions Signed-off-by: Adrian Bunk Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/usbatm.c | 4 ++-- drivers/usb/serial/io_ti.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index 2e6593e..9baa629 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c @@ -646,14 +646,14 @@ static void usbatm_destroy_instance(struct kref *kref) kfree(instance); } -void usbatm_get_instance(struct usbatm_data *instance) +static void usbatm_get_instance(struct usbatm_data *instance) { dbg("%s", __func__); kref_get(&instance->refcount); } -void usbatm_put_instance(struct usbatm_data *instance) +static void usbatm_put_instance(struct usbatm_data *instance) { dbg("%s", __func__); diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 22ad1a5..2edf9cab 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -2843,7 +2843,7 @@ static struct edge_buf *edge_buf_alloc(unsigned int size) * Free the buffer and all associated memory. */ -void edge_buf_free(struct edge_buf *eb) +static void edge_buf_free(struct edge_buf *eb) { if (eb) { kfree(eb->buf_buf); -- cgit v1.1 From 949bf6431189c62eeebd3b52201406ba9978f525 Mon Sep 17 00:00:00 2001 From: Fengwei Yin Date: Fri, 18 Nov 2005 10:35:36 +0800 Subject: [PATCH] USB: One potential problem in gadget/serial.c It looks like that the gs_serial module maybe sleep with spinlock in gs_close. Sometimes, system hang when I remove the gs_serial module. From: Fengwei Yin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/serial.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index b35ac6d..65e084a 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -890,10 +890,12 @@ static void gs_close(struct tty_struct *tty, struct file *file) /* wait for write buffer to drain, or */ /* at most GS_CLOSE_TIMEOUT seconds */ if (gs_buf_data_avail(port->port_write_buf) > 0) { + spin_unlock_irqrestore(&port->port_lock, flags); wait_cond_interruptible_timeout(port->port_write_wait, port->port_dev == NULL || gs_buf_data_avail(port->port_write_buf) == 0, &port->port_lock, flags, GS_CLOSE_TIMEOUT * HZ); + spin_lock_irqsave(&port->port_lock, flags); } /* free disconnected port on final close */ -- cgit v1.1 From 55c527187c9d78f840b284d596a0b298bc1493af Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 23 Nov 2005 12:03:12 -0500 Subject: [PATCH] USB: Consider power budget when choosing configuration This patch (as609) changes the way we keep track of power budgeting for USB hubs and devices, and it updates the choose_configuration routine to take this information into account. (This is something we should have been doing all along.) A new field in struct usb_device holds the amount of bus current available from the upstream port, and the usb_hub structure keeps track of the current available for each downstream port. Two new rules for configuration selection are added: Don't select a self-powered configuration when only bus power is available. Don't select a configuration requiring more bus power than is available. However the first rule is #if-ed out, because I found that the internal hub in my HP USB keyboard claims that its only configuration is self-powered. The rule would prevent the configuration from being chosen, leaving the hub & keyboard unconfigured. Since similar descriptor errors may turn out to be fairly common, it seemed wise not to include a rule that would break automatic configuration unnecessarily for such devices. The second rule may also trigger unnecessarily, although this should be less common. More likely it will annoy people by sometimes failing to accept configurations that should never have been chosen in the first place. The patch also changes usbcore's reaction when no configuration is suitable. Instead of raising an error and rejecting the device, now the core will simply leave the device unconfigured. People can always work around such problems by installing configurations manually through sysfs. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd.c | 5 +- drivers/usb/core/hub.c | 229 ++++++++++++++++++++++++++++++--------------- drivers/usb/core/hub.h | 3 +- drivers/usb/core/message.c | 6 ++ include/linux/usb.h | 2 + 5 files changed, 164 insertions(+), 81 deletions(-) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index d16a0e8..0018bbc 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1825,8 +1825,6 @@ int usb_add_hcd(struct usb_hcd *hcd, retval = -ENOMEM; goto err_allocate_root_hub; } - rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH : - USB_SPEED_FULL; /* Although in principle hcd->driver->start() might need to use rhdev, * none of the current drivers do. @@ -1844,6 +1842,9 @@ int usb_add_hcd(struct usb_hcd *hcd, dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); hcd->remote_wakeup = hcd->can_wakeup; + rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH : + USB_SPEED_FULL; + rhdev->bus_mA = min(500u, hcd->power_budget); if ((retval = register_root_hub(rhdev, hcd)) != 0) goto err_register_root_hub; diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 895ac82..b311005 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -702,26 +702,40 @@ static int hub_configure(struct usb_hub *hub, * and battery-powered root hubs (may provide just 8 mA). */ ret = usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus); - if (ret < 0) { + if (ret < 2) { message = "can't get hub status"; goto fail; } le16_to_cpus(&hubstatus); if (hdev == hdev->bus->root_hub) { - struct usb_hcd *hcd = - container_of(hdev->bus, struct usb_hcd, self); - - hub->power_budget = min(500u, hcd->power_budget) / 2; + if (hdev->bus_mA == 0 || hdev->bus_mA >= 500) + hub->mA_per_port = 500; + else { + hub->mA_per_port = hdev->bus_mA; + hub->limited_power = 1; + } } else if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) { dev_dbg(hub_dev, "hub controller current requirement: %dmA\n", hub->descriptor->bHubContrCurrent); - hub->power_budget = (501 - hub->descriptor->bHubContrCurrent) - / 2; + hub->limited_power = 1; + if (hdev->maxchild > 0) { + int remaining = hdev->bus_mA - + hub->descriptor->bHubContrCurrent; + + if (remaining < hdev->maxchild * 100) + dev_warn(hub_dev, + "insufficient power available " + "to use all downstream ports\n"); + hub->mA_per_port = 100; /* 7.2.1.1 */ + } + } else { /* Self-powered external hub */ + /* FIXME: What about battery-powered external hubs that + * provide less current per port? */ + hub->mA_per_port = 500; } - if (hub->power_budget) - dev_dbg(hub_dev, "%dmA bus power budget for children\n", - hub->power_budget * 2); - + if (hub->mA_per_port < 500) + dev_dbg(hub_dev, "%umA bus power budget for each child\n", + hub->mA_per_port); ret = hub_hub_status(hub, &hubstatus, &hubchange); if (ret < 0) { @@ -1136,45 +1150,107 @@ void usb_disconnect(struct usb_device **pdev) device_unregister(&udev->dev); } +static inline const char *plural(int n) +{ + return (n == 1 ? "" : "s"); +} + static int choose_configuration(struct usb_device *udev) { - int c, i; + int i; + u16 devstatus; + int bus_powered; + int num_configs; + struct usb_host_config *c, *best; + + /* If this fails, assume the device is bus-powered */ + devstatus = 0; + usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); + le16_to_cpus(&devstatus); + bus_powered = ((devstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0); + dev_dbg(&udev->dev, "device is %s-powered\n", + bus_powered ? "bus" : "self"); + + best = NULL; + c = udev->config; + num_configs = udev->descriptor.bNumConfigurations; + for (i = 0; i < num_configs; (i++, c++)) { + struct usb_interface_descriptor *desc = + &c->intf_cache[0]->altsetting->desc; + + /* + * HP's USB bus-powered keyboard has only one configuration + * and it claims to be self-powered; other devices may have + * similar errors in their descriptors. If the next test + * were allowed to execute, such configurations would always + * be rejected and the devices would not work as expected. + */ +#if 0 + /* Rule out self-powered configs for a bus-powered device */ + if (bus_powered && (c->desc.bmAttributes & + USB_CONFIG_ATT_SELFPOWER)) + continue; +#endif - /* NOTE: this should interact with hub power budgeting */ + /* + * The next test may not be as effective as it should be. + * Some hubs have errors in their descriptor, claiming + * to be self-powered when they are really bus-powered. + * We will overestimate the amount of current such hubs + * make available for each port. + * + * This is a fairly benign sort of failure. It won't + * cause us to reject configurations that we should have + * accepted. + */ - c = udev->config[0].desc.bConfigurationValue; - if (udev->descriptor.bNumConfigurations != 1) { - for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { - struct usb_interface_descriptor *desc; + /* Rule out configs that draw too much bus current */ + if (c->desc.bMaxPower * 2 > udev->bus_mA) + continue; - /* heuristic: Linux is more likely to have class - * drivers, so avoid vendor-specific interfaces. - */ - desc = &udev->config[i].intf_cache[0] - ->altsetting->desc; - if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) - continue; - /* COMM/2/all is CDC ACM, except 0xff is MSFT RNDIS. - * MSFT needs this to be the first config; never use - * it as the default unless Linux has host-side RNDIS. - * A second config would ideally be CDC-Ethernet, but - * may instead be the "vendor specific" CDC subset - * long used by ARM Linux for sa1100 or pxa255. - */ - if (desc->bInterfaceClass == USB_CLASS_COMM - && desc->bInterfaceSubClass == 2 - && desc->bInterfaceProtocol == 0xff) { - c = udev->config[1].desc.bConfigurationValue; - continue; - } - c = udev->config[i].desc.bConfigurationValue; + /* If the first config's first interface is COMM/2/0xff + * (MSFT RNDIS), rule it out unless Linux has host-side + * RNDIS support. */ + if (i == 0 && desc->bInterfaceClass == USB_CLASS_COMM + && desc->bInterfaceSubClass == 2 + && desc->bInterfaceProtocol == 0xff) { +#ifndef CONFIG_USB_NET_RNDIS + continue; +#else + best = c; +#endif + } + + /* From the remaining configs, choose the first one whose + * first interface is for a non-vendor-specific class. + * Reason: Linux is more likely to have a class driver + * than a vendor-specific driver. */ + else if (udev->descriptor.bDeviceClass != + USB_CLASS_VENDOR_SPEC && + desc->bInterfaceClass != + USB_CLASS_VENDOR_SPEC) { + best = c; break; } + + /* If all the remaining configs are vendor-specific, + * choose the first one. */ + else if (!best) + best = c; + } + + if (best) { + i = best->desc.bConfigurationValue; dev_info(&udev->dev, - "configuration #%d chosen from %d choices\n", - c, udev->descriptor.bNumConfigurations); + "configuration #%d chosen from %d choice%s\n", + i, num_configs, plural(num_configs)); + } else { + i = -1; + dev_warn(&udev->dev, + "no configuration chosen from %d choice%s\n", + num_configs, plural(num_configs)); } - return c; + return i; } #ifdef DEBUG @@ -1327,17 +1403,13 @@ int usb_new_device(struct usb_device *udev) * with the driver core, and lets usb device drivers bind to them. */ c = choose_configuration(udev); - if (c < 0) - dev_warn(&udev->dev, - "can't choose an initial configuration\n"); - else { + if (c >= 0) { err = usb_set_configuration(udev, c); if (err) { dev_err(&udev->dev, "can't set config #%d, error %d\n", c, err); - usb_remove_sysfs_dev_files(udev); - device_del(&udev->dev); - goto fail; + /* This need not be fatal. The user can try to + * set other configurations. */ } } @@ -1702,7 +1774,7 @@ static int finish_device_resume(struct usb_device *udev) * and device drivers will know about any resume quirks. */ status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); - if (status < 0) + if (status < 2) dev_dbg(&udev->dev, "gone after usb resume? status %d\n", status); @@ -1711,7 +1783,7 @@ static int finish_device_resume(struct usb_device *udev) int (*resume)(struct device *); le16_to_cpus(&devstatus); - if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP) + if ((devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) && udev->parent) { status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), @@ -2374,39 +2446,36 @@ hub_power_remaining (struct usb_hub *hub) { struct usb_device *hdev = hub->hdev; int remaining; - unsigned i; + int port1; - remaining = hub->power_budget; - if (!remaining) /* self-powered */ + if (!hub->limited_power) return 0; - for (i = 0; i < hdev->maxchild; i++) { - struct usb_device *udev = hdev->children[i]; - int delta, ceiling; + remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent; + for (port1 = 1; port1 <= hdev->maxchild; ++port1) { + struct usb_device *udev = hdev->children[port1 - 1]; + int delta; if (!udev) continue; - /* 100mA per-port ceiling, or 8mA for OTG ports */ - if (i != (udev->bus->otg_port - 1) || hdev->parent) - ceiling = 50; - else - ceiling = 4; - + /* Unconfigured devices may not use more than 100mA, + * or 8mA for OTG ports */ if (udev->actconfig) - delta = udev->actconfig->desc.bMaxPower; + delta = udev->actconfig->desc.bMaxPower * 2; + else if (port1 != udev->bus->otg_port || hdev->parent) + delta = 100; else - delta = ceiling; - // dev_dbg(&udev->dev, "budgeted %dmA\n", 2 * delta); - if (delta > ceiling) - dev_warn(&udev->dev, "%dmA over %dmA budget!\n", - 2 * (delta - ceiling), 2 * ceiling); + delta = 8; + if (delta > hub->mA_per_port) + dev_warn(&udev->dev, "%dmA is over %umA budget " + "for port %d!\n", + delta, hub->mA_per_port, port1); remaining -= delta; } if (remaining < 0) { - dev_warn(hub->intfdev, - "%dmA over power budget!\n", - -2 * remaining); + dev_warn(hub->intfdev, "%dmA over power budget!\n", + - remaining); remaining = 0; } return remaining; @@ -2501,7 +2570,8 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, usb_set_device_state(udev, USB_STATE_POWERED); udev->speed = USB_SPEED_UNKNOWN; - + udev->bus_mA = hub->mA_per_port; + /* set the address */ choose_address(udev); if (udev->devnum <= 0) { @@ -2521,16 +2591,16 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, * on the parent. */ if (udev->descriptor.bDeviceClass == USB_CLASS_HUB - && hub->power_budget) { + && udev->bus_mA <= 100) { u16 devstat; status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstat); - if (status < 0) { + if (status < 2) { dev_dbg(&udev->dev, "get status %d ?\n", status); goto loop_disable; } - cpu_to_le16s(&devstat); + le16_to_cpus(&devstat); if ((devstat & (1 << USB_DEVICE_SELF_POWERED)) == 0) { dev_err(&udev->dev, "can't connect bus-powered hub " @@ -2583,9 +2653,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, status = hub_power_remaining(hub); if (status) - dev_dbg(hub_dev, - "%dmA power budget left\n", - 2 * status); + dev_dbg(hub_dev, "%dmA power budget left\n", status); return; @@ -2797,6 +2865,11 @@ static void hub_events(void) if (hubchange & HUB_CHANGE_LOCAL_POWER) { dev_dbg (hub_dev, "power change\n"); clear_hub_feature(hdev, C_HUB_LOCAL_POWER); + if (hubstatus & HUB_STATUS_LOCAL_POWER) + /* FIXME: Is this always true? */ + hub->limited_power = 0; + else + hub->limited_power = 1; } if (hubchange & HUB_CHANGE_OVERCURRENT) { dev_dbg (hub_dev, "overcurrent change\n"); diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index bf23f89..29d5f45 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h @@ -220,8 +220,9 @@ struct usb_hub { struct usb_hub_descriptor *descriptor; /* class descriptor */ struct usb_tt tt; /* Transaction Translator */ - u8 power_budget; /* in 2mA units; or zero */ + unsigned mA_per_port; /* current for each child */ + unsigned limited_power:1; unsigned quiescing:1; unsigned activating:1; unsigned resume_root_hub:1; diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index fe74f99..99ab774 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1387,6 +1387,12 @@ free_interfaces: if (dev->state != USB_STATE_ADDRESS) usb_disable_device (dev, 1); // Skip ep0 + n = dev->bus_mA - cp->desc.bMaxPower * 2; + if (n < 0) + dev_warn(&dev->dev, "new config #%d exceeds power " + "limit by %dmA\n", + configuration, -n); + if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION, 0, configuration, 0, NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) diff --git a/include/linux/usb.h b/include/linux/usb.h index 46dc042..27575e67 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -347,6 +347,8 @@ struct usb_device { char **rawdescriptors; /* Raw descriptors for each config */ + unsigned short bus_mA; /* Current available from the bus */ + int have_langid; /* whether string_langid is valid */ int string_langid; /* language ID for strings */ -- cgit v1.1 From 12c3da346eb81b6a281031f62eda3bca993dff5a Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 23 Nov 2005 12:09:52 -0500 Subject: [PATCH] USB: Store port number in usb_device This patch (as610) adds a field to struct usb_device to store the device's port number. This allows us to remove several loops in the hub driver (searching for a particular device among all the entries in the parent's array of children). Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 79 ++++++++++++-------------------------------------- drivers/usb/core/usb.c | 1 + include/linux/usb.h | 1 + 3 files changed, 20 insertions(+), 61 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index b311005..a523c8f 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -946,24 +946,21 @@ static int locktree(struct usb_device *udev) t = locktree(hdev); if (t < 0) return t; - for (t = 0; t < hdev->maxchild; t++) { - if (hdev->children[t] == udev) { - /* everything is fail-fast once disconnect - * processing starts - */ - if (udev->state == USB_STATE_NOTATTACHED) - break; - /* when everyone grabs locks top->bottom, - * non-overlapping work may be concurrent - */ - usb_lock_device(udev); - usb_unlock_device(hdev); - return t + 1; - } + /* everything is fail-fast once disconnect + * processing starts + */ + if (udev->state == USB_STATE_NOTATTACHED) { + usb_unlock_device(hdev); + return -ENODEV; } + + /* when everyone grabs locks top->bottom, + * non-overlapping work may be concurrent + */ + usb_lock_device(udev); usb_unlock_device(hdev); - return -ENODEV; + return udev->portnum; } static void recursively_mark_NOTATTACHED(struct usb_device *udev) @@ -1335,15 +1332,9 @@ int usb_new_device(struct usb_device *udev) le16_to_cpu(udev->config[0].desc.wTotalLength), USB_DT_OTG, (void **) &desc) == 0) { if (desc->bmAttributes & USB_OTG_HNP) { - unsigned port1; + unsigned port1 = udev->portnum; struct usb_device *root = udev->parent; - for (port1 = 1; port1 <= root->maxchild; - port1++) { - if (root->children[port1-1] == udev) - break; - } - dev_info(&udev->dev, "Dual-Role OTG device on %sHNP port\n", (port1 == bus->otg_port) @@ -1720,22 +1711,9 @@ static int __usb_suspend_device (struct usb_device *udev, int port1) int usb_suspend_device(struct usb_device *udev) { #ifdef CONFIG_USB_SUSPEND - int port1; - if (udev->state == USB_STATE_NOTATTACHED) return -ENODEV; - if (!udev->parent) - port1 = 0; - else { - for (port1 = udev->parent->maxchild; port1 > 0; --port1) { - if (udev->parent->children[port1-1] == udev) - break; - } - if (port1 == 0) - return -ENODEV; - } - - return __usb_suspend_device(udev, port1); + return __usb_suspend_device(udev, udev->portnum); #else /* NOTE: udev->state unchanged, it's not lying ... */ udev->dev.power.power_state = PMSG_SUSPEND; @@ -1893,20 +1871,10 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) */ int usb_resume_device(struct usb_device *udev) { - int port1, status; + int status; if (udev->state == USB_STATE_NOTATTACHED) return -ENODEV; - if (!udev->parent) - port1 = 0; - else { - for (port1 = udev->parent->maxchild; port1 > 0; --port1) { - if (udev->parent->children[port1-1] == udev) - break; - } - if (port1 == 0) - return -ENODEV; - } #ifdef CONFIG_USB_SUSPEND /* selective resume of one downstream hub-to-device port */ @@ -1915,7 +1883,7 @@ int usb_resume_device(struct usb_device *udev) // NOTE swsusp may bork us, device state being wrong... // NOTE this fails if parent is also suspended... status = hub_port_resume(hdev_to_hub(udev->parent), - port1, udev); + udev->portnum, udev); } else status = 0; } else @@ -3029,7 +2997,8 @@ int usb_reset_device(struct usb_device *udev) struct usb_hub *parent_hub; struct usb_device_descriptor descriptor = udev->descriptor; struct usb_hub *hub = NULL; - int i, ret = 0, port1 = -1; + int i, ret = 0; + int port1 = udev->portnum; if (udev->state == USB_STATE_NOTATTACHED || udev->state == USB_STATE_SUSPENDED) { @@ -3043,18 +3012,6 @@ int usb_reset_device(struct usb_device *udev) dev_dbg(&udev->dev, "%s for root hub!\n", __FUNCTION__); return -EISDIR; } - - for (i = 0; i < parent_hdev->maxchild; i++) - if (parent_hdev->children[i] == udev) { - port1 = i + 1; - break; - } - - if (port1 < 0) { - /* If this ever happens, it's very bad */ - dev_err(&udev->dev, "Can't locate device's port!\n"); - return -ENOENT; - } parent_hub = hdev_to_hub(parent_hdev); /* If we're resetting an active hub, take some special actions */ diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index fcfda21..39e6b61b 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -439,6 +439,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1) /* hub driver sets up TT records */ } + dev->portnum = port1; dev->bus = bus; dev->parent = parent; INIT_LIST_HEAD(&dev->filelist); diff --git a/include/linux/usb.h b/include/linux/usb.h index 27575e67..e59d1bd 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -348,6 +348,7 @@ struct usb_device { char **rawdescriptors; /* Raw descriptors for each config */ unsigned short bus_mA; /* Current available from the bus */ + u8 portnum; /* Parent port number (origin 1) */ int have_langid; /* whether string_langid is valid */ int string_langid; /* language ID for strings */ -- cgit v1.1 From 3aea4a76a3ec4e6484f6316a97efff8b144b2b11 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sun, 27 Nov 2005 09:47:28 -0500 Subject: [PATCH] USB: Cleanups for usb gadget mass-storage Remove useless initalizers. Signed-off-by: Pavel Machek Signed-off-by: Alan Stern --- drivers/usb/gadget/file_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index f6f0b2a..f6c49b7 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -336,8 +336,8 @@ MODULE_LICENSE("Dual BSD/GPL"); #define MAX_LUNS 8 /* Arggh! There should be a module_param_array_named macro! */ -static char *file[MAX_LUNS] = {NULL, }; -static int ro[MAX_LUNS] = {0, }; +static char *file[MAX_LUNS]; +static int ro[MAX_LUNS]; static struct { int num_filenames; -- cgit v1.1 From 717f736d937d0e98e964375dac770bfa20f73b72 Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Sat, 26 Nov 2005 01:58:36 +0200 Subject: [PATCH] USB: isp116x-hcd: minor cleanup When going to suspend, there's no point in setting HC state in host controller driver as USB core takes care of this. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/isp116x-hcd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index c95af11..8344791 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -1426,7 +1426,6 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd) val = isp116x_read_reg32(isp116x, HCCONTROL); switch (val & HCCONTROL_HCFS) { case HCCONTROL_USB_OPER: - hcd->state = HC_STATE_QUIESCING; val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE); val |= HCCONTROL_USB_SUSPEND; if (device_may_wakeup(&hcd->self.root_hub->dev)) @@ -1434,7 +1433,6 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd) /* Wait for usb transfers to finish */ mdelay(2); isp116x_write_reg32(isp116x, HCCONTROL, val); - hcd->state = HC_STATE_SUSPENDED; /* Wait for devices to suspend */ mdelay(5); case HCCONTROL_USB_SUSPEND: -- cgit v1.1 From 487f9c6710e7dff338e59820f6cfaeaaa87cb532 Mon Sep 17 00:00:00 2001 From: Luiz Fernando Capitulino Date: Mon, 28 Nov 2005 19:16:05 -0200 Subject: [PATCH] USB: usbserial: Adds missing checks and bug fix. Checks if 'port' is NULL before using it in all tty operations, this can avoid NULL pointer dereferences. Signed-off-by: Luiz Capitulino Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb-serial.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 12aaf18..5bc023c 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -188,6 +188,8 @@ static int serial_open (struct tty_struct *tty, struct file * filp) portNumber = tty->index - serial->minor; port = serial->port[portNumber]; + if (!port) + return -ENODEV; ++port->open_count; @@ -258,6 +260,9 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int struct usb_serial_port *port = tty->driver_data; int retval = -EINVAL; + if (!port) + goto exit; + dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); if (!port->open_count) { @@ -277,6 +282,9 @@ static int serial_write_room (struct tty_struct *tty) struct usb_serial_port *port = tty->driver_data; int retval = -EINVAL; + if (!port) + goto exit; + dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -296,6 +304,9 @@ static int serial_chars_in_buffer (struct tty_struct *tty) struct usb_serial_port *port = tty->driver_data; int retval = -EINVAL; + if (!port) + goto exit; + dbg("%s = port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -314,6 +325,9 @@ static void serial_throttle (struct tty_struct * tty) { struct usb_serial_port *port = tty->driver_data; + if (!port) + return; + dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -330,6 +344,9 @@ static void serial_unthrottle (struct tty_struct * tty) { struct usb_serial_port *port = tty->driver_data; + if (!port) + return; + dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -347,6 +364,9 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in struct usb_serial_port *port = tty->driver_data; int retval = -ENODEV; + if (!port) + goto exit; + dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); if (!port->open_count) { @@ -368,6 +388,9 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old) { struct usb_serial_port *port = tty->driver_data; + if (!port) + return; + dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -384,6 +407,9 @@ static void serial_break (struct tty_struct *tty, int break_state) { struct usb_serial_port *port = tty->driver_data; + if (!port) + return; + dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -445,6 +471,9 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file) { struct usb_serial_port *port = tty->driver_data; + if (!port) + goto exit; + dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { @@ -464,6 +493,9 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file, { struct usb_serial_port *port = tty->driver_data; + if (!port) + goto exit; + dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { -- cgit v1.1 From 8a4613f01f5bb850cab34e3db572d97251d997b3 Mon Sep 17 00:00:00 2001 From: Luiz Fernando Capitulino Date: Mon, 28 Nov 2005 19:16:07 -0200 Subject: [PATCH] USB: usbserial: race-condition fix. There is a race-condition in usb-serial driver that can be triggered if a processes does 'port->tty->driver_data = NULL' in serial_close() while other processes is in kernel-space about to call serial_ioctl() on the same port. This happens because a process can open the device while there is another one closing it. The patch below fixes that by adding a semaphore to ensure that no process will open the device while another process is closing it. Note that we can't use spinlocks here, since serial_open() and serial_close() can sleep. Signed-off-by: Luiz Capitulino Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/usb-serial.c | 14 +++++++++++++- drivers/usb/serial/usb-serial.h | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 5bc023c..8bc8337 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "usb-serial.h" #include "pl2303.h" @@ -190,6 +191,9 @@ static int serial_open (struct tty_struct *tty, struct file * filp) port = serial->port[portNumber]; if (!port) return -ENODEV; + + if (down_interruptible(&port->sem)) + return -ERESTARTSYS; ++port->open_count; @@ -215,6 +219,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp) goto bailout_module_put; } + up(&port->sem); return 0; bailout_module_put: @@ -222,6 +227,7 @@ bailout_module_put: bailout_kref_put: kref_put(&serial->kref, destroy_serial); port->open_count = 0; + up(&port->sem); return retval; } @@ -234,8 +240,10 @@ static void serial_close(struct tty_struct *tty, struct file * filp) dbg("%s - port %d", __FUNCTION__, port->number); + down(&port->sem); + if (port->open_count == 0) - return; + goto out; --port->open_count; if (port->open_count == 0) { @@ -253,6 +261,9 @@ static void serial_close(struct tty_struct *tty, struct file * filp) } kref_put(&port->serial->kref, destroy_serial); + +out: + up(&port->sem); } static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) @@ -774,6 +785,7 @@ int usb_serial_probe(struct usb_interface *interface, port->number = i + serial->minor; port->serial = serial; spin_lock_init(&port->lock); + sema_init(&port->sem, 1); INIT_WORK(&port->work, usb_serial_port_softint, port); serial->port[i] = port; } diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h index 238a5a8..d7d27c3 100644 --- a/drivers/usb/serial/usb-serial.h +++ b/drivers/usb/serial/usb-serial.h @@ -16,6 +16,7 @@ #include #include +#include #define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ #define SERIAL_TTY_MINORS 255 /* loads of devices :) */ @@ -30,6 +31,8 @@ * @serial: pointer back to the struct usb_serial owner of this port. * @tty: pointer to the corresponding tty for this port. * @lock: spinlock to grab when updating portions of this structure. + * @sem: semaphore used to synchronize serial_open() and serial_close() + * access for this port. * @number: the number of the port (the minor number). * @interrupt_in_buffer: pointer to the interrupt in buffer for this port. * @interrupt_in_urb: pointer to the interrupt in struct urb for this port. @@ -60,6 +63,7 @@ struct usb_serial_port { struct usb_serial * serial; struct tty_struct * tty; spinlock_t lock; + struct semaphore sem; unsigned char number; unsigned char * interrupt_in_buffer; -- cgit v1.1 From 5d3202949c9ac6e135d98bde15a8f05ad3fa5849 Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Sun, 27 Nov 2005 22:23:38 +0100 Subject: [PATCH] USB: input/touchkitusb: handle multiple packets Some versions of the controller seem to put multiple report packet into a single urb. also it can happen that a packet is split across multiple urbs. unpatched you get a jumpy cursor on some screens. the patch does: - handle multiple packets per urb - handle packets split across multiple urb - check packet type - cleanups Signed-off-by: Daniel Ritz Signed-off-by: Greg Kroah-Hartman --- drivers/usb/input/touchkitusb.c | 148 ++++++++++++++++++++++++++++++++++------ 1 file changed, 126 insertions(+), 22 deletions(-) diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c index 75e7c12..3b3c7b4 100644 --- a/drivers/usb/input/touchkitusb.c +++ b/drivers/usb/input/touchkitusb.c @@ -1,7 +1,7 @@ /****************************************************************************** * touchkitusb.c -- Driver for eGalax TouchKit USB Touchscreens * - * Copyright (C) 2004 by Daniel Ritz + * Copyright (C) 2004-2005 by Daniel Ritz * Copyright (C) by Todd E. Johnson (mtouchusb.c) * * This program is free software; you can redistribute it and/or @@ -41,15 +41,13 @@ #define TOUCHKIT_MAX_YC 0x07ff #define TOUCHKIT_YC_FUZZ 0x0 #define TOUCHKIT_YC_FLAT 0x0 -#define TOUCHKIT_REPORT_DATA_SIZE 8 +#define TOUCHKIT_REPORT_DATA_SIZE 16 #define TOUCHKIT_DOWN 0x01 -#define TOUCHKIT_POINT_TOUCH 0x81 -#define TOUCHKIT_POINT_NOTOUCH 0x80 -#define TOUCHKIT_GET_TOUCHED(dat) ((((dat)[0]) & TOUCHKIT_DOWN) ? 1 : 0) -#define TOUCHKIT_GET_X(dat) (((dat)[3] << 7) | (dat)[4]) -#define TOUCHKIT_GET_Y(dat) (((dat)[1] << 7) | (dat)[2]) +#define TOUCHKIT_PKT_TYPE_MASK 0xFE +#define TOUCHKIT_PKT_TYPE_REPT 0x80 +#define TOUCHKIT_PKT_TYPE_DIAG 0x0A #define DRIVER_VERSION "v0.1" #define DRIVER_AUTHOR "Daniel Ritz " @@ -62,6 +60,8 @@ MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped."); struct touchkit_usb { unsigned char *data; dma_addr_t data_dma; + char buffer[TOUCHKIT_REPORT_DATA_SIZE]; + int buf_len; struct urb *irq; struct usb_device *udev; struct input_dev *input; @@ -77,11 +77,128 @@ static struct usb_device_id touchkit_devices[] = { {} }; +/* helpers to read the data */ +static inline int touchkit_get_touched(char *data) +{ + return (data[0] & TOUCHKIT_DOWN) ? 1 : 0; +} + +static inline int touchkit_get_x(char *data) +{ + return ((data[3] & 0x0F) << 7) | (data[4] & 0x7F); +} + +static inline int touchkit_get_y(char *data) +{ + return ((data[1] & 0x0F) << 7) | (data[2] & 0x7F); +} + + +/* processes one input packet. */ +static void touchkit_process_pkt(struct touchkit_usb *touchkit, + struct pt_regs *regs, char *pkt) +{ + int x, y; + + /* only process report packets */ + if ((pkt[0] & TOUCHKIT_PKT_TYPE_MASK) != TOUCHKIT_PKT_TYPE_REPT) + return; + + if (swap_xy) { + y = touchkit_get_x(pkt); + x = touchkit_get_y(pkt); + } else { + x = touchkit_get_x(pkt); + y = touchkit_get_y(pkt); + } + + input_regs(touchkit->input, regs); + input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt)); + input_report_abs(touchkit->input, ABS_X, x); + input_report_abs(touchkit->input, ABS_Y, y); + input_sync(touchkit->input); +} + + +static int touchkit_get_pkt_len(char *buf) +{ + switch (buf[0] & TOUCHKIT_PKT_TYPE_MASK) { + case TOUCHKIT_PKT_TYPE_REPT: + return 5; + + case TOUCHKIT_PKT_TYPE_DIAG: + return buf[1] + 2; + } + + return 0; +} + +static void touchkit_process(struct touchkit_usb *touchkit, int len, + struct pt_regs *regs) +{ + char *buffer; + int pkt_len, buf_len, pos; + + /* if the buffer contains data, append */ + if (unlikely(touchkit->buf_len)) { + int tmp; + + /* if only 1 byte in buffer, add another one to get length */ + if (touchkit->buf_len == 1) + touchkit->buffer[1] = touchkit->data[0]; + + pkt_len = touchkit_get_pkt_len(touchkit->buffer); + + /* unknown packet: drop everything */ + if (!pkt_len) + return; + + /* append, process */ + tmp = pkt_len - touchkit->buf_len; + memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp); + touchkit_process_pkt(touchkit, regs, touchkit->buffer); + + buffer = touchkit->data + tmp; + buf_len = len - tmp; + } else { + buffer = touchkit->data; + buf_len = len; + } + + /* only one byte left in buffer */ + if (unlikely(buf_len == 1)) { + touchkit->buffer[0] = buffer[0]; + touchkit->buf_len = 1; + return; + } + + /* loop over the buffer */ + pos = 0; + while (pos < buf_len) { + /* get packet len */ + pkt_len = touchkit_get_pkt_len(buffer + pos); + + /* unknown packet: drop everything */ + if (unlikely(!pkt_len)) + return; + + /* full packet: process */ + if (likely(pkt_len <= buf_len)) { + touchkit_process_pkt(touchkit, regs, buffer + pos); + } else { + /* incomplete packet: save in buffer */ + memcpy(touchkit->buffer, buffer + pos, buf_len - pos); + touchkit->buf_len = buf_len - pos; + } + pos += pkt_len; + } +} + + static void touchkit_irq(struct urb *urb, struct pt_regs *regs) { struct touchkit_usb *touchkit = urb->context; int retval; - int x, y; switch (urb->status) { case 0: @@ -105,20 +222,7 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs) goto exit; } - if (swap_xy) { - y = TOUCHKIT_GET_X(touchkit->data); - x = TOUCHKIT_GET_Y(touchkit->data); - } else { - x = TOUCHKIT_GET_X(touchkit->data); - y = TOUCHKIT_GET_Y(touchkit->data); - } - - input_regs(touchkit->input, regs); - input_report_key(touchkit->input, BTN_TOUCH, - TOUCHKIT_GET_TOUCHED(touchkit->data)); - input_report_abs(touchkit->input, ABS_X, x); - input_report_abs(touchkit->input, ABS_Y, y); - input_sync(touchkit->input); + touchkit_process(touchkit, urb->actual_length, regs); exit: retval = usb_submit_urb(urb, GFP_ATOMIC); -- cgit v1.1 From bd39b7f195e5a780a3c6710eb1c1450f158a1f31 Mon Sep 17 00:00:00 2001 From: Chris Humbert Date: Mon, 28 Nov 2005 09:29:23 -0800 Subject: [PATCH] USB: don't allocate dma pools for PIO HCDs USB: don't allocate dma pools for PIO HCDs hcd_buffer_alloc() and hcd_buffer_free() have a similar dma_mask check and revert to kmalloc()/kfree(), but hcd_buffer_create() doesn't check dma_mask and allocates unused dma pools. Signed-off-by: Chris Humbert Acked-by: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/buffer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c index 419c994..ad742ce 100644 --- a/drivers/usb/core/buffer.c +++ b/drivers/usb/core/buffer.c @@ -55,6 +55,9 @@ int hcd_buffer_create (struct usb_hcd *hcd) char name [16]; int i, size; + if (!hcd->self.controller->dma_mask) + return 0; + for (i = 0; i < HCD_BUFFER_POOLS; i++) { if (!(size = pool_max [i])) continue; -- cgit v1.1 From a21d4fed4b00eaf7e7c3b2e2b25de24f540bfa66 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 29 Nov 2005 12:04:24 -0500 Subject: [PATCH] USB Gadget: file_storage: remove "volatile" declarations This patch (as612) removes the "volatile" declarations from the file-storage gadget. It turns out that they aren't needed for anything much; adding a few memory barriers does a sufficient job. The patch also removes a wait_queue. Not much point having a queue when only one task is ever going to be on it! Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/file_storage.c | 59 +++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index f6c49b7..0cea978 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -239,7 +239,6 @@ #include #include #include -#include #include #include @@ -251,7 +250,7 @@ #define DRIVER_DESC "File-backed Storage Gadget" #define DRIVER_NAME "g_file_storage" -#define DRIVER_VERSION "20 October 2004" +#define DRIVER_VERSION "28 November 2005" static const char longname[] = DRIVER_DESC; static const char shortname[] = DRIVER_NAME; @@ -588,7 +587,7 @@ enum fsg_buffer_state { struct fsg_buffhd { void *buf; dma_addr_t dma; - volatile enum fsg_buffer_state state; + enum fsg_buffer_state state; struct fsg_buffhd *next; /* The NetChip 2280 is faster, and handles some protocol faults @@ -597,9 +596,9 @@ struct fsg_buffhd { unsigned int bulk_out_intended_length; struct usb_request *inreq; - volatile int inreq_busy; + int inreq_busy; struct usb_request *outreq; - volatile int outreq_busy; + int outreq_busy; }; enum fsg_state { @@ -637,11 +636,11 @@ struct fsg_dev { struct usb_ep *ep0; // Handy copy of gadget->ep0 struct usb_request *ep0req; // For control responses - volatile unsigned int ep0_req_tag; + unsigned int ep0_req_tag; const char *ep0req_name; struct usb_request *intreq; // For interrupt responses - volatile int intreq_busy; + int intreq_busy; struct fsg_buffhd *intr_buffhd; unsigned int bulk_out_maxpacket; @@ -671,7 +670,6 @@ struct fsg_dev { struct fsg_buffhd *next_buffhd_to_drain; struct fsg_buffhd buffhds[NUM_BUFFERS]; - wait_queue_head_t thread_wqh; int thread_wakeup_needed; struct completion thread_notifier; struct task_struct *thread_task; @@ -1076,11 +1074,13 @@ static int populate_config_buf(struct usb_gadget *gadget, /* These routines may be called in process context or in_irq */ +/* Caller must hold fsg->lock */ static void wakeup_thread(struct fsg_dev *fsg) { /* Tell the main thread that something has happened */ fsg->thread_wakeup_needed = 1; - wake_up_all(&fsg->thread_wqh); + if (fsg->thread_task) + wake_up_process(fsg->thread_task); } @@ -1167,11 +1167,12 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req) usb_ep_fifo_flush(ep); /* Hold the lock while we update the request and buffer states */ + smp_wmb(); spin_lock(&fsg->lock); bh->inreq_busy = 0; bh->state = BUF_STATE_EMPTY; - spin_unlock(&fsg->lock); wakeup_thread(fsg); + spin_unlock(&fsg->lock); } static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) @@ -1188,11 +1189,12 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) usb_ep_fifo_flush(ep); /* Hold the lock while we update the request and buffer states */ + smp_wmb(); spin_lock(&fsg->lock); bh->outreq_busy = 0; bh->state = BUF_STATE_FULL; - spin_unlock(&fsg->lock); wakeup_thread(fsg); + spin_unlock(&fsg->lock); } @@ -1209,11 +1211,12 @@ static void intr_in_complete(struct usb_ep *ep, struct usb_request *req) usb_ep_fifo_flush(ep); /* Hold the lock while we update the request and buffer states */ + smp_wmb(); spin_lock(&fsg->lock); fsg->intreq_busy = 0; bh->state = BUF_STATE_EMPTY; - spin_unlock(&fsg->lock); wakeup_thread(fsg); + spin_unlock(&fsg->lock); } #else @@ -1264,8 +1267,8 @@ static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh) fsg->cbbuf_cmnd_size = req->actual; memcpy(fsg->cbbuf_cmnd, req->buf, fsg->cbbuf_cmnd_size); - spin_unlock(&fsg->lock); wakeup_thread(fsg); + spin_unlock(&fsg->lock); } #else @@ -1517,8 +1520,8 @@ static int fsg_setup(struct usb_gadget *gadget, /* Use this for bulk or interrupt transfers, not ep0 */ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, - struct usb_request *req, volatile int *pbusy, - volatile enum fsg_buffer_state *state) + struct usb_request *req, int *pbusy, + enum fsg_buffer_state *state) { int rc; @@ -1526,8 +1529,11 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, dump_msg(fsg, "bulk-in", req->buf, req->length); else if (ep == fsg->intr_in) dump_msg(fsg, "intr-in", req->buf, req->length); + + spin_lock_irq(&fsg->lock); *pbusy = 1; *state = BUF_STATE_BUSY; + spin_unlock_irq(&fsg->lock); rc = usb_ep_queue(ep, req, GFP_KERNEL); if (rc != 0) { *pbusy = 0; @@ -1547,14 +1553,23 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, static int sleep_thread(struct fsg_dev *fsg) { - int rc; + int rc = 0; /* Wait until a signal arrives or we are woken up */ - rc = wait_event_interruptible(fsg->thread_wqh, - fsg->thread_wakeup_needed); + for (;;) { + try_to_freeze(); + set_current_state(TASK_INTERRUPTIBLE); + if (signal_pending(current)) { + rc = -EINTR; + break; + } + if (fsg->thread_wakeup_needed) + break; + schedule(); + } + __set_current_state(TASK_RUNNING); fsg->thread_wakeup_needed = 0; - try_to_freeze(); - return (rc ? -EINTR : 0); + return rc; } @@ -1791,6 +1806,7 @@ static int do_write(struct fsg_dev *fsg) if (bh->state == BUF_STATE_EMPTY && !get_some_more) break; // We stopped early if (bh->state == BUF_STATE_FULL) { + smp_rmb(); fsg->next_buffhd_to_drain = bh->next; bh->state = BUF_STATE_EMPTY; @@ -2359,6 +2375,7 @@ static int throw_away_data(struct fsg_dev *fsg) /* Throw away the data in a filled buffer */ if (bh->state == BUF_STATE_FULL) { + smp_rmb(); bh->state = BUF_STATE_EMPTY; fsg->next_buffhd_to_drain = bh->next; @@ -3024,6 +3041,7 @@ static int get_next_command(struct fsg_dev *fsg) if ((rc = sleep_thread(fsg)) != 0) return rc; } + smp_rmb(); rc = received_cbw(fsg, bh); bh->state = BUF_STATE_EMPTY; @@ -4072,7 +4090,6 @@ static int __init fsg_alloc(void) spin_lock_init(&fsg->lock); init_rwsem(&fsg->filesem); kref_init(&fsg->ref); - init_waitqueue_head(&fsg->thread_wqh); init_completion(&fsg->thread_notifier); the_fsg = fsg; -- cgit v1.1 From 3cf0a22e8b1b3f44288db773d315e72e89d51c4c Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 29 Nov 2005 12:08:15 -0500 Subject: [PATCH] USB Gadget: dummy_hcd: updates to hcd->state This patch (as613) moves the updates to hcd->state in the dummy_hcd driver to where they now belong. It also uses the new HC_FLAG_HW_ACCESSIBLE flag in a way that simulates a real PCI controller, and it adds checks for attempts to resume the bus while the controller is suspended or to suspend the controller while the bus is active. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/dummy_hcd.c | 43 ++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 4932b07..ce0d4b4 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -1576,7 +1576,7 @@ static int dummy_hub_status (struct usb_hcd *hcd, char *buf) dum = hcd_to_dummy (hcd); spin_lock_irqsave (&dum->lock, flags); - if (hcd->state != HC_STATE_RUNNING) + if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) goto done; if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) { @@ -1623,7 +1623,7 @@ static int dummy_hub_control ( int retval = 0; unsigned long flags; - if (hcd->state != HC_STATE_RUNNING) + if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) return -ETIMEDOUT; dum = hcd_to_dummy (hcd); @@ -1756,9 +1756,12 @@ static int dummy_bus_suspend (struct usb_hcd *hcd) { struct dummy *dum = hcd_to_dummy (hcd); + dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__); + spin_lock_irq (&dum->lock); dum->rh_state = DUMMY_RH_SUSPENDED; set_link_state (dum); + hcd->state = HC_STATE_SUSPENDED; spin_unlock_irq (&dum->lock); return 0; } @@ -1766,14 +1769,23 @@ static int dummy_bus_suspend (struct usb_hcd *hcd) static int dummy_bus_resume (struct usb_hcd *hcd) { struct dummy *dum = hcd_to_dummy (hcd); + int rc = 0; + + dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__); spin_lock_irq (&dum->lock); - dum->rh_state = DUMMY_RH_RUNNING; - set_link_state (dum); - if (!list_empty(&dum->urbp_list)) - mod_timer (&dum->timer, jiffies); + if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { + dev_warn (&hcd->self.root_hub->dev, "HC isn't running!\n"); + rc = -ENODEV; + } else { + dum->rh_state = DUMMY_RH_RUNNING; + set_link_state (dum); + if (!list_empty(&dum->urbp_list)) + mod_timer (&dum->timer, jiffies); + hcd->state = HC_STATE_RUNNING; + } spin_unlock_irq (&dum->lock); - return 0; + return rc; } /*-------------------------------------------------------------------------*/ @@ -1933,12 +1945,19 @@ static int dummy_hcd_remove (struct platform_device *pdev) static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state) { struct usb_hcd *hcd; + struct dummy *dum; + int rc = 0; dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); - hcd = platform_get_drvdata (pdev); - hcd->state = HC_STATE_SUSPENDED; - return 0; + hcd = platform_get_drvdata (pdev); + dum = hcd_to_dummy (hcd); + if (dum->rh_state == DUMMY_RH_RUNNING) { + dev_warn(&pdev->dev, "Root hub isn't suspended!\n"); + rc = -EBUSY; + } else + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + return rc; } static int dummy_hcd_resume (struct platform_device *pdev) @@ -1946,9 +1965,9 @@ static int dummy_hcd_resume (struct platform_device *pdev) struct usb_hcd *hcd; dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); - hcd = platform_get_drvdata (pdev); - hcd->state = HC_STATE_RUNNING; + hcd = platform_get_drvdata (pdev); + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); usb_hcd_poll_rh_status (hcd); return 0; } -- cgit v1.1 From 2425e9fe67cb5e66c173c4f604ddd8a5970d89e9 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 29 Nov 2005 12:13:31 -0500 Subject: [PATCH] USB: Don't assume root-hub resume succeeds This patch (as614) makes a small change to the part of the hub driver responsible for remote wakeup of root hubs. When these wakeups occur the driver is suspended, and in case the resume fails the driver should remain suspended -- it shouldn't try to proceed with its normal processing. This will hardly ever matter in normal use, but it did crop up while I was debugging a different problem. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a523c8f..650d5ee 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2697,6 +2697,8 @@ static void hub_events(void) if (i) { dpm_runtime_resume(&hdev->dev); dpm_runtime_resume(&intf->dev); + usb_put_intf(intf); + continue; } /* Lock the device, then check to see if we were -- cgit v1.1 From 9fe6fcd8ccb2c8c661dfd1e07e3122aef31a67d4 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 29 Nov 2005 14:01:55 +0100 Subject: [PATCH] USB: drivers/usb/misc/sisusbvga/sisusb.c: remove dead code The Coverity checker found this dead code. Signed-off-by: Adrian Bunk Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/sisusbvga/sisusb.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c index 44350d4..1ced113 100644 --- a/drivers/usb/misc/sisusbvga/sisusb.c +++ b/drivers/usb/misc/sisusbvga/sisusb.c @@ -863,9 +863,6 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, switch (length) { - case 0: - return ret; - case 1: if (userbuffer) { if (get_user(swap8, (u8 __user *)userbuffer)) @@ -1221,9 +1218,6 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, switch (length) { - case 0: - return ret; - case 1: ret |= sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, -- cgit v1.1 From 4c4c9432a6c916729c7296c47fe93b053a73e20c Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Tue, 29 Nov 2005 09:43:42 +0100 Subject: [PATCH] USB: mark various usb tables const patch below marks various USB tables and variables as const so that they end up in .rodata section and don't cacheline share with things that get written to. For the non-array variables it also allows gcc to optimize more. Signed-off-by: Arjan van de Ven Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-acm.c | 4 ++-- drivers/usb/class/usblp.c | 4 ++-- drivers/usb/core/devices.c | 20 ++++++++++---------- drivers/usb/host/uhci-debug.c | 2 +- drivers/usb/input/aiptek.c | 2 +- drivers/usb/input/ati_remote.c | 4 ++-- drivers/usb/input/fixp-arith.h | 2 +- drivers/usb/input/hid-core.c | 2 +- drivers/usb/input/hid-input.c | 4 ++-- drivers/usb/input/keyspan_remote.c | 2 +- drivers/usb/input/xpad.c | 6 +++--- drivers/usb/media/konicawc.c | 6 +++--- drivers/usb/media/ov511.c | 2 +- drivers/usb/media/pwc/pwc-ctrl.c | 2 +- drivers/usb/media/stv680.h | 6 +++--- drivers/usb/media/usbvideo.c | 2 +- drivers/usb/misc/sisusbvga/sisusb.c | 4 ++-- drivers/usb/serial/ftdi_sio.c | 2 +- drivers/usb/serial/io_edgeport.c | 2 +- drivers/usb/serial/io_fw_boot2.h | 2 +- drivers/usb/serial/safe_serial.c | 2 +- drivers/usb/storage/sddr09.c | 2 +- drivers/usb/storage/usb.c | 2 +- 23 files changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 93de121..248279e 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -658,7 +658,7 @@ static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int return -ENOIOCTLCMD; } -static __u32 acm_tty_speed[] = { +static const __u32 acm_tty_speed[] = { 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 576000, @@ -666,7 +666,7 @@ static __u32 acm_tty_speed[] = { 2500000, 3000000, 3500000, 4000000 }; -static __u8 acm_tty_size[] = { +static const __u8 acm_tty_size[] = { 5, 6, 7, 8 }; diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 10406b8..6918037 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -199,7 +199,7 @@ struct quirk_printer_struct { #define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */ #define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */ -static struct quirk_printer_struct quirk_printers[] = { +static const struct quirk_printer_struct quirk_printers[] = { { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */ { 0x03f0, 0x0104, USBLP_QUIRK_BIDIR }, /* HP DeskJet 880C */ { 0x03f0, 0x0204, USBLP_QUIRK_BIDIR }, /* HP DeskJet 815C */ @@ -301,7 +301,7 @@ static void usblp_bulk_write(struct urb *urb, struct pt_regs *regs) * Get and print printer errors. */ -static char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" }; +static const char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" }; static int usblp_check_status(struct usblp *usblp, int err) { diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 55bc563..2684e15 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c @@ -67,45 +67,45 @@ /* Define ALLOW_SERIAL_NUMBER if you want to see the serial number of devices */ #define ALLOW_SERIAL_NUMBER -static char *format_topo = +static const char *format_topo = /* T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd */ "\nT: Bus=%2.2d Lev=%2.2d Prnt=%2.2d Port=%2.2d Cnt=%2.2d Dev#=%3d Spd=%3s MxCh=%2d\n"; -static char *format_string_manufacturer = +static const char *format_string_manufacturer = /* S: Manufacturer=xxxx */ "S: Manufacturer=%.100s\n"; -static char *format_string_product = +static const char *format_string_product = /* S: Product=xxxx */ "S: Product=%.100s\n"; #ifdef ALLOW_SERIAL_NUMBER -static char *format_string_serialnumber = +static const char *format_string_serialnumber = /* S: SerialNumber=xxxx */ "S: SerialNumber=%.100s\n"; #endif -static char *format_bandwidth = +static const char *format_bandwidth = /* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; -static char *format_device1 = +static const char *format_device1 = /* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; -static char *format_device2 = +static const char *format_device2 = /* P: Vendor=xxxx ProdID=xxxx Rev=xx.xx */ "P: Vendor=%04x ProdID=%04x Rev=%2x.%02x\n"; -static char *format_config = +static const char *format_config = /* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; -static char *format_iface = +static const char *format_iface = /* I: If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=xxxx*/ "I: If#=%2d Alt=%2d #EPs=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x Driver=%s\n"; -static char *format_endpt = +static const char *format_endpt = /* E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=D?s */ "E: Ad=%02x(%c) Atr=%02x(%-4s) MxPS=%4d Ivl=%d%cs\n"; diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c index 151154d..cab02e1 100644 --- a/drivers/usb/host/uhci-debug.c +++ b/drivers/usb/host/uhci-debug.c @@ -197,7 +197,7 @@ out: } #ifdef CONFIG_PROC_FS -static const char *qh_names[] = { +static const char * const qh_names[] = { "skel_int128_qh", "skel_int64_qh", "skel_int32_qh", "skel_int16_qh", "skel_int8_qh", "skel_int4_qh", diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index 356284c..87ae08c 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c @@ -338,7 +338,7 @@ struct aiptek { * the bitmap which comes from the tablet. This hides the * issue that the F_keys are not sequentially numbered. */ -static int macroKeyEvents[] = { +static const int macroKeyEvents[] = { KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index 8948e5c..b78a4d8 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c @@ -146,7 +146,7 @@ static char init1[] = { 0x01, 0x00, 0x20, 0x14 }; static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 }; /* Acceleration curve for directional control pad */ -static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; +static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; /* Duplicate event filtering time. * Sequential, identical KIND_FILTERED inputs with less than @@ -197,7 +197,7 @@ struct ati_remote { #define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ /* Translation table from hardware messages to input events. */ -static struct { +static const struct { short kind; unsigned char data1, data2; int type; diff --git a/drivers/usb/input/fixp-arith.h b/drivers/usb/input/fixp-arith.h index 26ca5b8..b44d398 100644 --- a/drivers/usb/input/fixp-arith.h +++ b/drivers/usb/input/fixp-arith.h @@ -38,7 +38,7 @@ typedef s16 fixp_t; #define FRAC_MASK ((1<lock is down */ diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 857fe79..11da073 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -491,7 +491,7 @@ static struct usb_driver ftdi_driver = { .no_dynamic_id = 1, }; -static char *ftdi_chip_name[] = { +static const char *ftdi_chip_name[] = { [SIO] = "SIO", /* the serial part of FT8U100AX */ [FT8U232AM] = "FT8U232AM", [FT232BM] = "FT232BM", diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 4e2b599..89bb356 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -184,7 +184,7 @@ struct divisor_table_entry { // These assume a 3.6864MHz crystal, the standard /16, and // MCR.7 = 0. // -static struct divisor_table_entry divisor_table[] = { +static const struct divisor_table_entry divisor_table[] = { { 50, 4608}, { 75, 3072}, { 110, 2095}, /* 2094.545455 => 230450 => .0217 % over */ diff --git a/drivers/usb/serial/io_fw_boot2.h b/drivers/usb/serial/io_fw_boot2.h index c7c3a3c..e3463de 100644 --- a/drivers/usb/serial/io_fw_boot2.h +++ b/drivers/usb/serial/io_fw_boot2.h @@ -537,7 +537,7 @@ static unsigned char IMAGE_ARRAY_NAME[] = { }; -static struct edge_firmware_version_info IMAGE_VERSION_NAME = { +static const struct edge_firmware_version_info IMAGE_VERSION_NAME = { 2, 0, 3 }; // Major, Minor, Build #undef IMAGE_VERSION_NAME diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 3ea284c..86dc21c 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -167,7 +167,7 @@ static struct usb_driver safe_driver = { .no_dynamic_id = 1, }; -static __u16 crc10_table[256] = { +static const __u16 crc10_table[256] = { 0x000, 0x233, 0x255, 0x066, 0x299, 0x0aa, 0x0cc, 0x2ff, 0x301, 0x132, 0x154, 0x367, 0x198, 0x3ab, 0x3cd, 0x1fe, 0x031, 0x202, 0x264, 0x057, 0x2a8, 0x09b, 0x0fd, 0x2ce, 0x330, 0x103, 0x165, 0x356, 0x1a9, 0x39a, 0x3fc, 0x1cf, 0x062, 0x251, 0x237, 0x004, 0x2fb, 0x0c8, 0x0ae, 0x29d, 0x363, 0x150, 0x136, 0x305, 0x1fa, 0x3c9, 0x3af, 0x19c, diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 0ea2f5a..0a6efae 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -237,7 +237,7 @@ static void nand_store_ecc(unsigned char *data, unsigned char *ecc) { #define SPARE 0xfffffffe #define UNUSABLE 0xfffffffd -static int erase_bad_lba_entries = 0; +static const int erase_bad_lba_entries = 0; /* send vendor interface command (0x41) */ /* called for requests 0, 1, 8 */ diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 484ed29..356f471 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -470,7 +470,7 @@ static void get_device_info(struct us_data *us, const struct usb_device_id *id) * from the unusual_devs.h table. */ if (id->idVendor || id->idProduct) { - static char *msgs[3] = { + static const char *msgs[3] = { "an unneeded SubClass entry", "an unneeded Protocol entry", "unneeded SubClass and Protocol entries"}; -- cgit v1.1 From a5e36d20897ff8317e722fceb4d9eea3e4a5906b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 28 Nov 2005 22:15:46 +0000 Subject: [PATCH] USB: Correct ohci-pxa27x suspend/resume struct confusion The device data in ohci-pxa27x is a struct hcd, not a struct ohci_hcd. This correct the suspend/resume calls to account for this and adds some code to invalidate the platform data when the module is removed. Signed-off-by: Richard Purdie Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-pxa27x.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 3b1cfe9..acde886 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c @@ -309,20 +309,22 @@ static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) struct usb_hcd *hcd = platform_get_drvdata(pdev); usb_hcd_pxa27x_remove(hcd, pdev); + platform_set_drvdata(pdev, NULL); return 0; } #ifdef CONFIG_PM static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state) { - struct ohci_hcd *ohci = platform_get_drvdata(pdev); + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct ohci_hcd *ohci = hcd_to_ohci(hcd); if (time_before(jiffies, ohci->next_statechange)) msleep(5); ohci->next_statechange = jiffies; pxa27x_stop_hc(&pdev->dev); - ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; + hcd->state = HC_STATE_SUSPENDED; pdev->dev.power.power_state = PMSG_SUSPEND; return 0; @@ -330,7 +332,8 @@ static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) { - struct ohci_hcd *ohci = platform_get_drvdata(pdev); + struct usb_hcd *hcd = platform_get_drvdata(pdev); + struct ohci_hcd *ohci = hcd_to_ohci(hcd); int status; if (time_before(jiffies, ohci->next_statechange)) @@ -341,7 +344,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) return status; pdev->dev.power.power_state = PMSG_ON; - usb_hcd_resume_root_hub(platform_get_drvdata(pdev)); + usb_hcd_resume_root_hub(hcd); return 0; } -- cgit v1.1 From 17fa6e552f2fc6bb06af767b0abf9cb642e13404 Mon Sep 17 00:00:00 2001 From: fabien COSSE Date: Wed, 30 Nov 2005 01:16:00 -0800 Subject: [PATCH] USB Storage: add unusual_devs entry for NIKON Coolpix 2000 This patch adds an unusual_devs.h entry for NIKON Coolpix 2000 camera wich cause error: "Not Ready: Medium not present" Works fine with th patched kernel... Here are the informations in /proc/bus/usb/devices: T: Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=04b0 ProdID=0301 Rev= 0.10 S: Manufacturer=NIKON S: Product=NIKON DSC E2000 C:* #Ifs= 1 Cfg#= 1 Atr=c0 MxPwr= 0mA I: If#= 0 Alt= 0 #EPs= 3 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage E: Ad=01(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=83(I) Atr=03(Int.) MxPS= 8 Ivl=16ms Signed-off-by: Fabien COSSE Signed-off-by: Phil Dibowitz Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 76904ad..100f53c 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -187,6 +187,14 @@ UNUSUAL_DEV( 0x04b0, 0x0405, 0x0100, 0x0100, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_CAPACITY), +/* Patch for Nikon coolpix 2000 + * Submitted by Fabien Cosse */ +UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010, + "NIKON", + "NIKON DSC E2000", + US_SC_DEVICE, US_PR_DEVICE,NULL, + US_FL_NOT_LOCKABLE ), + /* BENQ DC5330 * Reported by Manuel Fombuena and * Frank Copeland */ -- cgit v1.1 From 95f209f93663103db2a8fb989e226ac68a98b036 Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Thu, 28 Jul 2005 15:32:20 +0200 Subject: [PATCH] USB: pl2303_update_line_status data length fix Minimum data length must be UART_STATE + 1, as data[UART_STATE] is being accessed for the new line_state. Although PL-2303 hardware is not expected to send data with exactly UART_STATE length, this keeps it on the safe side. Signed-off-by: Horst Schirmeier Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/pl2303.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index c96ba9f..f037210 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c @@ -810,7 +810,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port, struct pl2303_private *priv = usb_get_serial_port_data(port); unsigned long flags; u8 status_idx = UART_STATE; - u8 length = UART_STATE; + u8 length = UART_STATE + 1; if ((le16_to_cpu(port->serial->dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && (le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X65 || -- cgit v1.1 From f0b80fbf294bc4f6ec179b09fd5b63df25188259 Mon Sep 17 00:00:00 2001 From: Marcelo Feitoza Parisi Date: Thu, 1 Dec 2005 00:50:39 +0300 Subject: [PATCH] USB: ati_remote: use time_before() and friends They deal with wrapping correctly and are nicer to read. Signed-off-by: Marcelo Feitoza Parisi Signed-off-by: Alexey Dobriyan Signed-off-by: Greg Kroah-Hartman --- drivers/usb/input/ati_remote.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c index b78a4d8..f7bdc50 100644 --- a/drivers/usb/input/ati_remote.c +++ b/drivers/usb/input/ati_remote.c @@ -96,6 +96,7 @@ #include #include #include +#include /* * Module and Version Information, Module Parameters @@ -471,7 +472,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) /* Filter duplicate events which happen "too close" together. */ if ((ati_remote->old_data[0] == data[1]) && (ati_remote->old_data[1] == data[2]) && - ((ati_remote->old_jiffies + FILTER_TIME) > jiffies)) { + time_before(jiffies, ati_remote->old_jiffies + FILTER_TIME)) { ati_remote->repeat_count++; } else { ati_remote->repeat_count = 0; @@ -506,16 +507,16 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs) * pad down, so we increase acceleration, ramping up over two seconds to * a maximum speed. The acceleration curve is #defined above. */ - if ((jiffies - ati_remote->old_jiffies) > (HZ >> 2)) { + if (time_after(jiffies, ati_remote->old_jiffies + (HZ >> 2))) { acc = 1; ati_remote->acc_jiffies = jiffies; } - else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 3)) acc = accel[0]; - else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 2)) acc = accel[1]; - else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 1)) acc = accel[2]; - else if ((jiffies - ati_remote->acc_jiffies) < HZ ) acc = accel[3]; - else if ((jiffies - ati_remote->acc_jiffies) < HZ+(HZ>>1)) acc = accel[4]; - else if ((jiffies - ati_remote->acc_jiffies) < (HZ << 1)) acc = accel[5]; + else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 3))) acc = accel[0]; + else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 2))) acc = accel[1]; + else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 1))) acc = accel[2]; + else if (time_before(jiffies, ati_remote->acc_jiffies + HZ)) acc = accel[3]; + else if (time_before(jiffies, ati_remote->acc_jiffies + HZ+(HZ>>1))) acc = accel[4]; + else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ << 1))) acc = accel[5]; else acc = accel[6]; input_regs(dev, regs); -- cgit v1.1 From fa3465689f93331834a831bbe98e3863701e1068 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 30 Nov 2005 11:57:51 -0500 Subject: [PATCH] USB: UHCI: change uhci_explen macro This patch (as616) changed the uhci_explen macro in uhci-hcd.h so that it now accepts the desired length, rather than length - 1 with special handling for 0. This also fixes a minor bug that would show up only when a driver submits a 0-length bulk URB. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/uhci-hcd.c | 2 +- drivers/usb/host/uhci-hcd.h | 8 ++++---- drivers/usb/host/uhci-q.c | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 071fab6..120ca64 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -566,7 +566,7 @@ static int uhci_start(struct usb_hcd *hcd) uhci->skel_bulk_qh->link = cpu_to_le32(uhci->skel_term_qh->dma_handle) | UHCI_PTR_QH; /* This dummy TD is to work around a bug in Intel PIIX controllers */ - uhci_fill_td(uhci->term_td, 0, (UHCI_NULL_DATA_SIZE << 21) | + uhci_fill_td(uhci->term_td, 0, uhci_explen(0) | (0x7f << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_IN, 0); uhci->term_td->link = cpu_to_le32(uhci->term_td->dma_handle); diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h index e576db5..e43282e 100644 --- a/drivers/usb/host/uhci-hcd.h +++ b/drivers/usb/host/uhci-hcd.h @@ -71,8 +71,6 @@ #define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ #define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ -#define UHCI_NULL_DATA_SIZE 0x7FF /* for UHCI controller TD */ - #define UHCI_PTR_BITS cpu_to_le32(0x000F) #define UHCI_PTR_TERM cpu_to_le32(0x0001) #define UHCI_PTR_QH cpu_to_le32(0x0002) @@ -168,9 +166,11 @@ static __le32 inline qh_element(struct uhci_qh *qh) { #define TD_TOKEN_EXPLEN_MASK 0x7FF /* expected length, encoded as n - 1 */ #define TD_TOKEN_PID_MASK 0xFF -#define uhci_explen(len) ((len) << TD_TOKEN_EXPLEN_SHIFT) +#define uhci_explen(len) ((((len) - 1) & TD_TOKEN_EXPLEN_MASK) << \ + TD_TOKEN_EXPLEN_SHIFT) -#define uhci_expected_length(token) ((((token) >> 21) + 1) & TD_TOKEN_EXPLEN_MASK) +#define uhci_expected_length(token) ((((token) >> TD_TOKEN_EXPLEN_SHIFT) + \ + 1) & TD_TOKEN_EXPLEN_MASK) #define uhci_toggle(token) (((token) >> TD_TOKEN_TOGGLE_SHIFT) & 1) #define uhci_endpoint(token) (((token) >> 15) & 0xf) #define uhci_devaddr(token) (((token) >> TD_TOKEN_DEVADDR_SHIFT) & 0x7f) diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index 7e46887..ace9d15 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c @@ -596,7 +596,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur return -ENOMEM; uhci_add_td_to_urb(urb, td); - uhci_fill_td(td, status, destination | uhci_explen(7), + uhci_fill_td(td, status, destination | uhci_explen(8), urb->setup_dma); /* @@ -628,7 +628,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur destination ^= TD_TOKEN_TOGGLE; uhci_add_td_to_urb(urb, td); - uhci_fill_td(td, status, destination | uhci_explen(pktsze - 1), + uhci_fill_td(td, status, destination | uhci_explen(pktsze), data); data += pktsze; @@ -658,7 +658,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur uhci_add_td_to_urb(urb, td); uhci_fill_td(td, status | TD_CTRL_IOC, - destination | uhci_explen(UHCI_NULL_DATA_SIZE), 0); + destination | uhci_explen(0), 0); qh = uhci_alloc_qh(uhci); if (!qh) @@ -864,7 +864,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb return -ENOMEM; uhci_add_td_to_urb(urb, td); - uhci_fill_td(td, status, destination | uhci_explen(pktsze - 1) | + uhci_fill_td(td, status, destination | uhci_explen(pktsze) | (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT), data); @@ -890,7 +890,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb return -ENOMEM; uhci_add_td_to_urb(urb, td); - uhci_fill_td(td, status, destination | uhci_explen(UHCI_NULL_DATA_SIZE) | + uhci_fill_td(td, status, destination | uhci_explen(0) | (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT), data); @@ -1092,7 +1092,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb) return -ENOMEM; uhci_add_td_to_urb(urb, td); - uhci_fill_td(td, status, destination | uhci_explen(urb->iso_frame_desc[i].length - 1), + uhci_fill_td(td, status, destination | uhci_explen(urb->iso_frame_desc[i].length), urb->transfer_dma + urb->iso_frame_desc[i].offset); if (i + 1 >= urb->number_of_packets) -- cgit v1.1 From 687f5f3428157bea4940dd967fd7b4e59c1b13b4 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 30 Nov 2005 17:16:19 -0500 Subject: [PATCH] USB: UHCI: edit some comments This patch (as615b) edits a large number of comments in the uhci-hcd code, mainly removing excess apostrophes. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/uhci-debug.c | 12 ++++++------ drivers/usb/host/uhci-hcd.c | 17 +++++++++-------- drivers/usb/host/uhci-hcd.h | 24 ++++++++++++------------ drivers/usb/host/uhci-q.c | 18 +++++++++--------- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c index cab02e1..5832953 100644 --- a/drivers/usb/host/uhci-debug.c +++ b/drivers/usb/host/uhci-debug.c @@ -2,8 +2,8 @@ * UHCI-specific debugging code. Invaluable when something * goes wrong, but don't get in my face. * - * Kernel visible pointers are surrounded in []'s and bus - * visible pointers are surrounded in ()'s + * Kernel visible pointers are surrounded in []s and bus + * visible pointers are surrounded in ()s * * (C) Copyright 1999 Linus Torvalds * (C) Copyright 1999-2001 Johannes Erdfelt @@ -19,7 +19,7 @@ static struct dentry *uhci_debugfs_root = NULL; -/* Handle REALLY large printk's so we don't overflow buffers */ +/* Handle REALLY large printks so we don't overflow buffers */ static inline void lprintk(char *buf) { char *p; @@ -160,7 +160,7 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space) } if (active && ni > i) { - out += sprintf(out, "%*s[skipped %d active TD's]\n", space, "", ni - i); + out += sprintf(out, "%*s[skipped %d active TDs]\n", space, "", ni - i); tmp = ntmp; td = ntd; i = ni; @@ -173,7 +173,7 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space) if (list_empty(&urbp->queue_list) || urbp->queued) goto out; - out += sprintf(out, "%*sQueued QH's:\n", -space, "--"); + out += sprintf(out, "%*sQueued QHs:\n", -space, "--"); head = &urbp->queue_list; tmp = head->next; @@ -464,7 +464,7 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len) } while (tmp != head); } - out += sprintf(out, "Skeleton QH's\n"); + out += sprintf(out, "Skeleton QHs\n"); for (i = 0; i < UHCI_NUM_SKELQH; ++i) { int shown = 0; diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 120ca64..dfe121d 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c @@ -62,10 +62,10 @@ Alan Stern" /* * debug = 0, no debugging messages - * debug = 1, dump failed URB's except for stalls - * debug = 2, dump all failed URB's (including stalls) + * debug = 1, dump failed URBs except for stalls + * debug = 2, dump all failed URBs (including stalls) * show all queues in /debug/uhci/[pci_addr] - * debug = 3, show all TD's in URB's when dumping + * debug = 3, show all TDs in URBs when dumping */ #ifdef DEBUG static int debug = 1; @@ -88,7 +88,7 @@ static void uhci_get_current_frame_number(struct uhci_hcd *uhci); #define FSBR_DELAY msecs_to_jiffies(50) /* When we timeout an idle transfer for FSBR, we'll switch it over to */ -/* depth first traversal. We'll do it in groups of this number of TD's */ +/* depth first traversal. We'll do it in groups of this number of TDs */ /* to make sure it doesn't hog all of the bandwidth */ #define DEPTH_INTERVAL 5 @@ -728,8 +728,9 @@ static int uhci_resume(struct usb_hcd *hcd) dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); - /* We aren't in D3 state anymore, we do that even if dead as I - * really don't want to keep a stale HCD_FLAG_HW_ACCESSIBLE=0 + /* Since we aren't in D3 any more, it's safe to set this flag + * even if the controller was dead. It might not even be dead + * any more, if the firmware or quirks code has reset it. */ set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); mb(); @@ -879,7 +880,7 @@ static int __init uhci_hcd_init(void) init_failed: if (kmem_cache_destroy(uhci_up_cachep)) - warn("not all urb_priv's were freed!"); + warn("not all urb_privs were freed!"); up_failed: debugfs_remove(uhci_debugfs_root); @@ -897,7 +898,7 @@ static void __exit uhci_hcd_cleanup(void) pci_unregister_driver(&uhci_pci_driver); if (kmem_cache_destroy(uhci_up_cachep)) - warn("not all urb_priv's were freed!"); + warn("not all urb_privs were freed!"); debugfs_remove(uhci_debugfs_root); kfree(errbuf); diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h index e43282e..8b4b887 100644 --- a/drivers/usb/host/uhci-hcd.h +++ b/drivers/usb/host/uhci-hcd.h @@ -223,10 +223,10 @@ static u32 inline td_status(struct uhci_td *td) { */ /* - * The UHCI driver places Interrupt, Control and Bulk into QH's both - * to group together TD's for one transfer, and also to faciliate queuing - * of URB's. To make it easy to insert entries into the schedule, we have - * a skeleton of QH's for each predefined Interrupt latency, low-speed + * The UHCI driver places Interrupt, Control and Bulk into QHs both + * to group together TDs for one transfer, and also to facilitate queuing + * of URBs. To make it easy to insert entries into the schedule, we have + * a skeleton of QHs for each predefined Interrupt latency, low-speed * control, full-speed control and terminating QH (see explanation for * the terminating QH below). * @@ -257,8 +257,8 @@ static u32 inline td_status(struct uhci_td *td) { * reclamation. * * Isochronous transfers are stored before the start of the skeleton - * schedule and don't use QH's. While the UHCI spec doesn't forbid the - * use of QH's for Isochronous, it doesn't use them either. And the spec + * schedule and don't use QHs. While the UHCI spec doesn't forbid the + * use of QHs for Isochronous, it doesn't use them either. And the spec * says that queues never advance on an error completion status, which * makes them totally unsuitable for Isochronous transfers. */ @@ -359,7 +359,7 @@ struct uhci_hcd { struct dma_pool *td_pool; struct uhci_td *term_td; /* Terminating TD, see UHCI bug */ - struct uhci_qh *skelqh[UHCI_NUM_SKELQH]; /* Skeleton QH's */ + struct uhci_qh *skelqh[UHCI_NUM_SKELQH]; /* Skeleton QHs */ spinlock_t lock; @@ -389,22 +389,22 @@ struct uhci_hcd { unsigned long resuming_ports; unsigned long ports_timeout; /* Time to stop signalling */ - /* Main list of URB's currently controlled by this HC */ + /* Main list of URBs currently controlled by this HC */ struct list_head urb_list; - /* List of QH's that are done, but waiting to be unlinked (race) */ + /* List of QHs that are done, but waiting to be unlinked (race) */ struct list_head qh_remove_list; unsigned int qh_remove_age; /* Age in frames */ - /* List of TD's that are done, but waiting to be freed (race) */ + /* List of TDs that are done, but waiting to be freed (race) */ struct list_head td_remove_list; unsigned int td_remove_age; /* Age in frames */ - /* List of asynchronously unlinked URB's */ + /* List of asynchronously unlinked URBs */ struct list_head urb_remove_list; unsigned int urb_remove_age; /* Age in frames */ - /* List of URB's awaiting completion callback */ + /* List of URBs awaiting completion callback */ struct list_head complete_list; int rh_numports; /* Number of root-hub ports */ diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index ace9d15..b607600 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c @@ -80,7 +80,7 @@ static inline void uhci_fill_td(struct uhci_td *td, u32 status, } /* - * We insert Isochronous URB's directly into the frame list at the beginning + * We insert Isochronous URBs directly into the frame list at the beginning */ static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td, unsigned framenum) { @@ -369,7 +369,7 @@ static void uhci_append_queued_urb(struct uhci_hcd *uhci, struct urb *eurb, stru uhci_fixup_toggle(urb, uhci_toggle(td_token(lltd)) ^ 1)); - /* All qh's in the queue need to link to the next queue */ + /* All qhs in the queue need to link to the next queue */ urbp->qh->link = eurbp->qh->link; wmb(); /* Make sure we flush everything */ @@ -502,7 +502,7 @@ static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb) } /* Check to see if the remove list is empty. Set the IOC bit */ - /* to force an interrupt so we can remove the TD's*/ + /* to force an interrupt so we can remove the TDs*/ if (list_empty(&uhci->td_remove_list)) uhci_set_next_interrupt(uhci); @@ -612,7 +612,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur } /* - * Build the DATA TD's + * Build the DATA TDs */ while (len > 0) { int pktsze = len; @@ -744,7 +744,7 @@ static int uhci_result_control(struct uhci_hcd *uhci, struct urb *urb) urb->actual_length = 0; - /* The rest of the TD's (but the last) are data */ + /* The rest of the TDs (but the last) are data */ tmp = tmp->next; while (tmp != head && tmp->next != head) { unsigned int ctrlstat; @@ -848,7 +848,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb status |= TD_CTRL_SPD; /* - * Build the DATA TD's + * Build the DATA TDs */ do { /* Allow zero length packets */ int pktsze = maxsze; @@ -1025,7 +1025,7 @@ static int isochronous_find_limits(struct uhci_hcd *uhci, struct urb *urb, unsig list_for_each_entry(up, &uhci->urb_list, urb_list) { struct urb *u = up->urb; - /* look for pending URB's with identical pipe handle */ + /* look for pending URBs with identical pipe handle */ if ((urb->pipe == u->pipe) && (urb->dev == u->dev) && (u->status == -EINPROGRESS) && (u != urb)) { if (!last_urb) @@ -1355,7 +1355,7 @@ static void uhci_unlink_generic(struct uhci_hcd *uhci, struct urb *urb) uhci_delete_queued_urb(uhci, urb); - /* The interrupt loop will reclaim the QH's */ + /* The interrupt loop will reclaim the QHs */ uhci_remove_qh(uhci, urbp->qh); urbp->qh = NULL; } @@ -1413,7 +1413,7 @@ static int uhci_fsbr_timeout(struct uhci_hcd *uhci, struct urb *urb) list_for_each_entry(td, head, list) { /* * Make sure we don't do the last one (since it'll have the - * TERM bit set) as well as we skip every so many TD's to + * TERM bit set) as well as we skip every so many TDs to * make sure it doesn't hog the bandwidth */ if (td->list.next != head && (count % DEPTH_INTERVAL) == -- cgit v1.1 From b9b09422570e5e35a9f590a1ead63e711aefac8c Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sat, 3 Dec 2005 21:52:10 -0800 Subject: [PATCH] USB: Let usbmon collect less garbage Alan Stern pointed out that (in 2.6 kernel) one successful submission results in one callback, even for ISO-out transfers. Thus, the silly check can be removed from usbmon. This reduces the amount of garbage printed in case of ISO and Interrupt transfers. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mon/mon_text.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index 17d0190..6116121 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c @@ -97,19 +97,12 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb, if (len >= DATA_MAX) len = DATA_MAX; - /* - * Bulk is easy to shortcut reliably. - * XXX Other pipe types need consideration. Currently, we overdo it - * and collect garbage for them: better more than less. - */ - if (usb_pipebulk(pipe) || usb_pipecontrol(pipe)) { - if (usb_pipein(pipe)) { - if (ev_type == 'S') - return '<'; - } else { - if (ev_type == 'C') - return '>'; - } + if (usb_pipein(pipe)) { + if (ev_type == 'S') + return '<'; + } else { + if (ev_type == 'C') + return '>'; } /* -- cgit v1.1 From 7931e1c6f8007d5fef8a0bb2dc71bd97315eeae9 Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Sun, 4 Dec 2005 21:56:51 -0800 Subject: [PATCH] USB Storage: make OneTouch PM-aware The OneTouch subdriver submits its own interrupt URB for notifications about button presses. Consequently it needs to know about suspend and resume events, so it can cancel or restart the URB. This patch (as593) adds a hook to struct us_data, to be used for notifying subdrivers about Power Management events, and it implements the hook in the OneTouch driver. Signed-off-by: Alan Stern Signed-off-by: Nick Sillik Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/onetouch.c | 27 +++++++++++++++++++++++++++ drivers/usb/storage/usb.c | 4 ++++ drivers/usb/storage/usb.h | 9 ++++++++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index 89401a5..55ee2d3 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c @@ -52,6 +52,7 @@ struct usb_onetouch { struct urb *irq; /* urb for interrupt in report */ unsigned char *data; /* input data */ dma_addr_t data_dma; + unsigned int is_open:1; }; static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) @@ -89,6 +90,7 @@ static int usb_onetouch_open(struct input_dev *dev) { struct usb_onetouch *onetouch = dev->private; + onetouch->is_open = 1; onetouch->irq->dev = onetouch->udev; if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { err("usb_submit_urb failed"); @@ -103,8 +105,30 @@ static void usb_onetouch_close(struct input_dev *dev) struct usb_onetouch *onetouch = dev->private; usb_kill_urb(onetouch->irq); + onetouch->is_open = 0; } +#ifdef CONFIG_PM +static void usb_onetouch_pm_hook(struct us_data *us, int action) +{ + struct usb_onetouch *onetouch = (struct usb_onetouch *) us->extra; + + if (onetouch->is_open) { + switch (action) { + case US_SUSPEND: + usb_kill_urb(onetouch->irq); + break; + case US_RESUME: + if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0) + err("usb_submit_urb failed"); + break; + default: + break; + } + } +} +#endif /* CONFIG_PM */ + int onetouch_connect_input(struct us_data *ss) { struct usb_device *udev = ss->pusb_dev; @@ -185,6 +209,9 @@ int onetouch_connect_input(struct us_data *ss) ss->extra_destructor = onetouch_release_input; ss->extra = onetouch; +#ifdef CONFIG_PM + ss->suspend_resume_hook = usb_onetouch_pm_hook; +#endif input_register_device(onetouch->dev); diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 356f471..ca02ae9 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -188,6 +188,8 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message) down(&us->dev_semaphore); US_DEBUGP("%s\n", __FUNCTION__); + if (us->suspend_resume_hook) + (us->suspend_resume_hook)(us, US_SUSPEND); iface->dev.power.power_state.event = message.event; /* When runtime PM is working, we'll set a flag to indicate @@ -204,6 +206,8 @@ static int storage_resume(struct usb_interface *iface) down(&us->dev_semaphore); US_DEBUGP("%s\n", __FUNCTION__); + if (us->suspend_resume_hook) + (us->suspend_resume_hook)(us, US_RESUME); iface->dev.power.power_state.event = PM_EVENT_ON; up(&us->dev_semaphore); diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 0cd1eeb..7259fd1 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -93,7 +93,11 @@ struct us_unusual_dev { typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*); typedef int (*trans_reset)(struct us_data*); typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*); -typedef void (*extra_data_destructor)(void *); /* extra data destructor */ +typedef void (*extra_data_destructor)(void *); /* extra data destructor */ +typedef void (*pm_hook)(struct us_data *, int); /* power management hook */ + +#define US_SUSPEND 0 +#define US_RESUME 1 /* we allocate one of these for every device that we remember */ struct us_data { @@ -149,6 +153,9 @@ struct us_data { /* subdriver information */ void *extra; /* Any extra data */ extra_data_destructor extra_destructor;/* extra data destructor */ +#ifdef CONFIG_PM + pm_hook suspend_resume_hook; +#endif }; /* Convert between us_data and the corresponding Scsi_Host */ -- cgit v1.1 From f5b8cb9c91f2f7d54dc3f066db8d4e0f041de79b Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Sun, 4 Dec 2005 21:57:51 -0800 Subject: [PATCH] USB Storage: cleanups of sddr09 This is the first of three patches to prepare the sddr09 subdriver for conversion to the Sim-SCSI framework. This patch (as594) straightens out the initialization procedures and headers: Some ugly code from usb.c was moved into sddr09.c. Set-up of the private data structures was moved into the initialization routine. The connection between the "dpcm" version and the standalone version was clarified. A private declaration was moved from a header file into the subdriver's .c file. Signed-off-by: Alan Stern Acked-by: Andries Brouwer Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/initializers.h | 4 --- drivers/usb/storage/sddr09.c | 72 +++++++++++++++++++++++++++++--------- drivers/usb/storage/sddr09.h | 15 ++------ drivers/usb/storage/unusual_devs.h | 14 ++++---- drivers/usb/storage/usb.c | 22 ------------ 5 files changed, 64 insertions(+), 63 deletions(-) diff --git a/drivers/usb/storage/initializers.h b/drivers/usb/storage/initializers.h index 7372386..4c1b2bd 100644 --- a/drivers/usb/storage/initializers.h +++ b/drivers/usb/storage/initializers.h @@ -45,10 +45,6 @@ * mode */ int usb_stor_euscsi_init(struct us_data *us); -#ifdef CONFIG_USB_STORAGE_SDDR09 -int sddr09_init(struct us_data *us); -#endif - /* This function is required to activate all four slots on the UCR-61S2B * flash reader */ int usb_stor_ucr61s2b_init(struct us_data *us); diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 0a6efae..6c379b6 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -214,6 +214,20 @@ static void nand_store_ecc(unsigned char *data, unsigned char *ecc) { * The actual driver starts here. */ +struct sddr09_card_info { + unsigned long capacity; /* Size of card in bytes */ + int pagesize; /* Size of page in bytes */ + int pageshift; /* log2 of pagesize */ + int blocksize; /* Size of block in pages */ + int blockshift; /* log2 of blocksize */ + int blockmask; /* 2^blockshift - 1 */ + int *lba_to_pba; /* logical to physical map */ + int *pba_to_lba; /* physical to logical map */ + int lbact; /* number of available pages */ + int flags; +#define SDDR09_WP 1 /* write protected */ +}; + /* * On my 16MB card, control blocks have size 64 (16 real control bytes, * and 48 junk bytes). In reality of course the card uses 16 control bytes, @@ -1342,27 +1356,51 @@ sddr09_card_info_destructor(void *extra) { kfree(info->pba_to_lba); } -static void -sddr09_init_card_info(struct us_data *us) { - if (!us->extra) { - us->extra = kmalloc(sizeof(struct sddr09_card_info), GFP_NOIO); - if (us->extra) { - memset(us->extra, 0, sizeof(struct sddr09_card_info)); - us->extra_destructor = sddr09_card_info_destructor; - } +static int +sddr09_common_init(struct us_data *us) { + int result; + + /* set the configuration -- STALL is an acceptable response here */ + if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) { + US_DEBUGP("active config #%d != 1 ??\n", us->pusb_dev + ->actconfig->desc.bConfigurationValue); + return -EINVAL; + } + + result = usb_reset_configuration(us->pusb_dev); + US_DEBUGP("Result of usb_reset_configuration is %d\n", result); + if (result == -EPIPE) { + US_DEBUGP("-- stall on control interface\n"); + } else if (result != 0) { + /* it's not a stall, but another error -- time to bail */ + US_DEBUGP("-- Unknown error. Rejecting device\n"); + return -EINVAL; } + + us->extra = kzalloc(sizeof(struct sddr09_card_info), GFP_NOIO); + if (!us->extra) + return -ENOMEM; + us->extra_destructor = sddr09_card_info_destructor; + + nand_init_ecc(); + return 0; } + /* * This is needed at a very early stage. If this is not listed in the * unusual devices list but called from here then LUN 0 of the combo reader * is not recognized. But I do not know what precisely these calls do. */ int -sddr09_init(struct us_data *us) { +usb_stor_sddr09_dpcm_init(struct us_data *us) { int result; unsigned char *data = us->iobuf; + result = sddr09_common_init(us); + if (result) + return result; + result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2); if (result != USB_STOR_TRANSPORT_GOOD) { US_DEBUGP("sddr09_init: send_command fails\n"); @@ -1398,7 +1436,7 @@ sddr09_init(struct us_data *us) { // test unit ready - return USB_STOR_TRANSPORT_GOOD; /* not result */ + return 0; /* not result */ } /* @@ -1427,13 +1465,6 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) }; info = (struct sddr09_card_info *)us->extra; - if (!info) { - nand_init_ecc(); - sddr09_init_card_info(us); - info = (struct sddr09_card_info *)us->extra; - if (!info) - return USB_STOR_TRANSPORT_ERROR; - } if (srb->cmnd[0] == REQUEST_SENSE && havefakesense) { /* for a faked command, we have to follow with a faked sense */ @@ -1606,3 +1637,10 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) return USB_STOR_TRANSPORT_GOOD; } +/* + * Initialization routine for the sddr09 subdriver + */ +int +usb_stor_sddr09_init(struct us_data *us) { + return sddr09_common_init(us); +} diff --git a/drivers/usb/storage/sddr09.h b/drivers/usb/storage/sddr09.h index c9d78d6..c03089a 100644 --- a/drivers/usb/storage/sddr09.h +++ b/drivers/usb/storage/sddr09.h @@ -31,18 +31,7 @@ extern int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us); -struct sddr09_card_info { - unsigned long capacity; /* Size of card in bytes */ - int pagesize; /* Size of page in bytes */ - int pageshift; /* log2 of pagesize */ - int blocksize; /* Size of block in pages */ - int blockshift; /* log2 of blocksize */ - int blockmask; /* 2^blockshift - 1 */ - int *lba_to_pba; /* logical to physical map */ - int *pba_to_lba; /* physical to logical map */ - int lbact; /* number of available pages */ - int flags; -#define SDDR09_WP 1 /* write protected */ -}; +extern int usb_stor_sddr09_dpcm_init(struct us_data *us); +extern int usb_stor_sddr09_init(struct us_data *us); #endif diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 100f53c..be3c06d 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -284,14 +284,14 @@ UNUSUAL_DEV( 0x04e6, 0x0002, 0x0100, 0x0100, UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999, "Sandisk", "ImageMate SDDR09", - US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, - US_FL_SINGLE_LUN ), + US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, + 0), /* This entry is from Andries.Brouwer@cwi.nl */ UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208, "SCM Microsystems", "eUSB SmartMedia / CompactFlash Adapter", - US_SC_SCSI, US_PR_DPCM_USB, sddr09_init, + US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init, 0), #endif @@ -681,8 +681,8 @@ UNUSUAL_DEV( 0x0644, 0x0000, 0x0100, 0x0100, UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100, "Olympus", "Camedia MAUSB-2", - US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, - US_FL_SINGLE_LUN ), + US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, + 0), #endif /* Reported by Darsen Lu */ @@ -747,8 +747,8 @@ UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100, UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999, "Sandisk", "ImageMate SDDR-09", - US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, - US_FL_SINGLE_LUN ), + US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init, + 0), #endif #ifdef CONFIG_USB_STORAGE_FREECOM diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index ca02ae9..85c8c17 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -919,28 +919,6 @@ static int storage_probe(struct usb_interface *intf, */ get_device_info(us, id); -#ifdef CONFIG_USB_STORAGE_SDDR09 - if (us->protocol == US_PR_EUSB_SDDR09 || - us->protocol == US_PR_DPCM_USB) { - /* set the configuration -- STALL is an acceptable response here */ - if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) { - US_DEBUGP("active config #%d != 1 ??\n", us->pusb_dev - ->actconfig->desc.bConfigurationValue); - goto BadDevice; - } - result = usb_reset_configuration(us->pusb_dev); - - US_DEBUGP("Result of usb_reset_configuration is %d\n", result); - if (result == -EPIPE) { - US_DEBUGP("-- stall on control interface\n"); - } else if (result != 0) { - /* it's not a stall, but another error -- time to bail */ - US_DEBUGP("-- Unknown error. Rejecting device\n"); - goto BadDevice; - } - } -#endif - /* Get the transport, protocol, and pipe settings */ result = get_transport(us); if (result) -- cgit v1.1 From 0dc08a357538de3d93305fbf99348663abdbf2cd Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Sun, 4 Dec 2005 21:58:52 -0800 Subject: [PATCH] USB Storage: sddr09 cleanups This is the second of three patches to prepare the sddr09 subdriver for conversion to the Sim-SCSI framework. This patch (as595) updates the code to use standard error values for return codes instead of our special-purpose USB_STOR_TRANSPORT_... codes. The reverse update is then needed in the transport routine, but with the Sim-SCSI framework that routine will go away. Signed-off-by: Alan Stern Acked-by: Andries Brouwer Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/sddr09.c | 103 +++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 6c379b6..760fe93 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -274,8 +274,11 @@ sddr09_send_command(struct us_data *us, rc = usb_stor_ctrl_transfer(us, pipe, request, requesttype, 0, 0, xfer_data, xfer_len); - return (rc == USB_STOR_XFER_GOOD ? USB_STOR_TRANSPORT_GOOD : - USB_STOR_TRANSPORT_ERROR); + switch (rc) { + case USB_STOR_XFER_GOOD: return 0; + case USB_STOR_XFER_STALLED: return -EPIPE; + default: return -EIO; + } } static int @@ -322,20 +325,12 @@ sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) { command[4] = buflen; result = sddr09_send_scsi_command(us, command, 12); - if (result != USB_STOR_TRANSPORT_GOOD) { - US_DEBUGP("request sense failed\n"); + if (result) return result; - } result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, sensebuf, buflen, NULL); - if (result != USB_STOR_XFER_GOOD) { - US_DEBUGP("request sense bulk in failed\n"); - return USB_STOR_TRANSPORT_ERROR; - } else { - US_DEBUGP("request sense worked\n"); - return USB_STOR_TRANSPORT_GOOD; - } + return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); } /* @@ -383,7 +378,7 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress, result = sddr09_send_scsi_command(us, command, 12); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { US_DEBUGP("Result for send_control in sddr09_read2%d %d\n", x, result); return result; @@ -395,9 +390,9 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress, if (result != USB_STOR_XFER_GOOD) { US_DEBUGP("Result for bulk_transfer in sddr09_read2%d %d\n", x, result); - return USB_STOR_TRANSPORT_ERROR; + return -EIO; } - return USB_STOR_TRANSPORT_GOOD; + return 0; } /* @@ -511,7 +506,7 @@ sddr09_erase(struct us_data *us, unsigned long Eaddress) { result = sddr09_send_scsi_command(us, command, 12); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result) US_DEBUGP("Result for send_control in sddr09_erase %d\n", result); @@ -569,7 +564,7 @@ sddr09_writeX(struct us_data *us, result = sddr09_send_scsi_command(us, command, 12); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { US_DEBUGP("Result for send_control in sddr09_writeX %d\n", result); return result; @@ -581,9 +576,9 @@ sddr09_writeX(struct us_data *us, if (result != USB_STOR_XFER_GOOD) { US_DEBUGP("Result for bulk_transfer in sddr09_writeX %d\n", result); - return USB_STOR_TRANSPORT_ERROR; + return -EIO; } - return USB_STOR_TRANSPORT_GOOD; + return 0; } /* erase address, write same address */ @@ -647,7 +642,7 @@ sddr09_read_sg_test_only(struct us_data *us) { result = sddr09_send_scsi_command(us, command, 4*nsg+3); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { US_DEBUGP("Result for send_control in sddr09_read_sg %d\n", result); return result; @@ -655,7 +650,7 @@ sddr09_read_sg_test_only(struct us_data *us) { buf = (unsigned char *) kmalloc(bulklen, GFP_NOIO); if (!buf) - return USB_STOR_TRANSPORT_ERROR; + return -ENOMEM; result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, buf, bulklen, NULL); @@ -663,10 +658,10 @@ sddr09_read_sg_test_only(struct us_data *us) { if (result != USB_STOR_XFER_GOOD) { US_DEBUGP("Result for bulk_transfer in sddr09_read_sg %d\n", result); - return USB_STOR_TRANSPORT_ERROR; + return -EIO; } - return USB_STOR_TRANSPORT_GOOD; + return 0; } #endif @@ -695,14 +690,13 @@ sddr09_read_status(struct us_data *us, unsigned char *status) { command[1] = LUNBITS; result = sddr09_send_scsi_command(us, command, 12); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result) return result; result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, data, 64, NULL); *status = data[0]; - return (result == USB_STOR_XFER_GOOD ? - USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); + return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); } static int @@ -725,7 +719,7 @@ sddr09_read_data(struct us_data *us, buffer = kmalloc(len, GFP_NOIO); if (buffer == NULL) { printk("sddr09_read_data: Out of memory\n"); - return USB_STOR_TRANSPORT_ERROR; + return -ENOMEM; } // Figure out the initial LBA and page @@ -736,7 +730,7 @@ sddr09_read_data(struct us_data *us, // This could be made much more efficient by checking for // contiguous LBA's. Another exercise left to the student. - result = USB_STOR_TRANSPORT_GOOD; + result = 0; index = offset = 0; while (sectors > 0) { @@ -749,7 +743,7 @@ sddr09_read_data(struct us_data *us, if (lba >= maxlba) { US_DEBUGP("Error: Requested lba %u exceeds " "maximum %u\n", lba, maxlba); - result = USB_STOR_TRANSPORT_ERROR; + result = -EIO; break; } @@ -763,7 +757,7 @@ sddr09_read_data(struct us_data *us, /* This is not really an error. It just means that the block has never been written. - Instead of returning USB_STOR_TRANSPORT_ERROR + Instead of returning an error it is better to return all zero data. */ memset(buffer, 0, len); @@ -778,7 +772,7 @@ sddr09_read_data(struct us_data *us, result = sddr09_read20(us, address>>1, pages, info->pageshift, buffer, 0); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result) break; } @@ -844,7 +838,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba, pba = sddr09_find_unused_pba(info, lba); if (!pba) { printk("sddr09_write_lba: Out of unused blocks\n"); - return USB_STOR_TRANSPORT_ERROR; + return -ENOSPC; } info->pba_to_lba[pba] = lba; info->lba_to_pba[lba] = pba; @@ -855,7 +849,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba, /* Maybe it is impossible to write to PBA 1. Fake success, but don't do anything. */ printk("sddr09: avoid writing to pba 1\n"); - return USB_STOR_TRANSPORT_GOOD; + return 0; } pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); @@ -864,7 +858,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba, address = (pba << (info->pageshift + info->blockshift)); result = sddr09_read22(us, address>>1, info->blocksize, info->pageshift, blockbuffer, 0); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result) return result; /* check old contents and fill lba */ @@ -911,7 +905,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba, { unsigned char status = 0; int result2 = sddr09_read_status(us, &status); - if (result2 != USB_STOR_TRANSPORT_GOOD) + if (result2) US_DEBUGP("sddr09_write_inplace: cannot read status\n"); else if (status != 0xc0) US_DEBUGP("sddr09_write_inplace: status after write: 0x%x\n", @@ -952,7 +946,7 @@ sddr09_write_data(struct us_data *us, blockbuffer = kmalloc(blocklen, GFP_NOIO); if (!blockbuffer) { printk("sddr09_write_data: Out of memory\n"); - return USB_STOR_TRANSPORT_ERROR; + return -ENOMEM; } // Since we don't write the user data directly to the device, @@ -964,14 +958,14 @@ sddr09_write_data(struct us_data *us, if (buffer == NULL) { printk("sddr09_write_data: Out of memory\n"); kfree(blockbuffer); - return USB_STOR_TRANSPORT_ERROR; + return -ENOMEM; } // Figure out the initial LBA and page lba = address >> info->blockshift; page = (address & info->blockmask); - result = USB_STOR_TRANSPORT_GOOD; + result = 0; index = offset = 0; while (sectors > 0) { @@ -987,7 +981,7 @@ sddr09_write_data(struct us_data *us, result = sddr09_write_lba(us, lba, page, pages, buffer, blockbuffer); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result) break; page = 0; @@ -1036,7 +1030,7 @@ sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) { command[1] = LUNBITS; result = sddr09_send_scsi_command(us, command, 12); - if (result != USB_STOR_TRANSPORT_GOOD) + if (result) return result; result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, @@ -1045,8 +1039,7 @@ sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) { for (i = 0; i < 4; i++) deviceID[i] = content[i]; - return (result == USB_STOR_XFER_GOOD ? - USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR); + return (result == USB_STOR_XFER_GOOD ? 0 : -EIO); } static int @@ -1055,7 +1048,7 @@ sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) { unsigned char status; result = sddr09_read_status(us, &status); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { US_DEBUGP("sddr09_get_wp: read_status fails\n"); return result; } @@ -1071,7 +1064,7 @@ sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) { if (status & 0x1) US_DEBUGP(" Error"); US_DEBUGP("\n"); - return USB_STOR_TRANSPORT_GOOD; + return 0; } #if 0 @@ -1103,7 +1096,7 @@ sddr09_get_cardinfo(struct us_data *us, unsigned char flags) { result = sddr09_read_deviceID(us, deviceID); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { US_DEBUGP("Result of read_deviceID is %d\n", result); printk("sddr09: could not read card info\n"); return NULL; @@ -1214,7 +1207,7 @@ sddr09_read_map(struct us_data *us) { us, address>>1, min(alloc_blocks, numblocks - i), buffer, 0); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { result = -1; goto done; } @@ -1402,7 +1395,7 @@ usb_stor_sddr09_dpcm_init(struct us_data *us) { return result; result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { US_DEBUGP("sddr09_init: send_command fails\n"); return result; } @@ -1411,7 +1404,7 @@ usb_stor_sddr09_dpcm_init(struct us_data *us) { // get 07 02 result = sddr09_send_command(us, 0x08, USB_DIR_IN, data, 2); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { US_DEBUGP("sddr09_init: 2nd send_command fails\n"); return result; } @@ -1420,7 +1413,7 @@ usb_stor_sddr09_dpcm_init(struct us_data *us) { // get 07 00 result = sddr09_request_sense(us, data, 18); - if (result == USB_STOR_TRANSPORT_GOOD && data[2] != 0) { + if (result == 0 && data[2] != 0) { int j; for (j=0; j<18; j++) printk(" %02X", data[j]); @@ -1567,7 +1560,9 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) US_DEBUGP("READ_10: read page %d pagect %d\n", page, pages); - return sddr09_read_data(us, page, pages); + result = sddr09_read_data(us, page, pages); + return (result == 0 ? USB_STOR_TRANSPORT_GOOD : + USB_STOR_TRANSPORT_ERROR); } if (srb->cmnd[0] == WRITE_10) { @@ -1580,7 +1575,9 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) US_DEBUGP("WRITE_10: write page %d pagect %d\n", page, pages); - return sddr09_write_data(us, page, pages); + result = sddr09_write_data(us, page, pages); + return (result == 0 ? USB_STOR_TRANSPORT_GOOD : + USB_STOR_TRANSPORT_ERROR); } /* catch-all for all other commands, except @@ -1606,10 +1603,10 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) US_DEBUGP("SDDR09: Send control for command %s\n", ptr); result = sddr09_send_scsi_command(us, srb->cmnd, 12); - if (result != USB_STOR_TRANSPORT_GOOD) { + if (result) { US_DEBUGP("sddr09_transport: sddr09_send_scsi_command " "returns %d\n", result); - return result; + return USB_STOR_TRANSPORT_ERROR; } if (srb->request_bufflen == 0) -- cgit v1.1 From a6c976c6c4628ce0c9277c47e7545956d9d4f441 Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Sun, 4 Dec 2005 21:59:45 -0800 Subject: [PATCH] USB Storage: more sddr09 cleanups This is the third of three patches to prepare the sddr09 subdriver for conversion to the Sim-SCSI framework. This patch (as596) moves the computation of the LBA to the start of the read/write routines, so that addresses completely beyond the end of the device can be detected and reported differently from transfers that are partially within the device's capacity. Signed-off-by: Alan Stern Acked-by: Andries Brouwer Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/sddr09.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 760fe93..b8e7802 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c @@ -711,6 +711,13 @@ sddr09_read_data(struct us_data *us, unsigned int len, index, offset; int result; + // Figure out the initial LBA and page + lba = address >> info->blockshift; + page = (address & info->blockmask); + maxlba = info->capacity >> (info->pageshift + info->blockshift); + if (lba >= maxlba) + return -EIO; + // Since we only read in one block at a time, we have to create // a bounce buffer and move the data a piece at a time between the // bounce buffer and the actual transfer buffer. @@ -722,11 +729,6 @@ sddr09_read_data(struct us_data *us, return -ENOMEM; } - // Figure out the initial LBA and page - lba = address >> info->blockshift; - page = (address & info->blockmask); - maxlba = info->capacity >> (info->pageshift + info->blockshift); - // This could be made much more efficient by checking for // contiguous LBA's. Another exercise left to the student. @@ -928,13 +930,20 @@ sddr09_write_data(struct us_data *us, unsigned int sectors) { struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; - unsigned int lba, page, pages; + unsigned int lba, maxlba, page, pages; unsigned int pagelen, blocklen; unsigned char *blockbuffer; unsigned char *buffer; unsigned int len, index, offset; int result; + // Figure out the initial LBA and page + lba = address >> info->blockshift; + page = (address & info->blockmask); + maxlba = info->capacity >> (info->pageshift + info->blockshift); + if (lba >= maxlba) + return -EIO; + // blockbuffer is used for reading in the old data, overwriting // with the new data, and performing ECC calculations @@ -961,10 +970,6 @@ sddr09_write_data(struct us_data *us, return -ENOMEM; } - // Figure out the initial LBA and page - lba = address >> info->blockshift; - page = (address & info->blockmask); - result = 0; index = offset = 0; @@ -975,6 +980,14 @@ sddr09_write_data(struct us_data *us, pages = min(sectors, info->blocksize - page); len = (pages << info->pageshift); + /* Not overflowing capacity? */ + if (lba >= maxlba) { + US_DEBUGP("Error: Requested lba %u exceeds " + "maximum %u\n", lba, maxlba); + result = -EIO; + break; + } + // Get the data from the transfer buffer usb_stor_access_xfer_buf(buffer, len, us->srb, &index, &offset, FROM_XFER_BUF); -- cgit v1.1 From e80b0fade09ef1ee67b0898d480d4c588f124d5f Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Sun, 4 Dec 2005 22:02:44 -0800 Subject: [PATCH] USB Storage: add alauda support This patch adds another usb-storage subdriver, which supports two fairly old dual-XD/SmartMedia reader-writers (USB1.1 devices). This driver was written by Daniel Drake -- he notes that he wrote this driver without specs, however a vendor-supplied GPL driver for the previous generation of products ("sma03") did prove to be quite useful, as did the sddr09 driver which also has to deal with low-level physical block layout on SmartMedia. The original patch has been reformed by me, as it clashed with the libusual patches. We really need to consolidate some of this common SmartMedia code, and get together with the MTD guys to share it with them as well. Signed-off-by: Daniel Drake Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/Kconfig | 9 + drivers/usb/storage/Makefile | 1 + drivers/usb/storage/alauda.c | 1119 ++++++++++++++++++++++++++++++++++++ drivers/usb/storage/alauda.h | 100 ++++ drivers/usb/storage/unusual_devs.h | 14 + drivers/usb/storage/usb.c | 12 + include/linux/usb_usual.h | 3 + 7 files changed, 1258 insertions(+) create mode 100644 drivers/usb/storage/alauda.c create mode 100644 drivers/usb/storage/alauda.h diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index bdfcb95..92be101 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig @@ -112,6 +112,15 @@ config USB_STORAGE_JUMPSHOT Say Y here to include additional code to support the Lexar Jumpshot USB CompactFlash reader. +config USB_STORAGE_ALAUDA + bool "Olympus MAUSB-10/Fuji DPC-R1 support (EXPERIMENTAL)" + depends on USB_STORAGE && EXPERIMENTAL + help + Say Y here to include additional code to support the Olympus MAUSB-10 + and Fujifilm DPC-R1 USB Card reader/writer devices. + + These devices are based on the Alauda chip and support support both + XD and SmartMedia cards. config USB_STORAGE_ONETOUCH bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile index 2d416e9..8cbba22 100644 --- a/drivers/usb/storage/Makefile +++ b/drivers/usb/storage/Makefile @@ -18,6 +18,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_DPCM) += dpcm.o usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o +usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c new file mode 100644 index 0000000..4d3cbb1 --- /dev/null +++ b/drivers/usb/storage/alauda.c @@ -0,0 +1,1119 @@ +/* + * Driver for Alauda-based card readers + * + * Current development and maintenance by: + * (c) 2005 Daniel Drake + * + * The 'Alauda' is a chip manufacturered by RATOC for OEM use. + * + * Alauda implements a vendor-specific command set to access two media reader + * ports (XD, SmartMedia). This driver converts SCSI commands to the commands + * which are accepted by these devices. + * + * The driver was developed through reverse-engineering, with the help of the + * sddr09 driver which has many similarities, and with some help from the + * (very old) vendor-supplied GPL sma03 driver. + * + * For protocol info, see http://alauda.sourceforge.net + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include + +#include "usb.h" +#include "transport.h" +#include "protocol.h" +#include "debug.h" +#include "alauda.h" + +#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) +#define LSB_of(s) ((s)&0xFF) +#define MSB_of(s) ((s)>>8) + +#define MEDIA_PORT(us) us->srb->device->lun +#define MEDIA_INFO(us) ((struct alauda_info *)us->extra)->port[MEDIA_PORT(us)] + +#define PBA_LO(pba) ((pba & 0xF) << 5) +#define PBA_HI(pba) (pba >> 3) +#define PBA_ZONE(pba) (pba >> 11) + +/* + * Media handling + */ + +struct alauda_card_info { + unsigned char id; /* id byte */ + unsigned char chipshift; /* 1< LBA mappings for a particular port + */ +static void alauda_free_maps (struct alauda_media_info *media_info) +{ + unsigned int shift = media_info->zoneshift + + media_info->blockshift + media_info->pageshift; + unsigned int num_zones = media_info->capacity >> shift; + unsigned int i; + + if (media_info->lba_to_pba != NULL) + for (i = 0; i < num_zones; i++) { + kfree(media_info->lba_to_pba[i]); + media_info->lba_to_pba[i] = NULL; + } + + if (media_info->pba_to_lba != NULL) + for (i = 0; i < num_zones; i++) { + kfree(media_info->pba_to_lba[i]); + media_info->pba_to_lba[i] = NULL; + } +} + +/* + * Returns 2 bytes of status data + * The first byte describes media status, and second byte describes door status + */ +static int alauda_get_media_status(struct us_data *us, unsigned char *data) +{ + int rc; + unsigned char command; + + if (MEDIA_PORT(us) == ALAUDA_PORT_XD) + command = ALAUDA_GET_XD_MEDIA_STATUS; + else + command = ALAUDA_GET_SM_MEDIA_STATUS; + + rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, + command, 0xc0, 0, 1, data, 2); + + US_DEBUGP("alauda_get_media_status: Media status %02X %02X\n", + data[0], data[1]); + + return rc; +} + +/* + * Clears the "media was changed" bit so that we know when it changes again + * in the future. + */ +static int alauda_ack_media(struct us_data *us) +{ + unsigned char command; + + if (MEDIA_PORT(us) == ALAUDA_PORT_XD) + command = ALAUDA_ACK_XD_MEDIA_CHANGE; + else + command = ALAUDA_ACK_SM_MEDIA_CHANGE; + + return usb_stor_ctrl_transfer(us, us->send_ctrl_pipe, + command, 0x40, 0, 1, NULL, 0); +} + +/* + * Retrieves a 4-byte media signature, which indicates manufacturer, capacity, + * and some other details. + */ +static int alauda_get_media_signature(struct us_data *us, unsigned char *data) +{ + unsigned char command; + + if (MEDIA_PORT(us) == ALAUDA_PORT_XD) + command = ALAUDA_GET_XD_MEDIA_SIG; + else + command = ALAUDA_GET_SM_MEDIA_SIG; + + return usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe, + command, 0xc0, 0, 0, data, 4); +} + +/* + * Resets the media status (but not the whole device?) + */ +static int alauda_reset_media(struct us_data *us) +{ + unsigned char *command = us->iobuf; + + memset(command, 0, 9); + command[0] = ALAUDA_BULK_CMD; + command[1] = ALAUDA_BULK_RESET_MEDIA; + command[8] = MEDIA_PORT(us); + + return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, + command, 9, NULL); +} + +/* + * Examines the media and deduces capacity, etc. + */ +static int alauda_init_media(struct us_data *us) +{ + unsigned char *data = us->iobuf; + int ready = 0; + struct alauda_card_info *media_info; + unsigned int num_zones; + + while (ready == 0) { + msleep(20); + + if (alauda_get_media_status(us, data) != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; + + if (data[0] & 0x10) + ready = 1; + } + + US_DEBUGP("alauda_init_media: We are ready for action!\n"); + + if (alauda_ack_media(us) != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; + + msleep(10); + + if (alauda_get_media_status(us, data) != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; + + if (data[0] != 0x14) { + US_DEBUGP("alauda_init_media: Media not ready after ack\n"); + return USB_STOR_TRANSPORT_ERROR; + } + + if (alauda_get_media_signature(us, data) != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; + + US_DEBUGP("alauda_init_media: Media signature: %02X %02X %02X %02X\n", + data[0], data[1], data[2], data[3]); + media_info = alauda_card_find_id(data[1]); + if (media_info == NULL) { + printk("alauda_init_media: Unrecognised media signature: " + "%02X %02X %02X %02X\n", + data[0], data[1], data[2], data[3]); + return USB_STOR_TRANSPORT_ERROR; + } + + MEDIA_INFO(us).capacity = 1 << media_info->chipshift; + US_DEBUGP("Found media with capacity: %ldMB\n", + MEDIA_INFO(us).capacity >> 20); + + MEDIA_INFO(us).pageshift = media_info->pageshift; + MEDIA_INFO(us).blockshift = media_info->blockshift; + MEDIA_INFO(us).zoneshift = media_info->zoneshift; + + MEDIA_INFO(us).pagesize = 1 << media_info->pageshift; + MEDIA_INFO(us).blocksize = 1 << media_info->blockshift; + MEDIA_INFO(us).zonesize = 1 << media_info->zoneshift; + + MEDIA_INFO(us).uzonesize = ((1 << media_info->zoneshift) / 128) * 125; + MEDIA_INFO(us).blockmask = MEDIA_INFO(us).blocksize - 1; + + num_zones = MEDIA_INFO(us).capacity >> (MEDIA_INFO(us).zoneshift + + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift); + MEDIA_INFO(us).pba_to_lba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); + MEDIA_INFO(us).lba_to_pba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO); + + if (alauda_reset_media(us) != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; + + return USB_STOR_TRANSPORT_GOOD; +} + +/* + * Examines the media status and does the right thing when the media has gone, + * appeared, or changed. + */ +static int alauda_check_media(struct us_data *us) +{ + struct alauda_info *info = (struct alauda_info *) us->extra; + unsigned char status[2]; + int rc; + + rc = alauda_get_media_status(us, status); + + /* Check for no media or door open */ + if ((status[0] & 0x80) || ((status[0] & 0x1F) == 0x10) + || ((status[1] & 0x01) == 0)) { + US_DEBUGP("alauda_check_media: No media, or door open\n"); + alauda_free_maps(&MEDIA_INFO(us)); + info->sense_key = 0x02; + info->sense_asc = 0x3A; + info->sense_ascq = 0x00; + return USB_STOR_TRANSPORT_FAILED; + } + + /* Check for media change */ + if (status[0] & 0x08) { + US_DEBUGP("alauda_check_media: Media change detected\n"); + alauda_free_maps(&MEDIA_INFO(us)); + alauda_init_media(us); + + info->sense_key = UNIT_ATTENTION; + info->sense_asc = 0x28; + info->sense_ascq = 0x00; + return USB_STOR_TRANSPORT_FAILED; + } + + return USB_STOR_TRANSPORT_GOOD; +} + +/* + * Checks the status from the 2nd status register + * Returns 3 bytes of status data, only the first is known + */ +static int alauda_check_status2(struct us_data *us) +{ + int rc; + unsigned char command[] = { + ALAUDA_BULK_CMD, ALAUDA_BULK_GET_STATUS2, + 0, 0, 0, 0, 3, 0, MEDIA_PORT(us) + }; + unsigned char data[3]; + + rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, + command, 9, NULL); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + rc = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, + data, 3, NULL); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + US_DEBUGP("alauda_check_status2: %02X %02X %02X\n", data[0], data[1], data[2]); + if (data[0] & ALAUDA_STATUS_ERROR) + return USB_STOR_XFER_ERROR; + + return USB_STOR_XFER_GOOD; +} + +/* + * Gets the redundancy data for the first page of a PBA + * Returns 16 bytes. + */ +static int alauda_get_redu_data(struct us_data *us, u16 pba, unsigned char *data) +{ + int rc; + unsigned char command[] = { + ALAUDA_BULK_CMD, ALAUDA_BULK_GET_REDU_DATA, + PBA_HI(pba), PBA_ZONE(pba), 0, PBA_LO(pba), 0, 0, MEDIA_PORT(us) + }; + + rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, + command, 9, NULL); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, + data, 16, NULL); +} + +/* + * Finds the first unused PBA in a zone + * Returns the absolute PBA of an unused PBA, or 0 if none found. + */ +static u16 alauda_find_unused_pba(struct alauda_media_info *info, + unsigned int zone) +{ + u16 *pba_to_lba = info->pba_to_lba[zone]; + unsigned int i; + + for (i = 0; i < info->zonesize; i++) + if (pba_to_lba[i] == UNDEF) + return (zone << info->zoneshift) + i; + + return 0; +} + +/* + * Reads the redundancy data for all PBA's in a zone + * Produces lba <--> pba mappings + */ +static int alauda_read_map(struct us_data *us, unsigned int zone) +{ + unsigned char *data = us->iobuf; + int result; + int i, j; + unsigned int zonesize = MEDIA_INFO(us).zonesize; + unsigned int uzonesize = MEDIA_INFO(us).uzonesize; + unsigned int lba_offset, lba_real, blocknum; + unsigned int zone_base_lba = zone * uzonesize; + unsigned int zone_base_pba = zone * zonesize; + u16 *lba_to_pba = kcalloc(zonesize, sizeof(u16), GFP_NOIO); + u16 *pba_to_lba = kcalloc(zonesize, sizeof(u16), GFP_NOIO); + if (lba_to_pba == NULL || pba_to_lba == NULL) { + result = USB_STOR_TRANSPORT_ERROR; + goto error; + } + + US_DEBUGP("alauda_read_map: Mapping blocks for zone %d\n", zone); + + /* 1024 PBA's per zone */ + for (i = 0; i < zonesize; i++) + lba_to_pba[i] = pba_to_lba[i] = UNDEF; + + for (i = 0; i < zonesize; i++) { + blocknum = zone_base_pba + i; + + result = alauda_get_redu_data(us, blocknum, data); + if (result != USB_STOR_XFER_GOOD) { + result = USB_STOR_TRANSPORT_ERROR; + goto error; + } + + /* special PBAs have control field 0^16 */ + for (j = 0; j < 16; j++) + if (data[j] != 0) + goto nonz; + pba_to_lba[i] = UNUSABLE; + US_DEBUGP("alauda_read_map: PBA %d has no logical mapping\n", blocknum); + continue; + + nonz: + /* unwritten PBAs have control field FF^16 */ + for (j = 0; j < 16; j++) + if (data[j] != 0xff) + goto nonff; + continue; + + nonff: + /* normal PBAs start with six FFs */ + if (j < 6) { + US_DEBUGP("alauda_read_map: PBA %d has no logical mapping: " + "reserved area = %02X%02X%02X%02X " + "data status %02X block status %02X\n", + blocknum, data[0], data[1], data[2], data[3], + data[4], data[5]); + pba_to_lba[i] = UNUSABLE; + continue; + } + + if ((data[6] >> 4) != 0x01) { + US_DEBUGP("alauda_read_map: PBA %d has invalid address " + "field %02X%02X/%02X%02X\n", + blocknum, data[6], data[7], data[11], data[12]); + pba_to_lba[i] = UNUSABLE; + continue; + } + + /* check even parity */ + if (parity[data[6] ^ data[7]]) { + printk("alauda_read_map: Bad parity in LBA for block %d" + " (%02X %02X)\n", i, data[6], data[7]); + pba_to_lba[i] = UNUSABLE; + continue; + } + + lba_offset = short_pack(data[7], data[6]); + lba_offset = (lba_offset & 0x07FF) >> 1; + lba_real = lba_offset + zone_base_lba; + + /* + * Every 1024 physical blocks ("zone"), the LBA numbers + * go back to zero, but are within a higher block of LBA's. + * Also, there is a maximum of 1000 LBA's per zone. + * In other words, in PBA 1024-2047 you will find LBA 0-999 + * which are really LBA 1000-1999. This allows for 24 bad + * or special physical blocks per zone. + */ + + if (lba_offset >= uzonesize) { + printk("alauda_read_map: Bad low LBA %d for block %d\n", + lba_real, blocknum); + continue; + } + + if (lba_to_pba[lba_offset] != UNDEF) { + printk("alauda_read_map: LBA %d seen for PBA %d and %d\n", + lba_real, lba_to_pba[lba_offset], blocknum); + continue; + } + + pba_to_lba[i] = lba_real; + lba_to_pba[lba_offset] = blocknum; + continue; + } + + MEDIA_INFO(us).lba_to_pba[zone] = lba_to_pba; + MEDIA_INFO(us).pba_to_lba[zone] = pba_to_lba; + result = 0; + goto out; + +error: + kfree(lba_to_pba); + kfree(pba_to_lba); +out: + return result; +} + +/* + * Checks to see whether we have already mapped a certain zone + * If we haven't, the map is generated + */ +static void alauda_ensure_map_for_zone(struct us_data *us, unsigned int zone) +{ + if (MEDIA_INFO(us).lba_to_pba[zone] == NULL + || MEDIA_INFO(us).pba_to_lba[zone] == NULL) + alauda_read_map(us, zone); +} + +/* + * Erases an entire block + */ +static int alauda_erase_block(struct us_data *us, u16 pba) +{ + int rc; + unsigned char command[] = { + ALAUDA_BULK_CMD, ALAUDA_BULK_ERASE_BLOCK, PBA_HI(pba), + PBA_ZONE(pba), 0, PBA_LO(pba), 0x02, 0, MEDIA_PORT(us) + }; + unsigned char buf[2]; + + US_DEBUGP("alauda_erase_block: Erasing PBA %d\n", pba); + + rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, + command, 9, NULL); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + rc = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, + buf, 2, NULL); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + US_DEBUGP("alauda_erase_block: Erase result: %02X %02X\n", + buf[0], buf[1]); + return rc; +} + +/* + * Reads data from a certain offset page inside a PBA, including interleaved + * redundancy data. Returns (pagesize+64)*pages bytes in data. + */ +static int alauda_read_block_raw(struct us_data *us, u16 pba, + unsigned int page, unsigned int pages, unsigned char *data) +{ + int rc; + unsigned char command[] = { + ALAUDA_BULK_CMD, ALAUDA_BULK_READ_BLOCK, PBA_HI(pba), + PBA_ZONE(pba), 0, PBA_LO(pba) + page, pages, 0, MEDIA_PORT(us) + }; + + US_DEBUGP("alauda_read_block: pba %d page %d count %d\n", + pba, page, pages); + + rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, + command, 9, NULL); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, + data, (MEDIA_INFO(us).pagesize + 64) * pages, NULL); +} + +/* + * Reads data from a certain offset page inside a PBA, excluding redundancy + * data. Returns pagesize*pages bytes in data. Note that data must be big enough + * to hold (pagesize+64)*pages bytes of data, but you can ignore those 'extra' + * trailing bytes outside this function. + */ +static int alauda_read_block(struct us_data *us, u16 pba, + unsigned int page, unsigned int pages, unsigned char *data) +{ + int i, rc; + unsigned int pagesize = MEDIA_INFO(us).pagesize; + + rc = alauda_read_block_raw(us, pba, page, pages, data); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + /* Cut out the redundancy data */ + for (i = 0; i < pages; i++) { + int dest_offset = i * pagesize; + int src_offset = i * (pagesize + 64); + memmove(data + dest_offset, data + src_offset, pagesize); + } + + return rc; +} + +/* + * Writes an entire block of data and checks status after write. + * Redundancy data must be already included in data. Data should be + * (pagesize+64)*blocksize bytes in length. + */ +static int alauda_write_block(struct us_data *us, u16 pba, unsigned char *data) +{ + int rc; + struct alauda_info *info = (struct alauda_info *) us->extra; + unsigned char command[] = { + ALAUDA_BULK_CMD, ALAUDA_BULK_WRITE_BLOCK, PBA_HI(pba), + PBA_ZONE(pba), 0, PBA_LO(pba), 32, 0, MEDIA_PORT(us) + }; + + US_DEBUGP("alauda_write_block: pba %d\n", pba); + + rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, + command, 9, NULL); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + rc = usb_stor_bulk_transfer_buf(us, info->wr_ep, data, + (MEDIA_INFO(us).pagesize + 64) * MEDIA_INFO(us).blocksize, + NULL); + if (rc != USB_STOR_XFER_GOOD) + return rc; + + return alauda_check_status2(us); +} + +/* + * Write some data to a specific LBA. + */ +static int alauda_write_lba(struct us_data *us, u16 lba, + unsigned int page, unsigned int pages, + unsigned char *ptr, unsigned char *blockbuffer) +{ + u16 pba, lbap, new_pba; + unsigned char *bptr, *cptr, *xptr; + unsigned char ecc[3]; + int i, result; + unsigned int uzonesize = MEDIA_INFO(us).uzonesize; + unsigned int zonesize = MEDIA_INFO(us).zonesize; + unsigned int pagesize = MEDIA_INFO(us).pagesize; + unsigned int blocksize = MEDIA_INFO(us).blocksize; + unsigned int lba_offset = lba % uzonesize; + unsigned int new_pba_offset; + unsigned int zone = lba / uzonesize; + + alauda_ensure_map_for_zone(us, zone); + + pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; + if (pba == 1) { + /* Maybe it is impossible to write to PBA 1. + Fake success, but don't do anything. */ + printk("alauda_write_lba: avoid writing to pba 1\n"); + return USB_STOR_TRANSPORT_GOOD; + } + + new_pba = alauda_find_unused_pba(&MEDIA_INFO(us), zone); + if (!new_pba) { + printk("alauda_write_lba: Out of unused blocks\n"); + return USB_STOR_TRANSPORT_ERROR; + } + + /* read old contents */ + if (pba != UNDEF) { + result = alauda_read_block_raw(us, pba, 0, + blocksize, blockbuffer); + if (result != USB_STOR_XFER_GOOD) + return result; + } else { + memset(blockbuffer, 0, blocksize * (pagesize + 64)); + } + + lbap = (lba_offset << 1) | 0x1000; + if (parity[MSB_of(lbap) ^ LSB_of(lbap)]) + lbap ^= 1; + + /* check old contents and fill lba */ + for (i = 0; i < blocksize; i++) { + bptr = blockbuffer + (i * (pagesize + 64)); + cptr = bptr + pagesize; + nand_compute_ecc(bptr, ecc); + if (!nand_compare_ecc(cptr+13, ecc)) { + US_DEBUGP("Warning: bad ecc in page %d- of pba %d\n", + i, pba); + nand_store_ecc(cptr+13, ecc); + } + nand_compute_ecc(bptr + (pagesize / 2), ecc); + if (!nand_compare_ecc(cptr+8, ecc)) { + US_DEBUGP("Warning: bad ecc in page %d+ of pba %d\n", + i, pba); + nand_store_ecc(cptr+8, ecc); + } + cptr[6] = cptr[11] = MSB_of(lbap); + cptr[7] = cptr[12] = LSB_of(lbap); + } + + /* copy in new stuff and compute ECC */ + xptr = ptr; + for (i = page; i < page+pages; i++) { + bptr = blockbuffer + (i * (pagesize + 64)); + cptr = bptr + pagesize; + memcpy(bptr, xptr, pagesize); + xptr += pagesize; + nand_compute_ecc(bptr, ecc); + nand_store_ecc(cptr+13, ecc); + nand_compute_ecc(bptr + (pagesize / 2), ecc); + nand_store_ecc(cptr+8, ecc); + } + + result = alauda_write_block(us, new_pba, blockbuffer); + if (result != USB_STOR_XFER_GOOD) + return result; + + new_pba_offset = new_pba - (zone * zonesize); + MEDIA_INFO(us).pba_to_lba[zone][new_pba_offset] = lba; + MEDIA_INFO(us).lba_to_pba[zone][lba_offset] = new_pba; + US_DEBUGP("alauda_write_lba: Remapped LBA %d to PBA %d\n", + lba, new_pba); + + if (pba != UNDEF) { + unsigned int pba_offset = pba - (zone * zonesize); + result = alauda_erase_block(us, pba); + if (result != USB_STOR_XFER_GOOD) + return result; + MEDIA_INFO(us).pba_to_lba[zone][pba_offset] = UNDEF; + } + + return USB_STOR_TRANSPORT_GOOD; +} + +/* + * Read data from a specific sector address + */ +static int alauda_read_data(struct us_data *us, unsigned long address, + unsigned int sectors) +{ + unsigned char *buffer; + u16 lba, max_lba; + unsigned int page, len, index, offset; + unsigned int blockshift = MEDIA_INFO(us).blockshift; + unsigned int pageshift = MEDIA_INFO(us).pageshift; + unsigned int blocksize = MEDIA_INFO(us).blocksize; + unsigned int pagesize = MEDIA_INFO(us).pagesize; + unsigned int uzonesize = MEDIA_INFO(us).uzonesize; + int result; + + /* + * Since we only read in one block at a time, we have to create + * a bounce buffer and move the data a piece at a time between the + * bounce buffer and the actual transfer buffer. + * We make this buffer big enough to hold temporary redundancy data, + * which we use when reading the data blocks. + */ + + len = min(sectors, blocksize) * (pagesize + 64); + buffer = kmalloc(len, GFP_NOIO); + if (buffer == NULL) { + printk("alauda_read_data: Out of memory\n"); + return USB_STOR_TRANSPORT_ERROR; + } + + /* Figure out the initial LBA and page */ + lba = address >> blockshift; + page = (address & MEDIA_INFO(us).blockmask); + max_lba = MEDIA_INFO(us).capacity >> (blockshift + pageshift); + + result = USB_STOR_TRANSPORT_GOOD; + index = offset = 0; + + while (sectors > 0) { + unsigned int zone = lba / uzonesize; /* integer division */ + unsigned int lba_offset = lba - (zone * uzonesize); + unsigned int pages; + u16 pba; + alauda_ensure_map_for_zone(us, zone); + + /* Not overflowing capacity? */ + if (lba >= max_lba) { + US_DEBUGP("Error: Requested lba %u exceeds " + "maximum %u\n", lba, max_lba); + result = USB_STOR_TRANSPORT_ERROR; + break; + } + + /* Find number of pages we can read in this block */ + pages = min(sectors, blocksize - page); + len = pages << pageshift; + + /* Find where this lba lives on disk */ + pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset]; + + if (pba == UNDEF) { /* this lba was never written */ + US_DEBUGP("Read %d zero pages (LBA %d) page %d\n", + pages, lba, page); + + /* This is not really an error. It just means + that the block has never been written. + Instead of returning USB_STOR_TRANSPORT_ERROR + it is better to return all zero data. */ + + memset(buffer, 0, len); + } else { + US_DEBUGP("Read %d pages, from PBA %d" + " (LBA %d) page %d\n", + pages, pba, lba, page); + + result = alauda_read_block(us, pba, page, pages, buffer); + if (result != USB_STOR_TRANSPORT_GOOD) + break; + } + + /* Store the data in the transfer buffer */ + usb_stor_access_xfer_buf(buffer, len, us->srb, + &index, &offset, TO_XFER_BUF); + + page = 0; + lba++; + sectors -= pages; + } + + kfree(buffer); + return result; +} + +/* + * Write data to a specific sector address + */ +static int alauda_write_data(struct us_data *us, unsigned long address, + unsigned int sectors) +{ + unsigned char *buffer, *blockbuffer; + unsigned int page, len, index, offset; + unsigned int blockshift = MEDIA_INFO(us).blockshift; + unsigned int pageshift = MEDIA_INFO(us).pageshift; + unsigned int blocksize = MEDIA_INFO(us).blocksize; + unsigned int pagesize = MEDIA_INFO(us).pagesize; + u16 lba, max_lba; + int result; + + /* + * Since we don't write the user data directly to the device, + * we have to create a bounce buffer and move the data a piece + * at a time between the bounce buffer and the actual transfer buffer. + */ + + len = min(sectors, blocksize) * pagesize; + buffer = kmalloc(len, GFP_NOIO); + if (buffer == NULL) { + printk("alauda_write_data: Out of memory\n"); + return USB_STOR_TRANSPORT_ERROR; + } + + /* + * We also need a temporary block buffer, where we read in the old data, + * overwrite parts with the new data, and manipulate the redundancy data + */ + blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO); + if (blockbuffer == NULL) { + printk("alauda_write_data: Out of memory\n"); + kfree(buffer); + return USB_STOR_TRANSPORT_ERROR; + } + + /* Figure out the initial LBA and page */ + lba = address >> blockshift; + page = (address & MEDIA_INFO(us).blockmask); + max_lba = MEDIA_INFO(us).capacity >> (pageshift + blockshift); + + result = USB_STOR_TRANSPORT_GOOD; + index = offset = 0; + + while (sectors > 0) { + /* Write as many sectors as possible in this block */ + unsigned int pages = min(sectors, blocksize - page); + len = pages << pageshift; + + /* Not overflowing capacity? */ + if (lba >= max_lba) { + US_DEBUGP("alauda_write_data: Requested lba %u exceeds " + "maximum %u\n", lba, max_lba); + result = USB_STOR_TRANSPORT_ERROR; + break; + } + + /* Get the data from the transfer buffer */ + usb_stor_access_xfer_buf(buffer, len, us->srb, + &index, &offset, FROM_XFER_BUF); + + result = alauda_write_lba(us, lba, page, pages, buffer, + blockbuffer); + if (result != USB_STOR_TRANSPORT_GOOD) + break; + + page = 0; + lba++; + sectors -= pages; + } + + kfree(buffer); + kfree(blockbuffer); + return result; +} + +/* + * Our interface with the rest of the world + */ + +static void alauda_info_destructor(void *extra) +{ + struct alauda_info *info = (struct alauda_info *) extra; + int port; + + if (!info) + return; + + for (port = 0; port < 2; port++) { + struct alauda_media_info *media_info = &info->port[port]; + + alauda_free_maps(media_info); + kfree(media_info->lba_to_pba); + kfree(media_info->pba_to_lba); + } +} + +/* + * Initialize alauda_info struct and find the data-write endpoint + */ +int init_alauda(struct us_data *us) +{ + struct alauda_info *info; + struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting; + nand_init_ecc(); + + us->extra = kzalloc(sizeof(struct alauda_info), GFP_NOIO); + if (!us->extra) { + US_DEBUGP("init_alauda: Gah! Can't allocate storage for" + "alauda info struct!\n"); + return USB_STOR_TRANSPORT_ERROR; + } + info = (struct alauda_info *) us->extra; + us->extra_destructor = alauda_info_destructor; + + info->wr_ep = usb_sndbulkpipe(us->pusb_dev, + altsetting->endpoint[0].desc.bEndpointAddress + & USB_ENDPOINT_NUMBER_MASK); + + return USB_STOR_TRANSPORT_GOOD; +} + +int alauda_transport(struct scsi_cmnd *srb, struct us_data *us) +{ + int rc; + struct alauda_info *info = (struct alauda_info *) us->extra; + unsigned char *ptr = us->iobuf; + static unsigned char inquiry_response[36] = { + 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00 + }; + + if (srb->cmnd[0] == INQUIRY) { + US_DEBUGP("alauda_transport: INQUIRY. " + "Returning bogus response.\n"); + memcpy(ptr, inquiry_response, sizeof(inquiry_response)); + fill_inquiry_response(us, ptr, 36); + return USB_STOR_TRANSPORT_GOOD; + } + + if (srb->cmnd[0] == TEST_UNIT_READY) { + US_DEBUGP("alauda_transport: TEST_UNIT_READY.\n"); + return alauda_check_media(us); + } + + if (srb->cmnd[0] == READ_CAPACITY) { + unsigned int num_zones; + unsigned long capacity; + + rc = alauda_check_media(us); + if (rc != USB_STOR_TRANSPORT_GOOD) + return rc; + + num_zones = MEDIA_INFO(us).capacity >> (MEDIA_INFO(us).zoneshift + + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift); + + capacity = num_zones * MEDIA_INFO(us).uzonesize + * MEDIA_INFO(us).blocksize; + + /* Report capacity and page size */ + ((__be32 *) ptr)[0] = cpu_to_be32(capacity - 1); + ((__be32 *) ptr)[1] = cpu_to_be32(512); + + usb_stor_set_xfer_buf(ptr, 8, srb); + return USB_STOR_TRANSPORT_GOOD; + } + + if (srb->cmnd[0] == READ_10) { + unsigned int page, pages; + + rc = alauda_check_media(us); + if (rc != USB_STOR_TRANSPORT_GOOD) + return rc; + + page = short_pack(srb->cmnd[3], srb->cmnd[2]); + page <<= 16; + page |= short_pack(srb->cmnd[5], srb->cmnd[4]); + pages = short_pack(srb->cmnd[8], srb->cmnd[7]); + + US_DEBUGP("alauda_transport: READ_10: page %d pagect %d\n", + page, pages); + + return alauda_read_data(us, page, pages); + } + + if (srb->cmnd[0] == WRITE_10) { + unsigned int page, pages; + + rc = alauda_check_media(us); + if (rc != USB_STOR_TRANSPORT_GOOD) + return rc; + + page = short_pack(srb->cmnd[3], srb->cmnd[2]); + page <<= 16; + page |= short_pack(srb->cmnd[5], srb->cmnd[4]); + pages = short_pack(srb->cmnd[8], srb->cmnd[7]); + + US_DEBUGP("alauda_transport: WRITE_10: page %d pagect %d\n", + page, pages); + + return alauda_write_data(us, page, pages); + } + + if (srb->cmnd[0] == REQUEST_SENSE) { + US_DEBUGP("alauda_transport: REQUEST_SENSE.\n"); + + memset(ptr, 0, 18); + ptr[0] = 0xF0; + ptr[2] = info->sense_key; + ptr[7] = 11; + ptr[12] = info->sense_asc; + ptr[13] = info->sense_ascq; + usb_stor_set_xfer_buf(ptr, 18, srb); + + return USB_STOR_TRANSPORT_GOOD; + } + + if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) { + /* sure. whatever. not like we can stop the user from popping + the media out of the device (no locking doors, etc) */ + return USB_STOR_TRANSPORT_GOOD; + } + + US_DEBUGP("alauda_transport: Gah! Unknown command: %d (0x%x)\n", + srb->cmnd[0], srb->cmnd[0]); + info->sense_key = 0x05; + info->sense_asc = 0x20; + info->sense_ascq = 0x00; + return USB_STOR_TRANSPORT_FAILED; +} + diff --git a/drivers/usb/storage/alauda.h b/drivers/usb/storage/alauda.h new file mode 100644 index 0000000..a700f87 --- /dev/null +++ b/drivers/usb/storage/alauda.h @@ -0,0 +1,100 @@ +/* + * Driver for Alauda-based card readers + * + * Current development and maintenance by: + * (c) 2005 Daniel Drake + * + * See alauda.c for more explanation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _USB_ALAUDA_H +#define _USB_ALAUDA_H + +/* + * Status bytes + */ +#define ALAUDA_STATUS_ERROR 0x01 +#define ALAUDA_STATUS_READY 0x40 + +/* + * Control opcodes (for request field) + */ +#define ALAUDA_GET_XD_MEDIA_STATUS 0x08 +#define ALAUDA_GET_SM_MEDIA_STATUS 0x98 +#define ALAUDA_ACK_XD_MEDIA_CHANGE 0x0a +#define ALAUDA_ACK_SM_MEDIA_CHANGE 0x9a +#define ALAUDA_GET_XD_MEDIA_SIG 0x86 +#define ALAUDA_GET_SM_MEDIA_SIG 0x96 + +/* + * Bulk command identity (byte 0) + */ +#define ALAUDA_BULK_CMD 0x40 + +/* + * Bulk opcodes (byte 1) + */ +#define ALAUDA_BULK_GET_REDU_DATA 0x85 +#define ALAUDA_BULK_READ_BLOCK 0x94 +#define ALAUDA_BULK_ERASE_BLOCK 0xa3 +#define ALAUDA_BULK_WRITE_BLOCK 0xb4 +#define ALAUDA_BULK_GET_STATUS2 0xb7 +#define ALAUDA_BULK_RESET_MEDIA 0xe0 + +/* + * Port to operate on (byte 8) + */ +#define ALAUDA_PORT_XD 0x00 +#define ALAUDA_PORT_SM 0x01 + +/* + * LBA and PBA are unsigned ints. Special values. + */ +#define UNDEF 0xffff +#define SPARE 0xfffe +#define UNUSABLE 0xfffd + +int init_alauda(struct us_data *us); +int alauda_transport(struct scsi_cmnd *srb, struct us_data *us); + +struct alauda_media_info { + unsigned long capacity; /* total media size in bytes */ + unsigned int pagesize; /* page size in bytes */ + unsigned int blocksize; /* number of pages per block */ + unsigned int uzonesize; /* number of usable blocks per zone */ + unsigned int zonesize; /* number of blocks per zone */ + unsigned int blockmask; /* mask to get page from address */ + + unsigned char pageshift; + unsigned char blockshift; + unsigned char zoneshift; + + u16 **lba_to_pba; /* logical to physical block map */ + u16 **pba_to_lba; /* physical to logical block map */ +}; + +struct alauda_info { + struct alauda_media_info port[2]; + int wr_ep; /* endpoint to write data out of */ + + unsigned char sense_key; + unsigned long sense_asc; /* additional sense code */ + unsigned long sense_ascq; /* additional sense code qualifier */ +}; + +#endif + diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index be3c06d..7a865dd 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -535,6 +535,13 @@ UNUSUAL_DEV( 0x057b, 0x0022, 0x0000, 0x9999, "Silicon Media R/W", US_SC_DEVICE, US_PR_DEVICE, NULL, 0), +#ifdef CONFIG_USB_STORAGE_ALAUDA +UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102, + "Fujifilm", + "DPC-R1 (Alauda)", + US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ), +#endif + /* Fabrizio Fellini */ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, "Fujifilm", @@ -784,6 +791,13 @@ UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100, US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ), #endif +#ifdef CONFIG_USB_STORAGE_ALAUDA +UNUSUAL_DEV( 0x07b4, 0x010a, 0x0102, 0x0102, + "Olympus", + "MAUSB-10 (Alauda)", + US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ), +#endif + #ifdef CONFIG_USB_STORAGE_DATAFAB UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015, "Datafab", diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 85c8c17..dbcf239 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -94,6 +94,9 @@ #ifdef CONFIG_USB_STORAGE_ONETOUCH #include "onetouch.h" #endif +#ifdef CONFIG_USB_STORAGE_ALAUDA +#include "alauda.h" +#endif /* Some informational data */ MODULE_AUTHOR("Matthew Dharm "); @@ -644,6 +647,15 @@ static int get_protocol(struct us_data *us) break; #endif +#ifdef CONFIG_USB_STORAGE_ALAUDA + case US_PR_ALAUDA: + us->transport_name = "Alauda Control/Bulk"; + us->transport = alauda_transport; + us->transport_reset = usb_stor_Bulk_reset; + us->max_lun = 1; + break; +#endif + default: return -EIO; } diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h index f9c058f..b2d0898 100644 --- a/include/linux/usb_usual.h +++ b/include/linux/usb_usual.h @@ -102,6 +102,9 @@ enum { US_DO_ALL_FLAGS }; #ifdef CONFIG_USB_STORAGE_JUMPSHOT #define US_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */ #endif +#ifdef CONFIG_USB_STORAGE_ALAUDA +#define US_PR_ALAUDA 0xf4 /* Alauda chipsets */ +#endif #define US_PR_DEVICE 0xff /* Use device's value */ -- cgit v1.1 From 8836aeb86158163532c1835e74751708c2d74385 Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Sun, 4 Dec 2005 22:03:47 -0800 Subject: [PATCH] USB Storage: update MAINTAINERS Someone recently pointed out to me that the MAINTAINERS entry for usb-storage was, perhaps, in need of changing. Signed-off-by: Matthew Dharm Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 861d297..3fd7687 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2657,7 +2657,7 @@ USB MASS STORAGE DRIVER P: Matthew Dharm M: mdharm-usb@one-eyed-alien.net L: linux-usb-users@lists.sourceforge.net -L: linux-usb-devel@lists.sourceforge.net +L: usb-storage@lists.one-eyed-alien.net S: Maintained W: http://www.one-eyed-alien.net/~mdharm/linux-usb/ -- cgit v1.1 From 3717f2952bd0aab30fe2a6af80657abbeb065461 Mon Sep 17 00:00:00 2001 From: Paul Walmsley Date: Wed, 30 Nov 2005 13:57:45 -0800 Subject: [PATCH] USB: usb-storage: add debug entry for REPORT LUNS Bugs involving the REPORT LUNS SCSI-3 command are much easier to track down if usb-storage displays the command's name, rather than "(Unknown command)". Signed-off-by: Paul Walmsley Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/debug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c index 5a93217..01e4306 100644 --- a/drivers/usb/storage/debug.c +++ b/drivers/usb/storage/debug.c @@ -132,6 +132,7 @@ void usb_stor_show_command(struct scsi_cmnd *srb) case 0x5C: what = "READ BUFFER CAPACITY"; break; case 0x5D: what = "SEND CUE SHEET"; break; case GPCMD_BLANK: what = "BLANK"; break; + case REPORT_LUNS: what = "REPORT LUNS"; break; case MOVE_MEDIUM: what = "MOVE_MEDIUM or PLAY AUDIO (12)"; break; case READ_12: what = "READ_12"; break; case WRITE_12: what = "WRITE_12"; break; -- cgit v1.1 From f3d34ed48c80903544b509031fee64838d29f35f Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Tue, 13 Dec 2005 10:32:13 -0500 Subject: [PATCH] USB: fix local variable clash This patch (as621) fixes a local variable conflict I accidently introduced into usb_set_configuration. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/message.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 99ab774..319de03 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1387,11 +1387,11 @@ free_interfaces: if (dev->state != USB_STATE_ADDRESS) usb_disable_device (dev, 1); // Skip ep0 - n = dev->bus_mA - cp->desc.bMaxPower * 2; - if (n < 0) + i = dev->bus_mA - cp->desc.bMaxPower * 2; + if (i < 0) dev_warn(&dev->dev, "new config #%d exceeds power " "limit by %dmA\n", - configuration, -n); + configuration, -i); if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), USB_REQ_SET_CONFIGURATION, 0, configuration, 0, -- cgit v1.1 From 52950ed40dc97456209979af1d8f51b63cf6dcab Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 11 Dec 2005 16:20:08 +0100 Subject: [PATCH] USB: Use ARRAY_SIZE macro Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]) and remove duplicates of ARRAY_SIZE. Some trailing whitespaces are also removed. Patch is compile-tested on i386. Signed-off-by: Tobias Klauser Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/dummy_hcd.c | 2 +- drivers/usb/input/aiptek.c | 4 ++-- drivers/usb/media/ibmcam.c | 2 +- drivers/usb/media/sn9c102_core.c | 23 ++++++++++------------- drivers/usb/media/w9968cf.c | 2 +- drivers/usb/net/zd1201.c | 8 ++++---- drivers/usb/serial/io_edgeport.c | 2 +- drivers/usb/serial/io_edgeport.h | 3 --- drivers/usb/serial/safe_serial.c | 2 +- drivers/usb/serial/ti_usb_3410_5052.c | 7 ++----- drivers/usb/storage/sddr09.c | 4 +--- 11 files changed, 24 insertions(+), 35 deletions(-) diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index ce0d4b4..9734cb7 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -138,7 +138,7 @@ static const char *const ep_name [] = { /* or like sa1100: two fixed function endpoints */ "ep1out-bulk", "ep2in-bulk", }; -#define DUMMY_ENDPOINTS (sizeof(ep_name)/sizeof(char *)) +#define DUMMY_ENDPOINTS ARRAY_SIZE(ep_name) /*-------------------------------------------------------------------------*/ diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c index 87ae08c..a6693b0 100644 --- a/drivers/usb/input/aiptek.c +++ b/drivers/usb/input/aiptek.c @@ -2093,7 +2093,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) /* Programming the tablet macro keys needs to be done with a for loop * as the keycodes are discontiguous. */ - for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) + for (i = 0; i < ARRAY_SIZE(macroKeyEvents); ++i) set_bit(macroKeyEvents[i], inputdev->keybit); /* @@ -2135,7 +2135,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id) * not an error :-) */ - for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { + for (i = 0; i < ARRAY_SIZE(speeds); ++i) { aiptek->curSetting.programmableDelay = speeds[i]; (void)aiptek_program_tablet(aiptek); if (aiptek->inputdev->absmax[ABS_X] > 0) { diff --git a/drivers/usb/media/ibmcam.c b/drivers/usb/media/ibmcam.c index ba41fc7..a42c222 100644 --- a/drivers/usb/media/ibmcam.c +++ b/drivers/usb/media/ibmcam.c @@ -3457,7 +3457,7 @@ static void ibmcam_model3_setup_after_video_if(struct uvd *uvd) if(init_model3_input) { if (debug > 0) info("Setting input to RCA."); - for (i=0; i < (sizeof(initData)/sizeof(initData[0])); i++) { + for (i=0; i < ARRAY_SIZE(initData); i++) { ibmcam_veio(uvd, initData[i].req, initData[i].value, initData[i].index); } } diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c index 0872345..8d1a1c3 100644 --- a/drivers/usb/media/sn9c102_core.c +++ b/drivers/usb/media/sn9c102_core.c @@ -1316,7 +1316,7 @@ static int sn9c102_init(struct sn9c102_device* cam) struct v4l2_control ctrl; struct v4l2_queryctrl *qctrl; struct v4l2_rect* rect; - u8 i = 0, n = 0; + u8 i = 0; int err = 0; if (!(cam->state & DEV_INITIALIZED)) { @@ -1352,7 +1352,7 @@ static int sn9c102_init(struct sn9c102_device* cam) return err; if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X) - DBG(3, "Compressed video format is active, quality %d", + DBG(3, "Compressed video format is active, quality %d", cam->compression.quality) else DBG(3, "Uncompressed video format is active") @@ -1364,9 +1364,8 @@ static int sn9c102_init(struct sn9c102_device* cam) } if (s->set_ctrl) { - n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); - for (i = 0; i < n; i++) - if (s->qctrl[i].id != 0 && + for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) + if (s->qctrl[i].id != 0 && !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) { ctrl.id = s->qctrl[i].id; ctrl.value = qctrl[i].default_value; @@ -1388,7 +1387,7 @@ static int sn9c102_init(struct sn9c102_device* cam) init_waitqueue_head(&cam->wait_stream); cam->nreadbuffers = 2; memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl)); - memcpy(&(s->_rect), &(s->cropcap.defrect), + memcpy(&(s->_rect), &(s->cropcap.defrect), sizeof(struct v4l2_rect)); cam->state |= DEV_INITIALIZED; } @@ -1810,13 +1809,12 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, { struct sn9c102_sensor* s = cam->sensor; struct v4l2_queryctrl qc; - u8 i, n; + u8 i; if (copy_from_user(&qc, arg, sizeof(qc))) return -EFAULT; - n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); - for (i = 0; i < n; i++) + for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) if (qc.id && qc.id == s->qctrl[i].id) { memcpy(&qc, &(s->qctrl[i]), sizeof(qc)); if (copy_to_user(arg, &qc, sizeof(qc))) @@ -1852,7 +1850,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, { struct sn9c102_sensor* s = cam->sensor; struct v4l2_control ctrl; - u8 i, n; + u8 i; int err = 0; if (!s->set_ctrl) @@ -1861,8 +1859,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, if (copy_from_user(&ctrl, arg, sizeof(ctrl))) return -EFAULT; - n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); - for (i = 0; i < n; i++) + for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) if (ctrl.id == s->qctrl[i].id) { if (ctrl.value < s->qctrl[i].minimum || ctrl.value > s->qctrl[i].maximum) @@ -2544,7 +2541,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) unsigned int i, n; int err = 0, r; - n = sizeof(sn9c102_id_table)/sizeof(sn9c102_id_table[0]); + n = ARRAY_SIZE(sn9c102_id_table); for (i = 0; i < n-1; i++) if (le16_to_cpu(udev->descriptor.idVendor) == sn9c102_id_table[i].idVendor && diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 52b90d5..8d6a1ff 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -2958,7 +2958,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp, }; #define V4L1_IOCTL(cmd) \ - ((_IOC_NR((cmd)) < sizeof(v4l1_ioctls)/sizeof(char*)) ? \ + ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \ v4l1_ioctls[_IOC_NR((cmd))] : "?") cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index 4d6673a..2af21a6 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c @@ -1722,7 +1722,7 @@ static const struct iw_priv_args zd1201_private_args[] = { IW_PRIV_TYPE_NONE, "sethostauth" }, { ZD1201GIWHOSTAUTH, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostauth" }, - { ZD1201SIWAUTHSTA, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, + { ZD1201SIWAUTHSTA, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "authstation" }, { ZD1201SIWMAXASSOC, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "setmaxassoc" }, @@ -1731,9 +1731,9 @@ static const struct iw_priv_args zd1201_private_args[] = { }; static const struct iw_handler_def zd1201_iw_handlers = { - .num_standard = sizeof(zd1201_iw_handler)/sizeof(iw_handler), - .num_private = sizeof(zd1201_private_handler)/sizeof(iw_handler), - .num_private_args = sizeof(zd1201_private_args)/sizeof(struct iw_priv_args), + .num_standard = ARRAY_SIZE(zd1201_iw_handler), + .num_private = ARRAY_SIZE(zd1201_private_handler), + .num_private_args = ARRAY_SIZE(zd1201_private_args), .standard = (iw_handler *)zd1201_iw_handler, .private = (iw_handler *)zd1201_private_handler, .private_args = (struct iw_priv_args *) zd1201_private_args, diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 89bb356..faedbeb 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -2353,7 +2353,7 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor) dbg("%s - %d", __FUNCTION__, baudrate); - for (i = 0; i < NUM_ENTRIES(divisor_table); i++) { + for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { if ( divisor_table[i].BaudRate == baudrate ) { *divisor = divisor_table[i].Divisor; return 0; diff --git a/drivers/usb/serial/io_edgeport.h b/drivers/usb/serial/io_edgeport.h index 5112d7a..123fa8a 100644 --- a/drivers/usb/serial/io_edgeport.h +++ b/drivers/usb/serial/io_edgeport.h @@ -31,9 +31,6 @@ #ifndef HIGH8 #define HIGH8(a) ((unsigned char)((a & 0xff00) >> 8)) #endif -#ifndef NUM_ENTRIES - #define NUM_ENTRIES(x) (sizeof(x)/sizeof((x)[0])) -#endif #ifndef __KERNEL__ #define __KERNEL__ diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index 86dc21c..f0215f8 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c @@ -425,7 +425,7 @@ static int __init safe_init (void) if (vendor || product) { info ("vendor: %x product: %x\n", vendor, product); - for (i = 0; i < (sizeof (id_table) / sizeof (struct usb_device_id)); i++) { + for (i = 0; i < ARRAY_SIZE(id_table); i++) { if (!id_table[i].idVendor && !id_table[i].idProduct) { id_table[i].idVendor = vendor; id_table[i].idProduct = product; diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 9e53ec7..abb830c 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c @@ -351,17 +351,14 @@ static int __init ti_init(void) int i,j; int ret; - /* insert extra vendor and product ids */ - j = sizeof(ti_id_table_3410)/sizeof(struct usb_device_id) - - TI_EXTRA_VID_PID_COUNT - 1; + j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1; for (i=0; i Date: Sat, 10 Dec 2005 20:30:54 +0200 Subject: [PATCH] USB: add driver for ATI/Philips USB RF remotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Driver for ATI/Philips USB RF remotes This is a new input driver for ATI/Philips USB RF remotes (eg. ATI Remote Wonder II). Signed-off-by: Ville Syrjälä Signed-off-by: Greg Kroah-Hartman --- drivers/usb/input/Kconfig | 14 ++ drivers/usb/input/Makefile | 1 + drivers/usb/input/ati_remote2.c | 477 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 492 insertions(+) create mode 100644 drivers/usb/input/ati_remote2.c diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig index 1e53934..509dd0a 100644 --- a/drivers/usb/input/Kconfig +++ b/drivers/usb/input/Kconfig @@ -273,6 +273,20 @@ config USB_ATI_REMOTE To compile this driver as a module, choose M here: the module will be called ati_remote. +config USB_ATI_REMOTE2 + tristate "ATI / Philips USB RF remote control" + depends on USB && INPUT + ---help--- + Say Y here if you want to use an ATI or Philips USB RF remote control. + These are RF remotes with USB receivers. + ATI Remote Wonder II comes with some ATI's All-In-Wonder video cards + and is also available as a separate product. + This driver provides mouse pointer, left and right mouse buttons, + and maps all the other remote buttons to keypress events. + + To compile this driver as a module, choose M here: the module will be + called ati_remote2. + config USB_KEYSPAN_REMOTE tristate "Keyspan DMR USB remote control (EXPERIMENTAL)" depends on USB && INPUT && EXPERIMENTAL diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile index 07cb17d..d512d9f 100644 --- a/drivers/usb/input/Makefile +++ b/drivers/usb/input/Makefile @@ -28,6 +28,7 @@ endif obj-$(CONFIG_USB_AIPTEK) += aiptek.o obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o +obj-$(CONFIG_USB_ATI_REMOTE2) += ati_remote2.o obj-$(CONFIG_USB_HID) += usbhid.o obj-$(CONFIG_USB_KBD) += usbkbd.o obj-$(CONFIG_USB_KBTAB) += kbtab.o diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c new file mode 100644 index 0000000..ab1a1ae --- /dev/null +++ b/drivers/usb/input/ati_remote2.c @@ -0,0 +1,477 @@ +/* + * ati_remote2 - ATI/Philips USB RF remote driver + * + * Copyright (C) 2005 Ville Syrjala + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + */ + +#include + +#define DRIVER_DESC "ATI/Philips USB RF remote driver" +#define DRIVER_VERSION "0.1" + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_VERSION(DRIVER_VERSION); +MODULE_AUTHOR("Ville Syrjala "); +MODULE_LICENSE("GPL"); + +static unsigned int mode_mask = 0x1F; +module_param(mode_mask, uint, 0644); +MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>"); + +static struct usb_device_id ati_remote2_id_table[] = { + { USB_DEVICE(0x0471, 0x0602) }, /* ATI Remote Wonder II */ + { } +}; +MODULE_DEVICE_TABLE(usb, ati_remote2_id_table); + +static struct { + int hw_code; + int key_code; +} ati_remote2_key_table[] = { + { 0x00, KEY_0 }, + { 0x01, KEY_1 }, + { 0x02, KEY_2 }, + { 0x03, KEY_3 }, + { 0x04, KEY_4 }, + { 0x05, KEY_5 }, + { 0x06, KEY_6 }, + { 0x07, KEY_7 }, + { 0x08, KEY_8 }, + { 0x09, KEY_9 }, + { 0x0c, KEY_POWER }, + { 0x0d, KEY_MUTE }, + { 0x10, KEY_VOLUMEUP }, + { 0x11, KEY_VOLUMEDOWN }, + { 0x20, KEY_CHANNELUP }, + { 0x21, KEY_CHANNELDOWN }, + { 0x28, KEY_FORWARD }, + { 0x29, KEY_REWIND }, + { 0x2c, KEY_PLAY }, + { 0x30, KEY_PAUSE }, + { 0x31, KEY_STOP }, + { 0x37, KEY_RECORD }, + { 0x38, KEY_DVD }, + { 0x39, KEY_TV }, + { 0x54, KEY_MENU }, + { 0x58, KEY_UP }, + { 0x59, KEY_DOWN }, + { 0x5a, KEY_LEFT }, + { 0x5b, KEY_RIGHT }, + { 0x5c, KEY_OK }, + { 0x78, KEY_A }, + { 0x79, KEY_B }, + { 0x7a, KEY_C }, + { 0x7b, KEY_D }, + { 0x7c, KEY_E }, + { 0x7d, KEY_F }, + { 0x82, KEY_ENTER }, + { 0x8e, KEY_VENDOR }, + { 0x96, KEY_COFFEE }, + { 0xa9, BTN_LEFT }, + { 0xaa, BTN_RIGHT }, + { 0xbe, KEY_QUESTION }, + { 0xd5, KEY_FRONT }, + { 0xd0, KEY_EDIT }, + { 0xf9, KEY_INFO }, + { (0x00 << 8) | 0x3f, KEY_PROG1 }, + { (0x01 << 8) | 0x3f, KEY_PROG2 }, + { (0x02 << 8) | 0x3f, KEY_PROG3 }, + { (0x03 << 8) | 0x3f, KEY_PROG4 }, + { (0x04 << 8) | 0x3f, KEY_PC }, + { 0, KEY_RESERVED } +}; + +struct ati_remote2 { + struct input_dev *idev; + struct usb_device *udev; + + struct usb_interface *intf[2]; + struct usb_endpoint_descriptor *ep[2]; + struct urb *urb[2]; + void *buf[2]; + dma_addr_t buf_dma[2]; + + unsigned long jiffies; + int mode; + + char name[64]; + char phys[64]; +}; + +static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id); +static void ati_remote2_disconnect(struct usb_interface *interface); + +static struct usb_driver ati_remote2_driver = { + .name = "ati_remote2", + .probe = ati_remote2_probe, + .disconnect = ati_remote2_disconnect, + .id_table = ati_remote2_id_table, +}; + +static int ati_remote2_open(struct input_dev *idev) +{ + struct ati_remote2 *ar2 = idev->private; + int r; + + r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); + if (r) { + dev_err(&ar2->intf[0]->dev, + "%s: usb_submit_urb() = %d\n", __FUNCTION__, r); + return r; + } + r = usb_submit_urb(ar2->urb[1], GFP_KERNEL); + if (r) { + usb_kill_urb(ar2->urb[0]); + dev_err(&ar2->intf[1]->dev, + "%s: usb_submit_urb() = %d\n", __FUNCTION__, r); + return r; + } + + return 0; +} + +static void ati_remote2_close(struct input_dev *idev) +{ + struct ati_remote2 *ar2 = idev->private; + + usb_kill_urb(ar2->urb[0]); + usb_kill_urb(ar2->urb[1]); +} + +static void ati_remote2_input_mouse(struct ati_remote2 *ar2, struct pt_regs *regs) +{ + struct input_dev *idev = ar2->idev; + u8 *data = ar2->buf[0]; + + if (data[0] > 4) { + dev_err(&ar2->intf[0]->dev, + "Unknown mode byte (%02x %02x %02x %02x)\n", + data[3], data[2], data[1], data[0]); + return; + } + + if (!((1 << data[0]) & mode_mask)) + return; + + input_regs(idev, regs); + input_event(idev, EV_REL, REL_X, (s8) data[1]); + input_event(idev, EV_REL, REL_Y, (s8) data[2]); + input_sync(idev); +} + +static int ati_remote2_lookup(unsigned int hw_code) +{ + int i; + + for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) + if (ati_remote2_key_table[i].hw_code == hw_code) + return i; + + return -1; +} + +static void ati_remote2_input_key(struct ati_remote2 *ar2, struct pt_regs *regs) +{ + struct input_dev *idev = ar2->idev; + u8 *data = ar2->buf[1]; + int hw_code, index; + + if (data[0] > 4) { + dev_err(&ar2->intf[1]->dev, + "Unknown mode byte (%02x %02x %02x %02x)\n", + data[3], data[2], data[1], data[0]); + return; + } + + hw_code = data[2]; + /* + * Mode keys (AUX1-AUX4, PC) all generate the same code byte. + * Use the mode byte to figure out which one was pressed. + */ + if (hw_code == 0x3f) { + /* + * For some incomprehensible reason the mouse pad generates + * events which look identical to the events from the last + * pressed mode key. Naturally we don't want to generate key + * events for the mouse pad so we filter out any subsequent + * events from the same mode key. + */ + if (ar2->mode == data[0]) + return; + + if (data[1] == 0) + ar2->mode = data[0]; + + hw_code |= data[0] << 8; + } + + if (!((1 << data[0]) & mode_mask)) + return; + + index = ati_remote2_lookup(hw_code); + if (index < 0) { + dev_err(&ar2->intf[1]->dev, + "Unknown code byte (%02x %02x %02x %02x)\n", + data[3], data[2], data[1], data[0]); + return; + } + + switch (data[1]) { + case 0: /* release */ + break; + case 1: /* press */ + ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_DELAY]); + break; + case 2: /* repeat */ + + /* No repeat for mouse buttons. */ + if (ati_remote2_key_table[index].key_code == BTN_LEFT || + ati_remote2_key_table[index].key_code == BTN_RIGHT) + return; + + if (!time_after_eq(jiffies, ar2->jiffies)) + return; + + ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_PERIOD]); + break; + default: + dev_err(&ar2->intf[1]->dev, + "Unknown state byte (%02x %02x %02x %02x)\n", + data[3], data[2], data[1], data[0]); + return; + } + + input_regs(idev, regs); + input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]); + input_sync(idev); +} + +static void ati_remote2_complete_mouse(struct urb *urb, struct pt_regs *regs) +{ + struct ati_remote2 *ar2 = urb->context; + int r; + + switch (urb->status) { + case 0: + ati_remote2_input_mouse(ar2, regs); + break; + case -ENOENT: + case -EILSEQ: + case -ECONNRESET: + case -ESHUTDOWN: + dev_dbg(&ar2->intf[0]->dev, + "%s(): urb status = %d\n", __FUNCTION__, urb->status); + return; + default: + dev_err(&ar2->intf[0]->dev, + "%s(): urb status = %d\n", __FUNCTION__, urb->status); + } + + r = usb_submit_urb(urb, GFP_ATOMIC); + if (r) + dev_err(&ar2->intf[0]->dev, + "%s(): usb_submit_urb() = %d\n", __FUNCTION__, r); +} + +static void ati_remote2_complete_key(struct urb *urb, struct pt_regs *regs) +{ + struct ati_remote2 *ar2 = urb->context; + int r; + + switch (urb->status) { + case 0: + ati_remote2_input_key(ar2, regs); + break; + case -ENOENT: + case -EILSEQ: + case -ECONNRESET: + case -ESHUTDOWN: + dev_dbg(&ar2->intf[1]->dev, + "%s(): urb status = %d\n", __FUNCTION__, urb->status); + return; + default: + dev_err(&ar2->intf[1]->dev, + "%s(): urb status = %d\n", __FUNCTION__, urb->status); + } + + r = usb_submit_urb(urb, GFP_ATOMIC); + if (r) + dev_err(&ar2->intf[1]->dev, + "%s(): usb_submit_urb() = %d\n", __FUNCTION__, r); +} + +static int ati_remote2_input_init(struct ati_remote2 *ar2) +{ + struct input_dev *idev; + int i; + + idev = input_allocate_device(); + if (!idev) + return -ENOMEM; + + ar2->idev = idev; + idev->private = ar2; + + idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL); + idev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT); + idev->relbit[0] = BIT(REL_X) | BIT(REL_Y); + for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++) + set_bit(ati_remote2_key_table[i].key_code, idev->keybit); + + idev->rep[REP_DELAY] = 250; + idev->rep[REP_PERIOD] = 33; + + idev->open = ati_remote2_open; + idev->close = ati_remote2_close; + + idev->name = ar2->name; + idev->phys = ar2->phys; + + usb_to_input_id(ar2->udev, &idev->id); + idev->cdev.dev = &ar2->udev->dev; + + i = input_register_device(idev); + if (i) + input_free_device(idev); + + return i; +} + +static int ati_remote2_urb_init(struct ati_remote2 *ar2) +{ + struct usb_device *udev = ar2->udev; + int i, pipe, maxp; + + for (i = 0; i < 2; i++) { + ar2->buf[i] = usb_buffer_alloc(udev, 4, GFP_KERNEL, &ar2->buf_dma[i]); + if (!ar2->buf[i]) + return -ENOMEM; + + ar2->urb[i] = usb_alloc_urb(0, GFP_KERNEL); + if (!ar2->urb[i]) + return -ENOMEM; + + pipe = usb_rcvintpipe(udev, ar2->ep[i]->bEndpointAddress); + maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); + maxp = maxp > 4 ? 4 : maxp; + + usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp, + i ? ati_remote2_complete_key : ati_remote2_complete_mouse, + ar2, ar2->ep[i]->bInterval); + ar2->urb[i]->transfer_dma = ar2->buf_dma[i]; + ar2->urb[i]->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; + } + + return 0; +} + +static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2) +{ + int i; + + for (i = 0; i < 2; i++) { + if (ar2->urb[i]) + usb_free_urb(ar2->urb[i]); + + if (ar2->buf[i]) + usb_buffer_free(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]); + } +} + +static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id) +{ + struct usb_device *udev = interface_to_usbdev(interface); + struct usb_host_interface *alt = interface->cur_altsetting; + struct ati_remote2 *ar2; + int r; + + if (alt->desc.bInterfaceNumber) + return -ENODEV; + + ar2 = kzalloc(sizeof (struct ati_remote2), GFP_KERNEL); + if (!ar2) + return -ENOMEM; + + ar2->udev = udev; + + ar2->intf[0] = interface; + ar2->ep[0] = &alt->endpoint[0].desc; + + ar2->intf[1] = usb_ifnum_to_if(udev, 1); + r = usb_driver_claim_interface(&ati_remote2_driver, ar2->intf[1], ar2); + if (r) + goto fail1; + alt = ar2->intf[1]->cur_altsetting; + ar2->ep[1] = &alt->endpoint[0].desc; + + r = ati_remote2_urb_init(ar2); + if (r) + goto fail2; + + usb_make_path(udev, ar2->phys, sizeof(ar2->phys)); + strlcat(ar2->phys, "/input0", sizeof(ar2->phys)); + + strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name)); + + r = ati_remote2_input_init(ar2); + if (r) + goto fail2; + + usb_set_intfdata(interface, ar2); + + return 0; + + fail2: + ati_remote2_urb_cleanup(ar2); + + usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); + fail1: + kfree(ar2); + + return r; +} + +static void ati_remote2_disconnect(struct usb_interface *interface) +{ + struct ati_remote2 *ar2; + struct usb_host_interface *alt = interface->cur_altsetting; + + if (alt->desc.bInterfaceNumber) + return; + + ar2 = usb_get_intfdata(interface); + usb_set_intfdata(interface, NULL); + + input_unregister_device(ar2->idev); + + ati_remote2_urb_cleanup(ar2); + + usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); + + kfree(ar2); +} + +static int __init ati_remote2_init(void) +{ + int r; + + r = usb_register(&ati_remote2_driver); + if (r) + printk(KERN_ERR "ati_remote2: usb_register() = %d\n", r); + else + printk(KERN_INFO "ati_remote2: " DRIVER_DESC " " DRIVER_VERSION "\n"); + + return r; +} + +static void __exit ati_remote2_exit(void) +{ + usb_deregister(&ati_remote2_driver); +} + +module_init(ati_remote2_init); +module_exit(ati_remote2_exit); -- cgit v1.1 From effac8be4e46aabf22788d24caaa1ae9c295d26d Mon Sep 17 00:00:00 2001 From: Pavel Fedin Date: Fri, 9 Dec 2005 09:30:59 +0300 Subject: [PATCH] USB: Support for Posiflex PP-7000 retail printer in Linux This little patch adds recognition of Posiflex PP-7000 retail printer to ftdo_sio module. The printer uses FT232BM bridge programmed with custom VID/PID. The patch posted to lkml and sf.net was for 2.6.11.1 kernel, here is one reworked for 2.6.12. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 1 + drivers/usb/serial/ftdi_sio.h | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 11da073..be8c29f 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -477,6 +477,7 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, + { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) }, { }, /* Optional parameter entry */ { } /* Terminating entry */ }; diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 773ea3e..deab666 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -352,6 +352,12 @@ /* Pyramid Computer GmbH */ #define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ +/* + * Posiflex inc retail equipment (http://www.posiflex.com.tw) + */ +#define POSIFLEX_VID 0x0d3a /* Vendor ID */ +#define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */ + /* Commands */ #define FTDI_SIO_RESET 0 /* Reset the port */ #define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ -- cgit v1.1 From 740a4282ed5cf0fbcad9a1a1660f24e1b5d11ed2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 13 Dec 2005 16:18:47 +0000 Subject: [PATCH] USB: ftdi_sio: new IDs for Teratronik devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds vendor and product IDs to the ftdi_sio driver's device ID table for two devices from teratronik.de. The device IDs were submitted by O. Wölfelschneider of Teratronik Elektronische Systeme GmbH. The charset of the patch is latin-1, same as the original files. Please apply, thanks! (I've tried to avoid a clash with Andrew Morton's patch to add support for Posiflex PP-7700 printer to the same driver.) Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 2 ++ drivers/usb/serial/ftdi_sio.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index be8c29f..eb863b3 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -471,6 +471,8 @@ static struct usb_device_id id_table_combined [] = { { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) }, { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) }, { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index deab666..f380f9ea 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h @@ -343,6 +343,13 @@ #define XSENS_CONVERTER_7_PID 0xD38F /* + * Teratronik product ids. + * Submitted by O. Wölfelschneider. + */ +#define FTDI_TERATRONIK_VCP_PID 0xEC88 /* Teratronik device (preferring VCP driver on windows) */ +#define FTDI_TERATRONIK_D2XX_PID 0xEC89 /* Teratronik device (preferring D2XX driver on windows) */ + +/* * Evolution Robotics products (http://www.evolution.com/). * Submitted by Shawn M. Lavelle. */ -- cgit v1.1 From 0e8eb0f06b21bc05c42bcdbb6b273fce59ba9689 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 11 Dec 2005 20:34:02 +0100 Subject: [PATCH] USB: Remove unneeded kmalloc() return value casts Remove kmalloc() return value casts that we don't need from drivers/usb/* Signed-off-by: Jesper Juhl Signed-off-by: Greg Kroah-Hartman --- drivers/usb/media/usbvideo.c | 2 +- drivers/usb/media/w9968cf.c | 4 ++-- drivers/usb/misc/auerswald.c | 4 ++-- drivers/usb/misc/rio500.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c index af05859..4bd1133 100644 --- a/drivers/usb/media/usbvideo.c +++ b/drivers/usb/media/usbvideo.c @@ -725,7 +725,7 @@ int usbvideo_register( /* Allocate user_data separately because of kmalloc's limits */ if (num_extra > 0) { up->user_size = num_cams * num_extra; - up->user_data = (char *) kmalloc(up->user_size, GFP_KERNEL); + up->user_data = kmalloc(up->user_size, GFP_KERNEL); if (up->user_data == NULL) { err("%s: Failed to allocate user_data (%d. bytes)", __FUNCTION__, up->user_size); diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 8d6a1ff..04d6933 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -3554,7 +3554,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) /* Allocate 2 bytes of memory for camera control USB transfers */ - if (!(cam->control_buffer = (u16*)kmalloc(2, GFP_KERNEL))) { + if (!(cam->control_buffer = kmalloc(2, GFP_KERNEL))) { DBG(1,"Couldn't allocate memory for camera control transfers") err = -ENOMEM; goto fail; @@ -3562,7 +3562,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) memset(cam->control_buffer, 0, 2); /* Allocate 8 bytes of memory for USB data transfers to the FSB */ - if (!(cam->data_buffer = (u16*)kmalloc(8, GFP_KERNEL))) { + if (!(cam->data_buffer = kmalloc(8, GFP_KERNEL))) { DBG(1, "Couldn't allocate memory for data " "transfers to the FSB") err = -ENOMEM; diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c index fad387f..449b250 100644 --- a/drivers/usb/misc/auerswald.c +++ b/drivers/usb/misc/auerswald.c @@ -767,7 +767,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned memset (bep, 0, sizeof (auerbuf_t)); bep->list = bcp; INIT_LIST_HEAD (&bep->buff_list); - bep->bufp = (char *) kmalloc (bufsize, GFP_KERNEL); + bep->bufp = kmalloc (bufsize, GFP_KERNEL); if (!bep->bufp) goto bl_fail; bep->dr = (struct usb_ctrlrequest *) kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL); @@ -1123,7 +1123,7 @@ static int auerswald_int_open (pauerswald_t cp) } } if (!cp->intbufp) { - cp->intbufp = (char *) kmalloc (irqsize, GFP_KERNEL); + cp->intbufp = kmalloc (irqsize, GFP_KERNEL); if (!cp->intbufp) { ret = -ENOMEM; goto intoend; diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c index b9d6607..384fa37 100644 --- a/drivers/usb/misc/rio500.c +++ b/drivers/usb/misc/rio500.c @@ -465,14 +465,14 @@ static int probe_rio(struct usb_interface *intf, rio->rio_dev = dev; - if (!(rio->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) { + if (!(rio->obuf = kmalloc(OBUF_SIZE, GFP_KERNEL))) { err("probe_rio: Not enough memory for the output buffer"); usb_deregister_dev(intf, &usb_rio_class); return -ENOMEM; } dbg("probe_rio: obuf address:%p", rio->obuf); - if (!(rio->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) { + if (!(rio->ibuf = kmalloc(IBUF_SIZE, GFP_KERNEL))) { err("probe_rio: Not enough memory for the input buffer"); usb_deregister_dev(intf, &usb_rio_class); kfree(rio->obuf); -- cgit v1.1 From 6b495f4c5accec6261f522ea6898580dc9cb6316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=E4ki?= Date: Tue, 13 Dec 2005 15:30:20 +0200 Subject: [PATCH] USB: isp116x-hcd.c: Removed unused variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed unused variable Signed-off-by: Daniel Marjamäki Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/isp116x-hcd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 8344791..584b8dc 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c @@ -154,13 +154,11 @@ static void pack_fifo(struct isp116x *isp116x) struct ptd *ptd; int buflen = isp116x->atl_last_dir == PTD_DIR_IN ? isp116x->atl_bufshrt : isp116x->atl_buflen; - int ptd_count = 0; isp116x_write_reg16(isp116x, HCuPINT, HCuPINT_AIIEOT); isp116x_write_reg16(isp116x, HCXFERCTR, buflen); isp116x_write_addr(isp116x, HCATLPORT | ISP116x_WRITE_OFFSET); for (ep = isp116x->atl_active; ep; ep = ep->active) { - ++ptd_count; ptd = &ep->ptd; dump_ptd(ptd); dump_ptd_out_data(ptd, ep->data); -- cgit v1.1 From 2c26c9e6b4993a1a1231849feff4b6518a4fc239 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sat, 17 Dec 2005 02:16:43 -0800 Subject: [PATCH] USB: ub 00 implement retries and resets Implement command retries and resets in ub. It is advantageous for users to know if their devices are getting bad. However, failing every I/O is not practical if you have a external USB enclosure with a hard drive. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/block/ub.c | 404 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 287 insertions(+), 117 deletions(-) diff --git a/drivers/block/ub.c b/drivers/block/ub.c index c7a28f5..ba05e31 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -9,7 +9,6 @@ * * TODO (sorted by decreasing priority) * -- Kill first_open (Al Viro fixed the block layer now) - * -- Do resets with usb_device_reset (needs a thread context, use khubd) * -- set readonly flag for CDs, set removable flag for CF readers * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries @@ -236,6 +235,13 @@ struct ub_scsi_cmd { void *back; }; +struct ub_request { + struct request *rq; + unsigned int current_try; + unsigned int nsg; /* sgv[nsg] */ + struct scatterlist sgv[UB_MAX_REQ_SG]; +}; + /* */ struct ub_capacity { @@ -331,6 +337,8 @@ struct ub_lun { int readonly; int first_open; /* Kludge. See ub_bd_open. */ + struct ub_request urq; + /* Use Ingo's mempool if or when we have more than one command. */ /* * Currently we never need more than one command for the whole device. @@ -351,6 +359,7 @@ struct ub_dev { atomic_t poison; /* The USB device is disconnected */ int openc; /* protected by ub_lock! */ /* kref is too implicit for our taste */ + int reset; /* Reset is running */ unsigned int tagcnt; char name[12]; struct usb_device *dev; @@ -378,6 +387,9 @@ struct ub_dev { struct bulk_cs_wrap work_bcs; struct usb_ctrlrequest work_cr; + struct work_struct reset_work; + wait_queue_head_t reset_wait; + int sg_stat[6]; struct ub_scsi_trace tr; }; @@ -386,12 +398,14 @@ struct ub_dev { */ static void ub_cleanup(struct ub_dev *sc); static int ub_request_fn_1(struct ub_lun *lun, struct request *rq); -static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, - struct ub_scsi_cmd *cmd, struct request *rq); -static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, - struct ub_scsi_cmd *cmd, struct request *rq); +static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, + struct ub_scsi_cmd *cmd, struct ub_request *urq); +static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, + struct ub_scsi_cmd *cmd, struct ub_request *urq); static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static void ub_end_rq(struct request *rq, int uptodate); +static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, + struct ub_request *urq, struct ub_scsi_cmd *cmd); static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static void ub_urb_complete(struct urb *urb, struct pt_regs *pt); static void ub_scsi_action(unsigned long _dev); @@ -406,6 +420,8 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd); static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, int stalled_pipe); static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); +static void ub_reset_enter(struct ub_dev *sc); +static void ub_reset_task(void *arg); static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, struct ub_capacity *ret); @@ -518,6 +534,9 @@ static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr, spin_lock_irqsave(&sc->lock, flags); cnt += sprintf(page + cnt, + "poison %d reset %d\n", + atomic_read(&sc->poison), sc->reset); + cnt += sprintf(page + cnt, "qlen %d qmax %d\n", sc->cmd_queue.qlen, sc->cmd_queue.qmax); cnt += sprintf(page + cnt, @@ -766,7 +785,8 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) { struct ub_dev *sc = lun->udev; struct ub_scsi_cmd *cmd; - int rc; + struct ub_request *urq; + int n_elem; if (atomic_read(&sc->poison) || lun->changed) { blkdev_dequeue_request(rq); @@ -774,65 +794,70 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq) return 0; } + if (lun->urq.rq != NULL) + return -1; if ((cmd = ub_get_cmd(lun)) == NULL) return -1; memset(cmd, 0, sizeof(struct ub_scsi_cmd)); blkdev_dequeue_request(rq); + + urq = &lun->urq; + memset(urq, 0, sizeof(struct ub_request)); + urq->rq = rq; + + /* + * get scatterlist from block layer + */ + n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]); + if (n_elem < 0) { + printk(KERN_INFO "%s: failed request map (%d)\n", + lun->name, n_elem); /* P3 */ + goto drop; + } + if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ + printk(KERN_WARNING "%s: request with %d segments\n", + lun->name, n_elem); + goto drop; + } + urq->nsg = n_elem; + sc->sg_stat[n_elem < 5 ? n_elem : 5]++; + if (blk_pc_request(rq)) { - rc = ub_cmd_build_packet(sc, lun, cmd, rq); + ub_cmd_build_packet(sc, lun, cmd, urq); } else { - rc = ub_cmd_build_block(sc, lun, cmd, rq); - } - if (rc != 0) { - ub_put_cmd(lun, cmd); - ub_end_rq(rq, 0); - return 0; + ub_cmd_build_block(sc, lun, cmd, urq); } cmd->state = UB_CMDST_INIT; cmd->lun = lun; cmd->done = ub_rw_cmd_done; - cmd->back = rq; + cmd->back = urq; cmd->tag = sc->tagcnt++; - if (ub_submit_scsi(sc, cmd) != 0) { - ub_put_cmd(lun, cmd); - ub_end_rq(rq, 0); - return 0; - } + if (ub_submit_scsi(sc, cmd) != 0) + goto drop; + + return 0; +drop: + ub_put_cmd(lun, cmd); + ub_end_rq(rq, 0); return 0; } -static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, - struct ub_scsi_cmd *cmd, struct request *rq) +static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, + struct ub_scsi_cmd *cmd, struct ub_request *urq) { - int ub_dir; - int n_elem; + struct request *rq = urq->rq; unsigned int block, nblks; if (rq_data_dir(rq) == WRITE) - ub_dir = UB_DIR_WRITE; + cmd->dir = UB_DIR_WRITE; else - ub_dir = UB_DIR_READ; - cmd->dir = ub_dir; + cmd->dir = UB_DIR_READ; - /* - * get scatterlist from block layer - */ - n_elem = blk_rq_map_sg(lun->disk->queue, rq, &cmd->sgv[0]); - if (n_elem <= 0) { - printk(KERN_INFO "%s: failed request map (%d)\n", - sc->name, n_elem); /* P3 */ - return -1; /* request with no s/g entries? */ - } - if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ - printk(KERN_WARNING "%s: request with %d segments\n", - sc->name, n_elem); - return -1; - } - cmd->nsg = n_elem; - sc->sg_stat[n_elem < 5 ? n_elem : 5]++; + cmd->nsg = urq->nsg; + memcpy(cmd->sgv, urq->sgv, sizeof(struct scatterlist) * cmd->nsg); /* * build the command @@ -843,7 +868,7 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, block = rq->sector >> lun->capacity.bshift; nblks = rq->nr_sectors >> lun->capacity.bshift; - cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; + cmd->cdb[0] = (cmd->dir == UB_DIR_READ)? READ_10: WRITE_10; /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ cmd->cdb[2] = block >> 24; cmd->cdb[3] = block >> 16; @@ -854,14 +879,12 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, cmd->cdb_len = 10; cmd->len = rq->nr_sectors * 512; - - return 0; } -static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, - struct ub_scsi_cmd *cmd, struct request *rq) +static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, + struct ub_scsi_cmd *cmd, struct ub_request *urq) { - int n_elem; + struct request *rq = urq->rq; if (rq->data_len == 0) { cmd->dir = UB_DIR_NONE; @@ -870,40 +893,26 @@ static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, cmd->dir = UB_DIR_WRITE; else cmd->dir = UB_DIR_READ; - } - /* - * get scatterlist from block layer - */ - n_elem = blk_rq_map_sg(lun->disk->queue, rq, &cmd->sgv[0]); - if (n_elem < 0) { - printk(KERN_INFO "%s: failed request map (%d)\n", - sc->name, n_elem); /* P3 */ - return -1; - } - if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */ - printk(KERN_WARNING "%s: request with %d segments\n", - sc->name, n_elem); - return -1; - } - cmd->nsg = n_elem; - sc->sg_stat[n_elem < 5 ? n_elem : 5]++; + cmd->nsg = urq->nsg; + memcpy(cmd->sgv, urq->sgv, sizeof(struct scatterlist) * cmd->nsg); memcpy(&cmd->cdb, rq->cmd, rq->cmd_len); cmd->cdb_len = rq->cmd_len; cmd->len = rq->data_len; - - return 0; } static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) { - struct request *rq = cmd->back; struct ub_lun *lun = cmd->lun; + struct ub_request *urq = cmd->back; + struct request *rq; int uptodate; + rq = urq->rq; + if (cmd->error == 0) { uptodate = 1; @@ -924,9 +933,16 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) rq->errors = SAM_STAT_CHECK_CONDITION; else rq->errors = DID_ERROR << 16; + } else { + if (cmd->error == -EIO) { + if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0) + return; + } } } + urq->rq = NULL; + ub_put_cmd(lun, cmd); ub_end_rq(rq, uptodate); blk_start_queue(lun->disk->queue); @@ -941,6 +957,41 @@ static void ub_end_rq(struct request *rq, int uptodate) end_that_request_last(rq); } +static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, + struct ub_request *urq, struct ub_scsi_cmd *cmd) +{ + + if (atomic_read(&sc->poison)) + return -ENXIO; + + ub_reset_enter(sc); + + if (urq->current_try >= 3) + return -EIO; + urq->current_try++; + /* P3 */ printk("%s: dir %c len/act %d/%d " + "[sense %x %02x %02x] retry %d\n", + sc->name, UB_DIR_CHAR(cmd->dir), cmd->len, cmd->act_len, + cmd->key, cmd->asc, cmd->ascq, urq->current_try); + + memset(cmd, 0, sizeof(struct ub_scsi_cmd)); + ub_cmd_build_block(sc, lun, cmd, urq); + + cmd->state = UB_CMDST_INIT; + cmd->lun = lun; + cmd->done = ub_rw_cmd_done; + cmd->back = urq; + + cmd->tag = sc->tagcnt++; + +#if 0 /* Wasteful */ + return ub_submit_scsi(sc, cmd); +#else + ub_cmdq_add(sc, cmd); + return 0; +#endif +} + /* * Submit a regular SCSI operation (not an auto-sense). * @@ -1071,7 +1122,7 @@ static void ub_scsi_dispatch(struct ub_dev *sc) struct ub_scsi_cmd *cmd; int rc; - while ((cmd = ub_cmdq_peek(sc)) != NULL) { + while (!sc->reset && (cmd = ub_cmdq_peek(sc)) != NULL) { if (cmd->state == UB_CMDST_DONE) { ub_cmdq_pop(sc); (*cmd->done)(sc, cmd); @@ -1094,11 +1145,12 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) { struct urb *urb = &sc->work_urb; struct bulk_cs_wrap *bcs; + int len; int rc; if (atomic_read(&sc->poison)) { - /* A little too simplistic, I feel... */ - goto Bad_End; + ub_state_done(sc, cmd, -ENODEV); + return; } if (cmd->state == UB_CMDST_CLEAR) { @@ -1106,7 +1158,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) /* * STALL while clearning STALL. * The control pipe clears itself - nothing to do. - * XXX Might try to reset the device here and retry. */ printk(KERN_NOTICE "%s: stall on control pipe\n", sc->name); @@ -1125,11 +1176,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) } else if (cmd->state == UB_CMDST_CLR2STS) { if (urb->status == -EPIPE) { - /* - * STALL while clearning STALL. - * The control pipe clears itself - nothing to do. - * XXX Might try to reset the device here and retry. - */ printk(KERN_NOTICE "%s: stall on control pipe\n", sc->name); goto Bad_End; @@ -1147,11 +1193,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) } else if (cmd->state == UB_CMDST_CLRRS) { if (urb->status == -EPIPE) { - /* - * STALL while clearning STALL. - * The control pipe clears itself - nothing to do. - * XXX Might try to reset the device here and retry. - */ printk(KERN_NOTICE "%s: stall on control pipe\n", sc->name); goto Bad_End; @@ -1168,7 +1209,12 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) ub_state_stat_counted(sc, cmd); } else if (cmd->state == UB_CMDST_CMD) { - if (urb->status == -EPIPE) { + switch (urb->status) { + case 0: + break; + case -EOVERFLOW: + goto Bad_End; + case -EPIPE: rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); if (rc != 0) { printk(KERN_NOTICE "%s: " @@ -1178,17 +1224,20 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) * This is typically ENOMEM or some other such shit. * Retrying is pointless. Just do Bad End on it... */ - goto Bad_End; + ub_state_done(sc, cmd, rc); + return; } cmd->state = UB_CMDST_CLEAR; ub_cmdtr_state(sc, cmd); return; - } - if (urb->status != 0) { + case -ESHUTDOWN: /* unplug */ + case -EILSEQ: /* unplug timeout on uhci */ + ub_state_done(sc, cmd, -ENODEV); + return; + default: goto Bad_End; } if (urb->actual_length != US_BULK_CB_WRAP_LEN) { - /* XXX Must do reset here to unconfuse the device */ goto Bad_End; } @@ -1207,11 +1256,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) printk(KERN_NOTICE "%s: " "unable to submit clear (%d)\n", sc->name, rc); - /* - * This is typically ENOMEM or some other such shit. - * Retrying is pointless. Just do Bad End on it... - */ - goto Bad_End; + ub_state_done(sc, cmd, rc); + return; } cmd->state = UB_CMDST_CLR2STS; ub_cmdtr_state(sc, cmd); @@ -1220,14 +1266,50 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) if (urb->status == -EOVERFLOW) { /* * A babble? Failure, but we must transfer CSW now. - * XXX This is going to end in perpetual babble. Reset. */ cmd->error = -EOVERFLOW; /* A cheap trick... */ ub_state_stat(sc, cmd); return; } - if (urb->status != 0) - goto Bad_End; + + if (cmd->dir == UB_DIR_WRITE) { + /* + * Do not continue writes in case of a failure. + * Doing so would cause sectors to be mixed up, + * which is worse than sectors lost. + * + * We must try to read the CSW, or many devices + * get confused. + */ + len = urb->actual_length; + if (urb->status != 0 || + len != cmd->sgv[cmd->current_sg].length) { + cmd->act_len += len; + ub_cmdtr_act_len(sc, cmd); + + cmd->error = -EIO; + ub_state_stat(sc, cmd); + return; + } + + } else { + /* + * If an error occurs on read, we record it, and + * continue to fetch data in order to avoid bubble. + * + * As a small shortcut, we stop if we detect that + * a CSW mixed into data. + */ + if (urb->status != 0) + cmd->error = -EIO; + + len = urb->actual_length; + if (urb->status != 0 || + len != cmd->sgv[cmd->current_sg].length) { + if ((len & 0x1FF) == US_BULK_CS_WRAP_LEN) + goto Bad_End; + } + } cmd->act_len += urb->actual_length; ub_cmdtr_act_len(sc, cmd); @@ -1245,11 +1327,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) printk(KERN_NOTICE "%s: " "unable to submit clear (%d)\n", sc->name, rc); - /* - * This is typically ENOMEM or some other such shit. - * Retrying is pointless. Just do Bad End on it... - */ - goto Bad_End; + ub_state_done(sc, cmd, rc); + return; } /* @@ -1262,14 +1341,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) ub_cmdtr_state(sc, cmd); return; } - if (urb->status == -EOVERFLOW) { - /* - * XXX We are screwed here. Retrying is pointless, - * because the pipelined data will not get in until - * we read with a big enough buffer. We must reset XXX. - */ - goto Bad_End; - } + + /* Catch everything, including -EOVERFLOW and other nasties. */ if (urb->status != 0) goto Bad_End; @@ -1315,15 +1388,15 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) return; } - rc = le32_to_cpu(bcs->Residue); - if (rc != cmd->len - cmd->act_len) { + len = le32_to_cpu(bcs->Residue); + if (len != cmd->len - cmd->act_len) { /* * It is all right to transfer less, the caller has * to check. But it's not all right if the device * counts disagree with our counts. */ /* P3 */ printk("%s: resid %d len %d act %d\n", - sc->name, rc, cmd->len, cmd->act_len); + sc->name, len, cmd->len, cmd->act_len); goto Bad_End; } @@ -1334,13 +1407,13 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) ub_state_sense(sc, cmd); return; case US_BULK_STAT_PHASE: - /* XXX We must reset the transport here */ /* P3 */ printk("%s: status PHASE\n", sc->name); goto Bad_End; default: printk(KERN_INFO "%s: unknown CSW status 0x%x\n", sc->name, bcs->Status); - goto Bad_End; + ub_state_done(sc, cmd, -EINVAL); + return; } /* Not zeroing error to preserve a babble indicator */ @@ -1360,7 +1433,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd) printk(KERN_WARNING "%s: " "wrong command state %d\n", sc->name, cmd->state); - goto Bad_End; + ub_state_done(sc, cmd, -EINVAL); + return; } return; @@ -1608,6 +1682,93 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd) } /* + * Reset management + */ + +static void ub_reset_enter(struct ub_dev *sc) +{ + + if (sc->reset) { + /* This happens often on multi-LUN devices. */ + return; + } + sc->reset = 1; + +#if 0 /* Not needed because the disconnect waits for us. */ + unsigned long flags; + spin_lock_irqsave(&ub_lock, flags); + sc->openc++; + spin_unlock_irqrestore(&ub_lock, flags); +#endif + +#if 0 /* We let them stop themselves. */ + struct list_head *p; + struct ub_lun *lun; + list_for_each(p, &sc->luns) { + lun = list_entry(p, struct ub_lun, link); + blk_stop_queue(lun->disk->queue); + } +#endif + + schedule_work(&sc->reset_work); +} + +static void ub_reset_task(void *arg) +{ + struct ub_dev *sc = arg; + unsigned long flags; + struct list_head *p; + struct ub_lun *lun; + int lkr, rc; + + if (!sc->reset) { + printk(KERN_WARNING "%s: Running reset unrequested\n", + sc->name); + return; + } + + if (atomic_read(&sc->poison)) { + printk(KERN_NOTICE "%s: Not resetting disconnected device\n", + sc->name); /* P3 This floods. Remove soon. XXX */ + } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) { + printk(KERN_NOTICE "%s: Not resetting multi-interface device\n", + sc->name); /* P3 This floods. Remove soon. XXX */ + } else { + if ((lkr = usb_lock_device_for_reset(sc->dev, sc->intf)) < 0) { + printk(KERN_NOTICE + "%s: usb_lock_device_for_reset failed (%d)\n", + sc->name, lkr); + } else { + rc = usb_reset_device(sc->dev); + if (rc < 0) { + printk(KERN_NOTICE "%s: " + "usb_lock_device_for_reset failed (%d)\n", + sc->name, rc); + } + + if (lkr) + usb_unlock_device(sc->dev); + } + } + + /* + * In theory, no commands can be running while reset is active, + * so nobody can ask for another reset, and so we do not need any + * queues of resets or anything. We do need a spinlock though, + * to interact with block layer. + */ + spin_lock_irqsave(&sc->lock, flags); + sc->reset = 0; + tasklet_schedule(&sc->tasklet); + list_for_each(p, &sc->luns) { + lun = list_entry(p, struct ub_lun, link); + blk_start_queue(lun->disk->queue); + } + wake_up(&sc->reset_wait); + spin_unlock_irqrestore(&sc->lock, flags); +} + +/* * This is called from a process context. */ static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun) @@ -2142,7 +2303,7 @@ static int ub_get_pipes(struct ub_dev *sc, struct usb_device *dev, if (ep_in == NULL || ep_out == NULL) { printk(KERN_NOTICE "%s: failed endpoint check\n", sc->name); - return -EIO; + return -ENODEV; } /* Calculate and store the pipe values */ @@ -2180,6 +2341,8 @@ static int ub_probe(struct usb_interface *intf, usb_init_urb(&sc->work_urb); tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); atomic_set(&sc->poison, 0); + INIT_WORK(&sc->reset_work, ub_reset_task, sc); + init_waitqueue_head(&sc->reset_wait); init_timer(&sc->work_timer); sc->work_timer.data = (unsigned long) sc; @@ -2200,7 +2363,8 @@ static int ub_probe(struct usb_interface *intf, /* XXX Verify that we can handle the device (from descriptors) */ - ub_get_pipes(sc, sc->dev, intf); + if (ub_get_pipes(sc, sc->dev, intf) != 0) + goto err_dev_desc; if (device_create_file(&sc->intf->dev, &dev_attr_diag) != 0) goto err_diag; @@ -2271,6 +2435,7 @@ static int ub_probe(struct usb_interface *intf, /* device_remove_file(&sc->intf->dev, &dev_attr_diag); */ err_diag: +err_dev_desc: usb_set_intfdata(intf, NULL); // usb_put_intf(sc->intf); usb_put_dev(sc->dev); @@ -2379,6 +2544,11 @@ static void ub_disconnect(struct usb_interface *intf) atomic_set(&sc->poison, 1); /* + * Wait for reset to end, if any. + */ + wait_event(sc->reset_wait, !sc->reset); + + /* * Blow away queued commands. * * Actually, this never works, because before we get here @@ -2391,7 +2561,7 @@ static void ub_disconnect(struct usb_interface *intf) { struct ub_scsi_cmd *cmd; int cnt = 0; - while ((cmd = ub_cmdq_pop(sc)) != NULL) { + while ((cmd = ub_cmdq_peek(sc)) != NULL) { cmd->error = -ENOTCONN; cmd->state = UB_CMDST_DONE; ub_cmdtr_state(sc, cmd); -- cgit v1.1 From 4fb729f5863c29e4466afb4508186303f46458e7 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sat, 17 Dec 2005 02:34:12 -0800 Subject: [PATCH] USB: ub 01 rename Rename misleading UB_MINORS_PER_MAJOR into UB_PARTS_PER_LUN. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/block/ub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/ub.c b/drivers/block/ub.c index ba05e31..8138059 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -115,7 +115,7 @@ /* */ -#define UB_MINORS_PER_MAJOR 8 +#define UB_PARTS_PER_LUN 8 #define UB_MAX_CDB_SIZE 16 /* Corresponds to Bulk */ @@ -2473,14 +2473,14 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum) ub_revalidate(sc, lun); rc = -ENOMEM; - if ((disk = alloc_disk(UB_MINORS_PER_MAJOR)) == NULL) + if ((disk = alloc_disk(UB_PARTS_PER_LUN)) == NULL) goto err_diskalloc; lun->disk = disk; sprintf(disk->disk_name, DRV_NAME "%c", lun->id + 'a'); sprintf(disk->devfs_name, DEVFS_NAME "/%c", lun->id + 'a'); disk->major = UB_MAJOR; - disk->first_minor = lun->id * UB_MINORS_PER_MAJOR; + disk->first_minor = lun->id * UB_PARTS_PER_LUN; disk->fops = &ub_bd_fops; disk->private_data = lun; disk->driverfs_dev = &sc->intf->dev; -- cgit v1.1 From ab93091dd7f3d3dff9e8d1811d8344af1c52493b Mon Sep 17 00:00:00 2001 From: Daniel Marjamaki Date: Sat, 17 Dec 2005 02:38:46 -0800 Subject: [PATCH] USB: ub 02 Removed unused variable Removed an unused variable Signed-off-by: Daniel Marjamaki Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/block/ub.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 8138059..10740a0 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -950,10 +950,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) static void ub_end_rq(struct request *rq, int uptodate) { - int rc; - - rc = end_that_request_first(rq, uptodate, rq->hard_nr_sectors); - // assert(rc == 0); + end_that_request_first(rq, uptodate, rq->hard_nr_sectors); end_that_request_last(rq); } -- cgit v1.1 From 3e220e9505f3c993b666b5e22b1c466b69ee4f54 Mon Sep 17 00:00:00 2001 From: Phil Dibowitz Date: Sun, 18 Dec 2005 21:30:02 -0800 Subject: [PATCH] USB Storage: Fix unusual_devs.h order Alan Stern pointed out there was an ordering issue in unusual_devs.h, and this patch fixes it. Signed-off-by: Phil Dibowitz Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 7a865dd..dc301e5 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -79,13 +79,6 @@ UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001, US_SC_8070, US_PR_USBAT, init_usbat, 0), #endif -/* Patch submitted by Mihnea-Costin Grigore */ -UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003, - "VIA Technologies Inc.", - "USB 2.0 Card Reader", - US_SC_DEVICE, US_PR_DEVICE, NULL, - US_FL_IGNORE_RESIDUE ), - /* Reported by Sebastian Kapfer * and Olaf Hering (different bcd's, same vendor/product) * for USB floppies that need the SINGLE_LUN enforcement. @@ -96,6 +89,13 @@ UNUSUAL_DEV( 0x0409, 0x0040, 0x0000, 0x9999, US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_SINGLE_LUN ), +/* Patch submitted by Mihnea-Costin Grigore */ +UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003, + "VIA Technologies Inc.", + "USB 2.0 Card Reader", + US_SC_DEVICE, US_PR_DEVICE, NULL, + US_FL_IGNORE_RESIDUE ), + /* Deduced by Jonathan Woithe * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message * always fails and confuses drive. -- cgit v1.1 From 5e0f76c6bbc0d26cd9625876f7beeb7b002f39bf Mon Sep 17 00:00:00 2001 From: David Hollis Date: Mon, 19 Dec 2005 13:58:38 -0500 Subject: [PATCH] USB: asix.c - Add Linksys USB200M Rev 2 ids Attached patch adds device IDs for the Linksys USB200M Rev 2 device which uses the AX88772 chipset. Signed-off-by: David Hollis Signed-off-by: Greg Kroah-Hartman --- drivers/usb/net/asix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c index 2faf2f2..5411816 100644 --- a/drivers/usb/net/asix.c +++ b/drivers/usb/net/asix.c @@ -912,6 +912,10 @@ static const struct usb_device_id products [] = { // ASIX AX88772 10/100 USB_DEVICE (0x0b95, 0x7720), .driver_info = (unsigned long) &ax88772_info, +}, { + // Linksys USB200M Rev 2 + USB_DEVICE (0x13b1, 0x0018), + .driver_info = (unsigned long) &ax88772_info, }, { }, // END }; -- cgit v1.1 From aafbf24a1129480157af7ee780eddcea9b76ee5c Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Tue, 20 Dec 2005 14:15:04 -0800 Subject: [PATCH] USB: replace __setup("nousb") with __module_param_call Fedora users complain that passing "nousbstorage" to the installer causes the rest of the USB support to disappear. The installer uses kernel command line as a way to pass options through Syslinux. The problem stems from the use of strncmp() in obsolete_checksetup(). I used __module_param_call() instead of module_param because I wanted to preserve the old syntax in grub.conf, and it's the only macro which allows to remove the prefix. The fix is tested to accept the option "nousb" correctly now. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/usb.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 39e6b61b..6ee2b53 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -46,7 +46,6 @@ const char *usbcore_name = "usbcore"; static int nousb; /* Disable USB when built into kernel image */ - /* Not honored on modular build */ /** @@ -1096,18 +1095,8 @@ struct bus_type usb_bus_type = { .resume = usb_generic_resume, }; -#ifndef MODULE - -static int __init usb_setup_disable(char *str) -{ - nousb = 1; - return 1; -} - /* format to disable USB on kernel command line is: nousb */ -__setup("nousb", usb_setup_disable); - -#endif +__module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444); /* * for external read access to -- cgit v1.1 From ff90651883093576de2d60bebaae39b0dd2e62f6 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Wed, 21 Dec 2005 19:27:29 +0100 Subject: [PATCH] USB: Limiting of resource use in skeleton driver this introduces limits whose lack in the skeleton driver someone recently complained about. Signed-off-by: Oliver Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usb-skeleton.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 60c458e..719d23a 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -39,10 +39,15 @@ MODULE_DEVICE_TABLE (usb, skel_table); /* Get a minor range for your devices from the usb maintainer */ #define USB_SKEL_MINOR_BASE 192 +/* our private defines. if this grows any larger, use your own .h file */ +#define MAX_TRANSFER ( PAGE_SIZE - 512 ) +#define WRITES_IN_FLIGHT 8 + /* Structure to hold all of our device specific stuff */ struct usb_skel { struct usb_device * udev; /* the usb device for this device */ struct usb_interface * interface; /* the interface for this device */ + struct semaphore limit_sem; /* limiting the number of writes in progress */ unsigned char * bulk_in_buffer; /* the buffer to receive data */ size_t bulk_in_size; /* the size of the receive buffer */ __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */ @@ -152,6 +157,7 @@ static void skel_write_bulk_callback(struct urb *urb, struct pt_regs *regs) /* free up our allocated buffer */ usb_buffer_free(urb->dev, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); + up(&dev->limit_sem); } static ssize_t skel_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos) @@ -160,6 +166,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou int retval = 0; struct urb *urb = NULL; char *buf = NULL; + size_t writesize = max(count, MAX_TRANSFER); dev = (struct usb_skel *)file->private_data; @@ -167,6 +174,9 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou if (count == 0) goto exit; + /* limit the number of URBs in flight to stop a user from using up all RAM */ + down (&dev->limit_sem); + /* create a urb, and a buffer for it, and copy the data to the urb */ urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) { @@ -174,13 +184,13 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou goto error; } - buf = usb_buffer_alloc(dev->udev, count, GFP_KERNEL, &urb->transfer_dma); + buf = usb_buffer_alloc(dev->udev, writesize, GFP_KERNEL, &urb->transfer_dma); if (!buf) { retval = -ENOMEM; goto error; } - if (copy_from_user(buf, user_buffer, count)) { + if (copy_from_user(buf, user_buffer, writesize)) { retval = -EFAULT; goto error; } @@ -188,7 +198,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou /* initialize the urb properly */ usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr), - buf, count, skel_write_bulk_callback, dev); + buf, writesize, skel_write_bulk_callback, dev); urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; /* send the data out the bulk port */ @@ -202,11 +212,12 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou usb_free_urb(urb); exit: - return count; + return writesize; error: - usb_buffer_free(dev->udev, count, buf, urb->transfer_dma); + usb_buffer_free(dev->udev, writesize, buf, urb->transfer_dma); usb_free_urb(urb); + up(&dev->limit_sem); return retval; } @@ -238,13 +249,13 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i int retval = -ENOMEM; /* allocate memory for our device state and initialize it */ - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (dev == NULL) { err("Out of memory"); goto error; } - memset(dev, 0x00, sizeof(*dev)); kref_init(&dev->kref); + sema_init(&dev->limit_sem, WRITES_IN_FLIGHT); dev->udev = usb_get_dev(interface_to_usbdev(interface)); dev->interface = interface; -- cgit v1.1 From a083dec0ed537a75fbe8f2f83d198e9e672240d8 Mon Sep 17 00:00:00 2001 From: Nathan Lynch Date: Sun, 18 Dec 2005 23:41:38 -0600 Subject: [PATCH] USB: zd1201: make sysfs device symlink Noticed that my zd1201 adapter isn't "seen" by hal and NetworkManager. The problem seems to be that unlike other network device drivers I checked, zd1201 does not do a SET_NETDEV_DEV(), which makes it so a "device" symlink is created under /sys/class/net/wlan0. With the following patch the device symlink shows up, and now I am happily using NetworkManager to control the adapter: $ ls -l /sys/class/net/wlan0 total 0 -r--r--r-- 1 root root 4096 Dec 18 13:42 address -r--r--r-- 1 root root 4096 Dec 18 13:42 addr_len -r--r--r-- 1 root root 4096 Dec 18 13:42 broadcast -r--r--r-- 1 root root 4096 Dec 18 13:42 carrier lrwxrwxrwx 1 root root 0 Dec 18 13:42 device -> ../../../devices/pci0001:10/0001:10:1b.1/usb4/4-1 -r--r--r-- 1 root root 4096 Dec 18 13:42 features Signed-off-by: Nathan Lynch Signed-off-by: Greg Kroah-Hartman --- drivers/usb/net/zd1201.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index 2af21a6..f3a8e28 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c @@ -1829,6 +1829,8 @@ static int zd1201_probe(struct usb_interface *interface, if (err) goto err_net; + SET_NETDEV_DEV(zd->dev, &usb->dev); + err = register_netdev(zd->dev); if (err) goto err_net; -- cgit v1.1 From 318e479eb7ad9a948c6da381976d258464413816 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Wed, 21 Dec 2005 17:03:24 -0800 Subject: [PATCH] USB: ioctl compat for usblp.c From: David Woodhouse David has a G5 with a printer. I am quite surprised that nobody else noticed this before. Linus has a G5. Hackers hate printing in general, maybe. We do not use BKL anymore, because one of code paths had a sleeping call, so we had to use a semaphore. I am sure it's safe to use unlocked_ioctl. The new ioctls return long and retval is int. It looks completely fine to me. We never want these extra bits, and the sign extension ought to work right. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman -- --- drivers/usb/class/usblp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 6918037..708a292 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -438,7 +438,7 @@ static unsigned int usblp_poll(struct file *file, struct poll_table_struct *wait | (!usblp->wcomplete ? 0 : POLLOUT | POLLWRNORM); } -static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct usblp *usblp = file->private_data; int length, err, i; @@ -838,7 +838,8 @@ static struct file_operations usblp_fops = { .read = usblp_read, .write = usblp_write, .poll = usblp_poll, - .ioctl = usblp_ioctl, + .unlocked_ioctl = usblp_ioctl, + .compat_ioctl = usblp_ioctl, .open = usblp_open, .release = usblp_release, }; -- cgit v1.1 From a9714c845c0681a203a9ae22aa5165ec72c51d33 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Fri, 23 Dec 2005 16:41:41 +0000 Subject: [PATCH] USB: Export IEEE-1284 device id in sysfs for usblp devices I looked at the userspace code which uses the LPIOC_GET_DEVICE_ID ioctl and I almost went blind. Let's export it in sysfs instead, and just as a string instead of with a big-endian length at the beginning of it. This also prints the message about finding the printer _after_ we know the minor device number it's going to have, rather than reporting all printers as 'usblp0'. Signed-off-by: David Woodhouse Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usblp.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 708a292..27e9404 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -850,6 +850,20 @@ static struct usb_class_driver usblp_class = { .minor_base = USBLP_MINOR_BASE, }; +static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct usb_interface *intf = to_usb_interface(dev); + struct usblp *usblp = usb_get_intfdata (intf); + + if (usblp->device_id_string[0] == 0 && + usblp->device_id_string[1] == 0) + return 0; + + return sprintf(buf, "%s", usblp->device_id_string+2); +} + +static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL); + static int usblp_probe(struct usb_interface *intf, const struct usb_device_id *id) { @@ -934,20 +948,12 @@ static int usblp_probe(struct usb_interface *intf, /* Retrieve and store the device ID string. */ usblp_cache_device_id_string(usblp); + device_create_file(&intf->dev, &dev_attr_ieee1284_id); #ifdef DEBUG usblp_check_status(usblp, 0); #endif - info("usblp%d: USB %sdirectional printer dev %d " - "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X", - usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum, - usblp->ifnum, - usblp->protocol[usblp->current_protocol].alt_setting, - usblp->current_protocol, - le16_to_cpu(usblp->dev->descriptor.idVendor), - le16_to_cpu(usblp->dev->descriptor.idProduct)); - usb_set_intfdata (intf, usblp); usblp->present = 1; @@ -958,11 +964,20 @@ static int usblp_probe(struct usb_interface *intf, goto abort_intfdata; } usblp->minor = intf->minor; + info("usblp%d: USB %sdirectional printer dev %d " + "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X", + usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum, + usblp->ifnum, + usblp->protocol[usblp->current_protocol].alt_setting, + usblp->current_protocol, + le16_to_cpu(usblp->dev->descriptor.idVendor), + le16_to_cpu(usblp->dev->descriptor.idProduct)); return 0; abort_intfdata: usb_set_intfdata (intf, NULL); + device_remove_file(&intf->dev, &dev_attr_ieee1284_id); abort: if (usblp) { if (usblp->writebuf) @@ -1157,6 +1172,8 @@ static void usblp_disconnect(struct usb_interface *intf) BUG (); } + device_remove_file(&intf->dev, &dev_attr_ieee1284_id); + down (&usblp_sem); down (&usblp->sem); usblp->present = 0; -- cgit v1.1 From f5691d70d4aeec0ac9cff11f0cabb7d5a1735705 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Wed, 21 Dec 2005 17:24:54 -0800 Subject: [PATCH] USB: fix usb_find_interface for ppc64 Fix usb_find_interface. You cannot case pointers to int and long on a big-endian 64-bitter without consequences. Signed-off-by: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/usb.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 6ee2b53..56a3520 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -192,20 +192,23 @@ void usb_driver_release_interface(struct usb_driver *driver, iface->condition = USB_INTERFACE_UNBOUND; mark_quiesced(iface); } +struct find_interface_arg { + int minor; + struct usb_interface *interface; +}; static int __find_interface(struct device * dev, void * data) { - struct usb_interface ** ret = (struct usb_interface **)data; - struct usb_interface * intf = *ret; - int *minor = (int *)data; + struct find_interface_arg *arg = data; + struct usb_interface *intf; /* can't look at usb devices, only interfaces */ if (dev->driver == &usb_generic_driver) return 0; intf = to_usb_interface(dev); - if (intf->minor != -1 && intf->minor == *minor) { - *ret = intf; + if (intf->minor != -1 && intf->minor == arg->minor) { + arg->interface = intf; return 1; } return 0; @@ -222,12 +225,12 @@ static int __find_interface(struct device * dev, void * data) */ struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) { - struct usb_interface *intf = (struct usb_interface *)(long)minor; - int ret; - - ret = driver_for_each_device(&drv->driver, NULL, &intf, __find_interface); + struct find_interface_arg argb; - return ret ? intf : NULL; + argb.minor = minor; + argb.interface = NULL; + driver_for_each_device(&drv->driver, NULL, &argb, __find_interface); + return argb.interface; } #ifdef CONFIG_HOTPLUG -- cgit v1.1 From cb5b3f6950b4fbad9d8d41756f49aba792804b5b Mon Sep 17 00:00:00 2001 From: Olav Kongas Date: Thu, 22 Dec 2005 12:44:52 +0200 Subject: [PATCH] USB: fix buffer size limiting in skeleton driver Fix buffer size limiting. Signed-off-by: Olav Kongas Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usb-skeleton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 719d23a..b6652ef 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -166,7 +166,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou int retval = 0; struct urb *urb = NULL; char *buf = NULL; - size_t writesize = max(count, MAX_TRANSFER); + size_t writesize = min(count, MAX_TRANSFER); dev = (struct usb_skel *)file->private_data; -- cgit v1.1 From c8dd7709c534ab0d713aa698c99132b6c812b57c Mon Sep 17 00:00:00 2001 From: Sam Bishop Date: Thu, 22 Dec 2005 17:11:02 -0700 Subject: [PATCH] USB: fix usb-skeleton limit resource usage patch. Prevents a compiler warning and uses down_interruptible() instead of down() in process context. Signed-off-by: Sam Bishop Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usb-skeleton.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index b6652ef..5d02f16 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -166,7 +166,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou int retval = 0; struct urb *urb = NULL; char *buf = NULL; - size_t writesize = min(count, MAX_TRANSFER); + size_t writesize = min(count, (size_t)MAX_TRANSFER); dev = (struct usb_skel *)file->private_data; @@ -175,7 +175,10 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou goto exit; /* limit the number of URBs in flight to stop a user from using up all RAM */ - down (&dev->limit_sem); + if (down_interruptible(&dev->limit_sem)) { + retval = -ERESTARTSYS; + goto exit; + } /* create a urb, and a buffer for it, and copy the data to the urb */ urb = usb_alloc_urb(0, GFP_KERNEL); -- cgit v1.1 From a020ff412f0ecbb1e4aae1681b287e5785dd77b5 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 4 Jan 2006 18:01:03 +0000 Subject: [PATCH] Fix pragma packing in ip2 driver This fixes the pragma packing in the ip2 driver by popping the previous setting rather than explicitly assuming that the correct setting is 4. This also gets around a compiler bug in the FRV compiler when building allmodconfig. Signed-Off-By: David Howells Signed-off-by: Linus Torvalds --- drivers/char/ip2/i2pack.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/char/ip2/i2pack.h b/drivers/char/ip2/i2pack.h index e9b87a7..00342a6 100644 --- a/drivers/char/ip2/i2pack.h +++ b/drivers/char/ip2/i2pack.h @@ -358,7 +358,7 @@ typedef struct _failStat #define MB_OUT_STRIPPED 0x40 // Board has read all output from fifo #define MB_FATAL_ERROR 0x20 // Board has encountered a fatal error -#pragma pack(4) // Reset padding to command-line default +#pragma pack() // Reset padding to command-line default #endif // I2PACK_H -- cgit v1.1 From ca4033024858fcbd392465ba9cbf4c838aedfb58 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Wed, 4 Jan 2006 13:56:08 -0800 Subject: [ECONET]: Use macro for spinlock_t definition. Signed-off-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- net/econet/af_econet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 4fc2452..c792994 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c @@ -57,7 +57,7 @@ static struct net_device *net2dev_map[256]; #define EC_PORT_IP 0xd2 #ifdef CONFIG_ECONET_AUNUDP -static spinlock_t aun_queue_lock; +static DEFINE_SPINLOCK(aun_queue_lock); static struct socket *udpsock; #define AUN_PORT 0x8000 -- cgit v1.1 From 196433c5b788eb732fdcf92449274e302f089ce4 Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Wed, 4 Jan 2006 13:56:31 -0800 Subject: [IPV6]: Use macro for rwlock_t initialization. Signed-off-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- net/ipv6/mcast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index f829a4a..1cf305a 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c @@ -224,7 +224,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr) mc_lst->ifindex = dev->ifindex; mc_lst->sfmode = MCAST_EXCLUDE; - mc_lst->sflock = RW_LOCK_UNLOCKED; + rwlock_init(&mc_lst->sflock); mc_lst->sflist = NULL; /* -- cgit v1.1 From 181a46a56e9f852060c54247209e93740329b6eb Mon Sep 17 00:00:00 2001 From: YOSHIFUJI Hideaki Date: Wed, 4 Jan 2006 13:56:54 -0800 Subject: [NETFILTER]: Use macro for spinlock_t/rwlock_t initializations/definition. Signed-off-by: YOSHIFUJI Hideaki Signed-off-by: David S. Miller --- net/ipv6/netfilter/nf_conntrack_reasm.c | 4 ++-- net/netfilter/nfnetlink_log.c | 2 +- net/netfilter/nfnetlink_queue.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index c2c52af..f3e5ffb 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -98,7 +98,7 @@ struct nf_ct_frag6_queue #define FRAG6Q_HASHSZ 64 static struct nf_ct_frag6_queue *nf_ct_frag6_hash[FRAG6Q_HASHSZ]; -static rwlock_t nf_ct_frag6_lock = RW_LOCK_UNLOCKED; +static DEFINE_RWLOCK(nf_ct_frag6_lock); static u32 nf_ct_frag6_hash_rnd; static LIST_HEAD(nf_ct_frag6_lru_list); int nf_ct_frag6_nqueues = 0; @@ -371,7 +371,7 @@ nf_ct_frag6_create(unsigned int hash, u32 id, struct in6_addr *src, struct init_timer(&fq->timer); fq->timer.function = nf_ct_frag6_expire; fq->timer.data = (long) fq; - fq->lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&fq->lock); atomic_set(&fq->refcnt, 1); return nf_ct_frag6_intern(hash, fq); diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index cba6372..e10512e 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -151,7 +151,7 @@ instance_create(u_int16_t group_num, int pid) goto out_unlock; INIT_HLIST_NODE(&inst->hlist); - inst->lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&inst->lock); /* needs to be two, since we _put() after creation */ atomic_set(&inst->use, 2); diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index f28460b6..55afdda 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c @@ -148,7 +148,7 @@ instance_create(u_int16_t queue_num, int pid) atomic_set(&inst->id_sequence, 0); /* needs to be two, since we _put() after creation */ atomic_set(&inst->use, 2); - inst->lock = SPIN_LOCK_UNLOCKED; + spin_lock_init(&inst->lock); INIT_LIST_HEAD(&inst->queue_list); if (!try_module_get(THIS_MODULE)) -- cgit v1.1 From 9369986306d4692f37b61302d4e1ce3054d8833e Mon Sep 17 00:00:00 2001 From: Kris Katterjohn Date: Wed, 4 Jan 2006 13:58:36 -0800 Subject: [NET]: More instruction checks fornet/core/filter.c Signed-off-by: Kris Katterjohn Signed-off-by: David S. Miller --- net/core/filter.c | 112 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 32 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 3a10e0b..8964d34 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -13,6 +13,7 @@ * 2 of the License, or (at your option) any later version. * * Andi Kleen - Fix a few bad bugs and races. + * Kris Katterjohn - Added many additional checks in sk_chk_filter() */ #include @@ -250,7 +251,7 @@ load_b: mem[fentry->k] = X; continue; default: - /* Invalid instruction counts as RET */ + WARN_ON(1); return 0; } @@ -283,8 +284,8 @@ load_b: * * Check the user's filter code. If we let some ugly * filter code slip through kaboom! The filter must contain - * no references or jumps that are out of range, no illegal instructions - * and no backward jumps. It must end with a RET instruction + * no references or jumps that are out of range, no illegal + * instructions, and must end with a RET instruction. * * Returns 0 if the rule set is legal or a negative errno code if not. */ @@ -300,38 +301,85 @@ int sk_chk_filter(struct sock_filter *filter, int flen) for (pc = 0; pc < flen; pc++) { /* all jumps are forward as they are not signed */ ftest = &filter[pc]; - if (BPF_CLASS(ftest->code) == BPF_JMP) { - /* but they mustn't jump off the end */ - if (BPF_OP(ftest->code) == BPF_JA) { - /* - * Note, the large ftest->k might cause loops. - * Compare this with conditional jumps below, - * where offsets are limited. --ANK (981016) - */ - if (ftest->k >= (unsigned)(flen-pc-1)) - return -EINVAL; - } else { - /* for conditionals both must be safe */ - if (pc + ftest->jt +1 >= flen || - pc + ftest->jf +1 >= flen) - return -EINVAL; - } - } - /* check for division by zero -Kris Katterjohn 2005-10-30 */ - if (ftest->code == (BPF_ALU|BPF_DIV|BPF_K) && ftest->k == 0) - return -EINVAL; + /* Only allow valid instructions */ + switch (ftest->code) { + case BPF_ALU|BPF_ADD|BPF_K: + case BPF_ALU|BPF_ADD|BPF_X: + case BPF_ALU|BPF_SUB|BPF_K: + case BPF_ALU|BPF_SUB|BPF_X: + case BPF_ALU|BPF_MUL|BPF_K: + case BPF_ALU|BPF_MUL|BPF_X: + case BPF_ALU|BPF_DIV|BPF_X: + case BPF_ALU|BPF_AND|BPF_K: + case BPF_ALU|BPF_AND|BPF_X: + case BPF_ALU|BPF_OR|BPF_K: + case BPF_ALU|BPF_OR|BPF_X: + case BPF_ALU|BPF_LSH|BPF_K: + case BPF_ALU|BPF_LSH|BPF_X: + case BPF_ALU|BPF_RSH|BPF_K: + case BPF_ALU|BPF_RSH|BPF_X: + case BPF_ALU|BPF_NEG: + case BPF_LD|BPF_W|BPF_ABS: + case BPF_LD|BPF_H|BPF_ABS: + case BPF_LD|BPF_B|BPF_ABS: + case BPF_LD|BPF_W|BPF_LEN: + case BPF_LD|BPF_W|BPF_IND: + case BPF_LD|BPF_H|BPF_IND: + case BPF_LD|BPF_B|BPF_IND: + case BPF_LD|BPF_IMM: + case BPF_LDX|BPF_W|BPF_LEN: + case BPF_LDX|BPF_B|BPF_MSH: + case BPF_LDX|BPF_IMM: + case BPF_MISC|BPF_TAX: + case BPF_MISC|BPF_TXA: + case BPF_RET|BPF_K: + case BPF_RET|BPF_A: + break; + + /* Some instructions need special checks */ - /* check that memory operations use valid addresses. */ - if (ftest->k >= BPF_MEMWORDS) { - /* but it might not be a memory operation... */ - switch (ftest->code) { - case BPF_ST: - case BPF_STX: - case BPF_LD|BPF_MEM: - case BPF_LDX|BPF_MEM: + case BPF_ALU|BPF_DIV|BPF_K: + /* check for division by zero */ + if (ftest->k == 0) return -EINVAL; - } + break; + + case BPF_LD|BPF_MEM: + case BPF_LDX|BPF_MEM: + case BPF_ST: + case BPF_STX: + /* check for invalid memory addresses */ + if (ftest->k >= BPF_MEMWORDS) + return -EINVAL; + break; + + case BPF_JMP|BPF_JA: + /* + * Note, the large ftest->k might cause loops. + * Compare this with conditional jumps below, + * where offsets are limited. --ANK (981016) + */ + if (ftest->k >= (unsigned)(flen-pc-1)) + return -EINVAL; + break; + + case BPF_JMP|BPF_JEQ|BPF_K: + case BPF_JMP|BPF_JEQ|BPF_X: + case BPF_JMP|BPF_JGE|BPF_K: + case BPF_JMP|BPF_JGE|BPF_X: + case BPF_JMP|BPF_JGT|BPF_K: + case BPF_JMP|BPF_JGT|BPF_X: + case BPF_JMP|BPF_JSET|BPF_K: + case BPF_JMP|BPF_JSET|BPF_X: + /* for conditionals both must be safe */ + if (pc + ftest->jt + 1 >= flen || + pc + ftest->jf + 1 >= flen) + return -EINVAL; + break; + + default: + return -EINVAL; } } -- cgit v1.1 From 74cb8798222bb7d1aecb0acb91e6eeedf5feb948 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Wed, 4 Jan 2006 13:59:32 -0800 Subject: [TCP] tcp_vegas: Fix slow start Vegas' slow start was only adding one MSS per RTT rather than one for every ack. Slow start behavior should now match Reno. Signed-off-by: Thomas Young Signed-off-by: David S. Miller --- net/ipv4/tcp_vegas.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c index 13e7e6e..3b74034 100644 --- a/net/ipv4/tcp_vegas.c +++ b/net/ipv4/tcp_vegas.c @@ -330,6 +330,10 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, vegas->cntRTT = 0; vegas->minRTT = 0x7fffffff; } + /* Use normal slow start */ + else if (tp->snd_cwnd <= tp->snd_ssthresh) + tcp_slow_start(tp); + } /* Extract info for Tcp socket info provided via netlink. */ -- cgit v1.1 From 034382117725f6b6b26fbb138498139c5c012c1b Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 11 Nov 2005 04:25:06 +0100 Subject: [PATCH] keep pnpbios usermod_helper away from hotplug_path[] These days we use udev to manage all kernel events. /proc/sys/kernel/hotplug will usually be disabled by an init-script. pnpnbios is not integrated with the driver core and should stay away from the now disabled /sbin/hotplug. Set the helper to /sbin/phpbios, even when there is probably no current user of this faciliy. If it's needed, it should definitely get proper driver core integration instead of forking binaries from the kernel. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/pnp/pnpbios/core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c index f49674f..b154b3f 100644 --- a/drivers/pnp/pnpbios/core.c +++ b/drivers/pnp/pnpbios/core.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include @@ -106,8 +105,6 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) char *argv [3], **envp, *buf, *scratch; int i = 0, value; - if (!hotplug_path [0]) - return -ENOENT; if (!current->fs->root) { return -EAGAIN; } @@ -119,8 +116,9 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info) return -ENOMEM; } - /* only one standardized param to hotplug command: type */ - argv [0] = hotplug_path; + /* FIXME: if there are actual users of this, it should be integrated into + * the driver core and use the usual infrastructure like sysfs and uevents */ + argv [0] = "/sbin/pnpbios"; argv [1] = "dock"; argv [2] = NULL; -- cgit v1.1 From 0296b2281352e4794e174b393c37f131502e09f0 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 11 Nov 2005 05:33:52 +0100 Subject: [PATCH] remove CONFIG_KOBJECT_UEVENT option It makes zero sense to have hotplug, but not the netlink events enabled today. Remove this option and merge the kobject_uevent.h header into the kobject.h header file. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 6 ----- drivers/input/input.c | 1 - drivers/s390/crypto/z90main.c | 1 - include/linux/kobject.h | 35 +++++++++++++++++++++++++- include/linux/kobject_uevent.h | 57 ------------------------------------------ init/Kconfig | 19 -------------- kernel/sysctl.c | 4 +-- lib/kobject_uevent.c | 24 ++++-------------- 8 files changed, 40 insertions(+), 107 deletions(-) delete mode 100644 include/linux/kobject_uevent.h diff --git a/MAINTAINERS b/MAINTAINERS index 6af6830..b49a4ad 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1476,12 +1476,6 @@ W: http://nfs.sourceforge.net/ W: http://www.cse.unsw.edu.au/~neilb/patches/linux-devel/ S: Maintained -KERNEL EVENT LAYER (KOBJECT_UEVENT) -P: Robert Love -M: rml@novell.com -L: linux-kernel@vger.kernel.org -S: Maintained - KEXEC P: Eric Biederman P: Randy Dunlap diff --git a/drivers/input/input.c b/drivers/input/input.c index bdd2a7f..43b49ccd 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c index 4010f2b..790fcbb 100644 --- a/drivers/s390/crypto/z90main.c +++ b/drivers/s390/crypto/z90main.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include "z90crypt.h" diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 7f7403a..baf5251 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -23,15 +23,31 @@ #include #include #include -#include #include #include #define KOBJ_NAME_LEN 20 +#define HOTPLUG_PATH_LEN 256 + +/* path to the userspace helper executed on an event */ +extern char hotplug_path[]; + /* counter to tag the hotplug event, read only except for the kobject core */ extern u64 hotplug_seqnum; +/* the actions here must match the proper string in lib/kobject_uevent.c */ +typedef int __bitwise kobject_action_t; +enum kobject_action { + KOBJ_ADD = (__force kobject_action_t) 0x01, /* add event, for hotplug */ + KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* remove event, for hotplug */ + KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* a sysfs attribute file has changed */ + KOBJ_MOUNT = (__force kobject_action_t) 0x04, /* mount event for block devices */ + KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices */ + KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* offline event for hotplug devices */ + KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* online event for hotplug devices */ +}; + struct kobject { const char * k_name; char name[KOBJ_NAME_LEN]; @@ -243,16 +259,33 @@ extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *); #ifdef CONFIG_HOTPLUG void kobject_hotplug(struct kobject *kobj, enum kobject_action action); + int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, char *buffer, int buffer_size, int *cur_len, const char *format, ...) __attribute__((format (printf, 7, 8))); + +int kobject_uevent(struct kobject *kobj, + enum kobject_action action, + struct attribute *attr); +int kobject_uevent_atomic(struct kobject *kobj, + enum kobject_action action, + struct attribute *attr); + #else static inline void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { } static inline int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, char *buffer, int buffer_size, int *cur_len, const char *format, ...) { return 0; } +int kobject_uevent(struct kobject *kobj, + enum kobject_action action, + struct attribute *attr) +{ return 0; } +int kobject_uevent_atomic(struct kobject *kobj, + enum kobject_action action, + struct attribute *attr) +{ return 0; } #endif #endif /* __KERNEL__ */ diff --git a/include/linux/kobject_uevent.h b/include/linux/kobject_uevent.h deleted file mode 100644 index aa664fe..0000000 --- a/include/linux/kobject_uevent.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * kobject_uevent.h - list of kobject user events that can be generated - * - * Copyright (C) 2004 IBM Corp. - * Copyright (C) 2004 Greg Kroah-Hartman - * - * This file is released under the GPLv2. - * - */ - -#ifndef _KOBJECT_EVENT_H_ -#define _KOBJECT_EVENT_H_ - -#define HOTPLUG_PATH_LEN 256 - -/* path to the hotplug userspace helper executed on an event */ -extern char hotplug_path[]; - -/* - * If you add an action here, you must also add the proper string to the - * lib/kobject_uevent.c file. - */ -typedef int __bitwise kobject_action_t; -enum kobject_action { - KOBJ_ADD = (__force kobject_action_t) 0x01, /* add event, for hotplug */ - KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* remove event, for hotplug */ - KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* a sysfs attribute file has changed */ - KOBJ_MOUNT = (__force kobject_action_t) 0x04, /* mount event for block devices */ - KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices */ - KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* offline event for hotplug devices */ - KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* online event for hotplug devices */ -}; - - -#ifdef CONFIG_KOBJECT_UEVENT -int kobject_uevent(struct kobject *kobj, - enum kobject_action action, - struct attribute *attr); -int kobject_uevent_atomic(struct kobject *kobj, - enum kobject_action action, - struct attribute *attr); -#else -static inline int kobject_uevent(struct kobject *kobj, - enum kobject_action action, - struct attribute *attr) -{ - return 0; -} -static inline int kobject_uevent_atomic(struct kobject *kobj, - enum kobject_action action, - struct attribute *attr) -{ - return 0; -} -#endif - -#endif diff --git a/init/Kconfig b/init/Kconfig index 9fc0759f..0de8b77 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -205,25 +205,6 @@ config HOTPLUG modules require HOTPLUG functionality, but a module built outside the kernel tree does. Such modules require Y here. -config KOBJECT_UEVENT - bool "Kernel Userspace Events" if EMBEDDED - depends on NET - default y - help - This option enables the kernel userspace event layer, which is a - simple mechanism for kernel-to-user communication over a netlink - socket. - The goal of the kernel userspace events layer is to provide a simple - and efficient events system, that notifies userspace about kobject - state changes. This will enable applications to just listen for - events instead of polling system devices and files. - Hotplug events (kobject addition and removal) are also available on - the netlink socket in addition to the execution of /sbin/hotplug if - CONFIG_HOTPLUG is enabled. - - Say Y, unless you are building a system requiring minimal memory - consumption. - config IKCONFIG bool "Kernel .config support" ---help--- diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b53115b..6a51e25 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -83,9 +84,6 @@ static int ngroups_max = NGROUPS_MAX; #ifdef CONFIG_KMOD extern char modprobe_path[]; #endif -#ifdef CONFIG_HOTPLUG -extern char hotplug_path[]; -#endif #ifdef CONFIG_CHR_DEV_SG extern int sg_big_buff; #endif diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 3ab3754..1f90eea 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -19,14 +19,17 @@ #include #include #include -#include #include #include #define BUFFER_SIZE 1024 /* buffer for the hotplug env */ #define NUM_ENVP 32 /* number of env pointers */ -#if defined(CONFIG_KOBJECT_UEVENT) || defined(CONFIG_HOTPLUG) +#if defined(CONFIG_HOTPLUG) +char hotplug_path[HOTPLUG_PATH_LEN] = "/sbin/hotplug"; +u64 hotplug_seqnum; +static DEFINE_SPINLOCK(sequence_lock); + static char *action_to_string(enum kobject_action action) { switch (action) { @@ -48,9 +51,7 @@ static char *action_to_string(enum kobject_action action) return NULL; } } -#endif -#ifdef CONFIG_KOBJECT_UEVENT static struct sock *uevent_sock; /** @@ -168,21 +169,6 @@ static int __init kobject_uevent_init(void) postcore_initcall(kobject_uevent_init); -#else -static inline int send_uevent(const char *signal, const char *obj, - char **envp, int gfp_mask) -{ - return 0; -} - -#endif /* CONFIG_KOBJECT_UEVENT */ - - -#ifdef CONFIG_HOTPLUG -char hotplug_path[HOTPLUG_PATH_LEN] = "/sbin/hotplug"; -u64 hotplug_seqnum; -static DEFINE_SPINLOCK(sequence_lock); - /** * kobject_hotplug - notify userspace by executing /sbin/hotplug * -- cgit v1.1 From 0f76e5acf9dc788e664056dda1e461f0bec93948 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 11 Nov 2005 04:58:04 +0100 Subject: [PATCH] add uevent_helper control in /sys/kernel/ This deprecates the /proc/sys/kernel/hotplug file, as all this stuff should be in /sys some day, right? :) In /sys/kernel/ we have now uevent_seqnum and uevent_helper. The seqnum is no longer used by udev, as the version for this kernel depends on netlink which events will never get out-of-order. Recent udev versions disable the /sbin/hotplug helper with an init script, cause it leads to OOM on big boxes by running hundreds of shells in parallel. It should be done now by: echo "" > /sys/kernel/uevent_helper (Note that "-n" does not work, cause neighter proc nor sysfs support truncate().) Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- kernel/ksysfs.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 015fb69..e975a76 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -23,11 +23,29 @@ static struct subsys_attribute _name##_attr = \ __ATTR(_name, 0644, _name##_show, _name##_store) #ifdef CONFIG_HOTPLUG -static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page) +/* current uevent sequence number */ +static ssize_t uevent_seqnum_show(struct subsystem *subsys, char *page) { return sprintf(page, "%llu\n", (unsigned long long)hotplug_seqnum); } -KERNEL_ATTR_RO(hotplug_seqnum); +KERNEL_ATTR_RO(uevent_seqnum); + +/* uevent helper program, used during early boo */ +static ssize_t uevent_helper_show(struct subsystem *subsys, char *page) +{ + return sprintf(page, "%s\n", hotplug_path); +} +static ssize_t uevent_helper_store(struct subsystem *subsys, const char *page, size_t count) +{ + if (count+1 > HOTPLUG_PATH_LEN) + return -ENOENT; + memcpy(hotplug_path, page, count); + hotplug_path[count] = '\0'; + if (count && hotplug_path[count-1] == '\n') + hotplug_path[count-1] = '\0'; + return count; +} +KERNEL_ATTR_RW(uevent_helper); #endif #ifdef CONFIG_KEXEC @@ -45,7 +63,8 @@ EXPORT_SYMBOL_GPL(kernel_subsys); static struct attribute * kernel_attrs[] = { #ifdef CONFIG_HOTPLUG - &hotplug_seqnum_attr.attr, + &uevent_seqnum_attr.attr, + &uevent_helper_attr.attr, #endif #ifdef CONFIG_KEXEC &crash_notes_attr.attr, -- cgit v1.1 From 033b96fd30db52a710d97b06f87d16fc59fee0f1 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 11 Nov 2005 06:09:55 +0100 Subject: [PATCH] remove mount/umount uevents from superblock handling The names of these events have been confusing from the beginning on, as they have been more like claim/release events. We needed these events for noticing HAL if storage devices have been mounted. Thanks to Al, we have the proper solution now and can poll() /proc/mounts instead to get notfied about mount tree changes. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- fs/super.c | 15 +-------------- include/linux/kobject.h | 6 ++---- lib/kobject_uevent.c | 4 ---- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/fs/super.c b/fs/super.c index 6689dde..5a347a4f 100644 --- a/fs/super.c +++ b/fs/super.c @@ -665,16 +665,6 @@ static int test_bdev_super(struct super_block *s, void *data) return (void *)s->s_bdev == data; } -static void bdev_uevent(struct block_device *bdev, enum kobject_action action) -{ - if (bdev->bd_disk) { - if (bdev->bd_part) - kobject_uevent(&bdev->bd_part->kobj, action, NULL); - else - kobject_uevent(&bdev->bd_disk->kobj, action, NULL); - } -} - struct super_block *get_sb_bdev(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, int (*fill_super)(struct super_block *, void *, int)) @@ -717,10 +707,8 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type, up_write(&s->s_umount); deactivate_super(s); s = ERR_PTR(error); - } else { + } else s->s_flags |= MS_ACTIVE; - bdev_uevent(bdev, KOBJ_MOUNT); - } } return s; @@ -736,7 +724,6 @@ void kill_block_super(struct super_block *sb) { struct block_device *bdev = sb->s_bdev; - bdev_uevent(bdev, KOBJ_UMOUNT); generic_shutdown_super(sb); sync_blockdev(bdev); close_bdev_excl(bdev); diff --git a/include/linux/kobject.h b/include/linux/kobject.h index baf5251..e6926b3 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -42,10 +42,8 @@ enum kobject_action { KOBJ_ADD = (__force kobject_action_t) 0x01, /* add event, for hotplug */ KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* remove event, for hotplug */ KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* a sysfs attribute file has changed */ - KOBJ_MOUNT = (__force kobject_action_t) 0x04, /* mount event for block devices */ - KOBJ_UMOUNT = (__force kobject_action_t) 0x05, /* umount event for block devices */ - KOBJ_OFFLINE = (__force kobject_action_t) 0x06, /* offline event for hotplug devices */ - KOBJ_ONLINE = (__force kobject_action_t) 0x07, /* online event for hotplug devices */ + KOBJ_OFFLINE = (__force kobject_action_t) 0x04, /* offline event for hotplug devices */ + KOBJ_ONLINE = (__force kobject_action_t) 0x05, /* online event for hotplug devices */ }; struct kobject { diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 1f90eea..845bf67 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -39,10 +39,6 @@ static char *action_to_string(enum kobject_action action) return "remove"; case KOBJ_CHANGE: return "change"; - case KOBJ_MOUNT: - return "mount"; - case KOBJ_UMOUNT: - return "umount"; case KOBJ_OFFLINE: return "offline"; case KOBJ_ONLINE: -- cgit v1.1 From 5f123fbd80f4f788554636f02bf73e40f914e0d6 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 11 Nov 2005 14:43:07 +0100 Subject: [PATCH] merge kobject_uevent and kobject_hotplug The distinction between hotplug and uevent does not make sense these days, netlink events are the default. udev depends entirely on netlink uevents. Only during early boot and in initramfs, /sbin/hotplug is needed. So merge the two functions and provide only one interface without all the options. The netlink layer got a nice generic interface with named slots recently, which is probably a better facility to plug events for subsystem specific events. Also the new poll() interface to /proc/mounts is a nicer way to notify about changes than sending events through the core. The uevents should only be used for driver core related requests to userspace now. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ipr.c | 2 +- include/linux/kobject.h | 27 ++--- lib/kobject_uevent.c | 279 +++++++++++++++++------------------------------- 3 files changed, 102 insertions(+), 206 deletions(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index fa2cb358..bf44a40 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -2132,7 +2132,7 @@ restart: } spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); - kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE, NULL); + kobject_hotplug(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE); LEAVE; } diff --git a/include/linux/kobject.h b/include/linux/kobject.h index e6926b3..5b08248 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -39,11 +39,11 @@ extern u64 hotplug_seqnum; /* the actions here must match the proper string in lib/kobject_uevent.c */ typedef int __bitwise kobject_action_t; enum kobject_action { - KOBJ_ADD = (__force kobject_action_t) 0x01, /* add event, for hotplug */ - KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* remove event, for hotplug */ - KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* a sysfs attribute file has changed */ - KOBJ_OFFLINE = (__force kobject_action_t) 0x04, /* offline event for hotplug devices */ - KOBJ_ONLINE = (__force kobject_action_t) 0x05, /* online event for hotplug devices */ + KOBJ_ADD = (__force kobject_action_t) 0x01, /* exclusive to core */ + KOBJ_REMOVE = (__force kobject_action_t) 0x02, /* exclusive to core */ + KOBJ_CHANGE = (__force kobject_action_t) 0x03, /* device state change */ + KOBJ_OFFLINE = (__force kobject_action_t) 0x04, /* device offline */ + KOBJ_ONLINE = (__force kobject_action_t) 0x05, /* device online */ }; struct kobject { @@ -262,28 +262,13 @@ int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, char *buffer, int buffer_size, int *cur_len, const char *format, ...) __attribute__((format (printf, 7, 8))); - -int kobject_uevent(struct kobject *kobj, - enum kobject_action action, - struct attribute *attr); -int kobject_uevent_atomic(struct kobject *kobj, - enum kobject_action action, - struct attribute *attr); - #else static inline void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { } + static inline int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, char *buffer, int buffer_size, int *cur_len, const char *format, ...) { return 0; } -int kobject_uevent(struct kobject *kobj, - enum kobject_action action, - struct attribute *attr) -{ return 0; } -int kobject_uevent_atomic(struct kobject *kobj, - enum kobject_action action, - struct attribute *attr) -{ return 0; } #endif #endif /* __KERNEL__ */ diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 845bf67..dd061da 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -29,6 +29,7 @@ char hotplug_path[HOTPLUG_PATH_LEN] = "/sbin/hotplug"; u64 hotplug_seqnum; static DEFINE_SPINLOCK(sequence_lock); +static struct sock *uevent_sock; static char *action_to_string(enum kobject_action action) { @@ -48,123 +49,6 @@ static char *action_to_string(enum kobject_action action) } } -static struct sock *uevent_sock; - -/** - * send_uevent - notify userspace by sending event through netlink socket - * - * @signal: signal name - * @obj: object path (kobject) - * @envp: possible hotplug environment to pass with the message - * @gfp_mask: - */ -static int send_uevent(const char *signal, const char *obj, - char **envp, gfp_t gfp_mask) -{ - struct sk_buff *skb; - char *pos; - int len; - - if (!uevent_sock) - return -EIO; - - len = strlen(signal) + 1; - len += strlen(obj) + 1; - - /* allocate buffer with the maximum possible message size */ - skb = alloc_skb(len + BUFFER_SIZE, gfp_mask); - if (!skb) - return -ENOMEM; - - pos = skb_put(skb, len); - sprintf(pos, "%s@%s", signal, obj); - - /* copy the environment key by key to our continuous buffer */ - if (envp) { - int i; - - for (i = 2; envp[i]; i++) { - len = strlen(envp[i]) + 1; - pos = skb_put(skb, len); - strcpy(pos, envp[i]); - } - } - - NETLINK_CB(skb).dst_group = 1; - return netlink_broadcast(uevent_sock, skb, 0, 1, gfp_mask); -} - -static int do_kobject_uevent(struct kobject *kobj, enum kobject_action action, - struct attribute *attr, gfp_t gfp_mask) -{ - char *path; - char *attrpath; - char *signal; - int len; - int rc = -ENOMEM; - - path = kobject_get_path(kobj, gfp_mask); - if (!path) - return -ENOMEM; - - signal = action_to_string(action); - if (!signal) - return -EINVAL; - - if (attr) { - len = strlen(path); - len += strlen(attr->name) + 2; - attrpath = kmalloc(len, gfp_mask); - if (!attrpath) - goto exit; - sprintf(attrpath, "%s/%s", path, attr->name); - rc = send_uevent(signal, attrpath, NULL, gfp_mask); - kfree(attrpath); - } else - rc = send_uevent(signal, path, NULL, gfp_mask); - -exit: - kfree(path); - return rc; -} - -/** - * kobject_uevent - notify userspace by sending event through netlink socket - * - * @signal: signal name - * @kobj: struct kobject that the event is happening to - * @attr: optional struct attribute the event belongs to - */ -int kobject_uevent(struct kobject *kobj, enum kobject_action action, - struct attribute *attr) -{ - return do_kobject_uevent(kobj, action, attr, GFP_KERNEL); -} -EXPORT_SYMBOL_GPL(kobject_uevent); - -int kobject_uevent_atomic(struct kobject *kobj, enum kobject_action action, - struct attribute *attr) -{ - return do_kobject_uevent(kobj, action, attr, GFP_ATOMIC); -} -EXPORT_SYMBOL_GPL(kobject_uevent_atomic); - -static int __init kobject_uevent_init(void) -{ - uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL, - THIS_MODULE); - - if (!uevent_sock) { - printk(KERN_ERR - "kobject_uevent: unable to create netlink socket!\n"); - return -ENODEV; - } - - return 0; -} - -postcore_initcall(kobject_uevent_init); - /** * kobject_hotplug - notify userspace by executing /sbin/hotplug * @@ -173,95 +57,84 @@ postcore_initcall(kobject_uevent_init); */ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { - char *argv [3]; - char **envp = NULL; - char *buffer = NULL; - char *seq_buff; + char **envp; + char *buffer; char *scratch; + const char *action_string; + const char *devpath = NULL; + const char *subsystem; + struct kobject *top_kobj; + struct kset *kset; + struct kset_hotplug_ops *hotplug_ops; + u64 seq; + char *seq_buff; int i = 0; int retval; - char *kobj_path = NULL; - const char *name = NULL; - char *action_string; - u64 seq; - struct kobject *top_kobj = kobj; - struct kset *kset; - static struct kset_hotplug_ops null_hotplug_ops; - struct kset_hotplug_ops *hotplug_ops = &null_hotplug_ops; - /* If this kobj does not belong to a kset, - try to find a parent that does. */ + pr_debug("%s\n", __FUNCTION__); + + action_string = action_to_string(action); + if (!action_string) + return; + + /* search the kset we belong to */ + top_kobj = kobj; if (!top_kobj->kset && top_kobj->parent) { do { top_kobj = top_kobj->parent; } while (!top_kobj->kset && top_kobj->parent); } - - if (top_kobj->kset) - kset = top_kobj->kset; - else + if (!top_kobj->kset) return; - if (kset->hotplug_ops) - hotplug_ops = kset->hotplug_ops; + kset = top_kobj->kset; + hotplug_ops = kset->hotplug_ops; - /* If the kset has a filter operation, call it. - Skip the event, if the filter returns zero. */ - if (hotplug_ops->filter) { + /* skip the event, if the filter returns zero. */ + if (hotplug_ops && hotplug_ops->filter) if (!hotplug_ops->filter(kset, kobj)) return; - } - - pr_debug ("%s\n", __FUNCTION__); - - action_string = action_to_string(action); - if (!action_string) - return; - envp = kmalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); + /* environment index */ + envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); if (!envp) return; - memset (envp, 0x00, NUM_ENVP * sizeof (char *)); + /* environment values */ buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL); if (!buffer) goto exit; - if (hotplug_ops->name) - name = hotplug_ops->name(kset, kobj); - if (name == NULL) - name = kobject_name(&kset->kobj); + /* complete object path */ + devpath = kobject_get_path(kobj, GFP_KERNEL); + if (!devpath) + goto exit; - argv [0] = hotplug_path; - argv [1] = (char *)name; /* won't be changed but 'const' has to go */ - argv [2] = NULL; + /* originating subsystem */ + if (hotplug_ops && hotplug_ops->name) + subsystem = hotplug_ops->name(kset, kobj); + else + subsystem = kobject_name(&kset->kobj); - /* minimal command environment */ - envp [i++] = "HOME=/"; - envp [i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; + /* event environemnt for helper process only */ + envp[i++] = "HOME=/"; + envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; + /* default keys */ scratch = buffer; - envp [i++] = scratch; scratch += sprintf(scratch, "ACTION=%s", action_string) + 1; - - kobj_path = kobject_get_path(kobj, GFP_KERNEL); - if (!kobj_path) - goto exit; - envp [i++] = scratch; - scratch += sprintf (scratch, "DEVPATH=%s", kobj_path) + 1; - + scratch += sprintf (scratch, "DEVPATH=%s", devpath) + 1; envp [i++] = scratch; - scratch += sprintf(scratch, "SUBSYSTEM=%s", name) + 1; + scratch += sprintf(scratch, "SUBSYSTEM=%s", subsystem) + 1; - /* reserve space for the sequence, - * put the real one in after the hotplug call */ + /* just reserve the space, overwrite it after kset call has returned */ envp[i++] = seq_buff = scratch; scratch += strlen("SEQNUM=18446744073709551616") + 1; - if (hotplug_ops->hotplug) { - /* have the kset specific function add its stuff */ + /* let the kset specific function add its stuff */ + if (hotplug_ops && hotplug_ops->hotplug) { retval = hotplug_ops->hotplug (kset, kobj, &envp[i], NUM_ENVP - i, scratch, BUFFER_SIZE - (scratch - buffer)); @@ -272,27 +145,49 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) } } + /* we will send an event, request a new sequence number */ spin_lock(&sequence_lock); seq = ++hotplug_seqnum; spin_unlock(&sequence_lock); sprintf(seq_buff, "SEQNUM=%llu", (unsigned long long)seq); - pr_debug ("%s: %s %s seq=%llu %s %s %s %s %s\n", - __FUNCTION__, argv[0], argv[1], (unsigned long long)seq, - envp[0], envp[1], envp[2], envp[3], envp[4]); - - send_uevent(action_string, kobj_path, envp, GFP_KERNEL); + /* send netlink message */ + if (uevent_sock) { + struct sk_buff *skb; + size_t len; + + /* allocate message with the maximum possible size */ + len = strlen(action_string) + strlen(devpath) + 2; + skb = alloc_skb(len + BUFFER_SIZE, GFP_KERNEL); + if (skb) { + /* add header */ + scratch = skb_put(skb, len); + sprintf(scratch, "%s@%s", action_string, devpath); + + /* copy keys to our continuous event payload buffer */ + for (i = 2; envp[i]; i++) { + len = strlen(envp[i]) + 1; + scratch = skb_put(skb, len); + strcpy(scratch, envp[i]); + } + + NETLINK_CB(skb).dst_group = 1; + netlink_broadcast(uevent_sock, skb, 0, 1, GFP_KERNEL); + } + } - if (!hotplug_path[0]) - goto exit; + /* call uevent_helper, usually only enabled during early boot */ + if (hotplug_path[0]) { + char *argv [3]; - retval = call_usermodehelper (argv[0], argv, envp, 0); - if (retval) - pr_debug ("%s - call_usermodehelper returned %d\n", - __FUNCTION__, retval); + argv [0] = hotplug_path; + argv [1] = (char *)subsystem; + argv [2] = NULL; + call_usermodehelper (argv[0], argv, envp, 0); + } exit: - kfree(kobj_path); + kfree(devpath); kfree(buffer); kfree(envp); return; @@ -350,4 +245,20 @@ int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, } EXPORT_SYMBOL(add_hotplug_env_var); +static int __init kobject_uevent_init(void) +{ + uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL, + THIS_MODULE); + + if (!uevent_sock) { + printk(KERN_ERR + "kobject_uevent: unable to create netlink socket!\n"); + return -ENODEV; + } + + return 0; +} + +postcore_initcall(kobject_uevent_init); + #endif /* CONFIG_HOTPLUG */ -- cgit v1.1 From 312c004d36ce6c739512bac83b452f4c20ab1f62 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 16 Nov 2005 09:00:00 +0100 Subject: [PATCH] driver core: replace "hotplug" by "uevent" Leave the overloaded "hotplug" word to susbsystems which are handling real devices. The driver core does not "plug" anything, it just exports the state to userspace and generates events. Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- Documentation/powerpc/eeh-pci-error-recovery.txt | 31 ++++----- arch/powerpc/kernel/vio.c | 2 +- block/genhd.c | 48 ++++++------- drivers/acpi/container.c | 8 +-- drivers/acpi/processor_core.c | 8 +-- drivers/acpi/scan.c | 14 ++-- drivers/base/Kconfig | 4 +- drivers/base/class.c | 66 +++++++++--------- drivers/base/core.c | 42 ++++++------ drivers/base/cpu.c | 4 +- drivers/base/firmware_class.c | 45 ++++++------- drivers/base/memory.c | 12 ++-- drivers/ieee1394/nodemgr.c | 20 +++--- drivers/infiniband/core/sysfs.c | 16 ++--- drivers/input/input.c | 14 ++-- drivers/input/serio/serio.c | 22 +++--- drivers/macintosh/macio_asic.c | 4 +- drivers/mmc/mmc_sysfs.c | 4 +- drivers/pci/hotplug.c | 44 ++++++------ drivers/pci/pci-driver.c | 6 +- drivers/pci/pci.h | 4 +- drivers/pcmcia/cs.c | 10 +-- drivers/pcmcia/ds.c | 50 +++++++------- drivers/scsi/ipr.c | 2 +- drivers/usb/core/usb.c | 86 +++++++++++------------- drivers/usb/host/hc_crisv10.c | 2 +- drivers/w1/w1.c | 14 ++-- fs/partitions/check.c | 6 +- include/linux/device.h | 14 ++-- include/linux/firmware.h | 2 +- include/linux/kobject.h | 40 ++++++----- include/linux/sysctl.h | 2 +- include/linux/usb.h | 2 +- kernel/ksysfs.c | 14 ++-- kernel/sysctl.c | 4 +- lib/kobject.c | 4 +- lib/kobject_uevent.c | 64 +++++++++--------- net/bluetooth/hci_sysfs.c | 4 +- net/bridge/br_sysfs_if.c | 4 +- net/core/net-sysfs.c | 8 +-- 40 files changed, 372 insertions(+), 378 deletions(-) diff --git a/Documentation/powerpc/eeh-pci-error-recovery.txt b/Documentation/powerpc/eeh-pci-error-recovery.txt index e75d747..67a11a3 100644 --- a/Documentation/powerpc/eeh-pci-error-recovery.txt +++ b/Documentation/powerpc/eeh-pci-error-recovery.txt @@ -115,7 +115,7 @@ Current PPC64 Linux EEH Implementation At this time, a generic EEH recovery mechanism has been implemented, so that individual device drivers do not need to be modified to support EEH recovery. This generic mechanism piggy-backs on the PCI hotplug -infrastructure, and percolates events up through the hotplug/udev +infrastructure, and percolates events up through the userspace/udev infrastructure. Followiing is a detailed description of how this is accomplished. @@ -172,7 +172,7 @@ A handler for the EEH notifier_block events is implemented in drivers/pci/hotplug/pSeries_pci.c, called handle_eeh_events(). It saves the device BAR's and then calls rpaphp_unconfig_pci_adapter(). This last call causes the device driver for the card to be stopped, -which causes hotplug events to go out to user space. This triggers +which causes uevents to go out to user space. This triggers user-space scripts that might issue commands such as "ifdown eth0" for ethernet cards, and so on. This handler then sleeps for 5 seconds, hoping to give the user-space scripts enough time to complete. @@ -258,29 +258,30 @@ rpa_php_unconfig_pci_adapter() { // in rpaphp_pci.c calls pci_destroy_dev (struct pci_dev *) { calls - device_unregister (&dev->dev) { // in /drivers/base/core.c + device_unregister (&dev->dev) { // in /drivers/base/core.c calls - device_del(struct device * dev) { // in /drivers/base/core.c + device_del(struct device * dev) { // in /drivers/base/core.c calls - kobject_del() { //in /libs/kobject.c + kobject_del() { //in /libs/kobject.c calls - kobject_hotplug() { // in /libs/kobject.c + kobject_uevent() { // in /libs/kobject.c calls - kset_hotplug() { // in /lib/kobject.c + kset_uevent() { // in /lib/kobject.c calls - kset->hotplug_ops->hotplug() which is really just + kset->uevent_ops->uevent() // which is really just a call to - dev_hotplug() { // in /drivers/base/core.c + dev_uevent() { // in /drivers/base/core.c calls - dev->bus->hotplug() which is really just a call to - pci_hotplug () { // in drivers/pci/hotplug.c + dev->bus->uevent() which is really just a call to + pci_uevent () { // in drivers/pci/hotplug.c which prints device name, etc.... } } - then kset_hotplug() calls - call_usermodehelper () with - argv[0]=hotplug_path[] which is "/sbin/hotplug" - --> event to userspace, + then kobject_uevent() sends a netlink uevent to userspace + --> userspace uevent + (during early boot, nobody listens to netlink events and + kobject_uevent() executes uevent_helper[], which runs the + event process /sbin/hotplug) } } kobject_del() then calls sysfs_remove_dir(), which would diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c index 71a6add..13c4149 100644 --- a/arch/powerpc/kernel/vio.c +++ b/arch/powerpc/kernel/vio.c @@ -293,6 +293,6 @@ static int vio_hotplug(struct device *dev, char **envp, int num_envp, struct bus_type vio_bus_type = { .name = "vio", - .hotplug = vio_hotplug, + .uevent = vio_hotplug, .match = vio_bus_match, }; diff --git a/block/genhd.c b/block/genhd.c index f04609d..f1ed83f 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -358,7 +358,7 @@ static struct sysfs_ops disk_sysfs_ops = { static ssize_t disk_uevent_store(struct gendisk * disk, const char *buf, size_t count) { - kobject_hotplug(&disk->kobj, KOBJ_ADD); + kobject_uevent(&disk->kobj, KOBJ_ADD); return count; } static ssize_t disk_dev_read(struct gendisk * disk, char *page) @@ -455,14 +455,14 @@ static struct kobj_type ktype_block = { extern struct kobj_type ktype_part; -static int block_hotplug_filter(struct kset *kset, struct kobject *kobj) +static int block_uevent_filter(struct kset *kset, struct kobject *kobj) { struct kobj_type *ktype = get_ktype(kobj); return ((ktype == &ktype_block) || (ktype == &ktype_part)); } -static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp, +static int block_uevent(struct kset *kset, struct kobject *kobj, char **envp, int num_envp, char *buffer, int buffer_size) { struct kobj_type *ktype = get_ktype(kobj); @@ -474,40 +474,40 @@ static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp, if (ktype == &ktype_block) { disk = container_of(kobj, struct gendisk, kobj); - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, - &length, "MINOR=%u", disk->first_minor); + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, + &length, "MINOR=%u", disk->first_minor); } else if (ktype == &ktype_part) { disk = container_of(kobj->parent, struct gendisk, kobj); part = container_of(kobj, struct hd_struct, kobj); - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, - &length, "MINOR=%u", - disk->first_minor + part->partno); + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, + &length, "MINOR=%u", + disk->first_minor + part->partno); } else return 0; - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length, - "MAJOR=%u", disk->major); + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, + "MAJOR=%u", disk->major); /* add physical device, backing this device */ physdev = disk->driverfs_dev; if (physdev) { char *path = kobject_get_path(&physdev->kobj, GFP_KERNEL); - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, - &length, "PHYSDEVPATH=%s", path); + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, + &length, "PHYSDEVPATH=%s", path); kfree(path); if (physdev->bus) - add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PHYSDEVBUS=%s", - physdev->bus->name); + add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PHYSDEVBUS=%s", + physdev->bus->name); if (physdev->driver) - add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PHYSDEVDRIVER=%s", - physdev->driver->name); + add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PHYSDEVDRIVER=%s", + physdev->driver->name); } /* terminate, set to next free slot, shrink available space */ @@ -520,13 +520,13 @@ static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp, return 0; } -static struct kset_hotplug_ops block_hotplug_ops = { - .filter = block_hotplug_filter, - .hotplug = block_hotplug, +static struct kset_uevent_ops block_uevent_ops = { + .filter = block_uevent_filter, + .uevent = block_uevent, }; /* declare block_subsys. */ -static decl_subsys(block, &ktype_block, &block_hotplug_ops); +static decl_subsys(block, &ktype_block, &block_uevent_ops); /* diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c index 27ec12c..b69a8ca 100644 --- a/drivers/acpi/container.c +++ b/drivers/acpi/container.c @@ -172,21 +172,21 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context) if (ACPI_FAILURE(status) || !device) { result = container_device_add(&device, handle); if (!result) - kobject_hotplug(&device->kobj, - KOBJ_ONLINE); + kobject_uevent(&device->kobj, + KOBJ_ONLINE); else printk("Failed to add container\n"); } } else { if (ACPI_SUCCESS(status)) { /* device exist and this is a remove request */ - kobject_hotplug(&device->kobj, KOBJ_OFFLINE); + kobject_uevent(&device->kobj, KOBJ_OFFLINE); } } break; case ACPI_NOTIFY_EJECT_REQUEST: if (!acpi_bus_get_device(handle, &device) && device) { - kobject_hotplug(&device->kobj, KOBJ_OFFLINE); + kobject_uevent(&device->kobj, KOBJ_OFFLINE); } break; default: diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 0c561c5..1278aca 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -748,7 +748,7 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device) return_VALUE(-ENODEV); if ((pr->id >= 0) && (pr->id < NR_CPUS)) { - kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE); + kobject_uevent(&(*device)->kobj, KOBJ_ONLINE); } return_VALUE(0); } @@ -788,13 +788,13 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) } if (pr->id >= 0 && (pr->id < NR_CPUS)) { - kobject_hotplug(&device->kobj, KOBJ_OFFLINE); + kobject_uevent(&device->kobj, KOBJ_OFFLINE); break; } result = acpi_processor_start(device); if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { - kobject_hotplug(&device->kobj, KOBJ_ONLINE); + kobject_uevent(&device->kobj, KOBJ_ONLINE); } else { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Device [%s] failed to start\n", @@ -818,7 +818,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) } if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) - kobject_hotplug(&device->kobj, KOBJ_OFFLINE); + kobject_uevent(&device->kobj, KOBJ_OFFLINE); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 31218e1..0745d20 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -78,7 +78,7 @@ static struct kobj_type ktype_acpi_ns = { .release = acpi_device_release, }; -static int namespace_hotplug(struct kset *kset, struct kobject *kobj, +static int namespace_uevent(struct kset *kset, struct kobject *kobj, char **envp, int num_envp, char *buffer, int buffer_size) { @@ -89,8 +89,8 @@ static int namespace_hotplug(struct kset *kset, struct kobject *kobj, if (!dev->driver) return 0; - if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, - "PHYSDEVDRIVER=%s", dev->driver->name)) + if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, + "PHYSDEVDRIVER=%s", dev->driver->name)) return -ENOMEM; envp[i] = NULL; @@ -98,8 +98,8 @@ static int namespace_hotplug(struct kset *kset, struct kobject *kobj, return 0; } -static struct kset_hotplug_ops namespace_hotplug_ops = { - .hotplug = &namespace_hotplug, +static struct kset_uevent_ops namespace_uevent_ops = { + .uevent = &namespace_uevent, }; static struct kset acpi_namespace_kset = { @@ -108,7 +108,7 @@ static struct kset acpi_namespace_kset = { }, .subsys = &acpi_subsys, .ktype = &ktype_acpi_ns, - .hotplug_ops = &namespace_hotplug_ops, + .uevent_ops = &namespace_uevent_ops, }; static void acpi_device_register(struct acpi_device *device, @@ -347,7 +347,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device) } /* -------------------------------------------------------------------------- - ACPI hotplug sysfs device file support + ACPI sysfs device file support -------------------------------------------------------------------------- */ static ssize_t acpi_eject_store(struct acpi_device *device, const char *buf, size_t count); diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 934149c..f0eff3d 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -19,11 +19,11 @@ config PREVENT_FIRMWARE_BUILD If unsure say Y here. config FW_LOADER - tristate "Hotplug firmware loading support" + tristate "Userspace firmware loading support" select HOTPLUG ---help--- This option is provided for the case where no in-kernel-tree modules - require hotplug firmware loading support, but a module built outside + require userspace firmware loading support, but a module built outside the kernel tree does. config DEBUG_DRIVER diff --git a/drivers/base/class.c b/drivers/base/class.c index db65fd0..df7fdab 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -178,7 +178,7 @@ static void class_device_create_release(struct class_device *class_dev) } /* needed to allow these devices to have parent class devices */ -static int class_device_create_hotplug(struct class_device *class_dev, +static int class_device_create_uevent(struct class_device *class_dev, char **envp, int num_envp, char *buffer, int buffer_size) { @@ -331,7 +331,7 @@ static struct kobj_type ktype_class_device = { .release = class_dev_release, }; -static int class_hotplug_filter(struct kset *kset, struct kobject *kobj) +static int class_uevent_filter(struct kset *kset, struct kobject *kobj) { struct kobj_type *ktype = get_ktype(kobj); @@ -343,14 +343,14 @@ static int class_hotplug_filter(struct kset *kset, struct kobject *kobj) return 0; } -static const char *class_hotplug_name(struct kset *kset, struct kobject *kobj) +static const char *class_uevent_name(struct kset *kset, struct kobject *kobj) { struct class_device *class_dev = to_class_dev(kobj); return class_dev->class->name; } -static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp, +static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp, int num_envp, char *buffer, int buffer_size) { struct class_device *class_dev = to_class_dev(kobj); @@ -365,29 +365,29 @@ static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp, struct device *dev = class_dev->dev; char *path = kobject_get_path(&dev->kobj, GFP_KERNEL); - add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, - &length, "PHYSDEVPATH=%s", path); + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, + &length, "PHYSDEVPATH=%s", path); kfree(path); if (dev->bus) - add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PHYSDEVBUS=%s", dev->bus->name); + add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PHYSDEVBUS=%s", dev->bus->name); if (dev->driver) - add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PHYSDEVDRIVER=%s", dev->driver->name); + add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PHYSDEVDRIVER=%s", dev->driver->name); } if (MAJOR(class_dev->devt)) { - add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "MAJOR=%u", MAJOR(class_dev->devt)); + add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MAJOR=%u", MAJOR(class_dev->devt)); - add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "MINOR=%u", MINOR(class_dev->devt)); + add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MINOR=%u", MINOR(class_dev->devt)); } /* terminate, set to next free slot, shrink available space */ @@ -397,30 +397,30 @@ static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp, buffer = &buffer[length]; buffer_size -= length; - if (class_dev->hotplug) { + if (class_dev->uevent) { /* have the class device specific function add its stuff */ - retval = class_dev->hotplug(class_dev, envp, num_envp, + retval = class_dev->uevent(class_dev, envp, num_envp, buffer, buffer_size); if (retval) - pr_debug("class_dev->hotplug() returned %d\n", retval); - } else if (class_dev->class->hotplug) { + pr_debug("class_dev->uevent() returned %d\n", retval); + } else if (class_dev->class->uevent) { /* have the class specific function add its stuff */ - retval = class_dev->class->hotplug(class_dev, envp, num_envp, + retval = class_dev->class->uevent(class_dev, envp, num_envp, buffer, buffer_size); if (retval) - pr_debug("class->hotplug() returned %d\n", retval); + pr_debug("class->uevent() returned %d\n", retval); } return retval; } -static struct kset_hotplug_ops class_hotplug_ops = { - .filter = class_hotplug_filter, - .name = class_hotplug_name, - .hotplug = class_hotplug, +static struct kset_uevent_ops class_uevent_ops = { + .filter = class_uevent_filter, + .name = class_uevent_name, + .uevent = class_uevent, }; -static decl_subsys(class_obj, &ktype_class_device, &class_hotplug_ops); +static decl_subsys(class_obj, &ktype_class_device, &class_uevent_ops); static int class_device_add_attrs(struct class_device * cd) @@ -464,7 +464,7 @@ static ssize_t show_dev(struct class_device *class_dev, char *buf) static ssize_t store_uevent(struct class_device *class_dev, const char *buf, size_t count) { - kobject_hotplug(&class_dev->kobj, KOBJ_ADD); + kobject_uevent(&class_dev->kobj, KOBJ_ADD); return count; } @@ -559,7 +559,7 @@ int class_device_add(struct class_device *class_dev) class_name); } - kobject_hotplug(&class_dev->kobj, KOBJ_ADD); + kobject_uevent(&class_dev->kobj, KOBJ_ADD); /* notify any interfaces this device is now here */ if (parent_class) { @@ -632,7 +632,7 @@ struct class_device *class_device_create(struct class *cls, class_dev->class = cls; class_dev->parent = parent; class_dev->release = class_device_create_release; - class_dev->hotplug = class_device_create_hotplug; + class_dev->uevent = class_device_create_uevent; va_start(args, fmt); vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args); @@ -674,7 +674,7 @@ void class_device_del(struct class_device *class_dev) class_device_remove_file(class_dev, class_dev->devt_attr); class_device_remove_attrs(class_dev); - kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE); + kobject_uevent(&class_dev->kobj, KOBJ_REMOVE); kobject_del(&class_dev->kobj); class_device_put(parent_device); diff --git a/drivers/base/core.c b/drivers/base/core.c index 8615b42..fd80599 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -90,7 +90,7 @@ static struct kobj_type ktype_device = { }; -static int dev_hotplug_filter(struct kset *kset, struct kobject *kobj) +static int dev_uevent_filter(struct kset *kset, struct kobject *kobj) { struct kobj_type *ktype = get_ktype(kobj); @@ -102,14 +102,14 @@ static int dev_hotplug_filter(struct kset *kset, struct kobject *kobj) return 0; } -static const char *dev_hotplug_name(struct kset *kset, struct kobject *kobj) +static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj) { struct device *dev = to_dev(kobj); return dev->bus->name; } -static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp, +static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp, int num_envp, char *buffer, int buffer_size) { struct device *dev = to_dev(kobj); @@ -119,15 +119,15 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp, /* add bus name of physical device */ if (dev->bus) - add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PHYSDEVBUS=%s", dev->bus->name); + add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PHYSDEVBUS=%s", dev->bus->name); /* add driver name of physical device */ if (dev->driver) - add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PHYSDEVDRIVER=%s", dev->driver->name); + add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PHYSDEVDRIVER=%s", dev->driver->name); /* terminate, set to next free slot, shrink available space */ envp[i] = NULL; @@ -136,11 +136,11 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp, buffer = &buffer[length]; buffer_size -= length; - if (dev->bus && dev->bus->hotplug) { + if (dev->bus && dev->bus->uevent) { /* have the bus specific function add its stuff */ - retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size); + retval = dev->bus->uevent(dev, envp, num_envp, buffer, buffer_size); if (retval) { - pr_debug ("%s - hotplug() returned %d\n", + pr_debug ("%s - uevent() returned %d\n", __FUNCTION__, retval); } } @@ -148,16 +148,16 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp, return retval; } -static struct kset_hotplug_ops device_hotplug_ops = { - .filter = dev_hotplug_filter, - .name = dev_hotplug_name, - .hotplug = dev_hotplug, +static struct kset_uevent_ops device_uevent_ops = { + .filter = dev_uevent_filter, + .name = dev_uevent_name, + .uevent = dev_uevent, }; static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - kobject_hotplug(&dev->kobj, KOBJ_ADD); + kobject_uevent(&dev->kobj, KOBJ_ADD); return count; } @@ -165,7 +165,7 @@ static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, * device_subsys - structure to be registered with kobject core. */ -decl_subsys(devices, &ktype_device, &device_hotplug_ops); +decl_subsys(devices, &ktype_device, &device_uevent_ops); /** @@ -274,7 +274,7 @@ int device_add(struct device *dev) dev->uevent_attr.store = store_uevent; device_create_file(dev, &dev->uevent_attr); - kobject_hotplug(&dev->kobj, KOBJ_ADD); + kobject_uevent(&dev->kobj, KOBJ_ADD); if ((error = device_pm_add(dev))) goto PMError; if ((error = bus_add_device(dev))) @@ -291,7 +291,7 @@ int device_add(struct device *dev) BusError: device_pm_remove(dev); PMError: - kobject_hotplug(&dev->kobj, KOBJ_REMOVE); + kobject_uevent(&dev->kobj, KOBJ_REMOVE); kobject_del(&dev->kobj); Error: if (parent) @@ -374,7 +374,7 @@ void device_del(struct device * dev) platform_notify_remove(dev); bus_remove_device(dev); device_pm_remove(dev); - kobject_hotplug(&dev->kobj, KOBJ_REMOVE); + kobject_uevent(&dev->kobj, KOBJ_REMOVE); kobject_del(&dev->kobj); if (parent) put_device(parent); diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index a958447..281d267 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -41,14 +41,14 @@ static ssize_t store_online(struct sys_device *dev, const char *buf, case '0': ret = cpu_down(cpu->sysdev.id); if (!ret) - kobject_hotplug(&dev->kobj, KOBJ_OFFLINE); + kobject_uevent(&dev->kobj, KOBJ_OFFLINE); break; case '1': ret = smp_prepare_cpu(cpu->sysdev.id); if (!ret) ret = cpu_up(cpu->sysdev.id); if (!ret) - kobject_hotplug(&dev->kobj, KOBJ_ONLINE); + kobject_uevent(&dev->kobj, KOBJ_ONLINE); break; default: ret = -EINVAL; diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 59dacb6..5b3d5e9 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -85,17 +85,17 @@ firmware_timeout_store(struct class *class, const char *buf, size_t count) static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); static void fw_class_dev_release(struct class_device *class_dev); -int firmware_class_hotplug(struct class_device *dev, char **envp, +int firmware_class_uevent(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size); static struct class firmware_class = { .name = "firmware", - .hotplug = firmware_class_hotplug, + .uevent = firmware_class_uevent, .release = fw_class_dev_release, }; int -firmware_class_hotplug(struct class_device *class_dev, char **envp, +firmware_class_uevent(struct class_device *class_dev, char **envp, int num_envp, char *buffer, int buffer_size) { struct firmware_priv *fw_priv = class_get_devdata(class_dev); @@ -104,13 +104,12 @@ firmware_class_hotplug(struct class_device *class_dev, char **envp, if (!test_bit(FW_STATUS_READY, &fw_priv->status)) return -ENODEV; - if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, - "FIRMWARE=%s", fw_priv->fw_id)) + if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, + "FIRMWARE=%s", fw_priv->fw_id)) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, - "TIMEOUT=%i", loading_timeout)) + if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len, + "TIMEOUT=%i", loading_timeout)) return -ENOMEM; - envp[i] = NULL; return 0; @@ -352,7 +351,7 @@ error_kfree: static int fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, - const char *fw_name, struct device *device, int hotplug) + const char *fw_name, struct device *device, int uevent) { struct class_device *class_dev; struct firmware_priv *fw_priv; @@ -384,7 +383,7 @@ fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, goto error_unreg; } - if (hotplug) + if (uevent) set_bit(FW_STATUS_READY, &fw_priv->status); else set_bit(FW_STATUS_READY_NOHOTPLUG, &fw_priv->status); @@ -399,7 +398,7 @@ out: static int _request_firmware(const struct firmware **firmware_p, const char *name, - struct device *device, int hotplug) + struct device *device, int uevent) { struct class_device *class_dev; struct firmware_priv *fw_priv; @@ -418,19 +417,19 @@ _request_firmware(const struct firmware **firmware_p, const char *name, } retval = fw_setup_class_device(firmware, &class_dev, name, device, - hotplug); + uevent); if (retval) goto error_kfree_fw; fw_priv = class_get_devdata(class_dev); - if (hotplug) { + if (uevent) { if (loading_timeout > 0) { fw_priv->timeout.expires = jiffies + loading_timeout * HZ; add_timer(&fw_priv->timeout); } - kobject_hotplug(&class_dev->kobj, KOBJ_ADD); + kobject_uevent(&class_dev->kobj, KOBJ_ADD); wait_for_completion(&fw_priv->completion); set_bit(FW_STATUS_DONE, &fw_priv->status); del_timer_sync(&fw_priv->timeout); @@ -456,7 +455,7 @@ out: } /** - * request_firmware: - request firmware to hotplug and wait for it + * request_firmware: - send firmware request and wait for it * @firmware_p: pointer to firmware image * @name: name of firmware file * @device: device for which firmware is being loaded @@ -466,7 +465,7 @@ out: * * Should be called from user context where sleeping is allowed. * - * @name will be used as $FIRMWARE in the hotplug environment and + * @name will be used as $FIRMWARE in the uevent environment and * should be distinctive enough not to be confused with any other * firmware image for this or any other device. **/ @@ -474,8 +473,8 @@ int request_firmware(const struct firmware **firmware_p, const char *name, struct device *device) { - int hotplug = 1; - return _request_firmware(firmware_p, name, device, hotplug); + int uevent = 1; + return _request_firmware(firmware_p, name, device, uevent); } /** @@ -518,7 +517,7 @@ struct firmware_work { struct device *device; void *context; void (*cont)(const struct firmware *fw, void *context); - int hotplug; + int uevent; }; static int @@ -533,7 +532,7 @@ request_firmware_work_func(void *arg) } daemonize("%s/%s", "firmware", fw_work->name); ret = _request_firmware(&fw, fw_work->name, fw_work->device, - fw_work->hotplug); + fw_work->uevent); if (ret < 0) fw_work->cont(NULL, fw_work->context); else { @@ -548,7 +547,7 @@ request_firmware_work_func(void *arg) /** * request_firmware_nowait: asynchronous version of request_firmware * @module: module requesting the firmware - * @hotplug: invokes hotplug event to copy the firmware image if this flag + * @uevent: sends uevent to copy the firmware image if this flag * is non-zero else the firmware copy must be done manually. * @name: name of firmware file * @device: device for which firmware is being loaded @@ -562,7 +561,7 @@ request_firmware_work_func(void *arg) **/ int request_firmware_nowait( - struct module *module, int hotplug, + struct module *module, int uevent, const char *name, struct device *device, void *context, void (*cont)(const struct firmware *fw, void *context)) { @@ -583,7 +582,7 @@ request_firmware_nowait( .device = device, .context = context, .cont = cont, - .hotplug = hotplug, + .uevent = uevent, }; ret = kernel_thread(request_firmware_work_func, fw_work, diff --git a/drivers/base/memory.c b/drivers/base/memory.c index bc3ca6a..7e1d077 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -29,12 +29,12 @@ static struct sysdev_class memory_sysdev_class = { set_kset_name(MEMORY_CLASS_NAME), }; -static char *memory_hotplug_name(struct kset *kset, struct kobject *kobj) +static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj) { return MEMORY_CLASS_NAME; } -static int memory_hotplug(struct kset *kset, struct kobject *kobj, char **envp, +static int memory_uevent(struct kset *kset, struct kobject *kobj, char **envp, int num_envp, char *buffer, int buffer_size) { int retval = 0; @@ -42,9 +42,9 @@ static int memory_hotplug(struct kset *kset, struct kobject *kobj, char **envp, return retval; } -static struct kset_hotplug_ops memory_hotplug_ops = { - .name = memory_hotplug_name, - .hotplug = memory_hotplug, +static struct kset_uevent_ops memory_uevent_ops = { + .name = memory_uevent_name, + .uevent = memory_uevent, }; static struct notifier_block *memory_chain; @@ -431,7 +431,7 @@ int __init memory_dev_init(void) unsigned int i; int ret; - memory_sysdev_class.kset.hotplug_ops = &memory_hotplug_ops; + memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; ret = sysdev_class_register(&memory_sysdev_class); /* diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 0ea37b1..f245366 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c @@ -121,8 +121,8 @@ struct host_info { }; static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); -static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, - char *buffer, int buffer_size); +static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, + char *buffer, int buffer_size); static void nodemgr_resume_ne(struct node_entry *ne); static void nodemgr_remove_ne(struct node_entry *ne); static struct node_entry *find_entry_by_guid(u64 guid); @@ -162,7 +162,7 @@ static void ud_cls_release(struct class_device *class_dev) static struct class nodemgr_ud_class = { .name = "ieee1394", .release = ud_cls_release, - .hotplug = nodemgr_hotplug, + .uevent = nodemgr_uevent, }; static struct hpsb_highlevel nodemgr_highlevel; @@ -966,7 +966,7 @@ static struct unit_directory *nodemgr_process_unit_directory if (ud_child == NULL) break; - /* inherit unspecified values so hotplug picks it up */ + /* inherit unspecified values, the driver core picks it up */ if ((ud->flags & UNIT_DIRECTORY_MODEL_ID) && !(ud_child->flags & UNIT_DIRECTORY_MODEL_ID)) { @@ -1062,8 +1062,8 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent #ifdef CONFIG_HOTPLUG -static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, - char *buffer, int buffer_size) +static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, + char *buffer, int buffer_size) { struct unit_directory *ud; int i = 0; @@ -1112,8 +1112,8 @@ do { \ #else -static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, - char *buffer, int buffer_size) +static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp, + char *buffer, int buffer_size) { return -ENODEV; } @@ -1618,8 +1618,8 @@ static int nodemgr_host_thread(void *__hi) /* Scan our nodes to get the bus options and create node * entries. This does not do the sysfs stuff, since that - * would trigger hotplug callbacks and such, which is a - * bad idea at this point. */ + * would trigger uevents and such, which is a bad idea at + * this point. */ nodemgr_node_scan(hi, generation); /* This actually does the full probe, with sysfs diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 08648b1a..1f1743c 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -434,24 +434,24 @@ static void ib_device_release(struct class_device *cdev) kfree(dev); } -static int ib_device_hotplug(struct class_device *cdev, char **envp, - int num_envp, char *buf, int size) +static int ib_device_uevent(struct class_device *cdev, char **envp, + int num_envp, char *buf, int size) { struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); int i = 0, len = 0; - if (add_hotplug_env_var(envp, num_envp, &i, buf, size, &len, - "NAME=%s", dev->name)) + if (add_uevent_var(envp, num_envp, &i, buf, size, &len, + "NAME=%s", dev->name)) return -ENOMEM; /* - * It might be nice to pass the node GUID to hotplug, but + * It might be nice to pass the node GUID with the event, but * right now the only way to get it is to query the device * provider, and this can crash during device removal because * we are will be running after driver removal has started. * We could add a node_guid field to struct ib_device, or we - * could just let the hotplug script read the node GUID from - * sysfs when devices are added. + * could just let userspace read the node GUID from sysfs when + * devices are added. */ envp[i] = NULL; @@ -653,7 +653,7 @@ static struct class_device_attribute *ib_class_attributes[] = { static struct class ib_class = { .name = "infiniband", .release = ib_device_release, - .hotplug = ib_device_hotplug, + .uevent = ib_device_uevent, }; int ib_device_register_sysfs(struct ib_device *device) diff --git a/drivers/input/input.c b/drivers/input/input.c index 43b49ccd..2d37b39 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -610,10 +610,10 @@ static void input_dev_release(struct class_device *class_dev) } /* - * Input hotplugging interface - loading event handlers based on + * Input uevent interface - loading event handlers based on * device bitfields. */ -static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index, +static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index, char *buffer, int buffer_size, int *cur_len, const char *name, unsigned long *bitmap, int max) { @@ -638,7 +638,7 @@ static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index, #define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \ do { \ - int err = add_hotplug_env_var(envp, num_envp, &i, \ + int err = add_uevent_var(envp, num_envp, &i, \ buffer, buffer_size, &len, \ fmt, val); \ if (err) \ @@ -647,15 +647,15 @@ static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index, #define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \ do { \ - int err = input_add_hotplug_bm_var(envp, num_envp, &i, \ + int err = input_add_uevent_bm_var(envp, num_envp, &i, \ buffer, buffer_size, &len, \ name, bm, max); \ if (err) \ return err; \ } while (0) -static int input_dev_hotplug(struct class_device *cdev, char **envp, - int num_envp, char *buffer, int buffer_size) +static int input_dev_uevent(struct class_device *cdev, char **envp, + int num_envp, char *buffer, int buffer_size) { struct input_dev *dev = to_input_dev(cdev); int i = 0; @@ -697,7 +697,7 @@ static int input_dev_hotplug(struct class_device *cdev, char **envp, struct class input_class = { .name = "input", .release = input_dev_release, - .hotplug = input_dev_hotplug, + .uevent = input_dev_uevent, }; struct input_dev *input_allocate_device(void) diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index fbb69ef..8e530cc 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -800,16 +800,16 @@ static int serio_bus_match(struct device *dev, struct device_driver *drv) #ifdef CONFIG_HOTPLUG -#define SERIO_ADD_HOTPLUG_VAR(fmt, val...) \ +#define SERIO_ADD_UEVENT_VAR(fmt, val...) \ do { \ - int err = add_hotplug_env_var(envp, num_envp, &i, \ + int err = add_uevent_var(envp, num_envp, &i, \ buffer, buffer_size, &len, \ fmt, val); \ if (err) \ return err; \ } while (0) -static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) +static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { struct serio *serio; int i = 0; @@ -820,21 +820,21 @@ static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *bu serio = to_serio_port(dev); - SERIO_ADD_HOTPLUG_VAR("SERIO_TYPE=%02x", serio->id.type); - SERIO_ADD_HOTPLUG_VAR("SERIO_PROTO=%02x", serio->id.proto); - SERIO_ADD_HOTPLUG_VAR("SERIO_ID=%02x", serio->id.id); - SERIO_ADD_HOTPLUG_VAR("SERIO_EXTRA=%02x", serio->id.extra); - SERIO_ADD_HOTPLUG_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", + SERIO_ADD_UEVENT_VAR("SERIO_TYPE=%02x", serio->id.type); + SERIO_ADD_UEVENT_VAR("SERIO_PROTO=%02x", serio->id.proto); + SERIO_ADD_UEVENT_VAR("SERIO_ID=%02x", serio->id.id); + SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra); + SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); envp[i] = NULL; return 0; } -#undef SERIO_ADD_HOTPLUG_VAR +#undef SERIO_ADD_UEVENT_VAR #else -static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) +static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { return -ENODEV; } @@ -908,7 +908,7 @@ static int __init serio_init(void) serio_bus.dev_attrs = serio_device_attrs; serio_bus.drv_attrs = serio_driver_attrs; serio_bus.match = serio_bus_match; - serio_bus.hotplug = serio_hotplug; + serio_bus.uevent = serio_uevent; serio_bus.resume = serio_resume; bus_register(&serio_bus); diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index c34c96d..228e185 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c @@ -128,7 +128,7 @@ static int macio_device_resume(struct device * dev) return 0; } -static int macio_hotplug (struct device *dev, char **envp, int num_envp, +static int macio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { struct macio_dev * macio_dev; @@ -203,7 +203,7 @@ extern struct device_attribute macio_dev_attrs[]; struct bus_type macio_bus_type = { .name = "macio", .match = macio_bus_match, - .hotplug = macio_hotplug, + .uevent = macio_uevent, .suspend = macio_device_suspend, .resume = macio_device_resume, .dev_attrs = macio_dev_attrs, diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c index 3f4a66c..ec70166 100644 --- a/drivers/mmc/mmc_sysfs.c +++ b/drivers/mmc/mmc_sysfs.c @@ -80,7 +80,7 @@ static int mmc_bus_match(struct device *dev, struct device_driver *drv) } static int -mmc_bus_hotplug(struct device *dev, char **envp, int num_envp, char *buf, +mmc_bus_uevent(struct device *dev, char **envp, int num_envp, char *buf, int buf_size) { struct mmc_card *card = dev_to_mmc_card(dev); @@ -140,7 +140,7 @@ static struct bus_type mmc_bus_type = { .name = "mmc", .dev_attrs = mmc_dev_attrs, .match = mmc_bus_match, - .hotplug = mmc_bus_hotplug, + .uevent = mmc_bus_uevent, .suspend = mmc_bus_suspend, .resume = mmc_bus_resume, }; diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c index e1743be..1c97e7d 100644 --- a/drivers/pci/hotplug.c +++ b/drivers/pci/hotplug.c @@ -3,8 +3,8 @@ #include #include "pci.h" -int pci_hotplug (struct device *dev, char **envp, int num_envp, - char *buffer, int buffer_size) +int pci_uevent(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size) { struct pci_dev *pdev; int i = 0; @@ -17,34 +17,34 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, if (!pdev) return -ENODEV; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PCI_CLASS=%04X", pdev->class)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_CLASS=%04X", pdev->class)) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, - pdev->subsystem_device)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, + pdev->subsystem_device)) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PCI_SLOT_NAME=%s", pci_name(pdev))) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PCI_SLOT_NAME=%s", pci_name(pdev))) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", - pdev->vendor, pdev->device, - pdev->subsystem_vendor, pdev->subsystem_device, - (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), - (u8)(pdev->class))) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", + pdev->vendor, pdev->device, + pdev->subsystem_vendor, pdev->subsystem_device, + (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), + (u8)(pdev->class))) return -ENOMEM; envp[i] = NULL; diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index a9046d4..7146b69 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -502,8 +502,8 @@ void pci_dev_put(struct pci_dev *dev) } #ifndef CONFIG_HOTPLUG -int pci_hotplug (struct device *dev, char **envp, int num_envp, - char *buffer, int buffer_size) +int pci_uevent(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size) { return -ENODEV; } @@ -512,7 +512,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp, struct bus_type pci_bus_type = { .name = "pci", .match = pci_bus_match, - .hotplug = pci_hotplug, + .uevent = pci_uevent, .suspend = pci_device_suspend, .resume = pci_device_resume, .dev_attrs = pci_dev_attrs, diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 6527b36..294849d 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1,7 +1,7 @@ /* Functions internal to the PCI core code */ -extern int pci_hotplug (struct device *dev, char **envp, int num_envp, - char *buffer, int buffer_size); +extern int pci_uevent(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size); extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); extern void pci_cleanup_rom(struct pci_dev *dev); diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index a30aa74..7cf0908 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -901,14 +901,14 @@ int pcmcia_insert_card(struct pcmcia_socket *skt) EXPORT_SYMBOL(pcmcia_insert_card); -static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, - int num_envp, char *buffer, int buffer_size) +static int pcmcia_socket_uevent(struct class_device *dev, char **envp, + int num_envp, char *buffer, int buffer_size) { struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); int i = 0, length = 0; - if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, - &length, "SOCKET_NO=%u", s->sock)) + if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, + &length, "SOCKET_NO=%u", s->sock)) return -ENOMEM; envp[i] = NULL; @@ -927,7 +927,7 @@ static void pcmcia_release_socket_class(struct class *data) struct class pcmcia_socket_class = { .name = "pcmcia_socket", - .hotplug = pcmcia_socket_hotplug, + .uevent = pcmcia_socket_uevent, .release = pcmcia_release_socket, .class_release = pcmcia_release_socket_class, }; diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 7f8219f..6fb7639 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -779,8 +779,8 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) { #ifdef CONFIG_HOTPLUG -static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, - char *buffer, int buffer_size) +static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size) { struct pcmcia_device *p_dev; int i, length = 0; @@ -800,31 +800,31 @@ static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, i = 0; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "SOCKET_NO=%u", - p_dev->socket->sock)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "SOCKET_NO=%u", + p_dev->socket->sock)) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "DEVICE_NO=%02X", - p_dev->device_no)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "DEVICE_NO=%02X", + p_dev->device_no)) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" - "pa%08Xpb%08Xpc%08Xpd%08X", - p_dev->has_manf_id ? p_dev->manf_id : 0, - p_dev->has_card_id ? p_dev->card_id : 0, - p_dev->has_func_id ? p_dev->func_id : 0, - p_dev->func, - p_dev->device_no, - hash[0], - hash[1], - hash[2], - hash[3])) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" + "pa%08Xpb%08Xpc%08Xpd%08X", + p_dev->has_manf_id ? p_dev->manf_id : 0, + p_dev->has_card_id ? p_dev->card_id : 0, + p_dev->has_func_id ? p_dev->func_id : 0, + p_dev->func, + p_dev->device_no, + hash[0], + hash[1], + hash[2], + hash[3])) return -ENOMEM; envp[i] = NULL; @@ -834,7 +834,7 @@ static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, #else -static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, +static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { return -ENODEV; @@ -1223,7 +1223,7 @@ static struct class_interface pcmcia_bus_interface = { struct bus_type pcmcia_bus_type = { .name = "pcmcia", - .hotplug = pcmcia_bus_hotplug, + .uevent = pcmcia_bus_uevent, .match = pcmcia_bus_match, .dev_attrs = pcmcia_dev_attrs, }; diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index bf44a40..07ddf9a 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -2132,7 +2132,7 @@ restart: } spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); - kobject_hotplug(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE); + kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE); LEAVE; } diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index e80ef94..af2f094 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -363,8 +363,7 @@ void usb_driver_release_interface(struct usb_driver *driver, * Most USB device drivers will use this indirectly, through the usb core, * but some layered driver frameworks use it directly. * These device tables are exported with MODULE_DEVICE_TABLE, through - * modutils and "modules.usbmap", to support the driver loading - * functionality of USB hotplugging. + * modutils, to support the driver loading functionality of USB hotplugging. * * What Matches: * @@ -545,10 +544,7 @@ static int usb_device_match (struct device *dev, struct device_driver *drv) #ifdef CONFIG_HOTPLUG /* - * USB hotplugging invokes what /proc/sys/kernel/hotplug says - * (normally /sbin/hotplug) when USB devices get added or removed. - * - * This invokes a user mode policy agent, typically helping to load driver + * This sends an uevent to userspace, typically helping to load driver * or other modules, configure the device, and more. Drivers can provide * a MODULE_DEVICE_TABLE to help with module loading subtasks. * @@ -557,8 +553,8 @@ static int usb_device_match (struct device *dev, struct device_driver *drv) * delays in event delivery. Use sysfs (and DEVPATH) to make sure the * device (and this configuration!) are still present. */ -static int usb_hotplug (struct device *dev, char **envp, int num_envp, - char *buffer, int buffer_size) +static int usb_uevent(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size) { struct usb_interface *intf; struct usb_device *usb_dev; @@ -570,7 +566,7 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, return -ENODEV; /* driver is often null here; dev_dbg() would oops */ - pr_debug ("usb %s: hotplug\n", dev->bus_id); + pr_debug ("usb %s: uevent\n", dev->bus_id); /* Must check driver_data here, as on remove driver is always NULL */ if ((dev->driver == &usb_generic_driver) || @@ -597,51 +593,51 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, * * FIXME reduce hardwired intelligence here */ - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "DEVICE=/proc/bus/usb/%03d/%03d", - usb_dev->bus->busnum, usb_dev->devnum)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "DEVICE=/proc/bus/usb/%03d/%03d", + usb_dev->bus->busnum, usb_dev->devnum)) return -ENOMEM; #endif /* per-device configurations are common */ - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "PRODUCT=%x/%x/%x", - le16_to_cpu(usb_dev->descriptor.idVendor), - le16_to_cpu(usb_dev->descriptor.idProduct), - le16_to_cpu(usb_dev->descriptor.bcdDevice))) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "PRODUCT=%x/%x/%x", + le16_to_cpu(usb_dev->descriptor.idVendor), + le16_to_cpu(usb_dev->descriptor.idProduct), + le16_to_cpu(usb_dev->descriptor.bcdDevice))) return -ENOMEM; /* class-based driver binding models */ - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "TYPE=%d/%d/%d", - usb_dev->descriptor.bDeviceClass, - usb_dev->descriptor.bDeviceSubClass, - usb_dev->descriptor.bDeviceProtocol)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "TYPE=%d/%d/%d", + usb_dev->descriptor.bDeviceClass, + usb_dev->descriptor.bDeviceSubClass, + usb_dev->descriptor.bDeviceProtocol)) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "INTERFACE=%d/%d/%d", - alt->desc.bInterfaceClass, - alt->desc.bInterfaceSubClass, - alt->desc.bInterfaceProtocol)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "INTERFACE=%d/%d/%d", + alt->desc.bInterfaceClass, + alt->desc.bInterfaceSubClass, + alt->desc.bInterfaceProtocol)) return -ENOMEM; - if (add_hotplug_env_var(envp, num_envp, &i, - buffer, buffer_size, &length, - "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", - le16_to_cpu(usb_dev->descriptor.idVendor), - le16_to_cpu(usb_dev->descriptor.idProduct), - le16_to_cpu(usb_dev->descriptor.bcdDevice), - usb_dev->descriptor.bDeviceClass, - usb_dev->descriptor.bDeviceSubClass, - usb_dev->descriptor.bDeviceProtocol, - alt->desc.bInterfaceClass, - alt->desc.bInterfaceSubClass, - alt->desc.bInterfaceProtocol)) + if (add_uevent_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", + le16_to_cpu(usb_dev->descriptor.idVendor), + le16_to_cpu(usb_dev->descriptor.idProduct), + le16_to_cpu(usb_dev->descriptor.bcdDevice), + usb_dev->descriptor.bDeviceClass, + usb_dev->descriptor.bDeviceSubClass, + usb_dev->descriptor.bDeviceProtocol, + alt->desc.bInterfaceClass, + alt->desc.bInterfaceSubClass, + alt->desc.bInterfaceProtocol)) return -ENOMEM; envp[i] = NULL; @@ -651,7 +647,7 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp, #else -static int usb_hotplug (struct device *dev, char **envp, +static int usb_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { return -ENODEV; @@ -1491,7 +1487,7 @@ static int usb_generic_resume(struct device *dev) struct bus_type usb_bus_type = { .name = "usb", .match = usb_device_match, - .hotplug = usb_hotplug, + .uevent = usb_uevent, .suspend = usb_generic_suspend, .resume = usb_generic_resume, }; diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c index 0eaabeb..641268d 100644 --- a/drivers/usb/host/hc_crisv10.c +++ b/drivers/usb/host/hc_crisv10.c @@ -4397,7 +4397,7 @@ static int __init etrax_usb_hc_init(void) device_initialize(&fake_device); kobject_set_name(&fake_device.kobj, "etrax_usb"); kobject_add(&fake_device.kobj); - kobject_hotplug(&fake_device.kobj, KOBJ_ADD); + kobject_uevent(&fake_device.kobj, KOBJ_ADD); hc->bus->controller = &fake_device; usb_register_bus(hc->bus); diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 14016b1..024206c 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -142,12 +142,12 @@ static struct bin_attribute w1_slave_attr_bin_id = { /* Default family */ static struct w1_family w1_default_family; -static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); +static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); static struct bus_type w1_bus_type = { .name = "w1", .match = w1_master_match, - .hotplug = w1_hotplug, + .uevent = w1_uevent, }; struct device_driver w1_master_driver = { @@ -361,7 +361,7 @@ void w1_destroy_master_attributes(struct w1_master *master) } #ifdef CONFIG_HOTPLUG -static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) +static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { struct w1_master *md = NULL; struct w1_slave *sl = NULL; @@ -377,7 +377,7 @@ static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffe event_owner = "slave"; name = sl->name; } else { - dev_dbg(dev, "Unknown hotplug event.\n"); + dev_dbg(dev, "Unknown event.\n"); return -EINVAL; } @@ -386,18 +386,18 @@ static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffe if (dev->driver != &w1_slave_driver || !sl) return 0; - err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_FID=%02X", sl->reg_num.family); + err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_FID=%02X", sl->reg_num.family); if (err) return err; - err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024LX", (u64)sl->reg_num.id); + err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024LX", (u64)sl->reg_num.id); if (err) return err; return 0; }; #else -static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) +static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { return 0; } diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 8dc1822..7187a57 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -226,7 +226,7 @@ static struct sysfs_ops part_sysfs_ops = { static ssize_t part_uevent_store(struct hd_struct * p, const char *page, size_t count) { - kobject_hotplug(&p->kobj, KOBJ_ADD); + kobject_uevent(&p->kobj, KOBJ_ADD); return count; } static ssize_t part_dev_read(struct hd_struct * p, char *page) @@ -360,7 +360,7 @@ void register_disk(struct gendisk *disk) if ((err = kobject_add(&disk->kobj))) return; disk_sysfs_symlinks(disk); - kobject_hotplug(&disk->kobj, KOBJ_ADD); + kobject_uevent(&disk->kobj, KOBJ_ADD); /* No minors to use for partitions */ if (disk->minors == 1) { @@ -465,6 +465,6 @@ void del_gendisk(struct gendisk *disk) sysfs_remove_link(&disk->driverfs_dev->kobj, "block"); put_device(disk->driverfs_dev); } - kobject_hotplug(&disk->kobj, KOBJ_REMOVE); + kobject_uevent(&disk->kobj, KOBJ_REMOVE); kobject_del(&disk->kobj); } diff --git a/include/linux/device.h b/include/linux/device.h index 17cbc6d..0cdee78e 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -47,8 +47,8 @@ struct bus_type { struct driver_attribute * drv_attrs; int (*match)(struct device * dev, struct device_driver * drv); - int (*hotplug) (struct device *dev, char **envp, - int num_envp, char *buffer, int buffer_size); + int (*uevent)(struct device *dev, char **envp, + int num_envp, char *buffer, int buffer_size); int (*suspend)(struct device * dev, pm_message_t state); int (*resume)(struct device * dev); }; @@ -151,7 +151,7 @@ struct class { struct class_attribute * class_attrs; struct class_device_attribute * class_dev_attrs; - int (*hotplug)(struct class_device *dev, char **envp, + int (*uevent)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size); void (*release)(struct class_device *dev); @@ -209,9 +209,9 @@ extern int class_device_create_file(struct class_device *, * set, this will be called instead of the class specific release function. * Only use this if you want to override the default release function, like * when you are nesting class_device structures. - * @hotplug: pointer to a hotplug function for this struct class_device. If - * set, this will be called instead of the class specific hotplug function. - * Only use this if you want to override the default hotplug function, like + * @uevent: pointer to a uevent function for this struct class_device. If + * set, this will be called instead of the class specific uevent function. + * Only use this if you want to override the default uevent function, like * when you are nesting class_device structures. */ struct class_device { @@ -227,7 +227,7 @@ struct class_device { struct class_device *parent; /* parent of this child device, if there is one */ void (*release)(struct class_device *dev); - int (*hotplug)(struct class_device *dev, char **envp, + int (*uevent)(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size); char class_id[BUS_ID_SIZE]; /* unique to this class */ }; diff --git a/include/linux/firmware.h b/include/linux/firmware.h index 2063c08..2d71608 100644 --- a/include/linux/firmware.h +++ b/include/linux/firmware.h @@ -14,7 +14,7 @@ struct device; int request_firmware(const struct firmware **fw, const char *name, struct device *device); int request_firmware_nowait( - struct module *module, int hotplug, + struct module *module, int uevent, const char *name, struct device *device, void *context, void (*cont)(const struct firmware *fw, void *context)); diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 5b08248..8eb21f2 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -26,15 +26,14 @@ #include #include -#define KOBJ_NAME_LEN 20 - -#define HOTPLUG_PATH_LEN 256 +#define KOBJ_NAME_LEN 20 +#define UEVENT_HELPER_PATH_LEN 256 /* path to the userspace helper executed on an event */ -extern char hotplug_path[]; +extern char uevent_helper[]; -/* counter to tag the hotplug event, read only except for the kobject core */ -extern u64 hotplug_seqnum; +/* counter to tag the uevent, read only except for the kobject core */ +extern u64 uevent_seqnum; /* the actions here must match the proper string in lib/kobject_uevent.c */ typedef int __bitwise kobject_action_t; @@ -101,15 +100,14 @@ struct kobj_type { * of object; multiple ksets can belong to one subsystem. All * ksets of a subsystem share the subsystem's lock. * - * Each kset can support hotplugging; if it does, it will be given - * the opportunity to filter out specific kobjects from being - * reported, as well as to add its own "data" elements to the - * environment being passed to the hotplug helper. + * Each kset can support specific event variables; it can + * supress the event generation or add subsystem specific + * variables carried with the event. */ -struct kset_hotplug_ops { +struct kset_uevent_ops { int (*filter)(struct kset *kset, struct kobject *kobj); const char *(*name)(struct kset *kset, struct kobject *kobj); - int (*hotplug)(struct kset *kset, struct kobject *kobj, char **envp, + int (*uevent)(struct kset *kset, struct kobject *kobj, char **envp, int num_envp, char *buffer, int buffer_size); }; @@ -119,7 +117,7 @@ struct kset { struct list_head list; spinlock_t list_lock; struct kobject kobj; - struct kset_hotplug_ops * hotplug_ops; + struct kset_uevent_ops * uevent_ops; }; @@ -167,20 +165,20 @@ struct subsystem { struct rw_semaphore rwsem; }; -#define decl_subsys(_name,_type,_hotplug_ops) \ +#define decl_subsys(_name,_type,_uevent_ops) \ struct subsystem _name##_subsys = { \ .kset = { \ .kobj = { .name = __stringify(_name) }, \ .ktype = _type, \ - .hotplug_ops =_hotplug_ops, \ + .uevent_ops =_uevent_ops, \ } \ } -#define decl_subsys_name(_varname,_name,_type,_hotplug_ops) \ +#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \ struct subsystem _varname##_subsys = { \ .kset = { \ .kobj = { .name = __stringify(_name) }, \ .ktype = _type, \ - .hotplug_ops =_hotplug_ops, \ + .uevent_ops =_uevent_ops, \ } \ } @@ -256,16 +254,16 @@ extern int subsys_create_file(struct subsystem * , struct subsys_attribute *); extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *); #ifdef CONFIG_HOTPLUG -void kobject_hotplug(struct kobject *kobj, enum kobject_action action); +void kobject_uevent(struct kobject *kobj, enum kobject_action action); -int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, +int add_uevent_var(char **envp, int num_envp, int *cur_index, char *buffer, int buffer_size, int *cur_len, const char *format, ...) __attribute__((format (printf, 7, 8))); #else -static inline void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { } +static inline void kobject_uevent(struct kobject *kobj, enum kobject_action action) { } -static inline int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, +static inline int add_uevent_var(char **envp, int num_envp, int *cur_index, char *buffer, int buffer_size, int *cur_len, const char *format, ...) { return 0; } diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 4be34ef..5015642 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -124,7 +124,7 @@ enum KERN_OVERFLOWUID=46, /* int: overflow UID */ KERN_OVERFLOWGID=47, /* int: overflow GID */ KERN_SHMPATH=48, /* string: path to shm fs */ - KERN_HOTPLUG=49, /* string: path to hotplug policy agent */ + KERN_HOTPLUG=49, /* string: path to uevent helper (deprecated) */ KERN_IEEE_EMULATION_WARNINGS=50, /* int: unimplemented ieee instructions */ KERN_S390_USER_DEBUG_LOGGING=51, /* int: dumps of user faults */ KERN_CORE_USES_PID=52, /* int: use core or core.%pid */ diff --git a/include/linux/usb.h b/include/linux/usb.h index d81b050..7a20997 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -225,7 +225,7 @@ struct usb_interface_cache { * Device drivers should not attempt to activate configurations. The choice * of which configuration to install is a policy decision based on such * considerations as available power, functionality provided, and the user's - * desires (expressed through hotplug scripts). However, drivers can call + * desires (expressed through userspace tools). However, drivers can call * usb_reset_configuration() to reinitialize the current configuration and * all its interfaces. */ diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index e975a76..bfb4a7a 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -26,23 +26,23 @@ static struct subsys_attribute _name##_attr = \ /* current uevent sequence number */ static ssize_t uevent_seqnum_show(struct subsystem *subsys, char *page) { - return sprintf(page, "%llu\n", (unsigned long long)hotplug_seqnum); + return sprintf(page, "%llu\n", (unsigned long long)uevent_seqnum); } KERNEL_ATTR_RO(uevent_seqnum); /* uevent helper program, used during early boo */ static ssize_t uevent_helper_show(struct subsystem *subsys, char *page) { - return sprintf(page, "%s\n", hotplug_path); + return sprintf(page, "%s\n", uevent_helper); } static ssize_t uevent_helper_store(struct subsystem *subsys, const char *page, size_t count) { - if (count+1 > HOTPLUG_PATH_LEN) + if (count+1 > UEVENT_HELPER_PATH_LEN) return -ENOENT; - memcpy(hotplug_path, page, count); - hotplug_path[count] = '\0'; - if (count && hotplug_path[count-1] == '\n') - hotplug_path[count-1] = '\0'; + memcpy(uevent_helper, page, count); + uevent_helper[count] = '\0'; + if (count && uevent_helper[count-1] == '\n') + uevent_helper[count-1] = '\0'; return count; } KERNEL_ATTR_RW(uevent_helper); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 6a51e25..345f4a1 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -395,8 +395,8 @@ static ctl_table kern_table[] = { { .ctl_name = KERN_HOTPLUG, .procname = "hotplug", - .data = &hotplug_path, - .maxlen = HOTPLUG_PATH_LEN, + .data = &uevent_helper, + .maxlen = UEVENT_HELPER_PATH_LEN, .mode = 0644, .proc_handler = &proc_dostring, .strategy = &sysctl_string, diff --git a/lib/kobject.c b/lib/kobject.c index a181abe..7a0e680 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -207,7 +207,7 @@ int kobject_register(struct kobject * kobj) kobject_name(kobj),error); dump_stack(); } else - kobject_hotplug(kobj, KOBJ_ADD); + kobject_uevent(kobj, KOBJ_ADD); } else error = -EINVAL; return error; @@ -312,7 +312,7 @@ void kobject_del(struct kobject * kobj) void kobject_unregister(struct kobject * kobj) { pr_debug("kobject %s: unregistering\n",kobject_name(kobj)); - kobject_hotplug(kobj, KOBJ_REMOVE); + kobject_uevent(kobj, KOBJ_REMOVE); kobject_del(kobj); kobject_put(kobj); } diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index dd061da..01479e5 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -22,12 +22,12 @@ #include #include -#define BUFFER_SIZE 1024 /* buffer for the hotplug env */ +#define BUFFER_SIZE 1024 /* buffer for the variables */ #define NUM_ENVP 32 /* number of env pointers */ #if defined(CONFIG_HOTPLUG) -char hotplug_path[HOTPLUG_PATH_LEN] = "/sbin/hotplug"; -u64 hotplug_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug"; +u64 uevent_seqnum; static DEFINE_SPINLOCK(sequence_lock); static struct sock *uevent_sock; @@ -50,12 +50,12 @@ static char *action_to_string(enum kobject_action action) } /** - * kobject_hotplug - notify userspace by executing /sbin/hotplug + * kobject_uevent - notify userspace by ending an uevent * - * @action: action that is happening (usually "ADD" or "REMOVE") + * @action: action that is happening (usually KOBJ_ADD and KOBJ_REMOVE) * @kobj: struct kobject that the action is happening to */ -void kobject_hotplug(struct kobject *kobj, enum kobject_action action) +void kobject_uevent(struct kobject *kobj, enum kobject_action action) { char **envp; char *buffer; @@ -65,7 +65,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) const char *subsystem; struct kobject *top_kobj; struct kset *kset; - struct kset_hotplug_ops *hotplug_ops; + struct kset_uevent_ops *uevent_ops; u64 seq; char *seq_buff; int i = 0; @@ -88,11 +88,11 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) return; kset = top_kobj->kset; - hotplug_ops = kset->hotplug_ops; + uevent_ops = kset->uevent_ops; /* skip the event, if the filter returns zero. */ - if (hotplug_ops && hotplug_ops->filter) - if (!hotplug_ops->filter(kset, kobj)) + if (uevent_ops && uevent_ops->filter) + if (!uevent_ops->filter(kset, kobj)) return; /* environment index */ @@ -111,8 +111,8 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) goto exit; /* originating subsystem */ - if (hotplug_ops && hotplug_ops->name) - subsystem = hotplug_ops->name(kset, kobj); + if (uevent_ops && uevent_ops->name) + subsystem = uevent_ops->name(kset, kobj); else subsystem = kobject_name(&kset->kobj); @@ -134,12 +134,12 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) scratch += strlen("SEQNUM=18446744073709551616") + 1; /* let the kset specific function add its stuff */ - if (hotplug_ops && hotplug_ops->hotplug) { - retval = hotplug_ops->hotplug (kset, kobj, + if (uevent_ops && uevent_ops->uevent) { + retval = uevent_ops->uevent(kset, kobj, &envp[i], NUM_ENVP - i, scratch, BUFFER_SIZE - (scratch - buffer)); if (retval) { - pr_debug ("%s - hotplug() returned %d\n", + pr_debug ("%s - uevent() returned %d\n", __FUNCTION__, retval); goto exit; } @@ -147,7 +147,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) /* we will send an event, request a new sequence number */ spin_lock(&sequence_lock); - seq = ++hotplug_seqnum; + seq = ++uevent_seqnum; spin_unlock(&sequence_lock); sprintf(seq_buff, "SEQNUM=%llu", (unsigned long long)seq); @@ -177,10 +177,10 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) } /* call uevent_helper, usually only enabled during early boot */ - if (hotplug_path[0]) { + if (uevent_helper[0]) { char *argv [3]; - argv [0] = hotplug_path; + argv [0] = uevent_helper; argv [1] = (char *)subsystem; argv [2] = NULL; call_usermodehelper (argv[0], argv, envp, 0); @@ -192,39 +192,39 @@ exit: kfree(envp); return; } -EXPORT_SYMBOL(kobject_hotplug); +EXPORT_SYMBOL_GPL(kobject_uevent); /** - * add_hotplug_env_var - helper for creating hotplug environment variables + * add_uevent_var - helper for creating event variables * @envp: Pointer to table of environment variables, as passed into - * hotplug() method. + * uevent() method. * @num_envp: Number of environment variable slots available, as - * passed into hotplug() method. + * passed into uevent() method. * @cur_index: Pointer to current index into @envp. It should be - * initialized to 0 before the first call to add_hotplug_env_var(), + * initialized to 0 before the first call to add_uevent_var(), * and will be incremented on success. * @buffer: Pointer to buffer for environment variables, as passed - * into hotplug() method. - * @buffer_size: Length of @buffer, as passed into hotplug() method. + * into uevent() method. + * @buffer_size: Length of @buffer, as passed into uevent() method. * @cur_len: Pointer to current length of space used in @buffer. * Should be initialized to 0 before the first call to - * add_hotplug_env_var(), and will be incremented on success. + * add_uevent_var(), and will be incremented on success. * @format: Format for creating environment variable (of the form * "XXX=%x") for snprintf(). * * Returns 0 if environment variable was added successfully or -ENOMEM * if no space was available. */ -int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, - char *buffer, int buffer_size, int *cur_len, - const char *format, ...) +int add_uevent_var(char **envp, int num_envp, int *cur_index, + char *buffer, int buffer_size, int *cur_len, + const char *format, ...) { va_list args; /* * We check against num_envp - 1 to make sure there is at - * least one slot left after we return, since the hotplug - * method needs to set the last slot to NULL. + * least one slot left after we return, since kobject_uevent() + * needs to set the last slot to NULL. */ if (*cur_index >= num_envp - 1) return -ENOMEM; @@ -243,7 +243,7 @@ int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, (*cur_index)++; return 0; } -EXPORT_SYMBOL(add_hotplug_env_var); +EXPORT_SYMBOL_GPL(add_uevent_var); static int __init kobject_uevent_init(void) { diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index bd7568a..0ed3874 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c @@ -78,7 +78,7 @@ static struct class_device_attribute *bt_attrs[] = { }; #ifdef CONFIG_HOTPLUG -static int bt_hotplug(struct class_device *cdev, char **envp, int num_envp, char *buf, int size) +static int bt_uevent(struct class_device *cdev, char **envp, int num_envp, char *buf, int size) { struct hci_dev *hdev = class_get_devdata(cdev); int n, i = 0; @@ -107,7 +107,7 @@ struct class bt_class = { .name = "bluetooth", .release = bt_release, #ifdef CONFIG_HOTPLUG - .hotplug = bt_hotplug, + .uevent = bt_uevent, #endif }; diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c index f6a19d5..2ebdc23 100644 --- a/net/bridge/br_sysfs_if.c +++ b/net/bridge/br_sysfs_if.c @@ -248,7 +248,7 @@ int br_sysfs_addif(struct net_bridge_port *p) if (err) goto out2; - kobject_hotplug(&p->kobj, KOBJ_ADD); + kobject_uevent(&p->kobj, KOBJ_ADD); return 0; out2: kobject_del(&p->kobj); @@ -260,7 +260,7 @@ void br_sysfs_removeif(struct net_bridge_port *p) { pr_debug("br_sysfs_removeif\n"); sysfs_remove_link(&p->br->ifobj, p->dev->name); - kobject_hotplug(&p->kobj, KOBJ_REMOVE); + kobject_uevent(&p->kobj, KOBJ_REMOVE); kobject_del(&p->kobj); } diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index e2137f3..198655d 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -369,14 +369,14 @@ static struct attribute_group wireless_group = { #endif #ifdef CONFIG_HOTPLUG -static int netdev_hotplug(struct class_device *cd, char **envp, - int num_envp, char *buf, int size) +static int netdev_uevent(struct class_device *cd, char **envp, + int num_envp, char *buf, int size) { struct net_device *dev = to_net_dev(cd); int i = 0; int n; - /* pass interface in env to hotplug. */ + /* pass interface to uevent. */ envp[i++] = buf; n = snprintf(buf, size, "INTERFACE=%s", dev->name) + 1; buf += n; @@ -408,7 +408,7 @@ static struct class net_class = { .name = "net", .release = netdev_release, #ifdef CONFIG_HOTPLUG - .hotplug = netdev_hotplug, + .uevent = netdev_uevent, #endif }; -- cgit v1.1 From 712f47cea7703a340406fde61e84eb86ce781988 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 16 Nov 2005 11:27:07 -0800 Subject: [PATCH] HOTPLUG: always enable the .config option, unless EMBEDDED With modules, dynamic /dev, and uevents, people really want CONFIG_HOTPLUG to be enabled in their kernels. If not, they can still disable it, but it is discouraged. Signed-off-by: Greg Kroah-Hartman --- init/Kconfig | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 0de8b77..d2b4e33 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -197,14 +197,6 @@ config AUDITSYSCALL can be used independently or with another kernel subsystem, such as SELinux. -config HOTPLUG - bool "Support for hot-pluggable devices" if !ARCH_S390 - default ARCH_S390 - help - This option is provided for the case where no in-kernel-tree - modules require HOTPLUG functionality, but a module built - outside the kernel tree does. Such modules require Y here. - config IKCONFIG bool "Kernel .config support" ---help--- @@ -289,6 +281,15 @@ config KALLSYMS_EXTRA_PASS you wait for kallsyms to be fixed. +config HOTPLUG + bool "Support for hot-pluggable devices" if EMBEDDED + default y + help + This option is provided for the case where no hotplug or uevent + capabilities is wanted by the kernel. You should only consider + disabling this option for embedded systems that do not use modules, a + dynamic /dev tree, or dynamic device discovery. Just say Y. + config PRINTK default y bool "Enable support for printk" if EMBEDDED -- cgit v1.1 From 6d20b035dee4300e9786c6e1cb77a765c7f9460a Mon Sep 17 00:00:00 2001 From: Paul Jackson Date: Fri, 25 Nov 2005 20:04:26 -0800 Subject: [PATCH] driver kill hotplug word from sn and others fix The first of these changes s/hotplug/uevent/ was needed to compile sn2_defconfig (ia64/sn). The other three files changed are blind changes of all remaining bus_type.hotplug references I could find to bus_type.uevent. This patch attempts to finish similar changes made in the gregkh-driver-kill-hotplug-word-from-driver-core Nov 22 patch. Signed-off-by: Paul Jackson Signed-off-by: Greg Kroah-Hartman --- arch/arm/common/amba.c | 6 +++--- arch/ia64/sn/kernel/tiocx.c | 4 ++-- drivers/s390/cio/ccwgroup.c | 4 ++-- drivers/s390/cio/device.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/arm/common/amba.c b/arch/arm/common/amba.c index e101311..c95ec9e 100644 --- a/arch/arm/common/amba.c +++ b/arch/arm/common/amba.c @@ -45,7 +45,7 @@ static int amba_match(struct device *dev, struct device_driver *drv) } #ifdef CONFIG_HOTPLUG -static int amba_hotplug(struct device *dev, char **envp, int nr_env, char *buf, int bufsz) +static int amba_uevent(struct device *dev, char **envp, int nr_env, char *buf, int bufsz) { struct amba_device *pcdev = to_amba_device(dev); @@ -58,7 +58,7 @@ static int amba_hotplug(struct device *dev, char **envp, int nr_env, char *buf, return 0; } #else -#define amba_hotplug NULL +#define amba_uevent NULL #endif static int amba_suspend(struct device *dev, pm_message_t state) @@ -88,7 +88,7 @@ static int amba_resume(struct device *dev) static struct bus_type amba_bustype = { .name = "amba", .match = amba_match, - .hotplug = amba_hotplug, + .uevent = amba_uevent, .suspend = amba_suspend, .resume = amba_resume, }; diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c index 0d8592a..768c21d 100644 --- a/arch/ia64/sn/kernel/tiocx.c +++ b/arch/ia64/sn/kernel/tiocx.c @@ -65,7 +65,7 @@ static int tiocx_match(struct device *dev, struct device_driver *drv) } -static int tiocx_hotplug(struct device *dev, char **envp, int num_envp, +static int tiocx_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { return -ENODEV; @@ -79,7 +79,7 @@ static void tiocx_bus_release(struct device *dev) struct bus_type tiocx_bus_type = { .name = "tiocx", .match = tiocx_match, - .hotplug = tiocx_hotplug, + .uevent = tiocx_uevent, }; /** diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index e7bd7f3..be9d2d6 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -45,7 +45,7 @@ ccwgroup_bus_match (struct device * dev, struct device_driver * drv) return 0; } static int -ccwgroup_hotplug (struct device *dev, char **envp, int num_envp, char *buffer, +ccwgroup_uevent (struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { /* TODO */ @@ -55,7 +55,7 @@ ccwgroup_hotplug (struct device *dev, char **envp, int num_envp, char *buffer, static struct bus_type ccwgroup_bus_type = { .name = "ccwgroup", .match = ccwgroup_bus_match, - .hotplug = ccwgroup_hotplug, + .uevent = ccwgroup_uevent, }; static inline void diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index 811c9d1..85908ca 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -59,7 +59,7 @@ ccw_bus_match (struct device * dev, struct device_driver * drv) * Heavily modeled on pci and usb hotplug. */ static int -ccw_hotplug (struct device *dev, char **envp, int num_envp, +ccw_uevent (struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) { struct ccw_device *cdev = to_ccwdev(dev); @@ -110,7 +110,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp, struct bus_type ccw_bus_type = { .name = "ccw", .match = &ccw_bus_match, - .hotplug = &ccw_hotplug, + .uevent = &ccw_uevent, }; static int io_subchannel_probe (struct device *); -- cgit v1.1 From bf74ad5bc41727d5f2f1c6bedb2c1fac394de731 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Thu, 17 Nov 2005 16:54:12 -0500 Subject: [PATCH] Hold the device's parent's lock during probe and remove This patch (as604) makes the driver core hold a device's parent's lock as well as the device's lock during calls to the probe and remove methods in a driver. This facility is needed by USB device drivers, owing to the peculiar way USB devices work: A device provides multiple interfaces, and drivers are bound to interfaces rather than to devices; Nevertheless a reset, reset-configuration, suspend, or resume affects the entire device and requires the caller to hold the lock for the device, not just a lock for one of the interfaces. Since a USB driver's probe method is always called with the interface lock held, the locking order rules (always lock parent before child) prevent these methods from acquiring the device lock. The solution provided here is to call all probe and remove methods, for all devices (not just USB), with the parent lock already acquired. Although currently only the USB subsystem requires these changes, people have mentioned in prior discussion that the overhead of acquiring an extra semaphore in all the prove/remove sequences is not overly large. Up to now, the USB core has been using its own set of private semaphores. A followup patch will remove them, relying entirely on the device semaphores provided by the driver core. The code paths affected by this patch are: device_add and device_del: The USB core already holds the parent lock, so no actual change is needed. driver_register and driver_unregister: The driver core will now lock both the parent and the device before probing or removing. driver_bind and driver_unbind (in sysfs): These routines will now lock both the parent and the device before binding or unbinding. bus_rescan_devices: The helper routine will lock the parent before probing a device. I have not tested this patch for conflicts with other subsystems. As far as I can see, the only possibility of conflict would lie in the bus_rescan_devices pathway, and it seems pretty remote. Nevertheless, it would be good for this to get a lot of testing in -mm. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/base/bus.c | 15 ++++++++++++++- drivers/base/dd.c | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index fa601b0..e3f915a 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -152,7 +152,11 @@ static ssize_t driver_unbind(struct device_driver *drv, dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); if (dev && dev->driver == drv) { + if (dev->parent) /* Needed for USB */ + down(&dev->parent->sem); device_release_driver(dev); + if (dev->parent) + up(&dev->parent->sem); err = count; } put_device(dev); @@ -175,9 +179,13 @@ static ssize_t driver_bind(struct device_driver *drv, dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); if (dev && dev->driver == NULL) { + if (dev->parent) /* Needed for USB */ + down(&dev->parent->sem); down(&dev->sem); err = driver_probe_device(drv, dev); up(&dev->sem); + if (dev->parent) + up(&dev->parent->sem); } put_device(dev); put_bus(bus); @@ -484,8 +492,13 @@ void bus_remove_driver(struct device_driver * drv) /* Helper for bus_rescan_devices's iter */ static int bus_rescan_devices_helper(struct device *dev, void *data) { - if (!dev->driver) + if (!dev->driver) { + if (dev->parent) /* Needed for USB */ + down(&dev->parent->sem); device_attach(dev); + if (dev->parent) + up(&dev->parent->sem); + } return 0; } diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 3b419c9..2b90501 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -65,7 +65,8 @@ void device_bind_driver(struct device * dev) * This function returns 1 if a match is found, an error if one * occurs (that is not -ENODEV or -ENXIO), and 0 otherwise. * - * This function must be called with @dev->sem held. + * This function must be called with @dev->sem held. When called + * for a USB interface, @dev->parent->sem must be held as well. */ int driver_probe_device(struct device_driver * drv, struct device * dev) { @@ -123,6 +124,8 @@ static int __device_attach(struct device_driver * drv, void * data) * * Returns 1 if the device was bound to a driver; * 0 if no matching device was found; error code otherwise. + * + * When called for a USB interface, @dev->parent->sem must be held. */ int device_attach(struct device * dev) { @@ -152,10 +155,14 @@ static int __driver_attach(struct device * dev, void * data) * is an error. */ + if (dev->parent) /* Needed for USB */ + down(&dev->parent->sem); down(&dev->sem); if (!dev->driver) driver_probe_device(drv, dev); up(&dev->sem); + if (dev->parent) + up(&dev->parent->sem); return 0; } @@ -181,6 +188,8 @@ void driver_attach(struct device_driver * drv) * Manually detach device from driver. * * __device_release_driver() must be called with @dev->sem held. + * When called for a USB interface, @dev->parent->sem must be held + * as well. */ static void __device_release_driver(struct device * dev) @@ -233,10 +242,14 @@ void driver_detach(struct device_driver * drv) get_device(dev); spin_unlock(&drv->klist_devices.k_lock); + if (dev->parent) /* Needed for USB */ + down(&dev->parent->sem); down(&dev->sem); if (dev->driver == drv) __device_release_driver(dev); up(&dev->sem); + if (dev->parent) + up(&dev->parent->sem); put_device(dev); } } -- cgit v1.1 From e22dafbcd7a579c29a424d5203b5b33b131948a7 Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Sat, 26 Nov 2005 20:48:40 -0800 Subject: [PATCH] klist: Fix broken kref counting in find functions The klist reference counting in the find functions that use klist_iter_init_node is broken. If the function (for example driver_find_device) is called with a NULL start object then everything is fine, the first call to next_device()/klist_next increases the ref-count of the first node on the list and does nothing for the start object which is NULL. If they are called with a valid start object then klist_next will decrement the ref-count for the start object but nobody has incremented it. Logical place to fix this would be klist_iter_init_node because the function puts a reference of the object into the klist_iter struct. Signed-off-by: Martin Schwidefsky Signed-off-by: Frank Pavlic Cc: Patrick Mochel Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- lib/klist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/klist.c b/lib/klist.c index bb2f355..9c94f0b 100644 --- a/lib/klist.c +++ b/lib/klist.c @@ -199,6 +199,8 @@ void klist_iter_init_node(struct klist * k, struct klist_iter * i, struct klist_ i->i_klist = k; i->i_head = &k->k_list; i->i_cur = n; + if (n) + kref_get(&n->n_ref); } EXPORT_SYMBOL_GPL(klist_iter_init_node); -- cgit v1.1 From d960bb4db9f422b5c3c82e0dfd6c8213a4fc430d Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Mon, 28 Nov 2005 10:15:39 -0600 Subject: [PATCH] Allow overlapping resources for platform devices There are cases in which a device's memory mapped registers overlap with another device's memory mapped registers. On several PowerPC devices this occurs for the MDIO bus, whose registers tended to overlap with one of the ethernet controllers. By switching from request_resource to insert_resource we can register the MDIO bus as a proper platform device and not hack around how we handle its memory mapped registers. Signed-off-by: Kumar Gala Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 8827daf..1091af1 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -257,7 +257,7 @@ int platform_device_add(struct platform_device *pdev) p = &ioport_resource; } - if (p && request_resource(p, r)) { + if (p && insert_resource(p, r)) { printk(KERN_ERR "%s: failed to claim resource %d\n", pdev->dev.bus_id, i); -- cgit v1.1 From f743ca5e10f4145e0b3e6d11b9b46171e16af7ce Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Tue, 22 Nov 2005 23:36:13 -0800 Subject: [PATCH] kobject_uevent CONFIG_NET=n fix lib/lib.a(kobject_uevent.o)(.text+0x25f): In function `kobject_uevent': : undefined reference to `__alloc_skb' lib/lib.a(kobject_uevent.o)(.text+0x2a1): In function `kobject_uevent': : undefined reference to `skb_over_panic' lib/lib.a(kobject_uevent.o)(.text+0x31d): In function `kobject_uevent': : undefined reference to `skb_over_panic' lib/lib.a(kobject_uevent.o)(.text+0x356): In function `kobject_uevent': : undefined reference to `netlink_broadcast' lib/lib.a(kobject_uevent.o)(.init.text+0x9): In function `kobject_uevent_init': : undefined reference to `netlink_kernel_create' make: *** [.tmp_vmlinux1] Error 1 Netlink is unconditionally enabled if CONFIG_NET, so that's OK. kobject_uevent.o is compiled even if !CONFIG_HOTPLUG, which is lazy. Let's compound the sin. Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- include/linux/kobject.h | 2 +- kernel/ksysfs.c | 3 +++ lib/kobject_uevent.c | 4 +--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 8eb21f2..2a8d8da 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -253,7 +253,7 @@ struct subsys_attribute { extern int subsys_create_file(struct subsystem * , struct subsys_attribute *); extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *); -#ifdef CONFIG_HOTPLUG +#if defined(CONFIG_HOTPLUG) & defined(CONFIG_NET) void kobject_uevent(struct kobject *kobj, enum kobject_action action); int add_uevent_var(char **envp, int num_envp, int *cur_index, diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index bfb4a7a..99af8b0 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -15,6 +15,9 @@ #include #include +u64 uevent_seqnum; +char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug"; + #define KERNEL_ATTR_RO(_name) \ static struct subsys_attribute _name##_attr = __ATTR_RO(_name) diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 01479e5..f56e27a 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c @@ -25,9 +25,7 @@ #define BUFFER_SIZE 1024 /* buffer for the variables */ #define NUM_ENVP 32 /* number of env pointers */ -#if defined(CONFIG_HOTPLUG) -char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug"; -u64 uevent_seqnum; +#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET) static DEFINE_SPINLOCK(sequence_lock); static struct sock *uevent_sock; -- cgit v1.1 From 263756ec228f1cdd49fc50b1f87001a4cebdfe12 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Mon, 12 Dec 2005 18:03:44 +0100 Subject: [PATCH] ide: MODALIAS support for autoloading of ide-cd, ide-disk, ... IDE: MODALIAS support for autoloading of ide-cd, ide-disk, ... Add MODULE_ALIAS to IDE midlayer modules: ide-disk, ide-cd, ide-floppy and ide-tape, to autoload these modules depending on the probed media type of the IDE device. It is used by udev and replaces the former agent shell script of the hotplug package, which was required to lookup the media type in the proc filesystem. Using proc was racy, cause the media file is created after the hotplug event is sent out. The module autoloading does not take any effect, until something like the following udev rule is configured: SUBSYSTEM=="ide", ACTION=="add", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}" The module ide-scsi will not be autoloaded, cause it requires manual configuration. It can't be, and never was supported for automatic setup in the hotplug package. Adding a MODULE_ALIAS to ide-scsi for all supported media types, would just lead to a default blacklist entry anyway. $ modinfo ide-disk filename: /lib/modules/2.6.15-rc4-g1b0997f5/kernel/drivers/ide/ide-disk.ko description: ATA DISK Driver alias: ide:*m-disk* license: GPL ... $ modprobe -vn ide:m-disk insmod /lib/modules/2.6.15-rc4-g1b0997f5/kernel/drivers/ide/ide-disk.ko $ cat /sys/bus/ide/devices/0.0/modalias ide:m-disk It also adds attributes to the IDE device: $ tree /sys/bus/ide/devices/0.0/ /sys/bus/ide/devices/0.0/ |-- bus -> ../../../../../../../bus/ide |-- drivename |-- media |-- modalias |-- power | |-- state | `-- wakeup `-- uevent $ cat /sys/bus/ide/devices/0.0/{modalias,drivename,media} ide:m-disk hda disk Signed-off-by: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/ide/ide-cd.c | 1 + drivers/ide/ide-disk.c | 1 + drivers/ide/ide-floppy.c | 1 + drivers/ide/ide-tape.c | 1 + drivers/ide/ide.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+) diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index b4d7a3e..70aeb3a 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -3509,6 +3509,7 @@ static int __init ide_cdrom_init(void) return driver_register(&ide_cdrom_driver.gen_driver); } +MODULE_ALIAS("ide:*m-cdrom*"); module_init(ide_cdrom_init); module_exit(ide_cdrom_exit); MODULE_LICENSE("GPL"); diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 449522f..4e57679 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -1271,6 +1271,7 @@ static int __init idedisk_init(void) return driver_register(&idedisk_driver.gen_driver); } +MODULE_ALIAS("ide:*m-disk*"); module_init(idedisk_init); module_exit(idedisk_exit); MODULE_LICENSE("GPL"); diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 9e293c8..fba3fff 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c @@ -2197,6 +2197,7 @@ static int __init idefloppy_init(void) return driver_register(&idefloppy_driver.gen_driver); } +MODULE_ALIAS("ide:*m-floppy*"); module_init(idefloppy_init); module_exit(idefloppy_exit); MODULE_LICENSE("GPL"); diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 7d7944e..fab9b2b 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -4947,6 +4947,7 @@ out: return error; } +MODULE_ALIAS("ide:*m-tape*"); module_init(idetape_init); module_exit(idetape_exit); MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR); diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 8af179b..4b524f6 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1904,9 +1904,69 @@ static int ide_bus_match(struct device *dev, struct device_driver *drv) return 1; } +static char *media_string(ide_drive_t *drive) +{ + switch (drive->media) { + case ide_disk: + return "disk"; + case ide_cdrom: + return "cdrom"; + case ide_tape: + return "tape"; + case ide_floppy: + return "floppy"; + default: + return "UNKNOWN"; + } +} + +static ssize_t media_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + ide_drive_t *drive = to_ide_device(dev); + return sprintf(buf, "%s\n", media_string(drive)); +} + +static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + ide_drive_t *drive = to_ide_device(dev); + return sprintf(buf, "%s\n", drive->name); +} + +static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + ide_drive_t *drive = to_ide_device(dev); + return sprintf(buf, "ide:m-%s\n", media_string(drive)); +} + +static struct device_attribute ide_dev_attrs[] = { + __ATTR_RO(media), + __ATTR_RO(drivename), + __ATTR_RO(modalias), + __ATTR_NULL +}; + +static int ide_uevent(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size) +{ + ide_drive_t *drive = to_ide_device(dev); + int i = 0; + int length = 0; + + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, + "MEDIA=%s", media_string(drive)); + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, + "DRIVENAME=%s", drive->name); + add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length, + "MODALIAS=ide:m-%s", media_string(drive)); + envp[i] = NULL; + return 0; +} + struct bus_type ide_bus_type = { .name = "ide", .match = ide_bus_match, + .uevent = ide_uevent, + .dev_attrs = ide_dev_attrs, .suspend = generic_ide_suspend, .resume = generic_ide_resume, }; -- cgit v1.1 From 1d8f430c15b3a345db990e285742c67c2f52f9a6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 7 Dec 2005 21:40:34 +0100 Subject: [PATCH] Input: add modalias support Here's the patch for modalias support for input classes. It uses comma-separated numbers, and doesn't describe all the potential keys (no module currently cares, and that would make the strings huge). The changes to input.h are to move the definitions needed by file2alias outside __KERNEL__. I chose not to move those definitions to mod_devicetable.h, because there are so many that it might break compile of something else in the kernel. The rest is fairly straightforward. Signed-off-by: Rusty Russell CC: Kay Sievers Signed-off-by: Greg Kroah-Hartman --- drivers/input/input.c | 39 ++++++++++++++++++++++++ include/linux/input.h | 79 +++++++++++++++++++++++++----------------------- scripts/mod/file2alias.c | 62 ++++++++++++++++++++++++++++++++++++- 3 files changed, 141 insertions(+), 39 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index 2d37b39..ef5824c 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -528,10 +528,49 @@ INPUT_DEV_STRING_ATTR_SHOW(name); INPUT_DEV_STRING_ATTR_SHOW(phys); INPUT_DEV_STRING_ATTR_SHOW(uniq); +static int print_modalias_bits(char *buf, char prefix, unsigned long *arr, + unsigned int min, unsigned int max) +{ + int len, i; + + len = sprintf(buf, "%c", prefix); + for (i = min; i < max; i++) + if (arr[LONG(i)] & BIT(i)) + len += sprintf(buf+len, "%X,", i); + return len; +} + +static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf) +{ + struct input_dev *id = to_input_dev(dev); + ssize_t len = 0; + + len += sprintf(buf+len, "input:b%04Xv%04Xp%04Xe%04X-", + id->id.bustype, + id->id.vendor, + id->id.product, + id->id.version); + + len += print_modalias_bits(buf+len, 'e', id->evbit, 0, EV_MAX); + len += print_modalias_bits(buf+len, 'k', id->keybit, + KEY_MIN_INTERESTING, KEY_MAX); + len += print_modalias_bits(buf+len, 'r', id->relbit, 0, REL_MAX); + len += print_modalias_bits(buf+len, 'a', id->absbit, 0, ABS_MAX); + len += print_modalias_bits(buf+len, 'm', id->mscbit, 0, MSC_MAX); + len += print_modalias_bits(buf+len, 'l', id->ledbit, 0, LED_MAX); + len += print_modalias_bits(buf+len, 's', id->sndbit, 0, SND_MAX); + len += print_modalias_bits(buf+len, 'f', id->ffbit, 0, FF_MAX); + len += print_modalias_bits(buf+len, 'w', id->swbit, 0, SW_MAX); + len += sprintf(buf+len, "\n"); + return len; +} +static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL); + static struct attribute *input_dev_attrs[] = { &class_device_attr_name.attr, &class_device_attr_phys.attr, &class_device_attr_uniq.attr, + &class_device_attr_modalias.attr, NULL }; diff --git a/include/linux/input.h b/include/linux/input.h index 3c58233..bef0855 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -18,6 +18,7 @@ #include #include #endif +#include /* * The event structure itself @@ -511,6 +512,8 @@ struct input_absinfo { #define KEY_FN_S 0x1e3 #define KEY_FN_B 0x1e4 +/* We avoid low common keys in module aliases so they don't get huge. */ +#define KEY_MIN_INTERESTING KEY_MUTE #define KEY_MAX 0x1ff /* @@ -793,6 +796,44 @@ struct ff_effect { #define FF_MAX 0x7f +struct input_device_id { + + kernel_ulong_t flags; + + struct input_id id; + + kernel_ulong_t evbit[EV_MAX/BITS_PER_LONG+1]; + kernel_ulong_t keybit[KEY_MAX/BITS_PER_LONG+1]; + kernel_ulong_t relbit[REL_MAX/BITS_PER_LONG+1]; + kernel_ulong_t absbit[ABS_MAX/BITS_PER_LONG+1]; + kernel_ulong_t mscbit[MSC_MAX/BITS_PER_LONG+1]; + kernel_ulong_t ledbit[LED_MAX/BITS_PER_LONG+1]; + kernel_ulong_t sndbit[SND_MAX/BITS_PER_LONG+1]; + kernel_ulong_t ffbit[FF_MAX/BITS_PER_LONG+1]; + kernel_ulong_t swbit[SW_MAX/BITS_PER_LONG+1]; + + kernel_ulong_t driver_info; +}; + +/* + * Structure for hotplug & device<->driver matching. + */ + +#define INPUT_DEVICE_ID_MATCH_BUS 1 +#define INPUT_DEVICE_ID_MATCH_VENDOR 2 +#define INPUT_DEVICE_ID_MATCH_PRODUCT 4 +#define INPUT_DEVICE_ID_MATCH_VERSION 8 + +#define INPUT_DEVICE_ID_MATCH_EVBIT 0x010 +#define INPUT_DEVICE_ID_MATCH_KEYBIT 0x020 +#define INPUT_DEVICE_ID_MATCH_RELBIT 0x040 +#define INPUT_DEVICE_ID_MATCH_ABSBIT 0x080 +#define INPUT_DEVICE_ID_MATCH_MSCIT 0x100 +#define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200 +#define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400 +#define INPUT_DEVICE_ID_MATCH_FFBIT 0x800 +#define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000 + #ifdef __KERNEL__ /* @@ -901,49 +942,11 @@ struct input_dev { }; #define to_input_dev(d) container_of(d, struct input_dev, cdev) -/* - * Structure for hotplug & device<->driver matching. - */ - -#define INPUT_DEVICE_ID_MATCH_BUS 1 -#define INPUT_DEVICE_ID_MATCH_VENDOR 2 -#define INPUT_DEVICE_ID_MATCH_PRODUCT 4 -#define INPUT_DEVICE_ID_MATCH_VERSION 8 - -#define INPUT_DEVICE_ID_MATCH_EVBIT 0x010 -#define INPUT_DEVICE_ID_MATCH_KEYBIT 0x020 -#define INPUT_DEVICE_ID_MATCH_RELBIT 0x040 -#define INPUT_DEVICE_ID_MATCH_ABSBIT 0x080 -#define INPUT_DEVICE_ID_MATCH_MSCIT 0x100 -#define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200 -#define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400 -#define INPUT_DEVICE_ID_MATCH_FFBIT 0x800 -#define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000 - #define INPUT_DEVICE_ID_MATCH_DEVICE\ (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\ (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION) -struct input_device_id { - - unsigned long flags; - - struct input_id id; - - unsigned long evbit[NBITS(EV_MAX)]; - unsigned long keybit[NBITS(KEY_MAX)]; - unsigned long relbit[NBITS(REL_MAX)]; - unsigned long absbit[NBITS(ABS_MAX)]; - unsigned long mscbit[NBITS(MSC_MAX)]; - unsigned long ledbit[NBITS(LED_MAX)]; - unsigned long sndbit[NBITS(SND_MAX)]; - unsigned long ffbit[NBITS(FF_MAX)]; - unsigned long swbit[NBITS(SW_MAX)]; - - unsigned long driver_info; -}; - struct input_handle; struct input_handler { diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index e3d144a..e0eedff 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -16,8 +16,10 @@ * use either stdint.h or inttypes.h for the rest. */ #if KERNEL_ELFCLASS == ELFCLASS32 typedef Elf32_Addr kernel_ulong_t; +#define BITS_PER_LONG 32 #else typedef Elf64_Addr kernel_ulong_t; +#define BITS_PER_LONG 64 #endif #ifdef __sun__ #include @@ -35,6 +37,7 @@ typedef unsigned char __u8; * even potentially has different endianness and word sizes, since * we handle those differences explicitly below */ #include "../../include/linux/mod_devicetable.h" +#include "../../include/linux/input.h" #define ADD(str, sep, cond, field) \ do { \ @@ -366,6 +369,61 @@ static int do_i2c_entry(const char *filename, struct i2c_device_id *i2c, char *a return 1; } +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + +static void do_input(char *alias, + kernel_ulong_t *arr, unsigned int min, unsigned int max) +{ + unsigned int i; + for (i = min; i < max; i++) { + if (arr[i/BITS_PER_LONG] & (1 << (i%BITS_PER_LONG))) + sprintf(alias+strlen(alias), "%X,*", i); + } +} + +/* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */ +static int do_input_entry(const char *filename, struct input_device_id *id, + char *alias) +{ + sprintf(alias, "input:"); + + ADD(alias, "b", id->flags&INPUT_DEVICE_ID_MATCH_BUS, id->id.bustype); + ADD(alias, "v", id->flags&INPUT_DEVICE_ID_MATCH_VENDOR, id->id.vendor); + ADD(alias, "p", id->flags&INPUT_DEVICE_ID_MATCH_PRODUCT, + id->id.product); + ADD(alias, "e", id->flags&INPUT_DEVICE_ID_MATCH_VERSION, + id->id.version); + + sprintf(alias + strlen(alias), "-e*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_EVBIT) + do_input(alias, id->evbit, 0, EV_MAX); + sprintf(alias + strlen(alias), "k*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_KEYBIT) + do_input(alias, id->keybit, KEY_MIN_INTERESTING, KEY_MAX); + sprintf(alias + strlen(alias), "r*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_RELBIT) + do_input(alias, id->relbit, 0, REL_MAX); + sprintf(alias + strlen(alias), "a*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_ABSBIT) + do_input(alias, id->absbit, 0, ABS_MAX); + sprintf(alias + strlen(alias), "m*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_MSCIT) + do_input(alias, id->mscbit, 0, MSC_MAX); + sprintf(alias + strlen(alias), "l*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_LEDBIT) + do_input(alias, id->ledbit, 0, LED_MAX); + sprintf(alias + strlen(alias), "s*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_SNDBIT) + do_input(alias, id->sndbit, 0, SND_MAX); + sprintf(alias + strlen(alias), "f*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_FFBIT) + do_input(alias, id->ffbit, 0, SND_MAX); + sprintf(alias + strlen(alias), "w*"); + if (id->flags&INPUT_DEVICE_ID_MATCH_SWBIT) + do_input(alias, id->swbit, 0, SW_MAX); + return 1; +} + /* Ignore any prefix, eg. v850 prepends _ */ static inline int sym_is(const char *symbol, const char *name) { @@ -453,7 +511,9 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, else if (sym_is(symname, "__mod_i2c_device_table")) do_table(symval, sym->st_size, sizeof(struct i2c_device_id), do_i2c_entry, mod); - + else if (sym_is(symname, "__mod_input_device_table")) + do_table(symval, sym->st_size, sizeof(struct input_device_id), + do_input_entry, mod); } /* Now add out buffered information to the generated C source */ -- cgit v1.1 From e39b84337b8aed3044683a57741a19e5002225b9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 10 Dec 2005 22:48:20 +1100 Subject: [PATCH] Input: fix add modalias support build error Fix build when scripts/mod/file2alias.c includes linux/input.h, which tries to include /usr/include/linux/mod_devicetable.h: In file included from scripts/mod/file2alias.c:40: include/linux/input.h:21:35: linux/mod_devicetable.h: No such file or directory make[2]: *** [scripts/mod/file2alias.o] Error 1 Signed-off-by: Rusty Russell Signed-off-by: Greg Kroah-Hartman --- include/linux/input.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/input.h b/include/linux/input.h index bef0855..6d4cc3c 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -13,12 +13,12 @@ #include #include #include +#include #else #include #include #include #endif -#include /* * The event structure itself -- cgit v1.1 From 93ce3061be212f6280e7ccafa9a7f698a95c6d75 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sat, 10 Dec 2005 01:36:27 -0500 Subject: [PATCH] Driver Core: Add platform_device_del() Driver core: add platform_device_del function Having platform_device_del90 allows more straightforward error handling code in drivers registering platform devices. Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 45 +++++++++++++++++++++++++++-------------- include/linux/platform_device.h | 1 + 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1091af1..95ecfc4 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -168,7 +168,7 @@ struct platform_device *platform_device_alloc(const char *name, unsigned int id) pa->pdev.dev.release = platform_device_release; } - return pa ? &pa->pdev : NULL; + return pa ? &pa->pdev : NULL; } EXPORT_SYMBOL_GPL(platform_device_alloc); @@ -282,24 +282,13 @@ int platform_device_add(struct platform_device *pdev) EXPORT_SYMBOL_GPL(platform_device_add); /** - * platform_device_register - add a platform-level device - * @pdev: platform device we're adding - * - */ -int platform_device_register(struct platform_device * pdev) -{ - device_initialize(&pdev->dev); - return platform_device_add(pdev); -} - -/** - * platform_device_unregister - remove a platform-level device + * platform_device_del - remove a platform-level device * @pdev: platform device we're removing * * Note that this function will also release all memory- and port-based * resources owned by the device (@dev->resource). */ -void platform_device_unregister(struct platform_device * pdev) +void platform_device_del(struct platform_device *pdev) { int i; @@ -310,9 +299,35 @@ void platform_device_unregister(struct platform_device * pdev) release_resource(r); } - device_unregister(&pdev->dev); + device_del(&pdev->dev); } } +EXPORT_SYMBOL_GPL(platform_device_del); + +/** + * platform_device_register - add a platform-level device + * @pdev: platform device we're adding + * + */ +int platform_device_register(struct platform_device * pdev) +{ + device_initialize(&pdev->dev); + return platform_device_add(pdev); +} + +/** + * platform_device_unregister - unregister a platform-level device + * @pdev: platform device we're unregistering + * + * Unregistration is done in 2 steps. Fisrt we release all resources + * and remove it from the sybsystem, then we drop reference count by + * calling platform_device_put(). + */ +void platform_device_unregister(struct platform_device * pdev) +{ + platform_device_del(pdev); + platform_device_put(pdev); +} /** * platform_device_register_simple diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 17e336f..782090c 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -41,6 +41,7 @@ extern struct platform_device *platform_device_alloc(const char *name, unsigned extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); extern int platform_device_add_data(struct platform_device *pdev, void *data, size_t size); extern int platform_device_add(struct platform_device *pdev); +extern void platform_device_del(struct platform_device *pdev); extern void platform_device_put(struct platform_device *pdev); struct platform_driver { -- cgit v1.1 From a96b204208443ab7e23c681f7ddabe807a741d0c Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sat, 10 Dec 2005 01:36:28 -0500 Subject: [PATCH] Driver Core: Rearrange exports in platform.c Driver core: rearrange exports in platform.c The new way is to specify export right after symbol definition. Rearrange exports to follow new style to avoid mixing two styles in one file. Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 95ecfc4..0f81731 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -25,6 +25,7 @@ struct device platform_bus = { .bus_id = "platform", }; +EXPORT_SYMBOL_GPL(platform_bus); /** * platform_get_resource - get a resource for a device @@ -49,6 +50,7 @@ platform_get_resource(struct platform_device *dev, unsigned int type, } return NULL; } +EXPORT_SYMBOL_GPL(platform_get_resource); /** * platform_get_irq - get an IRQ for a device @@ -61,6 +63,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) return r ? r->start : 0; } +EXPORT_SYMBOL_GPL(platform_get_irq); /** * platform_get_resource_byname - get a resource for a device by name @@ -84,6 +87,7 @@ platform_get_resource_byname(struct platform_device *dev, unsigned int type, } return NULL; } +EXPORT_SYMBOL_GPL(platform_get_resource_byname); /** * platform_get_irq - get an IRQ for a device @@ -96,6 +100,7 @@ int platform_get_irq_byname(struct platform_device *dev, char *name) return r ? r->start : 0; } +EXPORT_SYMBOL_GPL(platform_get_irq_byname); /** * platform_add_devices - add a numbers of platform devices @@ -117,6 +122,7 @@ int platform_add_devices(struct platform_device **devs, int num) return ret; } +EXPORT_SYMBOL_GPL(platform_add_devices); struct platform_object { struct platform_device pdev; @@ -314,6 +320,7 @@ int platform_device_register(struct platform_device * pdev) device_initialize(&pdev->dev); return platform_device_add(pdev); } +EXPORT_SYMBOL_GPL(platform_device_register); /** * platform_device_unregister - unregister a platform-level device @@ -328,6 +335,7 @@ void platform_device_unregister(struct platform_device * pdev) platform_device_del(pdev); platform_device_put(pdev); } +EXPORT_SYMBOL_GPL(platform_device_unregister); /** * platform_device_register_simple @@ -370,6 +378,7 @@ error: platform_device_put(pdev); return ERR_PTR(retval); } +EXPORT_SYMBOL_GPL(platform_device_register_simple); static int platform_drv_probe(struct device *_dev) { @@ -491,6 +500,7 @@ struct bus_type platform_bus_type = { .suspend = platform_suspend, .resume = platform_resume, }; +EXPORT_SYMBOL_GPL(platform_bus_type); int __init platform_bus_init(void) { @@ -519,14 +529,3 @@ u64 dma_get_required_mask(struct device *dev) } EXPORT_SYMBOL_GPL(dma_get_required_mask); #endif - -EXPORT_SYMBOL_GPL(platform_bus); -EXPORT_SYMBOL_GPL(platform_bus_type); -EXPORT_SYMBOL_GPL(platform_add_devices); -EXPORT_SYMBOL_GPL(platform_device_register); -EXPORT_SYMBOL_GPL(platform_device_register_simple); -EXPORT_SYMBOL_GPL(platform_device_unregister); -EXPORT_SYMBOL_GPL(platform_get_irq); -EXPORT_SYMBOL_GPL(platform_get_resource); -EXPORT_SYMBOL_GPL(platform_get_irq_byname); -EXPORT_SYMBOL_GPL(platform_get_resource_byname); -- cgit v1.1 From 874c6241b2e49e52680d32a50d4909c7768d5cb9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 13 Dec 2005 15:17:34 -0800 Subject: [PATCH] Driver core: only all userspace bind/unbind if CONFIG_HOTPLUG is enabled Thanks to drivers making their id tables __devinit, we can't allow userspace to bind or unbind drivers from devices manually through sysfs. So we only allow this if CONFIG_HOTPLUG is enabled. Cc: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/base/bus.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index e3f915a..29f6af5 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -428,6 +428,26 @@ static void driver_remove_attrs(struct bus_type * bus, struct device_driver * dr } } +#ifdef CONFIG_HOTPLUG +/* + * Thanks to drivers making their tables __devinit, we can't allow manual + * bind and unbind from userspace unless CONFIG_HOTPLUG is enabled. + */ +static void add_bind_files(struct device_driver *drv) +{ + driver_create_file(drv, &driver_attr_unbind); + driver_create_file(drv, &driver_attr_bind); +} + +static void remove_bind_files(struct device_driver *drv) +{ + driver_remove_file(drv, &driver_attr_bind); + driver_remove_file(drv, &driver_attr_unbind); +} +#else +static inline void add_bind_files(struct device_driver *drv) {} +static inline void remove_bind_files(struct device_driver *drv) {} +#endif /** * bus_add_driver - Add a driver to the bus. @@ -457,8 +477,7 @@ int bus_add_driver(struct device_driver * drv) module_add_driver(drv->owner, drv); driver_add_attrs(bus, drv); - driver_create_file(drv, &driver_attr_unbind); - driver_create_file(drv, &driver_attr_bind); + add_bind_files(drv); } return error; } @@ -476,8 +495,7 @@ int bus_add_driver(struct device_driver * drv) void bus_remove_driver(struct device_driver * drv) { if (drv->bus) { - driver_remove_file(drv, &driver_attr_bind); - driver_remove_file(drv, &driver_attr_unbind); + remove_bind_files(drv); driver_remove_attrs(drv->bus, drv); klist_remove(&drv->knode_bus); pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); -- cgit v1.1 From 8218ef80932aa7e5e3d20c929a640c8d82133a9a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 13 Dec 2005 15:17:34 -0800 Subject: [PATCH] Driver core: Make block devices create the proper symlink name Block devices need to add the block device name to the symlink they put in the device directory, otherwise multiple symlinks of the same name can be created. This matches the class system, which works the same way, we just forgot to convert block at the same time. Cc: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman --- fs/partitions/check.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 7187a57..7881ce0 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c @@ -336,12 +336,31 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len) disk->part[part-1] = p; } +static char *make_block_name(struct gendisk *disk) +{ + char *name; + static char *block_str = "block:"; + int size; + + size = strlen(block_str) + strlen(disk->disk_name) + 1; + name = kmalloc(size, GFP_KERNEL); + if (!name) + return NULL; + strcpy(name, block_str); + strcat(name, disk->disk_name); + return name; +} + static void disk_sysfs_symlinks(struct gendisk *disk) { struct device *target = get_device(disk->driverfs_dev); if (target) { + char *disk_name = make_block_name(disk); sysfs_create_link(&disk->kobj,&target->kobj,"device"); - sysfs_create_link(&target->kobj,&disk->kobj,"block"); + if (disk_name) { + sysfs_create_link(&target->kobj,&disk->kobj,disk_name); + kfree(disk_name); + } } } @@ -461,8 +480,12 @@ void del_gendisk(struct gendisk *disk) devfs_remove_disk(disk); if (disk->driverfs_dev) { + char *disk_name = make_block_name(disk); sysfs_remove_link(&disk->kobj, "device"); - sysfs_remove_link(&disk->driverfs_dev->kobj, "block"); + if (disk_name) { + sysfs_remove_link(&disk->driverfs_dev->kobj, disk_name); + kfree(disk_name); + } put_device(disk->driverfs_dev); } kobject_uevent(&disk->kobj, KOBJ_REMOVE); -- cgit v1.1 From e80a5dea8e056d8f398be1900d61c581d379f02f Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Wed, 23 Nov 2005 09:15:44 -0500 Subject: [PATCH] sysfs: handle failures in sysfs_make_dirent I noticed that if sysfs_make_dirent fails to allocate the sd, then a null will be passed to sysfs_put. Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 59734ba..d367803 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -112,7 +112,11 @@ static int create_dir(struct kobject * k, struct dentry * p, } } if (error && (error != -EEXIST)) { - sysfs_put((*d)->d_fsdata); + struct sysfs_dirent *sd = (*d)->d_fsdata; + if (sd) { + list_del_init(&sd->s_sibling); + sysfs_put(sd); + } d_drop(*d); } dput(*d); -- cgit v1.1 From 1f1bf132d81ed723bc5fefbcec7d0779ce683a4f Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 12 Dec 2005 01:31:03 -0800 Subject: [PATCH] drivers/base/power/runtime.c: #if 0 dpm_set_power_state() This patch #if 0's an unused global function. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/base/power/runtime.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index adbc3148..4bafef8 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -64,6 +64,7 @@ int dpm_runtime_suspend(struct device * dev, pm_message_t state) } +#if 0 /** * dpm_set_power_state - Update power_state field. * @dev: Device. @@ -80,3 +81,4 @@ void dpm_set_power_state(struct device * dev, pm_message_t state) dev->power.power_state = state; up(&dpm_sem); } +#endif /* 0 */ -- cgit v1.1 From fd586bacf439f36dea9b9bf6e6133ac87df2730c Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Mon, 19 Dec 2005 01:42:56 +0100 Subject: [PATCH] net: swich device attribute creation to default attrs Recent udev versions don't longer cover bad sysfs timing with built-in logic. Explicit rules are required to do that. For net devices, the following is needed: ACTION=="add", SUBSYSTEM=="net", WAIT_FOR_SYSFS="address" to handle access to net device properties from an event handler without races. This patch changes the main net attributes to be created by the driver core, which is done _before_ the event is sent out and will not require the stat() loop of the WAIT_FOR_SYSFS key. Signed-off-by: Kay Sievers Acked-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/net-sysfs.c | 68 ++++++++++++++++------------------------------------ 1 file changed, 21 insertions(+), 47 deletions(-) diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 198655d..e1da81d 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -84,16 +84,11 @@ static ssize_t netdev_store(struct class_device *dev, return ret; } -/* generate a read-only network device class attribute */ -#define NETDEVICE_ATTR(field, format_string) \ -NETDEVICE_SHOW(field, format_string) \ -static CLASS_DEVICE_ATTR(field, S_IRUGO, show_##field, NULL) \ - -NETDEVICE_ATTR(addr_len, fmt_dec); -NETDEVICE_ATTR(iflink, fmt_dec); -NETDEVICE_ATTR(ifindex, fmt_dec); -NETDEVICE_ATTR(features, fmt_long_hex); -NETDEVICE_ATTR(type, fmt_dec); +NETDEVICE_SHOW(addr_len, fmt_dec); +NETDEVICE_SHOW(iflink, fmt_dec); +NETDEVICE_SHOW(ifindex, fmt_dec); +NETDEVICE_SHOW(features, fmt_long_hex); +NETDEVICE_SHOW(type, fmt_dec); /* use same locking rules as GIFHWADDR ioctl's */ static ssize_t format_addr(char *buf, const unsigned char *addr, int len) @@ -136,10 +131,6 @@ static ssize_t show_carrier(struct class_device *dev, char *buf) return -EINVAL; } -static CLASS_DEVICE_ATTR(address, S_IRUGO, show_address, NULL); -static CLASS_DEVICE_ATTR(broadcast, S_IRUGO, show_broadcast, NULL); -static CLASS_DEVICE_ATTR(carrier, S_IRUGO, show_carrier, NULL); - /* read-write attributes */ NETDEVICE_SHOW(mtu, fmt_dec); @@ -153,8 +144,6 @@ static ssize_t store_mtu(struct class_device *dev, const char *buf, size_t len) return netdev_store(dev, buf, len, change_mtu); } -static CLASS_DEVICE_ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu); - NETDEVICE_SHOW(flags, fmt_hex); static int change_flags(struct net_device *net, unsigned long new_flags) @@ -167,8 +156,6 @@ static ssize_t store_flags(struct class_device *dev, const char *buf, size_t len return netdev_store(dev, buf, len, change_flags); } -static CLASS_DEVICE_ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags); - NETDEVICE_SHOW(tx_queue_len, fmt_ulong); static int change_tx_queue_len(struct net_device *net, unsigned long new_len) @@ -182,9 +169,6 @@ static ssize_t store_tx_queue_len(struct class_device *dev, const char *buf, siz return netdev_store(dev, buf, len, change_tx_queue_len); } -static CLASS_DEVICE_ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, - store_tx_queue_len); - NETDEVICE_SHOW(weight, fmt_dec); static int change_weight(struct net_device *net, unsigned long new_weight) @@ -198,24 +182,21 @@ static ssize_t store_weight(struct class_device *dev, const char *buf, size_t le return netdev_store(dev, buf, len, change_weight); } -static CLASS_DEVICE_ATTR(weight, S_IRUGO | S_IWUSR, show_weight, - store_weight); - - -static struct class_device_attribute *net_class_attributes[] = { - &class_device_attr_ifindex, - &class_device_attr_iflink, - &class_device_attr_addr_len, - &class_device_attr_tx_queue_len, - &class_device_attr_features, - &class_device_attr_mtu, - &class_device_attr_flags, - &class_device_attr_weight, - &class_device_attr_type, - &class_device_attr_address, - &class_device_attr_broadcast, - &class_device_attr_carrier, - NULL +static struct class_device_attribute net_class_attributes[] = { + __ATTR(addr_len, S_IRUGO, show_addr_len, NULL), + __ATTR(iflink, S_IRUGO, show_iflink, NULL), + __ATTR(ifindex, S_IRUGO, show_ifindex, NULL), + __ATTR(features, S_IRUGO, show_features, NULL), + __ATTR(type, S_IRUGO, show_type, NULL), + __ATTR(address, S_IRUGO, show_address, NULL), + __ATTR(broadcast, S_IRUGO, show_broadcast, NULL), + __ATTR(carrier, S_IRUGO, show_carrier, NULL), + __ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu), + __ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags), + __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, + store_tx_queue_len), + __ATTR(weight, S_IRUGO | S_IWUSR, show_weight, store_weight), + {} }; /* Show a given an attribute in the statistics group */ @@ -407,6 +388,7 @@ static void netdev_release(struct class_device *cd) static struct class net_class = { .name = "net", .release = netdev_release, + .class_dev_attrs = net_class_attributes, #ifdef CONFIG_HOTPLUG .uevent = netdev_uevent, #endif @@ -431,8 +413,6 @@ void netdev_unregister_sysfs(struct net_device * net) int netdev_register_sysfs(struct net_device *net) { struct class_device *class_dev = &(net->class_dev); - int i; - struct class_device_attribute *attr; int ret; class_dev->class = &net_class; @@ -442,12 +422,6 @@ int netdev_register_sysfs(struct net_device *net) if ((ret = class_device_register(class_dev))) goto out; - for (i = 0; (attr = net_class_attributes[i]) != NULL; i++) { - if ((ret = class_device_create_file(class_dev, attr))) - goto out_unreg; - } - - if (net->get_stats && (ret = sysfs_create_group(&class_dev->kobj, &netstat_group))) goto out_unreg; -- cgit v1.1 From e28cc71572da38a5a12c1cfe4d7032017adccf69 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 4 Jan 2006 16:20:40 -0800 Subject: Relax the rw_verify_area() error checking. In particular, allow over-large read- or write-requests to be downgraded to a more reasonable range, rather than considering them outright errors. We want to protect lower layers from (the sadly all too common) overflow conditions, but prefer to do so by chopping the requests up, rather than just refusing them outright. Cc: Peter Anvin Cc: Ulrich Drepper Cc: Andi Kleen Cc: Al Viro Signed-off-by: Linus Torvalds --- arch/mips/kernel/linux32.c | 4 ++-- fs/compat.c | 2 +- fs/read_write.c | 34 +++++++++++++++++++++++++--------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index 330cf84..60353f5 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c @@ -420,7 +420,7 @@ asmlinkage ssize_t sys32_pread(unsigned int fd, char * buf, goto out; pos = merge_64(a4, a5); ret = rw_verify_area(READ, file, &pos, count); - if (ret) + if (ret < 0) goto out; ret = -EINVAL; if (!file->f_op || !(read = file->f_op->read)) @@ -455,7 +455,7 @@ asmlinkage ssize_t sys32_pwrite(unsigned int fd, const char * buf, goto out; pos = merge_64(a4, a5); ret = rw_verify_area(WRITE, file, &pos, count); - if (ret) + if (ret < 0) goto out; ret = -EINVAL; if (!file->f_op || !(write = file->f_op->write)) diff --git a/fs/compat.c b/fs/compat.c index 8186341..55ac032 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -1170,7 +1170,7 @@ static ssize_t compat_do_readv_writev(int type, struct file *file, } ret = rw_verify_area(type, file, pos, tot_len); - if (ret) + if (ret < 0) goto out; fnv = NULL; diff --git a/fs/read_write.c b/fs/read_write.c index a091ee4..df3468a 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -182,22 +183,33 @@ bad: } #endif +/* + * rw_verify_area doesn't like huge counts. We limit + * them to something that fits in "int" so that others + * won't have to do range checks all the time. + */ +#define MAX_RW_COUNT (INT_MAX & PAGE_CACHE_MASK) int rw_verify_area(int read_write, struct file *file, loff_t *ppos, size_t count) { struct inode *inode; loff_t pos; - if (unlikely(count > INT_MAX)) + if (unlikely((ssize_t) count < 0)) goto Einval; pos = *ppos; if (unlikely((pos < 0) || (loff_t) (pos + count) < 0)) goto Einval; inode = file->f_dentry->d_inode; - if (inode->i_flock && MANDATORY_LOCK(inode)) - return locks_mandatory_area(read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE, inode, file, pos, count); - return 0; + if (inode->i_flock && MANDATORY_LOCK(inode)) { + int retval = locks_mandatory_area( + read_write == READ ? FLOCK_VERIFY_READ : FLOCK_VERIFY_WRITE, + inode, file, pos, count); + if (retval < 0) + return retval; + } + return count > MAX_RW_COUNT ? MAX_RW_COUNT : count; Einval: return -EINVAL; @@ -244,7 +256,8 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos) return -EFAULT; ret = rw_verify_area(READ, file, pos, count); - if (!ret) { + if (ret >= 0) { + count = ret; ret = security_file_permission (file, MAY_READ); if (!ret) { if (file->f_op->read) @@ -295,7 +308,8 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_ return -EFAULT; ret = rw_verify_area(WRITE, file, pos, count); - if (!ret) { + if (ret >= 0) { + count = ret; ret = security_file_permission (file, MAY_WRITE); if (!ret) { if (file->f_op->write) @@ -497,7 +511,7 @@ static ssize_t do_readv_writev(int type, struct file *file, } ret = rw_verify_area(type, file, pos, tot_len); - if (ret) + if (ret < 0) goto out; ret = security_file_permission(file, type == READ ? MAY_READ : MAY_WRITE); if (ret) @@ -653,8 +667,9 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, if (!(in_file->f_mode & FMODE_PREAD)) goto fput_in; retval = rw_verify_area(READ, in_file, ppos, count); - if (retval) + if (retval < 0) goto fput_in; + count = retval; retval = security_file_permission (in_file, MAY_READ); if (retval) @@ -674,8 +689,9 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, goto fput_out; out_inode = out_file->f_dentry->d_inode; retval = rw_verify_area(WRITE, out_file, &out_file->f_pos, count); - if (retval) + if (retval < 0) goto fput_out; + count = retval; retval = security_file_permission (out_file, MAY_WRITE); if (retval) -- cgit v1.1 From 3adfd4e2b8804e926a5245062ba8ee12e88d30c3 Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Tue, 3 Jan 2006 12:50:30 -0800 Subject: [PATCH] Fix IXP4xx watchdog errata workaround The IXP4xx driver bails out on all A0 CPUs, but it should only do so on IXP42x as IXP46x has functioning HW. Signed-off-by: Deepak Saxena Signed-off-by: Linus Torvalds --- drivers/char/watchdog/ixp4xx_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/watchdog/ixp4xx_wdt.c b/drivers/char/watchdog/ixp4xx_wdt.c index b5be8b1..3800835 100644 --- a/drivers/char/watchdog/ixp4xx_wdt.c +++ b/drivers/char/watchdog/ixp4xx_wdt.c @@ -186,8 +186,8 @@ static int __init ixp4xx_wdt_init(void) unsigned long processor_id; asm("mrc p15, 0, %0, cr0, cr0, 0;" : "=r"(processor_id) :); - if (!(processor_id & 0xf)) { - printk("IXP4XXX Watchdog: Rev. A0 CPU detected - " + if (!(processor_id & 0xf) && !cpu_is_ixp46x()) { + printk("IXP4XXX Watchdog: Rev. A0 IXP42x CPU detected - " "watchdog disabled\n"); return -ENODEV; -- cgit v1.1 From 631b034724364b413e8a52e7c2e03a9d77e4c2b4 Mon Sep 17 00:00:00 2001 From: Chuck Ebbert <76306.1226@compuserve.com> Date: Tue, 3 Jan 2006 22:36:14 -0500 Subject: [PATCH] i386: "invalid operand" -> "invalid opcode" According to the manual, INT 6 is "invalid opcode", not "invalid operand". Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com> Signed-off-by: Linus Torvalds --- arch/i386/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c index f0dffa0..ab0e943 100644 --- a/arch/i386/kernel/traps.c +++ b/arch/i386/kernel/traps.c @@ -452,7 +452,7 @@ DO_VM86_ERROR( 3, SIGTRAP, "int3", int3) #endif DO_VM86_ERROR( 4, SIGSEGV, "overflow", overflow) DO_VM86_ERROR( 5, SIGSEGV, "bounds", bounds) -DO_ERROR_INFO( 6, SIGILL, "invalid operand", invalid_op, ILL_ILLOPN, regs->eip) +DO_ERROR_INFO( 6, SIGILL, "invalid opcode", invalid_op, ILL_ILLOPN, regs->eip) DO_ERROR( 9, SIGFPE, "coprocessor segment overrun", coprocessor_segment_overrun) DO_ERROR(10, SIGSEGV, "invalid TSS", invalid_TSS) DO_ERROR(11, SIGBUS, "segment not present", segment_not_present) -- cgit v1.1 From 4ffd2e4907184813101cefa7196102927cdbe104 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 5 Jan 2006 12:14:43 -0800 Subject: [IPVS]: Fix compilation Signed-off-by: Adrian Bunk Acked-by: Arnaldo Carvalho de Melo Signed-off-by: David S. Miller --- net/ipv4/ipvs/ip_vs_est.c | 1 + net/ipv4/ipvs/ip_vs_sched.c | 1 + 2 files changed, 2 insertions(+) diff --git a/net/ipv4/ipvs/ip_vs_est.c b/net/ipv4/ipvs/ip_vs_est.c index e700474..c453e1e 100644 --- a/net/ipv4/ipvs/ip_vs_est.c +++ b/net/ipv4/ipvs/ip_vs_est.c @@ -18,6 +18,7 @@ #include #include #include +#include #include diff --git a/net/ipv4/ipvs/ip_vs_sched.c b/net/ipv4/ipvs/ip_vs_sched.c index 0f7c56a..8bc42b7 100644 --- a/net/ipv4/ipvs/ip_vs_sched.c +++ b/net/ipv4/ipvs/ip_vs_sched.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include -- cgit v1.1 From 3e4ead4fe5d0d9fdd7ad6749e6e608d39dd46e8a Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Thu, 5 Jan 2006 12:15:58 -0800 Subject: [NETFILTER]: Decrease number of pointer derefs in nfnetlink_queue.c Benefits of the patch: - Fewer pointer dereferences should make the code slightly faster. - Size of generated code is smaller - improved readability Signed-off-by: Jesper Juhl Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/netfilter/nfnetlink_queue.c | 79 +++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index 55afdda..18ed9c5 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c @@ -345,6 +345,10 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, struct nfqnl_msg_packet_hdr pmsg; struct nlmsghdr *nlh; struct nfgenmsg *nfmsg; + struct nf_info *entinf = entry->info; + struct sk_buff *entskb = entry->skb; + struct net_device *indev; + struct net_device *outdev; unsigned int tmp_uint; QDEBUG("entered\n"); @@ -361,6 +365,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, + NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hw)) + NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_timestamp)); + outdev = entinf->outdev; + spin_lock_bh(&queue->lock); switch (queue->copy_mode) { @@ -370,15 +376,15 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, break; case NFQNL_COPY_PACKET: - if (entry->skb->ip_summed == CHECKSUM_HW && - (*errp = skb_checksum_help(entry->skb, - entry->info->outdev == NULL))) { + if (entskb->ip_summed == CHECKSUM_HW && + (*errp = skb_checksum_help(entskb, + outdev == NULL))) { spin_unlock_bh(&queue->lock); return NULL; } if (queue->copy_range == 0 - || queue->copy_range > entry->skb->len) - data_len = entry->skb->len; + || queue->copy_range > entskb->len) + data_len = entskb->len; else data_len = queue->copy_range; @@ -402,29 +408,30 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, NFNL_SUBSYS_QUEUE << 8 | NFQNL_MSG_PACKET, sizeof(struct nfgenmsg)); nfmsg = NLMSG_DATA(nlh); - nfmsg->nfgen_family = entry->info->pf; + nfmsg->nfgen_family = entinf->pf; nfmsg->version = NFNETLINK_V0; nfmsg->res_id = htons(queue->queue_num); pmsg.packet_id = htonl(entry->id); - pmsg.hw_protocol = htons(entry->skb->protocol); - pmsg.hook = entry->info->hook; + pmsg.hw_protocol = htons(entskb->protocol); + pmsg.hook = entinf->hook; NFA_PUT(skb, NFQA_PACKET_HDR, sizeof(pmsg), &pmsg); - if (entry->info->indev) { - tmp_uint = htonl(entry->info->indev->ifindex); + indev = entinf->indev; + if (indev) { + tmp_uint = htonl(indev->ifindex); #ifndef CONFIG_BRIDGE_NETFILTER NFA_PUT(skb, NFQA_IFINDEX_INDEV, sizeof(tmp_uint), &tmp_uint); #else - if (entry->info->pf == PF_BRIDGE) { + if (entinf->pf == PF_BRIDGE) { /* Case 1: indev is physical input device, we need to * look for bridge group (when called from * netfilter_bridge) */ NFA_PUT(skb, NFQA_IFINDEX_PHYSINDEV, sizeof(tmp_uint), &tmp_uint); /* this is the bridge group "brX" */ - tmp_uint = htonl(entry->info->indev->br_port->br->dev->ifindex); + tmp_uint = htonl(indev->br_port->br->dev->ifindex); NFA_PUT(skb, NFQA_IFINDEX_INDEV, sizeof(tmp_uint), &tmp_uint); } else { @@ -432,9 +439,9 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, * physical device (when called from ipv4) */ NFA_PUT(skb, NFQA_IFINDEX_INDEV, sizeof(tmp_uint), &tmp_uint); - if (entry->skb->nf_bridge - && entry->skb->nf_bridge->physindev) { - tmp_uint = htonl(entry->skb->nf_bridge->physindev->ifindex); + if (entskb->nf_bridge + && entskb->nf_bridge->physindev) { + tmp_uint = htonl(entskb->nf_bridge->physindev->ifindex); NFA_PUT(skb, NFQA_IFINDEX_PHYSINDEV, sizeof(tmp_uint), &tmp_uint); } @@ -442,19 +449,19 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, #endif } - if (entry->info->outdev) { - tmp_uint = htonl(entry->info->outdev->ifindex); + if (outdev) { + tmp_uint = htonl(outdev->ifindex); #ifndef CONFIG_BRIDGE_NETFILTER NFA_PUT(skb, NFQA_IFINDEX_OUTDEV, sizeof(tmp_uint), &tmp_uint); #else - if (entry->info->pf == PF_BRIDGE) { + if (entinf->pf == PF_BRIDGE) { /* Case 1: outdev is physical output device, we need to * look for bridge group (when called from * netfilter_bridge) */ NFA_PUT(skb, NFQA_IFINDEX_PHYSOUTDEV, sizeof(tmp_uint), &tmp_uint); /* this is the bridge group "brX" */ - tmp_uint = htonl(entry->info->outdev->br_port->br->dev->ifindex); + tmp_uint = htonl(outdev->br_port->br->dev->ifindex); NFA_PUT(skb, NFQA_IFINDEX_OUTDEV, sizeof(tmp_uint), &tmp_uint); } else { @@ -462,9 +469,9 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, * physical output device (when called from ipv4) */ NFA_PUT(skb, NFQA_IFINDEX_OUTDEV, sizeof(tmp_uint), &tmp_uint); - if (entry->skb->nf_bridge - && entry->skb->nf_bridge->physoutdev) { - tmp_uint = htonl(entry->skb->nf_bridge->physoutdev->ifindex); + if (entskb->nf_bridge + && entskb->nf_bridge->physoutdev) { + tmp_uint = htonl(entskb->nf_bridge->physoutdev->ifindex); NFA_PUT(skb, NFQA_IFINDEX_PHYSOUTDEV, sizeof(tmp_uint), &tmp_uint); } @@ -472,27 +479,27 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, #endif } - if (entry->skb->nfmark) { - tmp_uint = htonl(entry->skb->nfmark); + if (entskb->nfmark) { + tmp_uint = htonl(entskb->nfmark); NFA_PUT(skb, NFQA_MARK, sizeof(u_int32_t), &tmp_uint); } - if (entry->info->indev && entry->skb->dev - && entry->skb->dev->hard_header_parse) { + if (indev && entskb->dev + && entskb->dev->hard_header_parse) { struct nfqnl_msg_packet_hw phw; phw.hw_addrlen = - entry->skb->dev->hard_header_parse(entry->skb, + entskb->dev->hard_header_parse(entskb, phw.hw_addr); phw.hw_addrlen = htons(phw.hw_addrlen); NFA_PUT(skb, NFQA_HWADDR, sizeof(phw), &phw); } - if (entry->skb->tstamp.off_sec) { + if (entskb->tstamp.off_sec) { struct nfqnl_msg_packet_timestamp ts; - ts.sec = cpu_to_be64(entry->skb->tstamp.off_sec); - ts.usec = cpu_to_be64(entry->skb->tstamp.off_usec); + ts.sec = cpu_to_be64(entskb->tstamp.off_sec); + ts.usec = cpu_to_be64(entskb->tstamp.off_usec); NFA_PUT(skb, NFQA_TIMESTAMP, sizeof(ts), &ts); } @@ -510,7 +517,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, nfa->nfa_type = NFQA_PAYLOAD; nfa->nfa_len = size; - if (skb_copy_bits(entry->skb, 0, NFA_DATA(nfa), data_len)) + if (skb_copy_bits(entskb, 0, NFA_DATA(nfa), data_len)) BUG(); } @@ -667,12 +674,14 @@ nfqnl_set_mode(struct nfqnl_instance *queue, static int dev_cmp(struct nfqnl_queue_entry *entry, unsigned long ifindex) { - if (entry->info->indev) - if (entry->info->indev->ifindex == ifindex) + struct nf_info *entinf = entry->info; + + if (entinf->indev) + if (entinf->indev->ifindex == ifindex) return 1; - if (entry->info->outdev) - if (entry->info->outdev->ifindex == ifindex) + if (entinf->outdev) + if (entinf->outdev->ifindex == ifindex) return 1; return 0; -- cgit v1.1 From d695aa8a1f133359485e15db06d53e15e7309e4d Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Thu, 5 Jan 2006 12:16:16 -0800 Subject: [NETFILTER]: Decrease number of pointer derefs in nf_conntrack_core.c Benefits of the patch: - Fewer pointer dereferences should make the code slightly faster. - Size of generated code is smaller - improved readability Signed-off-by: Jesper Juhl Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/netfilter/nf_conntrack_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index a7c7b49..0c5b01d 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -1129,6 +1129,7 @@ static inline int refresh_timer(struct nf_conntrack_expect *i) int nf_conntrack_expect_related(struct nf_conntrack_expect *expect) { struct nf_conntrack_expect *i; + struct nf_conn *master = expect->master; int ret; DEBUGP("nf_conntrack_expect_related %p\n", related_to); @@ -1149,9 +1150,9 @@ int nf_conntrack_expect_related(struct nf_conntrack_expect *expect) } } /* Will be over limit? */ - if (expect->master->helper->max_expected && - expect->master->expecting >= expect->master->helper->max_expected) - evict_oldest_expect(expect->master); + if (master->helper->max_expected && + master->expecting >= master->helper->max_expected) + evict_oldest_expect(master); nf_conntrack_expect_insert(expect); nf_conntrack_expect_event(IPEXP_NEW, expect); -- cgit v1.1 From 684f7b296c0cb8238ce63f1828d33a00d5f3a26e Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Jan 2006 12:16:41 -0800 Subject: [NETFILTER]: ctnetlink: remove bogus checks in ICMP protocol at dumping Signed-off-by: Pablo Neira Ayuso Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_proto_icmp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c index 5f9925d..19cc550 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c @@ -279,10 +279,6 @@ static int icmp_tuple_to_nfattr(struct sk_buff *skb, NFA_PUT(skb, CTA_PROTO_ICMP_CODE, sizeof(u_int8_t), &t->dst.u.icmp.code); - if (t->dst.u.icmp.type >= sizeof(valid_new) - || !valid_new[t->dst.u.icmp.type]) - return -EINVAL; - return 0; nfattr_failure: -- cgit v1.1 From 90c4656eb4871c47a5d9fe7050590c9bb8b78b5a Mon Sep 17 00:00:00 2001 From: Yasuyuki Kozakai Date: Thu, 5 Jan 2006 12:17:03 -0800 Subject: [NETFILTER]: ctnetlink: Add sanity checkings for ICMP Signed-off-by: Yasuyuki Kozakai Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_proto_icmp.c | 43 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c index 19cc550..30fc21d 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c @@ -47,20 +47,21 @@ static int icmp_pkt_to_tuple(const struct sk_buff *skb, return 1; } +/* Add 1; spaces filled with 0. */ +static const u_int8_t invmap[] = { + [ICMP_ECHO] = ICMP_ECHOREPLY + 1, + [ICMP_ECHOREPLY] = ICMP_ECHO + 1, + [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1, + [ICMP_TIMESTAMPREPLY] = ICMP_TIMESTAMP + 1, + [ICMP_INFO_REQUEST] = ICMP_INFO_REPLY + 1, + [ICMP_INFO_REPLY] = ICMP_INFO_REQUEST + 1, + [ICMP_ADDRESS] = ICMP_ADDRESSREPLY + 1, + [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 1 +}; + static int icmp_invert_tuple(struct ip_conntrack_tuple *tuple, const struct ip_conntrack_tuple *orig) { - /* Add 1; spaces filled with 0. */ - static const u_int8_t invmap[] - = { [ICMP_ECHO] = ICMP_ECHOREPLY + 1, - [ICMP_ECHOREPLY] = ICMP_ECHO + 1, - [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1, - [ICMP_TIMESTAMPREPLY] = ICMP_TIMESTAMP + 1, - [ICMP_INFO_REQUEST] = ICMP_INFO_REPLY + 1, - [ICMP_INFO_REPLY] = ICMP_INFO_REQUEST + 1, - [ICMP_ADDRESS] = ICMP_ADDRESSREPLY + 1, - [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 1}; - if (orig->dst.u.icmp.type >= sizeof(invmap) || !invmap[orig->dst.u.icmp.type]) return 0; @@ -110,17 +111,17 @@ static int icmp_packet(struct ip_conntrack *ct, return NF_ACCEPT; } -static const u_int8_t valid_new[] = { - [ICMP_ECHO] = 1, - [ICMP_TIMESTAMP] = 1, - [ICMP_INFO_REQUEST] = 1, - [ICMP_ADDRESS] = 1 -}; - /* Called when a new connection for this protocol found. */ static int icmp_new(struct ip_conntrack *conntrack, const struct sk_buff *skb) { + static const u_int8_t valid_new[] = { + [ICMP_ECHO] = 1, + [ICMP_TIMESTAMP] = 1, + [ICMP_INFO_REQUEST] = 1, + [ICMP_ADDRESS] = 1 + }; + if (conntrack->tuplehash[0].tuple.dst.u.icmp.type >= sizeof(valid_new) || !valid_new[conntrack->tuplehash[0].tuple.dst.u.icmp.type]) { /* Can't create a new ICMP `conn' with this. */ @@ -291,7 +292,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[], if (!tb[CTA_PROTO_ICMP_TYPE-1] || !tb[CTA_PROTO_ICMP_CODE-1] || !tb[CTA_PROTO_ICMP_ID-1]) - return -1; + return -EINVAL; tuple->dst.u.icmp.type = *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_TYPE-1]); @@ -300,6 +301,10 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[], tuple->src.u.icmp.id = *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]); + if (tuple->dst.u.icmp.type >= sizeof(invmap) + || !invmap[tuple->dst.u.icmp.type]) + return -EINVAL; + return 0; } #endif -- cgit v1.1 From 984955b3d7f9943becf9915601f49a1fb7a41f7a Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Jan 2006 12:17:29 -0800 Subject: [NETFILTER]: ctnetlink: propagate ctnetlink_dump_tuples_proto return value back Signed-off-by: Pablo Neira Ayuso Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_netlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index 91fe8f2..5e9affd 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c @@ -79,6 +79,7 @@ ctnetlink_dump_tuples(struct sk_buff *skb, const struct ip_conntrack_tuple *tuple) { struct nfattr *nest_parms; + int ret; nest_parms = NFA_NEST(skb, CTA_TUPLE_IP); NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), &tuple->src.ip); @@ -86,10 +87,10 @@ ctnetlink_dump_tuples(struct sk_buff *skb, NFA_NEST_END(skb, nest_parms); nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO); - ctnetlink_dump_tuples_proto(skb, tuple); + ret = ctnetlink_dump_tuples_proto(skb, tuple); NFA_NEST_END(skb, nest_parms); - return 0; + return ret; nfattr_failure: return -1; -- cgit v1.1 From 47116eb201571ad1198a8d76dc3571e85ba7c8c9 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Jan 2006 12:17:50 -0800 Subject: [NETFILTER]: ctnetlink: use u_int32_t instead of unsigned int Signed-off-by: Pablo Neira Ayuso Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index 5e9affd..faa027b 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c @@ -230,7 +230,7 @@ nfattr_failure: static inline int ctnetlink_dump_use(struct sk_buff *skb, const struct ip_conntrack *ct) { - unsigned int use = htonl(atomic_read(&ct->ct_general.use)); + u_int32_t use = htonl(atomic_read(&ct->ct_general.use)); NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use); return 0; -- cgit v1.1 From 0368309cb45bbba99f84a01d5fc6a18780788480 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Jan 2006 12:18:08 -0800 Subject: [NETFILTER]: ctnetlink: ctnetlink_event cleanup Cleanup: Use 'else if' instead of a ugly 'goto' statement. Signed-off-by: Pablo Neira Ayuso Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_netlink.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index faa027b..04137d0 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c @@ -312,29 +312,22 @@ static int ctnetlink_conntrack_event(struct notifier_block *this, if (events & IPCT_DESTROY) { type = IPCTNL_MSG_CT_DELETE; group = NFNLGRP_CONNTRACK_DESTROY; - goto alloc_skb; - } - if (events & (IPCT_NEW | IPCT_RELATED)) { + } else if (events & (IPCT_NEW | IPCT_RELATED)) { type = IPCTNL_MSG_CT_NEW; flags = NLM_F_CREATE|NLM_F_EXCL; /* dump everything */ events = ~0UL; group = NFNLGRP_CONNTRACK_NEW; - goto alloc_skb; - } - if (events & (IPCT_STATUS | + } else if (events & (IPCT_STATUS | IPCT_PROTOINFO | IPCT_HELPER | IPCT_HELPINFO | IPCT_NATINFO)) { type = IPCTNL_MSG_CT_NEW; group = NFNLGRP_CONNTRACK_UPDATE; - goto alloc_skb; - } + } else + return NOTIFY_DONE; - return NOTIFY_DONE; - -alloc_skb: /* FIXME: Check if there are any listeners before, don't hurt performance */ skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); -- cgit v1.1 From d4d6bb41e09f07668ca2655da707eab936e8e8f0 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Jan 2006 12:18:25 -0800 Subject: [NETFILTER]: ctnetlink: fix conntrack mark race Set conntrack mark before it is in hashes. Signed-off-by: Pablo Neira Ayuso Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_netlink.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index 04137d0..df04ad8 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c @@ -1031,6 +1031,11 @@ ctnetlink_create_conntrack(struct nfattr *cda[], return err; } +#if defined(CONFIG_IP_NF_CONNTRACK_MARK) + if (cda[CTA_MARK-1]) + ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); +#endif + ct->helper = ip_conntrack_helper_find_get(rtuple); add_timer(&ct->timeout); @@ -1039,11 +1044,6 @@ ctnetlink_create_conntrack(struct nfattr *cda[], if (ct->helper) ip_conntrack_helper_put(ct->helper); -#if defined(CONFIG_IP_NF_CONNTRACK_MARK) - if (cda[CTA_MARK-1]) - ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); -#endif - DEBUGP("conntrack with id %u inserted\n", ct->id); return 0; -- cgit v1.1 From 205d67c7d942c057648148fefb17e46f77e3efd6 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Jan 2006 12:18:44 -0800 Subject: [NETFILTER]: ctnetlink: remove unused variable Signed-off-by: Pablo Neira Ayuso Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_netlink.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index df04ad8..703f2d2 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c @@ -1203,7 +1203,6 @@ static int ctnetlink_expect_event(struct notifier_block *this, unsigned int type; unsigned char *b; int flags = 0; - u16 proto; if (events & IPEXP_NEW) { type = IPCTNL_MSG_EXP_NEW; @@ -1230,7 +1229,6 @@ static int ctnetlink_expect_event(struct notifier_block *this, goto nfattr_failure; nlh->nlmsg_len = skb->tail - b; - proto = exp->tuple.dst.protonum; nfnetlink_send(skb, 0, NFNLGRP_CONNTRACK_EXP_NEW, 0); return NOTIFY_DONE; -- cgit v1.1 From c1d10adb4a521de5760112853f42aaeefcec96eb Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Jan 2006 12:19:05 -0800 Subject: [NETFILTER]: Add ctnetlink port for nf_conntrack Signed-off-by: Pablo Neira Ayuso Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- include/linux/netfilter/nfnetlink_conntrack.h | 3 + include/net/netfilter/nf_conntrack.h | 31 + include/net/netfilter/nf_conntrack_helper.h | 2 + include/net/netfilter/nf_conntrack_l3proto.h | 15 +- include/net/netfilter/nf_conntrack_protocol.h | 26 +- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 47 + net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 97 +- net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 47 + net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 77 +- net/netfilter/Kconfig | 7 + net/netfilter/Makefile | 3 + net/netfilter/nf_conntrack_core.c | 232 +++- net/netfilter/nf_conntrack_netlink.c | 1642 ++++++++++++++++++++++++ net/netfilter/nf_conntrack_proto_tcp.c | 71 + net/netfilter/nf_conntrack_proto_udp.c | 10 + net/netfilter/nf_conntrack_standalone.c | 42 +- 16 files changed, 2289 insertions(+), 63 deletions(-) create mode 100644 net/netfilter/nf_conntrack_netlink.c diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h index 116fcac..b8e9a5b 100644 --- a/include/linux/netfilter/nfnetlink_conntrack.h +++ b/include/linux/netfilter/nfnetlink_conntrack.h @@ -64,6 +64,9 @@ enum ctattr_l4proto { CTA_PROTO_ICMP_ID, CTA_PROTO_ICMP_TYPE, CTA_PROTO_ICMP_CODE, + CTA_PROTO_ICMPV6_ID, + CTA_PROTO_ICMPV6_TYPE, + CTA_PROTO_ICMPV6_CODE, __CTA_PROTO_MAX }; #define CTA_PROTO_MAX (__CTA_PROTO_MAX - 1) diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index cc48256..64b82b7 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h @@ -94,6 +94,9 @@ struct nf_conn /* Current number of expected connections */ unsigned int expecting; + /* Unique ID that identifies this conntrack*/ + unsigned int id; + /* Helper. if any */ struct nf_conntrack_helper *helper; @@ -140,6 +143,9 @@ struct nf_conntrack_expect /* Usage count. */ atomic_t use; + /* Unique ID */ + unsigned int id; + /* Flags */ unsigned int flags; @@ -190,6 +196,31 @@ static inline void nf_ct_put(struct nf_conn *ct) nf_conntrack_put(&ct->ct_general); } +extern struct nf_conntrack_tuple_hash * +__nf_conntrack_find(const struct nf_conntrack_tuple *tuple, + const struct nf_conn *ignored_conntrack); + +extern void nf_conntrack_hash_insert(struct nf_conn *ct); + +extern struct nf_conntrack_expect * +__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple); + +extern struct nf_conntrack_expect * +nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple); + +extern void nf_ct_unlink_expect(struct nf_conntrack_expect *exp); + +extern void nf_ct_remove_expectations(struct nf_conn *ct); + +extern void nf_conntrack_flush(void); + +extern struct nf_conntrack_helper * +nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple); +extern void nf_ct_helper_put(struct nf_conntrack_helper *helper); + +extern struct nf_conntrack_helper * +__nf_conntrack_helper_find_byname(const char *name); + /* call to create an explicit dependency on nf_conntrack. */ extern void need_nf_conntrack(void); diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h index 5a66b2a..86ec817 100644 --- a/include/net/netfilter/nf_conntrack_helper.h +++ b/include/net/netfilter/nf_conntrack_helper.h @@ -33,6 +33,8 @@ struct nf_conntrack_helper unsigned int protoff, struct nf_conn *ct, enum ip_conntrack_info conntrackinfo); + + int (*to_nfattr)(struct sk_buff *skb, const struct nf_conn *ct); }; extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h index 01663e5..67856eb 100644 --- a/include/net/netfilter/nf_conntrack_l3proto.h +++ b/include/net/netfilter/nf_conntrack_l3proto.h @@ -14,6 +14,8 @@ #include #include +struct nfattr; + struct nf_conntrack_l3proto { /* Next pointer. */ @@ -70,6 +72,12 @@ struct nf_conntrack_l3proto u_int32_t (*get_features)(const struct nf_conntrack_tuple *tuple); + int (*tuple_to_nfattr)(struct sk_buff *skb, + const struct nf_conntrack_tuple *t); + + int (*nfattr_to_tuple)(struct nfattr *tb[], + struct nf_conntrack_tuple *t); + /* Module (if any) which this is connected to. */ struct module *me; }; @@ -81,11 +89,16 @@ extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto); static inline struct nf_conntrack_l3proto * -nf_ct_find_l3proto(u_int16_t l3proto) +__nf_ct_l3proto_find(u_int16_t l3proto) { return nf_ct_l3protos[l3proto]; } +extern struct nf_conntrack_l3proto * +nf_ct_l3proto_find_get(u_int16_t l3proto); + +extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p); + /* Existing built-in protocols */ extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4; extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6; diff --git a/include/net/netfilter/nf_conntrack_protocol.h b/include/net/netfilter/nf_conntrack_protocol.h index b3afda3..1f33737 100644 --- a/include/net/netfilter/nf_conntrack_protocol.h +++ b/include/net/netfilter/nf_conntrack_protocol.h @@ -12,6 +12,7 @@ #include struct seq_file; +struct nfattr; struct nf_conntrack_protocol { @@ -66,6 +67,18 @@ struct nf_conntrack_protocol enum ip_conntrack_info *ctinfo, int pf, unsigned int hooknum); + /* convert protoinfo to nfnetink attributes */ + int (*to_nfattr)(struct sk_buff *skb, struct nfattr *nfa, + const struct nf_conn *ct); + + /* convert nfnetlink attributes to protoinfo */ + int (*from_nfattr)(struct nfattr *tb[], struct nf_conn *ct); + + int (*tuple_to_nfattr)(struct sk_buff *skb, + const struct nf_conntrack_tuple *t); + int (*nfattr_to_tuple)(struct nfattr *tb[], + struct nf_conntrack_tuple *t); + /* Module (if any) which this is connected to. */ struct module *me; }; @@ -80,12 +93,23 @@ extern struct nf_conntrack_protocol nf_conntrack_generic_protocol; extern struct nf_conntrack_protocol **nf_ct_protos[PF_MAX]; extern struct nf_conntrack_protocol * -nf_ct_find_proto(u_int16_t l3proto, u_int8_t protocol); +__nf_ct_proto_find(u_int16_t l3proto, u_int8_t protocol); + +extern struct nf_conntrack_protocol * +nf_ct_proto_find_get(u_int16_t l3proto, u_int8_t protocol); + +extern void nf_ct_proto_put(struct nf_conntrack_protocol *p); /* Protocol registration. */ extern int nf_conntrack_protocol_register(struct nf_conntrack_protocol *proto); extern void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol *proto); +/* Generic netlink helpers */ +extern int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb, + const struct nf_conntrack_tuple *tuple); +extern int nf_ct_port_nfattr_to_tuple(struct nfattr *tb[], + struct nf_conntrack_tuple *t); + /* Log invalid packets */ extern unsigned int nf_ct_log_invalid; diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index 8202c1c..385867e 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c @@ -392,6 +392,48 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len) return -ENOENT; } +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + +#include +#include + +static int ipv4_tuple_to_nfattr(struct sk_buff *skb, + const struct nf_conntrack_tuple *tuple) +{ + NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), + &tuple->src.u3.ip); + NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), + &tuple->dst.u3.ip); + return 0; + +nfattr_failure: + return -1; +} + +static const size_t cta_min_ip[CTA_IP_MAX] = { + [CTA_IP_V4_SRC-1] = sizeof(u_int32_t), + [CTA_IP_V4_DST-1] = sizeof(u_int32_t), +}; + +static int ipv4_nfattr_to_tuple(struct nfattr *tb[], + struct nf_conntrack_tuple *t) +{ + if (!tb[CTA_IP_V4_SRC-1] || !tb[CTA_IP_V4_DST-1]) + return -EINVAL; + + if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) + return -EINVAL; + + t->src.u3.ip = + *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_SRC-1]); + t->dst.u3.ip = + *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_DST-1]); + + return 0; +} +#endif + static struct nf_sockopt_ops so_getorigdst = { .pf = PF_INET, .get_optmin = SO_ORIGINAL_DST, @@ -408,6 +450,11 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 = { .print_conntrack = ipv4_print_conntrack, .prepare = ipv4_prepare, .get_features = ipv4_get_features, +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + .tuple_to_nfattr = ipv4_tuple_to_nfattr, + .nfattr_to_tuple = ipv4_nfattr_to_tuple, +#endif .me = THIS_MODULE, }; diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index 7ddb5c0..52dc175 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c @@ -50,20 +50,21 @@ static int icmp_pkt_to_tuple(const struct sk_buff *skb, return 1; } +/* Add 1; spaces filled with 0. */ +static const u_int8_t invmap[] = { + [ICMP_ECHO] = ICMP_ECHOREPLY + 1, + [ICMP_ECHOREPLY] = ICMP_ECHO + 1, + [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1, + [ICMP_TIMESTAMPREPLY] = ICMP_TIMESTAMP + 1, + [ICMP_INFO_REQUEST] = ICMP_INFO_REPLY + 1, + [ICMP_INFO_REPLY] = ICMP_INFO_REQUEST + 1, + [ICMP_ADDRESS] = ICMP_ADDRESSREPLY + 1, + [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 1 +}; + static int icmp_invert_tuple(struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *orig) { - /* Add 1; spaces filled with 0. */ - static u_int8_t invmap[] - = { [ICMP_ECHO] = ICMP_ECHOREPLY + 1, - [ICMP_ECHOREPLY] = ICMP_ECHO + 1, - [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1, - [ICMP_TIMESTAMPREPLY] = ICMP_TIMESTAMP + 1, - [ICMP_INFO_REQUEST] = ICMP_INFO_REPLY + 1, - [ICMP_INFO_REPLY] = ICMP_INFO_REQUEST + 1, - [ICMP_ADDRESS] = ICMP_ADDRESSREPLY + 1, - [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 1}; - if (orig->dst.u.icmp.type >= sizeof(invmap) || !invmap[orig->dst.u.icmp.type]) return 0; @@ -120,11 +121,12 @@ static int icmp_packet(struct nf_conn *ct, static int icmp_new(struct nf_conn *conntrack, const struct sk_buff *skb, unsigned int dataoff) { - static u_int8_t valid_new[] - = { [ICMP_ECHO] = 1, - [ICMP_TIMESTAMP] = 1, - [ICMP_INFO_REQUEST] = 1, - [ICMP_ADDRESS] = 1 }; + static const u_int8_t valid_new[] = { + [ICMP_ECHO] = 1, + [ICMP_TIMESTAMP] = 1, + [ICMP_INFO_REQUEST] = 1, + [ICMP_ADDRESS] = 1 + }; if (conntrack->tuplehash[0].tuple.dst.u.icmp.type >= sizeof(valid_new) || !valid_new[conntrack->tuplehash[0].tuple.dst.u.icmp.type]) { @@ -168,7 +170,7 @@ icmp_error_message(struct sk_buff *skb, return -NF_ACCEPT; } - innerproto = nf_ct_find_proto(PF_INET, inside->ip.protocol); + innerproto = __nf_ct_proto_find(PF_INET, inside->ip.protocol); dataoff = skb->nh.iph->ihl*4 + sizeof(inside->icmp); /* Are they talking about one of our connections? */ if (!nf_ct_get_tuple(skb, dataoff, dataoff + inside->ip.ihl*4, PF_INET, @@ -281,6 +283,60 @@ checksum_skipped: return icmp_error_message(skb, ctinfo, hooknum); } +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + +#include +#include + +static int icmp_tuple_to_nfattr(struct sk_buff *skb, + const struct nf_conntrack_tuple *t) +{ + NFA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(u_int16_t), + &t->src.u.icmp.id); + NFA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t), + &t->dst.u.icmp.type); + NFA_PUT(skb, CTA_PROTO_ICMP_CODE, sizeof(u_int8_t), + &t->dst.u.icmp.code); + + return 0; + +nfattr_failure: + return -1; +} + +static const size_t cta_min_proto[CTA_PROTO_MAX] = { + [CTA_PROTO_ICMP_TYPE-1] = sizeof(u_int8_t), + [CTA_PROTO_ICMP_CODE-1] = sizeof(u_int8_t), + [CTA_PROTO_ICMP_ID-1] = sizeof(u_int16_t) +}; + +static int icmp_nfattr_to_tuple(struct nfattr *tb[], + struct nf_conntrack_tuple *tuple) +{ + if (!tb[CTA_PROTO_ICMP_TYPE-1] + || !tb[CTA_PROTO_ICMP_CODE-1] + || !tb[CTA_PROTO_ICMP_ID-1]) + return -EINVAL; + + if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) + return -EINVAL; + + tuple->dst.u.icmp.type = + *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_TYPE-1]); + tuple->dst.u.icmp.code = + *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]); + tuple->src.u.icmp.id = + *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]); + + if (tuple->dst.u.icmp.type >= sizeof(invmap) + || !invmap[tuple->dst.u.icmp.type]) + return -EINVAL; + + return 0; +} +#endif + struct nf_conntrack_protocol nf_conntrack_protocol_icmp = { .list = { NULL, NULL }, @@ -295,7 +351,12 @@ struct nf_conntrack_protocol nf_conntrack_protocol_icmp = .new = icmp_new, .error = icmp_error, .destroy = NULL, - .me = NULL + .me = NULL, +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + .tuple_to_nfattr = icmp_tuple_to_nfattr, + .nfattr_to_tuple = icmp_nfattr_to_tuple, +#endif }; EXPORT_SYMBOL(nf_conntrack_protocol_icmp); diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c index 753a3ae..704fbbe 100644 --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c @@ -401,6 +401,48 @@ static ctl_table nf_ct_net_table[] = { }; #endif +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + +#include +#include + +static int ipv6_tuple_to_nfattr(struct sk_buff *skb, + const struct nf_conntrack_tuple *tuple) +{ + NFA_PUT(skb, CTA_IP_V6_SRC, sizeof(u_int32_t) * 4, + &tuple->src.u3.ip6); + NFA_PUT(skb, CTA_IP_V6_DST, sizeof(u_int32_t) * 4, + &tuple->dst.u3.ip6); + return 0; + +nfattr_failure: + return -1; +} + +static const size_t cta_min_ip[CTA_IP_MAX] = { + [CTA_IP_V6_SRC-1] = sizeof(u_int32_t)*4, + [CTA_IP_V6_DST-1] = sizeof(u_int32_t)*4, +}; + +static int ipv6_nfattr_to_tuple(struct nfattr *tb[], + struct nf_conntrack_tuple *t) +{ + if (!tb[CTA_IP_V6_SRC-1] || !tb[CTA_IP_V6_DST-1]) + return -EINVAL; + + if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) + return -EINVAL; + + memcpy(&t->src.u3.ip6, NFA_DATA(tb[CTA_IP_V6_SRC-1]), + sizeof(u_int32_t) * 4); + memcpy(&t->dst.u3.ip6, NFA_DATA(tb[CTA_IP_V6_DST-1]), + sizeof(u_int32_t) * 4); + + return 0; +} +#endif + struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6 = { .l3proto = PF_INET6, .name = "ipv6", @@ -409,6 +451,11 @@ struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6 = { .print_tuple = ipv6_print_tuple, .print_conntrack = ipv6_print_conntrack, .prepare = ipv6_prepare, +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + .tuple_to_nfattr = ipv6_tuple_to_nfattr, + .nfattr_to_tuple = ipv6_nfattr_to_tuple, +#endif .get_features = ipv6_get_features, .me = THIS_MODULE, }; diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c index a7e03cf..09945c3 100644 --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c @@ -57,17 +57,17 @@ static int icmpv6_pkt_to_tuple(const struct sk_buff *skb, return 1; } +/* Add 1; spaces filled with 0. */ +static u_int8_t invmap[] = { + [ICMPV6_ECHO_REQUEST - 128] = ICMPV6_ECHO_REPLY + 1, + [ICMPV6_ECHO_REPLY - 128] = ICMPV6_ECHO_REQUEST + 1, + [ICMPV6_NI_QUERY - 128] = ICMPV6_NI_QUERY + 1, + [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_REPLY +1 +}; + static int icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple, const struct nf_conntrack_tuple *orig) { - /* Add 1; spaces filled with 0. */ - static u_int8_t invmap[] = { - [ICMPV6_ECHO_REQUEST - 128] = ICMPV6_ECHO_REPLY + 1, - [ICMPV6_ECHO_REPLY - 128] = ICMPV6_ECHO_REQUEST + 1, - [ICMPV6_NI_QUERY - 128] = ICMPV6_NI_QUERY + 1, - [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_REPLY +1 - }; - int type = orig->dst.u.icmp.type - 128; if (type < 0 || type >= sizeof(invmap) || !invmap[type]) return 0; @@ -185,7 +185,7 @@ icmpv6_error_message(struct sk_buff *skb, return -NF_ACCEPT; } - inproto = nf_ct_find_proto(PF_INET6, inprotonum); + inproto = __nf_ct_proto_find(PF_INET6, inprotonum); /* Are they talking about one of our connections? */ if (!nf_ct_get_tuple(skb, inip6off, inprotoff, PF_INET6, inprotonum, @@ -255,6 +255,60 @@ skipped: return icmpv6_error_message(skb, dataoff, ctinfo, hooknum); } +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + +#include +#include +static int icmpv6_tuple_to_nfattr(struct sk_buff *skb, + const struct nf_conntrack_tuple *t) +{ + NFA_PUT(skb, CTA_PROTO_ICMPV6_ID, sizeof(u_int16_t), + &t->src.u.icmp.id); + NFA_PUT(skb, CTA_PROTO_ICMPV6_TYPE, sizeof(u_int8_t), + &t->dst.u.icmp.type); + NFA_PUT(skb, CTA_PROTO_ICMPV6_CODE, sizeof(u_int8_t), + &t->dst.u.icmp.code); + + return 0; + +nfattr_failure: + return -1; +} + +static const size_t cta_min_proto[CTA_PROTO_MAX] = { + [CTA_PROTO_ICMPV6_TYPE-1] = sizeof(u_int8_t), + [CTA_PROTO_ICMPV6_CODE-1] = sizeof(u_int8_t), + [CTA_PROTO_ICMPV6_ID-1] = sizeof(u_int16_t) +}; + +static int icmpv6_nfattr_to_tuple(struct nfattr *tb[], + struct nf_conntrack_tuple *tuple) +{ + if (!tb[CTA_PROTO_ICMPV6_TYPE-1] + || !tb[CTA_PROTO_ICMPV6_CODE-1] + || !tb[CTA_PROTO_ICMPV6_ID-1]) + return -EINVAL; + + if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) + return -EINVAL; + + tuple->dst.u.icmp.type = + *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_TYPE-1]); + tuple->dst.u.icmp.code = + *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_CODE-1]); + tuple->src.u.icmp.id = + *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_ID-1]); + + if (tuple->dst.u.icmp.type < 128 + || tuple->dst.u.icmp.type - 128 >= sizeof(invmap) + || !invmap[tuple->dst.u.icmp.type - 128]) + return -EINVAL; + + return 0; +} +#endif + struct nf_conntrack_protocol nf_conntrack_protocol_icmpv6 = { .l3proto = PF_INET6, @@ -267,6 +321,11 @@ struct nf_conntrack_protocol nf_conntrack_protocol_icmpv6 = .packet = icmpv6_packet, .new = icmpv6_new, .error = icmpv6_error, +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + .tuple_to_nfattr = icmpv6_tuple_to_nfattr, + .nfattr_to_tuple = icmpv6_nfattr_to_tuple, +#endif }; EXPORT_SYMBOL(nf_conntrack_protocol_icmpv6); diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index 794c41d..7d55f9c 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig @@ -95,4 +95,11 @@ config NF_CONNTRACK_FTP To compile it as a module, choose M here. If unsure, say N. +config NF_CT_NETLINK + tristate 'Connection tracking netlink interface (EXPERIMENTAL)' + depends on EXPERIMENTAL && NF_CONNTRACK && NETFILTER_NETLINK + depends on NF_CONNTRACK!=y || NETFILTER_NETLINK!=m + help + This option enables support for a netlink-based userspace interface + endmenu diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile index 55f019a..cb21831 100644 --- a/net/netfilter/Makefile +++ b/net/netfilter/Makefile @@ -13,3 +13,6 @@ obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o # SCTP protocol connection tracking obj-$(CONFIG_NF_CT_PROTO_SCTP) += nf_conntrack_proto_sctp.o + +# netlink interface for nf_conntrack +obj-$(CONFIG_NF_CT_NETLINK) += nf_conntrack_netlink.o diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 0c5b01d..62bb509 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -82,6 +82,8 @@ unsigned int nf_ct_log_invalid; static LIST_HEAD(unconfirmed); static int nf_conntrack_vmalloc; +static unsigned int nf_conntrack_next_id = 1; +static unsigned int nf_conntrack_expect_next_id = 1; #ifdef CONFIG_NF_CONNTRACK_EVENTS struct notifier_block *nf_conntrack_chain; struct notifier_block *nf_conntrack_expect_chain; @@ -184,7 +186,7 @@ DECLARE_MUTEX(nf_ct_cache_mutex); extern struct nf_conntrack_protocol nf_conntrack_generic_protocol; struct nf_conntrack_protocol * -nf_ct_find_proto(u_int16_t l3proto, u_int8_t protocol) +__nf_ct_proto_find(u_int16_t l3proto, u_int8_t protocol) { if (unlikely(nf_ct_protos[l3proto] == NULL)) return &nf_conntrack_generic_protocol; @@ -192,6 +194,50 @@ nf_ct_find_proto(u_int16_t l3proto, u_int8_t protocol) return nf_ct_protos[l3proto][protocol]; } +/* this is guaranteed to always return a valid protocol helper, since + * it falls back to generic_protocol */ +struct nf_conntrack_protocol * +nf_ct_proto_find_get(u_int16_t l3proto, u_int8_t protocol) +{ + struct nf_conntrack_protocol *p; + + preempt_disable(); + p = __nf_ct_proto_find(l3proto, protocol); + if (p) { + if (!try_module_get(p->me)) + p = &nf_conntrack_generic_protocol; + } + preempt_enable(); + + return p; +} + +void nf_ct_proto_put(struct nf_conntrack_protocol *p) +{ + module_put(p->me); +} + +struct nf_conntrack_l3proto * +nf_ct_l3proto_find_get(u_int16_t l3proto) +{ + struct nf_conntrack_l3proto *p; + + preempt_disable(); + p = __nf_ct_l3proto_find(l3proto); + if (p) { + if (!try_module_get(p->me)) + p = &nf_conntrack_generic_l3proto; + } + preempt_enable(); + + return p; +} + +void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p) +{ + module_put(p->me); +} + static int nf_conntrack_hash_rnd_initted; static unsigned int nf_conntrack_hash_rnd; @@ -384,7 +430,7 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, } /* nf_conntrack_expect helper functions */ -static void nf_ct_unlink_expect(struct nf_conntrack_expect *exp) +void nf_ct_unlink_expect(struct nf_conntrack_expect *exp) { ASSERT_WRITE_LOCK(&nf_conntrack_lock); NF_CT_ASSERT(!timer_pending(&exp->timeout)); @@ -404,6 +450,33 @@ static void expectation_timed_out(unsigned long ul_expect) nf_conntrack_expect_put(exp); } +struct nf_conntrack_expect * +__nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple) +{ + struct nf_conntrack_expect *i; + + list_for_each_entry(i, &nf_conntrack_expect_list, list) { + if (nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask)) { + atomic_inc(&i->use); + return i; + } + } + return NULL; +} + +/* Just find a expectation corresponding to a tuple. */ +struct nf_conntrack_expect * +nf_conntrack_expect_find(const struct nf_conntrack_tuple *tuple) +{ + struct nf_conntrack_expect *i; + + read_lock_bh(&nf_conntrack_lock); + i = __nf_conntrack_expect_find(tuple); + read_unlock_bh(&nf_conntrack_lock); + + return i; +} + /* If an expectation for this connection is found, it gets delete from * global list then returned. */ static struct nf_conntrack_expect * @@ -432,7 +505,7 @@ find_expectation(const struct nf_conntrack_tuple *tuple) } /* delete all expectations for this conntrack */ -static void remove_expectations(struct nf_conn *ct) +void nf_ct_remove_expectations(struct nf_conn *ct) { struct nf_conntrack_expect *i, *tmp; @@ -462,7 +535,7 @@ clean_from_lists(struct nf_conn *ct) LIST_DELETE(&nf_conntrack_hash[hr], &ct->tuplehash[IP_CT_DIR_REPLY]); /* Destroy all pending expectations */ - remove_expectations(ct); + nf_ct_remove_expectations(ct); } static void @@ -482,12 +555,11 @@ destroy_conntrack(struct nf_conntrack *nfct) /* To make sure we don't get any weird locking issues here: * destroy_conntrack() MUST NOT be called with a write lock * to nf_conntrack_lock!!! -HW */ - l3proto = nf_ct_find_l3proto(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num); + l3proto = __nf_ct_l3proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num); if (l3proto && l3proto->destroy) l3proto->destroy(ct); - proto = nf_ct_find_proto(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num, - ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum); + proto = __nf_ct_proto_find(ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.l3num, ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum); if (proto && proto->destroy) proto->destroy(ct); @@ -499,7 +571,7 @@ destroy_conntrack(struct nf_conntrack *nfct) * except TFTP can create an expectation on the first packet, * before connection is in the list, so we need to clean here, * too. */ - remove_expectations(ct); + nf_ct_remove_expectations(ct); /* We overload first tuple to link into unconfirmed list. */ if (!nf_ct_is_confirmed(ct)) { @@ -540,7 +612,7 @@ conntrack_tuple_cmp(const struct nf_conntrack_tuple_hash *i, && nf_ct_tuple_equal(tuple, &i->tuple); } -static struct nf_conntrack_tuple_hash * +struct nf_conntrack_tuple_hash * __nf_conntrack_find(const struct nf_conntrack_tuple *tuple, const struct nf_conn *ignored_conntrack) { @@ -575,6 +647,29 @@ nf_conntrack_find_get(const struct nf_conntrack_tuple *tuple, return h; } +static void __nf_conntrack_hash_insert(struct nf_conn *ct, + unsigned int hash, + unsigned int repl_hash) +{ + ct->id = ++nf_conntrack_next_id; + list_prepend(&nf_conntrack_hash[hash], + &ct->tuplehash[IP_CT_DIR_ORIGINAL].list); + list_prepend(&nf_conntrack_hash[repl_hash], + &ct->tuplehash[IP_CT_DIR_REPLY].list); +} + +void nf_conntrack_hash_insert(struct nf_conn *ct) +{ + unsigned int hash, repl_hash; + + hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); + repl_hash = hash_conntrack(&ct->tuplehash[IP_CT_DIR_REPLY].tuple); + + write_lock_bh(&nf_conntrack_lock); + __nf_conntrack_hash_insert(ct, hash, repl_hash); + write_unlock_bh(&nf_conntrack_lock); +} + /* Confirm a connection given skb; places it in hash table */ int __nf_conntrack_confirm(struct sk_buff **pskb) @@ -621,10 +716,7 @@ __nf_conntrack_confirm(struct sk_buff **pskb) /* Remove from unconfirmed list */ list_del(&ct->tuplehash[IP_CT_DIR_ORIGINAL].list); - list_prepend(&nf_conntrack_hash[hash], - &ct->tuplehash[IP_CT_DIR_ORIGINAL]); - list_prepend(&nf_conntrack_hash[repl_hash], - &ct->tuplehash[IP_CT_DIR_REPLY]); + __nf_conntrack_hash_insert(ct, hash, repl_hash); /* Timer relative to confirmation time, not original setting time, otherwise we'd get timer wrap in weird delay cases. */ @@ -708,13 +800,41 @@ static inline int helper_cmp(const struct nf_conntrack_helper *i, } static struct nf_conntrack_helper * -nf_ct_find_helper(const struct nf_conntrack_tuple *tuple) +__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple) { return LIST_FIND(&helpers, helper_cmp, struct nf_conntrack_helper *, tuple); } +struct nf_conntrack_helper * +nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple) +{ + struct nf_conntrack_helper *helper; + + /* need nf_conntrack_lock to assure that helper exists until + * try_module_get() is called */ + read_lock_bh(&nf_conntrack_lock); + + helper = __nf_ct_helper_find(tuple); + if (helper) { + /* need to increase module usage count to assure helper will + * not go away while the caller is e.g. busy putting a + * conntrack in the hash that uses the helper */ + if (!try_module_get(helper->me)) + helper = NULL; + } + + read_unlock_bh(&nf_conntrack_lock); + + return helper; +} + +void nf_ct_helper_put(struct nf_conntrack_helper *helper) +{ + module_put(helper->me); +} + static struct nf_conn * __nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, const struct nf_conntrack_tuple *repl, @@ -744,7 +864,7 @@ __nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, /* find features needed by this conntrack. */ features = l3proto->get_features(orig); read_lock_bh(&nf_conntrack_lock); - if (nf_ct_find_helper(repl) != NULL) + if (__nf_ct_helper_find(repl) != NULL) features |= NF_CT_F_HELP; read_unlock_bh(&nf_conntrack_lock); @@ -794,7 +914,7 @@ struct nf_conn *nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, { struct nf_conntrack_l3proto *l3proto; - l3proto = nf_ct_find_l3proto(orig->src.l3num); + l3proto = __nf_ct_l3proto_find(orig->src.l3num); return __nf_conntrack_alloc(orig, repl, l3proto); } @@ -853,7 +973,7 @@ init_conntrack(const struct nf_conntrack_tuple *tuple, nf_conntrack_get(&conntrack->master->ct_general); NF_CT_STAT_INC(expect_new); } else { - conntrack->helper = nf_ct_find_helper(&repl_tuple); + conntrack->helper = __nf_ct_helper_find(&repl_tuple); NF_CT_STAT_INC(new); } @@ -947,13 +1067,13 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff **pskb) return NF_ACCEPT; } - l3proto = nf_ct_find_l3proto((u_int16_t)pf); + l3proto = __nf_ct_l3proto_find((u_int16_t)pf); if ((ret = l3proto->prepare(pskb, hooknum, &dataoff, &protonum)) <= 0) { DEBUGP("not prepared to track yet or error occured\n"); return -ret; } - proto = nf_ct_find_proto((u_int16_t)pf, protonum); + proto = __nf_ct_proto_find((u_int16_t)pf, protonum); /* It may be an special packet, error, unclean... * inverse of the return code tells to the netfilter @@ -1002,9 +1122,9 @@ int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse, const struct nf_conntrack_tuple *orig) { return nf_ct_invert_tuple(inverse, orig, - nf_ct_find_l3proto(orig->src.l3num), - nf_ct_find_proto(orig->src.l3num, - orig->dst.protonum)); + __nf_ct_l3proto_find(orig->src.l3num), + __nf_ct_proto_find(orig->src.l3num, + orig->dst.protonum)); } /* Would two expected things clash? */ @@ -1096,6 +1216,7 @@ static void nf_conntrack_expect_insert(struct nf_conntrack_expect *exp) exp->timeout.expires = jiffies + exp->master->helper->timeout * HZ; add_timer(&exp->timeout); + exp->id = ++nf_conntrack_expect_next_id; atomic_inc(&exp->use); NF_CT_STAT_INC(expect_create); } @@ -1176,7 +1297,7 @@ void nf_conntrack_alter_reply(struct nf_conn *conntrack, conntrack->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply; if (!conntrack->master && conntrack->expecting == 0) - conntrack->helper = nf_ct_find_helper(newreply); + conntrack->helper = __nf_ct_helper_find(newreply); write_unlock_bh(&nf_conntrack_lock); } @@ -1201,6 +1322,19 @@ int nf_conntrack_helper_register(struct nf_conntrack_helper *me) return 0; } +struct nf_conntrack_helper * +__nf_conntrack_helper_find_byname(const char *name) +{ + struct nf_conntrack_helper *h; + + list_for_each_entry(h, &helpers, list) { + if (!strcmp(h->name, name)) + return h; + } + + return NULL; +} + static inline int unhelp(struct nf_conntrack_tuple_hash *i, const struct nf_conntrack_helper *me) { @@ -1284,6 +1418,51 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, nf_conntrack_event_cache(event, skb); } +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + +#include +#include + +/* Generic function for tcp/udp/sctp/dccp and alike. This needs to be + * in ip_conntrack_core, since we don't want the protocols to autoload + * or depend on ctnetlink */ +int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb, + const struct nf_conntrack_tuple *tuple) +{ + NFA_PUT(skb, CTA_PROTO_SRC_PORT, sizeof(u_int16_t), + &tuple->src.u.tcp.port); + NFA_PUT(skb, CTA_PROTO_DST_PORT, sizeof(u_int16_t), + &tuple->dst.u.tcp.port); + return 0; + +nfattr_failure: + return -1; +} + +static const size_t cta_min_proto[CTA_PROTO_MAX] = { + [CTA_PROTO_SRC_PORT-1] = sizeof(u_int16_t), + [CTA_PROTO_DST_PORT-1] = sizeof(u_int16_t) +}; + +int nf_ct_port_nfattr_to_tuple(struct nfattr *tb[], + struct nf_conntrack_tuple *t) +{ + if (!tb[CTA_PROTO_SRC_PORT-1] || !tb[CTA_PROTO_DST_PORT-1]) + return -EINVAL; + + if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) + return -EINVAL; + + t->src.u.tcp.port = + *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]); + t->dst.u.tcp.port = + *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]); + + return 0; +} +#endif + /* Used by ipt_REJECT and ip6t_REJECT. */ void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb) { @@ -1366,6 +1545,11 @@ static void free_conntrack_hash(struct list_head *hash, int vmalloced, int size) get_order(sizeof(struct list_head) * size)); } +void nf_conntrack_flush() +{ + nf_ct_iterate_cleanup(kill_all, NULL); +} + /* Mishearing the voices in his head, our hero wonders how he's supposed to kill the mall. */ void nf_conntrack_cleanup(void) @@ -1379,7 +1563,7 @@ void nf_conntrack_cleanup(void) nf_ct_event_cache_flush(); i_see_dead_people: - nf_ct_iterate_cleanup(kill_all, NULL); + nf_conntrack_flush(); if (atomic_read(&nf_conntrack_count) != 0) { schedule(); goto i_see_dead_people; diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c new file mode 100644 index 0000000..4f2e509 --- /dev/null +++ b/net/netfilter/nf_conntrack_netlink.c @@ -0,0 +1,1642 @@ +/* Connection tracking via netlink socket. Allows for user space + * protocol helpers and general trouble making from userspace. + * + * (C) 2001 by Jay Schulist + * (C) 2002-2005 by Harald Welte + * (C) 2003 by Patrick Mchardy + * (C) 2005 by Pablo Neira Ayuso + * + * I've reworked this stuff to use attributes instead of conntrack + * structures. 5.44 am. I need more tea. --pablo 05/07/11. + * + * Initial connection tracking via netlink development funded and + * generally made possible by Network Robots, Inc. (www.networkrobots.com) + * + * Further development of this code funded by Astaro AG (http://www.astaro.com) + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + * + * Derived from ip_conntrack_netlink.c: Port by Pablo Neira Ayuso (05/11/14) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +MODULE_LICENSE("GPL"); + +static char __initdata version[] = "0.92"; + +#if 0 +#define DEBUGP printk +#else +#define DEBUGP(format, args...) +#endif + + +static inline int +ctnetlink_dump_tuples_proto(struct sk_buff *skb, + const struct nf_conntrack_tuple *tuple) +{ + struct nf_conntrack_protocol *proto; + int ret = 0; + + NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum); + + /* If no protocol helper is found, this function will return the + * generic protocol helper, so proto won't *ever* be NULL */ + proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum); + if (likely(proto->tuple_to_nfattr)) + ret = proto->tuple_to_nfattr(skb, tuple); + + nf_ct_proto_put(proto); + + return ret; + +nfattr_failure: + return -1; +} + +static inline int +ctnetlink_dump_tuples(struct sk_buff *skb, + const struct nf_conntrack_tuple *tuple) +{ + struct nfattr *nest_parms; + struct nf_conntrack_l3proto *l3proto; + int ret = 0; + + l3proto = nf_ct_l3proto_find_get(tuple->src.l3num); + + nest_parms = NFA_NEST(skb, CTA_TUPLE_IP); + if (likely(l3proto->tuple_to_nfattr)) + ret = l3proto->tuple_to_nfattr(skb, tuple); + NFA_NEST_END(skb, nest_parms); + + nf_ct_l3proto_put(l3proto); + + if (unlikely(ret < 0)) + return ret; + + nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO); + ret = ctnetlink_dump_tuples_proto(skb, tuple); + NFA_NEST_END(skb, nest_parms); + + return ret; + +nfattr_failure: + return -1; +} + +static inline int +ctnetlink_dump_status(struct sk_buff *skb, const struct nf_conn *ct) +{ + u_int32_t status = htonl((u_int32_t) ct->status); + NFA_PUT(skb, CTA_STATUS, sizeof(status), &status); + return 0; + +nfattr_failure: + return -1; +} + +static inline int +ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct) +{ + long timeout_l = ct->timeout.expires - jiffies; + u_int32_t timeout; + + if (timeout_l < 0) + timeout = 0; + else + timeout = htonl(timeout_l / HZ); + + NFA_PUT(skb, CTA_TIMEOUT, sizeof(timeout), &timeout); + return 0; + +nfattr_failure: + return -1; +} + +static inline int +ctnetlink_dump_protoinfo(struct sk_buff *skb, const struct nf_conn *ct) +{ + struct nf_conntrack_protocol *proto = nf_ct_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num, ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum); + struct nfattr *nest_proto; + int ret; + + if (!proto->to_nfattr) { + nf_ct_proto_put(proto); + return 0; + } + + nest_proto = NFA_NEST(skb, CTA_PROTOINFO); + + ret = proto->to_nfattr(skb, nest_proto, ct); + + nf_ct_proto_put(proto); + + NFA_NEST_END(skb, nest_proto); + + return ret; + +nfattr_failure: + return -1; +} + +static inline int +ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct nf_conn *ct) +{ + struct nfattr *nest_helper; + + if (!ct->helper) + return 0; + + nest_helper = NFA_NEST(skb, CTA_HELP); + NFA_PUT(skb, CTA_HELP_NAME, strlen(ct->helper->name), ct->helper->name); + + if (ct->helper->to_nfattr) + ct->helper->to_nfattr(skb, ct); + + NFA_NEST_END(skb, nest_helper); + + return 0; + +nfattr_failure: + return -1; +} + +#ifdef CONFIG_NF_CT_ACCT +static inline int +ctnetlink_dump_counters(struct sk_buff *skb, const struct nf_conn *ct, + enum ip_conntrack_dir dir) +{ + enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG; + struct nfattr *nest_count = NFA_NEST(skb, type); + u_int32_t tmp; + + tmp = htonl(ct->counters[dir].packets); + NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp); + + tmp = htonl(ct->counters[dir].bytes); + NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(u_int32_t), &tmp); + + NFA_NEST_END(skb, nest_count); + + return 0; + +nfattr_failure: + return -1; +} +#else +#define ctnetlink_dump_counters(a, b, c) (0) +#endif + +#ifdef CONFIG_NF_CONNTRACK_MARK +static inline int +ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct) +{ + u_int32_t mark = htonl(ct->mark); + + NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark); + return 0; + +nfattr_failure: + return -1; +} +#else +#define ctnetlink_dump_mark(a, b) (0) +#endif + +static inline int +ctnetlink_dump_id(struct sk_buff *skb, const struct nf_conn *ct) +{ + u_int32_t id = htonl(ct->id); + NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id); + return 0; + +nfattr_failure: + return -1; +} + +static inline int +ctnetlink_dump_use(struct sk_buff *skb, const struct nf_conn *ct) +{ + u_int32_t use = htonl(atomic_read(&ct->ct_general.use)); + + NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use); + return 0; + +nfattr_failure: + return -1; +} + +#define tuple(ct, dir) (&(ct)->tuplehash[dir].tuple) + +static int +ctnetlink_fill_info(struct sk_buff *skb, u32 pid, u32 seq, + int event, int nowait, + const struct nf_conn *ct) +{ + struct nlmsghdr *nlh; + struct nfgenmsg *nfmsg; + struct nfattr *nest_parms; + unsigned char *b; + + b = skb->tail; + + event |= NFNL_SUBSYS_CTNETLINK << 8; + nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(struct nfgenmsg)); + nfmsg = NLMSG_DATA(nlh); + + nlh->nlmsg_flags = (nowait && pid) ? NLM_F_MULTI : 0; + nfmsg->nfgen_family = + ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num; + nfmsg->version = NFNETLINK_V0; + nfmsg->res_id = 0; + + nest_parms = NFA_NEST(skb, CTA_TUPLE_ORIG); + if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_ORIGINAL)) < 0) + goto nfattr_failure; + NFA_NEST_END(skb, nest_parms); + + nest_parms = NFA_NEST(skb, CTA_TUPLE_REPLY); + if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0) + goto nfattr_failure; + NFA_NEST_END(skb, nest_parms); + + if (ctnetlink_dump_status(skb, ct) < 0 || + ctnetlink_dump_timeout(skb, ct) < 0 || + ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || + ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0 || + ctnetlink_dump_protoinfo(skb, ct) < 0 || + ctnetlink_dump_helpinfo(skb, ct) < 0 || + ctnetlink_dump_mark(skb, ct) < 0 || + ctnetlink_dump_id(skb, ct) < 0 || + ctnetlink_dump_use(skb, ct) < 0) + goto nfattr_failure; + + nlh->nlmsg_len = skb->tail - b; + return skb->len; + +nlmsg_failure: +nfattr_failure: + skb_trim(skb, b - skb->data); + return -1; +} + +#ifdef CONFIG_NF_CONNTRACK_EVENTS +static int ctnetlink_conntrack_event(struct notifier_block *this, + unsigned long events, void *ptr) +{ + struct nlmsghdr *nlh; + struct nfgenmsg *nfmsg; + struct nfattr *nest_parms; + struct nf_conn *ct = (struct nf_conn *)ptr; + struct sk_buff *skb; + unsigned int type; + unsigned char *b; + unsigned int flags = 0, group; + + /* ignore our fake conntrack entry */ + if (ct == &nf_conntrack_untracked) + return NOTIFY_DONE; + + if (events & IPCT_DESTROY) { + type = IPCTNL_MSG_CT_DELETE; + group = NFNLGRP_CONNTRACK_DESTROY; + } else if (events & (IPCT_NEW | IPCT_RELATED)) { + type = IPCTNL_MSG_CT_NEW; + flags = NLM_F_CREATE|NLM_F_EXCL; + /* dump everything */ + events = ~0UL; + group = NFNLGRP_CONNTRACK_NEW; + } else if (events & (IPCT_STATUS | + IPCT_PROTOINFO | + IPCT_HELPER | + IPCT_HELPINFO | + IPCT_NATINFO)) { + type = IPCTNL_MSG_CT_NEW; + group = NFNLGRP_CONNTRACK_UPDATE; + } else + return NOTIFY_DONE; + + /* FIXME: Check if there are any listeners before, don't hurt performance */ + + skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); + if (!skb) + return NOTIFY_DONE; + + b = skb->tail; + + type |= NFNL_SUBSYS_CTNETLINK << 8; + nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg)); + nfmsg = NLMSG_DATA(nlh); + + nlh->nlmsg_flags = flags; + nfmsg->nfgen_family = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num; + nfmsg->version = NFNETLINK_V0; + nfmsg->res_id = 0; + + nest_parms = NFA_NEST(skb, CTA_TUPLE_ORIG); + if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_ORIGINAL)) < 0) + goto nfattr_failure; + NFA_NEST_END(skb, nest_parms); + + nest_parms = NFA_NEST(skb, CTA_TUPLE_REPLY); + if (ctnetlink_dump_tuples(skb, tuple(ct, IP_CT_DIR_REPLY)) < 0) + goto nfattr_failure; + NFA_NEST_END(skb, nest_parms); + + /* NAT stuff is now a status flag */ + if ((events & IPCT_STATUS || events & IPCT_NATINFO) + && ctnetlink_dump_status(skb, ct) < 0) + goto nfattr_failure; + if (events & IPCT_REFRESH + && ctnetlink_dump_timeout(skb, ct) < 0) + goto nfattr_failure; + if (events & IPCT_PROTOINFO + && ctnetlink_dump_protoinfo(skb, ct) < 0) + goto nfattr_failure; + if (events & IPCT_HELPINFO + && ctnetlink_dump_helpinfo(skb, ct) < 0) + goto nfattr_failure; + + if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || + ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0) + goto nfattr_failure; + + nlh->nlmsg_len = skb->tail - b; + nfnetlink_send(skb, 0, group, 0); + return NOTIFY_DONE; + +nlmsg_failure: +nfattr_failure: + kfree_skb(skb); + return NOTIFY_DONE; +} +#endif /* CONFIG_NF_CONNTRACK_EVENTS */ + +static int ctnetlink_done(struct netlink_callback *cb) +{ + DEBUGP("entered %s\n", __FUNCTION__); + return 0; +} + +static int +ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) +{ + struct nf_conn *ct = NULL; + struct nf_conntrack_tuple_hash *h; + struct list_head *i; + u_int32_t *id = (u_int32_t *) &cb->args[1]; + + DEBUGP("entered %s, last bucket=%lu id=%u\n", __FUNCTION__, + cb->args[0], *id); + + read_lock_bh(&nf_conntrack_lock); + for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++, *id = 0) { + list_for_each_prev(i, &nf_conntrack_hash[cb->args[0]]) { + h = (struct nf_conntrack_tuple_hash *) i; + if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) + continue; + ct = nf_ct_tuplehash_to_ctrack(h); + if (ct->id <= *id) + continue; + if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq, + IPCTNL_MSG_CT_NEW, + 1, ct) < 0) + goto out; + *id = ct->id; + } + } +out: + read_unlock_bh(&nf_conntrack_lock); + + DEBUGP("leaving, last bucket=%lu id=%u\n", cb->args[0], *id); + + return skb->len; +} + +#ifdef CONFIG_NF_CT_ACCT +static int +ctnetlink_dump_table_w(struct sk_buff *skb, struct netlink_callback *cb) +{ + struct nf_conn *ct = NULL; + struct nf_conntrack_tuple_hash *h; + struct list_head *i; + u_int32_t *id = (u_int32_t *) &cb->args[1]; + + DEBUGP("entered %s, last bucket=%u id=%u\n", __FUNCTION__, + cb->args[0], *id); + + write_lock_bh(&nf_conntrack_lock); + for (; cb->args[0] < nf_conntrack_htable_size; cb->args[0]++, *id = 0) { + list_for_each_prev(i, &nf_conntrack_hash[cb->args[0]]) { + h = (struct nf_conntrack_tuple_hash *) i; + if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) + continue; + ct = nf_ct_tuplehash_to_ctrack(h); + if (ct->id <= *id) + continue; + if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq, + IPCTNL_MSG_CT_NEW, + 1, ct) < 0) + goto out; + *id = ct->id; + + memset(&ct->counters, 0, sizeof(ct->counters)); + } + } +out: + write_unlock_bh(&nf_conntrack_lock); + + DEBUGP("leaving, last bucket=%lu id=%u\n", cb->args[0], *id); + + return skb->len; +} +#endif + +static inline int +ctnetlink_parse_tuple_ip(struct nfattr *attr, struct nf_conntrack_tuple *tuple) +{ + struct nfattr *tb[CTA_IP_MAX]; + struct nf_conntrack_l3proto *l3proto; + int ret = 0; + + DEBUGP("entered %s\n", __FUNCTION__); + + nfattr_parse_nested(tb, CTA_IP_MAX, attr); + + l3proto = nf_ct_l3proto_find_get(tuple->src.l3num); + + if (likely(l3proto->nfattr_to_tuple)) + ret = l3proto->nfattr_to_tuple(tb, tuple); + + nf_ct_l3proto_put(l3proto); + + DEBUGP("leaving\n"); + + return ret; +} + +static const size_t cta_min_proto[CTA_PROTO_MAX] = { + [CTA_PROTO_NUM-1] = sizeof(u_int8_t), +}; + +static inline int +ctnetlink_parse_tuple_proto(struct nfattr *attr, + struct nf_conntrack_tuple *tuple) +{ + struct nfattr *tb[CTA_PROTO_MAX]; + struct nf_conntrack_protocol *proto; + int ret = 0; + + DEBUGP("entered %s\n", __FUNCTION__); + + nfattr_parse_nested(tb, CTA_PROTO_MAX, attr); + + if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) + return -EINVAL; + + if (!tb[CTA_PROTO_NUM-1]) + return -EINVAL; + tuple->dst.protonum = *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_NUM-1]); + + proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum); + + if (likely(proto->nfattr_to_tuple)) + ret = proto->nfattr_to_tuple(tb, tuple); + + nf_ct_proto_put(proto); + + return ret; +} + +static inline int +ctnetlink_parse_tuple(struct nfattr *cda[], struct nf_conntrack_tuple *tuple, + enum ctattr_tuple type, u_int8_t l3num) +{ + struct nfattr *tb[CTA_TUPLE_MAX]; + int err; + + DEBUGP("entered %s\n", __FUNCTION__); + + memset(tuple, 0, sizeof(*tuple)); + + nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]); + + if (!tb[CTA_TUPLE_IP-1]) + return -EINVAL; + + tuple->src.l3num = l3num; + + err = ctnetlink_parse_tuple_ip(tb[CTA_TUPLE_IP-1], tuple); + if (err < 0) + return err; + + if (!tb[CTA_TUPLE_PROTO-1]) + return -EINVAL; + + err = ctnetlink_parse_tuple_proto(tb[CTA_TUPLE_PROTO-1], tuple); + if (err < 0) + return err; + + /* orig and expect tuples get DIR_ORIGINAL */ + if (type == CTA_TUPLE_REPLY) + tuple->dst.dir = IP_CT_DIR_REPLY; + else + tuple->dst.dir = IP_CT_DIR_ORIGINAL; + + NF_CT_DUMP_TUPLE(tuple); + + DEBUGP("leaving\n"); + + return 0; +} + +#ifdef CONFIG_IP_NF_NAT_NEEDED +static const size_t cta_min_protonat[CTA_PROTONAT_MAX] = { + [CTA_PROTONAT_PORT_MIN-1] = sizeof(u_int16_t), + [CTA_PROTONAT_PORT_MAX-1] = sizeof(u_int16_t), +}; + +static int ctnetlink_parse_nat_proto(struct nfattr *attr, + const struct nf_conn *ct, + struct ip_nat_range *range) +{ + struct nfattr *tb[CTA_PROTONAT_MAX]; + struct ip_nat_protocol *npt; + + DEBUGP("entered %s\n", __FUNCTION__); + + nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr); + + if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat)) + return -EINVAL; + + npt = ip_nat_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum); + + if (!npt->nfattr_to_range) { + ip_nat_proto_put(npt); + return 0; + } + + /* nfattr_to_range returns 1 if it parsed, 0 if not, neg. on error */ + if (npt->nfattr_to_range(tb, range) > 0) + range->flags |= IP_NAT_RANGE_PROTO_SPECIFIED; + + ip_nat_proto_put(npt); + + DEBUGP("leaving\n"); + return 0; +} + +static const size_t cta_min_nat[CTA_NAT_MAX] = { + [CTA_NAT_MINIP-1] = sizeof(u_int32_t), + [CTA_NAT_MAXIP-1] = sizeof(u_int32_t), +}; + +static inline int +ctnetlink_parse_nat(struct nfattr *cda[], + const struct nf_conn *ct, struct ip_nat_range *range) +{ + struct nfattr *tb[CTA_NAT_MAX]; + int err; + + DEBUGP("entered %s\n", __FUNCTION__); + + memset(range, 0, sizeof(*range)); + + nfattr_parse_nested(tb, CTA_NAT_MAX, cda[CTA_NAT-1]); + + if (nfattr_bad_size(tb, CTA_NAT_MAX, cta_min_nat)) + return -EINVAL; + + if (tb[CTA_NAT_MINIP-1]) + range->min_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MINIP-1]); + + if (!tb[CTA_NAT_MAXIP-1]) + range->max_ip = range->min_ip; + else + range->max_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MAXIP-1]); + + if (range->min_ip) + range->flags |= IP_NAT_RANGE_MAP_IPS; + + if (!tb[CTA_NAT_PROTO-1]) + return 0; + + err = ctnetlink_parse_nat_proto(tb[CTA_NAT_PROTO-1], ct, range); + if (err < 0) + return err; + + DEBUGP("leaving\n"); + return 0; +} +#endif + +static inline int +ctnetlink_parse_help(struct nfattr *attr, char **helper_name) +{ + struct nfattr *tb[CTA_HELP_MAX]; + + DEBUGP("entered %s\n", __FUNCTION__); + + nfattr_parse_nested(tb, CTA_HELP_MAX, attr); + + if (!tb[CTA_HELP_NAME-1]) + return -EINVAL; + + *helper_name = NFA_DATA(tb[CTA_HELP_NAME-1]); + + return 0; +} + +static const size_t cta_min[CTA_MAX] = { + [CTA_STATUS-1] = sizeof(u_int32_t), + [CTA_TIMEOUT-1] = sizeof(u_int32_t), + [CTA_MARK-1] = sizeof(u_int32_t), + [CTA_USE-1] = sizeof(u_int32_t), + [CTA_ID-1] = sizeof(u_int32_t) +}; + +static int +ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb, + struct nlmsghdr *nlh, struct nfattr *cda[], int *errp) +{ + struct nf_conntrack_tuple_hash *h; + struct nf_conntrack_tuple tuple; + struct nf_conn *ct; + struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); + u_int8_t u3 = nfmsg->nfgen_family; + int err = 0; + + DEBUGP("entered %s\n", __FUNCTION__); + + if (nfattr_bad_size(cda, CTA_MAX, cta_min)) + return -EINVAL; + + if (cda[CTA_TUPLE_ORIG-1]) + err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_ORIG, u3); + else if (cda[CTA_TUPLE_REPLY-1]) + err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_REPLY, u3); + else { + /* Flush the whole table */ + nf_conntrack_flush(); + return 0; + } + + if (err < 0) + return err; + + h = nf_conntrack_find_get(&tuple, NULL); + if (!h) { + DEBUGP("tuple not found in conntrack hash\n"); + return -ENOENT; + } + + ct = nf_ct_tuplehash_to_ctrack(h); + + if (cda[CTA_ID-1]) { + u_int32_t id = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_ID-1])); + if (ct->id != id) { + nf_ct_put(ct); + return -ENOENT; + } + } + if (del_timer(&ct->timeout)) + ct->timeout.function((unsigned long)ct); + + nf_ct_put(ct); + DEBUGP("leaving\n"); + + return 0; +} + +static int +ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb, + struct nlmsghdr *nlh, struct nfattr *cda[], int *errp) +{ + struct nf_conntrack_tuple_hash *h; + struct nf_conntrack_tuple tuple; + struct nf_conn *ct; + struct sk_buff *skb2 = NULL; + struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); + u_int8_t u3 = nfmsg->nfgen_family; + int err = 0; + + DEBUGP("entered %s\n", __FUNCTION__); + + if (nlh->nlmsg_flags & NLM_F_DUMP) { + u32 rlen; + + if (nfmsg->nfgen_family != AF_INET) + return -EAFNOSUPPORT; + + if (NFNL_MSG_TYPE(nlh->nlmsg_type) == + IPCTNL_MSG_CT_GET_CTRZERO) { +#ifdef CONFIG_NF_CT_ACCT + if ((*errp = netlink_dump_start(ctnl, skb, nlh, + ctnetlink_dump_table_w, + ctnetlink_done)) != 0) + return -EINVAL; +#else + return -ENOTSUPP; +#endif + } else { + if ((*errp = netlink_dump_start(ctnl, skb, nlh, + ctnetlink_dump_table, + ctnetlink_done)) != 0) + return -EINVAL; + } + + rlen = NLMSG_ALIGN(nlh->nlmsg_len); + if (rlen > skb->len) + rlen = skb->len; + skb_pull(skb, rlen); + return 0; + } + + if (nfattr_bad_size(cda, CTA_MAX, cta_min)) + return -EINVAL; + + if (cda[CTA_TUPLE_ORIG-1]) + err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_ORIG, u3); + else if (cda[CTA_TUPLE_REPLY-1]) + err = ctnetlink_parse_tuple(cda, &tuple, CTA_TUPLE_REPLY, u3); + else + return -EINVAL; + + if (err < 0) + return err; + + h = nf_conntrack_find_get(&tuple, NULL); + if (!h) { + DEBUGP("tuple not found in conntrack hash"); + return -ENOENT; + } + DEBUGP("tuple found\n"); + ct = nf_ct_tuplehash_to_ctrack(h); + + err = -ENOMEM; + skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); + if (!skb2) { + nf_ct_put(ct); + return -ENOMEM; + } + NETLINK_CB(skb2).dst_pid = NETLINK_CB(skb).pid; + + err = ctnetlink_fill_info(skb2, NETLINK_CB(skb).pid, nlh->nlmsg_seq, + IPCTNL_MSG_CT_NEW, 1, ct); + nf_ct_put(ct); + if (err <= 0) + goto free; + + err = netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); + if (err < 0) + goto out; + + DEBUGP("leaving\n"); + return 0; + +free: + kfree_skb(skb2); +out: + return err; +} + +static inline int +ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[]) +{ + unsigned long d; + unsigned status = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1])); + d = ct->status ^ status; + + if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING)) + /* unchangeable */ + return -EINVAL; + + if (d & IPS_SEEN_REPLY && !(status & IPS_SEEN_REPLY)) + /* SEEN_REPLY bit can only be set */ + return -EINVAL; + + + if (d & IPS_ASSURED && !(status & IPS_ASSURED)) + /* ASSURED bit can only be set */ + return -EINVAL; + + if (cda[CTA_NAT-1]) { +#ifndef CONFIG_IP_NF_NAT_NEEDED + return -EINVAL; +#else + unsigned int hooknum; + struct ip_nat_range range; + + if (ctnetlink_parse_nat(cda, ct, &range) < 0) + return -EINVAL; + + DEBUGP("NAT: %u.%u.%u.%u-%u.%u.%u.%u:%u-%u\n", + NIPQUAD(range.min_ip), NIPQUAD(range.max_ip), + htons(range.min.all), htons(range.max.all)); + + /* This is tricky but it works. ip_nat_setup_info needs the + * hook number as parameter, so let's do the correct + * conversion and run away */ + if (status & IPS_SRC_NAT_DONE) + hooknum = NF_IP_POST_ROUTING; /* IP_NAT_MANIP_SRC */ + else if (status & IPS_DST_NAT_DONE) + hooknum = NF_IP_PRE_ROUTING; /* IP_NAT_MANIP_DST */ + else + return -EINVAL; /* Missing NAT flags */ + + DEBUGP("NAT status: %lu\n", + status & (IPS_NAT_MASK | IPS_NAT_DONE_MASK)); + + if (ip_nat_initialized(ct, HOOK2MANIP(hooknum))) + return -EEXIST; + ip_nat_setup_info(ct, &range, hooknum); + + DEBUGP("NAT status after setup_info: %lu\n", + ct->status & (IPS_NAT_MASK | IPS_NAT_DONE_MASK)); +#endif + } + + /* Be careful here, modifying NAT bits can screw up things, + * so don't let users modify them directly if they don't pass + * ip_nat_range. */ + ct->status |= status & ~(IPS_NAT_DONE_MASK | IPS_NAT_MASK); + return 0; +} + + +static inline int +ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[]) +{ + struct nf_conntrack_helper *helper; + char *helpname; + int err; + + DEBUGP("entered %s\n", __FUNCTION__); + + /* don't change helper of sibling connections */ + if (ct->master) + return -EINVAL; + + err = ctnetlink_parse_help(cda[CTA_HELP-1], &helpname); + if (err < 0) + return err; + + helper = __nf_conntrack_helper_find_byname(helpname); + if (!helper) { + if (!strcmp(helpname, "")) + helper = NULL; + else + return -EINVAL; + } + + if (ct->helper) { + if (!helper) { + /* we had a helper before ... */ + nf_ct_remove_expectations(ct); + ct->helper = NULL; + } else { + /* need to zero data of old helper */ + memset(&ct->help, 0, sizeof(ct->help)); + } + } + + ct->helper = helper; + + return 0; +} + +static inline int +ctnetlink_change_timeout(struct nf_conn *ct, struct nfattr *cda[]) +{ + u_int32_t timeout = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); + + if (!del_timer(&ct->timeout)) + return -ETIME; + + ct->timeout.expires = jiffies + timeout * HZ; + add_timer(&ct->timeout); + + return 0; +} + +static inline int +ctnetlink_change_protoinfo(struct nf_conn *ct, struct nfattr *cda[]) +{ + struct nfattr *tb[CTA_PROTOINFO_MAX], *attr = cda[CTA_PROTOINFO-1]; + struct nf_conntrack_protocol *proto; + u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum; + u_int16_t l3num = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num; + int err = 0; + + nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr); + + proto = nf_ct_proto_find_get(l3num, npt); + + if (proto->from_nfattr) + err = proto->from_nfattr(tb, ct); + nf_ct_proto_put(proto); + + return err; +} + +static int +ctnetlink_change_conntrack(struct nf_conn *ct, struct nfattr *cda[]) +{ + int err; + + DEBUGP("entered %s\n", __FUNCTION__); + + if (cda[CTA_HELP-1]) { + err = ctnetlink_change_helper(ct, cda); + if (err < 0) + return err; + } + + if (cda[CTA_TIMEOUT-1]) { + err = ctnetlink_change_timeout(ct, cda); + if (err < 0) + return err; + } + + if (cda[CTA_STATUS-1]) { + err = ctnetlink_change_status(ct, cda); + if (err < 0) + return err; + } + + if (cda[CTA_PROTOINFO-1]) { + err = ctnetlink_change_protoinfo(ct, cda); + if (err < 0) + return err; + } + +#if defined(CONFIG_IP_NF_CONNTRACK_MARK) + if (cda[CTA_MARK-1]) + ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); +#endif + + DEBUGP("all done\n"); + return 0; +} + +static int +ctnetlink_create_conntrack(struct nfattr *cda[], + struct nf_conntrack_tuple *otuple, + struct nf_conntrack_tuple *rtuple) +{ + struct nf_conn *ct; + int err = -EINVAL; + + DEBUGP("entered %s\n", __FUNCTION__); + + ct = nf_conntrack_alloc(otuple, rtuple); + if (ct == NULL || IS_ERR(ct)) + return -ENOMEM; + + if (!cda[CTA_TIMEOUT-1]) + goto err; + ct->timeout.expires = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); + + ct->timeout.expires = jiffies + ct->timeout.expires * HZ; + ct->status |= IPS_CONFIRMED; + + err = ctnetlink_change_status(ct, cda); + if (err < 0) + goto err; + + if (cda[CTA_PROTOINFO-1]) { + err = ctnetlink_change_protoinfo(ct, cda); + if (err < 0) + return err; + } + +#if defined(CONFIG_IP_NF_CONNTRACK_MARK) + if (cda[CTA_MARK-1]) + ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); +#endif + + ct->helper = nf_ct_helper_find_get(rtuple); + + add_timer(&ct->timeout); + nf_conntrack_hash_insert(ct); + + if (ct->helper) + nf_ct_helper_put(ct->helper); + + DEBUGP("conntrack with id %u inserted\n", ct->id); + return 0; + +err: + nf_conntrack_free(ct); + return err; +} + +static int +ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb, + struct nlmsghdr *nlh, struct nfattr *cda[], int *errp) +{ + struct nf_conntrack_tuple otuple, rtuple; + struct nf_conntrack_tuple_hash *h = NULL; + struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); + u_int8_t u3 = nfmsg->nfgen_family; + int err = 0; + + DEBUGP("entered %s\n", __FUNCTION__); + + if (nfattr_bad_size(cda, CTA_MAX, cta_min)) + return -EINVAL; + + if (cda[CTA_TUPLE_ORIG-1]) { + err = ctnetlink_parse_tuple(cda, &otuple, CTA_TUPLE_ORIG, u3); + if (err < 0) + return err; + } + + if (cda[CTA_TUPLE_REPLY-1]) { + err = ctnetlink_parse_tuple(cda, &rtuple, CTA_TUPLE_REPLY, u3); + if (err < 0) + return err; + } + + write_lock_bh(&nf_conntrack_lock); + if (cda[CTA_TUPLE_ORIG-1]) + h = __nf_conntrack_find(&otuple, NULL); + else if (cda[CTA_TUPLE_REPLY-1]) + h = __nf_conntrack_find(&rtuple, NULL); + + if (h == NULL) { + write_unlock_bh(&nf_conntrack_lock); + DEBUGP("no such conntrack, create new\n"); + err = -ENOENT; + if (nlh->nlmsg_flags & NLM_F_CREATE) + err = ctnetlink_create_conntrack(cda, &otuple, &rtuple); + return err; + } + /* implicit 'else' */ + + /* we only allow nat config for new conntracks */ + if (cda[CTA_NAT-1]) { + err = -EINVAL; + goto out_unlock; + } + + /* We manipulate the conntrack inside the global conntrack table lock, + * so there's no need to increase the refcount */ + DEBUGP("conntrack found\n"); + err = -EEXIST; + if (!(nlh->nlmsg_flags & NLM_F_EXCL)) + err = ctnetlink_change_conntrack(nf_ct_tuplehash_to_ctrack(h), cda); + +out_unlock: + write_unlock_bh(&nf_conntrack_lock); + return err; +} + +/*********************************************************************** + * EXPECT + ***********************************************************************/ + +static inline int +ctnetlink_exp_dump_tuple(struct sk_buff *skb, + const struct nf_conntrack_tuple *tuple, + enum ctattr_expect type) +{ + struct nfattr *nest_parms = NFA_NEST(skb, type); + + if (ctnetlink_dump_tuples(skb, tuple) < 0) + goto nfattr_failure; + + NFA_NEST_END(skb, nest_parms); + + return 0; + +nfattr_failure: + return -1; +} + +static inline int +ctnetlink_exp_dump_expect(struct sk_buff *skb, + const struct nf_conntrack_expect *exp) +{ + struct nf_conn *master = exp->master; + u_int32_t timeout = htonl((exp->timeout.expires - jiffies) / HZ); + u_int32_t id = htonl(exp->id); + + if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0) + goto nfattr_failure; + if (ctnetlink_exp_dump_tuple(skb, &exp->mask, CTA_EXPECT_MASK) < 0) + goto nfattr_failure; + if (ctnetlink_exp_dump_tuple(skb, + &master->tuplehash[IP_CT_DIR_ORIGINAL].tuple, + CTA_EXPECT_MASTER) < 0) + goto nfattr_failure; + + NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(timeout), &timeout); + NFA_PUT(skb, CTA_EXPECT_ID, sizeof(u_int32_t), &id); + + return 0; + +nfattr_failure: + return -1; +} + +static int +ctnetlink_exp_fill_info(struct sk_buff *skb, u32 pid, u32 seq, + int event, + int nowait, + const struct nf_conntrack_expect *exp) +{ + struct nlmsghdr *nlh; + struct nfgenmsg *nfmsg; + unsigned char *b; + + b = skb->tail; + + event |= NFNL_SUBSYS_CTNETLINK_EXP << 8; + nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(struct nfgenmsg)); + nfmsg = NLMSG_DATA(nlh); + + nlh->nlmsg_flags = (nowait && pid) ? NLM_F_MULTI : 0; + nfmsg->nfgen_family = exp->tuple.src.l3num; + nfmsg->version = NFNETLINK_V0; + nfmsg->res_id = 0; + + if (ctnetlink_exp_dump_expect(skb, exp) < 0) + goto nfattr_failure; + + nlh->nlmsg_len = skb->tail - b; + return skb->len; + +nlmsg_failure: +nfattr_failure: + skb_trim(skb, b - skb->data); + return -1; +} + +#ifdef CONFIG_NF_CONNTRACK_EVENTS +static int ctnetlink_expect_event(struct notifier_block *this, + unsigned long events, void *ptr) +{ + struct nlmsghdr *nlh; + struct nfgenmsg *nfmsg; + struct nf_conntrack_expect *exp = (struct nf_conntrack_expect *)ptr; + struct sk_buff *skb; + unsigned int type; + unsigned char *b; + int flags = 0; + + if (events & IPEXP_NEW) { + type = IPCTNL_MSG_EXP_NEW; + flags = NLM_F_CREATE|NLM_F_EXCL; + } else + return NOTIFY_DONE; + + skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); + if (!skb) + return NOTIFY_DONE; + + b = skb->tail; + + type |= NFNL_SUBSYS_CTNETLINK << 8; + nlh = NLMSG_PUT(skb, 0, 0, type, sizeof(struct nfgenmsg)); + nfmsg = NLMSG_DATA(nlh); + + nlh->nlmsg_flags = flags; + nfmsg->nfgen_family = exp->tuple.src.l3num; + nfmsg->version = NFNETLINK_V0; + nfmsg->res_id = 0; + + if (ctnetlink_exp_dump_expect(skb, exp) < 0) + goto nfattr_failure; + + nlh->nlmsg_len = skb->tail - b; + nfnetlink_send(skb, 0, NFNLGRP_CONNTRACK_EXP_NEW, 0); + return NOTIFY_DONE; + +nlmsg_failure: +nfattr_failure: + kfree_skb(skb); + return NOTIFY_DONE; +} +#endif + +static int +ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb) +{ + struct nf_conntrack_expect *exp = NULL; + struct list_head *i; + u_int32_t *id = (u_int32_t *) &cb->args[0]; + + DEBUGP("entered %s, last id=%llu\n", __FUNCTION__, *id); + + read_lock_bh(&nf_conntrack_lock); + list_for_each_prev(i, &nf_conntrack_expect_list) { + exp = (struct nf_conntrack_expect *) i; + if (exp->id <= *id) + continue; + if (ctnetlink_exp_fill_info(skb, NETLINK_CB(cb->skb).pid, + cb->nlh->nlmsg_seq, + IPCTNL_MSG_EXP_NEW, + 1, exp) < 0) + goto out; + *id = exp->id; + } +out: + read_unlock_bh(&nf_conntrack_lock); + + DEBUGP("leaving, last id=%llu\n", *id); + + return skb->len; +} + +static const size_t cta_min_exp[CTA_EXPECT_MAX] = { + [CTA_EXPECT_TIMEOUT-1] = sizeof(u_int32_t), + [CTA_EXPECT_ID-1] = sizeof(u_int32_t) +}; + +static int +ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb, + struct nlmsghdr *nlh, struct nfattr *cda[], int *errp) +{ + struct nf_conntrack_tuple tuple; + struct nf_conntrack_expect *exp; + struct sk_buff *skb2; + struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); + u_int8_t u3 = nfmsg->nfgen_family; + int err = 0; + + DEBUGP("entered %s\n", __FUNCTION__); + + if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp)) + return -EINVAL; + + if (nlh->nlmsg_flags & NLM_F_DUMP) { + u32 rlen; + + if (nfmsg->nfgen_family != AF_INET) + return -EAFNOSUPPORT; + + if ((*errp = netlink_dump_start(ctnl, skb, nlh, + ctnetlink_exp_dump_table, + ctnetlink_done)) != 0) + return -EINVAL; + rlen = NLMSG_ALIGN(nlh->nlmsg_len); + if (rlen > skb->len) + rlen = skb->len; + skb_pull(skb, rlen); + return 0; + } + + if (cda[CTA_EXPECT_MASTER-1]) + err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_MASTER, u3); + else + return -EINVAL; + + if (err < 0) + return err; + + exp = nf_conntrack_expect_find(&tuple); + if (!exp) + return -ENOENT; + + if (cda[CTA_EXPECT_ID-1]) { + u_int32_t id = *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); + if (exp->id != ntohl(id)) { + nf_conntrack_expect_put(exp); + return -ENOENT; + } + } + + err = -ENOMEM; + skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); + if (!skb2) + goto out; + NETLINK_CB(skb2).dst_pid = NETLINK_CB(skb).pid; + + err = ctnetlink_exp_fill_info(skb2, NETLINK_CB(skb).pid, + nlh->nlmsg_seq, IPCTNL_MSG_EXP_NEW, + 1, exp); + if (err <= 0) + goto free; + + nf_conntrack_expect_put(exp); + + return netlink_unicast(ctnl, skb2, NETLINK_CB(skb).pid, MSG_DONTWAIT); + +free: + kfree_skb(skb2); +out: + nf_conntrack_expect_put(exp); + return err; +} + +static int +ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb, + struct nlmsghdr *nlh, struct nfattr *cda[], int *errp) +{ + struct nf_conntrack_expect *exp, *tmp; + struct nf_conntrack_tuple tuple; + struct nf_conntrack_helper *h; + struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); + u_int8_t u3 = nfmsg->nfgen_family; + int err; + + if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp)) + return -EINVAL; + + if (cda[CTA_EXPECT_TUPLE-1]) { + /* delete a single expect by tuple */ + err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3); + if (err < 0) + return err; + + /* bump usage count to 2 */ + exp = nf_conntrack_expect_find(&tuple); + if (!exp) + return -ENOENT; + + if (cda[CTA_EXPECT_ID-1]) { + u_int32_t id = + *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); + if (exp->id != ntohl(id)) { + nf_conntrack_expect_put(exp); + return -ENOENT; + } + } + + /* after list removal, usage count == 1 */ + nf_conntrack_unexpect_related(exp); + /* have to put what we 'get' above. + * after this line usage count == 0 */ + nf_conntrack_expect_put(exp); + } else if (cda[CTA_EXPECT_HELP_NAME-1]) { + char *name = NFA_DATA(cda[CTA_EXPECT_HELP_NAME-1]); + + /* delete all expectations for this helper */ + write_lock_bh(&nf_conntrack_lock); + h = __nf_conntrack_helper_find_byname(name); + if (!h) { + write_unlock_bh(&nf_conntrack_lock); + return -EINVAL; + } + list_for_each_entry_safe(exp, tmp, &nf_conntrack_expect_list, + list) { + if (exp->master->helper == h + && del_timer(&exp->timeout)) { + nf_ct_unlink_expect(exp); + nf_conntrack_expect_put(exp); + } + } + write_unlock_bh(&nf_conntrack_lock); + } else { + /* This basically means we have to flush everything*/ + write_lock_bh(&nf_conntrack_lock); + list_for_each_entry_safe(exp, tmp, &nf_conntrack_expect_list, + list) { + if (del_timer(&exp->timeout)) { + nf_ct_unlink_expect(exp); + nf_conntrack_expect_put(exp); + } + } + write_unlock_bh(&nf_conntrack_lock); + } + + return 0; +} +static int +ctnetlink_change_expect(struct nf_conntrack_expect *x, struct nfattr *cda[]) +{ + return -EOPNOTSUPP; +} + +static int +ctnetlink_create_expect(struct nfattr *cda[], u_int8_t u3) +{ + struct nf_conntrack_tuple tuple, mask, master_tuple; + struct nf_conntrack_tuple_hash *h = NULL; + struct nf_conntrack_expect *exp; + struct nf_conn *ct; + int err = 0; + + DEBUGP("entered %s\n", __FUNCTION__); + + /* caller guarantees that those three CTA_EXPECT_* exist */ + err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3); + if (err < 0) + return err; + err = ctnetlink_parse_tuple(cda, &mask, CTA_EXPECT_MASK, u3); + if (err < 0) + return err; + err = ctnetlink_parse_tuple(cda, &master_tuple, CTA_EXPECT_MASTER, u3); + if (err < 0) + return err; + + /* Look for master conntrack of this expectation */ + h = nf_conntrack_find_get(&master_tuple, NULL); + if (!h) + return -ENOENT; + ct = nf_ct_tuplehash_to_ctrack(h); + + if (!ct->helper) { + /* such conntrack hasn't got any helper, abort */ + err = -EINVAL; + goto out; + } + + exp = nf_conntrack_expect_alloc(ct); + if (!exp) { + err = -ENOMEM; + goto out; + } + + exp->expectfn = NULL; + exp->flags = 0; + exp->master = ct; + memcpy(&exp->tuple, &tuple, sizeof(struct nf_conntrack_tuple)); + memcpy(&exp->mask, &mask, sizeof(struct nf_conntrack_tuple)); + + err = nf_conntrack_expect_related(exp); + nf_conntrack_expect_put(exp); + +out: + nf_ct_put(nf_ct_tuplehash_to_ctrack(h)); + return err; +} + +static int +ctnetlink_new_expect(struct sock *ctnl, struct sk_buff *skb, + struct nlmsghdr *nlh, struct nfattr *cda[], int *errp) +{ + struct nf_conntrack_tuple tuple; + struct nf_conntrack_expect *exp; + struct nfgenmsg *nfmsg = NLMSG_DATA(nlh); + u_int8_t u3 = nfmsg->nfgen_family; + int err = 0; + + DEBUGP("entered %s\n", __FUNCTION__); + + if (nfattr_bad_size(cda, CTA_EXPECT_MAX, cta_min_exp)) + return -EINVAL; + + if (!cda[CTA_EXPECT_TUPLE-1] + || !cda[CTA_EXPECT_MASK-1] + || !cda[CTA_EXPECT_MASTER-1]) + return -EINVAL; + + err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_TUPLE, u3); + if (err < 0) + return err; + + write_lock_bh(&nf_conntrack_lock); + exp = __nf_conntrack_expect_find(&tuple); + + if (!exp) { + write_unlock_bh(&nf_conntrack_lock); + err = -ENOENT; + if (nlh->nlmsg_flags & NLM_F_CREATE) + err = ctnetlink_create_expect(cda, u3); + return err; + } + + err = -EEXIST; + if (!(nlh->nlmsg_flags & NLM_F_EXCL)) + err = ctnetlink_change_expect(exp, cda); + write_unlock_bh(&nf_conntrack_lock); + + DEBUGP("leaving\n"); + + return err; +} + +#ifdef CONFIG_NF_CONNTRACK_EVENTS +static struct notifier_block ctnl_notifier = { + .notifier_call = ctnetlink_conntrack_event, +}; + +static struct notifier_block ctnl_notifier_exp = { + .notifier_call = ctnetlink_expect_event, +}; +#endif + +static struct nfnl_callback ctnl_cb[IPCTNL_MSG_MAX] = { + [IPCTNL_MSG_CT_NEW] = { .call = ctnetlink_new_conntrack, + .attr_count = CTA_MAX, }, + [IPCTNL_MSG_CT_GET] = { .call = ctnetlink_get_conntrack, + .attr_count = CTA_MAX, }, + [IPCTNL_MSG_CT_DELETE] = { .call = ctnetlink_del_conntrack, + .attr_count = CTA_MAX, }, + [IPCTNL_MSG_CT_GET_CTRZERO] = { .call = ctnetlink_get_conntrack, + .attr_count = CTA_MAX, }, +}; + +static struct nfnl_callback ctnl_exp_cb[IPCTNL_MSG_EXP_MAX] = { + [IPCTNL_MSG_EXP_GET] = { .call = ctnetlink_get_expect, + .attr_count = CTA_EXPECT_MAX, }, + [IPCTNL_MSG_EXP_NEW] = { .call = ctnetlink_new_expect, + .attr_count = CTA_EXPECT_MAX, }, + [IPCTNL_MSG_EXP_DELETE] = { .call = ctnetlink_del_expect, + .attr_count = CTA_EXPECT_MAX, }, +}; + +static struct nfnetlink_subsystem ctnl_subsys = { + .name = "conntrack", + .subsys_id = NFNL_SUBSYS_CTNETLINK, + .cb_count = IPCTNL_MSG_MAX, + .cb = ctnl_cb, +}; + +static struct nfnetlink_subsystem ctnl_exp_subsys = { + .name = "conntrack_expect", + .subsys_id = NFNL_SUBSYS_CTNETLINK_EXP, + .cb_count = IPCTNL_MSG_EXP_MAX, + .cb = ctnl_exp_cb, +}; + +MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_CTNETLINK); + +static int __init ctnetlink_init(void) +{ + int ret; + + printk("ctnetlink v%s: registering with nfnetlink.\n", version); + ret = nfnetlink_subsys_register(&ctnl_subsys); + if (ret < 0) { + printk("ctnetlink_init: cannot register with nfnetlink.\n"); + goto err_out; + } + + ret = nfnetlink_subsys_register(&ctnl_exp_subsys); + if (ret < 0) { + printk("ctnetlink_init: cannot register exp with nfnetlink.\n"); + goto err_unreg_subsys; + } + +#ifdef CONFIG_NF_CONNTRACK_EVENTS + ret = nf_conntrack_register_notifier(&ctnl_notifier); + if (ret < 0) { + printk("ctnetlink_init: cannot register notifier.\n"); + goto err_unreg_exp_subsys; + } + + ret = nf_conntrack_expect_register_notifier(&ctnl_notifier_exp); + if (ret < 0) { + printk("ctnetlink_init: cannot expect register notifier.\n"); + goto err_unreg_notifier; + } +#endif + + return 0; + +#ifdef CONFIG_NF_CONNTRACK_EVENTS +err_unreg_notifier: + nf_conntrack_unregister_notifier(&ctnl_notifier); +err_unreg_exp_subsys: + nfnetlink_subsys_unregister(&ctnl_exp_subsys); +#endif +err_unreg_subsys: + nfnetlink_subsys_unregister(&ctnl_subsys); +err_out: + return ret; +} + +static void __exit ctnetlink_exit(void) +{ + printk("ctnetlink: unregistering from nfnetlink.\n"); + +#ifdef CONFIG_NF_CONNTRACK_EVENTS + nf_conntrack_unregister_notifier(&ctnl_notifier_exp); + nf_conntrack_unregister_notifier(&ctnl_notifier); +#endif + + nfnetlink_subsys_unregister(&ctnl_exp_subsys); + nfnetlink_subsys_unregister(&ctnl_subsys); + return; +} + +module_init(ctnetlink_init); +module_exit(ctnetlink_exit); diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 6035633..6167137 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c @@ -1147,6 +1147,63 @@ static int tcp_new(struct nf_conn *conntrack, receiver->td_scale); return 1; } + +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + +#include +#include + +static int tcp_to_nfattr(struct sk_buff *skb, struct nfattr *nfa, + const struct nf_conn *ct) +{ + struct nfattr *nest_parms; + + read_lock_bh(&tcp_lock); + nest_parms = NFA_NEST(skb, CTA_PROTOINFO_TCP); + NFA_PUT(skb, CTA_PROTOINFO_TCP_STATE, sizeof(u_int8_t), + &ct->proto.tcp.state); + read_unlock_bh(&tcp_lock); + + NFA_NEST_END(skb, nest_parms); + + return 0; + +nfattr_failure: + read_unlock_bh(&tcp_lock); + return -1; +} + +static const size_t cta_min_tcp[CTA_PROTOINFO_TCP_MAX] = { + [CTA_PROTOINFO_TCP_STATE-1] = sizeof(u_int8_t), +}; + +static int nfattr_to_tcp(struct nfattr *cda[], struct nf_conn *ct) +{ + struct nfattr *attr = cda[CTA_PROTOINFO_TCP-1]; + struct nfattr *tb[CTA_PROTOINFO_TCP_MAX]; + + /* updates could not contain anything about the private + * protocol info, in that case skip the parsing */ + if (!attr) + return 0; + + nfattr_parse_nested(tb, CTA_PROTOINFO_TCP_MAX, attr); + + if (nfattr_bad_size(tb, CTA_PROTOINFO_TCP_MAX, cta_min_tcp)) + return -EINVAL; + + if (!tb[CTA_PROTOINFO_TCP_STATE-1]) + return -EINVAL; + + write_lock_bh(&tcp_lock); + ct->proto.tcp.state = + *(u_int8_t *)NFA_DATA(tb[CTA_PROTOINFO_TCP_STATE-1]); + write_unlock_bh(&tcp_lock); + + return 0; +} +#endif struct nf_conntrack_protocol nf_conntrack_protocol_tcp4 = { @@ -1160,6 +1217,13 @@ struct nf_conntrack_protocol nf_conntrack_protocol_tcp4 = .packet = tcp_packet, .new = tcp_new, .error = tcp_error4, +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + .to_nfattr = tcp_to_nfattr, + .from_nfattr = nfattr_to_tcp, + .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, + .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, +#endif }; struct nf_conntrack_protocol nf_conntrack_protocol_tcp6 = @@ -1174,6 +1238,13 @@ struct nf_conntrack_protocol nf_conntrack_protocol_tcp6 = .packet = tcp_packet, .new = tcp_new, .error = tcp_error6, +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + .to_nfattr = tcp_to_nfattr, + .from_nfattr = nfattr_to_tcp, + .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, + .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, +#endif }; EXPORT_SYMBOL(nf_conntrack_protocol_tcp4); diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c index 3cae7ce..1a592a5 100644 --- a/net/netfilter/nf_conntrack_proto_udp.c +++ b/net/netfilter/nf_conntrack_proto_udp.c @@ -196,6 +196,11 @@ struct nf_conntrack_protocol nf_conntrack_protocol_udp4 = .packet = udp_packet, .new = udp_new, .error = udp_error4, +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, + .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, +#endif }; struct nf_conntrack_protocol nf_conntrack_protocol_udp6 = @@ -210,6 +215,11 @@ struct nf_conntrack_protocol nf_conntrack_protocol_udp6 = .packet = udp_packet, .new = udp_new, .error = udp_error6, +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) + .tuple_to_nfattr = nf_ct_port_tuple_to_nfattr, + .nfattr_to_tuple = nf_ct_port_nfattr_to_tuple, +#endif }; EXPORT_SYMBOL(nf_conntrack_protocol_udp4); diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index 5af381f..d17e42b 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c @@ -161,14 +161,14 @@ static int ct_seq_show(struct seq_file *s, void *v) if (NF_CT_DIRECTION(hash)) return 0; - l3proto = nf_ct_find_l3proto(conntrack->tuplehash[IP_CT_DIR_ORIGINAL] - .tuple.src.l3num); + l3proto = __nf_ct_l3proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL] + .tuple.src.l3num); NF_CT_ASSERT(l3proto); - proto = nf_ct_find_proto(conntrack->tuplehash[IP_CT_DIR_ORIGINAL] - .tuple.src.l3num, - conntrack->tuplehash[IP_CT_DIR_ORIGINAL] - .tuple.dst.protonum); + proto = __nf_ct_proto_find(conntrack->tuplehash[IP_CT_DIR_ORIGINAL] + .tuple.src.l3num, + conntrack->tuplehash[IP_CT_DIR_ORIGINAL] + .tuple.dst.protonum); NF_CT_ASSERT(proto); if (seq_printf(s, "%-8s %u %-8s %u %ld ", @@ -307,9 +307,9 @@ static int exp_seq_show(struct seq_file *s, void *v) expect->tuple.src.l3num, expect->tuple.dst.protonum); print_tuple(s, &expect->tuple, - nf_ct_find_l3proto(expect->tuple.src.l3num), - nf_ct_find_proto(expect->tuple.src.l3num, - expect->tuple.dst.protonum)); + __nf_ct_l3proto_find(expect->tuple.src.l3num), + __nf_ct_proto_find(expect->tuple.src.l3num, + expect->tuple.dst.protonum)); return seq_putc(s, '\n'); } @@ -847,7 +847,11 @@ EXPORT_SYMBOL(nf_conntrack_helper_unregister); EXPORT_SYMBOL(nf_ct_iterate_cleanup); EXPORT_SYMBOL(__nf_ct_refresh_acct); EXPORT_SYMBOL(nf_ct_protos); -EXPORT_SYMBOL(nf_ct_find_proto); +EXPORT_SYMBOL(__nf_ct_proto_find); +EXPORT_SYMBOL(nf_ct_proto_find_get); +EXPORT_SYMBOL(nf_ct_proto_put); +EXPORT_SYMBOL(nf_ct_l3proto_find_get); +EXPORT_SYMBOL(nf_ct_l3proto_put); EXPORT_SYMBOL(nf_ct_l3protos); EXPORT_SYMBOL(nf_conntrack_expect_alloc); EXPORT_SYMBOL(nf_conntrack_expect_put); @@ -867,3 +871,21 @@ EXPORT_SYMBOL(nf_ct_get_tuple); EXPORT_SYMBOL(nf_ct_invert_tuple); EXPORT_SYMBOL(nf_conntrack_in); EXPORT_SYMBOL(__nf_conntrack_attach); +EXPORT_SYMBOL(nf_conntrack_alloc); +EXPORT_SYMBOL(nf_conntrack_free); +EXPORT_SYMBOL(nf_conntrack_flush); +EXPORT_SYMBOL(nf_ct_remove_expectations); +EXPORT_SYMBOL(nf_ct_helper_find_get); +EXPORT_SYMBOL(nf_ct_helper_put); +EXPORT_SYMBOL(__nf_conntrack_helper_find_byname); +EXPORT_SYMBOL(__nf_conntrack_find); +EXPORT_SYMBOL(nf_ct_unlink_expect); +EXPORT_SYMBOL(nf_conntrack_hash_insert); +EXPORT_SYMBOL(__nf_conntrack_expect_find); +EXPORT_SYMBOL(nf_conntrack_expect_find); +EXPORT_SYMBOL(nf_conntrack_expect_list); +#if defined(CONFIG_NF_CT_NETLINK) || \ + defined(CONFIG_NF_CT_NETLINK_MODULE) +EXPORT_SYMBOL(nf_ct_port_tuple_to_nfattr); +EXPORT_SYMBOL(nf_ct_port_nfattr_to_tuple); +#endif -- cgit v1.1 From 87711cb81c33e75fe8c95137fe62c8d462ff781c Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 5 Jan 2006 12:19:23 -0800 Subject: [NETFILTER]: Filter dumped entries based on the layer 3 protocol number Dump entries of a given Layer 3 protocol number. Signed-off-by: Pablo Neira Ayuso Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/netfilter/nf_conntrack_netlink.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 4f2e509..73ab16b 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -400,6 +400,8 @@ static int ctnetlink_done(struct netlink_callback *cb) return 0; } +#define L3PROTO(ct) ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num + static int ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) { @@ -407,6 +409,8 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) struct nf_conntrack_tuple_hash *h; struct list_head *i; u_int32_t *id = (u_int32_t *) &cb->args[1]; + struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh); + u_int8_t l3proto = nfmsg->nfgen_family; DEBUGP("entered %s, last bucket=%lu id=%u\n", __FUNCTION__, cb->args[0], *id); @@ -418,6 +422,11 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb) if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) continue; ct = nf_ct_tuplehash_to_ctrack(h); + /* Dump entries of a given L3 protocol number. + * If it is not specified, ie. l3proto == 0, + * then dump everything. */ + if (l3proto && L3PROTO(ct) != l3proto) + continue; if (ct->id <= *id) continue; if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, @@ -444,6 +453,8 @@ ctnetlink_dump_table_w(struct sk_buff *skb, struct netlink_callback *cb) struct nf_conntrack_tuple_hash *h; struct list_head *i; u_int32_t *id = (u_int32_t *) &cb->args[1]; + struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh); + u_int8_t l3proto = nfmsg->nfgen_family; DEBUGP("entered %s, last bucket=%u id=%u\n", __FUNCTION__, cb->args[0], *id); @@ -455,6 +466,8 @@ ctnetlink_dump_table_w(struct sk_buff *skb, struct netlink_callback *cb) if (DIRECTION(h) != IP_CT_DIR_ORIGINAL) continue; ct = nf_ct_tuplehash_to_ctrack(h); + if (l3proto && L3PROTO(ct) != l3proto) + continue; if (ct->id <= *id) continue; if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid, @@ -750,9 +763,6 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb, if (nlh->nlmsg_flags & NLM_F_DUMP) { u32 rlen; - if (nfmsg->nfgen_family != AF_INET) - return -EAFNOSUPPORT; - if (NFNL_MSG_TYPE(nlh->nlmsg_type) == IPCTNL_MSG_CT_GET_CTRZERO) { #ifdef CONFIG_NF_CT_ACCT @@ -1251,12 +1261,16 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb) struct nf_conntrack_expect *exp = NULL; struct list_head *i; u_int32_t *id = (u_int32_t *) &cb->args[0]; + struct nfgenmsg *nfmsg = NLMSG_DATA(cb->nlh); + u_int8_t l3proto = nfmsg->nfgen_family; DEBUGP("entered %s, last id=%llu\n", __FUNCTION__, *id); read_lock_bh(&nf_conntrack_lock); list_for_each_prev(i, &nf_conntrack_expect_list) { exp = (struct nf_conntrack_expect *) i; + if (l3proto && exp->tuple.src.l3num != l3proto) + continue; if (exp->id <= *id) continue; if (ctnetlink_exp_fill_info(skb, NETLINK_CB(cb->skb).pid, @@ -1298,9 +1312,6 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb, if (nlh->nlmsg_flags & NLM_F_DUMP) { u32 rlen; - if (nfmsg->nfgen_family != AF_INET) - return -EAFNOSUPPORT; - if ((*errp = netlink_dump_start(ctnl, skb, nlh, ctnetlink_exp_dump_table, ctnetlink_done)) != 0) -- cgit v1.1 From e7be6994ec68c38d8e23e647eac649b280c4fe5a Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 5 Jan 2006 12:19:46 -0800 Subject: [NETFILTER]: Fix module_param types and permissions Fix netfilter module_param types and permissions. Also fix an off-by-one in the ipt_ULOG nlbufsiz < 128k check. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/ip_conntrack_amanda.c | 2 +- net/ipv4/netfilter/ip_conntrack_ftp.c | 2 +- net/ipv4/netfilter/ip_conntrack_irc.c | 10 +++------- net/ipv4/netfilter/ip_conntrack_netbios_ns.c | 2 +- net/ipv4/netfilter/ipt_ULOG.c | 10 +++++----- net/ipv4/netfilter/ipt_recent.c | 20 ++++++++++---------- net/netfilter/nf_conntrack_ftp.c | 2 +- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c index 0366eed..84e4f79 100644 --- a/net/ipv4/netfilter/ip_conntrack_amanda.c +++ b/net/ipv4/netfilter/ip_conntrack_amanda.c @@ -36,7 +36,7 @@ static unsigned int master_timeout = 300; MODULE_AUTHOR("Brian J. Murrell "); MODULE_DESCRIPTION("Amanda connection tracking module"); MODULE_LICENSE("GPL"); -module_param(master_timeout, int, 0600); +module_param(master_timeout, uint, 0600); MODULE_PARM_DESC(master_timeout, "timeout for the master connection"); static const char *conns[] = { "DATA ", "MESG ", "INDEX " }; diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c index 68b173b..e627e58 100644 --- a/net/ipv4/netfilter/ip_conntrack_ftp.c +++ b/net/ipv4/netfilter/ip_conntrack_ftp.c @@ -34,7 +34,7 @@ static int ports_c; module_param_array(ports, ushort, &ports_c, 0400); static int loose; -module_param(loose, int, 0600); +module_param(loose, bool, 0600); unsigned int (*ip_nat_ftp_hook)(struct sk_buff **pskb, enum ip_conntrack_info ctinfo, diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c index d7c4042..c51a2cf 100644 --- a/net/ipv4/netfilter/ip_conntrack_irc.c +++ b/net/ipv4/netfilter/ip_conntrack_irc.c @@ -36,7 +36,7 @@ #define MAX_PORTS 8 static unsigned short ports[MAX_PORTS]; static int ports_c; -static int max_dcc_channels = 8; +static unsigned int max_dcc_channels = 8; static unsigned int dcc_timeout = 300; /* This is slow, but it's simple. --RR */ static char *irc_buffer; @@ -54,9 +54,9 @@ MODULE_DESCRIPTION("IRC (DCC) connection tracking helper"); MODULE_LICENSE("GPL"); module_param_array(ports, ushort, &ports_c, 0400); MODULE_PARM_DESC(ports, "port numbers of IRC servers"); -module_param(max_dcc_channels, int, 0400); +module_param(max_dcc_channels, uint, 0400); MODULE_PARM_DESC(max_dcc_channels, "max number of expected DCC channels per IRC session"); -module_param(dcc_timeout, int, 0400); +module_param(dcc_timeout, uint, 0400); MODULE_PARM_DESC(dcc_timeout, "timeout on for unestablished DCC channels"); static const char *dccprotos[] = { "SEND ", "CHAT ", "MOVE ", "TSEND ", "SCHAT " }; @@ -254,10 +254,6 @@ static int __init init(void) printk("ip_conntrack_irc: max_dcc_channels must be a positive integer\n"); return -EBUSY; } - if (dcc_timeout < 0) { - printk("ip_conntrack_irc: dcc_timeout must be a positive integer\n"); - return -EBUSY; - } irc_buffer = kmalloc(65536, GFP_KERNEL); if (!irc_buffer) diff --git a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c index 186646e..4e68e16 100644 --- a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c +++ b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c @@ -37,7 +37,7 @@ MODULE_DESCRIPTION("NetBIOS name service broadcast connection tracking helper"); MODULE_LICENSE("GPL"); static unsigned int timeout = 3; -module_param(timeout, int, 0600); +module_param(timeout, uint, 0400); MODULE_PARM_DESC(timeout, "timeout for master connection/replies in seconds"); static int help(struct sk_buff **pskb, diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c index 2883ccd..38641cd 100644 --- a/net/ipv4/netfilter/ipt_ULOG.c +++ b/net/ipv4/netfilter/ipt_ULOG.c @@ -77,15 +77,15 @@ MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NFLOG); #define PRINTR(format, args...) do { if (net_ratelimit()) printk(format , ## args); } while (0) static unsigned int nlbufsiz = 4096; -module_param(nlbufsiz, uint, 0600); /* FIXME: Check size < 128k --RR */ +module_param(nlbufsiz, uint, 0400); MODULE_PARM_DESC(nlbufsiz, "netlink buffer size"); static unsigned int flushtimeout = 10; -module_param(flushtimeout, int, 0600); +module_param(flushtimeout, uint, 0600); MODULE_PARM_DESC(flushtimeout, "buffer flush timeout (hundredths of a second)"); -static unsigned int nflog = 1; -module_param(nflog, int, 0400); +static int nflog = 1; +module_param(nflog, bool, 0400); MODULE_PARM_DESC(nflog, "register as internal netfilter logging module"); /* global data structures */ @@ -376,7 +376,7 @@ static int __init init(void) DEBUGP("ipt_ULOG: init module\n"); - if (nlbufsiz >= 128*1024) { + if (nlbufsiz > 128*1024) { printk("Netlink buffer has to be <= 128kB\n"); return -EINVAL; } diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c index 261cbb4..5ddccb1 100644 --- a/net/ipv4/netfilter/ipt_recent.c +++ b/net/ipv4/netfilter/ipt_recent.c @@ -24,10 +24,10 @@ #define HASH_LOG 9 /* Defaults, these can be overridden on the module command-line. */ -static int ip_list_tot = 100; -static int ip_pkt_list_tot = 20; -static int ip_list_hash_size = 0; -static int ip_list_perms = 0644; +static unsigned int ip_list_tot = 100; +static unsigned int ip_pkt_list_tot = 20; +static unsigned int ip_list_hash_size = 0; +static unsigned int ip_list_perms = 0644; #ifdef DEBUG static int debug = 1; #endif @@ -38,13 +38,13 @@ KERN_INFO RECENT_NAME " " RECENT_VER ": Stephen Frost . htt MODULE_AUTHOR("Stephen Frost "); MODULE_DESCRIPTION("IP tables recently seen matching module " RECENT_VER); MODULE_LICENSE("GPL"); -module_param(ip_list_tot, int, 0400); -module_param(ip_pkt_list_tot, int, 0400); -module_param(ip_list_hash_size, int, 0400); -module_param(ip_list_perms, int, 0400); +module_param(ip_list_tot, uint, 0400); +module_param(ip_pkt_list_tot, uint, 0400); +module_param(ip_list_hash_size, uint, 0400); +module_param(ip_list_perms, uint, 0400); #ifdef DEBUG -module_param(debug, int, 0600); -MODULE_PARM_DESC(debug,"debugging level, defaults to 1"); +module_param(debug, bool, 0600); +MODULE_PARM_DESC(debug,"enable debugging output"); #endif MODULE_PARM_DESC(ip_list_tot,"number of IPs to remember per list"); MODULE_PARM_DESC(ip_pkt_list_tot,"number of packets per IP to remember"); diff --git a/net/netfilter/nf_conntrack_ftp.c b/net/netfilter/nf_conntrack_ftp.c index 65080e26..d5a6eaf 100644 --- a/net/netfilter/nf_conntrack_ftp.c +++ b/net/netfilter/nf_conntrack_ftp.c @@ -44,7 +44,7 @@ static unsigned int ports_c; module_param_array(ports, ushort, &ports_c, 0400); static int loose; -module_param(loose, int, 0600); +module_param(loose, bool, 0600); unsigned int (*nf_nat_ftp_hook)(struct sk_buff **pskb, enum ip_conntrack_info ctinfo, -- cgit v1.1 From a9b305c4e56f97d6a2ae4f21691bc13797498caf Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 5 Jan 2006 12:20:02 -0800 Subject: [NETFILTER]: ctnetlink: Fix dumping of helper name Properly dump the helper name instead of internal kernel data. Based on patch by Marcus Sundberg . Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- include/linux/netfilter/nfnetlink_conntrack.h | 2 -- net/ipv4/netfilter/ip_conntrack_netlink.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h index b8e9a5b..668ec94 100644 --- a/include/linux/netfilter/nfnetlink_conntrack.h +++ b/include/linux/netfilter/nfnetlink_conntrack.h @@ -131,6 +131,4 @@ enum ctattr_help { }; #define CTA_HELP_MAX (__CTA_HELP_MAX - 1) -#define CTA_HELP_MAXNAMESIZE 32 - #endif /* _IPCONNTRACK_NETLINK_H */ diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index 703f2d2..c9ebbe0 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c @@ -161,7 +161,7 @@ ctnetlink_dump_helpinfo(struct sk_buff *skb, const struct ip_conntrack *ct) return 0; nest_helper = NFA_NEST(skb, CTA_HELP); - NFA_PUT(skb, CTA_HELP_NAME, CTA_HELP_MAXNAMESIZE, &ct->helper->name); + NFA_PUT(skb, CTA_HELP_NAME, strlen(ct->helper->name), ct->helper->name); if (ct->helper->to_nfattr) ct->helper->to_nfattr(skb, ct); -- cgit v1.1 From abbcc73982445c1457901c7fc1d0d110e7a587e3 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 5 Jan 2006 12:20:40 -0800 Subject: [NETFILTER]: Remove okfn usage in ip_vs_core.c okfn should only be used from different contexts to avoid deep call chains, i.e. by nf_queue. Acked-by: Julian Anastasov Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/ipvs/ip_vs_core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c index 1aca94a..3f47ad8 100644 --- a/net/ipv4/ipvs/ip_vs_core.c +++ b/net/ipv4/ipvs/ip_vs_core.c @@ -532,11 +532,8 @@ static unsigned int ip_vs_post_routing(unsigned int hooknum, { if (!((*pskb)->ipvs_property)) return NF_ACCEPT; - /* The packet was sent from IPVS, exit this chain */ - (*okfn)(*pskb); - - return NF_STOLEN; + return NF_STOP; } u16 ip_vs_checksum_complete(struct sk_buff *skb, int offset) -- cgit v1.1 From 1bd9bef6f9fe06dd0c628ac877c85b6b36aca062 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 5 Jan 2006 12:20:59 -0800 Subject: [NETFILTER]: Call POST_ROUTING hook before fragmentation Call POST_ROUTING hook before fragmentation to get rid of the okfn use in ip_refrag and save the useless fragmentation/defragmentation step when NAT is used. The patch introduces one user-visible change, the POSTROUTING chain in the mangle table gets entire packets, not fragments, which should simplify use of the MARK and CLASSIFY targets for queueing as a nice side-effect. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- include/net/ip.h | 1 - net/ipv4/ip_output.c | 30 ++++++++++++-------------- net/ipv4/netfilter/ip_conntrack_standalone.c | 26 +--------------------- net/ipv4/netfilter/ip_nat_standalone.c | 17 --------------- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 26 +--------------------- 5 files changed, 16 insertions(+), 84 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index f7e7fd7..7bb5804 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -317,7 +317,6 @@ enum ip_defrag_users IP_DEFRAG_CALL_RA_CHAIN, IP_DEFRAG_CONNTRACK_IN, IP_DEFRAG_CONNTRACK_OUT, - IP_DEFRAG_NAT_OUT, IP_DEFRAG_VS_IN, IP_DEFRAG_VS_OUT, IP_DEFRAG_VS_FWD diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 2a830de..71da318 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -202,13 +202,11 @@ static inline int ip_finish_output2(struct sk_buff *skb) static inline int ip_finish_output(struct sk_buff *skb) { - struct net_device *dev = skb->dst->dev; - - skb->dev = dev; - skb->protocol = htons(ETH_P_IP); - - return NF_HOOK(PF_INET, NF_IP_POST_ROUTING, skb, NULL, dev, - ip_finish_output2); + if (skb->len > dst_mtu(skb->dst) && + !(skb_shinfo(skb)->ufo_size || skb_shinfo(skb)->tso_size)) + return ip_fragment(skb, ip_finish_output2); + else + return ip_finish_output2(skb); } int ip_mc_output(struct sk_buff *skb) @@ -265,21 +263,21 @@ int ip_mc_output(struct sk_buff *skb) newskb->dev, ip_dev_loopback_xmit); } - if (skb->len > dst_mtu(&rt->u.dst)) - return ip_fragment(skb, ip_finish_output); - else - return ip_finish_output(skb); + return NF_HOOK(PF_INET, NF_IP_POST_ROUTING, skb, NULL, skb->dev, + ip_finish_output); } int ip_output(struct sk_buff *skb) { + struct net_device *dev = skb->dst->dev; + IP_INC_STATS(IPSTATS_MIB_OUTREQUESTS); - if (skb->len > dst_mtu(skb->dst) && - !(skb_shinfo(skb)->ufo_size || skb_shinfo(skb)->tso_size)) - return ip_fragment(skb, ip_finish_output); - else - return ip_finish_output(skb); + skb->dev = dev; + skb->protocol = htons(ETH_P_IP); + + return NF_HOOK(PF_INET, NF_IP_POST_ROUTING, skb, NULL, dev, + ip_finish_output); } int ip_queue_xmit(struct sk_buff *skb, int ipfragok) diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c index a88bcc5..7ba9778 100644 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c @@ -451,30 +451,6 @@ static unsigned int ip_conntrack_defrag(unsigned int hooknum, return NF_ACCEPT; } -static unsigned int ip_refrag(unsigned int hooknum, - struct sk_buff **pskb, - const struct net_device *in, - const struct net_device *out, - int (*okfn)(struct sk_buff *)) -{ - struct rtable *rt = (struct rtable *)(*pskb)->dst; - - /* We've seen it coming out the other side: confirm */ - if (ip_confirm(hooknum, pskb, in, out, okfn) != NF_ACCEPT) - return NF_DROP; - - /* Local packets are never produced too large for their - interface. We degfragment them at LOCAL_OUT, however, - so we have to refragment them here. */ - if ((*pskb)->len > dst_mtu(&rt->u.dst) && - !skb_shinfo(*pskb)->tso_size) { - /* No hook can be after us, so this should be OK. */ - ip_fragment(*pskb, okfn); - return NF_STOLEN; - } - return NF_ACCEPT; -} - static unsigned int ip_conntrack_local(unsigned int hooknum, struct sk_buff **pskb, const struct net_device *in, @@ -544,7 +520,7 @@ static struct nf_hook_ops ip_conntrack_helper_in_ops = { /* Refragmenter; last chance. */ static struct nf_hook_ops ip_conntrack_out_ops = { - .hook = ip_refrag, + .hook = ip_confirm, .owner = THIS_MODULE, .pf = PF_INET, .hooknum = NF_IP_POST_ROUTING, diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c index 30cd4e1..f04111f 100644 --- a/net/ipv4/netfilter/ip_nat_standalone.c +++ b/net/ipv4/netfilter/ip_nat_standalone.c @@ -190,23 +190,6 @@ ip_nat_out(unsigned int hooknum, || (*pskb)->nh.iph->ihl * 4 < sizeof(struct iphdr)) return NF_ACCEPT; - /* We can hit fragment here; forwarded packets get - defragmented by connection tracking coming in, then - fragmented (grr) by the forward code. - - In future: If we have nfct != NULL, AND we have NAT - initialized, AND there is no helper, then we can do full - NAPT on the head, and IP-address-only NAT on the rest. - - I'm starting to have nightmares about fragments. */ - - if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) { - *pskb = ip_ct_gather_frags(*pskb, IP_DEFRAG_NAT_OUT); - - if (!*pskb) - return NF_STOLEN; - } - return ip_nat_fn(hooknum, pskb, in, out, okfn); } diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index 385867e..1d36e8e 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c @@ -180,30 +180,6 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, return NF_ACCEPT; } -static unsigned int ipv4_refrag(unsigned int hooknum, - struct sk_buff **pskb, - const struct net_device *in, - const struct net_device *out, - int (*okfn)(struct sk_buff *)) -{ - struct rtable *rt = (struct rtable *)(*pskb)->dst; - - /* We've seen it coming out the other side: confirm */ - if (ipv4_confirm(hooknum, pskb, in, out, okfn) != NF_ACCEPT) - return NF_DROP; - - /* Local packets are never produced too large for their - interface. We degfragment them at LOCAL_OUT, however, - so we have to refragment them here. */ - if ((*pskb)->len > dst_mtu(&rt->u.dst) && - !skb_shinfo(*pskb)->tso_size) { - /* No hook can be after us, so this should be OK. */ - ip_fragment(*pskb, okfn); - return NF_STOLEN; - } - return NF_ACCEPT; -} - static unsigned int ipv4_conntrack_in(unsigned int hooknum, struct sk_buff **pskb, const struct net_device *in, @@ -283,7 +259,7 @@ static struct nf_hook_ops ipv4_conntrack_helper_in_ops = { /* Refragmenter; last chance. */ static struct nf_hook_ops ipv4_conntrack_out_ops = { - .hook = ipv4_refrag, + .hook = ipv4_confirm, .owner = THIS_MODULE, .pf = PF_INET, .hooknum = NF_IP_POST_ROUTING, -- cgit v1.1 From b777e0ce7437a0e788e2aeb42aca9af2cce1f2e1 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 5 Jan 2006 12:21:16 -0800 Subject: [NETFILTER]: make ipv6_find_hdr() find transport protocol header The original ipv6_find_hdr() finds the specified header in IPv6 packets. This makes it possible to get transport header so that we can kill similar loop in ip6_match_packet(). Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- include/linux/netfilter_ipv6/ip6_tables.h | 2 +- net/ipv6/netfilter/ip6_tables.c | 106 +++++++++++------------------- net/ipv6/netfilter/ip6t_ah.c | 2 +- net/ipv6/netfilter/ip6t_dst.c | 4 +- net/ipv6/netfilter/ip6t_esp.c | 2 +- net/ipv6/netfilter/ip6t_frag.c | 2 +- net/ipv6/netfilter/ip6t_hbh.c | 4 +- net/ipv6/netfilter/ip6t_rt.c | 2 +- 8 files changed, 49 insertions(+), 75 deletions(-) diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h index 2efc046..a291cb7 100644 --- a/include/linux/netfilter_ipv6/ip6_tables.h +++ b/include/linux/netfilter_ipv6/ip6_tables.h @@ -474,7 +474,7 @@ extern unsigned int ip6t_do_table(struct sk_buff **pskb, extern int ip6t_ext_hdr(u8 nexthdr); /* find specified header and get offset to it */ extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, - u8 target); + int target, unsigned short *fragoff); #define IP6T_ALIGN(s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1)) diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index ea43ef1..13b1a52 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -205,69 +205,21 @@ ip6_packet_match(const struct sk_buff *skb, /* look for the desired protocol header */ if((ip6info->flags & IP6T_F_PROTO)) { - u_int8_t currenthdr = ipv6->nexthdr; - struct ipv6_opt_hdr _hdr, *hp; - u_int16_t ptr; /* Header offset in skb */ - u_int16_t hdrlen; /* Header */ - u_int16_t _fragoff = 0, *fp = NULL; - - ptr = IPV6_HDR_LEN; - - while (ip6t_ext_hdr(currenthdr)) { - /* Is there enough space for the next ext header? */ - if (skb->len - ptr < IPV6_OPTHDR_LEN) - return 0; - - /* NONE or ESP: there isn't protocol part */ - /* If we want to count these packets in '-p all', - * we will change the return 0 to 1*/ - if ((currenthdr == IPPROTO_NONE) || - (currenthdr == IPPROTO_ESP)) - break; + int protohdr; + unsigned short _frag_off; - hp = skb_header_pointer(skb, ptr, sizeof(_hdr), &_hdr); - BUG_ON(hp == NULL); - - /* Size calculation */ - if (currenthdr == IPPROTO_FRAGMENT) { - fp = skb_header_pointer(skb, - ptr+offsetof(struct frag_hdr, - frag_off), - sizeof(_fragoff), - &_fragoff); - if (fp == NULL) - return 0; - - _fragoff = ntohs(*fp) & ~0x7; - hdrlen = 8; - } else if (currenthdr == IPPROTO_AH) - hdrlen = (hp->hdrlen+2)<<2; - else - hdrlen = ipv6_optlen(hp); - - currenthdr = hp->nexthdr; - ptr += hdrlen; - /* ptr is too large */ - if ( ptr > skb->len ) - return 0; - if (_fragoff) { - if (ip6t_ext_hdr(currenthdr)) - return 0; - break; - } - } - - *protoff = ptr; - *fragoff = _fragoff; + protohdr = ipv6_find_hdr(skb, protoff, -1, &_frag_off); + if (protohdr < 0) + return 0; - /* currenthdr contains the protocol header */ + *fragoff = _frag_off; dprintf("Packet protocol %hi ?= %s%hi.\n", - currenthdr, + protohdr, ip6info->invflags & IP6T_INV_PROTO ? "!":"", ip6info->proto); - if (ip6info->proto == currenthdr) { + if (ip6info->proto == protohdr) { if(ip6info->invflags & IP6T_INV_PROTO) { return 0; } @@ -2098,26 +2050,39 @@ static void __exit fini(void) } /* - * find specified header up to transport protocol header. - * If found target header, the offset to the header is set to *offset - * and return 0. otherwise, return -1. + * find the offset to specified header or the protocol number of last header + * if target < 0. "last header" is transport protocol header, ESP, or + * "No next header". + * + * If target header is found, its offset is set in *offset and return protocol + * number. Otherwise, return -1. + * + * Note that non-1st fragment is special case that "the protocol number + * of last header" is "next header" field in Fragment header. In this case, + * *offset is meaningless and fragment offset is stored in *fragoff if fragoff + * isn't NULL. * - * Notes: - non-1st Fragment Header isn't skipped. - * - ESP header isn't skipped. - * - The target header may be trancated. */ -int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, u8 target) +int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, + int target, unsigned short *fragoff) { unsigned int start = (u8*)(skb->nh.ipv6h + 1) - skb->data; u8 nexthdr = skb->nh.ipv6h->nexthdr; unsigned int len = skb->len - start; + if (fragoff) + *fragoff = 0; + while (nexthdr != target) { struct ipv6_opt_hdr _hdr, *hp; unsigned int hdrlen; - if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) + if ((!ipv6_ext_hdr(nexthdr)) || nexthdr == NEXTHDR_NONE) { + if (target < 0) + break; return -1; + } + hp = skb_header_pointer(skb, start, sizeof(_hdr), &_hdr); if (hp == NULL) return -1; @@ -2131,8 +2096,17 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, u8 target) if (fp == NULL) return -1; - if (ntohs(*fp) & ~0x7) + _frag_off = ntohs(*fp) & ~0x7; + if (_frag_off) { + if (target < 0 && + ((!ipv6_ext_hdr(hp->nexthdr)) || + nexthdr == NEXTHDR_NONE)) { + if (fragoff) + *fragoff = _frag_off; + return hp->nexthdr; + } return -1; + } hdrlen = 8; } else if (nexthdr == NEXTHDR_AUTH) hdrlen = (hp->hdrlen + 2) << 2; @@ -2145,7 +2119,7 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, u8 target) } *offset = start; - return 0; + return nexthdr; } EXPORT_SYMBOL(ip6t_register_table); diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c index 268918d..f5c1a7ff 100644 --- a/net/ipv6/netfilter/ip6t_ah.c +++ b/net/ipv6/netfilter/ip6t_ah.c @@ -54,7 +54,7 @@ match(const struct sk_buff *skb, unsigned int ptr; unsigned int hdrlen = 0; - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_AUTH) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_AUTH, NULL) < 0) return 0; ah = skb_header_pointer(skb, ptr, sizeof(_ah), &_ah); diff --git a/net/ipv6/netfilter/ip6t_dst.c b/net/ipv6/netfilter/ip6t_dst.c index c450a63..48cf5f9 100644 --- a/net/ipv6/netfilter/ip6t_dst.c +++ b/net/ipv6/netfilter/ip6t_dst.c @@ -71,9 +71,9 @@ match(const struct sk_buff *skb, unsigned int optlen; #if HOPBYHOP - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_HOP) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_HOP, NULL) < 0) #else - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST, NULL) < 0) #endif return 0; diff --git a/net/ipv6/netfilter/ip6t_esp.c b/net/ipv6/netfilter/ip6t_esp.c index 65937de..e1828f6 100644 --- a/net/ipv6/netfilter/ip6t_esp.c +++ b/net/ipv6/netfilter/ip6t_esp.c @@ -56,7 +56,7 @@ match(const struct sk_buff *skb, /* Make sure this isn't an evil packet */ /*DEBUGP("ipv6_esp entered \n");*/ - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_ESP) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_ESP, NULL) < 0) return 0; eh = skb_header_pointer(skb, ptr, sizeof(_esp), &_esp); diff --git a/net/ipv6/netfilter/ip6t_frag.c b/net/ipv6/netfilter/ip6t_frag.c index 085d5f8..d1549b2 100644 --- a/net/ipv6/netfilter/ip6t_frag.c +++ b/net/ipv6/netfilter/ip6t_frag.c @@ -52,7 +52,7 @@ match(const struct sk_buff *skb, const struct ip6t_frag *fraginfo = matchinfo; unsigned int ptr; - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_FRAGMENT) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_FRAGMENT, NULL) < 0) return 0; fh = skb_header_pointer(skb, ptr, sizeof(_frag), &_frag); diff --git a/net/ipv6/netfilter/ip6t_hbh.c b/net/ipv6/netfilter/ip6t_hbh.c index 1d09485..e3bc8e2 100644 --- a/net/ipv6/netfilter/ip6t_hbh.c +++ b/net/ipv6/netfilter/ip6t_hbh.c @@ -71,9 +71,9 @@ match(const struct sk_buff *skb, unsigned int optlen; #if HOPBYHOP - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_HOP) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_HOP, NULL) < 0) #else - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_DEST, NULL) < 0) #endif return 0; diff --git a/net/ipv6/netfilter/ip6t_rt.c b/net/ipv6/netfilter/ip6t_rt.c index beb2fd5..c1e770e 100644 --- a/net/ipv6/netfilter/ip6t_rt.c +++ b/net/ipv6/netfilter/ip6t_rt.c @@ -58,7 +58,7 @@ match(const struct sk_buff *skb, unsigned int ret = 0; struct in6_addr *ap, _addr; - if (ipv6_find_hdr(skb, &ptr, NEXTHDR_ROUTING) < 0) + if (ipv6_find_hdr(skb, &ptr, NEXTHDR_ROUTING, NULL) < 0) return 0; rh = skb_header_pointer(skb, ptr, sizeof(_route), &_route); -- cgit v1.1 From 22dea562bb56dbc3430c8f23f60ccd38527b1f5a Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 5 Jan 2006 12:21:34 -0800 Subject: [NETFILTER]: Export ip6_masked_addrcmp, don't pass IPv6 addresses on stack Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- include/linux/netfilter_ipv6/ip6_tables.h | 4 ++++ net/ipv6/netfilter/ip6_tables.c | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h index a291cb7..c163ba3 100644 --- a/include/linux/netfilter_ipv6/ip6_tables.h +++ b/include/linux/netfilter_ipv6/ip6_tables.h @@ -476,6 +476,10 @@ extern int ip6t_ext_hdr(u8 nexthdr); extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, int target, unsigned short *fragoff); +extern int ip6_masked_addrcmp(const struct in6_addr *addr1, + const struct in6_addr *mask, + const struct in6_addr *addr2); + #define IP6T_ALIGN(s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1)) #endif /*__KERNEL__*/ diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 13b1a52..925b42d4 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c @@ -119,13 +119,14 @@ static LIST_HEAD(ip6t_tables); #define up(x) do { printk("UP:%u:" #x "\n", __LINE__); up(x); } while(0) #endif -static int ip6_masked_addrcmp(struct in6_addr addr1, struct in6_addr mask, - struct in6_addr addr2) +int +ip6_masked_addrcmp(const struct in6_addr *addr1, const struct in6_addr *mask, + const struct in6_addr *addr2) { int i; for( i = 0; i < 16; i++){ - if((addr1.s6_addr[i] & mask.s6_addr[i]) != - (addr2.s6_addr[i] & mask.s6_addr[i])) + if((addr1->s6_addr[i] & mask->s6_addr[i]) != + (addr2->s6_addr[i] & mask->s6_addr[i])) return 1; } return 0; @@ -159,10 +160,10 @@ ip6_packet_match(const struct sk_buff *skb, #define FWINV(bool,invflg) ((bool) ^ !!(ip6info->invflags & invflg)) - if (FWINV(ip6_masked_addrcmp(ipv6->saddr,ip6info->smsk,ip6info->src), - IP6T_INV_SRCIP) - || FWINV(ip6_masked_addrcmp(ipv6->daddr,ip6info->dmsk,ip6info->dst), - IP6T_INV_DSTIP)) { + if (FWINV(ip6_masked_addrcmp(&ipv6->saddr, &ip6info->smsk, + &ip6info->src), IP6T_INV_SRCIP) + || FWINV(ip6_masked_addrcmp(&ipv6->daddr, &ip6info->dmsk, + &ip6info->dst), IP6T_INV_DSTIP)) { dprintf("Source or dest mismatch.\n"); /* dprintf("SRC: %u. Mask: %u. Target: %u.%s\n", ip->saddr, @@ -2131,6 +2132,7 @@ EXPORT_SYMBOL(ip6t_register_target); EXPORT_SYMBOL(ip6t_unregister_target); EXPORT_SYMBOL(ip6t_ext_hdr); EXPORT_SYMBOL(ipv6_find_hdr); +EXPORT_SYMBOL(ip6_masked_addrcmp); module_init(init); module_exit(fini); -- cgit v1.1 From 0ae2cfe7f3d88f061aa2656c7e881d3a0697d622 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Thu, 5 Jan 2006 12:21:52 -0800 Subject: [NETFILTER]: nf_conntrack_l3proto_ipv4.c needs net/route.h CC [M] net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.o net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c: In function 'ipv4_refrag': net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c:198: error: dereferencing pointer to incomplete type make[3]: *** [net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.o] Error 1 Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c index 1d36e8e..9bdbb77 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include -- cgit v1.1 From e8eaedf2f8b368c26aa31a5a5a623b6867ef7f2b Mon Sep 17 00:00:00 2001 From: Yasuyuki Kozakai Date: Thu, 5 Jan 2006 12:28:57 -0800 Subject: [NETFILTER]: Use HOPLIMIT metric as TTL of TCP reset sent by REJECT HOPLIMIT metric is appropriate to TCP reset sent by REJECT target than hard-coded max TTL. Thanks to David S. Miller for hint. Signed-off-by: Yasuyuki Kozakai Signed-off-by: David S. Miller --- net/ipv4/netfilter/ipt_REJECT.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c index f057025..6693526 100644 --- a/net/ipv4/netfilter/ipt_REJECT.c +++ b/net/ipv4/netfilter/ipt_REJECT.c @@ -203,7 +203,7 @@ static void send_reset(struct sk_buff *oldskb, int hook) sizeof(struct tcphdr), 0)); /* Adjust IP TTL, DF */ - nskb->nh.iph->ttl = MAXTTL; + nskb->nh.iph->ttl = dst_metric(nskb->dst, RTAX_HOPLIMIT); /* Set DF, id = 0 */ nskb->nh.iph->frag_off = htons(IP_DF); nskb->nh.iph->id = 0; -- cgit v1.1 From 5b373e10aeadc2599c085a3357b7fad8b8e760b8 Mon Sep 17 00:00:00 2001 From: "Luis F. Ortiz" Date: Thu, 5 Jan 2006 13:12:41 -0800 Subject: [ATYFB]: Fix onboard video on SPARC Blade 100 for 2.6.{13,14,15} I have recently been switching from using 2.4.32 on my trusty old Sparc Blade 100 to using 2.6.15 . Some of the problems I ran into were distorted video when the console was active (missing first character, skipped dots) and when running X windows (colored snow, stripes, missing pixels). A quick examination of the 2.6 versus 2.4 source for the ATY driver revealed alot of changes. A closer look at the code/data for the 64GR/XL chip revealed two minor "typos" that the rewriter(s) of the code made. The first is a incorrect clock value (230 .vs. 235) and the second is a missing flag (M64F_SDRAM_MAGIC_PLL). Making both these changes seems to have fixed my problem. I tend to think the 235 value is the correct one, as there is a 29.4 Mhz clock crystal close to the video chip and 235.2 (29.4*8) is too close to 235 to make it a coincidence. The flag for M64F_SDRAM_MAGIC_PLL was dropped during the changes made by adaplas in file revision 1.72 on the old bitkeeper repository. The change relating to the clock rate has been there forever, at least in the 2.6 tree. I'm not sure where to look for the old 2.5 tree or if anyone cares when it happened. On SPARC Blades 100's, which use the ATY MACH64GR video chipset, the clock crystal frequency is 235.2 Mhz, not 230 Mhz. The chipset also requires the use of M64F_SDRAM_MAGIC_PLL in order to setup the PLL properly for the DRAM. Signed-off-by: Luis F. Ortiz Signed-off-by: David S. Miller --- drivers/video/aty/atyfb_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c index 08edbfc..3fefdb0c 100644 --- a/drivers/video/aty/atyfb_base.c +++ b/drivers/video/aty/atyfb_base.c @@ -403,7 +403,7 @@ static struct { { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP)", 230, 83, 63, ATI_CHIP_264XL }, { PCI_CHIP_MACH64GN, "3D RAGE XL (Mach64 GN, AGP)", 230, 83, 63, ATI_CHIP_264XL }, { PCI_CHIP_MACH64GO, "3D RAGE XL (Mach64 GO, PCI-66/BGA)", 230, 83, 63, ATI_CHIP_264XL }, - { PCI_CHIP_MACH64GR, "3D RAGE XL (Mach64 GR, PCI-33MHz)", 230, 83, 63, ATI_CHIP_264XL }, + { PCI_CHIP_MACH64GR, "3D RAGE XL (Mach64 GR, PCI-33MHz)", 235, 83, 63, ATI_CHIP_264XL | M64F_SDRAM_MAGIC_PLL }, { PCI_CHIP_MACH64GL, "3D RAGE XL (Mach64 GL, PCI)", 230, 83, 63, ATI_CHIP_264XL }, { PCI_CHIP_MACH64GS, "3D RAGE XL (Mach64 GS, PCI)", 230, 83, 63, ATI_CHIP_264XL }, -- cgit v1.1 From 38c0b2c2aaab5595a140ade4410e01d407fff751 Mon Sep 17 00:00:00 2001 From: Tony Luck Date: Thu, 5 Jan 2006 13:30:52 -0800 Subject: [IA64] Fix compile warnings in setup.c arch/ia64/kernel/setup.c: In function `show_cpuinfo': arch/ia64/kernel/setup.c:576: warning: long unsigned int format, different type arg (arg 12) arch/ia64/kernel/setup.c:576: warning: long unsigned int format, different type arg (arg 13) Introduced by 95235ca2c20ac0b31a8eb39e2d599bcc3e9c9a10 Signed-off-by: Tony Luck --- arch/ia64/kernel/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 088e5dd..c33305d 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -518,7 +518,7 @@ show_cpuinfo (struct seq_file *m, void *v) char family[32], features[128], *cp, sep; struct cpuinfo_ia64 *c = v; unsigned long mask; - unsigned int proc_freq; + unsigned long proc_freq; int i; mask = c->features; -- cgit v1.1 From 37f779554404ddca981ac4b4cc6692fc09b71e96 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Wed, 7 Sep 2005 16:00:26 -0700 Subject: [PATCH] pcmcia: avoid macro usage in cistpl Fix macro abuse in pcmcia. Signed-off-by: Pavel Machek Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cistpl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 2dc3e61..55d7247 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -60,9 +60,9 @@ static const u_int exponent[] = { /* Parameters that can be set with 'insmod' */ -#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444) - -INT_MODULE_PARM(cis_width, 0); /* 16-bit CIS? */ +/* 16-bit CIS? */ +static int cis_width; +module_param(cis_width, int, 0444); void release_cis_mem(struct pcmcia_socket *s) { -- cgit v1.1 From e4115805cf2020da94e8bd1296243605cda487ff Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Tue, 20 Sep 2005 14:17:37 -0700 Subject: [PATCH] yenta: optimize interrupt handler Don't waste cpu time in yenta interrupt handler when the interrupt was for another device. Signed-off-by: Daniel Ritz Signed-off-by: Dominik Brodowski --- drivers/pcmcia/yenta_socket.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index ec6ab65..8bfe72b 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -531,6 +531,9 @@ static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs) csc = exca_readb(socket, I365_CSC); + if (!(cb_event || csc)) + return IRQ_NONE; + events = (cb_event & (CB_CD1EVENT | CB_CD2EVENT)) ? SS_DETECT : 0 ; events |= (csc & I365_CSC_DETECT) ? SS_DETECT : 0; if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) { @@ -544,10 +547,7 @@ static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (events) pcmcia_parse_events(&socket->socket, events); - if (cb_event || csc) - return IRQ_HANDLED; - - return IRQ_NONE; + return IRQ_HANDLED; } static void yenta_interrupt_wrapper(unsigned long data) -- cgit v1.1 From 7f316b033b36adfbdf56bfb15c13de49798ab0b2 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Wed, 28 Sep 2005 19:41:55 +0200 Subject: [PATCH] pcmcia: remove socket register_callback Remove the register_callback declaration in struct pccard_operations as it is unused. Signed-off-by: Dominik Brodowski --- include/pcmcia/ss.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index e788bbc..25e6bf0 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -118,7 +118,6 @@ struct pcmcia_socket; struct pccard_operations { int (*init)(struct pcmcia_socket *sock); int (*suspend)(struct pcmcia_socket *sock); - int (*register_callback)(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info); int (*get_status)(struct pcmcia_socket *sock, u_int *value); int (*get_socket)(struct pcmcia_socket *sock, socket_state_t *state); int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state); -- cgit v1.1 From 9da4bc6d6a38c1c3d850c046d0aee324c1a2e52a Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sat, 12 Nov 2005 23:56:33 +0100 Subject: [PATCH] pcmcia: remove get_socket callback The .get_socket callback is never used by the PCMCIA core, therefore remove it. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/au1000_generic.c | 18 --------- drivers/pcmcia/hd64465_ss.c | 13 ------ drivers/pcmcia/i82092.c | 73 --------------------------------- drivers/pcmcia/i82092aa.h | 1 - drivers/pcmcia/i82365.c | 83 ------------------------------------- drivers/pcmcia/m32r_cfc.c | 32 --------------- drivers/pcmcia/m32r_pcc.c | 20 --------- drivers/pcmcia/m8xx_pcmcia.c | 12 ------ drivers/pcmcia/pd6729.c | 70 -------------------------------- drivers/pcmcia/soc_common.c | 20 --------- drivers/pcmcia/tcic.c | 61 ---------------------------- drivers/pcmcia/vrc4171_card.c | 70 -------------------------------- drivers/pcmcia/vrc4173_cardu.c | 43 -------------------- drivers/pcmcia/yenta_socket.c | 90 ----------------------------------------- include/pcmcia/ss.h | 1 - 15 files changed, 607 deletions(-) diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c index 87302c5..0868b72 100644 --- a/drivers/pcmcia/au1000_generic.c +++ b/drivers/pcmcia/au1000_generic.c @@ -241,23 +241,6 @@ au1x00_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status) return 0; } -/* au1x00_pcmcia_get_socket() - * Implements the get_socket() operation for the in-kernel PCMCIA - * service (formerly SS_GetSocket in Card Services). Not a very - * exciting routine. - * - * Returns: 0 - */ -static int -au1x00_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state) -{ - struct au1000_pcmcia_socket *skt = to_au1000_socket(sock); - - debug("for sock %u\n", skt->nr); - *state = skt->cs_state; - return 0; -} - /* au1x00_pcmcia_set_socket() * Implements the set_socket() operation for the in-kernel PCMCIA * service (formerly SS_SetSocket in Card Services). We more or @@ -352,7 +335,6 @@ static struct pccard_operations au1x00_pcmcia_operations = { .init = au1x00_pcmcia_sock_init, .suspend = au1x00_pcmcia_suspend, .get_status = au1x00_pcmcia_get_status, - .get_socket = au1x00_pcmcia_get_socket, .set_socket = au1x00_pcmcia_set_socket, .set_io_map = au1x00_pcmcia_set_io_map, .set_mem_map = au1x00_pcmcia_set_mem_map, diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c index 561706b..b39435b 100644 --- a/drivers/pcmcia/hd64465_ss.c +++ b/drivers/pcmcia/hd64465_ss.c @@ -417,18 +417,6 @@ static int hs_get_status(struct pcmcia_socket *s, u_int *value) /*============================================================*/ -static int hs_get_socket(struct pcmcia_socket *s, socket_state_t *state) -{ - hs_socket_t *sp = container_of(s, struct hs_socket_t, socket); - - DPRINTK("hs_get_socket(%d)\n", sock); - - *state = sp->state; - return 0; -} - -/*============================================================*/ - static int hs_set_socket(struct pcmcia_socket *s, socket_state_t *state) { hs_socket_t *sp = container_of(s, struct hs_socket_t, socket); @@ -749,7 +737,6 @@ static irqreturn_t hs_interrupt(int irq, void *dev, struct pt_regs *regs) static struct pccard_operations hs_operations = { .init = hs_init, .get_status = hs_get_status, - .get_socket = hs_get_socket, .set_socket = hs_set_socket, .set_io_map = hs_set_io_map, .set_mem_map = hs_set_mem_map, diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c index f3fdc74..7979c85 100644 --- a/drivers/pcmcia/i82092.c +++ b/drivers/pcmcia/i82092.c @@ -66,7 +66,6 @@ static struct pci_driver i82092aa_pci_drv = { static struct pccard_operations i82092aa_operations = { .init = i82092aa_init, .get_status = i82092aa_get_status, - .get_socket = i82092aa_get_socket, .set_socket = i82092aa_set_socket, .set_io_map = i82092aa_set_io_map, .set_mem_map = i82092aa_set_mem_map, @@ -482,78 +481,6 @@ static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value) } -static int i82092aa_get_socket(struct pcmcia_socket *socket, socket_state_t *state) -{ - unsigned int sock = container_of(socket, struct socket_info, socket)->number; - unsigned char reg,vcc,vpp; - - enter("i82092aa_get_socket"); - state->flags = 0; - state->Vcc = 0; - state->Vpp = 0; - state->io_irq = 0; - state->csc_mask = 0; - - /* First the power status of the socket */ - reg = indirect_read(sock,I365_POWER); /* PCTRL - Power Control Register */ - - if (reg & I365_PWR_AUTO) - state->flags |= SS_PWR_AUTO; /* Automatic Power Switch */ - - if (reg & I365_PWR_OUT) - state->flags |= SS_OUTPUT_ENA; /* Output signals are enabled */ - - vcc = reg & I365_VCC_MASK; vpp = reg & I365_VPP1_MASK; - - if (reg & I365_VCC_5V) { /* Can still be 3.3V, in this case the Vcc value will be overwritten later */ - state->Vcc = 50; - - if (vpp == I365_VPP1_5V) - state->Vpp = 50; - if (vpp == I365_VPP1_12V) - state->Vpp = 120; - - } - - if ((reg & I365_VCC_3V)==I365_VCC_3V) - state->Vcc = 33; - - - /* Now the IO card, RESET flags and IO interrupt */ - - reg = indirect_read(sock, I365_INTCTL); /* IGENC, Interrupt and General Control */ - - if ((reg & I365_PC_RESET)==0) - state->flags |= SS_RESET; - if (reg & I365_PC_IOCARD) - state->flags |= SS_IOCARD; /* This is an IO card */ - - /* Set the IRQ number */ - if (sockets[sock].dev!=NULL) - state->io_irq = sockets[sock].dev->irq; - - /* Card status change */ - reg = indirect_read(sock, I365_CSCINT); /* CSCICR, Card Status Change Interrupt Configuration */ - - if (reg & I365_CSC_DETECT) - state->csc_mask |= SS_DETECT; /* Card detect is enabled */ - - if (state->flags & SS_IOCARD) {/* IO Cards behave different */ - if (reg & I365_CSC_STSCHG) - state->csc_mask |= SS_STSCHG; - } else { - if (reg & I365_CSC_BVD1) - state->csc_mask |= SS_BATDEAD; - if (reg & I365_CSC_BVD2) - state->csc_mask |= SS_BATWARN; - if (reg & I365_CSC_READY) - state->csc_mask |= SS_READY; - } - - leave("i82092aa_get_socket"); - return 0; -} - static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *state) { unsigned int sock = container_of(socket, struct socket_info, socket)->number; diff --git a/drivers/pcmcia/i82092aa.h b/drivers/pcmcia/i82092aa.h index b98cac7..9c14599d 100644 --- a/drivers/pcmcia/i82092aa.h +++ b/drivers/pcmcia/i82092aa.h @@ -29,7 +29,6 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev, struct pt_regs *regs); static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value); -static int i82092aa_get_socket(struct pcmcia_socket *socket, socket_state_t *state); static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *state); static int i82092aa_set_io_map(struct pcmcia_socket *socket, struct pccard_io_map *io); static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_map *mem); diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 4d56bc9..35a92d1 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c @@ -940,78 +940,6 @@ static int i365_get_status(u_short sock, u_int *value) /*====================================================================*/ -static int i365_get_socket(u_short sock, socket_state_t *state) -{ - struct i82365_socket *t = &socket[sock]; - u_char reg, vcc, vpp; - - reg = i365_get(sock, I365_POWER); - state->flags = (reg & I365_PWR_AUTO) ? SS_PWR_AUTO : 0; - state->flags |= (reg & I365_PWR_OUT) ? SS_OUTPUT_ENA : 0; - vcc = reg & I365_VCC_MASK; vpp = reg & I365_VPP1_MASK; - state->Vcc = state->Vpp = 0; - if (t->flags & IS_CIRRUS) { - if (i365_get(sock, PD67_MISC_CTL_1) & PD67_MC1_VCC_3V) { - if (reg & I365_VCC_5V) state->Vcc = 33; - if (vpp == I365_VPP1_5V) state->Vpp = 33; - } else { - if (reg & I365_VCC_5V) state->Vcc = 50; - if (vpp == I365_VPP1_5V) state->Vpp = 50; - } - if (vpp == I365_VPP1_12V) state->Vpp = 120; - } else if (t->flags & IS_VG_PWR) { - if (i365_get(sock, VG469_VSELECT) & VG469_VSEL_VCC) { - if (reg & I365_VCC_5V) state->Vcc = 33; - if (vpp == I365_VPP1_5V) state->Vpp = 33; - } else { - if (reg & I365_VCC_5V) state->Vcc = 50; - if (vpp == I365_VPP1_5V) state->Vpp = 50; - } - if (vpp == I365_VPP1_12V) state->Vpp = 120; - } else if (t->flags & IS_DF_PWR) { - if (vcc == I365_VCC_3V) state->Vcc = 33; - if (vcc == I365_VCC_5V) state->Vcc = 50; - if (vpp == I365_VPP1_5V) state->Vpp = 50; - if (vpp == I365_VPP1_12V) state->Vpp = 120; - } else { - if (reg & I365_VCC_5V) { - state->Vcc = 50; - if (vpp == I365_VPP1_5V) state->Vpp = 50; - if (vpp == I365_VPP1_12V) state->Vpp = 120; - } - } - - /* IO card, RESET flags, IO interrupt */ - reg = i365_get(sock, I365_INTCTL); - state->flags |= (reg & I365_PC_RESET) ? 0 : SS_RESET; - if (reg & I365_PC_IOCARD) state->flags |= SS_IOCARD; - state->io_irq = reg & I365_IRQ_MASK; - - /* speaker control */ - if (t->flags & IS_CIRRUS) { - if (i365_get(sock, PD67_MISC_CTL_1) & PD67_MC1_SPKR_ENA) - state->flags |= SS_SPKR_ENA; - } - - /* Card status change mask */ - reg = i365_get(sock, I365_CSCINT); - state->csc_mask = (reg & I365_CSC_DETECT) ? SS_DETECT : 0; - if (state->flags & SS_IOCARD) - state->csc_mask |= (reg & I365_CSC_STSCHG) ? SS_STSCHG : 0; - else { - state->csc_mask |= (reg & I365_CSC_BVD1) ? SS_BATDEAD : 0; - state->csc_mask |= (reg & I365_CSC_BVD2) ? SS_BATWARN : 0; - state->csc_mask |= (reg & I365_CSC_READY) ? SS_READY : 0; - } - - debug(1, "GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, " - "io_irq %d, csc_mask %#2.2x\n", sock, state->flags, - state->Vcc, state->Vpp, state->io_irq, state->csc_mask); - return 0; -} /* i365_get_socket */ - -/*====================================================================*/ - static int i365_set_socket(u_short sock, socket_state_t *state) { struct i82365_socket *t = &socket[sock]; @@ -1265,16 +1193,6 @@ static int pcic_get_status(struct pcmcia_socket *s, u_int *value) LOCKED(i365_get_status(sock, value)); } -static int pcic_get_socket(struct pcmcia_socket *s, socket_state_t *state) -{ - unsigned int sock = container_of(s, struct i82365_socket, socket)->number; - - if (socket[sock].flags & IS_ALIVE) - return -EINVAL; - - LOCKED(i365_get_socket(sock, state)); -} - static int pcic_set_socket(struct pcmcia_socket *s, socket_state_t *state) { unsigned int sock = container_of(s, struct i82365_socket, socket)->number; @@ -1324,7 +1242,6 @@ static int pcic_init(struct pcmcia_socket *s) static struct pccard_operations pcic_operations = { .init = pcic_init, .get_status = pcic_get_status, - .get_socket = pcic_get_socket, .set_socket = pcic_set_socket, .set_io_map = pcic_set_io_map, .set_mem_map = pcic_set_mem_map, diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c index 078579a..071cf48 100644 --- a/drivers/pcmcia/m32r_cfc.c +++ b/drivers/pcmcia/m32r_cfc.c @@ -480,25 +480,6 @@ static int _pcc_get_status(u_short sock, u_int *value) /*====================================================================*/ -static int _pcc_get_socket(u_short sock, socket_state_t *state) -{ -// pcc_socket_t *t = &socket[sock]; - - state->flags = 0; - state->csc_mask = SS_DETECT; - state->csc_mask |= SS_READY; - state->io_irq = 0; - state->Vcc = 33; /* 3.3V fixed */ - state->Vpp = 33; - - debug(3, "m32r_cfc: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, " - "io_irq %d, csc_mask %#2.2x\n", sock, state->flags, - state->Vcc, state->Vpp, state->io_irq, state->csc_mask); - return 0; -} /* _get_socket */ - -/*====================================================================*/ - static int _pcc_set_socket(u_short sock, socket_state_t *state) { debug(3, "m32r_cfc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, " @@ -667,18 +648,6 @@ static int pcc_get_status(struct pcmcia_socket *s, u_int *value) LOCKED(_pcc_get_status(sock, value)); } -static int pcc_get_socket(struct pcmcia_socket *s, socket_state_t *state) -{ - unsigned int sock = container_of(s, struct pcc_socket, socket)->number; - - if (socket[sock].flags & IS_ALIVE) { - debug(3, "m32r_cfc: pcc_get_socket: sock(%d) -EINVAL\n", sock); - return -EINVAL; - } - debug(3, "m32r_cfc: pcc_get_socket: sock(%d)\n", sock); - LOCKED(_pcc_get_socket(sock, state)); -} - static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state) { unsigned int sock = container_of(s, struct pcc_socket, socket)->number; @@ -724,7 +693,6 @@ static int pcc_init(struct pcmcia_socket *s) static struct pccard_operations pcc_operations = { .init = pcc_init, .get_status = pcc_get_status, - .get_socket = pcc_get_socket, .set_socket = pcc_set_socket, .set_io_map = pcc_set_io_map, .set_mem_map = pcc_set_mem_map, diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c index 356a6fb..70d5f07 100644 --- a/drivers/pcmcia/m32r_pcc.c +++ b/drivers/pcmcia/m32r_pcc.c @@ -429,16 +429,6 @@ static int _pcc_get_status(u_short sock, u_int *value) /*====================================================================*/ -static int _pcc_get_socket(u_short sock, socket_state_t *state) -{ - debug(3, "m32r-pcc: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, " - "io_irq %d, csc_mask %#2.2x\n", sock, state->flags, - state->Vcc, state->Vpp, state->io_irq, state->csc_mask); - return 0; -} /* _get_socket */ - -/*====================================================================*/ - static int _pcc_set_socket(u_short sock, socket_state_t *state) { u_long reg = 0; @@ -641,15 +631,6 @@ static int pcc_get_status(struct pcmcia_socket *s, u_int *value) LOCKED(_pcc_get_status(sock, value)); } -static int pcc_get_socket(struct pcmcia_socket *s, socket_state_t *state) -{ - unsigned int sock = container_of(s, struct pcc_socket, socket)->number; - - if (socket[sock].flags & IS_ALIVE) - return -EINVAL; - LOCKED(_pcc_get_socket(sock, state)); -} - static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state) { unsigned int sock = container_of(s, struct pcc_socket, socket)->number; @@ -687,7 +668,6 @@ static int pcc_init(struct pcmcia_socket *s) static struct pccard_operations pcc_operations = { .init = pcc_init, .get_status = pcc_get_status, - .get_socket = pcc_get_socket, .set_socket = pcc_set_socket, .set_io_map = pcc_set_io_map, .set_mem_map = pcc_set_mem_map, diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c index 6d9f71c..a7f27c3 100644 --- a/drivers/pcmcia/m8xx_pcmcia.c +++ b/drivers/pcmcia/m8xx_pcmcia.c @@ -823,17 +823,6 @@ static int m8xx_get_status(struct pcmcia_socket *sock, unsigned int *value) return 0; } -static int m8xx_get_socket(struct pcmcia_socket *sock, socket_state_t *state) -{ - int lsock = container_of(sock, struct socket_info, socket)->slot; - *state = socket[lsock].state; /* copy the whole structure */ - - dprintk("GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, " - "io_irq %d, csc_mask %#2.2x\n", lsock, state->flags, - state->Vcc, state->Vpp, state->io_irq, state->csc_mask); - return 0; -} - static int m8xx_set_socket(struct pcmcia_socket *sock, socket_state_t *state) { int lsock = container_of(sock, struct socket_info, socket)->slot; @@ -1169,7 +1158,6 @@ static struct pccard_operations m8xx_services = { .init = m8xx_sock_init, .suspend = m8xx_suspend, .get_status = m8xx_get_status, - .get_socket = m8xx_get_socket, .set_socket = m8xx_set_socket, .set_io_map = m8xx_set_io_map, .set_mem_map = m8xx_set_mem_map, diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c index 20642f0..e7a6d9a 100644 --- a/drivers/pcmcia/pd6729.c +++ b/drivers/pcmcia/pd6729.c @@ -304,75 +304,6 @@ static int pd6729_get_status(struct pcmcia_socket *sock, u_int *value) } -static int pd6729_get_socket(struct pcmcia_socket *sock, socket_state_t *state) -{ - struct pd6729_socket *socket - = container_of(sock, struct pd6729_socket, socket); - unsigned char reg, vcc, vpp; - - state->flags = 0; - state->Vcc = 0; - state->Vpp = 0; - state->io_irq = 0; - state->csc_mask = 0; - - /* First the power status of the socket */ - reg = indirect_read(socket, I365_POWER); - - if (reg & I365_PWR_AUTO) - state->flags |= SS_PWR_AUTO; /* Automatic Power Switch */ - - if (reg & I365_PWR_OUT) - state->flags |= SS_OUTPUT_ENA; /* Output signals are enabled */ - - vcc = reg & I365_VCC_MASK; vpp = reg & I365_VPP1_MASK; - - if (reg & I365_VCC_5V) { - state->Vcc = (indirect_read(socket, PD67_MISC_CTL_1) & - PD67_MC1_VCC_3V) ? 33 : 50; - - if (vpp == I365_VPP1_5V) { - if (state->Vcc == 50) - state->Vpp = 50; - else - state->Vpp = 33; - } - if (vpp == I365_VPP1_12V) - state->Vpp = 120; - } - - /* Now the IO card, RESET flags and IO interrupt */ - reg = indirect_read(socket, I365_INTCTL); - - if ((reg & I365_PC_RESET) == 0) - state->flags |= SS_RESET; - if (reg & I365_PC_IOCARD) - state->flags |= SS_IOCARD; /* This is an IO card */ - - /* Set the IRQ number */ - state->io_irq = socket->card_irq; - - /* Card status change */ - reg = indirect_read(socket, I365_CSCINT); - - if (reg & I365_CSC_DETECT) - state->csc_mask |= SS_DETECT; /* Card detect is enabled */ - - if (state->flags & SS_IOCARD) {/* IO Cards behave different */ - if (reg & I365_CSC_STSCHG) - state->csc_mask |= SS_STSCHG; - } else { - if (reg & I365_CSC_BVD1) - state->csc_mask |= SS_BATDEAD; - if (reg & I365_CSC_BVD2) - state->csc_mask |= SS_BATWARN; - if (reg & I365_CSC_READY) - state->csc_mask |= SS_READY; - } - - return 0; -} - static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state) { struct pd6729_socket *socket @@ -640,7 +571,6 @@ static int pd6729_init(struct pcmcia_socket *sock) static struct pccard_operations pd6729_operations = { .init = pd6729_init, .get_status = pd6729_get_status, - .get_socket = pd6729_get_socket, .set_socket = pd6729_set_socket, .set_io_map = pd6729_set_io_map, .set_mem_map = pd6729_set_mem_map, diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c index 9e7ccd8..a563bd9 100644 --- a/drivers/pcmcia/soc_common.c +++ b/drivers/pcmcia/soc_common.c @@ -297,25 +297,6 @@ soc_common_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status) /* - * Implements the get_socket() operation for the in-kernel PCMCIA - * service (formerly SS_GetSocket in Card Services). Not a very - * exciting routine. - * - * Returns: 0 - */ -static int -soc_common_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state) -{ - struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock); - - debug(skt, 2, "\n"); - - *state = skt->cs_state; - - return 0; -} - -/* * Implements the set_socket() operation for the in-kernel PCMCIA * service (formerly SS_SetSocket in Card Services). We more or * less punt all of this work and let the kernel handle the details @@ -528,7 +509,6 @@ static struct pccard_operations soc_common_pcmcia_operations = { .init = soc_common_pcmcia_sock_init, .suspend = soc_common_pcmcia_suspend, .get_status = soc_common_pcmcia_get_status, - .get_socket = soc_common_pcmcia_get_socket, .set_socket = soc_common_pcmcia_set_socket, .set_io_map = soc_common_pcmcia_set_io_map, .set_mem_map = soc_common_pcmcia_set_mem_map, diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c index e312638..73bad1d 100644 --- a/drivers/pcmcia/tcic.c +++ b/drivers/pcmcia/tcic.c @@ -181,13 +181,6 @@ static void tcic_setl(u_char reg, u_int data) outw(data >> 16, tcic_base+reg+2); } -static u_char tcic_aux_getb(u_short reg) -{ - u_char mode = (tcic_getb(TCIC_MODE) & TCIC_MODE_PGMMASK) | reg; - tcic_setb(TCIC_MODE, mode); - return tcic_getb(TCIC_AUX); -} - static void tcic_aux_setb(u_short reg, u_char data) { u_char mode = (tcic_getb(TCIC_MODE) & TCIC_MODE_PGMMASK) | reg; @@ -641,59 +634,6 @@ static int tcic_get_status(struct pcmcia_socket *sock, u_int *value) debug(1, "GetStatus(%d) = %#2.2x\n", psock, *value); return 0; } /* tcic_get_status */ - -/*====================================================================*/ - -static int tcic_get_socket(struct pcmcia_socket *sock, socket_state_t *state) -{ - u_short psock = container_of(sock, struct tcic_socket, socket)->psock; - u_char reg; - u_short scf1, scf2; - - tcic_setl(TCIC_ADDR, (psock << TCIC_ADDR_SS_SHFT) - | TCIC_ADDR_INDREG | TCIC_SCF1(psock)); - scf1 = tcic_getw(TCIC_DATA); - state->flags = (scf1 & TCIC_SCF1_IOSTS) ? SS_IOCARD : 0; - state->flags |= (scf1 & TCIC_SCF1_DMA_MASK) ? SS_DMA_MODE : 0; - state->flags |= (scf1 & TCIC_SCF1_SPKR) ? SS_SPKR_ENA : 0; - if (tcic_getb(TCIC_SCTRL) & TCIC_SCTRL_ENA) - state->flags |= SS_OUTPUT_ENA; - state->io_irq = scf1 & TCIC_SCF1_IRQ_MASK; - if (state->io_irq == 1) state->io_irq = 11; - - reg = tcic_getb(TCIC_PWR); - state->Vcc = state->Vpp = 0; - if (reg & TCIC_PWR_VCC(psock)) { - if (reg & TCIC_PWR_VPP(psock)) - state->Vcc = 50; - else - state->Vcc = state->Vpp = 50; - } else { - if (reg & TCIC_PWR_VPP(psock)) { - state->Vcc = 50; - state->Vpp = 120; - } - } - reg = tcic_aux_getb(TCIC_AUX_ILOCK); - state->flags |= (reg & TCIC_ILOCK_CRESET) ? SS_RESET : 0; - - /* Card status change interrupt mask */ - tcic_setw(TCIC_ADDR, TCIC_SCF2(psock)); - scf2 = tcic_getw(TCIC_DATA); - state->csc_mask = (scf2 & TCIC_SCF2_MCD) ? 0 : SS_DETECT; - if (state->flags & SS_IOCARD) { - state->csc_mask |= (scf2 & TCIC_SCF2_MLBAT1) ? 0 : SS_STSCHG; - } else { - state->csc_mask |= (scf2 & TCIC_SCF2_MLBAT1) ? 0 : SS_BATDEAD; - state->csc_mask |= (scf2 & TCIC_SCF2_MLBAT2) ? 0 : SS_BATWARN; - state->csc_mask |= (scf2 & TCIC_SCF2_MRDY) ? 0 : SS_READY; - } - - debug(1, "GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, " - "io_irq %d, csc_mask %#2.2x\n", psock, state->flags, - state->Vcc, state->Vpp, state->io_irq, state->csc_mask); - return 0; -} /* tcic_get_socket */ /*====================================================================*/ @@ -874,7 +814,6 @@ static int tcic_init(struct pcmcia_socket *s) static struct pccard_operations tcic_operations = { .init = tcic_init, .get_status = tcic_get_status, - .get_socket = tcic_get_socket, .set_socket = tcic_set_socket, .set_io_map = tcic_set_io_map, .set_mem_map = tcic_set_mem_map, diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c index 38a028c..24c547e 100644 --- a/drivers/pcmcia/vrc4171_card.c +++ b/drivers/pcmcia/vrc4171_card.c @@ -301,75 +301,6 @@ static int pccard_get_status(struct pcmcia_socket *sock, u_int *value) return 0; } -static inline u_char get_Vcc_value(uint8_t voltage) -{ - switch (voltage) { - case VCC_STATUS_3V: - return 33; - case VCC_STATUS_5V: - return 50; - default: - break; - } - - return 0; -} - -static inline u_char get_Vpp_value(uint8_t power, u_char Vcc) -{ - if ((power & 0x03) == 0x01 || (power & 0x03) == 0x02) - return Vcc; - - return 0; -} - -static int pccard_get_socket(struct pcmcia_socket *sock, socket_state_t *state) -{ - unsigned int slot; - uint8_t power, voltage, control, cscint; - - if (sock == NULL || sock->sock >= CARD_MAX_SLOTS || state == NULL) - return -EINVAL; - - slot = sock->sock; - - power = exca_read_byte(slot, I365_POWER); - voltage = exca_read_byte(slot, CARD_VOLTAGE_SELECT); - - state->Vcc = get_Vcc_value(voltage); - state->Vpp = get_Vpp_value(power, state->Vcc); - - state->flags = 0; - if (power & POWER_ENABLE) - state->flags |= SS_PWR_AUTO; - if (power & I365_PWR_OUT) - state->flags |= SS_OUTPUT_ENA; - - control = exca_read_byte(slot, I365_INTCTL); - if (control & I365_PC_IOCARD) - state->flags |= SS_IOCARD; - if (!(control & I365_PC_RESET)) - state->flags |= SS_RESET; - - cscint = exca_read_byte(slot, I365_CSCINT); - state->csc_mask = 0; - if (state->flags & SS_IOCARD) { - if (cscint & I365_CSC_STSCHG) - state->flags |= SS_STSCHG; - } else { - if (cscint & I365_CSC_BVD1) - state->csc_mask |= SS_BATDEAD; - if (cscint & I365_CSC_BVD2) - state->csc_mask |= SS_BATWARN; - } - if (cscint & I365_CSC_READY) - state->csc_mask |= SS_READY; - if (cscint & I365_CSC_DETECT) - state->csc_mask |= SS_DETECT; - - return 0; -} - static inline uint8_t set_Vcc_value(u_char Vcc) { switch (Vcc) { @@ -551,7 +482,6 @@ static int pccard_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map static struct pccard_operations vrc4171_pccard_operations = { .init = pccard_init, .get_status = pccard_get_status, - .get_socket = pccard_get_socket, .set_socket = pccard_set_socket, .set_io_map = pccard_set_io_map, .set_mem_map = pccard_set_mem_map, diff --git a/drivers/pcmcia/vrc4173_cardu.c b/drivers/pcmcia/vrc4173_cardu.c index db91259..1b277d2 100644 --- a/drivers/pcmcia/vrc4173_cardu.c +++ b/drivers/pcmcia/vrc4173_cardu.c @@ -198,48 +198,6 @@ static int cardu_get_status(unsigned int sock, u_int *value) return 0; } -static inline u_char get_Vcc_value(uint8_t val) -{ - switch (val & VCC_MASK) { - case VCC_3V: - return 33; - case VCC_5V: - return 50; - } - - return 0; -} - -static inline u_char get_Vpp_value(uint8_t val) -{ - switch (val & VPP_MASK) { - case VPP_12V: - return 120; - case VPP_VCC: - return get_Vcc_value(val); - } - - return 0; -} - -static int cardu_get_socket(unsigned int sock, socket_state_t *state) -{ - vrc4173_socket_t *socket = &cardu_sockets[sock]; - uint8_t val; - - val = exca_readb(socket, PWR_CNT); - state->Vcc = get_Vcc_value(val); - state->Vpp = get_Vpp_value(val); - state->flags = 0; - if (val & CARD_OUT_EN) state->flags |= SS_OUTPUT_ENA; - - val = exca_readb(socket, INT_GEN_CNT); - if (!(val & CARD_REST0)) state->flags |= SS_RESET; - if (val & CARD_TYPE_IO) state->flags |= SS_IOCARD; - - return 0; -} - static inline uint8_t set_Vcc_value(u_char Vcc) { switch (Vcc) { @@ -431,7 +389,6 @@ static struct pccard_operations cardu_operations = { .register_callback = cardu_register_callback, .inquire_socket = cardu_inquire_socket, .get_status = cardu_get_status, - .get_socket = cardu_get_socket, .set_socket = cardu_set_socket, .get_io_map = cardu_get_io_map, .set_io_map = cardu_set_io_map, diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 8bfe72b..fa0625c 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -224,95 +224,6 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value) return 0; } -static void yenta_get_power(struct yenta_socket *socket, socket_state_t *state) -{ - if (!(cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) && - (socket->flags & YENTA_16BIT_POWER_EXCA)) { - u8 reg, vcc, vpp; - - reg = exca_readb(socket, I365_POWER); - vcc = reg & I365_VCC_MASK; - vpp = reg & I365_VPP1_MASK; - state->Vcc = state->Vpp = 0; - - if (socket->flags & YENTA_16BIT_POWER_DF) { - if (vcc == I365_VCC_3V) - state->Vcc = 33; - if (vcc == I365_VCC_5V) - state->Vcc = 50; - if (vpp == I365_VPP1_5V) - state->Vpp = state->Vcc; - if (vpp == I365_VPP1_12V) - state->Vpp = 120; - } else { - if (reg & I365_VCC_5V) { - state->Vcc = 50; - if (vpp == I365_VPP1_5V) - state->Vpp = 50; - if (vpp == I365_VPP1_12V) - state->Vpp = 120; - } - } - } else { - u32 control; - - control = cb_readl(socket, CB_SOCKET_CONTROL); - - switch (control & CB_SC_VCC_MASK) { - case CB_SC_VCC_5V: state->Vcc = 50; break; - case CB_SC_VCC_3V: state->Vcc = 33; break; - default: state->Vcc = 0; - } - - switch (control & CB_SC_VPP_MASK) { - case CB_SC_VPP_12V: state->Vpp = 120; break; - case CB_SC_VPP_5V: state->Vpp = 50; break; - case CB_SC_VPP_3V: state->Vpp = 33; break; - default: state->Vpp = 0; - } - } -} - -static int yenta_get_socket(struct pcmcia_socket *sock, socket_state_t *state) -{ - struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); - u8 reg; - u32 control; - - control = cb_readl(socket, CB_SOCKET_CONTROL); - - yenta_get_power(socket, state); - state->io_irq = socket->io_irq; - - if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) { - u16 bridge = config_readw(socket, CB_BRIDGE_CONTROL); - if (bridge & CB_BRIDGE_CRST) - state->flags |= SS_RESET; - return 0; - } - - /* 16-bit card state.. */ - reg = exca_readb(socket, I365_POWER); - state->flags = (reg & I365_PWR_AUTO) ? SS_PWR_AUTO : 0; - state->flags |= (reg & I365_PWR_OUT) ? SS_OUTPUT_ENA : 0; - - reg = exca_readb(socket, I365_INTCTL); - state->flags |= (reg & I365_PC_RESET) ? 0 : SS_RESET; - state->flags |= (reg & I365_PC_IOCARD) ? SS_IOCARD : 0; - - reg = exca_readb(socket, I365_CSCINT); - state->csc_mask = (reg & I365_CSC_DETECT) ? SS_DETECT : 0; - if (state->flags & SS_IOCARD) { - state->csc_mask |= (reg & I365_CSC_STSCHG) ? SS_STSCHG : 0; - } else { - state->csc_mask |= (reg & I365_CSC_BVD1) ? SS_BATDEAD : 0; - state->csc_mask |= (reg & I365_CSC_BVD2) ? SS_BATWARN : 0; - state->csc_mask |= (reg & I365_CSC_READY) ? SS_READY : 0; - } - - return 0; -} - static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state) { /* some birdges require to use the ExCA registers to power 16bit cards */ @@ -828,7 +739,6 @@ static struct pccard_operations yenta_socket_operations = { .init = yenta_sock_init, .suspend = yenta_sock_suspend, .get_status = yenta_get_status, - .get_socket = yenta_get_socket, .set_socket = yenta_set_socket, .set_io_map = yenta_set_io_map, .set_mem_map = yenta_set_mem_map, diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index 25e6bf0..9f7dab8 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -119,7 +119,6 @@ struct pccard_operations { int (*init)(struct pcmcia_socket *sock); int (*suspend)(struct pcmcia_socket *sock); int (*get_status)(struct pcmcia_socket *sock, u_int *value); - int (*get_socket)(struct pcmcia_socket *sock, socket_state_t *state); int (*set_socket)(struct pcmcia_socket *sock, socket_state_t *state); int (*set_io_map)(struct pcmcia_socket *sock, struct pccard_io_map *io); int (*set_mem_map)(struct pcmcia_socket *sock, struct pccard_mem_map *mem); -- cgit v1.1 From de75914ee103a30d82ad21b39b7e04f70e4fa1f0 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Wed, 28 Sep 2005 19:41:56 +0200 Subject: [PATCH] pcmcia: validate_mem shouldn't be void Add a return value to pcmcia_validate_mem. Only if we have enough memory available to map the CIS, we should proceed in trying to determine information about the device. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cs_internal.h | 2 +- drivers/pcmcia/ds.c | 4 +- drivers/pcmcia/rsrc_mgr.c | 6 +- drivers/pcmcia/rsrc_nonstatic.c | 123 +++++++++++++++++++++------------------- include/pcmcia/ss.h | 2 +- 5 files changed, 75 insertions(+), 62 deletions(-) diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 55867bc..634426b 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -117,7 +117,7 @@ int verify_cis_cache(struct pcmcia_socket *s); int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse); /* In rsrc_mgr */ -void pcmcia_validate_mem(struct pcmcia_socket *s); +int pcmcia_validate_mem(struct pcmcia_socket *s); struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align, struct pcmcia_socket *s); int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start, diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 6fb7639..b120794 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -583,7 +583,9 @@ static int pcmcia_card_add(struct pcmcia_socket *s) if (!(s->resource_setup_done)) return -EAGAIN; /* try again, but later... */ - pcmcia_validate_mem(s); + if (pcmcia_validate_mem(s)) + return -EAGAIN; /* try again, but later... */ + ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo); if (ret || !cisinfo.Chains) { ds_dbg(0, "invalid CIS or invalid resources\n"); diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c index 0668384..b02598a 100644 --- a/drivers/pcmcia/rsrc_mgr.c +++ b/drivers/pcmcia/rsrc_mgr.c @@ -98,10 +98,12 @@ int pcmcia_adjust_resource_info(adjust_t *adj) } EXPORT_SYMBOL(pcmcia_adjust_resource_info); -void pcmcia_validate_mem(struct pcmcia_socket *s) +int pcmcia_validate_mem(struct pcmcia_socket *s) { if (s->resource_ops->validate_mem) - s->resource_ops->validate_mem(s); + return s->resource_ops->validate_mem(s); + /* if there is no callback, we can assume that everything is OK */ + return 0; } EXPORT_SYMBOL(pcmcia_validate_mem); diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 00960a3..ebfcab5 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -407,56 +407,62 @@ static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s) static u_long inv_probe(struct resource_map *m, struct pcmcia_socket *s) { - struct socket_data *s_data = s->resource_data; - u_long ok; - if (m == &s_data->mem_db) - return 0; - ok = inv_probe(m->next, s); - if (ok) { - if (m->base >= 0x100000) - sub_interval(&s_data->mem_db, m->base, m->num); - return ok; - } - if (m->base < 0x100000) - return 0; - return do_mem_probe(m->base, m->num, s); + struct socket_data *s_data = s->resource_data; + u_long ok; + if (m == &s_data->mem_db) + return 0; + ok = inv_probe(m->next, s); + if (ok) { + if (m->base >= 0x100000) + sub_interval(&s_data->mem_db, m->base, m->num); + return ok; + } + if (m->base < 0x100000) + return 0; + return do_mem_probe(m->base, m->num, s); } -static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) +static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) { - struct resource_map *m, mm; - static u_char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 }; - u_long b, i, ok = 0; - struct socket_data *s_data = s->resource_data; + struct resource_map *m, mm; + static unsigned char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 }; + unsigned long b, i, ok = 0; + struct socket_data *s_data = s->resource_data; - /* We do up to four passes through the list */ - if (probe_mask & MEM_PROBE_HIGH) { - if (inv_probe(s_data->mem_db.next, s) > 0) - return; - printk(KERN_NOTICE "cs: warning: no high memory space " - "available!\n"); - } - if ((probe_mask & MEM_PROBE_LOW) == 0) - return; - for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) { - mm = *m; - /* Only probe < 1 MB */ - if (mm.base >= 0x100000) continue; - if ((mm.base | mm.num) & 0xffff) { - ok += do_mem_probe(mm.base, mm.num, s); - continue; + /* We do up to four passes through the list */ + if (probe_mask & MEM_PROBE_HIGH) { + if (inv_probe(s_data->mem_db.next, s) > 0) + return 0; + printk(KERN_NOTICE "cs: warning: no high memory space " + "available!\n"); + return -ENODEV; } - /* Special probe for 64K-aligned block */ - for (i = 0; i < 4; i++) { - b = order[i] << 12; - if ((b >= mm.base) && (b+0x10000 <= mm.base+mm.num)) { - if (ok >= mem_limit) - sub_interval(&s_data->mem_db, b, 0x10000); - else - ok += do_mem_probe(b, 0x10000, s); - } + + for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) { + mm = *m; + /* Only probe < 1 MB */ + if (mm.base >= 0x100000) + continue; + if ((mm.base | mm.num) & 0xffff) { + ok += do_mem_probe(mm.base, mm.num, s); + continue; + } + /* Special probe for 64K-aligned block */ + for (i = 0; i < 4; i++) { + b = order[i] << 12; + if ((b >= mm.base) && (b+0x10000 <= mm.base+mm.num)) { + if (ok >= mem_limit) + sub_interval(&s_data->mem_db, b, 0x10000); + else + ok += do_mem_probe(b, 0x10000, s); + } + } } - } + + if (ok > 0) + return 0; + + return -ENODEV; } #else /* CONFIG_PCMCIA_PROBE */ @@ -478,27 +484,30 @@ static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) /* * Locking note: Must be called with skt_sem held! */ -static void pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s) +static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s) { struct socket_data *s_data = s->resource_data; - if (probe_mem) { - unsigned int probe_mask; + unsigned int probe_mask = MEM_PROBE_LOW; + int ret = 0; - down(&rsrc_sem); + if (!probe_mem) + return 0; - probe_mask = MEM_PROBE_LOW; - if (s->features & SS_CAP_PAGE_REGS) - probe_mask = MEM_PROBE_HIGH; + down(&rsrc_sem); - if (probe_mask & ~s_data->rsrc_mem_probe) { + if (s->features & SS_CAP_PAGE_REGS) + probe_mask = MEM_PROBE_HIGH; + + if (probe_mask & ~s_data->rsrc_mem_probe) { + if (s->state & SOCKET_PRESENT) + ret = validate_mem(s, probe_mask); + if (!ret) s_data->rsrc_mem_probe |= probe_mask; + } - if (s->state & SOCKET_PRESENT) - validate_mem(s, probe_mask); - } + up(&rsrc_sem); - up(&rsrc_sem); - } + return ret; } struct pcmcia_align_data { diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index 9f7dab8..2889a69 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -125,7 +125,7 @@ struct pccard_operations { }; struct pccard_resource_ops { - void (*validate_mem) (struct pcmcia_socket *s); + int (*validate_mem) (struct pcmcia_socket *s); int (*adjust_io_region) (struct resource *res, unsigned long r_start, unsigned long r_end, -- cgit v1.1 From 2cff944720332535a24b7eae16cff32055a43048 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 16 Nov 2005 21:29:26 -0800 Subject: [PATCH] pcmcia: validate_mem fix Also return a value if CONFIG_PCMCIA_PROBE is not set. Signed-off-by: Andrew Morton Signed-off-by: Dominik Brodowski --- drivers/pcmcia/rsrc_nonstatic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index ebfcab5..6b18092 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -467,15 +467,19 @@ static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) #else /* CONFIG_PCMCIA_PROBE */ -static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) +static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) { struct resource_map *m, mm; struct socket_data *s_data = s->resource_data; + unsigned long ok = 0; for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) { mm = *m; - do_mem_probe(mm.base, mm.num, s); + ok += do_mem_probe(mm.base, mm.num, s); } + if (ok > 0) + return 0; + return -ENODEV; } #endif /* CONFIG_PCMCIA_PROBE */ -- cgit v1.1 From 63e7ebd06402951bc8863ba5b7bc9b9f42044849 Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Thu, 3 Nov 2005 21:12:14 +0100 Subject: [PATCH] yenta: make bridge specific init code configurable Make the bridge specific initialization code config options depending on CONFIG_EMBEDDED. Config options for TI/EnE, Toshiba, Ricoh and O2Micro are available. Disabling all of the specific tweaks cuts off more than half of yenta_socket.ko. Signed-off-by: Daniel Ritz Signed-off-by: Dominik Brodowski --- drivers/pcmcia/Kconfig | 25 +++++++++++++++++++++++++ drivers/pcmcia/ti113x.h | 4 ++-- drivers/pcmcia/yenta_socket.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 309eb55..ea00b1f 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -116,6 +116,31 @@ config YENTA If unsure, say Y. +config YENTA_O2 + default y + bool "Special initialization for O2Micro bridges" if EMBEDDED + depends on YENTA + +config YENTA_RICOH + default y + bool "Special initialization for Ricoh bridges" if EMBEDDED + depends on YENTA + +config YENTA_TI + default y + bool "Special initialization for TI and EnE bridges" if EMBEDDED + depends on YENTA + +config YENTA_ENE_TUNE + default y + bool "Auto-tune EnE bridges for CB cards" if EMBEDDED + depends on YENTA_TI && CARDBUS + +config YENTA_TOSHIBA + default y + bool "Special initialization for Toshiba ToPIC bridges" if EMBEDDED + depends on YENTA + config PD6729 tristate "Cirrus PD6729 compatible bridge support" depends on PCMCIA && PCI diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h index 539b5cd..d5b4ff7 100644 --- a/drivers/pcmcia/ti113x.h +++ b/drivers/pcmcia/ti113x.h @@ -873,7 +873,7 @@ static int ti1250_override(struct yenta_socket *socket) * Some fixup code to make everybody happy (TM). */ -#ifdef CONFIG_CARDBUS +#ifdef CONFIG_YENTA_ENE_TUNE /** * set/clear various test bits: * Defaults to clear the bit. @@ -937,7 +937,7 @@ static int ene_override(struct yenta_socket *socket) } #else # define ene_override ti1250_override -#endif +#endif /* !CONFIG_YENTA_ENE_TUNE */ #endif /* _LINUX_TI113X_H */ diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index fa0625c..826e7e1 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -49,7 +49,13 @@ MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only #define to_cycles(ns) ((ns)/120) #define to_ns(cycles) ((cycles)*120) +/** + * yenta PCI irq probing. + * currently only used in the TI/EnE initialization code + */ +#ifdef CONFIG_YENTA_TI static int yenta_probe_cb_irq(struct yenta_socket *socket); +#endif static unsigned int override_bios; @@ -745,10 +751,18 @@ static struct pccard_operations yenta_socket_operations = { }; +#ifdef CONFIG_YENTA_TI #include "ti113x.h" +#endif +#ifdef CONFIG_YENTA_RICOH #include "ricoh.h" +#endif +#ifdef CONFIG_YENTA_TOSHIBA #include "topic.h" +#endif +#ifdef CONFIG_YENTA_O2 #include "o2micro.h" +#endif enum { CARDBUS_TYPE_DEFAULT = -1, @@ -768,6 +782,7 @@ enum { * initialization sequences etc details. List them here.. */ static struct cardbus_type cardbus_type[] = { +#ifdef CONFIG_YENTA_TI [CARDBUS_TYPE_TI] = { .override = ti_override, .save_state = ti_save_state, @@ -792,27 +807,36 @@ static struct cardbus_type cardbus_type[] = { .restore_state = ti_restore_state, .sock_init = ti_init, }, +#endif +#ifdef CONFIG_YENTA_RICOH [CARDBUS_TYPE_RICOH] = { .override = ricoh_override, .save_state = ricoh_save_state, .restore_state = ricoh_restore_state, }, +#endif +#ifdef CONFIG_YENTA_TOSHIBA [CARDBUS_TYPE_TOPIC95] = { .override = topic95_override, }, [CARDBUS_TYPE_TOPIC97] = { .override = topic97_override, }, +#endif +#ifdef CONFIG_YENTA_O2 [CARDBUS_TYPE_O2MICRO] = { .override = o2micro_override, .restore_state = o2micro_restore_state, }, +#endif +#ifdef CONFIG_YENTA_TI [CARDBUS_TYPE_ENE] = { .override = ene_override, .save_state = ti_save_state, .restore_state = ti_restore_state, .sock_init = ti_init, }, +#endif }; @@ -858,6 +882,12 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas } +/** + * yenta PCI irq probing. + * currently only used in the TI/EnE initialization code + */ +#ifdef CONFIG_YENTA_TI + /* interrupt handler, only used during probing */ static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *regs) { @@ -910,6 +940,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket) return (int) socket->probe_status; } +#endif /* CONFIG_YENTA_TI */ /* @@ -1173,6 +1204,7 @@ static struct pci_device_id yenta_table [] = { * advanced overrides instead. (I can't get the * data sheets for these devices. --rmk) */ +#ifdef CONFIG_YENTA_TI CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI), CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X), @@ -1215,18 +1247,25 @@ static struct pci_device_id yenta_table [] = { CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE), CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE), CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE), +#endif /* CONFIG_YENTA_TI */ +#ifdef CONFIG_YENTA_RICOH CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH), CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH), CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH), CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH), CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH), +#endif +#ifdef CONFIG_YENTA_TOSHIBA CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC95, TOPIC95), CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97), CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97), +#endif +#ifdef CONFIG_YENTA_O2 CB_ID(PCI_VENDOR_ID_O2, PCI_ANY_ID, O2MICRO), +#endif /* match any cardbus bridge */ CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT), -- cgit v1.1 From 98e4c28b7ec390c2dad6a4c69d69629c0f7e8b10 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:21:18 +0100 Subject: [PATCH] pcmcia: new suspend core Move the suspend and resume methods out of the event handler, and into special functions. Also use these functions for pre- and post-reset, as almost all drivers already do, and the remaining ones can easily be converted. Bugfix to include/pcmcia/ds.c Signed-off-by: Andrew Morton Signed-off-by: Dominik Brodowski --- Documentation/pcmcia/driver-changes.txt | 6 ++ drivers/bluetooth/bluecard_cs.c | 37 +++++--- drivers/bluetooth/bt3c_cs.c | 37 +++++--- drivers/bluetooth/btuart_cs.c | 38 ++++++--- drivers/bluetooth/dtl1_cs.c | 37 +++++--- drivers/char/pcmcia/cm4000_cs.c | 61 ++++++++------ drivers/char/pcmcia/cm4040_cs.c | 50 +++++------ drivers/char/pcmcia/synclink_cs.c | 47 +++++++---- drivers/ide/legacy/ide-cs.c | 38 ++++++--- drivers/isdn/hardware/avm/avm_cs.c | 38 ++++++--- drivers/isdn/hisax/avma1_cs.c | 38 ++++++--- drivers/isdn/hisax/elsa_cs.c | 46 ++++++---- drivers/isdn/hisax/sedlbauer_cs.c | 50 ++++++----- drivers/isdn/hisax/teles_cs.c | 46 ++++++---- drivers/mtd/maps/pcmciamtd.c | 36 ++++---- drivers/net/pcmcia/3c574_cs.c | 56 +++++++----- drivers/net/pcmcia/3c589_cs.c | 56 +++++++----- drivers/net/pcmcia/axnet_cs.c | 59 ++++++++----- drivers/net/pcmcia/com20020_cs.c | 62 ++++++++------ drivers/net/pcmcia/fmvj18x_cs.c | 57 ++++++++----- drivers/net/pcmcia/ibmtr_cs.c | 59 ++++++++----- drivers/net/pcmcia/nmclan_cs.c | 57 ++++++++----- drivers/net/pcmcia/pcnet_cs.c | 58 ++++++++----- drivers/net/pcmcia/smc91c92_cs.c | 109 +++++++++++++----------- drivers/net/pcmcia/xirc2ps_cs.c | 61 ++++++++------ drivers/net/wireless/airo_cs.c | 50 ++++++----- drivers/net/wireless/atmel_cs.c | 50 ++++++----- drivers/net/wireless/hostap/hostap_cs.c | 88 ++++++++++--------- drivers/net/wireless/netwave_cs.c | 57 ++++++++----- drivers/net/wireless/orinoco_cs.c | 145 +++++++++++++++++--------------- drivers/net/wireless/ray_cs.c | 59 ++++++++----- drivers/net/wireless/spectrum_cs.c | 96 +++++++++++---------- drivers/net/wireless/wavelan_cs.c | 92 +++++++++++--------- drivers/net/wireless/wl3501_cs.c | 61 ++++++++------ drivers/parport/parport_cs.c | 39 +++++---- drivers/pcmcia/ds.c | 10 +++ drivers/scsi/pcmcia/aha152x_stub.c | 48 ++++++----- drivers/scsi/pcmcia/fdomain_stub.c | 42 +++++---- drivers/scsi/pcmcia/nsp_cs.c | 102 +++++++++++----------- drivers/scsi/pcmcia/qlogic_stub.c | 59 ++++++++----- drivers/scsi/pcmcia/sym53c500_cs.c | 69 ++++++++------- drivers/serial/serial_cs.c | 31 +++---- drivers/telephony/ixj_pcmcia.c | 38 ++++++--- drivers/usb/host/sl811_cs.c | 41 +++++---- include/pcmcia/ds.h | 6 ++ 45 files changed, 1431 insertions(+), 991 deletions(-) diff --git a/Documentation/pcmcia/driver-changes.txt b/Documentation/pcmcia/driver-changes.txt index 403e7b4..5c822f5 100644 --- a/Documentation/pcmcia/driver-changes.txt +++ b/Documentation/pcmcia/driver-changes.txt @@ -1,5 +1,11 @@ This file details changes in 2.6 which affect PCMCIA card driver authors: +* Move suspend, resume and reset out of event handler (as of 2.6.16) + int (*suspend) (struct pcmcia_device *dev); + int (*resume) (struct pcmcia_device *dev); + should be initialized in struct pcmcia_driver, and handle + (SUSPEND == RESET_PHYSICAL) and (RESUME == CARD_RESET) events + * event handler initialization in struct pcmcia_driver (as of 2.6.13) The event handler is notified of all events, and must be initialized as the event() callback in the driver's struct pcmcia_driver. diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index f36c563..5b24131 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -1045,6 +1045,27 @@ static void bluecard_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int bluecard_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int bluecard_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (DEV_OK(link)) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} static int bluecard_event(event_t event, int priority, event_callback_args_t *args) { @@ -1063,20 +1084,6 @@ static int bluecard_event(event_t event, int priority, event_callback_args_t *ar link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; bluecard_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (DEV_OK(link)) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; @@ -1099,6 +1106,8 @@ static struct pcmcia_driver bluecard_driver = { .event = bluecard_event, .detach = bluecard_detach, .id_table = bluecard_ids, + .suspend = bluecard_suspend, + .resume = bluecard_resume, }; static int __init init_bluecard_cs(void) diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index d2a0add..1d524ba 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -891,6 +891,27 @@ static void bt3c_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int bt3c_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int bt3c_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (DEV_OK(link)) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} static int bt3c_event(event_t event, int priority, event_callback_args_t *args) { @@ -909,20 +930,6 @@ static int bt3c_event(event_t event, int priority, event_callback_args_t *args) link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; bt3c_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (DEV_OK(link)) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; @@ -943,6 +950,8 @@ static struct pcmcia_driver bt3c_driver = { .event = bt3c_event, .detach = bt3c_detach, .id_table = bt3c_ids, + .suspend = bt3c_suspend, + .resume = bt3c_resume, }; static int __init init_bt3c_cs(void) diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 529a28a..1828ba6 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -811,6 +811,28 @@ static void btuart_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int btuart_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int btuart_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (DEV_OK(link)) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} + static int btuart_event(event_t event, int priority, event_callback_args_t *args) { @@ -829,20 +851,6 @@ static int btuart_event(event_t event, int priority, event_callback_args_t *args link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; btuart_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (DEV_OK(link)) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; @@ -863,6 +871,8 @@ static struct pcmcia_driver btuart_driver = { .event = btuart_event, .detach = btuart_detach, .id_table = btuart_ids, + .suspend = btuart_suspend, + .resume = btuart_resume, }; static int __init init_btuart_cs(void) diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index dec5980..9f9d3f9 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -763,6 +763,27 @@ static void dtl1_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int dtl1_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int dtl1_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (DEV_OK(link)) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} static int dtl1_event(event_t event, int priority, event_callback_args_t *args) { @@ -781,20 +802,6 @@ static int dtl1_event(event_t event, int priority, event_callback_args_t *args) link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; dtl1_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (DEV_OK(link)) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; @@ -816,6 +823,8 @@ static struct pcmcia_driver dtl1_driver = { .event = dtl1_event, .detach = dtl1_detach, .id_table = dtl1_ids, + .suspend = dtl1_suspend, + .resume = dtl1_resume, }; static int __init init_dtl1_cs(void) diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 61681c9..05e9305 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c @@ -1893,33 +1893,6 @@ static int cm4000_event(event_t event, int priority, link->state &= ~DEV_PRESENT; stop_monitor(dev); break; - case CS_EVENT_PM_SUSPEND: - DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND " - "(fall-through to CS_EVENT_RESET_PHYSICAL)\n"); - link->state |= DEV_SUSPEND; - /* fall-through */ - case CS_EVENT_RESET_PHYSICAL: - DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n"); - if (link->state & DEV_CONFIG) { - DEBUGP(5, dev, "ReleaseConfiguration\n"); - pcmcia_release_configuration(link->handle); - } - stop_monitor(dev); - break; - case CS_EVENT_PM_RESUME: - DEBUGP(5, dev, "CS_EVENT_PM_RESUME " - "(fall-through to CS_EVENT_CARD_RESET)\n"); - link->state &= ~DEV_SUSPEND; - /* fall-through */ - case CS_EVENT_CARD_RESET: - DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n"); - if ((link->state & DEV_CONFIG)) { - DEBUGP(5, dev, "RequestConfiguration\n"); - pcmcia_request_configuration(link->handle, &link->conf); - } - if (link->open) - start_monitor(dev); - break; default: DEBUGP(5, dev, "unknown event %.2x\n", event); break; @@ -1928,6 +1901,38 @@ static int cm4000_event(event_t event, int priority, return CS_SUCCESS; } +static int cm4000_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct cm4000_dev *dev; + + dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + stop_monitor(dev); + + return 0; +} + +static int cm4000_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct cm4000_dev *dev; + + dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + + if (link->open) + start_monitor(dev); + + return 0; +} + static void cm4000_release(dev_link_t *link) { cmm_cm4000_release(link->priv); /* delay release until device closed */ @@ -2044,6 +2049,8 @@ static struct pcmcia_driver cm4000_driver = { }, .attach = cm4000_attach, .detach = cm4000_detach, + .suspend = cm4000_suspend, + .resume = cm4000_resume, .event = cm4000_event, .id_table = cm4000_ids, }; diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 4c698d9..3622fd3 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c @@ -656,31 +656,7 @@ static int reader_event(event_t event, int priority, DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n"); link->state &= ~DEV_PRESENT; break; - case CS_EVENT_PM_SUSPEND: - DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND " - "(fall-through to CS_EVENT_RESET_PHYSICAL)\n"); - link->state |= DEV_SUSPEND; - - case CS_EVENT_RESET_PHYSICAL: - DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n"); - if (link->state & DEV_CONFIG) { - DEBUGP(5, dev, "ReleaseConfiguration\n"); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - DEBUGP(5, dev, "CS_EVENT_PM_RESUME " - "(fall-through to CS_EVENT_CARD_RESET)\n"); - link->state &= ~DEV_SUSPEND; - - case CS_EVENT_CARD_RESET: - DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n"); - if ((link->state & DEV_CONFIG)) { - DEBUGP(5, dev, "RequestConfiguration\n"); - pcmcia_request_configuration(link->handle, - &link->conf); - } - break; + default: DEBUGP(5, dev, "reader_event: unknown event %.2x\n", event); @@ -690,6 +666,28 @@ static int reader_event(event_t event, int priority, return CS_SUCCESS; } +static int reader_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int reader_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} + static void reader_release(dev_link_t *link) { cm4040_reader_release(link->priv); @@ -806,6 +804,8 @@ static struct pcmcia_driver reader_driver = { }, .attach = reader_attach, .detach = reader_detach, + .suspend = reader_suspend, + .resume = reader_resume, .event = reader_event, .id_table = cm4040_ids, }; diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 2c326ea..776103e 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -773,11 +773,37 @@ static void mgslpc_detach(dev_link_t *link) mgslpc_remove_device((MGSLPC_INFO *)link->priv); } +static int mgslpc_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + MGSLPC_INFO *info = link->priv; + + link->state |= DEV_SUSPEND; + info->stop = 1; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int mgslpc_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + MGSLPC_INFO *info = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + info->stop = 0; + + return 0; +} + + static int mgslpc_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - MGSLPC_INFO *info = link->priv; if (debug_level >= DEBUG_LEVEL_INFO) printk("mgslpc_event(0x%06x)\n", event); @@ -794,23 +820,6 @@ static int mgslpc_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; mgslpc_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - /* Mark the device as stopped, to block IO until later */ - info->stop = 1; - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) - pcmcia_request_configuration(link->handle, &link->conf); - info->stop = 0; - break; } return 0; } @@ -3095,6 +3104,8 @@ static struct pcmcia_driver mgslpc_driver = { .event = mgslpc_event, .detach = mgslpc_detach, .id_table = mgslpc_ids, + .suspend = mgslpc_suspend, + .resume = mgslpc_resume, }; static struct tty_operations mgslpc_ops = { diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index ef79805..982b74a 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -406,6 +406,28 @@ void ide_release(dev_link_t *link) } /* ide_release */ +static int ide_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int ide_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (DEV_OK(link)) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -432,20 +454,6 @@ int ide_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; ide_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (DEV_OK(link)) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; } /* ide_event */ @@ -498,6 +506,8 @@ static struct pcmcia_driver ide_cs_driver = { .event = ide_event, .detach = ide_detach, .id_table = ide_ids, + .suspend = ide_suspend, + .resume = ide_resume, }; static int __init init_ide_cs(void) diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index 27391c3..6d9816e 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c @@ -430,6 +430,28 @@ static void avmcs_release(dev_link_t *link) } /* avmcs_release */ +static int avmcs_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int avmcs_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -459,20 +481,6 @@ static int avmcs_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; avmcs_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; } /* avmcs_event */ @@ -494,6 +502,8 @@ static struct pcmcia_driver avmcs_driver = { .event = avmcs_event, .detach = avmcs_detach, .id_table = avmcs_ids, + .suspend= avmcs_suspend, + .resume = avmcs_resume, }; static int __init avmcs_init(void) diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 5f5a5ae7..433cec4 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c @@ -445,6 +445,28 @@ static void avma1cs_release(dev_link_t *link) avma1cs_detach(link); } /* avma1cs_release */ +static int avma1cs_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int avma1cs_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -475,20 +497,6 @@ static int avma1cs_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; avma1cs_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; } /* avma1cs_event */ @@ -509,6 +517,8 @@ static struct pcmcia_driver avma1cs_driver = { .event = avma1cs_event, .detach = avma1cs_detach, .id_table = avma1cs_ids, + .suspend = avma1cs_suspend, + .resume = avma1cs_resume, }; /*====================================================================*/ diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index 6fc6868..0cbe045 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c @@ -447,6 +447,32 @@ static void elsa_cs_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } /* elsa_cs_release */ +static int elsa_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + local_info_t *dev = link->priv; + + link->state |= DEV_SUSPEND; + dev->busy = 1; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int elsa_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + local_info_t *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + dev->busy = 0; + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -465,7 +491,6 @@ static int elsa_cs_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - local_info_t *dev = link->priv; DEBUG(1, "elsa_cs_event(%d)\n", event); @@ -481,23 +506,6 @@ static int elsa_cs_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; elsa_cs_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - /* Mark the device as stopped, to block IO until later */ - dev->busy = 1; - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) - pcmcia_request_configuration(link->handle, &link->conf); - dev->busy = 0; - break; } return 0; } /* elsa_cs_event */ @@ -518,6 +526,8 @@ static struct pcmcia_driver elsa_cs_driver = { .event = elsa_cs_event, .detach = elsa_cs_detach, .id_table = elsa_ids, + .suspend = elsa_suspend, + .resume = elsa_resume, }; static int __init init_elsa_cs(void) diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index dc334aa..27dce7c 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c @@ -553,6 +553,32 @@ static void sedlbauer_release(dev_link_t *link) } /* sedlbauer_release */ +static int sedlbauer_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + local_info_t *dev = link->priv; + + link->state |= DEV_SUSPEND; + dev->stop = 1; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int sedlbauer_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + local_info_t *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + dev->stop = 0; + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -569,7 +595,6 @@ static int sedlbauer_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - local_info_t *dev = link->priv; DEBUG(1, "sedlbauer_event(0x%06x)\n", event); @@ -585,27 +610,6 @@ static int sedlbauer_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; sedlbauer_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - /* Mark the device as stopped, to block IO until later */ - dev->stop = 1; - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) - pcmcia_request_configuration(link->handle, &link->conf); - dev->stop = 0; - /* - In a normal driver, additional code may go here to restore - the device state and restart IO. - */ - break; } return 0; } /* sedlbauer_event */ @@ -631,6 +635,8 @@ static struct pcmcia_driver sedlbauer_driver = { .event = sedlbauer_event, .detach = sedlbauer_detach, .id_table = sedlbauer_ids, + .suspend = sedlbauer_suspend, + .resume = sedlbauer_resume, }; static int __init init_sedlbauer_cs(void) diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index 0ddef1b..70213bc 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c @@ -428,6 +428,32 @@ static void teles_cs_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } /* teles_cs_release */ +static int teles_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + local_info_t *dev = link->priv; + + link->state |= DEV_SUSPEND; + dev->busy = 1; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int teles_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + local_info_t *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + dev->busy = 0; + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -446,7 +472,6 @@ static int teles_cs_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - local_info_t *dev = link->priv; DEBUG(1, "teles_cs_event(%d)\n", event); @@ -462,23 +487,6 @@ static int teles_cs_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; teles_cs_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - /* Mark the device as stopped, to block IO until later */ - dev->busy = 1; - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) - pcmcia_request_configuration(link->handle, &link->conf); - dev->busy = 0; - break; } return 0; } /* teles_cs_event */ @@ -498,6 +506,8 @@ static struct pcmcia_driver teles_cs_driver = { .event = teles_cs_event, .detach = teles_detach, .id_table = teles_ids, + .suspend = teles_suspend, + .resume = teles_resume, }; static int __init init_teles_cs(void) diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index af24216..86443cf 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c @@ -691,6 +691,24 @@ static void pcmciamtd_config(dev_link_t *link) } +static int pcmciamtd_suspend(struct pcmcia_device *dev) +{ + DEBUG(2, "EVENT_PM_RESUME"); + + /* get_lock(link); */ + + return 0; +} + +static int pcmciamtd_resume(struct pcmcia_device *dev) +{ + DEBUG(2, "EVENT_PM_SUSPEND"); + + /* free_lock(link); */ + + return 0; +} + /* The card status event handler. Mostly, this schedules other * stuff to run after an event is received. A CARD_REMOVAL event * also sets some flags to discourage the driver from trying @@ -721,22 +739,6 @@ static int pcmciamtd_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; pcmciamtd_config(link); break; - case CS_EVENT_PM_SUSPEND: - DEBUG(2, "EVENT_PM_SUSPEND"); - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - DEBUG(2, "EVENT_RESET_PHYSICAL"); - /* get_lock(link); */ - break; - case CS_EVENT_PM_RESUME: - DEBUG(2, "EVENT_PM_RESUME"); - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - DEBUG(2, "EVENT_CARD_RESET"); - /* free_lock(link); */ - break; default: DEBUG(2, "Unknown event %d", event); } @@ -848,6 +850,8 @@ static struct pcmcia_driver pcmciamtd_driver = { .detach = pcmciamtd_detach, .owner = THIS_MODULE, .id_table = pcmciamtd_ids, + .suspend = pcmciamtd_suspend, + .resume = pcmciamtd_resume, }; diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 71fd411..80414a7 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c @@ -547,6 +547,38 @@ static void tc574_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int tc574_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int tc574_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + tc574_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + /* The card status event handler. Mostly, this schedules other stuff to run after an event is received. A CARD_REMOVAL event @@ -572,28 +604,6 @@ static int tc574_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; tc574_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - tc574_reset(dev); - netif_device_attach(dev); - } - } - break; } return 0; } /* tc574_event */ @@ -1296,6 +1306,8 @@ static struct pcmcia_driver tc574_driver = { .event = tc574_event, .detach = tc574_detach, .id_table = tc574_ids, + .suspend = tc574_suspend, + .resume = tc574_resume, }; static int __init init_tc574(void) diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index d83fdd8..bbda681 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c @@ -421,6 +421,38 @@ static void tc589_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int tc589_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int tc589_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + tc589_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -448,28 +480,6 @@ static int tc589_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; tc589_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - tc589_reset(dev); - netif_device_attach(dev); - } - } - break; } return 0; } /* tc589_event */ @@ -1071,6 +1081,8 @@ static struct pcmcia_driver tc589_driver = { .event = tc589_event, .detach = tc589_detach, .id_table = tc589_ids, + .suspend = tc589_suspend, + .resume = tc589_resume, }; static int __init init_tc589(void) diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 8bb4e85..6c6b252 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -490,6 +490,40 @@ static void axnet_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int axnet_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int axnet_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + axnet_reset_8390(dev); + AX88190_init(dev, 1); + netif_device_attach(dev); + } + } + + return 0; +} + + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -517,29 +551,6 @@ static int axnet_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; axnet_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - axnet_reset_8390(dev); - AX88190_init(dev, 1); - netif_device_attach(dev); - } - } - break; } return 0; } /* axnet_event */ @@ -881,6 +892,8 @@ static struct pcmcia_driver axnet_cs_driver = { .event = axnet_event, .detach = axnet_detach, .id_table = axnet_ids, + .suspend = axnet_suspend, + .resume = axnet_resume, }; static int __init init_axnet_cs(void) diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index b9355d9..6861222 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c @@ -421,6 +421,42 @@ static void com20020_release(dev_link_t *link) link->state &= ~(DEV_CONFIG | DEV_RELEASE_PENDING); } +static int com20020_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + com20020_dev_t *info = link->priv; + struct net_device *dev = info->dev; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) { + netif_device_detach(dev); + } + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int com20020_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + com20020_dev_t *info = link->priv; + struct net_device *dev = info->dev; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + int ioaddr = dev->base_addr; + struct arcnet_local *lp = dev->priv; + ARCRESET; + } + } + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -449,30 +485,6 @@ static int com20020_event(event_t event, int priority, link->state |= DEV_PRESENT; com20020_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) { - netif_device_detach(dev); - } - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - int ioaddr = dev->base_addr; - struct arcnet_local *lp = dev->priv; - ARCRESET; - } - } - break; } return 0; } /* com20020_event */ @@ -492,6 +504,8 @@ static struct pcmcia_driver com20020_cs_driver = { .event = com20020_event, .detach = com20020_detach, .id_table = com20020_ids, + .suspend = com20020_suspend, + .resume = com20020_resume, }; static int __init init_com20020_cs(void) diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 356f509..388ecad 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -713,6 +713,39 @@ static void fmvj18x_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int fmvj18x_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + + return 0; +} + +static int fmvj18x_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + fjn_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + /*====================================================================*/ static int fmvj18x_event(event_t event, int priority, @@ -733,28 +766,6 @@ static int fmvj18x_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; fmvj18x_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - fjn_reset(dev); - netif_device_attach(dev); - } - } - break; } return 0; } /* fmvj18x_event */ @@ -793,6 +804,8 @@ static struct pcmcia_driver fmvj18x_cs_driver = { .event = fmvj18x_event, .detach = fmvj18x_detach, .id_table = fmvj18x_ids, + .suspend = fmvj18x_suspend, + .resume = fmvj18x_resume, }; static int __init init_fmvj18x_cs(void) diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index b6c140e..3a7218e 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -401,6 +401,41 @@ static void ibmtr_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int ibmtr_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + ibmtr_dev_t *info = link->priv; + struct net_device *dev = info->dev; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int ibmtr_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + ibmtr_dev_t *info = link->priv; + struct net_device *dev = info->dev; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + ibmtr_probe(dev); /* really? */ + netif_device_attach(dev); + } + } + + return 0; +} + + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -433,28 +468,6 @@ static int ibmtr_event(event_t event, int priority, link->state |= DEV_PRESENT; ibmtr_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - ibmtr_probe(dev); /* really? */ - netif_device_attach(dev); - } - } - break; } return 0; } /* ibmtr_event */ @@ -518,6 +531,8 @@ static struct pcmcia_driver ibmtr_cs_driver = { .event = ibmtr_event, .detach = ibmtr_detach, .id_table = ibmtr_ids, + .suspend = ibmtr_suspend, + .resume = ibmtr_resume, }; static int __init init_ibmtr_cs(void) diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index 980d7e5..fa4921f 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c @@ -801,6 +801,39 @@ static void nmclan_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int nmclan_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + + return 0; +} + +static int nmclan_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + nmclan_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + /* ---------------------------------------------------------------------------- nmclan_event The card status event handler. Mostly, this schedules other @@ -826,28 +859,6 @@ static int nmclan_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; nmclan_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - nmclan_reset(dev); - netif_device_attach(dev); - } - } - break; case CS_EVENT_RESET_REQUEST: return 1; break; @@ -1685,6 +1696,8 @@ static struct pcmcia_driver nmclan_cs_driver = { .event = nmclan_event, .detach = nmclan_detach, .id_table = nmclan_ids, + .suspend = nmclan_suspend, + .resume = nmclan_resume, }; static int __init init_nmclan_cs(void) diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 818c185..7db4d6f 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -780,6 +780,39 @@ static void pcnet_release(dev_link_t *link) ======================================================================*/ +static int pcnet_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int pcnet_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + pcnet_reset_8390(dev); + NS8390_init(dev, 1); + netif_device_attach(dev); + } + } + + return 0; +} + static int pcnet_event(event_t event, int priority, event_callback_args_t *args) { @@ -798,29 +831,6 @@ static int pcnet_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; pcnet_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - pcnet_reset_8390(dev); - NS8390_init(dev, 1); - netif_device_attach(dev); - } - } - break; } return 0; } /* pcnet_event */ @@ -1849,6 +1859,8 @@ static struct pcmcia_driver pcnet_driver = { .detach = pcnet_detach, .owner = THIS_MODULE, .id_table = pcnet_ids, + .suspend = pcnet_suspend, + .resume = pcnet_resume, }; static int __init init_pcnet_cs(void) diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index c7cca84..7c61ec9 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -895,6 +895,62 @@ free_cfg_mem: return rc; } +static int smc91c92_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int smc91c92_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + struct smc_private *smc = netdev_priv(dev); + int i; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if ((smc->manfid == MANFID_MEGAHERTZ) && + (smc->cardid == PRODID_MEGAHERTZ_EM3288)) + mhz_3288_power(link); + pcmcia_request_configuration(link->handle, &link->conf); + if (smc->manfid == MANFID_MOTOROLA) + mot_config(link); + if ((smc->manfid == MANFID_OSITECH) && + (smc->cardid != PRODID_OSITECH_SEVEN)) { + /* Power up the card and enable interrupts */ + set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR); + set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR); + } + if (((smc->manfid == MANFID_OSITECH) && + (smc->cardid == PRODID_OSITECH_SEVEN)) || + ((smc->manfid == MANFID_PSION) && + (smc->cardid == PRODID_PSION_NET100))) { + /* Download the Seven of Diamonds firmware */ + for (i = 0; i < sizeof(__Xilinx7OD); i++) { + outb(__Xilinx7OD[i], link->io.BasePort1+2); + udelay(50); + } + } + if (link->open) { + smc_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + + /*====================================================================== This verifies that the chip is some SMC91cXX variant, and returns @@ -935,14 +991,12 @@ static int check_sig(dev_link_t *link) } if (width) { - event_callback_args_t args; printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n"); - args.client_data = link; - smc91c92_event(CS_EVENT_RESET_PHYSICAL, 0, &args); + smc91c92_suspend(link->handle); pcmcia_release_io(link->handle, &link->io); link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; pcmcia_request_io(link->handle, &link->io); - smc91c92_event(CS_EVENT_CARD_RESET, 0, &args); + smc91c92_resume(link->handle); return check_sig(link); } return -ENODEV; @@ -1184,8 +1238,6 @@ static int smc91c92_event(event_t event, int priority, { dev_link_t *link = args->client_data; struct net_device *dev = link->priv; - struct smc_private *smc = netdev_priv(dev); - int i; DEBUG(1, "smc91c92_event(0x%06x)\n", event); @@ -1199,49 +1251,6 @@ static int smc91c92_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; smc91c92_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - if ((smc->manfid == MANFID_MEGAHERTZ) && - (smc->cardid == PRODID_MEGAHERTZ_EM3288)) - mhz_3288_power(link); - pcmcia_request_configuration(link->handle, &link->conf); - if (smc->manfid == MANFID_MOTOROLA) - mot_config(link); - if ((smc->manfid == MANFID_OSITECH) && - (smc->cardid != PRODID_OSITECH_SEVEN)) { - /* Power up the card and enable interrupts */ - set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR); - set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR); - } - if (((smc->manfid == MANFID_OSITECH) && - (smc->cardid == PRODID_OSITECH_SEVEN)) || - ((smc->manfid == MANFID_PSION) && - (smc->cardid == PRODID_PSION_NET100))) { - /* Download the Seven of Diamonds firmware */ - for (i = 0; i < sizeof(__Xilinx7OD); i++) { - outb(__Xilinx7OD[i], link->io.BasePort1+2); - udelay(50); - } - } - if (link->open) { - smc_reset(dev); - netif_device_attach(dev); - } - } - break; } return 0; } /* smc91c92_event */ @@ -2364,6 +2373,8 @@ static struct pcmcia_driver smc91c92_cs_driver = { .event = smc91c92_event, .detach = smc91c92_detach, .id_table = smc91c92_ids, + .suspend = smc91c92_suspend, + .resume = smc91c92_resume, }; static int __init init_smc91c92_cs(void) diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index ce143f0..917e50a 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -1157,6 +1157,41 @@ xirc2ps_release(dev_link_t *link) /*====================================================================*/ + +static int xirc2ps_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) { + netif_device_detach(dev); + do_powerdown(dev); + } + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int xirc2ps_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + do_reset(dev,1); + netif_device_attach(dev); + } + } + + return 0; +} + /**************** * The card status event handler. Mostly, this schedules other * stuff to run after an event is received. A CARD_REMOVAL event @@ -1191,30 +1226,6 @@ xirc2ps_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; xirc2ps_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) { - netif_device_detach(dev); - do_powerdown(dev); - } - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - do_reset(dev,1); - netif_device_attach(dev); - } - } - break; } return 0; } /* xirc2ps_event */ @@ -2013,6 +2024,8 @@ static struct pcmcia_driver xirc2ps_cs_driver = { .event = xirc2ps_event, .detach = xirc2ps_detach, .id_table = xirc2ps_ids, + .suspend = xirc2ps_suspend, + .resume = xirc2ps_resume, }; static int __init diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index e328547..80c9de7 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -492,6 +492,35 @@ static void airo_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int airo_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + local_info_t *local = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + netif_device_detach(local->eth_dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int airo_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + local_info_t *local = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + reset_airo_card(local->eth_dev); + netif_device_attach(local->eth_dev); + } + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -524,25 +553,6 @@ static int airo_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; airo_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - netif_device_detach(local->eth_dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - reset_airo_card(local->eth_dev); - netif_device_attach(local->eth_dev); - } - break; } return 0; } /* airo_event */ @@ -565,6 +575,8 @@ static struct pcmcia_driver airo_driver = { .event = airo_event, .detach = airo_detach, .id_table = airo_ids, + .suspend = airo_suspend, + .resume = airo_resume, }; static int airo_cs_init(void) diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index 17d1fd9..598a9cd 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -477,6 +477,35 @@ static void atmel_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int atmel_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + local_info_t *local = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + netif_device_detach(local->eth_dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int atmel_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + local_info_t *local = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + atmel_open(local->eth_dev); + netif_device_attach(local->eth_dev); + } + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -509,25 +538,6 @@ static int atmel_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; atmel_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - netif_device_detach(local->eth_dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - atmel_open(local->eth_dev); - netif_device_attach(local->eth_dev); - } - break; } return 0; } /* atmel_event */ @@ -585,6 +595,8 @@ static struct pcmcia_driver atmel_driver = { .event = atmel_event, .detach = atmel_detach, .id_table = atmel_ids, + .suspend = atmel_suspend, + .resume = atmel_resume, }; static int atmel_cs_init(void) diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 2643976..ba4a7da 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -846,20 +846,64 @@ static void prism2_release(u_long arg) PDEBUG(DEBUG_FLOW, "release - done\n"); } +static int hostap_cs_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = (struct net_device *) link->priv; + int dev_open = 0; -static int prism2_event(event_t event, int priority, - event_callback_args_t *args) + PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); + + link->state |= DEV_SUSPEND; + + if (link->state & DEV_CONFIG) { + struct hostap_interface *iface = netdev_priv(dev); + if (iface && iface->local) + dev_open = iface->local->num_dev_open > 0; + if (dev_open) { + netif_stop_queue(dev); + netif_device_detach(dev); + } + prism2_suspend(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int hostap_cs_resume(struct pcmcia_device *p_dev) { - dev_link_t *link = args->client_data; + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = (struct net_device *) link->priv; int dev_open = 0; + PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); + + link->state &= ~DEV_SUSPEND; if (link->state & DEV_CONFIG) { struct hostap_interface *iface = netdev_priv(dev); if (iface && iface->local) dev_open = iface->local->num_dev_open > 0; + + pcmcia_request_configuration(link->handle, &link->conf); + + prism2_hw_shutdown(dev, 1); + prism2_hw_config(dev, dev_open ? 0 : 1); + if (dev_open) { + netif_device_attach(dev); + netif_start_queue(dev); + } } + return 0; +} + +static int prism2_event(event_t event, int priority, + event_callback_args_t *args) +{ + dev_link_t *link = args->client_data; + struct net_device *dev = (struct net_device *) link->priv; + switch (event) { case CS_EVENT_CARD_INSERTION: PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info); @@ -879,42 +923,6 @@ static int prism2_event(event_t event, int priority, } break; - case CS_EVENT_PM_SUSPEND: - PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); - link->state |= DEV_SUSPEND; - /* fall through */ - - case CS_EVENT_RESET_PHYSICAL: - PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info); - if (link->state & DEV_CONFIG) { - if (dev_open) { - netif_stop_queue(dev); - netif_device_detach(dev); - } - prism2_suspend(dev); - pcmcia_release_configuration(link->handle); - } - break; - - case CS_EVENT_PM_RESUME: - PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); - link->state &= ~DEV_SUSPEND; - /* fall through */ - - case CS_EVENT_CARD_RESET: - PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_RESET\n", dev_info); - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, - &link->conf); - prism2_hw_shutdown(dev, 1); - prism2_hw_config(dev, dev_open ? 0 : 1); - if (dev_open) { - netif_device_attach(dev); - netif_start_queue(dev); - } - } - break; - default: PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n", dev_info, event); @@ -987,6 +995,8 @@ static struct pcmcia_driver hostap_driver = { .owner = THIS_MODULE, .event = prism2_event, .id_table = hostap_cs_ids, + .suspend = hostap_cs_suspend, + .resume = hostap_cs_resume, }; static int __init init_prism2_pccard(void) diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 92793b9..7ab2d70 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c @@ -935,6 +935,39 @@ static void netwave_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int netwave_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int netwave_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + netwave_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + + /* * Function netwave_event (event, priority, args) * @@ -973,28 +1006,6 @@ static int netwave_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; netwave_pcmcia_config( link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - netwave_reset(dev); - netif_device_attach(dev); - } - } - break; } return 0; } /* netwave_event */ @@ -1495,6 +1506,8 @@ static struct pcmcia_driver netwave_driver = { .event = netwave_event, .detach = netwave_detach, .id_table = netwave_ids, + .suspend = netwave_suspend, + .resume = netwave_resume, }; static int __init init_netwave_cs(void) diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index dc1128a..1d66050 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -465,6 +465,83 @@ orinoco_cs_release(dev_link_t *link) ioport_unmap(priv->hw.iobase); } /* orinoco_cs_release */ +static int orinoco_cs_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + struct orinoco_private *priv = netdev_priv(dev); + struct orinoco_pccard *card = priv->card; + int err = 0; + unsigned long flags; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + /* This is probably racy, but I can't think of + a better way, short of rewriting the PCMCIA + layer to not suck :-( */ + if (! test_bit(0, &card->hard_reset_in_progress)) { + spin_lock_irqsave(&priv->lock, flags); + + err = __orinoco_down(dev); + if (err) + printk(KERN_WARNING "%s: Error %d downing interface\n", + dev->name, err); + + netif_device_detach(dev); + priv->hw_unavailable++; + + spin_unlock_irqrestore(&priv->lock, flags); + } + + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int orinoco_cs_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + struct orinoco_private *priv = netdev_priv(dev); + struct orinoco_pccard *card = priv->card; + int err = 0; + unsigned long flags; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + /* FIXME: should we double check that this is + * the same card as we had before */ + pcmcia_request_configuration(link->handle, &link->conf); + + if (! test_bit(0, &card->hard_reset_in_progress)) { + err = orinoco_reinit_firmware(dev); + if (err) { + printk(KERN_ERR "%s: Error %d re-initializing firmware\n", + dev->name, err); + return -EIO; + } + + spin_lock_irqsave(&priv->lock, flags); + + netif_device_attach(dev); + priv->hw_unavailable--; + + if (priv->open && ! priv->hw_unavailable) { + err = __orinoco_up(dev); + if (err) + printk(KERN_ERR "%s: Error %d restarting card\n", + dev->name, err); + } + + spin_unlock_irqrestore(&priv->lock, flags); + } + } + + return 0; +} + + /* * The card status event handler. Mostly, this schedules other stuff * to run after an event is received. @@ -476,9 +553,7 @@ orinoco_cs_event(event_t event, int priority, dev_link_t *link = args->client_data; struct net_device *dev = link->priv; struct orinoco_private *priv = netdev_priv(dev); - struct orinoco_pccard *card = priv->card; int err = 0; - unsigned long flags; switch (event) { case CS_EVENT_CARD_REMOVAL: @@ -497,70 +572,6 @@ orinoco_cs_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; orinoco_cs_config(link); break; - - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - /* Mark the device as stopped, to block IO until later */ - if (link->state & DEV_CONFIG) { - /* This is probably racy, but I can't think of - a better way, short of rewriting the PCMCIA - layer to not suck :-( */ - if (! test_bit(0, &card->hard_reset_in_progress)) { - spin_lock_irqsave(&priv->lock, flags); - - err = __orinoco_down(dev); - if (err) - printk(KERN_WARNING "%s: %s: Error %d downing interface\n", - dev->name, - event == CS_EVENT_PM_SUSPEND ? "SUSPEND" : "RESET_PHYSICAL", - err); - - netif_device_detach(dev); - priv->hw_unavailable++; - - spin_unlock_irqrestore(&priv->lock, flags); - } - - pcmcia_release_configuration(link->handle); - } - break; - - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - /* FIXME: should we double check that this is - * the same card as we had before */ - pcmcia_request_configuration(link->handle, &link->conf); - - if (! test_bit(0, &card->hard_reset_in_progress)) { - err = orinoco_reinit_firmware(dev); - if (err) { - printk(KERN_ERR "%s: Error %d re-initializing firmware\n", - dev->name, err); - break; - } - - spin_lock_irqsave(&priv->lock, flags); - - netif_device_attach(dev); - priv->hw_unavailable--; - - if (priv->open && ! priv->hw_unavailable) { - err = __orinoco_up(dev); - if (err) - printk(KERN_ERR "%s: Error %d restarting card\n", - dev->name, err); - - } - - spin_unlock_irqrestore(&priv->lock, flags); - } - } - break; } return err; @@ -669,6 +680,8 @@ static struct pcmcia_driver orinoco_driver = { .detach = orinoco_cs_detach, .event = orinoco_cs_event, .id_table = orinoco_cs_ids, + .suspend = orinoco_cs_suspend, + .resume = orinoco_cs_resume, }; static int __init diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 70fd6fd..c2cb6c8 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -891,6 +891,40 @@ static void ray_release(dev_link_t *link) DEBUG(2,"ray_release ending\n"); } +static int ray_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + + pcmcia_release_configuration(link->handle); + } + + + return 0; +} + +static int ray_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + ray_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + /*============================================================================= The card status event handler. Mostly, this schedules other stuff to run after an event is received. A CARD_REMOVAL event @@ -923,29 +957,6 @@ static int ray_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; ray_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - ray_reset(dev); - netif_device_attach(dev); - } - } - break; } return 0; DEBUG(2,"ray_event ending\n"); @@ -2949,6 +2960,8 @@ static struct pcmcia_driver ray_driver = { .event = ray_event, .detach = ray_detach, .id_table = ray_ids, + .suspend = ray_suspend, + .resume = ray_resume, }; static int __init init_ray_cs(void) diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index b1bbc8e..3938a57 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c @@ -948,6 +948,56 @@ spectrum_cs_release(dev_link_t *link) ioport_unmap(priv->hw.iobase); } /* spectrum_cs_release */ + +static int +spectrum_cs_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + struct orinoco_private *priv = netdev_priv(dev); + unsigned long flags; + int err = 0; + + link->state |= DEV_SUSPEND; + /* Mark the device as stopped, to block IO until later */ + if (link->state & DEV_CONFIG) { + spin_lock_irqsave(&priv->lock, flags); + + err = __orinoco_down(dev); + if (err) + printk(KERN_WARNING "%s: Error %d downing interface\n", + dev->name, err); + + netif_device_detach(dev); + priv->hw_unavailable++; + + spin_unlock_irqrestore(&priv->lock, flags); + + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int +spectrum_cs_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + struct orinoco_private *priv = netdev_priv(dev); + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + /* FIXME: should we double check that this is + * the same card as we had before */ + pcmcia_request_configuration(link->handle, &link->conf); + netif_device_attach(dev); + priv->hw_unavailable--; + schedule_work(&priv->reset_work); + } + return 0; +} + /* * The card status event handler. Mostly, this schedules other stuff * to run after an event is received. @@ -959,8 +1009,6 @@ spectrum_cs_event(event_t event, int priority, dev_link_t *link = args->client_data; struct net_device *dev = link->priv; struct orinoco_private *priv = netdev_priv(dev); - int err = 0; - unsigned long flags; switch (event) { case CS_EVENT_CARD_REMOVAL: @@ -980,49 +1028,9 @@ spectrum_cs_event(event_t event, int priority, spectrum_cs_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - /* Mark the device as stopped, to block IO until later */ - if (link->state & DEV_CONFIG) { - /* This is probably racy, but I can't think of - a better way, short of rewriting the PCMCIA - layer to not suck :-( */ - spin_lock_irqsave(&priv->lock, flags); - - err = __orinoco_down(dev); - if (err) - printk(KERN_WARNING "%s: %s: Error %d downing interface\n", - dev->name, - event == CS_EVENT_PM_SUSPEND ? "SUSPEND" : "RESET_PHYSICAL", - err); - - netif_device_detach(dev); - priv->hw_unavailable++; - - spin_unlock_irqrestore(&priv->lock, flags); - - pcmcia_release_configuration(link->handle); - } - break; - - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - /* FIXME: should we double check that this is - * the same card as we had before */ - pcmcia_request_configuration(link->handle, &link->conf); - netif_device_attach(dev); - priv->hw_unavailable--; - schedule_work(&priv->reset_work); - } - break; } - return err; + return 0; } /* spectrum_cs_event */ /********************************************************************/ @@ -1050,6 +1058,8 @@ static struct pcmcia_driver orinoco_driver = { }, .attach = spectrum_cs_attach, .detach = spectrum_cs_detach, + .suspend = spectrum_cs_suspend, + .resume = spectrum_cs_resume, .event = spectrum_cs_event, .id_table = spectrum_cs_ids, }; diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index c822cad..3e35328 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c @@ -4775,6 +4775,56 @@ wavelan_detach(dev_link_t * link) #endif } +static int wavelan_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device * dev = (struct net_device *) link->priv; + + /* NB: wavelan_close will be called, but too late, so we are + * obliged to close nicely the wavelan here. David, could you + * close the device before suspending them ? And, by the way, + * could you, on resume, add a "route add -net ..." after the + * ifconfig up ? Thanks... */ + + /* Stop receiving new messages and wait end of transmission */ + wv_ru_stop(dev); + + /* Power down the module */ + hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT)); + + /* The card is now suspended */ + link->state |= DEV_SUSPEND; + + if(link->state & DEV_CONFIG) + { + if(link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int wavelan_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device * dev = (struct net_device *) link->priv; + + link->state &= ~DEV_SUSPEND; + if(link->state & DEV_CONFIG) + { + pcmcia_request_configuration(link->handle, &link->conf); + if(link->open) /* If RESET -> True, If RESUME -> False ? */ + { + wv_hw_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + + /*------------------------------------------------------------------*/ /* * The card status event handler. Mostly, this schedules other stuff @@ -4832,46 +4882,6 @@ wavelan_event(event_t event, /* The event received */ else dev->irq = 0; break; - - case CS_EVENT_PM_SUSPEND: - /* NB: wavelan_close will be called, but too late, so we are - * obliged to close nicely the wavelan here. David, could you - * close the device before suspending them ? And, by the way, - * could you, on resume, add a "route add -net ..." after the - * ifconfig up ? Thanks... */ - - /* Stop receiving new messages and wait end of transmission */ - wv_ru_stop(dev); - - /* Power down the module */ - hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT)); - - /* The card is now suspended */ - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if(link->state & DEV_CONFIG) - { - if(link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if(link->state & DEV_CONFIG) - { - pcmcia_request_configuration(link->handle, &link->conf); - if(link->open) /* If RESET -> True, If RESUME -> False ? */ - { - wv_hw_reset(dev); - netif_device_attach(dev); - } - } - break; } #ifdef DEBUG_CALLBACK_TRACE @@ -4898,6 +4908,8 @@ static struct pcmcia_driver wavelan_driver = { .event = wavelan_event, .detach = wavelan_detach, .id_table = wavelan_ids, + .suspend = wavelan_suspend, + .resume = wavelan_resume, }; static int __init diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 978fdc6..7511431 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -2173,6 +2173,41 @@ static void wl3501_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int wl3501_suspend(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + link->state |= DEV_SUSPEND; + + wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); + if (link->state & DEV_CONFIG) { + if (link->open) + netif_device_detach(dev); + pcmcia_release_configuration(link->handle); + } + + return 0; +} + +static int wl3501_resume(struct pcmcia_device *p_dev) +{ + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + + wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + if (link->open) { + wl3501_reset(dev); + netif_device_attach(dev); + } + } + + return 0; +} + + /** * wl3501_event - The card status event handler * @event - event @@ -2206,30 +2241,6 @@ static int wl3501_event(event_t event, int pri, event_callback_args_t *args) link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; wl3501_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) { - if (link->open) - netif_device_detach(dev); - pcmcia_release_configuration(link->handle); - } - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - if (link->open) { - wl3501_reset(dev); - netif_device_attach(dev); - } - } - break; } return 0; } @@ -2249,6 +2260,8 @@ static struct pcmcia_driver wl3501_driver = { .event = wl3501_event, .detach = wl3501_detach, .id_table = wl3501_ids, + .suspend = wl3501_suspend, + .resume = wl3501_resume, }; static int __init wl3501_init_module(void) diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 24e6aac..4c89853 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c @@ -325,6 +325,28 @@ void parport_cs_release(dev_link_t *link) } /* parport_cs_release */ +static int parport_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int parport_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (DEV_OK(link)) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -349,20 +371,6 @@ int parport_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; parport_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (DEV_OK(link)) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; } /* parport_event */ @@ -383,7 +391,8 @@ static struct pcmcia_driver parport_cs_driver = { .event = parport_event, .detach = parport_detach, .id_table = parport_ids, - + .suspend = parport_suspend, + .resume = parport_resume, }; static int __init init_parport_cs(void) diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index b120794..a802c65 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -951,6 +951,16 @@ static int send_event_callback(struct device *dev, void * _data) if (p_dev->state & (CLIENT_UNBOUND|CLIENT_STALE)) return 0; + if ((data->event == CS_EVENT_PM_SUSPEND) || + (data->event == CS_EVENT_RESET_PHYSICAL)) { + if (p_drv->suspend) + return p_drv->suspend(p_dev); + } else if ((data->event == CS_EVENT_PM_RESUME) || + (data->event == CS_EVENT_CARD_RESET)) { + if (p_drv->resume) + return p_drv->resume(p_dev); + } + if (p_drv->event) return p_drv->event(data->event, data->priority, &p_dev->event_callback_args); diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 7c53064..82988a3 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -272,11 +272,37 @@ static void aha152x_release_cs(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int aha152x_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int aha152x_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + scsi_info_t *info = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + Scsi_Cmnd tmp; + pcmcia_request_configuration(link->handle, &link->conf); + tmp.device->host = info->host; + aha152x_host_reset(&tmp); + } + + return 0; +} + static int aha152x_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - scsi_info_t *info = link->priv; DEBUG(0, "aha152x_event(0x%06x)\n", event); @@ -290,24 +316,6 @@ static int aha152x_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; aha152x_config_cs(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - Scsi_Cmnd tmp; - pcmcia_request_configuration(link->handle, &link->conf); - tmp.device->host = info->host; - aha152x_host_reset(&tmp); - } - break; } return 0; } @@ -331,6 +339,8 @@ static struct pcmcia_driver aha152x_cs_driver = { .event = aha152x_event, .detach = aha152x_detach, .id_table = aha152x_ids, + .suspend = aha152x_suspend, + .resume = aha152x_resume, }; static int __init init_aha152x_cs(void) diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index db8f5cd..9e1d68c 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -256,6 +256,30 @@ static void fdomain_release(dev_link_t *link) /*====================================================================*/ +static int fdomain_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int fdomain_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + fdomain_16x0_bus_reset(NULL); + } + + return 0; +} + static int fdomain_event(event_t event, int priority, event_callback_args_t *args) { @@ -273,22 +297,6 @@ static int fdomain_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; fdomain_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - fdomain_16x0_bus_reset(NULL); - } - break; } return 0; } /* fdomain_event */ @@ -311,6 +319,8 @@ static struct pcmcia_driver fdomain_cs_driver = { .event = fdomain_event, .detach = fdomain_detach, .id_table = fdomain_ids, + .suspend = fdomain_suspend, + .resume = fdomain_resume, }; static int __init init_fdomain_cs(void) diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index 050ea13..870e871 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -2021,6 +2021,59 @@ static void nsp_cs_release(dev_link_t *link) #endif } /* nsp_cs_release */ +static int nsp_cs_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + scsi_info_t *info = link->priv; + nsp_hw_data *data; + + link->state |= DEV_SUSPEND; + + nsp_dbg(NSP_DEBUG_INIT, "event: suspend"); + + if (info->host != NULL) { + nsp_msg(KERN_INFO, "clear SDTR status"); + + data = (nsp_hw_data *)info->host->hostdata; + + nsphw_init_sync(data); + } + + info->stop = 1; + + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int nsp_cs_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + scsi_info_t *info = link->priv; + nsp_hw_data *data; + + nsp_dbg(NSP_DEBUG_INIT, "event: resume"); + + link->state &= ~DEV_SUSPEND; + + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + + info->stop = 0; + + if (info->host != NULL) { + nsp_msg(KERN_INFO, "reset host and bus"); + + data = (nsp_hw_data *)info->host->hostdata; + + nsphw_init (data); + nsp_bus_reset(data); + } + + return 0; +} + /*====================================================================== The card status event handler. Mostly, this schedules other @@ -2039,8 +2092,6 @@ static int nsp_cs_event(event_t event, event_callback_args_t *args) { dev_link_t *link = args->client_data; - scsi_info_t *info = link->priv; - nsp_hw_data *data; nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event); @@ -2062,51 +2113,6 @@ static int nsp_cs_event(event_t event, #endif nsp_cs_config(link); break; - - case CS_EVENT_PM_SUSPEND: - nsp_dbg(NSP_DEBUG_INIT, "event: suspend"); - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - /* Mark the device as stopped, to block IO until later */ - nsp_dbg(NSP_DEBUG_INIT, "event: reset physical"); - - if (info->host != NULL) { - nsp_msg(KERN_INFO, "clear SDTR status"); - - data = (nsp_hw_data *)info->host->hostdata; - - nsphw_init_sync(data); - } - - info->stop = 1; - if (link->state & DEV_CONFIG) { - pcmcia_release_configuration(link->handle); - } - break; - - case CS_EVENT_PM_RESUME: - nsp_dbg(NSP_DEBUG_INIT, "event: resume"); - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - nsp_dbg(NSP_DEBUG_INIT, "event: reset"); - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - } - info->stop = 0; - - if (info->host != NULL) { - nsp_msg(KERN_INFO, "reset host and bus"); - - data = (nsp_hw_data *)info->host->hostdata; - - nsphw_init (data); - nsp_bus_reset(data); - } - - break; - default: nsp_dbg(NSP_DEBUG_INIT, "event: unknown"); break; @@ -2140,6 +2146,8 @@ static struct pcmcia_driver nsp_driver = { .event = nsp_cs_event, .detach = nsp_cs_detach, .id_table = nsp_cs_ids, + .suspend = nsp_cs_suspend, + .resume = nsp_cs_resume, }; #endif diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index bb091a4..2541a99 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -349,6 +349,40 @@ static void qlogic_release(dev_link_t *link) /*====================================================================*/ +static int qlogic_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int qlogic_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + scsi_info_t *info = link->priv; + + pcmcia_request_configuration(link->handle, &link->conf); + if ((info->manf_id == MANFID_MACNICA) || + (info->manf_id == MANFID_PIONEER) || + (info->manf_id == 0x0098)) { + outb(0x80, link->io.BasePort1 + 0xd); + outb(0x24, link->io.BasePort1 + 0x9); + outb(0x04, link->io.BasePort1 + 0xd); + } + /* Ugggglllyyyy!!! */ + qlogicfas408_bus_reset(NULL); + } + + return 0; +} + static int qlogic_event(event_t event, int priority, event_callback_args_t * args) { dev_link_t *link = args->client_data; @@ -365,29 +399,6 @@ static int qlogic_event(event_t event, int priority, event_callback_args_t * arg link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; qlogic_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - scsi_info_t *info = link->priv; - pcmcia_request_configuration(link->handle, &link->conf); - if ((info->manf_id == MANFID_MACNICA) || (info->manf_id == MANFID_PIONEER) || (info->manf_id == 0x0098)) { - outb(0x80, link->io.BasePort1 + 0xd); - outb(0x24, link->io.BasePort1 + 0x9); - outb(0x04, link->io.BasePort1 + 0xd); - } - /* Ugggglllyyyy!!! */ - qlogicfas408_bus_reset(NULL); - } - break; } return 0; } /* qlogic_event */ @@ -423,6 +434,8 @@ static struct pcmcia_driver qlogic_cs_driver = { .event = qlogic_event, .detach = qlogic_detach, .id_table = qlogic_ids, + .suspend = qlogic_suspend, + .resume = qlogic_resume, }; static int __init init_qlogic_cs(void) diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 98b64b2..c4e3e22 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -872,11 +872,48 @@ cs_failed: return; } /* SYM53C500_config */ +static int sym53c500_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int sym53c500_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + struct scsi_info_t *info = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + + /* See earlier comment about manufacturer IDs. */ + if ((info->manf_id == MANFID_MACNICA) || + (info->manf_id == MANFID_PIONEER) || + (info->manf_id == 0x0098)) { + outb(0x80, link->io.BasePort1 + 0xd); + outb(0x24, link->io.BasePort1 + 0x9); + outb(0x04, link->io.BasePort1 + 0xd); + } + /* + * If things don't work after a "resume", + * this is a good place to start looking. + */ + SYM53C500_int_host_reset(link->io.BasePort1); + } + + return 0; +} + static int SYM53C500_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct scsi_info_t *info = link->priv; DEBUG(1, "SYM53C500_event(0x%06x)\n", event); @@ -890,34 +927,6 @@ SYM53C500_event(event_t event, int priority, event_callback_args_t *args) link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; SYM53C500_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - /* See earlier comment about manufacturer IDs. */ - if ((info->manf_id == MANFID_MACNICA) || - (info->manf_id == MANFID_PIONEER) || - (info->manf_id == 0x0098)) { - outb(0x80, link->io.BasePort1 + 0xd); - outb(0x24, link->io.BasePort1 + 0x9); - outb(0x04, link->io.BasePort1 + 0xd); - } - /* - * If things don't work after a "resume", - * this is a good place to start looking. - */ - SYM53C500_int_host_reset(link->io.BasePort1); - } - break; } return 0; } /* SYM53C500_event */ @@ -1012,6 +1021,8 @@ static struct pcmcia_driver sym53c500_cs_driver = { .event = SYM53C500_event, .detach = SYM53C500_detach, .id_table = sym53c500_ids, + .suspend = sym53c500_suspend, + .resume = sym53c500_resume, }; static int __init diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 7ce0c7e..3487ee9 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -159,8 +159,9 @@ static void serial_remove(dev_link_t *link) } } -static void serial_suspend(dev_link_t *link) +static int serial_suspend(struct pcmcia_device *dev) { + dev_link_t *link = dev_to_instance(dev); link->state |= DEV_SUSPEND; if (link->state & DEV_CONFIG) { @@ -173,10 +174,13 @@ static void serial_suspend(dev_link_t *link) if (!info->slave) pcmcia_release_configuration(link->handle); } + + return 0; } -static void serial_resume(dev_link_t *link) +static int serial_resume(struct pcmcia_device *dev) { + dev_link_t *link = dev_to_instance(dev); link->state &= ~DEV_SUSPEND; if (DEV_OK(link)) { @@ -189,6 +193,8 @@ static void serial_resume(dev_link_t *link) for (i = 0; i < info->ndev; i++) serial8250_resume_port(info->line[i]); } + + return 0; } /*====================================================================== @@ -731,7 +737,6 @@ static int serial_event(event_t event, int priority, event_callback_args_t * args) { dev_link_t *link = args->client_data; - struct serial_info *info = link->priv; DEBUG(1, "serial_event(0x%06x)\n", event); @@ -744,24 +749,6 @@ serial_event(event_t event, int priority, event_callback_args_t * args) link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; serial_config(link); break; - - case CS_EVENT_PM_SUSPEND: - serial_suspend(link); - break; - - case CS_EVENT_RESET_PHYSICAL: - if ((link->state & DEV_CONFIG) && !info->slave) - pcmcia_release_configuration(link->handle); - break; - - case CS_EVENT_PM_RESUME: - serial_resume(link); - break; - - case CS_EVENT_CARD_RESET: - if (DEV_OK(link) && !info->slave) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; } @@ -881,6 +868,8 @@ static struct pcmcia_driver serial_cs_driver = { .event = serial_event, .detach = serial_detach, .id_table = serial_ids, + .suspend = serial_suspend, + .resume = serial_resume, }; static int __init init_serial_cs(void) diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index 57c0c6e..7cca46b 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -255,6 +255,28 @@ static void ixj_cs_release(dev_link_t *link) link->state &= ~DEV_CONFIG; } +static int ixj_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int ixj_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (DEV_OK(link)) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} + static int ixj_event(event_t event, int priority, event_callback_args_t * args) { dev_link_t *link = args->client_data; @@ -271,20 +293,6 @@ static int ixj_event(event_t event, int priority, event_callback_args_t * args) link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; ixj_config(link); break; - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (DEV_OK(link)) - pcmcia_request_configuration(link->handle, &link->conf); - break; } return 0; } @@ -304,6 +312,8 @@ static struct pcmcia_driver ixj_driver = { .event = ixj_event, .detach = ixj_detach, .id_table = ixj_ids, + .suspend = ixj_suspend, + .resume = ixj_resume, }; static int __init ixj_pcmcia_init(void) diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 5056b74..cb8c2bd 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -323,6 +323,28 @@ cs_failed: } } +static int sl811_suspend(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int sl811_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); + + return 0; +} + static int sl811_cs_event(event_t event, int priority, event_callback_args_t *args) { @@ -341,23 +363,6 @@ sl811_cs_event(event_t event, int priority, event_callback_args_t *args) link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; sl811_cs_config(link); break; - - case CS_EVENT_PM_SUSPEND: - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - - case CS_EVENT_PM_RESUME: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) - pcmcia_request_configuration(link->handle, &link->conf); - DBG(0, "reset sl811-hcd here?\n"); - break; } return 0; } @@ -417,6 +422,8 @@ static struct pcmcia_driver sl811_cs_driver = { .event = sl811_cs_event, .detach = sl811_cs_detach, .id_table = sl811_ids, + .suspend = sl811_suspend, + .resume = sl811_resume, }; /*====================================================================*/ diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index cb8b6e6..0200551 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -137,6 +137,10 @@ struct pcmcia_driver { int (*event) (event_t event, int priority, event_callback_args_t *); void (*detach)(dev_link_t *); + + int (*suspend) (struct pcmcia_device *dev); + int (*resume) (struct pcmcia_device *dev); + struct module *owner; struct pcmcia_device_id *id_table; struct device_driver drv; @@ -193,6 +197,8 @@ struct pcmcia_device { #define handle_to_pdev(handle) (handle) #define handle_to_dev(handle) (handle->dev) +#define dev_to_instance(dev) (dev->instance) + /* error reporting */ void cs_error(client_handle_t handle, int func, int ret); -- cgit v1.1 From 8e9e793d68fcda6cc84c18cedf85ca0f91d801a8 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 6 Jan 2006 00:02:03 +0100 Subject: [PATCH] pcmcia: merge suspend into device model Merge the suspend and resume methods for 16-bit PCMCIA cards into the device model -- for both runtime power management and suspend to ram/disk. Bugfix in ds.c by Richard Purdie Signed-Off-By: Richard Purdie Signed-off-by: Dominik Brodowski --- drivers/base/power/runtime.c | 1 + drivers/pcmcia/cs.c | 14 ++++++- drivers/pcmcia/cs_internal.h | 2 + drivers/pcmcia/ds.c | 94 +++++++++++++++++++++++++++++++++++++++----- 4 files changed, 100 insertions(+), 11 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 4bafef8..96370ec 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -62,6 +62,7 @@ int dpm_runtime_suspend(struct device * dev, pm_message_t state) up(&dpm_sem); return error; } +EXPORT_SYMBOL(dpm_runtime_suspend); #if 0 diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 7cf0908..83d2753 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -780,8 +780,13 @@ int pccard_reset_card(struct pcmcia_socket *skt) ret = send_event(skt, CS_EVENT_RESET_REQUEST, CS_EVENT_PRI_LOW); if (ret == 0) { send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); - if (socket_reset(skt) == CS_SUCCESS) + if (skt->callback) + skt->callback->suspend(skt); + if (socket_reset(skt) == CS_SUCCESS) { send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); + if (skt->callback) + skt->callback->resume(skt); + } } ret = CS_SUCCESS; @@ -812,6 +817,11 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt) ret = CS_UNSUPPORTED_FUNCTION; break; } + if (skt->callback) { + ret = skt->callback->suspend(skt); + if (ret) + break; + } ret = socket_suspend(skt); } while (0); up(&skt->skt_sem); @@ -838,6 +848,8 @@ int pcmcia_resume_card(struct pcmcia_socket *skt) break; } ret = socket_resume(skt); + if (!ret && skt->callback) + skt->callback->resume(skt); } while (0); up(&skt->skt_sem); diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 634426b..7b37eba 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -143,6 +143,8 @@ struct pcmcia_callback{ struct module *owner; int (*event) (struct pcmcia_socket *s, event_t event, int priority); void (*requery) (struct pcmcia_socket *s); + int (*suspend) (struct pcmcia_socket *s); + int (*resume) (struct pcmcia_socket *s); }; int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index a802c65..5223395 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -920,6 +920,78 @@ static struct device_attribute pcmcia_dev_attrs[] = { __ATTR_NULL, }; +/* PM support, also needed for reset */ + +static int pcmcia_dev_suspend(struct device * dev, pm_message_t state) +{ + struct pcmcia_device *p_dev = to_pcmcia_dev(dev); + struct pcmcia_driver *p_drv = NULL; + + if (dev->driver) + p_drv = to_pcmcia_drv(dev->driver); + + if (p_drv && p_drv->suspend) + return p_drv->suspend(p_dev); + + return 0; +} + + +static int pcmcia_dev_resume(struct device * dev) +{ + struct pcmcia_device *p_dev = to_pcmcia_dev(dev); + struct pcmcia_driver *p_drv = NULL; + + if (dev->driver) + p_drv = to_pcmcia_drv(dev->driver); + + if (p_drv && p_drv->resume) + return p_drv->resume(p_dev); + + return 0; +} + + +static int pcmcia_bus_suspend_callback(struct device *dev, void * _data) +{ + struct pcmcia_socket *skt = _data; + struct pcmcia_device *p_dev = to_pcmcia_dev(dev); + + if (p_dev->socket != skt) + return 0; + + return dpm_runtime_suspend(dev, PMSG_SUSPEND); +} + +static int pcmcia_bus_resume_callback(struct device *dev, void * _data) +{ + struct pcmcia_socket *skt = _data; + struct pcmcia_device *p_dev = to_pcmcia_dev(dev); + + if (p_dev->socket != skt) + return 0; + + dpm_runtime_resume(dev); + + return 0; +} + +static int pcmcia_bus_resume(struct pcmcia_socket *skt) +{ + bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); + return 0; +} + +static int pcmcia_bus_suspend(struct pcmcia_socket *skt) +{ + if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, + pcmcia_bus_suspend_callback)) { + pcmcia_bus_resume(skt); + return -EIO; + } + return 0; +} + /*====================================================================== @@ -951,16 +1023,6 @@ static int send_event_callback(struct device *dev, void * _data) if (p_dev->state & (CLIENT_UNBOUND|CLIENT_STALE)) return 0; - if ((data->event == CS_EVENT_PM_SUSPEND) || - (data->event == CS_EVENT_RESET_PHYSICAL)) { - if (p_drv->suspend) - return p_drv->suspend(p_dev); - } else if ((data->event == CS_EVENT_PM_RESUME) || - (data->event == CS_EVENT_CARD_RESET)) { - if (p_drv->resume) - return p_drv->resume(p_dev); - } - if (p_drv->event) return p_drv->event(data->event, data->priority, &p_dev->event_callback_args); @@ -1012,6 +1074,13 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) ret = send_event(skt, event, priority); break; + case CS_EVENT_PM_SUSPEND: + case CS_EVENT_PM_RESUME: + case CS_EVENT_RESET_PHYSICAL: + case CS_EVENT_CARD_RESET: + handle_event(skt, event); + break; + default: handle_event(skt, event); send_event(skt, event, priority); @@ -1166,10 +1235,13 @@ int pcmcia_deregister_client(struct pcmcia_device *p_dev) } /* deregister_client */ EXPORT_SYMBOL(pcmcia_deregister_client); + static struct pcmcia_callback pcmcia_bus_callback = { .owner = THIS_MODULE, .event = ds_event, .requery = pcmcia_bus_rescan, + .suspend = pcmcia_bus_suspend, + .resume = pcmcia_bus_resume, }; static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev, @@ -1238,6 +1310,8 @@ struct bus_type pcmcia_bus_type = { .uevent = pcmcia_bus_uevent, .match = pcmcia_bus_match, .dev_attrs = pcmcia_dev_attrs, + .suspend = pcmcia_dev_suspend, + .resume = pcmcia_dev_resume, }; -- cgit v1.1 From cc3b4866bee996c922e875b8c8efe9f0d8803aae Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:23:14 +0100 Subject: [PATCH] pcmcia: unify detach, REMOVAL_EVENT handlers into one remove callback Unify the "detach" and REMOVAL_EVENT handlers to one "remove" function. Old functionality is preserved, for the moment. Signed-off-by: Dominik Brodowski --- Documentation/pcmcia/driver-changes.txt | 3 + drivers/bluetooth/bluecard_cs.c | 24 ++------ drivers/bluetooth/bt3c_cs.c | 24 ++------ drivers/bluetooth/btuart_cs.c | 24 ++------ drivers/bluetooth/dtl1_cs.c | 24 ++------ drivers/char/pcmcia/cm4000_cs.c | 55 ++++++------------- drivers/char/pcmcia/cm4040_cs.c | 52 ++++++------------ drivers/char/pcmcia/synclink_cs.c | 34 +++--------- drivers/ide/legacy/ide-cs.c | 21 ++----- drivers/isdn/hardware/avm/avm_cs.c | 34 +++--------- drivers/isdn/hisax/avma1_cs.c | 39 +++---------- drivers/isdn/hisax/elsa_cs.c | 26 +++------ drivers/isdn/hisax/sedlbauer_cs.c | 38 +++---------- drivers/isdn/hisax/teles_cs.c | 26 +++------ drivers/mtd/maps/pcmciamtd.c | 36 ++++-------- drivers/net/pcmcia/3c574_cs.c | 18 ++---- drivers/net/pcmcia/3c589_cs.c | 20 ++----- drivers/net/pcmcia/axnet_cs.c | 18 ++---- drivers/net/pcmcia/com20020_cs.c | 19 ++----- drivers/net/pcmcia/fmvj18x_cs.c | 19 ++----- drivers/net/pcmcia/ibmtr_cs.c | 23 ++------ drivers/net/pcmcia/nmclan_cs.c | 18 ++---- drivers/net/pcmcia/pcnet_cs.c | 48 +++++++--------- drivers/net/pcmcia/smc91c92_cs.c | 18 ++---- drivers/net/pcmcia/xirc2ps_cs.c | 28 ++-------- drivers/net/wireless/airo_cs.c | 31 +++-------- drivers/net/wireless/atmel_cs.c | 25 +++------ drivers/net/wireless/hostap/hostap_cs.c | 28 ++-------- drivers/net/wireless/netwave_cs.c | 31 +++-------- drivers/net/wireless/orinoco_cs.c | 30 ++-------- drivers/net/wireless/ray_cs.c | 43 ++++++--------- drivers/net/wireless/spectrum_cs.c | 37 ++----------- drivers/net/wireless/wavelan_cs.c | 31 ++--------- drivers/net/wireless/wavelan_cs.p.h | 2 +- drivers/net/wireless/wl3501_cs.c | 32 ++++------- drivers/parport/parport_cs.c | 26 +++------ drivers/pcmcia/ds.c | 97 +++++++++++++++++++++------------ drivers/scsi/pcmcia/aha152x_stub.c | 17 ++---- drivers/scsi/pcmcia/fdomain_stub.c | 17 ++---- drivers/scsi/pcmcia/nsp_cs.c | 23 ++------ drivers/scsi/pcmcia/nsp_cs.h | 2 +- drivers/scsi/pcmcia/qlogic_stub.c | 17 ++---- drivers/scsi/pcmcia/sym53c500_cs.c | 15 ++--- drivers/serial/serial_cs.c | 19 ++----- drivers/telephony/ixj_pcmcia.c | 24 +++----- drivers/usb/host/sl811_cs.c | 31 +++-------- include/pcmcia/ds.h | 2 + 47 files changed, 373 insertions(+), 896 deletions(-) diff --git a/Documentation/pcmcia/driver-changes.txt b/Documentation/pcmcia/driver-changes.txt index 5c822f5..45c25c7 100644 --- a/Documentation/pcmcia/driver-changes.txt +++ b/Documentation/pcmcia/driver-changes.txt @@ -1,5 +1,8 @@ This file details changes in 2.6 which affect PCMCIA card driver authors: +* Unify detach and REMOVAL event code (as of 2.6.16) + void (*remove) (struct pcmcia_device *dev); + * Move suspend, resume and reset out of event handler (as of 2.6.16) int (*suspend) (struct pcmcia_device *dev); int (*resume) (struct pcmcia_device *dev); diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 5b24131..f5088cb 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -92,7 +92,7 @@ static int bluecard_event(event_t event, int priority, event_callback_args_t *ar static dev_info_t dev_info = "bluecard_cs"; static dev_link_t *bluecard_attach(void); -static void bluecard_detach(dev_link_t *); +static void bluecard_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -899,7 +899,7 @@ static dev_link_t *bluecard_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - bluecard_detach(link); + bluecard_detach(link->handle); return NULL; } @@ -907,11 +907,11 @@ static dev_link_t *bluecard_attach(void) } -static void bluecard_detach(dev_link_t *link) +static void bluecard_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); bluecard_info_t *info = link->priv; dev_link_t **linkp; - int ret; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) @@ -924,12 +924,6 @@ static void bluecard_detach(dev_link_t *link) if (link->state & DEV_CONFIG) bluecard_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; @@ -1070,16 +1064,8 @@ static int bluecard_resume(struct pcmcia_device *dev) static int bluecard_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - bluecard_info_t *info = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - bluecard_close(info); - bluecard_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; bluecard_config(link); @@ -1104,7 +1090,7 @@ static struct pcmcia_driver bluecard_driver = { }, .attach = bluecard_attach, .event = bluecard_event, - .detach = bluecard_detach, + .remove = bluecard_detach, .id_table = bluecard_ids, .suspend = bluecard_suspend, .resume = bluecard_resume, diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 1d524ba..02ce38e 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -95,7 +95,7 @@ static int bt3c_event(event_t event, int priority, event_callback_args_t *args); static dev_info_t dev_info = "bt3c_cs"; static dev_link_t *bt3c_attach(void); -static void bt3c_detach(dev_link_t *); +static void bt3c_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -700,7 +700,7 @@ static dev_link_t *bt3c_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - bt3c_detach(link); + bt3c_detach(link->handle); return NULL; } @@ -708,11 +708,11 @@ static dev_link_t *bt3c_attach(void) } -static void bt3c_detach(dev_link_t *link) +static void bt3c_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); bt3c_info_t *info = link->priv; dev_link_t **linkp; - int ret; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) @@ -725,12 +725,6 @@ static void bt3c_detach(dev_link_t *link) if (link->state & DEV_CONFIG) bt3c_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; @@ -916,16 +910,8 @@ static int bt3c_resume(struct pcmcia_device *dev) static int bt3c_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - bt3c_info_t *info = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - bt3c_close(info); - bt3c_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; bt3c_config(link); @@ -948,7 +934,7 @@ static struct pcmcia_driver bt3c_driver = { }, .attach = bt3c_attach, .event = bt3c_event, - .detach = bt3c_detach, + .remove = bt3c_detach, .id_table = bt3c_ids, .suspend = bt3c_suspend, .resume = bt3c_resume, diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 1828ba6..63221d3 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -91,7 +91,7 @@ static int btuart_event(event_t event, int priority, event_callback_args_t *args static dev_info_t dev_info = "btuart_cs"; static dev_link_t *btuart_attach(void); -static void btuart_detach(dev_link_t *); +static void btuart_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -619,7 +619,7 @@ static dev_link_t *btuart_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - btuart_detach(link); + btuart_detach(link->handle); return NULL; } @@ -627,11 +627,11 @@ static dev_link_t *btuart_attach(void) } -static void btuart_detach(dev_link_t *link) +static void btuart_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); btuart_info_t *info = link->priv; dev_link_t **linkp; - int ret; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) @@ -644,12 +644,6 @@ static void btuart_detach(dev_link_t *link) if (link->state & DEV_CONFIG) btuart_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; @@ -837,16 +831,8 @@ static int btuart_resume(struct pcmcia_device *dev) static int btuart_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - btuart_info_t *info = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - btuart_close(info); - btuart_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; btuart_config(link); @@ -869,7 +855,7 @@ static struct pcmcia_driver btuart_driver = { }, .attach = btuart_attach, .event = btuart_event, - .detach = btuart_detach, + .remove = btuart_detach, .id_table = btuart_ids, .suspend = btuart_suspend, .resume = btuart_resume, diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 9f9d3f9..2874d87 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -94,7 +94,7 @@ static int dtl1_event(event_t event, int priority, event_callback_args_t *args); static dev_info_t dev_info = "dtl1_cs"; static dev_link_t *dtl1_attach(void); -static void dtl1_detach(dev_link_t *); +static void dtl1_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -598,7 +598,7 @@ static dev_link_t *dtl1_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - dtl1_detach(link); + dtl1_detach(link->handle); return NULL; } @@ -606,11 +606,11 @@ static dev_link_t *dtl1_attach(void) } -static void dtl1_detach(dev_link_t *link) +static void dtl1_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dtl1_info_t *info = link->priv; dev_link_t **linkp; - int ret; /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) @@ -623,12 +623,6 @@ static void dtl1_detach(dev_link_t *link) if (link->state & DEV_CONFIG) dtl1_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; @@ -788,16 +782,8 @@ static int dtl1_resume(struct pcmcia_device *dev) static int dtl1_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - dtl1_info_t *info = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - dtl1_close(info); - dtl1_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; dtl1_config(link); @@ -821,7 +807,7 @@ static struct pcmcia_driver dtl1_driver = { }, .attach = dtl1_attach, .event = dtl1_event, - .detach = dtl1_detach, + .remove = dtl1_detach, .id_table = dtl1_ids, .suspend = dtl1_suspend, .resume = dtl1_resume, diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 05e9305..8a064f2 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c @@ -66,7 +66,7 @@ static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte"; #define T_100MSEC msecs_to_jiffies(100) #define T_500MSEC msecs_to_jiffies(500) -static void cm4000_detach(dev_link_t *link); +static void cm4000_detach(struct pcmcia_device *p_dev); static void cm4000_release(dev_link_t *link); static int major; /* major number we get from the kernel */ @@ -1888,11 +1888,6 @@ static int cm4000_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; cm4000_config(link, devno); break; - case CS_EVENT_CARD_REMOVAL: - DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n"); - link->state &= ~DEV_PRESENT; - stop_monitor(dev); - break; default: DEBUGP(5, dev, "unknown event %.2x\n", event); break; @@ -1978,7 +1973,7 @@ static dev_link_t *cm4000_attach(void) i = pcmcia_register_client(&link->handle, &client_reg); if (i) { cs_error(link->handle, RegisterClient, i); - cm4000_detach(link); + cm4000_detach(link->handle); return NULL; } @@ -1990,39 +1985,28 @@ static dev_link_t *cm4000_attach(void) return link; } -static void cm4000_detach_by_devno(int devno, dev_link_t * link) +static void cm4000_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct cm4000_dev *dev = link->priv; + int devno; - DEBUGP(3, dev, "-> detach_by_devno(devno=%d)\n", devno); + /* find device */ + for (devno = 0; devno < CM4000_MAX_DEV; devno++) + if (dev_table[devno] == link) + break; + if (devno == CM4000_MAX_DEV) + return; - if (link->state & DEV_CONFIG) { - DEBUGP(5, dev, "device still configured (try to release it)\n"); - cm4000_release(link); - } + link->state &= ~DEV_PRESENT; + stop_monitor(dev); - if (link->handle) { - pcmcia_deregister_client(link->handle); - } + if (link->state & DEV_CONFIG) + cm4000_release(link); dev_table[devno] = NULL; - kfree(dev); - return; -} - -static void cm4000_detach(dev_link_t * link) -{ - int i; + kfree(dev); - /* find device */ - for (i = 0; i < CM4000_MAX_DEV; i++) - if (dev_table[i] == link) - break; - - if (i == CM4000_MAX_DEV) - return; - - cm4000_detach_by_devno(i, link); return; } @@ -2048,7 +2032,7 @@ static struct pcmcia_driver cm4000_driver = { .name = "cm4000_cs", }, .attach = cm4000_attach, - .detach = cm4000_detach, + .remove = cm4000_detach, .suspend = cm4000_suspend, .resume = cm4000_resume, .event = cm4000_event, @@ -2071,13 +2055,8 @@ static int __init cmm_init(void) static void __exit cmm_exit(void) { - int i; - printk(KERN_INFO MODULE_NAME ": unloading\n"); pcmcia_unregister_driver(&cm4000_driver); - for (i = 0; i < CM4000_MAX_DEV; i++) - if (dev_table[i]) - cm4000_detach_by_devno(i, dev_table[i]); unregister_chrdev(major, DEVICE_NAME); }; diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 3622fd3..e08ab94 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c @@ -65,7 +65,7 @@ static char *version = #define POLL_PERIOD msecs_to_jiffies(10) static void reader_release(dev_link_t *link); -static void reader_detach(dev_link_t *link); +static void reader_detach(struct pcmcia_device *p_dev); static int major; @@ -652,10 +652,6 @@ static int reader_event(event_t event, int priority, link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; reader_config(link, devno); break; - case CS_EVENT_CARD_REMOVAL: - DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n"); - link->state &= ~DEV_PRESENT; - break; default: DEBUGP(5, dev, "reader_event: unknown event %.2x\n", @@ -734,7 +730,7 @@ static dev_link_t *reader_attach(void) i = pcmcia_register_client(&link->handle, &client_reg); if (i) { cs_error(link->handle, RegisterClient, i); - reader_detach(link); + reader_detach(link->handle); return NULL; } init_waitqueue_head(&dev->devq); @@ -747,36 +743,28 @@ static dev_link_t *reader_attach(void) return link; } -static void reader_detach_by_devno(int devno, dev_link_t *link) +static void reader_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct reader_dev *dev = link->priv; - - if (link->state & DEV_CONFIG) { - DEBUGP(5, dev, "device still configured (try to release it)\n"); - reader_release(link); - } - - pcmcia_deregister_client(link->handle); - dev_table[devno] = NULL; - DEBUGP(5, dev, "freeing dev=%p\n", dev); - cm4040_stop_poll(dev); - kfree(dev); - return; -} - -static void reader_detach(dev_link_t *link) -{ - int i; + int devno; /* find device */ - for (i = 0; i < CM_MAX_DEV; i++) { - if (dev_table[i] == link) + for (devno = 0; devno < CM_MAX_DEV; devno++) { + if (dev_table[devno] == link) break; } - if (i == CM_MAX_DEV) + if (devno == CM_MAX_DEV) return; - reader_detach_by_devno(i, link); + link->state &= ~DEV_PRESENT; + + if (link->state & DEV_CONFIG) + reader_release(link); + + dev_table[devno] = NULL; + kfree(dev); + return; } @@ -803,7 +791,7 @@ static struct pcmcia_driver reader_driver = { .name = "cm4040_cs", }, .attach = reader_attach, - .detach = reader_detach, + .remove = reader_detach, .suspend = reader_suspend, .resume = reader_resume, .event = reader_event, @@ -825,14 +813,8 @@ static int __init cm4040_init(void) static void __exit cm4040_exit(void) { - int i; - printk(KERN_INFO MODULE_NAME ": unloading\n"); pcmcia_unregister_driver(&reader_driver); - for (i = 0; i < CM_MAX_DEV; i++) { - if (dev_table[i]) - reader_detach_by_devno(i, dev_table[i]); - } unregister_chrdev(major, DEVICE_NAME); } diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 776103e..3459714 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -489,7 +489,7 @@ static void mgslpc_release(u_long arg); static int mgslpc_event(event_t event, int priority, event_callback_args_t *args); static dev_link_t *mgslpc_attach(void); -static void mgslpc_detach(dev_link_t *); +static void mgslpc_detach(struct pcmcia_device *p_dev); static dev_info_t dev_info = "synclink_cs"; static dev_link_t *dev_list = NULL; @@ -598,7 +598,7 @@ static dev_link_t *mgslpc_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - mgslpc_detach(link); + mgslpc_detach(link->handle); return NULL; } @@ -736,17 +736,16 @@ static void mgslpc_release(u_long arg) pcmcia_release_io(link->handle, &link->io); if (link->irq.AssignedIRQ) pcmcia_release_irq(link->handle, &link->irq); - if (link->state & DEV_STALE_LINK) - mgslpc_detach(link); } -static void mgslpc_detach(dev_link_t *link) +static void mgslpc_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; if (debug_level >= DEBUG_LEVEL_INFO) printk("mgslpc_detach(0x%p)\n", link); - + /* find device */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) if (*linkp == link) break; @@ -754,20 +753,10 @@ static void mgslpc_detach(dev_link_t *link) return; if (link->state & DEV_CONFIG) { - /* device is configured/active, mark it so when - * release() is called a proper detach() occurs. - */ - if (debug_level >= DEBUG_LEVEL_INFO) - printk(KERN_DEBUG "synclinkpc: detach postponed, '%s' " - "still locked\n", link->dev->dev_name); - link->state |= DEV_STALE_LINK; - return; + ((MGSLPC_INFO *)link->priv)->stop = 1; + mgslpc_release((u_long)link); } - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, and free it */ *linkp = link->next; mgslpc_remove_device((MGSLPC_INFO *)link->priv); @@ -809,13 +798,6 @@ static int mgslpc_event(event_t event, int priority, printk("mgslpc_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((MGSLPC_INFO *)link->priv)->stop = 1; - mgslpc_release((u_long)link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; mgslpc_config(link); @@ -3102,7 +3084,7 @@ static struct pcmcia_driver mgslpc_driver = { }, .attach = mgslpc_attach, .event = mgslpc_event, - .detach = mgslpc_detach, + .remove = mgslpc_detach, .id_table = mgslpc_ids, .suspend = mgslpc_suspend, .resume = mgslpc_resume, diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 982b74a..1fb8976 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -94,7 +94,7 @@ static int ide_event(event_t event, int priority, static dev_info_t dev_info = "ide-cs"; static dev_link_t *ide_attach(void); -static void ide_detach(dev_link_t *); +static void ide_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -138,7 +138,7 @@ static dev_link_t *ide_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - ide_detach(link); + ide_detach(link->handle); return NULL; } @@ -154,10 +154,10 @@ static dev_link_t *ide_attach(void) ======================================================================*/ -static void ide_detach(dev_link_t *link) +static void ide_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; - int ret; DEBUG(0, "ide_detach(0x%p)\n", link); @@ -170,12 +170,6 @@ static void ide_detach(dev_link_t *link) if (link->state & DEV_CONFIG) ide_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink, free device structure */ *linkp = link->next; kfree(link->priv); @@ -445,11 +439,6 @@ int ide_event(event_t event, int priority, DEBUG(1, "ide_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - ide_release(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; ide_config(link); @@ -504,7 +493,7 @@ static struct pcmcia_driver ide_cs_driver = { }, .attach = ide_attach, .event = ide_event, - .detach = ide_detach, + .remove = ide_detach, .id_table = ide_ids, .suspend = ide_suspend, .resume = ide_resume, diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index 6d9816e..2d898d3 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c @@ -63,7 +63,7 @@ static int avmcs_event(event_t event, int priority, */ static dev_link_t *avmcs_attach(void); -static void avmcs_detach(dev_link_t *); +static void avmcs_detach(struct pcmcia_device *p_dev); /* The dev_info variable is the "key" that is used to match up this @@ -165,7 +165,7 @@ static dev_link_t *avmcs_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - avmcs_detach(link); + avmcs_detach(link->handle); goto err; } return link; @@ -185,8 +185,9 @@ static dev_link_t *avmcs_attach(void) ======================================================================*/ -static void avmcs_detach(dev_link_t *link) +static void avmcs_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; /* Locate device structure */ @@ -195,21 +196,9 @@ static void avmcs_detach(dev_link_t *link) if (*linkp == NULL) return; - /* - If the device is currently configured and active, we won't - actually delete it yet. Instead, it is marked so that when - the release() function is called, that will trigger a proper - detach(). - */ - if (link->state & DEV_CONFIG) { - link->state |= DEV_STALE_LINK; - return; - } + if (link->state & DEV_CONFIG) + avmcs_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free pieces */ *linkp = link->next; kfree(link->priv); @@ -424,10 +413,6 @@ static void avmcs_release(dev_link_t *link) pcmcia_release_io(link->handle, &link->io); pcmcia_release_irq(link->handle, &link->irq); link->state &= ~DEV_CONFIG; - - if (link->state & DEV_STALE_LINK) - avmcs_detach(link); - } /* avmcs_release */ static int avmcs_suspend(struct pcmcia_device *dev) @@ -472,11 +457,6 @@ static int avmcs_event(event_t event, int priority, dev_link_t *link = args->client_data; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - avmcs_release(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; avmcs_config(link); @@ -500,7 +480,7 @@ static struct pcmcia_driver avmcs_driver = { }, .attach = avmcs_attach, .event = avmcs_event, - .detach = avmcs_detach, + .remove = avmcs_detach, .id_table = avmcs_ids, .suspend= avmcs_suspend, .resume = avmcs_resume, diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 433cec4..6b322e8 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c @@ -79,7 +79,7 @@ static int avma1cs_event(event_t event, int priority, */ static dev_link_t *avma1cs_attach(void); -static void avma1cs_detach(dev_link_t *); +static void avma1cs_detach(struct pcmcia_device *p_dev); /* The dev_info variable is the "key" that is used to match up this @@ -187,7 +187,7 @@ static dev_link_t *avma1cs_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - avma1cs_detach(link); + avma1cs_detach(link->handle); return NULL; } @@ -203,42 +203,26 @@ static dev_link_t *avma1cs_attach(void) ======================================================================*/ -static void avma1cs_detach(dev_link_t *link) +static void avma1cs_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "avma1cs_detach(0x%p)\n", link); - + /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) if (*linkp == link) break; if (*linkp == NULL) return; - /* - If the device is currently configured and active, we won't - actually delete it yet. Instead, it is marked so that when - the release() function is called, that will trigger a proper - detach(). - */ - if (link->state & DEV_CONFIG) { -#ifdef PCMCIA_DEBUG - printk(KERN_DEBUG "avma1_cs: detach postponed, '%s' " - "still locked\n", link->dev->dev_name); -#endif - link->state |= DEV_STALE_LINK; - return; - } + if (link->state & DEV_CONFIG) + avma1cs_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free pieces */ *linkp = link->next; kfree(link->priv); kfree(link); - } /* avma1cs_detach */ /*====================================================================== @@ -440,9 +424,6 @@ static void avma1cs_release(dev_link_t *link) pcmcia_release_io(link->handle, &link->io); pcmcia_release_irq(link->handle, &link->irq); link->state &= ~DEV_CONFIG; - - if (link->state & DEV_STALE_LINK) - avma1cs_detach(link); } /* avma1cs_release */ static int avma1cs_suspend(struct pcmcia_device *dev) @@ -489,10 +470,6 @@ static int avma1cs_event(event_t event, int priority, DEBUG(1, "avma1cs_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - if (link->state & DEV_CONFIG) - avma1cs_release(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; avma1cs_config(link); @@ -515,7 +492,7 @@ static struct pcmcia_driver avma1cs_driver = { }, .attach = avma1cs_attach, .event = avma1cs_event, - .detach = avma1cs_detach, + .remove = avma1cs_detach, .id_table = avma1cs_ids, .suspend = avma1cs_suspend, .resume = avma1cs_resume, diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index 0cbe045..48cc677 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c @@ -106,7 +106,7 @@ static int elsa_cs_event(event_t event, int priority, */ static dev_link_t *elsa_cs_attach(void); -static void elsa_cs_detach(dev_link_t *); +static void elsa_cs_detach(struct pcmcia_device *p_dev); /* The dev_info variable is the "key" that is used to match up this @@ -216,7 +216,7 @@ static dev_link_t *elsa_cs_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - elsa_cs_detach(link); + elsa_cs_detach(link->handle); return NULL; } @@ -232,11 +232,11 @@ static dev_link_t *elsa_cs_attach(void) ======================================================================*/ -static void elsa_cs_detach(dev_link_t *link) +static void elsa_cs_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; local_info_t *info = link->priv; - int ret; DEBUG(0, "elsa_cs_detach(0x%p)\n", link); @@ -246,14 +246,9 @@ static void elsa_cs_detach(dev_link_t *link) if (*linkp == NULL) return; - if (link->state & DEV_CONFIG) + if (link->state & DEV_CONFIG) { + ((local_info_t*)link->priv)->busy = 1; elsa_cs_release(link); - - /* Break the link with Card Services */ - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); } /* Unlink device structure and free it */ @@ -495,13 +490,6 @@ static int elsa_cs_event(event_t event, int priority, DEBUG(1, "elsa_cs_event(%d)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((local_info_t*)link->priv)->busy = 1; - elsa_cs_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; elsa_cs_config(link); @@ -524,7 +512,7 @@ static struct pcmcia_driver elsa_cs_driver = { }, .attach = elsa_cs_attach, .event = elsa_cs_event, - .detach = elsa_cs_detach, + .remove = elsa_cs_detach, .id_table = elsa_ids, .suspend = elsa_suspend, .resume = elsa_resume, diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 27dce7c..d2386f6 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c @@ -107,7 +107,7 @@ static int sedlbauer_event(event_t event, int priority, */ static dev_link_t *sedlbauer_attach(void); -static void sedlbauer_detach(dev_link_t *); +static void sedlbauer_detach(struct pcmcia_device *p_dev); /* You'll also need to prototype all the functions that will actually @@ -230,7 +230,7 @@ static dev_link_t *sedlbauer_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - sedlbauer_detach(link); + sedlbauer_detach(link->handle); return NULL; } @@ -246,8 +246,9 @@ static dev_link_t *sedlbauer_attach(void) ======================================================================*/ -static void sedlbauer_detach(dev_link_t *link) +static void sedlbauer_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "sedlbauer_detach(0x%p)\n", link); @@ -258,25 +259,11 @@ static void sedlbauer_detach(dev_link_t *link) if (*linkp == NULL) return; - /* - If the device is currently configured and active, we won't - actually delete it yet. Instead, it is marked so that when - the release() function is called, that will trigger a proper - detach(). - */ if (link->state & DEV_CONFIG) { -#ifdef PCMCIA_DEBUG - printk(KERN_DEBUG "sedlbauer_cs: detach postponed, '%s' " - "still locked\n", link->dev->dev_name); -#endif - link->state |= DEV_STALE_LINK; - return; + ((local_info_t *)link->priv)->stop = 1; + sedlbauer_release(link); } - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, and free it */ *linkp = link->next; /* This points to the parent local_info_t struct */ @@ -547,10 +534,6 @@ static void sedlbauer_release(dev_link_t *link) if (link->irq.AssignedIRQ) pcmcia_release_irq(link->handle, &link->irq); link->state &= ~DEV_CONFIG; - - if (link->state & DEV_STALE_LINK) - sedlbauer_detach(link); - } /* sedlbauer_release */ static int sedlbauer_suspend(struct pcmcia_device *p_dev) @@ -599,13 +582,6 @@ static int sedlbauer_event(event_t event, int priority, DEBUG(1, "sedlbauer_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((local_info_t *)link->priv)->stop = 1; - sedlbauer_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; sedlbauer_config(link); @@ -633,7 +609,7 @@ static struct pcmcia_driver sedlbauer_driver = { }, .attach = sedlbauer_attach, .event = sedlbauer_event, - .detach = sedlbauer_detach, + .remove = sedlbauer_detach, .id_table = sedlbauer_ids, .suspend = sedlbauer_suspend, .resume = sedlbauer_resume, diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index 70213bc..cd0f86f 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c @@ -87,7 +87,7 @@ static int teles_cs_event(event_t event, int priority, */ static dev_link_t *teles_attach(void); -static void teles_detach(dev_link_t *); +static void teles_detach(struct pcmcia_device *p_dev); /* The dev_info variable is the "key" that is used to match up this @@ -197,7 +197,7 @@ static dev_link_t *teles_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - teles_detach(link); + teles_detach(link->handle); return NULL; } @@ -213,11 +213,11 @@ static dev_link_t *teles_attach(void) ======================================================================*/ -static void teles_detach(dev_link_t *link) +static void teles_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; local_info_t *info = link->priv; - int ret; DEBUG(0, "teles_detach(0x%p)\n", link); @@ -227,14 +227,9 @@ static void teles_detach(dev_link_t *link) if (*linkp == NULL) return; - if (link->state & DEV_CONFIG) + if (link->state & DEV_CONFIG) { + info->busy = 1; teles_cs_release(link); - - /* Break the link with Card Services */ - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); } /* Unlink device structure and free it */ @@ -476,13 +471,6 @@ static int teles_cs_event(event_t event, int priority, DEBUG(1, "teles_cs_event(%d)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((local_info_t*)link->priv)->busy = 1; - teles_cs_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; teles_cs_config(link); @@ -504,7 +492,7 @@ static struct pcmcia_driver teles_cs_driver = { }, .attach = teles_attach, .event = teles_cs_event, - .detach = teles_detach, + .remove = teles_detach, .id_table = teles_ids, .suspend = teles_suspend, .resume = teles_resume, diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 86443cf..3ddcb1b 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c @@ -722,18 +722,6 @@ static int pcmciamtd_event(event_t event, int priority, DEBUG(1, "event=0x%06x", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - DEBUG(2, "EVENT_CARD_REMOVAL"); - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - struct pcmciamtd_dev *dev = link->priv; - if(dev->mtd_info) { - del_mtd_device(dev->mtd_info); - info("mtd%d: Removed", dev->mtd_info->index); - } - pcmciamtd_release(link); - } - break; case CS_EVENT_CARD_INSERTION: DEBUG(2, "EVENT_CARD_INSERTION"); link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; @@ -752,23 +740,21 @@ static int pcmciamtd_event(event_t event, int priority, * when the device is released. */ -static void pcmciamtd_detach(dev_link_t *link) +static void pcmciamtd_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); + DEBUG(3, "link=0x%p", link); if(link->state & DEV_CONFIG) { - pcmciamtd_release(link); - } + struct pcmciamtd_dev *dev = link->priv; + if(dev->mtd_info) { + del_mtd_device(dev->mtd_info); + info("mtd%d: Removed", dev->mtd_info->index); + } - if (link->handle) { - int ret; - DEBUG(2, "Deregistering with card services"); - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); + pcmciamtd_release(link); } - - link->state |= DEV_STALE_LINK; } @@ -807,7 +793,7 @@ static dev_link_t *pcmciamtd_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - pcmciamtd_detach(link); + pcmciamtd_detach(link->handle); return NULL; } DEBUG(2, "link = %p", link); @@ -847,7 +833,7 @@ static struct pcmcia_driver pcmciamtd_driver = { }, .attach = pcmciamtd_attach, .event = pcmciamtd_event, - .detach = pcmciamtd_detach, + .remove = pcmciamtd_detach, .owner = THIS_MODULE, .id_table = pcmciamtd_ids, .suspend = pcmciamtd_suspend, diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 80414a7..60a3bc2 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c @@ -253,7 +253,7 @@ static void set_rx_mode(struct net_device *dev); static dev_info_t dev_info = "3c574_cs"; static dev_link_t *tc574_attach(void); -static void tc574_detach(dev_link_t *); +static void tc574_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list; @@ -316,7 +316,7 @@ static dev_link_t *tc574_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - tc574_detach(link); + tc574_detach(link->handle); return NULL; } @@ -332,8 +332,9 @@ static dev_link_t *tc574_attach(void) */ -static void tc574_detach(dev_link_t *link) +static void tc574_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -351,9 +352,6 @@ static void tc574_detach(dev_link_t *link) if (link->state & DEV_CONFIG) tc574_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ *linkp = link->next; free_netdev(dev); @@ -590,16 +588,10 @@ static int tc574_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(1, "3c574_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; tc574_config(link); @@ -1304,7 +1296,7 @@ static struct pcmcia_driver tc574_driver = { }, .attach = tc574_attach, .event = tc574_event, - .detach = tc574_detach, + .remove = tc574_detach, .id_table = tc574_ids, .suspend = tc574_suspend, .resume = tc574_resume, diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index bbda681..09b96c7 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c @@ -164,7 +164,7 @@ static struct ethtool_ops netdev_ethtool_ops; static dev_info_t dev_info = "3c589_cs"; static dev_link_t *tc589_attach(void); -static void tc589_detach(dev_link_t *); +static void tc589_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list; @@ -230,7 +230,7 @@ static dev_link_t *tc589_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - tc589_detach(link); + tc589_detach(link->handle); return NULL; } @@ -246,8 +246,9 @@ static dev_link_t *tc589_attach(void) ======================================================================*/ -static void tc589_detach(dev_link_t *link) +static void tc589_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -264,10 +265,7 @@ static void tc589_detach(dev_link_t *link) if (link->state & DEV_CONFIG) tc589_release(link); - - if (link->handle) - pcmcia_deregister_client(link->handle); - + /* Unlink device structure, free bits */ *linkp = link->next; free_netdev(dev); @@ -466,16 +464,10 @@ static int tc589_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(1, "3c589_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; tc589_config(link); @@ -1079,7 +1071,7 @@ static struct pcmcia_driver tc589_driver = { }, .attach = tc589_attach, .event = tc589_event, - .detach = tc589_detach, + .remove = tc589_detach, .id_table = tc589_ids, .suspend = tc589_suspend, .resume = tc589_resume, diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 6c6b252..11f701a 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -108,7 +108,7 @@ static void block_output(struct net_device *dev, int count, const u_char *buf, const int start_page); static dev_link_t *axnet_attach(void); -static void axnet_detach(dev_link_t *); +static void axnet_detach(struct pcmcia_device *p_dev); static dev_info_t dev_info = "axnet_cs"; static dev_link_t *dev_list; @@ -185,7 +185,7 @@ static dev_link_t *axnet_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - axnet_detach(link); + axnet_detach(link->handle); return NULL; } @@ -201,8 +201,9 @@ static dev_link_t *axnet_attach(void) ======================================================================*/ -static void axnet_detach(dev_link_t *link) +static void axnet_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -220,9 +221,6 @@ static void axnet_detach(dev_link_t *link) if (link->state & DEV_CONFIG) axnet_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ *linkp = link->next; free_netdev(dev); @@ -537,16 +535,10 @@ static int axnet_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(2, "axnet_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; axnet_config(link); @@ -890,7 +882,7 @@ static struct pcmcia_driver axnet_cs_driver = { }, .attach = axnet_attach, .event = axnet_event, - .detach = axnet_detach, + .remove = axnet_detach, .id_table = axnet_ids, .suspend = axnet_suspend, .resume = axnet_resume, diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index 6861222..6970888 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c @@ -126,7 +126,7 @@ static int com20020_event(event_t event, int priority, static dev_info_t dev_info = "com20020_cs"; static dev_link_t *com20020_attach(void); -static void com20020_detach(dev_link_t *); +static void com20020_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list; @@ -204,7 +204,7 @@ static dev_link_t *com20020_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - com20020_detach(link); + com20020_detach(link->handle); return NULL; } @@ -226,8 +226,9 @@ fail_alloc_info: ======================================================================*/ -static void com20020_detach(dev_link_t *link) +static void com20020_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct com20020_dev_t *info = link->priv; dev_link_t **linkp; struct net_device *dev; @@ -260,9 +261,6 @@ static void com20020_detach(dev_link_t *link) if (link->state & DEV_CONFIG) com20020_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ DEBUG(1,"unlinking...\n"); *linkp = link->next; @@ -470,17 +468,10 @@ static int com20020_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - com20020_dev_t *info = link->priv; - struct net_device *dev = info->dev; DEBUG(1, "com20020_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT; com20020_config(link); @@ -502,7 +493,7 @@ static struct pcmcia_driver com20020_cs_driver = { }, .attach = com20020_attach, .event = com20020_event, - .detach = com20020_detach, + .remove = com20020_detach, .id_table = com20020_ids, .suspend = com20020_suspend, .resume = com20020_resume, diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 388ecad..560d4ee 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -91,7 +91,7 @@ static void fmvj18x_release(dev_link_t *link); static int fmvj18x_event(event_t event, int priority, event_callback_args_t *args); static dev_link_t *fmvj18x_attach(void); -static void fmvj18x_detach(dev_link_t *); +static void fmvj18x_detach(struct pcmcia_device *p_dev); /* LAN controller(MBH86960A) specific routines @@ -291,7 +291,7 @@ static dev_link_t *fmvj18x_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - fmvj18x_detach(link); + fmvj18x_detach(link->handle); return NULL; } @@ -300,8 +300,9 @@ static dev_link_t *fmvj18x_attach(void) /*====================================================================*/ -static void fmvj18x_detach(dev_link_t *link) +static void fmvj18x_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -319,10 +320,6 @@ static void fmvj18x_detach(dev_link_t *link) if (link->state & DEV_CONFIG) fmvj18x_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free pieces */ *linkp = link->next; free_netdev(dev); @@ -752,16 +749,10 @@ static int fmvj18x_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(1, "fmvj18x_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; fmvj18x_config(link); @@ -802,7 +793,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = { }, .attach = fmvj18x_attach, .event = fmvj18x_event, - .detach = fmvj18x_detach, + .remove = fmvj18x_detach, .id_table = fmvj18x_ids, .suspend = fmvj18x_suspend, .resume = fmvj18x_resume, diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index 3a7218e..9612949 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -114,7 +114,7 @@ static int ibmtr_event(event_t event, int priority, static dev_info_t dev_info = "ibmtr_cs"; static dev_link_t *ibmtr_attach(void); -static void ibmtr_detach(dev_link_t *); +static void ibmtr_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list; @@ -201,7 +201,7 @@ out: return link; out_detach: - ibmtr_detach(link); + ibmtr_detach(link->handle); link = NULL; goto out; } /* ibmtr_attach */ @@ -215,8 +215,9 @@ out_detach: ======================================================================*/ -static void ibmtr_detach(dev_link_t *link) +static void ibmtr_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct ibmtr_dev_t *info = link->priv; dev_link_t **linkp; struct net_device *dev; @@ -241,9 +242,6 @@ static void ibmtr_detach(dev_link_t *link) if (link->state & DEV_CONFIG) ibmtr_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ *linkp = link->next; free_netdev(dev); @@ -449,21 +447,10 @@ static int ibmtr_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - ibmtr_dev_t *info = link->priv; - struct net_device *dev = info->dev; DEBUG(1, "ibmtr_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - /* set flag to bypass normal interrupt code */ - struct tok_info *priv = netdev_priv(dev); - priv->sram_phys |= 1; - netif_device_detach(dev); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT; ibmtr_config(link); @@ -529,7 +516,7 @@ static struct pcmcia_driver ibmtr_cs_driver = { }, .attach = ibmtr_attach, .event = ibmtr_event, - .detach = ibmtr_detach, + .remove = ibmtr_detach, .id_table = ibmtr_ids, .suspend = ibmtr_suspend, .resume = ibmtr_resume, diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index fa4921f..011ceb0 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c @@ -440,7 +440,7 @@ static struct ethtool_ops netdev_ethtool_ops; static dev_link_t *nmclan_attach(void); -static void nmclan_detach(dev_link_t *); +static void nmclan_detach(struct pcmcia_device *p_dev); /* ---------------------------------------------------------------------------- nmclan_attach @@ -506,7 +506,7 @@ static dev_link_t *nmclan_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - nmclan_detach(link); + nmclan_detach(link->handle); return NULL; } @@ -521,8 +521,9 @@ nmclan_detach when the device is released. ---------------------------------------------------------------------------- */ -static void nmclan_detach(dev_link_t *link) +static void nmclan_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -540,9 +541,6 @@ static void nmclan_detach(dev_link_t *link) if (link->state & DEV_CONFIG) nmclan_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ *linkp = link->next; free_netdev(dev); @@ -845,16 +843,10 @@ static int nmclan_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(1, "nmclan_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; nmclan_config(link); @@ -1694,7 +1686,7 @@ static struct pcmcia_driver nmclan_cs_driver = { }, .attach = nmclan_attach, .event = nmclan_event, - .detach = nmclan_detach, + .remove = nmclan_detach, .id_table = nmclan_ids, .suspend = nmclan_suspend, .resume = nmclan_resume, diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 7db4d6f..fb3e411 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -121,7 +121,7 @@ static int setup_dma_config(dev_link_t *link, int start_pg, int stop_pg); static dev_link_t *pcnet_attach(void); -static void pcnet_detach(dev_link_t *); +static void pcnet_detach(struct pcmcia_device *p_dev); static dev_info_t dev_info = "pcnet_cs"; static dev_link_t *dev_list; @@ -280,7 +280,7 @@ static dev_link_t *pcnet_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - pcnet_detach(link); + pcnet_detach(link->handle); return NULL; } @@ -296,31 +296,29 @@ static dev_link_t *pcnet_attach(void) ======================================================================*/ -static void pcnet_detach(dev_link_t *link) +static void pcnet_detach(struct pcmcia_device *p_dev) { - struct net_device *dev = link->priv; - dev_link_t **linkp; - - DEBUG(0, "pcnet_detach(0x%p)\n", link); + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; + dev_link_t **linkp; - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; + DEBUG(0, "pcnet_detach(0x%p)\n", link); - if (link->dev) - unregister_netdev(dev); + /* Locate device structure */ + for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) + if (*linkp == link) break; + if (*linkp == NULL) + return; - if (link->state & DEV_CONFIG) - pcnet_release(link); + if (link->dev) + unregister_netdev(dev); - if (link->handle) - pcmcia_deregister_client(link->handle); + if (link->state & DEV_CONFIG) + pcnet_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; - free_netdev(dev); + /* Unlink device structure, free bits */ + *linkp = link->next; + free_netdev(dev); } /* pcnet_detach */ /*====================================================================== @@ -817,16 +815,10 @@ static int pcnet_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(2, "pcnet_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; pcnet_config(link); @@ -1856,7 +1848,7 @@ static struct pcmcia_driver pcnet_driver = { }, .attach = pcnet_attach, .event = pcnet_event, - .detach = pcnet_detach, + .remove = pcnet_detach, .owner = THIS_MODULE, .id_table = pcnet_ids, .suspend = pcnet_suspend, diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 7c61ec9..6cb5198 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -282,7 +282,7 @@ enum RxCfg { RxAllMulti = 0x0004, RxPromisc = 0x0002, /*====================================================================*/ static dev_link_t *smc91c92_attach(void); -static void smc91c92_detach(dev_link_t *); +static void smc91c92_detach(struct pcmcia_device *p_dev); static void smc91c92_config(dev_link_t *link); static void smc91c92_release(dev_link_t *link); static int smc91c92_event(event_t event, int priority, @@ -375,7 +375,7 @@ static dev_link_t *smc91c92_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - smc91c92_detach(link); + smc91c92_detach(link->handle); return NULL; } @@ -391,8 +391,9 @@ static dev_link_t *smc91c92_attach(void) ======================================================================*/ -static void smc91c92_detach(dev_link_t *link) +static void smc91c92_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -410,9 +411,6 @@ static void smc91c92_detach(dev_link_t *link) if (link->state & DEV_CONFIG) smc91c92_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ *linkp = link->next; free_netdev(dev); @@ -1237,16 +1235,10 @@ static int smc91c92_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(1, "smc91c92_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; smc91c92_config(link); @@ -2371,7 +2363,7 @@ static struct pcmcia_driver smc91c92_cs_driver = { }, .attach = smc91c92_attach, .event = smc91c92_event, - .detach = smc91c92_detach, + .remove = smc91c92_detach, .id_table = smc91c92_ids, .suspend = smc91c92_suspend, .resume = smc91c92_resume, diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index 917e50a..804e567 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -302,7 +302,7 @@ static int xirc2ps_event(event_t event, int priority, */ static dev_link_t *xirc2ps_attach(void); -static void xirc2ps_detach(dev_link_t *); +static void xirc2ps_detach(struct pcmcia_device *p_dev); /**************** * You'll also need to prototype all the functions that will actually @@ -622,7 +622,7 @@ xirc2ps_attach(void) client_reg.event_callback_args.client_data = link; if ((err = pcmcia_register_client(&link->handle, &client_reg))) { cs_error(link->handle, RegisterClient, err); - xirc2ps_detach(link); + xirc2ps_detach(link->handle); return NULL; } @@ -637,8 +637,9 @@ xirc2ps_attach(void) */ static void -xirc2ps_detach(dev_link_t * link) +xirc2ps_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -656,19 +657,9 @@ xirc2ps_detach(dev_link_t * link) if (link->dev) unregister_netdev(dev); - /* - * If the device is currently configured and active, we won't - * actually delete it yet. Instead, it is marked so that when - * the release() function is called, that will trigger a proper - * detach(). - */ if (link->state & DEV_CONFIG) xirc2ps_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free it */ *linkp = link->next; free_netdev(dev); @@ -1209,19 +1200,10 @@ xirc2ps_event(event_t event, int priority, event_callback_args_t * args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; DEBUG(0, "event(%d)\n", (int)event); switch (event) { - case CS_EVENT_REGISTRATION_COMPLETE: - DEBUG(0, "registration complete\n"); - break; - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - netif_device_detach(dev); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; xirc2ps_config(link); @@ -2022,7 +2004,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = { }, .attach = xirc2ps_attach, .event = xirc2ps_event, - .detach = xirc2ps_detach, + .remove = xirc2ps_detach, .id_table = xirc2ps_ids, .suspend = xirc2ps_suspend, .resume = xirc2ps_resume, diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index 80c9de7..7a28139 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -92,7 +92,7 @@ static int airo_event(event_t event, int priority, */ static dev_link_t *airo_attach(void); -static void airo_detach(dev_link_t *); +static void airo_detach(struct pcmcia_device *p_dev); /* You'll also need to prototype all the functions that will actually @@ -210,7 +210,7 @@ static dev_link_t *airo_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - airo_detach(link); + airo_detach(link->handle); return NULL; } @@ -226,8 +226,9 @@ static dev_link_t *airo_attach(void) ======================================================================*/ -static void airo_detach(dev_link_t *link) +static void airo_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "airo_detach(0x%p)\n", link); @@ -244,14 +245,8 @@ static void airo_detach(dev_link_t *link) if ( ((local_info_t*)link->priv)->eth_dev ) { stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); } - ((local_info_t*)link->priv)->eth_dev = NULL; - - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - - - + ((local_info_t*)link->priv)->eth_dev = NULL; + /* Unlink device structure, free pieces */ *linkp = link->next; kfree(link->priv); @@ -537,18 +532,10 @@ static int airo_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - local_info_t *local = link->priv; - + DEBUG(1, "airo_event(0x%06x)\n", event); - + switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - netif_device_detach(local->eth_dev); - airo_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; airo_config(link); @@ -573,7 +560,7 @@ static struct pcmcia_driver airo_driver = { }, .attach = airo_attach, .event = airo_event, - .detach = airo_detach, + .remove = airo_detach, .id_table = airo_ids, .suspend = airo_suspend, .resume = airo_resume, diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index 598a9cd..3ab33dd 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -103,7 +103,7 @@ static int atmel_event(event_t event, int priority, */ static dev_link_t *atmel_attach(void); -static void atmel_detach(dev_link_t *); +static void atmel_detach(struct pcmcia_device *p_dev); /* You'll also need to prototype all the functions that will actually @@ -221,7 +221,7 @@ static dev_link_t *atmel_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - atmel_detach(link); + atmel_detach(link->handle); return NULL; } @@ -237,8 +237,9 @@ static dev_link_t *atmel_attach(void) ======================================================================*/ -static void atmel_detach(dev_link_t *link) +static void atmel_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "atmel_detach(0x%p)\n", link); @@ -252,10 +253,6 @@ static void atmel_detach(dev_link_t *link) if (link->state & DEV_CONFIG) atmel_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free pieces */ *linkp = link->next; kfree(link->priv); @@ -522,18 +519,10 @@ static int atmel_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - local_info_t *local = link->priv; - + DEBUG(1, "atmel_event(0x%06x)\n", event); - + switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - netif_device_detach(local->eth_dev); - atmel_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; atmel_config(link); @@ -593,7 +582,7 @@ static struct pcmcia_driver atmel_driver = { }, .attach = atmel_attach, .event = atmel_event, - .detach = atmel_detach, + .remove = atmel_detach, .id_table = atmel_ids, .suspend = atmel_suspend, .resume = atmel_resume, diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index ba4a7da..866142a 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -203,7 +203,7 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len) -static void prism2_detach(dev_link_t *link); +static void prism2_detach(struct pcmcia_device *p_dev); static void prism2_release(u_long arg); static int prism2_event(event_t event, int priority, event_callback_args_t *args); @@ -528,15 +528,16 @@ static dev_link_t *prism2_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - prism2_detach(link); + prism2_detach(link->handle); return NULL; } return link; } -static void prism2_detach(dev_link_t *link) +static void prism2_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; PDEBUG(DEBUG_FLOW, "prism2_detach\n"); @@ -554,14 +555,6 @@ static void prism2_detach(dev_link_t *link) prism2_release((u_long)link); } - if (link->handle) { - int res = pcmcia_deregister_client(link->handle); - if (res) { - printk("CardService(DeregisterClient) => %d\n", res); - cs_error(link->handle, DeregisterClient, res); - } - } - *linkp = link->next; /* release net devices */ if (link->priv) { @@ -902,7 +895,6 @@ static int prism2_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = (struct net_device *) link->priv; switch (event) { case CS_EVENT_CARD_INSERTION: @@ -913,16 +905,6 @@ static int prism2_event(event_t event, int priority, } break; - case CS_EVENT_CARD_REMOVAL: - PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_REMOVAL\n", dev_info); - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - netif_stop_queue(dev); - netif_device_detach(dev); - prism2_release((u_long) link); - } - break; - default: PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n", dev_info, event); @@ -991,7 +973,7 @@ static struct pcmcia_driver hostap_driver = { .name = "hostap_cs", }, .attach = prism2_attach, - .detach = prism2_detach, + .remove = prism2_detach, .owner = THIS_MODULE, .event = prism2_event, .id_table = hostap_cs_ids, diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 7ab2d70..1770677 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c @@ -200,7 +200,7 @@ static int netwave_event(event_t event, int priority, static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card insertion */ static dev_link_t *netwave_attach(void); /* Create instance */ -static void netwave_detach(dev_link_t *); /* Destroy instance */ +static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ /* Hardware configuration */ static void netwave_doreset(kio_addr_t iobase, u_char __iomem *ramBase); @@ -459,7 +459,7 @@ static dev_link_t *netwave_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - netwave_detach(link); + netwave_detach(link->handle); return NULL; } @@ -474,8 +474,9 @@ static dev_link_t *netwave_attach(void) * structures are freed. Otherwise, the structures will be freed * when the device is released. */ -static void netwave_detach(dev_link_t *link) +static void netwave_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; dev_link_t **linkp; @@ -489,11 +490,7 @@ static void netwave_detach(dev_link_t *link) */ if (link->state & DEV_CONFIG) netwave_release(link); - - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - + /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) if (*linkp == link) break; @@ -986,22 +983,10 @@ static int netwave_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; - + DEBUG(1, "netwave_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_REGISTRATION_COMPLETE: - DEBUG(0, "netwave_cs: registration complete\n"); - break; - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - netif_device_detach(dev); - netwave_release(link); - } - break; + switch (event) { case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; netwave_pcmcia_config( link); @@ -1504,7 +1489,7 @@ static struct pcmcia_driver netwave_driver = { }, .attach = netwave_attach, .event = netwave_event, - .detach = netwave_detach, + .remove = netwave_detach, .id_table = netwave_ids, .suspend = netwave_suspend, .resume = netwave_resume, diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 1d66050..00679b6 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -81,7 +81,7 @@ static dev_link_t *dev_list; /* = NULL */ /********************************************************************/ static void orinoco_cs_release(dev_link_t *link); -static void orinoco_cs_detach(dev_link_t *link); +static void orinoco_cs_detach(struct pcmcia_device *p_dev); /********************************************************************/ /* Device methods */ @@ -165,7 +165,7 @@ orinoco_cs_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - orinoco_cs_detach(link); + orinoco_cs_detach(link->handle); return NULL; } @@ -178,8 +178,9 @@ orinoco_cs_attach(void) * are freed. Otherwise, the structures will be freed when the device * is released. */ -static void orinoco_cs_detach(dev_link_t *link) +static void orinoco_cs_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; struct net_device *dev = link->priv; @@ -193,10 +194,6 @@ static void orinoco_cs_detach(dev_link_t *link) if (link->state & DEV_CONFIG) orinoco_cs_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, and free it */ *linkp = link->next; DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); @@ -551,30 +548,15 @@ orinoco_cs_event(event_t event, int priority, event_callback_args_t * args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; - struct orinoco_private *priv = netdev_priv(dev); - int err = 0; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - unsigned long flags; - - spin_lock_irqsave(&priv->lock, flags); - netif_device_detach(dev); - priv->hw_unavailable++; - spin_unlock_irqrestore(&priv->lock, flags); - } - break; - case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; orinoco_cs_config(link); break; } - return err; + return 0; } /* orinoco_cs_event */ /********************************************************************/ @@ -677,7 +659,7 @@ static struct pcmcia_driver orinoco_driver = { .name = DRIVER_NAME, }, .attach = orinoco_cs_attach, - .detach = orinoco_cs_detach, + .remove = orinoco_cs_detach, .event = orinoco_cs_event, .id_table = orinoco_cs_ids, .suspend = orinoco_cs_suspend, diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index c2cb6c8..33a89e2 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -94,7 +94,7 @@ static void ray_config(dev_link_t *link); static void ray_release(dev_link_t *link); static int ray_event(event_t event, int priority, event_callback_args_t *args); static dev_link_t *ray_attach(void); -static void ray_detach(dev_link_t *); +static void ray_detach(struct pcmcia_device *p_dev); /***** Prototypes indicated by device structure ******************************/ static int ray_dev_close(struct net_device *dev); @@ -402,7 +402,7 @@ static dev_link_t *ray_attach(void) if (ret != 0) { printk("ray_cs ray_attach RegisterClient unhappy - detaching\n"); cs_error(link->handle, RegisterClient, ret); - ray_detach(link); + ray_detach(link->handle); return NULL; } DEBUG(2,"ray_cs ray_attach ending\n"); @@ -418,9 +418,12 @@ fail_alloc_dev: structures are freed. Otherwise, the structures will be freed when the device is released. =============================================================================*/ -static void ray_detach(dev_link_t *link) +static void ray_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; + struct net_device *dev; + ray_dev_t *local; DEBUG(1, "ray_detach(0x%p)\n", link); @@ -430,22 +433,18 @@ static void ray_detach(dev_link_t *link) if (*linkp == NULL) return; - /* If the device is currently configured and active, we won't - actually delete it yet. Instead, it is marked so that when - the release() function is called, that will trigger a proper - detach(). - */ - if (link->state & DEV_CONFIG) - ray_release(link); + dev = link->priv; + + if (link->state & DEV_CONFIG) { + ray_release(link); + + local = (ray_dev_t *)dev->priv; + del_timer(&local->timer); + } - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free pieces */ *linkp = link->next; if (link->priv) { - struct net_device *dev = link->priv; if (link->dev) unregister_netdev(dev); free_netdev(dev); } @@ -940,19 +939,9 @@ static int ray_event(event_t event, int priority, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; - ray_dev_t *local = (ray_dev_t *)dev->priv; DEBUG(1, "ray_event(0x%06x)\n", event); - + switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - netif_device_detach(dev); - if (link->state & DEV_CONFIG) { - ray_release(link); - del_timer(&local->timer); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; ray_config(link); @@ -2958,7 +2947,7 @@ static struct pcmcia_driver ray_driver = { }, .attach = ray_attach, .event = ray_event, - .detach = ray_detach, + .remove = ray_detach, .id_table = ray_ids, .suspend = ray_suspend, .resume = ray_resume, diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index 3938a57..a2dcab7 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c @@ -90,7 +90,7 @@ static dev_link_t *dev_list; /* = NULL */ /********************************************************************/ static void spectrum_cs_release(dev_link_t *link); -static void spectrum_cs_detach(dev_link_t *link); +static void spectrum_cs_detach(struct pcmcia_device *p_dev); /********************************************************************/ /* Firmware downloader */ @@ -647,7 +647,7 @@ spectrum_cs_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - spectrum_cs_detach(link); + spectrum_cs_detach(link->handle); return NULL; } @@ -660,27 +660,14 @@ spectrum_cs_attach(void) * are freed. Otherwise, the structures will be freed when the device * is released. */ -static void spectrum_cs_detach(dev_link_t *link) +static void spectrum_cs_detach(struct pcmcia_device *p_dev) { - dev_link_t **linkp; + dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - - BUG_ON(*linkp == NULL); - if (link->state & DEV_CONFIG) spectrum_cs_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - - /* Unlink device structure, and free it */ - *linkp = link->next; DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); if (link->dev) { DEBUG(0, PFX "About to unregister net device %p\n", @@ -1007,22 +994,8 @@ spectrum_cs_event(event_t event, int priority, event_callback_args_t * args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; - struct orinoco_private *priv = netdev_priv(dev); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - unsigned long flags; - - spin_lock_irqsave(&priv->lock, flags); - netif_device_detach(dev); - priv->hw_unavailable++; - spin_unlock_irqrestore(&priv->lock, flags); - } - break; - case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; spectrum_cs_config(link); @@ -1057,7 +1030,7 @@ static struct pcmcia_driver orinoco_driver = { .name = DRIVER_NAME, }, .attach = spectrum_cs_attach, - .detach = spectrum_cs_detach, + .remove = spectrum_cs_detach, .suspend = spectrum_cs_suspend, .resume = spectrum_cs_resume, .event = spectrum_cs_event, diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 3e35328..255952d 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c @@ -4692,7 +4692,7 @@ wavelan_attach(void) if(ret != 0) { cs_error(link->handle, RegisterClient, ret); - wavelan_detach(link); + wavelan_detach(link->handle); return NULL; } @@ -4711,8 +4711,10 @@ wavelan_attach(void) * is released. */ static void -wavelan_detach(dev_link_t * link) +wavelan_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); + #ifdef DEBUG_CALLBACK_TRACE printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link); #endif @@ -4729,10 +4731,6 @@ wavelan_detach(dev_link_t * link) wv_pcmcia_release(link); } - /* Break the link with Card Services */ - if(link->handle) - pcmcia_deregister_client(link->handle); - /* Remove the interface data from the linked list */ if(dev_list == link) dev_list = link->next; @@ -4854,25 +4852,6 @@ wavelan_event(event_t event, /* The event received */ switch(event) { - case CS_EVENT_REGISTRATION_COMPLETE: -#ifdef DEBUG_CONFIG_INFO - printk(KERN_DEBUG "wavelan_cs: registration complete\n"); -#endif - break; - - case CS_EVENT_CARD_REMOVAL: - /* Oups ! The card is no more there */ - link->state &= ~DEV_PRESENT; - if(link->state & DEV_CONFIG) - { - /* Accept no more transmissions */ - netif_device_detach(dev); - - /* Release the card */ - wv_pcmcia_release(link); - } - break; - case CS_EVENT_CARD_INSERTION: /* Reset and configure the card */ link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; @@ -4906,7 +4885,7 @@ static struct pcmcia_driver wavelan_driver = { }, .attach = wavelan_attach, .event = wavelan_event, - .detach = wavelan_detach, + .remove = wavelan_detach, .id_table = wavelan_ids, .suspend = wavelan_suspend, .resume = wavelan_resume, diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h index 724a715..3cb3481 100644 --- a/drivers/net/wireless/wavelan_cs.p.h +++ b/drivers/net/wireless/wavelan_cs.p.h @@ -757,7 +757,7 @@ static int static dev_link_t * wavelan_attach(void); /* Create a new device */ static void - wavelan_detach(dev_link_t *); /* Destroy a removed device */ + wavelan_detach(struct pcmcia_device *p_dev); /* Destroy a removed device */ static int wavelan_event(event_t, /* Manage pcmcia events */ int, diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 7511431..21e498f 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -1498,9 +1498,11 @@ static struct ethtool_ops ops = { * Services. If it has been released, all local data structures are freed. * Otherwise, the structures will be freed when the device is released. */ -static void wl3501_detach(dev_link_t *link) +static void wl3501_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; + struct net_device *dev = link->priv; /* Locate device structure */ for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next) @@ -1514,16 +1516,12 @@ static void wl3501_detach(dev_link_t *link) * function is called, that will trigger a proper detach(). */ if (link->state & DEV_CONFIG) { -#ifdef PCMCIA_DEBUG - printk(KERN_DEBUG "wl3501_cs: detach postponed, '%s' " - "still locked\n", link->dev->dev_name); -#endif - goto out; - } + while (link->open > 0) + wl3501_close(dev); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); + netif_device_detach(dev); + wl3501_release(link); + } /* Unlink device structure, free pieces */ *linkp = link->next; @@ -2012,7 +2010,7 @@ static dev_link_t *wl3501_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret) { cs_error(link->handle, RegisterClient, ret); - wl3501_detach(link); + wl3501_detach(link->handle); link = NULL; } out: @@ -2225,18 +2223,8 @@ static int wl3501_resume(struct pcmcia_device *p_dev) static int wl3501_event(event_t event, int pri, event_callback_args_t *args) { dev_link_t *link = args->client_data; - struct net_device *dev = link->priv; switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - while (link->open > 0) - wl3501_close(dev); - netif_device_detach(dev); - wl3501_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; wl3501_config(link); @@ -2258,7 +2246,7 @@ static struct pcmcia_driver wl3501_driver = { }, .attach = wl3501_attach, .event = wl3501_event, - .detach = wl3501_detach, + .remove = wl3501_detach, .id_table = wl3501_ids, .suspend = wl3501_suspend, .resume = wl3501_resume, diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 4c89853..063d22d 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c @@ -88,7 +88,7 @@ typedef struct parport_info_t { } parport_info_t; static dev_link_t *parport_attach(void); -static void parport_detach(dev_link_t *); +static void parport_detach(struct pcmcia_device *p_dev); static void parport_config(dev_link_t *link); static void parport_cs_release(dev_link_t *); static int parport_event(event_t event, int priority, @@ -137,7 +137,7 @@ static dev_link_t *parport_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - parport_detach(link); + parport_detach(link->handle); return NULL; } @@ -153,13 +153,13 @@ static dev_link_t *parport_attach(void) ======================================================================*/ -static void parport_detach(dev_link_t *link) +static void parport_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; - int ret; DEBUG(0, "parport_detach(0x%p)\n", link); - + /* Locate device structure */ for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) if (*linkp == link) break; @@ -168,17 +168,10 @@ static void parport_detach(dev_link_t *link) if (link->state & DEV_CONFIG) parport_cs_release(link); - - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - + /* Unlink, free device structure */ *linkp = link->next; kfree(link->priv); - } /* parport_detach */ /*====================================================================== @@ -362,11 +355,6 @@ int parport_event(event_t event, int priority, DEBUG(1, "parport_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - parport_cs_release(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; parport_config(link); @@ -389,7 +377,7 @@ static struct pcmcia_driver parport_cs_driver = { }, .attach = parport_attach, .event = parport_event, - .detach = parport_detach, + .remove = parport_detach, .id_table = parport_ids, .suspend = parport_suspend, .resume = parport_resume, diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 5223395..32b4d6b 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -57,8 +57,6 @@ module_param_named(pc_debug, ds_pc_debug, int, 0644); spinlock_t pcmcia_dev_list_lock; -static int unbind_request(struct pcmcia_socket *s); - /*====================================================================*/ /* code which was in cs.c before */ @@ -205,7 +203,7 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv) unsigned int i; u32 hash; - if (!p_drv->attach || !p_drv->event || !p_drv->detach) + if (!p_drv->attach || !p_drv->event || !p_drv->remove) printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback " "function\n", p_drv->drv.name); @@ -399,13 +397,42 @@ static int pcmcia_device_remove(struct device * dev) { struct pcmcia_device *p_dev; struct pcmcia_driver *p_drv; + int i; /* detach the "instance" */ p_dev = to_pcmcia_dev(dev); p_drv = to_pcmcia_drv(dev->driver); + /* the likely, new path */ + if (p_drv && p_drv->remove) { + p_drv->remove(p_dev); + + /* check for proper unloading */ + if (p_dev->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED)) + printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", + p_drv->drv.name); + + for (i = 0; i < MAX_WIN; i++) + if (p_dev->state & CLIENT_WIN_REQ(i)) + printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", + p_drv->drv.name); + + /* undo pcmcia_register_client */ + p_dev->state = CLIENT_UNBOUND; + pcmcia_put_dev(p_dev); + + /* references from pcmcia_probe_device */ + pcmcia_put_dev(p_dev); + module_put(p_drv->owner); + + return 0; + } + + /* old path */ if (p_drv) { if ((p_drv->detach) && (p_dev->instance)) { + printk(KERN_INFO "pcmcia: using deprecated detach mechanism. Fix the driver!\n"); + p_drv->detach(p_dev->instance); /* from pcmcia_probe_device */ put_device(&p_dev->dev); @@ -417,6 +444,36 @@ static int pcmcia_device_remove(struct device * dev) } +/* + * Removes a PCMCIA card from the device tree and socket list. + */ +static void pcmcia_card_remove(struct pcmcia_socket *s) +{ + struct pcmcia_device *p_dev; + unsigned long flags; + + ds_dbg(2, "unbind_request(%d)\n", s->sock); + + s->device_count = 0; + + for (;;) { + /* unregister all pcmcia_devices registered with this socket*/ + spin_lock_irqsave(&pcmcia_dev_list_lock, flags); + if (list_empty(&s->devices_list)) { + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + return; + } + p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list); + list_del(&p_dev->socket_device_list); + p_dev->state |= CLIENT_STALE; + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + + device_unregister(&p_dev->dev); + } + + return; +} /* unbind_request */ + /* * pcmcia_device_query -- determine information about a pcmcia device @@ -1059,8 +1116,8 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) case CS_EVENT_CARD_REMOVAL: s->pcmcia_state.present = 0; - send_event(skt, event, priority); - unbind_request(skt); + send_event(skt, event, priority); + pcmcia_card_remove(skt); handle_event(skt, event); break; @@ -1177,36 +1234,6 @@ int pcmcia_register_client(struct pcmcia_device **handle, client_reg_t *req) EXPORT_SYMBOL(pcmcia_register_client); -/* unbind _all_ devices attached to a given pcmcia_bus_socket. The - * drivers have been called with EVENT_CARD_REMOVAL before. - */ -static int unbind_request(struct pcmcia_socket *s) -{ - struct pcmcia_device *p_dev; - unsigned long flags; - - ds_dbg(2, "unbind_request(%d)\n", s->sock); - - s->device_count = 0; - - for (;;) { - /* unregister all pcmcia_devices registered with this socket*/ - spin_lock_irqsave(&pcmcia_dev_list_lock, flags); - if (list_empty(&s->devices_list)) { - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - return 0; - } - p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list); - list_del(&p_dev->socket_device_list); - p_dev->state |= CLIENT_STALE; - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - - device_unregister(&p_dev->dev); - } - - return 0; -} /* unbind_request */ - int pcmcia_deregister_client(struct pcmcia_device *p_dev) { struct pcmcia_socket *s; diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 82988a3..3128ba8 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -99,7 +99,7 @@ static int aha152x_event(event_t event, int priority, event_callback_args_t *args); static dev_link_t *aha152x_attach(void); -static void aha152x_detach(dev_link_t *); +static void aha152x_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list; static dev_info_t dev_info = "aha152x_cs"; @@ -138,7 +138,7 @@ static dev_link_t *aha152x_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - aha152x_detach(link); + aha152x_detach(link->handle); return NULL; } @@ -147,8 +147,9 @@ static dev_link_t *aha152x_attach(void) /*====================================================================*/ -static void aha152x_detach(dev_link_t *link) +static void aha152x_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "aha152x_detach(0x%p)\n", link); @@ -162,9 +163,6 @@ static void aha152x_detach(dev_link_t *link) if (link->state & DEV_CONFIG) aha152x_release_cs(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ *linkp = link->next; kfree(link->priv); @@ -307,11 +305,6 @@ static int aha152x_event(event_t event, int priority, DEBUG(0, "aha152x_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - aha152x_release_cs(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; aha152x_config_cs(link); @@ -337,7 +330,7 @@ static struct pcmcia_driver aha152x_cs_driver = { }, .attach = aha152x_attach, .event = aha152x_event, - .detach = aha152x_detach, + .remove = aha152x_detach, .id_table = aha152x_ids, .suspend = aha152x_suspend, .resume = aha152x_resume, diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index 9e1d68c..5842c93 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -84,7 +84,7 @@ static int fdomain_event(event_t event, int priority, event_callback_args_t *args); static dev_link_t *fdomain_attach(void); -static void fdomain_detach(dev_link_t *); +static void fdomain_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -124,7 +124,7 @@ static dev_link_t *fdomain_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - fdomain_detach(link); + fdomain_detach(link->handle); return NULL; } @@ -133,8 +133,9 @@ static dev_link_t *fdomain_attach(void) /*====================================================================*/ -static void fdomain_detach(dev_link_t *link) +static void fdomain_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "fdomain_detach(0x%p)\n", link); @@ -148,9 +149,6 @@ static void fdomain_detach(dev_link_t *link) if (link->state & DEV_CONFIG) fdomain_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ *linkp = link->next; kfree(link->priv); @@ -288,11 +286,6 @@ static int fdomain_event(event_t event, int priority, DEBUG(1, "fdomain_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - fdomain_release(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; fdomain_config(link); @@ -317,7 +310,7 @@ static struct pcmcia_driver fdomain_cs_driver = { }, .attach = fdomain_attach, .event = fdomain_event, - .detach = fdomain_detach, + .remove = fdomain_detach, .id_table = fdomain_ids, .suspend = fdomain_suspend, .resume = fdomain_resume, diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index 870e871..e40a8c2 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -1646,7 +1646,7 @@ static dev_link_t *nsp_cs_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - nsp_cs_detach(link); + nsp_cs_detach(link->handle); return NULL; } @@ -1662,8 +1662,9 @@ static dev_link_t *nsp_cs_attach(void) structures are freed. Otherwise, the structures will be freed when the device is released. ======================================================================*/ -static void nsp_cs_detach(dev_link_t *link) +static void nsp_cs_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); @@ -1678,12 +1679,9 @@ static void nsp_cs_detach(dev_link_t *link) return; } - if (link->state & DEV_CONFIG) + if (link->state & DEV_CONFIG) { + ((scsi_info_t *)link->priv)->stop = 1; nsp_cs_release(link); - - /* Break the link with Card Services */ - if (link->handle) { - pcmcia_deregister_client(link->handle); } /* Unlink device structure, free bits */ @@ -2096,15 +2094,6 @@ static int nsp_cs_event(event_t event, nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - nsp_dbg(NSP_DEBUG_INIT, "event: remove"); - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((scsi_info_t *)link->priv)->stop = 1; - nsp_cs_release(link); - } - break; - case CS_EVENT_CARD_INSERTION: nsp_dbg(NSP_DEBUG_INIT, "event: insert"); link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; @@ -2144,7 +2133,7 @@ static struct pcmcia_driver nsp_driver = { }, .attach = nsp_cs_attach, .event = nsp_cs_event, - .detach = nsp_cs_detach, + .remove = nsp_cs_detach, .id_table = nsp_cs_ids, .suspend = nsp_cs_suspend, .resume = nsp_cs_resume, diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index f8b9430..d276c46 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -297,7 +297,7 @@ typedef struct _nsp_hw_data { /* Card service functions */ static dev_link_t *nsp_cs_attach (void); -static void nsp_cs_detach (dev_link_t *link); +static void nsp_cs_detach (struct pcmcia_device *p_dev); static void nsp_cs_release(dev_link_t *link); static void nsp_cs_config (dev_link_t *link); static int nsp_cs_event (event_t event, int priority, event_callback_args_t *args); diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index 2541a99..8351dc2 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -101,7 +101,7 @@ static void qlogic_release(dev_link_t *link); static int qlogic_event(event_t event, int priority, event_callback_args_t * args); static dev_link_t *qlogic_attach(void); -static void qlogic_detach(dev_link_t *); +static void qlogic_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -198,7 +198,7 @@ static dev_link_t *qlogic_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - qlogic_detach(link); + qlogic_detach(link->handle); return NULL; } @@ -207,8 +207,9 @@ static dev_link_t *qlogic_attach(void) /*====================================================================*/ -static void qlogic_detach(dev_link_t * link) +static void qlogic_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "qlogic_detach(0x%p)\n", link); @@ -223,9 +224,6 @@ static void qlogic_detach(dev_link_t * link) if (link->state & DEV_CONFIG) qlogic_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits */ *linkp = link->next; kfree(link->priv); @@ -390,11 +388,6 @@ static int qlogic_event(event_t event, int priority, event_callback_args_t * arg DEBUG(1, "qlogic_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - qlogic_release(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; qlogic_config(link); @@ -432,7 +425,7 @@ static struct pcmcia_driver qlogic_cs_driver = { }, .attach = qlogic_attach, .event = qlogic_event, - .detach = qlogic_detach, + .remove = qlogic_detach, .id_table = qlogic_ids, .suspend = qlogic_suspend, .resume = qlogic_resume, diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index c4e3e22..a0f8e269 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -918,11 +918,6 @@ SYM53C500_event(event_t event, int priority, event_callback_args_t *args) DEBUG(1, "SYM53C500_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - SYM53C500_release(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; SYM53C500_config(link); @@ -932,8 +927,9 @@ SYM53C500_event(event_t event, int priority, event_callback_args_t *args) } /* SYM53C500_event */ static void -SYM53C500_detach(dev_link_t *link) +SYM53C500_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DEBUG(0, "SYM53C500_detach(0x%p)\n", link); @@ -948,9 +944,6 @@ SYM53C500_detach(dev_link_t *link) if (link->state & DEV_CONFIG) SYM53C500_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - /* Unlink device structure, free bits. */ *linkp = link->next; kfree(link->priv); @@ -993,7 +986,7 @@ SYM53C500_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != 0) { cs_error(link->handle, RegisterClient, ret); - SYM53C500_detach(link); + SYM53C500_detach(link->handle); return NULL; } @@ -1019,7 +1012,7 @@ static struct pcmcia_driver sym53c500_cs_driver = { }, .attach = SYM53C500_attach, .event = SYM53C500_event, - .detach = SYM53C500_detach, + .remove = SYM53C500_detach, .id_table = sym53c500_ids, .suspend = sym53c500_suspend, .resume = sym53c500_resume, diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 3487ee9..a953663 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -120,7 +120,7 @@ static int serial_event(event_t event, int priority, static dev_info_t dev_info = "serial_cs"; static dev_link_t *serial_attach(void); -static void serial_detach(dev_link_t *); +static void serial_detach(struct pcmcia_device *p_dev); static dev_link_t *dev_list = NULL; @@ -242,7 +242,7 @@ static dev_link_t *serial_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - serial_detach(link); + serial_detach(link->handle); return NULL; } @@ -258,11 +258,11 @@ static dev_link_t *serial_attach(void) ======================================================================*/ -static void serial_detach(dev_link_t * link) +static void serial_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct serial_info *info = link->priv; dev_link_t **linkp; - int ret; DEBUG(0, "serial_detach(0x%p)\n", link); @@ -283,12 +283,6 @@ static void serial_detach(dev_link_t * link) */ serial_remove(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } - /* Unlink device structure, free bits */ *linkp = link->next; kfree(info); @@ -741,9 +735,6 @@ serial_event(event_t event, int priority, event_callback_args_t * args) DEBUG(1, "serial_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - serial_remove(link); - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; @@ -866,7 +857,7 @@ static struct pcmcia_driver serial_cs_driver = { }, .attach = serial_attach, .event = serial_event, - .detach = serial_detach, + .remove = serial_detach, .id_table = serial_ids, .suspend = serial_suspend, .resume = serial_resume, diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index 7cca46b..c58140d 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -35,7 +35,7 @@ typedef struct ixj_info_t { } ixj_info_t; static dev_link_t *ixj_attach(void); -static void ixj_detach(dev_link_t *); +static void ixj_detach(struct pcmcia_device *p_dev); static void ixj_config(dev_link_t * link); static void ixj_cs_release(dev_link_t * link); static int ixj_event(event_t event, int priority, event_callback_args_t * args); @@ -73,16 +73,17 @@ static dev_link_t *ixj_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - ixj_detach(link); + ixj_detach(link->handle); return NULL; } return link; } -static void ixj_detach(dev_link_t * link) +static void ixj_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; - int ret; + DEBUG(0, "ixj_detach(0x%p)\n", link); for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) if (*linkp == link) @@ -92,11 +93,7 @@ static void ixj_detach(dev_link_t * link) link->state &= ~DEV_RELEASE_PENDING; if (link->state & DEV_CONFIG) ixj_cs_release(link); - if (link->handle) { - ret = pcmcia_deregister_client(link->handle); - if (ret != CS_SUCCESS) - cs_error(link->handle, DeregisterClient, ret); - } + /* Unlink device structure, free bits */ *linkp = link->next; kfree(link->priv); @@ -282,13 +279,6 @@ static int ixj_event(event_t event, int priority, event_callback_args_t * args) dev_link_t *link = args->client_data; DEBUG(1, "ixj_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - link->state |= DEV_RELEASE_PENDING; - ixj_cs_release(link); - } - break; case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; ixj_config(link); @@ -310,7 +300,7 @@ static struct pcmcia_driver ixj_driver = { }, .attach = ixj_attach, .event = ixj_event, - .detach = ixj_detach, + .remove = ixj_detach, .id_table = ixj_ids, .suspend = ixj_suspend, .resume = ixj_resume, diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index cb8c2bd..ed3e701 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -73,6 +73,8 @@ typedef struct local_info_t { dev_node_t node; } local_info_t; +static void sl811_cs_release(dev_link_t * link); + /*====================================================================*/ static void release_platform_dev(struct device * dev) @@ -138,8 +140,9 @@ static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) /*====================================================================*/ -static void sl811_cs_detach(dev_link_t *link) +static void sl811_cs_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); dev_link_t **linkp; DBG(0, "sl811_cs_detach(0x%p)\n", link); @@ -152,9 +155,9 @@ static void sl811_cs_detach(dev_link_t *link) if (*linkp == NULL) return; - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); + link->state &= ~DEV_PRESENT; + if (link->state & DEV_CONFIG) + sl811_cs_release(link); /* Unlink device structure, and free it */ *linkp = link->next; @@ -167,13 +170,6 @@ static void sl811_cs_release(dev_link_t * link) DBG(0, "sl811_cs_release(0x%p)\n", link); - if (link->open) { - DBG(1, "sl811_cs: release postponed, '%s' still open\n", - link->dev->dev_name); - link->state |= DEV_STALE_CONFIG; - return; - } - /* Unlink the device chain */ link->dev = NULL; @@ -184,9 +180,6 @@ static void sl811_cs_release(dev_link_t * link) if (link->irq.AssignedIRQ) pcmcia_release_irq(link->handle, &link->irq); link->state &= ~DEV_CONFIG; - - if (link->state & DEV_STALE_LINK) - sl811_cs_detach(link); } static void sl811_cs_config(dev_link_t *link) @@ -353,12 +346,6 @@ sl811_cs_event(event_t event, int priority, event_callback_args_t *args) DBG(1, "sl811_cs_event(0x%06x)\n", event); switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - sl811_cs_release(link); - break; - case CS_EVENT_CARD_INSERTION: link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; sl811_cs_config(link); @@ -400,7 +387,7 @@ static dev_link_t *sl811_cs_attach(void) ret = pcmcia_register_client(&link->handle, &client_reg); if (ret != CS_SUCCESS) { cs_error(link->handle, RegisterClient, ret); - sl811_cs_detach(link); + sl811_cs_detach(link->handle); return NULL; } @@ -420,7 +407,7 @@ static struct pcmcia_driver sl811_cs_driver = { }, .attach = sl811_cs_attach, .event = sl811_cs_event, - .detach = sl811_cs_detach, + .remove = sl811_cs_detach, .id_table = sl811_ids, .suspend = sl811_suspend, .resume = sl811_resume, diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 0200551..2869283 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -138,6 +138,8 @@ struct pcmcia_driver { event_callback_args_t *); void (*detach)(dev_link_t *); + void (*remove) (struct pcmcia_device *dev); + int (*suspend) (struct pcmcia_device *dev); int (*resume) (struct pcmcia_device *dev); -- cgit v1.1 From f3990715589d378a2d3aa9b8accd78bb4a2378b7 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:25:23 +0100 Subject: [PATCH] pcmcia: remove old detach mechanism Remove the old "detach" mechanism as it is unused now. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/ds.c | 77 ++++++++++++----------------------------------------- include/pcmcia/cs.h | 1 - include/pcmcia/ds.h | 1 - 3 files changed, 17 insertions(+), 62 deletions(-) diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 32b4d6b..8eff55b 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -402,43 +402,29 @@ static int pcmcia_device_remove(struct device * dev) /* detach the "instance" */ p_dev = to_pcmcia_dev(dev); p_drv = to_pcmcia_drv(dev->driver); + if (!p_drv) + return 0; - /* the likely, new path */ - if (p_drv && p_drv->remove) { + if (p_drv->remove) p_drv->remove(p_dev); - /* check for proper unloading */ - if (p_dev->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED)) - printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", - p_drv->drv.name); - - for (i = 0; i < MAX_WIN; i++) - if (p_dev->state & CLIENT_WIN_REQ(i)) - printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", - p_drv->drv.name); - - /* undo pcmcia_register_client */ - p_dev->state = CLIENT_UNBOUND; - pcmcia_put_dev(p_dev); - - /* references from pcmcia_probe_device */ - pcmcia_put_dev(p_dev); - module_put(p_drv->owner); + /* check for proper unloading */ + if (p_dev->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED)) + printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", + p_drv->drv.name); - return 0; - } + for (i = 0; i < MAX_WIN; i++) + if (p_dev->state & CLIENT_WIN_REQ(i)) + printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", + p_drv->drv.name); - /* old path */ - if (p_drv) { - if ((p_drv->detach) && (p_dev->instance)) { - printk(KERN_INFO "pcmcia: using deprecated detach mechanism. Fix the driver!\n"); + /* undo pcmcia_register_client */ + p_dev->state = CLIENT_UNBOUND; + pcmcia_put_dev(p_dev); - p_drv->detach(p_dev->instance); - /* from pcmcia_probe_device */ - put_device(&p_dev->dev); - } - module_put(p_drv->owner); - } + /* references from pcmcia_probe_device */ + pcmcia_put_dev(p_dev); + module_put(p_drv->owner); return 0; } @@ -1234,35 +1220,6 @@ int pcmcia_register_client(struct pcmcia_device **handle, client_reg_t *req) EXPORT_SYMBOL(pcmcia_register_client); -int pcmcia_deregister_client(struct pcmcia_device *p_dev) -{ - struct pcmcia_socket *s; - int i; - - s = p_dev->socket; - ds_dbg(1, "deregister_client(%p)\n", p_dev); - - if (p_dev->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED)) - goto warn_out; - for (i = 0; i < MAX_WIN; i++) - if (p_dev->state & CLIENT_WIN_REQ(i)) - goto warn_out; - - if (p_dev->state & CLIENT_STALE) { - p_dev->state &= ~CLIENT_STALE; - pcmcia_put_dev(p_dev); - } else { - p_dev->state = CLIENT_UNBOUND; - } - - return CS_SUCCESS; - warn_out: - printk(KERN_WARNING "ds: deregister_client was called too early.\n"); - return CS_IN_USE; -} /* deregister_client */ -EXPORT_SYMBOL(pcmcia_deregister_client); - - static struct pcmcia_callback pcmcia_bus_callback = { .owner = THIS_MODULE, .event = ds_event, diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index 2cab39f..a751251 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -382,7 +382,6 @@ enum service { struct pcmcia_socket; int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, conf_reg_t *reg); -int pcmcia_deregister_client(struct pcmcia_device *p_dev); int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, config_info_t *config); int pcmcia_get_first_window(window_handle_t *win, win_req_t *req); int pcmcia_get_next_window(window_handle_t *win, win_req_t *req); diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index 2869283..c53a060 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -136,7 +136,6 @@ struct pcmcia_driver { dev_link_t *(*attach)(void); int (*event) (event_t event, int priority, event_callback_args_t *); - void (*detach)(dev_link_t *); void (*remove) (struct pcmcia_device *dev); -- cgit v1.1 From b463581154f3f3eecda27cae60df813fefcd84d3 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:25:35 +0100 Subject: [PATCH] pcmcia: remove dev_list from drivers The linked list of devices managed by each PCMCIA driver is, in very most cases, unused. Therefore, remove it from many drivers. Signed-off-by: Dominik Brodowski --- drivers/bluetooth/bluecard_cs.c | 18 +---------- drivers/bluetooth/bt3c_cs.c | 18 +---------- drivers/bluetooth/btuart_cs.c | 18 +---------- drivers/bluetooth/dtl1_cs.c | 18 +---------- drivers/char/pcmcia/synclink_cs.c | 14 +-------- drivers/ide/legacy/ide-cs.c | 19 +++-------- drivers/isdn/hardware/avm/avm_cs.c | 21 +------------ drivers/isdn/hisax/avma1_cs.c | 21 +------------ drivers/isdn/hisax/elsa_cs.c | 28 ++--------------- drivers/isdn/hisax/sedlbauer_cs.c | 28 ++--------------- drivers/isdn/hisax/teles_cs.c | 28 ++--------------- drivers/mtd/maps/pcmciamtd.c | 5 +-- drivers/net/pcmcia/3c574_cs.c | 15 +-------- drivers/net/pcmcia/3c589_cs.c | 17 ++-------- drivers/net/pcmcia/axnet_cs.c | 14 +-------- drivers/net/pcmcia/com20020_cs.c | 22 +++---------- drivers/net/pcmcia/fmvj18x_cs.c | 16 ++-------- drivers/net/pcmcia/ibmtr_cs.c | 21 ++----------- drivers/net/pcmcia/nmclan_cs.c | 14 +-------- drivers/net/pcmcia/pcnet_cs.c | 14 +-------- drivers/net/pcmcia/smc91c92_cs.c | 15 +-------- drivers/net/pcmcia/xirc2ps_cs.c | 24 +------------- drivers/net/wireless/airo_cs.c | 28 +++-------------- drivers/net/wireless/atmel_cs.c | 25 ++------------- drivers/net/wireless/hostap/hostap_cs.c | 15 +-------- drivers/net/wireless/netwave_cs.c | 56 +++++++-------------------------- drivers/net/wireless/orinoco_cs.c | 21 +------------ drivers/net/wireless/spectrum_cs.c | 11 +------ drivers/net/wireless/wavelan_cs.c | 24 +------------- drivers/net/wireless/wavelan_cs.p.h | 1 - drivers/parport/parport_cs.c | 14 +-------- drivers/scsi/pcmcia/fdomain_stub.c | 30 +++++------------- drivers/scsi/pcmcia/nsp_cs.c | 19 +---------- drivers/scsi/pcmcia/qlogic_stub.c | 16 +--------- drivers/scsi/pcmcia/sym53c500_cs.c | 14 +-------- drivers/serial/serial_cs.c | 17 ++-------- drivers/telephony/ixj_pcmcia.c | 14 ++------- drivers/usb/host/sl811_cs.c | 16 +--------- 38 files changed, 78 insertions(+), 651 deletions(-) diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index f5088cb..bd80535 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -94,8 +94,6 @@ static dev_info_t dev_info = "bluecard_cs"; static dev_link_t *bluecard_attach(void); static void bluecard_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; - /* Default baud rate: 57600, 115200, 230400 or 460800 */ #define DEFAULT_BAUD_RATE 230400 @@ -890,8 +888,7 @@ static dev_link_t *bluecard_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -911,22 +908,10 @@ static void bluecard_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); bluecard_info_t *info = link->priv; - dev_link_t **linkp; - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - - if (*linkp == NULL) - return; if (link->state & DEV_CONFIG) bluecard_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; - kfree(info); } @@ -1105,7 +1090,6 @@ static int __init init_bluecard_cs(void) static void __exit exit_bluecard_cs(void) { pcmcia_unregister_driver(&bluecard_driver); - BUG_ON(dev_list != NULL); } module_init(init_bluecard_cs); diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 02ce38e..50aa52b 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -97,8 +97,6 @@ static dev_info_t dev_info = "bt3c_cs"; static dev_link_t *bt3c_attach(void); static void bt3c_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; - /* Transmit states */ #define XMIT_SENDING 1 @@ -691,8 +689,7 @@ static dev_link_t *bt3c_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -712,22 +709,10 @@ static void bt3c_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); bt3c_info_t *info = link->priv; - dev_link_t **linkp; - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - - if (*linkp == NULL) - return; if (link->state & DEV_CONFIG) bt3c_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; - kfree(info); } @@ -949,7 +934,6 @@ static int __init init_bt3c_cs(void) static void __exit exit_bt3c_cs(void) { pcmcia_unregister_driver(&bt3c_driver); - BUG_ON(dev_list != NULL); } module_init(init_bt3c_cs); diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 63221d3..7b04f89 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -93,8 +93,6 @@ static dev_info_t dev_info = "btuart_cs"; static dev_link_t *btuart_attach(void); static void btuart_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; - /* Maximum baud rate */ #define SPEED_MAX 115200 @@ -610,8 +608,7 @@ static dev_link_t *btuart_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -631,22 +628,10 @@ static void btuart_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); btuart_info_t *info = link->priv; - dev_link_t **linkp; - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - - if (*linkp == NULL) - return; if (link->state & DEV_CONFIG) btuart_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; - kfree(info); } @@ -870,7 +855,6 @@ static int __init init_btuart_cs(void) static void __exit exit_btuart_cs(void) { pcmcia_unregister_driver(&btuart_driver); - BUG_ON(dev_list != NULL); } module_init(init_btuart_cs); diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 2874d87..c39d457 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -96,8 +96,6 @@ static dev_info_t dev_info = "dtl1_cs"; static dev_link_t *dtl1_attach(void); static void dtl1_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; - /* Transmit states */ #define XMIT_SENDING 1 @@ -589,8 +587,7 @@ static dev_link_t *dtl1_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -610,22 +607,10 @@ static void dtl1_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); dtl1_info_t *info = link->priv; - dev_link_t **linkp; - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - - if (*linkp == NULL) - return; if (link->state & DEV_CONFIG) dtl1_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; - kfree(info); } @@ -822,7 +807,6 @@ static int __init init_dtl1_cs(void) static void __exit exit_dtl1_cs(void) { pcmcia_unregister_driver(&dtl1_driver); - BUG_ON(dev_list != NULL); } module_init(init_dtl1_cs); diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 3459714..dc38b1d 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -492,7 +492,6 @@ static dev_link_t *mgslpc_attach(void); static void mgslpc_detach(struct pcmcia_device *p_dev); static dev_info_t dev_info = "synclink_cs"; -static dev_link_t *dev_list = NULL; /* * 1st function defined in .text section. Calling this function in @@ -588,8 +587,7 @@ static dev_link_t *mgslpc_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; @@ -741,24 +739,15 @@ static void mgslpc_release(u_long arg) static void mgslpc_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; if (debug_level >= DEBUG_LEVEL_INFO) printk("mgslpc_detach(0x%p)\n", link); - /* find device */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->state & DEV_CONFIG) { ((MGSLPC_INFO *)link->priv)->stop = 1; mgslpc_release((u_long)link); } - /* Unlink device structure, and free it */ - *linkp = link->next; mgslpc_remove_device((MGSLPC_INFO *)link->priv); } @@ -3131,7 +3120,6 @@ static void synclink_cs_cleanup(void) } pcmcia_unregister_driver(&mgslpc_driver); - BUG_ON(dev_list != NULL); } static int __init synclink_cs_init(void) diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 1fb8976..c83068d 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -96,7 +96,8 @@ static dev_info_t dev_info = "ide-cs"; static dev_link_t *ide_attach(void); static void ide_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; + + /*====================================================================== @@ -130,8 +131,7 @@ static dev_link_t *ide_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -157,23 +157,13 @@ static dev_link_t *ide_attach(void) static void ide_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; DEBUG(0, "ide_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; if (link->state & DEV_CONFIG) ide_release(link); - - /* Unlink, free device structure */ - *linkp = link->next; + kfree(link->priv); - } /* ide_detach */ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) @@ -507,7 +497,6 @@ static int __init init_ide_cs(void) static void __exit exit_ide_cs(void) { pcmcia_unregister_driver(&ide_cs_driver); - BUG_ON(dev_list != NULL); } late_initcall(init_ide_cs); diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index 2d898d3..0a8c1da 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c @@ -83,15 +83,7 @@ static dev_info_t dev_info = "avm_cs"; device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list = NULL; - /* - A dev_link_t structure has fields for most things that are needed - to keep track of a socket, but there will usually be some device - specific information that also needs to be kept track of. The - 'priv' pointer in a dev_link_t structure can be used to point to - a device-specific private data structure, like this. - A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -157,8 +149,7 @@ static dev_link_t *avmcs_attach(void) link->priv = local; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -188,19 +179,10 @@ static dev_link_t *avmcs_attach(void) static void avmcs_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; if (link->state & DEV_CONFIG) avmcs_release(link); - /* Unlink device structure, free pieces */ - *linkp = link->next; kfree(link->priv); kfree(link); } /* avmcs_detach */ @@ -494,7 +476,6 @@ static int __init avmcs_init(void) static void __exit avmcs_exit(void) { pcmcia_unregister_driver(&avmcs_driver); - BUG_ON(dev_list != NULL); } module_init(avmcs_init); diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 6b322e8..b6ea653 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c @@ -99,15 +99,7 @@ static dev_info_t dev_info = "avma1_cs"; device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list = NULL; - /* - A dev_link_t structure has fields for most things that are needed - to keep track of a socket, but there will usually be some device - specific information that also needs to be kept track of. The - 'priv' pointer in a dev_link_t structure can be used to point to - a device-specific private data structure, like this. - A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -179,8 +171,7 @@ static dev_link_t *avma1cs_attach(void) link->conf.Present = PRESENT_OPTION; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -206,21 +197,12 @@ static dev_link_t *avma1cs_attach(void) static void avma1cs_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; DEBUG(0, "avma1cs_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->state & DEV_CONFIG) avma1cs_release(link); - /* Unlink device structure, free pieces */ - *linkp = link->next; kfree(link->priv); kfree(link); } /* avma1cs_detach */ @@ -508,7 +490,6 @@ static int __init init_avma1_cs(void) static void __exit exit_avma1_cs(void) { pcmcia_unregister_driver(&avma1cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_avma1_cs); diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index 48cc677..a0c5bad 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c @@ -126,18 +126,7 @@ static dev_info_t dev_info = "elsa_cs"; device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list = NULL; - /* - A dev_link_t structure has fields for most things that are needed - to keep track of a socket, but there will usually be some device - specific information that also needs to be kept track of. The - 'priv' pointer in a dev_link_t structure can be used to point to - a device-specific private data structure, like this. - - To simplify the data structure handling, we actually include the - dev_link_t structure in the device's private data structure. - A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -208,8 +197,7 @@ static dev_link_t *elsa_cs_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -235,24 +223,15 @@ static dev_link_t *elsa_cs_attach(void) static void elsa_cs_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; local_info_t *info = link->priv; DEBUG(0, "elsa_cs_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->state & DEV_CONFIG) { - ((local_info_t*)link->priv)->busy = 1; - elsa_cs_release(link); + info->busy = 1; + elsa_cs_release(link); } - /* Unlink device structure and free it */ - *linkp = link->next; kfree(info); } /* elsa_cs_detach */ @@ -526,7 +505,6 @@ static int __init init_elsa_cs(void) static void __exit exit_elsa_cs(void) { pcmcia_unregister_driver(&elsa_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_elsa_cs); diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index d2386f6..814b32a 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c @@ -134,18 +134,7 @@ static dev_info_t dev_info = "sedlbauer_cs"; device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list = NULL; - /* - A dev_link_t structure has fields for most things that are needed - to keep track of a socket, but there will usually be some device - specific information that also needs to be kept track of. The - 'priv' pointer in a dev_link_t structure can be used to point to - a device-specific private data structure, like this. - - To simplify the data structure handling, we actually include the - dev_link_t structure in the device's private data structure. - A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -222,8 +211,7 @@ static dev_link_t *sedlbauer_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -249,23 +237,14 @@ static dev_link_t *sedlbauer_attach(void) static void sedlbauer_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; DEBUG(0, "sedlbauer_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; if (link->state & DEV_CONFIG) { - ((local_info_t *)link->priv)->stop = 1; - sedlbauer_release(link); + ((local_info_t *)link->priv)->stop = 1; + sedlbauer_release(link); } - /* Unlink device structure, and free it */ - *linkp = link->next; /* This points to the parent local_info_t struct */ kfree(link->priv); } /* sedlbauer_detach */ @@ -623,7 +602,6 @@ static int __init init_sedlbauer_cs(void) static void __exit exit_sedlbauer_cs(void) { pcmcia_unregister_driver(&sedlbauer_driver); - BUG_ON(dev_list != NULL); } module_init(init_sedlbauer_cs); diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index cd0f86f..f956fce 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c @@ -107,18 +107,7 @@ static dev_info_t dev_info = "teles_cs"; device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list = NULL; - /* - A dev_link_t structure has fields for most things that are needed - to keep track of a socket, but there will usually be some device - specific information that also needs to be kept track of. The - 'priv' pointer in a dev_link_t structure can be used to point to - a device-specific private data structure, like this. - - To simplify the data structure handling, we actually include the - dev_link_t structure in the device's private data structure. - A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -189,8 +178,7 @@ static dev_link_t *teles_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -216,24 +204,15 @@ static dev_link_t *teles_attach(void) static void teles_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; local_info_t *info = link->priv; DEBUG(0, "teles_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->state & DEV_CONFIG) { - info->busy = 1; - teles_cs_release(link); + info->busy = 1; + teles_cs_release(link); } - /* Unlink device structure and free it */ - *linkp = link->next; kfree(info); } /* teles_detach */ @@ -506,7 +485,6 @@ static int __init init_teles_cs(void) static void __exit exit_teles_cs(void) { pcmcia_unregister_driver(&teles_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_teles_cs); diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 3ddcb1b..93c05df 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c @@ -67,7 +67,6 @@ struct pcmciamtd_dev { static dev_info_t dev_info = "pcmciamtd"; -static dev_link_t *dev_list; /* Module parameters */ @@ -782,8 +781,7 @@ static dev_link_t *pcmciamtd_attach(void) link->conf.Attributes = 0; link->conf.IntType = INT_MEMORY; - link->next = dev_list; - dev_list = link; + link->next = NULL; /* Register with Card Services */ client_reg.dev_info = &dev_info; @@ -865,7 +863,6 @@ static void __exit exit_pcmciamtd(void) { DEBUG(1, DRIVER_DESC " unloading"); pcmcia_unregister_driver(&pcmciamtd_driver); - BUG_ON(dev_list != NULL); } module_init(init_pcmciamtd); diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 60a3bc2..8fcb636 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c @@ -255,8 +255,6 @@ static dev_info_t dev_info = "3c574_cs"; static dev_link_t *tc574_attach(void); static void tc574_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list; - /* tc574_attach() creates an "instance" of the driver, allocating local data structures for one device. The device is registered @@ -308,8 +306,7 @@ static dev_link_t *tc574_attach(void) #endif /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -336,24 +333,15 @@ static void tc574_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; DEBUG(0, "3c574_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->dev) unregister_netdev(dev); if (link->state & DEV_CONFIG) tc574_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; free_netdev(dev); } /* tc574_detach */ @@ -1310,7 +1298,6 @@ static int __init init_tc574(void) static void __exit exit_tc574(void) { pcmcia_unregister_driver(&tc574_driver); - BUG_ON(dev_list != NULL); } module_init(init_tc574); diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 09b96c7..3516c02 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c @@ -166,8 +166,6 @@ static dev_info_t dev_info = "3c589_cs"; static dev_link_t *tc589_attach(void); static void tc589_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list; - /*====================================================================== tc589_attach() creates an "instance" of the driver, allocating @@ -222,8 +220,7 @@ static dev_link_t *tc589_attach(void) SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -250,15 +247,8 @@ static void tc589_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; - + DEBUG(0, "3c589_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; if (link->dev) unregister_netdev(dev); @@ -266,8 +256,6 @@ static void tc589_detach(struct pcmcia_device *p_dev) if (link->state & DEV_CONFIG) tc589_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; free_netdev(dev); } /* tc589_detach */ @@ -1085,7 +1073,6 @@ static int __init init_tc589(void) static void __exit exit_tc589(void) { pcmcia_unregister_driver(&tc589_driver); - BUG_ON(dev_list != NULL); } module_init(init_tc589); diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 11f701a..3d36207 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -111,7 +111,6 @@ static dev_link_t *axnet_attach(void); static void axnet_detach(struct pcmcia_device *p_dev); static dev_info_t dev_info = "axnet_cs"; -static dev_link_t *dev_list; static void axdev_setup(struct net_device *dev); static void AX88190_init(struct net_device *dev, int startp); @@ -177,8 +176,7 @@ static dev_link_t *axnet_attach(void) SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -205,24 +203,15 @@ static void axnet_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; DEBUG(0, "axnet_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->dev) unregister_netdev(dev); if (link->state & DEV_CONFIG) axnet_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; free_netdev(dev); } /* axnet_detach */ @@ -896,7 +885,6 @@ static int __init init_axnet_cs(void) static void __exit exit_axnet_cs(void) { pcmcia_unregister_driver(&axnet_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_axnet_cs); diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index 6970888..d48dbd3 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c @@ -128,8 +128,6 @@ static dev_info_t dev_info = "com20020_cs"; static dev_link_t *com20020_attach(void); static void com20020_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list; - /*====================================================================*/ typedef struct com20020_dev_t { @@ -196,8 +194,7 @@ static dev_link_t *com20020_attach(void) link->priv = info; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -230,26 +227,17 @@ static void com20020_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct com20020_dev_t *info = link->priv; - dev_link_t **linkp; - struct net_device *dev; - + struct net_device *dev = info->dev; + DEBUG(1,"detach...\n"); DEBUG(0, "com20020_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - - dev = info->dev; - if (link->dev) { DEBUG(1,"unregister...\n"); unregister_netdev(dev); - + /* * this is necessary because we register our IRQ separately * from card services. @@ -263,7 +251,6 @@ static void com20020_detach(struct pcmcia_device *p_dev) /* Unlink device structure, free bits */ DEBUG(1,"unlinking...\n"); - *linkp = link->next; if (link->priv) { dev = info->dev; @@ -507,7 +494,6 @@ static int __init init_com20020_cs(void) static void __exit exit_com20020_cs(void) { pcmcia_unregister_driver(&com20020_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_com20020_cs); diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 560d4ee..dad6393 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -109,7 +109,6 @@ static void fjn_tx_timeout(struct net_device *dev); static struct ethtool_ops netdev_ethtool_ops; static dev_info_t dev_info = "fmvj18x_cs"; -static dev_link_t *dev_list; /* card type @@ -283,8 +282,7 @@ static dev_link_t *fmvj18x_attach(void) SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -304,15 +302,8 @@ static void fmvj18x_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; - + DEBUG(0, "fmvj18x_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; if (link->dev) unregister_netdev(dev); @@ -320,8 +311,6 @@ static void fmvj18x_detach(struct pcmcia_device *p_dev) if (link->state & DEV_CONFIG) fmvj18x_release(link); - /* Unlink device structure, free pieces */ - *linkp = link->next; free_netdev(dev); } /* fmvj18x_detach */ @@ -807,7 +796,6 @@ static int __init init_fmvj18x_cs(void) static void __exit exit_fmvj18x_cs(void) { pcmcia_unregister_driver(&fmvj18x_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_fmvj18x_cs); diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index 9612949..90da35d 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -116,8 +116,6 @@ static dev_info_t dev_info = "ibmtr_cs"; static dev_link_t *ibmtr_attach(void); static void ibmtr_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list; - /*====================================================================*/ typedef struct ibmtr_dev_t { @@ -186,8 +184,7 @@ static dev_link_t *ibmtr_attach(void) SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -219,19 +216,10 @@ static void ibmtr_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct ibmtr_dev_t *info = link->priv; - dev_link_t **linkp; - struct net_device *dev; + struct net_device *dev = info->dev; DEBUG(0, "ibmtr_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - - dev = info->dev; - if (link->dev) unregister_netdev(dev); @@ -242,10 +230,8 @@ static void ibmtr_detach(struct pcmcia_device *p_dev) if (link->state & DEV_CONFIG) ibmtr_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; free_netdev(dev); - kfree(info); + kfree(info); } /* ibmtr_detach */ /*====================================================================== @@ -530,7 +516,6 @@ static int __init init_ibmtr_cs(void) static void __exit exit_ibmtr_cs(void) { pcmcia_unregister_driver(&ibmtr_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_ibmtr_cs); diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index 011ceb0..0c9cb9f 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c @@ -389,7 +389,6 @@ DRV_NAME " " DRV_VERSION " (Roger C. Pao)"; #endif static dev_info_t dev_info="nmclan_cs"; -static dev_link_t *dev_list; static char *if_names[]={ "Auto", "10baseT", "BNC", @@ -498,8 +497,7 @@ static dev_link_t *nmclan_attach(void) #endif /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -525,24 +523,15 @@ static void nmclan_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; DEBUG(0, "nmclan_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->dev) unregister_netdev(dev); if (link->state & DEV_CONFIG) nmclan_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; free_netdev(dev); } /* nmclan_detach */ @@ -1700,7 +1689,6 @@ static int __init init_nmclan_cs(void) static void __exit exit_nmclan_cs(void) { pcmcia_unregister_driver(&nmclan_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_nmclan_cs); diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index fb3e411..b35c951 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -124,7 +124,6 @@ static dev_link_t *pcnet_attach(void); static void pcnet_detach(struct pcmcia_device *p_dev); static dev_info_t dev_info = "pcnet_cs"; -static dev_link_t *dev_list; /*====================================================================*/ @@ -272,8 +271,7 @@ static dev_link_t *pcnet_attach(void) dev->set_config = &set_config; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -300,24 +298,15 @@ static void pcnet_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; DEBUG(0, "pcnet_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->dev) unregister_netdev(dev); if (link->state & DEV_CONFIG) pcnet_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; free_netdev(dev); } /* pcnet_detach */ @@ -1864,7 +1853,6 @@ static void __exit exit_pcnet_cs(void) { DEBUG(0, "pcnet_cs: unloading\n"); pcmcia_unregister_driver(&pcnet_driver); - BUG_ON(dev_list != NULL); } module_init(init_pcnet_cs); diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 6cb5198..9eb5cec 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -104,8 +104,6 @@ static const char *version = static dev_info_t dev_info = "smc91c92_cs"; -static dev_link_t *dev_list; - struct smc_private { dev_link_t link; spinlock_t lock; @@ -367,8 +365,7 @@ static dev_link_t *smc91c92_attach(void) smc->mii_if.reg_num_mask = 0x1f; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -395,24 +392,15 @@ static void smc91c92_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; DEBUG(0, "smc91c92_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->dev) unregister_netdev(dev); if (link->state & DEV_CONFIG) smc91c92_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; free_netdev(dev); } /* smc91c92_detach */ @@ -2377,7 +2365,6 @@ static int __init init_smc91c92_cs(void) static void __exit exit_smc91c92_cs(void) { pcmcia_unregister_driver(&smc91c92_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_smc91c92_cs); diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index 804e567..8c8cc40 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -331,15 +331,7 @@ static dev_info_t dev_info = "xirc2ps_cs"; * device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list; - /**************** - * A dev_link_t structure has fields for most things that are needed - * to keep track of a socket, but there will usually be some device - * specific information that also needs to be kept track of. The - * 'priv' pointer in a dev_link_t structure can be used to point to - * a device-specific private data structure, like this. - * * A driver needs to provide a dev_node_t structure for each device * on a card. In some cases, there is only one device per card (for * example, ethernet cards, modems). In other cases, there may be @@ -615,8 +607,7 @@ xirc2ps_attach(void) #endif /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -641,27 +632,15 @@ xirc2ps_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct net_device *dev = link->priv; - dev_link_t **linkp; DEBUG(0, "detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (!*linkp) { - DEBUG(0, "detach(0x%p): dev_link lost\n", link); - return; - } - if (link->dev) unregister_netdev(dev); if (link->state & DEV_CONFIG) xirc2ps_release(link); - /* Unlink device structure, free it */ - *linkp = link->next; free_netdev(dev); } /* xirc2ps_detach */ @@ -2020,7 +1999,6 @@ static void __exit exit_xirc2ps_cs(void) { pcmcia_unregister_driver(&xirc2ps_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_xirc2ps_cs); diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index 7a28139..88805a4 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -119,15 +119,7 @@ static dev_info_t dev_info = "airo_cs"; device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list = NULL; - /* - A dev_link_t structure has fields for most things that are needed - to keep track of a socket, but there will usually be some device - specific information that also needs to be kept track of. The - 'priv' pointer in a dev_link_t structure can be used to point to - a device-specific private data structure, like this. - A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -202,8 +194,7 @@ static dev_link_t *airo_attach(void) link->priv = local; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -229,29 +220,19 @@ static dev_link_t *airo_attach(void) static void airo_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; - + DEBUG(0, "airo_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - + if (link->state & DEV_CONFIG) airo_release(link); - + if ( ((local_info_t*)link->priv)->eth_dev ) { stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); } ((local_info_t*)link->priv)->eth_dev = NULL; - /* Unlink device structure, free pieces */ - *linkp = link->next; kfree(link->priv); kfree(link); - } /* airo_detach */ /*====================================================================== @@ -574,7 +555,6 @@ static int airo_cs_init(void) static void airo_cs_cleanup(void) { pcmcia_unregister_driver(&airo_driver); - BUG_ON(dev_list != NULL); } /* diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index 3ab33dd..32f0097 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -130,15 +130,7 @@ static dev_info_t dev_info = "atmel_cs"; device numbers are used to derive the corresponding array index. */ -static dev_link_t *dev_list = NULL; - /* - A dev_link_t structure has fields for most things that are needed - to keep track of a socket, but there will usually be some device - specific information that also needs to be kept track of. The - 'priv' pointer in a dev_link_t structure can be used to point to - a device-specific private data structure, like this. - A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -213,8 +205,7 @@ static dev_link_t *atmel_attach(void) link->priv = local; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -240,21 +231,12 @@ static dev_link_t *atmel_attach(void) static void atmel_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; - + DEBUG(0, "atmel_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; if (link->state & DEV_CONFIG) atmel_release(link); - - /* Unlink device structure, free pieces */ - *linkp = link->next; + kfree(link->priv); kfree(link); } @@ -596,7 +578,6 @@ static int atmel_cs_init(void) static void atmel_cs_cleanup(void) { pcmcia_unregister_driver(&atmel_driver); - BUG_ON(dev_list != NULL); } /* diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 866142a..195a5bf3 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -25,7 +25,6 @@ static char *version = PRISM2_VERSION " (Jouni Malinen )"; static dev_info_t dev_info = "hostap_cs"; -static dev_link_t *dev_list = NULL; MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN " @@ -520,8 +519,7 @@ static dev_link_t *prism2_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* register with CardServices */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -538,24 +536,13 @@ static dev_link_t *prism2_attach(void) static void prism2_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; PDEBUG(DEBUG_FLOW, "prism2_detach\n"); - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp == NULL) { - printk(KERN_WARNING "%s: Attempt to detach non-existing " - "PCMCIA client\n", dev_info); - return; - } - if (link->state & DEV_CONFIG) { prism2_release((u_long)link); } - *linkp = link->next; /* release net devices */ if (link->priv) { struct hostap_cs_priv *hw_priv; diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 1770677..af9a32d 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c @@ -228,17 +228,6 @@ static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev); static void set_multicast_list(struct net_device *dev); /* - A linked list of "instances" of the skeleton device. Each actual - PCMCIA card corresponds to one device instance, and is described - by one dev_link_t structure (defined in ds.h). - - You may not want to use a linked list for this -- for example, the - memory card driver uses an array of dev_link_t pointers, where minor - device numbers are used to derive the corresponding array index. -*/ -static dev_link_t *dev_list; - -/* A dev_link_t structure has fields for most things that are needed to keep track of a socket, but there will usually be some device specific information that also needs to be kept track of. The @@ -451,8 +440,7 @@ static dev_link_t *netwave_attach(void) link->irq.Instance = dev; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -476,37 +464,18 @@ static dev_link_t *netwave_attach(void) */ static void netwave_detach(struct pcmcia_device *p_dev) { - dev_link_t *link = dev_to_instance(p_dev); - struct net_device *dev = link->priv; - dev_link_t **linkp; + dev_link_t *link = dev_to_instance(p_dev); + struct net_device *dev = link->priv; - DEBUG(0, "netwave_detach(0x%p)\n", link); - - /* - If the device is currently configured and active, we won't - actually delete it yet. Instead, it is marked so that when - the release() function is called, that will trigger a proper - detach(). - */ - if (link->state & DEV_CONFIG) - netwave_release(link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - { - DEBUG(1, "netwave_cs: detach fail, '%s' not in list\n", - link->dev->dev_name); - return; - } - - /* Unlink device structure, free pieces */ - *linkp = link->next; - if (link->dev) - unregister_netdev(dev); - free_netdev(dev); - + DEBUG(0, "netwave_detach(0x%p)\n", link); + + if (link->state & DEV_CONFIG) + netwave_release(link); + + if (link->dev) + unregister_netdev(dev); + + free_netdev(dev); } /* netwave_detach */ /* @@ -1503,7 +1472,6 @@ static int __init init_netwave_cs(void) static void __exit exit_netwave_cs(void) { pcmcia_unregister_driver(&netwave_driver); - BUG_ON(dev_list != NULL); } module_init(init_netwave_cs); diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 00679b6..bfeeef4 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -69,12 +69,6 @@ struct orinoco_pccard { unsigned long hard_reset_in_progress; }; -/* - * A linked list of "instances" of the device. Each actual PCMCIA - * card corresponds to one device instance, and is described by one - * dev_link_t structure (defined in ds.h). - */ -static dev_link_t *dev_list; /* = NULL */ /********************************************************************/ /* Function prototypes */ @@ -154,9 +148,7 @@ orinoco_cs_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - /* FIXME: need a lock? */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; /* FIXME: what does this mean? */ @@ -181,21 +173,11 @@ orinoco_cs_attach(void) static void orinoco_cs_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; struct net_device *dev = link->priv; - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - - BUG_ON(*linkp == NULL); - if (link->state & DEV_CONFIG) orinoco_cs_release(link); - /* Unlink device structure, and free it */ - *linkp = link->next; DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); if (link->dev) { DEBUG(0, PFX "About to unregister net device %p\n", @@ -678,7 +660,6 @@ static void __exit exit_orinoco_cs(void) { pcmcia_unregister_driver(&orinoco_driver); - BUG_ON(dev_list != NULL); } module_init(init_orinoco_cs); diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index a2dcab7..1933250 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c @@ -78,13 +78,6 @@ struct orinoco_pccard { dev_node_t node; }; -/* - * A linked list of "instances" of the device. Each actual PCMCIA - * card corresponds to one device instance, and is described by one - * dev_link_t structure (defined in ds.h). - */ -static dev_link_t *dev_list; /* = NULL */ - /********************************************************************/ /* Function prototypes */ /********************************************************************/ @@ -637,8 +630,7 @@ spectrum_cs_attach(void) /* Register with Card Services */ /* FIXME: need a lock? */ - link->next = dev_list; - dev_list = link; + link->next = NULL; /* not needed */ client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; /* FIXME: what does this mean? */ @@ -1049,7 +1041,6 @@ static void __exit exit_spectrum_cs(void) { pcmcia_unregister_driver(&orinoco_driver); - BUG_ON(dev_list != NULL); } module_init(init_spectrum_cs); diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 255952d..196e827 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c @@ -4627,8 +4627,7 @@ wavelan_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Chain drivers */ - link->next = dev_list; - dev_list = link; + link->next = NULL; /* Allocate the generic data structure */ dev = alloc_etherdev(sizeof(net_local)); @@ -4731,27 +4730,6 @@ wavelan_detach(struct pcmcia_device *p_dev) wv_pcmcia_release(link); } - /* Remove the interface data from the linked list */ - if(dev_list == link) - dev_list = link->next; - else - { - dev_link_t * prev = dev_list; - - while((prev != (dev_link_t *) NULL) && (prev->next != link)) - prev = prev->next; - - if(prev == (dev_link_t *) NULL) - { -#ifdef DEBUG_CONFIG_ERRORS - printk(KERN_WARNING "wavelan_detach : Attempting to remove a nonexistent device.\n"); -#endif - return; - } - - prev->next = link->next; - } - /* Free pieces */ if(link->priv) { diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h index 3cb3481..a1a1917 100644 --- a/drivers/net/wireless/wavelan_cs.p.h +++ b/drivers/net/wireless/wavelan_cs.p.h @@ -766,7 +766,6 @@ static int /**************************** VARIABLES ****************************/ static dev_info_t dev_info = "wavelan_cs"; -static dev_link_t *dev_list = NULL; /* Linked list of devices */ /* * Parameters that can be set with 'insmod' diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 063d22d..763f91a 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c @@ -95,7 +95,6 @@ static int parport_event(event_t event, int priority, event_callback_args_t *args); static dev_info_t dev_info = "parport_cs"; -static dev_link_t *dev_list = NULL; /*====================================================================== @@ -129,8 +128,7 @@ static dev_link_t *parport_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -156,21 +154,12 @@ static dev_link_t *parport_attach(void) static void parport_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; DEBUG(0, "parport_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - if (link->state & DEV_CONFIG) parport_cs_release(link); - /* Unlink, free device structure */ - *linkp = link->next; kfree(link->priv); } /* parport_detach */ @@ -391,7 +380,6 @@ static int __init init_parport_cs(void) static void __exit exit_parport_cs(void) { pcmcia_unregister_driver(&parport_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_parport_cs); diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index 5842c93..538fedb 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -87,8 +87,6 @@ static dev_link_t *fdomain_attach(void); static void fdomain_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; - static dev_info_t dev_info = "fdomain_cs"; static dev_link_t *fdomain_attach(void) @@ -116,8 +114,7 @@ static dev_link_t *fdomain_attach(void) link->conf.Present = PRESENT_OPTION; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -135,24 +132,14 @@ static dev_link_t *fdomain_attach(void) static void fdomain_detach(struct pcmcia_device *p_dev) { - dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; + dev_link_t *link = dev_to_instance(p_dev); - DEBUG(0, "fdomain_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; - - if (link->state & DEV_CONFIG) - fdomain_release(link); - - /* Unlink device structure, free bits */ - *linkp = link->next; - kfree(link->priv); - + DEBUG(0, "fdomain_detach(0x%p)\n", link); + + if (link->state & DEV_CONFIG) + fdomain_release(link); + + kfree(link->priv); } /* fdomain_detach */ /*====================================================================*/ @@ -324,7 +311,6 @@ static int __init init_fdomain_cs(void) static void __exit exit_fdomain_cs(void) { pcmcia_unregister_driver(&fdomain_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_fdomain_cs); diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index e40a8c2..e48e9fb 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -104,7 +104,6 @@ static struct scsi_host_template nsp_driver_template = { #endif }; -static dev_link_t *dev_list = NULL; static dev_info_t dev_info = {"nsp_cs"}; static nsp_hw_data nsp_data_base; /* attach <-> detect glue */ @@ -1638,8 +1637,7 @@ static dev_link_t *nsp_cs_attach(void) /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -1665,30 +1663,16 @@ static dev_link_t *nsp_cs_attach(void) static void nsp_cs_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) { - if (*linkp == link) { - break; - } - } - if (*linkp == NULL) { - return; - } - if (link->state & DEV_CONFIG) { ((scsi_info_t *)link->priv)->stop = 1; nsp_cs_release(link); } - /* Unlink device structure, free bits */ - *linkp = link->next; kfree(link->priv); link->priv = NULL; - } /* nsp_cs_detach */ @@ -2168,7 +2152,6 @@ static void __exit nsp_cs_exit(void) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68)) pcmcia_unregister_driver(&nsp_driver); - BUG_ON(dev_list != NULL); #else unregister_pcmcia_driver(&dev_info); /* XXX: this really needs to move into generic code.. */ diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index 8351dc2..e10281a 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -104,8 +104,6 @@ static dev_link_t *qlogic_attach(void); static void qlogic_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; - static dev_info_t dev_info = "qlogic_cs"; static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host, @@ -190,8 +188,7 @@ static dev_link_t *qlogic_attach(void) link->conf.Present = PRESENT_OPTION; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -210,22 +207,12 @@ static dev_link_t *qlogic_attach(void) static void qlogic_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; DEBUG(0, "qlogic_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp == NULL) - return; - if (link->state & DEV_CONFIG) qlogic_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; kfree(link->priv); } /* qlogic_detach */ @@ -439,7 +426,6 @@ static int __init init_qlogic_cs(void) static void __exit exit_qlogic_cs(void) { pcmcia_unregister_driver(&qlogic_cs_driver); - BUG_ON(dev_list != NULL); } MODULE_AUTHOR("Tom Zerucha, Michael Griffith"); diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index a0f8e269..87d50b3 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -232,7 +232,6 @@ enum Phase { * Global (within this module) variables other than * sym53c500_driver_template (the scsi_host_template). */ -static dev_link_t *dev_list; static dev_info_t dev_info = "sym53c500_cs"; /* ================================================================== */ @@ -930,22 +929,12 @@ static void SYM53C500_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; DEBUG(0, "SYM53C500_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp == NULL) - return; - if (link->state & DEV_CONFIG) SYM53C500_release(link); - /* Unlink device structure, free bits. */ - *linkp = link->next; kfree(link->priv); link->priv = NULL; } /* SYM53C500_detach */ @@ -978,8 +967,7 @@ SYM53C500_attach(void) link->conf.Present = PRESENT_OPTION; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index a953663..6e7a1a0 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -122,8 +122,6 @@ static dev_info_t dev_info = "serial_cs"; static dev_link_t *serial_attach(void); static void serial_detach(struct pcmcia_device *p_dev); -static dev_link_t *dev_list = NULL; - /*====================================================================== After a card is removed, serial_remove() will unregister @@ -234,8 +232,7 @@ static dev_link_t *serial_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; /* not needed */ client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -262,17 +259,9 @@ static void serial_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); struct serial_info *info = link->priv; - dev_link_t **linkp; DEBUG(0, "serial_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp == NULL) - return; - /* * Ensure any outstanding scheduled tasks are completed. */ @@ -283,8 +272,7 @@ static void serial_detach(struct pcmcia_device *p_dev) */ serial_remove(link); - /* Unlink device structure, free bits */ - *linkp = link->next; + /* free bits */ kfree(info); } @@ -871,7 +859,6 @@ static int __init init_serial_cs(void) static void __exit exit_serial_cs(void) { pcmcia_unregister_driver(&serial_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_serial_cs); diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index c58140d..6b99298 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -40,7 +40,6 @@ static void ixj_config(dev_link_t * link); static void ixj_cs_release(dev_link_t * link); static int ixj_event(event_t event, int priority, event_callback_args_t * args); static dev_info_t dev_info = "ixj_cs"; -static dev_link_t *dev_list = NULL; static dev_link_t *ixj_attach(void) { @@ -65,8 +64,7 @@ static dev_link_t *ixj_attach(void) } memset(link->priv, 0, sizeof(struct ixj_info_t)); /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = &dev_info; client_reg.Version = 0x0210; client_reg.event_callback_args.client_data = link; @@ -82,20 +80,13 @@ static dev_link_t *ixj_attach(void) static void ixj_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; DEBUG(0, "ixj_detach(0x%p)\n", link); - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp == NULL) - return; + link->state &= ~DEV_RELEASE_PENDING; if (link->state & DEV_CONFIG) ixj_cs_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; kfree(link->priv); kfree(link); } @@ -314,7 +305,6 @@ static int __init ixj_pcmcia_init(void) static void ixj_pcmcia_exit(void) { pcmcia_unregister_driver(&ixj_driver); - BUG_ON(dev_list != NULL); } module_init(ixj_pcmcia_init); diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index ed3e701..4397096 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -66,8 +66,6 @@ module_param(pc_debug, int, 0644); static const char driver_name[DEV_NAME_LEN] = "sl811_cs"; -static dev_link_t *dev_list = NULL; - typedef struct local_info_t { dev_link_t link; dev_node_t node; @@ -143,24 +141,13 @@ static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) static void sl811_cs_detach(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); - dev_link_t **linkp; DBG(0, "sl811_cs_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) { - if (*linkp == link) - break; - } - if (*linkp == NULL) - return; - link->state &= ~DEV_PRESENT; if (link->state & DEV_CONFIG) sl811_cs_release(link); - /* Unlink device structure, and free it */ - *linkp = link->next; /* This points to the parent local_info_t struct */ kfree(link->priv); } @@ -378,8 +365,7 @@ static dev_link_t *sl811_cs_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; /* Register with Card Services */ - link->next = dev_list; - dev_list = link; + link->next = NULL; client_reg.dev_info = (dev_info_t *) &driver_name; client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; client_reg.Version = 0x0210; -- cgit v1.1 From f8cfa618dccbdc6dab5297f75779566a388a98fd Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 14 Nov 2005 21:25:51 +0100 Subject: [PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback Unify the EVENT_CARD_INSERTION and "attach" callbacks to one unified probe() callback. As all in-kernel drivers are changed to this new callback, there will be no temporary backwards-compatibility. Inside a probe() function, each driver _must_ set struct pcmcia_device *p_dev->instance and instance->handle correctly. With these patches, the basic driver interface for 16-bit PCMCIA drivers now has the classic four callbacks known also from other buses: int (*probe) (struct pcmcia_device *dev); void (*remove) (struct pcmcia_device *dev); int (*suspend) (struct pcmcia_device *dev); int (*resume) (struct pcmcia_device *dev); Signed-off-by: Dominik Brodowski --- Documentation/pcmcia/driver-changes.txt | 6 +- drivers/bluetooth/bluecard_cs.c | 46 ++------- drivers/bluetooth/bt3c_cs.c | 45 ++------ drivers/bluetooth/btuart_cs.c | 46 ++------- drivers/bluetooth/dtl1_cs.c | 45 ++------ drivers/char/pcmcia/cm4000_cs.c | 68 ++---------- drivers/char/pcmcia/cm4040_cs.c | 67 ++---------- drivers/char/pcmcia/synclink_cs.c | 49 ++------- drivers/ide/legacy/ide-cs.c | 56 +++------- drivers/isdn/hardware/avm/avm_cs.c | 56 +++------- drivers/isdn/hisax/avma1_cs.c | 70 ++----------- drivers/isdn/hisax/elsa_cs.c | 78 ++------------ drivers/isdn/hisax/sedlbauer_cs.c | 75 ++------------ drivers/isdn/hisax/teles_cs.c | 67 ++---------- drivers/mtd/maps/pcmciamtd.c | 54 ++-------- drivers/net/pcmcia/3c574_cs.c | 55 ++-------- drivers/net/pcmcia/3c589_cs.c | 63 +++--------- drivers/net/pcmcia/axnet_cs.c | 59 ++--------- drivers/net/pcmcia/com20020_cs.c | 59 ++--------- drivers/net/pcmcia/fmvj18x_cs.c | 54 +++------- drivers/net/pcmcia/ibmtr_cs.c | 69 +++---------- drivers/net/pcmcia/nmclan_cs.c | 57 ++-------- drivers/net/pcmcia/pcnet_cs.c | 45 ++------ drivers/net/pcmcia/smc91c92_cs.c | 57 ++-------- drivers/net/pcmcia/xirc2ps_cs.c | 67 ++---------- drivers/net/wireless/airo_cs.c | 74 +++---------- drivers/net/wireless/atmel_cs.c | 80 +++------------ drivers/net/wireless/hostap/hostap_cs.c | 55 +++------- drivers/net/wireless/netwave_cs.c | 68 +++--------- drivers/net/wireless/orinoco_cs.c | 58 ++--------- drivers/net/wireless/ray_cs.c | 68 ++---------- drivers/net/wireless/spectrum_cs.c | 63 ++---------- drivers/net/wireless/wavelan_cs.c | 84 +++------------ drivers/net/wireless/wavelan_cs.p.h | 8 -- drivers/net/wireless/wl3501_cs.c | 60 ++--------- drivers/parport/parport_cs.c | 61 +++-------- drivers/pcmcia/ds.c | 177 +++++--------------------------- drivers/scsi/pcmcia/aha152x_stub.c | 52 ++-------- drivers/scsi/pcmcia/fdomain_stub.c | 56 +++------- drivers/scsi/pcmcia/nsp_cs.c | 67 ++---------- drivers/scsi/pcmcia/nsp_cs.h | 2 - drivers/scsi/pcmcia/qlogic_stub.c | 49 ++------- drivers/scsi/pcmcia/sym53c500_cs.c | 53 ++-------- drivers/serial/serial_cs.c | 58 ++--------- drivers/telephony/ixj_pcmcia.c | 48 +++------ drivers/usb/host/sl811_cs.c | 44 ++------ include/pcmcia/cs.h | 1 - include/pcmcia/ds.h | 6 +- 48 files changed, 472 insertions(+), 2233 deletions(-) diff --git a/Documentation/pcmcia/driver-changes.txt b/Documentation/pcmcia/driver-changes.txt index 45c25c7..97420f0 100644 --- a/Documentation/pcmcia/driver-changes.txt +++ b/Documentation/pcmcia/driver-changes.txt @@ -1,7 +1,9 @@ This file details changes in 2.6 which affect PCMCIA card driver authors: -* Unify detach and REMOVAL event code (as of 2.6.16) - void (*remove) (struct pcmcia_device *dev); +* Unify detach and REMOVAL event code, as well as attach and INSERTION + code (as of 2.6.16) + void (*remove) (struct pcmcia_device *dev); + int (*probe) (struct pcmcia_device *dev); * Move suspend, resume and reset out of event handler (as of 2.6.16) int (*suspend) (struct pcmcia_device *dev); diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index bd80535..9888bc1 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -87,11 +87,7 @@ typedef struct bluecard_info_t { static void bluecard_config(dev_link_t *link); static void bluecard_release(dev_link_t *link); -static int bluecard_event(event_t event, int priority, event_callback_args_t *args); -static dev_info_t dev_info = "bluecard_cs"; - -static dev_link_t *bluecard_attach(void); static void bluecard_detach(struct pcmcia_device *p_dev); @@ -860,17 +856,15 @@ static int bluecard_close(bluecard_info_t *info) return 0; } -static dev_link_t *bluecard_attach(void) +static int bluecard_attach(struct pcmcia_device *p_dev) { bluecard_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; /* Create new info device */ info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; link = &info->link; link->priv = info; @@ -887,20 +881,13 @@ static dev_link_t *bluecard_attach(void) link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - bluecard_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + bluecard_config(link); - return link; + return 0; } @@ -1046,20 +1033,6 @@ static int bluecard_resume(struct pcmcia_device *dev) return 0; } -static int bluecard_event(event_t event, int priority, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - bluecard_config(link); - break; - } - - return 0; -} - static struct pcmcia_device_id bluecard_ids[] = { PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e), PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c), @@ -1073,8 +1046,7 @@ static struct pcmcia_driver bluecard_driver = { .drv = { .name = "bluecard_cs", }, - .attach = bluecard_attach, - .event = bluecard_event, + .probe = bluecard_attach, .remove = bluecard_detach, .id_table = bluecard_ids, .suspend = bluecard_suspend, diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 50aa52b..e522d19 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -90,11 +90,7 @@ typedef struct bt3c_info_t { static void bt3c_config(dev_link_t *link); static void bt3c_release(dev_link_t *link); -static int bt3c_event(event_t event, int priority, event_callback_args_t *args); -static dev_info_t dev_info = "bt3c_cs"; - -static dev_link_t *bt3c_attach(void); static void bt3c_detach(struct pcmcia_device *p_dev); @@ -661,17 +657,15 @@ static int bt3c_close(bt3c_info_t *info) return 0; } -static dev_link_t *bt3c_attach(void) +static int bt3c_attach(struct pcmcia_device *p_dev) { bt3c_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; /* Create new info device */ info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; link = &info->link; link->priv = info; @@ -688,20 +682,13 @@ static dev_link_t *bt3c_attach(void) link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - bt3c_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + bt3c_config(link); + + return 0; } @@ -892,19 +879,6 @@ static int bt3c_resume(struct pcmcia_device *dev) return 0; } -static int bt3c_event(event_t event, int priority, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - bt3c_config(link); - break; - } - - return 0; -} static struct pcmcia_device_id bt3c_ids[] = { PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02), @@ -917,8 +891,7 @@ static struct pcmcia_driver bt3c_driver = { .drv = { .name = "bt3c_cs", }, - .attach = bt3c_attach, - .event = bt3c_event, + .probe = bt3c_attach, .remove = bt3c_detach, .id_table = bt3c_ids, .suspend = bt3c_suspend, diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 7b04f89..7b4bff4 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -86,11 +86,7 @@ typedef struct btuart_info_t { static void btuart_config(dev_link_t *link); static void btuart_release(dev_link_t *link); -static int btuart_event(event_t event, int priority, event_callback_args_t *args); -static dev_info_t dev_info = "btuart_cs"; - -static dev_link_t *btuart_attach(void); static void btuart_detach(struct pcmcia_device *p_dev); @@ -580,17 +576,15 @@ static int btuart_close(btuart_info_t *info) return 0; } -static dev_link_t *btuart_attach(void) +static int btuart_attach(struct pcmcia_device *p_dev) { btuart_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; /* Create new info device */ info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; link = &info->link; link->priv = info; @@ -607,20 +601,13 @@ static dev_link_t *btuart_attach(void) link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - btuart_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + btuart_config(link); - return link; + return 0; } @@ -813,20 +800,6 @@ static int btuart_resume(struct pcmcia_device *dev) } -static int btuart_event(event_t event, int priority, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - btuart_config(link); - break; - } - - return 0; -} - static struct pcmcia_device_id btuart_ids[] = { /* don't use this driver. Use serial_cs + hci_uart instead */ PCMCIA_DEVICE_NULL @@ -838,8 +811,7 @@ static struct pcmcia_driver btuart_driver = { .drv = { .name = "btuart_cs", }, - .attach = btuart_attach, - .event = btuart_event, + .probe = btuart_attach, .remove = btuart_detach, .id_table = btuart_ids, .suspend = btuart_suspend, diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index c39d457..787c5eb 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -89,11 +89,7 @@ typedef struct dtl1_info_t { static void dtl1_config(dev_link_t *link); static void dtl1_release(dev_link_t *link); -static int dtl1_event(event_t event, int priority, event_callback_args_t *args); -static dev_info_t dev_info = "dtl1_cs"; - -static dev_link_t *dtl1_attach(void); static void dtl1_detach(struct pcmcia_device *p_dev); @@ -559,17 +555,15 @@ static int dtl1_close(dtl1_info_t *info) return 0; } -static dev_link_t *dtl1_attach(void) +static int dtl1_attach(struct pcmcia_device *p_dev) { dtl1_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; /* Create new info device */ info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; link = &info->link; link->priv = info; @@ -586,20 +580,13 @@ static dev_link_t *dtl1_attach(void) link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - dtl1_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + dtl1_config(link); + + return 0; } @@ -764,19 +751,6 @@ static int dtl1_resume(struct pcmcia_device *dev) return 0; } -static int dtl1_event(event_t event, int priority, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - dtl1_config(link); - break; - } - - return 0; -} static struct pcmcia_device_id dtl1_ids[] = { PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), @@ -790,8 +764,7 @@ static struct pcmcia_driver dtl1_driver = { .drv = { .name = "dtl1_cs", }, - .attach = dtl1_attach, - .event = dtl1_event, + .probe = dtl1_attach, .remove = dtl1_detach, .id_table = dtl1_ids, .suspend = dtl1_suspend, diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 8a064f2..649677b 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c @@ -66,7 +66,6 @@ static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte"; #define T_100MSEC msecs_to_jiffies(100) #define T_500MSEC msecs_to_jiffies(500) -static void cm4000_detach(struct pcmcia_device *p_dev); static void cm4000_release(dev_link_t *link); static int major; /* major number we get from the kernel */ @@ -156,7 +155,6 @@ struct cm4000_dev { /*sbuf*/ 512*sizeof(char) - \ /*queue*/ 4*sizeof(wait_queue_head_t)) -static dev_info_t dev_info = MODULE_NAME; static dev_link_t *dev_table[CM4000_MAX_DEV]; /* This table doesn't use spaces after the comma between fields and thus @@ -1864,38 +1862,6 @@ cs_release: link->state &= ~DEV_CONFIG_PENDING; } -static int cm4000_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link; - struct cm4000_dev *dev; - int devno; - - link = args->client_data; - dev = link->priv; - - DEBUGP(3, dev, "-> cm4000_event\n"); - for (devno = 0; devno < CM4000_MAX_DEV; devno++) - if (dev_table[devno] == link) - break; - - if (devno == CM4000_MAX_DEV) - return CS_BAD_ADAPTER; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n"); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - cm4000_config(link, devno); - break; - default: - DEBUGP(5, dev, "unknown event %.2x\n", event); - break; - } - DEBUGP(3, dev, "<- cm4000_event\n"); - return CS_SUCCESS; -} - static int cm4000_suspend(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); @@ -1935,11 +1901,10 @@ static void cm4000_release(dev_link_t *link) pcmcia_release_io(link->handle, &link->io); } -static dev_link_t *cm4000_attach(void) +static int cm4000_attach(struct pcmcia_device *p_dev) { struct cm4000_dev *dev; dev_link_t *link; - client_reg_t client_reg; int i; for (i = 0; i < CM4000_MAX_DEV; i++) @@ -1948,41 +1913,31 @@ static dev_link_t *cm4000_attach(void) if (i == CM4000_MAX_DEV) { printk(KERN_NOTICE MODULE_NAME ": all devices in use\n"); - return NULL; + return -ENODEV; } /* create a new cm4000_cs device */ dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL); if (dev == NULL) - return NULL; + return -ENOMEM; link = &dev->link; link->priv = dev; link->conf.IntType = INT_MEMORY_AND_IO; dev_table[i] = link; - /* register with card services */ - client_reg.dev_info = &dev_info; - client_reg.EventMask = - CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | - CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET | - CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - i = pcmcia_register_client(&link->handle, &client_reg); - if (i) { - cs_error(link->handle, RegisterClient, i); - cm4000_detach(link->handle); - return NULL; - } - init_waitqueue_head(&dev->devq); init_waitqueue_head(&dev->ioq); init_waitqueue_head(&dev->atrq); init_waitqueue_head(&dev->readq); - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + cm4000_config(link, i); + + return 0; } static void cm4000_detach(struct pcmcia_device *p_dev) @@ -2031,11 +1986,10 @@ static struct pcmcia_driver cm4000_driver = { .drv = { .name = "cm4000_cs", }, - .attach = cm4000_attach, + .probe = cm4000_attach, .remove = cm4000_detach, .suspend = cm4000_suspend, .resume = cm4000_resume, - .event = cm4000_event, .id_table = cm4000_ids, }; diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index e08ab94..46eb371 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c @@ -65,7 +65,6 @@ static char *version = #define POLL_PERIOD msecs_to_jiffies(10) static void reader_release(dev_link_t *link); -static void reader_detach(struct pcmcia_device *p_dev); static int major; @@ -86,7 +85,6 @@ struct reader_dev { struct timer_list poll_timer; }; -static dev_info_t dev_info = MODULE_NAME; static dev_link_t *dev_table[CM_MAX_DEV]; #ifndef PCMCIA_DEBUG @@ -629,39 +627,6 @@ cs_release: link->state &= ~DEV_CONFIG_PENDING; } -static int reader_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link; - struct reader_dev *dev; - int devno; - - link = args->client_data; - dev = link->priv; - DEBUGP(3, dev, "-> reader_event\n"); - for (devno = 0; devno < CM_MAX_DEV; devno++) { - if (dev_table[devno] == link) - break; - } - if (devno == CM_MAX_DEV) - return CS_BAD_ADAPTER; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n"); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - reader_config(link, devno); - break; - - default: - DEBUGP(5, dev, "reader_event: unknown event %.2x\n", - event); - break; - } - DEBUGP(3, dev, "<- reader_event\n"); - return CS_SUCCESS; -} - static int reader_suspend(struct pcmcia_device *p_dev) { dev_link_t *link = dev_to_instance(p_dev); @@ -691,11 +656,10 @@ static void reader_release(dev_link_t *link) pcmcia_release_io(link->handle, &link->io); } -static dev_link_t *reader_attach(void) +static int reader_attach(struct pcmcia_device *p_dev) { struct reader_dev *dev; dev_link_t *link; - client_reg_t client_reg; int i; for (i = 0; i < CM_MAX_DEV; i++) { @@ -704,11 +668,11 @@ static dev_link_t *reader_attach(void) } if (i == CM_MAX_DEV) - return NULL; + return -ENODEV; dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL); if (dev == NULL) - return NULL; + return -ENOMEM; dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; dev->buffer_status = 0; @@ -719,20 +683,6 @@ static dev_link_t *reader_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; dev_table[i] = link; - client_reg.dev_info = &dev_info; - client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; - client_reg.EventMask= - CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | - CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET | - CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - i = pcmcia_register_client(&link->handle, &client_reg); - if (i) { - cs_error(link->handle, RegisterClient, i); - reader_detach(link->handle); - return NULL; - } init_waitqueue_head(&dev->devq); init_waitqueue_head(&dev->poll_wait); init_waitqueue_head(&dev->read_wait); @@ -740,7 +690,13 @@ static dev_link_t *reader_attach(void) init_timer(&dev->poll_timer); dev->poll_timer.function = &cm4040_do_poll; - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + reader_config(link, i); + + return 0; } static void reader_detach(struct pcmcia_device *p_dev) @@ -790,11 +746,10 @@ static struct pcmcia_driver reader_driver = { .drv = { .name = "cm4040_cs", }, - .attach = reader_attach, + .probe = reader_attach, .remove = reader_detach, .suspend = reader_suspend, .resume = reader_resume, - .event = reader_event, .id_table = cm4040_ids, }; diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index dc38b1d..cf45b10 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -486,13 +486,8 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout); static void mgslpc_config(dev_link_t *link); static void mgslpc_release(u_long arg); -static int mgslpc_event(event_t event, int priority, - event_callback_args_t *args); -static dev_link_t *mgslpc_attach(void); static void mgslpc_detach(struct pcmcia_device *p_dev); -static dev_info_t dev_info = "synclink_cs"; - /* * 1st function defined in .text section. Calling this function in * init_module() followed by a breakpoint allows a remote debugger @@ -538,12 +533,10 @@ static void ldisc_receive_buf(struct tty_struct *tty, } } -static dev_link_t *mgslpc_attach(void) +static int mgslpc_attach(struct pcmcia_device *p_dev) { MGSLPC_INFO *info; dev_link_t *link; - client_reg_t client_reg; - int ret; if (debug_level >= DEBUG_LEVEL_INFO) printk("mgslpc_attach\n"); @@ -551,7 +544,7 @@ static dev_link_t *mgslpc_attach(void) info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); if (!info) { printk("Error can't allocate device instance data\n"); - return NULL; + return -ENOMEM; } memset(info, 0, sizeof(MGSLPC_INFO)); @@ -586,23 +579,15 @@ static dev_link_t *mgslpc_attach(void) link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; + link->handle = p_dev; + p_dev->instance = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - mgslpc_detach(link->handle); - return NULL; - } + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + mgslpc_config(link); mgslpc_add_device(info); - return link; + return 0; } /* Card has been inserted. @@ -778,23 +763,6 @@ static int mgslpc_resume(struct pcmcia_device *dev) } -static int mgslpc_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - if (debug_level >= DEBUG_LEVEL_INFO) - printk("mgslpc_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - mgslpc_config(link); - break; - } - return 0; -} - static inline int mgslpc_paranoia_check(MGSLPC_INFO *info, char *name, const char *routine) { @@ -3071,8 +3039,7 @@ static struct pcmcia_driver mgslpc_driver = { .drv = { .name = "synclink_cs", }, - .attach = mgslpc_attach, - .event = mgslpc_event, + .probe = mgslpc_attach, .remove = mgslpc_detach, .id_table = mgslpc_ids, .suspend = mgslpc_suspend, diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index c83068d..e36e6fb 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -88,12 +88,8 @@ typedef struct ide_info_t { } ide_info_t; static void ide_release(dev_link_t *); -static int ide_event(event_t event, int priority, - event_callback_args_t *args); +static void ide_config(dev_link_t *); -static dev_info_t dev_info = "ide-cs"; - -static dev_link_t *ide_attach(void); static void ide_detach(struct pcmcia_device *p_dev); @@ -107,18 +103,17 @@ static void ide_detach(struct pcmcia_device *p_dev); ======================================================================*/ -static dev_link_t *ide_attach(void) +static int ide_attach(struct pcmcia_device *p_dev) { ide_info_t *info; dev_link_t *link; - client_reg_t client_reg; - int ret; - + DEBUG(0, "ide_attach()\n"); /* Create new ide device */ info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) return NULL; + if (!info) + return -ENOMEM; link = &info->link; link->priv = info; link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; @@ -129,20 +124,14 @@ static dev_link_t *ide_attach(void) link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - ide_detach(link->handle); - return NULL; - } - - return link; + + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + ide_config(link); + + return 0; } /* ide_attach */ /*====================================================================== @@ -421,22 +410,6 @@ static int ide_resume(struct pcmcia_device *dev) ======================================================================*/ -int ide_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "ide_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - ide_config(link); - break; - } - return 0; -} /* ide_event */ - static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_FUNC_ID(4), PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), @@ -481,8 +454,7 @@ static struct pcmcia_driver ide_cs_driver = { .drv = { .name = "ide-cs", }, - .attach = ide_attach, - .event = ide_event, + .probe = ide_attach, .remove = ide_detach, .id_table = ide_ids, .suspend = ide_suspend, diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index 0a8c1da..2a2b03f 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c @@ -53,8 +53,6 @@ MODULE_LICENSE("GPL"); static void avmcs_config(dev_link_t *link); static void avmcs_release(dev_link_t *link); -static int avmcs_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -62,18 +60,9 @@ static int avmcs_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *avmcs_attach(void); static void avmcs_detach(struct pcmcia_device *p_dev); /* - The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ - -static dev_info_t dev_info = "avm_cs"; - -/* A linked list of "instances" of the skeleton device. Each actual PCMCIA card corresponds to one device instance, and is described by one dev_link_t structure (defined in ds.h). @@ -110,13 +99,11 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *avmcs_attach(void) +static int avmcs_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; local_info_t *local; - int ret; - + /* Initialize the dev_link_t structure */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) @@ -147,24 +134,19 @@ static dev_link_t *avmcs_attach(void) goto err_kfree; memset(local, 0, sizeof(local_info_t)); link->priv = local; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - avmcs_detach(link->handle); - goto err; - } - return link; + + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + avmcs_config(link); + + return 0; err_kfree: kfree(link); err: - return NULL; + return -EINVAL; } /* avmcs_attach */ /*====================================================================== @@ -433,19 +415,6 @@ static int avmcs_resume(struct pcmcia_device *dev) ======================================================================*/ -static int avmcs_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - avmcs_config(link); - break; - } - return 0; -} /* avmcs_event */ static struct pcmcia_device_id avmcs_ids[] = { PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335), @@ -460,8 +429,7 @@ static struct pcmcia_driver avmcs_driver = { .drv = { .name = "avm_cs", }, - .attach = avmcs_attach, - .event = avmcs_event, + .probe = avmcs_attach, .remove = avmcs_detach, .id_table = avmcs_ids, .suspend= avmcs_suspend, diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index b6ea653..969da40 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c @@ -69,8 +69,6 @@ module_param(isdnprot, int, 0); static void avma1cs_config(dev_link_t *link); static void avma1cs_release(dev_link_t *link); -static int avma1cs_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -78,16 +76,8 @@ static int avma1cs_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *avma1cs_attach(void); static void avma1cs_detach(struct pcmcia_device *p_dev); -/* - The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ - -static dev_info_t dev_info = "avma1_cs"; /* A linked list of "instances" of the skeleton device. Each actual @@ -126,26 +116,24 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *avma1cs_attach(void) +static int avma1cs_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; local_info_t *local; - int ret; - + DEBUG(0, "avma1cs_attach()\n"); /* Initialize the dev_link_t structure */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) - return NULL; + return -ENOMEM; memset(link, 0, sizeof(struct dev_link_t)); /* Allocate space for private device-specific data */ local = kmalloc(sizeof(local_info_t), GFP_KERNEL); if (!local) { kfree(link); - return NULL; + return -ENOMEM; } memset(local, 0, sizeof(local_info_t)); link->priv = local; @@ -170,19 +158,13 @@ static dev_link_t *avma1cs_attach(void) link->conf.ConfigIndex = 1; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - avma1cs_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + avma1cs_config(link); - return link; + return 0; } /* avma1cs_attach */ /*====================================================================== @@ -430,35 +412,6 @@ static int avma1cs_resume(struct pcmcia_device *dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - - When a CARD_REMOVAL event is received, we immediately set a flag - to block future accesses to this device. All the functions that - actually access the device should check this flag to make sure - the card is still present. - -======================================================================*/ - -static int avma1cs_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "avma1cs_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - avma1cs_config(link); - break; - } - return 0; -} /* avma1cs_event */ static struct pcmcia_device_id avma1cs_ids[] = { PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb), @@ -472,8 +425,7 @@ static struct pcmcia_driver avma1cs_driver = { .drv = { .name = "avma1_cs", }, - .attach = avma1cs_attach, - .event = avma1cs_event, + .probe = avma1cs_attach, .remove = avma1cs_detach, .id_table = avma1cs_ids, .suspend = avma1cs_suspend, diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index a0c5bad..062fb8f 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c @@ -96,8 +96,6 @@ module_param(protocol, int, 0); static void elsa_cs_config(dev_link_t *link); static void elsa_cs_release(dev_link_t *link); -static int elsa_cs_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -105,28 +103,9 @@ static int elsa_cs_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *elsa_cs_attach(void); static void elsa_cs_detach(struct pcmcia_device *p_dev); /* - The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ - -static dev_info_t dev_info = "elsa_cs"; - -/* - A linked list of "instances" of the elsa_cs device. Each actual - PCMCIA card corresponds to one device instance, and is described - by one dev_link_t structure (defined in ds.h). - - You may not want to use a linked list for this -- for example, the - memory card driver uses an array of dev_link_t pointers, where minor - device numbers are used to derive the corresponding array index. -*/ - -/* A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -160,18 +139,16 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *elsa_cs_attach(void) +static int elsa_cs_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; local_info_t *local; - int ret; DEBUG(0, "elsa_cs_attach()\n"); /* Allocate space for private device-specific data */ local = kmalloc(sizeof(local_info_t), GFP_KERNEL); - if (!local) return NULL; + if (!local) return -ENOMEM; memset(local, 0, sizeof(local_info_t)); local->cardnr = -1; link = &local->link; link->priv = local; @@ -196,19 +173,13 @@ static dev_link_t *elsa_cs_attach(void) link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - elsa_cs_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + elsa_cs_config(link); + + return 0; } /* elsa_cs_attach */ /*====================================================================== @@ -447,36 +418,6 @@ static int elsa_resume(struct pcmcia_device *p_dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - - When a CARD_REMOVAL event is received, we immediately set a flag - to block future accesses to this device. All the functions that - actually access the device should check this flag to make sure - the card is still present. - -======================================================================*/ - -static int elsa_cs_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "elsa_cs_event(%d)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - elsa_cs_config(link); - break; - } - return 0; -} /* elsa_cs_event */ - static struct pcmcia_device_id elsa_ids[] = { PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257), PCMCIA_DEVICE_PROD_ID12("ELSA GmbH, Aachen", "MicroLink ISDN/MC ", 0x639e5718, 0x333ba257), @@ -489,8 +430,7 @@ static struct pcmcia_driver elsa_cs_driver = { .drv = { .name = "elsa_cs", }, - .attach = elsa_cs_attach, - .event = elsa_cs_event, + .probe = elsa_cs_attach, .remove = elsa_cs_detach, .id_table = elsa_ids, .suspend = elsa_suspend, diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 814b32a..6f5213a 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c @@ -97,8 +97,6 @@ module_param(protocol, int, 0); static void sedlbauer_config(dev_link_t *link); static void sedlbauer_release(dev_link_t *link); -static int sedlbauer_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -106,7 +104,6 @@ static int sedlbauer_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *sedlbauer_attach(void); static void sedlbauer_detach(struct pcmcia_device *p_dev); /* @@ -117,24 +114,6 @@ static void sedlbauer_detach(struct pcmcia_device *p_dev); */ /* - The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ - -static dev_info_t dev_info = "sedlbauer_cs"; - -/* - A linked list of "instances" of the sedlbauer device. Each actual - PCMCIA card corresponds to one device instance, and is described - by one dev_link_t structure (defined in ds.h). - - You may not want to use a linked list for this -- for example, the - memory card driver uses an array of dev_link_t pointers, where minor - device numbers are used to derive the corresponding array index. -*/ - -/* A driver needs to provide a dev_node_t structure for each device on a card. In some cases, there is only one device per card (for example, ethernet cards, modems). In other cases, there may be @@ -169,18 +148,16 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *sedlbauer_attach(void) +static int sedlbauer_attach(struct pcmcia_device *p_dev) { local_info_t *local; dev_link_t *link; - client_reg_t client_reg; - int ret; DEBUG(0, "sedlbauer_attach()\n"); /* Allocate space for private device-specific data */ local = kmalloc(sizeof(local_info_t), GFP_KERNEL); - if (!local) return NULL; + if (!local) return -ENOMEM; memset(local, 0, sizeof(local_info_t)); local->cardnr = -1; link = &local->link; link->priv = local; @@ -210,19 +187,13 @@ static dev_link_t *sedlbauer_attach(void) link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - sedlbauer_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + sedlbauer_config(link); + + return 0; } /* sedlbauer_attach */ /*====================================================================== @@ -541,33 +512,6 @@ static int sedlbauer_resume(struct pcmcia_device *p_dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. - - When a CARD_REMOVAL event is received, we immediately set a - private flag to block future accesses to this device. All the - functions that actually access the device should check this flag - to make sure the card is still present. - -======================================================================*/ - -static int sedlbauer_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "sedlbauer_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - sedlbauer_config(link); - break; - } - return 0; -} /* sedlbauer_event */ static struct pcmcia_device_id sedlbauer_ids[] = { PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "speed star II", "V 3.1", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a), @@ -586,8 +530,7 @@ static struct pcmcia_driver sedlbauer_driver = { .drv = { .name = "sedlbauer_cs", }, - .attach = sedlbauer_attach, - .event = sedlbauer_event, + .probe = sedlbauer_attach, .remove = sedlbauer_detach, .id_table = sedlbauer_ids, .suspend = sedlbauer_suspend, diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index f956fce..4e5c14c 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c @@ -77,8 +77,6 @@ module_param(protocol, int, 0); static void teles_cs_config(dev_link_t *link); static void teles_cs_release(dev_link_t *link); -static int teles_cs_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -86,18 +84,9 @@ static int teles_cs_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *teles_attach(void); static void teles_detach(struct pcmcia_device *p_dev); /* - The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ - -static dev_info_t dev_info = "teles_cs"; - -/* A linked list of "instances" of the teles_cs device. Each actual PCMCIA card corresponds to one device instance, and is described by one dev_link_t structure (defined in ds.h). @@ -141,18 +130,16 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *teles_attach(void) +static int teles_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; local_info_t *local; - int ret; DEBUG(0, "teles_attach()\n"); /* Allocate space for private device-specific data */ local = kmalloc(sizeof(local_info_t), GFP_KERNEL); - if (!local) return NULL; + if (!local) return -ENOMEM; memset(local, 0, sizeof(local_info_t)); local->cardnr = -1; link = &local->link; link->priv = local; @@ -177,19 +164,13 @@ static dev_link_t *teles_attach(void) link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - teles_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + teles_cs_config(link); + + return 0; } /* teles_attach */ /*====================================================================== @@ -428,35 +409,6 @@ static int teles_resume(struct pcmcia_device *p_dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - - When a CARD_REMOVAL event is received, we immediately set a flag - to block future accesses to this device. All the functions that - actually access the device should check this flag to make sure - the card is still present. - -======================================================================*/ - -static int teles_cs_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "teles_cs_event(%d)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - teles_cs_config(link); - break; - } - return 0; -} /* teles_cs_event */ static struct pcmcia_device_id teles_ids[] = { PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119), @@ -469,8 +421,7 @@ static struct pcmcia_driver teles_cs_driver = { .drv = { .name = "teles_cs", }, - .attach = teles_attach, - .event = teles_cs_event, + .probe = teles_attach, .remove = teles_detach, .id_table = teles_ids, .suspend = teles_suspend, diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 93c05df..f0f8916 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c @@ -66,8 +66,6 @@ struct pcmciamtd_dev { }; -static dev_info_t dev_info = "pcmciamtd"; - /* Module parameters */ /* 2 = do 16-bit transfers, 1 = do 8-bit transfers */ @@ -708,30 +706,6 @@ static int pcmciamtd_resume(struct pcmcia_device *dev) return 0; } -/* The card status event handler. Mostly, this schedules other - * stuff to run after an event is received. A CARD_REMOVAL event - * also sets some flags to discourage the driver from trying - * to talk to the card any more. - */ - -static int pcmciamtd_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "event=0x%06x", event); - switch (event) { - case CS_EVENT_CARD_INSERTION: - DEBUG(2, "EVENT_CARD_INSERTION"); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - pcmciamtd_config(link); - break; - default: - DEBUG(2, "Unknown event %d", event); - } - return 0; -} - /* This deletes a driver "instance". The device is de-registered * with Card Services. If it has been released, all local data @@ -762,16 +736,14 @@ static void pcmciamtd_detach(struct pcmcia_device *p_dev) * with Card Services. */ -static dev_link_t *pcmciamtd_attach(void) +static int pcmciamtd_attach(struct pcmcia_device *p_dev) { struct pcmciamtd_dev *dev; dev_link_t *link; - client_reg_t client_reg; - int ret; /* Create new memory card device */ dev = kmalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) return NULL; + if (!dev) return -ENOMEM; DEBUG(1, "dev=0x%p", dev); memset(dev, 0, sizeof(*dev)); @@ -782,20 +754,13 @@ static dev_link_t *pcmciamtd_attach(void) link->conf.IntType = INT_MEMORY; link->next = NULL; + link->handle = p_dev; + p_dev->instance = link; - /* Register with Card Services */ - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - DEBUG(2, "Calling RegisterClient"); - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - pcmciamtd_detach(link->handle); - return NULL; - } - DEBUG(2, "link = %p", link); - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + pcmciamtd_config(link); + + return 0; } static struct pcmcia_device_id pcmciamtd_ids[] = { @@ -829,8 +794,7 @@ static struct pcmcia_driver pcmciamtd_driver = { .drv = { .name = "pcmciamtd" }, - .attach = pcmciamtd_attach, - .event = pcmciamtd_event, + .probe = pcmciamtd_attach, .remove = pcmciamtd_detach, .owner = THIS_MODULE, .id_table = pcmciamtd_ids, diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 8fcb636..48774ef 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c @@ -227,8 +227,6 @@ static char mii_preamble_required = 0; static void tc574_config(dev_link_t *link); static void tc574_release(dev_link_t *link); -static int tc574_event(event_t event, int priority, - event_callback_args_t *args); static void mdio_sync(kio_addr_t ioaddr, int bits); static int mdio_read(kio_addr_t ioaddr, int phy_id, int location); @@ -250,9 +248,6 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); static struct ethtool_ops netdev_ethtool_ops; static void set_rx_mode(struct net_device *dev); -static dev_info_t dev_info = "3c574_cs"; - -static dev_link_t *tc574_attach(void); static void tc574_detach(struct pcmcia_device *p_dev); /* @@ -261,20 +256,18 @@ static void tc574_detach(struct pcmcia_device *p_dev); with Card Services. */ -static dev_link_t *tc574_attach(void) +static int tc574_attach(struct pcmcia_device *p_dev) { struct el3_private *lp; - client_reg_t client_reg; dev_link_t *link; struct net_device *dev; - int ret; DEBUG(0, "3c574_attach()\n"); /* Create the PC card device object. */ dev = alloc_etherdev(sizeof(struct el3_private)); if (!dev) - return NULL; + return -ENOMEM; lp = netdev_priv(dev); link = &lp->link; link->priv = dev; @@ -305,19 +298,13 @@ static dev_link_t *tc574_attach(void) dev->watchdog_timeo = TX_TIMEOUT; #endif - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - tc574_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + tc574_config(link); + + return 0; } /* tc574_attach */ /* @@ -565,29 +552,6 @@ static int tc574_resume(struct pcmcia_device *p_dev) return 0; } -/* - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. -*/ - -static int tc574_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "3c574_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - tc574_config(link); - break; - } - return 0; -} /* tc574_event */ - static void dump_status(struct net_device *dev) { kio_addr_t ioaddr = dev->base_addr; @@ -1282,8 +1246,7 @@ static struct pcmcia_driver tc574_driver = { .drv = { .name = "3c574_cs", }, - .attach = tc574_attach, - .event = tc574_event, + .probe = tc574_attach, .remove = tc574_detach, .id_table = tc574_ids, .suspend = tc574_suspend, diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 3516c02..1c3c9c6 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c @@ -143,8 +143,6 @@ DRV_NAME ".c " DRV_VERSION " 2001/10/13 00:08:50 (David Hinds)"; static void tc589_config(dev_link_t *link); static void tc589_release(dev_link_t *link); -static int tc589_event(event_t event, int priority, - event_callback_args_t *args); static u16 read_eeprom(kio_addr_t ioaddr, int index); static void tc589_reset(struct net_device *dev); @@ -161,9 +159,6 @@ static void el3_tx_timeout(struct net_device *dev); static void set_multicast_list(struct net_device *dev); static struct ethtool_ops netdev_ethtool_ops; -static dev_info_t dev_info = "3c589_cs"; - -static dev_link_t *tc589_attach(void); static void tc589_detach(struct pcmcia_device *p_dev); /*====================================================================== @@ -174,20 +169,18 @@ static void tc589_detach(struct pcmcia_device *p_dev); ======================================================================*/ -static dev_link_t *tc589_attach(void) +static int tc589_attach(struct pcmcia_device *p_dev) { struct el3_private *lp; - client_reg_t client_reg; dev_link_t *link; struct net_device *dev; - int ret; DEBUG(0, "3c589_attach()\n"); - + /* Create new ethernet device */ dev = alloc_etherdev(sizeof(struct el3_private)); if (!dev) - return NULL; + return -ENOMEM; lp = netdev_priv(dev); link = &lp->link; link->priv = dev; @@ -204,7 +197,7 @@ static dev_link_t *tc589_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.ConfigIndex = 1; link->conf.Present = PRESENT_OPTION; - + /* The EL3-specific entries in the device structure. */ SET_MODULE_OWNER(dev); dev->hard_start_xmit = &el3_start_xmit; @@ -219,19 +212,13 @@ static dev_link_t *tc589_attach(void) #endif SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - tc589_detach(link->handle); - return NULL; - } - - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + tc589_config(link); + + return 0; } /* tc589_attach */ /*====================================================================== @@ -439,31 +426,6 @@ static int tc589_resume(struct pcmcia_device *p_dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - -======================================================================*/ - -static int tc589_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "3c589_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - tc589_config(link); - break; - } - return 0; -} /* tc589_event */ - /*====================================================================*/ /* @@ -1057,8 +1019,7 @@ static struct pcmcia_driver tc589_driver = { .drv = { .name = "3c589_cs", }, - .attach = tc589_attach, - .event = tc589_event, + .probe = tc589_attach, .remove = tc589_detach, .id_table = tc589_ids, .suspend = tc589_suspend, diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 3d36207..01ddfc8 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -87,8 +87,6 @@ static char *version = static void axnet_config(dev_link_t *link); static void axnet_release(dev_link_t *link); -static int axnet_event(event_t event, int priority, - event_callback_args_t *args); static int axnet_open(struct net_device *dev); static int axnet_close(struct net_device *dev); static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); @@ -107,11 +105,8 @@ static void block_input(struct net_device *dev, int count, static void block_output(struct net_device *dev, int count, const u_char *buf, const int start_page); -static dev_link_t *axnet_attach(void); static void axnet_detach(struct pcmcia_device *p_dev); -static dev_info_t dev_info = "axnet_cs"; - static void axdev_setup(struct net_device *dev); static void AX88190_init(struct net_device *dev, int startp); static int ax_open(struct net_device *dev); @@ -146,13 +141,11 @@ static inline axnet_dev_t *PRIV(struct net_device *dev) ======================================================================*/ -static dev_link_t *axnet_attach(void) +static int axnet_attach(struct pcmcia_device *p_dev) { axnet_dev_t *info; dev_link_t *link; struct net_device *dev; - client_reg_t client_reg; - int ret; DEBUG(0, "axnet_attach()\n"); @@ -160,7 +153,7 @@ static dev_link_t *axnet_attach(void) "eth%d", axdev_setup); if (!dev) - return NULL; + return -ENOMEM; info = PRIV(dev); link = &info->link; @@ -175,19 +168,13 @@ static dev_link_t *axnet_attach(void) dev->do_ioctl = &axnet_ioctl; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - axnet_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + axnet_config(link); + + return 0; } /* axnet_attach */ /*====================================================================== @@ -513,31 +500,6 @@ static int axnet_resume(struct pcmcia_device *p_dev) /*====================================================================== - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - -======================================================================*/ - -static int axnet_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(2, "axnet_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - axnet_config(link); - break; - } - return 0; -} /* axnet_event */ - -/*====================================================================== - MII interface support ======================================================================*/ @@ -608,7 +570,7 @@ static int axnet_open(struct net_device *dev) link->open++; - request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, dev_info, dev); + request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, "axnet_cs", dev); info->link_status = 0x00; init_timer(&info->watchdog); @@ -869,8 +831,7 @@ static struct pcmcia_driver axnet_cs_driver = { .drv = { .name = "axnet_cs", }, - .attach = axnet_attach, - .event = axnet_event, + .probe = axnet_attach, .remove = axnet_detach, .id_table = axnet_ids, .suspend = axnet_suspend, diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index d48dbd3..2827a48 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c @@ -120,12 +120,7 @@ MODULE_LICENSE("GPL"); static void com20020_config(dev_link_t *link); static void com20020_release(dev_link_t *link); -static int com20020_event(event_t event, int priority, - event_callback_args_t *args); -static dev_info_t dev_info = "com20020_cs"; - -static dev_link_t *com20020_attach(void); static void com20020_detach(struct pcmcia_device *p_dev); /*====================================================================*/ @@ -143,21 +138,19 @@ typedef struct com20020_dev_t { ======================================================================*/ -static dev_link_t *com20020_attach(void) +static int com20020_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; com20020_dev_t *info; struct net_device *dev; - int ret; struct arcnet_local *lp; - + DEBUG(0, "com20020_attach()\n"); /* Create new network device */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) - return NULL; + return -ENOMEM; info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); if (!info) @@ -189,29 +182,19 @@ static dev_link_t *com20020_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - link->irq.Instance = info->dev = dev; link->priv = info; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - com20020_detach(link->handle); - return NULL; - } + link->state |= DEV_PRESENT; + com20020_config(link); - return link; + return 0; fail_alloc_dev: kfree(info); fail_alloc_info: kfree(link); - return NULL; + return -ENOMEM; } /* com20020_attach */ /*====================================================================== @@ -442,31 +425,6 @@ static int com20020_resume(struct pcmcia_device *p_dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - -======================================================================*/ - -static int com20020_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "com20020_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT; - com20020_config(link); - break; - } - return 0; -} /* com20020_event */ - static struct pcmcia_device_id com20020_ids[] = { PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf), PCMCIA_DEVICE_NULL @@ -478,8 +436,7 @@ static struct pcmcia_driver com20020_cs_driver = { .drv = { .name = "com20020_cs", }, - .attach = com20020_attach, - .event = com20020_event, + .probe = com20020_attach, .remove = com20020_detach, .id_table = com20020_ids, .suspend = com20020_suspend, diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index dad6393..28fe2fb 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -88,9 +88,6 @@ static void fmvj18x_config(dev_link_t *link); static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id); static int fmvj18x_setup_mfc(dev_link_t *link); static void fmvj18x_release(dev_link_t *link); -static int fmvj18x_event(event_t event, int priority, - event_callback_args_t *args); -static dev_link_t *fmvj18x_attach(void); static void fmvj18x_detach(struct pcmcia_device *p_dev); /* @@ -108,8 +105,6 @@ static void set_rx_mode(struct net_device *dev); static void fjn_tx_timeout(struct net_device *dev); static struct ethtool_ops netdev_ethtool_ops; -static dev_info_t dev_info = "fmvj18x_cs"; - /* card type */ @@ -233,20 +228,18 @@ typedef struct local_info_t { #define BANK_1U 0x24 /* bank 1 (CONFIG_1) */ #define BANK_2U 0x28 /* bank 2 (CONFIG_1) */ -static dev_link_t *fmvj18x_attach(void) +static int fmvj18x_attach(struct pcmcia_device *p_dev) { local_info_t *lp; dev_link_t *link; struct net_device *dev; - client_reg_t client_reg; - int ret; - + DEBUG(0, "fmvj18x_attach()\n"); /* Make up a FMVJ18x specific data structure */ dev = alloc_etherdev(sizeof(local_info_t)); if (!dev) - return NULL; + return -ENOMEM; lp = netdev_priv(dev); link = &lp->link; link->priv = dev; @@ -261,7 +254,7 @@ static dev_link_t *fmvj18x_attach(void) link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = &fjn_interrupt; link->irq.Instance = dev; - + /* General socket configuration */ link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.Vcc = 50; @@ -280,20 +273,14 @@ static dev_link_t *fmvj18x_attach(void) dev->watchdog_timeo = TX_TIMEOUT; #endif SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - fmvj18x_detach(link->handle); - return NULL; - } - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + fmvj18x_config(link); + + return 0; } /* fmvj18x_attach */ /*====================================================================*/ @@ -734,22 +721,6 @@ static int fmvj18x_resume(struct pcmcia_device *p_dev) /*====================================================================*/ -static int fmvj18x_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "fmvj18x_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - fmvj18x_config(link); - break; - } - return 0; -} /* fmvj18x_event */ - static struct pcmcia_device_id fmvj18x_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004), PCMCIA_DEVICE_PROD_ID12("EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04", 0x528c88c4, 0x74f91e59), @@ -780,8 +751,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = { .drv = { .name = "fmvj18x_cs", }, - .attach = fmvj18x_attach, - .event = fmvj18x_event, + .probe = fmvj18x_attach, .remove = fmvj18x_detach, .id_table = fmvj18x_ids, .suspend = fmvj18x_suspend, diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index 90da35d..b9c7e39 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -108,12 +108,6 @@ MODULE_LICENSE("GPL"); static void ibmtr_config(dev_link_t *link); static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase); static void ibmtr_release(dev_link_t *link); -static int ibmtr_event(event_t event, int priority, - event_callback_args_t *args); - -static dev_info_t dev_info = "ibmtr_cs"; - -static dev_link_t *ibmtr_attach(void); static void ibmtr_detach(struct pcmcia_device *p_dev); /*====================================================================*/ @@ -144,25 +138,23 @@ static struct ethtool_ops netdev_ethtool_ops = { ======================================================================*/ -static dev_link_t *ibmtr_attach(void) +static int ibmtr_attach(struct pcmcia_device *p_dev) { ibmtr_dev_t *info; dev_link_t *link; struct net_device *dev; - client_reg_t client_reg; - int ret; DEBUG(0, "ibmtr_attach()\n"); /* Create new token-ring device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (!info) return NULL; + if (!info) return -ENOMEM; memset(info,0,sizeof(*info)); dev = alloc_trdev(sizeof(struct tok_info)); - if (!dev) { - kfree(info); - return NULL; - } + if (!dev) { + kfree(info); + return -ENOMEM; + } link = &info->link; link->priv = info; @@ -183,24 +175,13 @@ static dev_link_t *ibmtr_attach(void) SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - goto out_detach; - } + link->handle = p_dev; + p_dev->instance = link; -out: - return link; + link->state |= DEV_PRESENT; + ibmtr_config(link); -out_detach: - ibmtr_detach(link->handle); - link = NULL; - goto out; + return 0; } /* ibmtr_attach */ /*====================================================================== @@ -420,31 +401,6 @@ static int ibmtr_resume(struct pcmcia_device *p_dev) } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - -======================================================================*/ - -static int ibmtr_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "ibmtr_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT; - ibmtr_config(link); - break; - } - return 0; -} /* ibmtr_event */ - /*====================================================================*/ static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase) @@ -500,8 +456,7 @@ static struct pcmcia_driver ibmtr_cs_driver = { .drv = { .name = "ibmtr_cs", }, - .attach = ibmtr_attach, - .event = ibmtr_event, + .probe = ibmtr_attach, .remove = ibmtr_detach, .id_table = ibmtr_ids, .suspend = ibmtr_suspend, diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index 0c9cb9f..4a23225 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c @@ -388,8 +388,6 @@ static char *version = DRV_NAME " " DRV_VERSION " (Roger C. Pao)"; #endif -static dev_info_t dev_info="nmclan_cs"; - static char *if_names[]={ "Auto", "10baseT", "BNC", }; @@ -421,8 +419,6 @@ Function Prototypes static void nmclan_config(dev_link_t *link); static void nmclan_release(dev_link_t *link); -static int nmclan_event(event_t event, int priority, - event_callback_args_t *args); static void nmclan_reset(struct net_device *dev); static int mace_config(struct net_device *dev, struct ifmap *map); @@ -438,7 +434,6 @@ static void set_multicast_list(struct net_device *dev); static struct ethtool_ops netdev_ethtool_ops; -static dev_link_t *nmclan_attach(void); static void nmclan_detach(struct pcmcia_device *p_dev); /* ---------------------------------------------------------------------------- @@ -448,13 +443,11 @@ nmclan_attach Services. ---------------------------------------------------------------------------- */ -static dev_link_t *nmclan_attach(void) +static int nmclan_attach(struct pcmcia_device *p_dev) { mace_private *lp; dev_link_t *link; struct net_device *dev; - client_reg_t client_reg; - int ret; DEBUG(0, "nmclan_attach()\n"); DEBUG(1, "%s\n", rcsid); @@ -462,7 +455,7 @@ static dev_link_t *nmclan_attach(void) /* Create new ethernet device */ dev = alloc_etherdev(sizeof(mace_private)); if (!dev) - return NULL; + return -ENOMEM; lp = netdev_priv(dev); link = &lp->link; link->priv = dev; @@ -496,19 +489,13 @@ static dev_link_t *nmclan_attach(void) dev->watchdog_timeo = TX_TIMEOUT; #endif - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - nmclan_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + nmclan_config(link); - return link; + return 0; } /* nmclan_attach */ /* ---------------------------------------------------------------------------- @@ -821,31 +808,6 @@ static int nmclan_resume(struct pcmcia_device *p_dev) return 0; } -/* ---------------------------------------------------------------------------- -nmclan_event - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. ----------------------------------------------------------------------------- */ -static int nmclan_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "nmclan_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - nmclan_config(link); - break; - case CS_EVENT_RESET_REQUEST: - return 1; - break; - } - return 0; -} /* nmclan_event */ /* ---------------------------------------------------------------------------- nmclan_reset @@ -1673,8 +1635,7 @@ static struct pcmcia_driver nmclan_cs_driver = { .drv = { .name = "nmclan_cs", }, - .attach = nmclan_attach, - .event = nmclan_event, + .probe = nmclan_attach, .remove = nmclan_detach, .id_table = nmclan_ids, .suspend = nmclan_suspend, diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index b35c951..d85b758f3 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -105,8 +105,6 @@ module_param_array(hw_addr, int, NULL, 0); static void mii_phy_probe(struct net_device *dev); static void pcnet_config(dev_link_t *link); static void pcnet_release(dev_link_t *link); -static int pcnet_event(event_t event, int priority, - event_callback_args_t *args); static int pcnet_open(struct net_device *dev); static int pcnet_close(struct net_device *dev); static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); @@ -120,7 +118,6 @@ static int setup_shmem_window(dev_link_t *link, int start_pg, static int setup_dma_config(dev_link_t *link, int start_pg, int stop_pg); -static dev_link_t *pcnet_attach(void); static void pcnet_detach(struct pcmcia_device *p_dev); static dev_info_t dev_info = "pcnet_cs"; @@ -243,19 +240,17 @@ static inline pcnet_dev_t *PRIV(struct net_device *dev) ======================================================================*/ -static dev_link_t *pcnet_attach(void) +static int pcnet_probe(struct pcmcia_device *p_dev) { pcnet_dev_t *info; dev_link_t *link; struct net_device *dev; - client_reg_t client_reg; - int ret; DEBUG(0, "pcnet_attach()\n"); /* Create new ethernet device */ dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); - if (!dev) return NULL; + if (!dev) return -ENOMEM; info = PRIV(dev); link = &info->link; link->priv = dev; @@ -270,19 +265,13 @@ static dev_link_t *pcnet_attach(void) dev->stop = &pcnet_close; dev->set_config = &set_config; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - pcnet_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + pcnet_config(link); - return link; + return 0; } /* pcnet_attach */ /*====================================================================== @@ -800,21 +789,6 @@ static int pcnet_resume(struct pcmcia_device *p_dev) return 0; } -static int pcnet_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(2, "pcnet_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - pcnet_config(link); - break; - } - return 0; -} /* pcnet_event */ /*====================================================================== @@ -1835,8 +1809,7 @@ static struct pcmcia_driver pcnet_driver = { .drv = { .name = "pcnet_cs", }, - .attach = pcnet_attach, - .event = pcnet_event, + .probe = pcnet_probe, .remove = pcnet_detach, .owner = THIS_MODULE, .id_table = pcnet_ids, diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 9eb5cec..0122415df 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -102,8 +102,6 @@ static const char *version = currently have room for another Tx packet. */ #define MEMORY_WAIT_TIME 8 -static dev_info_t dev_info = "smc91c92_cs"; - struct smc_private { dev_link_t link; spinlock_t lock; @@ -279,12 +277,9 @@ enum RxCfg { RxAllMulti = 0x0004, RxPromisc = 0x0002, /*====================================================================*/ -static dev_link_t *smc91c92_attach(void); static void smc91c92_detach(struct pcmcia_device *p_dev); static void smc91c92_config(dev_link_t *link); static void smc91c92_release(dev_link_t *link); -static int smc91c92_event(event_t event, int priority, - event_callback_args_t *args); static int smc_open(struct net_device *dev); static int smc_close(struct net_device *dev); @@ -313,20 +308,18 @@ static struct ethtool_ops ethtool_ops; ======================================================================*/ -static dev_link_t *smc91c92_attach(void) +static int smc91c92_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; struct smc_private *smc; dev_link_t *link; struct net_device *dev; - int ret; DEBUG(0, "smc91c92_attach()\n"); /* Create new ethernet device */ dev = alloc_etherdev(sizeof(struct smc_private)); if (!dev) - return NULL; + return -ENOMEM; smc = netdev_priv(dev); link = &smc->link; link->priv = dev; @@ -364,19 +357,13 @@ static dev_link_t *smc91c92_attach(void) smc->mii_if.phy_id_mask = 0x1f; smc->mii_if.reg_num_mask = 0x1f; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - smc91c92_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + smc91c92_config(link); + + return 0; } /* smc91c92_attach */ /*====================================================================== @@ -1212,31 +1199,6 @@ static void smc91c92_release(dev_link_t *link) /*====================================================================== - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - -======================================================================*/ - -static int smc91c92_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "smc91c92_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - smc91c92_config(link); - break; - } - return 0; -} /* smc91c92_event */ - -/*====================================================================== - MII interface support for SMC91cXX based cards ======================================================================*/ @@ -2349,8 +2311,7 @@ static struct pcmcia_driver smc91c92_cs_driver = { .drv = { .name = "smc91c92_cs", }, - .attach = smc91c92_attach, - .event = smc91c92_event, + .probe = smc91c92_attach, .remove = smc91c92_detach, .id_table = smc91c92_ids, .suspend = smc91c92_suspend, diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index 8c8cc40..049c34b3 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -292,8 +292,6 @@ static void mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, static int has_ce2_string(dev_link_t * link); static void xirc2ps_config(dev_link_t * link); static void xirc2ps_release(dev_link_t * link); -static int xirc2ps_event(event_t event, int priority, - event_callback_args_t * args); /**************** * The attach() and detach() entry points are used to create and destroy @@ -301,7 +299,6 @@ static int xirc2ps_event(event_t event, int priority, * needed to manage one actual PCMCIA card. */ -static dev_link_t *xirc2ps_attach(void); static void xirc2ps_detach(struct pcmcia_device *p_dev); /**************** @@ -313,14 +310,6 @@ static void xirc2ps_detach(struct pcmcia_device *p_dev); static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs); -/* - * The dev_info variable is the "key" that is used to match up this - * device driver with appropriate cards, through the card configuration - * database. - */ - -static dev_info_t dev_info = "xirc2ps_cs"; - /**************** * A linked list of "instances" of the device. Each actual * PCMCIA card corresponds to one device instance, and is described @@ -563,21 +552,19 @@ mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, unsigned data, int len) * card insertion event. */ -static dev_link_t * -xirc2ps_attach(void) +static int +xirc2ps_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; struct net_device *dev; local_info_t *local; - int err; DEBUG(0, "attach()\n"); /* Allocate the device structure */ dev = alloc_etherdev(sizeof(local_info_t)); if (!dev) - return NULL; + return -ENOMEM; local = netdev_priv(dev); link = &local->link; link->priv = dev; @@ -606,18 +593,13 @@ xirc2ps_attach(void) dev->watchdog_timeo = TX_TIMEOUT; #endif - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - if ((err = pcmcia_register_client(&link->handle, &client_reg))) { - cs_error(link->handle, RegisterClient, err); - xirc2ps_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + xirc2ps_config(link); - return link; + return 0; } /* xirc2ps_attach */ /**************** @@ -1162,34 +1144,6 @@ static int xirc2ps_resume(struct pcmcia_device *p_dev) return 0; } -/**************** - * The card status event handler. Mostly, this schedules other - * stuff to run after an event is received. A CARD_REMOVAL event - * also sets some flags to discourage the net drivers from trying - * to talk to the card any more. - * - * When a CARD_REMOVAL event is received, we immediately set a flag - * to block future accesses to this device. All the functions that - * actually access the device should check this flag to make sure - * the card is still present. - */ - -static int -xirc2ps_event(event_t event, int priority, - event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - DEBUG(0, "event(%d)\n", (int)event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - xirc2ps_config(link); - break; - } - return 0; -} /* xirc2ps_event */ /*====================================================================*/ @@ -1981,8 +1935,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = { .drv = { .name = "xirc2ps_cs", }, - .attach = xirc2ps_attach, - .event = xirc2ps_event, + .probe = xirc2ps_attach, .remove = xirc2ps_detach, .id_table = xirc2ps_ids, .suspend = xirc2ps_suspend, diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index 88805a4..a496460 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -82,8 +82,6 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards"); static void airo_config(dev_link_t *link); static void airo_release(dev_link_t *link); -static int airo_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -91,7 +89,6 @@ static int airo_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *airo_attach(void); static void airo_detach(struct pcmcia_device *p_dev); /* @@ -102,14 +99,6 @@ static void airo_detach(struct pcmcia_device *p_dev); */ /* - The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ - -static dev_info_t dev_info = "airo_cs"; - -/* A linked list of "instances" of the aironet device. Each actual PCMCIA card corresponds to one device instance, and is described by one dev_link_t structure (defined in ds.h). @@ -152,20 +141,18 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *airo_attach(void) +static int airo_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; local_info_t *local; - int ret; - + DEBUG(0, "airo_attach()\n"); /* Initialize the dev_link_t structure */ link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) { printk(KERN_ERR "airo_cs: no memory for new device\n"); - return NULL; + return -ENOMEM; } /* Interrupt setup */ @@ -189,23 +176,17 @@ static dev_link_t *airo_attach(void) if (!local) { printk(KERN_ERR "airo_cs: no memory for new device\n"); kfree (link); - return NULL; + return -ENOMEM; } link->priv = local; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - airo_detach(link->handle); - return NULL; - } - - return link; + + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + airo_config(link); + + return 0; } /* airo_attach */ /*====================================================================== @@ -497,34 +478,6 @@ static int airo_resume(struct pcmcia_device *p_dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. - - When a CARD_REMOVAL event is received, we immediately set a - private flag to block future accesses to this device. All the - functions that actually access the device should check this flag - to make sure the card is still present. - - ======================================================================*/ - -static int airo_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "airo_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - airo_config(link); - break; - } - return 0; -} /* airo_event */ - static struct pcmcia_device_id airo_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a), PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005), @@ -539,8 +492,7 @@ static struct pcmcia_driver airo_driver = { .drv = { .name = "airo_cs", }, - .attach = airo_attach, - .event = airo_event, + .probe = airo_attach, .remove = airo_detach, .id_table = airo_ids, .suspend = airo_suspend, diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index 32f0097..d6f4a5a 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -93,8 +93,6 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards"); static void atmel_config(dev_link_t *link); static void atmel_release(dev_link_t *link); -static int atmel_event(event_t event, int priority, - event_callback_args_t *args); /* The attach() and detach() entry points are used to create and destroy @@ -102,7 +100,6 @@ static int atmel_event(event_t event, int priority, needed to manage one actual PCMCIA card. */ -static dev_link_t *atmel_attach(void); static void atmel_detach(struct pcmcia_device *p_dev); /* @@ -113,14 +110,6 @@ static void atmel_detach(struct pcmcia_device *p_dev); */ /* - The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ - -static dev_info_t dev_info = "atmel_cs"; - -/* A linked list of "instances" of the atmelnet device. Each actual PCMCIA card corresponds to one device instance, and is described by one dev_link_t structure (defined in ds.h). @@ -163,27 +152,25 @@ typedef struct local_info_t { ======================================================================*/ -static dev_link_t *atmel_attach(void) +static int atmel_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; local_info_t *local; - int ret; - + DEBUG(0, "atmel_attach()\n"); /* Initialize the dev_link_t structure */ link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) { printk(KERN_ERR "atmel_cs: no memory for new device\n"); - return NULL; + return -ENOMEM; } - + /* Interrupt setup */ link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = NULL; - + /* General socket configuration defaults can go here. In this client, we assume very little, and rely on the CIS for almost @@ -194,29 +181,23 @@ static dev_link_t *atmel_attach(void) link->conf.Attributes = 0; link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - + /* Allocate space for private device-specific data */ local = kzalloc(sizeof(local_info_t), GFP_KERNEL); if (!local) { printk(KERN_ERR "atmel_cs: no memory for new device\n"); kfree (link); - return NULL; + return -ENOMEM; } link->priv = local; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - atmel_detach(link->handle); - return NULL; - } - - return link; + + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + atmel_config(link); + + return 0; } /* atmel_attach */ /*====================================================================== @@ -485,34 +466,6 @@ static int atmel_resume(struct pcmcia_device *dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. - - When a CARD_REMOVAL event is received, we immediately set a - private flag to block future accesses to this device. All the - functions that actually access the device should check this flag - to make sure the card is still present. - - ======================================================================*/ - -static int atmel_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "atmel_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - atmel_config(link); - break; - } - return 0; -} /* atmel_event */ - /*====================================================================*/ /* We use the driver_info field to store the correct firmware type for a card. */ @@ -562,8 +515,7 @@ static struct pcmcia_driver atmel_driver = { .drv = { .name = "atmel_cs", }, - .attach = atmel_attach, - .event = atmel_event, + .probe = atmel_attach, .remove = atmel_detach, .id_table = atmel_ids, .suspend = atmel_suspend, diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 195a5bf3..8bc0b528 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -204,8 +204,7 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len) static void prism2_detach(struct pcmcia_device *p_dev); static void prism2_release(u_long arg); -static int prism2_event(event_t event, int priority, - event_callback_args_t *args); +static int prism2_config(dev_link_t *link); static int prism2_pccard_card_present(local_info_t *local) @@ -502,15 +501,13 @@ static struct prism2_helper_functions prism2_pccard_funcs = /* allocate local data and register with CardServices * initialize dev_link structure, but do not configure the card yet */ -static dev_link_t *prism2_attach(void) +static int prism2_attach(struct pcmcia_device *p_dev) { dev_link_t *link; - client_reg_t client_reg; - int ret; link = kmalloc(sizeof(dev_link_t), GFP_KERNEL); if (link == NULL) - return NULL; + return -ENOMEM; memset(link, 0, sizeof(dev_link_t)); @@ -518,18 +515,14 @@ static dev_link_t *prism2_attach(void) link->conf.Vcc = 33; link->conf.IntType = INT_MEMORY_AND_IO; - /* register with CardServices */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - prism2_detach(link->handle); - return NULL; - } - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + if (prism2_config(link)) + PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); + + return 0; } @@ -878,29 +871,6 @@ static int hostap_cs_resume(struct pcmcia_device *p_dev) return 0; } -static int prism2_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - if (prism2_config(link)) { - PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); - } - break; - - default: - PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n", - dev_info, event); - break; - } - return 0; -} - - static struct pcmcia_device_id hostap_cs_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), @@ -959,10 +929,9 @@ static struct pcmcia_driver hostap_driver = { .drv = { .name = "hostap_cs", }, - .attach = prism2_attach, + .probe = prism2_attach, .remove = prism2_detach, .owner = THIS_MODULE, - .event = prism2_event, .id_table = hostap_cs_ids, .suspend = hostap_cs_suspend, .resume = hostap_cs_resume, diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index af9a32d..bf6271e 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c @@ -166,8 +166,6 @@ static char *version = #define DEBUG(n, args...) #endif -static dev_info_t dev_info = "netwave_cs"; - /*====================================================================*/ /* Parameters that can be set with 'insmod' */ @@ -195,11 +193,8 @@ module_param(mem_speed, int, 0); /* PCMCIA (Card Services) related functions */ static void netwave_release(dev_link_t *link); /* Card removal */ -static int netwave_event(event_t event, int priority, - event_callback_args_t *args); static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card insertion */ -static dev_link_t *netwave_attach(void); /* Create instance */ static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ /* Hardware configuration */ @@ -383,20 +378,18 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev) * configure the card at this point -- we wait until we receive a * card insertion event. */ -static dev_link_t *netwave_attach(void) +static int netwave_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; struct net_device *dev; netwave_private *priv; - int ret; - + DEBUG(0, "netwave_attach()\n"); - + /* Initialize the dev_link_t structure */ dev = alloc_etherdev(sizeof(netwave_private)); if (!dev) - return NULL; + return -ENOMEM; priv = netdev_priv(dev); link = &priv->link; link->priv = dev; @@ -438,20 +431,14 @@ static dev_link_t *netwave_attach(void) dev->open = &netwave_open; dev->stop = &netwave_close; link->irq.Instance = dev; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - netwave_detach(link->handle); - return NULL; - } - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + netwave_pcmcia_config( link); + + return 0; } /* netwave_attach */ /* @@ -935,36 +922,6 @@ static int netwave_resume(struct pcmcia_device *p_dev) /* - * Function netwave_event (event, priority, args) - * - * The card status event handler. Mostly, this schedules other - * stuff to run after an event is received. A CARD_REMOVAL event - * also sets some flags to discourage the net drivers from trying - * to talk to the card any more. - * - * When a CARD_REMOVAL event is received, we immediately set a flag - * to block future accesses to this device. All the functions that - * actually access the device should check this flag to make sure - * the card is still present. - * - */ -static int netwave_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "netwave_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - netwave_pcmcia_config( link); - break; - } - return 0; -} /* netwave_event */ - -/* * Function netwave_doreset (ioBase, ramBase) * * Proper hardware reset of the card. @@ -1456,8 +1413,7 @@ static struct pcmcia_driver netwave_driver = { .drv = { .name = "netwave_cs", }, - .attach = netwave_attach, - .event = netwave_event, + .probe = netwave_attach, .remove = netwave_detach, .id_table = netwave_ids, .suspend = netwave_suspend, diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index bfeeef4..b664708 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -43,17 +43,6 @@ module_param(ignore_cis_vcc, int, 0); MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); /********************************************************************/ -/* Magic constants */ -/********************************************************************/ - -/* - * The dev_info variable is the "key" that is used to match up this - * device driver with appropriate cards, through the card - * configuration database. - */ -static dev_info_t dev_info = DRIVER_NAME; - -/********************************************************************/ /* Data structures */ /********************************************************************/ @@ -74,6 +63,7 @@ struct orinoco_pccard { /* Function prototypes */ /********************************************************************/ +static void orinoco_cs_config(dev_link_t *link); static void orinoco_cs_release(dev_link_t *link); static void orinoco_cs_detach(struct pcmcia_device *p_dev); @@ -113,19 +103,17 @@ orinoco_cs_hard_reset(struct orinoco_private *priv) * The dev_link structure is initialized, but we don't actually * configure the card at this point -- we wait until we receive a card * insertion event. */ -static dev_link_t * -orinoco_cs_attach(void) +static int +orinoco_cs_attach(struct pcmcia_device *p_dev) { struct net_device *dev; struct orinoco_private *priv; struct orinoco_pccard *card; dev_link_t *link; - client_reg_t client_reg; - int ret; dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); if (! dev) - return NULL; + return -ENOMEM; priv = netdev_priv(dev); card = priv->card; @@ -150,18 +138,13 @@ orinoco_cs_attach(void) /* Register with Card Services */ link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; /* FIXME: what does this mean? */ - client_reg.event_callback_args.client_data = link; + link->handle = p_dev; + p_dev->instance = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - orinoco_cs_detach(link->handle); - return NULL; - } + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + orinoco_cs_config(link); - return link; + return 0; } /* orinoco_cs_attach */ /* @@ -521,26 +504,6 @@ static int orinoco_cs_resume(struct pcmcia_device *p_dev) } -/* - * The card status event handler. Mostly, this schedules other stuff - * to run after an event is received. - */ -static int -orinoco_cs_event(event_t event, int priority, - event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - orinoco_cs_config(link); - break; - } - - return 0; -} /* orinoco_cs_event */ - /********************************************************************/ /* Module initialization */ /********************************************************************/ @@ -640,9 +603,8 @@ static struct pcmcia_driver orinoco_driver = { .drv = { .name = DRIVER_NAME, }, - .attach = orinoco_cs_attach, + .probe = orinoco_cs_attach, .remove = orinoco_cs_detach, - .event = orinoco_cs_event, .id_table = orinoco_cs_ids, .suspend = orinoco_cs_suspend, .resume = orinoco_cs_resume, diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 33a89e2..319180c 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -92,8 +92,6 @@ module_param(pc_debug, int, 0); /** Prototypes based on PCMCIA skeleton driver *******************************/ static void ray_config(dev_link_t *link); static void ray_release(dev_link_t *link); -static int ray_event(event_t event, int priority, event_callback_args_t *args); -static dev_link_t *ray_attach(void); static void ray_detach(struct pcmcia_device *p_dev); /***** Prototypes indicated by device structure ******************************/ @@ -192,12 +190,6 @@ static int bc; static char *phy_addr = NULL; -/* The dev_info variable is the "key" that is used to match up this - device driver with appropriate cards, through the card configuration - database. -*/ -static dev_info_t dev_info = "ray_cs"; - /* A linked list of "instances" of the ray device. Each actual PCMCIA card corresponds to one device instance, and is described by one dev_link_t structure (defined in ds.h). @@ -314,12 +306,10 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey stop = &ray_dev_close; netif_stop_queue(dev); - /* Register with Card Services */ - link->next = dev_list; - dev_list = link; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; + init_timer(&local->timer); - DEBUG(2,"ray_cs ray_attach calling pcmcia_register_client(...)\n"); + link->handle = p_dev; + p_dev->instance = link; - init_timer(&local->timer); + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + ray_config(link); - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - printk("ray_cs ray_attach RegisterClient unhappy - detaching\n"); - cs_error(link->handle, RegisterClient, ret); - ray_detach(link->handle); - return NULL; - } - DEBUG(2,"ray_cs ray_attach ending\n"); - return link; + return 0; fail_alloc_dev: kfree(link); - return NULL; + return -ENOMEM; } /* ray_attach */ /*============================================================================= This deletes a driver "instance". The device is de-registered @@ -924,32 +903,6 @@ static int ray_resume(struct pcmcia_device *p_dev) return 0; } -/*============================================================================= - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - - When a CARD_REMOVAL event is received, we immediately set a flag - to block future accesses to this device. All the functions that - actually access the device should check this flag to make sure - the card is still present. -=============================================================================*/ -static int ray_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - DEBUG(1, "ray_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - ray_config(link); - break; - } - return 0; - DEBUG(2,"ray_event ending\n"); -} /* ray_event */ /*===========================================================================*/ int ray_dev_init(struct net_device *dev) { @@ -2945,8 +2898,7 @@ static struct pcmcia_driver ray_driver = { .drv = { .name = "ray_cs", }, - .attach = ray_attach, - .event = ray_event, + .probe = ray_attach, .remove = ray_detach, .id_table = ray_ids, .suspend = ray_suspend, diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index 1933250..fee4be1 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c @@ -57,17 +57,6 @@ module_param(ignore_cis_vcc, int, 0); MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); /********************************************************************/ -/* Magic constants */ -/********************************************************************/ - -/* - * The dev_info variable is the "key" that is used to match up this - * device driver with appropriate cards, through the card - * configuration database. - */ -static dev_info_t dev_info = DRIVER_NAME; - -/********************************************************************/ /* Data structures */ /********************************************************************/ @@ -82,8 +71,8 @@ struct orinoco_pccard { /* Function prototypes */ /********************************************************************/ +static void spectrum_cs_config(dev_link_t *link); static void spectrum_cs_release(dev_link_t *link); -static void spectrum_cs_detach(struct pcmcia_device *p_dev); /********************************************************************/ /* Firmware downloader */ @@ -594,19 +583,17 @@ spectrum_cs_hard_reset(struct orinoco_private *priv) * The dev_link structure is initialized, but we don't actually * configure the card at this point -- we wait until we receive a card * insertion event. */ -static dev_link_t * -spectrum_cs_attach(void) +static int +spectrum_cs_attach(struct pcmcia_device *p_dev) { struct net_device *dev; struct orinoco_private *priv; struct orinoco_pccard *card; dev_link_t *link; - client_reg_t client_reg; - int ret; dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); if (! dev) - return NULL; + return -ENOMEM; priv = netdev_priv(dev); card = priv->card; @@ -628,22 +615,13 @@ spectrum_cs_attach(void) link->conf.Attributes = 0; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - /* FIXME: need a lock? */ - link->next = NULL; /* not needed */ + link->handle = p_dev; + p_dev->instance = link; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; /* FIXME: what does this mean? */ - client_reg.event_callback_args.client_data = link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + spectrum_cs_config(link); - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - spectrum_cs_detach(link->handle); - return NULL; - } - - return link; + return 0; } /* spectrum_cs_attach */ /* @@ -977,26 +955,6 @@ spectrum_cs_resume(struct pcmcia_device *p_dev) return 0; } -/* - * The card status event handler. Mostly, this schedules other stuff - * to run after an event is received. - */ -static int -spectrum_cs_event(event_t event, int priority, - event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - spectrum_cs_config(link); - break; - - } - - return 0; -} /* spectrum_cs_event */ /********************************************************************/ /* Module initialization */ @@ -1021,11 +979,10 @@ static struct pcmcia_driver orinoco_driver = { .drv = { .name = DRIVER_NAME, }, - .attach = spectrum_cs_attach, + .probe = spectrum_cs_attach, .remove = spectrum_cs_detach, .suspend = spectrum_cs_suspend, .resume = spectrum_cs_resume, - .event = spectrum_cs_event, .id_table = spectrum_cs_ids, }; diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 196e827..7e2039f 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c @@ -4594,14 +4594,12 @@ wavelan_close(struct net_device * dev) * configure the card at this point -- we wait until we receive a * card insertion event. */ -static dev_link_t * -wavelan_attach(void) +static int +wavelan_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; /* Register with cardmgr */ dev_link_t * link; /* Info for cardmgr */ struct net_device * dev; /* Interface generic data */ net_local * lp; /* Interface specific data */ - int ret; #ifdef DEBUG_CALLBACK_TRACE printk(KERN_DEBUG "-> wavelan_attach()\n"); @@ -4609,7 +4607,7 @@ wavelan_attach(void) /* Initialize the dev_link_t structure */ link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); - if (!link) return NULL; + if (!link) return -ENOMEM; /* The io structure describes IO port mapping */ link->io.NumPorts1 = 8; @@ -4633,7 +4631,7 @@ wavelan_attach(void) dev = alloc_etherdev(sizeof(net_local)); if (!dev) { kfree(link); - return NULL; + return -ENOMEM; } link->priv = link->irq.Instance = dev; @@ -4678,28 +4676,21 @@ wavelan_attach(void) /* Other specific data */ dev->mtu = WAVELAN_MTU; - /* Register with Card Services */ - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - -#ifdef DEBUG_CONFIG_INFO - printk(KERN_DEBUG "wavelan_attach(): almost done, calling pcmcia_register_client\n"); -#endif + link->handle = p_dev; + p_dev->instance = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if(ret != 0) - { - cs_error(link->handle, RegisterClient, ret); - wavelan_detach(link->handle); - return NULL; - } + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + if(wv_pcmcia_config(link) && + wv_hw_config(dev)) + wv_init_info(dev); + else + dev->irq = 0; #ifdef DEBUG_CALLBACK_TRACE printk(KERN_DEBUG "<- wavelan_attach()\n"); #endif - return link; + return 0; } /*------------------------------------------------------------------*/ @@ -4801,52 +4792,6 @@ static int wavelan_resume(struct pcmcia_device *p_dev) } -/*------------------------------------------------------------------*/ -/* - * The card status event handler. Mostly, this schedules other stuff - * to run after an event is received. A CARD_REMOVAL event also sets - * some flags to discourage the net drivers from trying to talk to the - * card any more. - */ -static int -wavelan_event(event_t event, /* The event received */ - int priority, - event_callback_args_t * args) -{ - dev_link_t * link = (dev_link_t *) args->client_data; - struct net_device * dev = (struct net_device *) link->priv; - -#ifdef DEBUG_CALLBACK_TRACE - printk(KERN_DEBUG "->wavelan_event(): %s\n", - ((event == CS_EVENT_REGISTRATION_COMPLETE)?"registration complete" : - ((event == CS_EVENT_CARD_REMOVAL) ? "card removal" : - ((event == CS_EVENT_CARD_INSERTION) ? "card insertion" : - ((event == CS_EVENT_PM_SUSPEND) ? "pm suspend" : - ((event == CS_EVENT_RESET_PHYSICAL) ? "physical reset" : - ((event == CS_EVENT_PM_RESUME) ? "pm resume" : - ((event == CS_EVENT_CARD_RESET) ? "card reset" : - "unknown")))))))); -#endif - - switch(event) - { - case CS_EVENT_CARD_INSERTION: - /* Reset and configure the card */ - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - if(wv_pcmcia_config(link) && - wv_hw_config(dev)) - wv_init_info(dev); - else - dev->irq = 0; - break; - } - -#ifdef DEBUG_CALLBACK_TRACE - printk(KERN_DEBUG "<-wavelan_event()\n"); -#endif - return 0; -} - static struct pcmcia_device_id wavelan_ids[] = { PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975), PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06), @@ -4861,8 +4806,7 @@ static struct pcmcia_driver wavelan_driver = { .drv = { .name = "wavelan_cs", }, - .attach = wavelan_attach, - .event = wavelan_event, + .probe = wavelan_attach, .remove = wavelan_detach, .id_table = wavelan_ids, .suspend = wavelan_suspend, diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h index a1a1917..f2d5975 100644 --- a/drivers/net/wireless/wavelan_cs.p.h +++ b/drivers/net/wireless/wavelan_cs.p.h @@ -754,19 +754,11 @@ static void static int wavelan_open(struct net_device *), /* Open the device */ wavelan_close(struct net_device *); /* Close the device */ -static dev_link_t * - wavelan_attach(void); /* Create a new device */ static void wavelan_detach(struct pcmcia_device *p_dev); /* Destroy a removed device */ -static int - wavelan_event(event_t, /* Manage pcmcia events */ - int, - event_callback_args_t *); /**************************** VARIABLES ****************************/ -static dev_info_t dev_info = "wavelan_cs"; - /* * Parameters that can be set with 'insmod' * The exact syntax is 'insmod wavelan_cs.o =' diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 21e498f..48e10b0 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -105,7 +105,6 @@ module_param(pc_debug, int, 0); */ static void wl3501_config(dev_link_t *link); static void wl3501_release(dev_link_t *link); -static int wl3501_event(event_t event, int pri, event_callback_args_t *args); /* * The dev_info variable is the "key" that is used to match up this @@ -1954,18 +1953,16 @@ static const struct iw_handler_def wl3501_handler_def = { * The dev_link structure is initialized, but we don't actually configure the * card at this point -- we wait until we receive a card insertion event. */ -static dev_link_t *wl3501_attach(void) +static int wl3501_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; struct net_device *dev; struct wl3501_card *this; - int ret; /* Initialize the dev_link_t structure */ link = kzalloc(sizeof(*link), GFP_KERNEL); if (!link) - goto out; + return -ENOMEM; /* The io structure describes IO port mapping */ link->io.NumPorts1 = 16; @@ -2001,24 +1998,17 @@ static dev_link_t *wl3501_attach(void) netif_stop_queue(dev); link->priv = link->irq.Instance = dev; - /* Register with Card Services */ - link->next = wl3501_dev_list; - wl3501_dev_list = link; - client_reg.dev_info = &wl3501_dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret) { - cs_error(link->handle, RegisterClient, ret); - wl3501_detach(link->handle); - link = NULL; - } -out: - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + wl3501_config(link); + + return 0; out_link: kfree(link); link = NULL; - goto out; + return -ENOMEM; } #define CS_CHECK(fn, ret) \ @@ -2206,33 +2196,6 @@ static int wl3501_resume(struct pcmcia_device *p_dev) } -/** - * wl3501_event - The card status event handler - * @event - event - * @pri - priority - * @args - arguments for this event - * - * The card status event handler. Mostly, this schedules other stuff to run - * after an event is received. A CARD_REMOVAL event also sets some flags to - * discourage the net drivers from trying to talk to the card any more. - * - * When a CARD_REMOVAL event is received, we immediately set a flag to block - * future accesses to this device. All the functions that actually access the - * device should check this flag to make sure the card is still present. - */ -static int wl3501_event(event_t event, int pri, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - wl3501_config(link); - break; - } - return 0; -} - static struct pcmcia_device_id wl3501_ids[] = { PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001), PCMCIA_DEVICE_NULL @@ -2244,8 +2207,7 @@ static struct pcmcia_driver wl3501_driver = { .drv = { .name = "wl3501_cs", }, - .attach = wl3501_attach, - .event = wl3501_event, + .probe = wl3501_attach, .remove = wl3501_detach, .id_table = wl3501_ids, .suspend = wl3501_suspend, diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 763f91a..158d925 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c @@ -87,14 +87,9 @@ typedef struct parport_info_t { struct parport *port; } parport_info_t; -static dev_link_t *parport_attach(void); static void parport_detach(struct pcmcia_device *p_dev); static void parport_config(dev_link_t *link); static void parport_cs_release(dev_link_t *); -static int parport_event(event_t event, int priority, - event_callback_args_t *args); - -static dev_info_t dev_info = "parport_cs"; /*====================================================================== @@ -104,18 +99,16 @@ static dev_info_t dev_info = "parport_cs"; ======================================================================*/ -static dev_link_t *parport_attach(void) +static int parport_attach(struct pcmcia_device *p_dev) { parport_info_t *info; dev_link_t *link; - client_reg_t client_reg; - int ret; - + DEBUG(0, "parport_attach()\n"); /* Create new parport device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (!info) return NULL; + if (!info) return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -126,20 +119,14 @@ static dev_link_t *parport_attach(void) link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.Vcc = 50; link->conf.IntType = INT_MEMORY_AND_IO; - - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - parport_detach(link->handle); - return NULL; - } - - return link; + + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + parport_config(link); + + return 0; } /* parport_attach */ /*====================================================================== @@ -329,29 +316,6 @@ static int parport_resume(struct pcmcia_device *dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. - -======================================================================*/ - -int parport_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "parport_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - parport_config(link); - break; - } - return 0; -} /* parport_event */ - static struct pcmcia_device_id parport_ids[] = { PCMCIA_DEVICE_FUNC_ID(3), PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003), @@ -364,8 +328,7 @@ static struct pcmcia_driver parport_cs_driver = { .drv = { .name = "parport_cs", }, - .attach = parport_attach, - .event = parport_event, + .probe = parport_attach, .remove = parport_detach, .id_table = parport_ids, .suspend = parport_suspend, diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 8eff55b..0fc61dd 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -203,7 +203,7 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv) unsigned int i; u32 hash; - if (!p_drv->attach || !p_drv->event || !p_drv->remove) + if (!p_drv->probe || !p_drv->remove) printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback " "function\n", p_drv->drv.name); @@ -361,6 +361,7 @@ static int pcmcia_device_probe(struct device * dev) { struct pcmcia_device *p_dev; struct pcmcia_driver *p_drv; + struct pcmcia_socket *s; int ret = 0; dev = get_device(dev); @@ -369,25 +370,39 @@ static int pcmcia_device_probe(struct device * dev) p_dev = to_pcmcia_dev(dev); p_drv = to_pcmcia_drv(dev->driver); + s = p_dev->socket; - if (!try_module_get(p_drv->owner)) { + if ((!p_drv->probe) || (!try_module_get(p_drv->owner))) { ret = -EINVAL; goto put_dev; } - if (p_drv->attach) { - p_dev->instance = p_drv->attach(); - if ((!p_dev->instance) || (p_dev->state & CLIENT_UNBOUND)) { - printk(KERN_NOTICE "ds: unable to create instance " - "of '%s'!\n", p_drv->drv.name); - ret = -EINVAL; + p_dev->state &= ~CLIENT_UNBOUND; + + /* set up the device configuration, if it hasn't been done before */ + if (!s->functions) { + cistpl_longlink_mfc_t mfc; + if (pccard_read_tuple(s, p_dev->func, CISTPL_LONGLINK_MFC, + &mfc) == CS_SUCCESS) + s->functions = mfc.nfn; + else + s->functions = 1; + s->config = kmalloc(sizeof(config_t) * s->functions, + GFP_KERNEL); + if (!s->config) { + ret = -ENOMEM; + goto put_module; } + memset(s->config, 0, sizeof(config_t) * s->functions); } + ret = p_drv->probe(p_dev); + + put_module: if (ret) module_put(p_drv->owner); put_dev: - if ((ret) || !(p_drv->attach)) + if (ret) put_device(dev); return (ret); } @@ -418,11 +433,8 @@ static int pcmcia_device_remove(struct device * dev) printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", p_drv->drv.name); - /* undo pcmcia_register_client */ - p_dev->state = CLIENT_UNBOUND; - pcmcia_put_dev(p_dev); - /* references from pcmcia_probe_device */ + p_dev->state = CLIENT_UNBOUND; pcmcia_put_dev(p_dev); module_put(p_drv->owner); @@ -1042,49 +1054,6 @@ static int pcmcia_bus_suspend(struct pcmcia_socket *skt) ======================================================================*/ -struct send_event_data { - struct pcmcia_socket *skt; - event_t event; - int priority; -}; - -static int send_event_callback(struct device *dev, void * _data) -{ - struct pcmcia_device *p_dev = to_pcmcia_dev(dev); - struct pcmcia_driver *p_drv; - struct send_event_data *data = _data; - - /* we get called for all sockets, but may only pass the event - * for drivers _on the affected socket_ */ - if (p_dev->socket != data->skt) - return 0; - - p_drv = to_pcmcia_drv(p_dev->dev.driver); - if (!p_drv) - return 0; - - if (p_dev->state & (CLIENT_UNBOUND|CLIENT_STALE)) - return 0; - - if (p_drv->event) - return p_drv->event(data->event, data->priority, - &p_dev->event_callback_args); - - return 0; -} - -static int send_event(struct pcmcia_socket *s, event_t event, int priority) -{ - struct send_event_data private; - - private.skt = s; - private.event = event; - private.priority = priority; - - return bus_for_each_dev(&pcmcia_bus_type, NULL, &private, send_event_callback); -} /* send_event */ - - /* Normally, the event is passed to individual drivers after * informing userspace. Only for CS_EVENT_CARD_REMOVAL this * is inversed to maintain historic compatibility. @@ -1093,20 +1062,17 @@ static int send_event(struct pcmcia_socket *s, event_t event, int priority) static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) { struct pcmcia_socket *s = pcmcia_get_socket(skt); - int ret = 0; ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n", event, priority, skt); - - switch (event) { + switch (event) { case CS_EVENT_CARD_REMOVAL: s->pcmcia_state.present = 0; - send_event(skt, event, priority); pcmcia_card_remove(skt); handle_event(skt, event); break; - + case CS_EVENT_CARD_INSERTION: s->pcmcia_state.present = 1; pcmcia_card_add(skt); @@ -1114,19 +1080,14 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) break; case CS_EVENT_EJECTION_REQUEST: - ret = send_event(skt, event, priority); break; case CS_EVENT_PM_SUSPEND: case CS_EVENT_PM_RESUME: case CS_EVENT_RESET_PHYSICAL: case CS_EVENT_CARD_RESET: - handle_event(skt, event); - break; - default: handle_event(skt, event); - send_event(skt, event, priority); break; } @@ -1136,90 +1097,6 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) } /* ds_event */ - -int pcmcia_register_client(struct pcmcia_device **handle, client_reg_t *req) -{ - struct pcmcia_socket *s = NULL; - struct pcmcia_device *p_dev = NULL; - struct pcmcia_driver *p_drv = NULL; - - /* Look for unbound client with matching dev_info */ - down_read(&pcmcia_socket_list_rwsem); - list_for_each_entry(s, &pcmcia_socket_list, socket_list) { - unsigned long flags; - - if (s->state & SOCKET_CARDBUS) - continue; - - s = pcmcia_get_socket(s); - if (!s) - continue; - spin_lock_irqsave(&pcmcia_dev_list_lock, flags); - list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { - p_dev = pcmcia_get_dev(p_dev); - if (!p_dev) - continue; - if (!(p_dev->state & CLIENT_UNBOUND) || - (!p_dev->dev.driver)) { - pcmcia_put_dev(p_dev); - continue; - } - p_drv = to_pcmcia_drv(p_dev->dev.driver); - if (!strncmp(p_drv->drv.name, (char *)req->dev_info, DEV_NAME_LEN)) { - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - goto found; - } - pcmcia_put_dev(p_dev); - } - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - pcmcia_put_socket(s); - } - found: - up_read(&pcmcia_socket_list_rwsem); - if (!p_dev) - return -ENODEV; - - pcmcia_put_socket(s); /* safe, as we already hold a reference from bind_device */ - - *handle = p_dev; - p_dev->state &= ~CLIENT_UNBOUND; - p_dev->event_callback_args = req->event_callback_args; - p_dev->event_callback_args.client_handle = p_dev; - - - if (!s->functions) { - cistpl_longlink_mfc_t mfc; - if (pccard_read_tuple(s, p_dev->func, CISTPL_LONGLINK_MFC, &mfc) - == CS_SUCCESS) - s->functions = mfc.nfn; - else - s->functions = 1; - s->config = kmalloc(sizeof(config_t) * s->functions, - GFP_KERNEL); - if (!s->config) - goto out_no_resource; - memset(s->config, 0, sizeof(config_t) * s->functions); - } - - ds_dbg(1, "register_client(): client 0x%p, dev %s\n", - p_dev, p_dev->dev.bus_id); - - if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT) { - if (p_drv->event) - p_drv->event(CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW, - &p_dev->event_callback_args); - - } - - return CS_SUCCESS; - - out_no_resource: - pcmcia_put_dev(p_dev); - return CS_OUT_OF_RESOURCE; -} /* register_client */ -EXPORT_SYMBOL(pcmcia_register_client); - - static struct pcmcia_callback pcmcia_bus_callback = { .owner = THIS_MODULE, .event = ds_event, diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index 3128ba8..0c9edb7 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -95,27 +95,21 @@ typedef struct scsi_info_t { } scsi_info_t; static void aha152x_release_cs(dev_link_t *link); -static int aha152x_event(event_t event, int priority, - event_callback_args_t *args); - -static dev_link_t *aha152x_attach(void); static void aha152x_detach(struct pcmcia_device *p_dev); +static void aha152x_config_cs(dev_link_t *link); static dev_link_t *dev_list; -static dev_info_t dev_info = "aha152x_cs"; -static dev_link_t *aha152x_attach(void) +static int aha152x_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "aha152x_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (!info) return NULL; + if (!info) return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -129,20 +123,13 @@ static dev_link_t *aha152x_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - link->next = dev_list; - dev_list = link; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - aha152x_detach(link->handle); - return NULL; - } - - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + aha152x_config_cs(link); + + return 0; } /* aha152x_attach */ /*====================================================================*/ @@ -297,22 +284,6 @@ static int aha152x_resume(struct pcmcia_device *dev) return 0; } -static int aha152x_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(0, "aha152x_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - aha152x_config_cs(link); - break; - } - return 0; -} - static struct pcmcia_device_id aha152x_ids[] = { PCMCIA_DEVICE_PROD_ID123("New Media", "SCSI", "Bus Toaster", 0xcdf7e4cc, 0x35f26476, 0xa8851d6e), PCMCIA_DEVICE_PROD_ID123("NOTEWORTHY", "SCSI", "Bus Toaster", 0xad89c6e8, 0x35f26476, 0xa8851d6e), @@ -328,8 +299,7 @@ static struct pcmcia_driver aha152x_cs_driver = { .drv = { .name = "aha152x_cs", }, - .attach = aha152x_attach, - .event = aha152x_event, + .probe = aha152x_attach, .remove = aha152x_detach, .id_table = aha152x_ids, .suspend = aha152x_suspend, diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index 538fedb..788c58d 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -80,27 +80,19 @@ typedef struct scsi_info_t { static void fdomain_release(dev_link_t *link); -static int fdomain_event(event_t event, int priority, - event_callback_args_t *args); - -static dev_link_t *fdomain_attach(void); static void fdomain_detach(struct pcmcia_device *p_dev); +static void fdomain_config(dev_link_t *link); - -static dev_info_t dev_info = "fdomain_cs"; - -static dev_link_t *fdomain_attach(void) +static int fdomain_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; - + DEBUG(0, "fdomain_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (!info) return NULL; + if (!info) return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; link->io.NumPorts1 = 0x10; @@ -113,19 +105,13 @@ static dev_link_t *fdomain_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - fdomain_detach(link->handle); - return NULL; - } - - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + fdomain_config(link); + + return 0; } /* fdomain_attach */ /*====================================================================*/ @@ -265,23 +251,6 @@ static int fdomain_resume(struct pcmcia_device *dev) return 0; } -static int fdomain_event(event_t event, int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "fdomain_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - fdomain_config(link); - break; - } - return 0; -} /* fdomain_event */ - - static struct pcmcia_device_id fdomain_ids[] = { PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20), PCMCIA_DEVICE_PROD_ID1("SCSI PCMCIA Adapter Card", 0x8dacb57e), @@ -295,8 +264,7 @@ static struct pcmcia_driver fdomain_cs_driver = { .drv = { .name = "fdomain_cs", }, - .attach = fdomain_attach, - .event = fdomain_event, + .probe = fdomain_attach, .remove = fdomain_detach, .id_table = fdomain_ids, .suspend = fdomain_suspend, diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index e48e9fb..9e3ab3f 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -104,8 +104,6 @@ static struct scsi_host_template nsp_driver_template = { #endif }; -static dev_info_t dev_info = {"nsp_cs"}; - static nsp_hw_data nsp_data_base; /* attach <-> detect glue */ @@ -1595,19 +1593,17 @@ static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt) configure the card at this point -- we wait until we receive a card insertion event. ======================================================================*/ -static dev_link_t *nsp_cs_attach(void) +static int nsp_cs_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; nsp_hw_data *data = &nsp_data_base; nsp_dbg(NSP_DEBUG_INIT, "in"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (info == NULL) { return NULL; } + if (info == NULL) { return -ENOMEM; } memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -1635,22 +1631,14 @@ static dev_link_t *nsp_cs_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; + link->handle = p_dev; + p_dev->instance = link; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - nsp_cs_detach(link->handle); - return NULL; - } - + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + nsp_cs_config(link); nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); - return link; + return 0; } /* nsp_cs_attach */ @@ -2056,44 +2044,6 @@ static int nsp_cs_resume(struct pcmcia_device *dev) return 0; } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the net drivers from trying - to talk to the card any more. - - When a CARD_REMOVAL event is received, we immediately set a flag - to block future accesses to this device. All the functions that - actually access the device should check this flag to make sure - the card is still present. - -======================================================================*/ -static int nsp_cs_event(event_t event, - int priority, - event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - nsp_dbg(NSP_DEBUG_INIT, "event: insert"); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) - info->bus = args->bus; -#endif - nsp_cs_config(link); - break; - default: - nsp_dbg(NSP_DEBUG_INIT, "event: unknown"); - break; - } - nsp_dbg(NSP_DEBUG_INIT, "end"); - return 0; -} /* nsp_cs_event */ - /*======================================================================* * module entry point *====================================================================*/ @@ -2115,8 +2065,7 @@ static struct pcmcia_driver nsp_driver = { .drv = { .name = "nsp_cs", }, - .attach = nsp_cs_attach, - .event = nsp_cs_event, + .probe = nsp_cs_attach, .remove = nsp_cs_detach, .id_table = nsp_cs_ids, .suspend = nsp_cs_suspend, diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h index d276c46..b66b140 100644 --- a/drivers/scsi/pcmcia/nsp_cs.h +++ b/drivers/scsi/pcmcia/nsp_cs.h @@ -296,11 +296,9 @@ typedef struct _nsp_hw_data { */ /* Card service functions */ -static dev_link_t *nsp_cs_attach (void); static void nsp_cs_detach (struct pcmcia_device *p_dev); static void nsp_cs_release(dev_link_t *link); static void nsp_cs_config (dev_link_t *link); -static int nsp_cs_event (event_t event, int priority, event_callback_args_t *args); /* Linux SCSI subsystem specific functions */ static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht); diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index e10281a..dce7e68 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -98,13 +98,8 @@ typedef struct scsi_info_t { } scsi_info_t; static void qlogic_release(dev_link_t *link); -static int qlogic_event(event_t event, int priority, event_callback_args_t * args); - -static dev_link_t *qlogic_attach(void); static void qlogic_detach(struct pcmcia_device *p_dev); - - -static dev_info_t dev_info = "qlogic_cs"; +static void qlogic_config(dev_link_t * link); static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host, dev_link_t *link, int qbase, int qlirq) @@ -161,19 +156,17 @@ free_scsi_host: err: return NULL; } -static dev_link_t *qlogic_attach(void) +static int qlogic_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "qlogic_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -187,19 +180,13 @@ static dev_link_t *qlogic_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - qlogic_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + qlogic_config(link); - return link; + return 0; } /* qlogic_attach */ /*====================================================================*/ @@ -368,21 +355,6 @@ static int qlogic_resume(struct pcmcia_device *dev) return 0; } -static int qlogic_event(event_t event, int priority, event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "qlogic_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - qlogic_config(link); - break; - } - return 0; -} /* qlogic_event */ - static struct pcmcia_device_id qlogic_ids[] = { PCMCIA_DEVICE_PROD_ID12("EIger Labs", "PCMCIA-to-SCSI Adapter", 0x88395fa7, 0x33b7a5e6), PCMCIA_DEVICE_PROD_ID12("EPSON", "SCSI-2 PC Card SC200", 0xd361772f, 0x299d1751), @@ -410,8 +382,7 @@ static struct pcmcia_driver qlogic_cs_driver = { .drv = { .name = "qlogic_cs", }, - .attach = qlogic_attach, - .event = qlogic_event, + .probe = qlogic_attach, .remove = qlogic_detach, .id_table = qlogic_ids, .suspend = qlogic_suspend, diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 87d50b3..3a4dd6f 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -228,14 +228,6 @@ enum Phase { /* ================================================================== */ -/* -* Global (within this module) variables other than -* sym53c500_driver_template (the scsi_host_template). -*/ -static dev_info_t dev_info = "sym53c500_cs"; - -/* ================================================================== */ - static void chip_init(int io_port) { @@ -909,22 +901,6 @@ static int sym53c500_resume(struct pcmcia_device *dev) return 0; } -static int -SYM53C500_event(event_t event, int priority, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "SYM53C500_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - SYM53C500_config(link); - break; - } - return 0; -} /* SYM53C500_event */ - static void SYM53C500_detach(struct pcmcia_device *p_dev) { @@ -939,20 +915,18 @@ SYM53C500_detach(struct pcmcia_device *p_dev) link->priv = NULL; } /* SYM53C500_detach */ -static dev_link_t * -SYM53C500_attach(void) +static int +SYM53C500_attach(struct pcmcia_device *p_dev) { struct scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "SYM53C500_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -966,19 +940,13 @@ SYM53C500_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - SYM53C500_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + SYM53C500_config(link); + + return 0; } /* SYM53C500_attach */ MODULE_AUTHOR("Bob Tracy "); @@ -998,8 +966,7 @@ static struct pcmcia_driver sym53c500_cs_driver = { .drv = { .name = "sym53c500_cs", }, - .attach = SYM53C500_attach, - .event = SYM53C500_event, + .probe = SYM53C500_attach, .remove = SYM53C500_detach, .id_table = sym53c500_ids, .suspend = sym53c500_suspend, diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 6e7a1a0..96969cb 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -114,13 +114,7 @@ struct serial_cfg_mem { static void serial_config(dev_link_t * link); -static int serial_event(event_t event, int priority, - event_callback_args_t * args); -static dev_info_t dev_info = "serial_cs"; - -static dev_link_t *serial_attach(void); -static void serial_detach(struct pcmcia_device *p_dev); /*====================================================================== @@ -203,19 +197,17 @@ static int serial_resume(struct pcmcia_device *dev) ======================================================================*/ -static dev_link_t *serial_attach(void) +static int serial_probe(struct pcmcia_device *p_dev) { struct serial_info *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "serial_attach()\n"); /* Create new serial device */ info = kmalloc(sizeof (*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; memset(info, 0, sizeof (*info)); link = &info->link; link->priv = info; @@ -231,19 +223,12 @@ static dev_link_t *serial_attach(void) } link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; /* not needed */ - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - serial_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + serial_config(link); - return link; + return 0; } /*====================================================================== @@ -706,32 +691,6 @@ void serial_config(dev_link_t * link) kfree(cfg_mem); } -/*====================================================================== - - The card status event handler. Mostly, this schedules other - stuff to run after an event is received. A CARD_REMOVAL event - also sets some flags to discourage the serial drivers from - talking to the ports. - -======================================================================*/ - -static int -serial_event(event_t event, int priority, event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - - DEBUG(1, "serial_event(0x%06x)\n", event); - - switch (event) { - - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - serial_config(link); - break; - } - return 0; -} - static struct pcmcia_device_id serial_ids[] = { PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), @@ -843,8 +802,7 @@ static struct pcmcia_driver serial_cs_driver = { .drv = { .name = "serial_cs", }, - .attach = serial_attach, - .event = serial_event, + .probe = serial_probe, .remove = serial_detach, .id_table = serial_ids, .suspend = serial_suspend, diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index 6b99298..d3a7b0c 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -34,23 +34,19 @@ typedef struct ixj_info_t { struct ixj *port; } ixj_info_t; -static dev_link_t *ixj_attach(void); static void ixj_detach(struct pcmcia_device *p_dev); static void ixj_config(dev_link_t * link); static void ixj_cs_release(dev_link_t * link); -static int ixj_event(event_t event, int priority, event_callback_args_t * args); -static dev_info_t dev_info = "ixj_cs"; -static dev_link_t *ixj_attach(void) +static int ixj_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; dev_link_t *link; - int ret; + DEBUG(0, "ixj_attach()\n"); /* Create new ixj device */ link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); if (!link) - return NULL; + return -ENOMEM; memset(link, 0, sizeof(struct dev_link_t)); link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; @@ -60,21 +56,17 @@ static dev_link_t *ixj_attach(void) link->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL); if (!link->priv) { kfree(link); - return NULL; + return -ENOMEM; } memset(link->priv, 0, sizeof(struct ixj_info_t)); - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - ixj_detach(link->handle); - return NULL; - } - return link; + + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + ixj_config(link); + + return 0; } static void ixj_detach(struct pcmcia_device *p_dev) @@ -265,19 +257,6 @@ static int ixj_resume(struct pcmcia_device *dev) return 0; } -static int ixj_event(event_t event, int priority, event_callback_args_t * args) -{ - dev_link_t *link = args->client_data; - DEBUG(1, "ixj_event(0x%06x)\n", event); - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - ixj_config(link); - break; - } - return 0; -} - static struct pcmcia_device_id ixj_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x0257, 0x0600), PCMCIA_DEVICE_NULL @@ -289,8 +268,7 @@ static struct pcmcia_driver ixj_driver = { .drv = { .name = "ixj_cs", }, - .attach = ixj_attach, - .event = ixj_event, + .probe = ixj_attach, .remove = ixj_detach, .id_table = ixj_ids, .suspend = ixj_suspend, diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 4397096..466384d 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -325,32 +325,14 @@ static int sl811_resume(struct pcmcia_device *dev) return 0; } -static int -sl811_cs_event(event_t event, int priority, event_callback_args_t *args) -{ - dev_link_t *link = args->client_data; - - DBG(1, "sl811_cs_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - sl811_cs_config(link); - break; - } - return 0; -} - -static dev_link_t *sl811_cs_attach(void) +static int sl811_cs_attach(struct pcmcia_device *p_dev) { local_info_t *local; dev_link_t *link; - client_reg_t client_reg; - int ret; local = kmalloc(sizeof(local_info_t), GFP_KERNEL); if (!local) - return NULL; + return -ENOMEM; memset(local, 0, sizeof(local_info_t)); link = &local->link; link->priv = local; @@ -364,20 +346,13 @@ static dev_link_t *sl811_cs_attach(void) link->conf.Vcc = 33; link->conf.IntType = INT_MEMORY_AND_IO; - /* Register with Card Services */ - link->next = NULL; - client_reg.dev_info = (dev_info_t *) &driver_name; - client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - sl811_cs_detach(link->handle); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; - return link; + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + sl811_cs_config(link); + + return 0; } static struct pcmcia_device_id sl811_ids[] = { @@ -391,8 +366,7 @@ static struct pcmcia_driver sl811_cs_driver = { .drv = { .name = (char *)driver_name, }, - .attach = sl811_cs_attach, - .event = sl811_cs_event, + .probe = sl811_cs_attach, .remove = sl811_cs_detach, .id_table = sl811_ids, .suspend = sl811_suspend, diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h index a751251..52660f3 100644 --- a/include/pcmcia/cs.h +++ b/include/pcmcia/cs.h @@ -389,7 +389,6 @@ int pcmcia_get_status(struct pcmcia_device *p_dev, cs_status_t *status); int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); int pcmcia_map_mem_page(window_handle_t win, memreq_t *req); int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); -int pcmcia_register_client(client_handle_t *handle, client_reg_t *req); int pcmcia_release_configuration(struct pcmcia_device *p_dev); int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req); int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req); diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h index c53a060..8e2a963 100644 --- a/include/pcmcia/ds.h +++ b/include/pcmcia/ds.h @@ -133,10 +133,7 @@ typedef struct dev_link_t { struct pcmcia_socket; struct pcmcia_driver { - dev_link_t *(*attach)(void); - int (*event) (event_t event, int priority, - event_callback_args_t *); - + int (*probe) (struct pcmcia_device *dev); void (*remove) (struct pcmcia_device *dev); int (*suspend) (struct pcmcia_device *dev); @@ -169,7 +166,6 @@ struct pcmcia_device { /* deprecated, a cleaned up version will be moved into this struct soon */ dev_link_t *instance; - event_callback_args_t event_callback_args; u_int state; /* information about this device */ -- cgit v1.1 From efe3cd105f2a19e72ce9280bb22c7c80752e4314 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Fri, 6 Jan 2006 00:27:16 +0100 Subject: [PATCH] pcmcia: fix sound drivers Update the PCMCIA sound drivers to handle the recent changes to the PCMCIA core. A part of this merge was done by Takashi Iwai . Signed-off-by: Dominik Brodowski --- sound/pcmcia/pdaudiocf/pdaudiocf.c | 154 ++++++++++++++---------------------- sound/pcmcia/vx/vxpocket.c | 155 +++++++++++++------------------------ 2 files changed, 115 insertions(+), 194 deletions(-) diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index a7cd2d4..77caf43 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c @@ -52,16 +52,13 @@ MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); /* */ -static dev_info_t dev_info = "snd-pdaudiocf"; static struct snd_card *card_list[SNDRV_CARDS]; -static dev_link_t *dev_list; /* * prototypes */ static void pdacf_config(dev_link_t *link); -static int pdacf_event(event_t event, int priority, event_callback_args_t *args); -static void snd_pdacf_detach(dev_link_t *link); +static void snd_pdacf_detach(struct pcmcia_device *p_dev); static void pdacf_release(dev_link_t *link) { @@ -83,10 +80,6 @@ static int snd_pdacf_free(struct snd_pdacf *pdacf) pdacf_release(link); - /* Break the link with Card Services */ - if (link->handle) - pcmcia_deregister_client(link->handle); - card_list[pdacf->index] = NULL; pdacf->card = NULL; @@ -103,11 +96,10 @@ static int snd_pdacf_dev_free(struct snd_device *device) /* * snd_pdacf_attach - attach callback for cs */ -static dev_link_t *snd_pdacf_attach(void) +static int snd_pdacf_attach(struct pcmcia_device *p_dev) { - client_reg_t client_reg; /* Register with cardmgr */ - dev_link_t *link; /* Info for cardmgr */ - int i, ret; + int i; + dev_link_t *link; /* Info for cardmgr */ struct snd_pdacf *pdacf; struct snd_card *card; static struct snd_device_ops ops = { @@ -122,26 +114,26 @@ static dev_link_t *snd_pdacf_attach(void) } if (i >= SNDRV_CARDS) { snd_printk(KERN_ERR "pdacf: too many cards found\n"); - return NULL; + return -EINVAL; } if (! enable[i]) - return NULL; /* disabled explicitly */ + return -ENODEV; /* disabled explicitly */ /* ok, create a card instance */ card = snd_card_new(index[i], id[i], THIS_MODULE, 0); if (card == NULL) { snd_printk(KERN_ERR "pdacf: cannot create a card instance\n"); - return NULL; + return -ENOMEM; } pdacf = snd_pdacf_create(card); if (! pdacf) - return NULL; + return -EIO; if (snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops) < 0) { kfree(pdacf); snd_card_free(card); - return NULL; + return -ENODEV; } pdacf->index = i; @@ -165,22 +157,12 @@ static dev_link_t *snd_pdacf_attach(void) link->conf.Present = PRESENT_OPTION; /* Chain drivers */ - link->next = dev_list; - dev_list = link; - - /* Register with Card Services */ - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - snd_pdacf_detach(link); - return NULL; - } + link->next = NULL; - return link; + link->handle = p_dev; + pdacf_config(link); + + return 0; } @@ -227,21 +209,13 @@ static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irq /* * snd_pdacf_detach - detach callback for cs */ -static void snd_pdacf_detach(dev_link_t *link) +static void snd_pdacf_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct snd_pdacf *chip = link->priv; snd_printdd(KERN_DEBUG "pdacf_detach called\n"); - /* Remove the interface data from the linked list */ - { - dev_link_t **linkp; - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp) - *linkp = link->next; - } + if (chip->chip_status & PDAUDIOCF_STAT_IS_CONFIGURED) snd_pdacf_powerdown(chip); chip->chip_status |= PDAUDIOCF_STAT_IS_STALE; /* to be sure */ @@ -310,62 +284,51 @@ failed: pcmcia_release_irq(link->handle, &link->irq); } -/* - * event callback - */ -static int pdacf_event(event_t event, int priority, event_callback_args_t *args) +#ifdef CONFIG_PM + +static int pdacf_suspend(struct pcmcia_device *dev) { - dev_link_t *link = args->client_data; + dev_link_t *link = dev_to_instance(dev); struct snd_pdacf *chip = link->priv; - switch (event) { - case CS_EVENT_CARD_REMOVAL: - snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n"); - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - chip->chip_status |= PDAUDIOCF_STAT_IS_STALE; - } - break; - case CS_EVENT_CARD_INSERTION: - snd_printdd(KERN_DEBUG "CARD_INSERTION..\n"); - link->state |= DEV_PRESENT; - pdacf_config(link); - break; -#ifdef CONFIG_PM - case CS_EVENT_PM_SUSPEND: - snd_printdd(KERN_DEBUG "SUSPEND\n"); - link->state |= DEV_SUSPEND; + snd_printdd(KERN_DEBUG "SUSPEND\n"); + link->state |= DEV_SUSPEND; + if (chip) { + snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); + snd_pdacf_suspend(chip, PMSG_SUSPEND); + } + + snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int pdacf_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + struct snd_pdacf *chip = link->priv; + + snd_printdd(KERN_DEBUG "RESUME\n"); + link->state &= ~DEV_SUSPEND; + + snd_printdd(KERN_DEBUG "CARD_RESET\n"); + if (DEV_OK(link)) { + snd_printdd(KERN_DEBUG "requestconfig...\n"); + pcmcia_request_configuration(link->handle, &link->conf); if (chip) { - snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); - snd_pdacf_suspend(chip, PMSG_SUSPEND); - } - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - snd_printdd(KERN_DEBUG "RESUME\n"); - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - snd_printdd(KERN_DEBUG "CARD_RESET\n"); - if (DEV_OK(link)) { - snd_printdd(KERN_DEBUG "requestconfig...\n"); - pcmcia_request_configuration(link->handle, &link->conf); - if (chip) { - snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); - snd_pdacf_resume(chip); - } + snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); + snd_pdacf_resume(chip); } - snd_printdd(KERN_DEBUG "resume done!\n"); - break; -#endif } + snd_printdd(KERN_DEBUG "resume done!\n"); + return 0; } +#endif + /* * Module entry points */ @@ -380,10 +343,14 @@ static struct pcmcia_driver pdacf_cs_driver = { .drv = { .name = "snd-pdaudiocf", }, - .attach = snd_pdacf_attach, - .event = pdacf_event, - .detach = snd_pdacf_detach, + .probe = snd_pdacf_attach, + .remove = snd_pdacf_detach, .id_table = snd_pdacf_ids, +#ifdef CONFIG_PM + .suspend = pdacf_suspend, + .resume = pdacf_resume, +#endif + }; static int __init init_pdacf(void) @@ -394,7 +361,6 @@ static int __init init_pdacf(void) static void __exit exit_pdacf(void) { pcmcia_unregister_driver(&pdacf_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_pdacf); diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index 5bb079d..66900d2 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c @@ -55,11 +55,6 @@ MODULE_PARM_DESC(ibl, "Capture IBL size for VXPocket soundcard."); */ static unsigned int card_alloc; -static dev_link_t *dev_list; /* Linked list of devices */ -static dev_info_t dev_info = "snd-vxpocket"; - - -static int vxpocket_event(event_t event, int priority, event_callback_args_t *args); /* @@ -73,11 +68,6 @@ static void vxpocket_release(dev_link_t *link) pcmcia_release_irq(link->handle, &link->irq); link->state &= ~DEV_CONFIG; } - if (link->handle) { - /* Break the link with Card Services */ - pcmcia_deregister_client(link->handle); - link->handle = NULL; - } } /* @@ -144,11 +134,9 @@ static struct snd_vx_hardware vxp440_hw = { */ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) { - client_reg_t client_reg; /* Register with cardmgr */ dev_link_t *link; /* Info for cardmgr */ struct vx_core *chip; struct snd_vxpocket *vxp; - int ret; static struct snd_device_ops ops = { .dev_free = snd_vxpocket_dev_free, }; @@ -184,26 +172,6 @@ static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) link->conf.ConfigIndex = 1; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - memset(&client_reg, 0, sizeof(client_reg)); - client_reg.dev_info = &dev_info; - client_reg.EventMask = - CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL -#ifdef CONFIG_PM - | CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET - | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME -#endif - ; - client_reg.event_handler = &vxpocket_event; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - return NULL; - } - return vxp; } @@ -317,67 +285,55 @@ failed: kfree(parse); } +#ifdef CONFIG_PM -/* - * event callback - */ -static int vxpocket_event(event_t event, int priority, event_callback_args_t *args) +static int vxp_suspend(struct pcmcia_device *dev) { - dev_link_t *link = args->client_data; + dev_link_t *link = dev_to_instance(dev); struct vx_core *chip = link->priv; - switch (event) { - case CS_EVENT_CARD_REMOVAL: - snd_printdd(KERN_DEBUG "CARD_REMOVAL..\n"); - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - chip->chip_status |= VX_STAT_IS_STALE; - break; - case CS_EVENT_CARD_INSERTION: - snd_printdd(KERN_DEBUG "CARD_INSERTION..\n"); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - vxpocket_config(link); - break; -#ifdef CONFIG_PM - case CS_EVENT_PM_SUSPEND: - snd_printdd(KERN_DEBUG "SUSPEND\n"); - link->state |= DEV_SUSPEND; + snd_printdd(KERN_DEBUG "SUSPEND\n"); + link->state |= DEV_SUSPEND; + if (chip) { + snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); + snd_vx_suspend(chip, PMSG_SUSPEND); + } + snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int vxp_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + struct vx_core *chip = link->priv; + + snd_printdd(KERN_DEBUG "RESUME\n"); + link->state &= ~DEV_SUSPEND; + + snd_printdd(KERN_DEBUG "CARD_RESET\n"); + if (DEV_OK(link)) { + //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; + snd_printdd(KERN_DEBUG "requestconfig...\n"); + pcmcia_request_configuration(link->handle, &link->conf); if (chip) { - snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); - snd_vx_suspend(chip, PMSG_SUSPEND); + snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); + snd_vx_resume(chip); } - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); - if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: - snd_printdd(KERN_DEBUG "RESUME\n"); - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - snd_printdd(KERN_DEBUG "CARD_RESET\n"); - if (DEV_OK(link)) { - //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; - snd_printdd(KERN_DEBUG "requestconfig...\n"); - pcmcia_request_configuration(link->handle, &link->conf); - if (chip) { - snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); - snd_vx_resume(chip); - } - } - snd_printdd(KERN_DEBUG "resume done!\n"); - break; -#endif } + snd_printdd(KERN_DEBUG "resume done!\n"); + return 0; } +#endif + /* */ -static dev_link_t *vxpocket_attach(void) +static int vxpocket_attach(struct pcmcia_device *p_dev) { struct snd_card *card; struct snd_vxpocket *vxp; @@ -390,22 +346,22 @@ static dev_link_t *vxpocket_attach(void) } if (i >= SNDRV_CARDS) { snd_printk(KERN_ERR "vxpocket: too many cards found\n"); - return NULL; + return -EINVAL; } if (! enable[i]) - return NULL; /* disabled explicitly */ + return -ENODEV; /* disabled explicitly */ /* ok, create a card instance */ card = snd_card_new(index[i], id[i], THIS_MODULE, 0); if (card == NULL) { snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n"); - return NULL; + return -ENOMEM; } vxp = snd_vxpocket_new(card, ibl[i]); if (! vxp) { snd_card_free(card); - return NULL; + return -ENODEV; } card->private_data = vxp; @@ -413,17 +369,21 @@ static dev_link_t *vxpocket_attach(void) card_alloc |= 1 << i; /* Chain drivers */ - vxp->link.next = dev_list; - dev_list = &vxp->link; + vxp->link.next = NULL; + + vxp->link.handle = p_dev; + vxp->link.state |= DEV_PRESENT | DEV_CONFIG_PENDING; + p_dev->instance = &vxp->link; + vxpocket_config(&vxp->link); - return &vxp->link; + return 0; } -static void vxpocket_detach(dev_link_t *link) +static void vxpocket_detach(struct pcmcia_device *p_dev) { + dev_link_t *link = dev_to_instance(p_dev); struct snd_vxpocket *vxp; struct vx_core *chip; - dev_link_t **linkp; if (! link) return; @@ -432,13 +392,6 @@ static void vxpocket_detach(dev_link_t *link) chip = (struct vx_core *)vxp; card_alloc &= ~(1 << vxp->index); - /* Remove the interface data from the linked list */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) { - *linkp = link->next; - break; - } - chip->chip_status |= VX_STAT_IS_STALE; /* to be sure */ snd_card_disconnect(chip->card); vxpocket_release(link); @@ -460,10 +413,13 @@ static struct pcmcia_driver vxp_cs_driver = { .drv = { .name = "snd-vxpocket", }, - .attach = vxpocket_attach, - .detach = vxpocket_detach, - .event = vxpocket_event, + .probe = vxpocket_attach, + .remove = vxpocket_detach, .id_table = vxp_ids, +#ifdef CONFIG_PM + .suspend = vxp_suspend, + .resume = vxp_resume, +#endif }; static int __init init_vxpocket(void) @@ -474,7 +430,6 @@ static int __init init_vxpocket(void) static void __exit exit_vxpocket(void) { pcmcia_unregister_driver(&vxp_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_vxpocket); -- cgit v1.1 From 3b27e9421a1433689704fe0a02e926d4ba971121 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Wed, 7 Dec 2005 12:32:20 +0100 Subject: [PATCH] pcmcia: properly handle static mem, but dynamic io sockets Some PCMCIA sockets have statically mapped memory windows, but dynamically mapped IO windows. Using the "nonstatic" socket library is inpractical for them, as they do neither need a resource database (as we can trust the kernel resource database on m68k and ppc) nor lots of other features of that library. Let them get a small "iodyn" socket library (105 lines of code) instead. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/Kconfig | 5 ++- drivers/pcmcia/m8xx_pcmcia.c | 2 +- drivers/pcmcia/rsrc_mgr.c | 102 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 2 deletions(-) diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index ea00b1f..df93df6 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -182,7 +182,7 @@ config TCIC config PCMCIA_M8XX tristate "MPC8xx PCMCIA support" depends on PCMCIA && PPC && 8xx - select PCCARD_NONSTATIC + select PCCARD_IODYN help Say Y here to include support for PowerPC 8xx series PCMCIA controller. @@ -266,6 +266,9 @@ config OMAP_CF config PCCARD_NONSTATIC tristate +config PCCARD_IODYN + bool + endif # PCCARD endmenu diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c index a7f27c3..570e4e8 100644 --- a/drivers/pcmcia/m8xx_pcmcia.c +++ b/drivers/pcmcia/m8xx_pcmcia.c @@ -1232,7 +1232,7 @@ static int __init m8xx_init(void) socket[i].socket.io_offset = 0; socket[i].socket.pci_irq = i ? 7 : 9; socket[i].socket.ops = &m8xx_services; - socket[i].socket.resource_ops = &pccard_nonstatic_ops; + socket[i].socket.resource_ops = &pccard_iodyn_ops; socket[i].socket.cb_dev = NULL; socket[i].socket.dev.dev = &m8xx_device.dev; } diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c index b02598a..5146093 100644 --- a/drivers/pcmcia/rsrc_mgr.c +++ b/drivers/pcmcia/rsrc_mgr.c @@ -166,3 +166,105 @@ struct pccard_resource_ops pccard_static_ops = { .exit = NULL, }; EXPORT_SYMBOL(pccard_static_ops); + + +#ifdef CONFIG_PCCARD_IODYN + +static struct resource * +make_resource(unsigned long b, unsigned long n, int flags, char *name) +{ + struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); + + if (res) { + res->name = name; + res->start = b; + res->end = b + n - 1; + res->flags = flags; + } + return res; +} + +struct pcmcia_align_data { + unsigned long mask; + unsigned long offset; +}; + +static void pcmcia_align(void *align_data, struct resource *res, + unsigned long size, unsigned long align) +{ + struct pcmcia_align_data *data = align_data; + unsigned long start; + + start = (res->start & ~data->mask) + data->offset; + if (start < res->start) + start += data->mask + 1; + res->start = start; + +#ifdef CONFIG_X86 + if (res->flags & IORESOURCE_IO) { + if (start & 0x300) { + start = (start + 0x3ff) & ~0x3ff; + res->start = start; + } + } +#endif + +#ifdef CONFIG_M68K + if (res->flags & IORESOURCE_IO) { + if ((res->start + size - 1) >= 1024) + res->start = res->end; + } +#endif +} + + +static int iodyn_adjust_io_region(struct resource *res, unsigned long r_start, + unsigned long r_end, struct pcmcia_socket *s) +{ + return adjust_resource(res, r_start, r_end - r_start + 1); +} + + +static struct resource *iodyn_find_io_region(unsigned long base, int num, + unsigned long align, struct pcmcia_socket *s) +{ + struct resource *res = make_resource(0, num, IORESOURCE_IO, + s->dev.class_id); + struct pcmcia_align_data data; + unsigned long min = base; + int ret; + + if (align == 0) + align = 0x10000; + + data.mask = align - 1; + data.offset = base & data.mask; + +#ifdef CONFIG_PCI + if (s->cb_dev) { + ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1, + min, 0, pcmcia_align, &data); + } else +#endif + ret = allocate_resource(&ioport_resource, res, num, min, ~0UL, + 1, pcmcia_align, &data); + + if (ret != 0) { + kfree(res); + res = NULL; + } + return res; +} + +struct pccard_resource_ops pccard_iodyn_ops = { + .validate_mem = NULL, + .adjust_io_region = iodyn_adjust_io_region, + .find_io = iodyn_find_io_region, + .find_mem = NULL, + .adjust_resource = NULL, + .init = static_init, + .exit = NULL, +}; +EXPORT_SYMBOL(pccard_iodyn_ops); + +#endif /* CONFIG_PCCARD_IODYN */ -- cgit v1.1 From a94515fa1f1609249dbebcfb93181ad0ba4b285a Mon Sep 17 00:00:00 2001 From: Vitaly Bordug Date: Thu, 8 Dec 2005 13:53:20 -0200 Subject: [PATCH] m8xx_pcmcia: support MAP_AUTOSZ required for CF cards This fixes misconfiguration that could result in odd work of some old CF cards. Signed-off-by: Vitaly Bordug Signed-off-by: Marcelo Tosatti Signed-off-by: Dominik Brodowski --- drivers/pcmcia/m8xx_pcmcia.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c index 570e4e8..ddaab13 100644 --- a/drivers/pcmcia/m8xx_pcmcia.c +++ b/drivers/pcmcia/m8xx_pcmcia.c @@ -1012,8 +1012,7 @@ static int m8xx_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io) if(io->flags & MAP_WRPROT) reg |= M8XX_PCMCIA_POR_WRPROT; - /*if(io->flags & (MAP_16BIT | MAP_AUTOSZ))*/ - if(io->flags & MAP_16BIT) + if(io->flags & (MAP_16BIT | MAP_AUTOSZ)) reg |= M8XX_PCMCIA_POR_16BIT; if(io->flags & MAP_ACTIVE) -- cgit v1.1 From 1371d3be045a6a1a8b828b838069b5fe6e0ab4c6 Mon Sep 17 00:00:00 2001 From: Vitaly Bordug Date: Thu, 8 Dec 2005 13:56:12 -0200 Subject: [PATCH] 8xx PCMCIA: support for MPC885ADS and MPC866ADS This adds PCMCIA support for both MPC885ADS and MPC866ADS. This is established not together with FADS, because 885 does not have io_block_mapping() for BCSR area. Also, some cleanups done both for 885ADS and MBX. Signed-off-by: Vitaly Bordug Signed-off-by: Marcelo Tosatti Signed-off-by: Dominik Brodowski --- drivers/pcmcia/m8xx_pcmcia.c | 97 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 6 deletions(-) diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c index ddaab13..0e07d95 100644 --- a/drivers/pcmcia/m8xx_pcmcia.c +++ b/drivers/pcmcia/m8xx_pcmcia.c @@ -9,6 +9,9 @@ * * Further fixes, v2.6 kernel port * + * + * Some fixes, additions (C) 2005 Montavista Software, Inc. + * * * "The ExCA standard specifies that socket controllers should provide * two IO and five memory windows per socket, which can be independently @@ -97,6 +100,11 @@ MODULE_LICENSE("Dual MPL/GPL"); #endif #endif +#if defined(CONFIG_MPC885ADS) +#define CONFIG_PCMCIA_SLOT_A +#define PCMCIA_GLITCHY_CD +#endif + /* Cyclades ACS uses both slots */ #ifdef CONFIG_PRxK #define CONFIG_PCMCIA_SLOT_A @@ -374,11 +382,80 @@ static int voltage_set(int slot, int vcc, int vpp) } /* first, turn off all power */ - out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) & ~(BCSR1_PCCVCC_MASK | BCSR1_PCCVPP_MASK)); + out_be32((u32 *)BCSR1, in_be32((u32 *)BCSR1) & ~(BCSR1_PCCVCC_MASK | BCSR1_PCCVPP_MASK)); + + /* enable new powersettings */ + out_be32((u32 *)BCSR1, in_be32((u32 *)BCSR1) | reg); + + return 0; +} + +#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V + +static void hardware_enable(int slot) +{ + out_be32((u32 *)BCSR1, in_be32((u32 *)BCSR1) & ~BCSR1_PCCEN); +} + +static void hardware_disable(int slot) +{ + out_be32((u32 *)BCSR1, in_be32((u32 *)BCSR1) | BCSR1_PCCEN); +} + +#endif + +/* MPC885ADS Boards */ + +#if defined(CONFIG_MPC885ADS) + +#define PCMCIA_BOARD_MSG "MPC885ADS" + +static int voltage_set(int slot, int vcc, int vpp) +{ + u32 reg = 0; + unsigned *bcsr_io; + + bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); + + switch(vcc) { + case 0: + break; + case 33: + reg |= BCSR1_PCCVCC0; + break; + case 50: + reg |= BCSR1_PCCVCC1; + break; + default: + return 1; + } + + switch(vpp) { + case 0: + break; + case 33: + case 50: + if(vcc == vpp) + reg |= BCSR1_PCCVPP1; + else + return 1; + break; + case 120: + if ((vcc == 33) || (vcc == 50)) + reg |= BCSR1_PCCVPP0; + else + return 1; + default: + return 1; + } + + /* first, turn off all power */ + out_be32(bcsr_io, in_be32(bcsr_io) & ~(BCSR1_PCCVCC_MASK | BCSR1_PCCVPP_MASK)); /* enable new powersettings */ - out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) | reg); + out_be32(bcsr_io, in_be32(bcsr_io) | reg); + iounmap(bcsr_io); return 0; } @@ -386,12 +463,20 @@ static int voltage_set(int slot, int vcc, int vpp) static void hardware_enable(int slot) { - out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) & ~BCSR1_PCCEN); + unsigned *bcsr_io; + + bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); + out_be32(bcsr_io, in_be32(bcsr_io) & ~BCSR1_PCCEN); + iounmap(bcsr_io); } static void hardware_disable(int slot) { - out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) | BCSR1_PCCEN); + unsigned *bcsr_io; + + bcsr_io = ioremap(BCSR1, sizeof(unsigned long)); + out_be32(bcsr_io, in_be32(bcsr_io) | BCSR1_PCCEN); + iounmap(bcsr_io); } #endif @@ -440,10 +525,10 @@ static int voltage_set(int slot, int vcc, int vpp) } /* first, turn off all power */ - out_8(&((u8 *)MBX_CSR2_ADDR), in_8(&((u8 *)MBX_CSR2_ADDR)) & ~(CSR2_VCC_MASK | CSR2_VPP_MASK)); + out_8((u8 *)MBX_CSR2_ADDR, in_8((u8 *)MBX_CSR2_ADDR) & ~(CSR2_VCC_MASK | CSR2_VPP_MASK)); /* enable new powersettings */ - out_8(&((u8 *)MBX_CSR2_ADDR), in_8(&((u8 *)MBX_CSR2_ADDR)) | reg); + out_8((u8 *)MBX_CSR2_ADDR, in_8((u8 *)MBX_CSR2_ADDR) | reg); return 0; } -- cgit v1.1 From 002dbb2d0d42b4a2c1eef2012c2fe7af48163b3c Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Thu, 8 Dec 2005 23:50:36 +0100 Subject: [PATCH] pcmcia: export stored values in sysfs Export the stored values instead of re-reading everything in the socket information sysfs files, and make them accessible to all users, not only to root. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/socket_sysfs.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index 4a3150a..e074bc1 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c @@ -42,35 +42,28 @@ static ssize_t pccard_show_type(struct class_device *dev, char *buf) { - int val; struct pcmcia_socket *s = to_socket(dev); if (!(s->state & SOCKET_PRESENT)) return -ENODEV; - s->ops->get_status(s, &val); - if (val & SS_CARDBUS) + if (s->state & SOCKET_CARDBUS) return sprintf(buf, "32-bit\n"); - if (val & SS_DETECT) - return sprintf(buf, "16-bit\n"); - return sprintf(buf, "invalid\n"); + return sprintf(buf, "16-bit\n"); } -static CLASS_DEVICE_ATTR(card_type, 0400, pccard_show_type, NULL); +static CLASS_DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL); static ssize_t pccard_show_voltage(struct class_device *dev, char *buf) { - int val; struct pcmcia_socket *s = to_socket(dev); if (!(s->state & SOCKET_PRESENT)) return -ENODEV; - s->ops->get_status(s, &val); - if (val & SS_3VCARD) - return sprintf(buf, "3.3V\n"); - if (val & SS_XVCARD) - return sprintf(buf, "X.XV\n"); - return sprintf(buf, "5.0V\n"); + if (s->socket.Vcc) + return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, + s->socket.Vcc % 10); + return sprintf(buf, "X.XV\n"); } -static CLASS_DEVICE_ATTR(card_voltage, 0400, pccard_show_voltage, NULL); +static CLASS_DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL); static ssize_t pccard_show_vpp(struct class_device *dev, char *buf) { @@ -79,7 +72,7 @@ static ssize_t pccard_show_vpp(struct class_device *dev, char *buf) return -ENODEV; return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10); } -static CLASS_DEVICE_ATTR(card_vpp, 0400, pccard_show_vpp, NULL); +static CLASS_DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL); static ssize_t pccard_show_vcc(struct class_device *dev, char *buf) { @@ -88,7 +81,7 @@ static ssize_t pccard_show_vcc(struct class_device *dev, char *buf) return -ENODEV; return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10); } -static CLASS_DEVICE_ATTR(card_vcc, 0400, pccard_show_vcc, NULL); +static CLASS_DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL); static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, size_t count) -- cgit v1.1 From 6423efaacbf0bce6372897e793d8450c1c08ec8d Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 11 Dec 2005 20:47:44 +0100 Subject: [PATCH] pcmcia: no probing of ioports on PARISC Do not wildly probe the IO ports we're trying to use on PARISC. Signed-off-by: Dominik Brodowski --- drivers/pcmcia/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index df93df6..1f4ad0e 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -225,7 +225,7 @@ config PCMCIA_PXA2XX config PCMCIA_PROBE bool - default y if ISA && !ARCH_SA1100 && !ARCH_CLPS711X + default y if ISA && !ARCH_SA1100 && !ARCH_CLPS711X && !PARISC config M32R_PCC bool "M32R PCMCIA I/F" -- cgit v1.1 From 8084b372adac9c24ff7abdd939b2e8816e7b88a3 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Sun, 11 Dec 2005 21:18:26 +0100 Subject: [PATCH] pcmcia: kzalloc conversion Convert users of kmalloc and memset to kzalloc Signed-off-by: Dominik Brodowski --- drivers/pcmcia/au1000_generic.c | 3 +-- drivers/pcmcia/ds.c | 10 +++------- drivers/pcmcia/pd6729.c | 4 +--- drivers/pcmcia/pxa2xx_mainstone.c | 3 +-- drivers/pcmcia/pxa2xx_sharpsl.c | 3 +-- drivers/pcmcia/rsrc_nonstatic.c | 9 +++------ drivers/pcmcia/soc_common.c | 3 +-- drivers/pcmcia/socket_sysfs.c | 3 +-- drivers/pcmcia/yenta_socket.c | 3 +-- 9 files changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c index 0868b72..971a352 100644 --- a/drivers/pcmcia/au1000_generic.c +++ b/drivers/pcmcia/au1000_generic.c @@ -354,13 +354,12 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops, struct skt_dev_info *sinfo; int ret, i; - sinfo = kmalloc(sizeof(struct skt_dev_info), GFP_KERNEL); + sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL); if (!sinfo) { ret = -ENOMEM; goto out; } - memset(sinfo, 0, sizeof(struct skt_dev_info)); sinfo->nskt = nr; /* diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 0fc61dd..0252582 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -264,12 +264,10 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) if (fw->size >= CISTPL_MAX_CIS_SIZE) goto release; - cis = kmalloc(sizeof(cisdump_t), GFP_KERNEL); + cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL); if (!cis) goto release; - memset(cis, 0, sizeof(cisdump_t)); - cis->Length = fw->size + 1; memcpy(cis->Data, fw->data, fw->size); @@ -387,13 +385,12 @@ static int pcmcia_device_probe(struct device * dev) s->functions = mfc.nfn; else s->functions = 1; - s->config = kmalloc(sizeof(config_t) * s->functions, + s->config = kzalloc(sizeof(config_t) * s->functions, GFP_KERNEL); if (!s->config) { ret = -ENOMEM; goto put_module; } - memset(s->config, 0, sizeof(config_t) * s->functions); } ret = p_drv->probe(p_dev); @@ -572,10 +569,9 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f if (s->device_count == 2) goto err_put; - p_dev = kmalloc(sizeof(struct pcmcia_device), GFP_KERNEL); + p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL); if (!p_dev) goto err_put; - memset(p_dev, 0, sizeof(struct pcmcia_device)); p_dev->socket = s; p_dev->device_no = (s->device_count++); diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c index e7a6d9a..f2789af 100644 --- a/drivers/pcmcia/pd6729.c +++ b/drivers/pcmcia/pd6729.c @@ -634,13 +634,11 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev, char configbyte; struct pd6729_socket *socket; - socket = kmalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, + socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, GFP_KERNEL); if (!socket) return -ENOMEM; - memset(socket, 0, sizeof(struct pd6729_socket) * MAX_SOCKETS); - if ((ret = pci_enable_device(dev))) goto err_out_free_mem; diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c index 5209d8c..5d957df 100644 --- a/drivers/pcmcia/pxa2xx_mainstone.c +++ b/drivers/pcmcia/pxa2xx_mainstone.c @@ -171,10 +171,9 @@ static int __init mst_pcmcia_init(void) { int ret; - mst_pcmcia_device = kmalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL); + mst_pcmcia_device = kzalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL); if (!mst_pcmcia_device) return -ENOMEM; - memset(mst_pcmcia_device, 0, sizeof(*mst_pcmcia_device)); mst_pcmcia_device->name = "pxa2xx-pcmcia"; mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c index 56c5883..b5fdeec 100644 --- a/drivers/pcmcia/pxa2xx_sharpsl.c +++ b/drivers/pcmcia/pxa2xx_sharpsl.c @@ -264,11 +264,10 @@ static int __init sharpsl_pcmcia_init(void) int ret; sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs; - sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL); + sharpsl_pcmcia_device = kzalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL); if (!sharpsl_pcmcia_device) return -ENOMEM; - memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device)); sharpsl_pcmcia_device->name = "pxa2xx-pcmcia"; sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev; diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 6b18092..5301ac6 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -75,10 +75,9 @@ static DECLARE_MUTEX(rsrc_sem); static struct resource * make_resource(unsigned long b, unsigned long n, int flags, char *name) { - struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL); + struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); if (res) { - memset(res, 0, sizeof(*res)); res->name = name; res->start = b; res->end = b + n - 1; @@ -200,12 +199,11 @@ static void do_io_probe(struct pcmcia_socket *s, kio_addr_t base, kio_addr_t num base, base+num-1); /* First, what does a floating port look like? */ - b = kmalloc(256, GFP_KERNEL); + b = kzalloc(256, GFP_KERNEL); if (!b) { printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes"); return; } - memset(b, 0, 256); for (i = base, most = 0; i < base+num; i += 8) { res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe"); if (!res) @@ -850,10 +848,9 @@ static int nonstatic_init(struct pcmcia_socket *s) { struct socket_data *data; - data = kmalloc(sizeof(struct socket_data), GFP_KERNEL); + data = kzalloc(sizeof(struct socket_data), GFP_KERNEL); if (!data) return -ENOMEM; - memset(data, 0, sizeof(struct socket_data)); data->mem_db.next = &data->mem_db; data->io_db.next = &data->io_db; diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c index a563bd9..ea7d9ca 100644 --- a/drivers/pcmcia/soc_common.c +++ b/drivers/pcmcia/soc_common.c @@ -645,13 +645,12 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops down(&soc_pcmcia_sockets_lock); - sinfo = kmalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); + sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); if (!sinfo) { ret = -ENOMEM; goto out; } - memset(sinfo, 0, SKT_DEV_INFO_SIZE(nr)); sinfo->nskt = nr; /* diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index e074bc1..7a77446 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c @@ -285,10 +285,9 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz if (!(s->state & SOCKET_PRESENT)) return -ENODEV; - cis = kmalloc(sizeof(cisdump_t), GFP_KERNEL); + cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL); if (!cis) return -ENOMEM; - memset(cis, 0, sizeof(cisdump_t)); cis->Length = count + 1; memcpy(cis->Data, buf, count); diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 826e7e1..4145eb8 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -1019,10 +1019,9 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i return -ENODEV; } - socket = kmalloc(sizeof(struct yenta_socket), GFP_KERNEL); + socket = kzalloc(sizeof(struct yenta_socket), GFP_KERNEL); if (!socket) return -ENOMEM; - memset(socket, 0, sizeof(*socket)); /* prepare pcmcia_socket */ socket->socket.ops = ¥ta_socket_operations; -- cgit v1.1 From 3cf89b185971bf186cec657911f08354e7701635 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Fri, 23 Dec 2005 23:51:08 +0300 Subject: [PATCH] drivers/pcmcia/cistpl.c: fix endian warnings Signed-off-by: Alexey Dobriyan Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cistpl.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 55d7247..120fa8d 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -463,7 +463,7 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple) /* Get indirect link from the MFC tuple */ read_cis_cache(s, LINK_SPACE(tuple->Flags), tuple->LinkOffset, 5, link); - ofs = le32_to_cpu(*(u_int *)(link+1)); + ofs = le32_to_cpu(*(__le32 *)(link+1)); SPACE(tuple->Flags) = (link[0] == CISTPL_MFC_ATTR); /* Move to the next indirect link */ tuple->LinkOffset += 5; @@ -671,8 +671,8 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum) if (tuple->TupleDataLen < 5) return CS_BAD_TUPLE; p = (u_char *)tuple->TupleData; - csum->addr = tuple->CISOffset+(short)le16_to_cpu(*(u_short *)p)-2; - csum->len = le16_to_cpu(*(u_short *)(p + 2)); + csum->addr = tuple->CISOffset+(short)le16_to_cpu(*(__le16 *)p)-2; + csum->len = le16_to_cpu(*(__le16 *)(p + 2)); csum->sum = *(p+4); return CS_SUCCESS; } @@ -683,7 +683,7 @@ static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) { if (tuple->TupleDataLen < 4) return CS_BAD_TUPLE; - link->addr = le32_to_cpu(*(u_int *)tuple->TupleData); + link->addr = le32_to_cpu(*(__le32 *)tuple->TupleData); return CS_SUCCESS; } @@ -702,7 +702,7 @@ static int parse_longlink_mfc(tuple_t *tuple, return CS_BAD_TUPLE; for (i = 0; i < link->nfn; i++) { link->fn[i].space = *p; p++; - link->fn[i].addr = le32_to_cpu(*(u_int *)p); p += 4; + link->fn[i].addr = le32_to_cpu(*(__le32 *)p); p += 4; } return CS_SUCCESS; } @@ -789,10 +789,10 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec) static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) { - u_short *p; + __le16 *p; if (tuple->TupleDataLen < 4) return CS_BAD_TUPLE; - p = (u_short *)tuple->TupleData; + p = (__le16 *)tuple->TupleData; m->manf = le16_to_cpu(p[0]); m->card = le16_to_cpu(p[1]); return CS_SUCCESS; @@ -1093,7 +1093,7 @@ static int parse_cftable_entry(tuple_t *tuple, break; case 0x20: entry->mem.nwin = 1; - entry->mem.win[0].len = le16_to_cpu(*(u_short *)p) << 8; + entry->mem.win[0].len = le16_to_cpu(*(__le16 *)p) << 8; entry->mem.win[0].card_addr = 0; entry->mem.win[0].host_addr = 0; p += 2; @@ -1101,9 +1101,9 @@ static int parse_cftable_entry(tuple_t *tuple, break; case 0x40: entry->mem.nwin = 1; - entry->mem.win[0].len = le16_to_cpu(*(u_short *)p) << 8; + entry->mem.win[0].len = le16_to_cpu(*(__le16 *)p) << 8; entry->mem.win[0].card_addr = - le16_to_cpu(*(u_short *)(p+2)) << 8; + le16_to_cpu(*(__le16 *)(p+2)) << 8; entry->mem.win[0].host_addr = 0; p += 4; if (p > q) return CS_BAD_TUPLE; @@ -1140,7 +1140,7 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar) p = (u_char *)tuple->TupleData; bar->attr = *p; p += 2; - bar->size = le32_to_cpu(*(u_int *)p); + bar->size = le32_to_cpu(*(__le32 *)p); return CS_SUCCESS; } @@ -1153,7 +1153,7 @@ static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) return CS_BAD_TUPLE; config->last_idx = *(++p); p++; - config->base = le32_to_cpu(*(u_int *)p); + config->base = le32_to_cpu(*(__le32 *)p); config->subtuples = tuple->TupleDataLen - 6; return CS_SUCCESS; } @@ -1269,7 +1269,7 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2) v2->vers = p[0]; v2->comply = p[1]; - v2->dindex = le16_to_cpu(*(u_short *)(p+2)); + v2->dindex = le16_to_cpu(*(__le16 *)(p+2)); v2->vspec8 = p[6]; v2->vspec9 = p[7]; v2->nhdr = p[8]; @@ -1310,8 +1310,8 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt) fmt->type = p[0]; fmt->edc = p[1]; - fmt->offset = le32_to_cpu(*(u_int *)(p+2)); - fmt->length = le32_to_cpu(*(u_int *)(p+6)); + fmt->offset = le32_to_cpu(*(__le32 *)(p+2)); + fmt->length = le32_to_cpu(*(__le32 *)(p+6)); return CS_SUCCESS; } -- cgit v1.1 From 6e493882726e762d0eb7a0a5fcae42a122ae75a5 Mon Sep 17 00:00:00 2001 From: Daniel Ritz Date: Fri, 30 Dec 2005 15:12:35 +0100 Subject: [PATCH] pcmcia: cleanup cs.c, reduce size kill the socket_shutdown()/shutdown_socket() confusion by making it one single function. move cs_socket_put() in there. nicer to read and smaller: original: text data bss dec hex filename 25181 1076 32 26289 66b1 drivers/pcmcia/pcmcia_core.ko patched: text data bss dec hex filename 24973 1076 32 26081 65e1 drivers/pcmcia/pcmcia_core.ko Signed-off-by: Daniel Ritz Signed-off-by: Dominik Brodowski --- drivers/pcmcia/cs.c | 88 ++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 49 deletions(-) diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 83d2753..613f2f1 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -309,41 +309,6 @@ struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr) } EXPORT_SYMBOL(pcmcia_get_socket_by_nr); - -/** - * socket_setup() and shutdown_socket() are called by the main event - * handler when card insertion and removal events are received. - * socket_setup() turns on socket power and resets the socket, in two stages. - * shutdown_socket() unconfigures a socket and turns off socket power. - */ -static void shutdown_socket(struct pcmcia_socket *s) -{ - cs_dbg(s, 1, "shutdown_socket\n"); - - /* Blank out the socket state */ - s->socket = dead_socket; - s->ops->init(s); - s->ops->set_socket(s, &s->socket); - s->irq.AssignedIRQ = s->irq.Config = 0; - s->lock_count = 0; - destroy_cis_cache(s); -#ifdef CONFIG_CARDBUS - cb_free(s); -#endif - s->functions = 0; - kfree(s->config); - s->config = NULL; - - { - int status; - s->ops->get_status(s, &status); - if (status & SS_POWERON) { - printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); - } - } -} /* shutdown_socket */ - - /** * The central event handler. Send_event() sends an event to the * 16-bit subsystem, which then calls the relevant device drivers. @@ -383,17 +348,6 @@ static void socket_remove_drivers(struct pcmcia_socket *skt) send_event(skt, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH); } -static void socket_shutdown(struct pcmcia_socket *skt) -{ - cs_dbg(skt, 4, "shutdown\n"); - - socket_remove_drivers(skt); - skt->state &= SOCKET_INUSE|SOCKET_PRESENT; - msleep(shutdown_delay * 10); - skt->state &= SOCKET_INUSE; - shutdown_socket(skt); -} - static int socket_reset(struct pcmcia_socket *skt) { int status, i; @@ -424,6 +378,45 @@ static int socket_reset(struct pcmcia_socket *skt) return CS_GENERAL_FAILURE; } +/** + * socket_setup() and socket_shutdown() are called by the main event handler + * when card insertion and removal events are received. + * socket_setup() turns on socket power and resets the socket, in two stages. + * socket_shutdown() unconfigures a socket and turns off socket power. + */ +static void socket_shutdown(struct pcmcia_socket *s) +{ + int status; + + cs_dbg(s, 4, "shutdown\n"); + + socket_remove_drivers(s); + s->state &= SOCKET_INUSE | SOCKET_PRESENT; + msleep(shutdown_delay * 10); + s->state &= SOCKET_INUSE; + + /* Blank out the socket state */ + s->socket = dead_socket; + s->ops->init(s); + s->ops->set_socket(s, &s->socket); + s->irq.AssignedIRQ = s->irq.Config = 0; + s->lock_count = 0; + destroy_cis_cache(s); +#ifdef CONFIG_CARDBUS + cb_free(s); +#endif + s->functions = 0; + kfree(s->config); + s->config = NULL; + + s->ops->get_status(s, &status); + if (status & SS_POWERON) { + printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); + } + + cs_socket_put(s); +} + static int socket_setup(struct pcmcia_socket *skt, int initial_delay) { int status, i; @@ -529,7 +522,6 @@ static int socket_insert(struct pcmcia_socket *skt) send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW); } else { socket_shutdown(skt); - cs_socket_put(skt); } return ret; @@ -593,7 +585,6 @@ static int socket_resume(struct pcmcia_socket *skt) } } else { socket_shutdown(skt); - cs_socket_put(skt); } skt->state &= ~SOCKET_SUSPEND; @@ -605,7 +596,6 @@ static void socket_remove(struct pcmcia_socket *skt) { printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock); socket_shutdown(skt); - cs_socket_put(skt); } /* -- cgit v1.1 From 725a6abfe37025975c125ace1c7da35f27ce5384 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 5 Jan 2006 09:56:03 +0000 Subject: [PATCH] pcmcia: add some IDs for ide-cs and dtl1_cs Add some PCMCIA device IDs for the microdrive found in the Sharp Zaurus and a different revision of the Socket CF+ Bluetooth card. Signed-off-by: Richard Purdie Signed-off-by: Dominik Brodowski --- drivers/bluetooth/dtl1_cs.c | 1 + drivers/ide/legacy/ide-cs.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 787c5eb..0449bc4 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -755,6 +755,7 @@ static int dtl1_resume(struct pcmcia_device *dev) static struct pcmcia_device_id dtl1_ids[] = { PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863), + PCMCIA_DEVICE_PROD_ID12("Socket", "CF+ Personal Network Card", 0xb38bcc2e, 0xe732bae3), PCMCIA_DEVICE_NULL }; MODULE_DEVICE_TABLE(pcmcia, dtl1_ids); diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index e36e6fb..4c2af90 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -412,11 +412,13 @@ static int ide_resume(struct pcmcia_device *dev) static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_FUNC_ID(4), + PCMCIA_DEVICE_MANF_CARD(0x0007, 0x0000), /* Hitachi */ PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ + PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */ PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar */ PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), @@ -431,6 +433,8 @@ static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591), PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728), PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), + PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), + PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), -- cgit v1.1 From e924283bf93989979f27ef4f1228c5925f584a0a Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 5 Jan 2006 14:57:36 -0800 Subject: [IPVS]: Another file needs linux/interrupt.h Signed-off-by: Andrew Morton Signed-off-by: David S. Miller --- net/ipv4/ipvs/ip_vs_conn.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c index 81d90354..87b8381 100644 --- a/net/ipv4/ipvs/ip_vs_conn.c +++ b/net/ipv4/ipvs/ip_vs_conn.c @@ -24,6 +24,7 @@ * */ +#include #include #include #include -- cgit v1.1 From 46f25dffbaba48c571d75f5f574f31978287b8d2 Mon Sep 17 00:00:00 2001 From: Kris Katterjohn Date: Thu, 5 Jan 2006 16:35:42 -0800 Subject: [NET]: Change 1500 to ETH_DATA_LEN in some files These patches add the header linux/if_ether.h and change 1500 to ETH_DATA_LEN in some files. Signed-off-by: Kris Katterjohn Signed-off-by: David S. Miller --- net/bridge/br_if.c | 5 +++-- net/ethernet/eth.c | 5 +++-- net/ipv4/ip_gre.c | 5 +++-- net/ipv4/ipip.c | 3 ++- net/ipv4/ipmr.c | 3 ++- net/ipv6/sit.c | 3 ++- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 1132119..ba44288 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "br_private.h" @@ -323,7 +324,7 @@ int br_del_bridge(const char *name) return ret; } -/* Mtu of the bridge pseudo-device 1500 or the minimum of the ports */ +/* MTU of the bridge pseudo-device: ETH_DATA_LEN or the minimum of the ports */ int br_min_mtu(const struct net_bridge *br) { const struct net_bridge_port *p; @@ -332,7 +333,7 @@ int br_min_mtu(const struct net_bridge *br) ASSERT_RTNL(); if (list_empty(&br->port_list)) - mtu = 1500; + mtu = ETH_DATA_LEN; else { list_for_each_entry(p, &br->port_list, list) { if (!mtu || p->dev->mtu < mtu) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index e245773..9f4dbeb 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -251,7 +252,7 @@ static int eth_mac_addr(struct net_device *dev, void *p) static int eth_change_mtu(struct net_device *dev, int new_mtu) { - if ((new_mtu < 68) || (new_mtu > 1500)) + if (new_mtu < 68 || new_mtu > ETH_DATA_LEN) return -EINVAL; dev->mtu = new_mtu; return 0; @@ -272,7 +273,7 @@ void ether_setup(struct net_device *dev) dev->type = ARPHRD_ETHER; dev->hard_header_len = ETH_HLEN; - dev->mtu = 1500; /* eth_mtu */ + dev->mtu = ETH_DATA_LEN; dev->addr_len = ETH_ALEN; dev->tx_queue_len = 1000; /* Ethernet wants good queues */ dev->flags = IFF_BROADCAST|IFF_MULTICAST; diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 46f9d9c..912c42f 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1140,7 +1141,7 @@ static void ipgre_tunnel_setup(struct net_device *dev) dev->type = ARPHRD_IPGRE; dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr) + 4; - dev->mtu = 1500 - sizeof(struct iphdr) - 4; + dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 4; dev->flags = IFF_NOARP; dev->iflink = 0; dev->addr_len = 4; @@ -1152,7 +1153,7 @@ static int ipgre_tunnel_init(struct net_device *dev) struct ip_tunnel *tunnel; struct iphdr *iph; int hlen = LL_MAX_HEADER; - int mtu = 1500; + int mtu = ETH_DATA_LEN; int addend = sizeof(struct iphdr) + 4; tunnel = (struct ip_tunnel*)dev->priv; diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index c05c1df..35571cf 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c @@ -108,6 +108,7 @@ #include #include #include +#include #include #include @@ -786,7 +787,7 @@ static void ipip_tunnel_setup(struct net_device *dev) dev->type = ARPHRD_TUNNEL; dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr); - dev->mtu = 1500 - sizeof(struct iphdr); + dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr); dev->flags = IFF_NOARP; dev->iflink = 0; dev->addr_len = 4; diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index caa3b7d..9a5c0ce 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -193,7 +194,7 @@ static struct net_device_stats *reg_vif_get_stats(struct net_device *dev) static void reg_vif_setup(struct net_device *dev) { dev->type = ARPHRD_PIMREG; - dev->mtu = 1500 - sizeof(struct iphdr) - 8; + dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr) - 8; dev->flags = IFF_NOARP; dev->hard_start_xmit = reg_vif_xmit; dev->get_stats = reg_vif_get_stats; diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index c3123c9..577d497 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -720,7 +721,7 @@ static void ipip6_tunnel_setup(struct net_device *dev) dev->type = ARPHRD_SIT; dev->hard_header_len = LL_MAX_HEADER + sizeof(struct iphdr); - dev->mtu = 1500 - sizeof(struct iphdr); + dev->mtu = ETH_DATA_LEN - sizeof(struct iphdr); dev->flags = IFF_NOARP; dev->iflink = 0; dev->addr_len = 4; -- cgit v1.1 From 6c59f9d9fb95934bf3d7d64249b338ce79953b5b Mon Sep 17 00:00:00 2001 From: Jody McIntyre Date: Thu, 5 Jan 2006 23:04:08 -0500 Subject: Update MAINTAINERS - Jody is no longer at Steamballoon. --- MAINTAINERS | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 6246b7f..5daae53 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1230,7 +1230,7 @@ IEEE 1394 SUBSYSTEM P: Ben Collins M: bcollins@debian.org P: Jody McIntyre -M: scjody@steamballoon.com +M: scjody@modernduck.com L: linux1394-devel@lists.sourceforge.net W: http://www.linux1394.org/ T: git kernel.org:/pub/scm/linux/kernel/git/scjody/ieee1394.git @@ -1240,14 +1240,14 @@ IEEE 1394 OHCI DRIVER P: Ben Collins M: bcollins@debian.org P: Jody McIntyre -M: scjody@steamballoon.com +M: scjody@modernduck.com L: linux1394-devel@lists.sourceforge.net W: http://www.linux1394.org/ S: Maintained IEEE 1394 PCILYNX DRIVER P: Jody McIntyre -M: scjody@steamballoon.com +M: scjody@modernduck.com L: linux1394-devel@lists.sourceforge.net W: http://www.linux1394.org/ S: Maintained -- cgit v1.1 From 9f155b9802bb7049cd0f216c3fe903b58620df11 Mon Sep 17 00:00:00 2001 From: Chuck Ebbert <76306.1226@compuserve.com> Date: Thu, 5 Jan 2006 23:11:29 -0500 Subject: [PATCH] i386: PTRACE_POKEUSR: allow changing RF bit in EFLAGS register. Setting RF (resume flag) allows a debugger to resume execution after a code breakpoint without tripping the breakpoint again. It is reset by the CPU after execution of one instruction. Requested by Stephane Eranian: "I am trying to the user HW debug registers on i386 and I am running into a problem with ptrace() not allowing access to EFLAGS_RF for POKEUSER (see FLAG_MASK). [ ... ] It avoids the need to remove the breakpoint, single step, and reinstall. The equivalent functionality exists on IA-64 and is allowed by ptrace()" Cc: Stephane Eranian Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com> Signed-off-by: Linus Torvalds --- arch/i386/kernel/ptrace.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c index 5ffbb4b..5c1fb6a 100644 --- a/arch/i386/kernel/ptrace.c +++ b/arch/i386/kernel/ptrace.c @@ -32,9 +32,12 @@ * in exit.c or in signal.c. */ -/* determines which flags the user has access to. */ -/* 1 = access 0 = no access */ -#define FLAG_MASK 0x00044dd5 +/* + * Determines which flags the user has access to [1 = access, 0 = no access]. + * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9). + * Also masks reserved bits (31-22, 15, 5, 3, 1). + */ +#define FLAG_MASK 0x00054dd5 /* set's the trap flag. */ #define TRAP_FLAG 0x100 -- cgit v1.1 From 2e3e13f8e9d9b2111404cdccaa4e1b988b70acce Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Sun, 6 Nov 2005 23:04:51 +0100 Subject: [PATCH] i2c: i2c-i801 explicitly enables/disables PEC This patch tweaks i2c-i801.c so that the driver always sets the SMBAUXCTL register (which enables/disables PEC) explicitly before each transaction. Signed-off-by: Mark M. Hoffman Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-i801.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index ac3eafa..1c752dd 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -468,8 +468,7 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, return -1; } - if (hwpec) - outb_p(1, SMBAUXCTL); /* enable hardware PEC */ + outb_p(hwpec, SMBAUXCTL); /* enable/disable hardware PEC */ if(block) ret = i801_block_transaction(data, read_write, size, hwpec); @@ -478,9 +477,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, ret = i801_transaction(); } - if (hwpec) - outb_p(0, SMBAUXCTL); /* disable hardware PEC */ - if(block) return ret; if(ret) -- cgit v1.1 From f9e8957937ebf60d22732a5ca9130f48a7603f60 Mon Sep 17 00:00:00 2001 From: Michael Burian Date: Mon, 7 Nov 2005 22:30:14 +0100 Subject: [PATCH] i2c: Extend ds1337 initialization Add code to handle case where board firmware does not start the RTC. Signed-off-by: Jean Delvare CC: James Chapman Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/ds1337.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 02682fb..1822895 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -337,13 +337,38 @@ exit: static void ds1337_init_client(struct i2c_client *client) { - s32 val; + u8 status, control; - /* Ensure that device is set in 24-hour mode */ - val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR); - if ((val >= 0) && (val & (1 << 6))) - i2c_smbus_write_byte_data(client, DS1337_REG_HOUR, - val & 0x3f); + /* On some boards, the RTC isn't configured by boot firmware. + * Handle that case by starting/configuring the RTC now. + */ + status = i2c_smbus_read_byte_data(client, DS1337_REG_STATUS); + control = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL); + + if ((status & 0x80) || (control & 0x80)) { + /* RTC not running */ + u8 buf[16]; + struct i2c_msg msg[1]; + + dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__); + + /* Initialize all, including STATUS and CONTROL to zero */ + memset(buf, 0, sizeof(buf)); + msg[0].addr = client->addr; + msg[0].flags = 0; + msg[0].len = sizeof(buf); + msg[0].buf = &buf[0]; + + i2c_transfer(client->adapter, msg, 1); + } else { + /* Running: ensure that device is set in 24-hour mode */ + s32 val; + + val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR); + if ((val >= 0) && (val & (1 << 6))) + i2c_smbus_write_byte_data(client, DS1337_REG_HOUR, + val & 0x3f); + } } static int ds1337_detach_client(struct i2c_client *client) -- cgit v1.1 From 07421cabdc62519d0f747149b7c9b425b4d746cd Mon Sep 17 00:00:00 2001 From: Grant Coady Date: Sun, 6 Nov 2005 23:13:06 +0100 Subject: [PATCH] hwmon: remove deprecated sysfs names of adm1025 and adm1026 drivers, hwmon, adm1025 and adm1026: remove deprecated sysfs names. these names have been listed for removal for six months, time for them to go Signed-off-by: Grant Coady Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/feature-removal-schedule.txt | 9 --------- drivers/hwmon/adm1025.c | 4 ---- drivers/hwmon/adm1026.c | 4 ---- 3 files changed, 17 deletions(-) diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 9b74319..cb13b96 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt @@ -82,15 +82,6 @@ Who: Mauro Carvalho Chehab --------------------------- -What: i2c sysfs name change: in1_ref, vid deprecated in favour of cpu0_vid -When: November 2005 -Files: drivers/i2c/chips/adm1025.c, drivers/i2c/chips/adm1026.c -Why: Match the other drivers' name for the same function, duplicate names - will be available until removal of old names. -Who: Grant Coady - ---------------------------- - What: remove EXPORT_SYMBOL(panic_timeout) When: April 2006 Files: kernel/panic.c diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 3ec1242..bf67860 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -287,8 +287,6 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char struct adm1025_data *data = adm1025_update_device(dev); return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); } -/* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */ -static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL); static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) @@ -444,8 +442,6 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind) device_create_file(&new_client->dev, &dev_attr_temp1_max); device_create_file(&new_client->dev, &dev_attr_temp2_max); device_create_file(&new_client->dev, &dev_attr_alarms); - /* in1_ref is deprecated, remove after 2005-11-11 */ - device_create_file(&new_client->dev, &dev_attr_in1_ref); device_create_file(&new_client->dev, &dev_attr_cpu0_vid); device_create_file(&new_client->dev, &dev_attr_vrm); diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index e0f5654..5036b17 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -1227,8 +1227,6 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c struct adm1026_data *data = adm1026_update_device(dev); return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); } -/* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ -static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL); static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) @@ -1673,8 +1671,6 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address, device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); - /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */ - device_create_file(&new_client->dev, &dev_attr_vid); device_create_file(&new_client->dev, &dev_attr_cpu0_vid); device_create_file(&new_client->dev, &dev_attr_vrm); device_create_file(&new_client->dev, &dev_attr_alarms); -- cgit v1.1 From 9c516ef496c857aa4b1b41dc313010f11d39c496 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 20:07:54 +0100 Subject: [PATCH] hwmon: Support the VRM 10 mode of the ADT7463 Support the VRM 10 mode of the ADT7463. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/lm85.c | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index d1070ed..3f5544a 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -443,7 +443,17 @@ show_fan_offset(4); static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) { struct lm85_data *data = lm85_update_device(dev); - return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); + int vid; + + if (data->type == adt7463 && (data->vid & 0x80)) { + /* 6-pin VID (VRM 10) */ + vid = vid_from_reg(data->vid & 0x3f, data->vrm); + } else { + /* 5-pin VID (VRM 9) */ + vid = vid_from_reg(data->vid & 0x1f, data->vrm); + } + + return sprintf(buf, "%d\n", vid); } static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); @@ -1176,17 +1186,14 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in2_input); device_create_file(&new_client->dev, &dev_attr_in3_input); - device_create_file(&new_client->dev, &dev_attr_in4_input); device_create_file(&new_client->dev, &dev_attr_in0_min); device_create_file(&new_client->dev, &dev_attr_in1_min); device_create_file(&new_client->dev, &dev_attr_in2_min); device_create_file(&new_client->dev, &dev_attr_in3_min); - device_create_file(&new_client->dev, &dev_attr_in4_min); device_create_file(&new_client->dev, &dev_attr_in0_max); device_create_file(&new_client->dev, &dev_attr_in1_max); device_create_file(&new_client->dev, &dev_attr_in2_max); device_create_file(&new_client->dev, &dev_attr_in3_max); - device_create_file(&new_client->dev, &dev_attr_in4_max); device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp2_input); device_create_file(&new_client->dev, &dev_attr_temp3_input); @@ -1224,6 +1231,15 @@ static int lm85_detect(struct i2c_adapter *adapter, int address, device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_crit); device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_crit); + /* The ADT7463 has an optional VRM 10 mode where pin 21 is used + as a sixth digital VID input rather than an analog input. */ + data->vid = lm85_read_value(new_client, LM85_REG_VID); + if (!(kind == adt7463 && (data->vid & 0x80))) { + device_create_file(&new_client->dev, &dev_attr_in4_input); + device_create_file(&new_client->dev, &dev_attr_in4_min); + device_create_file(&new_client->dev, &dev_attr_in4_max); + } + return 0; /* Error out and cleanup code */ @@ -1382,11 +1398,18 @@ static struct lm85_data *lm85_update_device(struct device *dev) irrelevant. So it is left in 4*/ data->adc_scale = (data->type == emc6d102 ) ? 16 : 4; - for (i = 0; i <= 4; ++i) { + data->vid = lm85_read_value(client, LM85_REG_VID); + + for (i = 0; i <= 3; ++i) { data->in[i] = lm85_read_value(client, LM85_REG_IN(i)); } + if (!(data->type == adt7463 && (data->vid & 0x80))) { + data->in[4] = lm85_read_value(client, + LM85_REG_IN(4)); + } + for (i = 0; i <= 3; ++i) { data->fan[i] = lm85_read_value(client, LM85_REG_FAN(i)); @@ -1450,13 +1473,20 @@ static struct lm85_data *lm85_update_device(struct device *dev) /* Things that don't change often */ dev_dbg(&client->dev, "Reading config values\n"); - for (i = 0; i <= 4; ++i) { + for (i = 0; i <= 3; ++i) { data->in_min[i] = lm85_read_value(client, LM85_REG_IN_MIN(i)); data->in_max[i] = lm85_read_value(client, LM85_REG_IN_MAX(i)); } + if (!(data->type == adt7463 && (data->vid & 0x80))) { + data->in_min[4] = lm85_read_value(client, + LM85_REG_IN_MIN(4)); + data->in_max[4] = lm85_read_value(client, + LM85_REG_IN_MAX(4)); + } + if ( data->type == emc6d100 ) { for (i = 5; i <= 7; ++i) { data->in_min[i] = @@ -1478,8 +1508,6 @@ static struct lm85_data *lm85_update_device(struct device *dev) lm85_read_value(client, LM85_REG_TEMP_MAX(i)); } - data->vid = lm85_read_value(client, LM85_REG_VID); - for (i = 0; i <= 2; ++i) { int val ; data->autofan[i].config = -- cgit v1.1 From dd149c52223cfb05cdefb0755d3c2793e8d33ede Mon Sep 17 00:00:00 2001 From: Yuan Mu Date: Sat, 26 Nov 2005 20:13:18 +0100 Subject: [PATCH] hwmon: W83627THF VID fixes This patch fixes the VID reading; no cpu0_vid and vrm files created if the chip is w83627thf and GPIO5 not enabled. Signed-off-by: Yuan Mu Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/w83627hf.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index bbb3dcd..27cfde1 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -1122,11 +1122,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter) if (kind != w83697hf) device_create_file_temp(new_client, 3); - if (kind != w83697hf) + if (kind != w83697hf && data->vid != 0xff) { device_create_file_vid(new_client); - - if (kind != w83697hf) device_create_file_vrm(new_client); + } device_create_file_fan_div(new_client, 1); device_create_file_fan_div(new_client, 2); @@ -1232,7 +1231,7 @@ static int w83627thf_read_gpio5(struct i2c_client *client) /* Make sure the pins are configured for input There must be at least five (VRM 9), and possibly 6 (VRM 10) */ - sel = superio_inb(W83627THF_GPIO5_IOSR); + sel = superio_inb(W83627THF_GPIO5_IOSR) & 0x3f; if ((sel & 0x1f) != 0x1f) { dev_dbg(&client->dev, "GPIO5 not configured for VID " "function\n"); @@ -1323,19 +1322,18 @@ static void w83627hf_init_client(struct i2c_client *client) int hi = w83627hf_read_value(client, W83781D_REG_CHIPID); data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); } else if (w83627thf == data->type) { - data->vid = w83627thf_read_gpio5(client) & 0x3f; + data->vid = w83627thf_read_gpio5(client); } /* Read VRM & OVT Config only once */ if (w83627thf == data->type || w83637hf == data->type) { data->vrm_ovt = w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); - data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82; - } else { - /* Convert VID to voltage based on default VRM */ - data->vrm = vid_which_vrm(); } + /* Convert VID to voltage based on VRM */ + data->vrm = vid_which_vrm(); + tmp = w83627hf_read_value(client, W83781D_REG_SCFG1); for (i = 1; i <= 3; i++) { if (!(tmp & BIT_SCFG1[i - 1])) { -- cgit v1.1 From 5b319400f5e2cd31a82b38405856ff2b46a9bb83 Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Sat, 26 Nov 2005 20:10:56 +0100 Subject: [PATCH] hwmon: Clarify the W83627THF VID documentation This patch clarifies the W83627THF VID documentation. Signed-off-by: Mark M. Hoffman Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/hwmon/w83627hf | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Documentation/hwmon/w83627hf b/Documentation/hwmon/w83627hf index 78f37c2..5d23776 100644 --- a/Documentation/hwmon/w83627hf +++ b/Documentation/hwmon/w83627hf @@ -54,13 +54,16 @@ If you really want i2c accesses for these Super I/O chips, use the w83781d driver. However this is not the preferred method now that this ISA driver has been developed. -Technically, the w83627thf does not support a VID reading. However, it's -possible or even likely that your mainboard maker has routed these signals -to a specific set of general purpose IO pins (the Asus P4C800-E is one such -board). The w83627thf driver now interprets these as VID. If the VID on -your board doesn't work, first see doc/vid in the lm_sensors package. If -that still doesn't help, email us at lm-sensors@lm-sensors.org. +The w83627_HF_ uses pins 110-106 as VID0-VID4. The w83627_THF_ uses the +same pins as GPIO[0:4]. Technically, the w83627_THF_ does not support a +VID reading. However the two chips have the identical 128 pin package. So, +it is possible or even likely for a w83627thf to have the VID signals routed +to these pins despite their not being labeled for that purpose. Therefore, +the w83627thf driver interprets these as VID. If the VID on your board +doesn't work, first see doc/vid in the lm_sensors package[1]. If that still +doesn't help, you may just ignore the bogus VID reading with no harm done. -For further information on this driver see the w83781d driver -documentation. +For further information on this driver see the w83781d driver documentation. + +[1] http://www2.lm-sensors.nu/~lm78/cvs/browse.cgi/lm_sensors2/doc/vid -- cgit v1.1 From 7e94436942a7517d08c0cd1a8831122a0fea289e Mon Sep 17 00:00:00 2001 From: Nicolas Kaiser Date: Sat, 26 Nov 2005 20:15:23 +0100 Subject: [PATCH] i2c: Remove duplicate rtc8564 BCD macros Remove duplicate of BCD macros. Signed-off-by: Nicolas Kaiser Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/rtc8564.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 916cdc1..26e498d 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c @@ -14,6 +14,7 @@ */ #include #include +#include #include #include #include @@ -52,9 +53,6 @@ static inline u8 _rtc8564_ctrl2(struct i2c_client *client) #define CTRL1(c) _rtc8564_ctrl1(c) #define CTRL2(c) _rtc8564_ctrl2(c) -#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10) -#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10) - static int debug;; module_param(debug, int, S_IRUGO | S_IWUSR); @@ -224,16 +222,16 @@ static int rtc8564_get_datetime(struct i2c_client *client, struct rtc_tm *dt) return ret; /* century stored in minute alarm reg */ - dt->year = BCD_TO_BIN(buf[RTC8564_REG_YEAR]); - dt->year += 100 * BCD_TO_BIN(buf[RTC8564_REG_AL_MIN] & 0x3f); - dt->mday = BCD_TO_BIN(buf[RTC8564_REG_DAY] & 0x3f); - dt->wday = BCD_TO_BIN(buf[RTC8564_REG_WDAY] & 7); - dt->mon = BCD_TO_BIN(buf[RTC8564_REG_MON_CENT] & 0x1f); + dt->year = BCD2BIN(buf[RTC8564_REG_YEAR]); + dt->year += 100 * BCD2BIN(buf[RTC8564_REG_AL_MIN] & 0x3f); + dt->mday = BCD2BIN(buf[RTC8564_REG_DAY] & 0x3f); + dt->wday = BCD2BIN(buf[RTC8564_REG_WDAY] & 7); + dt->mon = BCD2BIN(buf[RTC8564_REG_MON_CENT] & 0x1f); - dt->secs = BCD_TO_BIN(buf[RTC8564_REG_SEC] & 0x7f); + dt->secs = BCD2BIN(buf[RTC8564_REG_SEC] & 0x7f); dt->vl = (buf[RTC8564_REG_SEC] & 0x80) == 0x80; - dt->mins = BCD_TO_BIN(buf[RTC8564_REG_MIN] & 0x7f); - dt->hours = BCD_TO_BIN(buf[RTC8564_REG_HR] & 0x3f); + dt->mins = BCD2BIN(buf[RTC8564_REG_MIN] & 0x7f); + dt->hours = BCD2BIN(buf[RTC8564_REG_HR] & 0x3f); _DBGRTCTM(2, *dt); @@ -255,18 +253,18 @@ rtc8564_set_datetime(struct i2c_client *client, struct rtc_tm *dt, int datetoo) buf[RTC8564_REG_CTRL1] = CTRL1(client) | RTC8564_CTRL1_STOP; buf[RTC8564_REG_CTRL2] = CTRL2(client); - buf[RTC8564_REG_SEC] = BIN_TO_BCD(dt->secs); - buf[RTC8564_REG_MIN] = BIN_TO_BCD(dt->mins); - buf[RTC8564_REG_HR] = BIN_TO_BCD(dt->hours); + buf[RTC8564_REG_SEC] = BIN2BCD(dt->secs); + buf[RTC8564_REG_MIN] = BIN2BCD(dt->mins); + buf[RTC8564_REG_HR] = BIN2BCD(dt->hours); if (datetoo) { len += 5; - buf[RTC8564_REG_DAY] = BIN_TO_BCD(dt->mday); - buf[RTC8564_REG_WDAY] = BIN_TO_BCD(dt->wday); - buf[RTC8564_REG_MON_CENT] = BIN_TO_BCD(dt->mon) & 0x1f; + buf[RTC8564_REG_DAY] = BIN2BCD(dt->mday); + buf[RTC8564_REG_WDAY] = BIN2BCD(dt->wday); + buf[RTC8564_REG_MON_CENT] = BIN2BCD(dt->mon) & 0x1f; /* century stored in minute alarm reg */ - buf[RTC8564_REG_YEAR] = BIN_TO_BCD(dt->year % 100); - buf[RTC8564_REG_AL_MIN] = BIN_TO_BCD(dt->year / 100); + buf[RTC8564_REG_YEAR] = BIN2BCD(dt->year % 100); + buf[RTC8564_REG_AL_MIN] = BIN2BCD(dt->year / 100); } ret = rtc8564_write(client, 0, buf, len); -- cgit v1.1 From 1d26f455eb0db0bf4d4b7177547f4310b645a32a Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Sat, 26 Nov 2005 20:18:43 +0100 Subject: [PATCH] i2c: Add support for Barco LPT->DVI to i2c-parport The following patch adds support for the Barco LPT->DVI I2C adapter to the i2c-parport driver. Signed-off-by: Peter Korsgaard Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/busses/i2c-parport | 1 + drivers/i2c/busses/i2c-parport.h | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/i2c/busses/i2c-parport b/Documentation/i2c/busses/i2c-parport index 9f1d008..d9f23c0 100644 --- a/Documentation/i2c/busses/i2c-parport +++ b/Documentation/i2c/busses/i2c-parport @@ -17,6 +17,7 @@ It currently supports the following devices: * Velleman K8000 adapter * ELV adapter * Analog Devices evaluation boards (ADM1025, ADM1030, ADM1031, ADM1032) + * Barco LPT->DVI (K5800236) adapter These devices use different pinout configurations, so you have to tell the driver what you have, using the type module parameter. There is no diff --git a/drivers/i2c/busses/i2c-parport.h b/drivers/i2c/busses/i2c-parport.h index f63a537..d702e5e 100644 --- a/drivers/i2c/busses/i2c-parport.h +++ b/drivers/i2c/busses/i2c-parport.h @@ -80,6 +80,14 @@ static struct adapter_parm adapter_parm[] = { .setscl = { 0x01, DATA, 1 }, .getsda = { 0x10, STAT, 1 }, }, + /* type 6: Barco LPT->DVI (K5800236) adapter */ + { + .setsda = { 0x02, DATA, 1 }, + .setscl = { 0x01, DATA, 1 }, + .getsda = { 0x20, STAT, 0 }, + .getscl = { 0x40, STAT, 0 }, + .init = { 0xfc, DATA, 0 }, + }, }; static int type; @@ -91,4 +99,6 @@ MODULE_PARM_DESC(type, " 2 = Velleman K8000 adapter\n" " 3 = ELV adapter\n" " 4 = ADM1032 evaluation board\n" - " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n"); + " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n" + " 6 = Barco LPT->DVI (K5800236) adapter\n" +); -- cgit v1.1 From 1de9e371b89e1cf4da123f0d92efa8eb134ca5e8 Mon Sep 17 00:00:00 2001 From: Roger Lucas Date: Sat, 26 Nov 2005 20:20:05 +0100 Subject: [PATCH] hwmon: New vt8231 driver Port the vt8231 hardware monitoring driver from lm_sensors CVS to Linux 2.6. Signed-off-by: Roger Lucas Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 6 + drivers/hwmon/Kconfig | 12 + drivers/hwmon/Makefile | 1 + drivers/hwmon/vt8231.c | 861 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 880 insertions(+) create mode 100644 drivers/hwmon/vt8231.c diff --git a/MAINTAINERS b/MAINTAINERS index 6246b7f..16f3782 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2902,6 +2902,12 @@ W: http://linuxtv.org T: git kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb.git S: Maintained +VT8231 HARDWARE MONITOR DRIVER +P: Roger Lucas +M: roger@planbit.co.uk +L: lm-sensors@lm-sensors.org +S: Maintained + W1 DALLAS'S 1-WIRE BUS P: Evgeniy Polyakov M: johnpol@2ka.mipt.ru diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index db358cf..c582959 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -350,6 +350,18 @@ config SENSORS_VIA686A This driver can also be built as a module. If so, the module will be called via686a. +config SENSORS_VT8231 + tristate "VT8231" + depends on HWMON && I2C && PCI && EXPERIMENTAL + select HWMON_VID + select I2C_ISA + help + If you say yes here then you get support for the integrated sensors + in the VIA VT8231 device. + + This driver can also be built as a module. If so, the module + will be called vt8231. + config SENSORS_W83781D tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" depends on HWMON && I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index f7d6a2f..06d4a1d 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -40,6 +40,7 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o +obj-$(CONFIG_SENSORS_VT8231) += vt8231.o obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c new file mode 100644 index 0000000..c8556a72 --- /dev/null +++ b/drivers/hwmon/vt8231.c @@ -0,0 +1,861 @@ +/* + vt8231.c - Part of lm_sensors, Linux kernel modules + for hardware monitoring + + Copyright (c) 2005 Roger Lucas + Copyright (c) 2002 Mark D. Studebaker + Aaron M. Marsh + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* Supports VIA VT8231 South Bridge embedded sensors +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int force_addr; +module_param(force_addr, int, 0); +MODULE_PARM_DESC(force_addr, "Initialize the base address of the sensors"); + +/* Device address + Note that we can't determine the ISA address until we have initialized + our module */ +static unsigned short isa_address; + +#define VT8231_EXTENT 0x80 +#define VT8231_BASE_REG 0x70 +#define VT8231_ENABLE_REG 0x74 + +/* The VT8231 registers + + The reset value for the input channel configuration is used (Reg 0x4A=0x07) + which sets the selected inputs marked with '*' below if multiple options are + possible: + + Voltage Mode Temperature Mode + Sensor Linux Id Linux Id VIA Id + -------- -------- -------- ------ + CPU Diode N/A temp1 0 + UIC1 in0 temp2 * 1 + UIC2 in1 * temp3 2 + UIC3 in2 * temp4 3 + UIC4 in3 * temp5 4 + UIC5 in4 * temp6 5 + 3.3V in5 N/A + + Note that the BIOS may set the configuration register to a different value + to match the motherboard configuration. +*/ + +/* fans numbered 0-1 */ +#define VT8231_REG_FAN_MIN(nr) (0x3b + (nr)) +#define VT8231_REG_FAN(nr) (0x29 + (nr)) + +/* Voltage inputs numbered 0-5 */ + +static const u8 regvolt[] = { 0x21, 0x22, 0x23, 0x24, 0x25, 0x26 }; +static const u8 regvoltmax[] = { 0x3d, 0x2b, 0x2d, 0x2f, 0x31, 0x33 }; +static const u8 regvoltmin[] = { 0x3e, 0x2c, 0x2e, 0x30, 0x32, 0x34 }; + +/* Temperatures are numbered 1-6 according to the Linux kernel specification. +** +** In the VIA datasheet, however, the temperatures are numbered from zero. +** Since it is important that this driver can easily be compared to the VIA +** datasheet, we will use the VIA numbering within this driver and map the +** kernel sysfs device name to the VIA number in the sysfs callback. +*/ + +#define VT8231_REG_TEMP_LOW01 0x49 +#define VT8231_REG_TEMP_LOW25 0x4d + +static const u8 regtemp[] = { 0x1f, 0x21, 0x22, 0x23, 0x24, 0x25 }; +static const u8 regtempmax[] = { 0x39, 0x3d, 0x2b, 0x2d, 0x2f, 0x31 }; +static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c, 0x2e, 0x30, 0x32 }; + +#define TEMP_FROM_REG(reg) (((253 * 4 - (reg)) * 550 + 105) / 210) +#define TEMP_MAXMIN_FROM_REG(reg) (((253 - (reg)) * 2200 + 105) / 210) +#define TEMP_MAXMIN_TO_REG(val) (253 - ((val) * 210 + 1100) / 2200) + +#define VT8231_REG_CONFIG 0x40 +#define VT8231_REG_ALARM1 0x41 +#define VT8231_REG_ALARM2 0x42 +#define VT8231_REG_FANDIV 0x47 +#define VT8231_REG_UCH_CONFIG 0x4a +#define VT8231_REG_TEMP1_CONFIG 0x4b +#define VT8231_REG_TEMP2_CONFIG 0x4c + +/* temps 0-5 as numbered in VIA datasheet - see later for mapping to Linux +** numbering +*/ +#define ISTEMP(i, ch_config) ((i) == 0 ? 1 : \ + ((ch_config) >> ((i)+1)) & 0x01) +/* voltages 0-5 */ +#define ISVOLT(i, ch_config) ((i) == 5 ? 1 : \ + !(((ch_config) >> ((i)+2)) & 0x01)) + +#define DIV_FROM_REG(val) (1 << (val)) + +/* NB The values returned here are NOT temperatures. The calibration curves +** for the thermistor curves are board-specific and must go in the +** sensors.conf file. Temperature sensors are actually ten bits, but the +** VIA datasheet only considers the 8 MSBs obtained from the regtemp[] +** register. The temperature value returned should have a magnitude of 3, +** so we use the VIA scaling as the "true" scaling and use the remaining 2 +** LSBs as fractional precision. +** +** All the on-chip hardware temperature comparisons for the alarms are only +** 8-bits wide, and compare against the 8 MSBs of the temperature. The bits +** in the registers VT8231_REG_TEMP_LOW01 and VT8231_REG_TEMP_LOW25 are +** ignored. +*/ + +/******** FAN RPM CONVERSIONS ******** +** This chip saturates back at 0, not at 255 like many the other chips. +** So, 0 means 0 RPM +*/ +static inline u8 FAN_TO_REG(long rpm, int div) +{ + if (rpm == 0) + return 0; + return SENSORS_LIMIT(1310720 / (rpm * div), 1, 255); +} + +#define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : 1310720 / ((val) * (div))) + +struct vt8231_data { + struct i2c_client client; + struct semaphore update_lock; + struct class_device *class_dev; + char valid; /* !=0 if following fields are valid */ + unsigned long last_updated; /* In jiffies */ + + u8 in[6]; /* Register value */ + u8 in_max[6]; /* Register value */ + u8 in_min[6]; /* Register value */ + u16 temp[6]; /* Register value 10 bit, right aligned */ + u8 temp_max[6]; /* Register value */ + u8 temp_min[6]; /* Register value */ + u8 fan[2]; /* Register value */ + u8 fan_min[2]; /* Register value */ + u8 fan_div[2]; /* Register encoding, shifted right */ + u16 alarms; /* Register encoding */ + u8 uch_config; +}; + +static struct pci_dev *s_bridge; +static int vt8231_detect(struct i2c_adapter *adapter); +static int vt8231_detach_client(struct i2c_client *client); +static struct vt8231_data *vt8231_update_device(struct device *dev); +static void vt8231_init_client(struct i2c_client *client); + +static inline int vt8231_read_value(struct i2c_client *client, u8 reg) +{ + return inb_p(client->addr + reg); +} + +static inline void vt8231_write_value(struct i2c_client *client, u8 reg, + u8 value) +{ + outb_p(value, client->addr + reg); +} + +/* following are the sysfs callback functions */ +static ssize_t show_in(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", ((data->in[nr] - 3) * 10000) / 958); +} + +static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", ((data->in_min[nr] - 3) * 10000) / 958); +} + +static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", (((data->in_max[nr] - 3) * 10000) / 958)); +} + +static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + unsigned long val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); + vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]); + up(&data->update_lock); + return count; +} + +static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + unsigned long val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); + vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]); + up(&data->update_lock); + return count; +} + +/* Special case for input 5 as this has 3.3V scaling built into the chip */ +static ssize_t show_in5(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", + (((data->in[5] - 3) * 10000 * 54) / (958 * 34))); +} + +static ssize_t show_in5_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", + (((data->in_min[5] - 3) * 10000 * 54) / (958 * 34))); +} + +static ssize_t show_in5_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + + return sprintf(buf, "%d\n", + (((data->in_max[5] - 3) * 10000 * 54) / (958 * 34))); +} + +static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + unsigned long val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, + 0, 255); + vt8231_write_value(client, regvoltmin[5], data->in_min[5]); + up(&data->update_lock); + return count; +} + +static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + unsigned long val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, + 0, 255); + vt8231_write_value(client, regvoltmax[5], data->in_max[5]); + up(&data->update_lock); + return count; +} + +#define define_voltage_sysfs(offset) \ +static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ + show_in, NULL, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ + show_in_min, set_in_min, offset); \ +static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ + show_in_max, set_in_max, offset) + +define_voltage_sysfs(0); +define_voltage_sysfs(1); +define_voltage_sysfs(2); +define_voltage_sysfs(3); +define_voltage_sysfs(4); + +static DEVICE_ATTR(in5_input, S_IRUGO, show_in5, NULL); +static DEVICE_ATTR(in5_min, S_IRUGO | S_IWUSR, show_in5_min, set_in5_min); +static DEVICE_ATTR(in5_max, S_IRUGO | S_IWUSR, show_in5_max, set_in5_max); + +/* Temperatures */ +static ssize_t show_temp0(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", data->temp[0] * 250); +} + +static ssize_t show_temp0_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", data->temp_max[0] * 1000); +} + +static ssize_t show_temp0_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", data->temp_min[0] * 1000); +} + +static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); + vt8231_write_value(client, regtempmax[0], data->temp_max[0]); + up(&data->update_lock); + return count; +} +static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); + vt8231_write_value(client, regtempmin[0], data->temp_min[0]); + up(&data->update_lock); + return count; +} + +static ssize_t show_temp(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr])); +} + +static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", TEMP_MAXMIN_FROM_REG(data->temp_max[nr])); +} + +static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", TEMP_MAXMIN_FROM_REG(data->temp_min[nr])); +} + +static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); + vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]); + up(&data->update_lock); + return count; +} +static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtol(buf, NULL, 10); + + down(&data->update_lock); + data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); + vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]); + up(&data->update_lock); + return count; +} + +/* Note that these map the Linux temperature sensor numbering (1-6) to the VIA +** temperature sensor numbering (0-5) +*/ +#define define_temperature_sysfs(offset) \ +static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ + show_temp, NULL, offset - 1); \ +static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ + show_temp_max, set_temp_max, offset - 1); \ +static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ + show_temp_min, set_temp_min, offset - 1) + +static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp0, NULL); +static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp0_max, set_temp0_max); +static DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, show_temp0_min, set_temp0_min); + +define_temperature_sysfs(2); +define_temperature_sysfs(3); +define_temperature_sysfs(4); +define_temperature_sysfs(5); +define_temperature_sysfs(6); + +#define CFG_INFO_TEMP(id) { &sensor_dev_attr_temp##id##_input.dev_attr, \ + &sensor_dev_attr_temp##id##_min.dev_attr, \ + &sensor_dev_attr_temp##id##_max.dev_attr } +#define CFG_INFO_VOLT(id) { &sensor_dev_attr_in##id##_input.dev_attr, \ + &sensor_dev_attr_in##id##_min.dev_attr, \ + &sensor_dev_attr_in##id##_max.dev_attr } + +struct str_device_attr_table { + struct device_attribute *input; + struct device_attribute *min; + struct device_attribute *max; +}; + +static struct str_device_attr_table cfg_info_temp[] = { + { &dev_attr_temp1_input, &dev_attr_temp1_min, &dev_attr_temp1_max }, + CFG_INFO_TEMP(2), + CFG_INFO_TEMP(3), + CFG_INFO_TEMP(4), + CFG_INFO_TEMP(5), + CFG_INFO_TEMP(6) +}; + +static struct str_device_attr_table cfg_info_volt[] = { + CFG_INFO_VOLT(0), + CFG_INFO_VOLT(1), + CFG_INFO_VOLT(2), + CFG_INFO_VOLT(3), + CFG_INFO_VOLT(4), + { &dev_attr_in5_input, &dev_attr_in5_min, &dev_attr_in5_max } +}; + +/* Fans */ +static ssize_t show_fan(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr], + DIV_FROM_REG(data->fan_div[nr]))); +} + +static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr], + DIV_FROM_REG(data->fan_div[nr]))); +} + +static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); +} + +static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + int nr = sensor_attr->index; + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int val = simple_strtoul(buf, NULL, 10); + + down(&data->update_lock); + data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); + vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); + up(&data->update_lock); + return count; +} + +static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); + unsigned long val = simple_strtoul(buf, NULL, 10); + int nr = sensor_attr->index; + int old = vt8231_read_value(client, VT8231_REG_FANDIV); + long min = FAN_FROM_REG(data->fan_min[nr], + DIV_FROM_REG(data->fan_div[nr])); + + down(&data->update_lock); + switch (val) { + case 1: data->fan_div[nr] = 0; break; + case 2: data->fan_div[nr] = 1; break; + case 4: data->fan_div[nr] = 2; break; + case 8: data->fan_div[nr] = 3; break; + default: + dev_err(&client->dev, "fan_div value %ld not supported." + "Choose one of 1, 2, 4 or 8!\n", val); + up(&data->update_lock); + return -EINVAL; + } + + /* Correct the fan minimum speed */ + data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); + vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]); + + old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4); + vt8231_write_value(client, VT8231_REG_FANDIV, old); + up(&data->update_lock); + return count; +} + + +#define define_fan_sysfs(offset) \ +static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ + show_fan, NULL, offset - 1); \ +static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ + show_fan_div, set_fan_div, offset - 1); \ +static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ + show_fan_min, set_fan_min, offset - 1) + +define_fan_sysfs(1); +define_fan_sysfs(2); + +/* Alarms */ +static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct vt8231_data *data = vt8231_update_device(dev); + return sprintf(buf, "%d\n", data->alarms); +} + +static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); + +static struct i2c_driver vt8231_driver = { + .owner = THIS_MODULE, + .name = "vt8231", + .attach_adapter = vt8231_detect, + .detach_client = vt8231_detach_client, +}; + +static struct pci_device_id vt8231_pci_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4) }, + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, vt8231_pci_ids); + +static int __devinit vt8231_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id); + +static struct pci_driver vt8231_pci_driver = { + .name = "vt8231", + .id_table = vt8231_pci_ids, + .probe = vt8231_pci_probe, +}; + +int vt8231_detect(struct i2c_adapter *adapter) +{ + struct i2c_client *client; + struct vt8231_data *data; + int err = 0, i; + u16 val; + + /* 8231 requires multiple of 256 */ + if (force_addr) { + isa_address = force_addr & 0xFF00; + dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", + isa_address); + if (PCIBIOS_SUCCESSFUL != pci_write_config_word(s_bridge, + VT8231_BASE_REG, isa_address)) + return -ENODEV; + } + + if (PCIBIOS_SUCCESSFUL != + pci_read_config_word(s_bridge, VT8231_ENABLE_REG, &val)) + return -ENODEV; + + if (!(val & 0x0001)) { + dev_warn(&adapter->dev, "enabling sensors\n"); + if (PCIBIOS_SUCCESSFUL != + pci_write_config_word(s_bridge, VT8231_ENABLE_REG, + val | 0x0001)) + return -ENODEV; + } + + /* Reserve the ISA region */ + if (!request_region(isa_address, VT8231_EXTENT, + vt8231_pci_driver.name)) { + dev_err(&adapter->dev, "region 0x%x already in use!\n", + isa_address); + return -ENODEV; + } + + if (!(data = kzalloc(sizeof(struct vt8231_data), GFP_KERNEL))) { + err = -ENOMEM; + goto exit_release; + } + + client = &data->client; + i2c_set_clientdata(client, data); + client->addr = isa_address; + client->adapter = adapter; + client->driver = &vt8231_driver; + client->dev.parent = &adapter->dev; + + /* Fill in the remaining client fields and put into the global list */ + strlcpy(client->name, "vt8231", I2C_NAME_SIZE); + + init_MUTEX(&data->update_lock); + + /* Tell the I2C layer a new client has arrived */ + if ((err = i2c_attach_client(client))) + goto exit_free; + + vt8231_init_client(client); + + /* Register sysfs hooks */ + data->class_dev = hwmon_device_register(&client->dev); + if (IS_ERR(data->class_dev)) { + err = PTR_ERR(data->class_dev); + goto exit_detach; + } + + /* Must update device information to find out the config field */ + data->uch_config = vt8231_read_value(client, VT8231_REG_UCH_CONFIG); + + for (i = 0; i < ARRAY_SIZE(cfg_info_temp); i++) { + if (ISTEMP(i, data->uch_config)) { + device_create_file(&client->dev, + cfg_info_temp[i].input); + device_create_file(&client->dev, cfg_info_temp[i].max); + device_create_file(&client->dev, cfg_info_temp[i].min); + } + } + + for (i = 0; i < ARRAY_SIZE(cfg_info_volt); i++) { + if (ISVOLT(i, data->uch_config)) { + device_create_file(&client->dev, + cfg_info_volt[i].input); + device_create_file(&client->dev, cfg_info_volt[i].max); + device_create_file(&client->dev, cfg_info_volt[i].min); + } + } + + device_create_file(&client->dev, &sensor_dev_attr_fan1_input.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan2_input.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan1_min.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan2_min.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan1_div.dev_attr); + device_create_file(&client->dev, &sensor_dev_attr_fan2_div.dev_attr); + + device_create_file(&client->dev, &dev_attr_alarms); + return 0; + +exit_detach: + i2c_detach_client(client); +exit_free: + kfree(data); +exit_release: + release_region(isa_address, VT8231_EXTENT); + return err; +} + +static int vt8231_detach_client(struct i2c_client *client) +{ + struct vt8231_data *data = i2c_get_clientdata(client); + int err; + + hwmon_device_unregister(data->class_dev); + + if ((err = i2c_detach_client(client))) { + return err; + } + + release_region(client->addr, VT8231_EXTENT); + kfree(data); + + return 0; +} + +static void vt8231_init_client(struct i2c_client *client) +{ + vt8231_write_value(client, VT8231_REG_TEMP1_CONFIG, 0); + vt8231_write_value(client, VT8231_REG_TEMP2_CONFIG, 0); +} + +static struct vt8231_data *vt8231_update_device(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + struct vt8231_data *data = i2c_get_clientdata(client); + int i; + u16 low; + + down(&data->update_lock); + + if (time_after(jiffies, data->last_updated + HZ + HZ / 2) + || !data->valid) { + for (i = 0; i < 6; i++) { + if (ISVOLT(i, data->uch_config)) { + data->in[i] = vt8231_read_value(client, + regvolt[i]); + data->in_min[i] = vt8231_read_value(client, + regvoltmin[i]); + data->in_max[i] = vt8231_read_value(client, + regvoltmax[i]); + } + } + for (i = 0; i < 2; i++) { + data->fan[i] = vt8231_read_value(client, + VT8231_REG_FAN(i)); + data->fan_min[i] = vt8231_read_value(client, + VT8231_REG_FAN_MIN(i)); + } + + low = vt8231_read_value(client, VT8231_REG_TEMP_LOW01); + low = (low >> 6) | ((low & 0x30) >> 2) + | (vt8231_read_value(client, VT8231_REG_TEMP_LOW25) << 4); + for (i = 0; i < 6; i++) { + if (ISTEMP(i, data->uch_config)) { + data->temp[i] = (vt8231_read_value(client, + regtemp[i]) << 2) + | ((low >> (2 * i)) & 0x03); + data->temp_max[i] = vt8231_read_value(client, + regtempmax[i]); + data->temp_min[i] = vt8231_read_value(client, + regtempmin[i]); + } + } + + i = vt8231_read_value(client, VT8231_REG_FANDIV); + data->fan_div[0] = (i >> 4) & 0x03; + data->fan_div[1] = i >> 6; + data->alarms = vt8231_read_value(client, VT8231_REG_ALARM1) | + (vt8231_read_value(client, VT8231_REG_ALARM2) << 8); + + /* Set alarm flags correctly */ + if (!data->fan[0] && data->fan_min[0]) { + data->alarms |= 0x40; + } else if (data->fan[0] && !data->fan_min[0]) { + data->alarms &= ~0x40; + } + + if (!data->fan[1] && data->fan_min[1]) { + data->alarms |= 0x80; + } else if (data->fan[1] && !data->fan_min[1]) { + data->alarms &= ~0x80; + } + + data->last_updated = jiffies; + data->valid = 1; + } + + up(&data->update_lock); + + return data; +} + +static int __devinit vt8231_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + u16 val; + + if (PCIBIOS_SUCCESSFUL != pci_read_config_word(dev, VT8231_BASE_REG, + &val)) + return -ENODEV; + + isa_address = val & ~(VT8231_EXTENT - 1); + if (isa_address == 0 && force_addr == 0) { + dev_err(&dev->dev, "base address not set -\ + upgrade BIOS or use force_addr=0xaddr\n"); + return -ENODEV; + } + + s_bridge = pci_dev_get(dev); + + if (i2c_isa_add_driver(&vt8231_driver)) { + pci_dev_put(s_bridge); + s_bridge = NULL; + } + + /* Always return failure here. This is to allow other drivers to bind + * to this pci device. We don't really want to have control over the + * pci device, we only wanted to read as few register values from it. + */ + return -ENODEV; +} + +static int __init sm_vt8231_init(void) +{ + return pci_module_init(&vt8231_pci_driver); +} + +static void __exit sm_vt8231_exit(void) +{ + pci_unregister_driver(&vt8231_pci_driver); + if (s_bridge != NULL) { + i2c_isa_del_driver(&vt8231_driver); + pci_dev_put(s_bridge); + s_bridge = NULL; + } +} + +MODULE_AUTHOR("Roger Lucas "); +MODULE_DESCRIPTION("VT8231 sensors"); +MODULE_LICENSE("GPL"); + +module_init(sm_vt8231_init); +module_exit(sm_vt8231_exit); -- cgit v1.1 From ff179c8cf5caa17bf3d407edbb5872aa2eee6900 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 20:24:59 +0100 Subject: [PATCH] i2c: Drop i2c_driver.flags, 1 of 3 The I2C_DF_DUMMY flag is gone since 2.5.70, it's about time to drop all ifdef'd out references thereto. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/media/video/tvmixer.c | 4 ---- include/linux/i2c.h | 5 ----- 2 files changed, 9 deletions(-) diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index 8318bd1..5897e5d 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -232,12 +232,8 @@ static struct i2c_driver driver = { #endif .name = "tv card mixer driver", .id = I2C_DRIVERID_TVMIXER, -#ifdef I2C_DF_DUMMY - .flags = I2C_DF_DUMMY, -#else .flags = I2C_DF_NOTIFY, .detach_adapter = tvmixer_adapters, -#endif .attach_adapter = tvmixer_adapters, .detach_client = tvmixer_clients, }; diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 5e19a7b..0316ba1 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -252,11 +252,6 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) /*flags for the driver struct: */ #define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */ -#if 0 -/* this flag is gone -- there is a (optional) driver->detach_adapter - * callback now which can be used instead */ -# define I2C_DF_DUMMY 0x02 -#endif /*flags for the client struct: */ #define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */ -- cgit v1.1 From 8a9947552d43b0d20d5fa23ac0ba435d526be454 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 20:28:06 +0100 Subject: [PATCH] i2c: Drop i2c_driver.flags, 2 of 3 Just about every i2c chip driver sets the I2C_DF_NOTIFY flag, so we can simply make it the default and drop the flag. If any driver really doesn't want to be notified when i2c adapters are added, that driver can simply omit to set .attach_adapter. This approach is also more robust as it prevents accidental NULL pointer dereferences. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/porting-clients | 3 +++ Documentation/i2c/writing-clients | 5 ----- arch/arm/mach-pxa/akita-ioexp.c | 1 - drivers/acorn/char/pcf8583.c | 1 - drivers/hwmon/adm1021.c | 1 - drivers/hwmon/adm1025.c | 1 - drivers/hwmon/adm1026.c | 1 - drivers/hwmon/adm1031.c | 1 - drivers/hwmon/adm9240.c | 1 - drivers/hwmon/asb100.c | 1 - drivers/hwmon/atxp1.c | 1 - drivers/hwmon/ds1621.c | 1 - drivers/hwmon/fscher.c | 1 - drivers/hwmon/fscpos.c | 1 - drivers/hwmon/gl518sm.c | 1 - drivers/hwmon/gl520sm.c | 1 - drivers/hwmon/it87.c | 1 - drivers/hwmon/lm63.c | 1 - drivers/hwmon/lm75.c | 1 - drivers/hwmon/lm77.c | 1 - drivers/hwmon/lm78.c | 1 - drivers/hwmon/lm80.c | 1 - drivers/hwmon/lm83.c | 1 - drivers/hwmon/lm85.c | 1 - drivers/hwmon/lm87.c | 1 - drivers/hwmon/lm90.c | 1 - drivers/hwmon/lm92.c | 1 - drivers/hwmon/max1619.c | 1 - drivers/hwmon/w83781d.c | 1 - drivers/hwmon/w83792d.c | 1 - drivers/hwmon/w83l785ts.c | 1 - drivers/i2c/chips/ds1337.c | 1 - drivers/i2c/chips/ds1374.c | 1 - drivers/i2c/chips/eeprom.c | 1 - drivers/i2c/chips/isp1301_omap.c | 1 - drivers/i2c/chips/m41t00.c | 1 - drivers/i2c/chips/max6875.c | 1 - drivers/i2c/chips/pca9539.c | 1 - drivers/i2c/chips/pcf8574.c | 1 - drivers/i2c/chips/pcf8591.c | 1 - drivers/i2c/chips/rtc8564.c | 1 - drivers/i2c/chips/tps65010.c | 1 - drivers/i2c/chips/x1205.c | 1 - drivers/i2c/i2c-core.c | 4 ++-- drivers/i2c/i2c-dev.c | 1 - drivers/macintosh/therm_adt746x.c | 1 - drivers/macintosh/therm_pm72.c | 1 - drivers/macintosh/therm_windtunnel.c | 1 - drivers/macintosh/windfarm_lm75_sensor.c | 1 - drivers/media/video/adv7170.c | 1 - drivers/media/video/adv7175.c | 1 - drivers/media/video/bt819.c | 1 - drivers/media/video/bt832.c | 1 - drivers/media/video/bt856.c | 1 - drivers/media/video/cs53l32a.c | 1 - drivers/media/video/cx25840/cx25840-core.c | 1 - drivers/media/video/indycam.c | 1 - drivers/media/video/ir-kbd-i2c.c | 1 - drivers/media/video/msp3400.c | 1 - drivers/media/video/ovcamchip/ovcamchip_core.c | 1 - drivers/media/video/saa5246a.c | 1 - drivers/media/video/saa5249.c | 1 - drivers/media/video/saa6588.c | 1 - drivers/media/video/saa7110.c | 1 - drivers/media/video/saa7111.c | 1 - drivers/media/video/saa7114.c | 1 - drivers/media/video/saa7115.c | 1 - drivers/media/video/saa711x.c | 1 - drivers/media/video/saa7127.c | 1 - drivers/media/video/saa7134/saa6752hs.c | 1 - drivers/media/video/saa7185.c | 1 - drivers/media/video/saa7191.c | 1 - drivers/media/video/tda7432.c | 1 - drivers/media/video/tda9840.c | 1 - drivers/media/video/tda9875.c | 1 - drivers/media/video/tda9887.c | 1 - drivers/media/video/tea6415c.c | 1 - drivers/media/video/tea6420.c | 1 - drivers/media/video/tuner-3036.c | 1 - drivers/media/video/tuner-core.c | 1 - drivers/media/video/tvaudio.c | 1 - drivers/media/video/tveeprom.c | 1 - drivers/media/video/tvmixer.c | 1 - drivers/media/video/tvp5150.c | 1 - drivers/media/video/vpx3220.c | 1 - drivers/media/video/wm8775.c | 1 - drivers/video/matrox/matroxfb_maven.c | 1 - include/linux/i2c.h | 1 - sound/oss/dmasound/dac3550a.c | 1 - sound/oss/dmasound/tas_common.c | 1 - sound/ppc/keywest.c | 1 - 91 files changed, 5 insertions(+), 95 deletions(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 184fac2..64c610b 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -109,6 +109,9 @@ Technical changes: there is a MODULE_LICENSE() line, at the bottom of the file (after MODULE_AUTHOR() and MODULE_DESCRIPTION(), in this order). +* [Driver] The flags field of the i2c_driver structure is gone. + I2C_DF_NOTIFY is now the default behavior. + Coding policy: * [Copyright] Use (C), not (c), for copyright. diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index d19993c..59d2c16 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -27,7 +27,6 @@ address. static struct i2c_driver foo_driver = { .owner = THIS_MODULE, .name = "Foo version 2.3 driver", - .flags = I2C_DF_NOTIFY, .attach_adapter = &foo_attach_adapter, .detach_client = &foo_detach_client, .command = &foo_command /* may be NULL */ @@ -36,10 +35,6 @@ static struct i2c_driver foo_driver = { The name field must match the driver name, including the case. It must not contain spaces, and may be up to 31 characters long. -Don't worry about the flags field; just put I2C_DF_NOTIFY into it. This -means that your driver will be notified when new adapters are found. -This is almost always what you want. - All other fields are for call-back functions which will be explained below. diff --git a/arch/arm/mach-pxa/akita-ioexp.c b/arch/arm/mach-pxa/akita-ioexp.c index f6d73cc..440ebb3 100644 --- a/arch/arm/mach-pxa/akita-ioexp.c +++ b/arch/arm/mach-pxa/akita-ioexp.c @@ -127,7 +127,6 @@ static struct i2c_driver max7310_i2c_driver = { .owner = THIS_MODULE, .name = "akita-max7310", .id = I2C_DRIVERID_AKITAIOEXP, - .flags = I2C_DF_NOTIFY, .attach_adapter = max7310_attach_adapter, .detach_client = max7310_detach_client, }; diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c index e26f007..befc946 100644 --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c @@ -259,7 +259,6 @@ pcf8583_command(struct i2c_client *client, unsigned int cmd, void *arg) static struct i2c_driver pcf8583_driver = { .name = "PCF8583", .id = I2C_DRIVERID_PCF8583, - .flags = I2C_DF_NOTIFY, .attach_adapter = pcf8583_probe, .detach_client = pcf8583_detach, .command = pcf8583_command diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 8102876..5e6df4b 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -129,7 +129,6 @@ static struct i2c_driver adm1021_driver = { .owner = THIS_MODULE, .name = "adm1021", .id = I2C_DRIVERID_ADM1021, - .flags = I2C_DF_NOTIFY, .attach_adapter = adm1021_attach_adapter, .detach_client = adm1021_detach_client, }; diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index bf67860..2be48a7 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -121,7 +121,6 @@ static struct i2c_driver adm1025_driver = { .owner = THIS_MODULE, .name = "adm1025", .id = I2C_DRIVERID_ADM1025, - .flags = I2C_DF_NOTIFY, .attach_adapter = adm1025_attach_adapter, .detach_client = adm1025_detach_client, }; diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 5036b17..5416db8 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -310,7 +310,6 @@ static void adm1026_init_client(struct i2c_client *client); static struct i2c_driver adm1026_driver = { .owner = THIS_MODULE, .name = "adm1026", - .flags = I2C_DF_NOTIFY, .attach_adapter = adm1026_attach_adapter, .detach_client = adm1026_detach_client, }; diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 7c545d5..1e244280 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c @@ -107,7 +107,6 @@ static struct adm1031_data *adm1031_update_device(struct device *dev); static struct i2c_driver adm1031_driver = { .owner = THIS_MODULE, .name = "adm1031", - .flags = I2C_DF_NOTIFY, .attach_adapter = adm1031_attach_adapter, .detach_client = adm1031_detach_client, }; diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 11dc95f..287733f 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -140,7 +140,6 @@ static struct i2c_driver adm9240_driver = { .owner = THIS_MODULE, .name = "adm9240", .id = I2C_DRIVERID_ADM9240, - .flags = I2C_DF_NOTIFY, .attach_adapter = adm9240_attach_adapter, .detach_client = adm9240_detach_client, }; diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 52c4697..7227f80 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -220,7 +220,6 @@ static struct i2c_driver asb100_driver = { .owner = THIS_MODULE, .name = "asb100", .id = I2C_DRIVERID_ASB100, - .flags = I2C_DF_NOTIFY, .attach_adapter = asb100_attach_adapter, .detach_client = asb100_detach_client, }; diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index 53324f5..a60a9f2 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -52,7 +52,6 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); static struct i2c_driver atxp1_driver = { .owner = THIS_MODULE, .name = "atxp1", - .flags = I2C_DF_NOTIFY, .attach_adapter = atxp1_attach_adapter, .detach_client = atxp1_detach_client, }; diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 34f71b7..0096eb3 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -92,7 +92,6 @@ static struct i2c_driver ds1621_driver = { .owner = THIS_MODULE, .name = "ds1621", .id = I2C_DRIVERID_DS1621, - .flags = I2C_DF_NOTIFY, .attach_adapter = ds1621_attach_adapter, .detach_client = ds1621_detach_client, }; diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index a02e1c3..f56ca06 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -121,7 +121,6 @@ static struct i2c_driver fscher_driver = { .owner = THIS_MODULE, .name = "fscher", .id = I2C_DRIVERID_FSCHER, - .flags = I2C_DF_NOTIFY, .attach_adapter = fscher_attach_adapter, .detach_client = fscher_detach_client, }; diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 64e4edc..701dffc 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -103,7 +103,6 @@ static struct i2c_driver fscpos_driver = { .owner = THIS_MODULE, .name = "fscpos", .id = I2C_DRIVERID_FSCPOS, - .flags = I2C_DF_NOTIFY, .attach_adapter = fscpos_attach_adapter, .detach_client = fscpos_detach_client, }; diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 2f178db..5788bbb 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -154,7 +154,6 @@ static struct i2c_driver gl518_driver = { .owner = THIS_MODULE, .name = "gl518sm", .id = I2C_DRIVERID_GL518, - .flags = I2C_DF_NOTIFY, .attach_adapter = gl518_attach_adapter, .detach_client = gl518_detach_client, }; diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index c39ba12..b399816 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -112,7 +112,6 @@ static struct i2c_driver gl520_driver = { .owner = THIS_MODULE, .name = "gl520sm", .id = I2C_DRIVERID_GL520, - .flags = I2C_DF_NOTIFY, .attach_adapter = gl520_attach_adapter, .detach_client = gl520_detach_client, }; diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index a61f5d0..d5f0d92 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -237,7 +237,6 @@ static struct i2c_driver it87_driver = { .owner = THIS_MODULE, .name = "it87", .id = I2C_DRIVERID_IT87, - .flags = I2C_DF_NOTIFY, .attach_adapter = it87_attach_adapter, .detach_client = it87_detach_client, }; diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 954ec24..c2dd4ac 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -141,7 +141,6 @@ static void lm63_init_client(struct i2c_client *client); static struct i2c_driver lm63_driver = { .owner = THIS_MODULE, .name = "lm63", - .flags = I2C_DF_NOTIFY, .attach_adapter = lm63_attach_adapter, .detach_client = lm63_detach_client, }; diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index d70f4c8..0bcbd65 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -69,7 +69,6 @@ static struct i2c_driver lm75_driver = { .owner = THIS_MODULE, .name = "lm75", .id = I2C_DRIVERID_LM75, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm75_attach_adapter, .detach_client = lm75_detach_client, }; diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 9380fda..6a524e9 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -76,7 +76,6 @@ static struct lm77_data *lm77_update_device(struct device *dev); static struct i2c_driver lm77_driver = { .owner = THIS_MODULE, .name = "lm77", - .flags = I2C_DF_NOTIFY, .attach_adapter = lm77_attach_adapter, .detach_client = lm77_detach_client, }; diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 78cdd50..18448f8 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -167,7 +167,6 @@ static struct i2c_driver lm78_driver = { .owner = THIS_MODULE, .name = "lm78", .id = I2C_DRIVERID_LM78, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm78_attach_adapter, .detach_client = lm78_detach_client, }; diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index c359fde..02303fa 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -146,7 +146,6 @@ static struct i2c_driver lm80_driver = { .owner = THIS_MODULE, .name = "lm80", .id = I2C_DRIVERID_LM80, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm80_attach_adapter, .detach_client = lm80_detach_client, }; diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 9a70611..96cb34e 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -127,7 +127,6 @@ static struct i2c_driver lm83_driver = { .owner = THIS_MODULE, .name = "lm83", .id = I2C_DRIVERID_LM83, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm83_attach_adapter, .detach_client = lm83_detach_client, }; diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 3f5544a..131ecab 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -383,7 +383,6 @@ static struct i2c_driver lm85_driver = { .owner = THIS_MODULE, .name = "lm85", .id = I2C_DRIVERID_LM85, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm85_attach_adapter, .detach_client = lm85_detach_client, }; diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index eeec1817..26fd0b3 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -164,7 +164,6 @@ static struct i2c_driver lm87_driver = { .owner = THIS_MODULE, .name = "lm87", .id = I2C_DRIVERID_LM87, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm87_attach_adapter, .detach_client = lm87_detach_client, }; diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 83cf2e1..011923b 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -189,7 +189,6 @@ static struct i2c_driver lm90_driver = { .owner = THIS_MODULE, .name = "lm90", .id = I2C_DRIVERID_LM90, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm90_attach_adapter, .detach_client = lm90_detach_client, }; diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 7a4b3701..2005a9e 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -413,7 +413,6 @@ static struct i2c_driver lm92_driver = { .owner = THIS_MODULE, .name = "lm92", .id = I2C_DRIVERID_LM92, - .flags = I2C_DF_NOTIFY, .attach_adapter = lm92_attach_adapter, .detach_client = lm92_detach_client, }; diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 69e7e12..d5aebef 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -92,7 +92,6 @@ static struct max1619_data *max1619_update_device(struct device *dev); static struct i2c_driver max1619_driver = { .owner = THIS_MODULE, .name = "max1619", - .flags = I2C_DF_NOTIFY, .attach_adapter = max1619_attach_adapter, .detach_client = max1619_detach_client, }; diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index ffdb3a0..a78929f 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -272,7 +272,6 @@ static struct i2c_driver w83781d_driver = { .owner = THIS_MODULE, .name = "w83781d", .id = I2C_DRIVERID_W83781D, - .flags = I2C_DF_NOTIFY, .attach_adapter = w83781d_attach_adapter, .detach_client = w83781d_detach_client, }; diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 1ba0726..6824243 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -319,7 +319,6 @@ static void w83792d_init_client(struct i2c_client *client); static struct i2c_driver w83792d_driver = { .owner = THIS_MODULE, .name = "w83792d", - .flags = I2C_DF_NOTIFY, .attach_adapter = w83792d_attach_adapter, .detach_client = w83792d_detach_client, }; diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index f495b63..35172fb 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -95,7 +95,6 @@ static struct i2c_driver w83l785ts_driver = { .owner = THIS_MODULE, .name = "w83l785ts", .id = I2C_DRIVERID_W83L785TS, - .flags = I2C_DF_NOTIFY, .attach_adapter = w83l785ts_attach_adapter, .detach_client = w83l785ts_detach_client, }; diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 1822895..65146cb 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -54,7 +54,6 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, static struct i2c_driver ds1337_driver = { .owner = THIS_MODULE, .name = "ds1337", - .flags = I2C_DF_NOTIFY, .attach_adapter = ds1337_attach_adapter, .detach_client = ds1337_detach_client, .command = ds1337_command, diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index da488b7..5a270d6 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -235,7 +235,6 @@ static struct i2c_driver ds1374_driver = { .owner = THIS_MODULE, .name = DS1374_DRV_NAME, .id = I2C_DRIVERID_DS1374, - .flags = I2C_DF_NOTIFY, .attach_adapter = ds1374_attach, .detach_client = ds1374_detach, }; diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 4baf573..9bb1f8b 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -71,7 +71,6 @@ static struct i2c_driver eeprom_driver = { .owner = THIS_MODULE, .name = "eeprom", .id = I2C_DRIVERID_EEPROM, - .flags = I2C_DF_NOTIFY, .attach_adapter = eeprom_attach_adapter, .detach_client = eeprom_detach_client, }; diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index d2a100d..4f472ba 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c @@ -1636,7 +1636,6 @@ static struct i2c_driver isp1301_driver = { .name = "isp1301_omap", .id = 1301, /* FIXME "official", i2c-ids.h */ .class = I2C_CLASS_HWMON, - .flags = I2C_DF_NOTIFY, .attach_adapter = isp1301_scan_bus, .detach_client = isp1301_detach_client, }; diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 3df309a..13e6783 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -214,7 +214,6 @@ static struct i2c_driver m41t00_driver = { .owner = THIS_MODULE, .name = M41T00_DRV_NAME, .id = I2C_DRIVERID_STM41T00, - .flags = I2C_DF_NOTIFY, .attach_adapter = m41t00_attach, .detach_client = m41t00_detach, }; diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index b376a00..7e61019 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -69,7 +69,6 @@ static int max6875_detach_client(struct i2c_client *client); static struct i2c_driver max6875_driver = { .owner = THIS_MODULE, .name = "max6875", - .flags = I2C_DF_NOTIFY, .attach_adapter = max6875_attach_adapter, .detach_client = max6875_detach_client, }; diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index 59a9303..26feb7a 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c @@ -40,7 +40,6 @@ static int pca9539_detach_client(struct i2c_client *client); static struct i2c_driver pca9539_driver = { .owner = THIS_MODULE, .name = "pca9539", - .flags = I2C_DF_NOTIFY, .attach_adapter = pca9539_attach_adapter, .detach_client = pca9539_detach_client, }; diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index c323c2d..2fae640 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -68,7 +68,6 @@ static struct i2c_driver pcf8574_driver = { .owner = THIS_MODULE, .name = "pcf8574", .id = I2C_DRIVERID_PCF8574, - .flags = I2C_DF_NOTIFY, .attach_adapter = pcf8574_attach_adapter, .detach_client = pcf8574_detach_client, }; diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index ce420a6..8750f71 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c @@ -91,7 +91,6 @@ static struct i2c_driver pcf8591_driver = { .owner = THIS_MODULE, .name = "pcf8591", .id = I2C_DRIVERID_PCF8591, - .flags = I2C_DF_NOTIFY, .attach_adapter = pcf8591_attach_adapter, .detach_client = pcf8591_detach_client, }; diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 26e498d..e586f75 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c @@ -362,7 +362,6 @@ static struct i2c_driver rtc8564_driver = { .owner = THIS_MODULE, .name = "RTC8564", .id = I2C_DRIVERID_RTC8564, - .flags = I2C_DF_NOTIFY, .attach_adapter = rtc8564_probe, .detach_client = rtc8564_detach, .command = rtc8564_command diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 280dd7a..439bf6c 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c @@ -639,7 +639,6 @@ static int __init tps65010_scan_bus(struct i2c_adapter *bus) static struct i2c_driver tps65010_driver = { .owner = THIS_MODULE, .name = "tps65010", - .flags = I2C_DF_NOTIFY, .attach_adapter = tps65010_scan_bus, .detach_client = __exit_p(tps65010_detach_client), }; diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c index 7da366c..c5ff2ce 100644 --- a/drivers/i2c/chips/x1205.c +++ b/drivers/i2c/chips/x1205.c @@ -107,7 +107,6 @@ static int x1205_command(struct i2c_client *client, unsigned int cmd, static struct i2c_driver x1205_driver = { .owner = THIS_MODULE, .name = "x1205", - .flags = I2C_DF_NOTIFY, .attach_adapter = &x1205_attach, .detach_client = &x1205_detach, }; diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 82ea1b7..ad68ac0 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -197,7 +197,7 @@ int i2c_add_adapter(struct i2c_adapter *adap) /* inform drivers of new adapters */ list_for_each(item,&drivers) { driver = list_entry(item, struct i2c_driver, list); - if (driver->flags & I2C_DF_NOTIFY) + if (driver->attach_adapter) /* We ignore the return code; if it fails, too bad */ driver->attach_adapter(adap); } @@ -309,7 +309,7 @@ int i2c_add_driver(struct i2c_driver *driver) pr_debug("i2c-core: driver [%s] registered\n", driver->name); /* now look for instances of driver on our adapters */ - if (driver->flags & I2C_DF_NOTIFY) { + if (driver->attach_adapter) { list_for_each(item,&adapters) { adapter = list_entry(item, struct i2c_adapter, list); driver->attach_adapter(adapter); diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 8af0bd1..9da51eb 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -484,7 +484,6 @@ static struct i2c_driver i2cdev_driver = { .owner = THIS_MODULE, .name = "dev_driver", .id = I2C_DRIVERID_I2CDEV, - .flags = I2C_DF_NOTIFY, .attach_adapter = i2cdev_attach_adapter, .detach_adapter = i2cdev_detach_adapter, .detach_client = i2cdev_detach_client, diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index f386966..f62c16f 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -173,7 +173,6 @@ detach_thermostat(struct i2c_adapter *adapter) static struct i2c_driver thermostat_driver = { .owner = THIS_MODULE, .name = "therm_adt746x", - .flags = I2C_DF_NOTIFY, .attach_adapter = attach_thermostat, .detach_adapter = detach_thermostat, }; diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index 190878e..df00c96 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c @@ -285,7 +285,6 @@ static struct i2c_driver therm_pm72_driver = { .owner = THIS_MODULE, .name = "therm_pm72", - .flags = I2C_DF_NOTIFY, .attach_adapter = therm_pm72_attach, .detach_adapter = therm_pm72_detach, }; diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index 6aaa1df..f3bae0d 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -357,7 +357,6 @@ static struct i2c_driver g4fan_driver = { .owner = THIS_MODULE, .name = "therm_windtunnel", .id = I2C_DRIVERID_G4FAN, - .flags = I2C_DF_NOTIFY, .attach_adapter = do_attach, .detach_client = do_detach, }; diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c index a0a41ad..2392789 100644 --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c @@ -49,7 +49,6 @@ static int wf_lm75_detach(struct i2c_client *client); static struct i2c_driver wf_lm75_driver = { .owner = THIS_MODULE, .name = "wf_lm75", - .flags = I2C_DF_NOTIFY, .attach_adapter = wf_lm75_attach, .detach_client = wf_lm75_detach, }; diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 1ca2b67..c4f2265 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c @@ -502,7 +502,6 @@ static struct i2c_driver i2c_driver_adv7170 = { .name = "adv7170", /* name */ .id = I2C_DRIVERID_ADV7170, - .flags = I2C_DF_NOTIFY, .attach_adapter = adv7170_attach_adapter, .detach_client = adv7170_detach_client, diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 173bca1..4fc08b1 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -552,7 +552,6 @@ static struct i2c_driver i2c_driver_adv7175 = { .name = "adv7175", /* name */ .id = I2C_DRIVERID_ADV7175, - .flags = I2C_DF_NOTIFY, .attach_adapter = adv7175_attach_adapter, .detach_client = adv7175_detach_client, diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index 3ee0afc..7bba697 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c @@ -627,7 +627,6 @@ static struct i2c_driver i2c_driver_bt819 = { .name = "bt819", .id = I2C_DRIVERID_BT819, - .flags = I2C_DF_NOTIFY, .attach_adapter = bt819_attach_adapter, .detach_client = bt819_detach_client, diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index 3ca1d76..0ba8652 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c @@ -233,7 +233,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "i2c bt832 driver", .id = -1, /* FIXME */ - .flags = I2C_DF_NOTIFY, .attach_adapter = bt832_probe, .detach_client = bt832_detach, .command = bt832_command, diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 8eb871d..4c9acd1 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c @@ -409,7 +409,6 @@ static struct i2c_driver i2c_driver_bt856 = { .name = "bt856", .id = I2C_DRIVERID_BT856, - .flags = I2C_DF_NOTIFY, .attach_adapter = bt856_attach_adapter, .detach_client = bt856_detach_client, diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c index 780b352..fce5d89 100644 --- a/drivers/media/video/cs53l32a.c +++ b/drivers/media/video/cs53l32a.c @@ -218,7 +218,6 @@ static int cs53l32a_detach(struct i2c_client *client) static struct i2c_driver i2c_driver = { .name = "cs53l32a", .id = I2C_DRIVERID_CS53L32A, - .flags = I2C_DF_NOTIFY, .attach_adapter = cs53l32a_probe, .detach_client = cs53l32a_detach, .command = cs53l32a_command, diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 5b93723..c66bc14 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c @@ -847,7 +847,6 @@ static struct i2c_driver i2c_driver_cx25840 = { .name = "cx25840", .id = I2C_DRIVERID_CX25840, - .flags = I2C_DF_NOTIFY, .attach_adapter = cx25840_attach_adapter, .detach_client = cx25840_detach_client, diff --git a/drivers/media/video/indycam.c b/drivers/media/video/indycam.c index deeef12..3eba514 100644 --- a/drivers/media/video/indycam.c +++ b/drivers/media/video/indycam.c @@ -454,7 +454,6 @@ static struct i2c_driver i2c_driver_indycam = { .owner = THIS_MODULE, .name = "indycam", .id = I2C_DRIVERID_INDYCAM, - .flags = I2C_DF_NOTIFY, .attach_adapter = indycam_probe, .detach_client = indycam_detach, .command = indycam_command, diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 740e543..2e2f78a 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -280,7 +280,6 @@ static int ir_probe(struct i2c_adapter *adap); static struct i2c_driver driver = { .name = "ir remote kbd driver", .id = I2C_DRIVERID_INFRARED, - .flags = I2C_DF_NOTIFY, .attach_adapter = ir_probe, .detach_client = ir_detach, }; diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index d86f8e9..46328fb 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -1564,7 +1564,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "msp3400", .id = I2C_DRIVERID_MSP3400, - .flags = I2C_DF_NOTIFY, .attach_adapter = msp_probe, .detach_client = msp_detach, .command = msp_command, diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c index 2de34eb..390d0d6 100644 --- a/drivers/media/video/ovcamchip/ovcamchip_core.c +++ b/drivers/media/video/ovcamchip/ovcamchip_core.c @@ -414,7 +414,6 @@ static struct i2c_driver driver = { .name = "ovcamchip", .id = I2C_DRIVERID_OVCAMCHIP, .class = I2C_CLASS_CAM_DIGITAL, - .flags = I2C_DF_NOTIFY, .attach_adapter = ovcamchip_attach, .detach_client = ovcamchip_detach, .command = ovcamchip_command, diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index b8054da..9bf6869 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c @@ -166,7 +166,6 @@ static struct i2c_driver i2c_driver_videotext = .owner = THIS_MODULE, .name = IF_NAME, /* name */ .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ - .flags = I2C_DF_NOTIFY, .attach_adapter = saa5246a_probe, .detach_client = saa5246a_detach, .command = saa5246a_command diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index 7ffa2e9..811e863 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c @@ -239,7 +239,6 @@ static struct i2c_driver i2c_driver_videotext = .owner = THIS_MODULE, .name = IF_NAME, /* name */ .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ - .flags = I2C_DF_NOTIFY, .attach_adapter = saa5249_probe, .detach_client = saa5249_detach, .command = saa5249_command diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c index 9233225..18a0b71 100644 --- a/drivers/media/video/saa6588.c +++ b/drivers/media/video/saa6588.c @@ -498,7 +498,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "i2c saa6588 driver", .id = -1, /* FIXME */ - .flags = I2C_DF_NOTIFY, .attach_adapter = saa6588_probe, .detach_client = saa6588_detach, .command = saa6588_command, diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index e116bdb..f266b35 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c @@ -591,7 +591,6 @@ static struct i2c_driver i2c_driver_saa7110 = { .name = "saa7110", .id = I2C_DRIVERID_SAA7110, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa7110_attach_adapter, .detach_client = saa7110_detach_client, diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index fe8a5e4..687beaf 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -594,7 +594,6 @@ static struct i2c_driver i2c_driver_saa7111 = { .name = "saa7111", .id = I2C_DRIVERID_SAA7111A, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa7111_attach_adapter, .detach_client = saa7111_detach_client, diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index d9f50e2..4748cf0 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c @@ -1208,7 +1208,6 @@ static struct i2c_driver i2c_driver_saa7114 = { .name = "saa7114", .id = I2C_DRIVERID_SAA7114, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa7114_attach_adapter, .detach_client = saa7114_detach_client, diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index e717e30..b1079de 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c @@ -1356,7 +1356,6 @@ static int saa7115_detach(struct i2c_client *client) static struct i2c_driver i2c_driver_saa7115 = { .name = "saa7115", .id = I2C_DRIVERID_SAA711X, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa7115_probe, .detach_client = saa7115_detach, .command = saa7115_command, diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 31f7b95..734a709 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c @@ -569,7 +569,6 @@ static struct i2c_driver i2c_driver_saa711x = { .name = "saa711x", .id = I2C_DRIVERID_SAA711X, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa711x_attach_adapter, .detach_client = saa711x_detach_client, diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index c36f014..a2fab98 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c @@ -821,7 +821,6 @@ static int saa7127_detach(struct i2c_client *client) static struct i2c_driver i2c_driver_saa7127 = { .name = "saa7127", .id = I2C_DRIVERID_SAA7127, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa7127_probe, .detach_client = saa7127_detach, .command = saa7127_command, diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index a61d24f..6fc298e 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c @@ -600,7 +600,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "i2c saa6752hs MPEG encoder", .id = I2C_DRIVERID_SAA6752HS, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa6752hs_probe, .detach_client = saa6752hs_detach, .command = saa6752hs_command, diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 132aa79..e24aa16 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c @@ -491,7 +491,6 @@ static struct i2c_driver i2c_driver_saa7185 = { .name = "saa7185", /* name */ .id = I2C_DRIVERID_SAA7185B, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa7185_attach_adapter, .detach_client = saa7185_detach_client, diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c index cbca896..6be98fc 100644 --- a/drivers/media/video/saa7191.c +++ b/drivers/media/video/saa7191.c @@ -791,7 +791,6 @@ static struct i2c_driver i2c_driver_saa7191 = { .owner = THIS_MODULE, .name = "saa7191", .id = I2C_DRIVERID_SAA7191, - .flags = I2C_DF_NOTIFY, .attach_adapter = saa7191_probe, .detach_client = saa7191_detach, .command = saa7191_command diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index d32737d..239a586 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c @@ -504,7 +504,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "i2c tda7432 driver", .id = I2C_DRIVERID_TDA7432, - .flags = I2C_DF_NOTIFY, .attach_adapter = tda7432_probe, .detach_client = tda7432_detach, .command = tda7432_command, diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index 1794686..f29fb50 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c @@ -224,7 +224,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "tda9840", .id = I2C_DRIVERID_TDA9840, - .flags = I2C_DF_NOTIFY, .attach_adapter = attach, .detach_client = detach, .command = command, diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index a5e37dc..d053b64 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c @@ -375,7 +375,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "i2c tda9875 driver", .id = I2C_DRIVERID_TDA9875, - .flags = I2C_DF_NOTIFY, .attach_adapter = tda9875_probe, .detach_client = tda9875_detach, .command = tda9875_command, diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 2f2414e..049b44e 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -822,7 +822,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "i2c tda9887 driver", .id = -1, /* FIXME */ - .flags = I2C_DF_NOTIFY, .attach_adapter = tda9887_probe, .detach_client = tda9887_detach, .command = tda9887_command, diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index ee36883..96d88ce 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c @@ -193,7 +193,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "tea6415c", .id = I2C_DRIVERID_TEA6415C, - .flags = I2C_DF_NOTIFY, .attach_adapter = attach, .detach_client = detach, .command = command, diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 17975c1..fd417de 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c @@ -170,7 +170,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "tea6420", .id = I2C_DRIVERID_TEA6420, - .flags = I2C_DF_NOTIFY, .attach_adapter = attach, .detach_client = detach, .command = command, diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c index 7920359..3505cec2 100644 --- a/drivers/media/video/tuner-3036.c +++ b/drivers/media/video/tuner-3036.c @@ -178,7 +178,6 @@ i2c_driver_tuner = .owner = THIS_MODULE, .name = "sab3036", .id = I2C_DRIVERID_SAB3036, - .flags = I2C_DF_NOTIFY, .attach_adapter = tuner_probe, .detach_client = tuner_detach, .command = tuner_command diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index e58abdf..3c75121 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -745,7 +745,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "tuner", .id = I2C_DRIVERID_TUNER, - .flags = I2C_DF_NOTIFY, .attach_adapter = tuner_probe, .detach_client = tuner_detach, .command = tuner_command, diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 5b20e81..3565f35 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -1705,7 +1705,6 @@ static struct i2c_driver driver = { .owner = THIS_MODULE, .name = "generic i2c audio driver", .id = I2C_DRIVERID_TVAUDIO, - .flags = I2C_DF_NOTIFY, .attach_adapter = chip_probe, .detach_client = chip_detach, .command = chip_command, diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 5ac2353..195bc51 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -782,7 +782,6 @@ static struct i2c_driver i2c_driver_tveeprom = { .owner = THIS_MODULE, .name = "tveeprom", .id = I2C_DRIVERID_TVEEPROM, - .flags = I2C_DF_NOTIFY, .attach_adapter = tveeprom_attach_adapter, .detach_client = tveeprom_detach_client, .command = tveeprom_command, diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index 5897e5d..936e01d 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -232,7 +232,6 @@ static struct i2c_driver driver = { #endif .name = "tv card mixer driver", .id = I2C_DRIVERID_TVMIXER, - .flags = I2C_DF_NOTIFY, .detach_adapter = tvmixer_adapters, .attach_adapter = tvmixer_adapters, .detach_client = tvmixer_clients, diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index 97431e2..4f3ee20 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c @@ -806,7 +806,6 @@ static struct i2c_driver driver = { /* FIXME */ .id = I2C_DRIVERID_SAA7110, - .flags = I2C_DF_NOTIFY, .attach_adapter = tvp5150_attach_adapter, .detach_client = tvp5150_detach_client, diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index 137b58f..c66d285 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c @@ -726,7 +726,6 @@ static struct i2c_driver vpx3220_i2c_driver = { .name = "vpx3220", .id = I2C_DRIVERID_VPX3220, - .flags = I2C_DF_NOTIFY, .attach_adapter = vpx3220_attach_adapter, .detach_client = vpx3220_detach_client, diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c index a6936ad..7b07717 100644 --- a/drivers/media/video/wm8775.c +++ b/drivers/media/video/wm8775.c @@ -236,7 +236,6 @@ static struct i2c_driver i2c_driver = { .name = "wm8775", .id = I2C_DRIVERID_WM8775, - .flags = I2C_DF_NOTIFY, .attach_adapter = wm8775_probe, .detach_client = wm8775_detach, diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index ad60bbb..78994c5 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c @@ -1296,7 +1296,6 @@ static struct i2c_driver maven_driver={ .owner = THIS_MODULE, .name = "maven", .id = I2C_DRIVERID_MGATVO, - .flags = I2C_DF_NOTIFY, .attach_adapter = maven_attach_adapter, .detach_client = maven_detach_client, .command = maven_command, diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 0316ba1..99399fa 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -251,7 +251,6 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) } /*flags for the driver struct: */ -#define I2C_DF_NOTIFY 0x01 /* notify on bus (de/a)ttaches */ /*flags for the client struct: */ #define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */ diff --git a/sound/oss/dmasound/dac3550a.c b/sound/oss/dmasound/dac3550a.c index 533895e..3402a66 100644 --- a/sound/oss/dmasound/dac3550a.c +++ b/sound/oss/dmasound/dac3550a.c @@ -44,7 +44,6 @@ struct i2c_driver daca_driver = { .owner = THIS_MODULE, .name = "DAC3550A driver V " DACA_VERSION, .id = I2C_DRIVERID_DACA, - .flags = I2C_DF_NOTIFY, .attach_adapter = daca_attach_adapter, .detach_client = daca_detach_client, }; diff --git a/sound/oss/dmasound/tas_common.c b/sound/oss/dmasound/tas_common.c index d36a1fe..7e3d517 100644 --- a/sound/oss/dmasound/tas_common.c +++ b/sound/oss/dmasound/tas_common.c @@ -49,7 +49,6 @@ static int tas_detach_client(struct i2c_client *); struct i2c_driver tas_driver = { .owner = THIS_MODULE, .name = "tas", - .flags = I2C_DF_NOTIFY, .attach_adapter = tas_attach_adapter, .detach_client = tas_detach_client, }; diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index 097fbcf..fd8e2e6 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -43,7 +43,6 @@ static int keywest_detach_client(struct i2c_client *client); struct i2c_driver keywest_driver = { .name = "PMac Keywest Audio", .id = I2C_DRIVERID_KEYWEST, - .flags = I2C_DF_NOTIFY, .attach_adapter = &keywest_attach_adapter, .detach_client = &keywest_detach_client, }; -- cgit v1.1 From 5d7b851dcced3611e4a4432308618b1ed1a9fc31 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 27 Nov 2005 08:57:10 +0100 Subject: [PATCH] i2c: Drop i2c_driver.flags, 3 of 3 The flags member of the i2c_driver structure is no more used. Drop it. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- include/linux/i2c.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 99399fa..3c16a8f 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -112,7 +112,6 @@ struct i2c_driver { char name[32]; int id; unsigned int class; - unsigned int flags; /* div., see below */ /* Notifies the driver that a new bus has appeared. This routine * can be used by the driver to test if the bus meets its conditions @@ -250,8 +249,6 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) dev_set_drvdata (&dev->dev, data); } -/*flags for the driver struct: */ - /*flags for the client struct: */ #define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */ #define I2C_CLIENT_ALLOW_MULTIPLE_USE 0x02 /* Allow multiple access-locks */ -- cgit v1.1 From cb748fb20186d4b345c68a7f580429f379fdd268 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 20:58:35 +0100 Subject: [PATCH] i2c: Rework client usage count, 1 of 3 No i2c client uses the I2C_CLIENT_ALLOW_MULTIPLE_USE flag, drop it. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-core.c | 4 +--- include/linux/i2c.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index ad68ac0..2f0bc95 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -500,9 +500,7 @@ int i2c_use_client(struct i2c_client *client) return ret; if (client->flags & I2C_CLIENT_ALLOW_USE) { - if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) - client->usage_count++; - else if (client->usage_count > 0) + if (client->usage_count > 0) goto busy; else client->usage_count++; diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 3c16a8f..4487c51 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -251,8 +251,6 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) /*flags for the client struct: */ #define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */ -#define I2C_CLIENT_ALLOW_MULTIPLE_USE 0x02 /* Allow multiple access-locks */ - /* on an i2c_client */ #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ #define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */ /* Must equal I2C_M_TEN below */ -- cgit v1.1 From cde7859bda0d1124392b44e50aa11df99707e1d9 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 21:00:54 +0100 Subject: [PATCH] i2c: Rework client usage count, 2 of 3 Make I2C_CLIENT_ALLOW_USE the default for all i2c clients. It doesn't hurt if the usage count is actually never used for any given driver, and allows for nice code simplifications in i2c-core. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-pxa/akita-ioexp.c | 1 - drivers/i2c/chips/rtc8564.c | 1 - drivers/i2c/i2c-core.c | 28 ++++++++++------------------ drivers/media/video/adv7170.c | 1 - drivers/media/video/adv7175.c | 1 - drivers/media/video/bt819.c | 1 - drivers/media/video/bt832.c | 1 - drivers/media/video/bt856.c | 1 - drivers/media/video/cs53l32a.c | 1 - drivers/media/video/cx25840/cx25840-core.c | 1 - drivers/media/video/em28xx/em28xx-i2c.c | 1 - drivers/media/video/msp3400.c | 1 - drivers/media/video/saa6588.c | 1 - drivers/media/video/saa7110.c | 1 - drivers/media/video/saa7111.c | 1 - drivers/media/video/saa7114.c | 1 - drivers/media/video/saa7115.c | 1 - drivers/media/video/saa711x.c | 1 - drivers/media/video/saa7127.c | 1 - drivers/media/video/saa7134/saa6752hs.c | 1 - drivers/media/video/saa7185.c | 1 - drivers/media/video/tda9887.c | 1 - drivers/media/video/tuner-core.c | 1 - drivers/media/video/tvaudio.c | 1 - drivers/media/video/tveeprom.c | 1 - drivers/media/video/tvp5150.c | 1 - drivers/media/video/vpx3220.c | 1 - drivers/media/video/wm8775.c | 1 - include/linux/i2c.h | 1 - 29 files changed, 10 insertions(+), 46 deletions(-) diff --git a/arch/arm/mach-pxa/akita-ioexp.c b/arch/arm/mach-pxa/akita-ioexp.c index 440ebb3..b6bff55 100644 --- a/arch/arm/mach-pxa/akita-ioexp.c +++ b/arch/arm/mach-pxa/akita-ioexp.c @@ -133,7 +133,6 @@ static struct i2c_driver max7310_i2c_driver = { static struct i2c_client max7310_template = { name: "akita-max7310", - flags: I2C_CLIENT_ALLOW_USE, driver: &max7310_i2c_driver, }; diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index e586f75..07494d3 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c @@ -155,7 +155,6 @@ static int rtc8564_attach(struct i2c_adapter *adap, int addr, int kind) strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE); i2c_set_clientdata(new_client, d); - new_client->flags = I2C_CLIENT_ALLOW_USE; new_client->addr = addr; new_client->adapter = adap; new_client->driver = &rtc8564_driver; diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 2f0bc95..d16b499 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -419,8 +419,7 @@ int i2c_attach_client(struct i2c_client *client) } } - if (client->flags & I2C_CLIENT_ALLOW_USE) - client->usage_count = 0; + client->usage_count = 0; client->dev.parent = &client->adapter->dev; client->dev.driver = &client->driver->driver; @@ -443,8 +442,7 @@ int i2c_detach_client(struct i2c_client *client) struct i2c_adapter *adapter = client->adapter; int res = 0; - if ((client->flags & I2C_CLIENT_ALLOW_USE) - && (client->usage_count > 0)) { + if (client->usage_count > 0) { dev_warn(&client->dev, "Client [%s] still busy, " "can't detach\n", client->name); return -EBUSY; @@ -499,12 +497,9 @@ int i2c_use_client(struct i2c_client *client) if (ret) return ret; - if (client->flags & I2C_CLIENT_ALLOW_USE) { - if (client->usage_count > 0) - goto busy; - else - client->usage_count++; - } + if (client->usage_count > 0) + goto busy; + client->usage_count++; return 0; busy: @@ -514,16 +509,13 @@ int i2c_use_client(struct i2c_client *client) int i2c_release_client(struct i2c_client *client) { - if(client->flags & I2C_CLIENT_ALLOW_USE) { - if(client->usage_count>0) - client->usage_count--; - else { - pr_debug("i2c-core: %s used one too many times\n", - __FUNCTION__); - return -EPERM; - } + if (!client->usage_count) { + pr_debug("i2c-core: %s used one too many times\n", + __FUNCTION__); + return -EPERM; } + client->usage_count--; i2c_dec_use_client(client); return 0; diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index c4f2265..622b161 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c @@ -420,7 +420,6 @@ adv7170_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_adv7170; - client->flags = I2C_CLIENT_ALLOW_USE; if ((client->addr == I2C_ADV7170 >> 1) || (client->addr == (I2C_ADV7170 >> 1) + 1)) { dname = adv7170_name; diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 4fc08b1..d4859b4 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -470,7 +470,6 @@ adv7175_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_adv7175; - client->flags = I2C_CLIENT_ALLOW_USE; if ((client->addr == I2C_ADV7175 >> 1) || (client->addr == (I2C_ADV7175 >> 1) + 1)) { dname = adv7175_name; diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index 7bba697..741e59a 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c @@ -535,7 +535,6 @@ bt819_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_bt819; - client->flags = I2C_CLIENT_ALLOW_USE; decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL); if (decoder == NULL) { diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index 0ba8652..4ed13860 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c @@ -240,7 +240,6 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { .name = "bt832", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 4c9acd1..d4bba8e 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c @@ -323,7 +323,6 @@ bt856_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_bt856; - client->flags = I2C_CLIENT_ALLOW_USE; strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client))); encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL); diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c index fce5d89..f442ce3 100644 --- a/drivers/media/video/cs53l32a.c +++ b/drivers/media/video/cs53l32a.c @@ -154,7 +154,6 @@ static int cs53l32a_attach(struct i2c_adapter *adapter, int address, int kind) client->addr = address; client->adapter = adapter; client->driver = &i2c_driver; - client->flags = I2C_CLIENT_ALLOW_USE; snprintf(client->name, sizeof(client->name) - 1, "cs53l32a"); cs53l32a_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name); diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index c66bc14..0b278ab 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c @@ -773,7 +773,6 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_cx25840; - client->flags = I2C_CLIENT_ALLOW_USE; snprintf(client->name, sizeof(client->name) - 1, "cx25840"); cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1); diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c index 7f56030..d14bcf4 100644 --- a/drivers/media/video/em28xx/em28xx-i2c.c +++ b/drivers/media/video/em28xx/em28xx-i2c.c @@ -497,7 +497,6 @@ static struct i2c_adapter em28xx_adap_template = { static struct i2c_client em28xx_client_template = { .name = "em28xx internal", - .flags = I2C_CLIENT_ALLOW_USE, }; /* ----------------------------------------------------------- */ diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 46328fb..c5e8ad3 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -1576,7 +1576,6 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { .name = "(unset)", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c index 18a0b71..3d4076c 100644 --- a/drivers/media/video/saa6588.c +++ b/drivers/media/video/saa6588.c @@ -505,7 +505,6 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { .name = "saa6588", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index f266b35..8affa63 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c @@ -501,7 +501,6 @@ saa7110_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_saa7110; - client->flags = I2C_CLIENT_ALLOW_USE; strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client))); decoder = kmalloc(sizeof(struct saa7110), GFP_KERNEL); diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 687beaf..2b22045 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -518,7 +518,6 @@ saa7111_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_saa7111; - client->flags = I2C_CLIENT_ALLOW_USE; strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client))); decoder = kmalloc(sizeof(struct saa7111), GFP_KERNEL); diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index 4748cf0..285f6c7 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c @@ -859,7 +859,6 @@ saa7114_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_saa7114; - client->flags = I2C_CLIENT_ALLOW_USE; strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client))); decoder = kmalloc(sizeof(struct saa7114), GFP_KERNEL); diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index b1079de..79aadd2 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c @@ -1270,7 +1270,6 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind) client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_saa7115; - client->flags = I2C_CLIENT_ALLOW_USE; snprintf(client->name, sizeof(client->name) - 1, "saa7115"); saa7115_dbg("detecting saa7115 client on address 0x%x\n", address << 1); diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 734a709..44bfc04 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c @@ -494,7 +494,6 @@ saa711x_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_saa711x; - client->flags = I2C_CLIENT_ALLOW_USE; strlcpy(I2C_NAME(client), "saa711x", sizeof(I2C_NAME(client))); decoder = kmalloc(sizeof(struct saa711x), GFP_KERNEL); if (decoder == NULL) { diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index a2fab98..1f4b415 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c @@ -719,7 +719,6 @@ static int saa7127_attach(struct i2c_adapter *adapter, int address, int kind) client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_saa7127; - client->flags = I2C_CLIENT_ALLOW_USE; snprintf(client->name, sizeof(client->name) - 1, "saa7127"); saa7127_dbg("detecting saa7127 client on address 0x%x\n", address << 1); diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 6fc298e..6820606 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c @@ -608,7 +608,6 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { .name = "saa6752hs", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index e24aa16..9f37585 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c @@ -415,7 +415,6 @@ saa7185_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_saa7185; - client->flags = I2C_CLIENT_ALLOW_USE; strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client))); encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL); diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 049b44e..324f61b 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -833,7 +833,6 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { .name = "tda9887", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 3c75121..6328f09 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -755,7 +755,6 @@ static struct i2c_driver driver = { }; static struct i2c_client client_template = { .name = "(tuner unset)", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 3565f35..4f1f339 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -1713,7 +1713,6 @@ static struct i2c_driver driver = { static struct i2c_client client_template = { .name = "(unset)", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index 195bc51..d833b65 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -751,7 +751,6 @@ tveeprom_detect_client(struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &i2c_driver_tveeprom; - client->flags = I2C_CLIENT_ALLOW_USE; snprintf(client->name, sizeof(client->name), "tveeprom"); i2c_attach_client(client); diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index 4f3ee20..3734554 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c @@ -714,7 +714,6 @@ static struct i2c_driver driver; static struct i2c_client client_template = { .name = "(unset)", - .flags = I2C_CLIENT_ALLOW_USE, .driver = &driver, }; diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index c66d285..54bc888 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c @@ -631,7 +631,6 @@ vpx3220_detect_client (struct i2c_adapter *adapter, client->addr = address; client->adapter = adapter; client->driver = &vpx3220_i2c_driver; - client->flags = I2C_CLIENT_ALLOW_USE; /* Check for manufacture ID and part number */ if (kind < 0) { diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c index 7b07717..527c2591 100644 --- a/drivers/media/video/wm8775.c +++ b/drivers/media/video/wm8775.c @@ -168,7 +168,6 @@ static int wm8775_attach(struct i2c_adapter *adapter, int address, int kind) client->addr = address; client->adapter = adapter; client->driver = &i2c_driver; - client->flags = I2C_CLIENT_ALLOW_USE; snprintf(client->name, sizeof(client->name) - 1, "wm8775"); wm8775_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 4487c51..8b4d469 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -250,7 +250,6 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) } /*flags for the client struct: */ -#define I2C_CLIENT_ALLOW_USE 0x01 /* Client allows access */ #define I2C_CLIENT_PEC 0x04 /* Use Packet Error Checking */ #define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */ /* Must equal I2C_M_TEN below */ -- cgit v1.1 From cf02df770228350254251fde520007a2709db785 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 21:03:41 +0100 Subject: [PATCH] i2c: Rework client usage count, 3 of 3 Do not limit the usage count of i2c clients to 1. In other words, change the client usage count behavior from the old I2C_CLIENT_ALLOW_USE to the old I2C_CLIENT_ALLOW_MULTIPLE_USE. The rationale is that no driver actually needs the limiting behavior, and the unlimiting behavior is slightly easier to implement. Update the documentation to reflect this change. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/porting-clients | 1 + drivers/i2c/i2c-core.c | 5 ----- include/linux/i2c.h | 4 +--- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 64c610b..6b07f23 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -92,6 +92,7 @@ Technical changes: Drop client->id. Drop any 24RF08 corruption prevention you find, as this is now done at the i2c-core level, and doing it twice voids it. + Don't add I2C_CLIENT_ALLOW_USE to client->flags, it's the default now. * [Init] Limits must not be set by the driver (can be done later in user-space). Chip should not be reset default (although a module diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index d16b499..a1c5dff 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -497,14 +497,9 @@ int i2c_use_client(struct i2c_client *client) if (ret) return ret; - if (client->usage_count > 0) - goto busy; client->usage_count++; return 0; - busy: - i2c_dec_use_client(client); - return -EBUSY; } int i2c_release_client(struct i2c_client *client) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 8b4d469..85c517a 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -307,9 +307,7 @@ extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id, extern struct i2c_client *i2c_get_client(int,int,struct i2c_client *); to make sure that client-struct is valid and that it is okay to access the i2c-client. - returns -EACCES if client doesn't allow use (default) - returns -EBUSY if client doesn't allow multiple use (default) and - usage_count >0 */ + returns -ENODEV if client has gone in the meantime */ extern int i2c_use_client(struct i2c_client *); extern int i2c_release_client(struct i2c_client *); -- cgit v1.1 From 92b429461228f0f06a994dd3d4ccf1c9ff7596bd Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 21:05:17 +0100 Subject: [PATCH] i2c: Chip driver porting guide update Update Documentation/i2c/porting-clients. Many recent changes to the i2c and hwmon subsystems were never reported there. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/porting-clients | 79 ++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 35 deletions(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 6b07f23..856274f 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -1,10 +1,13 @@ -Revision 5, 2005-07-29 +Revision 6, 2005-11-20 Jean Delvare Greg KH This is a guide on how to convert I2C chip drivers from Linux 2.4 to Linux 2.6. I have been using existing drivers (lm75, lm78) as examples. Then I converted a driver myself (lm83) and updated this document. +Note that this guide is strongly oriented towards hardware monitoring +drivers. Many points are still valid for other type of drivers, but +others may be irrelevant. There are two sets of points below. The first set concerns technical changes. The second set concerns coding policy. Both are mandatory. @@ -22,16 +25,20 @@ Technical changes: #include #include #include + #include #include + #include /* for ISA drivers */ #include /* for hardware monitoring drivers */ #include #include /* if you need VRM support */ + #include /* for class registration */ #include /* if you have I/O operations */ Please respect this inclusion order. Some extra headers may be required for a given driver (e.g. "lm75.h"). * [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses - are no more handled by the i2c core. + are no more handled by the i2c core. Address ranges are no more + supported either, define each individual address separately. SENSORS_INSMOD_ becomes I2C_CLIENT_INSMOD_. * [Client data] Get rid of sysctl_id. Try using standard names for @@ -48,23 +55,23 @@ Technical changes: int kind); static void lm75_init_client(struct i2c_client *client); static int lm75_detach_client(struct i2c_client *client); - static void lm75_update_client(struct i2c_client *client); + static struct lm75_data lm75_update_device(struct device *dev); * [Sysctl] All sysctl stuff is of course gone (defines, ctl_table and functions). Instead, you have to define show and set functions for each sysfs file. Only define set for writable values. Take a look at an - existing 2.6 driver for details (lm78 for example). Don't forget + existing 2.6 driver for details (it87 for example). Don't forget to define the attributes for each file (this is that step that links callback functions). Use the file names specified in - Documentation/i2c/sysfs-interface for the individual files. Also + Documentation/hwmon/sysfs-interface for the individual files. Also convert the units these files read and write to the specified ones. If you need to add a new type of file, please discuss it on the sensors mailing list by providing a - patch to the Documentation/i2c/sysfs-interface file. + patch to the Documentation/hwmon/sysfs-interface file. * [Attach] For I2C drivers, the attach function should make sure - that the adapter's class has I2C_CLASS_HWMON, using the - following construct: + that the adapter's class has I2C_CLASS_HWMON (or whatever class is + suitable for your driver), using the following construct: if (!(adapter->class & I2C_CLASS_HWMON)) return 0; ISA-only drivers of course don't need this. @@ -72,23 +79,23 @@ Technical changes: * [Detect] As mentioned earlier, the flags parameter is gone. The type_name and client_name strings are replaced by a single - name string, which will be filled with a lowercase, short string - (typically the driver name, e.g. "lm75"). + name string, which will be filled with a lowercase, short string. In i2c-only drivers, drop the i2c_is_isa_adapter check, it's useless. Same for isa-only drivers, as the test would always be true. Only hybrid drivers (which are quite rare) still need it. - The errorN labels are reduced to the number needed. If that number - is 2 (i2c-only drivers), it is advised that the labels are named - exit and exit_free. For i2c+isa drivers, labels should be named - ERROR0, ERROR1 and ERROR2. Don't forget to properly set err before + The labels used for error paths are reduced to the number needed. + It is advised that the labels are given descriptive names such as + exit and exit_free. Don't forget to properly set err before jumping to error labels. By the way, labels should be left-aligned. Use kzalloc instead of kmalloc. Use i2c_set_clientdata to set the client data (as opposed to a direct access to client->data). - Use strlcpy instead of strcpy to copy the client name. + Use strlcpy instead of strcpy or snprintf to copy the client name. Replace the sysctl directory registration by calls to device_create_file. Move the driver initialization before any sysfs file creation. + Register the client with the hwmon class (using hwmon_device_register) + if applicable. Drop client->id. Drop any 24RF08 corruption prevention you find, as this is now done at the i2c-core level, and doing it twice voids it. @@ -96,19 +103,25 @@ Technical changes: * [Init] Limits must not be set by the driver (can be done later in user-space). Chip should not be reset default (although a module - parameter may be used to force is), and initialization should be + parameter may be used to force it), and initialization should be limited to the strictly necessary steps. -* [Detach] Get rid of data, remove the call to - i2c_deregister_entry. Do not log an error message if - i2c_detach_client fails, as i2c-core will now do it for you. +* [Detach] Remove the call to i2c_deregister_entry. Do not log an + error message if i2c_detach_client fails, as i2c-core will now do + it for you. + Unregister from the hwmon class if applicable. -* [Update] Don't access client->data directly, use - i2c_get_clientdata(client) instead. +* [Update] The function prototype changed, it is now + passed a device structure, which you have to convert to a client + using to_i2c_client(dev). The update function should return a + pointer to the client data. + Don't access client->data directly, use i2c_get_clientdata(client) + instead. + Use time_after() instead of direct jiffies comparison. -* [Interface] Init function should not print anything. Make sure - there is a MODULE_LICENSE() line, at the bottom of the file - (after MODULE_AUTHOR() and MODULE_DESCRIPTION(), in this order). +* [Interface] Make sure there is a MODULE_LICENSE() line, at the bottom + of the file (after MODULE_AUTHOR() and MODULE_DESCRIPTION(), in this + order). * [Driver] The flags field of the i2c_driver structure is gone. I2C_DF_NOTIFY is now the default behavior. @@ -118,21 +131,17 @@ Coding policy: * [Copyright] Use (C), not (c), for copyright. * [Debug/log] Get rid of #ifdef DEBUG/#endif constructs whenever you - can. Calls to printk/pr_debug for debugging purposes are replaced - by calls to dev_dbg. Here is an example on how to call it (taken - from lm75_detect): + can. Calls to printk for debugging purposes are replaced by calls to + dev_dbg where possible, else to pr_debug. Here is an example of how + to call it (taken from lm75_detect): dev_dbg(&client->dev, "Starting lm75 update\n"); Replace other printk calls with the dev_info, dev_err or dev_warn function, as appropriate. -* [Constants] Constants defines (registers, conversions, initial - values) should be aligned. This greatly improves readability. - Same goes for variables declarations. Alignments are achieved by the - means of tabs, not spaces. Remember that tabs are set to 8 in the - Linux kernel code. - -* [Structure definition] The name field should be standardized. All - lowercase and as simple as the driver name itself (e.g. "lm75"). +* [Constants] Constants defines (registers, conversions) should be + aligned. This greatly improves readability. + Alignments are achieved by the means of tabs, not spaces. Remember + that tabs are set to 8 in the Linux kernel code. * [Layout] Avoid extra empty lines between comments and what they comment. Respect the coding style (see Documentation/CodingStyle), -- cgit v1.1 From 482c788ded0aa9710722eaf9cf60886d3b923218 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 21:06:08 +0100 Subject: [PATCH] i2c: i2c_get_client is gone The i2c_get_client function doesn't exist anymore, so we shouldn't have a definition for it in i2c.h. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- include/linux/i2c.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 85c517a..a9cea62 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -296,17 +296,8 @@ extern int i2c_del_driver(struct i2c_driver *); extern int i2c_attach_client(struct i2c_client *); extern int i2c_detach_client(struct i2c_client *); -/* New function: This is to get an i2c_client-struct for controlling the - client either by using i2c_control-function or having the - client-module export functions that can be used with the i2c_client - -struct. */ -extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id, - struct i2c_client *prev); - -/* Should be used with new function - extern struct i2c_client *i2c_get_client(int,int,struct i2c_client *); - to make sure that client-struct is valid and that it is okay to access - the i2c-client. +/* Should be used to make sure that client-struct is valid and that it + is okay to access the i2c-client. returns -ENODEV if client has gone in the meantime */ extern int i2c_use_client(struct i2c_client *); extern int i2c_release_client(struct i2c_client *); -- cgit v1.1 From 35d8b2e6b8e86b0d5126f36613b5202d4eb978b6 Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:34:05 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 1 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the core of the i2c drivers: it removes .name and .owner fields from the struct i2c_device and modify various functions to use struct device fields instead. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-isa.c | 4 +--- drivers/i2c/i2c-core.c | 22 +++++++++++----------- drivers/i2c/i2c-dev.c | 6 ++++-- include/linux/i2c.h | 5 +++-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 03672c9..9f93fb8 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c @@ -92,8 +92,6 @@ int i2c_isa_add_driver(struct i2c_driver *driver) int res; /* Add the driver to the list of i2c drivers in the driver core */ - driver->driver.name = driver->name; - driver->driver.owner = driver->owner; driver->driver.bus = &i2c_bus_type; driver->driver.probe = i2c_isa_device_probe; driver->driver.remove = i2c_isa_device_remove; @@ -124,7 +122,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver) if ((res = driver->detach_client(client))) { dev_err(&isa_adapter.dev, "Failed, driver " "%s not unregistered!\n", - driver->name); + driver->driver.name); return res; } } diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index a1c5dff..4ce5f0f 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -235,7 +235,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) if (driver->detach_adapter) if ((res = driver->detach_adapter(adap))) { dev_err(&adap->dev, "detach_adapter failed " - "for driver [%s]\n", driver->name); + "for driver [%s]\n", + driver->driver.name); goto out_unlock; } } @@ -295,8 +296,6 @@ int i2c_add_driver(struct i2c_driver *driver) down(&core_lists); /* add the driver to the list of i2c drivers in the driver core */ - driver->driver.owner = driver->owner; - driver->driver.name = driver->name; driver->driver.bus = &i2c_bus_type; driver->driver.probe = i2c_device_probe; driver->driver.remove = i2c_device_remove; @@ -306,7 +305,7 @@ int i2c_add_driver(struct i2c_driver *driver) goto out_unlock; list_add_tail(&driver->list,&drivers); - pr_debug("i2c-core: driver [%s] registered\n", driver->name); + pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); /* now look for instances of driver on our adapters */ if (driver->attach_adapter) { @@ -344,7 +343,8 @@ int i2c_del_driver(struct i2c_driver *driver) if (driver->detach_adapter) { if ((res = driver->detach_adapter(adap))) { dev_err(&adap->dev, "detach_adapter failed " - "for driver [%s]\n", driver->name); + "for driver [%s]\n", + driver->driver.name); goto out_unlock; } } else { @@ -368,7 +368,7 @@ int i2c_del_driver(struct i2c_driver *driver) driver_unregister(&driver->driver); list_del(&driver->list); - pr_debug("i2c-core: driver [%s] unregistered\n", driver->name); + pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); out_unlock: up(&core_lists); @@ -473,10 +473,10 @@ int i2c_detach_client(struct i2c_client *client) static int i2c_inc_use_client(struct i2c_client *client) { - if (!try_module_get(client->driver->owner)) + if (!try_module_get(client->driver->driver.owner)) return -ENODEV; if (!try_module_get(client->adapter->owner)) { - module_put(client->driver->owner); + module_put(client->driver->driver.owner); return -ENODEV; } @@ -485,7 +485,7 @@ static int i2c_inc_use_client(struct i2c_client *client) static void i2c_dec_use_client(struct i2c_client *client) { - module_put(client->driver->owner); + module_put(client->driver->driver.owner); module_put(client->adapter->owner); } @@ -524,14 +524,14 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg) down(&adap->clist_lock); list_for_each(item,&adap->clients) { client = list_entry(item, struct i2c_client, list); - if (!try_module_get(client->driver->owner)) + if (!try_module_get(client->driver->driver.owner)) continue; if (NULL != client->driver->command) { up(&adap->clist_lock); client->driver->command(client,cmd,arg); down(&adap->clist_lock); } - module_put(client->driver->owner); + module_put(client->driver->driver.owner); } up(&adap->clist_lock); } diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 9da51eb..9715217 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -481,8 +481,10 @@ static int i2cdev_command(struct i2c_client *client, unsigned int cmd, } static struct i2c_driver i2cdev_driver = { - .owner = THIS_MODULE, - .name = "dev_driver", + .driver = { + .owner = THIS_MODULE, + .name = "dev_driver", + }, .id = I2C_DRIVERID_I2CDEV, .attach_adapter = i2cdev_attach_adapter, .detach_adapter = i2cdev_detach_adapter, diff --git a/include/linux/i2c.h b/include/linux/i2c.h index a9cea62..75aa18e 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -105,11 +105,12 @@ extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, * A driver is capable of handling one or more physical devices present on * I2C adapters. This information is used to inform the driver of adapter * events. + * + * The driver.owner field should be set to the module owner of this driver. + * The driver.name field should be set to the name of this driver. */ struct i2c_driver { - struct module *owner; - char name[32]; int id; unsigned int class; -- cgit v1.1 From a9718b0c1154dcbd955be6aaee47a314cde6a25a Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:36:00 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 2 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the miscellaneaous i2c chip drivers. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/ds1337.c | 6 ++++-- drivers/i2c/chips/ds1374.c | 6 ++++-- drivers/i2c/chips/eeprom.c | 6 ++++-- drivers/i2c/chips/isp1301_omap.c | 6 ++++-- drivers/i2c/chips/m41t00.c | 6 ++++-- drivers/i2c/chips/max6875.c | 6 ++++-- drivers/i2c/chips/pca9539.c | 6 ++++-- drivers/i2c/chips/pcf8574.c | 6 ++++-- drivers/i2c/chips/pcf8591.c | 6 ++++-- drivers/i2c/chips/rtc8564.c | 6 ++++-- drivers/i2c/chips/tps65010.c | 6 ++++-- drivers/i2c/chips/x1205.c | 6 ++++-- 12 files changed, 48 insertions(+), 24 deletions(-) diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index 65146cb..a9d4ac7 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -52,8 +52,10 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, * Driver data (common to all clients) */ static struct i2c_driver ds1337_driver = { - .owner = THIS_MODULE, - .name = "ds1337", + .driver = { + .owner = THIS_MODULE, + .name = "ds1337", + }, .attach_adapter = ds1337_attach_adapter, .detach_client = ds1337_detach_client, .command = ds1337_command, diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 5a270d6..3e3ebd8 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -232,8 +232,10 @@ static int ds1374_detach(struct i2c_client *client) } static struct i2c_driver ds1374_driver = { - .owner = THIS_MODULE, - .name = DS1374_DRV_NAME, + .driver = { + .owner = THIS_MODULE, + .name = DS1374_DRV_NAME, + }, .id = I2C_DRIVERID_DS1374, .attach_adapter = ds1374_attach, .detach_client = ds1374_detach, diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index 9bb1f8b..d0c9f29 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -68,8 +68,10 @@ static int eeprom_detach_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver eeprom_driver = { - .owner = THIS_MODULE, - .name = "eeprom", + .driver = { + .owner = THIS_MODULE, + .name = "eeprom", + }, .id = I2C_DRIVERID_EEPROM, .attach_adapter = eeprom_attach_adapter, .detach_client = eeprom_detach_client, diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 4f472ba..9f1ec03 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c @@ -1632,8 +1632,10 @@ static int isp1301_scan_bus(struct i2c_adapter *bus) } static struct i2c_driver isp1301_driver = { - .owner = THIS_MODULE, - .name = "isp1301_omap", + .driver = { + .owner = THIS_MODULE, + .name = "isp1301_omap", + }, .id = 1301, /* FIXME "official", i2c-ids.h */ .class = I2C_CLASS_HWMON, .attach_adapter = isp1301_scan_bus, diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 13e6783..92759b2 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -211,8 +211,10 @@ m41t00_detach(struct i2c_client *client) } static struct i2c_driver m41t00_driver = { - .owner = THIS_MODULE, - .name = M41T00_DRV_NAME, + .driver = { + .owner = THIS_MODULE, + .name = M41T00_DRV_NAME, + }, .id = I2C_DRIVERID_STM41T00, .attach_adapter = m41t00_attach, .detach_client = m41t00_detach, diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 7e61019..3705117 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -67,8 +67,10 @@ static int max6875_detach_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver max6875_driver = { - .owner = THIS_MODULE, - .name = "max6875", + .driver = { + .owner = THIS_MODULE, + .name = "max6875", + }, .attach_adapter = max6875_attach_adapter, .detach_client = max6875_detach_client, }; diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index 26feb7a..bb57faa 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c @@ -38,8 +38,10 @@ static int pca9539_detach_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver pca9539_driver = { - .owner = THIS_MODULE, - .name = "pca9539", + .driver = { + .owner = THIS_MODULE, + .name = "pca9539", + }, .attach_adapter = pca9539_attach_adapter, .detach_client = pca9539_detach_client, }; diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 2fae640..3d4d4d6 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -65,8 +65,10 @@ static void pcf8574_init_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver pcf8574_driver = { - .owner = THIS_MODULE, - .name = "pcf8574", + .driver = { + .owner = THIS_MODULE, + .name = "pcf8574", + }, .id = I2C_DRIVERID_PCF8574, .attach_adapter = pcf8574_attach_adapter, .detach_client = pcf8574_detach_client, diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 8750f71..8f41bb3 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c @@ -88,8 +88,10 @@ static int pcf8591_read_channel(struct device *dev, int channel); /* This is the driver that will be inserted */ static struct i2c_driver pcf8591_driver = { - .owner = THIS_MODULE, - .name = "pcf8591", + .driver = { + .owner = THIS_MODULE, + .name = "pcf8591", + }, .id = I2C_DRIVERID_PCF8591, .attach_adapter = pcf8591_attach_adapter, .detach_client = pcf8591_detach_client, diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 07494d3..6f567e2 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c @@ -358,8 +358,10 @@ rtc8564_command(struct i2c_client *client, unsigned int cmd, void *arg) } static struct i2c_driver rtc8564_driver = { - .owner = THIS_MODULE, - .name = "RTC8564", + .driver = { + .owner = THIS_MODULE, + .name = "RTC8564", + }, .id = I2C_DRIVERID_RTC8564, .attach_adapter = rtc8564_probe, .detach_client = rtc8564_detach, diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 439bf6c..92947a6 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c @@ -637,8 +637,10 @@ static int __init tps65010_scan_bus(struct i2c_adapter *bus) } static struct i2c_driver tps65010_driver = { - .owner = THIS_MODULE, - .name = "tps65010", + .driver = { + .owner = THIS_MODULE, + .name = "tps65010", + }, .attach_adapter = tps65010_scan_bus, .detach_client = __exit_p(tps65010_detach_client), }; diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c index c5ff2ce..6880eab 100644 --- a/drivers/i2c/chips/x1205.c +++ b/drivers/i2c/chips/x1205.c @@ -105,8 +105,10 @@ static int x1205_command(struct i2c_client *client, unsigned int cmd, void *arg); static struct i2c_driver x1205_driver = { - .owner = THIS_MODULE, - .name = "x1205", + .driver = { + .owner = THIS_MODULE, + .name = "x1205", + }, .attach_adapter = &x1205_attach, .detach_client = &x1205_detach, }; -- cgit v1.1 From cdaf79349c7d24e1d33acb6497849c9e956a33ea Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:37:41 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 3 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the hwmon drivers. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/adm1021.c | 6 ++++-- drivers/hwmon/adm1025.c | 6 ++++-- drivers/hwmon/adm1026.c | 6 ++++-- drivers/hwmon/adm1031.c | 6 ++++-- drivers/hwmon/adm9240.c | 6 ++++-- drivers/hwmon/asb100.c | 6 ++++-- drivers/hwmon/atxp1.c | 6 ++++-- drivers/hwmon/ds1621.c | 6 ++++-- drivers/hwmon/fscher.c | 6 ++++-- drivers/hwmon/fscpos.c | 6 ++++-- drivers/hwmon/gl518sm.c | 6 ++++-- drivers/hwmon/gl520sm.c | 6 ++++-- drivers/hwmon/it87.c | 15 ++++++++++----- drivers/hwmon/lm63.c | 6 ++++-- drivers/hwmon/lm75.c | 6 ++++-- drivers/hwmon/lm77.c | 6 ++++-- drivers/hwmon/lm78.c | 14 +++++++++----- drivers/hwmon/lm80.c | 6 ++++-- drivers/hwmon/lm83.c | 6 ++++-- drivers/hwmon/lm85.c | 6 ++++-- drivers/hwmon/lm87.c | 6 ++++-- drivers/hwmon/lm90.c | 6 ++++-- drivers/hwmon/lm92.c | 6 ++++-- drivers/hwmon/max1619.c | 6 ++++-- drivers/hwmon/pc87360.c | 8 +++++--- drivers/hwmon/sis5595.c | 9 ++++++--- drivers/hwmon/smsc47b397.c | 9 ++++++--- drivers/hwmon/smsc47m1.c | 8 +++++--- drivers/hwmon/via686a.c | 9 ++++++--- drivers/hwmon/vt8231.c | 6 ++++-- drivers/hwmon/w83627ehf.c | 8 +++++--- drivers/hwmon/w83627hf.c | 8 +++++--- drivers/hwmon/w83781d.c | 14 +++++++++----- drivers/hwmon/w83792d.c | 6 ++++-- drivers/hwmon/w83l785ts.c | 6 ++++-- 35 files changed, 166 insertions(+), 86 deletions(-) diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 5e6df4b..679cb92 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -126,8 +126,10 @@ static int read_only; /* This is the driver that will be inserted */ static struct i2c_driver adm1021_driver = { - .owner = THIS_MODULE, - .name = "adm1021", + .driver = { + .owner = THIS_MODULE, + .name = "adm1021", + }, .id = I2C_DRIVERID_ADM1021, .attach_adapter = adm1021_attach_adapter, .detach_client = adm1021_detach_client, diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 2be48a7..3c70622 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -118,8 +118,10 @@ static struct adm1025_data *adm1025_update_device(struct device *dev); */ static struct i2c_driver adm1025_driver = { - .owner = THIS_MODULE, - .name = "adm1025", + .driver = { + .owner = THIS_MODULE, + .name = "adm1025", + }, .id = I2C_DRIVERID_ADM1025, .attach_adapter = adm1025_attach_adapter, .detach_client = adm1025_detach_client, diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 5416db8..92fac34 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -308,8 +308,10 @@ static void adm1026_init_client(struct i2c_client *client); static struct i2c_driver adm1026_driver = { - .owner = THIS_MODULE, - .name = "adm1026", + .driver = { + .owner = THIS_MODULE, + .name = "adm1026", + }, .attach_adapter = adm1026_attach_adapter, .detach_client = adm1026_detach_client, }; diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index 1e244280..e42d75e 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c @@ -105,8 +105,10 @@ static struct adm1031_data *adm1031_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver adm1031_driver = { - .owner = THIS_MODULE, - .name = "adm1031", + .driver = { + .owner = THIS_MODULE, + .name = "adm1031", + }, .attach_adapter = adm1031_attach_adapter, .detach_client = adm1031_detach_client, }; diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index 287733f..e60309e 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -137,8 +137,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev); /* driver data */ static struct i2c_driver adm9240_driver = { - .owner = THIS_MODULE, - .name = "adm9240", + .driver = { + .owner = THIS_MODULE, + .name = "adm9240", + }, .id = I2C_DRIVERID_ADM9240, .attach_adapter = adm9240_attach_adapter, .detach_client = adm9240_detach_client, diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 7227f80..3068de0 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -217,8 +217,10 @@ static struct asb100_data *asb100_update_device(struct device *dev); static void asb100_init_client(struct i2c_client *client); static struct i2c_driver asb100_driver = { - .owner = THIS_MODULE, - .name = "asb100", + .driver = { + .owner = THIS_MODULE, + .name = "asb100", + }, .id = I2C_DRIVERID_ASB100, .attach_adapter = asb100_attach_adapter, .detach_client = asb100_detach_client, diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index a60a9f2..ed152d9 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -50,8 +50,10 @@ static struct atxp1_data * atxp1_update_device(struct device *dev); static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); static struct i2c_driver atxp1_driver = { - .owner = THIS_MODULE, - .name = "atxp1", + .driver = { + .owner = THIS_MODULE, + .name = "atxp1", + }, .attach_adapter = atxp1_attach_adapter, .detach_client = atxp1_detach_client, }; diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 0096eb3..8600940 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -89,8 +89,10 @@ static struct ds1621_data *ds1621_update_client(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver ds1621_driver = { - .owner = THIS_MODULE, - .name = "ds1621", + .driver = { + .owner = THIS_MODULE, + .name = "ds1621", + }, .id = I2C_DRIVERID_DS1621, .attach_adapter = ds1621_attach_adapter, .detach_client = ds1621_detach_client, diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index f56ca06..982fff4 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -118,8 +118,10 @@ static int fscher_write_value(struct i2c_client *client, u8 reg, u8 value); */ static struct i2c_driver fscher_driver = { - .owner = THIS_MODULE, - .name = "fscher", + .driver = { + .owner = THIS_MODULE, + .name = "fscher", + }, .id = I2C_DRIVERID_FSCHER, .attach_adapter = fscher_attach_adapter, .detach_client = fscher_detach_client, diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 701dffc..971146b 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -100,8 +100,10 @@ static void reset_fan_alarm(struct i2c_client *client, int nr); * Driver data (common to all clients) */ static struct i2c_driver fscpos_driver = { - .owner = THIS_MODULE, - .name = "fscpos", + .driver = { + .owner = THIS_MODULE, + .name = "fscpos", + }, .id = I2C_DRIVERID_FSCPOS, .attach_adapter = fscpos_attach_adapter, .detach_client = fscpos_detach_client, diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 5788bbb..9c5ca1f 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -151,8 +151,10 @@ static struct gl518_data *gl518_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver gl518_driver = { - .owner = THIS_MODULE, - .name = "gl518sm", + .driver = { + .owner = THIS_MODULE, + .name = "gl518sm", + }, .id = I2C_DRIVERID_GL518, .attach_adapter = gl518_attach_adapter, .detach_client = gl518_detach_client, diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index b399816..a9a724a 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -109,8 +109,10 @@ static struct gl520_data *gl520_update_device(struct device *dev); /* Driver data */ static struct i2c_driver gl520_driver = { - .owner = THIS_MODULE, - .name = "gl520sm", + .driver = { + .owner = THIS_MODULE, + .name = "gl520sm", + }, .id = I2C_DRIVERID_GL520, .attach_adapter = gl520_attach_adapter, .detach_client = gl520_detach_client, diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index d5f0d92..24d520b 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -234,16 +234,20 @@ static void it87_init_client(struct i2c_client *client, struct it87_data *data); static struct i2c_driver it87_driver = { - .owner = THIS_MODULE, - .name = "it87", + .driver = { + .owner = THIS_MODULE, + .name = "it87", + }, .id = I2C_DRIVERID_IT87, .attach_adapter = it87_attach_adapter, .detach_client = it87_detach_client, }; static struct i2c_driver it87_isa_driver = { - .owner = THIS_MODULE, - .name = "it87-isa", + .driver = { + .owner = THIS_MODULE, + .name = "it87-isa", + }, .attach_adapter = it87_isa_attach_adapter, .detach_client = it87_detach_client, }; @@ -760,7 +764,8 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind) /* Reserve the ISA region */ if (is_isa) - if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) + if (!request_region(address, IT87_EXTENT, + it87_isa_driver.driver.name)) goto ERROR0; /* For now, we presume we have a valid client. We create the diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index c2dd4ac..35baae7 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -139,8 +139,10 @@ static void lm63_init_client(struct i2c_client *client); */ static struct i2c_driver lm63_driver = { - .owner = THIS_MODULE, - .name = "lm63", + .driver = { + .owner = THIS_MODULE, + .name = "lm63", + }, .attach_adapter = lm63_attach_adapter, .detach_client = lm63_detach_client, }; diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index 0bcbd65..db35fbf 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -66,8 +66,10 @@ static struct lm75_data *lm75_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver lm75_driver = { - .owner = THIS_MODULE, - .name = "lm75", + .driver = { + .owner = THIS_MODULE, + .name = "lm75", + }, .id = I2C_DRIVERID_LM75, .attach_adapter = lm75_attach_adapter, .detach_client = lm75_detach_client, diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 6a524e9..1770720 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -74,8 +74,10 @@ static struct lm77_data *lm77_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver lm77_driver = { - .owner = THIS_MODULE, - .name = "lm77", + .driver = { + .owner = THIS_MODULE, + .name = "lm77", + }, .attach_adapter = lm77_attach_adapter, .detach_client = lm77_detach_client, }; diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 18448f8..3af5b06 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -164,16 +164,20 @@ static void lm78_init_client(struct i2c_client *client); static struct i2c_driver lm78_driver = { - .owner = THIS_MODULE, - .name = "lm78", + .driver = { + .owner = THIS_MODULE, + .name = "lm78", + }, .id = I2C_DRIVERID_LM78, .attach_adapter = lm78_attach_adapter, .detach_client = lm78_detach_client, }; static struct i2c_driver lm78_isa_driver = { - .owner = THIS_MODULE, - .name = "lm78-isa", + .driver = { + .owner = THIS_MODULE, + .name = "lm78-isa", + }, .attach_adapter = lm78_isa_attach_adapter, .detach_client = lm78_detach_client, }; @@ -496,7 +500,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind) /* Reserve the ISA region */ if (is_isa) if (!request_region(address, LM78_EXTENT, - lm78_isa_driver.name)) { + lm78_isa_driver.driver.name)) { err = -EBUSY; goto ERROR0; } diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 02303fa..1dc118f 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -143,8 +143,10 @@ static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value); */ static struct i2c_driver lm80_driver = { - .owner = THIS_MODULE, - .name = "lm80", + .driver = { + .owner = THIS_MODULE, + .name = "lm80", + }, .id = I2C_DRIVERID_LM80, .attach_adapter = lm80_attach_adapter, .detach_client = lm80_detach_client, diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 96cb34e..1c1744f 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -124,8 +124,10 @@ static struct lm83_data *lm83_update_device(struct device *dev); */ static struct i2c_driver lm83_driver = { - .owner = THIS_MODULE, - .name = "lm83", + .driver = { + .owner = THIS_MODULE, + .name = "lm83", + }, .id = I2C_DRIVERID_LM83, .attach_adapter = lm83_attach_adapter, .detach_client = lm83_detach_client, diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 131ecab..b537c18 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -380,8 +380,10 @@ static void lm85_init_client(struct i2c_client *client); static struct i2c_driver lm85_driver = { - .owner = THIS_MODULE, - .name = "lm85", + .driver = { + .owner = THIS_MODULE, + .name = "lm85", + }, .id = I2C_DRIVERID_LM85, .attach_adapter = lm85_attach_adapter, .detach_client = lm85_detach_client, diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 26fd0b3..3152c00 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -161,8 +161,10 @@ static struct lm87_data *lm87_update_device(struct device *dev); */ static struct i2c_driver lm87_driver = { - .owner = THIS_MODULE, - .name = "lm87", + .driver = { + .owner = THIS_MODULE, + .name = "lm87", + }, .id = I2C_DRIVERID_LM87, .attach_adapter = lm87_attach_adapter, .detach_client = lm87_detach_client, diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 011923b..ff7ba1e 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -186,8 +186,10 @@ static struct lm90_data *lm90_update_device(struct device *dev); */ static struct i2c_driver lm90_driver = { - .owner = THIS_MODULE, - .name = "lm90", + .driver = { + .owner = THIS_MODULE, + .name = "lm90", + }, .id = I2C_DRIVERID_LM90, .attach_adapter = lm90_attach_adapter, .detach_client = lm90_detach_client, diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index 2005a9e..b4e4a84 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -410,8 +410,10 @@ static int lm92_detach_client(struct i2c_client *client) */ static struct i2c_driver lm92_driver = { - .owner = THIS_MODULE, - .name = "lm92", + .driver = { + .owner = THIS_MODULE, + .name = "lm92", + }, .id = I2C_DRIVERID_LM92, .attach_adapter = lm92_attach_adapter, .detach_client = lm92_detach_client, diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index d5aebef..1a50b13 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -90,8 +90,10 @@ static struct max1619_data *max1619_update_device(struct device *dev); */ static struct i2c_driver max1619_driver = { - .owner = THIS_MODULE, - .name = "max1619", + .driver = { + .owner = THIS_MODULE, + .name = "max1619", + }, .attach_adapter = max1619_attach_adapter, .detach_client = max1619_detach_client, }; diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 17f745a..5469489 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -236,8 +236,10 @@ static struct pc87360_data *pc87360_update_device(struct device *dev); */ static struct i2c_driver pc87360_driver = { - .owner = THIS_MODULE, - .name = "pc87360", + .driver = { + .owner = THIS_MODULE, + .name = "pc87360", + }, .attach_adapter = pc87360_detect, .detach_client = pc87360_detach_client, }; @@ -798,7 +800,7 @@ static int pc87360_detect(struct i2c_adapter *adapter) for (i = 0; i < 3; i++) { if (((data->address[i] = extra_isa[i])) && !request_region(extra_isa[i], PC87360_EXTENT, - pc87360_driver.name)) { + pc87360_driver.driver.name)) { dev_err(&new_client->dev, "Region 0x%x-0x%x already " "in use!\n", extra_isa[i], extra_isa[i]+PC87360_EXTENT-1); diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 9c6cade..9f44b93 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -198,8 +198,10 @@ static struct sis5595_data *sis5595_update_device(struct device *dev); static void sis5595_init_client(struct i2c_client *client); static struct i2c_driver sis5595_driver = { - .owner = THIS_MODULE, - .name = "sis5595", + .driver = { + .owner = THIS_MODULE, + .name = "sis5595", + }, .attach_adapter = sis5595_detect, .detach_client = sis5595_detach_client, }; @@ -484,7 +486,8 @@ static int sis5595_detect(struct i2c_adapter *adapter) if (force_addr) address = force_addr & ~(SIS5595_EXTENT - 1); /* Reserve the ISA region */ - if (!request_region(address, SIS5595_EXTENT, sis5595_driver.name)) { + if (!request_region(address, SIS5595_EXTENT, + sis5595_driver.driver.name)) { err = -EBUSY; goto exit; } diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 2a3e21b..02e5d55 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -226,8 +226,10 @@ static int smsc47b397_detach_client(struct i2c_client *client) static int smsc47b397_detect(struct i2c_adapter *adapter); static struct i2c_driver smsc47b397_driver = { - .owner = THIS_MODULE, - .name = "smsc47b397", + .driver = { + .owner = THIS_MODULE, + .name = "smsc47b397", + }, .attach_adapter = smsc47b397_detect, .detach_client = smsc47b397_detach_client, }; @@ -238,7 +240,8 @@ static int smsc47b397_detect(struct i2c_adapter *adapter) struct smsc47b397_data *data; int err = 0; - if (!request_region(address, SMSC_EXTENT, smsc47b397_driver.name)) { + if (!request_region(address, SMSC_EXTENT, + smsc47b397_driver.driver.name)) { dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); return -EBUSY; diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index 5905c1a..b3051ad 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -126,8 +126,10 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, static struct i2c_driver smsc47m1_driver = { - .owner = THIS_MODULE, - .name = "smsc47m1", + .driver = { + .owner = THIS_MODULE, + .name = "smsc47m1", + }, .attach_adapter = smsc47m1_detect, .detach_client = smsc47m1_detach_client, }; @@ -394,7 +396,7 @@ static int smsc47m1_detect(struct i2c_adapter *adapter) int err = 0; int fan1, fan2, pwm1, pwm2; - if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) { + if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.driver.name)) { dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); return -EBUSY; } diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index 6f696f8..db75fbc 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -572,8 +572,10 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); /* The driver. I choose to use type i2c_driver, as at is identical to both smbus_driver and isa_driver, and clients could be of either kind */ static struct i2c_driver via686a_driver = { - .owner = THIS_MODULE, - .name = "via686a", + .driver = { + .owner = THIS_MODULE, + .name = "via686a", + }, .attach_adapter = via686a_detect, .detach_client = via686a_detach_client, }; @@ -615,7 +617,8 @@ static int via686a_detect(struct i2c_adapter *adapter) } /* Reserve the ISA region */ - if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { + if (!request_region(address, VIA686A_EXTENT, + via686a_driver.driver.name)) { dev_err(&adapter->dev, "region 0x%x already in use!\n", address); return -ENODEV; diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index c8556a72..c2eb54b 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c @@ -585,8 +585,10 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); static struct i2c_driver vt8231_driver = { - .owner = THIS_MODULE, - .name = "vt8231", + .driver = { + .owner = THIS_MODULE, + .name = "vt8231", + }, .attach_adapter = vt8231_detect, .detach_client = vt8231_detach_client, }; diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index eee22a5..94538fb 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -676,7 +676,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter) int i, err = 0; if (!request_region(address + REGION_OFFSET, REGION_LENGTH, - w83627ehf_driver.name)) { + w83627ehf_driver.driver.name)) { err = -EBUSY; goto exit; } @@ -785,8 +785,10 @@ static int w83627ehf_detach_client(struct i2c_client *client) } static struct i2c_driver w83627ehf_driver = { - .owner = THIS_MODULE, - .name = "w83627ehf", + .driver = { + .owner = THIS_MODULE, + .name = "w83627ehf", + }, .attach_adapter = w83627ehf_detect, .detach_client = w83627ehf_detach_client, }; diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 27cfde1..2ffb84f 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -332,8 +332,10 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev); static void w83627hf_init_client(struct i2c_client *client); static struct i2c_driver w83627hf_driver = { - .owner = THIS_MODULE, - .name = "w83627hf", + .driver = { + .owner = THIS_MODULE, + .name = "w83627hf", + }, .attach_adapter = w83627hf_detect, .detach_client = w83627hf_detach_client, }; @@ -1009,7 +1011,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter) address = force_addr & WINB_ALIGNMENT; if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE, - w83627hf_driver.name)) { + w83627hf_driver.driver.name)) { err = -EBUSY; goto ERROR0; } diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index a78929f..fd1a59c 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -269,16 +269,20 @@ static struct w83781d_data *w83781d_update_device(struct device *dev); static void w83781d_init_client(struct i2c_client *client); static struct i2c_driver w83781d_driver = { - .owner = THIS_MODULE, - .name = "w83781d", + .driver = { + .owner = THIS_MODULE, + .name = "w83781d", + }, .id = I2C_DRIVERID_W83781D, .attach_adapter = w83781d_attach_adapter, .detach_client = w83781d_detach_client, }; static struct i2c_driver w83781d_isa_driver = { - .owner = THIS_MODULE, - .name = "w83781d-isa", + .driver = { + .owner = THIS_MODULE, + .name = "w83781d-isa", + }, .attach_adapter = w83781d_isa_attach_adapter, .detach_client = w83781d_detach_client, }; @@ -1011,7 +1015,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind) if (is_isa) if (!request_region(address, W83781D_EXTENT, - w83781d_isa_driver.name)) { + w83781d_isa_driver.driver.name)) { dev_dbg(&adapter->dev, "Request of region " "0x%x-0x%x for w83781d failed\n", address, address + W83781D_EXTENT - 1); diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 6824243..9018445 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -317,8 +317,10 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev); static void w83792d_init_client(struct i2c_client *client); static struct i2c_driver w83792d_driver = { - .owner = THIS_MODULE, - .name = "w83792d", + .driver = { + .owner = THIS_MODULE, + .name = "w83792d", + }, .attach_adapter = w83792d_attach_adapter, .detach_client = w83792d_detach_client, }; diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index 35172fb..fc9f202 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -92,8 +92,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev); */ static struct i2c_driver w83l785ts_driver = { - .owner = THIS_MODULE, - .name = "w83l785ts", + .driver = { + .owner = THIS_MODULE, + .name = "w83l785ts", + }, .id = I2C_DRIVERID_W83L785TS, .attach_adapter = w83l785ts_attach_adapter, .detach_client = w83l785ts_detach_client, -- cgit v1.1 From a33ca23231a37e28d15da9546b1f3e83dc48284b Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:40:34 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 4 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the drivers for macintosh. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Acked-by: Benjamin Herrenschmidt Signed-off-by: Greg Kroah-Hartman --- drivers/macintosh/therm_adt746x.c | 6 ++++-- drivers/macintosh/therm_pm72.c | 6 ++++-- drivers/macintosh/therm_windtunnel.c | 6 ++++-- drivers/macintosh/windfarm_lm75_sensor.c | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index f62c16f..8bb1d85 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -171,8 +171,10 @@ detach_thermostat(struct i2c_adapter *adapter) } static struct i2c_driver thermostat_driver = { - .owner = THIS_MODULE, - .name = "therm_adt746x", + .driver = { + .owner = THIS_MODULE, + .name = "therm_adt746x", + }, .attach_adapter = attach_thermostat, .detach_adapter = detach_thermostat, }; diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index df00c96..97807be 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c @@ -283,8 +283,10 @@ static int therm_pm72_detach(struct i2c_adapter *adapter); static struct i2c_driver therm_pm72_driver = { - .owner = THIS_MODULE, - .name = "therm_pm72", + .driver = { + .owner = THIS_MODULE, + .name = "therm_pm72", + }, .attach_adapter = therm_pm72_attach, .detach_adapter = therm_pm72_detach, }; diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index f3bae0d..259f19d 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -354,8 +354,10 @@ do_detach( struct i2c_client *client ) } static struct i2c_driver g4fan_driver = { - .owner = THIS_MODULE, - .name = "therm_windtunnel", + .driver = { + .owner = THIS_MODULE, + .name = "therm_windtunnel", + }, .id = I2C_DRIVERID_G4FAN, .attach_adapter = do_attach, .detach_client = do_detach, diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c index 2392789..555d0e4 100644 --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c @@ -47,8 +47,10 @@ static int wf_lm75_attach(struct i2c_adapter *adapter); static int wf_lm75_detach(struct i2c_client *client); static struct i2c_driver wf_lm75_driver = { - .owner = THIS_MODULE, - .name = "wf_lm75", + .driver = { + .owner = THIS_MODULE, + .name = "wf_lm75", + }, .attach_adapter = wf_lm75_attach, .detach_client = wf_lm75_detach, }; -- cgit v1.1 From 604f28e2b8d34cbaf08f0351374645f161335a82 Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:43:39 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 5 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the drivers/media/video and usb/media drivers. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/media/video/adv7170.c | 6 ++++-- drivers/media/video/adv7175.c | 6 ++++-- drivers/media/video/bt819.c | 6 ++++-- drivers/media/video/bt832.c | 6 ++++-- drivers/media/video/bt856.c | 6 ++++-- drivers/media/video/bttv-i2c.c | 2 +- drivers/media/video/cs53l32a.c | 13 ++++++++----- drivers/media/video/cx25840/cx25840-core.c | 6 ++++-- drivers/media/video/cx25840/cx25840.h | 7 ++++--- drivers/media/video/cx88/cx88-i2c.c | 2 +- drivers/media/video/indycam.c | 6 ++++-- drivers/media/video/ir-kbd-i2c.c | 5 ++++- drivers/media/video/msp3400.c | 19 +++++++++++-------- drivers/media/video/ovcamchip/ovcamchip_core.c | 6 ++++-- drivers/media/video/saa5246a.c | 6 ++++-- drivers/media/video/saa5249.c | 6 ++++-- drivers/media/video/saa6588.c | 6 ++++-- drivers/media/video/saa7110.c | 6 ++++-- drivers/media/video/saa7111.c | 6 ++++-- drivers/media/video/saa7114.c | 6 ++++-- drivers/media/video/saa7115.c | 13 ++++++++----- drivers/media/video/saa711x.c | 6 ++++-- drivers/media/video/saa7127.c | 16 ++++++++++------ drivers/media/video/saa7134/saa6752hs.c | 6 ++++-- drivers/media/video/saa7134/saa7134-i2c.c | 4 ++-- drivers/media/video/saa7185.c | 6 ++++-- drivers/media/video/saa7191.c | 6 ++++-- drivers/media/video/tda7432.c | 6 ++++-- drivers/media/video/tda9840.c | 6 ++++-- drivers/media/video/tda9875.c | 6 ++++-- drivers/media/video/tda9887.c | 4 ++-- drivers/media/video/tea6415c.c | 6 ++++-- drivers/media/video/tea6420.c | 6 ++++-- drivers/media/video/tuner-3036.c | 6 ++++-- drivers/media/video/tuner-core.c | 6 +++--- drivers/media/video/tvaudio.c | 6 ++++-- drivers/media/video/tveeprom.c | 6 ++++-- drivers/media/video/tvmixer.c | 8 ++++++-- drivers/media/video/tvp5150.c | 6 ++++-- drivers/media/video/vpx3220.c | 6 ++++-- drivers/media/video/wm8775.c | 10 ++++++---- drivers/media/video/zoran_driver.c | 14 +++++++------- drivers/usb/media/w9968cf.c | 4 ++-- include/media/tuner.h | 7 ++++--- 44 files changed, 191 insertions(+), 111 deletions(-) diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index 622b161..c5f1c6b 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c @@ -497,8 +497,10 @@ adv7170_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_adv7170 = { - .owner = THIS_MODULE, - .name = "adv7170", /* name */ + .driver = { + .owner = THIS_MODULE, + .name = "adv7170", /* name */ + }, .id = I2C_DRIVERID_ADV7170, diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index d4859b4..33158aa 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -547,8 +547,10 @@ adv7175_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_adv7175 = { - .owner = THIS_MODULE, - .name = "adv7175", /* name */ + .driver = { + .owner = THIS_MODULE, + .name = "adv7175", /* name */ + }, .id = I2C_DRIVERID_ADV7175, diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index 741e59a..5868bbb 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c @@ -622,8 +622,10 @@ bt819_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_bt819 = { - .owner = THIS_MODULE, - .name = "bt819", + .driver = { + .owner = THIS_MODULE, + .name = "bt819", + }, .id = I2C_DRIVERID_BT819, diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index 4ed13860..347eb71 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c @@ -230,8 +230,10 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg) /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "i2c bt832 driver", + .driver = { + .owner = THIS_MODULE, + .name = "i2c bt832 driver", + }, .id = -1, /* FIXME */ .attach_adapter = bt832_probe, .detach_client = bt832_detach, diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index d4bba8e..207525a 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c @@ -404,8 +404,10 @@ bt856_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_bt856 = { - .owner = THIS_MODULE, - .name = "bt856", + .driver = { + .owner = THIS_MODULE, + .name = "bt856", + }, .id = I2C_DRIVERID_BT856, diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c index 77619eb..d6418c0 100644 --- a/drivers/media/video/bttv-i2c.c +++ b/drivers/media/video/bttv-i2c.c @@ -300,7 +300,7 @@ static int attach_inform(struct i2c_client *client) if (bttv_debug) printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n", - btv->c.nr,client->driver->name,client->addr, + btv->c.nr, client->driver->driver.name, client->addr, client->name); if (!client->driver->command) return 0; diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c index f442ce3..60484f9 100644 --- a/drivers/media/video/cs53l32a.c +++ b/drivers/media/video/cs53l32a.c @@ -42,15 +42,16 @@ MODULE_PARM_DESC(debug, "Debugging messages\n\t\t\t0=Off (default), 1=On"); #define cs53l32a_dbg(fmt, arg...) \ do { \ if (debug) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, \ + client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); \ } while (0) #define cs53l32a_err(fmt, arg...) do { \ - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define cs53l32a_info(fmt, arg...) do { \ - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) static unsigned short normal_i2c[] = { 0x22 >> 1, I2C_CLIENT_END }; @@ -215,12 +216,14 @@ static int cs53l32a_detach(struct i2c_client *client) /* i2c implementation */ static struct i2c_driver i2c_driver = { - .name = "cs53l32a", + .driver = { + .owner = THIS_MODULE, + .name = "cs53l32a", + }, .id = I2C_DRIVERID_CS53L32A, .attach_adapter = cs53l32a_probe, .detach_client = cs53l32a_detach, .command = cs53l32a_command, - .owner = THIS_MODULE, }; diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 0b278ab..830d519 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c @@ -843,14 +843,16 @@ static int cx25840_detach_client(struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_cx25840 = { - .name = "cx25840", + .driver = { + .owner = THIS_MODULE, + .name = "cx25840", + }, .id = I2C_DRIVERID_CX25840, .attach_adapter = cx25840_attach_adapter, .detach_client = cx25840_detach_client, .command = cx25840_command, - .owner = THIS_MODULE, }; diff --git a/drivers/media/video/cx25840/cx25840.h b/drivers/media/video/cx25840/cx25840.h index 4932ed1..40aa59f 100644 --- a/drivers/media/video/cx25840/cx25840.h +++ b/drivers/media/video/cx25840/cx25840.h @@ -27,15 +27,16 @@ extern int cx25840_debug; #define cx25840_dbg(fmt, arg...) do { if (cx25840_debug) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, \ + client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define cx25840_err(fmt, arg...) do { \ - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define cx25840_info(fmt, arg...) do { \ - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0) diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c index 9790d41..4a8fb16 100644 --- a/drivers/media/video/cx88/cx88-i2c.c +++ b/drivers/media/video/cx88/cx88-i2c.c @@ -94,7 +94,7 @@ static int attach_inform(struct i2c_client *client) struct cx88_core *core = i2c_get_adapdata(client->adapter); dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n", - client->driver->name, client->addr, client->name); + client->driver->driver.name, client->addr, client->name); if (!client->driver->command) return 0; diff --git a/drivers/media/video/indycam.c b/drivers/media/video/indycam.c index 3eba514..96a808e 100644 --- a/drivers/media/video/indycam.c +++ b/drivers/media/video/indycam.c @@ -451,8 +451,10 @@ static int indycam_command(struct i2c_client *client, unsigned int cmd, } static struct i2c_driver i2c_driver_indycam = { - .owner = THIS_MODULE, - .name = "indycam", + .driver = { + .owner = THIS_MODULE, + .name = "indycam", + }, .id = I2C_DRIVERID_INDYCAM, .attach_adapter = indycam_probe, .detach_client = indycam_detach, diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 2e2f78a..82c7f50 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -278,7 +278,10 @@ static int ir_detach(struct i2c_client *client); static int ir_probe(struct i2c_adapter *adap); static struct i2c_driver driver = { - .name = "ir remote kbd driver", + .driver = { + .owner = THIS_MODULE, + .name = "ir remote kbd driver", + }, .id = I2C_DRIVERID_INFRARED, .attach_adapter = ir_probe, .detach_client = ir_detach, diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index c5e8ad3..3847d89 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -59,7 +59,8 @@ #define msp3400_dbg(fmt, arg...) \ do { \ if (debug) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, \ + client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); \ } while (0) @@ -67,7 +68,8 @@ #define msp3400_dbg_mediumvol(fmt, arg...) \ do { \ if (debug >= 2) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, \ + client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); \ } while (0) @@ -75,18 +77,19 @@ #define msp3400_dbg_highvol(fmt, arg...) \ do { \ if (debug >= 16) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, \ + client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); \ } while (0) #define msp3400_err(fmt, arg...) do { \ - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define msp3400_warn(fmt, arg...) do { \ - printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define msp3400_info(fmt, arg...) do { \ - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define OPMODE_AUTO -1 @@ -1561,13 +1564,13 @@ static int msp_resume(struct device * dev); static void msp_wake_thread(struct i2c_client *client); static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "msp3400", .id = I2C_DRIVERID_MSP3400, .attach_adapter = msp_probe, .detach_client = msp_detach, .command = msp_command, .driver = { + .owner = THIS_MODULE, + .name = "i2c msp3400 driver", .suspend = msp_suspend, .resume = msp_resume, }, diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c index 390d0d6..9ac398b 100644 --- a/drivers/media/video/ovcamchip/ovcamchip_core.c +++ b/drivers/media/video/ovcamchip/ovcamchip_core.c @@ -410,8 +410,10 @@ static int ovcamchip_command(struct i2c_client *c, unsigned int cmd, void *arg) /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "ovcamchip", + .driver = { + .owner = THIS_MODULE, + .name = "ovcamchip", + }, .id = I2C_DRIVERID_OVCAMCHIP, .class = I2C_CLASS_CAM_DIGITAL, .attach_adapter = ovcamchip_attach, diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index 9bf6869..8c99edb 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c @@ -163,8 +163,10 @@ static int saa5246a_command(struct i2c_client *device, unsigned int cmd, static struct i2c_driver i2c_driver_videotext = { - .owner = THIS_MODULE, - .name = IF_NAME, /* name */ + .driver = { + .owner = THIS_MODULE, + .name = IF_NAME, /* name */ + }, .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ .attach_adapter = saa5246a_probe, .detach_client = saa5246a_detach, diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index 811e863..5b346bd 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c @@ -236,8 +236,10 @@ static int saa5249_command(struct i2c_client *device, static struct i2c_driver i2c_driver_videotext = { - .owner = THIS_MODULE, - .name = IF_NAME, /* name */ + .driver = { + .owner = THIS_MODULE, + .name = IF_NAME, /* name */ + }, .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ .attach_adapter = saa5249_probe, .detach_client = saa5249_detach, diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c index 3d4076c..5ea36ee 100644 --- a/drivers/media/video/saa6588.c +++ b/drivers/media/video/saa6588.c @@ -495,8 +495,10 @@ static int saa6588_command(struct i2c_client *client, unsigned int cmd, /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "i2c saa6588 driver", + .driver = { + .owner = THIS_MODULE, + .name = "i2c saa6588 driver", + }, .id = -1, /* FIXME */ .attach_adapter = saa6588_probe, .detach_client = saa6588_detach, diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 8affa63..58f60ba 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c @@ -586,8 +586,10 @@ saa7110_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_saa7110 = { - .owner = THIS_MODULE, - .name = "saa7110", + .driver = { + .owner = THIS_MODULE, + .name = "saa7110", + }, .id = I2C_DRIVERID_SAA7110, diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 2b22045..946eb74 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -589,8 +589,10 @@ saa7111_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_saa7111 = { - .owner = THIS_MODULE, - .name = "saa7111", + .driver = { + .owner = THIS_MODULE, + .name = "saa7111", + }, .id = I2C_DRIVERID_SAA7111A, diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index 285f6c7..df53b58 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c @@ -1203,8 +1203,10 @@ saa7114_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_saa7114 = { - .owner = THIS_MODULE, - .name = "saa7114", + .driver = { + .owner = THIS_MODULE, + .name = "saa7114", + }, .id = I2C_DRIVERID_SAA7114, diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index 79aadd2..6ac1ab4 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c @@ -52,15 +52,16 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)"); #define saa7115_dbg(fmt,arg...) \ do { \ if (debug) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, \ + client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); \ } while (0) #define saa7115_err(fmt, arg...) do { \ - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define saa7115_info(fmt, arg...) do { \ - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; @@ -1353,12 +1354,14 @@ static int saa7115_detach(struct i2c_client *client) /* i2c implementation */ static struct i2c_driver i2c_driver_saa7115 = { - .name = "saa7115", + .driver = { + .owner = THIS_MODULE, + .name = "saa7115", + }, .id = I2C_DRIVERID_SAA711X, .attach_adapter = saa7115_probe, .detach_client = saa7115_detach, .command = saa7115_command, - .owner = THIS_MODULE, }; diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 44bfc04..3f7cfb7 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c @@ -564,8 +564,10 @@ saa711x_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_saa711x = { - .owner = THIS_MODULE, - .name = "saa711x", + .driver = { + .owner = THIS_MODULE, + .name = "saa711x", + }, .id = I2C_DRIVERID_SAA711X, diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index 1f4b415..659cb8a 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c @@ -69,7 +69,8 @@ MODULE_PARM_DESC(test_image, "test_image (0-1)"); #define saa7127_dbg(fmt, arg...) \ do { \ if (debug >= 1) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, \ + client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); \ } while (0) @@ -77,15 +78,16 @@ MODULE_PARM_DESC(test_image, "test_image (0-1)"); #define saa7127_dbg_highvol(fmt, arg...) \ do { \ if (debug == 2) \ - printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s debug %d-%04x: " fmt, \ + client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); \ } while (0) #define saa7127_err(fmt, arg...) do { \ - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define saa7127_info(fmt, arg...) do { \ - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; @@ -818,12 +820,14 @@ static int saa7127_detach(struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_saa7127 = { - .name = "saa7127", + .driver = { + .owner = THIS_MODULE, + .name = "saa7127", + }, .id = I2C_DRIVERID_SAA7127, .attach_adapter = saa7127_probe, .detach_client = saa7127_detach, .command = saa7127_command, - .owner = THIS_MODULE, }; diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 6820606..0e8c9ed 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c @@ -597,8 +597,10 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg) /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "i2c saa6752hs MPEG encoder", + .driver = { + .owner = THIS_MODULE, + .name = "i2c saa6752hs MPEG encoder", + }, .id = I2C_DRIVERID_SAA6752HS, .attach_adapter = saa6752hs_probe, .detach_client = saa6752hs_detach, diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index df9dd36..1792d03 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -333,7 +333,7 @@ static int attach_inform(struct i2c_client *client) struct tuner_setup tun_setup; d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", - client->driver->name, client->addr, client->name); + client->driver->driver.name, client->addr, client->name); /* Am I an i2c remote control? */ @@ -343,7 +343,7 @@ static int attach_inform(struct i2c_client *client) { struct IR_i2c *ir = i2c_get_clientdata(client); d1printk("%s i2c IR detected (%s).\n", - client->driver->name,ir->phys); + client->driver->driver.name, ir->phys); saa7134_set_i2c_ir(dev,ir); break; } diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 9f37585..64047d77 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c @@ -486,8 +486,10 @@ saa7185_detach_client (struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver i2c_driver_saa7185 = { - .owner = THIS_MODULE, - .name = "saa7185", /* name */ + .driver = { + .owner = THIS_MODULE, + .name = "saa7185", /* name */ + }, .id = I2C_DRIVERID_SAA7185B, diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c index 6be98fc..a0f8eaf 100644 --- a/drivers/media/video/saa7191.c +++ b/drivers/media/video/saa7191.c @@ -788,8 +788,10 @@ static int saa7191_command(struct i2c_client *client, unsigned int cmd, } static struct i2c_driver i2c_driver_saa7191 = { - .owner = THIS_MODULE, - .name = "saa7191", + .driver = { + .owner = THIS_MODULE, + .name = "saa7191", + }, .id = I2C_DRIVERID_SAA7191, .attach_adapter = saa7191_probe, .detach_client = saa7191_detach, diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index 239a586..59674d9 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c @@ -501,8 +501,10 @@ static int tda7432_command(struct i2c_client *client, } static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "i2c tda7432 driver", + .driver = { + .owner = THIS_MODULE, + .name = "i2c tda7432 driver", + }, .id = I2C_DRIVERID_TDA7432, .attach_adapter = tda7432_probe, .detach_client = tda7432_detach, diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index f29fb50..8efc726 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c @@ -221,8 +221,10 @@ static int detach(struct i2c_client *client) } static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "tda9840", + .driver = { + .owner = THIS_MODULE, + .name = "tda9840", + }, .id = I2C_DRIVERID_TDA9840, .attach_adapter = attach, .detach_client = detach, diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index d053b64..de89616 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c @@ -372,8 +372,10 @@ static int tda9875_command(struct i2c_client *client, static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "i2c tda9875 driver", + .driver = { + .owner = THIS_MODULE, + .name = "i2c tda9875 driver", + }, .id = I2C_DRIVERID_TDA9875, .attach_adapter = tda9875_probe, .detach_client = tda9875_detach, diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 324f61b..081f478 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -819,13 +819,13 @@ static int tda9887_resume(struct device * dev) /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "i2c tda9887 driver", .id = -1, /* FIXME */ .attach_adapter = tda9887_probe, .detach_client = tda9887_detach, .command = tda9887_command, .driver = { + .owner = THIS_MODULE, + .name = "i2c tda9887 driver", .suspend = tda9887_suspend, .resume = tda9887_resume, }, diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index 96d88ce..e7e2213 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c @@ -190,8 +190,10 @@ static int command(struct i2c_client *client, unsigned int cmd, void *arg) } static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "tea6415c", + .driver = { + .owner = THIS_MODULE, + .name = "tea6415c", + }, .id = I2C_DRIVERID_TEA6415C, .attach_adapter = attach, .detach_client = detach, diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index fd417de..74cc25f 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c @@ -167,8 +167,10 @@ static int command(struct i2c_client *client, unsigned int cmd, void *arg) } static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "tea6420", + .driver = { + .owner = THIS_MODULE, + .name = "tea6420", + }, .id = I2C_DRIVERID_TEA6420, .attach_adapter = attach, .detach_client = detach, diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c index 3505cec2..83257af 100644 --- a/drivers/media/video/tuner-3036.c +++ b/drivers/media/video/tuner-3036.c @@ -175,8 +175,10 @@ tuner_probe(struct i2c_adapter *adap) static struct i2c_driver i2c_driver_tuner = { - .owner = THIS_MODULE, - .name = "sab3036", + .driver = { + .owner = THIS_MODULE, + .name = "sab3036", + }, .id = I2C_DRIVERID_SAB3036, .attach_adapter = tuner_probe, .detach_client = tuner_detach, diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 6328f09..e8c8549 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -206,7 +206,7 @@ static void set_type(struct i2c_client *c, unsigned int type, set_freq(c, t->freq); tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", - c->adapter->name, c->driver->name, c->addr << 1, type, + c->adapter->name, c->driver->driver.name, c->addr << 1, type, t->mode_mask); } @@ -742,13 +742,13 @@ static int tuner_resume(struct device *dev) /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "tuner", .id = I2C_DRIVERID_TUNER, .attach_adapter = tuner_probe, .detach_client = tuner_detach, .command = tuner_command, .driver = { + .owner = THIS_MODULE, + .name = "tuner", .suspend = tuner_suspend, .resume = tuner_resume, }, diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 4f1f339..30bb2a3 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -1702,8 +1702,10 @@ static int chip_command(struct i2c_client *client, static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "generic i2c audio driver", + .driver = { + .owner = THIS_MODULE, + .name = "generic i2c audio driver", + }, .id = I2C_DRIVERID_TVAUDIO, .attach_adapter = chip_probe, .detach_client = chip_detach, diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index d833b65..d8b5a17 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -778,8 +778,10 @@ tveeprom_detach_client (struct i2c_client *client) } static struct i2c_driver i2c_driver_tveeprom = { - .owner = THIS_MODULE, - .name = "tveeprom", + .driver = { + .owner = THIS_MODULE, + .name = "tveeprom", + }, .id = I2C_DRIVERID_TVEEPROM, .attach_adapter = tveeprom_attach_adapter, .detach_client = tveeprom_detach_client, diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index 936e01d..5f4d0185 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -228,9 +228,13 @@ static int tvmixer_release(struct inode *inode, struct file *file) static struct i2c_driver driver = { #ifdef I2C_PEC - .owner = THIS_MODULE, -#endif + .driver = { + .owner = THIS_MODULE, + .name = "tv card mixer driver", + }, +#else .name = "tv card mixer driver", +#endif .id = I2C_DRIVERID_TVMIXER, .detach_adapter = tvmixer_adapters, .attach_adapter = tvmixer_adapters, diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index 3734554..5eca71f 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c @@ -800,8 +800,10 @@ static int tvp5150_detach_client(struct i2c_client *client) /* ----------------------------------------------------------------------- */ static struct i2c_driver driver = { - .owner = THIS_MODULE, - .name = "tvp5150", + .driver = { + .owner = THIS_MODULE, + .name = "tvp5150", + }, /* FIXME */ .id = I2C_DRIVERID_SAA7110, diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index 54bc888..b85b598 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c @@ -721,8 +721,10 @@ vpx3220_attach_adapter (struct i2c_adapter *adapter) */ static struct i2c_driver vpx3220_i2c_driver = { - .owner = THIS_MODULE, - .name = "vpx3220", + .driver = { + .owner = THIS_MODULE, + .name = "vpx3220", + }, .id = I2C_DRIVERID_VPX3220, diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c index 527c2591..22875f1 100644 --- a/drivers/media/video/wm8775.c +++ b/drivers/media/video/wm8775.c @@ -40,10 +40,10 @@ MODULE_AUTHOR("Ulf Eklund, Hans Verkuil"); MODULE_LICENSE("GPL"); #define wm8775_err(fmt, arg...) do { \ - printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) #define wm8775_info(fmt, arg...) do { \ - printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ + printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \ i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) @@ -232,14 +232,16 @@ static int wm8775_detach(struct i2c_client *client) /* i2c implementation */ static struct i2c_driver i2c_driver = { - .name = "wm8775", + .driver = { + .owner = THIS_MODULE, + .name = "wm8775", + }, .id = I2C_DRIVERID_WM8775, .attach_adapter = wm8775_probe, .detach_client = wm8775_detach, .command = wm8775_command, - .owner = THIS_MODULE, }; diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c index 07bde9a..4034f1b 100644 --- a/drivers/media/video/zoran_driver.c +++ b/drivers/media/video/zoran_driver.c @@ -1311,7 +1311,7 @@ zoran_open (struct inode *inode, res = -ENODEV; goto open_unlock_and_return; } - if (!try_module_get(zr->decoder->driver->owner)) { + if (!try_module_get(zr->decoder->driver->driver.owner)) { dprintk(1, KERN_ERR "%s: failed to grab ownership of i2c decoder\n", @@ -1321,13 +1321,13 @@ zoran_open (struct inode *inode, goto open_unlock_and_return; } if (zr->encoder && - !try_module_get(zr->encoder->driver->owner)) { + !try_module_get(zr->encoder->driver->driver.owner)) { dprintk(1, KERN_ERR "%s: failed to grab ownership of i2c encoder\n", ZR_DEVNAME(zr)); res = -EIO; - module_put(zr->decoder->driver->owner); + module_put(zr->decoder->driver->driver.owner); module_put(THIS_MODULE); goto open_unlock_and_return; } @@ -1393,9 +1393,9 @@ zoran_open (struct inode *inode, open_unlock_and_return: /* if we grabbed locks, release them accordingly */ if (have_module_locks) { - module_put(zr->decoder->driver->owner); + module_put(zr->decoder->driver->driver.owner); if (zr->encoder) { - module_put(zr->encoder->driver->owner); + module_put(zr->encoder->driver->driver.owner); } module_put(THIS_MODULE); } @@ -1461,9 +1461,9 @@ zoran_close (struct inode *inode, kfree(fh); /* release locks on the i2c modules */ - module_put(zr->decoder->driver->owner); + module_put(zr->decoder->driver->driver.owner); if (zr->encoder) { - module_put(zr->encoder->driver->owner); + module_put(zr->encoder->driver->driver.owner); } module_put(THIS_MODULE); diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c index 04d6933..3605a6f 100644 --- a/drivers/usb/media/w9968cf.c +++ b/drivers/usb/media/w9968cf.c @@ -1533,12 +1533,12 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client) } } else { DBG(4, "Rejected client [%s] with driver [%s]", - client->name, client->driver->name) + client->name, client->driver->driver.name) return -EINVAL; } DBG(5, "I2C attach client [%s] with driver [%s]", - client->name, client->driver->name) + client->name, client->driver->driver.name) return 0; } diff --git a/include/media/tuner.h b/include/media/tuner.h index faa0f8e..b37cde6 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h @@ -218,14 +218,15 @@ extern int default_tuner_init(struct i2c_client *c); extern int tea5767_autodetection(struct i2c_client *c); #define tuner_warn(fmt, arg...) do {\ - printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->name, \ + printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) #define tuner_info(fmt, arg...) do {\ - printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->name, \ + printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) #define tuner_dbg(fmt, arg...) do {\ if (tuner_debug) \ - printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->name, \ + printk(KERN_DEBUG "%s %d-%04x: " fmt, \ + t->i2c.driver->driver.name, \ t->i2c.adapter->nr, t->i2c.addr , ##arg); } while (0) #endif /* __KERNEL__ */ -- cgit v1.1 From d74cdab1cad1e5895d8928eeeb2ac469f8410d2e Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:46:32 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 6 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the OSS drivers. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- sound/oss/dmasound/dac3550a.c | 6 ++++-- sound/oss/dmasound/tas_common.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/oss/dmasound/dac3550a.c b/sound/oss/dmasound/dac3550a.c index 3402a66..835e0cf 100644 --- a/sound/oss/dmasound/dac3550a.c +++ b/sound/oss/dmasound/dac3550a.c @@ -41,8 +41,10 @@ static int daca_detect_client(struct i2c_adapter *adapter, int address); static int daca_detach_client(struct i2c_client *client); struct i2c_driver daca_driver = { - .owner = THIS_MODULE, - .name = "DAC3550A driver V " DACA_VERSION, + .driver = { + .owner = THIS_MODULE, + .name = "DAC3550A driver V " DACA_VERSION, + }, .id = I2C_DRIVERID_DACA, .attach_adapter = daca_attach_adapter, .detach_client = daca_detach_client, diff --git a/sound/oss/dmasound/tas_common.c b/sound/oss/dmasound/tas_common.c index 7e3d517..bd6910a 100644 --- a/sound/oss/dmasound/tas_common.c +++ b/sound/oss/dmasound/tas_common.c @@ -47,8 +47,10 @@ static int tas_attach_adapter(struct i2c_adapter *); static int tas_detach_client(struct i2c_client *); struct i2c_driver tas_driver = { - .owner = THIS_MODULE, - .name = "tas", + .driver = { + .owner = THIS_MODULE, + .name = "tas", + }, .attach_adapter = tas_attach_adapter, .detach_client = tas_detach_client, }; -- cgit v1.1 From e100fe103e679372b3d1d6e9d32fd3ab57484be2 Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:48:35 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 7 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the drivers for ppc arch. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- sound/ppc/keywest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index fd8e2e6..d532924 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -41,7 +41,10 @@ static int keywest_attach_adapter(struct i2c_adapter *adapter); static int keywest_detach_client(struct i2c_client *client); struct i2c_driver keywest_driver = { - .name = "PMac Keywest Audio", + .driver = { + .owner = THIS_MODULE, + .name = "PMac Keywest Audio", + }, .id = I2C_DRIVERID_KEYWEST, .attach_adapter = &keywest_attach_adapter, .detach_client = &keywest_detach_client, -- cgit v1.1 From e533449d291b5a28ce9527539750a0cb88146f6e Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:51:06 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 8 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the drivers for acorn arch. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Acked-by: Russell King Signed-off-by: Greg Kroah-Hartman --- drivers/acorn/char/pcf8583.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c index befc946..5fc5940 100644 --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c @@ -257,7 +257,10 @@ pcf8583_command(struct i2c_client *client, unsigned int cmd, void *arg) } static struct i2c_driver pcf8583_driver = { - .name = "PCF8583", + .driver = { + .owner = THIS_MODULE, + .name = "PCF8583", + }, .id = I2C_DRIVERID_PCF8583, .attach_adapter = pcf8583_probe, .detach_client = pcf8583_detach, -- cgit v1.1 From 1a7edcdca618d25564690c2df27c2c5c6e9f6316 Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sat, 26 Nov 2005 20:52:34 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 9 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the matroxfb driver. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Acked-by: Petr Vandrovec Signed-off-by: Greg Kroah-Hartman --- drivers/video/matrox/matroxfb_maven.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index 78994c5..f6fdb69 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c @@ -1293,8 +1293,10 @@ static int maven_command(struct i2c_client* client, unsigned int cmd, void* arg) } static struct i2c_driver maven_driver={ - .owner = THIS_MODULE, - .name = "maven", + .driver = { + .owner = THIS_MODULE, + .name = "maven", + }, .id = I2C_DRIVERID_MGATVO, .attach_adapter = maven_attach_adapter, .detach_client = maven_detach_client, -- cgit v1.1 From b33a665dba55c83f08cdd62aba1cd2672bccdd80 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 20:54:10 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 10 of 11 We should use the i2c_driver.driver's .name and .owner fields instead of the i2c_driver's ones. This patch updates the drivers for arm arch. Signed-off-by: Jean Delvare CC: Laurent Riffard Signed-off-by: Greg Kroah-Hartman --- arch/arm/mach-pxa/akita-ioexp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-pxa/akita-ioexp.c b/arch/arm/mach-pxa/akita-ioexp.c index b6bff55..6f7b965 100644 --- a/arch/arm/mach-pxa/akita-ioexp.c +++ b/arch/arm/mach-pxa/akita-ioexp.c @@ -124,8 +124,10 @@ static int max7310_detach_client(struct i2c_client *client) } static struct i2c_driver max7310_i2c_driver = { - .owner = THIS_MODULE, - .name = "akita-max7310", + .driver = { + .owner = THIS_MODULE, + .name = "akita-max7310", + }, .id = I2C_DRIVERID_AKITAIOEXP, .attach_adapter = max7310_attach_adapter, .detach_client = max7310_detach_client, -- cgit v1.1 From d45d204f0c3daa01a393dfe81415573f9459506a Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 26 Nov 2005 20:55:35 +0100 Subject: [PATCH] i2c: Drop i2c_driver.{owner,name}, 11 of 11 Document the drop of the owner and name fields of the i2c_driver structure. Signed-off-by: Jean Delvare CC: Laurent Riffard Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/porting-clients | 4 ++++ Documentation/i2c/writing-clients | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index 856274f..f997c72 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -125,6 +125,10 @@ Technical changes: * [Driver] The flags field of the i2c_driver structure is gone. I2C_DF_NOTIFY is now the default behavior. + The i2c_driver structure has a driver member, which is itself a + structure, those owner and name members should be initialized to + THIS_MODULE and a driver name string, respectively. i2c_driver + itself has no name member anymore. Coding policy: diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 59d2c16..95eed2b 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -25,8 +25,10 @@ routines, a client structure specific information like the actual I2C address. static struct i2c_driver foo_driver = { - .owner = THIS_MODULE, - .name = "Foo version 2.3 driver", + .driver = { + .owner = THIS_MODULE, + .name = "foo", + }, .attach_adapter = &foo_attach_adapter, .detach_client = &foo_detach_client, .command = &foo_command /* may be NULL */ -- cgit v1.1 From e1c489b0e4fbb1687f8227fe78b4769c123768c1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 30 Nov 2005 16:35:09 -0800 Subject: [PATCH] I2C: Fix up debug build error for previous i2c structure changes Signed-off-by: Greg Kroah-Hartman Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-isa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 9f93fb8..9f2ffef 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c @@ -98,7 +98,7 @@ int i2c_isa_add_driver(struct i2c_driver *driver) res = driver_register(&driver->driver); if (res) return res; - dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->name); + dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->driver.name); /* Now look for clients */ driver->attach_adapter(&isa_adapter); @@ -129,7 +129,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver) /* Get the driver off the core list */ driver_unregister(&driver->driver); - dev_dbg(&isa_adapter.dev, "Driver %s unregistered\n", driver->name); + dev_dbg(&isa_adapter.dev, "Driver %s unregistered\n", driver->driver.name); return 0; } @@ -174,7 +174,7 @@ static void __exit i2c_isa_exit(void) list_for_each_safe(item, _n, &isa_adapter.clients) { client = list_entry(item, struct i2c_client, list); dev_err(&isa_adapter.dev, "Driver %s still has an active " - "ISA client at 0x%x\n", client->driver->name, + "ISA client at 0x%x\n", client->driver->driver.name, client->addr); } if (client != NULL) -- cgit v1.1 From de59cf9ed44f64991e52a9de6094729537f0420c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 6 Dec 2005 15:33:15 -0800 Subject: [PATCH] I2C: Make i2c_add_driver automatically set the proper module owner This prevents i2c drivers from messing up and forgetting to set the module owner of their driver. It also reduces the size of their drivers by one line :) Signed-off-by: Greg Kroah-Hartman Cc: Jean Delvare --- drivers/i2c/i2c-core.c | 5 +++-- include/linux/i2c.h | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 4ce5f0f..c23443e 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -287,7 +287,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) * chips. */ -int i2c_add_driver(struct i2c_driver *driver) +int i2c_register_driver(struct module *owner, struct i2c_driver *driver) { struct list_head *item; struct i2c_adapter *adapter; @@ -296,6 +296,7 @@ int i2c_add_driver(struct i2c_driver *driver) down(&core_lists); /* add the driver to the list of i2c drivers in the driver core */ + driver->driver.owner = owner; driver->driver.bus = &i2c_bus_type; driver->driver.probe = i2c_device_probe; driver->driver.remove = i2c_device_remove; @@ -319,6 +320,7 @@ int i2c_add_driver(struct i2c_driver *driver) up(&core_lists); return res; } +EXPORT_SYMBOL(i2c_register_driver); int i2c_del_driver(struct i2c_driver *driver) { @@ -1132,7 +1134,6 @@ EXPORT_SYMBOL_GPL(i2c_bus_type); EXPORT_SYMBOL(i2c_add_adapter); EXPORT_SYMBOL(i2c_del_adapter); -EXPORT_SYMBOL(i2c_add_driver); EXPORT_SYMBOL(i2c_del_driver); EXPORT_SYMBOL(i2c_attach_client); EXPORT_SYMBOL(i2c_detach_client); diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 75aa18e..7863a59 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -291,9 +291,14 @@ struct i2c_client_address_data { extern int i2c_add_adapter(struct i2c_adapter *); extern int i2c_del_adapter(struct i2c_adapter *); -extern int i2c_add_driver(struct i2c_driver *); +extern int i2c_register_driver(struct module *, struct i2c_driver *); extern int i2c_del_driver(struct i2c_driver *); +static inline int i2c_add_driver(struct i2c_driver *driver) +{ + return i2c_register_driver(THIS_MODULE, driver); +} + extern int i2c_attach_client(struct i2c_client *); extern int i2c_detach_client(struct i2c_client *); -- cgit v1.1 From 2b48716d1d2f2edb1e7cbc5ecf1cb2cb39373e33 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 6 Dec 2005 15:33:15 -0800 Subject: [PATCH] I2C: Remove .owner setting from i2c_driver as it's no longer needed Now that i2c_add_driver() doesn't need the module owner to be set by hand, we can delete it from the drivers. This patch catches all of the drivers that I found in the current tree (if a driver sets the .owner by hand, it's not a problem, just not needed.) Signed-off-by: Greg Kroah-Hartman Cc: Jean Delvare --- arch/arm/mach-pxa/akita-ioexp.c | 1 - drivers/acorn/char/pcf8583.c | 1 - drivers/hwmon/adm1021.c | 1 - drivers/hwmon/adm1025.c | 1 - drivers/hwmon/adm1026.c | 1 - drivers/hwmon/adm1031.c | 1 - drivers/hwmon/adm9240.c | 1 - drivers/hwmon/asb100.c | 1 - drivers/hwmon/atxp1.c | 1 - drivers/hwmon/ds1621.c | 1 - drivers/hwmon/fscher.c | 1 - drivers/hwmon/fscpos.c | 1 - drivers/hwmon/gl518sm.c | 1 - drivers/hwmon/gl520sm.c | 1 - drivers/hwmon/it87.c | 2 -- drivers/hwmon/lm63.c | 1 - drivers/hwmon/lm75.c | 1 - drivers/hwmon/lm77.c | 1 - drivers/hwmon/lm78.c | 2 -- drivers/hwmon/lm80.c | 1 - drivers/hwmon/lm83.c | 1 - drivers/hwmon/lm85.c | 1 - drivers/hwmon/lm87.c | 1 - drivers/hwmon/lm90.c | 1 - drivers/hwmon/lm92.c | 1 - drivers/hwmon/max1619.c | 1 - drivers/hwmon/pc87360.c | 1 - drivers/hwmon/sis5595.c | 1 - drivers/hwmon/smsc47b397.c | 1 - drivers/hwmon/smsc47m1.c | 1 - drivers/hwmon/via686a.c | 1 - drivers/hwmon/vt8231.c | 1 - drivers/hwmon/w83627ehf.c | 1 - drivers/hwmon/w83627hf.c | 1 - drivers/hwmon/w83781d.c | 2 -- drivers/hwmon/w83792d.c | 1 - drivers/hwmon/w83l785ts.c | 1 - drivers/i2c/chips/ds1337.c | 1 - drivers/i2c/chips/ds1374.c | 1 - drivers/i2c/chips/eeprom.c | 1 - drivers/i2c/chips/isp1301_omap.c | 1 - drivers/i2c/chips/m41t00.c | 1 - drivers/i2c/chips/max6875.c | 1 - drivers/i2c/chips/pca9539.c | 1 - drivers/i2c/chips/pcf8574.c | 1 - drivers/i2c/chips/pcf8591.c | 1 - drivers/i2c/chips/rtc8564.c | 1 - drivers/i2c/chips/tps65010.c | 1 - drivers/i2c/chips/x1205.c | 1 - drivers/i2c/i2c-dev.c | 1 - drivers/macintosh/therm_adt746x.c | 1 - drivers/macintosh/therm_pm72.c | 1 - drivers/macintosh/therm_windtunnel.c | 1 - drivers/macintosh/windfarm_lm75_sensor.c | 1 - drivers/media/video/adv7170.c | 1 - drivers/media/video/adv7175.c | 1 - drivers/media/video/bt819.c | 1 - drivers/media/video/bt832.c | 1 - drivers/media/video/bt856.c | 1 - drivers/media/video/cs53l32a.c | 1 - drivers/media/video/cx25840/cx25840-core.c | 1 - drivers/media/video/indycam.c | 1 - drivers/media/video/ir-kbd-i2c.c | 1 - drivers/media/video/msp3400.c | 1 - drivers/media/video/ovcamchip/ovcamchip_core.c | 1 - drivers/media/video/saa5246a.c | 1 - drivers/media/video/saa5249.c | 1 - drivers/media/video/saa6588.c | 1 - drivers/media/video/saa7110.c | 1 - drivers/media/video/saa7111.c | 1 - drivers/media/video/saa7114.c | 1 - drivers/media/video/saa7115.c | 1 - drivers/media/video/saa711x.c | 1 - drivers/media/video/saa7127.c | 1 - drivers/media/video/saa7134/saa6752hs.c | 1 - drivers/media/video/saa7185.c | 1 - drivers/media/video/saa7191.c | 1 - drivers/media/video/tda7432.c | 1 - drivers/media/video/tda9840.c | 1 - drivers/media/video/tda9875.c | 1 - drivers/media/video/tda9887.c | 1 - drivers/media/video/tea6415c.c | 1 - drivers/media/video/tea6420.c | 1 - drivers/media/video/tuner-3036.c | 1 - drivers/media/video/tuner-core.c | 1 - drivers/media/video/tvaudio.c | 1 - drivers/media/video/tveeprom.c | 1 - drivers/media/video/tvmixer.c | 1 - drivers/media/video/tvp5150.c | 1 - drivers/media/video/vpx3220.c | 1 - drivers/media/video/wm8775.c | 1 - drivers/video/matrox/matroxfb_maven.c | 1 - sound/oss/dmasound/dac3550a.c | 1 - sound/oss/dmasound/tas_common.c | 1 - sound/ppc/keywest.c | 1 - 95 files changed, 98 deletions(-) diff --git a/arch/arm/mach-pxa/akita-ioexp.c b/arch/arm/mach-pxa/akita-ioexp.c index 6f7b965..1b39874 100644 --- a/arch/arm/mach-pxa/akita-ioexp.c +++ b/arch/arm/mach-pxa/akita-ioexp.c @@ -125,7 +125,6 @@ static int max7310_detach_client(struct i2c_client *client) static struct i2c_driver max7310_i2c_driver = { .driver = { - .owner = THIS_MODULE, .name = "akita-max7310", }, .id = I2C_DRIVERID_AKITAIOEXP, diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c index 5fc5940..9b49f31 100644 --- a/drivers/acorn/char/pcf8583.c +++ b/drivers/acorn/char/pcf8583.c @@ -258,7 +258,6 @@ pcf8583_command(struct i2c_client *client, unsigned int cmd, void *arg) static struct i2c_driver pcf8583_driver = { .driver = { - .owner = THIS_MODULE, .name = "PCF8583", }, .id = I2C_DRIVERID_PCF8583, diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 679cb92..6656127 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c @@ -127,7 +127,6 @@ static int read_only; /* This is the driver that will be inserted */ static struct i2c_driver adm1021_driver = { .driver = { - .owner = THIS_MODULE, .name = "adm1021", }, .id = I2C_DRIVERID_ADM1021, diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c index 3c70622..9331c56 100644 --- a/drivers/hwmon/adm1025.c +++ b/drivers/hwmon/adm1025.c @@ -119,7 +119,6 @@ static struct adm1025_data *adm1025_update_device(struct device *dev); static struct i2c_driver adm1025_driver = { .driver = { - .owner = THIS_MODULE, .name = "adm1025", }, .id = I2C_DRIVERID_ADM1025, diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c index 92fac34..fefe6e7 100644 --- a/drivers/hwmon/adm1026.c +++ b/drivers/hwmon/adm1026.c @@ -309,7 +309,6 @@ static void adm1026_init_client(struct i2c_client *client); static struct i2c_driver adm1026_driver = { .driver = { - .owner = THIS_MODULE, .name = "adm1026", }, .attach_adapter = adm1026_attach_adapter, diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index e42d75e..d063979 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c @@ -106,7 +106,6 @@ static struct adm1031_data *adm1031_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver adm1031_driver = { .driver = { - .owner = THIS_MODULE, .name = "adm1031", }, .attach_adapter = adm1031_attach_adapter, diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c index e60309e..5ddc22f 100644 --- a/drivers/hwmon/adm9240.c +++ b/drivers/hwmon/adm9240.c @@ -138,7 +138,6 @@ static struct adm9240_data *adm9240_update_device(struct device *dev); /* driver data */ static struct i2c_driver adm9240_driver = { .driver = { - .owner = THIS_MODULE, .name = "adm9240", }, .id = I2C_DRIVERID_ADM9240, diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c index 3068de0..ae9de63 100644 --- a/drivers/hwmon/asb100.c +++ b/drivers/hwmon/asb100.c @@ -218,7 +218,6 @@ static void asb100_init_client(struct i2c_client *client); static struct i2c_driver asb100_driver = { .driver = { - .owner = THIS_MODULE, .name = "asb100", }, .id = I2C_DRIVERID_ASB100, diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c index ed152d9..b0c4900 100644 --- a/drivers/hwmon/atxp1.c +++ b/drivers/hwmon/atxp1.c @@ -51,7 +51,6 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); static struct i2c_driver atxp1_driver = { .driver = { - .owner = THIS_MODULE, .name = "atxp1", }, .attach_adapter = atxp1_attach_adapter, diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c index 8600940..203f9c7 100644 --- a/drivers/hwmon/ds1621.c +++ b/drivers/hwmon/ds1621.c @@ -90,7 +90,6 @@ static struct ds1621_data *ds1621_update_client(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver ds1621_driver = { .driver = { - .owner = THIS_MODULE, .name = "ds1621", }, .id = I2C_DRIVERID_DS1621, diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c index 982fff4..2540918 100644 --- a/drivers/hwmon/fscher.c +++ b/drivers/hwmon/fscher.c @@ -119,7 +119,6 @@ static int fscher_write_value(struct i2c_client *client, u8 reg, u8 value); static struct i2c_driver fscher_driver = { .driver = { - .owner = THIS_MODULE, .name = "fscher", }, .id = I2C_DRIVERID_FSCHER, diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c index 971146b..6d0146b 100644 --- a/drivers/hwmon/fscpos.c +++ b/drivers/hwmon/fscpos.c @@ -101,7 +101,6 @@ static void reset_fan_alarm(struct i2c_client *client, int nr); */ static struct i2c_driver fscpos_driver = { .driver = { - .owner = THIS_MODULE, .name = "fscpos", }, .id = I2C_DRIVERID_FSCPOS, diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c index 9c5ca1f..9e685e3 100644 --- a/drivers/hwmon/gl518sm.c +++ b/drivers/hwmon/gl518sm.c @@ -152,7 +152,6 @@ static struct gl518_data *gl518_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver gl518_driver = { .driver = { - .owner = THIS_MODULE, .name = "gl518sm", }, .id = I2C_DRIVERID_GL518, diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c index a9a724a..baee60e 100644 --- a/drivers/hwmon/gl520sm.c +++ b/drivers/hwmon/gl520sm.c @@ -110,7 +110,6 @@ static struct gl520_data *gl520_update_device(struct device *dev); /* Driver data */ static struct i2c_driver gl520_driver = { .driver = { - .owner = THIS_MODULE, .name = "gl520sm", }, .id = I2C_DRIVERID_GL520, diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 24d520b..29b74a8 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -235,7 +235,6 @@ static void it87_init_client(struct i2c_client *client, struct it87_data *data); static struct i2c_driver it87_driver = { .driver = { - .owner = THIS_MODULE, .name = "it87", }, .id = I2C_DRIVERID_IT87, @@ -245,7 +244,6 @@ static struct i2c_driver it87_driver = { static struct i2c_driver it87_isa_driver = { .driver = { - .owner = THIS_MODULE, .name = "it87-isa", }, .attach_adapter = it87_isa_attach_adapter, diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c index 35baae7..6b1aa7e 100644 --- a/drivers/hwmon/lm63.c +++ b/drivers/hwmon/lm63.c @@ -140,7 +140,6 @@ static void lm63_init_client(struct i2c_client *client); static struct i2c_driver lm63_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm63", }, .attach_adapter = lm63_attach_adapter, diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c index db35fbf..74ca2c8 100644 --- a/drivers/hwmon/lm75.c +++ b/drivers/hwmon/lm75.c @@ -67,7 +67,6 @@ static struct lm75_data *lm75_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver lm75_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm75", }, .id = I2C_DRIVERID_LM75, diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 1770720..a2f420d 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c @@ -75,7 +75,6 @@ static struct lm77_data *lm77_update_device(struct device *dev); /* This is the driver that will be inserted */ static struct i2c_driver lm77_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm77", }, .attach_adapter = lm77_attach_adapter, diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c index 3af5b06..e404001 100644 --- a/drivers/hwmon/lm78.c +++ b/drivers/hwmon/lm78.c @@ -165,7 +165,6 @@ static void lm78_init_client(struct i2c_client *client); static struct i2c_driver lm78_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm78", }, .id = I2C_DRIVERID_LM78, @@ -175,7 +174,6 @@ static struct i2c_driver lm78_driver = { static struct i2c_driver lm78_isa_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm78-isa", }, .attach_adapter = lm78_isa_attach_adapter, diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c index 1dc118f..c9a7cde 100644 --- a/drivers/hwmon/lm80.c +++ b/drivers/hwmon/lm80.c @@ -144,7 +144,6 @@ static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value); static struct i2c_driver lm80_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm80", }, .id = I2C_DRIVERID_LM80, diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c index 1c1744f..26dfa9e 100644 --- a/drivers/hwmon/lm83.c +++ b/drivers/hwmon/lm83.c @@ -125,7 +125,6 @@ static struct lm83_data *lm83_update_device(struct device *dev); static struct i2c_driver lm83_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm83", }, .id = I2C_DRIVERID_LM83, diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index b537c18..7389a01 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -381,7 +381,6 @@ static void lm85_init_client(struct i2c_client *client); static struct i2c_driver lm85_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm85", }, .id = I2C_DRIVERID_LM85, diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index 3152c00..6ba34c3 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c @@ -162,7 +162,6 @@ static struct lm87_data *lm87_update_device(struct device *dev); static struct i2c_driver lm87_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm87", }, .id = I2C_DRIVERID_LM87, diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index ff7ba1e..56794644 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -187,7 +187,6 @@ static struct lm90_data *lm90_update_device(struct device *dev); static struct i2c_driver lm90_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm90", }, .id = I2C_DRIVERID_LM90, diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c index b4e4a84..b0c4cb7 100644 --- a/drivers/hwmon/lm92.c +++ b/drivers/hwmon/lm92.c @@ -411,7 +411,6 @@ static int lm92_detach_client(struct i2c_client *client) static struct i2c_driver lm92_driver = { .driver = { - .owner = THIS_MODULE, .name = "lm92", }, .id = I2C_DRIVERID_LM92, diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c index 1a50b13..3abe330 100644 --- a/drivers/hwmon/max1619.c +++ b/drivers/hwmon/max1619.c @@ -91,7 +91,6 @@ static struct max1619_data *max1619_update_device(struct device *dev); static struct i2c_driver max1619_driver = { .driver = { - .owner = THIS_MODULE, .name = "max1619", }, .attach_adapter = max1619_attach_adapter, diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c index 5469489..f161e88 100644 --- a/drivers/hwmon/pc87360.c +++ b/drivers/hwmon/pc87360.c @@ -237,7 +237,6 @@ static struct pc87360_data *pc87360_update_device(struct device *dev); static struct i2c_driver pc87360_driver = { .driver = { - .owner = THIS_MODULE, .name = "pc87360", }, .attach_adapter = pc87360_detect, diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c index 9f44b93..8be5189 100644 --- a/drivers/hwmon/sis5595.c +++ b/drivers/hwmon/sis5595.c @@ -199,7 +199,6 @@ static void sis5595_init_client(struct i2c_client *client); static struct i2c_driver sis5595_driver = { .driver = { - .owner = THIS_MODULE, .name = "sis5595", }, .attach_adapter = sis5595_detect, diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index 02e5d55..8663bbb 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -227,7 +227,6 @@ static int smsc47b397_detect(struct i2c_adapter *adapter); static struct i2c_driver smsc47b397_driver = { .driver = { - .owner = THIS_MODULE, .name = "smsc47b397", }, .attach_adapter = smsc47b397_detect, diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index b3051ad..d1e3ec0 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -127,7 +127,6 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, static struct i2c_driver smsc47m1_driver = { .driver = { - .owner = THIS_MODULE, .name = "smsc47m1", }, .attach_adapter = smsc47m1_detect, diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c index db75fbc..cb01848 100644 --- a/drivers/hwmon/via686a.c +++ b/drivers/hwmon/via686a.c @@ -573,7 +573,6 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); smbus_driver and isa_driver, and clients could be of either kind */ static struct i2c_driver via686a_driver = { .driver = { - .owner = THIS_MODULE, .name = "via686a", }, .attach_adapter = via686a_detect, diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index c2eb54b..d00a726 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c @@ -586,7 +586,6 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); static struct i2c_driver vt8231_driver = { .driver = { - .owner = THIS_MODULE, .name = "vt8231", }, .attach_adapter = vt8231_detect, diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 94538fb..12d79f5 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -786,7 +786,6 @@ static int w83627ehf_detach_client(struct i2c_client *client) static struct i2c_driver w83627ehf_driver = { .driver = { - .owner = THIS_MODULE, .name = "w83627ehf", }, .attach_adapter = w83627ehf_detect, diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c index 2ffb84f..7ea441d4 100644 --- a/drivers/hwmon/w83627hf.c +++ b/drivers/hwmon/w83627hf.c @@ -333,7 +333,6 @@ static void w83627hf_init_client(struct i2c_client *client); static struct i2c_driver w83627hf_driver = { .driver = { - .owner = THIS_MODULE, .name = "w83627hf", }, .attach_adapter = w83627hf_detect, diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index fd1a59c..5571148 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -270,7 +270,6 @@ static void w83781d_init_client(struct i2c_client *client); static struct i2c_driver w83781d_driver = { .driver = { - .owner = THIS_MODULE, .name = "w83781d", }, .id = I2C_DRIVERID_W83781D, @@ -280,7 +279,6 @@ static struct i2c_driver w83781d_driver = { static struct i2c_driver w83781d_isa_driver = { .driver = { - .owner = THIS_MODULE, .name = "w83781d-isa", }, .attach_adapter = w83781d_isa_attach_adapter, diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 9018445..ff1c9f0 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -318,7 +318,6 @@ static void w83792d_init_client(struct i2c_client *client); static struct i2c_driver w83792d_driver = { .driver = { - .owner = THIS_MODULE, .name = "w83792d", }, .attach_adapter = w83792d_attach_adapter, diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c index fc9f202..f66c0cf 100644 --- a/drivers/hwmon/w83l785ts.c +++ b/drivers/hwmon/w83l785ts.c @@ -93,7 +93,6 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev); static struct i2c_driver w83l785ts_driver = { .driver = { - .owner = THIS_MODULE, .name = "w83l785ts", }, .id = I2C_DRIVERID_W83L785TS, diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c index a9d4ac7..93d483b 100644 --- a/drivers/i2c/chips/ds1337.c +++ b/drivers/i2c/chips/ds1337.c @@ -53,7 +53,6 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, */ static struct i2c_driver ds1337_driver = { .driver = { - .owner = THIS_MODULE, .name = "ds1337", }, .attach_adapter = ds1337_attach_adapter, diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c index 3e3ebd8..0710b9d 100644 --- a/drivers/i2c/chips/ds1374.c +++ b/drivers/i2c/chips/ds1374.c @@ -233,7 +233,6 @@ static int ds1374_detach(struct i2c_client *client) static struct i2c_driver ds1374_driver = { .driver = { - .owner = THIS_MODULE, .name = DS1374_DRV_NAME, }, .id = I2C_DRIVERID_DS1374, diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c index d0c9f29..41116b7 100644 --- a/drivers/i2c/chips/eeprom.c +++ b/drivers/i2c/chips/eeprom.c @@ -69,7 +69,6 @@ static int eeprom_detach_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver eeprom_driver = { .driver = { - .owner = THIS_MODULE, .name = "eeprom", }, .id = I2C_DRIVERID_EEPROM, diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c index 9f1ec03..1251c7f 100644 --- a/drivers/i2c/chips/isp1301_omap.c +++ b/drivers/i2c/chips/isp1301_omap.c @@ -1633,7 +1633,6 @@ static int isp1301_scan_bus(struct i2c_adapter *bus) static struct i2c_driver isp1301_driver = { .driver = { - .owner = THIS_MODULE, .name = "isp1301_omap", }, .id = 1301, /* FIXME "official", i2c-ids.h */ diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 92759b2..2dc3d48 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c @@ -212,7 +212,6 @@ m41t00_detach(struct i2c_client *client) static struct i2c_driver m41t00_driver = { .driver = { - .owner = THIS_MODULE, .name = M41T00_DRV_NAME, }, .id = I2C_DRIVERID_STM41T00, diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c index 3705117..6d3ff58 100644 --- a/drivers/i2c/chips/max6875.c +++ b/drivers/i2c/chips/max6875.c @@ -68,7 +68,6 @@ static int max6875_detach_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver max6875_driver = { .driver = { - .owner = THIS_MODULE, .name = "max6875", }, .attach_adapter = max6875_attach_adapter, diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c index bb57faa..54b6e6a 100644 --- a/drivers/i2c/chips/pca9539.c +++ b/drivers/i2c/chips/pca9539.c @@ -39,7 +39,6 @@ static int pca9539_detach_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver pca9539_driver = { .driver = { - .owner = THIS_MODULE, .name = "pca9539", }, .attach_adapter = pca9539_attach_adapter, diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c index 3d4d4d6..c3e6449 100644 --- a/drivers/i2c/chips/pcf8574.c +++ b/drivers/i2c/chips/pcf8574.c @@ -66,7 +66,6 @@ static void pcf8574_init_client(struct i2c_client *client); /* This is the driver that will be inserted */ static struct i2c_driver pcf8574_driver = { .driver = { - .owner = THIS_MODULE, .name = "pcf8574", }, .id = I2C_DRIVERID_PCF8574, diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c index 8f41bb3..36cff09 100644 --- a/drivers/i2c/chips/pcf8591.c +++ b/drivers/i2c/chips/pcf8591.c @@ -89,7 +89,6 @@ static int pcf8591_read_channel(struct device *dev, int channel); /* This is the driver that will be inserted */ static struct i2c_driver pcf8591_driver = { .driver = { - .owner = THIS_MODULE, .name = "pcf8591", }, .id = I2C_DRIVERID_PCF8591, diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c index 6f567e2..ceaa6b0 100644 --- a/drivers/i2c/chips/rtc8564.c +++ b/drivers/i2c/chips/rtc8564.c @@ -359,7 +359,6 @@ rtc8564_command(struct i2c_client *client, unsigned int cmd, void *arg) static struct i2c_driver rtc8564_driver = { .driver = { - .owner = THIS_MODULE, .name = "RTC8564", }, .id = I2C_DRIVERID_RTC8564, diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c index 92947a6..e70b3db 100644 --- a/drivers/i2c/chips/tps65010.c +++ b/drivers/i2c/chips/tps65010.c @@ -638,7 +638,6 @@ static int __init tps65010_scan_bus(struct i2c_adapter *bus) static struct i2c_driver tps65010_driver = { .driver = { - .owner = THIS_MODULE, .name = "tps65010", }, .attach_adapter = tps65010_scan_bus, diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c index 6880eab..245fffa 100644 --- a/drivers/i2c/chips/x1205.c +++ b/drivers/i2c/chips/x1205.c @@ -106,7 +106,6 @@ static int x1205_command(struct i2c_client *client, unsigned int cmd, static struct i2c_driver x1205_driver = { .driver = { - .owner = THIS_MODULE, .name = "x1205", }, .attach_adapter = &x1205_attach, diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 9715217..e140dd7 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -482,7 +482,6 @@ static int i2cdev_command(struct i2c_client *client, unsigned int cmd, static struct i2c_driver i2cdev_driver = { .driver = { - .owner = THIS_MODULE, .name = "dev_driver", }, .id = I2C_DRIVERID_I2CDEV, diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index 8bb1d85..02a3117 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -172,7 +172,6 @@ detach_thermostat(struct i2c_adapter *adapter) static struct i2c_driver thermostat_driver = { .driver = { - .owner = THIS_MODULE, .name = "therm_adt746x", }, .attach_adapter = attach_thermostat, diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index 97807be..cf72b78 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c @@ -284,7 +284,6 @@ static int therm_pm72_detach(struct i2c_adapter *adapter); static struct i2c_driver therm_pm72_driver = { .driver = { - .owner = THIS_MODULE, .name = "therm_pm72", }, .attach_adapter = therm_pm72_attach, diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index 259f19d..3d9dd2e 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c @@ -355,7 +355,6 @@ do_detach( struct i2c_client *client ) static struct i2c_driver g4fan_driver = { .driver = { - .owner = THIS_MODULE, .name = "therm_windtunnel", }, .id = I2C_DRIVERID_G4FAN, diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c index 555d0e4..fd16642 100644 --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c @@ -48,7 +48,6 @@ static int wf_lm75_detach(struct i2c_client *client); static struct i2c_driver wf_lm75_driver = { .driver = { - .owner = THIS_MODULE, .name = "wf_lm75", }, .attach_adapter = wf_lm75_attach, diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index c5f1c6b..e61003d 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c @@ -498,7 +498,6 @@ adv7170_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_adv7170 = { .driver = { - .owner = THIS_MODULE, .name = "adv7170", /* name */ }, diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 33158aa..6d9536a 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c @@ -548,7 +548,6 @@ adv7175_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_adv7175 = { .driver = { - .owner = THIS_MODULE, .name = "adv7175", /* name */ }, diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index 5868bbb..560b998 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c @@ -623,7 +623,6 @@ bt819_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_bt819 = { .driver = { - .owner = THIS_MODULE, .name = "bt819", }, diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index 347eb71..1c3ff5f 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c @@ -231,7 +231,6 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg) static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "i2c bt832 driver", }, .id = -1, /* FIXME */ diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 207525a..6050806 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c @@ -405,7 +405,6 @@ bt856_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_bt856 = { .driver = { - .owner = THIS_MODULE, .name = "bt856", }, diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c index 60484f9..643ead1 100644 --- a/drivers/media/video/cs53l32a.c +++ b/drivers/media/video/cs53l32a.c @@ -217,7 +217,6 @@ static int cs53l32a_detach(struct i2c_client *client) /* i2c implementation */ static struct i2c_driver i2c_driver = { .driver = { - .owner = THIS_MODULE, .name = "cs53l32a", }, .id = I2C_DRIVERID_CS53L32A, diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 830d519..3b09f46 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c @@ -844,7 +844,6 @@ static int cx25840_detach_client(struct i2c_client *client) static struct i2c_driver i2c_driver_cx25840 = { .driver = { - .owner = THIS_MODULE, .name = "cx25840", }, diff --git a/drivers/media/video/indycam.c b/drivers/media/video/indycam.c index 96a808e..bb5cbec 100644 --- a/drivers/media/video/indycam.c +++ b/drivers/media/video/indycam.c @@ -452,7 +452,6 @@ static int indycam_command(struct i2c_client *client, unsigned int cmd, static struct i2c_driver i2c_driver_indycam = { .driver = { - .owner = THIS_MODULE, .name = "indycam", }, .id = I2C_DRIVERID_INDYCAM, diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index 82c7f50..3cc1d6a 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c @@ -279,7 +279,6 @@ static int ir_probe(struct i2c_adapter *adap); static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "ir remote kbd driver", }, .id = I2C_DRIVERID_INFRARED, diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index 3847d89..183253e 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -1569,7 +1569,6 @@ static struct i2c_driver driver = { .detach_client = msp_detach, .command = msp_command, .driver = { - .owner = THIS_MODULE, .name = "i2c msp3400 driver", .suspend = msp_suspend, .resume = msp_resume, diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c index 9ac398b..428f1bb 100644 --- a/drivers/media/video/ovcamchip/ovcamchip_core.c +++ b/drivers/media/video/ovcamchip/ovcamchip_core.c @@ -411,7 +411,6 @@ static int ovcamchip_command(struct i2c_client *c, unsigned int cmd, void *arg) static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "ovcamchip", }, .id = I2C_DRIVERID_OVCAMCHIP, diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index 8c99edb..135c214 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c @@ -164,7 +164,6 @@ static int saa5246a_command(struct i2c_client *device, unsigned int cmd, static struct i2c_driver i2c_driver_videotext = { .driver = { - .owner = THIS_MODULE, .name = IF_NAME, /* name */ }, .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index 5b346bd..d7c4e33 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c @@ -237,7 +237,6 @@ static int saa5249_command(struct i2c_client *device, static struct i2c_driver i2c_driver_videotext = { .driver = { - .owner = THIS_MODULE, .name = IF_NAME, /* name */ }, .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c index 5ea36ee..d60a783 100644 --- a/drivers/media/video/saa6588.c +++ b/drivers/media/video/saa6588.c @@ -496,7 +496,6 @@ static int saa6588_command(struct i2c_client *client, unsigned int cmd, static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "i2c saa6588 driver", }, .id = -1, /* FIXME */ diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 58f60ba..619ff0b 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c @@ -587,7 +587,6 @@ saa7110_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_saa7110 = { .driver = { - .owner = THIS_MODULE, .name = "saa7110", }, diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index 946eb74..acaeee5 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c @@ -590,7 +590,6 @@ saa7111_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_saa7111 = { .driver = { - .owner = THIS_MODULE, .name = "saa7111", }, diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index df53b58..b7ac012 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c @@ -1204,7 +1204,6 @@ saa7114_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_saa7114 = { .driver = { - .owner = THIS_MODULE, .name = "saa7114", }, diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index 6ac1ab4..29e28c7 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c @@ -1355,7 +1355,6 @@ static int saa7115_detach(struct i2c_client *client) /* i2c implementation */ static struct i2c_driver i2c_driver_saa7115 = { .driver = { - .owner = THIS_MODULE, .name = "saa7115", }, .id = I2C_DRIVERID_SAA711X, diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 3f7cfb7..8008537 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c @@ -565,7 +565,6 @@ saa711x_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_saa711x = { .driver = { - .owner = THIS_MODULE, .name = "saa711x", }, diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c index 659cb8a..bca6ed0 100644 --- a/drivers/media/video/saa7127.c +++ b/drivers/media/video/saa7127.c @@ -821,7 +821,6 @@ static int saa7127_detach(struct i2c_client *client) static struct i2c_driver i2c_driver_saa7127 = { .driver = { - .owner = THIS_MODULE, .name = "saa7127", }, .id = I2C_DRIVERID_SAA7127, diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c index 0e8c9ed..4615a98 100644 --- a/drivers/media/video/saa7134/saa6752hs.c +++ b/drivers/media/video/saa7134/saa6752hs.c @@ -598,7 +598,6 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg) static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "i2c saa6752hs MPEG encoder", }, .id = I2C_DRIVERID_SAA6752HS, diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 64047d77..f72a9f7 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c @@ -487,7 +487,6 @@ saa7185_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_saa7185 = { .driver = { - .owner = THIS_MODULE, .name = "saa7185", /* name */ }, diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c index a0f8eaf..41f6f05 100644 --- a/drivers/media/video/saa7191.c +++ b/drivers/media/video/saa7191.c @@ -789,7 +789,6 @@ static int saa7191_command(struct i2c_client *client, unsigned int cmd, static struct i2c_driver i2c_driver_saa7191 = { .driver = { - .owner = THIS_MODULE, .name = "saa7191", }, .id = I2C_DRIVERID_SAA7191, diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index 59674d9..549c992 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c @@ -502,7 +502,6 @@ static int tda7432_command(struct i2c_client *client, static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "i2c tda7432 driver", }, .id = I2C_DRIVERID_TDA7432, diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index 8efc726..2a353d2 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c @@ -222,7 +222,6 @@ static int detach(struct i2c_client *client) static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "tda9840", }, .id = I2C_DRIVERID_TDA9840, diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index de89616..9c3ecf7 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c @@ -373,7 +373,6 @@ static int tda9875_command(struct i2c_client *client, static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "i2c tda9875 driver", }, .id = I2C_DRIVERID_TDA9875, diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 081f478..7165a1b 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -824,7 +824,6 @@ static struct i2c_driver driver = { .detach_client = tda9887_detach, .command = tda9887_command, .driver = { - .owner = THIS_MODULE, .name = "i2c tda9887 driver", .suspend = tda9887_suspend, .resume = tda9887_resume, diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index e7e2213..17046d9 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c @@ -191,7 +191,6 @@ static int command(struct i2c_client *client, unsigned int cmd, void *arg) static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "tea6415c", }, .id = I2C_DRIVERID_TEA6415C, diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 74cc25f..3dc89d9 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c @@ -168,7 +168,6 @@ static int command(struct i2c_client *client, unsigned int cmd, void *arg) static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "tea6420", }, .id = I2C_DRIVERID_TEA6420, diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c index 83257af..d97f668 100644 --- a/drivers/media/video/tuner-3036.c +++ b/drivers/media/video/tuner-3036.c @@ -176,7 +176,6 @@ static struct i2c_driver i2c_driver_tuner = { .driver = { - .owner = THIS_MODULE, .name = "sab3036", }, .id = I2C_DRIVERID_SAB3036, diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index e8c8549..c13c7b9 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c @@ -747,7 +747,6 @@ static struct i2c_driver driver = { .detach_client = tuner_detach, .command = tuner_command, .driver = { - .owner = THIS_MODULE, .name = "tuner", .suspend = tuner_suspend, .resume = tuner_resume, diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 30bb2a3..0292c5a 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -1703,7 +1703,6 @@ static int chip_command(struct i2c_client *client, static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "generic i2c audio driver", }, .id = I2C_DRIVERID_TVAUDIO, diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index d8b5a17..8ac4cb8 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c @@ -779,7 +779,6 @@ tveeprom_detach_client (struct i2c_client *client) static struct i2c_driver i2c_driver_tveeprom = { .driver = { - .owner = THIS_MODULE, .name = "tveeprom", }, .id = I2C_DRIVERID_TVEEPROM, diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index 5f4d0185..e837f9f 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -229,7 +229,6 @@ static int tvmixer_release(struct inode *inode, struct file *file) static struct i2c_driver driver = { #ifdef I2C_PEC .driver = { - .owner = THIS_MODULE, .name = "tv card mixer driver", }, #else diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index 5eca71f..a60442e 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c @@ -801,7 +801,6 @@ static int tvp5150_detach_client(struct i2c_client *client) static struct i2c_driver driver = { .driver = { - .owner = THIS_MODULE, .name = "tvp5150", }, diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index b85b598..8dcee8b 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c @@ -722,7 +722,6 @@ vpx3220_attach_adapter (struct i2c_adapter *adapter) static struct i2c_driver vpx3220_i2c_driver = { .driver = { - .owner = THIS_MODULE, .name = "vpx3220", }, diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c index 22875f1..bbfd55c 100644 --- a/drivers/media/video/wm8775.c +++ b/drivers/media/video/wm8775.c @@ -233,7 +233,6 @@ static int wm8775_detach(struct i2c_client *client) /* i2c implementation */ static struct i2c_driver i2c_driver = { .driver = { - .owner = THIS_MODULE, .name = "wm8775", }, diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index f6fdb69..2558753 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c @@ -1294,7 +1294,6 @@ static int maven_command(struct i2c_client* client, unsigned int cmd, void* arg) static struct i2c_driver maven_driver={ .driver = { - .owner = THIS_MODULE, .name = "maven", }, .id = I2C_DRIVERID_MGATVO, diff --git a/sound/oss/dmasound/dac3550a.c b/sound/oss/dmasound/dac3550a.c index 835e0cf..7360d89 100644 --- a/sound/oss/dmasound/dac3550a.c +++ b/sound/oss/dmasound/dac3550a.c @@ -42,7 +42,6 @@ static int daca_detach_client(struct i2c_client *client); struct i2c_driver daca_driver = { .driver = { - .owner = THIS_MODULE, .name = "DAC3550A driver V " DACA_VERSION, }, .id = I2C_DRIVERID_DACA, diff --git a/sound/oss/dmasound/tas_common.c b/sound/oss/dmasound/tas_common.c index bd6910a..8131599 100644 --- a/sound/oss/dmasound/tas_common.c +++ b/sound/oss/dmasound/tas_common.c @@ -48,7 +48,6 @@ static int tas_detach_client(struct i2c_client *); struct i2c_driver tas_driver = { .driver = { - .owner = THIS_MODULE, .name = "tas", }, .attach_adapter = tas_attach_adapter, diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c index d532924..6058c2d 100644 --- a/sound/ppc/keywest.c +++ b/sound/ppc/keywest.c @@ -42,7 +42,6 @@ static int keywest_detach_client(struct i2c_client *client); struct i2c_driver keywest_driver = { .driver = { - .owner = THIS_MODULE, .name = "PMac Keywest Audio", }, .id = I2C_DRIVERID_KEYWEST, -- cgit v1.1 From d82c0bf88fa97c1993ea9d6051488e7cb012b440 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 7 Dec 2005 21:54:26 +0100 Subject: [PATCH] i2c: Documentation update Update the i2c documentation to reflect the recent change to i2c_add_driver. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/porting-clients | 5 ++--- Documentation/i2c/writing-clients | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients index f997c72..f03c2a0 100644 --- a/Documentation/i2c/porting-clients +++ b/Documentation/i2c/porting-clients @@ -126,9 +126,8 @@ Technical changes: * [Driver] The flags field of the i2c_driver structure is gone. I2C_DF_NOTIFY is now the default behavior. The i2c_driver structure has a driver member, which is itself a - structure, those owner and name members should be initialized to - THIS_MODULE and a driver name string, respectively. i2c_driver - itself has no name member anymore. + structure, those name member should be initialized to a driver name + string. i2c_driver itself has no name member anymore. Coding policy: diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 95eed2b..27c425a 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -26,7 +26,6 @@ address. static struct i2c_driver foo_driver = { .driver = { - .owner = THIS_MODULE, .name = "foo", }, .attach_adapter = &foo_attach_adapter, -- cgit v1.1 From 79472132f555ae1e912699e116e5c82f338872f6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 6 Dec 2005 15:33:15 -0800 Subject: [PATCH] I2C: move i2c-dev to use dynamic class devices i2c-dev doesn't use the reference counting logic of struct class_device so move it to the dynamic method. This makes the code paths simpler and the driver smaller. Signed-off-by: Greg Kroah-Hartman Cc: Jean Delvare --- drivers/i2c/i2c-dev.c | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index e140dd7..ad6e04f 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -42,8 +42,7 @@ static struct i2c_client i2cdev_client_template; struct i2c_dev { int minor; struct i2c_adapter *adap; - struct class_device class_dev; - struct completion released; /* FIXME, we need a class_device_unregister() */ + struct class_device *class_dev; }; #define to_i2c_dev(d) container_of(d, struct i2c_dev, class_dev) @@ -105,7 +104,10 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev) static ssize_t show_adapter_name(struct class_device *class_dev, char *buf) { - struct i2c_dev *i2c_dev = to_i2c_dev(class_dev); + struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(class_dev->devt)); + + if (!i2c_dev) + return -ENODEV; return sprintf(buf, "%s\n", i2c_dev->adap->name); } static CLASS_DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); @@ -408,21 +410,12 @@ static struct file_operations i2cdev_fops = { .release = i2cdev_release, }; -static void release_i2c_dev(struct class_device *dev) -{ - struct i2c_dev *i2c_dev = to_i2c_dev(dev); - complete(&i2c_dev->released); -} - -static struct class i2c_dev_class = { - .name = "i2c-dev", - .release = &release_i2c_dev, -}; +static struct class *i2c_dev_class; static int i2cdev_attach_adapter(struct i2c_adapter *adap) { struct i2c_dev *i2c_dev; - int retval; + struct device *dev; i2c_dev = get_free_i2c_dev(adap); if (IS_ERR(i2c_dev)) @@ -434,21 +427,20 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) /* register this i2c device with the driver core */ i2c_dev->adap = adap; if (adap->dev.parent == &platform_bus) - i2c_dev->class_dev.dev = &adap->dev; + dev = &adap->dev; else - i2c_dev->class_dev.dev = adap->dev.parent; - i2c_dev->class_dev.class = &i2c_dev_class; - i2c_dev->class_dev.devt = MKDEV(I2C_MAJOR, i2c_dev->minor); - snprintf(i2c_dev->class_dev.class_id, BUS_ID_SIZE, "i2c-%d", i2c_dev->minor); - retval = class_device_register(&i2c_dev->class_dev); - if (retval) + dev = adap->dev.parent; + i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL, + MKDEV(I2C_MAJOR, i2c_dev->minor), + dev, "i2c-%d", i2c_dev->minor); + if (!i2c_dev->class_dev) goto error; - class_device_create_file(&i2c_dev->class_dev, &class_device_attr_name); + class_device_create_file(i2c_dev->class_dev, &class_device_attr_name); return 0; error: return_i2c_dev(i2c_dev); kfree(i2c_dev); - return retval; + return -ENODEV; } static int i2cdev_detach_adapter(struct i2c_adapter *adap) @@ -459,10 +451,8 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) if (!i2c_dev) return -ENODEV; - init_completion(&i2c_dev->released); return_i2c_dev(i2c_dev); - class_device_unregister(&i2c_dev->class_dev); - wait_for_completion(&i2c_dev->released); + class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, i2c_dev->minor)); kfree(i2c_dev); pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); @@ -507,8 +497,8 @@ static int __init i2c_dev_init(void) if (res) goto out; - res = class_register(&i2c_dev_class); - if (res) + i2c_dev_class = class_create(THIS_MODULE, "i2c-dev"); + if (IS_ERR(i2c_dev_class)) goto out_unreg_chrdev; res = i2c_add_driver(&i2cdev_driver); @@ -518,7 +508,7 @@ static int __init i2c_dev_init(void) return 0; out_unreg_class: - class_unregister(&i2c_dev_class); + class_destroy(i2c_dev_class); out_unreg_chrdev: unregister_chrdev(I2C_MAJOR, "i2c"); out: @@ -529,7 +519,7 @@ out: static void __exit i2c_dev_exit(void) { i2c_del_driver(&i2cdev_driver); - class_unregister(&i2c_dev_class); + class_destroy(i2c_dev_class); unregister_chrdev(I2C_MAJOR,"i2c"); } -- cgit v1.1 From c9152deaa635cab09cb43c17cf80130b9e6ee29d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 18 Dec 2005 16:29:40 +0100 Subject: [PATCH] hwmon: w83792d misc cleanups Cleanup the w83792d driver a bit: * Discard unused lock and irrelevant comments inherited from the w83781d driver. * Simplify w83792d_{read,write}_value functions. * Drop useless address test during detection. * Drop useless bitmasking. Signed-off-by: Jean Delvare Acked-by: Yuan Mu Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/w83792d.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index ff1c9f0..0ad1ae5 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -269,7 +269,6 @@ DIV_TO_REG(long val) struct w83792d_data { struct i2c_client client; struct class_device *class_dev; - struct semaphore lock; enum chips type; struct semaphore update_lock; @@ -1192,7 +1191,6 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) new_client = &data->client; i2c_set_clientdata(new_client, data); new_client->addr = address; - init_MUTEX(&data->lock); new_client->adapter = adapter; new_client->driver = &w83792d_driver; new_client->flags = 0; @@ -1243,7 +1241,7 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind) goto ERROR1; } val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID); - if (val1 == 0x7a && address >= 0x2c) { + if (val1 == 0x7a) { kind = w83792d; } else { if (kind == 0) @@ -1416,26 +1414,17 @@ w83792d_detach_client(struct i2c_client *client) return 0; } -/* The SMBus locks itself, usually, but nothing may access the Winbond between - bank switches. ISA access must always be locked explicitly! - We ignore the W83792D BUSY flag at this moment - it could lead to deadlocks, - would slow down the W83792D access and should not be necessary. - There are some ugly typecasts here, but the good news is - they should - nowhere else be necessary! */ -static int -w83792d_read_value(struct i2c_client *client, u8 reg) +/* The SMBus locks itself. The Winbond W83792D chip has a bank register, + but the driver only accesses registers in bank 0, so we don't have + to switch banks and lock access between switches. */ +static int w83792d_read_value(struct i2c_client *client, u8 reg) { - int res=0; - res = i2c_smbus_read_byte_data(client, reg); - - return res; + return i2c_smbus_read_byte_data(client, reg); } -static int -w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) +static int w83792d_write_value(struct i2c_client *client, u8 reg, u8 value) { - i2c_smbus_write_byte_data(client, reg, value); - return 0; + return i2c_smbus_write_byte_data(client, reg, value); } static void @@ -1506,7 +1495,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) pwm_array_tmp[i] = w83792d_read_value(client, W83792D_REG_PWM[i]); data->pwm[i] = pwm_array_tmp[i] & 0x0f; - data->pwm_mode[i] = (pwm_array_tmp[i] >> 7) & 0x01; + data->pwm_mode[i] = pwm_array_tmp[i] >> 7; } reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG); -- cgit v1.1 From 99d855602c1d7968ca6b6cc99b773b0b47909690 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 18 Dec 2005 16:34:28 +0100 Subject: [PATCH] hwmon: w83792d simplify in low bits handling Simplify the way the w83792d driver handles the extra resolution bits of voltage input channels. Signed-off-by: Jean Delvare Acked-by: Yuan Mu Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/w83792d.c | 48 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 0ad1ae5..b176bf0 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -281,7 +281,7 @@ struct w83792d_data { u8 in[9]; /* Register value */ u8 in_max[9]; /* Register value */ u8 in_min[9]; /* Register value */ - u8 low_bits[2]; /* Additional resolution to voltage in0-6 */ + u16 low_bits; /* Additional resolution to voltage in6-0 */ u8 fan[7]; /* Register value */ u8 fan_min[7]; /* Register value */ u8 temp1[3]; /* current, over, thyst */ @@ -323,38 +323,10 @@ static struct i2c_driver w83792d_driver = { .detach_client = w83792d_detach_client, }; -static long in_count_from_reg(int nr, struct w83792d_data *data) +static inline long in_count_from_reg(int nr, struct w83792d_data *data) { - u16 vol_count = data->in[nr]; - u16 low_bits = 0; - vol_count = (vol_count << 2); - switch (nr) - { - case 0: /* vin0 */ - low_bits = (data->low_bits[0]) & 0x03; - break; - case 1: /* vin1 */ - low_bits = ((data->low_bits[0]) & 0x0c) >> 2; - break; - case 2: /* vin2 */ - low_bits = ((data->low_bits[0]) & 0x30) >> 4; - break; - case 3: /* vin3 */ - low_bits = ((data->low_bits[0]) & 0xc0) >> 6; - break; - case 4: /* vin4 */ - low_bits = (data->low_bits[1]) & 0x03; - break; - case 5: /* vin5 */ - low_bits = ((data->low_bits[1]) & 0x0c) >> 2; - break; - case 6: /* vin6 */ - low_bits = ((data->low_bits[1]) & 0x30) >> 4; - default: - break; - } - vol_count = vol_count | low_bits; - return vol_count; + /* in7 and in8 do not have low bits, but the formula still works */ + return ((data->in[nr] << 2) | ((data->low_bits >> (2 * nr)) & 0x03)); } /* following are the sysfs callback functions */ @@ -1481,10 +1453,10 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) data->in_min[i] = w83792d_read_value(client, W83792D_REG_IN_MIN[i]); } - data->low_bits[0] = w83792d_read_value(client, - W83792D_REG_LOW_BITS1); - data->low_bits[1] = w83792d_read_value(client, - W83792D_REG_LOW_BITS2); + data->low_bits = w83792d_read_value(client, + W83792D_REG_LOW_BITS1) + + (w83792d_read_value(client, + W83792D_REG_LOW_BITS2) << 8); for (i = 0; i < 7; i++) { /* Update the Fan measured value and limits */ data->fan[i] = w83792d_read_value(client, @@ -1596,8 +1568,8 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); } - dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits[0]); - dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits[1]); + dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits & 0xff); + dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits >> 8); dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); for (i=0; i<7; i++) { dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); -- cgit v1.1 From 734a12a36676ad3b9418fa5a829c518afec02b8a Mon Sep 17 00:00:00 2001 From: Rudolf Marek Date: Sun, 18 Dec 2005 16:36:52 +0100 Subject: [PATCH] hwmon: add VRM/VID support for some VIA CPUs This patch adds the VIA CENTAUR CPUs to detection table. Table was updated to treat future Intel x86 CPUs as VRD10. Stepping field was added, because some VIA CPUs have different VRM specs across stepping. I changed the vrm type to u8 because all drivers use u8 anyway. Signed-off-by: Rudolf Marek Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/hwmon-vid.c | 69 ++++++++++++++++++++++++++++------------------- include/linux/hwmon-vid.h | 6 ++--- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c index 312769a..e497274 100644 --- a/drivers/hwmon/hwmon-vid.c +++ b/drivers/hwmon/hwmon-vid.c @@ -49,20 +49,22 @@ . . . . 11110 = 0.800 V 11111 = 0.000 V (off) + + The 17 specification is in fact Intel Mobile Voltage Positioning - + (IMVP-II). You can find more information in the datasheet of Max1718 + http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452 + */ /* vrm is the VRM/VRD document version multiplied by 10. val is the 4-, 5- or 6-bit VID code. Returned value is in mV to avoid floating point in the kernel. */ -int vid_from_reg(int val, int vrm) +int vid_from_reg(int val, u8 vrm) { int vid; switch(vrm) { - case 0: - return 0; - case 100: /* VRD 10.0 */ if((val & 0x1f) == 0x1f) return 0; @@ -91,10 +93,16 @@ int vid_from_reg(int val, int vrm) case 84: /* VRM 8.4 */ val &= 0x0f; /* fall through */ - default: /* VRM 8.2 */ + case 82: /* VRM 8.2 */ return(val == 0x1f ? 0 : val & 0x10 ? 5100 - (val) * 100 : 2050 - (val) * 50); + case 17: /* Intel IMVP-II */ + return(val & 0x10 ? 975 - (val & 0xF) * 25 : + 1750 - val * 50); + default: /* report 0 for unknown */ + printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n"); + return 0; } } @@ -108,30 +116,36 @@ struct vrm_model { u8 vendor; u8 eff_family; u8 eff_model; - int vrm_type; + u8 eff_stepping; + u8 vrm_type; }; #define ANY 0xFF #ifdef CONFIG_X86 +/* the stepping parameter is highest acceptable stepping for current line */ + static struct vrm_model vrm_models[] = { - {X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */ - {X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */ - {X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */ - {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* Tualatin */ - {X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */ - {X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */ - {X86_VENDOR_INTEL, 0xF, 0x0, 90}, /* P4 */ - {X86_VENDOR_INTEL, 0xF, 0x1, 90}, /* P4 Willamette */ - {X86_VENDOR_INTEL, 0xF, 0x2, 90}, /* P4 Northwood */ - {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */ - {X86_VENDOR_INTEL, 0xF, 0x4, 100}, /* P4 Prescott */ - {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */ - {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */ + {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */ + {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */ + {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */ + {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */ + {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */ + {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */ + {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */ + {X86_VENDOR_INTEL, 0xF, 0x1, ANY, 90}, /* P4 Willamette */ + {X86_VENDOR_INTEL, 0xF, 0x2, ANY, 90}, /* P4 Northwood */ + {X86_VENDOR_INTEL, 0xF, ANY, ANY, 100}, /* Prescott and above assume VRD 10 */ + {X86_VENDOR_INTEL, 0x10, ANY, ANY, 0}, /* Itanium 2 */ + {X86_VENDOR_CENTAUR, 0x6, 0x7, ANY, 85}, /* Eden ESP/Ezra */ + {X86_VENDOR_CENTAUR, 0x6, 0x8, 0x7, 85}, /* Ezra T */ + {X86_VENDOR_CENTAUR, 0x6, 0x9, 0x7, 85}, /* Nemiah */ + {X86_VENDOR_CENTAUR, 0x6, 0x9, ANY, 17}, /* C3-M */ + {X86_VENDOR_UNKNOWN, ANY, ANY, ANY, 0} /* stop here */ }; -static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) +static u8 find_vrm(u8 eff_family, u8 eff_model, u8 eff_stepping, u8 vendor) { int i = 0; @@ -139,7 +153,8 @@ static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) if (vrm_models[i].vendor==vendor) if ((vrm_models[i].eff_family==eff_family) && ((vrm_models[i].eff_model==eff_model) || - (vrm_models[i].eff_model==ANY))) + (vrm_models[i].eff_model==ANY)) && + (eff_stepping <= vrm_models[i].eff_stepping)) return vrm_models[i].vrm_type; i++; } @@ -147,12 +162,11 @@ static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) return 0; } -int vid_which_vrm(void) +u8 vid_which_vrm(void) { struct cpuinfo_x86 *c = cpu_data; u32 eax; - u8 eff_family, eff_model; - int vrm_ret; + u8 eff_family, eff_model, eff_stepping, vrm_ret; if (c->x86 < 6) /* Any CPU with family lower than 6 */ return 0; /* doesn't have VID and/or CPUID */ @@ -160,20 +174,21 @@ int vid_which_vrm(void) eax = cpuid_eax(1); eff_family = ((eax & 0x00000F00)>>8); eff_model = ((eax & 0x000000F0)>>4); + eff_stepping = eax & 0xF; if (eff_family == 0xF) { /* use extended model & family */ eff_family += ((eax & 0x00F00000)>>20); eff_model += ((eax & 0x000F0000)>>16)<<4; } - vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor); + vrm_ret = find_vrm(eff_family, eff_model, eff_stepping, c->x86_vendor); if (vrm_ret == 0) printk(KERN_INFO "hwmon-vid: Unknown VRM version of your " "x86 CPU\n"); return vrm_ret; } -/* and now something completely different for the non-x86 world */ +/* and now for something completely different for the non-x86 world */ #else -int vid_which_vrm(void) +u8 vid_which_vrm(void) { printk(KERN_INFO "hwmon-vid: Unknown VRM version of your CPU\n"); return 0; diff --git a/include/linux/hwmon-vid.h b/include/linux/hwmon-vid.h index cd4b7a0..f346e4d 100644 --- a/include/linux/hwmon-vid.h +++ b/include/linux/hwmon-vid.h @@ -23,14 +23,14 @@ #ifndef _LINUX_HWMON_VID_H #define _LINUX_HWMON_VID_H -int vid_from_reg(int val, int vrm); -int vid_which_vrm(void); +int vid_from_reg(int val, u8 vrm); +u8 vid_which_vrm(void); /* vrm is the VRM/VRD document version multiplied by 10. val is in mV to avoid floating point in the kernel. Returned value is the 4-, 5- or 6-bit VID code. Note that only VRM 9.x is supported for now. */ -static inline int vid_to_reg(int val, int vrm) +static inline int vid_to_reg(int val, u8 vrm) { switch (vrm) { case 91: /* VRM 9.1 */ -- cgit v1.1 From a7be58a126d4cd9f0588df23f58796ed996c1835 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 18 Dec 2005 16:40:14 +0100 Subject: [PATCH] hwmon: it87 use u8 for vrm VRM values fit in u8 by design now. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/it87.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c index 29b74a8..0da7c9c 100644 --- a/drivers/hwmon/it87.c +++ b/drivers/hwmon/it87.c @@ -213,7 +213,7 @@ struct it87_data { u8 sensor; /* Register value */ u8 fan_div[3]; /* Register encoding, shifted right */ u8 vid; /* Register encoding, combined */ - int vrm; + u8 vrm; u32 alarms; /* Register encoding, combined */ u8 fan_main_ctrl; /* Register value */ u8 manual_pwm_ctl[3]; /* manual PWM value set by user */ @@ -669,7 +669,7 @@ static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) { struct it87_data *data = it87_update_device(dev); - return sprintf(buf, "%ld\n", (long) data->vrm); + return sprintf(buf, "%u\n", data->vrm); } static ssize_t store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) -- cgit v1.1 From 04b4b8434a92b9ef127985113c0bd961957778b7 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 18 Dec 2005 16:42:35 +0100 Subject: [PATCH] i2c: driver ID list cleanups Cleanups to i2c driver ID list: * Remove mostly bogus comments about driver ID ranges. * Drop experimental driver IDs, as the concept is pretty broken. * Drop now unused IDs of non-I2C (ISA) drivers. * Drop a few more IDs which are no more used. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- include/linux/i2c-id.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index 006c81e..fb46f8d 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h @@ -25,12 +25,6 @@ /* * ---- Driver types ----------------------------------------------------- - * device id name + number function description, i2c address(es) - * - * Range 1000-1999 range is defined in sensors/sensors.h - * Range 0x100 - 0x1ff is for V4L2 Common Components - * Range 0xf000 - 0xffff is reserved for local experimentation, and should - * never be used in official drivers */ #define I2C_DRIVERID_MSP3400 1 @@ -110,13 +104,7 @@ #define I2C_DRIVERID_AKITAIOEXP 74 /* IO Expander on Sharp SL-C1000 */ #define I2C_DRIVERID_INFRARED 75 /* I2C InfraRed on Video boards */ -#define I2C_DRIVERID_EXP0 0xF0 /* experimental use id's */ -#define I2C_DRIVERID_EXP1 0xF1 -#define I2C_DRIVERID_EXP2 0xF2 -#define I2C_DRIVERID_EXP3 0xF3 - #define I2C_DRIVERID_I2CDEV 900 -#define I2C_DRIVERID_I2CPROC 901 #define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */ #define I2C_DRIVERID_ALERT 903 /* SMBus Alert Responder Client */ @@ -131,15 +119,12 @@ #define I2C_DRIVERID_ADM1021 1008 #define I2C_DRIVERID_ADM9240 1009 #define I2C_DRIVERID_LTC1710 1010 -#define I2C_DRIVERID_SIS5595 1011 #define I2C_DRIVERID_ICSPLL 1012 #define I2C_DRIVERID_BT869 1013 #define I2C_DRIVERID_MAXILIFE 1014 #define I2C_DRIVERID_MATORB 1015 #define I2C_DRIVERID_GL520 1016 #define I2C_DRIVERID_THMC50 1017 -#define I2C_DRIVERID_DDCMON 1018 -#define I2C_DRIVERID_VIA686A 1019 #define I2C_DRIVERID_ADM1025 1020 #define I2C_DRIVERID_LM87 1021 #define I2C_DRIVERID_PCF8574 1022 @@ -151,21 +136,16 @@ #define I2C_DRIVERID_FSCPOS 1028 #define I2C_DRIVERID_FSCSCY 1029 #define I2C_DRIVERID_PCF8591 1030 -#define I2C_DRIVERID_SMSC47M1 1031 -#define I2C_DRIVERID_VT1211 1032 #define I2C_DRIVERID_LM92 1033 -#define I2C_DRIVERID_VT8231 1034 #define I2C_DRIVERID_SMARTBATT 1035 #define I2C_DRIVERID_BMCSENSORS 1036 #define I2C_DRIVERID_FS451 1037 -#define I2C_DRIVERID_W83627HF 1038 #define I2C_DRIVERID_LM85 1039 #define I2C_DRIVERID_LM83 1040 #define I2C_DRIVERID_LM90 1042 #define I2C_DRIVERID_ASB100 1043 #define I2C_DRIVERID_FSCHER 1046 #define I2C_DRIVERID_W83L785TS 1047 -#define I2C_DRIVERID_SMSC47B397 1050 /* * ---- Adapter types ---------------------------------------------------- -- cgit v1.1 From d564baee2984098c73fd0e55bc5c8a890878ef3b Mon Sep 17 00:00:00 2001 From: Laurent Riffard Date: Sun, 18 Dec 2005 16:49:30 +0100 Subject: [PATCH] i2c: drop empty i2c_driver.command implementations Given that implementing i2c_driver.command is optional, there is no point in an empty implementation thereof. Signed-off-by: Laurent Riffard Signed-off-by: Jean Delvare Cc: Michael Geng Cc: Petr Vandrovec Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-dev.c | 7 ------- drivers/media/video/saa5246a.c | 7 ------- drivers/media/video/saa5249.c | 7 ------- drivers/video/matrox/matroxfb_maven.c | 5 ----- 4 files changed, 26 deletions(-) diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index ad6e04f..ed7eed3 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -464,12 +464,6 @@ static int i2cdev_detach_client(struct i2c_client *client) return 0; } -static int i2cdev_command(struct i2c_client *client, unsigned int cmd, - void *arg) -{ - return -1; -} - static struct i2c_driver i2cdev_driver = { .driver = { .name = "dev_driver", @@ -478,7 +472,6 @@ static struct i2c_driver i2cdev_driver = { .attach_adapter = i2cdev_attach_adapter, .detach_adapter = i2cdev_detach_adapter, .detach_client = i2cdev_detach_client, - .command = i2cdev_command, }; static struct i2c_client i2cdev_client_template = { diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c index 135c214..0aa9e72 100644 --- a/drivers/media/video/saa5246a.c +++ b/drivers/media/video/saa5246a.c @@ -151,12 +151,6 @@ static int saa5246a_detach(struct i2c_client *client) return 0; } -static int saa5246a_command(struct i2c_client *device, unsigned int cmd, - void *arg) -{ - return -EINVAL; -} - /* * I2C interfaces */ @@ -169,7 +163,6 @@ static struct i2c_driver i2c_driver_videotext = .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ .attach_adapter = saa5246a_probe, .detach_client = saa5246a_detach, - .command = saa5246a_command }; static struct i2c_client client_template = { diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index d7c4e33..a51c7bd 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c @@ -226,12 +226,6 @@ static int saa5249_detach(struct i2c_client *client) return 0; } -static int saa5249_command(struct i2c_client *device, - unsigned int cmd, void *arg) -{ - return -EINVAL; -} - /* new I2C driver support */ static struct i2c_driver i2c_driver_videotext = @@ -242,7 +236,6 @@ static struct i2c_driver i2c_driver_videotext = .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ .attach_adapter = saa5249_probe, .detach_client = saa5249_detach, - .command = saa5249_command }; static struct i2c_client client_template = { diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c index 2558753..a1f2c5e 100644 --- a/drivers/video/matrox/matroxfb_maven.c +++ b/drivers/video/matrox/matroxfb_maven.c @@ -1288,10 +1288,6 @@ static int maven_detach_client(struct i2c_client* client) { return 0; } -static int maven_command(struct i2c_client* client, unsigned int cmd, void* arg) { - return -ENOIOCTLCMD; /* or -EINVAL, depends on who will call this */ -} - static struct i2c_driver maven_driver={ .driver = { .name = "maven", @@ -1299,7 +1295,6 @@ static struct i2c_driver maven_driver={ .id = I2C_DRIVERID_MGATVO, .attach_adapter = maven_attach_adapter, .detach_client = maven_detach_client, - .command = maven_command, }; /* ************************** */ -- cgit v1.1 From fb687d73fa7685ffeed1a6b24fadb5f4db817783 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 18 Dec 2005 16:51:55 +0100 Subject: [PATCH] i2c: update i2c_driver.command documentation Document i2c_driver.command as being deprecated, and don't suggest an empty implementation of this callback as it doesn't make any sense. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/writing-clients | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients index 27c425a..3a057c8 100644 --- a/Documentation/i2c/writing-clients +++ b/Documentation/i2c/writing-clients @@ -492,17 +492,13 @@ Note that some functions are marked by `__init', and some data structures by `__init_data'. Hose functions and structures can be removed after kernel booting (or module loading) is completed. + Command function ================ A generic ioctl-like function call back is supported. You will seldom -need this. You may even set it to NULL. - - /* No commands defined */ - int foo_command(struct i2c_client *client, unsigned int cmd, void *arg) - { - return 0; - } +need this, and its use is deprecated anyway, so newer design should not +use it. Set it to NULL. Sending and receiving -- cgit v1.1 From 3fb81a3df63e1900a7b3f496806a3f8d2b4295dd Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 18 Dec 2005 17:11:51 +0100 Subject: [PATCH] i2c: I2C_DF_NOTIFY removal comment cleanups The removal of I2C_DF_NOTIFY left some out of date comments in the code. Drop them. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-core.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index c23443e..52b7747 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -246,10 +246,6 @@ int i2c_del_adapter(struct i2c_adapter *adap) list_for_each_safe(item, _n, &adap->clients) { client = list_entry(item, struct i2c_client, list); - /* detaching devices is unconditional of the set notify - * flag, as _all_ clients that reside on the adapter - * must be deleted, as this would cause invalid states. - */ if ((res=client->driver->detach_client(client))) { dev_err(&adap->dev, "detach_client failed for client " "[%s] at address 0x%02x\n", client->name, @@ -335,10 +331,6 @@ int i2c_del_driver(struct i2c_driver *driver) /* Have a look at each adapter, if clients of this driver are still * attached. If so, detach them to be able to kill the driver * afterwards. - * - * Removing clients does not depend on the notify flag, else - * invalid operation might (will!) result, when using stale client - * pointers. */ list_for_each(item1,&adapters) { adap = list_entry(item1, struct i2c_adapter, list); -- cgit v1.1 From a4787c0d232e16e727b37205dc647337b8974f35 Mon Sep 17 00:00:00 2001 From: Martin Hicks Date: Sun, 18 Dec 2005 17:18:01 +0100 Subject: [PATCH] i2c: i2c-ibm_iic add I2C_CLASS_HWMON Add the ibm_iic driver to the HWMON class so it will scan the bus for connected hardware monitor sensors. Signed-off-by: Martin Hicks Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-ibm_iic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 1a58725..87fae93 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c @@ -725,6 +725,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){ strcpy(adap->name, "IBM IIC"); i2c_set_adapdata(adap, dev); adap->id = I2C_HW_OCP; + adap->class = I2C_CLASS_HWMON; adap->algo = &iic_algo; adap->client_register = NULL; adap->client_unregister = NULL; -- cgit v1.1 From 7c72ccf09b6debe55b8e049377ad3183ed4f4cb3 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 18 Dec 2005 17:25:18 +0100 Subject: [PATCH] i2c: i2c-nforce2 add nforce4 MCP-04 device ID One more supported PCI ID for the i2c-nforce2 driver. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- Documentation/i2c/busses/i2c-nforce2 | 3 ++- drivers/i2c/busses/i2c-nforce2.c | 2 ++ include/linux/pci_ids.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/i2c/busses/i2c-nforce2 b/Documentation/i2c/busses/i2c-nforce2 index e379e18..d751282 100644 --- a/Documentation/i2c/busses/i2c-nforce2 +++ b/Documentation/i2c/busses/i2c-nforce2 @@ -5,7 +5,8 @@ Supported adapters: * nForce2 Ultra 400 MCP 10de:0084 * nForce3 Pro150 MCP 10de:00D4 * nForce3 250Gb MCP 10de:00E4 - * nForce4 MCP 10de:0052 + * nForce4 MCP 10de:0052 + * nForce4 MCP-04 10de:0034 Datasheet: not publically available, but seems to be similar to the AMD-8111 SMBus 2.0 adapter. diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 4d18e6e5..2d80eb2 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c @@ -30,6 +30,7 @@ nForce3 Pro150 MCP 00D4 nForce3 250Gb MCP 00E4 nForce4 MCP 0052 + nForce4 MCP-04 0034 This driver supports the 2 SMBuses that are included in the MCP of the nForce2/3/4 chipsets. @@ -257,6 +258,7 @@ static struct pci_device_id nforce2_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS) }, { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS) }, { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS) }, + { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS) }, { 0 } }; diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 4f01710..96a0403 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -976,6 +976,7 @@ #define PCI_DEVICE_ID_NVIDIA_TNT_UNKNOWN 0x002a #define PCI_DEVICE_ID_NVIDIA_VTNT2 0x002C #define PCI_DEVICE_ID_NVIDIA_UVTNT2 0x002D +#define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS 0x0034 #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE 0x0035 #define PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SATA 0x0036 #define PCI_DEVICE_ID_NVIDIA_NVENET_10 0x0037 -- cgit v1.1 From e91c021c487110386a07facd0396e6c3b7cf9c1f Mon Sep 17 00:00:00 2001 From: "Mark A. Greer" Date: Sun, 18 Dec 2005 17:22:01 +0100 Subject: [PATCH] i2c: i2c-mv64xxx fix transaction abortion When the i2c-mv64xxx i2c driver is signalled to abort a transaction, it aborts it immediately by issuing a stop condition on the bus. This violates the i2c protocol and can cause what appears to be an i2c bus hang. This patch delays issuing the stop condition until the i2c device can reasonably expect a stop condition. Also includes a minor fixup. Signed-off-by: Mark A. Greer Signed-off-by: Jean Delvare --- drivers/i2c/busses/i2c-mv64xxx.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 81031eb..22781d8 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -1,6 +1,4 @@ /* - * drivers/i2c/busses/i2c-mv64xxx.c - * * Driver for the i2c controller on the Marvell line of host bridges for MIPS * and PPC (e.g, gt642[46]0, mv643[46]0, mv644[46]0). * @@ -65,7 +63,6 @@ enum { MV64XXX_I2C_STATE_WAITING_FOR_ADDR_2_ACK, MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_ACK, MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA, - MV64XXX_I2C_STATE_ABORTING, }; /* Driver actions */ @@ -85,6 +82,7 @@ struct mv64xxx_i2c_data { int irq; u32 state; u32 action; + u32 aborting; u32 cntl_bits; void __iomem *reg_base; u32 reg_base_p; @@ -122,12 +120,6 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) return; } - if (drv_data->state == MV64XXX_I2C_STATE_ABORTING) { - drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; - drv_data->state = MV64XXX_I2C_STATE_IDLE; - return; - } - /* The status from the ctlr [mostly] tells us what to do next */ switch (status) { /* Start condition interrupt */ @@ -148,14 +140,16 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) /* FALLTHRU */ case MV64XXX_I2C_STATUS_MAST_WR_ADDR_2_ACK: /* 0xd0 */ case MV64XXX_I2C_STATUS_MAST_WR_ACK: /* 0x28 */ - if (drv_data->bytes_left > 0) { + if ((drv_data->bytes_left == 0) + || (drv_data->aborting + && (drv_data->byte_posn != 0))) { + drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; + drv_data->state = MV64XXX_I2C_STATE_IDLE; + } else { drv_data->action = MV64XXX_I2C_ACTION_SEND_DATA; drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_ACK; drv_data->bytes_left--; - } else { - drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP; - drv_data->state = MV64XXX_I2C_STATE_IDLE; } break; @@ -184,7 +178,7 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) } drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA; - if (drv_data->bytes_left == 1) + if ((drv_data->bytes_left == 1) || drv_data->aborting) drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_ACK; break; @@ -320,6 +314,7 @@ mv64xxx_i2c_prepare_for_io(struct mv64xxx_i2c_data *drv_data, drv_data->msg = msg; drv_data->byte_posn = 0; drv_data->bytes_left = msg->len; + drv_data->aborting = 0; drv_data->rc = 0; drv_data->cntl_bits = MV64XXX_I2C_REG_CONTROL_ACK | MV64XXX_I2C_REG_CONTROL_INTEN | MV64XXX_I2C_REG_CONTROL_TWSIEN; @@ -359,17 +354,19 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data) } if (abort && drv_data->block) { - drv_data->state = MV64XXX_I2C_STATE_ABORTING; + drv_data->aborting = 1; spin_unlock_irqrestore(&drv_data->lock, flags); time_left = wait_event_timeout(drv_data->waitq, !drv_data->block, msecs_to_jiffies(drv_data->adapter.timeout)); - if (time_left <= 0) { + if ((time_left <= 0) && drv_data->block) { drv_data->state = MV64XXX_I2C_STATE_IDLE; dev_err(&drv_data->adapter.dev, - "mv64xxx: I2C bus locked\n"); + "mv64xxx: I2C bus locked, block: %d, " + "time_left: %d\n", drv_data->block, + (int)time_left); } } else spin_unlock_irqrestore(&drv_data->lock, flags); @@ -510,7 +507,7 @@ mv64xxx_i2c_probe(struct platform_device *pd) goto exit_kfree; } - strncpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", + strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", I2C_NAME_SIZE); init_waitqueue_head(&drv_data->waitq); -- cgit v1.1 From ef9be1d336378de279d4e37779f1b83cebadbcc0 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 11 Nov 2005 14:27:09 +0100 Subject: [BLOCK] as-iosched: update alias handling Unlike other ioscheds, as-iosched handles alias by chaing them using rq->queuelist. As aliased requests are very rare in the first place, this complicates merge/dispatch handling without meaningful performance improvement. This patch updates as-iosched to dump aliased requests into dispatch queue as other ioscheds do. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- block/as-iosched.c | 144 ++++++++++------------------------------------------- 1 file changed, 25 insertions(+), 119 deletions(-) diff --git a/block/as-iosched.c b/block/as-iosched.c index 43fa204..8da3cf6 100644 --- a/block/as-iosched.c +++ b/block/as-iosched.c @@ -182,6 +182,9 @@ struct as_rq { static kmem_cache_t *arq_pool; +static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq); +static void as_antic_stop(struct as_data *ad); + /* * IO Context helper functions */ @@ -370,7 +373,7 @@ static struct as_rq *as_find_first_arq(struct as_data *ad, int data_dir) * existing request against the same sector), which can happen when using * direct IO, then return the alias. */ -static struct as_rq *as_add_arq_rb(struct as_data *ad, struct as_rq *arq) +static struct as_rq *__as_add_arq_rb(struct as_data *ad, struct as_rq *arq) { struct rb_node **p = &ARQ_RB_ROOT(ad, arq)->rb_node; struct rb_node *parent = NULL; @@ -397,6 +400,16 @@ static struct as_rq *as_add_arq_rb(struct as_data *ad, struct as_rq *arq) return NULL; } +static void as_add_arq_rb(struct as_data *ad, struct as_rq *arq) +{ + struct as_rq *alias; + + while ((unlikely(alias = __as_add_arq_rb(ad, arq)))) { + as_move_to_dispatch(ad, alias); + as_antic_stop(ad); + } +} + static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq) { if (!ON_RB(&arq->rb_node)) { @@ -1133,23 +1146,6 @@ static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq) /* * take it off the sort and fifo list, add to dispatch queue */ - while (!list_empty(&rq->queuelist)) { - struct request *__rq = list_entry_rq(rq->queuelist.next); - struct as_rq *__arq = RQ_DATA(__rq); - - list_del(&__rq->queuelist); - - elv_dispatch_add_tail(ad->q, __rq); - - if (__arq->io_context && __arq->io_context->aic) - atomic_inc(&__arq->io_context->aic->nr_dispatched); - - WARN_ON(__arq->state != AS_RQ_QUEUED); - __arq->state = AS_RQ_DISPATCHED; - - ad->nr_dispatched++; - } - as_remove_queued_request(ad->q, rq); WARN_ON(arq->state != AS_RQ_QUEUED); @@ -1326,49 +1322,12 @@ fifo_expired: } /* - * Add arq to a list behind alias - */ -static inline void -as_add_aliased_request(struct as_data *ad, struct as_rq *arq, - struct as_rq *alias) -{ - struct request *req = arq->request; - struct list_head *insert = alias->request->queuelist.prev; - - /* - * Transfer list of aliases - */ - while (!list_empty(&req->queuelist)) { - struct request *__rq = list_entry_rq(req->queuelist.next); - struct as_rq *__arq = RQ_DATA(__rq); - - list_move_tail(&__rq->queuelist, &alias->request->queuelist); - - WARN_ON(__arq->state != AS_RQ_QUEUED); - } - - /* - * Another request with the same start sector on the rbtree. - * Link this request to that sector. They are untangled in - * as_move_to_dispatch - */ - list_add(&arq->request->queuelist, insert); - - /* - * Don't want to have to handle merges. - */ - as_del_arq_hash(arq); - arq->request->flags |= REQ_NOMERGE; -} - -/* * add arq to rbtree and fifo */ static void as_add_request(request_queue_t *q, struct request *rq) { struct as_data *ad = q->elevator->elevator_data; struct as_rq *arq = RQ_DATA(rq); - struct as_rq *alias; int data_dir; arq->state = AS_RQ_NEW; @@ -1387,33 +1346,17 @@ static void as_add_request(request_queue_t *q, struct request *rq) atomic_inc(&arq->io_context->aic->nr_queued); } - alias = as_add_arq_rb(ad, arq); - if (!alias) { - /* - * set expire time (only used for reads) and add to fifo list - */ - arq->expires = jiffies + ad->fifo_expire[data_dir]; - list_add_tail(&arq->fifo, &ad->fifo_list[data_dir]); + as_add_arq_rb(ad, arq); + if (rq_mergeable(arq->request)) + as_add_arq_hash(ad, arq); - if (rq_mergeable(arq->request)) - as_add_arq_hash(ad, arq); - as_update_arq(ad, arq); /* keep state machine up to date */ - - } else { - as_add_aliased_request(ad, arq, alias); - - /* - * have we been anticipating this request? - * or does it come from the same process as the one we are - * anticipating for? - */ - if (ad->antic_status == ANTIC_WAIT_REQ - || ad->antic_status == ANTIC_WAIT_NEXT) { - if (as_can_break_anticipation(ad, arq)) - as_antic_stop(ad); - } - } + /* + * set expire time (only used for reads) and add to fifo list + */ + arq->expires = jiffies + ad->fifo_expire[data_dir]; + list_add_tail(&arq->fifo, &ad->fifo_list[data_dir]); + as_update_arq(ad, arq); /* keep state machine up to date */ arq->state = AS_RQ_QUEUED; } @@ -1536,23 +1479,8 @@ static void as_merged_request(request_queue_t *q, struct request *req) * if the merge was a front merge, we need to reposition request */ if (rq_rb_key(req) != arq->rb_key) { - struct as_rq *alias, *next_arq = NULL; - - if (ad->next_arq[arq->is_sync] == arq) - next_arq = as_find_next_arq(ad, arq); - - /* - * Note! We should really be moving any old aliased requests - * off this request and try to insert them into the rbtree. We - * currently don't bother. Ditto the next function. - */ as_del_arq_rb(ad, arq); - if ((alias = as_add_arq_rb(ad, arq))) { - list_del_init(&arq->fifo); - as_add_aliased_request(ad, arq, alias); - if (next_arq) - ad->next_arq[arq->is_sync] = next_arq; - } + as_add_arq_rb(ad, arq); /* * Note! At this stage of this and the next function, our next * request may not be optimal - eg the request may have "grown" @@ -1579,18 +1507,8 @@ static void as_merged_requests(request_queue_t *q, struct request *req, as_add_arq_hash(ad, arq); if (rq_rb_key(req) != arq->rb_key) { - struct as_rq *alias, *next_arq = NULL; - - if (ad->next_arq[arq->is_sync] == arq) - next_arq = as_find_next_arq(ad, arq); - as_del_arq_rb(ad, arq); - if ((alias = as_add_arq_rb(ad, arq))) { - list_del_init(&arq->fifo); - as_add_aliased_request(ad, arq, alias); - if (next_arq) - ad->next_arq[arq->is_sync] = next_arq; - } + as_add_arq_rb(ad, arq); } /* @@ -1610,18 +1528,6 @@ static void as_merged_requests(request_queue_t *q, struct request *req, } /* - * Transfer list of aliases - */ - while (!list_empty(&next->queuelist)) { - struct request *__rq = list_entry_rq(next->queuelist.next); - struct as_rq *__arq = RQ_DATA(__rq); - - list_move_tail(&__rq->queuelist, &req->queuelist); - - WARN_ON(__arq->state != AS_RQ_QUEUED); - } - - /* * kill knowledge of next, this one is a goner */ as_remove_queued_request(q, next); -- cgit v1.1 From 88ee5ef157202624de2b43b3512fdcb54fda1ab5 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Sat, 12 Nov 2005 11:09:12 +0100 Subject: [BLOCK] ll_rw_blk: fastpath get_request() Originally from: Nick Piggin Move current_io_context out of the get_request fastpth. Also try to streamline a few other things in this area. Signed-off-by: Jens Axboe --- block/ll_rw_blk.c | 70 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index d4beb9a..97f4e7e 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -1908,40 +1908,40 @@ static struct request *get_request(request_queue_t *q, int rw, struct bio *bio, { struct request *rq = NULL; struct request_list *rl = &q->rq; - struct io_context *ioc = current_io_context(GFP_ATOMIC); - int priv; + struct io_context *ioc = NULL; + int may_queue, priv; - if (rl->count[rw]+1 >= q->nr_requests) { - /* - * The queue will fill after this allocation, so set it as - * full, and mark this process as "batching". This process - * will be allowed to complete a batch of requests, others - * will be blocked. - */ - if (!blk_queue_full(q, rw)) { - ioc_set_batching(q, ioc); - blk_set_queue_full(q, rw); - } - } + may_queue = elv_may_queue(q, rw, bio); + if (may_queue == ELV_MQUEUE_NO) + goto rq_starved; - switch (elv_may_queue(q, rw, bio)) { - case ELV_MQUEUE_NO: - goto rq_starved; - case ELV_MQUEUE_MAY: - break; - case ELV_MQUEUE_MUST: - goto get_rq; - } - - if (blk_queue_full(q, rw) && !ioc_batching(q, ioc)) { - /* - * The queue is full and the allocating process is not a - * "batcher", and not exempted by the IO scheduler - */ - goto out; + if (rl->count[rw]+1 >= queue_congestion_on_threshold(q)) { + if (rl->count[rw]+1 >= q->nr_requests) { + ioc = current_io_context(GFP_ATOMIC); + /* + * The queue will fill after this allocation, so set + * it as full, and mark this process as "batching". + * This process will be allowed to complete a batch of + * requests, others will be blocked. + */ + if (!blk_queue_full(q, rw)) { + ioc_set_batching(q, ioc); + blk_set_queue_full(q, rw); + } else { + if (may_queue != ELV_MQUEUE_MUST + && !ioc_batching(q, ioc)) { + /* + * The queue is full and the allocating + * process is not a "batcher", and not + * exempted by the IO scheduler + */ + goto out; + } + } + } + set_queue_congested(q, rw); } -get_rq: /* * Only allow batching queuers to allocate up to 50% over the defined * limit of requests, otherwise we could have thousands of requests @@ -1952,8 +1952,6 @@ get_rq: rl->count[rw]++; rl->starved[rw] = 0; - if (rl->count[rw] >= queue_congestion_on_threshold(q)) - set_queue_congested(q, rw); priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags); if (priv) @@ -1962,7 +1960,7 @@ get_rq: spin_unlock_irq(q->queue_lock); rq = blk_alloc_request(q, rw, bio, priv, gfp_mask); - if (!rq) { + if (unlikely(!rq)) { /* * Allocation failed presumably due to memory. Undo anything * we might have messed up. @@ -1987,6 +1985,12 @@ rq_starved: goto out; } + /* + * ioc may be NULL here, and ioc_batching will be false. That's + * OK, if the queue is under the request limit then requests need + * not count toward the nr_batch_requests limit. There will always + * be some limit enforced by BLK_BATCH_TIME. + */ if (ioc_batching(q, ioc)) ioc->nr_batch_requests--; -- cgit v1.1 From 80cfd548eed68cf90c5ae9cfcd6b02230cece756 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 6 Jan 2006 09:43:28 +0100 Subject: [BLOCK] bio: check for same page merge possibilities in __bio_add_page() For filesystems with a blocksize < page size, we can merge same page calls into the bio_vec at the end of the bio. This saves segments on systems with a page size > the "normal" 4kb fs block size. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- fs/bio.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/bio.c b/fs/bio.c index 38d3e80..dfe242a2 100644 --- a/fs/bio.c +++ b/fs/bio.c @@ -325,10 +325,31 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page if (unlikely(bio_flagged(bio, BIO_CLONED))) return 0; - if (bio->bi_vcnt >= bio->bi_max_vecs) + if (((bio->bi_size + len) >> 9) > max_sectors) return 0; - if (((bio->bi_size + len) >> 9) > max_sectors) + /* + * For filesystems with a blocksize smaller than the pagesize + * we will often be called with the same page as last time and + * a consecutive offset. Optimize this special case. + */ + if (bio->bi_vcnt > 0) { + struct bio_vec *prev = &bio->bi_io_vec[bio->bi_vcnt - 1]; + + if (page == prev->bv_page && + offset == prev->bv_offset + prev->bv_len) { + prev->bv_len += len; + if (q->merge_bvec_fn && + q->merge_bvec_fn(q, bio, prev) < len) { + prev->bv_len -= len; + return 0; + } + + goto done; + } + } + + if (bio->bi_vcnt >= bio->bi_max_vecs) return 0; /* @@ -382,6 +403,7 @@ static int __bio_add_page(request_queue_t *q, struct bio *bio, struct page bio->bi_vcnt++; bio->bi_phys_segments++; bio->bi_hw_segments++; + done: bio->bi_size += len; return len; } -- cgit v1.1 From 64100099ed22f71cce656c5c2caecf5c9cf255dc Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Fri, 6 Jan 2006 09:46:02 +0100 Subject: [BLOCK] mark some block/ variables cons the patch below marks various read-only variables in block/* as const, so that gcc can optimize the use of them; eg gcc will replace the use by the value directly now and will even remove the memory usage of these. Signed-off-by: Arjan van de Ven Signed-off-by: Jens Axboe --- block/cfq-iosched.c | 16 ++++++++-------- block/deadline-iosched.c | 8 ++++---- block/ll_rw_blk.c | 2 +- block/scsi_ioctl.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index ee0bb41..74fae2d 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -25,15 +25,15 @@ /* * tunables */ -static int cfq_quantum = 4; /* max queue in one round of service */ -static int cfq_queued = 8; /* minimum rq allocate limit per-queue*/ -static int cfq_fifo_expire[2] = { HZ / 4, HZ / 8 }; -static int cfq_back_max = 16 * 1024; /* maximum backwards seek, in KiB */ -static int cfq_back_penalty = 2; /* penalty of a backwards seek */ +static const int cfq_quantum = 4; /* max queue in one round of service */ +static const int cfq_queued = 8; /* minimum rq allocate limit per-queue*/ +static const int cfq_fifo_expire[2] = { HZ / 4, HZ / 8 }; +static const int cfq_back_max = 16 * 1024; /* maximum backwards seek, in KiB */ +static const int cfq_back_penalty = 2; /* penalty of a backwards seek */ -static int cfq_slice_sync = HZ / 10; +static const int cfq_slice_sync = HZ / 10; static int cfq_slice_async = HZ / 25; -static int cfq_slice_async_rq = 2; +static const int cfq_slice_async_rq = 2; static int cfq_slice_idle = HZ / 100; #define CFQ_IDLE_GRACE (HZ / 10) @@ -45,7 +45,7 @@ static int cfq_slice_idle = HZ / 100; /* * disable queueing at the driver/hardware level */ -static int cfq_max_depth = 2; +static const int cfq_max_depth = 2; /* * for the hash of cfqq inside the cfqd diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c index 9cbec09..27e494b 100644 --- a/block/deadline-iosched.c +++ b/block/deadline-iosched.c @@ -19,10 +19,10 @@ /* * See Documentation/block/deadline-iosched.txt */ -static int read_expire = HZ / 2; /* max time before a read is submitted. */ -static int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */ -static int writes_starved = 2; /* max times reads can starve a write */ -static int fifo_batch = 16; /* # of sequential requests treated as one +static const int read_expire = HZ / 2; /* max time before a read is submitted. */ +static const int write_expire = 5 * HZ; /* ditto for writes, these limits are SOFT! */ +static const int writes_starved = 2; /* max times reads can starve a write */ +static const int fifo_batch = 16; /* # of sequential requests treated as one by the above parameters. For throughput. */ static const int deadline_hash_shift = 5; diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 97f4e7e..e02c88c 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -1039,7 +1039,7 @@ void blk_queue_invalidate_tags(request_queue_t *q) EXPORT_SYMBOL(blk_queue_invalidate_tags); -static char *rq_flags[] = { +static const char * const rq_flags[] = { "REQ_RW", "REQ_FAILFAST", "REQ_SORTED", diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 1d8852f..c2ac36d 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c @@ -46,7 +46,7 @@ EXPORT_SYMBOL(scsi_command_size); static int sg_get_version(int __user *p) { - static int sg_version_num = 30527; + static const int sg_version_num = 30527; return put_user(sg_version_num, p); } -- cgit v1.1 From 8ffdc6550c47f75ca4e6c9f30a2a89063e035cf2 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:49:03 +0100 Subject: [BLOCK] add @uptodate to end_that_request_last() and @error to rq_end_io_fn() add @uptodate argument to end_that_request_last() and @error to rq_end_io_fn(). there's no generic way to pass error code to request completion function, making generic error handling of non-fs request difficult (rq->errors is driver-specific and each driver uses it differently). this patch adds @uptodate to end_that_request_last() and @error to rq_end_io_fn(). for fs requests, this doesn't really matter, so just using the same uptodate argument used in the last call to end_that_request_first() should suffice. imho, this can also help the generic command-carrying request jens is working on. Signed-off-by: tejun heo Signed-Off-By: Jens Axboe --- block/elevator.c | 2 +- block/ll_rw_blk.c | 22 +++++++++++++++------- drivers/block/DAC960.c | 2 +- drivers/block/cciss.c | 2 +- drivers/block/cpqarray.c | 2 +- drivers/block/floppy.c | 2 +- drivers/block/nbd.c | 2 +- drivers/block/sx8.c | 2 +- drivers/block/ub.c | 2 +- drivers/block/viodasd.c | 2 +- drivers/cdrom/cdu31a.c | 2 +- drivers/ide/ide-cd.c | 4 ++-- drivers/ide/ide-io.c | 6 +++--- drivers/message/i2o/i2o_block.c | 2 +- drivers/mmc/mmc_block.c | 4 ++-- drivers/s390/block/dasd.c | 2 +- drivers/s390/char/tape_block.c | 2 +- drivers/scsi/ide-scsi.c | 4 ++-- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/sd.c | 2 +- include/linux/blkdev.h | 6 +++--- 21 files changed, 42 insertions(+), 34 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index 6c3fc8a..85a11ce 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -498,7 +498,7 @@ struct request *elv_next_request(request_queue_t *q) blkdev_dequeue_request(rq); rq->flags |= REQ_QUIET; end_that_request_chunk(rq, 0, nr_bytes); - end_that_request_last(rq); + end_that_request_last(rq, 0); } else { printk(KERN_ERR "%s: bad return=%d\n", __FUNCTION__, ret); diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index e02c88c..8b1ae69 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -344,7 +344,7 @@ EXPORT_SYMBOL(blk_queue_issue_flush_fn); /* * Cache flushing for ordered writes handling */ -static void blk_pre_flush_end_io(struct request *flush_rq) +static void blk_pre_flush_end_io(struct request *flush_rq, int error) { struct request *rq = flush_rq->end_io_data; request_queue_t *q = rq->q; @@ -362,7 +362,7 @@ static void blk_pre_flush_end_io(struct request *flush_rq) } } -static void blk_post_flush_end_io(struct request *flush_rq) +static void blk_post_flush_end_io(struct request *flush_rq, int error) { struct request *rq = flush_rq->end_io_data; request_queue_t *q = rq->q; @@ -2317,7 +2317,7 @@ EXPORT_SYMBOL(blk_rq_map_kern); */ void blk_execute_rq_nowait(request_queue_t *q, struct gendisk *bd_disk, struct request *rq, int at_head, - void (*done)(struct request *)) + rq_end_io_fn *done) { int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; @@ -2521,7 +2521,7 @@ EXPORT_SYMBOL(blk_put_request); * blk_end_sync_rq - executes a completion event on a request * @rq: request to complete */ -void blk_end_sync_rq(struct request *rq) +void blk_end_sync_rq(struct request *rq, int error) { struct completion *waiting = rq->waiting; @@ -3183,9 +3183,17 @@ EXPORT_SYMBOL(end_that_request_chunk); /* * queue lock must be held */ -void end_that_request_last(struct request *req) +void end_that_request_last(struct request *req, int uptodate) { struct gendisk *disk = req->rq_disk; + int error; + + /* + * extend uptodate bool to allow < 0 value to be direct io error + */ + error = 0; + if (end_io_error(uptodate)) + error = !uptodate ? -EIO : uptodate; if (unlikely(laptop_mode) && blk_fs_request(req)) laptop_io_completion(); @@ -3200,7 +3208,7 @@ void end_that_request_last(struct request *req) disk->in_flight--; } if (req->end_io) - req->end_io(req); + req->end_io(req, error); else __blk_put_request(req->q, req); } @@ -3212,7 +3220,7 @@ void end_request(struct request *req, int uptodate) if (!end_that_request_first(req, uptodate, req->hard_cur_sectors)) { add_disk_randomness(req->rq_disk); blkdev_dequeue_request(req); - end_that_request_last(req); + end_that_request_last(req, uptodate); } } diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 70eaa5c..21097a3 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c @@ -3471,7 +3471,7 @@ static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command, if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) { - end_that_request_last(Request); + end_that_request_last(Request, UpToDate); if (Command->Completion) { complete(Command->Completion); diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index c3441b3..d2815b7 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -2310,7 +2310,7 @@ static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd, printk("Done with %p\n", cmd->rq); #endif /* CCISS_DEBUG */ - end_that_request_last(cmd->rq); + end_that_request_last(cmd->rq, status ? 1 : -EIO); cmd_free(h,cmd,1); } diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index cf1822a..9bddb68 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c @@ -1036,7 +1036,7 @@ static inline void complete_command(cmdlist_t *cmd, int timeout) complete_buffers(cmd->rq->bio, ok); DBGPX(printk("Done with %p\n", cmd->rq);); - end_that_request_last(cmd->rq); + end_that_request_last(cmd->rq, ok ? 1 : -EIO); } /* diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index f7e765a..a5b857c 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -2301,7 +2301,7 @@ static void floppy_end_request(struct request *req, int uptodate) add_disk_randomness(req->rq_disk); floppy_off((long)req->rq_disk->private_data); blkdev_dequeue_request(req); - end_that_request_last(req); + end_that_request_last(req, uptodate); /* We're done with the request */ current_req = NULL; diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 9e268dd..485345c 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -136,7 +136,7 @@ static void nbd_end_request(struct request *req) spin_lock_irqsave(q->queue_lock, flags); if (!end_that_request_first(req, uptodate, req->nr_sectors)) { - end_that_request_last(req); + end_that_request_last(req, uptodate); } spin_unlock_irqrestore(q->queue_lock, flags); } diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c index 1ded3b4..9251f41 100644 --- a/drivers/block/sx8.c +++ b/drivers/block/sx8.c @@ -770,7 +770,7 @@ static inline void carm_end_request_queued(struct carm_host *host, rc = end_that_request_first(req, uptodate, req->hard_nr_sectors); assert(rc == 0); - end_that_request_last(req); + end_that_request_last(req, uptodate); rc = carm_put_request(host, crq); assert(rc == 0); diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 10740a0..a05fe58 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c @@ -951,7 +951,7 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) static void ub_end_rq(struct request *rq, int uptodate) { end_that_request_first(rq, uptodate, rq->hard_nr_sectors); - end_that_request_last(rq); + end_that_request_last(rq, uptodate); } static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index 2d518aa..063f030 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c @@ -305,7 +305,7 @@ static void viodasd_end_request(struct request *req, int uptodate, if (end_that_request_first(req, uptodate, num_sectors)) return; add_disk_randomness(req->rq_disk); - end_that_request_last(req); + end_that_request_last(req, uptodate); } /* diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c index ac96de1..378e88d 100644 --- a/drivers/cdrom/cdu31a.c +++ b/drivers/cdrom/cdu31a.c @@ -1402,7 +1402,7 @@ static void do_cdu31a_request(request_queue_t * q) if (!end_that_request_first(req, 1, nblock)) { spin_lock_irq(q->queue_lock); blkdev_dequeue_request(req); - end_that_request_last(req); + end_that_request_last(req, 1); spin_unlock_irq(q->queue_lock); } continue; diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 70aeb3a..d31117e 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c @@ -614,7 +614,7 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate) */ spin_lock_irqsave(&ide_lock, flags); end_that_request_chunk(failed, 0, failed->data_len); - end_that_request_last(failed); + end_that_request_last(failed, 0); spin_unlock_irqrestore(&ide_lock, flags); } @@ -1735,7 +1735,7 @@ end_request: spin_lock_irqsave(&ide_lock, flags); blkdev_dequeue_request(rq); - end_that_request_last(rq); + end_that_request_last(rq, 1); HWGROUP(drive)->rq = NULL; spin_unlock_irqrestore(&ide_lock, flags); return ide_stopped; diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index ecfafcd..8435b44 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -89,7 +89,7 @@ int __ide_end_request(ide_drive_t *drive, struct request *rq, int uptodate, blkdev_dequeue_request(rq); HWGROUP(drive)->rq = NULL; - end_that_request_last(rq); + end_that_request_last(rq, uptodate); ret = 0; } return ret; @@ -247,7 +247,7 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq) } blkdev_dequeue_request(rq); HWGROUP(drive)->rq = NULL; - end_that_request_last(rq); + end_that_request_last(rq, 1); spin_unlock_irqrestore(&ide_lock, flags); } @@ -379,7 +379,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) blkdev_dequeue_request(rq); HWGROUP(drive)->rq = NULL; rq->errors = err; - end_that_request_last(rq); + end_that_request_last(rq, !rq->errors); spin_unlock_irqrestore(&ide_lock, flags); } diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index f283b5b..4f52252 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c @@ -466,7 +466,7 @@ static void i2o_block_end_request(struct request *req, int uptodate, spin_lock_irqsave(q->queue_lock, flags); - end_that_request_last(req); + end_that_request_last(req, uptodate); if (likely(dev)) { dev->open_queue_depth--; diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c index abcf191..8e380c1 100644 --- a/drivers/mmc/mmc_block.c +++ b/drivers/mmc/mmc_block.c @@ -263,7 +263,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) */ add_disk_randomness(req->rq_disk); blkdev_dequeue_request(req); - end_that_request_last(req); + end_that_request_last(req, 1); } spin_unlock_irq(&md->lock); } while (ret); @@ -289,7 +289,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) add_disk_randomness(req->rq_disk); blkdev_dequeue_request(req); - end_that_request_last(req); + end_that_request_last(req, 0); spin_unlock_irq(&md->lock); return 0; diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 7008d32..fdb6138 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -1035,7 +1035,7 @@ dasd_end_request(struct request *req, int uptodate) if (end_that_request_first(req, uptodate, req->hard_nr_sectors)) BUG(); add_disk_randomness(req->rq_disk); - end_that_request_last(req); + end_that_request_last(req, uptodate); } /* diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c index 1efc9f2..559d514 100644 --- a/drivers/s390/char/tape_block.c +++ b/drivers/s390/char/tape_block.c @@ -78,7 +78,7 @@ tapeblock_end_request(struct request *req, int uptodate) { if (end_that_request_first(req, uptodate, req->hard_nr_sectors)) BUG(); - end_that_request_last(req); + end_that_request_last(req, uptodate); } static void diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 4cb1f3e..3c688ef 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c @@ -1046,7 +1046,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd) /* kill current request */ blkdev_dequeue_request(req); - end_that_request_last(req); + end_that_request_last(req, 0); if (req->flags & REQ_SENSE) kfree(scsi->pc->buffer); kfree(scsi->pc); @@ -1056,7 +1056,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd) /* now nuke the drive queue */ while ((req = elv_next_request(drive->queue))) { blkdev_dequeue_request(req); - end_that_request_last(req); + end_that_request_last(req, 0); } HWGROUP(drive)->rq = NULL; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index a7f3f0c..53551f1 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -791,7 +791,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate, spin_lock_irqsave(q->queue_lock, flags); if (blk_rq_tagged(req)) blk_queue_end_tag(q, req); - end_that_request_last(req); + end_that_request_last(req, uptodate); spin_unlock_irqrestore(q->queue_lock, flags); /* diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 3d3ad7d..d651150 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -748,7 +748,7 @@ static void sd_end_flush(request_queue_t *q, struct request *flush_rq) * force journal abort of barriers */ end_that_request_first(rq, -EOPNOTSUPP, rq->hard_nr_sectors); - end_that_request_last(rq); + end_that_request_last(rq, -EOPNOTSUPP); } } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a18500d..a0ce8c5 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -102,7 +102,7 @@ void copy_io_context(struct io_context **pdst, struct io_context **psrc); void swap_io_context(struct io_context **ioc1, struct io_context **ioc2); struct request; -typedef void (rq_end_io_fn)(struct request *); +typedef void (rq_end_io_fn)(struct request *, int); struct request_list { int count[2]; @@ -560,7 +560,7 @@ extern void register_disk(struct gendisk *dev); extern void generic_make_request(struct bio *bio); extern void blk_put_request(struct request *); extern void __blk_put_request(request_queue_t *, struct request *); -extern void blk_end_sync_rq(struct request *rq); +extern void blk_end_sync_rq(struct request *rq, int error); extern void blk_attempt_remerge(request_queue_t *, struct request *); extern struct request *blk_get_request(request_queue_t *, int, gfp_t); extern void blk_insert_request(request_queue_t *, struct request *, int, void *); @@ -614,7 +614,7 @@ static inline void blk_run_address_space(struct address_space *mapping) */ extern int end_that_request_first(struct request *, int, int); extern int end_that_request_chunk(struct request *, int, int); -extern void end_that_request_last(struct request *); +extern void end_that_request_last(struct request *, int); extern void end_request(struct request *req, int uptodate); /* -- cgit v1.1 From 52d9e675361261a1eb1716b02222ec6177ec342b Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:49:58 +0100 Subject: [BLOCK] ll_rw_blk: separate out bio init part from __make_request Separate out bio initialization part from __make_request. It will be used by the following blk_ordered_reimpl. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- block/ll_rw_blk.c | 62 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 8b1ae69..65c4efc 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -36,6 +36,8 @@ static void blk_unplug_work(void *data); static void blk_unplug_timeout(unsigned long data); static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io); +static void init_request_from_bio(struct request *req, struct bio *bio); +static int __make_request(request_queue_t *q, struct bio *bio); /* * For the allocated request tables @@ -1667,8 +1669,6 @@ static int blk_init_free_list(request_queue_t *q) return 0; } -static int __make_request(request_queue_t *, struct bio *); - request_queue_t *blk_alloc_queue(gfp_t gfp_mask) { return blk_alloc_queue_node(gfp_mask, -1); @@ -2659,6 +2659,36 @@ void blk_attempt_remerge(request_queue_t *q, struct request *rq) EXPORT_SYMBOL(blk_attempt_remerge); +static void init_request_from_bio(struct request *req, struct bio *bio) +{ + req->flags |= REQ_CMD; + + /* + * inherit FAILFAST from bio (for read-ahead, and explicit FAILFAST) + */ + if (bio_rw_ahead(bio) || bio_failfast(bio)) + req->flags |= REQ_FAILFAST; + + /* + * REQ_BARRIER implies no merging, but lets make it explicit + */ + if (unlikely(bio_barrier(bio))) + req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE); + + req->errors = 0; + req->hard_sector = req->sector = bio->bi_sector; + req->hard_nr_sectors = req->nr_sectors = bio_sectors(bio); + req->current_nr_sectors = req->hard_cur_sectors = bio_cur_sectors(bio); + req->nr_phys_segments = bio_phys_segments(req->q, bio); + req->nr_hw_segments = bio_hw_segments(req->q, bio); + req->buffer = bio_data(bio); /* see ->buffer comment above */ + req->waiting = NULL; + req->bio = req->biotail = bio; + req->ioprio = bio_prio(bio); + req->rq_disk = bio->bi_bdev->bd_disk; + req->start_time = jiffies; +} + static int __make_request(request_queue_t *q, struct bio *bio) { struct request *req; @@ -2754,33 +2784,7 @@ get_rq: * We don't worry about that case for efficiency. It won't happen * often, and the elevators are able to handle it. */ - - req->flags |= REQ_CMD; - - /* - * inherit FAILFAST from bio (for read-ahead, and explicit FAILFAST) - */ - if (bio_rw_ahead(bio) || bio_failfast(bio)) - req->flags |= REQ_FAILFAST; - - /* - * REQ_BARRIER implies no merging, but lets make it explicit - */ - if (unlikely(barrier)) - req->flags |= (REQ_HARDBARRIER | REQ_NOMERGE); - - req->errors = 0; - req->hard_sector = req->sector = sector; - req->hard_nr_sectors = req->nr_sectors = nr_sectors; - req->current_nr_sectors = req->hard_cur_sectors = cur_nr_sectors; - req->nr_phys_segments = bio_phys_segments(q, bio); - req->nr_hw_segments = bio_hw_segments(q, bio); - req->buffer = bio_data(bio); /* see ->buffer comment above */ - req->waiting = NULL; - req->bio = req->biotail = bio; - req->ioprio = prio; - req->rq_disk = bio->bi_bdev->bd_disk; - req->start_time = jiffies; + init_request_from_bio(req, bio); spin_lock_irq(q->queue_lock); if (elv_queue_empty(q)) -- cgit v1.1 From 797e7dbbee0a91fa1349192f18ad5c454997d876 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:51:03 +0100 Subject: [BLOCK] reimplement handling of barrier request Reimplement handling of barrier requests. * Flexible handling to deal with various capabilities of target devices. * Retry support for falling back. * Tagged queues which don't support ordered tag can do ordered. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- block/elevator.c | 84 +++++++---- block/ll_rw_blk.c | 384 ++++++++++++++++++++++++++++++----------------- include/linux/blkdev.h | 82 +++++++--- include/linux/elevator.h | 1 + 4 files changed, 359 insertions(+), 192 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index 85a11ce..39dcccc 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -304,15 +304,7 @@ void elv_requeue_request(request_queue_t *q, struct request *rq) rq->flags &= ~REQ_STARTED; - /* - * if this is the flush, requeue the original instead and drop the flush - */ - if (rq->flags & REQ_BAR_FLUSH) { - clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); - rq = rq->end_io_data; - } - - __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); + __elv_add_request(q, rq, ELEVATOR_INSERT_REQUEUE, 0); } static void elv_drain_elevator(request_queue_t *q) @@ -332,8 +324,19 @@ static void elv_drain_elevator(request_queue_t *q) void __elv_add_request(request_queue_t *q, struct request *rq, int where, int plug) { + struct list_head *pos; + unsigned ordseq; + + if (q->ordcolor) + rq->flags |= REQ_ORDERED_COLOR; + if (rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER)) { /* + * toggle ordered color + */ + q->ordcolor ^= 1; + + /* * barriers implicitly indicate back insertion */ if (where == ELEVATOR_INSERT_SORT) @@ -393,6 +396,30 @@ void __elv_add_request(request_queue_t *q, struct request *rq, int where, q->elevator->ops->elevator_add_req_fn(q, rq); break; + case ELEVATOR_INSERT_REQUEUE: + /* + * If ordered flush isn't in progress, we do front + * insertion; otherwise, requests should be requeued + * in ordseq order. + */ + rq->flags |= REQ_SOFTBARRIER; + + if (q->ordseq == 0) { + list_add(&rq->queuelist, &q->queue_head); + break; + } + + ordseq = blk_ordered_req_seq(rq); + + list_for_each(pos, &q->queue_head) { + struct request *pos_rq = list_entry_rq(pos); + if (ordseq <= blk_ordered_req_seq(pos_rq)) + break; + } + + list_add_tail(&rq->queuelist, pos); + break; + default: printk(KERN_ERR "%s: bad insertion point %d\n", __FUNCTION__, where); @@ -422,25 +449,16 @@ static inline struct request *__elv_next_request(request_queue_t *q) { struct request *rq; - if (unlikely(list_empty(&q->queue_head) && - !q->elevator->ops->elevator_dispatch_fn(q, 0))) - return NULL; - - rq = list_entry_rq(q->queue_head.next); - - /* - * if this is a barrier write and the device has to issue a - * flush sequence to support it, check how far we are - */ - if (blk_fs_request(rq) && blk_barrier_rq(rq)) { - BUG_ON(q->ordered == QUEUE_ORDERED_NONE); + while (1) { + while (!list_empty(&q->queue_head)) { + rq = list_entry_rq(q->queue_head.next); + if (blk_do_ordered(q, &rq)) + return rq; + } - if (q->ordered == QUEUE_ORDERED_FLUSH && - !blk_barrier_preflush(rq)) - rq = blk_start_pre_flush(q, rq); + if (!q->elevator->ops->elevator_dispatch_fn(q, 0)) + return NULL; } - - return rq; } struct request *elv_next_request(request_queue_t *q) @@ -593,7 +611,21 @@ void elv_completed_request(request_queue_t *q, struct request *rq) * request is released from the driver, io must be done */ if (blk_account_rq(rq)) { + struct request *first_rq = list_entry_rq(q->queue_head.next); + q->in_flight--; + + /* + * Check if the queue is waiting for fs requests to be + * drained for flush sequence. + */ + if (q->ordseq && q->in_flight == 0 && + blk_ordered_cur_seq(q) == QUEUE_ORDSEQ_DRAIN && + blk_ordered_req_seq(first_rq) > QUEUE_ORDSEQ_DRAIN) { + blk_ordered_complete_seq(q, QUEUE_ORDSEQ_DRAIN, 0); + q->request_fn(q); + } + if (blk_sorted_rq(rq) && e->ops->elevator_completed_req_fn) e->ops->elevator_completed_req_fn(q, rq); } diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c index 65c4efc..91d3b48 100644 --- a/block/ll_rw_blk.c +++ b/block/ll_rw_blk.c @@ -290,8 +290,8 @@ static inline void rq_init(request_queue_t *q, struct request *rq) /** * blk_queue_ordered - does this queue support ordered writes - * @q: the request queue - * @flag: see below + * @q: the request queue + * @ordered: one of QUEUE_ORDERED_* * * Description: * For journalled file systems, doing ordered writes on a commit @@ -300,28 +300,30 @@ static inline void rq_init(request_queue_t *q, struct request *rq) * feature should call this function and indicate so. * **/ -void blk_queue_ordered(request_queue_t *q, int flag) -{ - switch (flag) { - case QUEUE_ORDERED_NONE: - if (q->flush_rq) - kmem_cache_free(request_cachep, q->flush_rq); - q->flush_rq = NULL; - q->ordered = flag; - break; - case QUEUE_ORDERED_TAG: - q->ordered = flag; - break; - case QUEUE_ORDERED_FLUSH: - q->ordered = flag; - if (!q->flush_rq) - q->flush_rq = kmem_cache_alloc(request_cachep, - GFP_KERNEL); - break; - default: - printk("blk_queue_ordered: bad value %d\n", flag); - break; +int blk_queue_ordered(request_queue_t *q, unsigned ordered, + prepare_flush_fn *prepare_flush_fn) +{ + if (ordered & (QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH) && + prepare_flush_fn == NULL) { + printk(KERN_ERR "blk_queue_ordered: prepare_flush_fn required\n"); + return -EINVAL; + } + + if (ordered != QUEUE_ORDERED_NONE && + ordered != QUEUE_ORDERED_DRAIN && + ordered != QUEUE_ORDERED_DRAIN_FLUSH && + ordered != QUEUE_ORDERED_DRAIN_FUA && + ordered != QUEUE_ORDERED_TAG && + ordered != QUEUE_ORDERED_TAG_FLUSH && + ordered != QUEUE_ORDERED_TAG_FUA) { + printk(KERN_ERR "blk_queue_ordered: bad value %d\n", ordered); + return -EINVAL; } + + q->next_ordered = ordered; + q->prepare_flush_fn = prepare_flush_fn; + + return 0; } EXPORT_SYMBOL(blk_queue_ordered); @@ -346,167 +348,265 @@ EXPORT_SYMBOL(blk_queue_issue_flush_fn); /* * Cache flushing for ordered writes handling */ -static void blk_pre_flush_end_io(struct request *flush_rq, int error) +inline unsigned blk_ordered_cur_seq(request_queue_t *q) { - struct request *rq = flush_rq->end_io_data; - request_queue_t *q = rq->q; - - elv_completed_request(q, flush_rq); - - rq->flags |= REQ_BAR_PREFLUSH; - - if (!flush_rq->errors) - elv_requeue_request(q, rq); - else { - q->end_flush_fn(q, flush_rq); - clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); - q->request_fn(q); - } + if (!q->ordseq) + return 0; + return 1 << ffz(q->ordseq); } -static void blk_post_flush_end_io(struct request *flush_rq, int error) +unsigned blk_ordered_req_seq(struct request *rq) { - struct request *rq = flush_rq->end_io_data; request_queue_t *q = rq->q; - elv_completed_request(q, flush_rq); + BUG_ON(q->ordseq == 0); - rq->flags |= REQ_BAR_POSTFLUSH; + if (rq == &q->pre_flush_rq) + return QUEUE_ORDSEQ_PREFLUSH; + if (rq == &q->bar_rq) + return QUEUE_ORDSEQ_BAR; + if (rq == &q->post_flush_rq) + return QUEUE_ORDSEQ_POSTFLUSH; - q->end_flush_fn(q, flush_rq); - clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); - q->request_fn(q); + if ((rq->flags & REQ_ORDERED_COLOR) == + (q->orig_bar_rq->flags & REQ_ORDERED_COLOR)) + return QUEUE_ORDSEQ_DRAIN; + else + return QUEUE_ORDSEQ_DONE; } -struct request *blk_start_pre_flush(request_queue_t *q, struct request *rq) +void blk_ordered_complete_seq(request_queue_t *q, unsigned seq, int error) { - struct request *flush_rq = q->flush_rq; - - BUG_ON(!blk_barrier_rq(rq)); + struct request *rq; + int uptodate; - if (test_and_set_bit(QUEUE_FLAG_FLUSH, &q->queue_flags)) - return NULL; + if (error && !q->orderr) + q->orderr = error; - rq_init(q, flush_rq); - flush_rq->elevator_private = NULL; - flush_rq->flags = REQ_BAR_FLUSH; - flush_rq->rq_disk = rq->rq_disk; - flush_rq->rl = NULL; + BUG_ON(q->ordseq & seq); + q->ordseq |= seq; - /* - * prepare_flush returns 0 if no flush is needed, just mark both - * pre and post flush as done in that case - */ - if (!q->prepare_flush_fn(q, flush_rq)) { - rq->flags |= REQ_BAR_PREFLUSH | REQ_BAR_POSTFLUSH; - clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); - return rq; - } + if (blk_ordered_cur_seq(q) != QUEUE_ORDSEQ_DONE) + return; /* - * some drivers dequeue requests right away, some only after io - * completion. make sure the request is dequeued. + * Okay, sequence complete. */ - if (!list_empty(&rq->queuelist)) - blkdev_dequeue_request(rq); + rq = q->orig_bar_rq; + uptodate = q->orderr ? q->orderr : 1; - flush_rq->end_io_data = rq; - flush_rq->end_io = blk_pre_flush_end_io; + q->ordseq = 0; - __elv_add_request(q, flush_rq, ELEVATOR_INSERT_FRONT, 0); - return flush_rq; + end_that_request_first(rq, uptodate, rq->hard_nr_sectors); + end_that_request_last(rq, uptodate); } -static void blk_start_post_flush(request_queue_t *q, struct request *rq) +static void pre_flush_end_io(struct request *rq, int error) { - struct request *flush_rq = q->flush_rq; + elv_completed_request(rq->q, rq); + blk_ordered_complete_seq(rq->q, QUEUE_ORDSEQ_PREFLUSH, error); +} - BUG_ON(!blk_barrier_rq(rq)); +static void bar_end_io(struct request *rq, int error) +{ + elv_completed_request(rq->q, rq); + blk_ordered_complete_seq(rq->q, QUEUE_ORDSEQ_BAR, error); +} - rq_init(q, flush_rq); - flush_rq->elevator_private = NULL; - flush_rq->flags = REQ_BAR_FLUSH; - flush_rq->rq_disk = rq->rq_disk; - flush_rq->rl = NULL; +static void post_flush_end_io(struct request *rq, int error) +{ + elv_completed_request(rq->q, rq); + blk_ordered_complete_seq(rq->q, QUEUE_ORDSEQ_POSTFLUSH, error); +} - if (q->prepare_flush_fn(q, flush_rq)) { - flush_rq->end_io_data = rq; - flush_rq->end_io = blk_post_flush_end_io; +static void queue_flush(request_queue_t *q, unsigned which) +{ + struct request *rq; + rq_end_io_fn *end_io; - __elv_add_request(q, flush_rq, ELEVATOR_INSERT_FRONT, 0); - q->request_fn(q); + if (which == QUEUE_ORDERED_PREFLUSH) { + rq = &q->pre_flush_rq; + end_io = pre_flush_end_io; + } else { + rq = &q->post_flush_rq; + end_io = post_flush_end_io; } + + rq_init(q, rq); + rq->flags = REQ_HARDBARRIER; + rq->elevator_private = NULL; + rq->rq_disk = q->bar_rq.rq_disk; + rq->rl = NULL; + rq->end_io = end_io; + q->prepare_flush_fn(q, rq); + + __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); } -static inline int blk_check_end_barrier(request_queue_t *q, struct request *rq, - int sectors) +static inline struct request *start_ordered(request_queue_t *q, + struct request *rq) { - if (sectors > rq->nr_sectors) - sectors = rq->nr_sectors; + q->bi_size = 0; + q->orderr = 0; + q->ordered = q->next_ordered; + q->ordseq |= QUEUE_ORDSEQ_STARTED; + + /* + * Prep proxy barrier request. + */ + blkdev_dequeue_request(rq); + q->orig_bar_rq = rq; + rq = &q->bar_rq; + rq_init(q, rq); + rq->flags = bio_data_dir(q->orig_bar_rq->bio); + rq->flags |= q->ordered & QUEUE_ORDERED_FUA ? REQ_FUA : 0; + rq->elevator_private = NULL; + rq->rl = NULL; + init_request_from_bio(rq, q->orig_bar_rq->bio); + rq->end_io = bar_end_io; + + /* + * Queue ordered sequence. As we stack them at the head, we + * need to queue in reverse order. Note that we rely on that + * no fs request uses ELEVATOR_INSERT_FRONT and thus no fs + * request gets inbetween ordered sequence. + */ + if (q->ordered & QUEUE_ORDERED_POSTFLUSH) + queue_flush(q, QUEUE_ORDERED_POSTFLUSH); + else + q->ordseq |= QUEUE_ORDSEQ_POSTFLUSH; + + __elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 0); + + if (q->ordered & QUEUE_ORDERED_PREFLUSH) { + queue_flush(q, QUEUE_ORDERED_PREFLUSH); + rq = &q->pre_flush_rq; + } else + q->ordseq |= QUEUE_ORDSEQ_PREFLUSH; - rq->nr_sectors -= sectors; - return rq->nr_sectors; + if ((q->ordered & QUEUE_ORDERED_TAG) || q->in_flight == 0) + q->ordseq |= QUEUE_ORDSEQ_DRAIN; + else + rq = NULL; + + return rq; } -static int __blk_complete_barrier_rq(request_queue_t *q, struct request *rq, - int sectors, int queue_locked) +int blk_do_ordered(request_queue_t *q, struct request **rqp) { - if (q->ordered != QUEUE_ORDERED_FLUSH) - return 0; - if (!blk_fs_request(rq) || !blk_barrier_rq(rq)) - return 0; - if (blk_barrier_postflush(rq)) - return 0; + struct request *rq = *rqp, *allowed_rq; + int is_barrier = blk_fs_request(rq) && blk_barrier_rq(rq); - if (!blk_check_end_barrier(q, rq, sectors)) { - unsigned long flags = 0; + if (!q->ordseq) { + if (!is_barrier) + return 1; - if (!queue_locked) - spin_lock_irqsave(q->queue_lock, flags); + if (q->next_ordered != QUEUE_ORDERED_NONE) { + *rqp = start_ordered(q, rq); + return 1; + } else { + /* + * This can happen when the queue switches to + * ORDERED_NONE while this request is on it. + */ + blkdev_dequeue_request(rq); + end_that_request_first(rq, -EOPNOTSUPP, + rq->hard_nr_sectors); + end_that_request_last(rq, -EOPNOTSUPP); + *rqp = NULL; + return 0; + } + } - blk_start_post_flush(q, rq); + if (q->ordered & QUEUE_ORDERED_TAG) { + if (is_barrier && rq != &q->bar_rq) + *rqp = NULL; + return 1; + } - if (!queue_locked) - spin_unlock_irqrestore(q->queue_lock, flags); + switch (blk_ordered_cur_seq(q)) { + case QUEUE_ORDSEQ_PREFLUSH: + allowed_rq = &q->pre_flush_rq; + break; + case QUEUE_ORDSEQ_BAR: + allowed_rq = &q->bar_rq; + break; + case QUEUE_ORDSEQ_POSTFLUSH: + allowed_rq = &q->post_flush_rq; + break; + default: + allowed_rq = NULL; + break; } + if (rq != allowed_rq && + (blk_fs_request(rq) || rq == &q->pre_flush_rq || + rq == &q->post_flush_rq)) + *rqp = NULL; + return 1; } -/** - * blk_complete_barrier_rq - complete possible barrier request - * @q: the request queue for the device - * @rq: the request - * @sectors: number of sectors to complete - * - * Description: - * Used in driver end_io handling to determine whether to postpone - * completion of a barrier request until a post flush has been done. This - * is the unlocked variant, used if the caller doesn't already hold the - * queue lock. - **/ -int blk_complete_barrier_rq(request_queue_t *q, struct request *rq, int sectors) +static int flush_dry_bio_endio(struct bio *bio, unsigned int bytes, int error) { - return __blk_complete_barrier_rq(q, rq, sectors, 0); + request_queue_t *q = bio->bi_private; + struct bio_vec *bvec; + int i; + + /* + * This is dry run, restore bio_sector and size. We'll finish + * this request again with the original bi_end_io after an + * error occurs or post flush is complete. + */ + q->bi_size += bytes; + + if (bio->bi_size) + return 1; + + /* Rewind bvec's */ + bio->bi_idx = 0; + bio_for_each_segment(bvec, bio, i) { + bvec->bv_len += bvec->bv_offset; + bvec->bv_offset = 0; + } + + /* Reset bio */ + set_bit(BIO_UPTODATE, &bio->bi_flags); + bio->bi_size = q->bi_size; + bio->bi_sector -= (q->bi_size >> 9); + q->bi_size = 0; + + return 0; } -EXPORT_SYMBOL(blk_complete_barrier_rq); -/** - * blk_complete_barrier_rq_locked - complete possible barrier request - * @q: the request queue for the device - * @rq: the request - * @sectors: number of sectors to complete - * - * Description: - * See blk_complete_barrier_rq(). This variant must be used if the caller - * holds the queue lock. - **/ -int blk_complete_barrier_rq_locked(request_queue_t *q, struct request *rq, - int sectors) +static inline int ordered_bio_endio(struct request *rq, struct bio *bio, + unsigned int nbytes, int error) { - return __blk_complete_barrier_rq(q, rq, sectors, 1); + request_queue_t *q = rq->q; + bio_end_io_t *endio; + void *private; + + if (&q->bar_rq != rq) + return 0; + + /* + * Okay, this is the barrier request in progress, dry finish it. + */ + if (error && !q->orderr) + q->orderr = error; + + endio = bio->bi_end_io; + private = bio->bi_private; + bio->bi_end_io = flush_dry_bio_endio; + bio->bi_private = q; + + bio_endio(bio, nbytes, error); + + bio->bi_end_io = endio; + bio->bi_private = private; + + return 1; } -EXPORT_SYMBOL(blk_complete_barrier_rq_locked); /** * blk_queue_bounce_limit - set bounce buffer limit for queue @@ -1047,6 +1147,7 @@ static const char * const rq_flags[] = { "REQ_SORTED", "REQ_SOFTBARRIER", "REQ_HARDBARRIER", + "REQ_FUA", "REQ_CMD", "REQ_NOMERGE", "REQ_STARTED", @@ -1066,6 +1167,7 @@ static const char * const rq_flags[] = { "REQ_PM_SUSPEND", "REQ_PM_RESUME", "REQ_PM_SHUTDOWN", + "REQ_ORDERED_COLOR", }; void blk_dump_rq_flags(struct request *rq, char *msg) @@ -1643,8 +1745,6 @@ void blk_cleanup_queue(request_queue_t * q) if (q->queue_tags) __blk_queue_free_tags(q); - blk_queue_ordered(q, QUEUE_ORDERED_NONE); - kmem_cache_free(requestq_cachep, q); } @@ -2714,7 +2814,7 @@ static int __make_request(request_queue_t *q, struct bio *bio) spin_lock_prefetch(q->queue_lock); barrier = bio_barrier(bio); - if (unlikely(barrier) && (q->ordered == QUEUE_ORDERED_NONE)) { + if (unlikely(barrier) && (q->next_ordered == QUEUE_ORDERED_NONE)) { err = -EOPNOTSUPP; goto end_io; } @@ -3075,7 +3175,8 @@ static int __end_that_request_first(struct request *req, int uptodate, if (nr_bytes >= bio->bi_size) { req->bio = bio->bi_next; nbytes = bio->bi_size; - bio_endio(bio, nbytes, error); + if (!ordered_bio_endio(req, bio, nbytes, error)) + bio_endio(bio, nbytes, error); next_idx = 0; bio_nbytes = 0; } else { @@ -3130,7 +3231,8 @@ static int __end_that_request_first(struct request *req, int uptodate, * if the request wasn't completed, update state */ if (bio_nbytes) { - bio_endio(bio, bio_nbytes, error); + if (!ordered_bio_endio(req, bio, bio_nbytes, error)) + bio_endio(bio, bio_nbytes, error); bio->bi_idx += next_idx; bio_iovec(bio)->bv_offset += nr_bytes; bio_iovec(bio)->bv_len -= nr_bytes; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a0ce8c5..15db0f1 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -207,6 +207,7 @@ enum rq_flag_bits { __REQ_SORTED, /* elevator knows about this request */ __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ __REQ_HARDBARRIER, /* may not be passed by drive either */ + __REQ_FUA, /* forced unit access */ __REQ_CMD, /* is a regular fs rw request */ __REQ_NOMERGE, /* don't touch this for merging */ __REQ_STARTED, /* drive already may have started this one */ @@ -230,9 +231,7 @@ enum rq_flag_bits { __REQ_PM_SUSPEND, /* suspend request */ __REQ_PM_RESUME, /* resume request */ __REQ_PM_SHUTDOWN, /* shutdown request */ - __REQ_BAR_PREFLUSH, /* barrier pre-flush done */ - __REQ_BAR_POSTFLUSH, /* barrier post-flush */ - __REQ_BAR_FLUSH, /* rq is the flush request */ + __REQ_ORDERED_COLOR, /* is before or after barrier */ __REQ_NR_BITS, /* stops here */ }; @@ -241,6 +240,7 @@ enum rq_flag_bits { #define REQ_SORTED (1 << __REQ_SORTED) #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) #define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) +#define REQ_FUA (1 << __REQ_FUA) #define REQ_CMD (1 << __REQ_CMD) #define REQ_NOMERGE (1 << __REQ_NOMERGE) #define REQ_STARTED (1 << __REQ_STARTED) @@ -260,9 +260,7 @@ enum rq_flag_bits { #define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) #define REQ_PM_RESUME (1 << __REQ_PM_RESUME) #define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) -#define REQ_BAR_PREFLUSH (1 << __REQ_BAR_PREFLUSH) -#define REQ_BAR_POSTFLUSH (1 << __REQ_BAR_POSTFLUSH) -#define REQ_BAR_FLUSH (1 << __REQ_BAR_FLUSH) +#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) /* * State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME @@ -292,8 +290,7 @@ struct bio_vec; typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *); typedef void (activity_fn) (void *data, int rw); typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *); -typedef int (prepare_flush_fn) (request_queue_t *, struct request *); -typedef void (end_flush_fn) (request_queue_t *, struct request *); +typedef void (prepare_flush_fn) (request_queue_t *, struct request *); enum blk_queue_state { Queue_down, @@ -335,7 +332,6 @@ struct request_queue activity_fn *activity_fn; issue_flush_fn *issue_flush_fn; prepare_flush_fn *prepare_flush_fn; - end_flush_fn *end_flush_fn; /* * Dispatch queue sorting @@ -420,14 +416,11 @@ struct request_queue /* * reserved for flush operations */ - struct request *flush_rq; - unsigned char ordered; -}; - -enum { - QUEUE_ORDERED_NONE, - QUEUE_ORDERED_TAG, - QUEUE_ORDERED_FLUSH, + unsigned int ordered, next_ordered, ordseq; + int orderr, ordcolor; + struct request pre_flush_rq, bar_rq, post_flush_rq; + struct request *orig_bar_rq; + unsigned int bi_size; }; #define RQ_INACTIVE (-1) @@ -445,12 +438,51 @@ enum { #define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ #define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ #define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ -#define QUEUE_FLAG_FLUSH 9 /* doing barrier flush sequence */ + +enum { + /* + * Hardbarrier is supported with one of the following methods. + * + * NONE : hardbarrier unsupported + * DRAIN : ordering by draining is enough + * DRAIN_FLUSH : ordering by draining w/ pre and post flushes + * DRAIN_FUA : ordering by draining w/ pre flush and FUA write + * TAG : ordering by tag is enough + * TAG_FLUSH : ordering by tag w/ pre and post flushes + * TAG_FUA : ordering by tag w/ pre flush and FUA write + */ + QUEUE_ORDERED_NONE = 0x00, + QUEUE_ORDERED_DRAIN = 0x01, + QUEUE_ORDERED_TAG = 0x02, + + QUEUE_ORDERED_PREFLUSH = 0x10, + QUEUE_ORDERED_POSTFLUSH = 0x20, + QUEUE_ORDERED_FUA = 0x40, + + QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN | + QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH, + QUEUE_ORDERED_DRAIN_FUA = QUEUE_ORDERED_DRAIN | + QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA, + QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG | + QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH, + QUEUE_ORDERED_TAG_FUA = QUEUE_ORDERED_TAG | + QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA, + + /* + * Ordered operation sequence + */ + QUEUE_ORDSEQ_STARTED = 0x01, /* flushing in progress */ + QUEUE_ORDSEQ_DRAIN = 0x02, /* waiting for the queue to be drained */ + QUEUE_ORDSEQ_PREFLUSH = 0x04, /* pre-flushing in progress */ + QUEUE_ORDSEQ_BAR = 0x08, /* original barrier req in progress */ + QUEUE_ORDSEQ_POSTFLUSH = 0x10, /* post-flushing in progress */ + QUEUE_ORDSEQ_DONE = 0x20, +}; #define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) #define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) #define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) -#define blk_queue_flushing(q) test_bit(QUEUE_FLAG_FLUSH, &(q)->queue_flags) +#define blk_queue_flushing(q) ((q)->ordseq) #define blk_fs_request(rq) ((rq)->flags & REQ_CMD) #define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC) @@ -466,8 +498,7 @@ enum { #define blk_sorted_rq(rq) ((rq)->flags & REQ_SORTED) #define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER) -#define blk_barrier_preflush(rq) ((rq)->flags & REQ_BAR_PREFLUSH) -#define blk_barrier_postflush(rq) ((rq)->flags & REQ_BAR_POSTFLUSH) +#define blk_fua_rq(rq) ((rq)->flags & REQ_FUA) #define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist) @@ -665,11 +696,12 @@ extern void blk_queue_prep_rq(request_queue_t *, prep_rq_fn *pfn); extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *); extern void blk_queue_dma_alignment(request_queue_t *, int); extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); -extern void blk_queue_ordered(request_queue_t *, int); +extern int blk_queue_ordered(request_queue_t *, unsigned, prepare_flush_fn *); extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *); -extern struct request *blk_start_pre_flush(request_queue_t *,struct request *); -extern int blk_complete_barrier_rq(request_queue_t *, struct request *, int); -extern int blk_complete_barrier_rq_locked(request_queue_t *, struct request *, int); +extern int blk_do_ordered(request_queue_t *, struct request **); +extern unsigned blk_ordered_cur_seq(request_queue_t *); +extern unsigned blk_ordered_req_seq(struct request *); +extern void blk_ordered_complete_seq(request_queue_t *, unsigned, int); extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); extern void blk_dump_rq_flags(struct request *, char *); diff --git a/include/linux/elevator.h b/include/linux/elevator.h index a74c27e..fb80fa4 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h @@ -130,6 +130,7 @@ extern int elv_try_last_merge(request_queue_t *, struct bio *); #define ELEVATOR_INSERT_FRONT 1 #define ELEVATOR_INSERT_BACK 2 #define ELEVATOR_INSERT_SORT 3 +#define ELEVATOR_INSERT_REQUEUE 4 /* * return values from elevator_may_queue_fn -- cgit v1.1 From 461d4e90c8cd049718884cd17c955e231140d3be Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:52:55 +0100 Subject: [BLOCK] update SCSI to use new blk_ordered for barriers All ordered request related stuff delegated to HLD. Midlayer now doens't deal with ordered setting or prepare_flush callback. sd.c updated to deal with blk_queue_ordered setting. Currently, ordered tag isn't used as SCSI midlayer cannot guarantee request ordering. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- drivers/scsi/hosts.c | 9 ------- drivers/scsi/scsi_lib.c | 46 ------------------------------------ drivers/scsi/sd.c | 58 ++++++++++++++++------------------------------ include/scsi/scsi_driver.h | 1 - include/scsi/scsi_host.h | 1 - 5 files changed, 20 insertions(+), 95 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 5b9c2c5..66783c8 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -347,17 +347,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) shost->cmd_per_lun = sht->cmd_per_lun; shost->unchecked_isa_dma = sht->unchecked_isa_dma; shost->use_clustering = sht->use_clustering; - shost->ordered_flush = sht->ordered_flush; shost->ordered_tag = sht->ordered_tag; - /* - * hosts/devices that do queueing must support ordered tags - */ - if (shost->can_queue > 1 && shost->ordered_flush) { - printk(KERN_ERR "scsi: ordered flushes don't support queueing\n"); - shost->ordered_flush = 0; - } - if (sht->max_host_blocked) shost->max_host_blocked = sht->max_host_blocked; else diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 53551f1..7a38b10 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -932,9 +932,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes, int sense_valid = 0; int sense_deferred = 0; - if (blk_complete_barrier_rq(q, req, good_bytes >> 9)) - return; - /* * Free up any indirection buffers we allocated for DMA purposes. * For the case of a READ, we need to copy the data out of the @@ -1199,38 +1196,6 @@ static int scsi_init_io(struct scsi_cmnd *cmd) return BLKPREP_KILL; } -static int scsi_prepare_flush_fn(request_queue_t *q, struct request *rq) -{ - struct scsi_device *sdev = q->queuedata; - struct scsi_driver *drv; - - if (sdev->sdev_state == SDEV_RUNNING) { - drv = *(struct scsi_driver **) rq->rq_disk->private_data; - - if (drv->prepare_flush) - return drv->prepare_flush(q, rq); - } - - return 0; -} - -static void scsi_end_flush_fn(request_queue_t *q, struct request *rq) -{ - struct scsi_device *sdev = q->queuedata; - struct request *flush_rq = rq->end_io_data; - struct scsi_driver *drv; - - if (flush_rq->errors) { - printk("scsi: barrier error, disabling flush support\n"); - blk_queue_ordered(q, QUEUE_ORDERED_NONE); - } - - if (sdev->sdev_state == SDEV_RUNNING) { - drv = *(struct scsi_driver **) rq->rq_disk->private_data; - drv->end_flush(q, rq); - } -} - static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, sector_t *error_sector) { @@ -1703,17 +1668,6 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) blk_queue_segment_boundary(q, shost->dma_boundary); blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); - /* - * ordered tags are superior to flush ordering - */ - if (shost->ordered_tag) - blk_queue_ordered(q, QUEUE_ORDERED_TAG); - else if (shost->ordered_flush) { - blk_queue_ordered(q, QUEUE_ORDERED_FLUSH); - q->prepare_flush_fn = scsi_prepare_flush_fn; - q->end_flush_fn = scsi_end_flush_fn; - } - if (!shost->use_clustering) clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); return q; diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index d651150..2eefc9e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -121,8 +121,7 @@ static void sd_shutdown(struct device *dev); static void sd_rescan(struct device *); static int sd_init_command(struct scsi_cmnd *); static int sd_issue_flush(struct device *, sector_t *); -static void sd_end_flush(request_queue_t *, struct request *); -static int sd_prepare_flush(request_queue_t *, struct request *); +static void sd_prepare_flush(request_queue_t *, struct request *); static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, unsigned char *buffer); @@ -137,8 +136,6 @@ static struct scsi_driver sd_template = { .rescan = sd_rescan, .init_command = sd_init_command, .issue_flush = sd_issue_flush, - .prepare_flush = sd_prepare_flush, - .end_flush = sd_end_flush, }; /* @@ -729,42 +726,13 @@ static int sd_issue_flush(struct device *dev, sector_t *error_sector) return ret; } -static void sd_end_flush(request_queue_t *q, struct request *flush_rq) +static void sd_prepare_flush(request_queue_t *q, struct request *rq) { - struct request *rq = flush_rq->end_io_data; - struct scsi_cmnd *cmd = rq->special; - unsigned int bytes = rq->hard_nr_sectors << 9; - - if (!flush_rq->errors) { - spin_unlock(q->queue_lock); - scsi_io_completion(cmd, bytes, 0); - spin_lock(q->queue_lock); - } else if (blk_barrier_postflush(rq)) { - spin_unlock(q->queue_lock); - scsi_io_completion(cmd, 0, bytes); - spin_lock(q->queue_lock); - } else { - /* - * force journal abort of barriers - */ - end_that_request_first(rq, -EOPNOTSUPP, rq->hard_nr_sectors); - end_that_request_last(rq, -EOPNOTSUPP); - } -} - -static int sd_prepare_flush(request_queue_t *q, struct request *rq) -{ - struct scsi_device *sdev = q->queuedata; - struct scsi_disk *sdkp = dev_get_drvdata(&sdev->sdev_gendev); - - if (!sdkp || !sdkp->WCE) - return 0; - memset(rq->cmd, 0, sizeof(rq->cmd)); - rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; + rq->flags |= REQ_BLOCK_PC; rq->timeout = SD_TIMEOUT; rq->cmd[0] = SYNCHRONIZE_CACHE; - return 1; + rq->cmd_len = 10; } static void sd_rescan(struct device *dev) @@ -1462,6 +1430,7 @@ static int sd_revalidate_disk(struct gendisk *disk) struct scsi_disk *sdkp = scsi_disk(disk); struct scsi_device *sdp = sdkp->device; unsigned char *buffer; + unsigned ordered; SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); @@ -1498,7 +1467,20 @@ static int sd_revalidate_disk(struct gendisk *disk) sd_read_write_protect_flag(sdkp, disk->disk_name, buffer); sd_read_cache_type(sdkp, disk->disk_name, buffer); } - + + /* + * We now have all cache related info, determine how we deal + * with ordered requests. Note that as the current SCSI + * dispatch function can alter request order, we cannot use + * QUEUE_ORDERED_TAG_* even when ordered tag is supported. + */ + if (sdkp->WCE) + ordered = QUEUE_ORDERED_DRAIN_FLUSH; + else + ordered = QUEUE_ORDERED_DRAIN; + + blk_queue_ordered(sdkp->disk->queue, ordered, sd_prepare_flush); + set_capacity(disk, sdkp->capacity); kfree(buffer); @@ -1598,6 +1580,7 @@ static int sd_probe(struct device *dev) strcpy(gd->devfs_name, sdp->devfs_name); gd->private_data = &sdkp->driver; + gd->queue = sdkp->device->request_queue; sd_revalidate_disk(gd); @@ -1605,7 +1588,6 @@ static int sd_probe(struct device *dev) gd->flags = GENHD_FL_DRIVERFS; if (sdp->removable) gd->flags |= GENHD_FL_REMOVABLE; - gd->queue = sdkp->device->request_queue; dev_set_drvdata(dev, sdkp); add_disk(gd); diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h index 850dfa8..02e26c1 100644 --- a/include/scsi/scsi_driver.h +++ b/include/scsi/scsi_driver.h @@ -15,7 +15,6 @@ struct scsi_driver { void (*rescan)(struct device *); int (*issue_flush)(struct device *, sector_t *); int (*prepare_flush)(struct request_queue *, struct request *); - void (*end_flush)(struct request_queue *, struct request *); }; #define to_scsi_driver(drv) \ container_of((drv), struct scsi_driver, gendrv) diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 6cbb198..25f637b 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -392,7 +392,6 @@ struct scsi_host_template { /* * ordered write support */ - unsigned ordered_flush:1; unsigned ordered_tag:1; /* -- cgit v1.1 From 007365ad60387df30f02f01fdc2b6e6432f6c265 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:53:52 +0100 Subject: [BLOCK] scsi: add FUA support to sd Add FUA support for barriers to SCSI disk. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- drivers/scsi/sd.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 2eefc9e..32d4d8d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -102,6 +102,7 @@ struct scsi_disk { u8 write_prot; unsigned WCE : 1; /* state of disk WCE bit */ unsigned RCD : 1; /* state of disk RCD bit, unused */ + unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ }; static DEFINE_IDR(sd_index_idr); @@ -343,6 +344,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) if (block > 0xffffffff) { SCpnt->cmnd[0] += READ_16 - READ_6; + SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0; SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0; SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0; @@ -362,6 +364,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) this_count = 0xffff; SCpnt->cmnd[0] += READ_10 - READ_6; + SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0; SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff; SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff; SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff; @@ -370,6 +373,17 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff; SCpnt->cmnd[8] = (unsigned char) this_count & 0xff; } else { + if (unlikely(blk_fua_rq(rq))) { + /* + * This happens only if this drive failed + * 10byte rw command with ILLEGAL_REQUEST + * during operation and thus turned off + * use_10_for_rw. + */ + printk(KERN_ERR "sd: FUA write on READ/WRITE(6) drive\n"); + return 0; + } + SCpnt->cmnd[1] |= (unsigned char) ((block >> 16) & 0x1f); SCpnt->cmnd[2] = (unsigned char) ((block >> 8) & 0xff); SCpnt->cmnd[3] = (unsigned char) block & 0xff; @@ -1395,10 +1409,18 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname, sdkp->RCD = 0; } + sdkp->DPOFUA = (data.device_specific & 0x10) != 0; + if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) { + printk(KERN_NOTICE "SCSI device %s: uses " + "READ/WRITE(6), disabling FUA\n", diskname); + sdkp->DPOFUA = 0; + } + ct = sdkp->RCD + 2*sdkp->WCE; - printk(KERN_NOTICE "SCSI device %s: drive cache: %s\n", - diskname, types[ct]); + printk(KERN_NOTICE "SCSI device %s: drive cache: %s%s\n", + diskname, types[ct], + sdkp->DPOFUA ? " w/ FUA" : ""); return; } @@ -1475,7 +1497,8 @@ static int sd_revalidate_disk(struct gendisk *disk) * QUEUE_ORDERED_TAG_* even when ordered tag is supported. */ if (sdkp->WCE) - ordered = QUEUE_ORDERED_DRAIN_FLUSH; + ordered = sdkp->DPOFUA + ? QUEUE_ORDERED_DRAIN_FUA : QUEUE_ORDERED_DRAIN_FLUSH; else ordered = QUEUE_ORDERED_DRAIN; -- cgit v1.1 From 93c9338713d4e11102cd09b4670ad42a336b06a3 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:55:00 +0100 Subject: [BLOCK] update libata to use new blk_ordered for barriers Reflect changes in SCSI midlayer and updated to use new ordered request implementation Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- drivers/scsi/ahci.c | 1 - drivers/scsi/ata_piix.c | 1 - drivers/scsi/sata_mv.c | 1 - drivers/scsi/sata_nv.c | 1 - drivers/scsi/sata_promise.c | 1 - drivers/scsi/sata_sil.c | 1 - drivers/scsi/sata_sil24.c | 1 - drivers/scsi/sata_sis.c | 1 - drivers/scsi/sata_svw.c | 1 - drivers/scsi/sata_sx4.c | 1 - drivers/scsi/sata_uli.c | 1 - drivers/scsi/sata_via.c | 1 - drivers/scsi/sata_vsc.c | 1 - 13 files changed, 13 deletions(-) diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c index 887eaa2..d113290 100644 --- a/drivers/scsi/ahci.c +++ b/drivers/scsi/ahci.c @@ -214,7 +214,6 @@ static struct scsi_host_template ahci_sht = { .dma_boundary = AHCI_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations ahci_ops = { diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 0ea2787..4b647ee 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -185,7 +185,6 @@ static struct scsi_host_template piix_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations piix_pata_ops = { diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index b2bf16a..cd54244 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c @@ -374,7 +374,6 @@ static struct scsi_host_template mv_sht = { .dma_boundary = MV_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations mv5_ops = { diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c index 4954896..c0cf52c 100644 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c @@ -235,7 +235,6 @@ static struct scsi_host_template nv_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations nv_ops = { diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index da7fa04..3d1ea09 100644 --- a/drivers/scsi/sata_promise.c +++ b/drivers/scsi/sata_promise.c @@ -114,7 +114,6 @@ static struct scsi_host_template pdc_ata_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations pdc_sata_ops = { diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c index d205348..b017f85 100644 --- a/drivers/scsi/sata_sil.c +++ b/drivers/scsi/sata_sil.c @@ -147,7 +147,6 @@ static struct scsi_host_template sil_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations sil_ops = { diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c index a0ad3ed..9231301 100644 --- a/drivers/scsi/sata_sil24.c +++ b/drivers/scsi/sata_sil24.c @@ -292,7 +292,6 @@ static struct scsi_host_template sil24_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, /* NCQ not supported yet */ }; static const struct ata_port_operations sil24_ops = { diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c index 32e1262..2df8c56 100644 --- a/drivers/scsi/sata_sis.c +++ b/drivers/scsi/sata_sis.c @@ -99,7 +99,6 @@ static struct scsi_host_template sis_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations sis_ops = { diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c index 6e7f7c8..6683735 100644 --- a/drivers/scsi/sata_svw.c +++ b/drivers/scsi/sata_svw.c @@ -303,7 +303,6 @@ static struct scsi_host_template k2_sata_sht = { .proc_info = k2_sata_proc_info, #endif .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index 94b253b..bc87c16 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c @@ -194,7 +194,6 @@ static struct scsi_host_template pdc_sata_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations pdc_20621_ops = { diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c index b2422a0..9635ca7 100644 --- a/drivers/scsi/sata_uli.c +++ b/drivers/scsi/sata_uli.c @@ -87,7 +87,6 @@ static struct scsi_host_template uli_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations uli_ops = { diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c index c762156..6d5b0a7 100644 --- a/drivers/scsi/sata_via.c +++ b/drivers/scsi/sata_via.c @@ -106,7 +106,6 @@ static struct scsi_host_template svia_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; static const struct ata_port_operations svia_sata_ops = { diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index fcfa486..2e2c3b7 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c @@ -235,7 +235,6 @@ static struct scsi_host_template vsc_sata_sht = { .dma_boundary = ATA_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, - .ordered_flush = 1, }; -- cgit v1.1 From 9a3dccc42556537a48f39ee9a9e7ab90a933f766 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:56:18 +0100 Subject: [BLOCK] add FUA support to libata Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- drivers/scsi/libata-core.c | 31 +++++++++++++++++++++++++------ drivers/scsi/libata-scsi.c | 32 ++++++++++++++++++++++++++------ drivers/scsi/libata.h | 4 +++- include/linux/ata.h | 6 +++++- include/linux/libata.h | 3 ++- 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 9ea1025..bdfb0a8 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -562,16 +562,28 @@ static const u8 ata_rw_cmds[] = { ATA_CMD_WRITE_MULTI, ATA_CMD_READ_MULTI_EXT, ATA_CMD_WRITE_MULTI_EXT, + 0, + 0, + 0, + ATA_CMD_WRITE_MULTI_FUA_EXT, /* pio */ ATA_CMD_PIO_READ, ATA_CMD_PIO_WRITE, ATA_CMD_PIO_READ_EXT, ATA_CMD_PIO_WRITE_EXT, + 0, + 0, + 0, + 0, /* dma */ ATA_CMD_READ, ATA_CMD_WRITE, ATA_CMD_READ_EXT, - ATA_CMD_WRITE_EXT + ATA_CMD_WRITE_EXT, + 0, + 0, + 0, + ATA_CMD_WRITE_FUA_EXT }; /** @@ -584,25 +596,32 @@ static const u8 ata_rw_cmds[] = { * LOCKING: * caller. */ -void ata_rwcmd_protocol(struct ata_queued_cmd *qc) +int ata_rwcmd_protocol(struct ata_queued_cmd *qc) { struct ata_taskfile *tf = &qc->tf; struct ata_device *dev = qc->dev; + u8 cmd; - int index, lba48, write; + int index, fua, lba48, write; + fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0; lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; if (dev->flags & ATA_DFLAG_PIO) { tf->protocol = ATA_PROT_PIO; - index = dev->multi_count ? 0 : 4; + index = dev->multi_count ? 0 : 8; } else { tf->protocol = ATA_PROT_DMA; - index = 8; + index = 16; } - tf->command = ata_rw_cmds[index + lba48 + write]; + cmd = ata_rw_cmds[index + fua + lba48 + write]; + if (cmd) { + tf->command = cmd; + return 0; + } + return -1; } static const char * const xfer_mode_str[] = { diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index e0439be..2c644cb 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c @@ -1080,11 +1080,13 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm scsicmd[0] == WRITE_16) tf->flags |= ATA_TFLAG_WRITE; - /* Calculate the SCSI LBA and transfer length. */ + /* Calculate the SCSI LBA, transfer length and FUA. */ switch (scsicmd[0]) { case READ_10: case WRITE_10: scsi_10_lba_len(scsicmd, &block, &n_block); + if (unlikely(scsicmd[1] & (1 << 3))) + tf->flags |= ATA_TFLAG_FUA; break; case READ_6: case WRITE_6: @@ -1099,6 +1101,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm case READ_16: case WRITE_16: scsi_16_lba_len(scsicmd, &block, &n_block); + if (unlikely(scsicmd[1] & (1 << 3))) + tf->flags |= ATA_TFLAG_FUA; break; default: DPRINTK("no-byte command\n"); @@ -1142,7 +1146,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm tf->device |= (block >> 24) & 0xf; } - ata_rwcmd_protocol(qc); + if (unlikely(ata_rwcmd_protocol(qc) < 0)) + goto invalid_fld; qc->nsect = n_block; tf->nsect = n_block & 0xff; @@ -1160,7 +1165,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm if ((block >> 28) || (n_block > 256)) goto out_of_range; - ata_rwcmd_protocol(qc); + if (unlikely(ata_rwcmd_protocol(qc) < 0)) + goto invalid_fld; /* Convert LBA to CHS */ track = (u32)block / dev->sectors; @@ -1695,6 +1701,7 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last) unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, unsigned int buflen) { + struct ata_device *dev = args->dev; u8 *scsicmd = args->cmd->cmnd, *p, *last; const u8 sat_blk_desc[] = { 0, 0, 0, 0, /* number of blocks: sat unspecified */ @@ -1703,6 +1710,7 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, }; u8 pg, spg; unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; + u8 dpofua; VPRINTK("ENTER\n"); @@ -1771,9 +1779,17 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, if (minlen < 1) return 0; + + dpofua = 0; + if (ata_id_has_fua(args->id) && dev->flags & ATA_DFLAG_LBA48 && + (!(dev->flags & ATA_DFLAG_PIO) || dev->multi_count)) + dpofua = 1 << 4; + if (six_byte) { output_len--; rbuf[0] = output_len; + if (minlen > 2) + rbuf[2] |= dpofua; if (ebd) { if (minlen > 3) rbuf[3] = sizeof(sat_blk_desc); @@ -1786,6 +1802,8 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, rbuf[0] = output_len >> 8; if (minlen > 1) rbuf[1] = output_len; + if (minlen > 3) + rbuf[3] |= dpofua; if (ebd) { if (minlen > 7) rbuf[7] = sizeof(sat_blk_desc); @@ -2446,7 +2464,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) if (xlat_func) ata_scsi_translate(ap, dev, cmd, done, xlat_func); else - ata_scsi_simulate(dev->id, cmd, done); + ata_scsi_simulate(ap, dev, cmd, done); } else ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); @@ -2469,14 +2487,16 @@ out_unlock: * spin_lock_irqsave(host_set lock) */ -void ata_scsi_simulate(u16 *id, +void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) { struct ata_scsi_args args; const u8 *scsicmd = cmd->cmnd; - args.id = id; + args.ap = ap; + args.dev = dev; + args.id = dev->id; args.cmd = cmd; args.done = done; diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h index 251e53b..e03ce48 100644 --- a/drivers/scsi/libata.h +++ b/drivers/scsi/libata.h @@ -32,6 +32,8 @@ #define DRV_VERSION "1.20" /* must be exactly four chars */ struct ata_scsi_args { + struct ata_port *ap; + struct ata_device *dev; u16 *id; struct scsi_cmnd *cmd; void (*done)(struct scsi_cmnd *); @@ -41,7 +43,7 @@ struct ata_scsi_args { extern int atapi_enabled; extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, struct ata_device *dev); -extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); +extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc); extern void ata_qc_free(struct ata_queued_cmd *qc); extern int ata_qc_issue(struct ata_queued_cmd *qc); extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); diff --git a/include/linux/ata.h b/include/linux/ata.h index d2873b7..f63dad4 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -129,6 +129,7 @@ enum { ATA_CMD_READ_EXT = 0x25, ATA_CMD_WRITE = 0xCA, ATA_CMD_WRITE_EXT = 0x35, + ATA_CMD_WRITE_FUA_EXT = 0x3D, ATA_CMD_PIO_READ = 0x20, ATA_CMD_PIO_READ_EXT = 0x24, ATA_CMD_PIO_WRITE = 0x30, @@ -137,6 +138,7 @@ enum { ATA_CMD_READ_MULTI_EXT = 0x29, ATA_CMD_WRITE_MULTI = 0xC5, ATA_CMD_WRITE_MULTI_EXT = 0x39, + ATA_CMD_WRITE_MULTI_FUA_EXT = 0xCE, ATA_CMD_SET_FEATURES = 0xEF, ATA_CMD_PACKET = 0xA0, ATA_CMD_VERIFY = 0x40, @@ -192,6 +194,7 @@ enum { ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */ ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */ ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ + ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ }; enum ata_tf_protocols { @@ -245,7 +248,8 @@ struct ata_taskfile { #define ata_id_is_sata(id) ((id)[93] == 0) #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) -#define ata_id_has_flush(id) ((id)[83] & (1 << 12)) +#define ata_id_has_fua(id) ((id)[84] & (1 << 6)) +#define ata_id_has_flush(id) ((id)[83] & (1 << 12)) #define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13)) #define ata_id_has_lba48(id) ((id)[83] & (1 << 10)) #define ata_id_has_wcache(id) ((id)[82] & (1 << 5)) diff --git a/include/linux/libata.h b/include/linux/libata.h index e828e17..6db2c08 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -480,7 +480,8 @@ extern u8 ata_bmdma_status(struct ata_port *ap); extern void ata_bmdma_irq_clear(struct ata_port *ap); extern void ata_qc_complete(struct ata_queued_cmd *qc); extern void ata_eng_timeout(struct ata_port *ap); -extern void ata_scsi_simulate(u16 *id, struct scsi_cmnd *cmd, +extern void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev, + struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)); extern int ata_std_bios_param(struct scsi_device *sdev, struct block_device *bdev, -- cgit v1.1 From 3e087b575496b8aa445192f58e7d996b1cdfa121 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:57:31 +0100 Subject: [BLOCK] update IDE to use new blk_ordered for barriers Update IDE to use new blk_ordered. This change makes the following behavior changes. * Partial completion of the barrier request is handled as failure of the whole ordered sequence. No more partial completion for barrier requests. * Any failure of pre or post flush request results in failure of the whole ordered sequence. So, successfully completed ordered sequence guarantees that all requests prior to the barrier made to physical medium and, then, the while barrier request made to the physical medium. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- drivers/ide/ide-disk.c | 137 +++++++++++++++++++------------------------------ drivers/ide/ide-io.c | 5 +- 2 files changed, 54 insertions(+), 88 deletions(-) diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 4e57679..4b44172 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -681,50 +681,9 @@ static ide_proc_entry_t idedisk_proc[] = { #endif /* CONFIG_PROC_FS */ -static void idedisk_end_flush(request_queue_t *q, struct request *flush_rq) +static void idedisk_prepare_flush(request_queue_t *q, struct request *rq) { ide_drive_t *drive = q->queuedata; - struct request *rq = flush_rq->end_io_data; - int good_sectors = rq->hard_nr_sectors; - int bad_sectors; - sector_t sector; - - if (flush_rq->errors & ABRT_ERR) { - printk(KERN_ERR "%s: barrier support doesn't work\n", drive->name); - blk_queue_ordered(drive->queue, QUEUE_ORDERED_NONE); - blk_queue_issue_flush_fn(drive->queue, NULL); - good_sectors = 0; - } else if (flush_rq->errors) { - good_sectors = 0; - if (blk_barrier_preflush(rq)) { - sector = ide_get_error_location(drive,flush_rq->buffer); - if ((sector >= rq->hard_sector) && - (sector < rq->hard_sector + rq->hard_nr_sectors)) - good_sectors = sector - rq->hard_sector; - } - } - - if (flush_rq->errors) - printk(KERN_ERR "%s: failed barrier write: " - "sector=%Lx(good=%d/bad=%d)\n", - drive->name, (unsigned long long)rq->sector, - good_sectors, - (int) (rq->hard_nr_sectors-good_sectors)); - - bad_sectors = rq->hard_nr_sectors - good_sectors; - - if (good_sectors) - __ide_end_request(drive, rq, 1, good_sectors); - if (bad_sectors) - __ide_end_request(drive, rq, 0, bad_sectors); -} - -static int idedisk_prepare_flush(request_queue_t *q, struct request *rq) -{ - ide_drive_t *drive = q->queuedata; - - if (!drive->wcache) - return 0; memset(rq->cmd, 0, sizeof(rq->cmd)); @@ -735,9 +694,8 @@ static int idedisk_prepare_flush(request_queue_t *q, struct request *rq) rq->cmd[0] = WIN_FLUSH_CACHE; - rq->flags |= REQ_DRIVE_TASK | REQ_SOFTBARRIER; + rq->flags |= REQ_DRIVE_TASK; rq->buffer = rq->cmd; - return 1; } static int idedisk_issue_flush(request_queue_t *q, struct gendisk *disk, @@ -794,27 +752,64 @@ static int set_nowerr(ide_drive_t *drive, int arg) return 0; } +static void update_ordered(ide_drive_t *drive) +{ + struct hd_driveid *id = drive->id; + unsigned ordered = QUEUE_ORDERED_NONE; + prepare_flush_fn *prep_fn = NULL; + issue_flush_fn *issue_fn = NULL; + + if (drive->wcache) { + unsigned long long capacity; + int barrier; + /* + * We must avoid issuing commands a drive does not + * understand or we may crash it. We check flush cache + * is supported. We also check we have the LBA48 flush + * cache if the drive capacity is too large. By this + * time we have trimmed the drive capacity if LBA48 is + * not available so we don't need to recheck that. + */ + capacity = idedisk_capacity(drive); + barrier = ide_id_has_flush_cache(id) && + (drive->addressing == 0 || capacity <= (1ULL << 28) || + ide_id_has_flush_cache_ext(id)); + + printk(KERN_INFO "%s: cache flushes %ssupported\n", + drive->name, barrier ? "" : "not"); + + if (barrier) { + ordered = QUEUE_ORDERED_DRAIN_FLUSH; + prep_fn = idedisk_prepare_flush; + issue_fn = idedisk_issue_flush; + } + } else + ordered = QUEUE_ORDERED_DRAIN; + + blk_queue_ordered(drive->queue, ordered, prep_fn); + blk_queue_issue_flush_fn(drive->queue, issue_fn); +} + static int write_cache(ide_drive_t *drive, int arg) { ide_task_t args; - int err; - - if (!ide_id_has_flush_cache(drive->id)) - return 1; + int err = 1; - memset(&args, 0, sizeof(ide_task_t)); - args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? + if (ide_id_has_flush_cache(drive->id)) { + memset(&args, 0, sizeof(ide_task_t)); + args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; - args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES; - args.command_type = IDE_DRIVE_TASK_NO_DATA; - args.handler = &task_no_data_intr; + args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES; + args.command_type = IDE_DRIVE_TASK_NO_DATA; + args.handler = &task_no_data_intr; + err = ide_raw_taskfile(drive, &args, NULL); + if (err == 0) + drive->wcache = arg; + } - err = ide_raw_taskfile(drive, &args, NULL); - if (err) - return err; + update_ordered(drive); - drive->wcache = arg; - return 0; + return err; } static int do_idedisk_flushcache (ide_drive_t *drive) @@ -888,7 +883,6 @@ static void idedisk_setup (ide_drive_t *drive) { struct hd_driveid *id = drive->id; unsigned long long capacity; - int barrier; idedisk_add_settings(drive); @@ -992,31 +986,6 @@ static void idedisk_setup (ide_drive_t *drive) drive->wcache = 1; write_cache(drive, 1); - - /* - * We must avoid issuing commands a drive does not understand - * or we may crash it. We check flush cache is supported. We also - * check we have the LBA48 flush cache if the drive capacity is - * too large. By this time we have trimmed the drive capacity if - * LBA48 is not available so we don't need to recheck that. - */ - barrier = 0; - if (ide_id_has_flush_cache(id)) - barrier = 1; - if (drive->addressing == 1) { - /* Can't issue the correct flush ? */ - if (capacity > (1ULL << 28) && !ide_id_has_flush_cache_ext(id)) - barrier = 0; - } - - printk(KERN_INFO "%s: cache flushes %ssupported\n", - drive->name, barrier ? "" : "not "); - if (barrier) { - blk_queue_ordered(drive->queue, QUEUE_ORDERED_FLUSH); - drive->queue->prepare_flush_fn = idedisk_prepare_flush; - drive->queue->end_flush_fn = idedisk_end_flush; - blk_queue_issue_flush_fn(drive->queue, idedisk_issue_flush); - } } static void ide_cacheflush_p(ide_drive_t *drive) diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 8435b44..b5dc6df 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -119,10 +119,7 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors) if (!nr_sectors) nr_sectors = rq->hard_cur_sectors; - if (blk_complete_barrier_rq_locked(drive->queue, rq, nr_sectors)) - ret = rq->nr_sectors != 0; - else - ret = __ide_end_request(drive, rq, uptodate, nr_sectors); + ret = __ide_end_request(drive, rq, uptodate, nr_sectors); spin_unlock_irqrestore(&ide_lock, flags); return ret; -- cgit v1.1 From ff5b8cf1491330836d75eede4e5632caa32b776a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 6 Jan 2006 09:58:37 +0100 Subject: [BLOCK] I/O barrier documentation update Update documentation to match new barrier implementation. Signed-off-by: Tejun Heo Signed-off-by: Jens Axboe --- Documentation/block/biodoc.txt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Documentation/block/biodoc.txt b/Documentation/block/biodoc.txt index 303c57a..8e63831 100644 --- a/Documentation/block/biodoc.txt +++ b/Documentation/block/biodoc.txt @@ -263,14 +263,8 @@ A flag in the bio structure, BIO_BARRIER is used to identify a barrier i/o. The generic i/o scheduler would make sure that it places the barrier request and all other requests coming after it after all the previous requests in the queue. Barriers may be implemented in different ways depending on the -driver. A SCSI driver for example could make use of ordered tags to -preserve the necessary ordering with a lower impact on throughput. For IDE -this might be two sync cache flush: a pre and post flush when encountering -a barrier write. - -There is a provision for queues to indicate what kind of barriers they -can provide. This is as of yet unmerged, details will be added here once it -is in the kernel. +driver. For more details regarding I/O barriers, please read barrier.txt +in this directory. 1.2.2 Request Priority/Latency -- cgit v1.1 From 15fc858a0067c800f410a24551a7b461978abf0b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 6 Jan 2006 10:00:50 +0100 Subject: [BLOCK] Correct blk_execute_rq_nowait() prototype --- include/linux/blkdev.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 15db0f1..fb09853 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -613,8 +613,7 @@ extern int blk_rq_map_user_iov(request_queue_t *, struct request *, struct sg_io extern int blk_execute_rq(request_queue_t *, struct gendisk *, struct request *, int); extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *, - struct request *, int, - void (*done)(struct request *)); + struct request *, int, rq_end_io_fn *); static inline request_queue_t *bdev_get_queue(struct block_device *bdev) { -- cgit v1.1 From e650c305ec3178818b317dad37a6d9c7fa8ba28d Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 6 Jan 2006 12:38:30 +0100 Subject: [SCSI] scsi_end_async() needs to take an uptodate parameter Signed-off-by: Jens Axboe --- drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 7a38b10..ba93d6e 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -308,7 +308,7 @@ struct scsi_io_context { static kmem_cache_t *scsi_io_context_cache; -static void scsi_end_async(struct request *req) +static void scsi_end_async(struct request *req, int uptodate) { struct scsi_io_context *sioc = req->end_io_data; -- cgit v1.1 From bd6a59b22fd3bd044bb14978b885bcd042a10e8e Mon Sep 17 00:00:00 2001 From: Joshua Kwan Date: Fri, 6 Jan 2006 00:09:45 -0800 Subject: [PATCH] hfsplus oops fix nls_utf8 is available, and the check in hfsplus_fill_super checks the wrong pointer for NULLness (it checks the saved nls, not the new one that it needs to use.) Signed-off-by: Joshua Kwan Cc: Roman Zippel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/hfsplus/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 8093351..6daaf7c 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c @@ -320,7 +320,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) /* temporarily use utf8 to correctly find the hidden dir below */ nls = sbi->nls; sbi->nls = load_nls("utf8"); - if (!nls) { + if (!sbi->nls) { printk("HFS+: unable to load nls for utf8\n"); err = -EINVAL; goto cleanup; -- cgit v1.1 From 4b2f0260c74324abca76ccaa42d426af163125e7 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 6 Jan 2006 00:09:47 -0800 Subject: [PATCH] nbd: fix TX/RX race condition Janos Haar of First NetCenter Bt. reported numerous crashes involving the NBD driver. With his help, this was tracked down to bogus bio vectors which in turn was the result of a race condition between the receive/transmit routines in the NBD driver. The bug manifests itself like this: CPU0 CPU1 do_nbd_request add req to queuelist nbd_send_request send req head for each bio kmap send nbd_read_stat nbd_find_request nbd_end_request kunmap When CPU1 finishes nbd_end_request, the request and all its associated bio's are freed. So when CPU0 calls kunmap whose argument is derived from the last bio, it may crash. Under normal circumstances, the race occurs only on the last bio. However, if an error is encountered on the remote NBD server (such as an incorrect magic number in the request), or if there were a bug in the server, it is possible for the nbd_end_request to occur any time after the request's addition to the queuelist. The following patch fixes this problem by making sure that requests are not added to the queuelist until after they have been completed transmission. In order for the receiving side to be ready for responses involving requests still being transmitted, the patch introduces the concept of the active request. When a response matches the current active request, its processing is delayed until after the tranmission has come to a stop. This has been tested by Janos and it has been successful in curing this race condition. From: Herbert Xu Here is an updated patch which removes the active_req wait in nbd_clear_queue and the associated memory barrier. I've also clarified this in the comment. Signed-off-by: Herbert Xu Cc: Cc: Paul Clements Signed-off-by: Herbert Xu Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/nbd.c | 122 ++++++++++++++++++++++++++-------------------------- include/linux/nbd.h | 8 ++++ 2 files changed, 68 insertions(+), 62 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 9e268dd..d5c8ee7 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -54,11 +54,15 @@ #include #include #include +#include +#include +#include #include #include #include +#include #include #include @@ -230,14 +234,6 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) request.len = htonl(size); memcpy(request.handle, &req, sizeof(req)); - down(&lo->tx_lock); - - if (!sock || !lo->sock) { - printk(KERN_ERR "%s: Attempted send on closed socket\n", - lo->disk->disk_name); - goto error_out; - } - dprintk(DBG_TX, "%s: request %p: sending control (%s@%llu,%luB)\n", lo->disk->disk_name, req, nbdcmd_to_ascii(nbd_cmd(req)), @@ -276,11 +272,9 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req) } } } - up(&lo->tx_lock); return 0; error_out: - up(&lo->tx_lock); return 1; } @@ -289,9 +283,14 @@ static struct request *nbd_find_request(struct nbd_device *lo, char *handle) struct request *req; struct list_head *tmp; struct request *xreq; + int err; memcpy(&xreq, handle, sizeof(xreq)); + err = wait_event_interruptible(lo->active_wq, lo->active_req != xreq); + if (unlikely(err)) + goto out; + spin_lock(&lo->queue_lock); list_for_each(tmp, &lo->queue_head) { req = list_entry(tmp, struct request, queuelist); @@ -302,7 +301,11 @@ static struct request *nbd_find_request(struct nbd_device *lo, char *handle) return req; } spin_unlock(&lo->queue_lock); - return NULL; + + err = -ENOENT; + +out: + return ERR_PTR(err); } static inline int sock_recv_bvec(struct socket *sock, struct bio_vec *bvec) @@ -331,7 +334,11 @@ static struct request *nbd_read_stat(struct nbd_device *lo) goto harderror; } req = nbd_find_request(lo, reply.handle); - if (req == NULL) { + if (unlikely(IS_ERR(req))) { + result = PTR_ERR(req); + if (result != -ENOENT) + goto harderror; + printk(KERN_ERR "%s: Unexpected reply (%p)\n", lo->disk->disk_name, reply.handle); result = -EBADR; @@ -395,19 +402,24 @@ static void nbd_clear_que(struct nbd_device *lo) BUG_ON(lo->magic != LO_MAGIC); - do { - req = NULL; - spin_lock(&lo->queue_lock); - if (!list_empty(&lo->queue_head)) { - req = list_entry(lo->queue_head.next, struct request, queuelist); - list_del_init(&req->queuelist); - } - spin_unlock(&lo->queue_lock); - if (req) { - req->errors++; - nbd_end_request(req); - } - } while (req); + /* + * Because we have set lo->sock to NULL under the tx_lock, all + * modifications to the list must have completed by now. For + * the same reason, the active_req must be NULL. + * + * As a consequence, we don't need to take the spin lock while + * purging the list here. + */ + BUG_ON(lo->sock); + BUG_ON(lo->active_req); + + while (!list_empty(&lo->queue_head)) { + req = list_entry(lo->queue_head.next, struct request, + queuelist); + list_del_init(&req->queuelist); + req->errors++; + nbd_end_request(req); + } } /* @@ -435,11 +447,6 @@ static void do_nbd_request(request_queue_t * q) BUG_ON(lo->magic != LO_MAGIC); - if (!lo->file) { - printk(KERN_ERR "%s: Request when not-ready\n", - lo->disk->disk_name); - goto error_out; - } nbd_cmd(req) = NBD_CMD_READ; if (rq_data_dir(req) == WRITE) { nbd_cmd(req) = NBD_CMD_WRITE; @@ -453,32 +460,34 @@ static void do_nbd_request(request_queue_t * q) req->errors = 0; spin_unlock_irq(q->queue_lock); - spin_lock(&lo->queue_lock); - - if (!lo->file) { - spin_unlock(&lo->queue_lock); - printk(KERN_ERR "%s: failed between accept and semaphore, file lost\n", - lo->disk->disk_name); + down(&lo->tx_lock); + if (unlikely(!lo->sock)) { + up(&lo->tx_lock); + printk(KERN_ERR "%s: Attempted send on closed socket\n", + lo->disk->disk_name); req->errors++; nbd_end_request(req); spin_lock_irq(q->queue_lock); continue; } - list_add(&req->queuelist, &lo->queue_head); - spin_unlock(&lo->queue_lock); + lo->active_req = req; if (nbd_send_req(lo, req) != 0) { printk(KERN_ERR "%s: Request send failed\n", lo->disk->disk_name); - if (nbd_find_request(lo, (char *)&req) != NULL) { - /* we still own req */ - req->errors++; - nbd_end_request(req); - } else /* we're racing with nbd_clear_que */ - printk(KERN_DEBUG "nbd: can't find req\n"); + req->errors++; + nbd_end_request(req); + } else { + spin_lock(&lo->queue_lock); + list_add(&req->queuelist, &lo->queue_head); + spin_unlock(&lo->queue_lock); } + lo->active_req = NULL; + up(&lo->tx_lock); + wake_up_all(&lo->active_wq); + spin_lock_irq(q->queue_lock); continue; @@ -529,17 +538,10 @@ static int nbd_ioctl(struct inode *inode, struct file *file, down(&lo->tx_lock); lo->sock = NULL; up(&lo->tx_lock); - spin_lock(&lo->queue_lock); file = lo->file; lo->file = NULL; - spin_unlock(&lo->queue_lock); nbd_clear_que(lo); - spin_lock(&lo->queue_lock); - if (!list_empty(&lo->queue_head)) { - printk(KERN_ERR "nbd: disconnect: some requests are in progress -> please try again.\n"); - error = -EBUSY; - } - spin_unlock(&lo->queue_lock); + BUG_ON(!list_empty(&lo->queue_head)); if (file) fput(file); return error; @@ -598,24 +600,19 @@ static int nbd_ioctl(struct inode *inode, struct file *file, lo->sock = NULL; } up(&lo->tx_lock); - spin_lock(&lo->queue_lock); file = lo->file; lo->file = NULL; - spin_unlock(&lo->queue_lock); nbd_clear_que(lo); printk(KERN_WARNING "%s: queue cleared\n", lo->disk->disk_name); if (file) fput(file); return lo->harderror; case NBD_CLEAR_QUE: - down(&lo->tx_lock); - if (lo->sock) { - up(&lo->tx_lock); - return 0; /* probably should be error, but that would - * break "nbd-client -d", so just return 0 */ - } - up(&lo->tx_lock); - nbd_clear_que(lo); + /* + * This is for compatibility only. The queue is always cleared + * by NBD_DO_IT or NBD_CLEAR_SOCK. + */ + BUG_ON(!lo->sock && !list_empty(&lo->queue_head)); return 0; case NBD_PRINT_DEBUG: printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n", @@ -688,6 +685,7 @@ static int __init nbd_init(void) spin_lock_init(&nbd_dev[i].queue_lock); INIT_LIST_HEAD(&nbd_dev[i].queue_head); init_MUTEX(&nbd_dev[i].tx_lock); + init_waitqueue_head(&nbd_dev[i].active_wq); nbd_dev[i].blksize = 1024; nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ disk->major = NBD_MAJOR; diff --git a/include/linux/nbd.h b/include/linux/nbd.h index 090e210..f95d51f 100644 --- a/include/linux/nbd.h +++ b/include/linux/nbd.h @@ -37,18 +37,26 @@ enum { /* userspace doesn't need the nbd_device structure */ #ifdef __KERNEL__ +#include + /* values for flags field */ #define NBD_READ_ONLY 0x0001 #define NBD_WRITE_NOCHK 0x0002 +struct request; + struct nbd_device { int flags; int harderror; /* Code of hard error */ struct socket * sock; struct file * file; /* If == NULL, device is not ready, yet */ int magic; + spinlock_t queue_lock; struct list_head queue_head;/* Requests are added here... */ + struct request *active_req; + wait_queue_head_t active_wq; + struct semaphore tx_lock; struct gendisk *disk; int blksize; -- cgit v1.1 From 1f1e030bf75774b6a283518e1534d598e14147d4 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:09:49 -0800 Subject: [PATCH] knfsd: fix hash function for IP addresses on 64bit little-endian machines. The hash.h hash_long function, when used on a 64 bit machine, ignores many of the middle-order bits. (The prime chosen it too bit-sparse). IP addresses for clients of an NFS server are very likely to differ only in the low-order bits. As addresses are stored in network-byte-order, these bits become middle-order bits in a little-endian 64bit 'long', and so do not contribute to the hash. Thus you can have the situation where all clients appear on one hash chain. So, until hash_long is fixed (or maybe forever), us a hash function that works well on IP addresses - xor the bytes together. Thanks to "Iozone" for identifying this problem. Cc: "Iozone" Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcauth_unix.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index cac2e77..3e6c694 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c @@ -101,10 +101,22 @@ static void ip_map_put(struct cache_head *item, struct cache_detail *cd) } } +#if IP_HASHBITS == 8 +/* hash_long on a 64 bit machine is currently REALLY BAD for + * IP addresses in reverse-endian (i.e. on a little-endian machine). + * So use a trivial but reliable hash instead + */ +static inline int hash_ip(unsigned long ip) +{ + int hash = ip ^ (ip>>16); + return (hash ^ (hash>>8)) & 0xff; +} +#endif + static inline int ip_map_hash(struct ip_map *item) { return hash_str(item->m_class, IP_HASHBITS) ^ - hash_long((unsigned long)item->m_addr.s_addr, IP_HASHBITS); + hash_ip((unsigned long)item->m_addr.s_addr); } static inline int ip_map_match(struct ip_map *item, struct ip_map *tmp) { -- cgit v1.1 From 817c41d76e9eaf72044268b0e545a547abadc0bb Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 6 Jan 2006 00:09:50 -0800 Subject: [PATCH] alpha: dma_map_page() fix Cc: Ivan Kokshaysky Cc: Richard Henderson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-alpha/dma-mapping.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-alpha/dma-mapping.h b/include/asm-alpha/dma-mapping.h index 680f7ec..9dc7256 100644 --- a/include/asm-alpha/dma-mapping.h +++ b/include/asm-alpha/dma-mapping.h @@ -16,7 +16,7 @@ #define dma_free_coherent(dev, size, va, addr) \ pci_free_consistent(alpha_gendev_to_pci(dev), size, va, addr) #define dma_map_page(dev, page, off, size, dir) \ - pci_map_single(alpha_gendev_to_pci(dev), page, off, size, dir) + pci_map_page(alpha_gendev_to_pci(dev), page, off, size, dir) #define dma_unmap_page(dev, addr, size, dir) \ pci_unmap_page(alpha_gendev_to_pci(dev), addr, size, dir) #define dma_map_sg(dev, sg, nents, dir) \ -- cgit v1.1 From a576219aca70e6700705a9836e098dbecd25fb56 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 6 Jan 2006 00:09:50 -0800 Subject: [PATCH] swsusp: resume_store() retval fix - This function returns -EINVAL all the time. Fix. - Decruftify it a bit too. - Writing to it doesn't seem to do what it's suppoed to do. Cc: Pavel Machek Cc: "Rafael J. Wysocki" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/power/disk.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 027322a..4d944b2 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c @@ -363,30 +363,28 @@ static ssize_t resume_show(struct subsystem * subsys, char *buf) MINOR(swsusp_resume_device)); } -static ssize_t resume_store(struct subsystem * subsys, const char * buf, size_t n) +static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n) { - int len; - char *p; unsigned int maj, min; - int error = -EINVAL; dev_t res; + int ret = -EINVAL; - p = memchr(buf, '\n', n); - len = p ? p - buf : n; + if (sscanf(buf, "%u:%u", &maj, &min) != 2) + goto out; - if (sscanf(buf, "%u:%u", &maj, &min) == 2) { - res = MKDEV(maj,min); - if (maj == MAJOR(res) && min == MINOR(res)) { - down(&pm_sem); - swsusp_resume_device = res; - up(&pm_sem); - printk("Attempting manual resume\n"); - noresume = 0; - software_resume(); - } - } + res = MKDEV(maj,min); + if (maj != MAJOR(res) || min != MINOR(res)) + goto out; - return error >= 0 ? n : error; + down(&pm_sem); + swsusp_resume_device = res; + up(&pm_sem); + printk("Attempting manual resume\n"); + noresume = 0; + software_resume(); + ret = n; +out: + return ret; } power_attr(resume); -- cgit v1.1 From 47f3a867f6310d6abfa185ab12baaba7ed1d69af Mon Sep 17 00:00:00 2001 From: Paul Jackson Date: Fri, 6 Jan 2006 00:10:32 -0800 Subject: [PATCH] mm: fix __alloc_pages cpuset ALLOC_* flags Two changes to the setting of the ALLOC_CPUSET flag in mm/page_alloc.c:__alloc_pages() - A bug fix - the "ignoring mins" case should not be honoring ALLOC_CPUSET. This case of all cases, since it is handling a request that will free up more memory than is asked for (exiting tasks, e.g.) should be allowed to escape cpuset constraints when memory is tight. - A logic change to make it simpler. Honor cpusets even on GFP_ATOMIC (!wait) requests. With this, cpuset confinement applies to all requests except ALLOC_NO_WATERMARKS, so that in a subsequent cleanup patch, I can remove the ALLOC_CPUSET flag entirely. Since I don't know any real reason this logic has to be either way, I am choosing the path of the simplest code. Signed-off-by: Paul Jackson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index fe14a8c..1e49dc7 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -903,8 +903,7 @@ restart: alloc_flags |= ALLOC_HARDER; if (gfp_mask & __GFP_HIGH) alloc_flags |= ALLOC_HIGH; - if (wait) - alloc_flags |= ALLOC_CPUSET; + alloc_flags |= ALLOC_CPUSET; /* * Go through the zonelist again. Let __GFP_HIGH and allocations @@ -926,7 +925,7 @@ restart: nofail_alloc: /* go through the zonelist yet again, ignoring mins */ page = get_page_from_freelist(gfp_mask, order, - zonelist, ALLOC_NO_WATERMARKS|ALLOC_CPUSET); + zonelist, ALLOC_NO_WATERMARKS); if (page) goto got_pg; if (gfp_mask & __GFP_NOFAIL) { -- cgit v1.1 From 5ac24eefd1d89bc6aa2817741c3bd5d4205b2efd Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 6 Jan 2006 00:10:33 -0800 Subject: [PATCH] memhotplug: __add_section remove unused pgdat definition __add_section defines an unused pointer to the zones pgdat. Remove this definition. This fixes a compile warning. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/memory_hotplug.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f6d4af8..a918f77 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -42,7 +42,6 @@ extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn, int nr_pages); static int __add_section(struct zone *zone, unsigned long phys_start_pfn) { - struct pglist_data *pgdat = zone->zone_pgdat; int nr_pages = PAGES_PER_SECTION; int ret; -- cgit v1.1 From 98a38ebdda69f1498be4f618d8d919695c8d6352 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 6 Jan 2006 00:10:35 -0800 Subject: [PATCH] memhotplug: register_ and unregister_memory_notifier should be global Both register_memory_notifer and unregister_memory_notifier are global and declared so in linux/memory.h. Update the HOTPLUG specific definitions to match. This fixes a compile warning when HOTPLUG is enabled. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/base/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 7e1d077..19fe9315 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -49,12 +49,12 @@ static struct kset_uevent_ops memory_uevent_ops = { static struct notifier_block *memory_chain; -static int register_memory_notifier(struct notifier_block *nb) +int register_memory_notifier(struct notifier_block *nb) { return notifier_chain_register(&memory_chain, nb); } -static void unregister_memory_notifier(struct notifier_block *nb) +void unregister_memory_notifier(struct notifier_block *nb) { notifier_chain_unregister(&memory_chain, nb); } -- cgit v1.1 From 900b2b463dc6e65ec474d6880412c63c25b3aea9 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 6 Jan 2006 00:10:35 -0800 Subject: [PATCH] memhotplug: register_memory should be global register_memory is global and declared so in linux/memory.h. Update the HOTPLUG specific definition to match. This fixes a compile warning when HOTPLUG is enabled. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/base/memory.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 19fe9315..58801d7 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -62,8 +62,7 @@ void unregister_memory_notifier(struct notifier_block *nb) /* * register_memory - Setup a sysfs device for a memory block */ -static int -register_memory(struct memory_block *memory, struct mem_section *section, +int register_memory(struct memory_block *memory, struct mem_section *section, struct node *root) { int error; -- cgit v1.1 From d7339071f6a8b50101d7ba327926b770f22d5d8b Mon Sep 17 00:00:00 2001 From: Hans Reiser Date: Fri, 6 Jan 2006 00:10:36 -0800 Subject: [PATCH] reiser4: vfs: add truncate_inode_pages_range() This patch makes truncate_inode_pages_range from truncate_inode_pages. truncate_inode_pages became a one-liner call to truncate_inode_pages_range. Reiser4 needs truncate_inode_pages_ranges because it tries to keep correspondence between existences of metadata pointing to data pages and pages to which those metadata point to. So, when metadata of certain part of file is removed from filesystem tree, only pages of corresponding range are to be truncated. (Needed by the madvise(MADV_REMOVE) patch) Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mm.h | 2 ++ mm/truncate.c | 44 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a06a84d..92acae9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -896,6 +896,8 @@ extern unsigned long do_brk(unsigned long, unsigned long); /* filemap.c */ extern unsigned long page_unuse(struct page *); extern void truncate_inode_pages(struct address_space *, loff_t); +extern void truncate_inode_pages_range(struct address_space *, + loff_t lstart, loff_t lend); /* generic vm_area_ops exported for stackable file systems */ extern struct page *filemap_nopage(struct vm_area_struct *, unsigned long, int *); diff --git a/mm/truncate.c b/mm/truncate.c index 9173ab50..7dee327 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -82,12 +82,15 @@ invalidate_complete_page(struct address_space *mapping, struct page *page) } /** - * truncate_inode_pages - truncate *all* the pages from an offset + * truncate_inode_pages - truncate range of pages specified by start and + * end byte offsets * @mapping: mapping to truncate * @lstart: offset from which to truncate + * @lend: offset to which to truncate * - * Truncate the page cache at a set offset, removing the pages that are beyond - * that offset (and zeroing out partial pages). + * Truncate the page cache, removing the pages that are between + * specified offsets (and zeroing out partial page + * (if lstart is not page aligned)). * * Truncate takes two passes - the first pass is nonblocking. It will not * block on page locks and it will not block on writeback. The second pass @@ -101,12 +104,12 @@ invalidate_complete_page(struct address_space *mapping, struct page *page) * We pass down the cache-hot hint to the page freeing code. Even if the * mapping is large, it is probably the case that the final pages are the most * recently touched, and freeing happens in ascending file offset order. - * - * Called under (and serialised by) inode->i_sem. */ -void truncate_inode_pages(struct address_space *mapping, loff_t lstart) +void truncate_inode_pages_range(struct address_space *mapping, + loff_t lstart, loff_t lend) { const pgoff_t start = (lstart + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; + pgoff_t end; const unsigned partial = lstart & (PAGE_CACHE_SIZE - 1); struct pagevec pvec; pgoff_t next; @@ -115,13 +118,22 @@ void truncate_inode_pages(struct address_space *mapping, loff_t lstart) if (mapping->nrpages == 0) return; + BUG_ON((lend & (PAGE_CACHE_SIZE - 1)) != (PAGE_CACHE_SIZE - 1)); + end = (lend >> PAGE_CACHE_SHIFT); + pagevec_init(&pvec, 0); next = start; - while (pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) { + while (next <= end && + pagevec_lookup(&pvec, mapping, next, PAGEVEC_SIZE)) { for (i = 0; i < pagevec_count(&pvec); i++) { struct page *page = pvec.pages[i]; pgoff_t page_index = page->index; + if (page_index > end) { + next = page_index; + break; + } + if (page_index > next) next = page_index; next++; @@ -157,9 +169,15 @@ void truncate_inode_pages(struct address_space *mapping, loff_t lstart) next = start; continue; } + if (pvec.pages[0]->index > end) { + pagevec_release(&pvec); + break; + } for (i = 0; i < pagevec_count(&pvec); i++) { struct page *page = pvec.pages[i]; + if (page->index > end) + break; lock_page(page); wait_on_page_writeback(page); if (page->index > next) @@ -171,7 +189,19 @@ void truncate_inode_pages(struct address_space *mapping, loff_t lstart) pagevec_release(&pvec); } } +EXPORT_SYMBOL(truncate_inode_pages_range); +/** + * truncate_inode_pages - truncate *all* the pages from an offset + * @mapping: mapping to truncate + * @lstart: offset from which to truncate + * + * Called under (and serialised by) inode->i_sem. + */ +void truncate_inode_pages(struct address_space *mapping, loff_t lstart) +{ + truncate_inode_pages_range(mapping, lstart, (loff_t)-1); +} EXPORT_SYMBOL(truncate_inode_pages); /** -- cgit v1.1 From f6b3ec238d12c8cc6cc71490c6e3127988460349 Mon Sep 17 00:00:00 2001 From: Badari Pulavarty Date: Fri, 6 Jan 2006 00:10:38 -0800 Subject: [PATCH] madvise(MADV_REMOVE): remove pages from tmpfs shm backing store Here is the patch to implement madvise(MADV_REMOVE) - which frees up a given range of pages & its associated backing store. Current implementation supports only shmfs/tmpfs and other filesystems return -ENOSYS. "Some app allocates large tmpfs files, then when some task quits and some client disconnect, some memory can be released. However the only way to release tmpfs-swap is to MADV_REMOVE". - Andrea Arcangeli Databases want to use this feature to drop a section of their bufferpool (shared memory segments) - without writing back to disk/swap space. This feature is also useful for supporting hot-plug memory on UML. Concerns raised by Andrew Morton: - "We have no plan for holepunching! If we _do_ have such a plan (or might in the future) then what would the API look like? I think sys_holepunch(fd, start, len), so we should start out with that." - Using madvise is very weird, because people will ask "why do I need to mmap my file before I can stick a hole in it?" - None of the other madvise operations call into the filesystem in this manner. A broad question is: is this capability an MM operation or a filesytem operation? truncate, for example, is a filesystem operation which sometimes has MM side-effects. madvise is an mm operation and with this patch, it gains FS side-effects, only they're really, really significant ones." Comments: - Andrea suggested the fs operation too but then it's more efficient to have it as a mm operation with fs side effects, because they don't immediatly know fd and physical offset of the range. It's possible to fixup in userland and to use the fs operation but it's more expensive, the vmas are already in the kernel and we can use them. Short term plan & Future Direction: - We seem to need this interface only for shmfs/tmpfs files in the short term. We have to add hooks into the filesystem for correctness and completeness. This is what this patch does. - In the future, plan is to support both fs and mmap apis also. This also involves (other) filesystem specific functions to be implemented. - Current patch doesn't support VM_NONLINEAR - which can be addressed in the future. Signed-off-by: Badari Pulavarty Cc: Hugh Dickins Cc: Andrea Arcangeli Cc: Michael Kerrisk Cc: Ulrich Drepper Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-alpha/mman.h | 1 + include/asm-arm/mman.h | 1 + include/asm-arm26/mman.h | 1 + include/asm-cris/mman.h | 1 + include/asm-frv/mman.h | 1 + include/asm-h8300/mman.h | 1 + include/asm-i386/mman.h | 1 + include/asm-ia64/mman.h | 1 + include/asm-m32r/mman.h | 1 + include/asm-m68k/mman.h | 1 + include/asm-mips/mman.h | 1 + include/asm-parisc/mman.h | 1 + include/asm-powerpc/mman.h | 1 + include/asm-s390/mman.h | 1 + include/asm-sh/mman.h | 1 + include/asm-sparc/mman.h | 1 + include/asm-sparc64/mman.h | 1 + include/asm-v850/mman.h | 1 + include/asm-x86_64/mman.h | 1 + include/asm-xtensa/mman.h | 1 + include/linux/fs.h | 1 + include/linux/mm.h | 1 + mm/madvise.c | 35 +++++++++++++++++++++++++++++++++++ mm/memory.c | 25 ++++++++++++++++++++++++- mm/shmem.c | 32 ++++++++++++++++++++++++-------- 25 files changed, 105 insertions(+), 9 deletions(-) diff --git a/include/asm-alpha/mman.h b/include/asm-alpha/mman.h index eb9c279..f643953 100644 --- a/include/asm-alpha/mman.h +++ b/include/asm-alpha/mman.h @@ -42,6 +42,7 @@ #define MADV_WILLNEED 3 /* will need these pages */ #define MADV_SPACEAVAIL 5 /* ensure resources are available */ #define MADV_DONTNEED 6 /* don't need these pages */ +#define MADV_REMOVE 7 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-arm/mman.h b/include/asm-arm/mman.h index 8e4f69c..f0bebca 100644 --- a/include/asm-arm/mman.h +++ b/include/asm-arm/mman.h @@ -35,6 +35,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-arm26/mman.h b/include/asm-arm26/mman.h index cc27b82..0ed7780 100644 --- a/include/asm-arm26/mman.h +++ b/include/asm-arm26/mman.h @@ -35,6 +35,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-cris/mman.h b/include/asm-cris/mman.h index 8570e72..5a382b8 100644 --- a/include/asm-cris/mman.h +++ b/include/asm-cris/mman.h @@ -37,6 +37,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-frv/mman.h b/include/asm-frv/mman.h index c684720..8af4a41 100644 --- a/include/asm-frv/mman.h +++ b/include/asm-frv/mman.h @@ -35,6 +35,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-h8300/mman.h b/include/asm-h8300/mman.h index 63f727a..744a8fb 100644 --- a/include/asm-h8300/mman.h +++ b/include/asm-h8300/mman.h @@ -35,6 +35,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-i386/mman.h b/include/asm-i386/mman.h index 196619a..ba4941e 100644 --- a/include/asm-i386/mman.h +++ b/include/asm-i386/mman.h @@ -35,6 +35,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-ia64/mman.h b/include/asm-ia64/mman.h index 1c0a73a..828beb2 100644 --- a/include/asm-ia64/mman.h +++ b/include/asm-ia64/mman.h @@ -43,6 +43,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-m32r/mman.h b/include/asm-m32r/mman.h index 011f6d9..12e2974 100644 --- a/include/asm-m32r/mman.h +++ b/include/asm-m32r/mman.h @@ -37,6 +37,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-m68k/mman.h b/include/asm-m68k/mman.h index f831c4e..ea262ab 100644 --- a/include/asm-m68k/mman.h +++ b/include/asm-m68k/mman.h @@ -35,6 +35,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-mips/mman.h b/include/asm-mips/mman.h index 6206095..dd17c8b 100644 --- a/include/asm-mips/mman.h +++ b/include/asm-mips/mman.h @@ -65,6 +65,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-parisc/mman.h b/include/asm-parisc/mman.h index e829607..736b0ab 100644 --- a/include/asm-parisc/mman.h +++ b/include/asm-parisc/mman.h @@ -38,6 +38,7 @@ #define MADV_SPACEAVAIL 5 /* insure that resources are reserved */ #define MADV_VPS_PURGE 6 /* Purge pages from VM page cache */ #define MADV_VPS_INHERIT 7 /* Inherit parents page size */ +#define MADV_REMOVE 8 /* remove these pages & resources */ /* The range 12-64 is reserved for page size specification. */ #define MADV_4K_PAGES 12 /* Use 4K pages */ diff --git a/include/asm-powerpc/mman.h b/include/asm-powerpc/mman.h index f5e5342..a2e34c2 100644 --- a/include/asm-powerpc/mman.h +++ b/include/asm-powerpc/mman.h @@ -44,6 +44,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-s390/mman.h b/include/asm-s390/mman.h index ea86bd1..c8d5409 100644 --- a/include/asm-s390/mman.h +++ b/include/asm-s390/mman.h @@ -43,6 +43,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-sh/mman.h b/include/asm-sh/mman.h index 3ebab5f..693bd55 100644 --- a/include/asm-sh/mman.h +++ b/include/asm-sh/mman.h @@ -35,6 +35,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-sparc/mman.h b/include/asm-sparc/mman.h index 138eb81..98435ad 100644 --- a/include/asm-sparc/mman.h +++ b/include/asm-sparc/mman.h @@ -54,6 +54,7 @@ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ #define MADV_FREE 0x5 /* (Solaris) contents can be freed */ +#define MADV_REMOVE 0x6 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-sparc64/mman.h b/include/asm-sparc64/mman.h index 01cecf5..cb4b615 100644 --- a/include/asm-sparc64/mman.h +++ b/include/asm-sparc64/mman.h @@ -54,6 +54,7 @@ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ #define MADV_FREE 0x5 /* (Solaris) contents can be freed */ +#define MADV_REMOVE 0x6 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-v850/mman.h b/include/asm-v850/mman.h index e2b9008..edc7996 100644 --- a/include/asm-v850/mman.h +++ b/include/asm-v850/mman.h @@ -32,6 +32,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-x86_64/mman.h b/include/asm-x86_64/mman.h index 78e60a4..d0e97b7 100644 --- a/include/asm-x86_64/mman.h +++ b/include/asm-x86_64/mman.h @@ -36,6 +36,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/asm-xtensa/mman.h b/include/asm-xtensa/mman.h index 9a95a45..082a750 100644 --- a/include/asm-xtensa/mman.h +++ b/include/asm-xtensa/mman.h @@ -72,6 +72,7 @@ #define MADV_SEQUENTIAL 0x2 /* read-ahead aggressively */ #define MADV_WILLNEED 0x3 /* pre-fault pages */ #define MADV_DONTNEED 0x4 /* discard these pages */ +#define MADV_REMOVE 0x5 /* remove these pages & resources */ /* compatibility flags */ #define MAP_ANON MAP_ANONYMOUS diff --git a/include/linux/fs.h b/include/linux/fs.h index ed9a41a..115e72b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1050,6 +1050,7 @@ struct inode_operations { ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); ssize_t (*listxattr) (struct dentry *, char *, size_t); int (*removexattr) (struct dentry *, const char *); + void (*truncate_range)(struct inode *, loff_t, loff_t); }; struct seq_file; diff --git a/include/linux/mm.h b/include/linux/mm.h index 92acae9..6c9be99 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -690,6 +690,7 @@ static inline void unmap_shared_mapping_range(struct address_space *mapping, } extern int vmtruncate(struct inode * inode, loff_t offset); +extern int vmtruncate_range(struct inode * inode, loff_t offset, loff_t end); extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot); extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot); extern int __handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access); diff --git a/mm/madvise.c b/mm/madvise.c index 2b7cf04..ae0ae3e 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -140,6 +140,36 @@ static long madvise_dontneed(struct vm_area_struct * vma, return 0; } +/* + * Application wants to free up the pages and associated backing store. + * This is effectively punching a hole into the middle of a file. + * + * NOTE: Currently, only shmfs/tmpfs is supported for this operation. + * Other filesystems return -ENOSYS. + */ +static long madvise_remove(struct vm_area_struct *vma, + unsigned long start, unsigned long end) +{ + struct address_space *mapping; + loff_t offset, endoff; + + if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB)) + return -EINVAL; + + if (!vma->vm_file || !vma->vm_file->f_mapping + || !vma->vm_file->f_mapping->host) { + return -EINVAL; + } + + mapping = vma->vm_file->f_mapping; + + offset = (loff_t)(start - vma->vm_start) + + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); + endoff = (loff_t)(end - vma->vm_start - 1) + + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); + return vmtruncate_range(mapping->host, offset, endoff); +} + static long madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev, unsigned long start, unsigned long end, int behavior) @@ -152,6 +182,9 @@ madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev, case MADV_RANDOM: error = madvise_behavior(vma, prev, start, end, behavior); break; + case MADV_REMOVE: + error = madvise_remove(vma, start, end); + break; case MADV_WILLNEED: error = madvise_willneed(vma, prev, start, end); @@ -190,6 +223,8 @@ madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev, * some pages ahead. * MADV_DONTNEED - the application is finished with the given range, * so the kernel can free resources associated with it. + * MADV_REMOVE - the application wants to free up the given range of + * pages and associated backing store. * * return values: * zero - success diff --git a/mm/memory.c b/mm/memory.c index d8dde07..e249088 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1770,9 +1770,32 @@ out_big: out_busy: return -ETXTBSY; } - EXPORT_SYMBOL(vmtruncate); +int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end) +{ + struct address_space *mapping = inode->i_mapping; + + /* + * If the underlying filesystem is not going to provide + * a way to truncate a range of blocks (punch a hole) - + * we should return failure right now. + */ + if (!inode->i_op || !inode->i_op->truncate_range) + return -ENOSYS; + + down(&inode->i_sem); + down_write(&inode->i_alloc_sem); + unmap_mapping_range(mapping, offset, (end - offset), 1); + truncate_inode_pages_range(mapping, offset, end); + inode->i_op->truncate_range(inode, offset, end); + up_write(&inode->i_alloc_sem); + up(&inode->i_sem); + + return 0; +} +EXPORT_SYMBOL(vmtruncate_range); + /* * Primitive swap readahead code. We simply read an aligned block of * (1 << page_cluster) entries in the swap area. This method is chosen diff --git a/mm/shmem.c b/mm/shmem.c index d9fc277..65c148e 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -457,7 +457,7 @@ static void shmem_free_pages(struct list_head *next) } while (next); } -static void shmem_truncate(struct inode *inode) +static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end) { struct shmem_inode_info *info = SHMEM_I(inode); unsigned long idx; @@ -475,18 +475,27 @@ static void shmem_truncate(struct inode *inode) long nr_swaps_freed = 0; int offset; int freed; + int punch_hole = 0; inode->i_ctime = inode->i_mtime = CURRENT_TIME; - idx = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + idx = (start + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; if (idx >= info->next_index) return; spin_lock(&info->lock); info->flags |= SHMEM_TRUNCATE; - limit = info->next_index; - info->next_index = idx; + if (likely(end == (loff_t) -1)) { + limit = info->next_index; + info->next_index = idx; + } else { + limit = (end + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; + if (limit > info->next_index) + limit = info->next_index; + punch_hole = 1; + } + topdir = info->i_indirect; - if (topdir && idx <= SHMEM_NR_DIRECT) { + if (topdir && idx <= SHMEM_NR_DIRECT && !punch_hole) { info->i_indirect = NULL; nr_pages_to_free++; list_add(&topdir->lru, &pages_to_free); @@ -573,11 +582,12 @@ static void shmem_truncate(struct inode *inode) set_page_private(subdir, page_private(subdir) - freed); if (offset) spin_unlock(&info->lock); - BUG_ON(page_private(subdir) > offset); + if (!punch_hole) + BUG_ON(page_private(subdir) > offset); } if (offset) offset = 0; - else if (subdir) { + else if (subdir && !page_private(subdir)) { dir[diroff] = NULL; nr_pages_to_free++; list_add(&subdir->lru, &pages_to_free); @@ -594,7 +604,7 @@ done2: * Also, though shmem_getpage checks i_size before adding to * cache, no recheck after: so fix the narrow window there too. */ - truncate_inode_pages(inode->i_mapping, inode->i_size); + truncate_inode_pages_range(inode->i_mapping, start, end); } spin_lock(&info->lock); @@ -614,6 +624,11 @@ done2: } } +static void shmem_truncate(struct inode *inode) +{ + shmem_truncate_range(inode, inode->i_size, (loff_t)-1); +} + static int shmem_notify_change(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; @@ -2083,6 +2098,7 @@ static struct file_operations shmem_file_operations = { static struct inode_operations shmem_inode_operations = { .truncate = shmem_truncate, .setattr = shmem_notify_change, + .truncate_range = shmem_truncate_range, }; static struct inode_operations shmem_dir_inode_operations = { -- cgit v1.1 From f0916794f00be44154102dedaeafe68b743078a2 Mon Sep 17 00:00:00 2001 From: Adam Litke Date: Fri, 6 Jan 2006 00:10:40 -0800 Subject: [PATCH] Hugetlb: Remove duplicate i_size check cleanup Signed-off-by: David Gibson Signed-off-by: Adam Litke Cc: William Lee Irwin III Cc: "Seth, Rohit" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/hugetlb.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 3e52df7..acb8641 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -350,19 +350,12 @@ static struct page *find_lock_huge_page(struct address_space *mapping, { struct page *page; int err; - struct inode *inode = mapping->host; - unsigned long size; retry: page = find_lock_page(mapping, idx); if (page) goto out; - /* Check to make sure the mapping hasn't been truncated */ - size = i_size_read(inode) >> HPAGE_SHIFT; - if (idx >= size) - goto out; - if (hugetlb_get_quota(mapping)) goto out; page = alloc_huge_page(); -- cgit v1.1 From 85ef47f74afe96c8c23eaa605f28cc01443c905f Mon Sep 17 00:00:00 2001 From: Adam Litke Date: Fri, 6 Jan 2006 00:10:42 -0800 Subject: [PATCH] Hugetlb: Rename find_lock_page to find_or_alloc_huge_page find_lock_huge_page() isn't a great name, since it does extra things not analagous to find_lock_page(). Rename it find_or_alloc_huge_page() which is closer to the mark. Signed-off-by: David Gibson Signed-off-by: Adam Litke Cc: William Lee Irwin III Cc: "Seth, Rohit" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/hugetlb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index acb8641..fdbbbb9 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -345,8 +345,8 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, flush_tlb_range(vma, start, end); } -static struct page *find_lock_huge_page(struct address_space *mapping, - unsigned long idx) +static struct page *find_or_alloc_huge_page(struct address_space *mapping, + unsigned long idx) { struct page *page; int err; @@ -398,7 +398,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, * Use page lock to guard against racing truncation * before we get page_table_lock. */ - page = find_lock_huge_page(mapping, idx); + page = find_or_alloc_huge_page(mapping, idx); if (!page) goto out; -- cgit v1.1 From 86e5216f8d8aa258ba836caffe2613d79cc9aead Mon Sep 17 00:00:00 2001 From: Adam Litke Date: Fri, 6 Jan 2006 00:10:43 -0800 Subject: [PATCH] Hugetlb: Reorganize hugetlb_fault to prepare for COW This patch splits the "no_page()" type activity into its own function, hugetlb_no_page(). hugetlb_fault() becomes the entry point for hugetlb faults and delegates to the appropriate handler depending on the type of fault. Right now we still have only hugetlb_no_page() but a later patch introduces a COW fault. Signed-off-by: David Gibson Signed-off-by: Adam Litke Cc: William Lee Irwin III Cc: "Seth, Rohit" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/hugetlb.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index fdbbbb9..cf82251 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -376,20 +376,15 @@ out: return page; } -int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, - unsigned long address, int write_access) +int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long address, pte_t *ptep) { int ret = VM_FAULT_SIGBUS; unsigned long idx; unsigned long size; - pte_t *pte; struct page *page; struct address_space *mapping; - pte = huge_pte_alloc(mm, address); - if (!pte) - goto out; - mapping = vma->vm_file->f_mapping; idx = ((address - vma->vm_start) >> HPAGE_SHIFT) + (vma->vm_pgoff >> (HPAGE_SHIFT - PAGE_SHIFT)); @@ -408,11 +403,11 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, goto backout; ret = VM_FAULT_MINOR; - if (!pte_none(*pte)) + if (!pte_none(*ptep)) goto backout; add_mm_counter(mm, file_rss, HPAGE_SIZE / PAGE_SIZE); - set_huge_pte_at(mm, address, pte, make_huge_pte(vma, page)); + set_huge_pte_at(mm, address, ptep, make_huge_pte(vma, page)); spin_unlock(&mm->page_table_lock); unlock_page(page); out: @@ -426,6 +421,27 @@ backout: goto out; } +int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long address, int write_access) +{ + pte_t *ptep; + pte_t entry; + + ptep = huge_pte_alloc(mm, address); + if (!ptep) + return VM_FAULT_OOM; + + entry = *ptep; + if (pte_none(entry)) + return hugetlb_no_page(mm, vma, address, ptep); + + /* + * We could get here if another thread instantiated the pte + * before the test above. + */ + return VM_FAULT_MINOR; +} + int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, struct page **pages, struct vm_area_struct **vmas, unsigned long *position, int *length, int i) -- cgit v1.1 From 1e8f889b10d8d2223105719e36ce45688fedbd59 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 6 Jan 2006 00:10:44 -0800 Subject: [PATCH] Hugetlb: Copy on Write support Implement copy-on-write support for hugetlb mappings so MAP_PRIVATE can be supported. This helps us to safely use hugetlb pages in many more applications. The patch makes the following changes. If needed, I also have it broken out according to the following paragraphs. 1. Add a pair of functions to set/clear write access on huge ptes. The writable check in make_huge_pte is moved out to the caller for use by COW later. 2. Hugetlb copy-on-write requires special case handling in the following situations: - copy_hugetlb_page_range() - Copied pages must be write protected so a COW fault will be triggered (if necessary) if those pages are written to. - find_or_alloc_huge_page() - Only MAP_SHARED pages are added to the page cache. MAP_PRIVATE pages still need to be locked however. 3. Provide hugetlb_cow() and calls from hugetlb_fault() and hugetlb_no_page() which handles the COW fault by making the actual copy. 4. Remove the check in hugetlbfs_file_map() so that MAP_PRIVATE mmaps will be allowed. Make MAP_HUGETLB exempt from the depricated VM_RESERVED mapping check. Signed-off-by: David Gibson Signed-off-by: Adam Litke Cc: William Lee Irwin III Cc: "Seth, Rohit" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/hugetlbfs/inode.c | 3 -- mm/hugetlb.c | 127 +++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 108 insertions(+), 22 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 8c1cef3..8c41315 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -100,9 +100,6 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) loff_t len, vma_len; int ret; - if ((vma->vm_flags & (VM_MAYSHARE | VM_WRITE)) == VM_WRITE) - return -EINVAL; - if (vma->vm_pgoff & (HPAGE_SIZE / PAGE_SIZE - 1)) return -EINVAL; diff --git a/mm/hugetlb.c b/mm/hugetlb.c index cf82251..da8a211 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -261,11 +261,12 @@ struct vm_operations_struct hugetlb_vm_ops = { .nopage = hugetlb_nopage, }; -static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page) +static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, + int writable) { pte_t entry; - if (vma->vm_flags & VM_WRITE) { + if (writable) { entry = pte_mkwrite(pte_mkdirty(mk_pte(page, vma->vm_page_prot))); } else { @@ -277,12 +278,27 @@ static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page) return entry; } +static void set_huge_ptep_writable(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep) +{ + pte_t entry; + + entry = pte_mkwrite(pte_mkdirty(*ptep)); + ptep_set_access_flags(vma, address, ptep, entry, 1); + update_mmu_cache(vma, address, entry); + lazy_mmu_prot_update(entry); +} + + int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, struct vm_area_struct *vma) { pte_t *src_pte, *dst_pte, entry; struct page *ptepage; unsigned long addr; + int cow; + + cow = (vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE; for (addr = vma->vm_start; addr < vma->vm_end; addr += HPAGE_SIZE) { src_pte = huge_pte_offset(src, addr); @@ -294,6 +310,8 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, spin_lock(&dst->page_table_lock); spin_lock(&src->page_table_lock); if (!pte_none(*src_pte)) { + if (cow) + ptep_set_wrprotect(src, addr, src_pte); entry = *src_pte; ptepage = pte_page(entry); get_page(ptepage); @@ -346,7 +364,7 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, } static struct page *find_or_alloc_huge_page(struct address_space *mapping, - unsigned long idx) + unsigned long idx, int shared) { struct page *page; int err; @@ -364,26 +382,80 @@ retry: goto out; } - err = add_to_page_cache(page, mapping, idx, GFP_KERNEL); - if (err) { - put_page(page); - hugetlb_put_quota(mapping); - if (err == -EEXIST) - goto retry; - page = NULL; + if (shared) { + err = add_to_page_cache(page, mapping, idx, GFP_KERNEL); + if (err) { + put_page(page); + hugetlb_put_quota(mapping); + if (err == -EEXIST) + goto retry; + page = NULL; + } + } else { + /* Caller expects a locked page */ + lock_page(page); } out: return page; } +static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, + unsigned long address, pte_t *ptep, pte_t pte) +{ + struct page *old_page, *new_page; + int i, avoidcopy; + + old_page = pte_page(pte); + + /* If no-one else is actually using this page, avoid the copy + * and just make the page writable */ + avoidcopy = (page_count(old_page) == 1); + if (avoidcopy) { + set_huge_ptep_writable(vma, address, ptep); + return VM_FAULT_MINOR; + } + + page_cache_get(old_page); + new_page = alloc_huge_page(); + + if (!new_page) { + page_cache_release(old_page); + + /* Logically this is OOM, not a SIGBUS, but an OOM + * could cause the kernel to go killing other + * processes which won't help the hugepage situation + * at all (?) */ + return VM_FAULT_SIGBUS; + } + + spin_unlock(&mm->page_table_lock); + for (i = 0; i < HPAGE_SIZE/PAGE_SIZE; i++) + copy_user_highpage(new_page + i, old_page + i, + address + i*PAGE_SIZE); + spin_lock(&mm->page_table_lock); + + ptep = huge_pte_offset(mm, address & HPAGE_MASK); + if (likely(pte_same(*ptep, pte))) { + /* Break COW */ + set_huge_pte_at(mm, address, ptep, + make_huge_pte(vma, new_page, 1)); + /* Make the old page be freed below */ + new_page = old_page; + } + page_cache_release(new_page); + page_cache_release(old_page); + return VM_FAULT_MINOR; +} + int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, - unsigned long address, pte_t *ptep) + unsigned long address, pte_t *ptep, int write_access) { int ret = VM_FAULT_SIGBUS; unsigned long idx; unsigned long size; struct page *page; struct address_space *mapping; + pte_t new_pte; mapping = vma->vm_file->f_mapping; idx = ((address - vma->vm_start) >> HPAGE_SHIFT) @@ -393,10 +465,13 @@ int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, * Use page lock to guard against racing truncation * before we get page_table_lock. */ - page = find_or_alloc_huge_page(mapping, idx); + page = find_or_alloc_huge_page(mapping, idx, + vma->vm_flags & VM_SHARED); if (!page) goto out; + BUG_ON(!PageLocked(page)); + spin_lock(&mm->page_table_lock); size = i_size_read(mapping->host) >> HPAGE_SHIFT; if (idx >= size) @@ -407,7 +482,15 @@ int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, goto backout; add_mm_counter(mm, file_rss, HPAGE_SIZE / PAGE_SIZE); - set_huge_pte_at(mm, address, ptep, make_huge_pte(vma, page)); + new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE) + && (vma->vm_flags & VM_SHARED))); + set_huge_pte_at(mm, address, ptep, new_pte); + + if (write_access && !(vma->vm_flags & VM_SHARED)) { + /* Optimization, do the COW without a second fault */ + ret = hugetlb_cow(mm, vma, address, ptep, new_pte); + } + spin_unlock(&mm->page_table_lock); unlock_page(page); out: @@ -426,6 +509,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, { pte_t *ptep; pte_t entry; + int ret; ptep = huge_pte_alloc(mm, address); if (!ptep) @@ -433,13 +517,18 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, entry = *ptep; if (pte_none(entry)) - return hugetlb_no_page(mm, vma, address, ptep); + return hugetlb_no_page(mm, vma, address, ptep, write_access); - /* - * We could get here if another thread instantiated the pte - * before the test above. - */ - return VM_FAULT_MINOR; + ret = VM_FAULT_MINOR; + + spin_lock(&mm->page_table_lock); + /* Check for a racing update before calling hugetlb_cow */ + if (likely(pte_same(entry, *ptep))) + if (write_access && !pte_write(entry)) + ret = hugetlb_cow(mm, vma, address, ptep, entry); + spin_unlock(&mm->page_table_lock); + + return ret; } int follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, -- cgit v1.1 From 96df9333c94d7d5aeceb21f6c5e7ae8ff34753cf Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:10:45 -0800 Subject: [PATCH] mm: dequeue a huge page near to this node This was discussed at http://marc.theaimsgroup.com/?l=linux-kernel&m=113166526217117&w=2 This patch changes the dequeueing to select a huge page near the node executing instead of always beginning to check for free nodes from node 0. This will result in a placement of the huge pages near the executing processor improving performance. The existing implementation can place the huge pages far away from the executing processor causing significant degradation of performance. The search starting from zero also means that the lower zones quickly run out of memory. Selecting a huge page near the process distributed the huge pages better. Signed-off-by: Christoph Lameter Cc: William Lee Irwin III Cc: Adam Litke Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/hugetlb.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index da8a211..e93bd63 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -40,14 +40,16 @@ static struct page *dequeue_huge_page(void) { int nid = numa_node_id(); struct page *page = NULL; + struct zonelist *zonelist = NODE_DATA(nid)->node_zonelists; + struct zone **z; - if (list_empty(&hugepage_freelists[nid])) { - for (nid = 0; nid < MAX_NUMNODES; ++nid) - if (!list_empty(&hugepage_freelists[nid])) - break; + for (z = zonelist->zones; *z; z++) { + nid = (*z)->zone_pgdat->node_id; + if (!list_empty(&hugepage_freelists[nid])) + break; } - if (nid >= 0 && nid < MAX_NUMNODES && - !list_empty(&hugepage_freelists[nid])) { + + if (*z) { page = list_entry(hugepage_freelists[nid].next, struct page, lru); list_del(&page->lru); -- cgit v1.1 From 5da7ca86078964cbfe6c83efc1205904587706fe Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:10:46 -0800 Subject: [PATCH] Add NUMA policy support for huge pages. The huge_zonelist() function in the memory policy layer provides an list of zones ordered by NUMA distance. The hugetlb layer will walk that list looking for a zone that has available huge pages but is also in the nodeset of the current cpuset. This patch does not contain the folding of find_or_alloc_huge_page() that was controversial in the earlier discussion. Signed-off-by: Christoph Lameter Cc: Andi Kleen Acked-by: William Lee Irwin III Cc: Adam Litke Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/hugetlb.h | 4 ++-- include/linux/mempolicy.h | 8 ++++++++ mm/hugetlb.c | 24 ++++++++++++++---------- mm/mempolicy.c | 39 ++++++++++++++++++++++++++++++--------- 4 files changed, 54 insertions(+), 21 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 1056717..68d82ad 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -22,7 +22,7 @@ int hugetlb_report_meminfo(char *); int hugetlb_report_node_meminfo(int, char *); int is_hugepage_mem_enough(size_t); unsigned long hugetlb_total_pages(void); -struct page *alloc_huge_page(void); +struct page *alloc_huge_page(struct vm_area_struct *, unsigned long); void free_huge_page(struct page *); int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, int write_access); @@ -97,7 +97,7 @@ static inline unsigned long hugetlb_total_pages(void) #define is_hugepage_only_range(mm, addr, len) 0 #define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) \ do { } while (0) -#define alloc_huge_page() ({ NULL; }) +#define alloc_huge_page(vma, addr) ({ NULL; }) #define free_huge_page(p) ({ (void)(p); BUG(); }) #define hugetlb_fault(mm, vma, addr, write) ({ BUG(); 0; }) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 8b67cf8..817db64 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -156,6 +156,8 @@ extern void numa_default_policy(void); extern void numa_policy_init(void); extern void numa_policy_rebind(const nodemask_t *old, const nodemask_t *new); extern struct mempolicy default_policy; +extern struct zonelist *huge_zonelist(struct vm_area_struct *vma, + unsigned long addr); #else @@ -232,6 +234,12 @@ static inline void numa_policy_rebind(const nodemask_t *old, { } +static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma, + unsigned long addr) +{ + return NODE_DATA(0)->node_zonelists + gfp_zone(GFP_HIGHUSER); +} + #endif /* CONFIG_NUMA */ #endif /* __KERNEL__ */ diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e93bd63..eb40556 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -11,6 +11,8 @@ #include #include #include +#include + #include #include @@ -36,11 +38,12 @@ static void enqueue_huge_page(struct page *page) free_huge_pages_node[nid]++; } -static struct page *dequeue_huge_page(void) +static struct page *dequeue_huge_page(struct vm_area_struct *vma, + unsigned long address) { int nid = numa_node_id(); struct page *page = NULL; - struct zonelist *zonelist = NODE_DATA(nid)->node_zonelists; + struct zonelist *zonelist = huge_zonelist(vma, address); struct zone **z; for (z = zonelist->zones; *z; z++) { @@ -87,13 +90,13 @@ void free_huge_page(struct page *page) spin_unlock(&hugetlb_lock); } -struct page *alloc_huge_page(void) +struct page *alloc_huge_page(struct vm_area_struct *vma, unsigned long addr) { struct page *page; int i; spin_lock(&hugetlb_lock); - page = dequeue_huge_page(); + page = dequeue_huge_page(vma, addr); if (!page) { spin_unlock(&hugetlb_lock); return NULL; @@ -196,7 +199,7 @@ static unsigned long set_max_huge_pages(unsigned long count) spin_lock(&hugetlb_lock); try_to_free_low(count); while (count < nr_huge_pages) { - struct page *page = dequeue_huge_page(); + struct page *page = dequeue_huge_page(NULL, 0); if (!page) break; update_and_free_page(page); @@ -365,8 +368,9 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, flush_tlb_range(vma, start, end); } -static struct page *find_or_alloc_huge_page(struct address_space *mapping, - unsigned long idx, int shared) +static struct page *find_or_alloc_huge_page(struct vm_area_struct *vma, + unsigned long addr, struct address_space *mapping, + unsigned long idx, int shared) { struct page *page; int err; @@ -378,7 +382,7 @@ retry: if (hugetlb_get_quota(mapping)) goto out; - page = alloc_huge_page(); + page = alloc_huge_page(vma, addr); if (!page) { hugetlb_put_quota(mapping); goto out; @@ -418,7 +422,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, } page_cache_get(old_page); - new_page = alloc_huge_page(); + new_page = alloc_huge_page(vma, address); if (!new_page) { page_cache_release(old_page); @@ -467,7 +471,7 @@ int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, * Use page lock to guard against racing truncation * before we get page_table_lock. */ - page = find_or_alloc_huge_page(mapping, idx, + page = find_or_alloc_huge_page(vma, address, mapping, idx, vma->vm_flags & VM_SHARED); if (!page) goto out; diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 72f402c..45c51ac 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -785,6 +785,34 @@ static unsigned offset_il_node(struct mempolicy *pol, return nid; } +/* Determine a node number for interleave */ +static inline unsigned interleave_nid(struct mempolicy *pol, + struct vm_area_struct *vma, unsigned long addr, int shift) +{ + if (vma) { + unsigned long off; + + off = vma->vm_pgoff; + off += (addr - vma->vm_start) >> shift; + return offset_il_node(pol, vma, off); + } else + return interleave_nodes(pol); +} + +/* Return a zonelist suitable for a huge page allocation. */ +struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr) +{ + struct mempolicy *pol = get_vma_policy(current, vma, addr); + + if (pol->policy == MPOL_INTERLEAVE) { + unsigned nid; + + nid = interleave_nid(pol, vma, addr, HPAGE_SHIFT); + return NODE_DATA(nid)->node_zonelists + gfp_zone(GFP_HIGHUSER); + } + return zonelist_policy(GFP_HIGHUSER, pol); +} + /* Allocate a page in interleaved policy. Own path because it needs to do special accounting. */ static struct page *alloc_page_interleave(gfp_t gfp, unsigned order, @@ -833,15 +861,8 @@ alloc_page_vma(gfp_t gfp, struct vm_area_struct *vma, unsigned long addr) if (unlikely(pol->policy == MPOL_INTERLEAVE)) { unsigned nid; - if (vma) { - unsigned long off; - off = vma->vm_pgoff; - off += (addr - vma->vm_start) >> PAGE_SHIFT; - nid = offset_il_node(pol, vma, off); - } else { - /* fall back to process interleaving */ - nid = interleave_nodes(pol); - } + + nid = interleave_nid(pol, vma, addr, PAGE_SHIFT); return alloc_page_interleave(gfp, 0, nid); } return __alloc_pages(gfp, 0, zonelist_policy(gfp, pol)); -- cgit v1.1 From 21abb1478a87e26f5fa71dbcb7cf4264272c2248 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:10:47 -0800 Subject: [PATCH] Remove old node based policy interface from mempolicy.c mempolicy.c contains provisional interface for huge page allocation based on node numbers. This is in use in SLES9 but was never used (AFAIK) in upstream versions of Linux. Huge page allocations now use zonelists to figure out where to allocate pages. The use of zonelists allows us to find the closest hugepage which was the consideration of the NUMA distance for huge page allocations. Remove the obsolete functions. Signed-off-by: Christoph Lameter Cc: Andi Kleen Acked-by: William Lee Irwin III Cc: Adam Litke Acked-by: Paul Jackson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mempolicy.h | 19 ------------------- mm/mempolicy.c | 48 ----------------------------------------------- 2 files changed, 67 deletions(-) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index 817db64..b972f985 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -110,14 +110,6 @@ static inline int mpol_equal(struct mempolicy *a, struct mempolicy *b) #define mpol_set_vma_default(vma) ((vma)->vm_policy = NULL) /* - * Hugetlb policy. i386 hugetlb so far works with node numbers - * instead of zone lists, so give it special interfaces for now. - */ -extern int mpol_first_node(struct vm_area_struct *vma, unsigned long addr); -extern int mpol_node_valid(int nid, struct vm_area_struct *vma, - unsigned long addr); - -/* * Tree of shared policies for a shared memory region. * Maintain the policies in a pseudo mm that contains vmas. The vmas * carry the policy. As a special twist the pseudo mm is indexed in pages, not @@ -184,17 +176,6 @@ static inline struct mempolicy *mpol_copy(struct mempolicy *old) return NULL; } -static inline int mpol_first_node(struct vm_area_struct *vma, unsigned long a) -{ - return numa_node_id(); -} - -static inline int -mpol_node_valid(int nid, struct vm_area_struct *vma, unsigned long a) -{ - return 1; -} - struct shared_policy {}; static inline int mpol_set_shared_policy(struct shared_policy *info, diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 45c51ac..96714e2 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -961,54 +961,6 @@ void __mpol_free(struct mempolicy *p) } /* - * Hugetlb policy. Same as above, just works with node numbers instead of - * zonelists. - */ - -/* Find first node suitable for an allocation */ -int mpol_first_node(struct vm_area_struct *vma, unsigned long addr) -{ - struct mempolicy *pol = get_vma_policy(current, vma, addr); - - switch (pol->policy) { - case MPOL_DEFAULT: - return numa_node_id(); - case MPOL_BIND: - return pol->v.zonelist->zones[0]->zone_pgdat->node_id; - case MPOL_INTERLEAVE: - return interleave_nodes(pol); - case MPOL_PREFERRED: - return pol->v.preferred_node >= 0 ? - pol->v.preferred_node : numa_node_id(); - } - BUG(); - return 0; -} - -/* Find secondary valid nodes for an allocation */ -int mpol_node_valid(int nid, struct vm_area_struct *vma, unsigned long addr) -{ - struct mempolicy *pol = get_vma_policy(current, vma, addr); - - switch (pol->policy) { - case MPOL_PREFERRED: - case MPOL_DEFAULT: - case MPOL_INTERLEAVE: - return 1; - case MPOL_BIND: { - struct zone **z; - for (z = pol->v.zonelist->zones; *z; z++) - if ((*z)->zone_pgdat->node_id == nid) - return 1; - return 0; - } - default: - BUG(); - return 0; - } -} - -/* * Shared memory backing store policy support. * * Remember policies even when nobody has shared memory mapped. -- cgit v1.1 From 6bda666a03f063968833760c5bb5c13062ab9291 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:10:49 -0800 Subject: [PATCH] hugepages: fold find_or_alloc_pages into huge_no_page() The number of parameters for find_or_alloc_page increases significantly after policy support is added to huge pages. Simplify the code by folding find_or_alloc_huge_page() into hugetlb_no_page(). Adam Litke objected to this piece in an earlier patch but I think this is a good simplification. Diffstat shows that we can get rid of almost half of the lines of find_or_alloc_page(). If we can find no consensus then lets simply drop this patch. Signed-off-by: Christoph Lameter Cc: Andi Kleen Acked-by: William Lee Irwin III Cc: Adam Litke Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/hugetlb.c | 66 ++++++++++++++++++++++-------------------------------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index eb40556..f4c43d7 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -368,43 +368,6 @@ void unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start, flush_tlb_range(vma, start, end); } -static struct page *find_or_alloc_huge_page(struct vm_area_struct *vma, - unsigned long addr, struct address_space *mapping, - unsigned long idx, int shared) -{ - struct page *page; - int err; - -retry: - page = find_lock_page(mapping, idx); - if (page) - goto out; - - if (hugetlb_get_quota(mapping)) - goto out; - page = alloc_huge_page(vma, addr); - if (!page) { - hugetlb_put_quota(mapping); - goto out; - } - - if (shared) { - err = add_to_page_cache(page, mapping, idx, GFP_KERNEL); - if (err) { - put_page(page); - hugetlb_put_quota(mapping); - if (err == -EEXIST) - goto retry; - page = NULL; - } - } else { - /* Caller expects a locked page */ - lock_page(page); - } -out: - return page; -} - static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, pte_t *ptep, pte_t pte) { @@ -471,12 +434,31 @@ int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, * Use page lock to guard against racing truncation * before we get page_table_lock. */ - page = find_or_alloc_huge_page(vma, address, mapping, idx, - vma->vm_flags & VM_SHARED); - if (!page) - goto out; +retry: + page = find_lock_page(mapping, idx); + if (!page) { + if (hugetlb_get_quota(mapping)) + goto out; + page = alloc_huge_page(vma, address); + if (!page) { + hugetlb_put_quota(mapping); + goto out; + } - BUG_ON(!PageLocked(page)); + if (vma->vm_flags & VM_SHARED) { + int err; + + err = add_to_page_cache(page, mapping, idx, GFP_KERNEL); + if (err) { + put_page(page); + hugetlb_put_quota(mapping); + if (err == -EEXIST) + goto retry; + goto out; + } + } else + lock_page(page); + } spin_lock(&mm->page_table_lock); size = i_size_read(mapping->host) >> HPAGE_SHIFT; -- cgit v1.1 From 9f3fd602aef96c2a490e3bfd669d06475aeba8d8 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 6 Jan 2006 00:10:50 -0800 Subject: [PATCH] mm: kvaddr_to_nid not used in common code kvaddr_to_nid() isn't used in common code nor in i386 code. Remove these definitions. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-i386/mmzone.h | 5 ----- include/linux/mmzone.h | 5 ----- 2 files changed, 10 deletions(-) diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h index 620a906..74f595d 100644 --- a/include/asm-i386/mmzone.h +++ b/include/asm-i386/mmzone.h @@ -76,11 +76,6 @@ static inline int pfn_to_nid(unsigned long pfn) * Following are macros that each numa implmentation must define. */ -/* - * Given a kernel address, find the home node of the underlying memory. - */ -#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT) - #define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn) #define node_end_pfn(nid) \ ({ \ diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 9f22090d..3c49f78 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -564,11 +564,6 @@ static inline int valid_section_nr(unsigned long nr) return valid_section(__nr_to_section(nr)); } -/* - * Given a kernel address, find the home node of the underlying memory. - */ -#define kvaddr_to_nid(kaddr) pfn_to_nid(__pa(kaddr) >> PAGE_SHIFT) - static inline struct mem_section *__pfn_to_section(unsigned long pfn) { return __nr_to_section(pfn_to_section_nr(pfn)); -- cgit v1.1 From d5afa6dcf74c0efb60ce07c63d0a727be93c67c5 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 6 Jan 2006 00:10:50 -0800 Subject: [PATCH] mm: pfn_to_pgdat not used in common code pfn_to_pgdat() isn't used in common code. Remove definition. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 3c49f78..28f8496 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -596,11 +596,6 @@ static inline int pfn_valid(unsigned long pfn) #define pfn_to_nid early_pfn_to_nid #endif -#define pfn_to_pgdat(pfn) \ -({ \ - NODE_DATA(pfn_to_nid(pfn)); \ -}) - #define early_pfn_valid(pfn) pfn_valid(pfn) void sparse_init(void); #else -- cgit v1.1 From a94b3ab7eab4edcc9b2cb474b188f774c331adf7 Mon Sep 17 00:00:00 2001 From: Mike Kravetz Date: Fri, 6 Jan 2006 00:10:51 -0800 Subject: [PATCH] mm: remove arch independent NODES_SPAN_OTHER_NODES The NODES_SPAN_OTHER_NODES config option was created so that DISCONTIGMEM could handle pSeries numa layouts. However, support for DISCONTIGMEM has been replaced by SPARSEMEM on powerpc. As a result, this config option and supporting code is no longer needed. I have already sent a patch to Paul that removes the option from powerpc specific code. This removes the arch independent piece. Doesn't really matter which is applied first. Signed-off-by: Mike Kravetz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 6 ------ mm/page_alloc.c | 2 -- 2 files changed, 8 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 28f8496..d294b57 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -603,12 +603,6 @@ void sparse_init(void); #define sparse_index_init(_sec, _nid) do {} while (0) #endif /* CONFIG_SPARSEMEM */ -#ifdef CONFIG_NODES_SPAN_OTHER_NODES -#define early_pfn_in_nid(pfn, nid) (early_pfn_to_nid(pfn) == (nid)) -#else -#define early_pfn_in_nid(pfn, nid) (1) -#endif - #ifndef early_pfn_valid #define early_pfn_valid(pfn) (1) #endif diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 1e49dc7..07825c6 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1708,8 +1708,6 @@ void __devinit memmap_init_zone(unsigned long size, int nid, unsigned long zone, for (pfn = start_pfn; pfn < end_pfn; pfn++, page++) { if (!early_pfn_valid(pfn)) continue; - if (!early_pfn_in_nid(pfn, nid)) - continue; page = pfn_to_page(pfn); set_page_links(page, zone, nid, pfn); set_page_count(page, 1); -- cgit v1.1 From 03b00ebcc804180829d513df9e92e5fe8f72aacf Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 6 Jan 2006 00:10:52 -0800 Subject: [PATCH] Shut up warnings in ipc/shm.c Fix two warnings in ipc/shm.c ipc/shm.c:122: warning: statement with no effect ipc/shm.c:560: warning: statement with no effect by converting the macros to empty inline functions. For safety, let's do all three. This also has the advantage that typechecking gets performed even without CONFIG_SHMEM enabled. Signed-off-by: Russell King Cc: Manfred Spraul Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mm.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6c9be99..75ec04e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -634,9 +634,24 @@ struct mempolicy *shmem_get_policy(struct vm_area_struct *vma, int shmem_lock(struct file *file, int lock, struct user_struct *user); #else #define shmem_nopage filemap_nopage -#define shmem_lock(a, b, c) ({0;}) /* always in memory, no need to lock */ -#define shmem_set_policy(a, b) (0) -#define shmem_get_policy(a, b) (NULL) + +static inline int shmem_lock(struct file *file, int lock, + struct user_struct *user) +{ + return 0; +} + +static inline int shmem_set_policy(struct vm_area_struct *vma, + struct mempolicy *new) +{ + return 0; +} + +static inline struct mempolicy *shmem_get_policy(struct vm_area_struct *vma, + unsigned long addr) +{ + return NULL; +} #endif struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags); -- cgit v1.1 From 2bdaf115b1c364d89484b59d5b937973f1c5a5c3 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 6 Jan 2006 00:10:53 -0800 Subject: [PATCH] flatmem split out memory model There are three places we define pfn_to_nid(). Two in linux/mmzone.h and one in asm/mmzone.h. These in essence represent the three memory models. The definition in linux/mmzone.h under !NEED_MULTIPLE_NODES is both the FLATMEM definition and the optimisation for single NUMA nodes; the one under SPARSEMEM is the NUMA sparsemem one; the one in asm/mmzone.h under DISCONTIGMEM is the discontigmem one. This is not in the least bit obvious, particularly the connection between the non-NUMA optimisations and the memory models. Two patches: flatmem-split-out-memory-model: simplifies the selection of pfn_to_nid() implementations. The selection is based primarily off the memory model selected. Optimisations for non-NUMA are applied where needed. sparse-provide-pfn_to_nid: implement pfn_to_nid() for SPARSEMEM This patch: pfn_to_nid is memory model specific The pfn_to_nid() call is memory model specific. It represents the locality identifier for the memory passed. Classically this would be a NUMA node, but not a chunk of memory under DISCONTIGMEM. The SPARSEMEM and FLATMEM memory model non-NUMA versions of pfn_to_nid() are folded together under NEED_MULTIPLE_NODES, while DISCONTIGMEM has its own optimisation. This is all very confusing. This patch splits out each implementation of pfn_to_nid() so that we can see them and the optimisations to each. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index d294b57..ee9f7b7 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -435,7 +435,6 @@ extern struct pglist_data contig_page_data; #define NODE_DATA(nid) (&contig_page_data) #define NODE_MEM_MAP(nid) mem_map #define MAX_NODES_SHIFT 1 -#define pfn_to_nid(pfn) (0) #else /* CONFIG_NEED_MULTIPLE_NODES */ @@ -470,6 +469,10 @@ extern struct pglist_data contig_page_data; #define early_pfn_to_nid(nid) (0UL) #endif +#ifdef CONFIG_FLATMEM +#define pfn_to_nid(pfn) (0) +#endif + #define pfn_to_section_nr(pfn) ((pfn) >> PFN_SECTION_SHIFT) #define section_nr_to_pfn(sec) ((sec) << PFN_SECTION_SHIFT) @@ -594,6 +597,8 @@ static inline int pfn_valid(unsigned long pfn) */ #ifdef CONFIG_NUMA #define pfn_to_nid early_pfn_to_nid +#else +#define pfn_to_nid(pfn) (0) #endif #define early_pfn_valid(pfn) pfn_valid(pfn) -- cgit v1.1 From 161599ff39a3c3cdea0a1be05ac53accd2c45cdd Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 6 Jan 2006 00:10:54 -0800 Subject: [PATCH] sparsemem: provide pfn_to_nid Before SPARSEMEM is initialised we cannot provide an efficient pfn_to_nid() implmentation; before initialisation is complete we use early_pfn_to_nid() to provide location information. Until recently there was no non-init user of this functionality. Provide a post init pfn_to_nid() implementation. Note that this implmentation assumes that the pfn passed has been validated with pfn_valid(). The current single user of this function already has this check. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index ee9f7b7..8cba76c 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -596,7 +596,11 @@ static inline int pfn_valid(unsigned long pfn) * this restriction. */ #ifdef CONFIG_NUMA -#define pfn_to_nid early_pfn_to_nid +#define pfn_to_nid(pfn) \ +({ \ + unsigned long __pfn_to_nid_pfn = (pfn); \ + page_to_nid(pfn_to_page(__pfn_to_nid_pfn)); \ +}) #else #define pfn_to_nid(pfn) (0) #endif -- cgit v1.1 From c484d41042e6ccb88089ca41e3b3eed1bafdae21 Mon Sep 17 00:00:00 2001 From: Hugh Dickins Date: Fri, 6 Jan 2006 00:10:55 -0800 Subject: [PATCH] mm: free_pages_and_swap_cache opt Minor optimization (though it doesn't help in the PREEMPT case, severely constrained by small ZAP_BLOCK_SIZE). free_pages_and_swap_cache works in chunks of 16, calling release_pages which works in chunks of PAGEVEC_SIZE. But PAGEVEC_SIZE was dropped from 16 to 14 in 2.6.10, so we're now doing more spin_lock_irq'ing than necessary: use PAGEVEC_SIZE throughout. Signed-off-by: Hugh Dickins Signed-off-by: Nick Piggin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/swap_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index 0df9a57..fc2aecb 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -272,12 +273,11 @@ void free_page_and_swap_cache(struct page *page) */ void free_pages_and_swap_cache(struct page **pages, int nr) { - int chunk = 16; struct page **pagep = pages; lru_add_drain(); while (nr) { - int todo = min(chunk, nr); + int todo = min(nr, PAGEVEC_SIZE); int i; for (i = 0; i < todo; i++) -- cgit v1.1 From c54ad30c784b84d0275152d0ca80985b21471811 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:10:56 -0800 Subject: [PATCH] mm: pagealloc opt Slightly optimise some page allocation and freeing functions by taking advantage of knowing whether or not interrupts are disabled. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 07825c6..680cbe5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -375,11 +375,10 @@ static int free_pages_bulk(struct zone *zone, int count, struct list_head *list, unsigned int order) { - unsigned long flags; struct page *page = NULL; int ret = 0; - spin_lock_irqsave(&zone->lock, flags); + spin_lock(&zone->lock); zone->all_unreclaimable = 0; zone->pages_scanned = 0; while (!list_empty(list) && count--) { @@ -389,12 +388,13 @@ free_pages_bulk(struct zone *zone, int count, __free_pages_bulk(page, zone, order); ret++; } - spin_unlock_irqrestore(&zone->lock, flags); + spin_unlock(&zone->lock); return ret; } void __free_pages_ok(struct page *page, unsigned int order) { + unsigned long flags; LIST_HEAD(list); int i; int reserved = 0; @@ -415,7 +415,9 @@ void __free_pages_ok(struct page *page, unsigned int order) list_add(&page->lru, &list); mod_page_state(pgfree, 1 << order); kernel_map_pages(page, 1<lock, flags); + spin_lock(&zone->lock); for (i = 0; i < count; ++i) { page = __rmqueue(zone, order); if (page == NULL) @@ -552,7 +553,7 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, allocated++; list_add_tail(&page->lru, list); } - spin_unlock_irqrestore(&zone->lock, flags); + spin_unlock(&zone->lock); return allocated; } @@ -589,6 +590,7 @@ void drain_remote_pages(void) #if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU) static void __drain_pages(unsigned int cpu) { + unsigned long flags; struct zone *zone; int i; @@ -600,8 +602,10 @@ static void __drain_pages(unsigned int cpu) struct per_cpu_pages *pcp; pcp = &pset->pcp[i]; + local_irq_save(flags); pcp->count -= free_pages_bulk(zone, pcp->count, &pcp->list, 0); + local_irq_restore(flags); } } } @@ -744,7 +748,7 @@ again: if (pcp->count <= pcp->low) pcp->count += rmqueue_bulk(zone, 0, pcp->batch, &pcp->list); - if (pcp->count) { + if (likely(pcp->count)) { page = list_entry(pcp->list.next, struct page, lru); list_del(&page->lru); pcp->count--; -- cgit v1.1 From 77a8a78834561398fb4cb1480afa7b0e80b1dd53 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:10:57 -0800 Subject: [PATCH] mm: set_page_refs opt Inline set_page_refs. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/internal.h | 19 +++++++++++++++++-- mm/page_alloc.c | 17 ----------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 6bf134e..85004f5 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -9,5 +9,20 @@ * 2 of the License, or (at your option) any later version. */ -/* page_alloc.c */ -extern void set_page_refs(struct page *page, int order); +static inline void set_page_refs(struct page *page, int order) +{ +#ifdef CONFIG_MMU + set_page_count(page, 1); +#else + int i; + + /* + * We need to reference all the pages for this order, otherwise if + * anyone accesses one of the pages with (get/put) it will be freed. + * - eg: access_process_vm() + */ + for (i = 0; i < (1 << order); i++) + set_page_count(page + i, 1); +#endif /* CONFIG_MMU */ +} + diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 680cbe5..6d513fa 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -453,23 +453,6 @@ expand(struct zone *zone, struct page *page, return page; } -void set_page_refs(struct page *page, int order) -{ -#ifdef CONFIG_MMU - set_page_count(page, 1); -#else - int i; - - /* - * We need to reference all the pages for this order, otherwise if - * anyone accesses one of the pages with (get/put) it will be freed. - * - eg: access_process_vm() - */ - for (i = 0; i < (1 << order); i++) - set_page_count(page + i, 1); -#endif /* CONFIG_MMU */ -} - /* * This page is about to be returned from the page allocator */ -- cgit v1.1 From 92be2e33b155ee76399f51f41fb061f850d02f08 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:10:57 -0800 Subject: [PATCH] mm: microopt conditions Micro optimise some conditionals where we don't need lazy evaluation. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 6d513fa..b0647b5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -336,9 +336,9 @@ static inline void __free_pages_bulk (struct page *page, static inline int free_pages_check(const char *function, struct page *page) { - if ( page_mapcount(page) || - page->mapping != NULL || - page_count(page) != 0 || + if (unlikely(page_mapcount(page) | + (page->mapping != NULL) | + (page_count(page) != 0) | (page->flags & ( 1 << PG_lru | 1 << PG_private | @@ -348,7 +348,7 @@ static inline int free_pages_check(const char *function, struct page *page) 1 << PG_slab | 1 << PG_swapcache | 1 << PG_writeback | - 1 << PG_reserved ))) + 1 << PG_reserved )))) bad_page(function, page); if (PageDirty(page)) __ClearPageDirty(page); @@ -458,9 +458,9 @@ expand(struct zone *zone, struct page *page, */ static int prep_new_page(struct page *page, int order) { - if ( page_mapcount(page) || - page->mapping != NULL || - page_count(page) != 0 || + if (unlikely(page_mapcount(page) | + (page->mapping != NULL) | + (page_count(page) != 0) | (page->flags & ( 1 << PG_lru | 1 << PG_private | @@ -471,7 +471,7 @@ static int prep_new_page(struct page *page, int order) 1 << PG_slab | 1 << PG_swapcache | 1 << PG_writeback | - 1 << PG_reserved ))) + 1 << PG_reserved )))) bad_page(__FUNCTION__, page); /* -- cgit v1.1 From 13e7444b0ec59f96d81a4e8c379d5f38fc5f2cc1 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:10:58 -0800 Subject: [PATCH] mm: remove bad_range bad_range is supposed to be a temporary check. It would be a pity to throw it out. Make it depend on CONFIG_DEBUG_VM instead. CONFIG_HOLES_IN_ZONE systems were relying on this to check pfn_valid in the page allocator. Add that to page_is_buddy instead. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/Kconfig.debug | 3 ++- mm/page_alloc.c | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 156822e..1cedc23 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -172,7 +172,8 @@ config DEBUG_VM bool "Debug VM" depends on DEBUG_KERNEL help - Enable this to debug the virtual-memory system. + Enable this to turn on extended checks in the virtual-memory system + that may impact performance. If unsure, say N. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b0647b5..088712f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -81,6 +81,7 @@ int min_free_kbytes = 1024; unsigned long __initdata nr_kernel_pages; unsigned long __initdata nr_all_pages; +#ifdef CONFIG_DEBUG_VM static int page_outside_zone_boundaries(struct zone *zone, struct page *page) { int ret = 0; @@ -122,6 +123,13 @@ static int bad_range(struct zone *zone, struct page *page) return 0; } +#else +static inline int bad_range(struct zone *zone, struct page *page) +{ + return 0; +} +#endif + static void bad_page(const char *function, struct page *page) { printk(KERN_EMERG "Bad page state at %s (in process '%s', page %p)\n", @@ -255,14 +263,20 @@ __find_combined_index(unsigned long page_idx, unsigned int order) /* * This function checks whether a page is free && is the buddy * we can do coalesce a page and its buddy if - * (a) the buddy is free && - * (b) the buddy is on the buddy system && - * (c) a page and its buddy have the same order. + * (a) the buddy is not in a hole && + * (b) the buddy is free && + * (c) the buddy is on the buddy system && + * (d) a page and its buddy have the same order. * for recording page's order, we use page_private(page) and PG_private. * */ static inline int page_is_buddy(struct page *page, int order) { +#ifdef CONFIG_HOLES_IN_ZONE + if (!pfn_valid(page_to_pfn(page))) + return 0; +#endif + if (PagePrivate(page) && (page_order(page) == order) && page_count(page) == 0) @@ -314,17 +328,15 @@ static inline void __free_pages_bulk (struct page *page, struct free_area *area; struct page *buddy; - combined_idx = __find_combined_index(page_idx, order); buddy = __page_find_buddy(page, page_idx, order); - - if (bad_range(zone, buddy)) - break; if (!page_is_buddy(buddy, order)) break; /* Move the buddy up one level. */ + list_del(&buddy->lru); area = zone->free_area + order; area->nr_free--; rmv_page_order(buddy); + combined_idx = __find_combined_index(page_idx, order); page = page + (combined_idx - page_idx); page_idx = combined_idx; order++; -- cgit v1.1 From 2d92c5c9150a2a9ca3dc25da58d5042e17a96b6a Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:10:59 -0800 Subject: [PATCH] mm: remove pcp low struct per_cpu_pages.low is useless. Remove it. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 1 - mm/page_alloc.c | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 8cba76c..0d1a598 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -46,7 +46,6 @@ struct zone_padding { struct per_cpu_pages { int count; /* number of pages in the list */ - int low; /* low watermark, refill needed */ int high; /* high watermark, emptying needed */ int batch; /* chunk size for buddy add/remove */ struct list_head list; /* the list of pages */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 088712f..7cff958 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -740,7 +740,7 @@ again: page = NULL; pcp = &zone_pcp(zone, get_cpu())->pcp[cold]; local_irq_save(flags); - if (pcp->count <= pcp->low) + if (!pcp->count) pcp->count += rmqueue_bulk(zone, 0, pcp->batch, &pcp->list); if (likely(pcp->count)) { @@ -1345,10 +1345,9 @@ void show_free_areas(void) pageset = zone_pcp(zone, cpu); for (temperature = 0; temperature < 2; temperature++) - printk("cpu %d %s: low %d, high %d, batch %d used:%d\n", + printk("cpu %d %s: high %d, batch %d used:%d\n", cpu, temperature ? "cold" : "hot", - pageset->pcp[temperature].low, pageset->pcp[temperature].high, pageset->pcp[temperature].batch, pageset->pcp[temperature].count); @@ -1790,14 +1789,12 @@ inline void setup_pageset(struct per_cpu_pageset *p, unsigned long batch) pcp = &p->pcp[0]; /* hot */ pcp->count = 0; - pcp->low = 0; pcp->high = 6 * batch; pcp->batch = max(1UL, 1 * batch); INIT_LIST_HEAD(&pcp->list); pcp = &p->pcp[1]; /* cold*/ pcp->count = 0; - pcp->low = 0; pcp->high = 2 * batch; pcp->batch = max(1UL, batch/2); INIT_LIST_HEAD(&pcp->list); @@ -2193,12 +2190,10 @@ static int zoneinfo_show(struct seq_file *m, void *arg) seq_printf(m, "\n cpu: %i pcp: %i" "\n count: %i" - "\n low: %i" "\n high: %i" "\n batch: %i", i, j, pageset->pcp[j].count, - pageset->pcp[j].low, pageset->pcp[j].high, pageset->pcp[j].batch); } -- cgit v1.1 From a86b1f53166a260ced8f3c8c526945bf496f2e78 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:11:00 -0800 Subject: [PATCH] mm: page_state fixes read_page_state and __get_page_state only traverse online CPUs, which will cause results to fluctuate when CPUs are plugged in or out. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7cff958..3796187 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1169,12 +1169,11 @@ EXPORT_SYMBOL(nr_pagecache); DEFINE_PER_CPU(long, nr_pagecache_local) = 0; #endif -void __get_page_state(struct page_state *ret, int nr, cpumask_t *cpumask) +static void __get_page_state(struct page_state *ret, int nr, cpumask_t *cpumask) { int cpu = 0; memset(ret, 0, sizeof(*ret)); - cpus_and(*cpumask, *cpumask, cpu_online_map); cpu = first_cpu(*cpumask); while (cpu < NR_CPUS) { @@ -1227,7 +1226,7 @@ unsigned long __read_page_state(unsigned long offset) unsigned long ret = 0; int cpu; - for_each_online_cpu(cpu) { + for_each_cpu(cpu) { unsigned long in; in = (unsigned long)&per_cpu(page_states, cpu) + offset; -- cgit v1.1 From 085cc7d5de3cc662da7ea78296464a0d52f3f01f Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:11:01 -0800 Subject: [PATCH] mm: page_alloc cleanups Small cleanups that does not change generated code with the gcc's I've tested with. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3796187..925b0b9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -447,8 +447,7 @@ void __free_pages_ok(struct page *page, unsigned int order) * * -- wli */ -static inline struct page * -expand(struct zone *zone, struct page *page, +static inline void expand(struct zone *zone, struct page *page, int low, int high, struct free_area *area) { unsigned long size = 1 << high; @@ -462,7 +461,6 @@ expand(struct zone *zone, struct page *page, area->nr_free++; set_page_order(&page[size], high); } - return page; } /* @@ -522,7 +520,8 @@ static struct page *__rmqueue(struct zone *zone, unsigned int order) rmv_page_order(page); area->nr_free--; zone->free_pages -= 1UL << order; - return expand(zone, page, order, current_order, area); + expand(zone, page, order, current_order, area); + return page; } return NULL; @@ -537,19 +536,16 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, unsigned long count, struct list_head *list) { int i; - int allocated = 0; - struct page *page; spin_lock(&zone->lock); for (i = 0; i < count; ++i) { - page = __rmqueue(zone, order); - if (page == NULL) + struct page *page = __rmqueue(zone, order); + if (unlikely(page == NULL)) break; - allocated++; list_add_tail(&page->lru, list); } spin_unlock(&zone->lock); - return allocated; + return i; } #ifdef CONFIG_NUMA -- cgit v1.1 From 008857c1a49ccffc31a54c3ea7e182833bd61304 Mon Sep 17 00:00:00 2001 From: Ravikiran G Thirumalai Date: Fri, 6 Jan 2006 00:11:01 -0800 Subject: [PATCH] Cleanup bootmem allocator and fix alloc_bootmem_low Patch cleans up the alloc_bootmem fix for swiotlb. Patch removes alloc_bootmem_*_limit api and fixes alloc_boot_*low api to do the right thing -- allocate from low32 memory. Signed-off-by: Ravikiran Thirumalai Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/bootmem.h | 46 ++++++++++++---------------------------------- lib/swiotlb.c | 3 +-- mm/bootmem.c | 38 +++++++++++++++++++++++++++++++------- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 3b03b0b..993da8c 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h @@ -43,50 +43,38 @@ typedef struct bootmem_data { extern unsigned long __init bootmem_bootmap_pages (unsigned long); extern unsigned long __init init_bootmem (unsigned long addr, unsigned long memend); extern void __init free_bootmem (unsigned long addr, unsigned long size); -extern void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, unsigned long goal, unsigned long limit); +extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal); +extern void * __init __alloc_bootmem_low(unsigned long size, + unsigned long align, + unsigned long goal); +extern void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, + unsigned long size, + unsigned long align, + unsigned long goal); #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE extern void __init reserve_bootmem (unsigned long addr, unsigned long size); #define alloc_bootmem(x) \ __alloc_bootmem((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) #define alloc_bootmem_low(x) \ - __alloc_bootmem((x), SMP_CACHE_BYTES, 0) + __alloc_bootmem_low((x), SMP_CACHE_BYTES, 0) #define alloc_bootmem_pages(x) \ __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) #define alloc_bootmem_low_pages(x) \ - __alloc_bootmem((x), PAGE_SIZE, 0) - -#define alloc_bootmem_limit(x, limit) \ - __alloc_bootmem_limit((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS), (limit)) -#define alloc_bootmem_low_limit(x, limit) \ - __alloc_bootmem_limit((x), SMP_CACHE_BYTES, 0, (limit)) -#define alloc_bootmem_pages_limit(x, limit) \ - __alloc_bootmem_limit((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS), (limit)) -#define alloc_bootmem_low_pages_limit(x, limit) \ - __alloc_bootmem_limit((x), PAGE_SIZE, 0, (limit)) - + __alloc_bootmem_low((x), PAGE_SIZE, 0) #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ extern unsigned long __init free_all_bootmem (void); - +extern void * __init __alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal); extern unsigned long __init init_bootmem_node (pg_data_t *pgdat, unsigned long freepfn, unsigned long startpfn, unsigned long endpfn); extern void __init reserve_bootmem_node (pg_data_t *pgdat, unsigned long physaddr, unsigned long size); extern void __init free_bootmem_node (pg_data_t *pgdat, unsigned long addr, unsigned long size); extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat); -extern void * __init __alloc_bootmem_node_limit (pg_data_t *pgdat, unsigned long size, unsigned long align, unsigned long goal, unsigned long limit); #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE #define alloc_bootmem_node(pgdat, x) \ __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) #define alloc_bootmem_pages_node(pgdat, x) \ __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) #define alloc_bootmem_low_pages_node(pgdat, x) \ - __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, 0) - -#define alloc_bootmem_node_limit(pgdat, x, limit) \ - __alloc_bootmem_node_limit((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS), (limit)) -#define alloc_bootmem_pages_node_limit(pgdat, x, limit) \ - __alloc_bootmem_node_limit((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS), (limit)) -#define alloc_bootmem_low_pages_node_limit(pgdat, x, limit) \ - __alloc_bootmem_node_limit((pgdat), (x), PAGE_SIZE, 0, (limit)) - + __alloc_bootmem_low_node((pgdat), (x), PAGE_SIZE, 0) #endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP @@ -123,15 +111,5 @@ extern void *__init alloc_large_system_hash(const char *tablename, #endif extern int __initdata hashdist; /* Distribute hashes across NUMA nodes? */ -static inline void *__alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal) -{ - return __alloc_bootmem_limit(size, align, goal, 0); -} - -static inline void *__alloc_bootmem_node (pg_data_t *pgdat, unsigned long size, unsigned long align, - unsigned long goal) -{ - return __alloc_bootmem_node_limit(pgdat, size, align, goal, 0); -} #endif /* _LINUX_BOOTMEM_H */ diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 1ff8dce..3b48205 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -142,8 +142,7 @@ swiotlb_init_with_default_size (size_t default_size) /* * Get IO TLB memory from the low pages */ - io_tlb_start = alloc_bootmem_low_pages_limit(io_tlb_nslabs * - (1 << IO_TLB_SHIFT), 0x100000000); + io_tlb_start = alloc_bootmem_low_pages(io_tlb_nslabs * (1 << IO_TLB_SHIFT)); if (!io_tlb_start) panic("Cannot allocate SWIOTLB buffer"); io_tlb_end = io_tlb_start + io_tlb_nslabs * (1 << IO_TLB_SHIFT); diff --git a/mm/bootmem.c b/mm/bootmem.c index 16b9465..cbb82ee 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -393,15 +393,14 @@ unsigned long __init free_all_bootmem (void) return(free_all_bootmem_core(NODE_DATA(0))); } -void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, unsigned long goal, - unsigned long limit) +void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal) { pg_data_t *pgdat = pgdat_list; void *ptr; for_each_pgdat(pgdat) if ((ptr = __alloc_bootmem_core(pgdat->bdata, size, - align, goal, limit))) + align, goal, 0))) return(ptr); /* @@ -413,15 +412,40 @@ void * __init __alloc_bootmem_limit (unsigned long size, unsigned long align, un } -void * __init __alloc_bootmem_node_limit (pg_data_t *pgdat, unsigned long size, unsigned long align, - unsigned long goal, unsigned long limit) +void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, unsigned long align, + unsigned long goal) { void *ptr; - ptr = __alloc_bootmem_core(pgdat->bdata, size, align, goal, limit); + ptr = __alloc_bootmem_core(pgdat->bdata, size, align, goal, 0); if (ptr) return (ptr); - return __alloc_bootmem_limit(size, align, goal, limit); + return __alloc_bootmem(size, align, goal); } +#define LOW32LIMIT 0xffffffff + +void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsigned long goal) +{ + pg_data_t *pgdat = pgdat_list; + void *ptr; + + for_each_pgdat(pgdat) + if ((ptr = __alloc_bootmem_core(pgdat->bdata, size, + align, goal, LOW32LIMIT))) + return(ptr); + + /* + * Whoops, we cannot satisfy the allocation request. + */ + printk(KERN_ALERT "low bootmem alloc of %lu bytes failed!\n", size); + panic("Out of low memory"); + return NULL; +} + +void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, + unsigned long align, unsigned long goal) +{ + return __alloc_bootmem_core(pgdat->bdata, size, align, goal, LOW32LIMIT); +} -- cgit v1.1 From a226f6c899799fe2c4919daa0767ac579c88f7bd Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:08 -0800 Subject: [PATCH] FRV: Clean up bootmem allocator's page freeing algorithm The attached patch cleans up the way the bootmem allocator frees pages. A new function, __free_pages_bootmem(), is provided in mm/page_alloc.c that is called from mm/bootmem.c to turn pages over to the main allocator. All the bits of code to initialise pages (clearing PG_reserved and setting the page count) are moved to here. The checks on page validity are removed, on the assumption that the struct page arrays will have been prepared correctly. Signed-off-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/bootmem.c | 20 ++++---------------- mm/internal.h | 2 ++ mm/page_alloc.c | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/mm/bootmem.c b/mm/bootmem.c index cbb82ee..35c3229 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -296,20 +296,12 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) unsigned long v = ~map[i / BITS_PER_LONG]; if (gofast && v == ~0UL) { - int j, order; + int order; page = pfn_to_page(pfn); count += BITS_PER_LONG; - __ClearPageReserved(page); order = ffs(BITS_PER_LONG) - 1; - set_page_refs(page, order); - for (j = 1; j < BITS_PER_LONG; j++) { - if (j + 16 < BITS_PER_LONG) - prefetchw(page + j + 16); - __ClearPageReserved(page + j); - set_page_count(page + j, 0); - } - __free_pages(page, order); + __free_pages_bootmem(page, order); i += BITS_PER_LONG; page += BITS_PER_LONG; } else if (v) { @@ -319,9 +311,7 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) for (m = 1; m && i < idx; m<<=1, page++, i++) { if (v & m) { count++; - __ClearPageReserved(page); - set_page_refs(page, 0); - __free_page(page); + __free_pages_bootmem(page, 0); } } } else { @@ -339,9 +329,7 @@ static unsigned long __init free_all_bootmem_core(pg_data_t *pgdat) count = 0; for (i = 0; i < ((bdata->node_low_pfn-(bdata->node_boot_start >> PAGE_SHIFT))/8 + PAGE_SIZE-1)/PAGE_SIZE; i++,page++) { count++; - __ClearPageReserved(page); - set_page_count(page, 1); - __free_page(page); + __free_pages_bootmem(page, 0); } total += count; bdata->node_bootmem_map = NULL; diff --git a/mm/internal.h b/mm/internal.h index 85004f5..17256bb 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -26,3 +26,5 @@ static inline void set_page_refs(struct page *page, int order) #endif /* CONFIG_MMU */ } +extern void fastcall __init __free_pages_bootmem(struct page *page, + unsigned int order); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 925b0b9..cdad324 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -53,6 +53,8 @@ unsigned long totalram_pages __read_mostly; unsigned long totalhigh_pages __read_mostly; long nr_swap_pages; +static void fastcall free_hot_cold_page(struct page *page, int cold); + /* * results with 256, 32 in the lowmem_reserve sysctl: * 1G machine -> (16M dma, 800M-16M normal, 1G-800M high) @@ -432,6 +434,39 @@ void __free_pages_ok(struct page *page, unsigned int order) local_irq_restore(flags); } +/* + * permit the bootmem allocator to evade page validation on high-order frees + */ +void fastcall __init __free_pages_bootmem(struct page *page, unsigned int order) +{ + if (order == 0) { + __ClearPageReserved(page); + set_page_count(page, 0); + + free_hot_cold_page(page, 0); + } else { + LIST_HEAD(list); + int loop; + + for (loop = 0; loop < BITS_PER_LONG; loop++) { + struct page *p = &page[loop]; + + if (loop + 16 < BITS_PER_LONG) + prefetchw(p + 16); + __ClearPageReserved(p); + set_page_count(p, 0); + } + + arch_free_page(page, order); + + mod_page_state(pgfree, 1 << order); + + list_add(&page->lru, &list); + kernel_map_pages(page, 1 << order, 0); + free_pages_bulk(page_zone(page), 1, &list, order); + } +} + /* * The order of subdivision here is critical for the IO subsystem. @@ -671,7 +706,6 @@ static void zone_statistics(struct zonelist *zonelist, struct zone *z) /* * Free a 0-order page */ -static void FASTCALL(free_hot_cold_page(struct page *page, int cold)); static void fastcall free_hot_cold_page(struct page *page, int cold) { struct zone *zone = page_zone(page); -- cgit v1.1 From bbfbb7cec9dd7266534b2b4b9c8be2fa425bbfc9 Mon Sep 17 00:00:00 2001 From: Nikita Danilov Date: Fri, 6 Jan 2006 00:11:08 -0800 Subject: [PATCH] find_lock_page(): call __lock_page() directly. As find_lock_page() already checks with TestSetPageLocked() that page is locked, there is no need to call lock_page() that will try-lock page again (chances of page being unlocked in between are small). Call __lock_page() directly, this saves one atomic operation. Also, mark truncate-while-slept path as unlikely while we are here. (akpm: ug. But this is actually a common path for normal old read()s against a page which is under readahead I/O so ho-hum.) Signed-off-by: Nikita Danilov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/filemap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 6e1d08a..4ef24a3 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -555,11 +555,12 @@ repeat: page_cache_get(page); if (TestSetPageLocked(page)) { read_unlock_irq(&mapping->tree_lock); - lock_page(page); + __lock_page(page); read_lock_irq(&mapping->tree_lock); /* Has the page been truncated while we slept? */ - if (page->mapping != mapping || page->index != offset) { + if (unlikely(page->mapping != mapping || + page->index != offset)) { unlock_page(page); page_cache_release(page); goto repeat; -- cgit v1.1 From 7756b9e4e321c3c83c7aa5b9532d3e7fd7ddeb4a Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 6 Jan 2006 00:11:09 -0800 Subject: [PATCH] kill last zone_reclaim() bits Remove the last bits of Martin's ill-fated sys_set_zone_reclaim(). Cc: Martin Hicks Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-i386/unistd.h | 2 +- include/asm-ia64/unistd.h | 2 +- include/linux/swap.h | 1 - mm/vmscan.c | 80 ----------------------------------------------- 4 files changed, 2 insertions(+), 83 deletions(-) diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h index 0f92e78..fe38b9a 100644 --- a/include/asm-i386/unistd.h +++ b/include/asm-i386/unistd.h @@ -256,7 +256,7 @@ #define __NR_io_submit 248 #define __NR_io_cancel 249 #define __NR_fadvise64 250 -#define __NR_set_zone_reclaim 251 +/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */ #define __NR_exit_group 252 #define __NR_lookup_dcookie 253 #define __NR_epoll_create 254 diff --git a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h index 6d96a67..2bf5434 100644 --- a/include/asm-ia64/unistd.h +++ b/include/asm-ia64/unistd.h @@ -265,7 +265,7 @@ #define __NR_keyctl 1273 #define __NR_ioprio_set 1274 #define __NR_ioprio_get 1275 -#define __NR_set_zone_reclaim 1276 +/* 1276 is available for reuse (was briefly sys_set_zone_reclaim) */ #define __NR_inotify_init 1277 #define __NR_inotify_add_watch 1278 #define __NR_inotify_rm_watch 1279 diff --git a/include/linux/swap.h b/include/linux/swap.h index 508668f..bd66417 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -172,7 +172,6 @@ extern void swap_setup(void); /* linux/mm/vmscan.c */ extern int try_to_free_pages(struct zone **, gfp_t); -extern int zone_reclaim(struct zone *, gfp_t, unsigned int); extern int shrink_all_memory(int); extern int vm_swappiness; diff --git a/mm/vmscan.c b/mm/vmscan.c index 795a050..b2baca7 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -74,9 +74,6 @@ struct scan_control { int may_writepage; - /* Can pages be swapped as part of reclaim? */ - int may_swap; - /* This context's SWAP_CLUSTER_MAX. If freeing memory for * suspend, we effectively ignore SWAP_CLUSTER_MAX. * In this context, it doesn't matter that we scan the @@ -430,8 +427,6 @@ static int shrink_list(struct list_head *page_list, struct scan_control *sc) * Try to allocate it some swap space here. */ if (PageAnon(page) && !PageSwapCache(page)) { - if (!sc->may_swap) - goto keep_locked; if (!add_to_swap(page)) goto activate_locked; } @@ -952,7 +947,6 @@ int try_to_free_pages(struct zone **zones, gfp_t gfp_mask) sc.gfp_mask = gfp_mask; sc.may_writepage = 0; - sc.may_swap = 1; inc_page_state(allocstall); @@ -1055,7 +1049,6 @@ loop_again: total_reclaimed = 0; sc.gfp_mask = GFP_KERNEL; sc.may_writepage = 0; - sc.may_swap = 1; sc.nr_mapped = read_page_state(nr_mapped); inc_page_state(pageoutrun); @@ -1353,76 +1346,3 @@ static int __init kswapd_init(void) } module_init(kswapd_init) - - -/* - * Try to free up some pages from this zone through reclaim. - */ -int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) -{ - struct scan_control sc; - int nr_pages = 1 << order; - int total_reclaimed = 0; - - /* The reclaim may sleep, so don't do it if sleep isn't allowed */ - if (!(gfp_mask & __GFP_WAIT)) - return 0; - if (zone->all_unreclaimable) - return 0; - - sc.gfp_mask = gfp_mask; - sc.may_writepage = 0; - sc.may_swap = 0; - sc.nr_mapped = read_page_state(nr_mapped); - sc.nr_scanned = 0; - sc.nr_reclaimed = 0; - /* scan at the highest priority */ - sc.priority = 0; - disable_swap_token(); - - if (nr_pages > SWAP_CLUSTER_MAX) - sc.swap_cluster_max = nr_pages; - else - sc.swap_cluster_max = SWAP_CLUSTER_MAX; - - /* Don't reclaim the zone if there are other reclaimers active */ - if (atomic_read(&zone->reclaim_in_progress) > 0) - goto out; - - shrink_zone(zone, &sc); - total_reclaimed = sc.nr_reclaimed; - - out: - return total_reclaimed; -} - -asmlinkage long sys_set_zone_reclaim(unsigned int node, unsigned int zone, - unsigned int state) -{ - struct zone *z; - int i; - - if (!capable(CAP_SYS_ADMIN)) - return -EACCES; - - if (node >= MAX_NUMNODES || !node_online(node)) - return -EINVAL; - - /* This will break if we ever add more zones */ - if (!(zone & (1<node_zones[i]; - - if (state) - z->reclaim_pages = 1; - else - z->reclaim_pages = 0; - } - - return 0; -} -- cgit v1.1 From 9328b8faae922e52073785ed6c1eaa8565648a0e Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:11:10 -0800 Subject: [PATCH] mm: dma32 zone statistics Add dma32 to zone statistics. Also attempt to arrange struct page_state a bit better (visually). Signed-off-by: Nick Piggin Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 11 +++++++++++ include/linux/page-flags.h | 38 ++++++++++++++++++++++++-------------- mm/page_alloc.c | 14 +++++++++++--- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 0d1a598..8d6caa4 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -397,6 +397,7 @@ static inline int is_normal_idx(int idx) { return (idx == ZONE_NORMAL); } + /** * is_highmem - helper function to quickly check if a struct zone is a * highmem zone or not. This is an attempt to keep references @@ -413,6 +414,16 @@ static inline int is_normal(struct zone *zone) return zone == zone->zone_pgdat->node_zones + ZONE_NORMAL; } +static inline int is_dma32(struct zone *zone) +{ + return zone == zone->zone_pgdat->node_zones + ZONE_DMA32; +} + +static inline int is_dma(struct zone *zone) +{ + return zone == zone->zone_pgdat->node_zones + ZONE_DMA; +} + /* These two functions are used to setup the per zone pages min values */ struct ctl_table; struct file; diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 343083fe..32d09c8 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -97,32 +97,40 @@ struct page_state { unsigned long pgpgout; /* Disk writes */ unsigned long pswpin; /* swap reads */ unsigned long pswpout; /* swap writes */ - unsigned long pgalloc_high; /* page allocations */ + unsigned long pgalloc_high; /* page allocations */ unsigned long pgalloc_normal; + unsigned long pgalloc_dma32; unsigned long pgalloc_dma; + unsigned long pgfree; /* page freeings */ unsigned long pgactivate; /* pages moved inactive->active */ unsigned long pgdeactivate; /* pages moved active->inactive */ unsigned long pgfault; /* faults (major+minor) */ unsigned long pgmajfault; /* faults (major only) */ + unsigned long pgrefill_high; /* inspected in refill_inactive_zone */ unsigned long pgrefill_normal; + unsigned long pgrefill_dma32; unsigned long pgrefill_dma; unsigned long pgsteal_high; /* total highmem pages reclaimed */ unsigned long pgsteal_normal; + unsigned long pgsteal_dma32; unsigned long pgsteal_dma; + unsigned long pgscan_kswapd_high;/* total highmem pages scanned */ unsigned long pgscan_kswapd_normal; - + unsigned long pgscan_kswapd_dma32; unsigned long pgscan_kswapd_dma; + unsigned long pgscan_direct_high;/* total highmem pages scanned */ unsigned long pgscan_direct_normal; + unsigned long pgscan_direct_dma32; unsigned long pgscan_direct_dma; - unsigned long pginodesteal; /* pages reclaimed via inode freeing */ + unsigned long pginodesteal; /* pages reclaimed via inode freeing */ unsigned long slabs_scanned; /* slab objects scanned */ unsigned long kswapd_steal; /* pages reclaimed by kswapd */ unsigned long kswapd_inodesteal;/* reclaimed via kswapd inode freeing */ @@ -150,17 +158,19 @@ extern void __mod_page_state(unsigned long offset, unsigned long delta); #define add_page_state(member,delta) mod_page_state(member, (delta)) #define sub_page_state(member,delta) mod_page_state(member, 0UL - (delta)) -#define mod_page_state_zone(zone, member, delta) \ - do { \ - unsigned offset; \ - if (is_highmem(zone)) \ - offset = offsetof(struct page_state, member##_high); \ - else if (is_normal(zone)) \ - offset = offsetof(struct page_state, member##_normal); \ - else \ - offset = offsetof(struct page_state, member##_dma); \ - __mod_page_state(offset, (delta)); \ - } while (0) +#define mod_page_state_zone(zone, member, delta) \ + do { \ + unsigned offset; \ + if (is_highmem(zone)) \ + offset = offsetof(struct page_state, member##_high); \ + else if (is_normal(zone)) \ + offset = offsetof(struct page_state, member##_normal); \ + else if (is_dma32(zone)) \ + offset = offsetof(struct page_state, member##_dma32); \ + else \ + offset = offsetof(struct page_state, member##_dma); \ + __mod_page_state(offset, (delta)); \ + } while (0) /* * Manipulation of page state flags diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cdad324..e12154d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2277,32 +2277,40 @@ static char *vmstat_text[] = { "pgpgout", "pswpin", "pswpout", - "pgalloc_high", + "pgalloc_high", "pgalloc_normal", + "pgalloc_dma32", "pgalloc_dma", + "pgfree", "pgactivate", "pgdeactivate", "pgfault", "pgmajfault", + "pgrefill_high", "pgrefill_normal", + "pgrefill_dma32", "pgrefill_dma", "pgsteal_high", "pgsteal_normal", + "pgsteal_dma32", "pgsteal_dma", + "pgscan_kswapd_high", "pgscan_kswapd_normal", - + "pgscan_kswapd_dma32", "pgscan_kswapd_dma", + "pgscan_direct_high", "pgscan_direct_normal", + "pgscan_direct_dma32", "pgscan_direct_dma", - "pginodesteal", + "pginodesteal", "slabs_scanned", "kswapd_steal", "kswapd_inodesteal", -- cgit v1.1 From 224abf92b2f439a9030f21d2926ec8047d1ffcdb Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:11:11 -0800 Subject: [PATCH] mm: bad_page optimisation Cut down size slightly by not passing bad_page the function name (it should be able to be determined by dump_stack()). And cut down the number of printks in bad_page. Also, cut down some branching in the destroy_compound_page path. Signed-off-by: Nick Piggin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e12154d..b9fd2c2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -132,16 +132,16 @@ static inline int bad_range(struct zone *zone, struct page *page) } #endif -static void bad_page(const char *function, struct page *page) -{ - printk(KERN_EMERG "Bad page state at %s (in process '%s', page %p)\n", - function, current->comm, page); - printk(KERN_EMERG "flags:0x%0*lx mapping:%p mapcount:%d count:%d\n", - (int)(2*sizeof(unsigned long)), (unsigned long)page->flags, - page->mapping, page_mapcount(page), page_count(page)); - printk(KERN_EMERG "Backtrace:\n"); +static void bad_page(struct page *page) +{ + printk(KERN_EMERG "Bad page state in process '%s'\n" + "page:%p flags:0x%0*lx mapping:%p mapcount:%d count:%d\n" + "Trying to fix it up, but a reboot is needed\n" + "Backtrace:\n", + current->comm, page, (int)(2*sizeof(unsigned long)), + (unsigned long)page->flags, page->mapping, + page_mapcount(page), page_count(page)); dump_stack(); - printk(KERN_EMERG "Trying to fix it up, but a reboot is needed\n"); page->flags &= ~(1 << PG_lru | 1 << PG_private | 1 << PG_locked | @@ -194,19 +194,15 @@ static void destroy_compound_page(struct page *page, unsigned long order) int i; int nr_pages = 1 << order; - if (!PageCompound(page)) - return; - - if (page[1].index != order) - bad_page(__FUNCTION__, page); + if (unlikely(page[1].index != order)) + bad_page(page); for (i = 0; i < nr_pages; i++) { struct page *p = page + i; - if (!PageCompound(p)) - bad_page(__FUNCTION__, page); - if (page_private(p) != (unsigned long)page) - bad_page(__FUNCTION__, page); + if (unlikely(!PageCompound(p) | + (page_private(p) != (unsigned long)page))) + bad_page(page); ClearPageCompound(p); } } @@ -316,7 +312,7 @@ static inline void __free_pages_bulk (struct page *page, unsigned long page_idx; int order_size = 1 << order; - if (unlikely(order)) + if (unlikely(PageCompound(page))) destroy_compound_page(page, order); page_idx = page_to_pfn(page) & ((1 << MAX_ORDER) - 1); @@ -348,7 +344,7 @@ static inline void __free_pages_bulk (struct page *page, zone->free_area[order].nr_free++; } -static inline int free_pages_check(const char *function, struct page *page) +static inline int free_pages_check(struct page *page) { if (unlikely(page_mapcount(page) | (page->mapping != NULL) | @@ -363,7 +359,7 @@ static inline int free_pages_check(const char *function, struct page *page) 1 << PG_swapcache | 1 << PG_writeback | 1 << PG_reserved )))) - bad_page(function, page); + bad_page(page); if (PageDirty(page)) __ClearPageDirty(page); /* @@ -422,7 +418,7 @@ void __free_pages_ok(struct page *page, unsigned int order) #endif for (i = 0 ; i < (1 << order) ; ++i) - reserved += free_pages_check(__FUNCTION__, page + i); + reserved += free_pages_check(page + i); if (reserved) return; @@ -517,7 +513,7 @@ static int prep_new_page(struct page *page, int order) 1 << PG_swapcache | 1 << PG_writeback | 1 << PG_reserved )))) - bad_page(__FUNCTION__, page); + bad_page(page); /* * For now, we report if PG_reserved was found set, but do not @@ -716,7 +712,7 @@ static void fastcall free_hot_cold_page(struct page *page, int cold) if (PageAnon(page)) page->mapping = NULL; - if (free_pages_check(__FUNCTION__, page)) + if (free_pages_check(page)) return; inc_page_state(pgfree); -- cgit v1.1 From 9617d95e6e9ffd883cf90a89724fe60d7ab22f9a Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:11:12 -0800 Subject: [PATCH] mm: rmap optimisation Optimise rmap functions by minimising atomic operations when we know there will be no concurrent modifications. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/exec.c | 2 +- include/linux/rmap.h | 1 + mm/memory.c | 6 +++--- mm/rmap.c | 49 ++++++++++++++++++++++++++++++++++++++----------- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 22533cc..e75a954 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -324,7 +324,7 @@ void install_arg_page(struct vm_area_struct *vma, lru_cache_add_active(page); set_pte_at(mm, address, pte, pte_mkdirty(pte_mkwrite(mk_pte( page, vma->vm_page_prot)))); - page_add_anon_rmap(page, vma, address); + page_add_new_anon_rmap(page, vma, address); pte_unmap_unlock(pte, ptl); /* no need for flush_tlb */ diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 33261f1..9d6fbee 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -71,6 +71,7 @@ void __anon_vma_link(struct vm_area_struct *); * rmap interfaces called when adding or removing pte of page */ void page_add_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); +void page_add_new_anon_rmap(struct page *, struct vm_area_struct *, unsigned long); void page_add_file_rmap(struct page *); void page_remove_rmap(struct page *); diff --git a/mm/memory.c b/mm/memory.c index e249088..d7ca7de 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1498,7 +1498,7 @@ gotten: update_mmu_cache(vma, address, entry); lazy_mmu_prot_update(entry); lru_cache_add_active(new_page); - page_add_anon_rmap(new_page, vma, address); + page_add_new_anon_rmap(new_page, vma, address); /* Free the old page.. */ new_page = old_page; @@ -1978,7 +1978,7 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, inc_mm_counter(mm, anon_rss); lru_cache_add_active(page); SetPageReferenced(page); - page_add_anon_rmap(page, vma, address); + page_add_new_anon_rmap(page, vma, address); } else { /* Map the ZERO_PAGE - vm_page_prot is readonly */ page = ZERO_PAGE(address); @@ -2109,7 +2109,7 @@ retry: if (anon) { inc_mm_counter(mm, anon_rss); lru_cache_add_active(new_page); - page_add_anon_rmap(new_page, vma, address); + page_add_new_anon_rmap(new_page, vma, address); } else { inc_mm_counter(mm, file_rss); page_add_file_rmap(new_page); diff --git a/mm/rmap.c b/mm/rmap.c index f853c6d..4107f64 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -435,6 +435,26 @@ int page_referenced(struct page *page, int is_locked) } /** + * page_set_anon_rmap - setup new anonymous rmap + * @page: the page to add the mapping to + * @vma: the vm area in which the mapping is added + * @address: the user virtual address mapped + */ +static void __page_set_anon_rmap(struct page *page, + struct vm_area_struct *vma, unsigned long address) +{ + struct anon_vma *anon_vma = vma->anon_vma; + + BUG_ON(!anon_vma); + anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON; + page->mapping = (struct address_space *) anon_vma; + + page->index = linear_page_index(vma, address); + + inc_page_state(nr_mapped); +} + +/** * page_add_anon_rmap - add pte mapping to an anonymous page * @page: the page to add the mapping to * @vma: the vm area in which the mapping is added @@ -445,20 +465,27 @@ int page_referenced(struct page *page, int is_locked) void page_add_anon_rmap(struct page *page, struct vm_area_struct *vma, unsigned long address) { - if (atomic_inc_and_test(&page->_mapcount)) { - struct anon_vma *anon_vma = vma->anon_vma; - - BUG_ON(!anon_vma); - anon_vma = (void *) anon_vma + PAGE_MAPPING_ANON; - page->mapping = (struct address_space *) anon_vma; - - page->index = linear_page_index(vma, address); - - inc_page_state(nr_mapped); - } + if (atomic_inc_and_test(&page->_mapcount)) + __page_set_anon_rmap(page, vma, address); /* else checking page index and mapping is racy */ } +/* + * page_add_new_anon_rmap - add pte mapping to a new anonymous page + * @page: the page to add the mapping to + * @vma: the vm area in which the mapping is added + * @address: the user virtual address mapped + * + * Same as page_add_anon_rmap but must only be called on *new* pages. + * This means the inc-and-test can be bypassed. + */ +void page_add_new_anon_rmap(struct page *page, + struct vm_area_struct *vma, unsigned long address) +{ + atomic_set(&page->_mapcount, 0); /* elevate count by 1 (starts at -1) */ + __page_set_anon_rmap(page, vma, address); +} + /** * page_add_file_rmap - add pte mapping to a file page * @page: the page to add the mapping to -- cgit v1.1 From 41e9b63b35b52cf918a4ffdb8d77862ab824aa8b Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:11:13 -0800 Subject: [PATCH] mm: pfault optimisation This atomic operation is superfluous: the pte will be added with the referenced bit set, and the page will be referenced through this mapping after the page fault handler returns anyway. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/memory.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index d7ca7de..7197f9b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1977,7 +1977,6 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma, goto release; inc_mm_counter(mm, anon_rss); lru_cache_add_active(page); - SetPageReferenced(page); page_add_new_anon_rmap(page, vma, address); } else { /* Map the ZERO_PAGE - vm_page_prot is readonly */ -- cgit v1.1 From 210fe530305ee50cd889fe9250168228b2994f32 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 6 Jan 2006 00:11:14 -0800 Subject: [PATCH] vmscan: balancing fix Revert a patch which went into 2.6.8-rc1. The changelog for that patch was: The shrink_zone() logic can, under some circumstances, cause far too many pages to be reclaimed. Say, we're scanning at high priority and suddenly hit a large number of reclaimable pages on the LRU. Change things so we bale out when SWAP_CLUSTER_MAX pages have been reclaimed. Problem is, this change caused significant imbalance in inter-zone scan balancing by truncating scans of larger zones. Suppose, for example, ZONE_HIGHMEM is 10x the size of ZONE_NORMAL. The zone balancing algorithm would require that if we're scanning 100 pages of ZONE_HIGHMEM, we should scan 10 pages of ZONE_NORMAL. But this logic will cause the scanning of ZONE_HIGHMEM to bale out after only 32 pages are reclaimed. Thus effectively causing smaller zones to be scanned relatively harder than large ones. Now I need to remember what the workload was which caused me to write this patch originally, then fix it up in a different way... Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/vmscan.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index b2baca7..5c8a412 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -63,9 +63,6 @@ struct scan_control { unsigned long nr_mapped; /* From page_state */ - /* How many pages shrink_cache() should reclaim */ - int nr_to_reclaim; - /* Ask shrink_caches, or shrink_zone to scan at this priority */ unsigned int priority; @@ -656,7 +653,6 @@ static void shrink_cache(struct zone *zone, struct scan_control *sc) if (current_is_kswapd()) mod_page_state(kswapd_steal, nr_freed); mod_page_state_zone(zone, pgsteal, nr_freed); - sc->nr_to_reclaim -= nr_freed; spin_lock_irq(&zone->lru_lock); /* @@ -856,8 +852,6 @@ shrink_zone(struct zone *zone, struct scan_control *sc) else nr_inactive = 0; - sc->nr_to_reclaim = sc->swap_cluster_max; - while (nr_active || nr_inactive) { if (nr_active) { sc->nr_to_scan = min(nr_active, @@ -871,8 +865,6 @@ shrink_zone(struct zone *zone, struct scan_control *sc) (unsigned long)sc->swap_cluster_max); nr_inactive -= sc->nr_to_scan; shrink_cache(zone, sc); - if (sc->nr_to_reclaim <= 0) - break; } } -- cgit v1.1 From 80bfed904c690642db9d4178950735299160950b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 6 Jan 2006 00:11:14 -0800 Subject: [PATCH] consolidate lru_add_drain() and lru_drain_cache() Cc: Christoph Lameter Cc: Rajesh Shah Cc: Li Shaohua Cc: Srivatsa Vaddagiri Cc: Ashok Raj Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/swap.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 73d3514..ee6d71c 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -156,16 +156,22 @@ void fastcall lru_cache_add_active(struct page *page) put_cpu_var(lru_add_active_pvecs); } -void lru_add_drain(void) +static void __lru_add_drain(int cpu) { - struct pagevec *pvec = &get_cpu_var(lru_add_pvecs); + struct pagevec *pvec = &per_cpu(lru_add_pvecs, cpu); + /* CPU is dead, so no locking needed. */ if (pagevec_count(pvec)) __pagevec_lru_add(pvec); - pvec = &__get_cpu_var(lru_add_active_pvecs); + pvec = &per_cpu(lru_add_active_pvecs, cpu); if (pagevec_count(pvec)) __pagevec_lru_add_active(pvec); - put_cpu_var(lru_add_pvecs); +} + +void lru_add_drain(void) +{ + __lru_add_drain(get_cpu()); + put_cpu(); } /* @@ -412,17 +418,6 @@ void vm_acct_memory(long pages) } #ifdef CONFIG_HOTPLUG_CPU -static void lru_drain_cache(unsigned int cpu) -{ - struct pagevec *pvec = &per_cpu(lru_add_pvecs, cpu); - - /* CPU is dead, so no locking needed. */ - if (pagevec_count(pvec)) - __pagevec_lru_add(pvec); - pvec = &per_cpu(lru_add_active_pvecs, cpu); - if (pagevec_count(pvec)) - __pagevec_lru_add_active(pvec); -} /* Drop the CPU's cached committed space back into the central pool. */ static int cpu_swap_callback(struct notifier_block *nfb, @@ -435,7 +430,7 @@ static int cpu_swap_callback(struct notifier_block *nfb, if (action == CPU_DEAD) { atomic_add(*committed, &vm_committed_space); *committed = 0; - lru_drain_cache((long)hcpu); + __lru_add_drain((long)hcpu); } return NOTIFY_OK; } -- cgit v1.1 From f3fe65122da05e1cd4c9140340d96ea2f95d0c49 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 6 Jan 2006 00:11:15 -0800 Subject: [PATCH] mm: add populated_zone() helper There are numerous places we check whether a zone is populated or not. Provide a helper function to check for populated zones and convert all checks for zone->present_pages. Signed-off-by: Con Kolivas Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mmzone.h | 5 +++++ mm/page_alloc.c | 8 ++++---- mm/vmscan.c | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 8d6caa4..c34f4a2 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -388,6 +388,11 @@ static inline struct zone *next_zone(struct zone *zone) #define for_each_zone(zone) \ for (zone = pgdat_list->node_zones; zone; zone = next_zone(zone)) +static inline int populated_zone(struct zone *zone) +{ + return (!!zone->present_pages); +} + static inline int is_highmem_idx(int idx) { return (idx == ZONE_HIGHMEM); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b9fd2c2..8f3de5a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1358,7 +1358,7 @@ void show_free_areas(void) show_node(zone); printk("%s per-cpu:", zone->name); - if (!zone->present_pages) { + if (!populated_zone(zone)) { printk(" empty\n"); continue; } else @@ -1435,7 +1435,7 @@ void show_free_areas(void) show_node(zone); printk("%s: ", zone->name); - if (!zone->present_pages) { + if (!populated_zone(zone)) { printk("empty\n"); continue; } @@ -2134,7 +2134,7 @@ static int frag_show(struct seq_file *m, void *arg) int order; for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) { - if (!zone->present_pages) + if (!populated_zone(zone)) continue; spin_lock_irqsave(&zone->lock, flags); @@ -2167,7 +2167,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg) for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; zone++) { int i; - if (!zone->present_pages) + if (!populated_zone(zone)) continue; spin_lock_irqsave(&zone->lock, flags); diff --git a/mm/vmscan.c b/mm/vmscan.c index 5c8a412..7681d8e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -897,7 +897,7 @@ shrink_caches(struct zone **zones, struct scan_control *sc) for (i = 0; zones[i] != NULL; i++) { struct zone *zone = zones[i]; - if (zone->present_pages == 0) + if (!populated_zone(zone)) continue; if (!cpuset_zone_allowed(zone, __GFP_HARDWALL)) @@ -1069,7 +1069,7 @@ loop_again: for (i = pgdat->nr_zones - 1; i >= 0; i--) { struct zone *zone = pgdat->node_zones + i; - if (zone->present_pages == 0) + if (!populated_zone(zone)) continue; if (zone->all_unreclaimable && @@ -1106,7 +1106,7 @@ scan: struct zone *zone = pgdat->node_zones + i; int nr_slab; - if (zone->present_pages == 0) + if (!populated_zone(zone)) continue; if (zone->all_unreclaimable && priority != DEF_PRIORITY) @@ -1258,7 +1258,7 @@ void wakeup_kswapd(struct zone *zone, int order) { pg_data_t *pgdat; - if (zone->present_pages == 0) + if (!populated_zone(zone)) return; pgdat = zone->zone_pgdat; -- cgit v1.1 From 1a93205bdffd9d7278d4a66081cdb48452522a58 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:11:16 -0800 Subject: [PATCH] mm: simplify build_zonelists_node by removing the case statement. Simplify build_zonelists_node by removing the case statement. Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8f3de5a..7adc952 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1455,35 +1455,23 @@ void show_free_areas(void) /* * Builds allocation fallback zone lists. + * + * Add all populated zones of a node to the zonelist. */ -static int __init build_zonelists_node(pg_data_t *pgdat, struct zonelist *zonelist, int j, int k) -{ - switch (k) { - struct zone *zone; - default: - BUG(); - case ZONE_HIGHMEM: - zone = pgdat->node_zones + ZONE_HIGHMEM; - if (zone->present_pages) { +static int __init build_zonelists_node(pg_data_t *pgdat, + struct zonelist *zonelist, int j, int k) +{ + struct zone *zone; + + BUG_ON(k > ZONE_HIGHMEM); + for (zone = pgdat->node_zones + k; zone >= pgdat->node_zones; zone--) { + if (populated_zone(zone)) { #ifndef CONFIG_HIGHMEM - BUG(); + BUG_ON(zone - pgdat->node_zones > ZONE_NORMAL); #endif zonelist->zones[j++] = zone; } - case ZONE_NORMAL: - zone = pgdat->node_zones + ZONE_NORMAL; - if (zone->present_pages) - zonelist->zones[j++] = zone; - case ZONE_DMA32: - zone = pgdat->node_zones + ZONE_DMA32; - if (zone->present_pages) - zonelist->zones[j++] = zone; - case ZONE_DMA: - zone = pgdat->node_zones + ZONE_DMA; - if (zone->present_pages) - zonelist->zones[j++] = zone; } - return j; } -- cgit v1.1 From 4be38e351c5f455f6f490f5aff29053e33ab4f99 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:11:17 -0800 Subject: [PATCH] mm: move determination of policy_zone into page allocator Currently the function to build a zonelist for a BIND policy has the side effect to set the policy_zone. This seems to be a bit strange. policy zone seems to not be initialized elsewhere and therefore 0. Do we police ZONE_DMA if no bind policy has been used yet? This patch moves the determination of the zone to apply policies to into the page allocator. We determine the zone while building the zonelist for nodes. Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mempolicy.h | 11 +++++++++++ mm/mempolicy.c | 15 +++------------ mm/page_alloc.c | 2 ++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h index b972f985..ed00b27 100644 --- a/include/linux/mempolicy.h +++ b/include/linux/mempolicy.h @@ -151,6 +151,14 @@ extern struct mempolicy default_policy; extern struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr); +extern int policy_zone; + +static inline void check_highest_zone(int k) +{ + if (k > policy_zone) + policy_zone = k; +} + #else struct mempolicy {}; @@ -221,6 +229,9 @@ static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma, return NODE_DATA(0)->node_zonelists + gfp_zone(GFP_HIGHUSER); } +static inline void check_highest_zone(int k) +{ +} #endif /* CONFIG_NUMA */ #endif /* __KERNEL__ */ diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 96714e2..0f1d2b8 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -93,7 +93,7 @@ static kmem_cache_t *sn_cache; /* Highest zone. An specific allocation for a zone below that is not policied. */ -static int policy_zone; +int policy_zone = ZONE_DMA; struct mempolicy default_policy = { .refcnt = ATOMIC_INIT(1), /* never free it */ @@ -131,17 +131,8 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes) if (!zl) return NULL; num = 0; - for_each_node_mask(nd, *nodes) { - int k; - for (k = MAX_NR_ZONES-1; k >= 0; k--) { - struct zone *z = &NODE_DATA(nd)->node_zones[k]; - if (!z->present_pages) - continue; - zl->zones[num++] = z; - if (k > policy_zone) - policy_zone = k; - } - } + for_each_node_mask(nd, *nodes) + zl->zones[num++] = &NODE_DATA(nd)->node_zones[policy_zone]; zl->zones[num] = NULL; return zl; } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7adc952..512e3f4 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include "internal.h" @@ -1470,6 +1471,7 @@ static int __init build_zonelists_node(pg_data_t *pgdat, BUG_ON(zone - pgdat->node_zones > ZONE_NORMAL); #endif zonelist->zones[j++] = zone; + check_highest_zone(k); } } return j; -- cgit v1.1 From 02a68a5ebc7dd823da7496116f42290103e1e4a9 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:11:18 -0800 Subject: [PATCH] Fix zone policy determination The use k in the inner loop means that the highest zone nr is always used if any zone of a node is populated. This means that the policy zone is not correctly determined on arches that do no use HIGHMEM like ia64. Change the loop to decrement k which also simplifies the BUG_ON. Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 512e3f4..ca97899 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1465,15 +1465,19 @@ static int __init build_zonelists_node(pg_data_t *pgdat, struct zone *zone; BUG_ON(k > ZONE_HIGHMEM); - for (zone = pgdat->node_zones + k; zone >= pgdat->node_zones; zone--) { + + do { + zone = pgdat->node_zones + k; if (populated_zone(zone)) { #ifndef CONFIG_HIGHMEM - BUG_ON(zone - pgdat->node_zones > ZONE_NORMAL); + BUG_ON(k > ZONE_NORMAL); #endif zonelist->zones[j++] = zone; check_highest_zone(k); } - } + k--; + + } while (k >= 0); return j; } -- cgit v1.1 From 070f80326a215d8e6c4fd6f175e28eb446c492bc Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:11:19 -0800 Subject: [PATCH] build_zonelists_node(): rename args Give j and r meaningful names. Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ca97899..7f58077 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1460,25 +1460,25 @@ void show_free_areas(void) * Add all populated zones of a node to the zonelist. */ static int __init build_zonelists_node(pg_data_t *pgdat, - struct zonelist *zonelist, int j, int k) + struct zonelist *zonelist, int nr_zones, int zone_type) { struct zone *zone; - BUG_ON(k > ZONE_HIGHMEM); + BUG_ON(zone_type > ZONE_HIGHMEM); do { - zone = pgdat->node_zones + k; + zone = pgdat->node_zones + zone_type; if (populated_zone(zone)) { #ifndef CONFIG_HIGHMEM - BUG_ON(k > ZONE_NORMAL); + BUG_ON(zone_type > ZONE_NORMAL); #endif - zonelist->zones[j++] = zone; - check_highest_zone(k); + zonelist->zones[nr_zones++] = zone; + check_highest_zone(zone_type); } - k--; + zone_type--; - } while (k >= 0); - return j; + } while (zone_type >= 0); + return nr_zones; } static inline int highest_zone(int zone_bits) -- cgit v1.1 From d3cb487149bd706aa6aeb02042332a450978dc1c Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 6 Jan 2006 00:11:20 -0800 Subject: [PATCH] atomic_long_t & include/asm-generic/atomic.h V2 Several counters already have the need to use 64 atomic variables on 64 bit platforms (see mm_counter_t in sched.h). We have to do ugly ifdefs to fall back to 32 bit atomic on 32 bit platforms. The VM statistics patch that I am working on will also make more extensive use of atomic64. This patch introduces a new type atomic_long_t by providing definitions in asm-generic/atomic.h that works similar to the c "long" type. Its 32 bits on 32 bit platforms and 64 bits on 64 bit platforms. Also cleans up the determination of the mm_counter_t in sched.h. Signed-off-by: Christoph Lameter Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-alpha/atomic.h | 1 + include/asm-arm/atomic.h | 1 + include/asm-arm26/atomic.h | 1 + include/asm-cris/atomic.h | 1 + include/asm-frv/atomic.h | 1 + include/asm-generic/atomic.h | 116 +++++++++++++++++++++++++++++++++++++++++ include/asm-h8300/atomic.h | 1 + include/asm-i386/atomic.h | 1 + include/asm-ia64/atomic.h | 1 + include/asm-m32r/atomic.h | 1 + include/asm-m68k/atomic.h | 1 + include/asm-m68knommu/atomic.h | 1 + include/asm-mips/atomic.h | 1 + include/asm-parisc/atomic.h | 1 + include/asm-powerpc/atomic.h | 1 + include/asm-s390/atomic.h | 1 + include/asm-sh/atomic.h | 1 + include/asm-sh64/atomic.h | 1 + include/asm-sparc/atomic.h | 1 + include/asm-sparc64/atomic.h | 1 + include/asm-v850/atomic.h | 1 + include/asm-x86_64/atomic.h | 1 + include/asm-xtensa/atomic.h | 1 + include/linux/sched.h | 25 +++------ 24 files changed, 144 insertions(+), 19 deletions(-) create mode 100644 include/asm-generic/atomic.h diff --git a/include/asm-alpha/atomic.h b/include/asm-alpha/atomic.h index 6183eab..cb03bbe 100644 --- a/include/asm-alpha/atomic.h +++ b/include/asm-alpha/atomic.h @@ -216,4 +216,5 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v) #define smp_mb__before_atomic_inc() smp_mb() #define smp_mb__after_atomic_inc() smp_mb() +#include #endif /* _ALPHA_ATOMIC_H */ diff --git a/include/asm-arm/atomic.h b/include/asm-arm/atomic.h index d586f65..f72b633 100644 --- a/include/asm-arm/atomic.h +++ b/include/asm-arm/atomic.h @@ -205,5 +205,6 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif #endif diff --git a/include/asm-arm26/atomic.h b/include/asm-arm26/atomic.h index a47cadc..3074b0e 100644 --- a/include/asm-arm26/atomic.h +++ b/include/asm-arm26/atomic.h @@ -118,5 +118,6 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif #endif diff --git a/include/asm-cris/atomic.h b/include/asm-cris/atomic.h index 683b05a..2df2c7a 100644 --- a/include/asm-cris/atomic.h +++ b/include/asm-cris/atomic.h @@ -156,4 +156,5 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif diff --git a/include/asm-frv/atomic.h b/include/asm-frv/atomic.h index f6539ff..3f54fea 100644 --- a/include/asm-frv/atomic.h +++ b/include/asm-frv/atomic.h @@ -426,4 +426,5 @@ extern uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new); }) #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) +#include #endif /* _ASM_ATOMIC_H */ diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h new file mode 100644 index 0000000..e0a28b9 --- /dev/null +++ b/include/asm-generic/atomic.h @@ -0,0 +1,116 @@ +#ifndef _ASM_GENERIC_ATOMIC_H +#define _ASM_GENERIC_ATOMIC_H +/* + * Copyright (C) 2005 Silicon Graphics, Inc. + * Christoph Lameter + * + * Allows to provide arch independent atomic definitions without the need to + * edit all arch specific atomic.h files. + */ + + +/* + * Suppport for atomic_long_t + * + * Casts for parameters are avoided for existing atomic functions in order to + * avoid issues with cast-as-lval under gcc 4.x and other limitations that the + * macros of a platform may have. + */ + +#if BITS_PER_LONG == 64 + +typedef atomic64_t atomic_long_t; + +#define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i) + +static inline long atomic_long_read(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + return (long)atomic64_read(v); +} + +static inline void atomic_long_set(atomic_long_t *l, long i) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic_set(v, i); +} + +static inline void atomic_long_inc(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_inc(v); +} + +static inline void atomic_long_dec(atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_dec(v); +} + +static inline void atomic_long_add(long i, atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_add(i, v); +} + +static inline void atomic_long_sub(long i, atomic_long_t *l) +{ + atomic64_t *v = (atomic64_t *)l; + + atomic64_sub(i, v); +} + +#else + +typedef atomic_t atomic_long_t; + +#define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i) +static inline long atomic_long_read(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + return (long)atomic_read(v); +} + +static inline void atomic_long_set(atomic_long_t *l, long i) +{ + atomic_t *v = (atomic_t *)l; + + atomic_set(v, i); +} + +static inline void atomic_long_inc(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + atomic_inc(v); +} + +static inline void atomic_long_dec(atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + atomic_dec(v); +} + +static inline void atomic_long_add(long i, atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + atomic_add(i, v); +} + +static inline void atomic_long_sub(long i, atomic_long_t *l) +{ + atomic_t *v = (atomic_t *)l; + + atomic_sub(i, v); +} + +#endif +#endif diff --git a/include/asm-h8300/atomic.h b/include/asm-h8300/atomic.h index f23d868..d891541 100644 --- a/include/asm-h8300/atomic.h +++ b/include/asm-h8300/atomic.h @@ -137,4 +137,5 @@ static __inline__ void atomic_set_mask(unsigned long mask, unsigned long *v) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif /* __ARCH_H8300_ATOMIC __ */ diff --git a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h index c68557a..7a5472d 100644 --- a/include/asm-i386/atomic.h +++ b/include/asm-i386/atomic.h @@ -254,4 +254,5 @@ __asm__ __volatile__(LOCK "orl %0,%1" \ #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif diff --git a/include/asm-ia64/atomic.h b/include/asm-ia64/atomic.h index 2fbebf8..15cf798 100644 --- a/include/asm-ia64/atomic.h +++ b/include/asm-ia64/atomic.h @@ -192,4 +192,5 @@ atomic64_add_negative (__s64 i, atomic64_t *v) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif /* _ASM_IA64_ATOMIC_H */ diff --git a/include/asm-m32r/atomic.h b/include/asm-m32r/atomic.h index ef1fb8e..7076127 100644 --- a/include/asm-m32r/atomic.h +++ b/include/asm-m32r/atomic.h @@ -313,4 +313,5 @@ static __inline__ void atomic_set_mask(unsigned long mask, atomic_t *addr) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif /* _ASM_M32R_ATOMIC_H */ diff --git a/include/asm-m68k/atomic.h b/include/asm-m68k/atomic.h index e3c962e..b8a4e75 100644 --- a/include/asm-m68k/atomic.h +++ b/include/asm-m68k/atomic.h @@ -157,4 +157,5 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *v) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif /* __ARCH_M68K_ATOMIC __ */ diff --git a/include/asm-m68knommu/atomic.h b/include/asm-m68knommu/atomic.h index 3c1cc15..1702dbe 100644 --- a/include/asm-m68knommu/atomic.h +++ b/include/asm-m68knommu/atomic.h @@ -143,4 +143,5 @@ static inline int atomic_sub_return(int i, atomic_t * v) #define atomic_dec_return(v) atomic_sub_return(1,(v)) #define atomic_inc_return(v) atomic_add_return(1,(v)) +#include #endif /* __ARCH_M68KNOMMU_ATOMIC __ */ diff --git a/include/asm-mips/atomic.h b/include/asm-mips/atomic.h index 55c37c1..92256e4 100644 --- a/include/asm-mips/atomic.h +++ b/include/asm-mips/atomic.h @@ -713,4 +713,5 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v) #define smp_mb__before_atomic_inc() smp_mb() #define smp_mb__after_atomic_inc() smp_mb() +#include #endif /* _ASM_ATOMIC_H */ diff --git a/include/asm-parisc/atomic.h b/include/asm-parisc/atomic.h index 983e9a2..64ebd08 100644 --- a/include/asm-parisc/atomic.h +++ b/include/asm-parisc/atomic.h @@ -216,4 +216,5 @@ static __inline__ int atomic_read(const atomic_t *v) #define smp_mb__before_atomic_inc() smp_mb() #define smp_mb__after_atomic_inc() smp_mb() +#include #endif diff --git a/include/asm-powerpc/atomic.h b/include/asm-powerpc/atomic.h index ec4b144..ae395a0 100644 --- a/include/asm-powerpc/atomic.h +++ b/include/asm-powerpc/atomic.h @@ -402,5 +402,6 @@ static __inline__ long atomic64_dec_if_positive(atomic64_t *v) #endif /* __powerpc64__ */ +#include #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_ATOMIC_H_ */ diff --git a/include/asm-s390/atomic.h b/include/asm-s390/atomic.h index b3bd4f6..6d07c7d 100644 --- a/include/asm-s390/atomic.h +++ b/include/asm-s390/atomic.h @@ -215,5 +215,6 @@ atomic_compare_and_swap(int expected_oldval,int new_val,atomic_t *v) #define smp_mb__before_atomic_inc() smp_mb() #define smp_mb__after_atomic_inc() smp_mb() +#include #endif /* __KERNEL__ */ #endif /* __ARCH_S390_ATOMIC__ */ diff --git a/include/asm-sh/atomic.h b/include/asm-sh/atomic.h index aabfd33..618d8e0 100644 --- a/include/asm-sh/atomic.h +++ b/include/asm-sh/atomic.h @@ -140,4 +140,5 @@ static __inline__ void atomic_set_mask(unsigned int mask, atomic_t *v) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif /* __ASM_SH_ATOMIC_H */ diff --git a/include/asm-sh64/atomic.h b/include/asm-sh64/atomic.h index 927a2bc..f3ce5c0 100644 --- a/include/asm-sh64/atomic.h +++ b/include/asm-sh64/atomic.h @@ -152,4 +152,5 @@ static __inline__ void atomic_set_mask(unsigned int mask, atomic_t *v) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif /* __ASM_SH64_ATOMIC_H */ diff --git a/include/asm-sparc/atomic.h b/include/asm-sparc/atomic.h index 62bec7a..accb496 100644 --- a/include/asm-sparc/atomic.h +++ b/include/asm-sparc/atomic.h @@ -159,4 +159,5 @@ static inline int __atomic24_sub(int i, atomic24_t *v) #endif /* !(__KERNEL__) */ +#include #endif /* !(__ARCH_SPARC_ATOMIC__) */ diff --git a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h index 3789fe3..11f5aa5 100644 --- a/include/asm-sparc64/atomic.h +++ b/include/asm-sparc64/atomic.h @@ -96,4 +96,5 @@ extern int atomic64_sub_ret(int, atomic64_t *); #define smp_mb__after_atomic_inc() barrier() #endif +#include #endif /* !(__ARCH_SPARC64_ATOMIC__) */ diff --git a/include/asm-v850/atomic.h b/include/asm-v850/atomic.h index bede317..f5b9ab6 100644 --- a/include/asm-v850/atomic.h +++ b/include/asm-v850/atomic.h @@ -126,4 +126,5 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif /* __V850_ATOMIC_H__ */ diff --git a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h index 50db9f3..72eb071 100644 --- a/include/asm-x86_64/atomic.h +++ b/include/asm-x86_64/atomic.h @@ -424,4 +424,5 @@ __asm__ __volatile__(LOCK "orl %0,%1" \ #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif diff --git a/include/asm-xtensa/atomic.h b/include/asm-xtensa/atomic.h index 3670cc7..e2ce06b 100644 --- a/include/asm-xtensa/atomic.h +++ b/include/asm-xtensa/atomic.h @@ -286,6 +286,7 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v) #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() +#include #endif /* __KERNEL__ */ #endif /* _XTENSA_ATOMIC_H */ diff --git a/include/linux/sched.h b/include/linux/sched.h index b0ad6f3..7da3361 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -254,25 +254,12 @@ extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long); * The mm counters are not protected by its page_table_lock, * so must be incremented atomically. */ -#ifdef ATOMIC64_INIT -#define set_mm_counter(mm, member, value) atomic64_set(&(mm)->_##member, value) -#define get_mm_counter(mm, member) ((unsigned long)atomic64_read(&(mm)->_##member)) -#define add_mm_counter(mm, member, value) atomic64_add(value, &(mm)->_##member) -#define inc_mm_counter(mm, member) atomic64_inc(&(mm)->_##member) -#define dec_mm_counter(mm, member) atomic64_dec(&(mm)->_##member) -typedef atomic64_t mm_counter_t; -#else /* !ATOMIC64_INIT */ -/* - * The counters wrap back to 0 at 2^32 * PAGE_SIZE, - * that is, at 16TB if using 4kB page size. - */ -#define set_mm_counter(mm, member, value) atomic_set(&(mm)->_##member, value) -#define get_mm_counter(mm, member) ((unsigned long)atomic_read(&(mm)->_##member)) -#define add_mm_counter(mm, member, value) atomic_add(value, &(mm)->_##member) -#define inc_mm_counter(mm, member) atomic_inc(&(mm)->_##member) -#define dec_mm_counter(mm, member) atomic_dec(&(mm)->_##member) -typedef atomic_t mm_counter_t; -#endif /* !ATOMIC64_INIT */ +#define set_mm_counter(mm, member, value) atomic_long_set(&(mm)->_##member, value) +#define get_mm_counter(mm, member) ((unsigned long)atomic_long_read(&(mm)->_##member)) +#define add_mm_counter(mm, member, value) atomic_long_add(value, &(mm)->_##member) +#define inc_mm_counter(mm, member) atomic_long_inc(&(mm)->_##member) +#define dec_mm_counter(mm, member) atomic_long_dec(&(mm)->_##member) +typedef atomic_long_t mm_counter_t; #else /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ /* -- cgit v1.1 From a74609fafa2e5cc31d558012abaaa55ec9ad9da4 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:11:20 -0800 Subject: [PATCH] mm: page_state opt Optimise page_state manipulations by introducing interrupt unsafe accessors to page_state fields. Callers must provide their own locking (either disable interrupts or not update from interrupt context). Switch over the hot callsites that can easily be moved under interrupts off sections. Signed-off-by: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/page-flags.h | 43 ++++++++++++++++------ mm/page_alloc.c | 89 ++++++++++++++++++++++++++-------------------- mm/rmap.c | 10 ++++-- mm/vmscan.c | 27 +++++++------- 4 files changed, 104 insertions(+), 65 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 32d09c8..dede8d4 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -144,22 +144,33 @@ struct page_state { extern void get_page_state(struct page_state *ret); extern void get_page_state_node(struct page_state *ret, int node); extern void get_full_page_state(struct page_state *ret); -extern unsigned long __read_page_state(unsigned long offset); -extern void __mod_page_state(unsigned long offset, unsigned long delta); +extern unsigned long read_page_state_offset(unsigned long offset); +extern void mod_page_state_offset(unsigned long offset, unsigned long delta); +extern void __mod_page_state_offset(unsigned long offset, unsigned long delta); #define read_page_state(member) \ - __read_page_state(offsetof(struct page_state, member)) + read_page_state_offset(offsetof(struct page_state, member)) #define mod_page_state(member, delta) \ - __mod_page_state(offsetof(struct page_state, member), (delta)) + mod_page_state_offset(offsetof(struct page_state, member), (delta)) -#define inc_page_state(member) mod_page_state(member, 1UL) -#define dec_page_state(member) mod_page_state(member, 0UL - 1) -#define add_page_state(member,delta) mod_page_state(member, (delta)) -#define sub_page_state(member,delta) mod_page_state(member, 0UL - (delta)) +#define __mod_page_state(member, delta) \ + __mod_page_state_offset(offsetof(struct page_state, member), (delta)) -#define mod_page_state_zone(zone, member, delta) \ - do { \ +#define inc_page_state(member) mod_page_state(member, 1UL) +#define dec_page_state(member) mod_page_state(member, 0UL - 1) +#define add_page_state(member,delta) mod_page_state(member, (delta)) +#define sub_page_state(member,delta) mod_page_state(member, 0UL - (delta)) + +#define __inc_page_state(member) __mod_page_state(member, 1UL) +#define __dec_page_state(member) __mod_page_state(member, 0UL - 1) +#define __add_page_state(member,delta) __mod_page_state(member, (delta)) +#define __sub_page_state(member,delta) __mod_page_state(member, 0UL - (delta)) + +#define page_state(member) (*__page_state(offsetof(struct page_state, member))) + +#define state_zone_offset(zone, member) \ +({ \ unsigned offset; \ if (is_highmem(zone)) \ offset = offsetof(struct page_state, member##_high); \ @@ -169,7 +180,17 @@ extern void __mod_page_state(unsigned long offset, unsigned long delta); offset = offsetof(struct page_state, member##_dma32); \ else \ offset = offsetof(struct page_state, member##_dma); \ - __mod_page_state(offset, (delta)); \ + offset; \ +}) + +#define __mod_page_state_zone(zone, member, delta) \ + do { \ + __mod_page_state_offset(state_zone_offset(zone, member), (delta)); \ + } while (0) + +#define mod_page_state_zone(zone, member, delta) \ + do { \ + mod_page_state_offset(state_zone_offset(zone, member), (delta)); \ } while (0) /* diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 7f58077..fd47494 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -424,9 +424,9 @@ void __free_pages_ok(struct page *page, unsigned int order) return; list_add(&page->lru, &list); - mod_page_state(pgfree, 1 << order); kernel_map_pages(page, 1<zone_pgdat; pg_data_t *orig = zonelist->zones[0]->zone_pgdat; struct per_cpu_pageset *p; - local_irq_save(flags); - cpu = smp_processor_id(); - p = zone_pcp(z,cpu); + p = zone_pcp(z, cpu); if (pg == orig) { p->numa_hit++; } else { @@ -696,7 +692,6 @@ static void zone_statistics(struct zonelist *zonelist, struct zone *z) p->local_node++; else p->other_node++; - local_irq_restore(flags); #endif } @@ -716,11 +711,11 @@ static void fastcall free_hot_cold_page(struct page *page, int cold) if (free_pages_check(page)) return; - inc_page_state(pgfree); kernel_map_pages(page, 1, 0); pcp = &zone_pcp(zone, get_cpu())->pcp[cold]; local_irq_save(flags); + __inc_page_state(pgfree); list_add(&page->lru, &pcp->list); pcp->count++; if (pcp->count >= pcp->high) @@ -753,49 +748,58 @@ static inline void prep_zero_page(struct page *page, int order, gfp_t gfp_flags) * we cheat by calling it from here, in the order > 0 path. Saves a branch * or two. */ -static struct page * -buffered_rmqueue(struct zone *zone, int order, gfp_t gfp_flags) +static struct page *buffered_rmqueue(struct zonelist *zonelist, + struct zone *zone, int order, gfp_t gfp_flags) { unsigned long flags; struct page *page; int cold = !!(gfp_flags & __GFP_COLD); + int cpu; again: + cpu = get_cpu(); if (order == 0) { struct per_cpu_pages *pcp; - page = NULL; - pcp = &zone_pcp(zone, get_cpu())->pcp[cold]; + pcp = &zone_pcp(zone, cpu)->pcp[cold]; local_irq_save(flags); - if (!pcp->count) + if (!pcp->count) { pcp->count += rmqueue_bulk(zone, 0, pcp->batch, &pcp->list); - if (likely(pcp->count)) { - page = list_entry(pcp->list.next, struct page, lru); - list_del(&page->lru); - pcp->count--; + if (unlikely(!pcp->count)) + goto failed; } - local_irq_restore(flags); - put_cpu(); + page = list_entry(pcp->list.next, struct page, lru); + list_del(&page->lru); + pcp->count--; } else { spin_lock_irqsave(&zone->lock, flags); page = __rmqueue(zone, order); - spin_unlock_irqrestore(&zone->lock, flags); + spin_unlock(&zone->lock); + if (!page) + goto failed; } - if (page != NULL) { - BUG_ON(bad_range(zone, page)); - mod_page_state_zone(zone, pgalloc, 1 << order); - if (prep_new_page(page, order)) - goto again; + __mod_page_state_zone(zone, pgalloc, 1 << order); + zone_statistics(zonelist, zone, cpu); + local_irq_restore(flags); + put_cpu(); - if (gfp_flags & __GFP_ZERO) - prep_zero_page(page, order, gfp_flags); + BUG_ON(bad_range(zone, page)); + if (prep_new_page(page, order)) + goto again; - if (order && (gfp_flags & __GFP_COMP)) - prep_compound_page(page, order); - } + if (gfp_flags & __GFP_ZERO) + prep_zero_page(page, order, gfp_flags); + + if (order && (gfp_flags & __GFP_COMP)) + prep_compound_page(page, order); return page; + +failed: + local_irq_restore(flags); + put_cpu(); + return NULL; } #define ALLOC_NO_WATERMARKS 0x01 /* don't check watermarks at all */ @@ -871,9 +875,8 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, continue; } - page = buffered_rmqueue(*z, order, gfp_mask); + page = buffered_rmqueue(zonelist, *z, order, gfp_mask); if (page) { - zone_statistics(zonelist, *z); break; } } while (*(++z) != NULL); @@ -1248,7 +1251,7 @@ void get_full_page_state(struct page_state *ret) __get_page_state(ret, sizeof(*ret) / sizeof(unsigned long), &mask); } -unsigned long __read_page_state(unsigned long offset) +unsigned long read_page_state_offset(unsigned long offset) { unsigned long ret = 0; int cpu; @@ -1262,18 +1265,26 @@ unsigned long __read_page_state(unsigned long offset) return ret; } -void __mod_page_state(unsigned long offset, unsigned long delta) +void __mod_page_state_offset(unsigned long offset, unsigned long delta) +{ + void *ptr; + + ptr = &__get_cpu_var(page_states); + *(unsigned long *)(ptr + offset) += delta; +} +EXPORT_SYMBOL(__mod_page_state_offset); + +void mod_page_state_offset(unsigned long offset, unsigned long delta) { unsigned long flags; - void* ptr; + void *ptr; local_irq_save(flags); ptr = &__get_cpu_var(page_states); - *(unsigned long*)(ptr + offset) += delta; + *(unsigned long *)(ptr + offset) += delta; local_irq_restore(flags); } - -EXPORT_SYMBOL(__mod_page_state); +EXPORT_SYMBOL(mod_page_state_offset); void __get_zone_counts(unsigned long *active, unsigned long *inactive, unsigned long *free, struct pglist_data *pgdat) diff --git a/mm/rmap.c b/mm/rmap.c index 4107f64..6f3f7db 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -451,7 +451,11 @@ static void __page_set_anon_rmap(struct page *page, page->index = linear_page_index(vma, address); - inc_page_state(nr_mapped); + /* + * nr_mapped state can be updated without turning off + * interrupts because it is not modified via interrupt. + */ + __inc_page_state(nr_mapped); } /** @@ -498,7 +502,7 @@ void page_add_file_rmap(struct page *page) BUG_ON(!pfn_valid(page_to_pfn(page))); if (atomic_inc_and_test(&page->_mapcount)) - inc_page_state(nr_mapped); + __inc_page_state(nr_mapped); } /** @@ -522,7 +526,7 @@ void page_remove_rmap(struct page *page) */ if (page_test_and_clear_dirty(page)) set_page_dirty(page); - dec_page_state(nr_mapped); + __dec_page_state(nr_mapped); } } diff --git a/mm/vmscan.c b/mm/vmscan.c index 7681d8e..be8235f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -645,16 +645,17 @@ static void shrink_cache(struct zone *zone, struct scan_control *sc) goto done; max_scan -= nr_scan; - if (current_is_kswapd()) - mod_page_state_zone(zone, pgscan_kswapd, nr_scan); - else - mod_page_state_zone(zone, pgscan_direct, nr_scan); nr_freed = shrink_list(&page_list, sc); - if (current_is_kswapd()) - mod_page_state(kswapd_steal, nr_freed); - mod_page_state_zone(zone, pgsteal, nr_freed); - spin_lock_irq(&zone->lru_lock); + local_irq_disable(); + if (current_is_kswapd()) { + __mod_page_state_zone(zone, pgscan_kswapd, nr_scan); + __mod_page_state(kswapd_steal, nr_freed); + } else + __mod_page_state_zone(zone, pgscan_direct, nr_scan); + __mod_page_state_zone(zone, pgsteal, nr_freed); + + spin_lock(&zone->lru_lock); /* * Put back any unfreeable pages. */ @@ -816,11 +817,13 @@ refill_inactive_zone(struct zone *zone, struct scan_control *sc) } } zone->nr_active += pgmoved; - spin_unlock_irq(&zone->lru_lock); - pagevec_release(&pvec); + spin_unlock(&zone->lru_lock); + + __mod_page_state_zone(zone, pgrefill, pgscanned); + __mod_page_state(pgdeactivate, pgdeactivate); + local_irq_enable(); - mod_page_state_zone(zone, pgrefill, pgscanned); - mod_page_state(pgdeactivate, pgdeactivate); + pagevec_release(&pvec); } /* -- cgit v1.1 From b09eb1c06a14641209e6b86e9a5b28ea8287f193 Mon Sep 17 00:00:00 2001 From: Nick Piggin Date: Fri, 6 Jan 2006 00:11:21 -0800 Subject: [PATCH] mm: page_state opt docs Comment the new locking rules for page_state statistics. Signed-off-by: Nick Piggin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/page-flags.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index dede8d4..d52999c 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -79,13 +79,23 @@ /* * Global page accounting. One instance per CPU. Only unsigned longs are * allowed. + * + * - Fields can be modified with xxx_page_state and xxx_page_state_zone at + * any time safely (which protects the instance from modification by + * interrupt. + * - The __xxx_page_state variants can be used safely when interrupts are + * disabled. + * - The __xxx_page_state variants can be used if the field is only + * modified from process context, or only modified from interrupt context. + * In this case, the field should be commented here. */ struct page_state { unsigned long nr_dirty; /* Dirty writeable pages */ unsigned long nr_writeback; /* Pages under writeback */ unsigned long nr_unstable; /* NFS unstable pages */ unsigned long nr_page_table_pages;/* Pages used for pagetables */ - unsigned long nr_mapped; /* mapped into pagetables */ + unsigned long nr_mapped; /* mapped into pagetables. + * only modified from process context */ unsigned long nr_slab; /* In slab */ #define GET_PAGE_STATE_LAST nr_slab -- cgit v1.1 From 6e20a64a3913819133fefeca466211c7eb8adda1 Mon Sep 17 00:00:00 2001 From: Nicolas Kaiser Date: Fri, 6 Jan 2006 00:11:22 -0800 Subject: [PATCH] selinux: ARRAY_SIZE cleanups Use ARRAY_SIZE macro instead of sizeof(x)/sizeof(x[0]). Signed-off-by: Nicolas Kaiser Signed-off-by: Stephen Smalley Acked-by: James Morris Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- security/selinux/selinuxfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 0e1352a..e59da63 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -376,7 +376,7 @@ static ssize_t selinux_transaction_write(struct file *file, const char __user *b char *data; ssize_t rv; - if (ino >= sizeof(write_op)/sizeof(write_op[0]) || !write_op[ino]) + if (ino >= ARRAY_SIZE(write_op) || !write_op[ino]) return -EINVAL; data = simple_transaction_get(file, buf, size); @@ -1161,7 +1161,7 @@ static int sel_make_avc_files(struct dentry *dir) #endif }; - for (i = 0; i < sizeof (files) / sizeof (files[0]); i++) { + for (i = 0; i < ARRAY_SIZE(files); i++) { struct inode *inode; struct dentry *dentry; -- cgit v1.1 From 32725ad8430b58e42c5d54757ce7871e680d05cb Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 6 Jan 2006 00:11:23 -0800 Subject: [PATCH] selinux: more ARRAY_SIZE cleanups Further ARRAY_SIZE cleanups under security/selinux. Signed-off-by: Tobias Klauser Signed-off-by: Stephen Smalley Acked-by: James Morris Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- security/selinux/ss/avtab.c | 2 +- security/selinux/ss/policydb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c index dde094f..d049c7a 100644 --- a/security/selinux/ss/avtab.c +++ b/security/selinux/ss/avtab.c @@ -359,7 +359,7 @@ int avtab_read_item(void *fp, u32 vers, struct avtab *a, return -1; } - for (i = 0; i < sizeof(spec_order)/sizeof(u16); i++) { + for (i = 0; i < ARRAY_SIZE(spec_order); i++) { if (val & spec_order[i]) { key.specified = spec_order[i] | enabled; datum.data = le32_to_cpu(buf32[items++]); diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 0ac311d..0111990 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -103,7 +103,7 @@ static struct policydb_compat_info *policydb_lookup_compat(int version) int i; struct policydb_compat_info *info = NULL; - for (i = 0; i < sizeof(policydb_compat)/sizeof(*info); i++) { + for (i = 0; i < ARRAY_SIZE(policydb_compat); i++) { if (policydb_compat[i].version == version) { info = &policydb_compat[i]; break; -- cgit v1.1 From 8d9067bda99c68e1a17d93e78cf3a5a3f67e0c35 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:24 -0800 Subject: [PATCH] Keys: Remove key duplication Remove the key duplication stuff since there's nothing that uses it, no way to get at it and it's awkward to deal with for LSM purposes. Signed-off-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/keys.txt | 18 ------------- include/keys/user-type.h | 1 - include/linux/key.h | 8 ------ security/keys/key.c | 56 +++----------------------------------- security/keys/keyring.c | 64 -------------------------------------------- security/keys/user_defined.c | 33 ----------------------- 6 files changed, 3 insertions(+), 177 deletions(-) diff --git a/Documentation/keys.txt b/Documentation/keys.txt index 3115488..6304db5 100644 --- a/Documentation/keys.txt +++ b/Documentation/keys.txt @@ -860,24 +860,6 @@ The structure has a number of fields, some of which are mandatory: It is safe to sleep in this method. - (*) int (*duplicate)(struct key *key, const struct key *source); - - If this type of key can be duplicated, then this method should be - provided. It is called to copy the payload attached to the source into the - new key. The data length on the new key will have been updated and the - quota adjusted already. - - This method will be called with the source key's semaphore read-locked to - prevent its payload from being changed, thus RCU constraints need not be - applied to the source key. - - This method does not have to lock the destination key in order to attach a - payload. The fact that KEY_FLAG_INSTANTIATED is not set in key->flags - prevents anything else from gaining access to the key. - - It is safe to sleep in this method. - - (*) int (*update)(struct key *key, const void *data, size_t datalen); If this type of key can be updated, then this method should be provided. diff --git a/include/keys/user-type.h b/include/keys/user-type.h index 26f6ec3..a3dae18 100644 --- a/include/keys/user-type.h +++ b/include/keys/user-type.h @@ -35,7 +35,6 @@ struct user_key_payload { extern struct key_type key_type_user; extern int user_instantiate(struct key *key, const void *data, size_t datalen); -extern int user_duplicate(struct key *key, const struct key *source); extern int user_update(struct key *key, const void *data, size_t datalen); extern int user_match(const struct key *key, const void *criterion); extern void user_destroy(struct key *key); diff --git a/include/linux/key.h b/include/linux/key.h index 53513a3..4d189e5 100644 --- a/include/linux/key.h +++ b/include/linux/key.h @@ -193,14 +193,6 @@ struct key_type { */ int (*instantiate)(struct key *key, const void *data, size_t datalen); - /* duplicate a key of this type (optional) - * - the source key will be locked against change - * - the new description will be attached - * - the quota will have been adjusted automatically from - * source->quotalen - */ - int (*duplicate)(struct key *key, const struct key *source); - /* update a key of this type (optional) * - this method should call key_payload_reserve() to recalculate the * quota consumption diff --git a/security/keys/key.c b/security/keys/key.c index 01bcfec..bb03662 100644 --- a/security/keys/key.c +++ b/security/keys/key.c @@ -240,9 +240,9 @@ static inline void key_alloc_serial(struct key *key) /* * allocate a key of the specified type * - update the user's quota to reflect the existence of the key - * - called from a key-type operation with key_types_sem read-locked by either - * key_create_or_update() or by key_duplicate(); this prevents unregistration - * of the key type + * - called from a key-type operation with key_types_sem read-locked by + * key_create_or_update() + * - this prevents unregistration of the key type * - upon return the key is as yet uninstantiated; the caller needs to either * instantiate the key or discard it before returning */ @@ -889,56 +889,6 @@ EXPORT_SYMBOL(key_update); /*****************************************************************************/ /* - * duplicate a key, potentially with a revised description - * - must be supported by the keytype (keyrings for instance can be duplicated) - */ -struct key *key_duplicate(struct key *source, const char *desc) -{ - struct key *key; - int ret; - - key_check(source); - - if (!desc) - desc = source->description; - - down_read(&key_types_sem); - - ret = -EINVAL; - if (!source->type->duplicate) - goto error; - - /* allocate and instantiate a key */ - key = key_alloc(source->type, desc, current->fsuid, current->fsgid, - source->perm, 0); - if (IS_ERR(key)) - goto error_k; - - down_read(&source->sem); - ret = key->type->duplicate(key, source); - up_read(&source->sem); - if (ret < 0) - goto error2; - - atomic_inc(&key->user->nikeys); - set_bit(KEY_FLAG_INSTANTIATED, &key->flags); - - error_k: - up_read(&key_types_sem); - out: - return key; - - error2: - key_put(key); - error: - up_read(&key_types_sem); - key = ERR_PTR(ret); - goto out; - -} /* end key_duplicate() */ - -/*****************************************************************************/ -/* * revoke a key */ void key_revoke(struct key *key) diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 4e9fa8b..0acecbd 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -48,7 +48,6 @@ static inline unsigned keyring_hash(const char *desc) */ static int keyring_instantiate(struct key *keyring, const void *data, size_t datalen); -static int keyring_duplicate(struct key *keyring, const struct key *source); static int keyring_match(const struct key *keyring, const void *criterion); static void keyring_destroy(struct key *keyring); static void keyring_describe(const struct key *keyring, struct seq_file *m); @@ -59,7 +58,6 @@ struct key_type key_type_keyring = { .name = "keyring", .def_datalen = sizeof(struct keyring_list), .instantiate = keyring_instantiate, - .duplicate = keyring_duplicate, .match = keyring_match, .destroy = keyring_destroy, .describe = keyring_describe, @@ -120,68 +118,6 @@ static int keyring_instantiate(struct key *keyring, /*****************************************************************************/ /* - * duplicate the list of subscribed keys from a source keyring into this one - */ -static int keyring_duplicate(struct key *keyring, const struct key *source) -{ - struct keyring_list *sklist, *klist; - unsigned max; - size_t size; - int loop, ret; - - const unsigned limit = - (PAGE_SIZE - sizeof(*klist)) / sizeof(struct key *); - - ret = 0; - - /* find out how many keys are currently linked */ - rcu_read_lock(); - sklist = rcu_dereference(source->payload.subscriptions); - max = 0; - if (sklist) - max = sklist->nkeys; - rcu_read_unlock(); - - /* allocate a new payload and stuff load with key links */ - if (max > 0) { - BUG_ON(max > limit); - - max = (max + 3) & ~3; - if (max > limit) - max = limit; - - ret = -ENOMEM; - size = sizeof(*klist) + sizeof(struct key *) * max; - klist = kmalloc(size, GFP_KERNEL); - if (!klist) - goto error; - - /* set links */ - rcu_read_lock(); - sklist = rcu_dereference(source->payload.subscriptions); - - klist->maxkeys = max; - klist->nkeys = sklist->nkeys; - memcpy(klist->keys, - sklist->keys, - sklist->nkeys * sizeof(struct key *)); - - for (loop = klist->nkeys - 1; loop >= 0; loop--) - atomic_inc(&klist->keys[loop]->usage); - - rcu_read_unlock(); - - rcu_assign_pointer(keyring->payload.subscriptions, klist); - ret = 0; - } - - error: - return ret; - -} /* end keyring_duplicate() */ - -/*****************************************************************************/ -/* * match keyrings on their name */ static int keyring_match(const struct key *keyring, const void *description) diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c index cbda3b2..8e71895 100644 --- a/security/keys/user_defined.c +++ b/security/keys/user_defined.c @@ -26,7 +26,6 @@ struct key_type key_type_user = { .name = "user", .instantiate = user_instantiate, - .duplicate = user_duplicate, .update = user_update, .match = user_match, .destroy = user_destroy, @@ -68,42 +67,10 @@ error: return ret; } /* end user_instantiate() */ - EXPORT_SYMBOL_GPL(user_instantiate); /*****************************************************************************/ /* - * duplicate a user defined key - * - both keys' semaphores are locked against further modification - * - the new key cannot yet be accessed - */ -int user_duplicate(struct key *key, const struct key *source) -{ - struct user_key_payload *upayload, *spayload; - int ret; - - /* just copy the payload */ - ret = -ENOMEM; - upayload = kmalloc(sizeof(*upayload) + source->datalen, GFP_KERNEL); - if (upayload) { - spayload = rcu_dereference(source->payload.data); - BUG_ON(source->datalen != spayload->datalen); - - upayload->datalen = key->datalen = spayload->datalen; - memcpy(upayload->data, spayload->data, key->datalen); - - key->payload.data = upayload; - ret = 0; - } - - return ret; - -} /* end user_duplicate() */ - -EXPORT_SYMBOL_GPL(user_duplicate); - -/*****************************************************************************/ -/* * dispose of the old data from an updated user defined key */ static void user_update_rcu_disposal(struct rcu_head *rcu) -- cgit v1.1 From 1ae8f40767a3afc6244719a2c8fbcf546767d5b0 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 6 Jan 2006 00:11:25 -0800 Subject: [PATCH] security/: possible cleanups make needlessly global code static Signed-off-by: Adrian Bunk Cc: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- security/keys/internal.h | 1 - security/keys/key.c | 2 +- security/keys/keyring.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/security/keys/internal.h b/security/keys/internal.h index db99ed4..39cba97 100644 --- a/security/keys/internal.h +++ b/security/keys/internal.h @@ -25,7 +25,6 @@ #define kdebug(FMT, a...) do {} while(0) #endif -extern struct key_type key_type_dead; extern struct key_type key_type_user; /*****************************************************************************/ diff --git a/security/keys/key.c b/security/keys/key.c index bb03662..99781b7 100644 --- a/security/keys/key.c +++ b/security/keys/key.c @@ -36,7 +36,7 @@ static DECLARE_WORK(key_cleanup_task, key_cleanup, NULL); DECLARE_RWSEM(key_construction_sem); /* any key who's type gets unegistered will be re-typed to this */ -struct key_type key_type_dead = { +static struct key_type key_type_dead = { .name = "dead", }; diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 0acecbd..5d22c03 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c @@ -68,7 +68,7 @@ struct key_type key_type_keyring = { * semaphore to serialise link/link calls to prevent two link calls in parallel * introducing a cycle */ -DECLARE_RWSEM(keyring_serialise_link_sem); +static DECLARE_RWSEM(keyring_serialise_link_sem); /*****************************************************************************/ /* -- cgit v1.1 From fa57f9c2b841872ffad9d8f7b3de23d6ba33c30d Mon Sep 17 00:00:00 2001 From: Eugene Surovegin Date: Fri, 6 Jan 2006 00:11:26 -0800 Subject: [PATCH] ppc32: remove "jumbo" member from ocp_func_emac_data Remove the not needed anymore "jumbo" member from ocp_func_emac_data. Jumbo frame support is handled by PPC4xx EMAC driver internally now. Signed-off-by: Eugene Surovegin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/platforms/4xx/ibm440gx.c | 2 -- arch/ppc/platforms/4xx/ibm440sp.c | 1 - include/asm-ppc/ibm_ocp.h | 1 - 3 files changed, 4 deletions(-) diff --git a/arch/ppc/platforms/4xx/ibm440gx.c b/arch/ppc/platforms/4xx/ibm440gx.c index 956f45e..d24c09e 100644 --- a/arch/ppc/platforms/4xx/ibm440gx.c +++ b/arch/ppc/platforms/4xx/ibm440gx.c @@ -58,7 +58,6 @@ static struct ocp_func_emac_data ibm440gx_emac2_def = { .wol_irq = 65, /* WOL interrupt number */ .mdio_idx = -1, /* No shared MDIO */ .tah_idx = 0, /* TAH device index */ - .jumbo = 1, /* Jumbo frames supported */ }; static struct ocp_func_emac_data ibm440gx_emac3_def = { @@ -72,7 +71,6 @@ static struct ocp_func_emac_data ibm440gx_emac3_def = { .wol_irq = 67, /* WOL interrupt number */ .mdio_idx = -1, /* No shared MDIO */ .tah_idx = 1, /* TAH device index */ - .jumbo = 1, /* Jumbo frames supported */ }; OCP_SYSFS_EMAC_DATA() diff --git a/arch/ppc/platforms/4xx/ibm440sp.c b/arch/ppc/platforms/4xx/ibm440sp.c index feb17e4..71a0117 100644 --- a/arch/ppc/platforms/4xx/ibm440sp.c +++ b/arch/ppc/platforms/4xx/ibm440sp.c @@ -31,7 +31,6 @@ static struct ocp_func_emac_data ibm440sp_emac0_def = { .wol_irq = 61, /* WOL interrupt number */ .mdio_idx = -1, /* No shared MDIO */ .tah_idx = -1, /* No TAH */ - .jumbo = 1, /* Jumbo frames supported */ }; OCP_SYSFS_EMAC_DATA() diff --git a/include/asm-ppc/ibm_ocp.h b/include/asm-ppc/ibm_ocp.h index 9c21de1..ddce616 100644 --- a/include/asm-ppc/ibm_ocp.h +++ b/include/asm-ppc/ibm_ocp.h @@ -63,7 +63,6 @@ struct ocp_func_emac_data { int wol_irq; /* WOL interrupt */ int mdio_idx; /* EMAC idx of MDIO master or -1 */ int tah_idx; /* TAH device index or -1 */ - int jumbo; /* Jumbo frames capable flag */ int phy_mode; /* PHY type or configurable mode */ u8 mac_addr[6]; /* EMAC mac address */ u32 phy_map; /* EMAC phy map */ -- cgit v1.1 From e13ac219816c58579f40b48220b2fa5d94c30e84 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Fri, 6 Jan 2006 00:11:26 -0800 Subject: [PATCH] arch/ppc/kernel/idle.c: don't declare cpu variable in non-SMP kernels Disable declaration of cpu variable in default_idle function when building non-SMP kernels. Signed-off-by: Otavio Salvador Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/kernel/idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ppc/kernel/idle.c b/arch/ppc/kernel/idle.c index 821a75e..1be3ca5 100644 --- a/arch/ppc/kernel/idle.c +++ b/arch/ppc/kernel/idle.c @@ -37,7 +37,6 @@ void default_idle(void) { void (*powersave)(void); - int cpu = smp_processor_id(); powersave = ppc_md.power_save; @@ -47,7 +46,8 @@ void default_idle(void) #ifdef CONFIG_SMP else { set_thread_flag(TIF_POLLING_NRFLAG); - while (!need_resched() && !cpu_is_offline(cpu)) + while (!need_resched() && + !cpu_is_offline(smp_processor_id())) barrier(); clear_thread_flag(TIF_POLLING_NRFLAG); } -- cgit v1.1 From c9662b4b37f8f00a212eb4131d1d177b6ed8ddbd Mon Sep 17 00:00:00 2001 From: Arthur Othieno Date: Fri, 6 Jan 2006 00:11:29 -0800 Subject: [PATCH] macintosh: don't store i2c_add_driver() return if no further processing done therm_pm72.c and windfarm_lm75_sensor.c both store the return from i2c_add_driver() but do no further processing on the result. Simply return what i2c_add_driver() did, instead. Signed-off-by: Arthur Othieno Acked-by: Benjamin Herrenschmidt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/macintosh/therm_pm72.c | 7 +------ drivers/macintosh/windfarm_lm75_sensor.c | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index 190878e..435427d 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c @@ -1988,18 +1988,13 @@ static void fcu_lookup_fans(struct device_node *fcu_node) static int fcu_of_probe(struct of_device* dev, const struct of_device_id *match) { - int rc; - state = state_detached; /* Lookup the fans in the device tree */ fcu_lookup_fans(dev->node); /* Add the driver */ - rc = i2c_add_driver(&therm_pm72_driver); - if (rc < 0) - return rc; - return 0; + return i2c_add_driver(&therm_pm72_driver); } static int fcu_of_remove(struct of_device* dev) diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c index a0a41ad..c62ed68 100644 --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c @@ -240,12 +240,7 @@ static int wf_lm75_detach(struct i2c_client *client) static int __init wf_lm75_sensor_init(void) { - int rc; - - rc = i2c_add_driver(&wf_lm75_driver); - if (rc < 0) - return rc; - return 0; + return i2c_add_driver(&wf_lm75_driver); } static void __exit wf_lm75_sensor_exit(void) -- cgit v1.1 From 7558824a8d16e244072bfebc9e5e3e3b1b9af261 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:30 -0800 Subject: [PATCH] ppc32: Remove useless file arch/ppc/platforms/mpc5200.c That file is a left-over of the 'old' OCP model that should have been erased during the change to platform model but I forgot it ... Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/platforms/mpc5200.c | 53 -------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 arch/ppc/platforms/mpc5200.c diff --git a/arch/ppc/platforms/mpc5200.c b/arch/ppc/platforms/mpc5200.c deleted file mode 100644 index a58db43..0000000 --- a/arch/ppc/platforms/mpc5200.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * arch/ppc/platforms/mpc5200.c - * - * OCP Definitions for the boards based on MPC5200 processor. Contains - * definitions for every common peripherals. (Mostly all but PSCs) - * - * Maintainer : Sylvain Munaut - * - * Copyright 2004 Sylvain Munaut - * - * This file is licensed under the terms of the GNU General Public License - * version 2. This program is licensed "as is" without any warranty of any - * kind, whether express or implied. - */ - -#include -#include - - -static struct ocp_fs_i2c_data mpc5200_i2c_def = { - .flags = FS_I2C_CLOCK_5200, -}; - - -/* Here is the core_ocp struct. - * With all the devices common to all board. Even if port multiplexing is - * not setup for them (if the user don't want them, just don't select the - * config option). The potentially conflicting devices (like PSCs) goes in - * board specific file. - */ -struct ocp_def core_ocp[] = { - { - .vendor = OCP_VENDOR_FREESCALE, - .function = OCP_FUNC_IIC, - .index = 0, - .paddr = MPC52xx_I2C1, - .irq = OCP_IRQ_NA, /* MPC52xx_IRQ_I2C1 - Buggy */ - .pm = OCP_CPM_NA, - .additions = &mpc5200_i2c_def, - }, - { - .vendor = OCP_VENDOR_FREESCALE, - .function = OCP_FUNC_IIC, - .index = 1, - .paddr = MPC52xx_I2C2, - .irq = OCP_IRQ_NA, /* MPC52xx_IRQ_I2C2 - Buggy */ - .pm = OCP_CPM_NA, - .additions = &mpc5200_i2c_def, - }, - { /* Terminating entry */ - .vendor = OCP_VENDOR_INVALID - } -}; -- cgit v1.1 From 2d8179c0b77b54e27321944e16f65defeda81e27 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:31 -0800 Subject: [PATCH] ppc32/serial: Fix compiler errors with GCC 4.x in mpc52xx_uart.c Signed-off-by: Wolfgang Denk Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/mpc52xx_uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index b8727d9..4dcf031 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c @@ -668,7 +668,7 @@ mpc52xx_console_setup(struct console *co, char *options) } -extern struct uart_driver mpc52xx_uart_driver; +static struct uart_driver mpc52xx_uart_driver; static struct console mpc52xx_console = { .name = "ttyS", -- cgit v1.1 From d62de3aa8ac762c09845aa38634a845da55f31dc Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:32 -0800 Subject: [PATCH] ppc32/serial: Change mpc52xx_uart.c to use the Low Density Serial port major Before this patch we were just using the "classic" /dev/ttySx devices. However when another on the system is loaded that uses those (like drivers for serial PCMCIA), that creates a conflict for the minors. Therefore, we now use /dev/ttyPSC[0:5] (note the 0-based numbering !) with some minors we've been assigned in the "Low Density Serial port major" Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/mpc52xx_uart.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 4dcf031..1288d62 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c @@ -37,11 +37,11 @@ * by the bootloader or in the platform init code. * * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2, - * and so on). So the PSC1 is mapped to /dev/ttyS0, PSC2 to /dev/ttyS1 and so - * on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly for - * the console code : without this 1:1 mapping, at early boot time, when we are - * parsing the kernel args console=ttyS?, we wouldn't know wich PSC it will be - * mapped to. + * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and + * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly + * fpr the console code : without this 1:1 mapping, at early boot time, when we + * are parsing the kernel args console=ttyPSC?, we wouldn't know wich PSC it + * will be mapped to. */ #include @@ -65,6 +65,10 @@ #include +/* We've been assigned a range on the "Low-density serial ports" major */ +#define SERIAL_PSC_MAJOR 204 +#define SERIAL_PSC_MINOR 148 + #define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */ @@ -671,12 +675,12 @@ mpc52xx_console_setup(struct console *co, char *options) static struct uart_driver mpc52xx_uart_driver; static struct console mpc52xx_console = { - .name = "ttyS", + .name = "ttyPSC", .write = mpc52xx_console_write, .device = uart_console_device, .setup = mpc52xx_console_setup, .flags = CON_PRINTBUFFER, - .index = -1, /* Specified on the cmdline (e.g. console=ttyS0 ) */ + .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0 ) */ .data = &mpc52xx_uart_driver, }; @@ -703,10 +707,10 @@ console_initcall(mpc52xx_console_init); static struct uart_driver mpc52xx_uart_driver = { .owner = THIS_MODULE, .driver_name = "mpc52xx_psc_uart", - .dev_name = "ttyS", - .devfs_name = "ttyS", - .major = TTY_MAJOR, - .minor = 64, + .dev_name = "ttyPSC", + .devfs_name = "ttyPSC", + .major = SERIAL_PSC_MAJOR, + .minor = SERIAL_PSC_MINOR, .nr = MPC52xx_PSC_MAXNUM, .cons = MPC52xx_PSC_CONSOLE, }; -- cgit v1.1 From 4aa7c80193c561e52c06351e0f521e697954a859 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:34 -0800 Subject: [PATCH] ppc32: Fix static IO mapping for Freescale MPC52xx The current iomapping used MBAR_SIZE for the size argument of io_block_mapping, resulting in a call to setbat with a size argument of 64k which is invalid. This patch correct this and maps the whole 0xf0000000->0xffffffff range so that devices on the local bus are also included in the BAT mapping. Thanks to Bernhard Kuhn from Metrowerks for pointing this out. Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/syslib/mpc52xx_setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/ppc/syslib/mpc52xx_setup.c b/arch/ppc/syslib/mpc52xx_setup.c index bb237458..a4a4b02 100644 --- a/arch/ppc/syslib/mpc52xx_setup.c +++ b/arch/ppc/syslib/mpc52xx_setup.c @@ -84,9 +84,11 @@ mpc52xx_set_bat(void) void __init mpc52xx_map_io(void) { - /* Here we only map the MBAR */ + /* Here we map the MBAR and the whole upper zone. MBAR is only + 64k but we can't map only 64k with BATs. Map the whole + 0xf0000000 range is ok and helps eventual lpb devices placed there */ io_block_mapping( - MPC52xx_MBAR_VIRT, MPC52xx_MBAR, MPC52xx_MBAR_SIZE, _PAGE_IO); + MPC52xx_MBAR_VIRT, MPC52xx_MBAR, 0x10000000, _PAGE_IO); } -- cgit v1.1 From e21b9f2e9a580ce7375ec58953c1bb19aabe0db4 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:35 -0800 Subject: [PATCH] ppc32: Modify Freescale MPC52xx IRQ mapping to _not_ use irq 0 AFAIK IRQ number 0 is a perfectly valid IRQ number. But it seems there are numerous places where it's considered to be invalid or "no irq" value. Since that value is problematic, the IRQ mapping is changed to not use it. Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-ppc/mpc52xx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-ppc/mpc52xx.h b/include/asm-ppc/mpc52xx.h index e5f80c2..04d5630 100644 --- a/include/asm-ppc/mpc52xx.h +++ b/include/asm-ppc/mpc52xx.h @@ -107,7 +107,7 @@ enum ppc_sys_devices { #define MPC52xx_SDMA_IRQ_NUM 17 #define MPC52xx_PERP_IRQ_NUM 23 -#define MPC52xx_CRIT_IRQ_BASE 0 +#define MPC52xx_CRIT_IRQ_BASE 1 #define MPC52xx_MAIN_IRQ_BASE (MPC52xx_CRIT_IRQ_BASE + MPC52xx_CRIT_IRQ_NUM) #define MPC52xx_SDMA_IRQ_BASE (MPC52xx_MAIN_IRQ_BASE + MPC52xx_MAIN_IRQ_NUM) #define MPC52xx_PERP_IRQ_BASE (MPC52xx_SDMA_IRQ_BASE + MPC52xx_SDMA_IRQ_NUM) -- cgit v1.1 From dbeb198d9366eb3d3ad64444ceecb5b1d5b5d7ef Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:35 -0800 Subject: [PATCH] ppc32: Remove __init qualifier from mpc52xx pci resources fixups The mpc52xx_pci_fixup_resources is not only called at init but also when there is a pci hotplug like when a cardbus card is plugged in. So that function is needed after init too. Thanks to Asier Llano Palacios for reporting this. Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/syslib/mpc52xx_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/ppc/syslib/mpc52xx_pci.c b/arch/ppc/syslib/mpc52xx_pci.c index 4ac1908..e6cb3e2 100644 --- a/arch/ppc/syslib/mpc52xx_pci.c +++ b/arch/ppc/syslib/mpc52xx_pci.c @@ -151,7 +151,7 @@ mpc52xx_pci_setup(struct mpc52xx_pci __iomem *pci_regs) #endif } -static void __init +static void mpc52xx_pci_fixup_resources(struct pci_dev *dev) { int i; -- cgit v1.1 From db674ed450f113518285f410c93abecd93e71a2f Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:36 -0800 Subject: [PATCH] ppc32: Fix MPC52xx configuration space access This patch takes care of an errata of the MPC5200 by avoiding 32 bits access in type 1 configuration accesses. All others accesses are still 32 bits wide. It also adds some mb() since the simple out_be(...) are not sufficient in this case. Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/syslib/mpc52xx_pci.c | 83 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 14 deletions(-) diff --git a/arch/ppc/syslib/mpc52xx_pci.c b/arch/ppc/syslib/mpc52xx_pci.c index e6cb3e2..2c5e6dd 100644 --- a/arch/ppc/syslib/mpc52xx_pci.c +++ b/arch/ppc/syslib/mpc52xx_pci.c @@ -24,6 +24,12 @@ #include +/* This macro is defined to activate the workaround for the bug + 435 of the MPC5200 (L25R). With it activated, we don't do any + 32 bits configuration access during type-1 cycles */ +#define MPC5200_BUG_435_WORKAROUND + + static int mpc52xx_pci_read_config(struct pci_bus *bus, unsigned int devfn, int offset, int len, u32 *val) @@ -40,17 +46,39 @@ mpc52xx_pci_read_config(struct pci_bus *bus, unsigned int devfn, ((bus->number - hose->bus_offset) << 16) | (devfn << 8) | (offset & 0xfc)); + mb(); + +#ifdef MPC5200_BUG_435_WORKAROUND + if (bus->number != hose->bus_offset) { + switch (len) { + case 1: + value = in_8(((u8 __iomem *)hose->cfg_data) + (offset & 3)); + break; + case 2: + value = in_le16(((u16 __iomem *)hose->cfg_data) + ((offset>>1) & 1)); + break; + + default: + value = in_le16((u16 __iomem *)hose->cfg_data) | + (in_le16(((u16 __iomem *)hose->cfg_data) + 1) << 16); + break; + } + } + else +#endif + { + value = in_le32(hose->cfg_data); - value = in_le32(hose->cfg_data); - - if (len != 4) { - value >>= ((offset & 0x3) << 3); - value &= 0xffffffff >> (32 - (len << 3)); + if (len != 4) { + value >>= ((offset & 0x3) << 3); + value &= 0xffffffff >> (32 - (len << 3)); + } } *val = value; out_be32(hose->cfg_addr, 0); + mb(); return PCIBIOS_SUCCESSFUL; } @@ -71,21 +99,48 @@ mpc52xx_pci_write_config(struct pci_bus *bus, unsigned int devfn, ((bus->number - hose->bus_offset) << 16) | (devfn << 8) | (offset & 0xfc)); + mb(); + +#ifdef MPC5200_BUG_435_WORKAROUND + if (bus->number != hose->bus_offset) { + switch (len) { + case 1: + out_8(((u8 __iomem *)hose->cfg_data) + + (offset & 3), val); + break; + case 2: + out_le16(((u16 __iomem *)hose->cfg_data) + + ((offset>>1) & 1), val); + break; + + default: + out_le16((u16 __iomem *)hose->cfg_data, + (u16)val); + out_le16(((u16 __iomem *)hose->cfg_data) + 1, + (u16)(val>>16)); + break; + } + } + else +#endif + { + if (len != 4) { + value = in_le32(hose->cfg_data); - if (len != 4) { - value = in_le32(hose->cfg_data); + offset = (offset & 0x3) << 3; + mask = (0xffffffff >> (32 - (len << 3))); + mask <<= offset; - offset = (offset & 0x3) << 3; - mask = (0xffffffff >> (32 - (len << 3))); - mask <<= offset; + value &= ~mask; + val = value | ((val << offset) & mask); + } - value &= ~mask; - val = value | ((val << offset) & mask); + out_le32(hose->cfg_data, val); } - - out_le32(hose->cfg_data, val); + mb(); out_be32(hose->cfg_addr, 0); + mb(); return PCIBIOS_SUCCESSFUL; } -- cgit v1.1 From 041cb6241fa97c4881dd19d79f783b2e077acd28 Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:37 -0800 Subject: [PATCH] ppc32: Fix MPC52xx PCI init in cas the bootloader didn't do it We were counting on the bootloader to init some stuff, like get the bus out of reset and enable accesses. Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/syslib/mpc52xx_pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/ppc/syslib/mpc52xx_pci.c b/arch/ppc/syslib/mpc52xx_pci.c index 2c5e6dd..313c96e 100644 --- a/arch/ppc/syslib/mpc52xx_pci.c +++ b/arch/ppc/syslib/mpc52xx_pci.c @@ -154,9 +154,12 @@ static struct pci_ops mpc52xx_pci_ops = { static void __init mpc52xx_pci_setup(struct mpc52xx_pci __iomem *pci_regs) { + u32 tmp; /* Setup control regs */ - /* Nothing to do afaik */ + tmp = in_be32(&pci_regs->scr); + tmp |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY; + out_be32(&pci_regs->scr, tmp); /* Setup windows */ out_be32(&pci_regs->iw0btar, MPC52xx_PCI_IWBTAR_TRANSLATION( @@ -197,13 +200,12 @@ mpc52xx_pci_setup(struct mpc52xx_pci __iomem *pci_regs) /* Not necessary and can be a bad thing if for example the bootloader is displaying a splash screen or ... Just left here for documentation purpose if anyone need it */ -#if 0 - u32 tmp; tmp = in_be32(&pci_regs->gscr); +#if 0 out_be32(&pci_regs->gscr, tmp | MPC52xx_PCI_GSCR_PR); udelay(50); - out_be32(&pci_regs->gscr, tmp); #endif + out_be32(&pci_regs->gscr, tmp & ~MPC52xx_PCI_GSCR_PR); } static void -- cgit v1.1 From f80257a25d9f73a0e6e377c7d6bf29b8938c042d Mon Sep 17 00:00:00 2001 From: Sylvain Munaut Date: Fri, 6 Jan 2006 00:11:38 -0800 Subject: [PATCH] ppc32: Allows compilation of a MPC52xx kernel without PCI Some custom cards might not need PCI, without this patch, compilation fails. Signed-off-by: Roger Blofeld Signed-off-by: Sylvain Munaut Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/platforms/lite5200.c | 2 ++ include/asm-ppc/io.h | 2 ++ include/asm-ppc/mpc52xx.h | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/arch/ppc/platforms/lite5200.c b/arch/ppc/platforms/lite5200.c index d44cc99..7ed52dc3 100644 --- a/arch/ppc/platforms/lite5200.c +++ b/arch/ppc/platforms/lite5200.c @@ -196,8 +196,10 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5, mpc52xx_set_bat(); /* No ISA bus by default */ +#ifdef CONFIG_PCI isa_io_base = 0; isa_mem_base = 0; +#endif /* Powersave */ /* This is provided as an example on how to do it. But you diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h index 84ac6e2..df9cf6e 100644 --- a/include/asm-ppc/io.h +++ b/include/asm-ppc/io.h @@ -27,6 +27,8 @@ #if defined(CONFIG_4xx) #include +#elif defined(CONFIG_PPC_MPC52xx) +#include #elif defined(CONFIG_8xx) #include #elif defined(CONFIG_8260) diff --git a/include/asm-ppc/mpc52xx.h b/include/asm-ppc/mpc52xx.h index 04d5630..a055e07 100644 --- a/include/asm-ppc/mpc52xx.h +++ b/include/asm-ppc/mpc52xx.h @@ -29,6 +29,17 @@ struct pt_regs; #endif /* __ASSEMBLY__ */ +#ifdef CONFIG_PCI +#define _IO_BASE isa_io_base +#define _ISA_MEM_BASE isa_mem_base +#define PCI_DRAM_OFFSET pci_dram_offset +#else +#define _IO_BASE 0 +#define _ISA_MEM_BASE 0 +#define PCI_DRAM_OFFSET 0 +#endif + + /* ======================================================================== */ /* PPC Sys devices definition */ /* ======================================================================== */ -- cgit v1.1 From 683e2cc6dc5aa9bb4ba2f2e0662df9d7f0a1d6c2 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Fri, 6 Jan 2006 00:11:39 -0800 Subject: [PATCH] ppc32: Re-add embed_config.c to ml300/ep405 Commit 3e9e7c1d0b7a36fb8affb973a054c5098e27baa8 (ppc32: cleanup AMCC PPC40x eval boards to support U-Boot) broke the kernel for ML300 / EP405. It still compiles as there's a weak definition of the function in misc-embedded.c, but the kernel crashes as the bd_t fixup isn't performed. Signed-off-by: Peter Korsgaard Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/ppc/boot/simple/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile index f3e9c53..9533f8d 100644 --- a/arch/ppc/boot/simple/Makefile +++ b/arch/ppc/boot/simple/Makefile @@ -190,6 +190,8 @@ boot-$(CONFIG_REDWOOD_5) += embed_config.o boot-$(CONFIG_REDWOOD_6) += embed_config.o boot-$(CONFIG_8xx) += embed_config.o boot-$(CONFIG_8260) += embed_config.o +boot-$(CONFIG_EP405) += embed_config.o +boot-$(CONFIG_XILINX_ML300) += embed_config.o boot-$(CONFIG_BSEIP) += iic.o boot-$(CONFIG_MBX) += iic.o pci.o qspan_pci.o boot-$(CONFIG_MV64X60) += misc-mv64x60.o -- cgit v1.1 From 9f6d4b0c21a6894dad7665d3dda4174c7c120784 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Fri, 6 Jan 2006 00:11:40 -0800 Subject: [PATCH] therm_adt746x: Quiet fan speed change messages Only output the messages about fan speed changes with a verbose=1 module param. Signed-off-by: Fabio M. Di Nitto Signed-off-by: Ben Collins Cc: Benjamin Herrenschmidt Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/macintosh/therm_adt746x.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index f386966..5e1f5e9 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c @@ -52,6 +52,7 @@ static char *sensor_location[3] = {NULL, NULL, NULL}; static int limit_adjust = 0; static int fan_speed = -1; +static int verbose = 0; MODULE_AUTHOR("Colin Leroy "); MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and " @@ -66,6 +67,10 @@ module_param(fan_speed, int, 0644); MODULE_PARM_DESC(fan_speed,"Specify starting fan speed (0-255) " "(default 64)"); +module_param(verbose, bool, 0); +MODULE_PARM_DESC(verbose,"Verbose log operations " + "(default 0)"); + struct thermostat { struct i2c_client clt; u8 temps[3]; @@ -149,13 +154,13 @@ detach_thermostat(struct i2c_adapter *adapter) if (thread_therm != NULL) { kthread_stop(thread_therm); } - + printk(KERN_INFO "adt746x: Putting max temperatures back from " "%d, %d, %d to %d, %d, %d\n", th->limits[0], th->limits[1], th->limits[2], th->initial_limits[0], th->initial_limits[1], th->initial_limits[2]); - + for (i = 0; i < 3; i++) write_reg(th, LIMIT_REG[i], th->initial_limits[i]); @@ -212,12 +217,14 @@ static void write_fan_speed(struct thermostat *th, int speed, int fan) return; if (th->last_speed[fan] != speed) { - if (speed == -1) - printk(KERN_DEBUG "adt746x: Setting speed to automatic " - "for %s fan.\n", sensor_location[fan+1]); - else - printk(KERN_DEBUG "adt746x: Setting speed to %d " - "for %s fan.\n", speed, sensor_location[fan+1]); + if (verbose) { + if (speed == -1) + printk(KERN_DEBUG "adt746x: Setting speed to automatic " + "for %s fan.\n", sensor_location[fan+1]); + else + printk(KERN_DEBUG "adt746x: Setting speed to %d " + "for %s fan.\n", speed, sensor_location[fan+1]); + } } else return; @@ -298,10 +305,11 @@ static void update_fans_speed (struct thermostat *th) if (new_speed > 255) new_speed = 255; - printk(KERN_DEBUG "adt746x: setting fans speed to %d " - "(limit exceeded by %d on %s) \n", - new_speed, var, - sensor_location[fan_number+1]); + if (verbose) + printk(KERN_DEBUG "adt746x: Setting fans speed to %d " + "(limit exceeded by %d on %s) \n", + new_speed, var, + sensor_location[fan_number+1]); write_both_fan_speed(th, new_speed); th->last_var[fan_number] = var; } else if (var < -2) { @@ -309,8 +317,9 @@ static void update_fans_speed (struct thermostat *th) * so cold (lastvar >= -1) */ if (i == 2 && lastvar < -1) { if (th->last_speed[fan_number] != 0) - printk(KERN_DEBUG "adt746x: Stopping " - "fans.\n"); + if (verbose) + printk(KERN_DEBUG "adt746x: Stopping " + "fans.\n"); write_both_fan_speed(th, 0); } } @@ -406,7 +415,7 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr, th->initial_limits[i] = read_reg(th, LIMIT_REG[i]); set_limit(th, i); } - + printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d" " to %d, %d, %d\n", th->initial_limits[0], th->initial_limits[1], -- cgit v1.1 From 642fb4d1f1dd2417aa69189fe5ceb81e4fb72900 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:41 -0800 Subject: [PATCH] NOMMU: Provide shared-writable mmap support on ramfs The attached patch makes ramfs support shared-writable mmaps by: (1) Attempting to perform a contiguous block allocation to the requested size when truncate attempts to increase the file from zero size, such as happens when: fd = shm_open("/file/on/ramfs", ...): ftruncate(fd, size_requested); addr = mmap(NULL, subsize, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED, fd, offset); (2) Permitting any shared-writable mapping over any contiguous set of extant pages. get_unmapped_area() will return the address into the actual ramfs pages. The mapping may start anywhere and be of any size, but may not go over the end of file. Multiple mappings may overlap in any way. (3) Not permitting a file to be shrunk if it would truncate any shared mappings (private mappings are copied). Thus this patch provides support for POSIX shared memory on NOMMU kernels, with certain limitations such as there being a large enough block of pages available to support the allocation and it only working on directly mappable filesystems. Signed-off-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/ramfs/Makefile | 4 +- fs/ramfs/file-mmu.c | 57 ++++++++++ fs/ramfs/file-nommu.c | 292 ++++++++++++++++++++++++++++++++++++++++++++++++++ fs/ramfs/inode.c | 22 +--- fs/ramfs/internal.h | 15 +++ include/linux/ramfs.h | 10 ++ 6 files changed, 378 insertions(+), 22 deletions(-) create mode 100644 fs/ramfs/file-mmu.c create mode 100644 fs/ramfs/file-nommu.c create mode 100644 fs/ramfs/internal.h diff --git a/fs/ramfs/Makefile b/fs/ramfs/Makefile index f096f30..5a0236e 100644 --- a/fs/ramfs/Makefile +++ b/fs/ramfs/Makefile @@ -4,4 +4,6 @@ obj-$(CONFIG_RAMFS) += ramfs.o -ramfs-objs := inode.o +file-mmu-y := file-nommu.o +file-mmu-$(CONFIG_MMU) := file-mmu.o +ramfs-objs += inode.o $(file-mmu-y) diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c new file mode 100644 index 0000000..2115383 --- /dev/null +++ b/fs/ramfs/file-mmu.c @@ -0,0 +1,57 @@ +/* file-mmu.c: ramfs MMU-based file operations + * + * Resizable simple ram filesystem for Linux. + * + * Copyright (C) 2000 Linus Torvalds. + * 2000 Transmeta Corp. + * + * Usage limits added by David Gibson, Linuxcare Australia. + * This file is released under the GPL. + */ + +/* + * NOTE! This filesystem is probably most useful + * not as a real filesystem, but as an example of + * how virtual filesystems can be written. + * + * It doesn't get much simpler than this. Consider + * that this file implements the full semantics of + * a POSIX-compliant read-write filesystem. + * + * Note in particular how the filesystem does not + * need to implement any data structures of its own + * to keep track of the virtual data: using the VFS + * caches is sufficient. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "internal.h" + +struct address_space_operations ramfs_aops = { + .readpage = simple_readpage, + .prepare_write = simple_prepare_write, + .commit_write = simple_commit_write +}; + +struct file_operations ramfs_file_operations = { + .read = generic_file_read, + .write = generic_file_write, + .mmap = generic_file_mmap, + .fsync = simple_sync_file, + .sendfile = generic_file_sendfile, + .llseek = generic_file_llseek, +}; + +struct inode_operations ramfs_file_inode_operations = { + .getattr = simple_getattr, +}; diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c new file mode 100644 index 0000000..3f810ac --- /dev/null +++ b/fs/ramfs/file-nommu.c @@ -0,0 +1,292 @@ +/* file-nommu.c: no-MMU version of ramfs + * + * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "internal.h" + +static int ramfs_nommu_setattr(struct dentry *, struct iattr *); + +struct address_space_operations ramfs_aops = { + .readpage = simple_readpage, + .prepare_write = simple_prepare_write, + .commit_write = simple_commit_write +}; + +struct file_operations ramfs_file_operations = { + .mmap = ramfs_nommu_mmap, + .get_unmapped_area = ramfs_nommu_get_unmapped_area, + .read = generic_file_read, + .write = generic_file_write, + .fsync = simple_sync_file, + .sendfile = generic_file_sendfile, + .llseek = generic_file_llseek, +}; + +struct inode_operations ramfs_file_inode_operations = { + .setattr = ramfs_nommu_setattr, + .getattr = simple_getattr, +}; + +/*****************************************************************************/ +/* + * add a contiguous set of pages into a ramfs inode when it's truncated from + * size 0 on the assumption that it's going to be used for an mmap of shared + * memory + */ +static int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) +{ + struct pagevec lru_pvec; + unsigned long npages, xpages, loop, limit; + struct page *pages; + unsigned order; + void *data; + int ret; + + /* make various checks */ + order = get_order(newsize); + if (unlikely(order >= MAX_ORDER)) + goto too_big; + + limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; + if (limit != RLIM_INFINITY && newsize > limit) + goto fsize_exceeded; + + if (newsize > inode->i_sb->s_maxbytes) + goto too_big; + + i_size_write(inode, newsize); + + /* allocate enough contiguous pages to be able to satisfy the + * request */ + pages = alloc_pages(mapping_gfp_mask(inode->i_mapping), order); + if (!pages) + return -ENOMEM; + + /* split the high-order page into an array of single pages */ + xpages = 1UL << order; + npages = (newsize + PAGE_SIZE - 1) >> PAGE_SHIFT; + + for (loop = 0; loop < npages; loop++) + set_page_count(pages + loop, 1); + + /* trim off any pages we don't actually require */ + for (loop = npages; loop < xpages; loop++) + __free_page(pages + loop); + + /* clear the memory we allocated */ + newsize = PAGE_SIZE * npages; + data = page_address(pages); + memset(data, 0, newsize); + + /* attach all the pages to the inode's address space */ + pagevec_init(&lru_pvec, 0); + for (loop = 0; loop < npages; loop++) { + struct page *page = pages + loop; + + ret = add_to_page_cache(page, inode->i_mapping, loop, GFP_KERNEL); + if (ret < 0) + goto add_error; + + if (!pagevec_add(&lru_pvec, page)) + __pagevec_lru_add(&lru_pvec); + + unlock_page(page); + } + + pagevec_lru_add(&lru_pvec); + return 0; + + fsize_exceeded: + send_sig(SIGXFSZ, current, 0); + too_big: + return -EFBIG; + + add_error: + page_cache_release(pages + loop); + for (loop++; loop < npages; loop++) + __free_page(pages + loop); + return ret; +} + +/*****************************************************************************/ +/* + * check that file shrinkage doesn't leave any VMAs dangling in midair + */ +static int ramfs_nommu_check_mappings(struct inode *inode, + size_t newsize, size_t size) +{ + struct vm_area_struct *vma; + struct prio_tree_iter iter; + + /* search for VMAs that fall within the dead zone */ + vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap, + newsize >> PAGE_SHIFT, + (size + PAGE_SIZE - 1) >> PAGE_SHIFT + ) { + /* found one - only interested if it's shared out of the page + * cache */ + if (vma->vm_flags & VM_SHARED) + return -ETXTBSY; /* not quite true, but near enough */ + } + + return 0; +} + +/*****************************************************************************/ +/* + * + */ +static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size) +{ + int ret; + + /* assume a truncate from zero size is going to be for the purposes of + * shared mmap */ + if (size == 0) { + if (unlikely(newsize >> 32)) + return -EFBIG; + + return ramfs_nommu_expand_for_mapping(inode, newsize); + } + + /* check that a decrease in size doesn't cut off any shared mappings */ + if (newsize < size) { + ret = ramfs_nommu_check_mappings(inode, newsize, size); + if (ret < 0) + return ret; + } + + ret = vmtruncate(inode, size); + + return ret; +} + +/*****************************************************************************/ +/* + * handle a change of attributes + * - we're specifically interested in a change of size + */ +static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia) +{ + struct inode *inode = dentry->d_inode; + unsigned int old_ia_valid = ia->ia_valid; + int ret = 0; + + /* by providing our own setattr() method, we skip this quotaism */ + if ((old_ia_valid & ATTR_UID && ia->ia_uid != inode->i_uid) || + (old_ia_valid & ATTR_GID && ia->ia_gid != inode->i_gid)) + ret = DQUOT_TRANSFER(inode, ia) ? -EDQUOT : 0; + + /* pick out size-changing events */ + if (ia->ia_valid & ATTR_SIZE) { + loff_t size = i_size_read(inode); + if (ia->ia_size != size) { + ret = ramfs_nommu_resize(inode, ia->ia_size, size); + if (ret < 0 || ia->ia_valid == ATTR_SIZE) + goto out; + } else { + /* we skipped the truncate but must still update + * timestamps + */ + ia->ia_valid |= ATTR_MTIME|ATTR_CTIME; + } + } + + ret = inode_setattr(inode, ia); + out: + ia->ia_valid = old_ia_valid; + return ret; +} + +/*****************************************************************************/ +/* + * try to determine where a shared mapping can be made + * - we require that: + * - the pages to be mapped must exist + * - the pages be physically contiguous in sequence + */ +unsigned long ramfs_nommu_get_unmapped_area(struct file *file, + unsigned long addr, unsigned long len, + unsigned long pgoff, unsigned long flags) +{ + unsigned long maxpages, lpages, nr, loop, ret; + struct inode *inode = file->f_dentry->d_inode; + struct page **pages = NULL, **ptr, *page; + loff_t isize; + + if (!(flags & MAP_SHARED)) + return addr; + + /* the mapping mustn't extend beyond the EOF */ + lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; + isize = i_size_read(inode); + + ret = -EINVAL; + maxpages = (isize + PAGE_SIZE - 1) >> PAGE_SHIFT; + if (pgoff >= maxpages) + goto out; + + if (maxpages - pgoff < lpages) + goto out; + + /* gang-find the pages */ + ret = -ENOMEM; + pages = kzalloc(lpages * sizeof(struct page *), GFP_KERNEL); + if (!pages) + goto out; + + nr = find_get_pages(inode->i_mapping, pgoff, lpages, pages); + if (nr != lpages) + goto out; /* leave if some pages were missing */ + + /* check the pages for physical adjacency */ + ptr = pages; + page = *ptr++; + page++; + for (loop = lpages; loop > 1; loop--) + if (*ptr++ != page++) + goto out; + + /* okay - all conditions fulfilled */ + ret = (unsigned long) page_address(pages[0]); + + out: + if (pages) { + ptr = pages; + for (loop = lpages; loop > 0; loop--) + put_page(*ptr++); + kfree(pages); + } + + return ret; +} + +/*****************************************************************************/ +/* + * set up a mapping + */ +int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma) +{ + return 0; +} diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c index 0a88917..c66bd5e 100644 --- a/fs/ramfs/inode.c +++ b/fs/ramfs/inode.c @@ -34,13 +34,12 @@ #include #include +#include "internal.h" /* some random number */ #define RAMFS_MAGIC 0x858458f6 static struct super_operations ramfs_ops; -static struct address_space_operations ramfs_aops; -static struct inode_operations ramfs_file_inode_operations; static struct inode_operations ramfs_dir_inode_operations; static struct backing_dev_info ramfs_backing_dev_info = { @@ -142,25 +141,6 @@ static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char * return error; } -static struct address_space_operations ramfs_aops = { - .readpage = simple_readpage, - .prepare_write = simple_prepare_write, - .commit_write = simple_commit_write -}; - -struct file_operations ramfs_file_operations = { - .read = generic_file_read, - .write = generic_file_write, - .mmap = generic_file_mmap, - .fsync = simple_sync_file, - .sendfile = generic_file_sendfile, - .llseek = generic_file_llseek, -}; - -static struct inode_operations ramfs_file_inode_operations = { - .getattr = simple_getattr, -}; - static struct inode_operations ramfs_dir_inode_operations = { .create = ramfs_create, .lookup = simple_lookup, diff --git a/fs/ramfs/internal.h b/fs/ramfs/internal.h new file mode 100644 index 0000000..272c8a7 --- /dev/null +++ b/fs/ramfs/internal.h @@ -0,0 +1,15 @@ +/* internal.h: ramfs internal definitions + * + * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + + +extern struct address_space_operations ramfs_aops; +extern struct file_operations ramfs_file_operations; +extern struct inode_operations ramfs_file_inode_operations; diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h index e0a4faa..953b6df 100644 --- a/include/linux/ramfs.h +++ b/include/linux/ramfs.h @@ -5,6 +5,16 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev); struct super_block *ramfs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data); +#ifndef CONFIG_MMU +extern unsigned long ramfs_nommu_get_unmapped_area(struct file *file, + unsigned long addr, + unsigned long len, + unsigned long pgoff, + unsigned long flags); + +extern int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma); +#endif + extern struct file_operations ramfs_file_operations; extern struct vm_operations_struct generic_file_vm_ops; -- cgit v1.1 From b0e15190ead07056ab0c3844a499ff35e66d27cc Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:42 -0800 Subject: [PATCH] NOMMU: Make SYSV IPC SHM use ramfs facilities on NOMMU The attached patch makes the SYSV IPC shared memory facilities use the new ramfs facilities on a no-MMU kernel. The following changes are made: (1) There are now shmem_mmap() and shmem_get_unmapped_area() functions to allow the IPC SHM facilities to commune with the tiny-shmem and shmem code. (2) ramfs files now need resizing using do_truncate() rather than by modifying the inode size directly (see shmem_file_setup()). This causes ramfs to attempt to bind a block of pages of sufficient size to the inode. (3) CONFIG_SYSVIPC is no longer contingent on CONFIG_MMU. Signed-off-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mm.h | 9 +++++++++ init/Kconfig | 1 - ipc/shm.c | 18 +++++++++++++----- mm/nommu.c | 7 +++++++ mm/shmem.c | 2 +- mm/tiny-shmem.c | 29 ++++++++++++++++++++++++++++- 6 files changed, 58 insertions(+), 8 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 75ec04e..26f3094 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -654,9 +654,18 @@ static inline struct mempolicy *shmem_get_policy(struct vm_area_struct *vma, } #endif struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags); +extern int shmem_mmap(struct file *file, struct vm_area_struct *vma); int shmem_zero_setup(struct vm_area_struct *); +#ifndef CONFIG_MMU +extern unsigned long shmem_get_unmapped_area(struct file *file, + unsigned long addr, + unsigned long len, + unsigned long pgoff, + unsigned long flags); +#endif + static inline int can_do_mlock(void) { if (capable(CAP_IPC_LOCK)) diff --git a/init/Kconfig b/init/Kconfig index ce737e0..24e0f7c7 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -105,7 +105,6 @@ config SWAP config SYSVIPC bool "System V IPC" - depends on MMU ---help--- Inter Process Communication is a suite of library functions and system calls which let processes (running programs) synchronize and diff --git a/ipc/shm.c b/ipc/shm.c index 587d836..0ef4a1c 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -157,14 +157,22 @@ static void shm_close (struct vm_area_struct *shmd) static int shm_mmap(struct file * file, struct vm_area_struct * vma) { - file_accessed(file); - vma->vm_ops = &shm_vm_ops; - shm_inc(file->f_dentry->d_inode->i_ino); - return 0; + int ret; + + ret = shmem_mmap(file, vma); + if (ret == 0) { + vma->vm_ops = &shm_vm_ops; + shm_inc(file->f_dentry->d_inode->i_ino); + } + + return ret; } static struct file_operations shm_file_operations = { - .mmap = shm_mmap + .mmap = shm_mmap, +#ifndef CONFIG_MMU + .get_unmapped_area = shmem_get_unmapped_area, +#endif }; static struct vm_operations_struct shm_vm_ops = { diff --git a/mm/nommu.c b/mm/nommu.c index c119681..c10262d 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -1177,3 +1177,10 @@ int in_gate_area_no_task(unsigned long addr) { return 0; } + +struct page *filemap_nopage(struct vm_area_struct *area, + unsigned long address, int *type) +{ + BUG(); + return NULL; +} diff --git a/mm/shmem.c b/mm/shmem.c index 65c148e..a1f2f02 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1270,7 +1270,7 @@ out_nomem: return retval; } -static int shmem_mmap(struct file *file, struct vm_area_struct *vma) +int shmem_mmap(struct file *file, struct vm_area_struct *vma) { file_accessed(file); vma->vm_ops = &shmem_vm_ops; diff --git a/mm/tiny-shmem.c b/mm/tiny-shmem.c index b58abcf..cdc6d43 100644 --- a/mm/tiny-shmem.c +++ b/mm/tiny-shmem.c @@ -81,13 +81,19 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags) goto close_file; d_instantiate(dentry, inode); - inode->i_size = size; inode->i_nlink = 0; /* It is unlinked */ + file->f_vfsmnt = mntget(shm_mnt); file->f_dentry = dentry; file->f_mapping = inode->i_mapping; file->f_op = &ramfs_file_operations; file->f_mode = FMODE_WRITE | FMODE_READ; + + /* notify everyone as to the change of file size */ + error = do_truncate(dentry, size, file); + if (error < 0) + goto close_file; + return file; close_file: @@ -123,3 +129,24 @@ int shmem_unuse(swp_entry_t entry, struct page *page) { return 0; } + +int shmem_mmap(struct file *file, struct vm_area_struct *vma) +{ + file_accessed(file); +#ifndef CONFIG_MMU + return ramfs_nommu_mmap(file, vma); +#else + return 0; +#endif +} + +#ifndef CONFIG_MMU +unsigned long shmem_get_unmapped_area(struct file *file, + unsigned long addr, + unsigned long len, + unsigned long pgoff, + unsigned long flags) +{ + return ramfs_nommu_get_unmapped_area(file, addr, len, pgoff, flags); +} +#endif -- cgit v1.1 From 5c40f7f373889930d176a515ec375b60a70b5b49 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:43 -0800 Subject: [PATCH] FRV: Implement futex operations for FRV The attached patch implements futex operations for the FRV architecture. The operations are applicable to both MMU and no-MMU modes; though the EFAULT handling will be a little bit of wasted space on the latter. Signed-off-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/frv/kernel/Makefile | 1 + arch/frv/kernel/futex.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++ include/asm-frv/futex.h | 42 +------- 3 files changed, 244 insertions(+), 41 deletions(-) create mode 100644 arch/frv/kernel/futex.c diff --git a/arch/frv/kernel/Makefile b/arch/frv/kernel/Makefile index 981c2c7..422f30e 100644 --- a/arch/frv/kernel/Makefile +++ b/arch/frv/kernel/Makefile @@ -20,3 +20,4 @@ obj-$(CONFIG_FUJITSU_MB93493) += irq-mb93493.o obj-$(CONFIG_PM) += pm.o cmode.o obj-$(CONFIG_MB93093_PDK) += pm-mb93093.o obj-$(CONFIG_SYSCTL) += sysctl.o +obj-$(CONFIG_FUTEX) += futex.o diff --git a/arch/frv/kernel/futex.c b/arch/frv/kernel/futex.c new file mode 100644 index 0000000..eae874a --- /dev/null +++ b/arch/frv/kernel/futex.c @@ -0,0 +1,242 @@ +/* futex.c: futex operations + * + * Copyright (C) 2005 Red Hat, Inc. All Rights Reserved. + * Written by David Howells (dhowells@redhat.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include +#include +#include + +/* + * the various futex operations; MMU fault checking is ignored under no-MMU + * conditions + */ +static inline int atomic_futex_op_xchg_set(int oparg, int __user *uaddr, int *_oldval) +{ + int oldval, ret; + + asm("0: \n" + " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ + " ckeq icc3,cc7 \n" + "1: ld.p %M0,%1 \n" /* LD.P/ORCR must be atomic */ + " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ + "2: cst.p %3,%M0 ,cc3,#1 \n" + " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* clear ICC3.Z if store happens */ + " beq icc3,#0,0b \n" + " setlos 0,%2 \n" + "3: \n" + ".subsection 2 \n" + "4: setlos %5,%2 \n" + " bra 3b \n" + ".previous \n" + ".section __ex_table,\"a\" \n" + " .balign 8 \n" + " .long 1b,4b \n" + " .long 2b,4b \n" + ".previous" + : "+U"(*uaddr), "=&r"(oldval), "=&r"(ret), "=r"(oparg) + : "3"(oparg), "i"(-EFAULT) + : "memory", "cc7", "cc3", "icc3" + ); + + *_oldval = oldval; + return ret; +} + +static inline int atomic_futex_op_xchg_add(int oparg, int __user *uaddr, int *_oldval) +{ + int oldval, ret; + + asm("0: \n" + " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ + " ckeq icc3,cc7 \n" + "1: ld.p %M0,%1 \n" /* LD.P/ORCR must be atomic */ + " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ + " add %1,%3,%3 \n" + "2: cst.p %3,%M0 ,cc3,#1 \n" + " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* clear ICC3.Z if store happens */ + " beq icc3,#0,0b \n" + " setlos 0,%2 \n" + "3: \n" + ".subsection 2 \n" + "4: setlos %5,%2 \n" + " bra 3b \n" + ".previous \n" + ".section __ex_table,\"a\" \n" + " .balign 8 \n" + " .long 1b,4b \n" + " .long 2b,4b \n" + ".previous" + : "+U"(*uaddr), "=&r"(oldval), "=&r"(ret), "=r"(oparg) + : "3"(oparg), "i"(-EFAULT) + : "memory", "cc7", "cc3", "icc3" + ); + + *_oldval = oldval; + return ret; +} + +static inline int atomic_futex_op_xchg_or(int oparg, int __user *uaddr, int *_oldval) +{ + int oldval, ret; + + asm("0: \n" + " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ + " ckeq icc3,cc7 \n" + "1: ld.p %M0,%1 \n" /* LD.P/ORCR must be atomic */ + " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ + " or %1,%3,%3 \n" + "2: cst.p %3,%M0 ,cc3,#1 \n" + " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* clear ICC3.Z if store happens */ + " beq icc3,#0,0b \n" + " setlos 0,%2 \n" + "3: \n" + ".subsection 2 \n" + "4: setlos %5,%2 \n" + " bra 3b \n" + ".previous \n" + ".section __ex_table,\"a\" \n" + " .balign 8 \n" + " .long 1b,4b \n" + " .long 2b,4b \n" + ".previous" + : "+U"(*uaddr), "=&r"(oldval), "=&r"(ret), "=r"(oparg) + : "3"(oparg), "i"(-EFAULT) + : "memory", "cc7", "cc3", "icc3" + ); + + *_oldval = oldval; + return ret; +} + +static inline int atomic_futex_op_xchg_and(int oparg, int __user *uaddr, int *_oldval) +{ + int oldval, ret; + + asm("0: \n" + " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ + " ckeq icc3,cc7 \n" + "1: ld.p %M0,%1 \n" /* LD.P/ORCR must be atomic */ + " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ + " and %1,%3,%3 \n" + "2: cst.p %3,%M0 ,cc3,#1 \n" + " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* clear ICC3.Z if store happens */ + " beq icc3,#0,0b \n" + " setlos 0,%2 \n" + "3: \n" + ".subsection 2 \n" + "4: setlos %5,%2 \n" + " bra 3b \n" + ".previous \n" + ".section __ex_table,\"a\" \n" + " .balign 8 \n" + " .long 1b,4b \n" + " .long 2b,4b \n" + ".previous" + : "+U"(*uaddr), "=&r"(oldval), "=&r"(ret), "=r"(oparg) + : "3"(oparg), "i"(-EFAULT) + : "memory", "cc7", "cc3", "icc3" + ); + + *_oldval = oldval; + return ret; +} + +static inline int atomic_futex_op_xchg_xor(int oparg, int __user *uaddr, int *_oldval) +{ + int oldval, ret; + + asm("0: \n" + " orcc gr0,gr0,gr0,icc3 \n" /* set ICC3.Z */ + " ckeq icc3,cc7 \n" + "1: ld.p %M0,%1 \n" /* LD.P/ORCR must be atomic */ + " orcr cc7,cc7,cc3 \n" /* set CC3 to true */ + " xor %1,%3,%3 \n" + "2: cst.p %3,%M0 ,cc3,#1 \n" + " corcc gr29,gr29,gr0 ,cc3,#1 \n" /* clear ICC3.Z if store happens */ + " beq icc3,#0,0b \n" + " setlos 0,%2 \n" + "3: \n" + ".subsection 2 \n" + "4: setlos %5,%2 \n" + " bra 3b \n" + ".previous \n" + ".section __ex_table,\"a\" \n" + " .balign 8 \n" + " .long 1b,4b \n" + " .long 2b,4b \n" + ".previous" + : "+U"(*uaddr), "=&r"(oldval), "=&r"(ret), "=r"(oparg) + : "3"(oparg), "i"(-EFAULT) + : "memory", "cc7", "cc3", "icc3" + ); + + *_oldval = oldval; + return ret; +} + +/*****************************************************************************/ +/* + * do the futex operations + */ +int futex_atomic_op_inuser(int encoded_op, int __user *uaddr) +{ + int op = (encoded_op >> 28) & 7; + int cmp = (encoded_op >> 24) & 15; + int oparg = (encoded_op << 8) >> 20; + int cmparg = (encoded_op << 20) >> 20; + int oldval = 0, ret; + + if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) + oparg = 1 << oparg; + + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) + return -EFAULT; + + inc_preempt_count(); + + switch (op) { + case FUTEX_OP_SET: + ret = atomic_futex_op_xchg_set(oparg, uaddr, &oldval); + break; + case FUTEX_OP_ADD: + ret = atomic_futex_op_xchg_add(oparg, uaddr, &oldval); + break; + case FUTEX_OP_OR: + ret = atomic_futex_op_xchg_or(oparg, uaddr, &oldval); + break; + case FUTEX_OP_ANDN: + ret = atomic_futex_op_xchg_and(~oparg, uaddr, &oldval); + break; + case FUTEX_OP_XOR: + ret = atomic_futex_op_xchg_xor(oparg, uaddr, &oldval); + break; + default: + ret = -ENOSYS; + break; + } + + dec_preempt_count(); + + if (!ret) { + switch (cmp) { + case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break; + case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break; + case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break; + case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break; + case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break; + case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break; + default: ret = -ENOSYS; break; + } + } + + return ret; + +} /* end futex_atomic_op_inuser() */ diff --git a/include/asm-frv/futex.h b/include/asm-frv/futex.h index 9feff4ce..fca9d90 100644 --- a/include/asm-frv/futex.h +++ b/include/asm-frv/futex.h @@ -7,47 +7,7 @@ #include #include -static inline int -futex_atomic_op_inuser (int encoded_op, int __user *uaddr) -{ - int op = (encoded_op >> 28) & 7; - int cmp = (encoded_op >> 24) & 15; - int oparg = (encoded_op << 8) >> 20; - int cmparg = (encoded_op << 20) >> 20; - int oldval = 0, ret; - if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) - oparg = 1 << oparg; - - if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) - return -EFAULT; - - inc_preempt_count(); - - switch (op) { - case FUTEX_OP_SET: - case FUTEX_OP_ADD: - case FUTEX_OP_OR: - case FUTEX_OP_ANDN: - case FUTEX_OP_XOR: - default: - ret = -ENOSYS; - } - - dec_preempt_count(); - - if (!ret) { - switch (cmp) { - case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break; - case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break; - case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break; - case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break; - case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break; - case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break; - default: ret = -ENOSYS; - } - } - return ret; -} +extern int futex_atomic_op_inuser(int encoded_op, int __user *uaddr); #endif #endif -- cgit v1.1 From 7ee1dd3fee22f15728f545d266403fc977e1eb99 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:44 -0800 Subject: [PATCH] FRV: Make futex code compilable on nommu [try #2] Make the futex code compilable and usable on NOMMU by making the attempt to handle page faults conditional on CONFIG_MMU. If this is not enabled, then we can assume that EFAULT returned from futex_atomic_op_inuser() is not recoverable, and that the address lies outside of valid memory. handle_mm_fault() is made to BUG if called on NOMMU without attempting to invoke the actual handler (__handle_mm_fault). Signed-off-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/mm.h | 22 +++++++++++++++++++--- kernel/futex.c | 7 +++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 26f3094..bc01fff 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -717,12 +717,28 @@ extern int vmtruncate(struct inode * inode, loff_t offset); extern int vmtruncate_range(struct inode * inode, loff_t offset, loff_t end); extern int install_page(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, struct page *page, pgprot_t prot); extern int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long addr, unsigned long pgoff, pgprot_t prot); -extern int __handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, unsigned long address, int write_access); -static inline int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, int write_access) +#ifdef CONFIG_MMU +extern int __handle_mm_fault(struct mm_struct *mm,struct vm_area_struct *vma, + unsigned long address, int write_access); + +static inline int handle_mm_fault(struct mm_struct *mm, + struct vm_area_struct *vma, unsigned long address, + int write_access) { - return __handle_mm_fault(mm, vma, address, write_access) & (~VM_FAULT_WRITE); + return __handle_mm_fault(mm, vma, address, write_access) & + (~VM_FAULT_WRITE); } +#else +static inline int handle_mm_fault(struct mm_struct *mm, + struct vm_area_struct *vma, unsigned long address, + int write_access) +{ + /* should never happen if there's no MMU */ + BUG(); + return VM_FAULT_SIGBUS; +} +#endif extern int make_pages_present(unsigned long addr, unsigned long end); extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write); diff --git a/kernel/futex.c b/kernel/futex.c index 5e71a6b..5efa2f9 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -356,6 +356,13 @@ retry: if (bh1 != bh2) spin_unlock(&bh2->lock); +#ifndef CONFIG_MMU + /* we don't get EFAULT from MMU faults if we don't have an MMU, + * but we might get them from range checking */ + ret = op_ret; + goto out; +#endif + if (unlikely(op_ret != -EFAULT)) { ret = op_ret; goto out; -- cgit v1.1 From 8efc0ab50edbac5c65191b8a58dfdab3741b7901 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:44 -0800 Subject: [PATCH] frv: fix signal handling The attached patch makes FRV signal handling work properly: (1) After do_notify_resume() has been called, the work flags must be checked again (there may be another signal to deliver or the process might require rescheduling for instance). (2) After the signal frame is set up on the userspace stack, ptrace() should be given an opportunity to single-step into the signal handler. (3) The error state from setting up a signal frame should be passed back up the call chain. (4) The segfault handler shouldn't be preemptively reset in the arch if we fail to deliver a SEGV signal: force_sig() will take care of that. Signed-off-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/frv/kernel/entry.S | 2 +- arch/frv/kernel/signal.c | 73 +++++++++++++++++++++++++++++------------------- 2 files changed, 46 insertions(+), 29 deletions(-) diff --git a/arch/frv/kernel/entry.S b/arch/frv/kernel/entry.S index ad10ea5..5f65483 100644 --- a/arch/frv/kernel/entry.S +++ b/arch/frv/kernel/entry.S @@ -1076,7 +1076,7 @@ __entry_work_notifysig: LEDS 0x6410 ori.p gr4,#0,gr8 call do_notify_resume - bra __entry_return_direct + bra __entry_resume_userspace # perform syscall entry tracing __syscall_trace_entry: diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c index d4ccc07..89a1cf5 100644 --- a/arch/frv/kernel/signal.c +++ b/arch/frv/kernel/signal.c @@ -297,7 +297,8 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, /* * */ -static void setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, struct pt_regs * regs) +static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, + struct pt_regs *regs) { struct sigframe __user *frame; int rsig; @@ -362,26 +363,30 @@ static void setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, struct p set_fs(USER_DS); + /* the tracer may want to single-step inside the handler */ + if (test_thread_flag(TIF_SINGLESTEP)) + ptrace_notify(SIGTRAP); + #if DEBUG_SIG printk("SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n", - sig, current->comm, current->pid, frame, regs->pc, frame->pretcode); + sig, current->comm, current->pid, frame, regs->pc, + frame->pretcode); #endif - return; + return 1; give_sigsegv: - if (sig == SIGSEGV) - ka->sa.sa_handler = SIG_DFL; - force_sig(SIGSEGV, current); + return 0; + } /* end setup_frame() */ /*****************************************************************************/ /* * */ -static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, - sigset_t *set, struct pt_regs * regs) +static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, + sigset_t *set, struct pt_regs * regs) { struct rt_sigframe __user *frame; int rsig; @@ -457,17 +462,21 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, set_fs(USER_DS); + /* the tracer may want to single-step inside the handler */ + if (test_thread_flag(TIF_SINGLESTEP)) + ptrace_notify(SIGTRAP); + #if DEBUG_SIG printk("SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n", - sig, current->comm, current->pid, frame, regs->pc, frame->pretcode); + sig, current->comm, current->pid, frame, regs->pc, + frame->pretcode); #endif - return; + return 1; give_sigsegv: - if (sig == SIGSEGV) - ka->sa.sa_handler = SIG_DFL; force_sig(SIGSEGV, current); + return 0; } /* end setup_rt_frame() */ @@ -475,10 +484,12 @@ give_sigsegv: /* * OK, we're invoking a handler */ -static void handle_signal(unsigned long sig, siginfo_t *info, - struct k_sigaction *ka, sigset_t *oldset, - struct pt_regs *regs) +static int handle_signal(unsigned long sig, siginfo_t *info, + struct k_sigaction *ka, sigset_t *oldset, + struct pt_regs *regs) { + int ret; + /* Are we from a system call? */ if (in_syscall(regs)) { /* If so, check system call restarting.. */ @@ -493,6 +504,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info, regs->gr8 = -EINTR; break; } + /* fallthrough */ case -ERESTARTNOINTR: regs->gr8 = regs->orig_gr8; @@ -502,16 +514,22 @@ static void handle_signal(unsigned long sig, siginfo_t *info, /* Set up the stack frame */ if (ka->sa.sa_flags & SA_SIGINFO) - setup_rt_frame(sig, ka, info, oldset, regs); + ret = setup_rt_frame(sig, ka, info, oldset, regs); else - setup_frame(sig, ka, oldset, regs); + ret = setup_frame(sig, ka, oldset, regs); + + if (ret) { + spin_lock_irq(¤t->sighand->siglock); + sigorsets(¤t->blocked, ¤t->blocked, + &ka->sa.sa_mask); + if (!(ka->sa.sa_flags & SA_NODEFER)) + sigaddset(¤t->blocked, sig); + recalc_sigpending(); + spin_unlock_irq(¤t->sighand->siglock); + } + + return ret; - spin_lock_irq(¤t->sighand->siglock); - sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask); - if (!(ka->sa.sa_flags & SA_NODEFER)) - sigaddset(¤t->blocked, sig); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); } /* end handle_signal() */ /*****************************************************************************/ @@ -542,12 +560,10 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) oldset = ¤t->blocked; signr = get_signal_to_deliver(&info, &ka, regs, NULL); - if (signr > 0) { - handle_signal(signr, &info, &ka, oldset, regs); - return 1; - } + if (signr > 0) + return handle_signal(signr, &info, &ka, oldset, regs); - no_signal: +no_signal: /* Did we come from a system call? */ if (regs->syscallno >= 0) { /* Restart the system call - no handlers present */ @@ -565,6 +581,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) } return 0; + } /* end do_signal() */ /*****************************************************************************/ -- cgit v1.1 From fef2b580eb50281ae1d2413ab340f677f6722281 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:45 -0800 Subject: [PATCH] frv: improve signal handling The attached patch improves the signal handling: (1) It makes do_signal() static as it isn't called from anywhere outside of the arch code. (2) It removes the regs argument to all the static functions within that file, using __frame instead (which is the same thing held in a global register). Signed-off-by: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/frv/kernel/signal.c | 102 +++++++++++++++++++++++------------------------ include/asm-frv/signal.h | 1 - 2 files changed, 50 insertions(+), 53 deletions(-) diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c index 89a1cf5..5b7146f 100644 --- a/arch/frv/kernel/signal.c +++ b/arch/frv/kernel/signal.c @@ -35,7 +35,7 @@ struct fdpic_func_descriptor { unsigned long GOT; }; -asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset); +static int do_signal(sigset_t *oldset); /* * Atomically swap in the new signal mask, and wait for a signal. @@ -55,7 +55,7 @@ asmlinkage int sys_sigsuspend(int history0, int history1, old_sigset_t mask) while (1) { current->state = TASK_INTERRUPTIBLE; schedule(); - if (do_signal(__frame, &saveset)) + if (do_signal(&saveset)) /* return the signal number as the return value of this function * - this is an utterly evil hack. syscalls should not invoke do_signal() * as entry.S sets regs->gr8 to the return value of the system call @@ -91,7 +91,7 @@ asmlinkage int sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize) while (1) { current->state = TASK_INTERRUPTIBLE; schedule(); - if (do_signal(__frame, &saveset)) + if (do_signal(&saveset)) /* return the signal number as the return value of this function * - this is an utterly evil hack. syscalls should not invoke do_signal() * as entry.S sets regs->gr8 to the return value of the system call @@ -276,13 +276,12 @@ static int setup_sigcontext(struct sigcontext __user *sc, unsigned long mask) * Determine which stack to use.. */ static inline void __user *get_sigframe(struct k_sigaction *ka, - struct pt_regs *regs, size_t frame_size) { unsigned long sp; /* Default to using normal stack */ - sp = regs->sp; + sp = __frame->sp; /* This is the X/Open sanctioned signal stack switching. */ if (ka->sa.sa_flags & SA_ONSTACK) { @@ -291,19 +290,19 @@ static inline void __user *get_sigframe(struct k_sigaction *ka, } return (void __user *) ((sp - frame_size) & ~7UL); + } /* end get_sigframe() */ /*****************************************************************************/ /* * */ -static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, - struct pt_regs *regs) +static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set) { struct sigframe __user *frame; int rsig; - frame = get_sigframe(ka, regs, sizeof(*frame)); + frame = get_sigframe(ka, sizeof(*frame)); if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) goto give_sigsegv; @@ -347,18 +346,18 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, } /* set up registers for signal handler */ - regs->sp = (unsigned long) frame; - regs->lr = (unsigned long) &frame->retcode; - regs->gr8 = sig; + __frame->sp = (unsigned long) frame; + __frame->lr = (unsigned long) &frame->retcode; + __frame->gr8 = sig; if (get_personality & FDPIC_FUNCPTRS) { struct fdpic_func_descriptor __user *funcptr = (struct fdpic_func_descriptor *) ka->sa.sa_handler; - __get_user(regs->pc, &funcptr->text); - __get_user(regs->gr15, &funcptr->GOT); + __get_user(__frame->pc, &funcptr->text); + __get_user(__frame->gr15, &funcptr->GOT); } else { - regs->pc = (unsigned long) ka->sa.sa_handler; - regs->gr15 = 0; + __frame->pc = (unsigned long) ka->sa.sa_handler; + __frame->gr15 = 0; } set_fs(USER_DS); @@ -369,7 +368,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, #if DEBUG_SIG printk("SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n", - sig, current->comm, current->pid, frame, regs->pc, + sig, current->comm, current->pid, frame, __frame->pc, frame->pretcode); #endif @@ -386,12 +385,12 @@ give_sigsegv: * */ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, - sigset_t *set, struct pt_regs * regs) + sigset_t *set) { struct rt_sigframe __user *frame; int rsig; - frame = get_sigframe(ka, regs, sizeof(*frame)); + frame = get_sigframe(ka, sizeof(*frame)); if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) goto give_sigsegv; @@ -414,7 +413,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, if (__put_user(0, &frame->uc.uc_flags) || __put_user(0, &frame->uc.uc_link) || __put_user((void*)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp) || - __put_user(sas_ss_flags(regs->sp), &frame->uc.uc_stack.ss_flags) || + __put_user(sas_ss_flags(__frame->sp), &frame->uc.uc_stack.ss_flags) || __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size)) goto give_sigsegv; @@ -445,19 +444,19 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, } /* Set up registers for signal handler */ - regs->sp = (unsigned long) frame; - regs->lr = (unsigned long) &frame->retcode; - regs->gr8 = sig; - regs->gr9 = (unsigned long) &frame->info; + __frame->sp = (unsigned long) frame; + __frame->lr = (unsigned long) &frame->retcode; + __frame->gr8 = sig; + __frame->gr9 = (unsigned long) &frame->info; if (get_personality & FDPIC_FUNCPTRS) { struct fdpic_func_descriptor *funcptr = (struct fdpic_func_descriptor __user *) ka->sa.sa_handler; - __get_user(regs->pc, &funcptr->text); - __get_user(regs->gr15, &funcptr->GOT); + __get_user(__frame->pc, &funcptr->text); + __get_user(__frame->gr15, &funcptr->GOT); } else { - regs->pc = (unsigned long) ka->sa.sa_handler; - regs->gr15 = 0; + __frame->pc = (unsigned long) ka->sa.sa_handler; + __frame->gr15 = 0; } set_fs(USER_DS); @@ -468,7 +467,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, #if DEBUG_SIG printk("SIG deliver %d (%s:%d): sp=%p pc=%lx ra=%p\n", - sig, current->comm, current->pid, frame, regs->pc, + sig, current->comm, current->pid, frame, __frame->pc, frame->pretcode); #endif @@ -485,38 +484,37 @@ give_sigsegv: * OK, we're invoking a handler */ static int handle_signal(unsigned long sig, siginfo_t *info, - struct k_sigaction *ka, sigset_t *oldset, - struct pt_regs *regs) + struct k_sigaction *ka, sigset_t *oldset) { int ret; /* Are we from a system call? */ - if (in_syscall(regs)) { + if (in_syscall(__frame)) { /* If so, check system call restarting.. */ - switch (regs->gr8) { + switch (__frame->gr8) { case -ERESTART_RESTARTBLOCK: case -ERESTARTNOHAND: - regs->gr8 = -EINTR; + __frame->gr8 = -EINTR; break; case -ERESTARTSYS: if (!(ka->sa.sa_flags & SA_RESTART)) { - regs->gr8 = -EINTR; + __frame->gr8 = -EINTR; break; } /* fallthrough */ case -ERESTARTNOINTR: - regs->gr8 = regs->orig_gr8; - regs->pc -= 4; + __frame->gr8 = __frame->orig_gr8; + __frame->pc -= 4; } } /* Set up the stack frame */ if (ka->sa.sa_flags & SA_SIGINFO) - ret = setup_rt_frame(sig, ka, info, oldset, regs); + ret = setup_rt_frame(sig, ka, info, oldset); else - ret = setup_frame(sig, ka, oldset, regs); + ret = setup_frame(sig, ka, oldset); if (ret) { spin_lock_irq(¤t->sighand->siglock); @@ -538,7 +536,7 @@ static int handle_signal(unsigned long sig, siginfo_t *info, * want to handle. Thus you cannot kill init even with a SIGKILL even by * mistake. */ -int do_signal(struct pt_regs *regs, sigset_t *oldset) +static int do_signal(sigset_t *oldset) { struct k_sigaction ka; siginfo_t info; @@ -550,7 +548,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) * kernel mode. Just return without doing anything * if so. */ - if (!user_mode(regs)) + if (!user_mode(__frame)) return 1; if (try_to_freeze()) @@ -559,24 +557,24 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) if (!oldset) oldset = ¤t->blocked; - signr = get_signal_to_deliver(&info, &ka, regs, NULL); + signr = get_signal_to_deliver(&info, &ka, __frame, NULL); if (signr > 0) - return handle_signal(signr, &info, &ka, oldset, regs); + return handle_signal(signr, &info, &ka, oldset); no_signal: /* Did we come from a system call? */ - if (regs->syscallno >= 0) { + if (__frame->syscallno >= 0) { /* Restart the system call - no handlers present */ - if (regs->gr8 == -ERESTARTNOHAND || - regs->gr8 == -ERESTARTSYS || - regs->gr8 == -ERESTARTNOINTR) { - regs->gr8 = regs->orig_gr8; - regs->pc -= 4; + if (__frame->gr8 == -ERESTARTNOHAND || + __frame->gr8 == -ERESTARTSYS || + __frame->gr8 == -ERESTARTNOINTR) { + __frame->gr8 = __frame->orig_gr8; + __frame->pc -= 4; } - if (regs->gr8 == -ERESTART_RESTARTBLOCK){ - regs->gr8 = __NR_restart_syscall; - regs->pc -= 4; + if (__frame->gr8 == -ERESTART_RESTARTBLOCK){ + __frame->gr8 = __NR_restart_syscall; + __frame->pc -= 4; } } @@ -597,6 +595,6 @@ asmlinkage void do_notify_resume(__u32 thread_info_flags) /* deal with pending signal delivery */ if (thread_info_flags & _TIF_SIGPENDING) - do_signal(__frame, NULL); + do_signal(NULL); } /* end do_notify_resume() */ diff --git a/include/asm-frv/signal.h b/include/asm-frv/signal.h index d407bde..6736689 100644 --- a/include/asm-frv/signal.h +++ b/include/asm-frv/signal.h @@ -151,7 +151,6 @@ typedef struct sigaltstack { size_t ss_size; } stack_t; -extern int do_signal(struct pt_regs *regs, sigset_t *oldset); #define ptrace_signal_deliver(regs, cookie) do { } while (0) #ifdef __KERNEL__ -- cgit v1.1 From 599a6e8ca4ff7f453f847217ecc2718d68e3b0f6 Mon Sep 17 00:00:00 2001 From: Domen Puncer Date: Fri, 6 Jan 2006 00:11:46 -0800 Subject: [PATCH] mips: remove include/asm-mips/riscos-syscall.h Remove nowhere referenced file ("grep riscos -r ." didn't find anything). Signed-off-by: Domen Puncer Signed-off-by: Alexey Dobriyan Acked-by: Ralf Baechle Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-mips/riscos-syscall.h | 979 -------------------------------------- 1 file changed, 979 deletions(-) delete mode 100644 include/asm-mips/riscos-syscall.h diff --git a/include/asm-mips/riscos-syscall.h b/include/asm-mips/riscos-syscall.h deleted file mode 100644 index 4d8eb15..0000000 --- a/include/asm-mips/riscos-syscall.h +++ /dev/null @@ -1,979 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 1995, 96, 97, 98, 99, 2000 by Ralf Baechle - */ -#ifndef _ASM_RISCOS_SYSCALL_H -#define _ASM_RISCOS_SYSCALL_H - -/* - * The syscalls 0 - 3999 are reserved for a down to the root syscall - * compatibility with RISC/os and IRIX. We'll see how to deal with the - * various "real" BSD variants like Ultrix, NetBSD ... - */ - -/* - * SVR4 syscalls are in the range from 1 to 999 - */ -#define __NR_SVR4 0 -#define __NR_SVR4_syscall (__NR_SVR4 + 0) -#define __NR_SVR4_exit (__NR_SVR4 + 1) -#define __NR_SVR4_fork (__NR_SVR4 + 2) -#define __NR_SVR4_read (__NR_SVR4 + 3) -#define __NR_SVR4_write (__NR_SVR4 + 4) -#define __NR_SVR4_open (__NR_SVR4 + 5) -#define __NR_SVR4_close (__NR_SVR4 + 6) -#define __NR_SVR4_wait (__NR_SVR4 + 7) -#define __NR_SVR4_creat (__NR_SVR4 + 8) -#define __NR_SVR4_link (__NR_SVR4 + 9) -#define __NR_SVR4_unlink (__NR_SVR4 + 10) -#define __NR_SVR4_exec (__NR_SVR4 + 11) -#define __NR_SVR4_chdir (__NR_SVR4 + 12) -#define __NR_SVR4_gtime (__NR_SVR4 + 13) -#define __NR_SVR4_mknod (__NR_SVR4 + 14) -#define __NR_SVR4_chmod (__NR_SVR4 + 15) -#define __NR_SVR4_chown (__NR_SVR4 + 16) -#define __NR_SVR4_sbreak (__NR_SVR4 + 17) -#define __NR_SVR4_stat (__NR_SVR4 + 18) -#define __NR_SVR4_lseek (__NR_SVR4 + 19) -#define __NR_SVR4_getpid (__NR_SVR4 + 20) -#define __NR_SVR4_mount (__NR_SVR4 + 21) -#define __NR_SVR4_umount (__NR_SVR4 + 22) -#define __NR_SVR4_setuid (__NR_SVR4 + 23) -#define __NR_SVR4_getuid (__NR_SVR4 + 24) -#define __NR_SVR4_stime (__NR_SVR4 + 25) -#define __NR_SVR4_ptrace (__NR_SVR4 + 26) -#define __NR_SVR4_alarm (__NR_SVR4 + 27) -#define __NR_SVR4_fstat (__NR_SVR4 + 28) -#define __NR_SVR4_pause (__NR_SVR4 + 29) -#define __NR_SVR4_utime (__NR_SVR4 + 30) -#define __NR_SVR4_stty (__NR_SVR4 + 31) -#define __NR_SVR4_gtty (__NR_SVR4 + 32) -#define __NR_SVR4_access (__NR_SVR4 + 33) -#define __NR_SVR4_nice (__NR_SVR4 + 34) -#define __NR_SVR4_statfs (__NR_SVR4 + 35) -#define __NR_SVR4_sync (__NR_SVR4 + 36) -#define __NR_SVR4_kill (__NR_SVR4 + 37) -#define __NR_SVR4_fstatfs (__NR_SVR4 + 38) -#define __NR_SVR4_setpgrp (__NR_SVR4 + 39) -#define __NR_SVR4_cxenix (__NR_SVR4 + 40) -#define __NR_SVR4_dup (__NR_SVR4 + 41) -#define __NR_SVR4_pipe (__NR_SVR4 + 42) -#define __NR_SVR4_times (__NR_SVR4 + 43) -#define __NR_SVR4_profil (__NR_SVR4 + 44) -#define __NR_SVR4_plock (__NR_SVR4 + 45) -#define __NR_SVR4_setgid (__NR_SVR4 + 46) -#define __NR_SVR4_getgid (__NR_SVR4 + 47) -#define __NR_SVR4_sig (__NR_SVR4 + 48) -#define __NR_SVR4_msgsys (__NR_SVR4 + 49) -#define __NR_SVR4_sysmips (__NR_SVR4 + 50) -#define __NR_SVR4_sysacct (__NR_SVR4 + 51) -#define __NR_SVR4_shmsys (__NR_SVR4 + 52) -#define __NR_SVR4_semsys (__NR_SVR4 + 53) -#define __NR_SVR4_ioctl (__NR_SVR4 + 54) -#define __NR_SVR4_uadmin (__NR_SVR4 + 55) -#define __NR_SVR4_exch (__NR_SVR4 + 56) -#define __NR_SVR4_utssys (__NR_SVR4 + 57) -#define __NR_SVR4_fsync (__NR_SVR4 + 58) -#define __NR_SVR4_exece (__NR_SVR4 + 59) -#define __NR_SVR4_umask (__NR_SVR4 + 60) -#define __NR_SVR4_chroot (__NR_SVR4 + 61) -#define __NR_SVR4_fcntl (__NR_SVR4 + 62) -#define __NR_SVR4_ulimit (__NR_SVR4 + 63) -#define __NR_SVR4_reserved1 (__NR_SVR4 + 64) -#define __NR_SVR4_reserved2 (__NR_SVR4 + 65) -#define __NR_SVR4_reserved3 (__NR_SVR4 + 66) -#define __NR_SVR4_reserved4 (__NR_SVR4 + 67) -#define __NR_SVR4_reserved5 (__NR_SVR4 + 68) -#define __NR_SVR4_reserved6 (__NR_SVR4 + 69) -#define __NR_SVR4_advfs (__NR_SVR4 + 70) -#define __NR_SVR4_unadvfs (__NR_SVR4 + 71) -#define __NR_SVR4_unused1 (__NR_SVR4 + 72) -#define __NR_SVR4_unused2 (__NR_SVR4 + 73) -#define __NR_SVR4_rfstart (__NR_SVR4 + 74) -#define __NR_SVR4_unused3 (__NR_SVR4 + 75) -#define __NR_SVR4_rdebug (__NR_SVR4 + 76) -#define __NR_SVR4_rfstop (__NR_SVR4 + 77) -#define __NR_SVR4_rfsys (__NR_SVR4 + 78) -#define __NR_SVR4_rmdir (__NR_SVR4 + 79) -#define __NR_SVR4_mkdir (__NR_SVR4 + 80) -#define __NR_SVR4_getdents (__NR_SVR4 + 81) -#define __NR_SVR4_libattach (__NR_SVR4 + 82) -#define __NR_SVR4_libdetach (__NR_SVR4 + 83) -#define __NR_SVR4_sysfs (__NR_SVR4 + 84) -#define __NR_SVR4_getmsg (__NR_SVR4 + 85) -#define __NR_SVR4_putmsg (__NR_SVR4 + 86) -#define __NR_SVR4_poll (__NR_SVR4 + 87) -#define __NR_SVR4_lstat (__NR_SVR4 + 88) -#define __NR_SVR4_symlink (__NR_SVR4 + 89) -#define __NR_SVR4_readlink (__NR_SVR4 + 90) -#define __NR_SVR4_setgroups (__NR_SVR4 + 91) -#define __NR_SVR4_getgroups (__NR_SVR4 + 92) -#define __NR_SVR4_fchmod (__NR_SVR4 + 93) -#define __NR_SVR4_fchown (__NR_SVR4 + 94) -#define __NR_SVR4_sigprocmask (__NR_SVR4 + 95) -#define __NR_SVR4_sigsuspend (__NR_SVR4 + 96) -#define __NR_SVR4_sigaltstack (__NR_SVR4 + 97) -#define __NR_SVR4_sigaction (__NR_SVR4 + 98) -#define __NR_SVR4_sigpending (__NR_SVR4 + 99) -#define __NR_SVR4_setcontext (__NR_SVR4 + 100) -#define __NR_SVR4_evsys (__NR_SVR4 + 101) -#define __NR_SVR4_evtrapret (__NR_SVR4 + 102) -#define __NR_SVR4_statvfs (__NR_SVR4 + 103) -#define __NR_SVR4_fstatvfs (__NR_SVR4 + 104) -#define __NR_SVR4_reserved7 (__NR_SVR4 + 105) -#define __NR_SVR4_nfssys (__NR_SVR4 + 106) -#define __NR_SVR4_waitid (__NR_SVR4 + 107) -#define __NR_SVR4_sigsendset (__NR_SVR4 + 108) -#define __NR_SVR4_hrtsys (__NR_SVR4 + 109) -#define __NR_SVR4_acancel (__NR_SVR4 + 110) -#define __NR_SVR4_async (__NR_SVR4 + 111) -#define __NR_SVR4_priocntlset (__NR_SVR4 + 112) -#define __NR_SVR4_pathconf (__NR_SVR4 + 113) -#define __NR_SVR4_mincore (__NR_SVR4 + 114) -#define __NR_SVR4_mmap (__NR_SVR4 + 115) -#define __NR_SVR4_mprotect (__NR_SVR4 + 116) -#define __NR_SVR4_munmap (__NR_SVR4 + 117) -#define __NR_SVR4_fpathconf (__NR_SVR4 + 118) -#define __NR_SVR4_vfork (__NR_SVR4 + 119) -#define __NR_SVR4_fchdir (__NR_SVR4 + 120) -#define __NR_SVR4_readv (__NR_SVR4 + 121) -#define __NR_SVR4_writev (__NR_SVR4 + 122) -#define __NR_SVR4_xstat (__NR_SVR4 + 123) -#define __NR_SVR4_lxstat (__NR_SVR4 + 124) -#define __NR_SVR4_fxstat (__NR_SVR4 + 125) -#define __NR_SVR4_xmknod (__NR_SVR4 + 126) -#define __NR_SVR4_clocal (__NR_SVR4 + 127) -#define __NR_SVR4_setrlimit (__NR_SVR4 + 128) -#define __NR_SVR4_getrlimit (__NR_SVR4 + 129) -#define __NR_SVR4_lchown (__NR_SVR4 + 130) -#define __NR_SVR4_memcntl (__NR_SVR4 + 131) -#define __NR_SVR4_getpmsg (__NR_SVR4 + 132) -#define __NR_SVR4_putpmsg (__NR_SVR4 + 133) -#define __NR_SVR4_rename (__NR_SVR4 + 134) -#define __NR_SVR4_nuname (__NR_SVR4 + 135) -#define __NR_SVR4_setegid (__NR_SVR4 + 136) -#define __NR_SVR4_sysconf (__NR_SVR4 + 137) -#define __NR_SVR4_adjtime (__NR_SVR4 + 138) -#define __NR_SVR4_sysinfo (__NR_SVR4 + 139) -#define __NR_SVR4_reserved8 (__NR_SVR4 + 140) -#define __NR_SVR4_seteuid (__NR_SVR4 + 141) -#define __NR_SVR4_PYRAMID_statis (__NR_SVR4 + 142) -#define __NR_SVR4_PYRAMID_tuning (__NR_SVR4 + 143) -#define __NR_SVR4_PYRAMID_forcerr (__NR_SVR4 + 144) -#define __NR_SVR4_PYRAMID_mpcntl (__NR_SVR4 + 145) -#define __NR_SVR4_reserved9 (__NR_SVR4 + 146) -#define __NR_SVR4_reserved10 (__NR_SVR4 + 147) -#define __NR_SVR4_reserved11 (__NR_SVR4 + 148) -#define __NR_SVR4_reserved12 (__NR_SVR4 + 149) -#define __NR_SVR4_reserved13 (__NR_SVR4 + 150) -#define __NR_SVR4_reserved14 (__NR_SVR4 + 151) -#define __NR_SVR4_reserved15 (__NR_SVR4 + 152) -#define __NR_SVR4_reserved16 (__NR_SVR4 + 153) -#define __NR_SVR4_reserved17 (__NR_SVR4 + 154) -#define __NR_SVR4_reserved18 (__NR_SVR4 + 155) -#define __NR_SVR4_reserved19 (__NR_SVR4 + 156) -#define __NR_SVR4_reserved20 (__NR_SVR4 + 157) -#define __NR_SVR4_reserved21 (__NR_SVR4 + 158) -#define __NR_SVR4_reserved22 (__NR_SVR4 + 159) -#define __NR_SVR4_reserved23 (__NR_SVR4 + 160) -#define __NR_SVR4_reserved24 (__NR_SVR4 + 161) -#define __NR_SVR4_reserved25 (__NR_SVR4 + 162) -#define __NR_SVR4_reserved26 (__NR_SVR4 + 163) -#define __NR_SVR4_reserved27 (__NR_SVR4 + 164) -#define __NR_SVR4_reserved28 (__NR_SVR4 + 165) -#define __NR_SVR4_reserved29 (__NR_SVR4 + 166) -#define __NR_SVR4_reserved30 (__NR_SVR4 + 167) -#define __NR_SVR4_reserved31 (__NR_SVR4 + 168) -#define __NR_SVR4_reserved32 (__NR_SVR4 + 169) -#define __NR_SVR4_reserved33 (__NR_SVR4 + 170) -#define __NR_SVR4_reserved34 (__NR_SVR4 + 171) -#define __NR_SVR4_reserved35 (__NR_SVR4 + 172) -#define __NR_SVR4_reserved36 (__NR_SVR4 + 173) -#define __NR_SVR4_reserved37 (__NR_SVR4 + 174) -#define __NR_SVR4_reserved38 (__NR_SVR4 + 175) -#define __NR_SVR4_reserved39 (__NR_SVR4 + 176) -#define __NR_SVR4_reserved40 (__NR_SVR4 + 177) -#define __NR_SVR4_reserved41 (__NR_SVR4 + 178) -#define __NR_SVR4_reserved42 (__NR_SVR4 + 179) -#define __NR_SVR4_reserved43 (__NR_SVR4 + 180) -#define __NR_SVR4_reserved44 (__NR_SVR4 + 181) -#define __NR_SVR4_reserved45 (__NR_SVR4 + 182) -#define __NR_SVR4_reserved46 (__NR_SVR4 + 183) -#define __NR_SVR4_reserved47 (__NR_SVR4 + 184) -#define __NR_SVR4_reserved48 (__NR_SVR4 + 185) -#define __NR_SVR4_reserved49 (__NR_SVR4 + 186) -#define __NR_SVR4_reserved50 (__NR_SVR4 + 187) -#define __NR_SVR4_reserved51 (__NR_SVR4 + 188) -#define __NR_SVR4_reserved52 (__NR_SVR4 + 189) -#define __NR_SVR4_reserved53 (__NR_SVR4 + 190) -#define __NR_SVR4_reserved54 (__NR_SVR4 + 191) -#define __NR_SVR4_reserved55 (__NR_SVR4 + 192) -#define __NR_SVR4_reserved56 (__NR_SVR4 + 193) -#define __NR_SVR4_reserved57 (__NR_SVR4 + 194) -#define __NR_SVR4_reserved58 (__NR_SVR4 + 195) -#define __NR_SVR4_reserved59 (__NR_SVR4 + 196) -#define __NR_SVR4_reserved60 (__NR_SVR4 + 197) -#define __NR_SVR4_reserved61 (__NR_SVR4 + 198) -#define __NR_SVR4_reserved62 (__NR_SVR4 + 199) -#define __NR_SVR4_reserved63 (__NR_SVR4 + 200) -#define __NR_SVR4_aread (__NR_SVR4 + 201) -#define __NR_SVR4_awrite (__NR_SVR4 + 202) -#define __NR_SVR4_listio (__NR_SVR4 + 203) -#define __NR_SVR4_mips_acancel (__NR_SVR4 + 204) -#define __NR_SVR4_astatus (__NR_SVR4 + 205) -#define __NR_SVR4_await (__NR_SVR4 + 206) -#define __NR_SVR4_areadv (__NR_SVR4 + 207) -#define __NR_SVR4_awritev (__NR_SVR4 + 208) -#define __NR_SVR4_MIPS_reserved1 (__NR_SVR4 + 209) -#define __NR_SVR4_MIPS_reserved2 (__NR_SVR4 + 210) -#define __NR_SVR4_MIPS_reserved3 (__NR_SVR4 + 211) -#define __NR_SVR4_MIPS_reserved4 (__NR_SVR4 + 212) -#define __NR_SVR4_MIPS_reserved5 (__NR_SVR4 + 213) -#define __NR_SVR4_MIPS_reserved6 (__NR_SVR4 + 214) -#define __NR_SVR4_MIPS_reserved7 (__NR_SVR4 + 215) -#define __NR_SVR4_MIPS_reserved8 (__NR_SVR4 + 216) -#define __NR_SVR4_MIPS_reserved9 (__NR_SVR4 + 217) -#define __NR_SVR4_MIPS_reserved10 (__NR_SVR4 + 218) -#define __NR_SVR4_MIPS_reserved11 (__NR_SVR4 + 219) -#define __NR_SVR4_MIPS_reserved12 (__NR_SVR4 + 220) -#define __NR_SVR4_CDC_reserved1 (__NR_SVR4 + 221) -#define __NR_SVR4_CDC_reserved2 (__NR_SVR4 + 222) -#define __NR_SVR4_CDC_reserved3 (__NR_SVR4 + 223) -#define __NR_SVR4_CDC_reserved4 (__NR_SVR4 + 224) -#define __NR_SVR4_CDC_reserved5 (__NR_SVR4 + 225) -#define __NR_SVR4_CDC_reserved6 (__NR_SVR4 + 226) -#define __NR_SVR4_CDC_reserved7 (__NR_SVR4 + 227) -#define __NR_SVR4_CDC_reserved8 (__NR_SVR4 + 228) -#define __NR_SVR4_CDC_reserved9 (__NR_SVR4 + 229) -#define __NR_SVR4_CDC_reserved10 (__NR_SVR4 + 230) -#define __NR_SVR4_CDC_reserved11 (__NR_SVR4 + 231) -#define __NR_SVR4_CDC_reserved12 (__NR_SVR4 + 232) -#define __NR_SVR4_CDC_reserved13 (__NR_SVR4 + 233) -#define __NR_SVR4_CDC_reserved14 (__NR_SVR4 + 234) -#define __NR_SVR4_CDC_reserved15 (__NR_SVR4 + 235) -#define __NR_SVR4_CDC_reserved16 (__NR_SVR4 + 236) -#define __NR_SVR4_CDC_reserved17 (__NR_SVR4 + 237) -#define __NR_SVR4_CDC_reserved18 (__NR_SVR4 + 238) -#define __NR_SVR4_CDC_reserved19 (__NR_SVR4 + 239) -#define __NR_SVR4_CDC_reserved20 (__NR_SVR4 + 240) - -/* - * SYS V syscalls are in the range from 1000 to 1999 - */ -#define __NR_SYSV 1000 -#define __NR_SYSV_syscall (__NR_SYSV + 0) -#define __NR_SYSV_exit (__NR_SYSV + 1) -#define __NR_SYSV_fork (__NR_SYSV + 2) -#define __NR_SYSV_read (__NR_SYSV + 3) -#define __NR_SYSV_write (__NR_SYSV + 4) -#define __NR_SYSV_open (__NR_SYSV + 5) -#define __NR_SYSV_close (__NR_SYSV + 6) -#define __NR_SYSV_wait (__NR_SYSV + 7) -#define __NR_SYSV_creat (__NR_SYSV + 8) -#define __NR_SYSV_link (__NR_SYSV + 9) -#define __NR_SYSV_unlink (__NR_SYSV + 10) -#define __NR_SYSV_execv (__NR_SYSV + 11) -#define __NR_SYSV_chdir (__NR_SYSV + 12) -#define __NR_SYSV_time (__NR_SYSV + 13) -#define __NR_SYSV_mknod (__NR_SYSV + 14) -#define __NR_SYSV_chmod (__NR_SYSV + 15) -#define __NR_SYSV_chown (__NR_SYSV + 16) -#define __NR_SYSV_brk (__NR_SYSV + 17) -#define __NR_SYSV_stat (__NR_SYSV + 18) -#define __NR_SYSV_lseek (__NR_SYSV + 19) -#define __NR_SYSV_getpid (__NR_SYSV + 20) -#define __NR_SYSV_mount (__NR_SYSV + 21) -#define __NR_SYSV_umount (__NR_SYSV + 22) -#define __NR_SYSV_setuid (__NR_SYSV + 23) -#define __NR_SYSV_getuid (__NR_SYSV + 24) -#define __NR_SYSV_stime (__NR_SYSV + 25) -#define __NR_SYSV_ptrace (__NR_SYSV + 26) -#define __NR_SYSV_alarm (__NR_SYSV + 27) -#define __NR_SYSV_fstat (__NR_SYSV + 28) -#define __NR_SYSV_pause (__NR_SYSV + 29) -#define __NR_SYSV_utime (__NR_SYSV + 30) -#define __NR_SYSV_stty (__NR_SYSV + 31) -#define __NR_SYSV_gtty (__NR_SYSV + 32) -#define __NR_SYSV_access (__NR_SYSV + 33) -#define __NR_SYSV_nice (__NR_SYSV + 34) -#define __NR_SYSV_statfs (__NR_SYSV + 35) -#define __NR_SYSV_sync (__NR_SYSV + 36) -#define __NR_SYSV_kill (__NR_SYSV + 37) -#define __NR_SYSV_fstatfs (__NR_SYSV + 38) -#define __NR_SYSV_setpgrp (__NR_SYSV + 39) -#define __NR_SYSV_syssgi (__NR_SYSV + 40) -#define __NR_SYSV_dup (__NR_SYSV + 41) -#define __NR_SYSV_pipe (__NR_SYSV + 42) -#define __NR_SYSV_times (__NR_SYSV + 43) -#define __NR_SYSV_profil (__NR_SYSV + 44) -#define __NR_SYSV_plock (__NR_SYSV + 45) -#define __NR_SYSV_setgid (__NR_SYSV + 46) -#define __NR_SYSV_getgid (__NR_SYSV + 47) -#define __NR_SYSV_sig (__NR_SYSV + 48) -#define __NR_SYSV_msgsys (__NR_SYSV + 49) -#define __NR_SYSV_sysmips (__NR_SYSV + 50) -#define __NR_SYSV_acct (__NR_SYSV + 51) -#define __NR_SYSV_shmsys (__NR_SYSV + 52) -#define __NR_SYSV_semsys (__NR_SYSV + 53) -#define __NR_SYSV_ioctl (__NR_SYSV + 54) -#define __NR_SYSV_uadmin (__NR_SYSV + 55) -#define __NR_SYSV_sysmp (__NR_SYSV + 56) -#define __NR_SYSV_utssys (__NR_SYSV + 57) -#define __NR_SYSV_USG_reserved1 (__NR_SYSV + 58) -#define __NR_SYSV_execve (__NR_SYSV + 59) -#define __NR_SYSV_umask (__NR_SYSV + 60) -#define __NR_SYSV_chroot (__NR_SYSV + 61) -#define __NR_SYSV_fcntl (__NR_SYSV + 62) -#define __NR_SYSV_ulimit (__NR_SYSV + 63) -#define __NR_SYSV_SAFARI4_reserved1 (__NR_SYSV + 64) -#define __NR_SYSV_SAFARI4_reserved2 (__NR_SYSV + 65) -#define __NR_SYSV_SAFARI4_reserved3 (__NR_SYSV + 66) -#define __NR_SYSV_SAFARI4_reserved4 (__NR_SYSV + 67) -#define __NR_SYSV_SAFARI4_reserved5 (__NR_SYSV + 68) -#define __NR_SYSV_SAFARI4_reserved6 (__NR_SYSV + 69) -#define __NR_SYSV_advfs (__NR_SYSV + 70) -#define __NR_SYSV_unadvfs (__NR_SYSV + 71) -#define __NR_SYSV_rmount (__NR_SYSV + 72) -#define __NR_SYSV_rumount (__NR_SYSV + 73) -#define __NR_SYSV_rfstart (__NR_SYSV + 74) -#define __NR_SYSV_getrlimit64 (__NR_SYSV + 75) -#define __NR_SYSV_setrlimit64 (__NR_SYSV + 76) -#define __NR_SYSV_nanosleep (__NR_SYSV + 77) -#define __NR_SYSV_lseek64 (__NR_SYSV + 78) -#define __NR_SYSV_rmdir (__NR_SYSV + 79) -#define __NR_SYSV_mkdir (__NR_SYSV + 80) -#define __NR_SYSV_getdents (__NR_SYSV + 81) -#define __NR_SYSV_sginap (__NR_SYSV + 82) -#define __NR_SYSV_sgikopt (__NR_SYSV + 83) -#define __NR_SYSV_sysfs (__NR_SYSV + 84) -#define __NR_SYSV_getmsg (__NR_SYSV + 85) -#define __NR_SYSV_putmsg (__NR_SYSV + 86) -#define __NR_SYSV_poll (__NR_SYSV + 87) -#define __NR_SYSV_sigreturn (__NR_SYSV + 88) -#define __NR_SYSV_accept (__NR_SYSV + 89) -#define __NR_SYSV_bind (__NR_SYSV + 90) -#define __NR_SYSV_connect (__NR_SYSV + 91) -#define __NR_SYSV_gethostid (__NR_SYSV + 92) -#define __NR_SYSV_getpeername (__NR_SYSV + 93) -#define __NR_SYSV_getsockname (__NR_SYSV + 94) -#define __NR_SYSV_getsockopt (__NR_SYSV + 95) -#define __NR_SYSV_listen (__NR_SYSV + 96) -#define __NR_SYSV_recv (__NR_SYSV + 97) -#define __NR_SYSV_recvfrom (__NR_SYSV + 98) -#define __NR_SYSV_recvmsg (__NR_SYSV + 99) -#define __NR_SYSV_select (__NR_SYSV + 100) -#define __NR_SYSV_send (__NR_SYSV + 101) -#define __NR_SYSV_sendmsg (__NR_SYSV + 102) -#define __NR_SYSV_sendto (__NR_SYSV + 103) -#define __NR_SYSV_sethostid (__NR_SYSV + 104) -#define __NR_SYSV_setsockopt (__NR_SYSV + 105) -#define __NR_SYSV_shutdown (__NR_SYSV + 106) -#define __NR_SYSV_socket (__NR_SYSV + 107) -#define __NR_SYSV_gethostname (__NR_SYSV + 108) -#define __NR_SYSV_sethostname (__NR_SYSV + 109) -#define __NR_SYSV_getdomainname (__NR_SYSV + 110) -#define __NR_SYSV_setdomainname (__NR_SYSV + 111) -#define __NR_SYSV_truncate (__NR_SYSV + 112) -#define __NR_SYSV_ftruncate (__NR_SYSV + 113) -#define __NR_SYSV_rename (__NR_SYSV + 114) -#define __NR_SYSV_symlink (__NR_SYSV + 115) -#define __NR_SYSV_readlink (__NR_SYSV + 116) -#define __NR_SYSV_lstat (__NR_SYSV + 117) -#define __NR_SYSV_nfsmount (__NR_SYSV + 118) -#define __NR_SYSV_nfssvc (__NR_SYSV + 119) -#define __NR_SYSV_getfh (__NR_SYSV + 120) -#define __NR_SYSV_async_daemon (__NR_SYSV + 121) -#define __NR_SYSV_exportfs (__NR_SYSV + 122) -#define __NR_SYSV_setregid (__NR_SYSV + 123) -#define __NR_SYSV_setreuid (__NR_SYSV + 124) -#define __NR_SYSV_getitimer (__NR_SYSV + 125) -#define __NR_SYSV_setitimer (__NR_SYSV + 126) -#define __NR_SYSV_adjtime (__NR_SYSV + 127) -#define __NR_SYSV_BSD_getime (__NR_SYSV + 128) -#define __NR_SYSV_sproc (__NR_SYSV + 129) -#define __NR_SYSV_prctl (__NR_SYSV + 130) -#define __NR_SYSV_procblk (__NR_SYSV + 131) -#define __NR_SYSV_sprocsp (__NR_SYSV + 132) -#define __NR_SYSV_sgigsc (__NR_SYSV + 133) -#define __NR_SYSV_mmap (__NR_SYSV + 134) -#define __NR_SYSV_munmap (__NR_SYSV + 135) -#define __NR_SYSV_mprotect (__NR_SYSV + 136) -#define __NR_SYSV_msync (__NR_SYSV + 137) -#define __NR_SYSV_madvise (__NR_SYSV + 138) -#define __NR_SYSV_pagelock (__NR_SYSV + 139) -#define __NR_SYSV_getpagesize (__NR_SYSV + 140) -#define __NR_SYSV_quotactl (__NR_SYSV + 141) -#define __NR_SYSV_libdetach (__NR_SYSV + 142) -#define __NR_SYSV_BSDgetpgrp (__NR_SYSV + 143) -#define __NR_SYSV_BSDsetpgrp (__NR_SYSV + 144) -#define __NR_SYSV_vhangup (__NR_SYSV + 145) -#define __NR_SYSV_fsync (__NR_SYSV + 146) -#define __NR_SYSV_fchdir (__NR_SYSV + 147) -#define __NR_SYSV_getrlimit (__NR_SYSV + 148) -#define __NR_SYSV_setrlimit (__NR_SYSV + 149) -#define __NR_SYSV_cacheflush (__NR_SYSV + 150) -#define __NR_SYSV_cachectl (__NR_SYSV + 151) -#define __NR_SYSV_fchown (__NR_SYSV + 152) -#define __NR_SYSV_fchmod (__NR_SYSV + 153) -#define __NR_SYSV_wait3 (__NR_SYSV + 154) -#define __NR_SYSV_socketpair (__NR_SYSV + 155) -#define __NR_SYSV_sysinfo (__NR_SYSV + 156) -#define __NR_SYSV_nuname (__NR_SYSV + 157) -#define __NR_SYSV_xstat (__NR_SYSV + 158) -#define __NR_SYSV_lxstat (__NR_SYSV + 159) -#define __NR_SYSV_fxstat (__NR_SYSV + 160) -#define __NR_SYSV_xmknod (__NR_SYSV + 161) -#define __NR_SYSV_ksigaction (__NR_SYSV + 162) -#define __NR_SYSV_sigpending (__NR_SYSV + 163) -#define __NR_SYSV_sigprocmask (__NR_SYSV + 164) -#define __NR_SYSV_sigsuspend (__NR_SYSV + 165) -#define __NR_SYSV_sigpoll (__NR_SYSV + 166) -#define __NR_SYSV_swapctl (__NR_SYSV + 167) -#define __NR_SYSV_getcontext (__NR_SYSV + 168) -#define __NR_SYSV_setcontext (__NR_SYSV + 169) -#define __NR_SYSV_waitsys (__NR_SYSV + 170) -#define __NR_SYSV_sigstack (__NR_SYSV + 171) -#define __NR_SYSV_sigaltstack (__NR_SYSV + 172) -#define __NR_SYSV_sigsendset (__NR_SYSV + 173) -#define __NR_SYSV_statvfs (__NR_SYSV + 174) -#define __NR_SYSV_fstatvfs (__NR_SYSV + 175) -#define __NR_SYSV_getpmsg (__NR_SYSV + 176) -#define __NR_SYSV_putpmsg (__NR_SYSV + 177) -#define __NR_SYSV_lchown (__NR_SYSV + 178) -#define __NR_SYSV_priocntl (__NR_SYSV + 179) -#define __NR_SYSV_ksigqueue (__NR_SYSV + 180) -#define __NR_SYSV_readv (__NR_SYSV + 181) -#define __NR_SYSV_writev (__NR_SYSV + 182) -#define __NR_SYSV_truncate64 (__NR_SYSV + 183) -#define __NR_SYSV_ftruncate64 (__NR_SYSV + 184) -#define __NR_SYSV_mmap64 (__NR_SYSV + 185) -#define __NR_SYSV_dmi (__NR_SYSV + 186) -#define __NR_SYSV_pread (__NR_SYSV + 187) -#define __NR_SYSV_pwrite (__NR_SYSV + 188) - -/* - * BSD 4.3 syscalls are in the range from 2000 to 2999 - */ -#define __NR_BSD43 2000 -#define __NR_BSD43_syscall (__NR_BSD43 + 0) -#define __NR_BSD43_exit (__NR_BSD43 + 1) -#define __NR_BSD43_fork (__NR_BSD43 + 2) -#define __NR_BSD43_read (__NR_BSD43 + 3) -#define __NR_BSD43_write (__NR_BSD43 + 4) -#define __NR_BSD43_open (__NR_BSD43 + 5) -#define __NR_BSD43_close (__NR_BSD43 + 6) -#define __NR_BSD43_wait (__NR_BSD43 + 7) -#define __NR_BSD43_creat (__NR_BSD43 + 8) -#define __NR_BSD43_link (__NR_BSD43 + 9) -#define __NR_BSD43_unlink (__NR_BSD43 + 10) -#define __NR_BSD43_exec (__NR_BSD43 + 11) -#define __NR_BSD43_chdir (__NR_BSD43 + 12) -#define __NR_BSD43_time (__NR_BSD43 + 13) -#define __NR_BSD43_mknod (__NR_BSD43 + 14) -#define __NR_BSD43_chmod (__NR_BSD43 + 15) -#define __NR_BSD43_chown (__NR_BSD43 + 16) -#define __NR_BSD43_sbreak (__NR_BSD43 + 17) -#define __NR_BSD43_oldstat (__NR_BSD43 + 18) -#define __NR_BSD43_lseek (__NR_BSD43 + 19) -#define __NR_BSD43_getpid (__NR_BSD43 + 20) -#define __NR_BSD43_oldmount (__NR_BSD43 + 21) -#define __NR_BSD43_umount (__NR_BSD43 + 22) -#define __NR_BSD43_setuid (__NR_BSD43 + 23) -#define __NR_BSD43_getuid (__NR_BSD43 + 24) -#define __NR_BSD43_stime (__NR_BSD43 + 25) -#define __NR_BSD43_ptrace (__NR_BSD43 + 26) -#define __NR_BSD43_alarm (__NR_BSD43 + 27) -#define __NR_BSD43_oldfstat (__NR_BSD43 + 28) -#define __NR_BSD43_pause (__NR_BSD43 + 29) -#define __NR_BSD43_utime (__NR_BSD43 + 30) -#define __NR_BSD43_stty (__NR_BSD43 + 31) -#define __NR_BSD43_gtty (__NR_BSD43 + 32) -#define __NR_BSD43_access (__NR_BSD43 + 33) -#define __NR_BSD43_nice (__NR_BSD43 + 34) -#define __NR_BSD43_ftime (__NR_BSD43 + 35) -#define __NR_BSD43_sync (__NR_BSD43 + 36) -#define __NR_BSD43_kill (__NR_BSD43 + 37) -#define __NR_BSD43_stat (__NR_BSD43 + 38) -#define __NR_BSD43_oldsetpgrp (__NR_BSD43 + 39) -#define __NR_BSD43_lstat (__NR_BSD43 + 40) -#define __NR_BSD43_dup (__NR_BSD43 + 41) -#define __NR_BSD43_pipe (__NR_BSD43 + 42) -#define __NR_BSD43_times (__NR_BSD43 + 43) -#define __NR_BSD43_profil (__NR_BSD43 + 44) -#define __NR_BSD43_msgsys (__NR_BSD43 + 45) -#define __NR_BSD43_setgid (__NR_BSD43 + 46) -#define __NR_BSD43_getgid (__NR_BSD43 + 47) -#define __NR_BSD43_ssig (__NR_BSD43 + 48) -#define __NR_BSD43_reserved1 (__NR_BSD43 + 49) -#define __NR_BSD43_reserved2 (__NR_BSD43 + 50) -#define __NR_BSD43_sysacct (__NR_BSD43 + 51) -#define __NR_BSD43_phys (__NR_BSD43 + 52) -#define __NR_BSD43_lock (__NR_BSD43 + 53) -#define __NR_BSD43_ioctl (__NR_BSD43 + 54) -#define __NR_BSD43_reboot (__NR_BSD43 + 55) -#define __NR_BSD43_mpxchan (__NR_BSD43 + 56) -#define __NR_BSD43_symlink (__NR_BSD43 + 57) -#define __NR_BSD43_readlink (__NR_BSD43 + 58) -#define __NR_BSD43_execve (__NR_BSD43 + 59) -#define __NR_BSD43_umask (__NR_BSD43 + 60) -#define __NR_BSD43_chroot (__NR_BSD43 + 61) -#define __NR_BSD43_fstat (__NR_BSD43 + 62) -#define __NR_BSD43_reserved3 (__NR_BSD43 + 63) -#define __NR_BSD43_getpagesize (__NR_BSD43 + 64) -#define __NR_BSD43_mremap (__NR_BSD43 + 65) -#define __NR_BSD43_vfork (__NR_BSD43 + 66) -#define __NR_BSD43_vread (__NR_BSD43 + 67) -#define __NR_BSD43_vwrite (__NR_BSD43 + 68) -#define __NR_BSD43_sbrk (__NR_BSD43 + 69) -#define __NR_BSD43_sstk (__NR_BSD43 + 70) -#define __NR_BSD43_mmap (__NR_BSD43 + 71) -#define __NR_BSD43_vadvise (__NR_BSD43 + 72) -#define __NR_BSD43_munmap (__NR_BSD43 + 73) -#define __NR_BSD43_mprotect (__NR_BSD43 + 74) -#define __NR_BSD43_madvise (__NR_BSD43 + 75) -#define __NR_BSD43_vhangup (__NR_BSD43 + 76) -#define __NR_BSD43_vlimit (__NR_BSD43 + 77) -#define __NR_BSD43_mincore (__NR_BSD43 + 78) -#define __NR_BSD43_getgroups (__NR_BSD43 + 79) -#define __NR_BSD43_setgroups (__NR_BSD43 + 80) -#define __NR_BSD43_getpgrp (__NR_BSD43 + 81) -#define __NR_BSD43_setpgrp (__NR_BSD43 + 82) -#define __NR_BSD43_setitimer (__NR_BSD43 + 83) -#define __NR_BSD43_wait3 (__NR_BSD43 + 84) -#define __NR_BSD43_swapon (__NR_BSD43 + 85) -#define __NR_BSD43_getitimer (__NR_BSD43 + 86) -#define __NR_BSD43_gethostname (__NR_BSD43 + 87) -#define __NR_BSD43_sethostname (__NR_BSD43 + 88) -#define __NR_BSD43_getdtablesize (__NR_BSD43 + 89) -#define __NR_BSD43_dup2 (__NR_BSD43 + 90) -#define __NR_BSD43_getdopt (__NR_BSD43 + 91) -#define __NR_BSD43_fcntl (__NR_BSD43 + 92) -#define __NR_BSD43_select (__NR_BSD43 + 93) -#define __NR_BSD43_setdopt (__NR_BSD43 + 94) -#define __NR_BSD43_fsync (__NR_BSD43 + 95) -#define __NR_BSD43_setpriority (__NR_BSD43 + 96) -#define __NR_BSD43_socket (__NR_BSD43 + 97) -#define __NR_BSD43_connect (__NR_BSD43 + 98) -#define __NR_BSD43_oldaccept (__NR_BSD43 + 99) -#define __NR_BSD43_getpriority (__NR_BSD43 + 100) -#define __NR_BSD43_send (__NR_BSD43 + 101) -#define __NR_BSD43_recv (__NR_BSD43 + 102) -#define __NR_BSD43_sigreturn (__NR_BSD43 + 103) -#define __NR_BSD43_bind (__NR_BSD43 + 104) -#define __NR_BSD43_setsockopt (__NR_BSD43 + 105) -#define __NR_BSD43_listen (__NR_BSD43 + 106) -#define __NR_BSD43_vtimes (__NR_BSD43 + 107) -#define __NR_BSD43_sigvec (__NR_BSD43 + 108) -#define __NR_BSD43_sigblock (__NR_BSD43 + 109) -#define __NR_BSD43_sigsetmask (__NR_BSD43 + 110) -#define __NR_BSD43_sigpause (__NR_BSD43 + 111) -#define __NR_BSD43_sigstack (__NR_BSD43 + 112) -#define __NR_BSD43_oldrecvmsg (__NR_BSD43 + 113) -#define __NR_BSD43_oldsendmsg (__NR_BSD43 + 114) -#define __NR_BSD43_vtrace (__NR_BSD43 + 115) -#define __NR_BSD43_gettimeofday (__NR_BSD43 + 116) -#define __NR_BSD43_getrusage (__NR_BSD43 + 117) -#define __NR_BSD43_getsockopt (__NR_BSD43 + 118) -#define __NR_BSD43_reserved4 (__NR_BSD43 + 119) -#define __NR_BSD43_readv (__NR_BSD43 + 120) -#define __NR_BSD43_writev (__NR_BSD43 + 121) -#define __NR_BSD43_settimeofday (__NR_BSD43 + 122) -#define __NR_BSD43_fchown (__NR_BSD43 + 123) -#define __NR_BSD43_fchmod (__NR_BSD43 + 124) -#define __NR_BSD43_oldrecvfrom (__NR_BSD43 + 125) -#define __NR_BSD43_setreuid (__NR_BSD43 + 126) -#define __NR_BSD43_setregid (__NR_BSD43 + 127) -#define __NR_BSD43_rename (__NR_BSD43 + 128) -#define __NR_BSD43_truncate (__NR_BSD43 + 129) -#define __NR_BSD43_ftruncate (__NR_BSD43 + 130) -#define __NR_BSD43_flock (__NR_BSD43 + 131) -#define __NR_BSD43_semsys (__NR_BSD43 + 132) -#define __NR_BSD43_sendto (__NR_BSD43 + 133) -#define __NR_BSD43_shutdown (__NR_BSD43 + 134) -#define __NR_BSD43_socketpair (__NR_BSD43 + 135) -#define __NR_BSD43_mkdir (__NR_BSD43 + 136) -#define __NR_BSD43_rmdir (__NR_BSD43 + 137) -#define __NR_BSD43_utimes (__NR_BSD43 + 138) -#define __NR_BSD43_sigcleanup (__NR_BSD43 + 139) -#define __NR_BSD43_adjtime (__NR_BSD43 + 140) -#define __NR_BSD43_oldgetpeername (__NR_BSD43 + 141) -#define __NR_BSD43_gethostid (__NR_BSD43 + 142) -#define __NR_BSD43_sethostid (__NR_BSD43 + 143) -#define __NR_BSD43_getrlimit (__NR_BSD43 + 144) -#define __NR_BSD43_setrlimit (__NR_BSD43 + 145) -#define __NR_BSD43_killpg (__NR_BSD43 + 146) -#define __NR_BSD43_shmsys (__NR_BSD43 + 147) -#define __NR_BSD43_quota (__NR_BSD43 + 148) -#define __NR_BSD43_qquota (__NR_BSD43 + 149) -#define __NR_BSD43_oldgetsockname (__NR_BSD43 + 150) -#define __NR_BSD43_sysmips (__NR_BSD43 + 151) -#define __NR_BSD43_cacheflush (__NR_BSD43 + 152) -#define __NR_BSD43_cachectl (__NR_BSD43 + 153) -#define __NR_BSD43_debug (__NR_BSD43 + 154) -#define __NR_BSD43_reserved5 (__NR_BSD43 + 155) -#define __NR_BSD43_reserved6 (__NR_BSD43 + 156) -#define __NR_BSD43_nfs_mount (__NR_BSD43 + 157) -#define __NR_BSD43_nfs_svc (__NR_BSD43 + 158) -#define __NR_BSD43_getdirentries (__NR_BSD43 + 159) -#define __NR_BSD43_statfs (__NR_BSD43 + 160) -#define __NR_BSD43_fstatfs (__NR_BSD43 + 161) -#define __NR_BSD43_unmount (__NR_BSD43 + 162) -#define __NR_BSD43_async_daemon (__NR_BSD43 + 163) -#define __NR_BSD43_nfs_getfh (__NR_BSD43 + 164) -#define __NR_BSD43_getdomainname (__NR_BSD43 + 165) -#define __NR_BSD43_setdomainname (__NR_BSD43 + 166) -#define __NR_BSD43_pcfs_mount (__NR_BSD43 + 167) -#define __NR_BSD43_quotactl (__NR_BSD43 + 168) -#define __NR_BSD43_oldexportfs (__NR_BSD43 + 169) -#define __NR_BSD43_smount (__NR_BSD43 + 170) -#define __NR_BSD43_mipshwconf (__NR_BSD43 + 171) -#define __NR_BSD43_exportfs (__NR_BSD43 + 172) -#define __NR_BSD43_nfsfh_open (__NR_BSD43 + 173) -#define __NR_BSD43_libattach (__NR_BSD43 + 174) -#define __NR_BSD43_libdetach (__NR_BSD43 + 175) -#define __NR_BSD43_accept (__NR_BSD43 + 176) -#define __NR_BSD43_reserved7 (__NR_BSD43 + 177) -#define __NR_BSD43_reserved8 (__NR_BSD43 + 178) -#define __NR_BSD43_recvmsg (__NR_BSD43 + 179) -#define __NR_BSD43_recvfrom (__NR_BSD43 + 180) -#define __NR_BSD43_sendmsg (__NR_BSD43 + 181) -#define __NR_BSD43_getpeername (__NR_BSD43 + 182) -#define __NR_BSD43_getsockname (__NR_BSD43 + 183) -#define __NR_BSD43_aread (__NR_BSD43 + 184) -#define __NR_BSD43_awrite (__NR_BSD43 + 185) -#define __NR_BSD43_listio (__NR_BSD43 + 186) -#define __NR_BSD43_acancel (__NR_BSD43 + 187) -#define __NR_BSD43_astatus (__NR_BSD43 + 188) -#define __NR_BSD43_await (__NR_BSD43 + 189) -#define __NR_BSD43_areadv (__NR_BSD43 + 190) -#define __NR_BSD43_awritev (__NR_BSD43 + 191) - -/* - * POSIX syscalls are in the range from 3000 to 3999 - */ -#define __NR_POSIX 3000 -#define __NR_POSIX_syscall (__NR_POSIX + 0) -#define __NR_POSIX_exit (__NR_POSIX + 1) -#define __NR_POSIX_fork (__NR_POSIX + 2) -#define __NR_POSIX_read (__NR_POSIX + 3) -#define __NR_POSIX_write (__NR_POSIX + 4) -#define __NR_POSIX_open (__NR_POSIX + 5) -#define __NR_POSIX_close (__NR_POSIX + 6) -#define __NR_POSIX_wait (__NR_POSIX + 7) -#define __NR_POSIX_creat (__NR_POSIX + 8) -#define __NR_POSIX_link (__NR_POSIX + 9) -#define __NR_POSIX_unlink (__NR_POSIX + 10) -#define __NR_POSIX_exec (__NR_POSIX + 11) -#define __NR_POSIX_chdir (__NR_POSIX + 12) -#define __NR_POSIX_gtime (__NR_POSIX + 13) -#define __NR_POSIX_mknod (__NR_POSIX + 14) -#define __NR_POSIX_chmod (__NR_POSIX + 15) -#define __NR_POSIX_chown (__NR_POSIX + 16) -#define __NR_POSIX_sbreak (__NR_POSIX + 17) -#define __NR_POSIX_stat (__NR_POSIX + 18) -#define __NR_POSIX_lseek (__NR_POSIX + 19) -#define __NR_POSIX_getpid (__NR_POSIX + 20) -#define __NR_POSIX_mount (__NR_POSIX + 21) -#define __NR_POSIX_umount (__NR_POSIX + 22) -#define __NR_POSIX_setuid (__NR_POSIX + 23) -#define __NR_POSIX_getuid (__NR_POSIX + 24) -#define __NR_POSIX_stime (__NR_POSIX + 25) -#define __NR_POSIX_ptrace (__NR_POSIX + 26) -#define __NR_POSIX_alarm (__NR_POSIX + 27) -#define __NR_POSIX_fstat (__NR_POSIX + 28) -#define __NR_POSIX_pause (__NR_POSIX + 29) -#define __NR_POSIX_utime (__NR_POSIX + 30) -#define __NR_POSIX_stty (__NR_POSIX + 31) -#define __NR_POSIX_gtty (__NR_POSIX + 32) -#define __NR_POSIX_access (__NR_POSIX + 33) -#define __NR_POSIX_nice (__NR_POSIX + 34) -#define __NR_POSIX_statfs (__NR_POSIX + 35) -#define __NR_POSIX_sync (__NR_POSIX + 36) -#define __NR_POSIX_kill (__NR_POSIX + 37) -#define __NR_POSIX_fstatfs (__NR_POSIX + 38) -#define __NR_POSIX_getpgrp (__NR_POSIX + 39) -#define __NR_POSIX_syssgi (__NR_POSIX + 40) -#define __NR_POSIX_dup (__NR_POSIX + 41) -#define __NR_POSIX_pipe (__NR_POSIX + 42) -#define __NR_POSIX_times (__NR_POSIX + 43) -#define __NR_POSIX_profil (__NR_POSIX + 44) -#define __NR_POSIX_lock (__NR_POSIX + 45) -#define __NR_POSIX_setgid (__NR_POSIX + 46) -#define __NR_POSIX_getgid (__NR_POSIX + 47) -#define __NR_POSIX_sig (__NR_POSIX + 48) -#define __NR_POSIX_msgsys (__NR_POSIX + 49) -#define __NR_POSIX_sysmips (__NR_POSIX + 50) -#define __NR_POSIX_sysacct (__NR_POSIX + 51) -#define __NR_POSIX_shmsys (__NR_POSIX + 52) -#define __NR_POSIX_semsys (__NR_POSIX + 53) -#define __NR_POSIX_ioctl (__NR_POSIX + 54) -#define __NR_POSIX_uadmin (__NR_POSIX + 55) -#define __NR_POSIX_exch (__NR_POSIX + 56) -#define __NR_POSIX_utssys (__NR_POSIX + 57) -#define __NR_POSIX_USG_reserved1 (__NR_POSIX + 58) -#define __NR_POSIX_exece (__NR_POSIX + 59) -#define __NR_POSIX_umask (__NR_POSIX + 60) -#define __NR_POSIX_chroot (__NR_POSIX + 61) -#define __NR_POSIX_fcntl (__NR_POSIX + 62) -#define __NR_POSIX_ulimit (__NR_POSIX + 63) -#define __NR_POSIX_SAFARI4_reserved1 (__NR_POSIX + 64) -#define __NR_POSIX_SAFARI4_reserved2 (__NR_POSIX + 65) -#define __NR_POSIX_SAFARI4_reserved3 (__NR_POSIX + 66) -#define __NR_POSIX_SAFARI4_reserved4 (__NR_POSIX + 67) -#define __NR_POSIX_SAFARI4_reserved5 (__NR_POSIX + 68) -#define __NR_POSIX_SAFARI4_reserved6 (__NR_POSIX + 69) -#define __NR_POSIX_advfs (__NR_POSIX + 70) -#define __NR_POSIX_unadvfs (__NR_POSIX + 71) -#define __NR_POSIX_rmount (__NR_POSIX + 72) -#define __NR_POSIX_rumount (__NR_POSIX + 73) -#define __NR_POSIX_rfstart (__NR_POSIX + 74) -#define __NR_POSIX_reserved1 (__NR_POSIX + 75) -#define __NR_POSIX_rdebug (__NR_POSIX + 76) -#define __NR_POSIX_rfstop (__NR_POSIX + 77) -#define __NR_POSIX_rfsys (__NR_POSIX + 78) -#define __NR_POSIX_rmdir (__NR_POSIX + 79) -#define __NR_POSIX_mkdir (__NR_POSIX + 80) -#define __NR_POSIX_getdents (__NR_POSIX + 81) -#define __NR_POSIX_sginap (__NR_POSIX + 82) -#define __NR_POSIX_sgikopt (__NR_POSIX + 83) -#define __NR_POSIX_sysfs (__NR_POSIX + 84) -#define __NR_POSIX_getmsg (__NR_POSIX + 85) -#define __NR_POSIX_putmsg (__NR_POSIX + 86) -#define __NR_POSIX_poll (__NR_POSIX + 87) -#define __NR_POSIX_sigreturn (__NR_POSIX + 88) -#define __NR_POSIX_accept (__NR_POSIX + 89) -#define __NR_POSIX_bind (__NR_POSIX + 90) -#define __NR_POSIX_connect (__NR_POSIX + 91) -#define __NR_POSIX_gethostid (__NR_POSIX + 92) -#define __NR_POSIX_getpeername (__NR_POSIX + 93) -#define __NR_POSIX_getsockname (__NR_POSIX + 94) -#define __NR_POSIX_getsockopt (__NR_POSIX + 95) -#define __NR_POSIX_listen (__NR_POSIX + 96) -#define __NR_POSIX_recv (__NR_POSIX + 97) -#define __NR_POSIX_recvfrom (__NR_POSIX + 98) -#define __NR_POSIX_recvmsg (__NR_POSIX + 99) -#define __NR_POSIX_select (__NR_POSIX + 100) -#define __NR_POSIX_send (__NR_POSIX + 101) -#define __NR_POSIX_sendmsg (__NR_POSIX + 102) -#define __NR_POSIX_sendto (__NR_POSIX + 103) -#define __NR_POSIX_sethostid (__NR_POSIX + 104) -#define __NR_POSIX_setsockopt (__NR_POSIX + 105) -#define __NR_POSIX_shutdown (__NR_POSIX + 106) -#define __NR_POSIX_socket (__NR_POSIX + 107) -#define __NR_POSIX_gethostname (__NR_POSIX + 108) -#define __NR_POSIX_sethostname (__NR_POSIX + 109) -#define __NR_POSIX_getdomainname (__NR_POSIX + 110) -#define __NR_POSIX_setdomainname (__NR_POSIX + 111) -#define __NR_POSIX_truncate (__NR_POSIX + 112) -#define __NR_POSIX_ftruncate (__NR_POSIX + 113) -#define __NR_POSIX_rename (__NR_POSIX + 114) -#define __NR_POSIX_symlink (__NR_POSIX + 115) -#define __NR_POSIX_readlink (__NR_POSIX + 116) -#define __NR_POSIX_lstat (__NR_POSIX + 117) -#define __NR_POSIX_nfs_mount (__NR_POSIX + 118) -#define __NR_POSIX_nfs_svc (__NR_POSIX + 119) -#define __NR_POSIX_nfs_getfh (__NR_POSIX + 120) -#define __NR_POSIX_async_daemon (__NR_POSIX + 121) -#define __NR_POSIX_exportfs (__NR_POSIX + 122) -#define __NR_POSIX_SGI_setregid (__NR_POSIX + 123) -#define __NR_POSIX_SGI_setreuid (__NR_POSIX + 124) -#define __NR_POSIX_getitimer (__NR_POSIX + 125) -#define __NR_POSIX_setitimer (__NR_POSIX + 126) -#define __NR_POSIX_adjtime (__NR_POSIX + 127) -#define __NR_POSIX_SGI_bsdgettime (__NR_POSIX + 128) -#define __NR_POSIX_SGI_sproc (__NR_POSIX + 129) -#define __NR_POSIX_SGI_prctl (__NR_POSIX + 130) -#define __NR_POSIX_SGI_blkproc (__NR_POSIX + 131) -#define __NR_POSIX_SGI_reserved1 (__NR_POSIX + 132) -#define __NR_POSIX_SGI_sgigsc (__NR_POSIX + 133) -#define __NR_POSIX_SGI_mmap (__NR_POSIX + 134) -#define __NR_POSIX_SGI_munmap (__NR_POSIX + 135) -#define __NR_POSIX_SGI_mprotect (__NR_POSIX + 136) -#define __NR_POSIX_SGI_msync (__NR_POSIX + 137) -#define __NR_POSIX_SGI_madvise (__NR_POSIX + 138) -#define __NR_POSIX_SGI_mpin (__NR_POSIX + 139) -#define __NR_POSIX_SGI_getpagesize (__NR_POSIX + 140) -#define __NR_POSIX_SGI_libattach (__NR_POSIX + 141) -#define __NR_POSIX_SGI_libdetach (__NR_POSIX + 142) -#define __NR_POSIX_SGI_getpgrp (__NR_POSIX + 143) -#define __NR_POSIX_SGI_setpgrp (__NR_POSIX + 144) -#define __NR_POSIX_SGI_reserved2 (__NR_POSIX + 145) -#define __NR_POSIX_SGI_reserved3 (__NR_POSIX + 146) -#define __NR_POSIX_SGI_reserved4 (__NR_POSIX + 147) -#define __NR_POSIX_SGI_reserved5 (__NR_POSIX + 148) -#define __NR_POSIX_SGI_reserved6 (__NR_POSIX + 149) -#define __NR_POSIX_cacheflush (__NR_POSIX + 150) -#define __NR_POSIX_cachectl (__NR_POSIX + 151) -#define __NR_POSIX_fchown (__NR_POSIX + 152) -#define __NR_POSIX_fchmod (__NR_POSIX + 153) -#define __NR_POSIX_wait3 (__NR_POSIX + 154) -#define __NR_POSIX_mmap (__NR_POSIX + 155) -#define __NR_POSIX_munmap (__NR_POSIX + 156) -#define __NR_POSIX_madvise (__NR_POSIX + 157) -#define __NR_POSIX_BSD_getpagesize (__NR_POSIX + 158) -#define __NR_POSIX_setreuid (__NR_POSIX + 159) -#define __NR_POSIX_setregid (__NR_POSIX + 160) -#define __NR_POSIX_setpgid (__NR_POSIX + 161) -#define __NR_POSIX_getgroups (__NR_POSIX + 162) -#define __NR_POSIX_setgroups (__NR_POSIX + 163) -#define __NR_POSIX_gettimeofday (__NR_POSIX + 164) -#define __NR_POSIX_getrusage (__NR_POSIX + 165) -#define __NR_POSIX_getrlimit (__NR_POSIX + 166) -#define __NR_POSIX_setrlimit (__NR_POSIX + 167) -#define __NR_POSIX_waitpid (__NR_POSIX + 168) -#define __NR_POSIX_dup2 (__NR_POSIX + 169) -#define __NR_POSIX_reserved2 (__NR_POSIX + 170) -#define __NR_POSIX_reserved3 (__NR_POSIX + 171) -#define __NR_POSIX_reserved4 (__NR_POSIX + 172) -#define __NR_POSIX_reserved5 (__NR_POSIX + 173) -#define __NR_POSIX_reserved6 (__NR_POSIX + 174) -#define __NR_POSIX_reserved7 (__NR_POSIX + 175) -#define __NR_POSIX_reserved8 (__NR_POSIX + 176) -#define __NR_POSIX_reserved9 (__NR_POSIX + 177) -#define __NR_POSIX_reserved10 (__NR_POSIX + 178) -#define __NR_POSIX_reserved11 (__NR_POSIX + 179) -#define __NR_POSIX_reserved12 (__NR_POSIX + 180) -#define __NR_POSIX_reserved13 (__NR_POSIX + 181) -#define __NR_POSIX_reserved14 (__NR_POSIX + 182) -#define __NR_POSIX_reserved15 (__NR_POSIX + 183) -#define __NR_POSIX_reserved16 (__NR_POSIX + 184) -#define __NR_POSIX_reserved17 (__NR_POSIX + 185) -#define __NR_POSIX_reserved18 (__NR_POSIX + 186) -#define __NR_POSIX_reserved19 (__NR_POSIX + 187) -#define __NR_POSIX_reserved20 (__NR_POSIX + 188) -#define __NR_POSIX_reserved21 (__NR_POSIX + 189) -#define __NR_POSIX_reserved22 (__NR_POSIX + 190) -#define __NR_POSIX_reserved23 (__NR_POSIX + 191) -#define __NR_POSIX_reserved24 (__NR_POSIX + 192) -#define __NR_POSIX_reserved25 (__NR_POSIX + 193) -#define __NR_POSIX_reserved26 (__NR_POSIX + 194) -#define __NR_POSIX_reserved27 (__NR_POSIX + 195) -#define __NR_POSIX_reserved28 (__NR_POSIX + 196) -#define __NR_POSIX_reserved29 (__NR_POSIX + 197) -#define __NR_POSIX_reserved30 (__NR_POSIX + 198) -#define __NR_POSIX_reserved31 (__NR_POSIX + 199) -#define __NR_POSIX_reserved32 (__NR_POSIX + 200) -#define __NR_POSIX_reserved33 (__NR_POSIX + 201) -#define __NR_POSIX_reserved34 (__NR_POSIX + 202) -#define __NR_POSIX_reserved35 (__NR_POSIX + 203) -#define __NR_POSIX_reserved36 (__NR_POSIX + 204) -#define __NR_POSIX_reserved37 (__NR_POSIX + 205) -#define __NR_POSIX_reserved38 (__NR_POSIX + 206) -#define __NR_POSIX_reserved39 (__NR_POSIX + 207) -#define __NR_POSIX_reserved40 (__NR_POSIX + 208) -#define __NR_POSIX_reserved41 (__NR_POSIX + 209) -#define __NR_POSIX_reserved42 (__NR_POSIX + 210) -#define __NR_POSIX_reserved43 (__NR_POSIX + 211) -#define __NR_POSIX_reserved44 (__NR_POSIX + 212) -#define __NR_POSIX_reserved45 (__NR_POSIX + 213) -#define __NR_POSIX_reserved46 (__NR_POSIX + 214) -#define __NR_POSIX_reserved47 (__NR_POSIX + 215) -#define __NR_POSIX_reserved48 (__NR_POSIX + 216) -#define __NR_POSIX_reserved49 (__NR_POSIX + 217) -#define __NR_POSIX_reserved50 (__NR_POSIX + 218) -#define __NR_POSIX_reserved51 (__NR_POSIX + 219) -#define __NR_POSIX_reserved52 (__NR_POSIX + 220) -#define __NR_POSIX_reserved53 (__NR_POSIX + 221) -#define __NR_POSIX_reserved54 (__NR_POSIX + 222) -#define __NR_POSIX_reserved55 (__NR_POSIX + 223) -#define __NR_POSIX_reserved56 (__NR_POSIX + 224) -#define __NR_POSIX_reserved57 (__NR_POSIX + 225) -#define __NR_POSIX_reserved58 (__NR_POSIX + 226) -#define __NR_POSIX_reserved59 (__NR_POSIX + 227) -#define __NR_POSIX_reserved60 (__NR_POSIX + 228) -#define __NR_POSIX_reserved61 (__NR_POSIX + 229) -#define __NR_POSIX_reserved62 (__NR_POSIX + 230) -#define __NR_POSIX_reserved63 (__NR_POSIX + 231) -#define __NR_POSIX_reserved64 (__NR_POSIX + 232) -#define __NR_POSIX_reserved65 (__NR_POSIX + 233) -#define __NR_POSIX_reserved66 (__NR_POSIX + 234) -#define __NR_POSIX_reserved67 (__NR_POSIX + 235) -#define __NR_POSIX_reserved68 (__NR_POSIX + 236) -#define __NR_POSIX_reserved69 (__NR_POSIX + 237) -#define __NR_POSIX_reserved70 (__NR_POSIX + 238) -#define __NR_POSIX_reserved71 (__NR_POSIX + 239) -#define __NR_POSIX_reserved72 (__NR_POSIX + 240) -#define __NR_POSIX_reserved73 (__NR_POSIX + 241) -#define __NR_POSIX_reserved74 (__NR_POSIX + 242) -#define __NR_POSIX_reserved75 (__NR_POSIX + 243) -#define __NR_POSIX_reserved76 (__NR_POSIX + 244) -#define __NR_POSIX_reserved77 (__NR_POSIX + 245) -#define __NR_POSIX_reserved78 (__NR_POSIX + 246) -#define __NR_POSIX_reserved79 (__NR_POSIX + 247) -#define __NR_POSIX_reserved80 (__NR_POSIX + 248) -#define __NR_POSIX_reserved81 (__NR_POSIX + 249) -#define __NR_POSIX_reserved82 (__NR_POSIX + 250) -#define __NR_POSIX_reserved83 (__NR_POSIX + 251) -#define __NR_POSIX_reserved84 (__NR_POSIX + 252) -#define __NR_POSIX_reserved85 (__NR_POSIX + 253) -#define __NR_POSIX_reserved86 (__NR_POSIX + 254) -#define __NR_POSIX_reserved87 (__NR_POSIX + 255) -#define __NR_POSIX_reserved88 (__NR_POSIX + 256) -#define __NR_POSIX_reserved89 (__NR_POSIX + 257) -#define __NR_POSIX_reserved90 (__NR_POSIX + 258) -#define __NR_POSIX_reserved91 (__NR_POSIX + 259) -#define __NR_POSIX_netboot (__NR_POSIX + 260) -#define __NR_POSIX_netunboot (__NR_POSIX + 261) -#define __NR_POSIX_rdump (__NR_POSIX + 262) -#define __NR_POSIX_setsid (__NR_POSIX + 263) -#define __NR_POSIX_getmaxsig (__NR_POSIX + 264) -#define __NR_POSIX_sigpending (__NR_POSIX + 265) -#define __NR_POSIX_sigprocmask (__NR_POSIX + 266) -#define __NR_POSIX_sigsuspend (__NR_POSIX + 267) -#define __NR_POSIX_sigaction (__NR_POSIX + 268) -#define __NR_POSIX_MIPS_reserved1 (__NR_POSIX + 269) -#define __NR_POSIX_MIPS_reserved2 (__NR_POSIX + 270) -#define __NR_POSIX_MIPS_reserved3 (__NR_POSIX + 271) -#define __NR_POSIX_MIPS_reserved4 (__NR_POSIX + 272) -#define __NR_POSIX_MIPS_reserved5 (__NR_POSIX + 273) -#define __NR_POSIX_MIPS_reserved6 (__NR_POSIX + 274) -#define __NR_POSIX_MIPS_reserved7 (__NR_POSIX + 275) -#define __NR_POSIX_MIPS_reserved8 (__NR_POSIX + 276) -#define __NR_POSIX_MIPS_reserved9 (__NR_POSIX + 277) -#define __NR_POSIX_MIPS_reserved10 (__NR_POSIX + 278) -#define __NR_POSIX_MIPS_reserved11 (__NR_POSIX + 279) -#define __NR_POSIX_TANDEM_reserved1 (__NR_POSIX + 280) -#define __NR_POSIX_TANDEM_reserved2 (__NR_POSIX + 281) -#define __NR_POSIX_TANDEM_reserved3 (__NR_POSIX + 282) -#define __NR_POSIX_TANDEM_reserved4 (__NR_POSIX + 283) -#define __NR_POSIX_TANDEM_reserved5 (__NR_POSIX + 284) -#define __NR_POSIX_TANDEM_reserved6 (__NR_POSIX + 285) -#define __NR_POSIX_TANDEM_reserved7 (__NR_POSIX + 286) -#define __NR_POSIX_TANDEM_reserved8 (__NR_POSIX + 287) -#define __NR_POSIX_TANDEM_reserved9 (__NR_POSIX + 288) -#define __NR_POSIX_TANDEM_reserved10 (__NR_POSIX + 289) -#define __NR_POSIX_TANDEM_reserved11 (__NR_POSIX + 290) -#define __NR_POSIX_TANDEM_reserved12 (__NR_POSIX + 291) -#define __NR_POSIX_TANDEM_reserved13 (__NR_POSIX + 292) -#define __NR_POSIX_TANDEM_reserved14 (__NR_POSIX + 293) -#define __NR_POSIX_TANDEM_reserved15 (__NR_POSIX + 294) -#define __NR_POSIX_TANDEM_reserved16 (__NR_POSIX + 295) -#define __NR_POSIX_TANDEM_reserved17 (__NR_POSIX + 296) -#define __NR_POSIX_TANDEM_reserved18 (__NR_POSIX + 297) -#define __NR_POSIX_TANDEM_reserved19 (__NR_POSIX + 298) -#define __NR_POSIX_TANDEM_reserved20 (__NR_POSIX + 299) -#define __NR_POSIX_SGI_reserved7 (__NR_POSIX + 300) -#define __NR_POSIX_SGI_reserved8 (__NR_POSIX + 301) -#define __NR_POSIX_SGI_reserved9 (__NR_POSIX + 302) -#define __NR_POSIX_SGI_reserved10 (__NR_POSIX + 303) -#define __NR_POSIX_SGI_reserved11 (__NR_POSIX + 304) -#define __NR_POSIX_SGI_reserved12 (__NR_POSIX + 305) -#define __NR_POSIX_SGI_reserved13 (__NR_POSIX + 306) -#define __NR_POSIX_SGI_reserved14 (__NR_POSIX + 307) -#define __NR_POSIX_SGI_reserved15 (__NR_POSIX + 308) -#define __NR_POSIX_SGI_reserved16 (__NR_POSIX + 309) -#define __NR_POSIX_SGI_reserved17 (__NR_POSIX + 310) -#define __NR_POSIX_SGI_reserved18 (__NR_POSIX + 311) -#define __NR_POSIX_SGI_reserved19 (__NR_POSIX + 312) -#define __NR_POSIX_SGI_reserved20 (__NR_POSIX + 313) -#define __NR_POSIX_SGI_reserved21 (__NR_POSIX + 314) -#define __NR_POSIX_SGI_reserved22 (__NR_POSIX + 315) -#define __NR_POSIX_SGI_reserved23 (__NR_POSIX + 316) -#define __NR_POSIX_SGI_reserved24 (__NR_POSIX + 317) -#define __NR_POSIX_SGI_reserved25 (__NR_POSIX + 318) -#define __NR_POSIX_SGI_reserved26 (__NR_POSIX + 319) - -#endif /* _ASM_RISCOS_SYSCALL_H */ -- cgit v1.1 From 7c4cb60e5b97677424e95baee9c29df54b26e6ba Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:47 -0800 Subject: [PATCH] x86: GDT alignment fix Make GDT page aligned and page padded to support running inside of a hypervisor. This prevents false sharing of the GDT page with other hot data, which is not allowed in Xen, and causes performance problems in VMware. Rather than go back to the old method of statically allocating the GDT (which wastes unneded space for non-present CPUs), the GDT for APs is allocated dynamically. Signed-off-by: Zachary Amsden Cc: "Seth, Rohit" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/apm.c | 2 ++ arch/i386/kernel/cpu/common.c | 3 --- arch/i386/kernel/head.S | 2 ++ arch/i386/kernel/i386_ksyms.c | 3 +-- arch/i386/kernel/smpboot.c | 6 ++++++ drivers/pnp/pnpbios/bioscalls.c | 22 +++++++++++++--------- include/asm-i386/desc.h | 8 +++++--- 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index 1e60acb..6c8e483 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c @@ -2317,6 +2317,8 @@ static int __init apm_init(void) for (i = 0; i < NR_CPUS; i++) { struct desc_struct *gdt = get_cpu_gdt_table(i); + if (!gdt) + continue; set_base(gdt[APM_CS >> 3], __va((unsigned long)apm_info.bios.cseg << 4)); set_base(gdt[APM_CS_16 >> 3], diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c index 31e344b..cbc3206 100644 --- a/arch/i386/kernel/cpu/common.c +++ b/arch/i386/kernel/cpu/common.c @@ -18,9 +18,6 @@ #include "cpu.h" -DEFINE_PER_CPU(struct desc_struct, cpu_gdt_table[GDT_ENTRIES]); -EXPORT_PER_CPU_SYMBOL(cpu_gdt_table); - DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack); diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index e437fb3..870f20b 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S @@ -525,3 +525,5 @@ ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* 0xf0 - unused */ .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */ + /* Be sure this is zeroed to avoid false validations in Xen */ + .fill PAGE_SIZE_asm / 8 - GDT_ENTRIES,8,0 diff --git a/arch/i386/kernel/i386_ksyms.c b/arch/i386/kernel/i386_ksyms.c index 180f070..3999bec 100644 --- a/arch/i386/kernel/i386_ksyms.c +++ b/arch/i386/kernel/i386_ksyms.c @@ -3,8 +3,7 @@ #include #include -/* This is definitely a GPL-only symbol */ -EXPORT_SYMBOL_GPL(cpu_gdt_table); +EXPORT_SYMBOL_GPL(cpu_gdt_descr); EXPORT_SYMBOL(__down_failed); EXPORT_SYMBOL(__down_failed_interruptible); diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c index 9ed449a..b3c2e2c 100644 --- a/arch/i386/kernel/smpboot.c +++ b/arch/i386/kernel/smpboot.c @@ -903,6 +903,12 @@ static int __devinit do_boot_cpu(int apicid, int cpu) unsigned long start_eip; unsigned short nmi_high = 0, nmi_low = 0; + if (!cpu_gdt_descr[cpu].address && + !(cpu_gdt_descr[cpu].address = get_zeroed_page(GFP_KERNEL))) { + printk("Failed to allocate GDT for CPU %d\n", cpu); + return 1; + } + ++cpucount; /* diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c index 6b7583f..7cb476e 100644 --- a/drivers/pnp/pnpbios/bioscalls.c +++ b/drivers/pnp/pnpbios/bioscalls.c @@ -69,14 +69,16 @@ __asm__( #define Q_SET_SEL(cpu, selname, address, size) \ do { \ -set_base(per_cpu(cpu_gdt_table,cpu)[(selname) >> 3], __va((u32)(address))); \ -set_limit(per_cpu(cpu_gdt_table,cpu)[(selname) >> 3], size); \ +struct desc_struct *gdt = get_cpu_gdt_table((cpu)); \ +set_base(gdt[(selname) >> 3], __va((u32)(address))); \ +set_limit(gdt[(selname) >> 3], size); \ } while(0) #define Q2_SET_SEL(cpu, selname, address, size) \ do { \ -set_base(per_cpu(cpu_gdt_table,cpu)[(selname) >> 3], (u32)(address)); \ -set_limit(per_cpu(cpu_gdt_table,cpu)[(selname) >> 3], size); \ +struct desc_struct *gdt = get_cpu_gdt_table((cpu)); \ +set_base(gdt[(selname) >> 3], (u32)(address)); \ +set_limit(gdt[(selname) >> 3], size); \ } while(0) static struct desc_struct bad_bios_desc = { 0, 0x00409200 }; @@ -115,8 +117,8 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3, return PNP_FUNCTION_NOT_SUPPORTED; cpu = get_cpu(); - save_desc_40 = per_cpu(cpu_gdt_table,cpu)[0x40 / 8]; - per_cpu(cpu_gdt_table,cpu)[0x40 / 8] = bad_bios_desc; + save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8]; + get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc; /* On some boxes IRQ's during PnP BIOS calls are deadly. */ spin_lock_irqsave(&pnp_bios_lock, flags); @@ -158,7 +160,7 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3, ); spin_unlock_irqrestore(&pnp_bios_lock, flags); - per_cpu(cpu_gdt_table,cpu)[0x40 / 8] = save_desc_40; + get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40; put_cpu(); /* If we get here and this is set then the PnP BIOS faulted on us. */ @@ -535,8 +537,10 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header) set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); - for(i=0; i < NR_CPUS; i++) - { + for (i = 0; i < NR_CPUS; i++) { + struct desc_struct *gdt = get_cpu_gdt_table(i); + if (!gdt) + continue; Q2_SET_SEL(i, PNP_CS32, &pnp_bios_callfunc, 64 * 1024); Q_SET_SEL(i, PNP_CS16, header->fields.pm16cseg, 64 * 1024); Q_SET_SEL(i, PNP_DS, header->fields.pm16dseg, 64 * 1024); diff --git a/include/asm-i386/desc.h b/include/asm-i386/desc.h index 29b851a..494e73b 100644 --- a/include/asm-i386/desc.h +++ b/include/asm-i386/desc.h @@ -15,9 +15,6 @@ #include extern struct desc_struct cpu_gdt_table[GDT_ENTRIES]; -DECLARE_PER_CPU(struct desc_struct, cpu_gdt_table[GDT_ENTRIES]); - -#define get_cpu_gdt_table(_cpu) (per_cpu(cpu_gdt_table,_cpu)) DECLARE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); @@ -29,6 +26,11 @@ struct Xgt_desc_struct { extern struct Xgt_desc_struct idt_descr, cpu_gdt_descr[NR_CPUS]; +static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu) +{ + return ((struct desc_struct *)cpu_gdt_descr[cpu].address); +} + #define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8)) #define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8)) -- cgit v1.1 From e43d674f44dc885a2476cab3537e639d9eaa31a9 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 6 Jan 2006 00:11:48 -0800 Subject: [PATCH] i386: don't blindly enable interrupts in die() Rather than blindly re-enabling interrupts in die(), save their state upon entry and then restore that state. If the kernel is in really bad condition and faults with interrupts disabled, re-enabling them in die() may cause even more trouble, implying more chances of data corruption. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/traps.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c index ab0e943..bb36a98 100644 --- a/arch/i386/kernel/traps.c +++ b/arch/i386/kernel/traps.c @@ -306,14 +306,17 @@ void die(const char * str, struct pt_regs * regs, long err) .lock_owner_depth = 0 }; static int die_counter; + unsigned long flags; if (die.lock_owner != raw_smp_processor_id()) { console_verbose(); - spin_lock_irq(&die.lock); + spin_lock_irqsave(&die.lock, flags); die.lock_owner = smp_processor_id(); die.lock_owner_depth = 0; bust_spinlocks(1); } + else + local_save_flags(flags); if (++die.lock_owner_depth < 3) { int nl = 0; @@ -340,7 +343,7 @@ void die(const char * str, struct pt_regs * regs, long err) bust_spinlocks(0); die.lock_owner = -1; - spin_unlock_irq(&die.lock); + spin_unlock_irqrestore(&die.lock, flags); if (kexec_should_crash(current)) crash_kexec(regs); -- cgit v1.1 From d43c6e8083ac8baeb1a167510aea34fcef396e33 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 6 Jan 2006 00:11:49 -0800 Subject: [PATCH] i386: move SIMD initialization Move some code unrelated to any dealing with hardware bugs from i386's bugs.h to a more logical place. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/traps.c | 22 ++++++++++++++++++++++ include/asm-i386/bugs.h | 23 +---------------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c index bb36a98..f0c4060 100644 --- a/arch/i386/kernel/traps.c +++ b/arch/i386/kernel/traps.c @@ -1098,6 +1098,28 @@ void __init trap_init(void) #endif set_trap_gate(19,&simd_coprocessor_error); + if (cpu_has_fxsr) { + /* + * Verify that the FXSAVE/FXRSTOR data will be 16-byte aligned. + * Generates a compile-time "error: zero width for bit-field" if + * the alignment is wrong. + */ + struct fxsrAlignAssert { + int _:!(offsetof(struct task_struct, + thread.i387.fxsave) & 15); + }; + + printk(KERN_INFO "Enabling fast FPU save and restore... "); + set_in_cr4(X86_CR4_OSFXSR); + printk("done.\n"); + } + if (cpu_has_xmm) { + printk(KERN_INFO "Enabling unmasked SIMD FPU exception " + "support... "); + set_in_cr4(X86_CR4_OSXMMEXCPT); + printk("done.\n"); + } + set_system_gate(SYSCALL_VECTOR,&system_call); /* diff --git a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h index ea54540..50233e0 100644 --- a/include/asm-i386/bugs.h +++ b/include/asm-i386/bugs.h @@ -8,9 +8,6 @@ * * - Channing Corn (tests & fixes), * - Andrew D. Balsa (code cleanup). - * - * Pentium III FXSR, SSE support - * Gareth Hughes , May 2000 */ /* @@ -76,25 +73,7 @@ static void __init check_fpu(void) return; } -/* Enable FXSR and company _before_ testing for FP problems. */ - /* - * Verify that the FXSAVE/FXRSTOR data will be 16-byte aligned. - */ - if (offsetof(struct task_struct, thread.i387.fxsave) & 15) { - extern void __buggy_fxsr_alignment(void); - __buggy_fxsr_alignment(); - } - if (cpu_has_fxsr) { - printk(KERN_INFO "Enabling fast FPU save and restore... "); - set_in_cr4(X86_CR4_OSFXSR); - printk("done.\n"); - } - if (cpu_has_xmm) { - printk(KERN_INFO "Enabling unmasked SIMD FPU exception support... "); - set_in_cr4(X86_CR4_OSXMMEXCPT); - printk("done.\n"); - } - +/* trap_init() enabled FXSR and company _before_ testing for FP problems here. */ /* Test for the divl bug.. */ __asm__("fninit\n\t" "fldl %1\n\t" -- cgit v1.1 From eb05c3249a8e8a675e79d221f4a0874dc10ec903 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 6 Jan 2006 00:11:49 -0800 Subject: [PATCH] i386: fix bound check IDT gate Other than apparently commonly assumed, the bound instruction does not require the corresponding IDT entry to have DPL 3. Acked-by: "Seth, Rohit" Acked-by: Zachary Amsden Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/traps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c index f0c4060..53ad954e 100644 --- a/arch/i386/kernel/traps.c +++ b/arch/i386/kernel/traps.c @@ -1078,9 +1078,9 @@ void __init trap_init(void) set_trap_gate(0,÷_error); set_intr_gate(1,&debug); set_intr_gate(2,&nmi); - set_system_intr_gate(3, &int3); /* int3-5 can be called from all */ + set_system_intr_gate(3, &int3); /* int3/4 can be called from all */ set_system_gate(4,&overflow); - set_system_gate(5,&bounds); + set_trap_gate(5,&bounds); set_trap_gate(6,&invalid_op); set_trap_gate(7,&device_not_available); set_task_gate(8,GDT_ENTRY_DOUBLEFAULT_TSS); -- cgit v1.1 From ff6e8c0d5e47f0ceeebde86ec2f5919dbd5beb67 Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:50 -0800 Subject: [PATCH] x86: Cr4 is valid on some 486s So some 486 processors do have CR4 register. Allow them to present it in register dumps by using the old fault technique rather than testing processor family. Thanks to Maciej for noticing this. Signed-off-by: Zachary Amsden Cc: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/process.c | 4 +--- include/asm-i386/system.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index 2333aea..6081a10 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c @@ -308,9 +308,7 @@ void show_regs(struct pt_regs * regs) cr0 = read_cr0(); cr2 = read_cr2(); cr3 = read_cr3(); - if (current_cpu_data.x86 > 4) { - cr4 = read_cr4(); - } + cr4 = read_cr4_safe(); printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", cr0, cr2, cr3, cr4); show_trace(NULL, ®s->esp); } diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h index 772f85d..88b4d5c 100644 --- a/include/asm-i386/system.h +++ b/include/asm-i386/system.h @@ -140,6 +140,19 @@ static inline unsigned long _get_base(char * addr) :"=r" (__dummy)); \ __dummy; \ }) + +#define read_cr4_safe() ({ \ + unsigned int __dummy; \ + /* This could fault if %cr4 does not exist */ \ + __asm__("1: movl %%cr4, %0 \n" \ + "2: \n" \ + ".section __ex_table,\"a\" \n" \ + ".long 1b,2b \n" \ + ".previous \n" \ + : "=r" (__dummy): "0" (0)); \ + __dummy; \ +}) + #define write_cr4(x) \ __asm__ __volatile__("movl %0,%%cr4": :"r" (x)); #define stts() write_cr0(8 | read_cr0()) -- cgit v1.1 From 5702d0f742b2f462267bca147334f77a255bcc74 Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:51 -0800 Subject: [PATCH] x86: Pnp segments in segment h Move PnP BIOS segment definitions into segment.h; the segments are reserved here, so they might as well be defined here as well. Note I didn't do this for APM BIOS, as Macintosh and other systems use those values to emulate APM in some scary way I don't want to understand. Signed-off-by: Zachary Amsden Acked-by: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pnp/pnpbios/bioscalls.c | 9 --------- include/asm-i386/segment.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c index 7cb476e..37bacfc 100644 --- a/drivers/pnp/pnpbios/bioscalls.c +++ b/drivers/pnp/pnpbios/bioscalls.c @@ -31,15 +31,6 @@ static struct { } pnp_bios_callpoint; -/* The PnP BIOS entries in the GDT */ -#define PNP_GDT (GDT_ENTRY_PNPBIOS_BASE * 8) - -#define PNP_CS32 (PNP_GDT+0x00) /* segment for calling fn */ -#define PNP_CS16 (PNP_GDT+0x08) /* code segment for BIOS */ -#define PNP_DS (PNP_GDT+0x10) /* data segment for BIOS */ -#define PNP_TS1 (PNP_GDT+0x18) /* transfer data segment */ -#define PNP_TS2 (PNP_GDT+0x20) /* another data segment */ - /* * These are some opcodes for a "static asmlinkage" * As this code is *not* executed inside the linux kernel segment, but in a diff --git a/include/asm-i386/segment.h b/include/asm-i386/segment.h index bb5ff5b..faf9953 100644 --- a/include/asm-i386/segment.h +++ b/include/asm-i386/segment.h @@ -91,6 +91,20 @@ #define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1) #define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8) +/* The PnP BIOS entries in the GDT */ +#define GDT_ENTRY_PNPBIOS_CS32 (GDT_ENTRY_PNPBIOS_BASE + 0) +#define GDT_ENTRY_PNPBIOS_CS16 (GDT_ENTRY_PNPBIOS_BASE + 1) +#define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2) +#define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3) +#define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4) + +/* The PnP BIOS selectors */ +#define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8) /* segment for calling fn */ +#define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8) /* code segment for BIOS */ +#define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8) /* data segment for BIOS */ +#define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8) /* transfer data segment */ +#define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8) /* another data segment */ + /* * The interrupt descriptor table has room for 256 idt's, * the global descriptor table is dependent on the number -- cgit v1.1 From 3012d2d209580c78b5927d55c60a10891be8befd Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:53 -0800 Subject: [PATCH] x86: Always relax segments APM BIOSes have many bugs regarding proper representation of the appropriate segment limits for calling the BIOS. By default, APM_RELAX_SEGMENTS is always turned on to support running the APM BIOS on these buggy machines. Keeping 64k limits poses very little danger to the kernel, because the pages where the APM BIOS is located will always be in low physical memory BIOS areas, which should already be marked reserved, and only buggy BIOSes would possibly overstep the segment bounds with writes to data anyway. Since forcing stricter limits breaks many machines and is not default behavior, it seems reasonable to deprecate the older code which may cause APM BIOS to fault. If you really have a badly enough broken APM BIOS that you have to turn off APM_RELAX_SEGMENTS, seems like the best recourse here would be to disable the APM BIOS and / or not compile it into your kernel to begin with, and / or add your system to the known bad list. The reason I want to deprecate this code is there is underlying brokenness with the set_limit macros, and getting rid of many of the call sites rather than rewriting them seems to be the simplest and most correct course of action. Signed-off-by: Zachary Amsden Acked-by: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/apm.c | 55 ++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index 6c8e483..0d29811 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c @@ -303,17 +303,6 @@ extern int (*console_blank_hook)(int); #include "apm.h" /* - * Define to make all _set_limit calls use 64k limits. The APM 1.1 BIOS is - * supposed to provide limit information that it recognizes. Many machines - * do this correctly, but many others do not restrict themselves to their - * claimed limit. When this happens, they will cause a segmentation - * violation in the kernel at boot time. Most BIOS's, however, will - * respect a 64k limit, so we use that. If you want to be pedantic and - * hold your BIOS to its claims, then undefine this. - */ -#define APM_RELAX_SEGMENTS - -/* * Define to re-initialize the interrupt 0 timer to 100 Hz after a suspend. * This patched by Chad Miller , original code by * David Chen @@ -2312,9 +2301,20 @@ static int __init apm_init(void) set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); + /* + * Set up the long jump entry point to the APM BIOS, which is called + * from inline assembly. + */ apm_bios_entry.offset = apm_info.bios.offset; apm_bios_entry.segment = APM_CS; + /* + * The APM 1.1 BIOS is supposed to provide limit information that it + * recognizes. Many machines do this correctly, but many others do + * not restrict themselves to their claimed limit. When this happens, + * they will cause a segmentation violation in the kernel at boot time. + * Most BIOS's, however, will respect a 64k limit, so we use that. + */ for (i = 0; i < NR_CPUS; i++) { struct desc_struct *gdt = get_cpu_gdt_table(i); if (!gdt) @@ -2325,33 +2325,12 @@ static int __init apm_init(void) __va((unsigned long)apm_info.bios.cseg_16 << 4)); set_base(gdt[APM_DS >> 3], __va((unsigned long)apm_info.bios.dseg << 4)); -#ifndef APM_RELAX_SEGMENTS - if (apm_info.bios.version == 0x100) { -#endif - /* For ASUS motherboard, Award BIOS rev 110 (and others?) */ - _set_limit((char *)&gdt[APM_CS >> 3], 64 * 1024 - 1); - /* For some unknown machine. */ - _set_limit((char *)&gdt[APM_CS_16 >> 3], 64 * 1024 - 1); - /* For the DEC Hinote Ultra CT475 (and others?) */ - _set_limit((char *)&gdt[APM_DS >> 3], 64 * 1024 - 1); -#ifndef APM_RELAX_SEGMENTS - } else { - _set_limit((char *)&gdt[APM_CS >> 3], - (apm_info.bios.cseg_len - 1) & 0xffff); - _set_limit((char *)&gdt[APM_CS_16 >> 3], - (apm_info.bios.cseg_16_len - 1) & 0xffff); - _set_limit((char *)&gdt[APM_DS >> 3], - (apm_info.bios.dseg_len - 1) & 0xffff); - /* workaround for broken BIOSes */ - if (apm_info.bios.cseg_len <= apm_info.bios.offset) - _set_limit((char *)&gdt[APM_CS >> 3], 64 * 1024 -1); - if (apm_info.bios.dseg_len <= 0x40) { /* 0x40 * 4kB == 64kB */ - /* for the BIOS that assumes granularity = 1 */ - gdt[APM_DS >> 3].b |= 0x800000; - printk(KERN_NOTICE "apm: we set the granularity of dseg.\n"); - } - } -#endif + /* For ASUS motherboard, Award BIOS rev 110 (and others?) */ + _set_limit((char *)&gdt[APM_CS >> 3], 64 * 1024 - 1); + /* For some unknown machine. */ + _set_limit((char *)&gdt[APM_CS_16 >> 3], 64 * 1024 - 1); + /* For the DEC Hinote Ultra CT475 (and others?) */ + _set_limit((char *)&gdt[APM_DS >> 3], 64 * 1024 - 1); } apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info); -- cgit v1.1 From 99022c4695d3f45fcf7f3827aa46dd2d9e53e365 Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:53 -0800 Subject: [PATCH] x86: Apm seg in gdt Since APM BIOS segment limits are now fixed, set them in head.S GDT and don't use the complicated _set_limit() macro expansion. Signed-off-by: Zachary Amsden Acked-by: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/apm.c | 6 ------ arch/i386/kernel/head.S | 9 +++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index 0d29811..45199bb 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c @@ -2325,12 +2325,6 @@ static int __init apm_init(void) __va((unsigned long)apm_info.bios.cseg_16 << 4)); set_base(gdt[APM_DS >> 3], __va((unsigned long)apm_info.bios.dseg << 4)); - /* For ASUS motherboard, Award BIOS rev 110 (and others?) */ - _set_limit((char *)&gdt[APM_CS >> 3], 64 * 1024 - 1); - /* For some unknown machine. */ - _set_limit((char *)&gdt[APM_CS_16 >> 3], 64 * 1024 - 1); - /* For the DEC Hinote Ultra CT475 (and others?) */ - _set_limit((char *)&gdt[APM_DS >> 3], 64 * 1024 - 1); } apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info); diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index 870f20b..37b599f 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S @@ -510,13 +510,14 @@ ENTRY(cpu_gdt_table) .quad 0x0080920000000000 /* 0xa0 16-bit data */ .quad 0x0080920000000000 /* 0xa8 16-bit data */ .quad 0x0080920000000000 /* 0xb0 16-bit data */ + /* * The APM segments have byte granularity and their bases - * and limits are set at run time. + * are set at run time. All have 64k limits. */ - .quad 0x00409a0000000000 /* 0xb8 APM CS code */ - .quad 0x00009a0000000000 /* 0xc0 APM CS 16 code (16 bit) */ - .quad 0x0040920000000000 /* 0xc8 APM DS data */ + .quad 0x00409a000000ffff /* 0xb8 APM CS code */ + .quad 0x00009a000000ffff /* 0xc0 APM CS 16 code (16 bit) */ + .quad 0x004092000000ffff /* 0xc8 APM DS data */ .quad 0x0000920000000000 /* 0xd0 - ESPFIX 16-bit SS */ .quad 0x0000000000000000 /* 0xd8 - unused */ -- cgit v1.1 From 3fae1c37eea98097de34ba665796fea93b29f4aa Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:54 -0800 Subject: [PATCH] x86: Deprecate obsolete ldt accessors Old accessors to fetch LDT descriptors are unused and outdated and in the wrong header file. Signed-off-by: Zachary Amsden Cc: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-i386/system.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h index 88b4d5c..24cc0c8 100644 --- a/include/asm-i386/system.h +++ b/include/asm-i386/system.h @@ -56,22 +56,6 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t" \ #define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) ) #define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1)>>12 ) -static inline unsigned long _get_base(char * addr) -{ - unsigned long __base; - __asm__("movb %3,%%dh\n\t" - "movb %2,%%dl\n\t" - "shll $16,%%edx\n\t" - "movw %1,%%dx" - :"=&d" (__base) - :"m" (*((addr)+2)), - "m" (*((addr)+4)), - "m" (*((addr)+7))); - return __base; -} - -#define get_base(ldt) _get_base( ((char *)&(ldt)) ) - /* * Load a segment. Fall back on loading the zero * segment if something goes wrong.. -- cgit v1.1 From 5fe9fe3c6f9a1ae7aa224bb7a66eb9aad9e4abef Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:55 -0800 Subject: [PATCH] x86: Pnp byte granularity The one remaining caller of set_limit, the PnP BIOS code, calls into the PnP BIOS, passing kernel parameters in and out. These parameteres may be passed from arbitrary kernel virtual memory, so they deserve strict protection to stop a bad BIOS from smashing beyond the object size. Unfortunately, the use of set_limit was badly botching this by setting the limit in terms of pages, when it really should have byte granularity. When doing this, I discovered my BIOS had the buggy code during the "get system device node" call: mov ax, es:[bx] Which is harmless, but has a trivial workaround. Signed-off-by: Zachary Amsden Cc: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/head.S | 12 ++++++------ drivers/pnp/pnpbios/bioscalls.c | 5 ++++- include/asm-i386/system.h | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index 37b599f..58d2746 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S @@ -504,12 +504,12 @@ ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* 0x80 TSS descriptor */ .quad 0x0000000000000000 /* 0x88 LDT descriptor */ - /* Segments used for calling PnP BIOS */ - .quad 0x00c09a0000000000 /* 0x90 32-bit code */ - .quad 0x00809a0000000000 /* 0x98 16-bit code */ - .quad 0x0080920000000000 /* 0xa0 16-bit data */ - .quad 0x0080920000000000 /* 0xa8 16-bit data */ - .quad 0x0080920000000000 /* 0xb0 16-bit data */ + /* Segments used for calling PnP BIOS have byte granularity */ + .quad 0x00409a0000000000 /* 0x90 32-bit code */ + .quad 0x00009a0000000000 /* 0x98 16-bit code */ + .quad 0x0000920000000000 /* 0xa0 16-bit data */ + .quad 0x0000920000000000 /* 0xa8 16-bit data */ + .quad 0x0000920000000000 /* 0xb0 16-bit data */ /* * The APM segments have byte granularity and their bases diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c index 37bacfc..a721261 100644 --- a/drivers/pnp/pnpbios/bioscalls.c +++ b/drivers/pnp/pnpbios/bioscalls.c @@ -283,12 +283,15 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data) static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) { u16 status; + u16 tmp_nodenum; if (!pnp_bios_present()) return PNP_FUNCTION_NOT_SUPPORTED; if ( !boot && pnpbios_dont_use_current_config ) return PNP_FUNCTION_NOT_SUPPORTED; + tmp_nodenum = *nodenum; status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0, - nodenum, sizeof(char), data, 65536); + &tmp_nodenum, sizeof(tmp_nodenum), data, 65536); + *nodenum = tmp_nodenum; return status; } diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h index 24cc0c8..9c0593b 100644 --- a/include/asm-i386/system.h +++ b/include/asm-i386/system.h @@ -54,7 +54,7 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t" \ ); } while(0) #define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) ) -#define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1)>>12 ) +#define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1) ) /* * Load a segment. Fall back on loading the zero -- cgit v1.1 From e6a9918c9617ed21f71f2f20b45efe06822c8f00 Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:56 -0800 Subject: [PATCH] x86: Fixed pnp bios limits PnP BIOS data, code, and 32-bit entry segments all have fixed limits as well; set them in the GDT rather than adding more code. It would be nice to add these fixups to the boot GDT rather than setting the GDT for each CPU; perhaps I can wiggle this in later, but getting it in before the subsys init looks tricky. Also, make some progress on deprecating the ugly Q_SET_SEL macros. Signed-off-by: Zachary Amsden Cc: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/head.S | 12 ++++++++---- drivers/pnp/pnpbios/bioscalls.c | 15 ++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S index 58d2746..5884469 100644 --- a/arch/i386/kernel/head.S +++ b/arch/i386/kernel/head.S @@ -504,10 +504,14 @@ ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* 0x80 TSS descriptor */ .quad 0x0000000000000000 /* 0x88 LDT descriptor */ - /* Segments used for calling PnP BIOS have byte granularity */ - .quad 0x00409a0000000000 /* 0x90 32-bit code */ - .quad 0x00009a0000000000 /* 0x98 16-bit code */ - .quad 0x0000920000000000 /* 0xa0 16-bit data */ + /* + * Segments used for calling PnP BIOS have byte granularity. + * They code segments and data segments have fixed 64k limits, + * the transfer segment sizes are set at run time. + */ + .quad 0x00409a000000ffff /* 0x90 32-bit code */ + .quad 0x00009a000000ffff /* 0x98 16-bit code */ + .quad 0x000092000000ffff /* 0xa0 16-bit data */ .quad 0x0000920000000000 /* 0xa8 16-bit data */ .quad 0x0000920000000000 /* 0xb0 16-bit data */ diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c index a721261..a1f0b0b 100644 --- a/drivers/pnp/pnpbios/bioscalls.c +++ b/drivers/pnp/pnpbios/bioscalls.c @@ -58,13 +58,6 @@ __asm__( ".previous \n" ); -#define Q_SET_SEL(cpu, selname, address, size) \ -do { \ -struct desc_struct *gdt = get_cpu_gdt_table((cpu)); \ -set_base(gdt[(selname) >> 3], __va((u32)(address))); \ -set_limit(gdt[(selname) >> 3], size); \ -} while(0) - #define Q2_SET_SEL(cpu, selname, address, size) \ do { \ struct desc_struct *gdt = get_cpu_gdt_table((cpu)); \ @@ -535,8 +528,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header) struct desc_struct *gdt = get_cpu_gdt_table(i); if (!gdt) continue; - Q2_SET_SEL(i, PNP_CS32, &pnp_bios_callfunc, 64 * 1024); - Q_SET_SEL(i, PNP_CS16, header->fields.pm16cseg, 64 * 1024); - Q_SET_SEL(i, PNP_DS, header->fields.pm16dseg, 64 * 1024); - } + set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc); + set_base(gdt[GDT_ENTRY_PNPBIOS_CS16], __va(header->fields.pm16cseg)); + set_base(gdt[GDT_ENTRY_PNPBIOS_DS], __va(header->fields.pm16dseg)); + } } -- cgit v1.1 From 2891dcdc4538e8f4ce50c9d1eea457cf2d81fb5b Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:57 -0800 Subject: [PATCH] x86: Stop deleting nt Stop deleting NT bit from EFLAGS. See arch/i386/kernel/head.S line 223, which does something even better. Signed-off-by: Zachary Amsden Cc: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/cpu/common.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c index cbc3206..cca6556 100644 --- a/arch/i386/kernel/cpu/common.c +++ b/arch/i386/kernel/cpu/common.c @@ -596,11 +596,6 @@ void __devinit cpu_init(void) load_idt(&idt_descr); /* - * Delete NT - */ - __asm__("pushfl ; andl $0xffffbfff,(%esp) ; popfl"); - - /* * Set up and load the per-CPU TSS and LDT */ atomic_inc(&init_mm.mm_count); -- cgit v1.1 From 92f17f0171e864a2cbe448c5b7b473e72a7d27b8 Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:58 -0800 Subject: [PATCH] x86: Apm is on cpu zero only APM BIOS code has a protective wrapper that runs it only on CPU zero. Thus, no need to set APM BIOS segments in the GDT for other CPUs. Signed-off-by: Zachary Amsden Acked-by: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/apm.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index 45199bb..d0b4880 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c @@ -2222,8 +2222,8 @@ static struct dmi_system_id __initdata apm_dmi_table[] = { static int __init apm_init(void) { struct proc_dir_entry *apm_proc; + struct desc_struct *gdt; int ret; - int i; dmi_check_system(apm_dmi_table); @@ -2314,18 +2314,17 @@ static int __init apm_init(void) * not restrict themselves to their claimed limit. When this happens, * they will cause a segmentation violation in the kernel at boot time. * Most BIOS's, however, will respect a 64k limit, so we use that. + * + * Note we only set APM segments on CPU zero, since we pin the APM + * code to that CPU. */ - for (i = 0; i < NR_CPUS; i++) { - struct desc_struct *gdt = get_cpu_gdt_table(i); - if (!gdt) - continue; - set_base(gdt[APM_CS >> 3], - __va((unsigned long)apm_info.bios.cseg << 4)); - set_base(gdt[APM_CS_16 >> 3], - __va((unsigned long)apm_info.bios.cseg_16 << 4)); - set_base(gdt[APM_DS >> 3], - __va((unsigned long)apm_info.bios.dseg << 4)); - } + gdt = get_cpu_gdt_table(0); + set_base(gdt[APM_CS >> 3], + __va((unsigned long)apm_info.bios.cseg << 4)); + set_base(gdt[APM_CS_16 >> 3], + __va((unsigned long)apm_info.bios.cseg_16 << 4)); + set_base(gdt[APM_DS >> 3], + __va((unsigned long)apm_info.bios.dseg << 4)); apm_proc = create_proc_info_entry("apm", 0, NULL, apm_get_info); if (apm_proc) -- cgit v1.1 From 2684927c6b938ec7a679891e0ec1fa0709c521bd Mon Sep 17 00:00:00 2001 From: Zachary Amsden Date: Fri, 6 Jan 2006 00:11:59 -0800 Subject: [PATCH] x86: Deprecate useless bug Remove the "temporary debugging check" which has managed to live for quite some time, and is clearly unneeded. The mm can never be live at this point, so clearly checking the LDT in the mm->context is redundant as well. Signed-off-by: Zachary Amsden Cc: "Seth, Rohit" Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/process.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index 6081a10..45e7f0a 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c @@ -402,17 +402,7 @@ void flush_thread(void) void release_thread(struct task_struct *dead_task) { - if (dead_task->mm) { - // temporary debugging check - if (dead_task->mm->context.size) { - printk("WARNING: dead process %8s still has LDT? <%p/%d>\n", - dead_task->comm, - dead_task->mm->context.ldt, - dead_task->mm->context.size); - BUG(); - } - } - + BUG_ON(dead_task->mm); release_vm86_irqs(dead_task); } -- cgit v1.1 From d89c145c0344fe2180336af6a309a59a8bc8c1c0 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 6 Jan 2006 00:11:59 -0800 Subject: [PATCH] x86: handle -Wsign-compare in bitops Make i386's find_first_bit() use an unsigned integer as a counter to avoid getting warnings when -Wsign-compare is given. Signed-Off-By: David Howells Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-i386/bitops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index 4807aa1..26eb981 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -332,9 +332,9 @@ static inline unsigned long __ffs(unsigned long word) * Returns the bit-number of the first set bit, not the number of the byte * containing a bit. */ -static inline int find_first_bit(const unsigned long *addr, unsigned size) +static inline unsigned find_first_bit(const unsigned long *addr, unsigned size) { - int x = 0; + unsigned x = 0; while (x < size) { unsigned long val = *addr++; -- cgit v1.1 From 37b73c828185731f6236a6387c02d7b08c150810 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Fri, 6 Jan 2006 00:12:01 -0800 Subject: [PATCH] x86/x86_64: mark rodata section read only: generic infrastructure Generic prep-work for marking the .rodata section readonly: * Align the rodata section at 4Kb boundary * call the mark_rodata_ro() function when available Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Signed-off-by: Adrian Bunk Cc: Andi Kleen Signed-off-by: Jesper Juhl Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-generic/vmlinux.lds.h | 4 ++++ init/main.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 094d491..35de20c 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -10,6 +10,8 @@ #define ALIGN_FUNCTION() . = ALIGN(8) #define RODATA \ + . = ALIGN(4096); \ + __start_rodata = .; \ .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ *(.rodata) *(.rodata.*) \ *(__vermagic) /* Kernel version magic */ \ @@ -74,6 +76,8 @@ __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ *(__ksymtab_strings) \ } \ + __end_rodata = .; \ + . = ALIGN(4096); \ \ /* Built-in module parameters. */ \ __param : AT(ADDR(__param) - LOAD_OFFSET) { \ diff --git a/init/main.c b/init/main.c index 54aaf56..2ed3638 100644 --- a/init/main.c +++ b/init/main.c @@ -52,6 +52,7 @@ #include #include #include +#include /* * This is one of the first .c files built. Error out early @@ -99,6 +100,9 @@ extern void acpi_early_init(void); #else static inline void acpi_early_init(void) { } #endif +#ifndef CONFIG_DEBUG_RODATA +static inline void mark_rodata_ro(void) { } +#endif #ifdef CONFIG_TC extern void tc_init(void); @@ -708,6 +712,7 @@ static int init(void * unused) */ free_initmem(); unlock_kernel(); + mark_rodata_ro(); system_state = SYSTEM_RUNNING; numa_default_policy(); -- cgit v1.1 From 63aaf3086baea7b94c218053af8237f9dbac5d05 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Fri, 6 Jan 2006 00:12:02 -0800 Subject: [PATCH] x86/x86_64: mark rodata section read only: x86 parts x86 specific parts to make the .rodata section read only Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Signed-off-by: Adrian Bunk Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/Kconfig.debug | 10 ++++++++++ arch/i386/mm/init.c | 24 ++++++++++++++++++++++++ include/asm-i386/cacheflush.h | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/arch/i386/Kconfig.debug b/arch/i386/Kconfig.debug index c48b424..bf32ecc 100644 --- a/arch/i386/Kconfig.debug +++ b/arch/i386/Kconfig.debug @@ -42,6 +42,16 @@ config DEBUG_PAGEALLOC This results in a large slowdown, but helps to find certain types of memory corruptions. +config DEBUG_RODATA + bool "Write protect kernel read-only data structures" + depends on DEBUG_KERNEL + help + Mark the kernel read-only data as write-protected in the pagetables, + in order to catch accidental (and incorrect) writes to such const + data. This option may have a slight performance impact because a + portion of the kernel code won't be covered by a 2MB TLB anymore. + If in doubt, say "N". + config 4KSTACKS bool "Use 4Kb for kernel stacks instead of 8Kb" depends on DEBUG_KERNEL diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c index 06e26f0..7df494b 100644 --- a/arch/i386/mm/init.c +++ b/arch/i386/mm/init.c @@ -735,6 +735,30 @@ void free_initmem(void) printk (KERN_INFO "Freeing unused kernel memory: %dk freed\n", (__init_end - __init_begin) >> 10); } +#ifdef CONFIG_DEBUG_RODATA + +extern char __start_rodata, __end_rodata; +void mark_rodata_ro(void) +{ + unsigned long addr = (unsigned long)&__start_rodata; + + for (; addr < (unsigned long)&__end_rodata; addr += PAGE_SIZE) + change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RO); + + printk ("Write protecting the kernel read-only data: %luk\n", + (unsigned long)(&__end_rodata - &__start_rodata) >> 10); + + /* + * change_page_attr() requires a global_flush_tlb() call after it. + * We do this after the printk so that if something went wrong in the + * change, the printk gets out at least to give a better debug hint + * of who is the culprit. + */ + global_flush_tlb(); +} +#endif + + #ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem(unsigned long start, unsigned long end) { diff --git a/include/asm-i386/cacheflush.h b/include/asm-i386/cacheflush.h index 2ea36de..7199f7b 100644 --- a/include/asm-i386/cacheflush.h +++ b/include/asm-i386/cacheflush.h @@ -31,4 +31,8 @@ int change_page_attr(struct page *page, int numpages, pgprot_t prot); void kernel_map_pages(struct page *page, int numpages, int enable); #endif +#ifdef CONFIG_DEBUG_RODATA +void mark_rodata_ro(void); +#endif + #endif /* _I386_CACHEFLUSH_H */ -- cgit v1.1 From c728252c7a072628bd3932ff87943d1e12423359 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Fri, 6 Jan 2006 00:12:03 -0800 Subject: [PATCH] x86/x86_64: mark rodata section read only: generic x86-64 bugfix Bug fix required for the .rodata work on x86-64: when change_page_attr() and friends need to break up a 2Mb page into 4Kb pages, it always set the NX bit on the PMD, which causes the cpu to consider the entire 2Mb region to be NX regardless of the actual PTE perms. This is fine in general, with one big exception: the 2Mb page that covers the last part of the kernel .text! The fix is to not invent a new permission for the new PMD entry, but to just inherit the existing one minus the PSE bit. Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/x86_64/mm/pageattr.c | 9 +++++++-- include/asm-x86_64/pgtable.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/mm/pageattr.c b/arch/x86_64/mm/pageattr.c index b90e8fe..35f1f1a 100644 --- a/arch/x86_64/mm/pageattr.c +++ b/arch/x86_64/mm/pageattr.c @@ -128,6 +128,7 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot, pte_t *kpte; struct page *kpte_page; unsigned kpte_flags; + pgprot_t ref_prot2; kpte = lookup_address(address); if (!kpte) return 0; kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK); @@ -140,10 +141,14 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot, * split_large_page will take the reference for this change_page_attr * on the split page. */ - struct page *split = split_large_page(address, prot, ref_prot); + + struct page *split; + ref_prot2 = __pgprot(pgprot_val(pte_pgprot(*lookup_address(address))) & ~(1<<_PAGE_BIT_PSE)); + + split = split_large_page(address, prot, ref_prot2); if (!split) return -ENOMEM; - set_pte(kpte,mk_pte(split, ref_prot)); + set_pte(kpte,mk_pte(split, ref_prot2)); kpte_page = split; } get_page(kpte_page); diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h index ecf58c7..02888d7 100644 --- a/include/asm-x86_64/pgtable.h +++ b/include/asm-x86_64/pgtable.h @@ -122,6 +122,8 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long #define pte_same(a, b) ((a).pte == (b).pte) +#define pte_pgprot(a) (__pgprot((a).pte & ~PHYSICAL_PAGE_MASK)) + #define PMD_SIZE (1UL << PMD_SHIFT) #define PMD_MASK (~(PMD_SIZE-1)) #define PUD_SIZE (1UL << PUD_SHIFT) -- cgit v1.1 From 67df197b1a07944c2e0e40ded3d4fd07d108e110 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Fri, 6 Jan 2006 00:12:04 -0800 Subject: [PATCH] x86/x86_64: mark rodata section read-only: x86-64 support x86-64 specific parts to make the .rodata section read only Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/x86_64/Kconfig.debug | 10 ++++++++++ arch/x86_64/mm/init.c | 23 +++++++++++++++++++++++ include/asm-x86_64/cacheflush.h | 4 ++++ 3 files changed, 37 insertions(+) diff --git a/arch/x86_64/Kconfig.debug b/arch/x86_64/Kconfig.debug index e2c6e64a..fcb06a5 100644 --- a/arch/x86_64/Kconfig.debug +++ b/arch/x86_64/Kconfig.debug @@ -9,6 +9,16 @@ config INIT_DEBUG Fill __init and __initdata at the end of boot. This helps debugging illegal uses of __init and __initdata after initialization. +config DEBUG_RODATA + bool "Write protect kernel read-only data structures" + depends on DEBUG_KERNEL + help + Mark the kernel read-only data as write-protected in the pagetables, + in order to catch accidental (and incorrect) writes to such const data. + This option may have a slight performance impact because a portion + of the kernel code won't be covered by a 2MB TLB anymore. + If in doubt, say "N". + config IOMMU_DEBUG depends on GART_IOMMU && DEBUG_KERNEL bool "Enable IOMMU debugging" diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c index c016dfe..1faae5f 100644 --- a/arch/x86_64/mm/init.c +++ b/arch/x86_64/mm/init.c @@ -498,6 +498,29 @@ void free_initmem(void) printk ("Freeing unused kernel memory: %luk freed\n", (__init_end - __init_begin) >> 10); } +#ifdef CONFIG_DEBUG_RODATA + +extern char __start_rodata, __end_rodata; +void mark_rodata_ro(void) +{ + unsigned long addr = (unsigned long)&__start_rodata; + + for (; addr < (unsigned long)&__end_rodata; addr += PAGE_SIZE) + change_page_attr_addr(addr, 1, PAGE_KERNEL_RO); + + printk ("Write protecting the kernel read-only data: %luk\n", + (&__end_rodata - &__start_rodata) >> 10); + + /* + * change_page_attr_addr() requires a global_flush_tlb() call after it. + * We do this after the printk so that if something went wrong in the + * change, the printk gets out at least to give a better debug hint + * of who is the culprit. + */ + global_flush_tlb(); +} +#endif + #ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem(unsigned long start, unsigned long end) { diff --git a/include/asm-x86_64/cacheflush.h b/include/asm-x86_64/cacheflush.h index b3189fb..d32f7f5 100644 --- a/include/asm-x86_64/cacheflush.h +++ b/include/asm-x86_64/cacheflush.h @@ -27,4 +27,8 @@ void global_flush_tlb(void); int change_page_attr(struct page *page, int numpages, pgprot_t prot); int change_page_attr_addr(unsigned long addr, int numpages, pgprot_t prot); +#ifdef CONFIG_DEBUG_RODATA +void mark_rodata_ro(void); +#endif + #endif /* _X8664_CACHEFLUSH_H */ -- cgit v1.1 From bb152f53120d66c98c1f16518407df6a84f23714 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven Date: Fri, 6 Jan 2006 00:12:05 -0800 Subject: [PATCH] x86/x86_64: mark rodata section read-only: make some datastructures const Mark some key kernel datastructures readonly. This patch was previously posted on Jun 28th but was back then not merged because nothing was enforcing rodata anyway.. well that changed now :) Patch by Christoph Lameter and Dave Jones Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/entry.S | 1 + arch/i386/kernel/syscall_table.S | 1 - arch/x86_64/ia32/ia32entry.S | 2 +- arch/x86_64/kernel/syscall.c | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S index e50b9315..607c060 100644 --- a/arch/i386/kernel/entry.S +++ b/arch/i386/kernel/entry.S @@ -657,6 +657,7 @@ ENTRY(spurious_interrupt_bug) pushl $do_spurious_interrupt_bug jmp error_code +.section .rodata,"a" #include "syscall_table.S" syscall_table_size=(.-sys_call_table) diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S index 9b21a31..f7ba4ac 100644 --- a/arch/i386/kernel/syscall_table.S +++ b/arch/i386/kernel/syscall_table.S @@ -1,4 +1,3 @@ -.data ENTRY(sys_call_table) .long sys_restart_syscall /* 0 - old "setup()" system call, used for restarting */ .long sys_exit diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S index e0eb0c7..df0773c 100644 --- a/arch/x86_64/ia32/ia32entry.S +++ b/arch/x86_64/ia32/ia32entry.S @@ -341,7 +341,7 @@ ENTRY(ia32_ptregs_common) jmp ia32_sysret /* misbalances the return cache */ CFI_ENDPROC - .data + .section .rodata,"a" .align 8 .globl ia32_sys_call_table ia32_sys_call_table: diff --git a/arch/x86_64/kernel/syscall.c b/arch/x86_64/kernel/syscall.c index e263685..7c176b3 100644 --- a/arch/x86_64/kernel/syscall.c +++ b/arch/x86_64/kernel/syscall.c @@ -19,7 +19,7 @@ typedef void (*sys_call_ptr_t)(void); extern void sys_ni_syscall(void); -sys_call_ptr_t sys_call_table[__NR_syscall_max+1] __cacheline_aligned = { +const sys_call_ptr_t sys_call_table[__NR_syscall_max+1] = { /* Smells like a like a compiler bug -- it doesn't work when the & below is removed. */ [0 ... __NR_syscall_max] = &sys_ni_syscall, #include -- cgit v1.1 From 215c3409eed16c89b6d11ea1126bd9d4f36b9afd Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 6 Jan 2006 00:12:06 -0800 Subject: [PATCH] i386 sparsemem for single node systems Allow SPARSEMEM to be enabled on non-numa x86 systems. This is made dependant on EXPERIMENTAL also being set. When an in-tree user (such as simulated numa) exists it should be made dependant on that. The plan is to have no options and no selector as normal when !EXPERIMENTAL. When EXPERIMENTAL we enable the FLATMEM and SPARSEMEM options for X86_PC whilst maintaining DISCONTIGMEM and SPARSEMEM for NUMA. Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/Kconfig | 8 ++++++-- arch/i386/kernel/setup.c | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig index 6004bb0..968fabd 100644 --- a/arch/i386/Kconfig +++ b/arch/i386/Kconfig @@ -464,7 +464,6 @@ config NUMA depends on SMP && HIGHMEM64G && (X86_NUMAQ || X86_GENERICARCH || (X86_SUMMIT && ACPI)) default n if X86_PC default y if (X86_NUMAQ || X86_SUMMIT) - select SPARSEMEM_STATIC # Need comments to help the hapless user trying to turn on NUMA support comment "NUMA (NUMA-Q) requires SMP, 64GB highmem support" @@ -493,6 +492,10 @@ config HAVE_ARCH_ALLOC_REMAP depends on NUMA default y +config ARCH_FLATMEM_ENABLE + def_bool y + depends on (ARCH_SELECT_MEMORY_MODEL && X86_PC) + config ARCH_DISCONTIGMEM_ENABLE def_bool y depends on NUMA @@ -503,7 +506,8 @@ config ARCH_DISCONTIGMEM_DEFAULT config ARCH_SPARSEMEM_ENABLE def_bool y - depends on NUMA + depends on (NUMA || (X86_PC && EXPERIMENTAL)) + select SPARSEMEM_STATIC config ARCH_SELECT_MEMORY_MODEL def_bool y diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index fdfcb0c..27c956d 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c @@ -954,6 +954,12 @@ efi_find_max_pfn(unsigned long start, unsigned long end, void *arg) return 0; } +static int __init +efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg) +{ + memory_present(0, start, end); + return 0; +} /* * Find the highest page frame number we have available @@ -965,6 +971,7 @@ void __init find_max_pfn(void) max_pfn = 0; if (efi_enabled) { efi_memmap_walk(efi_find_max_pfn, &max_pfn); + efi_memmap_walk(efi_memory_present_wrapper, NULL); return; } @@ -979,6 +986,7 @@ void __init find_max_pfn(void) continue; if (end > max_pfn) max_pfn = end; + memory_present(0, start, end); } } -- cgit v1.1 From c898ec16e83331abde39118e22e9e38335bbb950 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Fri, 6 Jan 2006 00:12:07 -0800 Subject: [PATCH] allow flatmem to be disabled when only sparsemem is implemented On architectures that implement sparsemem but not discontigmem we want to be able to hide the flatmem option in some cases. On ppc64 for example, when we select NUMA we must not select flatmem. Signed-off-by: Anton Blanchard Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/Kconfig b/mm/Kconfig index 21eb51d..b3db11f 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -11,7 +11,7 @@ choice config FLATMEM_MANUAL bool "Flat Memory" - depends on !ARCH_DISCONTIGMEM_ENABLE || ARCH_FLATMEM_ENABLE + depends on !(ARCH_DISCONTIGMEM_ENABLE || ARCH_SPARSEMEM_ENABLE) || ARCH_FLATMEM_ENABLE help This option allows you to change some of the ways that Linux manages its memory internally. Most users will -- cgit v1.1 From 1855a2c4ce708b823b8b824f8b12937b45f5462a Mon Sep 17 00:00:00 2001 From: Ashok Raj Date: Fri, 6 Jan 2006 00:12:08 -0800 Subject: [PATCH] x86: convert bigsmp to use flat physical mode When we bring up a new CPU via INIT/startup IPI messages, the CPU that's coming up sends a xTPR message to the chipset. Intel chipsets (at least) don't provide any architectural guarantee on what the chipset will do with this message. For example, the E850x chipsets uses this xTPR message to interpret the interrupt operating mode of the platform. When the CPU coming online sends this message, it always indicates that it is in logical flat mode. For the CPU hotplug case, the platform may already be functioning in cluster APIC mode at this time, the chipset can get confused and mishandle I/O device and IPI interrupt routing. The situation eventually gets corrected when the new CPU sends another xTPR update when we switch it to cluster mode, but there's a window during which the chipset may be in an inconsistent state. This patch avoids this problem by using the flat physical interrupt delivery mode instead of cluster mode for bigsmp (>8 cpu) support. Signed-off-by: Ashok Raj Signed-off-by: Venkatesh Pallipadi Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-i386/mach-bigsmp/mach_apic.h | 79 +++++++++++++---------------- include/asm-i386/mach-bigsmp/mach_apicdef.h | 4 +- 2 files changed, 38 insertions(+), 45 deletions(-) diff --git a/include/asm-i386/mach-bigsmp/mach_apic.h b/include/asm-i386/mach-bigsmp/mach_apic.h index ba936d4..18b19a7 100644 --- a/include/asm-i386/mach-bigsmp/mach_apic.h +++ b/include/asm-i386/mach-bigsmp/mach_apic.h @@ -1,17 +1,10 @@ #ifndef __ASM_MACH_APIC_H #define __ASM_MACH_APIC_H -#include - -#define SEQUENTIAL_APICID -#ifdef SEQUENTIAL_APICID -#define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\ - ((phys_apic<<2) & (~0xf)) ) -#elif CLUSTERED_APICID -#define xapic_phys_to_log_apicid(phys_apic) ( (1ul << ((phys_apic) & 0x3)) |\ - ((phys_apic) & (~0xf)) ) -#endif - -#define NO_BALANCE_IRQ (1) + + +extern u8 bios_cpu_apicid[]; + +#define xapic_phys_to_log_apicid(cpu) (bios_cpu_apicid[cpu]) #define esr_disable (1) static inline int apic_id_registered(void) @@ -19,7 +12,6 @@ static inline int apic_id_registered(void) return (1); } -#define APIC_DFR_VALUE (APIC_DFR_CLUSTER) /* Round robin the irqs amoung the online cpus */ static inline cpumask_t target_cpus(void) { @@ -32,29 +24,34 @@ static inline cpumask_t target_cpus(void) } while (cpu >= NR_CPUS); return cpumask_of_cpu(cpu); } -#define TARGET_CPUS (target_cpus()) -#define INT_DELIVERY_MODE dest_Fixed -#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */ +#undef APIC_DEST_LOGICAL +#define APIC_DEST_LOGICAL 0 +#define TARGET_CPUS (target_cpus()) +#define APIC_DFR_VALUE (APIC_DFR_FLAT) +#define INT_DELIVERY_MODE (dest_Fixed) +#define INT_DEST_MODE (0) /* phys delivery to target proc */ +#define NO_BALANCE_IRQ (0) +#define WAKE_SECONDARY_VIA_INIT + static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid) { - return 0; + return (0); } -/* we don't use the phys_cpu_present_map to indicate apicid presence */ -static inline unsigned long check_apicid_present(int bit) +static inline unsigned long check_apicid_present(int bit) { - return 1; + return (1); } -#define apicid_cluster(apicid) (apicid & 0xF0) - -static inline unsigned long calculate_ldr(unsigned long old) +static inline unsigned long calculate_ldr(int cpu) { - unsigned long id; - id = xapic_phys_to_log_apicid(hard_smp_processor_id()); - return ((old & ~APIC_LDR_MASK) | SET_APIC_LOGICAL_ID(id)); + unsigned long val, id; + val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; + id = xapic_phys_to_log_apicid(cpu); + val |= SET_APIC_LOGICAL_ID(id); + return val; } /* @@ -67,37 +64,35 @@ static inline unsigned long calculate_ldr(unsigned long old) static inline void init_apic_ldr(void) { unsigned long val; + int cpu = smp_processor_id(); apic_write_around(APIC_DFR, APIC_DFR_VALUE); - val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; - val = calculate_ldr(val); + val = calculate_ldr(cpu); apic_write_around(APIC_LDR, val); } static inline void clustered_apic_check(void) { printk("Enabling APIC mode: %s. Using %d I/O APICs\n", - "Cluster", nr_ioapics); + "Physflat", nr_ioapics); } static inline int multi_timer_check(int apic, int irq) { - return 0; + return (0); } static inline int apicid_to_node(int logical_apicid) { - return 0; + return (0); } -extern u8 bios_cpu_apicid[]; - static inline int cpu_present_to_apicid(int mps_cpu) { if (mps_cpu < NR_CPUS) - return (int)bios_cpu_apicid[mps_cpu]; - else - return BAD_APICID; + return (int) bios_cpu_apicid[mps_cpu]; + + return BAD_APICID; } static inline physid_mask_t apicid_to_cpu_present(int phys_apicid) @@ -109,10 +104,10 @@ extern u8 cpu_2_logical_apicid[]; /* Mapping from cpu number to logical apicid */ static inline int cpu_to_logical_apicid(int cpu) { - if (cpu >= NR_CPUS) - return BAD_APICID; - return (int)cpu_2_logical_apicid[cpu]; - } + if (cpu >= NR_CPUS) + return BAD_APICID; + return cpu_physical_id(cpu); +} static inline int mpc_apic_id(struct mpc_config_processor *m, struct mpc_config_translation *translation_record) @@ -128,11 +123,9 @@ static inline int mpc_apic_id(struct mpc_config_processor *m, static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) { /* For clustered we don't have a good way to do this yet - hack */ - return physids_promote(0xFUL); + return physids_promote(0xFFL); } -#define WAKE_SECONDARY_VIA_INIT - static inline void setup_portio_remap(void) { } diff --git a/include/asm-i386/mach-bigsmp/mach_apicdef.h b/include/asm-i386/mach-bigsmp/mach_apicdef.h index 23e58b3..a58ab5a 100644 --- a/include/asm-i386/mach-bigsmp/mach_apicdef.h +++ b/include/asm-i386/mach-bigsmp/mach_apicdef.h @@ -1,11 +1,11 @@ #ifndef __ASM_MACH_APICDEF_H #define __ASM_MACH_APICDEF_H -#define APIC_ID_MASK (0x0F<<24) +#define APIC_ID_MASK (0xFF<<24) static inline unsigned get_apic_id(unsigned long x) { - return (((x)>>24)&0x0F); + return (((x)>>24)&0xFF); } #define GET_APIC_ID(x) get_apic_id(x) -- cgit v1.1 From e72c8585e09f127a69a1608bb5ccd1e3fc0dd41e Mon Sep 17 00:00:00 2001 From: Ashok Raj Date: Fri, 6 Jan 2006 00:12:09 -0800 Subject: [PATCH] make bigsmp the default mode if CONFIG_HOTPLUG_CPU If we are using hotplug enabled kernel, then make bigsmp the default mode. Signed-off-by: Ashok Raj Signed-off-by: Venkatesh Pallipadi Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/mpparse.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c index 1ca5269b1..91a6401 100644 --- a/arch/i386/kernel/mpparse.c +++ b/arch/i386/kernel/mpparse.c @@ -38,6 +38,12 @@ int smp_found_config; unsigned int __initdata maxcpus = NR_CPUS; +#ifdef CONFIG_HOTPLUG_CPU +#define CPU_HOTPLUG_ENABLED (1) +#else +#define CPU_HOTPLUG_ENABLED (0) +#endif + /* * Various Linux-internal data structures created from the * MP-table. @@ -219,14 +225,18 @@ static void __devinit MP_processor_info (struct mpc_config_processor *m) cpu_set(num_processors, cpu_possible_map); num_processors++; - if ((num_processors > 8) && - ((APIC_XAPIC(ver) && - (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)) || - (boot_cpu_data.x86_vendor == X86_VENDOR_AMD))) - def_to_bigsmp = 1; - else - def_to_bigsmp = 0; - + if (CPU_HOTPLUG_ENABLED || (num_processors > 8)) { + switch (boot_cpu_data.x86_vendor) { + case X86_VENDOR_INTEL: + if (!APIC_XAPIC(ver)) { + def_to_bigsmp = 0; + break; + } + /* If P4 and above fall through */ + case X86_VENDOR_AMD: + def_to_bigsmp = 1; + } + } bios_cpu_apicid[num_processors - 1] = m->mpc_apicid; } -- cgit v1.1 From f8af095d3a4c8300b4e63ee2c4bb198b565d9431 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Fri, 6 Jan 2006 00:12:10 -0800 Subject: [PATCH] x86: change_page_attr() fix The 'make rodata read-only' patch in -mm exposes a latent bug in the 32-bit change_page_attr() function, which causes certain CPUs (Those with NX basically) to reboot instantly after pages are marked read-only. The same bug got fixed a while back on x86-64, but never got propagated to i386. Stuart Hayes from Dell also picked up on this last June, but it never got fixed, as the only thing affected by it aparently was the nvidia driver. Blatantly stealing description from his post.. "It doesn't appear to be fixed (in the i386 arch). The change_page_attr()/split_large_page() code will still still set all the 4K PTEs to PAGE_KERNEL (setting the _PAGE_NX bit) when a large page needs to be split. This wouldn't be a problem for the bulk of the kernel memory, but there are pages in the lower 4MB of memory that's free, and are part of large executable pages that also contain kernel code. If change_page_attr() is called on these, it will set the _PAGE_NX bit on the whole 2MB region that was covered by the large page, causing a large chunk of kernel code to be non-executable." Signed-off-by: Arjan van de Ven Signed-off-by: Dave Jones Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/mm/pageattr.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c index f600fc2..c30a16d 100644 --- a/arch/i386/mm/pageattr.c +++ b/arch/i386/mm/pageattr.c @@ -13,6 +13,7 @@ #include #include #include +#include static DEFINE_SPINLOCK(cpa_lock); static struct list_head df_list = LIST_HEAD_INIT(df_list); @@ -36,7 +37,8 @@ pte_t *lookup_address(unsigned long address) return pte_offset_kernel(pmd, address); } -static struct page *split_large_page(unsigned long address, pgprot_t prot) +static struct page *split_large_page(unsigned long address, pgprot_t prot, + pgprot_t ref_prot) { int i; unsigned long addr; @@ -54,7 +56,7 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot) pbase = (pte_t *)page_address(base); for (i = 0; i < PTRS_PER_PTE; i++, addr += PAGE_SIZE) { set_pte(&pbase[i], pfn_pte(addr >> PAGE_SHIFT, - addr == address ? prot : PAGE_KERNEL)); + addr == address ? prot : ref_prot)); } return base; } @@ -98,11 +100,18 @@ static void set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte) */ static inline void revert_page(struct page *kpte_page, unsigned long address) { - pte_t *linear = (pte_t *) + pgprot_t ref_prot; + pte_t *linear; + + ref_prot = + ((address & LARGE_PAGE_MASK) < (unsigned long)&_etext) + ? PAGE_KERNEL_LARGE_EXEC : PAGE_KERNEL_LARGE; + + linear = (pte_t *) pmd_offset(pud_offset(pgd_offset_k(address), address), address); set_pmd_pte(linear, address, pfn_pte((__pa(address) & LARGE_PAGE_MASK) >> PAGE_SHIFT, - PAGE_KERNEL_LARGE)); + ref_prot)); } static int @@ -123,10 +132,16 @@ __change_page_attr(struct page *page, pgprot_t prot) if ((pte_val(*kpte) & _PAGE_PSE) == 0) { set_pte_atomic(kpte, mk_pte(page, prot)); } else { - struct page *split = split_large_page(address, prot); + pgprot_t ref_prot; + struct page *split; + + ref_prot = + ((address & LARGE_PAGE_MASK) < (unsigned long)&_etext) + ? PAGE_KERNEL_EXEC : PAGE_KERNEL; + split = split_large_page(address, prot, ref_prot); if (!split) return -ENOMEM; - set_pmd_pte(kpte,address,mk_pte(split, PAGE_KERNEL)); + set_pmd_pte(kpte,address,mk_pte(split, ref_prot)); kpte_page = split; } get_page(kpte_page); -- cgit v1.1 From e31b88ba49460653bab87423287bb68743f5de5c Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Fri, 6 Jan 2006 00:12:11 -0800 Subject: [PATCH] x86: missing printk newline in apic boot option parser Missing newline in printk. Signed-off-by: Dave Jones Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c index 496a2c9..d8f94e7 100644 --- a/arch/i386/kernel/apic.c +++ b/arch/i386/kernel/apic.c @@ -721,7 +721,7 @@ static int __init apic_set_verbosity(char *str) apic_verbosity = APIC_VERBOSE; else printk(KERN_WARNING "APIC Verbosity level %s not recognised" - " use apic=verbose or apic=debug", str); + " use apic=verbose or apic=debug\n", str); return 0; } -- cgit v1.1 From d832245d7cc16d50b29c1b708ccbe9c75ac376a3 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 6 Jan 2006 00:12:12 -0800 Subject: [PATCH] x86: fls() in asm There is a single instruction on i386 to find largest set bit; so it makes sense to use it (like we use bfs for ffs()). Signed-off-by: Stephen Hemminger Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-i386/bitops.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h index 26eb981..65679ac 100644 --- a/include/asm-i386/bitops.h +++ b/include/asm-i386/bitops.h @@ -367,11 +367,6 @@ static inline unsigned long ffz(unsigned long word) return word; } -/* - * fls: find last bit set. - */ - -#define fls(x) generic_fls(x) #define fls64(x) generic_fls64(x) #ifdef __KERNEL__ @@ -415,6 +410,23 @@ static inline int ffs(int x) } /** + * fls - find last bit set + * @x: the word to search + * + * This is defined the same way as ffs. + */ +static inline int fls(int x) +{ + int r; + + __asm__("bsrl %1,%0\n\t" + "jnz 1f\n\t" + "movl $-1,%0\n" + "1:" : "=r" (r) : "rm" (x)); + return r+1; +} + +/** * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh * -- cgit v1.1 From 6926d570b6159c6a7f65921ca119a675b12fef86 Mon Sep 17 00:00:00 2001 From: Daniel Marjamaki Date: Fri, 6 Jan 2006 00:12:12 -0800 Subject: [PATCH] arch/i386/kernel/msr.c: removed unused variable Removed the unused variable "rv". Signed-off-by: Daniel Marjamaki Signed-off-by: H. Peter Anvin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/msr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c index 44470fe..1d0a55e 100644 --- a/arch/i386/kernel/msr.c +++ b/arch/i386/kernel/msr.c @@ -172,7 +172,6 @@ static ssize_t msr_read(struct file *file, char __user * buf, { u32 __user *tmp = (u32 __user *) buf; u32 data[2]; - size_t rv; u32 reg = *ppos; int cpu = iminor(file->f_dentry->d_inode); int err; @@ -180,7 +179,7 @@ static ssize_t msr_read(struct file *file, char __user * buf, if (count % 8) return -EINVAL; /* Invalid chunk size */ - for (rv = 0; count; count -= 8) { + for (; count; count -= 8) { err = do_rdmsr(cpu, reg, &data[0], &data[1]); if (err) return err; -- cgit v1.1 From 6b7f430ee0a269464aa29159eb464e647ca313d3 Mon Sep 17 00:00:00 2001 From: Daniel Marjamaki Date: Fri, 6 Jan 2006 00:12:13 -0800 Subject: [PATCH] arch/i386/kernel/cpuid.c: unused variable Removed the unused variable "rv". Signed-off-by: Daniel Marjamaki Signed-off-by: H. Peter Anvin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/cpuid.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c index 13bae79..006141d 100644 --- a/arch/i386/kernel/cpuid.c +++ b/arch/i386/kernel/cpuid.c @@ -117,14 +117,13 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, { char __user *tmp = buf; u32 data[4]; - size_t rv; u32 reg = *ppos; int cpu = iminor(file->f_dentry->d_inode); if (count % 16) return -EINVAL; /* Invalid chunk size */ - for (rv = 0; count; count -= 16) { + for (; count; count -= 16) { do_cpuid(cpu, reg, data); if (copy_to_user(tmp, &data, 16)) return -EFAULT; -- cgit v1.1 From f90b8116032f4216d260e31f966a3585319387ac Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Fri, 6 Jan 2006 00:12:14 -0800 Subject: [PATCH] Base support for AMD Geode GX/LX processors Provide basic support for the AMD Geode GX and LX processors. Signed-off-by: Jordan Crouse Cc: Alan Cox Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- MAINTAINERS | 7 +++++++ arch/i386/Kconfig.cpu | 14 ++++++++++---- arch/i386/kernel/cpu/amd.c | 7 ++++++- arch/i386/kernel/cpu/cyrix.c | 27 ++++++++++++++++++++++++++- include/asm-i386/module.h | 4 +++- include/linux/pci_ids.h | 10 ++++++++++ 6 files changed, 62 insertions(+), 7 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index e9db0d6..cb536bb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -258,6 +258,13 @@ P: Ivan Kokshaysky M: ink@jurassic.park.msu.ru S: Maintained for 2.4; PCI support for 2.6. +AMD GEODE PROCESSOR/CHIPSET SUPPORT +P: Jordan Crouse +M: info-linux@geode.amd.com +L: info-linux@geode.amd.com +W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html +S: Supported + APM DRIVER P: Stephen Rothwell M: sfr@canb.auug.org.au diff --git a/arch/i386/Kconfig.cpu b/arch/i386/Kconfig.cpu index 53bbb3c..79603b3 100644 --- a/arch/i386/Kconfig.cpu +++ b/arch/i386/Kconfig.cpu @@ -39,6 +39,7 @@ config M386 - "Winchip-2" for IDT Winchip 2. - "Winchip-2A" for IDT Winchips with 3dNow! capabilities. - "GeodeGX1" for Geode GX1 (Cyrix MediaGX). + - "Geode GX/LX" For AMD Geode GX and LX processors. - "CyrixIII/VIA C3" for VIA Cyrix III or VIA C3. - "VIA C3-2 for VIA C3-2 "Nehemiah" (model 9 and above). @@ -171,6 +172,11 @@ config MGEODEGX1 help Select this for a Geode GX1 (Cyrix MediaGX) chip. +config MGEODE_LX + bool "Geode GX/LX" + help + Select this for AMD Geode GX and LX processors. + config MCYRIXIII bool "CyrixIII/VIA-C3" help @@ -220,8 +226,8 @@ config X86_XADD config X86_L1_CACHE_SHIFT int default "7" if MPENTIUM4 || X86_GENERIC - default "4" if X86_ELAN || M486 || M386 - default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODEGX1 + default "4" if X86_ELAN || M486 || M386 || MGEODEGX1 + default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX default "6" if MK7 || MK8 || MPENTIUMM config RWSEM_GENERIC_SPINLOCK @@ -290,12 +296,12 @@ config X86_INTEL_USERCOPY config X86_USE_PPRO_CHECKSUM bool - depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MEFFICEON + depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MEFFICEON || MGEODE_LX default y config X86_USE_3DNOW bool - depends on MCYRIXIII || MK7 + depends on MCYRIXIII || MK7 || MGEODE_LX default y config X86_OOSTORE diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c index e344ef88..e7697e0 100644 --- a/arch/i386/kernel/cpu/amd.c +++ b/arch/i386/kernel/cpu/amd.c @@ -161,8 +161,13 @@ static void __init init_amd(struct cpuinfo_x86 *c) set_bit(X86_FEATURE_K6_MTRR, c->x86_capability); break; } - break; + if (c->x86_model == 10) { + /* AMD Geode LX is model 10 */ + /* placeholder for any needed mods */ + break; + } + break; case 6: /* An Athlon/Duron */ /* Bit 15 of Athlon specific MSR 15, needs to be 0 diff --git a/arch/i386/kernel/cpu/cyrix.c b/arch/i386/kernel/cpu/cyrix.c index ff87cc2..7501597 100644 --- a/arch/i386/kernel/cpu/cyrix.c +++ b/arch/i386/kernel/cpu/cyrix.c @@ -343,6 +343,31 @@ static void __init init_cyrix(struct cpuinfo_x86 *c) } /* + * Handle National Semiconductor branded processors + */ +static void __devinit init_nsc(struct cpuinfo_x86 *c) +{ + /* There may be GX1 processors in the wild that are branded + * NSC and not Cyrix. + * + * This function only handles the GX processor, and kicks every + * thing else to the Cyrix init function above - that should + * cover any processors that might have been branded differently + * after NSC aquired Cyrix. + * + * If this breaks your GX1 horribly, please e-mail + * info-linux@ldcmail.amd.com to tell us. + */ + + /* Handle the GX (Formally known as the GX2) */ + + if (c->x86 == 5 && c->x86_model == 5) + display_cacheinfo(c); + else + init_cyrix(c); +} + +/* * Cyrix CPUs without cpuid or with cpuid not yet enabled can be detected * by the fact that they preserve the flags across the division of 5/2. * PII and PPro exhibit this behavior too, but they have cpuid available. @@ -422,7 +447,7 @@ int __init cyrix_init_cpu(void) static struct cpu_dev nsc_cpu_dev __initdata = { .c_vendor = "NSC", .c_ident = { "Geode by NSC" }, - .c_init = init_cyrix, + .c_init = init_nsc, .c_identify = generic_identify, }; diff --git a/include/asm-i386/module.h b/include/asm-i386/module.h index eb7f2b4..424661d 100644 --- a/include/asm-i386/module.h +++ b/include/asm-i386/module.h @@ -52,8 +52,10 @@ struct mod_arch_specific #define MODULE_PROC_FAMILY "CYRIXIII " #elif defined CONFIG_MVIAC3_2 #define MODULE_PROC_FAMILY "VIAC3-2 " -#elif CONFIG_MGEODEGX1 +#elif defined CONFIG_MGEODEGX1 #define MODULE_PROC_FAMILY "GEODEGX1 " +#elif defined CONFIG_MGEODE_LX +#define MODULE_PROC_FAMILY "GEODE " #else #error unknown processor family #endif diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h index 4f01710..24db724 100644 --- a/include/linux/pci_ids.h +++ b/include/linux/pci_ids.h @@ -394,6 +394,13 @@ #define PCI_DEVICE_ID_NS_87410 0xd001 #define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d +#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 +#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b +#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d +#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e +#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f +#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 + #define PCI_VENDOR_ID_TSENG 0x100c #define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 #define PCI_DEVICE_ID_TSENG_W32P_b 0x3205 @@ -496,6 +503,9 @@ #define PCI_DEVICE_ID_AMD_CS5536_IDE 0x209A +#define PCI_DEVICE_ID_AMD_LX_VIDEO 0x2081 +#define PCI_DEVICE_ID_AMD_LX_AES 0x2082 + #define PCI_VENDOR_ID_TRIDENT 0x1023 #define PCI_DEVICE_ID_TRIDENT_4DWAVE_DX 0x2000 #define PCI_DEVICE_ID_TRIDENT_4DWAVE_NX 0x2001 -- cgit v1.1 From a7a4ad0998dcd682f4968e8ec5fc1259914a1c4a Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Fri, 6 Jan 2006 00:12:15 -0800 Subject: [PATCH] Geode LX HW RNG Support Add support to hw_random for the Geode LX HRNG device. Signed-off-by: Jordan Crouse Cc: Alan Cox Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/hw_random.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random.c b/drivers/char/hw_random.c index 6f673d2..49769f5 100644 --- a/drivers/char/hw_random.c +++ b/drivers/char/hw_random.c @@ -1,4 +1,9 @@ /* + Added support for the AMD Geode LX RNG + (c) Copyright 2004-2005 Advanced Micro Devices, Inc. + + derived from + Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) (c) Copyright 2003 Red Hat Inc @@ -95,6 +100,11 @@ static unsigned int via_data_present (void); static u32 via_data_read (void); #endif +static int __init geode_init(struct pci_dev *dev); +static void geode_cleanup(void); +static unsigned int geode_data_present (void); +static u32 geode_data_read (void); + struct rng_operations { int (*init) (struct pci_dev *dev); void (*cleanup) (void); @@ -122,6 +132,7 @@ enum { rng_hw_intel, rng_hw_amd, rng_hw_via, + rng_hw_geode, }; static struct rng_operations rng_vendor_ops[] = { @@ -139,6 +150,9 @@ static struct rng_operations rng_vendor_ops[] = { /* rng_hw_via */ { via_init, via_cleanup, via_data_present, via_data_read, 1 }, #endif + + /* rng_hw_geode */ + { geode_init, geode_cleanup, geode_data_present, geode_data_read, 4 } }; /* @@ -159,6 +173,9 @@ static struct pci_device_id rng_pci_tbl[] = { { 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, { 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, + { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_geode }, + { 0, }, /* terminate list */ }; MODULE_DEVICE_TABLE (pci, rng_pci_tbl); @@ -460,6 +477,57 @@ static void via_cleanup(void) } #endif +/*********************************************************************** + * + * AMD Geode RNG operations + * + */ + +static void __iomem *geode_rng_base = NULL; + +#define GEODE_RNG_DATA_REG 0x50 +#define GEODE_RNG_STATUS_REG 0x54 + +static u32 geode_data_read(void) +{ + u32 val; + + assert(geode_rng_base != NULL); + val = readl(geode_rng_base + GEODE_RNG_DATA_REG); + return val; +} + +static unsigned int geode_data_present(void) +{ + u32 val; + + assert(geode_rng_base != NULL); + val = readl(geode_rng_base + GEODE_RNG_STATUS_REG); + return val; +} + +static void geode_cleanup(void) +{ + iounmap(geode_rng_base); + geode_rng_base = NULL; +} + +static int geode_init(struct pci_dev *dev) +{ + unsigned long rng_base = pci_resource_start(dev, 0); + + if (rng_base == 0) + return 1; + + geode_rng_base = ioremap(rng_base, 0x58); + + if (geode_rng_base == NULL) { + printk(KERN_ERR PFX "Cannot ioremap RNG memory\n"); + return -EBUSY; + } + + return 0; +} /*********************************************************************** * @@ -574,7 +642,7 @@ static int __init rng_init (void) DPRINTK ("ENTER\n"); - /* Probe for Intel, AMD RNGs */ + /* Probe for Intel, AMD, Geode RNGs */ for_each_pci_dev(pdev) { ent = pci_match_id(rng_pci_tbl, pdev); if (ent) { -- cgit v1.1 From 3841b0a173cb6fc52163e67c03280543f2412db3 Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Fri, 6 Jan 2006 00:12:16 -0800 Subject: [PATCH] APM Screen Blanking fix - Fix screen blanking on BIOSes that return APM_NOT_ENGAGED when APM enabled screen blanking is not turned on. The original code only tried to set the state on device 0x100, and then 0x1FF, and I added 0x101 to the mix too. - Clean up logic in apm_console_blank(). - Prevent the error message from printing out twice. Cc: Jordan Crouse Cc: Stephen Rothwell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/apm.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index d0b4880..2d793d4 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c @@ -1064,22 +1064,23 @@ static int apm_engage_power_management(u_short device, int enable) static int apm_console_blank(int blank) { - int error; - u_short state; + int error, i; + u_short state; + static const u_short dev[3] = { 0x100, 0x1FF, 0x101 }; state = blank ? APM_STATE_STANDBY : APM_STATE_READY; - /* Blank the first display device */ - error = set_power_state(0x100, state); - if ((error != APM_SUCCESS) && (error != APM_NO_ERROR)) { - /* try to blank them all instead */ - error = set_power_state(0x1ff, state); - if ((error != APM_SUCCESS) && (error != APM_NO_ERROR)) - /* try to blank device one instead */ - error = set_power_state(0x101, state); + + for (i = 0; i < ARRAY_SIZE(dev); i++) { + error = set_power_state(dev[i], state); + + if ((error == APM_SUCCESS) || (error == APM_NO_ERROR)) + return 1; + + if (error == APM_NOT_ENGAGED) + break; } - if ((error == APM_SUCCESS) || (error == APM_NO_ERROR)) - return 1; - if (error == APM_NOT_ENGAGED) { + + if (error == APM_NOT_ENGAGED && state != APM_STATE_READY) { static int tried; int eng_error; if (tried++ == 0) { -- cgit v1.1 From bcf0f0d233fc76e7c59c7f731caad555428d0e8d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 6 Jan 2006 00:12:17 -0800 Subject: [PATCH] fix cpu frequency detection in arch/i386/kernel/timers/timer_tsc.c::recalibrate_cpu_khz() When we re-calibrate the frequency, it is likely that an interrupt (as for example the main system clock) will be triggered by the system. Therefore the calibration may not be accurate. This will also provide a fix to bug #5266. Many thanks to Larry Finger for helping resolving this issue. Signed-off-by: Bruno Ducrot Cc: john stultz Cc: Dave Jones Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/timers/timer_tsc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c index d395e3b..47675bb 100644 --- a/arch/i386/kernel/timers/timer_tsc.c +++ b/arch/i386/kernel/timers/timer_tsc.c @@ -330,7 +330,9 @@ int recalibrate_cpu_khz(void) unsigned int cpu_khz_old = cpu_khz; if (cpu_has_tsc) { + local_irq_disable(); init_cpu_khz(); + local_irq_enable(); cpu_data[0].loops_per_jiffy = cpufreq_scale(cpu_data[0].loops_per_jiffy, cpu_khz_old, -- cgit v1.1 From 19d534842cc39df1b568722c18f96ae24fb0e136 Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Fri, 6 Jan 2006 00:12:18 -0800 Subject: [PATCH] mpspec: remove unneeded packed attribute GCC 4.1 gives the following warning: include/asm/mpspec.h:79: warning: `packed' attribute ignored for field of type `unsigned char' The packed attribute isn't really necessary anyways so just remove it. Signed-off-by: Brian Gerst Acked-by: Dave Jones Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-i386/mpspec_def.h | 2 +- include/asm-x86_64/mpspec.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/asm-i386/mpspec_def.h b/include/asm-i386/mpspec_def.h index a961093..76feedf 100644 --- a/include/asm-i386/mpspec_def.h +++ b/include/asm-i386/mpspec_def.h @@ -75,7 +75,7 @@ struct mpc_config_bus { unsigned char mpc_type; unsigned char mpc_busid; - unsigned char mpc_bustype[6] __attribute((packed)); + unsigned char mpc_bustype[6]; }; /* List of Bus Type string values, Intel MP Spec. */ diff --git a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h index 6f8a17d..10248a9 100644 --- a/include/asm-x86_64/mpspec.h +++ b/include/asm-x86_64/mpspec.h @@ -76,7 +76,7 @@ struct mpc_config_bus { unsigned char mpc_type; unsigned char mpc_busid; - unsigned char mpc_bustype[6] __attribute((packed)); + unsigned char mpc_bustype[6]; }; /* List of Bus Type string values, Intel MP Spec. */ -- cgit v1.1 From 76865c3f87e825dda0c458b02f30dd8ae64b7bdc Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Fri, 6 Jan 2006 00:12:19 -0800 Subject: [PATCH] i386: ioapic virtual wire mode fix o Currently, during kexec reboot, IOAPIC is re-programmed back to virtual wire mode if there was an i8259 connected to it. This enables getting timer interrupts in second kernel in legacy mode. o After putting into virtual wire mode, IOAPIC delivers the i8259 interrupts to CPU0. This works well for kexec but not for kdump as we might crash on a different CPU and second kernel will not see timer interrupts. o This patch modifies the redirection table entry to deliver the timer interrupts to the cpu we are rebooting (instead of hardcoding to zero). This ensures that second kernel receives timer interrupts even on a non-boot cpu. Signed-off-by: Vivek Goyal Cc: Andi Kleen Cc: "Seth, Rohit" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index 22c8675..7554f8f 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c @@ -1722,8 +1722,8 @@ void disable_IO_APIC(void) entry.dest_mode = 0; /* Physical */ entry.delivery_mode = dest_ExtINT; /* ExtInt */ entry.vector = 0; - entry.dest.physical.physical_dest = 0; - + entry.dest.physical.physical_dest = + GET_APIC_ID(apic_read(APIC_ID)); /* * Add it to the IO-APIC irq-routing table: -- cgit v1.1 From 766c3f94d4492ee4ec60b65693e71ee4b1d6fd68 Mon Sep 17 00:00:00 2001 From: Ben Collins Date: Fri, 6 Jan 2006 00:12:20 -0800 Subject: [PATCH] i386: Handle HP laptop rebooting properly. Signed-off-by: Ben Collins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/i386/kernel/reboot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c index 2afe0f8..2fa5803 100644 --- a/arch/i386/kernel/reboot.c +++ b/arch/i386/kernel/reboot.c @@ -111,12 +111,12 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 2400"), }, }, - { /* Handle problems with rebooting on HP nc6120 */ + { /* Handle problems with rebooting on HP laptops */ .callback = set_bios_reboot, - .ident = "HP Compaq nc6120", + .ident = "HP Compaq Laptop", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), - DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq nc6120"), + DMI_MATCH(DMI_PRODUCT_NAME, "HP Compaq"), }, }, { } -- cgit v1.1 From 1fa744e6e91a895750b9980d13fcfc5791a0cd91 Mon Sep 17 00:00:00 2001 From: Shaohua Li Date: Fri, 6 Jan 2006 00:12:20 -0800 Subject: [PATCH] cpu hotplug/x86_64: disable interrupt in play_dead With physical CPU hotplug, the CPU is hot removed and it should not receive any interrupts. Disabling interrupt is much safer. This basically is what we do in ia64 & x86. Signed-off-by: Shaohua Li Cc: Andi Kleen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/x86_64/kernel/process.c | 5 +++-- include/asm-x86_64/system.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c index 7519fc5..3060ed9 100644 --- a/arch/x86_64/kernel/process.c +++ b/arch/x86_64/kernel/process.c @@ -157,7 +157,7 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait); DECLARE_PER_CPU(int, cpu_state); #include -/* We don't actually take CPU down, just spin without interrupts. */ +/* We halt the CPU with physical CPU hotplug */ static inline void play_dead(void) { idle_task_exit(); @@ -166,8 +166,9 @@ static inline void play_dead(void) /* Ack it */ __get_cpu_var(cpu_state) = CPU_DEAD; + local_irq_disable(); while (1) - safe_halt(); + halt(); } #else static inline void play_dead(void) diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h index 85348e0..b34cc2e 100644 --- a/include/asm-x86_64/system.h +++ b/include/asm-x86_64/system.h @@ -315,6 +315,8 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, #define local_irq_enable() __asm__ __volatile__("sti": : :"memory") /* used in the idle loop; sti takes one instruction cycle to complete */ #define safe_halt() __asm__ __volatile__("sti; hlt": : :"memory") +/* used when interrupts are already enabled or to shutdown the processor */ +#define halt() __asm__ __volatile__("hlt": : :"memory") #define irqs_disabled() \ ({ \ -- cgit v1.1 From eee45269b0f5979c70bc151c6c2f4e5f4f5ababe Mon Sep 17 00:00:00 2001 From: Ivan Kokshaysky Date: Fri, 6 Jan 2006 00:12:21 -0800 Subject: [PATCH] Alpha: convert to generic irq framework (generic part) Thanks to Christoph for doing most of the work. This allows automatic SMP IRQ affinity assignment other than default "all interrupts on all CPUs" which is rather expensive. This might be useful if the hardware can be programmed to distribute interrupts among different CPUs, like Alpha does. Signed-off-by: Ivan Kokshaysky Cc: Christoph Hellwig Cc: Richard Henderson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/irq.h | 11 +++++++++++ kernel/irq/manage.c | 2 ++ kernel/irq/proc.c | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index f04ba20..60f8bc7 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -221,6 +221,17 @@ extern void note_interrupt(unsigned int irq, irq_desc_t *desc, extern int can_request_irq(unsigned int irq, unsigned long irqflags); extern void init_irq_proc(void); + +#ifdef CONFIG_AUTO_IRQ_AFFINITY +extern int select_smp_affinity(unsigned int irq); +#else +static inline int +select_smp_affinity(unsigned int irq) +{ + return 1; +} +#endif + #endif extern hw_irq_controller no_irq_type; /* needed in every arch ? */ diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 81c49a4..97d5559 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -366,6 +366,8 @@ int request_irq(unsigned int irq, action->next = NULL; action->dev_id = dev_id; + select_smp_affinity(irq); + retval = setup_irq(irq, action); if (retval) kfree(action); diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index f26e534..8a64a48 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -68,7 +68,9 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer, */ cpus_and(tmp, new_value, cpu_online_map); if (cpus_empty(tmp)) - return -EINVAL; + /* Special case for empty set - allow the architecture + code to set default SMP affinity. */ + return select_smp_affinity(irq) ? -EINVAL : full_count; proc_set_irq_affinity(irq, new_value); -- cgit v1.1 From 0595bf3bca9d9932a05b06dd438f40f01d27cd33 Mon Sep 17 00:00:00 2001 From: Ivan Kokshaysky Date: Fri, 6 Jan 2006 00:12:22 -0800 Subject: [PATCH] Alpha: convert to generic irq framework (alpha part) Kconfig tweaks and tons of deletions. Signed-off-by: Ivan Kokshaysky Cc: Christoph Hellwig Cc: Richard Henderson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/alpha/Kconfig | 13 + arch/alpha/kernel/alpha_ksyms.c | 1 - arch/alpha/kernel/irq.c | 630 +--------------------------------------- include/asm-alpha/hardirq.h | 2 + 4 files changed, 24 insertions(+), 622 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 786491f..153337f 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -40,6 +40,19 @@ config GENERIC_IOMAP bool default n +config GENERIC_HARDIRQS + bool + default y + +config GENERIC_IRQ_PROBE + bool + default y + +config AUTO_IRQ_AFFINITY + bool + depends on SMP + default y + source "init/Kconfig" diff --git a/arch/alpha/kernel/alpha_ksyms.c b/arch/alpha/kernel/alpha_ksyms.c index 24ae9a3..f3e98f8 100644 --- a/arch/alpha/kernel/alpha_ksyms.c +++ b/arch/alpha/kernel/alpha_ksyms.c @@ -175,7 +175,6 @@ EXPORT_SYMBOL(up); */ #ifdef CONFIG_SMP -EXPORT_SYMBOL(synchronize_irq); EXPORT_SYMBOL(flush_tlb_mm); EXPORT_SYMBOL(flush_tlb_range); EXPORT_SYMBOL(flush_tlb_page); diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c index b6114f5..76be5cf 100644 --- a/arch/alpha/kernel/irq.c +++ b/arch/alpha/kernel/irq.c @@ -32,214 +32,25 @@ #include #include -/* - * Controller mappings for all interrupt sources: - */ -irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = { - [0 ... NR_IRQS-1] = { - .handler = &no_irq_type, - .lock = SPIN_LOCK_UNLOCKED - } -}; - -static void register_irq_proc(unsigned int irq); - volatile unsigned long irq_err_count; -/* - * Special irq handlers. - */ - -irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs) -{ - return IRQ_NONE; -} - -/* - * Generic no controller code - */ - -static void no_irq_enable_disable(unsigned int irq) { } -static unsigned int no_irq_startup(unsigned int irq) { return 0; } - -static void -no_irq_ack(unsigned int irq) +void ack_bad_irq(unsigned int irq) { irq_err_count++; printk(KERN_CRIT "Unexpected IRQ trap at vector %u\n", irq); } -struct hw_interrupt_type no_irq_type = { - .typename = "none", - .startup = no_irq_startup, - .shutdown = no_irq_enable_disable, - .enable = no_irq_enable_disable, - .disable = no_irq_enable_disable, - .ack = no_irq_ack, - .end = no_irq_enable_disable, -}; - -int -handle_IRQ_event(unsigned int irq, struct pt_regs *regs, - struct irqaction *action) -{ - int status = 1; /* Force the "do bottom halves" bit */ - int ret; - - do { - if (!(action->flags & SA_INTERRUPT)) - local_irq_enable(); - else - local_irq_disable(); - - ret = action->handler(irq, action->dev_id, regs); - if (ret == IRQ_HANDLED) - status |= action->flags; - action = action->next; - } while (action); - if (status & SA_SAMPLE_RANDOM) - add_interrupt_randomness(irq); - local_irq_disable(); - - return status; -} - -/* - * Generic enable/disable code: this just calls - * down into the PIC-specific version for the actual - * hardware disable after having gotten the irq - * controller lock. - */ -void inline -disable_irq_nosync(unsigned int irq) -{ - irq_desc_t *desc = irq_desc + irq; - unsigned long flags; - - spin_lock_irqsave(&desc->lock, flags); - if (!desc->depth++) { - desc->status |= IRQ_DISABLED; - desc->handler->disable(irq); - } - spin_unlock_irqrestore(&desc->lock, flags); -} - -/* - * Synchronous version of the above, making sure the IRQ is - * no longer running on any other IRQ.. - */ -void -disable_irq(unsigned int irq) -{ - disable_irq_nosync(irq); - synchronize_irq(irq); -} - -void -enable_irq(unsigned int irq) -{ - irq_desc_t *desc = irq_desc + irq; - unsigned long flags; - - spin_lock_irqsave(&desc->lock, flags); - switch (desc->depth) { - case 1: { - unsigned int status = desc->status & ~IRQ_DISABLED; - desc->status = status; - if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { - desc->status = status | IRQ_REPLAY; - hw_resend_irq(desc->handler,irq); - } - desc->handler->enable(irq); - /* fall-through */ - } - default: - desc->depth--; - break; - case 0: - printk(KERN_ERR "enable_irq() unbalanced from %p\n", - __builtin_return_address(0)); - } - spin_unlock_irqrestore(&desc->lock, flags); -} - -int -setup_irq(unsigned int irq, struct irqaction * new) -{ - int shared = 0; - struct irqaction *old, **p; - unsigned long flags; - irq_desc_t *desc = irq_desc + irq; - - if (desc->handler == &no_irq_type) - return -ENOSYS; - - /* - * Some drivers like serial.c use request_irq() heavily, - * so we have to be careful not to interfere with a - * running system. - */ - if (new->flags & SA_SAMPLE_RANDOM) { - /* - * This function might sleep, we want to call it first, - * outside of the atomic block. - * Yes, this might clear the entropy pool if the wrong - * driver is attempted to be loaded, without actually - * installing a new handler, but is this really a problem, - * only the sysadmin is able to do this. - */ - rand_initialize_irq(irq); - } - - /* - * The following block of code has to be executed atomically - */ - spin_lock_irqsave(&desc->lock,flags); - p = &desc->action; - if ((old = *p) != NULL) { - /* Can't share interrupts unless both agree to */ - if (!(old->flags & new->flags & SA_SHIRQ)) { - spin_unlock_irqrestore(&desc->lock,flags); - return -EBUSY; - } - - /* add new interrupt at end of irq queue */ - do { - p = &old->next; - old = *p; - } while (old); - shared = 1; - } - - *p = new; - - if (!shared) { - desc->depth = 0; - desc->status &= - ~(IRQ_DISABLED|IRQ_AUTODETECT|IRQ_WAITING|IRQ_INPROGRESS); - desc->handler->startup(irq); - } - spin_unlock_irqrestore(&desc->lock,flags); - - return 0; -} - -static struct proc_dir_entry * root_irq_dir; -static struct proc_dir_entry * irq_dir[NR_IRQS]; - #ifdef CONFIG_SMP -static struct proc_dir_entry * smp_affinity_entry[NR_IRQS]; static char irq_user_affinity[NR_IRQS]; -static cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL }; -static void -select_smp_affinity(int irq) +int +select_smp_affinity(unsigned int irq) { static int last_cpu; int cpu = last_cpu + 1; - if (! irq_desc[irq].handler->set_affinity || irq_user_affinity[irq]) - return; + if (!irq_desc[irq].handler->set_affinity || irq_user_affinity[irq]) + return 1; while (!cpu_possible(cpu)) cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0); @@ -247,208 +58,10 @@ select_smp_affinity(int irq) irq_affinity[irq] = cpumask_of_cpu(cpu); irq_desc[irq].handler->set_affinity(irq, cpumask_of_cpu(cpu)); + return 0; } - -static int -irq_affinity_read_proc (char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); - if (count - len < 2) - return -EINVAL; - len += sprintf(page + len, "\n"); - return len; -} - -static int -irq_affinity_write_proc(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - int irq = (long) data, full_count = count, err; - cpumask_t new_value; - - if (!irq_desc[irq].handler->set_affinity) - return -EIO; - - err = cpumask_parse(buffer, count, new_value); - - /* The special value 0 means release control of the - affinity to kernel. */ - cpus_and(new_value, new_value, cpu_online_map); - if (cpus_empty(new_value)) { - irq_user_affinity[irq] = 0; - select_smp_affinity(irq); - } - /* Do not allow disabling IRQs completely - it's a too easy - way to make the system unusable accidentally :-) At least - one online CPU still has to be targeted. */ - else { - irq_affinity[irq] = new_value; - irq_user_affinity[irq] = 1; - irq_desc[irq].handler->set_affinity(irq, new_value); - } - - return full_count; -} - #endif /* CONFIG_SMP */ -#define MAX_NAMELEN 10 - -static void -register_irq_proc (unsigned int irq) -{ - char name [MAX_NAMELEN]; - - if (!root_irq_dir || (irq_desc[irq].handler == &no_irq_type) || - irq_dir[irq]) - return; - - memset(name, 0, MAX_NAMELEN); - sprintf(name, "%d", irq); - - /* create /proc/irq/1234 */ - irq_dir[irq] = proc_mkdir(name, root_irq_dir); - -#ifdef CONFIG_SMP - if (irq_desc[irq].handler->set_affinity) { - struct proc_dir_entry *entry; - /* create /proc/irq/1234/smp_affinity */ - entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]); - - if (entry) { - entry->nlink = 1; - entry->data = (void *)(long)irq; - entry->read_proc = irq_affinity_read_proc; - entry->write_proc = irq_affinity_write_proc; - } - - smp_affinity_entry[irq] = entry; - } -#endif -} - -void -init_irq_proc (void) -{ - int i; - - /* create /proc/irq */ - root_irq_dir = proc_mkdir("irq", NULL); - -#ifdef CONFIG_SMP - /* create /proc/irq/prof_cpu_mask */ - create_prof_cpu_mask(root_irq_dir); -#endif - - /* - * Create entries for all existing IRQs. - */ - for (i = 0; i < ACTUAL_NR_IRQS; i++) { - if (irq_desc[i].handler == &no_irq_type) - continue; - register_irq_proc(i); - } -} - -int -request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *), - unsigned long irqflags, const char * devname, void *dev_id) -{ - int retval; - struct irqaction * action; - - if (irq >= ACTUAL_NR_IRQS) - return -EINVAL; - if (!handler) - return -EINVAL; - -#if 1 - /* - * Sanity-check: shared interrupts should REALLY pass in - * a real dev-ID, otherwise we'll have trouble later trying - * to figure out which interrupt is which (messes up the - * interrupt freeing logic etc). - */ - if ((irqflags & SA_SHIRQ) && !dev_id) { - printk(KERN_ERR - "Bad boy: %s (at %p) called us without a dev_id!\n", - devname, __builtin_return_address(0)); - } -#endif - - action = (struct irqaction *) - kmalloc(sizeof(struct irqaction), GFP_KERNEL); - if (!action) - return -ENOMEM; - - action->handler = handler; - action->flags = irqflags; - cpus_clear(action->mask); - action->name = devname; - action->next = NULL; - action->dev_id = dev_id; - -#ifdef CONFIG_SMP - select_smp_affinity(irq); -#endif - - retval = setup_irq(irq, action); - if (retval) - kfree(action); - return retval; -} - -EXPORT_SYMBOL(request_irq); - -void -free_irq(unsigned int irq, void *dev_id) -{ - irq_desc_t *desc; - struct irqaction **p; - unsigned long flags; - - if (irq >= ACTUAL_NR_IRQS) { - printk(KERN_CRIT "Trying to free IRQ%d\n", irq); - return; - } - - desc = irq_desc + irq; - spin_lock_irqsave(&desc->lock,flags); - p = &desc->action; - for (;;) { - struct irqaction * action = *p; - if (action) { - struct irqaction **pp = p; - p = &action->next; - if (action->dev_id != dev_id) - continue; - - /* Found - now remove it from the list of entries. */ - *pp = action->next; - if (!desc->action) { - desc->status |= IRQ_DISABLED; - desc->handler->shutdown(irq); - } - spin_unlock_irqrestore(&desc->lock,flags); - -#ifdef CONFIG_SMP - /* Wait to make sure it's not being used on - another CPU. */ - while (desc->status & IRQ_INPROGRESS) - barrier(); -#endif - kfree(action); - return; - } - printk(KERN_ERR "Trying to free free IRQ%d\n",irq); - spin_unlock_irqrestore(&desc->lock,flags); - return; - } -} - -EXPORT_SYMBOL(free_irq); - int show_interrupts(struct seq_file *p, void *v) { @@ -531,10 +144,6 @@ handle_irq(int irq, struct pt_regs * regs) * 0 return value means that this irq is already being * handled by some other CPU. (or is disabled) */ - int cpu = smp_processor_id(); - irq_desc_t *desc = irq_desc + irq; - struct irqaction * action; - unsigned int status; static unsigned int illegal_count=0; if ((unsigned) irq > ACTUAL_NR_IRQS && illegal_count < MAX_ILLEGAL_IRQS ) { @@ -546,229 +155,8 @@ handle_irq(int irq, struct pt_regs * regs) } irq_enter(); - kstat_cpu(cpu).irqs[irq]++; - spin_lock_irq(&desc->lock); /* mask also the higher prio events */ - desc->handler->ack(irq); - /* - * REPLAY is when Linux resends an IRQ that was dropped earlier. - * WAITING is used by probe to mark irqs that are being tested. - */ - status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING); - status |= IRQ_PENDING; /* we _want_ to handle it */ - - /* - * If the IRQ is disabled for whatever reason, we cannot - * use the action we have. - */ - action = NULL; - if (!(status & (IRQ_DISABLED | IRQ_INPROGRESS))) { - action = desc->action; - status &= ~IRQ_PENDING; /* we commit to handling */ - status |= IRQ_INPROGRESS; /* we are handling it */ - } - desc->status = status; - - /* - * If there is no IRQ handler or it was disabled, exit early. - * Since we set PENDING, if another processor is handling - * a different instance of this same irq, the other processor - * will take care of it. - */ - if (!action) - goto out; - - /* - * Edge triggered interrupts need to remember pending events. - * This applies to any hw interrupts that allow a second - * instance of the same irq to arrive while we are in handle_irq - * or in the handler. But the code here only handles the _second_ - * instance of the irq, not the third or fourth. So it is mostly - * useful for irq hardware that does not mask cleanly in an - * SMP environment. - */ - for (;;) { - spin_unlock(&desc->lock); - handle_IRQ_event(irq, regs, action); - spin_lock(&desc->lock); - - if (!(desc->status & IRQ_PENDING) - || (desc->status & IRQ_LEVEL)) - break; - desc->status &= ~IRQ_PENDING; - } - desc->status &= ~IRQ_INPROGRESS; -out: - /* - * The ->end() handler has to deal with interrupts which got - * disabled while the handler was running. - */ - desc->handler->end(irq); - spin_unlock(&desc->lock); - + local_irq_disable(); + __do_IRQ(irq, regs); + local_irq_enable(); irq_exit(); } - -/* - * IRQ autodetection code.. - * - * This depends on the fact that any interrupt that - * comes in on to an unassigned handler will get stuck - * with "IRQ_WAITING" cleared and the interrupt - * disabled. - */ -unsigned long -probe_irq_on(void) -{ - int i; - irq_desc_t *desc; - unsigned long delay; - unsigned long val; - - /* Something may have generated an irq long ago and we want to - flush such a longstanding irq before considering it as spurious. */ - for (i = NR_IRQS-1; i >= 0; i--) { - desc = irq_desc + i; - - spin_lock_irq(&desc->lock); - if (!irq_desc[i].action) - irq_desc[i].handler->startup(i); - spin_unlock_irq(&desc->lock); - } - - /* Wait for longstanding interrupts to trigger. */ - for (delay = jiffies + HZ/50; time_after(delay, jiffies); ) - /* about 20ms delay */ barrier(); - - /* enable any unassigned irqs (we must startup again here because - if a longstanding irq happened in the previous stage, it may have - masked itself) first, enable any unassigned irqs. */ - for (i = NR_IRQS-1; i >= 0; i--) { - desc = irq_desc + i; - - spin_lock_irq(&desc->lock); - if (!desc->action) { - desc->status |= IRQ_AUTODETECT | IRQ_WAITING; - if (desc->handler->startup(i)) - desc->status |= IRQ_PENDING; - } - spin_unlock_irq(&desc->lock); - } - - /* - * Wait for spurious interrupts to trigger - */ - for (delay = jiffies + HZ/10; time_after(delay, jiffies); ) - /* about 100ms delay */ barrier(); - - /* - * Now filter out any obviously spurious interrupts - */ - val = 0; - for (i=0; ilock); - status = desc->status; - - if (status & IRQ_AUTODETECT) { - /* It triggered already - consider it spurious. */ - if (!(status & IRQ_WAITING)) { - desc->status = status & ~IRQ_AUTODETECT; - desc->handler->shutdown(i); - } else - if (i < 32) - val |= 1 << i; - } - spin_unlock_irq(&desc->lock); - } - - return val; -} - -EXPORT_SYMBOL(probe_irq_on); - -/* - * Return a mask of triggered interrupts (this - * can handle only legacy ISA interrupts). - */ -unsigned int -probe_irq_mask(unsigned long val) -{ - int i; - unsigned int mask; - - mask = 0; - for (i = 0; i < NR_IRQS; i++) { - irq_desc_t *desc = irq_desc + i; - unsigned int status; - - spin_lock_irq(&desc->lock); - status = desc->status; - - if (status & IRQ_AUTODETECT) { - /* We only react to ISA interrupts */ - if (!(status & IRQ_WAITING)) { - if (i < 16) - mask |= 1 << i; - } - - desc->status = status & ~IRQ_AUTODETECT; - desc->handler->shutdown(i); - } - spin_unlock_irq(&desc->lock); - } - - return mask & val; -} - -/* - * Get the result of the IRQ probe.. A negative result means that - * we have several candidates (but we return the lowest-numbered - * one). - */ - -int -probe_irq_off(unsigned long val) -{ - int i, irq_found, nr_irqs; - - nr_irqs = 0; - irq_found = 0; - for (i=0; ilock); - status = desc->status; - - if (status & IRQ_AUTODETECT) { - if (!(status & IRQ_WAITING)) { - if (!nr_irqs) - irq_found = i; - nr_irqs++; - } - desc->status = status & ~IRQ_AUTODETECT; - desc->handler->shutdown(i); - } - spin_unlock_irq(&desc->lock); - } - - if (nr_irqs > 1) - irq_found = -irq_found; - return irq_found; -} - -EXPORT_SYMBOL(probe_irq_off); - -#ifdef CONFIG_SMP -void synchronize_irq(unsigned int irq) -{ - /* is there anything to synchronize with? */ - if (!irq_desc[irq].action) - return; - - while (irq_desc[irq].status & IRQ_INPROGRESS) - barrier(); -} -#endif diff --git a/include/asm-alpha/hardirq.h b/include/asm-alpha/hardirq.h index c0593f9..7bb6a36 100644 --- a/include/asm-alpha/hardirq.h +++ b/include/asm-alpha/hardirq.h @@ -13,6 +13,8 @@ typedef struct { #include /* Standard mappings for irq_cpustat_t above */ +void ack_bad_irq(unsigned int irq); + #define HARDIRQ_BITS 12 /* -- cgit v1.1 From f2d97f02961e8b1f8a24befb88ab0e5c886586ff Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:12:24 -0800 Subject: [PATCH] swsusp: remove encryption This patch removes the image encryption that is only used by swsusp instead of zeroing the image after resume in order to prevent someone from reading some confidential data from it in the future and it does not protect the image from being read by an unauthorized person before resume. The functionality it provides should really belong to the user space and will possibly be reimplemented after the swap-handling functionality of swsusp is moved to the user space. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/power/swsusp.c | 163 ++------------------------------------------------ 1 file changed, 4 insertions(+), 159 deletions(-) diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index c05f46e..bd3097c 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c @@ -30,9 +30,6 @@ * Alex Badea : * Fixed runaway init * - * Andreas Steinmetz : - * Added encrypted suspend option - * * More state savers are welcome. Especially for the scsi layer... * * For TODOs,FIXMEs also look in Documentation/power/swsusp.txt @@ -67,10 +64,6 @@ #include #include -#include -#include -#include - #include "power.h" #ifdef CONFIG_HIGHMEM @@ -81,10 +74,6 @@ static int save_highmem(void) { return 0; } static int restore_highmem(void) { return 0; } #endif -#define CIPHER "aes" -#define MAXKEY 32 -#define MAXIV 32 - extern char resume_file[]; /* Local variables that should not be affected by save */ @@ -102,8 +91,7 @@ suspend_pagedir_t *pagedir_nosave __nosavedata = NULL; #define SWSUSP_SIG "S1SUSPEND" static struct swsusp_header { - char reserved[PAGE_SIZE - 20 - MAXKEY - MAXIV - sizeof(swp_entry_t)]; - u8 key_iv[MAXKEY+MAXIV]; + char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)]; swp_entry_t swsusp_info; char orig_sig[10]; char sig[10]; @@ -123,131 +111,6 @@ static struct swsusp_info swsusp_info; static unsigned short swapfile_used[MAX_SWAPFILES]; static unsigned short root_swap; -static int write_page(unsigned long addr, swp_entry_t *loc); -static int bio_read_page(pgoff_t page_off, void *page); - -static u8 key_iv[MAXKEY+MAXIV]; - -#ifdef CONFIG_SWSUSP_ENCRYPT - -static int crypto_init(int mode, void **mem) -{ - int error = 0; - int len; - char *modemsg; - struct crypto_tfm *tfm; - - modemsg = mode ? "suspend not possible" : "resume not possible"; - - tfm = crypto_alloc_tfm(CIPHER, CRYPTO_TFM_MODE_CBC); - if(!tfm) { - printk(KERN_ERR "swsusp: no tfm, %s\n", modemsg); - error = -EINVAL; - goto out; - } - - if(MAXKEY < crypto_tfm_alg_min_keysize(tfm)) { - printk(KERN_ERR "swsusp: key buffer too small, %s\n", modemsg); - error = -ENOKEY; - goto fail; - } - - if (mode) - get_random_bytes(key_iv, MAXKEY+MAXIV); - - len = crypto_tfm_alg_max_keysize(tfm); - if (len > MAXKEY) - len = MAXKEY; - - if (crypto_cipher_setkey(tfm, key_iv, len)) { - printk(KERN_ERR "swsusp: key setup failure, %s\n", modemsg); - error = -EKEYREJECTED; - goto fail; - } - - len = crypto_tfm_alg_ivsize(tfm); - - if (MAXIV < len) { - printk(KERN_ERR "swsusp: iv buffer too small, %s\n", modemsg); - error = -EOVERFLOW; - goto fail; - } - - crypto_cipher_set_iv(tfm, key_iv+MAXKEY, len); - - *mem=(void *)tfm; - - goto out; - -fail: crypto_free_tfm(tfm); -out: return error; -} - -static __inline__ void crypto_exit(void *mem) -{ - crypto_free_tfm((struct crypto_tfm *)mem); -} - -static __inline__ int crypto_write(struct pbe *p, void *mem) -{ - int error = 0; - struct scatterlist src, dst; - - src.page = virt_to_page(p->address); - src.offset = 0; - src.length = PAGE_SIZE; - dst.page = virt_to_page((void *)&swsusp_header); - dst.offset = 0; - dst.length = PAGE_SIZE; - - error = crypto_cipher_encrypt((struct crypto_tfm *)mem, &dst, &src, - PAGE_SIZE); - - if (!error) - error = write_page((unsigned long)&swsusp_header, - &(p->swap_address)); - return error; -} - -static __inline__ int crypto_read(struct pbe *p, void *mem) -{ - int error = 0; - struct scatterlist src, dst; - - error = bio_read_page(swp_offset(p->swap_address), (void *)p->address); - if (!error) { - src.offset = 0; - src.length = PAGE_SIZE; - dst.offset = 0; - dst.length = PAGE_SIZE; - src.page = dst.page = virt_to_page((void *)p->address); - - error = crypto_cipher_decrypt((struct crypto_tfm *)mem, &dst, - &src, PAGE_SIZE); - } - return error; -} -#else -static __inline__ int crypto_init(int mode, void *mem) -{ - return 0; -} - -static __inline__ void crypto_exit(void *mem) -{ -} - -static __inline__ int crypto_write(struct pbe *p, void *mem) -{ - return write_page(p->address, &(p->swap_address)); -} - -static __inline__ int crypto_read(struct pbe *p, void *mem) -{ - return bio_read_page(swp_offset(p->swap_address), (void *)p->address); -} -#endif - static int mark_swapfiles(swp_entry_t prev) { int error; @@ -259,7 +122,6 @@ static int mark_swapfiles(swp_entry_t prev) !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) { memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10); memcpy(swsusp_header.sig,SWSUSP_SIG, 10); - memcpy(swsusp_header.key_iv, key_iv, MAXKEY+MAXIV); swsusp_header.swsusp_info = prev; error = rw_swap_page_sync(WRITE, swp_entry(root_swap, 0), @@ -405,10 +267,6 @@ static int data_write(void) int error = 0, i = 0; unsigned int mod = nr_copy_pages / 100; struct pbe *p; - void *tfm; - - if ((error = crypto_init(1, &tfm))) - return error; if (!mod) mod = 1; @@ -417,14 +275,11 @@ static int data_write(void) for_each_pbe (p, pagedir_nosave) { if (!(i%mod)) printk( "\b\b\b\b%3d%%", i / mod ); - if ((error = crypto_write(p, tfm))) { - crypto_exit(tfm); + if ((error = write_page(p->address, &p->swap_address))) return error; - } i++; } printk("\b\b\b\bdone\n"); - crypto_exit(tfm); return error; } @@ -550,7 +405,6 @@ static int write_suspend_image(void) if ((error = close_swap())) goto FreePagedir; Done: - memset(key_iv, 0, MAXKEY+MAXIV); return error; FreePagedir: free_pagedir_entries(); @@ -812,8 +666,6 @@ static int check_sig(void) return error; if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) { memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10); - memcpy(key_iv, swsusp_header.key_iv, MAXKEY+MAXIV); - memset(swsusp_header.key_iv, 0, MAXKEY+MAXIV); /* * Reset swap signature now. @@ -840,10 +692,6 @@ static int data_read(struct pbe *pblist) int error = 0; int i = 0; int mod = swsusp_info.image_pages / 100; - void *tfm; - - if ((error = crypto_init(0, &tfm))) - return error; if (!mod) mod = 1; @@ -855,15 +703,13 @@ static int data_read(struct pbe *pblist) if (!(i % mod)) printk("\b\b\b\b%3d%%", i / mod); - if ((error = crypto_read(p, tfm))) { - crypto_exit(tfm); + if ((error = bio_read_page(swp_offset(p->swap_address), + (void *)p->address))) return error; - } i++; } printk("\b\b\b\bdone\n"); - crypto_exit(tfm); return error; } @@ -986,7 +832,6 @@ int swsusp_read(void) error = read_suspend_image(); blkdev_put(resume_bdev); - memset(key_iv, 0, MAXKEY+MAXIV); if (!error) pr_debug("swsusp: Reading resume file was successful\n"); -- cgit v1.1 From 7088a5c00103ef48782d6c359cd12b13a10666e6 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:13:05 -0800 Subject: [PATCH] swsusp: introduce the swap map structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch introduces the swap map structure that can be used by swsusp for keeping tracks of data pages written to the swap.  The structure itself is described in a comment within the patch. The overall idea is to reduce the amount of metadata written to the swap and to write and read the image pages sequentially, in a file-alike way. This makes the swap-handling part of swsusp fairly independent of its snapshot-handling part and will hopefully allow us to completely separate these two parts in the future. This patch is needed to remove the suspend image size limit imposed by the limited size of the swsusp_info structure, which is essential for x86-64 systems with more than 512 MB of RAM. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/suspend.h | 6 +- kernel/power/disk.c | 8 +- kernel/power/power.h | 13 +- kernel/power/snapshot.c | 14 +- kernel/power/swsusp.c | 558 ++++++++++++++++++++++++++++++++++-------------- 5 files changed, 418 insertions(+), 181 deletions(-) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index a61c04f..33bbaea 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -14,11 +14,7 @@ typedef struct pbe { unsigned long address; /* address of the copy */ unsigned long orig_address; /* original address of page */ - swp_entry_t swap_address; - - struct pbe *next; /* also used as scratch space at - * end of page (see link, diskpage) - */ + struct pbe *next; } suspend_pagedir_t; #define for_each_pbe(pbe, pblist) \ diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 4d944b2..76a5131 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c @@ -25,9 +25,9 @@ extern suspend_disk_method_t pm_disk_mode; extern int swsusp_suspend(void); -extern int swsusp_write(void); +extern int swsusp_write(struct pbe *pblist, unsigned int nr_pages); extern int swsusp_check(void); -extern int swsusp_read(void); +extern int swsusp_read(struct pbe **pblist_ptr); extern void swsusp_close(void); extern int swsusp_resume(void); @@ -176,7 +176,7 @@ int pm_suspend_disk(void) if (in_suspend) { device_resume(); pr_debug("PM: writing image.\n"); - error = swsusp_write(); + error = swsusp_write(pagedir_nosave, nr_copy_pages); if (!error) power_down(pm_disk_mode); else { @@ -247,7 +247,7 @@ static int software_resume(void) pr_debug("PM: Reading swsusp image.\n"); - if ((error = swsusp_read())) { + if ((error = swsusp_read(&pagedir_nosave))) { swsusp_free(); goto Thaw; } diff --git a/kernel/power/power.h b/kernel/power/power.h index 6c042b5..977877c 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -9,19 +9,14 @@ #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) #endif -#define MAX_PBES ((PAGE_SIZE - sizeof(struct new_utsname) \ - - 4 - 3*sizeof(unsigned long) - sizeof(int) \ - - sizeof(void *)) / sizeof(swp_entry_t)) - struct swsusp_info { struct new_utsname uts; u32 version_code; unsigned long num_physpages; int cpus; unsigned long image_pages; - unsigned long pagedir_pages; - suspend_pagedir_t * suspend_pagedir; - swp_entry_t pagedir[MAX_PBES]; + unsigned long pages; + swp_entry_t start; } __attribute__((aligned(PAGE_SIZE))); @@ -67,6 +62,8 @@ extern asmlinkage int swsusp_arch_resume(void); extern void free_pagedir(struct pbe *pblist); extern struct pbe *alloc_pagedir(unsigned nr_pages, gfp_t gfp_mask, int safe_needed); -extern void create_pbe_list(struct pbe *pblist, unsigned nr_pages); extern void swsusp_free(void); extern int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed); +extern unsigned int snapshot_nr_pages(void); +extern struct pbe *snapshot_pblist(void); +extern void snapshot_pblist_set(struct pbe *pblist); diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 4a6dbce..152d56c 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -33,6 +33,9 @@ #include "power.h" +struct pbe *pagedir_nosave; +unsigned int nr_copy_pages; + #ifdef CONFIG_HIGHMEM struct highmem_page { char *data; @@ -244,7 +247,7 @@ static inline void fill_pb_page(struct pbe *pbpage) * of memory pages allocated with alloc_pagedir() */ -void create_pbe_list(struct pbe *pblist, unsigned int nr_pages) +static inline void create_pbe_list(struct pbe *pblist, unsigned int nr_pages) { struct pbe *pbpage, *p; unsigned int num = PBES_PER_PAGE; @@ -261,7 +264,6 @@ void create_pbe_list(struct pbe *pblist, unsigned int nr_pages) p->next = p + 1; p->next = NULL; } - pr_debug("create_pbe_list(): initialized %d PBEs\n", num); } /** @@ -332,7 +334,8 @@ struct pbe *alloc_pagedir(unsigned int nr_pages, gfp_t gfp_mask, int safe_needed if (!pbe) { /* get_zeroed_page() failed */ free_pagedir(pblist); pblist = NULL; - } + } else + create_pbe_list(pblist, nr_pages); return pblist; } @@ -395,7 +398,6 @@ static struct pbe *swsusp_alloc(unsigned int nr_pages) printk(KERN_ERR "suspend: Allocating pagedir failed.\n"); return NULL; } - create_pbe_list(pblist, nr_pages); if (alloc_data_pages(pblist, GFP_ATOMIC | __GFP_COLD, 0)) { printk(KERN_ERR "suspend: Allocating image pages failed.\n"); @@ -421,10 +423,6 @@ asmlinkage int swsusp_save(void) (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE, PAGES_FOR_IO, nr_free_pages()); - /* This is needed because of the fixed size of swsusp_info */ - if (MAX_PBES < (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE) - return -ENOSPC; - if (!enough_free_mem(nr_pages)) { printk(KERN_ERR "swsusp: Not enough free memory\n"); return -ENOMEM; diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index bd3097c..b09bd7c 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c @@ -30,6 +30,9 @@ * Alex Badea : * Fixed runaway init * + * Rafael J. Wysocki + * Added the swap map data structure and reworked the handling of swap + * * More state savers are welcome. Especially for the scsi layer... * * For TODOs,FIXMEs also look in Documentation/power/swsusp.txt @@ -76,18 +79,6 @@ static int restore_highmem(void) { return 0; } extern char resume_file[]; -/* Local variables that should not be affected by save */ -unsigned int nr_copy_pages __nosavedata = 0; - -/* Suspend pagedir is allocated before final copy, therefore it - must be freed after resume - - Warning: this is even more evil than it seems. Pagedirs this file - talks about are completely different from page directories used by - MMU hardware. - */ -suspend_pagedir_t *pagedir_nosave __nosavedata = NULL; - #define SWSUSP_SIG "S1SUSPEND" static struct swsusp_header { @@ -238,48 +229,205 @@ static int write_page(unsigned long addr, swp_entry_t *loc) } /** - * data_free - Free the swap entries used by the saved image. + * Swap map-handling functions + * + * The swap map is a data structure used for keeping track of each page + * written to the swap. It consists of many swap_map_page structures + * that contain each an array of MAP_PAGE_SIZE swap entries. + * These structures are linked together with the help of either the + * .next (in memory) or the .next_swap (in swap) member. * - * Walk the list of used swap entries and free each one. - * This is only used for cleanup when suspend fails. + * The swap map is created during suspend. At that time we need to keep + * it in memory, because we have to free all of the allocated swap + * entries if an error occurs. The memory needed is preallocated + * so that we know in advance if there's enough of it. + * + * The first swap_map_page structure is filled with the swap entries that + * correspond to the first MAP_PAGE_SIZE data pages written to swap and + * so on. After the all of the data pages have been written, the order + * of the swap_map_page structures in the map is reversed so that they + * can be read from swap in the original order. This causes the data + * pages to be loaded in exactly the same order in which they have been + * saved. + * + * During resume we only need to use one swap_map_page structure + * at a time, which means that we only need to use two memory pages for + * reading the image - one for reading the swap_map_page structures + * and the second for reading the data pages from swap. */ -static void data_free(void) + +#define MAP_PAGE_SIZE ((PAGE_SIZE - sizeof(swp_entry_t) - sizeof(void *)) \ + / sizeof(swp_entry_t)) + +struct swap_map_page { + swp_entry_t entries[MAP_PAGE_SIZE]; + swp_entry_t next_swap; + struct swap_map_page *next; +}; + +static inline void free_swap_map(struct swap_map_page *swap_map) { - swp_entry_t entry; - struct pbe *p; + struct swap_map_page *swp; - for_each_pbe (p, pagedir_nosave) { - entry = p->swap_address; - if (entry.val) - swap_free(entry); - else - break; + while (swap_map) { + swp = swap_map->next; + free_page((unsigned long)swap_map); + swap_map = swp; + } +} + +static struct swap_map_page *alloc_swap_map(unsigned int nr_pages) +{ + struct swap_map_page *swap_map, *swp; + unsigned n = 0; + + if (!nr_pages) + return NULL; + + pr_debug("alloc_swap_map(): nr_pages = %d\n", nr_pages); + swap_map = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC); + swp = swap_map; + for (n = MAP_PAGE_SIZE; n < nr_pages; n += MAP_PAGE_SIZE) { + swp->next = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC); + swp = swp->next; + if (!swp) { + free_swap_map(swap_map); + return NULL; + } } + return swap_map; } /** - * data_write - Write saved image to swap. - * - * Walk the list of pages in the image and sync each one to swap. + * reverse_swap_map - reverse the order of pages in the swap map + * @swap_map */ -static int data_write(void) + +static inline struct swap_map_page *reverse_swap_map(struct swap_map_page *swap_map) { - int error = 0, i = 0; - unsigned int mod = nr_copy_pages / 100; - struct pbe *p; + struct swap_map_page *prev, *next; + + prev = NULL; + while (swap_map) { + next = swap_map->next; + swap_map->next = prev; + prev = swap_map; + swap_map = next; + } + return prev; +} - if (!mod) - mod = 1; +/** + * free_swap_map_entries - free the swap entries allocated to store + * the swap map @swap_map (this is only called in case of an error) + */ +static inline void free_swap_map_entries(struct swap_map_page *swap_map) +{ + while (swap_map) { + if (swap_map->next_swap.val) + swap_free(swap_map->next_swap); + swap_map = swap_map->next; + } +} - printk( "Writing data to swap (%d pages)... ", nr_copy_pages ); - for_each_pbe (p, pagedir_nosave) { - if (!(i%mod)) - printk( "\b\b\b\b%3d%%", i / mod ); - if ((error = write_page(p->address, &p->swap_address))) +/** + * save_swap_map - save the swap map used for tracing the data pages + * stored in the swap + */ + +static int save_swap_map(struct swap_map_page *swap_map, swp_entry_t *start) +{ + swp_entry_t entry = (swp_entry_t){0}; + int error; + + while (swap_map) { + swap_map->next_swap = entry; + if ((error = write_page((unsigned long)swap_map, &entry))) return error; - i++; + swap_map = swap_map->next; } - printk("\b\b\b\bdone\n"); + *start = entry; + return 0; +} + +/** + * free_image_entries - free the swap entries allocated to store + * the image data pages (this is only called in case of an error) + */ + +static inline void free_image_entries(struct swap_map_page *swp) +{ + unsigned k; + + while (swp) { + for (k = 0; k < MAP_PAGE_SIZE; k++) + if (swp->entries[k].val) + swap_free(swp->entries[k]); + swp = swp->next; + } +} + +/** + * The swap_map_handle structure is used for handling the swap map in + * a file-alike way + */ + +struct swap_map_handle { + struct swap_map_page *cur; + unsigned int k; +}; + +static inline void init_swap_map_handle(struct swap_map_handle *handle, + struct swap_map_page *map) +{ + handle->cur = map; + handle->k = 0; +} + +static inline int swap_map_write_page(struct swap_map_handle *handle, + unsigned long addr) +{ + int error; + + error = write_page(addr, handle->cur->entries + handle->k); + if (error) + return error; + if (++handle->k >= MAP_PAGE_SIZE) { + handle->cur = handle->cur->next; + handle->k = 0; + } + return 0; +} + +/** + * save_image_data - save the data pages pointed to by the PBEs + * from the list @pblist using the swap map handle @handle + * (assume there are @nr_pages data pages to save) + */ + +static int save_image_data(struct pbe *pblist, + struct swap_map_handle *handle, + unsigned int nr_pages) +{ + unsigned int m; + struct pbe *p; + int error = 0; + + printk("Saving image data pages (%u pages) ... ", nr_pages); + m = nr_pages / 100; + if (!m) + m = 1; + nr_pages = 0; + for_each_pbe (p, pblist) { + error = swap_map_write_page(handle, p->address); + if (error) + break; + if (!(nr_pages % m)) + printk("\b\b\b\b%3d%%", nr_pages / m); + nr_pages++; + } + if (!error) + printk("\b\b\b\bdone\n"); return error; } @@ -295,19 +443,20 @@ static void dump_info(void) pr_debug(" swsusp: UTS Domain: %s\n",swsusp_info.uts.domainname); pr_debug(" swsusp: CPUs: %d\n",swsusp_info.cpus); pr_debug(" swsusp: Image: %ld Pages\n",swsusp_info.image_pages); - pr_debug(" swsusp: Pagedir: %ld Pages\n",swsusp_info.pagedir_pages); + pr_debug(" swsusp: Total: %ld Pages\n", swsusp_info.pages); } -static void init_header(void) +static void init_header(unsigned int nr_pages) { memset(&swsusp_info, 0, sizeof(swsusp_info)); swsusp_info.version_code = LINUX_VERSION_CODE; swsusp_info.num_physpages = num_physpages; memcpy(&swsusp_info.uts, &system_utsname, sizeof(system_utsname)); - swsusp_info.suspend_pagedir = pagedir_nosave; swsusp_info.cpus = num_online_cpus(); - swsusp_info.image_pages = nr_copy_pages; + swsusp_info.image_pages = nr_pages; + swsusp_info.pages = nr_pages + + ((nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT); } static int close_swap(void) @@ -326,39 +475,53 @@ static int close_swap(void) } /** - * free_pagedir_entries - Free pages used by the page directory. - * - * This is used during suspend for error recovery. + * pack_orig_addresses - the .orig_address fields of the PBEs from the + * list starting at @pbe are stored in the array @buf[] (1 page) */ -static void free_pagedir_entries(void) +static inline struct pbe *pack_orig_addresses(unsigned long *buf, + struct pbe *pbe) { - int i; + int j; - for (i = 0; i < swsusp_info.pagedir_pages; i++) - swap_free(swsusp_info.pagedir[i]); + for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) { + buf[j] = pbe->orig_address; + pbe = pbe->next; + } + if (!pbe) + for (; j < PAGE_SIZE / sizeof(long); j++) + buf[j] = 0; + return pbe; } - /** - * write_pagedir - Write the array of pages holding the page directory. - * @last: Last swap entry we write (needed for header). + * save_image_metadata - save the .orig_address fields of the PBEs + * from the list @pblist using the swap map handle @handle */ -static int write_pagedir(void) +static int save_image_metadata(struct pbe *pblist, + struct swap_map_handle *handle) { - int error = 0; + unsigned long *buf; unsigned int n = 0; - struct pbe *pbe; + struct pbe *p; + int error = 0; - printk( "Writing pagedir..."); - for_each_pb_page (pbe, pagedir_nosave) { - if ((error = write_page((unsigned long)pbe, &swsusp_info.pagedir[n++]))) - return error; + printk("Saving image metadata ... "); + buf = (unsigned long *)get_zeroed_page(GFP_ATOMIC); + if (!buf) + return -ENOMEM; + p = pblist; + while (p) { + p = pack_orig_addresses(buf, p); + error = swap_map_write_page(handle, (unsigned long)buf); + if (error) + break; + n++; } - - swsusp_info.pagedir_pages = n; - printk("done (%u pages)\n", n); + free_page((unsigned long)buf); + if (!error) + printk("done (%u pages saved)\n", n); return error; } @@ -384,33 +547,48 @@ static int enough_swap(unsigned int nr_pages) /** * write_suspend_image - Write entire image and metadata. - * */ -static int write_suspend_image(void) +static int write_suspend_image(struct pbe *pblist, unsigned int nr_pages) { + struct swap_map_page *swap_map; + struct swap_map_handle handle; int error; - if (!enough_swap(nr_copy_pages)) { + if (!enough_swap(nr_pages)) { printk(KERN_ERR "swsusp: Not enough free swap\n"); return -ENOSPC; } - init_header(); - if ((error = data_write())) - goto FreeData; + init_header(nr_pages); + swap_map = alloc_swap_map(swsusp_info.pages); + if (!swap_map) + return -ENOMEM; + init_swap_map_handle(&handle, swap_map); - if ((error = write_pagedir())) - goto FreePagedir; + error = save_image_metadata(pblist, &handle); + if (!error) + error = save_image_data(pblist, &handle, nr_pages); + if (error) + goto Free_image_entries; - if ((error = close_swap())) - goto FreePagedir; - Done: + swap_map = reverse_swap_map(swap_map); + error = save_swap_map(swap_map, &swsusp_info.start); + if (error) + goto Free_map_entries; + + error = close_swap(); + if (error) + goto Free_map_entries; + +Free_swap_map: + free_swap_map(swap_map); return error; - FreePagedir: - free_pagedir_entries(); - FreeData: - data_free(); - goto Done; + +Free_map_entries: + free_swap_map_entries(swap_map); +Free_image_entries: + free_image_entries(swap_map); + goto Free_swap_map; } /* It is important _NOT_ to umount filesystems at this point. We want @@ -418,7 +596,7 @@ static int write_suspend_image(void) * filesystem clean: it is not. (And it does not matter, if we resume * correctly, we'll mark system clean, anyway.) */ -int swsusp_write(void) +int swsusp_write(struct pbe *pblist, unsigned int nr_pages) { int error; @@ -427,14 +605,12 @@ int swsusp_write(void) return error; } lock_swapdevices(); - error = write_suspend_image(); + error = write_suspend_image(pblist, nr_pages); /* This will unlock ignored swap devices since writing is finished */ lock_swapdevices(); return error; } - - int swsusp_suspend(void) { int error; @@ -531,7 +707,6 @@ static void copy_page_backup_list(struct pbe *dst, struct pbe *src) /* We assume both lists contain the same number of elements */ while (src) { dst->orig_address = src->orig_address; - dst->swap_address = src->swap_address; dst = dst->next; src = src->next; } @@ -611,6 +786,61 @@ static int bio_write_page(pgoff_t page_off, void *page) return submit(WRITE, page_off, page); } +/** + * The following functions allow us to read data using a swap map + * in a file-alike way + */ + +static inline void release_swap_map_reader(struct swap_map_handle *handle) +{ + if (handle->cur) + free_page((unsigned long)handle->cur); + handle->cur = NULL; +} + +static inline int get_swap_map_reader(struct swap_map_handle *handle, + swp_entry_t start) +{ + int error; + + if (!swp_offset(start)) + return -EINVAL; + handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC); + if (!handle->cur) + return -ENOMEM; + error = bio_read_page(swp_offset(start), handle->cur); + if (error) { + release_swap_map_reader(handle); + return error; + } + handle->k = 0; + return 0; +} + +static inline int swap_map_read_page(struct swap_map_handle *handle, void *buf) +{ + unsigned long offset; + int error; + + if (!handle->cur) + return -EINVAL; + offset = swp_offset(handle->cur->entries[handle->k]); + if (!offset) + return -EINVAL; + error = bio_read_page(offset, buf); + if (error) + return error; + if (++handle->k >= MAP_PAGE_SIZE) { + handle->k = 0; + offset = swp_offset(handle->cur->next_swap); + if (!offset) + release_swap_map_reader(handle); + else + error = bio_read_page(offset, handle->cur); + } + return error; +} + /* * Sanity check if this image makes sense with this kernel/swap context * I really don't think that it's foolproof but more than nothing.. @@ -639,7 +869,6 @@ static const char *sanity_check(void) return NULL; } - static int check_header(void) { const char *reason = NULL; @@ -653,7 +882,6 @@ static int check_header(void) printk(KERN_ERR "swsusp: Resume mismatch: %s\n",reason); return -EPERM; } - nr_copy_pages = swsusp_info.image_pages; return error; } @@ -680,75 +908,88 @@ static int check_sig(void) } /** - * data_read - Read image pages from swap. - * - * You do not need to check for overlaps, check_pagedir() - * already did that. + * load_image_data - load the image data using the swap map handle + * @handle and store them using the page backup list @pblist + * (assume there are @nr_pages pages to load) */ -static int data_read(struct pbe *pblist) +static int load_image_data(struct pbe *pblist, + struct swap_map_handle *handle, + unsigned int nr_pages) { + int error; + unsigned int m; struct pbe *p; - int error = 0; - int i = 0; - int mod = swsusp_info.image_pages / 100; - - if (!mod) - mod = 1; - - printk("swsusp: Reading image data (%lu pages): ", - swsusp_info.image_pages); - - for_each_pbe (p, pblist) { - if (!(i % mod)) - printk("\b\b\b\b%3d%%", i / mod); - if ((error = bio_read_page(swp_offset(p->swap_address), - (void *)p->address))) - return error; - - i++; + if (!pblist) + return -EINVAL; + printk("Loading image data pages (%u pages) ... ", nr_pages); + m = nr_pages / 100; + if (!m) + m = 1; + nr_pages = 0; + p = pblist; + while (p) { + error = swap_map_read_page(handle, (void *)p->address); + if (error) + break; + p = p->next; + if (!(nr_pages % m)) + printk("\b\b\b\b%3d%%", nr_pages / m); + nr_pages++; } - printk("\b\b\b\bdone\n"); + if (!error) + printk("\b\b\b\bdone\n"); return error; } /** - * read_pagedir - Read page backup list pages from swap + * unpack_orig_addresses - copy the elements of @buf[] (1 page) to + * the PBEs in the list starting at @pbe */ -static int read_pagedir(struct pbe *pblist) +static inline struct pbe *unpack_orig_addresses(unsigned long *buf, + struct pbe *pbe) { - struct pbe *pbpage, *p; - unsigned int i = 0; - int error; + int j; - if (!pblist) - return -EFAULT; + for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) { + pbe->orig_address = buf[j]; + pbe = pbe->next; + } + return pbe; +} - printk("swsusp: Reading pagedir (%lu pages)\n", - swsusp_info.pagedir_pages); +/** + * load_image_metadata - load the image metadata using the swap map + * handle @handle and put them into the PBEs in the list @pblist + */ - for_each_pb_page (pbpage, pblist) { - unsigned long offset = swp_offset(swsusp_info.pagedir[i++]); +static int load_image_metadata(struct pbe *pblist, struct swap_map_handle *handle) +{ + struct pbe *p; + unsigned long *buf; + unsigned int n = 0; + int error = 0; - error = -EFAULT; - if (offset) { - p = (pbpage + PB_PAGE_SKIP)->next; - error = bio_read_page(offset, (void *)pbpage); - (pbpage + PB_PAGE_SKIP)->next = p; - } + printk("Loading image metadata ... "); + buf = (unsigned long *)get_zeroed_page(GFP_ATOMIC); + if (!buf) + return -ENOMEM; + p = pblist; + while (p) { + error = swap_map_read_page(handle, buf); if (error) break; + p = unpack_orig_addresses(buf, p); + n++; } - + free_page((unsigned long)buf); if (!error) - BUG_ON(i != swsusp_info.pagedir_pages); - + printk("done (%u pages loaded)\n", n); return error; } - static int check_suspend_image(void) { int error = 0; @@ -762,34 +1003,39 @@ static int check_suspend_image(void) return 0; } -static int read_suspend_image(void) +static int read_suspend_image(struct pbe **pblist_ptr) { int error = 0; - struct pbe *p; + struct pbe *p, *pblist; + struct swap_map_handle handle; + unsigned int nr_pages = swsusp_info.image_pages; - if (!(p = alloc_pagedir(nr_copy_pages, GFP_ATOMIC, 0))) + p = alloc_pagedir(nr_pages, GFP_ATOMIC, 0); + if (!p) return -ENOMEM; - - if ((error = read_pagedir(p))) + error = get_swap_map_reader(&handle, swsusp_info.start); + if (error) + /* The PBE list at p will be released by swsusp_free() */ return error; - create_pbe_list(p, nr_copy_pages); - mark_unsafe_pages(p); - pagedir_nosave = alloc_pagedir(nr_copy_pages, GFP_ATOMIC, 1); - if (pagedir_nosave) { - create_pbe_list(pagedir_nosave, nr_copy_pages); - copy_page_backup_list(pagedir_nosave, p); + error = load_image_metadata(p, &handle); + if (!error) { + mark_unsafe_pages(p); + pblist = alloc_pagedir(nr_pages, GFP_ATOMIC, 1); + if (pblist) + copy_page_backup_list(pblist, p); + free_pagedir(p); + if (!pblist) + error = -ENOMEM; + + /* Allocate memory for the image and read the data from swap */ + if (!error) + error = alloc_data_pages(pblist, GFP_ATOMIC, 1); + if (!error) + error = load_image_data(pblist, &handle, nr_pages); + if (!error) + *pblist_ptr = pblist; } - free_pagedir(p); - if (!pagedir_nosave) - return -ENOMEM; - - /* Allocate memory for the image and read the data from swap */ - - error = alloc_data_pages(pagedir_nosave, GFP_ATOMIC, 1); - - if (!error) - error = data_read(pagedir_nosave); - + release_swap_map_reader(&handle); return error; } @@ -821,7 +1067,7 @@ int swsusp_check(void) * swsusp_read - Read saved image from swap. */ -int swsusp_read(void) +int swsusp_read(struct pbe **pblist_ptr) { int error; @@ -830,7 +1076,7 @@ int swsusp_read(void) return PTR_ERR(resume_bdev); } - error = read_suspend_image(); + error = read_suspend_image(pblist_ptr); blkdev_put(resume_bdev); if (!error) -- cgit v1.1 From 72a97e08394a3b2e75481ff680ec2a0591e3cba4 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:13:46 -0800 Subject: [PATCH] swsusp: improve freeing of memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch makes swsusp free only as much memory as needed to complete the suspend and not as much as possible.  In the most of cases this should speed up the suspend and make the system much more responsive after resume, especially if a GUI (eg. X Windows) is used. If needed, the old behavior (ie to free as much memory as possible during suspend) can be restored by unsetting FAST_FREE in power.h Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/suspend.h | 2 +- kernel/power/disk.c | 30 +++-------------------- kernel/power/power.h | 14 ++++++++--- kernel/power/snapshot.c | 65 +++++++++++++++++++++++++++++++++++++++++++++---- kernel/power/swsusp.c | 52 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 126 insertions(+), 37 deletions(-) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 33bbaea..5dc94e7 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -73,6 +73,6 @@ unsigned long get_safe_page(gfp_t gfp_mask); * XXX: We try to keep some more pages free so that I/O operations succeed * without paging. Might this be more? */ -#define PAGES_FOR_IO 512 +#define PAGES_FOR_IO 1024 #endif /* _LINUX_SWSUSP_H */ diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 76a5131..9e51cdf 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c @@ -24,6 +24,7 @@ extern suspend_disk_method_t pm_disk_mode; +extern int swsusp_shrink_memory(void); extern int swsusp_suspend(void); extern int swsusp_write(struct pbe *pblist, unsigned int nr_pages); extern int swsusp_check(void); @@ -73,31 +74,6 @@ static void power_down(suspend_disk_method_t mode) static int in_suspend __nosavedata = 0; -/** - * free_some_memory - Try to free as much memory as possible - * - * ... but do not OOM-kill anyone - * - * Notice: all userland should be stopped at this point, or - * livelock is possible. - */ - -static void free_some_memory(void) -{ - unsigned int i = 0; - unsigned int tmp; - unsigned long pages = 0; - char *p = "-\\|/"; - - printk("Freeing memory... "); - while ((tmp = shrink_all_memory(10000))) { - pages += tmp; - printk("\b%c", p[i++ % 4]); - } - printk("\bdone (%li pages freed)\n", pages); -} - - static inline void platform_finish(void) { if (pm_disk_mode == PM_DISK_PLATFORM) { @@ -127,8 +103,8 @@ static int prepare_processes(void) } /* Free memory before shutting down devices. */ - free_some_memory(); - return 0; + if (!(error = swsusp_shrink_memory())) + return 0; thaw: thaw_processes(); enable_nonboot_cpus(); diff --git a/kernel/power/power.h b/kernel/power/power.h index 977877c..acdc83b 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -49,18 +49,26 @@ extern void thaw_processes(void); extern int pm_prepare_console(void); extern void pm_restore_console(void); - /* References to section boundaries */ extern const void __nosave_begin, __nosave_end; extern unsigned int nr_copy_pages; -extern suspend_pagedir_t *pagedir_nosave; -extern suspend_pagedir_t *pagedir_save; +extern struct pbe *pagedir_nosave; + +/* + * This compilation switch determines the way in which memory will be freed + * during suspend. If defined, only as much memory will be freed as needed + * to complete the suspend, which will make it go faster. Otherwise, the + * largest possible amount of memory will be freed. + */ +#define FAST_FREE 1 extern asmlinkage int swsusp_arch_suspend(void); extern asmlinkage int swsusp_arch_resume(void); +extern unsigned int count_data_pages(void); extern void free_pagedir(struct pbe *pblist); +extern void release_eaten_pages(void); extern struct pbe *alloc_pagedir(unsigned nr_pages, gfp_t gfp_mask, int safe_needed); extern void swsusp_free(void); extern int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed); diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index 152d56c..e80d282 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -37,6 +37,31 @@ struct pbe *pagedir_nosave; unsigned int nr_copy_pages; #ifdef CONFIG_HIGHMEM +unsigned int count_highmem_pages(void) +{ + struct zone *zone; + unsigned long zone_pfn; + unsigned int n = 0; + + for_each_zone (zone) + if (is_highmem(zone)) { + mark_free_pages(zone); + for (zone_pfn = 0; zone_pfn < zone->spanned_pages; zone_pfn++) { + struct page *page; + unsigned long pfn = zone_pfn + zone->zone_start_pfn; + if (!pfn_valid(pfn)) + continue; + page = pfn_to_page(pfn); + if (PageReserved(page)) + continue; + if (PageNosaveFree(page)) + continue; + n++; + } + } + return n; +} + struct highmem_page { char *data; struct page *page; @@ -152,17 +177,15 @@ static int saveable(struct zone *zone, unsigned long *zone_pfn) BUG_ON(PageReserved(page) && PageNosave(page)); if (PageNosave(page)) return 0; - if (PageReserved(page) && pfn_is_nosave(pfn)) { - pr_debug("[nosave pfn 0x%lx]", pfn); + if (PageReserved(page) && pfn_is_nosave(pfn)) return 0; - } if (PageNosaveFree(page)) return 0; return 1; } -static unsigned count_data_pages(void) +unsigned int count_data_pages(void) { struct zone *zone; unsigned long zone_pfn; @@ -267,6 +290,35 @@ static inline void create_pbe_list(struct pbe *pblist, unsigned int nr_pages) } /** + * On resume it is necessary to trace and eventually free the unsafe + * pages that have been allocated, because they are needed for I/O + * (on x86-64 we likely will "eat" these pages once again while + * creating the temporary page translation tables) + */ + +struct eaten_page { + struct eaten_page *next; + char padding[PAGE_SIZE - sizeof(void *)]; +}; + +static struct eaten_page *eaten_pages = NULL; + +void release_eaten_pages(void) +{ + struct eaten_page *p, *q; + + p = eaten_pages; + while (p) { + q = p->next; + /* We don't want swsusp_free() to free this page again */ + ClearPageNosave(virt_to_page(p)); + free_page((unsigned long)p); + p = q; + } + eaten_pages = NULL; +} + +/** * @safe_needed - on resume, for storing the PBE list and the image, * we can only use memory pages that do not conflict with the pages * which had been used before suspend. @@ -284,9 +336,12 @@ static inline void *alloc_image_page(gfp_t gfp_mask, int safe_needed) if (safe_needed) do { res = (void *)get_zeroed_page(gfp_mask); - if (res && PageNosaveFree(virt_to_page(res))) + if (res && PageNosaveFree(virt_to_page(res))) { /* This is for swsusp_free() */ SetPageNosave(virt_to_page(res)); + ((struct eaten_page *)res)->next = eaten_pages; + eaten_pages = res; + } } while (res && PageNosaveFree(virt_to_page(res))); else res = (void *)get_zeroed_page(gfp_mask); diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index b09bd7c..f77f939 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c @@ -70,11 +70,13 @@ #include "power.h" #ifdef CONFIG_HIGHMEM +unsigned int count_highmem_pages(void); int save_highmem(void); int restore_highmem(void); #else static int save_highmem(void) { return 0; } static int restore_highmem(void) { return 0; } +static unsigned int count_highmem_pages(void) { return 0; } #endif extern char resume_file[]; @@ -611,6 +613,52 @@ int swsusp_write(struct pbe *pblist, unsigned int nr_pages) return error; } +/** + * swsusp_shrink_memory - Try to free as much memory as needed + * + * ... but do not OOM-kill anyone + * + * Notice: all userland should be stopped before it is called, or + * livelock is possible. + */ + +#define SHRINK_BITE 10000 + +int swsusp_shrink_memory(void) +{ + long tmp; + struct zone *zone; + unsigned long pages = 0; + unsigned int i = 0; + char *p = "-\\|/"; + + printk("Shrinking memory... "); + do { +#ifdef FAST_FREE + tmp = 2 * count_highmem_pages(); + tmp += tmp / 50 + count_data_pages(); + tmp += (tmp + PBES_PER_PAGE - 1) / PBES_PER_PAGE + + PAGES_FOR_IO; + for_each_zone (zone) + if (!is_highmem(zone)) + tmp -= zone->free_pages; + if (tmp > 0) { + tmp = shrink_all_memory(SHRINK_BITE); + if (!tmp) + return -ENOMEM; + pages += tmp; + } +#else + tmp = shrink_all_memory(SHRINK_BITE); + pages += tmp; +#endif + printk("\b%c", p[i++%4]); + } while (tmp > 0); + printk("\bdone (%lu pages freed)\n", pages); + + return 0; +} + int swsusp_suspend(void) { int error; @@ -1030,8 +1078,10 @@ static int read_suspend_image(struct pbe **pblist_ptr) /* Allocate memory for the image and read the data from swap */ if (!error) error = alloc_data_pages(pblist, GFP_ATOMIC, 1); - if (!error) + if (!error) { + release_eaten_pages(); error = load_image_data(pblist, &handle, nr_pages); + } if (!error) *pblist_ptr = pblist; } -- cgit v1.1 From e5e2fa7857f6bf46605c77d949fa6698b9b0bc28 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:14:20 -0800 Subject: [PATCH] swsusp: fix enough_free_mem This patch fixes a problem with the function enough_free_mem() used by swsusp to verify if there is a sufficient number of memory pages available to it to create and save the suspend image. Namely, enough_free_mem() uses nr_free_pages() to obtain the number of free memory pages, which is incorrect, because this function returns the total number of free pages, including free highmem pages, and the highmem pages cannot be used by swsusp for storing the image data. The patch makes enough_free_mem() avoid counting the free highmem pages as available to swsusp. Signed-off-by: Rafael J. Wysocki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/power/snapshot.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c index e80d282..41f6636 100644 --- a/kernel/power/snapshot.c +++ b/kernel/power/snapshot.c @@ -428,8 +428,14 @@ void swsusp_free(void) static int enough_free_mem(unsigned int nr_pages) { - pr_debug("swsusp: available memory: %u pages\n", nr_free_pages()); - return nr_free_pages() > (nr_pages + PAGES_FOR_IO + + struct zone *zone; + unsigned int n = 0; + + for_each_zone (zone) + if (!is_highmem(zone)) + n += zone->free_pages; + pr_debug("swsusp: available memory: %u pages\n", n); + return n > (nr_pages + PAGES_FOR_IO + (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE); } -- cgit v1.1 From e7c045c14bffcab2d329e86b80dc8ff7d528e05b Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Fri, 6 Jan 2006 00:15:07 -0800 Subject: [PATCH] oss: remove deprecated PM interface from ad1848 driver This change removes the old, deprecated interface from the ad1848 driver, including the pm_{,un}register() calls, the local storage of the pmdev object and the reference to the old header files. This change is done to assist in eradicating the users of the legacy interface so as to help facilitate the removal of the interface itself. Signed-off-by: Patrick Mochel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- sound/oss/ad1848.c | 92 ------------------------------------------------------ 1 file changed, 92 deletions(-) diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c index 3f30c57..49796be 100644 --- a/sound/oss/ad1848.c +++ b/sound/oss/ad1848.c @@ -46,8 +46,6 @@ #include #include #include -#include -#include #include #include #include @@ -105,9 +103,6 @@ typedef struct int irq_ok; mixer_ents *mix_devices; int mixer_output_port; - - /* Power management */ - struct pm_dev *pmdev; } ad1848_info; typedef struct ad1848_port_info @@ -201,7 +196,6 @@ static void ad1848_halt(int dev); static void ad1848_halt_input(int dev); static void ad1848_halt_output(int dev); static void ad1848_trigger(int dev, int bits); -static int ad1848_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data); #ifndef EXCLUDE_TIMERS static int ad1848_tmr_install(int dev); @@ -2027,10 +2021,6 @@ int ad1848_init (char *name, struct resource *ports, int irq, int dma_playback, nr_ad1848_devs++; - devc->pmdev = pm_register(PM_ISA_DEV, my_dev, ad1848_pm_callback); - if (devc->pmdev) - devc->pmdev->data = devc; - ad1848_init_hw(devc); if (irq > 0) @@ -2197,9 +2187,6 @@ void ad1848_unload(int io_base, int irq, int dma_playback, int dma_capture, int if(mixer>=0) sound_unload_mixerdev(mixer); - if (devc->pmdev) - pm_unregister(devc->pmdev); - nr_ad1848_devs--; for ( ; i < nr_ad1848_devs ; i++) adev_info[i] = adev_info[i+1]; @@ -2811,85 +2798,6 @@ static int ad1848_tmr_install(int dev) } #endif /* EXCLUDE_TIMERS */ -static int ad1848_suspend(ad1848_info *devc) -{ - unsigned long flags; - - spin_lock_irqsave(&devc->lock,flags); - - ad_mute(devc); - - spin_unlock_irqrestore(&devc->lock,flags); - return 0; -} - -static int ad1848_resume(ad1848_info *devc) -{ - int mixer_levels[32], i; - - /* Thinkpad is a bit more of PITA than normal. The BIOS tends to - restore it in a different config to the one we use. Need to - fix this somehow */ - - /* store old mixer levels */ - memcpy(mixer_levels, devc->levels, sizeof (mixer_levels)); - ad1848_init_hw(devc); - - /* restore mixer levels */ - for (i = 0; i < 32; i++) - ad1848_mixer_set(devc, devc->dev_no, mixer_levels[i]); - - if (!devc->subtype) { - static signed char interrupt_bits[12] = { -1, -1, -1, -1, -1, 0x00, -1, 0x08, -1, 0x10, 0x18, 0x20 }; - static char dma_bits[4] = { 1, 2, 0, 3 }; - unsigned long flags; - signed char bits; - char dma2_bit = 0; - - int config_port = devc->base + 0; - - bits = interrupt_bits[devc->irq]; - if (bits == -1) { - printk(KERN_ERR "MSS: Bad IRQ %d\n", devc->irq); - return -1; - } - - spin_lock_irqsave(&devc->lock,flags); - - outb((bits | 0x40), config_port); - - if (devc->dma2 != -1 && devc->dma2 != devc->dma1) - if ( (devc->dma1 == 0 && devc->dma2 == 1) || - (devc->dma1 == 1 && devc->dma2 == 0) || - (devc->dma1 == 3 && devc->dma2 == 0)) - dma2_bit = 0x04; - - outb((bits | dma_bits[devc->dma1] | dma2_bit), config_port); - spin_unlock_irqrestore(&devc->lock,flags); - } - - return 0; -} - -static int ad1848_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data) -{ - ad1848_info *devc = dev->data; - if (devc) { - DEB(printk("ad1848: pm event received: 0x%x\n", rqst)); - - switch (rqst) { - case PM_SUSPEND: - ad1848_suspend(devc); - break; - case PM_RESUME: - ad1848_resume(devc); - break; - } - } - return 0; -} - - EXPORT_SYMBOL(ad1848_detect); EXPORT_SYMBOL(ad1848_init); EXPORT_SYMBOL(ad1848_unload); -- cgit v1.1 From ee77e2754247d011a11f572788040cda2493c998 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Fri, 6 Jan 2006 00:15:14 -0800 Subject: [PATCH] oss: remove deprecated PM interface from cs4281 driver This change removes the old, deprecated interface from the cs4281 driver, including the pm_{,un}register() calls, the local storage of the pmdev object and the reference to the old header files. This change is done to assist in eradicating the users of the legacy interface so as to help facilitate the removal of the interface itself. Note that this driver has been obsoleted by an ALSA equivalent. Note that this driver has hooks for PCI power management, but does not implement the ->suspend()/->resume() methods. Signed-off-by: Patrick Mochel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- sound/oss/cs4281/cs4281m.c | 21 +-------------------- sound/oss/cs4281/cs4281pm-24.c | 39 --------------------------------------- 2 files changed, 1 insertion(+), 59 deletions(-) diff --git a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c index adc6896..46dd41d 100644 --- a/sound/oss/cs4281/cs4281m.c +++ b/sound/oss/cs4281/cs4281m.c @@ -298,7 +298,6 @@ struct cs4281_state { struct cs4281_pipeline pl[CS4281_NUMBER_OF_PIPELINES]; }; -#include #include "cs4281pm-24.c" #if CSDEBUG @@ -4256,9 +4255,6 @@ static void __devinit cs4281_InitPM(struct cs4281_state *s) static int __devinit cs4281_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid) { -#ifndef NOT_CS4281_PM - struct pm_dev *pmdev; -#endif struct cs4281_state *s; dma_addr_t dma_mask; mm_segment_t fs; @@ -4374,19 +4370,7 @@ static int __devinit cs4281_probe(struct pci_dev *pcidev, } #ifndef NOT_CS4281_PM cs4281_InitPM(s); - pmdev = cs_pm_register(PM_PCI_DEV, PM_PCI_ID(pcidev), cs4281_pm_callback); - if (pmdev) - { - CS_DBGOUT(CS_INIT | CS_PM, 4, printk(KERN_INFO - "cs4281: probe() pm_register() succeeded (%p).\n", pmdev)); - pmdev->data = s; - } - else - { - CS_DBGOUT(CS_INIT | CS_PM | CS_ERROR, 0, printk(KERN_INFO - "cs4281: probe() pm_register() failed (%p).\n", pmdev)); - s->pm.flags |= CS4281_PM_NOT_REGISTERED; - } + s->pm.flags |= CS4281_PM_NOT_REGISTERED; #endif pci_set_master(pcidev); // enable bus mastering @@ -4487,9 +4471,6 @@ static int __init cs4281_init_module(void) static void __exit cs4281_cleanup_module(void) { pci_unregister_driver(&cs4281_pci_driver); -#ifndef NOT_CS4281_PM - cs_pm_unregister_all(cs4281_pm_callback); -#endif CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO "cs4281: cleanup_cs4281() finished\n")); } diff --git a/sound/oss/cs4281/cs4281pm-24.c b/sound/oss/cs4281/cs4281pm-24.c index d2a453a..90cbd76 100644 --- a/sound/oss/cs4281/cs4281pm-24.c +++ b/sound/oss/cs4281/cs4281pm-24.c @@ -27,9 +27,6 @@ #ifndef NOT_CS4281_PM #include -#define cs_pm_register(a, b, c) pm_register((a), (b), (c)); -#define cs_pm_unregister_all(a) pm_unregister_all((a)); - static int cs4281_suspend(struct cs4281_state *s); static int cs4281_resume(struct cs4281_state *s); /* @@ -41,42 +38,6 @@ static int cs4281_resume(struct cs4281_state *s); #define CS4281_SUSPEND_TBL cs4281_suspend_null #define CS4281_RESUME_TBL cs4281_resume_null -static int cs4281_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data) -{ - struct cs4281_state *state; - - CS_DBGOUT(CS_PM, 2, printk(KERN_INFO - "cs4281: cs4281_pm_callback dev=%p rqst=0x%x state=%p\n", - dev,(unsigned)rqst,data)); - state = (struct cs4281_state *) dev->data; - if (state) { - switch(rqst) { - case PM_SUSPEND: - CS_DBGOUT(CS_PM, 2, printk(KERN_INFO - "cs4281: PM suspend request\n")); - if(cs4281_suspend(state)) - { - CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO - "cs4281: PM suspend request refused\n")); - return 1; - } - break; - case PM_RESUME: - CS_DBGOUT(CS_PM, 2, printk(KERN_INFO - "cs4281: PM resume request\n")); - if(cs4281_resume(state)) - { - CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO - "cs4281: PM resume request refused\n")); - return 1; - } - break; - } - } - - return 0; -} - #else /* CS4281_PM */ #define CS4281_SUSPEND_TBL cs4281_suspend_null #define CS4281_RESUME_TBL cs4281_resume_null -- cgit v1.1 From 94661e7c33e6e3001be07d76d3a87eaa41dad3df Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Fri, 6 Jan 2006 00:15:17 -0800 Subject: [PATCH] oss: remove deprecated PM interface from cs46xx driver This change removes the old, deprecated interface from the cs46xx driver, including the pm_{,un}register() calls, the local storage of the pmdev object and the reference to the old header files. This change is done to assist in eradicating the users of the legacy interface so as to help facilitate the removal of the interface itself. Note this driver has PCI PM hooks which are set properly. It also has the ability to trigger suspend/resume from an ioctl. This functionality was not touched, though it could use a serious review if this driver continues to persist in the mainline tree.. Note that this driver has been obsoleted by an ALSA equivalent. Signed-off-by: Patrick Mochel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- sound/oss/cs46xx.c | 60 ------------------------------------------------- sound/oss/cs46xxpm-24.h | 4 ---- 2 files changed, 64 deletions(-) diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c index cb998e8..0da4d93 100644 --- a/sound/oss/cs46xx.c +++ b/sound/oss/cs46xx.c @@ -391,10 +391,6 @@ static void cs461x_clear_serial_FIFOs(struct cs_card *card, int type); static int cs46xx_suspend_tbl(struct pci_dev *pcidev, pm_message_t state); static int cs46xx_resume_tbl(struct pci_dev *pcidev); -#ifndef CS46XX_ACPI_SUPPORT -static int cs46xx_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data); -#endif - #if CSDEBUG /* DEBUG ROUTINES */ @@ -5320,7 +5316,6 @@ static const char fndmsg[] = KERN_INFO "cs46xx: Found %d audio device(s).\n"; static int __devinit cs46xx_probe(struct pci_dev *pci_dev, const struct pci_device_id *pciid) { - struct pm_dev *pmdev; int i,j; u16 ss_card, ss_vendor; struct cs_card *card; @@ -5530,22 +5525,6 @@ static int __devinit cs46xx_probe(struct pci_dev *pci_dev, PCI_SET_DMA_MASK(pci_dev, dma_mask); list_add(&card->list, &cs46xx_devs); - pmdev = cs_pm_register(PM_PCI_DEV, PM_PCI_ID(pci_dev), cs46xx_pm_callback); - if (pmdev) - { - CS_DBGOUT(CS_INIT | CS_PM, 4, printk(KERN_INFO - "cs46xx: probe() pm_register() succeeded (%p).\n", - pmdev)); - pmdev->data = card; - } - else - { - CS_DBGOUT(CS_INIT | CS_PM | CS_ERROR, 2, printk(KERN_INFO - "cs46xx: probe() pm_register() failed (%p).\n", - pmdev)); - card->pm.flags |= CS46XX_PM_NOT_REGISTERED; - } - CS_DBGOUT(CS_PM, 9, printk(KERN_INFO "cs46xx: pm.flags=0x%x card=%p\n", (unsigned)card->pm.flags,card)); @@ -5727,7 +5706,6 @@ static int __init cs46xx_init_module(void) static void __exit cs46xx_cleanup_module(void) { pci_unregister_driver(&cs46xx_pci_driver); - cs_pm_unregister_all(cs46xx_pm_callback); CS_DBGOUT(CS_INIT | CS_FUNCTION, 2, printk(KERN_INFO "cs46xx: cleanup_cs46xx() finished\n")); } @@ -5735,44 +5713,6 @@ static void __exit cs46xx_cleanup_module(void) module_init(cs46xx_init_module); module_exit(cs46xx_cleanup_module); -#ifndef CS46XX_ACPI_SUPPORT -static int cs46xx_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data) -{ - struct cs_card *card; - - CS_DBGOUT(CS_PM, 2, printk(KERN_INFO - "cs46xx: cs46xx_pm_callback dev=%p rqst=0x%x card=%p\n", - dev,(unsigned)rqst,data)); - card = (struct cs_card *) dev->data; - if (card) { - switch(rqst) { - case PM_SUSPEND: - CS_DBGOUT(CS_PM, 2, printk(KERN_INFO - "cs46xx: PM suspend request\n")); - if(cs46xx_suspend(card, PMSG_SUSPEND)) - { - CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO - "cs46xx: PM suspend request refused\n")); - return 1; - } - break; - case PM_RESUME: - CS_DBGOUT(CS_PM, 2, printk(KERN_INFO - "cs46xx: PM resume request\n")); - if(cs46xx_resume(card)) - { - CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO - "cs46xx: PM resume request refused\n")); - return 1; - } - break; - } - } - - return 0; -} -#endif - #if CS46XX_ACPI_SUPPORT static int cs46xx_suspend_tbl(struct pci_dev *pcidev, pm_message_t state) { diff --git a/sound/oss/cs46xxpm-24.h b/sound/oss/cs46xxpm-24.h index e220bd7..ad82db8 100644 --- a/sound/oss/cs46xxpm-24.h +++ b/sound/oss/cs46xxpm-24.h @@ -38,13 +38,9 @@ */ static int cs46xx_suspend_tbl(struct pci_dev *pcidev, pm_message_t state); static int cs46xx_resume_tbl(struct pci_dev *pcidev); -#define cs_pm_register(a, b, c) NULL -#define cs_pm_unregister_all(a) #define CS46XX_SUSPEND_TBL cs46xx_suspend_tbl #define CS46XX_RESUME_TBL cs46xx_resume_tbl #else -#define cs_pm_register(a, b, c) pm_register((a), (b), (c)); -#define cs_pm_unregister_all(a) pm_unregister_all((a)); #define CS46XX_SUSPEND_TBL cs46xx_null #define CS46XX_RESUME_TBL cs46xx_null #endif -- cgit v1.1 From 53052539f3e2b29ccaf2064b0d3b8cee51d05621 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Fri, 6 Jan 2006 00:15:18 -0800 Subject: [PATCH] oss: remove deprecated PM interface from maestro driver This change removes the old, deprecated interface from the maestro driver, including the pm_{,un}register() calls, the local storage of the pmdev object and the reference to the old header files. This change is done to assist in eradicating the users of the legacy interface so as to help facilitate the removal of the interface itself. The check_suspend() function and associated logic was not removed, even though it is now unnecessary. Note that this driver has been obsoleted by an ALSA equivalent. Acked-by: Zach Brown Signed-off-by: Patrick Mochel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- sound/oss/maestro.c | 149 ---------------------------------------------------- 1 file changed, 149 deletions(-) diff --git a/sound/oss/maestro.c b/sound/oss/maestro.c index 3abd354..f9ac5b1 100644 --- a/sound/oss/maestro.c +++ b/sound/oss/maestro.c @@ -230,10 +230,6 @@ #include #include -#include -#include -static int maestro_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *d); - #include "maestro.h" static struct pci_driver maestro_pci_driver; @@ -3404,7 +3400,6 @@ maestro_probe(struct pci_dev *pcidev,const struct pci_device_id *pdid) int i, ret; struct ess_card *card; struct ess_state *ess; - struct pm_dev *pmdev; int num = 0; /* when built into the kernel, we only print version if device is found */ @@ -3450,11 +3445,6 @@ maestro_probe(struct pci_dev *pcidev,const struct pci_device_id *pdid) memset(card, 0, sizeof(*card)); card->pcidev = pcidev; - pmdev = pm_register(PM_PCI_DEV, PM_PCI_ID(pcidev), - maestro_pm_callback); - if (pmdev) - pmdev->data = card; - card->iobase = iobase; card->card_type = card_type; card->irq = pcidev->irq; @@ -3670,7 +3660,6 @@ static int maestro_notifier(struct notifier_block *nb, unsigned long event, void static void cleanup_maestro(void) { M_printk("maestro: unloading\n"); pci_unregister_driver(&maestro_pci_driver); - pm_unregister_all(maestro_pm_callback); unregister_reboot_notifier(&maestro_nb); } @@ -3691,143 +3680,5 @@ check_suspend(struct ess_card *card) current->state = TASK_RUNNING; } -static int -maestro_suspend(struct ess_card *card) -{ - unsigned long flags; - int i,j; - - spin_lock_irqsave(&card->lock,flags); /* over-kill */ - - M_printk("maestro: apm in dev %p\n",card); - - /* we have to read from the apu regs, need - to power it up */ - maestro_power(card,ACPI_D0); - - for(i=0;ichannels[i]; - - if(s->dev_audio == -1) - continue; - - M_printk("maestro: stopping apus for device %d\n",i); - stop_dac(s); - stop_adc(s); - for(j=0;j<6;j++) - card->apu_map[s->apu[j]][5]=apu_get_register(s,j,5); - - } - - /* get rid of interrupts? */ - if( card->dsps_open > 0) - stop_bob(&card->channels[0]); - - card->in_suspend++; - - spin_unlock_irqrestore(&card->lock,flags); - - /* we trust in the bios to power down the chip on suspend. - * XXX I'm also not sure that in_suspend will protect - * against all reg accesses from here on out. - */ - return 0; -} -static int -maestro_resume(struct ess_card *card) -{ - unsigned long flags; - int i; - - spin_lock_irqsave(&card->lock,flags); /* over-kill */ - - card->in_suspend = 0; - - M_printk("maestro: resuming card at %p\n",card); - - /* restore all our config */ - maestro_config(card); - /* need to restore the base pointers.. */ - if(card->dmapages) - set_base_registers(&card->channels[0],card->dmapages); - - mixer_push_state(card); - - /* set each channels' apu control registers before - * restoring audio - */ - for(i=0;ichannels[i]; - int chan,reg; - - if(s->dev_audio == -1) - continue; - - for(chan = 0 ; chan < 6 ; chan++) { - wave_set_register(s,s->apu[chan]<<3,s->apu_base[chan]); - for(reg = 1 ; reg < NR_APU_REGS ; reg++) - apu_set_register(s,chan,reg,s->card->apu_map[s->apu[chan]][reg]); - } - for(chan = 0 ; chan < 6 ; chan++) - apu_set_register(s,chan,0,s->card->apu_map[s->apu[chan]][0] & 0xFF0F); - } - - /* now we flip on the music */ - - if( card->dsps_open <= 0) { - /* this card's idle */ - maestro_power(card,ACPI_D2); - } else { - /* ok, we're actually playing things on - this card */ - maestro_power(card,ACPI_D0); - start_bob(&card->channels[0]); - for(i=0;ichannels[i]; - - /* these use the apu_mode, and can handle - spurious calls */ - start_dac(s); - start_adc(s); - } - } - - spin_unlock_irqrestore(&card->lock,flags); - - /* all right, we think things are ready, - wake up people who were using the device - when we suspended */ - wake_up(&(card->suspend_queue)); - - return 0; -} - -int -maestro_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data) -{ - struct ess_card *card = (struct ess_card*) dev->data; - - if ( ! card ) goto out; - - M_printk("maestro: pm event 0x%x received for card %p\n", rqst, card); - - switch (rqst) { - case PM_SUSPEND: - maestro_suspend(card); - break; - case PM_RESUME: - maestro_resume(card); - break; - /* - * we'd also like to find out about - * power level changes because some biosen - * do mean things to the maestro when they - * change their power state. - */ - } -out: - return 0; -} - module_init(init_maestro); module_exit(cleanup_maestro); -- cgit v1.1 From 76cd48a397f126ea883835f5889ee1837596f021 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Fri, 6 Jan 2006 00:15:19 -0800 Subject: [PATCH] oss: remove deprecated PM interface from nm256 driver This change removes the old, deprecated interface from the nm256 driver, including the pm_{,un}register() calls, the local storage of the pmdev object and the reference to the old header files. This change is done to assist in eradicating the users of the legacy interface so as to help facilitate the removal of the interface itself. Note that this driver has been obsoleted by an ALSA equivalent. Signed-off-by: Patrick Mochel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- sound/oss/nm256_audio.c | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/sound/oss/nm256_audio.c b/sound/oss/nm256_audio.c index 0ce2c40..42d8f05 100644 --- a/sound/oss/nm256_audio.c +++ b/sound/oss/nm256_audio.c @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include #include #include "sound_config.h" @@ -49,7 +47,6 @@ static int nm256_grabInterrupt (struct nm256_info *card); static int nm256_releaseInterrupt (struct nm256_info *card); static irqreturn_t nm256_interrupt (int irq, void *dev_id, struct pt_regs *dummy); static irqreturn_t nm256_interrupt_zx (int irq, void *dev_id, struct pt_regs *dummy); -static int handle_pm_event (struct pm_dev *dev, pm_request_t rqst, void *data); /* These belong in linux/pci.h. */ #define PCI_DEVICE_ID_NEOMAGIC_NM256AV_AUDIO 0x8005 @@ -992,15 +989,6 @@ nm256_install_mixer (struct nm256_info *card) return 0; } -/* Perform a full reset on the hardware; this is invoked when an APM - resume event occurs. */ -static void -nm256_full_reset (struct nm256_info *card) -{ - nm256_initHw (card); - ac97_reset (&(card->mdev)); -} - /* * See if the signature left by the NM256 BIOS is intact; if so, we use * the associated address as the end of our audio buffer in the video @@ -1053,7 +1041,6 @@ static int __devinit nm256_install(struct pci_dev *pcidev, enum nm256rev rev, char *verstr) { struct nm256_info *card; - struct pm_dev *pmdev; int x; if (pci_enable_device(pcidev)) @@ -1234,43 +1221,10 @@ nm256_install(struct pci_dev *pcidev, enum nm256rev rev, char *verstr) nm256_install_mixer (card); - pmdev = pm_register(PM_PCI_DEV, PM_PCI_ID(pcidev), handle_pm_event); - if (pmdev) - pmdev->data = card; - return 1; } -/* - * PM event handler, so the card is properly reinitialized after a power - * event. - */ -static int -handle_pm_event (struct pm_dev *dev, pm_request_t rqst, void *data) -{ - struct nm256_info *crd = (struct nm256_info*) dev->data; - if (crd) { - switch (rqst) { - case PM_SUSPEND: - break; - case PM_RESUME: - { - int playing = crd->playing; - nm256_full_reset (crd); - /* - * A little ugly, but that's ok; pretend the - * block we were playing is done. - */ - if (playing) - DMAbuf_outputintr (crd->dev_for_play, 1); - } - break; - } - } - return 0; -} - static int __devinit nm256_probe(struct pci_dev *pcidev,const struct pci_device_id *pciid) { @@ -1696,7 +1650,6 @@ static int __init do_init_nm256(void) static void __exit cleanup_nm256 (void) { pci_unregister_driver(&nm256_pci_driver); - pm_unregister_all (&handle_pm_event); } module_init(do_init_nm256); -- cgit v1.1 From 45029c3207840edb9c9b795de0145ded1c675fce Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Fri, 6 Jan 2006 00:15:20 -0800 Subject: [PATCH] oss: remove deprecated PM interface from opl3sa2 driver This change removes the old, deprecated interface from the opl3sa2 driver, including the pm_{,un}register() calls, the local storage of the pmdev object and the reference to the old header files. This change is done to assist in eradicating the users of the legacy interface so as to help facilitate the removal of the interface itself. Signed-off-by: Patrick Mochel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- sound/oss/opl3sa2.c | 110 ---------------------------------------------------- 1 file changed, 110 deletions(-) diff --git a/sound/oss/opl3sa2.c b/sound/oss/opl3sa2.c index cd41d0e..5cecdbc 100644 --- a/sound/oss/opl3sa2.c +++ b/sound/oss/opl3sa2.c @@ -69,8 +69,6 @@ #include #include #include -#include -#include #include "sound_config.h" #include "ad1848.h" @@ -139,10 +137,6 @@ typedef struct { struct pnp_dev* pdev; int activated; /* Whether said devices have been activated */ #endif -#ifdef CONFIG_PM_LEGACY - unsigned int in_suspend; - struct pm_dev *pmdev; -#endif unsigned int card; int chipset; /* What's my version(s)? */ char *chipset_name; @@ -341,22 +335,6 @@ static void opl3sa2_mixer_reset(opl3sa2_state_t* devc) } } -/* Currently only used for power management */ -#ifdef CONFIG_PM_LEGACY -static void opl3sa2_mixer_restore(opl3sa2_state_t* devc) -{ - if (devc) { - opl3sa2_set_volume(devc, devc->volume_l, devc->volume_r); - opl3sa2_set_mic(devc, devc->mic); - - if (devc->chipset == CHIPSET_OPL3SA3) { - opl3sa3_set_bass(devc, devc->bass_l, devc->bass_r); - opl3sa3_set_treble(devc, devc->treble_l, devc->treble_r); - } - } -} -#endif /* CONFIG_PM_LEGACY */ - static inline void arg_to_vol_mono(unsigned int vol, int* value) { int left; @@ -832,84 +810,6 @@ static struct pnp_driver opl3sa2_driver = { /* End of component functions */ -#ifdef CONFIG_PM_LEGACY - -static DEFINE_SPINLOCK(opl3sa2_lock); - -/* Power Management support functions */ -static int opl3sa2_suspend(struct pm_dev *pdev, unsigned int pm_mode) -{ - unsigned long flags; - opl3sa2_state_t *p; - - if (!pdev) - return -EINVAL; - - spin_lock_irqsave(&opl3sa2_lock,flags); - - p = (opl3sa2_state_t *) pdev->data; - switch (pm_mode) { - case 1: - pm_mode = OPL3SA2_PM_MODE1; - break; - case 2: - pm_mode = OPL3SA2_PM_MODE2; - break; - case 3: - pm_mode = OPL3SA2_PM_MODE3; - break; - default: - /* we don't know howto handle this... */ - spin_unlock_irqrestore(&opl3sa2_lock, flags); - return -EBUSY; - } - - p->in_suspend = 1; - - /* its supposed to automute before suspending, so we won't bother */ - opl3sa2_write(p->cfg_port, OPL3SA2_PM, pm_mode); - /* wait a while for the clock oscillator to stabilise */ - mdelay(10); - - spin_unlock_irqrestore(&opl3sa2_lock,flags); - return 0; -} - -static int opl3sa2_resume(struct pm_dev *pdev) -{ - unsigned long flags; - opl3sa2_state_t *p; - - if (!pdev) - return -EINVAL; - - p = (opl3sa2_state_t *) pdev->data; - spin_lock_irqsave(&opl3sa2_lock,flags); - - /* I don't think this is necessary */ - opl3sa2_write(p->cfg_port, OPL3SA2_PM, OPL3SA2_PM_MODE0); - opl3sa2_mixer_restore(p); - p->in_suspend = 0; - - spin_unlock_irqrestore(&opl3sa2_lock,flags); - return 0; -} - -static int opl3sa2_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data) -{ - unsigned long mode = (unsigned long)data; - - switch (rqst) { - case PM_SUSPEND: - return opl3sa2_suspend(pdev, mode); - - case PM_RESUME: - return opl3sa2_resume(pdev); - } - return 0; -} -#endif /* CONFIG_PM_LEGACY */ - /* * Install OPL3-SA2 based card(s). * @@ -1021,12 +921,6 @@ static int __init init_opl3sa2(void) /* ewww =) */ opl3sa2_state[card].card = card; -#ifdef CONFIG_PM_LEGACY - /* register our power management capabilities */ - opl3sa2_state[card].pmdev = pm_register(PM_ISA_DEV, card, opl3sa2_pm_callback); - if (opl3sa2_state[card].pmdev) - opl3sa2_state[card].pmdev->data = &opl3sa2_state[card]; -#endif /* CONFIG_PM_LEGACY */ /* * Set the Yamaha 3D enhancement mode (aka Ymersion) if asked to and @@ -1083,10 +977,6 @@ static void __exit cleanup_opl3sa2(void) int card; for(card = 0; card < opl3sa2_cards_num; card++) { -#ifdef CONFIG_PM_LEGACY - if (opl3sa2_state[card].pmdev) - pm_unregister(opl3sa2_state[card].pmdev); -#endif if (opl3sa2_state[card].cfg_mpu.slots[1] != -1) { unload_opl3sa2_mpu(&opl3sa2_state[card].cfg_mpu); } -- cgit v1.1 From c050ca78705592d440c22055865bf4de40fe2a4c Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Fri, 6 Jan 2006 00:15:21 -0800 Subject: [PATCH] swsusp: Drop duplicate prototypes These two prototypes are already present in sched.h, remove duplicate version. Signed-off-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/power/power.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/power/power.h b/kernel/power/power.h index acdc83b..e521e61 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -43,9 +43,6 @@ static struct subsys_attribute _name##_attr = { \ extern struct subsystem power_subsys; -extern int freeze_processes(void); -extern void thaw_processes(void); - extern int pm_prepare_console(void); extern void pm_restore_console(void); -- cgit v1.1 From b3a93a255ec33a04776ec50efb30b7a99168dda2 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:15:22 -0800 Subject: [PATCH] swsusp: limit image size Limit the size of the suspend image to approx. 500 MB, which should improve the overall performance of swsusp on systems with more than 1 GB of RAM. It introduces the constant IMAGE_SIZE that can be set to the preferred size of the image (in MB) and modifies the memory-shrinking part of swsusp to take this constant into account (500 is the default value of IMAGE_SIZE). Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/power/power.h | 8 +++----- kernel/power/swsusp.c | 17 ++++++++--------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/kernel/power/power.h b/kernel/power/power.h index e521e61..9b04599 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -53,12 +53,10 @@ extern unsigned int nr_copy_pages; extern struct pbe *pagedir_nosave; /* - * This compilation switch determines the way in which memory will be freed - * during suspend. If defined, only as much memory will be freed as needed - * to complete the suspend, which will make it go faster. Otherwise, the - * largest possible amount of memory will be freed. + * Preferred image size in MB (set it to zero to get the smallest + * image possible) */ -#define FAST_FREE 1 +#define IMAGE_SIZE 500 extern asmlinkage int swsusp_arch_suspend(void); extern asmlinkage int swsusp_arch_resume(void); diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index f77f939..6d5ceaf 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c @@ -626,7 +626,7 @@ int swsusp_write(struct pbe *pblist, unsigned int nr_pages) int swsusp_shrink_memory(void) { - long tmp; + long size, tmp; struct zone *zone; unsigned long pages = 0; unsigned int i = 0; @@ -634,11 +634,11 @@ int swsusp_shrink_memory(void) printk("Shrinking memory... "); do { -#ifdef FAST_FREE - tmp = 2 * count_highmem_pages(); - tmp += tmp / 50 + count_data_pages(); - tmp += (tmp + PBES_PER_PAGE - 1) / PBES_PER_PAGE + + size = 2 * count_highmem_pages(); + size += size / 50 + count_data_pages(); + size += (size + PBES_PER_PAGE - 1) / PBES_PER_PAGE + PAGES_FOR_IO; + tmp = size; for_each_zone (zone) if (!is_highmem(zone)) tmp -= zone->free_pages; @@ -647,11 +647,10 @@ int swsusp_shrink_memory(void) if (!tmp) return -ENOMEM; pages += tmp; + } else if (size > (IMAGE_SIZE * 1024 * 1024) / PAGE_SIZE) { + tmp = shrink_all_memory(SHRINK_BITE); + pages += tmp; } -#else - tmp = shrink_all_memory(SHRINK_BITE); - pages += tmp; -#endif printk("\b%c", p[i++%4]); } while (tmp > 0); printk("\bdone (%lu pages freed)\n", pages); -- cgit v1.1 From ca0aec0f7a94bf9f07fefa8bfd23282d4e8ceb8a Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:15:56 -0800 Subject: [PATCH] swsusp: make image size limit tunable Make the suspend image size limit tunable via /sys/power/image_size. It is necessary for systems on which there is a limited amount of swap available for suspend. It can also be useful for optimizing performance of swsusp on systems with 1 GB of RAM or more. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/power/interface.txt | 11 +++++++++++ Documentation/power/swsusp.txt | 5 +++++ kernel/power/disk.c | 20 ++++++++++++++++++++ kernel/power/power.h | 7 ++----- kernel/power/swsusp.c | 10 +++++++++- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Documentation/power/interface.txt b/Documentation/power/interface.txt index f5ebda5..bd4ffb5 100644 --- a/Documentation/power/interface.txt +++ b/Documentation/power/interface.txt @@ -41,3 +41,14 @@ to. Writing to this file will accept one of It will only change to 'firmware' or 'platform' if the system supports it. +/sys/power/image_size controls the size of the image created by +the suspend-to-disk mechanism. It can be written a string +representing a non-negative integer that will be used as an upper +limit of the image size, in megabytes. The suspend-to-disk mechanism will +do its best to ensure the image size will not exceed that number. However, +if this turns out to be impossible, it will try to suspend anyway using the +smallest image possible. In particular, if "0" is written to this file, the +suspend image will be as small as possible. + +Reading from this file will display the current image size limit, which +is set to 500 MB by default. diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt index b0d5084..cd0fcd8 100644 --- a/Documentation/power/swsusp.txt +++ b/Documentation/power/swsusp.txt @@ -27,6 +27,11 @@ echo shutdown > /sys/power/disk; echo disk > /sys/power/state echo platform > /sys/power/disk; echo disk > /sys/power/state +If you want to limit the suspend image size to N megabytes, do + +echo N > /sys/power/image_size + +before suspend (it is limited to 500 MB by default). Encrypted suspend image: ------------------------ diff --git a/kernel/power/disk.c b/kernel/power/disk.c index 9e51cdf..e24446f 100644 --- a/kernel/power/disk.c +++ b/kernel/power/disk.c @@ -365,9 +365,29 @@ out: power_attr(resume); +static ssize_t image_size_show(struct subsystem * subsys, char *buf) +{ + return sprintf(buf, "%u\n", image_size); +} + +static ssize_t image_size_store(struct subsystem * subsys, const char * buf, size_t n) +{ + unsigned int size; + + if (sscanf(buf, "%u", &size) == 1) { + image_size = size; + return n; + } + + return -EINVAL; +} + +power_attr(image_size); + static struct attribute * g[] = { &disk_attr.attr, &resume_attr.attr, + &image_size_attr.attr, NULL, }; diff --git a/kernel/power/power.h b/kernel/power/power.h index 9b04599..273a5b1 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -52,11 +52,8 @@ extern const void __nosave_begin, __nosave_end; extern unsigned int nr_copy_pages; extern struct pbe *pagedir_nosave; -/* - * Preferred image size in MB (set it to zero to get the smallest - * image possible) - */ -#define IMAGE_SIZE 500 +/* Preferred image size in MB (default 500) */ +extern unsigned int image_size; extern asmlinkage int swsusp_arch_suspend(void); extern asmlinkage int swsusp_arch_resume(void); diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index 6d5ceaf..d760a6a 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c @@ -69,6 +69,14 @@ #include "power.h" +/* + * Preferred image size in MB (tunable via /sys/power/image_size). + * When it is set to N, swsusp will do its best to ensure the image + * size will not exceed N MB, but if that is impossible, it will + * try to create the smallest image possible. + */ +unsigned int image_size = 500; + #ifdef CONFIG_HIGHMEM unsigned int count_highmem_pages(void); int save_highmem(void); @@ -647,7 +655,7 @@ int swsusp_shrink_memory(void) if (!tmp) return -ENOMEM; pages += tmp; - } else if (size > (IMAGE_SIZE * 1024 * 1024) / PAGE_SIZE) { + } else if (size > (image_size * 1024 * 1024) / PAGE_SIZE) { tmp = shrink_all_memory(SHRINK_BITE); pages += tmp; } -- cgit v1.1 From 3a291a20bd6fcfafb2109031f0760a0d3e92ecd7 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:16:37 -0800 Subject: [PATCH] mm: add a new function (needed for swap suspend) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds the function get_swap_page_of_type() allowing us to specify an index in swap_info[] and select a swap_info_struct structure to be used for allocating a swap page. This function (or another one of similar functionality) will be necessary for implementing the image-writing part of swsusp in the user space.  It can also be used for simplifying the current in-kernel implementation of the image-writing part of swsusp. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/swap.h | 1 + mm/swapfile.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/swap.h b/include/linux/swap.h index bd66417..556617b 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -209,6 +209,7 @@ extern unsigned int nr_swapfiles; extern struct swap_info_struct swap_info[]; extern void si_swapinfo(struct sysinfo *); extern swp_entry_t get_swap_page(void); +extern swp_entry_t get_swap_page_of_type(int type); extern int swap_duplicate(swp_entry_t); extern int valid_swaphandles(swp_entry_t, unsigned long *); extern void swap_free(swp_entry_t); diff --git a/mm/swapfile.c b/mm/swapfile.c index edafeac..6da4b28 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -211,6 +211,26 @@ noswap: return (swp_entry_t) {0}; } +swp_entry_t get_swap_page_of_type(int type) +{ + struct swap_info_struct *si; + pgoff_t offset; + + spin_lock(&swap_lock); + si = swap_info + type; + if (si->flags & SWP_WRITEOK) { + nr_swap_pages--; + offset = scan_swap_map(si); + if (offset) { + spin_unlock(&swap_lock); + return swp_entry(type, offset); + } + nr_swap_pages++; + } + spin_unlock(&swap_lock); + return (swp_entry_t) {0}; +} + static struct swap_info_struct * swap_info_get(swp_entry_t entry) { struct swap_info_struct * p; -- cgit v1.1 From 1adf6c8ea916bc4a2587a881ec7715fece63fb5e Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:17:16 -0800 Subject: [PATCH] swsusp: improve handling of swap partitions This changes the handling of swap partitions by swsusp to avoid locking of the swap devices that are not used for suspend and, consequently, simplifies the code. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/power/swsusp.c | 128 ++++++++++++++------------------------------------ 1 file changed, 36 insertions(+), 92 deletions(-) diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index d760a6a..0479c9b 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c @@ -104,13 +104,7 @@ static struct swsusp_info swsusp_info; * Saving part... */ -/* We memorize in swapfile_used what swap devices are used for suspension */ -#define SWAPFILE_UNUSED 0 -#define SWAPFILE_SUSPEND 1 /* This is the suspending device */ -#define SWAPFILE_IGNORED 2 /* Those are other swap devices ignored for suspension */ - -static unsigned short swapfile_used[MAX_SWAPFILES]; -static unsigned short root_swap; +static unsigned short root_swap = 0xffff; static int mark_swapfiles(swp_entry_t prev) { @@ -146,7 +140,7 @@ static int mark_swapfiles(swp_entry_t prev) * devfs, since the resume code can only recognize the form /dev/hda4, * but the suspend code would see the long name.) */ -static int is_resume_device(const struct swap_info_struct *swap_info) +static inline int is_resume_device(const struct swap_info_struct *swap_info) { struct file *file = swap_info->swap_file; struct inode *inode = file->f_dentry->d_inode; @@ -157,54 +151,22 @@ static int is_resume_device(const struct swap_info_struct *swap_info) static int swsusp_swap_check(void) /* This is called before saving image */ { - int i, len; - - len=strlen(resume_file); - root_swap = 0xFFFF; - - spin_lock(&swap_lock); - for (i=0; i (nr_pages + PAGES_FOR_IO + + pr_debug("swsusp: free swap pages: %u\n", free_swap); + return free_swap > (nr_pages + PAGES_FOR_IO + (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE); } /** - * write_suspend_image - Write entire image and metadata. + * swsusp_write - Write entire image and metadata. + * + * It is important _NOT_ to umount filesystems at this point. We want + * them synced (in case something goes wrong) but we DO not want to mark + * filesystem clean: it is not. (And it does not matter, if we resume + * correctly, we'll mark system clean, anyway.) */ -static int write_suspend_image(struct pbe *pblist, unsigned int nr_pages) + +int swsusp_write(struct pbe *pblist, unsigned int nr_pages) { struct swap_map_page *swap_map; struct swap_map_handle handle; int error; + if ((error = swsusp_swap_check())) { + printk(KERN_ERR "swsusp: Cannot find swap device, try swapon -a.\n"); + return error; + } if (!enough_swap(nr_pages)) { printk(KERN_ERR "swsusp: Not enough free swap\n"); return -ENOSPC; @@ -601,26 +565,6 @@ Free_image_entries: goto Free_swap_map; } -/* It is important _NOT_ to umount filesystems at this point. We want - * them synced (in case something goes wrong) but we DO not want to mark - * filesystem clean: it is not. (And it does not matter, if we resume - * correctly, we'll mark system clean, anyway.) - */ -int swsusp_write(struct pbe *pblist, unsigned int nr_pages) -{ - int error; - - if ((error = swsusp_swap_check())) { - printk(KERN_ERR "swsusp: cannot find swap device, try swapon -a.\n"); - return error; - } - lock_swapdevices(); - error = write_suspend_image(pblist, nr_pages); - /* This will unlock ignored swap devices since writing is finished */ - lock_swapdevices(); - return error; -} - /** * swsusp_shrink_memory - Try to free as much memory as needed * -- cgit v1.1 From 277c6e2ad7369558dbd7ffbcc6dcbe16458bf723 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 6 Jan 2006 00:17:58 -0800 Subject: [PATCH] swsusp: save image header first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the swsusp_info structure become the header of the image in the literal sense (ie. it is saved to the swap and read before any other image data with the help of the swsusp's swap map structure, so generally it is treated in the same way as the rest of the image). The main thing it does is to make swsusp_header contain the offset of the swap map used to track the image data pages rather than the offset of swsusp_info.  Simultaneously, swsusp_info becomes the first image page written to the swap. The other changes are generally consequences of the above with a few exceptions (there's some consolidation in the image reading part as a few functions turn into trivial wrappers around something else). Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/power/power.h | 1 - kernel/power/swsusp.c | 190 +++++++++++++++++--------------------------------- 2 files changed, 65 insertions(+), 126 deletions(-) diff --git a/kernel/power/power.h b/kernel/power/power.h index 273a5b1..7e8492f 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -16,7 +16,6 @@ struct swsusp_info { int cpus; unsigned long image_pages; unsigned long pages; - swp_entry_t start; } __attribute__((aligned(PAGE_SIZE))); diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index 0479c9b..55a18d2 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c @@ -93,7 +93,7 @@ extern char resume_file[]; static struct swsusp_header { char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)]; - swp_entry_t swsusp_info; + swp_entry_t image; char orig_sig[10]; char sig[10]; } __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header; @@ -106,7 +106,7 @@ static struct swsusp_info swsusp_info; static unsigned short root_swap = 0xffff; -static int mark_swapfiles(swp_entry_t prev) +static int mark_swapfiles(swp_entry_t start) { int error; @@ -117,7 +117,7 @@ static int mark_swapfiles(swp_entry_t prev) !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) { memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10); memcpy(swsusp_header.sig,SWSUSP_SIG, 10); - swsusp_header.swsusp_info = prev; + swsusp_header.image = start; error = rw_swap_page_sync(WRITE, swp_entry(root_swap, 0), virt_to_page((unsigned long) @@ -423,22 +423,7 @@ static void init_header(unsigned int nr_pages) swsusp_info.cpus = num_online_cpus(); swsusp_info.image_pages = nr_pages; swsusp_info.pages = nr_pages + - ((nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT); -} - -static int close_swap(void) -{ - swp_entry_t entry; - int error; - - dump_info(); - error = write_page((unsigned long)&swsusp_info, &entry); - if (!error) { - printk( "S" ); - error = mark_swapfiles(entry); - printk( "|\n" ); - } - return error; + ((nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1; } /** @@ -522,6 +507,7 @@ int swsusp_write(struct pbe *pblist, unsigned int nr_pages) { struct swap_map_page *swap_map; struct swap_map_handle handle; + swp_entry_t start; int error; if ((error = swsusp_swap_check())) { @@ -539,18 +525,23 @@ int swsusp_write(struct pbe *pblist, unsigned int nr_pages) return -ENOMEM; init_swap_map_handle(&handle, swap_map); - error = save_image_metadata(pblist, &handle); + error = swap_map_write_page(&handle, (unsigned long)&swsusp_info); + if (!error) + error = save_image_metadata(pblist, &handle); if (!error) error = save_image_data(pblist, &handle, nr_pages); if (error) goto Free_image_entries; swap_map = reverse_swap_map(swap_map); - error = save_swap_map(swap_map, &swsusp_info.start); + error = save_swap_map(swap_map, &start); if (error) goto Free_map_entries; - error = close_swap(); + dump_info(); + printk( "S" ); + error = mark_swapfiles(start); + printk( "|\n" ); if (error) goto Free_map_entries; @@ -840,70 +831,28 @@ static inline int swap_map_read_page(struct swap_map_handle *handle, void *buf) return error; } -/* - * Sanity check if this image makes sense with this kernel/swap context - * I really don't think that it's foolproof but more than nothing.. - */ - -static const char *sanity_check(void) +static int check_header(void) { + char *reason = NULL; + dump_info(); if (swsusp_info.version_code != LINUX_VERSION_CODE) - return "kernel version"; + reason = "kernel version"; if (swsusp_info.num_physpages != num_physpages) - return "memory size"; + reason = "memory size"; if (strcmp(swsusp_info.uts.sysname,system_utsname.sysname)) - return "system type"; + reason = "system type"; if (strcmp(swsusp_info.uts.release,system_utsname.release)) - return "kernel release"; + reason = "kernel release"; if (strcmp(swsusp_info.uts.version,system_utsname.version)) - return "version"; + reason = "version"; if (strcmp(swsusp_info.uts.machine,system_utsname.machine)) - return "machine"; -#if 0 - /* We can't use number of online CPUs when we use hotplug to remove them ;-))) */ - if (swsusp_info.cpus != num_possible_cpus()) - return "number of cpus"; -#endif - return NULL; -} - -static int check_header(void) -{ - const char *reason = NULL; - int error; - - if ((error = bio_read_page(swp_offset(swsusp_header.swsusp_info), &swsusp_info))) - return error; - - /* Is this same machine? */ - if ((reason = sanity_check())) { - printk(KERN_ERR "swsusp: Resume mismatch: %s\n",reason); + reason = "machine"; + if (reason) { + printk(KERN_ERR "swsusp: Resume mismatch: %s\n", reason); return -EPERM; } - return error; -} - -static int check_sig(void) -{ - int error; - - memset(&swsusp_header, 0, sizeof(swsusp_header)); - if ((error = bio_read_page(0, &swsusp_header))) - return error; - if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) { - memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10); - - /* - * Reset swap signature now. - */ - error = bio_write_page(0, &swsusp_header); - } else { - return -EINVAL; - } - if (!error) - pr_debug("swsusp: Signature found, resuming\n"); - return error; + return 0; } /** @@ -989,33 +938,29 @@ static int load_image_metadata(struct pbe *pblist, struct swap_map_handle *handl return error; } -static int check_suspend_image(void) -{ - int error = 0; - - if ((error = check_sig())) - return error; - - if ((error = check_header())) - return error; - - return 0; -} - -static int read_suspend_image(struct pbe **pblist_ptr) +int swsusp_read(struct pbe **pblist_ptr) { - int error = 0; + int error; struct pbe *p, *pblist; struct swap_map_handle handle; - unsigned int nr_pages = swsusp_info.image_pages; + unsigned int nr_pages; + if (IS_ERR(resume_bdev)) { + pr_debug("swsusp: block device not initialised\n"); + return PTR_ERR(resume_bdev); + } + + error = get_swap_map_reader(&handle, swsusp_header.image); + if (!error) + error = swap_map_read_page(&handle, &swsusp_info); + if (!error) + error = check_header(); + if (error) + return error; + nr_pages = swsusp_info.image_pages; p = alloc_pagedir(nr_pages, GFP_ATOMIC, 0); if (!p) return -ENOMEM; - error = get_swap_map_reader(&handle, swsusp_info.start); - if (error) - /* The PBE list at p will be released by swsusp_free() */ - return error; error = load_image_metadata(p, &handle); if (!error) { mark_unsafe_pages(p); @@ -1037,11 +982,18 @@ static int read_suspend_image(struct pbe **pblist_ptr) *pblist_ptr = pblist; } release_swap_map_reader(&handle); + + blkdev_put(resume_bdev); + + if (!error) + pr_debug("swsusp: Reading resume file was successful\n"); + else + pr_debug("swsusp: Error %d resuming\n", error); return error; } /** - * swsusp_check - Check for saved image in swap + * swsusp_check - Check for swsusp signature in the resume device */ int swsusp_check(void) @@ -1051,39 +1003,27 @@ int swsusp_check(void) resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ); if (!IS_ERR(resume_bdev)) { set_blocksize(resume_bdev, PAGE_SIZE); - error = check_suspend_image(); + memset(&swsusp_header, 0, sizeof(swsusp_header)); + if ((error = bio_read_page(0, &swsusp_header))) + return error; + if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) { + memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10); + /* Reset swap signature now */ + error = bio_write_page(0, &swsusp_header); + } else { + return -EINVAL; + } if (error) - blkdev_put(resume_bdev); - } else + blkdev_put(resume_bdev); + else + pr_debug("swsusp: Signature found, resuming\n"); + } else { error = PTR_ERR(resume_bdev); - - if (!error) - pr_debug("swsusp: resume file found\n"); - else - pr_debug("swsusp: Error %d check for resume file\n", error); - return error; -} - -/** - * swsusp_read - Read saved image from swap. - */ - -int swsusp_read(struct pbe **pblist_ptr) -{ - int error; - - if (IS_ERR(resume_bdev)) { - pr_debug("swsusp: block device not initialised\n"); - return PTR_ERR(resume_bdev); } - error = read_suspend_image(pblist_ptr); - blkdev_put(resume_bdev); + if (error) + pr_debug("swsusp: Error %d check for resume file\n", error); - if (!error) - pr_debug("swsusp: Reading resume file was successful\n"); - else - pr_debug("swsusp: Error %d resuming\n", error); return error; } -- cgit v1.1 From 8c1d286e6aa5581e9d214cbaec2bee0394bb8de8 Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Fri, 6 Jan 2006 00:18:38 -0800 Subject: [PATCH] don't freeze firewire on suspend. We had a report from one loony user who tried out suspend to disk using a swap partition on a firewire drive. As the firewire thread was put to sleep it didn't work out too well. Signed-off-by: Dave Jones Cc: Pavel Machek Cc: Ben Collins Cc: Jody McIntyre Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ieee1394/ieee1394_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c index 64fbbb0..25ef5a8 100644 --- a/drivers/ieee1394/ieee1394_core.c +++ b/drivers/ieee1394/ieee1394_core.c @@ -1027,10 +1027,10 @@ static int hpsbpkt_thread(void *__hi) daemonize("khpsbpkt"); + current->flags |= PF_NOFREEZE; + while (1) { if (down_interruptible(&khpsbpkt_sig)) { - if (try_to_freeze()) - continue; printk("khpsbpkt: received unexpected signal?!\n" ); break; } -- cgit v1.1 From 60c83c77c4a6a399d55e4f9ad156bccdfe51c96b Mon Sep 17 00:00:00 2001 From: Hirokazu Takata Date: Fri, 6 Jan 2006 00:18:39 -0800 Subject: [PATCH] m32r: trivial fix to remove unused instructions A trivial fix to remove unused instructions. Signed-off-by: Naoto Sugai Signed-off-by: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m32r/kernel/entry.S | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/m32r/kernel/entry.S b/arch/m32r/kernel/entry.S index 396c942..f6d4a58 100644 --- a/arch/m32r/kernel/entry.S +++ b/arch/m32r/kernel/entry.S @@ -651,8 +651,6 @@ ENTRY(rie_handler) /* void rie_handler(int error_code) */ SWITCH_TO_KERNEL_STACK SAVE_ALL - mvfc r0, bpc - ld r1, @r0 ldi r1, #0x20 ; error_code mv r0, sp ; pt_regs bl do_rie_handler -- cgit v1.1 From 9287d95ea194abf32fab24c6909f8ea55ab0292f Mon Sep 17 00:00:00 2001 From: Hirokazu Takata Date: Fri, 6 Jan 2006 00:18:41 -0800 Subject: [PATCH] m32r: Support M32104UT target platform This patch is for supporting a new target platform, Renesas M32104UT evaluation board. The M32104UT is an eval board based on an uT-Engine specification. This board has an MMU-less M32R family processor, M32104. http://www-wa0.personal-media.co.jp/pmc/archive/te/te_m32104_e.pdf This board is one of the most popular M32R platform, so we have ported Linux/M32R to it. Signed-off-by: Naoto Sugai Signed-off-by: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m32r/Kconfig | 26 +- arch/m32r/boot/compressed/head.S | 5 + arch/m32r/boot/setup.S | 9 + arch/m32r/kernel/Makefile | 1 + arch/m32r/kernel/entry.S | 17 +- arch/m32r/kernel/io_m32104ut.c | 298 ++++++++++++++ arch/m32r/kernel/setup.c | 7 +- arch/m32r/kernel/setup_m32104ut.c | 162 ++++++++ arch/m32r/kernel/time.c | 4 +- arch/m32r/m32104ut/defconfig.m32104ut | 657 +++++++++++++++++++++++++++++++ arch/m32r/mm/cache.c | 10 + include/asm-m32r/assembler.h | 10 +- include/asm-m32r/cacheflush.h | 2 +- include/asm-m32r/irq.h | 16 + include/asm-m32r/m32102.h | 31 +- include/asm-m32r/m32104ut/m32104ut_pld.h | 163 ++++++++ include/asm-m32r/m32r.h | 6 +- include/asm-m32r/system.h | 12 +- 18 files changed, 1407 insertions(+), 29 deletions(-) create mode 100644 arch/m32r/kernel/io_m32104ut.c create mode 100644 arch/m32r/kernel/setup_m32104ut.c create mode 100644 arch/m32r/m32104ut/defconfig.m32104ut create mode 100644 include/asm-m32r/m32104ut/m32104ut_pld.h diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 4d100f3..fae67bb 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig @@ -81,6 +81,12 @@ config PLAT_MAPPI2 config PLAT_MAPPI3 bool "Mappi-III(M3A-2170)" +config PLAT_M32104UT + bool "M32104UT" + help + The M3T-M32104UT is an reference board based on uT-Engine + specification. This board has a M32104 chip. + endchoice choice @@ -93,6 +99,10 @@ config CHIP_M32700 config CHIP_M32102 bool "M32102" +config CHIP_M32104 + bool "M32104" + depends on PLAT_M32104UT + config CHIP_VDEC2 bool "VDEC2" @@ -115,7 +125,7 @@ config TLB_ENTRIES config ISA_M32R bool - depends on CHIP_M32102 + depends on CHIP_M32102 || CHIP_M32104 default y config ISA_M32R2 @@ -140,6 +150,7 @@ config BUS_CLOCK default "50000000" if PLAT_MAPPI3 default "50000000" if PLAT_M32700UT default "50000000" if PLAT_OPSPUT + default "54000000" if PLAT_M32104UT default "33333333" if PLAT_OAKS32R default "20000000" if PLAT_MAPPI2 @@ -157,6 +168,7 @@ config MEMORY_START default "08000000" if PLAT_USRV default "08000000" if PLAT_M32700UT default "08000000" if PLAT_OPSPUT + default "04000000" if PLAT_M32104UT default "01000000" if PLAT_OAKS32R config MEMORY_SIZE @@ -166,6 +178,7 @@ config MEMORY_SIZE default "02000000" if PLAT_USRV default "01000000" if PLAT_M32700UT default "01000000" if PLAT_OPSPUT + default "01000000" if PLAT_M32104UT default "00800000" if PLAT_OAKS32R config NOHIGHMEM @@ -174,21 +187,22 @@ config NOHIGHMEM config ARCH_DISCONTIGMEM_ENABLE bool "Internal RAM Support" - depends on CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || CHIP_OPSP + depends on CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || CHIP_OPSP || CHIP_M32104 default y source "mm/Kconfig" config IRAM_START hex "Internal memory start address (hex)" - default "00f00000" - depends on (CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || CHIP_OPSP) && DISCONTIGMEM + default "00f00000" if !CHIP_M32104 + default "00700000" if CHIP_M32104 + depends on (CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || CHIP_OPSP || CHIP_M32104) && DISCONTIGMEM config IRAM_SIZE hex "Internal memory size (hex)" - depends on (CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || CHIP_OPSP) && DISCONTIGMEM + depends on (CHIP_M32700 || CHIP_M32102 || CHIP_VDEC2 || CHIP_OPSP || CHIP_M32104) && DISCONTIGMEM default "00080000" if CHIP_M32700 - default "00010000" if CHIP_M32102 || CHIP_OPSP + default "00010000" if CHIP_M32102 || CHIP_OPSP || CHIP_M32104 default "00008000" if CHIP_VDEC2 # diff --git a/arch/m32r/boot/compressed/head.S b/arch/m32r/boot/compressed/head.S index 07cfd6a..234d8b1 100644 --- a/arch/m32r/boot/compressed/head.S +++ b/arch/m32r/boot/compressed/head.S @@ -143,6 +143,11 @@ startup: ldi r0, -2 ldi r1, 0x0100 ; invalidate stb r1, @r0 +#elif defined(CONFIG_CHIP_M32104) + /* Cache flush */ + ldi r0, -2 + ldi r1, 0x0700 ; invalidate i-cache, copy back d-cache + sth r1, @r0 #else #error "put your cache flush function, please" #endif diff --git a/arch/m32r/boot/setup.S b/arch/m32r/boot/setup.S index 5d25643..742669f 100644 --- a/arch/m32r/boot/setup.S +++ b/arch/m32r/boot/setup.S @@ -80,6 +80,10 @@ ENTRY(boot) ldi r1, #0x101 ; cache on (with invalidation) ; ldi r1, #0x00 ; cache off st r1, @r0 +#elif defined(CONFIG_CHIP_M32104) + ldi r0, #-4 ;LDIMM (r0, M32R_MCCR) + ldi r1, #0x703 ; cache on (with invalidation) + st r1, @r0 #else #error unknown chip configuration #endif @@ -115,10 +119,15 @@ mmu_on: st r1, @(MATM_offset,r0) ; Set MATM (T bit ON) ld r0, @(MATM_offset,r0) ; Check #else +#if defined(CONFIG_CHIP_M32700) seth r0,#high(M32R_MCDCAR) or3 r0,r0,#low(M32R_MCDCAR) ld24 r1,#0x8080 st r1,@r0 +#elif defined(CONFIG_CHIP_M32104) + LDIMM (r2, eit_vector) ; set EVB(cr5) + mvtc r2, cr5 +#endif #endif /* CONFIG_MMU */ jmp r13 nop diff --git a/arch/m32r/kernel/Makefile b/arch/m32r/kernel/Makefile index 6c6b6c3..5a2fa88 100644 --- a/arch/m32r/kernel/Makefile +++ b/arch/m32r/kernel/Makefile @@ -16,5 +16,6 @@ obj-$(CONFIG_PLAT_M32700UT) += setup_m32700ut.o io_m32700ut.o obj-$(CONFIG_PLAT_OPSPUT) += setup_opsput.o io_opsput.o obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_PLAT_OAKS32R) += setup_oaks32r.o io_oaks32r.o +obj-$(CONFIG_PLAT_M32104UT) += setup_m32104ut.o io_m32104ut.o EXTRA_AFLAGS := -traditional diff --git a/arch/m32r/kernel/entry.S b/arch/m32r/kernel/entry.S index f6d4a58..3871b65 100644 --- a/arch/m32r/kernel/entry.S +++ b/arch/m32r/kernel/entry.S @@ -315,7 +315,7 @@ ENTRY(ei_handler) mv r1, sp ; arg1(regs) #if defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_XNUX2) \ || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \ - || defined(CONFIG_CHIP_OPSP) + || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104) ; GET_ICU_STATUS; seth r0, #shigh(M32R_ICU_ISTS_ADDR) @@ -541,7 +541,20 @@ check_int2: bra check_end .fillinsn check_end: -#endif /* CONFIG_PLAT_OPSPUT */ +#elif defined(CONFIG_PLAT_M32104UT) + add3 r2, r0, #-(M32R_IRQ_INT1) ; INT1# interrupt + bnez r2, check_end + ; read ICU status register of PLD + seth r0, #high(PLD_ICUISTS) + or3 r0, r0, #low(PLD_ICUISTS) + lduh r0, @r0 + slli r0, #21 + srli r0, #27 ; ISN + addi r0, #(M32104UT_PLD_IRQ_BASE) + bra check_end + .fillinsn +check_end: +#endif /* CONFIG_PLAT_M32104UT */ bl do_IRQ #endif /* CONFIG_SMP */ ld r14, @sp+ diff --git a/arch/m32r/kernel/io_m32104ut.c b/arch/m32r/kernel/io_m32104ut.c new file mode 100644 index 0000000..3df4215 --- /dev/null +++ b/arch/m32r/kernel/io_m32104ut.c @@ -0,0 +1,298 @@ +/* + * linux/arch/m32r/kernel/io_m32104ut.c + * + * Typical I/O routines for M32104UT board. + * + * Copyright (c) 2001-2005 Hiroyuki Kondo, Hirokazu Takata, + * Hitoshi Yamamoto, Mamoru Sakugawa, + * Naoto Sugai, Hayato Fujiwara + */ + +#include +#include +#include +#include +#include + +#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) +#include + +#define M32R_PCC_IOMAP_SIZE 0x1000 + +#define M32R_PCC_IOSTART0 0x1000 +#define M32R_PCC_IOEND0 (M32R_PCC_IOSTART0 + M32R_PCC_IOMAP_SIZE - 1) + +extern void pcc_ioread_byte(int, unsigned long, void *, size_t, size_t, int); +extern void pcc_ioread_word(int, unsigned long, void *, size_t, size_t, int); +extern void pcc_iowrite_byte(int, unsigned long, void *, size_t, size_t, int); +extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); +#endif /* CONFIG_PCMCIA && CONFIG_M32R_CFC */ + +#define PORT2ADDR(port) _port2addr(port) + +static inline void *_port2addr(unsigned long port) +{ + return (void *)(port + NONCACHE_OFFSET); +} + +#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) +static inline void *__port2addr_ata(unsigned long port) +{ + static int dummy_reg; + + switch (port) { + case 0x1f0: return (void *)0xac002000; + case 0x1f1: return (void *)0xac012800; + case 0x1f2: return (void *)0xac012002; + case 0x1f3: return (void *)0xac012802; + case 0x1f4: return (void *)0xac012004; + case 0x1f5: return (void *)0xac012804; + case 0x1f6: return (void *)0xac012006; + case 0x1f7: return (void *)0xac012806; + case 0x3f6: return (void *)0xac01200e; + default: return (void *)&dummy_reg; + } +} +#endif + +/* + * M32104T-LAN is located in the extended bus space + * from 0x01000000 to 0x01ffffff on physical address. + * The base address of LAN controller(LAN91C111) is 0x300. + */ +#define LAN_IOSTART 0x300 +#define LAN_IOEND 0x320 +static inline void *_port2addr_ne(unsigned long port) +{ + return (void *)(port + NONCACHE_OFFSET + 0x01000000); +} + +static inline void delay(void) +{ + __asm__ __volatile__ ("push r0; \n\t pop r0;" : : :"memory"); +} + +/* + * NIC I/O function + */ + +#define PORT2ADDR_NE(port) _port2addr_ne(port) + +static inline unsigned char _ne_inb(void *portp) +{ + return *(volatile unsigned char *)portp; +} + +static inline unsigned short _ne_inw(void *portp) +{ + return (unsigned short)le16_to_cpu(*(volatile unsigned short *)portp); +} + +static inline void _ne_insb(void *portp, void *addr, unsigned long count) +{ + unsigned char *buf = (unsigned char *)addr; + + while (count--) + *buf++ = _ne_inb(portp); +} + +static inline void _ne_outb(unsigned char b, void *portp) +{ + *(volatile unsigned char *)portp = b; +} + +static inline void _ne_outw(unsigned short w, void *portp) +{ + *(volatile unsigned short *)portp = cpu_to_le16(w); +} + +unsigned char _inb(unsigned long port) +{ + if (port >= LAN_IOSTART && port < LAN_IOEND) + return _ne_inb(PORT2ADDR_NE(port)); + + return *(volatile unsigned char *)PORT2ADDR(port); +} + +unsigned short _inw(unsigned long port) +{ + if (port >= LAN_IOSTART && port < LAN_IOEND) + return _ne_inw(PORT2ADDR_NE(port)); + + return *(volatile unsigned short *)PORT2ADDR(port); +} + +unsigned long _inl(unsigned long port) +{ + return *(volatile unsigned long *)PORT2ADDR(port); +} + +unsigned char _inb_p(unsigned long port) +{ + unsigned char v = _inb(port); + delay(); + return (v); +} + +unsigned short _inw_p(unsigned long port) +{ + unsigned short v = _inw(port); + delay(); + return (v); +} + +unsigned long _inl_p(unsigned long port) +{ + unsigned long v = _inl(port); + delay(); + return (v); +} + +void _outb(unsigned char b, unsigned long port) +{ + if (port >= LAN_IOSTART && port < LAN_IOEND) + _ne_outb(b, PORT2ADDR_NE(port)); + else + *(volatile unsigned char *)PORT2ADDR(port) = b; +} + +void _outw(unsigned short w, unsigned long port) +{ + if (port >= LAN_IOSTART && port < LAN_IOEND) + _ne_outw(w, PORT2ADDR_NE(port)); + else + *(volatile unsigned short *)PORT2ADDR(port) = w; +} + +void _outl(unsigned long l, unsigned long port) +{ + *(volatile unsigned long *)PORT2ADDR(port) = l; +} + +void _outb_p(unsigned char b, unsigned long port) +{ + _outb(b, port); + delay(); +} + +void _outw_p(unsigned short w, unsigned long port) +{ + _outw(w, port); + delay(); +} + +void _outl_p(unsigned long l, unsigned long port) +{ + _outl(l, port); + delay(); +} + +void _insb(unsigned int port, void *addr, unsigned long count) +{ + if (port >= LAN_IOSTART && port < LAN_IOEND) + _ne_insb(PORT2ADDR_NE(port), addr, count); + else { + unsigned char *buf = addr; + unsigned char *portp = PORT2ADDR(port); + while (count--) + *buf++ = *(volatile unsigned char *)portp; + } +} + +void _insw(unsigned int port, void *addr, unsigned long count) +{ + unsigned short *buf = addr; + unsigned short *portp; + + if (port >= LAN_IOSTART && port < LAN_IOEND) { + /* + * This portion is only used by smc91111.c to read data + * from the DATA_REG. Do not swap the data. + */ + portp = PORT2ADDR_NE(port); + while (count--) + *buf++ = *(volatile unsigned short *)portp; +#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) + } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { + pcc_ioread_word(9, port, (void *)addr, sizeof(unsigned short), + count, 1); +#endif +#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) + } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { + portp = __port2addr_ata(port); + while (count--) + *buf++ = *(volatile unsigned short *)portp; +#endif + } else { + portp = PORT2ADDR(port); + while (count--) + *buf++ = *(volatile unsigned short *)portp; + } +} + +void _insl(unsigned int port, void *addr, unsigned long count) +{ + unsigned long *buf = addr; + unsigned long *portp; + + portp = PORT2ADDR(port); + while (count--) + *buf++ = *(volatile unsigned long *)portp; +} + +void _outsb(unsigned int port, const void *addr, unsigned long count) +{ + const unsigned char *buf = addr; + unsigned char *portp; + + if (port >= LAN_IOSTART && port < LAN_IOEND) { + portp = PORT2ADDR_NE(port); + while (count--) + _ne_outb(*buf++, portp); + } else { + portp = PORT2ADDR(port); + while (count--) + *(volatile unsigned char *)portp = *buf++; + } +} + +void _outsw(unsigned int port, const void *addr, unsigned long count) +{ + const unsigned short *buf = addr; + unsigned short *portp; + + if (port >= LAN_IOSTART && port < LAN_IOEND) { + /* + * This portion is only used by smc91111.c to write data + * into the DATA_REG. Do not swap the data. + */ + portp = PORT2ADDR_NE(port); + while (count--) + *(volatile unsigned short *)portp = *buf++; +#if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) + } else if ((port >= 0x1f0 && port <=0x1f7) || port == 0x3f6) { + portp = __port2addr_ata(port); + while (count--) + *(volatile unsigned short *)portp = *buf++; +#endif +#if defined(CONFIG_PCMCIA) && defined(CONFIG_M32R_CFC) + } else if (port >= M32R_PCC_IOSTART0 && port <= M32R_PCC_IOEND0) { + pcc_iowrite_word(9, port, (void *)addr, sizeof(unsigned short), + count, 1); +#endif + } else { + portp = PORT2ADDR(port); + while (count--) + *(volatile unsigned short *)portp = *buf++; + } +} + +void _outsl(unsigned int port, const void *addr, unsigned long count) +{ + const unsigned long *buf = addr; + unsigned char *portp; + + portp = PORT2ADDR(port); + while (count--) + *(volatile unsigned long *)portp = *buf++; +} diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c index f722ec8..c2e4dcc 100644 --- a/arch/m32r/kernel/setup.c +++ b/arch/m32r/kernel/setup.c @@ -320,6 +320,9 @@ static int show_cpuinfo(struct seq_file *m, void *v) #elif defined(CONFIG_CHIP_MP) seq_printf(m, "cpu family\t: M32R-MP\n" "cache size\t: I-xxKB/D-xxKB\n"); +#elif defined(CONFIG_CHIP_M32104) + seq_printf(m,"cpu family\t: M32104\n" + "cache size\t: I-8KB/D-8KB\n"); #else seq_printf(m, "cpu family\t: Unknown\n"); #endif @@ -340,6 +343,8 @@ static int show_cpuinfo(struct seq_file *m, void *v) seq_printf(m, "Machine\t\t: uServer\n"); #elif defined(CONFIG_PLAT_OAKS32R) seq_printf(m, "Machine\t\t: OAKS32R\n"); +#elif defined(CONFIG_PLAT_M32104UT) + seq_printf(m, "Machine\t\t: M3T-M32104UT uT Engine board\n"); #else seq_printf(m, "Machine\t\t: Unknown\n"); #endif @@ -389,7 +394,7 @@ unsigned long cpu_initialized __initdata = 0; */ #if defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_XNUX2) \ || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \ - || defined(CONFIG_CHIP_OPSP) + || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104) void __init cpu_init (void) { int cpu_id = smp_processor_id(); diff --git a/arch/m32r/kernel/setup_m32104ut.c b/arch/m32r/kernel/setup_m32104ut.c new file mode 100644 index 0000000..ab16c66 --- /dev/null +++ b/arch/m32r/kernel/setup_m32104ut.c @@ -0,0 +1,162 @@ +/* + * linux/arch/m32r/kernel/setup_m32104ut.c + * + * Setup routines for M32104UT Board + * + * Copyright (c) 2002-2005 Hiroyuki Kondo, Hirokazu Takata, + * Hitoshi Yamamoto, Mamoru Sakugawa, + * Naoto Sugai, Hayato Fujiwara + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) + +#ifndef CONFIG_SMP +typedef struct { + unsigned long icucr; /* ICU Control Register */ +} icu_data_t; +#endif /* CONFIG_SMP */ + +icu_data_t icu_data[NR_IRQS]; + +static void disable_m32104ut_irq(unsigned int irq) +{ + unsigned long port, data; + + port = irq2port(irq); + data = icu_data[irq].icucr|M32R_ICUCR_ILEVEL7; + outl(data, port); +} + +static void enable_m32104ut_irq(unsigned int irq) +{ + unsigned long port, data; + + port = irq2port(irq); + data = icu_data[irq].icucr|M32R_ICUCR_IEN|M32R_ICUCR_ILEVEL6; + outl(data, port); +} + +static void mask_and_ack_m32104ut(unsigned int irq) +{ + disable_m32104ut_irq(irq); +} + +static void end_m32104ut_irq(unsigned int irq) +{ + enable_m32104ut_irq(irq); +} + +static unsigned int startup_m32104ut_irq(unsigned int irq) +{ + enable_m32104ut_irq(irq); + return (0); +} + +static void shutdown_m32104ut_irq(unsigned int irq) +{ + unsigned long port; + + port = irq2port(irq); + outl(M32R_ICUCR_ILEVEL7, port); +} + +static struct hw_interrupt_type m32104ut_irq_type = +{ + .typename = "M32104UT-IRQ", + .startup = startup_m32104ut_irq, + .shutdown = shutdown_m32104ut_irq, + .enable = enable_m32104ut_irq, + .disable = disable_m32104ut_irq, + .ack = mask_and_ack_m32104ut, + .end = end_m32104ut_irq +}; + +void __init init_IRQ(void) +{ + static int once = 0; + + if (once) + return; + else + once++; + +#if defined(CONFIG_SMC91X) + /* INT#0: LAN controller on M32104UT-LAN (SMC91C111)*/ + irq_desc[M32R_IRQ_INT0].status = IRQ_DISABLED; + irq_desc[M32R_IRQ_INT0].handler = &m32104ut_irq_type; + irq_desc[M32R_IRQ_INT0].action = 0; + irq_desc[M32R_IRQ_INT0].depth = 1; + icu_data[M32R_IRQ_INT0].icucr = M32R_ICUCR_IEN | M32R_ICUCR_ISMOD11; /* "H" level sense */ + disable_m32104ut_irq(M32R_IRQ_INT0); +#endif /* CONFIG_SMC91X */ + + /* MFT2 : system timer */ + irq_desc[M32R_IRQ_MFT2].status = IRQ_DISABLED; + irq_desc[M32R_IRQ_MFT2].handler = &m32104ut_irq_type; + irq_desc[M32R_IRQ_MFT2].action = 0; + irq_desc[M32R_IRQ_MFT2].depth = 1; + icu_data[M32R_IRQ_MFT2].icucr = M32R_ICUCR_IEN; + disable_m32104ut_irq(M32R_IRQ_MFT2); + +#ifdef CONFIG_SERIAL_M32R_SIO + /* SIO0_R : uart receive data */ + irq_desc[M32R_IRQ_SIO0_R].status = IRQ_DISABLED; + irq_desc[M32R_IRQ_SIO0_R].handler = &m32104ut_irq_type; + irq_desc[M32R_IRQ_SIO0_R].action = 0; + irq_desc[M32R_IRQ_SIO0_R].depth = 1; + icu_data[M32R_IRQ_SIO0_R].icucr = M32R_ICUCR_IEN; + disable_m32104ut_irq(M32R_IRQ_SIO0_R); + + /* SIO0_S : uart send data */ + irq_desc[M32R_IRQ_SIO0_S].status = IRQ_DISABLED; + irq_desc[M32R_IRQ_SIO0_S].handler = &m32104ut_irq_type; + irq_desc[M32R_IRQ_SIO0_S].action = 0; + irq_desc[M32R_IRQ_SIO0_S].depth = 1; + icu_data[M32R_IRQ_SIO0_S].icucr = M32R_ICUCR_IEN; + disable_m32104ut_irq(M32R_IRQ_SIO0_S); +#endif /* CONFIG_SERIAL_M32R_SIO */ +} + +#if defined(CONFIG_SMC91X) + +#define LAN_IOSTART 0x300 +#define LAN_IOEND 0x320 +static struct resource smc91x_resources[] = { + [0] = { + .start = (LAN_IOSTART), + .end = (LAN_IOEND), + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = M32R_IRQ_INT0, + .end = M32R_IRQ_INT0, + .flags = IORESOURCE_IRQ, + } +}; + +static struct platform_device smc91x_device = { + .name = "smc91x", + .id = 0, + .num_resources = ARRAY_SIZE(smc91x_resources), + .resource = smc91x_resources, +}; +#endif + +static int __init platform_init(void) +{ +#if defined(CONFIG_SMC91X) + platform_device_register(&smc91x_device); +#endif + return 0; +} +arch_initcall(platform_init); diff --git a/arch/m32r/kernel/time.c b/arch/m32r/kernel/time.c index 2ebce20..b8e68b5 100644 --- a/arch/m32r/kernel/time.c +++ b/arch/m32r/kernel/time.c @@ -57,7 +57,7 @@ static unsigned long do_gettimeoffset(void) #if defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_XNUX2) \ || defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_M32700) \ - || defined(CONFIG_CHIP_OPSP) + || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104) #ifndef CONFIG_SMP unsigned long count; @@ -268,7 +268,7 @@ void __init time_init(void) #if defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_XNUX2) \ || defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_M32700) \ - || defined(CONFIG_CHIP_OPSP) + || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104) /* M32102 MFT setup */ setup_irq(M32R_IRQ_MFT2, &irq0); diff --git a/arch/m32r/m32104ut/defconfig.m32104ut b/arch/m32r/m32104ut/defconfig.m32104ut new file mode 100644 index 0000000..454de33 --- /dev/null +++ b/arch/m32r/m32104ut/defconfig.m32104ut @@ -0,0 +1,657 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.14 +# Wed Nov 9 16:04:51 2005 +# +CONFIG_M32R=y +# CONFIG_UID16 is not set +CONFIG_GENERIC_ISA_DMA=y +CONFIG_GENERIC_HARDIRQS=y +CONFIG_GENERIC_IRQ_PROBE=y + +# +# Code maturity level options +# +CONFIG_EXPERIMENTAL=y +CONFIG_CLEAN_COMPILE=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 + +# +# General setup +# +CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION_AUTO=y +# CONFIG_POSIX_MQUEUE is not set +# CONFIG_BSD_PROCESS_ACCT is not set +CONFIG_SYSCTL=y +# CONFIG_AUDIT is not set +CONFIG_HOTPLUG=y +# CONFIG_KOBJECT_UEVENT is not set +# CONFIG_IKCONFIG is not set +CONFIG_INITRAMFS_SOURCE="" +CONFIG_EMBEDDED=y +# CONFIG_KALLSYMS is not set +CONFIG_PRINTK=y +CONFIG_BUG=y +CONFIG_BASE_FULL=y +# CONFIG_FUTEX is not set +# CONFIG_EPOLL is not set +# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set +CONFIG_CC_ALIGN_FUNCTIONS=0 +CONFIG_CC_ALIGN_LABELS=0 +CONFIG_CC_ALIGN_LOOPS=0 +CONFIG_CC_ALIGN_JUMPS=0 +CONFIG_TINY_SHMEM=y +CONFIG_BASE_SMALL=0 + +# +# Loadable module support +# +# CONFIG_MODULES is not set + +# +# Processor type and features +# +# CONFIG_PLAT_MAPPI is not set +# CONFIG_PLAT_USRV is not set +# CONFIG_PLAT_M32700UT is not set +# CONFIG_PLAT_OPSPUT is not set +# CONFIG_PLAT_OAKS32R is not set +# CONFIG_PLAT_MAPPI2 is not set +# CONFIG_PLAT_MAPPI3 is not set +CONFIG_PLAT_M32104UT=y +# CONFIG_CHIP_M32700 is not set +# CONFIG_CHIP_M32102 is not set +CONFIG_CHIP_M32104=y +# CONFIG_CHIP_VDEC2 is not set +# CONFIG_CHIP_OPSP is not set +CONFIG_ISA_M32R=y +CONFIG_BUS_CLOCK=54000000 +CONFIG_TIMER_DIVIDE=128 +# CONFIG_CPU_LITTLE_ENDIAN is not set +CONFIG_MEMORY_START=04000000 +CONFIG_MEMORY_SIZE=01000000 +CONFIG_NOHIGHMEM=y +# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +# CONFIG_SPARSEMEM_STATIC is not set +CONFIG_RWSEM_GENERIC_SPINLOCK=y +# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set +CONFIG_GENERIC_CALIBRATE_DELAY=y +# CONFIG_PREEMPT is not set +# CONFIG_SMP is not set + +# +# Bus options (PCI, PCMCIA, EISA, MCA, ISA) +# +# CONFIG_ISA is not set + +# +# PCCARD (PCMCIA/CardBus) support +# +CONFIG_PCCARD=y +# CONFIG_PCMCIA_DEBUG is not set +CONFIG_PCMCIA=y +CONFIG_PCMCIA_LOAD_CIS=y +CONFIG_PCMCIA_IOCTL=y + +# +# PC-card bridges +# + +# +# PCI Hotplug Support +# + +# +# Executable file formats +# +CONFIG_BINFMT_FLAT=y +# CONFIG_BINFMT_ZFLAT is not set +# CONFIG_BINFMT_SHARED_FLAT is not set +# CONFIG_BINFMT_MISC is not set + +# +# Networking +# +CONFIG_NET=y + +# +# Networking options +# +# CONFIG_PACKET is not set +CONFIG_UNIX=y +# CONFIG_NET_KEY is not set +CONFIG_INET=y +# CONFIG_IP_MULTICAST is not set +# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +# CONFIG_IP_PNP_BOOTP is not set +# CONFIG_IP_PNP_RARP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_ARPD is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_TUNNEL is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_BIC=y +# CONFIG_IPV6 is not set +# CONFIG_NETFILTER is not set + +# +# DCCP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_DCCP is not set + +# +# SCTP Configuration (EXPERIMENTAL) +# +# CONFIG_IP_SCTP is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_NET_DIVERT is not set +# CONFIG_ECONET is not set +# CONFIG_WAN_ROUTER is not set +# CONFIG_NET_SCHED is not set +# CONFIG_NET_CLS_ROUTE is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_HAMRADIO is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_IEEE80211 is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +# CONFIG_DEBUG_DRIVER is not set + +# +# Connector - unified userspace <-> kernelspace linker +# +# CONFIG_CONNECTOR is not set + +# +# Memory Technology Devices (MTD) +# +# CONFIG_MTD is not set + +# +# Parallel port support +# +# CONFIG_PARPORT is not set + +# +# Plug and Play support +# + +# +# Block devices +# +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +CONFIG_BLK_DEV_NBD=y +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=4096 +CONFIG_BLK_DEV_INITRD=y +# CONFIG_CDROM_PKTCDVD is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +# CONFIG_IOSCHED_AS is not set +# CONFIG_IOSCHED_DEADLINE is not set +# CONFIG_IOSCHED_CFQ is not set +# CONFIG_ATA_OVER_ETH is not set + +# +# ATA/ATAPI/MFM/RLL support +# +# CONFIG_IDE is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +# CONFIG_SCSI is not set + +# +# Multi-device support (RAID and LVM) +# +# CONFIG_MD is not set + +# +# Fusion MPT device support +# +# CONFIG_FUSION is not set + +# +# IEEE 1394 (FireWire) support +# + +# +# I2O device support +# + +# +# Network device support +# +CONFIG_NETDEVICES=y +CONFIG_DUMMY=y +# CONFIG_BONDING is not set +# CONFIG_EQUALIZER is not set +# CONFIG_TUN is not set + +# +# PHY device support +# +# CONFIG_PHYLIB is not set + +# +# Ethernet (10 or 100Mbit) +# +CONFIG_NET_ETHERNET=y +CONFIG_MII=y +CONFIG_SMC91X=y +# CONFIG_NE2000 is not set + +# +# Ethernet (1000 Mbit) +# + +# +# Ethernet (10000 Mbit) +# + +# +# Token Ring devices +# + +# +# Wireless LAN (non-hamradio) +# +# CONFIG_NET_RADIO is not set + +# +# PCMCIA network device support +# +# CONFIG_NET_PCMCIA is not set + +# +# Wan interfaces +# +# CONFIG_WAN is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +# CONFIG_SHAPER is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set + +# +# ISDN subsystem +# +# CONFIG_ISDN is not set + +# +# Telephony Support +# +# CONFIG_PHONE is not set + +# +# Input device support +# +# CONFIG_INPUT is not set + +# +# Hardware I/O ports +# +# CONFIG_SERIO is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +# CONFIG_VT is not set +# CONFIG_SERIAL_NONSTANDARD is not set + +# +# Serial drivers +# +# CONFIG_SERIAL_8250 is not set + +# +# Non-8250 serial port support +# +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_SERIAL_M32R_SIO=y +CONFIG_SERIAL_M32R_SIO_CONSOLE=y +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 + +# +# IPMI +# +# CONFIG_IPMI_HANDLER is not set + +# +# Watchdog Cards +# +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# +CONFIG_SOFT_WATCHDOG=y +# CONFIG_RTC is not set +# CONFIG_DTLK is not set +# CONFIG_R3964 is not set + +# +# Ftape, the floppy tape device driver +# + +# +# PCMCIA character devices +# +# CONFIG_SYNCLINK_CS is not set +# CONFIG_RAW_DRIVER is not set + +# +# TPM devices +# + +# +# I2C support +# +# CONFIG_I2C is not set + +# +# Dallas's 1-wire bus +# +# CONFIG_W1 is not set + +# +# Hardware Monitoring support +# +# CONFIG_HWMON is not set +# CONFIG_HWMON_VID is not set + +# +# Misc devices +# + +# +# Multimedia Capabilities Port drivers +# + +# +# Multimedia devices +# +# CONFIG_VIDEO_DEV is not set + +# +# Digital Video Broadcasting Devices +# +# CONFIG_DVB is not set + +# +# Graphics support +# +# CONFIG_FB is not set + +# +# Sound +# +# CONFIG_SOUND is not set + +# +# USB support +# +# CONFIG_USB_ARCH_HAS_HCD is not set +# CONFIG_USB_ARCH_HAS_OHCI is not set + +# +# USB Gadget Support +# +# CONFIG_USB_GADGET is not set + +# +# MMC/SD Card support +# +# CONFIG_MMC is not set + +# +# InfiniBand support +# + +# +# SN Devices +# + +# +# File systems +# +CONFIG_EXT2_FS=y +# CONFIG_EXT2_FS_XATTR is not set +# CONFIG_EXT2_FS_XIP is not set +CONFIG_EXT3_FS=y +CONFIG_EXT3_FS_XATTR=y +CONFIG_EXT3_FS_POSIX_ACL=y +# CONFIG_EXT3_FS_SECURITY is not set +CONFIG_JBD=y +# CONFIG_JBD_DEBUG is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +CONFIG_FS_POSIX_ACL=y +# CONFIG_XFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_INOTIFY is not set +# CONFIG_QUOTA is not set +CONFIG_DNOTIFY=y +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_FUSE_FS is not set + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=932 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +# CONFIG_NTFS_FS is not set + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +# CONFIG_HUGETLB_PAGE is not set +CONFIG_RAMFS=y +# CONFIG_RELAYFS_FS is not set + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_CRAMFS=y +# CONFIG_VXFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set + +# +# Network File Systems +# +CONFIG_NFS_FS=y +CONFIG_NFS_V3=y +# CONFIG_NFS_V3_ACL is not set +# CONFIG_NFS_V4 is not set +# CONFIG_NFS_DIRECTIO is not set +# CONFIG_NFSD is not set +CONFIG_ROOT_NFS=y +CONFIG_LOCKD=y +CONFIG_LOCKD_V4=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set +# CONFIG_9P_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y + +# +# Native Language Support +# +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="iso8859-1" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +# CONFIG_NLS_CODEPAGE_936 is not set +# CONFIG_NLS_CODEPAGE_950 is not set +CONFIG_NLS_CODEPAGE_932=y +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +# CONFIG_NLS_ASCII is not set +# CONFIG_NLS_ISO8859_1 is not set +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +CONFIG_NLS_UTF8=y + +# +# Profiling support +# +# CONFIG_PROFILING is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +CONFIG_DEBUG_KERNEL=y +CONFIG_MAGIC_SYSRQ=y +CONFIG_LOG_BUF_SHIFT=14 +CONFIG_DETECT_SOFTLOCKUP=y +# CONFIG_SCHEDSTATS is not set +# CONFIG_DEBUG_SLAB is not set +# CONFIG_DEBUG_SPINLOCK is not set +# CONFIG_DEBUG_SPINLOCK_SLEEP is not set +# CONFIG_DEBUG_KOBJECT is not set +# CONFIG_DEBUG_BUGVERBOSE is not set +CONFIG_DEBUG_INFO=y +# CONFIG_DEBUG_FS is not set +# CONFIG_FRAME_POINTER is not set +# CONFIG_DEBUG_STACKOVERFLOW is not set +# CONFIG_DEBUG_STACK_USAGE is not set + +# +# Security options +# +# CONFIG_KEYS is not set +# CONFIG_SECURITY is not set + +# +# Cryptographic options +# +# CONFIG_CRYPTO is not set + +# +# Hardware crypto devices +# + +# +# Library routines +# +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +CONFIG_CRC32=y +CONFIG_LIBCRC32C=y +CONFIG_ZLIB_INFLATE=y diff --git a/arch/m32r/mm/cache.c b/arch/m32r/mm/cache.c index 31b0789..c6f72a6 100644 --- a/arch/m32r/mm/cache.c +++ b/arch/m32r/mm/cache.c @@ -26,6 +26,16 @@ #define MCCR ((volatile unsigned char*)0xfffffffe) #define MCCR_IIV (1UL << 0) /* I-cache invalidate */ #define MCCR_ICACHE_INV MCCR_IIV +#elif defined(CONFIG_CHIP_M32104) +#define MCCR ((volatile unsigned long*)0xfffffffc) +#define MCCR_IIV (1UL << 8) /* I-cache invalidate */ +#define MCCR_DIV (1UL << 9) /* D-cache invalidate */ +#define MCCR_DCB (1UL << 10) /* D-cache copy back */ +#define MCCR_ICM (1UL << 0) /* I-cache mode [0:off,1:on] */ +#define MCCR_DCM (1UL << 1) /* D-cache mode [0:off,1:on] */ +#define MCCR_ICACHE_INV MCCR_IIV +#define MCCR_DCACHE_CB MCCR_DCB +#define MCCR_DCACHE_CBINV (MCCR_DIV|MCCR_DCB) #endif /* CONFIG_CHIP_XNUX2 || CONFIG_CHIP_M32700 */ #ifndef MCCR diff --git a/include/asm-m32r/assembler.h b/include/asm-m32r/assembler.h index e1dff9d..b7f4d8a 100644 --- a/include/asm-m32r/assembler.h +++ b/include/asm-m32r/assembler.h @@ -52,7 +52,7 @@ or3 \reg, \reg, #low(\x) .endm -#if !defined(CONFIG_CHIP_M32102) +#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104)) #define STI(reg) STI_M reg .macro STI_M reg setpsw #0x40 -> nop @@ -64,7 +64,7 @@ clrpsw #0x40 -> nop ; WORKAROUND: "-> nop" is a workaround for the M32700(TS1). .endm -#else /* CONFIG_CHIP_M32102 */ +#else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */ #define STI(reg) STI_M reg .macro STI_M reg mvfc \reg, psw @@ -191,12 +191,12 @@ and \reg, sp .endm -#if !defined(CONFIG_CHIP_M32102) +#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104)) .macro SWITCH_TO_KERNEL_STACK ; switch to kernel stack (spi) clrpsw #0x80 -> nop .endm -#else /* CONFIG_CHIP_M32102 */ +#else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */ .macro SWITCH_TO_KERNEL_STACK push r0 ; save r0 for working mvfc r0, psw @@ -218,7 +218,7 @@ .fillinsn 2: .endm -#endif /* CONFIG_CHIP_M32102 */ +#endif /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */ #endif /* __ASSEMBLY__ */ diff --git a/include/asm-m32r/cacheflush.h b/include/asm-m32r/cacheflush.h index 46fc4c3..e57427b 100644 --- a/include/asm-m32r/cacheflush.h +++ b/include/asm-m32r/cacheflush.h @@ -7,7 +7,7 @@ extern void _flush_cache_all(void); extern void _flush_cache_copyback_all(void); -#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_OPSP) +#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104) #define flush_cache_all() do { } while (0) #define flush_cache_mm(mm) do { } while (0) #define flush_cache_range(vma, start, end) do { } while (0) diff --git a/include/asm-m32r/irq.h b/include/asm-m32r/irq.h index 8ed7796..ca94395 100644 --- a/include/asm-m32r/irq.h +++ b/include/asm-m32r/irq.h @@ -65,6 +65,22 @@ #define NR_IRQS \ (OPSPUT_NUM_CPU_IRQ + OPSPUT_NUM_PLD_IRQ \ + OPSPUT_NUM_LCD_PLD_IRQ + OPSPUT_NUM_LAN_PLD_IRQ) + +#elif defined(CONFIG_PLAT_M32104UT) +/* + * IRQ definitions for M32104UT + * M32104 Chip: 64 interrupts + * ICU of M32104UT-on-board PLD: 32 interrupts cascaded to INT1# chip pin + */ +#define M32104UT_NUM_CPU_IRQ (64) +#define M32104UT_NUM_PLD_IRQ (32) +#define M32104UT_IRQ_BASE 0 +#define M32104UT_CPU_IRQ_BASE M32104UT_IRQ_BASE +#define M32104UT_PLD_IRQ_BASE (M32104UT_CPU_IRQ_BASE + M32104UT_NUM_CPU_IRQ) + +#define NR_IRQS \ + (M32104UT_NUM_CPU_IRQ + M32104UT_NUM_PLD_IRQ) + #else #define NR_IRQS 64 #endif diff --git a/include/asm-m32r/m32102.h b/include/asm-m32r/m32102.h index cb98101..0bd0a3f 100644 --- a/include/asm-m32r/m32102.h +++ b/include/asm-m32r/m32102.h @@ -11,7 +11,11 @@ /*======================================================================* * Special Function Register *======================================================================*/ +#if !defined(CONFIG_CHIP_M32104) #define M32R_SFR_OFFSET (0x00E00000) /* 0x00E00000-0x00EFFFFF 1[MB] */ +#else +#define M32R_SFR_OFFSET (0x00700000) /* 0x00700000-0x007FFFFF 1[MB] */ +#endif /* * Clock and Power Management registers. @@ -100,7 +104,7 @@ #define M32R_MFT5RLD_PORTL (0x0C+M32R_MFT5_OFFSET) /* MFT4 reload */ #define M32R_MFT5CMPRLD_PORTL (0x10+M32R_MFT5_OFFSET) /* MFT4 compare reload */ -#ifdef CONFIG_CHIP_M32700 +#if defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32104) #define M32R_MFTCR_MFT0MSK (1UL<<31) /* b0 */ #define M32R_MFTCR_MFT1MSK (1UL<<30) /* b1 */ #define M32R_MFTCR_MFT2MSK (1UL<<29) /* b2 */ @@ -113,7 +117,7 @@ #define M32R_MFTCR_MFT3EN (1UL<<20) /* b11 */ #define M32R_MFTCR_MFT4EN (1UL<<19) /* b12 */ #define M32R_MFTCR_MFT5EN (1UL<<18) /* b13 */ -#else /* not CONFIG_CHIP_M32700 */ +#else /* not CONFIG_CHIP_M32700 && not CONFIG_CHIP_M32104 */ #define M32R_MFTCR_MFT0MSK (1UL<<15) /* b16 */ #define M32R_MFTCR_MFT1MSK (1UL<<14) /* b17 */ #define M32R_MFTCR_MFT2MSK (1UL<<13) /* b18 */ @@ -126,7 +130,7 @@ #define M32R_MFTCR_MFT3EN (1UL<<4) /* b27 */ #define M32R_MFTCR_MFT4EN (1UL<<3) /* b28 */ #define M32R_MFTCR_MFT5EN (1UL<<2) /* b29 */ -#endif /* not CONFIG_CHIP_M32700 */ +#endif /* not CONFIG_CHIP_M32700 && not CONFIG_CHIP_M32104 */ #define M32R_MFTMOD_CC_MASK (1UL<<15) /* b16 */ #define M32R_MFTMOD_TCCR (1UL<<13) /* b18 */ @@ -241,8 +245,24 @@ #define M32R_IRQ_MFT1 (17) /* MFT1 */ #define M32R_IRQ_MFT2 (18) /* MFT2 */ #define M32R_IRQ_MFT3 (19) /* MFT3 */ -#define M32R_IRQ_MFT4 (20) /* MFT4 */ -#define M32R_IRQ_MFT5 (21) /* MFT5 */ +#ifdef CONFIG_CHIP_M32104 +#define M32R_IRQ_MFTX0 (24) /* MFTX0 */ +#define M32R_IRQ_MFTX1 (25) /* MFTX1 */ +#define M32R_IRQ_DMA0 (32) /* DMA0 */ +#define M32R_IRQ_DMA1 (33) /* DMA1 */ +#define M32R_IRQ_DMA2 (34) /* DMA2 */ +#define M32R_IRQ_DMA3 (35) /* DMA3 */ +#define M32R_IRQ_SIO0_R (40) /* SIO0 send */ +#define M32R_IRQ_SIO0_S (41) /* SIO0 receive */ +#define M32R_IRQ_SIO1_R (42) /* SIO1 send */ +#define M32R_IRQ_SIO1_S (43) /* SIO1 receive */ +#define M32R_IRQ_SIO2_R (44) /* SIO2 send */ +#define M32R_IRQ_SIO2_S (45) /* SIO2 receive */ +#define M32R_IRQ_SIO3_R (46) /* SIO3 send */ +#define M32R_IRQ_SIO3_S (47) /* SIO3 receive */ +#define M32R_IRQ_ADC (56) /* ADC */ +#define M32R_IRQ_PC (57) /* PC */ +#else /* ! M32104 */ #define M32R_IRQ_DMA0 (32) /* DMA0 */ #define M32R_IRQ_DMA1 (33) /* DMA1 */ #define M32R_IRQ_SIO0_R (48) /* SIO0 send */ @@ -255,6 +275,7 @@ #define M32R_IRQ_SIO3_S (55) /* SIO3 receive */ #define M32R_IRQ_SIO4_R (56) /* SIO4 send */ #define M32R_IRQ_SIO4_S (57) /* SIO4 receive */ +#endif /* ! M32104 */ #ifdef CONFIG_SMP #define M32R_IRQ_IPI0 (56) diff --git a/include/asm-m32r/m32104ut/m32104ut_pld.h b/include/asm-m32r/m32104ut/m32104ut_pld.h new file mode 100644 index 0000000..a4eac20 --- /dev/null +++ b/include/asm-m32r/m32104ut/m32104ut_pld.h @@ -0,0 +1,163 @@ +/* + * include/asm/m32104ut/m32104ut_pld.h + * + * Definitions for Programable Logic Device(PLD) on M32104UT board. + * Based on m32700ut_pld.h + * + * Copyright (c) 2002 Takeo Takahashi + * Copyright (c) 2005 Naoto Sugai + * + * This file is subject to the terms and conditions of the GNU General + * Public License. See the file "COPYING" in the main directory of + * this archive for more details. + */ + +#ifndef _M32104UT_M32104UT_PLD_H +#define _M32104UT_M32104UT_PLD_H + +#include + +#if defined(CONFIG_PLAT_M32104UT) +#define PLD_PLAT_BASE 0x02c00000 +#else +#error "no platform configuration" +#endif + +#ifndef __ASSEMBLY__ +/* + * C functions use non-cache address. + */ +#define PLD_BASE (PLD_PLAT_BASE /* + NONCACHE_OFFSET */) +#define __reg8 (volatile unsigned char *) +#define __reg16 (volatile unsigned short *) +#define __reg32 (volatile unsigned int *) +#else +#define PLD_BASE (PLD_PLAT_BASE + NONCACHE_OFFSET) +#define __reg8 +#define __reg16 +#define __reg32 +#endif /* __ASSEMBLY__ */ + +/* CFC */ +#define PLD_CFRSTCR __reg16(PLD_BASE + 0x0000) +#define PLD_CFSTS __reg16(PLD_BASE + 0x0002) +#define PLD_CFIMASK __reg16(PLD_BASE + 0x0004) +#define PLD_CFBUFCR __reg16(PLD_BASE + 0x0006) + +/* MMC */ +#define PLD_MMCCR __reg16(PLD_BASE + 0x4000) +#define PLD_MMCMOD __reg16(PLD_BASE + 0x4002) +#define PLD_MMCSTS __reg16(PLD_BASE + 0x4006) +#define PLD_MMCBAUR __reg16(PLD_BASE + 0x400a) +#define PLD_MMCCMDBCUT __reg16(PLD_BASE + 0x400c) +#define PLD_MMCCDTBCUT __reg16(PLD_BASE + 0x400e) +#define PLD_MMCDET __reg16(PLD_BASE + 0x4010) +#define PLD_MMCWP __reg16(PLD_BASE + 0x4012) +#define PLD_MMCWDATA __reg16(PLD_BASE + 0x5000) +#define PLD_MMCRDATA __reg16(PLD_BASE + 0x6000) +#define PLD_MMCCMDDATA __reg16(PLD_BASE + 0x7000) +#define PLD_MMCRSPDATA __reg16(PLD_BASE + 0x7006) + +/* ICU + * ICUISTS: status register + * ICUIREQ0: request register + * ICUIREQ1: request register + * ICUCR3: control register for CFIREQ# interrupt + * ICUCR4: control register for CFC Card insert interrupt + * ICUCR5: control register for CFC Card eject interrupt + * ICUCR6: control register for external interrupt + * ICUCR11: control register for MMC Card insert/eject interrupt + * ICUCR13: control register for SC error interrupt + * ICUCR14: control register for SC receive interrupt + * ICUCR15: control register for SC send interrupt + */ + +#define PLD_IRQ_INT0 (M32104UT_PLD_IRQ_BASE + 0) /* None */ +#define PLD_IRQ_CFIREQ (M32104UT_PLD_IRQ_BASE + 3) /* CF IREQ */ +#define PLD_IRQ_CFC_INSERT (M32104UT_PLD_IRQ_BASE + 4) /* CF Insert */ +#define PLD_IRQ_CFC_EJECT (M32104UT_PLD_IRQ_BASE + 5) /* CF Eject */ +#define PLD_IRQ_EXINT (M32104UT_PLD_IRQ_BASE + 6) /* EXINT */ +#define PLD_IRQ_MMCCARD (M32104UT_PLD_IRQ_BASE + 11) /* MMC Insert/Eject */ +#define PLD_IRQ_SC_ERROR (M32104UT_PLD_IRQ_BASE + 13) /* SC error */ +#define PLD_IRQ_SC_RCV (M32104UT_PLD_IRQ_BASE + 14) /* SC receive */ +#define PLD_IRQ_SC_SND (M32104UT_PLD_IRQ_BASE + 15) /* SC send */ + +#define PLD_ICUISTS __reg16(PLD_BASE + 0x8002) +#define PLD_ICUISTS_VECB_MASK (0xf000) +#define PLD_ICUISTS_VECB(x) ((x) & PLD_ICUISTS_VECB_MASK) +#define PLD_ICUISTS_ISN_MASK (0x07c0) +#define PLD_ICUISTS_ISN(x) ((x) & PLD_ICUISTS_ISN_MASK) +#define PLD_ICUCR3 __reg16(PLD_BASE + 0x8104) +#define PLD_ICUCR4 __reg16(PLD_BASE + 0x8106) +#define PLD_ICUCR5 __reg16(PLD_BASE + 0x8108) +#define PLD_ICUCR6 __reg16(PLD_BASE + 0x810a) +#define PLD_ICUCR11 __reg16(PLD_BASE + 0x8114) +#define PLD_ICUCR13 __reg16(PLD_BASE + 0x8118) +#define PLD_ICUCR14 __reg16(PLD_BASE + 0x811a) +#define PLD_ICUCR15 __reg16(PLD_BASE + 0x811c) +#define PLD_ICUCR_IEN (0x1000) +#define PLD_ICUCR_IREQ (0x0100) +#define PLD_ICUCR_ISMOD00 (0x0000) /* Low edge */ +#define PLD_ICUCR_ISMOD01 (0x0010) /* Low level */ +#define PLD_ICUCR_ISMOD02 (0x0020) /* High edge */ +#define PLD_ICUCR_ISMOD03 (0x0030) /* High level */ +#define PLD_ICUCR_ILEVEL0 (0x0000) +#define PLD_ICUCR_ILEVEL1 (0x0001) +#define PLD_ICUCR_ILEVEL2 (0x0002) +#define PLD_ICUCR_ILEVEL3 (0x0003) +#define PLD_ICUCR_ILEVEL4 (0x0004) +#define PLD_ICUCR_ILEVEL5 (0x0005) +#define PLD_ICUCR_ILEVEL6 (0x0006) +#define PLD_ICUCR_ILEVEL7 (0x0007) + +/* Power Control of MMC and CF */ +#define PLD_CPCR __reg16(PLD_BASE + 0x14000) +#define PLD_CPCR_CDP 0x0001 + +/* LED Control + * + * 1: DIP swich side + * 2: Reset switch side + */ +#define PLD_IOLEDCR __reg16(PLD_BASE + 0x14002) +#define PLD_IOLED_1_ON 0x001 +#define PLD_IOLED_1_OFF 0x000 +#define PLD_IOLED_2_ON 0x002 +#define PLD_IOLED_2_OFF 0x000 + +/* DIP Switch + * 0: Write-protect of Flash Memory (0:protected, 1:non-protected) + * 1: - + * 2: - + * 3: - + */ +#define PLD_IOSWSTS __reg16(PLD_BASE + 0x14004) +#define PLD_IOSWSTS_IOSW2 0x0200 +#define PLD_IOSWSTS_IOSW1 0x0100 +#define PLD_IOSWSTS_IOWP0 0x0001 + +/* CRC */ +#define PLD_CRC7DATA __reg16(PLD_BASE + 0x18000) +#define PLD_CRC7INDATA __reg16(PLD_BASE + 0x18002) +#define PLD_CRC16DATA __reg16(PLD_BASE + 0x18004) +#define PLD_CRC16INDATA __reg16(PLD_BASE + 0x18006) +#define PLD_CRC16ADATA __reg16(PLD_BASE + 0x18008) +#define PLD_CRC16AINDATA __reg16(PLD_BASE + 0x1800a) + +/* RTC */ +#define PLD_RTCCR __reg16(PLD_BASE + 0x1c000) +#define PLD_RTCBAUR __reg16(PLD_BASE + 0x1c002) +#define PLD_RTCWRDATA __reg16(PLD_BASE + 0x1c004) +#define PLD_RTCRDDATA __reg16(PLD_BASE + 0x1c006) +#define PLD_RTCRSTODT __reg16(PLD_BASE + 0x1c008) + +/* SIM Card */ +#define PLD_SCCR __reg16(PLD_BASE + 0x38000) +#define PLD_SCMOD __reg16(PLD_BASE + 0x38004) +#define PLD_SCSTS __reg16(PLD_BASE + 0x38006) +#define PLD_SCINTCR __reg16(PLD_BASE + 0x38008) +#define PLD_SCBAUR __reg16(PLD_BASE + 0x3800a) +#define PLD_SCTXB __reg16(PLD_BASE + 0x3800c) +#define PLD_SCRXB __reg16(PLD_BASE + 0x3800e) + +#endif /* _M32104UT_M32104UT_PLD_H */ diff --git a/include/asm-m32r/m32r.h b/include/asm-m32r/m32r.h index ec142be..f9bb48ac 100644 --- a/include/asm-m32r/m32r.h +++ b/include/asm-m32r/m32r.h @@ -14,7 +14,7 @@ #include #elif defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_XNUX2) \ || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_M32102) \ - || defined(CONFIG_CHIP_OPSP) + || defined(CONFIG_CHIP_OPSP) || defined(CONFIG_CHIP_M32104) #include #endif @@ -43,6 +43,10 @@ #include #endif +#if defined(CONFIG_PLAT_M32104UT) +#include +#endif /* CONFIG_PLAT_M32104 */ + /* * M32R Register */ diff --git a/include/asm-m32r/system.h b/include/asm-m32r/system.h index 5eee832..dcf619a 100644 --- a/include/asm-m32r/system.h +++ b/include/asm-m32r/system.h @@ -69,12 +69,12 @@ } while(0) /* Interrupt Control */ -#if !defined(CONFIG_CHIP_M32102) +#if !defined(CONFIG_CHIP_M32102) && !defined(CONFIG_CHIP_M32104) #define local_irq_enable() \ __asm__ __volatile__ ("setpsw #0x40 -> nop": : :"memory") #define local_irq_disable() \ __asm__ __volatile__ ("clrpsw #0x40 -> nop": : :"memory") -#else /* CONFIG_CHIP_M32102 */ +#else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */ static inline void local_irq_enable(void) { unsigned long tmpreg; @@ -96,7 +96,7 @@ static inline void local_irq_disable(void) "mvtc %0, psw \n\t" : "=&r" (tmpreg0), "=&r" (tmpreg1) : : "cbit", "memory"); } -#endif /* CONFIG_CHIP_M32102 */ +#endif /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */ #define local_save_flags(x) \ __asm__ __volatile__("mvfc %0,psw" : "=r"(x) : /* no input */) @@ -105,13 +105,13 @@ static inline void local_irq_disable(void) __asm__ __volatile__("mvtc %0,psw" : /* no outputs */ \ : "r" (x) : "cbit", "memory") -#if !defined(CONFIG_CHIP_M32102) +#if !(defined(CONFIG_CHIP_M32102) || defined(CONFIG_CHIP_M32104)) #define local_irq_save(x) \ __asm__ __volatile__( \ "mvfc %0, psw; \n\t" \ "clrpsw #0x40 -> nop; \n\t" \ : "=r" (x) : /* no input */ : "memory") -#else /* CONFIG_CHIP_M32102 */ +#else /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */ #define local_irq_save(x) \ ({ \ unsigned long tmpreg; \ @@ -124,7 +124,7 @@ static inline void local_irq_disable(void) : "=r" (x), "=&r" (tmpreg) \ : : "cbit", "memory"); \ }) -#endif /* CONFIG_CHIP_M32102 */ +#endif /* CONFIG_CHIP_M32102 || CONFIG_CHIP_M32104 */ #define irqs_disabled() \ ({ \ -- cgit v1.1 From 1b5b776aa5730cbda9cba84ba0f8ccd53a775797 Mon Sep 17 00:00:00 2001 From: Hirokazu Takata Date: Fri, 6 Jan 2006 00:18:42 -0800 Subject: [PATCH] m32r: Update syscall macros for MMU-less targets This patch is for updating m32r's MMU-less support. Some legacy MMU-less m32r chips cannot return from a trap handler to the right-hand side 16-bit halfword code of a 32-bit instrucion code pair, because a "trap" instruction specification was expanded in M32R-II ISA. This modification forces "trap" instructions to be placed in word alignment location with a parallel "nop" code. Signed-off-by: Kazuhiro Inaoka Signed-off-by: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-m32r/unistd.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h index ac399e1..39be87c 100644 --- a/include/asm-m32r/unistd.h +++ b/include/asm-m32r/unistd.h @@ -319,7 +319,7 @@ type name(void) \ register long __scno __asm__ ("r7") = __NR_##name; \ register long __res __asm__("r0"); \ __asm__ __volatile__ (\ - "trap #" SYSCALL_VECTOR \ + "trap #" SYSCALL_VECTOR "|| nop"\ : "=r" (__res) \ : "r" (__scno) \ : "memory"); \ @@ -332,7 +332,7 @@ type name(type1 arg1) \ register long __scno __asm__ ("r7") = __NR_##name; \ register long __res __asm__ ("r0") = (long)(arg1); \ __asm__ __volatile__ (\ - "trap #" SYSCALL_VECTOR \ + "trap #" SYSCALL_VECTOR "|| nop"\ : "=r" (__res) \ : "r" (__scno), "0" (__res) \ : "memory"); \ @@ -346,7 +346,7 @@ register long __scno __asm__ ("r7") = __NR_##name; \ register long __arg2 __asm__ ("r1") = (long)(arg2); \ register long __res __asm__ ("r0") = (long)(arg1); \ __asm__ __volatile__ (\ - "trap #" SYSCALL_VECTOR \ + "trap #" SYSCALL_VECTOR "|| nop"\ : "=r" (__res) \ : "r" (__scno), "0" (__res), "r" (__arg2) \ : "memory"); \ @@ -361,7 +361,7 @@ register long __arg3 __asm__ ("r2") = (long)(arg3); \ register long __arg2 __asm__ ("r1") = (long)(arg2); \ register long __res __asm__ ("r0") = (long)(arg1); \ __asm__ __volatile__ (\ - "trap #" SYSCALL_VECTOR \ + "trap #" SYSCALL_VECTOR "|| nop"\ : "=r" (__res) \ : "r" (__scno), "0" (__res), "r" (__arg2), \ "r" (__arg3) \ @@ -378,7 +378,7 @@ register long __arg3 __asm__ ("r2") = (long)(arg3); \ register long __arg2 __asm__ ("r1") = (long)(arg2); \ register long __res __asm__ ("r0") = (long)(arg1); \ __asm__ __volatile__ (\ - "trap #" SYSCALL_VECTOR \ + "trap #" SYSCALL_VECTOR "|| nop"\ : "=r" (__res) \ : "r" (__scno), "0" (__res), "r" (__arg2), \ "r" (__arg3), "r" (__arg4) \ @@ -397,7 +397,7 @@ register long __arg3 __asm__ ("r2") = (long)(arg3); \ register long __arg2 __asm__ ("r1") = (long)(arg2); \ register long __res __asm__ ("r0") = (long)(arg1); \ __asm__ __volatile__ (\ - "trap #" SYSCALL_VECTOR \ + "trap #" SYSCALL_VECTOR "|| nop"\ : "=r" (__res) \ : "r" (__scno), "0" (__res), "r" (__arg2), \ "r" (__arg3), "r" (__arg4), "r" (__arg5) \ -- cgit v1.1 From 46ea178b7a5162405bf70954d769165cf2161309 Mon Sep 17 00:00:00 2001 From: Hirokazu Takata Date: Fri, 6 Jan 2006 00:18:43 -0800 Subject: [PATCH] m32r: Update _port2addr to use NONCACHE_OFFSET Modify _port2addr*() routines in arch/m32r/kernel/io_*.c to use NONCACHE_OFFSET instead of hard-coding of a constant address. This modification is also required to support an M3A-ZA36 FPGA eva board in case an MMU-less synthesizable m32r core is used. Signed-off-by: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m32r/kernel/io_m32104ut.c | 24 ++++++++++---------- arch/m32r/kernel/io_m32700ut.c | 24 ++++++++++---------- arch/m32r/kernel/io_mappi.c | 2 +- arch/m32r/kernel/io_mappi2.c | 24 ++++++++++---------- arch/m32r/kernel/io_mappi3.c | 51 +++++++++++++++++++++++++----------------- arch/m32r/kernel/io_oaks32r.c | 2 +- arch/m32r/kernel/io_opsput.c | 6 ++--- include/asm-m32r/m32r.h | 2 +- 8 files changed, 72 insertions(+), 63 deletions(-) diff --git a/arch/m32r/kernel/io_m32104ut.c b/arch/m32r/kernel/io_m32104ut.c index 3df4215..d26adab 100644 --- a/arch/m32r/kernel/io_m32104ut.c +++ b/arch/m32r/kernel/io_m32104ut.c @@ -32,7 +32,7 @@ extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); static inline void *_port2addr(unsigned long port) { - return (void *)(port + NONCACHE_OFFSET); + return (void *)(port | NONCACHE_OFFSET); } #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) @@ -41,15 +41,15 @@ static inline void *__port2addr_ata(unsigned long port) static int dummy_reg; switch (port) { - case 0x1f0: return (void *)0xac002000; - case 0x1f1: return (void *)0xac012800; - case 0x1f2: return (void *)0xac012002; - case 0x1f3: return (void *)0xac012802; - case 0x1f4: return (void *)0xac012004; - case 0x1f5: return (void *)0xac012804; - case 0x1f6: return (void *)0xac012006; - case 0x1f7: return (void *)0xac012806; - case 0x3f6: return (void *)0xac01200e; + case 0x1f0: return (void *)(0x0c002000 | NONCACHE_OFFSET); + case 0x1f1: return (void *)(0x0c012800 | NONCACHE_OFFSET); + case 0x1f2: return (void *)(0x0c012002 | NONCACHE_OFFSET); + case 0x1f3: return (void *)(0x0c012802 | NONCACHE_OFFSET); + case 0x1f4: return (void *)(0x0c012004 | NONCACHE_OFFSET); + case 0x1f5: return (void *)(0x0c012804 | NONCACHE_OFFSET); + case 0x1f6: return (void *)(0x0c012006 | NONCACHE_OFFSET); + case 0x1f7: return (void *)(0x0c012806 | NONCACHE_OFFSET); + case 0x3f6: return (void *)(0x0c01200e | NONCACHE_OFFSET); default: return (void *)&dummy_reg; } } @@ -60,8 +60,8 @@ static inline void *__port2addr_ata(unsigned long port) * from 0x01000000 to 0x01ffffff on physical address. * The base address of LAN controller(LAN91C111) is 0x300. */ -#define LAN_IOSTART 0x300 -#define LAN_IOEND 0x320 +#define LAN_IOSTART (0x300 | NONCACHE_OFFSET) +#define LAN_IOEND (0x320 | NONCACHE_OFFSET) static inline void *_port2addr_ne(unsigned long port) { return (void *)(port + NONCACHE_OFFSET + 0x01000000); diff --git a/arch/m32r/kernel/io_m32700ut.c b/arch/m32r/kernel/io_m32700ut.c index eda9f96..939932d 100644 --- a/arch/m32r/kernel/io_m32700ut.c +++ b/arch/m32r/kernel/io_m32700ut.c @@ -36,7 +36,7 @@ extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); static inline void *_port2addr(unsigned long port) { - return (void *)(port + NONCACHE_OFFSET); + return (void *)(port | NONCACHE_OFFSET); } #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) @@ -45,15 +45,15 @@ static inline void *__port2addr_ata(unsigned long port) static int dummy_reg; switch (port) { - case 0x1f0: return (void *)0xac002000; - case 0x1f1: return (void *)0xac012800; - case 0x1f2: return (void *)0xac012002; - case 0x1f3: return (void *)0xac012802; - case 0x1f4: return (void *)0xac012004; - case 0x1f5: return (void *)0xac012804; - case 0x1f6: return (void *)0xac012006; - case 0x1f7: return (void *)0xac012806; - case 0x3f6: return (void *)0xac01200e; + case 0x1f0: return (void *)(0x0c002000 | NONCACHE_OFFSET); + case 0x1f1: return (void *)(0x0c012800 | NONCACHE_OFFSET); + case 0x1f2: return (void *)(0x0c012002 | NONCACHE_OFFSET); + case 0x1f3: return (void *)(0x0c012802 | NONCACHE_OFFSET); + case 0x1f4: return (void *)(0x0c012004 | NONCACHE_OFFSET); + case 0x1f5: return (void *)(0x0c012804 | NONCACHE_OFFSET); + case 0x1f6: return (void *)(0x0c012006 | NONCACHE_OFFSET); + case 0x1f7: return (void *)(0x0c012806 | NONCACHE_OFFSET); + case 0x3f6: return (void *)(0x0c01200e | NONCACHE_OFFSET); default: return (void *)&dummy_reg; } } @@ -64,8 +64,8 @@ static inline void *__port2addr_ata(unsigned long port) * from 0x10000000 to 0x13ffffff on physical address. * The base address of LAN controller(LAN91C111) is 0x300. */ -#define LAN_IOSTART 0xa0000300 -#define LAN_IOEND 0xa0000320 +#define LAN_IOSTART (0x300 | NONCACHE_OFFSET) +#define LAN_IOEND (0x320 | NONCACHE_OFFSET) static inline void *_port2addr_ne(unsigned long port) { return (void *)(port + 0x10000000); diff --git a/arch/m32r/kernel/io_mappi.c b/arch/m32r/kernel/io_mappi.c index 3c3da04..a662b53 100644 --- a/arch/m32r/kernel/io_mappi.c +++ b/arch/m32r/kernel/io_mappi.c @@ -31,7 +31,7 @@ extern void pcc_iowrite(int, unsigned long, void *, size_t, size_t, int); static inline void *_port2addr(unsigned long port) { - return (void *)(port | (NONCACHE_OFFSET)); + return (void *)(port | NONCACHE_OFFSET); } static inline void *_port2addr_ne(unsigned long port) diff --git a/arch/m32r/kernel/io_mappi2.c b/arch/m32r/kernel/io_mappi2.c index df3c729..e72d725 100644 --- a/arch/m32r/kernel/io_mappi2.c +++ b/arch/m32r/kernel/io_mappi2.c @@ -33,7 +33,7 @@ extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); static inline void *_port2addr(unsigned long port) { - return (void *)(port | (NONCACHE_OFFSET)); + return (void *)(port | NONCACHE_OFFSET); } #if defined(CONFIG_IDE) && !defined(CONFIG_M32R_CFC) @@ -42,22 +42,22 @@ static inline void *__port2addr_ata(unsigned long port) static int dummy_reg; switch (port) { - case 0x1f0: return (void *)0xac002000; - case 0x1f1: return (void *)0xac012800; - case 0x1f2: return (void *)0xac012002; - case 0x1f3: return (void *)0xac012802; - case 0x1f4: return (void *)0xac012004; - case 0x1f5: return (void *)0xac012804; - case 0x1f6: return (void *)0xac012006; - case 0x1f7: return (void *)0xac012806; - case 0x3f6: return (void *)0xac01200e; + case 0x1f0: return (void *)(0x0c002000 | NONCACHE_OFFSET); + case 0x1f1: return (void *)(0x0c012800 | NONCACHE_OFFSET); + case 0x1f2: return (void *)(0x0c012002 | NONCACHE_OFFSET); + case 0x1f3: return (void *)(0x0c012802 | NONCACHE_OFFSET); + case 0x1f4: return (void *)(0x0c012004 | NONCACHE_OFFSET); + case 0x1f5: return (void *)(0x0c012804 | NONCACHE_OFFSET); + case 0x1f6: return (void *)(0x0c012006 | NONCACHE_OFFSET); + case 0x1f7: return (void *)(0x0c012806 | NONCACHE_OFFSET); + case 0x3f6: return (void *)(0x0c01200e | NONCACHE_OFFSET); default: return (void *)&dummy_reg; } } #endif -#define LAN_IOSTART 0xa0000300 -#define LAN_IOEND 0xa0000320 +#define LAN_IOSTART (0x300 | NONCACHE_OFFSET) +#define LAN_IOEND (0x320 | NONCACHE_OFFSET) #ifdef CONFIG_CHIP_OPSP static inline void *_port2addr_ne(unsigned long port) { diff --git a/arch/m32r/kernel/io_mappi3.c b/arch/m32r/kernel/io_mappi3.c index f80321a..ed6da93 100644 --- a/arch/m32r/kernel/io_mappi3.c +++ b/arch/m32r/kernel/io_mappi3.c @@ -33,7 +33,7 @@ extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); static inline void *_port2addr(unsigned long port) { - return (void *)(port + NONCACHE_OFFSET); + return (void *)(port | NONCACHE_OFFSET); } #if defined(CONFIG_IDE) @@ -43,33 +43,42 @@ static inline void *__port2addr_ata(unsigned long port) switch (port) { /* IDE0 CF */ - case 0x1f0: return (void *)0xb4002000; - case 0x1f1: return (void *)0xb4012800; - case 0x1f2: return (void *)0xb4012002; - case 0x1f3: return (void *)0xb4012802; - case 0x1f4: return (void *)0xb4012004; - case 0x1f5: return (void *)0xb4012804; - case 0x1f6: return (void *)0xb4012006; - case 0x1f7: return (void *)0xb4012806; - case 0x3f6: return (void *)0xb401200e; + case 0x1f0: return (void *)(0x14002000 | NONCACHE_OFFSET); + case 0x1f1: return (void *)(0x14012800 | NONCACHE_OFFSET); + case 0x1f2: return (void *)(0x14012002 | NONCACHE_OFFSET); + case 0x1f3: return (void *)(0x14012802 | NONCACHE_OFFSET); + case 0x1f4: return (void *)(0x14012004 | NONCACHE_OFFSET); + case 0x1f5: return (void *)(0x14012804 | NONCACHE_OFFSET); + case 0x1f6: return (void *)(0x14012006 | NONCACHE_OFFSET); + case 0x1f7: return (void *)(0x14012806 | NONCACHE_OFFSET); + case 0x3f6: return (void *)(0x1401200e | NONCACHE_OFFSET); /* IDE1 IDE */ - case 0x170: return (void *)0xb4810000; /* Data 16bit */ - case 0x171: return (void *)0xb4810002; /* Features / Error */ - case 0x172: return (void *)0xb4810004; /* Sector count */ - case 0x173: return (void *)0xb4810006; /* Sector number */ - case 0x174: return (void *)0xb4810008; /* Cylinder low */ - case 0x175: return (void *)0xb481000a; /* Cylinder high */ - case 0x176: return (void *)0xb481000c; /* Device head */ - case 0x177: return (void *)0xb481000e; /* Command */ - case 0x376: return (void *)0xb480800c; /* Device control / Alt status */ + case 0x170: /* Data 16bit */ + return (void *)(0x14810000 | NONCACHE_OFFSET); + case 0x171: /* Features / Error */ + return (void *)(0x14810002 | NONCACHE_OFFSET); + case 0x172: /* Sector count */ + return (void *)(0x14810004 | NONCACHE_OFFSET); + case 0x173: /* Sector number */ + return (void *)(0x14810006 | NONCACHE_OFFSET); + case 0x174: /* Cylinder low */ + return (void *)(0x14810008 | NONCACHE_OFFSET); + case 0x175: /* Cylinder high */ + return (void *)(0x1481000a | NONCACHE_OFFSET); + case 0x176: /* Device head */ + return (void *)(0x1481000c | NONCACHE_OFFSET); + case 0x177: /* Command */ + return (void *)(0x1481000e | NONCACHE_OFFSET); + case 0x376: /* Device control / Alt status */ + return (void *)(0x1480800c | NONCACHE_OFFSET); default: return (void *)&dummy_reg; } } #endif -#define LAN_IOSTART 0xa0000300 -#define LAN_IOEND 0xa0000320 +#define LAN_IOSTART (0x300 | NONCACHE_OFFSET) +#define LAN_IOEND (0x320 | NONCACHE_OFFSET) static inline void *_port2addr_ne(unsigned long port) { return (void *)(port + 0x10000000); diff --git a/arch/m32r/kernel/io_oaks32r.c b/arch/m32r/kernel/io_oaks32r.c index 8be3239..910dd13 100644 --- a/arch/m32r/kernel/io_oaks32r.c +++ b/arch/m32r/kernel/io_oaks32r.c @@ -16,7 +16,7 @@ static inline void *_port2addr(unsigned long port) { - return (void *)(port | (NONCACHE_OFFSET)); + return (void *)(port | NONCACHE_OFFSET); } static inline void *_port2addr_ne(unsigned long port) diff --git a/arch/m32r/kernel/io_opsput.c b/arch/m32r/kernel/io_opsput.c index 4793bd1..bec6929 100644 --- a/arch/m32r/kernel/io_opsput.c +++ b/arch/m32r/kernel/io_opsput.c @@ -36,7 +36,7 @@ extern void pcc_iowrite_word(int, unsigned long, void *, size_t, size_t, int); static inline void *_port2addr(unsigned long port) { - return (void *)(port | (NONCACHE_OFFSET)); + return (void *)(port | NONCACHE_OFFSET); } /* @@ -44,8 +44,8 @@ static inline void *_port2addr(unsigned long port) * from 0x10000000 to 0x13ffffff on physical address. * The base address of LAN controller(LAN91C111) is 0x300. */ -#define LAN_IOSTART 0xa0000300 -#define LAN_IOEND 0xa0000320 +#define LAN_IOSTART (0x300 | NONCACHE_OFFSET) +#define LAN_IOEND (0x320 | NONCACHE_OFFSET) static inline void *_port2addr_ne(unsigned long port) { return (void *)(port + 0x10000000); diff --git a/include/asm-m32r/m32r.h b/include/asm-m32r/m32r.h index f9bb48ac..b133ca6 100644 --- a/include/asm-m32r/m32r.h +++ b/include/asm-m32r/m32r.h @@ -126,7 +126,7 @@ #include #ifdef CONFIG_MMU -#define NONCACHE_OFFSET __PAGE_OFFSET+0x20000000 +#define NONCACHE_OFFSET (__PAGE_OFFSET + 0x20000000) #else #define NONCACHE_OFFSET __PAGE_OFFSET #endif /* CONFIG_MMU */ -- cgit v1.1 From 9b791d4766c19ac014a7b81a551efe4a7511e12a Mon Sep 17 00:00:00 2001 From: Hirokazu Takata Date: Fri, 6 Jan 2006 00:18:44 -0800 Subject: [PATCH] m32r: Fix M32104 cache flushing routines This patch fixes cache memory parameter setting for the M32104 target. So far, its performance seemed to have been degraded due to incorrect cache parameter setting. * arch/m32r/boot/setup.S: Set SFR(Special Fuction Registers) region to be non-cachable explicitly. * arch/m32r/mm/cache.c: Fix cache flushing routines not to switch off the M32104 cache. Signed-off-by: Hayato Fujiwara Signed-off-by: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m32r/boot/setup.S | 15 ++++++++++++--- arch/m32r/mm/cache.c | 28 +++++++++++++++++++++------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/arch/m32r/boot/setup.S b/arch/m32r/boot/setup.S index 742669f..3985425 100644 --- a/arch/m32r/boot/setup.S +++ b/arch/m32r/boot/setup.S @@ -1,11 +1,10 @@ /* * linux/arch/m32r/boot/setup.S -- A setup code. * - * Copyright (C) 2001, 2002 Hiroyuki Kondo, Hirokazu Takata, - * and Hitoshi Yamamoto + * Copyright (C) 2001-2005 Hiroyuki Kondo, Hirokazu Takata, + * Hitoshi Yamamoto, Hayato Fujiwara * */ -/* $Id$ */ #include #include @@ -81,6 +80,16 @@ ENTRY(boot) ; ldi r1, #0x00 ; cache off st r1, @r0 #elif defined(CONFIG_CHIP_M32104) + ldi r0, #-96 ; DNCR0 + seth r1, #0x0060 ; from 0x00600000 + or3 r1, r1, #0x0005 ; size 2MB + st r1, @r0 + seth r1, #0x0100 ; from 0x01000000 + or3 r1, r1, #0x0003 ; size 16MB + st r1, @+r0 + seth r1, #0x0200 ; from 0x02000000 + or3 r1, r1, #0x0002 ; size 32MB + st r1, @+r0 ldi r0, #-4 ;LDIMM (r0, M32R_MCCR) ldi r1, #0x703 ; cache on (with invalidation) st r1, @r0 diff --git a/arch/m32r/mm/cache.c b/arch/m32r/mm/cache.c index c6f72a6..9f54dd9 100644 --- a/arch/m32r/mm/cache.c +++ b/arch/m32r/mm/cache.c @@ -1,7 +1,7 @@ /* * linux/arch/m32r/mm/cache.c * - * Copyright (C) 2002 Hirokazu Takata + * Copyright (C) 2002-2005 Hirokazu Takata, Hayato Fujiwara */ #include @@ -9,7 +9,8 @@ #undef MCCR -#if defined(CONFIG_CHIP_XNUX2) || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_OPSP) +#if defined(CONFIG_CHIP_XNUX2) || defined(CONFIG_CHIP_M32700) \ + || defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_OPSP) /* Cache Control Register */ #define MCCR ((volatile unsigned long*)0xfffffffc) #define MCCR_CC (1UL << 7) /* Cache mode modify bit */ @@ -27,7 +28,7 @@ #define MCCR_IIV (1UL << 0) /* I-cache invalidate */ #define MCCR_ICACHE_INV MCCR_IIV #elif defined(CONFIG_CHIP_M32104) -#define MCCR ((volatile unsigned long*)0xfffffffc) +#define MCCR ((volatile unsigned short*)0xfffffffe) #define MCCR_IIV (1UL << 8) /* I-cache invalidate */ #define MCCR_DIV (1UL << 9) /* D-cache invalidate */ #define MCCR_DCB (1UL << 10) /* D-cache copy back */ @@ -36,7 +37,7 @@ #define MCCR_ICACHE_INV MCCR_IIV #define MCCR_DCACHE_CB MCCR_DCB #define MCCR_DCACHE_CBINV (MCCR_DIV|MCCR_DCB) -#endif /* CONFIG_CHIP_XNUX2 || CONFIG_CHIP_M32700 */ +#endif #ifndef MCCR #error Unknown cache type. @@ -47,29 +48,42 @@ void _flush_cache_all(void) { #if defined(CONFIG_CHIP_M32102) + unsigned char mccr; *MCCR = MCCR_ICACHE_INV; +#elif defined(CONFIG_CHIP_M32104) + unsigned short mccr; + + /* Copyback and invalidate D-cache */ + /* Invalidate I-cache */ + *MCCR |= (MCCR_ICACHE_INV | MCCR_DCACHE_CBINV); #else unsigned long mccr; /* Copyback and invalidate D-cache */ /* Invalidate I-cache */ *MCCR = MCCR_ICACHE_INV | MCCR_DCACHE_CBINV; - while ((mccr = *MCCR) & MCCR_IIV); /* loop while invalidating... */ #endif + while ((mccr = *MCCR) & MCCR_IIV); /* loop while invalidating... */ } /* Copy back D-cache and invalidate I-cache all */ void _flush_cache_copyback_all(void) { #if defined(CONFIG_CHIP_M32102) + unsigned char mccr; *MCCR = MCCR_ICACHE_INV; +#elif defined(CONFIG_CHIP_M32104) + unsigned short mccr; + + /* Copyback and invalidate D-cache */ + /* Invalidate I-cache */ + *MCCR |= (MCCR_ICACHE_INV | MCCR_DCACHE_CB); #else unsigned long mccr; /* Copyback D-cache */ /* Invalidate I-cache */ *MCCR = MCCR_ICACHE_INV | MCCR_DCACHE_CB; - while ((mccr = *MCCR) & MCCR_IIV); /* loop while invalidating... */ - #endif + while ((mccr = *MCCR) & MCCR_IIV); /* loop while invalidating... */ } -- cgit v1.1 From adfc31c67f4515ed4bad1ef9555cbacdfc24e8d3 Mon Sep 17 00:00:00 2001 From: Hirokazu Takata Date: Fri, 6 Jan 2006 00:18:45 -0800 Subject: [PATCH] m32r: Remove unnecessary icu_data_t definitions This patch removes unnecessary struct icu_data_t definitions of arch/m32r/kernel/setup_*.c. Signed-off-by: Hayato Fujiwara Signed-off-by: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m32r/kernel/setup_m32104ut.c | 6 ------ arch/m32r/kernel/setup_m32700ut.c | 8 -------- arch/m32r/kernel/setup_mappi.c | 6 ------ arch/m32r/kernel/setup_mappi2.c | 6 ------ arch/m32r/kernel/setup_mappi3.c | 6 ------ arch/m32r/kernel/setup_oaks32r.c | 6 ------ arch/m32r/kernel/setup_opsput.c | 8 -------- arch/m32r/kernel/setup_usrv.c | 6 ------ include/asm-m32r/m32102.h | 7 ++----- 9 files changed, 2 insertions(+), 57 deletions(-) diff --git a/arch/m32r/kernel/setup_m32104ut.c b/arch/m32r/kernel/setup_m32104ut.c index ab16c66..6328e13 100644 --- a/arch/m32r/kernel/setup_m32104ut.c +++ b/arch/m32r/kernel/setup_m32104ut.c @@ -20,12 +20,6 @@ #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) -#ifndef CONFIG_SMP -typedef struct { - unsigned long icucr; /* ICU Control Register */ -} icu_data_t; -#endif /* CONFIG_SMP */ - icu_data_t icu_data[NR_IRQS]; static void disable_m32104ut_irq(unsigned int irq) diff --git a/arch/m32r/kernel/setup_m32700ut.c b/arch/m32r/kernel/setup_m32700ut.c index cb76916..fad1fc9 100644 --- a/arch/m32r/kernel/setup_m32700ut.c +++ b/arch/m32r/kernel/setup_m32700ut.c @@ -26,15 +26,7 @@ */ #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) -#ifndef CONFIG_SMP -typedef struct { - unsigned long icucr; /* ICU Control Register */ -} icu_data_t; -static icu_data_t icu_data[M32700UT_NUM_CPU_IRQ]; -#else icu_data_t icu_data[M32700UT_NUM_CPU_IRQ]; -#endif /* CONFIG_SMP */ - static void disable_m32700ut_irq(unsigned int irq) { diff --git a/arch/m32r/kernel/setup_mappi.c b/arch/m32r/kernel/setup_mappi.c index 501d798..00f2532 100644 --- a/arch/m32r/kernel/setup_mappi.c +++ b/arch/m32r/kernel/setup_mappi.c @@ -19,12 +19,6 @@ #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) -#ifndef CONFIG_SMP -typedef struct { - unsigned long icucr; /* ICU Control Register */ -} icu_data_t; -#endif /* CONFIG_SMP */ - icu_data_t icu_data[NR_IRQS]; static void disable_mappi_irq(unsigned int irq) diff --git a/arch/m32r/kernel/setup_mappi2.c b/arch/m32r/kernel/setup_mappi2.c index 7f2db5b..eebc9d8 100644 --- a/arch/m32r/kernel/setup_mappi2.c +++ b/arch/m32r/kernel/setup_mappi2.c @@ -19,12 +19,6 @@ #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) -#ifndef CONFIG_SMP -typedef struct { - unsigned long icucr; /* ICU Control Register */ -} icu_data_t; -#endif /* CONFIG_SMP */ - icu_data_t icu_data[NR_IRQS]; static void disable_mappi2_irq(unsigned int irq) diff --git a/arch/m32r/kernel/setup_mappi3.c b/arch/m32r/kernel/setup_mappi3.c index f6ecdf7..d2ff021 100644 --- a/arch/m32r/kernel/setup_mappi3.c +++ b/arch/m32r/kernel/setup_mappi3.c @@ -19,12 +19,6 @@ #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) -#ifndef CONFIG_SMP -typedef struct { - unsigned long icucr; /* ICU Control Register */ -} icu_data_t; -#endif /* CONFIG_SMP */ - icu_data_t icu_data[NR_IRQS]; static void disable_mappi3_irq(unsigned int irq) diff --git a/arch/m32r/kernel/setup_oaks32r.c b/arch/m32r/kernel/setup_oaks32r.c index 45add5b..0e9e635 100644 --- a/arch/m32r/kernel/setup_oaks32r.c +++ b/arch/m32r/kernel/setup_oaks32r.c @@ -18,12 +18,6 @@ #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) -#ifndef CONFIG_SMP -typedef struct { - unsigned long icucr; /* ICU Control Register */ -} icu_data_t; -#endif /* CONFIG_SMP */ - icu_data_t icu_data[NR_IRQS]; static void disable_oaks32r_irq(unsigned int irq) diff --git a/arch/m32r/kernel/setup_opsput.c b/arch/m32r/kernel/setup_opsput.c index 1fbb140..548e8fc 100644 --- a/arch/m32r/kernel/setup_opsput.c +++ b/arch/m32r/kernel/setup_opsput.c @@ -27,15 +27,7 @@ */ #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) -#ifndef CONFIG_SMP -typedef struct { - unsigned long icucr; /* ICU Control Register */ -} icu_data_t; -static icu_data_t icu_data[OPSPUT_NUM_CPU_IRQ]; -#else icu_data_t icu_data[OPSPUT_NUM_CPU_IRQ]; -#endif /* CONFIG_SMP */ - static void disable_opsput_irq(unsigned int irq) { diff --git a/arch/m32r/kernel/setup_usrv.c b/arch/m32r/kernel/setup_usrv.c index 634741b..64be659 100644 --- a/arch/m32r/kernel/setup_usrv.c +++ b/arch/m32r/kernel/setup_usrv.c @@ -18,12 +18,6 @@ #define irq2port(x) (M32R_ICU_CR1_PORTL + ((x - 1) * sizeof(unsigned long))) -#if !defined(CONFIG_SMP) -typedef struct { - unsigned long icucr; /* ICU Control Register */ -} icu_data_t; -#endif /* CONFIG_SMP */ - icu_data_t icu_data[M32700UT_NUM_CPU_IRQ]; static void disable_mappi_irq(unsigned int irq) diff --git a/include/asm-m32r/m32102.h b/include/asm-m32r/m32102.h index 0bd0a3f..a1f0d1f 100644 --- a/include/asm-m32r/m32102.h +++ b/include/asm-m32r/m32102.h @@ -302,15 +302,12 @@ #define M32R_FPGA_VERSION0_PORTL (0x30+M32R_FPGA_TOP) #define M32R_FPGA_VERSION1_PORTL (0x34+M32R_FPGA_TOP) +#endif /* CONFIG_SMP */ + #ifndef __ASSEMBLY__ -/* For NETDEV WATCHDOG */ typedef struct { unsigned long icucr; /* ICU Control Register */ } icu_data_t; - -extern icu_data_t icu_data[]; #endif -#endif /* CONFIG_SMP */ - #endif /* _M32102_H_ */ -- cgit v1.1 From 32588918254cff7c03651dcbd3d8cc2301aba5bd Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 6 Jan 2006 00:18:45 -0800 Subject: [PATCH] m68knommu: enable_irq/disable_irq mach_enable_irq/mach_disable_irq are never actually set, so let's remove them. Signed-off-by: Christoph Hellwig Cc: Greg Ungerer Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m68knommu/kernel/m68k_ksyms.c | 2 -- arch/m68knommu/kernel/setup.c | 2 -- include/asm-m68knommu/irq.h | 4 ++-- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/m68knommu/kernel/m68k_ksyms.c b/arch/m68knommu/kernel/m68k_ksyms.c index e93a5ad..b2c62ee 100644 --- a/arch/m68knommu/kernel/m68k_ksyms.c +++ b/arch/m68knommu/kernel/m68k_ksyms.c @@ -38,8 +38,6 @@ EXPORT_SYMBOL(strncmp); EXPORT_SYMBOL(ip_fast_csum); -EXPORT_SYMBOL(mach_enable_irq); -EXPORT_SYMBOL(mach_disable_irq); EXPORT_SYMBOL(kernel_thread); /* Networking helper routines. */ diff --git a/arch/m68knommu/kernel/setup.c b/arch/m68knommu/kernel/setup.c index abb80fa..93120b9 100644 --- a/arch/m68knommu/kernel/setup.c +++ b/arch/m68knommu/kernel/setup.c @@ -65,8 +65,6 @@ void (*mach_kbd_leds) (unsigned int) = NULL; /* machine dependent irq functions */ void (*mach_init_IRQ) (void) = NULL; irqreturn_t (*(*mach_default_handler)[]) (int, void *, struct pt_regs *) = NULL; -void (*mach_enable_irq) (unsigned int) = NULL; -void (*mach_disable_irq) (unsigned int) = NULL; int (*mach_get_irq_list) (struct seq_file *, void *) = NULL; void (*mach_process_int) (int irq, struct pt_regs *fp) = NULL; void (*mach_trap_init) (void); diff --git a/include/asm-m68knommu/irq.h b/include/asm-m68knommu/irq.h index a08fa9b..993046b 100644 --- a/include/asm-m68knommu/irq.h +++ b/include/asm-m68knommu/irq.h @@ -84,8 +84,8 @@ extern void (*mach_disable_irq)(unsigned int); /* * Some drivers want these entry points */ -#define enable_irq(x) (mach_enable_irq ? (*mach_enable_irq)(x) : 0) -#define disable_irq(x) (mach_disable_irq ? (*mach_disable_irq)(x) : 0) +#define enable_irq(x) 0 +#define disable_irq(x) do { } while (0) #define enable_irq_nosync(x) enable_irq(x) #define disable_irq_nosync(x) disable_irq(x) -- cgit v1.1 From b14a72d6cbf73443b975ffb04871e0ffb240df58 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 6 Jan 2006 00:18:46 -0800 Subject: [PATCH] m68knommu: remove enable_irq_nosync() m68k, m68knommu and h8300 define this, but it's not actually used anywhere. Signed-off-by: Christoph Hellwig Cc: Greg Ungerer Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/asm-h8300/irq.h | 5 ----- include/asm-m68k/irq.h | 2 -- include/asm-m68knommu/irq.h | 2 -- 3 files changed, 9 deletions(-) diff --git a/include/asm-h8300/irq.h b/include/asm-h8300/irq.h index 5027181..73065f5 100644 --- a/include/asm-h8300/irq.h +++ b/include/asm-h8300/irq.h @@ -61,11 +61,6 @@ static __inline__ int irq_canonicalize(int irq) extern void enable_irq(unsigned int); extern void disable_irq(unsigned int); - -/* - * Some drivers want these entry points - */ -#define enable_irq_nosync(x) enable_irq(x) #define disable_irq_nosync(x) disable_irq(x) struct irqaction; diff --git a/include/asm-m68k/irq.h b/include/asm-m68k/irq.h index 1f56990..127ad19 100644 --- a/include/asm-m68k/irq.h +++ b/include/asm-m68k/irq.h @@ -70,8 +70,6 @@ static __inline__ int irq_canonicalize(int irq) extern void (*enable_irq)(unsigned int); extern void (*disable_irq)(unsigned int); - -#define disable_irq_nosync disable_irq #define enable_irq_nosync enable_irq struct pt_regs; diff --git a/include/asm-m68knommu/irq.h b/include/asm-m68knommu/irq.h index 993046b..20c48ec 100644 --- a/include/asm-m68knommu/irq.h +++ b/include/asm-m68knommu/irq.h @@ -86,8 +86,6 @@ extern void (*mach_disable_irq)(unsigned int); */ #define enable_irq(x) 0 #define disable_irq(x) do { } while (0) - -#define enable_irq_nosync(x) enable_irq(x) #define disable_irq_nosync(x) disable_irq(x) struct irqaction; -- cgit v1.1 From 118c1f27b838c5d1cf5338dc5abff52ceb364826 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Fri, 6 Jan 2006 00:18:47 -0800 Subject: [PATCH] cris: kgdb: remove double_this() Doesn't make much sense and unused. Signed-off-by: Alexey Dobriyan Signed-off-by: Adrian Bunk Cc: Mikael Starvik Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/cris/arch-v10/kernel/kgdb.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/cris/arch-v10/kernel/kgdb.c b/arch/cris/arch-v10/kernel/kgdb.c index b72e6a9..34528da 100644 --- a/arch/cris/arch-v10/kernel/kgdb.c +++ b/arch/cris/arch-v10/kernel/kgdb.c @@ -569,12 +569,6 @@ gdb_cris_strtol (const char *s, char **endptr, int base) return x; } -int -double_this(int x) -{ - return 2 * x; -} - /********************************* Register image ****************************/ /* Copy the content of a register image into another. The size n is the size of the register image. Due to struct assignment generation of -- cgit v1.1 From 970d6e3a3461ebc62bc3fc6d4962c936cb2ed97c Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:48 -0800 Subject: [PATCH] uml: use kstrdup There were a bunch of calls to uml_strdup dating from before kstrdup was introduced. This changes those calls. It doesn't eliminate the definition since there is still a couple of calls in userspace code (which should probably call the libc strdup). Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/line.c | 10 +++++----- arch/um/drivers/mconsole_kern.c | 2 +- arch/um/drivers/net_kern.c | 2 +- arch/um/drivers/ubd_kern.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index e0fdffa..c31fc54 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -562,10 +562,11 @@ int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed int line_config(struct line *lines, unsigned int num, char *str) { - char *new = uml_strdup(str); + char *new; + new = kstrdup(str, GFP_KERNEL); if(new == NULL){ - printk("line_config - uml_strdup failed\n"); + printk("line_config - kstrdup failed\n"); return -ENOMEM; } return !line_setup(lines, num, new, 0); @@ -677,10 +678,9 @@ void lines_init(struct line *lines, int nlines) INIT_LIST_HEAD(&line->chan_list); spin_lock_init(&line->lock); if(line->init_str != NULL){ - line->init_str = uml_strdup(line->init_str); + line->init_str = kstrdup(line->init_str, GFP_KERNEL); if(line->init_str == NULL) - printk("lines_init - uml_strdup returned " - "NULL\n"); + printk("lines_init - kstrdup returned NULL\n"); } } } diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index 12c9536..b367864 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -563,7 +563,7 @@ int mconsole_init(void) } if(notify_socket != NULL){ - notify_socket = uml_strdup(notify_socket); + notify_socket = kstrdup(notify_socket, GFP_KERNEL); if(notify_socket != NULL) mconsole_notify(notify_socket, MCONSOLE_SOCKET, mconsole_socket_name, diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 84c73a3..29785f6 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c @@ -586,7 +586,7 @@ static int net_config(char *str) err = eth_parse(str, &n, &str); if(err) return(err); - str = uml_strdup(str); + str = kstrdup(str, GFP_KERNEL); if(str == NULL){ printk(KERN_ERR "net_config failed to strdup string\n"); return(-1); diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 9389891..1fe0dcd 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -706,7 +706,7 @@ static int ubd_config(char *str) { int n, err; - str = uml_strdup(str); + str = kstrdup(str, GFP_KERNEL); if(str == NULL){ printk(KERN_ERR "ubd_config failed to strdup string\n"); return(1); -- cgit v1.1 From 1b57e9c27882a908f180d4daf72ee12c6f137178 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:49 -0800 Subject: [PATCH] uml: non-void functions should return something There are a few functions which are declared to return something, but don't. These are actually infinite loops which are forced to be declared as non-void. This makes them all return 0. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/ubd_kern.c | 13 ++----------- arch/um/kernel/sigio_user.c | 2 ++ arch/um/os-Linux/aio.c | 2 ++ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 1fe0dcd..73f9652 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -1387,15 +1387,6 @@ int io_thread(void *arg) printk("io_thread - write failed, fd = %d, err = %d\n", kernel_fd, -n); } -} -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ + return 0; +} diff --git a/arch/um/kernel/sigio_user.c b/arch/um/kernel/sigio_user.c index 48b1f64..62e5cfd 100644 --- a/arch/um/kernel/sigio_user.c +++ b/arch/um/kernel/sigio_user.c @@ -216,6 +216,8 @@ static int write_sigio_thread(void *unused) "err = %d\n", -n); } } + + return 0; } static int need_poll(int n) diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c index ffa759a..0b78bb7 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c @@ -210,6 +210,8 @@ static int not_aio_thread(void *arg) printk("not_aio_thread - write failed, fd = %d, " "err = %d\n", aio_req_fd_r, -err); } + + return 0; } static int aio_pid = -1; -- cgit v1.1 From d50084a2991f3d9490d5c0f3af72e6fe1515a493 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:50 -0800 Subject: [PATCH] uml: Formatting changes This patch makes a bunch of non-functional changes - return(foo); becomes return foo; some statements are broken across lines for readability some trailing whitespace is cleaned up open_one_chan took four arguments, three of which could be deduced from the first. Accordingly, they were eliminated. some examples of "} else {" had a newline added some whitespace cleanup in the indentation lines_init got some control flow cleanup some long lines were broken removed another emacs-specific C formatting comment Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/chan_kern.c | 124 ++++++----- arch/um/drivers/line.c | 47 ++-- arch/um/drivers/mconsole_kern.c | 25 ++- arch/um/drivers/ssl.c | 29 +-- arch/um/drivers/stdio_console.c | 26 +-- arch/um/include/chan_kern.h | 11 - arch/um/include/line.h | 22 +- arch/um/os-Linux/aio.c | 465 ++++++++++++++++++++-------------------- 8 files changed, 381 insertions(+), 368 deletions(-) diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 5b58fad..8b1262e 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -58,7 +58,7 @@ static void *not_configged_init(char *str, int device, struct chan_opts *opts) { my_puts("Using a channel type which is configured out of " "UML\n"); - return(NULL); + return NULL; } static int not_configged_open(int input, int output, int primary, void *data, @@ -66,7 +66,7 @@ static int not_configged_open(int input, int output, int primary, void *data, { my_puts("Using a channel type which is configured out of " "UML\n"); - return(-ENODEV); + return -ENODEV; } static void not_configged_close(int fd, void *data) @@ -79,21 +79,21 @@ static int not_configged_read(int fd, char *c_out, void *data) { my_puts("Using a channel type which is configured out of " "UML\n"); - return(-EIO); + return -EIO; } static int not_configged_write(int fd, const char *buf, int len, void *data) { my_puts("Using a channel type which is configured out of " "UML\n"); - return(-EIO); + return -EIO; } static int not_configged_console_write(int fd, const char *buf, int len) { my_puts("Using a channel type which is configured out of " "UML\n"); - return(-EIO); + return -EIO; } static int not_configged_window_size(int fd, void *data, unsigned short *rows, @@ -101,7 +101,7 @@ static int not_configged_window_size(int fd, void *data, unsigned short *rows, { my_puts("Using a channel type which is configured out of " "UML\n"); - return(-ENODEV); + return -ENODEV; } static void not_configged_free(void *data) @@ -135,17 +135,17 @@ int generic_read(int fd, char *c_out, void *unused) n = os_read_file(fd, c_out, sizeof(*c_out)); if(n == -EAGAIN) - return(0); + return 0; else if(n == 0) - return(-EIO); - return(n); + return -EIO; + return n; } /* XXX Trivial wrapper around os_write_file */ int generic_write(int fd, const char *buf, int n, void *unused) { - return(os_write_file(fd, buf, n)); + return os_write_file(fd, buf, n); } int generic_window_size(int fd, void *unused, unsigned short *rows_out, @@ -156,14 +156,14 @@ int generic_window_size(int fd, void *unused, unsigned short *rows_out, ret = os_window_size(fd, &rows, &cols); if(ret < 0) - return(ret); + return ret; ret = ((*rows_out != rows) || (*cols_out != cols)); *rows_out = rows; *cols_out = cols; - return(ret); + return ret; } void generic_free(void *data) @@ -186,25 +186,29 @@ static void tty_receive_char(struct tty_struct *tty, char ch) } } - if((tty->flip.flag_buf_ptr == NULL) || + if((tty->flip.flag_buf_ptr == NULL) || (tty->flip.char_buf_ptr == NULL)) return; tty_insert_flip_char(tty, ch, TTY_NORMAL); } -static int open_one_chan(struct chan *chan, int input, int output, int primary) +static int open_one_chan(struct chan *chan) { int fd; - if(chan->opened) return(0); - if(chan->ops->open == NULL) fd = 0; - else fd = (*chan->ops->open)(input, output, primary, chan->data, - &chan->dev); - if(fd < 0) return(fd); + if(chan->opened) + return 0; + + if(chan->ops->open == NULL) + fd = 0; + else fd = (*chan->ops->open)(chan->input, chan->output, chan->primary, + chan->data, &chan->dev); + if(fd < 0) + return fd; chan->fd = fd; chan->opened = 1; - return(0); + return 0; } int open_chan(struct list_head *chans) @@ -215,11 +219,11 @@ int open_chan(struct list_head *chans) list_for_each(ele, chans){ chan = list_entry(ele, struct chan, list); - ret = open_one_chan(chan, chan->input, chan->output, - chan->primary); - if(chan->primary) err = ret; + ret = open_one_chan(chan); + if(chan->primary) + err = ret; } - return(err); + return err; } void chan_enable_winch(struct list_head *chans, struct tty_struct *tty) @@ -267,7 +271,7 @@ void close_chan(struct list_head *chans) } } -int write_chan(struct list_head *chans, const char *buf, int len, +int write_chan(struct list_head *chans, const char *buf, int len, int write_irq) { struct list_head *ele; @@ -285,7 +289,7 @@ int write_chan(struct list_head *chans, const char *buf, int len, reactivate_fd(chan->fd, write_irq); } } - return(ret); + return ret; } int console_write_chan(struct list_head *chans, const char *buf, int len) @@ -301,10 +305,11 @@ int console_write_chan(struct list_head *chans, const char *buf, int len) n = chan->ops->console_write(chan->fd, buf, len); if(chan->primary) ret = n; } - return(ret); + return ret; } -int console_open_chan(struct line *line, struct console *co, struct chan_opts *opts) +int console_open_chan(struct line *line, struct console *co, + struct chan_opts *opts) { if (!list_empty(&line->chan_list)) return 0; @@ -327,12 +332,13 @@ int chan_window_size(struct list_head *chans, unsigned short *rows_out, list_for_each(ele, chans){ chan = list_entry(ele, struct chan, list); if(chan->primary){ - if(chan->ops->window_size == NULL) return(0); - return(chan->ops->window_size(chan->fd, chan->data, - rows_out, cols_out)); + if(chan->ops->window_size == NULL) + return 0; + return chan->ops->window_size(chan->fd, chan->data, + rows_out, cols_out); } } - return(0); + return 0; } void free_one_chan(struct chan *chan) @@ -363,23 +369,23 @@ static int one_chan_config_string(struct chan *chan, char *str, int size, if(chan == NULL){ CONFIG_CHUNK(str, size, n, "none", 1); - return(n); + return n; } CONFIG_CHUNK(str, size, n, chan->ops->type, 0); if(chan->dev == NULL){ CONFIG_CHUNK(str, size, n, "", 1); - return(n); + return n; } CONFIG_CHUNK(str, size, n, ":", 0); CONFIG_CHUNK(str, size, n, chan->dev, 0); - return(n); + return n; } -static int chan_pair_config_string(struct chan *in, struct chan *out, +static int chan_pair_config_string(struct chan *in, struct chan *out, char *str, int size, char **error_out) { int n; @@ -390,7 +396,7 @@ static int chan_pair_config_string(struct chan *in, struct chan *out, if(in == out){ CONFIG_CHUNK(str, size, n, "", 1); - return(n); + return n; } CONFIG_CHUNK(str, size, n, ",", 1); @@ -399,10 +405,10 @@ static int chan_pair_config_string(struct chan *in, struct chan *out, size -= n; CONFIG_CHUNK(str, size, n, "", 1); - return(n); + return n; } -int chan_config_string(struct list_head *chans, char *str, int size, +int chan_config_string(struct list_head *chans, char *str, int size, char **error_out) { struct list_head *ele; @@ -418,7 +424,7 @@ int chan_config_string(struct list_head *chans, char *str, int size, out = chan; } - return(chan_pair_config_string(in, out, str, size, error_out)); + return chan_pair_config_string(in, out, str, size, error_out); } struct chan_type { @@ -462,7 +468,7 @@ struct chan_type chan_table[] = { #endif }; -static struct chan *parse_chan(char *str, int pri, int device, +static struct chan *parse_chan(char *str, int pri, int device, struct chan_opts *opts) { struct chan_type *entry; @@ -484,14 +490,17 @@ static struct chan *parse_chan(char *str, int pri, int device, if(ops == NULL){ my_printf("parse_chan couldn't parse \"%s\"\n", str); - return(NULL); + return NULL; } - if(ops->init == NULL) return(NULL); + if(ops->init == NULL) + return NULL; data = (*ops->init)(str, device, opts); - if(data == NULL) return(NULL); + if(data == NULL) + return NULL; chan = kmalloc(sizeof(*chan), GFP_ATOMIC); - if(chan == NULL) return(NULL); + if(chan == NULL) + return NULL; *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list), .primary = 1, .input = 0, @@ -501,7 +510,7 @@ static struct chan *parse_chan(char *str, int pri, int device, .pri = pri, .ops = ops, .data = data }); - return(chan); + return chan; } int parse_chan_pair(char *str, struct list_head *chans, int pri, int device, @@ -512,7 +521,8 @@ int parse_chan_pair(char *str, struct list_head *chans, int pri, int device, if(!list_empty(chans)){ chan = list_entry(chans->next, struct chan, list); - if(chan->pri >= pri) return(0); + if(chan->pri >= pri) + return 0; free_chan(chans); INIT_LIST_HEAD(chans); } @@ -523,23 +533,29 @@ int parse_chan_pair(char *str, struct list_head *chans, int pri, int device, *out = '\0'; out++; new = parse_chan(in, pri, device, opts); - if(new == NULL) return(-1); + if(new == NULL) + return -1; + new->input = 1; list_add(&new->list, chans); new = parse_chan(out, pri, device, opts); - if(new == NULL) return(-1); + if(new == NULL) + return -1; + list_add(&new->list, chans); new->output = 1; } else { new = parse_chan(str, pri, device, opts); - if(new == NULL) return(-1); + if(new == NULL) + return -1; + list_add(&new->list, chans); new->input = 1; new->output = 1; } - return(0); + return 0; } int chan_out_fd(struct list_head *chans) @@ -550,9 +566,9 @@ int chan_out_fd(struct list_head *chans) list_for_each(ele, chans){ chan = list_entry(ele, struct chan, list); if(chan->primary && chan->output) - return(chan->fd); + return chan->fd; } - return(-1); + return -1; } void chan_interrupt(struct list_head *chans, struct work_struct *task, @@ -567,7 +583,7 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task, chan = list_entry(ele, struct chan, list); if(!chan->input || (chan->ops->read == NULL)) continue; do { - if((tty != NULL) && + if((tty != NULL) && (tty->flip.count >= TTY_FLIPBUF_SIZE)){ schedule_work(task); goto out; diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index c31fc54..2ee00cb 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -124,7 +124,8 @@ static int buffer_data(struct line *line, const char *buf, int len) if (len < end){ memcpy(line->tail, buf, len); line->tail += len; - } else { + } + else { /* The circular buffer is wrapping */ memcpy(line->tail, buf, end); buf += end; @@ -170,7 +171,7 @@ static int flush_buffer(struct line *line) } count = line->tail - line->head; - n = write_chan(&line->chan_list, line->head, count, + n = write_chan(&line->chan_list, line->head, count, line->driver->write_irq); if(n < 0) @@ -227,7 +228,7 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len) if (err <= 0 && (err != -EAGAIN || !ret)) ret = err; } else { - n = write_chan(&line->chan_list, buf, len, + n = write_chan(&line->chan_list, buf, len, line->driver->write_irq); if (n < 0) { ret = n; @@ -384,13 +385,13 @@ int line_setup_irq(int fd, int input, int output, struct tty_struct *tty) if (input) err = um_request_irq(driver->read_irq, fd, IRQ_READ, - line_interrupt, flags, + line_interrupt, flags, driver->read_irq_name, tty); if (err) return err; if (output) err = um_request_irq(driver->write_irq, fd, IRQ_WRITE, - line_write_interrupt, flags, + line_write_interrupt, flags, driver->write_irq_name, tty); line->have_irq = 1; return err; @@ -512,10 +513,11 @@ int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed /* We said con=/ssl= instead of con#=, so we are configuring all * consoles at once.*/ n = -1; - } else { + } + else { n = simple_strtoul(init, &end, 0); if(*end != '='){ - printk(KERN_ERR "line_setup failed to parse \"%s\"\n", + printk(KERN_ERR "line_setup failed to parse \"%s\"\n", init); return 0; } @@ -527,7 +529,8 @@ int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed printk("line_setup - %d out of range ((0 ... %d) allowed)\n", n, num - 1); return 0; - } else if (n >= 0){ + } + else if (n >= 0){ if (lines[n].count > 0) { printk("line_setup - device %d is open\n", n); return 0; @@ -541,11 +544,13 @@ int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed lines[n].valid = 1; } } - } else if(!all_allowed){ + } + else if(!all_allowed){ printk("line_setup - can't configure all devices from " "mconsole\n"); return 0; - } else { + } + else { for(i = 0; i < num; i++){ if(lines[i].init_pri <= INIT_ALL){ lines[i].init_pri = INIT_ALL; @@ -627,7 +632,7 @@ int line_remove(struct line *lines, unsigned int num, int n) } struct tty_driver *line_register_devfs(struct lines *set, - struct line_driver *line_driver, + struct line_driver *line_driver, struct tty_operations *ops, struct line *lines, int nlines) { @@ -656,7 +661,7 @@ struct tty_driver *line_register_devfs(struct lines *set, } for(i = 0; i < nlines; i++){ - if(!lines[i].valid) + if(!lines[i].valid) tty_unregister_device(driver, i); } @@ -677,11 +682,12 @@ void lines_init(struct line *lines, int nlines) line = &lines[i]; INIT_LIST_HEAD(&line->chan_list); spin_lock_init(&line->lock); - if(line->init_str != NULL){ - line->init_str = kstrdup(line->init_str, GFP_KERNEL); - if(line->init_str == NULL) - printk("lines_init - kstrdup returned NULL\n"); - } + if(line->init_str == NULL) + continue; + + line->init_str = kstrdup(line->init_str, GFP_KERNEL); + if(line->init_str == NULL) + printk("lines_init - kstrdup returned NULL\n"); } } @@ -717,8 +723,7 @@ irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused) tty = winch->tty; if (tty != NULL) { line = tty->driver_data; - chan_window_size(&line->chan_list, - &tty->winsize.ws_row, + chan_window_size(&line->chan_list, &tty->winsize.ws_row, &tty->winsize.ws_col); kill_pg(tty->pgrp, SIGWINCH, 1); } @@ -749,7 +754,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty) spin_unlock(&winch_handler_lock); if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, - SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, + SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, "winch", winch) < 0) printk("register_winch_irq - failed to register IRQ\n"); } @@ -800,7 +805,7 @@ static void winch_cleanup(void) deactivate_fd(winch->fd, WINCH_IRQ); os_close_file(winch->fd); } - if(winch->pid != -1) + if(winch->pid != -1) os_kill_process(winch->pid, 1); } } diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index b367864..355866a 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -34,7 +34,7 @@ #include "irq_kern.h" #include "choose-mode.h" -static int do_unlink_socket(struct notifier_block *notifier, +static int do_unlink_socket(struct notifier_block *notifier, unsigned long what, void *data) { return(mconsole_unlink_socket()); @@ -46,7 +46,7 @@ static struct notifier_block reboot_notifier = { .priority = 0, }; -/* Safe without explicit locking for now. Tasklets provide their own +/* Safe without explicit locking for now. Tasklets provide their own * locking, and the interrupt handler is safe because it can't interrupt * itself and it can only happen on CPU 0. */ @@ -60,7 +60,7 @@ static void mc_work_proc(void *unused) while(!list_empty(&mc_requests)){ local_save_flags(flags); - req = list_entry(mc_requests.next, struct mconsole_entry, + req = list_entry(mc_requests.next, struct mconsole_entry, list); list_del(&req->list); local_irq_restore(flags); @@ -103,8 +103,8 @@ void mconsole_version(struct mc_request *req) { char version[256]; - sprintf(version, "%s %s %s %s %s", system_utsname.sysname, - system_utsname.nodename, system_utsname.release, + sprintf(version, "%s %s %s %s %s", system_utsname.sysname, + system_utsname.nodename, system_utsname.release, system_utsname.version, system_utsname.machine); mconsole_reply(req, version, 0, 0); } @@ -348,7 +348,7 @@ static struct mc_device *mconsole_find_dev(char *name) #define CONFIG_BUF_SIZE 64 -static void mconsole_get_config(int (*get_config)(char *, char *, int, +static void mconsole_get_config(int (*get_config)(char *, char *, int, char **), struct mc_request *req, char *name) { @@ -389,7 +389,6 @@ static void mconsole_get_config(int (*get_config)(char *, char *, int, out: if(buf != default_buf) kfree(buf); - } void mconsole_config(struct mc_request *req) @@ -420,7 +419,7 @@ void mconsole_config(struct mc_request *req) void mconsole_remove(struct mc_request *req) { - struct mc_device *dev; + struct mc_device *dev; char *ptr = req->request.data, *err_msg = ""; char error[256]; int err, start, end, n; @@ -534,7 +533,7 @@ void mconsole_stack(struct mc_request *req) /* Changed by mconsole_setup, which is __setup, and called before SMP is * active. */ -static char *notify_socket = NULL; +static char *notify_socket = NULL; int mconsole_init(void) { @@ -566,13 +565,13 @@ int mconsole_init(void) notify_socket = kstrdup(notify_socket, GFP_KERNEL); if(notify_socket != NULL) mconsole_notify(notify_socket, MCONSOLE_SOCKET, - mconsole_socket_name, + mconsole_socket_name, strlen(mconsole_socket_name) + 1); else printk(KERN_ERR "mconsole_setup failed to strdup " "string\n"); } - printk("mconsole (version %d) initialized on %s\n", + printk("mconsole (version %d) initialized on %s\n", MCONSOLE_VERSION, mconsole_socket_name); return(0); } @@ -585,7 +584,7 @@ static int write_proc_mconsole(struct file *file, const char __user *buffer, char *buf; buf = kmalloc(count + 1, GFP_KERNEL); - if(buf == NULL) + if(buf == NULL) return(-ENOMEM); if(copy_from_user(buf, buffer, count)){ @@ -661,7 +660,7 @@ static int notify_panic(struct notifier_block *self, unsigned long unused1, if(notify_socket == NULL) return(0); - mconsole_notify(notify_socket, MCONSOLE_PANIC, message, + mconsole_notify(notify_socket, MCONSOLE_PANIC, message, strlen(message) + 1); return(0); } diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 62e04ec..95a3eaa 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -69,7 +69,7 @@ static struct line_driver driver = { .name = "ssl", .config = ssl_config, .get_config = ssl_get_config, - .id = line_id, + .id = line_id, .remove = ssl_remove, }, }; @@ -84,21 +84,21 @@ static struct lines lines = LINES_INIT(NR_PORTS); static int ssl_config(char *str) { - return(line_config(serial_lines, - sizeof(serial_lines)/sizeof(serial_lines[0]), str)); + return line_config(serial_lines, + sizeof(serial_lines)/sizeof(serial_lines[0]), str); } static int ssl_get_config(char *dev, char *str, int size, char **error_out) { - return(line_get_config(dev, serial_lines, - sizeof(serial_lines)/sizeof(serial_lines[0]), - str, size, error_out)); + return line_get_config(dev, serial_lines, + sizeof(serial_lines)/sizeof(serial_lines[0]), + str, size, error_out); } static int ssl_remove(int n) { - return line_remove(serial_lines, - sizeof(serial_lines)/sizeof(serial_lines[0]), n); + return line_remove(serial_lines, + sizeof(serial_lines)/sizeof(serial_lines[0]), n); } int ssl_open(struct tty_struct *tty, struct file *filp) @@ -183,7 +183,7 @@ static int ssl_console_setup(struct console *co, char *options) { struct line *line = &serial_lines[co->index]; - return console_open_chan(line,co,&opts); + return console_open_chan(line, co, &opts); } static struct console ssl_cons = { @@ -199,10 +199,11 @@ int ssl_init(void) { char *new_title; - printk(KERN_INFO "Initializing software serial port version %d\n", + printk(KERN_INFO "Initializing software serial port version %d\n", ssl_version); ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops, - serial_lines, ARRAY_SIZE(serial_lines)); + serial_lines, + ARRAY_SIZE(serial_lines)); lines_init(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0])); @@ -212,7 +213,7 @@ int ssl_init(void) ssl_init_done = 1; register_console(&ssl_cons); - return(0); + return 0; } late_initcall(ssl_init); @@ -227,9 +228,9 @@ __uml_exitcall(ssl_exit); static int ssl_chan_setup(char *str) { - return(line_setup(serial_lines, + return line_setup(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]), - str, 1)); + str, 1); } __setup("ssl", ssl_chan_setup); diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 005aa63..8f3b168 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -75,7 +75,7 @@ static struct line_driver driver = { .name = "con", .config = con_config, .get_config = con_get_config, - .id = line_id, + .id = line_id, .remove = con_remove, }, }; @@ -86,23 +86,23 @@ static struct lines console_lines = LINES_INIT(MAX_TTYS); * individual elements are protected by individual semaphores. */ struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver), - [ 1 ... MAX_TTYS - 1 ] = + [ 1 ... MAX_TTYS - 1 ] = LINE_INIT(CONFIG_CON_CHAN, &driver) }; static int con_config(char *str) { - return(line_config(vts, sizeof(vts)/sizeof(vts[0]), str)); + return line_config(vts, sizeof(vts)/sizeof(vts[0]), str); } static int con_get_config(char *dev, char *str, int size, char **error_out) { - return(line_get_config(dev, vts, sizeof(vts)/sizeof(vts[0]), str, - size, error_out)); + return line_get_config(dev, vts, sizeof(vts)/sizeof(vts[0]), str, + size, error_out); } static int con_remove(int n) { - return line_remove(vts, sizeof(vts)/sizeof(vts[0]), n); + return line_remove(vts, sizeof(vts)/sizeof(vts[0]), n); } static int con_open(struct tty_struct *tty, struct file *filp) @@ -117,7 +117,7 @@ static struct tty_operations console_ops = { .close = line_close, .write = line_write, .put_char = line_put_char, - .write_room = line_write_room, + .write_room = line_write_room, .chars_in_buffer = line_chars_in_buffer, .flush_buffer = line_flush_buffer, .flush_chars = line_flush_chars, @@ -126,7 +126,7 @@ static struct tty_operations console_ops = { }; static void uml_console_write(struct console *console, const char *string, - unsigned len) + unsigned len) { struct line *line = &vts[console->index]; unsigned long flags; @@ -146,7 +146,7 @@ static int uml_console_setup(struct console *co, char *options) { struct line *line = &vts[co->index]; - return console_open_chan(line,co,&opts); + return console_open_chan(line, co, &opts); } static struct console stdiocons = { @@ -156,7 +156,7 @@ static struct console stdiocons = { .setup = uml_console_setup, .flags = CON_PRINTBUFFER, .index = -1, - .data = &vts, + .data = &vts, }; int stdio_init(void) @@ -166,7 +166,7 @@ int stdio_init(void) console_driver = line_register_devfs(&console_lines, &driver, &console_ops, vts, ARRAY_SIZE(vts)); - if (NULL == console_driver) + if (console_driver == NULL) return -1; printk(KERN_INFO "Initialized stdio console driver\n"); @@ -178,7 +178,7 @@ int stdio_init(void) con_init_done = 1; register_console(&stdiocons); - return(0); + return 0; } late_initcall(stdio_init); @@ -192,7 +192,7 @@ __uml_exitcall(console_exit); static int console_chan_setup(char *str) { - return(line_setup(vts, sizeof(vts)/sizeof(vts[0]), str, 1)); + return line_setup(vts, sizeof(vts)/sizeof(vts[0]), str, 1); } __setup("con", console_chan_setup); __channel_help(console_chan_setup, "con"); diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h index da9a671..9ac0691 100644 --- a/arch/um/include/chan_kern.h +++ b/arch/um/include/chan_kern.h @@ -47,14 +47,3 @@ extern int chan_config_string(struct list_head *chans, char *str, int size, char **error_out); #endif - -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ diff --git a/arch/um/include/line.h b/arch/um/include/line.h index 5323d22..315788c 100644 --- a/arch/um/include/line.h +++ b/arch/um/include/line.h @@ -64,8 +64,8 @@ struct line { head : NULL, \ tail : NULL, \ sigio : 0, \ - driver : d, \ - have_irq : 0 } + driver : d, \ + have_irq : 0 } struct lines { int num; @@ -74,11 +74,12 @@ struct lines { #define LINES_INIT(n) { num : n } extern void line_close(struct tty_struct *tty, struct file * filp); -extern int line_open(struct line *lines, struct tty_struct *tty, +extern int line_open(struct line *lines, struct tty_struct *tty, struct chan_opts *opts); extern int line_setup(struct line *lines, unsigned int sizeof_lines, char *init, int all_allowed); -extern int line_write(struct tty_struct *tty, const unsigned char *buf, int len); +extern int line_write(struct tty_struct *tty, const unsigned char *buf, + int len); extern void line_put_char(struct tty_struct *tty, unsigned char ch); extern void line_set_termios(struct tty_struct *tty, struct termios * old); extern int line_chars_in_buffer(struct tty_struct *tty); @@ -89,21 +90,24 @@ extern int line_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); extern char *add_xterm_umid(char *base); -extern int line_setup_irq(int fd, int input, int output, struct tty_struct *tty); +extern int line_setup_irq(int fd, int input, int output, + struct tty_struct *tty); extern void line_close_chan(struct line *line); extern void line_disable(struct tty_struct *tty, int current_irq); -extern struct tty_driver * line_register_devfs(struct lines *set, - struct line_driver *line_driver, +extern struct tty_driver * line_register_devfs(struct lines *set, + struct line_driver *line_driver, struct tty_operations *driver, struct line *lines, int nlines); extern void lines_init(struct line *lines, int nlines); extern void close_lines(struct line *lines, int nlines); -extern int line_config(struct line *lines, unsigned int sizeof_lines, char *str); +extern int line_config(struct line *lines, unsigned int sizeof_lines, + char *str); extern int line_id(char **str, int *start_out, int *end_out); extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n); -extern int line_get_config(char *dev, struct line *lines, unsigned int sizeof_lines, char *str, +extern int line_get_config(char *dev, struct line *lines, + unsigned int sizeof_lines, char *str, int size, char **error_out); #endif diff --git a/arch/um/os-Linux/aio.c b/arch/um/os-Linux/aio.c index 0b78bb7..f897140 100644 --- a/arch/um/os-Linux/aio.c +++ b/arch/um/os-Linux/aio.c @@ -16,12 +16,12 @@ #include "mode.h" struct aio_thread_req { - enum aio_type type; - int io_fd; - unsigned long long offset; - char *buf; - int len; - struct aio_context *aio; + enum aio_type type; + int io_fd; + unsigned long long offset; + char *buf; + int len; + struct aio_context *aio; }; static int aio_req_fd_r = -1; @@ -38,18 +38,18 @@ static int aio_req_fd_w = -1; static long io_setup(int n, aio_context_t *ctxp) { - return syscall(__NR_io_setup, n, ctxp); + return syscall(__NR_io_setup, n, ctxp); } static long io_submit(aio_context_t ctx, long nr, struct iocb **iocbpp) { - return syscall(__NR_io_submit, ctx, nr, iocbpp); + return syscall(__NR_io_submit, ctx, nr, iocbpp); } static long io_getevents(aio_context_t ctx_id, long min_nr, long nr, - struct io_event *events, struct timespec *timeout) + struct io_event *events, struct timespec *timeout) { - return syscall(__NR_io_getevents, ctx_id, min_nr, nr, events, timeout); + return syscall(__NR_io_getevents, ctx_id, min_nr, nr, events, timeout); } #endif @@ -66,150 +66,150 @@ static long io_getevents(aio_context_t ctx_id, long min_nr, long nr, */ static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf, - int len, unsigned long long offset, struct aio_context *aio) + int len, unsigned long long offset, struct aio_context *aio) { - struct iocb iocb, *iocbp = &iocb; - char c; - int err; - - iocb = ((struct iocb) { .aio_data = (unsigned long) aio, - .aio_reqprio = 0, - .aio_fildes = fd, - .aio_buf = (unsigned long) buf, - .aio_nbytes = len, - .aio_offset = offset, - .aio_reserved1 = 0, - .aio_reserved2 = 0, - .aio_reserved3 = 0 }); - - switch(type){ - case AIO_READ: - iocb.aio_lio_opcode = IOCB_CMD_PREAD; - err = io_submit(ctx, 1, &iocbp); - break; - case AIO_WRITE: - iocb.aio_lio_opcode = IOCB_CMD_PWRITE; - err = io_submit(ctx, 1, &iocbp); - break; - case AIO_MMAP: - iocb.aio_lio_opcode = IOCB_CMD_PREAD; - iocb.aio_buf = (unsigned long) &c; - iocb.aio_nbytes = sizeof(c); - err = io_submit(ctx, 1, &iocbp); - break; - default: - printk("Bogus op in do_aio - %d\n", type); - err = -EINVAL; - break; - } - - if(err > 0) - err = 0; + struct iocb iocb, *iocbp = &iocb; + char c; + int err; + + iocb = ((struct iocb) { .aio_data = (unsigned long) aio, + .aio_reqprio = 0, + .aio_fildes = fd, + .aio_buf = (unsigned long) buf, + .aio_nbytes = len, + .aio_offset = offset, + .aio_reserved1 = 0, + .aio_reserved2 = 0, + .aio_reserved3 = 0 }); + + switch(type){ + case AIO_READ: + iocb.aio_lio_opcode = IOCB_CMD_PREAD; + err = io_submit(ctx, 1, &iocbp); + break; + case AIO_WRITE: + iocb.aio_lio_opcode = IOCB_CMD_PWRITE; + err = io_submit(ctx, 1, &iocbp); + break; + case AIO_MMAP: + iocb.aio_lio_opcode = IOCB_CMD_PREAD; + iocb.aio_buf = (unsigned long) &c; + iocb.aio_nbytes = sizeof(c); + err = io_submit(ctx, 1, &iocbp); + break; + default: + printk("Bogus op in do_aio - %d\n", type); + err = -EINVAL; + break; + } + + if(err > 0) + err = 0; else err = -errno; - return err; + return err; } static aio_context_t ctx = 0; static int aio_thread(void *arg) { - struct aio_thread_reply reply; - struct io_event event; - int err, n, reply_fd; - - signal(SIGWINCH, SIG_IGN); - - while(1){ - n = io_getevents(ctx, 1, 1, &event, NULL); - if(n < 0){ - if(errno == EINTR) - continue; - printk("aio_thread - io_getevents failed, " - "errno = %d\n", errno); - } - else { - reply = ((struct aio_thread_reply) - { .data = (void *) (long) event.data, - .err = event.res }); + struct aio_thread_reply reply; + struct io_event event; + int err, n, reply_fd; + + signal(SIGWINCH, SIG_IGN); + + while(1){ + n = io_getevents(ctx, 1, 1, &event, NULL); + if(n < 0){ + if(errno == EINTR) + continue; + printk("aio_thread - io_getevents failed, " + "errno = %d\n", errno); + } + else { + reply = ((struct aio_thread_reply) + { .data = (void *) (long) event.data, + .err = event.res }); reply_fd = ((struct aio_context *) reply.data)->reply_fd; err = os_write_file(reply_fd, &reply, sizeof(reply)); - if(err != sizeof(reply)) + if(err != sizeof(reply)) printk("aio_thread - write failed, fd = %d, " - "err = %d\n", aio_req_fd_r, -err); - } - } - return 0; + "err = %d\n", aio_req_fd_r, -err); + } + } + return 0; } #endif static int do_not_aio(struct aio_thread_req *req) { - char c; - int err; - - switch(req->type){ - case AIO_READ: - err = os_seek_file(req->io_fd, req->offset); - if(err) - goto out; - - err = os_read_file(req->io_fd, req->buf, req->len); - break; - case AIO_WRITE: - err = os_seek_file(req->io_fd, req->offset); - if(err) - goto out; - - err = os_write_file(req->io_fd, req->buf, req->len); - break; - case AIO_MMAP: - err = os_seek_file(req->io_fd, req->offset); - if(err) - goto out; - - err = os_read_file(req->io_fd, &c, sizeof(c)); - break; - default: - printk("do_not_aio - bad request type : %d\n", req->type); - err = -EINVAL; - break; - } - - out: - return err; + char c; + int err; + + switch(req->type){ + case AIO_READ: + err = os_seek_file(req->io_fd, req->offset); + if(err) + goto out; + + err = os_read_file(req->io_fd, req->buf, req->len); + break; + case AIO_WRITE: + err = os_seek_file(req->io_fd, req->offset); + if(err) + goto out; + + err = os_write_file(req->io_fd, req->buf, req->len); + break; + case AIO_MMAP: + err = os_seek_file(req->io_fd, req->offset); + if(err) + goto out; + + err = os_read_file(req->io_fd, &c, sizeof(c)); + break; + default: + printk("do_not_aio - bad request type : %d\n", req->type); + err = -EINVAL; + break; + } + +out: + return err; } static int not_aio_thread(void *arg) { - struct aio_thread_req req; - struct aio_thread_reply reply; - int err; - - signal(SIGWINCH, SIG_IGN); - while(1){ - err = os_read_file(aio_req_fd_r, &req, sizeof(req)); - if(err != sizeof(req)){ - if(err < 0) - printk("not_aio_thread - read failed, " - "fd = %d, err = %d\n", aio_req_fd_r, - -err); - else { - printk("not_aio_thread - short read, fd = %d, " - "length = %d\n", aio_req_fd_r, err); - } - continue; - } - err = do_not_aio(&req); - reply = ((struct aio_thread_reply) { .data = req.aio, - .err = err }); - err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply)); - if(err != sizeof(reply)) - printk("not_aio_thread - write failed, fd = %d, " - "err = %d\n", aio_req_fd_r, -err); - } + struct aio_thread_req req; + struct aio_thread_reply reply; + int err; + + signal(SIGWINCH, SIG_IGN); + while(1){ + err = os_read_file(aio_req_fd_r, &req, sizeof(req)); + if(err != sizeof(req)){ + if(err < 0) + printk("not_aio_thread - read failed, " + "fd = %d, err = %d\n", aio_req_fd_r, + -err); + else { + printk("not_aio_thread - short read, fd = %d, " + "length = %d\n", aio_req_fd_r, err); + } + continue; + } + err = do_not_aio(&req); + reply = ((struct aio_thread_reply) { .data = req.aio, + .err = err }); + err = os_write_file(req.aio->reply_fd, &reply, sizeof(reply)); + if(err != sizeof(reply)) + printk("not_aio_thread - write failed, fd = %d, " + "err = %d\n", aio_req_fd_r, -err); + } return 0; } @@ -218,93 +218,93 @@ static int aio_pid = -1; static int init_aio_24(void) { - unsigned long stack; - int fds[2], err; - - err = os_pipe(fds, 1, 1); - if(err) - goto out; - - aio_req_fd_w = fds[0]; - aio_req_fd_r = fds[1]; - err = run_helper_thread(not_aio_thread, NULL, - CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); - if(err < 0) - goto out_close_pipe; - - aio_pid = err; - goto out; - - out_close_pipe: - os_close_file(fds[0]); - os_close_file(fds[1]); - aio_req_fd_w = -1; - aio_req_fd_r = -1; - out: + unsigned long stack; + int fds[2], err; + + err = os_pipe(fds, 1, 1); + if(err) + goto out; + + aio_req_fd_w = fds[0]; + aio_req_fd_r = fds[1]; + err = run_helper_thread(not_aio_thread, NULL, + CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); + if(err < 0) + goto out_close_pipe; + + aio_pid = err; + goto out; + +out_close_pipe: + os_close_file(fds[0]); + os_close_file(fds[1]); + aio_req_fd_w = -1; + aio_req_fd_r = -1; +out: #ifndef HAVE_AIO_ABI printk("/usr/include/linux/aio_abi.h not present during build\n"); #endif printk("2.6 host AIO support not used - falling back to I/O " "thread\n"); - return 0; + return 0; } #ifdef HAVE_AIO_ABI #define DEFAULT_24_AIO 0 static int init_aio_26(void) { - unsigned long stack; - int err; + unsigned long stack; + int err; - if(io_setup(256, &ctx)){ + if(io_setup(256, &ctx)){ err = -errno; - printk("aio_thread failed to initialize context, err = %d\n", - errno); - return err; - } + printk("aio_thread failed to initialize context, err = %d\n", + errno); + return err; + } - err = run_helper_thread(aio_thread, NULL, - CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); - if(err < 0) - return err; + err = run_helper_thread(aio_thread, NULL, + CLONE_FILES | CLONE_VM | SIGCHLD, &stack, 0); + if(err < 0) + return err; - aio_pid = err; + aio_pid = err; printk("Using 2.6 host AIO\n"); - return 0; + return 0; } static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len, unsigned long long offset, struct aio_context *aio) { - struct aio_thread_reply reply; - int err; - - err = do_aio(ctx, type, io_fd, buf, len, offset, aio); - if(err){ - reply = ((struct aio_thread_reply) { .data = aio, - .err = err }); - err = os_write_file(aio->reply_fd, &reply, sizeof(reply)); - if(err != sizeof(reply)) - printk("submit_aio_26 - write failed, " - "fd = %d, err = %d\n", aio->reply_fd, -err); - else err = 0; - } - - return err; + struct aio_thread_reply reply; + int err; + + err = do_aio(ctx, type, io_fd, buf, len, offset, aio); + if(err){ + reply = ((struct aio_thread_reply) { .data = aio, + .err = err }); + err = os_write_file(aio->reply_fd, &reply, sizeof(reply)); + if(err != sizeof(reply)) + printk("submit_aio_26 - write failed, " + "fd = %d, err = %d\n", aio->reply_fd, -err); + else err = 0; + } + + return err; } #else #define DEFAULT_24_AIO 1 static int init_aio_26(void) { - return -ENOSYS; + return -ENOSYS; } static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len, unsigned long long offset, struct aio_context *aio) { - return -ENOSYS; + return -ENOSYS; } #endif @@ -312,8 +312,8 @@ static int aio_24 = DEFAULT_24_AIO; static int __init set_aio_24(char *name, int *add) { - aio_24 = 1; - return 0; + aio_24 = 1; + return 0; } __uml_setup("aio=2.4", set_aio_24, @@ -330,28 +330,27 @@ __uml_setup("aio=2.4", set_aio_24, static int init_aio(void) { - int err; - - CHOOSE_MODE(({ - if(!aio_24){ - printk("Disabling 2.6 AIO in tt mode\n"); - aio_24 = 1; - } }), (void) 0); - - if(!aio_24){ - err = init_aio_26(); - if(err && (errno == ENOSYS)){ - printk("2.6 AIO not supported on the host - " - "reverting to 2.4 AIO\n"); - aio_24 = 1; - } - else return err; - } - - if(aio_24) - return init_aio_24(); - - return 0; + int err; + + CHOOSE_MODE(({ if(!aio_24){ + printk("Disabling 2.6 AIO in tt mode\n"); + aio_24 = 1; + } }), (void) 0); + + if(!aio_24){ + err = init_aio_26(); + if(err && (errno == ENOSYS)){ + printk("2.6 AIO not supported on the host - " + "reverting to 2.4 AIO\n"); + aio_24 = 1; + } + else return err; + } + + if(aio_24) + return init_aio_24(); + + return 0; } /* The reason for the __initcall/__uml_exitcall asymmetry is that init_aio @@ -364,8 +363,8 @@ __initcall(init_aio); static void exit_aio(void) { - if(aio_pid != -1) - os_kill_process(aio_pid, 1); + if(aio_pid != -1) + os_kill_process(aio_pid, 1); } __uml_exitcall(exit_aio); @@ -373,30 +372,30 @@ __uml_exitcall(exit_aio); static int submit_aio_24(enum aio_type type, int io_fd, char *buf, int len, unsigned long long offset, struct aio_context *aio) { - struct aio_thread_req req = { .type = type, - .io_fd = io_fd, - .offset = offset, - .buf = buf, - .len = len, - .aio = aio, - }; - int err; - - err = os_write_file(aio_req_fd_w, &req, sizeof(req)); - if(err == sizeof(req)) - err = 0; - - return err; + struct aio_thread_req req = { .type = type, + .io_fd = io_fd, + .offset = offset, + .buf = buf, + .len = len, + .aio = aio, + }; + int err; + + err = os_write_file(aio_req_fd_w, &req, sizeof(req)); + if(err == sizeof(req)) + err = 0; + + return err; } int submit_aio(enum aio_type type, int io_fd, char *buf, int len, - unsigned long long offset, int reply_fd, - struct aio_context *aio) + unsigned long long offset, int reply_fd, + struct aio_context *aio) { - aio->reply_fd = reply_fd; - if(aio_24) - return submit_aio_24(type, io_fd, buf, len, offset, aio); - else { - return submit_aio_26(type, io_fd, buf, len, offset, aio); - } + aio->reply_fd = reply_fd; + if(aio_24) + return submit_aio_24(type, io_fd, buf, len, offset, aio); + else { + return submit_aio_26(type, io_fd, buf, len, offset, aio); + } } -- cgit v1.1 From 0834cc77af6a8a650f803d4a7c3c0f134b366f87 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:51 -0800 Subject: [PATCH] uml: use ARRAY_SIZE This patch replaces instances of "sizeof(foo)/sizeof(foo[0])" with ARRAY_SIZE(foo), which expands to the same thing. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/ssl.c | 20 +++++++------------- arch/um/drivers/stdio_console.c | 13 ++++++------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 95a3eaa..8564784c 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -84,21 +84,18 @@ static struct lines lines = LINES_INIT(NR_PORTS); static int ssl_config(char *str) { - return line_config(serial_lines, - sizeof(serial_lines)/sizeof(serial_lines[0]), str); + return line_config(serial_lines, ARRAY_SIZE(serial_lines), str); } static int ssl_get_config(char *dev, char *str, int size, char **error_out) { - return line_get_config(dev, serial_lines, - sizeof(serial_lines)/sizeof(serial_lines[0]), - str, size, error_out); + return line_get_config(dev, serial_lines, ARRAY_SIZE(serial_lines), str, + size, error_out); } static int ssl_remove(int n) { - return line_remove(serial_lines, - sizeof(serial_lines)/sizeof(serial_lines[0]), n); + return line_remove(serial_lines, ARRAY_SIZE(serial_lines), n); } int ssl_open(struct tty_struct *tty, struct file *filp) @@ -205,7 +202,7 @@ int ssl_init(void) serial_lines, ARRAY_SIZE(serial_lines)); - lines_init(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0])); + lines_init(serial_lines, ARRAY_SIZE(serial_lines)); new_title = add_xterm_umid(opts.xterm_title); if (new_title != NULL) @@ -221,16 +218,13 @@ static void ssl_exit(void) { if (!ssl_init_done) return; - close_lines(serial_lines, - sizeof(serial_lines)/sizeof(serial_lines[0])); + close_lines(serial_lines, ARRAY_SIZE(serial_lines)); } __uml_exitcall(ssl_exit); static int ssl_chan_setup(char *str) { - return line_setup(serial_lines, - sizeof(serial_lines)/sizeof(serial_lines[0]), - str, 1); + return line_setup(serial_lines, ARRAY_SIZE(serial_lines), str, 1); } __setup("ssl", ssl_chan_setup); diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 8f3b168..b77f7d2 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -91,18 +91,17 @@ struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver), static int con_config(char *str) { - return line_config(vts, sizeof(vts)/sizeof(vts[0]), str); + return line_config(vts, ARRAY_SIZE(vts), str); } static int con_get_config(char *dev, char *str, int size, char **error_out) { - return line_get_config(dev, vts, sizeof(vts)/sizeof(vts[0]), str, - size, error_out); + return line_get_config(dev, vts, ARRAY_SIZE(vts), str, size, error_out); } static int con_remove(int n) { - return line_remove(vts, sizeof(vts)/sizeof(vts[0]), n); + return line_remove(vts, ARRAY_SIZE(vts), n); } static int con_open(struct tty_struct *tty, struct file *filp) @@ -170,7 +169,7 @@ int stdio_init(void) return -1; printk(KERN_INFO "Initialized stdio console driver\n"); - lines_init(vts, sizeof(vts)/sizeof(vts[0])); + lines_init(vts, ARRAY_SIZE(vts)); new_title = add_xterm_umid(opts.xterm_title); if(new_title != NULL) @@ -186,13 +185,13 @@ static void console_exit(void) { if (!con_init_done) return; - close_lines(vts, sizeof(vts)/sizeof(vts[0])); + close_lines(vts, ARRAY_SIZE(vts)); } __uml_exitcall(console_exit); static int console_chan_setup(char *str) { - return line_setup(vts, sizeof(vts)/sizeof(vts[0]), str, 1); + return line_setup(vts, ARRAY_SIZE(vts), str, 1); } __setup("con", console_chan_setup); __channel_help(console_chan_setup, "con"); -- cgit v1.1 From 88890b88742debb97006df264b653d18acdc80d0 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:52 -0800 Subject: [PATCH] uml: Remove unneeded structure field This removes a structure field which turned out to be pointless, and references to it. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/chan_kern.c | 16 ++++++---------- arch/um/drivers/line.c | 2 +- arch/um/include/chan_kern.h | 5 ++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 8b1262e..59c9b3f 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -315,7 +315,7 @@ int console_open_chan(struct line *line, struct console *co, return 0; if (0 != parse_chan_pair(line->init_str, &line->chan_list, - line->init_pri, co->index, opts)) + co->index, opts)) return -1; if (0 != open_chan(&line->chan_list)) return -1; @@ -468,8 +468,7 @@ struct chan_type chan_table[] = { #endif }; -static struct chan *parse_chan(char *str, int pri, int device, - struct chan_opts *opts) +static struct chan *parse_chan(char *str, int device, struct chan_opts *opts) { struct chan_type *entry; struct chan_ops *ops; @@ -507,13 +506,12 @@ static struct chan *parse_chan(char *str, int pri, int device, .output = 0, .opened = 0, .fd = -1, - .pri = pri, .ops = ops, .data = data }); return chan; } -int parse_chan_pair(char *str, struct list_head *chans, int pri, int device, +int parse_chan_pair(char *str, struct list_head *chans, int device, struct chan_opts *opts) { struct chan *new, *chan; @@ -521,8 +519,6 @@ int parse_chan_pair(char *str, struct list_head *chans, int pri, int device, if(!list_empty(chans)){ chan = list_entry(chans->next, struct chan, list); - if(chan->pri >= pri) - return 0; free_chan(chans); INIT_LIST_HEAD(chans); } @@ -532,14 +528,14 @@ int parse_chan_pair(char *str, struct list_head *chans, int pri, int device, in = str; *out = '\0'; out++; - new = parse_chan(in, pri, device, opts); + new = parse_chan(in, device, opts); if(new == NULL) return -1; new->input = 1; list_add(&new->list, chans); - new = parse_chan(out, pri, device, opts); + new = parse_chan(out, device, opts); if(new == NULL) return -1; @@ -547,7 +543,7 @@ int parse_chan_pair(char *str, struct list_head *chans, int pri, int device, new->output = 1; } else { - new = parse_chan(str, pri, device, opts); + new = parse_chan(str, device, opts); if(new == NULL) return -1; diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 2ee00cb..80ade22 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -438,7 +438,7 @@ int line_open(struct line *lines, struct tty_struct *tty, } if (list_empty(&line->chan_list)) { err = parse_chan_pair(line->init_str, &line->chan_list, - line->init_pri, tty->index, opts); + tty->index, opts); if(err) goto out; err = open_chan(&line->chan_list); if(err) goto out; diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h index 9ac0691..22bf3a7 100644 --- a/arch/um/include/chan_kern.h +++ b/arch/um/include/chan_kern.h @@ -20,15 +20,14 @@ struct chan { unsigned int output:1; unsigned int opened:1; int fd; - enum chan_init_pri pri; struct chan_ops *ops; void *data; }; extern void chan_interrupt(struct list_head *chans, struct work_struct *task, struct tty_struct *tty, int irq); -extern int parse_chan_pair(char *str, struct list_head *chans, int pri, - int device, struct chan_opts *opts); +extern int parse_chan_pair(char *str, struct list_head *chans, int device, + struct chan_opts *opts); extern int open_chan(struct list_head *chans); extern int write_chan(struct list_head *chans, const char *buf, int len, int write_irq); -- cgit v1.1 From d571cd18f225542460b5d9b83e5e0d507be71656 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:53 -0800 Subject: [PATCH] uml: Move mconsole support out of generic code A bit of restructuring which eliminates the all_allowed argument (which is mconsole-specific) to line_setup. That logic is moved to the mconsole callback. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/line.c | 21 ++++++++++----------- arch/um/drivers/ssl.c | 2 +- arch/um/drivers/stdio_console.c | 2 +- arch/um/include/line.h | 4 ++-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 80ade22..9af55ec 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -500,11 +500,9 @@ void close_lines(struct line *lines, int nlines) /* Common setup code for both startup command line and mconsole initialization. * @lines contains the the array (of size @num) to modify; * @init is the setup string; - * @all_allowed is a boolean saying if we can setup the whole @lines - * at once. For instance, it will be usually true for startup init. (where we - * can use con=xterm) and false for mconsole.*/ + */ -int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed) +int line_setup(struct line *lines, unsigned int num, char *init) { int i, n; char *end; @@ -545,11 +543,6 @@ int line_setup(struct line *lines, unsigned int num, char *init, int all_allowed } } } - else if(!all_allowed){ - printk("line_setup - can't configure all devices from " - "mconsole\n"); - return 0; - } else { for(i = 0; i < num; i++){ if(lines[i].init_pri <= INIT_ALL){ @@ -569,12 +562,18 @@ int line_config(struct line *lines, unsigned int num, char *str) { char *new; + if(*str == '='){ + printk("line_config - can't configure all devices from " + "mconsole\n"); + return 1; + } + new = kstrdup(str, GFP_KERNEL); if(new == NULL){ printk("line_config - kstrdup failed\n"); return -ENOMEM; } - return !line_setup(lines, num, new, 0); + return !line_setup(lines, num, new); } int line_get_config(char *name, struct line *lines, unsigned int num, char *str, @@ -628,7 +627,7 @@ int line_remove(struct line *lines, unsigned int num, int n) char config[sizeof("conxxxx=none\0")]; sprintf(config, "%d=none", n); - return !line_setup(lines, num, config, 0); + return !line_setup(lines, num, config); } struct tty_driver *line_register_devfs(struct lines *set, diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 8564784c..e1895d9 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -224,7 +224,7 @@ __uml_exitcall(ssl_exit); static int ssl_chan_setup(char *str) { - return line_setup(serial_lines, ARRAY_SIZE(serial_lines), str, 1); + return line_setup(serial_lines, ARRAY_SIZE(serial_lines), str); } __setup("ssl", ssl_chan_setup); diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index b77f7d2..72000d3 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -191,7 +191,7 @@ __uml_exitcall(console_exit); static int console_chan_setup(char *str) { - return line_setup(vts, ARRAY_SIZE(vts), str, 1); + return line_setup(vts, ARRAY_SIZE(vts), str); } __setup("con", console_chan_setup); __channel_help(console_chan_setup, "con"); diff --git a/arch/um/include/line.h b/arch/um/include/line.h index 315788c..e22c9e0 100644 --- a/arch/um/include/line.h +++ b/arch/um/include/line.h @@ -76,8 +76,8 @@ struct lines { extern void line_close(struct tty_struct *tty, struct file * filp); extern int line_open(struct line *lines, struct tty_struct *tty, struct chan_opts *opts); -extern int line_setup(struct line *lines, unsigned int sizeof_lines, char *init, - int all_allowed); +extern int line_setup(struct line *lines, unsigned int sizeof_lines, + char *init); extern int line_write(struct tty_struct *tty, const unsigned char *buf, int len); extern void line_put_char(struct tty_struct *tty, unsigned char ch); -- cgit v1.1 From 9010772cdff36072dd509ec72c1a55fccde8e58e Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:54 -0800 Subject: [PATCH] uml: Add static initializations and declarations Some structure fields were being dynamically initialized when they could be initialized at compile-time instead. This also makes some declarations static (in the C sense). Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/line.c | 7 +++---- arch/um/drivers/mconsole_kern.c | 6 +++--- arch/um/drivers/net_kern.c | 4 ++-- arch/um/include/line.h | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 9af55ec..1c2cc5d 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -668,19 +668,18 @@ struct tty_driver *line_register_devfs(struct lines *set, return driver; } -static spinlock_t winch_handler_lock; -LIST_HEAD(winch_handlers); +static DEFINE_SPINLOCK(winch_handler_lock); +static LIST_HEAD(winch_handlers); void lines_init(struct line *lines, int nlines) { struct line *line; int i; - spin_lock_init(&winch_handler_lock); for(i = 0; i < nlines; i++){ line = &lines[i]; INIT_LIST_HEAD(&line->chan_list); - spin_lock_init(&line->lock); + if(line->init_str == NULL) continue; diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index 355866a..b5217bd 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -51,7 +51,7 @@ static struct notifier_block reboot_notifier = { * itself and it can only happen on CPU 0. */ -LIST_HEAD(mc_requests); +static LIST_HEAD(mc_requests); static void mc_work_proc(void *unused) { @@ -69,7 +69,7 @@ static void mc_work_proc(void *unused) } } -DECLARE_WORK(mconsole_work, mc_work_proc, NULL); +static DECLARE_WORK(mconsole_work, mc_work_proc, NULL); static irqreturn_t mconsole_interrupt(int irq, void *dev_id, struct pt_regs *regs) @@ -535,7 +535,7 @@ void mconsole_stack(struct mc_request *req) */ static char *notify_socket = NULL; -int mconsole_init(void) +static int mconsole_init(void) { /* long to avoid size mismatch warnings from gcc */ long sock; diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index 29785f6..deb2482 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c @@ -34,7 +34,7 @@ #define DRIVER_NAME "uml-netdev" static DEFINE_SPINLOCK(opened_lock); -LIST_HEAD(opened); +static LIST_HEAD(opened); static int uml_net_rx(struct net_device *dev) { @@ -266,7 +266,7 @@ void uml_net_user_timer_expire(unsigned long _conn) } static DEFINE_SPINLOCK(devices_lock); -static struct list_head devices = LIST_HEAD_INIT(devices); +static LIST_HEAD(devices); static struct platform_driver uml_net_driver = { .driver = { diff --git a/arch/um/include/line.h b/arch/um/include/line.h index e22c9e0..351d3ac 100644 --- a/arch/um/include/line.h +++ b/arch/um/include/line.h @@ -58,8 +58,8 @@ struct line { #define LINE_INIT(str, d) \ { init_str : str, \ init_pri : INIT_STATIC, \ - chan_list : { }, \ valid : 1, \ + lock : SPIN_LOCK_UNLOCKED, \ buffer : NULL, \ head : NULL, \ tail : NULL, \ -- cgit v1.1 From 418e55d49b0ec7d2e7a033f2dd083f5b2ab7d119 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:54 -0800 Subject: [PATCH] uml: line_setup interface change line_setup is changed to return the device which it set up, rather than just success or failure. This will be important in the line-config patch. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/line.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 1c2cc5d..1352a21 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -555,12 +555,13 @@ int line_setup(struct line *lines, unsigned int num, char *init) } } } - return 1; + return n == -1 ? num : n; } int line_config(struct line *lines, unsigned int num, char *str) { char *new; + int n; if(*str == '='){ printk("line_config - can't configure all devices from " @@ -573,7 +574,8 @@ int line_config(struct line *lines, unsigned int num, char *str) printk("line_config - kstrdup failed\n"); return -ENOMEM; } - return !line_setup(lines, num, new); + n = line_setup(lines, num, new); + return n < 0 ? n : 0; } int line_get_config(char *name, struct line *lines, unsigned int num, char *str, @@ -624,10 +626,14 @@ int line_id(char **str, int *start_out, int *end_out) int line_remove(struct line *lines, unsigned int num, int n) { + int err; char config[sizeof("conxxxx=none\0")]; sprintf(config, "%d=none", n); - return !line_setup(lines, num, config); + err = line_setup(lines, num, config); + if(err >= 0) + err = 0; + return err; } struct tty_driver *line_register_devfs(struct lines *set, -- cgit v1.1 From 1f80171e81ed0d08dcdb6efe239d7b929aef498f Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:55 -0800 Subject: [PATCH] uml: move console configuration This patch changes when console devices are configured in order to prepare the ground for the next patch. parse_chan_pair is now done earlier, when initcalls are run, rather than when the device is opened. When a host device disappears, the channel list is closed, but not freed. This is required by the previous change. line_config now takes the options structure as an argument, and line_open doesn't. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/chan_kern.c | 14 +++++--------- arch/um/drivers/line.c | 34 +++++++++++++++++++++------------- arch/um/drivers/ssl.c | 6 +++--- arch/um/drivers/stdio_console.c | 6 +++--- arch/um/include/line.h | 7 +++---- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 59c9b3f..31b69c4 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -311,14 +311,12 @@ int console_write_chan(struct list_head *chans, const char *buf, int len) int console_open_chan(struct line *line, struct console *co, struct chan_opts *opts) { - if (!list_empty(&line->chan_list)) - return 0; + int err; + + err = open_chan(&line->chan_list); + if(err) + return err; - if (0 != parse_chan_pair(line->init_str, &line->chan_list, - co->index, opts)) - return -1; - if (0 != open_chan(&line->chan_list)) - return -1; printk("Console initialized on /dev/%s%d\n",co->name,co->index); return 0; } @@ -596,13 +594,11 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task, tty_hangup(tty); line_disable(tty, irq); close_chan(chans); - free_chan(chans); return; } else { if(chan->ops->close != NULL) chan->ops->close(chan->fd, chan->data); - free_one_chan(chan); } } } diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 1352a21..da81d22 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -419,8 +419,7 @@ void line_disable(struct tty_struct *tty, int current_irq) line->have_irq = 0; } -int line_open(struct line *lines, struct tty_struct *tty, - struct chan_opts *opts) +int line_open(struct line *lines, struct tty_struct *tty) { struct line *line; int err = 0; @@ -436,13 +435,11 @@ int line_open(struct line *lines, struct tty_struct *tty, err = -ENODEV; goto out; } - if (list_empty(&line->chan_list)) { - err = parse_chan_pair(line->init_str, &line->chan_list, - tty->index, opts); - if(err) goto out; - err = open_chan(&line->chan_list); - if(err) goto out; - } + + err = open_chan(&line->chan_list); + if(err) + goto out; + /* Here the interrupt is registered.*/ enable_chan(&line->chan_list, tty); INIT_WORK(&line->task, line_timer_cb, tty); @@ -558,8 +555,10 @@ int line_setup(struct line *lines, unsigned int num, char *init) return n == -1 ? num : n; } -int line_config(struct line *lines, unsigned int num, char *str) +int line_config(struct line *lines, unsigned int num, char *str, + struct chan_opts *opts) { + struct line *line; char *new; int n; @@ -572,10 +571,14 @@ int line_config(struct line *lines, unsigned int num, char *str) new = kstrdup(str, GFP_KERNEL); if(new == NULL){ printk("line_config - kstrdup failed\n"); - return -ENOMEM; + return 1; } n = line_setup(lines, num, new); - return n < 0 ? n : 0; + if(n < 0) + return 1; + + line = &lines[n]; + return parse_chan_pair(line->init_str, &line->chan_list, n, opts); } int line_get_config(char *name, struct line *lines, unsigned int num, char *str, @@ -677,7 +680,7 @@ struct tty_driver *line_register_devfs(struct lines *set, static DEFINE_SPINLOCK(winch_handler_lock); static LIST_HEAD(winch_handlers); -void lines_init(struct line *lines, int nlines) +void lines_init(struct line *lines, int nlines, struct chan_opts *opts) { struct line *line; int i; @@ -692,6 +695,11 @@ void lines_init(struct line *lines, int nlines) line->init_str = kstrdup(line->init_str, GFP_KERNEL); if(line->init_str == NULL) printk("lines_init - kstrdup returned NULL\n"); + + if(parse_chan_pair(line->init_str, &line->chan_list, i, opts)){ + printk("parse_chan_pair failed for device %d\n", i); + line->valid = 0; + } } } diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index e1895d9..6823dc5 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -84,7 +84,7 @@ static struct lines lines = LINES_INIT(NR_PORTS); static int ssl_config(char *str) { - return line_config(serial_lines, ARRAY_SIZE(serial_lines), str); + return line_config(serial_lines, ARRAY_SIZE(serial_lines), str, &opts); } static int ssl_get_config(char *dev, char *str, int size, char **error_out) @@ -100,7 +100,7 @@ static int ssl_remove(int n) int ssl_open(struct tty_struct *tty, struct file *filp) { - return line_open(serial_lines, tty, &opts); + return line_open(serial_lines, tty); } #if 0 @@ -202,7 +202,7 @@ int ssl_init(void) serial_lines, ARRAY_SIZE(serial_lines)); - lines_init(serial_lines, ARRAY_SIZE(serial_lines)); + lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts); new_title = add_xterm_umid(opts.xterm_title); if (new_title != NULL) diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 72000d3..6d4edda 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -91,7 +91,7 @@ struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver), static int con_config(char *str) { - return line_config(vts, ARRAY_SIZE(vts), str); + return line_config(vts, ARRAY_SIZE(vts), str, &opts); } static int con_get_config(char *dev, char *str, int size, char **error_out) @@ -106,7 +106,7 @@ static int con_remove(int n) static int con_open(struct tty_struct *tty, struct file *filp) { - return line_open(vts, tty, &opts); + return line_open(vts, tty); } static int con_init_done = 0; @@ -169,7 +169,7 @@ int stdio_init(void) return -1; printk(KERN_INFO "Initialized stdio console driver\n"); - lines_init(vts, ARRAY_SIZE(vts)); + lines_init(vts, ARRAY_SIZE(vts), &opts); new_title = add_xterm_umid(opts.xterm_title); if(new_title != NULL) diff --git a/arch/um/include/line.h b/arch/um/include/line.h index 351d3ac..474398b 100644 --- a/arch/um/include/line.h +++ b/arch/um/include/line.h @@ -74,8 +74,7 @@ struct lines { #define LINES_INIT(n) { num : n } extern void line_close(struct tty_struct *tty, struct file * filp); -extern int line_open(struct line *lines, struct tty_struct *tty, - struct chan_opts *opts); +extern int line_open(struct line *lines, struct tty_struct *tty); extern int line_setup(struct line *lines, unsigned int sizeof_lines, char *init); extern int line_write(struct tty_struct *tty, const unsigned char *buf, @@ -99,11 +98,11 @@ extern struct tty_driver * line_register_devfs(struct lines *set, struct tty_operations *driver, struct line *lines, int nlines); -extern void lines_init(struct line *lines, int nlines); +extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); extern void close_lines(struct line *lines, int nlines); extern int line_config(struct line *lines, unsigned int sizeof_lines, - char *str); + char *str, struct chan_opts *opts); extern int line_id(char **str, int *start_out, int *end_out); extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n); extern int line_get_config(char *dev, struct line *lines, -- cgit v1.1 From 165dc5911627a9c4752e909a0da661b96b6fd269 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:57 -0800 Subject: [PATCH] uml: Simplify console opening/closing and irq registration This patch simplifies the opening and closing of host console devices and the registration and deregistration of IRQs. The intent is to make it obvious that an IRQ can't exist without an open file descriptor. chan_enable will now open the channel, and when both opening and IRQ registration are desired, this should be used. Opening only is done for the initial console, so that interface still needs to exist. The free_irqs_later interface is now gone. It was intended to avoid freeing an IRQ while it was being processed. It did this, but it didn't eliminate the possiblity of free_irq being called from an interrupt, which is bad. In its place is a list of irqs to be freed, which is processed by the signal handler just before exiting. close_one_chan now disables irqs. When a host device disappears, it is just closed, and that disables IRQs. The device id registered with the IRQ is now the chan structure, not the tty. This is because the interrupt arrives on a descriptor associated with the channel. This caused equivalent changes in the arguments to line_timer_cb. line_disable is gone since it is not used any more. The count field in the line structure is gone. tty->count is used instead. The complicated logic in sigio_handler with freeing IRQs when necessary and making sure its idea of the next irq is correct is now much simpler. The irq list can't be rearranged underneath it, so it is now a simple list walk. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/chan_kern.c | 111 +++++++++++++++++++++++++++--------------- arch/um/drivers/line.c | 116 ++++++++++++++++++-------------------------- arch/um/include/chan_kern.h | 9 ++-- arch/um/include/irq_user.h | 13 +---- arch/um/include/line.h | 6 +-- arch/um/kernel/irq_user.c | 48 +++--------------- 6 files changed, 137 insertions(+), 166 deletions(-) diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 31b69c4..1bb920c 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) * Licensed under the GPL */ @@ -240,20 +240,65 @@ void chan_enable_winch(struct list_head *chans, struct tty_struct *tty) } } -void enable_chan(struct list_head *chans, struct tty_struct *tty) +void enable_chan(struct line *line) { struct list_head *ele; struct chan *chan; - list_for_each(ele, chans){ + list_for_each(ele, &line->chan_list){ chan = list_entry(ele, struct chan, list); - if(!chan->opened) continue; + if(open_one_chan(chan)) + continue; + + if(chan->enabled) + continue; + line_setup_irq(chan->fd, chan->input, chan->output, line, + chan); + chan->enabled = 1; + } +} + +static LIST_HEAD(irqs_to_free); + +void free_irqs(void) +{ + struct chan *chan; + + while(!list_empty(&irqs_to_free)){ + chan = list_entry(irqs_to_free.next, struct chan, free_list); + list_del(&chan->free_list); + + if(chan->input) + free_irq(chan->line->driver->read_irq, chan); + if(chan->output) + free_irq(chan->line->driver->write_irq, chan); + chan->enabled = 0; + } +} + +static void close_one_chan(struct chan *chan, int delay_free_irq) +{ + if(!chan->opened) + return; - line_setup_irq(chan->fd, chan->input, chan->output, tty); + if(delay_free_irq){ + list_add(&chan->free_list, &irqs_to_free); + } + else { + if(chan->input) + free_irq(chan->line->driver->read_irq, chan); + if(chan->output) + free_irq(chan->line->driver->write_irq, chan); + chan->enabled = 0; } + if(chan->ops->close != NULL) + (*chan->ops->close)(chan->fd, chan->data); + + chan->opened = 0; + chan->fd = -1; } -void close_chan(struct list_head *chans) +void close_chan(struct list_head *chans, int delay_free_irq) { struct chan *chan; @@ -263,11 +308,7 @@ void close_chan(struct list_head *chans) * so it must be the last closed. */ list_for_each_entry_reverse(chan, chans, list) { - if(!chan->opened) continue; - if(chan->ops->close != NULL) - (*chan->ops->close)(chan->fd, chan->data); - chan->opened = 0; - chan->fd = -1; + close_one_chan(chan, delay_free_irq); } } @@ -339,24 +380,27 @@ int chan_window_size(struct list_head *chans, unsigned short *rows_out, return 0; } -void free_one_chan(struct chan *chan) +void free_one_chan(struct chan *chan, int delay_free_irq) { list_del(&chan->list); + + close_one_chan(chan, delay_free_irq); + if(chan->ops->free != NULL) (*chan->ops->free)(chan->data); - free_irq_by_fd(chan->fd); + if(chan->primary && chan->output) ignore_sigio_fd(chan->fd); kfree(chan); } -void free_chan(struct list_head *chans) +void free_chan(struct list_head *chans, int delay_free_irq) { struct list_head *ele, *next; struct chan *chan; list_for_each_safe(ele, next, chans){ chan = list_entry(ele, struct chan, list); - free_one_chan(chan); + free_one_chan(chan, delay_free_irq); } } @@ -466,7 +510,8 @@ struct chan_type chan_table[] = { #endif }; -static struct chan *parse_chan(char *str, int device, struct chan_opts *opts) +static struct chan *parse_chan(struct line *line, char *str, int device, + struct chan_opts *opts) { struct chan_type *entry; struct chan_ops *ops; @@ -499,25 +544,30 @@ static struct chan *parse_chan(char *str, int device, struct chan_opts *opts) if(chan == NULL) return NULL; *chan = ((struct chan) { .list = LIST_HEAD_INIT(chan->list), + .free_list = + LIST_HEAD_INIT(chan->free_list), + .line = line, .primary = 1, .input = 0, .output = 0, .opened = 0, + .enabled = 0, .fd = -1, .ops = ops, .data = data }); return chan; } -int parse_chan_pair(char *str, struct list_head *chans, int device, +int parse_chan_pair(char *str, struct line *line, int device, struct chan_opts *opts) { + struct list_head *chans = &line->chan_list; struct chan *new, *chan; char *in, *out; if(!list_empty(chans)){ chan = list_entry(chans->next, struct chan, list); - free_chan(chans); + free_chan(chans, 0); INIT_LIST_HEAD(chans); } @@ -526,14 +576,14 @@ int parse_chan_pair(char *str, struct list_head *chans, int device, in = str; *out = '\0'; out++; - new = parse_chan(in, device, opts); + new = parse_chan(line, in, device, opts); if(new == NULL) return -1; new->input = 1; list_add(&new->list, chans); - new = parse_chan(out, device, opts); + new = parse_chan(line, out, device, opts); if(new == NULL) return -1; @@ -541,7 +591,7 @@ int parse_chan_pair(char *str, struct list_head *chans, int device, new->output = 1; } else { - new = parse_chan(str, device, opts); + new = parse_chan(line, str, device, opts); if(new == NULL) return -1; @@ -592,27 +642,12 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task, if(chan->primary){ if(tty != NULL) tty_hangup(tty); - line_disable(tty, irq); - close_chan(chans); + close_chan(chans, 1); return; } - else { - if(chan->ops->close != NULL) - chan->ops->close(chan->fd, chan->data); - } + else close_one_chan(chan, 1); } } out: if(tty) tty_flip_buffer_push(tty); } - -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index da81d22..851a7c8 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com) * Licensed under the GPL */ @@ -23,8 +23,9 @@ static irqreturn_t line_interrupt(int irq, void *data, struct pt_regs *unused) { - struct tty_struct *tty = data; - struct line *line = tty->driver_data; + struct chan *chan = data; + struct line *line = chan->line; + struct tty_struct *tty = line->tty; if (line) chan_interrupt(&line->chan_list, &line->task, tty, irq); @@ -33,10 +34,10 @@ static irqreturn_t line_interrupt(int irq, void *data, struct pt_regs *unused) static void line_timer_cb(void *arg) { - struct tty_struct *tty = arg; - struct line *line = tty->driver_data; + struct line *line = arg; - line_interrupt(line->driver->read_irq, arg, NULL); + chan_interrupt(&line->chan_list, &line->task, line->tty, + line->driver->read_irq); } /* Returns the free space inside the ring buffer of this line. @@ -342,8 +343,9 @@ int line_ioctl(struct tty_struct *tty, struct file * file, static irqreturn_t line_write_interrupt(int irq, void *data, struct pt_regs *unused) { - struct tty_struct *tty = data; - struct line *line = tty->driver_data; + struct chan *chan = data; + struct line *line = chan->line; + struct tty_struct *tty = line->tty; int err; /* Interrupts are enabled here because we registered the interrupt with @@ -365,7 +367,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data, if (test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags) && (tty->ldisc.write_wakeup != NULL)) (tty->ldisc.write_wakeup)(tty); - + /* BLOCKING mode * In blocking mode, everything sleeps on tty->write_wait. * Sleeping in the console driver would break non-blocking @@ -377,52 +379,29 @@ static irqreturn_t line_write_interrupt(int irq, void *data, return IRQ_HANDLED; } -int line_setup_irq(int fd, int input, int output, struct tty_struct *tty) +int line_setup_irq(int fd, int input, int output, struct line *line, void *data) { - struct line *line = tty->driver_data; struct line_driver *driver = line->driver; int err = 0, flags = SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM; if (input) err = um_request_irq(driver->read_irq, fd, IRQ_READ, line_interrupt, flags, - driver->read_irq_name, tty); + driver->read_irq_name, data); if (err) return err; if (output) err = um_request_irq(driver->write_irq, fd, IRQ_WRITE, line_write_interrupt, flags, - driver->write_irq_name, tty); + driver->write_irq_name, data); line->have_irq = 1; return err; } -void line_disable(struct tty_struct *tty, int current_irq) -{ - struct line *line = tty->driver_data; - - if(!line->have_irq) - return; - - if(line->driver->read_irq == current_irq) - free_irq_later(line->driver->read_irq, tty); - else { - free_irq(line->driver->read_irq, tty); - } - - if(line->driver->write_irq == current_irq) - free_irq_later(line->driver->write_irq, tty); - else { - free_irq(line->driver->write_irq, tty); - } - - line->have_irq = 0; -} - int line_open(struct line *lines, struct tty_struct *tty) { struct line *line; - int err = 0; + int err = -ENODEV; line = &lines[tty->index]; tty->driver_data = line; @@ -430,29 +409,29 @@ int line_open(struct line *lines, struct tty_struct *tty) /* The IRQ which takes this lock is not yet enabled and won't be run * before the end, so we don't need to use spin_lock_irq.*/ spin_lock(&line->lock); - if (tty->count == 1) { - if (!line->valid) { - err = -ENODEV; - goto out; - } - err = open_chan(&line->chan_list); - if(err) - goto out; - - /* Here the interrupt is registered.*/ - enable_chan(&line->chan_list, tty); - INIT_WORK(&line->task, line_timer_cb, tty); - } + tty->driver_data = line; + line->tty = tty; + if(!line->valid) + goto out; + + if(tty->count == 1){ + /* Here the device is opened, if necessary, and interrupt + * is registered. + */ + enable_chan(line); + INIT_WORK(&line->task, line_timer_cb, line); + + if(!line->sigio){ + chan_enable_winch(&line->chan_list, tty); + line->sigio = 1; + } - if(!line->sigio){ - chan_enable_winch(&line->chan_list, tty); - line->sigio = 1; + chan_window_size(&line->chan_list, &tty->winsize.ws_row, + &tty->winsize.ws_col); } - chan_window_size(&line->chan_list, &tty->winsize.ws_row, - &tty->winsize.ws_col); - line->count++; + err = 0; out: spin_unlock(&line->lock); return err; @@ -472,15 +451,14 @@ void line_close(struct tty_struct *tty, struct file * filp) /* We ignore the error anyway! */ flush_buffer(line); - line->count--; - if (tty->count == 1) { - line_disable(tty, -1); + if(tty->count == 1){ + line->tty = NULL; tty->driver_data = NULL; - } - if((line->count == 0) && line->sigio){ - unregister_winch(tty); - line->sigio = 0; + if(line->sigio){ + unregister_winch(tty); + line->sigio = 0; + } } spin_unlock_irq(&line->lock); @@ -491,7 +469,7 @@ void close_lines(struct line *lines, int nlines) int i; for(i = 0; i < nlines; i++) - close_chan(&lines[i].chan_list); + close_chan(&lines[i].chan_list, 0); } /* Common setup code for both startup command line and mconsole initialization. @@ -526,7 +504,7 @@ int line_setup(struct line *lines, unsigned int num, char *init) return 0; } else if (n >= 0){ - if (lines[n].count > 0) { + if (lines[n].tty != NULL) { printk("line_setup - device %d is open\n", n); return 0; } @@ -537,7 +515,7 @@ int line_setup(struct line *lines, unsigned int num, char *init) else { lines[n].init_str = init; lines[n].valid = 1; - } + } } } else { @@ -578,7 +556,7 @@ int line_config(struct line *lines, unsigned int num, char *str, return 1; line = &lines[n]; - return parse_chan_pair(line->init_str, &line->chan_list, n, opts); + return parse_chan_pair(line->init_str, line, n, opts); } int line_get_config(char *name, struct line *lines, unsigned int num, char *str, @@ -604,7 +582,7 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str, spin_lock(&line->lock); if(!line->valid) CONFIG_CHUNK(str, size, n, "none", 1); - else if(line->count == 0) + else if(line->tty == NULL) CONFIG_CHUNK(str, size, n, line->init_str, 1); else n = chan_config_string(&line->chan_list, str, size, error_out); spin_unlock(&line->lock); @@ -696,7 +674,7 @@ void lines_init(struct line *lines, int nlines, struct chan_opts *opts) if(line->init_str == NULL) printk("lines_init - kstrdup returned NULL\n"); - if(parse_chan_pair(line->init_str, &line->chan_list, i, opts)){ + if(parse_chan_pair(line->init_str, line, i, opts)){ printk("parse_chan_pair failed for device %d\n", i); line->valid = 0; } @@ -831,7 +809,7 @@ char *add_xterm_umid(char *base) umid = get_umid(1); if(umid == NULL) return base; - + len = strlen(base) + strlen(" ()") + strlen(umid) + 1; title = kmalloc(len, GFP_KERNEL); if(title == NULL){ diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h index 22bf3a7..84d1f64 100644 --- a/arch/um/include/chan_kern.h +++ b/arch/um/include/chan_kern.h @@ -14,11 +14,14 @@ struct chan { struct list_head list; + struct list_head free_list; + struct line *line; char *dev; unsigned int primary:1; unsigned int input:1; unsigned int output:1; unsigned int opened:1; + unsigned int enabled:1; int fd; struct chan_ops *ops; void *data; @@ -26,7 +29,7 @@ struct chan { extern void chan_interrupt(struct list_head *chans, struct work_struct *task, struct tty_struct *tty, int irq); -extern int parse_chan_pair(char *str, struct list_head *chans, int device, +extern int parse_chan_pair(char *str, struct line *line, int device, struct chan_opts *opts); extern int open_chan(struct list_head *chans); extern int write_chan(struct list_head *chans, const char *buf, int len, @@ -35,9 +38,9 @@ extern int console_write_chan(struct list_head *chans, const char *buf, int len); extern int console_open_chan(struct line *line, struct console *co, struct chan_opts *opts); -extern void close_chan(struct list_head *chans); extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); -extern void enable_chan(struct list_head *chans, struct tty_struct *tty); +extern void enable_chan(struct line *line); +extern void close_chan(struct list_head *chans, int delay_free_irq); extern int chan_window_size(struct list_head *chans, unsigned short *rows_out, unsigned short *cols_out); diff --git a/arch/um/include/irq_user.h b/arch/um/include/irq_user.h index f724b71..b61deb8 100644 --- a/arch/um/include/irq_user.h +++ b/arch/um/include/irq_user.h @@ -18,19 +18,8 @@ extern int deactivate_all_fds(void); extern void forward_interrupts(int pid); extern void init_irq_signals(int on_sigstack); extern void forward_ipi(int fd, int pid); -extern void free_irq_later(int irq, void *dev_id); extern int activate_ipi(int fd, int pid); extern unsigned long irq_lock(void); extern void irq_unlock(unsigned long flags); -#endif -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ +#endif diff --git a/arch/um/include/line.h b/arch/um/include/line.h index 474398b..e6cc3ab 100644 --- a/arch/um/include/line.h +++ b/arch/um/include/line.h @@ -32,6 +32,7 @@ struct line_driver { }; struct line { + struct tty_struct *tty; char *init_str; int init_pri; struct list_head chan_list; @@ -89,10 +90,9 @@ extern int line_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); extern char *add_xterm_umid(char *base); -extern int line_setup_irq(int fd, int input, int output, - struct tty_struct *tty); +extern int line_setup_irq(int fd, int input, int output, struct line *line, + void *data); extern void line_close_chan(struct line *line); -extern void line_disable(struct tty_struct *tty, int current_irq); extern struct tty_driver * line_register_devfs(struct lines *set, struct line_driver *line_driver, struct tty_operations *driver, diff --git a/arch/um/kernel/irq_user.c b/arch/um/kernel/irq_user.c index c3ccaf2..50a2aa3 100644 --- a/arch/um/kernel/irq_user.c +++ b/arch/um/kernel/irq_user.c @@ -29,7 +29,6 @@ struct irq_fd { int pid; int events; int current_events; - int freed; }; static struct irq_fd *active_fds = NULL; @@ -41,9 +40,11 @@ static int pollfds_size = 0; extern int io_count, intr_count; +extern void free_irqs(void); + void sigio_handler(int sig, union uml_pt_regs *regs) { - struct irq_fd *irq_fd, *next; + struct irq_fd *irq_fd; int i, n; if(smp_sigio_handler()) return; @@ -66,29 +67,15 @@ void sigio_handler(int sig, union uml_pt_regs *regs) irq_fd = irq_fd->next; } - for(irq_fd = active_fds; irq_fd != NULL; irq_fd = next){ - next = irq_fd->next; + for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){ if(irq_fd->current_events != 0){ irq_fd->current_events = 0; do_IRQ(irq_fd->irq, regs); - - /* This is here because the next irq may be - * freed in the handler. If a console goes - * away, both the read and write irqs will be - * freed. After do_IRQ, ->next will point to - * a good IRQ. - * Irqs can't be freed inside their handlers, - * so the next best thing is to have them - * marked as needing freeing, so that they - * can be freed here. - */ - next = irq_fd->next; - if(irq_fd->freed){ - free_irq(irq_fd->irq, irq_fd->id); - } } } } + + free_irqs(); } int activate_ipi(int fd, int pid) @@ -136,8 +123,7 @@ int activate_fd(int irq, int fd, int type, void *dev_id) .irq = irq, .pid = pid, .events = events, - .current_events = 0, - .freed = 0 } ); + .current_events = 0 } ); /* Critical section - locked by a spinlock because this stuff can * be changed from interrupt handlers. The stuff above is done @@ -313,26 +299,6 @@ static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out) return(irq); } -void free_irq_later(int irq, void *dev_id) -{ - struct irq_fd *irq_fd; - unsigned long flags; - - flags = irq_lock(); - for(irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next){ - if((irq_fd->irq == irq) && (irq_fd->id == dev_id)) - break; - } - if(irq_fd == NULL){ - printk("free_irq_later found no irq, irq = %d, " - "dev_id = 0x%p\n", irq, dev_id); - goto out; - } - irq_fd->freed = 1; - out: - irq_unlock(flags); -} - void reactivate_fd(int fd, int irqnum) { struct irq_fd *irq; -- cgit v1.1 From 9159c9dfffe1746d58b015ceaa3b7b8e99ee9d5c Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:58 -0800 Subject: [PATCH] uml: Fix flip_buf full handling When the tty flip_buf is full, it's a good idea to delay the input processing for a jiffy, rather than just scheduling the tasklet immediately. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/chan_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 1bb920c..36df55a 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -629,7 +629,7 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task, do { if((tty != NULL) && (tty->flip.count >= TTY_FLIPBUF_SIZE)){ - schedule_work(task); + schedule_delayed_work(task, 1); goto out; } err = chan->ops->read(chan->fd, &c, chan->data); -- cgit v1.1 From e4dcee8099802c71437a15b940f66106d9f88b2f Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:58 -0800 Subject: [PATCH] uml: Add throttling to console driver This patch adds support for throttling and unthrottling input when the tty driver can't handle it. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/chan_kern.c | 26 ++++++++++++++++++++++++++ arch/um/drivers/line.c | 29 +++++++++++++++++++++++++++-- arch/um/drivers/ssl.c | 14 ++------------ arch/um/drivers/stdio_console.c | 2 ++ arch/um/include/chan_kern.h | 2 ++ arch/um/include/line.h | 4 ++++ 6 files changed, 63 insertions(+), 14 deletions(-) diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c index 36df55a..cd13b91 100644 --- a/arch/um/drivers/chan_kern.c +++ b/arch/um/drivers/chan_kern.c @@ -312,6 +312,32 @@ void close_chan(struct list_head *chans, int delay_free_irq) } } +void deactivate_chan(struct list_head *chans, int irq) +{ + struct list_head *ele; + + struct chan *chan; + list_for_each(ele, chans) { + chan = list_entry(ele, struct chan, list); + + if(chan->enabled && chan->input) + deactivate_fd(chan->fd, irq); + } +} + +void reactivate_chan(struct list_head *chans, int irq) +{ + struct list_head *ele; + struct chan *chan; + + list_for_each(ele, chans) { + chan = list_entry(ele, struct chan, list); + + if(chan->enabled && chan->input) + reactivate_fd(chan->fd, irq); + } +} + int write_chan(struct list_head *chans, const char *buf, int len, int write_irq) { diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index 851a7c8..b8e3e80 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -36,8 +36,9 @@ static void line_timer_cb(void *arg) { struct line *line = arg; - chan_interrupt(&line->chan_list, &line->task, line->tty, - line->driver->read_irq); + if(!line->throttled) + chan_interrupt(&line->chan_list, &line->task, line->tty, + line->driver->read_irq); } /* Returns the free space inside the ring buffer of this line. @@ -340,6 +341,30 @@ int line_ioctl(struct tty_struct *tty, struct file * file, return ret; } +void line_throttle(struct tty_struct *tty) +{ + struct line *line = tty->driver_data; + + deactivate_chan(&line->chan_list, line->driver->read_irq); + line->throttled = 1; +} + +void line_unthrottle(struct tty_struct *tty) +{ + struct line *line = tty->driver_data; + + line->throttled = 0; + chan_interrupt(&line->chan_list, &line->task, tty, + line->driver->read_irq); + + /* Maybe there is enough stuff pending that calling the interrupt + * throttles us again. In this case, line->throttled will be 1 + * again and we shouldn't turn the interrupt back on. + */ + if(!line->throttled) + reactivate_chan(&line->chan_list, line->driver->read_irq); +} + static irqreturn_t line_write_interrupt(int irq, void *data, struct pt_regs *unused) { diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 6823dc5..a32ef55 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -109,16 +109,6 @@ static void ssl_flush_buffer(struct tty_struct *tty) return; } -static void ssl_throttle(struct tty_struct * tty) -{ - printk(KERN_ERR "Someone should implement ssl_throttle\n"); -} - -static void ssl_unthrottle(struct tty_struct * tty) -{ - printk(KERN_ERR "Someone should implement ssl_unthrottle\n"); -} - static void ssl_stop(struct tty_struct *tty) { printk(KERN_ERR "Someone should implement ssl_stop\n"); @@ -145,9 +135,9 @@ static struct tty_operations ssl_ops = { .flush_chars = line_flush_chars, .set_termios = line_set_termios, .ioctl = line_ioctl, + .throttle = line_throttle, + .unthrottle = line_unthrottle, #if 0 - .throttle = ssl_throttle, - .unthrottle = ssl_unthrottle, .stop = ssl_stop, .start = ssl_start, .hangup = ssl_hangup, diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 6d4edda..61db8b2 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -122,6 +122,8 @@ static struct tty_operations console_ops = { .flush_chars = line_flush_chars, .set_termios = line_set_termios, .ioctl = line_ioctl, + .throttle = line_throttle, + .unthrottle = line_unthrottle, }; static void uml_console_write(struct console *console, const char *string, diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h index 84d1f64..1bb5e9d 100644 --- a/arch/um/include/chan_kern.h +++ b/arch/um/include/chan_kern.h @@ -38,6 +38,8 @@ extern int console_write_chan(struct list_head *chans, const char *buf, int len); extern int console_open_chan(struct line *line, struct console *co, struct chan_opts *opts); +extern void deactivate_chan(struct list_head *chans, int irq); +extern void reactivate_chan(struct list_head *chans, int irq); extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); extern void enable_chan(struct line *line); extern void close_chan(struct list_head *chans, int delay_free_irq); diff --git a/arch/um/include/line.h b/arch/um/include/line.h index e6cc3ab..6f4d680 100644 --- a/arch/um/include/line.h +++ b/arch/um/include/line.h @@ -38,6 +38,7 @@ struct line { struct list_head chan_list; int valid; int count; + int throttled; /*This lock is actually, mostly, local to*/ spinlock_t lock; @@ -60,6 +61,7 @@ struct line { { init_str : str, \ init_pri : INIT_STATIC, \ valid : 1, \ + throttled : 0, \ lock : SPIN_LOCK_UNLOCKED, \ buffer : NULL, \ head : NULL, \ @@ -88,6 +90,8 @@ extern void line_flush_chars(struct tty_struct *tty); extern int line_write_room(struct tty_struct *tty); extern int line_ioctl(struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); +extern void line_throttle(struct tty_struct *tty); +extern void line_unthrottle(struct tty_struct *tty); extern char *add_xterm_umid(char *base); extern int line_setup_irq(int fd, int input, int output, struct line *line, -- cgit v1.1 From 2264c475e4bf7427e59921953c89a5693ecb506f Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:18:59 -0800 Subject: [PATCH] uml: separate libc-dependent umid code I reworked Gennady's umid OS abstraction patch because the code shouldn't be moved entirely to os. As it turns out, I moved most of it anyway. This patch is the minimal one needed to move the code and have it work. It turns out that the concept of the umid is OS-independent, but almost everything else about the implementation is OS-dependent. This is code movement without cleanup - a follow-on patch tidies everything up without shuffling code around. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/kern.h | 13 +- arch/um/include/os.h | 17 +-- arch/um/kernel/Makefile | 6 +- arch/um/kernel/process_kern.c | 4 - arch/um/kernel/umid.c | 327 +++--------------------------------------- arch/um/os-Linux/Makefile | 4 +- arch/um/os-Linux/umid.c | 292 +++++++++++++++++++++++++++++++++++++ 7 files changed, 324 insertions(+), 339 deletions(-) create mode 100644 arch/um/os-Linux/umid.c diff --git a/arch/um/include/kern.h b/arch/um/include/kern.h index 1e31707..7d223be 100644 --- a/arch/um/include/kern.h +++ b/arch/um/include/kern.h @@ -17,7 +17,7 @@ extern int errno; extern int clone(int (*proc)(void *), void *sp, int flags, void *data); extern int sleep(int); -extern int printf(char *fmt, ...); +extern int printf(const char *fmt, ...); extern char *strerror(int errnum); extern char *ptsname(int __fd); extern int munmap(void *, int); @@ -35,15 +35,6 @@ extern int read(unsigned int, char *, int); extern int pipe(int *); extern int sched_yield(void); extern int ptrace(int op, int pid, long addr, long data); + #endif -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 2cccfa5..258444e 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -213,15 +213,10 @@ extern int run_helper_thread(int (*proc)(void *), void *arg, int stack_order); extern int helper_wait(int pid); -#endif +/* umid.c */ -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ +extern int umid_file_name(char *name, char *buf, int len); +extern int set_umid(char *name, int (*printer)(const char *fmt, ...)); +extern char *get_umid(int only_if_set); + +#endif diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 3de9d21..6f77005 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile @@ -10,8 +10,8 @@ obj-y = config.o exec_kern.o exitcode.o \ init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ signal_kern.o signal_user.o smp.o syscall_kern.o sysrq.o time.o \ - time_kern.o tlb.o trap_kern.o trap_user.o uaccess.o um_arch.o \ - umid.o user_util.o + time_kern.o tlb.o trap_kern.o trap_user.o uaccess.o um_arch.o umid.o \ + user_util.o obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o obj-$(CONFIG_GPROF) += gprof_syms.o @@ -24,7 +24,7 @@ obj-$(CONFIG_MODE_SKAS) += skas/ user-objs-$(CONFIG_TTY_LOG) += tty_log.o -USER_OBJS := $(user-objs-y) config.o time.o tty_log.o umid.o user_util.o +USER_OBJS := $(user-objs-y) config.o time.o tty_log.o user_util.o include arch/um/scripts/Makefile.rules diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c index 34b54a3..651abf2 100644 --- a/arch/um/kernel/process_kern.c +++ b/arch/um/kernel/process_kern.c @@ -324,10 +324,6 @@ int user_context(unsigned long sp) return(stack != (unsigned long) current_thread); } -extern void remove_umid_dir(void); - -__uml_exitcall(remove_umid_dir); - extern exitcall_t __uml_exitcall_begin, __uml_exitcall_end; void do_uml_exitcalls(void) diff --git a/arch/um/kernel/umid.c b/arch/um/kernel/umid.c index 0b21d59..772c7cf 100644 --- a/arch/um/kernel/umid.c +++ b/arch/um/kernel/umid.c @@ -3,61 +3,34 @@ * Licensed under the GPL */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "user.h" -#include "umid.h" +#include "linux/stddef.h" +#include "linux/kernel.h" +#include "asm/errno.h" #include "init.h" #include "os.h" -#include "user_util.h" -#include "choose-mode.h" +#include "kern.h" -#define UMID_LEN 64 -#define UML_DIR "~/.uml/" - -/* Changed by set_umid and make_umid, which are run early in boot */ -static char umid[UMID_LEN] = { 0 }; - -/* Changed by set_uml_dir and make_uml_dir, which are run early in boot */ -static char *uml_dir = UML_DIR; - -/* Changed by set_umid */ -static int umid_is_random = 1; +/* Changed by set_umid_arg and umid_file_name */ +int umid_is_random = 0; static int umid_inited = 0; -/* Have we created the files? Should we remove them? */ -static int umid_owned = 0; -static int make_umid(int (*printer)(const char *fmt, ...)); - -static int __init set_umid(char *name, int is_random, - int (*printer)(const char *fmt, ...)) +static int __init set_umid_arg(char *name, int *add) { - if(umid_inited){ - (*printer)("Unique machine name can't be set twice\n"); - return(-1); - } + int err; - if(strlen(name) > UMID_LEN - 1) - (*printer)("Unique machine name is being truncated to %d " - "characters\n", UMID_LEN); - strlcpy(umid, name, sizeof(umid)); + if(umid_inited) + return 0; - umid_is_random = is_random; - umid_inited = 1; - return 0; -} - -static int __init set_umid_arg(char *name, int *add) -{ *add = 0; - return(set_umid(name, 0, printf)); + err = set_umid(name, printf); + if(err == -EEXIST){ + printf("umid '%s' already in use\n", name); + umid_is_random = 1; + } + else if(!err) + umid_inited = 1; + + return 0; } __uml_setup("umid=", set_umid_arg, @@ -66,265 +39,3 @@ __uml_setup("umid=", set_umid_arg, " is used for naming the pid file and management console socket.\n\n" ); -int __init umid_file_name(char *name, char *buf, int len) -{ - int n; - - if(!umid_inited && make_umid(printk)) return(-1); - - n = strlen(uml_dir) + strlen(umid) + strlen(name) + 1; - if(n > len){ - printk("umid_file_name : buffer too short\n"); - return(-1); - } - - sprintf(buf, "%s%s/%s", uml_dir, umid, name); - return(0); -} - -extern int tracing_pid; - -static void __init create_pid_file(void) -{ - char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; - char pid[sizeof("nnnnn\0")]; - int fd, n; - - if(umid_file_name("pid", file, sizeof(file))) - return; - - fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), - 0644); - if(fd < 0){ - printf("Open of machine pid file \"%s\" failed: %s\n", - file, strerror(-fd)); - return; - } - - sprintf(pid, "%d\n", os_getpid()); - n = os_write_file(fd, pid, strlen(pid)); - if(n != strlen(pid)) - printf("Write of pid file failed - err = %d\n", -n); - os_close_file(fd); -} - -static int actually_do_remove(char *dir) -{ - DIR *directory; - struct dirent *ent; - int len; - char file[256]; - - directory = opendir(dir); - if(directory == NULL){ - printk("actually_do_remove : couldn't open directory '%s', " - "errno = %d\n", dir, errno); - return(1); - } - while((ent = readdir(directory)) != NULL){ - if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) - continue; - len = strlen(dir) + sizeof("/") + strlen(ent->d_name) + 1; - if(len > sizeof(file)){ - printk("Not deleting '%s' from '%s' - name too long\n", - ent->d_name, dir); - continue; - } - sprintf(file, "%s/%s", dir, ent->d_name); - if(unlink(file) < 0){ - printk("actually_do_remove : couldn't remove '%s' " - "from '%s', errno = %d\n", ent->d_name, dir, - errno); - return(1); - } - } - if(rmdir(dir) < 0){ - printk("actually_do_remove : couldn't rmdir '%s', " - "errno = %d\n", dir, errno); - return(1); - } - return(0); -} - -void remove_umid_dir(void) -{ - char dir[strlen(uml_dir) + UMID_LEN + 1]; - if (!umid_owned) - return; - - sprintf(dir, "%s%s", uml_dir, umid); - actually_do_remove(dir); -} - -char *get_umid(int only_if_set) -{ - if(only_if_set && umid_is_random) - return NULL; - return umid; -} - -static int not_dead_yet(char *dir) -{ - char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; - char pid[sizeof("nnnnn\0")], *end; - int dead, fd, p, n; - - sprintf(file, "%s/pid", dir); - dead = 0; - fd = os_open_file(file, of_read(OPENFLAGS()), 0); - if(fd < 0){ - if(fd != -ENOENT){ - printk("not_dead_yet : couldn't open pid file '%s', " - "err = %d\n", file, -fd); - return(1); - } - dead = 1; - } - if(fd > 0){ - n = os_read_file(fd, pid, sizeof(pid)); - if(n < 0){ - printk("not_dead_yet : couldn't read pid file '%s', " - "err = %d\n", file, -n); - return(1); - } - p = strtoul(pid, &end, 0); - if(end == pid){ - printk("not_dead_yet : couldn't parse pid file '%s', " - "errno = %d\n", file, errno); - dead = 1; - } - if(((kill(p, 0) < 0) && (errno == ESRCH)) || - (p == CHOOSE_MODE(tracing_pid, os_getpid()))) - dead = 1; - } - if(!dead) - return(1); - return(actually_do_remove(dir)); -} - -static int __init set_uml_dir(char *name, int *add) -{ - if((strlen(name) > 0) && (name[strlen(name) - 1] != '/')){ - uml_dir = malloc(strlen(name) + 2); - if(uml_dir == NULL){ - printf("Failed to malloc uml_dir - error = %d\n", - errno); - uml_dir = name; - /* Return 0 here because do_initcalls doesn't look at - * the return value. - */ - return(0); - } - sprintf(uml_dir, "%s/", name); - } - else uml_dir = name; - return(0); -} - -static int __init make_uml_dir(void) -{ - char dir[MAXPATHLEN + 1] = { '\0' }; - int len; - - if(*uml_dir == '~'){ - char *home = getenv("HOME"); - - if(home == NULL){ - printf("make_uml_dir : no value in environment for " - "$HOME\n"); - exit(1); - } - strlcpy(dir, home, sizeof(dir)); - uml_dir++; - } - strlcat(dir, uml_dir, sizeof(dir)); - len = strlen(dir); - if (len > 0 && dir[len - 1] != '/') - strlcat(dir, "/", sizeof(dir)); - - uml_dir = malloc(strlen(dir) + 1); - if (uml_dir == NULL) { - printf("make_uml_dir : malloc failed, errno = %d\n", errno); - exit(1); - } - strcpy(uml_dir, dir); - - if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){ - printf("Failed to mkdir %s: %s\n", uml_dir, strerror(errno)); - return(-1); - } - return 0; -} - -static int __init make_umid(int (*printer)(const char *fmt, ...)) -{ - int fd, err; - char tmp[strlen(uml_dir) + UMID_LEN + 1]; - - strlcpy(tmp, uml_dir, sizeof(tmp)); - - if(!umid_inited){ - strcat(tmp, "XXXXXX"); - fd = mkstemp(tmp); - if(fd < 0){ - (*printer)("make_umid - mkstemp(%s) failed: %s\n", - tmp,strerror(errno)); - return(1); - } - - os_close_file(fd); - /* There's a nice tiny little race between this unlink and - * the mkdir below. It'd be nice if there were a mkstemp - * for directories. - */ - unlink(tmp); - set_umid(&tmp[strlen(uml_dir)], 1, printer); - } - - sprintf(tmp, "%s%s", uml_dir, umid); - - err = mkdir(tmp, 0777); - if(err < 0){ - if(errno == EEXIST){ - if(not_dead_yet(tmp)){ - (*printer)("umid '%s' is in use\n", umid); - umid_owned = 0; - return(-1); - } - err = mkdir(tmp, 0777); - } - } - if(err < 0){ - (*printer)("Failed to create %s - errno = %d\n", umid, errno); - return(-1); - } - - umid_owned = 1; - return 0; -} - -__uml_setup("uml_dir=", set_uml_dir, -"uml_dir=\n" -" The location to place the pid and umid files.\n\n" -); - -static int __init make_umid_setup(void) -{ - /* one function with the ordering we need ... */ - make_uml_dir(); - make_umid(printf); - create_pid_file(); - return 0; -} -__uml_postsetup(make_umid_setup); - -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index b83ac8e..11e30b13 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -4,11 +4,11 @@ # obj-y = aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ - start_up.o time.o tt.o tty.o uaccess.o user_syms.o drivers/ \ + start_up.o time.o tt.o tty.o uaccess.o umid.o user_syms.o drivers/ \ sys-$(SUBARCH)/ USER_OBJS := aio.o elf_aux.o file.o helper.o main.o mem.o process.o signal.o \ - start_up.o time.o tt.o tty.o uaccess.o + start_up.o time.o tt.o tty.o uaccess.o umid.o elf_aux.o: $(ARCH_DIR)/kernel-offsets.h CFLAGS_elf_aux.o += -I$(objtree)/arch/um diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c new file mode 100644 index 0000000..77d69a3 --- /dev/null +++ b/arch/um/os-Linux/umid.c @@ -0,0 +1,292 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "init.h" +#include "os.h" +#include "user.h" +#include "mode.h" + +#define UML_DIR "~/.uml/" + +#define UMID_LEN 64 + +/* Changed by set_umid, which is run early in boot */ +char umid[UMID_LEN] = { 0 }; + +/* Changed by set_uml_dir and make_uml_dir, which are run early in boot */ +static char *uml_dir = UML_DIR; + +static int __init make_uml_dir(void) +{ + char dir[512] = { '\0' }; + int len; + + if(*uml_dir == '~'){ + char *home = getenv("HOME"); + + if(home == NULL){ + printf("make_uml_dir : no value in environment for " + "$HOME\n"); + exit(1); + } + strlcpy(dir, home, sizeof(dir)); + uml_dir++; + } + strlcat(dir, uml_dir, sizeof(dir)); + len = strlen(dir); + if (len > 0 && dir[len - 1] != '/') + strlcat(dir, "/", sizeof(dir)); + + uml_dir = malloc(strlen(dir) + 1); + if (uml_dir == NULL) { + printf("make_uml_dir : malloc failed, errno = %d\n", errno); + exit(1); + } + strcpy(uml_dir, dir); + + if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){ + printf("Failed to mkdir '%s': %s\n", uml_dir, strerror(errno)); + return(-1); + } + return 0; +} + +static int actually_do_remove(char *dir) +{ + DIR *directory; + struct dirent *ent; + int len; + char file[256]; + + directory = opendir(dir); + if(directory == NULL){ + printk("actually_do_remove : couldn't open directory '%s', " + "errno = %d\n", dir, errno); + return(1); + } + while((ent = readdir(directory)) != NULL){ + if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) + continue; + len = strlen(dir) + sizeof("/") + strlen(ent->d_name) + 1; + if(len > sizeof(file)){ + printk("Not deleting '%s' from '%s' - name too long\n", + ent->d_name, dir); + continue; + } + sprintf(file, "%s/%s", dir, ent->d_name); + if(unlink(file) < 0){ + printk("actually_do_remove : couldn't remove '%s' " + "from '%s', errno = %d\n", ent->d_name, dir, + errno); + return(1); + } + } + if(rmdir(dir) < 0){ + printk("actually_do_remove : couldn't rmdir '%s', " + "errno = %d\n", dir, errno); + return(1); + } + return(0); +} + +extern int tracing_pid; + +static int not_dead_yet(char *dir) +{ + char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; + char pid[sizeof("nnnnn\0")], *end; + int dead, fd, p, n; + + sprintf(file, "%s/pid", dir); + dead = 0; + fd = os_open_file(file, of_read(OPENFLAGS()), 0); + if(fd < 0){ + if(fd != -ENOENT){ + printk("not_dead_yet : couldn't open pid file '%s', " + "err = %d\n", file, -fd); + return(1); + } + dead = 1; + } + if(fd > 0){ + n = os_read_file(fd, pid, sizeof(pid)); + if(n < 0){ + printk("not_dead_yet : couldn't read pid file '%s', " + "err = %d\n", file, -n); + return(1); + } + p = strtoul(pid, &end, 0); + if(end == pid){ + printk("not_dead_yet : couldn't parse pid file '%s', " + "errno = %d\n", file, errno); + dead = 1; + } + if(((kill(p, 0) < 0) && (errno == ESRCH)) || + (p == CHOOSE_MODE(tracing_pid, os_getpid()))) + dead = 1; + } + if(!dead) + return(1); + return(actually_do_remove(dir)); +} + +static void __init create_pid_file(void) +{ + char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; + char pid[sizeof("nnnnn\0")]; + int fd, n; + + if(umid_file_name("pid", file, sizeof(file))) + return; + + fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), + 0644); + if(fd < 0){ + printf("Open of machine pid file \"%s\" failed: %s\n", + file, strerror(-fd)); + return; + } + + sprintf(pid, "%d\n", os_getpid()); + n = os_write_file(fd, pid, strlen(pid)); + if(n != strlen(pid)) + printf("Write of pid file failed - err = %d\n", -n); + os_close_file(fd); +} + +int __init set_umid(char *name, int (*printer)(const char *fmt, ...)) +{ + if(strlen(name) > UMID_LEN - 1) + (*printer)("Unique machine name is being truncated to %d " + "characters\n", UMID_LEN); + strlcpy(umid, name, sizeof(umid)); + + return 0; +} + +static int umid_setup = 0; + +int __init make_umid(int (*printer)(const char *fmt, ...)) +{ + int fd, err; + char tmp[256]; + + make_uml_dir(); + + if(*umid == '\0'){ + strlcpy(tmp, uml_dir, sizeof(tmp)); + strcat(tmp, "XXXXXX"); + fd = mkstemp(tmp); + if(fd < 0){ + (*printer)("make_umid - mkstemp(%s) failed: %s\n", + tmp,strerror(errno)); + return(1); + } + + os_close_file(fd); + /* There's a nice tiny little race between this unlink and + * the mkdir below. It'd be nice if there were a mkstemp + * for directories. + */ + unlink(tmp); + set_umid(&tmp[strlen(uml_dir)], printer); + } + + sprintf(tmp, "%s%s", uml_dir, umid); + err = mkdir(tmp, 0777); + if(err < 0){ + if(errno == EEXIST){ + if(not_dead_yet(tmp)) + return -EEXIST; + err = mkdir(tmp, 0777); + } + } + if(err < 0){ + (*printer)("Failed to create %s - errno = %d\n", umid, errno); + return(-1); + } + + umid_setup = 1; + + create_pid_file(); + + return 0; +} + +static int __init make_umid_init(void) +{ + make_umid(printk); + + return(0); +} + +__initcall(make_umid_init); + +int __init umid_file_name(char *name, char *buf, int len) +{ + int n, err; + + if(!umid_setup){ + err = make_umid(printk); + if(err) + return err; + } + + n = strlen(uml_dir) + strlen(umid) + strlen("/") + strlen(name) + 1; + if(n > len){ + printk("umid_file_name : buffer too short\n"); + return(-1); + } + + sprintf(buf, "%s%s/%s", uml_dir, umid, name); + return(0); +} + +extern int umid_is_random; + +char *get_umid(int only_if_set) +{ + if(only_if_set && umid_is_random) + return NULL; + return umid; +} + +static int __init set_uml_dir(char *name, int *add) +{ + if((strlen(name) > 0) && (name[strlen(name) - 1] != '/')){ + uml_dir = malloc(strlen(name) + 2); + if(uml_dir == NULL){ + printf("Failed to malloc uml_dir - error = %d\n", + errno); + uml_dir = name; + /* Return 0 here because do_initcalls doesn't look at + * the return value. + */ + return(0); + } + sprintf(uml_dir, "%s/", name); + } + else uml_dir = name; + return(0); +} + +__uml_setup("uml_dir=", set_uml_dir, +"uml_dir=\n" +" The location to place the pid and umid files.\n\n" +); + +static void remove_umid_dir(void) +{ + char dir[strlen(uml_dir) + UMID_LEN + 1]; + + sprintf(dir, "%s%s", uml_dir, umid); + actually_do_remove(dir); +} + +__uml_exitcall(remove_umid_dir); -- cgit v1.1 From 7eebe8a9c51686927709a57b1f2725d371014abc Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:19:01 -0800 Subject: [PATCH] uml: umid cleanup This patch cleans up the umid code: - The only_if_set argument to get_umid is gone. - get_umid returns an empty string rather than NULL if there is no umid. - umid_is_random is gone since its users went away. - Some printfs were turned into printks because the code runs late enough that printk is working. - Error paths were cleaned up. - Some functions now return an error and let the caller print the error message rather than printing it themselves. This eliminates the practice of passing a pointer to printf or printk in, depending on where in the boot process we are. - Major tidying of not_dead_yet - mostly error path cleanup, plus a comment explaining why it doesn't react to errors the way you might expect. - Calls to os_* interfaces that were moved under os are changed back to their native libc forms. - snprintf, strlcpy, and their bounds-checking friends are used more often, replacing by-hand bounds checking in some places. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/line.c | 4 +- arch/um/include/os.h | 4 +- arch/um/include/user_util.h | 1 - arch/um/kernel/um_arch.c | 4 +- arch/um/kernel/umid.c | 12 +- arch/um/os-Linux/umid.c | 265 +++++++++++++++++++++++++------------------- 6 files changed, 164 insertions(+), 126 deletions(-) diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index b8e3e80..a3c3937 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -831,8 +831,8 @@ char *add_xterm_umid(char *base) char *umid, *title; int len; - umid = get_umid(1); - if(umid == NULL) + umid = get_umid(); + if(*umid == '\0') return base; len = strlen(base) + strlen(" ()") + strlen(umid) + 1; diff --git a/arch/um/include/os.h b/arch/um/include/os.h index 258444e..c279ee6 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h @@ -216,7 +216,7 @@ extern int helper_wait(int pid); /* umid.c */ extern int umid_file_name(char *name, char *buf, int len); -extern int set_umid(char *name, int (*printer)(const char *fmt, ...)); -extern char *get_umid(int only_if_set); +extern int set_umid(char *name); +extern char *get_umid(void); #endif diff --git a/arch/um/include/user_util.h b/arch/um/include/user_util.h index bb505e0..b998400 100644 --- a/arch/um/include/user_util.h +++ b/arch/um/include/user_util.h @@ -64,7 +64,6 @@ extern void setup_machinename(char *machine_out); extern void setup_hostinfo(void); extern void do_exec(int old_pid, int new_pid); extern void tracer_panic(char *msg, ...); -extern char *get_umid(int only_if_set); extern void do_longjmp(void *p, int val); extern int detach(int pid, int sig); extern int attach(int pid); diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 142a949..26626b2b 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c @@ -146,8 +146,8 @@ void set_cmdline(char *cmd) if(CHOOSE_MODE(honeypot, 0)) return; - umid = get_umid(1); - if(umid != NULL){ + umid = get_umid(); + if(*umid != '\0'){ snprintf(argv1_begin, (argv1_end - argv1_begin) * sizeof(*ptr), "(%s) ", umid); diff --git a/arch/um/kernel/umid.c b/arch/um/kernel/umid.c index 772c7cf..4eaee82 100644 --- a/arch/um/kernel/umid.c +++ b/arch/um/kernel/umid.c @@ -3,15 +3,13 @@ * Licensed under the GPL */ -#include "linux/stddef.h" -#include "linux/kernel.h" #include "asm/errno.h" #include "init.h" #include "os.h" #include "kern.h" +#include "linux/kernel.h" -/* Changed by set_umid_arg and umid_file_name */ -int umid_is_random = 0; +/* Changed by set_umid_arg */ static int umid_inited = 0; static int __init set_umid_arg(char *name, int *add) @@ -22,11 +20,9 @@ static int __init set_umid_arg(char *name, int *add) return 0; *add = 0; - err = set_umid(name, printf); - if(err == -EEXIST){ + err = set_umid(name); + if(err == -EEXIST) printf("umid '%s' already in use\n", name); - umid_is_random = 1; - } else if(!err) umid_inited = 1; diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c index 77d69a3..ecf107a 100644 --- a/arch/um/os-Linux/umid.c +++ b/arch/um/os-Linux/umid.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include "init.h" @@ -25,15 +26,16 @@ static char *uml_dir = UML_DIR; static int __init make_uml_dir(void) { char dir[512] = { '\0' }; - int len; + int len, err; if(*uml_dir == '~'){ char *home = getenv("HOME"); + err = -ENOENT; if(home == NULL){ - printf("make_uml_dir : no value in environment for " + printk("make_uml_dir : no value in environment for " "$HOME\n"); - exit(1); + goto err; } strlcpy(dir, home, sizeof(dir)); uml_dir++; @@ -43,18 +45,26 @@ static int __init make_uml_dir(void) if (len > 0 && dir[len - 1] != '/') strlcat(dir, "/", sizeof(dir)); + err = -ENOMEM; uml_dir = malloc(strlen(dir) + 1); if (uml_dir == NULL) { printf("make_uml_dir : malloc failed, errno = %d\n", errno); - exit(1); + goto err; } strcpy(uml_dir, dir); if((mkdir(uml_dir, 0777) < 0) && (errno != EEXIST)){ printf("Failed to mkdir '%s': %s\n", uml_dir, strerror(errno)); - return(-1); + err = -errno; + goto err_free; } return 0; + +err_free: + free(uml_dir); +err: + uml_dir = NULL; + return err; } static int actually_do_remove(char *dir) @@ -65,75 +75,88 @@ static int actually_do_remove(char *dir) char file[256]; directory = opendir(dir); - if(directory == NULL){ - printk("actually_do_remove : couldn't open directory '%s', " - "errno = %d\n", dir, errno); - return(1); - } + if(directory == NULL) + return -errno; + while((ent = readdir(directory)) != NULL){ if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) continue; len = strlen(dir) + sizeof("/") + strlen(ent->d_name) + 1; - if(len > sizeof(file)){ - printk("Not deleting '%s' from '%s' - name too long\n", - ent->d_name, dir); - continue; - } + if(len > sizeof(file)) + return -E2BIG; + sprintf(file, "%s/%s", dir, ent->d_name); - if(unlink(file) < 0){ - printk("actually_do_remove : couldn't remove '%s' " - "from '%s', errno = %d\n", ent->d_name, dir, - errno); - return(1); - } - } - if(rmdir(dir) < 0){ - printk("actually_do_remove : couldn't rmdir '%s', " - "errno = %d\n", dir, errno); - return(1); + if(unlink(file) < 0) + return -errno; } - return(0); + if(rmdir(dir) < 0) + return -errno; + + return 0; } -extern int tracing_pid; +/* This says that there isn't already a user of the specified directory even if + * there are errors during the checking. This is because if these errors + * happen, the directory is unusable by the pre-existing UML, so we might as + * well take it over. This could happen either by + * the existing UML somehow corrupting its umid directory + * something other than UML sticking stuff in the directory + * this boot racing with a shutdown of the other UML + * In any of these cases, the directory isn't useful for anything else. + */ static int not_dead_yet(char *dir) { char file[strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")]; char pid[sizeof("nnnnn\0")], *end; - int dead, fd, p, n; + int dead, fd, p, n, err; + + n = snprintf(file, sizeof(file), "%s/pid", dir); + if(n >= sizeof(file)){ + printk("not_dead_yet - pid filename too long\n"); + err = -E2BIG; + goto out; + } - sprintf(file, "%s/pid", dir); dead = 0; - fd = os_open_file(file, of_read(OPENFLAGS()), 0); + fd = open(file, O_RDONLY); if(fd < 0){ if(fd != -ENOENT){ printk("not_dead_yet : couldn't open pid file '%s', " "err = %d\n", file, -fd); - return(1); } - dead = 1; + goto out; } - if(fd > 0){ - n = os_read_file(fd, pid, sizeof(pid)); - if(n < 0){ - printk("not_dead_yet : couldn't read pid file '%s', " - "err = %d\n", file, -n); - return(1); - } - p = strtoul(pid, &end, 0); - if(end == pid){ - printk("not_dead_yet : couldn't parse pid file '%s', " - "errno = %d\n", file, errno); - dead = 1; - } - if(((kill(p, 0) < 0) && (errno == ESRCH)) || - (p == CHOOSE_MODE(tracing_pid, os_getpid()))) - dead = 1; + + err = 0; + n = read(fd, pid, sizeof(pid)); + if(n <= 0){ + printk("not_dead_yet : couldn't read pid file '%s', " + "err = %d\n", file, -n); + goto out_close; + } + + p = strtoul(pid, &end, 0); + if(end == pid){ + printk("not_dead_yet : couldn't parse pid file '%s', " + "errno = %d\n", file, errno); + goto out_close; } - if(!dead) - return(1); - return(actually_do_remove(dir)); + + if((kill(p, 0) == 0) || (errno != ESRCH)) + return 1; + + err = actually_do_remove(dir); + if(err) + printk("not_dead_yet - actually_do_remove failed with " + "err = %d\n", err); + + return err; + + out_close: + close(fd); + out: + return 0; } static void __init create_pid_file(void) @@ -145,26 +168,26 @@ static void __init create_pid_file(void) if(umid_file_name("pid", file, sizeof(file))) return; - fd = os_open_file(file, of_create(of_excl(of_rdwr(OPENFLAGS()))), - 0644); + fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644); if(fd < 0){ - printf("Open of machine pid file \"%s\" failed: %s\n", + printk("Open of machine pid file \"%s\" failed: %s\n", file, strerror(-fd)); return; } - sprintf(pid, "%d\n", os_getpid()); - n = os_write_file(fd, pid, strlen(pid)); + snprintf(pid, sizeof(pid), "%d\n", getpid()); + n = write(fd, pid, strlen(pid)); if(n != strlen(pid)) - printf("Write of pid file failed - err = %d\n", -n); - os_close_file(fd); + printk("Write of pid file failed - err = %d\n", -n); + + close(fd); } -int __init set_umid(char *name, int (*printer)(const char *fmt, ...)) +int __init set_umid(char *name) { if(strlen(name) > UMID_LEN - 1) - (*printer)("Unique machine name is being truncated to %d " - "characters\n", UMID_LEN); + return -E2BIG; + strlcpy(umid, name, sizeof(umid)); return 0; @@ -172,44 +195,56 @@ int __init set_umid(char *name, int (*printer)(const char *fmt, ...)) static int umid_setup = 0; -int __init make_umid(int (*printer)(const char *fmt, ...)) +int __init make_umid(void) { int fd, err; char tmp[256]; + if(umid_setup) + return 0; + make_uml_dir(); if(*umid == '\0'){ strlcpy(tmp, uml_dir, sizeof(tmp)); - strcat(tmp, "XXXXXX"); + strlcat(tmp, "XXXXXX", sizeof(tmp)); fd = mkstemp(tmp); if(fd < 0){ - (*printer)("make_umid - mkstemp(%s) failed: %s\n", - tmp,strerror(errno)); - return(1); + printk("make_umid - mkstemp(%s) failed: %s\n", + tmp, strerror(errno)); + err = -errno; + goto err; } - os_close_file(fd); + close(fd); + + set_umid(&tmp[strlen(uml_dir)]); + /* There's a nice tiny little race between this unlink and * the mkdir below. It'd be nice if there were a mkstemp * for directories. */ - unlink(tmp); - set_umid(&tmp[strlen(uml_dir)], printer); + if(unlink(tmp)){ + err = -errno; + goto err; + } } - sprintf(tmp, "%s%s", uml_dir, umid); + snprintf(tmp, sizeof(tmp), "%s%s", uml_dir, umid); err = mkdir(tmp, 0777); if(err < 0){ - if(errno == EEXIST){ - if(not_dead_yet(tmp)) - return -EEXIST; - err = mkdir(tmp, 0777); - } + err = -errno; + if(errno != EEXIST) + goto err; + + if(not_dead_yet(tmp) < 0) + goto err; + + err = mkdir(tmp, 0777); } if(err < 0){ - (*printer)("Failed to create %s - errno = %d\n", umid, errno); - return(-1); + printk("Failed to create '%s' - err = %d\n", umid, err); + goto err_rmdir; } umid_setup = 1; @@ -217,13 +252,18 @@ int __init make_umid(int (*printer)(const char *fmt, ...)) create_pid_file(); return 0; + + err_rmdir: + rmdir(tmp); + err: + return err; } static int __init make_umid_init(void) { - make_umid(printk); + make_umid(); - return(0); + return 0; } __initcall(make_umid_init); @@ -232,48 +272,48 @@ int __init umid_file_name(char *name, char *buf, int len) { int n, err; - if(!umid_setup){ - err = make_umid(printk); - if(err) - return err; - } + err = make_umid(); + if(err) + return err; - n = strlen(uml_dir) + strlen(umid) + strlen("/") + strlen(name) + 1; - if(n > len){ + n = snprintf(buf, len, "%s%s/%s", uml_dir, umid, name); + if(n >= len){ printk("umid_file_name : buffer too short\n"); - return(-1); + return -E2BIG; } - sprintf(buf, "%s%s/%s", uml_dir, umid, name); - return(0); + return 0; } -extern int umid_is_random; - -char *get_umid(int only_if_set) +char *get_umid(void) { - if(only_if_set && umid_is_random) - return NULL; return umid; } static int __init set_uml_dir(char *name, int *add) { - if((strlen(name) > 0) && (name[strlen(name) - 1] != '/')){ - uml_dir = malloc(strlen(name) + 2); - if(uml_dir == NULL){ - printf("Failed to malloc uml_dir - error = %d\n", - errno); - uml_dir = name; - /* Return 0 here because do_initcalls doesn't look at - * the return value. - */ - return(0); - } - sprintf(uml_dir, "%s/", name); + if(*name == '\0'){ + printf("uml_dir can't be an empty string\n"); + return 0; } - else uml_dir = name; - return(0); + + if(name[strlen(name) - 1] == '/'){ + uml_dir = name; + return 0; + } + + uml_dir = malloc(strlen(name) + 2); + if(uml_dir == NULL){ + printf("Failed to malloc uml_dir - error = %d\n", errno); + + /* Return 0 here because do_initcalls doesn't look at + * the return value. + */ + return 0; + } + sprintf(uml_dir, "%s/", name); + + return 0; } __uml_setup("uml_dir=", set_uml_dir, @@ -283,10 +323,13 @@ __uml_setup("uml_dir=", set_uml_dir, static void remove_umid_dir(void) { - char dir[strlen(uml_dir) + UMID_LEN + 1]; + char dir[strlen(uml_dir) + UMID_LEN + 1], err; sprintf(dir, "%s%s", uml_dir, umid); - actually_do_remove(dir); + err = actually_do_remove(dir); + if(err) + printf("remove_umid_dir - actually_do_remove failed with " + "err = %d\n", err); } __uml_exitcall(remove_umid_dir); -- cgit v1.1 From e464bf2bed027ea185992b44bf4b0326387a520d Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:19:01 -0800 Subject: [PATCH] uml: SIGWINCH handling cleanup Code cleanup - unregister_winch and winch_cleanup had some duplicate code. This is now abstracted out into free_winch. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/line.c | 54 ++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c index a3c3937..46ceb25 100644 --- a/arch/um/drivers/line.c +++ b/arch/um/drivers/line.c @@ -774,55 +774,49 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty) printk("register_winch_irq - failed to register IRQ\n"); } +static void free_winch(struct winch *winch) +{ + list_del(&winch->list); + + if(winch->pid != -1) + os_kill_process(winch->pid, 1); + if(winch->fd != -1) + os_close_file(winch->fd); + + free_irq(WINCH_IRQ, winch); + kfree(winch); +} + static void unregister_winch(struct tty_struct *tty) { struct list_head *ele; - struct winch *winch, *found = NULL; + struct winch *winch; spin_lock(&winch_handler_lock); + list_for_each(ele, &winch_handlers){ winch = list_entry(ele, struct winch, list); if(winch->tty == tty){ - found = winch; - break; + free_winch(winch); + break; } } - if(found == NULL) - goto err; - - list_del(&winch->list); - spin_unlock(&winch_handler_lock); - - if(winch->pid != -1) - os_kill_process(winch->pid, 1); - - free_irq(WINCH_IRQ, winch); - kfree(winch); - - return; -err: spin_unlock(&winch_handler_lock); } -/* XXX: No lock as it's an exitcall... is this valid? Depending on cleanup - * order... are we sure that nothing else is done on the list? */ static void winch_cleanup(void) { - struct list_head *ele; + struct list_head *ele, *next; struct winch *winch; - list_for_each(ele, &winch_handlers){ + spin_lock(&winch_handler_lock); + + list_for_each_safe(ele, next, &winch_handlers){ winch = list_entry(ele, struct winch, list); - if(winch->fd != -1){ - /* Why is this different from the above free_irq(), - * which deactivates SIGIO? This searches the FD - * somewhere else and removes it from the list... */ - deactivate_fd(winch->fd, WINCH_IRQ); - os_close_file(winch->fd); - } - if(winch->pid != -1) - os_kill_process(winch->pid, 1); + free_winch(winch); } + + spin_unlock(&winch_handler_lock); } __uml_exitcall(winch_cleanup); -- cgit v1.1 From 44700a4469b6bb89e6f1edd32b8a4a915dd967c6 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:19:02 -0800 Subject: [PATCH] uml: better diagnostics for broken configs Produce a compile-time error if both MODE_SKAS and MODE_TT are disabled. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/include/choose-mode.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/um/include/choose-mode.h b/arch/um/include/choose-mode.h index f25fa83..b87b36a 100644 --- a/arch/um/include/choose-mode.h +++ b/arch/um/include/choose-mode.h @@ -23,6 +23,9 @@ static inline void *__choose_mode(void *tt, void *skas) { #elif defined(UML_CONFIG_MODE_TT) #define CHOOSE_MODE(tt, skas) (tt) + +#else +#error CONFIG_MODE_SKAS and CONFIG_MODE_TT are both disabled #endif #define CHOOSE_MODE_PROC(tt, skas, args...) \ -- cgit v1.1 From 7b033e1fdeef3d8bacac3cd5cfa53c9d670d1f3d Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:19:03 -0800 Subject: [PATCH] uml: add mconsole_reply variant with length param This is needed for the console output patch, since we have a possibly non-NULL-terminated string there. So, the new interface takes a string and a length, and the old interface calls strlen on its string and calls the new interface with the length. There's also a bit of whitespace cleanup. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/mconsole_user.c | 12 +++++++++--- arch/um/include/mconsole.h | 8 +++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/um/drivers/mconsole_user.c b/arch/um/drivers/mconsole_user.c index 310c1f8..4b109fe 100644 --- a/arch/um/drivers/mconsole_user.c +++ b/arch/um/drivers/mconsole_user.c @@ -122,12 +122,12 @@ int mconsole_get_request(int fd, struct mc_request *req) return(1); } -int mconsole_reply(struct mc_request *req, char *str, int err, int more) +int mconsole_reply_len(struct mc_request *req, const char *str, int total, + int err, int more) { struct mconsole_reply reply; - int total, len, n; + int len, n; - total = strlen(str); do { reply.err = err; @@ -155,6 +155,12 @@ int mconsole_reply(struct mc_request *req, char *str, int err, int more) return(0); } +int mconsole_reply(struct mc_request *req, const char *str, int err, int more) +{ + return mconsole_reply_len(req, str, strlen(str), err, more); +} + + int mconsole_unlink_socket(void) { unlink(mconsole_socket_name); diff --git a/arch/um/include/mconsole.h b/arch/um/include/mconsole.h index b1b512f..58f67d3 100644 --- a/arch/um/include/mconsole.h +++ b/arch/um/include/mconsole.h @@ -32,7 +32,7 @@ struct mconsole_reply { struct mconsole_notify { u32 magic; - u32 version; + u32 version; enum { MCONSOLE_SOCKET, MCONSOLE_PANIC, MCONSOLE_HANG, MCONSOLE_USER_NOTIFY } type; u32 len; @@ -66,7 +66,9 @@ struct mc_request extern char mconsole_socket_name[]; extern int mconsole_unlink_socket(void); -extern int mconsole_reply(struct mc_request *req, char *reply, int err, +extern int mconsole_reply_len(struct mc_request *req, const char *reply, + int len, int err, int more); +extern int mconsole_reply(struct mc_request *req, const char *str, int err, int more); extern void mconsole_version(struct mc_request *req); @@ -84,7 +86,7 @@ extern void mconsole_proc(struct mc_request *req); extern void mconsole_stack(struct mc_request *req); extern int mconsole_get_request(int fd, struct mc_request *req); -extern int mconsole_notify(char *sock_name, int type, const void *data, +extern int mconsole_notify(char *sock_name, int type, const void *data, int len); extern char *mconsole_notify_socket(void); extern void lock_notify(void); -- cgit v1.1 From 6f517d3fc862d3c8d8ba65c0b2472d399aceb9ed Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:19:04 -0800 Subject: [PATCH] uml: capture printk output for mconsole stack The stack command now sends the printk output back to the mconsole client. This is done by registering a special console for the mconsole driver. This receives all printk output. Normally, it is ignored, but when a stack command is issued, any printk output will be sent back to the client. This will capture any printk output, whether it is stack output or not, since we can't tell the difference. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/mconsole_kern.c | 87 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 6 deletions(-) diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index b5217bd..e9bbc14 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -20,6 +20,7 @@ #include "linux/namei.h" #include "linux/proc_fs.h" #include "linux/syscalls.h" +#include "linux/console.h" #include "asm/irq.h" #include "asm/uaccess.h" #include "user_util.h" @@ -480,6 +481,82 @@ void mconsole_sysrq(struct mc_request *req) } #endif +static DEFINE_SPINLOCK(console_lock); +static LIST_HEAD(clients); +static char console_buf[MCONSOLE_MAX_DATA]; +static int console_index = 0; + +static void console_write(struct console *console, const char *string, + unsigned len) +{ + struct list_head *ele; + int n; + + if(list_empty(&clients)) + return; + + while(1){ + n = min(len, ARRAY_SIZE(console_buf) - console_index); + strncpy(&console_buf[console_index], string, n); + console_index += n; + string += n; + len -= n; + if(len == 0) + return; + + list_for_each(ele, &clients){ + struct mconsole_entry *entry; + + entry = list_entry(ele, struct mconsole_entry, list); + mconsole_reply_len(&entry->request, console_buf, + console_index, 0, 1); + } + + console_index = 0; + } +} + +static struct console mc_console = { .name = "mc", + .write = console_write, + .flags = CON_PRINTBUFFER | CON_ENABLED, + .index = -1 }; + +static int mc_add_console(void) +{ + register_console(&mc_console); + return 0; +} + +late_initcall(mc_add_console); + +static void with_console(struct mc_request *req, void (*proc)(void *), + void *arg) +{ + struct mconsole_entry entry; + unsigned long flags; + + INIT_LIST_HEAD(&entry.list); + entry.request = *req; + list_add(&entry.list, &clients); + spin_lock_irqsave(&console_lock, flags); + + (*proc)(arg); + + mconsole_reply_len(req, console_buf, console_index, 0, 0); + console_index = 0; + + spin_unlock_irqrestore(&console_lock, flags); + list_del(&entry.list); +} + +static void stack_proc(void *arg) +{ + struct task_struct *from = current, *to = arg; + + to->thread.saved_task = from; + switch_to(from, to, from); +} + /* Mconsole stack trace * Added by Allan Graves, Jeff Dike * Dumps a stacks registers to the linux console. @@ -489,7 +566,7 @@ void do_stack(struct mc_request *req) { char *ptr = req->request.data; int pid_requested= -1; - struct task_struct *from = NULL; + struct task_struct *from = NULL; struct task_struct *to = NULL; /* Would be nice: @@ -507,17 +584,15 @@ void do_stack(struct mc_request *req) return; } - from = current; - to = find_task_by_pid(pid_requested); + from = current; + to = find_task_by_pid(pid_requested); if((to == NULL) || (pid_requested == 0)) { mconsole_reply(req, "Couldn't find that pid", 1, 0); return; } - to->thread.saved_task = current; - switch_to(from, to, from); - mconsole_reply(req, "Stack Dumped to console and message log", 0, 0); + with_console(req, stack_proc, to); } void mconsole_stack(struct mc_request *req) -- cgit v1.1 From 4111b025dc64f33803d2147565147428dc51d014 Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:19:05 -0800 Subject: [PATCH] uml: capture printk output for mconsole sysrq Pass sysrq output back to the mconsole client using the mechanism introduced for stack output. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/mconsole_kern.c | 48 +++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index e9bbc14..8b453a7 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -463,24 +463,6 @@ void mconsole_remove(struct mc_request *req) mconsole_reply(req, err_msg, err, 0); } -#ifdef CONFIG_MAGIC_SYSRQ -void mconsole_sysrq(struct mc_request *req) -{ - char *ptr = req->request.data; - - ptr += strlen("sysrq"); - while(isspace(*ptr)) ptr++; - - mconsole_reply(req, "", 0, 0); - handle_sysrq(*ptr, ¤t->thread.regs, NULL); -} -#else -void mconsole_sysrq(struct mc_request *req) -{ - mconsole_reply(req, "Sysrq not compiled in", 1, 0); -} -#endif - static DEFINE_SPINLOCK(console_lock); static LIST_HEAD(clients); static char console_buf[MCONSOLE_MAX_DATA]; @@ -549,6 +531,36 @@ static void with_console(struct mc_request *req, void (*proc)(void *), list_del(&entry.list); } +#ifdef CONFIG_MAGIC_SYSRQ +static void sysrq_proc(void *arg) +{ + char *op = arg; + + handle_sysrq(*op, ¤t->thread.regs, NULL); +} + +void mconsole_sysrq(struct mc_request *req) +{ + char *ptr = req->request.data; + + ptr += strlen("sysrq"); + while(isspace(*ptr)) ptr++; + + /* With 'b', the system will shut down without a chance to reply, + * so in this case, we reply first. + */ + if(*ptr == 'b') + mconsole_reply(req, "", 0, 0); + + with_console(req, sysrq_proc, ptr); +} +#else +void mconsole_sysrq(struct mc_request *req) +{ + mconsole_reply(req, "Sysrq not compiled in", 1, 0); +} +#endif + static void stack_proc(void *arg) { struct task_struct *from = current, *to = arg; -- cgit v1.1 From 3a331a511a2fe522034f3958eecf58751be434ac Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:19:05 -0800 Subject: [PATCH] uml: fix whitespace in mconsole driver Fix up some bogus spacing in the mconsole driver. Also delete the emacs formatting comment at the end. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/mconsole_kern.c | 96 ++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 54 deletions(-) diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c index 8b453a7..be61012 100644 --- a/arch/um/drivers/mconsole_kern.c +++ b/arch/um/drivers/mconsole_kern.c @@ -422,7 +422,7 @@ void mconsole_remove(struct mc_request *req) { struct mc_device *dev; char *ptr = req->request.data, *err_msg = ""; - char error[256]; + char error[256]; int err, start, end, n; ptr += strlen("remove"); @@ -433,33 +433,33 @@ void mconsole_remove(struct mc_request *req) return; } - ptr = &ptr[strlen(dev->name)]; - - err = 1; - n = (*dev->id)(&ptr, &start, &end); - if(n < 0){ - err_msg = "Couldn't parse device number"; - goto out; - } - else if((n < start) || (n > end)){ - sprintf(error, "Invalid device number - must be between " - "%d and %d", start, end); - err_msg = error; - goto out; - } + ptr = &ptr[strlen(dev->name)]; + + err = 1; + n = (*dev->id)(&ptr, &start, &end); + if(n < 0){ + err_msg = "Couldn't parse device number"; + goto out; + } + else if((n < start) || (n > end)){ + sprintf(error, "Invalid device number - must be between " + "%d and %d", start, end); + err_msg = error; + goto out; + } err = (*dev->remove)(n); - switch(err){ - case -ENODEV: - err_msg = "Device doesn't exist"; - break; - case -EBUSY: - err_msg = "Device is currently open"; - break; - default: - break; - } - out: + switch(err){ + case -ENODEV: + err_msg = "Device doesn't exist"; + break; + case -EBUSY: + err_msg = "Device is currently open"; + break; + default: + break; + } +out: mconsole_reply(req, err_msg, err, 0); } @@ -576,34 +576,33 @@ static void stack_proc(void *arg) */ void do_stack(struct mc_request *req) { - char *ptr = req->request.data; - int pid_requested= -1; + char *ptr = req->request.data; + int pid_requested= -1; struct task_struct *from = NULL; struct task_struct *to = NULL; - /* Would be nice: - * 1) Send showregs output to mconsole. + /* Would be nice: + * 1) Send showregs output to mconsole. * 2) Add a way to stack dump all pids. */ - ptr += strlen("stack"); - while(isspace(*ptr)) ptr++; + ptr += strlen("stack"); + while(isspace(*ptr)) ptr++; - /* Should really check for multiple pids or reject bad args here */ - /* What do the arguments in mconsole_reply mean? */ - if(sscanf(ptr, "%d", &pid_requested) == 0){ - mconsole_reply(req, "Please specify a pid", 1, 0); - return; - } + /* Should really check for multiple pids or reject bad args here */ + /* What do the arguments in mconsole_reply mean? */ + if(sscanf(ptr, "%d", &pid_requested) == 0){ + mconsole_reply(req, "Please specify a pid", 1, 0); + return; + } from = current; to = find_task_by_pid(pid_requested); - if((to == NULL) || (pid_requested == 0)) { - mconsole_reply(req, "Couldn't find that pid", 1, 0); - return; - } - + if((to == NULL) || (pid_requested == 0)) { + mconsole_reply(req, "Couldn't find that pid", 1, 0); + return; + } with_console(req, stack_proc, to); } @@ -772,14 +771,3 @@ char *mconsole_notify_socket(void) } EXPORT_SYMBOL(mconsole_notify_socket); - -/* - * Overrides for Emacs so that we follow Linus's tabbing style. - * Emacs will notice this stuff at the end of the file and automatically - * adjust the settings for this buffer only. This must remain at the end - * of the file. - * --------------------------------------------------------------------------- - * Local variables: - * c-file-style: "linux" - * End: - */ -- cgit v1.1 From 8d93c700a489eba08514222df414a23852a85d2b Mon Sep 17 00:00:00 2001 From: Jeff Dike Date: Fri, 6 Jan 2006 00:19:06 -0800 Subject: [PATCH] uml: free network IRQ correctly Free the network IRQ when closing down the network devices at shutdown. Delete the device from the opened devices list on close. These prevent an -EBADF when later disabling SIGIO on all extant descriptors and a complaint from free_irq about freeing the IRQ twice. Signed-off-by: Jeff Dike Cc: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/um/drivers/net_kern.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c index deb2482..fb1f9fb 100644 --- a/arch/um/drivers/net_kern.c +++ b/arch/um/drivers/net_kern.c @@ -150,6 +150,7 @@ static int uml_net_close(struct net_device *dev) if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user); lp->fd = -1; + list_del(&lp->list); spin_unlock(&lp->lock); return 0; @@ -715,6 +716,7 @@ static void close_devices(void) list_for_each(ele, &opened){ lp = list_entry(ele, struct uml_net_private, list); + free_irq(lp->dev->irq, lp->dev); if((lp->close != NULL) && (lp->fd >= 0)) (*lp->close)(lp->fd, &lp->user); if(lp->remove != NULL) (*lp->remove)(&lp->user); -- cgit v1.1 From 973bd9937569146de0917f54f05b2942f8257912 Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Fri, 6 Jan 2006 00:19:07 -0800 Subject: [PATCH] s390: atomic primitives Hugh Dickins Fix the broken atomic_cmpxchg primitive. Add atomic_sub_and_test, atomic64_sub_return, atomic64_sub_and_test, atomic64_cmpxchg, atomic64_add_unless and atomic64_inc_not_zero. Replace old style atomic_compare_and_swap by atomic_cmpxchg. Shorten the whole header by defining most primitives with the two inline functions atomic_add_return and atomic_sub_return. In addition this patch contains the s390 related fixes of Hugh's "mm: fill arch atomic64 gaps" patch. Signed-off-by: Martin Schwidefsky Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/kernel/machine_kexec.c | 2 +- arch/s390/kernel/smp.c | 6 +- drivers/s390/block/dasd.c | 4 +- drivers/s390/char/sclp_quiesce.c | 2 +- drivers/s390/char/tape_block.c | 2 +- drivers/s390/cio/ccwgroup.c | 6 +- drivers/s390/cio/device.c | 4 +- drivers/s390/net/iucv.c | 8 +- drivers/s390/net/qeth_main.c | 20 ++--- include/asm-s390/atomic.h | 173 ++++++++++++++++----------------------- 10 files changed, 96 insertions(+), 131 deletions(-) diff --git a/arch/s390/kernel/machine_kexec.c b/arch/s390/kernel/machine_kexec.c index 5aa71b0..f0ed5c6 100644 --- a/arch/s390/kernel/machine_kexec.c +++ b/arch/s390/kernel/machine_kexec.c @@ -85,7 +85,7 @@ kexec_halt_all_cpus(void *kernel_image) pfault_fini(); #endif - if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid)) + if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) != -1) signal_processor(smp_processor_id(), sigp_stop); /* Wait for all other cpus to enter stopped state */ diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 5856b3f..bd5b311 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -263,7 +263,7 @@ static void do_machine_restart(void * __unused) int cpu; static atomic_t cpuid = ATOMIC_INIT(-1); - if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid)) + if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) != -1) signal_processor(smp_processor_id(), sigp_stop); /* Wait for all other cpus to enter stopped state */ @@ -313,7 +313,7 @@ static void do_machine_halt(void * __unused) { static atomic_t cpuid = ATOMIC_INIT(-1); - if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid) == 0) { + if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) == -1) { smp_send_stop(); if (MACHINE_IS_VM && strlen(vmhalt_cmd) > 0) cpcmd(vmhalt_cmd, NULL, 0, NULL); @@ -332,7 +332,7 @@ static void do_machine_power_off(void * __unused) { static atomic_t cpuid = ATOMIC_INIT(-1); - if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid) == 0) { + if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) == -1) { smp_send_stop(); if (MACHINE_IS_VM && strlen(vmpoff_cmd) > 0) cpcmd(vmpoff_cmd, NULL, 0, NULL); diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 7008d32..6278739 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -7,7 +7,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 * - * $Revision: 1.167 $ + * $Revision: 1.169 $ */ #include @@ -1323,7 +1323,7 @@ void dasd_schedule_bh(struct dasd_device * device) { /* Protect against rescheduling. */ - if (atomic_compare_and_swap (0, 1, &device->tasklet_scheduled)) + if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0) return; dasd_get_device(device); tasklet_hi_schedule(&device->tasklet); diff --git a/drivers/s390/char/sclp_quiesce.c b/drivers/s390/char/sclp_quiesce.c index 83f7577..56fa691 100644 --- a/drivers/s390/char/sclp_quiesce.c +++ b/drivers/s390/char/sclp_quiesce.c @@ -32,7 +32,7 @@ do_load_quiesce_psw(void * __unused) psw_t quiesce_psw; int cpu; - if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid)) + if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) != -1) signal_processor(smp_processor_id(), sigp_stop); /* Wait for all other cpus to enter stopped state */ for_each_online_cpu(cpu) { diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c index 1efc9f2..482e07e 100644 --- a/drivers/s390/char/tape_block.c +++ b/drivers/s390/char/tape_block.c @@ -65,7 +65,7 @@ static void tapeblock_trigger_requeue(struct tape_device *device) { /* Protect against rescheduling. */ - if (atomic_compare_and_swap(0, 1, &device->blk_data.requeue_scheduled)) + if (atomic_cmpxchg(&device->blk_data.requeue_scheduled, 0, 1) != 0) return; schedule_work(&device->blk_data.requeue_task); } diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c index be9d2d6..e849289 100644 --- a/drivers/s390/cio/ccwgroup.c +++ b/drivers/s390/cio/ccwgroup.c @@ -1,7 +1,7 @@ /* * drivers/s390/cio/ccwgroup.c * bus driver for ccwgroup - * $Revision: 1.32 $ + * $Revision: 1.33 $ * * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, * IBM Corporation @@ -263,7 +263,7 @@ ccwgroup_set_online(struct ccwgroup_device *gdev) struct ccwgroup_driver *gdrv; int ret; - if (atomic_compare_and_swap(0, 1, &gdev->onoff)) + if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0) return -EAGAIN; if (gdev->state == CCWGROUP_ONLINE) { ret = 0; @@ -289,7 +289,7 @@ ccwgroup_set_offline(struct ccwgroup_device *gdev) struct ccwgroup_driver *gdrv; int ret; - if (atomic_compare_and_swap(0, 1, &gdev->onoff)) + if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0) return -EAGAIN; if (gdev->state == CCWGROUP_OFFLINE) { ret = 0; diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index 85908ca..0590cff 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -1,7 +1,7 @@ /* * drivers/s390/cio/device.c * bus driver for ccw devices - * $Revision: 1.131 $ + * $Revision: 1.137 $ * * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, * IBM Corporation @@ -374,7 +374,7 @@ online_store (struct device *dev, struct device_attribute *attr, const char *buf int i, force, ret; char *tmp; - if (atomic_compare_and_swap(0, 1, &cdev->private->onoff)) + if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0) return -EAGAIN; if (cdev->drv && !try_module_get(cdev->drv->owner)) { diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c index df7647c..ecb2f8f 100644 --- a/drivers/s390/net/iucv.c +++ b/drivers/s390/net/iucv.c @@ -1,5 +1,5 @@ /* - * $Id: iucv.c,v 1.45 2005/04/26 22:59:06 braunu Exp $ + * $Id: iucv.c,v 1.47 2005/11/21 11:35:22 mschwide Exp $ * * IUCV network driver * @@ -29,7 +29,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.45 $ + * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.47 $ * */ @@ -355,7 +355,7 @@ do { \ static void iucv_banner(void) { - char vbuf[] = "$Revision: 1.45 $"; + char vbuf[] = "$Revision: 1.47 $"; char *version = vbuf; if ((version = strchr(version, ':'))) { @@ -477,7 +477,7 @@ grab_param(void) ptr++; if (ptr >= iucv_param_pool + PARAM_POOL_SIZE) ptr = iucv_param_pool; - } while (atomic_compare_and_swap(0, 1, &ptr->in_use)); + } while (atomic_cmpxchg(&ptr->in_use, 0, 1) != 0); hint = ptr - iucv_param_pool; memset(&ptr->param, 0, sizeof(ptr->param)); diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index f8f55cc..7b2663f 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c @@ -1396,7 +1396,7 @@ qeth_idx_activate_get_answer(struct qeth_channel *channel, channel->ccw.cda = (__u32) __pa(iob->data); wait_event(card->wait_q, - atomic_compare_and_swap(0,1,&channel->irq_pending) == 0); + atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0); QETH_DBF_TEXT(setup, 6, "noirqpnd"); spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); rc = ccw_device_start(channel->ccwdev, @@ -1463,7 +1463,7 @@ qeth_idx_activate_channel(struct qeth_channel *channel, memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob->data), &temp, 2); wait_event(card->wait_q, - atomic_compare_and_swap(0,1,&channel->irq_pending) == 0); + atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0); QETH_DBF_TEXT(setup, 6, "noirqpnd"); spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); rc = ccw_device_start(channel->ccwdev, @@ -1616,7 +1616,7 @@ qeth_issue_next_read(struct qeth_card *card) } qeth_setup_ccw(&card->read, iob->data, QETH_BUFSIZE); wait_event(card->wait_q, - atomic_compare_and_swap(0,1,&card->read.irq_pending) == 0); + atomic_cmpxchg(&card->read.irq_pending, 0, 1) == 0); QETH_DBF_TEXT(trace, 6, "noirqpnd"); rc = ccw_device_start(card->read.ccwdev, &card->read.ccw, (addr_t) iob, 0, 0); @@ -1882,7 +1882,7 @@ qeth_send_control_data(struct qeth_card *card, int len, spin_unlock_irqrestore(&card->lock, flags); QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN); wait_event(card->wait_q, - atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0); + atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0); qeth_prepare_control_data(card, len, iob); if (IS_IPA(iob->data)) timer.expires = jiffies + QETH_IPA_TIMEOUT; @@ -1924,7 +1924,7 @@ qeth_osn_send_control_data(struct qeth_card *card, int len, QETH_DBF_TEXT(trace, 5, "osndctrd"); wait_event(card->wait_q, - atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0); + atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0); qeth_prepare_control_data(card, len, iob); QETH_DBF_TEXT(trace, 6, "osnoirqp"); spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags); @@ -4236,9 +4236,8 @@ qeth_do_send_packet_fast(struct qeth_card *card, struct qeth_qdio_out_q *queue, QETH_DBF_TEXT(trace, 6, "dosndpfa"); /* spin until we get the queue ... */ - while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED, - QETH_OUT_Q_LOCKED, - &queue->state)); + while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED, + QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED); /* ... now we've got the queue */ index = queue->next_buf_to_fill; buffer = &queue->bufs[queue->next_buf_to_fill]; @@ -4292,9 +4291,8 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, QETH_DBF_TEXT(trace, 6, "dosndpkt"); /* spin until we get the queue ... */ - while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED, - QETH_OUT_Q_LOCKED, - &queue->state)); + while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED, + QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED); start_index = queue->next_buf_to_fill; buffer = &queue->bufs[queue->next_buf_to_fill]; /* diff --git a/include/asm-s390/atomic.h b/include/asm-s390/atomic.h index 6d07c7d..d82aedf 100644 --- a/include/asm-s390/atomic.h +++ b/include/asm-s390/atomic.h @@ -5,7 +5,7 @@ * include/asm-s390/atomic.h * * S390 version - * Copyright (C) 1999-2003 IBM Deutschland Entwicklung GmbH, IBM Corporation + * Copyright (C) 1999-2005 IBM Deutschland Entwicklung GmbH, IBM Corporation * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), * Denis Joseph Barrow, * Arnd Bergmann (arndb@de.ibm.com) @@ -45,59 +45,57 @@ typedef struct { #define atomic_read(v) ((v)->counter) #define atomic_set(v,i) (((v)->counter) = (i)) -static __inline__ void atomic_add(int i, atomic_t * v) -{ - __CS_LOOP(v, i, "ar"); -} static __inline__ int atomic_add_return(int i, atomic_t * v) { return __CS_LOOP(v, i, "ar"); } -static __inline__ int atomic_add_negative(int i, atomic_t * v) -{ - return __CS_LOOP(v, i, "ar") < 0; -} -static __inline__ void atomic_sub(int i, atomic_t * v) -{ - __CS_LOOP(v, i, "sr"); -} +#define atomic_add(_i, _v) atomic_add_return(_i, _v) +#define atomic_add_negative(_i, _v) (atomic_add_return(_i, _v) < 0) +#define atomic_inc(_v) atomic_add_return(1, _v) +#define atomic_inc_return(_v) atomic_add_return(1, _v) +#define atomic_inc_and_test(_v) (atomic_add_return(1, _v) == 0) + static __inline__ int atomic_sub_return(int i, atomic_t * v) { return __CS_LOOP(v, i, "sr"); } -static __inline__ void atomic_inc(volatile atomic_t * v) -{ - __CS_LOOP(v, 1, "ar"); -} -static __inline__ int atomic_inc_return(volatile atomic_t * v) -{ - return __CS_LOOP(v, 1, "ar"); -} +#define atomic_sub(_i, _v) atomic_sub_return(_i, _v) +#define atomic_sub_and_test(_i, _v) (atomic_sub_return(_i, _v) == 0) +#define atomic_dec(_v) atomic_sub_return(1, _v) +#define atomic_dec_return(_v) atomic_sub_return(1, _v) +#define atomic_dec_and_test(_v) (atomic_sub_return(1, _v) == 0) -static __inline__ int atomic_inc_and_test(volatile atomic_t * v) -{ - return __CS_LOOP(v, 1, "ar") == 0; -} -static __inline__ void atomic_dec(volatile atomic_t * v) -{ - __CS_LOOP(v, 1, "sr"); -} -static __inline__ int atomic_dec_return(volatile atomic_t * v) -{ - return __CS_LOOP(v, 1, "sr"); -} -static __inline__ int atomic_dec_and_test(volatile atomic_t * v) -{ - return __CS_LOOP(v, 1, "sr") == 0; -} static __inline__ void atomic_clear_mask(unsigned long mask, atomic_t * v) { __CS_LOOP(v, ~mask, "nr"); } + static __inline__ void atomic_set_mask(unsigned long mask, atomic_t * v) { __CS_LOOP(v, mask, "or"); } + +static __inline__ int atomic_cmpxchg(atomic_t *v, int old, int new) +{ + __asm__ __volatile__(" cs %0,%3,0(%2)\n" + : "+d" (old), "=m" (v->counter) + : "a" (v), "d" (new), "m" (v->counter) + : "cc", "memory" ); + return old; +} + +static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) +{ + int c, old; + + c = atomic_read(v); + while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c) + c = old; + return c != u; +} + +#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) + #undef __CS_LOOP #ifdef __s390x__ @@ -123,92 +121,61 @@ typedef struct { #define atomic64_read(v) ((v)->counter) #define atomic64_set(v,i) (((v)->counter) = (i)) -static __inline__ void atomic64_add(long long i, atomic64_t * v) -{ - __CSG_LOOP(v, i, "agr"); -} static __inline__ long long atomic64_add_return(long long i, atomic64_t * v) { return __CSG_LOOP(v, i, "agr"); } -static __inline__ long long atomic64_add_negative(long long i, atomic64_t * v) -{ - return __CSG_LOOP(v, i, "agr") < 0; -} -static __inline__ void atomic64_sub(long long i, atomic64_t * v) -{ - __CSG_LOOP(v, i, "sgr"); -} -static __inline__ void atomic64_inc(volatile atomic64_t * v) -{ - __CSG_LOOP(v, 1, "agr"); -} -static __inline__ long long atomic64_inc_return(volatile atomic64_t * v) -{ - return __CSG_LOOP(v, 1, "agr"); -} -static __inline__ long long atomic64_inc_and_test(volatile atomic64_t * v) -{ - return __CSG_LOOP(v, 1, "agr") == 0; -} -static __inline__ void atomic64_dec(volatile atomic64_t * v) -{ - __CSG_LOOP(v, 1, "sgr"); -} -static __inline__ long long atomic64_dec_return(volatile atomic64_t * v) -{ - return __CSG_LOOP(v, 1, "sgr"); -} -static __inline__ long long atomic64_dec_and_test(volatile atomic64_t * v) +#define atomic64_add(_i, _v) atomic64_add_return(_i, _v) +#define atomic64_add_negative(_i, _v) (atomic64_add_return(_i, _v) < 0) +#define atomic64_inc(_v) atomic64_add_return(1, _v) +#define atomic64_inc_return(_v) atomic64_add_return(1, _v) +#define atomic64_inc_and_test(_v) (atomic64_add_return(1, _v) == 0) + +static __inline__ long long atomic64_sub_return(long long i, atomic64_t * v) { - return __CSG_LOOP(v, 1, "sgr") == 0; + return __CSG_LOOP(v, i, "sgr"); } +#define atomic64_sub(_i, _v) atomic64_sub_return(_i, _v) +#define atomic64_sub_and_test(_i, _v) (atomic64_sub_return(_i, _v) == 0) +#define atomic64_dec(_v) atomic64_sub_return(1, _v) +#define atomic64_dec_return(_v) atomic64_sub_return(1, _v) +#define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0) + static __inline__ void atomic64_clear_mask(unsigned long mask, atomic64_t * v) { __CSG_LOOP(v, ~mask, "ngr"); } + static __inline__ void atomic64_set_mask(unsigned long mask, atomic64_t * v) { __CSG_LOOP(v, mask, "ogr"); } -#undef __CSG_LOOP -#endif - -/* - returns 0 if expected_oldval==value in *v ( swap was successful ) - returns 1 if unsuccessful. +static __inline__ long long atomic64_cmpxchg(atomic64_t *v, + long long old, long long new) +{ + __asm__ __volatile__(" csg %0,%3,0(%2)\n" + : "+d" (old), "=m" (v->counter) + : "a" (v), "d" (new), "m" (v->counter) + : "cc", "memory" ); + return old; +} - This is non-portable, use bitops or spinlocks instead! -*/ -static __inline__ int -atomic_compare_and_swap(int expected_oldval,int new_val,atomic_t *v) +static __inline__ int atomic64_add_unless(atomic64_t *v, + long long a, long long u) { - int retval; - - __asm__ __volatile__( - " lr %0,%3\n" - " cs %0,%4,0(%2)\n" - " ipm %0\n" - " srl %0,28\n" - "0:" - : "=&d" (retval), "=m" (v->counter) - : "a" (v), "d" (expected_oldval) , "d" (new_val), - "m" (v->counter) : "cc", "memory" ); - return retval; + long long c, old; + + c = atomic64_read(v); + while (c != u && (old = atomic64_cmpxchg(v, c, c + a)) != c) + c = old; + return c != u; } -#define atomic_cmpxchg(v, o, n) (atomic_compare_and_swap((o), (n), &((v)->counter))) +#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) -#define atomic_add_unless(v, a, u) \ -({ \ - int c, old; \ - c = atomic_read(v); \ - while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ - c = old; \ - c != (u); \ -}) -#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) +#undef __CSG_LOOP +#endif #define smp_mb__before_atomic_dec() smp_mb() #define smp_mb__after_atomic_dec() smp_mb() -- cgit v1.1 From 56dc6a88ec76019e0d0729165cb5b98536270e1d Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Fri, 6 Jan 2006 00:19:09 -0800 Subject: [PATCH] s390: cms volume label definitions Moved definition of CMS volume label to vtoc.h and modify partitions/ibm.c to use this volume label definition instead of anonymous array. Signed-off-by: Peter Oberparleiter Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/block/dasd_diag.c | 7 ++++--- drivers/s390/block/dasd_diag.h | 23 +---------------------- fs/partitions/ibm.c | 30 +++++++++++++++--------------- include/asm-s390/vtoc.h | 24 ++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c index ab8754e..16c4b7d 100644 --- a/drivers/s390/block/dasd_diag.c +++ b/drivers/s390/block/dasd_diag.c @@ -6,7 +6,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 * - * $Revision: 1.51 $ + * $Revision: 1.52 $ */ #include @@ -25,6 +25,7 @@ #include #include #include +#include #include "dasd_int.h" #include "dasd_diag.h" @@ -329,7 +330,7 @@ dasd_diag_check_device(struct dasd_device *device) struct dasd_diag_private *private; struct dasd_diag_characteristics *rdc_data; struct dasd_diag_bio bio; - struct dasd_diag_cms_label *label; + struct vtoc_cms_label *label; blocknum_t end_block; unsigned int sb, bsize; int rc; @@ -380,7 +381,7 @@ dasd_diag_check_device(struct dasd_device *device) mdsk_term_io(device); /* figure out blocksize of device */ - label = (struct dasd_diag_cms_label *) get_zeroed_page(GFP_KERNEL); + label = (struct vtoc_cms_label *) get_zeroed_page(GFP_KERNEL); if (label == NULL) { DEV_MESSAGE(KERN_WARNING, device, "%s", "No memory to allocate initialization request"); diff --git a/drivers/s390/block/dasd_diag.h b/drivers/s390/block/dasd_diag.h index df31484..37edf6e 100644 --- a/drivers/s390/block/dasd_diag.h +++ b/drivers/s390/block/dasd_diag.h @@ -6,7 +6,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ */ #define MDSK_WRITE_REQ 0x01 @@ -44,27 +44,6 @@ struct dasd_diag_characteristics { u8 rdev_features; } __attribute__ ((packed, aligned(4))); -struct dasd_diag_cms_label { - u8 label_id[4]; - u8 vol_id[6]; - u16 version_id; - u32 block_size; - u32 origin_ptr; - u32 usable_count; - u32 formatted_count; - u32 block_count; - u32 used_count; - u32 fst_size; - u32 fst_count; - u8 format_date[6]; - u8 reserved1[2]; - u32 disk_offset; - u32 map_block; - u32 hblk_disp; - u32 user_disp; - u8 reserved2[4]; - u8 segment_name[8]; -} __attribute__ ((packed)); #ifdef CONFIG_ARCH_S390X #define DASD_DIAG_FLAGA_DEFAULT DASD_DIAG_FLAGA_FORMAT_64BIT diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c index 6327bcb..78010ad 100644 --- a/fs/partitions/ibm.c +++ b/fs/partitions/ibm.c @@ -56,7 +56,10 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) struct hd_geometry *geo; char type[5] = {0,}; char name[7] = {0,}; - struct vtoc_volume_label *vlabel; + union label_t { + struct vtoc_volume_label vol; + struct vtoc_cms_label cms; + } *label; unsigned char *data; Sector sect; @@ -64,9 +67,8 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) goto out_noinfo; if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) goto out_nogeo; - if ((vlabel = kmalloc(sizeof(struct vtoc_volume_label), - GFP_KERNEL)) == NULL) - goto out_novlab; + if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL) + goto out_nolab; if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0) @@ -87,7 +89,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) strncpy(name, data + 8, 6); else strncpy(name, data + 4, 6); - memcpy (vlabel, data, sizeof(struct vtoc_volume_label)); + memcpy(label, data, sizeof(union label_t)); put_dev_sector(sect); EBCASC(type, 4); @@ -100,14 +102,12 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) /* * VM style CMS1 labeled disk */ - int *label = (int *) vlabel; - - if (label[13] != 0) { + if (label->cms.disk_offset != 0) { printk("CMS1/%8s(MDSK):", name); /* disk is reserved minidisk */ - blocksize = label[3]; - offset = label[13]; - size = (label[7] - 1)*(blocksize >> 9); + blocksize = label->cms.block_size; + offset = label->cms.disk_offset; + size = (label->cms.block_count - 1) * (blocksize >> 9); } else { printk("CMS1/%8s:", name); offset = (info->label_block + 1); @@ -126,7 +126,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) printk("VOL1/%8s:", name); /* get block number and read then go through format1 labels */ - blk = cchhb2blk(&vlabel->vtoc, geo) + 1; + blk = cchhb2blk(&label->vol.vtoc, geo) + 1; counter = 0; while ((data = read_dev_sector(bdev, blk*(blocksize/512), §)) != NULL) { @@ -174,7 +174,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) } printk("\n"); - kfree(vlabel); + kfree(label); kfree(geo); kfree(info); return 1; @@ -182,8 +182,8 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev) out_readerr: out_badsect: out_noioctl: - kfree(vlabel); -out_novlab: + kfree(label); +out_nolab: kfree(geo); out_nogeo: kfree(info); diff --git a/include/asm-s390/vtoc.h b/include/asm-s390/vtoc.h index 41d369f..d1de5b7 100644 --- a/include/asm-s390/vtoc.h +++ b/include/asm-s390/vtoc.h @@ -176,4 +176,28 @@ struct vtoc_format7_label struct vtoc_cchhb DS7PTRDS; /* pointer to next FMT7 DSCB */ } __attribute__ ((packed)); +struct vtoc_cms_label { + u8 label_id[4]; /* Label identifier */ + u8 vol_id[6]; /* Volid */ + u16 version_id; /* Version identifier */ + u32 block_size; /* Disk block size */ + u32 origin_ptr; /* Disk origin pointer */ + u32 usable_count; /* Number of usable cylinders/blocks */ + u32 formatted_count; /* Maximum number of formatted cylinders/ + * blocks */ + u32 block_count; /* Disk size in CMS blocks */ + u32 used_count; /* Number of CMS blocks in use */ + u32 fst_size; /* File Status Table (FST) size */ + u32 fst_count; /* Number of FSTs per CMS block */ + u8 format_date[6]; /* Disk FORMAT date */ + u8 reserved1[2]; + u32 disk_offset; /* Disk offset when reserved*/ + u32 map_block; /* Allocation Map Block with next hole */ + u32 hblk_disp; /* Displacement into HBLK data of next hole */ + u32 user_disp; /* Displacement into user part of Allocation + * map */ + u8 reserved2[4]; + u8 segment_name[8]; /* Name of shared segment */ +} __attribute__ ((packed)); + #endif /* _ASM_S390_VTOC_H */ -- cgit v1.1 From a63a4931c301a14ca79c41fec0b99d898dbba1fb Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Fri, 6 Jan 2006 00:19:09 -0800 Subject: [PATCH] s390: uaccess warnings Convert __access_ok to an inline C function and change __get_user primitive to avoid uaccess compiler warnings. Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/kernel/compat_linux.c | 2 +- include/asm-s390/uaccess.h | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c index ed877d0..41b197a 100644 --- a/arch/s390/kernel/compat_linux.c +++ b/arch/s390/kernel/compat_linux.c @@ -279,7 +279,7 @@ asmlinkage long sys32_getegid16(void) static inline long get_tv32(struct timeval *o, struct compat_timeval *i) { - return (!access_ok(VERIFY_READ, tv32, sizeof(*tv32)) || + return (!access_ok(VERIFY_READ, o, sizeof(*o)) || (__get_user(o->tv_sec, &i->tv_sec) || __get_user(o->tv_usec, &i->tv_usec))); } diff --git a/include/asm-s390/uaccess.h b/include/asm-s390/uaccess.h index 10a619d..be104f2 100644 --- a/include/asm-s390/uaccess.h +++ b/include/asm-s390/uaccess.h @@ -61,8 +61,10 @@ #define segment_eq(a,b) ((a).ar4 == (b).ar4) -#define __access_ok(addr,size) (1) - +static inline int __access_ok(const void *addr, unsigned long size) +{ + return 1; +} #define access_ok(type,addr,size) __access_ok(addr,size) /* @@ -206,25 +208,25 @@ extern int __put_user_bad(void) __attribute__((noreturn)); case 1: { \ unsigned char __x; \ __get_user_asm(__x, ptr, __gu_err); \ - (x) = (__typeof__(*(ptr))) __x; \ + (x) = *(__typeof__(*(ptr)) *) &__x; \ break; \ }; \ case 2: { \ unsigned short __x; \ __get_user_asm(__x, ptr, __gu_err); \ - (x) = (__typeof__(*(ptr))) __x; \ + (x) = *(__typeof__(*(ptr)) *) &__x; \ break; \ }; \ case 4: { \ unsigned int __x; \ __get_user_asm(__x, ptr, __gu_err); \ - (x) = (__typeof__(*(ptr))) __x; \ + (x) = *(__typeof__(*(ptr)) *) &__x; \ break; \ }; \ case 8: { \ unsigned long long __x; \ __get_user_asm(__x, ptr, __gu_err); \ - (x) = (__typeof__(*(ptr))) __x; \ + (x) = *(__typeof__(*(ptr)) *) &__x; \ break; \ }; \ default: \ -- cgit v1.1 From 4e3df37e7fb4e41bec84465ff31949737160ed58 Mon Sep 17 00:00:00 2001 From: Cedric Le Goater Date: Fri, 6 Jan 2006 00:19:10 -0800 Subject: [PATCH] s390: rt_sigreturn fix Check return code of do_sigaltstack and force a SIGSEGV if it is -EFAULT. Signed-off-by: Martin Schwidefsky Signed-off-by: Cedric Le Goater Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/kernel/compat_signal.c | 2 -- arch/s390/kernel/signal.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c index 4ff6808..fa2b3bc 100644 --- a/arch/s390/kernel/compat_signal.c +++ b/arch/s390/kernel/compat_signal.c @@ -467,8 +467,6 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs) if (err) goto badframe; - /* It is more difficult to avoid calling this function than to - call it and ignore errors. */ set_fs (KERNEL_DS); do_sigaltstack((stack_t __user *)&st, NULL, regs->gprs[15]); set_fs (old_fs); diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c index 6e0110d..13592d0 100644 --- a/arch/s390/kernel/signal.c +++ b/arch/s390/kernel/signal.c @@ -254,9 +254,9 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) if (restore_sigregs(regs, &frame->uc.uc_mcontext)) goto badframe; - /* It is more difficult to avoid calling this function than to - call it and ignore errors. */ - do_sigaltstack(&frame->uc.uc_stack, NULL, regs->gprs[15]); + if (do_sigaltstack(&frame->uc.uc_stack, NULL, + regs->gprs[15]) == -EFAULT) + goto badframe; return regs->gprs[2]; badframe: -- cgit v1.1 From 088c4ec16aa6b865dcf690051ddac30eb2bf6bcc Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Fri, 6 Jan 2006 00:19:11 -0800 Subject: [PATCH] s390: update default configuration Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/defconfig | 55 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/arch/s390/defconfig b/arch/s390/defconfig index 45d44c6..0c495fe 100644 --- a/arch/s390/defconfig +++ b/arch/s390/defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.14-rc1 -# Wed Sep 14 16:46:19 2005 +# Linux kernel version: 2.6.15-rc2 +# Mon Nov 21 13:51:30 2005 # CONFIG_MMU=y CONFIG_RWSEM_XCHGADD_ALGORITHM=y @@ -65,6 +65,24 @@ CONFIG_KMOD=y CONFIG_STOP_MACHINE=y # +# Block layer +# +# CONFIG_LBD is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +CONFIG_DEFAULT_AS=y +# CONFIG_DEFAULT_DEADLINE is not set +# CONFIG_DEFAULT_CFQ is not set +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="anticipatory" + +# # Base setup # @@ -97,6 +115,7 @@ CONFIG_FLATMEM_MANUAL=y CONFIG_FLATMEM=y CONFIG_FLAT_NODE_MEM_MAP=y # CONFIG_SPARSEMEM_STATIC is not set +CONFIG_SPLIT_PTLOCK_CPUS=4 # # I/O subsystem configuration @@ -188,10 +207,18 @@ CONFIG_IPV6=y # CONFIG_NET_DIVERT is not set # CONFIG_ECONET is not set # CONFIG_WAN_ROUTER is not set + +# +# QoS and/or fair queueing +# CONFIG_NET_SCHED=y CONFIG_NET_SCH_CLK_JIFFIES=y # CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set # CONFIG_NET_SCH_CLK_CPU is not set + +# +# Queueing/Scheduling +# CONFIG_NET_SCH_CBQ=m # CONFIG_NET_SCH_HTB is not set # CONFIG_NET_SCH_HFSC is not set @@ -204,8 +231,10 @@ CONFIG_NET_SCH_GRED=m CONFIG_NET_SCH_DSMARK=m # CONFIG_NET_SCH_NETEM is not set # CONFIG_NET_SCH_INGRESS is not set -CONFIG_NET_QOS=y -CONFIG_NET_ESTIMATOR=y + +# +# Classification +# CONFIG_NET_CLS=y # CONFIG_NET_CLS_BASIC is not set CONFIG_NET_CLS_TCINDEX=m @@ -214,18 +243,18 @@ CONFIG_NET_CLS_ROUTE=y CONFIG_NET_CLS_FW=m CONFIG_NET_CLS_U32=m # CONFIG_CLS_U32_PERF is not set -# CONFIG_NET_CLS_IND is not set CONFIG_NET_CLS_RSVP=m CONFIG_NET_CLS_RSVP6=m # CONFIG_NET_EMATCH is not set # CONFIG_NET_CLS_ACT is not set CONFIG_NET_CLS_POLICE=y +# CONFIG_NET_CLS_IND is not set +CONFIG_NET_ESTIMATOR=y # # Network testing # # CONFIG_NET_PKTGEN is not set -# CONFIG_NETFILTER_NETLINK is not set # CONFIG_HAMRADIO is not set # CONFIG_IRDA is not set # CONFIG_BT is not set @@ -276,6 +305,7 @@ CONFIG_SCSI_FC_ATTRS=y # # SCSI low-level drivers # +# CONFIG_ISCSI_TCP is not set # CONFIG_SCSI_SATA is not set # CONFIG_SCSI_DEBUG is not set CONFIG_ZFCP=y @@ -292,7 +322,6 @@ CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_COUNT=16 CONFIG_BLK_DEV_RAM_SIZE=4096 CONFIG_BLK_DEV_INITRD=y -# CONFIG_LBD is not set # CONFIG_CDROM_PKTCDVD is not set # @@ -305,15 +334,8 @@ CONFIG_DASD_PROFILE=y CONFIG_DASD_ECKD=y CONFIG_DASD_FBA=y CONFIG_DASD_DIAG=y +CONFIG_DASD_EER=m # CONFIG_DASD_CMB is not set - -# -# IO Schedulers -# -CONFIG_IOSCHED_NOOP=y -CONFIG_IOSCHED_AS=y -CONFIG_IOSCHED_DEADLINE=y -CONFIG_IOSCHED_CFQ=y # CONFIG_ATA_OVER_ETH is not set # @@ -378,7 +400,6 @@ CONFIG_S390_TAPE_34XX=m # CONFIG_VMLOGRDR is not set # CONFIG_VMCP is not set # CONFIG_MONREADER is not set -# CONFIG_DCSS_SHM is not set # # Cryptographic devices @@ -593,6 +614,8 @@ CONFIG_DEBUG_PREEMPT=y # CONFIG_DEBUG_KOBJECT is not set # CONFIG_DEBUG_INFO is not set CONFIG_DEBUG_FS=y +# CONFIG_DEBUG_VM is not set +# CONFIG_RCU_TORTURE_TEST is not set # # Security options -- cgit v1.1 From 089545f0c71bab6511395c2a060d7f81a99bad58 Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Fri, 6 Jan 2006 00:19:12 -0800 Subject: [PATCH] s390: cputime_t fixes There are some more places where the use of cputime_t instead of an integer type and the associated macros is necessary for the virtual cputime accounting on s390. Affected are the s390 specific appldata code and BSD process accounting. Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/appldata/appldata_os.c | 14 +++++++------- kernel/acct.c | 16 +++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/arch/s390/appldata/appldata_os.c b/arch/s390/appldata/appldata_os.c index e0a476b..99ddd3b 100644 --- a/arch/s390/appldata/appldata_os.c +++ b/arch/s390/appldata/appldata_os.c @@ -141,19 +141,19 @@ static void appldata_get_os_data(void *data) j = 0; for_each_online_cpu(i) { os_data->os_cpu[j].per_cpu_user = - kstat_cpu(i).cpustat.user; + cputime_to_jiffies(kstat_cpu(i).cpustat.user); os_data->os_cpu[j].per_cpu_nice = - kstat_cpu(i).cpustat.nice; + cputime_to_jiffies(kstat_cpu(i).cpustat.nice); os_data->os_cpu[j].per_cpu_system = - kstat_cpu(i).cpustat.system; + cputime_to_jiffies(kstat_cpu(i).cpustat.system); os_data->os_cpu[j].per_cpu_idle = - kstat_cpu(i).cpustat.idle; + cputime_to_jiffies(kstat_cpu(i).cpustat.idle); os_data->os_cpu[j].per_cpu_irq = - kstat_cpu(i).cpustat.irq; + cputime_to_jiffies(kstat_cpu(i).cpustat.irq); os_data->os_cpu[j].per_cpu_softirq = - kstat_cpu(i).cpustat.softirq; + cputime_to_jiffies(kstat_cpu(i).cpustat.softirq); os_data->os_cpu[j].per_cpu_iowait = - kstat_cpu(i).cpustat.iowait; + cputime_to_jiffies(kstat_cpu(i).cpustat.iowait); j++; } diff --git a/kernel/acct.c b/kernel/acct.c index 6312d6b..38d57fa 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -427,6 +427,7 @@ static void do_acct_process(long exitcode, struct file *file) u64 elapsed; u64 run_time; struct timespec uptime; + unsigned long jiffies; /* * First check to see if there is enough free_space to continue @@ -467,12 +468,12 @@ static void do_acct_process(long exitcode, struct file *file) #endif do_div(elapsed, AHZ); ac.ac_btime = xtime.tv_sec - elapsed; - ac.ac_utime = encode_comp_t(jiffies_to_AHZ( - current->signal->utime + - current->group_leader->utime)); - ac.ac_stime = encode_comp_t(jiffies_to_AHZ( - current->signal->stime + - current->group_leader->stime)); + jiffies = cputime_to_jiffies(cputime_add(current->group_leader->utime, + current->signal->utime)); + ac.ac_utime = encode_comp_t(jiffies_to_AHZ(jiffies)); + jiffies = cputime_to_jiffies(cputime_add(current->group_leader->stime, + current->signal->stime)); + ac.ac_stime = encode_comp_t(jiffies_to_AHZ(jiffies)); /* we really need to bite the bullet and change layout */ ac.ac_uid = current->uid; ac.ac_gid = current->gid; @@ -580,7 +581,8 @@ void acct_process(long exitcode) void acct_update_integrals(struct task_struct *tsk) { if (likely(tsk->mm)) { - long delta = tsk->stime - tsk->acct_stimexpd; + long delta = + cputime_to_jiffies(tsk->stime) - tsk->acct_stimexpd; if (delta == 0) return; -- cgit v1.1 From 6810a2bce3aa6573faa9920487274f166fe95c6e Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Fri, 6 Jan 2006 00:19:13 -0800 Subject: [PATCH] s390: re-activated path detection If we receive path not operational indications (pnom in pmcw nonzero), we switch off those paths. To catch them becoming available again, we have to recalculate the lpm from the pmcw each time we start path verification. Signed-off-by: Cornelia Huck Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/cio/device_pgid.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c index 0adac8a..757b270 100644 --- a/drivers/s390/cio/device_pgid.c +++ b/drivers/s390/cio/device_pgid.c @@ -22,6 +22,7 @@ #include "cio_debug.h" #include "css.h" #include "device.h" +#include "ioasm.h" /* * Start Sense Path Group ID helper function. Used in ccw_device_recog @@ -364,8 +365,22 @@ ccw_device_verify_irq(struct ccw_device *cdev, enum dev_event dev_event) void ccw_device_verify_start(struct ccw_device *cdev) { + struct subchannel *sch = to_subchannel(cdev->dev.parent); + cdev->private->flags.pgid_single = 0; cdev->private->iretry = 5; + /* + * Update sch->lpm with current values to catch paths becoming + * available again. + */ + if (stsch(sch->irq, &sch->schib)) { + ccw_device_verify_done(cdev, -ENODEV); + return; + } + sch->lpm = sch->schib.pmcw.pim & + sch->schib.pmcw.pam & + sch->schib.pmcw.pom & + sch->opm; __ccw_device_verify_start(cdev); } -- cgit v1.1 From cfb1b55595a0dfd87b5849e8d0216c029f34445f Mon Sep 17 00:00:00 2001 From: Carsten Otte Date: Fri, 6 Jan 2006 00:19:14 -0800 Subject: [PATCH] s390: move s390_root_dev_* out of the cio layer Extract the s390_root_dev_* functions from the common I/O layer as they are also used by non-ccw device drivers. Signed-off-by: Carsten Otte Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/Makefile | 2 +- drivers/s390/block/dcssblk.c | 2 +- drivers/s390/cio/css.c | 41 ---------------------------------- drivers/s390/net/cu3088.c | 3 ++- drivers/s390/net/iucv.c | 2 +- drivers/s390/net/qeth_main.c | 1 + drivers/s390/s390_rdev.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ include/asm-s390/ccwdev.h | 3 --- include/asm-s390/s390_rdev.h | 15 +++++++++++++ 9 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 drivers/s390/s390_rdev.c create mode 100644 include/asm-s390/s390_rdev.h diff --git a/drivers/s390/Makefile b/drivers/s390/Makefile index c99a2fe..9803c93 100644 --- a/drivers/s390/Makefile +++ b/drivers/s390/Makefile @@ -2,7 +2,7 @@ # Makefile for the S/390 specific device drivers # -obj-y += s390mach.o sysinfo.o +obj-y += s390mach.o sysinfo.o s390_rdev.o obj-y += cio/ block/ char/ crypto/ net/ scsi/ drivers-y += drivers/s390/built-in.o diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 4fde411..2e727f4 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -15,7 +15,7 @@ #include #include #include -#include // for s390_root_dev_(un)register() +#include //#define DCSSBLK_DEBUG /* Debug messages on/off */ #define DCSSBLK_NAME "dcssblk" diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 555119c..7e4d57b 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -481,45 +481,6 @@ struct bus_type css_bus_type = { subsys_initcall(init_channel_subsystem); -/* - * Register root devices for some drivers. The release function must not be - * in the device drivers, so we do it here. - */ -static void -s390_root_dev_release(struct device *dev) -{ - kfree(dev); -} - -struct device * -s390_root_dev_register(const char *name) -{ - struct device *dev; - int ret; - - if (!strlen(name)) - return ERR_PTR(-EINVAL); - dev = kmalloc(sizeof(struct device), GFP_KERNEL); - if (!dev) - return ERR_PTR(-ENOMEM); - memset(dev, 0, sizeof(struct device)); - strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE)); - dev->release = s390_root_dev_release; - ret = device_register(dev); - if (ret) { - kfree(dev); - return ERR_PTR(ret); - } - return dev; -} - -void -s390_root_dev_unregister(struct device *dev) -{ - if (dev) - device_unregister(dev); -} - int css_enqueue_subchannel_slow(unsigned long schid) { @@ -564,6 +525,4 @@ css_slow_subchannels_exist(void) MODULE_LICENSE("GPL"); EXPORT_SYMBOL(css_bus_type); -EXPORT_SYMBOL(s390_root_dev_register); -EXPORT_SYMBOL(s390_root_dev_unregister); EXPORT_SYMBOL_GPL(css_characteristics_avail); diff --git a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c index 0075894..77dacb4 100644 --- a/drivers/s390/net/cu3088.c +++ b/drivers/s390/net/cu3088.c @@ -1,5 +1,5 @@ /* - * $Id: cu3088.c,v 1.35 2005/03/30 19:28:52 richtera Exp $ + * $Id: cu3088.c,v 1.36 2005/10/25 14:37:17 cohuck Exp $ * * CTC / LCS ccw_device driver * @@ -27,6 +27,7 @@ #include #include +#include #include #include diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c index ecb2f8f..ea81773 100644 --- a/drivers/s390/net/iucv.c +++ b/drivers/s390/net/iucv.c @@ -54,7 +54,7 @@ #include #include #include -#include //for root device stuff +#include /* FLAGS: * All flags are defined in the field IPFLAGS1 of each function diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index 7b2663f..97f927c 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c @@ -65,6 +65,7 @@ #include #include #include +#include #include "qeth.h" #include "qeth_mpc.h" diff --git a/drivers/s390/s390_rdev.c b/drivers/s390/s390_rdev.c new file mode 100644 index 0000000..566cc3d --- /dev/null +++ b/drivers/s390/s390_rdev.c @@ -0,0 +1,53 @@ +/* + * drivers/s390/s390_rdev.c + * s390 root device + * $Revision: 1.2 $ + * + * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH, + * IBM Corporation + * Author(s): Cornelia Huck (cohuck@de.ibm.com) + * Carsten Otte (cotte@de.ibm.com) + */ + +#include +#include +#include +#include + +static void +s390_root_dev_release(struct device *dev) +{ + kfree(dev); +} + +struct device * +s390_root_dev_register(const char *name) +{ + struct device *dev; + int ret; + + if (!strlen(name)) + return ERR_PTR(-EINVAL); + dev = kmalloc(sizeof(struct device), GFP_KERNEL); + if (!dev) + return ERR_PTR(-ENOMEM); + memset(dev, 0, sizeof(struct device)); + strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE)); + dev->release = s390_root_dev_release; + ret = device_register(dev); + if (ret) { + kfree(dev); + return ERR_PTR(ret); + } + return dev; +} + +void +s390_root_dev_unregister(struct device *dev) +{ + if (dev) + device_unregister(dev); +} + +EXPORT_SYMBOL(s390_root_dev_register); +EXPORT_SYMBOL(s390_root_dev_unregister); diff --git a/include/asm-s390/ccwdev.h b/include/asm-s390/ccwdev.h index 3eb231a..12456cb 100644 --- a/include/asm-s390/ccwdev.h +++ b/include/asm-s390/ccwdev.h @@ -185,8 +185,5 @@ extern struct ccw_device *ccw_device_probe_console(void); extern int _ccw_device_get_device_number(struct ccw_device *); extern int _ccw_device_get_subchannel_number(struct ccw_device *); -extern struct device *s390_root_dev_register(const char *); -extern void s390_root_dev_unregister(struct device *); - extern void *ccw_device_get_chp_desc(struct ccw_device *, int); #endif /* _S390_CCWDEV_H_ */ diff --git a/include/asm-s390/s390_rdev.h b/include/asm-s390/s390_rdev.h new file mode 100644 index 0000000..3ad78f2 --- /dev/null +++ b/include/asm-s390/s390_rdev.h @@ -0,0 +1,15 @@ +/* + * include/asm-s390/ccwdev.h + * + * Copyright (C) 2002,2005 IBM Deutschland Entwicklung GmbH, IBM Corporation + * Author(s): Cornelia Huck + * Carsten Otte + * + * Interface for s390 root device + */ + +#ifndef _S390_RDEV_H_ +#define _S390_RDEV_H_ +extern struct device *s390_root_dev_register(const char *); +extern void s390_root_dev_unregister(struct device *); +#endif /* _S390_RDEV_H_ */ -- cgit v1.1 From 9a7af289660dc749d7c58234191601046a9bf488 Mon Sep 17 00:00:00 2001 From: Horst Hummel Date: Fri, 6 Jan 2006 00:19:14 -0800 Subject: [PATCH] s390: BIODASDPRRD ioctl return code The IOCTL BIODASDPRRD had no return code for 'profiling is inactive' and therefore tunedasd wrote misleading message for request-counter = 0. Introduce return-code EIO for inactive profiling. Signed-off-by: Horst Hummel Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/block/dasd_ioctl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c index 789595b..044b753 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -7,7 +7,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 * - * $Revision: 1.47 $ + * $Revision: 1.50 $ * * i/o controls for the dasd driver. */ @@ -352,6 +352,9 @@ dasd_ioctl_read_profile(struct block_device *bdev, int no, long args) if (device == NULL) return -ENODEV; + if (dasd_profile_level == DASD_PROFILE_OFF) + return -EIO; + if (copy_to_user((long __user *) args, (long *) &device->profile, sizeof (struct dasd_profile_info_t))) return -EFAULT; -- cgit v1.1 From 1c01b8a5963aec60488c1c97d67cffd8b5275e3f Mon Sep 17 00:00:00 2001 From: Horst Hummel Date: Fri, 6 Jan 2006 00:19:15 -0800 Subject: [PATCH] s390: dasd failfast support To properly support multipath-failover handling, the linux block layer has introduced a special request flag, 'REQ_FAILFAST'. This flag is now used to return requests immediately in case the device is not operational. Signed-off-by: Horst Hummel Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/block/dasd.c | 28 ++++++++++++++++++++-------- drivers/s390/block/dasd_diag.c | 4 +++- drivers/s390/block/dasd_eckd.c | 7 ++++++- drivers/s390/block/dasd_fba.c | 4 +++- drivers/s390/block/dasd_int.h | 3 ++- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 6278739..1141a59 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -7,7 +7,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 * - * $Revision: 1.169 $ + * $Revision: 1.172 $ */ #include @@ -1224,6 +1224,12 @@ __dasd_start_head(struct dasd_device * device) if (list_empty(&device->ccw_queue)) return; cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list); + /* check FAILFAST */ + if (device->stopped & ~DASD_STOPPED_PENDING && + test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) { + cqr->status = DASD_CQR_FAILED; + dasd_schedule_bh(device); + } if ((cqr->status == DASD_CQR_QUEUED) && (!device->stopped)) { /* try to start the first I/O that can be started */ @@ -1750,8 +1756,10 @@ dasd_exit(void) * SECTION: common functions for ccw_driver use */ -/* initial attempt at a probe function. this can be simplified once - * the other detection code is gone */ +/* + * Initial attempt at a probe function. this can be simplified once + * the other detection code is gone. + */ int dasd_generic_probe (struct ccw_device *cdev, struct dasd_discipline *discipline) @@ -1770,8 +1778,10 @@ dasd_generic_probe (struct ccw_device *cdev, return ret; } -/* this will one day be called from a global not_oper handler. - * It is also used by driver_unregister during module unload */ +/* + * This will one day be called from a global not_oper handler. + * It is also used by driver_unregister during module unload. + */ void dasd_generic_remove (struct ccw_device *cdev) { @@ -1798,9 +1808,11 @@ dasd_generic_remove (struct ccw_device *cdev) dasd_delete_device(device); } -/* activate a device. This is called from dasd_{eckd,fba}_probe() when either +/* + * Activate a device. This is called from dasd_{eckd,fba}_probe() when either * the device is detected for the first time and is supposed to be used - * or the user has started activation through sysfs */ + * or the user has started activation through sysfs. + */ int dasd_generic_set_online (struct ccw_device *cdev, struct dasd_discipline *discipline) @@ -1917,7 +1929,6 @@ dasd_generic_notify(struct ccw_device *cdev, int event) if (cqr->status == DASD_CQR_IN_IO) cqr->status = DASD_CQR_FAILED; device->stopped |= DASD_STOPPED_DC_EIO; - dasd_schedule_bh(device); } else { list_for_each_entry(cqr, &device->ccw_queue, list) if (cqr->status == DASD_CQR_IN_IO) { @@ -1927,6 +1938,7 @@ dasd_generic_notify(struct ccw_device *cdev, int event) device->stopped |= DASD_STOPPED_DC_WAIT; dasd_set_timer(device, 0); } + dasd_schedule_bh(device); ret = 1; break; case CIO_OPER: diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c index 16c4b7d..a33d406 100644 --- a/drivers/s390/block/dasd_diag.c +++ b/drivers/s390/block/dasd_diag.c @@ -6,7 +6,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 * - * $Revision: 1.52 $ + * $Revision: 1.53 $ */ #include @@ -549,6 +549,8 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req) } cqr->retries = DIAG_MAX_RETRIES; cqr->buildclk = get_clock(); + if (req->flags & REQ_FAILFAST) + set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); cqr->device = device; cqr->expires = DIAG_TIMEOUT; cqr->status = DASD_CQR_FILLED; diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index 811060e..efc4cf6 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -7,7 +7,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 * - * $Revision: 1.71 $ + * $Revision: 1.74 $ */ #include @@ -1136,6 +1136,8 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req) recid++; } } + if (req->flags & REQ_FAILFAST) + set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); cqr->device = device; cqr->expires = 5 * 60 * HZ; /* 5 minutes */ cqr->lpm = private->path_data.ppm; @@ -1252,6 +1254,7 @@ dasd_eckd_release(struct block_device *bdev, int no, long args) cqr->cpaddr->cda = (__u32)(addr_t) cqr->data; cqr->device = device; clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); + set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); cqr->retries = 0; cqr->expires = 2 * HZ; cqr->buildclk = get_clock(); @@ -1296,6 +1299,7 @@ dasd_eckd_reserve(struct block_device *bdev, int no, long args) cqr->cpaddr->cda = (__u32)(addr_t) cqr->data; cqr->device = device; clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); + set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); cqr->retries = 0; cqr->expires = 2 * HZ; cqr->buildclk = get_clock(); @@ -1339,6 +1343,7 @@ dasd_eckd_steal_lock(struct block_device *bdev, int no, long args) cqr->cpaddr->cda = (__u32)(addr_t) cqr->data; cqr->device = device; clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); + set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); cqr->retries = 0; cqr->expires = 2 * HZ; cqr->buildclk = get_clock(); diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c index 28cb461..9bac8d8 100644 --- a/drivers/s390/block/dasd_fba.c +++ b/drivers/s390/block/dasd_fba.c @@ -4,7 +4,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 * - * $Revision: 1.40 $ + * $Revision: 1.41 $ */ #include @@ -352,6 +352,8 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req) recid++; } } + if (req->flags & REQ_FAILFAST) + set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); cqr->device = device; cqr->expires = 5 * 60 * HZ; /* 5 minutes */ cqr->retries = 32; diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h index 9fab04f..2fb05c4 100644 --- a/drivers/s390/block/dasd_int.h +++ b/drivers/s390/block/dasd_int.h @@ -6,7 +6,7 @@ * Bugreports.to..: * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 * - * $Revision: 1.65 $ + * $Revision: 1.68 $ */ #ifndef DASD_INT_H @@ -208,6 +208,7 @@ struct dasd_ccw_req { /* per dasd_ccw_req flags */ #define DASD_CQR_FLAGS_USE_ERP 0 /* use ERP for this request */ +#define DASD_CQR_FLAGS_FAILFAST 1 /* FAILFAST */ /* Signature for error recovery functions. */ typedef struct dasd_ccw_req *(*dasd_erp_fn_t) (struct dasd_ccw_req *); -- cgit v1.1 From d0f4c16febf258ba8c0f917ac3ba935fc5459566 Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Fri, 6 Jan 2006 00:19:16 -0800 Subject: [PATCH] s390: add oprofile callgraph support Signed-off-by: Andreas Krebbel Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/oprofile/Makefile | 2 +- arch/s390/oprofile/backtrace.c | 79 ++++++++++++++++++++++++++++++++++++++++++ arch/s390/oprofile/init.c | 4 +++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 arch/s390/oprofile/backtrace.c diff --git a/arch/s390/oprofile/Makefile b/arch/s390/oprofile/Makefile index ec34927..537b2d8 100644 --- a/arch/s390/oprofile/Makefile +++ b/arch/s390/oprofile/Makefile @@ -6,4 +6,4 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ oprofilefs.o oprofile_stats.o \ timer_int.o ) -oprofile-y := $(DRIVER_OBJS) init.o +oprofile-y := $(DRIVER_OBJS) init.o backtrace.o diff --git a/arch/s390/oprofile/backtrace.c b/arch/s390/oprofile/backtrace.c new file mode 100644 index 0000000..bc4b84a --- /dev/null +++ b/arch/s390/oprofile/backtrace.c @@ -0,0 +1,79 @@ +/** + * arch/s390/oprofile/backtrace.c + * + * S390 Version + * Copyright (C) 2005 IBM Corporation, IBM Deutschland Entwicklung GmbH. + * Author(s): Andreas Krebbel + */ + +#include + +#include /* for struct stack_frame */ + +static unsigned long +__show_trace(unsigned int *depth, unsigned long sp, + unsigned long low, unsigned long high) +{ + struct stack_frame *sf; + struct pt_regs *regs; + + while (*depth) { + sp = sp & PSW_ADDR_INSN; + if (sp < low || sp > high - sizeof(*sf)) + return sp; + sf = (struct stack_frame *) sp; + (*depth)--; + oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN); + + /* Follow the backchain. */ + while (*depth) { + low = sp; + sp = sf->back_chain & PSW_ADDR_INSN; + if (!sp) + break; + if (sp <= low || sp > high - sizeof(*sf)) + return sp; + sf = (struct stack_frame *) sp; + (*depth)--; + oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN); + + } + + if (*depth == 0) + break; + + /* Zero backchain detected, check for interrupt frame. */ + sp = (unsigned long) (sf + 1); + if (sp <= low || sp > high - sizeof(*regs)) + return sp; + regs = (struct pt_regs *) sp; + (*depth)--; + oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN); + low = sp; + sp = regs->gprs[15]; + } + return sp; +} + +void s390_backtrace(struct pt_regs * const regs, unsigned int depth) +{ + unsigned long head; + struct stack_frame* head_sf; + + if (user_mode (regs)) + return; + + head = regs->gprs[15]; + head_sf = (struct stack_frame*)head; + + if (!head_sf->back_chain) + return; + + head = head_sf->back_chain; + + head = __show_trace(&depth, head, S390_lowcore.async_stack - ASYNC_SIZE, + S390_lowcore.async_stack); + + __show_trace(&depth, head, S390_lowcore.thread_info, + S390_lowcore.thread_info + THREAD_SIZE); +} diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c index a65ead0..7a99511 100644 --- a/arch/s390/oprofile/init.c +++ b/arch/s390/oprofile/init.c @@ -12,8 +12,12 @@ #include #include + +extern void s390_backtrace(struct pt_regs * const regs, unsigned int depth); + int __init oprofile_arch_init(struct oprofile_operations* ops) { + ops->backtrace = s390_backtrace; return -ENODEV; } -- cgit v1.1 From c1e26e1ef7ab50f30e5fbf004fe96ed44321ca78 Mon Sep 17 00:00:00 2001 From: Jan Glauber Date: Fri, 6 Jan 2006 00:19:17 -0800 Subject: [PATCH] s390: in-kernel crypto rename Replace all references to z990 by s390 in the in-kernel crypto files in arch/s390/crypto. The code is not specific to a particular machine (z990) but to the s390 platform. Big diff, does nothing.. Signed-off-by: Jan Glauber Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/crypto/Makefile | 6 +- arch/s390/crypto/crypt_s390.h | 383 ++++++++++++++++++++++++++++++++++++ arch/s390/crypto/crypt_s390_query.c | 113 +++++++++++ arch/s390/crypto/crypt_z990.h | 374 ----------------------------------- arch/s390/crypto/crypt_z990_query.c | 111 ----------- arch/s390/crypto/des_s390.c | 284 ++++++++++++++++++++++++++ arch/s390/crypto/des_z990.c | 284 -------------------------- arch/s390/crypto/sha1_s390.c | 167 ++++++++++++++++ arch/s390/crypto/sha1_z990.c | 167 ---------------- arch/s390/defconfig | 4 +- crypto/Kconfig | 8 +- 11 files changed, 956 insertions(+), 945 deletions(-) create mode 100644 arch/s390/crypto/crypt_s390.h create mode 100644 arch/s390/crypto/crypt_s390_query.c delete mode 100644 arch/s390/crypto/crypt_z990.h delete mode 100644 arch/s390/crypto/crypt_z990_query.c create mode 100644 arch/s390/crypto/des_s390.c delete mode 100644 arch/s390/crypto/des_z990.c create mode 100644 arch/s390/crypto/sha1_s390.c delete mode 100644 arch/s390/crypto/sha1_z990.c diff --git a/arch/s390/crypto/Makefile b/arch/s390/crypto/Makefile index 96a05e6..50843f8 100644 --- a/arch/s390/crypto/Makefile +++ b/arch/s390/crypto/Makefile @@ -2,7 +2,7 @@ # Cryptographic API # -obj-$(CONFIG_CRYPTO_SHA1_Z990) += sha1_z990.o -obj-$(CONFIG_CRYPTO_DES_Z990) += des_z990.o des_check_key.o +obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s390.o +obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o -obj-$(CONFIG_CRYPTO_TEST) += crypt_z990_query.o +obj-$(CONFIG_CRYPTO_TEST) += crypt_s390_query.o diff --git a/arch/s390/crypto/crypt_s390.h b/arch/s390/crypto/crypt_s390.h new file mode 100644 index 0000000..4d24f66 --- /dev/null +++ b/arch/s390/crypto/crypt_s390.h @@ -0,0 +1,383 @@ +/* + * Cryptographic API. + * + * Support for s390 cryptographic instructions. + * + * Copyright (C) 2003 IBM Deutschland GmbH, IBM Corporation + * Author(s): Thomas Spatzier (tspat@de.ibm.com) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ +#ifndef _CRYPTO_ARCH_S390_CRYPT_S390_H +#define _CRYPTO_ARCH_S390_CRYPT_S390_H + +#include + +#define CRYPT_S390_OP_MASK 0xFF00 +#define CRYPT_S390_FUNC_MASK 0x00FF + +/* s930 cryptographic operations */ +enum crypt_s390_operations { + CRYPT_S390_KM = 0x0100, + CRYPT_S390_KMC = 0x0200, + CRYPT_S390_KIMD = 0x0300, + CRYPT_S390_KLMD = 0x0400, + CRYPT_S390_KMAC = 0x0500 +}; + +/* function codes for KM (CIPHER MESSAGE) instruction + * 0x80 is the decipher modifier bit + */ +enum crypt_s390_km_func { + KM_QUERY = CRYPT_S390_KM | 0, + KM_DEA_ENCRYPT = CRYPT_S390_KM | 1, + KM_DEA_DECRYPT = CRYPT_S390_KM | 1 | 0x80, + KM_TDEA_128_ENCRYPT = CRYPT_S390_KM | 2, + KM_TDEA_128_DECRYPT = CRYPT_S390_KM | 2 | 0x80, + KM_TDEA_192_ENCRYPT = CRYPT_S390_KM | 3, + KM_TDEA_192_DECRYPT = CRYPT_S390_KM | 3 | 0x80, +}; + +/* function codes for KMC (CIPHER MESSAGE WITH CHAINING) + * instruction + */ +enum crypt_s390_kmc_func { + KMC_QUERY = CRYPT_S390_KMC | 0, + KMC_DEA_ENCRYPT = CRYPT_S390_KMC | 1, + KMC_DEA_DECRYPT = CRYPT_S390_KMC | 1 | 0x80, + KMC_TDEA_128_ENCRYPT = CRYPT_S390_KMC | 2, + KMC_TDEA_128_DECRYPT = CRYPT_S390_KMC | 2 | 0x80, + KMC_TDEA_192_ENCRYPT = CRYPT_S390_KMC | 3, + KMC_TDEA_192_DECRYPT = CRYPT_S390_KMC | 3 | 0x80, +}; + +/* function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) + * instruction + */ +enum crypt_s390_kimd_func { + KIMD_QUERY = CRYPT_S390_KIMD | 0, + KIMD_SHA_1 = CRYPT_S390_KIMD | 1, +}; + +/* function codes for KLMD (COMPUTE LAST MESSAGE DIGEST) + * instruction + */ +enum crypt_s390_klmd_func { + KLMD_QUERY = CRYPT_S390_KLMD | 0, + KLMD_SHA_1 = CRYPT_S390_KLMD | 1, +}; + +/* function codes for KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) + * instruction + */ +enum crypt_s390_kmac_func { + KMAC_QUERY = CRYPT_S390_KMAC | 0, + KMAC_DEA = CRYPT_S390_KMAC | 1, + KMAC_TDEA_128 = CRYPT_S390_KMAC | 2, + KMAC_TDEA_192 = CRYPT_S390_KMAC | 3 +}; + +/* status word for s390 crypto instructions' QUERY functions */ +struct crypt_s390_query_status { + u64 high; + u64 low; +}; + +/* + * Standard fixup and ex_table sections for crypt_s390 inline functions. + * label 0: the s390 crypto operation + * label 1: just after 1 to catch illegal operation exception + * (unsupported model) + * label 6: the return point after fixup + * label 7: set error value if exception _in_ crypto operation + * label 8: set error value if illegal operation exception + * [ret] is the variable to receive the error code + * [ERR] is the error code value + */ +#ifndef __s390x__ +#define __crypt_s390_fixup \ + ".section .fixup,\"ax\" \n" \ + "7: lhi %0,%h[e1] \n" \ + " bras 1,9f \n" \ + " .long 6b \n" \ + "8: lhi %0,%h[e2] \n" \ + " bras 1,9f \n" \ + " .long 6b \n" \ + "9: l 1,0(1) \n" \ + " br 1 \n" \ + ".previous \n" \ + ".section __ex_table,\"a\" \n" \ + " .align 4 \n" \ + " .long 0b,7b \n" \ + " .long 1b,8b \n" \ + ".previous" +#else /* __s390x__ */ +#define __crypt_s390_fixup \ + ".section .fixup,\"ax\" \n" \ + "7: lhi %0,%h[e1] \n" \ + " jg 6b \n" \ + "8: lhi %0,%h[e2] \n" \ + " jg 6b \n" \ + ".previous\n" \ + ".section __ex_table,\"a\" \n" \ + " .align 8 \n" \ + " .quad 0b,7b \n" \ + " .quad 1b,8b \n" \ + ".previous" +#endif /* __s390x__ */ + +/* + * Standard code for setting the result of s390 crypto instructions. + * %0: the register which will receive the result + * [result]: the register containing the result (e.g. second operand length + * to compute number of processed bytes]. + */ +#ifndef __s390x__ +#define __crypt_s390_set_result \ + " lr %0,%[result] \n" +#else /* __s390x__ */ +#define __crypt_s390_set_result \ + " lgr %0,%[result] \n" +#endif + +/* + * Executes the KM (CIPHER MESSAGE) operation of the CPU. + * @param func: the function code passed to KM; see crypt_s390_km_func + * @param param: address of parameter block; see POP for details on each func + * @param dest: address of destination memory area + * @param src: address of source memory area + * @param src_len: length of src operand in bytes + * @returns < zero for failure, 0 for the query func, number of processed bytes + * for encryption/decryption funcs + */ +static inline int +crypt_s390_km(long func, void* param, u8* dest, const u8* src, long src_len) +{ + register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; + register void* __param asm("1") = param; + register u8* __dest asm("4") = dest; + register const u8* __src asm("2") = src; + register long __src_len asm("3") = src_len; + int ret; + + ret = 0; + __asm__ __volatile__ ( + "0: .insn rre,0xB92E0000,%1,%2 \n" /* KM opcode */ + "1: brc 1,0b \n" /* handle partial completion */ + __crypt_s390_set_result + "6: \n" + __crypt_s390_fixup + : "+d" (ret), "+a" (__dest), "+a" (__src), + [result] "+d" (__src_len) + : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), + "a" (__param) + : "cc", "memory" + ); + if (ret >= 0 && func & CRYPT_S390_FUNC_MASK){ + ret = src_len - ret; + } + return ret; +} + +/* + * Executes the KMC (CIPHER MESSAGE WITH CHAINING) operation of the CPU. + * @param func: the function code passed to KM; see crypt_s390_kmc_func + * @param param: address of parameter block; see POP for details on each func + * @param dest: address of destination memory area + * @param src: address of source memory area + * @param src_len: length of src operand in bytes + * @returns < zero for failure, 0 for the query func, number of processed bytes + * for encryption/decryption funcs + */ +static inline int +crypt_s390_kmc(long func, void* param, u8* dest, const u8* src, long src_len) +{ + register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; + register void* __param asm("1") = param; + register u8* __dest asm("4") = dest; + register const u8* __src asm("2") = src; + register long __src_len asm("3") = src_len; + int ret; + + ret = 0; + __asm__ __volatile__ ( + "0: .insn rre,0xB92F0000,%1,%2 \n" /* KMC opcode */ + "1: brc 1,0b \n" /* handle partial completion */ + __crypt_s390_set_result + "6: \n" + __crypt_s390_fixup + : "+d" (ret), "+a" (__dest), "+a" (__src), + [result] "+d" (__src_len) + : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), + "a" (__param) + : "cc", "memory" + ); + if (ret >= 0 && func & CRYPT_S390_FUNC_MASK){ + ret = src_len - ret; + } + return ret; +} + +/* + * Executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) operation + * of the CPU. + * @param func: the function code passed to KM; see crypt_s390_kimd_func + * @param param: address of parameter block; see POP for details on each func + * @param src: address of source memory area + * @param src_len: length of src operand in bytes + * @returns < zero for failure, 0 for the query func, number of processed bytes + * for digest funcs + */ +static inline int +crypt_s390_kimd(long func, void* param, const u8* src, long src_len) +{ + register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; + register void* __param asm("1") = param; + register const u8* __src asm("2") = src; + register long __src_len asm("3") = src_len; + int ret; + + ret = 0; + __asm__ __volatile__ ( + "0: .insn rre,0xB93E0000,%1,%1 \n" /* KIMD opcode */ + "1: brc 1,0b \n" /* handle partical completion */ + __crypt_s390_set_result + "6: \n" + __crypt_s390_fixup + : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) + : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), + "a" (__param) + : "cc", "memory" + ); + if (ret >= 0 && (func & CRYPT_S390_FUNC_MASK)){ + ret = src_len - ret; + } + return ret; +} + +/* + * Executes the KLMD (COMPUTE LAST MESSAGE DIGEST) operation of the CPU. + * @param func: the function code passed to KM; see crypt_s390_klmd_func + * @param param: address of parameter block; see POP for details on each func + * @param src: address of source memory area + * @param src_len: length of src operand in bytes + * @returns < zero for failure, 0 for the query func, number of processed bytes + * for digest funcs + */ +static inline int +crypt_s390_klmd(long func, void* param, const u8* src, long src_len) +{ + register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; + register void* __param asm("1") = param; + register const u8* __src asm("2") = src; + register long __src_len asm("3") = src_len; + int ret; + + ret = 0; + __asm__ __volatile__ ( + "0: .insn rre,0xB93F0000,%1,%1 \n" /* KLMD opcode */ + "1: brc 1,0b \n" /* handle partical completion */ + __crypt_s390_set_result + "6: \n" + __crypt_s390_fixup + : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) + : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), + "a" (__param) + : "cc", "memory" + ); + if (ret >= 0 && func & CRYPT_S390_FUNC_MASK){ + ret = src_len - ret; + } + return ret; +} + +/* + * Executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) operation + * of the CPU. + * @param func: the function code passed to KM; see crypt_s390_klmd_func + * @param param: address of parameter block; see POP for details on each func + * @param src: address of source memory area + * @param src_len: length of src operand in bytes + * @returns < zero for failure, 0 for the query func, number of processed bytes + * for digest funcs + */ +static inline int +crypt_s390_kmac(long func, void* param, const u8* src, long src_len) +{ + register long __func asm("0") = func & CRYPT_S390_FUNC_MASK; + register void* __param asm("1") = param; + register const u8* __src asm("2") = src; + register long __src_len asm("3") = src_len; + int ret; + + ret = 0; + __asm__ __volatile__ ( + "0: .insn rre,0xB91E0000,%5,%5 \n" /* KMAC opcode */ + "1: brc 1,0b \n" /* handle partical completion */ + __crypt_s390_set_result + "6: \n" + __crypt_s390_fixup + : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) + : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), + "a" (__param) + : "cc", "memory" + ); + if (ret >= 0 && func & CRYPT_S390_FUNC_MASK){ + ret = src_len - ret; + } + return ret; +} + +/** + * Tests if a specific crypto function is implemented on the machine. + * @param func: the function code of the specific function; 0 if op in general + * @return 1 if func available; 0 if func or op in general not available + */ +static inline int +crypt_s390_func_available(int func) +{ + int ret; + + struct crypt_s390_query_status status = { + .high = 0, + .low = 0 + }; + switch (func & CRYPT_S390_OP_MASK){ + case CRYPT_S390_KM: + ret = crypt_s390_km(KM_QUERY, &status, NULL, NULL, 0); + break; + case CRYPT_S390_KMC: + ret = crypt_s390_kmc(KMC_QUERY, &status, NULL, NULL, 0); + break; + case CRYPT_S390_KIMD: + ret = crypt_s390_kimd(KIMD_QUERY, &status, NULL, 0); + break; + case CRYPT_S390_KLMD: + ret = crypt_s390_klmd(KLMD_QUERY, &status, NULL, 0); + break; + case CRYPT_S390_KMAC: + ret = crypt_s390_kmac(KMAC_QUERY, &status, NULL, 0); + break; + default: + ret = 0; + return ret; + } + if (ret >= 0){ + func &= CRYPT_S390_FUNC_MASK; + func &= 0x7f; //mask modifier bit + if (func < 64){ + ret = (status.high >> (64 - func - 1)) & 0x1; + } else { + ret = (status.low >> (128 - func - 1)) & 0x1; + } + } else { + ret = 0; + } + return ret; +} + +#endif // _CRYPTO_ARCH_S390_CRYPT_S390_H diff --git a/arch/s390/crypto/crypt_s390_query.c b/arch/s390/crypto/crypt_s390_query.c new file mode 100644 index 0000000..0fa6bdf --- /dev/null +++ b/arch/s390/crypto/crypt_s390_query.c @@ -0,0 +1,113 @@ +/* + * Cryptographic API. + * + * Support for s390 cryptographic instructions. + * Testing module for querying processor crypto capabilities. + * + * Copyright (c) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation + * Author(s): Thomas Spatzier (tspat@de.ibm.com) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ +#include +#include +#include +#include +#include "crypt_s390.h" + +static void query_available_functions(void) +{ + printk(KERN_INFO "#####################\n"); + + /* query available KM functions */ + printk(KERN_INFO "KM_QUERY: %d\n", + crypt_s390_func_available(KM_QUERY)); + printk(KERN_INFO "KM_DEA: %d\n", + crypt_s390_func_available(KM_DEA_ENCRYPT)); + printk(KERN_INFO "KM_TDEA_128: %d\n", + crypt_s390_func_available(KM_TDEA_128_ENCRYPT)); + printk(KERN_INFO "KM_TDEA_192: %d\n", + crypt_s390_func_available(KM_TDEA_192_ENCRYPT)); + + /* query available KMC functions */ + printk(KERN_INFO "KMC_QUERY: %d\n", + crypt_s390_func_available(KMC_QUERY)); + printk(KERN_INFO "KMC_DEA: %d\n", + crypt_s390_func_available(KMC_DEA_ENCRYPT)); + printk(KERN_INFO "KMC_TDEA_128: %d\n", + crypt_s390_func_available(KMC_TDEA_128_ENCRYPT)); + printk(KERN_INFO "KMC_TDEA_192: %d\n", + crypt_s390_func_available(KMC_TDEA_192_ENCRYPT)); + + /* query available KIMD fucntions */ + printk(KERN_INFO "KIMD_QUERY: %d\n", + crypt_s390_func_available(KIMD_QUERY)); + printk(KERN_INFO "KIMD_SHA_1: %d\n", + crypt_s390_func_available(KIMD_SHA_1)); + + /* query available KLMD functions */ + printk(KERN_INFO "KLMD_QUERY: %d\n", + crypt_s390_func_available(KLMD_QUERY)); + printk(KERN_INFO "KLMD_SHA_1: %d\n", + crypt_s390_func_available(KLMD_SHA_1)); + + /* query available KMAC functions */ + printk(KERN_INFO "KMAC_QUERY: %d\n", + crypt_s3990_func_available(KMAC_QUERY)); + printk(KERN_INFO "KMAC_DEA: %d\n", + crypt_s390_func_available(KMAC_DEA)); + printk(KERN_INFO "KMAC_TDEA_128: %d\n", + crypt_s390_func_available(KMAC_TDEA_128)); + printk(KERN_INFO "KMAC_TDEA_192: %d\n", + crypt_s390_func_available(KMAC_TDEA_192)); +} + +static int init(void) +{ + struct crypt_s390_query_status status = { + .high = 0, + .low = 0 + }; + + printk(KERN_INFO "crypt_s390: querying available crypto functions\n"); + crypt_s390_km(KM_QUERY, &status, NULL, NULL, 0); + printk(KERN_INFO "KM:\t%016llx %016llx\n", + (unsigned long long) status.high, + (unsigned long long) status.low); + status.high = status.low = 0; + crypt_s390_kmc(KMC_QUERY, &status, NULL, NULL, 0); + printk(KERN_INFO "KMC:\t%016llx %016llx\n", + (unsigned long long) status.high, + (unsigned long long) status.low); + status.high = status.low = 0; + crypt_s390_kimd(KIMD_QUERY, &status, NULL, 0); + printk(KERN_INFO "KIMD:\t%016llx %016llx\n", + (unsigned long long) status.high, + (unsigned long long) status.low); + status.high = status.low = 0; + crypt_s390_klmd(KLMD_QUERY, &status, NULL, 0); + printk(KERN_INFO "KLMD:\t%016llx %016llx\n", + (unsigned long long) status.high, + (unsigned long long) status.low); + status.high = status.low = 0; + crypt_s390_kmac(KMAC_QUERY, &status, NULL, 0); + printk(KERN_INFO "KMAC:\t%016llx %016llx\n", + (unsigned long long) status.high, + (unsigned long long) status.low); + + query_available_functions(); + return -ECANCELED; +} + +static void __exit cleanup(void) +{ +} + +module_init(init); +module_exit(cleanup); + +MODULE_LICENSE("GPL"); diff --git a/arch/s390/crypto/crypt_z990.h b/arch/s390/crypto/crypt_z990.h deleted file mode 100644 index 4df660b..0000000 --- a/arch/s390/crypto/crypt_z990.h +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Cryptographic API. - * - * Support for z990 cryptographic instructions. - * - * Copyright (C) 2003 IBM Deutschland GmbH, IBM Corporation - * Author(s): Thomas Spatzier (tspat@de.ibm.com) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - */ -#ifndef _CRYPTO_ARCH_S390_CRYPT_Z990_H -#define _CRYPTO_ARCH_S390_CRYPT_Z990_H - -#include - -#define CRYPT_Z990_OP_MASK 0xFF00 -#define CRYPT_Z990_FUNC_MASK 0x00FF - - -/*z990 cryptographic operations*/ -enum crypt_z990_operations { - CRYPT_Z990_KM = 0x0100, - CRYPT_Z990_KMC = 0x0200, - CRYPT_Z990_KIMD = 0x0300, - CRYPT_Z990_KLMD = 0x0400, - CRYPT_Z990_KMAC = 0x0500 -}; - -/*function codes for KM (CIPHER MESSAGE) instruction*/ -enum crypt_z990_km_func { - KM_QUERY = CRYPT_Z990_KM | 0, - KM_DEA_ENCRYPT = CRYPT_Z990_KM | 1, - KM_DEA_DECRYPT = CRYPT_Z990_KM | 1 | 0x80, //modifier bit->decipher - KM_TDEA_128_ENCRYPT = CRYPT_Z990_KM | 2, - KM_TDEA_128_DECRYPT = CRYPT_Z990_KM | 2 | 0x80, - KM_TDEA_192_ENCRYPT = CRYPT_Z990_KM | 3, - KM_TDEA_192_DECRYPT = CRYPT_Z990_KM | 3 | 0x80, -}; - -/*function codes for KMC (CIPHER MESSAGE WITH CHAINING) instruction*/ -enum crypt_z990_kmc_func { - KMC_QUERY = CRYPT_Z990_KMC | 0, - KMC_DEA_ENCRYPT = CRYPT_Z990_KMC | 1, - KMC_DEA_DECRYPT = CRYPT_Z990_KMC | 1 | 0x80, //modifier bit->decipher - KMC_TDEA_128_ENCRYPT = CRYPT_Z990_KMC | 2, - KMC_TDEA_128_DECRYPT = CRYPT_Z990_KMC | 2 | 0x80, - KMC_TDEA_192_ENCRYPT = CRYPT_Z990_KMC | 3, - KMC_TDEA_192_DECRYPT = CRYPT_Z990_KMC | 3 | 0x80, -}; - -/*function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) instruction*/ -enum crypt_z990_kimd_func { - KIMD_QUERY = CRYPT_Z990_KIMD | 0, - KIMD_SHA_1 = CRYPT_Z990_KIMD | 1, -}; - -/*function codes for KLMD (COMPUTE LAST MESSAGE DIGEST) instruction*/ -enum crypt_z990_klmd_func { - KLMD_QUERY = CRYPT_Z990_KLMD | 0, - KLMD_SHA_1 = CRYPT_Z990_KLMD | 1, -}; - -/*function codes for KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) instruction*/ -enum crypt_z990_kmac_func { - KMAC_QUERY = CRYPT_Z990_KMAC | 0, - KMAC_DEA = CRYPT_Z990_KMAC | 1, - KMAC_TDEA_128 = CRYPT_Z990_KMAC | 2, - KMAC_TDEA_192 = CRYPT_Z990_KMAC | 3 -}; - -/*status word for z990 crypto instructions' QUERY functions*/ -struct crypt_z990_query_status { - u64 high; - u64 low; -}; - -/* - * Standard fixup and ex_table sections for crypt_z990 inline functions. - * label 0: the z990 crypto operation - * label 1: just after 1 to catch illegal operation exception on non-z990 - * label 6: the return point after fixup - * label 7: set error value if exception _in_ crypto operation - * label 8: set error value if illegal operation exception - * [ret] is the variable to receive the error code - * [ERR] is the error code value - */ -#ifndef __s390x__ -#define __crypt_z990_fixup \ - ".section .fixup,\"ax\" \n" \ - "7: lhi %0,%h[e1] \n" \ - " bras 1,9f \n" \ - " .long 6b \n" \ - "8: lhi %0,%h[e2] \n" \ - " bras 1,9f \n" \ - " .long 6b \n" \ - "9: l 1,0(1) \n" \ - " br 1 \n" \ - ".previous \n" \ - ".section __ex_table,\"a\" \n" \ - " .align 4 \n" \ - " .long 0b,7b \n" \ - " .long 1b,8b \n" \ - ".previous" -#else /* __s390x__ */ -#define __crypt_z990_fixup \ - ".section .fixup,\"ax\" \n" \ - "7: lhi %0,%h[e1] \n" \ - " jg 6b \n" \ - "8: lhi %0,%h[e2] \n" \ - " jg 6b \n" \ - ".previous\n" \ - ".section __ex_table,\"a\" \n" \ - " .align 8 \n" \ - " .quad 0b,7b \n" \ - " .quad 1b,8b \n" \ - ".previous" -#endif /* __s390x__ */ - -/* - * Standard code for setting the result of z990 crypto instructions. - * %0: the register which will receive the result - * [result]: the register containing the result (e.g. second operand length - * to compute number of processed bytes]. - */ -#ifndef __s390x__ -#define __crypt_z990_set_result \ - " lr %0,%[result] \n" -#else /* __s390x__ */ -#define __crypt_z990_set_result \ - " lgr %0,%[result] \n" -#endif - -/* - * Executes the KM (CIPHER MESSAGE) operation of the z990 CPU. - * @param func: the function code passed to KM; see crypt_z990_km_func - * @param param: address of parameter block; see POP for details on each func - * @param dest: address of destination memory area - * @param src: address of source memory area - * @param src_len: length of src operand in bytes - * @returns < zero for failure, 0 for the query func, number of processed bytes - * for encryption/decryption funcs - */ -static inline int -crypt_z990_km(long func, void* param, u8* dest, const u8* src, long src_len) -{ - register long __func asm("0") = func & CRYPT_Z990_FUNC_MASK; - register void* __param asm("1") = param; - register u8* __dest asm("4") = dest; - register const u8* __src asm("2") = src; - register long __src_len asm("3") = src_len; - int ret; - - ret = 0; - __asm__ __volatile__ ( - "0: .insn rre,0xB92E0000,%1,%2 \n" //KM opcode - "1: brc 1,0b \n" //handle partial completion - __crypt_z990_set_result - "6: \n" - __crypt_z990_fixup - : "+d" (ret), "+a" (__dest), "+a" (__src), - [result] "+d" (__src_len) - : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), - "a" (__param) - : "cc", "memory" - ); - if (ret >= 0 && func & CRYPT_Z990_FUNC_MASK){ - ret = src_len - ret; - } - return ret; -} - -/* - * Executes the KMC (CIPHER MESSAGE WITH CHAINING) operation of the z990 CPU. - * @param func: the function code passed to KM; see crypt_z990_kmc_func - * @param param: address of parameter block; see POP for details on each func - * @param dest: address of destination memory area - * @param src: address of source memory area - * @param src_len: length of src operand in bytes - * @returns < zero for failure, 0 for the query func, number of processed bytes - * for encryption/decryption funcs - */ -static inline int -crypt_z990_kmc(long func, void* param, u8* dest, const u8* src, long src_len) -{ - register long __func asm("0") = func & CRYPT_Z990_FUNC_MASK; - register void* __param asm("1") = param; - register u8* __dest asm("4") = dest; - register const u8* __src asm("2") = src; - register long __src_len asm("3") = src_len; - int ret; - - ret = 0; - __asm__ __volatile__ ( - "0: .insn rre,0xB92F0000,%1,%2 \n" //KMC opcode - "1: brc 1,0b \n" //handle partial completion - __crypt_z990_set_result - "6: \n" - __crypt_z990_fixup - : "+d" (ret), "+a" (__dest), "+a" (__src), - [result] "+d" (__src_len) - : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), - "a" (__param) - : "cc", "memory" - ); - if (ret >= 0 && func & CRYPT_Z990_FUNC_MASK){ - ret = src_len - ret; - } - return ret; -} - -/* - * Executes the KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) operation - * of the z990 CPU. - * @param func: the function code passed to KM; see crypt_z990_kimd_func - * @param param: address of parameter block; see POP for details on each func - * @param src: address of source memory area - * @param src_len: length of src operand in bytes - * @returns < zero for failure, 0 for the query func, number of processed bytes - * for digest funcs - */ -static inline int -crypt_z990_kimd(long func, void* param, const u8* src, long src_len) -{ - register long __func asm("0") = func & CRYPT_Z990_FUNC_MASK; - register void* __param asm("1") = param; - register const u8* __src asm("2") = src; - register long __src_len asm("3") = src_len; - int ret; - - ret = 0; - __asm__ __volatile__ ( - "0: .insn rre,0xB93E0000,%1,%1 \n" //KIMD opcode - "1: brc 1,0b \n" /*handle partical completion of kimd*/ - __crypt_z990_set_result - "6: \n" - __crypt_z990_fixup - : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) - : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), - "a" (__param) - : "cc", "memory" - ); - if (ret >= 0 && (func & CRYPT_Z990_FUNC_MASK)){ - ret = src_len - ret; - } - return ret; -} - -/* - * Executes the KLMD (COMPUTE LAST MESSAGE DIGEST) operation of the z990 CPU. - * @param func: the function code passed to KM; see crypt_z990_klmd_func - * @param param: address of parameter block; see POP for details on each func - * @param src: address of source memory area - * @param src_len: length of src operand in bytes - * @returns < zero for failure, 0 for the query func, number of processed bytes - * for digest funcs - */ -static inline int -crypt_z990_klmd(long func, void* param, const u8* src, long src_len) -{ - register long __func asm("0") = func & CRYPT_Z990_FUNC_MASK; - register void* __param asm("1") = param; - register const u8* __src asm("2") = src; - register long __src_len asm("3") = src_len; - int ret; - - ret = 0; - __asm__ __volatile__ ( - "0: .insn rre,0xB93F0000,%1,%1 \n" //KLMD opcode - "1: brc 1,0b \n" /*handle partical completion of klmd*/ - __crypt_z990_set_result - "6: \n" - __crypt_z990_fixup - : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) - : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), - "a" (__param) - : "cc", "memory" - ); - if (ret >= 0 && func & CRYPT_Z990_FUNC_MASK){ - ret = src_len - ret; - } - return ret; -} - -/* - * Executes the KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) operation - * of the z990 CPU. - * @param func: the function code passed to KM; see crypt_z990_klmd_func - * @param param: address of parameter block; see POP for details on each func - * @param src: address of source memory area - * @param src_len: length of src operand in bytes - * @returns < zero for failure, 0 for the query func, number of processed bytes - * for digest funcs - */ -static inline int -crypt_z990_kmac(long func, void* param, const u8* src, long src_len) -{ - register long __func asm("0") = func & CRYPT_Z990_FUNC_MASK; - register void* __param asm("1") = param; - register const u8* __src asm("2") = src; - register long __src_len asm("3") = src_len; - int ret; - - ret = 0; - __asm__ __volatile__ ( - "0: .insn rre,0xB91E0000,%5,%5 \n" //KMAC opcode - "1: brc 1,0b \n" /*handle partical completion of klmd*/ - __crypt_z990_set_result - "6: \n" - __crypt_z990_fixup - : "+d" (ret), "+a" (__src), [result] "+d" (__src_len) - : [e1] "K" (-EFAULT), [e2] "K" (-ENOSYS), "d" (__func), - "a" (__param) - : "cc", "memory" - ); - if (ret >= 0 && func & CRYPT_Z990_FUNC_MASK){ - ret = src_len - ret; - } - return ret; -} - -/** - * Tests if a specific z990 crypto function is implemented on the machine. - * @param func: the function code of the specific function; 0 if op in general - * @return 1 if func available; 0 if func or op in general not available - */ -static inline int -crypt_z990_func_available(int func) -{ - int ret; - - struct crypt_z990_query_status status = { - .high = 0, - .low = 0 - }; - switch (func & CRYPT_Z990_OP_MASK){ - case CRYPT_Z990_KM: - ret = crypt_z990_km(KM_QUERY, &status, NULL, NULL, 0); - break; - case CRYPT_Z990_KMC: - ret = crypt_z990_kmc(KMC_QUERY, &status, NULL, NULL, 0); - break; - case CRYPT_Z990_KIMD: - ret = crypt_z990_kimd(KIMD_QUERY, &status, NULL, 0); - break; - case CRYPT_Z990_KLMD: - ret = crypt_z990_klmd(KLMD_QUERY, &status, NULL, 0); - break; - case CRYPT_Z990_KMAC: - ret = crypt_z990_kmac(KMAC_QUERY, &status, NULL, 0); - break; - default: - ret = 0; - return ret; - } - if (ret >= 0){ - func &= CRYPT_Z990_FUNC_MASK; - func &= 0x7f; //mask modifier bit - if (func < 64){ - ret = (status.high >> (64 - func - 1)) & 0x1; - } else { - ret = (status.low >> (128 - func - 1)) & 0x1; - } - } else { - ret = 0; - } - return ret; -} - - -#endif // _CRYPTO_ARCH_S390_CRYPT_Z990_H diff --git a/arch/s390/crypto/crypt_z990_query.c b/arch/s390/crypto/crypt_z990_query.c deleted file mode 100644 index 7133983..0000000 --- a/arch/s390/crypto/crypt_z990_query.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Cryptographic API. - * - * Support for z990 cryptographic instructions. - * Testing module for querying processor crypto capabilities. - * - * Copyright (c) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation - * Author(s): Thomas Spatzier (tspat@de.ibm.com) - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - */ -#include -#include -#include -#include -#include "crypt_z990.h" - -static void -query_available_functions(void) -{ - printk(KERN_INFO "#####################\n"); - //query available KM functions - printk(KERN_INFO "KM_QUERY: %d\n", - crypt_z990_func_available(KM_QUERY)); - printk(KERN_INFO "KM_DEA: %d\n", - crypt_z990_func_available(KM_DEA_ENCRYPT)); - printk(KERN_INFO "KM_TDEA_128: %d\n", - crypt_z990_func_available(KM_TDEA_128_ENCRYPT)); - printk(KERN_INFO "KM_TDEA_192: %d\n", - crypt_z990_func_available(KM_TDEA_192_ENCRYPT)); - //query available KMC functions - printk(KERN_INFO "KMC_QUERY: %d\n", - crypt_z990_func_available(KMC_QUERY)); - printk(KERN_INFO "KMC_DEA: %d\n", - crypt_z990_func_available(KMC_DEA_ENCRYPT)); - printk(KERN_INFO "KMC_TDEA_128: %d\n", - crypt_z990_func_available(KMC_TDEA_128_ENCRYPT)); - printk(KERN_INFO "KMC_TDEA_192: %d\n", - crypt_z990_func_available(KMC_TDEA_192_ENCRYPT)); - //query available KIMD fucntions - printk(KERN_INFO "KIMD_QUERY: %d\n", - crypt_z990_func_available(KIMD_QUERY)); - printk(KERN_INFO "KIMD_SHA_1: %d\n", - crypt_z990_func_available(KIMD_SHA_1)); - //query available KLMD functions - printk(KERN_INFO "KLMD_QUERY: %d\n", - crypt_z990_func_available(KLMD_QUERY)); - printk(KERN_INFO "KLMD_SHA_1: %d\n", - crypt_z990_func_available(KLMD_SHA_1)); - //query available KMAC functions - printk(KERN_INFO "KMAC_QUERY: %d\n", - crypt_z990_func_available(KMAC_QUERY)); - printk(KERN_INFO "KMAC_DEA: %d\n", - crypt_z990_func_available(KMAC_DEA)); - printk(KERN_INFO "KMAC_TDEA_128: %d\n", - crypt_z990_func_available(KMAC_TDEA_128)); - printk(KERN_INFO "KMAC_TDEA_192: %d\n", - crypt_z990_func_available(KMAC_TDEA_192)); -} - -static int -init(void) -{ - struct crypt_z990_query_status status = { - .high = 0, - .low = 0 - }; - - printk(KERN_INFO "crypt_z990: querying available crypto functions\n"); - crypt_z990_km(KM_QUERY, &status, NULL, NULL, 0); - printk(KERN_INFO "KM: %016llx %016llx\n", - (unsigned long long) status.high, - (unsigned long long) status.low); - status.high = status.low = 0; - crypt_z990_kmc(KMC_QUERY, &status, NULL, NULL, 0); - printk(KERN_INFO "KMC: %016llx %016llx\n", - (unsigned long long) status.high, - (unsigned long long) status.low); - status.high = status.low = 0; - crypt_z990_kimd(KIMD_QUERY, &status, NULL, 0); - printk(KERN_INFO "KIMD: %016llx %016llx\n", - (unsigned long long) status.high, - (unsigned long long) status.low); - status.high = status.low = 0; - crypt_z990_klmd(KLMD_QUERY, &status, NULL, 0); - printk(KERN_INFO "KLMD: %016llx %016llx\n", - (unsigned long long) status.high, - (unsigned long long) status.low); - status.high = status.low = 0; - crypt_z990_kmac(KMAC_QUERY, &status, NULL, 0); - printk(KERN_INFO "KMAC: %016llx %016llx\n", - (unsigned long long) status.high, - (unsigned long long) status.low); - - query_available_functions(); - return -1; -} - -static void __exit -cleanup(void) -{ -} - -module_init(init); -module_exit(cleanup); - -MODULE_LICENSE("GPL"); diff --git a/arch/s390/crypto/des_s390.c b/arch/s390/crypto/des_s390.c new file mode 100644 index 0000000..a38bb2a --- /dev/null +++ b/arch/s390/crypto/des_s390.c @@ -0,0 +1,284 @@ +/* + * Cryptographic API. + * + * s390 implementation of the DES Cipher Algorithm. + * + * Copyright (c) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation + * Author(s): Thomas Spatzier (tspat@de.ibm.com) + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ +#include +#include +#include +#include +#include +#include +#include "crypt_s390.h" +#include "crypto_des.h" + +#define DES_BLOCK_SIZE 8 +#define DES_KEY_SIZE 8 + +#define DES3_128_KEY_SIZE (2 * DES_KEY_SIZE) +#define DES3_128_BLOCK_SIZE DES_BLOCK_SIZE + +#define DES3_192_KEY_SIZE (3 * DES_KEY_SIZE) +#define DES3_192_BLOCK_SIZE DES_BLOCK_SIZE + +struct crypt_s390_des_ctx { + u8 iv[DES_BLOCK_SIZE]; + u8 key[DES_KEY_SIZE]; +}; + +struct crypt_s390_des3_128_ctx { + u8 iv[DES_BLOCK_SIZE]; + u8 key[DES3_128_KEY_SIZE]; +}; + +struct crypt_s390_des3_192_ctx { + u8 iv[DES_BLOCK_SIZE]; + u8 key[DES3_192_KEY_SIZE]; +}; + +static int +des_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) +{ + struct crypt_s390_des_ctx *dctx; + int ret; + + dctx = ctx; + //test if key is valid (not a weak key) + ret = crypto_des_check_key(key, keylen, flags); + if (ret == 0){ + memcpy(dctx->key, key, keylen); + } + return ret; +} + + +static void +des_encrypt(void *ctx, u8 *dst, const u8 *src) +{ + struct crypt_s390_des_ctx *dctx; + + dctx = ctx; + crypt_s390_km(KM_DEA_ENCRYPT, dctx->key, dst, src, DES_BLOCK_SIZE); +} + +static void +des_decrypt(void *ctx, u8 *dst, const u8 *src) +{ + struct crypt_s390_des_ctx *dctx; + + dctx = ctx; + crypt_s390_km(KM_DEA_DECRYPT, dctx->key, dst, src, DES_BLOCK_SIZE); +} + +static struct crypto_alg des_alg = { + .cra_name = "des", + .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_blocksize = DES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct crypt_s390_des_ctx), + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(des_alg.cra_list), + .cra_u = { .cipher = { + .cia_min_keysize = DES_KEY_SIZE, + .cia_max_keysize = DES_KEY_SIZE, + .cia_setkey = des_setkey, + .cia_encrypt = des_encrypt, + .cia_decrypt = des_decrypt } } +}; + +/* + * RFC2451: + * + * For DES-EDE3, there is no known need to reject weak or + * complementation keys. Any weakness is obviated by the use of + * multiple keys. + * + * However, if the two independent 64-bit keys are equal, + * then the DES3 operation is simply the same as DES. + * Implementers MUST reject keys that exhibit this property. + * + */ +static int +des3_128_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) +{ + int i, ret; + struct crypt_s390_des3_128_ctx *dctx; + const u8* temp_key = key; + + dctx = ctx; + if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) { + + *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; + return -EINVAL; + } + for (i = 0; i < 2; i++, temp_key += DES_KEY_SIZE) { + ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags); + if (ret < 0) + return ret; + } + memcpy(dctx->key, key, keylen); + return 0; +} + +static void +des3_128_encrypt(void *ctx, u8 *dst, const u8 *src) +{ + struct crypt_s390_des3_128_ctx *dctx; + + dctx = ctx; + crypt_s390_km(KM_TDEA_128_ENCRYPT, dctx->key, dst, (void*)src, + DES3_128_BLOCK_SIZE); +} + +static void +des3_128_decrypt(void *ctx, u8 *dst, const u8 *src) +{ + struct crypt_s390_des3_128_ctx *dctx; + + dctx = ctx; + crypt_s390_km(KM_TDEA_128_DECRYPT, dctx->key, dst, (void*)src, + DES3_128_BLOCK_SIZE); +} + +static struct crypto_alg des3_128_alg = { + .cra_name = "des3_ede128", + .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_blocksize = DES3_128_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct crypt_s390_des3_128_ctx), + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(des3_128_alg.cra_list), + .cra_u = { .cipher = { + .cia_min_keysize = DES3_128_KEY_SIZE, + .cia_max_keysize = DES3_128_KEY_SIZE, + .cia_setkey = des3_128_setkey, + .cia_encrypt = des3_128_encrypt, + .cia_decrypt = des3_128_decrypt } } +}; + +/* + * RFC2451: + * + * For DES-EDE3, there is no known need to reject weak or + * complementation keys. Any weakness is obviated by the use of + * multiple keys. + * + * However, if the first two or last two independent 64-bit keys are + * equal (k1 == k2 or k2 == k3), then the DES3 operation is simply the + * same as DES. Implementers MUST reject keys that exhibit this + * property. + * + */ +static int +des3_192_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) +{ + int i, ret; + struct crypt_s390_des3_192_ctx *dctx; + const u8* temp_key; + + dctx = ctx; + temp_key = key; + if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) && + memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2], + DES_KEY_SIZE))) { + + *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; + return -EINVAL; + } + for (i = 0; i < 3; i++, temp_key += DES_KEY_SIZE) { + ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags); + if (ret < 0){ + return ret; + } + } + memcpy(dctx->key, key, keylen); + return 0; +} + +static void +des3_192_encrypt(void *ctx, u8 *dst, const u8 *src) +{ + struct crypt_s390_des3_192_ctx *dctx; + + dctx = ctx; + crypt_s390_km(KM_TDEA_192_ENCRYPT, dctx->key, dst, (void*)src, + DES3_192_BLOCK_SIZE); +} + +static void +des3_192_decrypt(void *ctx, u8 *dst, const u8 *src) +{ + struct crypt_s390_des3_192_ctx *dctx; + + dctx = ctx; + crypt_s390_km(KM_TDEA_192_DECRYPT, dctx->key, dst, (void*)src, + DES3_192_BLOCK_SIZE); +} + +static struct crypto_alg des3_192_alg = { + .cra_name = "des3_ede", + .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_blocksize = DES3_192_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct crypt_s390_des3_192_ctx), + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(des3_192_alg.cra_list), + .cra_u = { .cipher = { + .cia_min_keysize = DES3_192_KEY_SIZE, + .cia_max_keysize = DES3_192_KEY_SIZE, + .cia_setkey = des3_192_setkey, + .cia_encrypt = des3_192_encrypt, + .cia_decrypt = des3_192_decrypt } } +}; + + + +static int +init(void) +{ + int ret; + + if (!crypt_s390_func_available(KM_DEA_ENCRYPT) || + !crypt_s390_func_available(KM_TDEA_128_ENCRYPT) || + !crypt_s390_func_available(KM_TDEA_192_ENCRYPT)){ + return -ENOSYS; + } + + ret = 0; + ret |= (crypto_register_alg(&des_alg) == 0)? 0:1; + ret |= (crypto_register_alg(&des3_128_alg) == 0)? 0:2; + ret |= (crypto_register_alg(&des3_192_alg) == 0)? 0:4; + if (ret){ + crypto_unregister_alg(&des3_192_alg); + crypto_unregister_alg(&des3_128_alg); + crypto_unregister_alg(&des_alg); + return -EEXIST; + } + + printk(KERN_INFO "crypt_s390: des_s390 loaded.\n"); + return 0; +} + +static void __exit +fini(void) +{ + crypto_unregister_alg(&des3_192_alg); + crypto_unregister_alg(&des3_128_alg); + crypto_unregister_alg(&des_alg); +} + +module_init(init); +module_exit(fini); + +MODULE_ALIAS("des"); +MODULE_ALIAS("des3_ede"); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("DES & Triple DES EDE Cipher Algorithms"); diff --git a/arch/s390/crypto/des_z990.c b/arch/s390/crypto/des_z990.c deleted file mode 100644 index 813cf37..0000000 --- a/arch/s390/crypto/des_z990.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Cryptographic API. - * - * z990 implementation of the DES Cipher Algorithm. - * - * Copyright (c) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation - * Author(s): Thomas Spatzier (tspat@de.ibm.com) - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - */ -#include -#include -#include -#include -#include -#include -#include "crypt_z990.h" -#include "crypto_des.h" - -#define DES_BLOCK_SIZE 8 -#define DES_KEY_SIZE 8 - -#define DES3_128_KEY_SIZE (2 * DES_KEY_SIZE) -#define DES3_128_BLOCK_SIZE DES_BLOCK_SIZE - -#define DES3_192_KEY_SIZE (3 * DES_KEY_SIZE) -#define DES3_192_BLOCK_SIZE DES_BLOCK_SIZE - -struct crypt_z990_des_ctx { - u8 iv[DES_BLOCK_SIZE]; - u8 key[DES_KEY_SIZE]; -}; - -struct crypt_z990_des3_128_ctx { - u8 iv[DES_BLOCK_SIZE]; - u8 key[DES3_128_KEY_SIZE]; -}; - -struct crypt_z990_des3_192_ctx { - u8 iv[DES_BLOCK_SIZE]; - u8 key[DES3_192_KEY_SIZE]; -}; - -static int -des_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) -{ - struct crypt_z990_des_ctx *dctx; - int ret; - - dctx = ctx; - //test if key is valid (not a weak key) - ret = crypto_des_check_key(key, keylen, flags); - if (ret == 0){ - memcpy(dctx->key, key, keylen); - } - return ret; -} - - -static void -des_encrypt(void *ctx, u8 *dst, const u8 *src) -{ - struct crypt_z990_des_ctx *dctx; - - dctx = ctx; - crypt_z990_km(KM_DEA_ENCRYPT, dctx->key, dst, src, DES_BLOCK_SIZE); -} - -static void -des_decrypt(void *ctx, u8 *dst, const u8 *src) -{ - struct crypt_z990_des_ctx *dctx; - - dctx = ctx; - crypt_z990_km(KM_DEA_DECRYPT, dctx->key, dst, src, DES_BLOCK_SIZE); -} - -static struct crypto_alg des_alg = { - .cra_name = "des", - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = DES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct crypt_z990_des_ctx), - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(des_alg.cra_list), - .cra_u = { .cipher = { - .cia_min_keysize = DES_KEY_SIZE, - .cia_max_keysize = DES_KEY_SIZE, - .cia_setkey = des_setkey, - .cia_encrypt = des_encrypt, - .cia_decrypt = des_decrypt } } -}; - -/* - * RFC2451: - * - * For DES-EDE3, there is no known need to reject weak or - * complementation keys. Any weakness is obviated by the use of - * multiple keys. - * - * However, if the two independent 64-bit keys are equal, - * then the DES3 operation is simply the same as DES. - * Implementers MUST reject keys that exhibit this property. - * - */ -static int -des3_128_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) -{ - int i, ret; - struct crypt_z990_des3_128_ctx *dctx; - const u8* temp_key = key; - - dctx = ctx; - if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) { - - *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; - return -EINVAL; - } - for (i = 0; i < 2; i++, temp_key += DES_KEY_SIZE) { - ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags); - if (ret < 0) - return ret; - } - memcpy(dctx->key, key, keylen); - return 0; -} - -static void -des3_128_encrypt(void *ctx, u8 *dst, const u8 *src) -{ - struct crypt_z990_des3_128_ctx *dctx; - - dctx = ctx; - crypt_z990_km(KM_TDEA_128_ENCRYPT, dctx->key, dst, (void*)src, - DES3_128_BLOCK_SIZE); -} - -static void -des3_128_decrypt(void *ctx, u8 *dst, const u8 *src) -{ - struct crypt_z990_des3_128_ctx *dctx; - - dctx = ctx; - crypt_z990_km(KM_TDEA_128_DECRYPT, dctx->key, dst, (void*)src, - DES3_128_BLOCK_SIZE); -} - -static struct crypto_alg des3_128_alg = { - .cra_name = "des3_ede128", - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = DES3_128_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct crypt_z990_des3_128_ctx), - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(des3_128_alg.cra_list), - .cra_u = { .cipher = { - .cia_min_keysize = DES3_128_KEY_SIZE, - .cia_max_keysize = DES3_128_KEY_SIZE, - .cia_setkey = des3_128_setkey, - .cia_encrypt = des3_128_encrypt, - .cia_decrypt = des3_128_decrypt } } -}; - -/* - * RFC2451: - * - * For DES-EDE3, there is no known need to reject weak or - * complementation keys. Any weakness is obviated by the use of - * multiple keys. - * - * However, if the first two or last two independent 64-bit keys are - * equal (k1 == k2 or k2 == k3), then the DES3 operation is simply the - * same as DES. Implementers MUST reject keys that exhibit this - * property. - * - */ -static int -des3_192_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) -{ - int i, ret; - struct crypt_z990_des3_192_ctx *dctx; - const u8* temp_key; - - dctx = ctx; - temp_key = key; - if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) && - memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2], - DES_KEY_SIZE))) { - - *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED; - return -EINVAL; - } - for (i = 0; i < 3; i++, temp_key += DES_KEY_SIZE) { - ret = crypto_des_check_key(temp_key, DES_KEY_SIZE, flags); - if (ret < 0){ - return ret; - } - } - memcpy(dctx->key, key, keylen); - return 0; -} - -static void -des3_192_encrypt(void *ctx, u8 *dst, const u8 *src) -{ - struct crypt_z990_des3_192_ctx *dctx; - - dctx = ctx; - crypt_z990_km(KM_TDEA_192_ENCRYPT, dctx->key, dst, (void*)src, - DES3_192_BLOCK_SIZE); -} - -static void -des3_192_decrypt(void *ctx, u8 *dst, const u8 *src) -{ - struct crypt_z990_des3_192_ctx *dctx; - - dctx = ctx; - crypt_z990_km(KM_TDEA_192_DECRYPT, dctx->key, dst, (void*)src, - DES3_192_BLOCK_SIZE); -} - -static struct crypto_alg des3_192_alg = { - .cra_name = "des3_ede", - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = DES3_192_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct crypt_z990_des3_192_ctx), - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(des3_192_alg.cra_list), - .cra_u = { .cipher = { - .cia_min_keysize = DES3_192_KEY_SIZE, - .cia_max_keysize = DES3_192_KEY_SIZE, - .cia_setkey = des3_192_setkey, - .cia_encrypt = des3_192_encrypt, - .cia_decrypt = des3_192_decrypt } } -}; - - - -static int -init(void) -{ - int ret; - - if (!crypt_z990_func_available(KM_DEA_ENCRYPT) || - !crypt_z990_func_available(KM_TDEA_128_ENCRYPT) || - !crypt_z990_func_available(KM_TDEA_192_ENCRYPT)){ - return -ENOSYS; - } - - ret = 0; - ret |= (crypto_register_alg(&des_alg) == 0)? 0:1; - ret |= (crypto_register_alg(&des3_128_alg) == 0)? 0:2; - ret |= (crypto_register_alg(&des3_192_alg) == 0)? 0:4; - if (ret){ - crypto_unregister_alg(&des3_192_alg); - crypto_unregister_alg(&des3_128_alg); - crypto_unregister_alg(&des_alg); - return -EEXIST; - } - - printk(KERN_INFO "crypt_z990: des_z990 loaded.\n"); - return 0; -} - -static void __exit -fini(void) -{ - crypto_unregister_alg(&des3_192_alg); - crypto_unregister_alg(&des3_128_alg); - crypto_unregister_alg(&des_alg); -} - -module_init(init); -module_exit(fini); - -MODULE_ALIAS("des"); -MODULE_ALIAS("des3_ede"); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("DES & Triple DES EDE Cipher Algorithms"); diff --git a/arch/s390/crypto/sha1_s390.c b/arch/s390/crypto/sha1_s390.c new file mode 100644 index 0000000..98c896b --- /dev/null +++ b/arch/s390/crypto/sha1_s390.c @@ -0,0 +1,167 @@ +/* + * Cryptographic API. + * + * s390 implementation of the SHA1 Secure Hash Algorithm. + * + * Derived from cryptoapi implementation, adapted for in-place + * scatterlist interface. Originally based on the public domain + * implementation written by Steve Reid. + * + * s390 Version: + * Copyright (C) 2003 IBM Deutschland GmbH, IBM Corporation + * Author(s): Thomas Spatzier (tspat@de.ibm.com) + * + * Derived from "crypto/sha1.c" + * Copyright (c) Alan Smithee. + * Copyright (c) Andrew McDonald + * Copyright (c) Jean-Francois Dive + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ +#include +#include +#include +#include +#include +#include +#include "crypt_s390.h" + +#define SHA1_DIGEST_SIZE 20 +#define SHA1_BLOCK_SIZE 64 + +struct crypt_s390_sha1_ctx { + u64 count; + u32 state[5]; + u32 buf_len; + u8 buffer[2 * SHA1_BLOCK_SIZE]; +}; + +static void +sha1_init(void *ctx) +{ + static const struct crypt_s390_sha1_ctx initstate = { + .state = { + 0x67452301, + 0xEFCDAB89, + 0x98BADCFE, + 0x10325476, + 0xC3D2E1F0 + }, + }; + memcpy(ctx, &initstate, sizeof(initstate)); +} + +static void +sha1_update(void *ctx, const u8 *data, unsigned int len) +{ + struct crypt_s390_sha1_ctx *sctx; + long imd_len; + + sctx = ctx; + sctx->count += len * 8; //message bit length + + //anything in buffer yet? -> must be completed + if (sctx->buf_len && (sctx->buf_len + len) >= SHA1_BLOCK_SIZE) { + //complete full block and hash + memcpy(sctx->buffer + sctx->buf_len, data, + SHA1_BLOCK_SIZE - sctx->buf_len); + crypt_s390_kimd(KIMD_SHA_1, sctx->state, sctx->buffer, + SHA1_BLOCK_SIZE); + data += SHA1_BLOCK_SIZE - sctx->buf_len; + len -= SHA1_BLOCK_SIZE - sctx->buf_len; + sctx->buf_len = 0; + } + + //rest of data contains full blocks? + imd_len = len & ~0x3ful; + if (imd_len){ + crypt_s390_kimd(KIMD_SHA_1, sctx->state, data, imd_len); + data += imd_len; + len -= imd_len; + } + //anything left? store in buffer + if (len){ + memcpy(sctx->buffer + sctx->buf_len , data, len); + sctx->buf_len += len; + } +} + + +static void +pad_message(struct crypt_s390_sha1_ctx* sctx) +{ + int index; + + index = sctx->buf_len; + sctx->buf_len = (sctx->buf_len < 56)? + SHA1_BLOCK_SIZE:2 * SHA1_BLOCK_SIZE; + //start pad with 1 + sctx->buffer[index] = 0x80; + //pad with zeros + index++; + memset(sctx->buffer + index, 0x00, sctx->buf_len - index); + //append length + memcpy(sctx->buffer + sctx->buf_len - 8, &sctx->count, + sizeof sctx->count); +} + +/* Add padding and return the message digest. */ +static void +sha1_final(void* ctx, u8 *out) +{ + struct crypt_s390_sha1_ctx *sctx = ctx; + + //must perform manual padding + pad_message(sctx); + crypt_s390_kimd(KIMD_SHA_1, sctx->state, sctx->buffer, sctx->buf_len); + //copy digest to out + memcpy(out, sctx->state, SHA1_DIGEST_SIZE); + /* Wipe context */ + memset(sctx, 0, sizeof *sctx); +} + +static struct crypto_alg alg = { + .cra_name = "sha1", + .cra_flags = CRYPTO_ALG_TYPE_DIGEST, + .cra_blocksize = SHA1_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct crypt_s390_sha1_ctx), + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), + .cra_u = { .digest = { + .dia_digestsize = SHA1_DIGEST_SIZE, + .dia_init = sha1_init, + .dia_update = sha1_update, + .dia_final = sha1_final } } +}; + +static int +init(void) +{ + int ret = -ENOSYS; + + if (crypt_s390_func_available(KIMD_SHA_1)){ + ret = crypto_register_alg(&alg); + if (ret == 0){ + printk(KERN_INFO "crypt_s390: sha1_s390 loaded.\n"); + } + } + return ret; +} + +static void __exit +fini(void) +{ + crypto_unregister_alg(&alg); +} + +module_init(init); +module_exit(fini); + +MODULE_ALIAS("sha1"); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm"); diff --git a/arch/s390/crypto/sha1_z990.c b/arch/s390/crypto/sha1_z990.c deleted file mode 100644 index 298174d..0000000 --- a/arch/s390/crypto/sha1_z990.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Cryptographic API. - * - * z990 implementation of the SHA1 Secure Hash Algorithm. - * - * Derived from cryptoapi implementation, adapted for in-place - * scatterlist interface. Originally based on the public domain - * implementation written by Steve Reid. - * - * s390 Version: - * Copyright (C) 2003 IBM Deutschland GmbH, IBM Corporation - * Author(s): Thomas Spatzier (tspat@de.ibm.com) - * - * Derived from "crypto/sha1.c" - * Copyright (c) Alan Smithee. - * Copyright (c) Andrew McDonald - * Copyright (c) Jean-Francois Dive - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - */ -#include -#include -#include -#include -#include -#include -#include "crypt_z990.h" - -#define SHA1_DIGEST_SIZE 20 -#define SHA1_BLOCK_SIZE 64 - -struct crypt_z990_sha1_ctx { - u64 count; - u32 state[5]; - u32 buf_len; - u8 buffer[2 * SHA1_BLOCK_SIZE]; -}; - -static void -sha1_init(void *ctx) -{ - static const struct crypt_z990_sha1_ctx initstate = { - .state = { - 0x67452301, - 0xEFCDAB89, - 0x98BADCFE, - 0x10325476, - 0xC3D2E1F0 - }, - }; - memcpy(ctx, &initstate, sizeof(initstate)); -} - -static void -sha1_update(void *ctx, const u8 *data, unsigned int len) -{ - struct crypt_z990_sha1_ctx *sctx; - long imd_len; - - sctx = ctx; - sctx->count += len * 8; //message bit length - - //anything in buffer yet? -> must be completed - if (sctx->buf_len && (sctx->buf_len + len) >= SHA1_BLOCK_SIZE) { - //complete full block and hash - memcpy(sctx->buffer + sctx->buf_len, data, - SHA1_BLOCK_SIZE - sctx->buf_len); - crypt_z990_kimd(KIMD_SHA_1, sctx->state, sctx->buffer, - SHA1_BLOCK_SIZE); - data += SHA1_BLOCK_SIZE - sctx->buf_len; - len -= SHA1_BLOCK_SIZE - sctx->buf_len; - sctx->buf_len = 0; - } - - //rest of data contains full blocks? - imd_len = len & ~0x3ful; - if (imd_len){ - crypt_z990_kimd(KIMD_SHA_1, sctx->state, data, imd_len); - data += imd_len; - len -= imd_len; - } - //anything left? store in buffer - if (len){ - memcpy(sctx->buffer + sctx->buf_len , data, len); - sctx->buf_len += len; - } -} - - -static void -pad_message(struct crypt_z990_sha1_ctx* sctx) -{ - int index; - - index = sctx->buf_len; - sctx->buf_len = (sctx->buf_len < 56)? - SHA1_BLOCK_SIZE:2 * SHA1_BLOCK_SIZE; - //start pad with 1 - sctx->buffer[index] = 0x80; - //pad with zeros - index++; - memset(sctx->buffer + index, 0x00, sctx->buf_len - index); - //append length - memcpy(sctx->buffer + sctx->buf_len - 8, &sctx->count, - sizeof sctx->count); -} - -/* Add padding and return the message digest. */ -static void -sha1_final(void* ctx, u8 *out) -{ - struct crypt_z990_sha1_ctx *sctx = ctx; - - //must perform manual padding - pad_message(sctx); - crypt_z990_kimd(KIMD_SHA_1, sctx->state, sctx->buffer, sctx->buf_len); - //copy digest to out - memcpy(out, sctx->state, SHA1_DIGEST_SIZE); - /* Wipe context */ - memset(sctx, 0, sizeof *sctx); -} - -static struct crypto_alg alg = { - .cra_name = "sha1", - .cra_flags = CRYPTO_ALG_TYPE_DIGEST, - .cra_blocksize = SHA1_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct crypt_z990_sha1_ctx), - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(alg.cra_list), - .cra_u = { .digest = { - .dia_digestsize = SHA1_DIGEST_SIZE, - .dia_init = sha1_init, - .dia_update = sha1_update, - .dia_final = sha1_final } } -}; - -static int -init(void) -{ - int ret = -ENOSYS; - - if (crypt_z990_func_available(KIMD_SHA_1)){ - ret = crypto_register_alg(&alg); - if (ret == 0){ - printk(KERN_INFO "crypt_z990: sha1_z990 loaded.\n"); - } - } - return ret; -} - -static void __exit -fini(void) -{ - crypto_unregister_alg(&alg); -} - -module_init(init); -module_exit(fini); - -MODULE_ALIAS("sha1"); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm"); diff --git a/arch/s390/defconfig b/arch/s390/defconfig index 0c495fe..0cb2995 100644 --- a/arch/s390/defconfig +++ b/arch/s390/defconfig @@ -632,13 +632,13 @@ CONFIG_CRYPTO=y # CONFIG_CRYPTO_MD4 is not set # CONFIG_CRYPTO_MD5 is not set # CONFIG_CRYPTO_SHA1 is not set -# CONFIG_CRYPTO_SHA1_Z990 is not set +# CONFIG_CRYPTO_SHA1_S390 is not set # CONFIG_CRYPTO_SHA256 is not set # CONFIG_CRYPTO_SHA512 is not set # CONFIG_CRYPTO_WP512 is not set # CONFIG_CRYPTO_TGR192 is not set # CONFIG_CRYPTO_DES is not set -# CONFIG_CRYPTO_DES_Z990 is not set +# CONFIG_CRYPTO_DES_S390 is not set # CONFIG_CRYPTO_BLOWFISH is not set # CONFIG_CRYPTO_TWOFISH is not set # CONFIG_CRYPTO_SERPENT is not set diff --git a/crypto/Kconfig b/crypto/Kconfig index 89299f4..85af571 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -40,8 +40,8 @@ config CRYPTO_SHA1 help SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2). -config CRYPTO_SHA1_Z990 - tristate "SHA1 digest algorithm for IBM zSeries z990" +config CRYPTO_SHA1_S390 + tristate "SHA1 digest algorithm (s390)" depends on CRYPTO && ARCH_S390 help SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2). @@ -98,8 +98,8 @@ config CRYPTO_DES help DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3). -config CRYPTO_DES_Z990 - tristate "DES and Triple DES cipher algorithms for IBM zSeries z990" +config CRYPTO_DES_S390 + tristate "DES and Triple DES cipher algorithms (s390)" depends on CRYPTO && ARCH_S390 help DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3). -- cgit v1.1 From 0a497c17fee428604e06320272ff74415eacdc31 Mon Sep 17 00:00:00 2001 From: Jan Glauber Date: Fri, 6 Jan 2006 00:19:18 -0800 Subject: [PATCH] s390: sha256 support Add support for the hardware accelerated sha256 crypto algorithm. Signed-off-by: Jan Glauber Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/crypto/Makefile | 1 + arch/s390/crypto/crypt_s390.h | 2 + arch/s390/crypto/crypt_s390_query.c | 6 +- arch/s390/crypto/sha256_s390.c | 151 ++++++++++++++++++++++++++++++++++++ arch/s390/defconfig | 1 + crypto/Kconfig | 11 +++ 6 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 arch/s390/crypto/sha256_s390.c diff --git a/arch/s390/crypto/Makefile b/arch/s390/crypto/Makefile index 50843f8..3fccf61 100644 --- a/arch/s390/crypto/Makefile +++ b/arch/s390/crypto/Makefile @@ -3,6 +3,7 @@ # obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s390.o +obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o obj-$(CONFIG_CRYPTO_TEST) += crypt_s390_query.o diff --git a/arch/s390/crypto/crypt_s390.h b/arch/s390/crypto/crypt_s390.h index 4d24f66..b70a410 100644 --- a/arch/s390/crypto/crypt_s390.h +++ b/arch/s390/crypto/crypt_s390.h @@ -61,6 +61,7 @@ enum crypt_s390_kmc_func { enum crypt_s390_kimd_func { KIMD_QUERY = CRYPT_S390_KIMD | 0, KIMD_SHA_1 = CRYPT_S390_KIMD | 1, + KIMD_SHA_256 = CRYPT_S390_KIMD | 2, }; /* function codes for KLMD (COMPUTE LAST MESSAGE DIGEST) @@ -69,6 +70,7 @@ enum crypt_s390_kimd_func { enum crypt_s390_klmd_func { KLMD_QUERY = CRYPT_S390_KLMD | 0, KLMD_SHA_1 = CRYPT_S390_KLMD | 1, + KLMD_SHA_256 = CRYPT_S390_KLMD | 2, }; /* function codes for KMAC (COMPUTE MESSAGE AUTHENTICATION CODE) diff --git a/arch/s390/crypto/crypt_s390_query.c b/arch/s390/crypto/crypt_s390_query.c index 0fa6bdf..67081b8 100644 --- a/arch/s390/crypto/crypt_s390_query.c +++ b/arch/s390/crypto/crypt_s390_query.c @@ -48,16 +48,20 @@ static void query_available_functions(void) crypt_s390_func_available(KIMD_QUERY)); printk(KERN_INFO "KIMD_SHA_1: %d\n", crypt_s390_func_available(KIMD_SHA_1)); + printk(KERN_INFO "KIMD_SHA_256: %d\n", + crypt_s390_func_available(KIMD_SHA_256)); /* query available KLMD functions */ printk(KERN_INFO "KLMD_QUERY: %d\n", crypt_s390_func_available(KLMD_QUERY)); printk(KERN_INFO "KLMD_SHA_1: %d\n", crypt_s390_func_available(KLMD_SHA_1)); + printk(KERN_INFO "KLMD_SHA_256: %d\n", + crypt_s390_func_available(KLMD_SHA_256)); /* query available KMAC functions */ printk(KERN_INFO "KMAC_QUERY: %d\n", - crypt_s3990_func_available(KMAC_QUERY)); + crypt_s390_func_available(KMAC_QUERY)); printk(KERN_INFO "KMAC_DEA: %d\n", crypt_s390_func_available(KMAC_DEA)); printk(KERN_INFO "KMAC_TDEA_128: %d\n", diff --git a/arch/s390/crypto/sha256_s390.c b/arch/s390/crypto/sha256_s390.c new file mode 100644 index 0000000..b75bdbd --- /dev/null +++ b/arch/s390/crypto/sha256_s390.c @@ -0,0 +1,151 @@ +/* + * Cryptographic API. + * + * s390 implementation of the SHA256 Secure Hash Algorithm. + * + * s390 Version: + * Copyright (C) 2005 IBM Deutschland GmbH, IBM Corporation + * Author(s): Jan Glauber (jang@de.ibm.com) + * + * Derived from "crypto/sha256.c" + * and "arch/s390/crypto/sha1_s390.c" + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ +#include +#include +#include + +#include "crypt_s390.h" + +#define SHA256_DIGEST_SIZE 32 +#define SHA256_BLOCK_SIZE 64 + +struct s390_sha256_ctx { + u64 count; + u32 state[8]; + u8 buf[2 * SHA256_BLOCK_SIZE]; +}; + +static void sha256_init(void *ctx) +{ + struct s390_sha256_ctx *sctx = ctx; + + sctx->state[0] = 0x6a09e667; + sctx->state[1] = 0xbb67ae85; + sctx->state[2] = 0x3c6ef372; + sctx->state[3] = 0xa54ff53a; + sctx->state[4] = 0x510e527f; + sctx->state[5] = 0x9b05688c; + sctx->state[6] = 0x1f83d9ab; + sctx->state[7] = 0x5be0cd19; + sctx->count = 0; + memset(sctx->buf, 0, sizeof(sctx->buf)); +} + +static void sha256_update(void *ctx, const u8 *data, unsigned int len) +{ + struct s390_sha256_ctx *sctx = ctx; + unsigned int index; + + /* how much is already in the buffer? */ + index = sctx->count / 8 & 0x3f; + + /* update message bit length */ + sctx->count += len * 8; + + /* process one block */ + if ((index + len) >= SHA256_BLOCK_SIZE) { + memcpy(sctx->buf + index, data, SHA256_BLOCK_SIZE - index); + crypt_s390_kimd(KIMD_SHA_256, sctx->state, sctx->buf, + SHA256_BLOCK_SIZE); + data += SHA256_BLOCK_SIZE - index; + len -= SHA256_BLOCK_SIZE - index; + } + + /* anything left? */ + if (len) + memcpy(sctx->buf + index , data, len); +} + +static void pad_message(struct s390_sha256_ctx* sctx) +{ + int index, end; + + index = sctx->count / 8 & 0x3f; + end = index < 56 ? SHA256_BLOCK_SIZE : 2 * SHA256_BLOCK_SIZE; + + /* start pad with 1 */ + sctx->buf[index] = 0x80; + + /* pad with zeros */ + index++; + memset(sctx->buf + index, 0x00, end - index - 8); + + /* append message length */ + memcpy(sctx->buf + end - 8, &sctx->count, sizeof sctx->count); + + sctx->count = end * 8; +} + +/* Add padding and return the message digest */ +static void sha256_final(void* ctx, u8 *out) +{ + struct s390_sha256_ctx *sctx = ctx; + + /* must perform manual padding */ + pad_message(sctx); + + crypt_s390_kimd(KIMD_SHA_256, sctx->state, sctx->buf, + sctx->count / 8); + + /* copy digest to out */ + memcpy(out, sctx->state, SHA256_DIGEST_SIZE); + + /* wipe context */ + memset(sctx, 0, sizeof *sctx); +} + +static struct crypto_alg alg = { + .cra_name = "sha256", + .cra_flags = CRYPTO_ALG_TYPE_DIGEST, + .cra_blocksize = SHA256_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct s390_sha256_ctx), + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), + .cra_u = { .digest = { + .dia_digestsize = SHA256_DIGEST_SIZE, + .dia_init = sha256_init, + .dia_update = sha256_update, + .dia_final = sha256_final } } +}; + +static int init(void) +{ + int ret; + + if (!crypt_s390_func_available(KIMD_SHA_256)) + return -ENOSYS; + + ret = crypto_register_alg(&alg); + if (ret != 0) + printk(KERN_INFO "crypt_s390: sha256_s390 couldn't be loaded."); + return ret; +} + +static void __exit fini(void) +{ + crypto_unregister_alg(&alg); +} + +module_init(init); +module_exit(fini); + +MODULE_ALIAS("sha256"); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("SHA256 Secure Hash Algorithm"); diff --git a/arch/s390/defconfig b/arch/s390/defconfig index 0cb2995..fd00a9f 100644 --- a/arch/s390/defconfig +++ b/arch/s390/defconfig @@ -634,6 +634,7 @@ CONFIG_CRYPTO=y # CONFIG_CRYPTO_SHA1 is not set # CONFIG_CRYPTO_SHA1_S390 is not set # CONFIG_CRYPTO_SHA256 is not set +# CONFIG_CRYPTO_SHA256_S390 is not set # CONFIG_CRYPTO_SHA512 is not set # CONFIG_CRYPTO_WP512 is not set # CONFIG_CRYPTO_TGR192 is not set diff --git a/crypto/Kconfig b/crypto/Kconfig index 85af571..9fdab74 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -44,6 +44,7 @@ config CRYPTO_SHA1_S390 tristate "SHA1 digest algorithm (s390)" depends on CRYPTO && ARCH_S390 help + This is the s390 hardware accelerated implementation of the SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2). config CRYPTO_SHA256 @@ -55,6 +56,16 @@ config CRYPTO_SHA256 This version of SHA implements a 256 bit hash with 128 bits of security against collision attacks. +config CRYPTO_SHA256_S390 + tristate "SHA256 digest algorithm (s390)" + depends on CRYPTO && ARCH_S390 + help + This is the s390 hardware accelerated implementation of the + SHA256 secure hash standard (DFIPS 180-2). + + This version of SHA implements a 256 bit hash with 128 bits of + security against collision attacks. + config CRYPTO_SHA512 tristate "SHA384 and SHA512 digest algorithms" depends on CRYPTO -- cgit v1.1 From bf754ae8ef8bc443c067601d9401103e4001e7c5 Mon Sep 17 00:00:00 2001 From: Jan Glauber Date: Fri, 6 Jan 2006 00:19:18 -0800 Subject: [PATCH] s390: aes support Add support for the hardware accelerated AES crypto algorithm. Signed-off-by: Jan Glauber Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/crypto/Makefile | 1 + arch/s390/crypto/aes_s390.c | 248 ++++++++++++++++++++++++++++++++++++ arch/s390/crypto/crypt_s390.h | 40 ++++-- arch/s390/crypto/crypt_s390_query.c | 12 ++ arch/s390/defconfig | 1 + crypto/Kconfig | 20 +++ 6 files changed, 308 insertions(+), 14 deletions(-) create mode 100644 arch/s390/crypto/aes_s390.c diff --git a/arch/s390/crypto/Makefile b/arch/s390/crypto/Makefile index 3fccf61..bfe2541 100644 --- a/arch/s390/crypto/Makefile +++ b/arch/s390/crypto/Makefile @@ -5,5 +5,6 @@ obj-$(CONFIG_CRYPTO_SHA1_S390) += sha1_s390.o obj-$(CONFIG_CRYPTO_SHA256_S390) += sha256_s390.o obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o des_check_key.o +obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o obj-$(CONFIG_CRYPTO_TEST) += crypt_s390_query.o diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c new file mode 100644 index 0000000..7a1033d --- /dev/null +++ b/arch/s390/crypto/aes_s390.c @@ -0,0 +1,248 @@ +/* + * Cryptographic API. + * + * s390 implementation of the AES Cipher Algorithm. + * + * s390 Version: + * Copyright (C) 2005 IBM Deutschland GmbH, IBM Corporation + * Author(s): Jan Glauber (jang@de.ibm.com) + * + * Derived from "crypto/aes.c" + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + */ + +#include +#include +#include +#include "crypt_s390.h" + +#define AES_MIN_KEY_SIZE 16 +#define AES_MAX_KEY_SIZE 32 + +/* data block size for all key lengths */ +#define AES_BLOCK_SIZE 16 + +int has_aes_128 = 0; +int has_aes_192 = 0; +int has_aes_256 = 0; + +struct s390_aes_ctx { + u8 iv[AES_BLOCK_SIZE]; + u8 key[AES_MAX_KEY_SIZE]; + int key_len; +}; + +static int aes_set_key(void *ctx, const u8 *in_key, unsigned int key_len, + u32 *flags) +{ + struct s390_aes_ctx *sctx = ctx; + + switch (key_len) { + case 16: + if (!has_aes_128) + goto fail; + break; + case 24: + if (!has_aes_192) + goto fail; + + break; + case 32: + if (!has_aes_256) + goto fail; + break; + default: + /* invalid key length */ + goto fail; + break; + } + + sctx->key_len = key_len; + memcpy(sctx->key, in_key, key_len); + return 0; +fail: + *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; + return -EINVAL; +} + +static void aes_encrypt(void *ctx, u8 *out, const u8 *in) +{ + const struct s390_aes_ctx *sctx = ctx; + + switch (sctx->key_len) { + case 16: + crypt_s390_km(KM_AES_128_ENCRYPT, &sctx->key, out, in, + AES_BLOCK_SIZE); + break; + case 24: + crypt_s390_km(KM_AES_192_ENCRYPT, &sctx->key, out, in, + AES_BLOCK_SIZE); + break; + case 32: + crypt_s390_km(KM_AES_256_ENCRYPT, &sctx->key, out, in, + AES_BLOCK_SIZE); + break; + } +} + +static void aes_decrypt(void *ctx, u8 *out, const u8 *in) +{ + const struct s390_aes_ctx *sctx = ctx; + + switch (sctx->key_len) { + case 16: + crypt_s390_km(KM_AES_128_DECRYPT, &sctx->key, out, in, + AES_BLOCK_SIZE); + break; + case 24: + crypt_s390_km(KM_AES_192_DECRYPT, &sctx->key, out, in, + AES_BLOCK_SIZE); + break; + case 32: + crypt_s390_km(KM_AES_256_DECRYPT, &sctx->key, out, in, + AES_BLOCK_SIZE); + break; + } +} + +static unsigned int aes_encrypt_ecb(const struct cipher_desc *desc, u8 *out, + const u8 *in, unsigned int nbytes) +{ + struct s390_aes_ctx *sctx = crypto_tfm_ctx(desc->tfm); + + switch (sctx->key_len) { + case 16: + crypt_s390_km(KM_AES_128_ENCRYPT, &sctx->key, out, in, nbytes); + break; + case 24: + crypt_s390_km(KM_AES_192_ENCRYPT, &sctx->key, out, in, nbytes); + break; + case 32: + crypt_s390_km(KM_AES_256_ENCRYPT, &sctx->key, out, in, nbytes); + break; + } + return nbytes & ~(AES_BLOCK_SIZE - 1); +} + +static unsigned int aes_decrypt_ecb(const struct cipher_desc *desc, u8 *out, + const u8 *in, unsigned int nbytes) +{ + struct s390_aes_ctx *sctx = crypto_tfm_ctx(desc->tfm); + + switch (sctx->key_len) { + case 16: + crypt_s390_km(KM_AES_128_DECRYPT, &sctx->key, out, in, nbytes); + break; + case 24: + crypt_s390_km(KM_AES_192_DECRYPT, &sctx->key, out, in, nbytes); + break; + case 32: + crypt_s390_km(KM_AES_256_DECRYPT, &sctx->key, out, in, nbytes); + break; + } + return nbytes & ~(AES_BLOCK_SIZE - 1); +} + +static unsigned int aes_encrypt_cbc(const struct cipher_desc *desc, u8 *out, + const u8 *in, unsigned int nbytes) +{ + struct s390_aes_ctx *sctx = crypto_tfm_ctx(desc->tfm); + + memcpy(&sctx->iv, desc->info, AES_BLOCK_SIZE); + switch (sctx->key_len) { + case 16: + crypt_s390_kmc(KMC_AES_128_ENCRYPT, &sctx->iv, out, in, nbytes); + break; + case 24: + crypt_s390_kmc(KMC_AES_192_ENCRYPT, &sctx->iv, out, in, nbytes); + break; + case 32: + crypt_s390_kmc(KMC_AES_256_ENCRYPT, &sctx->iv, out, in, nbytes); + break; + } + memcpy(desc->info, &sctx->iv, AES_BLOCK_SIZE); + + return nbytes & ~(AES_BLOCK_SIZE - 1); +} + +static unsigned int aes_decrypt_cbc(const struct cipher_desc *desc, u8 *out, + const u8 *in, unsigned int nbytes) +{ + struct s390_aes_ctx *sctx = crypto_tfm_ctx(desc->tfm); + + memcpy(&sctx->iv, desc->info, AES_BLOCK_SIZE); + switch (sctx->key_len) { + case 16: + crypt_s390_kmc(KMC_AES_128_DECRYPT, &sctx->iv, out, in, nbytes); + break; + case 24: + crypt_s390_kmc(KMC_AES_192_DECRYPT, &sctx->iv, out, in, nbytes); + break; + case 32: + crypt_s390_kmc(KMC_AES_256_DECRYPT, &sctx->iv, out, in, nbytes); + break; + } + return nbytes & ~(AES_BLOCK_SIZE - 1); +} + + +static struct crypto_alg aes_alg = { + .cra_name = "aes", + .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_blocksize = AES_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct s390_aes_ctx), + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), + .cra_u = { + .cipher = { + .cia_min_keysize = AES_MIN_KEY_SIZE, + .cia_max_keysize = AES_MAX_KEY_SIZE, + .cia_setkey = aes_set_key, + .cia_encrypt = aes_encrypt, + .cia_decrypt = aes_decrypt, + .cia_encrypt_ecb = aes_encrypt_ecb, + .cia_decrypt_ecb = aes_decrypt_ecb, + .cia_encrypt_cbc = aes_encrypt_cbc, + .cia_decrypt_cbc = aes_decrypt_cbc, + } + } +}; + +static int __init aes_init(void) +{ + int ret; + + if (crypt_s390_func_available(KM_AES_128_ENCRYPT)) + has_aes_128 = 1; + if (crypt_s390_func_available(KM_AES_192_ENCRYPT)) + has_aes_192 = 1; + if (crypt_s390_func_available(KM_AES_256_ENCRYPT)) + has_aes_256 = 1; + + if (!has_aes_128 && !has_aes_192 && !has_aes_256) + return -ENOSYS; + + ret = crypto_register_alg(&aes_alg); + if (ret != 0) + printk(KERN_INFO "crypt_s390: aes_s390 couldn't be loaded.\n"); + return ret; +} + +static void __exit aes_fini(void) +{ + crypto_unregister_alg(&aes_alg); +} + +module_init(aes_init); +module_exit(aes_fini); + +MODULE_ALIAS("aes"); + +MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm"); +MODULE_LICENSE("GPL"); + diff --git a/arch/s390/crypto/crypt_s390.h b/arch/s390/crypto/crypt_s390.h index b70a410..d6712cf 100644 --- a/arch/s390/crypto/crypt_s390.h +++ b/arch/s390/crypto/crypt_s390.h @@ -33,26 +33,38 @@ enum crypt_s390_operations { * 0x80 is the decipher modifier bit */ enum crypt_s390_km_func { - KM_QUERY = CRYPT_S390_KM | 0, - KM_DEA_ENCRYPT = CRYPT_S390_KM | 1, - KM_DEA_DECRYPT = CRYPT_S390_KM | 1 | 0x80, - KM_TDEA_128_ENCRYPT = CRYPT_S390_KM | 2, - KM_TDEA_128_DECRYPT = CRYPT_S390_KM | 2 | 0x80, - KM_TDEA_192_ENCRYPT = CRYPT_S390_KM | 3, - KM_TDEA_192_DECRYPT = CRYPT_S390_KM | 3 | 0x80, + KM_QUERY = CRYPT_S390_KM | 0x0, + KM_DEA_ENCRYPT = CRYPT_S390_KM | 0x1, + KM_DEA_DECRYPT = CRYPT_S390_KM | 0x1 | 0x80, + KM_TDEA_128_ENCRYPT = CRYPT_S390_KM | 0x2, + KM_TDEA_128_DECRYPT = CRYPT_S390_KM | 0x2 | 0x80, + KM_TDEA_192_ENCRYPT = CRYPT_S390_KM | 0x3, + KM_TDEA_192_DECRYPT = CRYPT_S390_KM | 0x3 | 0x80, + KM_AES_128_ENCRYPT = CRYPT_S390_KM | 0x12, + KM_AES_128_DECRYPT = CRYPT_S390_KM | 0x12 | 0x80, + KM_AES_192_ENCRYPT = CRYPT_S390_KM | 0x13, + KM_AES_192_DECRYPT = CRYPT_S390_KM | 0x13 | 0x80, + KM_AES_256_ENCRYPT = CRYPT_S390_KM | 0x14, + KM_AES_256_DECRYPT = CRYPT_S390_KM | 0x14 | 0x80, }; /* function codes for KMC (CIPHER MESSAGE WITH CHAINING) * instruction */ enum crypt_s390_kmc_func { - KMC_QUERY = CRYPT_S390_KMC | 0, - KMC_DEA_ENCRYPT = CRYPT_S390_KMC | 1, - KMC_DEA_DECRYPT = CRYPT_S390_KMC | 1 | 0x80, - KMC_TDEA_128_ENCRYPT = CRYPT_S390_KMC | 2, - KMC_TDEA_128_DECRYPT = CRYPT_S390_KMC | 2 | 0x80, - KMC_TDEA_192_ENCRYPT = CRYPT_S390_KMC | 3, - KMC_TDEA_192_DECRYPT = CRYPT_S390_KMC | 3 | 0x80, + KMC_QUERY = CRYPT_S390_KMC | 0x0, + KMC_DEA_ENCRYPT = CRYPT_S390_KMC | 0x1, + KMC_DEA_DECRYPT = CRYPT_S390_KMC | 0x1 | 0x80, + KMC_TDEA_128_ENCRYPT = CRYPT_S390_KMC | 0x2, + KMC_TDEA_128_DECRYPT = CRYPT_S390_KMC | 0x2 | 0x80, + KMC_TDEA_192_ENCRYPT = CRYPT_S390_KMC | 0x3, + KMC_TDEA_192_DECRYPT = CRYPT_S390_KMC | 0x3 | 0x80, + KMC_AES_128_ENCRYPT = CRYPT_S390_KMC | 0x12, + KMC_AES_128_DECRYPT = CRYPT_S390_KMC | 0x12 | 0x80, + KMC_AES_192_ENCRYPT = CRYPT_S390_KMC | 0x13, + KMC_AES_192_DECRYPT = CRYPT_S390_KMC | 0x13 | 0x80, + KMC_AES_256_ENCRYPT = CRYPT_S390_KMC | 0x14, + KMC_AES_256_DECRYPT = CRYPT_S390_KMC | 0x14 | 0x80, }; /* function codes for KIMD (COMPUTE INTERMEDIATE MESSAGE DIGEST) diff --git a/arch/s390/crypto/crypt_s390_query.c b/arch/s390/crypto/crypt_s390_query.c index 67081b8..def02bd 100644 --- a/arch/s390/crypto/crypt_s390_query.c +++ b/arch/s390/crypto/crypt_s390_query.c @@ -32,6 +32,12 @@ static void query_available_functions(void) crypt_s390_func_available(KM_TDEA_128_ENCRYPT)); printk(KERN_INFO "KM_TDEA_192: %d\n", crypt_s390_func_available(KM_TDEA_192_ENCRYPT)); + printk(KERN_INFO "KM_AES_128: %d\n", + crypt_s390_func_available(KM_AES_128_ENCRYPT)); + printk(KERN_INFO "KM_AES_192: %d\n", + crypt_s390_func_available(KM_AES_192_ENCRYPT)); + printk(KERN_INFO "KM_AES_256: %d\n", + crypt_s390_func_available(KM_AES_256_ENCRYPT)); /* query available KMC functions */ printk(KERN_INFO "KMC_QUERY: %d\n", @@ -42,6 +48,12 @@ static void query_available_functions(void) crypt_s390_func_available(KMC_TDEA_128_ENCRYPT)); printk(KERN_INFO "KMC_TDEA_192: %d\n", crypt_s390_func_available(KMC_TDEA_192_ENCRYPT)); + printk(KERN_INFO "KMC_AES_128: %d\n", + crypt_s390_func_available(KMC_AES_128_ENCRYPT)); + printk(KERN_INFO "KMC_AES_192: %d\n", + crypt_s390_func_available(KMC_AES_192_ENCRYPT)); + printk(KERN_INFO "KMC_AES_256: %d\n", + crypt_s390_func_available(KMC_AES_256_ENCRYPT)); /* query available KIMD fucntions */ printk(KERN_INFO "KIMD_QUERY: %d\n", diff --git a/arch/s390/defconfig b/arch/s390/defconfig index fd00a9f..f195c7e 100644 --- a/arch/s390/defconfig +++ b/arch/s390/defconfig @@ -644,6 +644,7 @@ CONFIG_CRYPTO=y # CONFIG_CRYPTO_TWOFISH is not set # CONFIG_CRYPTO_SERPENT is not set # CONFIG_CRYPTO_AES is not set +# CONFIG_CRYPTO_AES_S390 is not set # CONFIG_CRYPTO_CAST5 is not set # CONFIG_CRYPTO_CAST6 is not set # CONFIG_CRYPTO_TEA is not set diff --git a/crypto/Kconfig b/crypto/Kconfig index 9fdab74..c696f7a 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -215,6 +215,26 @@ config CRYPTO_AES_X86_64 See for more information. +config CRYPTO_AES_S390 + tristate "AES cipher algorithms (s390)" + depends on CRYPTO && ARCH_S390 + help + This is the s390 hardware accelerated implementation of the + AES cipher algorithms (FIPS-197). AES uses the Rijndael + algorithm. + + Rijndael appears to be consistently a very good performer in + both hardware and software across a wide range of computing + environments regardless of its use in feedback or non-feedback + modes. Its key setup time is excellent, and its key agility is + good. Rijndael's very low memory requirements make it very well + suited for restricted-space environments, in which it also + demonstrates excellent performance. Rijndael's operations are + among the easiest to defend against power and timing attacks. + + On s390 the System z9-109 currently only supports the key size + of 128 bit. + config CRYPTO_CAST5 tristate "CAST5 (CAST-128) cipher algorithm" depends on CRYPTO -- cgit v1.1 From 05f29fcdb0c6c99484c8bea5e244fe2f4edc9337 Mon Sep 17 00:00:00 2001 From: Jan Glauber Date: Fri, 6 Jan 2006 00:19:19 -0800 Subject: [PATCH] s390: in-kernel crypto test vectors Add new test vectors to the AES test suite for AES CBC and AES with plaintext larger than AES blocksize. Signed-off-by: Jan Glauber Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- crypto/tcrypt.c | 4 ++++ crypto/tcrypt.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 53f4ee8..49e344f 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -805,6 +805,8 @@ static void do_test(void) //AES test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS); test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS); + test_cipher ("aes", MODE_CBC, ENCRYPT, aes_cbc_enc_tv_template, AES_CBC_ENC_TEST_VECTORS); + test_cipher ("aes", MODE_CBC, DECRYPT, aes_cbc_dec_tv_template, AES_CBC_DEC_TEST_VECTORS); //CAST5 test_cipher ("cast5", MODE_ECB, ENCRYPT, cast5_enc_tv_template, CAST5_ENC_TEST_VECTORS); @@ -910,6 +912,8 @@ static void do_test(void) case 10: test_cipher ("aes", MODE_ECB, ENCRYPT, aes_enc_tv_template, AES_ENC_TEST_VECTORS); test_cipher ("aes", MODE_ECB, DECRYPT, aes_dec_tv_template, AES_DEC_TEST_VECTORS); + test_cipher ("aes", MODE_CBC, ENCRYPT, aes_cbc_enc_tv_template, AES_CBC_ENC_TEST_VECTORS); + test_cipher ("aes", MODE_CBC, DECRYPT, aes_cbc_dec_tv_template, AES_CBC_DEC_TEST_VECTORS); break; case 11: diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h index 522ffd4..733d07e 100644 --- a/crypto/tcrypt.h +++ b/crypto/tcrypt.h @@ -1836,6 +1836,8 @@ static struct cipher_testvec cast6_dec_tv_template[] = { */ #define AES_ENC_TEST_VECTORS 3 #define AES_DEC_TEST_VECTORS 3 +#define AES_CBC_ENC_TEST_VECTORS 2 +#define AES_CBC_DEC_TEST_VECTORS 2 static struct cipher_testvec aes_enc_tv_template[] = { { /* From FIPS-197 */ @@ -1911,6 +1913,68 @@ static struct cipher_testvec aes_dec_tv_template[] = { }, }; +static struct cipher_testvec aes_cbc_enc_tv_template[] = { + { /* From RFC 3602 */ + .key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, + 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 }, + .klen = 16, + .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, + 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 }, + .input = { "Single block msg" }, + .ilen = 16, + .result = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, + 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a }, + .rlen = 16, + }, { + .key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0, + 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a }, + .klen = 16, + .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28, + 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }, + .input = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, + .ilen = 32, + .result = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a, + 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a, + 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9, + 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 }, + .rlen = 32, + }, +}; + +static struct cipher_testvec aes_cbc_dec_tv_template[] = { + { /* From RFC 3602 */ + .key = { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, + 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 }, + .klen = 16, + .iv = { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, + 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 }, + .input = { 0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, + 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a }, + .ilen = 16, + .result = { "Single block msg" }, + .rlen = 16, + }, { + .key = { 0xc2, 0x86, 0x69, 0x6d, 0x88, 0x7c, 0x9a, 0xa0, + 0x61, 0x1b, 0xbb, 0x3e, 0x20, 0x25, 0xa4, 0x5a }, + .klen = 16, + .iv = { 0x56, 0x2e, 0x17, 0x99, 0x6d, 0x09, 0x3d, 0x28, + 0xdd, 0xb3, 0xba, 0x69, 0x5a, 0x2e, 0x6f, 0x58 }, + .input = { 0xd2, 0x96, 0xcd, 0x94, 0xc2, 0xcc, 0xcf, 0x8a, + 0x3a, 0x86, 0x30, 0x28, 0xb5, 0xe1, 0xdc, 0x0a, + 0x75, 0x86, 0x60, 0x2d, 0x25, 0x3c, 0xff, 0xf9, + 0x1b, 0x82, 0x66, 0xbe, 0xa6, 0xd6, 0x1a, 0xb1 }, + .ilen = 32, + .result = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }, + .rlen = 32, + }, +}; + /* Cast5 test vectors from RFC 2144 */ #define CAST5_ENC_TEST_VECTORS 3 #define CAST5_DEC_TEST_VECTORS 3 -- cgit v1.1 From 8129ee164267dc030b8e1d541ee3643c0b9f2fa1 Mon Sep 17 00:00:00 2001 From: Frank Pavlic Date: Fri, 6 Jan 2006 00:19:20 -0800 Subject: [PATCH] s390: qdio V=V pass-through New feature V=V qdio pass-through. QDIO and HiperSockets processing in z/VM V=V guest environments (as well as V=R with z/VM running in LPAR mode) requires shadowing of all QDIO architecture queue elements. Especially the shadowing of SBALs and SLSBs structures in the hypervisor, and the need to issue SIGA SYNC operations to observe state changes, eventually causes significant CPU processing overhead in the hypervisor. The QDIO pass-through support for V=V guests avoids the shadowing of SBALs and SLSBs. This significantly reduces the hypervisor overhead for QDIO based I/O. Signed-off-by: Frank Pavlic Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/Kconfig | 7 +- drivers/s390/cio/chsc.h | 4 +- drivers/s390/cio/qdio.c | 589 ++++++++++++++++++++++++++++++++++++++---------- drivers/s390/cio/qdio.h | 104 ++++++--- include/asm-s390/qdio.h | 8 +- 5 files changed, 556 insertions(+), 156 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 477ac27..1846fbf 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -240,8 +240,8 @@ config MACHCHK_WARNING config QDIO tristate "QDIO support" ---help--- - This driver provides the Queued Direct I/O base support for the - IBM S/390 (G5 and G6) and eServer zSeries (z800, z890, z900 and z990). + This driver provides the Queued Direct I/O base support for + IBM mainframes. For details please refer to the documentation provided by IBM at @@ -263,7 +263,8 @@ config QDIO_DEBUG bool "Extended debugging information" depends on QDIO help - Say Y here to get extended debugging output in /proc/s390dbf/qdio... + Say Y here to get extended debugging output in + /sys/kernel/debug/s390dbf/qdio... Warning: this option reduces the performance of the QDIO module. If unsure, say N. diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h index be20da4..6945013 100644 --- a/drivers/s390/cio/chsc.h +++ b/drivers/s390/cio/chsc.h @@ -43,7 +43,9 @@ struct css_general_char { u32 ext_mb : 1; /* bit 48 */ u32 : 7; u32 aif_tdd : 1; /* bit 56 */ - u32 : 10; + u32 : 1; + u32 qebsm : 1; /* bit 58 */ + u32 : 8; u32 aif_osa : 1; /* bit 67 */ u32 : 28; }__attribute__((packed)); diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index eb39218..e8bdfcd 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c @@ -56,7 +56,7 @@ #include "ioasm.h" #include "chsc.h" -#define VERSION_QDIO_C "$Revision: 1.108 $" +#define VERSION_QDIO_C "$Revision: 1.113 $" /****************** MODULE PARAMETER VARIABLES ********************/ MODULE_AUTHOR("Utz Bacher "); @@ -76,6 +76,7 @@ static struct qdio_perf_stats perf_stats; #endif /* QDIO_PERFORMANCE_STATS */ static int hydra_thinints; +static int is_passthrough = 0; static int omit_svs; static int indicator_used[INDICATORS_PER_CACHELINE]; @@ -136,12 +137,126 @@ qdio_release_q(struct qdio_q *q) atomic_dec(&q->use_count); } -static volatile inline void -qdio_set_slsb(volatile char *slsb, unsigned char value) +/*check ccq */ +static inline int +qdio_check_ccq(struct qdio_q *q, unsigned int ccq) { - xchg((char*)slsb,value); + char dbf_text[15]; + + if (ccq == 0 || ccq == 32 || ccq == 96) + return 0; + if (ccq == 97) + return 1; + /*notify devices immediately*/ + sprintf(dbf_text,"%d", ccq); + QDIO_DBF_TEXT2(1,trace,dbf_text); + return -EIO; } +/* EQBS: extract buffer states */ +static inline int +qdio_do_eqbs(struct qdio_q *q, unsigned char *state, + unsigned int *start, unsigned int *cnt) +{ + struct qdio_irq *irq; + unsigned int tmp_cnt, q_no, ccq; + int rc ; + char dbf_text[15]; + ccq = 0; + tmp_cnt = *cnt; + irq = (struct qdio_irq*)q->irq_ptr; + q_no = q->q_no; + if(!q->is_input_q) + q_no += irq->no_input_qs; + ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt); + rc = qdio_check_ccq(q, ccq); + if (rc < 0) { + QDIO_DBF_TEXT2(1,trace,"eqberr"); + sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt, *cnt, ccq, q_no); + QDIO_DBF_TEXT2(1,trace,dbf_text); + q->handler(q->cdev,QDIO_STATUS_ACTIVATE_CHECK_CONDITION| + QDIO_STATUS_LOOK_FOR_ERROR, + 0, 0, 0, -1, -1, q->int_parm); + return 0; + } + return (tmp_cnt - *cnt); +} + +/* SQBS: set buffer states */ +static inline int +qdio_do_sqbs(struct qdio_q *q, unsigned char state, + unsigned int *start, unsigned int *cnt) +{ + struct qdio_irq *irq; + unsigned int tmp_cnt, q_no, ccq; + int rc; + char dbf_text[15]; + + ccq = 0; + tmp_cnt = *cnt; + irq = (struct qdio_irq*)q->irq_ptr; + q_no = q->q_no; + if(!q->is_input_q) + q_no += irq->no_input_qs; + ccq = do_sqbs(irq->sch_token, state, q_no, start, cnt); + rc = qdio_check_ccq(q, ccq); + if (rc < 0) { + QDIO_DBF_TEXT3(1,trace,"sqberr"); + sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt,*cnt,ccq,q_no); + QDIO_DBF_TEXT3(1,trace,dbf_text); + q->handler(q->cdev,QDIO_STATUS_ACTIVATE_CHECK_CONDITION| + QDIO_STATUS_LOOK_FOR_ERROR, + 0, 0, 0, -1, -1, q->int_parm); + return 0; + } + return (tmp_cnt - *cnt); +} + +static inline int +qdio_set_slsb(struct qdio_q *q, unsigned int *bufno, + unsigned char state, unsigned int *count) +{ + volatile char *slsb; + struct qdio_irq *irq; + + irq = (struct qdio_irq*)q->irq_ptr; + if (!irq->is_qebsm) { + slsb = (char *)&q->slsb.acc.val[(*bufno)]; + xchg(slsb, state); + return 1; + } + return qdio_do_sqbs(q, state, bufno, count); +} + +#ifdef CONFIG_QDIO_DEBUG +static inline void +qdio_trace_slsb(struct qdio_q *q) +{ + if (q->queue_type==QDIO_TRACE_QTYPE) { + if (q->is_input_q) + QDIO_DBF_HEX2(0,slsb_in,&q->slsb, + QDIO_MAX_BUFFERS_PER_Q); + else + QDIO_DBF_HEX2(0,slsb_out,&q->slsb, + QDIO_MAX_BUFFERS_PER_Q); + } +} +#endif + +static inline int +set_slsb(struct qdio_q *q, unsigned int *bufno, + unsigned char state, unsigned int *count) +{ + int rc; +#ifdef CONFIG_QDIO_DEBUG + qdio_trace_slsb(q); +#endif + rc = qdio_set_slsb(q, bufno, state, count); +#ifdef CONFIG_QDIO_DEBUG + qdio_trace_slsb(q); +#endif + return rc; +} static inline int qdio_siga_sync(struct qdio_q *q, unsigned int gpr2, unsigned int gpr3) @@ -155,7 +270,7 @@ qdio_siga_sync(struct qdio_q *q, unsigned int gpr2, perf_stats.siga_syncs++; #endif /* QDIO_PERFORMANCE_STATS */ - cc = do_siga_sync(q->irq, gpr2, gpr3); + cc = do_siga_sync(0x10000|q->irq, gpr2, gpr3); if (cc) QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*)); @@ -170,6 +285,19 @@ qdio_siga_sync_q(struct qdio_q *q) return qdio_siga_sync(q, q->mask, 0); } +static int +__do_siga_output(struct qdio_q *q, unsigned int *busy_bit) +{ + struct qdio_irq *irq; + unsigned int fc = 0; + + irq = (struct qdio_irq *) q->irq_ptr; + if (!irq->is_qebsm) + return do_siga_output(0x10000|q->irq, q->mask, busy_bit, fc); + fc |= 0x80; + return do_siga_output(irq->sch_token, q->mask, busy_bit, fc); +} + /* * returns QDIO_SIGA_ERROR_ACCESS_EXCEPTION as cc, when SIGA returns * an access exception @@ -189,7 +317,7 @@ qdio_siga_output(struct qdio_q *q) QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); for (;;) { - cc = do_siga_output(q->irq, q->mask, &busy_bit); + cc = __do_siga_output(q, &busy_bit); //QDIO_PRINT_ERR("cc=%x, busy=%x\n",cc,busy_bit); if ((cc==2) && (busy_bit) && (q->is_iqdio_q)) { if (!start_time) @@ -221,7 +349,7 @@ qdio_siga_input(struct qdio_q *q) perf_stats.siga_ins++; #endif /* QDIO_PERFORMANCE_STATS */ - cc = do_siga_input(q->irq, q->mask); + cc = do_siga_input(0x10000|q->irq, q->mask); if (cc) QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*)); @@ -230,7 +358,7 @@ qdio_siga_input(struct qdio_q *q) } /* locked by the locks in qdio_activate and qdio_cleanup */ -static __u32 volatile * +static __u32 * qdio_get_indicator(void) { int i; @@ -258,7 +386,7 @@ qdio_put_indicator(__u32 *addr) atomic_dec(&spare_indicator_usecount); } -static inline volatile void +static inline void tiqdio_clear_summary_bit(__u32 *location) { QDIO_DBF_TEXT5(0,trace,"clrsummb"); @@ -267,7 +395,7 @@ tiqdio_clear_summary_bit(__u32 *location) xchg(location,0); } -static inline volatile void +static inline void tiqdio_set_summary_bit(__u32 *location) { QDIO_DBF_TEXT5(0,trace,"setsummb"); @@ -336,7 +464,9 @@ static inline int qdio_stop_polling(struct qdio_q *q) { #ifdef QDIO_USE_PROCESSING_STATE - int gsf; + unsigned int tmp, gsf, count = 1; + unsigned char state = 0; + struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr; if (!atomic_swap(&q->polling,0)) return 1; @@ -348,17 +478,22 @@ qdio_stop_polling(struct qdio_q *q) if (!q->is_input_q) return 1; - gsf=GET_SAVED_FRONTIER(q); - set_slsb(&q->slsb.acc.val[(gsf+QDIO_MAX_BUFFERS_PER_Q-1)& - (QDIO_MAX_BUFFERS_PER_Q-1)], - SLSB_P_INPUT_NOT_INIT); + tmp = gsf = GET_SAVED_FRONTIER(q); + tmp = ((tmp + QDIO_MAX_BUFFERS_PER_Q-1) & (QDIO_MAX_BUFFERS_PER_Q-1) ); + set_slsb(q, &tmp, SLSB_P_INPUT_NOT_INIT, &count); + /* * we don't issue this SYNC_MEMORY, as we trust Rick T and * moreover will not use the PROCESSING state under VM, so * q->polling was 0 anyway */ /*SYNC_MEMORY;*/ - if (q->slsb.acc.val[gsf]!=SLSB_P_INPUT_PRIMED) + if (irq->is_qebsm) { + count = 1; + qdio_do_eqbs(q, &state, &gsf, &count); + } else + state = q->slsb.acc.val[gsf]; + if (state != SLSB_P_INPUT_PRIMED) return 1; /* * set our summary bit again, as otherwise there is a @@ -431,18 +566,136 @@ tiqdio_clear_global_summary(void) /************************* OUTBOUND ROUTINES *******************************/ +static int +qdio_qebsm_get_outbound_buffer_frontier(struct qdio_q *q) +{ + struct qdio_irq *irq; + unsigned char state; + unsigned int cnt, count, ftc; + + irq = (struct qdio_irq *) q->irq_ptr; + if ((!q->is_iqdio_q) && (!q->hydra_gives_outbound_pcis)) + SYNC_MEMORY; + + ftc = q->first_to_check; + count = qdio_min(atomic_read(&q->number_of_buffers_used), + (QDIO_MAX_BUFFERS_PER_Q-1)); + if (count == 0) + return q->first_to_check; + cnt = qdio_do_eqbs(q, &state, &ftc, &count); + if (cnt == 0) + return q->first_to_check; + switch (state) { + case SLSB_P_OUTPUT_ERROR: + QDIO_DBF_TEXT3(0,trace,"outperr"); + atomic_sub(cnt , &q->number_of_buffers_used); + if (q->qdio_error) + q->error_status_flags |= + QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR; + q->qdio_error = SLSB_P_OUTPUT_ERROR; + q->error_status_flags |= QDIO_STATUS_LOOK_FOR_ERROR; + q->first_to_check = ftc; + break; + case SLSB_P_OUTPUT_EMPTY: + QDIO_DBF_TEXT5(0,trace,"outpempt"); + atomic_sub(cnt, &q->number_of_buffers_used); + q->first_to_check = ftc; + break; + case SLSB_CU_OUTPUT_PRIMED: + /* all buffers primed */ + QDIO_DBF_TEXT5(0,trace,"outpprim"); + break; + default: + break; + } + QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int)); + return q->first_to_check; +} + +static int +qdio_qebsm_get_inbound_buffer_frontier(struct qdio_q *q) +{ + struct qdio_irq *irq; + unsigned char state; + int tmp, ftc, count, cnt; + char dbf_text[15]; + + + irq = (struct qdio_irq *) q->irq_ptr; + ftc = q->first_to_check; + count = qdio_min(atomic_read(&q->number_of_buffers_used), + (QDIO_MAX_BUFFERS_PER_Q-1)); + if (count == 0) + return q->first_to_check; + cnt = qdio_do_eqbs(q, &state, &ftc, &count); + if (cnt == 0) + return q->first_to_check; + switch (state) { + case SLSB_P_INPUT_ERROR : +#ifdef CONFIG_QDIO_DEBUG + QDIO_DBF_TEXT3(1,trace,"inperr"); + sprintf(dbf_text,"%2x,%2x",ftc,count); + QDIO_DBF_TEXT3(1,trace,dbf_text); +#endif /* CONFIG_QDIO_DEBUG */ + if (q->qdio_error) + q->error_status_flags |= + QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR; + q->qdio_error = SLSB_P_INPUT_ERROR; + q->error_status_flags |= QDIO_STATUS_LOOK_FOR_ERROR; + atomic_sub(cnt, &q->number_of_buffers_used); + q->first_to_check = ftc; + break; + case SLSB_P_INPUT_PRIMED : + QDIO_DBF_TEXT3(0,trace,"inptprim"); + sprintf(dbf_text,"%2x,%2x",ftc,count); + QDIO_DBF_TEXT3(1,trace,dbf_text); + tmp = 0; + ftc = q->first_to_check; +#ifdef QDIO_USE_PROCESSING_STATE + if (cnt > 1) { + cnt -= 1; + tmp = set_slsb(q, &ftc, SLSB_P_INPUT_NOT_INIT, &cnt); + if (!tmp) + break; + } + cnt = 1; + tmp += set_slsb(q, &ftc, + SLSB_P_INPUT_PROCESSING, &cnt); + atomic_set(&q->polling, 1); +#else + tmp = set_slsb(q, &ftc, SLSB_P_INPUT_NOT_INIT, &cnt); +#endif + atomic_sub(tmp, &q->number_of_buffers_used); + q->first_to_check = ftc; + break; + case SLSB_CU_INPUT_EMPTY: + case SLSB_P_INPUT_NOT_INIT: + case SLSB_P_INPUT_PROCESSING: + QDIO_DBF_TEXT5(0,trace,"inpnipro"); + break; + default: + break; + } + QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int)); + return q->first_to_check; +} static inline int qdio_get_outbound_buffer_frontier(struct qdio_q *q) { - int f,f_mod_no; - volatile char *slsb; - int first_not_to_check; + struct qdio_irq *irq; + volatile char *slsb; + unsigned int count = 1; + int first_not_to_check, f, f_mod_no; char dbf_text[15]; QDIO_DBF_TEXT4(0,trace,"getobfro"); QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); + irq = (struct qdio_irq *) q->irq_ptr; + if (irq->is_qebsm) + return qdio_qebsm_get_outbound_buffer_frontier(q); + slsb=&q->slsb.acc.val[0]; f_mod_no=f=q->first_to_check; /* @@ -484,7 +737,7 @@ check_next: QDIO_DBF_HEX2(1,sbal,q->sbal[f_mod_no],256); /* kind of process the buffer */ - set_slsb(&q->slsb.acc.val[f_mod_no], SLSB_P_OUTPUT_NOT_INIT); + set_slsb(q, &f_mod_no, SLSB_P_OUTPUT_NOT_INIT, &count); /* * we increment the frontier, as this buffer @@ -597,48 +850,48 @@ qdio_kick_outbound_q(struct qdio_q *q) result=qdio_siga_output(q); - switch (result) { - case 0: - /* went smooth this time, reset timestamp */ + switch (result) { + case 0: + /* went smooth this time, reset timestamp */ #ifdef CONFIG_QDIO_DEBUG - QDIO_DBF_TEXT3(0,trace,"cc2reslv"); - sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no, - atomic_read(&q->busy_siga_counter)); - QDIO_DBF_TEXT3(0,trace,dbf_text); + QDIO_DBF_TEXT3(0,trace,"cc2reslv"); + sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no, + atomic_read(&q->busy_siga_counter)); + QDIO_DBF_TEXT3(0,trace,dbf_text); #endif /* CONFIG_QDIO_DEBUG */ - q->timing.busy_start=0; + q->timing.busy_start=0; + break; + case (2|QDIO_SIGA_ERROR_B_BIT_SET): + /* cc=2 and busy bit: */ + atomic_inc(&q->busy_siga_counter); + + /* if the last siga was successful, save + * timestamp here */ + if (!q->timing.busy_start) + q->timing.busy_start=NOW; + + /* if we're in time, don't touch error_status_flags + * and siga_error */ + if (NOW-q->timing.busy_startbusy_siga_counter); - - /* if the last siga was successful, save - * timestamp here */ - if (!q->timing.busy_start) - q->timing.busy_start=NOW; - - /* if we're in time, don't touch error_status_flags - * and siga_error */ - if (NOW-q->timing.busy_startirq,q->q_no, - atomic_read(&q->busy_siga_counter)); - QDIO_DBF_TEXT3(0,trace,dbf_text); + sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no, + atomic_read(&q->busy_siga_counter)); + QDIO_DBF_TEXT3(0,trace,dbf_text); #endif /* CONFIG_QDIO_DEBUG */ - /* else fallthrough and report error */ - default: - /* for plain cc=1, 2 or 3: */ - if (q->siga_error) - q->error_status_flags|= - QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR; + /* else fallthrough and report error */ + default: + /* for plain cc=1, 2 or 3: */ + if (q->siga_error) q->error_status_flags|= - QDIO_STATUS_LOOK_FOR_ERROR; - q->siga_error=result; - } + QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR; + q->error_status_flags|= + QDIO_STATUS_LOOK_FOR_ERROR; + q->siga_error=result; + } } static inline void @@ -743,8 +996,10 @@ qdio_outbound_processing(struct qdio_q *q) static inline int qdio_get_inbound_buffer_frontier(struct qdio_q *q) { + struct qdio_irq *irq; int f,f_mod_no; volatile char *slsb; + unsigned int count = 1; int first_not_to_check; #ifdef CONFIG_QDIO_DEBUG char dbf_text[15]; @@ -756,6 +1011,10 @@ qdio_get_inbound_buffer_frontier(struct qdio_q *q) QDIO_DBF_TEXT4(0,trace,"getibfro"); QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); + irq = (struct qdio_irq *) q->irq_ptr; + if (irq->is_qebsm) + return qdio_qebsm_get_inbound_buffer_frontier(q); + slsb=&q->slsb.acc.val[0]; f_mod_no=f=q->first_to_check; /* @@ -792,19 +1051,19 @@ check_next: * kill VM in terms of CP overhead */ if (q->siga_sync) { - set_slsb(&slsb[f_mod_no],SLSB_P_INPUT_NOT_INIT); + set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count); } else { /* set the previous buffer to NOT_INIT. The current * buffer will be set to PROCESSING at the end of * this function to avoid further interrupts. */ if (last_position>=0) - set_slsb(&slsb[last_position], - SLSB_P_INPUT_NOT_INIT); + set_slsb(q, &last_position, + SLSB_P_INPUT_NOT_INIT, &count); atomic_set(&q->polling,1); last_position=f_mod_no; } #else /* QDIO_USE_PROCESSING_STATE */ - set_slsb(&slsb[f_mod_no],SLSB_P_INPUT_NOT_INIT); + set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count); #endif /* QDIO_USE_PROCESSING_STATE */ /* * not needed, as the inbound queue will be synced on the next @@ -829,7 +1088,7 @@ check_next: QDIO_DBF_HEX2(1,sbal,q->sbal[f_mod_no],256); /* kind of process the buffer */ - set_slsb(&slsb[f_mod_no],SLSB_P_INPUT_NOT_INIT); + set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count); if (q->qdio_error) q->error_status_flags|= @@ -857,7 +1116,7 @@ out: #ifdef QDIO_USE_PROCESSING_STATE if (last_position>=0) - set_slsb(&slsb[last_position],SLSB_P_INPUT_PROCESSING); + set_slsb(q, &last_position, SLSB_P_INPUT_NOT_INIT, &count); #endif /* QDIO_USE_PROCESSING_STATE */ QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int)); @@ -902,6 +1161,10 @@ static inline int tiqdio_is_inbound_q_done(struct qdio_q *q) { int no_used; + unsigned int start_buf, count; + unsigned char state = 0; + struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr; + #ifdef CONFIG_QDIO_DEBUG char dbf_text[15]; #endif @@ -927,8 +1190,13 @@ tiqdio_is_inbound_q_done(struct qdio_q *q) if (!q->siga_sync) /* we'll check for more primed buffers in qeth_stop_polling */ return 0; - - if (q->slsb.acc.val[q->first_to_check]!=SLSB_P_INPUT_PRIMED) + if (irq->is_qebsm) { + count = 1; + start_buf = q->first_to_check; + qdio_do_eqbs(q, &state, &start_buf, &count); + } else + state = q->slsb.acc.val[q->first_to_check]; + if (state != SLSB_P_INPUT_PRIMED) /* * nothing more to do, if next buffer is not PRIMED. * note that we did a SYNC_MEMORY before, that there @@ -955,6 +1223,10 @@ static inline int qdio_is_inbound_q_done(struct qdio_q *q) { int no_used; + unsigned int start_buf, count; + unsigned char state = 0; + struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr; + #ifdef CONFIG_QDIO_DEBUG char dbf_text[15]; #endif @@ -973,8 +1245,13 @@ qdio_is_inbound_q_done(struct qdio_q *q) QDIO_DBF_TEXT4(0,trace,dbf_text); return 1; } - - if (q->slsb.acc.val[q->first_to_check]==SLSB_P_INPUT_PRIMED) { + if (irq->is_qebsm) { + count = 1; + start_buf = q->first_to_check; + qdio_do_eqbs(q, &state, &start_buf, &count); + } else + state = q->slsb.acc.val[q->first_to_check]; + if (state == SLSB_P_INPUT_PRIMED) { /* we got something to do */ QDIO_DBF_TEXT4(0,trace,"inqisntA"); QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); @@ -1523,11 +1800,11 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev, QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*)); /* fill in slsb */ - for (j=0;jslsb.acc.val[j], - SLSB_P_INPUT_NOT_INIT); -/* q->sbal[j]->element[1].sbalf.i1.key=QDIO_STORAGE_KEY;*/ - } + if (!irq_ptr->is_qebsm) { + unsigned int count = 1; + for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++) + set_slsb(q, &j, SLSB_P_INPUT_NOT_INIT, &count); + } } for (i=0;islsb.acc.val[j], - SLSB_P_OUTPUT_NOT_INIT); -/* q->sbal[j]->element[1].sbalf.i1.key=QDIO_STORAGE_KEY;*/ - } + if (!irq_ptr->is_qebsm) { + unsigned int count = 1; + for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++) + set_slsb(q, &j, SLSB_P_OUTPUT_NOT_INIT, &count); + } } } @@ -1905,7 +2182,7 @@ int qdio_synchronize(struct ccw_device *cdev, unsigned int flags, unsigned int queue_number) { - int cc; + int cc = 0; struct qdio_q *q; struct qdio_irq *irq_ptr; void *ptr; @@ -1929,12 +2206,14 @@ qdio_synchronize(struct ccw_device *cdev, unsigned int flags, q=irq_ptr->input_qs[queue_number]; if (!q) return -EINVAL; - cc = do_siga_sync(q->irq, 0, q->mask); + if (!(irq_ptr->is_qebsm)) + cc = do_siga_sync(0x10000|q->irq, 0, q->mask); } else if (flags&QDIO_FLAG_SYNC_OUTPUT) { q=irq_ptr->output_qs[queue_number]; if (!q) return -EINVAL; - cc = do_siga_sync(q->irq, q->mask, 0); + if (!(irq_ptr->is_qebsm)) + cc = do_siga_sync(0x10000|q->irq, q->mask, 0); } else return -EINVAL; @@ -1945,12 +2224,49 @@ qdio_synchronize(struct ccw_device *cdev, unsigned int flags, return cc; } -static unsigned char -qdio_check_siga_needs(int sch) +static inline void +qdio_check_subchannel_qebsm(struct qdio_irq *irq_ptr, unsigned char qdioac, + unsigned long token) +{ + struct qdio_q *q; + int i; + unsigned int count, start_buf; + char dbf_text[15]; + + /*check if QEBSM is disabled */ + if (!(irq_ptr->is_qebsm) || !(qdioac & 0x01)) { + irq_ptr->is_qebsm = 0; + irq_ptr->sch_token = 0; + irq_ptr->qib.rflags &= ~QIB_RFLAGS_ENABLE_QEBSM; + QDIO_DBF_TEXT0(0,setup,"noV=V"); + return; + } + irq_ptr->sch_token = token; + /*input queue*/ + for (i = 0; i < irq_ptr->no_input_qs;i++) { + q = irq_ptr->input_qs[i]; + count = QDIO_MAX_BUFFERS_PER_Q; + start_buf = 0; + set_slsb(q, &start_buf, SLSB_P_INPUT_NOT_INIT, &count); + } + sprintf(dbf_text,"V=V:%2x",irq_ptr->is_qebsm); + QDIO_DBF_TEXT0(0,setup,dbf_text); + sprintf(dbf_text,"%8lx",irq_ptr->sch_token); + QDIO_DBF_TEXT0(0,setup,dbf_text); + /*output queue*/ + for (i = 0; i < irq_ptr->no_output_qs; i++) { + q = irq_ptr->output_qs[i]; + count = QDIO_MAX_BUFFERS_PER_Q; + start_buf = 0; + set_slsb(q, &start_buf, SLSB_P_OUTPUT_NOT_INIT, &count); + } +} + +static void +qdio_get_ssqd_information(struct qdio_irq *irq_ptr) { int result; unsigned char qdioac; - struct { struct chsc_header request; u16 reserved1; @@ -1964,67 +2280,80 @@ qdio_check_siga_needs(int sch) u8 reserved5; u16 sch; u8 qfmt; - u8 reserved6; - u8 qdioac; + u8 parm; + u8 qdioac1; u8 sch_class; u8 reserved7; u8 icnt; u8 reserved8; u8 ocnt; + u8 reserved9; + u8 mbccnt; + u16 qdioac2; + u64 sch_token; } *ssqd_area; + QDIO_DBF_TEXT0(0,setup,"getssqd"); + qdioac = 0; ssqd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); if (!ssqd_area) { QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \ - "SIGAs for sch x%x.\n", sch); - return CHSC_FLAG_SIGA_INPUT_NECESSARY || - CHSC_FLAG_SIGA_OUTPUT_NECESSARY || - CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ + "SIGAs for sch x%x.\n", irq_ptr->irq); + irq_ptr->qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || + CHSC_FLAG_SIGA_OUTPUT_NECESSARY || + CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ + irq_ptr->is_qebsm = 0; + irq_ptr->sch_token = 0; + irq_ptr->qib.rflags &= ~QIB_RFLAGS_ENABLE_QEBSM; + return; } + ssqd_area->request = (struct chsc_header) { .length = 0x0010, .code = 0x0024, }; - - ssqd_area->first_sch = sch; - ssqd_area->last_sch = sch; - - result=chsc(ssqd_area); + ssqd_area->first_sch = irq_ptr->irq; + ssqd_area->last_sch = irq_ptr->irq; + result = chsc(ssqd_area); if (result) { QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \ "SIGAs for sch x%x.\n", - result,sch); + result, irq_ptr->irq); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || CHSC_FLAG_SIGA_OUTPUT_NECESSARY || CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ + irq_ptr->is_qebsm = 0; goto out; } if (ssqd_area->response.code != QDIO_CHSC_RESPONSE_CODE_OK) { QDIO_PRINT_WARN("response upon checking SIGA needs " \ "is 0x%x. Using all SIGAs for sch x%x.\n", - ssqd_area->response.code, sch); + ssqd_area->response.code, irq_ptr->irq); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || CHSC_FLAG_SIGA_OUTPUT_NECESSARY || CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ + irq_ptr->is_qebsm = 0; goto out; } if (!(ssqd_area->flags & CHSC_FLAG_QDIO_CAPABILITY) || !(ssqd_area->flags & CHSC_FLAG_VALIDITY) || - (ssqd_area->sch != sch)) { + (ssqd_area->sch != irq_ptr->irq)) { QDIO_PRINT_WARN("huh? problems checking out sch x%x... " \ - "using all SIGAs.\n",sch); + "using all SIGAs.\n",irq_ptr->irq); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY | CHSC_FLAG_SIGA_OUTPUT_NECESSARY | CHSC_FLAG_SIGA_SYNC_NECESSARY; /* worst case */ + irq_ptr->is_qebsm = 0; goto out; } - - qdioac = ssqd_area->qdioac; + qdioac = ssqd_area->qdioac1; out: + qdio_check_subchannel_qebsm(irq_ptr, qdioac, + ssqd_area->sch_token); free_page ((unsigned long) ssqd_area); - return qdioac; + irq_ptr->qdioac = qdioac; } static unsigned int @@ -2055,6 +2384,13 @@ tiqdio_check_chsc_availability(void) sprintf(dbf_text,"hydrati%1x", hydra_thinints); QDIO_DBF_TEXT0(0,setup,dbf_text); +#ifdef CONFIG_ARCH_S390X + /* Check for QEBSM support in general (bit 58). */ + is_passthrough = css_general_characteristics.qebsm; +#endif + sprintf(dbf_text,"cssQBS:%1x", is_passthrough); + QDIO_DBF_TEXT0(0,setup,dbf_text); + /* Check for aif time delay disablement fac (bit 56). If installed, * omit svs even under lpar (good point by rick again) */ omit_svs = css_general_characteristics.aif_tdd; @@ -2698,7 +3034,7 @@ int qdio_fill_irq(struct qdio_initialize *init_data) QDIO_DBF_TEXT2(0,setup,dbf_text); if (irq_ptr->is_thinint_irq) { - irq_ptr->dev_st_chg_ind=qdio_get_indicator(); + irq_ptr->dev_st_chg_ind = qdio_get_indicator(); QDIO_DBF_HEX1(0,setup,&irq_ptr->dev_st_chg_ind,sizeof(void*)); if (!irq_ptr->dev_st_chg_ind) { QDIO_PRINT_WARN("no indicator location available " \ @@ -2747,6 +3083,10 @@ int qdio_fill_irq(struct qdio_initialize *init_data) irq_ptr->qdr->qkey=QDIO_STORAGE_KEY; /* fill in qib */ + irq_ptr->is_qebsm = is_passthrough; + if (irq_ptr->is_qebsm) + irq_ptr->qib.rflags |= QIB_RFLAGS_ENABLE_QEBSM; + irq_ptr->qib.qfmt=init_data->q_format; if (init_data->no_input_qs) irq_ptr->qib.isliba=(unsigned long)(irq_ptr->input_qs[0]->slib); @@ -2884,7 +3224,7 @@ qdio_establish(struct qdio_initialize *init_data) return -EIO; } - irq_ptr->qdioac=qdio_check_siga_needs(irq_ptr->irq); + qdio_get_ssqd_information(irq_ptr); /* if this gets set once, we're running under VM and can omit SVSes */ if (irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_NECESSARY) omit_svs=1; @@ -3015,30 +3355,40 @@ static inline void qdio_do_qdio_fill_input(struct qdio_q *q, unsigned int qidx, unsigned int count, struct qdio_buffer *buffers) { + struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr; + qidx &= (QDIO_MAX_BUFFERS_PER_Q - 1); + if (irq->is_qebsm) { + while (count) + set_slsb(q, &qidx, SLSB_CU_INPUT_EMPTY, &count); + return; + } for (;;) { - set_slsb(&q->slsb.acc.val[qidx],SLSB_CU_INPUT_EMPTY); + set_slsb(q, &qidx, SLSB_CU_INPUT_EMPTY, &count); count--; if (!count) break; - qidx=(qidx+1)&(QDIO_MAX_BUFFERS_PER_Q-1); + qidx = (qidx + 1) & (QDIO_MAX_BUFFERS_PER_Q - 1); } - - /* not necessary, as the queues are synced during the SIGA read */ - /*SYNC_MEMORY;*/ } static inline void qdio_do_qdio_fill_output(struct qdio_q *q, unsigned int qidx, unsigned int count, struct qdio_buffer *buffers) { + struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr; + + qidx &= (QDIO_MAX_BUFFERS_PER_Q - 1); + if (irq->is_qebsm) { + while (count) + set_slsb(q, &qidx, SLSB_CU_OUTPUT_PRIMED, &count); + return; + } + for (;;) { - set_slsb(&q->slsb.acc.val[qidx],SLSB_CU_OUTPUT_PRIMED); + set_slsb(q, &qidx, SLSB_CU_OUTPUT_PRIMED, &count); count--; if (!count) break; - qidx=(qidx+1)&(QDIO_MAX_BUFFERS_PER_Q-1); + qidx = (qidx + 1) & (QDIO_MAX_BUFFERS_PER_Q - 1); } - - /* SIGA write will sync the queues */ - /*SYNC_MEMORY;*/ } static inline void @@ -3083,6 +3433,9 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags, struct qdio_buffer *buffers) { int used_elements; + unsigned int cnt, start_buf; + unsigned char state = 0; + struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr; /* This is the outbound handling of queues */ #ifdef QDIO_PERFORMANCE_STATS @@ -3115,9 +3468,15 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags, * SYNC_MEMORY :-/ ), we try to * fast-requeue buffers */ - if (q->slsb.acc.val[(qidx+QDIO_MAX_BUFFERS_PER_Q-1) - &(QDIO_MAX_BUFFERS_PER_Q-1)]!= - SLSB_CU_OUTPUT_PRIMED) { + if (irq->is_qebsm) { + cnt = 1; + start_buf = ((qidx+QDIO_MAX_BUFFERS_PER_Q-1) & + (QDIO_MAX_BUFFERS_PER_Q-1)); + qdio_do_eqbs(q, &state, &start_buf, &cnt); + } else + state = q->slsb.acc.val[(qidx+QDIO_MAX_BUFFERS_PER_Q-1) + &(QDIO_MAX_BUFFERS_PER_Q-1) ]; + if (state != SLSB_CU_OUTPUT_PRIMED) { qdio_kick_outbound_q(q); } else { QDIO_DBF_TEXT3(0,trace, "fast-req"); diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h index 328e31c..b5d303e 100644 --- a/drivers/s390/cio/qdio.h +++ b/drivers/s390/cio/qdio.h @@ -3,14 +3,13 @@ #include -#define VERSION_CIO_QDIO_H "$Revision: 1.33 $" +#define VERSION_CIO_QDIO_H "$Revision: 1.37 $" #ifdef CONFIG_QDIO_DEBUG #define QDIO_VERBOSE_LEVEL 9 #else /* CONFIG_QDIO_DEBUG */ #define QDIO_VERBOSE_LEVEL 5 #endif /* CONFIG_QDIO_DEBUG */ - #define QDIO_USE_PROCESSING_STATE #ifdef CONFIG_QDIO_PERF_STATS @@ -265,6 +264,58 @@ QDIO_PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \ /* * Some instructions as assembly */ + +static inline int +do_sqbs(unsigned long sch, unsigned char state, int queue, + unsigned int *start, unsigned int *count) +{ +#ifdef CONFIG_ARCH_S390X + register unsigned long _ccq asm ("0") = *count; + register unsigned long _sch asm ("1") = sch; + unsigned long _queuestart = ((unsigned long)queue << 32) | *start; + + asm volatile ( + " .insn rsy,0xeb000000008A,%1,0,0(%2)\n\t" + : "+d" (_ccq), "+d" (_queuestart) + : "d" ((unsigned long)state), "d" (_sch) + : "memory", "cc" + ); + *count = _ccq & 0xff; + *start = _queuestart & 0xff; + + return (_ccq >> 32) & 0xff; +#else + return 0; +#endif +} + +static inline int +do_eqbs(unsigned long sch, unsigned char *state, int queue, + unsigned int *start, unsigned int *count) +{ +#ifdef CONFIG_ARCH_S390X + register unsigned long _ccq asm ("0") = *count; + register unsigned long _sch asm ("1") = sch; + unsigned long _queuestart = ((unsigned long)queue << 32) | *start; + unsigned long _state = 0; + + asm volatile ( + " .insn rrf,0xB99c0000,%1,%2,0,0 \n\t" + : "+d" (_ccq), "+d" (_queuestart), "+d" (_state) + : "d" (_sch) + : "memory", "cc" + ); + *count = _ccq & 0xff; + *start = _queuestart & 0xff; + *state = _state & 0xff; + + return (_ccq >> 32) & 0xff; +#else + return 0; +#endif +} + + static inline int do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2) { @@ -280,7 +331,7 @@ do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2) "ipm %0 \n\t" "srl %0,28 \n\t" : "=d" (cc) - : "d" (0x10000|irq), "d" (mask1), "d" (mask2) + : "d" (irq), "d" (mask1), "d" (mask2) : "cc", "0", "1", "2", "3" ); #else /* CONFIG_ARCH_S390X */ @@ -293,7 +344,7 @@ do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2) "ipm %0 \n\t" "srl %0,28 \n\t" : "=d" (cc) - : "d" (0x10000|irq), "d" (mask1), "d" (mask2) + : "d" (irq), "d" (mask1), "d" (mask2) : "cc", "0", "1", "2", "3" ); #endif /* CONFIG_ARCH_S390X */ @@ -314,7 +365,7 @@ do_siga_input(unsigned int irq, unsigned int mask) "ipm %0 \n\t" "srl %0,28 \n\t" : "=d" (cc) - : "d" (0x10000|irq), "d" (mask) + : "d" (irq), "d" (mask) : "cc", "0", "1", "2", "memory" ); #else /* CONFIG_ARCH_S390X */ @@ -326,7 +377,7 @@ do_siga_input(unsigned int irq, unsigned int mask) "ipm %0 \n\t" "srl %0,28 \n\t" : "=d" (cc) - : "d" (0x10000|irq), "d" (mask) + : "d" (irq), "d" (mask) : "cc", "0", "1", "2", "memory" ); #endif /* CONFIG_ARCH_S390X */ @@ -335,7 +386,8 @@ do_siga_input(unsigned int irq, unsigned int mask) } static inline int -do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb) +do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb, + unsigned int fc) { int cc; __u32 busy_bit; @@ -366,14 +418,14 @@ do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb) ".long 0b,2b \n\t" ".previous \n\t" : "=d" (cc), "=d" (busy_bit) - : "d" (0x10000|irq), "d" (mask), + : "d" (irq), "d" (mask), "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION) : "cc", "0", "1", "2", "memory" ); #else /* CONFIG_ARCH_S390X */ asm volatile ( - "lghi 0,0 \n\t" - "llgfr 1,%2 \n\t" + "llgfr 0,%5 \n\t" + "lgr 1,%2 \n\t" "llgfr 2,%3 \n\t" "siga 0 \n\t" "0:" @@ -391,8 +443,8 @@ do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb) ".quad 0b,1b \n\t" ".previous \n\t" : "=d" (cc), "=d" (busy_bit) - : "d" (0x10000|irq), "d" (mask), - "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION) + : "d" (irq), "d" (mask), + "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION), "d" (fc) : "cc", "0", "1", "2", "memory" ); #endif /* CONFIG_ARCH_S390X */ @@ -494,33 +546,12 @@ struct qdio_perf_stats { #define QDIO_GET_ADDR(x) ((__u32)(long)x) #endif /* CONFIG_ARCH_S390X */ -#ifdef CONFIG_QDIO_DEBUG -#define set_slsb(x,y) \ - if(q->queue_type==QDIO_TRACE_QTYPE) { \ - if(q->is_input_q) { \ - QDIO_DBF_HEX2(0,slsb_in,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \ - } else { \ - QDIO_DBF_HEX2(0,slsb_out,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \ - } \ - } \ - qdio_set_slsb(x,y); \ - if(q->queue_type==QDIO_TRACE_QTYPE) { \ - if(q->is_input_q) { \ - QDIO_DBF_HEX2(0,slsb_in,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \ - } else { \ - QDIO_DBF_HEX2(0,slsb_out,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \ - } \ - } -#else /* CONFIG_QDIO_DEBUG */ -#define set_slsb(x,y) qdio_set_slsb(x,y) -#endif /* CONFIG_QDIO_DEBUG */ - struct qdio_q { volatile struct slsb slsb; char unused[QDIO_MAX_BUFFERS_PER_Q]; - __u32 * volatile dev_st_chg_ind; + __u32 * dev_st_chg_ind; int is_input_q; int irq; @@ -568,6 +599,7 @@ struct qdio_q { struct tasklet_struct tasklet; #endif /* QDIO_USE_TIMERS_FOR_POLLING */ + enum qdio_irq_states state; /* used to store the error condition during a data transfer */ @@ -624,6 +656,10 @@ struct qdio_irq { unsigned int hydra_gives_outbound_pcis; unsigned int sync_done_on_outb_pcis; + /* QEBSM facility */ + unsigned int is_qebsm; + unsigned long sch_token; + enum qdio_irq_states state; unsigned int no_input_qs; diff --git a/include/asm-s390/qdio.h b/include/asm-s390/qdio.h index 0ddf0a8..7bc15f0 100644 --- a/include/asm-s390/qdio.h +++ b/include/asm-s390/qdio.h @@ -195,12 +195,14 @@ struct qdr { /* * queue information block (QIB) */ -#define QIB_AC_INBOUND_PCI_SUPPORTED 0x80 -#define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40 +#define QIB_AC_INBOUND_PCI_SUPPORTED 0x80 +#define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40 +#define QIB_RFLAGS_ENABLE_QEBSM 0x80 + struct qib { unsigned int qfmt : 8; /* queue format */ unsigned int pfmt : 8; /* impl. dep. parameter format */ - unsigned int res1 : 8; /* reserved */ + unsigned int rflags : 8; /* QEBSM */ unsigned int ac : 8; /* adapter characteristics */ unsigned int res2; /* reserved */ #ifdef QDIO_32_BIT -- cgit v1.1 From a8237fc4108060402d904bea5e1062e22e731969 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Fri, 6 Jan 2006 00:19:21 -0800 Subject: [PATCH] s390: introduce struct subchannel_id This patch introduces a struct subchannel_id containing the subchannel number (formerly referred to as "irq") and switches code formerly relying on the subchannel number over to it. While we're touching inline assemblies anyway, make sure they have correct memory constraints. Signed-off-by: Cornelia Huck Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/cio/blacklist.c | 23 +++++---- drivers/s390/cio/chsc.c | 63 +++++++++++++---------- drivers/s390/cio/cio.c | 84 ++++++++++++++++-------------- drivers/s390/cio/cio.h | 11 ++-- drivers/s390/cio/cmf.c | 8 +-- drivers/s390/cio/css.c | 69 +++++++++++++------------ drivers/s390/cio/css.h | 13 ++--- drivers/s390/cio/device.c | 17 +++++-- drivers/s390/cio/device.h | 1 + drivers/s390/cio/device_fsm.c | 18 +++---- drivers/s390/cio/device_id.c | 6 +-- drivers/s390/cio/device_ops.c | 4 +- drivers/s390/cio/device_pgid.c | 13 ++--- drivers/s390/cio/device_status.c | 8 +-- drivers/s390/cio/ioasm.h | 55 +++++++++++--------- drivers/s390/cio/qdio.c | 107 ++++++++++++++++++++------------------- drivers/s390/cio/qdio.h | 26 +++++----- drivers/s390/cio/schid.h | 25 +++++++++ 18 files changed, 313 insertions(+), 238 deletions(-) create mode 100644 drivers/s390/cio/schid.h diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c index a1c52a6..a4b0303 100644 --- a/drivers/s390/cio/blacklist.c +++ b/drivers/s390/cio/blacklist.c @@ -35,7 +35,7 @@ */ /* 65536 bits to indicate if a devno is blacklisted or not */ -#define __BL_DEV_WORDS ((__MAX_SUBCHANNELS + (8*sizeof(long) - 1)) / \ +#define __BL_DEV_WORDS ((__MAX_SUBCHANNEL + (8*sizeof(long) - 1)) / \ (8*sizeof(long))) static unsigned long bl_dev[__BL_DEV_WORDS]; typedef enum {add, free} range_action; @@ -50,7 +50,7 @@ blacklist_range (range_action action, unsigned int from, unsigned int to) if (!to) to = from; - if (from > to || to > __MAX_SUBCHANNELS) { + if (from > to || to > __MAX_SUBCHANNEL) { printk (KERN_WARNING "Invalid blacklist range " "0x%04x to 0x%04x, skipping\n", from, to); return; @@ -143,7 +143,7 @@ blacklist_parse_parameters (char *str, range_action action) if (strncmp(str,"all,",4) == 0 || strcmp(str,"all") == 0 || strncmp(str,"all\n",4) == 0 || strncmp(str,"all ",4) == 0) { from = 0; - to = __MAX_SUBCHANNELS; + to = __MAX_SUBCHANNEL; str += 3; } else { int rc; @@ -226,20 +226,21 @@ is_blacklisted (int devno) static inline void s390_redo_validation (void) { - unsigned int irq; + struct subchannel_id schid; CIO_TRACE_EVENT (0, "redoval"); - for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { + init_subchannel_id(&schid); + do { int ret; struct subchannel *sch; - sch = get_subchannel_by_schid(irq); + sch = get_subchannel_by_schid(schid); if (sch) { /* Already known. */ put_device(&sch->dev); continue; } - ret = css_probe_device(irq); + ret = css_probe_device(schid); if (ret == -ENXIO) break; /* We're through. */ if (ret == -ENOMEM) @@ -248,7 +249,7 @@ s390_redo_validation (void) * panic. */ break; - } + } while (schid.sch_no++ < __MAX_SUBCHANNEL); } /* @@ -289,12 +290,12 @@ static int cio_ignore_read (char *page, char **start, off_t off, len = 0; for (devno = off; /* abuse the page variable * as counter, see fs/proc/generic.c */ - devno < __MAX_SUBCHANNELS && len + entry_size < count; devno++) { + devno < __MAX_SUBCHANNEL && len + entry_size < count; devno++) { if (!test_bit(devno, bl_dev)) continue; len += sprintf(page + len, "0.0.%04lx", devno); if (test_bit(devno + 1, bl_dev)) { /* print range */ - while (++devno < __MAX_SUBCHANNELS) + while (++devno < __MAX_SUBCHANNEL) if (!test_bit(devno, bl_dev)) break; len += sprintf(page + len, "-0.0.%04lx", --devno); @@ -302,7 +303,7 @@ static int cio_ignore_read (char *page, char **start, off_t off, len += sprintf(page + len, "\n"); } - if (devno < __MAX_SUBCHANNELS) + if (devno < __MAX_SUBCHANNEL) *eof = 1; *start = (char *) (devno - off); /* number of checked entries */ return len; diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c index fa3c23b..aff5d14 100644 --- a/drivers/s390/cio/chsc.c +++ b/drivers/s390/cio/chsc.c @@ -104,8 +104,8 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page) .code = 0x0004, }; - ssd_area->f_sch = sch->irq; - ssd_area->l_sch = sch->irq; + ssd_area->f_sch = sch->schid.sch_no; + ssd_area->l_sch = sch->schid.sch_no; ccode = chsc(ssd_area); if (ccode > 0) { @@ -147,7 +147,8 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page) */ if (ssd_area->st > 3) { /* uhm, that looks strange... */ CIO_CRW_EVENT(0, "Strange subchannel type %d" - " for sch %04x\n", ssd_area->st, sch->irq); + " for sch %04x\n", ssd_area->st, + sch->schid.sch_no); /* * There may have been a new subchannel type defined in the * time since this code was written; since we don't know which @@ -157,7 +158,7 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page) } else { const char *type[4] = {"I/O", "chsc", "message", "ADM"}; CIO_CRW_EVENT(6, "ssd: sch %04x is %s subchannel\n", - sch->irq, type[ssd_area->st]); + sch->schid.sch_no, type[ssd_area->st]); sch->ssd_info.valid = 1; sch->ssd_info.type = ssd_area->st; @@ -232,7 +233,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data) mask = 0x80 >> j; spin_lock(&sch->lock); - stsch(sch->irq, &schib); + stsch(sch->schid, &schib); if (!schib.pmcw.dnv) goto out_unreg; memcpy(&sch->schib, &schib, sizeof(struct schib)); @@ -284,7 +285,7 @@ out_unlock: out_unreg: spin_unlock(&sch->lock); sch->lpm = 0; - if (css_enqueue_subchannel_slow(sch->irq)) { + if (css_enqueue_subchannel_slow(sch->schid)) { css_clear_subchannel_slow_list(); need_rescan = 1; } @@ -337,7 +338,7 @@ s390_process_res_acc_sch(u8 chpid, __u16 fla, u32 fla_mask, * new path information and eventually check for logically * offline chpids. */ - ccode = stsch(sch->irq, &sch->schib); + ccode = stsch(sch->schid, &sch->schib); if (ccode > 0) return 0; @@ -348,7 +349,8 @@ static int s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask) { struct subchannel *sch; - int irq, rc; + int rc; + struct subchannel_id schid; char dbf_txt[15]; sprintf(dbf_txt, "accpr%x", chpid); @@ -370,10 +372,11 @@ s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask) return 0; /* no need to do the rest */ rc = 0; - for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { + init_subchannel_id(&schid); + do { int chp_mask, old_lpm; - sch = get_subchannel_by_schid(irq); + sch = get_subchannel_by_schid(schid); if (!sch) { struct schib schib; int ret; @@ -385,7 +388,7 @@ s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask) * that beast may be on we'll have to do a stsch * on all devices, grr... */ - if (stsch(irq, &schib)) { + if (stsch(schid, &schib)) { /* We're through */ if (need_rescan) rc = -EAGAIN; @@ -396,7 +399,7 @@ s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask) continue; } /* Put it on the slow path. */ - ret = css_enqueue_subchannel_slow(irq); + ret = css_enqueue_subchannel_slow(schid); if (ret) { css_clear_subchannel_slow_list(); need_rescan = 1; @@ -428,7 +431,7 @@ s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask) put_device(&sch->dev); if (fla_mask == 0xffff) break; - } + } while (schid.sch_no++ < __MAX_SUBCHANNEL); return rc; } @@ -608,7 +611,8 @@ static int chp_add(int chpid) { struct subchannel *sch; - int irq, ret, rc; + int ret, rc; + struct subchannel_id schid; char dbf_txt[15]; if (!get_chp_status(chpid)) @@ -618,14 +622,15 @@ chp_add(int chpid) CIO_TRACE_EVENT(2, dbf_txt); rc = 0; - for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { + init_subchannel_id(&schid); + do { int i; - sch = get_subchannel_by_schid(irq); + sch = get_subchannel_by_schid(schid); if (!sch) { struct schib schib; - if (stsch(irq, &schib)) { + if (stsch(schid, &schib)) { /* We're through */ if (need_rescan) rc = -EAGAIN; @@ -636,7 +641,7 @@ chp_add(int chpid) continue; } /* Put it on the slow path. */ - ret = css_enqueue_subchannel_slow(irq); + ret = css_enqueue_subchannel_slow(schid); if (ret) { css_clear_subchannel_slow_list(); need_rescan = 1; @@ -648,7 +653,7 @@ chp_add(int chpid) spin_lock(&sch->lock); for (i=0; i<8; i++) if (sch->schib.pmcw.chpid[i] == chpid) { - if (stsch(sch->irq, &sch->schib) != 0) { + if (stsch(sch->schid, &sch->schib) != 0) { /* Endgame. */ spin_unlock(&sch->lock); return rc; @@ -669,7 +674,7 @@ chp_add(int chpid) spin_unlock(&sch->lock); put_device(&sch->dev); - } + } while (schid.sch_no++ < __MAX_SUBCHANNEL); return rc; } @@ -702,7 +707,7 @@ __check_for_io_and_kill(struct subchannel *sch, int index) if (!device_is_online(sch)) /* cio could be doing I/O. */ return 0; - cc = stsch(sch->irq, &sch->schib); + cc = stsch(sch->schid, &sch->schib); if (cc) return 0; if (sch->schib.scsw.actl && sch->schib.pmcw.lpum == (0x80 >> index)) { @@ -743,7 +748,7 @@ __s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on) * just varied off path. Then kill it. */ if (!__check_for_io_and_kill(sch, chp) && !sch->lpm) { - if (css_enqueue_subchannel_slow(sch->irq)) { + if (css_enqueue_subchannel_slow(sch->schid)) { css_clear_subchannel_slow_list(); need_rescan = 1; } @@ -789,7 +794,8 @@ static int s390_vary_chpid( __u8 chpid, int on) { char dbf_text[15]; - int status, irq, ret; + int status, ret; + struct subchannel_id schid; struct subchannel *sch; sprintf(dbf_text, on?"varyon%x":"varyoff%x", chpid); @@ -818,26 +824,27 @@ s390_vary_chpid( __u8 chpid, int on) if (!on) goto out; /* Scan for new devices on varied on path. */ - for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { + init_subchannel_id(&schid); + do { struct schib schib; if (need_rescan) break; - sch = get_subchannel_by_schid(irq); + sch = get_subchannel_by_schid(schid); if (sch) { put_device(&sch->dev); continue; } - if (stsch(irq, &schib)) + if (stsch(schid, &schib)) /* We're through */ break; /* Put it on the slow path. */ - ret = css_enqueue_subchannel_slow(irq); + ret = css_enqueue_subchannel_slow(schid); if (ret) { css_clear_subchannel_slow_list(); need_rescan = 1; } - } + } while (schid.sch_no++ < __MAX_SUBCHANNEL); out: if (need_rescan || css_slow_subchannels_exist()) queue_work(slow_path_wq, &slow_path_work); diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 185bc73..396bada 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c @@ -135,7 +135,7 @@ cio_tpi(void) return 0; irb = (struct irb *) __LC_IRB; /* Store interrupt response block to lowcore. */ - if (tsch (tpi_info->irq, irb) != 0) + if (tsch (tpi_info->schid, irb) != 0) /* Not status pending or not operational. */ return 1; sch = (struct subchannel *)(unsigned long)tpi_info->intparm; @@ -163,10 +163,10 @@ cio_start_handle_notoper(struct subchannel *sch, __u8 lpm) else sch->lpm = 0; - stsch (sch->irq, &sch->schib); + stsch (sch->schid, &sch->schib); CIO_MSG_EVENT(0, "cio_start: 'not oper' status for " - "subchannel %04x!\n", sch->irq); + "subchannel %04x!\n", sch->schid.sch_no); sprintf(dbf_text, "no%s", sch->dev.bus_id); CIO_TRACE_EVENT(0, dbf_text); CIO_HEX_EVENT(0, &sch->schib, sizeof (struct schib)); @@ -204,7 +204,7 @@ cio_start_key (struct subchannel *sch, /* subchannel structure */ sch->orb.key = key >> 4; /* issue "Start Subchannel" */ sch->orb.cpa = (__u32) __pa (cpa); - ccode = ssch (sch->irq, &sch->orb); + ccode = ssch (sch->schid, &sch->orb); /* process condition code */ sprintf (dbf_txt, "ccode:%d", ccode); @@ -243,7 +243,7 @@ cio_resume (struct subchannel *sch) CIO_TRACE_EVENT (4, "resIO"); CIO_TRACE_EVENT (4, sch->dev.bus_id); - ccode = rsch (sch->irq); + ccode = rsch (sch->schid); sprintf (dbf_txt, "ccode:%d", ccode); CIO_TRACE_EVENT (4, dbf_txt); @@ -283,7 +283,7 @@ cio_halt(struct subchannel *sch) /* * Issue "Halt subchannel" and process condition code */ - ccode = hsch (sch->irq); + ccode = hsch (sch->schid); sprintf (dbf_txt, "ccode:%d", ccode); CIO_TRACE_EVENT (2, dbf_txt); @@ -318,7 +318,7 @@ cio_clear(struct subchannel *sch) /* * Issue "Clear subchannel" and process condition code */ - ccode = csch (sch->irq); + ccode = csch (sch->schid); sprintf (dbf_txt, "ccode:%d", ccode); CIO_TRACE_EVENT (2, dbf_txt); @@ -351,7 +351,7 @@ cio_cancel (struct subchannel *sch) CIO_TRACE_EVENT (2, "cancelIO"); CIO_TRACE_EVENT (2, sch->dev.bus_id); - ccode = xsch (sch->irq); + ccode = xsch (sch->schid); sprintf (dbf_txt, "ccode:%d", ccode); CIO_TRACE_EVENT (2, dbf_txt); @@ -359,7 +359,7 @@ cio_cancel (struct subchannel *sch) switch (ccode) { case 0: /* success */ /* Update information in scsw. */ - stsch (sch->irq, &sch->schib); + stsch (sch->schid, &sch->schib); return 0; case 1: /* status pending */ return -EBUSY; @@ -381,7 +381,7 @@ cio_modify (struct subchannel *sch) ret = 0; for (retry = 0; retry < 5; retry++) { - ccode = msch_err (sch->irq, &sch->schib); + ccode = msch_err (sch->schid, &sch->schib); if (ccode < 0) /* -EIO if msch gets a program check. */ return ccode; switch (ccode) { @@ -414,7 +414,7 @@ cio_enable_subchannel (struct subchannel *sch, unsigned int isc) CIO_TRACE_EVENT (2, "ensch"); CIO_TRACE_EVENT (2, sch->dev.bus_id); - ccode = stsch (sch->irq, &sch->schib); + ccode = stsch (sch->schid, &sch->schib); if (ccode) return -ENODEV; @@ -432,13 +432,13 @@ cio_enable_subchannel (struct subchannel *sch, unsigned int isc) */ sch->schib.pmcw.csense = 0; if (ret == 0) { - stsch (sch->irq, &sch->schib); + stsch (sch->schid, &sch->schib); if (sch->schib.pmcw.ena) break; } if (ret == -EBUSY) { struct irb irb; - if (tsch(sch->irq, &irb) != 0) + if (tsch(sch->schid, &irb) != 0) break; } } @@ -461,7 +461,7 @@ cio_disable_subchannel (struct subchannel *sch) CIO_TRACE_EVENT (2, "dissch"); CIO_TRACE_EVENT (2, sch->dev.bus_id); - ccode = stsch (sch->irq, &sch->schib); + ccode = stsch (sch->schid, &sch->schib); if (ccode == 3) /* Not operational. */ return -ENODEV; @@ -485,7 +485,7 @@ cio_disable_subchannel (struct subchannel *sch) */ break; if (ret == 0) { - stsch (sch->irq, &sch->schib); + stsch (sch->schid, &sch->schib); if (!sch->schib.pmcw.ena) break; } @@ -508,12 +508,12 @@ cio_disable_subchannel (struct subchannel *sch) * -ENODEV for subchannels with invalid device number or blacklisted devices */ int -cio_validate_subchannel (struct subchannel *sch, unsigned int irq) +cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid) { char dbf_txt[15]; int ccode; - sprintf (dbf_txt, "valsch%x", irq); + sprintf (dbf_txt, "valsch%x", schid.sch_no); CIO_TRACE_EVENT (4, dbf_txt); /* Nuke all fields. */ @@ -522,17 +522,17 @@ cio_validate_subchannel (struct subchannel *sch, unsigned int irq) spin_lock_init(&sch->lock); /* Set a name for the subchannel */ - snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", irq); + snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", schid.sch_no); /* * The first subchannel that is not-operational (ccode==3) * indicates that there aren't any more devices available. */ - sch->irq = irq; - ccode = stsch (irq, &sch->schib); + ccode = stsch (schid, &sch->schib); if (ccode) return -ENXIO; + sch->schid = schid; /* Copy subchannel type from path management control word. */ sch->st = sch->schib.pmcw.st; @@ -543,7 +543,7 @@ cio_validate_subchannel (struct subchannel *sch, unsigned int irq) CIO_DEBUG(KERN_INFO, 0, "Subchannel %04X reports " "non-I/O subchannel type %04X\n", - sch->irq, sch->st); + sch->schid.sch_no, sch->st); /* We stop here for non-io subchannels. */ return sch->st; } @@ -573,7 +573,7 @@ cio_validate_subchannel (struct subchannel *sch, unsigned int irq) CIO_DEBUG(KERN_INFO, 0, "Detected device %04X on subchannel %04X" " - PIM = %02X, PAM = %02X, POM = %02X\n", - sch->schib.pmcw.dev, sch->irq, sch->schib.pmcw.pim, + sch->schib.pmcw.dev, sch->schid.sch_no, sch->schib.pmcw.pim, sch->schib.pmcw.pam, sch->schib.pmcw.pom); /* @@ -632,7 +632,7 @@ do_IRQ (struct pt_regs *regs) if (sch) spin_lock(&sch->lock); /* Store interrupt response block to lowcore. */ - if (tsch (tpi_info->irq, irb) == 0 && sch) { + if (tsch (tpi_info->schid, irb) == 0 && sch) { /* Keep subchannel information word up to date. */ memcpy (&sch->schib.scsw, &irb->scsw, sizeof (irb->scsw)); @@ -693,26 +693,28 @@ wait_cons_dev (void) static int cio_console_irq(void) { - int irq; + struct subchannel_id schid; + init_subchannel_id(&schid); if (console_irq != -1) { /* VM provided us with the irq number of the console. */ - if (stsch(console_irq, &console_subchannel.schib) != 0 || + schid.sch_no = console_irq; + if (stsch(schid, &console_subchannel.schib) != 0 || !console_subchannel.schib.pmcw.dnv) return -1; console_devno = console_subchannel.schib.pmcw.dev; } else if (console_devno != -1) { /* At least the console device number is known. */ - for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { - if (stsch(irq, &console_subchannel.schib) != 0) + do { + if (stsch(schid, &console_subchannel.schib) != 0) break; if (console_subchannel.schib.pmcw.dnv && console_subchannel.schib.pmcw.dev == console_devno) { - console_irq = irq; + console_irq = schid.sch_no; break; } - } + } while (schid.sch_no++ < __MAX_SUBCHANNEL); if (console_irq == -1) return -1; } else { @@ -729,6 +731,7 @@ struct subchannel * cio_probe_console(void) { int irq, ret; + struct subchannel_id schid; if (xchg(&console_subchannel_in_use, 1) != 0) return ERR_PTR(-EBUSY); @@ -738,7 +741,9 @@ cio_probe_console(void) return ERR_PTR(-ENODEV); } memset(&console_subchannel, 0, sizeof(struct subchannel)); - ret = cio_validate_subchannel(&console_subchannel, irq); + init_subchannel_id(&schid); + schid.sch_no = irq; + ret = cio_validate_subchannel(&console_subchannel, schid); if (ret) { console_subchannel_in_use = 0; return ERR_PTR(-ENODEV); @@ -770,11 +775,11 @@ cio_release_console(void) /* Bah... hack to catch console special sausages. */ int -cio_is_console(int irq) +cio_is_console(struct subchannel_id schid) { if (!console_subchannel_in_use) return 0; - return (irq == console_subchannel.irq); + return schid_equal(&schid, &console_subchannel.schid); } struct subchannel * @@ -787,7 +792,7 @@ cio_get_console_subchannel(void) #endif static inline int -__disable_subchannel_easy(unsigned int schid, struct schib *schib) +__disable_subchannel_easy(struct subchannel_id schid, struct schib *schib) { int retry, cc; @@ -805,7 +810,7 @@ __disable_subchannel_easy(unsigned int schid, struct schib *schib) } static inline int -__clear_subchannel_easy(unsigned int schid) +__clear_subchannel_easy(struct subchannel_id schid) { int retry; @@ -815,8 +820,8 @@ __clear_subchannel_easy(unsigned int schid) struct tpi_info ti; if (tpi(&ti)) { - tsch(ti.irq, (struct irb *)__LC_IRB); - if (ti.irq == schid) + tsch(ti.schid, (struct irb *)__LC_IRB); + if (schid_equal(&ti.schid, &schid)) return 0; } udelay(100); @@ -830,10 +835,11 @@ extern void do_reipl(unsigned long devno); void clear_all_subchannels(void) { - unsigned int schid; + struct subchannel_id schid; local_irq_disable(); - for (schid=0;schid<=highest_subchannel;schid++) { + init_subchannel_id(&schid); + do { struct schib schib; if (stsch(schid, &schib)) break; /* break out of the loop */ @@ -849,7 +855,7 @@ clear_all_subchannels(void) stsch(schid, &schib); __disable_subchannel_easy(schid, &schib); } - } + } while (schid.sch_no++ < __MAX_SUBCHANNEL); } /* Make sure all subchannels are quiet before we re-ipl an lpar. */ diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h index c50a9da..0ca9873 100644 --- a/drivers/s390/cio/cio.h +++ b/drivers/s390/cio/cio.h @@ -1,6 +1,8 @@ #ifndef S390_CIO_H #define S390_CIO_H +#include "schid.h" + /* * where we put the ssd info */ @@ -83,7 +85,7 @@ struct orb { /* subchannel data structure used by I/O subroutines */ struct subchannel { - unsigned int irq; /* aka. subchannel number */ + struct subchannel_id schid; spinlock_t lock; /* subchannel lock */ enum { @@ -114,7 +116,7 @@ struct subchannel { #define to_subchannel(n) container_of(n, struct subchannel, dev) -extern int cio_validate_subchannel (struct subchannel *, unsigned int); +extern int cio_validate_subchannel (struct subchannel *, struct subchannel_id); extern int cio_enable_subchannel (struct subchannel *, unsigned int); extern int cio_disable_subchannel (struct subchannel *); extern int cio_cancel (struct subchannel *); @@ -127,14 +129,15 @@ extern int cio_cancel (struct subchannel *); extern int cio_set_options (struct subchannel *, int); extern int cio_get_options (struct subchannel *); extern int cio_modify (struct subchannel *); + /* Use with care. */ #ifdef CONFIG_CCW_CONSOLE extern struct subchannel *cio_probe_console(void); extern void cio_release_console(void); -extern int cio_is_console(int irq); +extern int cio_is_console(struct subchannel_id); extern struct subchannel *cio_get_console_subchannel(void); #else -#define cio_is_console(irq) 0 +#define cio_is_console(schid) 0 #define cio_get_console_subchannel() NULL #endif diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c index b978f7f..0b03714 100644 --- a/drivers/s390/cio/cmf.c +++ b/drivers/s390/cio/cmf.c @@ -1,5 +1,5 @@ /* - * linux/drivers/s390/cio/cmf.c ($Revision: 1.16 $) + * linux/drivers/s390/cio/cmf.c ($Revision: 1.19 $) * * Linux on zSeries Channel Measurement Facility support * @@ -178,7 +178,7 @@ set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address) /* msch can silently fail, so do it again if necessary */ for (retry = 0; retry < 3; retry++) { /* prepare schib */ - stsch(sch->irq, schib); + stsch(sch->schid, schib); schib->pmcw.mme = mme; schib->pmcw.mbfc = mbfc; /* address can be either a block address or a block index */ @@ -188,7 +188,7 @@ set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address) schib->pmcw.mbi = address; /* try to submit it */ - switch(ret = msch_err(sch->irq, schib)) { + switch(ret = msch_err(sch->schid, schib)) { case 0: break; case 1: @@ -202,7 +202,7 @@ set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address) ret = -EINVAL; break; } - stsch(sch->irq, schib); /* restore the schib */ + stsch(sch->schid, schib); /* restore the schib */ if (ret) break; diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 7e4d57b..5137daf 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -33,7 +33,7 @@ struct device css_bus_device = { }; static struct subchannel * -css_alloc_subchannel(int irq) +css_alloc_subchannel(struct subchannel_id schid) { struct subchannel *sch; int ret; @@ -41,13 +41,11 @@ css_alloc_subchannel(int irq) sch = kmalloc (sizeof (*sch), GFP_KERNEL | GFP_DMA); if (sch == NULL) return ERR_PTR(-ENOMEM); - ret = cio_validate_subchannel (sch, irq); + ret = cio_validate_subchannel (sch, schid); if (ret < 0) { kfree(sch); return ERR_PTR(ret); } - if (irq > highest_subchannel) - highest_subchannel = irq; if (sch->st != SUBCHANNEL_TYPE_IO) { /* For now we ignore all non-io subchannels. */ @@ -87,7 +85,7 @@ css_subchannel_release(struct device *dev) struct subchannel *sch; sch = to_subchannel(dev); - if (!cio_is_console(sch->irq)) + if (!cio_is_console(sch->schid)) kfree(sch); } @@ -114,12 +112,12 @@ css_register_subchannel(struct subchannel *sch) } int -css_probe_device(int irq) +css_probe_device(struct subchannel_id schid) { int ret; struct subchannel *sch; - sch = css_alloc_subchannel(irq); + sch = css_alloc_subchannel(schid); if (IS_ERR(sch)) return PTR_ERR(sch); ret = css_register_subchannel(sch); @@ -132,26 +130,26 @@ static int check_subchannel(struct device * dev, void * data) { struct subchannel *sch; - int irq = (unsigned long)data; + struct subchannel_id *schid = data; sch = to_subchannel(dev); - return (sch->irq == irq); + return schid_equal(&sch->schid, schid); } struct subchannel * -get_subchannel_by_schid(int irq) +get_subchannel_by_schid(struct subchannel_id schid) { struct device *dev; dev = bus_find_device(&css_bus_type, NULL, - (void *)(unsigned long)irq, check_subchannel); + (void *)&schid, check_subchannel); return dev ? to_subchannel(dev) : NULL; } static inline int -css_get_subchannel_status(struct subchannel *sch, int schid) +css_get_subchannel_status(struct subchannel *sch, struct subchannel_id schid) { struct schib schib; int cc; @@ -170,13 +168,13 @@ css_get_subchannel_status(struct subchannel *sch, int schid) } static int -css_evaluate_subchannel(int irq, int slow) +css_evaluate_subchannel(struct subchannel_id schid, int slow) { int event, ret, disc; struct subchannel *sch; unsigned long flags; - sch = get_subchannel_by_schid(irq); + sch = get_subchannel_by_schid(schid); disc = sch ? device_is_disconnected(sch) : 0; if (disc && slow) { if (sch) @@ -194,9 +192,10 @@ css_evaluate_subchannel(int irq, int slow) put_device(&sch->dev); return -EAGAIN; /* Will be done on the slow path. */ } - event = css_get_subchannel_status(sch, irq); + event = css_get_subchannel_status(sch, schid); CIO_MSG_EVENT(4, "Evaluating schid %04x, event %d, %s, %s path.\n", - irq, event, sch?(disc?"disconnected":"normal"):"unknown", + schid.sch_no, event, + sch?(disc?"disconnected":"normal"):"unknown", slow?"slow":"fast"); switch (event) { case CIO_NO_PATH: @@ -253,7 +252,7 @@ css_evaluate_subchannel(int irq, int slow) sch->schib.pmcw.intparm = 0; cio_modify(sch); put_device(&sch->dev); - ret = css_probe_device(irq); + ret = css_probe_device(schid); } else { /* * We can't immediately deregister the disconnected @@ -272,7 +271,7 @@ css_evaluate_subchannel(int irq, int slow) device_trigger_reprobe(sch); spin_unlock_irqrestore(&sch->lock, flags); } - ret = sch ? 0 : css_probe_device(irq); + ret = sch ? 0 : css_probe_device(schid); break; default: BUG(); @@ -284,10 +283,12 @@ css_evaluate_subchannel(int irq, int slow) static void css_rescan_devices(void) { - int irq, ret; + int ret; + struct subchannel_id schid; - for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { - ret = css_evaluate_subchannel(irq, 1); + init_subchannel_id(&schid); + do { + ret = css_evaluate_subchannel(schid, 1); /* No more memory. It doesn't make sense to continue. No * panic because this can happen in midflight and just * because we can't use a new device is no reason to crash @@ -297,12 +298,12 @@ css_rescan_devices(void) /* -ENXIO indicates that there are no more subchannels. */ if (ret == -ENXIO) break; - } + } while (schid.sch_no++ < __MAX_SUBCHANNEL); } struct slow_subchannel { struct list_head slow_list; - unsigned long schid; + struct subchannel_id schid; }; static LIST_HEAD(slow_subchannels_head); @@ -357,20 +358,24 @@ int css_process_crw(int irq) { int ret; + struct subchannel_id mchk_schid; CIO_CRW_EVENT(2, "source is subchannel %04X\n", irq); if (need_rescan) /* We need to iterate all subchannels anyway. */ return -EAGAIN; + + init_subchannel_id(&mchk_schid); + mchk_schid.sch_no = irq; /* * Since we are always presented with IPI in the CRW, we have to * use stsch() to find out if the subchannel in question has come * or gone. */ - ret = css_evaluate_subchannel(irq, 0); + ret = css_evaluate_subchannel(mchk_schid, 0); if (ret == -EAGAIN) { - if (css_enqueue_subchannel_slow(irq)) { + if (css_enqueue_subchannel_slow(mchk_schid)) { css_clear_subchannel_slow_list(); need_rescan = 1; } @@ -404,7 +409,8 @@ css_generate_pgid(void) static int __init init_channel_subsystem (void) { - int ret, irq; + int ret; + struct subchannel_id schid; if (chsc_determine_css_characteristics() == 0) css_characteristics_avail = 1; @@ -420,13 +426,14 @@ init_channel_subsystem (void) ctl_set_bit(6, 28); - for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { + init_subchannel_id(&schid); + do { struct subchannel *sch; - if (cio_is_console(irq)) + if (cio_is_console(schid)) sch = cio_get_console_subchannel(); else { - sch = css_alloc_subchannel(irq); + sch = css_alloc_subchannel(schid); if (IS_ERR(sch)) ret = PTR_ERR(sch); else @@ -448,7 +455,7 @@ init_channel_subsystem (void) * console subchannel. */ css_register_subchannel(sch); - } + } while (schid.sch_no++ < __MAX_SUBCHANNEL); return 0; out_bus: @@ -482,7 +489,7 @@ struct bus_type css_bus_type = { subsys_initcall(init_channel_subsystem); int -css_enqueue_subchannel_slow(unsigned long schid) +css_enqueue_subchannel_slow(struct subchannel_id schid) { struct slow_subchannel *new_slow_sch; unsigned long flags; diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h index 2004a6c..f26e16d 100644 --- a/drivers/s390/cio/css.h +++ b/drivers/s390/cio/css.h @@ -6,6 +6,8 @@ #include +#include "schid.h" + /* * path grouping stuff */ @@ -68,7 +70,7 @@ struct ccw_device_private { atomic_t onoff; unsigned long registered; __u16 devno; /* device number */ - __u16 irq; /* subchannel number */ + __u16 sch_no; /* subchannel number */ __u8 imask; /* lpm mask for SNID/SID/SPGID */ int iretry; /* retry counter SNID/SID/SPGID */ struct { @@ -121,12 +123,11 @@ struct css_driver { extern struct bus_type css_bus_type; extern struct css_driver io_subchannel_driver; -int css_probe_device(int irq); -extern struct subchannel * get_subchannel_by_schid(int irq); -extern unsigned int highest_subchannel; +extern int css_probe_device(struct subchannel_id); +extern struct subchannel * get_subchannel_by_schid(struct subchannel_id); extern int css_init_done; -#define __MAX_SUBCHANNELS 65536 +#define __MAX_SUBCHANNEL 65535 extern struct bus_type css_bus_type; extern struct device css_bus_device; @@ -144,7 +145,7 @@ void device_set_waiting(struct subchannel *); void device_kill_pending_timer(struct subchannel *); /* Helper functions to build lists for the slow path. */ -int css_enqueue_subchannel_slow(unsigned long schid); +extern int css_enqueue_subchannel_slow(struct subchannel_id schid); void css_walk_subchannel_slow_list(void (*fn)(unsigned long)); void css_clear_subchannel_slow_list(void); int css_slow_subchannels_exist(void); diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index 0590cff..9ac07ae 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -622,7 +622,7 @@ ccw_device_do_unreg_rereg(void *data) other_sch = to_subchannel(other_cdev->dev.parent); if (get_device(&other_sch->dev)) { - stsch(other_sch->irq, &other_sch->schib); + stsch(other_sch->schid, &other_sch->schib); if (other_sch->schib.pmcw.dnv) { other_sch->schib.pmcw.intparm = 0; cio_modify(other_sch); @@ -772,7 +772,7 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch) /* Init private data. */ priv = cdev->private; priv->devno = sch->schib.pmcw.dev; - priv->irq = sch->irq; + priv->sch_no = sch->schid.sch_no; priv->state = DEV_STATE_NOT_OPER; INIT_LIST_HEAD(&priv->cmb_list); init_waitqueue_head(&priv->wait_q); @@ -951,7 +951,7 @@ io_subchannel_shutdown(struct device *dev) sch = to_subchannel(dev); cdev = dev->driver_data; - if (cio_is_console(sch->irq)) + if (cio_is_console(sch->schid)) return; if (!sch->schib.pmcw.ena) /* Nothing to do. */ @@ -1146,6 +1146,16 @@ ccw_driver_unregister (struct ccw_driver *cdriver) driver_unregister(&cdriver->driver); } +/* Helper func for qdio. */ +struct subchannel_id +ccw_device_get_subchannel_id(struct ccw_device *cdev) +{ + struct subchannel *sch; + + sch = to_subchannel(cdev->dev.parent); + return sch->schid; +} + MODULE_LICENSE("GPL"); EXPORT_SYMBOL(ccw_device_set_online); EXPORT_SYMBOL(ccw_device_set_offline); @@ -1155,3 +1165,4 @@ EXPORT_SYMBOL(get_ccwdev_by_busid); EXPORT_SYMBOL(ccw_bus_type); EXPORT_SYMBOL(ccw_device_work); EXPORT_SYMBOL(ccw_device_notify_work); +EXPORT_SYMBOL_GPL(ccw_device_get_subchannel_id); diff --git a/drivers/s390/cio/device.h b/drivers/s390/cio/device.h index a3aa056..11587eb 100644 --- a/drivers/s390/cio/device.h +++ b/drivers/s390/cio/device.h @@ -110,6 +110,7 @@ int ccw_device_stlck(struct ccw_device *); /* qdio needs this. */ void ccw_device_set_timeout(struct ccw_device *, int); +extern struct subchannel_id ccw_device_get_subchannel_id(struct ccw_device *); void retry_set_schib(struct ccw_device *cdev); #endif diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c index c1c89f4..9efeae7 100644 --- a/drivers/s390/cio/device_fsm.c +++ b/drivers/s390/cio/device_fsm.c @@ -133,7 +133,7 @@ ccw_device_cancel_halt_clear(struct ccw_device *cdev) int ret; sch = to_subchannel(cdev->dev.parent); - ret = stsch(sch->irq, &sch->schib); + ret = stsch(sch->schid, &sch->schib); if (ret || !sch->schib.pmcw.dnv) return -ENODEV; if (!sch->schib.pmcw.ena || sch->schib.scsw.actl == 0) @@ -231,7 +231,7 @@ ccw_device_recog_done(struct ccw_device *cdev, int state) * through ssch() and the path information is up to date. */ old_lpm = sch->lpm; - stsch(sch->irq, &sch->schib); + stsch(sch->schid, &sch->schib); sch->lpm = sch->schib.pmcw.pim & sch->schib.pmcw.pam & sch->schib.pmcw.pom & @@ -258,7 +258,7 @@ ccw_device_recog_done(struct ccw_device *cdev, int state) case DEV_STATE_NOT_OPER: CIO_DEBUG(KERN_WARNING, 2, "SenseID : unknown device %04x on subchannel %04x\n", - cdev->private->devno, sch->irq); + cdev->private->devno, sch->schid.sch_no); break; case DEV_STATE_OFFLINE: if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) { @@ -291,7 +291,7 @@ ccw_device_recog_done(struct ccw_device *cdev, int state) case DEV_STATE_BOXED: CIO_DEBUG(KERN_WARNING, 2, "SenseID : boxed device %04x on subchannel %04x\n", - cdev->private->devno, sch->irq); + cdev->private->devno, sch->schid.sch_no); break; } cdev->private->state = state; @@ -359,7 +359,7 @@ ccw_device_done(struct ccw_device *cdev, int state) if (state == DEV_STATE_BOXED) CIO_DEBUG(KERN_WARNING, 2, "Boxed device %04x on subchannel %04x\n", - cdev->private->devno, sch->irq); + cdev->private->devno, sch->schid.sch_no); if (cdev->private->flags.donotify) { cdev->private->flags.donotify = 0; @@ -592,7 +592,7 @@ ccw_device_offline(struct ccw_device *cdev) struct subchannel *sch; sch = to_subchannel(cdev->dev.parent); - if (stsch(sch->irq, &sch->schib) || !sch->schib.pmcw.dnv) + if (stsch(sch->schid, &sch->schib) || !sch->schib.pmcw.dnv) return -ENODEV; if (cdev->private->state != DEV_STATE_ONLINE) { if (sch->schib.scsw.actl != 0) @@ -711,7 +711,7 @@ ccw_device_online_verify(struct ccw_device *cdev, enum dev_event dev_event) * Since we might not just be coming from an interrupt from the * subchannel we have to update the schib. */ - stsch(sch->irq, &sch->schib); + stsch(sch->schid, &sch->schib); if (sch->schib.scsw.actl != 0 || (cdev->private->irb.scsw.stctl & SCSW_STCTL_STATUS_PEND)) { @@ -923,7 +923,7 @@ ccw_device_wait4io_irq(struct ccw_device *cdev, enum dev_event dev_event) /* Iff device is idle, reset timeout. */ sch = to_subchannel(cdev->dev.parent); - if (!stsch(sch->irq, &sch->schib)) + if (!stsch(sch->schid, &sch->schib)) if (sch->schib.scsw.actl == 0) ccw_device_set_timeout(cdev, 0); /* Call the handler. */ @@ -1035,7 +1035,7 @@ device_trigger_reprobe(struct subchannel *sch) return; /* Update some values. */ - if (stsch(sch->irq, &sch->schib)) + if (stsch(sch->schid, &sch->schib)) return; /* diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c index 0e68fb5..207881e 100644 --- a/drivers/s390/cio/device_id.c +++ b/drivers/s390/cio/device_id.c @@ -258,7 +258,7 @@ ccw_device_check_sense_id(struct ccw_device *cdev) */ CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel %04x " "reports cmd reject\n", - cdev->private->devno, sch->irq); + cdev->private->devno, sch->schid.sch_no); return -EOPNOTSUPP; } if (irb->esw.esw0.erw.cons) { @@ -280,13 +280,13 @@ ccw_device_check_sense_id(struct ccw_device *cdev) CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x on" " subchannel %04x is 'not operational'\n", sch->orb.lpm, cdev->private->devno, - sch->irq); + sch->schid.sch_no); return -EACCES; } /* Hmm, whatever happened, try again. */ CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on " "subchannel %04x returns status %02X%02X\n", - cdev->private->devno, sch->irq, + cdev->private->devno, sch->schid.sch_no, irb->scsw.dstat, irb->scsw.cstat); return -EAGAIN; } diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c index 85a3026..143b6c2 100644 --- a/drivers/s390/cio/device_ops.c +++ b/drivers/s390/cio/device_ops.c @@ -1,7 +1,7 @@ /* * drivers/s390/cio/device_ops.c * - * $Revision: 1.57 $ + * $Revision: 1.58 $ * * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, * IBM Corporation @@ -570,7 +570,7 @@ ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no) int _ccw_device_get_subchannel_number(struct ccw_device *cdev) { - return cdev->private->irq; + return cdev->private->sch_no; } int diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c index 757b270..f08e84c 100644 --- a/drivers/s390/cio/device_pgid.c +++ b/drivers/s390/cio/device_pgid.c @@ -59,7 +59,7 @@ __ccw_device_sense_pgid_start(struct ccw_device *cdev) CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " "%04x, lpm %02X, became 'not " "operational'\n", - cdev->private->devno, sch->irq, + cdev->private->devno, sch->schid.sch_no, cdev->private->imask); } @@ -121,13 +121,14 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev) if (irb->scsw.cc == 3) { CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " "%04x, lpm %02X, became 'not operational'\n", - cdev->private->devno, sch->irq, sch->orb.lpm); + cdev->private->devno, sch->schid.sch_no, + sch->orb.lpm); return -EACCES; } if (cdev->private->pgid.inf.ps.state2 == SNID_STATE2_RESVD_ELSE) { CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel %04x " "is reserved by someone else\n", - cdev->private->devno, sch->irq); + cdev->private->devno, sch->schid.sch_no); return -EUSERS; } return 0; @@ -237,7 +238,7 @@ __ccw_device_do_pgid(struct ccw_device *cdev, __u8 func) sch->vpm &= ~cdev->private->imask; CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " "%04x, lpm %02X, became 'not operational'\n", - cdev->private->devno, sch->irq, cdev->private->imask); + cdev->private->devno, sch->schid.sch_no, cdev->private->imask); return ret; } @@ -271,7 +272,7 @@ __ccw_device_check_pgid(struct ccw_device *cdev) if (irb->scsw.cc == 3) { CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " "%04x, lpm %02X, became 'not operational'\n", - cdev->private->devno, sch->irq, + cdev->private->devno, sch->schid.sch_no, cdev->private->imask); return -EACCES; } @@ -373,7 +374,7 @@ ccw_device_verify_start(struct ccw_device *cdev) * Update sch->lpm with current values to catch paths becoming * available again. */ - if (stsch(sch->irq, &sch->schib)) { + if (stsch(sch->schid, &sch->schib)) { ccw_device_verify_done(cdev, -ENODEV); return; } diff --git a/drivers/s390/cio/device_status.c b/drivers/s390/cio/device_status.c index 12a24d4..929f8fb 100644 --- a/drivers/s390/cio/device_status.c +++ b/drivers/s390/cio/device_status.c @@ -38,13 +38,13 @@ ccw_device_msg_control_check(struct ccw_device *cdev, struct irb *irb) "received" " ... device %04X on subchannel %04X, dev_stat " ": %02X sch_stat : %02X\n", - cdev->private->devno, cdev->private->irq, + cdev->private->devno, cdev->private->sch_no, irb->scsw.dstat, irb->scsw.cstat); if (irb->scsw.cc != 3) { char dbf_text[15]; - sprintf(dbf_text, "chk%x", cdev->private->irq); + sprintf(dbf_text, "chk%x", cdev->private->sch_no); CIO_TRACE_EVENT(0, dbf_text); CIO_HEX_EVENT(0, irb, sizeof (struct irb)); } @@ -59,10 +59,10 @@ ccw_device_path_notoper(struct ccw_device *cdev) struct subchannel *sch; sch = to_subchannel(cdev->dev.parent); - stsch (sch->irq, &sch->schib); + stsch (sch->schid, &sch->schib); CIO_MSG_EVENT(0, "%s(%04x) - path(s) %02x are " - "not operational \n", __FUNCTION__, sch->irq, + "not operational \n", __FUNCTION__, sch->schid.sch_no, sch->schib.pmcw.pnom); sch->lpm &= ~sch->schib.pmcw.pnom; diff --git a/drivers/s390/cio/ioasm.h b/drivers/s390/cio/ioasm.h index 45480a2..66c882e 100644 --- a/drivers/s390/cio/ioasm.h +++ b/drivers/s390/cio/ioasm.h @@ -1,12 +1,13 @@ #ifndef S390_CIO_IOASM_H #define S390_CIO_IOASM_H +#include "schid.h" + /* * TPI info structure */ struct tpi_info { - __u32 reserved1 : 16; /* reserved 0x00000001 */ - __u32 irq : 16; /* aka. subchannel number */ + struct subchannel_id schid; __u32 intparm; /* interruption parameter */ __u32 adapter_IO : 1; __u32 reserved2 : 1; @@ -21,7 +22,8 @@ struct tpi_info { * Some S390 specific IO instructions as inline */ -static inline int stsch(int irq, volatile struct schib *addr) +static inline int stsch(struct subchannel_id schid, + volatile struct schib *addr) { int ccode; @@ -31,12 +33,13 @@ static inline int stsch(int irq, volatile struct schib *addr) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "d" (irq | 0x10000), "a" (addr) + : "d" (schid), "a" (addr), "m" (*addr) : "cc", "1" ); return ccode; } -static inline int msch(int irq, volatile struct schib *addr) +static inline int msch(struct subchannel_id schid, + volatile struct schib *addr) { int ccode; @@ -46,12 +49,13 @@ static inline int msch(int irq, volatile struct schib *addr) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "d" (irq | 0x10000L), "a" (addr) + : "d" (schid), "a" (addr), "m" (*addr) : "cc", "1" ); return ccode; } -static inline int msch_err(int irq, volatile struct schib *addr) +static inline int msch_err(struct subchannel_id schid, + volatile struct schib *addr) { int ccode; @@ -74,12 +78,13 @@ static inline int msch_err(int irq, volatile struct schib *addr) ".previous" #endif : "=&d" (ccode) - : "d" (irq | 0x10000L), "a" (addr), "K" (-EIO) + : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr) : "cc", "1" ); return ccode; } -static inline int tsch(int irq, volatile struct irb *addr) +static inline int tsch(struct subchannel_id schid, + volatile struct irb *addr) { int ccode; @@ -89,7 +94,7 @@ static inline int tsch(int irq, volatile struct irb *addr) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "d" (irq | 0x10000L), "a" (addr) + : "d" (schid), "a" (addr), "m" (*addr) : "cc", "1" ); return ccode; } @@ -103,12 +108,13 @@ static inline int tpi( volatile struct tpi_info *addr) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "a" (addr) + : "a" (addr), "m" (*addr) : "cc", "1" ); return ccode; } -static inline int ssch(int irq, volatile struct orb *addr) +static inline int ssch(struct subchannel_id schid, + volatile struct orb *addr) { int ccode; @@ -118,12 +124,12 @@ static inline int ssch(int irq, volatile struct orb *addr) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "d" (irq | 0x10000L), "a" (addr) + : "d" (schid), "a" (addr), "m" (*addr) : "cc", "1" ); return ccode; } -static inline int rsch(int irq) +static inline int rsch(struct subchannel_id schid) { int ccode; @@ -133,12 +139,12 @@ static inline int rsch(int irq) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "d" (irq | 0x10000L) + : "d" (schid) : "cc", "1" ); return ccode; } -static inline int csch(int irq) +static inline int csch(struct subchannel_id schid) { int ccode; @@ -148,12 +154,12 @@ static inline int csch(int irq) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "d" (irq | 0x10000L) + : "d" (schid) : "cc", "1" ); return ccode; } -static inline int hsch(int irq) +static inline int hsch(struct subchannel_id schid) { int ccode; @@ -163,12 +169,12 @@ static inline int hsch(int irq) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "d" (irq | 0x10000L) + : "d" (schid) : "cc", "1" ); return ccode; } -static inline int xsch(int irq) +static inline int xsch(struct subchannel_id schid) { int ccode; @@ -178,21 +184,22 @@ static inline int xsch(int irq) " ipm %0\n" " srl %0,28" : "=d" (ccode) - : "d" (irq | 0x10000L) + : "d" (schid) : "cc", "1" ); return ccode; } static inline int chsc(void *chsc_area) { + typedef struct { char _[4096]; } addr_type; int cc; __asm__ __volatile__ ( - ".insn rre,0xb25f0000,%1,0 \n\t" + ".insn rre,0xb25f0000,%2,0 \n\t" "ipm %0 \n\t" "srl %0,28 \n\t" - : "=d" (cc) - : "d" (chsc_area) + : "=d" (cc), "=m" (*(addr_type *) chsc_area) + : "d" (chsc_area), "m" (*(addr_type *) chsc_area) : "cc" ); return cc; diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index e8bdfcd..5c7001b5 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c @@ -270,7 +270,7 @@ qdio_siga_sync(struct qdio_q *q, unsigned int gpr2, perf_stats.siga_syncs++; #endif /* QDIO_PERFORMANCE_STATS */ - cc = do_siga_sync(0x10000|q->irq, gpr2, gpr3); + cc = do_siga_sync(q->schid, gpr2, gpr3); if (cc) QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*)); @@ -290,12 +290,16 @@ __do_siga_output(struct qdio_q *q, unsigned int *busy_bit) { struct qdio_irq *irq; unsigned int fc = 0; + unsigned long schid; irq = (struct qdio_irq *) q->irq_ptr; if (!irq->is_qebsm) - return do_siga_output(0x10000|q->irq, q->mask, busy_bit, fc); - fc |= 0x80; - return do_siga_output(irq->sch_token, q->mask, busy_bit, fc); + schid = *((u32 *)&q->schid); + else { + schid = irq->sch_token; + fc |= 0x80; + } + return do_siga_output(schid, q->mask, busy_bit, fc); } /* @@ -349,7 +353,7 @@ qdio_siga_input(struct qdio_q *q) perf_stats.siga_ins++; #endif /* QDIO_PERFORMANCE_STATS */ - cc = do_siga_input(0x10000|q->irq, q->mask); + cc = do_siga_input(q->schid, q->mask); if (cc) QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*)); @@ -855,7 +859,7 @@ qdio_kick_outbound_q(struct qdio_q *q) /* went smooth this time, reset timestamp */ #ifdef CONFIG_QDIO_DEBUG QDIO_DBF_TEXT3(0,trace,"cc2reslv"); - sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no, + sprintf(dbf_text,"%4x%2x%2x",q->schid.sch_no,q->q_no, atomic_read(&q->busy_siga_counter)); QDIO_DBF_TEXT3(0,trace,dbf_text); #endif /* CONFIG_QDIO_DEBUG */ @@ -878,7 +882,7 @@ qdio_kick_outbound_q(struct qdio_q *q) } QDIO_DBF_TEXT2(0,trace,"cc2REPRT"); #ifdef CONFIG_QDIO_DEBUG - sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no, + sprintf(dbf_text,"%4x%2x%2x",q->schid.sch_no,q->q_no, atomic_read(&q->busy_siga_counter)); QDIO_DBF_TEXT3(0,trace,dbf_text); #endif /* CONFIG_QDIO_DEBUG */ @@ -1733,7 +1737,7 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev, void *ptr; int available; - sprintf(dbf_text,"qfqs%4x",cdev->private->irq); + sprintf(dbf_text,"qfqs%4x",cdev->private->sch_no); QDIO_DBF_TEXT0(0,setup,dbf_text); for (i=0;iinput_qs[i]; @@ -1753,7 +1757,7 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev, q->queue_type=q_format; q->int_parm=int_parm; - q->irq=irq_ptr->irq; + q->schid = irq_ptr->schid; q->irq_ptr = irq_ptr; q->cdev = cdev; q->mask=1<<(31-i); @@ -1826,7 +1830,7 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev, q->queue_type=q_format; q->int_parm=int_parm; q->is_input_q=0; - q->irq=irq_ptr->irq; + q->schid = irq_ptr->schid; q->cdev = cdev; q->irq_ptr = irq_ptr; q->mask=1<<(31-i); @@ -1933,7 +1937,7 @@ qdio_set_state(struct qdio_irq *irq_ptr, enum qdio_irq_states state) char dbf_text[15]; QDIO_DBF_TEXT5(0,trace,"newstate"); - sprintf(dbf_text,"%4x%4x",irq_ptr->irq,state); + sprintf(dbf_text,"%4x%4x",irq_ptr->schid.sch_no,state); QDIO_DBF_TEXT5(0,trace,dbf_text); #endif /* CONFIG_QDIO_DEBUG */ @@ -1946,12 +1950,12 @@ qdio_set_state(struct qdio_irq *irq_ptr, enum qdio_irq_states state) } static inline void -qdio_irq_check_sense(int irq, struct irb *irb) +qdio_irq_check_sense(struct subchannel_id schid, struct irb *irb) { char dbf_text[15]; if (irb->esw.esw0.erw.cons) { - sprintf(dbf_text,"sens%4x",irq); + sprintf(dbf_text,"sens%4x",schid.sch_no); QDIO_DBF_TEXT2(1,trace,dbf_text); QDIO_DBF_HEX0(0,sense,irb,QDIO_DBF_SENSE_LEN); @@ -2063,20 +2067,20 @@ qdio_timeout_handler(struct ccw_device *cdev) switch (irq_ptr->state) { case QDIO_IRQ_STATE_INACTIVE: QDIO_PRINT_ERR("establish queues on irq %04x: timed out\n", - irq_ptr->irq); + irq_ptr->schid.sch_no); QDIO_DBF_TEXT2(1,setup,"eq:timeo"); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); break; case QDIO_IRQ_STATE_CLEANUP: QDIO_PRINT_INFO("Did not get interrupt on cleanup, irq=0x%x.\n", - irq_ptr->irq); + irq_ptr->schid.sch_no); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); break; case QDIO_IRQ_STATE_ESTABLISHED: case QDIO_IRQ_STATE_ACTIVE: /* I/O has been terminated by common I/O layer. */ QDIO_PRINT_INFO("Queues on irq %04x killed by cio.\n", - irq_ptr->irq); + irq_ptr->schid.sch_no); QDIO_DBF_TEXT2(1, trace, "cio:term"); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED); if (get_device(&cdev->dev)) { @@ -2139,7 +2143,7 @@ qdio_handler(struct ccw_device *cdev, unsigned long intparm, struct irb *irb) } } - qdio_irq_check_sense(irq_ptr->irq, irb); + qdio_irq_check_sense(irq_ptr->schid, irb); #ifdef CONFIG_QDIO_DEBUG sprintf(dbf_text, "state:%d", irq_ptr->state); @@ -2195,7 +2199,7 @@ qdio_synchronize(struct ccw_device *cdev, unsigned int flags, return -ENODEV; #ifdef CONFIG_QDIO_DEBUG - *((int*)(&dbf_text[4])) = irq_ptr->irq; + *((int*)(&dbf_text[4])) = irq_ptr->schid.sch_no; QDIO_DBF_HEX4(0,trace,dbf_text,QDIO_DBF_TRACE_LEN); *((int*)(&dbf_text[0]))=flags; *((int*)(&dbf_text[4]))=queue_number; @@ -2207,13 +2211,13 @@ qdio_synchronize(struct ccw_device *cdev, unsigned int flags, if (!q) return -EINVAL; if (!(irq_ptr->is_qebsm)) - cc = do_siga_sync(0x10000|q->irq, 0, q->mask); + cc = do_siga_sync(q->schid, 0, q->mask); } else if (flags&QDIO_FLAG_SYNC_OUTPUT) { q=irq_ptr->output_qs[queue_number]; if (!q) return -EINVAL; if (!(irq_ptr->is_qebsm)) - cc = do_siga_sync(0x10000|q->irq, q->mask, 0); + cc = do_siga_sync(q->schid, q->mask, 0); } else return -EINVAL; @@ -2298,7 +2302,7 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) ssqd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); if (!ssqd_area) { QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \ - "SIGAs for sch x%x.\n", irq_ptr->irq); + "SIGAs for sch x%x.\n", irq_ptr->schid.sch_no); irq_ptr->qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || CHSC_FLAG_SIGA_OUTPUT_NECESSARY || CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ @@ -2312,14 +2316,14 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) .length = 0x0010, .code = 0x0024, }; - ssqd_area->first_sch = irq_ptr->irq; - ssqd_area->last_sch = irq_ptr->irq; + ssqd_area->first_sch = irq_ptr->schid.sch_no; + ssqd_area->last_sch = irq_ptr->schid.sch_no; result = chsc(ssqd_area); if (result) { QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \ "SIGAs for sch x%x.\n", - result, irq_ptr->irq); + result, irq_ptr->schid.sch_no); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || CHSC_FLAG_SIGA_OUTPUT_NECESSARY || CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ @@ -2330,7 +2334,7 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) if (ssqd_area->response.code != QDIO_CHSC_RESPONSE_CODE_OK) { QDIO_PRINT_WARN("response upon checking SIGA needs " \ "is 0x%x. Using all SIGAs for sch x%x.\n", - ssqd_area->response.code, irq_ptr->irq); + ssqd_area->response.code, irq_ptr->schid.sch_no); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || CHSC_FLAG_SIGA_OUTPUT_NECESSARY || CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ @@ -2339,9 +2343,9 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) } if (!(ssqd_area->flags & CHSC_FLAG_QDIO_CAPABILITY) || !(ssqd_area->flags & CHSC_FLAG_VALIDITY) || - (ssqd_area->sch != irq_ptr->irq)) { + (ssqd_area->sch != irq_ptr->schid.sch_no)) { QDIO_PRINT_WARN("huh? problems checking out sch x%x... " \ - "using all SIGAs.\n",irq_ptr->irq); + "using all SIGAs.\n",irq_ptr->schid.sch_no); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY | CHSC_FLAG_SIGA_OUTPUT_NECESSARY | CHSC_FLAG_SIGA_SYNC_NECESSARY; /* worst case */ @@ -2427,7 +2431,7 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero) /* set to 0x10000000 to enable * time delay disablement facility */ u32 reserved5; - u32 subsystem_id; + struct subchannel_id schid; u32 reserved6[1004]; struct chsc_header response; u32 reserved7; @@ -2449,7 +2453,7 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero) scssc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); if (!scssc_area) { QDIO_PRINT_WARN("No memory for setting indicators on " \ - "subchannel x%x.\n", irq_ptr->irq); + "subchannel x%x.\n", irq_ptr->schid.sch_no); return -ENOMEM; } scssc_area->request = (struct chsc_header) { @@ -2463,7 +2467,7 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero) scssc_area->ks = QDIO_STORAGE_KEY; scssc_area->kc = QDIO_STORAGE_KEY; scssc_area->isc = TIQDIO_THININT_ISC; - scssc_area->subsystem_id = (1<<16) + irq_ptr->irq; + scssc_area->schid = irq_ptr->schid; /* enables the time delay disablement facility. Don't care * whether it is really there (i.e. we haven't checked for * it) */ @@ -2473,12 +2477,10 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero) QDIO_PRINT_WARN("Time delay disablement facility " \ "not available\n"); - - result = chsc(scssc_area); if (result) { QDIO_PRINT_WARN("could not set indicators on irq x%x, " \ - "cc=%i.\n",irq_ptr->irq,result); + "cc=%i.\n",irq_ptr->schid.sch_no,result); result = -EIO; goto out; } @@ -2534,7 +2536,7 @@ tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target) scsscf_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); if (!scsscf_area) { QDIO_PRINT_WARN("No memory for setting delay target on " \ - "subchannel x%x.\n", irq_ptr->irq); + "subchannel x%x.\n", irq_ptr->schid.sch_no); return -ENOMEM; } scsscf_area->request = (struct chsc_header) { @@ -2547,7 +2549,8 @@ tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target) result=chsc(scsscf_area); if (result) { QDIO_PRINT_WARN("could not set delay target on irq x%x, " \ - "cc=%i. Continuing.\n",irq_ptr->irq,result); + "cc=%i. Continuing.\n",irq_ptr->schid.sch_no, + result); result = -EIO; goto out; } @@ -2581,7 +2584,7 @@ qdio_cleanup(struct ccw_device *cdev, int how) if (!irq_ptr) return -ENODEV; - sprintf(dbf_text,"qcln%4x",irq_ptr->irq); + sprintf(dbf_text,"qcln%4x",irq_ptr->schid.sch_no); QDIO_DBF_TEXT1(0,trace,dbf_text); QDIO_DBF_TEXT0(0,setup,dbf_text); @@ -2608,7 +2611,7 @@ qdio_shutdown(struct ccw_device *cdev, int how) down(&irq_ptr->setting_up_sema); - sprintf(dbf_text,"qsqs%4x",irq_ptr->irq); + sprintf(dbf_text,"qsqs%4x",irq_ptr->schid.sch_no); QDIO_DBF_TEXT1(0,trace,dbf_text); QDIO_DBF_TEXT0(0,setup,dbf_text); @@ -2714,7 +2717,7 @@ qdio_free(struct ccw_device *cdev) down(&irq_ptr->setting_up_sema); - sprintf(dbf_text,"qfqs%4x",irq_ptr->irq); + sprintf(dbf_text,"qfqs%4x",irq_ptr->schid.sch_no); QDIO_DBF_TEXT1(0,trace,dbf_text); QDIO_DBF_TEXT0(0,setup,dbf_text); @@ -2862,13 +2865,13 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat, irq_ptr = cdev->private->qdio_data; if (cstat || (dstat & ~(DEV_STAT_CHN_END|DEV_STAT_DEV_END))) { - sprintf(dbf_text,"ick1%4x",irq_ptr->irq); + sprintf(dbf_text,"ick1%4x",irq_ptr->schid.sch_no); QDIO_DBF_TEXT2(1,trace,dbf_text); QDIO_DBF_HEX2(0,trace,&dstat,sizeof(int)); QDIO_DBF_HEX2(0,trace,&cstat,sizeof(int)); QDIO_PRINT_ERR("received check condition on establish " \ "queues on irq 0x%x (cs=x%x, ds=x%x).\n", - irq_ptr->irq,cstat,dstat); + irq_ptr->schid.sch_no,cstat,dstat); qdio_set_state(irq_ptr,QDIO_IRQ_STATE_ERR); } @@ -2878,7 +2881,7 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat, QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat)); QDIO_PRINT_ERR("establish queues on irq %04x: didn't get " "device end: dstat=%02x, cstat=%02x\n", - irq_ptr->irq, dstat, cstat); + irq_ptr->schid.sch_no, dstat, cstat); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); return 1; } @@ -2890,7 +2893,7 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat, QDIO_PRINT_ERR("establish queues on irq %04x: got " "the following devstat: dstat=%02x, " "cstat=%02x\n", - irq_ptr->irq, dstat, cstat); + irq_ptr->schid.sch_no, dstat, cstat); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); return 1; } @@ -2905,7 +2908,7 @@ qdio_establish_handle_irq(struct ccw_device *cdev, int cstat, int dstat) irq_ptr = cdev->private->qdio_data; - sprintf(dbf_text,"qehi%4x",cdev->private->irq); + sprintf(dbf_text,"qehi%4x",cdev->private->sch_no); QDIO_DBF_TEXT0(0,setup,dbf_text); QDIO_DBF_TEXT0(0,trace,dbf_text); @@ -2924,7 +2927,7 @@ qdio_initialize(struct qdio_initialize *init_data) int rc; char dbf_text[15]; - sprintf(dbf_text,"qini%4x",init_data->cdev->private->irq); + sprintf(dbf_text,"qini%4x",init_data->cdev->private->sch_no); QDIO_DBF_TEXT0(0,setup,dbf_text); QDIO_DBF_TEXT0(0,trace,dbf_text); @@ -2945,7 +2948,7 @@ qdio_allocate(struct qdio_initialize *init_data) struct qdio_irq *irq_ptr; char dbf_text[15]; - sprintf(dbf_text,"qalc%4x",init_data->cdev->private->irq); + sprintf(dbf_text,"qalc%4x",init_data->cdev->private->sch_no); QDIO_DBF_TEXT0(0,setup,dbf_text); QDIO_DBF_TEXT0(0,trace,dbf_text); if ( (init_data->no_input_qs>QDIO_MAX_QUEUES_PER_IRQ) || @@ -3018,7 +3021,7 @@ int qdio_fill_irq(struct qdio_initialize *init_data) irq_ptr->int_parm=init_data->int_parm; - irq_ptr->irq = init_data->cdev->private->irq; + irq_ptr->schid = ccw_device_get_subchannel_id(init_data->cdev); irq_ptr->no_input_qs=init_data->no_input_qs; irq_ptr->no_output_qs=init_data->no_output_qs; @@ -3038,7 +3041,7 @@ int qdio_fill_irq(struct qdio_initialize *init_data) QDIO_DBF_HEX1(0,setup,&irq_ptr->dev_st_chg_ind,sizeof(void*)); if (!irq_ptr->dev_st_chg_ind) { QDIO_PRINT_WARN("no indicator location available " \ - "for irq 0x%x\n",irq_ptr->irq); + "for irq 0x%x\n",irq_ptr->schid.sch_no); qdio_release_irq_memory(irq_ptr); return -ENOBUFS; } @@ -3169,7 +3172,7 @@ qdio_establish(struct qdio_initialize *init_data) tiqdio_set_delay_target(irq_ptr,TIQDIO_DELAY_TARGET); } - sprintf(dbf_text,"qest%4x",cdev->private->irq); + sprintf(dbf_text,"qest%4x",cdev->private->sch_no); QDIO_DBF_TEXT0(0,setup,dbf_text); QDIO_DBF_TEXT0(0,trace,dbf_text); @@ -3197,7 +3200,7 @@ qdio_establish(struct qdio_initialize *init_data) } QDIO_PRINT_WARN("establish queues on irq %04x: do_IO " \ "returned %i, next try returned %i\n", - irq_ptr->irq,result,result2); + irq_ptr->schid.sch_no,result,result2); result=result2; if (result) ccw_device_set_timeout(cdev, 0); @@ -3270,7 +3273,7 @@ qdio_activate(struct ccw_device *cdev, int flags) goto out; } - sprintf(dbf_text,"qact%4x", irq_ptr->irq); + sprintf(dbf_text,"qact%4x", irq_ptr->schid.sch_no); QDIO_DBF_TEXT2(0,setup,dbf_text); QDIO_DBF_TEXT2(0,trace,dbf_text); @@ -3297,7 +3300,7 @@ qdio_activate(struct ccw_device *cdev, int flags) } QDIO_PRINT_WARN("activate queues on irq %04x: do_IO " \ "returned %i, next try returned %i\n", - irq_ptr->irq,result,result2); + irq_ptr->schid.sch_no,result,result2); result=result2; } @@ -3509,7 +3512,7 @@ do_QDIO(struct ccw_device *cdev,unsigned int callflags, #ifdef CONFIG_QDIO_DEBUG char dbf_text[20]; - sprintf(dbf_text,"doQD%04x",cdev->private->irq); + sprintf(dbf_text,"doQD%04x",cdev->private->sch_no); QDIO_DBF_TEXT3(0,trace,dbf_text); #endif /* CONFIG_QDIO_DEBUG */ diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h index b5d303e..43b840a 100644 --- a/drivers/s390/cio/qdio.h +++ b/drivers/s390/cio/qdio.h @@ -3,7 +3,9 @@ #include -#define VERSION_CIO_QDIO_H "$Revision: 1.37 $" +#include "schid.h" + +#define VERSION_CIO_QDIO_H "$Revision: 1.40 $" #ifdef CONFIG_QDIO_DEBUG #define QDIO_VERBOSE_LEVEL 9 @@ -317,7 +319,7 @@ do_eqbs(unsigned long sch, unsigned char *state, int queue, static inline int -do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2) +do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2) { int cc; @@ -331,7 +333,7 @@ do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2) "ipm %0 \n\t" "srl %0,28 \n\t" : "=d" (cc) - : "d" (irq), "d" (mask1), "d" (mask2) + : "d" (schid), "d" (mask1), "d" (mask2) : "cc", "0", "1", "2", "3" ); #else /* CONFIG_ARCH_S390X */ @@ -344,7 +346,7 @@ do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2) "ipm %0 \n\t" "srl %0,28 \n\t" : "=d" (cc) - : "d" (irq), "d" (mask1), "d" (mask2) + : "d" (schid), "d" (mask1), "d" (mask2) : "cc", "0", "1", "2", "3" ); #endif /* CONFIG_ARCH_S390X */ @@ -352,7 +354,7 @@ do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2) } static inline int -do_siga_input(unsigned int irq, unsigned int mask) +do_siga_input(struct subchannel_id schid, unsigned int mask) { int cc; @@ -365,7 +367,7 @@ do_siga_input(unsigned int irq, unsigned int mask) "ipm %0 \n\t" "srl %0,28 \n\t" : "=d" (cc) - : "d" (irq), "d" (mask) + : "d" (schid), "d" (mask) : "cc", "0", "1", "2", "memory" ); #else /* CONFIG_ARCH_S390X */ @@ -377,7 +379,7 @@ do_siga_input(unsigned int irq, unsigned int mask) "ipm %0 \n\t" "srl %0,28 \n\t" : "=d" (cc) - : "d" (irq), "d" (mask) + : "d" (schid), "d" (mask) : "cc", "0", "1", "2", "memory" ); #endif /* CONFIG_ARCH_S390X */ @@ -386,7 +388,7 @@ do_siga_input(unsigned int irq, unsigned int mask) } static inline int -do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb, +do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb, unsigned int fc) { int cc; @@ -418,7 +420,7 @@ do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb, ".long 0b,2b \n\t" ".previous \n\t" : "=d" (cc), "=d" (busy_bit) - : "d" (irq), "d" (mask), + : "d" (schid), "d" (mask), "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION) : "cc", "0", "1", "2", "memory" ); @@ -443,7 +445,7 @@ do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb, ".quad 0b,1b \n\t" ".previous \n\t" : "=d" (cc), "=d" (busy_bit) - : "d" (irq), "d" (mask), + : "d" (schid), "d" (mask), "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION), "d" (fc) : "cc", "0", "1", "2", "memory" ); @@ -554,7 +556,7 @@ struct qdio_q { __u32 * dev_st_chg_ind; int is_input_q; - int irq; + struct subchannel_id schid; struct ccw_device *cdev; unsigned int is_iqdio_q; @@ -649,7 +651,7 @@ struct qdio_irq { __u32 * volatile dev_st_chg_ind; unsigned long int_parm; - int irq; + struct subchannel_id schid; unsigned int is_iqdio_irq; unsigned int is_thinint_irq; diff --git a/drivers/s390/cio/schid.h b/drivers/s390/cio/schid.h new file mode 100644 index 0000000..220d978 --- /dev/null +++ b/drivers/s390/cio/schid.h @@ -0,0 +1,25 @@ +#ifndef S390_SCHID_H +#define S390_SCHID_H + +struct subchannel_id { + __u32 reserved:15; + __u32 one:1; + __u32 sch_no:16; +} __attribute__ ((packed,aligned(4))); + + +/* Helper function for sane state of pre-allocated subchannel_id. */ +static inline void +init_subchannel_id(struct subchannel_id *schid) +{ + memset(schid, 0, sizeof(struct subchannel_id)); + schid->one = 1; +} + +static inline int +schid_equal(struct subchannel_id *schid1, struct subchannel_id *schid2) +{ + return !memcmp(schid1, schid2, sizeof(struct subchannel_id)); +} + +#endif /* S390_SCHID_H */ -- cgit v1.1 From f97a56fb768e5fe9cd07c56ca47870136bb5530c Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Fri, 6 Jan 2006 00:19:22 -0800 Subject: [PATCH] s390: introduce for_each_subchannel for_each_subchannel() is an iterator calling a function for every possible subchannel id until non-zero is returned. Convert the current iterating functions to it. Signed-off-by: Cornelia Huck Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/cio/blacklist.c | 46 +++--- drivers/s390/cio/chsc.c | 372 ++++++++++++++++++++++--------------------- drivers/s390/cio/cio.c | 79 ++++----- drivers/s390/cio/css.c | 110 +++++++------ drivers/s390/cio/css.h | 1 + 5 files changed, 318 insertions(+), 290 deletions(-) diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c index a4b0303..25e9848 100644 --- a/drivers/s390/cio/blacklist.c +++ b/drivers/s390/cio/blacklist.c @@ -219,6 +219,27 @@ is_blacklisted (int devno) } #ifdef CONFIG_PROC_FS +static int +__s390_redo_validation(struct subchannel_id schid, void *data) +{ + int ret; + struct subchannel *sch; + + sch = get_subchannel_by_schid(schid); + if (sch) { + /* Already known. */ + put_device(&sch->dev); + return 0; + } + ret = css_probe_device(schid); + if (ret == -ENXIO) + return ret; /* We're through. */ + if (ret == -ENOMEM) + /* Stop validation for now. Bad, but no need for a panic. */ + return ret; + return 0; +} + /* * Function: s390_redo_validation * Look for no longer blacklisted devices @@ -226,30 +247,9 @@ is_blacklisted (int devno) static inline void s390_redo_validation (void) { - struct subchannel_id schid; - CIO_TRACE_EVENT (0, "redoval"); - init_subchannel_id(&schid); - do { - int ret; - struct subchannel *sch; - - sch = get_subchannel_by_schid(schid); - if (sch) { - /* Already known. */ - put_device(&sch->dev); - continue; - } - ret = css_probe_device(schid); - if (ret == -ENXIO) - break; /* We're through. */ - if (ret == -ENOMEM) - /* - * Stop validation for now. Bad, but no need for a - * panic. - */ - break; - } while (schid.sch_no++ < __MAX_SUBCHANNEL); + + for_each_subchannel(__s390_redo_validation, NULL); } /* diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c index aff5d14..78e0823 100644 --- a/drivers/s390/cio/chsc.c +++ b/drivers/s390/cio/chsc.c @@ -310,9 +310,14 @@ s390_set_chpid_offline( __u8 chpid) queue_work(slow_path_wq, &slow_path_work); } +struct res_acc_data { + struct channel_path *chp; + u32 fla_mask; + u16 fla; +}; + static int -s390_process_res_acc_sch(u8 chpid, __u16 fla, u32 fla_mask, - struct subchannel *sch) +s390_process_res_acc_sch(struct res_acc_data *res_data, struct subchannel *sch) { int found; int chp; @@ -324,8 +329,9 @@ s390_process_res_acc_sch(u8 chpid, __u16 fla, u32 fla_mask, * check if chpid is in information updated by ssd */ if (sch->ssd_info.valid && - sch->ssd_info.chpid[chp] == chpid && - (sch->ssd_info.fla[chp] & fla_mask) == fla) { + sch->ssd_info.chpid[chp] == res_data->chp->id && + (sch->ssd_info.fla[chp] & res_data->fla_mask) + == res_data->fla) { found = 1; break; } @@ -345,18 +351,80 @@ s390_process_res_acc_sch(u8 chpid, __u16 fla, u32 fla_mask, return 0x80 >> chp; } +static inline int +s390_process_res_acc_new_sch(struct subchannel_id schid) +{ + struct schib schib; + int ret; + /* + * We don't know the device yet, but since a path + * may be available now to the device we'll have + * to do recognition again. + * Since we don't have any idea about which chpid + * that beast may be on we'll have to do a stsch + * on all devices, grr... + */ + if (stsch(schid, &schib)) + /* We're through */ + return need_rescan ? -EAGAIN : -ENXIO; + + /* Put it on the slow path. */ + ret = css_enqueue_subchannel_slow(schid); + if (ret) { + css_clear_subchannel_slow_list(); + need_rescan = 1; + return -EAGAIN; + } + return 0; +} + static int -s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask) +__s390_process_res_acc(struct subchannel_id schid, void *data) { + int chp_mask, old_lpm; + struct res_acc_data *res_data; struct subchannel *sch; + + res_data = (struct res_acc_data *)data; + sch = get_subchannel_by_schid(schid); + if (!sch) + /* Check if a subchannel is newly available. */ + return s390_process_res_acc_new_sch(schid); + + spin_lock_irq(&sch->lock); + + chp_mask = s390_process_res_acc_sch(res_data, sch); + + if (chp_mask == 0) { + spin_unlock_irq(&sch->lock); + return 0; + } + old_lpm = sch->lpm; + sch->lpm = ((sch->schib.pmcw.pim & + sch->schib.pmcw.pam & + sch->schib.pmcw.pom) + | chp_mask) & sch->opm; + if (!old_lpm && sch->lpm) + device_trigger_reprobe(sch); + else if (sch->driver && sch->driver->verify) + sch->driver->verify(&sch->dev); + + spin_unlock_irq(&sch->lock); + put_device(&sch->dev); + return (res_data->fla_mask == 0xffff) ? -ENODEV : 0; +} + + +static int +s390_process_res_acc (struct res_acc_data *res_data) +{ int rc; - struct subchannel_id schid; char dbf_txt[15]; - sprintf(dbf_txt, "accpr%x", chpid); + sprintf(dbf_txt, "accpr%x", res_data->chp->id); CIO_TRACE_EVENT( 2, dbf_txt); - if (fla != 0) { - sprintf(dbf_txt, "fla%x", fla); + if (res_data->fla != 0) { + sprintf(dbf_txt, "fla%x", res_data->fla); CIO_TRACE_EVENT( 2, dbf_txt); } @@ -367,71 +435,11 @@ s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask) * The more information we have (info), the less scanning * will we have to do. */ - - if (!get_chp_status(chpid)) - return 0; /* no need to do the rest */ - - rc = 0; - init_subchannel_id(&schid); - do { - int chp_mask, old_lpm; - - sch = get_subchannel_by_schid(schid); - if (!sch) { - struct schib schib; - int ret; - /* - * We don't know the device yet, but since a path - * may be available now to the device we'll have - * to do recognition again. - * Since we don't have any idea about which chpid - * that beast may be on we'll have to do a stsch - * on all devices, grr... - */ - if (stsch(schid, &schib)) { - /* We're through */ - if (need_rescan) - rc = -EAGAIN; - break; - } - if (need_rescan) { - rc = -EAGAIN; - continue; - } - /* Put it on the slow path. */ - ret = css_enqueue_subchannel_slow(schid); - if (ret) { - css_clear_subchannel_slow_list(); - need_rescan = 1; - } - rc = -EAGAIN; - continue; - } - - spin_lock_irq(&sch->lock); - - chp_mask = s390_process_res_acc_sch(chpid, fla, fla_mask, sch); - - if (chp_mask == 0) { - - spin_unlock_irq(&sch->lock); - continue; - } - old_lpm = sch->lpm; - sch->lpm = ((sch->schib.pmcw.pim & - sch->schib.pmcw.pam & - sch->schib.pmcw.pom) - | chp_mask) & sch->opm; - if (!old_lpm && sch->lpm) - device_trigger_reprobe(sch); - else if (sch->driver && sch->driver->verify) - sch->driver->verify(&sch->dev); - - spin_unlock_irq(&sch->lock); - put_device(&sch->dev); - if (fla_mask == 0xffff) - break; - } while (schid.sch_no++ < __MAX_SUBCHANNEL); + rc = for_each_subchannel(__s390_process_res_acc, res_data); + if (css_slow_subchannels_exist()) + rc = -EAGAIN; + else if (rc != -EAGAIN) + rc = 0; return rc; } @@ -469,6 +477,7 @@ int chsc_process_crw(void) { int chpid, ret; + struct res_acc_data res_data; struct { struct chsc_header request; u32 reserved1; @@ -503,7 +512,7 @@ chsc_process_crw(void) do { int ccode, status; memset(sei_area, 0, sizeof(*sei_area)); - + memset(&res_data, 0, sizeof(struct res_acc_data)); sei_area->request = (struct chsc_header) { .length = 0x0010, .code = 0x000e, @@ -576,26 +585,23 @@ chsc_process_crw(void) if (status < 0) new_channel_path(sei_area->rsid); else if (!status) - return 0; - if ((sei_area->vf & 0x80) == 0) { - pr_debug("chpid: %x\n", sei_area->rsid); - ret = s390_process_res_acc(sei_area->rsid, - 0, 0); - } else if ((sei_area->vf & 0xc0) == 0x80) { - pr_debug("chpid: %x link addr: %x\n", - sei_area->rsid, sei_area->fla); - ret = s390_process_res_acc(sei_area->rsid, - sei_area->fla, - 0xff00); - } else if ((sei_area->vf & 0xc0) == 0xc0) { - pr_debug("chpid: %x full link addr: %x\n", - sei_area->rsid, sei_area->fla); - ret = s390_process_res_acc(sei_area->rsid, - sei_area->fla, - 0xffff); + break; + res_data.chp = chps[sei_area->rsid]; + pr_debug("chpid: %x", sei_area->rsid); + if ((sei_area->vf & 0xc0) != 0) { + res_data.fla = sei_area->fla; + if ((sei_area->vf & 0xc0) == 0xc0) { + pr_debug(" full link addr: %x", + sei_area->fla); + res_data.fla_mask = 0xffff; + } else { + pr_debug(" link addr: %x", + sei_area->fla); + res_data.fla_mask = 0xff00; + } } - pr_debug("\n"); - + ret = s390_process_res_acc(&res_data); + pr_debug("\n\n"); break; default: /* other stuff */ @@ -607,12 +613,70 @@ chsc_process_crw(void) return ret; } +static inline int +__chp_add_new_sch(struct subchannel_id schid) +{ + struct schib schib; + int ret; + + if (stsch(schid, &schib)) + /* We're through */ + return need_rescan ? -EAGAIN : -ENXIO; + + /* Put it on the slow path. */ + ret = css_enqueue_subchannel_slow(schid); + if (ret) { + css_clear_subchannel_slow_list(); + need_rescan = 1; + return -EAGAIN; + } + return 0; +} + + static int -chp_add(int chpid) +__chp_add(struct subchannel_id schid, void *data) { + int i; + struct channel_path *chp; struct subchannel *sch; - int ret, rc; - struct subchannel_id schid; + + chp = (struct channel_path *)data; + sch = get_subchannel_by_schid(schid); + if (!sch) + /* Check if the subchannel is now available. */ + return __chp_add_new_sch(schid); + spin_lock(&sch->lock); + for (i=0; i<8; i++) + if (sch->schib.pmcw.chpid[i] == chp->id) { + if (stsch(sch->schid, &sch->schib) != 0) { + /* Endgame. */ + spin_unlock(&sch->lock); + return -ENXIO; + } + break; + } + if (i==8) { + spin_unlock(&sch->lock); + return 0; + } + sch->lpm = ((sch->schib.pmcw.pim & + sch->schib.pmcw.pam & + sch->schib.pmcw.pom) + | 0x80 >> i) & sch->opm; + + if (sch->driver && sch->driver->verify) + sch->driver->verify(&sch->dev); + + spin_unlock(&sch->lock); + put_device(&sch->dev); + return 0; +} + +static int +chp_add(int chpid) +{ + int rc; char dbf_txt[15]; if (!get_chp_status(chpid)) @@ -621,60 +685,11 @@ chp_add(int chpid) sprintf(dbf_txt, "cadd%x", chpid); CIO_TRACE_EVENT(2, dbf_txt); - rc = 0; - init_subchannel_id(&schid); - do { - int i; - - sch = get_subchannel_by_schid(schid); - if (!sch) { - struct schib schib; - - if (stsch(schid, &schib)) { - /* We're through */ - if (need_rescan) - rc = -EAGAIN; - break; - } - if (need_rescan) { - rc = -EAGAIN; - continue; - } - /* Put it on the slow path. */ - ret = css_enqueue_subchannel_slow(schid); - if (ret) { - css_clear_subchannel_slow_list(); - need_rescan = 1; - } - rc = -EAGAIN; - continue; - } - - spin_lock(&sch->lock); - for (i=0; i<8; i++) - if (sch->schib.pmcw.chpid[i] == chpid) { - if (stsch(sch->schid, &sch->schib) != 0) { - /* Endgame. */ - spin_unlock(&sch->lock); - return rc; - } - break; - } - if (i==8) { - spin_unlock(&sch->lock); - return rc; - } - sch->lpm = ((sch->schib.pmcw.pim & - sch->schib.pmcw.pam & - sch->schib.pmcw.pom) - | 0x80 >> i) & sch->opm; - - if (sch->driver && sch->driver->verify) - sch->driver->verify(&sch->dev); - - spin_unlock(&sch->lock); - put_device(&sch->dev); - } while (schid.sch_no++ < __MAX_SUBCHANNEL); + rc = for_each_subchannel(__chp_add, chps[chpid]); + if (css_slow_subchannels_exist()) + rc = -EAGAIN; + if (rc != -EAGAIN) + rc = 0; return rc; } @@ -786,6 +801,29 @@ s390_subchannel_vary_chpid_on(struct device *dev, void *data) return 0; } +static int +__s390_vary_chpid_on(struct subchannel_id schid, void *data) +{ + struct schib schib; + struct subchannel *sch; + + sch = get_subchannel_by_schid(schid); + if (sch) { + put_device(&sch->dev); + return 0; + } + if (stsch(schid, &schib)) + /* We're through */ + return -ENXIO; + /* Put it on the slow path. */ + if (css_enqueue_subchannel_slow(schid)) { + css_clear_subchannel_slow_list(); + need_rescan = 1; + return -EAGAIN; + } + return 0; +} + /* * Function: s390_vary_chpid * Varies the specified chpid online or offline @@ -794,9 +832,7 @@ static int s390_vary_chpid( __u8 chpid, int on) { char dbf_text[15]; - int status, ret; - struct subchannel_id schid; - struct subchannel *sch; + int status; sprintf(dbf_text, on?"varyon%x":"varyoff%x", chpid); CIO_TRACE_EVENT( 2, dbf_text); @@ -821,31 +857,9 @@ s390_vary_chpid( __u8 chpid, int on) bus_for_each_dev(&css_bus_type, NULL, &chpid, on ? s390_subchannel_vary_chpid_on : s390_subchannel_vary_chpid_off); - if (!on) - goto out; - /* Scan for new devices on varied on path. */ - init_subchannel_id(&schid); - do { - struct schib schib; - - if (need_rescan) - break; - sch = get_subchannel_by_schid(schid); - if (sch) { - put_device(&sch->dev); - continue; - } - if (stsch(schid, &schib)) - /* We're through */ - break; - /* Put it on the slow path. */ - ret = css_enqueue_subchannel_slow(schid); - if (ret) { - css_clear_subchannel_slow_list(); - need_rescan = 1; - } - } while (schid.sch_no++ < __MAX_SUBCHANNEL); -out: + if (on) + /* Scan for new devices on varied on path. */ + for_each_subchannel(__s390_vary_chpid_on, NULL); if (need_rescan || css_slow_subchannels_exist()) queue_work(slow_path_wq, &slow_path_work); return 0; diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 396bada..3eb6cb6 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c @@ -691,7 +691,22 @@ wait_cons_dev (void) } static int -cio_console_irq(void) +cio_test_for_console(struct subchannel_id schid, void *data) +{ + if (stsch(schid, &console_subchannel.schib) != 0) + return -ENXIO; + if (console_subchannel.schib.pmcw.dnv && + console_subchannel.schib.pmcw.dev == + console_devno) { + console_irq = schid.sch_no; + return 1; /* found */ + } + return 0; +} + + +static int +cio_get_console_sch_no(void) { struct subchannel_id schid; @@ -705,16 +720,7 @@ cio_console_irq(void) console_devno = console_subchannel.schib.pmcw.dev; } else if (console_devno != -1) { /* At least the console device number is known. */ - do { - if (stsch(schid, &console_subchannel.schib) != 0) - break; - if (console_subchannel.schib.pmcw.dnv && - console_subchannel.schib.pmcw.dev == - console_devno) { - console_irq = schid.sch_no; - break; - } - } while (schid.sch_no++ < __MAX_SUBCHANNEL); + for_each_subchannel(cio_test_for_console, NULL); if (console_irq == -1) return -1; } else { @@ -730,19 +736,19 @@ cio_console_irq(void) struct subchannel * cio_probe_console(void) { - int irq, ret; + int sch_no, ret; struct subchannel_id schid; if (xchg(&console_subchannel_in_use, 1) != 0) return ERR_PTR(-EBUSY); - irq = cio_console_irq(); - if (irq == -1) { + sch_no = cio_get_console_sch_no(); + if (sch_no == -1) { console_subchannel_in_use = 0; return ERR_PTR(-ENODEV); } memset(&console_subchannel, 0, sizeof(struct subchannel)); init_subchannel_id(&schid); - schid.sch_no = irq; + schid.sch_no = sch_no; ret = cio_validate_subchannel(&console_subchannel, schid); if (ret) { console_subchannel_in_use = 0; @@ -830,32 +836,33 @@ __clear_subchannel_easy(struct subchannel_id schid) } extern void do_reipl(unsigned long devno); +static int +__shutdown_subchannel_easy(struct subchannel_id schid, void *data) +{ + struct schib schib; + + if (stsch(schid, &schib)) + return -ENXIO; + if (!schib.pmcw.ena) + return 0; + switch(__disable_subchannel_easy(schid, &schib)) { + case 0: + case -ENODEV: + break; + default: /* -EBUSY */ + if (__clear_subchannel_easy(schid)) + break; /* give up... */ + stsch(schid, &schib); + __disable_subchannel_easy(schid, &schib); + } + return 0; +} -/* Clear all subchannels. */ void clear_all_subchannels(void) { - struct subchannel_id schid; - local_irq_disable(); - init_subchannel_id(&schid); - do { - struct schib schib; - if (stsch(schid, &schib)) - break; /* break out of the loop */ - if (!schib.pmcw.ena) - continue; - switch(__disable_subchannel_easy(schid, &schib)) { - case 0: - case -ENODEV: - break; - default: /* -EBUSY */ - if (__clear_subchannel_easy(schid)) - break; /* give up... jump out of switch */ - stsch(schid, &schib); - __disable_subchannel_easy(schid, &schib); - } - } while (schid.sch_no++ < __MAX_SUBCHANNEL); + for_each_subchannel(__shutdown_subchannel_easy, NULL); } /* Make sure all subchannels are quiet before we re-ipl an lpar. */ diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 5137daf..dba632a 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -21,7 +21,6 @@ #include "ioasm.h" #include "chsc.h" -unsigned int highest_subchannel; int need_rescan = 0; int css_init_done = 0; @@ -32,6 +31,22 @@ struct device css_bus_device = { .bus_id = "css0", }; +inline int +for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *data) +{ + struct subchannel_id schid; + int ret; + + init_subchannel_id(&schid); + ret = -ENODEV; + do { + ret = fn(schid, data); + if (ret) + break; + } while (schid.sch_no++ < __MAX_SUBCHANNEL); + return ret; +} + static struct subchannel * css_alloc_subchannel(struct subchannel_id schid) { @@ -280,25 +295,10 @@ css_evaluate_subchannel(struct subchannel_id schid, int slow) return ret; } -static void -css_rescan_devices(void) +static int +css_rescan_devices(struct subchannel_id schid, void *data) { - int ret; - struct subchannel_id schid; - - init_subchannel_id(&schid); - do { - ret = css_evaluate_subchannel(schid, 1); - /* No more memory. It doesn't make sense to continue. No - * panic because this can happen in midflight and just - * because we can't use a new device is no reason to crash - * the system. */ - if (ret == -ENOMEM) - break; - /* -ENXIO indicates that there are no more subchannels. */ - if (ret == -ENXIO) - break; - } while (schid.sch_no++ < __MAX_SUBCHANNEL); + return css_evaluate_subchannel(schid, 1); } struct slow_subchannel { @@ -316,7 +316,7 @@ css_trigger_slow_path(void) if (need_rescan) { need_rescan = 0; - css_rescan_devices(); + for_each_subchannel(css_rescan_devices, NULL); return; } @@ -383,6 +383,43 @@ css_process_crw(int irq) return ret; } +static int __init +__init_channel_subsystem(struct subchannel_id schid, void *data) +{ + struct subchannel *sch; + int ret; + + if (cio_is_console(schid)) + sch = cio_get_console_subchannel(); + else { + sch = css_alloc_subchannel(schid); + if (IS_ERR(sch)) + ret = PTR_ERR(sch); + else + ret = 0; + switch (ret) { + case 0: + break; + case -ENOMEM: + panic("Out of memory in init_channel_subsystem\n"); + /* -ENXIO: no more subchannels. */ + case -ENXIO: + return ret; + default: + return 0; + } + } + /* + * We register ALL valid subchannels in ioinfo, even those + * that have been present before init_channel_subsystem. + * These subchannels can't have been registered yet (kmalloc + * not working) so we do it now. This is true e.g. for the + * console subchannel. + */ + css_register_subchannel(sch); + return 0; +} + static void __init css_generate_pgid(void) { @@ -410,7 +447,6 @@ static int __init init_channel_subsystem (void) { int ret; - struct subchannel_id schid; if (chsc_determine_css_characteristics() == 0) css_characteristics_avail = 1; @@ -426,38 +462,8 @@ init_channel_subsystem (void) ctl_set_bit(6, 28); - init_subchannel_id(&schid); - do { - struct subchannel *sch; - - if (cio_is_console(schid)) - sch = cio_get_console_subchannel(); - else { - sch = css_alloc_subchannel(schid); - if (IS_ERR(sch)) - ret = PTR_ERR(sch); - else - ret = 0; - if (ret == -ENOMEM) - panic("Out of memory in " - "init_channel_subsystem\n"); - /* -ENXIO: no more subchannels. */ - if (ret == -ENXIO) - break; - if (ret) - continue; - } - /* - * We register ALL valid subchannels in ioinfo, even those - * that have been present before init_channel_subsystem. - * These subchannels can't have been registered yet (kmalloc - * not working) so we do it now. This is true e.g. for the - * console subchannel. - */ - css_register_subchannel(sch); - } while (schid.sch_no++ < __MAX_SUBCHANNEL); + for_each_subchannel(__init_channel_subsystem, NULL); return 0; - out_bus: bus_unregister(&css_bus_type); out: diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h index f26e16d..71efca2 100644 --- a/drivers/s390/cio/css.h +++ b/drivers/s390/cio/css.h @@ -126,6 +126,7 @@ extern struct css_driver io_subchannel_driver; extern int css_probe_device(struct subchannel_id); extern struct subchannel * get_subchannel_by_schid(struct subchannel_id); extern int css_init_done; +extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *); #define __MAX_SUBCHANNEL 65535 -- cgit v1.1 From a28c69448154a0901e8815922030c5dcd2f8e388 Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Fri, 6 Jan 2006 00:19:23 -0800 Subject: [PATCH] s390: introduce struct channel_subsystem struct channel_subsystem encapsulates several per channel subsystem properties, like status of chpids or the global path group id. Signed-off-by: Cornelia Huck Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/cio/chsc.c | 32 ++++++++++++-------- drivers/s390/cio/chsc.h | 5 ++-- drivers/s390/cio/css.c | 67 +++++++++++++++++++++++++++++------------- drivers/s390/cio/css.h | 25 +++++++++++++--- drivers/s390/cio/device.c | 4 --- drivers/s390/cio/device_pgid.c | 2 +- 6 files changed, 90 insertions(+), 45 deletions(-) diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c index 78e0823..ebd9249 100644 --- a/drivers/s390/cio/chsc.c +++ b/drivers/s390/cio/chsc.c @@ -24,8 +24,6 @@ #include "ioasm.h" #include "chsc.h" -static struct channel_path *chps[NR_CHPIDS]; - static void *sei_page; static int new_channel_path(int chpid); @@ -33,13 +31,13 @@ static int new_channel_path(int chpid); static inline void set_chp_logically_online(int chp, int onoff) { - chps[chp]->state = onoff; + css[0]->chps[chp]->state = onoff; } static int get_chp_status(int chp) { - return (chps[chp] ? chps[chp]->state : -ENODEV); + return (css[0]->chps[chp] ? css[0]->chps[chp]->state : -ENODEV); } void @@ -219,13 +217,13 @@ s390_subchannel_remove_chpid(struct device *dev, void *data) int j; int mask; struct subchannel *sch; - __u8 *chpid; + struct channel_path *chpid; struct schib schib; sch = to_subchannel(dev); chpid = data; for (j = 0; j < 8; j++) - if (sch->schib.pmcw.chpid[j] == *chpid) + if (sch->schib.pmcw.chpid[j] == chpid->id) break; if (j >= 8) return 0; @@ -296,18 +294,20 @@ static inline void s390_set_chpid_offline( __u8 chpid) { char dbf_txt[15]; + struct device *dev; sprintf(dbf_txt, "chpr%x", chpid); CIO_TRACE_EVENT(2, dbf_txt); if (get_chp_status(chpid) <= 0) return; - - bus_for_each_dev(&css_bus_type, NULL, &chpid, + dev = get_device(&css[0]->chps[chpid]->dev); + bus_for_each_dev(&css_bus_type, NULL, to_channelpath(dev), s390_subchannel_remove_chpid); if (need_rescan || css_slow_subchannels_exist()) queue_work(slow_path_wq, &slow_path_work); + put_device(dev); } struct res_acc_data { @@ -511,6 +511,7 @@ chsc_process_crw(void) ret = 0; do { int ccode, status; + struct device *dev; memset(sei_area, 0, sizeof(*sei_area)); memset(&res_data, 0, sizeof(struct res_acc_data)); sei_area->request = (struct chsc_header) { @@ -586,7 +587,8 @@ chsc_process_crw(void) new_channel_path(sei_area->rsid); else if (!status) break; - res_data.chp = chps[sei_area->rsid]; + dev = get_device(&css[0]->chps[sei_area->rsid]->dev); + res_data.chp = to_channelpath(dev); pr_debug("chpid: %x", sei_area->rsid); if ((sei_area->vf & 0xc0) != 0) { res_data.fla = sei_area->fla; @@ -602,6 +604,7 @@ chsc_process_crw(void) } ret = s390_process_res_acc(&res_data); pr_debug("\n\n"); + put_device(dev); break; default: /* other stuff */ @@ -678,6 +681,7 @@ chp_add(int chpid) { int rc; char dbf_txt[15]; + struct device *dev; if (!get_chp_status(chpid)) return 0; /* no need to do the rest */ @@ -685,11 +689,13 @@ chp_add(int chpid) sprintf(dbf_txt, "cadd%x", chpid); CIO_TRACE_EVENT(2, dbf_txt); - rc = for_each_subchannel(__chp_add, chps[chpid]); + dev = get_device(&css[0]->chps[chpid]->dev); + rc = for_each_subchannel(__chp_add, to_channelpath(dev)); if (css_slow_subchannels_exist()) rc = -EAGAIN; if (rc != -EAGAIN) rc = 0; + put_device(dev); return rc; } @@ -1016,7 +1022,7 @@ new_channel_path(int chpid) chp->id = chpid; chp->state = 1; chp->dev = (struct device) { - .parent = &css_bus_device, + .parent = &css[0]->device, .release = chp_release, }; snprintf(chp->dev.bus_id, BUS_ID_SIZE, "chp0.%x", chpid); @@ -1038,7 +1044,7 @@ new_channel_path(int chpid) device_unregister(&chp->dev); goto out_free; } else - chps[chpid] = chp; + css[0]->chps[chpid] = chp; return ret; out_free: kfree(chp); @@ -1051,7 +1057,7 @@ chsc_get_chp_desc(struct subchannel *sch, int chp_no) struct channel_path *chp; struct channel_path_desc *desc; - chp = chps[sch->schib.pmcw.chpid[chp_no]]; + chp = css[0]->chps[sch->schib.pmcw.chpid[chp_no]]; if (!chp) return NULL; desc = kmalloc(sizeof(struct channel_path_desc), GFP_KERNEL); diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h index 6945013..170083c 100644 --- a/drivers/s390/cio/chsc.h +++ b/drivers/s390/cio/chsc.h @@ -1,8 +1,6 @@ #ifndef S390_CHSC_H #define S390_CHSC_H -#define NR_CHPIDS 256 - #define CHSC_SEI_ACC_CHPID 1 #define CHSC_SEI_ACC_LINKADDR 2 #define CHSC_SEI_ACC_FULLLINKADDR 3 @@ -65,4 +63,7 @@ extern int chsc_determine_css_characteristics(void); extern int css_characteristics_avail; extern void *chsc_get_chp_desc(struct subchannel*, int); + +#define to_channelpath(dev) container_of(dev, struct channel_path, dev) + #endif diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index dba632a..b6225cbb 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -24,12 +24,9 @@ int need_rescan = 0; int css_init_done = 0; -struct pgid global_pgid; -int css_characteristics_avail = 0; +struct channel_subsystem *css[__MAX_CSSID + 1]; -struct device css_bus_device = { - .bus_id = "css0", -}; +int css_characteristics_avail = 0; inline int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *data) @@ -112,7 +109,7 @@ css_register_subchannel(struct subchannel *sch) int ret; /* Initialize the subchannel structure */ - sch->dev.parent = &css_bus_device; + sch->dev.parent = &css[0]->device; sch->dev.bus = &css_bus_type; sch->dev.release = &css_subchannel_release; @@ -421,21 +418,35 @@ __init_channel_subsystem(struct subchannel_id schid, void *data) } static void __init -css_generate_pgid(void) +css_generate_pgid(struct channel_subsystem *css, u32 tod_high) { - /* Let's build our path group ID here. */ - if (css_characteristics_avail && css_general_characteristics.mcss) - global_pgid.cpu_addr = 0x8000; - else { + if (css_characteristics_avail && css_general_characteristics.mcss) { + css->global_pgid.pgid_high.ext_cssid.version = 0x80; + css->global_pgid.pgid_high.ext_cssid.cssid = css->cssid; + } else { #ifdef CONFIG_SMP - global_pgid.cpu_addr = hard_smp_processor_id(); + css->global_pgid.pgid_high.cpu_addr = hard_smp_processor_id(); #else - global_pgid.cpu_addr = 0; + css->global_pgid.pgid_high.cpu_addr = 0; #endif } - global_pgid.cpu_id = ((cpuid_t *) __LC_CPUID)->ident; - global_pgid.cpu_model = ((cpuid_t *) __LC_CPUID)->machine; - global_pgid.tod_high = (__u32) (get_clock() >> 32); + css->global_pgid.cpu_id = ((cpuid_t *) __LC_CPUID)->ident; + css->global_pgid.cpu_model = ((cpuid_t *) __LC_CPUID)->machine; + css->global_pgid.tod_high = tod_high; + +} + +static inline void __init +setup_css(int nr) +{ + u32 tod_high; + + memset(css[nr], 0, sizeof(struct channel_subsystem)); + css[nr]->valid = 1; + css[nr]->cssid = nr; + sprintf(css[nr]->device.bus_id, "css%x", nr); + tod_high = (u32) (get_clock() >> 32); + css_generate_pgid(css[nr], tod_high); } /* @@ -446,25 +457,39 @@ css_generate_pgid(void) static int __init init_channel_subsystem (void) { - int ret; + int ret, i; if (chsc_determine_css_characteristics() == 0) css_characteristics_avail = 1; - css_generate_pgid(); - if ((ret = bus_register(&css_bus_type))) goto out; - if ((ret = device_register (&css_bus_device))) - goto out_bus; + /* Setup css structure. */ + for (i = 0; i <= __MAX_CSSID; i++) { + css[i] = kmalloc(sizeof(struct channel_subsystem), GFP_KERNEL); + if (!css[i]) { + ret = -ENOMEM; + goto out_bus; + } + setup_css(i); + ret = device_register(&css[i]->device); + if (ret) + goto out_free; + } css_init_done = 1; ctl_set_bit(6, 28); for_each_subchannel(__init_channel_subsystem, NULL); return 0; +out_free: + kfree(css[i]); out_bus: + while (i > 0) { + i--; + device_unregister(&css[i]->device); + } bus_unregister(&css_bus_type); out: return ret; diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h index 71efca2..b74659c 100644 --- a/drivers/s390/cio/css.h +++ b/drivers/s390/cio/css.h @@ -35,19 +35,25 @@ struct path_state { __u8 resvd : 3; /* reserved */ } __attribute__ ((packed)); +struct extended_cssid { + u8 version; + u8 cssid; +} __attribute__ ((packed)); + struct pgid { union { __u8 fc; /* SPID function code */ struct path_state ps; /* SNID path state */ } inf; - __u32 cpu_addr : 16; /* CPU address */ + union { + __u32 cpu_addr : 16; /* CPU address */ + struct extended_cssid ext_cssid; + } pgid_high; __u32 cpu_id : 24; /* CPU identification */ __u32 cpu_model : 16; /* CPU model */ __u32 tod_high; /* high word TOD clock */ } __attribute__ ((packed)); -extern struct pgid global_pgid; - #define MAX_CIWS 8 /* @@ -129,9 +135,20 @@ extern int css_init_done; extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *); #define __MAX_SUBCHANNEL 65535 +#define __MAX_CHPID 255 +#define __MAX_CSSID 0 + +struct channel_subsystem { + u8 cssid; + int valid; + struct channel_path *chps[__MAX_CHPID]; + struct device device; + struct pgid global_pgid; +}; +#define to_css(dev) container_of(dev, struct channel_subsystem, device) extern struct bus_type css_bus_type; -extern struct device css_bus_device; +extern struct channel_subsystem *css[]; /* Some helper functions for disconnected state. */ int device_is_disconnected(struct subchannel *); diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index 9ac07ae..ba9f7c1 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -986,10 +986,6 @@ ccw_device_console_enable (struct ccw_device *cdev, struct subchannel *sch) cdev->dev = (struct device) { .parent = &sch->dev, }; - /* Initialize the subchannel structure */ - sch->dev.parent = &css_bus_device; - sch->dev.bus = &css_bus_type; - rc = io_subchannel_recog(cdev, sch); if (rc) return rc; diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c index f08e84c..3c89d70 100644 --- a/drivers/s390/cio/device_pgid.c +++ b/drivers/s390/cio/device_pgid.c @@ -164,7 +164,7 @@ ccw_device_sense_pgid_irq(struct ccw_device *cdev, enum dev_event dev_event) /* 0, -ETIME, -EOPNOTSUPP, -EAGAIN, -EACCES or -EUSERS */ case 0: /* Sense Path Group ID successful. */ if (cdev->private->pgid.inf.ps.state1 == SNID_STATE1_RESET) - memcpy(&cdev->private->pgid, &global_pgid, + memcpy(&cdev->private->pgid, &css[0]->global_pgid, sizeof(struct pgid)); ccw_device_sense_pgid_done(cdev, 0); break; -- cgit v1.1 From 678a395b356a98368a93c3640252502b70c3676f Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Fri, 6 Jan 2006 00:19:24 -0800 Subject: [PATCH] s390: convert /proc/cio_ignore Convert /proc/cio_ignore to a sequential file. This makes multiple subchannel sets support easier. Signed-off-by: Cornelia Huck Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/cio/blacklist.c | 122 ++++++++++++++++++++++++++++++++----------- 1 file changed, 92 insertions(+), 30 deletions(-) diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c index 25e9848..daea41c 100644 --- a/drivers/s390/cio/blacklist.c +++ b/drivers/s390/cio/blacklist.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -279,41 +280,82 @@ blacklist_parse_proc_parameters (char *buf) s390_redo_validation (); } -/* FIXME: These should be real bus ids and not home-grown ones! */ -static int cio_ignore_read (char *page, char **start, off_t off, - int count, int *eof, void *data) +/* Iterator struct for all devices. */ +struct ccwdev_iter { + int devno; + int in_range; +}; + +static void * +cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset) { - const unsigned int entry_size = 18; /* "0.0.ABCD-0.0.EFGH\n" */ - long devno; - int len; - - len = 0; - for (devno = off; /* abuse the page variable - * as counter, see fs/proc/generic.c */ - devno < __MAX_SUBCHANNEL && len + entry_size < count; devno++) { - if (!test_bit(devno, bl_dev)) - continue; - len += sprintf(page + len, "0.0.%04lx", devno); - if (test_bit(devno + 1, bl_dev)) { /* print range */ - while (++devno < __MAX_SUBCHANNEL) - if (!test_bit(devno, bl_dev)) - break; - len += sprintf(page + len, "-0.0.%04lx", --devno); - } - len += sprintf(page + len, "\n"); - } + struct ccwdev_iter *iter; + + if (*offset > __MAX_SUBCHANNEL) + return NULL; + iter = kmalloc(sizeof(struct ccwdev_iter), GFP_KERNEL); + if (!iter) + return ERR_PTR(-ENOMEM); + memset(iter, 0, sizeof(struct ccwdev_iter)); + iter->devno = *offset; + return iter; +} + +static void +cio_ignore_proc_seq_stop(struct seq_file *s, void *it) +{ + if (!IS_ERR(it)) + kfree(it); +} - if (devno < __MAX_SUBCHANNEL) - *eof = 1; - *start = (char *) (devno - off); /* number of checked entries */ - return len; +static void * +cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset) +{ + struct ccwdev_iter *iter; + + if (*offset > __MAX_SUBCHANNEL) + return NULL; + iter = (struct ccwdev_iter *)it; + iter->devno++; + (*offset)++; + return iter; } -static int cio_ignore_write(struct file *file, const char __user *user_buf, - unsigned long user_len, void *data) +static int +cio_ignore_proc_seq_show(struct seq_file *s, void *it) +{ + struct ccwdev_iter *iter; + + iter = (struct ccwdev_iter *)it; + if (!is_blacklisted(iter->devno)) + /* Not blacklisted, nothing to output. */ + return 0; + if (!iter->in_range) { + /* First device in range. */ + if ((iter->devno == __MAX_SUBCHANNEL) || + !is_blacklisted(iter->devno + 1)) + /* Singular device. */ + return seq_printf(s, "0.0.%04x\n", iter->devno); + iter->in_range = 1; + return seq_printf(s, "0.0.%04x-", iter->devno); + } + if ((iter->devno == __MAX_SUBCHANNEL) || + !is_blacklisted(iter->devno + 1)) { + /* Last device in range. */ + iter->in_range = 0; + return seq_printf(s, "0.0.%04x\n", iter->devno); + } + return 0; +} + +static ssize_t +cio_ignore_write(struct file *file, const char __user *user_buf, + size_t user_len, loff_t *offset) { char *buf; + if (*offset) + return -EINVAL; if (user_len > 65536) user_len = 65536; buf = vmalloc (user_len + 1); /* maybe better use the stack? */ @@ -331,6 +373,27 @@ static int cio_ignore_write(struct file *file, const char __user *user_buf, return user_len; } +static struct seq_operations cio_ignore_proc_seq_ops = { + .start = cio_ignore_proc_seq_start, + .stop = cio_ignore_proc_seq_stop, + .next = cio_ignore_proc_seq_next, + .show = cio_ignore_proc_seq_show, +}; + +static int +cio_ignore_proc_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &cio_ignore_proc_seq_ops); +} + +static struct file_operations cio_ignore_proc_fops = { + .open = cio_ignore_proc_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, + .write = cio_ignore_write, +}; + static int cio_ignore_proc_init (void) { @@ -341,8 +404,7 @@ cio_ignore_proc_init (void) if (!entry) return 0; - entry->read_proc = cio_ignore_read; - entry->write_proc = cio_ignore_write; + entry->proc_fops = &cio_ignore_proc_fops; return 1; } -- cgit v1.1 From fb6958a594da49ece869793e6ec163b89fc5f79f Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Fri, 6 Jan 2006 00:19:25 -0800 Subject: [PATCH] s390: multiple subchannel sets support Add support for multiple subchannel sets. Works with arbitrary devices in subchannel set 1 and is transparent to device drivers. Although currently only two subchannel sets are available, this will work with the architectured maximum number of subchannel sets as well. Signed-off-by: Cornelia Huck Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/cio/blacklist.c | 86 +++++++++++++++++++++++----------------- drivers/s390/cio/blacklist.h | 2 +- drivers/s390/cio/chsc.c | 68 +++++++++++++++++++++++++++---- drivers/s390/cio/chsc.h | 4 ++ drivers/s390/cio/cio.c | 35 +++++++++------- drivers/s390/cio/css.c | 44 ++++++++++++++------ drivers/s390/cio/css.h | 2 + drivers/s390/cio/device.c | 22 ++++++---- drivers/s390/cio/device_fsm.c | 15 ++++--- drivers/s390/cio/device_id.c | 22 +++++----- drivers/s390/cio/device_pgid.c | 40 ++++++++++--------- drivers/s390/cio/device_status.c | 10 +++-- drivers/s390/cio/ioasm.h | 29 ++++++++++++++ drivers/s390/cio/qdio.c | 81 ++++++++++++++++++++++--------------- drivers/s390/cio/schid.h | 3 +- drivers/s390/s390mach.c | 56 +++++++++++++++++++------- 16 files changed, 354 insertions(+), 165 deletions(-) diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c index daea41c..2d444cb 100644 --- a/drivers/s390/cio/blacklist.c +++ b/drivers/s390/cio/blacklist.c @@ -1,7 +1,7 @@ /* * drivers/s390/cio/blacklist.c * S/390 common I/O routines -- blacklisting of specific devices - * $Revision: 1.35 $ + * $Revision: 1.39 $ * * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, * IBM Corporation @@ -35,10 +35,10 @@ * These can be single devices or ranges of devices */ -/* 65536 bits to indicate if a devno is blacklisted or not */ +/* 65536 bits for each set to indicate if a devno is blacklisted or not */ #define __BL_DEV_WORDS ((__MAX_SUBCHANNEL + (8*sizeof(long) - 1)) / \ (8*sizeof(long))) -static unsigned long bl_dev[__BL_DEV_WORDS]; +static unsigned long bl_dev[__MAX_SSID + 1][__BL_DEV_WORDS]; typedef enum {add, free} range_action; /* @@ -46,21 +46,23 @@ typedef enum {add, free} range_action; * (Un-)blacklist the devices from-to */ static inline void -blacklist_range (range_action action, unsigned int from, unsigned int to) +blacklist_range (range_action action, unsigned int from, unsigned int to, + unsigned int ssid) { if (!to) to = from; - if (from > to || to > __MAX_SUBCHANNEL) { + if (from > to || to > __MAX_SUBCHANNEL || ssid > __MAX_SSID) { printk (KERN_WARNING "Invalid blacklist range " - "0x%04x to 0x%04x, skipping\n", from, to); + "0.%x.%04x to 0.%x.%04x, skipping\n", + ssid, from, ssid, to); return; } for (; from <= to; from++) { if (action == add) - set_bit (from, bl_dev); + set_bit (from, bl_dev[ssid]); else - clear_bit (from, bl_dev); + clear_bit (from, bl_dev[ssid]); } } @@ -70,7 +72,7 @@ blacklist_range (range_action action, unsigned int from, unsigned int to) * Shamelessly grabbed from dasd_devmap.c. */ static inline int -blacklist_busid(char **str, int *id0, int *id1, int *devno) +blacklist_busid(char **str, int *id0, int *ssid, int *devno) { int val, old_style; char *sav; @@ -87,7 +89,7 @@ blacklist_busid(char **str, int *id0, int *id1, int *devno) goto confused; val = simple_strtoul(*str, str, 16); if (old_style || (*str)[0] != '.') { - *id0 = *id1 = 0; + *id0 = *ssid = 0; if (val < 0 || val > 0xffff) goto confused; *devno = val; @@ -106,7 +108,7 @@ blacklist_busid(char **str, int *id0, int *id1, int *devno) val = simple_strtoul(*str, str, 16); if (val < 0 || val > 0xff || (*str)++[0] != '.') goto confused; - *id1 = val; + *ssid = val; if (!isxdigit((*str)[0])) /* We require at least one hex digit */ goto confused; val = simple_strtoul(*str, str, 16); @@ -126,7 +128,7 @@ confused: static inline int blacklist_parse_parameters (char *str, range_action action) { - unsigned int from, to, from_id0, to_id0, from_id1, to_id1; + unsigned int from, to, from_id0, to_id0, from_ssid, to_ssid; while (*str != 0 && *str != '\n') { range_action ra = action; @@ -143,23 +145,25 @@ blacklist_parse_parameters (char *str, range_action action) */ if (strncmp(str,"all,",4) == 0 || strcmp(str,"all") == 0 || strncmp(str,"all\n",4) == 0 || strncmp(str,"all ",4) == 0) { - from = 0; - to = __MAX_SUBCHANNEL; + int j; + str += 3; + for (j=0; j <= __MAX_SSID; j++) + blacklist_range(ra, 0, __MAX_SUBCHANNEL, j); } else { int rc; rc = blacklist_busid(&str, &from_id0, - &from_id1, &from); + &from_ssid, &from); if (rc) continue; to = from; to_id0 = from_id0; - to_id1 = from_id1; + to_ssid = from_ssid; if (*str == '-') { str++; rc = blacklist_busid(&str, &to_id0, - &to_id1, &to); + &to_ssid, &to); if (rc) continue; } @@ -169,18 +173,19 @@ blacklist_parse_parameters (char *str, range_action action) strsep(&str, ",\n")); continue; } - if ((from_id0 != to_id0) || (from_id1 != to_id1)) { + if ((from_id0 != to_id0) || + (from_ssid != to_ssid)) { printk(KERN_WARNING "invalid cio_ignore range " "%x.%x.%04x-%x.%x.%04x\n", - from_id0, from_id1, from, - to_id0, to_id1, to); + from_id0, from_ssid, from, + to_id0, to_ssid, to); continue; } + pr_debug("blacklist_setup: adding range " + "from %x.%x.%04x to %x.%x.%04x\n", + from_id0, from_ssid, from, to_id0, to_ssid, to); + blacklist_range (ra, from, to, to_ssid); } - /* FIXME: ignoring id0 and id1 here. */ - pr_debug("blacklist_setup: adding range " - "from 0.0.%04x to 0.0.%04x\n", from, to); - blacklist_range (ra, from, to); } return 1; } @@ -214,9 +219,9 @@ __setup ("cio_ignore=", blacklist_setup); * Used by validate_subchannel() */ int -is_blacklisted (int devno) +is_blacklisted (int ssid, int devno) { - return test_bit (devno, bl_dev); + return test_bit (devno, bl_dev[ssid]); } #ifdef CONFIG_PROC_FS @@ -283,6 +288,7 @@ blacklist_parse_proc_parameters (char *buf) /* Iterator struct for all devices. */ struct ccwdev_iter { int devno; + int ssid; int in_range; }; @@ -291,13 +297,14 @@ cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset) { struct ccwdev_iter *iter; - if (*offset > __MAX_SUBCHANNEL) + if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1)) return NULL; iter = kmalloc(sizeof(struct ccwdev_iter), GFP_KERNEL); if (!iter) return ERR_PTR(-ENOMEM); memset(iter, 0, sizeof(struct ccwdev_iter)); - iter->devno = *offset; + iter->ssid = *offset / (__MAX_SUBCHANNEL + 1); + iter->devno = *offset % (__MAX_SUBCHANNEL + 1); return iter; } @@ -313,10 +320,16 @@ cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset) { struct ccwdev_iter *iter; - if (*offset > __MAX_SUBCHANNEL) + if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1)) return NULL; iter = (struct ccwdev_iter *)it; - iter->devno++; + if (iter->devno == __MAX_SUBCHANNEL) { + iter->devno = 0; + iter->ssid++; + if (iter->ssid > __MAX_SSID) + return NULL; + } else + iter->devno++; (*offset)++; return iter; } @@ -327,23 +340,24 @@ cio_ignore_proc_seq_show(struct seq_file *s, void *it) struct ccwdev_iter *iter; iter = (struct ccwdev_iter *)it; - if (!is_blacklisted(iter->devno)) + if (!is_blacklisted(iter->ssid, iter->devno)) /* Not blacklisted, nothing to output. */ return 0; if (!iter->in_range) { /* First device in range. */ if ((iter->devno == __MAX_SUBCHANNEL) || - !is_blacklisted(iter->devno + 1)) + !is_blacklisted(iter->ssid, iter->devno + 1)) /* Singular device. */ - return seq_printf(s, "0.0.%04x\n", iter->devno); + return seq_printf(s, "0.%x.%04x\n", + iter->ssid, iter->devno); iter->in_range = 1; - return seq_printf(s, "0.0.%04x-", iter->devno); + return seq_printf(s, "0.%x.%04x-", iter->ssid, iter->devno); } if ((iter->devno == __MAX_SUBCHANNEL) || - !is_blacklisted(iter->devno + 1)) { + !is_blacklisted(iter->ssid, iter->devno + 1)) { /* Last device in range. */ iter->in_range = 0; - return seq_printf(s, "0.0.%04x\n", iter->devno); + return seq_printf(s, "0.%x.%04x\n", iter->ssid, iter->devno); } return 0; } diff --git a/drivers/s390/cio/blacklist.h b/drivers/s390/cio/blacklist.h index fb42caf..95e25c1 100644 --- a/drivers/s390/cio/blacklist.h +++ b/drivers/s390/cio/blacklist.h @@ -1,6 +1,6 @@ #ifndef S390_BLACKLIST_H #define S390_BLACKLIST_H -extern int is_blacklisted (int devno); +extern int is_blacklisted (int ssid, int devno); #endif diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c index ebd9249..7270808 100644 --- a/drivers/s390/cio/chsc.c +++ b/drivers/s390/cio/chsc.c @@ -1,7 +1,7 @@ /* * drivers/s390/cio/chsc.c * S/390 common I/O routines -- channel subsystem call - * $Revision: 1.120 $ + * $Revision: 1.126 $ * * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, * IBM Corporation @@ -75,7 +75,9 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page) struct { struct chsc_header request; - u16 reserved1; + u16 reserved1a:10; + u16 ssid:2; + u16 reserved1b:4; u16 f_sch; /* first subchannel */ u16 reserved2; u16 l_sch; /* last subchannel */ @@ -102,6 +104,7 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page) .code = 0x0004, }; + ssd_area->ssid = sch->schid.ssid; ssd_area->f_sch = sch->schid.sch_no; ssd_area->l_sch = sch->schid.sch_no; @@ -145,8 +148,8 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page) */ if (ssd_area->st > 3) { /* uhm, that looks strange... */ CIO_CRW_EVENT(0, "Strange subchannel type %d" - " for sch %04x\n", ssd_area->st, - sch->schid.sch_no); + " for sch 0.%x.%04x\n", ssd_area->st, + sch->schid.ssid, sch->schid.sch_no); /* * There may have been a new subchannel type defined in the * time since this code was written; since we don't know which @@ -155,8 +158,9 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page) return 0; } else { const char *type[4] = {"I/O", "chsc", "message", "ADM"}; - CIO_CRW_EVENT(6, "ssd: sch %04x is %s subchannel\n", - sch->schid.sch_no, type[ssd_area->st]); + CIO_CRW_EVENT(6, "ssd: sch 0.%x.%04x is %s subchannel\n", + sch->schid.ssid, sch->schid.sch_no, + type[ssd_area->st]); sch->ssd_info.valid = 1; sch->ssd_info.type = ssd_area->st; @@ -364,7 +368,7 @@ s390_process_res_acc_new_sch(struct subchannel_id schid) * that beast may be on we'll have to do a stsch * on all devices, grr... */ - if (stsch(schid, &schib)) + if (stsch_err(schid, &schib)) /* We're through */ return need_rescan ? -EAGAIN : -ENXIO; @@ -818,7 +822,7 @@ __s390_vary_chpid_on(struct subchannel_id schid, void *data) put_device(&sch->dev); return 0; } - if (stsch(schid, &schib)) + if (stsch_err(schid, &schib)) /* We're through */ return -ENXIO; /* Put it on the slow path. */ @@ -1078,6 +1082,54 @@ chsc_alloc_sei_area(void) return (sei_page ? 0 : -ENOMEM); } +int __init +chsc_enable_facility(int operation_code) +{ + int ret; + struct { + struct chsc_header request; + u8 reserved1:4; + u8 format:4; + u8 reserved2; + u16 operation_code; + u32 reserved3; + u32 reserved4; + u32 operation_data_area[252]; + struct chsc_header response; + u32 reserved5:4; + u32 format2:4; + u32 reserved6:24; + } *sda_area; + + sda_area = (void *)get_zeroed_page(GFP_KERNEL|GFP_DMA); + if (!sda_area) + return -ENOMEM; + sda_area->request = (struct chsc_header) { + .length = 0x0400, + .code = 0x0031, + }; + sda_area->operation_code = operation_code; + + ret = chsc(sda_area); + if (ret > 0) { + ret = (ret == 3) ? -ENODEV : -EBUSY; + goto out; + } + switch (sda_area->response.code) { + case 0x0003: /* invalid request block */ + case 0x0007: + ret = -EINVAL; + break; + case 0x0004: /* command not provided */ + case 0x0101: /* facility not provided */ + ret = -EOPNOTSUPP; + break; + } + out: + free_page((unsigned long)sda_area); + return ret; +} + subsys_initcall(chsc_alloc_sei_area); struct css_general_char css_general_characteristics; diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h index 170083c..44e4b4b 100644 --- a/drivers/s390/cio/chsc.h +++ b/drivers/s390/cio/chsc.h @@ -5,6 +5,8 @@ #define CHSC_SEI_ACC_LINKADDR 2 #define CHSC_SEI_ACC_FULLLINKADDR 3 +#define CHSC_SDA_OC_MSS 0x2 + struct chsc_header { u16 length; u16 code; @@ -64,6 +66,8 @@ extern int css_characteristics_avail; extern void *chsc_get_chp_desc(struct subchannel*, int); +extern int chsc_enable_facility(int); + #define to_channelpath(dev) container_of(dev, struct channel_path, dev) #endif diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 3eb6cb6..6f274f4 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c @@ -1,7 +1,7 @@ /* * drivers/s390/cio/cio.c * S/390 common I/O routines -- low level i/o calls - * $Revision: 1.135 $ + * $Revision: 1.138 $ * * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, * IBM Corporation @@ -166,7 +166,8 @@ cio_start_handle_notoper(struct subchannel *sch, __u8 lpm) stsch (sch->schid, &sch->schib); CIO_MSG_EVENT(0, "cio_start: 'not oper' status for " - "subchannel %04x!\n", sch->schid.sch_no); + "subchannel 0.%x.%04x!\n", sch->schid.ssid, + sch->schid.sch_no); sprintf(dbf_text, "no%s", sch->dev.bus_id); CIO_TRACE_EVENT(0, dbf_text); CIO_HEX_EVENT(0, &sch->schib, sizeof (struct schib)); @@ -522,15 +523,18 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid) spin_lock_init(&sch->lock); /* Set a name for the subchannel */ - snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", schid.sch_no); + snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", schid.ssid, + schid.sch_no); /* * The first subchannel that is not-operational (ccode==3) * indicates that there aren't any more devices available. + * If stsch gets an exception, it means the current subchannel set + * is not valid. */ - ccode = stsch (schid, &sch->schib); + ccode = stsch_err (schid, &sch->schib); if (ccode) - return -ENXIO; + return (ccode == 3) ? -ENXIO : ccode; sch->schid = schid; /* Copy subchannel type from path management control word. */ @@ -541,9 +545,9 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid) */ if (sch->st != 0) { CIO_DEBUG(KERN_INFO, 0, - "Subchannel %04X reports " + "Subchannel 0.%x.%04x reports " "non-I/O subchannel type %04X\n", - sch->schid.sch_no, sch->st); + sch->schid.ssid, sch->schid.sch_no, sch->st); /* We stop here for non-io subchannels. */ return sch->st; } @@ -554,26 +558,29 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid) return -ENODEV; /* Devno is valid. */ - if (is_blacklisted (sch->schib.pmcw.dev)) { + if (is_blacklisted (sch->schid.ssid, sch->schib.pmcw.dev)) { /* * This device must not be known to Linux. So we simply * say that there is no device and return ENODEV. */ CIO_MSG_EVENT(0, "Blacklisted device detected " - "at devno %04X\n", sch->schib.pmcw.dev); + "at devno %04X, subchannel set %x\n", + sch->schib.pmcw.dev, sch->schid.ssid); return -ENODEV; } sch->opm = 0xff; - chsc_validate_chpids(sch); + if (!cio_is_console(sch->schid)) + chsc_validate_chpids(sch); sch->lpm = sch->schib.pmcw.pim & sch->schib.pmcw.pam & sch->schib.pmcw.pom & sch->opm; CIO_DEBUG(KERN_INFO, 0, - "Detected device %04X on subchannel %04X" + "Detected device %04x on subchannel 0.%x.%04X" " - PIM = %02X, PAM = %02X, POM = %02X\n", - sch->schib.pmcw.dev, sch->schid.sch_no, sch->schib.pmcw.pim, + sch->schib.pmcw.dev, sch->schid.ssid, + sch->schid.sch_no, sch->schib.pmcw.pim, sch->schib.pmcw.pam, sch->schib.pmcw.pom); /* @@ -693,7 +700,7 @@ wait_cons_dev (void) static int cio_test_for_console(struct subchannel_id schid, void *data) { - if (stsch(schid, &console_subchannel.schib) != 0) + if (stsch_err(schid, &console_subchannel.schib) != 0) return -ENXIO; if (console_subchannel.schib.pmcw.dnv && console_subchannel.schib.pmcw.dev == @@ -841,7 +848,7 @@ __shutdown_subchannel_easy(struct subchannel_id schid, void *data) { struct schib schib; - if (stsch(schid, &schib)) + if (stsch_err(schid, &schib)) return -ENXIO; if (!schib.pmcw.ena) return 0; diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index b6225cbb..9e9d4a1 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -1,7 +1,7 @@ /* * drivers/s390/cio/css.c * driver for channel subsystem - * $Revision: 1.85 $ + * $Revision: 1.93 $ * * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, * IBM Corporation @@ -23,6 +23,7 @@ int need_rescan = 0; int css_init_done = 0; +static int max_ssid = 0; struct channel_subsystem *css[__MAX_CSSID + 1]; @@ -37,10 +38,13 @@ for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *data) init_subchannel_id(&schid); ret = -ENODEV; do { - ret = fn(schid, data); - if (ret) - break; - } while (schid.sch_no++ < __MAX_SUBCHANNEL); + do { + ret = fn(schid, data); + if (ret) + break; + } while (schid.sch_no++ < __MAX_SUBCHANNEL); + schid.sch_no = 0; + } while (schid.ssid++ < max_ssid); return ret; } @@ -205,8 +209,8 @@ css_evaluate_subchannel(struct subchannel_id schid, int slow) return -EAGAIN; /* Will be done on the slow path. */ } event = css_get_subchannel_status(sch, schid); - CIO_MSG_EVENT(4, "Evaluating schid %04x, event %d, %s, %s path.\n", - schid.sch_no, event, + CIO_MSG_EVENT(4, "Evaluating schid 0.%x.%04x, event %d, %s, %s path.\n", + schid.ssid, schid.sch_no, event, sch?(disc?"disconnected":"normal"):"unknown", slow?"slow":"fast"); switch (event) { @@ -352,19 +356,23 @@ css_reiterate_subchannels(void) * Called from the machine check handler for subchannel report words. */ int -css_process_crw(int irq) +css_process_crw(int rsid1, int rsid2) { int ret; struct subchannel_id mchk_schid; - CIO_CRW_EVENT(2, "source is subchannel %04X\n", irq); + CIO_CRW_EVENT(2, "source is subchannel %04X, subsystem id %x\n", + rsid1, rsid2); if (need_rescan) /* We need to iterate all subchannels anyway. */ return -EAGAIN; init_subchannel_id(&mchk_schid); - mchk_schid.sch_no = irq; + mchk_schid.sch_no = rsid1; + if (rsid2 != 0) + mchk_schid.ssid = (rsid2 >> 8) & 3; + /* * Since we are always presented with IPI in the CRW, we have to * use stsch() to find out if the subchannel in question has come @@ -465,12 +473,23 @@ init_channel_subsystem (void) if ((ret = bus_register(&css_bus_type))) goto out; + /* Try to enable MSS. */ + ret = chsc_enable_facility(CHSC_SDA_OC_MSS); + switch (ret) { + case 0: /* Success. */ + max_ssid = __MAX_SSID; + break; + case -ENOMEM: + goto out_bus; + default: + max_ssid = 0; + } /* Setup css structure. */ for (i = 0; i <= __MAX_CSSID; i++) { css[i] = kmalloc(sizeof(struct channel_subsystem), GFP_KERNEL); if (!css[i]) { ret = -ENOMEM; - goto out_bus; + goto out_unregister; } setup_css(i); ret = device_register(&css[i]->device); @@ -485,11 +504,12 @@ init_channel_subsystem (void) return 0; out_free: kfree(css[i]); -out_bus: +out_unregister: while (i > 0) { i--; device_unregister(&css[i]->device); } +out_bus: bus_unregister(&css_bus_type); out: return ret; diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h index b74659c..251ebd7 100644 --- a/drivers/s390/cio/css.h +++ b/drivers/s390/cio/css.h @@ -77,6 +77,7 @@ struct ccw_device_private { unsigned long registered; __u16 devno; /* device number */ __u16 sch_no; /* subchannel number */ + __u8 ssid; /* subchannel set id */ __u8 imask; /* lpm mask for SNID/SID/SPGID */ int iretry; /* retry counter SNID/SID/SPGID */ struct { @@ -135,6 +136,7 @@ extern int css_init_done; extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *); #define __MAX_SUBCHANNEL 65535 +#define __MAX_SSID 3 #define __MAX_CHPID 255 #define __MAX_CSSID 0 diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c index ba9f7c1..fa3e4c0 100644 --- a/drivers/s390/cio/device.c +++ b/drivers/s390/cio/device.c @@ -535,7 +535,8 @@ ccw_device_register(struct ccw_device *cdev) } struct match_data { - unsigned int devno; + unsigned int devno; + unsigned int ssid; struct ccw_device * sibling; }; @@ -548,6 +549,7 @@ match_devno(struct device * dev, void * data) cdev = to_ccwdev(dev); if ((cdev->private->state == DEV_STATE_DISCONNECTED) && (cdev->private->devno == d->devno) && + (cdev->private->ssid == d->ssid) && (cdev != d->sibling)) { cdev->private->state = DEV_STATE_NOT_OPER; return 1; @@ -556,11 +558,13 @@ match_devno(struct device * dev, void * data) } static struct ccw_device * -get_disc_ccwdev_by_devno(unsigned int devno, struct ccw_device *sibling) +get_disc_ccwdev_by_devno(unsigned int devno, unsigned int ssid, + struct ccw_device *sibling) { struct device *dev; struct match_data data = { - .devno = devno, + .devno = devno, + .ssid = ssid, .sibling = sibling, }; @@ -616,7 +620,7 @@ ccw_device_do_unreg_rereg(void *data) need_rename = 1; other_cdev = get_disc_ccwdev_by_devno(sch->schib.pmcw.dev, - cdev); + sch->schid.ssid, cdev); if (other_cdev) { struct subchannel *other_sch; @@ -639,8 +643,8 @@ ccw_device_do_unreg_rereg(void *data) if (test_and_clear_bit(1, &cdev->private->registered)) device_del(&cdev->dev); if (need_rename) - snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", - sch->schib.pmcw.dev); + snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", + sch->schid.ssid, sch->schib.pmcw.dev); PREPARE_WORK(&cdev->private->kick_work, ccw_device_add_changed, (void *)cdev); queue_work(ccw_device_work, &cdev->private->kick_work); @@ -769,9 +773,11 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch) sch->dev.driver_data = cdev; sch->driver = &io_subchannel_driver; cdev->ccwlock = &sch->lock; + /* Init private data. */ priv = cdev->private; priv->devno = sch->schib.pmcw.dev; + priv->ssid = sch->schid.ssid; priv->sch_no = sch->schid.sch_no; priv->state = DEV_STATE_NOT_OPER; INIT_LIST_HEAD(&priv->cmb_list); @@ -779,8 +785,8 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch) init_timer(&priv->timer); /* Set an initial name for the device. */ - snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", - sch->schib.pmcw.dev); + snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", + sch->schid.ssid, sch->schib.pmcw.dev); /* Increase counter of devices currently in recognition. */ atomic_inc(&ccw_device_init_count); diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c index 9efeae7..23d12b6 100644 --- a/drivers/s390/cio/device_fsm.c +++ b/drivers/s390/cio/device_fsm.c @@ -257,8 +257,9 @@ ccw_device_recog_done(struct ccw_device *cdev, int state) switch (state) { case DEV_STATE_NOT_OPER: CIO_DEBUG(KERN_WARNING, 2, - "SenseID : unknown device %04x on subchannel %04x\n", - cdev->private->devno, sch->schid.sch_no); + "SenseID : unknown device %04x on subchannel " + "0.%x.%04x\n", cdev->private->devno, + sch->schid.ssid, sch->schid.sch_no); break; case DEV_STATE_OFFLINE: if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) { @@ -282,16 +283,18 @@ ccw_device_recog_done(struct ccw_device *cdev, int state) return; } /* Issue device info message. */ - CIO_DEBUG(KERN_INFO, 2, "SenseID : device %04x reports: " + CIO_DEBUG(KERN_INFO, 2, "SenseID : device 0.%x.%04x reports: " "CU Type/Mod = %04X/%02X, Dev Type/Mod = " - "%04X/%02X\n", cdev->private->devno, + "%04X/%02X\n", + cdev->private->ssid, cdev->private->devno, cdev->id.cu_type, cdev->id.cu_model, cdev->id.dev_type, cdev->id.dev_model); break; case DEV_STATE_BOXED: CIO_DEBUG(KERN_WARNING, 2, - "SenseID : boxed device %04x on subchannel %04x\n", - cdev->private->devno, sch->schid.sch_no); + "SenseID : boxed device %04x on subchannel " + "0.%x.%04x\n", cdev->private->devno, + sch->schid.ssid, sch->schid.sch_no); break; } cdev->private->state = state; diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c index 207881e..3c77c3f 100644 --- a/drivers/s390/cio/device_id.c +++ b/drivers/s390/cio/device_id.c @@ -256,16 +256,17 @@ ccw_device_check_sense_id(struct ccw_device *cdev) * sense id information. So, for intervention required, * we use the "whack it until it talks" strategy... */ - CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel %04x " - "reports cmd reject\n", - cdev->private->devno, sch->schid.sch_no); + CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel " + "0.%x.%04x reports cmd reject\n", + cdev->private->devno, sch->schid.ssid, + sch->schid.sch_no); return -EOPNOTSUPP; } if (irb->esw.esw0.erw.cons) { - CIO_MSG_EVENT(2, "SenseID : UC on dev %04x, " + CIO_MSG_EVENT(2, "SenseID : UC on dev 0.%x.%04x, " "lpum %02X, cnt %02d, sns :" " %02X%02X%02X%02X %02X%02X%02X%02X ...\n", - cdev->private->devno, + cdev->private->ssid, cdev->private->devno, irb->esw.esw0.sublog.lpum, irb->esw.esw0.erw.scnt, irb->ecw[0], irb->ecw[1], @@ -277,16 +278,17 @@ ccw_device_check_sense_id(struct ccw_device *cdev) if (irb->scsw.cc == 3) { if ((sch->orb.lpm & sch->schib.pmcw.pim & sch->schib.pmcw.pam) != 0) - CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x on" - " subchannel %04x is 'not operational'\n", - sch->orb.lpm, cdev->private->devno, + CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x " + "on subchannel 0.%x.%04x is " + "'not operational'\n", sch->orb.lpm, + cdev->private->devno, sch->schid.ssid, sch->schid.sch_no); return -EACCES; } /* Hmm, whatever happened, try again. */ CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on " - "subchannel %04x returns status %02X%02X\n", - cdev->private->devno, sch->schid.sch_no, + "subchannel 0.%x.%04x returns status %02X%02X\n", + cdev->private->devno, sch->schid.ssid, sch->schid.sch_no, irb->scsw.dstat, irb->scsw.cstat); return -EAGAIN; } diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c index 3c89d70..052832d 100644 --- a/drivers/s390/cio/device_pgid.c +++ b/drivers/s390/cio/device_pgid.c @@ -57,10 +57,10 @@ __ccw_device_sense_pgid_start(struct ccw_device *cdev) if (ret != -EACCES) return ret; CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " - "%04x, lpm %02X, became 'not " + "0.%x.%04x, lpm %02X, became 'not " "operational'\n", - cdev->private->devno, sch->schid.sch_no, - cdev->private->imask); + cdev->private->devno, sch->schid.ssid, + sch->schid.sch_no, cdev->private->imask); } cdev->private->imask >>= 1; @@ -106,10 +106,10 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev) return -EOPNOTSUPP; } if (irb->esw.esw0.erw.cons) { - CIO_MSG_EVENT(2, "SNID - device %04x, unit check, " + CIO_MSG_EVENT(2, "SNID - device 0.%x.%04x, unit check, " "lpum %02X, cnt %02d, sns : " "%02X%02X%02X%02X %02X%02X%02X%02X ...\n", - cdev->private->devno, + cdev->private->ssid, cdev->private->devno, irb->esw.esw0.sublog.lpum, irb->esw.esw0.erw.scnt, irb->ecw[0], irb->ecw[1], @@ -119,16 +119,17 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev) return -EAGAIN; } if (irb->scsw.cc == 3) { - CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " - "%04x, lpm %02X, became 'not operational'\n", - cdev->private->devno, sch->schid.sch_no, - sch->orb.lpm); + CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x," + " lpm %02X, became 'not operational'\n", + cdev->private->devno, sch->schid.ssid, + sch->schid.sch_no, sch->orb.lpm); return -EACCES; } if (cdev->private->pgid.inf.ps.state2 == SNID_STATE2_RESVD_ELSE) { - CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel %04x " + CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x " "is reserved by someone else\n", - cdev->private->devno, sch->schid.sch_no); + cdev->private->devno, sch->schid.ssid, + sch->schid.sch_no); return -EUSERS; } return 0; @@ -237,8 +238,9 @@ __ccw_device_do_pgid(struct ccw_device *cdev, __u8 func) sch->lpm &= ~cdev->private->imask; sch->vpm &= ~cdev->private->imask; CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " - "%04x, lpm %02X, became 'not operational'\n", - cdev->private->devno, sch->schid.sch_no, cdev->private->imask); + "0.%x.%04x, lpm %02X, became 'not operational'\n", + cdev->private->devno, sch->schid.ssid, + sch->schid.sch_no, cdev->private->imask); return ret; } @@ -260,8 +262,10 @@ __ccw_device_check_pgid(struct ccw_device *cdev) if (irb->ecw[0] & SNS0_CMD_REJECT) return -EOPNOTSUPP; /* Hmm, whatever happened, try again. */ - CIO_MSG_EVENT(2, "SPID - device %04x, unit check, cnt %02d, " + CIO_MSG_EVENT(2, "SPID - device 0.%x.%04x, unit check, " + "cnt %02d, " "sns : %02X%02X%02X%02X %02X%02X%02X%02X ...\n", + cdev->private->ssid, cdev->private->devno, irb->esw.esw0.erw.scnt, irb->ecw[0], irb->ecw[1], irb->ecw[2], irb->ecw[3], @@ -270,10 +274,10 @@ __ccw_device_check_pgid(struct ccw_device *cdev) return -EAGAIN; } if (irb->scsw.cc == 3) { - CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " - "%04x, lpm %02X, became 'not operational'\n", - cdev->private->devno, sch->schid.sch_no, - cdev->private->imask); + CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel 0.%x.%04x," + " lpm %02X, became 'not operational'\n", + cdev->private->devno, sch->schid.ssid, + sch->schid.sch_no, cdev->private->imask); return -EACCES; } return 0; diff --git a/drivers/s390/cio/device_status.c b/drivers/s390/cio/device_status.c index 929f8fb..db09c20 100644 --- a/drivers/s390/cio/device_status.c +++ b/drivers/s390/cio/device_status.c @@ -36,9 +36,10 @@ ccw_device_msg_control_check(struct ccw_device *cdev, struct irb *irb) CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check " "received" - " ... device %04X on subchannel %04X, dev_stat " + " ... device %04x on subchannel 0.%x.%04x, dev_stat " ": %02X sch_stat : %02X\n", - cdev->private->devno, cdev->private->sch_no, + cdev->private->devno, cdev->private->ssid, + cdev->private->sch_no, irb->scsw.dstat, irb->scsw.cstat); if (irb->scsw.cc != 3) { @@ -61,8 +62,9 @@ ccw_device_path_notoper(struct ccw_device *cdev) sch = to_subchannel(cdev->dev.parent); stsch (sch->schid, &sch->schib); - CIO_MSG_EVENT(0, "%s(%04x) - path(s) %02x are " - "not operational \n", __FUNCTION__, sch->schid.sch_no, + CIO_MSG_EVENT(0, "%s(0.%x.%04x) - path(s) %02x are " + "not operational \n", __FUNCTION__, + sch->schid.ssid, sch->schid.sch_no, sch->schib.pmcw.pnom); sch->lpm &= ~sch->schib.pmcw.pnom; diff --git a/drivers/s390/cio/ioasm.h b/drivers/s390/cio/ioasm.h index 66c882e..62b0e2a 100644 --- a/drivers/s390/cio/ioasm.h +++ b/drivers/s390/cio/ioasm.h @@ -38,6 +38,35 @@ static inline int stsch(struct subchannel_id schid, return ccode; } +static inline int stsch_err(struct subchannel_id schid, + volatile struct schib *addr) +{ + int ccode; + + __asm__ __volatile__( + " lhi %0,%3\n" + " lr 1,%1\n" + " stsch 0(%2)\n" + "0: ipm %0\n" + " srl %0,28\n" + "1:\n" +#ifdef CONFIG_ARCH_S390X + ".section __ex_table,\"a\"\n" + " .align 8\n" + " .quad 0b,1b\n" + ".previous" +#else + ".section __ex_table,\"a\"\n" + " .align 4\n" + " .long 0b,1b\n" + ".previous" +#endif + : "=&d" (ccode) + : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr) + : "cc", "1" ); + return ccode; +} + static inline int msch(struct subchannel_id schid, volatile struct schib *addr) { diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index 5c7001b5..035c77a 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c @@ -56,7 +56,7 @@ #include "ioasm.h" #include "chsc.h" -#define VERSION_QDIO_C "$Revision: 1.113 $" +#define VERSION_QDIO_C "$Revision: 1.114 $" /****************** MODULE PARAMETER VARIABLES ********************/ MODULE_AUTHOR("Utz Bacher "); @@ -2066,21 +2066,22 @@ qdio_timeout_handler(struct ccw_device *cdev) switch (irq_ptr->state) { case QDIO_IRQ_STATE_INACTIVE: - QDIO_PRINT_ERR("establish queues on irq %04x: timed out\n", - irq_ptr->schid.sch_no); + QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: timed out\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); QDIO_DBF_TEXT2(1,setup,"eq:timeo"); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); break; case QDIO_IRQ_STATE_CLEANUP: - QDIO_PRINT_INFO("Did not get interrupt on cleanup, irq=0x%x.\n", - irq_ptr->schid.sch_no); + QDIO_PRINT_INFO("Did not get interrupt on cleanup, " + "irq=0.%x.%x.\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); break; case QDIO_IRQ_STATE_ESTABLISHED: case QDIO_IRQ_STATE_ACTIVE: /* I/O has been terminated by common I/O layer. */ - QDIO_PRINT_INFO("Queues on irq %04x killed by cio.\n", - irq_ptr->schid.sch_no); + QDIO_PRINT_INFO("Queues on irq 0.%x.%04x killed by cio.\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); QDIO_DBF_TEXT2(1, trace, "cio:term"); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED); if (get_device(&cdev->dev)) { @@ -2273,7 +2274,9 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) unsigned char qdioac; struct { struct chsc_header request; - u16 reserved1; + u16 reserved1:10; + u16 ssid:2; + u16 fmt:4; u16 first_sch; u16 reserved2; u16 last_sch; @@ -2318,12 +2321,13 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) }; ssqd_area->first_sch = irq_ptr->schid.sch_no; ssqd_area->last_sch = irq_ptr->schid.sch_no; + ssqd_area->ssid = irq_ptr->schid.ssid; result = chsc(ssqd_area); if (result) { QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \ - "SIGAs for sch x%x.\n", - result, irq_ptr->schid.sch_no); + "SIGAs for sch 0.%x.%x.\n", result, + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || CHSC_FLAG_SIGA_OUTPUT_NECESSARY || CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ @@ -2333,8 +2337,9 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) if (ssqd_area->response.code != QDIO_CHSC_RESPONSE_CODE_OK) { QDIO_PRINT_WARN("response upon checking SIGA needs " \ - "is 0x%x. Using all SIGAs for sch x%x.\n", - ssqd_area->response.code, irq_ptr->schid.sch_no); + "is 0x%x. Using all SIGAs for sch 0.%x.%x.\n", + ssqd_area->response.code, + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || CHSC_FLAG_SIGA_OUTPUT_NECESSARY || CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ @@ -2344,8 +2349,9 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) if (!(ssqd_area->flags & CHSC_FLAG_QDIO_CAPABILITY) || !(ssqd_area->flags & CHSC_FLAG_VALIDITY) || (ssqd_area->sch != irq_ptr->schid.sch_no)) { - QDIO_PRINT_WARN("huh? problems checking out sch x%x... " \ - "using all SIGAs.\n",irq_ptr->schid.sch_no); + QDIO_PRINT_WARN("huh? problems checking out sch 0.%x.%x... " \ + "using all SIGAs.\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY | CHSC_FLAG_SIGA_OUTPUT_NECESSARY | CHSC_FLAG_SIGA_SYNC_NECESSARY; /* worst case */ @@ -2453,7 +2459,8 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero) scssc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); if (!scssc_area) { QDIO_PRINT_WARN("No memory for setting indicators on " \ - "subchannel x%x.\n", irq_ptr->schid.sch_no); + "subchannel 0.%x.%x.\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); return -ENOMEM; } scssc_area->request = (struct chsc_header) { @@ -2479,8 +2486,9 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero) result = chsc(scssc_area); if (result) { - QDIO_PRINT_WARN("could not set indicators on irq x%x, " \ - "cc=%i.\n",irq_ptr->schid.sch_no,result); + QDIO_PRINT_WARN("could not set indicators on irq 0.%x.%x, " \ + "cc=%i.\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no,result); result = -EIO; goto out; } @@ -2536,7 +2544,8 @@ tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target) scsscf_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); if (!scsscf_area) { QDIO_PRINT_WARN("No memory for setting delay target on " \ - "subchannel x%x.\n", irq_ptr->schid.sch_no); + "subchannel 0.%x.%x.\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); return -ENOMEM; } scsscf_area->request = (struct chsc_header) { @@ -2548,8 +2557,9 @@ tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target) result=chsc(scsscf_area); if (result) { - QDIO_PRINT_WARN("could not set delay target on irq x%x, " \ - "cc=%i. Continuing.\n",irq_ptr->schid.sch_no, + QDIO_PRINT_WARN("could not set delay target on irq 0.%x.%x, " \ + "cc=%i. Continuing.\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no, result); result = -EIO; goto out; @@ -2870,8 +2880,9 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat, QDIO_DBF_HEX2(0,trace,&dstat,sizeof(int)); QDIO_DBF_HEX2(0,trace,&cstat,sizeof(int)); QDIO_PRINT_ERR("received check condition on establish " \ - "queues on irq 0x%x (cs=x%x, ds=x%x).\n", - irq_ptr->schid.sch_no,cstat,dstat); + "queues on irq 0.%x.%x (cs=x%x, ds=x%x).\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no, + cstat,dstat); qdio_set_state(irq_ptr,QDIO_IRQ_STATE_ERR); } @@ -2879,9 +2890,10 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat, QDIO_DBF_TEXT2(1,setup,"eq:no de"); QDIO_DBF_HEX2(0,setup,&dstat, sizeof(dstat)); QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat)); - QDIO_PRINT_ERR("establish queues on irq %04x: didn't get " + QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: didn't get " "device end: dstat=%02x, cstat=%02x\n", - irq_ptr->schid.sch_no, dstat, cstat); + irq_ptr->schid.ssid, irq_ptr->schid.sch_no, + dstat, cstat); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); return 1; } @@ -2890,9 +2902,9 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat, QDIO_DBF_TEXT2(1,setup,"eq:badio"); QDIO_DBF_HEX2(0,setup,&dstat, sizeof(dstat)); QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat)); - QDIO_PRINT_ERR("establish queues on irq %04x: got " + QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: got " "the following devstat: dstat=%02x, " - "cstat=%02x\n", + "cstat=%02x\n", irq_ptr->schid.ssid, irq_ptr->schid.sch_no, dstat, cstat); qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); return 1; @@ -3041,7 +3053,8 @@ int qdio_fill_irq(struct qdio_initialize *init_data) QDIO_DBF_HEX1(0,setup,&irq_ptr->dev_st_chg_ind,sizeof(void*)); if (!irq_ptr->dev_st_chg_ind) { QDIO_PRINT_WARN("no indicator location available " \ - "for irq 0x%x\n",irq_ptr->schid.sch_no); + "for irq 0.%x.%x\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no); qdio_release_irq_memory(irq_ptr); return -ENOBUFS; } @@ -3198,9 +3211,10 @@ qdio_establish(struct qdio_initialize *init_data) sprintf(dbf_text,"eq:io%4x",result); QDIO_DBF_TEXT2(1,setup,dbf_text); } - QDIO_PRINT_WARN("establish queues on irq %04x: do_IO " \ - "returned %i, next try returned %i\n", - irq_ptr->schid.sch_no,result,result2); + QDIO_PRINT_WARN("establish queues on irq 0.%x.%04x: do_IO " \ + "returned %i, next try returned %i\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no, + result, result2); result=result2; if (result) ccw_device_set_timeout(cdev, 0); @@ -3298,9 +3312,10 @@ qdio_activate(struct ccw_device *cdev, int flags) sprintf(dbf_text,"aq:io%4x",result); QDIO_DBF_TEXT2(1,setup,dbf_text); } - QDIO_PRINT_WARN("activate queues on irq %04x: do_IO " \ - "returned %i, next try returned %i\n", - irq_ptr->schid.sch_no,result,result2); + QDIO_PRINT_WARN("activate queues on irq 0.%x.%04x: do_IO " \ + "returned %i, next try returned %i\n", + irq_ptr->schid.ssid, irq_ptr->schid.sch_no, + result, result2); result=result2; } diff --git a/drivers/s390/cio/schid.h b/drivers/s390/cio/schid.h index 220d978..54328fe 100644 --- a/drivers/s390/cio/schid.h +++ b/drivers/s390/cio/schid.h @@ -2,7 +2,8 @@ #define S390_SCHID_H struct subchannel_id { - __u32 reserved:15; + __u32 reserved:13; + __u32 ssid:2; __u32 one:1; __u32 sch_no:16; } __attribute__ ((packed,aligned(4))); diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c index 4191fd9..7dad597 100644 --- a/drivers/s390/s390mach.c +++ b/drivers/s390/s390mach.c @@ -23,7 +23,7 @@ static struct semaphore m_sem; -extern int css_process_crw(int); +extern int css_process_crw(int, int); extern int chsc_process_crw(void); extern int chp_process_crw(int, int); extern void css_reiterate_subchannels(void); @@ -49,9 +49,10 @@ s390_handle_damage(char *msg) static int s390_collect_crw_info(void *param) { - struct crw crw; + struct crw crw[2]; int ccode, ret, slow; struct semaphore *sem; + unsigned int chain; sem = (struct semaphore *)param; /* Set a nice name. */ @@ -59,25 +60,50 @@ s390_collect_crw_info(void *param) repeat: down_interruptible(sem); slow = 0; + chain = 0; while (1) { - ccode = stcrw(&crw); + if (unlikely(chain > 1)) { + struct crw tmp_crw; + + printk(KERN_WARNING"%s: Code does not support more " + "than two chained crws; please report to " + "linux390@de.ibm.com!\n", __FUNCTION__); + ccode = stcrw(&tmp_crw); + printk(KERN_WARNING"%s: crw reports slct=%d, oflw=%d, " + "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n", + __FUNCTION__, tmp_crw.slct, tmp_crw.oflw, + tmp_crw.chn, tmp_crw.rsc, tmp_crw.anc, + tmp_crw.erc, tmp_crw.rsid); + printk(KERN_WARNING"%s: This was crw number %x in the " + "chain\n", __FUNCTION__, chain); + if (ccode != 0) + break; + chain = tmp_crw.chn ? chain + 1 : 0; + continue; + } + ccode = stcrw(&crw[chain]); if (ccode != 0) break; DBG(KERN_DEBUG "crw_info : CRW reports slct=%d, oflw=%d, " "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n", - crw.slct, crw.oflw, crw.chn, crw.rsc, crw.anc, - crw.erc, crw.rsid); + crw[chain].slct, crw[chain].oflw, crw[chain].chn, + crw[chain].rsc, crw[chain].anc, crw[chain].erc, + crw[chain].rsid); /* Check for overflows. */ - if (crw.oflw) { + if (crw[chain].oflw) { pr_debug("%s: crw overflow detected!\n", __FUNCTION__); css_reiterate_subchannels(); + chain = 0; slow = 1; continue; } - switch (crw.rsc) { + switch (crw[chain].rsc) { case CRW_RSC_SCH: - pr_debug("source is subchannel %04X\n", crw.rsid); - ret = css_process_crw (crw.rsid); + if (crw[0].chn && !chain) + break; + pr_debug("source is subchannel %04X\n", crw[0].rsid); + ret = css_process_crw (crw[0].rsid, + chain ? crw[1].rsid : 0); if (ret == -EAGAIN) slow = 1; break; @@ -85,18 +111,18 @@ repeat: pr_debug("source is monitoring facility\n"); break; case CRW_RSC_CPATH: - pr_debug("source is channel path %02X\n", crw.rsid); - switch (crw.erc) { + pr_debug("source is channel path %02X\n", crw[0].rsid); + switch (crw[0].erc) { case CRW_ERC_IPARM: /* Path has come. */ - ret = chp_process_crw(crw.rsid, 1); + ret = chp_process_crw(crw[0].rsid, 1); break; case CRW_ERC_PERRI: /* Path has gone. */ case CRW_ERC_PERRN: - ret = chp_process_crw(crw.rsid, 0); + ret = chp_process_crw(crw[0].rsid, 0); break; default: pr_debug("Don't know how to handle erc=%x\n", - crw.erc); + crw[0].erc); ret = 0; } if (ret == -EAGAIN) @@ -115,6 +141,8 @@ repeat: pr_debug("unknown source\n"); break; } + /* chain is always 0 or 1 here. */ + chain = crw[chain].chn ? chain + 1 : 0; } if (slow) queue_work(slow_path_wq, &slow_path_work); -- cgit v1.1 From 88fbf18399bde8f2900cf932acd40733dfa1effa Mon Sep 17 00:00:00 2001 From: Eric Rossman Date: Fri, 6 Jan 2006 00:19:25 -0800 Subject: [PATCH] s390: add support for cex2a crypto cards Signed-off-by: Eric Rossman Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/crypto/z90common.h | 9 +- drivers/s390/crypto/z90crypt.h | 13 +- drivers/s390/crypto/z90hardware.c | 301 +++++++++++++++++++++++++++++++++++++- drivers/s390/crypto/z90main.c | 111 +++++++++----- 4 files changed, 383 insertions(+), 51 deletions(-) diff --git a/drivers/s390/crypto/z90common.h b/drivers/s390/crypto/z90common.h index e319e78..f87c785 100644 --- a/drivers/s390/crypto/z90common.h +++ b/drivers/s390/crypto/z90common.h @@ -1,9 +1,9 @@ /* * linux/drivers/s390/crypto/z90common.h * - * z90crypt 1.3.2 + * z90crypt 1.3.3 * - * Copyright (C) 2001, 2004 IBM Corporation + * Copyright (C) 2001, 2005 IBM Corporation * Author(s): Robert Burroughs (burrough@us.ibm.com) * Eric Rossman (edrossma@us.ibm.com) * @@ -91,12 +91,13 @@ enum hdstat { #define TSQ_FATAL_ERROR 34 #define RSQ_FATAL_ERROR 35 -#define Z90CRYPT_NUM_TYPES 5 +#define Z90CRYPT_NUM_TYPES 6 #define PCICA 0 #define PCICC 1 #define PCIXCC_MCL2 2 #define PCIXCC_MCL3 3 #define CEX2C 4 +#define CEX2A 5 #define NILDEV -1 #define ANYDEV -1 #define PCIXCC_UNK -2 @@ -105,7 +106,7 @@ enum hdevice_type { PCICC_HW = 3, PCICA_HW = 4, PCIXCC_HW = 5, - OTHER_HW = 6, + CEX2A_HW = 6, CEX2C_HW = 7 }; diff --git a/drivers/s390/crypto/z90crypt.h b/drivers/s390/crypto/z90crypt.h index 0a3bb5a..3a18443 100644 --- a/drivers/s390/crypto/z90crypt.h +++ b/drivers/s390/crypto/z90crypt.h @@ -1,9 +1,9 @@ /* * linux/drivers/s390/crypto/z90crypt.h * - * z90crypt 1.3.2 + * z90crypt 1.3.3 * - * Copyright (C) 2001, 2004 IBM Corporation + * Copyright (C) 2001, 2005 IBM Corporation * Author(s): Robert Burroughs (burrough@us.ibm.com) * Eric Rossman (edrossma@us.ibm.com) * @@ -29,11 +29,11 @@ #include -#define VERSION_Z90CRYPT_H "$Revision: 1.11 $" +#define VERSION_Z90CRYPT_H "$Revision: 1.2.2.4 $" #define z90crypt_VERSION 1 #define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards -#define z90crypt_VARIANT 2 // 2 = added PCIXCC MCL3 and CEX2C support +#define z90crypt_VARIANT 3 // 3 = CEX2A support /** * struct ica_rsa_modexpo @@ -122,6 +122,9 @@ struct ica_rsa_modexpo_crt { * Z90STAT_CEX2CCOUNT * Return an integer count of all CEX2Cs. * + * Z90STAT_CEX2ACOUNT + * Return an integer count of all CEX2As. + * * Z90STAT_REQUESTQ_COUNT * Return an integer count of the number of entries waiting to be * sent to a device. @@ -144,6 +147,7 @@ struct ica_rsa_modexpo_crt { * 0x03: PCIXCC_MCL2 * 0x04: PCIXCC_MCL3 * 0x05: CEX2C + * 0x06: CEX2A * 0x0d: device is disabled via the proc filesystem * * Z90STAT_QDEPTH_MASK @@ -199,6 +203,7 @@ struct ica_rsa_modexpo_crt { #define Z90STAT_PCIXCCMCL2COUNT _IOR(Z90_IOCTL_MAGIC, 0x4b, int) #define Z90STAT_PCIXCCMCL3COUNT _IOR(Z90_IOCTL_MAGIC, 0x4c, int) #define Z90STAT_CEX2CCOUNT _IOR(Z90_IOCTL_MAGIC, 0x4d, int) +#define Z90STAT_CEX2ACOUNT _IOR(Z90_IOCTL_MAGIC, 0x4e, int) #define Z90STAT_REQUESTQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x44, int) #define Z90STAT_PENDINGQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x45, int) #define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int) diff --git a/drivers/s390/crypto/z90hardware.c b/drivers/s390/crypto/z90hardware.c index c215e08..7c3ed52 100644 --- a/drivers/s390/crypto/z90hardware.c +++ b/drivers/s390/crypto/z90hardware.c @@ -1,9 +1,9 @@ /* * linux/drivers/s390/crypto/z90hardware.c * - * z90crypt 1.3.2 + * z90crypt 1.3.3 * - * Copyright (C) 2001, 2004 IBM Corporation + * Copyright (C) 2001, 2005 IBM Corporation * Author(s): Robert Burroughs (burrough@us.ibm.com) * Eric Rossman (edrossma@us.ibm.com) * @@ -648,6 +648,87 @@ static struct cca_public_sec static_cca_pub_sec = { #define RESPONSE_CPRB_SIZE 0x000006B8 #define RESPONSE_CPRBX_SIZE 0x00000724 +struct type50_hdr { + u8 reserved1; + u8 msg_type_code; + u16 msg_len; + u8 reserved2; + u8 ignored; + u16 reserved3; +}; + +#define TYPE50_TYPE_CODE 0x50 + +#define TYPE50_MEB1_LEN (sizeof(struct type50_meb1_msg)) +#define TYPE50_MEB2_LEN (sizeof(struct type50_meb2_msg)) +#define TYPE50_CRB1_LEN (sizeof(struct type50_crb1_msg)) +#define TYPE50_CRB2_LEN (sizeof(struct type50_crb2_msg)) + +#define TYPE50_MEB1_FMT 0x0001 +#define TYPE50_MEB2_FMT 0x0002 +#define TYPE50_CRB1_FMT 0x0011 +#define TYPE50_CRB2_FMT 0x0012 + +struct type50_meb1_msg { + struct type50_hdr header; + u16 keyblock_type; + u8 reserved[6]; + u8 exponent[128]; + u8 modulus[128]; + u8 message[128]; +}; + +struct type50_meb2_msg { + struct type50_hdr header; + u16 keyblock_type; + u8 reserved[6]; + u8 exponent[256]; + u8 modulus[256]; + u8 message[256]; +}; + +struct type50_crb1_msg { + struct type50_hdr header; + u16 keyblock_type; + u8 reserved[6]; + u8 p[64]; + u8 q[64]; + u8 dp[64]; + u8 dq[64]; + u8 u[64]; + u8 message[128]; +}; + +struct type50_crb2_msg { + struct type50_hdr header; + u16 keyblock_type; + u8 reserved[6]; + u8 p[128]; + u8 q[128]; + u8 dp[128]; + u8 dq[128]; + u8 u[128]; + u8 message[256]; +}; + +union type50_msg { + struct type50_meb1_msg meb1; + struct type50_meb2_msg meb2; + struct type50_crb1_msg crb1; + struct type50_crb2_msg crb2; +}; + +struct type80_hdr { + u8 reserved1; + u8 type; + u16 len; + u8 code; + u8 reserved2[3]; + u8 reserved3[8]; +}; + +#define TYPE80_RSP_CODE 0x80 + struct error_hdr { unsigned char reserved1; unsigned char type; @@ -657,6 +738,7 @@ struct error_hdr { }; #define TYPE82_RSP_CODE 0x82 +#define TYPE88_RSP_CODE 0x88 #define REP82_ERROR_MACHINE_FAILURE 0x10 #define REP82_ERROR_PREEMPT_FAILURE 0x12 @@ -679,6 +761,22 @@ struct error_hdr { #define REP82_ERROR_PACKET_TRUNCATED 0xA0 #define REP82_ERROR_ZERO_BUFFER_LEN 0xB0 +#define REP88_ERROR_MODULE_FAILURE 0x10 +#define REP88_ERROR_MODULE_TIMEOUT 0x11 +#define REP88_ERROR_MODULE_NOTINIT 0x13 +#define REP88_ERROR_MODULE_NOTAVAIL 0x14 +#define REP88_ERROR_MODULE_DISABLED 0x15 +#define REP88_ERROR_MODULE_IN_DIAGN 0x17 +#define REP88_ERROR_FASTPATH_DISABLD 0x19 +#define REP88_ERROR_MESSAGE_TYPE 0x20 +#define REP88_ERROR_MESSAGE_MALFORMD 0x22 +#define REP88_ERROR_MESSAGE_LENGTH 0x23 +#define REP88_ERROR_RESERVED_FIELD 0x24 +#define REP88_ERROR_KEY_TYPE 0x34 +#define REP88_ERROR_INVALID_KEY 0x82 +#define REP88_ERROR_OPERAND 0x84 +#define REP88_ERROR_OPERAND_EVEN_MOD 0x85 + #define CALLER_HEADER 12 static inline int @@ -1029,10 +1127,6 @@ query_online(int deviceNr, int cdx, int resetNr, int *q_depth, int *dev_type) stat = HD_ONLINE; *q_depth = t_depth + 1; switch (t_dev_type) { - case OTHER_HW: - stat = HD_NOT_THERE; - *dev_type = NILDEV; - break; case PCICA_HW: *dev_type = PCICA; break; @@ -1045,6 +1139,9 @@ query_online(int deviceNr, int cdx, int resetNr, int *q_depth, int *dev_type) case CEX2C_HW: *dev_type = CEX2C; break; + case CEX2A_HW: + *dev_type = CEX2A; + break; default: *dev_type = NILDEV; break; @@ -2029,6 +2126,177 @@ ICACRT_msg_to_type6CRT_msgX(struct ica_rsa_modexpo_crt *icaMsg_p, int cdx, return 0; } +static int +ICAMEX_msg_to_type50MEX_msg(struct ica_rsa_modexpo *icaMex_p, int *z90cMsg_l_p, + union type50_msg *z90cMsg_p) +{ + int mod_len, msg_size, mod_tgt_len, exp_tgt_len, inp_tgt_len; + unsigned char *mod_tgt, *exp_tgt, *inp_tgt; + union type50_msg *tmp_type50_msg; + + mod_len = icaMex_p->inputdatalength; + + msg_size = ((mod_len <= 128) ? TYPE50_MEB1_LEN : TYPE50_MEB2_LEN) + + CALLER_HEADER; + + memset(z90cMsg_p, 0, msg_size); + + tmp_type50_msg = (union type50_msg *) + ((unsigned char *) z90cMsg_p + CALLER_HEADER); + + tmp_type50_msg->meb1.header.msg_type_code = TYPE50_TYPE_CODE; + + if (mod_len <= 128) { + tmp_type50_msg->meb1.header.msg_len = TYPE50_MEB1_LEN; + tmp_type50_msg->meb1.keyblock_type = TYPE50_MEB1_FMT; + mod_tgt = tmp_type50_msg->meb1.modulus; + mod_tgt_len = sizeof(tmp_type50_msg->meb1.modulus); + exp_tgt = tmp_type50_msg->meb1.exponent; + exp_tgt_len = sizeof(tmp_type50_msg->meb1.exponent); + inp_tgt = tmp_type50_msg->meb1.message; + inp_tgt_len = sizeof(tmp_type50_msg->meb1.message); + } else { + tmp_type50_msg->meb2.header.msg_len = TYPE50_MEB2_LEN; + tmp_type50_msg->meb2.keyblock_type = TYPE50_MEB2_FMT; + mod_tgt = tmp_type50_msg->meb2.modulus; + mod_tgt_len = sizeof(tmp_type50_msg->meb2.modulus); + exp_tgt = tmp_type50_msg->meb2.exponent; + exp_tgt_len = sizeof(tmp_type50_msg->meb2.exponent); + inp_tgt = tmp_type50_msg->meb2.message; + inp_tgt_len = sizeof(tmp_type50_msg->meb2.message); + } + + mod_tgt += (mod_tgt_len - mod_len); + if (copy_from_user(mod_tgt, icaMex_p->n_modulus, mod_len)) + return SEN_RELEASED; + if (is_empty(mod_tgt, mod_len)) + return SEN_USER_ERROR; + exp_tgt += (exp_tgt_len - mod_len); + if (copy_from_user(exp_tgt, icaMex_p->b_key, mod_len)) + return SEN_RELEASED; + if (is_empty(exp_tgt, mod_len)) + return SEN_USER_ERROR; + inp_tgt += (inp_tgt_len - mod_len); + if (copy_from_user(inp_tgt, icaMex_p->inputdata, mod_len)) + return SEN_RELEASED; + if (is_empty(inp_tgt, mod_len)) + return SEN_USER_ERROR; + + *z90cMsg_l_p = msg_size - CALLER_HEADER; + + return 0; +} + +static int +ICACRT_msg_to_type50CRT_msg(struct ica_rsa_modexpo_crt *icaMsg_p, + int *z90cMsg_l_p, union type50_msg *z90cMsg_p) +{ + int mod_len, short_len, long_len, tmp_size, p_tgt_len, q_tgt_len, + dp_tgt_len, dq_tgt_len, u_tgt_len, inp_tgt_len, long_offset; + unsigned char *p_tgt, *q_tgt, *dp_tgt, *dq_tgt, *u_tgt, *inp_tgt, + temp[8]; + union type50_msg *tmp_type50_msg; + + mod_len = icaMsg_p->inputdatalength; + short_len = mod_len / 2; + long_len = mod_len / 2 + 8; + long_offset = 0; + + if (long_len > 128) { + memset(temp, 0x00, sizeof(temp)); + if (copy_from_user(temp, icaMsg_p->np_prime, long_len-128)) + return SEN_RELEASED; + if (!is_empty(temp, 8)) + return SEN_NOT_AVAIL; + if (copy_from_user(temp, icaMsg_p->bp_key, long_len-128)) + return SEN_RELEASED; + if (!is_empty(temp, 8)) + return SEN_NOT_AVAIL; + if (copy_from_user(temp, icaMsg_p->u_mult_inv, long_len-128)) + return SEN_RELEASED; + if (!is_empty(temp, 8)) + return SEN_NOT_AVAIL; + long_offset = long_len - 128; + long_len = 128; + } + + tmp_size = ((mod_len <= 128) ? TYPE50_CRB1_LEN : TYPE50_CRB2_LEN) + + CALLER_HEADER; + + memset(z90cMsg_p, 0, tmp_size); + + tmp_type50_msg = (union type50_msg *) + ((unsigned char *) z90cMsg_p + CALLER_HEADER); + + tmp_type50_msg->crb1.header.msg_type_code = TYPE50_TYPE_CODE; + if (long_len <= 64) { + tmp_type50_msg->crb1.header.msg_len = TYPE50_CRB1_LEN; + tmp_type50_msg->crb1.keyblock_type = TYPE50_CRB1_FMT; + p_tgt = tmp_type50_msg->crb1.p; + p_tgt_len = sizeof(tmp_type50_msg->crb1.p); + q_tgt = tmp_type50_msg->crb1.q; + q_tgt_len = sizeof(tmp_type50_msg->crb1.q); + dp_tgt = tmp_type50_msg->crb1.dp; + dp_tgt_len = sizeof(tmp_type50_msg->crb1.dp); + dq_tgt = tmp_type50_msg->crb1.dq; + dq_tgt_len = sizeof(tmp_type50_msg->crb1.dq); + u_tgt = tmp_type50_msg->crb1.u; + u_tgt_len = sizeof(tmp_type50_msg->crb1.u); + inp_tgt = tmp_type50_msg->crb1.message; + inp_tgt_len = sizeof(tmp_type50_msg->crb1.message); + } else { + tmp_type50_msg->crb2.header.msg_len = TYPE50_CRB2_LEN; + tmp_type50_msg->crb2.keyblock_type = TYPE50_CRB2_FMT; + p_tgt = tmp_type50_msg->crb2.p; + p_tgt_len = sizeof(tmp_type50_msg->crb2.p); + q_tgt = tmp_type50_msg->crb2.q; + q_tgt_len = sizeof(tmp_type50_msg->crb2.q); + dp_tgt = tmp_type50_msg->crb2.dp; + dp_tgt_len = sizeof(tmp_type50_msg->crb2.dp); + dq_tgt = tmp_type50_msg->crb2.dq; + dq_tgt_len = sizeof(tmp_type50_msg->crb2.dq); + u_tgt = tmp_type50_msg->crb2.u; + u_tgt_len = sizeof(tmp_type50_msg->crb2.u); + inp_tgt = tmp_type50_msg->crb2.message; + inp_tgt_len = sizeof(tmp_type50_msg->crb2.message); + } + + p_tgt += (p_tgt_len - long_len); + if (copy_from_user(p_tgt, icaMsg_p->np_prime + long_offset, long_len)) + return SEN_RELEASED; + if (is_empty(p_tgt, long_len)) + return SEN_USER_ERROR; + q_tgt += (q_tgt_len - short_len); + if (copy_from_user(q_tgt, icaMsg_p->nq_prime, short_len)) + return SEN_RELEASED; + if (is_empty(q_tgt, short_len)) + return SEN_USER_ERROR; + dp_tgt += (dp_tgt_len - long_len); + if (copy_from_user(dp_tgt, icaMsg_p->bp_key + long_offset, long_len)) + return SEN_RELEASED; + if (is_empty(dp_tgt, long_len)) + return SEN_USER_ERROR; + dq_tgt += (dq_tgt_len - short_len); + if (copy_from_user(dq_tgt, icaMsg_p->bq_key, short_len)) + return SEN_RELEASED; + if (is_empty(dq_tgt, short_len)) + return SEN_USER_ERROR; + u_tgt += (u_tgt_len - long_len); + if (copy_from_user(u_tgt, icaMsg_p->u_mult_inv + long_offset, long_len)) + return SEN_RELEASED; + if (is_empty(u_tgt, long_len)) + return SEN_USER_ERROR; + inp_tgt += (inp_tgt_len - mod_len); + if (copy_from_user(inp_tgt, icaMsg_p->inputdata, mod_len)) + return SEN_RELEASED; + if (is_empty(inp_tgt, mod_len)) + return SEN_USER_ERROR; + + *z90cMsg_l_p = tmp_size - CALLER_HEADER; + + return 0; +} + int convert_request(unsigned char *buffer, int func, unsigned short function, int cdx, int dev_type, int *msg_l_p, unsigned char *msg_p) @@ -2071,6 +2339,16 @@ convert_request(unsigned char *buffer, int func, unsigned short function, cdx, msg_l_p, (struct type6_msg *) msg_p, dev_type); } + if (dev_type == CEX2A) { + if (func == ICARSACRT) + return ICACRT_msg_to_type50CRT_msg( + (struct ica_rsa_modexpo_crt *) buffer, + msg_l_p, (union type50_msg *) msg_p); + else + return ICAMEX_msg_to_type50MEX_msg( + (struct ica_rsa_modexpo *) buffer, + msg_l_p, (union type50_msg *) msg_p); + } return 0; } @@ -2081,8 +2359,8 @@ unset_ext_bitlens(void) { if (!ext_bitlens_msg_count) { PRINTK("Unable to use coprocessors for extended bitlengths. " - "Using PCICAs (if present) for extended bitlengths. " - "This is not an error.\n"); + "Using PCICAs/CEX2As (if present) for extended " + "bitlengths. This is not an error.\n"); ext_bitlens_msg_count++; } ext_bitlens = 0; @@ -2094,6 +2372,7 @@ convert_response(unsigned char *response, unsigned char *buffer, { struct ica_rsa_modexpo *icaMsg_p = (struct ica_rsa_modexpo *) buffer; struct error_hdr *errh_p = (struct error_hdr *) response; + struct type80_hdr *t80h_p = (struct type80_hdr *) response; struct type84_hdr *t84h_p = (struct type84_hdr *) response; struct type86_fmt2_msg *t86m_p = (struct type86_fmt2_msg *) response; int reply_code, service_rc, service_rs, src_l; @@ -2108,6 +2387,7 @@ convert_response(unsigned char *response, unsigned char *buffer, src_l = 0; switch (errh_p->type) { case TYPE82_RSP_CODE: + case TYPE88_RSP_CODE: reply_code = errh_p->reply_code; src_p = (unsigned char *)errh_p; PRINTK("Hardware error: Type %02X Message Header: " @@ -2116,6 +2396,10 @@ convert_response(unsigned char *response, unsigned char *buffer, src_p[0], src_p[1], src_p[2], src_p[3], src_p[4], src_p[5], src_p[6], src_p[7]); break; + case TYPE80_RSP_CODE: + src_l = icaMsg_p->outputdatalength; + src_p = response + (int)t80h_p->len - src_l; + break; case TYPE84_RSP_CODE: src_l = icaMsg_p->outputdatalength; src_p = response + (int)t84h_p->len - src_l; @@ -2202,6 +2486,7 @@ convert_response(unsigned char *response, unsigned char *buffer, if (reply_code) switch (reply_code) { case REP82_ERROR_OPERAND_INVALID: + case REP88_ERROR_MESSAGE_MALFORMD: return REC_OPERAND_INV; case REP82_ERROR_OPERAND_SIZE: return REC_OPERAND_SIZE; diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c index 790fcbb..135ae04 100644 --- a/drivers/s390/crypto/z90main.c +++ b/drivers/s390/crypto/z90main.c @@ -228,7 +228,7 @@ struct device_x { */ struct device { int dev_type; // PCICA, PCICC, PCIXCC_MCL2, - // PCIXCC_MCL3, CEX2C + // PCIXCC_MCL3, CEX2C, CEX2A enum devstat dev_stat; // current device status int dev_self_x; // Index in array int disabled; // Set when device is in error @@ -295,26 +295,30 @@ struct caller { /** * Function prototypes from z90hardware.c */ -enum hdstat query_online(int, int, int, int *, int *); -enum devstat reset_device(int, int, int); -enum devstat send_to_AP(int, int, int, unsigned char *); -enum devstat receive_from_AP(int, int, int, unsigned char *, unsigned char *); -int convert_request(unsigned char *, int, short, int, int, int *, - unsigned char *); -int convert_response(unsigned char *, unsigned char *, int *, unsigned char *); +enum hdstat query_online(int deviceNr, int cdx, int resetNr, int *q_depth, + int *dev_type); +enum devstat reset_device(int deviceNr, int cdx, int resetNr); +enum devstat send_to_AP(int dev_nr, int cdx, int msg_len, unsigned char *msg_ext); +enum devstat receive_from_AP(int dev_nr, int cdx, int resplen, + unsigned char *resp, unsigned char *psmid); +int convert_request(unsigned char *buffer, int func, unsigned short function, + int cdx, int dev_type, int *msg_l_p, unsigned char *msg_p); +int convert_response(unsigned char *response, unsigned char *buffer, + int *respbufflen_p, unsigned char *resp_buff); /** * Low level function prototypes */ -static int create_z90crypt(int *); -static int refresh_z90crypt(int *); -static int find_crypto_devices(struct status *); -static int create_crypto_device(int); -static int destroy_crypto_device(int); +static int create_z90crypt(int *cdx_p); +static int refresh_z90crypt(int *cdx_p); +static int find_crypto_devices(struct status *deviceMask); +static int create_crypto_device(int index); +static int destroy_crypto_device(int index); static void destroy_z90crypt(void); -static int refresh_index_array(struct status *, struct device_x *); -static int probe_device_type(struct device *); -static int probe_PCIXCC_type(struct device *); +static int refresh_index_array(struct status *status_str, + struct device_x *index_array); +static int probe_device_type(struct device *devPtr); +static int probe_PCIXCC_type(struct device *devPtr); /** * proc fs definitions @@ -425,7 +429,7 @@ static struct miscdevice z90crypt_misc_device = { MODULE_AUTHOR("zSeries Linux Crypto Team: Robert H. Burroughs, Eric D. Rossman" "and Jochen Roehrig"); MODULE_DESCRIPTION("zSeries Linux Cryptographic Coprocessor device driver, " - "Copyright 2001, 2004 IBM Corporation"); + "Copyright 2001, 2005 IBM Corporation"); MODULE_LICENSE("GPL"); module_param(domain, int, 0); MODULE_PARM_DESC(domain, "domain index for device"); @@ -860,6 +864,12 @@ get_status_CEX2Ccount(void) } static inline int +get_status_CEX2Acount(void) +{ + return z90crypt.hdware_info->type_mask[CEX2A].st_count; +} + +static inline int get_status_requestq_count(void) { return requestq_count; @@ -1008,11 +1018,13 @@ static inline int select_device_type(int *dev_type_p, int bytelength) { static int count = 0; - int PCICA_avail, PCIXCC_MCL3_avail, CEX2C_avail, index_to_use; + int PCICA_avail, PCIXCC_MCL3_avail, CEX2C_avail, CEX2A_avail, + index_to_use; struct status *stat; if ((*dev_type_p != PCICC) && (*dev_type_p != PCICA) && (*dev_type_p != PCIXCC_MCL2) && (*dev_type_p != PCIXCC_MCL3) && - (*dev_type_p != CEX2C) && (*dev_type_p != ANYDEV)) + (*dev_type_p != CEX2C) && (*dev_type_p != CEX2A) && + (*dev_type_p != ANYDEV)) return -1; if (*dev_type_p != ANYDEV) { stat = &z90crypt.hdware_info->type_mask[*dev_type_p]; @@ -1022,7 +1034,13 @@ select_device_type(int *dev_type_p, int bytelength) return -1; } - /* Assumption: PCICA, PCIXCC_MCL3, and CEX2C are all similar in speed */ + /** + * Assumption: PCICA, PCIXCC_MCL3, CEX2C, and CEX2A are all similar in + * speed. + * + * PCICA and CEX2A do NOT co-exist, so it would be either one or the + * other present. + */ stat = &z90crypt.hdware_info->type_mask[PCICA]; PCICA_avail = stat->st_count - (stat->disabled_count + stat->user_disabled_count); @@ -1032,29 +1050,38 @@ select_device_type(int *dev_type_p, int bytelength) stat = &z90crypt.hdware_info->type_mask[CEX2C]; CEX2C_avail = stat->st_count - (stat->disabled_count + stat->user_disabled_count); - if (PCICA_avail || PCIXCC_MCL3_avail || CEX2C_avail) { + stat = &z90crypt.hdware_info->type_mask[CEX2A]; + CEX2A_avail = stat->st_count - + (stat->disabled_count + stat->user_disabled_count); + if (PCICA_avail || PCIXCC_MCL3_avail || CEX2C_avail || CEX2A_avail) { /** - * bitlength is a factor, PCICA is the most capable, even with - * the new MCL for PCIXCC. + * bitlength is a factor, PCICA or CEX2A are the most capable, + * even with the new MCL for PCIXCC. */ if ((bytelength < PCIXCC_MIN_MOD_SIZE) || (!ext_bitlens && (bytelength < OLD_PCIXCC_MIN_MOD_SIZE))) { - if (!PCICA_avail) - return -1; - else { + if (PCICA_avail) { *dev_type_p = PCICA; return 0; } + if (CEX2A_avail) { + *dev_type_p = CEX2A; + return 0; + } + return -1; } index_to_use = count % (PCICA_avail + PCIXCC_MCL3_avail + - CEX2C_avail); + CEX2C_avail + CEX2A_avail); if (index_to_use < PCICA_avail) *dev_type_p = PCICA; else if (index_to_use < (PCICA_avail + PCIXCC_MCL3_avail)) *dev_type_p = PCIXCC_MCL3; - else + else if (index_to_use < (PCICA_avail + PCIXCC_MCL3_avail + + CEX2C_avail)) *dev_type_p = CEX2C; + else + *dev_type_p = CEX2A; count++; return 0; } @@ -1359,7 +1386,7 @@ build_caller(struct work_element *we_p, short function) if ((we_p->devtype != PCICC) && (we_p->devtype != PCICA) && (we_p->devtype != PCIXCC_MCL2) && (we_p->devtype != PCIXCC_MCL3) && - (we_p->devtype != CEX2C)) + (we_p->devtype != CEX2C) && (we_p->devtype != CEX2A)) return SEN_NOT_AVAIL; memcpy(caller_p->caller_id, we_p->caller_id, @@ -1428,7 +1455,8 @@ get_crypto_request_buffer(struct work_element *we_p) if ((we_p->devtype != PCICA) && (we_p->devtype != PCICC) && (we_p->devtype != PCIXCC_MCL2) && (we_p->devtype != PCIXCC_MCL3) && - (we_p->devtype != CEX2C) && (we_p->devtype != ANYDEV)) { + (we_p->devtype != CEX2C) && (we_p->devtype != CEX2A) && + (we_p->devtype != ANYDEV)) { PRINTK("invalid device type\n"); return SEN_USER_ERROR; } @@ -1503,8 +1531,9 @@ get_crypto_request_buffer(struct work_element *we_p) function = PCI_FUNC_KEY_ENCRYPT; switch (we_p->devtype) { - /* PCICA does everything with a simple RSA mod-expo operation */ + /* PCICA and CEX2A do everything with a simple RSA mod-expo operation */ case PCICA: + case CEX2A: function = PCI_FUNC_KEY_ENCRYPT; break; /** @@ -1662,7 +1691,8 @@ z90crypt_rsa(struct priv_data *private_data_p, pid_t pid, * trigger a fallback to software. */ case -EINVAL: - if (we_p->devtype != PCICA) + if ((we_p->devtype != PCICA) && + (we_p->devtype != CEX2A)) rv = -EGETBUFF; break; case -ETIMEOUT: @@ -1779,6 +1809,12 @@ z90crypt_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ret = -EFAULT; break; + case Z90STAT_CEX2ACOUNT: + tempstat = get_status_CEX2Acount(); + if (copy_to_user((int __user *)arg, &tempstat, sizeof(int)) != 0) + ret = -EFAULT; + break; + case Z90STAT_REQUESTQ_COUNT: tempstat = get_status_requestq_count(); if (copy_to_user((int __user *)arg, &tempstat, sizeof(int)) != 0) @@ -2019,6 +2055,8 @@ z90crypt_status(char *resp_buff, char **start, off_t offset, get_status_PCIXCCMCL3count()); len += sprintf(resp_buff+len, "CEX2C count: %d\n", get_status_CEX2Ccount()); + len += sprintf(resp_buff+len, "CEX2A count: %d\n", + get_status_CEX2Acount()); len += sprintf(resp_buff+len, "requestq count: %d\n", get_status_requestq_count()); len += sprintf(resp_buff+len, "pendingq count: %d\n", @@ -2026,8 +2064,8 @@ z90crypt_status(char *resp_buff, char **start, off_t offset, len += sprintf(resp_buff+len, "Total open handles: %d\n\n", get_status_totalopen_count()); len += sprinthx( - "Online devices: 1: PCICA, 2: PCICC, 3: PCIXCC (MCL2), " - "4: PCIXCC (MCL3), 5: CEX2C", + "Online devices: 1=PCICA 2=PCICC 3=PCIXCC(MCL2) " + "4=PCIXCC(MCL3) 5=CEX2C 6=CEX2A", resp_buff+len, get_status_status_mask(workarea), Z90CRYPT_NUM_APS); @@ -2140,6 +2178,7 @@ z90crypt_status_write(struct file *file, const char __user *buffer, case '3': // PCIXCC_MCL2 case '4': // PCIXCC_MCL3 case '5': // CEX2C + case '6': // CEX2A j++; break; case 'd': @@ -3007,7 +3046,9 @@ create_crypto_device(int index) z90crypt.hdware_info->device_type_array[index] = 4; else if (deviceType == CEX2C) z90crypt.hdware_info->device_type_array[index] = 5; - else + else if (deviceType == CEX2A) + z90crypt.hdware_info->device_type_array[index] = 6; + else // No idea how this would happen. z90crypt.hdware_info->device_type_array[index] = -1; } -- cgit v1.1 From 3b793060e768197d525e892fd1f84dbc8767cada Mon Sep 17 00:00:00 2001 From: Cornelia Huck Date: Fri, 6 Jan 2006 00:19:26 -0800 Subject: [PATCH] s390: Fix missing release function and cosmetic changes - Use kzalloc() in blacklist.c. - Kill unwanted casts in blacklist.c. - Provide release function for struct channel_subsystem. Signed-off-by: Cornelia Huck Cc: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/cio/blacklist.c | 7 +++---- drivers/s390/cio/css.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c index 2d444cb..daf21e0 100644 --- a/drivers/s390/cio/blacklist.c +++ b/drivers/s390/cio/blacklist.c @@ -299,10 +299,9 @@ cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset) if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1)) return NULL; - iter = kmalloc(sizeof(struct ccwdev_iter), GFP_KERNEL); + iter = kzalloc(sizeof(struct ccwdev_iter), GFP_KERNEL); if (!iter) return ERR_PTR(-ENOMEM); - memset(iter, 0, sizeof(struct ccwdev_iter)); iter->ssid = *offset / (__MAX_SUBCHANNEL + 1); iter->devno = *offset % (__MAX_SUBCHANNEL + 1); return iter; @@ -322,7 +321,7 @@ cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset) if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1)) return NULL; - iter = (struct ccwdev_iter *)it; + iter = it; if (iter->devno == __MAX_SUBCHANNEL) { iter->devno = 0; iter->ssid++; @@ -339,7 +338,7 @@ cio_ignore_proc_seq_show(struct seq_file *s, void *it) { struct ccwdev_iter *iter; - iter = (struct ccwdev_iter *)it; + iter = it; if (!is_blacklisted(iter->ssid, iter->devno)) /* Not blacklisted, nothing to output. */ return 0; diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 9e9d4a1..e565193 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -444,6 +444,15 @@ css_generate_pgid(struct channel_subsystem *css, u32 tod_high) } +static void +channel_subsystem_release(struct device *dev) +{ + struct channel_subsystem *css; + + css = to_css(dev); + kfree(css); +} + static inline void __init setup_css(int nr) { @@ -453,6 +462,7 @@ setup_css(int nr) css[nr]->valid = 1; css[nr]->cssid = nr; sprintf(css[nr]->device.bus_id, "css%x", nr); + css[nr]->device.release = channel_subsystem_release; tod_high = (u32) (get_clock() >> 32); css_generate_pgid(css[nr], tod_high); } -- cgit v1.1 From 9bbc8346fb21fad3f678220b067450e436e45dbf Mon Sep 17 00:00:00 2001 From: Peter Oberparleiter Date: Fri, 6 Jan 2006 00:19:27 -0800 Subject: [PATCH] s390: fix invalid return code in sclp_cpi When the sclp_cpi module is loaded on a system which does not support the required SCLP call (e.g. on z/VM), ENOSUPP is returned to user space. The correct return value is EOPNOTSUPP. Signed-off-by: Peter Oberparleiter Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/s390/char/sclp_cpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/char/sclp_cpi.c b/drivers/s390/char/sclp_cpi.c index 5a6cef2..80f7f31 100644 --- a/drivers/s390/char/sclp_cpi.c +++ b/drivers/s390/char/sclp_cpi.c @@ -204,7 +204,7 @@ cpi_module_init(void) printk(KERN_WARNING "cpi: no control program identification " "support\n"); sclp_unregister(&sclp_cpi_event); - return -ENOTSUPP; + return -EOPNOTSUPP; } req = cpi_prepare_req(); -- cgit v1.1 From 347a8dc3b815f0c0fa62a1df075184ffe4cbdcf1 Mon Sep 17 00:00:00 2001 From: Martin Schwidefsky Date: Fri, 6 Jan 2006 00:19:28 -0800 Subject: [PATCH] s390: cleanup Kconfig Sanitize some s390 Kconfig options. We have ARCH_S390, ARCH_S390X, ARCH_S390_31, 64BIT, S390_SUPPORT and COMPAT. Replace these 6 options by S390, 64BIT and COMPAT. Signed-off-by: Martin Schwidefsky Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/Kconfig | 27 +++++++-------------------- arch/s390/Makefile | 6 ++---- arch/s390/appldata/appldata_base.c | 8 ++++---- arch/s390/crypto/crypt_s390.h | 10 +++++----- arch/s390/defconfig | 4 +--- arch/s390/kernel/Makefile | 15 +++++---------- arch/s390/kernel/cpcmd.c | 16 ++++++++-------- arch/s390/kernel/entry64.S | 18 +++++++++--------- arch/s390/kernel/head.S | 4 ++-- arch/s390/kernel/module.c | 12 ++++++------ arch/s390/kernel/process.c | 12 ++++++------ arch/s390/kernel/ptrace.c | 24 ++++++++++++------------ arch/s390/kernel/reipl_diag.c | 2 +- arch/s390/kernel/setup.c | 14 +++++++------- arch/s390/kernel/signal.c | 2 +- arch/s390/kernel/smp.c | 8 ++++---- arch/s390/kernel/sys_s390.c | 12 +++++------- arch/s390/kernel/traps.c | 10 +++++----- arch/s390/kernel/vmlinux.lds.S | 2 +- arch/s390/lib/Makefile | 5 ++--- arch/s390/lib/spinlock.c | 2 +- arch/s390/mm/extmem.c | 2 +- arch/s390/mm/fault.c | 18 +++++++++--------- arch/s390/mm/init.c | 8 ++++---- arch/s390/mm/mmap.c | 2 +- block/Kconfig | 2 +- crypto/Kconfig | 8 ++++---- drivers/char/Kconfig | 2 +- drivers/char/hangcheck-timer.c | 2 +- drivers/char/watchdog/Kconfig | 2 +- drivers/input/evdev.c | 2 +- drivers/net/phy/Kconfig | 2 +- drivers/s390/block/Kconfig | 8 ++++---- drivers/s390/block/dasd.c | 2 +- drivers/s390/block/dasd_diag.c | 2 +- drivers/s390/block/dasd_diag.h | 6 +++--- drivers/s390/block/dasd_eckd.c | 2 +- drivers/s390/block/dasd_fba.c | 2 +- drivers/s390/block/xpram.c | 4 ++-- drivers/s390/char/vmwatchdog.c | 2 +- drivers/s390/cio/cio.c | 2 +- drivers/s390/cio/device_id.c | 2 +- drivers/s390/cio/ioasm.h | 4 ++-- drivers/s390/cio/qdio.c | 2 +- drivers/s390/cio/qdio.h | 34 +++++++++++++++++----------------- drivers/s390/crypto/z90hardware.c | 8 ++++---- drivers/s390/net/Kconfig | 2 +- drivers/s390/net/claw.c | 6 +++--- drivers/s390/s390mach.c | 10 +++++----- drivers/s390/sysinfo.c | 2 +- drivers/scsi/Kconfig | 2 +- fs/partitions/Kconfig | 2 +- fs/proc/array.c | 2 +- include/asm-s390/unistd.h | 2 +- include/linux/irq.h | 2 +- init/Kconfig | 2 +- init/do_mounts_rd.c | 4 ++-- kernel/panic.c | 4 ++-- kernel/sysctl.c | 6 +++--- lib/Kconfig.debug | 2 +- 60 files changed, 183 insertions(+), 208 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 1846fbf..6fe532d 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -23,14 +23,14 @@ config GENERIC_BUST_SPINLOCK mainmenu "Linux Kernel Configuration" -config ARCH_S390 +config S390 bool default y config UID16 bool default y - depends on ARCH_S390X = 'n' + depends on !64BIT source "init/Kconfig" @@ -38,20 +38,12 @@ menu "Base setup" comment "Processor type and features" -config ARCH_S390X +config 64BIT bool "64 bit kernel" help Select this option if you have a 64 bit IBM zSeries machine and want to use the 64 bit addressing mode. -config 64BIT - def_bool ARCH_S390X - -config ARCH_S390_31 - bool - depends on ARCH_S390X = 'n' - default y - config SMP bool "Symmetric multi-processing support" ---help--- @@ -101,20 +93,15 @@ config MATHEMU on older S/390 machines. Say Y unless you know your machine doesn't need this. -config S390_SUPPORT +config COMPAT bool "Kernel support for 31 bit emulation" - depends on ARCH_S390X + depends on 64BIT help Select this option if you want to enable your system kernel to handle system-calls from ELF binaries for 31 bit ESA. This option (and some other stuff like libraries and such) is needed for executing 31 bit applications. It is safe to say "Y". -config COMPAT - bool - depends on S390_SUPPORT - default y - config SYSVIPC_COMPAT bool depends on COMPAT && SYSVIPC @@ -122,7 +109,7 @@ config SYSVIPC_COMPAT config BINFMT_ELF32 tristate "Kernel support for 31 bit ELF binaries" - depends on S390_SUPPORT + depends on COMPAT help This allows you to run 32-bit Linux/ELF binaries on your zSeries in 64 bit mode. Everybody wants this; say Y. @@ -135,7 +122,7 @@ choice config MARCH_G5 bool "S/390 model G5 and G6" - depends on ARCH_S390_31 + depends on !64BIT help Select this to build a 31 bit kernel that works on all S/390 and zSeries machines. diff --git a/arch/s390/Makefile b/arch/s390/Makefile index 73a09a6..6c6b197 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile @@ -13,16 +13,14 @@ # Copyright (C) 1994 by Linus Torvalds # -ifdef CONFIG_ARCH_S390_31 +ifndef CONFIG_64BIT LDFLAGS := -m elf_s390 CFLAGS += -m31 AFLAGS += -m31 UTS_MACHINE := s390 STACK_SIZE := 8192 CHECKFLAGS += -D__s390__ -endif - -ifdef CONFIG_ARCH_S390X +else LDFLAGS := -m elf64_s390 MODFLAGS += -fpic -D__PIC__ CFLAGS += -m64 diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c index dee6ab54..d06a8d7 100644 --- a/arch/s390/appldata/appldata_base.c +++ b/arch/s390/appldata/appldata_base.c @@ -40,7 +40,7 @@ #define TOD_MICRO 0x01000 /* nr. of TOD clock units for 1 microsecond */ -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT #define APPLDATA_START_INTERVAL_REC 0x00 /* Function codes for */ #define APPLDATA_STOP_REC 0x01 /* DIAG 0xDC */ @@ -54,13 +54,13 @@ #define APPLDATA_GEN_EVENT_RECORD 0x82 #define APPLDATA_START_CONFIG_REC 0x83 -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ /* * Parameter list for DIAGNOSE X'DC' */ -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT struct appldata_parameter_list { u16 diag; /* The DIAGNOSE code X'00DC' */ u8 function; /* The function code for the DIAGNOSE */ @@ -82,7 +82,7 @@ struct appldata_parameter_list { u64 product_id_addr; u64 buffer_addr; }; -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ /* * /proc entries (sysctl) diff --git a/arch/s390/crypto/crypt_s390.h b/arch/s390/crypto/crypt_s390.h index d6712cf..d1c259a 100644 --- a/arch/s390/crypto/crypt_s390.h +++ b/arch/s390/crypto/crypt_s390.h @@ -112,7 +112,7 @@ struct crypt_s390_query_status { * [ret] is the variable to receive the error code * [ERR] is the error code value */ -#ifndef __s390x__ +#ifndef CONFIG_64BIT #define __crypt_s390_fixup \ ".section .fixup,\"ax\" \n" \ "7: lhi %0,%h[e1] \n" \ @@ -129,7 +129,7 @@ struct crypt_s390_query_status { " .long 0b,7b \n" \ " .long 1b,8b \n" \ ".previous" -#else /* __s390x__ */ +#else /* CONFIG_64BIT */ #define __crypt_s390_fixup \ ".section .fixup,\"ax\" \n" \ "7: lhi %0,%h[e1] \n" \ @@ -142,7 +142,7 @@ struct crypt_s390_query_status { " .quad 0b,7b \n" \ " .quad 1b,8b \n" \ ".previous" -#endif /* __s390x__ */ +#endif /* CONFIG_64BIT */ /* * Standard code for setting the result of s390 crypto instructions. @@ -150,10 +150,10 @@ struct crypt_s390_query_status { * [result]: the register containing the result (e.g. second operand length * to compute number of processed bytes]. */ -#ifndef __s390x__ +#ifndef CONFIG_64BIT #define __crypt_s390_set_result \ " lr %0,%[result] \n" -#else /* __s390x__ */ +#else /* CONFIG_64BIT */ #define __crypt_s390_set_result \ " lgr %0,%[result] \n" #endif diff --git a/arch/s390/defconfig b/arch/s390/defconfig index f195c7e..7d23edc 100644 --- a/arch/s390/defconfig +++ b/arch/s390/defconfig @@ -6,7 +6,7 @@ CONFIG_MMU=y CONFIG_RWSEM_XCHGADD_ALGORITHM=y CONFIG_GENERIC_CALIBRATE_DELAY=y -CONFIG_ARCH_S390=y +CONFIG_S390=y CONFIG_UID16=y # @@ -89,9 +89,7 @@ CONFIG_DEFAULT_IOSCHED="anticipatory" # # Processor type and features # -# CONFIG_ARCH_S390X is not set # CONFIG_64BIT is not set -CONFIG_ARCH_S390_31=y CONFIG_SMP=y CONFIG_NR_CPUS=32 CONFIG_HOTPLUG_CPU=y diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile index 7434c32..4865e4b 100644 --- a/arch/s390/kernel/Makefile +++ b/arch/s390/kernel/Makefile @@ -8,31 +8,26 @@ obj-y := bitmap.o traps.o time.o process.o \ setup.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o \ semaphore.o s390_ext.o debug.o profile.o irq.o reipl_diag.o +obj-y += $(if $(CONFIG_64BIT),entry64.o,entry.o) +obj-y += $(if $(CONFIG_64BIT),reipl64.o,reipl.o) + extra-y += head.o init_task.o vmlinux.lds obj-$(CONFIG_MODULES) += s390_ksyms.o module.o obj-$(CONFIG_SMP) += smp.o -obj-$(CONFIG_S390_SUPPORT) += compat_linux.o compat_signal.o \ +obj-$(CONFIG_COMPAT) += compat_linux.o compat_signal.o \ compat_ioctl.o compat_wrapper.o \ compat_exec_domain.o obj-$(CONFIG_BINFMT_ELF32) += binfmt_elf32.o -obj-$(CONFIG_ARCH_S390_31) += entry.o reipl.o -obj-$(CONFIG_ARCH_S390X) += entry64.o reipl64.o - obj-$(CONFIG_VIRT_TIMER) += vtime.o # Kexec part S390_KEXEC_OBJS := machine_kexec.o crash.o -ifeq ($(CONFIG_ARCH_S390X),y) -S390_KEXEC_OBJS += relocate_kernel64.o -else -S390_KEXEC_OBJS += relocate_kernel.o -endif +S390_KEXEC_OBJS += $(if $(CONFIG_64BIT),relocate_kernel64.o,relocate_kernel.o) obj-$(CONFIG_KEXEC) += $(S390_KEXEC_OBJS) - # # This is just to get the dependencies... # diff --git a/arch/s390/kernel/cpcmd.c b/arch/s390/kernel/cpcmd.c index d47fecb..4ef44e5 100644 --- a/arch/s390/kernel/cpcmd.c +++ b/arch/s390/kernel/cpcmd.c @@ -39,7 +39,7 @@ int __cpcmd(const char *cmd, char *response, int rlen, int *response_code) if (response != NULL && rlen > 0) { memset(response, 0, rlen); -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT asm volatile ( "lra 2,0(%2)\n" "lr 4,%3\n" "o 4,%6\n" @@ -55,7 +55,7 @@ int __cpcmd(const char *cmd, char *response, int rlen, int *response_code) : "a" (cpcmd_buf), "d" (cmdlen), "a" (response), "d" (rlen), "m" (mask) : "cc", "2", "3", "4", "5" ); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ asm volatile ( "lrag 2,0(%2)\n" "lgr 4,%3\n" "o 4,%6\n" @@ -73,11 +73,11 @@ int __cpcmd(const char *cmd, char *response, int rlen, int *response_code) : "a" (cpcmd_buf), "d" (cmdlen), "a" (response), "d" (rlen), "m" (mask) : "cc", "2", "3", "4", "5" ); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ EBCASC(response, rlen); } else { return_len = 0; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT asm volatile ( "lra 2,0(%1)\n" "lr 3,%2\n" "diag 2,3,0x8\n" @@ -85,7 +85,7 @@ int __cpcmd(const char *cmd, char *response, int rlen, int *response_code) : "=d" (return_code) : "a" (cpcmd_buf), "d" (cmdlen) : "2", "3" ); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ asm volatile ( "lrag 2,0(%1)\n" "lgr 3,%2\n" "sam31\n" @@ -95,7 +95,7 @@ int __cpcmd(const char *cmd, char *response, int rlen, int *response_code) : "=d" (return_code) : "a" (cpcmd_buf), "d" (cmdlen) : "2", "3" ); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ } spin_unlock_irqrestore(&cpcmd_lock, flags); if (response_code != NULL) @@ -105,7 +105,7 @@ int __cpcmd(const char *cmd, char *response, int rlen, int *response_code) EXPORT_SYMBOL(__cpcmd); -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT int cpcmd(const char *cmd, char *response, int rlen, int *response_code) { char *lowbuf; @@ -129,4 +129,4 @@ int cpcmd(const char *cmd, char *response, int rlen, int *response_code) } EXPORT_SYMBOL(cpcmd); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S index 4eb71ff..369ab44 100644 --- a/arch/s390/kernel/entry64.S +++ b/arch/s390/kernel/entry64.S @@ -213,7 +213,7 @@ sysc_nr_ok: mvc SP_ARGS(8,%r15),SP_R7(%r15) sysc_do_restart: larl %r10,sys_call_table -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT tm __TI_flags+5(%r9),(_TIF_31BIT>>16) # running in 31 bit mode ? jno sysc_noemu larl %r10,sys_call_table_emu # use 31 bit emulation system calls @@ -361,7 +361,7 @@ sys_clone_glue: la %r2,SP_PTREGS(%r15) # load pt_regs jg sys_clone # branch to sys_clone -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT sys32_clone_glue: la %r2,SP_PTREGS(%r15) # load pt_regs jg sys32_clone # branch to sys32_clone @@ -383,7 +383,7 @@ sys_execve_glue: bnz 0(%r12) # it did fail -> store result in gpr2 b 6(%r12) # SKIP STG 2,SP_R2(15) in # system_call/sysc_tracesys -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT sys32_execve_glue: la %r2,SP_PTREGS(%r15) # load pt_regs lgr %r12,%r14 # save return address @@ -398,7 +398,7 @@ sys_sigreturn_glue: la %r2,SP_PTREGS(%r15) # load pt_regs as parameter jg sys_sigreturn # branch to sys_sigreturn -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT sys32_sigreturn_glue: la %r2,SP_PTREGS(%r15) # load pt_regs as parameter jg sys32_sigreturn # branch to sys32_sigreturn @@ -408,7 +408,7 @@ sys_rt_sigreturn_glue: la %r2,SP_PTREGS(%r15) # load pt_regs as parameter jg sys_rt_sigreturn # branch to sys_sigreturn -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT sys32_rt_sigreturn_glue: la %r2,SP_PTREGS(%r15) # load pt_regs as parameter jg sys32_rt_sigreturn # branch to sys32_sigreturn @@ -429,7 +429,7 @@ sys_sigsuspend_glue: la %r14,6(%r14) # skip store of return value jg sys_sigsuspend # branch to sys_sigsuspend -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT sys32_sigsuspend_glue: llgfr %r4,%r4 # unsigned long lgr %r5,%r4 # move mask back @@ -449,7 +449,7 @@ sys_rt_sigsuspend_glue: la %r14,6(%r14) # skip store of return value jg sys_rt_sigsuspend # branch to sys_rt_sigsuspend -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT sys32_rt_sigsuspend_glue: llgfr %r3,%r3 # size_t lgr %r4,%r3 # move sigsetsize parameter @@ -464,7 +464,7 @@ sys_sigaltstack_glue: la %r4,SP_PTREGS(%r15) # load pt_regs as parameter jg sys_sigaltstack # branch to sys_sigreturn -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT sys32_sigaltstack_glue: la %r4,SP_PTREGS(%r15) # load pt_regs as parameter jg sys32_sigaltstack_wrapper # branch to sys_sigreturn @@ -1009,7 +1009,7 @@ sys_call_table: #include "syscalls.S" #undef SYSCALL -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT #define SYSCALL(esa,esame,emu) .long emu .globl sys_call_table_emu diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S index d31a97c..ea88d06 100644 --- a/arch/s390/kernel/head.S +++ b/arch/s390/kernel/head.S @@ -30,7 +30,7 @@ #include #include -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT #define ARCH_OFFSET 4 #else #define ARCH_OFFSET 0 @@ -539,7 +539,7 @@ ipl_devno: .word 0 .endm -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT #include "head64.S" #else #include "head31.S" diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c index 607d506..c271cda 100644 --- a/arch/s390/kernel/module.c +++ b/arch/s390/kernel/module.c @@ -37,11 +37,11 @@ #define DEBUGP(fmt , ...) #endif -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT #define PLT_ENTRY_SIZE 12 -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ #define PLT_ENTRY_SIZE 20 -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ void *module_alloc(unsigned long size) { @@ -294,17 +294,17 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab, unsigned int *ip; ip = me->module_core + me->arch.plt_offset + info->plt_offset; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */ ip[1] = 0x100607f1; ip[2] = val; -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ ip[0] = 0x0d10e310; /* basr 1,0; lg 1,10(1); br 1 */ ip[1] = 0x100a0004; ip[2] = 0x07f10000; ip[3] = (unsigned int) (val >> 32); ip[4] = (unsigned int) val; -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ info->plt_initialized = 1; } if (r_type == R_390_PLTOFF16 || diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 78b64fe5..a942bf2 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c @@ -235,7 +235,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long new_stackp, /* Save access registers to new thread structure. */ save_access_regs(&p->thread.acrs[0]); -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT /* * save fprs to current->thread.fp_regs to merge them with * the emulated registers and then copy the result to the child. @@ -247,7 +247,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long new_stackp, /* Set a new TLS ? */ if (clone_flags & CLONE_SETTLS) p->thread.acrs[0] = regs->gprs[6]; -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ /* Save the fpu registers to new thread structure. */ save_fp_regs(&p->thread.fp_regs); p->thread.user_seg = __pa((unsigned long) p->mm->pgd) | _REGION_TABLE; @@ -260,7 +260,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long new_stackp, p->thread.acrs[1] = (unsigned int) regs->gprs[6]; } } -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ /* start new process with ar4 pointing to the correct address space */ p->thread.mm_segment = get_fs(); /* Don't copy debug registers */ @@ -339,16 +339,16 @@ out: */ int dump_fpu (struct pt_regs * regs, s390_fp_regs *fpregs) { -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT /* * save fprs to current->thread.fp_regs to merge them with * the emulated registers and then copy the result to the dump. */ save_fp_regs(¤t->thread.fp_regs); memcpy(fpregs, ¤t->thread.fp_regs, sizeof(s390_fp_regs)); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ save_fp_regs(fpregs); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ return 1; } diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index 06afa31..8ecda6d 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c @@ -42,7 +42,7 @@ #include #include -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT #include "compat_ptrace.h" #endif @@ -59,7 +59,7 @@ FixPerRegisters(struct task_struct *task) if (per_info->single_step) { per_info->control_regs.bits.starting_addr = 0; -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT if (test_thread_flag(TIF_31BIT)) per_info->control_regs.bits.ending_addr = 0x7fffffffUL; else @@ -112,7 +112,7 @@ ptrace_disable(struct task_struct *child) clear_single_step(child); } -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT # define __ADDR_MASK 3 #else # define __ADDR_MASK 7 @@ -138,7 +138,7 @@ peek_user(struct task_struct *child, addr_t addr, addr_t data) * an alignment of 4. Programmers from hell... */ mask = __ADDR_MASK; -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT if (addr >= (addr_t) &dummy->regs.acrs && addr < (addr_t) &dummy->regs.orig_gpr2) mask = 3; @@ -160,7 +160,7 @@ peek_user(struct task_struct *child, addr_t addr, addr_t data) * access registers are stored in the thread structure */ offset = addr - (addr_t) &dummy->regs.acrs; -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT /* * Very special case: old & broken 64 bit gdb reading * from acrs[15]. Result is a 64 bit value. Read the @@ -218,7 +218,7 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data) * an alignment of 4. Programmers from hell indeed... */ mask = __ADDR_MASK; -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT if (addr >= (addr_t) &dummy->regs.acrs && addr < (addr_t) &dummy->regs.orig_gpr2) mask = 3; @@ -231,13 +231,13 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data) * psw and gprs are stored on the stack */ if (addr == (addr_t) &dummy->regs.psw.mask && -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT data != PSW_MASK_MERGE(PSW_USER32_BITS, data) && #endif data != PSW_MASK_MERGE(PSW_USER_BITS, data)) /* Invalid psw mask. */ return -EINVAL; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT if (addr == (addr_t) &dummy->regs.psw.addr) /* I'd like to reject addresses without the high order bit but older gdb's rely on it */ @@ -250,7 +250,7 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data) * access registers are stored in the thread structure */ offset = addr - (addr_t) &dummy->regs.acrs; -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT /* * Very special case: old & broken 64 bit gdb writing * to acrs[15] with a 64 bit value. Ignore the lower @@ -357,7 +357,7 @@ do_ptrace_normal(struct task_struct *child, long request, long addr, long data) return ptrace_request(child, request, addr, data); } -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT /* * Now the fun part starts... a 31 bit program running in the * 31 bit emulation tracing another program. PTRACE_PEEKTEXT, @@ -629,7 +629,7 @@ do_ptrace(struct task_struct *child, long request, long addr, long data) return peek_user(child, addr, data); if (request == PTRACE_POKEUSR && addr == PT_IEEE_IP) return poke_user(child, addr, data); -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT if (request == PTRACE_PEEKUSR && addr == PT32_IEEE_IP && test_thread_flag(TIF_31BIT)) return peek_user_emu31(child, addr, data); @@ -695,7 +695,7 @@ do_ptrace(struct task_struct *child, long request, long addr, long data) /* Do requests that differ for 31/64 bit */ default: -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT if (test_thread_flag(TIF_31BIT)) return do_ptrace_emu31(child, request, addr, data); #endif diff --git a/arch/s390/kernel/reipl_diag.c b/arch/s390/kernel/reipl_diag.c index 83cb42b..1f33951 100644 --- a/arch/s390/kernel/reipl_diag.c +++ b/arch/s390/kernel/reipl_diag.c @@ -26,7 +26,7 @@ void reipl_diag(void) " st %%r4,%0\n" " st %%r5,%1\n" ".section __ex_table,\"a\"\n" -#ifdef __s390x__ +#ifdef CONFIG_64BIT " .align 8\n" " .quad 0b, 0b\n" #else diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c index 31e7b19..b03847d 100644 --- a/arch/s390/kernel/setup.c +++ b/arch/s390/kernel/setup.c @@ -427,7 +427,7 @@ setup_lowcore(void) __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0) + PAGE_SIZE; lc->current_task = (unsigned long) init_thread_union.thread_info.task; lc->thread_info = (unsigned long) &init_thread_union; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT if (MACHINE_HAS_IEEE) { lc->extended_save_area_addr = (__u32) __alloc_bootmem(PAGE_SIZE, PAGE_SIZE, 0); @@ -562,21 +562,21 @@ setup_arch(char **cmdline_p) /* * print what head.S has found out about the machine */ -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT printk((MACHINE_IS_VM) ? "We are running under VM (31 bit mode)\n" : "We are running native (31 bit mode)\n"); printk((MACHINE_HAS_IEEE) ? "This machine has an IEEE fpu\n" : "This machine has no IEEE fpu\n"); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ printk((MACHINE_IS_VM) ? "We are running under VM (64 bit mode)\n" : "We are running native (64 bit mode)\n"); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ ROOT_DEV = Root_RAM0; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT memory_end = memory_size & ~0x400000UL; /* align memory end to 4MB */ /* * We need some free virtual space to be able to do vmalloc. @@ -585,9 +585,9 @@ setup_arch(char **cmdline_p) */ if (memory_end > 1920*1024*1024) memory_end = 1920*1024*1024; -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ memory_end = memory_size & ~0x200000UL; /* detected in head.s */ -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ init_mm.start_code = PAGE_OFFSET; init_mm.end_code = (unsigned long) &_etext; diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c index 13592d0..6ae4a77 100644 --- a/arch/s390/kernel/signal.c +++ b/arch/s390/kernel/signal.c @@ -501,7 +501,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset) if (signr > 0) { /* Whee! Actually deliver the signal. */ -#ifdef CONFIG_S390_SUPPORT +#ifdef CONFIG_COMPAT if (test_thread_flag(TIF_31BIT)) { extern void handle_signal32(unsigned long sig, struct k_sigaction *ka, diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index bd5b311..e10f4ca 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -402,7 +402,7 @@ static void smp_ext_bitcall_others(ec_bit_sig sig) } } -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT /* * this function sends a 'purge tlb' signal to another CPU. */ @@ -416,7 +416,7 @@ void smp_ptlb_all(void) on_each_cpu(smp_ptlb_callback, NULL, 0, 1); } EXPORT_SYMBOL(smp_ptlb_all); -#endif /* ! CONFIG_ARCH_S390X */ +#endif /* ! CONFIG_64BIT */ /* * this function sends a 'reschedule' IPI to another CPU. @@ -783,7 +783,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) if (stack == 0ULL) panic("smp_boot_cpus failed to allocate memory\n"); lowcore_ptr[i]->panic_stack = stack + (PAGE_SIZE); -#ifndef __s390x__ +#ifndef CONFIG_64BIT if (MACHINE_HAS_IEEE) { lowcore_ptr[i]->extended_save_area_addr = (__u32) __get_free_pages(GFP_KERNEL,0); @@ -793,7 +793,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) } #endif } -#ifndef __s390x__ +#ifndef CONFIG_64BIT if (MACHINE_HAS_IEEE) ctl_set_bit(14, 29); /* enable extended save area */ #endif diff --git a/arch/s390/kernel/sys_s390.c b/arch/s390/kernel/sys_s390.c index efe6b83..6a63553 100644 --- a/arch/s390/kernel/sys_s390.c +++ b/arch/s390/kernel/sys_s390.c @@ -26,9 +26,7 @@ #include #include #include -#ifdef CONFIG_ARCH_S390X #include -#endif /* CONFIG_ARCH_S390X */ #include #include @@ -121,7 +119,7 @@ out: return error; } -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT struct sel_arg_struct { unsigned long n; fd_set *inp, *outp, *exp; @@ -138,7 +136,7 @@ asmlinkage long old_select(struct sel_arg_struct __user *arg) return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp); } -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ /* * sys_ipc() is the de-multiplexer for the SysV IPC calls.. @@ -211,7 +209,7 @@ asmlinkage long sys_ipc(uint call, int first, unsigned long second, return -EINVAL; } -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT asmlinkage long s390x_newuname(struct new_utsname __user *name) { int ret = sys_newuname(name); @@ -235,12 +233,12 @@ asmlinkage long s390x_personality(unsigned long personality) return ret; } -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ /* * Wrapper function for sys_fadvise64/fadvise64_64 */ -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT asmlinkage long s390_fadvise64(int fd, u32 offset_high, u32 offset_low, size_t len, int advice) diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c index c5bd36f..95d1099 100644 --- a/arch/s390/kernel/traps.c +++ b/arch/s390/kernel/traps.c @@ -67,13 +67,13 @@ extern pgm_check_handler_t do_monitor_call; #define stack_pointer ({ void **sp; asm("la %0,0(15)" : "=&d" (sp)); sp; }) -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT #define FOURLONG "%08lx %08lx %08lx %08lx\n" static int kstack_depth_to_print = 12; -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ #define FOURLONG "%016lx %016lx %016lx %016lx\n" static int kstack_depth_to_print = 20; -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ /* * For show_trace we have tree different stack to consider: @@ -702,12 +702,12 @@ void __init trap_init(void) pgm_check_table[0x11] = &do_dat_exception; pgm_check_table[0x12] = &translation_exception; pgm_check_table[0x13] = &special_op_exception; -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT pgm_check_table[0x38] = &do_dat_exception; pgm_check_table[0x39] = &do_dat_exception; pgm_check_table[0x3A] = &do_dat_exception; pgm_check_table[0x3B] = &do_dat_exception; -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ pgm_check_table[0x15] = &operand_exception; pgm_check_table[0x1C] = &space_switch_exception; pgm_check_table[0x1D] = &hfp_sqrt_exception; diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S index 89fdb38..9289face 100644 --- a/arch/s390/kernel/vmlinux.lds.S +++ b/arch/s390/kernel/vmlinux.lds.S @@ -5,7 +5,7 @@ #include #include -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT OUTPUT_FORMAT("elf32-s390", "elf32-s390", "elf32-s390") OUTPUT_ARCH(s390) ENTRY(_start) diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile index b701efa..d9b97b3 100644 --- a/arch/s390/lib/Makefile +++ b/arch/s390/lib/Makefile @@ -4,6 +4,5 @@ EXTRA_AFLAGS := -traditional -lib-y += delay.o string.o -lib-$(CONFIG_ARCH_S390_31) += uaccess.o spinlock.o -lib-$(CONFIG_ARCH_S390X) += uaccess64.o spinlock.o +lib-y += delay.o string.o spinlock.o +lib-y += $(if $(CONFIG_64BIT),uaccess64.o,uaccess.o) diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c index 2dc14e9..68d79c5 100644 --- a/arch/s390/lib/spinlock.c +++ b/arch/s390/lib/spinlock.c @@ -29,7 +29,7 @@ __setup("spin_retry=", spin_retry_setup); static inline void _diag44(void) { -#ifdef __s390x__ +#ifdef CONFIG_64BIT if (MACHINE_HAS_DIAG44) #endif asm volatile("diag 0,0,0x44"); diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c index 506a33b..a9566bc 100644 --- a/arch/s390/mm/extmem.c +++ b/arch/s390/mm/extmem.c @@ -143,7 +143,7 @@ dcss_diag (__u8 func, void *parameter, rx = (unsigned long) parameter; ry = (unsigned long) func; __asm__ __volatile__( -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT " sam31\n" // switch to 31 bit " diag %0,%1,0x64\n" " sam64\n" // switch back to 64 bit diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index fb2607c..81ade40 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -31,17 +31,17 @@ #include #include -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT #define __FAIL_ADDR_MASK 0x7ffff000 #define __FIXUP_MASK 0x7fffffff #define __SUBCODE_MASK 0x0200 #define __PF_RES_FIELD 0ULL -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ #define __FAIL_ADDR_MASK -4096L #define __FIXUP_MASK ~0L #define __SUBCODE_MASK 0x0600 #define __PF_RES_FIELD 0x8000000000000000ULL -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ #ifdef CONFIG_SYSCTL extern int sysctl_userprocess_debug; @@ -393,11 +393,11 @@ int pfault_init(void) "2:\n" ".section __ex_table,\"a\"\n" " .align 4\n" -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT " .long 0b,1b\n" -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ " .quad 0b,1b\n" -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ ".previous" : "=d" (rc) : "a" (&refbk), "m" (refbk) : "cc" ); __ctl_set_bit(0, 9); @@ -417,11 +417,11 @@ void pfault_fini(void) "0:\n" ".section __ex_table,\"a\"\n" " .align 4\n" -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT " .long 0b,0b\n" -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ " .quad 0b,0b\n" -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ ".previous" : : "a" (&refbk), "m" (refbk) : "cc" ); } diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 6ec5cd9..df95338 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -44,7 +44,7 @@ void diag10(unsigned long addr) { if (addr >= 0x7ff00000) return; -#ifdef __s390x__ +#ifdef CONFIG_64BIT asm volatile ( " sam31\n" " diag %0,%0,0x10\n" @@ -106,7 +106,7 @@ extern unsigned long __initdata zholes_size[]; * paging_init() sets up the page tables */ -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT void __init paging_init(void) { pgd_t * pg_dir; @@ -175,7 +175,7 @@ void __init paging_init(void) return; } -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ void __init paging_init(void) { pgd_t * pg_dir; @@ -256,7 +256,7 @@ void __init paging_init(void) return; } -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ void __init mem_init(void) { diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index fb187e5..356257c 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -50,7 +50,7 @@ static inline unsigned long mmap_base(void) static inline int mmap_is_legacy(void) { -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT /* * Force standard allocation for 64 bit programs. */ diff --git a/block/Kconfig b/block/Kconfig index eb48edb..377f6dd 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -5,7 +5,7 @@ #for instance. config LBD bool "Support for Large Block Devices" - depends on X86 || (MIPS && 32BIT) || PPC32 || ARCH_S390_31 || SUPERH || UML + depends on X86 || (MIPS && 32BIT) || PPC32 || (S390 && !64BIT) || SUPERH || UML help Say Y here if you want to attach large (bigger than 2TB) discs to your machine, or if you want to have a raid or loopback device diff --git a/crypto/Kconfig b/crypto/Kconfig index c696f7a..52e1d41 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -42,7 +42,7 @@ config CRYPTO_SHA1 config CRYPTO_SHA1_S390 tristate "SHA1 digest algorithm (s390)" - depends on CRYPTO && ARCH_S390 + depends on CRYPTO && S390 help This is the s390 hardware accelerated implementation of the SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2). @@ -58,7 +58,7 @@ config CRYPTO_SHA256 config CRYPTO_SHA256_S390 tristate "SHA256 digest algorithm (s390)" - depends on CRYPTO && ARCH_S390 + depends on CRYPTO && S390 help This is the s390 hardware accelerated implementation of the SHA256 secure hash standard (DFIPS 180-2). @@ -111,7 +111,7 @@ config CRYPTO_DES config CRYPTO_DES_S390 tristate "DES and Triple DES cipher algorithms (s390)" - depends on CRYPTO && ARCH_S390 + depends on CRYPTO && S390 help DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3). @@ -217,7 +217,7 @@ config CRYPTO_AES_X86_64 config CRYPTO_AES_S390 tristate "AES cipher algorithms (s390)" - depends on CRYPTO && ARCH_S390 + depends on CRYPTO && S390 help This is the s390 hardware accelerated implementation of the AES cipher algorithms (FIPS-197). AES uses the Rijndael diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 84e68cd..5ebd06b 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -985,7 +985,7 @@ config HPET_MMAP config HANGCHECK_TIMER tristate "Hangcheck timer" - depends on X86 || IA64 || PPC64 || ARCH_S390 + depends on X86 || IA64 || PPC64 || S390 help The hangcheck-timer module detects when the system has gone out to lunch past a certain margin. It can reboot the system diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c index 66e53dd..40a67c8 100644 --- a/drivers/char/hangcheck-timer.c +++ b/drivers/char/hangcheck-timer.c @@ -120,7 +120,7 @@ __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks); #if defined(CONFIG_X86) # define HAVE_MONOTONIC # define TIMER_FREQ 1000000000ULL -#elif defined(CONFIG_ARCH_S390) +#elif defined(CONFIG_S390) /* FA240000 is 1 Second in the IBM time universe (Page 4-38 Principles of Op for zSeries */ # define TIMER_FREQ 0xFA240000ULL #elif defined(CONFIG_IA64) diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig index 344001b..a654479 100644 --- a/drivers/char/watchdog/Kconfig +++ b/drivers/char/watchdog/Kconfig @@ -438,7 +438,7 @@ config INDYDOG config ZVM_WATCHDOG tristate "z/VM Watchdog Timer" - depends on WATCHDOG && ARCH_S390 + depends on WATCHDOG && S390 help IBM s/390 and zSeries machines running under z/VM 5.1 or later provide a virtual watchdog timer to their guest that cause a diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 9f2352bd..a1e660e 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -157,7 +157,7 @@ struct input_event_compat { # define COMPAT_TEST test_thread_flag(TIF_IA32) #elif defined(CONFIG_IA64) # define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current)) -#elif defined(CONFIG_ARCH_S390) +#elif defined(CONFIG_S390) # define COMPAT_TEST test_thread_flag(TIF_31BIT) #elif defined(CONFIG_MIPS) # define COMPAT_TEST (current->thread.mflags & MF_32BIT_ADDR) diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index c782a63..fa39b94 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -6,7 +6,7 @@ menu "PHY device support" config PHYLIB tristate "PHY Device support and infrastructure" - depends on NET_ETHERNET && (BROKEN || !ARCH_S390) + depends on NET_ETHERNET && (BROKEN || !S390) help Ethernet controllers are usually attached to PHY devices. This option provides infrastructure for diff --git a/drivers/s390/block/Kconfig b/drivers/s390/block/Kconfig index 6e7d7b0..6f50cc9 100644 --- a/drivers/s390/block/Kconfig +++ b/drivers/s390/block/Kconfig @@ -1,11 +1,11 @@ -if ARCH_S390 +if S390 comment "S/390 block device drivers" - depends on ARCH_S390 + depends on S390 config BLK_DEV_XPRAM tristate "XPRAM disk support" - depends on ARCH_S390 + depends on S390 help Select this option if you want to use your expanded storage on S/390 or zSeries as a disk. This is useful as a _fast_ swap device if you @@ -49,7 +49,7 @@ config DASD_FBA config DASD_DIAG tristate "Support for DIAG access to Disks" - depends on DASD && ( ARCH_S390X = 'n' || EXPERIMENTAL) + depends on DASD && ( 64BIT = 'n' || EXPERIMENTAL) help Select this option if you want to use Diagnose250 command to access Disks under VM. If you are not running under VM or unsure what it is, diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 1141a59..041e1a6 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -604,7 +604,7 @@ dasd_smalloc_request(char *magic, int cplength, int datasize, void dasd_kfree_request(struct dasd_ccw_req * cqr, struct dasd_device * device) { -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT struct ccw1 *ccw; /* Clear any idals used for the request. */ diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c index a33d406..ba80fde 100644 --- a/drivers/s390/block/dasd_diag.c +++ b/drivers/s390/block/dasd_diag.c @@ -75,7 +75,7 @@ dia250(void *iob, int cmd) int rc; __asm__ __volatile__( -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT " lghi %0,3\n" " lgr 0,%3\n" " diag 0,%2,0x250\n" diff --git a/drivers/s390/block/dasd_diag.h b/drivers/s390/block/dasd_diag.h index 37edf6e..a4f80bd 100644 --- a/drivers/s390/block/dasd_diag.h +++ b/drivers/s390/block/dasd_diag.h @@ -45,7 +45,7 @@ struct dasd_diag_characteristics { } __attribute__ ((packed, aligned(4))); -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT #define DASD_DIAG_FLAGA_DEFAULT DASD_DIAG_FLAGA_FORMAT_64BIT typedef u64 blocknum_t; @@ -86,7 +86,7 @@ struct dasd_diag_rw_io { struct dasd_diag_bio *bio_list; u8 spare4[8]; } __attribute__ ((packed, aligned(8))); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ #define DASD_DIAG_FLAGA_DEFAULT 0x0 typedef u32 blocknum_t; @@ -125,4 +125,4 @@ struct dasd_diag_rw_io { u32 interrupt_params; u8 spare3[20]; } __attribute__ ((packed, aligned(8))); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index efc4cf6..96eb482 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -1041,7 +1041,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req) /* Eckd can only do full blocks. */ return ERR_PTR(-EINVAL); count += bv->bv_len >> (device->s2b_shift + 9); -#if defined(CONFIG_ARCH_S390X) +#if defined(CONFIG_64BIT) if (idal_is_needed (page_address(bv->bv_page), bv->bv_len)) cidaw += bv->bv_len >> (device->s2b_shift + 9); diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c index 9bac8d8..8ec75dc 100644 --- a/drivers/s390/block/dasd_fba.c +++ b/drivers/s390/block/dasd_fba.c @@ -271,7 +271,7 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req) /* Fba can only do full blocks. */ return ERR_PTR(-EINVAL); count += bv->bv_len >> (device->s2b_shift + 9); -#if defined(CONFIG_ARCH_S390X) +#if defined(CONFIG_64BIT) if (idal_is_needed (page_address(bv->bv_page), bv->bv_len)) cidaw += bv->bv_len / blksize; diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c index d428c90..bf3a67c 100644 --- a/drivers/s390/block/xpram.c +++ b/drivers/s390/block/xpram.c @@ -160,7 +160,7 @@ static int xpram_page_in (unsigned long page_addr, unsigned int xpage_index) "0: ipm %0\n" " srl %0,28\n" "1:\n" -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT ".section __ex_table,\"a\"\n" " .align 4\n" " .long 0b,1b\n" @@ -208,7 +208,7 @@ static long xpram_page_out (unsigned long page_addr, unsigned int xpage_index) "0: ipm %0\n" " srl %0,28\n" "1:\n" -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT ".section __ex_table,\"a\"\n" " .align 4\n" " .long 0b,1b\n" diff --git a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c index 5473c23..5acc0ac 100644 --- a/drivers/s390/char/vmwatchdog.c +++ b/drivers/s390/char/vmwatchdog.c @@ -66,7 +66,7 @@ static int __diag288(enum vmwdt_func func, unsigned int timeout, __cmdl = len; err = 0; asm volatile ( -#ifdef __s390x__ +#ifdef CONFIG_64BIT "diag %2,%4,0x288\n" "1: \n" ".section .fixup,\"ax\"\n" diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 6f274f4..7376bc8 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c @@ -195,7 +195,7 @@ cio_start_key (struct subchannel *sch, /* subchannel structure */ sch->orb.spnd = sch->options.suspend; sch->orb.ssic = sch->options.suspend && sch->options.inter; sch->orb.lpm = (lpm != 0) ? (lpm & sch->opm) : sch->lpm; -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT /* * for 64 bit we always support 64 bit IDAWs with 4k page size only */ diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c index 3c77c3f..04ceba3 100644 --- a/drivers/s390/cio/device_id.c +++ b/drivers/s390/cio/device_id.c @@ -27,7 +27,7 @@ /* * diag210 is used under VM to get information about a virtual device */ -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT int diag210(struct diag210 * addr) { diff --git a/drivers/s390/cio/ioasm.h b/drivers/s390/cio/ioasm.h index 62b0e2a..95a9462 100644 --- a/drivers/s390/cio/ioasm.h +++ b/drivers/s390/cio/ioasm.h @@ -50,7 +50,7 @@ static inline int stsch_err(struct subchannel_id schid, "0: ipm %0\n" " srl %0,28\n" "1:\n" -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT ".section __ex_table,\"a\"\n" " .align 8\n" " .quad 0b,1b\n" @@ -95,7 +95,7 @@ static inline int msch_err(struct subchannel_id schid, "0: ipm %0\n" " srl %0,28\n" "1:\n" -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT ".section __ex_table,\"a\"\n" " .align 8\n" " .quad 0b,1b\n" diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index 035c77a..30a836f 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c @@ -2394,7 +2394,7 @@ tiqdio_check_chsc_availability(void) sprintf(dbf_text,"hydrati%1x", hydra_thinints); QDIO_DBF_TEXT0(0,setup,dbf_text); -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT /* Check for QEBSM support in general (bit 58). */ is_passthrough = css_general_characteristics.qebsm; #endif diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h index 43b840a..fa385e7 100644 --- a/drivers/s390/cio/qdio.h +++ b/drivers/s390/cio/qdio.h @@ -271,7 +271,7 @@ static inline int do_sqbs(unsigned long sch, unsigned char state, int queue, unsigned int *start, unsigned int *count) { -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT register unsigned long _ccq asm ("0") = *count; register unsigned long _sch asm ("1") = sch; unsigned long _queuestart = ((unsigned long)queue << 32) | *start; @@ -295,7 +295,7 @@ static inline int do_eqbs(unsigned long sch, unsigned char *state, int queue, unsigned int *start, unsigned int *count) { -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT register unsigned long _ccq asm ("0") = *count; register unsigned long _sch asm ("1") = sch; unsigned long _queuestart = ((unsigned long)queue << 32) | *start; @@ -323,7 +323,7 @@ do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2) { int cc; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT asm volatile ( "lhi 0,2 \n\t" "lr 1,%1 \n\t" @@ -336,7 +336,7 @@ do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2) : "d" (schid), "d" (mask1), "d" (mask2) : "cc", "0", "1", "2", "3" ); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ asm volatile ( "lghi 0,2 \n\t" "llgfr 1,%1 \n\t" @@ -349,7 +349,7 @@ do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2) : "d" (schid), "d" (mask1), "d" (mask2) : "cc", "0", "1", "2", "3" ); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ return cc; } @@ -358,7 +358,7 @@ do_siga_input(struct subchannel_id schid, unsigned int mask) { int cc; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT asm volatile ( "lhi 0,1 \n\t" "lr 1,%1 \n\t" @@ -370,7 +370,7 @@ do_siga_input(struct subchannel_id schid, unsigned int mask) : "d" (schid), "d" (mask) : "cc", "0", "1", "2", "memory" ); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ asm volatile ( "lghi 0,1 \n\t" "llgfr 1,%1 \n\t" @@ -382,7 +382,7 @@ do_siga_input(struct subchannel_id schid, unsigned int mask) : "d" (schid), "d" (mask) : "cc", "0", "1", "2", "memory" ); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ return cc; } @@ -394,7 +394,7 @@ do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb, int cc; __u32 busy_bit; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT asm volatile ( "lhi 0,0 \n\t" "lr 1,%2 \n\t" @@ -424,7 +424,7 @@ do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb, "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION) : "cc", "0", "1", "2", "memory" ); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ asm volatile ( "llgfr 0,%5 \n\t" "lgr 1,%2 \n\t" @@ -449,7 +449,7 @@ do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb, "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION), "d" (fc) : "cc", "0", "1", "2", "memory" ); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ (*bb) = busy_bit; return cc; @@ -461,21 +461,21 @@ do_clear_global_summary(void) unsigned long time; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT asm volatile ( "lhi 1,3 \n\t" ".insn rre,0xb2650000,2,0 \n\t" "lr %0,3 \n\t" : "=d" (time) : : "cc", "1", "2", "3" ); -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ asm volatile ( "lghi 1,3 \n\t" ".insn rre,0xb2650000,2,0 \n\t" "lgr %0,3 \n\t" : "=d" (time) : : "cc", "1", "2", "3" ); -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ return time; } @@ -542,11 +542,11 @@ struct qdio_perf_stats { #define MY_MODULE_STRING(x) #x -#ifdef CONFIG_ARCH_S390X +#ifdef CONFIG_64BIT #define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x) -#else /* CONFIG_ARCH_S390X */ +#else /* CONFIG_64BIT */ #define QDIO_GET_ADDR(x) ((__u32)(long)x) -#endif /* CONFIG_ARCH_S390X */ +#endif /* CONFIG_64BIT */ struct qdio_q { volatile struct slsb slsb; diff --git a/drivers/s390/crypto/z90hardware.c b/drivers/s390/crypto/z90hardware.c index 7c3ed52..d7f7494 100644 --- a/drivers/s390/crypto/z90hardware.c +++ b/drivers/s390/crypto/z90hardware.c @@ -785,7 +785,7 @@ testq(int q_nr, int *q_depth, int *dev_type, struct ap_status_word *stat) int ccode; asm volatile -#ifdef __s390x__ +#ifdef CONFIG_64BIT (" llgfr 0,%4 \n" " slgr 1,1 \n" " lgr 2,1 \n" @@ -855,7 +855,7 @@ resetq(int q_nr, struct ap_status_word *stat_p) int ccode; asm volatile -#ifdef __s390x__ +#ifdef CONFIG_64BIT (" llgfr 0,%2 \n" " lghi 1,1 \n" " sll 1,24 \n" @@ -921,7 +921,7 @@ sen(int msg_len, unsigned char *msg_ext, struct ap_status_word *stat) int ccode; asm volatile -#ifdef __s390x__ +#ifdef CONFIG_64BIT (" lgr 6,%3 \n" " llgfr 7,%2 \n" " llgt 0,0(6) \n" @@ -1000,7 +1000,7 @@ rec(int q_nr, int buff_l, unsigned char *rsp, unsigned char *id, int ccode; asm volatile -#ifdef __s390x__ +#ifdef CONFIG_64BIT (" llgfr 0,%2 \n" " lgr 3,%4 \n" " lgr 6,%3 \n" diff --git a/drivers/s390/net/Kconfig b/drivers/s390/net/Kconfig index a7efc39..5488547 100644 --- a/drivers/s390/net/Kconfig +++ b/drivers/s390/net/Kconfig @@ -1,5 +1,5 @@ menu "S/390 network device drivers" - depends on NETDEVICES && ARCH_S390 + depends on NETDEVICES && S390 config LCS tristate "Lan Channel Station Interface" diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c index 6b63d21..e70af7f3 100644 --- a/drivers/s390/net/claw.c +++ b/drivers/s390/net/claw.c @@ -1603,7 +1603,7 @@ dumpit(char* buf, int len) __u32 ct, sw, rm, dup; char *ptr, *rptr; char tbuf[82], tdup[82]; -#if (CONFIG_ARCH_S390X) +#if (CONFIG_64BIT) char addr[22]; #else char addr[12]; @@ -1619,7 +1619,7 @@ dumpit(char* buf, int len) dup = 0; for ( ct=0; ct < len; ct++, ptr++, rptr++ ) { if (sw == 0) { -#if (CONFIG_ARCH_S390X) +#if (CONFIG_64BIT) sprintf(addr, "%16.16lX",(unsigned long)rptr); #else sprintf(addr, "%8.8X",(__u32)rptr); @@ -1634,7 +1634,7 @@ dumpit(char* buf, int len) if (sw == 8) { strcat(bhex, " "); } -#if (CONFIG_ARCH_S390X) +#if (CONFIG_64BIT) sprintf(tbuf,"%2.2lX", (unsigned long)*ptr); #else sprintf(tbuf,"%2.2X", (__u32)*ptr); diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c index 7dad597..3bf4666 100644 --- a/drivers/s390/s390mach.c +++ b/drivers/s390/s390mach.c @@ -246,7 +246,7 @@ s390_revalidate_registers(struct mci *mci) */ kill_task = 1; -#ifndef __s390x__ +#ifndef CONFIG_64BIT asm volatile("ld 0,0(%0)\n" "ld 2,8(%0)\n" "ld 4,16(%0)\n" @@ -255,7 +255,7 @@ s390_revalidate_registers(struct mci *mci) #endif if (MACHINE_HAS_IEEE) { -#ifdef __s390x__ +#ifdef CONFIG_64BIT fpt_save_area = &S390_lowcore.floating_pt_save_area; fpt_creg_save_area = &S390_lowcore.fpt_creg_save_area; #else @@ -314,7 +314,7 @@ s390_revalidate_registers(struct mci *mci) */ s390_handle_damage("invalid control registers."); else -#ifdef __s390x__ +#ifdef CONFIG_64BIT asm volatile("lctlg 0,15,0(%0)" : : "a" (&S390_lowcore.cregs_save_area)); #else @@ -327,7 +327,7 @@ s390_revalidate_registers(struct mci *mci) * can't write something sensible into that register. */ -#ifdef __s390x__ +#ifdef CONFIG_64BIT /* * See if we can revalidate the TOD programmable register with its * old contents (should be zero) otherwise set it to zero. @@ -384,7 +384,7 @@ s390_do_machine_check(struct pt_regs *regs) if (mci->b) { /* Processing backup -> verify if we can survive this */ u64 z_mcic, o_mcic, t_mcic; -#ifdef __s390x__ +#ifdef CONFIG_64BIT z_mcic = (1ULL<<63 | 1ULL<<59 | 1ULL<<29); o_mcic = (1ULL<<43 | 1ULL<<42 | 1ULL<<41 | 1ULL<<40 | 1ULL<<36 | 1ULL<<35 | 1ULL<<34 | 1ULL<<32 | diff --git a/drivers/s390/sysinfo.c b/drivers/s390/sysinfo.c index 87c2db1..66da840 100644 --- a/drivers/s390/sysinfo.c +++ b/drivers/s390/sysinfo.c @@ -106,7 +106,7 @@ static inline int stsi (void *sysinfo, { int cc, retv; -#ifndef CONFIG_ARCH_S390X +#ifndef CONFIG_64BIT __asm__ __volatile__ ( "lr\t0,%2\n" "\tlr\t1,%3\n" "\tstsi\t0(%4)\n" diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 4c42065..9e8254f 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -1815,7 +1815,7 @@ config SCSI_SUNESP config ZFCP tristate "FCP host bus adapter driver for IBM eServer zSeries" - depends on ARCH_S390 && QDIO && SCSI + depends on S390 && QDIO && SCSI select SCSI_FC_ATTRS help If you want to access SCSI devices attached to your IBM eServer diff --git a/fs/partitions/Kconfig b/fs/partitions/Kconfig index 656bc43..e227a04 100644 --- a/fs/partitions/Kconfig +++ b/fs/partitions/Kconfig @@ -85,7 +85,7 @@ config ATARI_PARTITION config IBM_PARTITION bool "IBM disk label and partition support" - depends on PARTITION_ADVANCED && ARCH_S390 + depends on PARTITION_ADVANCED && S390 help Say Y here if you would like to be able to read the hard disk partition table format used by IBM DASD disks operating under CMS. diff --git a/fs/proc/array.c b/fs/proc/array.c index 3e1239e..5e9251f 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -308,7 +308,7 @@ int proc_pid_status(struct task_struct *task, char * buffer) buffer = task_sig(task, buffer); buffer = task_cap(task, buffer); buffer = cpuset_task_status_allowed(task, buffer); -#if defined(CONFIG_ARCH_S390) +#if defined(CONFIG_S390) buffer = task_show_regs(task, buffer); #endif return buffer - orig; diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h index f97d926..2861cdc 100644 --- a/include/asm-s390/unistd.h +++ b/include/asm-s390/unistd.h @@ -539,7 +539,7 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ #define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_SYS_RT_SIGACTION -# ifdef CONFIG_ARCH_S390_31 +# ifndef CONFIG_64BIT # define __ARCH_WANT_STAT64 # define __ARCH_WANT_SYS_TIME # endif diff --git a/include/linux/irq.h b/include/linux/irq.h index 60f8bc7..6c5d4c8 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -12,7 +12,7 @@ #include #include -#if !defined(CONFIG_ARCH_S390) +#if !defined(CONFIG_S390) #include #include diff --git a/init/Kconfig b/init/Kconfig index 24e0f7c7..ba42f37 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -189,7 +189,7 @@ config AUDIT config AUDITSYSCALL bool "Enable system-call auditing support" - depends on AUDIT && (X86 || PPC || PPC64 || ARCH_S390 || IA64 || UML || SPARC64) + depends on AUDIT && (X86 || PPC || PPC64 || S390 || IA64 || UML || SPARC64) default y if SECURITY_SELINUX help Enable low-overhead system-call auditing infrastructure that diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c index c10b08a..c2683fc 100644 --- a/init/do_mounts_rd.c +++ b/init/do_mounts_rd.c @@ -145,7 +145,7 @@ int __init rd_load_image(char *from) int nblocks, i, disk; char *buf = NULL; unsigned short rotate = 0; -#if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES) +#if !defined(CONFIG_S390) && !defined(CONFIG_PPC_ISERIES) char rotator[4] = { '|' , '/' , '-' , '\\' }; #endif @@ -237,7 +237,7 @@ int __init rd_load_image(char *from) } sys_read(in_fd, buf, BLOCK_SIZE); sys_write(out_fd, buf, BLOCK_SIZE); -#if !defined(CONFIG_ARCH_S390) && !defined(CONFIG_PPC_ISERIES) +#if !defined(CONFIG_S390) && !defined(CONFIG_PPC_ISERIES) if (!(i % 16)) { printk("%c\b", rotator[rotate & 0x3]); rotate++; diff --git a/kernel/panic.c b/kernel/panic.c index aabc5f8..c5c4ab2 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -60,7 +60,7 @@ NORET_TYPE void panic(const char * fmt, ...) long i; static char buf[1024]; va_list args; -#if defined(CONFIG_ARCH_S390) +#if defined(CONFIG_S390) unsigned long caller = (unsigned long) __builtin_return_address(0); #endif @@ -125,7 +125,7 @@ NORET_TYPE void panic(const char * fmt, ...) printk(KERN_EMERG "Press Stop-A (L1-A) to return to the boot prom\n"); } #endif -#if defined(CONFIG_ARCH_S390) +#if defined(CONFIG_S390) disabled_wait(caller); #endif local_irq_enable(); diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 345f4a1..a85047b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -108,7 +108,7 @@ extern int pwrsw_enabled; extern int unaligned_enabled; #endif -#ifdef CONFIG_ARCH_S390 +#ifdef CONFIG_S390 #ifdef CONFIG_MATHEMU extern int sysctl_ieee_emulation_warnings; #endif @@ -542,7 +542,7 @@ static ctl_table kern_table[] = { .extra1 = &minolduid, .extra2 = &maxolduid, }, -#ifdef CONFIG_ARCH_S390 +#ifdef CONFIG_S390 #ifdef CONFIG_MATHEMU { .ctl_name = KERN_IEEE_EMULATION_WARNINGS, @@ -644,7 +644,7 @@ static ctl_table kern_table[] = { .mode = 0644, .proc_handler = &proc_dointvec, }, -#if defined(CONFIG_ARCH_S390) +#if defined(CONFIG_S390) { .ctl_name = KERN_SPIN_RETRY, .procname = "spin_retry", diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 1cedc23..80598cf 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -32,7 +32,7 @@ config MAGIC_SYSRQ config LOG_BUF_SHIFT int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL range 12 21 - default 17 if ARCH_S390 + default 17 if S390 default 16 if X86_NUMAQ || IA64 default 15 if SMP default 14 -- cgit v1.1 From a1a5ea70a6e9db6332b27fe2d96666e17aa1436b Mon Sep 17 00:00:00 2001 From: Markus Lidel Date: Fri, 6 Jan 2006 00:19:29 -0800 Subject: [PATCH] I2O: changed I2O API to create I2O messages in kernel memory Changed the I2O API to create I2O messages first in kernel memory and then transfer it at once over the PCI bus instead of sending each quad-word over the PCI bus. Signed-off-by: Markus Lidel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/bus-osm.c | 21 +- drivers/message/i2o/device.c | 51 +- drivers/message/i2o/exec-osm.c | 93 +- drivers/message/i2o/i2o_block.c | 157 +-- drivers/message/i2o/i2o_config.c | 169 ++-- drivers/message/i2o/i2o_scsi.c | 50 +- drivers/message/i2o/iop.c | 296 +++--- drivers/message/i2o/pci.c | 1 + include/linux/i2o.h | 1947 ++++++++++++++++++++------------------ 9 files changed, 1450 insertions(+), 1335 deletions(-) diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c index 151b228..ce039d3 100644 --- a/drivers/message/i2o/bus-osm.c +++ b/drivers/message/i2o/bus-osm.c @@ -39,18 +39,18 @@ static struct i2o_class_id i2o_bus_class_id[] = { */ static int i2o_bus_scan(struct i2o_device *dev) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; - m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) + msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) return -ETIMEDOUT; - writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.tid, - &msg->u.head[1]); + msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data. + tid); - return i2o_msg_post_wait(dev->iop, m, 60); + return i2o_msg_post_wait(dev->iop, msg, 60); }; /** @@ -59,8 +59,9 @@ static int i2o_bus_scan(struct i2o_device *dev) * * Returns count. */ -static ssize_t i2o_bus_store_scan(struct device *d, struct device_attribute *attr, const char *buf, - size_t count) +static ssize_t i2o_bus_store_scan(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) { struct i2o_device *i2o_dev = to_i2o_device(d); int rc; diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index 8eb50cd..002ae0e 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c @@ -35,18 +35,18 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd, u32 type) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; - m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid, &msg->u.head[1]); - writel(type, &msg->body[0]); + msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid); + msg->body[0] = cpu_to_le32(type); - return i2o_msg_post_wait(dev->iop, m, 60); + return i2o_msg_post_wait(dev->iop, msg, 60); } /** @@ -419,10 +419,9 @@ int i2o_device_parse_lct(struct i2o_controller *c) * ResultCount, ErrorInfoSize, BlockStatus and BlockSize. */ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, - int oplen, void *reslist, int reslen) + int oplen, void *reslist, int reslen) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; u32 *res32 = (u32 *) reslist; u32 *restmp = (u32 *) reslist; int len = 0; @@ -437,26 +436,28 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, if (i2o_dma_alloc(dev, &res, reslen, GFP_KERNEL)) return -ENOMEM; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) { + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) { i2o_dma_free(dev, &res); - return -ETIMEDOUT; + return PTR_ERR(msg); } i = 0; - writel(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid, - &msg->u.head[1]); - writel(0, &msg->body[i++]); - writel(0x4C000000 | oplen, &msg->body[i++]); /* OperationList */ - memcpy_toio(&msg->body[i], oplist, oplen); + msg->u.head[1] = + cpu_to_le32(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid); + msg->body[i++] = cpu_to_le32(0x00000000); + msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */ + memcpy(&msg->body[i], oplist, oplen); + i += (oplen / 4 + (oplen % 4 ? 1 : 0)); - writel(0xD0000000 | res.len, &msg->body[i++]); /* ResultList */ - writel(res.phys, &msg->body[i++]); + msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */ + msg->body[i++] = cpu_to_le32(res.phys); - writel(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) | - SGL_OFFSET_5, &msg->u.head[0]); + msg->u.head[0] = + cpu_to_le32(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) | + SGL_OFFSET_5); - rc = i2o_msg_post_wait_mem(c, m, 10, &res); + rc = i2o_msg_post_wait_mem(c, msg, 10, &res); /* This only looks like a memory leak - don't "fix" it. */ if (rc == -ETIMEDOUT) diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c index 9c339a2..71a0933 100644 --- a/drivers/message/i2o/exec-osm.c +++ b/drivers/message/i2o/exec-osm.c @@ -114,13 +114,12 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait) * Returns 0 on success, negative error code on timeout or positive error * code from reply. */ -int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long - timeout, struct i2o_dma *dma) +int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg, + unsigned long timeout, struct i2o_dma *dma) { DECLARE_WAIT_QUEUE_HEAD(wq); struct i2o_exec_wait *wait; static u32 tcntxt = 0x80000000; - struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m); int rc = 0; wait = i2o_exec_wait_alloc(); @@ -138,15 +137,15 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long * We will only use transaction contexts >= 0x80000000 for POST WAIT, * so we could find a POST WAIT reply easier in the reply handler. */ - writel(i2o_exec_driver.context, &msg->u.s.icntxt); + msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); wait->tcntxt = tcntxt++; - writel(wait->tcntxt, &msg->u.s.tcntxt); + msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt); /* * Post the message to the controller. At some point later it will * return. If we time out before it returns then complete will be zero. */ - i2o_msg_post(c, m); + i2o_msg_post(c, msg); if (!wait->complete) { wait->wq = &wq; @@ -266,7 +265,8 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m, * * Returns number of bytes printed into buffer. */ -static ssize_t i2o_exec_show_vendor_id(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t i2o_exec_show_vendor_id(struct device *d, + struct device_attribute *attr, char *buf) { struct i2o_device *dev = to_i2o_device(d); u16 id; @@ -286,7 +286,9 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d, struct device_attribute * * Returns number of bytes printed into buffer. */ -static ssize_t i2o_exec_show_product_id(struct device *d, struct device_attribute *attr, char *buf) +static ssize_t i2o_exec_show_product_id(struct device *d, + struct device_attribute *attr, + char *buf) { struct i2o_device *dev = to_i2o_device(d); u16 id; @@ -385,23 +387,22 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m, u32 context; if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) { + struct i2o_message __iomem *pmsg; + u32 pm; + /* * If Fail bit is set we must take the transaction context of * the preserved message to find the right request again. */ - struct i2o_message __iomem *pmsg; - u32 pm; pm = le32_to_cpu(msg->body[3]); - pmsg = i2o_msg_in_to_virt(c, pm); + context = readl(&pmsg->u.s.tcntxt); i2o_report_status(KERN_INFO, "i2o_core", msg); - context = readl(&pmsg->u.s.tcntxt); - /* Release the preserved msg */ - i2o_msg_nop(c, pm); + i2o_msg_nop_mfa(c, pm); } else context = le32_to_cpu(msg->u.s.tcntxt); @@ -462,25 +463,26 @@ static void i2o_exec_event(struct i2o_event *evt) */ int i2o_exec_lct_get(struct i2o_controller *c) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; int i = 0; int rc = -EAGAIN; for (i = 1; i <= I2O_LCT_GET_TRIES; i++) { - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; - - writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); - writel(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(0xffffffff, &msg->body[0]); - writel(0x00000000, &msg->body[1]); - writel(0xd0000000 | c->dlct.len, &msg->body[2]); - writel(c->dlct.phys, &msg->body[3]); - - rc = i2o_msg_post_wait(c, m, I2O_TIMEOUT_LCT_GET); + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); + + msg->u.head[0] = + cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | + ADAPTER_TID); + msg->body[0] = cpu_to_le32(0xffffffff); + msg->body[1] = cpu_to_le32(0x00000000); + msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len); + msg->body[3] = cpu_to_le32(c->dlct.phys); + + rc = i2o_msg_post_wait(c, msg, I2O_TIMEOUT_LCT_GET); if (rc < 0) break; @@ -506,29 +508,28 @@ static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind) { i2o_status_block *sb = c->status_block.virt; struct device *dev; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; dev = &c->pdev->dev; if (i2o_dma_realloc(dev, &c->dlct, sb->expected_lct_size, GFP_KERNEL)) return -ENOMEM; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; - - writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); - writel(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(i2o_exec_driver.context, &msg->u.s.icntxt); - writel(0, &msg->u.s.tcntxt); /* FIXME */ - writel(0xffffffff, &msg->body[0]); - writel(change_ind, &msg->body[1]); - writel(0xd0000000 | c->dlct.len, &msg->body[2]); - writel(c->dlct.phys, &msg->body[3]); - - i2o_msg_post(c, m); + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); + + msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6); + msg->u.head[1] = cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | + ADAPTER_TID); + msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); + msg->u.s.tcntxt = cpu_to_le32(0x00000000); + msg->body[0] = cpu_to_le32(0xffffffff); + msg->body[1] = cpu_to_le32(change_ind); + msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len); + msg->body[3] = cpu_to_le32(c->dlct.phys); + + i2o_msg_post(c, msg); return 0; }; diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index f283b5b..2bd15c7 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c @@ -130,20 +130,20 @@ static int i2o_block_remove(struct device *dev) */ static int i2o_block_device_flush(struct i2o_device *dev) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; - m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev->lct_data.tid, - &msg->u.head[1]); - writel(60 << 16, &msg->body[0]); + msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev-> + lct_data.tid); + msg->body[0] = cpu_to_le32(60 << 16); osm_debug("Flushing...\n"); - return i2o_msg_post_wait(dev->iop, m, 60); + return i2o_msg_post_wait(dev->iop, msg, 60); }; /** @@ -181,21 +181,21 @@ static int i2o_block_issue_flush(request_queue_t * queue, struct gendisk *disk, */ static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) { - struct i2o_message __iomem *msg; - u32 m; - - m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; - - writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_BLOCK_MMOUNT << 24 | HOST_TID << 12 | dev->lct_data.tid, - &msg->u.head[1]); - writel(-1, &msg->body[0]); - writel(0, &msg->body[1]); + struct i2o_message *msg; + + msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); + + msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_BLOCK_MMOUNT << 24 | HOST_TID << 12 | dev-> + lct_data.tid); + msg->body[0] = cpu_to_le32(-1); + msg->body[1] = cpu_to_le32(0x00000000); osm_debug("Mounting...\n"); - return i2o_msg_post_wait(dev->iop, m, 2); + return i2o_msg_post_wait(dev->iop, msg, 2); }; /** @@ -210,20 +210,20 @@ static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) */ static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; - m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg) == I2O_QUEUE_EMPTY) + return PTR_ERR(msg); - writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev->lct_data.tid, - &msg->u.head[1]); - writel(-1, &msg->body[0]); + msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev-> + lct_data.tid); + msg->body[0] = cpu_to_le32(-1); osm_debug("Locking...\n"); - return i2o_msg_post_wait(dev->iop, m, 2); + return i2o_msg_post_wait(dev->iop, msg, 2); }; /** @@ -238,20 +238,20 @@ static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id) */ static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; - m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev->lct_data.tid, - &msg->u.head[1]); - writel(media_id, &msg->body[0]); + msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev-> + lct_data.tid); + msg->body[0] = cpu_to_le32(media_id); osm_debug("Unlocking...\n"); - return i2o_msg_post_wait(dev->iop, m, 2); + return i2o_msg_post_wait(dev->iop, msg, 2); }; /** @@ -267,21 +267,21 @@ static int i2o_block_device_power(struct i2o_block_device *dev, u8 op) { struct i2o_device *i2o_dev = dev->i2o_dev; struct i2o_controller *c = i2o_dev->iop; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; int rc; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev->lct_data. - tid, &msg->u.head[1]); - writel(op << 24, &msg->body[0]); + msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev-> + lct_data.tid); + msg->body[0] = cpu_to_le32(op << 24); osm_debug("Power...\n"); - rc = i2o_msg_post_wait(c, m, 60); + rc = i2o_msg_post_wait(c, msg, 60); if (!rc) dev->power = op; @@ -331,7 +331,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq) */ static inline int i2o_block_sglist_alloc(struct i2o_controller *c, struct i2o_block_request *ireq, - u32 __iomem ** mptr) + u32 ** mptr) { int nents; enum dma_data_direction direction; @@ -745,10 +745,9 @@ static int i2o_block_transfer(struct request *req) struct i2o_block_device *dev = req->rq_disk->private_data; struct i2o_controller *c; int tid = dev->i2o_dev->lct_data.tid; - struct i2o_message __iomem *msg; - u32 __iomem *mptr; + struct i2o_message *msg; + u32 *mptr; struct i2o_block_request *ireq = req->special; - u32 m; u32 tcntxt; u32 sgl_offset = SGL_OFFSET_8; u32 ctl_flags = 0x00000000; @@ -763,9 +762,9 @@ static int i2o_block_transfer(struct request *req) c = dev->i2o_dev->iop; - m = i2o_msg_get(c, &msg); - if (m == I2O_QUEUE_EMPTY) { - rc = -EBUSY; + msg = i2o_msg_get(c); + if (IS_ERR(msg)) { + rc = PTR_ERR(msg); goto exit; } @@ -775,8 +774,8 @@ static int i2o_block_transfer(struct request *req) goto nop_msg; } - writel(i2o_block_driver.context, &msg->u.s.icntxt); - writel(tcntxt, &msg->u.s.tcntxt); + msg->u.s.icntxt = cpu_to_le32(i2o_block_driver.context); + msg->u.s.tcntxt = cpu_to_le32(tcntxt); mptr = &msg->body[0]; @@ -834,11 +833,11 @@ static int i2o_block_transfer(struct request *req) sgl_offset = SGL_OFFSET_12; - writel(I2O_CMD_PRIVATE << 24 | HOST_TID << 12 | tid, - &msg->u.head[1]); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_PRIVATE << 24 | HOST_TID << 12 | tid); - writel(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC, mptr++); - writel(tid, mptr++); + *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC); + *mptr++ = cpu_to_le32(tid); /* * ENABLE_DISCONNECT @@ -853,22 +852,24 @@ static int i2o_block_transfer(struct request *req) scsi_flags = 0xa0a0000a; } - writel(scsi_flags, mptr++); + *mptr++ = cpu_to_le32(scsi_flags); *((u32 *) & cmd[2]) = cpu_to_be32(req->sector * hwsec); *((u16 *) & cmd[7]) = cpu_to_be16(req->nr_sectors * hwsec); - memcpy_toio(mptr, cmd, 10); + memcpy(mptr, cmd, 10); mptr += 4; - writel(req->nr_sectors << KERNEL_SECTOR_SHIFT, mptr++); + *mptr++ = cpu_to_le32(req->nr_sectors << KERNEL_SECTOR_SHIFT); } else #endif { - writel(cmd | HOST_TID << 12 | tid, &msg->u.head[1]); - writel(ctl_flags, mptr++); - writel(req->nr_sectors << KERNEL_SECTOR_SHIFT, mptr++); - writel((u32) (req->sector << KERNEL_SECTOR_SHIFT), mptr++); - writel(req->sector >> (32 - KERNEL_SECTOR_SHIFT), mptr++); + msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid); + *mptr++ = cpu_to_le32(ctl_flags); + *mptr++ = cpu_to_le32(req->nr_sectors << KERNEL_SECTOR_SHIFT); + *mptr++ = + cpu_to_le32((u32) (req->sector << KERNEL_SECTOR_SHIFT)); + *mptr++ = + cpu_to_le32(req->sector >> (32 - KERNEL_SECTOR_SHIFT)); } if (!i2o_block_sglist_alloc(c, ireq, &mptr)) { @@ -876,13 +877,13 @@ static int i2o_block_transfer(struct request *req) goto context_remove; } - writel(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | - sgl_offset, &msg->u.head[0]); + msg->u.head[0] = + cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset); list_add_tail(&ireq->queue, &dev->open_queue); dev->open_queue_depth++; - i2o_msg_post(c, m); + i2o_msg_post(c, msg); return 0; @@ -890,7 +891,7 @@ static int i2o_block_transfer(struct request *req) i2o_cntxt_list_remove(c, req); nop_msg: - i2o_msg_nop(c, m); + i2o_msg_nop(c, msg); exit: return rc; diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index 3c3a7ab..4fe73d6 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c @@ -230,8 +230,7 @@ static int i2o_cfg_swdl(unsigned long arg) struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; unsigned char maxfrag = 0, curfrag = 1; struct i2o_dma buffer; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; unsigned int status = 0, swlen = 0, fragsize = 8192; struct i2o_controller *c; @@ -257,31 +256,34 @@ static int i2o_cfg_swdl(unsigned long arg) if (!c) return -ENXIO; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -EBUSY; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) { - i2o_msg_nop(c, m); + i2o_msg_nop(c, msg); return -ENOMEM; } __copy_from_user(buffer.virt, kxfer.buf, fragsize); - writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_7, &msg->u.head[0]); - writel(I2O_CMD_SW_DOWNLOAD << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(i2o_config_driver.context, &msg->u.head[2]); - writel(0, &msg->u.head[3]); - writel((((u32) kxfer.flags) << 24) | (((u32) kxfer.sw_type) << 16) | - (((u32) maxfrag) << 8) | (((u32) curfrag)), &msg->body[0]); - writel(swlen, &msg->body[1]); - writel(kxfer.sw_id, &msg->body[2]); - writel(0xD0000000 | fragsize, &msg->body[3]); - writel(buffer.phys, &msg->body[4]); + msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_SW_DOWNLOAD << 24 | HOST_TID << 12 | + ADAPTER_TID); + msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); + msg->u.head[3] = cpu_to_le32(0); + msg->body[0] = + cpu_to_le32((((u32) kxfer.flags) << 24) | (((u32) kxfer. + sw_type) << 16) | + (((u32) maxfrag) << 8) | (((u32) curfrag))); + msg->body[1] = cpu_to_le32(swlen); + msg->body[2] = cpu_to_le32(kxfer.sw_id); + msg->body[3] = cpu_to_le32(0xD0000000 | fragsize); + msg->body[4] = cpu_to_le32(buffer.phys); osm_debug("swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize); - status = i2o_msg_post_wait_mem(c, m, 60, &buffer); + status = i2o_msg_post_wait_mem(c, msg, 60, &buffer); if (status != -ETIMEDOUT) i2o_dma_free(&c->pdev->dev, &buffer); @@ -302,8 +304,7 @@ static int i2o_cfg_swul(unsigned long arg) struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; unsigned char maxfrag = 0, curfrag = 1; struct i2o_dma buffer; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; unsigned int status = 0, swlen = 0, fragsize = 8192; struct i2o_controller *c; int ret = 0; @@ -330,30 +331,30 @@ static int i2o_cfg_swul(unsigned long arg) if (!c) return -ENXIO; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -EBUSY; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) { - i2o_msg_nop(c, m); + i2o_msg_nop(c, msg); return -ENOMEM; } - writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_7, &msg->u.head[0]); - writel(I2O_CMD_SW_UPLOAD << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(i2o_config_driver.context, &msg->u.head[2]); - writel(0, &msg->u.head[3]); - writel((u32) kxfer.flags << 24 | (u32) kxfer. - sw_type << 16 | (u32) maxfrag << 8 | (u32) curfrag, - &msg->body[0]); - writel(swlen, &msg->body[1]); - writel(kxfer.sw_id, &msg->body[2]); - writel(0xD0000000 | fragsize, &msg->body[3]); - writel(buffer.phys, &msg->body[4]); + msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_SW_UPLOAD << 24 | HOST_TID << 12 | ADAPTER_TID); + msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); + msg->u.head[3] = cpu_to_le32(0); + msg->body[0] = + cpu_to_le32((u32) kxfer.flags << 24 | (u32) kxfer. + sw_type << 16 | (u32) maxfrag << 8 | (u32) curfrag); + msg->body[1] = cpu_to_le32(swlen); + msg->body[2] = cpu_to_le32(kxfer.sw_id); + msg->body[3] = cpu_to_le32(0xD0000000 | fragsize); + msg->body[4] = cpu_to_le32(buffer.phys); osm_debug("swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize); - status = i2o_msg_post_wait_mem(c, m, 60, &buffer); + status = i2o_msg_post_wait_mem(c, msg, 60, &buffer); if (status != I2O_POST_WAIT_OK) { if (status != -ETIMEDOUT) @@ -380,8 +381,7 @@ static int i2o_cfg_swdel(unsigned long arg) struct i2o_controller *c; struct i2o_sw_xfer kxfer; struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; unsigned int swlen; int token; @@ -395,21 +395,21 @@ static int i2o_cfg_swdel(unsigned long arg) if (!c) return -ENXIO; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -EBUSY; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_SW_REMOVE << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(i2o_config_driver.context, &msg->u.head[2]); - writel(0, &msg->u.head[3]); - writel((u32) kxfer.flags << 24 | (u32) kxfer.sw_type << 16, - &msg->body[0]); - writel(swlen, &msg->body[1]); - writel(kxfer.sw_id, &msg->body[2]); + msg->u.head[0] = cpu_to_le32(SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_SW_REMOVE << 24 | HOST_TID << 12 | ADAPTER_TID); + msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); + msg->u.head[3] = cpu_to_le32(0); + msg->body[0] = + cpu_to_le32((u32) kxfer.flags << 24 | (u32) kxfer.sw_type << 16); + msg->body[1] = cpu_to_le32(swlen); + msg->body[2] = cpu_to_le32(kxfer.sw_id); - token = i2o_msg_post_wait(c, m, 10); + token = i2o_msg_post_wait(c, msg, 10); if (token != I2O_POST_WAIT_OK) { osm_info("swdel failed, DetailedStatus = %d\n", token); @@ -423,25 +423,24 @@ static int i2o_cfg_validate(unsigned long arg) { int token; int iop = (int)arg; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; struct i2o_controller *c; c = i2o_find_iop(iop); if (!c) return -ENXIO; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -EBUSY; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_CONFIG_VALIDATE << 24 | HOST_TID << 12 | iop, - &msg->u.head[1]); - writel(i2o_config_driver.context, &msg->u.head[2]); - writel(0, &msg->u.head[3]); + msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_CONFIG_VALIDATE << 24 | HOST_TID << 12 | iop); + msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); + msg->u.head[3] = cpu_to_le32(0); - token = i2o_msg_post_wait(c, m, 10); + token = i2o_msg_post_wait(c, msg, 10); if (token != I2O_POST_WAIT_OK) { osm_info("Can't validate configuration, ErrorStatus = %d\n", @@ -454,8 +453,7 @@ static int i2o_cfg_validate(unsigned long arg) static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; struct i2o_evt_id __user *pdesc = (struct i2o_evt_id __user *)arg; struct i2o_evt_id kdesc; struct i2o_controller *c; @@ -474,18 +472,19 @@ static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp) if (!d) return -ENODEV; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -EBUSY; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | kdesc.tid, - &msg->u.head[1]); - writel(i2o_config_driver.context, &msg->u.head[2]); - writel(i2o_cntxt_list_add(c, fp->private_data), &msg->u.head[3]); - writel(kdesc.evt_mask, &msg->body[0]); + msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | + kdesc.tid); + msg->u.head[2] = cpu_to_le32(i2o_config_driver.context); + msg->u.head[3] = cpu_to_le32(i2o_cntxt_list_add(c, fp->private_data)); + msg->body[0] = cpu_to_le32(kdesc.evt_mask); - i2o_msg_post(c, m); + i2o_msg_post(c, msg); return 0; } @@ -537,7 +536,6 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, u32 sg_index = 0; i2o_status_block *sb; struct i2o_message *msg; - u32 m; unsigned int iop; cmd = (struct i2o_cmd_passthru32 __user *)arg; @@ -553,7 +551,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, return -ENXIO; } - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); sb = c->status_block.virt; @@ -595,8 +593,8 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, sg_offset = (msg->u.head[0] >> 4) & 0x0f; - writel(i2o_config_driver.context, &msg->u.s.icntxt); - writel(i2o_cntxt_list_add(c, reply), &msg->u.s.tcntxt); + msg->u.s.icntxt = cpu_to_le32(i2o_config_driver.context); + msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, reply)); memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); if (sg_offset) { @@ -662,7 +660,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, } } - rcode = i2o_msg_post_wait(c, m, 60); + rcode = i2o_msg_post_wait(c, msg, 60); if (rcode) goto sg_list_cleanup; @@ -780,8 +778,7 @@ static int i2o_cfg_passthru(unsigned long arg) u32 i = 0; void *p = NULL; i2o_status_block *sb; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; unsigned int iop; if (get_user(iop, &cmd->iop) || get_user(user_msg, &cmd->msg)) @@ -793,7 +790,7 @@ static int i2o_cfg_passthru(unsigned long arg) return -ENXIO; } - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); sb = c->status_block.virt; @@ -830,8 +827,8 @@ static int i2o_cfg_passthru(unsigned long arg) sg_offset = (msg->u.head[0] >> 4) & 0x0f; - writel(i2o_config_driver.context, &msg->u.s.icntxt); - writel(i2o_cntxt_list_add(c, reply), &msg->u.s.tcntxt); + msg->u.s.icntxt = cpu_to_le32(i2o_config_driver.context); + msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, reply)); memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); if (sg_offset) { @@ -894,7 +891,7 @@ static int i2o_cfg_passthru(unsigned long arg) } } - rcode = i2o_msg_post_wait(c, m, 60); + rcode = i2o_msg_post_wait(c, msg, 60); if (rcode) goto sg_list_cleanup; diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c index 9f1744c..7a784fd 100644 --- a/drivers/message/i2o/i2o_scsi.c +++ b/drivers/message/i2o/i2o_scsi.c @@ -510,8 +510,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, struct i2o_controller *c; struct i2o_device *i2o_dev; int tid; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; /* * ENABLE_DISCONNECT * SIMPLE_TAG @@ -519,7 +518,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, */ u32 scsi_flags = 0x20a00000; u32 sgl_offset; - u32 __iomem *mptr; + u32 *mptr; u32 cmd = I2O_CMD_SCSI_EXEC << 24; int rc = 0; @@ -576,8 +575,8 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, * throw it back to the scsi layer */ - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) { + msg = i2o_msg_get(c); + if (IS_ERR(msg)) { rc = SCSI_MLQUEUE_HOST_BUSY; goto exit; } @@ -617,16 +616,16 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, if (sgl_offset == SGL_OFFSET_10) sgl_offset = SGL_OFFSET_12; cmd = I2O_CMD_PRIVATE << 24; - writel(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC, mptr++); - writel(adpt_flags | tid, mptr++); + *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC); + *mptr++ = cpu_to_le32(adpt_flags | tid); } #endif - writel(cmd | HOST_TID << 12 | tid, &msg->u.head[1]); - writel(i2o_scsi_driver.context, &msg->u.s.icntxt); + msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid); + msg->u.s.icntxt = cpu_to_le32(i2o_scsi_driver.context); /* We want the SCSI control block back */ - writel(i2o_cntxt_list_add(c, SCpnt), &msg->u.s.tcntxt); + msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, SCpnt)); /* LSI_920_PCI_QUIRK * @@ -649,15 +648,15 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, } */ - writel(scsi_flags | SCpnt->cmd_len, mptr++); + *mptr++ = cpu_to_le32(scsi_flags | SCpnt->cmd_len); /* Write SCSI command into the message - always 16 byte block */ - memcpy_toio(mptr, SCpnt->cmnd, 16); + memcpy(mptr, SCpnt->cmnd, 16); mptr += 4; if (sgl_offset != SGL_OFFSET_0) { /* write size of data addressed by SGL */ - writel(SCpnt->request_bufflen, mptr++); + *mptr++ = cpu_to_le32(SCpnt->request_bufflen); /* Now fill in the SGList and command */ if (SCpnt->use_sg) { @@ -676,11 +675,11 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, } /* Stick the headers on */ - writel(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset, - &msg->u.head[0]); + msg->u.head[0] = + cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset); /* Queue the message */ - i2o_msg_post(c, m); + i2o_msg_post(c, msg); osm_debug("Issued %ld\n", SCpnt->serial_number); @@ -688,7 +687,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt, nomem: rc = -ENOMEM; - i2o_msg_nop(c, m); + i2o_msg_nop(c, msg); exit: return rc; @@ -709,8 +708,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt) { struct i2o_device *i2o_dev; struct i2o_controller *c; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; int tid; int status = FAILED; @@ -720,16 +718,16 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt) c = i2o_dev->iop; tid = i2o_dev->lct_data.tid; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) return SCSI_MLQUEUE_HOST_BUSY; - writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid, - &msg->u.head[1]); - writel(i2o_cntxt_list_get_ptr(c, SCpnt), &msg->body[0]); + msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid); + msg->body[0] = cpu_to_le32(i2o_cntxt_list_get_ptr(c, SCpnt)); - if (i2o_msg_post_wait(c, m, I2O_TIMEOUT_SCSI_SCB_ABORT)) + if (i2o_msg_post_wait(c, msg, I2O_TIMEOUT_SCSI_SCB_ABORT)) status = SUCCESS; return status; diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c index 4eb5325..f86abb4 100644 --- a/drivers/message/i2o/iop.c +++ b/drivers/message/i2o/iop.c @@ -47,27 +47,6 @@ static struct i2o_dma i2o_systab; static int i2o_hrt_get(struct i2o_controller *c); /** - * i2o_msg_nop - Returns a message which is not used - * @c: I2O controller from which the message was created - * @m: message which should be returned - * - * If you fetch a message via i2o_msg_get, and can't use it, you must - * return the message with this function. Otherwise the message frame - * is lost. - */ -void i2o_msg_nop(struct i2o_controller *c, u32 m) -{ - struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m); - - writel(THREE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(0, &msg->u.head[2]); - writel(0, &msg->u.head[3]); - i2o_msg_post(c, m); -}; - -/** * i2o_msg_get_wait - obtain an I2O message from the IOP * @c: I2O controller * @msg: pointer to a I2O message pointer @@ -81,22 +60,21 @@ void i2o_msg_nop(struct i2o_controller *c, u32 m) * address from the read port (see the i2o spec). If no message is * available returns I2O_QUEUE_EMPTY and msg is leaved untouched. */ -u32 i2o_msg_get_wait(struct i2o_controller *c, - struct i2o_message __iomem ** msg, int wait) +struct i2o_message *i2o_msg_get_wait(struct i2o_controller *c, int wait) { unsigned long timeout = jiffies + wait * HZ; - u32 m; + struct i2o_message *msg; - while ((m = i2o_msg_get(c, msg)) == I2O_QUEUE_EMPTY) { + while (IS_ERR(msg = i2o_msg_get(c))) { if (time_after(jiffies, timeout)) { osm_debug("%s: Timeout waiting for message frame.\n", c->name); - return I2O_QUEUE_EMPTY; + return ERR_PTR(-ETIMEDOUT); } schedule_timeout_uninterruptible(1); } - return m; + return msg; }; #if BITS_PER_LONG == 64 @@ -301,8 +279,7 @@ struct i2o_device *i2o_iop_find_device(struct i2o_controller *c, u16 tid) */ static int i2o_iop_quiesce(struct i2o_controller *c) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; i2o_status_block *sb = c->status_block.virt; int rc; @@ -313,16 +290,17 @@ static int i2o_iop_quiesce(struct i2o_controller *c) (sb->iop_state != ADAPTER_STATE_OPERATIONAL)) return 0; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_SYS_QUIESCE << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); + msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_SYS_QUIESCE << 24 | HOST_TID << 12 | + ADAPTER_TID); /* Long timeout needed for quiesce if lots of devices */ - if ((rc = i2o_msg_post_wait(c, m, 240))) + if ((rc = i2o_msg_post_wait(c, msg, 240))) osm_info("%s: Unable to quiesce (status=%#x).\n", c->name, -rc); else osm_debug("%s: Quiesced.\n", c->name); @@ -342,8 +320,7 @@ static int i2o_iop_quiesce(struct i2o_controller *c) */ static int i2o_iop_enable(struct i2o_controller *c) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; i2o_status_block *sb = c->status_block.virt; int rc; @@ -353,16 +330,17 @@ static int i2o_iop_enable(struct i2o_controller *c) if (sb->iop_state != ADAPTER_STATE_READY) return -EINVAL; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_SYS_ENABLE << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); + msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_SYS_ENABLE << 24 | HOST_TID << 12 | + ADAPTER_TID); /* How long of a timeout do we need? */ - if ((rc = i2o_msg_post_wait(c, m, 240))) + if ((rc = i2o_msg_post_wait(c, msg, 240))) osm_err("%s: Could not enable (status=%#x).\n", c->name, -rc); else osm_debug("%s: Enabled.\n", c->name); @@ -413,22 +391,22 @@ static inline void i2o_iop_enable_all(void) */ static int i2o_iop_clear(struct i2o_controller *c) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; int rc; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); /* Quiesce all IOPs first */ i2o_iop_quiesce_all(); - writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_ADAPTER_CLEAR << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); + msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_ADAPTER_CLEAR << 24 | HOST_TID << 12 | + ADAPTER_TID); - if ((rc = i2o_msg_post_wait(c, m, 30))) + if ((rc = i2o_msg_post_wait(c, msg, 30))) osm_info("%s: Unable to clear (status=%#x).\n", c->name, -rc); else osm_debug("%s: Cleared.\n", c->name); @@ -446,13 +424,13 @@ static int i2o_iop_clear(struct i2o_controller *c) * Clear and (re)initialize IOP's outbound queue and post the message * frames to the IOP. * - * Returns 0 on success or a negative errno code on failure. + * Returns 0 on success or negative error code on failure. */ static int i2o_iop_init_outbound_queue(struct i2o_controller *c) { - volatile u8 *status = c->status.virt; u32 m; - struct i2o_message __iomem *msg; + volatile u8 *status = c->status.virt; + struct i2o_message *msg; ulong timeout; int i; @@ -460,23 +438,24 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c) memset(c->status.virt, 0, 4); - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; - - writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); - writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(i2o_exec_driver.context, &msg->u.s.icntxt); - writel(0x00000000, &msg->u.s.tcntxt); - writel(PAGE_SIZE, &msg->body[0]); + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); + + msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | + ADAPTER_TID); + msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); + msg->u.s.tcntxt = cpu_to_le32(0x00000000); + msg->body[0] = cpu_to_le32(PAGE_SIZE); /* Outbound msg frame size in words and Initcode */ - writel(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]); - writel(0xd0000004, &msg->body[2]); - writel(i2o_dma_low(c->status.phys), &msg->body[3]); - writel(i2o_dma_high(c->status.phys), &msg->body[4]); + msg->body[1] = cpu_to_le32(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80); + msg->body[2] = cpu_to_le32(0xd0000004); + msg->body[3] = cpu_to_le32(i2o_dma_low(c->status.phys)); + msg->body[4] = cpu_to_le32(i2o_dma_high(c->status.phys)); - i2o_msg_post(c, m); + i2o_msg_post(c, msg); timeout = jiffies + I2O_TIMEOUT_INIT_OUTBOUND_QUEUE * HZ; while (*status <= I2O_CMD_IN_PROGRESS) { @@ -511,34 +490,34 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c) static int i2o_iop_reset(struct i2o_controller *c) { volatile u8 *status = c->status.virt; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; unsigned long timeout; i2o_status_block *sb = c->status_block.virt; int rc = 0; osm_debug("%s: Resetting controller\n", c->name); - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); memset(c->status_block.virt, 0, 8); /* Quiesce all IOPs first */ i2o_iop_quiesce_all(); - writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(i2o_exec_driver.context, &msg->u.s.icntxt); - writel(0, &msg->u.s.tcntxt); //FIXME: use reasonable transaction context - writel(0, &msg->body[0]); - writel(0, &msg->body[1]); - writel(i2o_dma_low(c->status.phys), &msg->body[2]); - writel(i2o_dma_high(c->status.phys), &msg->body[3]); + msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 | + ADAPTER_TID); + msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); + msg->u.s.tcntxt = cpu_to_le32(0x00000000); + msg->body[0] = cpu_to_le32(0x00000000); + msg->body[1] = cpu_to_le32(0x00000000); + msg->body[2] = cpu_to_le32(i2o_dma_low(c->status.phys)); + msg->body[3] = cpu_to_le32(i2o_dma_high(c->status.phys)); - i2o_msg_post(c, m); + i2o_msg_post(c, msg); /* Wait for a reply */ timeout = jiffies + I2O_TIMEOUT_RESET * HZ; @@ -567,18 +546,15 @@ static int i2o_iop_reset(struct i2o_controller *c) osm_debug("%s: Reset in progress, waiting for reboot...\n", c->name); - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET); - while (m == I2O_QUEUE_EMPTY) { + while (IS_ERR(msg = i2o_msg_get_wait(c, I2O_TIMEOUT_RESET))) { if (time_after(jiffies, timeout)) { osm_err("%s: IOP reset timeout.\n", c->name); - rc = -ETIMEDOUT; + rc = PTR_ERR(msg); goto exit; } schedule_timeout_uninterruptible(1); - - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET); } - i2o_msg_nop(c, m); + i2o_msg_nop(c, msg); /* from here all quiesce commands are safe */ c->no_quiesce = 0; @@ -686,8 +662,7 @@ static int i2o_iop_activate(struct i2o_controller *c) */ static int i2o_iop_systab_set(struct i2o_controller *c) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; i2o_status_block *sb = c->status_block.virt; struct device *dev = &c->pdev->dev; struct resource *root; @@ -735,20 +710,21 @@ static int i2o_iop_systab_set(struct i2o_controller *c) } } - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); i2o_systab.phys = dma_map_single(dev, i2o_systab.virt, i2o_systab.len, PCI_DMA_TODEVICE); if (!i2o_systab.phys) { - i2o_msg_nop(c, m); + i2o_msg_nop(c, msg); return -ENOMEM; } - writel(I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6, &msg->u.head[0]); - writel(I2O_CMD_SYS_TAB_SET << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); + msg->u.head[0] = cpu_to_le32(I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_SYS_TAB_SET << 24 | HOST_TID << 12 | + ADAPTER_TID); /* * Provide three SGL-elements: @@ -760,16 +736,16 @@ static int i2o_iop_systab_set(struct i2o_controller *c) * same table to everyone. We have to go remap it for them all */ - writel(c->unit + 2, &msg->body[0]); - writel(0, &msg->body[1]); - writel(0x54000000 | i2o_systab.len, &msg->body[2]); - writel(i2o_systab.phys, &msg->body[3]); - writel(0x54000000 | sb->current_mem_size, &msg->body[4]); - writel(sb->current_mem_base, &msg->body[5]); - writel(0xd4000000 | sb->current_io_size, &msg->body[6]); - writel(sb->current_io_base, &msg->body[6]); + msg->body[0] = cpu_to_le32(c->unit + 2); + msg->body[1] = cpu_to_le32(0x00000000); + msg->body[2] = cpu_to_le32(0x54000000 | i2o_systab.len); + msg->body[3] = cpu_to_le32(i2o_systab.phys); + msg->body[4] = cpu_to_le32(0x54000000 | sb->current_mem_size); + msg->body[5] = cpu_to_le32(sb->current_mem_base); + msg->body[6] = cpu_to_le32(0xd4000000 | sb->current_io_size); + msg->body[6] = cpu_to_le32(sb->current_io_base); - rc = i2o_msg_post_wait(c, m, 120); + rc = i2o_msg_post_wait(c, msg, 120); dma_unmap_single(dev, i2o_systab.phys, i2o_systab.len, PCI_DMA_TODEVICE); @@ -952,30 +928,30 @@ static int i2o_parse_hrt(struct i2o_controller *c) */ int i2o_status_get(struct i2o_controller *c) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; volatile u8 *status_block; unsigned long timeout; status_block = (u8 *) c->status_block.virt; memset(c->status_block.virt, 0, sizeof(i2o_status_block)); - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(i2o_exec_driver.context, &msg->u.s.icntxt); - writel(0, &msg->u.s.tcntxt); // FIXME: use resonable transaction context - writel(0, &msg->body[0]); - writel(0, &msg->body[1]); - writel(i2o_dma_low(c->status_block.phys), &msg->body[2]); - writel(i2o_dma_high(c->status_block.phys), &msg->body[3]); - writel(sizeof(i2o_status_block), &msg->body[4]); /* always 88 bytes */ + msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 | + ADAPTER_TID); + msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context); + msg->u.s.tcntxt = cpu_to_le32(0x00000000); + msg->body[0] = cpu_to_le32(0x00000000); + msg->body[1] = cpu_to_le32(0x00000000); + msg->body[2] = cpu_to_le32(i2o_dma_low(c->status_block.phys)); + msg->body[3] = cpu_to_le32(i2o_dma_high(c->status_block.phys)); + msg->body[4] = cpu_to_le32(sizeof(i2o_status_block)); /* always 88 bytes */ - i2o_msg_post(c, m); + i2o_msg_post(c, msg); /* Wait for a reply */ timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ; @@ -1013,20 +989,20 @@ static int i2o_hrt_get(struct i2o_controller *c) struct device *dev = &c->pdev->dev; for (i = 0; i < I2O_HRT_GET_TRIES; i++) { - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(SIX_WORD_MSG_SIZE | SGL_OFFSET_4, &msg->u.head[0]); - writel(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 | ADAPTER_TID, - &msg->u.head[1]); - writel(0xd0000000 | c->hrt.len, &msg->body[0]); - writel(c->hrt.phys, &msg->body[1]); + msg->u.head[0] = cpu_to_le32(SIX_WORD_MSG_SIZE | SGL_OFFSET_4); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 | + ADAPTER_TID); + msg->body[0] = cpu_to_le32(0xd0000000 | c->hrt.len); + msg->body[1] = cpu_to_le32(c->hrt.phys); - rc = i2o_msg_post_wait_mem(c, m, 20, &c->hrt); + rc = i2o_msg_post_wait_mem(c, msg, 20, &c->hrt); if (rc < 0) { osm_err("%s: Unable to get HRT (status=%#x)\n", c->name, @@ -1056,6 +1032,7 @@ static int i2o_hrt_get(struct i2o_controller *c) */ void i2o_iop_free(struct i2o_controller *c) { + i2o_pool_free(&c->in_msg); kfree(c); }; @@ -1080,7 +1057,7 @@ static struct class *i2o_controller_class; * i2o_iop_alloc - Allocate and initialize a i2o_controller struct * * Allocate the necessary memory for a i2o_controller struct and - * initialize the lists. + * initialize the lists and message mempool. * * Returns a pointer to the I2O controller or a negative error code on * failure. @@ -1089,6 +1066,7 @@ struct i2o_controller *i2o_iop_alloc(void) { static int unit = 0; /* 0 and 1 are NULL IOP and Local Host */ struct i2o_controller *c; + char poolname[32]; c = kmalloc(sizeof(*c), GFP_KERNEL); if (!c) { @@ -1098,11 +1076,20 @@ struct i2o_controller *i2o_iop_alloc(void) } memset(c, 0, sizeof(*c)); + c->unit = unit++; + sprintf(c->name, "iop%d", c->unit); + + snprintf(poolname, sizeof(poolname), "i2o_%s_msg_inpool", c->name); + if (i2o_pool_alloc + (&c->in_msg, poolname, I2O_INBOUND_MSG_FRAME_SIZE * 4, + I2O_MSG_INPOOL_MIN)) { + kfree(c); + return ERR_PTR(-ENOMEM); + }; + INIT_LIST_HEAD(&c->devices); spin_lock_init(&c->lock); init_MUTEX(&c->lct_lock); - c->unit = unit++; - sprintf(c->name, "iop%d", c->unit); device_initialize(&c->device); @@ -1199,28 +1186,27 @@ int i2o_iop_add(struct i2o_controller *c) * is waited for, or expected. If you do not want further notifications, * call the i2o_event_register again with a evt_mask of 0. * - * Returns 0 on success or -ETIMEDOUT if no message could be fetched for - * sending the request. + * Returns 0 on success or negative error code on failure. */ int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv, int tcntxt, u32 evt_mask) { struct i2o_controller *c = dev->iop; - struct i2o_message __iomem *msg; - u32 m; + struct i2o_message *msg; - m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); - if (m == I2O_QUEUE_EMPTY) - return -ETIMEDOUT; + msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); + if (IS_ERR(msg)) + return PTR_ERR(msg); - writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); - writel(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev->lct_data. - tid, &msg->u.head[1]); - writel(drv->context, &msg->u.s.icntxt); - writel(tcntxt, &msg->u.s.tcntxt); - writel(evt_mask, &msg->body[0]); + msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); + msg->u.head[1] = + cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev-> + lct_data.tid); + msg->u.s.icntxt = cpu_to_le32(drv->context); + msg->u.s.tcntxt = cpu_to_le32(tcntxt); + msg->body[0] = cpu_to_le32(evt_mask); - i2o_msg_post(c, m); + i2o_msg_post(c, msg); return 0; }; diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c index ee7075f..329d482 100644 --- a/drivers/message/i2o/pci.c +++ b/drivers/message/i2o/pci.c @@ -483,4 +483,5 @@ void __exit i2o_pci_exit(void) { pci_unregister_driver(&i2o_pci_driver); }; + MODULE_DEVICE_TABLE(pci, i2o_pci_ids); diff --git a/include/linux/i2o.h b/include/linux/i2o.h index d79c8a4..9e359a9 100644 --- a/include/linux/i2o.h +++ b/include/linux/i2o.h @@ -30,6 +30,7 @@ #include #include #include /* work_struct */ +#include #include #include /* Needed for MUTEX init macros */ @@ -38,1091 +39,1219 @@ #define I2O_QUEUE_EMPTY 0xffffffff /* - * Message structures + * Cache strategies */ -struct i2o_message { - union { - struct { - u8 version_offset; - u8 flags; - u16 size; - u32 target_tid:12; - u32 init_tid:12; - u32 function:8; - u32 icntxt; /* initiator context */ - u32 tcntxt; /* transaction context */ - } s; - u32 head[4]; - } u; - /* List follows */ - u32 body[0]; -}; -/* - * Each I2O device entity has one of these. There is one per device. +/* The NULL strategy leaves everything up to the controller. This tends to be a + * pessimal but functional choice. */ -struct i2o_device { - i2o_lct_entry lct_data; /* Device LCT information */ - - struct i2o_controller *iop; /* Controlling IOP */ - struct list_head list; /* node in IOP devices list */ - - struct device device; - - struct semaphore lock; /* device lock */ -}; +#define CACHE_NULL 0 +/* Prefetch data when reading. We continually attempt to load the next 32 sectors + * into the controller cache. + */ +#define CACHE_PREFETCH 1 +/* Prefetch data when reading. We sometimes attempt to load the next 32 sectors + * into the controller cache. When an I/O is less <= 8K we assume its probably + * not sequential and don't prefetch (default) + */ +#define CACHE_SMARTFETCH 2 +/* Data is written to the cache and then out on to the disk. The I/O must be + * physically on the medium before the write is acknowledged (default without + * NVRAM) + */ +#define CACHE_WRITETHROUGH 17 +/* Data is written to the cache and then out on to the disk. The controller + * is permitted to write back the cache any way it wants. (default if battery + * backed NVRAM is present). It can be useful to set this for swap regardless of + * battery state. + */ +#define CACHE_WRITEBACK 18 +/* Optimise for under powered controllers, especially on RAID1 and RAID0. We + * write large I/O's directly to disk bypassing the cache to avoid the extra + * memory copy hits. Small writes are writeback cached + */ +#define CACHE_SMARTBACK 19 +/* Optimise for under powered controllers, especially on RAID1 and RAID0. We + * write large I/O's directly to disk bypassing the cache to avoid the extra + * memory copy hits. Small writes are writethrough cached. Suitable for devices + * lacking battery backup + */ +#define CACHE_SMARTTHROUGH 20 /* - * Event structure provided to the event handling function + * Ioctl structures */ -struct i2o_event { - struct work_struct work; - struct i2o_device *i2o_dev; /* I2O device pointer from which the - event reply was initiated */ - u16 size; /* Size of data in 32-bit words */ - u32 tcntxt; /* Transaction context used at - registration */ - u32 event_indicator; /* Event indicator from reply */ - u32 data[0]; /* Event data from reply */ -}; + +#define BLKI2OGRSTRAT _IOR('2', 1, int) +#define BLKI2OGWSTRAT _IOR('2', 2, int) +#define BLKI2OSRSTRAT _IOW('2', 3, int) +#define BLKI2OSWSTRAT _IOW('2', 4, int) /* - * I2O classes which could be handled by the OSM + * I2O Function codes */ -struct i2o_class_id { - u16 class_id:12; -}; /* - * I2O driver structure for OSMs + * Executive Class */ -struct i2o_driver { - char *name; /* OSM name */ - int context; /* Low 8 bits of the transaction info */ - struct i2o_class_id *classes; /* I2O classes that this OSM handles */ - - /* Message reply handler */ - int (*reply) (struct i2o_controller *, u32, struct i2o_message *); - - /* Event handler */ - void (*event) (struct i2o_event *); - - struct workqueue_struct *event_queue; /* Event queue */ - - struct device_driver driver; - - /* notification of changes */ - void (*notify_controller_add) (struct i2o_controller *); - void (*notify_controller_remove) (struct i2o_controller *); - void (*notify_device_add) (struct i2o_device *); - void (*notify_device_remove) (struct i2o_device *); - - struct semaphore lock; -}; +#define I2O_CMD_ADAPTER_ASSIGN 0xB3 +#define I2O_CMD_ADAPTER_READ 0xB2 +#define I2O_CMD_ADAPTER_RELEASE 0xB5 +#define I2O_CMD_BIOS_INFO_SET 0xA5 +#define I2O_CMD_BOOT_DEVICE_SET 0xA7 +#define I2O_CMD_CONFIG_VALIDATE 0xBB +#define I2O_CMD_CONN_SETUP 0xCA +#define I2O_CMD_DDM_DESTROY 0xB1 +#define I2O_CMD_DDM_ENABLE 0xD5 +#define I2O_CMD_DDM_QUIESCE 0xC7 +#define I2O_CMD_DDM_RESET 0xD9 +#define I2O_CMD_DDM_SUSPEND 0xAF +#define I2O_CMD_DEVICE_ASSIGN 0xB7 +#define I2O_CMD_DEVICE_RELEASE 0xB9 +#define I2O_CMD_HRT_GET 0xA8 +#define I2O_CMD_ADAPTER_CLEAR 0xBE +#define I2O_CMD_ADAPTER_CONNECT 0xC9 +#define I2O_CMD_ADAPTER_RESET 0xBD +#define I2O_CMD_LCT_NOTIFY 0xA2 +#define I2O_CMD_OUTBOUND_INIT 0xA1 +#define I2O_CMD_PATH_ENABLE 0xD3 +#define I2O_CMD_PATH_QUIESCE 0xC5 +#define I2O_CMD_PATH_RESET 0xD7 +#define I2O_CMD_STATIC_MF_CREATE 0xDD +#define I2O_CMD_STATIC_MF_RELEASE 0xDF +#define I2O_CMD_STATUS_GET 0xA0 +#define I2O_CMD_SW_DOWNLOAD 0xA9 +#define I2O_CMD_SW_UPLOAD 0xAB +#define I2O_CMD_SW_REMOVE 0xAD +#define I2O_CMD_SYS_ENABLE 0xD1 +#define I2O_CMD_SYS_MODIFY 0xC1 +#define I2O_CMD_SYS_QUIESCE 0xC3 +#define I2O_CMD_SYS_TAB_SET 0xA3 /* - * Contains DMA mapped address information + * Utility Class */ -struct i2o_dma { - void *virt; - dma_addr_t phys; - size_t len; -}; +#define I2O_CMD_UTIL_NOP 0x00 +#define I2O_CMD_UTIL_ABORT 0x01 +#define I2O_CMD_UTIL_CLAIM 0x09 +#define I2O_CMD_UTIL_RELEASE 0x0B +#define I2O_CMD_UTIL_PARAMS_GET 0x06 +#define I2O_CMD_UTIL_PARAMS_SET 0x05 +#define I2O_CMD_UTIL_EVT_REGISTER 0x13 +#define I2O_CMD_UTIL_EVT_ACK 0x14 +#define I2O_CMD_UTIL_CONFIG_DIALOG 0x10 +#define I2O_CMD_UTIL_DEVICE_RESERVE 0x0D +#define I2O_CMD_UTIL_DEVICE_RELEASE 0x0F +#define I2O_CMD_UTIL_LOCK 0x17 +#define I2O_CMD_UTIL_LOCK_RELEASE 0x19 +#define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15 /* - * Contains IO mapped address information + * SCSI Host Bus Adapter Class */ -struct i2o_io { - void __iomem *virt; - unsigned long phys; - unsigned long len; -}; +#define I2O_CMD_SCSI_EXEC 0x81 +#define I2O_CMD_SCSI_ABORT 0x83 +#define I2O_CMD_SCSI_BUSRESET 0x27 /* - * Context queue entry, used for 32-bit context on 64-bit systems + * Bus Adapter Class */ -struct i2o_context_list_element { - struct list_head list; - u32 context; - void *ptr; - unsigned long timestamp; -}; +#define I2O_CMD_BUS_ADAPTER_RESET 0x85 +#define I2O_CMD_BUS_RESET 0x87 +#define I2O_CMD_BUS_SCAN 0x89 +#define I2O_CMD_BUS_QUIESCE 0x8b /* - * Each I2O controller has one of these objects + * Random Block Storage Class */ -struct i2o_controller { - char name[16]; - int unit; - int type; +#define I2O_CMD_BLOCK_READ 0x30 +#define I2O_CMD_BLOCK_WRITE 0x31 +#define I2O_CMD_BLOCK_CFLUSH 0x37 +#define I2O_CMD_BLOCK_MLOCK 0x49 +#define I2O_CMD_BLOCK_MUNLOCK 0x4B +#define I2O_CMD_BLOCK_MMOUNT 0x41 +#define I2O_CMD_BLOCK_MEJECT 0x43 +#define I2O_CMD_BLOCK_POWER 0x70 - struct pci_dev *pdev; /* PCI device */ +#define I2O_CMD_PRIVATE 0xFF - unsigned int promise:1; /* Promise controller */ - unsigned int adaptec:1; /* DPT / Adaptec controller */ - unsigned int raptor:1; /* split bar */ - unsigned int no_quiesce:1; /* dont quiesce before reset */ - unsigned int short_req:1; /* use small block sizes */ - unsigned int limit_sectors:1; /* limit number of sectors / request */ - unsigned int pae_support:1; /* controller has 64-bit SGL support */ +/* Command status values */ - struct list_head devices; /* list of I2O devices */ - struct list_head list; /* Controller list */ +#define I2O_CMD_IN_PROGRESS 0x01 +#define I2O_CMD_REJECTED 0x02 +#define I2O_CMD_FAILED 0x03 +#define I2O_CMD_COMPLETED 0x04 - void __iomem *in_port; /* Inbout port address */ - void __iomem *out_port; /* Outbound port address */ - void __iomem *irq_status; /* Interrupt status register address */ - void __iomem *irq_mask; /* Interrupt mask register address */ +/* I2O API function return values */ - /* Dynamic LCT related data */ +#define I2O_RTN_NO_ERROR 0 +#define I2O_RTN_NOT_INIT 1 +#define I2O_RTN_FREE_Q_EMPTY 2 +#define I2O_RTN_TCB_ERROR 3 +#define I2O_RTN_TRANSACTION_ERROR 4 +#define I2O_RTN_ADAPTER_ALREADY_INIT 5 +#define I2O_RTN_MALLOC_ERROR 6 +#define I2O_RTN_ADPTR_NOT_REGISTERED 7 +#define I2O_RTN_MSG_REPLY_TIMEOUT 8 +#define I2O_RTN_NO_STATUS 9 +#define I2O_RTN_NO_FIRM_VER 10 +#define I2O_RTN_NO_LINK_SPEED 11 - struct i2o_dma status; /* IOP status block */ +/* Reply message status defines for all messages */ - struct i2o_dma hrt; /* HW Resource Table */ - i2o_lct *lct; /* Logical Config Table */ - struct i2o_dma dlct; /* Temp LCT */ - struct semaphore lct_lock; /* Lock for LCT updates */ - struct i2o_dma status_block; /* IOP status block */ +#define I2O_REPLY_STATUS_SUCCESS 0x00 +#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01 +#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 +#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03 +#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04 +#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05 +#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06 +#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08 +#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09 +#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A +#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0B +#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80 - struct i2o_io base; /* controller messaging unit */ - struct i2o_io in_queue; /* inbound message queue Host->IOP */ - struct i2o_dma out_queue; /* outbound message queue IOP->Host */ +/* Status codes and Error Information for Parameter functions */ - unsigned int battery:1; /* Has a battery backup */ - unsigned int io_alloc:1; /* An I/O resource was allocated */ - unsigned int mem_alloc:1; /* A memory resource was allocated */ +#define I2O_PARAMS_STATUS_SUCCESS 0x00 +#define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01 +#define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02 +#define I2O_PARAMS_STATUS_BUFFER_FULL 0x03 +#define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04 +#define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05 +#define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE 0x06 +#define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS 0x07 +#define I2O_PARAMS_STATUS_INVALID_GROUP_ID 0x08 +#define I2O_PARAMS_STATUS_INVALID_OPERATION 0x09 +#define I2O_PARAMS_STATUS_NO_KEY_FIELD 0x0A +#define I2O_PARAMS_STATUS_NO_SUCH_FIELD 0x0B +#define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP 0x0C +#define I2O_PARAMS_STATUS_OPERATION_ERROR 0x0D +#define I2O_PARAMS_STATUS_SCALAR_ERROR 0x0E +#define I2O_PARAMS_STATUS_TABLE_ERROR 0x0F +#define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE 0x10 - struct resource io_resource; /* I/O resource allocated to the IOP */ - struct resource mem_resource; /* Mem resource allocated to the IOP */ +/* DetailedStatusCode defines for Executive, DDM, Util and Transaction error + * messages: Table 3-2 Detailed Status Codes.*/ - struct device device; - struct class_device *classdev; /* I2O controller class device */ - struct i2o_device *exec; /* Executive */ -#if BITS_PER_LONG == 64 - spinlock_t context_list_lock; /* lock for context_list */ - atomic_t context_list_counter; /* needed for unique contexts */ - struct list_head context_list; /* list of context id's - and pointers */ -#endif - spinlock_t lock; /* lock for controller - configuration */ +#define I2O_DSC_SUCCESS 0x0000 +#define I2O_DSC_BAD_KEY 0x0002 +#define I2O_DSC_TCL_ERROR 0x0003 +#define I2O_DSC_REPLY_BUFFER_FULL 0x0004 +#define I2O_DSC_NO_SUCH_PAGE 0x0005 +#define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x0006 +#define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x0007 +#define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x0009 +#define I2O_DSC_UNSUPPORTED_FUNCTION 0x000A +#define I2O_DSC_DEVICE_LOCKED 0x000B +#define I2O_DSC_DEVICE_RESET 0x000C +#define I2O_DSC_INAPPROPRIATE_FUNCTION 0x000D +#define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x000E +#define I2O_DSC_INVALID_MESSAGE_FLAGS 0x000F +#define I2O_DSC_INVALID_OFFSET 0x0010 +#define I2O_DSC_INVALID_PARAMETER 0x0011 +#define I2O_DSC_INVALID_REQUEST 0x0012 +#define I2O_DSC_INVALID_TARGET_ADDRESS 0x0013 +#define I2O_DSC_MESSAGE_TOO_LARGE 0x0014 +#define I2O_DSC_MESSAGE_TOO_SMALL 0x0015 +#define I2O_DSC_MISSING_PARAMETER 0x0016 +#define I2O_DSC_TIMEOUT 0x0017 +#define I2O_DSC_UNKNOWN_ERROR 0x0018 +#define I2O_DSC_UNKNOWN_FUNCTION 0x0019 +#define I2O_DSC_UNSUPPORTED_VERSION 0x001A +#define I2O_DSC_DEVICE_BUSY 0x001B +#define I2O_DSC_DEVICE_NOT_AVAILABLE 0x001C - void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */ -}; +/* DetailedStatusCode defines for Block Storage Operation: Table 6-7 Detailed + Status Codes.*/ -/* - * I2O System table entry - * - * The system table contains information about all the IOPs in the - * system. It is sent to all IOPs so that they can create peer2peer - * connections between them. - */ -struct i2o_sys_tbl_entry { - u16 org_id; - u16 reserved1; - u32 iop_id:12; - u32 reserved2:20; - u16 seg_num:12; - u16 i2o_version:4; - u8 iop_state; - u8 msg_type; - u16 frame_size; - u16 reserved3; - u32 last_changed; - u32 iop_capabilities; - u32 inbound_low; - u32 inbound_high; -}; +#define I2O_BSA_DSC_SUCCESS 0x0000 +#define I2O_BSA_DSC_MEDIA_ERROR 0x0001 +#define I2O_BSA_DSC_ACCESS_ERROR 0x0002 +#define I2O_BSA_DSC_DEVICE_FAILURE 0x0003 +#define I2O_BSA_DSC_DEVICE_NOT_READY 0x0004 +#define I2O_BSA_DSC_MEDIA_NOT_PRESENT 0x0005 +#define I2O_BSA_DSC_MEDIA_LOCKED 0x0006 +#define I2O_BSA_DSC_MEDIA_FAILURE 0x0007 +#define I2O_BSA_DSC_PROTOCOL_FAILURE 0x0008 +#define I2O_BSA_DSC_BUS_FAILURE 0x0009 +#define I2O_BSA_DSC_ACCESS_VIOLATION 0x000A +#define I2O_BSA_DSC_WRITE_PROTECTED 0x000B +#define I2O_BSA_DSC_DEVICE_RESET 0x000C +#define I2O_BSA_DSC_VOLUME_CHANGED 0x000D +#define I2O_BSA_DSC_TIMEOUT 0x000E -struct i2o_sys_tbl { - u8 num_entries; - u8 version; - u16 reserved1; - u32 change_ind; - u32 reserved2; - u32 reserved3; - struct i2o_sys_tbl_entry iops[0]; -}; +/* FailureStatusCodes, Table 3-3 Message Failure Codes */ -extern struct list_head i2o_controllers; +#define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED 0x81 +#define I2O_FSC_TRANSPORT_SERVICE_TERMINATED 0x82 +#define I2O_FSC_TRANSPORT_CONGESTION 0x83 +#define I2O_FSC_TRANSPORT_FAILURE 0x84 +#define I2O_FSC_TRANSPORT_STATE_ERROR 0x85 +#define I2O_FSC_TRANSPORT_TIME_OUT 0x86 +#define I2O_FSC_TRANSPORT_ROUTING_FAILURE 0x87 +#define I2O_FSC_TRANSPORT_INVALID_VERSION 0x88 +#define I2O_FSC_TRANSPORT_INVALID_OFFSET 0x89 +#define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS 0x8A +#define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL 0x8B +#define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE 0x8C +#define I2O_FSC_TRANSPORT_INVALID_TARGET_ID 0x8D +#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID 0x8E +#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F +#define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE 0xFF -/* Message functions */ -static inline u32 i2o_msg_get(struct i2o_controller *, - struct i2o_message __iomem **); -extern u32 i2o_msg_get_wait(struct i2o_controller *, - struct i2o_message __iomem **, int); -static inline void i2o_msg_post(struct i2o_controller *, u32); -static inline int i2o_msg_post_wait(struct i2o_controller *, u32, - unsigned long); -extern int i2o_msg_post_wait_mem(struct i2o_controller *, u32, unsigned long, - struct i2o_dma *); -extern void i2o_msg_nop(struct i2o_controller *, u32); -static inline void i2o_flush_reply(struct i2o_controller *, u32); +/* Device Claim Types */ +#define I2O_CLAIM_PRIMARY 0x01000000 +#define I2O_CLAIM_MANAGEMENT 0x02000000 +#define I2O_CLAIM_AUTHORIZED 0x03000000 +#define I2O_CLAIM_SECONDARY 0x04000000 -/* IOP functions */ -extern int i2o_status_get(struct i2o_controller *); +/* Message header defines for VersionOffset */ +#define I2OVER15 0x0001 +#define I2OVER20 0x0002 -extern int i2o_event_register(struct i2o_device *, struct i2o_driver *, int, - u32); -extern struct i2o_device *i2o_iop_find_device(struct i2o_controller *, u16); -extern struct i2o_controller *i2o_find_iop(int); +/* Default is 1.5 */ +#define I2OVERSION I2OVER15 -/* Functions needed for handling 64-bit pointers in 32-bit context */ -#if BITS_PER_LONG == 64 -extern u32 i2o_cntxt_list_add(struct i2o_controller *, void *); -extern void *i2o_cntxt_list_get(struct i2o_controller *, u32); -extern u32 i2o_cntxt_list_remove(struct i2o_controller *, void *); -extern u32 i2o_cntxt_list_get_ptr(struct i2o_controller *, void *); +#define SGL_OFFSET_0 I2OVERSION +#define SGL_OFFSET_4 (0x0040 | I2OVERSION) +#define SGL_OFFSET_5 (0x0050 | I2OVERSION) +#define SGL_OFFSET_6 (0x0060 | I2OVERSION) +#define SGL_OFFSET_7 (0x0070 | I2OVERSION) +#define SGL_OFFSET_8 (0x0080 | I2OVERSION) +#define SGL_OFFSET_9 (0x0090 | I2OVERSION) +#define SGL_OFFSET_10 (0x00A0 | I2OVERSION) +#define SGL_OFFSET_11 (0x00B0 | I2OVERSION) +#define SGL_OFFSET_12 (0x00C0 | I2OVERSION) +#define SGL_OFFSET(x) (((x)<<4) | I2OVERSION) -static inline u32 i2o_ptr_low(void *ptr) -{ - return (u32) (u64) ptr; -}; +/* Transaction Reply Lists (TRL) Control Word structure */ +#define TRL_SINGLE_FIXED_LENGTH 0x00 +#define TRL_SINGLE_VARIABLE_LENGTH 0x40 +#define TRL_MULTIPLE_FIXED_LENGTH 0x80 -static inline u32 i2o_ptr_high(void *ptr) -{ - return (u32) ((u64) ptr >> 32); -}; + /* msg header defines for MsgFlags */ +#define MSG_STATIC 0x0100 +#define MSG_64BIT_CNTXT 0x0200 +#define MSG_MULTI_TRANS 0x1000 +#define MSG_FAIL 0x2000 +#define MSG_FINAL 0x4000 +#define MSG_REPLY 0x8000 -static inline u32 i2o_dma_low(dma_addr_t dma_addr) -{ - return (u32) (u64) dma_addr; -}; + /* minimum size msg */ +#define THREE_WORD_MSG_SIZE 0x00030000 +#define FOUR_WORD_MSG_SIZE 0x00040000 +#define FIVE_WORD_MSG_SIZE 0x00050000 +#define SIX_WORD_MSG_SIZE 0x00060000 +#define SEVEN_WORD_MSG_SIZE 0x00070000 +#define EIGHT_WORD_MSG_SIZE 0x00080000 +#define NINE_WORD_MSG_SIZE 0x00090000 +#define TEN_WORD_MSG_SIZE 0x000A0000 +#define ELEVEN_WORD_MSG_SIZE 0x000B0000 +#define I2O_MESSAGE_SIZE(x) ((x)<<16) -static inline u32 i2o_dma_high(dma_addr_t dma_addr) -{ - return (u32) ((u64) dma_addr >> 32); -}; -#else -static inline u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr) -{ - return (u32) ptr; -}; +/* special TID assignments */ +#define ADAPTER_TID 0 +#define HOST_TID 1 -static inline void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context) -{ - return (void *)context; -}; +/* outbound queue defines */ +#define I2O_MAX_OUTBOUND_MSG_FRAMES 128 +#define I2O_OUTBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */ -static inline u32 i2o_cntxt_list_remove(struct i2o_controller *c, void *ptr) -{ - return (u32) ptr; -}; +/* inbound queue definitions */ +#define I2O_MSG_INPOOL_MIN 32 +#define I2O_INBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */ -static inline u32 i2o_cntxt_list_get_ptr(struct i2o_controller *c, void *ptr) -{ - return (u32) ptr; -}; +#define I2O_POST_WAIT_OK 0 +#define I2O_POST_WAIT_TIMEOUT -ETIMEDOUT -static inline u32 i2o_ptr_low(void *ptr) -{ - return (u32) ptr; -}; +#define I2O_CONTEXT_LIST_MIN_LENGTH 15 +#define I2O_CONTEXT_LIST_USED 0x01 +#define I2O_CONTEXT_LIST_DELETED 0x02 -static inline u32 i2o_ptr_high(void *ptr) -{ - return 0; -}; +/* timeouts */ +#define I2O_TIMEOUT_INIT_OUTBOUND_QUEUE 15 +#define I2O_TIMEOUT_MESSAGE_GET 5 +#define I2O_TIMEOUT_RESET 30 +#define I2O_TIMEOUT_STATUS_GET 5 +#define I2O_TIMEOUT_LCT_GET 360 +#define I2O_TIMEOUT_SCSI_SCB_ABORT 240 -static inline u32 i2o_dma_low(dma_addr_t dma_addr) -{ - return (u32) dma_addr; -}; +/* retries */ +#define I2O_HRT_GET_TRIES 3 +#define I2O_LCT_GET_TRIES 3 -static inline u32 i2o_dma_high(dma_addr_t dma_addr) -{ - return 0; -}; -#endif +/* defines for max_sectors and max_phys_segments */ +#define I2O_MAX_SECTORS 1024 +#define I2O_MAX_SECTORS_LIMITED 256 +#define I2O_MAX_PHYS_SEGMENTS MAX_PHYS_SEGMENTS -/** - * i2o_sg_tablesize - Calculate the maximum number of elements in a SGL - * @c: I2O controller for which the calculation should be done - * @body_size: maximum body size used for message in 32-bit words. - * - * Return the maximum number of SG elements in a SG list. +/* + * Message structures */ -static inline u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size) -{ - i2o_status_block *sb = c->status_block.virt; - u16 sg_count = - (sb->inbound_frame_size - sizeof(struct i2o_message) / 4) - - body_size; - - if (c->pae_support) { - /* - * for 64-bit a SG attribute element must be added and each - * SG element needs 12 bytes instead of 8. - */ - sg_count -= 2; - sg_count /= 3; - } else - sg_count /= 2; - - if (c->short_req && (sg_count > 8)) - sg_count = 8; +struct i2o_message { + union { + struct { + u8 version_offset; + u8 flags; + u16 size; + u32 target_tid:12; + u32 init_tid:12; + u32 function:8; + u32 icntxt; /* initiator context */ + u32 tcntxt; /* transaction context */ + } s; + u32 head[4]; + } u; + /* List follows */ + u32 body[0]; +}; - return sg_count; +/* MFA and I2O message used by mempool */ +struct i2o_msg_mfa { + u32 mfa; /* MFA returned by the controller */ + struct i2o_message msg; /* I2O message */ }; -/** - * i2o_dma_map_single - Map pointer to controller and fill in I2O message. - * @c: I2O controller - * @ptr: pointer to the data which should be mapped - * @size: size of data in bytes - * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE - * @sg_ptr: pointer to the SG list inside the I2O message - * - * This function does all necessary DMA handling and also writes the I2O - * SGL elements into the I2O message. For details on DMA handling see also - * dma_map_single(). The pointer sg_ptr will only be set to the end of the - * SG list if the allocation was successful. - * - * Returns DMA address which must be checked for failures using - * dma_mapping_error(). +/* + * Each I2O device entity has one of these. There is one per device. */ -static inline dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr, - size_t size, - enum dma_data_direction direction, - u32 __iomem ** sg_ptr) -{ - u32 sg_flags; - u32 __iomem *mptr = *sg_ptr; - dma_addr_t dma_addr; +struct i2o_device { + i2o_lct_entry lct_data; /* Device LCT information */ - switch (direction) { - case DMA_TO_DEVICE: - sg_flags = 0xd4000000; - break; - case DMA_FROM_DEVICE: - sg_flags = 0xd0000000; - break; - default: - return 0; - } + struct i2o_controller *iop; /* Controlling IOP */ + struct list_head list; /* node in IOP devices list */ - dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction); - if (!dma_mapping_error(dma_addr)) { -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if ((sizeof(dma_addr_t) > 4) && c->pae_support) { - writel(0x7C020002, mptr++); - writel(PAGE_SIZE, mptr++); - } -#endif + struct device device; - writel(sg_flags | size, mptr++); - writel(i2o_dma_low(dma_addr), mptr++); -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if ((sizeof(dma_addr_t) > 4) && c->pae_support) - writel(i2o_dma_high(dma_addr), mptr++); -#endif - *sg_ptr = mptr; - } - return dma_addr; + struct semaphore lock; /* device lock */ }; -/** - * i2o_dma_map_sg - Map a SG List to controller and fill in I2O message. - * @c: I2O controller - * @sg: SG list to be mapped - * @sg_count: number of elements in the SG list - * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE - * @sg_ptr: pointer to the SG list inside the I2O message - * - * This function does all necessary DMA handling and also writes the I2O - * SGL elements into the I2O message. For details on DMA handling see also - * dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG - * list if the allocation was successful. - * - * Returns 0 on failure or 1 on success. +/* + * Event structure provided to the event handling function */ -static inline int i2o_dma_map_sg(struct i2o_controller *c, - struct scatterlist *sg, int sg_count, - enum dma_data_direction direction, - u32 __iomem ** sg_ptr) -{ - u32 sg_flags; - u32 __iomem *mptr = *sg_ptr; - - switch (direction) { - case DMA_TO_DEVICE: - sg_flags = 0x14000000; - break; - case DMA_FROM_DEVICE: - sg_flags = 0x10000000; - break; - default: - return 0; - } - - sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction); - if (!sg_count) - return 0; - -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if ((sizeof(dma_addr_t) > 4) && c->pae_support) { - writel(0x7C020002, mptr++); - writel(PAGE_SIZE, mptr++); - } -#endif - - while (sg_count-- > 0) { - if (!sg_count) - sg_flags |= 0xC0000000; - writel(sg_flags | sg_dma_len(sg), mptr++); - writel(i2o_dma_low(sg_dma_address(sg)), mptr++); -#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 - if ((sizeof(dma_addr_t) > 4) && c->pae_support) - writel(i2o_dma_high(sg_dma_address(sg)), mptr++); -#endif - sg++; - } - *sg_ptr = mptr; +struct i2o_event { + struct work_struct work; + struct i2o_device *i2o_dev; /* I2O device pointer from which the + event reply was initiated */ + u16 size; /* Size of data in 32-bit words */ + u32 tcntxt; /* Transaction context used at + registration */ + u32 event_indicator; /* Event indicator from reply */ + u32 data[0]; /* Event data from reply */ +}; - return 1; +/* + * I2O classes which could be handled by the OSM + */ +struct i2o_class_id { + u16 class_id:12; }; -/** - * i2o_dma_alloc - Allocate DMA memory - * @dev: struct device pointer to the PCI device of the I2O controller - * @addr: i2o_dma struct which should get the DMA buffer - * @len: length of the new DMA memory - * @gfp_mask: GFP mask - * - * Allocate a coherent DMA memory and write the pointers into addr. - * - * Returns 0 on success or -ENOMEM on failure. +/* + * I2O driver structure for OSMs */ -static inline int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, - size_t len, gfp_t gfp_mask) -{ - struct pci_dev *pdev = to_pci_dev(dev); - int dma_64 = 0; +struct i2o_driver { + char *name; /* OSM name */ + int context; /* Low 8 bits of the transaction info */ + struct i2o_class_id *classes; /* I2O classes that this OSM handles */ - if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_64BIT_MASK)) { - dma_64 = 1; - if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) - return -ENOMEM; - } + /* Message reply handler */ + int (*reply) (struct i2o_controller *, u32, struct i2o_message *); - addr->virt = dma_alloc_coherent(dev, len, &addr->phys, gfp_mask); + /* Event handler */ + void (*event) (struct i2o_event *); - if ((sizeof(dma_addr_t) > 4) && dma_64) - if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)) - printk(KERN_WARNING "i2o: unable to set 64-bit DMA"); + struct workqueue_struct *event_queue; /* Event queue */ - if (!addr->virt) - return -ENOMEM; + struct device_driver driver; - memset(addr->virt, 0, len); - addr->len = len; + /* notification of changes */ + void (*notify_controller_add) (struct i2o_controller *); + void (*notify_controller_remove) (struct i2o_controller *); + void (*notify_device_add) (struct i2o_device *); + void (*notify_device_remove) (struct i2o_device *); - return 0; + struct semaphore lock; }; -/** - * i2o_dma_free - Free DMA memory - * @dev: struct device pointer to the PCI device of the I2O controller - * @addr: i2o_dma struct which contains the DMA buffer - * - * Free a coherent DMA memory and set virtual address of addr to NULL. +/* + * Contains DMA mapped address information */ -static inline void i2o_dma_free(struct device *dev, struct i2o_dma *addr) -{ - if (addr->virt) { - if (addr->phys) - dma_free_coherent(dev, addr->len, addr->virt, - addr->phys); - else - kfree(addr->virt); - addr->virt = NULL; - } +struct i2o_dma { + void *virt; + dma_addr_t phys; + size_t len; }; -/** - * i2o_dma_realloc - Realloc DMA memory - * @dev: struct device pointer to the PCI device of the I2O controller - * @addr: pointer to a i2o_dma struct DMA buffer - * @len: new length of memory - * @gfp_mask: GFP mask - * - * If there was something allocated in the addr, free it first. If len > 0 - * than try to allocate it and write the addresses back to the addr - * structure. If len == 0 set the virtual address to NULL. - * - * Returns the 0 on success or negative error code on failure. +/* + * Contains slab cache and mempool information */ -static inline int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, - size_t len, gfp_t gfp_mask) -{ - i2o_dma_free(dev, addr); - - if (len) - return i2o_dma_alloc(dev, addr, len, gfp_mask); - - return 0; +struct i2o_pool { + char *name; + kmem_cache_t *slab; + mempool_t *mempool; }; -/* I2O driver (OSM) functions */ -extern int i2o_driver_register(struct i2o_driver *); -extern void i2o_driver_unregister(struct i2o_driver *); - -/** - * i2o_driver_notify_controller_add - Send notification of added controller - * to a single I2O driver - * - * Send notification of added controller to a single registered driver. +/* + * Contains IO mapped address information */ -static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv, - struct i2o_controller *c) -{ - if (drv->notify_controller_add) - drv->notify_controller_add(c); +struct i2o_io { + void __iomem *virt; + unsigned long phys; + unsigned long len; }; -/** - * i2o_driver_notify_controller_remove - Send notification of removed - * controller to a single I2O driver - * - * Send notification of removed controller to a single registered driver. +/* + * Context queue entry, used for 32-bit context on 64-bit systems */ -static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv, - struct i2o_controller *c) -{ - if (drv->notify_controller_remove) - drv->notify_controller_remove(c); +struct i2o_context_list_element { + struct list_head list; + u32 context; + void *ptr; + unsigned long timestamp; }; -/** - * i2o_driver_notify_device_add - Send notification of added device to a - * single I2O driver - * - * Send notification of added device to a single registered driver. +/* + * Each I2O controller has one of these objects */ -static inline void i2o_driver_notify_device_add(struct i2o_driver *drv, - struct i2o_device *i2o_dev) -{ - if (drv->notify_device_add) - drv->notify_device_add(i2o_dev); +struct i2o_controller { + char name[16]; + int unit; + int type; + + struct pci_dev *pdev; /* PCI device */ + + unsigned int promise:1; /* Promise controller */ + unsigned int adaptec:1; /* DPT / Adaptec controller */ + unsigned int raptor:1; /* split bar */ + unsigned int no_quiesce:1; /* dont quiesce before reset */ + unsigned int short_req:1; /* use small block sizes */ + unsigned int limit_sectors:1; /* limit number of sectors / request */ + unsigned int pae_support:1; /* controller has 64-bit SGL support */ + + struct list_head devices; /* list of I2O devices */ + struct list_head list; /* Controller list */ + + void __iomem *in_port; /* Inbout port address */ + void __iomem *out_port; /* Outbound port address */ + void __iomem *irq_status; /* Interrupt status register address */ + void __iomem *irq_mask; /* Interrupt mask register address */ + + struct i2o_dma status; /* IOP status block */ + + struct i2o_dma hrt; /* HW Resource Table */ + i2o_lct *lct; /* Logical Config Table */ + struct i2o_dma dlct; /* Temp LCT */ + struct semaphore lct_lock; /* Lock for LCT updates */ + struct i2o_dma status_block; /* IOP status block */ + + struct i2o_io base; /* controller messaging unit */ + struct i2o_io in_queue; /* inbound message queue Host->IOP */ + struct i2o_dma out_queue; /* outbound message queue IOP->Host */ + + struct i2o_pool in_msg; /* mempool for inbound messages */ + + unsigned int battery:1; /* Has a battery backup */ + unsigned int io_alloc:1; /* An I/O resource was allocated */ + unsigned int mem_alloc:1; /* A memory resource was allocated */ + + struct resource io_resource; /* I/O resource allocated to the IOP */ + struct resource mem_resource; /* Mem resource allocated to the IOP */ + + struct device device; + struct class_device *classdev; /* I2O controller class device */ + struct i2o_device *exec; /* Executive */ +#if BITS_PER_LONG == 64 + spinlock_t context_list_lock; /* lock for context_list */ + atomic_t context_list_counter; /* needed for unique contexts */ + struct list_head context_list; /* list of context id's + and pointers */ +#endif + spinlock_t lock; /* lock for controller + configuration */ + + void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */ }; -/** - * i2o_driver_notify_device_remove - Send notification of removed device - * to a single I2O driver +/* + * I2O System table entry * - * Send notification of removed device to a single registered driver. + * The system table contains information about all the IOPs in the + * system. It is sent to all IOPs so that they can create peer2peer + * connections between them. */ -static inline void i2o_driver_notify_device_remove(struct i2o_driver *drv, - struct i2o_device *i2o_dev) -{ - if (drv->notify_device_remove) - drv->notify_device_remove(i2o_dev); +struct i2o_sys_tbl_entry { + u16 org_id; + u16 reserved1; + u32 iop_id:12; + u32 reserved2:20; + u16 seg_num:12; + u16 i2o_version:4; + u8 iop_state; + u8 msg_type; + u16 frame_size; + u16 reserved3; + u32 last_changed; + u32 iop_capabilities; + u32 inbound_low; + u32 inbound_high; }; -extern void i2o_driver_notify_controller_add_all(struct i2o_controller *); -extern void i2o_driver_notify_controller_remove_all(struct i2o_controller *); -extern void i2o_driver_notify_device_add_all(struct i2o_device *); -extern void i2o_driver_notify_device_remove_all(struct i2o_device *); +struct i2o_sys_tbl { + u8 num_entries; + u8 version; + u16 reserved1; + u32 change_ind; + u32 reserved2; + u32 reserved3; + struct i2o_sys_tbl_entry iops[0]; +}; -/* I2O device functions */ -extern int i2o_device_claim(struct i2o_device *); -extern int i2o_device_claim_release(struct i2o_device *); +extern struct list_head i2o_controllers; -/* Exec OSM functions */ -extern int i2o_exec_lct_get(struct i2o_controller *); +/* Message functions */ +static inline struct i2o_message *i2o_msg_get(struct i2o_controller *); +extern struct i2o_message *i2o_msg_get_wait(struct i2o_controller *, int); +static inline void i2o_msg_post(struct i2o_controller *, struct i2o_message *); +static inline int i2o_msg_post_wait(struct i2o_controller *, + struct i2o_message *, unsigned long); +extern int i2o_msg_post_wait_mem(struct i2o_controller *, struct i2o_message *, + unsigned long, struct i2o_dma *); +static inline void i2o_flush_reply(struct i2o_controller *, u32); -/* device / driver / kobject conversion functions */ -#define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver) -#define to_i2o_device(dev) container_of(dev, struct i2o_device, device) -#define to_i2o_controller(dev) container_of(dev, struct i2o_controller, device) -#define kobj_to_i2o_device(kobj) to_i2o_device(container_of(kobj, struct device, kobj)) +/* IOP functions */ +extern int i2o_status_get(struct i2o_controller *); -/** - * i2o_msg_get - obtain an I2O message from the IOP - * @c: I2O controller - * @msg: pointer to a I2O message pointer - * - * This function tries to get a message slot. If no message slot is - * available do not wait until one is availabe (see also i2o_msg_get_wait). - * - * On a success the message is returned and the pointer to the message is - * set in msg. The returned message is the physical page frame offset - * address from the read port (see the i2o spec). If no message is - * available returns I2O_QUEUE_EMPTY and msg is leaved untouched. - */ -static inline u32 i2o_msg_get(struct i2o_controller *c, - struct i2o_message __iomem ** msg) -{ - u32 m = readl(c->in_port); +extern int i2o_event_register(struct i2o_device *, struct i2o_driver *, int, + u32); +extern struct i2o_device *i2o_iop_find_device(struct i2o_controller *, u16); +extern struct i2o_controller *i2o_find_iop(int); - if (m != I2O_QUEUE_EMPTY) - *msg = c->in_queue.virt + m; +/* Functions needed for handling 64-bit pointers in 32-bit context */ +#if BITS_PER_LONG == 64 +extern u32 i2o_cntxt_list_add(struct i2o_controller *, void *); +extern void *i2o_cntxt_list_get(struct i2o_controller *, u32); +extern u32 i2o_cntxt_list_remove(struct i2o_controller *, void *); +extern u32 i2o_cntxt_list_get_ptr(struct i2o_controller *, void *); - return m; +static inline u32 i2o_ptr_low(void *ptr) +{ + return (u32) (u64) ptr; }; -/** - * i2o_msg_post - Post I2O message to I2O controller - * @c: I2O controller to which the message should be send - * @m: the message identifier - * - * Post the message to the I2O controller. - */ -static inline void i2o_msg_post(struct i2o_controller *c, u32 m) +static inline u32 i2o_ptr_high(void *ptr) { - writel(m, c->in_port); + return (u32) ((u64) ptr >> 32); }; -/** - * i2o_msg_post_wait - Post and wait a message and wait until return - * @c: controller - * @m: message to post - * @timeout: time in seconds to wait - * - * This API allows an OSM to post a message and then be told whether or - * not the system received a successful reply. If the message times out - * then the value '-ETIMEDOUT' is returned. - * - * Returns 0 on success or negative error code on failure. - */ -static inline int i2o_msg_post_wait(struct i2o_controller *c, u32 m, - unsigned long timeout) +static inline u32 i2o_dma_low(dma_addr_t dma_addr) { - return i2o_msg_post_wait_mem(c, m, timeout, NULL); + return (u32) (u64) dma_addr; }; -/** - * i2o_flush_reply - Flush reply from I2O controller - * @c: I2O controller - * @m: the message identifier - * - * The I2O controller must be informed that the reply message is not needed - * anymore. If you forget to flush the reply, the message frame can't be - * used by the controller anymore and is therefore lost. - */ -static inline void i2o_flush_reply(struct i2o_controller *c, u32 m) +static inline u32 i2o_dma_high(dma_addr_t dma_addr) { - writel(m, c->out_port); + return (u32) ((u64) dma_addr >> 32); +}; +#else +static inline u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr) +{ + return (u32) ptr; }; -/** - * i2o_out_to_virt - Turn an I2O message to a virtual address - * @c: controller - * @m: message engine value - * - * Turn a receive message from an I2O controller bus address into - * a Linux virtual address. The shared page frame is a linear block - * so we simply have to shift the offset. This function does not - * work for sender side messages as they are ioremap objects - * provided by the I2O controller. - */ -static inline struct i2o_message *i2o_msg_out_to_virt(struct i2o_controller *c, - u32 m) +static inline void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context) { - BUG_ON(m < c->out_queue.phys - || m >= c->out_queue.phys + c->out_queue.len); + return (void *)context; +}; - return c->out_queue.virt + (m - c->out_queue.phys); +static inline u32 i2o_cntxt_list_remove(struct i2o_controller *c, void *ptr) +{ + return (u32) ptr; }; -/** - * i2o_msg_in_to_virt - Turn an I2O message to a virtual address - * @c: controller - * @m: message engine value +static inline u32 i2o_cntxt_list_get_ptr(struct i2o_controller *c, void *ptr) +{ + return (u32) ptr; +}; + +static inline u32 i2o_ptr_low(void *ptr) +{ + return (u32) ptr; +}; + +static inline u32 i2o_ptr_high(void *ptr) +{ + return 0; +}; + +static inline u32 i2o_dma_low(dma_addr_t dma_addr) +{ + return (u32) dma_addr; +}; + +static inline u32 i2o_dma_high(dma_addr_t dma_addr) +{ + return 0; +}; +#endif + +/** + * i2o_sg_tablesize - Calculate the maximum number of elements in a SGL + * @c: I2O controller for which the calculation should be done + * @body_size: maximum body size used for message in 32-bit words. * - * Turn a send message from an I2O controller bus address into - * a Linux virtual address. The shared page frame is a linear block - * so we simply have to shift the offset. This function does not - * work for receive side messages as they are kmalloc objects - * in a different pool. + * Return the maximum number of SG elements in a SG list. */ -static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct - i2o_controller *c, - u32 m) +static inline u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size) { - return c->in_queue.virt + m; + i2o_status_block *sb = c->status_block.virt; + u16 sg_count = + (sb->inbound_frame_size - sizeof(struct i2o_message) / 4) - + body_size; + + if (c->pae_support) { + /* + * for 64-bit a SG attribute element must be added and each + * SG element needs 12 bytes instead of 8. + */ + sg_count -= 2; + sg_count /= 3; + } else + sg_count /= 2; + + if (c->short_req && (sg_count > 8)) + sg_count = 8; + + return sg_count; }; -/* - * Endian handling wrapped into the macro - keeps the core code - * cleaner. +/** + * i2o_dma_map_single - Map pointer to controller and fill in I2O message. + * @c: I2O controller + * @ptr: pointer to the data which should be mapped + * @size: size of data in bytes + * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE + * @sg_ptr: pointer to the SG list inside the I2O message + * + * This function does all necessary DMA handling and also writes the I2O + * SGL elements into the I2O message. For details on DMA handling see also + * dma_map_single(). The pointer sg_ptr will only be set to the end of the + * SG list if the allocation was successful. + * + * Returns DMA address which must be checked for failures using + * dma_mapping_error(). */ +static inline dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr, + size_t size, + enum dma_data_direction direction, + u32 ** sg_ptr) +{ + u32 sg_flags; + u32 *mptr = *sg_ptr; + dma_addr_t dma_addr; -#define i2o_raw_writel(val, mem) __raw_writel(cpu_to_le32(val), mem) + switch (direction) { + case DMA_TO_DEVICE: + sg_flags = 0xd4000000; + break; + case DMA_FROM_DEVICE: + sg_flags = 0xd0000000; + break; + default: + return 0; + } -extern int i2o_parm_field_get(struct i2o_device *, int, int, void *, int); -extern int i2o_parm_table_get(struct i2o_device *, int, int, int, void *, int, - void *, int); + dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction); + if (!dma_mapping_error(dma_addr)) { +#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 + if ((sizeof(dma_addr_t) > 4) && c->pae_support) { + *mptr++ = cpu_to_le32(0x7C020002); + *mptr++ = cpu_to_le32(PAGE_SIZE); + } +#endif -/* debugging and troubleshooting/diagnostic helpers. */ -#define osm_printk(level, format, arg...) \ - printk(level "%s: " format, OSM_NAME , ## arg) + *mptr++ = cpu_to_le32(sg_flags | size); + *mptr++ = cpu_to_le32(i2o_dma_low(dma_addr)); +#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 + if ((sizeof(dma_addr_t) > 4) && c->pae_support) + *mptr++ = cpu_to_le32(i2o_dma_high(dma_addr)); +#endif + *sg_ptr = mptr; + } + return dma_addr; +}; -#ifdef DEBUG -#define osm_debug(format, arg...) \ - osm_printk(KERN_DEBUG, format , ## arg) -#else -#define osm_debug(format, arg...) \ - do { } while (0) +/** + * i2o_dma_map_sg - Map a SG List to controller and fill in I2O message. + * @c: I2O controller + * @sg: SG list to be mapped + * @sg_count: number of elements in the SG list + * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE + * @sg_ptr: pointer to the SG list inside the I2O message + * + * This function does all necessary DMA handling and also writes the I2O + * SGL elements into the I2O message. For details on DMA handling see also + * dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG + * list if the allocation was successful. + * + * Returns 0 on failure or 1 on success. + */ +static inline int i2o_dma_map_sg(struct i2o_controller *c, + struct scatterlist *sg, int sg_count, + enum dma_data_direction direction, + u32 ** sg_ptr) +{ + u32 sg_flags; + u32 *mptr = *sg_ptr; + + switch (direction) { + case DMA_TO_DEVICE: + sg_flags = 0x14000000; + break; + case DMA_FROM_DEVICE: + sg_flags = 0x10000000; + break; + default: + return 0; + } + + sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction); + if (!sg_count) + return 0; + +#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 + if ((sizeof(dma_addr_t) > 4) && c->pae_support) { + *mptr++ = cpu_to_le32(0x7C020002); + *mptr++ = cpu_to_le32(PAGE_SIZE); + } #endif -#define osm_err(format, arg...) \ - osm_printk(KERN_ERR, format , ## arg) -#define osm_info(format, arg...) \ - osm_printk(KERN_INFO, format , ## arg) -#define osm_warn(format, arg...) \ - osm_printk(KERN_WARNING, format , ## arg) + while (sg_count-- > 0) { + if (!sg_count) + sg_flags |= 0xC0000000; + *mptr++ = cpu_to_le32(sg_flags | sg_dma_len(sg)); + *mptr++ = cpu_to_le32(i2o_dma_low(sg_dma_address(sg))); +#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 + if ((sizeof(dma_addr_t) > 4) && c->pae_support) + *mptr++ = cpu_to_le32(i2o_dma_high(sg_dma_address(sg))); +#endif + sg++; + } + *sg_ptr = mptr; -/* debugging functions */ -extern void i2o_report_status(const char *, const char *, struct i2o_message *); -extern void i2o_dump_message(struct i2o_message *); -extern void i2o_dump_hrt(struct i2o_controller *c); -extern void i2o_debug_state(struct i2o_controller *c); + return 1; +}; -/* - * Cache strategies +/** + * i2o_dma_alloc - Allocate DMA memory + * @dev: struct device pointer to the PCI device of the I2O controller + * @addr: i2o_dma struct which should get the DMA buffer + * @len: length of the new DMA memory + * @gfp_mask: GFP mask + * + * Allocate a coherent DMA memory and write the pointers into addr. + * + * Returns 0 on success or -ENOMEM on failure. */ +static inline int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, + size_t len, gfp_t gfp_mask) +{ + struct pci_dev *pdev = to_pci_dev(dev); + int dma_64 = 0; -/* The NULL strategy leaves everything up to the controller. This tends to be a - * pessimal but functional choice. - */ -#define CACHE_NULL 0 -/* Prefetch data when reading. We continually attempt to load the next 32 sectors - * into the controller cache. - */ -#define CACHE_PREFETCH 1 -/* Prefetch data when reading. We sometimes attempt to load the next 32 sectors - * into the controller cache. When an I/O is less <= 8K we assume its probably - * not sequential and don't prefetch (default) - */ -#define CACHE_SMARTFETCH 2 -/* Data is written to the cache and then out on to the disk. The I/O must be - * physically on the medium before the write is acknowledged (default without - * NVRAM) - */ -#define CACHE_WRITETHROUGH 17 -/* Data is written to the cache and then out on to the disk. The controller - * is permitted to write back the cache any way it wants. (default if battery - * backed NVRAM is present). It can be useful to set this for swap regardless of - * battery state. - */ -#define CACHE_WRITEBACK 18 -/* Optimise for under powered controllers, especially on RAID1 and RAID0. We - * write large I/O's directly to disk bypassing the cache to avoid the extra - * memory copy hits. Small writes are writeback cached - */ -#define CACHE_SMARTBACK 19 -/* Optimise for under powered controllers, especially on RAID1 and RAID0. We - * write large I/O's directly to disk bypassing the cache to avoid the extra - * memory copy hits. Small writes are writethrough cached. Suitable for devices - * lacking battery backup - */ -#define CACHE_SMARTTHROUGH 20 + if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_64BIT_MASK)) { + dma_64 = 1; + if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) + return -ENOMEM; + } -/* - * Ioctl structures - */ + addr->virt = dma_alloc_coherent(dev, len, &addr->phys, gfp_mask); -#define BLKI2OGRSTRAT _IOR('2', 1, int) -#define BLKI2OGWSTRAT _IOR('2', 2, int) -#define BLKI2OSRSTRAT _IOW('2', 3, int) -#define BLKI2OSWSTRAT _IOW('2', 4, int) + if ((sizeof(dma_addr_t) > 4) && dma_64) + if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)) + printk(KERN_WARNING "i2o: unable to set 64-bit DMA"); -/* - * I2O Function codes - */ + if (!addr->virt) + return -ENOMEM; -/* - * Executive Class - */ -#define I2O_CMD_ADAPTER_ASSIGN 0xB3 -#define I2O_CMD_ADAPTER_READ 0xB2 -#define I2O_CMD_ADAPTER_RELEASE 0xB5 -#define I2O_CMD_BIOS_INFO_SET 0xA5 -#define I2O_CMD_BOOT_DEVICE_SET 0xA7 -#define I2O_CMD_CONFIG_VALIDATE 0xBB -#define I2O_CMD_CONN_SETUP 0xCA -#define I2O_CMD_DDM_DESTROY 0xB1 -#define I2O_CMD_DDM_ENABLE 0xD5 -#define I2O_CMD_DDM_QUIESCE 0xC7 -#define I2O_CMD_DDM_RESET 0xD9 -#define I2O_CMD_DDM_SUSPEND 0xAF -#define I2O_CMD_DEVICE_ASSIGN 0xB7 -#define I2O_CMD_DEVICE_RELEASE 0xB9 -#define I2O_CMD_HRT_GET 0xA8 -#define I2O_CMD_ADAPTER_CLEAR 0xBE -#define I2O_CMD_ADAPTER_CONNECT 0xC9 -#define I2O_CMD_ADAPTER_RESET 0xBD -#define I2O_CMD_LCT_NOTIFY 0xA2 -#define I2O_CMD_OUTBOUND_INIT 0xA1 -#define I2O_CMD_PATH_ENABLE 0xD3 -#define I2O_CMD_PATH_QUIESCE 0xC5 -#define I2O_CMD_PATH_RESET 0xD7 -#define I2O_CMD_STATIC_MF_CREATE 0xDD -#define I2O_CMD_STATIC_MF_RELEASE 0xDF -#define I2O_CMD_STATUS_GET 0xA0 -#define I2O_CMD_SW_DOWNLOAD 0xA9 -#define I2O_CMD_SW_UPLOAD 0xAB -#define I2O_CMD_SW_REMOVE 0xAD -#define I2O_CMD_SYS_ENABLE 0xD1 -#define I2O_CMD_SYS_MODIFY 0xC1 -#define I2O_CMD_SYS_QUIESCE 0xC3 -#define I2O_CMD_SYS_TAB_SET 0xA3 + memset(addr->virt, 0, len); + addr->len = len; -/* - * Utility Class + return 0; +}; + +/** + * i2o_dma_free - Free DMA memory + * @dev: struct device pointer to the PCI device of the I2O controller + * @addr: i2o_dma struct which contains the DMA buffer + * + * Free a coherent DMA memory and set virtual address of addr to NULL. */ -#define I2O_CMD_UTIL_NOP 0x00 -#define I2O_CMD_UTIL_ABORT 0x01 -#define I2O_CMD_UTIL_CLAIM 0x09 -#define I2O_CMD_UTIL_RELEASE 0x0B -#define I2O_CMD_UTIL_PARAMS_GET 0x06 -#define I2O_CMD_UTIL_PARAMS_SET 0x05 -#define I2O_CMD_UTIL_EVT_REGISTER 0x13 -#define I2O_CMD_UTIL_EVT_ACK 0x14 -#define I2O_CMD_UTIL_CONFIG_DIALOG 0x10 -#define I2O_CMD_UTIL_DEVICE_RESERVE 0x0D -#define I2O_CMD_UTIL_DEVICE_RELEASE 0x0F -#define I2O_CMD_UTIL_LOCK 0x17 -#define I2O_CMD_UTIL_LOCK_RELEASE 0x19 -#define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15 +static inline void i2o_dma_free(struct device *dev, struct i2o_dma *addr) +{ + if (addr->virt) { + if (addr->phys) + dma_free_coherent(dev, addr->len, addr->virt, + addr->phys); + else + kfree(addr->virt); + addr->virt = NULL; + } +}; -/* - * SCSI Host Bus Adapter Class +/** + * i2o_dma_realloc - Realloc DMA memory + * @dev: struct device pointer to the PCI device of the I2O controller + * @addr: pointer to a i2o_dma struct DMA buffer + * @len: new length of memory + * @gfp_mask: GFP mask + * + * If there was something allocated in the addr, free it first. If len > 0 + * than try to allocate it and write the addresses back to the addr + * structure. If len == 0 set the virtual address to NULL. + * + * Returns the 0 on success or negative error code on failure. */ -#define I2O_CMD_SCSI_EXEC 0x81 -#define I2O_CMD_SCSI_ABORT 0x83 -#define I2O_CMD_SCSI_BUSRESET 0x27 +static inline int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, + size_t len, gfp_t gfp_mask) +{ + i2o_dma_free(dev, addr); + + if (len) + return i2o_dma_alloc(dev, addr, len, gfp_mask); + + return 0; +}; /* - * Bus Adapter Class + * i2o_pool_alloc - Allocate an slab cache and mempool + * @mempool: pointer to struct i2o_pool to write data into. + * @name: name which is used to identify cache + * @size: size of each object + * @min_nr: minimum number of objects + * + * First allocates a slab cache with name and size. Then allocates a + * mempool which uses the slab cache for allocation and freeing. + * + * Returns 0 on success or negative error code on failure. */ -#define I2O_CMD_BUS_ADAPTER_RESET 0x85 -#define I2O_CMD_BUS_RESET 0x87 -#define I2O_CMD_BUS_SCAN 0x89 -#define I2O_CMD_BUS_QUIESCE 0x8b +static inline int i2o_pool_alloc(struct i2o_pool *pool, const char *name, + size_t size, int min_nr) +{ + pool->name = kmalloc(strlen(name) + 1, GFP_KERNEL); + if (!pool->name) + goto exit; + strcpy(pool->name, name); + + pool->slab = + kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL, + NULL); + if (!pool->slab) + goto free_name; + + pool->mempool = + mempool_create(min_nr, mempool_alloc_slab, mempool_free_slab, + pool->slab); + if (!pool->mempool) + goto free_slab; + + return 0; + + free_slab: + kmem_cache_destroy(pool->slab); + + free_name: + kfree(pool->name); + + exit: + return -ENOMEM; +}; /* - * Random Block Storage Class + * i2o_pool_free - Free slab cache and mempool again + * @mempool: pointer to struct i2o_pool which should be freed + * + * Note that you have to return all objects to the mempool again before + * calling i2o_pool_free(). */ -#define I2O_CMD_BLOCK_READ 0x30 -#define I2O_CMD_BLOCK_WRITE 0x31 -#define I2O_CMD_BLOCK_CFLUSH 0x37 -#define I2O_CMD_BLOCK_MLOCK 0x49 -#define I2O_CMD_BLOCK_MUNLOCK 0x4B -#define I2O_CMD_BLOCK_MMOUNT 0x41 -#define I2O_CMD_BLOCK_MEJECT 0x43 -#define I2O_CMD_BLOCK_POWER 0x70 - -#define I2O_CMD_PRIVATE 0xFF +static inline void i2o_pool_free(struct i2o_pool *pool) +{ + mempool_destroy(pool->mempool); + kmem_cache_destroy(pool->slab); + kfree(pool->name); +}; -/* Command status values */ +/* I2O driver (OSM) functions */ +extern int i2o_driver_register(struct i2o_driver *); +extern void i2o_driver_unregister(struct i2o_driver *); -#define I2O_CMD_IN_PROGRESS 0x01 -#define I2O_CMD_REJECTED 0x02 -#define I2O_CMD_FAILED 0x03 -#define I2O_CMD_COMPLETED 0x04 +/** + * i2o_driver_notify_controller_add - Send notification of added controller + * to a single I2O driver + * + * Send notification of added controller to a single registered driver. + */ +static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv, + struct i2o_controller *c) +{ + if (drv->notify_controller_add) + drv->notify_controller_add(c); +}; -/* I2O API function return values */ +/** + * i2o_driver_notify_controller_remove - Send notification of removed + * controller to a single I2O driver + * + * Send notification of removed controller to a single registered driver. + */ +static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv, + struct i2o_controller *c) +{ + if (drv->notify_controller_remove) + drv->notify_controller_remove(c); +}; -#define I2O_RTN_NO_ERROR 0 -#define I2O_RTN_NOT_INIT 1 -#define I2O_RTN_FREE_Q_EMPTY 2 -#define I2O_RTN_TCB_ERROR 3 -#define I2O_RTN_TRANSACTION_ERROR 4 -#define I2O_RTN_ADAPTER_ALREADY_INIT 5 -#define I2O_RTN_MALLOC_ERROR 6 -#define I2O_RTN_ADPTR_NOT_REGISTERED 7 -#define I2O_RTN_MSG_REPLY_TIMEOUT 8 -#define I2O_RTN_NO_STATUS 9 -#define I2O_RTN_NO_FIRM_VER 10 -#define I2O_RTN_NO_LINK_SPEED 11 +/** + * i2o_driver_notify_device_add - Send notification of added device to a + * single I2O driver + * + * Send notification of added device to a single registered driver. + */ +static inline void i2o_driver_notify_device_add(struct i2o_driver *drv, + struct i2o_device *i2o_dev) +{ + if (drv->notify_device_add) + drv->notify_device_add(i2o_dev); +}; -/* Reply message status defines for all messages */ +/** + * i2o_driver_notify_device_remove - Send notification of removed device + * to a single I2O driver + * + * Send notification of removed device to a single registered driver. + */ +static inline void i2o_driver_notify_device_remove(struct i2o_driver *drv, + struct i2o_device *i2o_dev) +{ + if (drv->notify_device_remove) + drv->notify_device_remove(i2o_dev); +}; -#define I2O_REPLY_STATUS_SUCCESS 0x00 -#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01 -#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02 -#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03 -#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04 -#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05 -#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06 -#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08 -#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09 -#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A -#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0B -#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80 +extern void i2o_driver_notify_controller_add_all(struct i2o_controller *); +extern void i2o_driver_notify_controller_remove_all(struct i2o_controller *); +extern void i2o_driver_notify_device_add_all(struct i2o_device *); +extern void i2o_driver_notify_device_remove_all(struct i2o_device *); -/* Status codes and Error Information for Parameter functions */ +/* I2O device functions */ +extern int i2o_device_claim(struct i2o_device *); +extern int i2o_device_claim_release(struct i2o_device *); -#define I2O_PARAMS_STATUS_SUCCESS 0x00 -#define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01 -#define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02 -#define I2O_PARAMS_STATUS_BUFFER_FULL 0x03 -#define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04 -#define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05 -#define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE 0x06 -#define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS 0x07 -#define I2O_PARAMS_STATUS_INVALID_GROUP_ID 0x08 -#define I2O_PARAMS_STATUS_INVALID_OPERATION 0x09 -#define I2O_PARAMS_STATUS_NO_KEY_FIELD 0x0A -#define I2O_PARAMS_STATUS_NO_SUCH_FIELD 0x0B -#define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP 0x0C -#define I2O_PARAMS_STATUS_OPERATION_ERROR 0x0D -#define I2O_PARAMS_STATUS_SCALAR_ERROR 0x0E -#define I2O_PARAMS_STATUS_TABLE_ERROR 0x0F -#define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE 0x10 +/* Exec OSM functions */ +extern int i2o_exec_lct_get(struct i2o_controller *); -/* DetailedStatusCode defines for Executive, DDM, Util and Transaction error - * messages: Table 3-2 Detailed Status Codes.*/ +/* device / driver / kobject conversion functions */ +#define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver) +#define to_i2o_device(dev) container_of(dev, struct i2o_device, device) +#define to_i2o_controller(dev) container_of(dev, struct i2o_controller, device) +#define kobj_to_i2o_device(kobj) to_i2o_device(container_of(kobj, struct device, kobj)) -#define I2O_DSC_SUCCESS 0x0000 -#define I2O_DSC_BAD_KEY 0x0002 -#define I2O_DSC_TCL_ERROR 0x0003 -#define I2O_DSC_REPLY_BUFFER_FULL 0x0004 -#define I2O_DSC_NO_SUCH_PAGE 0x0005 -#define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x0006 -#define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x0007 -#define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x0009 -#define I2O_DSC_UNSUPPORTED_FUNCTION 0x000A -#define I2O_DSC_DEVICE_LOCKED 0x000B -#define I2O_DSC_DEVICE_RESET 0x000C -#define I2O_DSC_INAPPROPRIATE_FUNCTION 0x000D -#define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x000E -#define I2O_DSC_INVALID_MESSAGE_FLAGS 0x000F -#define I2O_DSC_INVALID_OFFSET 0x0010 -#define I2O_DSC_INVALID_PARAMETER 0x0011 -#define I2O_DSC_INVALID_REQUEST 0x0012 -#define I2O_DSC_INVALID_TARGET_ADDRESS 0x0013 -#define I2O_DSC_MESSAGE_TOO_LARGE 0x0014 -#define I2O_DSC_MESSAGE_TOO_SMALL 0x0015 -#define I2O_DSC_MISSING_PARAMETER 0x0016 -#define I2O_DSC_TIMEOUT 0x0017 -#define I2O_DSC_UNKNOWN_ERROR 0x0018 -#define I2O_DSC_UNKNOWN_FUNCTION 0x0019 -#define I2O_DSC_UNSUPPORTED_VERSION 0x001A -#define I2O_DSC_DEVICE_BUSY 0x001B -#define I2O_DSC_DEVICE_NOT_AVAILABLE 0x001C +/** + * i2o_out_to_virt - Turn an I2O message to a virtual address + * @c: controller + * @m: message engine value + * + * Turn a receive message from an I2O controller bus address into + * a Linux virtual address. The shared page frame is a linear block + * so we simply have to shift the offset. This function does not + * work for sender side messages as they are ioremap objects + * provided by the I2O controller. + */ +static inline struct i2o_message *i2o_msg_out_to_virt(struct i2o_controller *c, + u32 m) +{ + BUG_ON(m < c->out_queue.phys + || m >= c->out_queue.phys + c->out_queue.len); -/* DetailedStatusCode defines for Block Storage Operation: Table 6-7 Detailed - Status Codes.*/ + return c->out_queue.virt + (m - c->out_queue.phys); +}; -#define I2O_BSA_DSC_SUCCESS 0x0000 -#define I2O_BSA_DSC_MEDIA_ERROR 0x0001 -#define I2O_BSA_DSC_ACCESS_ERROR 0x0002 -#define I2O_BSA_DSC_DEVICE_FAILURE 0x0003 -#define I2O_BSA_DSC_DEVICE_NOT_READY 0x0004 -#define I2O_BSA_DSC_MEDIA_NOT_PRESENT 0x0005 -#define I2O_BSA_DSC_MEDIA_LOCKED 0x0006 -#define I2O_BSA_DSC_MEDIA_FAILURE 0x0007 -#define I2O_BSA_DSC_PROTOCOL_FAILURE 0x0008 -#define I2O_BSA_DSC_BUS_FAILURE 0x0009 -#define I2O_BSA_DSC_ACCESS_VIOLATION 0x000A -#define I2O_BSA_DSC_WRITE_PROTECTED 0x000B -#define I2O_BSA_DSC_DEVICE_RESET 0x000C -#define I2O_BSA_DSC_VOLUME_CHANGED 0x000D -#define I2O_BSA_DSC_TIMEOUT 0x000E +/** + * i2o_msg_in_to_virt - Turn an I2O message to a virtual address + * @c: controller + * @m: message engine value + * + * Turn a send message from an I2O controller bus address into + * a Linux virtual address. The shared page frame is a linear block + * so we simply have to shift the offset. This function does not + * work for receive side messages as they are kmalloc objects + * in a different pool. + */ +static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct + i2o_controller *c, + u32 m) +{ + return c->in_queue.virt + m; +}; -/* FailureStatusCodes, Table 3-3 Message Failure Codes */ +/** + * i2o_msg_get - obtain an I2O message from the IOP + * @c: I2O controller + * + * This function tries to get a message frame. If no message frame is + * available do not wait until one is availabe (see also i2o_msg_get_wait). + * The returned pointer to the message frame is not in I/O memory, it is + * allocated from a mempool. But because a MFA is allocated from the + * controller too it is guaranteed that i2o_msg_post() will never fail. + * + * On a success a pointer to the message frame is returned. If the message + * queue is empty -EBUSY is returned and if no memory is available -ENOMEM + * is returned. + */ +static inline struct i2o_message *i2o_msg_get(struct i2o_controller *c) +{ + struct i2o_msg_mfa *mmsg = mempool_alloc(c->in_msg.mempool, GFP_ATOMIC); + if (!mmsg) + return ERR_PTR(-ENOMEM); + + mmsg->mfa = readl(c->in_port); + if (mmsg->mfa == I2O_QUEUE_EMPTY) { + mempool_free(mmsg, c->in_msg.mempool); + return ERR_PTR(-EBUSY); + } -#define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED 0x81 -#define I2O_FSC_TRANSPORT_SERVICE_TERMINATED 0x82 -#define I2O_FSC_TRANSPORT_CONGESTION 0x83 -#define I2O_FSC_TRANSPORT_FAILURE 0x84 -#define I2O_FSC_TRANSPORT_STATE_ERROR 0x85 -#define I2O_FSC_TRANSPORT_TIME_OUT 0x86 -#define I2O_FSC_TRANSPORT_ROUTING_FAILURE 0x87 -#define I2O_FSC_TRANSPORT_INVALID_VERSION 0x88 -#define I2O_FSC_TRANSPORT_INVALID_OFFSET 0x89 -#define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS 0x8A -#define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL 0x8B -#define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE 0x8C -#define I2O_FSC_TRANSPORT_INVALID_TARGET_ID 0x8D -#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID 0x8E -#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F -#define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE 0xFF + return &mmsg->msg; +}; -/* Device Claim Types */ -#define I2O_CLAIM_PRIMARY 0x01000000 -#define I2O_CLAIM_MANAGEMENT 0x02000000 -#define I2O_CLAIM_AUTHORIZED 0x03000000 -#define I2O_CLAIM_SECONDARY 0x04000000 +/** + * i2o_msg_post - Post I2O message to I2O controller + * @c: I2O controller to which the message should be send + * @msg: message returned by i2o_msg_get() + * + * Post the message to the I2O controller and return immediately. + */ +static inline void i2o_msg_post(struct i2o_controller *c, + struct i2o_message *msg) +{ + struct i2o_msg_mfa *mmsg; -/* Message header defines for VersionOffset */ -#define I2OVER15 0x0001 -#define I2OVER20 0x0002 + mmsg = container_of(msg, struct i2o_msg_mfa, msg); + memcpy_toio(i2o_msg_in_to_virt(c, mmsg->mfa), msg, + (le32_to_cpu(msg->u.head[0]) >> 16) << 2); + writel(mmsg->mfa, c->in_port); + mempool_free(mmsg, c->in_msg.mempool); +}; -/* Default is 1.5 */ -#define I2OVERSION I2OVER15 +/** + * i2o_msg_post_wait - Post and wait a message and wait until return + * @c: controller + * @m: message to post + * @timeout: time in seconds to wait + * + * This API allows an OSM to post a message and then be told whether or + * not the system received a successful reply. If the message times out + * then the value '-ETIMEDOUT' is returned. + * + * Returns 0 on success or negative error code on failure. + */ +static inline int i2o_msg_post_wait(struct i2o_controller *c, + struct i2o_message *msg, + unsigned long timeout) +{ + return i2o_msg_post_wait_mem(c, msg, timeout, NULL); +}; -#define SGL_OFFSET_0 I2OVERSION -#define SGL_OFFSET_4 (0x0040 | I2OVERSION) -#define SGL_OFFSET_5 (0x0050 | I2OVERSION) -#define SGL_OFFSET_6 (0x0060 | I2OVERSION) -#define SGL_OFFSET_7 (0x0070 | I2OVERSION) -#define SGL_OFFSET_8 (0x0080 | I2OVERSION) -#define SGL_OFFSET_9 (0x0090 | I2OVERSION) -#define SGL_OFFSET_10 (0x00A0 | I2OVERSION) -#define SGL_OFFSET_11 (0x00B0 | I2OVERSION) -#define SGL_OFFSET_12 (0x00C0 | I2OVERSION) -#define SGL_OFFSET(x) (((x)<<4) | I2OVERSION) +/** + * i2o_msg_nop_mfa - Returns a fetched MFA back to the controller + * @c: I2O controller from which the MFA was fetched + * @mfa: MFA which should be returned + * + * This function must be used for preserved messages, because i2o_msg_nop() + * also returns the allocated memory back to the msg_pool mempool. + */ +static inline void i2o_msg_nop_mfa(struct i2o_controller *c, u32 mfa) +{ + struct i2o_message __iomem *msg; + u32 nop[3] = { + THREE_WORD_MSG_SIZE | SGL_OFFSET_0, + I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID, + 0x00000000 + }; + + msg = i2o_msg_in_to_virt(c, mfa); + memcpy_toio(msg, nop, sizeof(nop)); + writel(mfa, c->in_port); +}; -/* Transaction Reply Lists (TRL) Control Word structure */ -#define TRL_SINGLE_FIXED_LENGTH 0x00 -#define TRL_SINGLE_VARIABLE_LENGTH 0x40 -#define TRL_MULTIPLE_FIXED_LENGTH 0x80 +/** + * i2o_msg_nop - Returns a message which is not used + * @c: I2O controller from which the message was created + * @msg: message which should be returned + * + * If you fetch a message via i2o_msg_get, and can't use it, you must + * return the message with this function. Otherwise the MFA is lost as well + * as the allocated memory from the mempool. + */ +static inline void i2o_msg_nop(struct i2o_controller *c, + struct i2o_message *msg) +{ + struct i2o_msg_mfa *mmsg; + mmsg = container_of(msg, struct i2o_msg_mfa, msg); - /* msg header defines for MsgFlags */ -#define MSG_STATIC 0x0100 -#define MSG_64BIT_CNTXT 0x0200 -#define MSG_MULTI_TRANS 0x1000 -#define MSG_FAIL 0x2000 -#define MSG_FINAL 0x4000 -#define MSG_REPLY 0x8000 + i2o_msg_nop_mfa(c, mmsg->mfa); + mempool_free(mmsg, c->in_msg.mempool); +}; - /* minimum size msg */ -#define THREE_WORD_MSG_SIZE 0x00030000 -#define FOUR_WORD_MSG_SIZE 0x00040000 -#define FIVE_WORD_MSG_SIZE 0x00050000 -#define SIX_WORD_MSG_SIZE 0x00060000 -#define SEVEN_WORD_MSG_SIZE 0x00070000 -#define EIGHT_WORD_MSG_SIZE 0x00080000 -#define NINE_WORD_MSG_SIZE 0x00090000 -#define TEN_WORD_MSG_SIZE 0x000A0000 -#define ELEVEN_WORD_MSG_SIZE 0x000B0000 -#define I2O_MESSAGE_SIZE(x) ((x)<<16) +/** + * i2o_flush_reply - Flush reply from I2O controller + * @c: I2O controller + * @m: the message identifier + * + * The I2O controller must be informed that the reply message is not needed + * anymore. If you forget to flush the reply, the message frame can't be + * used by the controller anymore and is therefore lost. + */ +static inline void i2o_flush_reply(struct i2o_controller *c, u32 m) +{ + writel(m, c->out_port); +}; -/* special TID assignments */ -#define ADAPTER_TID 0 -#define HOST_TID 1 +/* + * Endian handling wrapped into the macro - keeps the core code + * cleaner. + */ -/* outbound queue defines */ -#define I2O_MAX_OUTBOUND_MSG_FRAMES 128 -#define I2O_OUTBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */ +#define i2o_raw_writel(val, mem) __raw_writel(cpu_to_le32(val), mem) -#define I2O_POST_WAIT_OK 0 -#define I2O_POST_WAIT_TIMEOUT -ETIMEDOUT +extern int i2o_parm_field_get(struct i2o_device *, int, int, void *, int); +extern int i2o_parm_table_get(struct i2o_device *, int, int, int, void *, int, + void *, int); -#define I2O_CONTEXT_LIST_MIN_LENGTH 15 -#define I2O_CONTEXT_LIST_USED 0x01 -#define I2O_CONTEXT_LIST_DELETED 0x02 +/* debugging and troubleshooting/diagnostic helpers. */ +#define osm_printk(level, format, arg...) \ + printk(level "%s: " format, OSM_NAME , ## arg) -/* timeouts */ -#define I2O_TIMEOUT_INIT_OUTBOUND_QUEUE 15 -#define I2O_TIMEOUT_MESSAGE_GET 5 -#define I2O_TIMEOUT_RESET 30 -#define I2O_TIMEOUT_STATUS_GET 5 -#define I2O_TIMEOUT_LCT_GET 360 -#define I2O_TIMEOUT_SCSI_SCB_ABORT 240 +#ifdef DEBUG +#define osm_debug(format, arg...) \ + osm_printk(KERN_DEBUG, format , ## arg) +#else +#define osm_debug(format, arg...) \ + do { } while (0) +#endif -/* retries */ -#define I2O_HRT_GET_TRIES 3 -#define I2O_LCT_GET_TRIES 3 +#define osm_err(format, arg...) \ + osm_printk(KERN_ERR, format , ## arg) +#define osm_info(format, arg...) \ + osm_printk(KERN_INFO, format , ## arg) +#define osm_warn(format, arg...) \ + osm_printk(KERN_WARNING, format , ## arg) -/* defines for max_sectors and max_phys_segments */ -#define I2O_MAX_SECTORS 1024 -#define I2O_MAX_SECTORS_LIMITED 256 -#define I2O_MAX_PHYS_SEGMENTS MAX_PHYS_SEGMENTS +/* debugging functions */ +extern void i2o_report_status(const char *, const char *, struct i2o_message *); +extern void i2o_dump_message(struct i2o_message *); +extern void i2o_dump_hrt(struct i2o_controller *c); +extern void i2o_debug_state(struct i2o_controller *c); #endif /* __KERNEL__ */ #endif /* _I2O_H */ -- cgit v1.1 From 793fd15d9fafe5b1c71e50d3c041f1463895dbde Mon Sep 17 00:00:00 2001 From: Markus Lidel Date: Fri, 6 Jan 2006 00:19:30 -0800 Subject: [PATCH] I2O: SPARC fixes Fix lot of BE <-> LE bugs which prevent it from working on SPARC. Signed-off-by: Markus Lidel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/Kconfig | 12 ++++ drivers/message/i2o/device.c | 130 +++++++++++++++++++--------------------- drivers/message/i2o/exec-osm.c | 15 +++-- drivers/message/i2o/i2o_block.c | 20 +++---- drivers/message/i2o/i2o_scsi.c | 35 ++++++----- 5 files changed, 111 insertions(+), 101 deletions(-) diff --git a/drivers/message/i2o/Kconfig b/drivers/message/i2o/Kconfig index 43a942a..fef6771 100644 --- a/drivers/message/i2o/Kconfig +++ b/drivers/message/i2o/Kconfig @@ -24,6 +24,18 @@ config I2O If unsure, say N. +config I2O_LCT_NOTIFY_ON_CHANGES + bool "Enable LCT notification" + depends on I2O + default y + ---help--- + Only say N here if you have a I2O controller from SUN. The SUN + firmware doesn't support LCT notification on changes. If this option + is enabled on such a controller the driver will hang up in a endless + loop. On all other controllers say Y. + + If unsure, say Y. + config I2O_EXT_ADAPTEC bool "Enable Adaptec extensions" depends on I2O diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index 002ae0e..1db2621 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c @@ -341,56 +341,83 @@ int i2o_device_parse_lct(struct i2o_controller *c) { struct i2o_device *dev, *tmp; i2o_lct *lct; - int i; - int max; + u32 *dlct = c->dlct.virt; + int max = 0, i = 0; + u16 table_size; + u32 buf; down(&c->lct_lock); kfree(c->lct); - lct = c->dlct.virt; + buf = le32_to_cpu(*dlct++); + table_size = buf & 0xffff; - c->lct = kmalloc(lct->table_size * 4, GFP_KERNEL); - if (!c->lct) { + lct = c->lct = kmalloc(table_size * 4, GFP_KERNEL); + if (!lct) { up(&c->lct_lock); return -ENOMEM; } - if (lct->table_size * 4 > c->dlct.len) { - memcpy(c->lct, c->dlct.virt, c->dlct.len); - up(&c->lct_lock); - return -EAGAIN; - } - - memcpy(c->lct, c->dlct.virt, lct->table_size * 4); + lct->lct_ver = buf >> 28; + lct->boot_tid = buf >> 16 & 0xfff; + lct->table_size = table_size; + lct->change_ind = le32_to_cpu(*dlct++); + lct->iop_flags = le32_to_cpu(*dlct++); - lct = c->lct; - - max = (lct->table_size - 3) / 9; + table_size -= 3; pr_debug("%s: LCT has %d entries (LCT size: %d)\n", c->name, max, lct->table_size); - /* remove devices, which are not in the LCT anymore */ - list_for_each_entry_safe(dev, tmp, &c->devices, list) { + while (table_size > 0) { + i2o_lct_entry *entry = &lct->lct_entry[max]; int found = 0; - for (i = 0; i < max; i++) { - if (lct->lct_entry[i].tid == dev->lct_data.tid) { + buf = le32_to_cpu(*dlct++); + entry->entry_size = buf & 0xffff; + entry->tid = buf >> 16 & 0xfff; + + entry->change_ind = le32_to_cpu(*dlct++); + entry->device_flags = le32_to_cpu(*dlct++); + + buf = le32_to_cpu(*dlct++); + entry->class_id = buf & 0xfff; + entry->version = buf >> 12 & 0xf; + entry->vendor_id = buf >> 16; + + entry->sub_class = le32_to_cpu(*dlct++); + + buf = le32_to_cpu(*dlct++); + entry->user_tid = buf & 0xfff; + entry->parent_tid = buf >> 12 & 0xfff; + entry->bios_info = buf >> 24; + + memcpy(&entry->identity_tag, dlct, 8); + dlct += 2; + + entry->event_capabilities = le32_to_cpu(*dlct++); + + /* add new devices, which are new in the LCT */ + list_for_each_entry_safe(dev, tmp, &c->devices, list) { + if (entry->tid == dev->lct_data.tid) { found = 1; break; } } if (!found) - i2o_device_remove(dev); + i2o_device_add(c, entry); + + table_size -= 9; + max++; } - /* add new devices, which are new in the LCT */ - for (i = 0; i < max; i++) { + /* remove devices, which are not in the LCT anymore */ + list_for_each_entry_safe(dev, tmp, &c->devices, list) { int found = 0; - list_for_each_entry_safe(dev, tmp, &c->devices, list) { + for (i = 0; i < max; i++) { if (lct->lct_entry[i].tid == dev->lct_data.tid) { found = 1; break; @@ -398,8 +425,9 @@ int i2o_device_parse_lct(struct i2o_controller *c) } if (!found) - i2o_device_add(c, &lct->lct_entry[i]); + i2o_device_remove(dev); } + up(&c->lct_lock); return 0; @@ -422,9 +450,6 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, int oplen, void *reslist, int reslen) { struct i2o_message *msg; - u32 *res32 = (u32 *) reslist; - u32 *restmp = (u32 *) reslist; - int len = 0; int i = 0; int rc; struct i2o_dma res; @@ -448,7 +473,6 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, msg->body[i++] = cpu_to_le32(0x00000000); msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */ memcpy(&msg->body[i], oplist, oplen); - i += (oplen / 4 + (oplen % 4 ? 1 : 0)); msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */ msg->body[i++] = cpu_to_le32(res.phys); @@ -466,36 +490,7 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, memcpy(reslist, res.virt, res.len); i2o_dma_free(dev, &res); - /* Query failed */ - if (rc) - return rc; - /* - * Calculate number of bytes of Result LIST - * We need to loop through each Result BLOCK and grab the length - */ - restmp = res32 + 1; - len = 1; - for (i = 0; i < (res32[0] & 0X0000FFFF); i++) { - if (restmp[0] & 0x00FF0000) { /* BlockStatus != SUCCESS */ - printk(KERN_WARNING - "%s - Error:\n ErrorInfoSize = 0x%02x, " - "BlockStatus = 0x%02x, BlockSize = 0x%04x\n", - (cmd == - I2O_CMD_UTIL_PARAMS_SET) ? "PARAMS_SET" : - "PARAMS_GET", res32[1] >> 24, - (res32[1] >> 16) & 0xFF, res32[1] & 0xFFFF); - - /* - * If this is the only request,than we return an error - */ - if ((res32[0] & 0x0000FFFF) == 1) { - return -((res32[1] >> 16) & 0xFF); /* -BlockStatus */ - } - } - len += restmp[0] & 0x0000FFFF; /* Length of res BLOCK */ - restmp += restmp[0] & 0x0000FFFF; /* Skip to next BLOCK */ - } - return (len << 2); /* bytes used by result list */ + return rc; } /* @@ -504,28 +499,25 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field, void *buf, int buflen) { - u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field }; + u32 opblk[] = { cpu_to_le32(0x00000001), + cpu_to_le32((u16) group << 16 | I2O_PARAMS_FIELD_GET), + cpu_to_le32((s16) field << 16 | 0x00000001) + }; u8 *resblk; /* 8 bytes for header */ - int size; - - if (field == -1) /* whole group */ - opblk[4] = -1; + int rc; resblk = kmalloc(buflen + 8, GFP_KERNEL | GFP_ATOMIC); if (!resblk) return -ENOMEM; - size = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk, - sizeof(opblk), resblk, buflen + 8); + rc = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk, + sizeof(opblk), resblk, buflen + 8); memcpy(buf, resblk + 8, buflen); /* cut off header */ kfree(resblk); - if (size > buflen) - return buflen; - - return size; + return rc; } /* diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c index 71a0933..d24548f 100644 --- a/drivers/message/i2o/exec-osm.c +++ b/drivers/message/i2o/exec-osm.c @@ -77,7 +77,7 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void) wait = kmalloc(sizeof(*wait), GFP_KERNEL); if (!wait) - return ERR_PTR(-ENOMEM); + return NULL; memset(wait, 0, sizeof(*wait)); @@ -271,8 +271,8 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d, struct i2o_device *dev = to_i2o_device(d); u16 id; - if (i2o_parm_field_get(dev, 0x0000, 0, &id, 2)) { - sprintf(buf, "0x%04x", id); + if (!i2o_parm_field_get(dev, 0x0000, 0, &id, 2)) { + sprintf(buf, "0x%04x", le16_to_cpu(id)); return strlen(buf) + 1; } @@ -293,8 +293,8 @@ static ssize_t i2o_exec_show_product_id(struct device *d, struct i2o_device *dev = to_i2o_device(d); u16 id; - if (i2o_parm_field_get(dev, 0x0000, 1, &id, 2)) { - sprintf(buf, "0x%04x", id); + if (!i2o_parm_field_get(dev, 0x0000, 1, &id, 2)) { + sprintf(buf, "0x%04x", le16_to_cpu(id)); return strlen(buf) + 1; } @@ -364,7 +364,9 @@ static void i2o_exec_lct_modified(struct i2o_controller *c) if (i2o_device_parse_lct(c) != -EAGAIN) change_ind = c->lct->change_ind + 1; +#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES i2o_exec_lct_notify(c, change_ind); +#endif }; /** @@ -512,7 +514,8 @@ static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind) dev = &c->pdev->dev; - if (i2o_dma_realloc(dev, &c->dlct, sb->expected_lct_size, GFP_KERNEL)) + if (i2o_dma_realloc + (dev, &c->dlct, le32_to_cpu(sb->expected_lct_size), GFP_KERNEL)) return -ENOMEM; msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET); diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index 2bd15c7..ed2df54 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c @@ -1050,8 +1050,8 @@ static int i2o_block_probe(struct device *dev) int rc; u64 size; u32 blocksize; - u32 flags, status; u16 body_size = 4; + u16 power; unsigned short max_sectors; #ifdef CONFIG_I2O_EXT_ADAPTEC @@ -1109,22 +1109,20 @@ static int i2o_block_probe(struct device *dev) * Ask for the current media data. If that isn't supported * then we ask for the device capacity data */ - if (i2o_parm_field_get(i2o_dev, 0x0004, 1, &blocksize, 4) || - i2o_parm_field_get(i2o_dev, 0x0000, 3, &blocksize, 4)) { - blk_queue_hardsect_size(queue, blocksize); + if (!i2o_parm_field_get(i2o_dev, 0x0004, 1, &blocksize, 4) || + !i2o_parm_field_get(i2o_dev, 0x0000, 3, &blocksize, 4)) { + blk_queue_hardsect_size(queue, le32_to_cpu(blocksize)); } else osm_warn("unable to get blocksize of %s\n", gd->disk_name); - if (i2o_parm_field_get(i2o_dev, 0x0004, 0, &size, 8) || - i2o_parm_field_get(i2o_dev, 0x0000, 4, &size, 8)) { - set_capacity(gd, size >> KERNEL_SECTOR_SHIFT); + if (!i2o_parm_field_get(i2o_dev, 0x0004, 0, &size, 8) || + !i2o_parm_field_get(i2o_dev, 0x0000, 4, &size, 8)) { + set_capacity(gd, le64_to_cpu(size) >> KERNEL_SECTOR_SHIFT); } else osm_warn("could not get size of %s\n", gd->disk_name); - if (!i2o_parm_field_get(i2o_dev, 0x0000, 2, &i2o_blk_dev->power, 2)) - i2o_blk_dev->power = 0; - i2o_parm_field_get(i2o_dev, 0x0000, 5, &flags, 4); - i2o_parm_field_get(i2o_dev, 0x0000, 6, &status, 4); + if (!i2o_parm_field_get(i2o_dev, 0x0000, 2, &power, 2)) + i2o_blk_dev->power = power; i2o_event_register(i2o_dev, &i2o_block_driver, 0, 0xffffffff); diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c index 7a784fd..24061df 100644 --- a/drivers/message/i2o/i2o_scsi.c +++ b/drivers/message/i2o/i2o_scsi.c @@ -113,7 +113,7 @@ static struct i2o_scsi_host *i2o_scsi_host_alloc(struct i2o_controller *c) list_for_each_entry(i2o_dev, &c->devices, list) if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) { - if (i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) + if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) && (type == 0x01)) /* SCSI bus */ max_channel++; } @@ -146,7 +146,7 @@ static struct i2o_scsi_host *i2o_scsi_host_alloc(struct i2o_controller *c) i = 0; list_for_each_entry(i2o_dev, &c->devices, list) if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) { - if (i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) + if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) && (type == 0x01)) /* only SCSI bus */ i2o_shost->channel[i++] = i2o_dev; @@ -238,13 +238,15 @@ static int i2o_scsi_probe(struct device *dev) u8 type; struct i2o_device *d = i2o_shost->channel[0]; - if (i2o_parm_field_get(d, 0x0000, 0, &type, 1) + if (!i2o_parm_field_get(d, 0x0000, 0, &type, 1) && (type == 0x01)) /* SCSI bus */ - if (i2o_parm_field_get(d, 0x0200, 4, &id, 4)) { + if (!i2o_parm_field_get(d, 0x0200, 4, &id, 4)) { channel = 0; if (i2o_dev->lct_data.class_id == I2O_CLASS_RANDOM_BLOCK_STORAGE) - lun = i2o_shost->lun++; + lun = + cpu_to_le64(i2o_shost-> + lun++); else lun = 0; } @@ -253,10 +255,10 @@ static int i2o_scsi_probe(struct device *dev) break; case I2O_CLASS_SCSI_PERIPHERAL: - if (i2o_parm_field_get(i2o_dev, 0x0000, 3, &id, 4) < 0) + if (i2o_parm_field_get(i2o_dev, 0x0000, 3, &id, 4)) return -EFAULT; - if (i2o_parm_field_get(i2o_dev, 0x0000, 4, &lun, 8) < 0) + if (i2o_parm_field_get(i2o_dev, 0x0000, 4, &lun, 8)) return -EFAULT; parent = i2o_iop_find_device(c, i2o_dev->lct_data.parent_tid); @@ -281,20 +283,22 @@ static int i2o_scsi_probe(struct device *dev) return -EFAULT; } - if (id >= scsi_host->max_id) { - osm_warn("SCSI device id (%d) >= max_id of I2O host (%d)", id, - scsi_host->max_id); + if (le32_to_cpu(id) >= scsi_host->max_id) { + osm_warn("SCSI device id (%d) >= max_id of I2O host (%d)", + le32_to_cpu(id), scsi_host->max_id); return -EFAULT; } - if (lun >= scsi_host->max_lun) { - osm_warn("SCSI device id (%d) >= max_lun of I2O host (%d)", - (unsigned int)lun, scsi_host->max_lun); + if (le64_to_cpu(lun) >= scsi_host->max_lun) { + osm_warn("SCSI device lun (%lu) >= max_lun of I2O host (%d)", + (long unsigned int)le64_to_cpu(lun), + scsi_host->max_lun); return -EFAULT; } scsi_dev = - __scsi_add_device(i2o_shost->scsi_host, channel, id, lun, i2o_dev); + __scsi_add_device(i2o_shost->scsi_host, channel, le32_to_cpu(id), + le64_to_cpu(lun), i2o_dev); if (IS_ERR(scsi_dev)) { osm_warn("can not add SCSI device %03x\n", @@ -306,7 +310,8 @@ static int i2o_scsi_probe(struct device *dev) "scsi"); osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %d\n", - i2o_dev->lct_data.tid, channel, id, (unsigned int)lun); + i2o_dev->lct_data.tid, channel, le32_to_cpu(id), + (unsigned int)le64_to_cpu(lun)); return 0; }; -- cgit v1.1 From 24791bd48f643194d806654b587251b0f92233e8 Mon Sep 17 00:00:00 2001 From: Markus Lidel Date: Fri, 6 Jan 2006 00:19:31 -0800 Subject: [PATCH] I2O: Remove wrong I2O device class Removed wrong I2O device class, which was only needed to add sysfs attributes. Signed-off-by: Markus Lidel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/core.h | 2 + drivers/message/i2o/device.c | 144 ++++++++++++++++++------------------------- drivers/message/i2o/driver.c | 2 - drivers/message/i2o/iop.c | 34 ++-------- include/linux/i2o.h | 1 - 5 files changed, 68 insertions(+), 115 deletions(-) diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h index 9eefedb..9aa9b91 100644 --- a/drivers/message/i2o/core.h +++ b/drivers/message/i2o/core.h @@ -33,6 +33,8 @@ extern int __init i2o_pci_init(void); extern void __exit i2o_pci_exit(void); /* device */ +extern struct device_attribute i2o_device_attrs[]; + extern void i2o_device_remove(struct i2o_device *); extern int i2o_device_parse_lct(struct i2o_controller *); diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index 1db2621..a5e260b 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c @@ -142,8 +142,9 @@ static void i2o_device_release(struct device *dev) /** - * i2o_device_class_show_class_id - Displays class id of I2O device - * @cd: class device of which the class id should be displayed + * i2o_device_show_class_id - Displays class id of I2O device + * @dev: device of which the class id should be displayed + * @attr: pointer to device attribute * @buf: buffer into which the class id should be printed * * Returns the number of bytes which are printed into the buffer. @@ -159,15 +160,15 @@ static ssize_t i2o_device_show_class_id(struct device *dev, } /** - * i2o_device_class_show_tid - Displays TID of I2O device - * @cd: class device of which the TID should be displayed - * @buf: buffer into which the class id should be printed + * i2o_device_show_tid - Displays TID of I2O device + * @dev: device of which the TID should be displayed + * @attr: pointer to device attribute + * @buf: buffer into which the TID should be printed * * Returns the number of bytes which are printed into the buffer. */ static ssize_t i2o_device_show_tid(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, char *buf) { struct i2o_device *i2o_dev = to_i2o_device(dev); @@ -209,66 +210,6 @@ static struct i2o_device *i2o_device_alloc(void) } /** - * i2o_setup_sysfs_links - Adds attributes to the I2O device - * @cd: I2O class device which is added to the I2O device class - * - * This function get called when a I2O device is added to the class. It - * creates the attributes for each device and creates user/parent symlink - * if necessary. - * - * Returns 0 on success or negative error code on failure. - */ -static void i2o_setup_sysfs_links(struct i2o_device *i2o_dev) -{ - struct i2o_controller *c = i2o_dev->iop; - struct i2o_device *tmp; - - /* create user entries for this device */ - tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid); - if (tmp && tmp != i2o_dev) - sysfs_create_link(&i2o_dev->device.kobj, - &tmp->device.kobj, "user"); - - /* create user entries refering to this device */ - list_for_each_entry(tmp, &c->devices, list) - if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid && - tmp != i2o_dev) - sysfs_create_link(&tmp->device.kobj, - &i2o_dev->device.kobj, "user"); - - /* create parent entries for this device */ - tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); - if (tmp && tmp != i2o_dev) - sysfs_create_link(&i2o_dev->device.kobj, - &tmp->device.kobj, "parent"); - - /* create parent entries refering to this device */ - list_for_each_entry(tmp, &c->devices, list) - if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid && - tmp != i2o_dev) - sysfs_create_link(&tmp->device.kobj, - &i2o_dev->device.kobj, "parent"); -} - -static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev) -{ - struct i2o_controller *c = i2o_dev->iop; - struct i2o_device *tmp; - - sysfs_remove_link(&i2o_dev->device.kobj, "parent"); - sysfs_remove_link(&i2o_dev->device.kobj, "user"); - - list_for_each_entry(tmp, &c->devices, list) { - if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) - sysfs_remove_link(&tmp->device.kobj, "parent"); - if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid) - sysfs_remove_link(&tmp->device.kobj, "user"); - } -} - - - -/** * i2o_device_add - allocate a new I2O device and add it to the IOP * @iop: I2O controller where the device is on * @entry: LCT entry of the I2O device @@ -282,33 +223,57 @@ static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev) static struct i2o_device *i2o_device_add(struct i2o_controller *c, i2o_lct_entry * entry) { - struct i2o_device *dev; + struct i2o_device *i2o_dev, *tmp; - dev = i2o_device_alloc(); - if (IS_ERR(dev)) { + i2o_dev = i2o_device_alloc(); + if (IS_ERR(i2o_dev)) { printk(KERN_ERR "i2o: unable to allocate i2o device\n"); - return dev; + return i2o_dev; } - dev->lct_data = *entry; - dev->iop = c; + i2o_dev->lct_data = *entry; - snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit, - dev->lct_data.tid); + snprintf(i2o_dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit, + i2o_dev->lct_data.tid); - dev->device.parent = &c->device; + i2o_dev->iop = c; + i2o_dev->device.parent = &c->device; - device_register(&dev->device); + device_register(&i2o_dev->device); - list_add_tail(&dev->list, &c->devices); + list_add_tail(&i2o_dev->list, &c->devices); - i2o_setup_sysfs_links(dev); + /* create user entries for this device */ + tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid); + if (tmp && (tmp != i2o_dev)) + sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj, + "user"); - i2o_driver_notify_device_add_all(dev); + /* create user entries refering to this device */ + list_for_each_entry(tmp, &c->devices, list) + if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid) + && (tmp != i2o_dev)) + sysfs_create_link(&tmp->device.kobj, + &i2o_dev->device.kobj, "user"); - pr_debug("i2o: device %s added\n", dev->device.bus_id); + /* create parent entries for this device */ + tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); + if (tmp && (tmp != i2o_dev)) + sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj, + "parent"); - return dev; + /* create parent entries refering to this device */ + list_for_each_entry(tmp, &c->devices, list) + if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) + && (tmp != i2o_dev)) + sysfs_create_link(&tmp->device.kobj, + &i2o_dev->device.kobj, "parent"); + + i2o_driver_notify_device_add_all(i2o_dev); + + pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id); + + return i2o_dev; } /** @@ -321,9 +286,22 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c, */ void i2o_device_remove(struct i2o_device *i2o_dev) { + struct i2o_device *tmp; + struct i2o_controller *c = i2o_dev->iop; + i2o_driver_notify_device_remove_all(i2o_dev); - i2o_remove_sysfs_links(i2o_dev); + + sysfs_remove_link(&i2o_dev->device.kobj, "parent"); + sysfs_remove_link(&i2o_dev->device.kobj, "user"); + + list_for_each_entry(tmp, &c->devices, list) { + if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) + sysfs_remove_link(&tmp->device.kobj, "parent"); + if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid) + sysfs_remove_link(&tmp->device.kobj, "user"); + } list_del(&i2o_dev->list); + device_unregister(&i2o_dev->device); } diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c index 0fb9c4e..25292b3 100644 --- a/drivers/message/i2o/driver.c +++ b/drivers/message/i2o/driver.c @@ -61,8 +61,6 @@ static int i2o_bus_match(struct device *dev, struct device_driver *drv) }; /* I2O bus type */ -extern struct device_attribute i2o_device_attrs[]; - struct bus_type i2o_bus_type = { .name = "i2o", .match = i2o_bus_match, diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c index f86abb4..7411a05 100644 --- a/drivers/message/i2o/iop.c +++ b/drivers/message/i2o/iop.c @@ -806,7 +806,6 @@ void i2o_iop_remove(struct i2o_controller *c) list_for_each_entry_safe(dev, tmp, &c->devices, list) i2o_device_remove(dev); - class_device_unregister(c->classdev); device_del(&c->device); /* Ask the IOP to switch to RESET state */ @@ -1050,9 +1049,6 @@ static void i2o_iop_release(struct device *dev) i2o_iop_free(c); }; -/* I2O controller class */ -static struct class *i2o_controller_class; - /** * i2o_iop_alloc - Allocate and initialize a i2o_controller struct * @@ -1124,36 +1120,29 @@ int i2o_iop_add(struct i2o_controller *c) goto iop_reset; } - c->classdev = class_device_create(i2o_controller_class, NULL, MKDEV(0,0), - &c->device, "iop%d", c->unit); - if (IS_ERR(c->classdev)) { - osm_err("%s: could not add controller class\n", c->name); - goto device_del; - } - osm_info("%s: Activating I2O controller...\n", c->name); osm_info("%s: This may take a few minutes if there are many devices\n", c->name); if ((rc = i2o_iop_activate(c))) { osm_err("%s: could not activate controller\n", c->name); - goto class_del; + goto device_del; } osm_debug("%s: building sys table...\n", c->name); if ((rc = i2o_systab_build())) - goto class_del; + goto device_del; osm_debug("%s: online controller...\n", c->name); if ((rc = i2o_iop_online(c))) - goto class_del; + goto device_del; osm_debug("%s: getting LCT...\n", c->name); if ((rc = i2o_exec_lct_get(c))) - goto class_del; + goto device_del; list_add(&c->list, &i2o_controllers); @@ -1163,9 +1152,6 @@ int i2o_iop_add(struct i2o_controller *c) return 0; - class_del: - class_device_unregister(c->classdev); - device_del: device_del(&c->device); @@ -1225,14 +1211,8 @@ static int __init i2o_iop_init(void) printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); - i2o_controller_class = class_create(THIS_MODULE, "i2o_controller"); - if (IS_ERR(i2o_controller_class)) { - osm_err("can't register class i2o_controller\n"); - goto exit; - } - if ((rc = i2o_driver_init())) - goto class_exit; + goto exit; if ((rc = i2o_exec_init())) goto driver_exit; @@ -1248,9 +1228,6 @@ static int __init i2o_iop_init(void) driver_exit: i2o_driver_exit(); - class_exit: - class_destroy(i2o_controller_class); - exit: return rc; } @@ -1265,7 +1242,6 @@ static void __exit i2o_iop_exit(void) i2o_pci_exit(); i2o_exec_exit(); i2o_driver_exit(); - class_destroy(i2o_controller_class); }; module_init(i2o_iop_init); diff --git a/include/linux/i2o.h b/include/linux/i2o.h index 9e359a9..4c18b77 100644 --- a/include/linux/i2o.h +++ b/include/linux/i2o.h @@ -561,7 +561,6 @@ struct i2o_controller { struct resource mem_resource; /* Mem resource allocated to the IOP */ struct device device; - struct class_device *classdev; /* I2O controller class device */ struct i2o_device *exec; /* Executive */ #if BITS_PER_LONG == 64 spinlock_t context_list_lock; /* lock for context_list */ -- cgit v1.1 From dcceafe25a5f47cf69e5b46b4da6f15186ec8386 Mon Sep 17 00:00:00 2001 From: Markus Lidel Date: Fri, 6 Jan 2006 00:19:32 -0800 Subject: [PATCH] I2O: Bugfixes - Removed some kmalloc's with __GFP_ZERO and replace it with memset() because it didn't work properly. - Fixed returned message frame in i2o_cfg_passthru() which caused raidutils to display wrong error message in case a disk was missing. - Fixed size of printk() in i2o_scsi.c. - Fixed get_device() and put_device() in probing of the I2O controller. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/driver.c | 5 +++-- drivers/message/i2o/i2o_config.c | 29 ++++++++++++++--------------- drivers/message/i2o/i2o_scsi.c | 4 ++-- drivers/message/i2o/pci.c | 6 +----- include/linux/i2o.h | 2 +- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c index 25292b3..9c631c8 100644 --- a/drivers/message/i2o/driver.c +++ b/drivers/message/i2o/driver.c @@ -217,14 +217,15 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m) /* cut of header from message size (in 32-bit words) */ size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5; - evt = kmalloc(size * 4 + sizeof(*evt), GFP_ATOMIC | __GFP_ZERO); + evt = kmalloc(size * 4 + sizeof(*evt), GFP_ATOMIC); if (!evt) return -ENOMEM; + memset(evt, 0, size * 4 + sizeof(*evt)); evt->size = size; evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt); evt->event_indicator = le32_to_cpu(msg->body[0]); - memcpy(&evt->tcntxt, &msg->u.s.tcntxt, size * 4); + memcpy(&evt->data, &msg->body[1], size * 4); list_for_each_entry_safe(dev, tmp, &c->devices, list) if (dev->lct_data.tid == tid) { diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index 4fe73d6..286fef3 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c @@ -36,12 +36,12 @@ #include -#include "core.h" - #define SG_TABLESIZE 30 -static int i2o_cfg_ioctl(struct inode *inode, struct file *fp, unsigned int cmd, - unsigned long arg); +extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int); + +static int i2o_cfg_ioctl(struct inode *, struct file *, unsigned int, + unsigned long); static spinlock_t i2o_config_lock; @@ -593,9 +593,6 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, sg_offset = (msg->u.head[0] >> 4) & 0x0f; - msg->u.s.icntxt = cpu_to_le32(i2o_config_driver.context); - msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, reply)); - memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); if (sg_offset) { struct sg_simple_element *sg; @@ -629,7 +626,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, goto cleanup; } sg_size = sg[i].flag_count & 0xffffff; - p = &(sg_list[sg_index++]); + p = &(sg_list[sg_index]); /* Allocate memory for the transfer */ if (i2o_dma_alloc (&c->pdev->dev, p, sg_size, @@ -640,6 +637,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, rcode = -ENOMEM; goto sg_list_cleanup; } + sg_index++; /* Copy in the user's SG buffer if necessary */ if (sg[i]. flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) { @@ -661,8 +659,10 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, } rcode = i2o_msg_post_wait(c, msg, 60); - if (rcode) + if (rcode) { + reply[4] = ((u32) rcode) << 24; goto sg_list_cleanup; + } if (sg_offset) { u32 msg[I2O_OUTBOUND_MSG_FRAME_SIZE]; @@ -712,6 +712,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, } } + sg_list_cleanup: /* Copy back the reply to user space */ if (reply_size) { // we wrote our own values for context - now restore the user supplied ones @@ -729,7 +730,6 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, } } - sg_list_cleanup: for (i = 0; i < sg_index; i++) i2o_dma_free(&c->pdev->dev, &sg_list[i]); @@ -827,9 +827,6 @@ static int i2o_cfg_passthru(unsigned long arg) sg_offset = (msg->u.head[0] >> 4) & 0x0f; - msg->u.s.icntxt = cpu_to_le32(i2o_config_driver.context); - msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, reply)); - memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); if (sg_offset) { struct sg_simple_element *sg; @@ -892,8 +889,10 @@ static int i2o_cfg_passthru(unsigned long arg) } rcode = i2o_msg_post_wait(c, msg, 60); - if (rcode) + if (rcode) { + reply[4] = ((u32) rcode) << 24; goto sg_list_cleanup; + } if (sg_offset) { u32 msg[128]; @@ -943,6 +942,7 @@ static int i2o_cfg_passthru(unsigned long arg) } } + sg_list_cleanup: /* Copy back the reply to user space */ if (reply_size) { // we wrote our own values for context - now restore the user supplied ones @@ -959,7 +959,6 @@ static int i2o_cfg_passthru(unsigned long arg) } } - sg_list_cleanup: for (i = 0; i < sg_index; i++) kfree(sg_list[i]); diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c index 24061df..76b9516 100644 --- a/drivers/message/i2o/i2o_scsi.c +++ b/drivers/message/i2o/i2o_scsi.c @@ -309,9 +309,9 @@ static int i2o_scsi_probe(struct device *dev) sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj, "scsi"); - osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %d\n", + osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n", i2o_dev->lct_data.tid, channel, le32_to_cpu(id), - (unsigned int)le64_to_cpu(lun)); + (long unsigned int)le64_to_cpu(lun)); return 0; }; diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c index 329d482..c5b656c 100644 --- a/drivers/message/i2o/pci.c +++ b/drivers/message/i2o/pci.c @@ -339,7 +339,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev, pci_name(pdev)); c->pdev = pdev; - c->device.parent = get_device(&pdev->dev); + c->device.parent = &pdev->dev; /* Cards that fall apart if you hit them with large I/O loads... */ if (pdev->vendor == PCI_VENDOR_ID_NCR && pdev->device == 0x0630) { @@ -410,8 +410,6 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev, if ((rc = i2o_iop_add(c))) goto uninstall; - get_device(&c->device); - if (i960) pci_write_config_word(i960, 0x42, 0x03ff); @@ -424,7 +422,6 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev, i2o_pci_free(c); free_controller: - put_device(c->device.parent); i2o_iop_free(c); disable: @@ -454,7 +451,6 @@ static void __devexit i2o_pci_remove(struct pci_dev *pdev) printk(KERN_INFO "%s: Controller removed.\n", c->name); - put_device(c->device.parent); put_device(&c->device); }; diff --git a/include/linux/i2o.h b/include/linux/i2o.h index 4c18b77..9ba8067 100644 --- a/include/linux/i2o.h +++ b/include/linux/i2o.h @@ -384,7 +384,7 @@ /* defines for max_sectors and max_phys_segments */ #define I2O_MAX_SECTORS 1024 -#define I2O_MAX_SECTORS_LIMITED 256 +#define I2O_MAX_SECTORS_LIMITED 128 #define I2O_MAX_PHYS_SEGMENTS MAX_PHYS_SEGMENTS /* -- cgit v1.1 From 2e1973a3cd0b9fe31469be62df3583bdc5a34f51 Mon Sep 17 00:00:00 2001 From: Markus Lidel Date: Fri, 6 Jan 2006 00:19:32 -0800 Subject: [PATCH] I2O: Beautifying Fix some typos and minor code beautifying. Signed-off-by: Markus Lidel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/bus-osm.c | 2 +- drivers/message/i2o/config-osm.c | 2 +- drivers/message/i2o/core.h | 7 ++----- drivers/message/i2o/device.c | 9 +++++---- drivers/message/i2o/driver.c | 2 +- drivers/message/i2o/i2o_block.c | 8 +++++--- drivers/message/i2o/i2o_proc.c | 2 +- drivers/message/i2o/i2o_scsi.c | 2 +- drivers/message/i2o/iop.c | 12 +++--------- 9 files changed, 20 insertions(+), 26 deletions(-) diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c index ce039d3..ac06f10 100644 --- a/drivers/message/i2o/bus-osm.c +++ b/drivers/message/i2o/bus-osm.c @@ -17,7 +17,7 @@ #include #define OSM_NAME "bus-osm" -#define OSM_VERSION "$Rev$" +#define OSM_VERSION "1.317" #define OSM_DESCRIPTION "I2O Bus Adapter OSM" static struct i2o_driver i2o_bus_driver; diff --git a/drivers/message/i2o/config-osm.c b/drivers/message/i2o/config-osm.c index 10432f6..b613890 100644 --- a/drivers/message/i2o/config-osm.c +++ b/drivers/message/i2o/config-osm.c @@ -22,7 +22,7 @@ #include #define OSM_NAME "config-osm" -#define OSM_VERSION "1.248" +#define OSM_VERSION "1.317" #define OSM_DESCRIPTION "I2O Configuration OSM" /* access mode user rw */ diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h index 9aa9b91..edab686 100644 --- a/drivers/message/i2o/core.h +++ b/drivers/message/i2o/core.h @@ -14,8 +14,6 @@ */ /* Exec-OSM */ -extern struct bus_type i2o_bus_type; - extern struct i2o_driver i2o_exec_driver; extern int i2o_exec_lct_get(struct i2o_controller *); @@ -23,6 +21,8 @@ extern int __init i2o_exec_init(void); extern void __exit i2o_exec_exit(void); /* driver */ +extern struct bus_type i2o_bus_type; + extern int i2o_driver_dispatch(struct i2o_controller *, u32); extern int __init i2o_driver_init(void); @@ -45,9 +45,6 @@ extern void i2o_iop_free(struct i2o_controller *); extern int i2o_iop_add(struct i2o_controller *); extern void i2o_iop_remove(struct i2o_controller *); -/* config */ -extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int); - /* control registers relative to c->base */ #define I2O_IRQ_STATUS 0x30 #define I2O_IRQ_MASK 0x34 diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index a5e260b..773b0a4 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c @@ -176,6 +176,7 @@ static ssize_t i2o_device_show_tid(struct device *dev, return strlen(buf) + 1; } +/* I2O device attributes */ struct device_attribute i2o_device_attrs[] = { __ATTR(class_id, S_IRUGO, i2o_device_show_class_id, NULL), __ATTR(tid, S_IRUGO, i2o_device_show_tid, NULL), @@ -505,12 +506,12 @@ int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field, * else return specific fields * ibuf contains fieldindexes * - * if oper == I2O_PARAMS_LIST_GET, get from specific rows - * if fieldcount == -1 return all fields + * if oper == I2O_PARAMS_LIST_GET, get from specific rows + * if fieldcount == -1 return all fields * ibuf contains rowcount, keyvalues - * else return specific fields + * else return specific fields * fieldcount is # of fieldindexes - * ibuf contains fieldindexes, rowcount, keyvalues + * ibuf contains fieldindexes, rowcount, keyvalues * * You could also use directly function i2o_issue_params(). */ diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c index 9c631c8..45f4119 100644 --- a/drivers/message/i2o/driver.c +++ b/drivers/message/i2o/driver.c @@ -64,7 +64,7 @@ static int i2o_bus_match(struct device *dev, struct device_driver *drv) struct bus_type i2o_bus_type = { .name = "i2o", .match = i2o_bus_match, - .dev_attrs = i2o_device_attrs, + .dev_attrs = i2o_device_attrs }; /** diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index ed2df54..3e865b7 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c @@ -59,10 +59,12 @@ #include #include +#include + #include "i2o_block.h" #define OSM_NAME "block-osm" -#define OSM_VERSION "1.287" +#define OSM_VERSION "1.316" #define OSM_DESCRIPTION "I2O Block Device OSM" static struct i2o_driver i2o_block_driver; @@ -845,10 +847,10 @@ static int i2o_block_transfer(struct request *req) * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME */ if (rq_data_dir(req) == READ) { - cmd[0] = 0x28; + cmd[0] = READ_10; scsi_flags = 0x60a0000a; } else { - cmd[0] = 0x2A; + cmd[0] = WRITE_10; scsi_flags = 0xa0a0000a; } diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c index d559a17..2a0c42b 100644 --- a/drivers/message/i2o/i2o_proc.c +++ b/drivers/message/i2o/i2o_proc.c @@ -28,7 +28,7 @@ */ #define OSM_NAME "proc-osm" -#define OSM_VERSION "1.145" +#define OSM_VERSION "1.316" #define OSM_DESCRIPTION "I2O ProcFS OSM" #define I2O_MAX_MODULES 4 diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c index 76b9516..f9e5a23 100644 --- a/drivers/message/i2o/i2o_scsi.c +++ b/drivers/message/i2o/i2o_scsi.c @@ -70,7 +70,7 @@ #include #define OSM_NAME "scsi-osm" -#define OSM_VERSION "1.282" +#define OSM_VERSION "1.316" #define OSM_DESCRIPTION "I2O SCSI Peripheral OSM" static struct i2o_driver i2o_scsi_driver; diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c index 7411a05..0e46518 100644 --- a/drivers/message/i2o/iop.c +++ b/drivers/message/i2o/iop.c @@ -32,7 +32,7 @@ #include "core.h" #define OSM_NAME "i2o" -#define OSM_VERSION "1.288" +#define OSM_VERSION "1.316" #define OSM_DESCRIPTION "I2O subsystem" /* global I2O controller list */ @@ -730,10 +730,6 @@ static int i2o_iop_systab_set(struct i2o_controller *c) * Provide three SGL-elements: * System table (SysTab), Private memory space declaration and * Private i/o space declaration - * - * FIXME: is this still true? - * Nasty one here. We can't use dma_alloc_coherent to send the - * same table to everyone. We have to go remap it for them all */ msg->body[0] = cpu_to_le32(c->unit + 2); @@ -756,8 +752,6 @@ static int i2o_iop_systab_set(struct i2o_controller *c) else osm_debug("%s: SysTab set.\n", c->name); - i2o_status_get(c); // Entered READY state - return rc; } @@ -767,7 +761,7 @@ static int i2o_iop_systab_set(struct i2o_controller *c) * * Send the system table and enable the I2O controller. * - * Returns 0 on success or negativer error code on failure. + * Returns 0 on success or negative error code on failure. */ static int i2o_iop_online(struct i2o_controller *c) { @@ -977,7 +971,7 @@ int i2o_status_get(struct i2o_controller *c) * The HRT contains information about possible hidden devices but is * mostly useless to us. * - * Returns 0 on success or negativer error code on failure. + * Returns 0 on success or negative error code on failure. */ static int i2o_hrt_get(struct i2o_controller *c) { -- cgit v1.1 From f6ed39a6e1a88240eec629a3da17c3a47ada3b89 Mon Sep 17 00:00:00 2001 From: Markus Lidel Date: Fri, 6 Jan 2006 00:19:33 -0800 Subject: [PATCH] I2O: Optimizing - make i2o_iop_free() static inline (from Adrian Bunk) - changed kmalloc() + memset(0) into kzalloc() Signed-off-by: Markus Lidel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/config-osm.c | 2 +- drivers/message/i2o/core.h | 11 ++++++++++- drivers/message/i2o/device.c | 4 +--- drivers/message/i2o/driver.c | 7 ++----- drivers/message/i2o/exec-osm.c | 4 +--- drivers/message/i2o/i2o_block.c | 5 ++--- drivers/message/i2o/i2o_config.c | 6 ++---- drivers/message/i2o/iop.c | 18 +++--------------- 8 files changed, 22 insertions(+), 35 deletions(-) diff --git a/drivers/message/i2o/config-osm.c b/drivers/message/i2o/config-osm.c index b613890..3bba7aa 100644 --- a/drivers/message/i2o/config-osm.c +++ b/drivers/message/i2o/config-osm.c @@ -22,7 +22,7 @@ #include #define OSM_NAME "config-osm" -#define OSM_VERSION "1.317" +#define OSM_VERSION "1.323" #define OSM_DESCRIPTION "I2O Configuration OSM" /* access mode user rw */ diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h index edab686..9062856 100644 --- a/drivers/message/i2o/core.h +++ b/drivers/message/i2o/core.h @@ -40,7 +40,16 @@ extern int i2o_device_parse_lct(struct i2o_controller *); /* IOP */ extern struct i2o_controller *i2o_iop_alloc(void); -extern void i2o_iop_free(struct i2o_controller *); + +/** + * i2o_iop_free - Free the i2o_controller struct + * @c: I2O controller to free + */ +static inline void i2o_iop_free(struct i2o_controller *c) +{ + i2o_pool_free(&c->in_msg); + kfree(c); +} extern int i2o_iop_add(struct i2o_controller *); extern void i2o_iop_remove(struct i2o_controller *); diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index 773b0a4..34976b2 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c @@ -195,12 +195,10 @@ static struct i2o_device *i2o_device_alloc(void) { struct i2o_device *dev; - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return ERR_PTR(-ENOMEM); - memset(dev, 0, sizeof(*dev)); - INIT_LIST_HEAD(&dev->list); init_MUTEX(&dev->lock); diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c index 45f4119..6413022 100644 --- a/drivers/message/i2o/driver.c +++ b/drivers/message/i2o/driver.c @@ -217,10 +217,9 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m) /* cut of header from message size (in 32-bit words) */ size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5; - evt = kmalloc(size * 4 + sizeof(*evt), GFP_ATOMIC); + evt = kzalloc(size * 4 + sizeof(*evt), GFP_ATOMIC); if (!evt) return -ENOMEM; - memset(evt, 0, size * 4 + sizeof(*evt)); evt->size = size; evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt); @@ -348,12 +347,10 @@ int __init i2o_driver_init(void) osm_info("max drivers = %d\n", i2o_max_drivers); i2o_drivers = - kmalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL); + kzalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL); if (!i2o_drivers) return -ENOMEM; - memset(i2o_drivers, 0, i2o_max_drivers * sizeof(*i2o_drivers)); - rc = bus_register(&i2o_bus_type); if (rc < 0) diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c index d24548f..d418ad3 100644 --- a/drivers/message/i2o/exec-osm.c +++ b/drivers/message/i2o/exec-osm.c @@ -75,12 +75,10 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void) { struct i2o_exec_wait *wait; - wait = kmalloc(sizeof(*wait), GFP_KERNEL); + wait = kzalloc(sizeof(*wait), GFP_KERNEL); if (!wait) return NULL; - memset(wait, 0, sizeof(*wait)); - INIT_LIST_HEAD(&wait->list); return wait; diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c index 3e865b7..c5807d6 100644 --- a/drivers/message/i2o/i2o_block.c +++ b/drivers/message/i2o/i2o_block.c @@ -64,7 +64,7 @@ #include "i2o_block.h" #define OSM_NAME "block-osm" -#define OSM_VERSION "1.316" +#define OSM_VERSION "1.325" #define OSM_DESCRIPTION "I2O Block Device OSM" static struct i2o_driver i2o_block_driver; @@ -981,13 +981,12 @@ static struct i2o_block_device *i2o_block_device_alloc(void) struct request_queue *queue; int rc; - dev = kmalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { osm_err("Insufficient memory to allocate I2O Block disk.\n"); rc = -ENOMEM; goto exit; } - memset(dev, 0, sizeof(*dev)); INIT_LIST_HEAD(&dev->open_queue); spin_lock_init(&dev->lock); diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index 286fef3..89daf67 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c @@ -583,13 +583,12 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, reply_size >>= 16; reply_size <<= 2; - reply = kmalloc(reply_size, GFP_KERNEL); + reply = kzalloc(reply_size, GFP_KERNEL); if (!reply) { printk(KERN_WARNING "%s: Could not allocate reply buffer\n", c->name); return -ENOMEM; } - memset(reply, 0, reply_size); sg_offset = (msg->u.head[0] >> 4) & 0x0f; @@ -817,13 +816,12 @@ static int i2o_cfg_passthru(unsigned long arg) reply_size >>= 16; reply_size <<= 2; - reply = kmalloc(reply_size, GFP_KERNEL); + reply = kzalloc(reply_size, GFP_KERNEL); if (!reply) { printk(KERN_WARNING "%s: Could not allocate reply buffer\n", c->name); return -ENOMEM; } - memset(reply, 0, reply_size); sg_offset = (msg->u.head[0] >> 4) & 0x0f; diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c index 0e46518..4921674 100644 --- a/drivers/message/i2o/iop.c +++ b/drivers/message/i2o/iop.c @@ -32,7 +32,7 @@ #include "core.h" #define OSM_NAME "i2o" -#define OSM_VERSION "1.316" +#define OSM_VERSION "1.325" #define OSM_DESCRIPTION "I2O subsystem" /* global I2O controller list */ @@ -838,12 +838,11 @@ static int i2o_systab_build(void) i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers * sizeof(struct i2o_sys_tbl_entry); - systab = i2o_systab.virt = kmalloc(i2o_systab.len, GFP_KERNEL); + systab = i2o_systab.virt = kzalloc(i2o_systab.len, GFP_KERNEL); if (!systab) { osm_err("unable to allocate memory for System Table\n"); return -ENOMEM; } - memset(systab, 0, i2o_systab.len); systab->version = I2OVERSION; systab->change_ind = change_ind + 1; @@ -1020,16 +1019,6 @@ static int i2o_hrt_get(struct i2o_controller *c) } /** - * i2o_iop_free - Free the i2o_controller struct - * @c: I2O controller to free - */ -void i2o_iop_free(struct i2o_controller *c) -{ - i2o_pool_free(&c->in_msg); - kfree(c); -}; - -/** * i2o_iop_release - release the memory for a I2O controller * @dev: I2O controller which should be released * @@ -1058,13 +1047,12 @@ struct i2o_controller *i2o_iop_alloc(void) struct i2o_controller *c; char poolname[32]; - c = kmalloc(sizeof(*c), GFP_KERNEL); + c = kzalloc(sizeof(*c), GFP_KERNEL); if (!c) { osm_err("i2o: Insufficient memory to allocate a I2O controller." "\n"); return ERR_PTR(-ENOMEM); } - memset(c, 0, sizeof(*c)); c->unit = unit++; sprintf(c->name, "iop%d", c->unit); -- cgit v1.1 From 524e3b623a9228efbdb70484b5214f27a1ca985d Mon Sep 17 00:00:00 2001 From: Markus Lidel Date: Fri, 6 Jan 2006 00:19:34 -0800 Subject: [PATCH] I2O: Lindent run Signed-off-by: Markus Lidel Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/message/i2o/device.c | 21 +++++++++------------ drivers/message/i2o/exec-osm.c | 2 +- drivers/message/i2o/i2o_lan.h | 38 +++++++++++++++++++------------------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c index 34976b2..ee18305 100644 --- a/drivers/message/i2o/device.c +++ b/drivers/message/i2o/device.c @@ -43,7 +43,7 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd, msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0); msg->u.head[1] = - cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid); + cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid); msg->body[0] = cpu_to_le32(type); return i2o_msg_post_wait(dev->iop, msg, 60); @@ -123,7 +123,6 @@ int i2o_device_claim_release(struct i2o_device *dev) return rc; } - /** * i2o_device_release - release the memory for a I2O device * @dev: I2O device which should be released @@ -140,7 +139,6 @@ static void i2o_device_release(struct device *dev) kfree(i2o_dev); } - /** * i2o_device_show_class_id - Displays class id of I2O device * @dev: device of which the class id should be displayed @@ -250,10 +248,10 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c, /* create user entries refering to this device */ list_for_each_entry(tmp, &c->devices, list) - if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid) - && (tmp != i2o_dev)) - sysfs_create_link(&tmp->device.kobj, - &i2o_dev->device.kobj, "user"); + if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid) + && (tmp != i2o_dev)) + sysfs_create_link(&tmp->device.kobj, + &i2o_dev->device.kobj, "user"); /* create parent entries for this device */ tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid); @@ -263,10 +261,10 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c, /* create parent entries refering to this device */ list_for_each_entry(tmp, &c->devices, list) - if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) - && (tmp != i2o_dev)) - sysfs_create_link(&tmp->device.kobj, - &i2o_dev->device.kobj, "parent"); + if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid) + && (tmp != i2o_dev)) + sysfs_create_link(&tmp->device.kobj, + &i2o_dev->device.kobj, "parent"); i2o_driver_notify_device_add_all(i2o_dev); @@ -410,7 +408,6 @@ int i2o_device_parse_lct(struct i2o_controller *c) return 0; } - /* * Run time support routines */ diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c index d418ad3..9bb9859 100644 --- a/drivers/message/i2o/exec-osm.c +++ b/drivers/message/i2o/exec-osm.c @@ -33,7 +33,7 @@ #include #include #include -#include /* wait_event_interruptible_timeout() needs this */ +#include /* wait_event_interruptible_timeout() needs this */ #include /* HZ */ #include "core.h" diff --git a/drivers/message/i2o/i2o_lan.h b/drivers/message/i2o/i2o_lan.h index 561d633..6502b81 100644 --- a/drivers/message/i2o/i2o_lan.h +++ b/drivers/message/i2o/i2o_lan.h @@ -103,14 +103,14 @@ #define I2O_LAN_DSC_SUSPENDED 0x11 struct i2o_packet_info { - u32 offset : 24; - u32 flags : 8; - u32 len : 24; - u32 status : 8; + u32 offset:24; + u32 flags:8; + u32 len:24; + u32 status:8; }; struct i2o_bucket_descriptor { - u32 context; /* FIXME: 64bit support */ + u32 context; /* FIXME: 64bit support */ struct i2o_packet_info packet_info[1]; }; @@ -127,14 +127,14 @@ struct i2o_lan_local { u8 unit; struct i2o_device *i2o_dev; - struct fddi_statistics stats; /* see also struct net_device_stats */ - unsigned short (*type_trans)(struct sk_buff *, struct net_device *); - atomic_t buckets_out; /* nbr of unused buckets on DDM */ - atomic_t tx_out; /* outstanding TXes */ - u8 tx_count; /* packets in one TX message frame */ - u16 tx_max_out; /* DDM's Tx queue len */ - u8 sgl_max; /* max SGLs in one message frame */ - u32 m; /* IOP address of the batch msg frame */ + struct fddi_statistics stats; /* see also struct net_device_stats */ + unsigned short (*type_trans) (struct sk_buff *, struct net_device *); + atomic_t buckets_out; /* nbr of unused buckets on DDM */ + atomic_t tx_out; /* outstanding TXes */ + u8 tx_count; /* packets in one TX message frame */ + u16 tx_max_out; /* DDM's Tx queue len */ + u8 sgl_max; /* max SGLs in one message frame */ + u32 m; /* IOP address of the batch msg frame */ struct work_struct i2o_batch_send_task; int send_active; @@ -144,16 +144,16 @@ struct i2o_lan_local { spinlock_t tx_lock; - u32 max_size_mc_table; /* max number of multicast addresses */ + u32 max_size_mc_table; /* max number of multicast addresses */ /* LAN OSM configurable parameters are here: */ - u16 max_buckets_out; /* max nbr of buckets to send to DDM */ - u16 bucket_thresh; /* send more when this many used */ + u16 max_buckets_out; /* max nbr of buckets to send to DDM */ + u16 bucket_thresh; /* send more when this many used */ u16 rx_copybreak; - u8 tx_batch_mode; /* Set when using batch mode sends */ - u32 i2o_event_mask; /* To turn on interesting event flags */ + u8 tx_batch_mode; /* Set when using batch mode sends */ + u32 i2o_event_mask; /* To turn on interesting event flags */ }; -#endif /* _I2O_LAN_H */ +#endif /* _I2O_LAN_H */ -- cgit v1.1 From 0aa7c6990e7de06131cdc14ef4abfcab017c24a0 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:34 -0800 Subject: [PATCH] fuse: clean up fuse_lookup() Simplify fuse_lookup() and related functions. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/dir.c | 75 ++++++++++++++++++----------------------------------------- 1 file changed, 23 insertions(+), 52 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 51f5da6..0d1438a 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -13,7 +13,6 @@ #include #include #include -#include static inline unsigned long time_to_jiffies(unsigned long sec, unsigned long nsec) @@ -22,6 +21,13 @@ static inline unsigned long time_to_jiffies(unsigned long sec, return jiffies + timespec_to_jiffies(&ts); } +static void fuse_change_timeout(struct dentry *entry, struct fuse_entry_out *o) +{ + struct fuse_inode *fi = get_fuse_inode(entry->d_inode); + entry->d_time = time_to_jiffies(o->entry_valid, o->entry_valid_nsec); + fi->i_time = time_to_jiffies(o->attr_valid, o->attr_valid_nsec); +} + static void fuse_lookup_init(struct fuse_req *req, struct inode *dir, struct dentry *entry, struct fuse_entry_out *outarg) @@ -66,10 +72,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) return 0; fuse_change_attributes(inode, &outarg.attr); - entry->d_time = time_to_jiffies(outarg.entry_valid, - outarg.entry_valid_nsec); - fi->i_time = time_to_jiffies(outarg.attr_valid, - outarg.attr_valid_nsec); + fuse_change_timeout(entry, &outarg); } return 1; } @@ -96,8 +99,8 @@ static struct dentry_operations fuse_dentry_operations = { .d_revalidate = fuse_dentry_revalidate, }; -static int fuse_lookup_iget(struct inode *dir, struct dentry *entry, - struct inode **inodep) +static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, + struct nameidata *nd) { int err; struct fuse_entry_out outarg; @@ -106,11 +109,11 @@ static int fuse_lookup_iget(struct inode *dir, struct dentry *entry, struct fuse_req *req; if (entry->d_name.len > FUSE_NAME_MAX) - return -ENAMETOOLONG; + return ERR_PTR(-ENAMETOOLONG); req = fuse_get_request(fc); if (!req) - return -EINTR; + return ERR_PTR(-EINTR); fuse_lookup_init(req, dir, entry, &outarg); request_send(fc, req); @@ -122,24 +125,22 @@ static int fuse_lookup_iget(struct inode *dir, struct dentry *entry, &outarg.attr); if (!inode) { fuse_send_forget(fc, req, outarg.nodeid, 1); - return -ENOMEM; + return ERR_PTR(-ENOMEM); } } fuse_put_request(fc, req); if (err && err != -ENOENT) - return err; + return ERR_PTR(err); - if (inode) { - struct fuse_inode *fi = get_fuse_inode(inode); - entry->d_time = time_to_jiffies(outarg.entry_valid, - outarg.entry_valid_nsec); - fi->i_time = time_to_jiffies(outarg.attr_valid, - outarg.attr_valid_nsec); + if (inode && dir_alias(inode)) { + iput(inode); + return ERR_PTR(-EIO); } - + d_add(entry, inode); entry->d_op = &fuse_dentry_operations; - *inodep = inode; - return 0; + if (inode) + fuse_change_timeout(entry, &outarg); + return NULL; } void fuse_invalidate_attr(struct inode *inode) @@ -163,7 +164,6 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, struct fuse_open_in inarg; struct fuse_open_out outopen; struct fuse_entry_out outentry; - struct fuse_inode *fi; struct fuse_file *ff; struct file *file; int flags = nd->intent.open.flags - 1; @@ -224,13 +224,8 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, goto out_put_request; } fuse_put_request(fc, req); - entry->d_time = time_to_jiffies(outentry.entry_valid, - outentry.entry_valid_nsec); - fi = get_fuse_inode(inode); - fi->i_time = time_to_jiffies(outentry.attr_valid, - outentry.attr_valid_nsec); - d_instantiate(entry, inode); + fuse_change_timeout(entry, &outentry); file = lookup_instantiate_filp(nd, entry, generic_file_open); if (IS_ERR(file)) { ff->fh = outopen.fh; @@ -254,7 +249,6 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, { struct fuse_entry_out outarg; struct inode *inode; - struct fuse_inode *fi; int err; req->in.h.nodeid = get_node_id(dir); @@ -286,14 +280,8 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, return -EIO; } - entry->d_time = time_to_jiffies(outarg.entry_valid, - outarg.entry_valid_nsec); - - fi = get_fuse_inode(inode); - fi->i_time = time_to_jiffies(outarg.attr_valid, - outarg.attr_valid_nsec); - d_instantiate(entry, inode); + fuse_change_timeout(entry, &outarg); fuse_invalidate_attr(dir); return 0; } @@ -883,23 +871,6 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry, return err; } -static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, - struct nameidata *nd) -{ - struct inode *inode; - int err; - - err = fuse_lookup_iget(dir, entry, &inode); - if (err) - return ERR_PTR(err); - if (inode && dir_alias(inode)) { - iput(inode); - return ERR_PTR(-EIO); - } - d_add(entry, inode); - return NULL; -} - static int fuse_setxattr(struct dentry *entry, const char *name, const void *value, size_t size, int flags) { -- cgit v1.1 From 4633a22e7added835fd1d4b072dbcc4474aa3017 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:36 -0800 Subject: [PATCH] fuse: clean up page offset calculation Use page_offset() instead of doing page offset calculation by hand. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/file.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 2ca8614..18aafa6 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -272,7 +272,6 @@ static int fuse_readpage(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; struct fuse_conn *fc = get_fuse_conn(inode); - loff_t pos = (loff_t) page->index << PAGE_CACHE_SHIFT; struct fuse_req *req = fuse_get_request(fc); int err = -EINTR; if (!req) @@ -281,7 +280,7 @@ static int fuse_readpage(struct file *file, struct page *page) req->out.page_zeroing = 1; req->num_pages = 1; req->pages[0] = page; - fuse_send_read(req, file, inode, pos, PAGE_CACHE_SIZE); + fuse_send_read(req, file, inode, page_offset(page), PAGE_CACHE_SIZE); err = req->out.h.error; fuse_put_request(fc, req); if (!err) @@ -295,7 +294,7 @@ static int fuse_readpage(struct file *file, struct page *page) static int fuse_send_readpages(struct fuse_req *req, struct file *file, struct inode *inode) { - loff_t pos = (loff_t) req->pages[0]->index << PAGE_CACHE_SHIFT; + loff_t pos = page_offset(req->pages[0]); size_t count = req->num_pages << PAGE_CACHE_SHIFT; unsigned i; req->out.page_zeroing = 1; @@ -402,7 +401,7 @@ static int fuse_commit_write(struct file *file, struct page *page, unsigned count = to - offset; struct inode *inode = page->mapping->host; struct fuse_conn *fc = get_fuse_conn(inode); - loff_t pos = ((loff_t) page->index << PAGE_CACHE_SHIFT) + offset; + loff_t pos = page_offset(page) + offset; struct fuse_req *req = fuse_get_request(fc); if (!req) return -EINTR; -- cgit v1.1 From 45714d65618407bce1fd0271bc58303ce14b0785 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:36 -0800 Subject: [PATCH] fuse: bump interface version Change interface version to 7.4. Following changes will need backward compatibility support, so store the minor version returned by userspace. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/dev.c | 2 ++ fs/fuse/fuse_i.h | 3 +++ include/linux/fuse.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 8f873e62..e5bc3f8 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -178,6 +178,8 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) if (req->misc.init_in_out.major != FUSE_KERNEL_VERSION) fc->conn_error = 1; + fc->minor = req->misc.init_in_out.minor; + /* After INIT reply is received other requests can go out. So do (FUSE_MAX_OUTSTANDING - 1) number of up()s on outstanding_sem. The last up() is done in diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 0ea5301..2d4835e 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -272,6 +272,9 @@ struct fuse_conn { /** Is create not implemented by fs? */ unsigned no_create : 1; + /** Negotiated minor version */ + unsigned minor; + /** Backing dev info */ struct backing_dev_info bdi; }; diff --git a/include/linux/fuse.h b/include/linux/fuse.h index b76b558..3c85f1a 100644 --- a/include/linux/fuse.h +++ b/include/linux/fuse.h @@ -14,7 +14,7 @@ #define FUSE_KERNEL_VERSION 7 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 3 +#define FUSE_KERNEL_MINOR_VERSION 4 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 -- cgit v1.1 From de5f12025572ef8fcffa4be5453061725acfb754 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:37 -0800 Subject: [PATCH] fuse: add frsize to statfs reply Add 'frsize' member to the statfs reply. I'm not sure if sending f_fsid will ever be needed, but just in case leave some space at the end of the structure, so less compatibility mess would be required. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/inode.c | 5 ++++- include/linux/fuse.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index e69a546..3b928a0 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -218,6 +218,7 @@ static void convert_fuse_statfs(struct kstatfs *stbuf, struct fuse_kstatfs *attr { stbuf->f_type = FUSE_SUPER_MAGIC; stbuf->f_bsize = attr->bsize; + stbuf->f_frsize = attr->frsize; stbuf->f_blocks = attr->blocks; stbuf->f_bfree = attr->bfree; stbuf->f_bavail = attr->bavail; @@ -238,10 +239,12 @@ static int fuse_statfs(struct super_block *sb, struct kstatfs *buf) if (!req) return -EINTR; + memset(&outarg, 0, sizeof(outarg)); req->in.numargs = 0; req->in.h.opcode = FUSE_STATFS; req->out.numargs = 1; - req->out.args[0].size = sizeof(outarg); + req->out.args[0].size = + fc->minor < 4 ? FUSE_COMPAT_STATFS_SIZE : sizeof(outarg); req->out.args[0].value = &outarg; request_send(fc, req); err = req->out.h.error; diff --git a/include/linux/fuse.h b/include/linux/fuse.h index 3c85f1a..9d5177c 100644 --- a/include/linux/fuse.h +++ b/include/linux/fuse.h @@ -53,6 +53,9 @@ struct fuse_kstatfs { __u64 ffree; __u32 bsize; __u32 namelen; + __u32 frsize; + __u32 padding; + __u32 spare[6]; }; #define FATTR_MODE (1 << 0) @@ -213,6 +216,8 @@ struct fuse_write_out { __u32 padding; }; +#define FUSE_COMPAT_STATFS_SIZE 48 + struct fuse_statfs_out { struct fuse_kstatfs st; }; -- cgit v1.1 From 8cbdf1e6f6876b37d2a0d96fd15ea9f90f7d51c1 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:38 -0800 Subject: [PATCH] fuse: support caching negative dentries Add support for caching negative dentries. Up till now, ->d_revalidate() always forced a new lookup on these. Now let the lookup method return a zero node ID (not used for anything else) meaning a negative entry, but with a positive cache timeout. The old way of signaling negative entry (replying ENOENT) still works. Userspace should check the ABI minor version to see whether sending a zero ID is allowed by the kernel or not. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/dir.c | 64 +++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 0d1438a..4c127f2 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -23,9 +23,26 @@ static inline unsigned long time_to_jiffies(unsigned long sec, static void fuse_change_timeout(struct dentry *entry, struct fuse_entry_out *o) { - struct fuse_inode *fi = get_fuse_inode(entry->d_inode); entry->d_time = time_to_jiffies(o->entry_valid, o->entry_valid_nsec); - fi->i_time = time_to_jiffies(o->attr_valid, o->attr_valid_nsec); + if (entry->d_inode) + get_fuse_inode(entry->d_inode)->i_time = + time_to_jiffies(o->attr_valid, o->attr_valid_nsec); +} + +void fuse_invalidate_attr(struct inode *inode) +{ + get_fuse_inode(inode)->i_time = jiffies - 1; +} + +static void fuse_invalidate_entry_cache(struct dentry *entry) +{ + entry->d_time = jiffies - 1; +} + +static void fuse_invalidate_entry(struct dentry *entry) +{ + d_invalidate(entry); + fuse_invalidate_entry_cache(entry); } static void fuse_lookup_init(struct fuse_req *req, struct inode *dir, @@ -45,15 +62,22 @@ static void fuse_lookup_init(struct fuse_req *req, struct inode *dir, static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) { - if (!entry->d_inode || is_bad_inode(entry->d_inode)) + struct inode *inode = entry->d_inode; + + if (inode && is_bad_inode(inode)) return 0; else if (time_after(jiffies, entry->d_time)) { int err; struct fuse_entry_out outarg; - struct inode *inode = entry->d_inode; - struct fuse_inode *fi = get_fuse_inode(inode); - struct fuse_conn *fc = get_fuse_conn(inode); - struct fuse_req *req = fuse_get_request(fc); + struct fuse_conn *fc; + struct fuse_req *req; + + fuse_invalidate_entry_cache(entry); + if (!inode) + return 0; + + fc = get_fuse_conn(inode); + req = fuse_get_request(fc); if (!req) return 0; @@ -61,6 +85,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) request_send(fc, req); err = req->out.h.error; if (!err) { + struct fuse_inode *fi = get_fuse_inode(inode); if (outarg.nodeid != get_node_id(inode)) { fuse_send_forget(fc, req, outarg.nodeid, 1); return 0; @@ -118,9 +143,9 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, fuse_lookup_init(req, dir, entry, &outarg); request_send(fc, req); err = req->out.h.error; - if (!err && invalid_nodeid(outarg.nodeid)) + if (!err && outarg.nodeid && invalid_nodeid(outarg.nodeid)) err = -EIO; - if (!err) { + if (!err && outarg.nodeid) { inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, &outarg.attr); if (!inode) { @@ -138,22 +163,13 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, } d_add(entry, inode); entry->d_op = &fuse_dentry_operations; - if (inode) + if (!err) fuse_change_timeout(entry, &outarg); + else + fuse_invalidate_entry_cache(entry); return NULL; } -void fuse_invalidate_attr(struct inode *inode) -{ - get_fuse_inode(inode)->i_time = jiffies - 1; -} - -static void fuse_invalidate_entry(struct dentry *entry) -{ - d_invalidate(entry); - entry->d_time = jiffies - 1; -} - static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, struct nameidata *nd) { @@ -387,6 +403,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry) inode->i_nlink = 0; fuse_invalidate_attr(inode); fuse_invalidate_attr(dir); + fuse_invalidate_entry_cache(entry); } else if (err == -EINTR) fuse_invalidate_entry(entry); return err; @@ -412,6 +429,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry) if (!err) { entry->d_inode->i_nlink = 0; fuse_invalidate_attr(dir); + fuse_invalidate_entry_cache(entry); } else if (err == -EINTR) fuse_invalidate_entry(entry); return err; @@ -447,6 +465,10 @@ static int fuse_rename(struct inode *olddir, struct dentry *oldent, fuse_invalidate_attr(olddir); if (olddir != newdir) fuse_invalidate_attr(newdir); + + /* newent will end up negative */ + if (newent->d_inode) + fuse_invalidate_entry_cache(newent); } else if (err == -EINTR) { /* If request was interrupted, DEITY only knows if the rename actually took place. If the invalidation -- cgit v1.1 From 6f9f11806af8ad3a107714a3ece56c1c4fafd047 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:39 -0800 Subject: [PATCH] fuse: add code documentation Document some not-so-trivial functions. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/dir.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 9 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 4c127f2..fead7f4 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -14,6 +14,15 @@ #include #include +/* + * FUSE caches dentries and attributes with separate timeout. The + * time in jiffies until the dentry/attributes are valid is stored in + * dentry->d_time and fuse_inode->i_time respectively. + */ + +/* + * Calculate the time in jiffies until a dentry/attributes are valid + */ static inline unsigned long time_to_jiffies(unsigned long sec, unsigned long nsec) { @@ -21,6 +30,10 @@ static inline unsigned long time_to_jiffies(unsigned long sec, return jiffies + timespec_to_jiffies(&ts); } +/* + * Set dentry and possibly attribute timeouts from the lookup/mk* + * replies + */ static void fuse_change_timeout(struct dentry *entry, struct fuse_entry_out *o) { entry->d_time = time_to_jiffies(o->entry_valid, o->entry_valid_nsec); @@ -29,16 +42,32 @@ static void fuse_change_timeout(struct dentry *entry, struct fuse_entry_out *o) time_to_jiffies(o->attr_valid, o->attr_valid_nsec); } +/* + * Mark the attributes as stale, so that at the next call to + * ->getattr() they will be fetched from userspace + */ void fuse_invalidate_attr(struct inode *inode) { get_fuse_inode(inode)->i_time = jiffies - 1; } +/* + * Just mark the entry as stale, so that a next attempt to look it up + * will result in a new lookup call to userspace + * + * This is called when a dentry is about to become negative and the + * timeout is unknown (unlink, rmdir, rename and in some cases + * lookup) + */ static void fuse_invalidate_entry_cache(struct dentry *entry) { entry->d_time = jiffies - 1; } +/* + * Same as fuse_invalidate_entry_cache(), but also try to remove the + * dentry from the hash + */ static void fuse_invalidate_entry(struct dentry *entry) { d_invalidate(entry); @@ -60,6 +89,15 @@ static void fuse_lookup_init(struct fuse_req *req, struct inode *dir, req->out.args[0].value = outarg; } +/* + * Check whether the dentry is still valid + * + * If the entry validity timeout has expired and the dentry is + * positive, try to redo the lookup. If the lookup results in a + * different inode, then let the VFS invalidate the dentry and redo + * the lookup once more. If the lookup results in the same inode, + * then refresh the attributes, timeouts and mark the dentry valid. + */ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) { struct inode *inode = entry->d_inode; @@ -72,6 +110,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) struct fuse_conn *fc; struct fuse_req *req; + /* Doesn't hurt to "reset" the validity timeout */ fuse_invalidate_entry_cache(entry); if (!inode) return 0; @@ -102,10 +141,13 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) return 1; } +/* + * Check if there's already a hashed alias of this directory inode. + * If yes, then lookup and mkdir must not create a new alias. + */ static int dir_alias(struct inode *inode) { if (S_ISDIR(inode->i_mode)) { - /* Don't allow creating an alias to a directory */ struct dentry *alias = d_find_alias(inode); if (alias) { dput(alias); @@ -170,6 +212,12 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, return NULL; } +/* + * Atomic create+open operation + * + * If the filesystem doesn't support this, then fall back to separate + * 'mknod' + 'open' requests. + */ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, struct nameidata *nd) { @@ -236,6 +284,9 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, if (!inode) { flags &= ~(O_CREAT | O_EXCL | O_TRUNC); ff->fh = outopen.fh; + /* Special release, with inode = NULL, this will + trigger a 'forget' request when the release is + complete */ fuse_send_release(fc, ff, outentry.nodeid, NULL, flags, 0); goto out_put_request; } @@ -259,6 +310,9 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, return err; } +/* + * Code shared between mknod, mkdir, symlink and link + */ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, struct inode *dir, struct dentry *entry, int mode) @@ -576,6 +630,15 @@ static int fuse_allow_task(struct fuse_conn *fc, struct task_struct *task) return 0; } +/* + * Check whether the inode attributes are still valid + * + * If the attribute validity timeout has expired, then fetch the fresh + * attributes with a 'getattr' request + * + * I'm not sure why cached attributes are never returned for the root + * inode, this is probably being too cautious. + */ static int fuse_revalidate(struct dentry *entry) { struct inode *inode = entry->d_inode; @@ -623,6 +686,19 @@ static int fuse_access(struct inode *inode, int mask) return err; } +/* + * Check permission. The two basic access models of FUSE are: + * + * 1) Local access checking ('default_permissions' mount option) based + * on file mode. This is the plain old disk filesystem permission + * modell. + * + * 2) "Remote" access checking, where server is responsible for + * checking permission in each inode operation. An exception to this + * is if ->permission() was invoked from sys_access() in which case an + * access request is sent. Execute permission is still checked + * locally based on file mode. + */ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) { struct fuse_conn *fc = get_fuse_conn(inode); @@ -641,14 +717,10 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd) err = generic_permission(inode, mask, NULL); } - /* FIXME: Need some mechanism to revoke permissions: - currently if the filesystem suddenly changes the - file mode, we will not be informed about it, and - continue to allow access to the file/directory. - - This is actually not so grave, since the user can - simply keep access to the file/directory anyway by - keeping it open... */ + /* Note: the opposite of the above test does not + exist. So if permissions are revoked this won't be + noticed immediately, only after the attribute + timeout has expired */ return err; } else { @@ -816,6 +888,15 @@ static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg) } } +/* + * Set attributes, and at the same time refresh them. + * + * Truncation is slightly complicated, because the 'truncate' request + * may fail, in which case we don't want to touch the mapping. + * vmtruncate() doesn't allow for this case. So do the rlimit + * checking by hand and call vmtruncate() only after the file has + * actually been truncated. + */ static int fuse_setattr(struct dentry *entry, struct iattr *attr) { struct inode *inode = entry->d_inode; -- cgit v1.1 From 248d86e87d12da19eee602075f05a49a5215288b Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:39 -0800 Subject: [PATCH] fuse: fail file operations on bad inode Make file operations on a bad inode fail. This just makes things a bit more consistent. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/dir.c | 7 ++++++- fs/fuse/file.c | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index fead7f4..9a6075d 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -773,7 +773,12 @@ static int fuse_readdir(struct file *file, void *dstbuf, filldir_t filldir) struct page *page; struct inode *inode = file->f_dentry->d_inode; struct fuse_conn *fc = get_fuse_conn(inode); - struct fuse_req *req = fuse_get_request(fc); + struct fuse_req *req; + + if (is_bad_inode(inode)) + return -EIO; + + req = fuse_get_request(fc); if (!req) return -EINTR; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 18aafa6..c989f0e 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -163,6 +163,9 @@ static int fuse_flush(struct file *file) struct fuse_flush_in inarg; int err; + if (is_bad_inode(inode)) + return -EIO; + if (fc->no_flush) return 0; @@ -199,6 +202,9 @@ int fuse_fsync_common(struct file *file, struct dentry *de, int datasync, struct fuse_fsync_in inarg; int err; + if (is_bad_inode(inode)) + return -EIO; + if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir)) return 0; @@ -272,8 +278,15 @@ static int fuse_readpage(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; struct fuse_conn *fc = get_fuse_conn(inode); - struct fuse_req *req = fuse_get_request(fc); - int err = -EINTR; + struct fuse_req *req; + int err; + + err = -EIO; + if (is_bad_inode(inode)) + goto out; + + err = -EINTR; + req = fuse_get_request(fc); if (!req) goto out; @@ -344,6 +357,10 @@ static int fuse_readpages(struct file *file, struct address_space *mapping, struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_readpages_data data; int err; + + if (is_bad_inode(inode)) + return -EIO; + data.file = file; data.inode = inode; data.req = fuse_get_request(fc); @@ -402,7 +419,12 @@ static int fuse_commit_write(struct file *file, struct page *page, struct inode *inode = page->mapping->host; struct fuse_conn *fc = get_fuse_conn(inode); loff_t pos = page_offset(page) + offset; - struct fuse_req *req = fuse_get_request(fc); + struct fuse_req *req; + + if (is_bad_inode(inode)) + return -EIO; + + req = fuse_get_request(fc); if (!req) return -EINTR; @@ -474,7 +496,12 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf, size_t nmax = write ? fc->max_write : fc->max_read; loff_t pos = *ppos; ssize_t res = 0; - struct fuse_req *req = fuse_get_request(fc); + struct fuse_req *req; + + if (is_bad_inode(inode)) + return -EIO; + + req = fuse_get_request(fc); if (!req) return -EINTR; -- cgit v1.1 From 1d3d752b471d2a3a1d5e4fe177e5e7d52abb4e4c Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:40 -0800 Subject: [PATCH] fuse: clean up request size limit checking Change the way a too large request is handled. Until now in this case the device read returned -EINVAL and the operation returned -EIO. Make it more flexibible by not returning -EINVAL from the read, but restarting it instead. Also remove the fixed limit on setxattr data and let the filesystem provide as large a read buffer as it needs to handle the extended attribute data. The symbolic link length is already checked by VFS to be less than PATH_MAX, so the extra check against FUSE_SYMLINK_MAX is not needed. The check in fuse_create_open() against FUSE_NAME_MAX is not needed, since the dentry has already been looked up, and hence the name already checked. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/dev.c | 26 ++++++++++++++++---------- fs/fuse/dir.c | 14 +------------- fs/fuse/fuse_i.h | 9 ++++++--- fs/fuse/inode.c | 2 +- include/linux/fuse.h | 8 ++------ 5 files changed, 26 insertions(+), 33 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index e5bc3f8..1afdffd 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -617,6 +617,7 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, struct fuse_copy_state cs; unsigned reqsize; + restart: spin_lock(&fuse_lock); fc = file->private_data; err = -EPERM; @@ -632,20 +633,25 @@ static ssize_t fuse_dev_readv(struct file *file, const struct iovec *iov, req = list_entry(fc->pending.next, struct fuse_req, list); list_del_init(&req->list); - spin_unlock(&fuse_lock); in = &req->in; - reqsize = req->in.h.len; - fuse_copy_init(&cs, 1, req, iov, nr_segs); - err = -EINVAL; - if (iov_length(iov, nr_segs) >= reqsize) { - err = fuse_copy_one(&cs, &in->h, sizeof(in->h)); - if (!err) - err = fuse_copy_args(&cs, in->numargs, in->argpages, - (struct fuse_arg *) in->args, 0); + reqsize = in->h.len; + /* If request is too large, reply with an error and restart the read */ + if (iov_length(iov, nr_segs) < reqsize) { + req->out.h.error = -EIO; + /* SETXATTR is special, since it may contain too large data */ + if (in->h.opcode == FUSE_SETXATTR) + req->out.h.error = -E2BIG; + request_end(fc, req); + goto restart; } + spin_unlock(&fuse_lock); + fuse_copy_init(&cs, 1, req, iov, nr_segs); + err = fuse_copy_one(&cs, &in->h, sizeof(in->h)); + if (!err) + err = fuse_copy_args(&cs, in->numargs, in->argpages, + (struct fuse_arg *) in->args, 0); fuse_copy_finish(&cs); - spin_lock(&fuse_lock); req->locked = 0; if (!err && req->interrupted) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 9a6075d..f156392 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -236,10 +236,6 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry, int mode, if (fc->no_create) goto out; - err = -ENAMETOOLONG; - if (entry->d_name.len > FUSE_NAME_MAX) - goto out; - err = -EINTR; req = fuse_get_request(fc); if (!req) @@ -413,12 +409,7 @@ static int fuse_symlink(struct inode *dir, struct dentry *entry, { struct fuse_conn *fc = get_fuse_conn(dir); unsigned len = strlen(link) + 1; - struct fuse_req *req; - - if (len > FUSE_SYMLINK_MAX) - return -ENAMETOOLONG; - - req = fuse_get_request(fc); + struct fuse_req *req = fuse_get_request(fc); if (!req) return -EINTR; @@ -988,9 +979,6 @@ static int fuse_setxattr(struct dentry *entry, const char *name, struct fuse_setxattr_in inarg; int err; - if (size > FUSE_XATTR_SIZE_MAX) - return -E2BIG; - if (fc->no_setxattr) return -EOPNOTSUPP; diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 2d4835e..17fd368 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -21,6 +21,12 @@ /** If more requests are outstanding, then the operation will block */ #define FUSE_MAX_OUTSTANDING 10 +/** Maximum size of data in a write request */ +#define FUSE_MAX_WRITE 4096 + +/** It could be as large as PATH_MAX, but would that have any uses? */ +#define FUSE_NAME_MAX 1024 + /** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem module will check permissions based on the file mode. Otherwise no permission checking is done in the kernel */ @@ -108,9 +114,6 @@ struct fuse_out { struct fuse_arg args[3]; }; -struct fuse_req; -struct fuse_conn; - /** * A request to the client */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 3b928a0..3580b9e 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -485,7 +485,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) fc->max_read = d.max_read; if (fc->max_read / PAGE_CACHE_SIZE < fc->bdi.ra_pages) fc->bdi.ra_pages = fc->max_read / PAGE_CACHE_SIZE; - fc->max_write = FUSE_MAX_IN / 2; + fc->max_write = FUSE_MAX_WRITE; err = -ENOMEM; root = get_root_inode(sb, d.rootmode); diff --git a/include/linux/fuse.h b/include/linux/fuse.h index 9d5177c..8f64cc2 100644 --- a/include/linux/fuse.h +++ b/include/linux/fuse.h @@ -108,12 +108,8 @@ enum fuse_opcode { FUSE_CREATE = 35 }; -/* Conservative buffer size for the client */ -#define FUSE_MAX_IN 8192 - -#define FUSE_NAME_MAX 1024 -#define FUSE_SYMLINK_MAX 4096 -#define FUSE_XATTR_SIZE_MAX 4096 +/* The read buffer is required to be at least 8k, but may be much larger */ +#define FUSE_MIN_READ_BUFFER 8192 struct fuse_entry_out { __u64 nodeid; /* Inode ID */ -- cgit v1.1 From 3ec870d524c9150add120475c8ddcfa50574f98e Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:41 -0800 Subject: [PATCH] fuse: make maximum write data configurable Make the maximum size of write data configurable by the filesystem. The previous fixed 4096 limit only worked on architectures where the page size is less or equal to this. This change make writing work on other architectures too, and also lets the filesystem receive bigger write requests in direct_io mode. Normal writes which go through the page cache are still limited to a page sized chunk per request. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/dev.c | 48 ++++++++++++++++++++++++++++++------------------ fs/fuse/fuse_i.h | 6 ++---- fs/fuse/inode.c | 1 - include/linux/fuse.h | 11 +++++++++-- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 1afdffd..e08ab47 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -148,6 +148,26 @@ void fuse_release_background(struct fuse_req *req) spin_unlock(&fuse_lock); } +static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) +{ + int i; + struct fuse_init_out *arg = &req->misc.init_out; + + if (arg->major != FUSE_KERNEL_VERSION) + fc->conn_error = 1; + else { + fc->minor = arg->minor; + fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; + } + + /* After INIT reply is received other requests can go + out. So do (FUSE_MAX_OUTSTANDING - 1) number of + up()s on outstanding_sem. The last up() is done in + fuse_putback_request() */ + for (i = 1; i < FUSE_MAX_OUTSTANDING; i++) + up(&fc->outstanding_sem); +} + /* * This function is called when a request is finished. Either a reply * has arrived or it was interrupted (and not yet sent) or some error @@ -172,21 +192,9 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req) up_read(&fc->sbput_sem); } wake_up(&req->waitq); - if (req->in.h.opcode == FUSE_INIT) { - int i; - - if (req->misc.init_in_out.major != FUSE_KERNEL_VERSION) - fc->conn_error = 1; - - fc->minor = req->misc.init_in_out.minor; - - /* After INIT reply is received other requests can go - out. So do (FUSE_MAX_OUTSTANDING - 1) number of - up()s on outstanding_sem. The last up() is done in - fuse_putback_request() */ - for (i = 1; i < FUSE_MAX_OUTSTANDING; i++) - up(&fc->outstanding_sem); - } else if (req->in.h.opcode == FUSE_RELEASE && req->inode == NULL) { + if (req->in.h.opcode == FUSE_INIT) + process_init_reply(fc, req); + else if (req->in.h.opcode == FUSE_RELEASE && req->inode == NULL) { /* Special case for failed iget in CREATE */ u64 nodeid = req->in.h.nodeid; __fuse_get_request(req); @@ -359,7 +367,7 @@ void fuse_send_init(struct fuse_conn *fc) /* This is called from fuse_read_super() so there's guaranteed to be a request available */ struct fuse_req *req = do_get_request(fc); - struct fuse_init_in_out *arg = &req->misc.init_in_out; + struct fuse_init_in *arg = &req->misc.init_in; arg->major = FUSE_KERNEL_VERSION; arg->minor = FUSE_KERNEL_MINOR_VERSION; req->in.h.opcode = FUSE_INIT; @@ -367,8 +375,12 @@ void fuse_send_init(struct fuse_conn *fc) req->in.args[0].size = sizeof(*arg); req->in.args[0].value = arg; req->out.numargs = 1; - req->out.args[0].size = sizeof(*arg); - req->out.args[0].value = arg; + /* Variable length arguement used for backward compatibility + with interface version < 7.5. Rest of init_out is zeroed + by do_get_request(), so a short reply is not a problem */ + req->out.argvar = 1; + req->out.args[0].size = sizeof(struct fuse_init_out); + req->out.args[0].value = &req->misc.init_out; request_send_background(fc, req); } diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 17fd368..74c8d09 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -21,9 +21,6 @@ /** If more requests are outstanding, then the operation will block */ #define FUSE_MAX_OUTSTANDING 10 -/** Maximum size of data in a write request */ -#define FUSE_MAX_WRITE 4096 - /** It could be as large as PATH_MAX, but would that have any uses? */ #define FUSE_NAME_MAX 1024 @@ -162,7 +159,8 @@ struct fuse_req { union { struct fuse_forget_in forget_in; struct fuse_release_in release_in; - struct fuse_init_in_out init_in_out; + struct fuse_init_in init_in; + struct fuse_init_out init_out; } misc; /** page vector */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 3580b9e..e454186 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -485,7 +485,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) fc->max_read = d.max_read; if (fc->max_read / PAGE_CACHE_SIZE < fc->bdi.ra_pages) fc->bdi.ra_pages = fc->max_read / PAGE_CACHE_SIZE; - fc->max_write = FUSE_MAX_WRITE; err = -ENOMEM; root = get_root_inode(sb, d.rootmode); diff --git a/include/linux/fuse.h b/include/linux/fuse.h index 8f64cc2..528959c 100644 --- a/include/linux/fuse.h +++ b/include/linux/fuse.h @@ -14,7 +14,7 @@ #define FUSE_KERNEL_VERSION 7 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 4 +#define FUSE_KERNEL_MINOR_VERSION 5 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -244,11 +244,18 @@ struct fuse_access_in { __u32 padding; }; -struct fuse_init_in_out { +struct fuse_init_in { __u32 major; __u32 minor; }; +struct fuse_init_out { + __u32 major; + __u32 minor; + __u32 unused[3]; + __u32 max_write; +}; + struct fuse_in_header { __u32 len; __u32 opcode; -- cgit v1.1 From 6ad84acab972f4dfc78e6fdb04c419f82c497d29 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:42 -0800 Subject: [PATCH] fuse: ensure progress in read and write In direct_io mode, send at least one page per reqest. Previously it was possible that reqests with zero data were sent, and hence the read/write didn't make any progress, resulting in an infinite (though interruptible) loop. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/file.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c989f0e..05deddd 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -475,7 +475,7 @@ static int fuse_get_user_pages(struct fuse_req *req, const char __user *buf, nbytes = min(nbytes, (unsigned) FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT); npages = (nbytes + offset + PAGE_SIZE - 1) >> PAGE_SHIFT; - npages = min(npages, FUSE_MAX_PAGES_PER_REQ); + npages = min(max(npages, 1), FUSE_MAX_PAGES_PER_REQ); down_read(¤t->mm->mmap_sem); npages = get_user_pages(current, current->mm, user_addr, npages, write, 0, req->pages, NULL); @@ -506,7 +506,6 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf, return -EINTR; while (count) { - size_t tmp; size_t nres; size_t nbytes = min(count, nmax); int err = fuse_get_user_pages(req, buf, nbytes, !write); @@ -514,8 +513,8 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf, res = err; break; } - tmp = (req->num_pages << PAGE_SHIFT) - req->page_offset; - nbytes = min(nbytes, tmp); + nbytes = (req->num_pages << PAGE_SHIFT) - req->page_offset; + nbytes = min(count, nbytes); if (write) nres = fuse_send_write(req, file, inode, pos, nbytes); else -- cgit v1.1 From 39ee059affaf57a152c64cd3a0adc3f48f02ed71 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Fri, 6 Jan 2006 00:19:43 -0800 Subject: [PATCH] fuse: check file type in lookup Previously invalid types were quietly changed to regular files, but at revalidation the inode was changed to bad. This was rather inconsistent behavior. Now check if the type is valid on initial lookup, and return -EIO if not. Signed-off-by: Miklos Szeredi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/fuse/dir.c | 27 ++++++++++++++++++++------- fs/fuse/inode.c | 8 ++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index f156392..417bcee 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -166,6 +166,12 @@ static struct dentry_operations fuse_dentry_operations = { .d_revalidate = fuse_dentry_revalidate, }; +static inline int valid_mode(int m) +{ + return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) || + S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m); +} + static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, struct nameidata *nd) { @@ -185,7 +191,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, fuse_lookup_init(req, dir, entry, &outarg); request_send(fc, req); err = req->out.h.error; - if (!err && outarg.nodeid && invalid_nodeid(outarg.nodeid)) + if (!err && ((outarg.nodeid && invalid_nodeid(outarg.nodeid)) || + !valid_mode(outarg.attr.mode))) err = -EIO; if (!err && outarg.nodeid) { inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, @@ -328,10 +335,13 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, fuse_put_request(fc, req); return err; } - if (invalid_nodeid(outarg.nodeid)) { - fuse_put_request(fc, req); - return -EIO; - } + err = -EIO; + if (invalid_nodeid(outarg.nodeid)) + goto out_put_request; + + if ((outarg.attr.mode ^ mode) & S_IFMT) + goto out_put_request; + inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, &outarg.attr); if (!inode) { @@ -340,8 +350,7 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, } fuse_put_request(fc, req); - /* Don't allow userspace to do really stupid things... */ - if (((inode->i_mode ^ mode) & S_IFMT) || dir_alias(inode)) { + if (dir_alias(inode)) { iput(inode); return -EIO; } @@ -350,6 +359,10 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, fuse_change_timeout(entry, &outarg); fuse_invalidate_attr(dir); return 0; + + out_put_request: + fuse_put_request(fc, req); + return err; } static int fuse_mknod(struct inode *dir, struct dentry *entry, int mode, diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index e454186..04c80cc 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -135,12 +135,8 @@ static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr) fuse_init_common(inode); init_special_inode(inode, inode->i_mode, new_decode_dev(attr->rdev)); - } else { - /* Don't let user create weird files */ - inode->i_mode = S_IFREG; - fuse_init_common(inode); - fuse_init_file_inode(inode); - } + } else + BUG(); } static int fuse_inode_eq(struct inode *inode, void *_nodeidp) -- cgit v1.1 From c660629059abbbd0eb56e12f9bb4494f01800bbc Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:43 -0800 Subject: [PATCH] parport: buffer overflow fix Fix potential buffer overflow in case the device ID did not end in semicolon. Also might fail to negotiate back to IEEE1284_MODE_COMPAT in case of failure. parport_device_id did not return what Documentation/parport-lowlevel.txt said, so I changed it to match it. Determining device ID length is overly complicated, but Tim Waugh recalled on linux-parport seeing some buggy device that might need it. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/probe.c | 193 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 130 insertions(+), 63 deletions(-) diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c index 4b48b31..5c29e82 100644 --- a/drivers/parport/probe.c +++ b/drivers/parport/probe.c @@ -128,8 +128,131 @@ static void parse_data(struct parport *port, int device, char *str) kfree(txt); } +/* Read up to count-1 bytes of device id. Terminate buffer with + * '\0'. Buffer begins with two Device ID length bytes as given by + * device. */ +static ssize_t parport_read_device_id (struct parport *port, char *buffer, + size_t count) +{ + unsigned char length[2]; + unsigned lelen, belen; + size_t idlens[4]; + unsigned numidlens; + unsigned current_idlen; + ssize_t retval; + size_t len; + + /* First two bytes are MSB,LSB of inclusive length. */ + retval = parport_read (port, length, 2); + + if (retval < 0) + return retval; + if (retval != 2) + return -EIO; + + if (count < 2) + return 0; + memcpy(buffer, length, 2); + len = 2; + + /* Some devices wrongly send LE length, and some send it two + * bytes short. Construct a sorted array of lengths to try. */ + belen = (length[0] << 8) + length[1]; + lelen = (length[1] << 8) + length[0]; + idlens[0] = min(belen, lelen); + idlens[1] = idlens[0]+2; + if (belen != lelen) { + int off = 2; + /* Don't try lenghts of 0x100 and 0x200 as 1 and 2 */ + if (idlens[0] <= 2) + off = 0; + idlens[off] = max(belen, lelen); + idlens[off+1] = idlens[off]+2; + numidlens = off+2; + } + else { + /* Some devices don't truly implement Device ID, but + * just return constant nibble forever. This catches + * also those cases. */ + if (idlens[0] == 0 || idlens[0] > 0xFFF) { + printk (KERN_DEBUG "%s: reported broken Device ID" + " length of %#zX bytes\n", + port->name, idlens[0]); + return -EIO; + } + numidlens = 2; + } + + /* Try to respect the given ID length despite all the bugs in + * the ID length. Read according to shortest possible ID + * first. */ + for (current_idlen = 0; current_idlen < numidlens; ++current_idlen) { + size_t idlen = idlens[current_idlen]; + if (idlen+1 >= count) + break; + + retval = parport_read (port, buffer+len, idlen-len); + + if (retval < 0) + return retval; + len += retval; + + if (port->physport->ieee1284.phase != IEEE1284_PH_HBUSY_DAVAIL) { + if (belen != len) { + printk (KERN_DEBUG "%s: Device ID was %d bytes" + " while device told it would be %d" + " bytes\n", + port->name, len, belen); + } + goto done; + } + + /* This might end reading the Device ID too + * soon. Hopefully the needed fields were already in + * the first 256 bytes or so that we must have read so + * far. */ + if (buffer[len-1] == ';') { + printk (KERN_DEBUG "%s: Device ID reading stopped" + " before device told data not available. " + "Current idlen %d of %d, len bytes %02X %02X\n", + port->name, current_idlen, numidlens, + length[0], length[1]); + goto done; + } + } + if (current_idlen < numidlens) { + /* Buffer not large enough, read to end of buffer. */ + size_t idlen, len2; + if (len+1 < count) { + retval = parport_read (port, buffer+len, count-len-1); + if (retval < 0) + return retval; + len += retval; + } + /* Read the whole ID since some devices would not + * otherwise give back the Device ID from beginning + * next time when asked. */ + idlen = idlens[current_idlen]; + len2 = len; + while(len2 < idlen && retval > 0) { + char tmp[4]; + retval = parport_read (port, tmp, + min(sizeof tmp, idlen-len2)); + if (retval < 0) + return retval; + len2 += retval; + } + } + /* In addition, there are broken devices out there that don't + even finish off with a semi-colon. We do not need to care + about those at this time. */ + done: + buffer[len] = '\0'; + return len; +} + /* Get Std 1284 Device ID. */ -ssize_t parport_device_id (int devnum, char *buffer, size_t len) +ssize_t parport_device_id (int devnum, char *buffer, size_t count) { ssize_t retval = -ENXIO; struct pardevice *dev = parport_open (devnum, "Device ID probe", @@ -139,76 +262,20 @@ ssize_t parport_device_id (int devnum, char *buffer, size_t len) parport_claim_or_block (dev); - /* Negotiate to compatibility mode, and then to device ID mode. - * (This is in case we are already in device ID mode.) */ + /* Negotiate to compatibility mode, and then to device ID + * mode. (This so that we start form beginning of device ID if + * already in device ID mode.) */ parport_negotiate (dev->port, IEEE1284_MODE_COMPAT); retval = parport_negotiate (dev->port, IEEE1284_MODE_NIBBLE | IEEE1284_DEVICEID); if (!retval) { - int idlen; - unsigned char length[2]; - - /* First two bytes are MSB,LSB of inclusive length. */ - retval = parport_read (dev->port, length, 2); - - if (retval != 2) goto end_id; - - idlen = (length[0] << 8) + length[1] - 2; - /* - * Check if the caller-allocated buffer is large enough - * otherwise bail out or there will be an at least off by one. - */ - if (idlen + 1 < len) - len = idlen; - else { - retval = -EINVAL; - goto out; - } - retval = parport_read (dev->port, buffer, len); - - if (retval != len) - printk (KERN_DEBUG "%s: only read %Zd of %Zd ID bytes\n", - dev->port->name, retval, - len); - - /* Some printer manufacturers mistakenly believe that - the length field is supposed to be _exclusive_. - In addition, there are broken devices out there - that don't even finish off with a semi-colon. */ - if (buffer[len - 1] != ';') { - ssize_t diff; - diff = parport_read (dev->port, buffer + len, 2); - retval += diff; - - if (diff) - printk (KERN_DEBUG - "%s: device reported incorrect " - "length field (%d, should be %Zd)\n", - dev->port->name, idlen, retval); - else { - /* One semi-colon short of a device ID. */ - buffer[len++] = ';'; - printk (KERN_DEBUG "%s: faking semi-colon\n", - dev->port->name); - - /* If we get here, I don't think we - need to worry about the possible - standard violation of having read - more than we were told to. The - device is non-compliant anyhow. */ - } - } - - end_id: - buffer[len] = '\0'; + retval = parport_read_device_id (dev->port, buffer, count); parport_negotiate (dev->port, IEEE1284_MODE_COMPAT); + if (retval > 2) + parse_data (dev->port, dev->daisy, buffer+2); } - if (retval > 2) - parse_data (dev->port, dev->daisy, buffer); - -out: parport_release (dev); parport_close (dev); return retval; -- cgit v1.1 From 742ec650e9b63ea61891455bb6f76bac37025c78 Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:44 -0800 Subject: [PATCH] parport: phase fixes Did not move the parport interface properly into IEEE1284_PH_REV_IDLE phase at end of data due to comparing bytes with nibbles. Internal phase IEEE1284_PH_HBUSY_DNA became unused, so remove it. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/video/cpia_pp.c | 30 +++++++++----------- drivers/parport/ieee1284_ops.c | 62 ++++++++++++++++++++---------------------- include/linux/parport.h | 1 - 3 files changed, 42 insertions(+), 51 deletions(-) diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c index ddf184f..6861d40 100644 --- a/drivers/media/video/cpia_pp.c +++ b/drivers/media/video/cpia_pp.c @@ -170,16 +170,9 @@ static size_t cpia_read_nibble (struct parport *port, /* Does the error line indicate end of data? */ if (((i /*& 1*/) == 0) && (parport_read_status(port) & PARPORT_STATUS_ERROR)) { - port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; - DBG("%s: No more nibble data (%d bytes)\n", - port->name, i/2); - - /* Go to reverse idle phase. */ - parport_frob_control (port, - PARPORT_CONTROL_AUTOFD, - PARPORT_CONTROL_AUTOFD); - port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; - break; + DBG("%s: No more nibble data (%d bytes)\n", + port->name, i/2); + goto end_of_data; } /* Event 7: Set nAutoFd low. */ @@ -227,18 +220,21 @@ static size_t cpia_read_nibble (struct parport *port, byte = nibble; } - i /= 2; /* i is now in bytes */ - if (i == len) { /* Read the last nibble without checking data avail. */ - port = port->physport; - if (parport_read_status (port) & PARPORT_STATUS_ERROR) - port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; + if (parport_read_status (port) & PARPORT_STATUS_ERROR) { + end_of_data: + /* Go to reverse idle phase. */ + parport_frob_control (port, + PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_AUTOFD); + port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; + } else - port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; + port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; } - return i; + return i/2; } /* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1) diff --git a/drivers/parport/ieee1284_ops.c b/drivers/parport/ieee1284_ops.c index ce1e2aa..d6c7765 100644 --- a/drivers/parport/ieee1284_ops.c +++ b/drivers/parport/ieee1284_ops.c @@ -165,17 +165,7 @@ size_t parport_ieee1284_read_nibble (struct parport *port, /* Does the error line indicate end of data? */ if (((i & 1) == 0) && (parport_read_status(port) & PARPORT_STATUS_ERROR)) { - port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; - DPRINTK (KERN_DEBUG - "%s: No more nibble data (%d bytes)\n", - port->name, i/2); - - /* Go to reverse idle phase. */ - parport_frob_control (port, - PARPORT_CONTROL_AUTOFD, - PARPORT_CONTROL_AUTOFD); - port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; - break; + goto end_of_data; } /* Event 7: Set nAutoFd low. */ @@ -225,18 +215,25 @@ size_t parport_ieee1284_read_nibble (struct parport *port, byte = nibble; } - i /= 2; /* i is now in bytes */ - if (i == len) { /* Read the last nibble without checking data avail. */ - port = port->physport; - if (parport_read_status (port) & PARPORT_STATUS_ERROR) - port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; + if (parport_read_status (port) & PARPORT_STATUS_ERROR) { + end_of_data: + DPRINTK (KERN_DEBUG + "%s: No more nibble data (%d bytes)\n", + port->name, i/2); + + /* Go to reverse idle phase. */ + parport_frob_control (port, + PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_AUTOFD); + port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; + } else - port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; + port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; } - return i; + return i/2; #endif /* IEEE1284 support */ } @@ -256,17 +253,7 @@ size_t parport_ieee1284_read_byte (struct parport *port, /* Data available? */ if (parport_read_status (port) & PARPORT_STATUS_ERROR) { - port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; - DPRINTK (KERN_DEBUG - "%s: No more byte data (%Zd bytes)\n", - port->name, count); - - /* Go to reverse idle phase. */ - parport_frob_control (port, - PARPORT_CONTROL_AUTOFD, - PARPORT_CONTROL_AUTOFD); - port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; - break; + goto end_of_data; } /* Event 14: Place data bus in high impedance state. */ @@ -318,11 +305,20 @@ size_t parport_ieee1284_read_byte (struct parport *port, if (count == len) { /* Read the last byte without checking data avail. */ - port = port->physport; - if (parport_read_status (port) & PARPORT_STATUS_ERROR) - port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; + if (parport_read_status (port) & PARPORT_STATUS_ERROR) { + end_of_data: + DPRINTK (KERN_DEBUG + "%s: No more byte data (%Zd bytes)\n", + port->name, count); + + /* Go to reverse idle phase. */ + parport_frob_control (port, + PARPORT_CONTROL_AUTOFD, + PARPORT_CONTROL_AUTOFD); + port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE; + } else - port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; + port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; } return count; diff --git a/include/linux/parport.h b/include/linux/parport.h index d2a4d9e..f7ff0b0 100644 --- a/include/linux/parport.h +++ b/include/linux/parport.h @@ -242,7 +242,6 @@ enum ieee1284_phase { IEEE1284_PH_FWD_IDLE, IEEE1284_PH_TERMINATE, IEEE1284_PH_NEGOTIATION, - IEEE1284_PH_HBUSY_DNA, IEEE1284_PH_REV_IDLE, IEEE1284_PH_HBUSY_DAVAIL, IEEE1284_PH_REV_DATA, -- cgit v1.1 From 310c8c324f988625a2880deab67607bf4e5aeb8a Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:45 -0800 Subject: [PATCH] parport: daisy chain end detection fix Daisy chain end detection failed at least with older daisy chain devices that do not implement the last device signal. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/daisy.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c index 075c7eb..6915114 100644 --- a/drivers/parport/daisy.c +++ b/drivers/parport/daisy.c @@ -436,7 +436,7 @@ static int select_port (struct parport *port) static int assign_addrs (struct parport *port) { - unsigned char s, last_dev; + unsigned char s; unsigned char daisy; int thisdev = numdevs; int detected; @@ -472,10 +472,13 @@ static int assign_addrs (struct parport *port) } parport_write_data (port, 0x78); udelay (2); - last_dev = 0; /* We've just been speaking to a device, so we - know there must be at least _one_ out there. */ + s = parport_read_status (port); - for (daisy = 0; daisy < 4; daisy++) { + for (daisy = 0; + (s & (PARPORT_STATUS_PAPEROUT|PARPORT_STATUS_SELECT)) + == (PARPORT_STATUS_PAPEROUT|PARPORT_STATUS_SELECT) + && daisy < 4; + ++daisy) { parport_write_data (port, daisy); udelay (2); parport_frob_control (port, @@ -485,14 +488,18 @@ static int assign_addrs (struct parport *port) parport_frob_control (port, PARPORT_CONTROL_STROBE, 0); udelay (1); - if (last_dev) - /* No more devices. */ - break; + add_dev (numdevs++, port, daisy); - last_dev = !(parport_read_status (port) - & PARPORT_STATUS_BUSY); + /* See if this device thought it was the last in the + * chain. */ + if (!(s & PARPORT_STATUS_BUSY)) + break; - add_dev (numdevs++, port, daisy); + /* We are seeing pass through status now. We see + last_dev from next device or if last_dev does not + work status lines from some non-daisy chain + device. */ + s = parport_read_status (port); } parport_write_data (port, 0xff); udelay (2); -- cgit v1.1 From c29a75ed0d94fae64b59345ea96e52424ae9c6a2 Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:46 -0800 Subject: [PATCH] parport: daisy chain device id reading fix Device ID reading from daisy chain devices failed because the daisy device could not be opened. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/daisy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c index 6915114..37dc179 100644 --- a/drivers/parport/daisy.c +++ b/drivers/parport/daisy.c @@ -252,7 +252,7 @@ struct pardevice *parport_open (int devnum, const char *name, selected = port->daisy; parport_release (dev); - if (selected != port->daisy) { + if (selected != daisy) { /* No corresponding device. */ parport_unregister_device (dev); return NULL; -- cgit v1.1 From 7c9cc3be1094b267a2da2e0016cbd6ced663da6d Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:46 -0800 Subject: [PATCH] parport: parport_daisy_select return value fix parport_daisy_select returned wrong status that is read at wrong time during daisy command execution. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/daisy.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c index 37dc179..9109a40 100644 --- a/drivers/parport/daisy.c +++ b/drivers/parport/daisy.c @@ -344,9 +344,9 @@ static int cpp_daisy (struct parport *port, int cmd) PARPORT_CONTROL_STROBE, PARPORT_CONTROL_STROBE); udelay (1); + s = parport_read_status (port); parport_frob_control (port, PARPORT_CONTROL_STROBE, 0); udelay (1); - s = parport_read_status (port); parport_write_data (port, 0xff); udelay (2); return s; @@ -395,15 +395,15 @@ int parport_daisy_select (struct parport *port, int daisy, int mode) case IEEE1284_MODE_EPP: case IEEE1284_MODE_EPPSL: case IEEE1284_MODE_EPPSWE: - return (cpp_daisy (port, 0x20 + daisy) & - PARPORT_STATUS_ERROR); + return !(cpp_daisy (port, 0x20 + daisy) & + PARPORT_STATUS_ERROR); // For these modes we should switch to ECP mode: case IEEE1284_MODE_ECP: case IEEE1284_MODE_ECPRLE: case IEEE1284_MODE_ECPSWE: - return (cpp_daisy (port, 0xd0 + daisy) & - PARPORT_STATUS_ERROR); + return !(cpp_daisy (port, 0xd0 + daisy) & + PARPORT_STATUS_ERROR); // Nothing was told for BECP in Daisy chain specification. // May be it's wise to use ECP? @@ -413,8 +413,8 @@ int parport_daisy_select (struct parport *port, int daisy, int mode) case IEEE1284_MODE_BYTE: case IEEE1284_MODE_COMPAT: default: - return (cpp_daisy (port, 0xe0 + daisy) & - PARPORT_STATUS_ERROR); + return !(cpp_daisy (port, 0xe0 + daisy) & + PARPORT_STATUS_ERROR); } } -- cgit v1.1 From b44d3bdd6fcf6233b381bf5bd0893ed235f497a9 Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:47 -0800 Subject: [PATCH] parport: use complete slab buffer Use the complete slab buffer that is allocated by kmalloc. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/daisy.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c index 9109a40..9ee6732 100644 --- a/drivers/parport/daisy.c +++ b/drivers/parport/daisy.c @@ -144,9 +144,9 @@ again: add_dev (numdevs++, port, -1); /* Find out the legacy device's IEEE 1284 device ID. */ - deviceid = kmalloc (1000, GFP_KERNEL); + deviceid = kmalloc (1024, GFP_KERNEL); if (deviceid) { - if (parport_device_id (numdevs - 1, deviceid, 1000) > 2) + if (parport_device_id (numdevs - 1, deviceid, 1024) > 2) detected++; kfree (deviceid); @@ -508,11 +508,11 @@ static int assign_addrs (struct parport *port) detected); /* Ask the new devices to introduce themselves. */ - deviceid = kmalloc (1000, GFP_KERNEL); + deviceid = kmalloc (1024, GFP_KERNEL); if (!deviceid) return 0; for (daisy = 0; thisdev < numdevs; thisdev++, daisy++) - parport_device_id (thisdev, deviceid, 1000); + parport_device_id (thisdev, deviceid, 1024); kfree (deviceid); return detected; -- cgit v1.1 From a6767b7cc674ee39635db75ed2f6f65ed0012239 Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:48 -0800 Subject: [PATCH] parport: constification Trivial "const" additions to places in parport that truly are const. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/parport_pc.c | 30 ++++++++++++++++++------------ drivers/parport/probe.c | 6 +++--- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index c6493ad..18e85cc 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -1169,7 +1169,7 @@ dump_parport_state ("fwd idle", port); /* GCC is not inlining extern inline function later overwriten to non-inline, so we use outlined_ variants here. */ -static struct parport_operations parport_pc_ops = +static const struct parport_operations parport_pc_ops = { .write_data = parport_pc_write_data, .read_data = parport_pc_read_data, @@ -1211,10 +1211,11 @@ static struct parport_operations parport_pc_ops = static void __devinit show_parconfig_smsc37c669(int io, int key) { int cr1,cr4,cra,cr23,cr26,cr27,i=0; - static const char *modes[]={ "SPP and Bidirectional (PS/2)", - "EPP and SPP", - "ECP", - "ECP and EPP" }; + static const char *const modes[]={ + "SPP and Bidirectional (PS/2)", + "EPP and SPP", + "ECP", + "ECP and EPP" }; outb(key,io); outb(key,io); @@ -1288,7 +1289,7 @@ static void __devinit show_parconfig_smsc37c669(int io, int key) static void __devinit show_parconfig_winbond(int io, int key) { int cr30,cr60,cr61,cr70,cr74,crf0,i=0; - static const char *modes[] = { + static const char *const modes[] = { "Standard (SPP) and Bidirectional(PS/2)", /* 0 */ "EPP-1.9 and SPP", "ECP", @@ -1297,7 +1298,9 @@ static void __devinit show_parconfig_winbond(int io, int key) "EPP-1.7 and SPP", /* 5 */ "undefined!", "ECP and EPP-1.7" }; - static char *irqtypes[] = { "pulsed low, high-Z", "follows nACK" }; + static char *const irqtypes[] = { + "pulsed low, high-Z", + "follows nACK" }; /* The registers are called compatible-PnP because the register layout is modelled after ISA-PnP, the access @@ -2396,7 +2399,8 @@ EXPORT_SYMBOL (parport_pc_unregister_port); /* ITE support maintained by Rich Liu */ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq, - int autodma, struct parport_pc_via_data *via) + int autodma, + const struct parport_pc_via_data *via) { short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 }; struct resource *base_res; @@ -2524,7 +2528,8 @@ static struct parport_pc_via_data via_8231_data __devinitdata = { }; static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, - int autodma, struct parport_pc_via_data *via) + int autodma, + const struct parport_pc_via_data *via) { u8 tmp, tmp2, siofunc; u8 ppcontrol = 0; @@ -2694,8 +2699,9 @@ enum parport_pc_sio_types { /* each element directly indexed from enum list, above */ static struct parport_pc_superio { - int (*probe) (struct pci_dev *pdev, int autoirq, int autodma, struct parport_pc_via_data *via); - struct parport_pc_via_data *via; + int (*probe) (struct pci_dev *pdev, int autoirq, int autodma, + const struct parport_pc_via_data *via); + const struct parport_pc_via_data *via; } parport_pc_superio_info[] __devinitdata = { { sio_via_probe, &via_686a_data, }, { sio_via_probe, &via_8231_data, }, @@ -2828,7 +2834,7 @@ static struct parport_pc_pci { /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, /* untested */ }; -static struct pci_device_id parport_pc_pci_tbl[] = { +static const struct pci_device_id parport_pc_pci_tbl[] = { /* Super-IO onboard chips */ { 0x1106, 0x0686, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_686a }, { 0x1106, 0x8231, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_8231 }, diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c index 5c29e82..b62aee8 100644 --- a/drivers/parport/probe.c +++ b/drivers/parport/probe.c @@ -11,9 +11,9 @@ #include #include -static struct { - char *token; - char *descr; +static const struct { + const char *token; + const char *descr; } classes[] = { { "", "Legacy device" }, { "PRINTER", "Printer" }, -- cgit v1.1 From 110bee75d2e03d3b4bcc74743dee5a21fe7b43bd Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:49 -0800 Subject: [PATCH] parport: DEBUG_PARPORT build fix Add missing "struct" keyword preventing compilation with DEBUG_PARPORT defined. Also add some "const". Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/parport_pc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/parport_pc.h b/include/linux/parport_pc.h index c6f7624..7e62b34 100644 --- a/include/linux/parport_pc.h +++ b/include/linux/parport_pc.h @@ -85,7 +85,7 @@ extern __inline__ void dump_parport_state (char *str, struct parport *p) unsigned char ecr = inb (ECONTROL (p)); unsigned char dcr = inb (CONTROL (p)); unsigned char dsr = inb (STATUS (p)); - static char *ecr_modes[] = {"SPP", "PS2", "PPFIFO", "ECP", "xXx", "yYy", "TST", "CFG"}; + static const char *const ecr_modes[] = {"SPP", "PS2", "PPFIFO", "ECP", "xXx", "yYy", "TST", "CFG"}; const struct parport_pc_private *priv = p->physport->private_data; int i; -- cgit v1.1 From 6a19b41b35bf45fc27a46dccf26005b3f44c1aa1 Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:49 -0800 Subject: [PATCH] parport: Kconfig dependency fixes Make drivers that use directly PC parport HW depend on PARPORT_PC rather than HW independent PARPORT. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/Kconfig | 2 +- drivers/block/paride/Kconfig | 5 +++-- drivers/scsi/Kconfig | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index c4b9d2a..139cbba 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -117,7 +117,7 @@ config BLK_DEV_XD config PARIDE tristate "Parallel port IDE device support" - depends on PARPORT + depends on PARPORT_PC ---help--- There are many external CD-ROM and disk devices that connect through your computer's parallel port. Most of them are actually IDE devices diff --git a/drivers/block/paride/Kconfig b/drivers/block/paride/Kconfig index 17ff405..c0d2854 100644 --- a/drivers/block/paride/Kconfig +++ b/drivers/block/paride/Kconfig @@ -4,11 +4,12 @@ # PARIDE doesn't need PARPORT, but if PARPORT is configured as a module, # PARIDE must also be a module. The bogus CONFIG_PARIDE_PARPORT option # controls the choices given to the user ... +# PARIDE only supports PC style parports. Tough for USB or other parports... config PARIDE_PARPORT tristate depends on PARIDE!=n - default m if PARPORT=m - default y if PARPORT!=m + default m if PARPORT_PC=m + default y if PARPORT_PC!=m comment "Parallel IDE high-level drivers" depends on PARIDE diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 9e8254f..3c606cf 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -914,7 +914,7 @@ config SCSI_INIA100 config SCSI_PPA tristate "IOMEGA parallel port (ppa - older drives)" - depends on SCSI && PARPORT + depends on SCSI && PARPORT_PC ---help--- This driver supports older versions of IOMEGA's parallel port ZIP drive (a 100 MB removable media device). @@ -941,7 +941,7 @@ config SCSI_PPA config SCSI_IMM tristate "IOMEGA parallel port (imm - newer drives)" - depends on SCSI && PARPORT + depends on SCSI && PARPORT_PC ---help--- This driver supports newer versions of IOMEGA's parallel port ZIP drive (a 100 MB removable media device). @@ -968,7 +968,7 @@ config SCSI_IMM config SCSI_IZIP_EPP16 bool "ppa/imm option - Use slow (but safe) EPP-16" - depends on PARPORT && (SCSI_PPA || SCSI_IMM) + depends on SCSI_PPA || SCSI_IMM ---help--- EPP (Enhanced Parallel Port) is a standard for parallel ports which allows them to act as expansion buses that can handle up to 64 @@ -983,7 +983,7 @@ config SCSI_IZIP_EPP16 config SCSI_IZIP_SLOW_CTR bool "ppa/imm option - Assume slow parport control register" - depends on PARPORT && (SCSI_PPA || SCSI_IMM) + depends on SCSI_PPA || SCSI_IMM help Some parallel ports are known to have excessive delays between changing the parallel port control register and good data being -- cgit v1.1 From 6a85081d1c3ab7935c3ade8f4b2700a860d6fb2e Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:51 -0800 Subject: [PATCH] parport: include fixes Small cleanup of includes meant for older implementation. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/plip.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/plip.c b/drivers/net/plip.c index 1bd22cd..87ee327 100644 --- a/drivers/net/plip.c +++ b/drivers/net/plip.c @@ -98,7 +98,6 @@ static const char version[] = "NET3 PLIP version 2.4-parport gniibe@mri.co.jp\n" #include #include #include -#include #include #include #include @@ -106,7 +105,6 @@ static const char version[] = "NET3 PLIP version 2.4-parport gniibe@mri.co.jp\n" #include #include #include -#include #include #include #include -- cgit v1.1 From 94b82095d0f5d6a72a0c619f54645727ebf66642 Mon Sep 17 00:00:00 2001 From: Marko Kohtala Date: Fri, 6 Jan 2006 00:19:51 -0800 Subject: [PATCH] parport: export parport_get_port() Help external ppSCSI driver by exporting parport_get_port to match the parport_put_port. Signed-off-by: Marko Kohtala Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/share.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/parport/share.c b/drivers/parport/share.c index 9cb3ab1..ea62bed 100644 --- a/drivers/parport/share.c +++ b/drivers/parport/share.c @@ -1002,6 +1002,7 @@ EXPORT_SYMBOL(parport_register_driver); EXPORT_SYMBOL(parport_unregister_driver); EXPORT_SYMBOL(parport_register_device); EXPORT_SYMBOL(parport_unregister_device); +EXPORT_SYMBOL(parport_get_port); EXPORT_SYMBOL(parport_put_port); EXPORT_SYMBOL(parport_find_number); EXPORT_SYMBOL(parport_find_base); -- cgit v1.1 From a1b9168d83962fbb05859c1ecaa57fd4f53cf38e Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 6 Jan 2006 00:19:52 -0800 Subject: [PATCH] simplify PARPORT_PC_PCMCIA dependencies Unless I miss something, this should be the simplest way to express the intended dependencies. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig index 725a141..b824156 100644 --- a/drivers/parport/Kconfig +++ b/drivers/parport/Kconfig @@ -77,7 +77,7 @@ config PARPORT_PC_SUPERIO config PARPORT_PC_PCMCIA tristate "Support for PCMCIA management for PC-style ports" - depends on PARPORT!=n && (PCMCIA!=n && PARPORT_PC=m && PARPORT_PC || PARPORT_PC=y && PCMCIA) + depends on PCMCIA && PARPORT_PC help Say Y here if you need PCMCIA support for your PC-style parallel ports. If unsure, say N. -- cgit v1.1 From 81684ee645e15601ec935461d9069a3086179c06 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 6 Jan 2006 00:19:53 -0800 Subject: [PATCH] include/linux/parport_pc.h: "extern inline" -> "static inline" "extern inline" doesn't make much sense. Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/parport_pc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/parport_pc.h b/include/linux/parport_pc.h index 7e62b34..1cc0f6b 100644 --- a/include/linux/parport_pc.h +++ b/include/linux/parport_pc.h @@ -79,7 +79,7 @@ static __inline__ unsigned char parport_pc_read_data(struct parport *p) } #ifdef DEBUG_PARPORT -extern __inline__ void dump_parport_state (char *str, struct parport *p) +static inline void dump_parport_state (char *str, struct parport *p) { /* here's hoping that reading these ports won't side-effect anything underneath */ unsigned char ecr = inb (ECONTROL (p)); -- cgit v1.1 From 066bb8d03b6e52e4844d37145573d6a2bedaa339 Mon Sep 17 00:00:00 2001 From: "Paul E. McKenney" Date: Fri, 6 Jan 2006 00:19:53 -0800 Subject: [PATCH] fix remaining list_for_each_safe_rcu in -mm (take 2) I missed a use of list_for_each_rcu_safe() in -mm tree. Here is an updated patch to fix it. This time tested on a machine that actually uses IPMI... (Thanks to Serge Hallyn for spotting this.) Signed-off-by: "Paul E. McKenney" Cc: Corey Minyard Cc: Matt Domsch Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/ipmi/ipmi_msghandler.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 1f56b4c..561430e 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -787,7 +787,6 @@ int ipmi_destroy_user(ipmi_user_t user) int i; unsigned long flags; struct cmd_rcvr *rcvr; - struct list_head *entry1, *entry2; struct cmd_rcvr *rcvrs = NULL; user->valid = 1; @@ -812,8 +811,7 @@ int ipmi_destroy_user(ipmi_user_t user) * synchronize_rcu()) then free everything in that list. */ down(&intf->cmd_rcvrs_lock); - list_for_each_safe_rcu(entry1, entry2, &intf->cmd_rcvrs) { - rcvr = list_entry(entry1, struct cmd_rcvr, link); + list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link) { if (rcvr->user == user) { list_del_rcu(&rcvr->link); rcvr->next = rcvrs; -- cgit v1.1 From 6fe2e70bbed3995d930f39452fb6ce3be7dc47dc Mon Sep 17 00:00:00 2001 From: Jayachandran C Date: Fri, 6 Jan 2006 00:19:54 -0800 Subject: [PATCH] kernel/module.c: removed dead code This patch fixes an issue reported by Coverity in kernel/module.c Error reported: Cannot reach this line of code "else return ptr;" Patch description: This is the error path, so 'err' will be negative, the else case is not required, this patch removes it. Signed-off-by: Jayachandran C. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/module.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 2ea929d..4b06bba 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1854,8 +1854,7 @@ static struct module *load_module(void __user *umod, kfree(args); free_hdr: vfree(hdr); - if (err < 0) return ERR_PTR(err); - else return ptr; + return ERR_PTR(err); truncated: printk(KERN_ERR "Module len %lu truncated\n", len); -- cgit v1.1 From f93ea411b73594f7d144855fd34278bcf34a9afc Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Fri, 6 Jan 2006 00:19:55 -0800 Subject: [PATCH] jbd: split checkpoint lists Split the checkpoint list of the transaction into two lists. In the first list we keep the buffers that need to be submitted for IO. In the second list are kept buffers that were already submitted and we just have to wait for the IO to complete. This should simplify a handling of checkpoint lists a bit and can eventually be also a performance gain. Signed-off-by: Jan Kara Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/jbd/checkpoint.c | 418 ++++++++++++++++++++++++++++++---------------------- include/linux/jbd.h | 8 +- 2 files changed, 248 insertions(+), 178 deletions(-) diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c index 014a51f..cb3cef5 100644 --- a/fs/jbd/checkpoint.c +++ b/fs/jbd/checkpoint.c @@ -24,29 +24,75 @@ #include /* - * Unlink a buffer from a transaction. + * Unlink a buffer from a transaction checkpoint list. * * Called with j_list_lock held. */ -static inline void __buffer_unlink(struct journal_head *jh) +static void __buffer_unlink_first(struct journal_head *jh) { transaction_t *transaction; transaction = jh->b_cp_transaction; - jh->b_cp_transaction = NULL; jh->b_cpnext->b_cpprev = jh->b_cpprev; jh->b_cpprev->b_cpnext = jh->b_cpnext; - if (transaction->t_checkpoint_list == jh) + if (transaction->t_checkpoint_list == jh) { transaction->t_checkpoint_list = jh->b_cpnext; - if (transaction->t_checkpoint_list == jh) - transaction->t_checkpoint_list = NULL; + if (transaction->t_checkpoint_list == jh) + transaction->t_checkpoint_list = NULL; + } +} + +/* + * Unlink a buffer from a transaction checkpoint(io) list. + * + * Called with j_list_lock held. + */ + +static inline void __buffer_unlink(struct journal_head *jh) +{ + transaction_t *transaction; + + transaction = jh->b_cp_transaction; + + __buffer_unlink_first(jh); + if (transaction->t_checkpoint_io_list == jh) { + transaction->t_checkpoint_io_list = jh->b_cpnext; + if (transaction->t_checkpoint_io_list == jh) + transaction->t_checkpoint_io_list = NULL; + } +} + +/* + * Move a buffer from the checkpoint list to the checkpoint io list + * + * Called with j_list_lock held + */ + +static inline void __buffer_relink_io(struct journal_head *jh) +{ + transaction_t *transaction; + + transaction = jh->b_cp_transaction; + __buffer_unlink_first(jh); + + if (!transaction->t_checkpoint_io_list) { + jh->b_cpnext = jh->b_cpprev = jh; + } else { + jh->b_cpnext = transaction->t_checkpoint_io_list; + jh->b_cpprev = transaction->t_checkpoint_io_list->b_cpprev; + jh->b_cpprev->b_cpnext = jh; + jh->b_cpnext->b_cpprev = jh; + } + transaction->t_checkpoint_io_list = jh; } /* * Try to release a checkpointed buffer from its transaction. - * Returns 1 if we released it. + * Returns 1 if we released it and 2 if we also released the + * whole transaction. + * * Requires j_list_lock * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it */ @@ -57,12 +103,11 @@ static int __try_to_free_cp_buf(struct journal_head *jh) if (jh->b_jlist == BJ_None && !buffer_locked(bh) && !buffer_dirty(bh)) { JBUFFER_TRACE(jh, "remove from checkpoint list"); - __journal_remove_checkpoint(jh); + ret = __journal_remove_checkpoint(jh) + 1; jbd_unlock_bh_state(bh); journal_remove_journal_head(bh); BUFFER_TRACE(bh, "release"); __brelse(bh); - ret = 1; } else { jbd_unlock_bh_state(bh); } @@ -117,83 +162,53 @@ static void jbd_sync_bh(journal_t *journal, struct buffer_head *bh) } /* - * Clean up a transaction's checkpoint list. - * - * We wait for any pending IO to complete and make sure any clean - * buffers are removed from the transaction. - * - * Return 1 if we performed any actions which might have destroyed the - * checkpoint. (journal_remove_checkpoint() deletes the transaction when - * the last checkpoint buffer is cleansed) + * Clean up transaction's list of buffers submitted for io. + * We wait for any pending IO to complete and remove any clean + * buffers. Note that we take the buffers in the opposite ordering + * from the one in which they were submitted for IO. * * Called with j_list_lock held. */ -static int __cleanup_transaction(journal_t *journal, transaction_t *transaction) + +static void __wait_cp_io(journal_t *journal, transaction_t *transaction) { - struct journal_head *jh, *next_jh, *last_jh; + struct journal_head *jh; struct buffer_head *bh; - int ret = 0; - - assert_spin_locked(&journal->j_list_lock); - jh = transaction->t_checkpoint_list; - if (!jh) - return 0; - - last_jh = jh->b_cpprev; - next_jh = jh; - do { - jh = next_jh; + tid_t this_tid; + int released = 0; + + this_tid = transaction->t_tid; +restart: + /* Didn't somebody clean up the transaction in the meanwhile */ + if (journal->j_checkpoint_transactions != transaction || + transaction->t_tid != this_tid) + return; + while (!released && transaction->t_checkpoint_io_list) { + jh = transaction->t_checkpoint_io_list; bh = jh2bh(jh); + if (!jbd_trylock_bh_state(bh)) { + jbd_sync_bh(journal, bh); + spin_lock(&journal->j_list_lock); + goto restart; + } if (buffer_locked(bh)) { atomic_inc(&bh->b_count); spin_unlock(&journal->j_list_lock); + jbd_unlock_bh_state(bh); wait_on_buffer(bh); /* the journal_head may have gone by now */ BUFFER_TRACE(bh, "brelse"); __brelse(bh); - goto out_return_1; - } - - /* - * This is foul - */ - if (!jbd_trylock_bh_state(bh)) { - jbd_sync_bh(journal, bh); - goto out_return_1; + spin_lock(&journal->j_list_lock); + goto restart; } - - if (jh->b_transaction != NULL) { - transaction_t *t = jh->b_transaction; - tid_t tid = t->t_tid; - - spin_unlock(&journal->j_list_lock); - jbd_unlock_bh_state(bh); - log_start_commit(journal, tid); - log_wait_commit(journal, tid); - goto out_return_1; - } - /* - * AKPM: I think the buffer_jbddirty test is redundant - it - * shouldn't have NULL b_transaction? + * Now in whatever state the buffer currently is, we know that + * it has been written out and so we can drop it from the list */ - next_jh = jh->b_cpnext; - if (!buffer_dirty(bh) && !buffer_jbddirty(bh)) { - BUFFER_TRACE(bh, "remove from checkpoint"); - __journal_remove_checkpoint(jh); - jbd_unlock_bh_state(bh); - journal_remove_journal_head(bh); - __brelse(bh); - ret = 1; - } else { - jbd_unlock_bh_state(bh); - } - } while (jh != last_jh); - - return ret; -out_return_1: - spin_lock(&journal->j_list_lock); - return 1; + released = __journal_remove_checkpoint(jh); + jbd_unlock_bh_state(bh); + } } #define NR_BATCH 64 @@ -203,9 +218,7 @@ __flush_batch(journal_t *journal, struct buffer_head **bhs, int *batch_count) { int i; - spin_unlock(&journal->j_list_lock); ll_rw_block(SWRITE, *batch_count, bhs); - spin_lock(&journal->j_list_lock); for (i = 0; i < *batch_count; i++) { struct buffer_head *bh = bhs[i]; clear_buffer_jwrite(bh); @@ -221,19 +234,46 @@ __flush_batch(journal_t *journal, struct buffer_head **bhs, int *batch_count) * Return 1 if something happened which requires us to abort the current * scan of the checkpoint list. * - * Called with j_list_lock held. + * Called with j_list_lock held and drops it if 1 is returned * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it */ -static int __flush_buffer(journal_t *journal, struct journal_head *jh, - struct buffer_head **bhs, int *batch_count, - int *drop_count) +static int __process_buffer(journal_t *journal, struct journal_head *jh, + struct buffer_head **bhs, int *batch_count) { struct buffer_head *bh = jh2bh(jh); int ret = 0; - if (buffer_dirty(bh) && !buffer_locked(bh) && jh->b_jlist == BJ_None) { - J_ASSERT_JH(jh, jh->b_transaction == NULL); + if (buffer_locked(bh)) { + get_bh(bh); + spin_unlock(&journal->j_list_lock); + jbd_unlock_bh_state(bh); + wait_on_buffer(bh); + /* the journal_head may have gone by now */ + BUFFER_TRACE(bh, "brelse"); + put_bh(bh); + ret = 1; + } + else if (jh->b_transaction != NULL) { + transaction_t *t = jh->b_transaction; + tid_t tid = t->t_tid; + spin_unlock(&journal->j_list_lock); + jbd_unlock_bh_state(bh); + log_start_commit(journal, tid); + log_wait_commit(journal, tid); + ret = 1; + } + else if (!buffer_dirty(bh)) { + J_ASSERT_JH(jh, !buffer_jbddirty(bh)); + BUFFER_TRACE(bh, "remove from checkpoint"); + __journal_remove_checkpoint(jh); + spin_unlock(&journal->j_list_lock); + jbd_unlock_bh_state(bh); + journal_remove_journal_head(bh); + put_bh(bh); + ret = 1; + } + else { /* * Important: we are about to write the buffer, and * possibly block, while still holding the journal lock. @@ -246,45 +286,30 @@ static int __flush_buffer(journal_t *journal, struct journal_head *jh, J_ASSERT_BH(bh, !buffer_jwrite(bh)); set_buffer_jwrite(bh); bhs[*batch_count] = bh; + __buffer_relink_io(jh); jbd_unlock_bh_state(bh); (*batch_count)++; if (*batch_count == NR_BATCH) { + spin_unlock(&journal->j_list_lock); __flush_batch(journal, bhs, batch_count); ret = 1; } - } else { - int last_buffer = 0; - if (jh->b_cpnext == jh) { - /* We may be about to drop the transaction. Tell the - * caller that the lists have changed. - */ - last_buffer = 1; - } - if (__try_to_free_cp_buf(jh)) { - (*drop_count)++; - ret = last_buffer; - } } return ret; } /* - * Perform an actual checkpoint. We don't write out only enough to - * satisfy the current blocked requests: rather we submit a reasonably - * sized chunk of the outstanding data to disk at once for - * efficiency. __log_wait_for_space() will retry if we didn't free enough. + * Perform an actual checkpoint. We take the first transaction on the + * list of transactions to be checkpointed and send all its buffers + * to disk. We submit larger chunks of data at once. * - * However, we _do_ take into account the amount requested so that once - * the IO has been queued, we can return as soon as enough of it has - * completed to disk. - * * The journal should be locked before calling this function. */ int log_do_checkpoint(journal_t *journal) { + transaction_t *transaction; + tid_t this_tid; int result; - int batch_count = 0; - struct buffer_head *bhs[NR_BATCH]; jbd_debug(1, "Start checkpoint\n"); @@ -299,79 +324,70 @@ int log_do_checkpoint(journal_t *journal) return result; /* - * OK, we need to start writing disk blocks. Try to free up a - * quarter of the log in a single checkpoint if we can. + * OK, we need to start writing disk blocks. Take one transaction + * and write it. */ + spin_lock(&journal->j_list_lock); + if (!journal->j_checkpoint_transactions) + goto out; + transaction = journal->j_checkpoint_transactions; + this_tid = transaction->t_tid; +restart: /* - * AKPM: check this code. I had a feeling a while back that it - * degenerates into a busy loop at unmount time. + * If someone cleaned up this transaction while we slept, we're + * done (maybe it's a new transaction, but it fell at the same + * address). */ - spin_lock(&journal->j_list_lock); - while (journal->j_checkpoint_transactions) { - transaction_t *transaction; - struct journal_head *jh, *last_jh, *next_jh; - int drop_count = 0; - int cleanup_ret, retry = 0; - tid_t this_tid; - - transaction = journal->j_checkpoint_transactions; - this_tid = transaction->t_tid; - jh = transaction->t_checkpoint_list; - last_jh = jh->b_cpprev; - next_jh = jh; - do { + if (journal->j_checkpoint_transactions == transaction || + transaction->t_tid == this_tid) { + int batch_count = 0; + struct buffer_head *bhs[NR_BATCH]; + struct journal_head *jh; + int retry = 0; + + while (!retry && transaction->t_checkpoint_list) { struct buffer_head *bh; - jh = next_jh; - next_jh = jh->b_cpnext; + jh = transaction->t_checkpoint_list; bh = jh2bh(jh); if (!jbd_trylock_bh_state(bh)) { jbd_sync_bh(journal, bh); - spin_lock(&journal->j_list_lock); retry = 1; break; } - retry = __flush_buffer(journal, jh, bhs, &batch_count, &drop_count); - if (cond_resched_lock(&journal->j_list_lock)) { + retry = __process_buffer(journal, jh, bhs, + &batch_count); + if (!retry && + lock_need_resched(&journal->j_list_lock)) { + spin_unlock(&journal->j_list_lock); retry = 1; break; } - } while (jh != last_jh && !retry); + } if (batch_count) { + if (!retry) { + spin_unlock(&journal->j_list_lock); + retry = 1; + } __flush_batch(journal, bhs, &batch_count); - retry = 1; } + if (retry) { + spin_lock(&journal->j_list_lock); + goto restart; + } /* - * If someone cleaned up this transaction while we slept, we're - * done - */ - if (journal->j_checkpoint_transactions != transaction) - break; - if (retry) - continue; - /* - * Maybe it's a new transaction, but it fell at the same - * address - */ - if (transaction->t_tid != this_tid) - continue; - /* - * We have walked the whole transaction list without - * finding anything to write to disk. We had better be - * able to make some progress or we are in trouble. + * Now we have cleaned up the first transaction's checkpoint + * list. Let's clean up the second one. */ - cleanup_ret = __cleanup_transaction(journal, transaction); - J_ASSERT(drop_count != 0 || cleanup_ret != 0); - if (journal->j_checkpoint_transactions != transaction) - break; + __wait_cp_io(journal, transaction); } +out: spin_unlock(&journal->j_list_lock); result = cleanup_journal_tail(journal); if (result < 0) return result; - return 0; } @@ -456,52 +472,91 @@ int cleanup_journal_tail(journal_t *journal) /* Checkpoint list management */ /* + * journal_clean_one_cp_list + * + * Find all the written-back checkpoint buffers in the given list and release them. + * + * Called with the journal locked. + * Called with j_list_lock held. + * Returns number of bufers reaped (for debug) + */ + +static int journal_clean_one_cp_list(struct journal_head *jh, int *released) +{ + struct journal_head *last_jh; + struct journal_head *next_jh = jh; + int ret, freed = 0; + + *released = 0; + if (!jh) + return 0; + + last_jh = jh->b_cpprev; + do { + jh = next_jh; + next_jh = jh->b_cpnext; + /* Use trylock because of the ranking */ + if (jbd_trylock_bh_state(jh2bh(jh))) { + ret = __try_to_free_cp_buf(jh); + if (ret) { + freed++; + if (ret == 2) { + *released = 1; + return freed; + } + } + } + /* + * This function only frees up some memory if possible so we + * dont have an obligation to finish processing. Bail out if + * preemption requested: + */ + if (need_resched()) + return freed; + } while (jh != last_jh); + + return freed; +} + +/* * journal_clean_checkpoint_list * * Find all the written-back checkpoint buffers in the journal and release them. * * Called with the journal locked. * Called with j_list_lock held. - * Returns number of bufers reaped (for debug) + * Returns number of buffers reaped (for debug) */ int __journal_clean_checkpoint_list(journal_t *journal) { transaction_t *transaction, *last_transaction, *next_transaction; - int ret = 0; + int ret = 0, released; transaction = journal->j_checkpoint_transactions; - if (transaction == 0) + if (!transaction) goto out; last_transaction = transaction->t_cpprev; next_transaction = transaction; do { - struct journal_head *jh; - transaction = next_transaction; next_transaction = transaction->t_cpnext; - jh = transaction->t_checkpoint_list; - if (jh) { - struct journal_head *last_jh = jh->b_cpprev; - struct journal_head *next_jh = jh; - - do { - jh = next_jh; - next_jh = jh->b_cpnext; - /* Use trylock because of the ranknig */ - if (jbd_trylock_bh_state(jh2bh(jh))) - ret += __try_to_free_cp_buf(jh); - /* - * This function only frees up some memory - * if possible so we dont have an obligation - * to finish processing. Bail out if preemption - * requested: - */ - if (need_resched()) - goto out; - } while (jh != last_jh); - } + ret += journal_clean_one_cp_list(transaction-> + t_checkpoint_list, &released); + if (need_resched()) + goto out; + if (released) + continue; + /* + * It is essential that we are as careful as in the case of + * t_checkpoint_list with removing the buffer from the list as + * we can possibly see not yet submitted buffers on io_list + */ + ret += journal_clean_one_cp_list(transaction-> + t_checkpoint_io_list, &released); + if (need_resched()) + goto out; } while (transaction != last_transaction); out: return ret; @@ -516,18 +571,22 @@ out: * buffer updates committed in that transaction have safely been stored * elsewhere on disk. To achieve this, all of the buffers in a * transaction need to be maintained on the transaction's checkpoint - * list until they have been rewritten, at which point this function is + * lists until they have been rewritten, at which point this function is * called to remove the buffer from the existing transaction's - * checkpoint list. + * checkpoint lists. + * + * The function returns 1 if it frees the transaction, 0 otherwise. * * This function is called with the journal locked. * This function is called with j_list_lock held. + * This function is called with jbd_lock_bh_state(jh2bh(jh)) */ -void __journal_remove_checkpoint(struct journal_head *jh) +int __journal_remove_checkpoint(struct journal_head *jh) { transaction_t *transaction; journal_t *journal; + int ret = 0; JBUFFER_TRACE(jh, "entry"); @@ -538,8 +597,10 @@ void __journal_remove_checkpoint(struct journal_head *jh) journal = transaction->t_journal; __buffer_unlink(jh); + jh->b_cp_transaction = NULL; - if (transaction->t_checkpoint_list != NULL) + if (transaction->t_checkpoint_list != NULL || + transaction->t_checkpoint_io_list != NULL) goto out; JBUFFER_TRACE(jh, "transaction has no more buffers"); @@ -565,8 +626,10 @@ void __journal_remove_checkpoint(struct journal_head *jh) /* Just in case anybody was waiting for more transactions to be checkpointed... */ wake_up(&journal->j_wait_logspace); + ret = 1; out: JBUFFER_TRACE(jh, "exit"); + return ret; } /* @@ -628,6 +691,7 @@ void __journal_drop_transaction(journal_t *journal, transaction_t *transaction) J_ASSERT(transaction->t_shadow_list == NULL); J_ASSERT(transaction->t_log_list == NULL); J_ASSERT(transaction->t_checkpoint_list == NULL); + J_ASSERT(transaction->t_checkpoint_io_list == NULL); J_ASSERT(transaction->t_updates == 0); J_ASSERT(journal->j_committing_transaction != transaction); J_ASSERT(journal->j_running_transaction != transaction); diff --git a/include/linux/jbd.h b/include/linux/jbd.h index dcde7adf..558cb4c 100644 --- a/include/linux/jbd.h +++ b/include/linux/jbd.h @@ -498,6 +498,12 @@ struct transaction_s struct journal_head *t_checkpoint_list; /* + * Doubly-linked circular list of all buffers submitted for IO while + * checkpointing. [j_list_lock] + */ + struct journal_head *t_checkpoint_io_list; + + /* * Doubly-linked circular list of temporary buffers currently undergoing * IO in the log [j_list_lock] */ @@ -843,7 +849,7 @@ extern void journal_commit_transaction(journal_t *); /* Checkpoint list management */ int __journal_clean_checkpoint_list(journal_t *journal); -void __journal_remove_checkpoint(struct journal_head *); +int __journal_remove_checkpoint(struct journal_head *); void __journal_insert_checkpoint(struct journal_head *, transaction_t *); /* Buffer IO */ -- cgit v1.1 From 93fbf1a5de8afde08988dda3735669099dee84d0 Mon Sep 17 00:00:00 2001 From: Olaf Kirch Date: Fri, 6 Jan 2006 00:19:56 -0800 Subject: [PATCH] Keep nfsd from exiting when seeing recv() errors I submitted this one previously - svc_tcp_recvfrom currently returns any errors to the caller, including ECONNRESET and the like. This is something svc_recv isn't able to deal with: len = svsk->sk_recvfrom(rqstp); [...] if (len == 0 || len == -EAGAIN) { [...] return -EAGAIN; } [...] return len; The nfsd main loop will exit when it sees an error code other than EAGAIN. The following patch fixes this problem svc_recv is not equipped to deal with error codes other than EAGAIN, and will propagate anything else (such as ECONNRESET) up to nfsd, causing it to exit. Signed-off-by: Olaf Kirch Cc: Trond Myklebust Cc: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/sunrpc/svcsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index d68eba4..e67613e 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1026,7 +1026,7 @@ svc_tcp_recvfrom(struct svc_rqst *rqstp) } else { printk(KERN_NOTICE "%s: recvfrom returned errno %d\n", svsk->sk_server->sv_name, -len); - svc_sock_received(svsk); + goto err_delete; } return len; -- cgit v1.1 From a334de28665b14f0a33df82699fa9a78cfeedf31 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Fri, 6 Jan 2006 00:19:58 -0800 Subject: [PATCH] knfsd: check error status from vfs_getattr and i_op->fsync Both vfs_getattr and i_op->fsync return error statuses which nfsd was largely ignoring. This as noticed when exporting directories using fuse. This patch cleans up most of the offences, which involves moving the call to vfs_getattr out of the xdr encoding routines (where it is too late to report an error) into the main NFS procedure handling routines. There is still a called to vfs_gettattr (related to the ACL code) where the status is ignored, and called to nfsd_sync_dir don't check return status either. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/nfsd/nfs3proc.c | 11 +++++++++-- fs/nfsd/nfs3xdr.c | 47 ++++++++++++++++++++++++---------------------- fs/nfsd/nfsxdr.c | 48 +++++++++++++++++++++++------------------------ fs/nfsd/vfs.c | 20 +++++++++++++------- include/linux/nfsd/xdr.h | 3 +++ include/linux/nfsd/xdr3.h | 1 + 6 files changed, 75 insertions(+), 55 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 041380f..6d2dfed 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -56,13 +56,20 @@ static int nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp, struct nfsd3_attrstat *resp) { - int nfserr; + int err, nfserr; dprintk("nfsd: GETATTR(3) %s\n", - SVCFH_fmt(&argp->fh)); + SVCFH_fmt(&argp->fh)); fh_copy(&resp->fh, &argp->fh); nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP); + if (nfserr) + RETURN_STATUS(nfserr); + + err = vfs_getattr(resp->fh.fh_export->ex_mnt, + resp->fh.fh_dentry, &resp->stat); + nfserr = nfserrno(err); + RETURN_STATUS(nfserr); } diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 9147b85..243d94b 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -154,37 +154,34 @@ decode_sattr3(u32 *p, struct iattr *iap) } static inline u32 * -encode_fattr3(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) +encode_fattr3(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp, + struct kstat *stat) { - struct vfsmount *mnt = fhp->fh_export->ex_mnt; struct dentry *dentry = fhp->fh_dentry; - struct kstat stat; struct timespec time; - vfs_getattr(mnt, dentry, &stat); - - *p++ = htonl(nfs3_ftypes[(stat.mode & S_IFMT) >> 12]); - *p++ = htonl((u32) stat.mode); - *p++ = htonl((u32) stat.nlink); - *p++ = htonl((u32) nfsd_ruid(rqstp, stat.uid)); - *p++ = htonl((u32) nfsd_rgid(rqstp, stat.gid)); - if (S_ISLNK(stat.mode) && stat.size > NFS3_MAXPATHLEN) { + *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]); + *p++ = htonl((u32) stat->mode); + *p++ = htonl((u32) stat->nlink); + *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid)); + *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid)); + if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) { p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN); } else { - p = xdr_encode_hyper(p, (u64) stat.size); + p = xdr_encode_hyper(p, (u64) stat->size); } - p = xdr_encode_hyper(p, ((u64)stat.blocks) << 9); - *p++ = htonl((u32) MAJOR(stat.rdev)); - *p++ = htonl((u32) MINOR(stat.rdev)); + p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9); + *p++ = htonl((u32) MAJOR(stat->rdev)); + *p++ = htonl((u32) MINOR(stat->rdev)); if (is_fsid(fhp, rqstp->rq_reffh)) p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid); else - p = xdr_encode_hyper(p, (u64) huge_encode_dev(stat.dev)); - p = xdr_encode_hyper(p, (u64) stat.ino); - p = encode_time3(p, &stat.atime); + p = xdr_encode_hyper(p, (u64) huge_encode_dev(stat->dev)); + p = xdr_encode_hyper(p, (u64) stat->ino); + p = encode_time3(p, &stat->atime); lease_get_mtime(dentry->d_inode, &time); p = encode_time3(p, &time); - p = encode_time3(p, &stat.ctime); + p = encode_time3(p, &stat->ctime); return p; } @@ -232,8 +229,14 @@ encode_post_op_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) { struct dentry *dentry = fhp->fh_dentry; if (dentry && dentry->d_inode != NULL) { - *p++ = xdr_one; /* attributes follow */ - return encode_fattr3(rqstp, p, fhp); + int err; + struct kstat stat; + + err = vfs_getattr(fhp->fh_export->ex_mnt, dentry, &stat); + if (!err) { + *p++ = xdr_one; /* attributes follow */ + return encode_fattr3(rqstp, p, fhp, &stat); + } } *p++ = xdr_zero; return p; @@ -616,7 +619,7 @@ nfs3svc_encode_attrstat(struct svc_rqst *rqstp, u32 *p, struct nfsd3_attrstat *resp) { if (resp->status == 0) - p = encode_fattr3(rqstp, p, &resp->fh); + p = encode_fattr3(rqstp, p, &resp->fh, &resp->stat); return xdr_ressize_check(rqstp, p); } diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index b45999f..aa7bb41 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -152,46 +152,44 @@ decode_sattr(u32 *p, struct iattr *iap) } static inline u32 * -encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) +encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp, + struct kstat *stat) { - struct vfsmount *mnt = fhp->fh_export->ex_mnt; struct dentry *dentry = fhp->fh_dentry; - struct kstat stat; int type; struct timespec time; - vfs_getattr(mnt, dentry, &stat); - type = (stat.mode & S_IFMT); + type = (stat->mode & S_IFMT); *p++ = htonl(nfs_ftypes[type >> 12]); - *p++ = htonl((u32) stat.mode); - *p++ = htonl((u32) stat.nlink); - *p++ = htonl((u32) nfsd_ruid(rqstp, stat.uid)); - *p++ = htonl((u32) nfsd_rgid(rqstp, stat.gid)); + *p++ = htonl((u32) stat->mode); + *p++ = htonl((u32) stat->nlink); + *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid)); + *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid)); - if (S_ISLNK(type) && stat.size > NFS_MAXPATHLEN) { + if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) { *p++ = htonl(NFS_MAXPATHLEN); } else { - *p++ = htonl((u32) stat.size); + *p++ = htonl((u32) stat->size); } - *p++ = htonl((u32) stat.blksize); + *p++ = htonl((u32) stat->blksize); if (S_ISCHR(type) || S_ISBLK(type)) - *p++ = htonl(new_encode_dev(stat.rdev)); + *p++ = htonl(new_encode_dev(stat->rdev)); else *p++ = htonl(0xffffffff); - *p++ = htonl((u32) stat.blocks); + *p++ = htonl((u32) stat->blocks); if (is_fsid(fhp, rqstp->rq_reffh)) *p++ = htonl((u32) fhp->fh_export->ex_fsid); else - *p++ = htonl(new_encode_dev(stat.dev)); - *p++ = htonl((u32) stat.ino); - *p++ = htonl((u32) stat.atime.tv_sec); - *p++ = htonl(stat.atime.tv_nsec ? stat.atime.tv_nsec / 1000 : 0); + *p++ = htonl(new_encode_dev(stat->dev)); + *p++ = htonl((u32) stat->ino); + *p++ = htonl((u32) stat->atime.tv_sec); + *p++ = htonl(stat->atime.tv_nsec ? stat->atime.tv_nsec / 1000 : 0); lease_get_mtime(dentry->d_inode, &time); *p++ = htonl((u32) time.tv_sec); *p++ = htonl(time.tv_nsec ? time.tv_nsec / 1000 : 0); - *p++ = htonl((u32) stat.ctime.tv_sec); - *p++ = htonl(stat.ctime.tv_nsec ? stat.ctime.tv_nsec / 1000 : 0); + *p++ = htonl((u32) stat->ctime.tv_sec); + *p++ = htonl(stat->ctime.tv_nsec ? stat->ctime.tv_nsec / 1000 : 0); return p; } @@ -199,7 +197,9 @@ encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) /* Helper function for NFSv2 ACL code */ u32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) { - return encode_fattr(rqstp, p, fhp); + struct kstat stat; + vfs_getattr(fhp->fh_export->ex_mnt, fhp->fh_dentry, &stat); + return encode_fattr(rqstp, p, fhp, &stat); } /* @@ -394,7 +394,7 @@ int nfssvc_encode_attrstat(struct svc_rqst *rqstp, u32 *p, struct nfsd_attrstat *resp) { - p = encode_fattr(rqstp, p, &resp->fh); + p = encode_fattr(rqstp, p, &resp->fh, &resp->stat); return xdr_ressize_check(rqstp, p); } @@ -403,7 +403,7 @@ nfssvc_encode_diropres(struct svc_rqst *rqstp, u32 *p, struct nfsd_diropres *resp) { p = encode_fh(p, &resp->fh); - p = encode_fattr(rqstp, p, &resp->fh); + p = encode_fattr(rqstp, p, &resp->fh, &resp->stat); return xdr_ressize_check(rqstp, p); } @@ -428,7 +428,7 @@ int nfssvc_encode_readres(struct svc_rqst *rqstp, u32 *p, struct nfsd_readres *resp) { - p = encode_fattr(rqstp, p, &resp->fh); + p = encode_fattr(rqstp, p, &resp->fh, &resp->stat); *p++ = htonl(resp->count); xdr_ressize_check(rqstp, p); diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index af7c3c3..f83ab4c 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -717,27 +717,33 @@ nfsd_close(struct file *filp) * As this calls fsync (not fdatasync) there is no need for a write_inode * after it. */ -static inline void nfsd_dosync(struct file *filp, struct dentry *dp, - struct file_operations *fop) +static inline int nfsd_dosync(struct file *filp, struct dentry *dp, + struct file_operations *fop) { struct inode *inode = dp->d_inode; int (*fsync) (struct file *, struct dentry *, int); + int err = nfs_ok; filemap_fdatawrite(inode->i_mapping); if (fop && (fsync = fop->fsync)) - fsync(filp, dp, 0); + err=fsync(filp, dp, 0); filemap_fdatawait(inode->i_mapping); + + return nfserrno(err); } -static void +static int nfsd_sync(struct file *filp) { + int err; struct inode *inode = filp->f_dentry->d_inode; dprintk("nfsd: sync file %s\n", filp->f_dentry->d_name.name); down(&inode->i_sem); - nfsd_dosync(filp, filp->f_dentry, filp->f_op); + err=nfsd_dosync(filp, filp->f_dentry, filp->f_op); up(&inode->i_sem); + + return err; } void @@ -962,7 +968,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, if (inode->i_state & I_DIRTY) { dprintk("nfsd: write sync %d\n", current->pid); - nfsd_sync(file); + err=nfsd_sync(file); } #if 0 wake_up(&inode->i_wait); @@ -1066,7 +1072,7 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, return err; if (EX_ISSYNC(fhp->fh_export)) { if (file->f_op && file->f_op->fsync) { - nfsd_sync(file); + err = nfsd_sync(file); } else { err = nfserr_notsupp; } diff --git a/include/linux/nfsd/xdr.h b/include/linux/nfsd/xdr.h index 130d4f5..3f4f714 100644 --- a/include/linux/nfsd/xdr.h +++ b/include/linux/nfsd/xdr.h @@ -88,10 +88,12 @@ struct nfsd_readdirargs { struct nfsd_attrstat { struct svc_fh fh; + struct kstat stat; }; struct nfsd_diropres { struct svc_fh fh; + struct kstat stat; }; struct nfsd_readlinkres { @@ -101,6 +103,7 @@ struct nfsd_readlinkres { struct nfsd_readres { struct svc_fh fh; unsigned long count; + struct kstat stat; }; struct nfsd_readdirres { diff --git a/include/linux/nfsd/xdr3.h b/include/linux/nfsd/xdr3.h index 3c2a71b..a432274 100644 --- a/include/linux/nfsd/xdr3.h +++ b/include/linux/nfsd/xdr3.h @@ -126,6 +126,7 @@ struct nfsd3_setaclargs { struct nfsd3_attrstat { __u32 status; struct svc_fh fh; + struct kstat stat; }; /* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */ -- cgit v1.1 From 9f708e40fe040e79f6c393a282f0701c9f8dc174 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 6 Jan 2006 00:19:59 -0800 Subject: [PATCH] knfsd: reduce stack consumption A typical nfsd call trace is nfsd -> svc_process -> nfsd_dispatch -> nfsd3_proc_write -> nfsd_write ->nfsd_vfs_write -> vfs_writev These add up to over 300 bytes on the stack. Looking at each of these, I see that nfsd_write (which includes nfsd_vfs_write) contributes 0x8c to stack usage itself!! It turns out this is because it puts a 'struct iattr' on the stack so it can kill suid if needed. The following patch saves about 50 bytes off the stack in this call path. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/nfsd/vfs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index f83ab4c..df4019f 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -880,6 +880,16 @@ out: return err; } +static void kill_suid(struct dentry *dentry) +{ + struct iattr ia; + ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID; + + down(&dentry->d_inode->i_sem); + notify_change(dentry, &ia); + up(&dentry->d_inode->i_sem); +} + static inline int nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, loff_t offset, struct kvec *vec, int vlen, @@ -933,14 +943,8 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, } /* clear setuid/setgid flag after write */ - if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) { - struct iattr ia; - ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID; - - down(&inode->i_sem); - notify_change(dentry, &ia); - up(&inode->i_sem); - } + if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) + kill_suid(dentry); if (err >= 0 && stable) { static ino_t last_ino; -- cgit v1.1 From 637842cfdbe2b981f7088f7633e630570f58efaf Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 6 Jan 2006 00:20:00 -0800 Subject: [PATCH] device-mapper: add dm_find_md Abstract dm_find_md() from dm_get_mdptr() to allow use elsewhere. Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 930b9fc..27cd234 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -902,10 +902,9 @@ int dm_create_with_minor(unsigned int minor, struct mapped_device **result) return create_aux(minor, 1, result); } -void *dm_get_mdptr(dev_t dev) +static struct mapped_device *dm_find_md(dev_t dev) { struct mapped_device *md; - void *mdptr = NULL; unsigned minor = MINOR(dev); if (MAJOR(dev) != _major || minor >= (1 << MINORBITS)) @@ -914,12 +913,22 @@ void *dm_get_mdptr(dev_t dev) down(&_minor_lock); md = idr_find(&_minor_idr, minor); - - if (md && (dm_disk(md)->first_minor == minor)) - mdptr = md->interface_ptr; + if (!md || (dm_disk(md)->first_minor != minor)) + md = NULL; up(&_minor_lock); + return md; +} + +void *dm_get_mdptr(dev_t dev) +{ + struct mapped_device *md; + void *mdptr = NULL; + + md = dm_find_md(dev); + if (md) + mdptr = md->interface_ptr; return mdptr; } -- cgit v1.1 From d229a9589ff3b988d3f999cdcfa350f97a372673 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Fri, 6 Jan 2006 00:20:01 -0800 Subject: [PATCH] device-mapper: add dm_get_md Add dm_get_dev() to get a mapped device given its dev_t. Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm.c | 10 ++++++++++ drivers/md/dm.h | 1 + 2 files changed, 11 insertions(+) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 27cd234..9e8c1ed 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -921,6 +921,16 @@ static struct mapped_device *dm_find_md(dev_t dev) return md; } +struct mapped_device *dm_get_md(dev_t dev) +{ + struct mapped_device *md = dm_find_md(dev); + + if (md) + dm_get(md); + + return md; +} + void *dm_get_mdptr(dev_t dev) { struct mapped_device *md; diff --git a/drivers/md/dm.h b/drivers/md/dm.h index e38c3fc..ab078a2 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -58,6 +58,7 @@ int dm_create(struct mapped_device **md); int dm_create_with_minor(unsigned int minor, struct mapped_device **md); void dm_set_mdptr(struct mapped_device *md, void *ptr); void *dm_get_mdptr(dev_t dev); +struct mapped_device *dm_get_md(dev_t dev); /* * Reference counting for md. -- cgit v1.1 From 81f1777a55e8c631b61e5fa5980fb7a2004287af Mon Sep 17 00:00:00 2001 From: "goggin, edward" Date: Fri, 6 Jan 2006 00:20:01 -0800 Subject: [PATCH] device-mapper ioctl: event on rename After changing the name of a mapped device, trigger a dm event. (For userspace multipath tools.) Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-ioctl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 07d44e1..3e327db 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -270,6 +270,7 @@ static int dm_hash_rename(const char *old, const char *new) { char *new_name, *old_name; struct hash_cell *hc; + struct dm_table *table; /* * duplicate new. @@ -317,6 +318,15 @@ static int dm_hash_rename(const char *old, const char *new) /* rename the device node in devfs */ register_with_devfs(hc); + /* + * Wake up any dm event waiters. + */ + table = dm_get_table(hc->md); + if (table) { + dm_table_event(table); + dm_table_put(table); + } + up_write(&_hash_lock); kfree(old_name); return 0; -- cgit v1.1 From 2d38fe204461dc542bb38f2b01a9cd115b367b36 Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Fri, 6 Jan 2006 00:20:02 -0800 Subject: [PATCH] device-mapper snapshot: metadata reading separation More snapshot metadata reading into separate function, to prepare for changing the place it gets called from. Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-snap.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index ab54f99..4b9dd8f 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -371,6 +371,20 @@ static inline ulong round_up(ulong n, ulong size) return (n + size) & ~size; } +static void read_snapshot_metadata(struct dm_snapshot *s) +{ + if (s->have_metadata) + return; + + if (s->store.read_metadata(&s->store)) { + down_write(&s->lock); + s->valid = 0; + up_write(&s->lock); + } + + s->have_metadata = 1; +} + /* * Construct a snapshot mapping:

*/ @@ -848,16 +862,7 @@ static void snapshot_resume(struct dm_target *ti) { struct dm_snapshot *s = (struct dm_snapshot *) ti->private; - if (s->have_metadata) - return; - - if (s->store.read_metadata(&s->store)) { - down_write(&s->lock); - s->valid = 0; - up_write(&s->lock); - } - - s->have_metadata = 1; + read_snapshot_metadata(s); } static int snapshot_status(struct dm_target *ti, status_type_t type, -- cgit v1.1 From e6c276159c812ab25f47b7c7b683a5c97c442dd5 Mon Sep 17 00:00:00 2001 From: Andrew Stribblehill Date: Fri, 6 Jan 2006 00:20:03 -0800 Subject: [PATCH] device-mapper: remove unused definition This patch removes an unused #define. Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-io.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/md/dm-io.h b/drivers/md/dm-io.h index 1a77f32..f9035bf 100644 --- a/drivers/md/dm-io.h +++ b/drivers/md/dm-io.h @@ -9,9 +9,6 @@ #include "dm.h" -/* FIXME make this configurable */ -#define DM_MAX_IO_REGIONS 8 - struct io_region { struct block_device *bdev; sector_t sector; -- cgit v1.1 From 2d5fe68987341a59a3fd97c71695efcabb0c6fd5 Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Fri, 6 Jan 2006 00:20:04 -0800 Subject: [PATCH] device-mapper: scanf sector format change Use %llu not %Lu in sscanf/printf format strings. Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm.h b/drivers/md/dm.h index ab078a2..95a0cfb 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -28,7 +28,7 @@ * in types.h. */ #ifdef CONFIG_LBD -#define SECTOR_FORMAT "%Lu" +#define SECTOR_FORMAT "%llu" #else #define SECTOR_FORMAT "%lu" #endif -- cgit v1.1 From a1a190807074bd6ad8771e00b00752771ae586cb Mon Sep 17 00:00:00 2001 From: Jonathan E Brassow Date: Fri, 6 Jan 2006 00:20:05 -0800 Subject: [PATCH] device-mapper raid1: add default mirror This patch introduces a new field to the mirror_set (default_mirror) to store the default mirror. (A subsequent patch will allow us to change the default mirror in the event of a failure.) Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-raid1.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 6b0fc16..6cfa8d4 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -562,6 +562,8 @@ struct mirror_set { region_t nr_regions; int in_sync; + struct mirror *default_mirror; /* Default mirror */ + unsigned int nr_mirrors; struct mirror mirror[0]; }; @@ -611,7 +613,7 @@ static int recover(struct mirror_set *ms, struct region *reg) unsigned long flags = 0; /* fill in the source */ - m = ms->mirror + DEFAULT_MIRROR; + m = ms->default_mirror; from.bdev = m->dev->bdev; from.sector = m->offset + region_to_sector(reg->rh, reg->key); if (reg->key == (ms->nr_regions - 1)) { @@ -627,7 +629,7 @@ static int recover(struct mirror_set *ms, struct region *reg) /* fill in the destinations */ for (i = 0, dest = to; i < ms->nr_mirrors; i++) { - if (i == DEFAULT_MIRROR) + if (&ms->mirror[i] == ms->default_mirror) continue; m = ms->mirror + i; @@ -682,7 +684,7 @@ static void do_recovery(struct mirror_set *ms) static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector) { /* FIXME: add read balancing */ - return ms->mirror + DEFAULT_MIRROR; + return ms->default_mirror; } /* @@ -709,7 +711,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads) if (rh_in_sync(&ms->rh, region, 0)) m = choose_mirror(ms, bio->bi_sector); else - m = ms->mirror + DEFAULT_MIRROR; + m = ms->default_mirror; map_bio(ms, m, bio); generic_make_request(bio); @@ -833,7 +835,7 @@ static void do_writes(struct mirror_set *ms, struct bio_list *writes) rh_delay(&ms->rh, bio); while ((bio = bio_list_pop(&nosync))) { - map_bio(ms, ms->mirror + DEFAULT_MIRROR, bio); + map_bio(ms, ms->default_mirror, bio); generic_make_request(bio); } } @@ -900,6 +902,7 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, ms->nr_mirrors = nr_mirrors; ms->nr_regions = dm_sector_div_up(ti->len, region_size); ms->in_sync = 0; + ms->default_mirror = &ms->mirror[DEFAULT_MIRROR]; if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) { ti->error = "dm-mirror: Error creating dirty region hash"; -- cgit v1.1 From e39e2e95eb8bd536b61654e8fda1516d0a6a3cd1 Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Fri, 6 Jan 2006 00:20:05 -0800 Subject: [PATCH] device-mapper: rename frozen_bdev Rename frozen_bdev to suspended_bdev and move the bdget outside lockfs. (This prepares for making lockfs optional.) Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm.c | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 9e8c1ed..fc335e0 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -97,7 +97,7 @@ struct mapped_device { * freeze/thaw support require holding onto a super block */ struct super_block *frozen_sb; - struct block_device *frozen_bdev; + struct block_device *suspended_bdev; }; #define MIN_IOS 256 @@ -836,9 +836,9 @@ static void __set_size(struct mapped_device *md, sector_t size) { set_capacity(md->disk, size); - down(&md->frozen_bdev->bd_inode->i_sem); - i_size_write(md->frozen_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT); - up(&md->frozen_bdev->bd_inode->i_sem); + down(&md->suspended_bdev->bd_inode->i_sem); + i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT); + up(&md->suspended_bdev->bd_inode->i_sem); } static int __bind(struct mapped_device *md, struct dm_table *t) @@ -1010,43 +1010,27 @@ out: */ static int lock_fs(struct mapped_device *md) { - int r = -ENOMEM; - - md->frozen_bdev = bdget_disk(md->disk, 0); - if (!md->frozen_bdev) { - DMWARN("bdget failed in lock_fs"); - goto out; - } + int r; WARN_ON(md->frozen_sb); - md->frozen_sb = freeze_bdev(md->frozen_bdev); + md->frozen_sb = freeze_bdev(md->suspended_bdev); if (IS_ERR(md->frozen_sb)) { r = PTR_ERR(md->frozen_sb); - goto out_bdput; + md->frozen_sb = NULL; + return r; } /* don't bdput right now, we don't want the bdev - * to go away while it is locked. We'll bdput - * in unlock_fs + * to go away while it is locked. */ return 0; - -out_bdput: - bdput(md->frozen_bdev); - md->frozen_sb = NULL; - md->frozen_bdev = NULL; -out: - return r; } static void unlock_fs(struct mapped_device *md) { - thaw_bdev(md->frozen_bdev, md->frozen_sb); - bdput(md->frozen_bdev); - + thaw_bdev(md->suspended_bdev, md->frozen_sb); md->frozen_sb = NULL; - md->frozen_bdev = NULL; } /* @@ -1072,6 +1056,13 @@ int dm_suspend(struct mapped_device *md) /* This does not get reverted if there's an error later. */ dm_table_presuspend_targets(map); + md->suspended_bdev = bdget_disk(md->disk, 0); + if (!md->suspended_bdev) { + DMWARN("bdget failed in dm_suspend"); + r = -ENOMEM; + goto out; + } + /* Flush I/O to the device. */ r = lock_fs(md); if (r) @@ -1124,6 +1115,11 @@ int dm_suspend(struct mapped_device *md) r = 0; out: + if (r && md->suspended_bdev) { + bdput(md->suspended_bdev); + md->suspended_bdev = NULL; + } + dm_table_put(map); up(&md->suspend_lock); return r; @@ -1154,6 +1150,9 @@ int dm_resume(struct mapped_device *md) unlock_fs(md); + bdput(md->suspended_bdev); + md->suspended_bdev = NULL; + clear_bit(DMF_SUSPENDED, &md->flags); dm_table_unplug_all(map); -- cgit v1.1 From aa8d7c2fbe619d8c0837296d2eaf4c14cebac198 Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Fri, 6 Jan 2006 00:20:06 -0800 Subject: [PATCH] device-mapper: make lock_fs optional Devices only needs syncing when creating snapshots, so make this optional when suspending a device. Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-ioctl.c | 4 ++-- drivers/md/dm.c | 17 +++++++++++++---- drivers/md/dm.h | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 3e327db..dbc07af 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -700,7 +700,7 @@ static int do_suspend(struct dm_ioctl *param) return -ENXIO; if (!dm_suspended(md)) - r = dm_suspend(md); + r = dm_suspend(md, 1); if (!r) r = __dev_status(md, param); @@ -738,7 +738,7 @@ static int do_resume(struct dm_ioctl *param) if (new_map) { /* Suspend if it isn't already suspended */ if (!dm_suspended(md)) - dm_suspend(md); + dm_suspend(md, 1); r = dm_swap_table(md, new_map); if (r) { diff --git a/drivers/md/dm.c b/drivers/md/dm.c index fc335e0..0e48151 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -55,6 +55,7 @@ union map_info *dm_get_mapinfo(struct bio *bio) */ #define DMF_BLOCK_IO 0 #define DMF_SUSPENDED 1 +#define DMF_FROZEN 2 struct mapped_device { struct rw_semaphore io_lock; @@ -1021,6 +1022,8 @@ static int lock_fs(struct mapped_device *md) return r; } + set_bit(DMF_FROZEN, &md->flags); + /* don't bdput right now, we don't want the bdev * to go away while it is locked. */ @@ -1029,8 +1032,12 @@ static int lock_fs(struct mapped_device *md) static void unlock_fs(struct mapped_device *md) { + if (!test_bit(DMF_FROZEN, &md->flags)) + return; + thaw_bdev(md->suspended_bdev, md->frozen_sb); md->frozen_sb = NULL; + clear_bit(DMF_FROZEN, &md->flags); } /* @@ -1040,7 +1047,7 @@ static void unlock_fs(struct mapped_device *md) * dm_bind_table, dm_suspend must be called to flush any in * flight bios and ensure that any further io gets deferred. */ -int dm_suspend(struct mapped_device *md) +int dm_suspend(struct mapped_device *md, int do_lockfs) { struct dm_table *map = NULL; DECLARE_WAITQUEUE(wait, current); @@ -1064,9 +1071,11 @@ int dm_suspend(struct mapped_device *md) } /* Flush I/O to the device. */ - r = lock_fs(md); - if (r) - goto out; + if (do_lockfs) { + r = lock_fs(md); + if (r) + goto out; + } /* * First we set the BLOCK_IO flag so no more ios will be mapped. diff --git a/drivers/md/dm.h b/drivers/md/dm.h index 95a0cfb..4eaf075 100644 --- a/drivers/md/dm.h +++ b/drivers/md/dm.h @@ -69,7 +69,7 @@ void dm_put(struct mapped_device *md); /* * A device can still be used while suspended, but I/O is deferred. */ -int dm_suspend(struct mapped_device *md); +int dm_suspend(struct mapped_device *md, int with_lockfs); int dm_resume(struct mapped_device *md); /* -- cgit v1.1 From 6da487dcc0c6f4c827779687a20016efeffc4d60 Mon Sep 17 00:00:00 2001 From: Alasdair G Kergon Date: Fri, 6 Jan 2006 00:20:07 -0800 Subject: [PATCH] device-mapper ioctl: add skip lock_fs flag Add ioctl DM_SKIP_LOCKFS_FLAG for userspace to request that lock_fs is bypassed when suspending a device. There's no change to the behaviour of existing code that doesn't know about the new flag. Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-ioctl.c | 11 +++++++++-- include/linux/dm-ioctl.h | 11 ++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index dbc07af..561bda5 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -693,14 +693,18 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size) static int do_suspend(struct dm_ioctl *param) { int r = 0; + int do_lockfs = 1; struct mapped_device *md; md = find_device(param); if (!md) return -ENXIO; + if (param->flags & DM_SKIP_LOCKFS_FLAG) + do_lockfs = 0; + if (!dm_suspended(md)) - r = dm_suspend(md, 1); + r = dm_suspend(md, do_lockfs); if (!r) r = __dev_status(md, param); @@ -712,6 +716,7 @@ static int do_suspend(struct dm_ioctl *param) static int do_resume(struct dm_ioctl *param) { int r = 0; + int do_lockfs = 1; struct hash_cell *hc; struct mapped_device *md; struct dm_table *new_map; @@ -737,8 +742,10 @@ static int do_resume(struct dm_ioctl *param) /* Do we need to load a new map ? */ if (new_map) { /* Suspend if it isn't already suspended */ + if (param->flags & DM_SKIP_LOCKFS_FLAG) + do_lockfs = 0; if (!dm_suspended(md)) - dm_suspend(md, 1); + dm_suspend(md, do_lockfs); r = dm_swap_table(md, new_map); if (r) { diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h index f5eb6b6..fa75ba0 100644 --- a/include/linux/dm-ioctl.h +++ b/include/linux/dm-ioctl.h @@ -272,9 +272,9 @@ typedef char ioctl_struct[308]; #define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl) #define DM_VERSION_MAJOR 4 -#define DM_VERSION_MINOR 4 +#define DM_VERSION_MINOR 5 #define DM_VERSION_PATCHLEVEL 0 -#define DM_VERSION_EXTRA "-ioctl (2005-01-12)" +#define DM_VERSION_EXTRA "-ioctl (2005-10-04)" /* Status bits */ #define DM_READONLY_FLAG (1 << 0) /* In/Out */ @@ -301,8 +301,13 @@ typedef char ioctl_struct[308]; #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */ /* - * Set this to improve performance when you aren't going to use open_count + * Set this to improve performance when you aren't going to use open_count. */ #define DM_SKIP_BDGET_FLAG (1 << 9) /* In */ +/* + * Set this to avoid attempting to freeze any filesystem when suspending. + */ +#define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */ + #endif /* _LINUX_DM_IOCTL_H */ -- cgit v1.1 From 0b56306e56784d0513e1193d58c05a6bd97bd1a9 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 6 Jan 2006 00:20:08 -0800 Subject: [PATCH] drivers/md/kcopyd.c: #if 0 kcopyd_cancel() This patch #if 0's the not yet implemented global function kcopyd_cancel(). Signed-off-by: Adrian Bunk Acked-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/kcopyd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c index eb70364..ca99979 100644 --- a/drivers/md/kcopyd.c +++ b/drivers/md/kcopyd.c @@ -561,11 +561,13 @@ int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from, * Cancels a kcopyd job, eg. someone might be deactivating a * mirror. */ +#if 0 int kcopyd_cancel(struct kcopyd_job *job, int block) { /* FIXME: finish */ return -1; } +#endif /* 0 */ /*----------------------------------------------------------------- * Unit setup @@ -684,4 +686,3 @@ void kcopyd_client_destroy(struct kcopyd_client *kc) EXPORT_SYMBOL(kcopyd_client_create); EXPORT_SYMBOL(kcopyd_client_destroy); EXPORT_SYMBOL(kcopyd_copy); -EXPORT_SYMBOL(kcopyd_cancel); -- cgit v1.1 From 9d3520a339d62f942085e9888f66905eb8b350bd Mon Sep 17 00:00:00 2001 From: Stefan Rompf Date: Fri, 6 Jan 2006 00:20:08 -0800 Subject: [PATCH] dm-crypt: zero key before freeing it Zap the memory before freeing it so we don't leave crypto information around in memory. Signed-off-by: Stefan Rompf Acked-by: Clemens Fruhwirth Acked-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-crypt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index cf66310..a601a42 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -690,6 +690,8 @@ bad3: bad2: crypto_free_tfm(tfm); bad1: + /* Must zero key material before freeing */ + memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8)); kfree(cc); return -EINVAL; } @@ -706,6 +708,9 @@ static void crypt_dtr(struct dm_target *ti) cc->iv_gen_ops->dtr(cc); crypto_free_tfm(cc->tfm); dm_put_device(ti, cc->dev); + + /* Must zero key material before freeing */ + memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8)); kfree(cc); } -- cgit v1.1 From ac81b2ee45eb811fdb0aa1cfb71d468d944d00ce Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Fri, 6 Jan 2006 00:20:11 -0800 Subject: [PATCH] make dm-mirror not issue invalid resync requests I've been attempting to set up a (Host)RAID mirror with dm_mirror on 2.6.14.3, and I've been having a strange little problem. The configuration in question is a set of 9GB SCSI disks that have 17942584 sectors. I set up the dm_mirror table as such: 0 17942528 mirror core 2 2048 nosync 2 8:48 0 8:64 0 If I'm not mistaken, this sets up a 9GB RAID1 mriror with 1MB stripes across both SCSI disks. The sector count of the dm device is less than the size of the disks, so we shouldn't fall off the end. However, I always get the messages like this in dmesg when I set up the dm table: attempt to access beyond end of device sdd: rw=0, want=17958656, limit=17942584 Clearly, something is trying to read sectors past the end of the drive. I traced it down to the __rh_recovery_prepare function in dm-raid1.c, which gets called when we're putting the mirror set together. This function calls the dirty region log's get_resync_work function to see if there's any resync that needs to be done, and queues up any areas that are out of sync. The log's get_resync_work function is actually a pointer to the core_get_resync_work function in dm-log.c. The core_get_resync_work function queries a bitset lc->sync_bits to find out if there are any regions that are out of date (i.e. the bit is 0), which is where the problem occurs. If every bit in lc->sync_bits is 1 (which is the case when we've just configured a new RAID1 with the nosync option), the find_next_zero_bit does NOT return the size parameter (lc->region_count in this case), it returns the size parameter rounded up to the nearest multiple of 32! I don't know if this is intentional, but i386 and x86_64 both exhibit this behavior. In any case, the statement "if (*region == lc->region_count)" looks like it's supposed to catch the case where are no regions to resync and return 0. Since find_next_zero_bit apparently has a habit of returning a value that's larger than lc->region_count, the enclosed patch changes the equality test to a greater-than test so that we don't try to resync areas outside of the RAID1 region. Seeing as the HostRAID metadata lives just past the end of the RAID1 data, mucking around in that area is not a good idea. I suppose another way to fix this would be to amend find_next_zero_bit so that it doesn't return values larger than "size", but I don't know if there's a reason for the current behavior. Signed-Off-By: Darrick J. Wong Acked-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index a76349c..efe4adf 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c @@ -573,7 +573,7 @@ static int core_get_resync_work(struct dirty_log *log, region_t *region) lc->sync_search); lc->sync_search = *region + 1; - if (*region == lc->region_count) + if (*region >= lc->region_count) return 0; } while (log_test_bit(lc->recovering_bits, *region)); -- cgit v1.1 From 17999be4aa408e7ff3b9d32c735649676567a3cd Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:12 -0800 Subject: [PATCH] md: improve raid1 "IO Barrier" concept raid1 needs to put up a barrier to new requests while it does resync or other background recovery. The code for this is currently open-coded, slighty obscure by its use of two waitqueues, and not documented. This patch gathers all the related code into 4 functions, and includes a comment which (hopefully) explains what is happening. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid1.c | 167 ++++++++++++++++++++++++--------------------- include/linux/raid/raid1.h | 4 +- 2 files changed, 91 insertions(+), 80 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 229d7b2..f520414 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -51,6 +51,8 @@ static mdk_personality_t raid1_personality; static void unplug_slaves(mddev_t *mddev); +static void allow_barrier(conf_t *conf); +static void lower_barrier(conf_t *conf); static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data) { @@ -160,20 +162,13 @@ static void put_all_bios(conf_t *conf, r1bio_t *r1_bio) static inline void free_r1bio(r1bio_t *r1_bio) { - unsigned long flags; - conf_t *conf = mddev_to_conf(r1_bio->mddev); /* * Wake up any possible resync thread that waits for the device * to go idle. */ - spin_lock_irqsave(&conf->resync_lock, flags); - if (!--conf->nr_pending) { - wake_up(&conf->wait_idle); - wake_up(&conf->wait_resume); - } - spin_unlock_irqrestore(&conf->resync_lock, flags); + allow_barrier(conf); put_all_bios(conf, r1_bio); mempool_free(r1_bio, conf->r1bio_pool); @@ -182,22 +177,10 @@ static inline void free_r1bio(r1bio_t *r1_bio) static inline void put_buf(r1bio_t *r1_bio) { conf_t *conf = mddev_to_conf(r1_bio->mddev); - unsigned long flags; mempool_free(r1_bio, conf->r1buf_pool); - spin_lock_irqsave(&conf->resync_lock, flags); - if (!conf->barrier) - BUG(); - --conf->barrier; - wake_up(&conf->wait_resume); - wake_up(&conf->wait_idle); - - if (!--conf->nr_pending) { - wake_up(&conf->wait_idle); - wake_up(&conf->wait_resume); - } - spin_unlock_irqrestore(&conf->resync_lock, flags); + lower_barrier(conf); } static void reschedule_retry(r1bio_t *r1_bio) @@ -210,6 +193,7 @@ static void reschedule_retry(r1bio_t *r1_bio) list_add(&r1_bio->retry_list, &conf->retry_list); spin_unlock_irqrestore(&conf->device_lock, flags); + wake_up(&conf->wait_barrier); md_wakeup_thread(mddev->thread); } @@ -593,30 +577,83 @@ static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk, return ret; } -/* - * Throttle resync depth, so that we can both get proper overlapping of - * requests, but are still able to handle normal requests quickly. +/* Barriers.... + * Sometimes we need to suspend IO while we do something else, + * either some resync/recovery, or reconfigure the array. + * To do this we raise a 'barrier'. + * The 'barrier' is a counter that can be raised multiple times + * to count how many activities are happening which preclude + * normal IO. + * We can only raise the barrier if there is no pending IO. + * i.e. if nr_pending == 0. + * We choose only to raise the barrier if no-one is waiting for the + * barrier to go down. This means that as soon as an IO request + * is ready, no other operations which require a barrier will start + * until the IO request has had a chance. + * + * So: regular IO calls 'wait_barrier'. When that returns there + * is no backgroup IO happening, It must arrange to call + * allow_barrier when it has finished its IO. + * backgroup IO calls must call raise_barrier. Once that returns + * there is no normal IO happeing. It must arrange to call + * lower_barrier when the particular background IO completes. */ #define RESYNC_DEPTH 32 -static void device_barrier(conf_t *conf, sector_t sect) +static void raise_barrier(conf_t *conf) { spin_lock_irq(&conf->resync_lock); - wait_event_lock_irq(conf->wait_idle, !waitqueue_active(&conf->wait_resume), - conf->resync_lock, raid1_unplug(conf->mddev->queue)); - - if (!conf->barrier++) { - wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, - conf->resync_lock, raid1_unplug(conf->mddev->queue)); - if (conf->nr_pending) - BUG(); + + /* Wait until no block IO is waiting */ + wait_event_lock_irq(conf->wait_barrier, !conf->nr_waiting, + conf->resync_lock, + raid1_unplug(conf->mddev->queue)); + + /* block any new IO from starting */ + conf->barrier++; + + /* No wait for all pending IO to complete */ + wait_event_lock_irq(conf->wait_barrier, + !conf->nr_pending && conf->barrier < RESYNC_DEPTH, + conf->resync_lock, + raid1_unplug(conf->mddev->queue)); + + spin_unlock_irq(&conf->resync_lock); +} + +static void lower_barrier(conf_t *conf) +{ + unsigned long flags; + spin_lock_irqsave(&conf->resync_lock, flags); + conf->barrier--; + spin_unlock_irqrestore(&conf->resync_lock, flags); + wake_up(&conf->wait_barrier); +} + +static void wait_barrier(conf_t *conf) +{ + spin_lock_irq(&conf->resync_lock); + if (conf->barrier) { + conf->nr_waiting++; + wait_event_lock_irq(conf->wait_barrier, !conf->barrier, + conf->resync_lock, + raid1_unplug(conf->mddev->queue)); + conf->nr_waiting--; } - wait_event_lock_irq(conf->wait_resume, conf->barrier < RESYNC_DEPTH, - conf->resync_lock, raid1_unplug(conf->mddev->queue)); - conf->next_resync = sect; + conf->nr_pending++; spin_unlock_irq(&conf->resync_lock); } +static void allow_barrier(conf_t *conf) +{ + unsigned long flags; + spin_lock_irqsave(&conf->resync_lock, flags); + conf->nr_pending--; + spin_unlock_irqrestore(&conf->resync_lock, flags); + wake_up(&conf->wait_barrier); +} + + /* duplicate the data pages for behind I/O */ static struct page **alloc_behind_pages(struct bio *bio) { @@ -678,10 +715,7 @@ static int make_request(request_queue_t *q, struct bio * bio) */ md_write_start(mddev, bio); /* wait on superblock update early */ - spin_lock_irq(&conf->resync_lock); - wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock, ); - conf->nr_pending++; - spin_unlock_irq(&conf->resync_lock); + wait_barrier(conf); disk_stat_inc(mddev->gendisk, ios[rw]); disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); @@ -909,13 +943,8 @@ static void print_conf(conf_t *conf) static void close_sync(conf_t *conf) { - spin_lock_irq(&conf->resync_lock); - wait_event_lock_irq(conf->wait_resume, !conf->barrier, - conf->resync_lock, raid1_unplug(conf->mddev->queue)); - spin_unlock_irq(&conf->resync_lock); - - if (conf->barrier) BUG(); - if (waitqueue_active(&conf->wait_idle)) BUG(); + wait_barrier(conf); + allow_barrier(conf); mempool_destroy(conf->r1buf_pool); conf->r1buf_pool = NULL; @@ -1317,12 +1346,16 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i return sync_blocks; } /* - * If there is non-resync activity waiting for us then - * put in a delay to throttle resync. + * If there is non-resync activity waiting for a turn, + * and resync is going fast enough, + * then let it though before starting on this new sync request. */ - if (!go_faster && waitqueue_active(&conf->wait_resume)) + if (!go_faster && conf->nr_waiting) msleep_interruptible(1000); - device_barrier(conf, sector_nr + RESYNC_SECTORS); + + raise_barrier(conf); + + conf->next_resync = sector_nr; /* * If reconstructing, and >1 working disc, @@ -1355,10 +1388,6 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO); - spin_lock_irq(&conf->resync_lock); - conf->nr_pending++; - spin_unlock_irq(&conf->resync_lock); - r1_bio->mddev = mddev; r1_bio->sector = sector_nr; r1_bio->state = 0; @@ -1542,8 +1571,7 @@ static int run(mddev_t *mddev) mddev->recovery_cp = MaxSector; spin_lock_init(&conf->resync_lock); - init_waitqueue_head(&conf->wait_idle); - init_waitqueue_head(&conf->wait_resume); + init_waitqueue_head(&conf->wait_barrier); bio_list_init(&conf->pending_bio_list); bio_list_init(&conf->flushing_bio_list); @@ -1714,11 +1742,7 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks) } memset(newmirrors, 0, sizeof(struct mirror_info)*raid_disks); - spin_lock_irq(&conf->resync_lock); - conf->barrier++; - wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, - conf->resync_lock, raid1_unplug(mddev->queue)); - spin_unlock_irq(&conf->resync_lock); + raise_barrier(conf); /* ok, everything is stopped */ oldpool = conf->r1bio_pool; @@ -1738,12 +1762,7 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks) conf->raid_disks = mddev->raid_disks = raid_disks; conf->last_used = 0; /* just make sure it is in-range */ - spin_lock_irq(&conf->resync_lock); - conf->barrier--; - spin_unlock_irq(&conf->resync_lock); - wake_up(&conf->wait_resume); - wake_up(&conf->wait_idle); - + lower_barrier(conf); set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); md_wakeup_thread(mddev->thread); @@ -1758,18 +1777,10 @@ static void raid1_quiesce(mddev_t *mddev, int state) switch(state) { case 1: - spin_lock_irq(&conf->resync_lock); - conf->barrier++; - wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, - conf->resync_lock, raid1_unplug(mddev->queue)); - spin_unlock_irq(&conf->resync_lock); + raise_barrier(conf); break; case 0: - spin_lock_irq(&conf->resync_lock); - conf->barrier--; - spin_unlock_irq(&conf->resync_lock); - wake_up(&conf->wait_resume); - wake_up(&conf->wait_idle); + lower_barrier(conf); break; } if (mddev->thread) { diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h index 292b98f..c556742 100644 --- a/include/linux/raid/raid1.h +++ b/include/linux/raid/raid1.h @@ -45,6 +45,7 @@ struct r1_private_data_s { spinlock_t resync_lock; int nr_pending; + int nr_waiting; int barrier; sector_t next_resync; int fullsync; /* set to 1 if a full sync is needed, @@ -52,8 +53,7 @@ struct r1_private_data_s { * Cleared when a sync completes. */ - wait_queue_head_t wait_idle; - wait_queue_head_t wait_resume; + wait_queue_head_t wait_barrier; struct pool_info *poolinfo; -- cgit v1.1 From 0a27ec96b6fb1abf867e36d7b0b681d67588767a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:13 -0800 Subject: [PATCH] md: improve raid10 "IO Barrier" concept raid10 needs to put up a barrier to new requests while it does resync or other background recovery. The code for this is currently open-coded, slighty obscure by its use of two waitqueues, and not documented. This patch gathers all the related code into 4 functions, and includes a comment which (hopefully) explains what is happening. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid10.c | 135 ++++++++++++++++++++++++++------------------ include/linux/raid/raid10.h | 4 +- 2 files changed, 81 insertions(+), 58 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 713dc9c..50bd7b1 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -47,6 +47,9 @@ static void unplug_slaves(mddev_t *mddev); +static void allow_barrier(conf_t *conf); +static void lower_barrier(conf_t *conf); + static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data) { conf_t *conf = data; @@ -175,20 +178,13 @@ static void put_all_bios(conf_t *conf, r10bio_t *r10_bio) static inline void free_r10bio(r10bio_t *r10_bio) { - unsigned long flags; - conf_t *conf = mddev_to_conf(r10_bio->mddev); /* * Wake up any possible resync thread that waits for the device * to go idle. */ - spin_lock_irqsave(&conf->resync_lock, flags); - if (!--conf->nr_pending) { - wake_up(&conf->wait_idle); - wake_up(&conf->wait_resume); - } - spin_unlock_irqrestore(&conf->resync_lock, flags); + allow_barrier(conf); put_all_bios(conf, r10_bio); mempool_free(r10_bio, conf->r10bio_pool); @@ -197,22 +193,10 @@ static inline void free_r10bio(r10bio_t *r10_bio) static inline void put_buf(r10bio_t *r10_bio) { conf_t *conf = mddev_to_conf(r10_bio->mddev); - unsigned long flags; mempool_free(r10_bio, conf->r10buf_pool); - spin_lock_irqsave(&conf->resync_lock, flags); - if (!conf->barrier) - BUG(); - --conf->barrier; - wake_up(&conf->wait_resume); - wake_up(&conf->wait_idle); - - if (!--conf->nr_pending) { - wake_up(&conf->wait_idle); - wake_up(&conf->wait_resume); - } - spin_unlock_irqrestore(&conf->resync_lock, flags); + lower_barrier(conf); } static void reschedule_retry(r10bio_t *r10_bio) @@ -640,30 +624,82 @@ static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk, return ret; } -/* - * Throttle resync depth, so that we can both get proper overlapping of - * requests, but are still able to handle normal requests quickly. +/* Barriers.... + * Sometimes we need to suspend IO while we do something else, + * either some resync/recovery, or reconfigure the array. + * To do this we raise a 'barrier'. + * The 'barrier' is a counter that can be raised multiple times + * to count how many activities are happening which preclude + * normal IO. + * We can only raise the barrier if there is no pending IO. + * i.e. if nr_pending == 0. + * We choose only to raise the barrier if no-one is waiting for the + * barrier to go down. This means that as soon as an IO request + * is ready, no other operations which require a barrier will start + * until the IO request has had a chance. + * + * So: regular IO calls 'wait_barrier'. When that returns there + * is no backgroup IO happening, It must arrange to call + * allow_barrier when it has finished its IO. + * backgroup IO calls must call raise_barrier. Once that returns + * there is no normal IO happeing. It must arrange to call + * lower_barrier when the particular background IO completes. */ #define RESYNC_DEPTH 32 -static void device_barrier(conf_t *conf, sector_t sect) +static void raise_barrier(conf_t *conf) { spin_lock_irq(&conf->resync_lock); - wait_event_lock_irq(conf->wait_idle, !waitqueue_active(&conf->wait_resume), - conf->resync_lock, unplug_slaves(conf->mddev)); - - if (!conf->barrier++) { - wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, - conf->resync_lock, unplug_slaves(conf->mddev)); - if (conf->nr_pending) - BUG(); + + /* Wait until no block IO is waiting */ + wait_event_lock_irq(conf->wait_barrier, !conf->nr_waiting, + conf->resync_lock, + raid10_unplug(conf->mddev->queue)); + + /* block any new IO from starting */ + conf->barrier++; + + /* No wait for all pending IO to complete */ + wait_event_lock_irq(conf->wait_barrier, + !conf->nr_pending && conf->barrier < RESYNC_DEPTH, + conf->resync_lock, + raid10_unplug(conf->mddev->queue)); + + spin_unlock_irq(&conf->resync_lock); +} + +static void lower_barrier(conf_t *conf) +{ + unsigned long flags; + spin_lock_irqsave(&conf->resync_lock, flags); + conf->barrier--; + spin_unlock_irqrestore(&conf->resync_lock, flags); + wake_up(&conf->wait_barrier); +} + +static void wait_barrier(conf_t *conf) +{ + spin_lock_irq(&conf->resync_lock); + if (conf->barrier) { + conf->nr_waiting++; + wait_event_lock_irq(conf->wait_barrier, !conf->barrier, + conf->resync_lock, + raid10_unplug(conf->mddev->queue)); + conf->nr_waiting--; } - wait_event_lock_irq(conf->wait_resume, conf->barrier < RESYNC_DEPTH, - conf->resync_lock, unplug_slaves(conf->mddev)); - conf->next_resync = sect; + conf->nr_pending++; spin_unlock_irq(&conf->resync_lock); } +static void allow_barrier(conf_t *conf) +{ + unsigned long flags; + spin_lock_irqsave(&conf->resync_lock, flags); + conf->nr_pending--; + spin_unlock_irqrestore(&conf->resync_lock, flags); + wake_up(&conf->wait_barrier); +} + static int make_request(request_queue_t *q, struct bio * bio) { mddev_t *mddev = q->queuedata; @@ -719,10 +755,7 @@ static int make_request(request_queue_t *q, struct bio * bio) * thread has put up a bar for new requests. * Continue immediately if no resync is active currently. */ - spin_lock_irq(&conf->resync_lock); - wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock, ); - conf->nr_pending++; - spin_unlock_irq(&conf->resync_lock); + wait_barrier(conf); disk_stat_inc(mddev->gendisk, ios[rw]); disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); @@ -897,13 +930,8 @@ static void print_conf(conf_t *conf) static void close_sync(conf_t *conf) { - spin_lock_irq(&conf->resync_lock); - wait_event_lock_irq(conf->wait_resume, !conf->barrier, - conf->resync_lock, unplug_slaves(conf->mddev)); - spin_unlock_irq(&conf->resync_lock); - - if (conf->barrier) BUG(); - if (waitqueue_active(&conf->wait_idle)) BUG(); + wait_barrier(conf); + allow_barrier(conf); mempool_destroy(conf->r10buf_pool); conf->r10buf_pool = NULL; @@ -1395,9 +1423,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i * If there is non-resync activity waiting for us then * put in a delay to throttle resync. */ - if (!go_faster && waitqueue_active(&conf->wait_resume)) + if (!go_faster && conf->nr_waiting) msleep_interruptible(1000); - device_barrier(conf, sector_nr + RESYNC_SECTORS); + raise_barrier(conf); + conf->next_resync = sector_nr; /* Again, very different code for resync and recovery. * Both must result in an r10bio with a list of bios that @@ -1427,7 +1456,6 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i r10_bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO); spin_lock_irq(&conf->resync_lock); - conf->nr_pending++; if (rb2) conf->barrier++; spin_unlock_irq(&conf->resync_lock); atomic_set(&r10_bio->remaining, 0); @@ -1500,10 +1528,6 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i int count = 0; r10_bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO); - spin_lock_irq(&conf->resync_lock); - conf->nr_pending++; - spin_unlock_irq(&conf->resync_lock); - r10_bio->mddev = mddev; atomic_set(&r10_bio->remaining, 0); @@ -1713,8 +1737,7 @@ static int run(mddev_t *mddev) INIT_LIST_HEAD(&conf->retry_list); spin_lock_init(&conf->resync_lock); - init_waitqueue_head(&conf->wait_idle); - init_waitqueue_head(&conf->wait_resume); + init_waitqueue_head(&conf->wait_barrier); /* need to check that every block has at least one working mirror */ if (!enough(conf)) { diff --git a/include/linux/raid/raid10.h b/include/linux/raid/raid10.h index 6070878..08317b7 100644 --- a/include/linux/raid/raid10.h +++ b/include/linux/raid/raid10.h @@ -39,11 +39,11 @@ struct r10_private_data_s { spinlock_t resync_lock; int nr_pending; + int nr_waiting; int barrier; sector_t next_resync; - wait_queue_head_t wait_idle; - wait_queue_head_t wait_resume; + wait_queue_head_t wait_barrier; mempool_t *r10bio_pool; mempool_t *r10buf_pool; -- cgit v1.1 From 14f8d26b8ea3413b28f2cac208c9a93600fe3a80 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:14 -0800 Subject: [PATCH] md: small cleanups for raid5 Resync code: A test that isn't needed, a 'compute_block' that makes more sense elsewhere (And then doesn't need a test), a couple of BUG_ONs to confirm the change makes sense. Printks: A few were missing KERN_* Also fix a typo in a comment.. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid5.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index fafc4bc..334ff7a 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -417,7 +417,7 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done, set_bit(R5_UPTODATE, &sh->dev[i].flags); #endif if (test_bit(R5_ReadError, &sh->dev[i].flags)) { - printk("R5: read error corrected!!\n"); + printk(KERN_INFO "raid5: read error corrected!!\n"); clear_bit(R5_ReadError, &sh->dev[i].flags); clear_bit(R5_ReWrite, &sh->dev[i].flags); } @@ -428,13 +428,14 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done, clear_bit(R5_UPTODATE, &sh->dev[i].flags); atomic_inc(&conf->disks[i].rdev->read_errors); if (conf->mddev->degraded) - printk("R5: read error not correctable.\n"); + printk(KERN_WARNING "raid5: read error not correctable.\n"); else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) /* Oh, no!!! */ - printk("R5: read error NOT corrected!!\n"); + printk(KERN_WARNING "raid5: read error NOT corrected!!\n"); else if (atomic_read(&conf->disks[i].rdev->read_errors) > conf->max_nr_stripes) - printk("raid5: Too many read errors, failing device.\n"); + printk(KERN_WARNING + "raid5: Too many read errors, failing device.\n"); else retry = 1; if (retry) @@ -604,7 +605,7 @@ static sector_t raid5_compute_sector(sector_t r_sector, unsigned int raid_disks, *dd_idx = (*pd_idx + 1 + *dd_idx) % raid_disks; break; default: - printk("raid5: unsupported algorithm %d\n", + printk(KERN_ERR "raid5: unsupported algorithm %d\n", conf->algorithm); } @@ -645,7 +646,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i) i -= (sh->pd_idx + 1); break; default: - printk("raid5: unsupported algorithm %d\n", + printk(KERN_ERR "raid5: unsupported algorithm %d\n", conf->algorithm); } @@ -654,7 +655,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i) check = raid5_compute_sector (r_sector, raid_disks, data_disks, &dummy1, &dummy2, conf); if (check != sh->sector || dummy1 != dd_idx || dummy2 != sh->pd_idx) { - printk("compute_blocknr: map not correct\n"); + printk(KERN_ERR "compute_blocknr: map not correct\n"); return 0; } return r_sector; @@ -737,7 +738,7 @@ static void compute_block(struct stripe_head *sh, int dd_idx) if (test_bit(R5_UPTODATE, &sh->dev[i].flags)) ptr[count++] = p; else - printk("compute_block() %d, stripe %llu, %d" + printk(KERN_ERR "compute_block() %d, stripe %llu, %d" " not present\n", dd_idx, (unsigned long long)sh->sector, i); @@ -1005,7 +1006,7 @@ static void handle_stripe(struct stripe_head *sh) if (dev->written) written++; rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ if (!rdev || !test_bit(In_sync, &rdev->flags)) { - /* The ReadError flag wil just be confusing now */ + /* The ReadError flag will just be confusing now */ clear_bit(R5_ReadError, &dev->flags); clear_bit(R5_ReWrite, &dev->flags); } @@ -1288,7 +1289,7 @@ static void handle_stripe(struct stripe_head *sh) * is available */ if (syncing && locked == 0 && - !test_bit(STRIPE_INSYNC, &sh->state) && failed <= 1) { + !test_bit(STRIPE_INSYNC, &sh->state)) { set_bit(STRIPE_HANDLE, &sh->state); if (failed == 0) { char *pagea; @@ -1306,21 +1307,20 @@ static void handle_stripe(struct stripe_head *sh) if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) /* don't try to repair!! */ set_bit(STRIPE_INSYNC, &sh->state); + else { + compute_block(sh, sh->pd_idx); + uptodate++; + } } } if (!test_bit(STRIPE_INSYNC, &sh->state)) { + /* either failed parity check, or recovery is happening */ if (failed==0) failed_num = sh->pd_idx; - /* should be able to compute the missing block and write it to spare */ - if (!test_bit(R5_UPTODATE, &sh->dev[failed_num].flags)) { - if (uptodate+1 != disks) - BUG(); - compute_block(sh, failed_num); - uptodate++; - } - if (uptodate != disks) - BUG(); dev = &sh->dev[failed_num]; + BUG_ON(!test_bit(R5_UPTODATE, &dev->flags)); + BUG_ON(uptodate != disks); + set_bit(R5_LOCKED, &dev->flags); set_bit(R5_Wantwrite, &dev->flags); clear_bit(STRIPE_DEGRADED, &sh->state); @@ -1822,7 +1822,8 @@ static int run(mddev_t *mddev) struct list_head *tmp; if (mddev->level != 5 && mddev->level != 4) { - printk("raid5: %s: raid level not set to 4/5 (%d)\n", mdname(mddev), mddev->level); + printk(KERN_ERR "raid5: %s: raid level not set to 4/5 (%d)\n", + mdname(mddev), mddev->level); return -EIO; } -- cgit v1.1 From 6ff8d8ec06690f4011a6c3ad9e0759b9094f0601 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:15 -0800 Subject: [PATCH] md: allow dirty raid[456] arrays to be started at boot See patch to md.txt for more details Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 24 ++++++++++++++++++++++++ drivers/md/md.c | 4 ++++ drivers/md/raid5.c | 15 +++++++++++---- drivers/md/raid6main.c | 13 +++++++++---- include/linux/raid/md_k.h | 1 + 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/Documentation/md.txt b/Documentation/md.txt index 23e6cce..1dd0fb6 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -51,6 +51,30 @@ superblock can be autodetected and run at boot time. The kernel parameter "raid=partitionable" (or "raid=part") means that all auto-detected arrays are assembled as partitionable. +Boot time assembly of degraded/dirty arrays +------------------------------------------- + +If a raid5 or raid6 array is both dirty and degraded, it could have +undetectable data corruption. This is because the fact that it is +'dirty' means that the parity cannot be trusted, and the fact that it +is degraded means that some datablocks are missing and cannot reliably +be reconstructed (due to no parity). + +For this reason, md will normally refuse to start such an array. This +requires the sysadmin to take action to explicitly start the array +desipite possible corruption. This is normally done with + mdadm --assemble --force .... + +This option is not really available if the array has the root +filesystem on it. In order to support this booting from such an +array, md supports a module parameter "start_dirty_degraded" which, +when set to 1, bypassed the checks and will allows dirty degraded +arrays to be started. + +So, to boot with a root filesystem of a dirty degraded raid[56], use + + md-mod.start_dirty_degraded=1 + Superblock formats ------------------ diff --git a/drivers/md/md.c b/drivers/md/md.c index 8175a2a..b4fb724 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1937,6 +1937,7 @@ static void md_safemode_timeout(unsigned long data) md_wakeup_thread(mddev->thread); } +static int start_dirty_degraded; static int do_md_run(mddev_t * mddev) { @@ -2048,6 +2049,7 @@ static int do_md_run(mddev_t * mddev) mddev->recovery = 0; mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ mddev->barriers_work = 1; + mddev->ok_start_degraded = start_dirty_degraded; if (start_readonly) mddev->ro = 2; /* read-only, but switch on first write */ @@ -4509,6 +4511,8 @@ static int set_ro(const char *val, struct kernel_param *kp) } module_param_call(start_ro, set_ro, get_ro, NULL, 0600); +module_param(start_dirty_degraded, int, 0644); + EXPORT_SYMBOL(register_md_personality); EXPORT_SYMBOL(unregister_md_personality); diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 334ff7a..53a0f2c 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -1904,10 +1904,17 @@ static int run(mddev_t *mddev) if (mddev->degraded == 1 && mddev->recovery_cp != MaxSector) { - printk(KERN_ERR - "raid5: cannot start dirty degraded array for %s\n", - mdname(mddev)); - goto abort; + if (mddev->ok_start_degraded) + printk(KERN_WARNING + "raid5: starting dirty degraded array: %s" + "- data corruption possible.\n", + mdname(mddev)); + else { + printk(KERN_ERR + "raid5: cannot start dirty degraded array for %s\n", + mdname(mddev)); + goto abort; + } } { diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 0000d16..9ac6dcd 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -1929,13 +1929,18 @@ static int run(mddev_t *mddev) goto abort; } -#if 0 /* FIX: For now */ if (mddev->degraded > 0 && mddev->recovery_cp != MaxSector) { - printk(KERN_ERR "raid6: cannot start dirty degraded array for %s\n", mdname(mddev)); - goto abort; + if (mddev->ok_start_degraded) + printk(KERN_WARNING "raid6: starting dirty degraded array:%s" + "- data corruption possible.\n", + mdname(mddev)); + else { + printk(KERN_ERR "raid6: cannot start dirty degraded array" + " for %s\n", mdname(mddev)); + goto abort; + } } -#endif { mddev->thread = md_register_thread(raid6d, mddev, "%s_raid6"); diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 46629a2..1dd587b5 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -183,6 +183,7 @@ struct mddev_s sector_t resync_mismatches; /* count of sectors where * parity/replica mismatch found */ + int ok_start_degraded; /* recovery/resync flags * NEEDED: we might need to start a resync/recover * RUNNING: a thread is running, or about to be started -- cgit v1.1 From b15c2e57f0f5bf596a19e9c5571e5b07cdfc7363 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:16 -0800 Subject: [PATCH] md: move bitmap_create to after md array has been initialised This is important because bitmap_create uses mddev->resync_max_sectors and that doesn't have a valid value until after the array has been initialised (with pers->run()). [It doesn't make a difference for current personalities that support bitmaps, but will make a difference for raid10] This has the added advantage of meaning with can move the thread->timeout manipulation inside the bitmap.c code instead of sprinkling identical code throughout all personalities. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/bitmap.c | 4 ++++ drivers/md/md.c | 16 +++++++++------- drivers/md/raid1.c | 8 -------- drivers/md/raid5.c | 11 +---------- drivers/md/raid6main.c | 11 +---------- 5 files changed, 15 insertions(+), 35 deletions(-) diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 252d55d..b65c36d 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -1530,6 +1530,8 @@ void bitmap_destroy(mddev_t *mddev) return; mddev->bitmap = NULL; /* disconnect from the md device */ + if (mddev->thread) + mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; bitmap_free(bitmap); } @@ -1636,6 +1638,8 @@ int bitmap_create(mddev_t *mddev) if (IS_ERR(bitmap->writeback_daemon)) return PTR_ERR(bitmap->writeback_daemon); + mddev->thread->timeout = bitmap->daemon_sleep * HZ; + return bitmap_update_sb(bitmap); error: diff --git a/drivers/md/md.c b/drivers/md/md.c index b4fb724..ee199d4 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -2054,13 +2054,15 @@ static int do_md_run(mddev_t * mddev) if (start_readonly) mddev->ro = 2; /* read-only, but switch on first write */ - /* before we start the array running, initialise the bitmap */ - err = bitmap_create(mddev); - if (err) - printk(KERN_ERR "%s: failed to create bitmap (%d)\n", - mdname(mddev), err); - else - err = mddev->pers->run(mddev); + err = mddev->pers->run(mddev); + if (!err && mddev->pers->sync_request) { + err = bitmap_create(mddev); + if (err) { + printk(KERN_ERR "%s: failed to create bitmap (%d)\n", + mdname(mddev), err); + mddev->pers->stop(mddev); + } + } if (err) { printk(KERN_ERR "md: pers->run() failed ...\n"); module_put(mddev->pers->owner); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index f520414..c618015 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1611,7 +1611,6 @@ static int run(mddev_t *mddev) mdname(mddev)); goto out_free_conf; } - if (mddev->bitmap) mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; printk(KERN_INFO "raid1: raid set %s active with %d out of %d mirrors\n", @@ -1783,13 +1782,6 @@ static void raid1_quiesce(mddev_t *mddev, int state) lower_barrier(conf); break; } - if (mddev->thread) { - if (mddev->bitmap) - mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; - else - mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; - md_wakeup_thread(mddev->thread); - } } diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 53a0f2c..0d016a8 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -1964,9 +1964,6 @@ static int run(mddev_t *mddev) /* Ok, everything is just fine now */ sysfs_create_group(&mddev->kobj, &raid5_attrs_group); - if (mddev->bitmap) - mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; - mddev->queue->unplug_fn = raid5_unplug_device; mddev->queue->issue_flush_fn = raid5_issue_flush; @@ -2200,14 +2197,8 @@ static void raid5_quiesce(mddev_t *mddev, int state) spin_unlock_irq(&conf->device_lock); break; } - if (mddev->thread) { - if (mddev->bitmap) - mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; - else - mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; - md_wakeup_thread(mddev->thread); - } } + static mdk_personality_t raid5_personality= { .name = "raid5", diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 9ac6dcd..304455d 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -1990,9 +1990,6 @@ static int run(mddev_t *mddev) /* Ok, everything is just fine now */ mddev->array_size = mddev->size * (mddev->raid_disks - 2); - if (mddev->bitmap) - mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; - mddev->queue->unplug_fn = raid6_unplug_device; mddev->queue->issue_flush_fn = raid6_issue_flush; return 0; @@ -2228,14 +2225,8 @@ static void raid6_quiesce(mddev_t *mddev, int state) spin_unlock_irq(&conf->device_lock); break; } - if (mddev->thread) { - if (mddev->bitmap) - mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; - else - mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; - md_wakeup_thread(mddev->thread); - } } + static mdk_personality_t raid6_personality= { .name = "raid6", -- cgit v1.1 From 6cce3b23f6f8e974c00af7a9b88f1d413ba368a8 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:16 -0800 Subject: [PATCH] md: write intent bitmap support for raid10 Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 10 ++- drivers/md/raid10.c | 178 ++++++++++++++++++++++++++++++++++++++------ include/linux/raid/raid10.h | 9 ++- 3 files changed, 171 insertions(+), 26 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index ee199d4..64e7da3 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -714,9 +714,10 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) if (sb->state & (1<bitmap_file == NULL) { - if (mddev->level != 1 && mddev->level != 5 && mddev->level != 6) { + if (mddev->level != 1 && mddev->level != 5 && mddev->level != 6 + && mddev->level != 10) { /* FIXME use a better test */ - printk(KERN_WARNING "md: bitmaps only support for raid1\n"); + printk(KERN_WARNING "md: bitmaps not supported for this level.\n"); return -EINVAL; } mddev->bitmap_offset = mddev->default_bitmap_offset; @@ -1037,8 +1038,9 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) && mddev->bitmap_file == NULL ) { - if (mddev->level != 1) { - printk(KERN_WARNING "md: bitmaps only supported for raid1\n"); + if (mddev->level != 1 && mddev->level != 5 && mddev->level != 6 + && mddev->level != 10) { + printk(KERN_WARNING "md: bitmaps not supported for this level.\n"); return -EINVAL; } mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset); diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 50bd7b1..8f58a44 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -18,7 +18,9 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "dm-bio-list.h" #include +#include /* * RAID10 provides a combination of RAID0 and RAID1 functionality. @@ -306,9 +308,11 @@ static int raid10_end_write_request(struct bio *bio, unsigned int bytes_done, in /* * this branch is our 'one mirror IO has finished' event handler: */ - if (!uptodate) + if (!uptodate) { md_error(r10_bio->mddev, conf->mirrors[dev].rdev); - else + /* an I/O failed, we can't clear the bitmap */ + set_bit(R10BIO_Degraded, &r10_bio->state); + } else /* * Set R10BIO_Uptodate in our master bio, so that * we will return a good error code for to the higher @@ -328,6 +332,11 @@ static int raid10_end_write_request(struct bio *bio, unsigned int bytes_done, in * already. */ if (atomic_dec_and_test(&r10_bio->remaining)) { + /* clear the bitmap if all writes complete successfully */ + bitmap_endwrite(r10_bio->mddev->bitmap, r10_bio->sector, + r10_bio->sectors, + !test_bit(R10BIO_Degraded, &r10_bio->state), + 0); md_write_end(r10_bio->mddev); raid_end_bio_io(r10_bio); } @@ -486,8 +495,9 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio) rcu_read_lock(); /* * Check if we can balance. We can balance on the whole - * device if no resync is going on, or below the resync window. - * We take the first readable disk when above the resync window. + * device if no resync is going on (recovery is ok), or below + * the resync window. We take the first readable disk when + * above the resync window. */ if (conf->mddev->recovery_cp < MaxSector && (this_sector + sectors >= conf->next_resync)) { @@ -591,7 +601,10 @@ static void unplug_slaves(mddev_t *mddev) static void raid10_unplug(request_queue_t *q) { + mddev_t *mddev = q->queuedata; + unplug_slaves(q->queuedata); + md_wakeup_thread(mddev->thread); } static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk, @@ -647,12 +660,13 @@ static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk, */ #define RESYNC_DEPTH 32 -static void raise_barrier(conf_t *conf) +static void raise_barrier(conf_t *conf, int force) { + BUG_ON(force && !conf->barrier); spin_lock_irq(&conf->resync_lock); - /* Wait until no block IO is waiting */ - wait_event_lock_irq(conf->wait_barrier, !conf->nr_waiting, + /* Wait until no block IO is waiting (unless 'force') */ + wait_event_lock_irq(conf->wait_barrier, force || !conf->nr_waiting, conf->resync_lock, raid10_unplug(conf->mddev->queue)); @@ -710,6 +724,8 @@ static int make_request(request_queue_t *q, struct bio * bio) int i; int chunk_sects = conf->chunk_mask + 1; const int rw = bio_data_dir(bio); + struct bio_list bl; + unsigned long flags; if (unlikely(bio_barrier(bio))) { bio_endio(bio, bio->bi_size, -EOPNOTSUPP); @@ -767,6 +783,7 @@ static int make_request(request_queue_t *q, struct bio * bio) r10_bio->mddev = mddev; r10_bio->sector = bio->bi_sector; + r10_bio->state = 0; if (rw == READ) { /* @@ -811,13 +828,16 @@ static int make_request(request_queue_t *q, struct bio * bio) !test_bit(Faulty, &rdev->flags)) { atomic_inc(&rdev->nr_pending); r10_bio->devs[i].bio = bio; - } else + } else { r10_bio->devs[i].bio = NULL; + set_bit(R10BIO_Degraded, &r10_bio->state); + } } rcu_read_unlock(); - atomic_set(&r10_bio->remaining, 1); + atomic_set(&r10_bio->remaining, 0); + bio_list_init(&bl); for (i = 0; i < conf->copies; i++) { struct bio *mbio; int d = r10_bio->devs[i].devnum; @@ -835,13 +855,14 @@ static int make_request(request_queue_t *q, struct bio * bio) mbio->bi_private = r10_bio; atomic_inc(&r10_bio->remaining); - generic_make_request(mbio); + bio_list_add(&bl, mbio); } - if (atomic_dec_and_test(&r10_bio->remaining)) { - md_write_end(mddev); - raid_end_bio_io(r10_bio); - } + bitmap_startwrite(mddev->bitmap, bio->bi_sector, r10_bio->sectors, 0); + spin_lock_irqsave(&conf->device_lock, flags); + bio_list_merge(&conf->pending_bio_list, &bl); + blk_plug_device(mddev->queue); + spin_unlock_irqrestore(&conf->device_lock, flags); return 0; } @@ -999,7 +1020,12 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) if (!enough(conf)) return 0; - for (mirror=0; mirror < mddev->raid_disks; mirror++) + if (rdev->saved_raid_disk >= 0 && + conf->mirrors[rdev->saved_raid_disk].rdev == NULL) + mirror = rdev->saved_raid_disk; + else + mirror = 0; + for ( ; mirror < mddev->raid_disks; mirror++) if ( !(p=conf->mirrors+mirror)->rdev) { blk_queue_stack_limits(mddev->queue, @@ -1015,6 +1041,8 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev) p->head_position = 0; rdev->raid_disk = mirror; found = 1; + if (rdev->saved_raid_disk != mirror) + conf->fullsync = 1; rcu_assign_pointer(p->rdev, rdev); break; } @@ -1282,6 +1310,26 @@ static void raid10d(mddev_t *mddev) for (;;) { char b[BDEVNAME_SIZE]; spin_lock_irqsave(&conf->device_lock, flags); + + if (conf->pending_bio_list.head) { + bio = bio_list_get(&conf->pending_bio_list); + blk_remove_plug(mddev->queue); + spin_unlock_irqrestore(&conf->device_lock, flags); + /* flush any pending bitmap writes to disk before proceeding w/ I/O */ + if (bitmap_unplug(mddev->bitmap) != 0) + printk("%s: bitmap file write failed!\n", mdname(mddev)); + + while (bio) { /* submit pending writes */ + struct bio *next = bio->bi_next; + bio->bi_next = NULL; + generic_make_request(bio); + bio = next; + } + unplug = 1; + + continue; + } + if (list_empty(head)) break; r10_bio = list_entry(head->prev, r10bio_t, retry_list); @@ -1388,6 +1436,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i sector_t max_sector, nr_sectors; int disk; int i; + int max_sync; + int sync_blocks; sector_t sectors_skipped = 0; int chunks_skipped = 0; @@ -1401,6 +1451,29 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) max_sector = mddev->resync_max_sectors; if (sector_nr >= max_sector) { + /* If we aborted, we need to abort the + * sync on the 'current' bitmap chucks (there can + * be several when recovering multiple devices). + * as we may have started syncing it but not finished. + * We can find the current address in + * mddev->curr_resync, but for recovery, + * we need to convert that to several + * virtual addresses. + */ + if (mddev->curr_resync < max_sector) { /* aborted */ + if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) + bitmap_end_sync(mddev->bitmap, mddev->curr_resync, + &sync_blocks, 1); + else for (i=0; iraid_disks; i++) { + sector_t sect = + raid10_find_virt(conf, mddev->curr_resync, i); + bitmap_end_sync(mddev->bitmap, sect, + &sync_blocks, 1); + } + } else /* completed sync */ + conf->fullsync = 0; + + bitmap_close_sync(mddev->bitmap); close_sync(conf); *skipped = 1; return sectors_skipped; @@ -1425,8 +1498,6 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i */ if (!go_faster && conf->nr_waiting) msleep_interruptible(1000); - raise_barrier(conf); - conf->next_resync = sector_nr; /* Again, very different code for resync and recovery. * Both must result in an r10bio with a list of bios that @@ -1443,6 +1514,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i * end_sync_write if we will want to write. */ + max_sync = RESYNC_PAGES << (PAGE_SHIFT-9); if (!test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { /* recovery... the complicated one */ int i, j, k; @@ -1451,13 +1523,29 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i for (i=0 ; iraid_disks; i++) if (conf->mirrors[i].rdev && !test_bit(In_sync, &conf->mirrors[i].rdev->flags)) { + int still_degraded = 0; /* want to reconstruct this device */ r10bio_t *rb2 = r10_bio; + sector_t sect = raid10_find_virt(conf, sector_nr, i); + int must_sync; + /* Unless we are doing a full sync, we only need + * to recover the block if it is set in the bitmap + */ + must_sync = bitmap_start_sync(mddev->bitmap, sect, + &sync_blocks, 1); + if (sync_blocks < max_sync) + max_sync = sync_blocks; + if (!must_sync && + !conf->fullsync) { + /* yep, skip the sync_blocks here, but don't assume + * that there will never be anything to do here + */ + chunks_skipped = -1; + continue; + } r10_bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO); - spin_lock_irq(&conf->resync_lock); - if (rb2) conf->barrier++; - spin_unlock_irq(&conf->resync_lock); + raise_barrier(conf, rb2 != NULL); atomic_set(&r10_bio->remaining, 0); r10_bio->master_bio = (struct bio*)rb2; @@ -1465,8 +1553,21 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i atomic_inc(&rb2->remaining); r10_bio->mddev = mddev; set_bit(R10BIO_IsRecover, &r10_bio->state); - r10_bio->sector = raid10_find_virt(conf, sector_nr, i); + r10_bio->sector = sect; + raid10_find_phys(conf, r10_bio); + /* Need to check if this section will still be + * degraded + */ + for (j=0; jcopies;j++) { + int d = r10_bio->devs[j].devnum; + if (conf->mirrors[d].rdev == NULL || + test_bit(Faulty, &conf->mirrors[d].rdev->flags)) + still_degraded = 1; + } + must_sync = bitmap_start_sync(mddev->bitmap, sect, + &sync_blocks, still_degraded); + for (j=0; jcopies;j++) { int d = r10_bio->devs[j].devnum; if (conf->mirrors[d].rdev && @@ -1526,10 +1627,22 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i } else { /* resync. Schedule a read for every block at this virt offset */ int count = 0; + + if (!bitmap_start_sync(mddev->bitmap, sector_nr, + &sync_blocks, mddev->degraded) && + !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { + /* We can skip this block */ + *skipped = 1; + return sync_blocks + sectors_skipped; + } + if (sync_blocks < max_sync) + max_sync = sync_blocks; r10_bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO); r10_bio->mddev = mddev; atomic_set(&r10_bio->remaining, 0); + raise_barrier(conf, 0); + conf->next_resync = sector_nr; r10_bio->master_bio = NULL; r10_bio->sector = sector_nr; @@ -1582,6 +1695,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i } nr_sectors = 0; + if (sector_nr + max_sync < max_sector) + max_sector = sector_nr + max_sync; do { struct page *page; int len = PAGE_SIZE; @@ -1821,6 +1936,26 @@ static int stop(mddev_t *mddev) return 0; } +static void raid10_quiesce(mddev_t *mddev, int state) +{ + conf_t *conf = mddev_to_conf(mddev); + + switch(state) { + case 1: + raise_barrier(conf, 0); + break; + case 0: + lower_barrier(conf); + break; + } + if (mddev->thread) { + if (mddev->bitmap) + mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ; + else + mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT; + md_wakeup_thread(mddev->thread); + } +} static mdk_personality_t raid10_personality = { @@ -1835,6 +1970,7 @@ static mdk_personality_t raid10_personality = .hot_remove_disk= raid10_remove_disk, .spare_active = raid10_spare_active, .sync_request = sync_request, + .quiesce = raid10_quiesce, }; static int __init raid_init(void) diff --git a/include/linux/raid/raid10.h b/include/linux/raid/raid10.h index 08317b7..b660cbf 100644 --- a/include/linux/raid/raid10.h +++ b/include/linux/raid/raid10.h @@ -35,13 +35,19 @@ struct r10_private_data_s { sector_t chunk_mask; struct list_head retry_list; - /* for use when syncing mirrors: */ + /* queue pending writes and submit them on unplug */ + struct bio_list pending_bio_list; + spinlock_t resync_lock; int nr_pending; int nr_waiting; int barrier; sector_t next_resync; + int fullsync; /* set to 1 if a full sync is needed, + * (fresh device added). + * Cleared when a sync completes. + */ wait_queue_head_t wait_barrier; @@ -100,4 +106,5 @@ struct r10bio_s { #define R10BIO_Uptodate 0 #define R10BIO_IsSync 1 #define R10BIO_IsRecover 2 +#define R10BIO_Degraded 3 #endif -- cgit v1.1 From ca65b73bd9c301d243df93780f7b26579e6c9204 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:17 -0800 Subject: [PATCH] md: fix raid6 resync check/repair code raid6 currently does not check the P/Q syndromes when doing a resync, it just calculates the correct value and writes it. Doing the check can reduce writes (often to 0) for a resync, and it is needed to properly implement the echo check > sync_action operation. This patch implements the appropriate checks and tidies up some related code. It also allows raid6 user-requested resync to bypass the intent bitmap. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid6main.c | 182 ++++++++++++++++++++++++++------------------- include/linux/raid/raid5.h | 2 + 2 files changed, 108 insertions(+), 76 deletions(-) diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 304455d..52e8796 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -805,7 +805,7 @@ static void compute_parity(struct stripe_head *sh, int method) } /* Compute one missing block */ -static void compute_block_1(struct stripe_head *sh, int dd_idx) +static void compute_block_1(struct stripe_head *sh, int dd_idx, int nozero) { raid6_conf_t *conf = sh->raid_conf; int i, count, disks = conf->raid_disks; @@ -821,7 +821,7 @@ static void compute_block_1(struct stripe_head *sh, int dd_idx) compute_parity(sh, UPDATE_PARITY); } else { ptr[0] = page_address(sh->dev[dd_idx].page); - memset(ptr[0], 0, STRIPE_SIZE); + if (!nozero) memset(ptr[0], 0, STRIPE_SIZE); count = 1; for (i = disks ; i--; ) { if (i == dd_idx || i == qd_idx) @@ -838,7 +838,8 @@ static void compute_block_1(struct stripe_head *sh, int dd_idx) } if (count != 1) xor_block(count, STRIPE_SIZE, ptr); - set_bit(R5_UPTODATE, &sh->dev[dd_idx].flags); + if (!nozero) set_bit(R5_UPTODATE, &sh->dev[dd_idx].flags); + else clear_bit(R5_UPTODATE, &sh->dev[dd_idx].flags); } } @@ -871,7 +872,7 @@ static void compute_block_2(struct stripe_head *sh, int dd_idx1, int dd_idx2) return; } else { /* We're missing D+Q; recompute D from P */ - compute_block_1(sh, (dd_idx1 == qd_idx) ? dd_idx2 : dd_idx1); + compute_block_1(sh, (dd_idx1 == qd_idx) ? dd_idx2 : dd_idx1, 0); compute_parity(sh, UPDATE_PARITY); /* Is this necessary? */ return; } @@ -982,6 +983,12 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in } +static int page_is_zero(struct page *p) +{ + char *a = page_address(p); + return ((*(u32*)a) == 0 && + memcmp(a, a+4, STRIPE_SIZE-4)==0); +} /* * handle_stripe - do things to a stripe. * @@ -1000,7 +1007,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in * */ -static void handle_stripe(struct stripe_head *sh) +static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) { raid6_conf_t *conf = sh->raid_conf; int disks = conf->raid_disks; @@ -1228,7 +1235,7 @@ static void handle_stripe(struct stripe_head *sh) if (uptodate == disks-1) { PRINTK("Computing stripe %llu block %d\n", (unsigned long long)sh->sector, i); - compute_block_1(sh, i); + compute_block_1(sh, i, 0); uptodate++; } else if ( uptodate == disks-2 && failed >= 2 ) { /* Computing 2-failure is *very* expensive; only do it if failed >= 2 */ @@ -1323,7 +1330,7 @@ static void handle_stripe(struct stripe_head *sh) /* We have failed blocks and need to compute them */ switch ( failed ) { case 0: BUG(); - case 1: compute_block_1(sh, failed_num[0]); break; + case 1: compute_block_1(sh, failed_num[0], 0); break; case 2: compute_block_2(sh, failed_num[0], failed_num[1]); break; default: BUG(); /* This request should have been failed? */ } @@ -1338,12 +1345,10 @@ static void handle_stripe(struct stripe_head *sh) (unsigned long long)sh->sector, i); locked++; set_bit(R5_Wantwrite, &sh->dev[i].flags); -#if 0 /**** FIX: I don't understand the logic here... ****/ - if (!test_bit(R5_Insync, &sh->dev[i].flags) - || ((i==pd_idx || i==qd_idx) && failed == 0)) /* FIX? */ - set_bit(STRIPE_INSYNC, &sh->state); -#endif } + /* after a RECONSTRUCT_WRITE, the stripe MUST be in-sync */ + set_bit(STRIPE_INSYNC, &sh->state); + if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) { atomic_dec(&conf->preread_active_stripes); if (atomic_read(&conf->preread_active_stripes) < IO_THRESHOLD) @@ -1356,79 +1361,97 @@ static void handle_stripe(struct stripe_head *sh) * Any reads will already have been scheduled, so we just see if enough data * is available */ - if (syncing && locked == 0 && - !test_bit(STRIPE_INSYNC, &sh->state) && failed <= 2) { - set_bit(STRIPE_HANDLE, &sh->state); -#if 0 /* RAID-6: Don't support CHECK PARITY yet */ - if (failed == 0) { - char *pagea; - if (uptodate != disks) - BUG(); - compute_parity(sh, CHECK_PARITY); - uptodate--; - pagea = page_address(sh->dev[pd_idx].page); - if ((*(u32*)pagea) == 0 && - !memcmp(pagea, pagea+4, STRIPE_SIZE-4)) { - /* parity is correct (on disc, not in buffer any more) */ - set_bit(STRIPE_INSYNC, &sh->state); - } - } -#endif - if (!test_bit(STRIPE_INSYNC, &sh->state)) { - int failed_needupdate[2]; - struct r5dev *adev, *bdev; - - if ( failed < 1 ) - failed_num[0] = pd_idx; - if ( failed < 2 ) - failed_num[1] = (failed_num[0] == qd_idx) ? pd_idx : qd_idx; + if (syncing && locked == 0 && !test_bit(STRIPE_INSYNC, &sh->state)) { + int update_p = 0, update_q = 0; + struct r5dev *dev; - failed_needupdate[0] = !test_bit(R5_UPTODATE, &sh->dev[failed_num[0]].flags); - failed_needupdate[1] = !test_bit(R5_UPTODATE, &sh->dev[failed_num[1]].flags); + set_bit(STRIPE_HANDLE, &sh->state); - PRINTK("sync: failed=%d num=%d,%d fnu=%u%u\n", - failed, failed_num[0], failed_num[1], failed_needupdate[0], failed_needupdate[1]); + BUG_ON(failed>2); + BUG_ON(uptodate < disks); + /* Want to check and possibly repair P and Q. + * However there could be one 'failed' device, in which + * case we can only check one of them, possibly using the + * other to generate missing data + */ -#if 0 /* RAID-6: This code seems to require that CHECK_PARITY destroys the uptodateness of the parity */ - /* should be able to compute the missing block(s) and write to spare */ - if ( failed_needupdate[0] ^ failed_needupdate[1] ) { - if (uptodate+1 != disks) - BUG(); - compute_block_1(sh, failed_needupdate[0] ? failed_num[0] : failed_num[1]); - uptodate++; - } else if ( failed_needupdate[0] & failed_needupdate[1] ) { - if (uptodate+2 != disks) - BUG(); - compute_block_2(sh, failed_num[0], failed_num[1]); - uptodate += 2; + /* If !tmp_page, we cannot do the calculations, + * but as we have set STRIPE_HANDLE, we will soon be called + * by stripe_handle with a tmp_page - just wait until then. + */ + if (tmp_page) { + if (failed == q_failed) { + /* The only possible failed device holds 'Q', so it makes + * sense to check P (If anything else were failed, we would + * have used P to recreate it). + */ + compute_block_1(sh, pd_idx, 1); + if (!page_is_zero(sh->dev[pd_idx].page)) { + compute_block_1(sh,pd_idx,0); + update_p = 1; + } + } + if (!q_failed && failed < 2) { + /* q is not failed, and we didn't use it to generate + * anything, so it makes sense to check it + */ + memcpy(page_address(tmp_page), + page_address(sh->dev[qd_idx].page), + STRIPE_SIZE); + compute_parity(sh, UPDATE_PARITY); + if (memcmp(page_address(tmp_page), + page_address(sh->dev[qd_idx].page), + STRIPE_SIZE)!= 0) { + clear_bit(STRIPE_INSYNC, &sh->state); + update_q = 1; + } + } + if (update_p || update_q) { + conf->mddev->resync_mismatches += STRIPE_SECTORS; + if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) + /* don't try to repair!! */ + update_p = update_q = 0; } -#else - compute_block_2(sh, failed_num[0], failed_num[1]); - uptodate += failed_needupdate[0] + failed_needupdate[1]; -#endif - if (uptodate != disks) - BUG(); + /* now write out any block on a failed drive, + * or P or Q if they need it + */ - PRINTK("Marking for sync stripe %llu blocks %d,%d\n", - (unsigned long long)sh->sector, failed_num[0], failed_num[1]); + if (failed == 2) { + dev = &sh->dev[failed_num[1]]; + locked++; + set_bit(R5_LOCKED, &dev->flags); + set_bit(R5_Wantwrite, &dev->flags); + set_bit(R5_Syncio, &dev->flags); + } + if (failed >= 1) { + dev = &sh->dev[failed_num[0]]; + locked++; + set_bit(R5_LOCKED, &dev->flags); + set_bit(R5_Wantwrite, &dev->flags); + set_bit(R5_Syncio, &dev->flags); + } - /**** FIX: Should we really do both of these unconditionally? ****/ - adev = &sh->dev[failed_num[0]]; - locked += !test_bit(R5_LOCKED, &adev->flags); - set_bit(R5_LOCKED, &adev->flags); - set_bit(R5_Wantwrite, &adev->flags); - bdev = &sh->dev[failed_num[1]]; - locked += !test_bit(R5_LOCKED, &bdev->flags); - set_bit(R5_LOCKED, &bdev->flags); + if (update_p) { + dev = &sh->dev[pd_idx]; + locked ++; + set_bit(R5_LOCKED, &dev->flags); + set_bit(R5_Wantwrite, &dev->flags); + set_bit(R5_Syncio, &dev->flags); + } + if (update_q) { + dev = &sh->dev[qd_idx]; + locked++; + set_bit(R5_LOCKED, &dev->flags); + set_bit(R5_Wantwrite, &dev->flags); + set_bit(R5_Syncio, &dev->flags); + } clear_bit(STRIPE_DEGRADED, &sh->state); - set_bit(R5_Wantwrite, &bdev->flags); set_bit(STRIPE_INSYNC, &sh->state); - set_bit(R5_Syncio, &adev->flags); - set_bit(R5_Syncio, &bdev->flags); } } + if (syncing && locked == 0 && test_bit(STRIPE_INSYNC, &sh->state)) { md_done_sync(conf->mddev, STRIPE_SECTORS,1); clear_bit(STRIPE_SYNCING, &sh->state); @@ -1664,7 +1687,7 @@ static int make_request (request_queue_t *q, struct bio * bi) } finish_wait(&conf->wait_for_overlap, &w); raid6_plug_device(conf); - handle_stripe(sh); + handle_stripe(sh, NULL); release_stripe(sh); } else { /* cannot get stripe for read-ahead, just give-up */ @@ -1728,6 +1751,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i return rv; } if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) && + !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) && !conf->fullsync && sync_blocks >= STRIPE_SECTORS) { /* we can skip this block, and probably more */ sync_blocks /= STRIPE_SECTORS; @@ -1765,7 +1789,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i clear_bit(STRIPE_INSYNC, &sh->state); spin_unlock(&sh->lock); - handle_stripe(sh); + handle_stripe(sh, NULL); release_stripe(sh); return STRIPE_SECTORS; @@ -1821,7 +1845,7 @@ static void raid6d (mddev_t *mddev) spin_unlock_irq(&conf->device_lock); handled++; - handle_stripe(sh); + handle_stripe(sh, conf->spare_page); release_stripe(sh); spin_lock_irq(&conf->device_lock); @@ -1860,6 +1884,10 @@ static int run(mddev_t *mddev) goto abort; memset(conf->stripe_hashtbl, 0, HASH_PAGES * PAGE_SIZE); + conf->spare_page = alloc_page(GFP_KERNEL); + if (!conf->spare_page) + goto abort; + spin_lock_init(&conf->device_lock); init_waitqueue_head(&conf->wait_for_stripe); init_waitqueue_head(&conf->wait_for_overlap); @@ -1996,6 +2024,8 @@ static int run(mddev_t *mddev) abort: if (conf) { print_raid6_conf(conf); + if (conf->spare_page) + page_cache_release(conf->spare_page); if (conf->stripe_hashtbl) free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER); diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h index f025ba6..e9c1c0d 100644 --- a/include/linux/raid/raid5.h +++ b/include/linux/raid/raid5.h @@ -228,6 +228,8 @@ struct raid5_private_data { * Cleared when a sync completes. */ + struct page *spare_page; /* Used when checking P/Q in raid6 */ + /* * Free stripes pool */ -- cgit v1.1 From d69762e98456b71167865db9e33e732a28dd36ab Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:18 -0800 Subject: [PATCH] md: improve handing of read errors with raid6 This is a simple port of match functionality across from raid5. If we get a read error, we don't kick the drive straight away, but try to over-write with good data first. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid6main.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 4 deletions(-) diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 52e8796..7a51553 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -367,8 +367,8 @@ static void shrink_stripes(raid6_conf_t *conf) conf->slab_cache = NULL; } -static int raid6_end_read_request (struct bio * bi, unsigned int bytes_done, - int error) +static int raid6_end_read_request(struct bio * bi, unsigned int bytes_done, + int error) { struct stripe_head *sh = bi->bi_private; raid6_conf_t *conf = sh->raid_conf; @@ -420,9 +420,35 @@ static int raid6_end_read_request (struct bio * bi, unsigned int bytes_done, #else set_bit(R5_UPTODATE, &sh->dev[i].flags); #endif + if (test_bit(R5_ReadError, &sh->dev[i].flags)) { + printk(KERN_INFO "raid6: read error corrected!!\n"); + clear_bit(R5_ReadError, &sh->dev[i].flags); + clear_bit(R5_ReWrite, &sh->dev[i].flags); + } + if (atomic_read(&conf->disks[i].rdev->read_errors)) + atomic_set(&conf->disks[i].rdev->read_errors, 0); } else { - md_error(conf->mddev, conf->disks[i].rdev); + int retry = 0; clear_bit(R5_UPTODATE, &sh->dev[i].flags); + atomic_inc(&conf->disks[i].rdev->read_errors); + if (conf->mddev->degraded) + printk(KERN_WARNING "raid6: read error not correctable.\n"); + else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) + /* Oh, no!!! */ + printk(KERN_WARNING "raid6: read error NOT corrected!!\n"); + else if (atomic_read(&conf->disks[i].rdev->read_errors) + > conf->max_nr_stripes) + printk(KERN_WARNING + "raid6: Too many read errors, failing device.\n"); + else + retry = 1; + if (retry) + set_bit(R5_ReadError, &sh->dev[i].flags); + else { + clear_bit(R5_ReadError, &sh->dev[i].flags); + clear_bit(R5_ReWrite, &sh->dev[i].flags); + md_error(conf->mddev, conf->disks[i].rdev); + } } rdev_dec_pending(conf->disks[i].rdev, conf->mddev); #if 0 @@ -1079,6 +1105,12 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) if (dev->written) written++; rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ if (!rdev || !test_bit(In_sync, &rdev->flags)) { + /* The ReadError flag will just be confusing now */ + clear_bit(R5_ReadError, &dev->flags); + clear_bit(R5_ReWrite, &dev->flags); + } + if (!rdev || !test_bit(In_sync, &rdev->flags) + || test_bit(R5_ReadError, &dev->flags)) { if ( failed < 2 ) failed_num[failed] = i; failed++; @@ -1095,6 +1127,14 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) if (failed > 2 && to_read+to_write+written) { for (i=disks; i--; ) { int bitmap_end = 0; + + if (test_bit(R5_ReadError, &sh->dev[i].flags)) { + mdk_rdev_t *rdev = conf->disks[i].rdev; + if (rdev && test_bit(In_sync, &rdev->flags)) + /* multiple read failures in one stripe */ + md_error(conf->mddev, rdev); + } + spin_lock_irq(&conf->device_lock); /* fail all writes first */ bi = sh->dev[i].towrite; @@ -1130,7 +1170,8 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) } /* fail any reads if this device is non-operational */ - if (!test_bit(R5_Insync, &sh->dev[i].flags)) { + if (!test_bit(R5_Insync, &sh->dev[i].flags) || + test_bit(R5_ReadError, &sh->dev[i].flags)) { bi = sh->dev[i].toread; sh->dev[i].toread = NULL; if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) @@ -1457,6 +1498,27 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) clear_bit(STRIPE_SYNCING, &sh->state); } + /* If the failed drives are just a ReadError, then we might need + * to progress the repair/check process + */ + if (failed <= 2 && ! conf->mddev->ro) + for (i=0; idev[failed_num[i]]; + if (test_bit(R5_ReadError, &dev->flags) + && !test_bit(R5_LOCKED, &dev->flags) + && test_bit(R5_UPTODATE, &dev->flags) + ) { + if (!test_bit(R5_ReWrite, &dev->flags)) { + set_bit(R5_Wantwrite, &dev->flags); + set_bit(R5_ReWrite, &dev->flags); + set_bit(R5_LOCKED, &dev->flags); + } else { + /* let's read it back */ + set_bit(R5_Wantread, &dev->flags); + set_bit(R5_LOCKED, &dev->flags); + } + } + } spin_unlock(&sh->lock); while ((bi=return_bi)) { -- cgit v1.1 From ddaf22abaa831763e75775e6d4c7693504237997 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:19 -0800 Subject: [PATCH] md: attempt to auto-correct read errors in raid1 On a read-error we suspend the array, then synchronously read the block from other arrays until we find one where we can read it. Then we try writing the good data back everywhere and make sure it works. If any write or subsequent read fails, only then do we fail the device out of the array. To be able to suspend the array, we need to also keep track of how many requests are queued for handling by raid1d. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 1 + drivers/md/raid1.c | 115 +++++++++++++++++++++++++++++++++++++++++---- include/linux/raid/raid1.h | 3 ++ 3 files changed, 109 insertions(+), 10 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 64e7da3..1364a1c 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -461,6 +461,7 @@ int sync_page_io(struct block_device *bdev, sector_t sector, int size, bio_put(bio); return ret; } +EXPORT_SYMBOL(sync_page_io); static int read_disk_sb(mdk_rdev_t * rdev, int size) { diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index c618015..b3856db 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -191,6 +191,7 @@ static void reschedule_retry(r1bio_t *r1_bio) spin_lock_irqsave(&conf->device_lock, flags); list_add(&r1_bio->retry_list, &conf->retry_list); + conf->nr_queued ++; spin_unlock_irqrestore(&conf->device_lock, flags); wake_up(&conf->wait_barrier); @@ -245,9 +246,9 @@ static int raid1_end_read_request(struct bio *bio, unsigned int bytes_done, int /* * this branch is our 'one mirror IO has finished' event handler: */ - if (!uptodate) - md_error(r1_bio->mddev, conf->mirrors[mirror].rdev); - else + update_head_pos(mirror, r1_bio); + + if (uptodate || conf->working_disks <= 1) { /* * Set R1BIO_Uptodate in our master bio, so that * we will return a good error code for to the higher @@ -259,14 +260,8 @@ static int raid1_end_read_request(struct bio *bio, unsigned int bytes_done, int */ set_bit(R1BIO_Uptodate, &r1_bio->state); - update_head_pos(mirror, r1_bio); - - /* - * we have only one bio on the read side - */ - if (uptodate) raid_end_bio_io(r1_bio); - else { + } else { /* * oops, read error: */ @@ -653,6 +648,32 @@ static void allow_barrier(conf_t *conf) wake_up(&conf->wait_barrier); } +static void freeze_array(conf_t *conf) +{ + /* stop syncio and normal IO and wait for everything to + * go quite. + * We increment barrier and nr_waiting, and then + * wait until barrier+nr_pending match nr_queued+2 + */ + spin_lock_irq(&conf->resync_lock); + conf->barrier++; + conf->nr_waiting++; + wait_event_lock_irq(conf->wait_barrier, + conf->barrier+conf->nr_pending == conf->nr_queued+2, + conf->resync_lock, + raid1_unplug(conf->mddev->queue)); + spin_unlock_irq(&conf->resync_lock); +} +static void unfreeze_array(conf_t *conf) +{ + /* reverse the effect of the freeze */ + spin_lock_irq(&conf->resync_lock); + conf->barrier--; + conf->nr_waiting--; + wake_up(&conf->wait_barrier); + spin_unlock_irq(&conf->resync_lock); +} + /* duplicate the data pages for behind I/O */ static struct page **alloc_behind_pages(struct bio *bio) @@ -1196,6 +1217,7 @@ static void raid1d(mddev_t *mddev) break; r1_bio = list_entry(head->prev, r1bio_t, retry_list); list_del(head->prev); + conf->nr_queued--; spin_unlock_irqrestore(&conf->device_lock, flags); mddev = r1_bio->mddev; @@ -1235,6 +1257,74 @@ static void raid1d(mddev_t *mddev) } } else { int disk; + + /* we got a read error. Maybe the drive is bad. Maybe just + * the block and we can fix it. + * We freeze all other IO, and try reading the block from + * other devices. When we find one, we re-write + * and check it that fixes the read error. + * This is all done synchronously while the array is + * frozen + */ + sector_t sect = r1_bio->sector; + int sectors = r1_bio->sectors; + freeze_array(conf); + while(sectors) { + int s = sectors; + int d = r1_bio->read_disk; + int success = 0; + + if (s > (PAGE_SIZE>>9)) + s = PAGE_SIZE >> 9; + + do { + rdev = conf->mirrors[d].rdev; + if (rdev && + test_bit(In_sync, &rdev->flags) && + sync_page_io(rdev->bdev, + sect + rdev->data_offset, + s<<9, + conf->tmppage, READ)) + success = 1; + else { + d++; + if (d == conf->raid_disks) + d = 0; + } + } while (!success && d != r1_bio->read_disk); + + if (success) { + /* write it back and re-read */ + while (d != r1_bio->read_disk) { + if (d==0) + d = conf->raid_disks; + d--; + rdev = conf->mirrors[d].rdev; + if (rdev && + test_bit(In_sync, &rdev->flags)) { + if (sync_page_io(rdev->bdev, + sect + rdev->data_offset, + s<<9, conf->tmppage, WRITE) == 0 || + sync_page_io(rdev->bdev, + sect + rdev->data_offset, + s<<9, conf->tmppage, READ) == 0) { + /* Well, this device is dead */ + md_error(mddev, rdev); + } + } + } + } else { + /* Cannot read from anywhere -- bye bye array */ + md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev); + break; + } + sectors -= s; + sect += s; + } + + + unfreeze_array(conf); + bio = r1_bio->bios[r1_bio->read_disk]; if ((disk=read_balance(conf, r1_bio)) == -1) { printk(KERN_ALERT "raid1: %s: unrecoverable I/O" @@ -1529,6 +1619,10 @@ static int run(mddev_t *mddev) memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks); + conf->tmppage = alloc_page(GFP_KERNEL); + if (!conf->tmppage) + goto out_no_mem; + conf->poolinfo = kmalloc(sizeof(*conf->poolinfo), GFP_KERNEL); if (!conf->poolinfo) goto out_no_mem; @@ -1635,6 +1729,7 @@ out_free_conf: if (conf->r1bio_pool) mempool_destroy(conf->r1bio_pool); kfree(conf->mirrors); + __free_page(conf->tmppage); kfree(conf->poolinfo); kfree(conf); mddev->private = NULL; diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h index c556742..cbe4238 100644 --- a/include/linux/raid/raid1.h +++ b/include/linux/raid/raid1.h @@ -46,6 +46,7 @@ struct r1_private_data_s { spinlock_t resync_lock; int nr_pending; int nr_waiting; + int nr_queued; int barrier; sector_t next_resync; int fullsync; /* set to 1 if a full sync is needed, @@ -57,6 +58,8 @@ struct r1_private_data_s { struct pool_info *poolinfo; + struct page *tmppage; + mempool_t *r1bio_pool; mempool_t *r1buf_pool; }; -- cgit v1.1 From 3e198f7826f830604f3aa7c20359a773e70cbeaa Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:21 -0800 Subject: [PATCH] md: tidyup some issues with raid1 resync and prepare for catching read errors We are dereferencing ->rdev without an rcu lock! Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid1.c | 110 +++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index b3856db..ea1f1eb 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -177,6 +177,13 @@ static inline void free_r1bio(r1bio_t *r1_bio) static inline void put_buf(r1bio_t *r1_bio) { conf_t *conf = mddev_to_conf(r1_bio->mddev); + int i; + + for (i=0; iraid_disks; i++) { + struct bio *bio = r1_bio->bios[i]; + if (bio->bi_end_io) + rdev_dec_pending(conf->mirrors[i].rdev, r1_bio->mddev); + } mempool_free(r1_bio, conf->r1buf_pool); @@ -1085,7 +1092,6 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) conf->mirrors[r1_bio->read_disk].rdev); } else set_bit(R1BIO_Uptodate, &r1_bio->state); - rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev); reschedule_retry(r1_bio); return 0; } @@ -1116,7 +1122,6 @@ static int end_sync_write(struct bio *bio, unsigned int bytes_done, int error) md_done_sync(mddev, r1_bio->sectors, uptodate); put_buf(r1_bio); } - rdev_dec_pending(conf->mirrors[mirror].rdev, mddev); return 0; } @@ -1153,10 +1158,14 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) atomic_set(&r1_bio->remaining, 1); for (i = 0; i < disks ; i++) { wbio = r1_bio->bios[i]; - if (wbio->bi_end_io != end_sync_write) + if (wbio->bi_end_io == NULL || + (wbio->bi_end_io == end_sync_read && + (i == r1_bio->read_disk || + !test_bit(MD_RECOVERY_SYNC, &mddev->recovery)))) continue; - atomic_inc(&conf->mirrors[i].rdev->nr_pending); + wbio->bi_rw = WRITE; + wbio->bi_end_io = end_sync_write; atomic_inc(&r1_bio->remaining); md_sync_acct(conf->mirrors[i].rdev->bdev, wbio->bi_size >> 9); @@ -1388,14 +1397,13 @@ static int init_resync(conf_t *conf) static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster) { conf_t *conf = mddev_to_conf(mddev); - mirror_info_t *mirror; r1bio_t *r1_bio; struct bio *bio; sector_t max_sector, nr_sectors; - int disk; + int disk = -1; int i; - int wonly; - int write_targets = 0; + int wonly = -1; + int write_targets = 0, read_targets = 0; int sync_blocks; int still_degraded = 0; @@ -1447,44 +1455,24 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i conf->next_resync = sector_nr; + r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO); + rcu_read_lock(); /* - * If reconstructing, and >1 working disc, - * could dedicate one to rebuild and others to - * service read requests .. + * If we get a correctably read error during resync or recovery, + * we might want to read from a different device. So we + * flag all drives that could conceivably be read from for READ, + * and any others (which will be non-In_sync devices) for WRITE. + * If a read fails, we try reading from something else for which READ + * is OK. */ - disk = conf->last_used; - /* make sure disk is operational */ - wonly = disk; - while (conf->mirrors[disk].rdev == NULL || - !test_bit(In_sync, &conf->mirrors[disk].rdev->flags) || - test_bit(WriteMostly, &conf->mirrors[disk].rdev->flags) - ) { - if (conf->mirrors[disk].rdev && - test_bit(In_sync, &conf->mirrors[disk].rdev->flags)) - wonly = disk; - if (disk <= 0) - disk = conf->raid_disks; - disk--; - if (disk == conf->last_used) { - disk = wonly; - break; - } - } - conf->last_used = disk; - atomic_inc(&conf->mirrors[disk].rdev->nr_pending); - - - mirror = conf->mirrors + disk; - - r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO); r1_bio->mddev = mddev; r1_bio->sector = sector_nr; r1_bio->state = 0; set_bit(R1BIO_IsSync, &r1_bio->state); - r1_bio->read_disk = disk; for (i=0; i < conf->raid_disks; i++) { + mdk_rdev_t *rdev; bio = r1_bio->bios[i]; /* take from bio_init */ @@ -1499,35 +1487,49 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i bio->bi_end_io = NULL; bio->bi_private = NULL; - if (i == disk) { - bio->bi_rw = READ; - bio->bi_end_io = end_sync_read; - } else if (conf->mirrors[i].rdev == NULL || - test_bit(Faulty, &conf->mirrors[i].rdev->flags)) { + rdev = rcu_dereference(conf->mirrors[i].rdev); + if (rdev == NULL || + test_bit(Faulty, &rdev->flags)) { still_degraded = 1; continue; - } else if (!test_bit(In_sync, &conf->mirrors[i].rdev->flags) || - sector_nr + RESYNC_SECTORS > mddev->recovery_cp || - test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { + } else if (!test_bit(In_sync, &rdev->flags)) { bio->bi_rw = WRITE; bio->bi_end_io = end_sync_write; write_targets ++; - } else - /* no need to read or write here */ - continue; - bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset; - bio->bi_bdev = conf->mirrors[i].rdev->bdev; + } else { + /* may need to read from here */ + bio->bi_rw = READ; + bio->bi_end_io = end_sync_read; + if (test_bit(WriteMostly, &rdev->flags)) { + if (wonly < 0) + wonly = i; + } else { + if (disk < 0) + disk = i; + } + read_targets++; + } + atomic_inc(&rdev->nr_pending); + bio->bi_sector = sector_nr + rdev->data_offset; + bio->bi_bdev = rdev->bdev; bio->bi_private = r1_bio; } + rcu_read_unlock(); + if (disk < 0) + disk = wonly; + r1_bio->read_disk = disk; - if (write_targets == 0) { + if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) && read_targets > 0) + /* extra read targets are also write targets */ + write_targets += read_targets-1; + + if (write_targets == 0 || read_targets == 0) { /* There is nowhere to write, so all non-sync * drives must be failed - so we are finished */ sector_t rv = max_sector - sector_nr; *skipped = 1; put_buf(r1_bio); - rdev_dec_pending(conf->mirrors[disk].rdev, mddev); return rv; } @@ -1578,10 +1580,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i sync_blocks -= (len>>9); } while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES); bio_full: - bio = r1_bio->bios[disk]; + bio = r1_bio->bios[r1_bio->read_disk]; r1_bio->sectors = nr_sectors; - md_sync_acct(mirror->rdev->bdev, nr_sectors); + md_sync_acct(conf->mirrors[r1_bio->read_disk].rdev->bdev, nr_sectors); generic_make_request(bio); -- cgit v1.1 From 69382e85371c232df71524137a806b9c210ec021 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:22 -0800 Subject: [PATCH] md: better handling for read error in raid1 during resync Handling of read errors during resync is separate from handling of read errors during normal IO in raid1. A previous patch added support for read errors during normal IO. This one adds support for read errors during resync or recovery. The key differences are that we don't need to freeze the array, because the normal handling of resync means that this part of the array will be idle except for resync, and the read/overwrite/re-read is needed in a separate piece of code. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid1.c | 99 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 21 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index ea1f1eb..14a8fe0 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1072,9 +1072,7 @@ abort: static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) { - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); - conf_t *conf = mddev_to_conf(r1_bio->mddev); if (bio->bi_size) return 1; @@ -1087,10 +1085,7 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) * or re-read if the read failed. * We don't do much here, just schedule handling by raid1d */ - if (!uptodate) { - md_error(r1_bio->mddev, - conf->mirrors[r1_bio->read_disk].rdev); - } else + if (test_bit(BIO_UPTODATE, &bio->bi_flags)) set_bit(R1BIO_Uptodate, &r1_bio->state); reschedule_retry(r1_bio); return 0; @@ -1134,27 +1129,89 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) bio = r1_bio->bios[r1_bio->read_disk]; -/* - if (r1_bio->sector == 0) printk("First sync write startss\n"); -*/ + /* * schedule writes */ if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) { - /* - * There is no point trying a read-for-reconstruct as - * reconstruct is about to be aborted + /* ouch - failed to read all of that. + * Try some synchronous reads of other devices to get + * good data, much like with normal read errors. Only + * read into the pages we already have so they we don't + * need to re-issue the read request. + * We don't need to freeze the array, because being in an + * active sync request, there is no normal IO, and + * no overlapping syncs. */ - char b[BDEVNAME_SIZE]; - printk(KERN_ALERT "raid1: %s: unrecoverable I/O read error" - " for block %llu\n", - bdevname(bio->bi_bdev,b), - (unsigned long long)r1_bio->sector); - md_done_sync(mddev, r1_bio->sectors, 0); - put_buf(r1_bio); - return; + sector_t sect = r1_bio->sector; + int sectors = r1_bio->sectors; + int idx = 0; + + while(sectors) { + int s = sectors; + int d = r1_bio->read_disk; + int success = 0; + mdk_rdev_t *rdev; + + if (s > (PAGE_SIZE>>9)) + s = PAGE_SIZE >> 9; + do { + if (r1_bio->bios[d]->bi_end_io == end_sync_read) { + rdev = conf->mirrors[d].rdev; + if (sync_page_io(rdev->bdev, + sect + rdev->data_offset, + s<<9, + bio->bi_io_vec[idx].bv_page, + READ)) { + success = 1; + break; + } + } + d++; + if (d == conf->raid_disks) + d = 0; + } while (!success && d != r1_bio->read_disk); + + if (success) { + /* write it back and re-read */ + set_bit(R1BIO_Uptodate, &r1_bio->state); + while (d != r1_bio->read_disk) { + if (d == 0) + d = conf->raid_disks; + d--; + if (r1_bio->bios[d]->bi_end_io != end_sync_read) + continue; + rdev = conf->mirrors[d].rdev; + if (sync_page_io(rdev->bdev, + sect + rdev->data_offset, + s<<9, + bio->bi_io_vec[idx].bv_page, + WRITE) == 0 || + sync_page_io(rdev->bdev, + sect + rdev->data_offset, + s<<9, + bio->bi_io_vec[idx].bv_page, + READ) == 0) { + md_error(mddev, rdev); + } + } + } else { + char b[BDEVNAME_SIZE]; + /* Cannot read from anywhere, array is toast */ + md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev); + printk(KERN_ALERT "raid1: %s: unrecoverable I/O read error" + " for block %llu\n", + bdevname(bio->bi_bdev,b), + (unsigned long long)r1_bio->sector); + md_done_sync(mddev, r1_bio->sectors, 0); + put_buf(r1_bio); + return; + } + sectors -= s; + sect += s; + idx ++; + } } - atomic_set(&r1_bio->remaining, 1); for (i = 0; i < disks ; i++) { wbio = r1_bio->bios[i]; -- cgit v1.1 From cf30a473a02901fe4db37abc0b0fa26dd5ba3f72 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:23 -0800 Subject: [PATCH] md: handle errors when read-only Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid1.c | 18 +++++++++++------- include/linux/raid/raid1.h | 7 +++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 14a8fe0..a8bc93d 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -154,7 +154,7 @@ static void put_all_bios(conf_t *conf, r1bio_t *r1_bio) for (i = 0; i < conf->raid_disks; i++) { struct bio **bio = r1_bio->bios + i; - if (*bio) + if (*bio && *bio != IO_BLOCKED) bio_put(*bio); *bio = NULL; } @@ -419,11 +419,13 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) new_disk = 0; for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); + r1_bio->bios[new_disk] == IO_BLOCKED || !rdev || !test_bit(In_sync, &rdev->flags) || test_bit(WriteMostly, &rdev->flags); rdev = rcu_dereference(conf->mirrors[++new_disk].rdev)) { - if (rdev && test_bit(In_sync, &rdev->flags)) + if (rdev && test_bit(In_sync, &rdev->flags) && + r1_bio->bios[new_disk] != IO_BLOCKED) wonly_disk = new_disk; if (new_disk == conf->raid_disks - 1) { @@ -437,11 +439,13 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) /* make sure the disk is operational */ for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); + r1_bio->bios[new_disk] == IO_BLOCKED || !rdev || !test_bit(In_sync, &rdev->flags) || test_bit(WriteMostly, &rdev->flags); rdev = rcu_dereference(conf->mirrors[new_disk].rdev)) { - if (rdev && test_bit(In_sync, &rdev->flags)) + if (rdev && test_bit(In_sync, &rdev->flags) && + r1_bio->bios[new_disk] != IO_BLOCKED) wonly_disk = new_disk; if (new_disk <= 0) @@ -478,7 +482,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) rdev = rcu_dereference(conf->mirrors[disk].rdev); - if (!rdev || + if (!rdev || r1_bio->bios[disk] == IO_BLOCKED || !test_bit(In_sync, &rdev->flags) || test_bit(WriteMostly, &rdev->flags)) continue; @@ -1335,7 +1339,7 @@ static void raid1d(mddev_t *mddev) sector_t sect = r1_bio->sector; int sectors = r1_bio->sectors; freeze_array(conf); - while(sectors) { + if (mddev->ro == 0) while(sectors) { int s = sectors; int d = r1_bio->read_disk; int success = 0; @@ -1388,7 +1392,6 @@ static void raid1d(mddev_t *mddev) sect += s; } - unfreeze_array(conf); bio = r1_bio->bios[r1_bio->read_disk]; @@ -1399,7 +1402,8 @@ static void raid1d(mddev_t *mddev) (unsigned long long)r1_bio->sector); raid_end_bio_io(r1_bio); } else { - r1_bio->bios[r1_bio->read_disk] = NULL; + r1_bio->bios[r1_bio->read_disk] = + mddev->ro ? IO_BLOCKED : NULL; r1_bio->read_disk = disk; bio_put(bio); bio = bio_clone(r1_bio->master_bio, GFP_NOIO); diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h index cbe4238..9d5494a 100644 --- a/include/linux/raid/raid1.h +++ b/include/linux/raid/raid1.h @@ -109,6 +109,13 @@ struct r1bio_s { /* DO NOT PUT ANY NEW FIELDS HERE - bios array is contiguously alloced*/ }; +/* when we get a read error on a read-only array, we redirect to another + * device without failing the first device, or trying to over-write to + * correct the read error. To keep track of bad blocks on a per-bio + * level, we store IO_BLOCKED in the appropriate 'bios' pointer + */ +#define IO_BLOCKED ((struct bio*)1) + /* bits for r1bio.state */ #define R1BIO_Uptodate 0 #define R1BIO_IsSync 1 -- cgit v1.1 From 9910f16af35419a5382fa7850eecc220103036fa Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:24 -0800 Subject: [PATCH] md: fix up some rdev rcu locking in raid5/6 There is this "FIXME" comment with a typo in it!! that been annoying me for days, so I just had to remove it. conf->disks[i].rdev should only be accessed if - we know we hold a reference or - the mddev->reconfig_sem is down or - we have a rcu_readlock handle_stripe was referencing rdev in three places without any of these. For the first two, get an rcu_readlock. For the last, the same access (md_sync_acct call) is made a little later after the rdev has been claimed under and rcu_readlock, if R5_Syncio is set. So just use that access... However R5_Syncio isn't really needed as the 'syncing' variable contains the same information. So use that instead. Issues, comment, and fix are identical in raid5 and raid6. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid5.c | 16 ++++++++-------- drivers/md/raid6main.c | 19 ++++++++----------- include/linux/raid/raid5.h | 1 - 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 0d016a8..0222ba1 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -961,11 +961,11 @@ static void handle_stripe(struct stripe_head *sh) syncing = test_bit(STRIPE_SYNCING, &sh->state); /* Now to look around and see what can be done */ + rcu_read_lock(); for (i=disks; i--; ) { mdk_rdev_t *rdev; dev = &sh->dev[i]; clear_bit(R5_Insync, &dev->flags); - clear_bit(R5_Syncio, &dev->flags); PRINTK("check %d: state 0x%lx read %p write %p written %p\n", i, dev->flags, dev->toread, dev->towrite, dev->written); @@ -1004,7 +1004,7 @@ static void handle_stripe(struct stripe_head *sh) non_overwrite++; } if (dev->written) written++; - rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ + rdev = rcu_dereference(conf->disks[i].rdev); if (!rdev || !test_bit(In_sync, &rdev->flags)) { /* The ReadError flag will just be confusing now */ clear_bit(R5_ReadError, &dev->flags); @@ -1017,6 +1017,7 @@ static void handle_stripe(struct stripe_head *sh) } else set_bit(R5_Insync, &dev->flags); } + rcu_read_unlock(); PRINTK("locked=%d uptodate=%d to_read=%d" " to_write=%d failed=%d failed_num=%d\n", locked, uptodate, to_read, to_write, failed, failed_num); @@ -1028,10 +1029,13 @@ static void handle_stripe(struct stripe_head *sh) int bitmap_end = 0; if (test_bit(R5_ReadError, &sh->dev[i].flags)) { - mdk_rdev_t *rdev = conf->disks[i].rdev; + mdk_rdev_t *rdev; + rcu_read_lock(); + rdev = rcu_dereference(conf->disks[i].rdev); if (rdev && test_bit(In_sync, &rdev->flags)) /* multiple read failures in one stripe */ md_error(conf->mddev, rdev); + rcu_read_unlock(); } spin_lock_irq(&conf->device_lock); @@ -1180,9 +1184,6 @@ static void handle_stripe(struct stripe_head *sh) locked++; PRINTK("Reading block %d (sync=%d)\n", i, syncing); - if (syncing) - md_sync_acct(conf->disks[i].rdev->bdev, - STRIPE_SECTORS); } } } @@ -1326,7 +1327,6 @@ static void handle_stripe(struct stripe_head *sh) clear_bit(STRIPE_DEGRADED, &sh->state); locked++; set_bit(STRIPE_INSYNC, &sh->state); - set_bit(R5_Syncio, &dev->flags); } } if (syncing && locked == 0 && test_bit(STRIPE_INSYNC, &sh->state)) { @@ -1392,7 +1392,7 @@ static void handle_stripe(struct stripe_head *sh) rcu_read_unlock(); if (rdev) { - if (test_bit(R5_Syncio, &sh->dev[i].flags)) + if (syncing) md_sync_acct(rdev->bdev, STRIPE_SECTORS); bi->bi_bdev = rdev->bdev; diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 7a51553..b5b7a8d 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -1060,11 +1060,11 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) syncing = test_bit(STRIPE_SYNCING, &sh->state); /* Now to look around and see what can be done */ + rcu_read_lock(); for (i=disks; i--; ) { mdk_rdev_t *rdev; dev = &sh->dev[i]; clear_bit(R5_Insync, &dev->flags); - clear_bit(R5_Syncio, &dev->flags); PRINTK("check %d: state 0x%lx read %p write %p written %p\n", i, dev->flags, dev->toread, dev->towrite, dev->written); @@ -1103,7 +1103,7 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) non_overwrite++; } if (dev->written) written++; - rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ + rdev = rcu_dereference(conf->disks[i].rdev); if (!rdev || !test_bit(In_sync, &rdev->flags)) { /* The ReadError flag will just be confusing now */ clear_bit(R5_ReadError, &dev->flags); @@ -1117,6 +1117,7 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) } else set_bit(R5_Insync, &dev->flags); } + rcu_read_unlock(); PRINTK("locked=%d uptodate=%d to_read=%d" " to_write=%d failed=%d failed_num=%d,%d\n", locked, uptodate, to_read, to_write, failed, @@ -1129,10 +1130,13 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) int bitmap_end = 0; if (test_bit(R5_ReadError, &sh->dev[i].flags)) { - mdk_rdev_t *rdev = conf->disks[i].rdev; + mdk_rdev_t *rdev; + rcu_read_lock(); + rdev = rcu_dereference(conf->disks[i].rdev); if (rdev && test_bit(In_sync, &rdev->flags)) /* multiple read failures in one stripe */ md_error(conf->mddev, rdev); + rcu_read_unlock(); } spin_lock_irq(&conf->device_lock); @@ -1307,9 +1311,6 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) locked++; PRINTK("Reading block %d (sync=%d)\n", i, syncing); - if (syncing) - md_sync_acct(conf->disks[i].rdev->bdev, - STRIPE_SECTORS); } } } @@ -1463,14 +1464,12 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) locked++; set_bit(R5_LOCKED, &dev->flags); set_bit(R5_Wantwrite, &dev->flags); - set_bit(R5_Syncio, &dev->flags); } if (failed >= 1) { dev = &sh->dev[failed_num[0]]; locked++; set_bit(R5_LOCKED, &dev->flags); set_bit(R5_Wantwrite, &dev->flags); - set_bit(R5_Syncio, &dev->flags); } if (update_p) { @@ -1478,14 +1477,12 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) locked ++; set_bit(R5_LOCKED, &dev->flags); set_bit(R5_Wantwrite, &dev->flags); - set_bit(R5_Syncio, &dev->flags); } if (update_q) { dev = &sh->dev[qd_idx]; locked++; set_bit(R5_LOCKED, &dev->flags); set_bit(R5_Wantwrite, &dev->flags); - set_bit(R5_Syncio, &dev->flags); } clear_bit(STRIPE_DEGRADED, &sh->state); @@ -1557,7 +1554,7 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) rcu_read_unlock(); if (rdev) { - if (test_bit(R5_Syncio, &sh->dev[i].flags)) + if (syncing) md_sync_acct(rdev->bdev, STRIPE_SECTORS); bi->bi_bdev = rdev->bdev; diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h index e9c1c0d..28fcd75 100644 --- a/include/linux/raid/raid5.h +++ b/include/linux/raid/raid5.h @@ -152,7 +152,6 @@ struct stripe_head { #define R5_Insync 3 /* rdev && rdev->in_sync at start */ #define R5_Wantread 4 /* want to schedule a read */ #define R5_Wantwrite 5 -#define R5_Syncio 6 /* this io need to be accounted as resync io */ #define R5_Overlap 7 /* There is a pending overlapping request on this block */ #define R5_ReadError 8 /* seen a read error here recently */ #define R5_ReWrite 9 /* have tried to over-write the readerror */ -- cgit v1.1 From 18f08819f42b647783e4f6ea99141623881bf182 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:25 -0800 Subject: [PATCH] md: support check-without-repair of raid10 arrays Also keep count on the number of errors found. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid10.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 8f58a44..1fa70c3 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1206,6 +1206,10 @@ static void sync_request_write(mddev_t *mddev, r10bio_t *r10_bio) break; if (j == vcnt) continue; + mddev->resync_mismatches += r10_bio->sectors; + if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) + /* Don't fix anything. */ + continue; /* Ok, we need to write this bio * First we need to fixup bv_offset, bv_len and * bi_vecs, as the read request might have corrupted these -- cgit v1.1 From d11c171e636cfd2df818cf3411d88222c2f4fcef Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:26 -0800 Subject: [PATCH] md: allow raid1 to check consistency Where performing a user-requested 'check' or 'repair', we read all readable devices, and compare the contents. We only write to blocks which had read errors, or blocks with content that differs from the first good device found. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid1.c | 156 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 128 insertions(+), 28 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index a8bc93d..7fbb608 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -106,15 +106,30 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) } /* * Allocate RESYNC_PAGES data pages and attach them to - * the first bio; + * the first bio. + * If this is a user-requested check/repair, allocate + * RESYNC_PAGES for each bio. */ - bio = r1_bio->bios[0]; - for (i = 0; i < RESYNC_PAGES; i++) { - page = alloc_page(gfp_flags); - if (unlikely(!page)) - goto out_free_pages; - - bio->bi_io_vec[i].bv_page = page; + if (test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) + j = pi->raid_disks; + else + j = 1; + while(j--) { + bio = r1_bio->bios[j]; + for (i = 0; i < RESYNC_PAGES; i++) { + page = alloc_page(gfp_flags); + if (unlikely(!page)) + goto out_free_pages; + + bio->bi_io_vec[i].bv_page = page; + } + } + /* If not user-requests, copy the page pointers to all bios */ + if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) { + for (i=0; iraid_disks; j++) + r1_bio->bios[j]->bi_io_vec[i].bv_page = + r1_bio->bios[0]->bi_io_vec[i].bv_page; } r1_bio->master_bio = NULL; @@ -122,8 +137,10 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) return r1_bio; out_free_pages: - for ( ; i > 0 ; i--) - __free_page(bio->bi_io_vec[i-1].bv_page); + for (i=0; i < RESYNC_PAGES ; i++) + for (j=0 ; j < pi->raid_disks; j++) + __free_page(r1_bio->bios[j]->bi_io_vec[i].bv_page); + j = -1; out_free_bio: while ( ++j < pi->raid_disks ) bio_put(r1_bio->bios[j]); @@ -134,14 +151,16 @@ out_free_bio: static void r1buf_pool_free(void *__r1_bio, void *data) { struct pool_info *pi = data; - int i; + int i,j; r1bio_t *r1bio = __r1_bio; - struct bio *bio = r1bio->bios[0]; - for (i = 0; i < RESYNC_PAGES; i++) { - __free_page(bio->bi_io_vec[i].bv_page); - bio->bi_io_vec[i].bv_page = NULL; - } + for (i = 0; i < RESYNC_PAGES; i++) + for (j = pi->raid_disks; j-- ;) { + if (j == 0 || + r1bio->bios[j]->bi_io_vec[i].bv_page != + r1bio->bios[0]->bi_io_vec[i].bv_page) + __free_page(r1bio->bios[j]->bi_io_vec[i].bv_page); + } for (i=0 ; i < pi->raid_disks; i++) bio_put(r1bio->bios[i]); @@ -1077,13 +1096,16 @@ abort: static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) { r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); + int i; if (bio->bi_size) return 1; - if (r1_bio->bios[r1_bio->read_disk] != bio) - BUG(); - update_head_pos(r1_bio->read_disk, r1_bio); + for (i=r1_bio->mddev->raid_disks; i--; ) + if (r1_bio->bios[i] == bio) + break; + BUG_ON(i < 0); + update_head_pos(i, r1_bio); /* * we have read a block, now it needs to be re-written, * or re-read if the read failed. @@ -1091,7 +1113,9 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) */ if (test_bit(BIO_UPTODATE, &bio->bi_flags)) set_bit(R1BIO_Uptodate, &r1_bio->state); - reschedule_retry(r1_bio); + + if (atomic_dec_and_test(&r1_bio->remaining)) + reschedule_retry(r1_bio); return 0; } @@ -1134,9 +1158,65 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) bio = r1_bio->bios[r1_bio->read_disk]; - /* - * schedule writes - */ + if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { + /* We have read all readable devices. If we haven't + * got the block, then there is no hope left. + * If we have, then we want to do a comparison + * and skip the write if everything is the same. + * If any blocks failed to read, then we need to + * attempt an over-write + */ + int primary; + if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) { + for (i=0; iraid_disks; i++) + if (r1_bio->bios[i]->bi_end_io == end_sync_read) + md_error(mddev, conf->mirrors[i].rdev); + + md_done_sync(mddev, r1_bio->sectors, 1); + put_buf(r1_bio); + return; + } + for (primary=0; primaryraid_disks; primary++) + if (r1_bio->bios[primary]->bi_end_io == end_sync_read && + test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) { + r1_bio->bios[primary]->bi_end_io = NULL; + break; + } + r1_bio->read_disk = primary; + for (i=0; iraid_disks; i++) + if (r1_bio->bios[i]->bi_end_io == end_sync_read && + test_bit(BIO_UPTODATE, &r1_bio->bios[i]->bi_flags)) { + int j; + int vcnt = r1_bio->sectors >> (PAGE_SHIFT- 9); + struct bio *pbio = r1_bio->bios[primary]; + struct bio *sbio = r1_bio->bios[i]; + for (j = vcnt; j-- ; ) + if (memcmp(page_address(pbio->bi_io_vec[j].bv_page), + page_address(sbio->bi_io_vec[j].bv_page), + PAGE_SIZE)) + break; + if (j >= 0) + mddev->resync_mismatches += r1_bio->sectors; + if (j < 0 || test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) + sbio->bi_end_io = NULL; + else { + /* fixup the bio for reuse */ + sbio->bi_vcnt = vcnt; + sbio->bi_size = r1_bio->sectors << 9; + sbio->bi_idx = 0; + sbio->bi_phys_segments = 0; + sbio->bi_hw_segments = 0; + sbio->bi_hw_front_size = 0; + sbio->bi_hw_back_size = 0; + sbio->bi_flags &= ~(BIO_POOL_MASK - 1); + sbio->bi_flags |= 1 << BIO_UPTODATE; + sbio->bi_next = NULL; + sbio->bi_sector = r1_bio->sector + + conf->mirrors[i].rdev->data_offset; + sbio->bi_bdev = conf->mirrors[i].rdev->bdev; + } + } + } if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) { /* ouch - failed to read all of that. * Try some synchronous reads of other devices to get @@ -1216,6 +1296,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) idx ++; } } + + /* + * schedule writes + */ atomic_set(&r1_bio->remaining, 1); for (i = 0; i < disks ; i++) { wbio = r1_bio->bios[i]; @@ -1618,10 +1702,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i for (i=0 ; i < conf->raid_disks; i++) { bio = r1_bio->bios[i]; if (bio->bi_end_io) { - page = r1_bio->bios[0]->bi_io_vec[bio->bi_vcnt].bv_page; + page = bio->bi_io_vec[bio->bi_vcnt].bv_page; if (bio_add_page(bio, page, len, 0) == 0) { /* stop here */ - r1_bio->bios[0]->bi_io_vec[bio->bi_vcnt].bv_page = page; + bio->bi_io_vec[bio->bi_vcnt].bv_page = page; while (i > 0) { i--; bio = r1_bio->bios[i]; @@ -1641,12 +1725,28 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i sync_blocks -= (len>>9); } while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES); bio_full: - bio = r1_bio->bios[r1_bio->read_disk]; r1_bio->sectors = nr_sectors; - md_sync_acct(conf->mirrors[r1_bio->read_disk].rdev->bdev, nr_sectors); + /* For a user-requested sync, we read all readable devices and do a + * compare + */ + if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { + atomic_set(&r1_bio->remaining, read_targets); + for (i=0; iraid_disks; i++) { + bio = r1_bio->bios[i]; + if (bio->bi_end_io == end_sync_read) { + md_sync_acct(conf->mirrors[i].rdev->bdev, nr_sectors); + generic_make_request(bio); + } + } + } else { + atomic_set(&r1_bio->remaining, 1); + bio = r1_bio->bios[r1_bio->read_disk]; + md_sync_acct(conf->mirrors[r1_bio->read_disk].rdev->bdev, + nr_sectors); + generic_make_request(bio); - generic_make_request(bio); + } return nr_sectors; } -- cgit v1.1 From 220946c9018de74b952446e3a4dff1bfd4cbf310 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:27 -0800 Subject: [PATCH] md: make sure read error on last working drive of raid1 actually returns failure We are inadvertently setting the R1BIO_Uptodate bit on read errors when we decide not to try correcting (because there are no other working devices). This means that the read error is reported to the client as success. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7fbb608..6c10f28 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -284,7 +284,8 @@ static int raid1_end_read_request(struct bio *bio, unsigned int bytes_done, int * user-side. So if something waits for IO, then it will * wait for the 'master' bio. */ - set_bit(R1BIO_Uptodate, &r1_bio->state); + if (uptodate) + set_bit(R1BIO_Uptodate, &r1_bio->state); raid_end_bio_io(r1_bio); } else { -- cgit v1.1 From 4443ae10ca15d07922ceda622f03db8865fa3d13 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:28 -0800 Subject: [PATCH] md: auto-correct correctable read errors in raid10 Largely just a cross-port from raid1. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid10.c | 127 ++++++++++++++++++++++++++++++++++++++------ include/linux/raid/raid10.h | 2 + 2 files changed, 114 insertions(+), 15 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 1fa70c3..64bb4ddc 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -209,6 +209,7 @@ static void reschedule_retry(r10bio_t *r10_bio) spin_lock_irqsave(&conf->device_lock, flags); list_add(&r10_bio->retry_list, &conf->retry_list); + conf->nr_queued ++; spin_unlock_irqrestore(&conf->device_lock, flags); md_wakeup_thread(mddev->thread); @@ -254,9 +255,9 @@ static int raid10_end_read_request(struct bio *bio, unsigned int bytes_done, int /* * this branch is our 'one mirror IO has finished' event handler: */ - if (!uptodate) - md_error(r10_bio->mddev, conf->mirrors[dev].rdev); - else + update_head_pos(slot, r10_bio); + + if (uptodate) { /* * Set R10BIO_Uptodate in our master bio, so that * we will return a good error code to the higher @@ -267,15 +268,8 @@ static int raid10_end_read_request(struct bio *bio, unsigned int bytes_done, int * wait for the 'master' bio. */ set_bit(R10BIO_Uptodate, &r10_bio->state); - - update_head_pos(slot, r10_bio); - - /* - * we have only one bio on the read side - */ - if (uptodate) raid_end_bio_io(r10_bio); - else { + } else { /* * oops, read error: */ @@ -714,6 +708,33 @@ static void allow_barrier(conf_t *conf) wake_up(&conf->wait_barrier); } +static void freeze_array(conf_t *conf) +{ + /* stop syncio and normal IO and wait for everything to + * go quite. + * We increment barrier and nr_waiting, and then + * wait until barrier+nr_pending match nr_queued+2 + */ + spin_lock_irq(&conf->resync_lock); + conf->barrier++; + conf->nr_waiting++; + wait_event_lock_irq(conf->wait_barrier, + conf->barrier+conf->nr_pending == conf->nr_queued+2, + conf->resync_lock, + raid10_unplug(conf->mddev->queue)); + spin_unlock_irq(&conf->resync_lock); +} + +static void unfreeze_array(conf_t *conf) +{ + /* reverse the effect of the freeze */ + spin_lock_irq(&conf->resync_lock); + conf->barrier--; + conf->nr_waiting--; + wake_up(&conf->wait_barrier); + spin_unlock_irq(&conf->resync_lock); +} + static int make_request(request_queue_t *q, struct bio * bio) { mddev_t *mddev = q->queuedata; @@ -1338,6 +1359,7 @@ static void raid10d(mddev_t *mddev) break; r10_bio = list_entry(head->prev, r10bio_t, retry_list); list_del(head->prev); + conf->nr_queued--; spin_unlock_irqrestore(&conf->device_lock, flags); mddev = r10_bio->mddev; @@ -1350,6 +1372,78 @@ static void raid10d(mddev_t *mddev) unplug = 1; } else { int mirror; + /* we got a read error. Maybe the drive is bad. Maybe just + * the block and we can fix it. + * We freeze all other IO, and try reading the block from + * other devices. When we find one, we re-write + * and check it that fixes the read error. + * This is all done synchronously while the array is + * frozen. + */ + int sect = 0; /* Offset from r10_bio->sector */ + int sectors = r10_bio->sectors; + freeze_array(conf); + if (mddev->ro == 0) while(sectors) { + int s = sectors; + int sl = r10_bio->read_slot; + int success = 0; + + if (s > (PAGE_SIZE>>9)) + s = PAGE_SIZE >> 9; + + do { + int d = r10_bio->devs[sl].devnum; + rdev = conf->mirrors[d].rdev; + if (rdev && + test_bit(In_sync, &rdev->flags) && + sync_page_io(rdev->bdev, + r10_bio->devs[sl].addr + + sect + rdev->data_offset, + s<<9, + conf->tmppage, READ)) + success = 1; + else { + sl++; + if (sl == conf->copies) + sl = 0; + } + } while (!success && sl != r10_bio->read_slot); + + if (success) { + /* write it back and re-read */ + while (sl != r10_bio->read_slot) { + int d; + if (sl==0) + sl = conf->copies; + sl--; + d = r10_bio->devs[sl].devnum; + rdev = conf->mirrors[d].rdev; + if (rdev && + test_bit(In_sync, &rdev->flags)) { + if (sync_page_io(rdev->bdev, + r10_bio->devs[sl].addr + + sect + rdev->data_offset, + s<<9, conf->tmppage, WRITE) == 0 || + sync_page_io(rdev->bdev, + r10_bio->devs[sl].addr + + sect + rdev->data_offset, + s<<9, conf->tmppage, READ) == 0) { + /* Well, this device is dead */ + md_error(mddev, rdev); + } + } + } + } else { + /* Cannot read from anywhere -- bye bye array */ + md_error(mddev, conf->mirrors[r10_bio->devs[r10_bio->read_slot].devnum].rdev); + break; + } + sectors -= s; + sect += s; + } + + unfreeze_array(conf); + bio = r10_bio->devs[r10_bio->read_slot].bio; r10_bio->devs[r10_bio->read_slot].bio = NULL; bio_put(bio); @@ -1793,22 +1887,24 @@ static int run(mddev_t *mddev) * bookkeeping area. [whatever we allocate in run(), * should be freed in stop()] */ - conf = kmalloc(sizeof(conf_t), GFP_KERNEL); + conf = kzalloc(sizeof(conf_t), GFP_KERNEL); mddev->private = conf; if (!conf) { printk(KERN_ERR "raid10: couldn't allocate memory for %s\n", mdname(mddev)); goto out; } - memset(conf, 0, sizeof(*conf)); - conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks, + conf->mirrors = kzalloc(sizeof(struct mirror_info)*mddev->raid_disks, GFP_KERNEL); if (!conf->mirrors) { printk(KERN_ERR "raid10: couldn't allocate memory for %s\n", mdname(mddev)); goto out_free_conf; } - memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks); + + conf->tmppage = alloc_page(GFP_KERNEL); + if (!conf->tmppage) + goto out_free_conf; conf->near_copies = nc; conf->far_copies = fc; @@ -1918,6 +2014,7 @@ static int run(mddev_t *mddev) out_free_conf: if (conf->r10bio_pool) mempool_destroy(conf->r10bio_pool); + put_page(conf->tmppage); kfree(conf->mirrors); kfree(conf); mddev->private = NULL; diff --git a/include/linux/raid/raid10.h b/include/linux/raid/raid10.h index b660cbf..dfa5283 100644 --- a/include/linux/raid/raid10.h +++ b/include/linux/raid/raid10.h @@ -42,6 +42,7 @@ struct r10_private_data_s { spinlock_t resync_lock; int nr_pending; int nr_waiting; + int nr_queued; int barrier; sector_t next_resync; int fullsync; /* set to 1 if a full sync is needed, @@ -53,6 +54,7 @@ struct r10_private_data_s { mempool_t *r10bio_pool; mempool_t *r10buf_pool; + struct page *tmppage; }; typedef struct r10_private_data_s conf_t; -- cgit v1.1 From 0eb3ff12aa8a12538ef681dc83f4361636a0699f Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:29 -0800 Subject: [PATCH] md: raid10 read-error handling - resync and read-only Add in correct read-error handling for resync and read-only situations. When read-only, we don't over-write, so we need to mark the failed drive in the r10_bio so we don't re-try it. During resync, we always read all blocks, so if there is a read error, we simply over-write it with the good block that we found (assuming we found one). Note that the recovery case still isn't handled in an interesting way. There is nothing useful to do for the 2-copies case. If there are 3 or more copies, then we could try reading from one of the non-missing copies, but this is a bit complicated and very rarely would be used, so I'm leaving it for now. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid10.c | 56 ++++++++++++++++++++++++++++----------------- include/linux/raid/raid10.h | 7 ++++++ 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 64bb4ddc..3f8df2e 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -172,7 +172,7 @@ static void put_all_bios(conf_t *conf, r10bio_t *r10_bio) for (i = 0; i < conf->copies; i++) { struct bio **bio = & r10_bio->devs[i].bio; - if (*bio) + if (*bio && *bio != IO_BLOCKED) bio_put(*bio); *bio = NULL; } @@ -500,6 +500,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio) disk = r10_bio->devs[slot].devnum; while ((rdev = rcu_dereference(conf->mirrors[disk].rdev)) == NULL || + r10_bio->devs[slot].bio == IO_BLOCKED || !test_bit(In_sync, &rdev->flags)) { slot++; if (slot == conf->copies) { @@ -517,6 +518,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio) slot = 0; disk = r10_bio->devs[slot].devnum; while ((rdev=rcu_dereference(conf->mirrors[disk].rdev)) == NULL || + r10_bio->devs[slot].bio == IO_BLOCKED || !test_bit(In_sync, &rdev->flags)) { slot ++; if (slot == conf->copies) { @@ -537,6 +539,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio) if ((rdev=rcu_dereference(conf->mirrors[ndisk].rdev)) == NULL || + r10_bio->devs[nslot].bio == IO_BLOCKED || !test_bit(In_sync, &rdev->flags)) continue; @@ -1104,7 +1107,6 @@ abort: static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) { - int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private); conf_t *conf = mddev_to_conf(r10_bio->mddev); int i,d; @@ -1119,7 +1121,10 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) BUG(); update_head_pos(i, r10_bio); d = r10_bio->devs[i].devnum; - if (!uptodate) + + if (test_bit(BIO_UPTODATE, &bio->bi_flags)) + set_bit(R10BIO_Uptodate, &r10_bio->state); + else if (!test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery)) md_error(r10_bio->mddev, conf->mirrors[d].rdev); @@ -1209,25 +1214,30 @@ static void sync_request_write(mddev_t *mddev, r10bio_t *r10_bio) fbio = r10_bio->devs[i].bio; /* now find blocks with errors */ - for (i=first+1 ; i < conf->copies ; i++) { - int vcnt, j, d; + for (i=0 ; i < conf->copies ; i++) { + int j, d; + int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9); - if (!test_bit(BIO_UPTODATE, &r10_bio->devs[i].bio->bi_flags)) - continue; - /* We know that the bi_io_vec layout is the same for - * both 'first' and 'i', so we just compare them. - * All vec entries are PAGE_SIZE; - */ tbio = r10_bio->devs[i].bio; - vcnt = r10_bio->sectors >> (PAGE_SHIFT-9); - for (j = 0; j < vcnt; j++) - if (memcmp(page_address(fbio->bi_io_vec[j].bv_page), - page_address(tbio->bi_io_vec[j].bv_page), - PAGE_SIZE)) - break; - if (j == vcnt) + + if (tbio->bi_end_io != end_sync_read) + continue; + if (i == first) continue; - mddev->resync_mismatches += r10_bio->sectors; + if (test_bit(BIO_UPTODATE, &r10_bio->devs[i].bio->bi_flags)) { + /* We know that the bi_io_vec layout is the same for + * both 'first' and 'i', so we just compare them. + * All vec entries are PAGE_SIZE; + */ + for (j = 0; j < vcnt; j++) + if (memcmp(page_address(fbio->bi_io_vec[j].bv_page), + page_address(tbio->bi_io_vec[j].bv_page), + PAGE_SIZE)) + break; + if (j == vcnt) + continue; + mddev->resync_mismatches += r10_bio->sectors; + } if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) /* Don't fix anything. */ continue; @@ -1308,7 +1318,10 @@ static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio) atomic_inc(&conf->mirrors[d].rdev->nr_pending); md_sync_acct(conf->mirrors[d].rdev->bdev, wbio->bi_size >> 9); - generic_make_request(wbio); + if (test_bit(R10BIO_Uptodate, &r10_bio->state)) + generic_make_request(wbio); + else + bio_endio(wbio, wbio->bi_size, -EIO); } @@ -1445,7 +1458,8 @@ static void raid10d(mddev_t *mddev) unfreeze_array(conf); bio = r10_bio->devs[r10_bio->read_slot].bio; - r10_bio->devs[r10_bio->read_slot].bio = NULL; + r10_bio->devs[r10_bio->read_slot].bio = + mddev->ro ? IO_BLOCKED : NULL; bio_put(bio); mirror = read_balance(conf, r10_bio); if (mirror == -1) { diff --git a/include/linux/raid/raid10.h b/include/linux/raid/raid10.h index dfa5283..b110329 100644 --- a/include/linux/raid/raid10.h +++ b/include/linux/raid/raid10.h @@ -104,6 +104,13 @@ struct r10bio_s { } devs[0]; }; +/* when we get a read error on a read-only array, we redirect to another + * device without failing the first device, or trying to over-write to + * correct the read error. To keep track of bad blocks on a per-bio + * level, we store IO_BLOCKED in the appropriate 'bios' pointer + */ +#define IO_BLOCKED ((struct bio*)1) + /* bits for r10bio.state */ #define R10BIO_Uptodate 0 #define R10BIO_IsSync 1 -- cgit v1.1 From d7603b7e3a7f802c67f9190b2387d4d5d111ec14 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:30 -0800 Subject: [PATCH] md: make /proc/mdstat pollable With this patch it is possible to poll /proc/mdstat to detect arrays appearing or disappearing, to detect failures, recovery starting, recovery completing, and devices being added and removed. It is similar to the poll-ability of /proc/mounts, though different in that: We always report that the file is readable (because face it, it is, even if only for EOF). We report POLLPRI when there is a change so that select() can detect it as an exceptional event. Not only are these exceptional events, but that is the mechanism that the current 'mdadm' uses to watch for events (It also polls after a timeout). (We also report POLLERR like /proc/mounts). Finally, we only reset the per-file event counter when the start of the file is read, rather than when poll() returns an event. This is more robust as it means that an fd will continue to report activity to poll/select until the program clearly responds to that activity. md_new_event takes an 'mddev' which isn't currently used, but it will be soon. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 1364a1c..6101879 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -42,6 +42,7 @@ #include #include /* for invalidate_bdev */ #include +#include #include @@ -134,6 +135,24 @@ static struct block_device_operations md_fops; static int start_readonly; /* + * We have a system wide 'event count' that is incremented + * on any 'interesting' event, and readers of /proc/mdstat + * can use 'poll' or 'select' to find out when the event + * count increases. + * + * Events are: + * start array, stop array, error, add device, remove device, + * start build, activate spare + */ +DECLARE_WAIT_QUEUE_HEAD(md_event_waiters); +static atomic_t md_event_count; +void md_new_event(mddev_t *mddev) +{ + atomic_inc(&md_event_count); + wake_up(&md_event_waiters); +} + +/* * Enables to iterate over all existing md arrays * all_mddevs_lock protects this list. */ @@ -2111,6 +2130,7 @@ static int do_md_run(mddev_t * mddev) mddev->queue->make_request_fn = mddev->pers->make_request; mddev->changed = 1; + md_new_event(mddev); return 0; } @@ -2238,6 +2258,7 @@ static int do_md_stop(mddev_t * mddev, int ro) printk(KERN_INFO "md: %s switched to read-only mode.\n", mdname(mddev)); err = 0; + md_new_event(mddev); out: return err; } @@ -2712,6 +2733,7 @@ static int hot_remove_disk(mddev_t * mddev, dev_t dev) kick_rdev_from_array(rdev); md_update_sb(mddev); + md_new_event(mddev); return 0; busy: @@ -2802,7 +2824,7 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev) */ set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); md_wakeup_thread(mddev->thread); - + md_new_event(mddev); return 0; abort_unbind_export: @@ -3531,6 +3553,7 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev) set_bit(MD_RECOVERY_INTR, &mddev->recovery); set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); md_wakeup_thread(mddev->thread); + md_new_event(mddev); } /* seq_file implementation /proc/mdstat */ @@ -3671,12 +3694,17 @@ static void md_seq_stop(struct seq_file *seq, void *v) mddev_put(mddev); } +struct mdstat_info { + int event; +}; + static int md_seq_show(struct seq_file *seq, void *v) { mddev_t *mddev = v; sector_t size; struct list_head *tmp2; mdk_rdev_t *rdev; + struct mdstat_info *mi = seq->private; int i; struct bitmap *bitmap; @@ -3689,6 +3717,7 @@ static int md_seq_show(struct seq_file *seq, void *v) spin_unlock(&pers_lock); seq_printf(seq, "\n"); + mi->event = atomic_read(&md_event_count); return 0; } if (v == (void*)2) { @@ -3797,16 +3826,52 @@ static struct seq_operations md_seq_ops = { static int md_seq_open(struct inode *inode, struct file *file) { int error; + struct mdstat_info *mi = kmalloc(sizeof(*mi), GFP_KERNEL); + if (mi == NULL) + return -ENOMEM; error = seq_open(file, &md_seq_ops); + if (error) + kfree(mi); + else { + struct seq_file *p = file->private_data; + p->private = mi; + mi->event = atomic_read(&md_event_count); + } return error; } +static int md_seq_release(struct inode *inode, struct file *file) +{ + struct seq_file *m = file->private_data; + struct mdstat_info *mi = m->private; + m->private = NULL; + kfree(mi); + return seq_release(inode, file); +} + +static unsigned int mdstat_poll(struct file *filp, poll_table *wait) +{ + struct seq_file *m = filp->private_data; + struct mdstat_info *mi = m->private; + int mask; + + poll_wait(filp, &md_event_waiters, wait); + + /* always allow read */ + mask = POLLIN | POLLRDNORM; + + if (mi->event != atomic_read(&md_event_count)) + mask |= POLLERR | POLLPRI; + return mask; +} + static struct file_operations md_seq_fops = { .open = md_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = seq_release, + .release = md_seq_release, + .poll = mdstat_poll, }; int register_md_personality(int pnum, mdk_personality_t *p) @@ -4076,7 +4141,11 @@ static void md_do_sync(mddev_t *mddev) j += sectors; if (j>1) mddev->curr_resync = j; - + if (last_check == 0) + /* this is the earliers that rebuilt will be + * visible in /proc/mdstat + */ + md_new_event(mddev); if (last_check + window > io_sectors || j == max_sectors) continue; @@ -4262,6 +4331,7 @@ void md_check_recovery(mddev_t *mddev) mddev->recovery = 0; /* flag recovery needed just to double check */ set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); + md_new_event(mddev); goto unlock; } /* Clear some bits that don't mean anything, but @@ -4299,6 +4369,7 @@ void md_check_recovery(mddev_t *mddev) sprintf(nm, "rd%d", rdev->raid_disk); sysfs_create_link(&mddev->kobj, &rdev->kobj, nm); spares++; + md_new_event(mddev); } else break; } @@ -4331,9 +4402,9 @@ void md_check_recovery(mddev_t *mddev) mdname(mddev)); /* leave the spares where they are, it shouldn't hurt */ mddev->recovery = 0; - } else { + } else md_wakeup_thread(mddev->sync_thread); - } + md_new_event(mddev); } unlock: mddev_unlock(mddev); -- cgit v1.1 From 2d1f3b5d1b2cd11a162eb29645df749ec0036413 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:31 -0800 Subject: [PATCH] md: clean up 'page' related names in md Substitute: page_cache_get -> get_page page_cache_release -> put_page PAGE_CACHE_SHIFT -> PAGE_SHIFT PAGE_CACHE_SIZE -> PAGE_SIZE PAGE_CACHE_MASK -> PAGE_MASK __free_page -> put_page because we aren't using the page cache, we are just using pages. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/bitmap.c | 44 ++++++++++++++++++++++---------------------- drivers/md/md.c | 2 +- drivers/md/raid0.c | 2 +- drivers/md/raid1.c | 10 +++++----- drivers/md/raid10.c | 8 ++++---- drivers/md/raid5.c | 4 ++-- drivers/md/raid6main.c | 6 +++--- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index b65c36d..fc05d12 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -341,7 +341,7 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait) /* add to list to be waited for by daemon */ struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO); item->page = page; - page_cache_get(page); + get_page(page); spin_lock(&bitmap->write_lock); list_add(&item->list, &bitmap->complete_pages); spin_unlock(&bitmap->write_lock); @@ -357,10 +357,10 @@ static struct page *read_page(struct file *file, unsigned long index, struct inode *inode = file->f_mapping->host; struct page *page = NULL; loff_t isize = i_size_read(inode); - unsigned long end_index = isize >> PAGE_CACHE_SHIFT; + unsigned long end_index = isize >> PAGE_SHIFT; - PRINTK("read bitmap file (%dB @ %Lu)\n", (int)PAGE_CACHE_SIZE, - (unsigned long long)index << PAGE_CACHE_SHIFT); + PRINTK("read bitmap file (%dB @ %Lu)\n", (int)PAGE_SIZE, + (unsigned long long)index << PAGE_SHIFT); page = read_cache_page(inode->i_mapping, index, (filler_t *)inode->i_mapping->a_ops->readpage, file); @@ -368,7 +368,7 @@ static struct page *read_page(struct file *file, unsigned long index, goto out; wait_on_page_locked(page); if (!PageUptodate(page) || PageError(page)) { - page_cache_release(page); + put_page(page); page = ERR_PTR(-EIO); goto out; } @@ -376,14 +376,14 @@ static struct page *read_page(struct file *file, unsigned long index, if (index > end_index) /* we have read beyond EOF */ *bytes_read = 0; else if (index == end_index) /* possible short read */ - *bytes_read = isize & ~PAGE_CACHE_MASK; + *bytes_read = isize & ~PAGE_MASK; else - *bytes_read = PAGE_CACHE_SIZE; /* got a full page */ + *bytes_read = PAGE_SIZE; /* got a full page */ out: if (IS_ERR(page)) printk(KERN_ALERT "md: bitmap read error: (%dB @ %Lu): %ld\n", - (int)PAGE_CACHE_SIZE, - (unsigned long long)index << PAGE_CACHE_SHIFT, + (int)PAGE_SIZE, + (unsigned long long)index << PAGE_SHIFT, PTR_ERR(page)); return page; } @@ -558,7 +558,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, spin_unlock_irqrestore(&bitmap->lock, flags); return; } - page_cache_get(bitmap->sb_page); + get_page(bitmap->sb_page); spin_unlock_irqrestore(&bitmap->lock, flags); sb = (bitmap_super_t *)kmap(bitmap->sb_page); switch (op) { @@ -569,7 +569,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, default: BUG(); } kunmap(bitmap->sb_page); - page_cache_release(bitmap->sb_page); + put_page(bitmap->sb_page); } /* @@ -622,12 +622,12 @@ static void bitmap_file_unmap(struct bitmap *bitmap) while (pages--) if (map[pages]->index != 0) /* 0 is sb_page, release it below */ - page_cache_release(map[pages]); + put_page(map[pages]); kfree(map); kfree(attr); if (sb_page) - page_cache_release(sb_page); + put_page(sb_page); } static void bitmap_stop_daemon(struct bitmap *bitmap); @@ -654,7 +654,7 @@ static void drain_write_queues(struct bitmap *bitmap) while ((item = dequeue_page(bitmap))) { /* don't bother to wait */ - page_cache_release(item->page); + put_page(item->page); mempool_free(item, bitmap->write_pool); } @@ -763,7 +763,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block) /* make sure the page stays cached until it gets written out */ if (! (get_page_attr(bitmap, page) & BITMAP_PAGE_DIRTY)) - page_cache_get(page); + get_page(page); /* set the bit */ kaddr = kmap_atomic(page, KM_USER0); @@ -938,7 +938,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) if (ret) { kunmap(page); /* release, page not in filemap yet */ - page_cache_release(page); + put_page(page); goto out; } } @@ -1043,7 +1043,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) /* skip this page unless it's marked as needing cleaning */ if (!((attr=get_page_attr(bitmap, page)) & BITMAP_PAGE_CLEAN)) { if (attr & BITMAP_PAGE_NEEDWRITE) { - page_cache_get(page); + get_page(page); clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); } spin_unlock_irqrestore(&bitmap->lock, flags); @@ -1057,13 +1057,13 @@ int bitmap_daemon_work(struct bitmap *bitmap) default: bitmap_file_kick(bitmap); } - page_cache_release(page); + put_page(page); } continue; } /* grab the new page, sync and release the old */ - page_cache_get(page); + get_page(page); if (lastpage != NULL) { if (get_page_attr(bitmap, lastpage) & BITMAP_PAGE_NEEDWRITE) { clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); @@ -1078,7 +1078,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) spin_unlock_irqrestore(&bitmap->lock, flags); } kunmap(lastpage); - page_cache_release(lastpage); + put_page(lastpage); if (err) bitmap_file_kick(bitmap); } else @@ -1133,7 +1133,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) spin_unlock_irqrestore(&bitmap->lock, flags); } - page_cache_release(lastpage); + put_page(lastpage); } return err; @@ -1184,7 +1184,7 @@ static void bitmap_writeback_daemon(mddev_t *mddev) PRINTK("finished page writeback: %p\n", page); err = PageError(page); - page_cache_release(page); + put_page(page); if (err) { printk(KERN_WARNING "%s: bitmap file writeback " "failed (page %lu): %d\n", diff --git a/drivers/md/md.c b/drivers/md/md.c index 6101879..c3ac67c 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -339,7 +339,7 @@ static int alloc_disk_sb(mdk_rdev_t * rdev) static void free_disk_sb(mdk_rdev_t * rdev) { if (rdev->sb_page) { - page_cache_release(rdev->sb_page); + put_page(rdev->sb_page); rdev->sb_loaded = 0; rdev->sb_page = NULL; rdev->sb_offset = 0; diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index fece327..a2c2e18 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -361,7 +361,7 @@ static int raid0_run (mddev_t *mddev) * chunksize should be used in that case. */ { - int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_CACHE_SIZE; + int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_SIZE; if (mddev->queue->backing_dev_info.ra_pages < 2* stripe) mddev->queue->backing_dev_info.ra_pages = 2* stripe; } diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 6c10f28..bbe0b81 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -139,7 +139,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) out_free_pages: for (i=0; i < RESYNC_PAGES ; i++) for (j=0 ; j < pi->raid_disks; j++) - __free_page(r1_bio->bios[j]->bi_io_vec[i].bv_page); + put_page(r1_bio->bios[j]->bi_io_vec[i].bv_page); j = -1; out_free_bio: while ( ++j < pi->raid_disks ) @@ -159,7 +159,7 @@ static void r1buf_pool_free(void *__r1_bio, void *data) if (j == 0 || r1bio->bios[j]->bi_io_vec[i].bv_page != r1bio->bios[0]->bi_io_vec[i].bv_page) - __free_page(r1bio->bios[j]->bi_io_vec[i].bv_page); + put_page(r1bio->bios[j]->bi_io_vec[i].bv_page); } for (i=0 ; i < pi->raid_disks; i++) bio_put(r1bio->bios[i]); @@ -384,7 +384,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int /* free extra copy of the data pages */ int i = bio->bi_vcnt; while (i--) - __free_page(bio->bi_io_vec[i].bv_page); + put_page(bio->bi_io_vec[i].bv_page); } /* clear the bitmap if all writes complete successfully */ bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector, @@ -733,7 +733,7 @@ static struct page **alloc_behind_pages(struct bio *bio) do_sync_io: if (pages) for (i = 0; i < bio->bi_vcnt && pages[i]; i++) - __free_page(pages[i]); + put_page(pages[i]); kfree(pages); PRINTK("%dB behind alloc failed, doing sync I/O\n", bio->bi_size); return NULL; @@ -1893,7 +1893,7 @@ out_free_conf: if (conf->r1bio_pool) mempool_destroy(conf->r1bio_pool); kfree(conf->mirrors); - __free_page(conf->tmppage); + put_page(conf->tmppage); kfree(conf->poolinfo); kfree(conf); mddev->private = NULL; diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 3f8df2e..ce729d6 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -134,10 +134,10 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data) out_free_pages: for ( ; i > 0 ; i--) - __free_page(bio->bi_io_vec[i-1].bv_page); + put_page(bio->bi_io_vec[i-1].bv_page); while (j--) for (i = 0; i < RESYNC_PAGES ; i++) - __free_page(r10_bio->devs[j].bio->bi_io_vec[i].bv_page); + put_page(r10_bio->devs[j].bio->bi_io_vec[i].bv_page); j = -1; out_free_bio: while ( ++j < nalloc ) @@ -157,7 +157,7 @@ static void r10buf_pool_free(void *__r10_bio, void *data) struct bio *bio = r10bio->devs[j].bio; if (bio) { for (i = 0; i < RESYNC_PAGES; i++) { - __free_page(bio->bi_io_vec[i].bv_page); + put_page(bio->bi_io_vec[i].bv_page); bio->bi_io_vec[i].bv_page = NULL; } bio_put(bio); @@ -2015,7 +2015,7 @@ static int run(mddev_t *mddev) * maybe... */ { - int stripe = conf->raid_disks * mddev->chunk_size / PAGE_CACHE_SIZE; + int stripe = conf->raid_disks * mddev->chunk_size / PAGE_SIZE; stripe /= conf->near_copies; if (mddev->queue->backing_dev_info.ra_pages < 2* stripe) mddev->queue->backing_dev_info.ra_pages = 2* stripe; diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 0222ba1..ec5186f 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -167,7 +167,7 @@ static void shrink_buffers(struct stripe_head *sh, int num) if (!p) continue; sh->dev[i].page = NULL; - page_cache_release(p); + put_page(p); } } @@ -1956,7 +1956,7 @@ static int run(mddev_t *mddev) */ { int stripe = (mddev->raid_disks-1) * mddev->chunk_size - / PAGE_CACHE_SIZE; + / PAGE_SIZE; if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe) mddev->queue->backing_dev_info.ra_pages = 2 * stripe; } diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index b5b7a8d..4062fc1 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -186,7 +186,7 @@ static void shrink_buffers(struct stripe_head *sh, int num) if (!p) continue; sh->dev[i].page = NULL; - page_cache_release(p); + put_page(p); } } @@ -2069,7 +2069,7 @@ static int run(mddev_t *mddev) */ { int stripe = (mddev->raid_disks-2) * mddev->chunk_size - / PAGE_CACHE_SIZE; + / PAGE_SIZE; if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe) mddev->queue->backing_dev_info.ra_pages = 2 * stripe; } @@ -2084,7 +2084,7 @@ abort: if (conf) { print_raid6_conf(conf); if (conf->spare_page) - page_cache_release(conf->spare_page); + put_page(conf->spare_page); if (conf->stripe_hashtbl) free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER); -- cgit v1.1 From 9ffae0cf3ea02f75d163922accfd3e592d87adde Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:32 -0800 Subject: [PATCH] md: convert md to use kzalloc throughout Replace multiple kmalloc/memset pairs with kzalloc calls. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/bitmap.c | 11 +++-------- drivers/md/linear.c | 3 +-- drivers/md/md.c | 10 +++------- drivers/md/multipath.c | 10 +++------- drivers/md/raid0.c | 9 ++------- drivers/md/raid1.c | 20 ++++++-------------- drivers/md/raid10.c | 6 ++---- drivers/md/raid5.c | 8 ++++---- 8 files changed, 24 insertions(+), 53 deletions(-) diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index fc05d12..c3faa6a 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -887,12 +887,10 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) if (!bitmap->filemap) goto out; - bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL); + bitmap->filemap_attr = kzalloc(sizeof(long) * num_pages, GFP_KERNEL); if (!bitmap->filemap_attr) goto out; - memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages); - oldindex = ~0L; for (i = 0; i < chunks; i++) { @@ -1557,12 +1555,10 @@ int bitmap_create(mddev_t *mddev) BUG_ON(file && mddev->bitmap_offset); - bitmap = kmalloc(sizeof(*bitmap), GFP_KERNEL); + bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL); if (!bitmap) return -ENOMEM; - memset(bitmap, 0, sizeof(*bitmap)); - spin_lock_init(&bitmap->lock); bitmap->mddev = mddev; @@ -1603,12 +1599,11 @@ int bitmap_create(mddev_t *mddev) #ifdef INJECT_FATAL_FAULT_1 bitmap->bp = NULL; #else - bitmap->bp = kmalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL); + bitmap->bp = kzalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL); #endif err = -ENOMEM; if (!bitmap->bp) goto error; - memset(bitmap->bp, 0, pages * sizeof(*bitmap->bp)); bitmap->flags |= BITMAP_ACTIVE; diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 946efef..f46c98d 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c @@ -121,11 +121,10 @@ static int linear_run (mddev_t *mddev) sector_t curr_offset; struct list_head *tmp; - conf = kmalloc (sizeof (*conf) + mddev->raid_disks*sizeof(dev_info_t), + conf = kzalloc (sizeof (*conf) + mddev->raid_disks*sizeof(dev_info_t), GFP_KERNEL); if (!conf) goto out; - memset(conf, 0, sizeof(*conf) + mddev->raid_disks*sizeof(dev_info_t)); mddev->private = conf; cnt = 0; diff --git a/drivers/md/md.c b/drivers/md/md.c index c3ac67c..8c378b6 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -228,12 +228,10 @@ static mddev_t * mddev_find(dev_t unit) } spin_unlock(&all_mddevs_lock); - new = (mddev_t *) kmalloc(sizeof(*new), GFP_KERNEL); + new = kzalloc(sizeof(*new), GFP_KERNEL); if (!new) return NULL; - memset(new, 0, sizeof(*new)); - new->unit = unit; if (MAJOR(unit) == MD_MAJOR) new->md_minor = MINOR(unit); @@ -1620,12 +1618,11 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi mdk_rdev_t *rdev; sector_t size; - rdev = (mdk_rdev_t *) kmalloc(sizeof(*rdev), GFP_KERNEL); + rdev = kzalloc(sizeof(*rdev), GFP_KERNEL); if (!rdev) { printk(KERN_ERR "md: could not alloc mem for new device!\n"); return ERR_PTR(-ENOMEM); } - memset(rdev, 0, sizeof(*rdev)); if ((err = alloc_disk_sb(rdev))) goto abort_free; @@ -3505,11 +3502,10 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev, { mdk_thread_t *thread; - thread = kmalloc(sizeof(mdk_thread_t), GFP_KERNEL); + thread = kzalloc(sizeof(mdk_thread_t), GFP_KERNEL); if (!thread) return NULL; - memset(thread, 0, sizeof(mdk_thread_t)); init_waitqueue_head(&thread->wqueue); thread->run = run; diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index 145cdc5..97a56aa 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c @@ -41,9 +41,7 @@ static mdk_personality_t multipath_personality; static void *mp_pool_alloc(gfp_t gfp_flags, void *data) { struct multipath_bh *mpb; - mpb = kmalloc(sizeof(*mpb), gfp_flags); - if (mpb) - memset(mpb, 0, sizeof(*mpb)); + mpb = kzalloc(sizeof(*mpb), gfp_flags); return mpb; } @@ -444,7 +442,7 @@ static int multipath_run (mddev_t *mddev) * should be freed in multipath_stop()] */ - conf = kmalloc(sizeof(multipath_conf_t), GFP_KERNEL); + conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL); mddev->private = conf; if (!conf) { printk(KERN_ERR @@ -452,9 +450,8 @@ static int multipath_run (mddev_t *mddev) mdname(mddev)); goto out; } - memset(conf, 0, sizeof(*conf)); - conf->multipaths = kmalloc(sizeof(struct multipath_info)*mddev->raid_disks, + conf->multipaths = kzalloc(sizeof(struct multipath_info)*mddev->raid_disks, GFP_KERNEL); if (!conf->multipaths) { printk(KERN_ERR @@ -462,7 +459,6 @@ static int multipath_run (mddev_t *mddev) mdname(mddev)); goto out_free_conf; } - memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks); conf->working_disks = 0; ITERATE_RDEV(mddev,rdev,tmp) { diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index a2c2e18..b4eaa67 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -113,21 +113,16 @@ static int create_strip_zones (mddev_t *mddev) } printk("raid0: FINAL %d zones\n", conf->nr_strip_zones); - conf->strip_zone = kmalloc(sizeof(struct strip_zone)* + conf->strip_zone = kzalloc(sizeof(struct strip_zone)* conf->nr_strip_zones, GFP_KERNEL); if (!conf->strip_zone) return 1; - conf->devlist = kmalloc(sizeof(mdk_rdev_t*)* + conf->devlist = kzalloc(sizeof(mdk_rdev_t*)* conf->nr_strip_zones*mddev->raid_disks, GFP_KERNEL); if (!conf->devlist) return 1; - memset(conf->strip_zone, 0,sizeof(struct strip_zone)* - conf->nr_strip_zones); - memset(conf->devlist, 0, - sizeof(mdk_rdev_t*) * conf->nr_strip_zones * mddev->raid_disks); - /* The first zone must contain all devices, so here we check that * there is a proper alignment of slots to devices and find them all */ diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index bbe0b81..c42ef1c 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -61,10 +61,8 @@ static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data) int size = offsetof(r1bio_t, bios[pi->raid_disks]); /* allocate a r1bio with room for raid_disks entries in the bios array */ - r1_bio = kmalloc(size, gfp_flags); - if (r1_bio) - memset(r1_bio, 0, size); - else + r1_bio = kzalloc(size, gfp_flags); + if (!r1_bio) unplug_slaves(pi->mddev); return r1_bio; @@ -711,13 +709,11 @@ static struct page **alloc_behind_pages(struct bio *bio) { int i; struct bio_vec *bvec; - struct page **pages = kmalloc(bio->bi_vcnt * sizeof(struct page *), + struct page **pages = kzalloc(bio->bi_vcnt * sizeof(struct page *), GFP_NOIO); if (unlikely(!pages)) goto do_sync_io; - memset(pages, 0, bio->bi_vcnt * sizeof(struct page *)); - bio_for_each_segment(bvec, bio, i) { pages[i] = alloc_page(GFP_NOIO); if (unlikely(!pages[i])) @@ -1770,19 +1766,16 @@ static int run(mddev_t *mddev) * bookkeeping area. [whatever we allocate in run(), * should be freed in stop()] */ - conf = kmalloc(sizeof(conf_t), GFP_KERNEL); + conf = kzalloc(sizeof(conf_t), GFP_KERNEL); mddev->private = conf; if (!conf) goto out_no_mem; - memset(conf, 0, sizeof(*conf)); - conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks, + conf->mirrors = kzalloc(sizeof(struct mirror_info)*mddev->raid_disks, GFP_KERNEL); if (!conf->mirrors) goto out_no_mem; - memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks); - conf->tmppage = alloc_page(GFP_KERNEL); if (!conf->tmppage) goto out_no_mem; @@ -1992,13 +1985,12 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks) kfree(newpoolinfo); return -ENOMEM; } - newmirrors = kmalloc(sizeof(struct mirror_info) * raid_disks, GFP_KERNEL); + newmirrors = kzalloc(sizeof(struct mirror_info) * raid_disks, GFP_KERNEL); if (!newmirrors) { kfree(newpoolinfo); mempool_destroy(newpool); return -ENOMEM; } - memset(newmirrors, 0, sizeof(struct mirror_info)*raid_disks); raise_barrier(conf); diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index ce729d6..254b50e 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -59,10 +59,8 @@ static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data) int size = offsetof(struct r10bio_s, devs[conf->copies]); /* allocate a r10bio with room for raid_disks entries in the bios array */ - r10_bio = kmalloc(size, gfp_flags); - if (r10_bio) - memset(r10_bio, 0, size); - else + r10_bio = kzalloc(size, gfp_flags); + if (!r10_bio) unplug_slaves(conf->mddev); return r10_bio; diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index ec5186f..9fc5048 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -1827,12 +1827,12 @@ static int run(mddev_t *mddev) return -EIO; } - mddev->private = kmalloc (sizeof (raid5_conf_t) - + mddev->raid_disks * sizeof(struct disk_info), - GFP_KERNEL); + mddev->private = kzalloc(sizeof (raid5_conf_t) + + mddev->raid_disks * sizeof(struct disk_info), + GFP_KERNEL); if ((conf = mddev->private) == NULL) goto abort; - memset (conf, 0, sizeof (*conf) + mddev->raid_disks * sizeof(struct disk_info) ); + conf->mddev = mddev; if ((conf->stripe_hashtbl = (struct stripe_head **) __get_free_pages(GFP_ATOMIC, HASH_PAGES_ORDER)) == NULL) -- cgit v1.1 From fccddba060f2b4916a30aa27acc3d03b01bb981e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:33 -0800 Subject: [PATCH] md: tidy up raid5/6 hash table code - replace open-coded hash chain with hlist macros - Fix hash-table size at one page - it is already quite generous, so there will never be a need to use multiple pages, so no need for __get_free_pages No functional change. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid5.c | 40 ++++++++++++++-------------------------- drivers/md/raid6main.c | 46 +++++++++++++++++----------------------------- include/linux/raid/raid5.h | 4 ++-- 3 files changed, 33 insertions(+), 57 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 9fc5048..6e4db95 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -35,12 +35,10 @@ #define STRIPE_SHIFT (PAGE_SHIFT - 9) #define STRIPE_SECTORS (STRIPE_SIZE>>9) #define IO_THRESHOLD 1 -#define HASH_PAGES 1 -#define HASH_PAGES_ORDER 0 -#define NR_HASH (HASH_PAGES * PAGE_SIZE / sizeof(struct stripe_head *)) +#define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head)) #define HASH_MASK (NR_HASH - 1) -#define stripe_hash(conf, sect) ((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK]) +#define stripe_hash(conf, sect) (&((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK])) /* bio's attached to a stripe+device for I/O are linked together in bi_sector * order without overlap. There may be several bio's per stripe+device, and @@ -113,29 +111,21 @@ static void release_stripe(struct stripe_head *sh) spin_unlock_irqrestore(&conf->device_lock, flags); } -static void remove_hash(struct stripe_head *sh) +static inline void remove_hash(struct stripe_head *sh) { PRINTK("remove_hash(), stripe %llu\n", (unsigned long long)sh->sector); - if (sh->hash_pprev) { - if (sh->hash_next) - sh->hash_next->hash_pprev = sh->hash_pprev; - *sh->hash_pprev = sh->hash_next; - sh->hash_pprev = NULL; - } + hlist_del_init(&sh->hash); } -static __inline__ void insert_hash(raid5_conf_t *conf, struct stripe_head *sh) +static inline void insert_hash(raid5_conf_t *conf, struct stripe_head *sh) { - struct stripe_head **shp = &stripe_hash(conf, sh->sector); + struct hlist_head *hp = stripe_hash(conf, sh->sector); PRINTK("insert_hash(), stripe %llu\n", (unsigned long long)sh->sector); CHECK_DEVLOCK(); - if ((sh->hash_next = *shp) != NULL) - (*shp)->hash_pprev = &sh->hash_next; - *shp = sh; - sh->hash_pprev = shp; + hlist_add_head(&sh->hash, hp); } @@ -228,10 +218,11 @@ static inline void init_stripe(struct stripe_head *sh, sector_t sector, int pd_i static struct stripe_head *__find_stripe(raid5_conf_t *conf, sector_t sector) { struct stripe_head *sh; + struct hlist_node *hn; CHECK_DEVLOCK(); PRINTK("__find_stripe, sector %llu\n", (unsigned long long)sector); - for (sh = stripe_hash(conf, sector); sh; sh = sh->hash_next) + hlist_for_each_entry(sh, hn, stripe_hash(conf, sector), hash) if (sh->sector == sector) return sh; PRINTK("__stripe %llu not in cache\n", (unsigned long long)sector); @@ -1835,9 +1826,8 @@ static int run(mddev_t *mddev) conf->mddev = mddev; - if ((conf->stripe_hashtbl = (struct stripe_head **) __get_free_pages(GFP_ATOMIC, HASH_PAGES_ORDER)) == NULL) + if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL) goto abort; - memset(conf->stripe_hashtbl, 0, HASH_PAGES * PAGE_SIZE); spin_lock_init(&conf->device_lock); init_waitqueue_head(&conf->wait_for_stripe); @@ -1972,9 +1962,7 @@ static int run(mddev_t *mddev) abort: if (conf) { print_raid5_conf(conf); - if (conf->stripe_hashtbl) - free_pages((unsigned long) conf->stripe_hashtbl, - HASH_PAGES_ORDER); + kfree(conf->stripe_hashtbl); kfree(conf); } mddev->private = NULL; @@ -1991,7 +1979,7 @@ static int stop(mddev_t *mddev) md_unregister_thread(mddev->thread); mddev->thread = NULL; shrink_stripes(conf); - free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER); + kfree(conf->stripe_hashtbl); blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ sysfs_remove_group(&mddev->kobj, &raid5_attrs_group); kfree(conf); @@ -2019,12 +2007,12 @@ static void print_sh (struct stripe_head *sh) static void printall (raid5_conf_t *conf) { struct stripe_head *sh; + struct hlist_node *hn; int i; spin_lock_irq(&conf->device_lock); for (i = 0; i < NR_HASH; i++) { - sh = conf->stripe_hashtbl[i]; - for (; sh; sh = sh->hash_next) { + hlist_for_each_entry(sh, hn, &conf->stripe_hashtbl[i], hash) { if (sh->raid_conf != conf) continue; print_sh(sh); diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 4062fc1..79b5244 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -40,12 +40,10 @@ #define STRIPE_SHIFT (PAGE_SHIFT - 9) #define STRIPE_SECTORS (STRIPE_SIZE>>9) #define IO_THRESHOLD 1 -#define HASH_PAGES 1 -#define HASH_PAGES_ORDER 0 -#define NR_HASH (HASH_PAGES * PAGE_SIZE / sizeof(struct stripe_head *)) +#define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head)) #define HASH_MASK (NR_HASH - 1) -#define stripe_hash(conf, sect) ((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK]) +#define stripe_hash(conf, sect) (&((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK])) /* bio's attached to a stripe+device for I/O are linked together in bi_sector * order without overlap. There may be several bio's per stripe+device, and @@ -132,29 +130,21 @@ static void release_stripe(struct stripe_head *sh) spin_unlock_irqrestore(&conf->device_lock, flags); } -static void remove_hash(struct stripe_head *sh) +static inline void remove_hash(struct stripe_head *sh) { PRINTK("remove_hash(), stripe %llu\n", (unsigned long long)sh->sector); - if (sh->hash_pprev) { - if (sh->hash_next) - sh->hash_next->hash_pprev = sh->hash_pprev; - *sh->hash_pprev = sh->hash_next; - sh->hash_pprev = NULL; - } + hlist_del_init(&sh->hash); } -static __inline__ void insert_hash(raid6_conf_t *conf, struct stripe_head *sh) +static inline void insert_hash(raid6_conf_t *conf, struct stripe_head *sh) { - struct stripe_head **shp = &stripe_hash(conf, sh->sector); + struct hlist_head *hp = stripe_hash(conf, sh->sector); PRINTK("insert_hash(), stripe %llu\n", (unsigned long long)sh->sector); CHECK_DEVLOCK(); - if ((sh->hash_next = *shp) != NULL) - (*shp)->hash_pprev = &sh->hash_next; - *shp = sh; - sh->hash_pprev = shp; + hlist_add_head(&sh->hash, hp); } @@ -247,10 +237,11 @@ static inline void init_stripe(struct stripe_head *sh, sector_t sector, int pd_i static struct stripe_head *__find_stripe(raid6_conf_t *conf, sector_t sector) { struct stripe_head *sh; + struct hlist_node *hn; CHECK_DEVLOCK(); PRINTK("__find_stripe, sector %llu\n", (unsigned long long)sector); - for (sh = stripe_hash(conf, sector); sh; sh = sh->hash_next) + hlist_for_each_entry (sh, hn, stripe_hash(conf, sector), hash) if (sh->sector == sector) return sh; PRINTK("__stripe %llu not in cache\n", (unsigned long long)sector); @@ -1931,17 +1922,15 @@ static int run(mddev_t *mddev) return -EIO; } - mddev->private = kmalloc (sizeof (raid6_conf_t) - + mddev->raid_disks * sizeof(struct disk_info), - GFP_KERNEL); + mddev->private = kzalloc(sizeof (raid6_conf_t) + + mddev->raid_disks * sizeof(struct disk_info), + GFP_KERNEL); if ((conf = mddev->private) == NULL) goto abort; - memset (conf, 0, sizeof (*conf) + mddev->raid_disks * sizeof(struct disk_info) ); conf->mddev = mddev; - if ((conf->stripe_hashtbl = (struct stripe_head **) __get_free_pages(GFP_ATOMIC, HASH_PAGES_ORDER)) == NULL) + if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL) goto abort; - memset(conf->stripe_hashtbl, 0, HASH_PAGES * PAGE_SIZE); conf->spare_page = alloc_page(GFP_KERNEL); if (!conf->spare_page) @@ -2085,9 +2074,7 @@ abort: print_raid6_conf(conf); if (conf->spare_page) put_page(conf->spare_page); - if (conf->stripe_hashtbl) - free_pages((unsigned long) conf->stripe_hashtbl, - HASH_PAGES_ORDER); + kfree(conf->stripe_hashtbl); kfree(conf); } mddev->private = NULL; @@ -2104,7 +2091,7 @@ static int stop (mddev_t *mddev) md_unregister_thread(mddev->thread); mddev->thread = NULL; shrink_stripes(conf); - free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER); + kfree(conf->stripe_hashtbl); blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ kfree(conf); mddev->private = NULL; @@ -2131,12 +2118,13 @@ static void print_sh (struct seq_file *seq, struct stripe_head *sh) static void printall (struct seq_file *seq, raid6_conf_t *conf) { struct stripe_head *sh; + struct hlist_node *hn; int i; spin_lock_irq(&conf->device_lock); for (i = 0; i < NR_HASH; i++) { sh = conf->stripe_hashtbl[i]; - for (; sh; sh = sh->hash_next) { + hlist_for_each_entry(sh, hn, &conf->stripe_hashtbl[i], hash) { if (sh->raid_conf != conf) continue; print_sh(seq, sh); diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h index 28fcd75..394da82 100644 --- a/include/linux/raid/raid5.h +++ b/include/linux/raid/raid5.h @@ -126,7 +126,7 @@ */ struct stripe_head { - struct stripe_head *hash_next, **hash_pprev; /* hash pointers */ + struct hlist_node hash; struct list_head lru; /* inactive_list or handle_list */ struct raid5_private_data *raid_conf; sector_t sector; /* sector of this row */ @@ -204,7 +204,7 @@ struct disk_info { }; struct raid5_private_data { - struct stripe_head **stripe_hashtbl; + struct hlist_head *stripe_hashtbl; mddev_t *mddev; struct disk_info *spare; int chunk_size, level, algorithm; -- cgit v1.1 From ea03aff93b4117c2ddfb91b34b44a44e19df24cd Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:34 -0800 Subject: [PATCH] md: convert various kmap calls to kmap_atomic Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/bitmap.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index c3faa6a..519b1bf 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -406,11 +406,11 @@ int bitmap_update_sb(struct bitmap *bitmap) return 0; } spin_unlock_irqrestore(&bitmap->lock, flags); - sb = (bitmap_super_t *)kmap(bitmap->sb_page); + sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); sb->events = cpu_to_le64(bitmap->mddev->events); if (!bitmap->mddev->degraded) sb->events_cleared = cpu_to_le64(bitmap->mddev->events); - kunmap(bitmap->sb_page); + kunmap_atomic(sb, KM_USER0); return write_page(bitmap, bitmap->sb_page, 1); } @@ -421,7 +421,7 @@ void bitmap_print_sb(struct bitmap *bitmap) if (!bitmap || !bitmap->sb_page) return; - sb = (bitmap_super_t *)kmap(bitmap->sb_page); + sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); @@ -440,7 +440,7 @@ void bitmap_print_sb(struct bitmap *bitmap) printk(KERN_DEBUG " sync size: %llu KB\n", (unsigned long long)le64_to_cpu(sb->sync_size)/2); printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind)); - kunmap(bitmap->sb_page); + kunmap_atomic(sb, KM_USER0); } /* read the superblock from the bitmap file and initialize some bitmap fields */ @@ -466,7 +466,7 @@ static int bitmap_read_sb(struct bitmap *bitmap) return err; } - sb = (bitmap_super_t *)kmap(bitmap->sb_page); + sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); if (bytes_read < sizeof(*sb)) { /* short read */ printk(KERN_INFO "%s: bitmap file superblock truncated\n", @@ -535,7 +535,7 @@ success: bitmap->events_cleared = bitmap->mddev->events; err = 0; out: - kunmap(bitmap->sb_page); + kunmap_atomic(sb, KM_USER0); if (err) bitmap_print_sb(bitmap); return err; @@ -560,7 +560,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, } get_page(bitmap->sb_page); spin_unlock_irqrestore(&bitmap->lock, flags); - sb = (bitmap_super_t *)kmap(bitmap->sb_page); + sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); switch (op) { case MASK_SET: sb->state |= bits; break; @@ -568,7 +568,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits, break; default: BUG(); } - kunmap(bitmap->sb_page); + kunmap_atomic(sb, KM_USER0); put_page(bitmap->sb_page); } @@ -854,6 +854,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) unsigned long bytes, offset, dummy; int outofdate; int ret = -ENOSPC; + void *paddr; chunks = bitmap->chunks; file = bitmap->file; @@ -899,8 +900,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) bit = file_page_offset(i); if (index != oldindex) { /* this is a new page, read it in */ /* unmap the old page, we're done with it */ - if (oldpage != NULL) - kunmap(oldpage); if (index == 0) { /* * if we're here then the superblock page @@ -923,18 +922,18 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) oldindex = index; oldpage = page; - kmap(page); if (outofdate) { /* * if bitmap is out of date, dirty the * whole page and write it out */ - memset(page_address(page) + offset, 0xff, + paddr = kmap_atomic(page, KM_USER0); + memset(paddr + offset, 0xff, PAGE_SIZE - offset); + kunmap_atomic(paddr, KM_USER0); ret = write_page(bitmap, page, 1); if (ret) { - kunmap(page); /* release, page not in filemap yet */ put_page(page); goto out; @@ -943,10 +942,12 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) bitmap->filemap[bitmap->file_pages++] = page; } + paddr = kmap_atomic(page, KM_USER0); if (bitmap->flags & BITMAP_HOSTENDIAN) - b = test_bit(bit, page_address(page)); + b = test_bit(bit, paddr); else - b = ext2_test_bit(bit, page_address(page)); + b = ext2_test_bit(bit, paddr); + kunmap_atomic(paddr, KM_USER0); if (b) { /* if the disk bit is set, set the memory bit */ bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), @@ -961,9 +962,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) ret = 0; bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET); - if (page) /* unmap the last page */ - kunmap(page); - if (bit_cnt) { /* Kick recovery if any bits were set */ set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); md_wakeup_thread(bitmap->mddev->thread); @@ -1019,6 +1017,7 @@ int bitmap_daemon_work(struct bitmap *bitmap) int err = 0; int blocks; int attr; + void *paddr; if (bitmap == NULL) return 0; @@ -1075,14 +1074,12 @@ int bitmap_daemon_work(struct bitmap *bitmap) set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); spin_unlock_irqrestore(&bitmap->lock, flags); } - kunmap(lastpage); put_page(lastpage); if (err) bitmap_file_kick(bitmap); } else spin_unlock_irqrestore(&bitmap->lock, flags); lastpage = page; - kmap(page); /* printk("bitmap clean at page %lu\n", j); */ @@ -1105,10 +1102,12 @@ int bitmap_daemon_work(struct bitmap *bitmap) -1); /* clear the bit */ + paddr = kmap_atomic(page, KM_USER0); if (bitmap->flags & BITMAP_HOSTENDIAN) - clear_bit(file_page_offset(j), page_address(page)); + clear_bit(file_page_offset(j), paddr); else - ext2_clear_bit(file_page_offset(j), page_address(page)); + ext2_clear_bit(file_page_offset(j), paddr); + kunmap_atomic(paddr, KM_USER0); } } spin_unlock_irqrestore(&bitmap->lock, flags); @@ -1116,7 +1115,6 @@ int bitmap_daemon_work(struct bitmap *bitmap) /* now sync the final page */ if (lastpage != NULL) { - kunmap(lastpage); spin_lock_irqsave(&bitmap->lock, flags); if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) { clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); -- cgit v1.1 From a8745db232dd86f145bff6946e78f839acab511b Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:34 -0800 Subject: [PATCH] md: convert recently exported symbol to GPL ...because that seems to be the preferred practice these days. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 8c378b6..a6a066f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -478,7 +478,7 @@ int sync_page_io(struct block_device *bdev, sector_t sector, int size, bio_put(bio); return ret; } -EXPORT_SYMBOL(sync_page_io); +EXPORT_SYMBOL_GPL(sync_page_io); static int read_disk_sb(mdk_rdev_t * rdev, int size) { -- cgit v1.1 From a24a8dd858e0ba50f06a9fd8f61fe8c4fe7a8d8e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:35 -0800 Subject: [PATCH] md: break out of a loop that doesn't need to run to completion Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid10.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 254b50e..253322a 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1672,8 +1672,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i for (j=0; jcopies;j++) { int d = r10_bio->devs[j].devnum; if (conf->mirrors[d].rdev == NULL || - test_bit(Faulty, &conf->mirrors[d].rdev->flags)) + test_bit(Faulty, &conf->mirrors[d].rdev->flags)) { still_degraded = 1; + break; + } } must_sync = bitmap_start_sync(mddev->bitmap, sect, &sync_blocks, still_degraded); -- cgit v1.1 From 2604b703b6b3db80e3c75ce472a54dfd0b7bf9f4 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:36 -0800 Subject: [PATCH] md: remove personality numbering from md md supports multiple different RAID level, each being implemented by a 'personality' (which is often in a separate module). These personalities have fairly artificial 'numbers'. The numbers are use to: 1- provide an index into an array where the various personalities are recorded 2- identify the module (via an alias) which implements are particular personality. Neither of these uses really justify the existence of personality numbers. The array can be replaced by a linked list which is searched (array lookup only happens very rarely). Module identification can be done using an alias based on level rather than 'personality' number. The current 'raid5' modules support two level (4 and 5) but only one personality. This slight awkwardness (which was handled in the mapping from level to personality) can be better handled by allowing raid5 to register 2 personalities. With this change in place, the core md module does not need to have an exhaustive list of all possible personalities, so other personalities can be added independently. This patch also moves the check for chunksize being non-zero into the ->run routines for the personalities that need it, rather than having it in core-md. This has a side effect of allowing 'faulty' and 'linear' not to have a chunk-size set. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/faulty.c | 8 +++-- drivers/md/linear.c | 10 +++--- drivers/md/md.c | 79 +++++++++++++++++------------------------------ drivers/md/multipath.c | 11 +++---- drivers/md/raid0.c | 14 ++++++--- drivers/md/raid1.c | 9 +++--- drivers/md/raid10.c | 16 +++++----- drivers/md/raid5.c | 34 +++++++++++++++++--- drivers/md/raid6main.c | 10 +++--- include/linux/raid/md.h | 4 +-- include/linux/raid/md_k.h | 63 ++++++------------------------------- init/do_mounts_md.c | 22 ++++++------- 12 files changed, 125 insertions(+), 155 deletions(-) diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c index 0248f8e..f12e830 100644 --- a/drivers/md/faulty.c +++ b/drivers/md/faulty.c @@ -316,9 +316,10 @@ static int stop(mddev_t *mddev) return 0; } -static mdk_personality_t faulty_personality = +static struct mdk_personality faulty_personality = { .name = "faulty", + .level = LEVEL_FAULTY, .owner = THIS_MODULE, .make_request = make_request, .run = run, @@ -329,15 +330,16 @@ static mdk_personality_t faulty_personality = static int __init raid_init(void) { - return register_md_personality(FAULTY, &faulty_personality); + return register_md_personality(&faulty_personality); } static void raid_exit(void) { - unregister_md_personality(FAULTY); + unregister_md_personality(&faulty_personality); } module_init(raid_init); module_exit(raid_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-10"); /* faulty */ +MODULE_ALIAS("md-level--5"); diff --git a/drivers/md/linear.c b/drivers/md/linear.c index f46c98d..79dee81 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c @@ -351,9 +351,10 @@ static void linear_status (struct seq_file *seq, mddev_t *mddev) } -static mdk_personality_t linear_personality= +static struct mdk_personality linear_personality = { .name = "linear", + .level = LEVEL_LINEAR, .owner = THIS_MODULE, .make_request = linear_make_request, .run = linear_run, @@ -363,16 +364,17 @@ static mdk_personality_t linear_personality= static int __init linear_init (void) { - return register_md_personality (LINEAR, &linear_personality); + return register_md_personality (&linear_personality); } static void linear_exit (void) { - unregister_md_personality (LINEAR); + unregister_md_personality (&linear_personality); } module_init(linear_init); module_exit(linear_exit); MODULE_LICENSE("GPL"); -MODULE_ALIAS("md-personality-1"); /* LINEAR */ +MODULE_ALIAS("md-personality-1"); /* LINEAR - degrecated*/ +MODULE_ALIAS("md-level--1"); diff --git a/drivers/md/md.c b/drivers/md/md.c index a6a066f..07f180f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -68,7 +68,7 @@ static void autostart_arrays (int part); #endif -static mdk_personality_t *pers[MAX_PERSONALITY]; +static LIST_HEAD(pers_list); static DEFINE_SPINLOCK(pers_lock); /* @@ -303,6 +303,15 @@ static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev) return NULL; } +static struct mdk_personality *find_pers(int level) +{ + struct mdk_personality *pers; + list_for_each_entry(pers, &pers_list, list) + if (pers->level == level) + return pers; + return NULL; +} + static inline sector_t calc_dev_sboffset(struct block_device *bdev) { sector_t size = bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; @@ -1744,7 +1753,7 @@ static void analyze_sbs(mddev_t * mddev) static ssize_t level_show(mddev_t *mddev, char *page) { - mdk_personality_t *p = mddev->pers; + struct mdk_personality *p = mddev->pers; if (p == NULL && mddev->raid_disks == 0) return 0; if (mddev->level >= 0) @@ -1960,11 +1969,12 @@ static int start_dirty_degraded; static int do_md_run(mddev_t * mddev) { - int pnum, err; + int err; int chunk_size; struct list_head *tmp; mdk_rdev_t *rdev; struct gendisk *disk; + struct mdk_personality *pers; char b[BDEVNAME_SIZE]; if (list_empty(&mddev->disks)) @@ -1981,20 +1991,8 @@ static int do_md_run(mddev_t * mddev) analyze_sbs(mddev); chunk_size = mddev->chunk_size; - pnum = level_to_pers(mddev->level); - if ((pnum != MULTIPATH) && (pnum != RAID1)) { - if (!chunk_size) { - /* - * 'default chunksize' in the old md code used to - * be PAGE_SIZE, baaad. - * we abort here to be on the safe side. We don't - * want to continue the bad practice. - */ - printk(KERN_ERR - "no chunksize specified, see 'man raidtab'\n"); - return -EINVAL; - } + if (chunk_size) { if (chunk_size > MAX_CHUNK_SIZE) { printk(KERN_ERR "too big chunk_size: %d > %d\n", chunk_size, MAX_CHUNK_SIZE); @@ -2030,10 +2028,7 @@ static int do_md_run(mddev_t * mddev) } #ifdef CONFIG_KMOD - if (!pers[pnum]) - { - request_module("md-personality-%d", pnum); - } + request_module("md-level-%d", mddev->level); #endif /* @@ -2055,14 +2050,14 @@ static int do_md_run(mddev_t * mddev) return -ENOMEM; spin_lock(&pers_lock); - if (!pers[pnum] || !try_module_get(pers[pnum]->owner)) { + pers = find_pers(mddev->level); + if (!pers || !try_module_get(pers->owner)) { spin_unlock(&pers_lock); - printk(KERN_WARNING "md: personality %d is not loaded!\n", - pnum); + printk(KERN_WARNING "md: personality for level %d is not loaded!\n", + mddev->level); return -EINVAL; } - - mddev->pers = pers[pnum]; + mddev->pers = pers; spin_unlock(&pers_lock); mddev->recovery = 0; @@ -3701,15 +3696,14 @@ static int md_seq_show(struct seq_file *seq, void *v) struct list_head *tmp2; mdk_rdev_t *rdev; struct mdstat_info *mi = seq->private; - int i; struct bitmap *bitmap; if (v == (void*)1) { + struct mdk_personality *pers; seq_printf(seq, "Personalities : "); spin_lock(&pers_lock); - for (i = 0; i < MAX_PERSONALITY; i++) - if (pers[i]) - seq_printf(seq, "[%s] ", pers[i]->name); + list_for_each_entry(pers, &pers_list, list) + seq_printf(seq, "[%s] ", pers->name); spin_unlock(&pers_lock); seq_printf(seq, "\n"); @@ -3870,35 +3864,20 @@ static struct file_operations md_seq_fops = { .poll = mdstat_poll, }; -int register_md_personality(int pnum, mdk_personality_t *p) +int register_md_personality(struct mdk_personality *p) { - if (pnum >= MAX_PERSONALITY) { - printk(KERN_ERR - "md: tried to install personality %s as nr %d, but max is %lu\n", - p->name, pnum, MAX_PERSONALITY-1); - return -EINVAL; - } - spin_lock(&pers_lock); - if (pers[pnum]) { - spin_unlock(&pers_lock); - return -EBUSY; - } - - pers[pnum] = p; - printk(KERN_INFO "md: %s personality registered as nr %d\n", p->name, pnum); + list_add_tail(&p->list, &pers_list); + printk(KERN_INFO "md: %s personality registered for level %d\n", p->name, p->level); spin_unlock(&pers_lock); return 0; } -int unregister_md_personality(int pnum) +int unregister_md_personality(struct mdk_personality *p) { - if (pnum >= MAX_PERSONALITY) - return -EINVAL; - - printk(KERN_INFO "md: %s personality unregistered\n", pers[pnum]->name); + printk(KERN_INFO "md: %s personality unregistered\n", p->name); spin_lock(&pers_lock); - pers[pnum] = NULL; + list_del_init(&p->list); spin_unlock(&pers_lock); return 0; } diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index 97a56aa..d4d838e 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c @@ -35,9 +35,6 @@ #define NR_RESERVED_BUFS 32 -static mdk_personality_t multipath_personality; - - static void *mp_pool_alloc(gfp_t gfp_flags, void *data) { struct multipath_bh *mpb; @@ -553,9 +550,10 @@ static int multipath_stop (mddev_t *mddev) return 0; } -static mdk_personality_t multipath_personality= +static struct mdk_personality multipath_personality = { .name = "multipath", + .level = LEVEL_MULTIPATH, .owner = THIS_MODULE, .make_request = multipath_make_request, .run = multipath_run, @@ -568,15 +566,16 @@ static mdk_personality_t multipath_personality= static int __init multipath_init (void) { - return register_md_personality (MULTIPATH, &multipath_personality); + return register_md_personality (&multipath_personality); } static void __exit multipath_exit (void) { - unregister_md_personality (MULTIPATH); + unregister_md_personality (&multipath_personality); } module_init(multipath_init); module_exit(multipath_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-7"); /* MULTIPATH */ +MODULE_ALIAS("md-level--4"); diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index b4eaa67..7fb69e2 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -275,7 +275,11 @@ static int raid0_run (mddev_t *mddev) mdk_rdev_t *rdev; struct list_head *tmp; - printk("%s: setting max_sectors to %d, segment boundary to %d\n", + if (mddev->chunk_size == 0) { + printk(KERN_ERR "md/raid0: non-zero chunk size required.\n"); + return -EINVAL; + } + printk(KERN_INFO "%s: setting max_sectors to %d, segment boundary to %d\n", mdname(mddev), mddev->chunk_size >> 9, (mddev->chunk_size>>1)-1); @@ -507,9 +511,10 @@ static void raid0_status (struct seq_file *seq, mddev_t *mddev) return; } -static mdk_personality_t raid0_personality= +static struct mdk_personality raid0_personality= { .name = "raid0", + .level = 0, .owner = THIS_MODULE, .make_request = raid0_make_request, .run = raid0_run, @@ -519,15 +524,16 @@ static mdk_personality_t raid0_personality= static int __init raid0_init (void) { - return register_md_personality (RAID0, &raid0_personality); + return register_md_personality (&raid0_personality); } static void raid0_exit (void) { - unregister_md_personality (RAID0); + unregister_md_personality (&raid0_personality); } module_init(raid0_init); module_exit(raid0_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-2"); /* RAID0 */ +MODULE_ALIAS("md-level-0"); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index c42ef1c..6e0f59e 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -47,7 +47,6 @@ */ #define NR_RAID1_BIOS 256 -static mdk_personality_t raid1_personality; static void unplug_slaves(mddev_t *mddev); @@ -2036,9 +2035,10 @@ static void raid1_quiesce(mddev_t *mddev, int state) } -static mdk_personality_t raid1_personality = +static struct mdk_personality raid1_personality = { .name = "raid1", + .level = 1, .owner = THIS_MODULE, .make_request = make_request, .run = run, @@ -2056,15 +2056,16 @@ static mdk_personality_t raid1_personality = static int __init raid_init(void) { - return register_md_personality(RAID1, &raid1_personality); + return register_md_personality(&raid1_personality); } static void raid_exit(void) { - unregister_md_personality(RAID1); + unregister_md_personality(&raid1_personality); } module_init(raid_init); module_exit(raid_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-3"); /* RAID1 */ +MODULE_ALIAS("md-level-1"); diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 253322a..f23d52c 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1883,11 +1883,11 @@ static int run(mddev_t *mddev) int nc, fc; sector_t stride, size; - if (mddev->level != 10) { - printk(KERN_ERR "raid10: %s: raid level not set correctly... (%d)\n", - mdname(mddev), mddev->level); - goto out; + if (mddev->chunk_size == 0) { + printk(KERN_ERR "md/raid10: non-zero chunk size required.\n"); + return -EINVAL; } + nc = mddev->layout & 255; fc = (mddev->layout >> 8) & 255; if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks || @@ -2072,9 +2072,10 @@ static void raid10_quiesce(mddev_t *mddev, int state) } } -static mdk_personality_t raid10_personality = +static struct mdk_personality raid10_personality = { .name = "raid10", + .level = 10, .owner = THIS_MODULE, .make_request = make_request, .run = run, @@ -2090,15 +2091,16 @@ static mdk_personality_t raid10_personality = static int __init raid_init(void) { - return register_md_personality(RAID10, &raid10_personality); + return register_md_personality(&raid10_personality); } static void raid_exit(void) { - unregister_md_personality(RAID10); + unregister_md_personality(&raid10_personality); } module_init(raid_init); module_exit(raid_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-9"); /* RAID10 */ +MODULE_ALIAS("md-level-10"); diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 6e4db95..b0cfd3c 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -2187,9 +2187,10 @@ static void raid5_quiesce(mddev_t *mddev, int state) } } -static mdk_personality_t raid5_personality= +static struct mdk_personality raid5_personality = { .name = "raid5", + .level = 5, .owner = THIS_MODULE, .make_request = make_request, .run = run, @@ -2204,17 +2205,40 @@ static mdk_personality_t raid5_personality= .quiesce = raid5_quiesce, }; -static int __init raid5_init (void) +static struct mdk_personality raid4_personality = { - return register_md_personality (RAID5, &raid5_personality); + .name = "raid4", + .level = 4, + .owner = THIS_MODULE, + .make_request = make_request, + .run = run, + .stop = stop, + .status = status, + .error_handler = error, + .hot_add_disk = raid5_add_disk, + .hot_remove_disk= raid5_remove_disk, + .spare_active = raid5_spare_active, + .sync_request = sync_request, + .resize = raid5_resize, + .quiesce = raid5_quiesce, +}; + +static int __init raid5_init(void) +{ + register_md_personality(&raid5_personality); + register_md_personality(&raid4_personality); + return 0; } -static void raid5_exit (void) +static void raid5_exit(void) { - unregister_md_personality (RAID5); + unregister_md_personality(&raid5_personality); + unregister_md_personality(&raid4_personality); } module_init(raid5_init); module_exit(raid5_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-4"); /* RAID5 */ +MODULE_ALIAS("md-level-5"); +MODULE_ALIAS("md-level-4"); diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 79b5244..950e5fa 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -2304,9 +2304,10 @@ static void raid6_quiesce(mddev_t *mddev, int state) } } -static mdk_personality_t raid6_personality= +static struct mdk_personality raid6_personality = { .name = "raid6", + .level = 6, .owner = THIS_MODULE, .make_request = make_request, .run = run, @@ -2321,7 +2322,7 @@ static mdk_personality_t raid6_personality= .quiesce = raid6_quiesce, }; -static int __init raid6_init (void) +static int __init raid6_init(void) { int e; @@ -2329,15 +2330,16 @@ static int __init raid6_init (void) if ( e ) return e; - return register_md_personality (RAID6, &raid6_personality); + return register_md_personality(&raid6_personality); } static void raid6_exit (void) { - unregister_md_personality (RAID6); + unregister_md_personality(&raid6_personality); } module_init(raid6_init); module_exit(raid6_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-8"); /* RAID6 */ +MODULE_ALIAS("md-level-6"); diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h index 13e7c4b..b6e0bca 100644 --- a/include/linux/raid/md.h +++ b/include/linux/raid/md.h @@ -71,8 +71,8 @@ */ #define MD_PATCHLEVEL_VERSION 3 -extern int register_md_personality (int p_num, mdk_personality_t *p); -extern int unregister_md_personality (int p_num); +extern int register_md_personality (struct mdk_personality *p); +extern int unregister_md_personality (struct mdk_personality *p); extern mdk_thread_t * md_register_thread (void (*run) (mddev_t *mddev), mddev_t *mddev, const char *name); extern void md_unregister_thread (mdk_thread_t *thread); diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 1dd587b5..e559fb7 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -18,62 +18,19 @@ /* and dm-bio-list.h is not under include/linux because.... ??? */ #include "../../../drivers/md/dm-bio-list.h" -#define MD_RESERVED 0UL -#define LINEAR 1UL -#define RAID0 2UL -#define RAID1 3UL -#define RAID5 4UL -#define TRANSLUCENT 5UL -#define HSM 6UL -#define MULTIPATH 7UL -#define RAID6 8UL -#define RAID10 9UL -#define FAULTY 10UL -#define MAX_PERSONALITY 11UL - #define LEVEL_MULTIPATH (-4) #define LEVEL_LINEAR (-1) #define LEVEL_FAULTY (-5) +/* we need a value for 'no level specified' and 0 + * means 'raid0', so we need something else. This is + * for internal use only + */ +#define LEVEL_NONE (-1000000) + #define MaxSector (~(sector_t)0) #define MD_THREAD_NAME_MAX 14 -static inline int pers_to_level (int pers) -{ - switch (pers) { - case FAULTY: return LEVEL_FAULTY; - case MULTIPATH: return LEVEL_MULTIPATH; - case HSM: return -3; - case TRANSLUCENT: return -2; - case LINEAR: return LEVEL_LINEAR; - case RAID0: return 0; - case RAID1: return 1; - case RAID5: return 5; - case RAID6: return 6; - case RAID10: return 10; - } - BUG(); - return MD_RESERVED; -} - -static inline int level_to_pers (int level) -{ - switch (level) { - case LEVEL_FAULTY: return FAULTY; - case LEVEL_MULTIPATH: return MULTIPATH; - case -3: return HSM; - case -2: return TRANSLUCENT; - case LEVEL_LINEAR: return LINEAR; - case 0: return RAID0; - case 1: return RAID1; - case 4: - case 5: return RAID5; - case 6: return RAID6; - case 10: return RAID10; - } - return MD_RESERVED; -} - typedef struct mddev_s mddev_t; typedef struct mdk_rdev_s mdk_rdev_t; @@ -140,12 +97,10 @@ struct mdk_rdev_s */ }; -typedef struct mdk_personality_s mdk_personality_t; - struct mddev_s { void *private; - mdk_personality_t *pers; + struct mdk_personality *pers; dev_t unit; int md_minor; struct list_head disks; @@ -266,9 +221,11 @@ static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sect atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io); } -struct mdk_personality_s +struct mdk_personality { char *name; + int level; + struct list_head list; struct module *owner; int (*make_request)(request_queue_t *q, struct bio *bio); int (*run)(mddev_t *mddev); diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c index 3fbc355..f6f3680 100644 --- a/init/do_mounts_md.c +++ b/init/do_mounts_md.c @@ -17,7 +17,7 @@ static int __initdata raid_noautodetect, raid_autopart; static struct { int minor; int partitioned; - int pers; + int level; int chunk; char *device_names; } md_setup_args[MAX_MD_DEVS] __initdata; @@ -47,7 +47,7 @@ extern int mdp_major; */ static int __init md_setup(char *str) { - int minor, level, factor, fault, pers, partitioned = 0; + int minor, level, factor, fault, partitioned = 0; char *pername = ""; char *str1; int ent; @@ -78,7 +78,7 @@ static int __init md_setup(char *str) } if (ent >= md_setup_ents) md_setup_ents++; - switch (get_option(&str, &level)) { /* RAID Personality */ + switch (get_option(&str, &level)) { /* RAID level */ case 2: /* could be 0 or -1.. */ if (level == 0 || level == LEVEL_LINEAR) { if (get_option(&str, &factor) != 2 || /* Chunk Size */ @@ -86,16 +86,12 @@ static int __init md_setup(char *str) printk(KERN_WARNING "md: Too few arguments supplied to md=.\n"); return 0; } - md_setup_args[ent].pers = level; + md_setup_args[ent].level = level; md_setup_args[ent].chunk = 1 << (factor+12); - if (level == LEVEL_LINEAR) { - pers = LINEAR; + if (level == LEVEL_LINEAR) pername = "linear"; - } else { - pers = RAID0; + else pername = "raid0"; - } - md_setup_args[ent].pers = pers; break; } /* FALL THROUGH */ @@ -103,7 +99,7 @@ static int __init md_setup(char *str) str = str1; /* FALL THROUGH */ case 0: - md_setup_args[ent].pers = 0; + md_setup_args[ent].level = LEVEL_NONE; pername="super-block"; } @@ -190,10 +186,10 @@ static void __init md_setup_drive(void) continue; } - if (md_setup_args[ent].pers) { + if (md_setup_args[ent].level != LEVEL_NONE) { /* non-persistent */ mdu_array_info_t ainfo; - ainfo.level = pers_to_level(md_setup_args[ent].pers); + ainfo.level = md_setup_args[ent].level; ainfo.size = 0; ainfo.nr_disks =0; ainfo.raid_disks =0; -- cgit v1.1 From 097426f689f179747f3cd6b4749eb2a6b605702d Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:37 -0800 Subject: [PATCH] md: fix possible problem in raid1/raid10 error overwriting The code to overwrite/reread for addressing read errors in raid1/raid10 currently assumes that the read will not alter the buffer which could be used to write to the next device. This is not a safe assumption to make. So we split the loops into a overwrite loop and a separate re-read loop, so that the writing is complete before reading is attempted. Cc: Paul Clements Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid1.c | 38 ++++++++++++++++++++++++++++++-------- drivers/md/raid10.c | 22 ++++++++++++++++++---- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 6e0f59e..39c10a6 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1253,6 +1253,7 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) } while (!success && d != r1_bio->read_disk); if (success) { + int start = d; /* write it back and re-read */ set_bit(R1BIO_Uptodate, &r1_bio->state); while (d != r1_bio->read_disk) { @@ -1266,14 +1267,23 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) sect + rdev->data_offset, s<<9, bio->bi_io_vec[idx].bv_page, - WRITE) == 0 || - sync_page_io(rdev->bdev, + WRITE) == 0) + md_error(mddev, rdev); + } + d = start; + while (d != r1_bio->read_disk) { + if (d == 0) + d = conf->raid_disks; + d--; + if (r1_bio->bios[d]->bi_end_io != end_sync_read) + continue; + rdev = conf->mirrors[d].rdev; + if (sync_page_io(rdev->bdev, sect + rdev->data_offset, s<<9, bio->bi_io_vec[idx].bv_page, - READ) == 0) { + READ) == 0) md_error(mddev, rdev); - } } } else { char b[BDEVNAME_SIZE]; @@ -1445,6 +1455,7 @@ static void raid1d(mddev_t *mddev) if (success) { /* write it back and re-read */ + int start = d; while (d != r1_bio->read_disk) { if (d==0) d = conf->raid_disks; @@ -1454,13 +1465,24 @@ static void raid1d(mddev_t *mddev) test_bit(In_sync, &rdev->flags)) { if (sync_page_io(rdev->bdev, sect + rdev->data_offset, - s<<9, conf->tmppage, WRITE) == 0 || - sync_page_io(rdev->bdev, + s<<9, conf->tmppage, WRITE) == 0) + /* Well, this device is dead */ + md_error(mddev, rdev); + } + } + d = start; + while (d != r1_bio->read_disk) { + if (d==0) + d = conf->raid_disks; + d--; + rdev = conf->mirrors[d].rdev; + if (rdev && + test_bit(In_sync, &rdev->flags)) { + if (sync_page_io(rdev->bdev, sect + rdev->data_offset, - s<<9, conf->tmppage, READ) == 0) { + s<<9, conf->tmppage, READ) == 0) /* Well, this device is dead */ md_error(mddev, rdev); - } } } } else { diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index f23d52c..9647ebb 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1421,6 +1421,7 @@ static void raid10d(mddev_t *mddev) } while (!success && sl != r10_bio->read_slot); if (success) { + int start = sl; /* write it back and re-read */ while (sl != r10_bio->read_slot) { int d; @@ -1434,14 +1435,27 @@ static void raid10d(mddev_t *mddev) if (sync_page_io(rdev->bdev, r10_bio->devs[sl].addr + sect + rdev->data_offset, - s<<9, conf->tmppage, WRITE) == 0 || - sync_page_io(rdev->bdev, + s<<9, conf->tmppage, WRITE) == 0) + /* Well, this device is dead */ + md_error(mddev, rdev); + } + } + sl = start; + while (sl != r10_bio->read_slot) { + int d; + if (sl==0) + sl = conf->copies; + sl--; + d = r10_bio->devs[sl].devnum; + rdev = conf->mirrors[d].rdev; + if (rdev && + test_bit(In_sync, &rdev->flags)) { + if (sync_page_io(rdev->bdev, r10_bio->devs[sl].addr + sect + rdev->data_offset, - s<<9, conf->tmppage, READ) == 0) { + s<<9, conf->tmppage, READ) == 0) /* Well, this device is dead */ md_error(mddev, rdev); - } } } } else { -- cgit v1.1 From 7dd5d34c6c2da04e8cd0732e08b33cd3359e4bae Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:39 -0800 Subject: [PATCH] md: remove inappropriate limits in md/bitmap configuration. The kernel should not be imposing these policy limits: The time between bitmap updates should certainly be allowed to be more than 15 seconds, and if someone wants a bitmap chunk size in excess of 4MB, the kernel isn't the place to stop them. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/bitmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 519b1bf..abe415f 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -485,12 +485,12 @@ static int bitmap_read_sb(struct bitmap *bitmap) else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO || le32_to_cpu(sb->version) > BITMAP_MAJOR_HI) reason = "unrecognized superblock version"; - else if (chunksize < 512 || chunksize > (1024 * 1024 * 4)) - reason = "bitmap chunksize out of range (512B - 4MB)"; + else if (chunksize < PAGE_SIZE) + reason = "bitmap chunksize too small"; else if ((1 << ffz(~chunksize)) != chunksize) reason = "bitmap chunksize not a power of 2"; - else if (daemon_sleep < 1 || daemon_sleep > 15) - reason = "daemon sleep period out of range (1-15s)"; + else if (daemon_sleep < 1 || daemon_sleep > MAX_SCHEDULE_TIMEOUT / HZ) + reason = "daemon sleep period out of range"; else if (write_behind > COUNTER_MAX) reason = "write-behind limit out of range (0 - 16383)"; if (reason) { -- cgit v1.1 From 1345b1d8adbdeceb1c871d9a4af5e2a700b341c6 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:40 -0800 Subject: [PATCH] md: define and use safe_put_page for md md sometimes call put_page on NULL pointers (treating it like kfree). This is not safe, so define and use a 'safe_put_page' which checks for NULL. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/bitmap.c | 3 +-- drivers/md/raid1.c | 8 ++++---- drivers/md/raid10.c | 8 ++++---- drivers/md/raid6main.c | 3 +-- include/linux/raid/md_k.h | 5 +++++ 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index abe415f..ee4a342 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -626,8 +626,7 @@ static void bitmap_file_unmap(struct bitmap *bitmap) kfree(map); kfree(attr); - if (sb_page) - put_page(sb_page); + safe_put_page(sb_page); } static void bitmap_stop_daemon(struct bitmap *bitmap); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 39c10a6..feea4ee 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -136,7 +136,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) out_free_pages: for (i=0; i < RESYNC_PAGES ; i++) for (j=0 ; j < pi->raid_disks; j++) - put_page(r1_bio->bios[j]->bi_io_vec[i].bv_page); + safe_put_page(r1_bio->bios[j]->bi_io_vec[i].bv_page); j = -1; out_free_bio: while ( ++j < pi->raid_disks ) @@ -156,7 +156,7 @@ static void r1buf_pool_free(void *__r1_bio, void *data) if (j == 0 || r1bio->bios[j]->bi_io_vec[i].bv_page != r1bio->bios[0]->bi_io_vec[i].bv_page) - put_page(r1bio->bios[j]->bi_io_vec[i].bv_page); + safe_put_page(r1bio->bios[j]->bi_io_vec[i].bv_page); } for (i=0 ; i < pi->raid_disks; i++) bio_put(r1bio->bios[i]); @@ -381,7 +381,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int /* free extra copy of the data pages */ int i = bio->bi_vcnt; while (i--) - put_page(bio->bi_io_vec[i].bv_page); + safe_put_page(bio->bi_io_vec[i].bv_page); } /* clear the bitmap if all writes complete successfully */ bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector, @@ -1907,7 +1907,7 @@ out_free_conf: if (conf->r1bio_pool) mempool_destroy(conf->r1bio_pool); kfree(conf->mirrors); - put_page(conf->tmppage); + safe_put_page(conf->tmppage); kfree(conf->poolinfo); kfree(conf); mddev->private = NULL; diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 9647ebb..fb95200 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -132,10 +132,10 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data) out_free_pages: for ( ; i > 0 ; i--) - put_page(bio->bi_io_vec[i-1].bv_page); + safe_put_page(bio->bi_io_vec[i-1].bv_page); while (j--) for (i = 0; i < RESYNC_PAGES ; i++) - put_page(r10_bio->devs[j].bio->bi_io_vec[i].bv_page); + safe_put_page(r10_bio->devs[j].bio->bi_io_vec[i].bv_page); j = -1; out_free_bio: while ( ++j < nalloc ) @@ -155,7 +155,7 @@ static void r10buf_pool_free(void *__r10_bio, void *data) struct bio *bio = r10bio->devs[j].bio; if (bio) { for (i = 0; i < RESYNC_PAGES; i++) { - put_page(bio->bi_io_vec[i].bv_page); + safe_put_page(bio->bi_io_vec[i].bv_page); bio->bi_io_vec[i].bv_page = NULL; } bio_put(bio); @@ -2042,7 +2042,7 @@ static int run(mddev_t *mddev) out_free_conf: if (conf->r10bio_pool) mempool_destroy(conf->r10bio_pool); - put_page(conf->tmppage); + safe_put_page(conf->tmppage); kfree(conf->mirrors); kfree(conf); mddev->private = NULL; diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 950e5fa..06b32bd 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -2072,8 +2072,7 @@ static int run(mddev_t *mddev) abort: if (conf) { print_raid6_conf(conf); - if (conf->spare_page) - put_page(conf->spare_page); + safe_put_page(conf->spare_page); kfree(conf->stripe_hashtbl); kfree(conf); } diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index e559fb7..12b3203 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -324,5 +324,10 @@ do { \ __wait_event_lock_irq(wq, condition, lock, cmd); \ } while (0) +static inline void safe_put_page(struct page *p) +{ + if (p) put_page(p); +} + #endif -- cgit v1.1 From bce74dac082787375e76d2b33726b94c9701fabc Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:41 -0800 Subject: [PATCH] md: helper function to match commands written to sysfs files Commands written to sysfs files may, or my not, be \n terminated. We want to accept with case. For this we use cmd_match. Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 07f180f..c161385 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1525,6 +1525,26 @@ repeat: } +/* words written to sysfs files may, or my not, be \n terminated. + * We want to accept with case. For this we use cmd_match. + */ +static int cmd_match(const char *cmd, const char *str) +{ + /* See if cmd, written into a sysfs file, matches + * str. They must either be the same, or cmd can + * have a trailing newline + */ + while (*cmd && *str && *cmd == *str) { + cmd++; + str++; + } + if (*cmd == '\n') + cmd++; + if (*str || *cmd) + return 0; + return 1; +} + struct rdev_sysfs_entry { struct attribute attr; ssize_t (*show)(mdk_rdev_t *, char *); @@ -1799,7 +1819,7 @@ action_store(mddev_t *mddev, const char *page, size_t len) if (!mddev->pers || !mddev->pers->sync_request) return -EINVAL; - if (strcmp(page, "idle")==0 || strcmp(page, "idle\n")==0) { + if (cmd_match(page, "idle")) { if (mddev->sync_thread) { set_bit(MD_RECOVERY_INTR, &mddev->recovery); md_unregister_thread(mddev->sync_thread); @@ -1812,13 +1832,12 @@ action_store(mddev_t *mddev, const char *page, size_t len) if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) return -EBUSY; - if (strcmp(page, "resync")==0 || strcmp(page, "resync\n")==0 || - strcmp(page, "recover")==0 || strcmp(page, "recover\n")==0) + if (cmd_match(page, "resync") || cmd_match(page, "recover")) set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); else { - if (strcmp(page, "check")==0 || strcmp(page, "check\n")==0) + if (cmd_match(page, "check")) set_bit(MD_RECOVERY_CHECK, &mddev->recovery); - else if (strcmp(page, "repair")!=0 && strcmp(page, "repair\n")!=0) + else if (cmd_match(page, "repair")) return -EINVAL; set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); set_bit(MD_RECOVERY_SYNC, &mddev->recovery); -- cgit v1.1 From f188593ee7af8c71755d2df269a7a5f62c4b695e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:42 -0800 Subject: [PATCH] md: fix typo in comment Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/raid10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index fb95200..8e6f6df 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -712,7 +712,7 @@ static void allow_barrier(conf_t *conf) static void freeze_array(conf_t *conf) { /* stop syncio and normal IO and wait for everything to - * go quite. + * go quiet. * We increment barrier and nr_waiting, and then * wait until barrier+nr_pending match nr_queued+2 */ -- cgit v1.1 From 2989ddbd6e1d9638a188311b896362c4bf7b7c25 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:43 -0800 Subject: [PATCH] md: make a couple of names in md.c static .. because they aren't used outside md.c Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 4 ++-- include/linux/raid/md_k.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index c161385..3cf0893 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -144,7 +144,7 @@ static int start_readonly; * start array, stop array, error, add device, remove device, * start build, activate spare */ -DECLARE_WAIT_QUEUE_HEAD(md_event_waiters); +static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters); static atomic_t md_event_count; void md_new_event(mddev_t *mddev) { @@ -279,7 +279,7 @@ static inline void mddev_unlock(mddev_t * mddev) md_wakeup_thread(mddev->thread); } -mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr) +static mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr) { mdk_rdev_t * rdev; struct list_head *tmp; diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 12b3203..0fb5af6 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -263,8 +263,6 @@ static inline char * mdname (mddev_t * mddev) return mddev->gendisk ? mddev->gendisk->disk_name : "mdX"; } -extern mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr); - /* * iterates through some rdev ringlist. It's safe to remove the * current 'rdev'. Dont touch 'tmp' though. -- cgit v1.1 From 07dbd37727049c0d56e313e5afcf8db07a9c3e37 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 6 Jan 2006 00:20:44 -0800 Subject: [PATCH] drivers/md/md.c: make md_new_event() static Make the needlessly global function md_new_event() static. Signed-off-by: Adrian Bunk Cc: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 3cf0893..241d514 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -146,7 +146,7 @@ static int start_readonly; */ static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters); static atomic_t md_event_count; -void md_new_event(mddev_t *mddev) +static void md_new_event(mddev_t *mddev) { atomic_inc(&md_event_count); wake_up(&md_event_waiters); -- cgit v1.1 From c708443c004f2310abdd7f1c353daa372b37f7a2 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:45 -0800 Subject: [PATCH] md: make sure bitmap updates are visible through filesystem When we update a page_cache page in the kernel, we need to flush_dache_page or userspace might not see the change. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/bitmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index ee4a342..76a189c 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -315,6 +315,8 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait) if (bitmap->file == NULL) return write_sb_page(bitmap->mddev, bitmap->offset, page, wait); + flush_dcache_page(page); /* make sure visible to anyone reading the file */ + if (wait) lock_page(page); else { -- cgit v1.1 From 03c902e17f40cfed63cd2494616f35fc9c58571b Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:46 -0800 Subject: [PATCH] md: fix rdev->pending counts in raid1 When we do a user-requested check/repair, we lose count of the outstanding requests... Also make sure that when anything is written to md/sync_action, the RECOVERY_NEEDED flag is set and the thread is woken up so any changes take effect. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 11 ++++------- drivers/md/raid1.c | 10 ++++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 241d514..0b3081a 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1826,13 +1826,10 @@ action_store(mddev_t *mddev, const char *page, size_t len) mddev->sync_thread = NULL; mddev->recovery = 0; } - return len; - } - - if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || - test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) + } else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || + test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) return -EBUSY; - if (cmd_match(page, "resync") || cmd_match(page, "recover")) + else if (cmd_match(page, "resync") || cmd_match(page, "recover")) set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); else { if (cmd_match(page, "check")) @@ -1841,8 +1838,8 @@ action_store(mddev_t *mddev, const char *page, size_t len) return -EINVAL; set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); set_bit(MD_RECOVERY_SYNC, &mddev->recovery); - set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); } + set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); md_wakeup_thread(mddev->thread); return len; } diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index feea4ee..7d4465f 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -527,7 +527,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) /* cannot risk returning a device that failed * before we inc'ed nr_pending */ - atomic_dec(&rdev->nr_pending); + rdev_dec_pending(rdev, conf->mddev); goto retry; } conf->next_seq_sect = this_sector + sectors; @@ -830,7 +830,7 @@ static int make_request(request_queue_t *q, struct bio * bio) !test_bit(Faulty, &rdev->flags)) { atomic_inc(&rdev->nr_pending); if (test_bit(Faulty, &rdev->flags)) { - atomic_dec(&rdev->nr_pending); + rdev_dec_pending(rdev, mddev); r1_bio->bios[i] = NULL; } else r1_bio->bios[i] = bio; @@ -1176,6 +1176,7 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) if (r1_bio->bios[primary]->bi_end_io == end_sync_read && test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) { r1_bio->bios[primary]->bi_end_io = NULL; + rdev_dec_pending(conf->mirrors[primary].rdev, mddev); break; } r1_bio->read_disk = primary; @@ -1193,9 +1194,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) break; if (j >= 0) mddev->resync_mismatches += r1_bio->sectors; - if (j < 0 || test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) + if (j < 0 || test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) { sbio->bi_end_io = NULL; - else { + rdev_dec_pending(conf->mirrors[i].rdev, mddev); + } else { /* fixup the bio for reuse */ sbio->bi_vcnt = vcnt; sbio->bi_size = r1_bio->sectors << 9; -- cgit v1.1 From 3b34380ae8c5df6debd85183c7fa1ac05f79b7d2 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:47 -0800 Subject: [PATCH] md: allow chunk_size to be settable through sysfs ... only before array is started of course. Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 8 ++++++++ drivers/md/md.c | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/Documentation/md.txt b/Documentation/md.txt index 1dd0fb6..9710138 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -166,6 +166,14 @@ All md devices contain: will be empty. If an array is being resized (not currently possible) this will contain the larger of the old and new sizes. + chunk_size + This is the size if bytes for 'chunks' and is only relevant to + raid levels that involve striping (1,4,5,6,10). The address space + of the array is conceptually divided into chunks and consecutive + chunks are striped onto neighbouring devices. + The size should be atleast PAGE_SIZE (4k) and should be a power + of 2. This can only be set while assembling an array + As component devices are added to an md array, they appear in the 'md' directory as new directories named dev-XXX diff --git a/drivers/md/md.c b/drivers/md/md.c index 0b3081a..9e57e97 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1795,6 +1795,31 @@ raid_disks_show(mddev_t *mddev, char *page) static struct md_sysfs_entry md_raid_disks = __ATTR_RO(raid_disks); static ssize_t +chunk_size_show(mddev_t *mddev, char *page) +{ + return sprintf(page, "%d\n", mddev->chunk_size); +} + +static ssize_t +chunk_size_store(mddev_t *mddev, const char *buf, size_t len) +{ + /* can only set chunk_size if array is not yet active */ + char *e; + unsigned long n = simple_strtoul(buf, &e, 10); + + if (mddev->pers) + return -EBUSY; + if (!*buf || (*e && *e != '\n')) + return -EINVAL; + + mddev->chunk_size = n; + return len; +} +static struct md_sysfs_entry md_chunk_size = +__ATTR(chunk_size, 0644, chunk_size_show, chunk_size_store); + + +static ssize_t action_show(mddev_t *mddev, char *page) { char *type = "idle"; @@ -1861,6 +1886,7 @@ md_mismatches = __ATTR_RO(mismatch_cnt); static struct attribute *md_default_attrs[] = { &md_level.attr, &md_raid_disks.attr, + &md_chunk_size.attr, NULL, }; -- cgit v1.1 From a35b0d695d44410eb1734c9abb632725a3138628 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:49 -0800 Subject: [PATCH] md: allow md array component size to be accessed and set via sysfs Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 9 ++++ drivers/md/md.c | 131 ++++++++++++++++++++++++++++++++++----------------- 2 files changed, 98 insertions(+), 42 deletions(-) diff --git a/Documentation/md.txt b/Documentation/md.txt index 9710138..0a2e10a 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -174,6 +174,15 @@ All md devices contain: The size should be atleast PAGE_SIZE (4k) and should be a power of 2. This can only be set while assembling an array + component_size + For arrays with data redundancy (i.e. not raid0, linear, faulty, + multipath), all components must be the same size - or at least + there must a size that they all provide space for. This is a key + part or the geometry of the array. It is measured in sectors + and can be read from here. Writing to this value may resize + the array if the personality supports it (raid1, raid5, raid6), + and if the component drives are large enough. + As component devices are added to an md array, they appear in the 'md' directory as new directories named dev-XXX diff --git a/drivers/md/md.c b/drivers/md/md.c index 9e57e97..d568ab4 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1820,6 +1820,44 @@ __ATTR(chunk_size, 0644, chunk_size_show, chunk_size_store); static ssize_t +size_show(mddev_t *mddev, char *page) +{ + return sprintf(page, "%llu\n", (unsigned long long)mddev->size); +} + +static int update_size(mddev_t *mddev, unsigned long size); + +static ssize_t +size_store(mddev_t *mddev, const char *buf, size_t len) +{ + /* If array is inactive, we can reduce the component size, but + * not increase it (except from 0). + * If array is active, we can try an on-line resize + */ + char *e; + int err = 0; + unsigned long long size = simple_strtoull(buf, &e, 10); + if (!*buf || *buf == '\n' || + (*e && *e != '\n')) + return -EINVAL; + + if (mddev->pers) { + err = update_size(mddev, size); + md_update_sb(mddev); + } else { + if (mddev->size == 0 || + mddev->size > size) + mddev->size = size; + else + err = -ENOSPC; + } + return err ? err : len; +} + +static struct md_sysfs_entry md_size = +__ATTR(component_size, 0644, size_show, size_store); + +static ssize_t action_show(mddev_t *mddev, char *page) { char *type = "idle"; @@ -1887,6 +1925,7 @@ static struct attribute *md_default_attrs[] = { &md_level.attr, &md_raid_disks.attr, &md_chunk_size.attr, + &md_size.attr, NULL, }; @@ -3005,6 +3044,54 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info) return 0; } +static int update_size(mddev_t *mddev, unsigned long size) +{ + mdk_rdev_t * rdev; + int rv; + struct list_head *tmp; + + if (mddev->pers->resize == NULL) + return -EINVAL; + /* The "size" is the amount of each device that is used. + * This can only make sense for arrays with redundancy. + * linear and raid0 always use whatever space is available + * We can only consider changing the size if no resync + * or reconstruction is happening, and if the new size + * is acceptable. It must fit before the sb_offset or, + * if that is sync_thread) + return -EBUSY; + ITERATE_RDEV(mddev,rdev,tmp) { + sector_t avail; + int fit = (size == 0); + if (rdev->sb_offset > rdev->data_offset) + avail = (rdev->sb_offset*2) - rdev->data_offset; + else + avail = get_capacity(rdev->bdev->bd_disk) + - rdev->data_offset; + if (fit && (size == 0 || size > avail/2)) + size = avail/2; + if (avail < ((sector_t)size << 1)) + return -ENOSPC; + } + rv = mddev->pers->resize(mddev, (sector_t)size *2); + if (!rv) { + struct block_device *bdev; + + bdev = bdget_disk(mddev->gendisk, 0); + if (bdev) { + down(&bdev->bd_inode->i_sem); + i_size_write(bdev->bd_inode, mddev->array_size << 10); + up(&bdev->bd_inode->i_sem); + bdput(bdev); + } + } + return rv; +} + /* * update_array_info is used to change the configuration of an * on-line array. @@ -3053,49 +3140,9 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) else return mddev->pers->reconfig(mddev, info->layout, -1); } - if (mddev->size != info->size) { - mdk_rdev_t * rdev; - struct list_head *tmp; - if (mddev->pers->resize == NULL) - return -EINVAL; - /* The "size" is the amount of each device that is used. - * This can only make sense for arrays with redundancy. - * linear and raid0 always use whatever space is available - * We can only consider changing the size if no resync - * or reconstruction is happening, and if the new size - * is acceptable. It must fit before the sb_offset or, - * if that is sync_thread) - return -EBUSY; - ITERATE_RDEV(mddev,rdev,tmp) { - sector_t avail; - int fit = (info->size == 0); - if (rdev->sb_offset > rdev->data_offset) - avail = (rdev->sb_offset*2) - rdev->data_offset; - else - avail = get_capacity(rdev->bdev->bd_disk) - - rdev->data_offset; - if (fit && (info->size == 0 || info->size > avail/2)) - info->size = avail/2; - if (avail < ((sector_t)info->size << 1)) - return -ENOSPC; - } - rv = mddev->pers->resize(mddev, (sector_t)info->size *2); - if (!rv) { - struct block_device *bdev; + if (mddev->size != info->size) + rv = update_size(mddev, info->size); - bdev = bdget_disk(mddev->gendisk, 0); - if (bdev) { - down(&bdev->bd_inode->i_sem); - i_size_write(bdev->bd_inode, mddev->array_size << 10); - up(&bdev->bd_inode->i_sem); - bdput(bdev); - } - } - } if (mddev->raid_disks != info->raid_disks) { /* change the number of raid disks */ if (mddev->pers->reshape == NULL) -- cgit v1.1 From 8bb93aaca2062cd54cc2c58c76ee8409cae209a7 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:50 -0800 Subject: [PATCH] md: expose md metadata format in sysfs Allow it to be set to a particular version, or 'none'. Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 6 ++++++ drivers/md/md.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/Documentation/md.txt b/Documentation/md.txt index 0a2e10a..c5512af 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -183,6 +183,12 @@ All md devices contain: the array if the personality supports it (raid1, raid5, raid6), and if the component drives are large enough. + metadata_version + This indicates the format that is being used to record metadata + about the array. It can be 0.90 (traditional format), 1.0, 1.1, + 1.2 (newer format in varying locations) or "none" indicating that + the kernel isn't managing metadata at all. + As component devices are added to an md array, they appear in the 'md' directory as new directories named dev-XXX diff --git a/drivers/md/md.c b/drivers/md/md.c index d568ab4..ecc0166 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1857,6 +1857,54 @@ size_store(mddev_t *mddev, const char *buf, size_t len) static struct md_sysfs_entry md_size = __ATTR(component_size, 0644, size_show, size_store); + +/* Metdata version. + * This is either 'none' for arrays with externally managed metadata, + * or N.M for internally known formats + */ +static ssize_t +metadata_show(mddev_t *mddev, char *page) +{ + if (mddev->persistent) + return sprintf(page, "%d.%d\n", + mddev->major_version, mddev->minor_version); + else + return sprintf(page, "none\n"); +} + +static ssize_t +metadata_store(mddev_t *mddev, const char *buf, size_t len) +{ + int major, minor; + char *e; + if (!list_empty(&mddev->disks)) + return -EBUSY; + + if (cmd_match(buf, "none")) { + mddev->persistent = 0; + mddev->major_version = 0; + mddev->minor_version = 90; + return len; + } + major = simple_strtoul(buf, &e, 10); + if (e==buf || *e != '.') + return -EINVAL; + buf = e+1; + minor = simple_strtoul(buf, &e, 10); + if (e==buf || *e != '\n') + return -EINVAL; + if (major >= sizeof(super_types)/sizeof(super_types[0]) || + super_types[major].name == NULL) + return -ENOENT; + mddev->major_version = major; + mddev->minor_version = minor; + mddev->persistent = 1; + return len; +} + +static struct md_sysfs_entry md_metadata = +__ATTR(metadata_version, 0644, metadata_show, metadata_store); + static ssize_t action_show(mddev_t *mddev, char *page) { @@ -1926,6 +1974,7 @@ static struct attribute *md_default_attrs[] = { &md_raid_disks.attr, &md_chunk_size.attr, &md_size.attr, + &md_metadata.attr, NULL, }; -- cgit v1.1 From d9d166c2a9d5d01af34396793950aa695883eed4 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:51 -0800 Subject: [PATCH] md: allow array level to be set textually via sysfs Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 8 +++++++ drivers/md/faulty.c | 1 + drivers/md/linear.c | 3 ++- drivers/md/md.c | 61 +++++++++++++++++++++++++++++++++++++---------- drivers/md/multipath.c | 1 + drivers/md/raid0.c | 1 + drivers/md/raid1.c | 1 + drivers/md/raid10.c | 1 + drivers/md/raid5.c | 2 ++ drivers/md/raid6main.c | 1 + include/linux/raid/md_k.h | 1 + 11 files changed, 67 insertions(+), 14 deletions(-) diff --git a/Documentation/md.txt b/Documentation/md.txt index c5512af..fd43fd2 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -189,6 +189,14 @@ All md devices contain: 1.2 (newer format in varying locations) or "none" indicating that the kernel isn't managing metadata at all. + level + The raid 'level' for this array. The name will often (but not + always) be the same as the name of the module that implements the + level. To be auto-loaded the module must have an alias + md-$LEVEL e.g. md-raid5 + This can be written only while the array is being assembled, not + after it is started. + As component devices are added to an md array, they appear in the 'md' directory as new directories named dev-XXX diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c index f12e830..a7a5ab5 100644 --- a/drivers/md/faulty.c +++ b/drivers/md/faulty.c @@ -342,4 +342,5 @@ module_init(raid_init); module_exit(raid_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-10"); /* faulty */ +MODULE_ALIAS("md-faulty"); MODULE_ALIAS("md-level--5"); diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 79dee81..7775854 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c @@ -376,5 +376,6 @@ static void linear_exit (void) module_init(linear_init); module_exit(linear_exit); MODULE_LICENSE("GPL"); -MODULE_ALIAS("md-personality-1"); /* LINEAR - degrecated*/ +MODULE_ALIAS("md-personality-1"); /* LINEAR - deprecated*/ +MODULE_ALIAS("md-linear"); MODULE_ALIAS("md-level--1"); diff --git a/drivers/md/md.c b/drivers/md/md.c index ecc0166..594d8c3 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -303,12 +303,15 @@ static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev) return NULL; } -static struct mdk_personality *find_pers(int level) +static struct mdk_personality *find_pers(int level, char *clevel) { struct mdk_personality *pers; - list_for_each_entry(pers, &pers_list, list) - if (pers->level == level) + list_for_each_entry(pers, &pers_list, list) { + if (level != LEVEL_NONE && pers->level == level) return pers; + if (strcmp(pers->name, clevel)==0) + return pers; + } return NULL; } @@ -715,6 +718,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev) mddev->ctime = sb->ctime; mddev->utime = sb->utime; mddev->level = sb->level; + mddev->clevel[0] = 0; mddev->layout = sb->layout; mddev->raid_disks = sb->raid_disks; mddev->size = sb->size; @@ -1051,6 +1055,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev) mddev->ctime = le64_to_cpu(sb->ctime) & ((1ULL << 32)-1); mddev->utime = le64_to_cpu(sb->utime) & ((1ULL << 32)-1); mddev->level = le32_to_cpu(sb->level); + mddev->clevel[0] = 0; mddev->layout = le32_to_cpu(sb->layout); mddev->raid_disks = le32_to_cpu(sb->raid_disks); mddev->size = le64_to_cpu(sb->size)/2; @@ -1774,15 +1779,36 @@ static ssize_t level_show(mddev_t *mddev, char *page) { struct mdk_personality *p = mddev->pers; - if (p == NULL && mddev->raid_disks == 0) - return 0; - if (mddev->level >= 0) - return sprintf(page, "raid%d\n", mddev->level); - else + if (p) return sprintf(page, "%s\n", p->name); + else if (mddev->clevel[0]) + return sprintf(page, "%s\n", mddev->clevel); + else if (mddev->level != LEVEL_NONE) + return sprintf(page, "%d\n", mddev->level); + else + return 0; +} + +static ssize_t +level_store(mddev_t *mddev, const char *buf, size_t len) +{ + int rv = len; + if (mddev->pers) + return -EBUSY; + if (len == 0) + return 0; + if (len >= sizeof(mddev->clevel)) + return -ENOSPC; + strncpy(mddev->clevel, buf, len); + if (mddev->clevel[len-1] == '\n') + len--; + mddev->clevel[len] = 0; + mddev->level = LEVEL_NONE; + return rv; } -static struct md_sysfs_entry md_level = __ATTR_RO(level); +static struct md_sysfs_entry md_level = +__ATTR(level, 0644, level_show, level_store); static ssize_t raid_disks_show(mddev_t *mddev, char *page) @@ -2158,7 +2184,10 @@ static int do_md_run(mddev_t * mddev) } #ifdef CONFIG_KMOD - request_module("md-level-%d", mddev->level); + if (mddev->level != LEVEL_NONE) + request_module("md-level-%d", mddev->level); + else if (mddev->clevel[0]) + request_module("md-%s", mddev->clevel); #endif /* @@ -2180,15 +2209,21 @@ static int do_md_run(mddev_t * mddev) return -ENOMEM; spin_lock(&pers_lock); - pers = find_pers(mddev->level); + pers = find_pers(mddev->level, mddev->clevel); if (!pers || !try_module_get(pers->owner)) { spin_unlock(&pers_lock); - printk(KERN_WARNING "md: personality for level %d is not loaded!\n", - mddev->level); + if (mddev->level != LEVEL_NONE) + printk(KERN_WARNING "md: personality for level %d is not loaded!\n", + mddev->level); + else + printk(KERN_WARNING "md: personality for level %s is not loaded!\n", + mddev->clevel); return -EINVAL; } mddev->pers = pers; spin_unlock(&pers_lock); + mddev->level = pers->level; + strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); mddev->recovery = 0; mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index d4d838e..e6aa309 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c @@ -578,4 +578,5 @@ module_init(multipath_init); module_exit(multipath_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-7"); /* MULTIPATH */ +MODULE_ALIAS("md-multipath"); MODULE_ALIAS("md-level--4"); diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 7fb69e2..abbca15 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -536,4 +536,5 @@ module_init(raid0_init); module_exit(raid0_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-2"); /* RAID0 */ +MODULE_ALIAS("md-raid0"); MODULE_ALIAS("md-level-0"); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7d4465f..181c961 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2092,4 +2092,5 @@ module_init(raid_init); module_exit(raid_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-3"); /* RAID1 */ +MODULE_ALIAS("md-raid1"); MODULE_ALIAS("md-level-1"); diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 8e6f6df..201dc71 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -2117,4 +2117,5 @@ module_init(raid_init); module_exit(raid_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-9"); /* RAID10 */ +MODULE_ALIAS("md-raid10"); MODULE_ALIAS("md-level-10"); diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index b0cfd3c..9cc844f 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -2240,5 +2240,7 @@ module_init(raid5_init); module_exit(raid5_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-4"); /* RAID5 */ +MODULE_ALIAS("md-raid5"); +MODULE_ALIAS("md-raid4"); MODULE_ALIAS("md-level-5"); MODULE_ALIAS("md-level-4"); diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 06b32bd..84dd875 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -2341,4 +2341,5 @@ module_init(raid6_init); module_exit(raid6_exit); MODULE_LICENSE("GPL"); MODULE_ALIAS("md-personality-8"); /* RAID6 */ +MODULE_ALIAS("md-raid6"); MODULE_ALIAS("md-level-6"); diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 0fb5af6..6864631 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -119,6 +119,7 @@ struct mddev_s int chunk_size; time_t ctime, utime; int level, layout; + char clevel[16]; int raid_disks; int max_disks; sector_t size; /* used size of component devices */ -- cgit v1.1 From 4dbcdc751cb25ffca3a8374cbc5ab6de961cc545 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:52 -0800 Subject: [PATCH] md: count corrected read errors per drive Store this total in superblock (As appropriate), and make it available to userspace via sysfs. Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 11 +++++++++++ drivers/md/md.c | 27 ++++++++++++++++++++++++++- drivers/md/raid1.c | 2 ++ drivers/md/raid10.c | 11 ++++++++--- drivers/md/raid5.c | 3 +++ drivers/md/raid6main.c | 3 +++ include/linux/raid/md_k.h | 4 ++++ 7 files changed, 57 insertions(+), 4 deletions(-) diff --git a/Documentation/md.txt b/Documentation/md.txt index fd43fd2..a3eadf8 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -222,6 +222,17 @@ Each directory contains: of being recoverred to This list make grow in future. + errors + An approximate count of read errors that have been detected on + this device but have not caused the device to be evicted from + the array (either because they were corrected or because they + happened while the array was read-only). When using version-1 + metadata, this value persists across restarts of the array. + + This value can be written while assembling an array thus + providing an ongoing count for arrays with metadata managed by + userspace. + An active md device will also contain and entry for each active device in the array. These are named diff --git a/drivers/md/md.c b/drivers/md/md.c index 594d8c3..32a4e23 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1000,6 +1000,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version) } rdev->preferred_minor = 0xffff; rdev->data_offset = le64_to_cpu(sb->data_offset); + atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read)); rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256; bmask = queue_hardsect_size(rdev->bdev->bd_disk->queue)-1; @@ -1139,6 +1140,8 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev) else sb->resync_offset = cpu_to_le64(0); + sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors); + if (mddev->bitmap && mddev->bitmap_file == NULL) { sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); @@ -1592,9 +1595,30 @@ super_show(mdk_rdev_t *rdev, char *page) } static struct rdev_sysfs_entry rdev_super = __ATTR_RO(super); +static ssize_t +errors_show(mdk_rdev_t *rdev, char *page) +{ + return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors)); +} + +static ssize_t +errors_store(mdk_rdev_t *rdev, const char *buf, size_t len) +{ + char *e; + unsigned long n = simple_strtoul(buf, &e, 10); + if (*buf && (*e == 0 || *e == '\n')) { + atomic_set(&rdev->corrected_errors, n); + return len; + } + return -EINVAL; +} +static struct rdev_sysfs_entry rdev_errors = +__ATTR(errors, 0644, errors_show, errors_store); + static struct attribute *rdev_default_attrs[] = { &rdev_state.attr, &rdev_super.attr, + &rdev_errors.attr, NULL, }; static ssize_t @@ -1674,6 +1698,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi rdev->data_offset = 0; atomic_set(&rdev->nr_pending, 0); atomic_set(&rdev->read_errors, 0); + atomic_set(&rdev->corrected_errors, 0); size = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; if (!size) { @@ -4729,7 +4754,7 @@ static int set_ro(const char *val, struct kernel_param *kp) int num = simple_strtoul(val, &e, 10); if (*val && (*e == '\0' || *e == '\n')) { start_readonly = num; - return 0;; + return 0; } return -EINVAL; } diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 181c961..a06ff91 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1265,6 +1265,7 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) if (r1_bio->bios[d]->bi_end_io != end_sync_read) continue; rdev = conf->mirrors[d].rdev; + atomic_add(s, &rdev->corrected_errors); if (sync_page_io(rdev->bdev, sect + rdev->data_offset, s<<9, @@ -1463,6 +1464,7 @@ static void raid1d(mddev_t *mddev) d = conf->raid_disks; d--; rdev = conf->mirrors[d].rdev; + atomic_add(s, &rdev->corrected_errors); if (rdev && test_bit(In_sync, &rdev->flags)) { if (sync_page_io(rdev->bdev, diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 201dc71..9e658e5 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1122,9 +1122,13 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) if (test_bit(BIO_UPTODATE, &bio->bi_flags)) set_bit(R10BIO_Uptodate, &r10_bio->state); - else if (!test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery)) - md_error(r10_bio->mddev, - conf->mirrors[d].rdev); + else { + atomic_add(r10_bio->sectors, + &conf->mirrors[d].rdev->corrected_errors); + if (!test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery)) + md_error(r10_bio->mddev, + conf->mirrors[d].rdev); + } /* for reconstruct, we always reschedule after a read. * for resync, only after all reads @@ -1430,6 +1434,7 @@ static void raid10d(mddev_t *mddev) sl--; d = r10_bio->devs[sl].devnum; rdev = conf->mirrors[d].rdev; + atomic_add(s, &rdev->corrected_errors); if (rdev && test_bit(In_sync, &rdev->flags)) { if (sync_page_io(rdev->bdev, diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 9cc844f..54f4a98 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -1400,6 +1400,9 @@ static void handle_stripe(struct stripe_head *sh) bi->bi_io_vec[0].bv_offset = 0; bi->bi_size = STRIPE_SIZE; bi->bi_next = NULL; + if (rw == WRITE && + test_bit(R5_ReWrite, &sh->dev[i].flags)) + atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); generic_make_request(bi); } else { if (rw == 1) diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c index 84dd875..8c823d6 100644 --- a/drivers/md/raid6main.c +++ b/drivers/md/raid6main.c @@ -1562,6 +1562,9 @@ static void handle_stripe(struct stripe_head *sh, struct page *tmp_page) bi->bi_io_vec[0].bv_offset = 0; bi->bi_size = STRIPE_SIZE; bi->bi_next = NULL; + if (rw == WRITE && + test_bit(R5_ReWrite, &sh->dev[i].flags)) + atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); generic_make_request(bi); } else { if (rw == 1) diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 6864631..68b929c 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -95,6 +95,10 @@ struct mdk_rdev_s atomic_t read_errors; /* number of consecutive read errors that * we have tried to ignore. */ + atomic_t corrected_errors; /* number of corrected read errors, + * for reporting to userspace and storing + * in superblock. + */ }; struct mddev_s -- cgit v1.1 From da943b9912df063322d37b1a1f285460531d481d Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:54 -0800 Subject: [PATCH] md: allow md/raid_disks to be settable If array is active, try to reshape, else just set the value. Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 3 +++ drivers/md/md.c | 74 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 23 deletions(-) diff --git a/Documentation/md.txt b/Documentation/md.txt index a3eadf8..69f742d 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -165,6 +165,9 @@ All md devices contain: in a fully functional array. If this is not yet known, the file will be empty. If an array is being resized (not currently possible) this will contain the larger of the old and new sizes. + Some raid level (RAID1) allow this value to be set while the + array is active. This will reconfigure the array. Otherwise + it can only be set while assembling an array. chunk_size This is the size if bytes for 'chunks' and is only relevant to diff --git a/drivers/md/md.c b/drivers/md/md.c index 32a4e23..86e9f2e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1843,7 +1843,27 @@ raid_disks_show(mddev_t *mddev, char *page) return sprintf(page, "%d\n", mddev->raid_disks); } -static struct md_sysfs_entry md_raid_disks = __ATTR_RO(raid_disks); +static int update_raid_disks(mddev_t *mddev, int raid_disks); + +static ssize_t +raid_disks_store(mddev_t *mddev, const char *buf, size_t len) +{ + /* can only set raid_disks if array is not yet active */ + char *e; + int rv = 0; + unsigned long n = simple_strtoul(buf, &e, 10); + + if (!*buf || (*e && *e != '\n')) + return -EINVAL; + + if (mddev->pers) + rv = update_raid_disks(mddev, n); + else + mddev->raid_disks = n; + return rv ? rv : len; +} +static struct md_sysfs_entry md_raid_disks = +__ATTR(raid_disks, 0644, raid_disks_show, raid_disks_store); static ssize_t chunk_size_show(mddev_t *mddev, char *page) @@ -3201,6 +3221,33 @@ static int update_size(mddev_t *mddev, unsigned long size) return rv; } +static int update_raid_disks(mddev_t *mddev, int raid_disks) +{ + int rv; + /* change the number of raid disks */ + if (mddev->pers->reshape == NULL) + return -EINVAL; + if (raid_disks <= 0 || + raid_disks >= mddev->max_disks) + return -EINVAL; + if (mddev->sync_thread) + return -EBUSY; + rv = mddev->pers->reshape(mddev, raid_disks); + if (!rv) { + struct block_device *bdev; + + bdev = bdget_disk(mddev->gendisk, 0); + if (bdev) { + down(&bdev->bd_inode->i_sem); + i_size_write(bdev->bd_inode, mddev->array_size << 10); + up(&bdev->bd_inode->i_sem); + bdput(bdev); + } + } + return rv; +} + + /* * update_array_info is used to change the configuration of an * on-line array. @@ -3252,28 +3299,9 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info) if (mddev->size != info->size) rv = update_size(mddev, info->size); - if (mddev->raid_disks != info->raid_disks) { - /* change the number of raid disks */ - if (mddev->pers->reshape == NULL) - return -EINVAL; - if (info->raid_disks <= 0 || - info->raid_disks >= mddev->max_disks) - return -EINVAL; - if (mddev->sync_thread) - return -EBUSY; - rv = mddev->pers->reshape(mddev, info->raid_disks); - if (!rv) { - struct block_device *bdev; - - bdev = bdget_disk(mddev->gendisk, 0); - if (bdev) { - down(&bdev->bd_inode->i_sem); - i_size_write(bdev->bd_inode, mddev->array_size << 10); - up(&bdev->bd_inode->i_sem); - bdput(bdev); - } - } - } + if (mddev->raid_disks != info->raid_disks) + rv = update_raid_disks(mddev, info->raid_disks); + if ((state ^ info->state) & (1<pers->quiesce == NULL) return -EINVAL; -- cgit v1.1 From 2bf071bf50580380a8c3afe5eef8152a66be96c7 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:55 -0800 Subject: [PATCH] md: keep better track of dev/array size when assembling md arrays Move the checks - that dev size is never less than array size - into bind_rdev_to_array to make sure it always happens properly (there is one place where currently it doesn't). Also reject any superblock which claims an array size smaller than the device in question can hold. Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 86e9f2e..27a9871 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -695,6 +695,10 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version } rdev->size = calc_dev_size(rdev, sb->chunk_size); + if (rdev->size < sb->size && sb->level > 1) + /* "this cannot possibly happen" ... */ + ret = -EINVAL; + abort: return ret; } @@ -1039,6 +1043,9 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version) rdev->size = le64_to_cpu(sb->data_size)/2; if (le32_to_cpu(sb->chunksize)) rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1); + + if (le32_to_cpu(sb->size) > rdev->size*2) + return -EINVAL; return 0; } @@ -1224,6 +1231,14 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) MD_BUG(); return -EINVAL; } + /* make sure rdev->size exceeds mddev->size */ + if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) { + if (mddev->pers) + /* Cannot change size, so fail */ + return -ENOSPC; + else + mddev->size = rdev->size; + } same_pdev = match_dev_unit(mddev, rdev); if (same_pdev) printk(KERN_WARNING @@ -2898,12 +2913,6 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) if (info->state & (1<flags); - err = bind_rdev_to_array(rdev, mddev); - if (err) { - export_rdev(rdev); - return err; - } - if (!mddev->persistent) { printk(KERN_INFO "md: nonpersistent superblock ...\n"); rdev->sb_offset = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; @@ -2911,8 +2920,11 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) rdev->sb_offset = calc_dev_sboffset(rdev->bdev); rdev->size = calc_dev_size(rdev, mddev->chunk_size); - if (!mddev->size || (mddev->size > rdev->size)) - mddev->size = rdev->size; + err = bind_rdev_to_array(rdev, mddev); + if (err) { + export_rdev(rdev); + return err; + } } return 0; @@ -2984,15 +2996,6 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev) size = calc_dev_size(rdev, mddev->chunk_size); rdev->size = size; - if (size < mddev->size) { - printk(KERN_WARNING - "%s: disk size %llu blocks < array size %llu\n", - mdname(mddev), (unsigned long long)size, - (unsigned long long)mddev->size); - err = -ENOSPC; - goto abort_export; - } - if (test_bit(Faulty, &rdev->flags)) { printk(KERN_WARNING "md: can not hot-add faulty %s disk to %s!\n", @@ -3002,7 +3005,9 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev) } clear_bit(In_sync, &rdev->flags); rdev->desc_nr = -1; - bind_rdev_to_array(rdev, mddev); + err = bind_rdev_to_array(rdev, mddev); + if (err) + goto abort_export; /* * The rest should better be atomic, we can have disk failures -- cgit v1.1 From 014236d2b8ec6faea2a6134ab8e019d84d67b524 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:55 -0800 Subject: [PATCH] md: expose device slot information via sysfs This the role that a device has in an array can be viewed and set. Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 8 ++++++++ drivers/md/md.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/Documentation/md.txt b/Documentation/md.txt index 69f742d..d525fff 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -236,6 +236,14 @@ Each directory contains: providing an ongoing count for arrays with metadata managed by userspace. + slot + This gives the role that the device has in the array. It will + either be 'none' if the device is not active in the array + (i.e. is a spare or has failed) or an integer less than the + 'raid_disks' number for the array indicating which possition + it currently fills. This can only be set while assembling an + array. A device for which this is set is assumed to be working. + An active md device will also contain and entry for each active device in the array. These are named diff --git a/drivers/md/md.c b/drivers/md/md.c index 27a9871..a816956 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1630,10 +1630,45 @@ errors_store(mdk_rdev_t *rdev, const char *buf, size_t len) static struct rdev_sysfs_entry rdev_errors = __ATTR(errors, 0644, errors_show, errors_store); +static ssize_t +slot_show(mdk_rdev_t *rdev, char *page) +{ + if (rdev->raid_disk < 0) + return sprintf(page, "none\n"); + else + return sprintf(page, "%d\n", rdev->raid_disk); +} + +static ssize_t +slot_store(mdk_rdev_t *rdev, const char *buf, size_t len) +{ + char *e; + int slot = simple_strtoul(buf, &e, 10); + if (strncmp(buf, "none", 4)==0) + slot = -1; + else if (e==buf || (*e && *e!= '\n')) + return -EINVAL; + if (rdev->mddev->pers) + /* Cannot set slot in active array (yet) */ + return -EBUSY; + if (slot >= rdev->mddev->raid_disks) + return -ENOSPC; + rdev->raid_disk = slot; + /* assume it is working */ + rdev->flags = 0; + set_bit(In_sync, &rdev->flags); + return len; +} + + +static struct rdev_sysfs_entry rdev_slot = +__ATTR(slot, 0644, slot_show, slot_store); + static struct attribute *rdev_default_attrs[] = { &rdev_state.attr, &rdev_super.attr, &rdev_errors.attr, + &rdev_slot.attr, NULL, }; static ssize_t -- cgit v1.1 From 93c8cad03f02dbd1532a5413bdced25f000d5728 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:20:56 -0800 Subject: [PATCH] md: export rdev->data_offset via sysfs Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 6 ++++++ drivers/md/md.c | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Documentation/md.txt b/Documentation/md.txt index d525fff..866a1a8 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -244,6 +244,12 @@ Each directory contains: it currently fills. This can only be set while assembling an array. A device for which this is set is assumed to be working. + offset + This gives the location in the device (in sectors from the + start) where data from the array will be stored. Any part of + the device before this offset us not touched, unless it is + used for storing metadata (Formats 1.1 and 1.2). + An active md device will also contain and entry for each active device in the array. These are named diff --git a/drivers/md/md.c b/drivers/md/md.c index a816956..742a82a 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1664,11 +1664,34 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len) static struct rdev_sysfs_entry rdev_slot = __ATTR(slot, 0644, slot_show, slot_store); +static ssize_t +offset_show(mdk_rdev_t *rdev, char *page) +{ + return sprintf(page, "%llu\n", rdev->data_offset); +} + +static ssize_t +offset_store(mdk_rdev_t *rdev, const char *buf, size_t len) +{ + char *e; + unsigned long long offset = simple_strtoull(buf, &e, 10); + if (e==buf || (*e && *e != '\n')) + return -EINVAL; + if (rdev->mddev->pers) + return -EBUSY; + rdev->data_offset = offset; + return len; +} + +static struct rdev_sysfs_entry rdev_offset = +__ATTR(offset, 0644, offset_show, offset_store); + static struct attribute *rdev_default_attrs[] = { &rdev_state.attr, &rdev_super.attr, &rdev_errors.attr, &rdev_slot.attr, + &rdev_offset.attr, NULL, }; static ssize_t -- cgit v1.1 From 6961ece46c7d02de1bb83914900608e39633787d Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 6 Jan 2006 00:20:59 -0800 Subject: [PATCH] md-export-rdev-data_offset-via-sysfs-fix drivers/md/md.c: In function `offset_show': drivers/md/md.c:1670: warning: long long unsigned int format, different type arg (arg 3) Cc: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/md.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 742a82a..27db100 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1667,7 +1667,7 @@ __ATTR(slot, 0644, slot_show, slot_store); static ssize_t offset_show(mdk_rdev_t *rdev, char *page) { - return sprintf(page, "%llu\n", rdev->data_offset); + return sprintf(page, "%llu\n", (unsigned long long)rdev->data_offset); } static ssize_t -- cgit v1.1 From 83303b613d00718b07ec0a4dee7c99aa66629d96 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:21:06 -0800 Subject: [PATCH] md: allow available size of component devices to be set via sysfs Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 7 +++++++ drivers/md/md.c | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/Documentation/md.txt b/Documentation/md.txt index 866a1a8..7b3d471 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -250,6 +250,13 @@ Each directory contains: the device before this offset us not touched, unless it is used for storing metadata (Formats 1.1 and 1.2). + size + The amount of the device, after the offset, that can be used + for storage of data. This will normally be the same as the + component_size. This can be written while assembling an + array. If a value less than the current component_size is + written, component_size will be reduced to this value. + An active md device will also contain and entry for each active device in the array. These are named diff --git a/drivers/md/md.c b/drivers/md/md.c index 27db100..40ac7fb 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1686,12 +1686,37 @@ offset_store(mdk_rdev_t *rdev, const char *buf, size_t len) static struct rdev_sysfs_entry rdev_offset = __ATTR(offset, 0644, offset_show, offset_store); +static ssize_t +rdev_size_show(mdk_rdev_t *rdev, char *page) +{ + return sprintf(page, "%llu\n", (unsigned long long)rdev->size); +} + +static ssize_t +rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len) +{ + char *e; + unsigned long long size = simple_strtoull(buf, &e, 10); + if (e==buf || (*e && *e != '\n')) + return -EINVAL; + if (rdev->mddev->pers) + return -EBUSY; + rdev->size = size; + if (size < rdev->mddev->size || rdev->mddev->size == 0) + rdev->mddev->size = size; + return len; +} + +static struct rdev_sysfs_entry rdev_size = +__ATTR(size, 0644, rdev_size_show, rdev_size_store); + static struct attribute *rdev_default_attrs[] = { &rdev_state.attr, &rdev_super.attr, &rdev_errors.attr, &rdev_slot.attr, &rdev_offset.attr, + &rdev_size.attr, NULL, }; static ssize_t -- cgit v1.1 From 6d7ff7380b2e28c2807da3bf9fa614d91d15bacf Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:21:16 -0800 Subject: [PATCH] md: support adding new devices to md arrays via sysfs Writing major:minor to md/new_dev will bind that device to the array. Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 8 +++++++ drivers/md/md.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/Documentation/md.txt b/Documentation/md.txt index 7b3d471..b8d172b 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -200,6 +200,14 @@ All md devices contain: This can be written only while the array is being assembled, not after it is started. + new_dev + This file can be written but not read. The value written should + be a block device number as major:minor. e.g. 8:0 + This will cause that device to be attached to the array, if it is + available. It will then appear at md/dev-XXX (depending on the + name of the device) and further configuration is then possible. + + As component devices are added to an md array, they appear in the 'md' directory as new directories named dev-XXX diff --git a/drivers/md/md.c b/drivers/md/md.c index 40ac7fb..825e235 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1987,6 +1987,65 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len) static struct md_sysfs_entry md_chunk_size = __ATTR(chunk_size, 0644, chunk_size_show, chunk_size_store); +static ssize_t +null_show(mddev_t *mddev, char *page) +{ + return -EINVAL; +} + +static ssize_t +new_dev_store(mddev_t *mddev, const char *buf, size_t len) +{ + /* buf must be %d:%d\n? giving major and minor numbers */ + /* The new device is added to the array. + * If the array has a persistent superblock, we read the + * superblock to initialise info and check validity. + * Otherwise, only checking done is that in bind_rdev_to_array, + * which mainly checks size. + */ + char *e; + int major = simple_strtoul(buf, &e, 10); + int minor; + dev_t dev; + mdk_rdev_t *rdev; + int err; + + if (!*buf || *e != ':' || !e[1] || e[1] == '\n') + return -EINVAL; + minor = simple_strtoul(e+1, &e, 10); + if (*e && *e != '\n') + return -EINVAL; + dev = MKDEV(major, minor); + if (major != MAJOR(dev) || + minor != MINOR(dev)) + return -EOVERFLOW; + + + if (mddev->persistent) { + rdev = md_import_device(dev, mddev->major_version, + mddev->minor_version); + if (!IS_ERR(rdev) && !list_empty(&mddev->disks)) { + mdk_rdev_t *rdev0 = list_entry(mddev->disks.next, + mdk_rdev_t, same_set); + err = super_types[mddev->major_version] + .load_super(rdev, rdev0, mddev->minor_version); + if (err < 0) + goto out; + } + } else + rdev = md_import_device(dev, -1, -1); + + if (IS_ERR(rdev)) + return PTR_ERR(rdev); + err = bind_rdev_to_array(rdev, mddev); + out: + if (err) + export_rdev(rdev); + return err ? err : len; +} + +static struct md_sysfs_entry md_new_device = +__ATTR(new_dev, 0200, null_show, new_dev_store); static ssize_t size_show(mddev_t *mddev, char *page) @@ -2144,6 +2203,7 @@ static struct attribute *md_default_attrs[] = { &md_chunk_size.attr, &md_size.attr, &md_metadata.attr, + &md_new_device.attr, NULL, }; -- cgit v1.1 From 88202a0c84e1951d6630d1d557d4801a8cc5b5ef Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 6 Jan 2006 00:21:36 -0800 Subject: [PATCH] md: allow sync-speed to be controlled per-device Also export current (average) speed and status in sysfs. Signed-off-by: Neil Brown Acked-by: Greg KH Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Documentation/md.txt | 22 ++++++++++ drivers/md/md.c | 110 +++++++++++++++++++++++++++++++++++++++++++--- include/linux/raid/md_k.h | 4 ++ 3 files changed, 131 insertions(+), 5 deletions(-) diff --git a/Documentation/md.txt b/Documentation/md.txt index b8d172b..03a13c4 100644 --- a/Documentation/md.txt +++ b/Documentation/md.txt @@ -207,6 +207,28 @@ All md devices contain: available. It will then appear at md/dev-XXX (depending on the name of the device) and further configuration is then possible. + sync_speed_min + sync_speed_max + This are similar to /proc/sys/dev/raid/speed_limit_{min,max} + however they only apply to the particular array. + If no value has been written to these, of if the word 'system' + is written, then the system-wide value is used. If a value, + in kibibytes-per-second is written, then it is used. + When the files are read, they show the currently active value + followed by "(local)" or "(system)" depending on whether it is + a locally set or system-wide value. + + sync_completed + This shows the number of sectors that have been completed of + whatever the current sync_action is, followed by the number of + sectors in total that could need to be processed. The two + numbers are separated by a '/' thus effectively showing one + value, a fraction of the process that is complete. + + sync_speed + This shows the current actual speed, in K/sec, of the current + sync_action. It is averaged over the last 30 seconds. + As component devices are added to an md array, they appear in the 'md' directory as new directories named diff --git a/drivers/md/md.c b/drivers/md/md.c index 825e235..1b76fb2 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -81,10 +81,22 @@ static DEFINE_SPINLOCK(pers_lock); * idle IO detection. * * you can change it via /proc/sys/dev/raid/speed_limit_min and _max. + * or /sys/block/mdX/md/sync_speed_{min,max} */ static int sysctl_speed_limit_min = 1000; static int sysctl_speed_limit_max = 200000; +static inline int speed_min(mddev_t *mddev) +{ + return mddev->sync_speed_min ? + mddev->sync_speed_min : sysctl_speed_limit_min; +} + +static inline int speed_max(mddev_t *mddev) +{ + return mddev->sync_speed_max ? + mddev->sync_speed_max : sysctl_speed_limit_max; +} static struct ctl_table_header *raid_table_header; @@ -2197,6 +2209,90 @@ md_scan_mode = __ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store); static struct md_sysfs_entry md_mismatches = __ATTR_RO(mismatch_cnt); +static ssize_t +sync_min_show(mddev_t *mddev, char *page) +{ + return sprintf(page, "%d (%s)\n", speed_min(mddev), + mddev->sync_speed_min ? "local": "system"); +} + +static ssize_t +sync_min_store(mddev_t *mddev, const char *buf, size_t len) +{ + int min; + char *e; + if (strncmp(buf, "system", 6)==0) { + mddev->sync_speed_min = 0; + return len; + } + min = simple_strtoul(buf, &e, 10); + if (buf == e || (*e && *e != '\n') || min <= 0) + return -EINVAL; + mddev->sync_speed_min = min; + return len; +} + +static struct md_sysfs_entry md_sync_min = +__ATTR(sync_speed_min, S_IRUGO|S_IWUSR, sync_min_show, sync_min_store); + +static ssize_t +sync_max_show(mddev_t *mddev, char *page) +{ + return sprintf(page, "%d (%s)\n", speed_max(mddev), + mddev->sync_speed_max ? "local": "system"); +} + +static ssize_t +sync_max_store(mddev_t *mddev, const char *buf, size_t len) +{ + int max; + char *e; + if (strncmp(buf, "system", 6)==0) { + mddev->sync_speed_max = 0; + return len; + } + max = simple_strtoul(buf, &e, 10); + if (buf == e || (*e && *e != '\n') || max <= 0) + return -EINVAL; + mddev->sync_speed_max = max; + return len; +} + +static struct md_sysfs_entry md_sync_max = +__ATTR(sync_speed_max, S_IRUGO|S_IWUSR, sync_max_show, sync_max_store); + + +static ssize_t +sync_speed_show(mddev_t *mddev, char *page) +{ + unsigned long resync, dt, db; + resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active)); + dt = ((jiffies - mddev->resync_mark) / HZ); + if (!dt) dt++; + db = resync - (mddev->resync_mark_cnt); + return sprintf(page, "%ld\n", db/dt/2); /* K/sec */ +} + +static struct md_sysfs_entry +md_sync_speed = __ATTR_RO(sync_speed); + +static ssize_t +sync_completed_show(mddev_t *mddev, char *page) +{ + unsigned long max_blocks, resync; + + if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) + max_blocks = mddev->resync_max_sectors; + else + max_blocks = mddev->size << 1; + + resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active)); + return sprintf(page, "%lu / %lu\n", resync, max_blocks); +} + +static struct md_sysfs_entry +md_sync_completed = __ATTR_RO(sync_completed); + static struct attribute *md_default_attrs[] = { &md_level.attr, &md_raid_disks.attr, @@ -2210,6 +2306,10 @@ static struct attribute *md_default_attrs[] = { static struct attribute *md_redundancy_attrs[] = { &md_scan_mode.attr, &md_mismatches.attr, + &md_sync_min.attr, + &md_sync_max.attr, + &md_sync_speed.attr, + &md_sync_completed.attr, NULL, }; static struct attribute_group md_redundancy_group = { @@ -4433,10 +4533,10 @@ static void md_do_sync(mddev_t *mddev) printk(KERN_INFO "md: syncing RAID array %s\n", mdname(mddev)); printk(KERN_INFO "md: minimum _guaranteed_ reconstruction speed:" - " %d KB/sec/disc.\n", sysctl_speed_limit_min); + " %d KB/sec/disc.\n", speed_min(mddev)); printk(KERN_INFO "md: using maximum available idle IO bandwidth " "(but not more than %d KB/sec) for reconstruction.\n", - sysctl_speed_limit_max); + speed_max(mddev)); is_mddev_idle(mddev); /* this also initializes IO event counters */ /* we don't use the checkpoint if there's a bitmap */ @@ -4477,7 +4577,7 @@ static void md_do_sync(mddev_t *mddev) skipped = 0; sectors = mddev->pers->sync_request(mddev, j, &skipped, - currspeed < sysctl_speed_limit_min); + currspeed < speed_min(mddev)); if (sectors == 0) { set_bit(MD_RECOVERY_ERR, &mddev->recovery); goto out; @@ -4542,8 +4642,8 @@ static void md_do_sync(mddev_t *mddev) currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2 /((jiffies-mddev->resync_mark)/HZ +1) +1; - if (currspeed > sysctl_speed_limit_min) { - if ((currspeed > sysctl_speed_limit_max) || + if (currspeed > speed_min(mddev)) { + if ((currspeed > speed_max(mddev)) || !is_mddev_idle(mddev)) { msleep(500); goto repeat; diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h index 68b929c..617b950 100644 --- a/include/linux/raid/md_k.h +++ b/include/linux/raid/md_k.h @@ -143,6 +143,10 @@ struct mddev_s sector_t resync_mismatches; /* count of sectors where * parity/replica mismatch found */ + /* if zero, use the system-wide default */ + int sync_speed_min; + int sync_speed_max; + int ok_start_degraded; /* recovery/resync flags * NEEDED: we might need to start a resync/recover -- cgit v1.1 From 9b847548663ef1039dd49f0eb4463d001e596bc3 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 6 Jan 2006 09:28:07 +0100 Subject: [PATCH] Suspend support for libata This patch adds suspend patch to libata, and ata_piix in particular. For most low level drivers, they should just need to add the 4 hooks to work. As I can only test ata_piix, I didn't enable it for more though. Suspend support is the single most important feature on a notebook, and most new notebooks have sata drives. It's quite embarrassing that we _still_ do not support this. Right now, it's perfectly possible to suspend the drive in mid-transfer. Signed-off-by: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/ata_piix.c | 4 ++ drivers/scsi/libata-core.c | 114 +++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/libata-scsi.c | 16 +++++++ drivers/scsi/scsi_sysfs.c | 31 ++++++++++++ include/linux/ata.h | 2 + include/linux/libata.h | 8 ++++ include/scsi/scsi_host.h | 6 +++ 7 files changed, 181 insertions(+) diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c index 0ea2787..f796303 100644 --- a/drivers/scsi/ata_piix.c +++ b/drivers/scsi/ata_piix.c @@ -166,6 +166,8 @@ static struct pci_driver piix_pci_driver = { .id_table = piix_pci_tbl, .probe = piix_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, }; static struct scsi_host_template piix_sht = { @@ -186,6 +188,8 @@ static struct scsi_host_template piix_sht = { .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static const struct ata_port_operations piix_pata_ops = { diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 9ea1025..9c66d40 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c @@ -4154,6 +4154,96 @@ err_out: * Inherited from caller. */ +/* + * Execute a 'simple' command, that only consists of the opcode 'cmd' itself, + * without filling any other registers + */ +static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev, + u8 cmd) +{ + struct ata_taskfile tf; + int err; + + ata_tf_init(ap, &tf, dev->devno); + + tf.command = cmd; + tf.flags |= ATA_TFLAG_DEVICE; + tf.protocol = ATA_PROT_NODATA; + + err = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0); + if (err) + printk(KERN_ERR "%s: ata command failed: %d\n", + __FUNCTION__, err); + + return err; +} + +static int ata_flush_cache(struct ata_port *ap, struct ata_device *dev) +{ + u8 cmd; + + if (!ata_try_flush_cache(dev)) + return 0; + + if (ata_id_has_flush_ext(dev->id)) + cmd = ATA_CMD_FLUSH_EXT; + else + cmd = ATA_CMD_FLUSH; + + return ata_do_simple_cmd(ap, dev, cmd); +} + +static int ata_standby_drive(struct ata_port *ap, struct ata_device *dev) +{ + return ata_do_simple_cmd(ap, dev, ATA_CMD_STANDBYNOW1); +} + +static int ata_start_drive(struct ata_port *ap, struct ata_device *dev) +{ + return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE); +} + +/** + * ata_device_resume - wakeup a previously suspended devices + * + * Kick the drive back into action, by sending it an idle immediate + * command and making sure its transfer mode matches between drive + * and host. + * + */ +int ata_device_resume(struct ata_port *ap, struct ata_device *dev) +{ + if (ap->flags & ATA_FLAG_SUSPENDED) { + ap->flags &= ~ATA_FLAG_SUSPENDED; + ata_set_mode(ap); + } + if (!ata_dev_present(dev)) + return 0; + if (dev->class == ATA_DEV_ATA) + ata_start_drive(ap, dev); + + return 0; +} + +/** + * ata_device_suspend - prepare a device for suspend + * + * Flush the cache on the drive, if appropriate, then issue a + * standbynow command. + * + */ +int ata_device_suspend(struct ata_port *ap, struct ata_device *dev) +{ + if (!ata_dev_present(dev)) + return 0; + if (dev->class == ATA_DEV_ATA) + ata_flush_cache(ap, dev); + + ata_standby_drive(ap, dev); + ap->flags |= ATA_FLAG_SUSPENDED; + return 0; +} + int ata_port_start (struct ata_port *ap) { struct device *dev = ap->host_set->dev; @@ -4902,6 +4992,23 @@ int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits) return (tmp == bits->val) ? 1 : 0; } + +int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state) +{ + pci_save_state(pdev); + pci_disable_device(pdev); + pci_set_power_state(pdev, PCI_D3hot); + return 0; +} + +int ata_pci_device_resume(struct pci_dev *pdev) +{ + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + pci_enable_device(pdev); + pci_set_master(pdev); + return 0; +} #endif /* CONFIG_PCI */ @@ -5005,4 +5112,11 @@ EXPORT_SYMBOL_GPL(ata_pci_host_stop); EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); EXPORT_SYMBOL_GPL(ata_pci_init_one); EXPORT_SYMBOL_GPL(ata_pci_remove_one); +EXPORT_SYMBOL_GPL(ata_pci_device_suspend); +EXPORT_SYMBOL_GPL(ata_pci_device_resume); #endif /* CONFIG_PCI */ + +EXPORT_SYMBOL_GPL(ata_device_suspend); +EXPORT_SYMBOL_GPL(ata_device_resume); +EXPORT_SYMBOL_GPL(ata_scsi_device_suspend); +EXPORT_SYMBOL_GPL(ata_scsi_device_resume); diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c index e0439be..c1ebede 100644 --- a/drivers/scsi/libata-scsi.c +++ b/drivers/scsi/libata-scsi.c @@ -396,6 +396,22 @@ void ata_dump_status(unsigned id, struct ata_taskfile *tf) } } +int ata_scsi_device_resume(struct scsi_device *sdev) +{ + struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; + struct ata_device *dev = &ap->device[sdev->id]; + + return ata_device_resume(ap, dev); +} + +int ata_scsi_device_suspend(struct scsi_device *sdev) +{ + struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; + struct ata_device *dev = &ap->device[sdev->id]; + + return ata_device_suspend(ap, dev); +} + /** * ata_to_sense_error - convert ATA error to SCSI error * @id: ATA device number diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 15842b1..ea7f3a4 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -263,9 +263,40 @@ static int scsi_bus_match(struct device *dev, struct device_driver *gendrv) return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; } +static int scsi_bus_suspend(struct device * dev, pm_message_t state) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct scsi_host_template *sht = sdev->host->hostt; + int err; + + err = scsi_device_quiesce(sdev); + if (err) + return err; + + if (sht->suspend) + err = sht->suspend(sdev); + + return err; +} + +static int scsi_bus_resume(struct device * dev) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct scsi_host_template *sht = sdev->host->hostt; + int err = 0; + + if (sht->resume) + err = sht->resume(sdev); + + scsi_device_resume(sdev); + return err; +} + struct bus_type scsi_bus_type = { .name = "scsi", .match = scsi_bus_match, + .suspend = scsi_bus_suspend, + .resume = scsi_bus_resume, }; int scsi_sysfs_register(void) diff --git a/include/linux/ata.h b/include/linux/ata.h index d2873b7..3eb80c3 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -141,6 +141,8 @@ enum { ATA_CMD_PACKET = 0xA0, ATA_CMD_VERIFY = 0x40, ATA_CMD_VERIFY_EXT = 0x42, + ATA_CMD_STANDBYNOW1 = 0xE0, + ATA_CMD_IDLEIMMEDIATE = 0xE1, ATA_CMD_INIT_DEV_PARAMS = 0x91, /* SETFEATURES stuff */ diff --git a/include/linux/libata.h b/include/linux/libata.h index e828e17..cdab75c 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -124,6 +124,8 @@ enum { ATA_FLAG_DEBUGMSG = (1 << 10), ATA_FLAG_NO_ATAPI = (1 << 11), /* No ATAPI support */ + ATA_FLAG_SUSPENDED = (1 << 12), /* port is suspended */ + ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */ ATA_QCFLAG_SINGLE = (1 << 4), /* no s/g, just a single buffer */ @@ -436,6 +438,8 @@ extern void ata_std_ports(struct ata_ioports *ioaddr); extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, unsigned int n_ports); extern void ata_pci_remove_one (struct pci_dev *pdev); +extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state); +extern int ata_pci_device_resume(struct pci_dev *pdev); #endif /* CONFIG_PCI */ extern int ata_device_add(const struct ata_probe_ent *ent); extern void ata_host_set_remove(struct ata_host_set *host_set); @@ -445,6 +449,10 @@ extern int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmn extern int ata_scsi_error(struct Scsi_Host *host); extern int ata_scsi_release(struct Scsi_Host *host); extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); +extern int ata_scsi_device_resume(struct scsi_device *); +extern int ata_scsi_device_suspend(struct scsi_device *); +extern int ata_device_resume(struct ata_port *, struct ata_device *); +extern int ata_device_suspend(struct ata_port *, struct ata_device *); extern int ata_ratelimit(void); /* diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 6cbb198..6297885 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -296,6 +296,12 @@ struct scsi_host_template { int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int); /* + * suspend support + */ + int (*resume)(struct scsi_device *); + int (*suspend)(struct scsi_device *); + + /* * Name of proc directory */ char *proc_name; -- cgit v1.1 From 7ed40918a386afc2e14a6d3da563ea6d13686c25 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 6 Jan 2006 08:43:16 -0800 Subject: x86: remove bogus 'pci=usepirqmask' suggestion when no irq is defined This was harmless, but for the case of a device that had no irq pre-defined we would incorrectly suggest that "usepirqmask" might make a difference. It never would, and the message was just confusing people. Reported in the dmesg of Etienne Lorrain. Signed-off-by: Linus Torvalds --- arch/i386/pci/irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c index 19e6f48..ee8e016 100644 --- a/arch/i386/pci/irq.c +++ b/arch/i386/pci/irq.c @@ -846,7 +846,7 @@ static int pcibios_lookup_irq(struct pci_dev *dev, int assign) * reported by the device if possible. */ newirq = dev->irq; - if (!((1 << newirq) & mask)) { + if (newirq && !((1 << newirq) & mask)) { if ( pci_probe & PCI_USE_PIRQ_MASK) newirq = 0; else printk(KERN_WARNING "PCI: IRQ %i for device %s doesn't match PIRQ mask - try pci=usepirqmask\n", newirq, pci_name(dev)); } -- cgit v1.1 From 253dfa6e465c054a73bd3b13af51c34c9d8d233d Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 6 Jan 2006 20:33:41 +0100 Subject: kbuild: document howto build external modules using several directories Update modules.txt with info how to build external modules with files in several directories. The question popped up on lkml often enough to warrant this, let's see if people read this stuff - or google hits it. Signed-off-by: Sam Ravnborg --- Documentation/kbuild/modules.txt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index 1c0db65..7e77f93 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt @@ -18,6 +18,7 @@ In this document you will find information about: === 5. Include files --- 5.1 How to include files from the kernel include dir --- 5.2 External modules using an include/ dir + --- 5.3 External modules using several directories === 6. Module installation --- 6.1 INSTALL_MOD_PATH --- 6.2 INSTALL_MOD_DIR @@ -344,6 +345,45 @@ directory and therefore needs to deal with this in their kbuild file. Note that in the assignment there is no space between -I and the path. This is a kbuild limitation: there must be no space present. +--- 5.3 External modules using several directories + + If an external module does not follow the usual kernel style but + decide to spread files over several directories then kbuild can + support this too. + + Consider the following example: + + | + +- src/complex_main.c + | +- hal/hardwareif.c + | +- hal/include/hardwareif.h + +- include/complex.h + + To build a single module named complex.ko we then need the following + kbuild file: + + Kbuild: + obj-m := complex.o + complex-y := src/complex_main.o + complex-y += src/hal/hardwareif.o + + EXTRA_CFLAGS := -I$(src)/include + EXTRA_CFLAGS += -I$(src)src/hal/include + + + kbuild knows how to handle .o files located in another directory - + although this is NOT reccommended practice. The syntax is to specify + the directory relative to the directory where the Kbuild file is + located. + + To find the .h files we have to explicitly tell kbuild where to look + for the .h files. When kbuild executes current directory is always + the root of the kernel tree (argument to -C) and therefore we have to + tell kbuild how to find the .h files using absolute paths. + $(src) will specify the absolute path to the directory where the + Kbuild file are located when being build as an external module. + Therefore -I$(src)/ is used to point out the directory of the Kbuild + file and any additional path are just appended. === 6. Module installation -- cgit v1.1 From 117a93db1dcd6ed61336b27e4e2938f791c1841b Mon Sep 17 00:00:00 2001 From: Rene Scharfe Date: Wed, 4 Jan 2006 20:42:03 +0100 Subject: kbuild: Use git in scripts/setlocalversion Currently scripts/setlocalversion is a Perl script that tries to figure out the current git commit ID of a repo without using git. It also imports Digest::MD5 without using it and generally is too big for the small task it does. :] And it always reports a git ID, even when the HEAD is tagged -- this is a bug. This patch replaces it with a Bourne Shell script that uses git commands to do the same. I can't come up with a scenario where someone would use a git repo and refuse to install git core at the same time, so I think it's reasonable to assume git is available. The new script also reports uncommitted changes by adding -git_dirty to the version string. Obviously you can't see from that _what_ has been changed from the last commit, so it's more of a reminder that you forgot to commit something. The script is easily extensible: simply add a check for Mercurial (or whatever) below the git check. Note: the script doesn't print a newline char anymore. That's only because it was easier to implement it that way, not a feature (or bug). 'make kernelrelease' doesn't care. Signed-off-by: Rene Scharfe Acked-by: Ryan Anderson Signed-off-by: Sam Ravnborg --- scripts/setlocalversion | 68 +++++++++++++------------------------------------ 1 file changed, 17 insertions(+), 51 deletions(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 7c805c8..f54dac8 100644 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -1,56 +1,22 @@ -#!/usr/bin/perl -# Copyright 2004 - Ryan Anderson GPL v2 +#!/bin/sh +# Print additional version information for non-release trees. -use strict; -use warnings; -use Digest::MD5; -require 5.006; - -if (@ARGV != 1) { - print < -EOT - exit(1); +usage() { + echo "Usage: $0 [srctree]" >&2 + exit 1 } -my ($srctree) = @ARGV; -chdir($srctree); - -my @LOCALVERSIONS = (); - -# We are going to use the following commands to try and determine if this -# repository is at a Version boundary (i.e, 2.6.10 vs 2.6.10 + some patches) We -# currently assume that all meaningful version boundaries are marked by a tag. -# We don't care what the tag is, just that something exists. - -# Git/Cogito store the top-of-tree "commit" in .git/HEAD -# A list of known tags sits in .git/refs/tags/ -# -# The simple trick here is to just compare the two of these, and if we get a -# match, return nothing, otherwise, return a subset of the SHA-1 hash in -# .git/HEAD - -sub do_git_checks { - open(H,"<.git/HEAD") or return; - my $head = ; - chomp $head; - close(H); +cd "${1:-.}" || usage - opendir(D,".git/refs/tags") or return; - foreach my $tagfile (grep !/^\.{1,2}$/, readdir(D)) { - open(F,"<.git/refs/tags/" . $tagfile) or return; - my $tag = ; - chomp $tag; - close(F); - return if ($tag eq $head); - } - closedir(D); - - push @LOCALVERSIONS, "g" . substr($head,0,8); -} - -if ( -d ".git") { - do_git_checks(); -} +# Check for git and a git repo. +if head=`git rev-parse --verify HEAD 2>/dev/null`; then + # Do we have an untagged version? + if [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then + printf '%s%s' -g `echo "$head" | cut -c1-8` + fi -printf "-%s\n", join("-",@LOCALVERSIONS) if (scalar @LOCALVERSIONS > 0); + # Are there uncommitted changes? + if git diff-files | read dummy; then + printf '%s' -git_dirty + fi +fi -- cgit v1.1 From 20ede2741551d4a1d24313292beb0da915a55911 Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Thu, 5 Jan 2006 12:10:52 -0500 Subject: gitignore: ignore shared objects Many arches make shared objects for VDSOs. Generally exclude them. Signed-off-by: Brian Gerst Signed-off-by: Sam Ravnborg --- .gitignore | 1 + arch/x86_64/ia32/.gitignore | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 arch/x86_64/ia32/.gitignore diff --git a/.gitignore b/.gitignore index a4b576e..3f8fb68 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ *.a *.s *.ko +*.so *.mod.c # diff --git a/arch/x86_64/ia32/.gitignore b/arch/x86_64/ia32/.gitignore deleted file mode 100644 index 48ab174..0000000 --- a/arch/x86_64/ia32/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vsyscall*.so -- cgit v1.1 From 22905f775dd6a8b73be99826dcad07ceec00244b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Wed, 16 Nov 2005 15:07:01 -0800 Subject: identify multipage ->writepages() calls NFS needs to be able to distinguish between single-page ->writepage() calls and multipage ->writepages() calls. For the single-page writepage calls NFS can kick off the I/O within the context of ->writepage(). For multipage ->writepages calls, nfs_writepage() will leave the I/O pending and nfs_writepages() will kick off the I/O when it all has been queued up within NFS. Cc: Trond Myklebust Signed-off-by: Andrew Morton Signed-off-by: Trond Myklebust --- include/linux/writeback.h | 9 +++++---- mm/page-writeback.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index 64a36ba..b096159 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -53,10 +53,11 @@ struct writeback_control { loff_t start; loff_t end; - unsigned nonblocking:1; /* Don't get stuck on request queues */ - unsigned encountered_congestion:1; /* An output: a queue is full */ - unsigned for_kupdate:1; /* A kupdate writeback */ - unsigned for_reclaim:1; /* Invoked from the page allocator */ + unsigned nonblocking:1; /* Don't get stuck on request queues */ + unsigned encountered_congestion:1; /* An output: a queue is full */ + unsigned for_kupdate:1; /* A kupdate writeback */ + unsigned for_reclaim:1; /* Invoked from the page allocator */ + unsigned for_writepages:1; /* This is a writepages() call */ }; /* diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 0166ea15..5240e42 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -550,11 +550,17 @@ void __init page_writeback_init(void) int do_writepages(struct address_space *mapping, struct writeback_control *wbc) { + int ret; + if (wbc->nr_to_write <= 0) return 0; + wbc->for_writepages = 1; if (mapping->a_ops->writepages) - return mapping->a_ops->writepages(mapping, wbc); - return generic_writepages(mapping, wbc); + ret = mapping->a_ops->writepages(mapping, wbc); + else + ret = generic_writepages(mapping, wbc); + wbc->for_writepages = 0; + return ret; } /** -- cgit v1.1 From abd3e641d5ef9f836ab2f2b04d80b8619b051531 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:02 +0100 Subject: NFS: Work correctly with single-page ->writepage() calls Ensure that we always initiate flushing of data before we exit a single-page ->writepage() call. Signed-off-by: Trond Myklebust --- fs/nfs/write.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 3107908..95d00f9 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -232,19 +232,16 @@ static int nfs_writepage_async(struct nfs_open_context *ctx, unsigned int offset, unsigned int count) { struct nfs_page *req; - int status; req = nfs_update_request(ctx, inode, page, offset, count); - status = (IS_ERR(req)) ? PTR_ERR(req) : 0; - if (status < 0) - goto out; + if (IS_ERR(req)) + return PTR_ERR(req); /* Update file length */ nfs_grow_file(page, offset, count); /* Set the PG_uptodate flag? */ nfs_mark_uptodate(page, offset, count); nfs_unlock_request(req); - out: - return status; + return 0; } static int wb_priority(struct writeback_control *wbc) @@ -304,11 +301,8 @@ do_it: lock_kernel(); if (!IS_SYNC(inode) && inode_referenced) { err = nfs_writepage_async(ctx, inode, page, 0, offset); - if (err >= 0) { - err = 0; - if (wbc->for_reclaim) - nfs_flush_inode(inode, 0, 0, FLUSH_STABLE); - } + if (!wbc->for_writepages) + nfs_flush_inode(inode, 0, 0, wb_priority(wbc)); } else { err = nfs_writepage_sync(ctx, inode, page, 0, offset, priority); -- cgit v1.1 From abbcf28f23d53e8ec56a91f3528743913fa2694a Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:03 +0100 Subject: SUNRPC: Yet more RPC cleanups Signed-off-by: Trond Myklebust --- include/linux/sunrpc/sched.h | 3 ++- net/sunrpc/clnt.c | 32 +++++++++++++++++--------------- net/sunrpc/pmap_clnt.c | 8 +++----- net/sunrpc/sched.c | 31 ++++++++++++------------------- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 4d77e90..4c4b2dc 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -233,6 +233,7 @@ struct rpc_task *rpc_new_child(struct rpc_clnt *, struct rpc_task *parent); void rpc_init_task(struct rpc_task *, struct rpc_clnt *, rpc_action exitfunc, int flags); void rpc_release_task(struct rpc_task *); +void rpc_exit_task(struct rpc_task *); void rpc_killall_tasks(struct rpc_clnt *); int rpc_execute(struct rpc_task *); void rpc_run_child(struct rpc_task *parent, struct rpc_task *child, @@ -259,7 +260,7 @@ void rpc_destroy_mempool(void); static inline void rpc_exit(struct rpc_task *task, int status) { task->tk_status = status; - task->tk_action = NULL; + task->tk_action = rpc_exit_task; } #ifdef RPC_DEBUG diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 61c3abe..6ab4cbd 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -511,7 +511,7 @@ rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags) if (task->tk_status == 0) task->tk_action = call_start; else - task->tk_action = NULL; + task->tk_action = rpc_exit_task; } void @@ -892,7 +892,7 @@ call_transmit(struct rpc_task *task) if (task->tk_status < 0) return; if (!task->tk_msg.rpc_proc->p_decode) { - task->tk_action = NULL; + task->tk_action = rpc_exit_task; rpc_wake_up_task(task); } return; @@ -1039,13 +1039,14 @@ call_decode(struct rpc_task *task) sizeof(req->rq_rcv_buf)) != 0); /* Verify the RPC header */ - if (!(p = call_verify(task))) { - if (task->tk_action == NULL) - return; - goto out_retry; + p = call_verify(task); + if (IS_ERR(p)) { + if (p == ERR_PTR(-EAGAIN)) + goto out_retry; + return; } - task->tk_action = NULL; + task->tk_action = rpc_exit_task; if (decode) task->tk_status = rpcauth_unwrap_resp(task, decode, req, p, @@ -1138,7 +1139,7 @@ call_verify(struct rpc_task *task) if ((n = ntohl(*p++)) != RPC_REPLY) { printk(KERN_WARNING "call_verify: not an RPC reply: %x\n", n); - goto out_retry; + goto out_garbage; } if ((n = ntohl(*p++)) != RPC_MSG_ACCEPTED) { if (--len < 0) @@ -1168,7 +1169,7 @@ call_verify(struct rpc_task *task) task->tk_pid); rpcauth_invalcred(task); task->tk_action = call_refresh; - return NULL; + goto out_retry; case RPC_AUTH_BADCRED: case RPC_AUTH_BADVERF: /* possibly garbled cred/verf? */ @@ -1178,7 +1179,7 @@ call_verify(struct rpc_task *task) dprintk("RPC: %4d call_verify: retry garbled creds\n", task->tk_pid); task->tk_action = call_bind; - return NULL; + goto out_retry; case RPC_AUTH_TOOWEAK: printk(KERN_NOTICE "call_verify: server requires stronger " "authentication.\n"); @@ -1193,7 +1194,7 @@ call_verify(struct rpc_task *task) } if (!(p = rpcauth_checkverf(task, p))) { printk(KERN_WARNING "call_verify: auth check failed\n"); - goto out_retry; /* bad verifier, retry */ + goto out_garbage; /* bad verifier, retry */ } len = p - (u32 *)iov->iov_base - 1; if (len < 0) @@ -1230,23 +1231,24 @@ call_verify(struct rpc_task *task) /* Also retry */ } -out_retry: +out_garbage: task->tk_client->cl_stats->rpcgarbage++; if (task->tk_garb_retry) { task->tk_garb_retry--; dprintk("RPC %s: retrying %4d\n", __FUNCTION__, task->tk_pid); task->tk_action = call_bind; - return NULL; +out_retry: + return ERR_PTR(-EAGAIN); } printk(KERN_WARNING "RPC %s: retry failed, exit EIO\n", __FUNCTION__); out_eio: error = -EIO; out_err: rpc_exit(task, error); - return NULL; + return ERR_PTR(error); out_overflow: printk(KERN_WARNING "RPC %s: server reply was truncated.\n", __FUNCTION__); - goto out_retry; + goto out_garbage; } static int rpcproc_encode_null(void *rqstp, u32 *data, void *obj) diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c index a398575..cad4568 100644 --- a/net/sunrpc/pmap_clnt.c +++ b/net/sunrpc/pmap_clnt.c @@ -90,8 +90,7 @@ bailout: map->pm_binding = 0; rpc_wake_up(&map->pm_bindwait); spin_unlock(&pmap_lock); - task->tk_status = -EIO; - task->tk_action = NULL; + rpc_exit(task, -EIO); } #ifdef CONFIG_ROOT_NFS @@ -138,11 +137,10 @@ pmap_getport_done(struct rpc_task *task) task->tk_pid, task->tk_status, clnt->cl_port); if (task->tk_status < 0) { /* Make the calling task exit with an error */ - task->tk_action = NULL; + task->tk_action = rpc_exit_task; } else if (clnt->cl_port == 0) { /* Program not registered */ - task->tk_status = -EACCES; - task->tk_action = NULL; + rpc_exit(task, -EACCES); } else { /* byte-swap port number first */ clnt->cl_port = htons(clnt->cl_port); diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 54e60a6..3fcf7b0 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -555,28 +555,22 @@ __rpc_atrun(struct rpc_task *task) } /* - * Helper that calls task->tk_exit if it exists and then returns - * true if we should exit __rpc_execute. + * Helper that calls task->tk_exit if it exists */ -static inline int __rpc_do_exit(struct rpc_task *task) +void rpc_exit_task(struct rpc_task *task) { + task->tk_action = NULL; if (task->tk_exit != NULL) { - lock_kernel(); task->tk_exit(task); - unlock_kernel(); - /* If tk_action is non-null, we should restart the call */ if (task->tk_action != NULL) { - if (!RPC_ASSASSINATED(task)) { - /* Release RPC slot and buffer memory */ - xprt_release(task); - rpc_free(task); - return 0; - } - printk(KERN_ERR "RPC: dead task tried to walk away.\n"); + WARN_ON(RPC_ASSASSINATED(task)); + /* Always release the RPC slot and buffer memory */ + xprt_release(task); + rpc_free(task); } } - return 1; } +EXPORT_SYMBOL(rpc_exit_task); static int rpc_wait_bit_interruptible(void *word) { @@ -631,12 +625,11 @@ static int __rpc_execute(struct rpc_task *task) * by someone else. */ if (!RPC_IS_QUEUED(task)) { - if (task->tk_action != NULL) { - lock_kernel(); - task->tk_action(task); - unlock_kernel(); - } else if (__rpc_do_exit(task)) + if (task->tk_action == NULL) break; + lock_kernel(); + task->tk_action(task); + unlock_kernel(); } /* -- cgit v1.1 From 963d8fe53339128ee46a7701f2e36305f0ccff8c Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:04 +0100 Subject: RPC: Clean up RPC task structure Shrink the RPC task structure. Instead of storing separate pointers for task->tk_exit and task->tk_release, put them in a structure. Also pass the user data pointer as a parameter instead of passing it via task->tk_calldata. This enables us to nest callbacks. Signed-off-by: Trond Myklebust --- fs/lockd/clntproc.c | 38 ++++++++------- fs/lockd/svc4proc.c | 15 +++--- fs/lockd/svclock.c | 14 ++++-- fs/lockd/svcproc.c | 14 ++++-- fs/nfs/direct.c | 1 - fs/nfs/nfs3proc.c | 44 +++++++++++------- fs/nfs/nfs4proc.c | 107 +++++++++++++++++++++++++------------------ fs/nfs/proc.c | 28 +++++++---- fs/nfs/read.c | 10 ++-- fs/nfs/unlink.c | 19 ++++---- fs/nfs/write.c | 21 +++------ fs/nfsd/nfs4callback.c | 10 ++-- include/linux/lockd/lockd.h | 2 +- include/linux/nfs_fs.h | 12 +++-- include/linux/sunrpc/clnt.h | 3 +- include/linux/sunrpc/sched.h | 20 +++++--- net/sunrpc/clnt.c | 15 +++--- net/sunrpc/sched.c | 53 +++++++++++---------- 18 files changed, 241 insertions(+), 185 deletions(-) diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index c5a3364..816333c 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -26,11 +26,12 @@ static int nlmclnt_test(struct nlm_rqst *, struct file_lock *); static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *); static int nlmclnt_unlock(struct nlm_rqst *, struct file_lock *); -static void nlmclnt_unlock_callback(struct rpc_task *); -static void nlmclnt_cancel_callback(struct rpc_task *); static int nlm_stat_to_errno(u32 stat); static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host); +static const struct rpc_call_ops nlmclnt_unlock_ops; +static const struct rpc_call_ops nlmclnt_cancel_ops; + /* * Cookie counter for NLM requests */ @@ -399,8 +400,7 @@ in_grace_period: /* * Generic NLM call, async version. */ -int -nlmsvc_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback) +int nlmsvc_async_call(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops) { struct nlm_host *host = req->a_host; struct rpc_clnt *clnt; @@ -419,13 +419,12 @@ nlmsvc_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback) msg.rpc_proc = &clnt->cl_procinfo[proc]; /* bootstrap and kick off the async RPC call */ - status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req); + status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, tk_ops, req); return status; } -static int -nlmclnt_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback) +static int nlmclnt_async_call(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops) { struct nlm_host *host = req->a_host; struct rpc_clnt *clnt; @@ -448,7 +447,7 @@ nlmclnt_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback) /* Increment host refcount */ nlm_get_host(host); /* bootstrap and kick off the async RPC call */ - status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req); + status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, tk_ops, req); if (status < 0) nlm_release_host(host); return status; @@ -664,7 +663,7 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) if (req->a_flags & RPC_TASK_ASYNC) { status = nlmclnt_async_call(req, NLMPROC_UNLOCK, - nlmclnt_unlock_callback); + &nlmclnt_unlock_ops); /* Hrmf... Do the unlock early since locks_remove_posix() * really expects us to free the lock synchronously */ do_vfs_lock(fl); @@ -692,10 +691,9 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) return -ENOLCK; } -static void -nlmclnt_unlock_callback(struct rpc_task *task) +static void nlmclnt_unlock_callback(struct rpc_task *task, void *data) { - struct nlm_rqst *req = (struct nlm_rqst *) task->tk_calldata; + struct nlm_rqst *req = data; int status = req->a_res.status; if (RPC_ASSASSINATED(task)) @@ -722,6 +720,10 @@ die: rpc_restart_call(task); } +static const struct rpc_call_ops nlmclnt_unlock_ops = { + .rpc_call_done = nlmclnt_unlock_callback, +}; + /* * Cancel a blocked lock request. * We always use an async RPC call for this in order not to hang a @@ -750,8 +752,7 @@ nlmclnt_cancel(struct nlm_host *host, struct file_lock *fl) nlmclnt_setlockargs(req, fl); - status = nlmclnt_async_call(req, NLMPROC_CANCEL, - nlmclnt_cancel_callback); + status = nlmclnt_async_call(req, NLMPROC_CANCEL, &nlmclnt_cancel_ops); if (status < 0) { nlmclnt_release_lockargs(req); kfree(req); @@ -765,10 +766,9 @@ nlmclnt_cancel(struct nlm_host *host, struct file_lock *fl) return status; } -static void -nlmclnt_cancel_callback(struct rpc_task *task) +static void nlmclnt_cancel_callback(struct rpc_task *task, void *data) { - struct nlm_rqst *req = (struct nlm_rqst *) task->tk_calldata; + struct nlm_rqst *req = data; if (RPC_ASSASSINATED(task)) goto die; @@ -807,6 +807,10 @@ retry_cancel: rpc_delay(task, 30 * HZ); } +static const struct rpc_call_ops nlmclnt_cancel_ops = { + .rpc_call_done = nlmclnt_cancel_callback, +}; + /* * Convert an NLM status code to a generic kernel errno */ diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index 489670e..4063095 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -22,7 +22,8 @@ #define NLMDBG_FACILITY NLMDBG_CLIENT static u32 nlm4svc_callback(struct svc_rqst *, u32, struct nlm_res *); -static void nlm4svc_callback_exit(struct rpc_task *); + +static const struct rpc_call_ops nlm4svc_callback_ops; /* * Obtain client and file from arguments @@ -470,7 +471,6 @@ nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp, } - /* * This is the generic lockd callback for async RPC calls */ @@ -494,7 +494,7 @@ nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp) call->a_host = host; memcpy(&call->a_args, resp, sizeof(*resp)); - if (nlmsvc_async_call(call, proc, nlm4svc_callback_exit) < 0) + if (nlmsvc_async_call(call, proc, &nlm4svc_callback_ops) < 0) goto error; return rpc_success; @@ -504,10 +504,9 @@ nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp) return rpc_system_err; } -static void -nlm4svc_callback_exit(struct rpc_task *task) +static void nlm4svc_callback_exit(struct rpc_task *task, void *data) { - struct nlm_rqst *call = (struct nlm_rqst *) task->tk_calldata; + struct nlm_rqst *call = data; if (task->tk_status < 0) { dprintk("lockd: %4d callback failed (errno = %d)\n", @@ -517,6 +516,10 @@ nlm4svc_callback_exit(struct rpc_task *task) kfree(call); } +static const struct rpc_call_ops nlm4svc_callback_ops = { + .rpc_call_done = nlm4svc_callback_exit, +}; + /* * NLM Server procedures. */ diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 49f9597..87d09a0 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -41,7 +41,8 @@ static void nlmsvc_insert_block(struct nlm_block *block, unsigned long); static int nlmsvc_remove_block(struct nlm_block *block); -static void nlmsvc_grant_callback(struct rpc_task *task); + +static const struct rpc_call_ops nlmsvc_grant_ops; /* * The list of blocked locks to retry @@ -562,7 +563,7 @@ callback: /* Call the client */ nlm_get_host(block->b_call.a_host); if (nlmsvc_async_call(&block->b_call, NLMPROC_GRANTED_MSG, - nlmsvc_grant_callback) < 0) + &nlmsvc_grant_ops) < 0) nlm_release_host(block->b_call.a_host); up(&file->f_sema); } @@ -575,10 +576,9 @@ callback: * chain once more in order to have it removed by lockd itself (which can * then sleep on the file semaphore without disrupting e.g. the nfs client). */ -static void -nlmsvc_grant_callback(struct rpc_task *task) +static void nlmsvc_grant_callback(struct rpc_task *task, void *data) { - struct nlm_rqst *call = (struct nlm_rqst *) task->tk_calldata; + struct nlm_rqst *call = data; struct nlm_block *block; unsigned long timeout; struct sockaddr_in *peer_addr = RPC_PEERADDR(task->tk_client); @@ -614,6 +614,10 @@ nlmsvc_grant_callback(struct rpc_task *task) nlm_release_host(call->a_host); } +static const struct rpc_call_ops nlmsvc_grant_ops = { + .rpc_call_done = nlmsvc_grant_callback, +}; + /* * We received a GRANT_RES callback. Try to find the corresponding * block. diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index 757e344..3bc437e 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -23,7 +23,8 @@ #define NLMDBG_FACILITY NLMDBG_CLIENT static u32 nlmsvc_callback(struct svc_rqst *, u32, struct nlm_res *); -static void nlmsvc_callback_exit(struct rpc_task *); + +static const struct rpc_call_ops nlmsvc_callback_ops; #ifdef CONFIG_LOCKD_V4 static u32 @@ -518,7 +519,7 @@ nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp) call->a_host = host; memcpy(&call->a_args, resp, sizeof(*resp)); - if (nlmsvc_async_call(call, proc, nlmsvc_callback_exit) < 0) + if (nlmsvc_async_call(call, proc, &nlmsvc_callback_ops) < 0) goto error; return rpc_success; @@ -528,10 +529,9 @@ nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp) return rpc_system_err; } -static void -nlmsvc_callback_exit(struct rpc_task *task) +static void nlmsvc_callback_exit(struct rpc_task *task, void *data) { - struct nlm_rqst *call = (struct nlm_rqst *) task->tk_calldata; + struct nlm_rqst *call = data; if (task->tk_status < 0) { dprintk("lockd: %4d callback failed (errno = %d)\n", @@ -541,6 +541,10 @@ nlmsvc_callback_exit(struct rpc_task *task) kfree(call); } +static const struct rpc_call_ops nlmsvc_callback_ops = { + .rpc_call_done = nlmsvc_callback_exit, +}; + /* * NLM Server procedures. */ diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 07922881..a834423 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -269,7 +269,6 @@ static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, data->task.tk_cookie = (unsigned long) inode; data->task.tk_calldata = data; - data->task.tk_release = nfs_readdata_release; data->complete = nfs_direct_read_result; lock_kernel(); diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 92c870d..c172a75 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -732,19 +732,23 @@ nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, extern u32 *nfs3_decode_dirent(u32 *, struct nfs_entry *, int); -static void -nfs3_read_done(struct rpc_task *task) +static void nfs3_read_done(struct rpc_task *task, void *calldata) { - struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata; + struct nfs_read_data *data = calldata; if (nfs3_async_handle_jukebox(task)) return; /* Call back common NFS readpage processing */ if (task->tk_status >= 0) nfs_refresh_inode(data->inode, &data->fattr); - nfs_readpage_result(task); + nfs_readpage_result(task, calldata); } +static const struct rpc_call_ops nfs3_read_ops = { + .rpc_call_done = nfs3_read_done, + .rpc_release = nfs_readdata_release, +}; + static void nfs3_proc_read_setup(struct nfs_read_data *data) { @@ -762,23 +766,26 @@ nfs3_proc_read_setup(struct nfs_read_data *data) flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0); /* Finalize the task. */ - rpc_init_task(task, NFS_CLIENT(inode), nfs3_read_done, flags); + rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_read_ops, data); rpc_call_setup(task, &msg, 0); } -static void -nfs3_write_done(struct rpc_task *task) +static void nfs3_write_done(struct rpc_task *task, void *calldata) { - struct nfs_write_data *data; + struct nfs_write_data *data = calldata; if (nfs3_async_handle_jukebox(task)) return; - data = (struct nfs_write_data *)task->tk_calldata; if (task->tk_status >= 0) nfs_post_op_update_inode(data->inode, data->res.fattr); - nfs_writeback_done(task); + nfs_writeback_done(task, calldata); } +static const struct rpc_call_ops nfs3_write_ops = { + .rpc_call_done = nfs3_write_done, + .rpc_release = nfs_writedata_release, +}; + static void nfs3_proc_write_setup(struct nfs_write_data *data, int how) { @@ -806,23 +813,26 @@ nfs3_proc_write_setup(struct nfs_write_data *data, int how) flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; /* Finalize the task. */ - rpc_init_task(task, NFS_CLIENT(inode), nfs3_write_done, flags); + rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_write_ops, data); rpc_call_setup(task, &msg, 0); } -static void -nfs3_commit_done(struct rpc_task *task) +static void nfs3_commit_done(struct rpc_task *task, void *calldata) { - struct nfs_write_data *data; + struct nfs_write_data *data = calldata; if (nfs3_async_handle_jukebox(task)) return; - data = (struct nfs_write_data *)task->tk_calldata; if (task->tk_status >= 0) nfs_post_op_update_inode(data->inode, data->res.fattr); - nfs_commit_done(task); + nfs_commit_done(task, calldata); } +static const struct rpc_call_ops nfs3_commit_ops = { + .rpc_call_done = nfs3_commit_done, + .rpc_release = nfs_commit_release, +}; + static void nfs3_proc_commit_setup(struct nfs_write_data *data, int how) { @@ -840,7 +850,7 @@ nfs3_proc_commit_setup(struct nfs_write_data *data, int how) flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; /* Finalize the task. */ - rpc_init_task(task, NFS_CLIENT(inode), nfs3_commit_done, flags); + rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_commit_ops, data); rpc_call_setup(task, &msg, 0); } diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index f988a94..3d5d3c0 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -196,14 +196,12 @@ static void update_changeattr(struct inode *inode, struct nfs4_change_info *cinf /* Helper for asynchronous RPC calls */ static int nfs4_call_async(struct rpc_clnt *clnt, rpc_action tk_begin, - rpc_action tk_exit, void *calldata) + const struct rpc_call_ops *tk_ops, void *calldata) { struct rpc_task *task; - if (!(task = rpc_new_task(clnt, tk_exit, RPC_TASK_ASYNC))) + if (!(task = rpc_new_task(clnt, RPC_TASK_ASYNC, tk_ops, calldata))) return -ENOMEM; - - task->tk_calldata = calldata; task->tk_action = tk_begin; rpc_execute(task); return 0; @@ -867,10 +865,10 @@ struct nfs4_closedata { struct nfs_fattr fattr; }; -static void nfs4_free_closedata(struct nfs4_closedata *calldata) +static void nfs4_free_closedata(void *data) { - struct nfs4_state *state = calldata->state; - struct nfs4_state_owner *sp = state->owner; + struct nfs4_closedata *calldata = data; + struct nfs4_state_owner *sp = calldata->state->owner; nfs4_put_open_state(calldata->state); nfs_free_seqid(calldata->arg.seqid); @@ -878,9 +876,9 @@ static void nfs4_free_closedata(struct nfs4_closedata *calldata) kfree(calldata); } -static void nfs4_close_done(struct rpc_task *task) +static void nfs4_close_done(struct rpc_task *task, void *data) { - struct nfs4_closedata *calldata = (struct nfs4_closedata *)task->tk_calldata; + struct nfs4_closedata *calldata = data; struct nfs4_state *state = calldata->state; struct nfs_server *server = NFS_SERVER(calldata->inode); @@ -904,7 +902,6 @@ static void nfs4_close_done(struct rpc_task *task) } } nfs_refresh_inode(calldata->inode, calldata->res.fattr); - nfs4_free_closedata(calldata); } static void nfs4_close_begin(struct rpc_task *task) @@ -918,10 +915,8 @@ static void nfs4_close_begin(struct rpc_task *task) .rpc_cred = state->owner->so_cred, }; int mode = 0, old_mode; - int status; - status = nfs_wait_on_sequence(calldata->arg.seqid, task); - if (status != 0) + if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) return; /* Recalculate the new open mode in case someone reopened the file * while we were waiting in line to be scheduled. @@ -937,9 +932,8 @@ static void nfs4_close_begin(struct rpc_task *task) spin_unlock(&calldata->inode->i_lock); spin_unlock(&state->owner->so_lock); if (mode == old_mode || test_bit(NFS_DELEGATED_STATE, &state->flags)) { - nfs4_free_closedata(calldata); - task->tk_exit = NULL; - rpc_exit(task, 0); + /* Note: exit _without_ calling nfs4_close_done */ + task->tk_action = NULL; return; } nfs_fattr_init(calldata->res.fattr); @@ -949,6 +943,11 @@ static void nfs4_close_begin(struct rpc_task *task) rpc_call_setup(task, &msg, 0); } +static const struct rpc_call_ops nfs4_close_ops = { + .rpc_call_done = nfs4_close_done, + .rpc_release = nfs4_free_closedata, +}; + /* * It is possible for data to be read/written from a mem-mapped file * after the sys_close call (which hits the vfs layer as a flush). @@ -982,7 +981,7 @@ int nfs4_do_close(struct inode *inode, struct nfs4_state *state) calldata->res.server = server; status = nfs4_call_async(server->client, nfs4_close_begin, - nfs4_close_done, calldata); + &nfs4_close_ops, calldata); if (status == 0) goto out; @@ -2125,10 +2124,9 @@ static int nfs4_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, return err; } -static void -nfs4_read_done(struct rpc_task *task) +static void nfs4_read_done(struct rpc_task *task, void *calldata) { - struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata; + struct nfs_read_data *data = calldata; struct inode *inode = data->inode; if (nfs4_async_handle_error(task, NFS_SERVER(inode)) == -EAGAIN) { @@ -2138,9 +2136,14 @@ nfs4_read_done(struct rpc_task *task) if (task->tk_status > 0) renew_lease(NFS_SERVER(inode), data->timestamp); /* Call back common NFS readpage processing */ - nfs_readpage_result(task); + nfs_readpage_result(task, calldata); } +static const struct rpc_call_ops nfs4_read_ops = { + .rpc_call_done = nfs4_read_done, + .rpc_release = nfs_readdata_release, +}; + static void nfs4_proc_read_setup(struct nfs_read_data *data) { @@ -2160,14 +2163,13 @@ nfs4_proc_read_setup(struct nfs_read_data *data) flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0); /* Finalize the task. */ - rpc_init_task(task, NFS_CLIENT(inode), nfs4_read_done, flags); + rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs4_read_ops, data); rpc_call_setup(task, &msg, 0); } -static void -nfs4_write_done(struct rpc_task *task) +static void nfs4_write_done(struct rpc_task *task, void *calldata) { - struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; + struct nfs_write_data *data = calldata; struct inode *inode = data->inode; if (nfs4_async_handle_error(task, NFS_SERVER(inode)) == -EAGAIN) { @@ -2179,9 +2181,14 @@ nfs4_write_done(struct rpc_task *task) nfs_post_op_update_inode(inode, data->res.fattr); } /* Call back common NFS writeback processing */ - nfs_writeback_done(task); + nfs_writeback_done(task, calldata); } +static const struct rpc_call_ops nfs4_write_ops = { + .rpc_call_done = nfs4_write_done, + .rpc_release = nfs_writedata_release, +}; + static void nfs4_proc_write_setup(struct nfs_write_data *data, int how) { @@ -2214,14 +2221,13 @@ nfs4_proc_write_setup(struct nfs_write_data *data, int how) flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; /* Finalize the task. */ - rpc_init_task(task, NFS_CLIENT(inode), nfs4_write_done, flags); + rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs4_write_ops, data); rpc_call_setup(task, &msg, 0); } -static void -nfs4_commit_done(struct rpc_task *task) +static void nfs4_commit_done(struct rpc_task *task, void *calldata) { - struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; + struct nfs_write_data *data = calldata; struct inode *inode = data->inode; if (nfs4_async_handle_error(task, NFS_SERVER(inode)) == -EAGAIN) { @@ -2231,9 +2237,14 @@ nfs4_commit_done(struct rpc_task *task) if (task->tk_status >= 0) nfs_post_op_update_inode(inode, data->res.fattr); /* Call back common NFS writeback processing */ - nfs_commit_done(task); + nfs_commit_done(task, calldata); } +static const struct rpc_call_ops nfs4_commit_ops = { + .rpc_call_done = nfs4_commit_done, + .rpc_release = nfs_commit_release, +}; + static void nfs4_proc_commit_setup(struct nfs_write_data *data, int how) { @@ -2255,7 +2266,7 @@ nfs4_proc_commit_setup(struct nfs_write_data *data, int how) flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; /* Finalize the task. */ - rpc_init_task(task, NFS_CLIENT(inode), nfs4_commit_done, flags); + rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs4_commit_ops, data); rpc_call_setup(task, &msg, 0); } @@ -2263,11 +2274,10 @@ nfs4_proc_commit_setup(struct nfs_write_data *data, int how) * nfs4_proc_async_renew(): This is not one of the nfs_rpc_ops; it is a special * standalone procedure for queueing an asynchronous RENEW. */ -static void -renew_done(struct rpc_task *task) +static void nfs4_renew_done(struct rpc_task *task, void *data) { struct nfs4_client *clp = (struct nfs4_client *)task->tk_msg.rpc_argp; - unsigned long timestamp = (unsigned long)task->tk_calldata; + unsigned long timestamp = (unsigned long)data; if (task->tk_status < 0) { switch (task->tk_status) { @@ -2284,6 +2294,10 @@ renew_done(struct rpc_task *task) spin_unlock(&clp->cl_lock); } +static const struct rpc_call_ops nfs4_renew_ops = { + .rpc_call_done = nfs4_renew_done, +}; + int nfs4_proc_async_renew(struct nfs4_client *clp) { @@ -2294,7 +2308,7 @@ nfs4_proc_async_renew(struct nfs4_client *clp) }; return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_SOFT, - renew_done, (void *)jiffies); + &nfs4_renew_ops, (void *)jiffies); } int @@ -2866,15 +2880,16 @@ static void nfs4_locku_release_calldata(struct nfs4_unlockdata *calldata) } } -static void nfs4_locku_complete(struct nfs4_unlockdata *calldata) +static void nfs4_locku_complete(void *data) { + struct nfs4_unlockdata *calldata = data; complete(&calldata->completion); nfs4_locku_release_calldata(calldata); } -static void nfs4_locku_done(struct rpc_task *task) +static void nfs4_locku_done(struct rpc_task *task, void *data) { - struct nfs4_unlockdata *calldata = (struct nfs4_unlockdata *)task->tk_calldata; + struct nfs4_unlockdata *calldata = data; nfs_increment_lock_seqid(task->tk_status, calldata->luargs.seqid); switch (task->tk_status) { @@ -2890,10 +2905,8 @@ static void nfs4_locku_done(struct rpc_task *task) default: if (nfs4_async_handle_error(task, calldata->res.server) == -EAGAIN) { rpc_restart_call(task); - return; } } - nfs4_locku_complete(calldata); } static void nfs4_locku_begin(struct rpc_task *task) @@ -2911,14 +2924,18 @@ static void nfs4_locku_begin(struct rpc_task *task) if (status != 0) return; if ((calldata->lsp->ls_flags & NFS_LOCK_INITIALIZED) == 0) { - nfs4_locku_complete(calldata); - task->tk_exit = NULL; - rpc_exit(task, 0); + /* Note: exit _without_ running nfs4_locku_done */ + task->tk_action = NULL; return; } rpc_call_setup(task, &msg, 0); } +static const struct rpc_call_ops nfs4_locku_ops = { + .rpc_call_done = nfs4_locku_done, + .rpc_release = nfs4_locku_complete, +}; + static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) { struct nfs4_unlockdata *calldata; @@ -2963,7 +2980,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * init_completion(&calldata->completion); status = nfs4_call_async(NFS_SERVER(inode)->client, nfs4_locku_begin, - nfs4_locku_done, calldata); + &nfs4_locku_ops, calldata); if (status == 0) wait_for_completion_interruptible(&calldata->completion); do_vfs_lock(request->fl_file, request); diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index e1e3ca5..6145e82 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -547,10 +547,9 @@ nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int); -static void -nfs_read_done(struct rpc_task *task) +static void nfs_read_done(struct rpc_task *task, void *calldata) { - struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata; + struct nfs_read_data *data = calldata; if (task->tk_status >= 0) { nfs_refresh_inode(data->inode, data->res.fattr); @@ -560,9 +559,14 @@ nfs_read_done(struct rpc_task *task) if (data->args.offset + data->args.count >= data->res.fattr->size) data->res.eof = 1; } - nfs_readpage_result(task); + nfs_readpage_result(task, calldata); } +static const struct rpc_call_ops nfs_read_ops = { + .rpc_call_done = nfs_read_done, + .rpc_release = nfs_readdata_release, +}; + static void nfs_proc_read_setup(struct nfs_read_data *data) { @@ -580,20 +584,24 @@ nfs_proc_read_setup(struct nfs_read_data *data) flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0); /* Finalize the task. */ - rpc_init_task(task, NFS_CLIENT(inode), nfs_read_done, flags); + rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs_read_ops, data); rpc_call_setup(task, &msg, 0); } -static void -nfs_write_done(struct rpc_task *task) +static void nfs_write_done(struct rpc_task *task, void *calldata) { - struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; + struct nfs_write_data *data = calldata; if (task->tk_status >= 0) nfs_post_op_update_inode(data->inode, data->res.fattr); - nfs_writeback_done(task); + nfs_writeback_done(task, calldata); } +static const struct rpc_call_ops nfs_write_ops = { + .rpc_call_done = nfs_write_done, + .rpc_release = nfs_writedata_release, +}; + static void nfs_proc_write_setup(struct nfs_write_data *data, int how) { @@ -614,7 +622,7 @@ nfs_proc_write_setup(struct nfs_write_data *data, int how) flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC; /* Finalize the task. */ - rpc_init_task(task, NFS_CLIENT(inode), nfs_write_done, flags); + rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs_write_ops, data); rpc_call_setup(task, &msg, 0); } diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 5f20eaf..2148624 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -42,9 +42,8 @@ mempool_t *nfs_rdata_mempool; #define MIN_POOL_READ (32) -void nfs_readdata_release(struct rpc_task *task) +void nfs_readdata_release(void *data) { - struct nfs_read_data *data = (struct nfs_read_data *)task->tk_calldata; nfs_readdata_free(data); } @@ -220,9 +219,6 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data, NFS_PROTO(inode)->read_setup(data); data->task.tk_cookie = (unsigned long)inode; - data->task.tk_calldata = data; - /* Release requests */ - data->task.tk_release = nfs_readdata_release; dprintk("NFS: %4d initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n", data->task.tk_pid, @@ -452,9 +448,9 @@ static void nfs_readpage_result_full(struct nfs_read_data *data, int status) * This is the callback from RPC telling us whether a reply was * received or some error occurred (timeout or socket shutdown). */ -void nfs_readpage_result(struct rpc_task *task) +void nfs_readpage_result(struct rpc_task *task, void *calldata) { - struct nfs_read_data *data = (struct nfs_read_data *)task->tk_calldata; + struct nfs_read_data *data = calldata; struct nfs_readargs *argp = &data->args; struct nfs_readres *resp = &data->res; int status = task->tk_status; diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index d639d17..1494484 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -116,10 +116,9 @@ nfs_async_unlink_init(struct rpc_task *task) * * Do the directory attribute update. */ -static void -nfs_async_unlink_done(struct rpc_task *task) +static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) { - struct nfs_unlinkdata *data = (struct nfs_unlinkdata *)task->tk_calldata; + struct nfs_unlinkdata *data = calldata; struct dentry *dir = data->dir; struct inode *dir_i; @@ -141,13 +140,17 @@ nfs_async_unlink_done(struct rpc_task *task) * We need to call nfs_put_unlinkdata as a 'tk_release' task since the * rpc_task would be freed too. */ -static void -nfs_async_unlink_release(struct rpc_task *task) +static void nfs_async_unlink_release(void *calldata) { - struct nfs_unlinkdata *data = (struct nfs_unlinkdata *)task->tk_calldata; + struct nfs_unlinkdata *data = calldata; nfs_put_unlinkdata(data); } +static const struct rpc_call_ops nfs_unlink_ops = { + .rpc_call_done = nfs_async_unlink_done, + .rpc_release = nfs_async_unlink_release, +}; + /** * nfs_async_unlink - asynchronous unlinking of a file * @dentry: dentry to unlink @@ -179,10 +182,8 @@ nfs_async_unlink(struct dentry *dentry) data->count = 1; task = &data->task; - rpc_init_task(task, clnt, nfs_async_unlink_done , RPC_TASK_ASYNC); - task->tk_calldata = data; + rpc_init_task(task, clnt, RPC_TASK_ASYNC, &nfs_unlink_ops, data); task->tk_action = nfs_async_unlink_init; - task->tk_release = nfs_async_unlink_release; spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_NFSFS_RENAMED; diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 95d00f9..80bc4ea 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -104,9 +104,8 @@ static inline void nfs_commit_free(struct nfs_write_data *p) mempool_free(p, nfs_commit_mempool); } -static void nfs_writedata_release(struct rpc_task *task) +void nfs_writedata_release(void *wdata) { - struct nfs_write_data *wdata = (struct nfs_write_data *)task->tk_calldata; nfs_writedata_free(wdata); } @@ -871,9 +870,6 @@ static void nfs_write_rpcsetup(struct nfs_page *req, data->task.tk_priority = flush_task_priority(how); data->task.tk_cookie = (unsigned long)inode; - data->task.tk_calldata = data; - /* Release requests */ - data->task.tk_release = nfs_writedata_release; dprintk("NFS: %4d initiated write call (req %s/%Ld, %u bytes @ offset %Lu)\n", data->task.tk_pid, @@ -1131,9 +1127,9 @@ static void nfs_writeback_done_full(struct nfs_write_data *data, int status) /* * This function is called when the WRITE call is complete. */ -void nfs_writeback_done(struct rpc_task *task) +void nfs_writeback_done(struct rpc_task *task, void *calldata) { - struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; + struct nfs_write_data *data = calldata; struct nfs_writeargs *argp = &data->args; struct nfs_writeres *resp = &data->res; @@ -1200,9 +1196,8 @@ void nfs_writeback_done(struct rpc_task *task) #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) -static void nfs_commit_release(struct rpc_task *task) +void nfs_commit_release(void *wdata) { - struct nfs_write_data *wdata = (struct nfs_write_data *)task->tk_calldata; nfs_commit_free(wdata); } @@ -1238,9 +1233,6 @@ static void nfs_commit_rpcsetup(struct list_head *head, data->task.tk_priority = flush_task_priority(how); data->task.tk_cookie = (unsigned long)inode; - data->task.tk_calldata = data; - /* Release requests */ - data->task.tk_release = nfs_commit_release; dprintk("NFS: %4d initiated commit call\n", data->task.tk_pid); } @@ -1277,10 +1269,9 @@ nfs_commit_list(struct list_head *head, int how) /* * COMMIT call returned */ -void -nfs_commit_done(struct rpc_task *task) +void nfs_commit_done(struct rpc_task *task, void *calldata) { - struct nfs_write_data *data = (struct nfs_write_data *)task->tk_calldata; + struct nfs_write_data *data = calldata; struct nfs_page *req; int res = 0; diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 583c071..cf92008 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -53,7 +53,7 @@ #define NFSPROC4_CB_COMPOUND 1 /* declarations */ -static void nfs4_cb_null(struct rpc_task *task); +static const struct rpc_call_ops nfs4_cb_null_ops; /* Index of predefined Linux callback client operations */ @@ -447,7 +447,7 @@ nfsd4_probe_callback(struct nfs4_client *clp) msg.rpc_cred = nfsd4_lookupcred(clp,0); if (IS_ERR(msg.rpc_cred)) goto out_rpciod; - status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, nfs4_cb_null, NULL); + status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, &nfs4_cb_null_ops, NULL); put_rpccred(msg.rpc_cred); if (status != 0) { @@ -469,7 +469,7 @@ out_err: } static void -nfs4_cb_null(struct rpc_task *task) +nfs4_cb_null(struct rpc_task *task, void *dummy) { struct nfs4_client *clp = (struct nfs4_client *)task->tk_msg.rpc_argp; struct nfs4_callback *cb = &clp->cl_callback; @@ -488,6 +488,10 @@ out: put_nfs4_client(clp); } +static const struct rpc_call_ops nfs4_cb_null_ops = { + .rpc_call_done = nfs4_cb_null, +}; + /* * called with dp->dl_count inc'ed. * nfs4_lock_state() may or may not have been called. diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index 16d4e5a..95c8fea 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h @@ -172,7 +172,7 @@ extern struct nlm_host *nlm_find_client(void); /* * Server-side lock handling */ -int nlmsvc_async_call(struct nlm_rqst *, u32, rpc_action); +int nlmsvc_async_call(struct nlm_rqst *, u32, const struct rpc_call_ops *); u32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, struct nlm_lock *, int, struct nlm_cookie *); u32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *); diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 2516ade..4dff705 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -406,10 +406,12 @@ extern int nfs_writepage(struct page *page, struct writeback_control *wbc); extern int nfs_writepages(struct address_space *, struct writeback_control *); extern int nfs_flush_incompatible(struct file *file, struct page *page); extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int); -extern void nfs_writeback_done(struct rpc_task *task); +extern void nfs_writeback_done(struct rpc_task *task, void *data); +extern void nfs_writedata_release(void *data); #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) -extern void nfs_commit_done(struct rpc_task *); +extern void nfs_commit_done(struct rpc_task *, void *data); +extern void nfs_commit_release(void *data); #endif /* @@ -481,7 +483,9 @@ static inline void nfs_writedata_free(struct nfs_write_data *p) extern int nfs_readpage(struct file *, struct page *); extern int nfs_readpages(struct file *, struct address_space *, struct list_head *, unsigned); -extern void nfs_readpage_result(struct rpc_task *); +extern void nfs_readpage_result(struct rpc_task *, void *); +extern void nfs_readdata_release(void *data); + /* * Allocate and free nfs_read_data structures @@ -501,8 +505,6 @@ static inline void nfs_readdata_free(struct nfs_read_data *p) mempool_free(p, nfs_rdata_mempool); } -extern void nfs_readdata_release(struct rpc_task *task); - /* * linux/fs/nfs3proc.c */ diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index ab151bb..b0ab959 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -126,7 +126,8 @@ int rpc_register(u32, u32, int, unsigned short, int *); void rpc_call_setup(struct rpc_task *, struct rpc_message *, int); int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, - int flags, rpc_action callback, void *clntdata); + int flags, const struct rpc_call_ops *tk_ops, + void *calldata); int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags); void rpc_restart_call(struct rpc_task *); diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 4c4b2dc..581d8cd 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -27,6 +27,7 @@ struct rpc_message { struct rpc_cred * rpc_cred; /* Credentials */ }; +struct rpc_call_ops; struct rpc_wait_queue; struct rpc_wait { struct list_head list; /* wait queue links */ @@ -61,13 +62,12 @@ struct rpc_task { * timeout_fn to be executed by timer bottom half * callback to be executed after waking up * action next procedure for async tasks - * exit exit async task and report to caller + * tk_ops caller callbacks */ void (*tk_timeout_fn)(struct rpc_task *); void (*tk_callback)(struct rpc_task *); void (*tk_action)(struct rpc_task *); - void (*tk_exit)(struct rpc_task *); - void (*tk_release)(struct rpc_task *); + const struct rpc_call_ops *tk_ops; void * tk_calldata; /* @@ -111,6 +111,12 @@ struct rpc_task { typedef void (*rpc_action)(struct rpc_task *); +struct rpc_call_ops { + void (*rpc_call_done)(struct rpc_task *, void *); + void (*rpc_release)(void *); +}; + + /* * RPC task flags */ @@ -228,10 +234,12 @@ struct rpc_wait_queue { /* * Function prototypes */ -struct rpc_task *rpc_new_task(struct rpc_clnt *, rpc_action, int flags); +struct rpc_task *rpc_new_task(struct rpc_clnt *, int flags, + const struct rpc_call_ops *ops, void *data); struct rpc_task *rpc_new_child(struct rpc_clnt *, struct rpc_task *parent); -void rpc_init_task(struct rpc_task *, struct rpc_clnt *, - rpc_action exitfunc, int flags); +void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, + int flags, const struct rpc_call_ops *ops, + void *data); void rpc_release_task(struct rpc_task *); void rpc_exit_task(struct rpc_task *); void rpc_killall_tasks(struct rpc_clnt *); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 6ab4cbd..8b2f75b 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -374,10 +374,14 @@ out: * Default callback for async RPC calls */ static void -rpc_default_callback(struct rpc_task *task) +rpc_default_callback(struct rpc_task *task, void *data) { } +static const struct rpc_call_ops rpc_default_ops = { + .rpc_call_done = rpc_default_callback, +}; + /* * Export the signal mask handling for synchronous code that * sleeps on RPC calls @@ -432,7 +436,7 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) BUG_ON(flags & RPC_TASK_ASYNC); status = -ENOMEM; - task = rpc_new_task(clnt, NULL, flags); + task = rpc_new_task(clnt, flags, &rpc_default_ops, NULL); if (task == NULL) goto out; @@ -459,7 +463,7 @@ out: */ int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags, - rpc_action callback, void *data) + const struct rpc_call_ops *tk_ops, void *data) { struct rpc_task *task; sigset_t oldset; @@ -472,12 +476,9 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags, flags |= RPC_TASK_ASYNC; /* Create/initialize a new RPC task */ - if (!callback) - callback = rpc_default_callback; status = -ENOMEM; - if (!(task = rpc_new_task(clnt, callback, flags))) + if (!(task = rpc_new_task(clnt, flags, tk_ops, data))) goto out; - task->tk_calldata = data; /* Mask signals on GSS_AUTH upcalls */ rpc_task_sigmask(task, &oldset); diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 3fcf7b0..8d6233d 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -555,13 +555,13 @@ __rpc_atrun(struct rpc_task *task) } /* - * Helper that calls task->tk_exit if it exists + * Helper that calls task->tk_ops->rpc_call_done if it exists */ void rpc_exit_task(struct rpc_task *task) { task->tk_action = NULL; - if (task->tk_exit != NULL) { - task->tk_exit(task); + if (task->tk_ops->rpc_call_done != NULL) { + task->tk_ops->rpc_call_done(task, task->tk_calldata); if (task->tk_action != NULL) { WARN_ON(RPC_ASSASSINATED(task)); /* Always release the RPC slot and buffer memory */ @@ -747,7 +747,7 @@ rpc_free(struct rpc_task *task) /* * Creation and deletion of RPC task structures */ -void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, rpc_action callback, int flags) +void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, const struct rpc_call_ops *tk_ops, void *calldata) { memset(task, 0, sizeof(*task)); init_timer(&task->tk_timer); @@ -755,7 +755,8 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, rpc_action call task->tk_timer.function = (void (*)(unsigned long)) rpc_run_timer; task->tk_client = clnt; task->tk_flags = flags; - task->tk_exit = callback; + task->tk_ops = tk_ops; + task->tk_calldata = calldata; /* Initialize retry counters */ task->tk_garb_retry = 2; @@ -784,6 +785,8 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, rpc_action call list_add_tail(&task->tk_task, &all_tasks); spin_unlock(&rpc_sched_lock); + BUG_ON(task->tk_ops == NULL); + dprintk("RPC: %4d new task procpid %d\n", task->tk_pid, current->pid); } @@ -794,8 +797,7 @@ rpc_alloc_task(void) return (struct rpc_task *)mempool_alloc(rpc_task_mempool, GFP_NOFS); } -static void -rpc_default_free_task(struct rpc_task *task) +static void rpc_free_task(struct rpc_task *task) { dprintk("RPC: %4d freeing task\n", task->tk_pid); mempool_free(task, rpc_task_mempool); @@ -806,8 +808,7 @@ rpc_default_free_task(struct rpc_task *task) * clean up after an allocation failure, as the client may * have specified "oneshot". */ -struct rpc_task * -rpc_new_task(struct rpc_clnt *clnt, rpc_action callback, int flags) +struct rpc_task *rpc_new_task(struct rpc_clnt *clnt, int flags, const struct rpc_call_ops *tk_ops, void *calldata) { struct rpc_task *task; @@ -815,10 +816,7 @@ rpc_new_task(struct rpc_clnt *clnt, rpc_action callback, int flags) if (!task) goto cleanup; - rpc_init_task(task, clnt, callback, flags); - - /* Replace tk_release */ - task->tk_release = rpc_default_free_task; + rpc_init_task(task, clnt, flags, tk_ops, calldata); dprintk("RPC: %4d allocated task\n", task->tk_pid); task->tk_flags |= RPC_TASK_DYNAMIC; @@ -838,6 +836,8 @@ cleanup: void rpc_release_task(struct rpc_task *task) { + const struct rpc_call_ops *tk_ops = task->tk_ops; + void *calldata = task->tk_calldata; dprintk("RPC: %4d release task\n", task->tk_pid); #ifdef RPC_DEBUG @@ -869,8 +869,10 @@ void rpc_release_task(struct rpc_task *task) #ifdef RPC_DEBUG task->tk_magic = 0; #endif - if (task->tk_release) - task->tk_release(task); + if (task->tk_flags & RPC_TASK_DYNAMIC) + rpc_free_task(task); + if (tk_ops->rpc_release) + tk_ops->rpc_release(calldata); } /** @@ -883,12 +885,11 @@ void rpc_release_task(struct rpc_task *task) * * Caller must hold childq.lock */ -static inline struct rpc_task *rpc_find_parent(struct rpc_task *child) +static inline struct rpc_task *rpc_find_parent(struct rpc_task *child, struct rpc_task *parent) { - struct rpc_task *task, *parent; + struct rpc_task *task; struct list_head *le; - parent = (struct rpc_task *) child->tk_calldata; task_for_each(task, le, &childq.tasks[0]) if (task == parent) return parent; @@ -896,18 +897,22 @@ static inline struct rpc_task *rpc_find_parent(struct rpc_task *child) return NULL; } -static void rpc_child_exit(struct rpc_task *child) +static void rpc_child_exit(struct rpc_task *child, void *calldata) { struct rpc_task *parent; spin_lock_bh(&childq.lock); - if ((parent = rpc_find_parent(child)) != NULL) { + if ((parent = rpc_find_parent(child, calldata)) != NULL) { parent->tk_status = child->tk_status; __rpc_wake_up_task(parent); } spin_unlock_bh(&childq.lock); } +static const struct rpc_call_ops rpc_child_ops = { + .rpc_call_done = rpc_child_exit, +}; + /* * Note: rpc_new_task releases the client after a failure. */ @@ -916,11 +921,9 @@ rpc_new_child(struct rpc_clnt *clnt, struct rpc_task *parent) { struct rpc_task *task; - task = rpc_new_task(clnt, NULL, RPC_TASK_ASYNC | RPC_TASK_CHILD); + task = rpc_new_task(clnt, RPC_TASK_ASYNC | RPC_TASK_CHILD, &rpc_child_ops, parent); if (!task) goto fail; - task->tk_exit = rpc_child_exit; - task->tk_calldata = parent; return task; fail: @@ -1056,7 +1059,7 @@ void rpc_show_tasks(void) return; } printk("-pid- proc flgs status -client- -prog- --rqstp- -timeout " - "-rpcwait -action- --exit--\n"); + "-rpcwait -action- ---ops--\n"); alltask_for_each(t, le, &all_tasks) { const char *rpc_waitq = "none"; @@ -1071,7 +1074,7 @@ void rpc_show_tasks(void) (t->tk_client ? t->tk_client->cl_prog : 0), t->tk_rqstp, t->tk_timeout, rpc_waitq, - t->tk_action, t->tk_exit); + t->tk_action, t->tk_ops); } spin_unlock(&rpc_sched_lock); } -- cgit v1.1 From 4ce70ada1ff1d0b80916ec9ec5764ce44a50a54f Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:05 +0100 Subject: SUNRPC: Further cleanups Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 21 +++++++++++---------- fs/nfs/unlink.c | 13 +++++-------- include/linux/sunrpc/sched.h | 1 + net/sunrpc/sched.c | 10 ++++++++++ 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3d5d3c0..368b75b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -195,14 +195,13 @@ static void update_changeattr(struct inode *inode, struct nfs4_change_info *cinf } /* Helper for asynchronous RPC calls */ -static int nfs4_call_async(struct rpc_clnt *clnt, rpc_action tk_begin, +static int nfs4_call_async(struct rpc_clnt *clnt, const struct rpc_call_ops *tk_ops, void *calldata) { struct rpc_task *task; if (!(task = rpc_new_task(clnt, RPC_TASK_ASYNC, tk_ops, calldata))) return -ENOMEM; - task->tk_action = tk_begin; rpc_execute(task); return 0; } @@ -882,6 +881,8 @@ static void nfs4_close_done(struct rpc_task *task, void *data) struct nfs4_state *state = calldata->state; struct nfs_server *server = NFS_SERVER(calldata->inode); + if (RPC_ASSASSINATED(task)) + return; /* hmm. we are done with the inode, and in the process of freeing * the state_owner. we keep this around to process errors */ @@ -904,9 +905,9 @@ static void nfs4_close_done(struct rpc_task *task, void *data) nfs_refresh_inode(calldata->inode, calldata->res.fattr); } -static void nfs4_close_begin(struct rpc_task *task) +static void nfs4_close_prepare(struct rpc_task *task, void *data) { - struct nfs4_closedata *calldata = (struct nfs4_closedata *)task->tk_calldata; + struct nfs4_closedata *calldata = data; struct nfs4_state *state = calldata->state; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE], @@ -944,6 +945,7 @@ static void nfs4_close_begin(struct rpc_task *task) } static const struct rpc_call_ops nfs4_close_ops = { + .rpc_call_prepare = nfs4_close_prepare, .rpc_call_done = nfs4_close_done, .rpc_release = nfs4_free_closedata, }; @@ -980,8 +982,7 @@ int nfs4_do_close(struct inode *inode, struct nfs4_state *state) calldata->res.fattr = &calldata->fattr; calldata->res.server = server; - status = nfs4_call_async(server->client, nfs4_close_begin, - &nfs4_close_ops, calldata); + status = nfs4_call_async(server->client, &nfs4_close_ops, calldata); if (status == 0) goto out; @@ -2909,9 +2910,9 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) } } -static void nfs4_locku_begin(struct rpc_task *task) +static void nfs4_locku_prepare(struct rpc_task *task, void *data) { - struct nfs4_unlockdata *calldata = (struct nfs4_unlockdata *)task->tk_calldata; + struct nfs4_unlockdata *calldata = data; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKU], .rpc_argp = &calldata->arg, @@ -2932,6 +2933,7 @@ static void nfs4_locku_begin(struct rpc_task *task) } static const struct rpc_call_ops nfs4_locku_ops = { + .rpc_call_prepare = nfs4_locku_prepare, .rpc_call_done = nfs4_locku_done, .rpc_release = nfs4_locku_complete, }; @@ -2979,8 +2981,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * atomic_set(&calldata->refcount, 2); init_completion(&calldata->completion); - status = nfs4_call_async(NFS_SERVER(inode)->client, nfs4_locku_begin, - &nfs4_locku_ops, calldata); + status = nfs4_call_async(NFS_SERVER(inode)->client, &nfs4_locku_ops, calldata); if (status == 0) wait_for_completion_interruptible(&calldata->completion); do_vfs_lock(request->fl_file, request); diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 1494484..a65c7b5 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -87,10 +87,9 @@ nfs_copy_dname(struct dentry *dentry, struct nfs_unlinkdata *data) * We delay initializing RPC info until after the call to dentry_iput() * in order to minimize races against rename(). */ -static void -nfs_async_unlink_init(struct rpc_task *task) +static void nfs_async_unlink_init(struct rpc_task *task, void *calldata) { - struct nfs_unlinkdata *data = (struct nfs_unlinkdata *)task->tk_calldata; + struct nfs_unlinkdata *data = calldata; struct dentry *dir = data->dir; struct rpc_message msg = { .rpc_cred = data->cred, @@ -147,6 +146,7 @@ static void nfs_async_unlink_release(void *calldata) } static const struct rpc_call_ops nfs_unlink_ops = { + .rpc_call_prepare = nfs_async_unlink_init, .rpc_call_done = nfs_async_unlink_done, .rpc_release = nfs_async_unlink_release, }; @@ -160,7 +160,6 @@ nfs_async_unlink(struct dentry *dentry) { struct dentry *dir = dentry->d_parent; struct nfs_unlinkdata *data; - struct rpc_task *task; struct rpc_clnt *clnt = NFS_CLIENT(dir->d_inode); int status = -ENOMEM; @@ -181,15 +180,13 @@ nfs_async_unlink(struct dentry *dentry) nfs_deletes = data; data->count = 1; - task = &data->task; - rpc_init_task(task, clnt, RPC_TASK_ASYNC, &nfs_unlink_ops, data); - task->tk_action = nfs_async_unlink_init; + rpc_init_task(&data->task, clnt, RPC_TASK_ASYNC, &nfs_unlink_ops, data); spin_lock(&dentry->d_lock); dentry->d_flags |= DCACHE_NFSFS_RENAMED; spin_unlock(&dentry->d_lock); - rpc_sleep_on(&nfs_delete_queue, task, NULL, NULL); + rpc_sleep_on(&nfs_delete_queue, &data->task, NULL, NULL); status = 0; out: return status; diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 581d8cd..ac1326f 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -112,6 +112,7 @@ struct rpc_task { typedef void (*rpc_action)(struct rpc_task *); struct rpc_call_ops { + void (*rpc_call_prepare)(struct rpc_task *, void *); void (*rpc_call_done)(struct rpc_task *, void *); void (*rpc_release)(void *); }; diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 8d6233d..2d74a16 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -555,6 +555,14 @@ __rpc_atrun(struct rpc_task *task) } /* + * Helper to call task->tk_ops->rpc_call_prepare + */ +static void rpc_prepare_task(struct rpc_task *task) +{ + task->tk_ops->rpc_call_prepare(task, task->tk_calldata); +} + +/* * Helper that calls task->tk_ops->rpc_call_done if it exists */ void rpc_exit_task(struct rpc_task *task) @@ -756,6 +764,8 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, cons task->tk_client = clnt; task->tk_flags = flags; task->tk_ops = tk_ops; + if (tk_ops->rpc_call_prepare != NULL) + task->tk_action = rpc_prepare_task; task->tk_calldata = calldata; /* Initialize retry counters */ -- cgit v1.1 From 44c288732fdbd7e38460d156a40d29590bf93bce Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:06 +0100 Subject: NFSv4: stateful NFSv4 RPC call interface The NFSv4 model requires us to complete all RPC calls that might establish state on the server whether or not the user wants to interrupt it. We may also need to schedule new work (including new RPC calls) in order to cancel the new state. The asynchronous RPC model will allow us to ensure that RPC calls always complete, but in order to allow for "synchronous" RPC, we want to add the ability to wait for completion. The waits are, of course, interruptible. Signed-off-by: Trond Myklebust --- fs/nfs/direct.c | 1 - include/linux/sunrpc/sched.h | 21 ++++++++++-- net/sunrpc/sched.c | 78 +++++++++++++++++++++++++++++++++----------- 3 files changed, 78 insertions(+), 22 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index a834423..ae2be07 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -268,7 +268,6 @@ static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, NFS_PROTO(inode)->read_setup(data); data->task.tk_cookie = (unsigned long) inode; - data->task.tk_calldata = data; data->complete = nfs_direct_read_result; lock_kernel(); diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index ac1326f..94b0afa 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -42,6 +42,7 @@ struct rpc_task { #ifdef RPC_DEBUG unsigned long tk_magic; /* 0xf00baa */ #endif + atomic_t tk_count; /* Reference count */ struct list_head tk_task; /* global list of tasks */ struct rpc_clnt * tk_client; /* RPC client */ struct rpc_rqst * tk_rqstp; /* RPC request */ @@ -78,7 +79,6 @@ struct rpc_task { struct timer_list tk_timer; /* kernel timer */ unsigned long tk_timeout; /* timeout for rpc_sleep() */ unsigned short tk_flags; /* misc flags */ - unsigned char tk_active : 1;/* Task has been activated */ unsigned char tk_priority : 2;/* Task priority */ unsigned long tk_runstate; /* Task run status */ struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could @@ -136,7 +136,6 @@ struct rpc_call_ops { #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) #define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) #define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) -#define RPC_IS_ACTIVATED(t) ((t)->tk_active) #define RPC_DO_CALLBACK(t) ((t)->tk_callback != NULL) #define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT) #define RPC_TASK_UNINTERRUPTIBLE(t) ((t)->tk_flags & RPC_TASK_NOINTR) @@ -145,6 +144,7 @@ struct rpc_call_ops { #define RPC_TASK_QUEUED 1 #define RPC_TASK_WAKEUP 2 #define RPC_TASK_HAS_TIMER 3 +#define RPC_TASK_ACTIVE 4 #define RPC_IS_RUNNING(t) (test_bit(RPC_TASK_RUNNING, &(t)->tk_runstate)) #define rpc_set_running(t) (set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate)) @@ -175,6 +175,15 @@ struct rpc_call_ops { smp_mb__after_clear_bit(); \ } while (0) +#define RPC_IS_ACTIVATED(t) (test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate)) +#define rpc_set_active(t) (set_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate)) +#define rpc_clear_active(t) \ + do { \ + smp_mb__before_clear_bit(); \ + clear_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate); \ + smp_mb__after_clear_bit(); \ + } while(0) + /* * Task priorities. * Note: if you change these, you must also change @@ -237,6 +246,8 @@ struct rpc_wait_queue { */ struct rpc_task *rpc_new_task(struct rpc_clnt *, int flags, const struct rpc_call_ops *ops, void *data); +struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags, + const struct rpc_call_ops *ops, void *data); struct rpc_task *rpc_new_child(struct rpc_clnt *, struct rpc_task *parent); void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, const struct rpc_call_ops *ops, @@ -260,6 +271,7 @@ void * rpc_malloc(struct rpc_task *, size_t); int rpciod_up(void); void rpciod_down(void); void rpciod_wake_up(void); +int __rpc_wait_for_completion_task(struct rpc_task *task, int (*)(void *)); #ifdef RPC_DEBUG void rpc_show_tasks(void); #endif @@ -272,6 +284,11 @@ static inline void rpc_exit(struct rpc_task *task, int status) task->tk_action = rpc_exit_task; } +static inline int rpc_wait_for_completion_task(struct rpc_task *task) +{ + return __rpc_wait_for_completion_task(task, NULL); +} + #ifdef RPC_DEBUG static inline const char * rpc_qname(struct rpc_wait_queue *q) { diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 2d74a16..82d158d 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -264,6 +264,35 @@ void rpc_init_wait_queue(struct rpc_wait_queue *queue, const char *qname) } EXPORT_SYMBOL(rpc_init_wait_queue); +static int rpc_wait_bit_interruptible(void *word) +{ + if (signal_pending(current)) + return -ERESTARTSYS; + schedule(); + return 0; +} + +/* + * Mark an RPC call as having completed by clearing the 'active' bit + */ +static inline void rpc_mark_complete_task(struct rpc_task *task) +{ + rpc_clear_active(task); + wake_up_bit(&task->tk_runstate, RPC_TASK_ACTIVE); +} + +/* + * Allow callers to wait for completion of an RPC call + */ +int __rpc_wait_for_completion_task(struct rpc_task *task, int (*action)(void *)) +{ + if (action == NULL) + action = rpc_wait_bit_interruptible; + return wait_on_bit(&task->tk_runstate, RPC_TASK_ACTIVE, + action, TASK_INTERRUPTIBLE); +} +EXPORT_SYMBOL(__rpc_wait_for_completion_task); + /* * Make an RPC task runnable. * @@ -299,10 +328,7 @@ static void rpc_make_runnable(struct rpc_task *task) static inline void rpc_schedule_run(struct rpc_task *task) { - /* Don't run a child twice! */ - if (RPC_IS_ACTIVATED(task)) - return; - task->tk_active = 1; + rpc_set_active(task); rpc_make_runnable(task); } @@ -324,8 +350,7 @@ static void __rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task, } /* Mark the task as being activated if so needed */ - if (!RPC_IS_ACTIVATED(task)) - task->tk_active = 1; + rpc_set_active(task); __rpc_add_wait_queue(q, task); @@ -580,14 +605,6 @@ void rpc_exit_task(struct rpc_task *task) } EXPORT_SYMBOL(rpc_exit_task); -static int rpc_wait_bit_interruptible(void *word) -{ - if (signal_pending(current)) - return -ERESTARTSYS; - schedule(); - return 0; -} - /* * This is the RPC `scheduler' (or rather, the finite state machine). */ @@ -680,6 +697,8 @@ static int __rpc_execute(struct rpc_task *task) dprintk("RPC: %4d exit() = %d\n", task->tk_pid, task->tk_status); status = task->tk_status; + /* Wake up anyone who is waiting for task completion */ + rpc_mark_complete_task(task); /* Release all resources associated with the task */ rpc_release_task(task); return status; @@ -697,9 +716,7 @@ static int __rpc_execute(struct rpc_task *task) int rpc_execute(struct rpc_task *task) { - BUG_ON(task->tk_active); - - task->tk_active = 1; + rpc_set_active(task); rpc_set_running(task); return __rpc_execute(task); } @@ -761,6 +778,7 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, cons init_timer(&task->tk_timer); task->tk_timer.data = (unsigned long) task; task->tk_timer.function = (void (*)(unsigned long)) rpc_run_timer; + atomic_set(&task->tk_count, 1); task->tk_client = clnt; task->tk_flags = flags; task->tk_ops = tk_ops; @@ -848,11 +866,13 @@ void rpc_release_task(struct rpc_task *task) { const struct rpc_call_ops *tk_ops = task->tk_ops; void *calldata = task->tk_calldata; - dprintk("RPC: %4d release task\n", task->tk_pid); #ifdef RPC_DEBUG BUG_ON(task->tk_magic != RPC_TASK_MAGIC_ID); #endif + if (!atomic_dec_and_test(&task->tk_count)) + return; + dprintk("RPC: %4d release task\n", task->tk_pid); /* Remove from global task list */ spin_lock(&rpc_sched_lock); @@ -860,7 +880,6 @@ void rpc_release_task(struct rpc_task *task) spin_unlock(&rpc_sched_lock); BUG_ON (RPC_IS_QUEUED(task)); - task->tk_active = 0; /* Synchronously delete any running timer */ rpc_delete_timer(task); @@ -886,6 +905,27 @@ void rpc_release_task(struct rpc_task *task) } /** + * rpc_run_task - Allocate a new RPC task, then run rpc_execute against it + * @clnt - pointer to RPC client + * @flags - RPC flags + * @ops - RPC call ops + * @data - user call data + */ +struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags, + const struct rpc_call_ops *ops, + void *data) +{ + struct rpc_task *task; + task = rpc_new_task(clnt, flags, ops, data); + if (task == NULL) + return ERR_PTR(-ENOMEM); + atomic_inc(&task->tk_count); + rpc_execute(task); + return task; +} +EXPORT_SYMBOL(rpc_run_task); + +/** * rpc_find_parent - find the parent of a child task. * @child: child task * -- cgit v1.1 From 06f814a3ad0ddfe19e6e4f44e3da5d490547faf3 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:07 +0100 Subject: NFSv4: Make locku use the new RPC "wait on completion" interface. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 65 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 368b75b..c7bec43 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -206,6 +206,17 @@ static int nfs4_call_async(struct rpc_clnt *clnt, return 0; } +static int nfs4_wait_for_completion_rpc_task(struct rpc_task *task) +{ + sigset_t oldset; + int ret; + + rpc_clnt_sigmask(task->tk_client, &oldset); + ret = rpc_wait_for_completion_task(task); + rpc_clnt_sigunmask(task->tk_client, &oldset); + return ret; +} + static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, int open_flags) { struct inode *inode = state->inode; @@ -2867,31 +2878,23 @@ struct nfs4_unlockdata { struct nfs_lockres res; struct nfs4_lock_state *lsp; struct nfs_open_context *ctx; - atomic_t refcount; - struct completion completion; }; -static void nfs4_locku_release_calldata(struct nfs4_unlockdata *calldata) -{ - if (atomic_dec_and_test(&calldata->refcount)) { - nfs_free_seqid(calldata->luargs.seqid); - nfs4_put_lock_state(calldata->lsp); - put_nfs_open_context(calldata->ctx); - kfree(calldata); - } -} - -static void nfs4_locku_complete(void *data) +static void nfs4_locku_release_calldata(void *data) { struct nfs4_unlockdata *calldata = data; - complete(&calldata->completion); - nfs4_locku_release_calldata(calldata); + nfs_free_seqid(calldata->luargs.seqid); + nfs4_put_lock_state(calldata->lsp); + put_nfs_open_context(calldata->ctx); + kfree(calldata); } static void nfs4_locku_done(struct rpc_task *task, void *data) { struct nfs4_unlockdata *calldata = data; + if (RPC_ASSASSINATED(task)) + return; nfs_increment_lock_seqid(task->tk_status, calldata->luargs.seqid); switch (task->tk_status) { case 0: @@ -2935,7 +2938,7 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data) static const struct rpc_call_ops nfs4_locku_ops = { .rpc_call_prepare = nfs4_locku_prepare, .rpc_call_done = nfs4_locku_done, - .rpc_release = nfs4_locku_complete, + .rpc_release = nfs4_locku_release_calldata, }; static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) @@ -2944,26 +2947,28 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * struct inode *inode = state->inode; struct nfs_server *server = NFS_SERVER(inode); struct nfs4_lock_state *lsp; - int status; + struct rpc_task *task; + int status = 0; /* Is this a delegated lock? */ if (test_bit(NFS_DELEGATED_STATE, &state->flags)) - return do_vfs_lock(request->fl_file, request); + goto out; status = nfs4_set_lock_state(state, request); if (status != 0) - return status; + goto out; lsp = request->fl_u.nfs4_fl.owner; /* We might have lost the locks! */ if ((lsp->ls_flags & NFS_LOCK_INITIALIZED) == 0) - return 0; + goto out; + status = -ENOMEM; calldata = kmalloc(sizeof(*calldata), GFP_KERNEL); if (calldata == NULL) - return -ENOMEM; + goto out; calldata->luargs.seqid = nfs_alloc_seqid(&lsp->ls_seqid); if (calldata->luargs.seqid == NULL) { kfree(calldata); - return -ENOMEM; + goto out; } calldata->luargs.stateid = &lsp->ls_stateid; calldata->arg.fh = NFS_FH(inode); @@ -2978,14 +2983,16 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * /* Ensure we don't close file until we're done freeing locks! */ calldata->ctx = get_nfs_open_context((struct nfs_open_context*)request->fl_file->private_data); - atomic_set(&calldata->refcount, 2); - init_completion(&calldata->completion); - - status = nfs4_call_async(NFS_SERVER(inode)->client, &nfs4_locku_ops, calldata); - if (status == 0) - wait_for_completion_interruptible(&calldata->completion); + task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_locku_ops, calldata); + if (!IS_ERR(task)) { + status = nfs4_wait_for_completion_rpc_task(task); + rpc_release_task(task); + } else { + status = PTR_ERR(task); + nfs4_locku_release_calldata(calldata); + } +out: do_vfs_lock(request->fl_file, request); - nfs4_locku_release_calldata(calldata); return status; } -- cgit v1.1 From e56e0b78eb1097a8e06512b9ed4be94d7538e7ac Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:08 +0100 Subject: NFSv4: Allocate OPEN call RPC arguments using kmalloc() Cleanup in preparation for making OPEN calls interruptible by the user. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 213 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 117 insertions(+), 96 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c7bec43..4a5cc840 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -194,6 +194,76 @@ static void update_changeattr(struct inode *inode, struct nfs4_change_info *cinf spin_unlock(&inode->i_lock); } +struct nfs4_opendata { + struct nfs_openargs o_arg; + struct nfs_openres o_res; + struct nfs_fattr f_attr; + struct nfs_fattr dir_attr; + struct dentry *dentry; + struct dentry *dir; + struct nfs4_state_owner *owner; + struct iattr attrs; +}; + +static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, + struct nfs4_state_owner *sp, int flags, + const struct iattr *attrs) +{ + struct dentry *parent = dget_parent(dentry); + struct inode *dir = parent->d_inode; + struct nfs_server *server = NFS_SERVER(dir); + struct nfs4_opendata *p; + + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (p == NULL) + goto err; + p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid); + if (p->o_arg.seqid == NULL) + goto err_free; + p->dentry = dget(dentry); + p->dir = parent; + p->owner = sp; + atomic_inc(&sp->so_count); + p->o_arg.fh = NFS_FH(dir); + p->o_arg.open_flags = flags, + p->o_arg.clientid = server->nfs4_state->cl_clientid; + p->o_arg.id = sp->so_id; + p->o_arg.name = &dentry->d_name; + p->o_arg.server = server; + p->o_arg.bitmask = server->attr_bitmask; + p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; + p->o_res.f_attr = &p->f_attr; + p->o_res.dir_attr = &p->dir_attr; + p->o_res.server = server; + nfs_fattr_init(&p->f_attr); + nfs_fattr_init(&p->dir_attr); + if (flags & O_EXCL) { + u32 *s = (u32 *) p->o_arg.u.verifier.data; + s[0] = jiffies; + s[1] = current->pid; + } else if (flags & O_CREAT) { + p->o_arg.u.attrs = &p->attrs; + memcpy(&p->attrs, attrs, sizeof(p->attrs)); + } + return p; +err_free: + kfree(p); +err: + dput(parent); + return NULL; +} + +static void nfs4_opendata_free(struct nfs4_opendata *p) +{ + if (p != NULL) { + nfs_free_seqid(p->o_arg.seqid); + nfs4_put_state_owner(p->owner); + dput(p->dir); + dput(p->dentry); + kfree(p); + } +} + /* Helper for asynchronous RPC calls */ static int nfs4_call_async(struct rpc_clnt *clnt, const struct rpc_call_ops *tk_ops, void *calldata) @@ -314,57 +384,45 @@ static int _nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state struct nfs4_state_owner *sp = state->owner; struct inode *inode = dentry->d_inode; struct nfs_server *server = NFS_SERVER(inode); - struct dentry *parent = dget_parent(dentry); - struct nfs_openargs arg = { - .fh = NFS_FH(parent->d_inode), - .clientid = server->nfs4_state->cl_clientid, - .name = &dentry->d_name, - .id = sp->so_id, - .server = server, - .bitmask = server->attr_bitmask, - .claim = NFS4_OPEN_CLAIM_DELEGATE_CUR, - }; - struct nfs_openres res = { - .server = server, - }; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR], - .rpc_argp = &arg, - .rpc_resp = &res, .rpc_cred = sp->so_cred, }; + struct nfs4_opendata *opendata; int status = 0; if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) goto out; if (state->state == 0) goto out; - arg.seqid = nfs_alloc_seqid(&sp->so_seqid); + opendata = nfs4_opendata_alloc(dentry, sp, state->state, NULL); status = -ENOMEM; - if (arg.seqid == NULL) + if (opendata == NULL) goto out; - arg.open_flags = state->state; - memcpy(arg.u.delegation.data, state->stateid.data, sizeof(arg.u.delegation.data)); + opendata->o_arg.claim = NFS4_OPEN_CLAIM_DELEGATE_CUR; + msg.rpc_argp = &opendata->o_arg; + msg.rpc_resp = &opendata->o_res; + memcpy(opendata->o_arg.u.delegation.data, state->stateid.data, + sizeof(opendata->o_arg.u.delegation.data)); status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); - nfs_increment_open_seqid(status, arg.seqid); + nfs_increment_open_seqid(status, opendata->o_arg.seqid); if (status != 0) goto out_free; - if(res.rflags & NFS4_OPEN_RESULT_CONFIRM) { + if(opendata->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) { status = _nfs4_proc_open_confirm(server->client, NFS_FH(inode), - sp, &res.stateid, arg.seqid); + sp, &opendata->o_res.stateid, opendata->o_arg.seqid); if (status != 0) goto out_free; } nfs_confirm_seqid(&sp->so_seqid, 0); if (status >= 0) { - memcpy(state->stateid.data, res.stateid.data, + memcpy(state->stateid.data, opendata->o_res.stateid.data, sizeof(state->stateid.data)); clear_bit(NFS_DELEGATED_STATE, &state->flags); } out_free: - nfs_free_seqid(arg.seqid); + nfs4_opendata_free(opendata); out: - dput(parent); return status; } @@ -506,21 +564,8 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st struct dentry *parent = dget_parent(dentry); struct inode *dir = parent->d_inode; struct inode *inode = state->inode; - struct nfs_server *server = NFS_SERVER(dir); struct nfs_delegation *delegation = NFS_I(inode)->delegation; - struct nfs_fattr f_attr, dir_attr; - struct nfs_openargs o_arg = { - .fh = NFS_FH(dir), - .open_flags = state->state, - .name = &dentry->d_name, - .bitmask = server->attr_bitmask, - .claim = NFS4_OPEN_CLAIM_NULL, - }; - struct nfs_openres o_res = { - .f_attr = &f_attr, - .dir_attr = &dir_attr, - .server = server, - }; + struct nfs4_opendata *opendata; int status = 0; if (delegation != NULL && !(delegation->flags & NFS_DELEGATION_NEED_RECLAIM)) { @@ -531,38 +576,38 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st set_bit(NFS_DELEGATED_STATE, &state->flags); goto out; } - o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid); status = -ENOMEM; - if (o_arg.seqid == NULL) + opendata = nfs4_opendata_alloc(dentry, sp, state->state, NULL); + if (opendata == NULL) goto out; - nfs_fattr_init(&f_attr); - nfs_fattr_init(&dir_attr); - status = _nfs4_proc_open(dir, sp, &o_arg, &o_res); + status = _nfs4_proc_open(dir, sp, &opendata->o_arg, &opendata->o_res); if (status != 0) goto out_nodeleg; /* Check if files differ */ - if ((f_attr.mode & S_IFMT) != (inode->i_mode & S_IFMT)) + if ((opendata->f_attr.mode & S_IFMT) != (inode->i_mode & S_IFMT)) goto out_stale; /* Has the file handle changed? */ - if (nfs_compare_fh(&o_res.fh, NFS_FH(inode)) != 0) { + if (nfs_compare_fh(&opendata->o_res.fh, NFS_FH(inode)) != 0) { /* Verify if the change attributes are the same */ - if (f_attr.change_attr != NFS_I(inode)->change_attr) + if (opendata->f_attr.change_attr != NFS_I(inode)->change_attr) goto out_stale; - if (nfs_size_to_loff_t(f_attr.size) != inode->i_size) + if (nfs_size_to_loff_t(opendata->f_attr.size) != inode->i_size) goto out_stale; /* Lets just pretend that this is the same file */ - nfs_copy_fh(NFS_FH(inode), &o_res.fh); - NFS_I(inode)->fileid = f_attr.fileid; + nfs_copy_fh(NFS_FH(inode), &opendata->o_res.fh); + NFS_I(inode)->fileid = opendata->f_attr.fileid; } - memcpy(&state->stateid, &o_res.stateid, sizeof(state->stateid)); - if (o_res.delegation_type != 0) { + memcpy(&state->stateid, &opendata->o_res.stateid, sizeof(state->stateid)); + if (opendata->o_res.delegation_type != 0) { if (!(delegation->flags & NFS_DELEGATION_NEED_RECLAIM)) - nfs_inode_set_delegation(inode, sp->so_cred, &o_res); + nfs_inode_set_delegation(inode, sp->so_cred, + &opendata->o_res); else - nfs_inode_reclaim_delegation(inode, sp->so_cred, &o_res); + nfs_inode_reclaim_delegation(inode, sp->so_cred, + &opendata->o_res); } out_nodeleg: - nfs_free_seqid(o_arg.seqid); + nfs4_opendata_free(opendata); clear_bit(NFS_DELEGATED_STATE, &state->flags); out: dput(parent); @@ -706,21 +751,8 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st struct nfs_server *server = NFS_SERVER(dir); struct nfs4_client *clp = server->nfs4_state; struct inode *inode = NULL; + struct nfs4_opendata *opendata; int status; - struct nfs_fattr f_attr, dir_attr; - struct nfs_openargs o_arg = { - .fh = NFS_FH(dir), - .open_flags = flags, - .name = &dentry->d_name, - .server = server, - .bitmask = server->attr_bitmask, - .claim = NFS4_OPEN_CLAIM_NULL, - }; - struct nfs_openres o_res = { - .f_attr = &f_attr, - .dir_attr = &dir_attr, - .server = server, - }; /* Protect against reboot recovery conflicts */ down_read(&clp->cl_sem); @@ -729,45 +761,34 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st dprintk("nfs4_do_open: nfs4_get_state_owner failed!\n"); goto out_err; } - if (flags & O_EXCL) { - u32 *p = (u32 *) o_arg.u.verifier.data; - p[0] = jiffies; - p[1] = current->pid; - } else - o_arg.u.attrs = sattr; - /* Serialization for the sequence id */ + opendata = nfs4_opendata_alloc(dentry, sp, flags, sattr); + if (opendata == NULL) + goto err_put_state_owner; - o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid); - if (o_arg.seqid == NULL) - return -ENOMEM; - nfs_fattr_init(&f_attr); - nfs_fattr_init(&dir_attr); - status = _nfs4_proc_open(dir, sp, &o_arg, &o_res); + status = _nfs4_proc_open(dir, sp, &opendata->o_arg, &opendata->o_res); if (status != 0) - goto out_err; + goto err_opendata_free; status = -ENOMEM; - inode = nfs_fhget(dir->i_sb, &o_res.fh, &f_attr); + inode = nfs_fhget(dir->i_sb, &opendata->o_res.fh, &opendata->f_attr); if (!inode) - goto out_err; + goto err_opendata_free; state = nfs4_get_open_state(inode, sp); if (!state) - goto out_err; - update_open_stateid(state, &o_res.stateid, flags); - if (o_res.delegation_type != 0) - nfs_inode_set_delegation(inode, cred, &o_res); - nfs_free_seqid(o_arg.seqid); + goto err_opendata_free; + update_open_stateid(state, &opendata->o_res.stateid, flags); + if (opendata->o_res.delegation_type != 0) + nfs_inode_set_delegation(inode, cred, &opendata->o_res); + nfs4_opendata_free(opendata); nfs4_put_state_owner(sp); up_read(&clp->cl_sem); *res = state; return 0; +err_opendata_free: + nfs4_opendata_free(opendata); +err_put_state_owner: + nfs4_put_state_owner(sp); out_err: - if (sp != NULL) { - if (state != NULL) - nfs4_put_open_state(state); - nfs_free_seqid(o_arg.seqid); - nfs4_put_state_owner(sp); - } /* Note: clp->cl_sem must be released before nfs4_put_open_state()! */ up_read(&clp->cl_sem); if (inode != NULL) -- cgit v1.1 From 89991c24e48b76f40aa3bd8c40c1e87c75d10a33 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:09 +0100 Subject: SUNRPC: Get rid of some unused exports Signed-off-by: Trond Myklebust --- net/sunrpc/sunrpc_syms.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index a03d4b6..9f73732 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -30,8 +30,6 @@ EXPORT_SYMBOL(rpc_init_task); EXPORT_SYMBOL(rpc_sleep_on); EXPORT_SYMBOL(rpc_wake_up_next); EXPORT_SYMBOL(rpc_wake_up_task); -EXPORT_SYMBOL(rpc_new_child); -EXPORT_SYMBOL(rpc_run_child); EXPORT_SYMBOL(rpciod_down); EXPORT_SYMBOL(rpciod_up); EXPORT_SYMBOL(rpc_new_task); @@ -45,7 +43,6 @@ EXPORT_SYMBOL(rpc_clone_client); EXPORT_SYMBOL(rpc_bind_new_program); EXPORT_SYMBOL(rpc_destroy_client); EXPORT_SYMBOL(rpc_shutdown_client); -EXPORT_SYMBOL(rpc_release_client); EXPORT_SYMBOL(rpc_killall_tasks); EXPORT_SYMBOL(rpc_call_sync); EXPORT_SYMBOL(rpc_call_async); @@ -120,7 +117,6 @@ EXPORT_SYMBOL(unix_domain_find); /* Generic XDR */ EXPORT_SYMBOL(xdr_encode_string); -EXPORT_SYMBOL(xdr_decode_string); EXPORT_SYMBOL(xdr_decode_string_inplace); EXPORT_SYMBOL(xdr_decode_netobj); EXPORT_SYMBOL(xdr_encode_netobj); -- cgit v1.1 From e60859ac0e50f660d23b72e42e05f58757dcfeff Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:10 +0100 Subject: SUNRPC: rpc_execute should not return task->tk_status; Signed-off-by: Trond Myklebust --- net/sunrpc/clnt.c | 11 ++++++----- net/sunrpc/sched.c | 4 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 8b2f75b..f025b7e 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -446,14 +446,15 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) rpc_call_setup(task, msg, 0); /* Set up the call info struct and execute the task */ - if (task->tk_status == 0) { + status = task->tk_status; + if (status == 0) { + atomic_inc(&task->tk_count); status = rpc_execute(task); - } else { - status = task->tk_status; - rpc_release_task(task); + if (status == 0) + status = task->tk_status; } - rpc_restore_sigmask(&oldset); + rpc_release_task(task); out: return status; } diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 82d158d..48510e3 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -694,9 +694,7 @@ static int __rpc_execute(struct rpc_task *task) dprintk("RPC: %4d sync task resuming\n", task->tk_pid); } - dprintk("RPC: %4d exit() = %d\n", task->tk_pid, task->tk_status); - status = task->tk_status; - + dprintk("RPC: %4d, return %d, status %d\n", task->tk_pid, status, task->tk_status); /* Wake up anyone who is waiting for task completion */ rpc_mark_complete_task(task); /* Release all resources associated with the task */ -- cgit v1.1 From 24ac23ab88df5b21b5b2df8cde748bf99b289099 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:11 +0100 Subject: NFSv4: Convert open() into an asynchronous RPC call OPEN is a stateful operation, so we must ensure that it always completes. In order to allow users to interrupt the operation, we need to make the RPC call asynchronous, and then wait on completion (or cancel). Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 193 ++++++++++++++++++++++++++++++++++++------------------ fs/nfs/nfs4xdr.c | 3 - 2 files changed, 130 insertions(+), 66 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4a5cc840..aed8701 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -195,6 +195,7 @@ static void update_changeattr(struct inode *inode, struct nfs4_change_info *cinf } struct nfs4_opendata { + atomic_t count; struct nfs_openargs o_arg; struct nfs_openres o_res; struct nfs_fattr f_attr; @@ -203,6 +204,8 @@ struct nfs4_opendata { struct dentry *dir; struct nfs4_state_owner *owner; struct iattr attrs; + int rpc_status; + int cancelled; }; static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, @@ -220,6 +223,7 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid); if (p->o_arg.seqid == NULL) goto err_free; + atomic_set(&p->count, 1); p->dentry = dget(dentry); p->dir = parent; p->owner = sp; @@ -255,7 +259,7 @@ err: static void nfs4_opendata_free(struct nfs4_opendata *p) { - if (p != NULL) { + if (p != NULL && atomic_dec_and_test(&p->count)) { nfs_free_seqid(p->o_arg.seqid); nfs4_put_state_owner(p->owner); dput(p->dir); @@ -305,6 +309,26 @@ static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, spin_unlock(&state->owner->so_lock); } +static struct nfs4_state *nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data) +{ + struct inode *inode; + struct nfs4_state *state = NULL; + + if (!(data->f_attr.valid & NFS_ATTR_FATTR)) + goto out; + inode = nfs_fhget(data->dir->d_sb, &data->o_res.fh, &data->f_attr); + if (inode == NULL) + goto out; + state = nfs4_get_open_state(inode, data->owner); + if (state == NULL) + goto put_inode; + update_open_stateid(state, &data->o_res.stateid, data->o_arg.open_flags); +put_inode: + iput(inode); +out: + return state; +} + /* * OPEN_RECLAIM: * reclaim state on the server after a reboot. @@ -473,41 +497,105 @@ static int _nfs4_proc_open_confirm(struct rpc_clnt *clnt, const struct nfs_fh *f return status; } -static int _nfs4_proc_open(struct inode *dir, struct nfs4_state_owner *sp, struct nfs_openargs *o_arg, struct nfs_openres *o_res) +static void nfs4_open_prepare(struct rpc_task *task, void *calldata) { - struct nfs_server *server = NFS_SERVER(dir); + struct nfs4_opendata *data = calldata; + struct nfs4_state_owner *sp = data->owner; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN], - .rpc_argp = o_arg, - .rpc_resp = o_res, + .rpc_argp = &data->o_arg, + .rpc_resp = &data->o_res, .rpc_cred = sp->so_cred, }; - int status; + + if (nfs_wait_on_sequence(data->o_arg.seqid, task) != 0) + return; + /* Update sequence id. */ + data->o_arg.id = sp->so_id; + data->o_arg.clientid = sp->so_client->cl_clientid; + rpc_call_setup(task, &msg, 0); +} - /* Update sequence id. The caller must serialize! */ - o_arg->id = sp->so_id; - o_arg->clientid = sp->so_client->cl_clientid; +static void nfs4_open_done(struct rpc_task *task, void *calldata) +{ + struct nfs4_opendata *data = calldata; - status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); - if (status == 0) { - /* OPEN on anything except a regular file is disallowed in NFSv4 */ - switch (o_res->f_attr->mode & S_IFMT) { + data->rpc_status = task->tk_status; + if (RPC_ASSASSINATED(task)) + return; + if (task->tk_status == 0) { + switch (data->o_res.f_attr->mode & S_IFMT) { case S_IFREG: break; case S_IFLNK: - status = -ELOOP; + data->rpc_status = -ELOOP; break; case S_IFDIR: - status = -EISDIR; + data->rpc_status = -EISDIR; break; default: - status = -ENOTDIR; + data->rpc_status = -ENOTDIR; } } + nfs_increment_open_seqid(data->rpc_status, data->o_arg.seqid); +} + +static void nfs4_open_release(void *calldata) +{ + struct nfs4_opendata *data = calldata; + struct nfs4_state *state = NULL; + + /* If this request hasn't been cancelled, do nothing */ + if (data->cancelled == 0) + goto out_free; + /* In case of error, no cleanup! */ + if (data->rpc_status != 0) + goto out_free; + /* In case we need an open_confirm, no cleanup! */ + if (data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) + goto out_free; + nfs_confirm_seqid(&data->owner->so_seqid, 0); + state = nfs4_opendata_to_nfs4_state(data); + if (state != NULL) + nfs4_close_state(state, data->o_arg.open_flags); +out_free: + nfs4_opendata_free(data); +} + +static const struct rpc_call_ops nfs4_open_ops = { + .rpc_call_prepare = nfs4_open_prepare, + .rpc_call_done = nfs4_open_done, + .rpc_release = nfs4_open_release, +}; - nfs_increment_open_seqid(status, o_arg->seqid); +/* + * Note: On error, nfs4_proc_open will free the struct nfs4_opendata + */ +static int _nfs4_proc_open(struct nfs4_opendata *data) +{ + struct inode *dir = data->dir->d_inode; + struct nfs_server *server = NFS_SERVER(dir); + struct nfs_openargs *o_arg = &data->o_arg; + struct nfs_openres *o_res = &data->o_res; + struct rpc_task *task; + int status; + + atomic_inc(&data->count); + task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_ops, data); + if (IS_ERR(task)) { + nfs4_opendata_free(data); + return PTR_ERR(task); + } + status = nfs4_wait_for_completion_rpc_task(task); + if (status != 0) { + data->cancelled = 1; + smp_wmb(); + } else + status = data->rpc_status; + rpc_release_task(task); if (status != 0) - goto out; + return status; + if (o_arg->open_flags & O_CREAT) { update_changeattr(dir, &o_res->cinfo); nfs_post_op_update_inode(dir, o_res->dir_attr); @@ -515,15 +603,14 @@ static int _nfs4_proc_open(struct inode *dir, struct nfs4_state_owner *sp, stru nfs_refresh_inode(dir, o_res->dir_attr); if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { status = _nfs4_proc_open_confirm(server->client, &o_res->fh, - sp, &o_res->stateid, o_arg->seqid); + data->owner, &o_res->stateid, o_arg->seqid); if (status != 0) - goto out; + return status; } - nfs_confirm_seqid(&sp->so_seqid, 0); + nfs_confirm_seqid(&data->owner->so_seqid, 0); if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) - status = server->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr); -out: - return status; + return server->rpc_ops->getattr(server, &o_res->fh, o_res->f_attr); + return 0; } static int _nfs4_do_access(struct inode *inode, struct rpc_cred *cred, int openflags) @@ -562,14 +649,15 @@ out: static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state, struct dentry *dentry) { struct dentry *parent = dget_parent(dentry); - struct inode *dir = parent->d_inode; struct inode *inode = state->inode; struct nfs_delegation *delegation = NFS_I(inode)->delegation; struct nfs4_opendata *opendata; + struct nfs4_state *newstate; + int openflags = state->state & (FMODE_READ|FMODE_WRITE); int status = 0; if (delegation != NULL && !(delegation->flags & NFS_DELEGATION_NEED_RECLAIM)) { - status = _nfs4_do_access(inode, sp->so_cred, state->state); + status = _nfs4_do_access(inode, sp->so_cred, openflags); if (status < 0) goto out; memcpy(&state->stateid, &delegation->stateid, sizeof(state->stateid)); @@ -577,27 +665,15 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st goto out; } status = -ENOMEM; - opendata = nfs4_opendata_alloc(dentry, sp, state->state, NULL); + opendata = nfs4_opendata_alloc(dentry, sp, openflags, NULL); if (opendata == NULL) goto out; - status = _nfs4_proc_open(dir, sp, &opendata->o_arg, &opendata->o_res); + status = _nfs4_proc_open(opendata); if (status != 0) goto out_nodeleg; - /* Check if files differ */ - if ((opendata->f_attr.mode & S_IFMT) != (inode->i_mode & S_IFMT)) + newstate = nfs4_opendata_to_nfs4_state(opendata); + if (newstate != state) goto out_stale; - /* Has the file handle changed? */ - if (nfs_compare_fh(&opendata->o_res.fh, NFS_FH(inode)) != 0) { - /* Verify if the change attributes are the same */ - if (opendata->f_attr.change_attr != NFS_I(inode)->change_attr) - goto out_stale; - if (nfs_size_to_loff_t(opendata->f_attr.size) != inode->i_size) - goto out_stale; - /* Lets just pretend that this is the same file */ - nfs_copy_fh(NFS_FH(inode), &opendata->o_res.fh); - NFS_I(inode)->fileid = opendata->f_attr.fileid; - } - memcpy(&state->stateid, &opendata->o_res.stateid, sizeof(state->stateid)); if (opendata->o_res.delegation_type != 0) { if (!(delegation->flags & NFS_DELEGATION_NEED_RECLAIM)) nfs_inode_set_delegation(inode, sp->so_cred, @@ -606,6 +682,8 @@ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st nfs_inode_reclaim_delegation(inode, sp->so_cred, &opendata->o_res); } +out_close_state: + nfs4_close_state(newstate, openflags); out_nodeleg: nfs4_opendata_free(opendata); clear_bit(NFS_DELEGATED_STATE, &state->flags); @@ -618,7 +696,7 @@ out_stale: nfs4_drop_state_owner(sp); d_drop(dentry); /* Should we be trying to close that stateid? */ - goto out_nodeleg; + goto out_close_state; } static inline int nfs4_do_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state, struct dentry *dentry) @@ -656,7 +734,7 @@ static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *sta } /* - * Returns an nfs4_state + an extra reference to the inode + * Returns a referenced nfs4_state if there is an open delegation on the file */ static int _nfs4_open_delegated(struct inode *inode, int flags, struct rpc_cred *cred, struct nfs4_state **res) { @@ -709,7 +787,6 @@ out_ok: nfs4_put_state_owner(sp); up_read(&nfsi->rwsem); up_read(&clp->cl_sem); - igrab(inode); *res = state; return 0; out_err: @@ -742,7 +819,7 @@ static struct nfs4_state *nfs4_open_delegated(struct inode *inode, int flags, st } /* - * Returns an nfs4_state + an referenced inode + * Returns a referenced nfs4_state */ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, struct iattr *sattr, struct rpc_cred *cred, struct nfs4_state **res) { @@ -750,7 +827,6 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st struct nfs4_state *state = NULL; struct nfs_server *server = NFS_SERVER(dir); struct nfs4_client *clp = server->nfs4_state; - struct inode *inode = NULL; struct nfs4_opendata *opendata; int status; @@ -765,20 +841,16 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st if (opendata == NULL) goto err_put_state_owner; - status = _nfs4_proc_open(dir, sp, &opendata->o_arg, &opendata->o_res); + status = _nfs4_proc_open(opendata); if (status != 0) goto err_opendata_free; status = -ENOMEM; - inode = nfs_fhget(dir->i_sb, &opendata->o_res.fh, &opendata->f_attr); - if (!inode) - goto err_opendata_free; - state = nfs4_get_open_state(inode, sp); - if (!state) + state = nfs4_opendata_to_nfs4_state(opendata); + if (state == NULL) goto err_opendata_free; - update_open_stateid(state, &opendata->o_res.stateid, flags); if (opendata->o_res.delegation_type != 0) - nfs_inode_set_delegation(inode, cred, &opendata->o_res); + nfs_inode_set_delegation(state->inode, cred, &opendata->o_res); nfs4_opendata_free(opendata); nfs4_put_state_owner(sp); up_read(&clp->cl_sem); @@ -791,8 +863,6 @@ err_put_state_owner: out_err: /* Note: clp->cl_sem must be released before nfs4_put_open_state()! */ up_read(&clp->cl_sem); - if (inode != NULL) - iput(inode); *res = NULL; return status; } @@ -1066,7 +1136,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) d_add(dentry, NULL); return (struct dentry *)state; } - res = d_add_unique(dentry, state->inode); + res = d_add_unique(dentry, igrab(state->inode)); if (res != NULL) dentry = res; nfs4_intent_set_file(nd, dentry, state); @@ -1078,7 +1148,6 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st { struct rpc_cred *cred; struct nfs4_state *state; - struct inode *inode; cred = rpcauth_lookupcred(NFS_SERVER(dir)->client->cl_auth, 0); if (IS_ERR(cred)) @@ -1102,9 +1171,7 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st } goto out_drop; } - inode = state->inode; - iput(inode); - if (inode == dentry->d_inode) { + if (state->inode == dentry->d_inode) { nfs4_intent_set_file(nd, dentry, state); return 1; } @@ -1633,7 +1700,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, status = PTR_ERR(state); goto out; } - d_instantiate(dentry, state->inode); + d_instantiate(dentry, igrab(state->inode)); if (flags & O_EXCL) { struct nfs_fattr fattr; status = nfs4_do_setattr(NFS_SERVER(dir), &fattr, diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index fbbace8..db2bcf7 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1499,9 +1499,6 @@ static int nfs4_xdr_enc_open(struct rpc_rqst *req, uint32_t *p, struct nfs_opena }; int status; - status = nfs_wait_on_sequence(args->seqid, req->rq_task); - if (status != 0) - goto out; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); status = encode_putfh(&xdr, args->fh); -- cgit v1.1 From cdd4e68b5f0ed12c64b3e2be83655d2a47588a74 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:12 +0100 Subject: NFSv4: Make open_confirm() asynchronous too Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 101 +++++++++++++++++++++++++++++++++++++----------- fs/nfs/nfs4xdr.c | 7 +--- include/linux/nfs_xdr.h | 2 +- 3 files changed, 81 insertions(+), 29 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index aed8701..8154f25 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -57,7 +57,8 @@ #define NFS4_POLL_RETRY_MIN (1*HZ) #define NFS4_POLL_RETRY_MAX (15*HZ) -static int _nfs4_proc_open_confirm(struct rpc_clnt *clnt, const struct nfs_fh *fh, struct nfs4_state_owner *sp, nfs4_stateid *stateid, struct nfs_seqid *seqid); +struct nfs4_opendata; +static int _nfs4_proc_open_confirm(struct nfs4_opendata *data); static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *); static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry); @@ -198,6 +199,8 @@ struct nfs4_opendata { atomic_t count; struct nfs_openargs o_arg; struct nfs_openres o_res; + struct nfs_open_confirmargs c_arg; + struct nfs_open_confirmres c_res; struct nfs_fattr f_attr; struct nfs_fattr dir_attr; struct dentry *dentry; @@ -249,6 +252,9 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry, p->o_arg.u.attrs = &p->attrs; memcpy(&p->attrs, attrs, sizeof(p->attrs)); } + p->c_arg.fh = &p->o_res.fh; + p->c_arg.stateid = &p->o_res.stateid; + p->c_arg.seqid = p->o_arg.seqid; return p; err_free: kfree(p); @@ -433,8 +439,7 @@ static int _nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state if (status != 0) goto out_free; if(opendata->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) { - status = _nfs4_proc_open_confirm(server->client, NFS_FH(inode), - sp, &opendata->o_res.stateid, opendata->o_arg.seqid); + status = _nfs4_proc_open_confirm(opendata); if (status != 0) goto out_free; } @@ -472,28 +477,79 @@ int nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state) return err; } -static int _nfs4_proc_open_confirm(struct rpc_clnt *clnt, const struct nfs_fh *fh, struct nfs4_state_owner *sp, nfs4_stateid *stateid, struct nfs_seqid *seqid) +static void nfs4_open_confirm_prepare(struct rpc_task *task, void *calldata) { - struct nfs_open_confirmargs arg = { - .fh = fh, - .seqid = seqid, - .stateid = *stateid, - }; - struct nfs_open_confirmres res; - struct rpc_message msg = { - .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_CONFIRM], - .rpc_argp = &arg, - .rpc_resp = &res, - .rpc_cred = sp->so_cred, + struct nfs4_opendata *data = calldata; + struct rpc_message msg = { + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_CONFIRM], + .rpc_argp = &data->c_arg, + .rpc_resp = &data->c_res, + .rpc_cred = data->owner->so_cred, }; + rpc_call_setup(task, &msg, 0); +} + +static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata) +{ + struct nfs4_opendata *data = calldata; + + data->rpc_status = task->tk_status; + if (RPC_ASSASSINATED(task)) + return; + if (data->rpc_status == 0) + memcpy(data->o_res.stateid.data, data->c_res.stateid.data, + sizeof(data->o_res.stateid.data)); + nfs_increment_open_seqid(data->rpc_status, data->c_arg.seqid); + nfs_confirm_seqid(&data->owner->so_seqid, data->rpc_status); +} + +static void nfs4_open_confirm_release(void *calldata) +{ + struct nfs4_opendata *data = calldata; + struct nfs4_state *state = NULL; + + /* If this request hasn't been cancelled, do nothing */ + if (data->cancelled == 0) + goto out_free; + /* In case of error, no cleanup! */ + if (data->rpc_status != 0) + goto out_free; + nfs_confirm_seqid(&data->owner->so_seqid, 0); + state = nfs4_opendata_to_nfs4_state(data); + if (state != NULL) + nfs4_close_state(state, data->o_arg.open_flags); +out_free: + nfs4_opendata_free(data); +} + +static const struct rpc_call_ops nfs4_open_confirm_ops = { + .rpc_call_prepare = nfs4_open_confirm_prepare, + .rpc_call_done = nfs4_open_confirm_done, + .rpc_release = nfs4_open_confirm_release, +}; + +/* + * Note: On error, nfs4_proc_open_confirm will free the struct nfs4_opendata + */ +static int _nfs4_proc_open_confirm(struct nfs4_opendata *data) +{ + struct nfs_server *server = NFS_SERVER(data->dir->d_inode); + struct rpc_task *task; int status; - status = rpc_call_sync(clnt, &msg, RPC_TASK_NOINTR); - /* Confirm the sequence as being established */ - nfs_confirm_seqid(&sp->so_seqid, status); - nfs_increment_open_seqid(status, seqid); - if (status >= 0) - memcpy(stateid, &res.stateid, sizeof(*stateid)); + atomic_inc(&data->count); + task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_confirm_ops, data); + if (IS_ERR(task)) { + nfs4_opendata_free(data); + return PTR_ERR(task); + } + status = nfs4_wait_for_completion_rpc_task(task); + if (status != 0) { + data->cancelled = 1; + smp_wmb(); + } else + status = data->rpc_status; + rpc_release_task(task); return status; } @@ -602,8 +658,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) } else nfs_refresh_inode(dir, o_res->dir_attr); if(o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { - status = _nfs4_proc_open_confirm(server->client, &o_res->fh, - data->owner, &o_res->stateid, o_arg->seqid); + status = _nfs4_proc_open_confirm(data); if (status != 0) return status; } diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index db2bcf7..2ba9906 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -964,9 +964,9 @@ static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_con { uint32_t *p; - RESERVE_SPACE(8+sizeof(arg->stateid.data)); + RESERVE_SPACE(8+sizeof(arg->stateid->data)); WRITE32(OP_OPEN_CONFIRM); - WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data)); + WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data)); WRITE32(arg->seqid->sequence->counter); return 0; @@ -1535,9 +1535,6 @@ static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, uint32_t *p, struct n }; int status; - status = nfs_wait_on_sequence(args->seqid, req->rq_task); - if (status != 0) - goto out; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); status = encode_putfh(&xdr, args->fh); diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 4071866..518cfa5 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -137,7 +137,7 @@ struct nfs_openres { */ struct nfs_open_confirmargs { const struct nfs_fh * fh; - nfs4_stateid stateid; + nfs4_stateid * stateid; struct nfs_seqid * seqid; }; -- cgit v1.1 From e761692381f294ea079d2e869fcd7c0afc79e394 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:13 +0100 Subject: NFSv4: Make nfs4_state track O_RDWR, O_RDONLY and O_WRONLY separately A closer reading of RFC3530 reveals that OPEN_DOWNGRADE must always specify a access modes that have been the argument of a previous OPEN operation. IOW: doing OPEN(O_RDWR) and then OPEN_DOWNGRADE(O_WRONLY) is forbidden unless the user called OPEN(O_WRONLY) In order to fix that, we really need to track the three possible open states separately. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 5 +++-- fs/nfs/nfs4proc.c | 34 ++++++++++++++++++++++------------ fs/nfs/nfs4state.c | 31 +++++++++++++++++-------------- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index b7f262d..4ad5981 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -182,8 +182,9 @@ struct nfs4_state { nfs4_stateid stateid; - unsigned int nreaders; - unsigned int nwriters; + unsigned int n_rdonly; + unsigned int n_wronly; + unsigned int n_rdwr; int state; /* State on the server (R,W, or RW) */ atomic_t count; }; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 8154f25..e494cc2 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -297,6 +297,20 @@ static int nfs4_wait_for_completion_rpc_task(struct rpc_task *task) return ret; } +static inline void update_open_stateflags(struct nfs4_state *state, mode_t open_flags) +{ + switch (open_flags) { + case FMODE_WRITE: + state->n_wronly++; + break; + case FMODE_READ: + state->n_rdonly++; + break; + case FMODE_READ|FMODE_WRITE: + state->n_rdwr++; + } +} + static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, int open_flags) { struct inode *inode = state->inode; @@ -306,10 +320,7 @@ static void update_open_stateid(struct nfs4_state *state, nfs4_stateid *stateid, spin_lock(&state->owner->so_lock); spin_lock(&inode->i_lock); memcpy(&state->stateid, stateid, sizeof(state->stateid)); - if ((open_flags & FMODE_WRITE)) - state->nwriters++; - if (open_flags & FMODE_READ) - state->nreaders++; + update_open_stateflags(state, open_flags); nfs4_state_set_mode_locked(state, state->state | open_flags); spin_unlock(&inode->i_lock); spin_unlock(&state->owner->so_lock); @@ -822,10 +833,7 @@ static int _nfs4_open_delegated(struct inode *inode, int flags, struct rpc_cred err = -ENOENT; if ((state->state & open_flags) == open_flags) { spin_lock(&inode->i_lock); - if (open_flags & FMODE_READ) - state->nreaders++; - if (open_flags & FMODE_WRITE) - state->nwriters++; + update_open_stateflags(state, open_flags); spin_unlock(&inode->i_lock); goto out_ok; } else if (state->state != 0) @@ -1082,10 +1090,12 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) spin_lock(&state->owner->so_lock); spin_lock(&calldata->inode->i_lock); mode = old_mode = state->state; - if (state->nreaders == 0) - mode &= ~FMODE_READ; - if (state->nwriters == 0) - mode &= ~FMODE_WRITE; + if (state->n_rdwr == 0) { + if (state->n_rdonly == 0) + mode &= ~FMODE_READ; + if (state->n_wronly == 0) + mode &= ~FMODE_WRITE; + } nfs4_state_set_mode_locked(state, mode); spin_unlock(&calldata->inode->i_lock); spin_unlock(&state->owner->so_lock); diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 5ef4c57..41a5f1a 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -349,14 +349,9 @@ nfs4_alloc_open_state(void) { struct nfs4_state *state; - state = kmalloc(sizeof(*state), GFP_KERNEL); + state = kzalloc(sizeof(*state), GFP_KERNEL); if (!state) return NULL; - state->state = 0; - state->nreaders = 0; - state->nwriters = 0; - state->flags = 0; - memset(state->stateid.data, 0, sizeof(state->stateid.data)); atomic_set(&state->count, 1); INIT_LIST_HEAD(&state->lock_states); spin_lock_init(&state->state_lock); @@ -475,15 +470,23 @@ void nfs4_close_state(struct nfs4_state *state, mode_t mode) /* Protect against nfs4_find_state() */ spin_lock(&owner->so_lock); spin_lock(&inode->i_lock); - if (mode & FMODE_READ) - state->nreaders--; - if (mode & FMODE_WRITE) - state->nwriters--; + switch (mode & (FMODE_READ | FMODE_WRITE)) { + case FMODE_READ: + state->n_rdonly--; + break; + case FMODE_WRITE: + state->n_wronly--; + break; + case FMODE_READ|FMODE_WRITE: + state->n_rdwr--; + } oldstate = newstate = state->state; - if (state->nreaders == 0) - newstate &= ~FMODE_READ; - if (state->nwriters == 0) - newstate &= ~FMODE_WRITE; + if (state->n_rdwr == 0) { + if (state->n_rdonly == 0) + newstate &= ~FMODE_READ; + if (state->n_wronly == 0) + newstate &= ~FMODE_WRITE; + } if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { nfs4_state_set_mode_locked(state, newstate); oldstate = newstate; -- cgit v1.1 From 864472e9b8fa76ffaad17dfcb84d79e16df6828c Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:15 +0100 Subject: NFSv4: Make open recovery track O_RDWR, O_RDONLY and O_WRONLY correctly When recovering from a delegation recall or a network partition, we need to replay open(O_RDWR), open(O_RDONLY) and open(O_WRONLY) separately. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 276 +++++++++++++++++++++++++++++------------------------- fs/nfs/nfs4xdr.c | 11 ++- 2 files changed, 156 insertions(+), 131 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index e494cc2..3ecb7da 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -58,7 +58,7 @@ #define NFS4_POLL_RETRY_MAX (15*HZ) struct nfs4_opendata; -static int _nfs4_proc_open_confirm(struct nfs4_opendata *data); +static int _nfs4_proc_open(struct nfs4_opendata *data); static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *); static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry); @@ -346,32 +346,108 @@ out: return state; } +static struct nfs_open_context *nfs4_state_find_open_context(struct nfs4_state *state) +{ + struct nfs_inode *nfsi = NFS_I(state->inode); + struct nfs_open_context *ctx; + + spin_lock(&state->inode->i_lock); + list_for_each_entry(ctx, &nfsi->open_files, list) { + if (ctx->state != state) + continue; + get_nfs_open_context(ctx); + spin_unlock(&state->inode->i_lock); + return ctx; + } + spin_unlock(&state->inode->i_lock); + return ERR_PTR(-ENOENT); +} + +static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, mode_t openflags, nfs4_stateid *stateid) +{ + int ret; + + opendata->o_arg.open_flags = openflags; + ret = _nfs4_proc_open(opendata); + if (ret != 0) + return ret; + memcpy(stateid->data, opendata->o_res.stateid.data, + sizeof(stateid->data)); + return 0; +} + +static int nfs4_open_recover(struct nfs4_opendata *opendata, struct nfs4_state *state) +{ + nfs4_stateid stateid; + struct nfs4_state *newstate; + int mode = 0; + int delegation = 0; + int ret; + + /* memory barrier prior to reading state->n_* */ + smp_rmb(); + if (state->n_rdwr != 0) { + ret = nfs4_open_recover_helper(opendata, FMODE_READ|FMODE_WRITE, &stateid); + if (ret != 0) + return ret; + mode |= FMODE_READ|FMODE_WRITE; + if (opendata->o_res.delegation_type != 0) + delegation = opendata->o_res.delegation_type; + smp_rmb(); + } + if (state->n_wronly != 0) { + ret = nfs4_open_recover_helper(opendata, FMODE_WRITE, &stateid); + if (ret != 0) + return ret; + mode |= FMODE_WRITE; + if (opendata->o_res.delegation_type != 0) + delegation = opendata->o_res.delegation_type; + smp_rmb(); + } + if (state->n_rdonly != 0) { + ret = nfs4_open_recover_helper(opendata, FMODE_READ, &stateid); + if (ret != 0) + return ret; + mode |= FMODE_READ; + } + clear_bit(NFS_DELEGATED_STATE, &state->flags); + if (mode == 0) + return 0; + if (opendata->o_res.delegation_type == 0) + opendata->o_res.delegation_type = delegation; + opendata->o_arg.open_flags |= mode; + newstate = nfs4_opendata_to_nfs4_state(opendata); + if (newstate != NULL) { + if (opendata->o_res.delegation_type != 0) { + struct nfs_inode *nfsi = NFS_I(newstate->inode); + int delegation_flags = 0; + if (nfsi->delegation) + delegation_flags = nfsi->delegation->flags; + if (!(delegation_flags & NFS_DELEGATION_NEED_RECLAIM)) + nfs_inode_set_delegation(newstate->inode, + opendata->owner->so_cred, + &opendata->o_res); + else + nfs_inode_reclaim_delegation(newstate->inode, + opendata->owner->so_cred, + &opendata->o_res); + } + nfs4_close_state(newstate, opendata->o_arg.open_flags); + } + if (newstate != state) + return -ESTALE; + return 0; +} + /* * OPEN_RECLAIM: * reclaim state on the server after a reboot. */ -static int _nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state) +static int _nfs4_do_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state, struct dentry *dentry) { - struct inode *inode = state->inode; - struct nfs_server *server = NFS_SERVER(inode); - struct nfs_delegation *delegation = NFS_I(inode)->delegation; - struct nfs_openargs o_arg = { - .fh = NFS_FH(inode), - .id = sp->so_id, - .open_flags = state->state, - .clientid = server->nfs4_state->cl_clientid, - .claim = NFS4_OPEN_CLAIM_PREVIOUS, - .bitmask = server->attr_bitmask, - }; - struct nfs_openres o_res = { - .server = server, /* Grrr */ - }; - struct rpc_message msg = { - .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR], - .rpc_argp = &o_arg, - .rpc_resp = &o_res, - .rpc_cred = sp->so_cred, - }; + struct nfs_delegation *delegation = NFS_I(state->inode)->delegation; + struct nfs4_opendata *opendata; + int delegation_type = 0; int status; if (delegation != NULL) { @@ -381,38 +457,27 @@ static int _nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *st set_bit(NFS_DELEGATED_STATE, &state->flags); return 0; } - o_arg.u.delegation_type = delegation->type; + delegation_type = delegation->type; } - o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid); - if (o_arg.seqid == NULL) + opendata = nfs4_opendata_alloc(dentry, sp, 0, NULL); + if (opendata == NULL) return -ENOMEM; - status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); - /* Confirm the sequence as being established */ - nfs_confirm_seqid(&sp->so_seqid, status); - nfs_increment_open_seqid(status, o_arg.seqid); - if (status == 0) { - memcpy(&state->stateid, &o_res.stateid, sizeof(state->stateid)); - if (o_res.delegation_type != 0) { - nfs_inode_reclaim_delegation(inode, sp->so_cred, &o_res); - /* Did the server issue an immediate delegation recall? */ - if (o_res.do_recall) - nfs_async_inode_return_delegation(inode, &o_res.stateid); - } - } - nfs_free_seqid(o_arg.seqid); - clear_bit(NFS_DELEGATED_STATE, &state->flags); - /* Ensure we update the inode attributes */ - NFS_CACHEINV(inode); + opendata->o_arg.claim = NFS4_OPEN_CLAIM_PREVIOUS; + opendata->o_arg.fh = NFS_FH(state->inode); + nfs_copy_fh(&opendata->o_res.fh, opendata->o_arg.fh); + opendata->o_arg.u.delegation_type = delegation_type; + status = nfs4_open_recover(opendata, state); + nfs4_opendata_free(opendata); return status; } -static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state) +static int nfs4_do_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state, struct dentry *dentry) { struct nfs_server *server = NFS_SERVER(state->inode); struct nfs4_exception exception = { }; int err; do { - err = _nfs4_open_reclaim(sp, state); + err = _nfs4_do_open_reclaim(sp, state, dentry); if (err != -NFS4ERR_DELAY) break; nfs4_handle_exception(server, err, &exception); @@ -420,50 +485,36 @@ static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *sta return err; } +static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state) +{ + struct nfs_open_context *ctx; + int ret; + + ctx = nfs4_state_find_open_context(state); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + ret = nfs4_do_open_reclaim(sp, state, ctx->dentry); + put_nfs_open_context(ctx); + return ret; +} + static int _nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state) { struct nfs4_state_owner *sp = state->owner; - struct inode *inode = dentry->d_inode; - struct nfs_server *server = NFS_SERVER(inode); - struct rpc_message msg = { - .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR], - .rpc_cred = sp->so_cred, - }; struct nfs4_opendata *opendata; - int status = 0; + int ret; if (!test_bit(NFS_DELEGATED_STATE, &state->flags)) - goto out; - if (state->state == 0) - goto out; - opendata = nfs4_opendata_alloc(dentry, sp, state->state, NULL); - status = -ENOMEM; + return 0; + opendata = nfs4_opendata_alloc(dentry, sp, 0, NULL); if (opendata == NULL) - goto out; + return -ENOMEM; opendata->o_arg.claim = NFS4_OPEN_CLAIM_DELEGATE_CUR; - msg.rpc_argp = &opendata->o_arg; - msg.rpc_resp = &opendata->o_res; memcpy(opendata->o_arg.u.delegation.data, state->stateid.data, sizeof(opendata->o_arg.u.delegation.data)); - status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); - nfs_increment_open_seqid(status, opendata->o_arg.seqid); - if (status != 0) - goto out_free; - if(opendata->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM) { - status = _nfs4_proc_open_confirm(opendata); - if (status != 0) - goto out_free; - } - nfs_confirm_seqid(&sp->so_seqid, 0); - if (status >= 0) { - memcpy(state->stateid.data, opendata->o_res.stateid.data, - sizeof(state->stateid.data)); - clear_bit(NFS_DELEGATED_STATE, &state->flags); - } -out_free: + ret = nfs4_open_recover(opendata, state); nfs4_opendata_free(opendata); -out: - return status; + return ret; } int nfs4_open_delegation_recall(struct dentry *dentry, struct nfs4_state *state) @@ -580,6 +631,8 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata) /* Update sequence id. */ data->o_arg.id = sp->so_id; data->o_arg.clientid = sp->so_client->cl_clientid; + if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) + msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; rpc_call_setup(task, &msg, 0); } @@ -714,55 +767,31 @@ out: */ static int _nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state, struct dentry *dentry) { - struct dentry *parent = dget_parent(dentry); struct inode *inode = state->inode; struct nfs_delegation *delegation = NFS_I(inode)->delegation; struct nfs4_opendata *opendata; - struct nfs4_state *newstate; int openflags = state->state & (FMODE_READ|FMODE_WRITE); - int status = 0; + int ret; if (delegation != NULL && !(delegation->flags & NFS_DELEGATION_NEED_RECLAIM)) { - status = _nfs4_do_access(inode, sp->so_cred, openflags); - if (status < 0) - goto out; + ret = _nfs4_do_access(inode, sp->so_cred, openflags); + if (ret < 0) + return ret; memcpy(&state->stateid, &delegation->stateid, sizeof(state->stateid)); set_bit(NFS_DELEGATED_STATE, &state->flags); - goto out; + return 0; } - status = -ENOMEM; opendata = nfs4_opendata_alloc(dentry, sp, openflags, NULL); if (opendata == NULL) - goto out; - status = _nfs4_proc_open(opendata); - if (status != 0) - goto out_nodeleg; - newstate = nfs4_opendata_to_nfs4_state(opendata); - if (newstate != state) - goto out_stale; - if (opendata->o_res.delegation_type != 0) { - if (!(delegation->flags & NFS_DELEGATION_NEED_RECLAIM)) - nfs_inode_set_delegation(inode, sp->so_cred, - &opendata->o_res); - else - nfs_inode_reclaim_delegation(inode, sp->so_cred, - &opendata->o_res); + return -ENOMEM; + ret = nfs4_open_recover(opendata, state); + if (ret == -ESTALE) { + /* Invalidate the state owner so we don't ever use it again */ + nfs4_drop_state_owner(sp); + d_drop(dentry); } -out_close_state: - nfs4_close_state(newstate, openflags); -out_nodeleg: nfs4_opendata_free(opendata); - clear_bit(NFS_DELEGATED_STATE, &state->flags); -out: - dput(parent); - return status; -out_stale: - status = -ESTALE; - /* Invalidate the state owner so we don't ever use it again */ - nfs4_drop_state_owner(sp); - d_drop(dentry); - /* Should we be trying to close that stateid? */ - goto out_close_state; + return ret; } static inline int nfs4_do_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state, struct dentry *dentry) @@ -781,22 +810,15 @@ static inline int nfs4_do_open_expired(struct nfs4_state_owner *sp, struct nfs4_ static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *state) { - struct nfs_inode *nfsi = NFS_I(state->inode); struct nfs_open_context *ctx; - int status; + int ret; - spin_lock(&state->inode->i_lock); - list_for_each_entry(ctx, &nfsi->open_files, list) { - if (ctx->state != state) - continue; - get_nfs_open_context(ctx); - spin_unlock(&state->inode->i_lock); - status = nfs4_do_open_expired(sp, state, ctx->dentry); - put_nfs_open_context(ctx); - return status; - } - spin_unlock(&state->inode->i_lock); - return -ENOENT; + ctx = nfs4_state_find_open_context(state); + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + ret = nfs4_do_open_expired(sp, state, ctx->dentry); + put_nfs_open_context(ctx); + return ret; } /* diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 2ba9906..3100172 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1552,19 +1552,19 @@ static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, uint32_t *p, struct nf { struct xdr_stream xdr; struct compound_hdr hdr = { - .nops = 2, + .nops = 3, }; int status; - status = nfs_wait_on_sequence(args->seqid, req->rq_task); - if (status != 0) - goto out; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); status = encode_putfh(&xdr, args->fh); if (status) goto out; status = encode_open(&xdr, args); + if (status) + goto out; + status = encode_getfattr(&xdr, args->bitmask); out: return status; } @@ -3825,6 +3825,9 @@ static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp, uint32_t *p, struct if (status) goto out; status = decode_open(&xdr, res); + if (status) + goto out; + decode_getfattr(&xdr, res->f_attr, res->server); out: return status; } -- cgit v1.1 From 911d1aaf26fc4d771174d98fcab710a44e2a5fa0 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:16 +0100 Subject: NFSv4: locking XDR cleanup Get rid of some unnecessary intermediate structures Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 192 ++++++++++++++++++++---------------------------- fs/nfs/nfs4xdr.c | 131 +++++++++++++++++++-------------- include/linux/nfs_xdr.h | 52 ++++++------- 3 files changed, 179 insertions(+), 196 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 3ecb7da..8571257 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2935,43 +2935,17 @@ nfs4_set_lock_task_retry(unsigned long timeout) return timeout; } -static inline int -nfs4_lck_type(int cmd, struct file_lock *request) -{ - /* set lock type */ - switch (request->fl_type) { - case F_RDLCK: - return IS_SETLKW(cmd) ? NFS4_READW_LT : NFS4_READ_LT; - case F_WRLCK: - return IS_SETLKW(cmd) ? NFS4_WRITEW_LT : NFS4_WRITE_LT; - case F_UNLCK: - return NFS4_WRITE_LT; - } - BUG(); - return 0; -} - -static inline uint64_t -nfs4_lck_length(struct file_lock *request) -{ - if (request->fl_end == OFFSET_MAX) - return ~(uint64_t)0; - return request->fl_end - request->fl_start + 1; -} - static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request) { struct inode *inode = state->inode; struct nfs_server *server = NFS_SERVER(inode); struct nfs4_client *clp = server->nfs4_state; - struct nfs_lockargs arg = { + struct nfs_lockt_args arg = { .fh = NFS_FH(inode), - .type = nfs4_lck_type(cmd, request), - .offset = request->fl_start, - .length = nfs4_lck_length(request), + .fl = request, }; - struct nfs_lockres res = { - .server = server, + struct nfs_lockt_res res = { + .denied = request, }; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKT], @@ -2979,36 +2953,23 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock .rpc_resp = &res, .rpc_cred = state->owner->so_cred, }; - struct nfs_lowner nlo; struct nfs4_lock_state *lsp; int status; down_read(&clp->cl_sem); - nlo.clientid = clp->cl_clientid; + arg.lock_owner.clientid = clp->cl_clientid; status = nfs4_set_lock_state(state, request); if (status != 0) goto out; lsp = request->fl_u.nfs4_fl.owner; - nlo.id = lsp->ls_id; - arg.u.lockt = &nlo; + arg.lock_owner.id = lsp->ls_id; status = rpc_call_sync(server->client, &msg, 0); - if (!status) { - request->fl_type = F_UNLCK; - } else if (status == -NFS4ERR_DENIED) { - int64_t len, start, end; - start = res.u.denied.offset; - len = res.u.denied.length; - end = start + len - 1; - if (end < 0 || len == 0) - request->fl_end = OFFSET_MAX; - else - request->fl_end = (loff_t)end; - request->fl_start = (loff_t)start; - request->fl_type = F_WRLCK; - if (res.u.denied.type & 1) - request->fl_type = F_RDLCK; - request->fl_pid = 0; - status = 0; + switch (status) { + case 0: + request->fl_type = F_UNLCK; + break; + case -NFS4ERR_DENIED: + status = 0; } out: up_read(&clp->cl_sem); @@ -3048,17 +3009,42 @@ static int do_vfs_lock(struct file *file, struct file_lock *fl) } struct nfs4_unlockdata { - struct nfs_lockargs arg; - struct nfs_locku_opargs luargs; - struct nfs_lockres res; + struct nfs_locku_args arg; + struct nfs_locku_res res; struct nfs4_lock_state *lsp; struct nfs_open_context *ctx; + struct file_lock fl; + const struct nfs_server *server; }; +static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl, + struct nfs_open_context *ctx, + struct nfs4_lock_state *lsp, + struct nfs_seqid *seqid) +{ + struct nfs4_unlockdata *p; + struct inode *inode = lsp->ls_state->inode; + + p = kmalloc(sizeof(*p), GFP_KERNEL); + if (p == NULL) + return NULL; + p->arg.fh = NFS_FH(inode); + p->arg.fl = &p->fl; + p->arg.seqid = seqid; + p->arg.stateid = &lsp->ls_stateid; + p->lsp = lsp; + atomic_inc(&lsp->ls_count); + /* Ensure we don't close file until we're done freeing locks! */ + p->ctx = get_nfs_open_context(ctx); + memcpy(&p->fl, fl, sizeof(p->fl)); + p->server = NFS_SERVER(inode); + return p; +} + static void nfs4_locku_release_calldata(void *data) { struct nfs4_unlockdata *calldata = data; - nfs_free_seqid(calldata->luargs.seqid); + nfs_free_seqid(calldata->arg.seqid); nfs4_put_lock_state(calldata->lsp); put_nfs_open_context(calldata->ctx); kfree(calldata); @@ -3070,19 +3056,19 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) if (RPC_ASSASSINATED(task)) return; - nfs_increment_lock_seqid(task->tk_status, calldata->luargs.seqid); + nfs_increment_lock_seqid(task->tk_status, calldata->arg.seqid); switch (task->tk_status) { case 0: memcpy(calldata->lsp->ls_stateid.data, - calldata->res.u.stateid.data, + calldata->res.stateid.data, sizeof(calldata->lsp->ls_stateid.data)); break; case -NFS4ERR_STALE_STATEID: case -NFS4ERR_EXPIRED: - nfs4_schedule_state_recovery(calldata->res.server->nfs4_state); + nfs4_schedule_state_recovery(calldata->server->nfs4_state); break; default: - if (nfs4_async_handle_error(task, calldata->res.server) == -EAGAIN) { + if (nfs4_async_handle_error(task, calldata->server) == -EAGAIN) { rpc_restart_call(task); } } @@ -3097,10 +3083,8 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data) .rpc_resp = &calldata->res, .rpc_cred = calldata->lsp->ls_state->owner->so_cred, }; - int status; - status = nfs_wait_on_sequence(calldata->luargs.seqid, task); - if (status != 0) + if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) return; if ((calldata->lsp->ls_flags & NFS_LOCK_INITIALIZED) == 0) { /* Note: exit _without_ running nfs4_locku_done */ @@ -3121,43 +3105,32 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * struct nfs4_unlockdata *calldata; struct inode *inode = state->inode; struct nfs_server *server = NFS_SERVER(inode); + struct nfs_seqid *seqid; struct nfs4_lock_state *lsp; struct rpc_task *task; int status = 0; /* Is this a delegated lock? */ if (test_bit(NFS_DELEGATED_STATE, &state->flags)) - goto out; + goto out_unlock; + /* Is this open_owner holding any locks on the server? */ + if (test_bit(LK_STATE_IN_USE, &state->flags) == 0) + goto out_unlock; status = nfs4_set_lock_state(state, request); if (status != 0) - goto out; + goto out_unlock; lsp = request->fl_u.nfs4_fl.owner; - /* We might have lost the locks! */ - if ((lsp->ls_flags & NFS_LOCK_INITIALIZED) == 0) - goto out; status = -ENOMEM; - calldata = kmalloc(sizeof(*calldata), GFP_KERNEL); + seqid = nfs_alloc_seqid(&lsp->ls_seqid); + if (seqid == NULL) + goto out_unlock; + calldata = nfs4_alloc_unlockdata(request, request->fl_file->private_data, + lsp, seqid); if (calldata == NULL) - goto out; - calldata->luargs.seqid = nfs_alloc_seqid(&lsp->ls_seqid); - if (calldata->luargs.seqid == NULL) { - kfree(calldata); - goto out; - } - calldata->luargs.stateid = &lsp->ls_stateid; - calldata->arg.fh = NFS_FH(inode); - calldata->arg.type = nfs4_lck_type(cmd, request); - calldata->arg.offset = request->fl_start; - calldata->arg.length = nfs4_lck_length(request); - calldata->arg.u.locku = &calldata->luargs; - calldata->res.server = server; - calldata->lsp = lsp; - atomic_inc(&lsp->ls_count); - - /* Ensure we don't close file until we're done freeing locks! */ - calldata->ctx = get_nfs_open_context((struct nfs_open_context*)request->fl_file->private_data); - + goto out_free_seqid; + /* Unlock _before_ we do the RPC call */ + do_vfs_lock(request->fl_file, request); task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_locku_ops, calldata); if (!IS_ERR(task)) { status = nfs4_wait_for_completion_rpc_task(task); @@ -3166,7 +3139,10 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * status = PTR_ERR(task); nfs4_locku_release_calldata(calldata); } -out: + return status; +out_free_seqid: + nfs_free_seqid(seqid); +out_unlock: do_vfs_lock(request->fl_file, request); return status; } @@ -3176,27 +3152,19 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *r struct inode *inode = state->inode; struct nfs_server *server = NFS_SERVER(inode); struct nfs4_lock_state *lsp = request->fl_u.nfs4_fl.owner; - struct nfs_lock_opargs largs = { + struct nfs_lock_args arg = { + .fh = NFS_FH(inode), + .fl = request, .lock_stateid = &lsp->ls_stateid, .open_stateid = &state->stateid, .lock_owner = { .clientid = server->nfs4_state->cl_clientid, .id = lsp->ls_id, }, + .block = (IS_SETLKW(cmd)) ? 1 : 0, .reclaim = reclaim, }; - struct nfs_lockargs arg = { - .fh = NFS_FH(inode), - .type = nfs4_lck_type(cmd, request), - .offset = request->fl_start, - .length = nfs4_lck_length(request), - .u = { - .lock = &largs, - }, - }; - struct nfs_lockres res = { - .server = server, - }; + struct nfs_lock_res res; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCK], .rpc_argp = &arg, @@ -3205,37 +3173,37 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *r }; int status = -ENOMEM; - largs.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid); - if (largs.lock_seqid == NULL) + arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid); + if (arg.lock_seqid == NULL) return -ENOMEM; if (!(lsp->ls_seqid.flags & NFS_SEQID_CONFIRMED)) { struct nfs4_state_owner *owner = state->owner; - largs.open_seqid = nfs_alloc_seqid(&owner->so_seqid); - if (largs.open_seqid == NULL) + arg.open_seqid = nfs_alloc_seqid(&owner->so_seqid); + if (arg.open_seqid == NULL) goto out; - largs.new_lock_owner = 1; + arg.new_lock_owner = 1; status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); /* increment open seqid on success, and seqid mutating errors */ - if (largs.new_lock_owner != 0) { - nfs_increment_open_seqid(status, largs.open_seqid); + if (arg.new_lock_owner != 0) { + nfs_increment_open_seqid(status, arg.open_seqid); if (status == 0) nfs_confirm_seqid(&lsp->ls_seqid, 0); } - nfs_free_seqid(largs.open_seqid); + nfs_free_seqid(arg.open_seqid); } else status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); /* increment lock seqid on success, and seqid mutating errors*/ - nfs_increment_lock_seqid(status, largs.lock_seqid); + nfs_increment_lock_seqid(status, arg.lock_seqid); /* save the returned stateid. */ if (status == 0) { - memcpy(lsp->ls_stateid.data, res.u.stateid.data, + memcpy(lsp->ls_stateid.data, res.stateid.data, sizeof(lsp->ls_stateid.data)); lsp->ls_flags |= NFS_LOCK_INITIALIZED; } else if (status == -NFS4ERR_DENIED) status = -EAGAIN; out: - nfs_free_seqid(largs.lock_seqid); + nfs_free_seqid(arg.lock_seqid); return status; } diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 3100172..a7b5de8 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -742,69 +742,80 @@ static int encode_link(struct xdr_stream *xdr, const struct qstr *name) return 0; } +static inline int nfs4_lock_type(struct file_lock *fl, int block) +{ + if ((fl->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) == F_RDLCK) + return block ? NFS4_READW_LT : NFS4_READ_LT; + return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; +} + +static inline uint64_t nfs4_lock_length(struct file_lock *fl) +{ + if (fl->fl_end == OFFSET_MAX) + return ~(uint64_t)0; + return fl->fl_end - fl->fl_start + 1; +} + /* * opcode,type,reclaim,offset,length,new_lock_owner = 32 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 */ -static int encode_lock(struct xdr_stream *xdr, const struct nfs_lockargs *arg) +static int encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args) { uint32_t *p; - struct nfs_lock_opargs *opargs = arg->u.lock; RESERVE_SPACE(32); WRITE32(OP_LOCK); - WRITE32(arg->type); - WRITE32(opargs->reclaim); - WRITE64(arg->offset); - WRITE64(arg->length); - WRITE32(opargs->new_lock_owner); - if (opargs->new_lock_owner){ + WRITE32(nfs4_lock_type(args->fl, args->block)); + WRITE32(args->reclaim); + WRITE64(args->fl->fl_start); + WRITE64(nfs4_lock_length(args->fl)); + WRITE32(args->new_lock_owner); + if (args->new_lock_owner){ RESERVE_SPACE(40); - WRITE32(opargs->open_seqid->sequence->counter); - WRITEMEM(opargs->open_stateid->data, sizeof(opargs->open_stateid->data)); - WRITE32(opargs->lock_seqid->sequence->counter); - WRITE64(opargs->lock_owner.clientid); + WRITE32(args->open_seqid->sequence->counter); + WRITEMEM(args->open_stateid->data, sizeof(args->open_stateid->data)); + WRITE32(args->lock_seqid->sequence->counter); + WRITE64(args->lock_owner.clientid); WRITE32(4); - WRITE32(opargs->lock_owner.id); + WRITE32(args->lock_owner.id); } else { RESERVE_SPACE(20); - WRITEMEM(opargs->lock_stateid->data, sizeof(opargs->lock_stateid->data)); - WRITE32(opargs->lock_seqid->sequence->counter); + WRITEMEM(args->lock_stateid->data, sizeof(args->lock_stateid->data)); + WRITE32(args->lock_seqid->sequence->counter); } return 0; } -static int encode_lockt(struct xdr_stream *xdr, const struct nfs_lockargs *arg) +static int encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *args) { uint32_t *p; - struct nfs_lowner *opargs = arg->u.lockt; RESERVE_SPACE(40); WRITE32(OP_LOCKT); - WRITE32(arg->type); - WRITE64(arg->offset); - WRITE64(arg->length); - WRITE64(opargs->clientid); + WRITE32(nfs4_lock_type(args->fl, 0)); + WRITE64(args->fl->fl_start); + WRITE64(nfs4_lock_length(args->fl)); + WRITE64(args->lock_owner.clientid); WRITE32(4); - WRITE32(opargs->id); + WRITE32(args->lock_owner.id); return 0; } -static int encode_locku(struct xdr_stream *xdr, const struct nfs_lockargs *arg) +static int encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *args) { uint32_t *p; - struct nfs_locku_opargs *opargs = arg->u.locku; RESERVE_SPACE(44); WRITE32(OP_LOCKU); - WRITE32(arg->type); - WRITE32(opargs->seqid->sequence->counter); - WRITEMEM(opargs->stateid->data, sizeof(opargs->stateid->data)); - WRITE64(arg->offset); - WRITE64(arg->length); + WRITE32(nfs4_lock_type(args->fl, 0)); + WRITE32(args->seqid->sequence->counter); + WRITEMEM(args->stateid->data, sizeof(args->stateid->data)); + WRITE64(args->fl->fl_start); + WRITE64(nfs4_lock_length(args->fl)); return 0; } @@ -1596,21 +1607,20 @@ out: /* * Encode a LOCK request */ -static int nfs4_xdr_enc_lock(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) +static int nfs4_xdr_enc_lock(struct rpc_rqst *req, uint32_t *p, struct nfs_lock_args *args) { struct xdr_stream xdr; struct compound_hdr hdr = { .nops = 2, }; - struct nfs_lock_opargs *opargs = args->u.lock; int status; - status = nfs_wait_on_sequence(opargs->lock_seqid, req->rq_task); + status = nfs_wait_on_sequence(args->lock_seqid, req->rq_task); if (status != 0) goto out; /* Do we need to do an open_to_lock_owner? */ - if (opargs->lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED) - opargs->new_lock_owner = 0; + if (args->lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED) + args->new_lock_owner = 0; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); status = encode_putfh(&xdr, args->fh); @@ -1624,7 +1634,7 @@ out: /* * Encode a LOCKT request */ -static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) +static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, uint32_t *p, struct nfs_lockt_args *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1645,7 +1655,7 @@ out: /* * Encode a LOCKU request */ -static int nfs4_xdr_enc_locku(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) +static int nfs4_xdr_enc_locku(struct rpc_rqst *req, uint32_t *p, struct nfs_locku_args *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -2949,55 +2959,64 @@ static int decode_link(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) /* * We create the owner, so we know a proper owner.id length is 4. */ -static int decode_lock_denied (struct xdr_stream *xdr, struct nfs_lock_denied *denied) +static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) { + uint64_t offset, length, clientid; uint32_t *p; - uint32_t namelen; + uint32_t namelen, type; READ_BUF(32); - READ64(denied->offset); - READ64(denied->length); - READ32(denied->type); - READ64(denied->owner.clientid); + READ64(offset); + READ64(length); + READ32(type); + if (fl != NULL) { + fl->fl_start = (loff_t)offset; + fl->fl_end = fl->fl_start + (loff_t)length - 1; + if (length == ~(uint64_t)0) + fl->fl_end = OFFSET_MAX; + fl->fl_type = F_WRLCK; + if (type & 1) + fl->fl_type = F_RDLCK; + fl->fl_pid = 0; + } + READ64(clientid); READ32(namelen); READ_BUF(namelen); - if (namelen == 4) - READ32(denied->owner.id); return -NFS4ERR_DENIED; } -static int decode_lock(struct xdr_stream *xdr, struct nfs_lockres *res) +static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res) { uint32_t *p; int status; status = decode_op_hdr(xdr, OP_LOCK); if (status == 0) { - READ_BUF(sizeof(res->u.stateid.data)); - COPYMEM(res->u.stateid.data, sizeof(res->u.stateid.data)); + READ_BUF(sizeof(res->stateid.data)); + COPYMEM(res->stateid.data, sizeof(res->stateid.data)); } else if (status == -NFS4ERR_DENIED) - return decode_lock_denied(xdr, &res->u.denied); + return decode_lock_denied(xdr, NULL); return status; } -static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockres *res) +static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockt_res *res) { int status; status = decode_op_hdr(xdr, OP_LOCKT); if (status == -NFS4ERR_DENIED) - return decode_lock_denied(xdr, &res->u.denied); + return decode_lock_denied(xdr, res->denied); return status; } -static int decode_locku(struct xdr_stream *xdr, struct nfs_lockres *res) +static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res) { uint32_t *p; int status; status = decode_op_hdr(xdr, OP_LOCKU); if (status == 0) { - READ_BUF(sizeof(res->u.stateid.data)); - COPYMEM(res->u.stateid.data, sizeof(res->u.stateid.data)); + READ_BUF(sizeof(res->stateid.data)); + COPYMEM(res->stateid.data, sizeof(res->stateid.data)); } return status; } @@ -3861,7 +3880,7 @@ out: /* * Decode LOCK response */ -static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) +static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lock_res *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3882,7 +3901,7 @@ out: /* * Decode LOCKT response */ -static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) +static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockt_res *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3903,7 +3922,7 @@ out: /* * Decode LOCKU response */ -static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) +static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_locku_res *res) { struct xdr_stream xdr; struct compound_hdr hdr; diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 518cfa5..b8b0eed 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -165,50 +165,46 @@ struct nfs_closeres { * * Arguments to the lock,lockt, and locku call. * */ struct nfs_lowner { - __u64 clientid; - u32 id; + __u64 clientid; + u32 id; }; -struct nfs_lock_opargs { +struct nfs_lock_args { + struct nfs_fh * fh; + struct file_lock * fl; struct nfs_seqid * lock_seqid; nfs4_stateid * lock_stateid; struct nfs_seqid * open_seqid; nfs4_stateid * open_stateid; - struct nfs_lowner lock_owner; - __u32 reclaim; - __u32 new_lock_owner; + struct nfs_lowner lock_owner; + unsigned char block : 1; + unsigned char reclaim : 1; + unsigned char new_lock_owner : 1; +}; + +struct nfs_lock_res { + nfs4_stateid stateid; }; -struct nfs_locku_opargs { +struct nfs_locku_args { + struct nfs_fh * fh; + struct file_lock * fl; struct nfs_seqid * seqid; nfs4_stateid * stateid; }; -struct nfs_lockargs { - struct nfs_fh * fh; - __u32 type; - __u64 offset; - __u64 length; - union { - struct nfs_lock_opargs *lock; /* LOCK */ - struct nfs_lowner *lockt; /* LOCKT */ - struct nfs_locku_opargs *locku; /* LOCKU */ - } u; +struct nfs_locku_res { + nfs4_stateid stateid; }; -struct nfs_lock_denied { - __u64 offset; - __u64 length; - __u32 type; - struct nfs_lowner owner; +struct nfs_lockt_args { + struct nfs_fh * fh; + struct file_lock * fl; + struct nfs_lowner lock_owner; }; -struct nfs_lockres { - union { - nfs4_stateid stateid;/* LOCK success, LOCKU */ - struct nfs_lock_denied denied; /* LOCK failed, LOCKT success */ - } u; - const struct nfs_server * server; +struct nfs_lockt_res { + struct file_lock * denied; /* LOCK, LOCKT failed */ }; struct nfs4_delegreturnargs { -- cgit v1.1 From a5d16a4d090bd2af86e648ed9bb205903fcf1e86 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:17 +0100 Subject: NFSv4: Convert LOCK rpc call into an asynchronous RPC call In order to allow users to interrupt/cancel it. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 244 +++++++++++++++++++++++++++++++++++++++--------------- fs/nfs/nfs4xdr.c | 6 -- 2 files changed, 175 insertions(+), 75 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 8571257..718fcc7 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3100,11 +3100,30 @@ static const struct rpc_call_ops nfs4_locku_ops = { .rpc_release = nfs4_locku_release_calldata, }; +static struct rpc_task *nfs4_do_unlck(struct file_lock *fl, + struct nfs_open_context *ctx, + struct nfs4_lock_state *lsp, + struct nfs_seqid *seqid) +{ + struct nfs4_unlockdata *data; + struct rpc_task *task; + + data = nfs4_alloc_unlockdata(fl, ctx, lsp, seqid); + if (data == NULL) { + nfs_free_seqid(seqid); + return ERR_PTR(-ENOMEM); + } + + /* Unlock _before_ we do the RPC call */ + do_vfs_lock(fl->fl_file, fl); + task = rpc_run_task(NFS_CLIENT(lsp->ls_state->inode), RPC_TASK_ASYNC, &nfs4_locku_ops, data); + if (IS_ERR(task)) + nfs4_locku_release_calldata(data); + return task; +} + static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) { - struct nfs4_unlockdata *calldata; - struct inode *inode = state->inode; - struct nfs_server *server = NFS_SERVER(inode); struct nfs_seqid *seqid; struct nfs4_lock_state *lsp; struct rpc_task *task; @@ -3125,86 +3144,173 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * seqid = nfs_alloc_seqid(&lsp->ls_seqid); if (seqid == NULL) goto out_unlock; - calldata = nfs4_alloc_unlockdata(request, request->fl_file->private_data, - lsp, seqid); - if (calldata == NULL) - goto out_free_seqid; - /* Unlock _before_ we do the RPC call */ - do_vfs_lock(request->fl_file, request); - task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_locku_ops, calldata); - if (!IS_ERR(task)) { - status = nfs4_wait_for_completion_rpc_task(task); - rpc_release_task(task); - } else { - status = PTR_ERR(task); - nfs4_locku_release_calldata(calldata); - } + task = nfs4_do_unlck(request, request->fl_file->private_data, lsp, seqid); + status = PTR_ERR(task); + if (IS_ERR(task)) + goto out_unlock; + status = nfs4_wait_for_completion_rpc_task(task); + rpc_release_task(task); return status; -out_free_seqid: - nfs_free_seqid(seqid); out_unlock: do_vfs_lock(request->fl_file, request); return status; } -static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *request, int reclaim) +struct nfs4_lockdata { + struct nfs_lock_args arg; + struct nfs_lock_res res; + struct nfs4_lock_state *lsp; + struct nfs_open_context *ctx; + struct file_lock fl; + int rpc_status; + int cancelled; +}; + +static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl, + struct nfs_open_context *ctx, struct nfs4_lock_state *lsp) { - struct inode *inode = state->inode; + struct nfs4_lockdata *p; + struct inode *inode = lsp->ls_state->inode; struct nfs_server *server = NFS_SERVER(inode); - struct nfs4_lock_state *lsp = request->fl_u.nfs4_fl.owner; - struct nfs_lock_args arg = { - .fh = NFS_FH(inode), - .fl = request, - .lock_stateid = &lsp->ls_stateid, - .open_stateid = &state->stateid, - .lock_owner = { - .clientid = server->nfs4_state->cl_clientid, - .id = lsp->ls_id, - }, - .block = (IS_SETLKW(cmd)) ? 1 : 0, - .reclaim = reclaim, - }; - struct nfs_lock_res res; + + p = kzalloc(sizeof(*p), GFP_KERNEL); + if (p == NULL) + return NULL; + + p->arg.fh = NFS_FH(inode); + p->arg.fl = &p->fl; + p->arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid); + if (p->arg.lock_seqid == NULL) + goto out_free; + p->arg.lock_stateid = &lsp->ls_stateid; + p->arg.lock_owner.clientid = server->nfs4_state->cl_clientid; + p->arg.lock_owner.id = lsp->ls_id; + p->lsp = lsp; + atomic_inc(&lsp->ls_count); + p->ctx = get_nfs_open_context(ctx); + memcpy(&p->fl, fl, sizeof(p->fl)); + return p; +out_free: + kfree(p); + return NULL; +} + +static void nfs4_lock_prepare(struct rpc_task *task, void *calldata) +{ + struct nfs4_lockdata *data = calldata; + struct nfs4_state *state = data->lsp->ls_state; + struct nfs4_state_owner *sp = state->owner; struct rpc_message msg = { - .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCK], - .rpc_argp = &arg, - .rpc_resp = &res, - .rpc_cred = state->owner->so_cred, + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCK], + .rpc_argp = &data->arg, + .rpc_resp = &data->res, + .rpc_cred = sp->so_cred, }; - int status = -ENOMEM; - - arg.lock_seqid = nfs_alloc_seqid(&lsp->ls_seqid); - if (arg.lock_seqid == NULL) - return -ENOMEM; - if (!(lsp->ls_seqid.flags & NFS_SEQID_CONFIRMED)) { - struct nfs4_state_owner *owner = state->owner; - arg.open_seqid = nfs_alloc_seqid(&owner->so_seqid); - if (arg.open_seqid == NULL) + if (nfs_wait_on_sequence(data->arg.lock_seqid, task) != 0) + return; + dprintk("%s: begin!\n", __FUNCTION__); + /* Do we need to do an open_to_lock_owner? */ + if (!(data->arg.lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)) { + data->arg.open_seqid = nfs_alloc_seqid(&sp->so_seqid); + if (data->arg.open_seqid == NULL) { + data->rpc_status = -ENOMEM; + task->tk_action = NULL; goto out; - arg.new_lock_owner = 1; - status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); - /* increment open seqid on success, and seqid mutating errors */ - if (arg.new_lock_owner != 0) { - nfs_increment_open_seqid(status, arg.open_seqid); - if (status == 0) - nfs_confirm_seqid(&lsp->ls_seqid, 0); } - nfs_free_seqid(arg.open_seqid); - } else - status = rpc_call_sync(server->client, &msg, RPC_TASK_NOINTR); - /* increment lock seqid on success, and seqid mutating errors*/ - nfs_increment_lock_seqid(status, arg.lock_seqid); - /* save the returned stateid. */ - if (status == 0) { - memcpy(lsp->ls_stateid.data, res.stateid.data, - sizeof(lsp->ls_stateid.data)); - lsp->ls_flags |= NFS_LOCK_INITIALIZED; - } else if (status == -NFS4ERR_DENIED) - status = -EAGAIN; + data->arg.open_stateid = &state->stateid; + data->arg.new_lock_owner = 1; + } + rpc_call_setup(task, &msg, 0); out: - nfs_free_seqid(arg.lock_seqid); - return status; + dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status); +} + +static void nfs4_lock_done(struct rpc_task *task, void *calldata) +{ + struct nfs4_lockdata *data = calldata; + + dprintk("%s: begin!\n", __FUNCTION__); + + data->rpc_status = task->tk_status; + if (RPC_ASSASSINATED(task)) + goto out; + if (data->arg.new_lock_owner != 0) { + nfs_increment_open_seqid(data->rpc_status, data->arg.open_seqid); + if (data->rpc_status == 0) + nfs_confirm_seqid(&data->lsp->ls_seqid, 0); + else + goto out; + } + if (data->rpc_status == 0) { + memcpy(data->lsp->ls_stateid.data, data->res.stateid.data, + sizeof(data->lsp->ls_stateid.data)); + data->lsp->ls_flags |= NFS_LOCK_INITIALIZED; + } + nfs_increment_lock_seqid(data->rpc_status, data->arg.lock_seqid); +out: + dprintk("%s: done, ret = %d!\n", __FUNCTION__, data->rpc_status); +} + +static void nfs4_lock_release(void *calldata) +{ + struct nfs4_lockdata *data = calldata; + + dprintk("%s: begin!\n", __FUNCTION__); + if (data->arg.open_seqid != NULL) + nfs_free_seqid(data->arg.open_seqid); + if (data->cancelled != 0) { + struct rpc_task *task; + task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp, + data->arg.lock_seqid); + if (!IS_ERR(task)) + rpc_release_task(task); + dprintk("%s: cancelling lock!\n", __FUNCTION__); + } else + nfs_free_seqid(data->arg.lock_seqid); + nfs4_put_lock_state(data->lsp); + put_nfs_open_context(data->ctx); + kfree(data); + dprintk("%s: done!\n", __FUNCTION__); +} + +static const struct rpc_call_ops nfs4_lock_ops = { + .rpc_call_prepare = nfs4_lock_prepare, + .rpc_call_done = nfs4_lock_done, + .rpc_release = nfs4_lock_release, +}; + +static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int reclaim) +{ + struct nfs4_lockdata *data; + struct rpc_task *task; + int ret; + + dprintk("%s: begin!\n", __FUNCTION__); + data = nfs4_alloc_lockdata(fl, fl->fl_file->private_data, + fl->fl_u.nfs4_fl.owner); + if (data == NULL) + return -ENOMEM; + if (IS_SETLKW(cmd)) + data->arg.block = 1; + if (reclaim != 0) + data->arg.reclaim = 1; + task = rpc_run_task(NFS_CLIENT(state->inode), RPC_TASK_ASYNC, + &nfs4_lock_ops, data); + if (IS_ERR(task)) { + nfs4_lock_release(data); + return PTR_ERR(task); + } + ret = nfs4_wait_for_completion_rpc_task(task); + if (ret == 0) { + ret = data->rpc_status; + if (ret == -NFS4ERR_DENIED) + ret = -EAGAIN; + } else + data->cancelled = 1; + rpc_release_task(task); + dprintk("%s: done, ret = %d!\n", __FUNCTION__, ret); + return ret; } static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index a7b5de8..5d6bda4 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1615,12 +1615,6 @@ static int nfs4_xdr_enc_lock(struct rpc_rqst *req, uint32_t *p, struct nfs_lock_ }; int status; - status = nfs_wait_on_sequence(args->lock_seqid, req->rq_task); - if (status != 0) - goto out; - /* Do we need to do an open_to_lock_owner? */ - if (args->lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED) - args->new_lock_owner = 0; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); status = encode_putfh(&xdr, args->fh); -- cgit v1.1 From fe650407a86823bcafbfbee96c7bc6a1b5cd1c76 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:18 +0100 Subject: NFSv4: Make DELEGRETURN an interruptible operation. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 718fcc7..f060e65 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2885,19 +2885,71 @@ nfs4_proc_setclientid_confirm(struct nfs4_client *clp) return status; } -static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid) +struct nfs4_delegreturndata { + struct nfs4_delegreturnargs args; + struct nfs_fh fh; + nfs4_stateid stateid; + struct rpc_cred *cred; + int rpc_status; +}; + +static void nfs4_delegreturn_prepare(struct rpc_task *task, void *calldata) { - struct nfs4_delegreturnargs args = { - .fhandle = NFS_FH(inode), - .stateid = stateid, - }; + struct nfs4_delegreturndata *data = calldata; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DELEGRETURN], - .rpc_argp = &args, - .rpc_cred = cred, + .rpc_argp = &data->args, + .rpc_cred = data->cred, }; + rpc_call_setup(task, &msg, 0); +} - return rpc_call_sync(NFS_CLIENT(inode), &msg, 0); +static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) +{ + struct nfs4_delegreturndata *data = calldata; + data->rpc_status = task->tk_status; +} + +static void nfs4_delegreturn_release(void *calldata) +{ + struct nfs4_delegreturndata *data = calldata; + + put_rpccred(data->cred); + kfree(calldata); +} + +const static struct rpc_call_ops nfs4_delegreturn_ops = { + .rpc_call_prepare = nfs4_delegreturn_prepare, + .rpc_call_done = nfs4_delegreturn_done, + .rpc_release = nfs4_delegreturn_release, +}; + +static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid) +{ + struct nfs4_delegreturndata *data; + struct rpc_task *task; + int status; + + data = kmalloc(sizeof(*data), GFP_KERNEL); + if (data == NULL) + return -ENOMEM; + data->args.fhandle = &data->fh; + data->args.stateid = &data->stateid; + nfs_copy_fh(&data->fh, NFS_FH(inode)); + memcpy(&data->stateid, stateid, sizeof(data->stateid)); + data->cred = get_rpccred(cred); + data->rpc_status = 0; + + task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data); + if (IS_ERR(task)) { + nfs4_delegreturn_release(data); + return PTR_ERR(task); + } + status = nfs4_wait_for_completion_rpc_task(task); + if (status == 0) + status = data->rpc_status; + rpc_release_task(task); + return status; } int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid) -- cgit v1.1 From 2bd615797ef32ec06ef0ee44198a7aecc21ffd8c Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:19 +0100 Subject: SUNRPC: Ensure that SIGKILL will always terminate a synchronous RPC call. ...and make sure that the "intr" flag also enables SIGHUP and SIGTERM to interrupt RPC calls too (as per the Solaris implementation). Signed-off-by: Trond Myklebust --- fs/lockd/svc.c | 4 ++-- net/sunrpc/clnt.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 12a857c..71a30b4 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -178,6 +178,8 @@ lockd(struct svc_rqst *rqstp) } + flush_signals(current); + /* * Check whether there's a new lockd process before * shutting down the hosts and clearing the slot. @@ -192,8 +194,6 @@ lockd(struct svc_rqst *rqstp) "lockd: new process, skipping host shutdown\n"); wake_up(&lockd_exit); - flush_signals(current); - /* Exit the RPC thread */ svc_exit_thread(rqstp); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index f025b7e..b23c0d3 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -386,11 +386,11 @@ static const struct rpc_call_ops rpc_default_ops = { * Export the signal mask handling for synchronous code that * sleeps on RPC calls */ -#define RPC_INTR_SIGNALS (sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGKILL)) +#define RPC_INTR_SIGNALS (sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTERM)) static void rpc_save_sigmask(sigset_t *oldset, int intr) { - unsigned long sigallow = 0; + unsigned long sigallow = sigmask(SIGKILL); sigset_t sigmask; /* Block all signals except those listed in sigallow */ -- cgit v1.1 From 26e976a884be9aa08f8ff906372f25f68df0d948 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:21 +0100 Subject: NFSv4: OPEN/LOCK/LOCKU/CLOSE will automatically renew the NFSv4 lease Cut down on the number of unnecessary RENEW requests on the wire. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index f060e65..76d7d02 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -174,8 +174,7 @@ static void nfs4_setup_readdir(u64 cookie, u32 *verifier, struct dentry *dentry, kunmap_atomic(start, KM_USER0); } -static void -renew_lease(struct nfs_server *server, unsigned long timestamp) +static void renew_lease(const struct nfs_server *server, unsigned long timestamp) { struct nfs4_client *clp = server->nfs4_state; spin_lock(&clp->cl_lock); @@ -207,6 +206,7 @@ struct nfs4_opendata { struct dentry *dir; struct nfs4_state_owner *owner; struct iattr attrs; + unsigned long timestamp; int rpc_status; int cancelled; }; @@ -548,6 +548,7 @@ static void nfs4_open_confirm_prepare(struct rpc_task *task, void *calldata) .rpc_resp = &data->c_res, .rpc_cred = data->owner->so_cred, }; + data->timestamp = jiffies; rpc_call_setup(task, &msg, 0); } @@ -558,9 +559,11 @@ static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata) data->rpc_status = task->tk_status; if (RPC_ASSASSINATED(task)) return; - if (data->rpc_status == 0) + if (data->rpc_status == 0) { memcpy(data->o_res.stateid.data, data->c_res.stateid.data, sizeof(data->o_res.stateid.data)); + renew_lease(data->o_res.server, data->timestamp); + } nfs_increment_open_seqid(data->rpc_status, data->c_arg.seqid); nfs_confirm_seqid(&data->owner->so_seqid, data->rpc_status); } @@ -633,6 +636,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata) data->o_arg.clientid = sp->so_client->cl_clientid; if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; + data->timestamp = jiffies; rpc_call_setup(task, &msg, 0); } @@ -656,6 +660,7 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata) default: data->rpc_status = -ENOTDIR; } + renew_lease(data->o_res.server, data->timestamp); } nfs_increment_open_seqid(data->rpc_status, data->o_arg.seqid); } @@ -1014,6 +1019,7 @@ static int _nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr, .rpc_argp = &arg, .rpc_resp = &res, }; + unsigned long timestamp = jiffies; int status; nfs_fattr_init(fattr); @@ -1025,6 +1031,8 @@ static int _nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr, memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid)); status = rpc_call_sync(server->client, &msg, 0); + if (status == 0 && state != NULL) + renew_lease(server, timestamp); return status; } @@ -1049,6 +1057,7 @@ struct nfs4_closedata { struct nfs_closeargs arg; struct nfs_closeres res; struct nfs_fattr fattr; + unsigned long timestamp; }; static void nfs4_free_closedata(void *data) @@ -1078,6 +1087,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data) case 0: memcpy(&state->stateid, &calldata->res.stateid, sizeof(state->stateid)); + renew_lease(server, calldata->timestamp); break; case -NFS4ERR_STALE_STATEID: case -NFS4ERR_EXPIRED: @@ -1130,6 +1140,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) if (mode != 0) msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; calldata->arg.open_flags = mode; + calldata->timestamp = jiffies; rpc_call_setup(task, &msg, 0); } @@ -1694,11 +1705,13 @@ static int _nfs4_proc_write(struct nfs_write_data *wdata) wdata->args.bitmask = server->attr_bitmask; wdata->res.server = server; + wdata->timestamp = jiffies; nfs_fattr_init(fattr); status = rpc_call_sync(server->client, &msg, rpcflags); dprintk("NFS reply write: %d\n", status); if (status < 0) return status; + renew_lease(server, wdata->timestamp); nfs_post_op_update_inode(inode, fattr); return wdata->res.count; } @@ -1733,8 +1746,11 @@ static int _nfs4_proc_commit(struct nfs_write_data *cdata) cdata->args.bitmask = server->attr_bitmask; cdata->res.server = server; + cdata->timestamp = jiffies; nfs_fattr_init(fattr); status = rpc_call_sync(server->client, &msg, 0); + if (status >= 0) + renew_lease(server, cdata->timestamp); dprintk("NFS reply commit: %d\n", status); if (status >= 0) nfs_post_op_update_inode(inode, fattr); @@ -2890,6 +2906,8 @@ struct nfs4_delegreturndata { struct nfs_fh fh; nfs4_stateid stateid; struct rpc_cred *cred; + unsigned long timestamp; + const struct nfs_server *server; int rpc_status; }; @@ -2908,6 +2926,8 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) { struct nfs4_delegreturndata *data = calldata; data->rpc_status = task->tk_status; + if (data->rpc_status == 0) + renew_lease(data->server, data->timestamp); } static void nfs4_delegreturn_release(void *calldata) @@ -2938,6 +2958,8 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co nfs_copy_fh(&data->fh, NFS_FH(inode)); memcpy(&data->stateid, stateid, sizeof(data->stateid)); data->cred = get_rpccred(cred); + data->timestamp = jiffies; + data->server = NFS_SERVER(inode); data->rpc_status = 0; task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data); @@ -3067,6 +3089,7 @@ struct nfs4_unlockdata { struct nfs_open_context *ctx; struct file_lock fl; const struct nfs_server *server; + unsigned long timestamp; }; static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl, @@ -3114,6 +3137,7 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) memcpy(calldata->lsp->ls_stateid.data, calldata->res.stateid.data, sizeof(calldata->lsp->ls_stateid.data)); + renew_lease(calldata->server, calldata->timestamp); break; case -NFS4ERR_STALE_STATEID: case -NFS4ERR_EXPIRED: @@ -3143,6 +3167,7 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data) task->tk_action = NULL; return; } + calldata->timestamp = jiffies; rpc_call_setup(task, &msg, 0); } @@ -3214,6 +3239,7 @@ struct nfs4_lockdata { struct nfs4_lock_state *lsp; struct nfs_open_context *ctx; struct file_lock fl; + unsigned long timestamp; int rpc_status; int cancelled; }; @@ -3273,6 +3299,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata) data->arg.open_stateid = &state->stateid; data->arg.new_lock_owner = 1; } + data->timestamp = jiffies; rpc_call_setup(task, &msg, 0); out: dprintk("%s: done!, ret = %d\n", __FUNCTION__, data->rpc_status); @@ -3298,6 +3325,7 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata) memcpy(data->lsp->ls_stateid.data, data->res.stateid.data, sizeof(data->lsp->ls_stateid.data)); data->lsp->ls_flags |= NFS_LOCK_INITIALIZED; + renew_lease(NFS_SERVER(data->ctx->dentry->d_inode), data->timestamp); } nfs_increment_lock_seqid(data->rpc_status, data->arg.lock_seqid); out: -- cgit v1.1 From 433fbe4c8837e3cc2ba6a6374edf28737d01a2e9 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:22 +0100 Subject: NFSv4: State recovery cleanup Use wait_on_bit() when waiting for state recovery to complete. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 3 +-- fs/nfs/nfs4proc.c | 27 ++++++++++++++------------- fs/nfs/nfs4state.c | 23 +++++++++++++---------- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 4ad5981..1d4c5b3 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -38,7 +38,7 @@ struct idmap; ((err) != NFSERR_NOFILEHANDLE)) enum nfs4_client_state { - NFS4CLNT_OK = 0, + NFS4CLNT_STATE_RECOVER = 0, }; /* @@ -76,7 +76,6 @@ struct nfs4_client { struct work_struct cl_renewd; struct work_struct cl_recoverd; - wait_queue_head_t cl_waitq; struct rpc_wait_queue cl_rpcwaitq; /* used for the setclientid verifier */ diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 76d7d02..46623ac 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2736,7 +2736,7 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server) case -NFS4ERR_EXPIRED: rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL, NULL); nfs4_schedule_state_recovery(clp); - if (test_bit(NFS4CLNT_OK, &clp->cl_state)) + if (test_bit(NFS4CLNT_STATE_RECOVER, &clp->cl_state) == 0) rpc_wake_up_task(task); task->tk_status = 0; return -EAGAIN; @@ -2753,25 +2753,25 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server) return 0; } +static int nfs4_wait_bit_interruptible(void *word) +{ + if (signal_pending(current)) + return -ERESTARTSYS; + schedule(); + return 0; +} + static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs4_client *clp) { - DEFINE_WAIT(wait); sigset_t oldset; - int interruptible, res = 0; + int res; might_sleep(); rpc_clnt_sigmask(clnt, &oldset); - interruptible = TASK_UNINTERRUPTIBLE; - if (clnt->cl_intr) - interruptible = TASK_INTERRUPTIBLE; - prepare_to_wait(&clp->cl_waitq, &wait, interruptible); - nfs4_schedule_state_recovery(clp); - if (clnt->cl_intr && signalled()) - res = -ERESTARTSYS; - else if (!test_bit(NFS4CLNT_OK, &clp->cl_state)) - schedule(); - finish_wait(&clp->cl_waitq, &wait); + res = wait_on_bit(&clp->cl_state, NFS4CLNT_STATE_RECOVER, + nfs4_wait_bit_interruptible, + TASK_INTERRUPTIBLE); rpc_clnt_sigunmask(clnt, &oldset); return res; } @@ -2814,6 +2814,7 @@ int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct case -NFS4ERR_STALE_CLIENTID: case -NFS4ERR_STALE_STATEID: case -NFS4ERR_EXPIRED: + nfs4_schedule_state_recovery(clp); ret = nfs4_wait_clnt_recover(server->client, clp); if (ret == 0) exception->retry = 1; diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 41a5f1a..4ebf4df 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -106,11 +106,10 @@ nfs4_alloc_client(struct in_addr *addr) INIT_WORK(&clp->cl_recoverd, nfs4_recover_state, clp); INIT_WORK(&clp->cl_renewd, nfs4_renew_state, clp); INIT_LIST_HEAD(&clp->cl_superblocks); - init_waitqueue_head(&clp->cl_waitq); rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS4 client"); clp->cl_rpcclient = ERR_PTR(-EINVAL); clp->cl_boot_time = CURRENT_TIME; - clp->cl_state = 1 << NFS4CLNT_OK; + clp->cl_state = 0; return clp; } @@ -193,7 +192,6 @@ nfs4_put_client(struct nfs4_client *clp) list_del(&clp->cl_servers); spin_unlock(&state_spinlock); BUG_ON(!list_empty(&clp->cl_superblocks)); - wake_up_all(&clp->cl_waitq); rpc_wake_up(&clp->cl_rpcwaitq); nfs4_kill_renewd(clp); nfs4_free_client(clp); @@ -741,6 +739,15 @@ struct reclaimer_args { struct completion complete; }; +static inline void nfs4_clear_recover_bit(struct nfs4_client *clp) +{ + smp_mb__before_clear_bit(); + clear_bit(NFS4CLNT_STATE_RECOVER, &clp->cl_state); + smp_mb__after_clear_bit(); + wake_up_bit(&clp->cl_state, NFS4CLNT_STATE_RECOVER); + rpc_wake_up(&clp->cl_rpcwaitq); +} + /* * State recovery routine */ @@ -760,9 +767,7 @@ nfs4_recover_state(void *data) wait_for_completion(&args.complete); return; out_failed_clear: - set_bit(NFS4CLNT_OK, &clp->cl_state); - wake_up_all(&clp->cl_waitq); - rpc_wake_up(&clp->cl_rpcwaitq); + nfs4_clear_recover_bit(clp); } /* @@ -773,7 +778,7 @@ nfs4_schedule_state_recovery(struct nfs4_client *clp) { if (!clp) return; - if (test_and_clear_bit(NFS4CLNT_OK, &clp->cl_state)) + if (test_and_set_bit(NFS4CLNT_STATE_RECOVER, &clp->cl_state) == 0) schedule_work(&clp->cl_recoverd); } @@ -943,13 +948,11 @@ restart_loop: } nfs_delegation_reap_unclaimed(clp); out: - set_bit(NFS4CLNT_OK, &clp->cl_state); up_write(&clp->cl_sem); unlock_kernel(); - wake_up_all(&clp->cl_waitq); - rpc_wake_up(&clp->cl_rpcwaitq); if (status == -NFS4ERR_CB_PATH_DOWN) nfs_handle_cb_pathdown(clp); + nfs4_clear_recover_bit(clp); nfs4_put_client(clp); return 0; out_error: -- cgit v1.1 From 5043e900f5404c01864fbeb5826aa7de3981bbc1 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:23 +0100 Subject: NFS: Convert instances of kernel_thread() to kthread() Convert private implementations in NFSv4 state recovery and delegation code to use kthreads. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4state.c | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 4ebf4df..f214837 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -57,8 +59,6 @@ const nfs4_stateid zero_stateid; static DEFINE_SPINLOCK(state_spinlock); static LIST_HEAD(nfs4_clientid_list); -static void nfs4_recover_state(void *); - void init_nfsv4_state(struct nfs_server *server) { @@ -103,7 +103,6 @@ nfs4_alloc_client(struct in_addr *addr) INIT_LIST_HEAD(&clp->cl_unused); spin_lock_init(&clp->cl_lock); atomic_set(&clp->cl_count, 1); - INIT_WORK(&clp->cl_recoverd, nfs4_recover_state, clp); INIT_WORK(&clp->cl_renewd, nfs4_renew_state, clp); INIT_LIST_HEAD(&clp->cl_superblocks); rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS4 client"); @@ -734,10 +733,6 @@ out: } static int reclaimer(void *); -struct reclaimer_args { - struct nfs4_client *clp; - struct completion complete; -}; static inline void nfs4_clear_recover_bit(struct nfs4_client *clp) { @@ -751,35 +746,30 @@ static inline void nfs4_clear_recover_bit(struct nfs4_client *clp) /* * State recovery routine */ -void -nfs4_recover_state(void *data) +static void nfs4_recover_state(struct nfs4_client *clp) { - struct nfs4_client *clp = (struct nfs4_client *)data; - struct reclaimer_args args = { - .clp = clp, - }; - might_sleep(); - - init_completion(&args.complete); + struct task_struct *task; - if (kernel_thread(reclaimer, &args, CLONE_KERNEL) < 0) - goto out_failed_clear; - wait_for_completion(&args.complete); - return; -out_failed_clear: + __module_get(THIS_MODULE); + atomic_inc(&clp->cl_count); + task = kthread_run(reclaimer, clp, "%u.%u.%u.%u-reclaim", + NIPQUAD(clp->cl_addr)); + if (!IS_ERR(task)) + return; nfs4_clear_recover_bit(clp); + nfs4_put_client(clp); + module_put(THIS_MODULE); } /* * Schedule a state recovery attempt */ -void -nfs4_schedule_state_recovery(struct nfs4_client *clp) +void nfs4_schedule_state_recovery(struct nfs4_client *clp) { if (!clp) return; if (test_and_set_bit(NFS4CLNT_STATE_RECOVER, &clp->cl_state) == 0) - schedule_work(&clp->cl_recoverd); + nfs4_recover_state(clp); } static int nfs4_reclaim_locks(struct nfs4_state_recovery_ops *ops, struct nfs4_state *state) @@ -895,18 +885,13 @@ static void nfs4_state_mark_reclaim(struct nfs4_client *clp) static int reclaimer(void *ptr) { - struct reclaimer_args *args = (struct reclaimer_args *)ptr; - struct nfs4_client *clp = args->clp; + struct nfs4_client *clp = ptr; struct nfs4_state_owner *sp; struct nfs4_state_recovery_ops *ops; int status = 0; - daemonize("%u.%u.%u.%u-reclaim", NIPQUAD(clp->cl_addr)); allow_signal(SIGKILL); - atomic_inc(&clp->cl_count); - complete(&args->complete); - /* Ensure exclusive access to NFSv4 state */ lock_kernel(); down_write(&clp->cl_sem); @@ -954,6 +939,7 @@ out: nfs_handle_cb_pathdown(clp); nfs4_clear_recover_bit(clp); nfs4_put_client(clp); + module_put_and_exit(0); return 0; out_error: printk(KERN_WARNING "Error: state recovery failed on NFSv4 server %u.%u.%u.%u with error %d\n", -- cgit v1.1 From 58d9714a44a79bba9b414da3ffbf3c753dc5915f Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:24 +0100 Subject: NFSv4: Send RENEW requests to the server only when we're holding state Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/delegation.h | 1 + fs/nfs/nfs4_fs.h | 1 + fs/nfs/nfs4proc.c | 20 +++++++++++++++++++- fs/nfs/nfs4renewd.c | 9 ++++++++- 5 files changed, 75 insertions(+), 2 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 618a327..75dfb1c 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -8,6 +8,7 @@ */ #include #include +#include #include #include #include @@ -231,6 +232,51 @@ restart: spin_unlock(&clp->cl_lock); } +int nfs_do_expire_all_delegations(void *ptr) +{ + struct nfs4_client *clp = ptr; + struct nfs_delegation *delegation; + struct inode *inode; + int err = 0; + + allow_signal(SIGKILL); +restart: + spin_lock(&clp->cl_lock); + if (test_bit(NFS4CLNT_STATE_RECOVER, &clp->cl_state) != 0) + goto out; + if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) == 0) + goto out; + list_for_each_entry(delegation, &clp->cl_delegations, super_list) { + inode = igrab(delegation->inode); + if (inode == NULL) + continue; + spin_unlock(&clp->cl_lock); + err = nfs_inode_return_delegation(inode); + iput(inode); + if (!err) + goto restart; + } +out: + spin_unlock(&clp->cl_lock); + nfs4_put_client(clp); + module_put_and_exit(0); +} + +void nfs_expire_all_delegations(struct nfs4_client *clp) +{ + struct task_struct *task; + + __module_get(THIS_MODULE); + atomic_inc(&clp->cl_count); + task = kthread_run(nfs_do_expire_all_delegations, clp, + "%u.%u.%u.%u-delegreturn", + NIPQUAD(clp->cl_addr)); + if (!IS_ERR(task)) + return; + nfs4_put_client(clp); + module_put(THIS_MODULE); +} + /* * Return all delegations following an NFS4ERR_CB_PATH_DOWN error. */ diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 2fcc30d..fbc50ec 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -30,6 +30,7 @@ int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *s struct inode *nfs_delegation_find_inode(struct nfs4_client *clp, const struct nfs_fh *fhandle); void nfs_return_all_delegations(struct super_block *sb); +void nfs_expire_all_delegations(struct nfs4_client *clp); void nfs_handle_cb_pathdown(struct nfs4_client *clp); void nfs_delegation_mark_reclaim(struct nfs4_client *clp); diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 1d4c5b3..75fe646 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -39,6 +39,7 @@ struct idmap; enum nfs4_client_state { NFS4CLNT_STATE_RECOVER = 0, + NFS4CLNT_LEASE_EXPIRED, }; /* diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 46623ac..cc33a1c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -63,6 +63,7 @@ static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinf static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *); static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry); static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception); +static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs4_client *clp); extern u32 *nfs4_decode_dirent(u32 *p, struct nfs_entry *entry, int plus); extern struct rpc_procinfo nfs4_procedures[]; @@ -765,6 +766,15 @@ out: return -EACCES; } +int nfs4_recover_expired_lease(struct nfs_server *server) +{ + struct nfs4_client *clp = server->nfs4_state; + + if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) + nfs4_schedule_state_recovery(clp); + return nfs4_wait_clnt_recover(server->client, clp); +} + /* * OPEN_EXPIRED: * reclaim state on the server after a network partition. @@ -840,6 +850,9 @@ static int _nfs4_open_delegated(struct inode *inode, int flags, struct rpc_cred int open_flags = flags & (FMODE_READ|FMODE_WRITE); int err; + err = nfs4_recover_expired_lease(server); + if (err != 0) + return err; /* Protect against reboot recovery - NOTE ORDER! */ down_read(&clp->cl_sem); /* Protect against delegation recall */ @@ -921,12 +934,16 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st int status; /* Protect against reboot recovery conflicts */ - down_read(&clp->cl_sem); status = -ENOMEM; if (!(sp = nfs4_get_state_owner(server, cred))) { dprintk("nfs4_do_open: nfs4_get_state_owner failed!\n"); goto out_err; } + status = nfs4_recover_expired_lease(server); + if (status != 0) + goto out_err; + down_read(&clp->cl_sem); + status = -ENOMEM; opendata = nfs4_opendata_alloc(dentry, sp, flags, sattr); if (opendata == NULL) goto err_put_state_owner; @@ -2897,6 +2914,7 @@ nfs4_proc_setclientid_confirm(struct nfs4_client *clp) spin_lock(&clp->cl_lock); clp->cl_lease_time = fsinfo.lease_time * HZ; clp->cl_last_renewal = now; + clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); spin_unlock(&clp->cl_lock); } return status; diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c index a300162..f62c2f7 100644 --- a/fs/nfs/nfs4renewd.c +++ b/fs/nfs/nfs4renewd.c @@ -54,6 +54,7 @@ #include #include #include "nfs4_fs.h" +#include "delegation.h" #define NFSDBG_FACILITY NFSDBG_PROC @@ -68,7 +69,7 @@ nfs4_renew_state(void *data) dprintk("%s: start\n", __FUNCTION__); /* Are there any active superblocks? */ if (list_empty(&clp->cl_superblocks)) - goto out; + goto out; spin_lock(&clp->cl_lock); lease = clp->cl_lease_time; last = clp->cl_last_renewal; @@ -76,6 +77,12 @@ nfs4_renew_state(void *data) timeout = (2 * lease) / 3 + (long)last - (long)now; /* Are we close to a lease timeout? */ if (time_after(now, last + lease/3)) { + if (list_empty(&clp->cl_state_owners)) { + set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); + spin_unlock(&clp->cl_lock); + nfs_expire_all_delegations(clp); + goto out; + } spin_unlock(&clp->cl_lock); /* Queue an asynchronous RENEW. */ nfs4_proc_async_renew(clp); -- cgit v1.1 From b4454fe1a7cb76a248d0641c9d68a44a1b8d9a1f Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:25 +0100 Subject: NFSv4: Remove requirement for machine creds for the "renew" operation In RFC3530, the RENEW operation is allowed to use either the same principal, RPC security flavour and (if RPCSEC_GSS), the same mechanism and service that was used for SETCLIENTID_CONFIRM OR Any principal, RPC security flavour and service combination that currently has an OPEN file on the server. Choose the latter since that doesn't require us to keep credentials for the same principal for the entire duration of the mount. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 5 +++-- fs/nfs/nfs4proc.c | 38 ++++++++++++++++++-------------------- fs/nfs/nfs4renewd.c | 7 +++++-- fs/nfs/nfs4state.c | 16 +++++++++++++++- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 75fe646..4a9c53e 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -213,8 +213,8 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); extern int nfs4_map_errors(int err); extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short); extern int nfs4_proc_setclientid_confirm(struct nfs4_client *); -extern int nfs4_proc_async_renew(struct nfs4_client *); -extern int nfs4_proc_renew(struct nfs4_client *); +extern int nfs4_proc_async_renew(struct nfs4_client *, struct rpc_cred *); +extern int nfs4_proc_renew(struct nfs4_client *, struct rpc_cred *); extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); @@ -240,6 +240,7 @@ extern struct nfs4_client *nfs4_get_client(struct in_addr *); extern void nfs4_put_client(struct nfs4_client *clp); extern int nfs4_init_client(struct nfs4_client *clp); extern struct nfs4_client *nfs4_find_client(struct in_addr *); +struct rpc_cred *nfs4_get_renew_cred(struct nfs4_client *clp); extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *); extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index cc33a1c..e384019 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -850,9 +850,14 @@ static int _nfs4_open_delegated(struct inode *inode, int flags, struct rpc_cred int open_flags = flags & (FMODE_READ|FMODE_WRITE); int err; + err = -ENOMEM; + if (!(sp = nfs4_get_state_owner(server, cred))) { + dprintk("%s: nfs4_get_state_owner failed!\n", __FUNCTION__); + return err; + } err = nfs4_recover_expired_lease(server); if (err != 0) - return err; + goto out_put_state_owner; /* Protect against reboot recovery - NOTE ORDER! */ down_read(&clp->cl_sem); /* Protect against delegation recall */ @@ -862,10 +867,6 @@ static int _nfs4_open_delegated(struct inode *inode, int flags, struct rpc_cred if (delegation == NULL || (delegation->type & open_flags) != open_flags) goto out_err; err = -ENOMEM; - if (!(sp = nfs4_get_state_owner(server, cred))) { - dprintk("%s: nfs4_get_state_owner failed!\n", __FUNCTION__); - goto out_err; - } state = nfs4_get_open_state(inode, sp); if (state == NULL) goto out_err; @@ -877,13 +878,13 @@ static int _nfs4_open_delegated(struct inode *inode, int flags, struct rpc_cred spin_unlock(&inode->i_lock); goto out_ok; } else if (state->state != 0) - goto out_err; + goto out_put_open_state; lock_kernel(); err = _nfs4_do_access(inode, cred, open_flags); unlock_kernel(); if (err != 0) - goto out_err; + goto out_put_open_state; set_bit(NFS_DELEGATED_STATE, &state->flags); update_open_stateid(state, &delegation->stateid, open_flags); out_ok: @@ -891,17 +892,16 @@ out_ok: up_read(&nfsi->rwsem); up_read(&clp->cl_sem); *res = state; - return 0; + return 0; +out_put_open_state: + nfs4_put_open_state(state); out_err: - if (sp != NULL) { - if (state != NULL) - nfs4_put_open_state(state); - nfs4_put_state_owner(sp); - } up_read(&nfsi->rwsem); up_read(&clp->cl_sem); if (err != -EACCES) nfs_inode_return_delegation(inode); +out_put_state_owner: + nfs4_put_state_owner(sp); return err; } @@ -941,7 +941,7 @@ static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, int flags, st } status = nfs4_recover_expired_lease(server); if (status != 0) - goto out_err; + goto err_put_state_owner; down_read(&clp->cl_sem); status = -ENOMEM; opendata = nfs4_opendata_alloc(dentry, sp, flags, sattr); @@ -2518,26 +2518,24 @@ static const struct rpc_call_ops nfs4_renew_ops = { .rpc_call_done = nfs4_renew_done, }; -int -nfs4_proc_async_renew(struct nfs4_client *clp) +int nfs4_proc_async_renew(struct nfs4_client *clp, struct rpc_cred *cred) { struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], .rpc_argp = clp, - .rpc_cred = clp->cl_cred, + .rpc_cred = cred, }; return rpc_call_async(clp->cl_rpcclient, &msg, RPC_TASK_SOFT, &nfs4_renew_ops, (void *)jiffies); } -int -nfs4_proc_renew(struct nfs4_client *clp) +int nfs4_proc_renew(struct nfs4_client *clp, struct rpc_cred *cred) { struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENEW], .rpc_argp = clp, - .rpc_cred = clp->cl_cred, + .rpc_cred = cred, }; unsigned long now = jiffies; int status; diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c index f62c2f7..5d764d8 100644 --- a/fs/nfs/nfs4renewd.c +++ b/fs/nfs/nfs4renewd.c @@ -62,6 +62,7 @@ void nfs4_renew_state(void *data) { struct nfs4_client *clp = (struct nfs4_client *)data; + struct rpc_cred *cred; long lease, timeout; unsigned long last, now; @@ -77,7 +78,8 @@ nfs4_renew_state(void *data) timeout = (2 * lease) / 3 + (long)last - (long)now; /* Are we close to a lease timeout? */ if (time_after(now, last + lease/3)) { - if (list_empty(&clp->cl_state_owners)) { + cred = nfs4_get_renew_cred(clp); + if (cred == NULL) { set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); spin_unlock(&clp->cl_lock); nfs_expire_all_delegations(clp); @@ -85,7 +87,8 @@ nfs4_renew_state(void *data) } spin_unlock(&clp->cl_lock); /* Queue an asynchronous RENEW. */ - nfs4_proc_async_renew(clp); + nfs4_proc_async_renew(clp, cred); + put_rpccred(cred); timeout = (2 * lease) / 3; spin_lock(&clp->cl_lock); } else diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index f214837..18f6ed1 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -232,6 +232,20 @@ nfs4_client_grab_unused(struct nfs4_client *clp, struct rpc_cred *cred) return sp; } +struct rpc_cred *nfs4_get_renew_cred(struct nfs4_client *clp) +{ + struct nfs4_state_owner *sp; + struct rpc_cred *cred = NULL; + + list_for_each_entry(sp, &clp->cl_state_owners, so_list) { + if (list_empty(&sp->so_states)) + continue; + cred = get_rpccred(sp->so_cred); + break; + } + return cred; +} + static struct nfs4_state_owner * nfs4_find_state_owner(struct nfs4_client *clp, struct rpc_cred *cred) { @@ -899,7 +913,7 @@ static int reclaimer(void *ptr) if (list_empty(&clp->cl_superblocks)) goto out; restart_loop: - status = nfs4_proc_renew(clp); + status = nfs4_proc_renew(clp, clp->cl_cred); switch (status) { case 0: case -NFS4ERR_CB_PATH_DOWN: -- cgit v1.1 From 286d7d6a0cb38d3d4316a1dfea9b0c0fc5a6455b Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:26 +0100 Subject: NFSv4: Remove requirement for machine creds for the "setclientid" operation Use a cred from the nfs4_client->cl_state_owners list. Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 14 ----------- fs/nfs/nfs4_fs.h | 6 ++--- fs/nfs/nfs4proc.c | 10 ++++---- fs/nfs/nfs4state.c | 71 ++++++++++++++++++++++++++++++++++-------------------- 4 files changed, 52 insertions(+), 49 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 432f41c..740d3cd 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1822,23 +1822,9 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, clnt->cl_softrtry = 1; clnt->cl_chatty = 1; clp->cl_rpcclient = clnt; - clp->cl_cred = rpcauth_lookupcred(clnt->cl_auth, 0); - if (IS_ERR(clp->cl_cred)) { - up_write(&clp->cl_sem); - err = PTR_ERR(clp->cl_cred); - clp->cl_cred = NULL; - goto out_fail; - } memcpy(clp->cl_ipaddr, server->ip_addr, sizeof(clp->cl_ipaddr)); nfs_idmap_new(clp); } - if (list_empty(&clp->cl_superblocks)) { - err = nfs4_init_client(clp); - if (err != 0) { - up_write(&clp->cl_sem); - goto out_fail; - } - } list_add_tail(&server->nfs4_siblings, &clp->cl_superblocks); clnt = rpc_clone_client(clp->cl_rpcclient); if (!IS_ERR(clnt)) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 4a9c53e..0f5e4e7 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -68,7 +68,6 @@ struct nfs4_client { atomic_t cl_count; struct rpc_clnt * cl_rpcclient; - struct rpc_cred * cl_cred; struct list_head cl_superblocks; /* List of nfs_server structs */ @@ -211,8 +210,8 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); /* nfs4proc.c */ extern int nfs4_map_errors(int err); -extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short); -extern int nfs4_proc_setclientid_confirm(struct nfs4_client *); +extern int nfs4_proc_setclientid(struct nfs4_client *, u32, unsigned short, struct rpc_cred *); +extern int nfs4_proc_setclientid_confirm(struct nfs4_client *, struct rpc_cred *); extern int nfs4_proc_async_renew(struct nfs4_client *, struct rpc_cred *); extern int nfs4_proc_renew(struct nfs4_client *, struct rpc_cred *); extern int nfs4_do_close(struct inode *inode, struct nfs4_state *state); @@ -238,7 +237,6 @@ extern void init_nfsv4_state(struct nfs_server *); extern void destroy_nfsv4_state(struct nfs_server *); extern struct nfs4_client *nfs4_get_client(struct in_addr *); extern void nfs4_put_client(struct nfs4_client *clp); -extern int nfs4_init_client(struct nfs4_client *clp); extern struct nfs4_client *nfs4_find_client(struct in_addr *); struct rpc_cred *nfs4_get_renew_cred(struct nfs4_client *clp); extern u32 nfs4_alloc_lockowner_id(struct nfs4_client *); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index e384019..b334915 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2846,7 +2846,7 @@ int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct return nfs4_map_errors(ret); } -int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short port) +int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short port, struct rpc_cred *cred) { nfs4_verifier sc_verifier; struct nfs4_setclientid setclientid = { @@ -2857,7 +2857,7 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID], .rpc_argp = &setclientid, .rpc_resp = clp, - .rpc_cred = clp->cl_cred, + .rpc_cred = cred, }; u32 *p; int loop = 0; @@ -2871,7 +2871,7 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p setclientid.sc_name_len = scnprintf(setclientid.sc_name, sizeof(setclientid.sc_name), "%s/%u.%u.%u.%u %s %u", clp->cl_ipaddr, NIPQUAD(clp->cl_addr.s_addr), - clp->cl_cred->cr_ops->cr_name, + cred->cr_ops->cr_name, clp->cl_id_uniquifier); setclientid.sc_netid_len = scnprintf(setclientid.sc_netid, sizeof(setclientid.sc_netid), "tcp"); @@ -2894,14 +2894,14 @@ int nfs4_proc_setclientid(struct nfs4_client *clp, u32 program, unsigned short p } int -nfs4_proc_setclientid_confirm(struct nfs4_client *clp) +nfs4_proc_setclientid_confirm(struct nfs4_client *clp, struct rpc_cred *cred) { struct nfs_fsinfo fsinfo; struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETCLIENTID_CONFIRM], .rpc_argp = clp, .rpc_resp = &fsinfo, - .rpc_cred = clp->cl_cred, + .rpc_cred = cred, }; unsigned long now; int status; diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 18f6ed1..afad025 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -91,11 +91,10 @@ nfs4_alloc_client(struct in_addr *addr) if (nfs_callback_up() < 0) return NULL; - if ((clp = kmalloc(sizeof(*clp), GFP_KERNEL)) == NULL) { + if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL) { nfs_callback_down(); return NULL; } - memset(clp, 0, sizeof(*clp)); memcpy(&clp->cl_addr, addr, sizeof(clp->cl_addr)); init_rwsem(&clp->cl_sem); INIT_LIST_HEAD(&clp->cl_delegations); @@ -108,7 +107,7 @@ nfs4_alloc_client(struct in_addr *addr) rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS4 client"); clp->cl_rpcclient = ERR_PTR(-EINVAL); clp->cl_boot_time = CURRENT_TIME; - clp->cl_state = 0; + clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED; return clp; } @@ -125,8 +124,6 @@ nfs4_free_client(struct nfs4_client *clp) kfree(sp); } BUG_ON(!list_empty(&clp->cl_state_owners)); - if (clp->cl_cred) - put_rpccred(clp->cl_cred); nfs_idmap_delete(clp); if (!IS_ERR(clp->cl_rpcclient)) rpc_shutdown_client(clp->cl_rpcclient); @@ -196,21 +193,17 @@ nfs4_put_client(struct nfs4_client *clp) nfs4_free_client(clp); } -static int __nfs4_init_client(struct nfs4_client *clp) +static int nfs4_init_client(struct nfs4_client *clp, struct rpc_cred *cred) { - int status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, nfs_callback_tcpport); + int status = nfs4_proc_setclientid(clp, NFS4_CALLBACK, + nfs_callback_tcpport, cred); if (status == 0) - status = nfs4_proc_setclientid_confirm(clp); + status = nfs4_proc_setclientid_confirm(clp, cred); if (status == 0) nfs4_schedule_state_renewal(clp); return status; } -int nfs4_init_client(struct nfs4_client *clp) -{ - return nfs4_map_errors(__nfs4_init_client(clp)); -} - u32 nfs4_alloc_lockowner_id(struct nfs4_client *clp) { @@ -246,6 +239,18 @@ struct rpc_cred *nfs4_get_renew_cred(struct nfs4_client *clp) return cred; } +struct rpc_cred *nfs4_get_setclientid_cred(struct nfs4_client *clp) +{ + struct nfs4_state_owner *sp; + + if (!list_empty(&clp->cl_state_owners)) { + sp = list_entry(clp->cl_state_owners.next, + struct nfs4_state_owner, so_list); + return get_rpccred(sp->so_cred); + } + return NULL; +} + static struct nfs4_state_owner * nfs4_find_state_owner(struct nfs4_client *clp, struct rpc_cred *cred) { @@ -902,6 +907,7 @@ static int reclaimer(void *ptr) struct nfs4_client *clp = ptr; struct nfs4_state_owner *sp; struct nfs4_state_recovery_ops *ops; + struct rpc_cred *cred; int status = 0; allow_signal(SIGKILL); @@ -913,20 +919,33 @@ static int reclaimer(void *ptr) if (list_empty(&clp->cl_superblocks)) goto out; restart_loop: - status = nfs4_proc_renew(clp, clp->cl_cred); - switch (status) { - case 0: - case -NFS4ERR_CB_PATH_DOWN: - goto out; - case -NFS4ERR_STALE_CLIENTID: - case -NFS4ERR_LEASE_MOVED: - ops = &nfs4_reboot_recovery_ops; - break; - default: - ops = &nfs4_network_partition_recovery_ops; - }; + ops = &nfs4_network_partition_recovery_ops; + /* Are there any open files on this volume? */ + cred = nfs4_get_renew_cred(clp); + if (cred != NULL) { + /* Yes there are: try to renew the old lease */ + status = nfs4_proc_renew(clp, cred); + switch (status) { + case 0: + case -NFS4ERR_CB_PATH_DOWN: + put_rpccred(cred); + goto out; + case -NFS4ERR_STALE_CLIENTID: + case -NFS4ERR_LEASE_MOVED: + ops = &nfs4_reboot_recovery_ops; + } + } else { + /* "reboot" to ensure we clear all state on the server */ + clp->cl_boot_time = CURRENT_TIME; + cred = nfs4_get_setclientid_cred(clp); + } + /* We're going to have to re-establish a clientid */ nfs4_state_mark_reclaim(clp); - status = __nfs4_init_client(clp); + status = -ENOENT; + if (cred != NULL) { + status = nfs4_init_client(clp, cred); + put_rpccred(cred); + } if (status) goto out_error; /* Mark all delegations for reclaim */ -- cgit v1.1 From ce1a8e6796150233f5098100f70217521dc7c08f Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 30 Nov 2005 18:08:17 -0500 Subject: NFS: use generic_write_checks() to sanity check direct writes Replace ad hoc write parameter sanity checking in nfs_file_direct_write() with a call to generic_write_checks(). This should make the proper checks modulo the O_LARGEFILE flag, and should catch NFSv2-specific limitations by virtue of i_sb->s_maxbytes. Test plan: Posix compliance testing with both NFSv2 and NFSv3. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/nfs/direct.c | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index ae2be07..f69d95a 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -660,10 +660,10 @@ nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t .iov_len = count, }; - dprintk("nfs: direct read(%s/%s, %lu@%lu)\n", + dprintk("nfs: direct read(%s/%s, %lu@%Ld)\n", file->f_dentry->d_parent->d_name.name, file->f_dentry->d_name.name, - (unsigned long) count, (unsigned long) pos); + (unsigned long) count, (long long) pos); if (!is_sync_kiocb(iocb)) goto out; @@ -716,9 +716,7 @@ out: ssize_t nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos) { - ssize_t retval = -EINVAL; - loff_t *ppos = &iocb->ki_pos; - unsigned long limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; + ssize_t retval; struct file *file = iocb->ki_filp; struct nfs_open_context *ctx = (struct nfs_open_context *) file->private_data; @@ -726,35 +724,32 @@ nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, struct inode *inode = mapping->host; struct iovec iov = { .iov_base = (char __user *)buf, - .iov_len = count, }; - dfprintk(VFS, "nfs: direct write(%s/%s(%ld), %lu@%lu)\n", + dfprintk(VFS, "nfs: direct write(%s/%s, %lu@%Ld)\n", file->f_dentry->d_parent->d_name.name, - file->f_dentry->d_name.name, inode->i_ino, - (unsigned long) count, (unsigned long) pos); + file->f_dentry->d_name.name, + (unsigned long) count, (long long) pos); + retval = -EINVAL; if (!is_sync_kiocb(iocb)) goto out; - if (count < 0) - goto out; - if (pos < 0) + + retval = generic_write_checks(file, &pos, &count, 0); + if (retval) goto out; - retval = -EFAULT; - if (!access_ok(VERIFY_READ, iov.iov_base, iov.iov_len)) + + retval = -EINVAL; + if ((ssize_t) count < 0) goto out; - retval = -EFBIG; - if (limit != RLIM_INFINITY) { - if (pos >= limit) { - send_sig(SIGXFSZ, current, 0); - goto out; - } - if (count > limit - (unsigned long) pos) - count = limit - (unsigned long) pos; - } retval = 0; if (!count) goto out; + iov.iov_len = count, + + retval = -EFAULT; + if (!access_ok(VERIFY_READ, iov.iov_base, iov.iov_len)) + goto out; retval = nfs_sync_mapping(mapping); if (retval) @@ -764,7 +759,7 @@ nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, if (mapping->nrpages) invalidate_inode_pages2(mapping); if (retval > 0) - *ppos = pos + retval; + iocb->ki_pos = pos + retval; out: return retval; -- cgit v1.1 From 6b59a75460eb9527145d7bd55068e5d32bee8a44 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 30 Nov 2005 18:08:19 -0500 Subject: NFS: Fix error recovery code in fs/nfs/inode.c:__init_nfs() Red Hat found a problem in the error recovery logic in __init_nfs. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 740d3cd..da58207 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -2152,11 +2152,11 @@ out: #ifdef CONFIG_PROC_FS rpc_proc_unregister("nfs"); #endif - nfs_destroy_writepagecache(); #ifdef CONFIG_NFS_DIRECTIO -out0: nfs_destroy_directcache(); +out0: #endif + nfs_destroy_writepagecache(); out1: nfs_destroy_readpagecache(); out2: -- cgit v1.1 From a911fd9a6046200e439b4af172e8379c0942eec3 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 30 Nov 2005 18:08:59 -0500 Subject: NFS: simplify inlined bit ops in nfs_page.h Minor cleanup: inlined bit ops in nfs_page.h can be simpler. Test plan: Write-intensive workload against a server that requires COMMITs. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- include/linux/nfs_page.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h index da2e077b..66e2ed6 100644 --- a/include/linux/nfs_page.h +++ b/include/linux/nfs_page.h @@ -79,9 +79,7 @@ extern void nfs_clear_page_writeback(struct nfs_page *req); static inline int nfs_lock_request_dontget(struct nfs_page *req) { - if (test_and_set_bit(PG_BUSY, &req->wb_flags)) - return 0; - return 1; + return !test_and_set_bit(PG_BUSY, &req->wb_flags); } /* @@ -125,9 +123,7 @@ nfs_list_remove_request(struct nfs_page *req) static inline int nfs_defer_commit(struct nfs_page *req) { - if (test_and_set_bit(PG_NEED_COMMIT, &req->wb_flags)) - return 0; - return 1; + return !test_and_set_bit(PG_NEED_COMMIT, &req->wb_flags); } static inline void @@ -141,9 +137,7 @@ nfs_clear_commit(struct nfs_page *req) static inline int nfs_defer_reschedule(struct nfs_page *req) { - if (test_and_set_bit(PG_NEED_RESCHED, &req->wb_flags)) - return 0; - return 1; + return !test_and_set_bit(PG_NEED_RESCHED, &req->wb_flags); } static inline void -- cgit v1.1 From dc20f803904dbf30f834dcc43c14701dfce32491 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 30 Nov 2005 18:08:57 -0500 Subject: NFS: get rid of useless kernel log message nfs_statfs() generates a log message when GETATTR returns an error. This is usually a useless message. Make it a dprintk. Test plan: None Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index da58207..cc75392 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -575,11 +575,10 @@ nfs_statfs(struct super_block *sb, struct kstatfs *buf) buf->f_namelen = server->namelen; out: unlock_kernel(); - return 0; out_err: - printk(KERN_WARNING "nfs_statfs: statfs error = %d\n", -error); + dprintk("%s: statfs error = %d\n", __FUNCTION__, -error); buf->f_bsize = buf->f_blocks = buf->f_bfree = buf->f_bavail = -1; goto out; -- cgit v1.1 From 325cfed9ae901320e9234b18c21434b783dbe342 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 30 Nov 2005 18:08:55 -0500 Subject: NFS: make "inode number mismatch" message more useful To help NFS users and server developers, make the "inode number mismatch" message display more useful information. Test-plan: None. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index cc75392..4e6558d 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1409,14 +1409,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) if ((fattr->valid & NFS_ATTR_FATTR) == 0) return 0; - if (nfsi->fileid != fattr->fileid) { - printk(KERN_ERR "%s: inode number mismatch\n" - "expected (%s/0x%Lx), got (%s/0x%Lx)\n", - __FUNCTION__, - inode->i_sb->s_id, (long long)nfsi->fileid, - inode->i_sb->s_id, (long long)fattr->fileid); - goto out_err; - } + if (nfsi->fileid != fattr->fileid) + goto out_fileid; /* * Make sure the inode's type hasn't changed. @@ -1538,6 +1532,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) */ nfs_invalidate_inode(inode); return -ESTALE; + + out_fileid: + printk(KERN_ERR "NFS: server %s error: fileid changed\n" + "fsid %s: expected fileid 0x%Lx, got 0x%Lx\n", + NFS_SERVER(inode)->hostname, inode->i_sb->s_id, + (long long)nfsi->fileid, (long long)fattr->fileid); + goto out_err; } /* -- cgit v1.1 From 40859d7ee64ed6bfad8a4e93f9bb5c1074afadff Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Wed, 30 Nov 2005 18:09:02 -0500 Subject: NFS: support large reads and writes on the wire Most NFS server implementations allow up to 64KB reads and writes on the wire. The Solaris NFS server allows up to a megabyte, for instance. Now the Linux NFS client supports transfer sizes up to 1MB, too. This will help reduce protocol and context switch overhead on read/write intensive NFS workloads, and support larger atomic read and write operations on servers that support them. Test-plan: Connectathon and iozone on mount point with wsize=rsize>32768 over TCP. Tests with NFS over UDP to verify the maximum RPC payload size cap. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/nfs/direct.c | 5 +++-- fs/nfs/inode.c | 25 ++++++++++--------------- fs/nfs/nfsroot.c | 4 ++-- fs/nfs/read.c | 6 +++--- fs/nfs/write.c | 29 ++++++++++++++++++++++------- include/linux/nfs_fs.h | 41 +++++++++++++++++++++++++++++++++++------ include/linux/nfs_xdr.h | 29 ++++++++++++++++------------- include/linux/sunrpc/xdr.h | 5 ----- 8 files changed, 91 insertions(+), 53 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index f69d95a..fd7ac5e 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -154,6 +154,7 @@ static struct nfs_direct_req *nfs_direct_read_alloc(size_t nbytes, unsigned int struct list_head *list; struct nfs_direct_req *dreq; unsigned int reads = 0; + unsigned int rpages = (rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; dreq = kmem_cache_alloc(nfs_direct_cachep, SLAB_KERNEL); if (!dreq) @@ -167,7 +168,7 @@ static struct nfs_direct_req *nfs_direct_read_alloc(size_t nbytes, unsigned int list = &dreq->list; for(;;) { - struct nfs_read_data *data = nfs_readdata_alloc(); + struct nfs_read_data *data = nfs_readdata_alloc(rpages); if (unlikely(!data)) { while (!list_empty(list)) { @@ -431,7 +432,7 @@ static ssize_t nfs_direct_write_seg(struct inode *inode, struct nfs_writeverf first_verf; struct nfs_write_data *wdata; - wdata = nfs_writedata_alloc(); + wdata = nfs_writedata_alloc(NFS_SERVER(inode)->wpages); if (!wdata) return -ENOMEM; diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 4e6558d..acde2c5 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -221,10 +221,10 @@ nfs_calc_block_size(u64 tsize) static inline unsigned long nfs_block_size(unsigned long bsize, unsigned char *nrbitsp) { - if (bsize < 1024) - bsize = NFS_DEF_FILE_IO_BUFFER_SIZE; - else if (bsize >= NFS_MAX_FILE_IO_BUFFER_SIZE) - bsize = NFS_MAX_FILE_IO_BUFFER_SIZE; + if (bsize < NFS_MIN_FILE_IO_SIZE) + bsize = NFS_DEF_FILE_IO_SIZE; + else if (bsize >= NFS_MAX_FILE_IO_SIZE) + bsize = NFS_MAX_FILE_IO_SIZE; return nfs_block_bits(bsize, nrbitsp); } @@ -307,20 +307,15 @@ nfs_sb_init(struct super_block *sb, rpc_authflavor_t authflavor) max_rpc_payload = nfs_block_size(rpc_max_payload(server->client), NULL); if (server->rsize > max_rpc_payload) server->rsize = max_rpc_payload; - if (server->wsize > max_rpc_payload) - server->wsize = max_rpc_payload; - + if (server->rsize > NFS_MAX_FILE_IO_SIZE) + server->rsize = NFS_MAX_FILE_IO_SIZE; server->rpages = (server->rsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - if (server->rpages > NFS_READ_MAXIOV) { - server->rpages = NFS_READ_MAXIOV; - server->rsize = server->rpages << PAGE_CACHE_SHIFT; - } + if (server->wsize > max_rpc_payload) + server->wsize = max_rpc_payload; + if (server->wsize > NFS_MAX_FILE_IO_SIZE) + server->wsize = NFS_MAX_FILE_IO_SIZE; server->wpages = (server->wsize + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - if (server->wpages > NFS_WRITE_MAXIOV) { - server->wpages = NFS_WRITE_MAXIOV; - server->wsize = server->wpages << PAGE_CACHE_SHIFT; - } if (sb->s_blocksize == 0) sb->s_blocksize = nfs_block_bits(server->wsize, diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index 1b272a1..985cc53 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c @@ -296,8 +296,8 @@ static int __init root_nfs_name(char *name) nfs_port = -1; nfs_data.version = NFS_MOUNT_VERSION; nfs_data.flags = NFS_MOUNT_NONLM; /* No lockd in nfs root yet */ - nfs_data.rsize = NFS_DEF_FILE_IO_BUFFER_SIZE; - nfs_data.wsize = NFS_DEF_FILE_IO_BUFFER_SIZE; + nfs_data.rsize = NFS_DEF_FILE_IO_SIZE; + nfs_data.wsize = NFS_DEF_FILE_IO_SIZE; nfs_data.acregmin = 3; nfs_data.acregmax = 60; nfs_data.acdirmin = 30; diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 2148624..05eb43f 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -83,7 +83,7 @@ static int nfs_readpage_sync(struct nfs_open_context *ctx, struct inode *inode, int result; struct nfs_read_data *rdata; - rdata = nfs_readdata_alloc(); + rdata = nfs_readdata_alloc(1); if (!rdata) return -ENOMEM; @@ -283,7 +283,7 @@ static int nfs_pagein_multi(struct list_head *head, struct inode *inode) nbytes = req->wb_bytes; for(;;) { - data = nfs_readdata_alloc(); + data = nfs_readdata_alloc(1); if (!data) goto out_bad; INIT_LIST_HEAD(&data->pages); @@ -339,7 +339,7 @@ static int nfs_pagein_one(struct list_head *head, struct inode *inode) if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE) return nfs_pagein_multi(head, inode); - data = nfs_readdata_alloc(); + data = nfs_readdata_alloc(NFS_SERVER(inode)->rpages); if (!data) goto out_bad; diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 80bc4ea..1ce0c20 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -89,18 +89,33 @@ static mempool_t *nfs_commit_mempool; static DECLARE_WAIT_QUEUE_HEAD(nfs_write_congestion); -static inline struct nfs_write_data *nfs_commit_alloc(void) +static inline struct nfs_write_data *nfs_commit_alloc(unsigned int pagecount) { struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, SLAB_NOFS); + if (p) { memset(p, 0, sizeof(*p)); INIT_LIST_HEAD(&p->pages); + if (pagecount < NFS_PAGEVEC_SIZE) + p->pagevec = &p->page_array[0]; + else { + size_t size = ++pagecount * sizeof(struct page *); + p->pagevec = kmalloc(size, GFP_NOFS); + if (p->pagevec) { + memset(p->pagevec, 0, size); + } else { + mempool_free(p, nfs_commit_mempool); + p = NULL; + } + } } return p; } static inline void nfs_commit_free(struct nfs_write_data *p) { + if (p && (p->pagevec != &p->page_array[0])) + kfree(p->pagevec); mempool_free(p, nfs_commit_mempool); } @@ -167,7 +182,7 @@ static int nfs_writepage_sync(struct nfs_open_context *ctx, struct inode *inode, int result, written = 0; struct nfs_write_data *wdata; - wdata = nfs_writedata_alloc(); + wdata = nfs_writedata_alloc(1); if (!wdata) return -ENOMEM; @@ -909,7 +924,7 @@ static int nfs_flush_multi(struct list_head *head, struct inode *inode, int how) nbytes = req->wb_bytes; for (;;) { - data = nfs_writedata_alloc(); + data = nfs_writedata_alloc(1); if (!data) goto out_bad; list_add(&data->pages, &list); @@ -973,7 +988,7 @@ static int nfs_flush_one(struct list_head *head, struct inode *inode, int how) if (NFS_SERVER(inode)->wsize < PAGE_CACHE_SIZE) return nfs_flush_multi(head, inode, how); - data = nfs_writedata_alloc(); + data = nfs_writedata_alloc(NFS_SERVER(inode)->wpages); if (!data) goto out_bad; @@ -1241,12 +1256,12 @@ static void nfs_commit_rpcsetup(struct list_head *head, * Commit dirty pages */ static int -nfs_commit_list(struct list_head *head, int how) +nfs_commit_list(struct inode *inode, struct list_head *head, int how) { struct nfs_write_data *data; struct nfs_page *req; - data = nfs_commit_alloc(); + data = nfs_commit_alloc(NFS_SERVER(inode)->wpages); if (!data) goto out_bad; @@ -1351,7 +1366,7 @@ int nfs_commit_inode(struct inode *inode, int how) res = nfs_scan_commit(inode, &head, 0, 0); spin_unlock(&nfsi->req_lock); if (res) { - error = nfs_commit_list(&head, how); + error = nfs_commit_list(inode, &head, how); if (error < 0) return error; } diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 4dff705..d38010b 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -38,9 +38,6 @@ # define NFS_DEBUG #endif -#define NFS_MAX_FILE_IO_BUFFER_SIZE 32768 -#define NFS_DEF_FILE_IO_BUFFER_SIZE 4096 - /* Default timeout values */ #define NFS_MAX_UDP_TIMEOUT (60*HZ) #define NFS_MAX_TCP_TIMEOUT (600*HZ) @@ -462,18 +459,33 @@ static inline int nfs_wb_page(struct inode *inode, struct page* page) */ extern mempool_t *nfs_wdata_mempool; -static inline struct nfs_write_data *nfs_writedata_alloc(void) +static inline struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount) { struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, SLAB_NOFS); + if (p) { memset(p, 0, sizeof(*p)); INIT_LIST_HEAD(&p->pages); + if (pagecount < NFS_PAGEVEC_SIZE) + p->pagevec = &p->page_array[0]; + else { + size_t size = ++pagecount * sizeof(struct page *); + p->pagevec = kmalloc(size, GFP_NOFS); + if (p->pagevec) { + memset(p->pagevec, 0, size); + } else { + mempool_free(p, nfs_wdata_mempool); + p = NULL; + } + } } return p; } static inline void nfs_writedata_free(struct nfs_write_data *p) { + if (p && (p->pagevec != &p->page_array[0])) + kfree(p->pagevec); mempool_free(p, nfs_wdata_mempool); } @@ -492,16 +504,33 @@ extern void nfs_readdata_release(void *data); */ extern mempool_t *nfs_rdata_mempool; -static inline struct nfs_read_data *nfs_readdata_alloc(void) +static inline struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount) { struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, SLAB_NOFS); - if (p) + + if (p) { memset(p, 0, sizeof(*p)); + INIT_LIST_HEAD(&p->pages); + if (pagecount < NFS_PAGEVEC_SIZE) + p->pagevec = &p->page_array[0]; + else { + size_t size = ++pagecount * sizeof(struct page *); + p->pagevec = kmalloc(size, GFP_NOFS); + if (p->pagevec) { + memset(p->pagevec, 0, size); + } else { + mempool_free(p, nfs_rdata_mempool); + p = NULL; + } + } + } return p; } static inline void nfs_readdata_free(struct nfs_read_data *p) { + if (p && (p->pagevec != &p->page_array[0])) + kfree(p->pagevec); mempool_free(p, nfs_rdata_mempool); } diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index b8b0eed..9f422fd 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -4,6 +4,16 @@ #include #include +/* + * To change the maximum rsize and wsize supported by the NFS client, adjust + * NFS_MAX_FILE_IO_SIZE. 64KB is a typical maximum, but some servers can + * support a megabyte or more. The default is left at 4096 bytes, which is + * reasonable for NFS over UDP. + */ +#define NFS_MAX_FILE_IO_SIZE (1048576U) +#define NFS_DEF_FILE_IO_SIZE (4096U) +#define NFS_MIN_FILE_IO_SIZE (1024U) + struct nfs4_fsid { __u64 major; __u64 minor; @@ -215,12 +225,6 @@ struct nfs4_delegreturnargs { /* * Arguments to the read call. */ - -#define NFS_READ_MAXIOV (9U) -#if (NFS_READ_MAXIOV > (MAX_IOVEC -2)) -#error "NFS_READ_MAXIOV is too large" -#endif - struct nfs_readargs { struct nfs_fh * fh; struct nfs_open_context *context; @@ -239,11 +243,6 @@ struct nfs_readres { /* * Arguments to the write call. */ -#define NFS_WRITE_MAXIOV (9U) -#if (NFS_WRITE_MAXIOV > (MAX_IOVEC -2)) -#error "NFS_WRITE_MAXIOV is too large" -#endif - struct nfs_writeargs { struct nfs_fh * fh; struct nfs_open_context *context; @@ -674,6 +673,8 @@ struct nfs4_server_caps_res { struct nfs_page; +#define NFS_PAGEVEC_SIZE (8U) + struct nfs_read_data { int flags; struct rpc_task task; @@ -682,13 +683,14 @@ struct nfs_read_data { struct nfs_fattr fattr; /* fattr storage */ struct list_head pages; /* Coalesced read requests */ struct nfs_page *req; /* multi ops per nfs_page */ - struct page *pagevec[NFS_READ_MAXIOV]; + struct page **pagevec; struct nfs_readargs args; struct nfs_readres res; #ifdef CONFIG_NFS_V4 unsigned long timestamp; /* For lease renewal */ #endif void (*complete) (struct nfs_read_data *, int); + struct page *page_array[NFS_PAGEVEC_SIZE + 1]; }; struct nfs_write_data { @@ -700,13 +702,14 @@ struct nfs_write_data { struct nfs_writeverf verf; struct list_head pages; /* Coalesced requests we wish to flush */ struct nfs_page *req; /* multi ops per nfs_page */ - struct page *pagevec[NFS_WRITE_MAXIOV]; + struct page **pagevec; struct nfs_writeargs args; /* argument struct */ struct nfs_writeres res; /* result struct */ #ifdef CONFIG_NFS_V4 unsigned long timestamp; /* For lease renewal */ #endif void (*complete) (struct nfs_write_data *, int); + struct page *page_array[NFS_PAGEVEC_SIZE + 1]; }; struct nfs_access_entry; diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 5da9687..5676794 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -135,11 +135,6 @@ xdr_adjust_iovec(struct kvec *iov, u32 *p) } /* - * Maximum number of iov's we use. - */ -#define MAX_IOVEC (12) - -/* * XDR buffer helper functions */ extern void xdr_shift_buf(struct xdr_buf *, size_t); -- cgit v1.1 From 24174119c73983d5217da8f56a12c79a9b57e056 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:33 +0100 Subject: NFSv4: Ensure that we return the delegation on the target of a rename too. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index c0d1a21..e925519 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1550,8 +1550,10 @@ go_ahead: } nfs_inode_return_delegation(old_inode); - if (new_inode) + if (new_inode != NULL) { + nfs_inode_return_delegation(new_inode); d_delete(new_dentry); + } nfs_begin_data_update(old_dir); nfs_begin_data_update(new_dir); -- cgit v1.1 From 70b9ecbdb9c5fdc731f8780bffd45d9519020c4a Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:34 +0100 Subject: NFS: Make stat() return updated mtimes after a write() The SuS states that a call to write() will cause mtime to be updated on the file. In order to satisfy that requirement, we need to flush out any cached writes in nfs_getattr(). Speed things up slightly by not committing the writes. Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 2 ++ fs/nfs/write.c | 23 ++++++++++++----------- include/linux/nfs_fs.h | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index acde2c5..2c7f8aa 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -952,6 +952,8 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME; int err; + /* Flush out writes to the server in order to update c/mtime */ + nfs_sync_inode(inode, 0, 0, FLUSH_WAIT|FLUSH_NOCOMMIT); if (__IS_FLG(inode, MS_NOATIME)) need_atime = 0; else if (__IS_FLG(inode, MS_NODIRATIME) && S_ISDIR(inode->i_mode)) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 1ce0c20..9449b68 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1377,22 +1377,23 @@ int nfs_commit_inode(struct inode *inode, int how) int nfs_sync_inode(struct inode *inode, unsigned long idx_start, unsigned int npages, int how) { - int error, - wait; + int nocommit = how & FLUSH_NOCOMMIT; + int wait = how & FLUSH_WAIT; + int error; - wait = how & FLUSH_WAIT; - how &= ~FLUSH_WAIT; + how &= ~(FLUSH_WAIT|FLUSH_NOCOMMIT); do { - error = 0; - if (wait) + if (wait) { error = nfs_wait_on_requests(inode, idx_start, npages); - if (error == 0) - error = nfs_flush_inode(inode, idx_start, npages, how); -#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) - if (error == 0) + if (error != 0) + continue; + } + error = nfs_flush_inode(inode, idx_start, npages, how); + if (error != 0) + continue; + if (!nocommit) error = nfs_commit_inode(inode, how); -#endif } while (error > 0); return error; } diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index d38010b..408d82d 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -62,6 +62,7 @@ #define FLUSH_STABLE 4 /* commit to stable storage */ #define FLUSH_LOWPRI 8 /* low priority background flush */ #define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */ +#define FLUSH_NOCOMMIT 32 /* Don't send the NFSv3/v4 COMMIT */ #ifdef __KERNEL__ -- cgit v1.1 From 566dd6064e89b15ff2dec666a421bebf0f98f26c Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:35 +0100 Subject: NFS: Make directIO aware of compound pages... ...and avoid calling set_page_dirty on them Signed-off-by: Trond Myklebust --- fs/nfs/direct.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index fd7ac5e..10ae377 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -122,9 +122,10 @@ nfs_free_user_pages(struct page **pages, int npages, int do_dirty) { int i; for (i = 0; i < npages; i++) { - if (do_dirty) - set_page_dirty_lock(pages[i]); - page_cache_release(pages[i]); + struct page *page = pages[i]; + if (do_dirty && !PageCompound(page)) + set_page_dirty_lock(page); + page_cache_release(page); } kfree(pages); } -- cgit v1.1 From 969b7f2522c90dfed5d0d2553a91522bda2c3bf3 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:36 +0100 Subject: SUNRPC: Fix a potential race in rpc_pipefs. Signed-off-by: Trond Myklebust --- net/sunrpc/rpc_pipe.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 16a2458..24cc23a 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -70,8 +70,11 @@ rpc_timeout_upcall_queue(void *data) struct inode *inode = &rpci->vfs_inode; down(&inode->i_sem); + if (rpci->ops == NULL) + goto out; if (rpci->nreaders == 0 && !list_empty(&rpci->pipe)) __rpc_purge_upcall(inode, -ETIMEDOUT); +out: up(&inode->i_sem); } @@ -113,8 +116,6 @@ rpc_close_pipes(struct inode *inode) { struct rpc_inode *rpci = RPC_I(inode); - cancel_delayed_work(&rpci->queue_timeout); - flush_scheduled_work(); down(&inode->i_sem); if (rpci->ops != NULL) { rpci->nreaders = 0; @@ -127,6 +128,8 @@ rpc_close_pipes(struct inode *inode) } rpc_inode_setowner(inode, NULL); up(&inode->i_sem); + cancel_delayed_work(&rpci->queue_timeout); + flush_scheduled_work(); } static struct inode * @@ -166,7 +169,7 @@ rpc_pipe_open(struct inode *inode, struct file *filp) static int rpc_pipe_release(struct inode *inode, struct file *filp) { - struct rpc_inode *rpci = RPC_I(filp->f_dentry->d_inode); + struct rpc_inode *rpci = RPC_I(inode); struct rpc_pipe_msg *msg; down(&inode->i_sem); -- cgit v1.1 From beb2a5ec386e5ce6891ebd1c06b913da04354b40 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:37 +0100 Subject: NFSv4: Ensure change attribute returned by GETATTR callback conforms to spec According to RFC3530 we're supposed to cache the change attribute at the time the client receives a write delegation. If the inode is clean, a CB_GETATTR callback by the server to the client is supposed to return the cached change attribute. If, OTOH, the inode is dirty, the client should bump the cached change attribute by 1. Signed-off-by: Trond Myklebust --- fs/nfs/callback_proc.c | 4 +++- fs/nfs/delegation.c | 1 + fs/nfs/delegation.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 65f1e19..462cfce 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c @@ -35,7 +35,9 @@ unsigned nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0) goto out_iput; res->size = i_size_read(inode); - res->change_attr = NFS_CHANGE_ATTR(inode); + res->change_attr = delegation->change_attr; + if (nfsi->npages != 0) + res->change_attr++; res->ctime = inode->i_ctime; res->mtime = inode->i_mtime; res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) & diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 75dfb1c..d2ee09b 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -131,6 +131,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct sizeof(delegation->stateid.data)); delegation->type = res->delegation_type; delegation->maxsize = res->maxsize; + delegation->change_attr = nfsi->change_attr; delegation->cred = get_rpccred(cred); delegation->inode = inode; diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index fbc50ec..7a0b2bf 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h @@ -21,6 +21,7 @@ struct nfs_delegation { #define NFS_DELEGATION_NEED_RECLAIM 1 long flags; loff_t maxsize; + __u64 change_attr; }; int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); -- cgit v1.1 From fa178f29c0f8a0dce748181a5351f4a92fd4f455 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:38 +0100 Subject: NFSv4: Ensure DELEGRETURN returns attributes Upon return of a write delegation, the server will almost always bump the change attribute. Ensure that we pick up that change so that we don't invalidate our data cache unnecessarily. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 2 -- fs/nfs/nfs4proc.c | 17 +++++++++++++---- fs/nfs/nfs4xdr.c | 33 ++++++++++++++++++++++----------- include/linux/nfs_xdr.h | 6 ++++++ 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index d2ee09b..66cc720 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -159,8 +159,6 @@ static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation * { int res = 0; - __nfs_revalidate_inode(NFS_SERVER(inode), inode); - res = nfs4_proc_delegreturn(inode, delegation->cred, &delegation->stateid); nfs_free_delegation(delegation); return res; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index b334915..984ca34 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2920,11 +2920,12 @@ nfs4_proc_setclientid_confirm(struct nfs4_client *clp, struct rpc_cred *cred) struct nfs4_delegreturndata { struct nfs4_delegreturnargs args; + struct nfs4_delegreturnres res; struct nfs_fh fh; nfs4_stateid stateid; struct rpc_cred *cred; unsigned long timestamp; - const struct nfs_server *server; + struct nfs_fattr fattr; int rpc_status; }; @@ -2934,8 +2935,10 @@ static void nfs4_delegreturn_prepare(struct rpc_task *task, void *calldata) struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_DELEGRETURN], .rpc_argp = &data->args, + .rpc_resp = &data->res, .rpc_cred = data->cred, }; + nfs_fattr_init(data->res.fattr); rpc_call_setup(task, &msg, 0); } @@ -2944,7 +2947,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) struct nfs4_delegreturndata *data = calldata; data->rpc_status = task->tk_status; if (data->rpc_status == 0) - renew_lease(data->server, data->timestamp); + renew_lease(data->res.server, data->timestamp); } static void nfs4_delegreturn_release(void *calldata) @@ -2964,6 +2967,7 @@ const static struct rpc_call_ops nfs4_delegreturn_ops = { static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid) { struct nfs4_delegreturndata *data; + struct nfs_server *server = NFS_SERVER(inode); struct rpc_task *task; int status; @@ -2972,11 +2976,13 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co return -ENOMEM; data->args.fhandle = &data->fh; data->args.stateid = &data->stateid; + data->args.bitmask = server->attr_bitmask; nfs_copy_fh(&data->fh, NFS_FH(inode)); memcpy(&data->stateid, stateid, sizeof(data->stateid)); + data->res.fattr = &data->fattr; + data->res.server = server; data->cred = get_rpccred(cred); data->timestamp = jiffies; - data->server = NFS_SERVER(inode); data->rpc_status = 0; task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data); @@ -2985,8 +2991,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co return PTR_ERR(task); } status = nfs4_wait_for_completion_rpc_task(task); - if (status == 0) + if (status == 0) { status = data->rpc_status; + if (status == 0) + nfs_post_op_update_inode(inode, &data->fattr); + } rpc_release_task(task); return status; } diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 5d6bda4..12be1d6 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -392,9 +392,11 @@ static int nfs_stat_to_errno(int); decode_getattr_maxsz) #define NFS4_enc_delegreturn_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ - encode_delegreturn_maxsz) + encode_delegreturn_maxsz + \ + encode_getattr_maxsz) #define NFS4_dec_delegreturn_sz (compound_decode_hdr_maxsz + \ - decode_delegreturn_maxsz) + decode_delegreturn_maxsz + \ + decode_getattr_maxsz) #define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ encode_getattr_maxsz) @@ -1983,14 +1985,20 @@ static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, uint32_t *p, const str { struct xdr_stream xdr; struct compound_hdr hdr = { - .nops = 2, + .nops = 3, }; int status; xdr_init_encode(&xdr, &req->rq_snd_buf, p); encode_compound_hdr(&xdr, &hdr); - if ((status = encode_putfh(&xdr, args->fhandle)) == 0) - status = encode_delegreturn(&xdr, args->stateid); + status = encode_putfh(&xdr, args->fhandle); + if (status != 0) + goto out; + status = encode_delegreturn(&xdr, args->stateid); + if (status != 0) + goto out; + status = encode_getfattr(&xdr, args->bitmask); +out: return status; } @@ -4184,7 +4192,7 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, s /* * DELEGRETURN request */ -static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, void *dummy) +static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, struct nfs4_delegreturnres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -4192,11 +4200,14 @@ static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, uint32_t *p, void *d xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); status = decode_compound_hdr(&xdr, &hdr); - if (status == 0) { - status = decode_putfh(&xdr); - if (status == 0) - status = decode_delegreturn(&xdr); - } + if (status != 0) + goto out; + status = decode_putfh(&xdr); + if (status != 0) + goto out; + status = decode_delegreturn(&xdr); + decode_getfattr(&xdr, res->fattr, res->server); +out: return status; } diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 9f422fd..6d6f69e 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -220,6 +220,12 @@ struct nfs_lockt_res { struct nfs4_delegreturnargs { const struct nfs_fh *fhandle; const nfs4_stateid *stateid; + const u32 * bitmask; +}; + +struct nfs4_delegreturnres { + struct nfs_fattr * fattr; + const struct nfs_server *server; }; /* -- cgit v1.1 From a895b4a198dd06f8353328867e4f6cfd28b63081 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:40 +0100 Subject: NFS: Clean up weak cache consistency code ...and ensure that nfs_update_inode() respects wcc Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 60 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 2c7f8aa..7270b1d 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1248,6 +1248,33 @@ void nfs_end_data_update(struct inode *inode) atomic_dec(&nfsi->data_updates); } +static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) +{ + struct nfs_inode *nfsi = NFS_I(inode); + + if ((fattr->valid & NFS_ATTR_PRE_CHANGE) != 0 + && nfsi->change_attr == fattr->pre_change_attr) { + nfsi->change_attr = fattr->change_attr; + nfsi->cache_change_attribute = jiffies; + } + + /* If we have atomic WCC data, we may update some attributes */ + if ((fattr->valid & NFS_ATTR_WCC) != 0) { + if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) { + memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime)); + nfsi->cache_change_attribute = jiffies; + } + if (timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) { + memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime)); + nfsi->cache_change_attribute = jiffies; + } + if (inode->i_size == fattr->pre_size && nfsi->npages == 0) { + inode->i_size = fattr->size; + nfsi->cache_change_attribute = jiffies; + } + } +} + /** * nfs_check_inode_attributes - verify consistency of the inode attribute cache * @inode - pointer to inode @@ -1264,22 +1291,20 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat int data_unstable; + if ((fattr->valid & NFS_ATTR_FATTR) == 0) + return 0; + /* Are we in the process of updating data on the server? */ data_unstable = nfs_caches_unstable(inode); - if (fattr->valid & NFS_ATTR_FATTR_V4) { - if ((fattr->valid & NFS_ATTR_PRE_CHANGE) != 0 - && nfsi->change_attr == fattr->pre_change_attr) - nfsi->change_attr = fattr->change_attr; - if (nfsi->change_attr != fattr->change_attr) { - nfsi->cache_validity |= NFS_INO_INVALID_ATTR; - if (!data_unstable) - nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; - } - } + /* Do atomic weak cache consistency updates */ + nfs_wcc_update_inode(inode, fattr); - if ((fattr->valid & NFS_ATTR_FATTR) == 0) { - return 0; + if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && + nfsi->change_attr != fattr->change_attr) { + nfsi->cache_validity |= NFS_INO_INVALID_ATTR; + if (!data_unstable) + nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; } /* Has the inode gone and changed behind our back? */ @@ -1291,14 +1316,6 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat cur_size = i_size_read(inode); new_isize = nfs_size_to_loff_t(fattr->size); - /* If we have atomic WCC data, we may update some attributes */ - if ((fattr->valid & NFS_ATTR_WCC) != 0) { - if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) - memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime)); - if (timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) - memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime)); - } - /* Verify a few of the more important attributes */ if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { nfsi->cache_validity |= NFS_INO_INVALID_ATTR; @@ -1426,6 +1443,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) if (data_stable) nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME); + /* Do atomic weak cache consistency updates */ + nfs_wcc_update_inode(inode, fattr); + /* Check if our cached file size is stale */ new_isize = nfs_size_to_loff_t(fattr->size); cur_isize = i_size_read(inode); -- cgit v1.1 From a72b44222d222749d54b3e370d825094352e389f Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:41 +0100 Subject: NFSv4: Allow user to set the port used by the NFSv4 callback channel Signed-off-by: Trond Myklebust --- Documentation/kernel-parameters.txt | 4 ++ fs/nfs/Makefile | 1 + fs/nfs/callback.c | 3 +- fs/nfs/callback.h | 1 + fs/nfs/inode.c | 37 ++++++++++++++++++- fs/nfs/sysctl.c | 74 +++++++++++++++++++++++++++++++++++++ include/linux/nfs_fs.h | 11 ++++++ 7 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 fs/nfs/sysctl.c diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 61a56b1..309c9ce 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -910,6 +910,10 @@ running once the system is up. nfsroot= [NFS] nfs root filesystem for disk-less boxes. See Documentation/nfsroot.txt. + nfs.callback_tcpport= + [NFS] set the TCP port on which the NFSv4 callback + channel should listen. + nmi_watchdog= [KNL,BUGS=IA-32] Debugging features for SMP kernels no387 [BUGS=IA-32] Tells the kernel to use the 387 maths diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile index 8b3bb71..ec61fd5 100644 --- a/fs/nfs/Makefile +++ b/fs/nfs/Makefile @@ -13,4 +13,5 @@ nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ delegation.o idmap.o \ callback.o callback_xdr.o callback_proc.o nfs-$(CONFIG_NFS_DIRECTIO) += direct.o +nfs-$(CONFIG_SYSCTL) += sysctl.o nfs-objs := $(nfs-y) diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 30cae36..fcd97406 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -34,6 +34,7 @@ static struct nfs_callback_data nfs_callback_info; static DECLARE_MUTEX(nfs_callback_sema); static struct svc_program nfs4_callback_program; +unsigned int nfs_callback_set_tcpport; unsigned short nfs_callback_tcpport; /* @@ -98,7 +99,7 @@ int nfs_callback_up(void) if (!serv) goto out_err; /* FIXME: We don't want to register this socket with the portmapper */ - ret = svc_makesock(serv, IPPROTO_TCP, 0); + ret = svc_makesock(serv, IPPROTO_TCP, nfs_callback_set_tcpport); if (ret < 0) goto out_destroy; if (!list_empty(&serv->sv_permsocks)) { diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index a0db2d4f9..b252e7f 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h @@ -65,6 +65,7 @@ extern unsigned nfs4_callback_recall(struct cb_recallargs *args, void *dummy); extern int nfs_callback_up(void); extern int nfs_callback_down(void); +extern unsigned int nfs_callback_set_tcpport; extern unsigned short nfs_callback_tcpport; #endif /* __LINUX_FS_NFS_CALLBACK_H */ diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 7270b1d..648cb1a 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -40,6 +40,7 @@ #include #include "nfs4_fs.h" +#include "callback.h" #include "delegation.h" #define NFSDBG_FACILITY NFSDBG_VFS @@ -2036,6 +2037,21 @@ static struct file_system_type nfs4_fs_type = { .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, }; +static const int nfs_set_port_min = 0; +static const int nfs_set_port_max = 65535; +static int param_set_port(const char *val, struct kernel_param *kp) +{ + char *endp; + int num = simple_strtol(val, &endp, 0); + if (endp == val || *endp || num < nfs_set_port_min || num > nfs_set_port_max) + return -EINVAL; + *((int *)kp->arg) = num; + return 0; +} + +module_param_call(callback_tcpport, param_set_port, param_get_int, + &nfs_callback_set_tcpport, 0644); + #define nfs4_init_once(nfsi) \ do { \ INIT_LIST_HEAD(&(nfsi)->open_states); \ @@ -2043,8 +2059,25 @@ static struct file_system_type nfs4_fs_type = { nfsi->delegation_state = 0; \ init_rwsem(&nfsi->rwsem); \ } while(0) -#define register_nfs4fs() register_filesystem(&nfs4_fs_type) -#define unregister_nfs4fs() unregister_filesystem(&nfs4_fs_type) + +static inline int register_nfs4fs(void) +{ + int ret; + + ret = nfs_register_sysctl(); + if (ret != 0) + return ret; + ret = register_filesystem(&nfs4_fs_type); + if (ret != 0) + nfs_unregister_sysctl(); + return ret; +} + +static inline void unregister_nfs4fs(void) +{ + unregister_filesystem(&nfs4_fs_type); + nfs_unregister_sysctl(); +} #else #define nfs4_init_once(nfsi) \ do { } while (0) diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c new file mode 100644 index 0000000..fdc64b5 --- /dev/null +++ b/fs/nfs/sysctl.c @@ -0,0 +1,74 @@ +/* + * linux/fs/nfs/sysctl.c + * + * Sysctl interface to NFS parameters + */ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "callback.h" + +static const int nfs_set_port_min = 0; +static const int nfs_set_port_max = 65535; +static struct ctl_table_header *nfs_callback_sysctl_table; +/* + * Something that isn't CTL_ANY, CTL_NONE or a value that may clash. + * Use the same values as fs/lockd/svc.c + */ +#define CTL_UNNUMBERED -2 + +static ctl_table nfs_cb_sysctls[] = { +#ifdef CONFIG_NFS_V4 + { + .ctl_name = CTL_UNNUMBERED, + .procname = "nfs_callback_tcpport", + .data = &nfs_callback_set_tcpport, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_minmax, + .extra1 = (int *)&nfs_set_port_min, + .extra2 = (int *)&nfs_set_port_max, + }, +#endif + { .ctl_name = 0 } +}; + +static ctl_table nfs_cb_sysctl_dir[] = { + { + .ctl_name = CTL_UNNUMBERED, + .procname = "nfs", + .mode = 0555, + .child = nfs_cb_sysctls, + }, + { .ctl_name = 0 } +}; + +static ctl_table nfs_cb_sysctl_root[] = { + { + .ctl_name = CTL_FS, + .procname = "fs", + .mode = 0555, + .child = nfs_cb_sysctl_dir, + }, + { .ctl_name = 0 } +}; + +int nfs_register_sysctl(void) +{ + nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root, 0); + if (nfs_callback_sysctl_table == NULL) + return -ENOMEM; + return 0; +} + +void nfs_unregister_sysctl(void) +{ + unregister_sysctl_table(nfs_callback_sysctl_table); + nfs_callback_sysctl_table = NULL; +} diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 408d82d..547d649 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -392,6 +392,17 @@ extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh, struct nfs_ extern struct inode_operations nfs_symlink_inode_operations; /* + * linux/fs/nfs/sysctl.c + */ +#ifdef CONFIG_SYSCTL +extern int nfs_register_sysctl(void); +extern void nfs_unregister_sysctl(void); +#else +#define nfs_register_sysctl() do { } while(0) +#define nfs_unregister_sysctl() do { } while(0) +#endif + +/* * linux/fs/nfs/unlink.c */ extern int nfs_async_unlink(struct dentry *); -- cgit v1.1 From fb459f45f7c7689714023d41b3dca999bb90a5d3 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Tue, 3 Jan 2006 09:55:41 +0100 Subject: SUNRPC: net/sunrpc/xdr.c: remove xdr_decode_string() This patch removes ths unused function xdr_decode_string(). Signed-off-by: Adrian Bunk Acked-by: Neil Brown Acked-by: Charles Lever Signed-off-by: Trond Myklebust --- include/linux/sunrpc/xdr.h | 1 - net/sunrpc/xdr.c | 21 --------------------- 2 files changed, 22 deletions(-) diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 5676794..84c35d4 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -91,7 +91,6 @@ struct xdr_buf { u32 * xdr_encode_opaque_fixed(u32 *p, const void *ptr, unsigned int len); u32 * xdr_encode_opaque(u32 *p, const void *ptr, unsigned int len); u32 * xdr_encode_string(u32 *p, const char *s); -u32 * xdr_decode_string(u32 *p, char **sp, int *lenp, int maxlen); u32 * xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen); u32 * xdr_encode_netobj(u32 *p, const struct xdr_netobj *); u32 * xdr_decode_netobj(u32 *p, struct xdr_netobj *); diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index aaf08cdd..ca4bfa5 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -93,27 +93,6 @@ xdr_encode_string(u32 *p, const char *string) } u32 * -xdr_decode_string(u32 *p, char **sp, int *lenp, int maxlen) -{ - unsigned int len; - char *string; - - if ((len = ntohl(*p++)) > maxlen) - return NULL; - if (lenp) - *lenp = len; - if ((len % 4) != 0) { - string = (char *) p; - } else { - string = (char *) (p - 1); - memmove(string, p, len); - } - string[len] = '\0'; - *sp = string; - return p + XDR_QUADLEN(len); -} - -u32 * xdr_decode_string_inplace(u32 *p, char **sp, int *lenp, int maxlen) { unsigned int len; -- cgit v1.1 From f232142cc21127c829559923eb405d1bcb2e2278 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:55:42 +0100 Subject: NLM: Clean up nlmsvc_grant_reply locking Slightly simpler logic here makes it more trivial to verify that the up's and down's are balanced here. Break out an assignment from a conditional while we're at it. Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- fs/lockd/svclock.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 87d09a0..e42f0cc6 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -637,11 +637,12 @@ nlmsvc_grant_reply(struct svc_rqst *rqstp, struct nlm_cookie *cookie, u32 status file->f_count++; down(&file->f_sema); - if ((block = nlmsvc_find_block(cookie,&rqstp->rq_addr)) != NULL) { + block = nlmsvc_find_block(cookie, &rqstp->rq_addr); + if (block) { if (status == NLM_LCK_DENIED_GRACE_PERIOD) { /* Try again in a couple of seconds */ nlmsvc_insert_block(block, 10 * HZ); - block = NULL; + up(&file->f_sema); } else { /* Lock is now held by client, or has been rejected. * In both cases, the block should be removed. */ @@ -652,8 +653,6 @@ nlmsvc_grant_reply(struct svc_rqst *rqstp, struct nlm_cookie *cookie, u32 status nlmsvc_delete_block(block, 1); } } - if (!block) - up(&file->f_sema); nlm_release_file(file); } -- cgit v1.1 From 5996a298da43a03081e9ba2116983d173001c862 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:55:44 +0100 Subject: NLM: don't unlock on cancel requests Currently when lockd gets an NLM_CANCEL request, it also does an unlock for the same range. This is incorrect. The Open Group documentation says that "This procedure cancels an *outstanding* blocked lock request." (Emphasis mine.) Also, consider a client that holds a lock on the first byte of a file, and requests a lock on the entire file. If the client cancels that request (perhaps because the requesting process is signalled), the server shouldn't apply perform an unlock on the entire file, since that will also remove the previous lock that the client was already granted. Or consider a lock request that actually *downgraded* an exclusive lock to a shared lock. Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- fs/lockd/svclock.c | 5 ----- fs/locks.c | 13 ++----------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index e42f0cc6..5fb48b4 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -240,11 +240,6 @@ nlmsvc_delete_block(struct nlm_block *block, int unlock) nlmsvc_remove_block(block); if (fl->fl_next) posix_unblock_lock(file->f_file, fl); - if (unlock) { - fl->fl_type = F_UNLCK; - posix_lock_file(file->f_file, fl); - block->b_granted = 0; - } /* If the block is in the middle of a GRANT callback, * don't kill it yet. */ diff --git a/fs/locks.c b/fs/locks.c index 250ef53..75650d5 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1961,19 +1961,10 @@ EXPORT_SYMBOL(posix_block_lock); void posix_unblock_lock(struct file *filp, struct file_lock *waiter) { - /* - * A remote machine may cancel the lock request after it's been - * granted locally. If that happens, we need to delete the lock. - */ lock_kernel(); - if (waiter->fl_next) { + if (waiter->fl_next) __locks_delete_block(waiter); - unlock_kernel(); - } else { - unlock_kernel(); - waiter->fl_type = F_UNLCK; - posix_lock_file(filp, waiter); - } + unlock_kernel(); } EXPORT_SYMBOL(posix_unblock_lock); -- cgit v1.1 From 2c5acd2e1a73cad59203a1bace21e6b03f2920a9 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:55:45 +0100 Subject: NLM: clean up nlmsvc_delete_block The fl_next check here is superfluous (and possibly a layering violation). Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- fs/lockd/svclock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 5fb48b4..b56d439 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -238,8 +238,7 @@ nlmsvc_delete_block(struct nlm_block *block, int unlock) /* Remove block from list */ nlmsvc_remove_block(block); - if (fl->fl_next) - posix_unblock_lock(file->f_file, fl); + posix_unblock_lock(file->f_file, fl); /* If the block is in the middle of a GRANT callback, * don't kill it yet. */ -- cgit v1.1 From 64a318ee2af9000df482d7a125c3b3e1f1007404 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:55:46 +0100 Subject: NLM: Further cancel fixes If the server receives an NLM cancel call and finds no waiting lock to cancel, then chances are the lock has already been applied, and the client just hadn't yet processed the NLM granted callback before it sent the cancel. The Open Group text, for example, perimts a server to return either success (LCK_GRANTED) or failure (LCK_DENIED) in this case. But returning an error seems more helpful; the client may be able to use it to recognize that a race has occurred and to recover from the race. So, modify the relevant functions to return an error in this case. Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- fs/lockd/svclock.c | 15 ++++++++++----- fs/locks.c | 7 ++++++- include/linux/fs.h | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index b56d439..9cfced6 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -227,25 +227,27 @@ failed: * It is the caller's responsibility to check whether the file * can be closed hereafter. */ -static void +static int nlmsvc_delete_block(struct nlm_block *block, int unlock) { struct file_lock *fl = &block->b_call.a_args.lock.fl; struct nlm_file *file = block->b_file; struct nlm_block **bp; + int status = 0; dprintk("lockd: deleting block %p...\n", block); /* Remove block from list */ nlmsvc_remove_block(block); - posix_unblock_lock(file->f_file, fl); + if (unlock) + status = posix_unblock_lock(file->f_file, fl); /* If the block is in the middle of a GRANT callback, * don't kill it yet. */ if (block->b_incall) { nlmsvc_insert_block(block, NLM_NEVER); block->b_done = 1; - return; + return status; } /* Remove block from file's list of blocks */ @@ -260,6 +262,7 @@ nlmsvc_delete_block(struct nlm_block *block, int unlock) nlm_release_host(block->b_host); nlmclnt_freegrantargs(&block->b_call); kfree(block); + return status; } /* @@ -270,6 +273,7 @@ int nlmsvc_traverse_blocks(struct nlm_host *host, struct nlm_file *file, int action) { struct nlm_block *block, *next; + /* XXX: Will everything get cleaned up if we don't unlock here? */ down(&file->f_sema); for (block = file->f_blocks; block; block = next) { @@ -439,6 +443,7 @@ u32 nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock) { struct nlm_block *block; + int status = 0; dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n", file->f_file->f_dentry->d_inode->i_sb->s_id, @@ -449,9 +454,9 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock) down(&file->f_sema); if ((block = nlmsvc_lookup_block(file, lock, 1)) != NULL) - nlmsvc_delete_block(block, 1); + status = nlmsvc_delete_block(block, 1); up(&file->f_sema); - return nlm_granted; + return status ? nlm_lck_denied : nlm_granted; } /* diff --git a/fs/locks.c b/fs/locks.c index 75650d5..fb32d62 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1958,13 +1958,18 @@ EXPORT_SYMBOL(posix_block_lock); * * lockd needs to block waiting for locks. */ -void +int posix_unblock_lock(struct file *filp, struct file_lock *waiter) { + int status = 0; + lock_kernel(); if (waiter->fl_next) __locks_delete_block(waiter); + else + status = -ENOENT; unlock_kernel(); + return status; } EXPORT_SYMBOL(posix_unblock_lock); diff --git a/include/linux/fs.h b/include/linux/fs.h index 115e72b..2c9c48d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -760,7 +760,7 @@ extern struct file_lock *posix_test_lock(struct file *, struct file_lock *); extern int posix_lock_file(struct file *, struct file_lock *); extern int posix_lock_file_wait(struct file *, struct file_lock *); extern void posix_block_lock(struct file_lock *, struct file_lock *); -extern void posix_unblock_lock(struct file *, struct file_lock *); +extern int posix_unblock_lock(struct file *, struct file_lock *); extern int posix_locks_deadlock(struct file_lock *, struct file_lock *); extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); extern int __break_lease(struct inode *inode, unsigned int flags); -- cgit v1.1 From a659753ecc66945e9c69823fcbbe222b446c66d7 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:55:46 +0100 Subject: NLM: fix parsing of sm notify procedure The procedure that decodes statd sm_notify call seems to be skipping a few arguments. How did this ever work? >From folks at Polyserve. Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- fs/lockd/xdr4.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c index ae4d6b4..fdcf105a 100644 --- a/fs/lockd/xdr4.c +++ b/fs/lockd/xdr4.c @@ -354,7 +354,9 @@ nlm4svc_decode_reboot(struct svc_rqst *rqstp, u32 *p, struct nlm_reboot *argp) return 0; argp->state = ntohl(*p++); /* Preserve the address in network byte order */ - argp->addr = *p++; + argp->addr = *p++; + argp->vers = *p++; + argp->proto = *p++; return xdr_argsize_check(rqstp, p); } -- cgit v1.1 From 03c21733938aad0758f5f88e1cc7ede69fc3c910 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:55:48 +0100 Subject: NFSv3: try get_root user-supplied security_flavor Thanks to Ed Keizer for bug and root cause. He says: "... we could only mount the top-level Solaris share. We could not mount deeper into the tree. Investigation showed that Solaris allows UNIX authenticated FSINFO only on the top level of the share. This is a problem because we share/export our home directories one level higher than we mount them. I.e. we share the partition and not the individual home directories. This prevented access to home directories." We still may need to try auth_sys for the case where the client doesn't have appropriate credentials. Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- fs/nfs/nfs3proc.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index c172a75..ed67567 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -68,27 +68,39 @@ nfs3_async_handle_jukebox(struct rpc_task *task) return 1; } -/* - * Bare-bones access to getattr: this is for nfs_read_super. - */ static int -nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, - struct nfs_fsinfo *info) +do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle, + struct nfs_fsinfo *info) { int status; dprintk("%s: call fsinfo\n", __FUNCTION__); nfs_fattr_init(info->fattr); - status = rpc_call(server->client_sys, NFS3PROC_FSINFO, fhandle, info, 0); + status = rpc_call(client, NFS3PROC_FSINFO, fhandle, info, 0); dprintk("%s: reply fsinfo: %d\n", __FUNCTION__, status); if (!(info->fattr->valid & NFS_ATTR_FATTR)) { - status = rpc_call(server->client_sys, NFS3PROC_GETATTR, fhandle, info->fattr, 0); + status = rpc_call(client, NFS3PROC_GETATTR, fhandle, info->fattr, 0); dprintk("%s: reply getattr: %d\n", __FUNCTION__, status); } return status; } /* + * Bare-bones access to getattr: this is for nfs_read_super. + */ +static int +nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, + struct nfs_fsinfo *info) +{ + int status; + + status = do_proc_get_root(server->client, fhandle, info); + if (status && server->client_sys != server->client) + status = do_proc_get_root(server->client_sys, fhandle, info); + return status; +} + +/* * One function for each procedure in the NFS protocol. */ static int -- cgit v1.1 From 02107148349f31eee7c0fb06fd7a880df73dbd20 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 3 Jan 2006 09:55:49 +0100 Subject: SUNRPC: switchable buffer allocation Add RPC client transport switch support for replacing buffer management on a per-transport basis. In the current IPv4 socket transport implementation, RPC buffers are allocated as needed for each RPC message that is sent. Some transport implementations may choose to use pre-allocated buffers for encoding, sending, receiving, and unmarshalling RPC messages, however. For transports capable of direct data placement, the buffers can be carved out of a pre-registered area of memory rather than from a slab cache. Test-plan: Millions of fsx operations. Performance characterization with "sio" and "iozone". Use oprofile and other tools to look for significant regression in CPU utilization. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- include/linux/sunrpc/sched.h | 3 +-- include/linux/sunrpc/xprt.h | 10 ++++----- net/sunrpc/clnt.c | 14 +++++++------ net/sunrpc/sched.c | 50 ++++++++++++++++++++++++-------------------- net/sunrpc/xprt.c | 3 +++ net/sunrpc/xprtsock.c | 5 +++++ 6 files changed, 49 insertions(+), 36 deletions(-) diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 94b0afa..8b25629 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -52,8 +52,6 @@ struct rpc_task { * RPC call state */ struct rpc_message tk_msg; /* RPC call info */ - __u32 * tk_buffer; /* XDR buffer */ - size_t tk_bufsize; __u8 tk_garb_retry; __u8 tk_cred_retry; @@ -268,6 +266,7 @@ struct rpc_task *rpc_wake_up_next(struct rpc_wait_queue *); void rpc_wake_up_status(struct rpc_wait_queue *, int); void rpc_delay(struct rpc_task *, unsigned long); void * rpc_malloc(struct rpc_task *, size_t); +void rpc_free(struct rpc_task *); int rpciod_up(void); void rpciod_down(void); void rpciod_wake_up(void); diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 3b8b6e8..7885b96 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -79,21 +79,19 @@ struct rpc_rqst { void (*rq_release_snd_buf)(struct rpc_rqst *); /* release rq_enc_pages */ struct list_head rq_list; + __u32 * rq_buffer; /* XDR encode buffer */ + size_t rq_bufsize; + struct xdr_buf rq_private_buf; /* The receive buffer * used in the softirq. */ unsigned long rq_majortimeo; /* major timeout alarm */ unsigned long rq_timeout; /* Current timeout value */ unsigned int rq_retries; /* # of retries */ - /* - * For authentication (e.g. auth_des) - */ - u32 rq_creddata[2]; /* * Partial send handling */ - u32 rq_bytes_sent; /* Bytes we have sent */ unsigned long rq_xtime; /* when transmitted */ @@ -107,6 +105,8 @@ struct rpc_xprt_ops { int (*reserve_xprt)(struct rpc_task *task); void (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task); void (*connect)(struct rpc_task *task); + void * (*buf_alloc)(struct rpc_task *task, size_t size); + void (*buf_free)(struct rpc_task *task); int (*send_request)(struct rpc_task *task); void (*set_retrans_timeout)(struct rpc_task *task); void (*timer)(struct rpc_task *task); diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index b23c0d3..25cba94 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -644,24 +644,26 @@ call_reserveresult(struct rpc_task *task) /* * 2. Allocate the buffer. For details, see sched.c:rpc_malloc. - * (Note: buffer memory is freed in rpc_task_release). + * (Note: buffer memory is freed in xprt_release). */ static void call_allocate(struct rpc_task *task) { + struct rpc_rqst *req = task->tk_rqstp; + struct rpc_xprt *xprt = task->tk_xprt; unsigned int bufsiz; dprintk("RPC: %4d call_allocate (status %d)\n", task->tk_pid, task->tk_status); task->tk_action = call_bind; - if (task->tk_buffer) + if (req->rq_buffer) return; /* FIXME: compute buffer requirements more exactly using * auth->au_wslack */ bufsiz = task->tk_msg.rpc_proc->p_bufsiz + RPC_SLACK_SPACE; - if (rpc_malloc(task, bufsiz << 1) != NULL) + if (xprt->ops->buf_alloc(task, bufsiz << 1) != NULL) return; printk(KERN_INFO "RPC: buffer allocation failed for task %p\n", task); @@ -704,14 +706,14 @@ call_encode(struct rpc_task *task) task->tk_pid, task->tk_status); /* Default buffer setup */ - bufsiz = task->tk_bufsize >> 1; - sndbuf->head[0].iov_base = (void *)task->tk_buffer; + bufsiz = req->rq_bufsize >> 1; + sndbuf->head[0].iov_base = (void *)req->rq_buffer; sndbuf->head[0].iov_len = bufsiz; sndbuf->tail[0].iov_len = 0; sndbuf->page_len = 0; sndbuf->len = 0; sndbuf->buflen = bufsiz; - rcvbuf->head[0].iov_base = (void *)((char *)task->tk_buffer + bufsiz); + rcvbuf->head[0].iov_base = (void *)((char *)req->rq_buffer + bufsiz); rcvbuf->head[0].iov_len = bufsiz; rcvbuf->tail[0].iov_len = 0; rcvbuf->page_len = 0; diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 48510e3..7415406 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -41,8 +41,6 @@ static mempool_t *rpc_buffer_mempool __read_mostly; static void __rpc_default_timer(struct rpc_task *task); static void rpciod_killall(void); -static void rpc_free(struct rpc_task *task); - static void rpc_async_schedule(void *); /* @@ -599,7 +597,6 @@ void rpc_exit_task(struct rpc_task *task) WARN_ON(RPC_ASSASSINATED(task)); /* Always release the RPC slot and buffer memory */ xprt_release(task); - rpc_free(task); } } } @@ -724,17 +721,19 @@ static void rpc_async_schedule(void *arg) __rpc_execute((struct rpc_task *)arg); } -/* - * Allocate memory for RPC purposes. +/** + * rpc_malloc - allocate an RPC buffer + * @task: RPC task that will use this buffer + * @size: requested byte size * * We try to ensure that some NFS reads and writes can always proceed * by using a mempool when allocating 'small' buffers. * In order to avoid memory starvation triggering more writebacks of * NFS requests, we use GFP_NOFS rather than GFP_KERNEL. */ -void * -rpc_malloc(struct rpc_task *task, size_t size) +void * rpc_malloc(struct rpc_task *task, size_t size) { + struct rpc_rqst *req = task->tk_rqstp; gfp_t gfp; if (task->tk_flags & RPC_TASK_SWAPPER) @@ -743,27 +742,33 @@ rpc_malloc(struct rpc_task *task, size_t size) gfp = GFP_NOFS; if (size > RPC_BUFFER_MAXSIZE) { - task->tk_buffer = kmalloc(size, gfp); - if (task->tk_buffer) - task->tk_bufsize = size; + req->rq_buffer = kmalloc(size, gfp); + if (req->rq_buffer) + req->rq_bufsize = size; } else { - task->tk_buffer = mempool_alloc(rpc_buffer_mempool, gfp); - if (task->tk_buffer) - task->tk_bufsize = RPC_BUFFER_MAXSIZE; + req->rq_buffer = mempool_alloc(rpc_buffer_mempool, gfp); + if (req->rq_buffer) + req->rq_bufsize = RPC_BUFFER_MAXSIZE; } - return task->tk_buffer; + return req->rq_buffer; } -static void -rpc_free(struct rpc_task *task) +/** + * rpc_free - free buffer allocated via rpc_malloc + * @task: RPC task with a buffer to be freed + * + */ +void rpc_free(struct rpc_task *task) { - if (task->tk_buffer) { - if (task->tk_bufsize == RPC_BUFFER_MAXSIZE) - mempool_free(task->tk_buffer, rpc_buffer_mempool); + struct rpc_rqst *req = task->tk_rqstp; + + if (req->rq_buffer) { + if (req->rq_bufsize == RPC_BUFFER_MAXSIZE) + mempool_free(req->rq_buffer, rpc_buffer_mempool); else - kfree(task->tk_buffer); - task->tk_buffer = NULL; - task->tk_bufsize = 0; + kfree(req->rq_buffer); + req->rq_buffer = NULL; + req->rq_bufsize = 0; } } @@ -887,7 +892,6 @@ void rpc_release_task(struct rpc_task *task) xprt_release(task); if (task->tk_msg.rpc_cred) rpcauth_unbindcred(task); - rpc_free(task); if (task->tk_client) { rpc_release_client(task->tk_client); task->tk_client = NULL; diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 6dda386..069a6cb 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -838,6 +838,8 @@ static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) req->rq_timeout = xprt->timeout.to_initval; req->rq_task = task; req->rq_xprt = xprt; + req->rq_buffer = NULL; + req->rq_bufsize = 0; req->rq_xid = xprt_alloc_xid(xprt); req->rq_release_snd_buf = NULL; dprintk("RPC: %4d reserved req %p xid %08x\n", task->tk_pid, @@ -867,6 +869,7 @@ void xprt_release(struct rpc_task *task) mod_timer(&xprt->timer, xprt->last_used + xprt->idle_timeout); spin_unlock_bh(&xprt->transport_lock); + xprt->ops->buf_free(task); task->tk_rqstp = NULL; if (req->rq_release_snd_buf) req->rq_release_snd_buf(req); diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 77e8800..51f07c9 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1161,6 +1162,8 @@ static struct rpc_xprt_ops xs_udp_ops = { .reserve_xprt = xprt_reserve_xprt_cong, .release_xprt = xprt_release_xprt_cong, .connect = xs_connect, + .buf_alloc = rpc_malloc, + .buf_free = rpc_free, .send_request = xs_udp_send_request, .set_retrans_timeout = xprt_set_retrans_timeout_rtt, .timer = xs_udp_timer, @@ -1173,6 +1176,8 @@ static struct rpc_xprt_ops xs_tcp_ops = { .reserve_xprt = xprt_reserve_xprt, .release_xprt = xprt_release_xprt, .connect = xs_connect, + .buf_alloc = rpc_malloc, + .buf_free = rpc_free, .send_request = xs_tcp_send_request, .set_retrans_timeout = xprt_set_retrans_timeout_def, .close = xs_close, -- cgit v1.1 From 35f5a422ce1af836007f811b613c440d0e348e06 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 3 Jan 2006 09:55:50 +0100 Subject: SUNRPC: new interface to force an RPC rebind We'd like to hide fields in rpc_xprt and rpc_clnt from upper layer protocols. Start by creating an API to force RPC rebind, replacing logic that simply sets cl_port to zero. Test-plan: Destructive testing (unplugging the network temporarily). Connectathon with UDP and TCP. NFSv2/3 and NFSv4 mounting should be carefully checked. Probably need to rig a server where certain services aren't running, or that returns an error for some typical operation. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/lockd/host.c | 4 ++-- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 21 +++++++++++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/fs/lockd/host.c b/fs/lockd/host.c index c4c8601..82f7a0b 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -177,7 +177,7 @@ nlm_bind_host(struct nlm_host *host) if ((clnt = host->h_rpcclnt) != NULL) { xprt = clnt->cl_xprt; if (time_after_eq(jiffies, host->h_nextrebind)) { - clnt->cl_port = 0; + rpc_force_rebind(clnt); host->h_nextrebind = jiffies + NLM_HOST_REBIND; dprintk("lockd: next rebind in %ld jiffies\n", host->h_nextrebind - jiffies); @@ -217,7 +217,7 @@ nlm_rebind_host(struct nlm_host *host) { dprintk("lockd: rebind host %s\n", host->h_name); if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) { - host->h_rpcclnt->cl_port = 0; + rpc_force_rebind(host->h_rpcclnt); host->h_nextrebind = jiffies + NLM_HOST_REBIND; } } diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index b0ab959..3d605765 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -135,6 +135,7 @@ void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset); void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset); void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); size_t rpc_max_payload(struct rpc_clnt *); +void rpc_force_rebind(struct rpc_clnt *); int rpc_ping(struct rpc_clnt *clnt, int flags); static __inline__ diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 25cba94..2789d30 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -538,6 +538,18 @@ size_t rpc_max_payload(struct rpc_clnt *clnt) } EXPORT_SYMBOL(rpc_max_payload); +/** + * rpc_force_rebind - force transport to check that remote port is unchanged + * @clnt: client to rebind + * + */ +void rpc_force_rebind(struct rpc_clnt *clnt) +{ + if (clnt->cl_autobind) + clnt->cl_port = 0; +} +EXPORT_SYMBOL(rpc_force_rebind); + /* * Restart an (async) RPC call. Usually called from within the * exit handler. @@ -853,8 +865,7 @@ call_connect_status(struct rpc_task *task) } /* Something failed: remote service port may have changed */ - if (clnt->cl_autobind) - clnt->cl_port = 0; + rpc_force_rebind(clnt); switch (status) { case -ENOTCONN: @@ -935,8 +946,7 @@ call_status(struct rpc_task *task) break; case -ECONNREFUSED: case -ENOTCONN: - if (clnt->cl_autobind) - clnt->cl_port = 0; + rpc_force_rebind(clnt); task->tk_action = call_bind; break; case -EAGAIN: @@ -995,8 +1005,7 @@ call_timeout(struct rpc_task *task) printk(KERN_NOTICE "%s: server %s not responding, still trying\n", clnt->cl_protname, clnt->cl_server); } - if (clnt->cl_autobind) - clnt->cl_port = 0; + rpc_force_rebind(clnt); retry: clnt->cl_stats->rpcretrans++; -- cgit v1.1 From 922004120b10dcb0ce04b55014168e8a7a8c1a0e Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 3 Jan 2006 09:55:51 +0100 Subject: SUNRPC: transport switch API for setting port number At some point, transport endpoint addresses will no longer be IPv4. To hide the structure of the rpc_xprt's address field from ULPs and port mappers, add an API for setting the port number during an RPC bind operation. Test-plan: Destructive testing (unplugging the network temporarily). Connectathon with UDP and TCP. NFSv2/3 and NFSv4 mounting should be carefully checked. Probably need to rig a server where certain services aren't running, or that returns an error for some typical operation. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/pmap_clnt.c | 8 +++++--- net/sunrpc/xprtsock.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 7885b96..dd86012 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -104,6 +104,7 @@ struct rpc_xprt_ops { void (*set_buffer_size)(struct rpc_xprt *xprt, size_t sndsize, size_t rcvsize); int (*reserve_xprt)(struct rpc_task *task); void (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task); + void (*set_port)(struct rpc_xprt *xprt, unsigned short port); void (*connect)(struct rpc_task *task); void * (*buf_alloc)(struct rpc_task *task, size_t size); void (*buf_free)(struct rpc_task *task); diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c index cad4568..0935adb 100644 --- a/net/sunrpc/pmap_clnt.c +++ b/net/sunrpc/pmap_clnt.c @@ -131,10 +131,13 @@ static void pmap_getport_done(struct rpc_task *task) { struct rpc_clnt *clnt = task->tk_client; + struct rpc_xprt *xprt = task->tk_xprt; struct rpc_portmap *map = clnt->cl_pmap; dprintk("RPC: %4d pmap_getport_done(status %d, port %d)\n", task->tk_pid, task->tk_status, clnt->cl_port); + + xprt->ops->set_port(xprt, 0); if (task->tk_status < 0) { /* Make the calling task exit with an error */ task->tk_action = rpc_exit_task; @@ -142,9 +145,8 @@ pmap_getport_done(struct rpc_task *task) /* Program not registered */ rpc_exit(task, -EACCES); } else { - /* byte-swap port number first */ + xprt->ops->set_port(xprt, clnt->cl_port); clnt->cl_port = htons(clnt->cl_port); - clnt->cl_xprt->addr.sin_port = clnt->cl_port; } spin_lock(&pmap_lock); map->pm_binding = 0; @@ -205,7 +207,7 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileg xprt = xprt_create_proto(proto, srvaddr, NULL); if (IS_ERR(xprt)) return (struct rpc_clnt *)xprt; - xprt->addr.sin_port = htons(RPC_PMAP_PORT); + xprt->ops->set_port(xprt, RPC_PMAP_PORT); if (!privileged) xprt->resvport = 0; diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 51f07c9..3e88930 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -921,6 +921,18 @@ static void xs_udp_timer(struct rpc_task *task) xprt_adjust_cwnd(task, -ETIMEDOUT); } +/** + * xs_set_port - reset the port number in the remote endpoint address + * @xprt: generic transport + * @port: new port number + * + */ +static void xs_set_port(struct rpc_xprt *xprt, unsigned short port) +{ + dprintk("RPC: setting port for xprt %p to %u\n", xprt, port); + xprt->addr.sin_port = htons(port); +} + static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock) { struct sockaddr_in myaddr = { @@ -1161,6 +1173,7 @@ static struct rpc_xprt_ops xs_udp_ops = { .set_buffer_size = xs_udp_set_buffer_size, .reserve_xprt = xprt_reserve_xprt_cong, .release_xprt = xprt_release_xprt_cong, + .set_port = xs_set_port, .connect = xs_connect, .buf_alloc = rpc_malloc, .buf_free = rpc_free, @@ -1175,6 +1188,7 @@ static struct rpc_xprt_ops xs_udp_ops = { static struct rpc_xprt_ops xs_tcp_ops = { .reserve_xprt = xprt_reserve_xprt, .release_xprt = xprt_release_xprt, + .set_port = xs_set_port, .connect = xs_connect, .buf_alloc = rpc_malloc, .buf_free = rpc_free, -- cgit v1.1 From f518e35aec984036903c1003e867f833747a9d79 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 3 Jan 2006 09:55:52 +0100 Subject: SUNRPC: get rid of cl_chatty Clean up: Every ULP that uses the in-kernel RPC client, except the NLM client, sets cl_chatty. There's no reason why NLM shouldn't set it, so just get rid of cl_chatty and always be verbose. Test-plan: Compile with CONFIG_NFS enabled. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/lockd/clntproc.c | 3 +-- fs/lockd/mon.c | 1 - fs/nfs/inode.c | 2 -- fs/nfs/mount_clnt.c | 1 - fs/nfsd/nfs4callback.c | 1 - include/linux/sunrpc/clnt.h | 1 - net/sunrpc/clnt.c | 10 ++++------ net/sunrpc/pmap_clnt.c | 1 - 8 files changed, 5 insertions(+), 15 deletions(-) diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index 816333c..1455240 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -222,8 +222,7 @@ nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl) goto done; } clnt->cl_softrtry = nfssrv->client->cl_softrtry; - clnt->cl_intr = nfssrv->client->cl_intr; - clnt->cl_chatty = nfssrv->client->cl_chatty; + clnt->cl_intr = nfssrv->client->cl_intr; } /* Keep the old signal mask */ diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index 2d144ab..0edc03e 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c @@ -123,7 +123,6 @@ nsm_create(void) if (IS_ERR(clnt)) goto out_err; clnt->cl_softrtry = 1; - clnt->cl_chatty = 1; clnt->cl_oneshot = 1; return clnt; diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 648cb1a..4625479 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -413,7 +413,6 @@ nfs_create_client(struct nfs_server *server, const struct nfs_mount_data *data) clnt->cl_intr = 1; clnt->cl_softrtry = 1; - clnt->cl_chatty = 1; return clnt; @@ -1838,7 +1837,6 @@ static int nfs4_fill_super(struct super_block *sb, struct nfs4_mount_data *data, } clnt->cl_intr = 1; clnt->cl_softrtry = 1; - clnt->cl_chatty = 1; clp->cl_rpcclient = clnt; memcpy(clp->cl_ipaddr, server->ip_addr, sizeof(clp->cl_ipaddr)); nfs_idmap_new(clp); diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c index 0e82617..db99b8f 100644 --- a/fs/nfs/mount_clnt.c +++ b/fs/nfs/mount_clnt.c @@ -82,7 +82,6 @@ mnt_create(char *hostname, struct sockaddr_in *srvaddr, int version, RPC_AUTH_UNIX); if (!IS_ERR(clnt)) { clnt->cl_softrtry = 1; - clnt->cl_chatty = 1; clnt->cl_oneshot = 1; clnt->cl_intr = 1; } diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index cf92008..d828662 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -431,7 +431,6 @@ nfsd4_probe_callback(struct nfs4_client *clp) } clnt->cl_intr = 0; clnt->cl_softrtry = 1; - clnt->cl_chatty = 1; /* Kick rpciod, put the call on the wire. */ diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 3d605765..f147e6b 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -49,7 +49,6 @@ struct rpc_clnt { unsigned int cl_softrtry : 1,/* soft timeouts */ cl_intr : 1,/* interruptible */ - cl_chatty : 1,/* be verbose */ cl_autobind : 1,/* use getport() */ cl_oneshot : 1,/* dispose after use */ cl_dead : 1;/* abandoned */ diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 2789d30..5530ac8 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -957,8 +957,7 @@ call_status(struct rpc_task *task) rpc_exit(task, status); break; default: - if (clnt->cl_chatty) - printk("%s: RPC call returned error %d\n", + printk("%s: RPC call returned error %d\n", clnt->cl_protname, -status); rpc_exit(task, status); break; @@ -993,14 +992,13 @@ call_timeout(struct rpc_task *task) dprintk("RPC: %4d call_timeout (major)\n", task->tk_pid); if (RPC_IS_SOFT(task)) { - if (clnt->cl_chatty) - printk(KERN_NOTICE "%s: server %s not responding, timed out\n", + printk(KERN_NOTICE "%s: server %s not responding, timed out\n", clnt->cl_protname, clnt->cl_server); rpc_exit(task, -EIO); return; } - if (clnt->cl_chatty && !(task->tk_flags & RPC_CALL_MAJORSEEN)) { + if (!(task->tk_flags & RPC_CALL_MAJORSEEN)) { task->tk_flags |= RPC_CALL_MAJORSEEN; printk(KERN_NOTICE "%s: server %s not responding, still trying\n", clnt->cl_protname, clnt->cl_server); @@ -1027,7 +1025,7 @@ call_decode(struct rpc_task *task) dprintk("RPC: %4d call_decode (status %d)\n", task->tk_pid, task->tk_status); - if (clnt->cl_chatty && (task->tk_flags & RPC_CALL_MAJORSEEN)) { + if (task->tk_flags & RPC_CALL_MAJORSEEN) { printk(KERN_NOTICE "%s: server %s OK\n", clnt->cl_protname, clnt->cl_server); task->tk_flags &= ~RPC_CALL_MAJORSEEN; diff --git a/net/sunrpc/pmap_clnt.c b/net/sunrpc/pmap_clnt.c index 0935adb..8139ce6 100644 --- a/net/sunrpc/pmap_clnt.c +++ b/net/sunrpc/pmap_clnt.c @@ -217,7 +217,6 @@ pmap_create(char *hostname, struct sockaddr_in *srvaddr, int proto, int privileg RPC_AUTH_UNIX); if (!IS_ERR(clnt)) { clnt->cl_softrtry = 1; - clnt->cl_chatty = 1; clnt->cl_oneshot = 1; } return clnt; -- cgit v1.1 From cf3fff54a46e1f8fa4cc1deb783172a392077eb0 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:53 +0100 Subject: NFS: Send valid mode bits to the server inode->i_mode contains a lot more than just the mode bits. Make sure that we mask away this extra stuff in SETATTR calls to the server. Signed-off-by: Trond Myklebust --- fs/nfs/nfs3xdr.c | 2 +- fs/nfs/nfs4xdr.c | 2 +- fs/nfs/proc.c | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index 0498bd3..b6c0b50 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c @@ -182,7 +182,7 @@ xdr_encode_sattr(u32 *p, struct iattr *attr) { if (attr->ia_valid & ATTR_MODE) { *p++ = xdr_one; - *p++ = htonl(attr->ia_mode); + *p++ = htonl(attr->ia_mode & S_IALLUGO); } else { *p++ = xdr_zero; } diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 12be1d6..4bbf5ef 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -566,7 +566,7 @@ static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const s } if (iap->ia_valid & ATTR_MODE) { bmval1 |= FATTR4_WORD1_MODE; - WRITE32(iap->ia_mode); + WRITE32(iap->ia_mode & S_IALLUGO); } if (iap->ia_valid & ATTR_UID) { bmval1 |= FATTR4_WORD1_OWNER; diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 6145e82..f5150d7 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -111,6 +111,9 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, }; int status; + /* Mask out the non-modebit related stuff from attr->ia_mode */ + sattr->ia_mode &= S_IALLUGO; + dprintk("NFS call setattr\n"); nfs_fattr_init(fattr); status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0); -- cgit v1.1 From eadb8c147154bff982f02accf31b847a1f142ace Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:54 +0100 Subject: NFS: get rid of some needless code obfuscation in xdr_encode_sattr(). Signed-off-by: Trond Myklebust --- fs/nfs/nfs2xdr.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index 59049e8..7fc0560 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c @@ -146,23 +146,23 @@ xdr_decode_fattr(u32 *p, struct nfs_fattr *fattr) return p; } -#define SATTR(p, attr, flag, field) \ - *p++ = (attr->ia_valid & flag) ? htonl(attr->field) : ~(u32) 0 static inline u32 * xdr_encode_sattr(u32 *p, struct iattr *attr) { - SATTR(p, attr, ATTR_MODE, ia_mode); - SATTR(p, attr, ATTR_UID, ia_uid); - SATTR(p, attr, ATTR_GID, ia_gid); - SATTR(p, attr, ATTR_SIZE, ia_size); + const u32 not_set = __constant_htonl(0xFFFFFFFF); + + *p++ = (attr->ia_valid & ATTR_MODE) ? htonl(attr->ia_mode) : not_set; + *p++ = (attr->ia_valid & ATTR_UID) ? htonl(attr->ia_uid) : not_set; + *p++ = (attr->ia_valid & ATTR_GID) ? htonl(attr->ia_gid) : not_set; + *p++ = (attr->ia_valid & ATTR_SIZE) ? htonl(attr->ia_size) : not_set; if (attr->ia_valid & ATTR_ATIME_SET) { p = xdr_encode_time(p, &attr->ia_atime); } else if (attr->ia_valid & ATTR_ATIME) { p = xdr_encode_current_server_time(p, &attr->ia_atime); } else { - *p++ = ~(u32) 0; - *p++ = ~(u32) 0; + *p++ = not_set; + *p++ = not_set; } if (attr->ia_valid & ATTR_MTIME_SET) { @@ -170,12 +170,11 @@ xdr_encode_sattr(u32 *p, struct iattr *attr) } else if (attr->ia_valid & ATTR_MTIME) { p = xdr_encode_current_server_time(p, &attr->ia_mtime); } else { - *p++ = ~(u32) 0; - *p++ = ~(u32) 0; + *p++ = not_set; + *p++ = not_set; } return p; } -#undef SATTR /* * NFS encode functions -- cgit v1.1 From 632e3bdc5006334cea894d078660b691685e1075 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:55 +0100 Subject: SUNRPC: Ensure client closes the socket when server initiates a close If the server decides to close the RPC socket, we currently don't actually respond until either another RPC call is scheduled, or until xprt_autoclose() gets called by the socket expiry timer (which may be up to 5 minutes later). This patch ensures that xprt_autoclose() is called much sooner if the server closes the socket. Signed-off-by: Trond Myklebust --- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/xprt.c | 33 ++++++++++++++++----------------- net/sunrpc/xprtsock.c | 12 ++++++++++-- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index dd86012..6ef99b1 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -254,6 +254,7 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to); #define XPRT_LOCKED (0) #define XPRT_CONNECTED (1) #define XPRT_CONNECTING (2) +#define XPRT_CLOSE_WAIT (3) static inline void xprt_set_connected(struct rpc_xprt *xprt) { diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 069a6cb..8bc0d5a 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -119,6 +119,17 @@ out_sleep: return 0; } +static void xprt_clear_locked(struct rpc_xprt *xprt) +{ + xprt->snd_task = NULL; + if (!test_bit(XPRT_CLOSE_WAIT, &xprt->state) || xprt->shutdown) { + smp_mb__before_clear_bit(); + clear_bit(XPRT_LOCKED, &xprt->state); + smp_mb__after_clear_bit(); + } else + schedule_work(&xprt->task_cleanup); +} + /* * xprt_reserve_xprt_cong - serialize write access to transports * @task: task that is requesting access to the transport @@ -145,9 +156,7 @@ int xprt_reserve_xprt_cong(struct rpc_task *task) } return 1; } - smp_mb__before_clear_bit(); - clear_bit(XPRT_LOCKED, &xprt->state); - smp_mb__after_clear_bit(); + xprt_clear_locked(xprt); out_sleep: dprintk("RPC: %4d failed to lock transport %p\n", task->tk_pid, xprt); task->tk_timeout = 0; @@ -193,9 +202,7 @@ static void __xprt_lock_write_next(struct rpc_xprt *xprt) return; out_unlock: - smp_mb__before_clear_bit(); - clear_bit(XPRT_LOCKED, &xprt->state); - smp_mb__after_clear_bit(); + xprt_clear_locked(xprt); } static void __xprt_lock_write_next_cong(struct rpc_xprt *xprt) @@ -222,9 +229,7 @@ static void __xprt_lock_write_next_cong(struct rpc_xprt *xprt) return; } out_unlock: - smp_mb__before_clear_bit(); - clear_bit(XPRT_LOCKED, &xprt->state); - smp_mb__after_clear_bit(); + xprt_clear_locked(xprt); } /** @@ -237,10 +242,7 @@ out_unlock: void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task) { if (xprt->snd_task == task) { - xprt->snd_task = NULL; - smp_mb__before_clear_bit(); - clear_bit(XPRT_LOCKED, &xprt->state); - smp_mb__after_clear_bit(); + xprt_clear_locked(xprt); __xprt_lock_write_next(xprt); } } @@ -256,10 +258,7 @@ void xprt_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task) void xprt_release_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task) { if (xprt->snd_task == task) { - xprt->snd_task = NULL; - smp_mb__before_clear_bit(); - clear_bit(XPRT_LOCKED, &xprt->state); - smp_mb__after_clear_bit(); + xprt_clear_locked(xprt); __xprt_lock_write_next_cong(xprt); } } diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 3e88930..c458f8d 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -425,7 +425,7 @@ static void xs_close(struct rpc_xprt *xprt) struct sock *sk = xprt->inet; if (!sk) - return; + goto clear_close_wait; dprintk("RPC: xs_close xprt %p\n", xprt); @@ -442,6 +442,10 @@ static void xs_close(struct rpc_xprt *xprt) sk->sk_no_check = 0; sock_release(sock); +clear_close_wait: + smp_mb__before_clear_bit(); + clear_bit(XPRT_CLOSE_WAIT, &xprt->state); + smp_mb__after_clear_bit(); } /** @@ -801,9 +805,13 @@ static void xs_tcp_state_change(struct sock *sk) case TCP_SYN_SENT: case TCP_SYN_RECV: break; + case TCP_CLOSE_WAIT: + /* Try to schedule an autoclose RPC calls */ + set_bit(XPRT_CLOSE_WAIT, &xprt->state); + if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) + schedule_work(&xprt->task_cleanup); default: xprt_disconnect(xprt); - break; } out: read_unlock(&sk->sk_callback_lock); -- cgit v1.1 From 0065db328533c390fbfb0fe0c46bcf9a278fb99e Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:56 +0100 Subject: SUNRPC: Clean up xprt_destroy() We ought never to be calling xprt_destroy() if there are still active rpc_tasks. Optimise away the broken code that attempts to "fix" that case. Signed-off-by: Trond Myklebust --- net/sunrpc/xprt.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 8bc0d5a..8ff2c8a 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -534,10 +534,6 @@ void xprt_connect(struct rpc_task *task) dprintk("RPC: %4d xprt_connect xprt %p %s connected\n", task->tk_pid, xprt, (xprt_connected(xprt) ? "is" : "is not")); - if (xprt->shutdown) { - task->tk_status = -EIO; - return; - } if (!xprt->addr.sin_port) { task->tk_status = -EIO; return; @@ -686,9 +682,6 @@ int xprt_prepare_transmit(struct rpc_task *task) dprintk("RPC: %4d xprt_prepare_transmit\n", task->tk_pid); - if (xprt->shutdown) - return -EIO; - spin_lock_bh(&xprt->transport_lock); if (req->rq_received && !req->rq_bytes_sent) { err = req->rq_received; @@ -813,11 +806,9 @@ void xprt_reserve(struct rpc_task *task) struct rpc_xprt *xprt = task->tk_xprt; task->tk_status = -EIO; - if (!xprt->shutdown) { - spin_lock(&xprt->reserve_lock); - do_xprt_reserve(task); - spin_unlock(&xprt->reserve_lock); - } + spin_lock(&xprt->reserve_lock); + do_xprt_reserve(task); + spin_unlock(&xprt->reserve_lock); } static inline u32 xprt_alloc_xid(struct rpc_xprt *xprt) @@ -864,7 +855,7 @@ void xprt_release(struct rpc_task *task) if (!list_empty(&req->rq_list)) list_del(&req->rq_list); xprt->last_used = jiffies; - if (list_empty(&xprt->recv) && !xprt->shutdown) + if (list_empty(&xprt->recv)) mod_timer(&xprt->timer, xprt->last_used + xprt->idle_timeout); spin_unlock_bh(&xprt->transport_lock); @@ -976,16 +967,6 @@ struct rpc_xprt *xprt_create_proto(int proto, struct sockaddr_in *sap, struct rp return xprt; } -static void xprt_shutdown(struct rpc_xprt *xprt) -{ - xprt->shutdown = 1; - rpc_wake_up(&xprt->sending); - rpc_wake_up(&xprt->resend); - xprt_wake_pending_tasks(xprt, -EIO); - rpc_wake_up(&xprt->backlog); - del_timer_sync(&xprt->timer); -} - /** * xprt_destroy - destroy an RPC transport, killing off all requests. * @xprt: transport to destroy @@ -994,7 +975,8 @@ static void xprt_shutdown(struct rpc_xprt *xprt) int xprt_destroy(struct rpc_xprt *xprt) { dprintk("RPC: destroying transport %p\n", xprt); - xprt_shutdown(xprt); + xprt->shutdown = 1; + del_timer_sync(&xprt->timer); xprt->ops->destroy(xprt); kfree(xprt); -- cgit v1.1 From 58df095b732529ade8f4051b41d7c29731afecd6 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:57 +0100 Subject: NFSv4: Allow entries in the idmap cache to expire If someone changes the uid/gid mapping in userland, then we do eventually want those changes to be propagated to the kernel. Currently the kernel assumes that it may cache entries forever. Add an expiration time + garbage collector for idmap entries. Signed-off-by: Trond Myklebust --- Documentation/kernel-parameters.txt | 4 ++++ fs/nfs/idmap.c | 9 +++++++++ fs/nfs/inode.c | 14 ++++++++++++++ fs/nfs/sysctl.c | 10 ++++++++++ include/linux/nfs_idmap.h | 2 ++ 5 files changed, 39 insertions(+) diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 309c9ce..a482fde 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt @@ -914,6 +914,10 @@ running once the system is up. [NFS] set the TCP port on which the NFSv4 callback channel should listen. + nfs.idmap_cache_timeout= + [NFS] set the maximum lifetime for idmapper cache + entries. + nmi_watchdog= [KNL,BUGS=IA-32] Debugging features for SMP kernels no387 [BUGS=IA-32] Tells the kernel to use the 387 maths diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c index ffb8df9..821edd3 100644 --- a/fs/nfs/idmap.c +++ b/fs/nfs/idmap.c @@ -54,7 +54,11 @@ #define IDMAP_HASH_SZ 128 +/* Default cache timeout is 10 minutes */ +unsigned int nfs_idmap_cache_timeout = 600 * HZ; + struct idmap_hashent { + unsigned long ih_expires; __u32 ih_id; int ih_namelen; char ih_name[IDMAP_NAMESZ]; @@ -149,6 +153,8 @@ idmap_lookup_name(struct idmap_hashtable *h, const char *name, size_t len) if (he->ih_namelen != len || memcmp(he->ih_name, name, len) != 0) return NULL; + if (time_after(jiffies, he->ih_expires)) + return NULL; return he; } @@ -164,6 +170,8 @@ idmap_lookup_id(struct idmap_hashtable *h, __u32 id) struct idmap_hashent *he = idmap_id_hash(h, id); if (he->ih_id != id || he->ih_namelen == 0) return NULL; + if (time_after(jiffies, he->ih_expires)) + return NULL; return he; } @@ -192,6 +200,7 @@ idmap_update_entry(struct idmap_hashent *he, const char *name, memcpy(he->ih_name, name, namelen); he->ih_name[namelen] = '\0'; he->ih_namelen = namelen; + he->ih_expires = jiffies + nfs_idmap_cache_timeout; } /* diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 4625479..e7bd0d9 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -2050,6 +2050,20 @@ static int param_set_port(const char *val, struct kernel_param *kp) module_param_call(callback_tcpport, param_set_port, param_get_int, &nfs_callback_set_tcpport, 0644); +static int param_set_idmap_timeout(const char *val, struct kernel_param *kp) +{ + char *endp; + int num = simple_strtol(val, &endp, 0); + int jif = num * HZ; + if (endp == val || *endp || num < 0 || jif < num) + return -EINVAL; + *((int *)kp->arg) = jif; + return 0; +} + +module_param_call(idmap_cache_timeout, param_set_idmap_timeout, param_get_int, + &nfs_idmap_cache_timeout, 0644); + #define nfs4_init_once(nfsi) \ do { \ INIT_LIST_HEAD(&(nfsi)->open_states); \ diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c index fdc64b5..4c486eb 100644 --- a/fs/nfs/sysctl.c +++ b/fs/nfs/sysctl.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "callback.h" @@ -35,6 +36,15 @@ static ctl_table nfs_cb_sysctls[] = { .extra1 = (int *)&nfs_set_port_min, .extra2 = (int *)&nfs_set_port_max, }, + { + .ctl_name = CTL_UNNUMBERED, + .procname = "idmap_cache_timeout", + .data = &nfs_idmap_cache_timeout, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec_jiffies, + .strategy = &sysctl_jiffies, + }, #endif { .ctl_name = 0 } }; diff --git a/include/linux/nfs_idmap.h b/include/linux/nfs_idmap.h index a0f1f25..102e560 100644 --- a/include/linux/nfs_idmap.h +++ b/include/linux/nfs_idmap.h @@ -71,6 +71,8 @@ int nfs_map_name_to_uid(struct nfs4_client *, const char *, size_t, __u32 *); int nfs_map_group_to_gid(struct nfs4_client *, const char *, size_t, __u32 *); int nfs_map_uid_to_name(struct nfs4_client *, __u32, char *); int nfs_map_gid_to_group(struct nfs4_client *, __u32, char *); + +extern unsigned int nfs_idmap_cache_timeout; #endif /* __KERNEL__ */ #endif /* NFS_IDMAP_H */ -- cgit v1.1 From 26c78e156b1d1b2387ec33b5f2fb62d6e0a186a3 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 3 Jan 2006 09:55:58 +0100 Subject: NFSv4: Fix an Oops in nfs_do_expire_all_delegations If the loop errors, we need to exit. Signed-off-by: Trond Myklebust --- fs/nfs/delegation.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 66cc720..c6f07c1 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -236,7 +236,6 @@ int nfs_do_expire_all_delegations(void *ptr) struct nfs4_client *clp = ptr; struct nfs_delegation *delegation; struct inode *inode; - int err = 0; allow_signal(SIGKILL); restart: @@ -250,10 +249,9 @@ restart: if (inode == NULL) continue; spin_unlock(&clp->cl_lock); - err = nfs_inode_return_delegation(inode); + nfs_inode_return_delegation(inode); iput(inode); - if (!err) - goto restart; + goto restart; } out: spin_unlock(&clp->cl_lock); -- cgit v1.1 From 9eed129bbde80cbd7ffeacaa1555ba1e0c9a0997 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:56:00 +0100 Subject: SUNRPC: Update the spkm3 code to use the make_checksum interface Also update the tokenlen calculations to accomodate g_token_size(). Signed-off-by: Andy Adamson Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- include/linux/sunrpc/gss_spkm3.h | 2 +- net/sunrpc/auth_gss/gss_spkm3_seal.c | 11 +++++------ net/sunrpc/auth_gss/gss_spkm3_token.c | 3 ++- net/sunrpc/auth_gss/gss_spkm3_unseal.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/sunrpc/gss_spkm3.h b/include/linux/sunrpc/gss_spkm3.h index 0beb2cf..336e218 100644 --- a/include/linux/sunrpc/gss_spkm3.h +++ b/include/linux/sunrpc/gss_spkm3.h @@ -48,7 +48,7 @@ u32 spkm3_read_token(struct spkm3_ctx *ctx, struct xdr_netobj *read_token, struc #define CKSUMTYPE_RSA_MD5 0x0007 s32 make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body, - struct xdr_netobj *cksum); + int body_offset, struct xdr_netobj *cksum); void asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits); int decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen); diff --git a/net/sunrpc/auth_gss/gss_spkm3_seal.c b/net/sunrpc/auth_gss/gss_spkm3_seal.c index d1e12b2..86fbf7c 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_seal.c +++ b/net/sunrpc/auth_gss/gss_spkm3_seal.c @@ -59,7 +59,7 @@ spkm3_make_token(struct spkm3_ctx *ctx, char tokhdrbuf[25]; struct xdr_netobj md5cksum = {.len = 0, .data = NULL}; struct xdr_netobj mic_hdr = {.len = 0, .data = tokhdrbuf}; - int tmsglen, tokenlen = 0; + int tokenlen = 0; unsigned char *ptr; s32 now; int ctxelen = 0, ctxzbit = 0; @@ -92,24 +92,23 @@ spkm3_make_token(struct spkm3_ctx *ctx, } if (toktype == SPKM_MIC_TOK) { - tmsglen = 0; /* Calculate checksum over the mic-header */ asn1_bitstring_len(&ctx->ctx_id, &ctxelen, &ctxzbit); spkm3_mic_header(&mic_hdr.data, &mic_hdr.len, ctx->ctx_id.data, ctxelen, ctxzbit); if (make_checksum(checksum_type, mic_hdr.data, mic_hdr.len, - text, &md5cksum)) + text, 0, &md5cksum)) goto out_err; asn1_bitstring_len(&md5cksum, &md5elen, &md5zbit); - tokenlen = 10 + ctxelen + 1 + 2 + md5elen + 1; + tokenlen = 10 + ctxelen + 1 + md5elen + 1; /* Create token header using generic routines */ - token->len = g_token_size(&ctx->mech_used, tokenlen + tmsglen); + token->len = g_token_size(&ctx->mech_used, tokenlen); ptr = token->data; - g_make_token_header(&ctx->mech_used, tokenlen + tmsglen, &ptr); + g_make_token_header(&ctx->mech_used, tokenlen, &ptr); spkm3_make_mic_token(&ptr, tokenlen, &mic_hdr, &md5cksum, md5elen, md5zbit); } else if (toktype == SPKM_WRAP_TOK) { /* Not Supported */ diff --git a/net/sunrpc/auth_gss/gss_spkm3_token.c b/net/sunrpc/auth_gss/gss_spkm3_token.c index 1f82457..af0d7ce 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_token.c +++ b/net/sunrpc/auth_gss/gss_spkm3_token.c @@ -182,6 +182,7 @@ spkm3_mic_header(unsigned char **hdrbuf, unsigned int *hdrlen, unsigned char *ct * *tokp points to the beginning of the SPKM_MIC token described * in rfc 2025, section 3.2.1: * + * toklen is the inner token length */ void spkm3_make_mic_token(unsigned char **tokp, int toklen, struct xdr_netobj *mic_hdr, struct xdr_netobj *md5cksum, int md5elen, int md5zbit) @@ -189,7 +190,7 @@ spkm3_make_mic_token(unsigned char **tokp, int toklen, struct xdr_netobj *mic_hd unsigned char *ict = *tokp; *(u8 *)ict++ = 0xa4; - *(u8 *)ict++ = toklen - 2; + *(u8 *)ict++ = toklen; memcpy(ict, mic_hdr->data, mic_hdr->len); ict += mic_hdr->len; diff --git a/net/sunrpc/auth_gss/gss_spkm3_unseal.c b/net/sunrpc/auth_gss/gss_spkm3_unseal.c index 241d5b3..96851b0 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_unseal.c +++ b/net/sunrpc/auth_gss/gss_spkm3_unseal.c @@ -95,7 +95,7 @@ spkm3_read_token(struct spkm3_ctx *ctx, ret = GSS_S_DEFECTIVE_TOKEN; code = make_checksum(CKSUMTYPE_RSA_MD5, ptr + 2, mic_hdrlen + 2, - message_buffer, &md5cksum); + message_buffer, 0, &md5cksum); if (code) goto out; -- cgit v1.1 From 42181d4bafe9047d0cd7f92fc11d79496bd95034 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:56:01 +0100 Subject: SUNRPC: Make spkm3 report unsupported encryption types Print messages when an unsupported encrytion algorthm is requested or there is an error locating a supported algorthm. Signed-off-by: Kevin Coffman Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- net/sunrpc/auth_gss/gss_spkm3_mech.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/auth_gss/gss_spkm3_mech.c b/net/sunrpc/auth_gss/gss_spkm3_mech.c index 39b3edc..5840080 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_mech.c +++ b/net/sunrpc/auth_gss/gss_spkm3_mech.c @@ -111,14 +111,18 @@ get_key(const void *p, const void *end, struct crypto_tfm **res, int *resalg) setkey = 0; break; default: - dprintk("RPC: SPKM3 get_key: unsupported algorithm %d", *resalg); + dprintk("gss_spkm3_mech: unsupported algorithm %d\n", *resalg); goto out_err_free_key; } - if (!(*res = crypto_alloc_tfm(alg_name, alg_mode))) + if (!(*res = crypto_alloc_tfm(alg_name, alg_mode))) { + printk("gss_spkm3_mech: unable to initialize crypto algorthm %s\n", alg_name); goto out_err_free_key; + } if (setkey) { - if (crypto_cipher_setkey(*res, key.data, key.len)) + if (crypto_cipher_setkey(*res, key.data, key.len)) { + printk("gss_spkm3_mech: error setting key for crypto algorthm %s\n", alg_name); goto out_err_free_tfm; + } } if(key.len > 0) -- cgit v1.1 From 9e56904e41e242169007e69d9916059dab995d90 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Tue, 3 Jan 2006 09:56:01 +0100 Subject: SUNRPC: Make krb5 report unsupported encryption types Print messages when an unsupported encrytion algorthm is requested or there is an error locating a supported algorthm. Signed-off-by: Kevin Coffman Signed-off-by: J. Bruce Fields Signed-off-by: Trond Myklebust --- net/sunrpc/auth_gss/gss_krb5_mech.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index 5f1f806..129e2bd 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c @@ -97,13 +97,17 @@ get_key(const void *p, const void *end, struct crypto_tfm **res) alg_mode = CRYPTO_TFM_MODE_CBC; break; default: - dprintk("RPC: get_key: unsupported algorithm %d\n", alg); + printk("gss_kerberos_mech: unsupported algorithm %d\n", alg); goto out_err_free_key; } - if (!(*res = crypto_alloc_tfm(alg_name, alg_mode))) + if (!(*res = crypto_alloc_tfm(alg_name, alg_mode))) { + printk("gss_kerberos_mech: unable to initialize crypto algorithm %s\n", alg_name); goto out_err_free_key; - if (crypto_cipher_setkey(*res, key.data, key.len)) + } + if (crypto_cipher_setkey(*res, key.data, key.len)) { + printk("gss_kerberos_mech: error setting key for crypto algorithm %s\n", alg_name); goto out_err_free_tfm; + } kfree(key.data); return p; -- cgit v1.1 From 367cb704212cd0c9273ba2b1e62523139210563b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 6 Jan 2006 21:17:50 +0100 Subject: kbuild: un-stringnify KBUILD_MODNAME Now when kbuild passes KBUILD_MODNAME with "" do not __stringify it when used. Remove __stringnify for all users. This also fixes the output of: $ ls -l /sys/module/ drwxr-xr-x 4 root root 0 2006-01-05 14:24 pcmcia drwxr-xr-x 4 root root 0 2006-01-05 14:24 pcmcia_core drwxr-xr-x 3 root root 0 2006-01-05 14:24 "processor" drwxr-xr-x 3 root root 0 2006-01-05 14:24 "psmouse" The quoting of the module names will be gone again. Thanks to GregKH + Kay Sievers for reproting this. Signed-off-by: Sam Ravnborg --- drivers/media/dvb/cinergyT2/cinergyT2.c | 2 +- drivers/media/dvb/ttpci/budget.h | 2 +- drivers/media/video/tda9840.c | 2 +- drivers/media/video/tea6415c.c | 2 +- drivers/media/video/tea6420.c | 2 +- include/linux/moduleparam.h | 2 +- include/media/saa7146.h | 6 +++--- net/ipv4/netfilter/ip_nat_ftp.c | 2 +- net/ipv4/netfilter/ip_nat_irc.c | 2 +- security/capability.c | 6 ++---- 10 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index b996fb5..1d69bf0 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c @@ -60,7 +60,7 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); #define dprintk(level, args...) \ do { \ if ((debug & level)) { \ - printk("%s: %s(): ", __stringify(KBUILD_MODNAME), \ + printk("%s: %s(): ", KBUILD_MODNAME, \ __FUNCTION__); \ printk(args); } \ } while (0) diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h index fdaa331..c8d48cf 100644 --- a/drivers/media/dvb/ttpci/budget.h +++ b/drivers/media/dvb/ttpci/budget.h @@ -19,7 +19,7 @@ extern int budget_debug; #endif #define dprintk(level,args...) \ - do { if ((budget_debug & level)) { printk("%s: %s(): ",__stringify(KBUILD_MODNAME), __FUNCTION__); printk(args); } } while (0) + do { if ((budget_debug & level)) { printk("%s: %s(): ", KBUILD_MODNAME, __FUNCTION__); printk(args); } } while (0) struct budget_info { char *name; diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index 1794686..0cb5c7e 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c @@ -34,7 +34,7 @@ static int debug = 0; /* insmod parameter */ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); #define dprintk(args...) \ - do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0) + do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) #define SWITCH 0x00 #define LEVEL_ADJUST 0x02 diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index ee36883..09149da 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c @@ -36,7 +36,7 @@ static int debug = 0; /* insmod parameter */ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); #define dprintk(args...) \ - do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0) + do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) #define TEA6415C_NUM_INPUTS 8 #define TEA6415C_NUM_OUTPUTS 6 diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 17975c1..e908f91 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c @@ -36,7 +36,7 @@ static int debug = 0; /* insmod parameter */ module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); #define dprintk(args...) \ - do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0) + do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 368ec8e..b5c98c4 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -10,7 +10,7 @@ #ifdef MODULE #define MODULE_PARAM_PREFIX /* empty */ #else -#define MODULE_PARAM_PREFIX __stringify(KBUILD_MODNAME) "." +#define MODULE_PARAM_PREFIX KBUILD_MODNAME "." #endif #ifdef MODULE diff --git a/include/media/saa7146.h b/include/media/saa7146.h index e5be2b9..2bc634f 100644 --- a/include/media/saa7146.h +++ b/include/media/saa7146.h @@ -21,14 +21,14 @@ extern unsigned int saa7146_debug; -//#define DEBUG_PROLOG printk("(0x%08x)(0x%08x) %s: %s(): ",(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,RPS_ADDR0))),(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,IER))),__stringify(KBUILD_MODNAME),__FUNCTION__) +//#define DEBUG_PROLOG printk("(0x%08x)(0x%08x) %s: %s(): ",(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,RPS_ADDR0))),(dev==0?-1:(dev->mem==0?-1:saa7146_read(dev,IER))),KBUILD_MODNAME,__FUNCTION__) #ifndef DEBUG_VARIABLE #define DEBUG_VARIABLE saa7146_debug #endif -#define DEBUG_PROLOG printk("%s: %s(): ",__stringify(KBUILD_MODNAME),__FUNCTION__) -#define INFO(x) { printk("%s: ",__stringify(KBUILD_MODNAME)); printk x; } +#define DEBUG_PROLOG printk("%s: %s(): ",KBUILD_MODNAME,__FUNCTION__) +#define INFO(x) { printk("%s: ",KBUILD_MODNAME); printk x; } #define ERR(x) { DEBUG_PROLOG; printk x; } diff --git a/net/ipv4/netfilter/ip_nat_ftp.c b/net/ipv4/netfilter/ip_nat_ftp.c index d83757a..b8daab3 100644 --- a/net/ipv4/netfilter/ip_nat_ftp.c +++ b/net/ipv4/netfilter/ip_nat_ftp.c @@ -171,7 +171,7 @@ static int __init init(void) /* Prior to 2.6.11, we had a ports param. No longer, but don't break users. */ static int warn_set(const char *val, struct kernel_param *kp) { - printk(KERN_INFO __stringify(KBUILD_MODNAME) + printk(KERN_INFO KBUILD_MODNAME ": kernel >= 2.6.10 only uses 'ports' for conntrack modules\n"); return 0; } diff --git a/net/ipv4/netfilter/ip_nat_irc.c b/net/ipv4/netfilter/ip_nat_irc.c index de31942..461c833 100644 --- a/net/ipv4/netfilter/ip_nat_irc.c +++ b/net/ipv4/netfilter/ip_nat_irc.c @@ -113,7 +113,7 @@ static int __init init(void) /* Prior to 2.6.11, we had a ports param. No longer, but don't break users. */ static int warn_set(const char *val, struct kernel_param *kp) { - printk(KERN_INFO __stringify(KBUILD_MODNAME) + printk(KERN_INFO KBUILD_MODNAME ": kernel >= 2.6.10 only uses 'ports' for conntrack modules\n"); return 0; } diff --git a/security/capability.c b/security/capability.c index ec18d60..f9b35cc 100644 --- a/security/capability.c +++ b/security/capability.c @@ -49,8 +49,6 @@ static struct security_operations capability_ops = { .vm_enough_memory = cap_vm_enough_memory, }; -#define MY_NAME __stringify(KBUILD_MODNAME) - /* flag to keep track of how we were registered */ static int secondary; @@ -67,7 +65,7 @@ static int __init capability_init (void) /* register ourselves with the security framework */ if (register_security (&capability_ops)) { /* try registering with primary module */ - if (mod_reg_security (MY_NAME, &capability_ops)) { + if (mod_reg_security (KBUILD_MODNAME, &capability_ops)) { printk (KERN_INFO "Failure registering capabilities " "with primary security module.\n"); return -EINVAL; @@ -85,7 +83,7 @@ static void __exit capability_exit (void) return; /* remove ourselves from the security framework */ if (secondary) { - if (mod_unreg_security (MY_NAME, &capability_ops)) + if (mod_unreg_security (KBUILD_MODNAME, &capability_ops)) printk (KERN_INFO "Failure unregistering capabilities " "with primary module.\n"); return; -- cgit v1.1 From 37193147991a53b2e9f573d0ec47f63a2d4de8dc Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Mon, 2 Jan 2006 11:25:30 +0100 Subject: kconfig: fix gconfig with POSIXLY_CORRECT=1 This patch fixed "make gconfig" with POSIXLY_CORRECT=1 set. This issue was reported by Jens Elkner in kernel Bugzilla #2919. Signed-off-by: Adrian Bunk Signed-off-by: Sam Ravnborg --- scripts/kconfig/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 3d7f1ac..5760e05 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -133,8 +133,8 @@ HOSTCFLAGS_zconf.tab.o := -I$(src) HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK -HOSTLOADLIBES_gconf = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --libs` -HOSTCFLAGS_gconf.o = `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --cflags` \ +HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` +HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ -D LKC_DIRECT_LINK $(obj)/qconf.o: $(obj)/.tmp_qtcheck @@ -193,8 +193,8 @@ ifeq ($(gconf-target),1) # GTK needs some extra effort, too... $(obj)/.tmp_gtkcheck: - @if `pkg-config gtk+-2.0 gmodule-2.0 libglade-2.0 --exists`; then \ - if `pkg-config gtk+-2.0 --atleast-version=2.0.0`; then \ + @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \ + if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ touch $@; \ else \ echo "*"; \ -- cgit v1.1 From dbbc0988288d9643044e8bd8c7e7de70016ecd23 Mon Sep 17 00:00:00 2001 From: Kris Katterjohn Date: Fri, 6 Jan 2006 13:05:58 -0800 Subject: [NET]: Use newer is_multicast_ether_addr() in some files This uses is_multicast_ether_addr() because it has recently been changed to do the same thing these seperate tests are doing. Signed-off-by: Kris Katterjohn Signed-off-by: David S. Miller --- net/atm/br2684.c | 2 +- net/bridge/br_input.c | 2 +- net/ethernet/eth.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/atm/br2684.c b/net/atm/br2684.c index 72f3f7b..bdb4d89 100644 --- a/net/atm/br2684.c +++ b/net/atm/br2684.c @@ -295,7 +295,7 @@ static inline __be16 br_type_trans(struct sk_buff *skb, struct net_device *dev) unsigned char *rawp; eth = eth_hdr(skb); - if (*eth->h_dest & 1) { + if (is_multicast_ether_addr(eth->h_dest)) { if (memcmp(eth->h_dest, dev->broadcast, ETH_ALEN) == 0) skb->pkt_type = PACKET_BROADCAST; else diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index c387852..e3a73ce 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -68,7 +68,7 @@ int br_handle_frame_finish(struct sk_buff *skb) } } - if (dest[0] & 1) { + if (is_multicast_ether_addr(dest)) { br_flood_forward(br, skb, !passedup); if (!passedup) br_pass_frame_up(br, skb); diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 9f4dbeb..9890fd9 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -163,7 +163,7 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) skb_pull(skb,ETH_HLEN); eth = eth_hdr(skb); - if (*eth->h_dest&1) { + if (is_multicast_ether_addr(eth->h_dest)) { if (!compare_ether_addr(eth->h_dest, dev->broadcast)) skb->pkt_type = PACKET_BROADCAST; else -- cgit v1.1 From 4bad4dc919573dbe9a5b41dd9edff279e99822d7 Mon Sep 17 00:00:00 2001 From: Kris Katterjohn Date: Fri, 6 Jan 2006 13:08:20 -0800 Subject: [NET]: Change sk_run_filter()'s return type in net/core/filter.c It should return an unsigned value, and fix sk_filter() as well. Signed-off-by: Kris Katterjohn Signed-off-by: David S. Miller --- include/linux/filter.h | 2 +- include/net/sock.h | 4 ++-- net/core/filter.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index 3ba843c..c6cb8f0 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -143,7 +143,7 @@ static inline unsigned int sk_filter_len(struct sk_filter *fp) struct sk_buff; struct sock; -extern int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen); +extern unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen); extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); extern int sk_chk_filter(struct sock_filter *filter, int flen); #endif /* __KERNEL__ */ diff --git a/include/net/sock.h b/include/net/sock.h index 6961700..1806e5b 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -856,8 +856,8 @@ static inline int sk_filter(struct sock *sk, struct sk_buff *skb, int needlock) filter = sk->sk_filter; if (filter) { - int pkt_len = sk_run_filter(skb, filter->insns, - filter->len); + unsigned int pkt_len = sk_run_filter(skb, filter->insns, + filter->len); if (!pkt_len) err = -EPERM; else diff --git a/net/core/filter.c b/net/core/filter.c index 8964d34..9eb9d00 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -75,7 +75,7 @@ static inline void *load_pointer(struct sk_buff *skb, int k, * len is the number of filter blocks in the array. */ -int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen) +unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen) { struct sock_filter *fentry; /* We walk down these */ void *ptr; @@ -241,9 +241,9 @@ load_b: A = X; continue; case BPF_RET|BPF_K: - return ((unsigned int)fentry->k); + return fentry->k; case BPF_RET|BPF_A: - return ((unsigned int)A); + return A; case BPF_ST: mem[fentry->k] = A; continue; -- cgit v1.1 From a20a8554796bc4e28879beabd0db4bf3ce77b686 Mon Sep 17 00:00:00 2001 From: Shaun Pereira Date: Fri, 6 Jan 2006 13:11:35 -0800 Subject: [X25]: Fix for broken x25 module. When a user-space server application calls bind on a socket, then in kernel space this bound socket is considered 'x25-linked' and the SOCK_ZAPPED flag is unset.(As in x25_bind()/af_x25.c). Now when a user-space client application attempts to connect to the server on the listening socket, if the kernel accepts this in-coming call, then it returns a new socket to userland and attempts to reply to the caller. The reply/x25_sendmsg() will fail, because the new socket created on call-accept has its SOCK_ZAPPED flag set by x25_make_new(). (sock_init_data() called by x25_alloc_socket() called by x25_make_new() sets the flag to SOCK_ZAPPED)). Fix: Using the sock_copy_flag() routine available in sock.h fixes this. Tested on 32 and 64 bit kernels with x25 over tcp. Signed-off-by: Shaun Pereira Signed-off-by: Andrew Morton Signed-off-by: David S. Miller --- net/x25/af_x25.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 16459c7..bfabaf9 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -540,12 +540,7 @@ static struct sock *x25_make_new(struct sock *osk) sk->sk_state = TCP_ESTABLISHED; sk->sk_sleep = osk->sk_sleep; sk->sk_backlog_rcv = osk->sk_backlog_rcv; - - if (sock_flag(osk, SOCK_ZAPPED)) - sock_set_flag(sk, SOCK_ZAPPED); - - if (sock_flag(osk, SOCK_DBG)) - sock_set_flag(sk, SOCK_DBG); + sock_copy_flags(sk, osk); ox25 = x25_sk(osk); x25->t21 = ox25->t21; -- cgit v1.1 From ee02b3a613a692a40e0f48a25d9d60cc751ebbe5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 6 Jan 2006 13:13:29 -0800 Subject: [BRIDGE] netfilter: vlan + hw checksum = bug? It looks like the bridge netfilter code does not correctly update the hardware checksum after popping off the VLAN header. This is by inspection, I have *not* tested this. To test you would need to set up a filtering bridge with vlans and a device the does hardware receive checksum (skge, or sungem) Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- net/bridge/br_netfilter.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index 223f827..7cac3fb 100644 --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c @@ -394,8 +394,9 @@ inhdr_error: * target in particular. Save the original destination IP * address to be able to detect DNAT afterwards. */ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb, - const struct net_device *in, const struct net_device *out, - int (*okfn)(struct sk_buff *)) + const struct net_device *in, + const struct net_device *out, + int (*okfn)(struct sk_buff *)) { struct iphdr *iph; __u32 len; @@ -412,8 +413,10 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb, goto out; if (skb->protocol == __constant_htons(ETH_P_8021Q)) { + u8 *vhdr = skb->data; skb_pull(skb, VLAN_HLEN); - (skb)->nh.raw += VLAN_HLEN; + skb_postpull_rcsum(skb, vhdr, VLAN_HLEN); + skb->nh.raw += VLAN_HLEN; } return br_nf_pre_routing_ipv6(hook, skb, in, out, okfn); } @@ -429,8 +432,10 @@ static unsigned int br_nf_pre_routing(unsigned int hook, struct sk_buff **pskb, goto out; if (skb->protocol == __constant_htons(ETH_P_8021Q)) { + u8 *vhdr = skb->data; skb_pull(skb, VLAN_HLEN); - (skb)->nh.raw += VLAN_HLEN; + skb_postpull_rcsum(skb, vhdr, VLAN_HLEN); + skb->nh.raw += VLAN_HLEN; } if (!pskb_may_pull(skb, sizeof(struct iphdr))) -- cgit v1.1 From 3cbc4ab58f79853740bf21f3736913d223ee50d4 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 6 Jan 2006 13:15:11 -0800 Subject: [NETFILTER]: ipt_helper.c needs linux/interrupt.h From: Joe Signed-off-by: David S. Miller --- net/ipv4/netfilter/ipt_helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/netfilter/ipt_helper.c b/net/ipv4/netfilter/ipt_helper.c index bf14e1c..aef649e 100644 --- a/net/ipv4/netfilter/ipt_helper.c +++ b/net/ipv4/netfilter/ipt_helper.c @@ -13,6 +13,7 @@ #include #include #include +#include #if defined(CONFIG_IP_NF_CONNTRACK) || defined(CONFIG_IP_NF_CONNTRACK_MODULE) #include #include -- cgit v1.1 From 69549ddd2f894c4cead50ee2b60cc02990c389ad Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Fri, 6 Jan 2006 13:19:31 -0800 Subject: [PKTGEN]: Adds missing __init. pktgen_find_thread() and pktgen_create_thread() are only called at initialization time. Signed-off-by: Luiz Capitulino Signed-off-by: David S. Miller --- net/core/pktgen.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 06cad2d..631056d 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -473,7 +473,6 @@ static char version[] __initdata = VERSION; static int pktgen_remove_device(struct pktgen_thread* t, struct pktgen_dev *i); static int pktgen_add_device(struct pktgen_thread* t, const char* ifname); -static struct pktgen_thread* pktgen_find_thread(const char* name); static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread* t, const char* ifname); static int pktgen_device_event(struct notifier_block *, unsigned long, void *); static void pktgen_run_all_threads(void); @@ -2883,7 +2882,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char* ifname) return add_dev_to_thread(t, pkt_dev); } -static struct pktgen_thread *pktgen_find_thread(const char* name) +static struct pktgen_thread * __init pktgen_find_thread(const char* name) { struct pktgen_thread *t = NULL; @@ -2900,7 +2899,7 @@ static struct pktgen_thread *pktgen_find_thread(const char* name) return t; } -static int pktgen_create_thread(const char* name, int cpu) +static int __init pktgen_create_thread(const char* name, int cpu) { struct pktgen_thread *t = NULL; struct proc_dir_entry *pe; -- cgit v1.1 From 5f8ac64b15172c7ced7d7990eb28342092bc751b Mon Sep 17 00:00:00 2001 From: Trent Jaeger Date: Fri, 6 Jan 2006 13:22:39 -0800 Subject: [LSM-IPSec]: Corrections to LSM-IPSec Nethooks This patch contains two corrections to the LSM-IPsec Nethooks patches previously applied. (1) free a security context on a failed insert via xfrm_user interface in xfrm_add_policy. Memory leak. (2) change the authorization of the allocation of a security context in a xfrm_policy or xfrm_state from both relabelfrom and relabelto to setcontext. Signed-off-by: Trent Jaeger Signed-off-by: David S. Miller --- net/xfrm/xfrm_user.c | 1 + security/selinux/include/av_perm_to_string.h | 3 +-- security/selinux/include/av_permissions.h | 3 +-- security/selinux/xfrm.c | 8 +------- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 92e2b80..ac87a09 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -802,6 +802,7 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr excl = nlh->nlmsg_type == XFRM_MSG_NEWPOLICY; err = xfrm_policy_insert(p->dir, xp, excl); if (err) { + security_xfrm_policy_free(xp); kfree(xp); return err; } diff --git a/security/selinux/include/av_perm_to_string.h b/security/selinux/include/av_perm_to_string.h index 71aeb12..591e98d 100644 --- a/security/selinux/include/av_perm_to_string.h +++ b/security/selinux/include/av_perm_to_string.h @@ -238,5 +238,4 @@ S_(SECCLASS_NSCD, NSCD__SHMEMHOST, "shmemhost") S_(SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO, "sendto") S_(SECCLASS_ASSOCIATION, ASSOCIATION__RECVFROM, "recvfrom") - S_(SECCLASS_ASSOCIATION, ASSOCIATION__RELABELFROM, "relabelfrom") - S_(SECCLASS_ASSOCIATION, ASSOCIATION__RELABELTO, "relabelto") + S_(SECCLASS_ASSOCIATION, ASSOCIATION__SETCONTEXT, "setcontext") diff --git a/security/selinux/include/av_permissions.h b/security/selinux/include/av_permissions.h index d1d0996..d7f02ed 100644 --- a/security/selinux/include/av_permissions.h +++ b/security/selinux/include/av_permissions.h @@ -908,8 +908,7 @@ #define ASSOCIATION__SENDTO 0x00000001UL #define ASSOCIATION__RECVFROM 0x00000002UL -#define ASSOCIATION__RELABELFROM 0x00000004UL -#define ASSOCIATION__RELABELTO 0x00000008UL +#define ASSOCIATION__SETCONTEXT 0x00000004UL #define NETLINK_KOBJECT_UEVENT_SOCKET__IOCTL 0x00000001UL #define NETLINK_KOBJECT_UEVENT_SOCKET__READ 0x00000002UL diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c index c4d87d4..5b77765 100644 --- a/security/selinux/xfrm.c +++ b/security/selinux/xfrm.c @@ -137,15 +137,9 @@ static int selinux_xfrm_sec_ctx_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_us * Must be permitted to relabel from default socket type (process type) * to specified context */ - rc = avc_has_perm(tsec->sid, tsec->sid, - SECCLASS_ASSOCIATION, - ASSOCIATION__RELABELFROM, NULL); - if (rc) - goto out; - rc = avc_has_perm(tsec->sid, ctx->ctx_sid, SECCLASS_ASSOCIATION, - ASSOCIATION__RELABELTO, NULL); + ASSOCIATION__SETCONTEXT, NULL); if (rc) goto out; -- cgit v1.1 From 76ab608d86cf1ef5c5c46819b5733eb9f9f964f8 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Fri, 6 Jan 2006 13:24:29 -0800 Subject: [NET]: Endian-annotate struct iphdr And fix trivial warnings that emerged. Signed-off-by: Alexey Dobriyan Signed-off-by: David S. Miller --- include/linux/ip.h | 10 +++++----- net/ipv4/ip_fragment.c | 2 +- net/ipv4/ip_output.c | 4 ++-- net/ipv4/ipvs/ip_vs_xmit.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/ip.h b/include/linux/ip.h index 9e2eb9a..4b55cf1 100644 --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -90,14 +90,14 @@ struct iphdr { #error "Please fix " #endif __u8 tos; - __u16 tot_len; - __u16 id; - __u16 frag_off; + __be16 tot_len; + __be16 id; + __be16 frag_off; __u8 ttl; __u8 protocol; __u16 check; - __u32 saddr; - __u32 daddr; + __be32 saddr; + __be32 daddr; /*The options start here. */ }; diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index ce2b70c..2a8adda 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -383,7 +383,7 @@ out_nomem: */ static inline struct ipq *ip_find(struct iphdr *iph, u32 user) { - __u16 id = iph->id; + __be16 id = iph->id; __u32 saddr = iph->saddr; __u32 daddr = iph->daddr; __u8 protocol = iph->protocol; diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 71da318..8b1c9bd 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -418,7 +418,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) struct sk_buff *skb2; unsigned int mtu, hlen, left, len, ll_rs; int offset; - int not_last_frag; + __be16 not_last_frag; struct rtable *rt = (struct rtable*)skb->dst; int err = 0; @@ -1180,7 +1180,7 @@ int ip_push_pending_frames(struct sock *sk) struct ip_options *opt = NULL; struct rtable *rt = inet->cork.rt; struct iphdr *iph; - int df = 0; + __be16 df = 0; __u8 ttl; int err = 0; diff --git a/net/ipv4/ipvs/ip_vs_xmit.c b/net/ipv4/ipvs/ip_vs_xmit.c index 3b87482..52c12e9 100644 --- a/net/ipv4/ipvs/ip_vs_xmit.c +++ b/net/ipv4/ipvs/ip_vs_xmit.c @@ -322,7 +322,7 @@ ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, struct net_device *tdev; /* Device to other host */ struct iphdr *old_iph = skb->nh.iph; u8 tos = old_iph->tos; - u16 df = old_iph->frag_off; + __be16 df = old_iph->frag_off; struct iphdr *iph; /* Our new IP header */ int max_headroom; /* The extra header space needed */ int mtu; -- cgit v1.1 From a2167dc62e9142b9a4bfb20f7e001c0f0a26fd8c Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Fri, 6 Jan 2006 13:24:54 -0800 Subject: [NET]: Endian-annotate in_aton() Signed-off-by: Alexey Dobriyan Signed-off-by: David S. Miller --- include/linux/inet.h | 2 +- net/core/utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/inet.h b/include/linux/inet.h index 3b5e9fd..6c5587a 100644 --- a/include/linux/inet.h +++ b/include/linux/inet.h @@ -45,6 +45,6 @@ #ifdef __KERNEL__ #include -extern __u32 in_aton(const char *str); +extern __be32 in_aton(const char *str); #endif #endif /* _LINUX_INET_H */ diff --git a/net/core/utils.c b/net/core/utils.c index 587eb77..ac1d1fc 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -162,7 +162,7 @@ EXPORT_SYMBOL(net_srandom); * is otherwise not dependent on the TCP/IP stack. */ -__u32 in_aton(const char *str) +__be32 in_aton(const char *str) { unsigned long l; unsigned int val; -- cgit v1.1 From c0e7dcc8bc01d7ea1865e7040a586207d1b34b36 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 6 Jan 2006 18:26:29 +0100 Subject: [PATCH] MAINTAINERS: remove the outdated DAC960 entry Randy Dunlap: "Dave is no longer at OSDL and is no longer maintaining that driver." Signed-off-by: Adrian Bunk Signed-off-by: Linus Torvalds --- MAINTAINERS | 7 ------- 1 file changed, 7 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index cb536bb..08e2dcf 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -696,13 +696,6 @@ M: pc300@cyclades.com W: http://www.cyclades.com/ S: Supported -DAC960 RAID CONTROLLER DRIVER -P: Dave Olien -M dmo@osdl.org -W: http://www.osdl.org/archive/dmo/DAC960 -L: linux-kernel@vger.kernel.org -S: Maintained - DAMA SLAVE for AX.25 P: Joerg Reuter M: jreuter@yaina.de -- cgit v1.1 From 76832c28de4fabbf32fe1e5a25194724a3430070 Mon Sep 17 00:00:00 2001 From: Dimitri Sivanich Date: Fri, 6 Jan 2006 11:33:41 -0600 Subject: [PATCH] shrink mmtimer memory size This greatly reduces the amount of memory used by mmtimer on smaller machines with large values of MAX_COMPACT_NODES. Signed-off-by: Dimitri Sivanich Signed-off-by: Christoph Lameter Signed-off-by: Linus Torvalds --- drivers/char/mmtimer.c | 90 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index 78c89a3..c923781 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c @@ -1,11 +1,11 @@ /* - * Intel Multimedia Timer device implementation for SGI SN platforms. + * Timer device implementation for SGI SN platforms. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * - * Copyright (c) 2001-2004 Silicon Graphics, Inc. All rights reserved. + * Copyright (c) 2001-2006 Silicon Graphics, Inc. All rights reserved. * * This driver exports an API that should be supportable by any HPET or IA-PC * multimedia timer. The code below is currently specific to the SGI Altix @@ -45,7 +45,7 @@ MODULE_LICENSE("GPL"); /* name of the device, usually in /dev */ #define MMTIMER_NAME "mmtimer" #define MMTIMER_DESC "SGI Altix RTC Timer" -#define MMTIMER_VERSION "2.0" +#define MMTIMER_VERSION "2.1" #define RTC_BITS 55 /* 55 bits for this implementation */ @@ -227,10 +227,7 @@ typedef struct mmtimer { struct tasklet_struct tasklet; } mmtimer_t; -/* - * Total number of comparators is comparators/node * MAX nodes/running kernel - */ -static mmtimer_t timers[NUM_COMPARATORS*MAX_COMPACT_NODES]; +static mmtimer_t ** timers; /** * mmtimer_ioctl - ioctl interface for /dev/mmtimer @@ -441,29 +438,29 @@ static irqreturn_t mmtimer_interrupt(int irq, void *dev_id, struct pt_regs *regs) { int i; - mmtimer_t *base = timers + cpu_to_node(smp_processor_id()) * - NUM_COMPARATORS; unsigned long expires = 0; int result = IRQ_NONE; + unsigned indx = cpu_to_node(smp_processor_id()); /* * Do this once for each comparison register */ for (i = 0; i < NUM_COMPARATORS; i++) { + mmtimer_t *base = timers[indx] + i; /* Make sure this doesn't get reused before tasklet_sched */ - spin_lock(&base[i].lock); - if (base[i].cpu == smp_processor_id()) { - if (base[i].timer) - expires = base[i].timer->it.mmtimer.expires; + spin_lock(&base->lock); + if (base->cpu == smp_processor_id()) { + if (base->timer) + expires = base->timer->it.mmtimer.expires; /* expires test won't work with shared irqs */ if ((mmtimer_int_pending(i) > 0) || (expires && (expires < rtc_time()))) { mmtimer_clr_int_pending(i); - tasklet_schedule(&base[i].tasklet); + tasklet_schedule(&base->tasklet); result = IRQ_HANDLED; } } - spin_unlock(&base[i].lock); + spin_unlock(&base->lock); expires = 0; } return result; @@ -523,7 +520,7 @@ static int sgi_timer_del(struct k_itimer *timr) { int i = timr->it.mmtimer.clock; cnodeid_t nodeid = timr->it.mmtimer.node; - mmtimer_t *t = timers + nodeid * NUM_COMPARATORS +i; + mmtimer_t *t = timers[nodeid] + i; unsigned long irqflags; if (i != TIMER_OFF) { @@ -609,11 +606,11 @@ static int sgi_timer_set(struct k_itimer *timr, int flags, preempt_disable(); nodeid = cpu_to_node(smp_processor_id()); - base = timers + nodeid * NUM_COMPARATORS; retry: /* Don't use an allocated timer, or a deleted one that's pending */ for(i = 0; i< NUM_COMPARATORS; i++) { - if (!base[i].timer && !base[i].tasklet.state) { + base = timers[nodeid] + i; + if (!base->timer && !base->tasklet.state) { break; } } @@ -623,14 +620,14 @@ retry: return -EBUSY; } - spin_lock_irqsave(&base[i].lock, irqflags); + spin_lock_irqsave(&base->lock, irqflags); - if (base[i].timer || base[i].tasklet.state != 0) { - spin_unlock_irqrestore(&base[i].lock, irqflags); + if (base->timer || base->tasklet.state != 0) { + spin_unlock_irqrestore(&base->lock, irqflags); goto retry; } - base[i].timer = timr; - base[i].cpu = smp_processor_id(); + base->timer = timr; + base->cpu = smp_processor_id(); timr->it.mmtimer.clock = i; timr->it.mmtimer.node = nodeid; @@ -645,11 +642,11 @@ retry: } } else { timr->it.mmtimer.expires -= period; - if (reschedule_periodic_timer(base+i)) + if (reschedule_periodic_timer(base)) err = -EINVAL; } - spin_unlock_irqrestore(&base[i].lock, irqflags); + spin_unlock_irqrestore(&base->lock, irqflags); preempt_enable(); @@ -675,6 +672,7 @@ static struct k_clock sgi_clock = { static int __init mmtimer_init(void) { unsigned i; + cnodeid_t node, maxn = -1; if (!ia64_platform_is("sn2")) return -1; @@ -691,14 +689,6 @@ static int __init mmtimer_init(void) mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second / 2) / sn_rtc_cycles_per_second; - for (i=0; i< NUM_COMPARATORS*MAX_COMPACT_NODES; i++) { - spin_lock_init(&timers[i].lock); - timers[i].timer = NULL; - timers[i].cpu = 0; - timers[i].i = i % NUM_COMPARATORS; - tasklet_init(&timers[i].tasklet, mmtimer_tasklet, (unsigned long) (timers+i)); - } - if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, SA_PERCPU_IRQ, MMTIMER_NAME, NULL)) { printk(KERN_WARNING "%s: unable to allocate interrupt.", MMTIMER_NAME); @@ -712,6 +702,40 @@ static int __init mmtimer_init(void) return -1; } + /* Get max numbered node, calculate slots needed */ + for_each_online_node(node) { + maxn = node; + } + maxn++; + + /* Allocate list of node ptrs to mmtimer_t's */ + timers = kmalloc(sizeof(mmtimer_t *)*maxn, GFP_KERNEL); + if (timers == NULL) { + printk(KERN_ERR "%s: failed to allocate memory for device\n", + MMTIMER_NAME); + return -1; + } + + /* Allocate mmtimer_t's for each online node */ + for_each_online_node(node) { + timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node); + if (timers[node] == NULL) { + printk(KERN_ERR "%s: failed to allocate memory for device\n", + MMTIMER_NAME); + return -1; + } + for (i=0; i< NUM_COMPARATORS; i++) { + mmtimer_t * base = timers[node] + i; + + spin_lock_init(&base->lock); + base->timer = NULL; + base->cpu = 0; + base->i = i; + tasklet_init(&base->tasklet, mmtimer_tasklet, + (unsigned long) (base)); + } + } + sgi_clock_period = sgi_clock.res = NSEC_PER_SEC / sn_rtc_cycles_per_second; register_posix_clock(CLOCK_SGI_CYCLE, &sgi_clock); -- cgit v1.1 From 221fc10ec89834329e5613e3cab4569ba22da410 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Fri, 6 Jan 2006 21:18:01 +0300 Subject: [PATCH] fs/ufs: debug mode compilation failure This patch should fix compilation failure of fs/ufs/dir.c with defined UFS_DIR_DEBUG Signed-off-by: Evgeniy Dushistov Signed-off-by: Linus Torvalds --- fs/ufs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index d0915fb..7c10c68 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -491,7 +491,7 @@ int ufs_delete_entry (struct inode * inode, struct ufs_dir_entry * dir, UFSD(("ino %u, reclen %u, namlen %u, name %s\n", fs32_to_cpu(sb, de->d_ino), - fs16to_cpu(sb, de->d_reclen), + fs16_to_cpu(sb, de->d_reclen), ufs_get_de_namlen(sb, de), de->d_name)) while (i < bh->b_size) { -- cgit v1.1 From 0aec63e67c69545ca757a73a66f5dcf05fa484bf Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Fri, 6 Jan 2006 15:36:48 -0800 Subject: [PATCH] Fix posix-cpu-timers sched_time accumulation I've spent the past 3 days digging into a glibc testsuite failure in current CVS, specifically libc/rt/tst-cputimer1.c The thr1 and thr2 timers fire too early in the second pass of this test. The second pass is noteworthy because it makes use of intervals, whereas the first pass does not. All throughout the posix-cpu-timers.c code, the calculation of the process sched_time sum is implemented roughly as: unsigned long long sum; sum = tsk->signal->sched_time; t = tsk; do { sum += t->sched_time; t = next_thread(t); } while (t != tsk); In fact this is the exact scheme used by check_process_timers(). In the case of check_process_timers(), current->sched_time has just been updated (via scheduler_tick(), which is invoked by update_process_times(), which subsequently invokes run_posix_cpu_timers()) So there is no special processing necessary wrt. that. In other contexts, we have to allot for the fact that tsk->sched_time might be a bit out of date if we are current. And the posix-cpu-timers.c code uses current_sched_time() to deal with that. Unfortunately it does so in an erroneous and inconsistent manner in one spot which is what results in the early timer firing. In cpu_clock_sample_group_locked(), it does this: cpu->sched = p->signal->sched_time; /* Add in each other live thread. */ while ((t = next_thread(t)) != p) { cpu->sched += t->sched_time; } if (p->tgid == current->tgid) { /* * We're sampling ourselves, so include the * cycles not yet banked. We still omit * other threads running on other CPUs, * so the total can always be behind as * much as max(nthreads-1,ncpus) * (NSEC_PER_SEC/HZ). */ cpu->sched += current_sched_time(current); } else { cpu->sched += p->sched_time; } The problem is the "p->tgid == current->tgid" test. If "p" is not current, and the tgids are the same, we will add the process t->sched_time twice into cpu->sched and omit "p"'s sched_time which is very very very wrong. posix-cpu-timers.c has a helper function, sched_ns(p) which takes care of this, so my fix is to use that here instead of this special tgid test. The fact that current can be one of the sub-threads of "p" points out that we could make things a little bit more accurate, perhaps by using sched_ns() on every thread we process in these loops. It also points out that we don't use the most accurate value for threads in the group actively running other cpus (and this is mentioned in the comment). But that is a future enhancement, and this fix here definitely makes sense. Signed-off-by: David S. Miller Signed-off-by: Linus Torvalds --- kernel/posix-cpu-timers.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index cae4f57..4c68edf 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c @@ -238,18 +238,7 @@ static int cpu_clock_sample_group_locked(unsigned int clock_idx, while ((t = next_thread(t)) != p) { cpu->sched += t->sched_time; } - if (p->tgid == current->tgid) { - /* - * We're sampling ourselves, so include the - * cycles not yet banked. We still omit - * other threads running on other CPUs, - * so the total can always be behind as - * much as max(nthreads-1,ncpus) * (NSEC_PER_SEC/HZ). - */ - cpu->sched += current_sched_time(current); - } else { - cpu->sched += p->sched_time; - } + cpu->sched += sched_ns(p); break; } return 0; -- cgit v1.1